diff --git a/Makefile b/Makefile
index 5f03d7212a0c..60639f908b98 100644
--- a/Makefile
+++ b/Makefile
@@ -176,7 +176,9 @@ TGTS=	all all-man buildenv buildenvvars buildetc buildkernel buildworld \
 	builddtb xdev xdev-build xdev-install \
 	xdev-links native-xtools native-xtools-install stageworld stagekernel \
 	stage-packages stage-packages-kernel stage-packages-world stage-packages-source \
-	create-packages-world create-packages-kernel create-packages-source create-packages \
+	create-packages-world create-packages-kernel \
+	create-packages-kernel-repo create-packages-world-repo \
+	create-packages-source create-packages \
 	update-packages packages installconfig real-packages real-update-packages \
 	sign-packages package-pkg print-dir test-system-compiler test-system-linker \
 	test-includes
diff --git a/Makefile.inc1 b/Makefile.inc1
index d317e3acdd7f..935421ea3b9a 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -550,17 +550,23 @@ MAJOR_REVISION=	${_REVISION:R}
 _PKG_REVISION=	${_REVISION}
 _STRTIMENOW=	%Y%m%d%H%M%S
 _TIMENOW=	${_STRTIMENOW:gmtime}
+BRANCH_EXT=
 .if ${_BRANCH:MCURRENT*} || ${_BRANCH:MSTABLE*} || ${_BRANCH:MPRERELEASE*}
 _PKG_REVISION=	${MAJOR_REVISION}
-EXTRA_REVISION=	.snap${_TIMENOW}
+BRANCH_EXT=	snap
+EXTRA_REVISION=	.${BRANCH_EXT}${_TIMENOW}
 .elif ${_BRANCH:MALPHA*}
-EXTRA_REVISION=	.a${_BRANCH:C/ALPHA([0-9]+).*/\1/}.${_TIMENOW}
+BRANCH_EXT=	a${_BRANCH:C/ALPHA([0-9]+).*/\1/}
+EXTRA_REVISION=	.${BRANCH_EXT}.${_TIMENOW}
 .elif ${_BRANCH:MBETA*}
-EXTRA_REVISION=	.b${_BRANCH:C/BETA([0-9]+).*/\1/}.${_TIMENOW}
+BRANCH_EXT=	b${_BRANCH:C/BETA([0-9]+).*/\1/}
+EXTRA_REVISION=	.${BRANCH_EXT}.${_TIMENOW}
 .elif ${_BRANCH:MRC*}
-EXTRA_REVISION=	.rc${_BRANCH:C/RC([0-9]+).*/\1/}.${_TIMENOW}
+BRANCH_EXT=	rc${_BRANCH:C/RC([0-9]+).*/\1/}
+EXTRA_REVISION=	.${BRANCH_EXT}.${_TIMENOW}
 .elif ${_BRANCH:M*-p*}
-EXTRA_REVISION=	p${_BRANCH:C/.*-p([0-9]+$)/\1/}
+BRANCH_EXT=	p${_BRANCH:C/.*-p([0-9]+$)/\1/}
+EXTRA_REVISION=	${BRANCH_EXT}
 .endif
 PKG_VERSION:=	${_PKG_REVISION}${EXTRA_REVISION:C/[[:space:]]//g}
 .endif
@@ -1995,9 +2001,11 @@ PKG_EXT=	pkg
 .if exists(${REPODIR}/${PKG_ABI})
 PKG_VERSION_FROM!=/usr/bin/readlink ${REPODIR}/${PKG_ABI}/latest
 PKG_VERSION_FROM_DIR=	${REPODIR}/${PKG_ABI}/${PKG_VERSION_FROM}
+BRANCH_EXT_FROM=	${PKG_VERSION_FROM:C/.*([[:alpha:]][^\.]*).*/\1/}
 .else
 PKG_VERSION_FROM=
 PKG_VERSION_FROM_DIR=
+BRANCH_EXT_FROM=
 .endif
 .endif
 .endif
@@ -2035,7 +2043,7 @@ real-update-packages: stage-packages .PHONY
 	    continue; \
 	  fi ; \
 	  newsum=$$(pkg query -F ${REPODIR}/${PKG_ABI}/${PKG_VERSION}/$${newpkgname} '%X') ; \
-	  if [ "$${oldsum}" == "$${newsum}" ]; then \
+	  if [ "${BRANCH_EXT_FROM}" == "${BRANCH_EXT}" -a "$${oldsum}" == "$${newsum}" ]; then \
 	   echo "==> Keeping old ${PKG_NAME_PREFIX}-$${pkgname}-${PKG_VERSION_FROM}.${PKG_EXT}" ; \
 	   rm ${REPODIR}/${PKG_ABI}/${PKG_VERSION}/$${newpkgname} ; \
 	   cp $${pkg} ${REPODIR}/${PKG_ABI}/${PKG_VERSION} ; \
@@ -2079,6 +2087,10 @@ create-packages-kernel:	_pkgbootstrap _repodir .PHONY
 			SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \
 			create-kernel-packages
 
+create-packages-kernel-repo: .PHONY create-packages-kernel sign-packages
+
+create-packages-world-repo: .PHONY create-packages-world sign-packages
+
 create-packages-source:	_pkgbootstrap _repodir .PHONY
 	${_+_}@cd ${.CURDIR}; \
 		${MAKE} -f Makefile.inc1 \
diff --git a/RELNOTES b/RELNOTES
index 1ec11c872d77..1ff7364f0ed5 100644
--- a/RELNOTES
+++ b/RELNOTES
@@ -10,6 +10,10 @@ newline.  Entries should be separated by a newline.
 
 Changes to this file should not be MFCed.
 
+c333758fca3e:
+	new MAC/do policy and mdo(1) utility which enables a user to
+	become another user without the requirement of setuid root.
+
 eeb04a736cb9:
 	date(1) now supports nanoseconds. For example:
 	`date -Ins` prints "2024-04-22T12:20:28,763742224+02:00" and
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l
index d50369bb57c9..756a48b9c45f 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l
@@ -407,7 +407,7 @@ if (yypcb->pcb_token != 0) {
 
 <S0>{RGX_FP}	yyerror("floating-point constants are not permitted\n");
 
-<S0>\"{RGX_STR}$ |
+<S0>\"{RGX_STR}$ xyerror(D_STR_NL, "newline encountered in string literal");
 <S3>\"{RGX_STR}$ xyerror(D_STR_NL, "newline encountered in string literal");
 
 <S0>\"{RGX_STR}\" |
diff --git a/cddl/usr.sbin/dtrace/tests/tools/dtest.sh b/cddl/usr.sbin/dtrace/tests/tools/dtest.sh
index d2f3dc4ed8df..a6634bea43a6 100755
--- a/cddl/usr.sbin/dtrace/tests/tools/dtest.sh
+++ b/cddl/usr.sbin/dtrace/tests/tools/dtest.sh
@@ -100,7 +100,7 @@ readonly STDOUT=$(mktemp)
 readonly TFILE=$(basename $1)
 readonly EXOUT=${TFILE}.out
 
-kldstat -q -m dtrace_test || kldload dtrace_test
+kldload -n dtrace_test
 cd $(dirname $1)
 runtest
 RESULT=$?
diff --git a/contrib/capsicum-test/capability-fd.cc b/contrib/capsicum-test/capability-fd.cc
index f255c6425cdd..0551d9bd81ef 100644
--- a/contrib/capsicum-test/capability-fd.cc
+++ b/contrib/capsicum-test/capability-fd.cc
@@ -1342,3 +1342,18 @@ TEST(Capability, NoBypassDACIfRoot) {
   close(fd);
   unlink(TmpFile("cap_root_owned"));
 }
+
+TEST(Capability, CheckIsEmpty) {
+  cap_rights_t rights;
+
+  cap_rights_init(&rights);
+  EXPECT_TRUE(cap_rights_is_empty(&rights));
+
+  size_t num_known = (sizeof(known_rights)/sizeof(known_rights[0]));
+  for (size_t ii = 0; ii < num_known; ii++) {
+    cap_rights_init(&rights, known_rights[ii].right);
+    EXPECT_FALSE(cap_rights_is_empty(&rights));
+    cap_rights_clear(&rights, known_rights[ii].right);
+    EXPECT_TRUE(cap_rights_is_empty(&rights));
+  }
+}
diff --git a/contrib/ee/ee.c b/contrib/ee/ee.c
index 072d26519f4c..2f122981dbe7 100644
--- a/contrib/ee/ee.c
+++ b/contrib/ee/ee.c
@@ -591,11 +591,11 @@ main(int argc, char *argv[])
 		{
 			wmove(com_win, 0, 0);
 			werase(com_win);
-			wprintw(com_win, ree_no_file_msg);
+			wprintw(com_win, "%s", ree_no_file_msg);
 			wrefresh(com_win);
 			edit_abort(0);
 		}
-		wprintw(com_win, no_file_string);
+		wprintw(com_win, "%s", no_file_string);
 		wrefresh(com_win);
 	}
 	else
@@ -615,7 +615,7 @@ main(int argc, char *argv[])
 			if (!nohighlight)
 				wstandout(info_win);
 			wmove(info_win, 5, 0);
-			wprintw(info_win, separator);
+			wprintw(info_win, "%s", separator);
 			wmove(info_win, 5, 5);
 			wprintw(info_win, "line %d col %d lines from top %d ", 
 			          curr_line->line_number, scr_horz, absolute_lin);
@@ -1668,7 +1668,7 @@ command_prompt(void)
 		if (result == 0)
 			wprintw(com_win, unkn_cmd_str, cmd_str);
 		else
-			wprintw(com_win, non_unique_cmd_msg);
+			wprintw(com_win, "%s", non_unique_cmd_msg);
 
 		wrefresh(com_win);
 
@@ -1744,7 +1744,7 @@ command(char *cmd_str1)
 		wmove(com_win, 0, 0);
 		wclrtoeol(com_win);
 		if (in_file_name == NULL)
-			wprintw(com_win, no_file_string);
+			wprintw(com_win, "%s", no_file_string);
 		else
 			wprintw(com_win, current_file_str, in_file_name);
 	}
@@ -2245,7 +2245,7 @@ get_file(char *file_name)
 		{
 			if ((errno == ENOTDIR) || (errno == EACCES) || (errno == EROFS) || (errno == ETXTBSY) || (errno == EFAULT))
 			{
-				wprintw(com_win, read_only_msg);
+				wprintw(com_win, "%s", read_only_msg);
 				ro_flag = TRUE;
 			}
 		}
@@ -2282,7 +2282,7 @@ get_file(char *file_name)
 		wclrtoeol(com_win);
 		wprintw(com_win, file_read_lines_msg, in_file_name, curr_line->line_number);
 		if (ro_flag)
-			wprintw(com_win, read_only_msg);
+			wprintw(com_win, "%s", read_only_msg);
 		wrefresh(com_win);
 	}
 	else if (can_read)	/* not input_file and file is non-zero size */
@@ -2400,7 +2400,7 @@ finish(void)
 	if ((file_name == NULL) || (*file_name == '\0'))
 	{
 		wmove(com_win, 0, 0);
-		wprintw(com_win, file_not_saved_msg);
+		wprintw(com_win, "%s", file_not_saved_msg);
 		wclrtoeol(com_win);
 		wrefresh(com_win);
 		clear_com_win = TRUE;
@@ -2577,7 +2577,7 @@ search(int display_message)
 	{
 		wmove(com_win, 0, 0);
 		wclrtoeol(com_win);
-		wprintw(com_win, searching_msg);
+		wprintw(com_win, "%s", searching_msg);
 		wrefresh(com_win);
 		clear_com_win = TRUE;
 	}
@@ -3378,7 +3378,7 @@ menu_op(struct menu_entries menu_list[])
 	{
 		wmove(com_win, 0, 0);
 		werase(com_win);
-		wprintw(com_win, menu_too_lrg_msg);
+		wprintw(com_win, "%s", menu_too_lrg_msg);
 		wrefresh(com_win);
 		clear_com_win = TRUE;
 		return(0);
@@ -3630,10 +3630,10 @@ paint_menu(struct menu_entries menu_list[], int max_width, int max_height,
 		{
 			if (list_size > 1)
 				wprintw(menu_win, "%c) ", item_alpha[min((counter - 1), max_alpha_char)]);
-			wprintw(menu_win, menu_list[counter].item_string);
+			wprintw(menu_win, "%s", menu_list[counter].item_string);
 		}
 		else
-			wprintw(menu_win, more_below_str);
+			wprintw(menu_win, "%s", more_below_str);
 	}
 	else
 	{
@@ -3663,7 +3663,7 @@ help(void)
 	wrefresh(help_win);
 	werase(com_win);
 	wmove(com_win, 0, 0);
-	wprintw(com_win, press_any_key_msg);
+	wprintw(com_win, "%s", press_any_key_msg);
 	wrefresh(com_win);
 	counter = wgetch(com_win);
 	if (counter == -1)
@@ -3790,7 +3790,7 @@ file_op(int arg)
 		if ((string == NULL) || (*string == '\0'))
 		{
 			wmove(com_win, 0, 0);
-			wprintw(com_win, file_not_saved_msg);
+			wprintw(com_win, "%s", file_not_saved_msg);
 			wclrtoeol(com_win);
 			wrefresh(com_win);
 			clear_com_win = TRUE;
@@ -3925,7 +3925,7 @@ Format(void)
 
 	wmove(com_win, 0, 0);
 	wclrtoeol(com_win);
-	wprintw(com_win, formatting_msg);
+	wprintw(com_win, "%s", formatting_msg);
 	wrefresh(com_win);
 
 /*
@@ -3971,7 +3971,7 @@ Format(void)
 
 	wmove(com_win, 0, 0);
 	wclrtoeol(com_win);
-	wprintw(com_win, formatting_msg);
+	wprintw(com_win, "%s", formatting_msg);
 	wrefresh(com_win);
 
 /*
@@ -4046,7 +4046,7 @@ Format(void)
 
 	wmove(com_win, 0, 0);
 	wclrtoeol(com_win);
-	wprintw(com_win, formatting_msg);
+	wprintw(com_win, "%s", formatting_msg);
 	wrefresh(com_win);
 
 /*
@@ -4270,7 +4270,7 @@ dump_ee_conf(void)
 
 	if (option == 0)
 	{
-		wprintw(com_win, conf_not_saved_msg);
+		wprintw(com_win, "%s", conf_not_saved_msg);
 		wrefresh(com_win);
 		return;
 	}
@@ -4293,7 +4293,7 @@ dump_ee_conf(void)
 	init_file = fopen(file_name, "w");
 	if (init_file == NULL)
 	{
-		wprintw(com_win, conf_dump_err_msg);
+		wprintw(com_win, "%s", conf_dump_err_msg);
 		wrefresh(com_win);
 		return;
 	}
@@ -4412,7 +4412,7 @@ spell_op(void)
 	command(shell_echo_msg);
 	adv_line();
 	wmove(com_win, 0, 0);
-	wprintw(com_win, spell_in_prog_msg);
+	wprintw(com_win, "%s", spell_in_prog_msg);
 	wrefresh(com_win);
 	command("<>!spell");	/* send contents of buffer to command 'spell' 
 				   and read the results back into the editor */
@@ -5000,7 +5000,7 @@ restrict_mode(void)
 		return(FALSE);
 
 	wmove(com_win, 0, 0);
-	wprintw(com_win, restricted_msg);
+	wprintw(com_win, "%s", restricted_msg);
 	wclrtoeol(com_win);
 	wrefresh(com_win);
 	clear_com_win = TRUE;
diff --git a/contrib/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp b/contrib/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp
index 1280bcd36de9..eb13cd40eb8a 100644
--- a/contrib/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/contrib/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp
@@ -67,6 +67,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/RISCVISAInfo.h"
 #include "llvm/Support/TimeProfiler.h"
 #include "llvm/Support/xxhash.h"
 #include "llvm/TargetParser/Triple.h"
@@ -1059,6 +1060,19 @@ void CodeGenModule::Release() {
     llvm::LLVMContext &Ctx = TheModule.getContext();
     getModule().addModuleFlag(llvm::Module::Error, "target-abi",
                               llvm::MDString::get(Ctx, ABIStr));
+
+    // Add the canonical ISA string as metadata so the backend can set the ELF
+    // attributes correctly. We use AppendUnique so LTO will keep all of the
+    // unique ISA strings that were linked together.
+    const std::vector<std::string> &Features =
+        getTarget().getTargetOpts().Features;
+    auto ParseResult = llvm::RISCVISAInfo::parseFeatures(
+        Arch == llvm::Triple::riscv64 ? 64 : 32, Features);
+    if (!errorToBool(ParseResult.takeError()))
+      getModule().addModuleFlag(
+          llvm::Module::AppendUnique, "riscv-isa",
+          llvm::MDNode::get(
+              Ctx, llvm::MDString::get(Ctx, (*ParseResult)->toString())));
   }
 
   if (CodeGenOpts.SanitizeCfiCrossDso) {
diff --git a/contrib/llvm-project/clang/lib/Driver/ToolChains/OpenBSD.cpp b/contrib/llvm-project/clang/lib/Driver/ToolChains/OpenBSD.cpp
index fd6aa4d7e684..00b6c520fcdd 100644
--- a/contrib/llvm-project/clang/lib/Driver/ToolChains/OpenBSD.cpp
+++ b/contrib/llvm-project/clang/lib/Driver/ToolChains/OpenBSD.cpp
@@ -371,7 +371,8 @@ std::string OpenBSD::getCompilerRT(const ArgList &Args, StringRef Component,
   if (Component == "builtins") {
     SmallString<128> Path(getDriver().SysRoot);
     llvm::sys::path::append(Path, "/usr/lib/libcompiler_rt.a");
-    return std::string(Path);
+    if (getVFS().exists(Path))
+      return std::string(Path);
   }
   SmallString<128> P(getDriver().ResourceDir);
   std::string CRTBasename =
diff --git a/contrib/llvm-project/clang/lib/Format/UnwrappedLineParser.cpp b/contrib/llvm-project/clang/lib/Format/UnwrappedLineParser.cpp
index a6eb18bb2b32..f70affb732a0 100644
--- a/contrib/llvm-project/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/contrib/llvm-project/clang/lib/Format/UnwrappedLineParser.cpp
@@ -2510,6 +2510,7 @@ bool UnwrappedLineParser::parseParens(TokenType AmpAmpTokenType) {
   assert(FormatTok->is(tok::l_paren) && "'(' expected.");
   auto *LeftParen = FormatTok;
   bool SeenEqual = false;
+  bool MightBeFoldExpr = false;
   const bool MightBeStmtExpr = Tokens->peekNextToken()->is(tok::l_brace);
   nextToken();
   do {
@@ -2521,7 +2522,7 @@ bool UnwrappedLineParser::parseParens(TokenType AmpAmpTokenType) {
         parseChildBlock();
       break;
     case tok::r_paren:
-      if (!MightBeStmtExpr && !Line->InMacroBody &&
+      if (!MightBeStmtExpr && !MightBeFoldExpr && !Line->InMacroBody &&
           Style.RemoveParentheses > FormatStyle::RPS_Leave) {
         const auto *Prev = LeftParen->Previous;
         const auto *Next = Tokens->peekNextToken();
@@ -2564,6 +2565,10 @@ bool UnwrappedLineParser::parseParens(TokenType AmpAmpTokenType) {
         parseBracedList();
       }
       break;
+    case tok::ellipsis:
+      MightBeFoldExpr = true;
+      nextToken();
+      break;
     case tok::equal:
       SeenEqual = true;
       if (Style.isCSharp() && FormatTok->is(TT_FatArrow))
diff --git a/contrib/llvm-project/clang/lib/Format/WhitespaceManager.cpp b/contrib/llvm-project/clang/lib/Format/WhitespaceManager.cpp
index df84f97a8e8a..7525e6ee650b 100644
--- a/contrib/llvm-project/clang/lib/Format/WhitespaceManager.cpp
+++ b/contrib/llvm-project/clang/lib/Format/WhitespaceManager.cpp
@@ -1466,7 +1466,7 @@ WhitespaceManager::CellDescriptions WhitespaceManager::getCells(unsigned Start,
                                                                 : Cell);
         // Go to the next non-comment and ensure there is a break in front
         const auto *NextNonComment = C.Tok->getNextNonComment();
-        while (NextNonComment->is(tok::comma))
+        while (NextNonComment && NextNonComment->is(tok::comma))
           NextNonComment = NextNonComment->getNextNonComment();
         auto j = i;
         while (Changes[j].Tok != NextNonComment && j < End)
diff --git a/contrib/llvm-project/clang/lib/Interpreter/IncrementalParser.cpp b/contrib/llvm-project/clang/lib/Interpreter/IncrementalParser.cpp
index 370bcbfee8b0..f5f32b9f3924 100644
--- a/contrib/llvm-project/clang/lib/Interpreter/IncrementalParser.cpp
+++ b/contrib/llvm-project/clang/lib/Interpreter/IncrementalParser.cpp
@@ -209,6 +209,10 @@ IncrementalParser::IncrementalParser(Interpreter &Interp,
   if (Err)
     return;
   CI->ExecuteAction(*Act);
+
+  if (getCodeGen())
+    CachedInCodeGenModule = GenModule();
+
   std::unique_ptr<ASTConsumer> IncrConsumer =
       std::make_unique<IncrementalASTConsumer>(Interp, CI->takeASTConsumer());
   CI->setASTConsumer(std::move(IncrConsumer));
@@ -224,11 +228,8 @@ IncrementalParser::IncrementalParser(Interpreter &Interp,
     return;                     // PTU.takeError();
   }
 
-  if (CodeGenerator *CG = getCodeGen()) {
-    std::unique_ptr<llvm::Module> M(CG->ReleaseModule());
-    CG->StartModule("incr_module_" + std::to_string(PTUs.size()),
-                    M->getContext());
-    PTU->TheModule = std::move(M);
+  if (getCodeGen()) {
+    PTU->TheModule = GenModule();
     assert(PTU->TheModule && "Failed to create initial PTU");
   }
 }
@@ -364,6 +365,19 @@ IncrementalParser::Parse(llvm::StringRef input) {
 std::unique_ptr<llvm::Module> IncrementalParser::GenModule() {
   static unsigned ID = 0;
   if (CodeGenerator *CG = getCodeGen()) {
+    // Clang's CodeGen is designed to work with a single llvm::Module. In many
+    // cases for convenience various CodeGen parts have a reference to the
+    // llvm::Module (TheModule or Module) which does not change when a new
+    // module is pushed. However, the execution engine wants to take ownership
+    // of the module which does not map well to CodeGen's design. To work this
+    // around we created an empty module to make CodeGen happy. We should make
+    // sure it always stays empty.
+    assert((!CachedInCodeGenModule ||
+            (CachedInCodeGenModule->empty() &&
+             CachedInCodeGenModule->global_empty() &&
+             CachedInCodeGenModule->alias_empty() &&
+             CachedInCodeGenModule->ifunc_empty())) &&
+           "CodeGen wrote to a readonly module");
     std::unique_ptr<llvm::Module> M(CG->ReleaseModule());
     CG->StartModule("incr_module_" + std::to_string(ID++), M->getContext());
     return M;
diff --git a/contrib/llvm-project/clang/lib/Interpreter/IncrementalParser.h b/contrib/llvm-project/clang/lib/Interpreter/IncrementalParser.h
index e13b74c7f659..f63bce50acd3 100644
--- a/contrib/llvm-project/clang/lib/Interpreter/IncrementalParser.h
+++ b/contrib/llvm-project/clang/lib/Interpreter/IncrementalParser.h
@@ -24,6 +24,7 @@
 #include <memory>
 namespace llvm {
 class LLVMContext;
+class Module;
 } // namespace llvm
 
 namespace clang {
@@ -57,6 +58,10 @@ class IncrementalParser {
   /// of code.
   std::list<PartialTranslationUnit> PTUs;
 
+  /// When CodeGen is created the first llvm::Module gets cached in many places
+  /// and we must keep it alive.
+  std::unique_ptr<llvm::Module> CachedInCodeGenModule;
+
   IncrementalParser();
 
 public:
diff --git a/contrib/llvm-project/clang/lib/Sema/SemaTemplate.cpp b/contrib/llvm-project/clang/lib/Sema/SemaTemplate.cpp
index b619f5d729e8..a12a64939c46 100644
--- a/contrib/llvm-project/clang/lib/Sema/SemaTemplate.cpp
+++ b/contrib/llvm-project/clang/lib/Sema/SemaTemplate.cpp
@@ -2404,9 +2404,6 @@ struct ConvertConstructorToDeductionGuideTransform {
       Args.addOuterRetainedLevel();
     }
 
-    if (NestedPattern)
-      Args.addOuterRetainedLevels(NestedPattern->getTemplateDepth());
-
     FunctionProtoTypeLoc FPTL = CD->getTypeSourceInfo()->getTypeLoc()
                                    .getAsAdjusted<FunctionProtoTypeLoc>();
     assert(FPTL && "no prototype for constructor declaration");
@@ -2526,11 +2523,27 @@ struct ConvertConstructorToDeductionGuideTransform {
 
     //    -- The types of the function parameters are those of the constructor.
     for (auto *OldParam : TL.getParams()) {
-      ParmVarDecl *NewParam =
-          transformFunctionTypeParam(OldParam, Args, MaterializedTypedefs);
-      if (NestedPattern && NewParam)
+      ParmVarDecl *NewParam = OldParam;
+      // Given
+      //   template <class T> struct C {
+      //     template <class U> struct D {
+      //       template <class V> D(U, V);
+      //     };
+      //   };
+      // First, transform all the references to template parameters that are
+      // defined outside of the surrounding class template. That is T in the
+      // above example.
+      if (NestedPattern) {
         NewParam = transformFunctionTypeParam(NewParam, OuterInstantiationArgs,
                                               MaterializedTypedefs);
+        if (!NewParam)
+          return QualType();
+      }
+      // Then, transform all the references to template parameters that are
+      // defined at the class template and the constructor. In this example,
+      // they're U and V, respectively.
+      NewParam =
+          transformFunctionTypeParam(NewParam, Args, MaterializedTypedefs);
       if (!NewParam)
         return QualType();
       ParamTypes.push_back(NewParam->getType());
diff --git a/contrib/llvm-project/libcxx/include/string b/contrib/llvm-project/libcxx/include/string
index ba169c3dbfc9..56e2ef09947f 100644
--- a/contrib/llvm-project/libcxx/include/string
+++ b/contrib/llvm-project/libcxx/include/string
@@ -1943,10 +1943,10 @@ private:
     if (__s < __min_cap) {
       return static_cast<size_type>(__min_cap) - 1;
     }
-    size_type __guess =
-        __align_it < sizeof(value_type) < __alignment ? __alignment / sizeof(value_type) : 1 > (__s + 1) - 1;
+    const size_type __boundary = sizeof(value_type) < __alignment ? __alignment / sizeof(value_type) : __endian_factor;
+    size_type __guess          = __align_it<__boundary>(__s + 1) - 1;
     if (__guess == __min_cap)
-      ++__guess;
+      __guess += __endian_factor;
     return __guess;
   }
 
diff --git a/contrib/llvm-project/libcxx/src/atomic.cpp b/contrib/llvm-project/libcxx/src/atomic.cpp
index 2f0389ae6974..6b1f03c21bbc 100644
--- a/contrib/llvm-project/libcxx/src/atomic.cpp
+++ b/contrib/llvm-project/libcxx/src/atomic.cpp
@@ -25,16 +25,28 @@
 #  if !defined(SYS_futex) && defined(SYS_futex_time64)
 #    define SYS_futex SYS_futex_time64
 #  endif
+#  define _LIBCPP_FUTEX(...) syscall(SYS_futex, __VA_ARGS__)
 
 #elif defined(__FreeBSD__)
 
 #  include <sys/types.h>
 #  include <sys/umtx.h>
 
+#  define _LIBCPP_FUTEX(...) syscall(SYS_futex, __VA_ARGS__)
+
+#elif defined(__OpenBSD__)
+
+#  include <sys/futex.h>
+
+// OpenBSD has no indirect syscalls
+#  define _LIBCPP_FUTEX(...) futex(__VA_ARGS__)
+
 #else // <- Add other operating systems here
 
 // Baseline needs no new headers
 
+#  define _LIBCPP_FUTEX(...) syscall(SYS_futex, __VA_ARGS__)
+
 #endif
 
 _LIBCPP_BEGIN_NAMESPACE_STD
@@ -44,11 +56,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 static void
 __libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr, __cxx_contention_t __val) {
   static constexpr timespec __timeout = {2, 0};
-  syscall(SYS_futex, __ptr, FUTEX_WAIT_PRIVATE, __val, &__timeout, 0, 0);
+  _LIBCPP_FUTEX(__ptr, FUTEX_WAIT_PRIVATE, __val, &__timeout, 0, 0);
 }
 
 static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile* __ptr, bool __notify_one) {
-  syscall(SYS_futex, __ptr, FUTEX_WAKE_PRIVATE, __notify_one ? 1 : INT_MAX, 0, 0, 0);
+  _LIBCPP_FUTEX(__ptr, FUTEX_WAKE_PRIVATE, __notify_one ? 1 : INT_MAX, 0, 0, 0);
 }
 
 #elif defined(__APPLE__) && defined(_LIBCPP_USE_ULOCK)
diff --git a/contrib/llvm-project/libcxx/src/chrono.cpp b/contrib/llvm-project/libcxx/src/chrono.cpp
index c5e827c0cb59..e7d6dfbc2292 100644
--- a/contrib/llvm-project/libcxx/src/chrono.cpp
+++ b/contrib/llvm-project/libcxx/src/chrono.cpp
@@ -31,7 +31,9 @@
 #  include <sys/time.h> // for gettimeofday and timeval
 #endif
 
-#if defined(__APPLE__) || defined(__gnu_hurd__) || (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0)
+// OpenBSD does not have a fully conformant suite of POSIX timers, but
+// it does have clock_gettime and CLOCK_MONOTONIC which is all we need.
+#if defined(__APPLE__) || defined(__gnu_hurd__) || defined(__OpenBSD__) || (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0)
 #  define _LIBCPP_HAS_CLOCK_GETTIME
 #endif
 
diff --git a/contrib/llvm-project/lld/ELF/Relocations.cpp b/contrib/llvm-project/lld/ELF/Relocations.cpp
index 619fbaf5dc54..92a1b9baaca3 100644
--- a/contrib/llvm-project/lld/ELF/Relocations.cpp
+++ b/contrib/llvm-project/lld/ELF/Relocations.cpp
@@ -1480,7 +1480,10 @@ template <class ELFT, class RelTy> void RelocationScanner::scanOne(RelTy *&i) {
 
   // Process TLS relocations, including TLS optimizations. Note that
   // R_TPREL and R_TPREL_NEG relocations are resolved in processAux.
-  if (sym.isTls()) {
+  //
+  // Some RISCV TLSDESC relocations reference a local NOTYPE symbol,
+  // but we need to process them in handleTlsRelocation.
+  if (sym.isTls() || oneof<R_TLSDESC_PC, R_TLSDESC_CALL>(expr)) {
     if (unsigned processed =
             handleTlsRelocation(type, sym, *sec, offset, addend, expr)) {
       i += processed - 1;
diff --git a/contrib/llvm-project/llvm/include/llvm/CodeGen/MachineFrameInfo.h b/contrib/llvm-project/llvm/include/llvm/CodeGen/MachineFrameInfo.h
index 7d11d63d4066..c35faac09c4d 100644
--- a/contrib/llvm-project/llvm/include/llvm/CodeGen/MachineFrameInfo.h
+++ b/contrib/llvm-project/llvm/include/llvm/CodeGen/MachineFrameInfo.h
@@ -697,6 +697,13 @@ class MachineFrameInfo {
     return Objects[ObjectIdx+NumFixedObjects].isAliased;
   }
 
+  /// Set "maybe pointed to by an LLVM IR value" for an object.
+  void setIsAliasedObjectIndex(int ObjectIdx, bool IsAliased) {
+    assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
+           "Invalid Object Idx!");
+    Objects[ObjectIdx+NumFixedObjects].isAliased = IsAliased;
+  }
+
   /// Returns true if the specified index corresponds to an immutable object.
   bool isImmutableObjectIndex(int ObjectIdx) const {
     // Tail calling functions can clobber their function arguments.
diff --git a/contrib/llvm-project/llvm/lib/Analysis/InstructionSimplify.cpp b/contrib/llvm-project/llvm/lib/Analysis/InstructionSimplify.cpp
index 72b6dfa181e8..8dcffe45c644 100644
--- a/contrib/llvm-project/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/contrib/llvm-project/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -4322,6 +4322,10 @@ static Value *simplifyWithOpReplaced(Value *V, Value *Op, Value *RepOp,
   if (match(I, m_Intrinsic<Intrinsic::is_constant>()))
     return nullptr;
 
+  // Don't simplify freeze.
+  if (isa<FreezeInst>(I))
+    return nullptr;
+
   // Replace Op with RepOp in instruction operands.
   SmallVector<Value *, 8> NewOps;
   bool AnyReplaced = false;
diff --git a/contrib/llvm-project/llvm/lib/CodeGen/InterleavedLoadCombinePass.cpp b/contrib/llvm-project/llvm/lib/CodeGen/InterleavedLoadCombinePass.cpp
index f2d5c3c867c2..bbb0b654dc67 100644
--- a/contrib/llvm-project/llvm/lib/CodeGen/InterleavedLoadCombinePass.cpp
+++ b/contrib/llvm-project/llvm/lib/CodeGen/InterleavedLoadCombinePass.cpp
@@ -877,6 +877,9 @@ struct VectorInfo {
     if (LI->isAtomic())
       return false;
 
+    if (!DL.typeSizeEqualsStoreSize(Result.VTy->getElementType()))
+      return false;
+
     // Get the base polynomial
     computePolynomialFromPointer(*LI->getPointerOperand(), Offset, BasePtr, DL);
 
diff --git a/contrib/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/contrib/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 5ce1013f30fd..7406a8ac1611 100644
--- a/contrib/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/contrib/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -10888,7 +10888,7 @@ static void tryToElideArgumentCopy(
   }
 
   // Perform the elision. Delete the old stack object and replace its only use
-  // in the variable info map. Mark the stack object as mutable.
+  // in the variable info map. Mark the stack object as mutable and aliased.
   LLVM_DEBUG({
     dbgs() << "Eliding argument copy from " << Arg << " to " << *AI << '\n'
            << "  Replacing frame index " << OldIndex << " with " << FixedIndex
@@ -10896,6 +10896,7 @@ static void tryToElideArgumentCopy(
   });
   MFI.RemoveStackObject(OldIndex);
   MFI.setIsImmutableObjectIndex(FixedIndex, false);
+  MFI.setIsAliasedObjectIndex(FixedIndex, true);
   AllocaIndex = FixedIndex;
   ArgCopyElisionFrameIndexMap.insert({OldIndex, FixedIndex});
   for (SDValue ArgVal : ArgVals)
diff --git a/contrib/llvm-project/llvm/lib/Target/AArch64/AArch64Arm64ECCallLowering.cpp b/contrib/llvm-project/llvm/lib/Target/AArch64/AArch64Arm64ECCallLowering.cpp
index 55c5bbc66a3f..862aefe46193 100644
--- a/contrib/llvm-project/llvm/lib/Target/AArch64/AArch64Arm64ECCallLowering.cpp
+++ b/contrib/llvm-project/llvm/lib/Target/AArch64/AArch64Arm64ECCallLowering.cpp
@@ -181,13 +181,14 @@ void AArch64Arm64ECCallLowering::getThunkArgTypes(
   }
 
   for (unsigned E = FT->getNumParams(); I != E; ++I) {
-    Align ParamAlign = AttrList.getParamAlignment(I).valueOrOne();
 #if 0
     // FIXME: Need more information about argument size; see
     // https://reviews.llvm.org/D132926
     uint64_t ArgSizeBytes = AttrList.getParamArm64ECArgSizeBytes(I);
+    Align ParamAlign = AttrList.getParamAlignment(I).valueOrOne();
 #else
     uint64_t ArgSizeBytes = 0;
+    Align ParamAlign = Align();
 #endif
     Type *Arm64Ty, *X64Ty;
     canonicalizeThunkType(FT->getParamType(I), ParamAlign,
@@ -297,7 +298,7 @@ void AArch64Arm64ECCallLowering::canonicalizeThunkType(
     uint64_t TotalSizeBytes = ElementCnt * ElementSizePerBytes;
     if (ElementTy->isFloatTy() || ElementTy->isDoubleTy()) {
       Out << (ElementTy->isFloatTy() ? "F" : "D") << TotalSizeBytes;
-      if (Alignment.value() >= 8 && !T->isPointerTy())
+      if (Alignment.value() >= 16 && !Ret)
         Out << "a" << Alignment.value();
       Arm64Ty = T;
       if (TotalSizeBytes <= 8) {
@@ -328,7 +329,7 @@ void AArch64Arm64ECCallLowering::canonicalizeThunkType(
   Out << "m";
   if (TypeSize != 4)
     Out << TypeSize;
-  if (Alignment.value() >= 8 && !T->isPointerTy())
+  if (Alignment.value() >= 16 && !Ret)
     Out << "a" << Alignment.value();
   // FIXME: Try to canonicalize Arm64Ty more thoroughly?
   Arm64Ty = T;
@@ -513,7 +514,14 @@ Function *AArch64Arm64ECCallLowering::buildEntryThunk(Function *F) {
   // Call the function passed to the thunk.
   Value *Callee = Thunk->getArg(0);
   Callee = IRB.CreateBitCast(Callee, PtrTy);
-  Value *Call = IRB.CreateCall(Arm64Ty, Callee, Args);
+  CallInst *Call = IRB.CreateCall(Arm64Ty, Callee, Args);
+
+  auto SRetAttr = F->getAttributes().getParamAttr(0, Attribute::StructRet);
+  auto InRegAttr = F->getAttributes().getParamAttr(0, Attribute::InReg);
+  if (SRetAttr.isValid() && !InRegAttr.isValid()) {
+    Thunk->addParamAttr(1, SRetAttr);
+    Call->addParamAttr(0, SRetAttr);
+  }
 
   Value *RetVal = Call;
   if (TransformDirectToSRet) {
diff --git a/contrib/llvm-project/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/contrib/llvm-project/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 95d8ab95b2c0..bcfd0253e73c 100644
--- a/contrib/llvm-project/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/contrib/llvm-project/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -22122,7 +22122,8 @@ SDValue performCONDCombine(SDNode *N,
   SDNode *SubsNode = N->getOperand(CmpIndex).getNode();
   unsigned CondOpcode = SubsNode->getOpcode();
 
-  if (CondOpcode != AArch64ISD::SUBS || SubsNode->hasAnyUseOfValue(0))
+  if (CondOpcode != AArch64ISD::SUBS || SubsNode->hasAnyUseOfValue(0) ||
+      !SubsNode->hasOneUse())
     return SDValue();
 
   // There is a SUBS feeding this condition. Is it fed by a mask we can
diff --git a/contrib/llvm-project/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp b/contrib/llvm-project/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp
index 92db89cc0915..80fe4bcb8b58 100644
--- a/contrib/llvm-project/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp
+++ b/contrib/llvm-project/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp
@@ -147,6 +147,12 @@ void AArch64GISelUtils::changeFCMPPredToAArch64CC(
   case CmpInst::FCMP_UNE:
     CondCode = AArch64CC::NE;
     break;
+  case CmpInst::FCMP_TRUE:
+    CondCode = AArch64CC::AL;
+    break;
+  case CmpInst::FCMP_FALSE:
+    CondCode = AArch64CC::NV;
+    break;
   }
 }
 
diff --git a/contrib/llvm-project/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp b/contrib/llvm-project/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
index 4b9d549e7911..de3c89e925a2 100644
--- a/contrib/llvm-project/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
+++ b/contrib/llvm-project/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
@@ -877,6 +877,7 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
 
   getActionDefinitionsBuilder(G_INSERT_VECTOR_ELT)
       .legalIf(typeInSet(0, {v16s8, v8s8, v8s16, v4s16, v4s32, v2s32, v2s64}))
+      .moreElementsToNextPow2(0)
       .widenVectorEltsToVectorMinSize(0, 64);
 
   getActionDefinitionsBuilder(G_BUILD_VECTOR)
diff --git a/contrib/llvm-project/llvm/lib/Target/AArch64/GISel/AArch64RegisterBankInfo.cpp b/contrib/llvm-project/llvm/lib/Target/AArch64/GISel/AArch64RegisterBankInfo.cpp
index b8e5e7bbdaba..06cdd7e4ef48 100644
--- a/contrib/llvm-project/llvm/lib/Target/AArch64/GISel/AArch64RegisterBankInfo.cpp
+++ b/contrib/llvm-project/llvm/lib/Target/AArch64/GISel/AArch64RegisterBankInfo.cpp
@@ -623,8 +623,11 @@ bool AArch64RegisterBankInfo::isLoadFromFPType(const MachineInstr &MI) const {
     EltTy = GV->getValueType();
     // Look at the first element of the struct to determine the type we are
     // loading
-    while (StructType *StructEltTy = dyn_cast<StructType>(EltTy))
+    while (StructType *StructEltTy = dyn_cast<StructType>(EltTy)) {
+      if (StructEltTy->getNumElements() == 0)
+        break;
       EltTy = StructEltTy->getTypeAtIndex(0U);
+    }
     // Look at the first element of the array to determine its type
     if (isa<ArrayType>(EltTy))
       EltTy = EltTy->getArrayElementType();
diff --git a/contrib/llvm-project/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp b/contrib/llvm-project/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
index 6ecb1c8bf6e1..7a3198612f86 100644
--- a/contrib/llvm-project/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
+++ b/contrib/llvm-project/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
@@ -1832,7 +1832,7 @@ bool SIInsertWaitcnts::generateWaitcntInstBefore(MachineInstr &MI,
   // not, we need to ensure the subtarget is capable of backing off barrier
   // instructions in case there are any outstanding memory operations that may
   // cause an exception. Otherwise, insert an explicit S_WAITCNT 0 here.
-  if (MI.getOpcode() == AMDGPU::S_BARRIER &&
+  if (TII->isBarrierStart(MI.getOpcode()) &&
       !ST->hasAutoWaitcntBeforeBarrier() && !ST->supportsBackOffBarrier()) {
     Wait = Wait.combined(
         AMDGPU::Waitcnt::allZero(ST->hasExtendedWaitCounts(), ST->hasVscnt()));
diff --git a/contrib/llvm-project/llvm/lib/Target/AMDGPU/SIInstrInfo.h b/contrib/llvm-project/llvm/lib/Target/AMDGPU/SIInstrInfo.h
index 1c9dacc09f81..626d903c0c69 100644
--- a/contrib/llvm-project/llvm/lib/Target/AMDGPU/SIInstrInfo.h
+++ b/contrib/llvm-project/llvm/lib/Target/AMDGPU/SIInstrInfo.h
@@ -908,6 +908,17 @@ class SIInstrInfo final : public AMDGPUGenInstrInfo {
     return MI.getDesc().TSFlags & SIInstrFlags::IsNeverUniform;
   }
 
+  // Check to see if opcode is for a barrier start. Pre gfx12 this is just the
+  // S_BARRIER, but after support for S_BARRIER_SIGNAL* / S_BARRIER_WAIT we want
+  // to check for the barrier start (S_BARRIER_SIGNAL*)
+  bool isBarrierStart(unsigned Opcode) const {
+    return Opcode == AMDGPU::S_BARRIER ||
+           Opcode == AMDGPU::S_BARRIER_SIGNAL_M0 ||
+           Opcode == AMDGPU::S_BARRIER_SIGNAL_ISFIRST_M0 ||
+           Opcode == AMDGPU::S_BARRIER_SIGNAL_IMM ||
+           Opcode == AMDGPU::S_BARRIER_SIGNAL_ISFIRST_IMM;
+  }
+
   static bool doesNotReadTiedSource(const MachineInstr &MI) {
     return MI.getDesc().TSFlags & SIInstrFlags::TiedSourceNotRead;
   }
diff --git a/contrib/llvm-project/llvm/lib/Target/AMDGPU/SOPInstructions.td b/contrib/llvm-project/llvm/lib/Target/AMDGPU/SOPInstructions.td
index ae5ef0541929..5762efde73f0 100644
--- a/contrib/llvm-project/llvm/lib/Target/AMDGPU/SOPInstructions.td
+++ b/contrib/llvm-project/llvm/lib/Target/AMDGPU/SOPInstructions.td
@@ -1786,7 +1786,7 @@ def : GCNPat<
 let SubtargetPredicate = isNotGFX12Plus in
   def : GCNPat <(int_amdgcn_s_wait_event_export_ready), (S_WAIT_EVENT (i16 0))>;
 let SubtargetPredicate = isGFX12Plus in
-  def : GCNPat <(int_amdgcn_s_wait_event_export_ready), (S_WAIT_EVENT (i16 1))>;
+  def : GCNPat <(int_amdgcn_s_wait_event_export_ready), (S_WAIT_EVENT (i16 2))>;
 
 // The first 10 bits of the mode register are the core FP mode on all
 // subtargets.
diff --git a/contrib/llvm-project/llvm/lib/Target/PowerPC/PPCMergeStringPool.cpp b/contrib/llvm-project/llvm/lib/Target/PowerPC/PPCMergeStringPool.cpp
index d9465e86d896..0830b02370cd 100644
--- a/contrib/llvm-project/llvm/lib/Target/PowerPC/PPCMergeStringPool.cpp
+++ b/contrib/llvm-project/llvm/lib/Target/PowerPC/PPCMergeStringPool.cpp
@@ -23,6 +23,7 @@
 #include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/Instructions.h"
+#include "llvm/IR/IntrinsicInst.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/ValueSymbolTable.h"
 #include "llvm/Pass.h"
@@ -116,9 +117,20 @@ class PPCMergeStringPool : public ModulePass {
 // sure that they can be replaced.
 static bool hasReplaceableUsers(GlobalVariable &GV) {
   for (User *CurrentUser : GV.users()) {
-    // Instruction users are always valid.
-    if (isa<Instruction>(CurrentUser))
+    if (auto *I = dyn_cast<Instruction>(CurrentUser)) {
+      // Do not merge globals in exception pads.
+      if (I->isEHPad())
+        return false;
+
+      if (auto *II = dyn_cast<IntrinsicInst>(I)) {
+        // Some intrinsics require a plain global.
+        if (II->getIntrinsicID() == Intrinsic::eh_typeid_for)
+          return false;
+      }
+
+      // Other instruction users are always valid.
       continue;
+    }
 
     // We cannot replace GlobalValue users because they are not just nodes
     // in IR. To replace a user like this we would need to create a new
@@ -278,13 +290,6 @@ bool PPCMergeStringPool::mergeModuleStringPool(Module &M) {
   return true;
 }
 
-static bool userHasOperand(User *TheUser, GlobalVariable *GVOperand) {
-  for (Value *Op : TheUser->operands())
-    if (Op == GVOperand)
-      return true;
-  return false;
-}
-
 // For pooled strings we need to add the offset into the pool for each string.
 // This is done by adding a Get Element Pointer (GEP) before each user. This
 // function adds the GEP.
@@ -295,62 +300,13 @@ void PPCMergeStringPool::replaceUsesWithGEP(GlobalVariable *GlobalToReplace,
   Indices.push_back(ConstantInt::get(Type::getInt32Ty(*Context), 0));
   Indices.push_back(ConstantInt::get(Type::getInt32Ty(*Context), ElementIndex));
 
-  // Need to save a temporary copy of each user list because we remove uses
-  // as we replace them.
-  SmallVector<User *> Users;
-  for (User *CurrentUser : GlobalToReplace->users())
-    Users.push_back(CurrentUser);
-
-  for (User *CurrentUser : Users) {
-    Instruction *UserInstruction = dyn_cast<Instruction>(CurrentUser);
-    Constant *UserConstant = dyn_cast<Constant>(CurrentUser);
-
-    // At this point we expect that the user is either an instruction or a
-    // constant.
-    assert((UserConstant || UserInstruction) &&
-           "Expected the user to be an instruction or a constant.");
-
-    // The user was not found so it must have been replaced earlier.
-    if (!userHasOperand(CurrentUser, GlobalToReplace))
-      continue;
-
-    // We cannot replace operands in globals so we ignore those.
-    if (isa<GlobalValue>(CurrentUser))
-      continue;
-
-    if (!UserInstruction) {
-      // User is a constant type.
-      Constant *ConstGEP = ConstantExpr::getInBoundsGetElementPtr(
-          PooledStructType, GPool, Indices);
-      UserConstant->handleOperandChange(GlobalToReplace, ConstGEP);
-      continue;
-    }
-
-    if (PHINode *UserPHI = dyn_cast<PHINode>(UserInstruction)) {
-      // GEP instructions cannot be added before PHI nodes.
-      // With getInBoundsGetElementPtr we create the GEP and then replace it
-      // inline into the PHI.
-      Constant *ConstGEP = ConstantExpr::getInBoundsGetElementPtr(
-          PooledStructType, GPool, Indices);
-      UserPHI->replaceUsesOfWith(GlobalToReplace, ConstGEP);
-      continue;
-    }
-    // The user is a valid instruction that is not a PHINode.
-    GetElementPtrInst *GEPInst =
-        GetElementPtrInst::Create(PooledStructType, GPool, Indices);
-    GEPInst->insertBefore(UserInstruction);
-
-    LLVM_DEBUG(dbgs() << "Inserting GEP before:\n");
-    LLVM_DEBUG(UserInstruction->dump());
-
-    LLVM_DEBUG(dbgs() << "Replacing this global:\n");
-    LLVM_DEBUG(GlobalToReplace->dump());
-    LLVM_DEBUG(dbgs() << "with this:\n");
-    LLVM_DEBUG(GEPInst->dump());
-
-    // After the GEP is inserted the GV can be replaced.
-    CurrentUser->replaceUsesOfWith(GlobalToReplace, GEPInst);
-  }
+  Constant *ConstGEP =
+      ConstantExpr::getInBoundsGetElementPtr(PooledStructType, GPool, Indices);
+  LLVM_DEBUG(dbgs() << "Replacing this global:\n");
+  LLVM_DEBUG(GlobalToReplace->dump());
+  LLVM_DEBUG(dbgs() << "with this:\n");
+  LLVM_DEBUG(ConstGEP->dump());
+  GlobalToReplace->replaceAllUsesWith(ConstGEP);
 }
 
 } // namespace
diff --git a/contrib/llvm-project/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp b/contrib/llvm-project/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
index 961b8f0afe22..cdf7c048a4bf 100644
--- a/contrib/llvm-project/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
+++ b/contrib/llvm-project/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
@@ -31,12 +31,13 @@ using namespace llvm;
 // This part is for ELF object output.
 RISCVTargetELFStreamer::RISCVTargetELFStreamer(MCStreamer &S,
                                                const MCSubtargetInfo &STI)
-    : RISCVTargetStreamer(S), CurrentVendor("riscv"), STI(STI) {
+    : RISCVTargetStreamer(S), CurrentVendor("riscv") {
   MCAssembler &MCA = getStreamer().getAssembler();
   const FeatureBitset &Features = STI.getFeatureBits();
   auto &MAB = static_cast<RISCVAsmBackend &>(MCA.getBackend());
   setTargetABI(RISCVABI::computeTargetABI(STI.getTargetTriple(), Features,
                                           MAB.getTargetOptions().getABIName()));
+  setFlagsFromFeatures(STI);
   // `j label` in `.option norelax; j label; .option relax; ...; label:` needs a
   // relocation to ensure the jump target is correct after linking. This is due
   // to a limitation that shouldForceRelocation has to make the decision upfront
@@ -87,14 +88,13 @@ void RISCVTargetELFStreamer::finishAttributeSection() {
 void RISCVTargetELFStreamer::finish() {
   RISCVTargetStreamer::finish();
   MCAssembler &MCA = getStreamer().getAssembler();
-  const FeatureBitset &Features = STI.getFeatureBits();
   RISCVABI::ABI ABI = getTargetABI();
 
   unsigned EFlags = MCA.getELFHeaderEFlags();
 
-  if (Features[RISCV::FeatureStdExtC])
+  if (hasRVC())
     EFlags |= ELF::EF_RISCV_RVC;
-  if (Features[RISCV::FeatureStdExtZtso])
+  if (hasTSO())
     EFlags |= ELF::EF_RISCV_TSO;
 
   switch (ABI) {
diff --git a/contrib/llvm-project/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.h b/contrib/llvm-project/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.h
index a6f54bf67b5d..e8f29cd8449b 100644
--- a/contrib/llvm-project/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.h
+++ b/contrib/llvm-project/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.h
@@ -46,7 +46,6 @@ class RISCVTargetELFStreamer : public RISCVTargetStreamer {
   StringRef CurrentVendor;
 
   MCSection *AttributeSection = nullptr;
-  const MCSubtargetInfo &STI;
 
   void emitAttribute(unsigned Attribute, unsigned Value) override;
   void emitTextAttribute(unsigned Attribute, StringRef String) override;
diff --git a/contrib/llvm-project/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.cpp b/contrib/llvm-project/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.cpp
index 254a9a4bc0ef..b8e0f3a867f4 100644
--- a/contrib/llvm-project/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.cpp
+++ b/contrib/llvm-project/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.cpp
@@ -207,8 +207,6 @@ void RISCVMCExpr::fixELFSymbolsInTLSFixups(MCAssembler &Asm) const {
   case VK_RISCV_TLS_GOT_HI:
   case VK_RISCV_TLS_GD_HI:
   case VK_RISCV_TLSDESC_HI:
-  case VK_RISCV_TLSDESC_ADD_LO:
-  case VK_RISCV_TLSDESC_LOAD_LO:
     break;
   }
 
diff --git a/contrib/llvm-project/llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp b/contrib/llvm-project/llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
index ac4861bf113e..eee78a8c161f 100644
--- a/contrib/llvm-project/llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
+++ b/contrib/llvm-project/llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
@@ -48,6 +48,11 @@ void RISCVTargetStreamer::setTargetABI(RISCVABI::ABI ABI) {
   TargetABI = ABI;
 }
 
+void RISCVTargetStreamer::setFlagsFromFeatures(const MCSubtargetInfo &STI) {
+  HasRVC = STI.hasFeature(RISCV::FeatureStdExtC);
+  HasTSO = STI.hasFeature(RISCV::FeatureStdExtZtso);
+}
+
 void RISCVTargetStreamer::emitTargetAttributes(const MCSubtargetInfo &STI,
                                                bool EmitStackAlign) {
   if (EmitStackAlign) {
diff --git a/contrib/llvm-project/llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.h b/contrib/llvm-project/llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.h
index 070e72fb157a..cb8bc21cb635 100644
--- a/contrib/llvm-project/llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.h
+++ b/contrib/llvm-project/llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.h
@@ -33,6 +33,8 @@ struct RISCVOptionArchArg {
 
 class RISCVTargetStreamer : public MCTargetStreamer {
   RISCVABI::ABI TargetABI = RISCVABI::ABI_Unknown;
+  bool HasRVC = false;
+  bool HasTSO = false;
 
 public:
   RISCVTargetStreamer(MCStreamer &S);
@@ -58,6 +60,9 @@ class RISCVTargetStreamer : public MCTargetStreamer {
   void emitTargetAttributes(const MCSubtargetInfo &STI, bool EmitStackAlign);
   void setTargetABI(RISCVABI::ABI ABI);
   RISCVABI::ABI getTargetABI() const { return TargetABI; }
+  void setFlagsFromFeatures(const MCSubtargetInfo &STI);
+  bool hasRVC() const { return HasRVC; }
+  bool hasTSO() const { return HasTSO; }
 };
 
 // This part is for ascii assembly output
diff --git a/contrib/llvm-project/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp b/contrib/llvm-project/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
index b2e9cd87373b..87bd9b4048cd 100644
--- a/contrib/llvm-project/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
+++ b/contrib/llvm-project/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
@@ -100,7 +100,7 @@ class RISCVAsmPrinter : public AsmPrinter {
   bool emitDirectiveOptionArch();
 
 private:
-  void emitAttributes();
+  void emitAttributes(const MCSubtargetInfo &SubtargetInfo);
 
   void emitNTLHint(const MachineInstr *MI);
 
@@ -385,8 +385,32 @@ void RISCVAsmPrinter::emitStartOfAsmFile(Module &M) {
   if (const MDString *ModuleTargetABI =
           dyn_cast_or_null<MDString>(M.getModuleFlag("target-abi")))
     RTS.setTargetABI(RISCVABI::getTargetABI(ModuleTargetABI->getString()));
+
+  MCSubtargetInfo SubtargetInfo = *TM.getMCSubtargetInfo();
+
+  // Use module flag to update feature bits.
+  if (auto *MD = dyn_cast_or_null<MDNode>(M.getModuleFlag("riscv-isa"))) {
+    for (auto &ISA : MD->operands()) {
+      if (auto *ISAString = dyn_cast_or_null<MDString>(ISA)) {
+        auto ParseResult = llvm::RISCVISAInfo::parseArchString(
+            ISAString->getString(), /*EnableExperimentalExtension=*/true,
+            /*ExperimentalExtensionVersionCheck=*/true);
+        if (!errorToBool(ParseResult.takeError())) {
+          auto &ISAInfo = *ParseResult;
+          for (const auto &Feature : RISCVFeatureKV) {
+            if (ISAInfo->hasExtension(Feature.Key) &&
+                !SubtargetInfo.hasFeature(Feature.Value))
+              SubtargetInfo.ToggleFeature(Feature.Key);
+          }
+        }
+      }
+    }
+
+    RTS.setFlagsFromFeatures(SubtargetInfo);
+  }
+
   if (TM.getTargetTriple().isOSBinFormatELF())
-    emitAttributes();
+    emitAttributes(SubtargetInfo);
 }
 
 void RISCVAsmPrinter::emitEndOfAsmFile(Module &M) {
@@ -398,13 +422,13 @@ void RISCVAsmPrinter::emitEndOfAsmFile(Module &M) {
   EmitHwasanMemaccessSymbols(M);
 }
 
-void RISCVAsmPrinter::emitAttributes() {
+void RISCVAsmPrinter::emitAttributes(const MCSubtargetInfo &SubtargetInfo) {
   RISCVTargetStreamer &RTS =
       static_cast<RISCVTargetStreamer &>(*OutStreamer->getTargetStreamer());
   // Use MCSubtargetInfo from TargetMachine. Individual functions may have
   // attributes that differ from other functions in the module and we have no
   // way to know which function is correct.
-  RTS.emitTargetAttributes(*TM.getMCSubtargetInfo(), /*EmitStackAlign*/ true);
+  RTS.emitTargetAttributes(SubtargetInfo, /*EmitStackAlign*/ true);
 }
 
 void RISCVAsmPrinter::emitFunctionEntryLabel() {
diff --git a/contrib/llvm-project/llvm/lib/Target/RISCV/RISCVExpandPseudoInsts.cpp b/contrib/llvm-project/llvm/lib/Target/RISCV/RISCVExpandPseudoInsts.cpp
index 0a314fdd41cb..89207640ee54 100644
--- a/contrib/llvm-project/llvm/lib/Target/RISCV/RISCVExpandPseudoInsts.cpp
+++ b/contrib/llvm-project/llvm/lib/Target/RISCV/RISCVExpandPseudoInsts.cpp
@@ -317,8 +317,9 @@ bool RISCVExpandPseudo::expandRV32ZdinxStore(MachineBasicBlock &MBB,
       .addReg(MBBI->getOperand(1).getReg())
       .add(MBBI->getOperand(2));
   if (MBBI->getOperand(2).isGlobal() || MBBI->getOperand(2).isCPI()) {
-    // FIXME: Zdinx RV32 can not work on unaligned memory.
-    assert(!STI->hasFastUnalignedAccess());
+    // FIXME: Zdinx RV32 can not work on unaligned scalar memory.
+    assert(!STI->hasFastUnalignedAccess() &&
+           !STI->enableUnalignedScalarMem());
 
     assert(MBBI->getOperand(2).getOffset() % 8 == 0);
     MBBI->getOperand(2).setOffset(MBBI->getOperand(2).getOffset() + 4);
diff --git a/contrib/llvm-project/llvm/lib/Target/RISCV/RISCVFeatures.td b/contrib/llvm-project/llvm/lib/Target/RISCV/RISCVFeatures.td
index 26451c80f57b..1bb6b6a561f4 100644
--- a/contrib/llvm-project/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/contrib/llvm-project/llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -1025,6 +1025,11 @@ def FeatureFastUnalignedAccess
                       "true", "Has reasonably performant unaligned "
                       "loads and stores (both scalar and vector)">;
 
+def FeatureUnalignedScalarMem
+   : SubtargetFeature<"unaligned-scalar-mem", "EnableUnalignedScalarMem",
+                      "true", "Has reasonably performant unaligned scalar "
+                      "loads and stores">;
+
 def FeaturePostRAScheduler : SubtargetFeature<"use-postra-scheduler",
     "UsePostRAScheduler", "true", "Schedule again after register allocation">;
 
diff --git a/contrib/llvm-project/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/contrib/llvm-project/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index d46093b9e260..3fe7ddfdd427 100644
--- a/contrib/llvm-project/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/contrib/llvm-project/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -1883,7 +1883,8 @@ bool RISCVTargetLowering::shouldConvertConstantLoadToIntImm(const APInt &Imm,
   // replace. If we don't support unaligned scalar mem, prefer the constant
   // pool.
   // TODO: Can the caller pass down the alignment?
-  if (!Subtarget.hasFastUnalignedAccess())
+  if (!Subtarget.hasFastUnalignedAccess() &&
+      !Subtarget.enableUnalignedScalarMem())
     return true;
 
   // Prefer to keep the load if it would require many instructions.
@@ -19772,8 +19773,10 @@ bool RISCVTargetLowering::allowsMisalignedMemoryAccesses(
     unsigned *Fast) const {
   if (!VT.isVector()) {
     if (Fast)
-      *Fast = Subtarget.hasFastUnalignedAccess();
-    return Subtarget.hasFastUnalignedAccess();
+      *Fast = Subtarget.hasFastUnalignedAccess() ||
+              Subtarget.enableUnalignedScalarMem();
+    return Subtarget.hasFastUnalignedAccess() ||
+           Subtarget.enableUnalignedScalarMem();
   }
 
   // All vector implementations must support element alignment
diff --git a/contrib/llvm-project/llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp b/contrib/llvm-project/llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp
index bf6547cc87ec..2f2dc6b80792 100644
--- a/contrib/llvm-project/llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp
+++ b/contrib/llvm-project/llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp
@@ -70,49 +70,62 @@ void SystemZInstrInfo::splitMove(MachineBasicBlock::iterator MI,
   MachineBasicBlock *MBB = MI->getParent();
   MachineFunction &MF = *MBB->getParent();
 
-  // Get two load or store instructions.  Use the original instruction for one
-  // of them (arbitrarily the second here) and create a clone for the other.
-  MachineInstr *EarlierMI = MF.CloneMachineInstr(&*MI);
-  MBB->insert(MI, EarlierMI);
+  // Get two load or store instructions.  Use the original instruction for
+  // one of them and create a clone for the other.
+  MachineInstr *HighPartMI = MF.CloneMachineInstr(&*MI);
+  MachineInstr *LowPartMI = &*MI;
+  MBB->insert(LowPartMI, HighPartMI);
 
   // Set up the two 64-bit registers and remember super reg and its flags.
-  MachineOperand &HighRegOp = EarlierMI->getOperand(0);
-  MachineOperand &LowRegOp = MI->getOperand(0);
+  MachineOperand &HighRegOp = HighPartMI->getOperand(0);
+  MachineOperand &LowRegOp = LowPartMI->getOperand(0);
   Register Reg128 = LowRegOp.getReg();
   unsigned Reg128Killed = getKillRegState(LowRegOp.isKill());
   unsigned Reg128Undef  = getUndefRegState(LowRegOp.isUndef());
   HighRegOp.setReg(RI.getSubReg(HighRegOp.getReg(), SystemZ::subreg_h64));
   LowRegOp.setReg(RI.getSubReg(LowRegOp.getReg(), SystemZ::subreg_l64));
 
-  if (MI->mayStore()) {
-    // Add implicit uses of the super register in case one of the subregs is
-    // undefined. We could track liveness and skip storing an undefined
-    // subreg, but this is hopefully rare (discovered with llvm-stress).
-    // If Reg128 was killed, set kill flag on MI.
-    unsigned Reg128UndefImpl = (Reg128Undef | RegState::Implicit);
-    MachineInstrBuilder(MF, EarlierMI).addReg(Reg128, Reg128UndefImpl);
-    MachineInstrBuilder(MF, MI).addReg(Reg128, (Reg128UndefImpl | Reg128Killed));
-  }
-
   // The address in the first (high) instruction is already correct.
   // Adjust the offset in the second (low) instruction.
-  MachineOperand &HighOffsetOp = EarlierMI->getOperand(2);
-  MachineOperand &LowOffsetOp = MI->getOperand(2);
+  MachineOperand &HighOffsetOp = HighPartMI->getOperand(2);
+  MachineOperand &LowOffsetOp = LowPartMI->getOperand(2);
   LowOffsetOp.setImm(LowOffsetOp.getImm() + 8);
 
-  // Clear the kill flags on the registers in the first instruction.
-  if (EarlierMI->getOperand(0).isReg() && EarlierMI->getOperand(0).isUse())
-    EarlierMI->getOperand(0).setIsKill(false);
-  EarlierMI->getOperand(1).setIsKill(false);
-  EarlierMI->getOperand(3).setIsKill(false);
-
   // Set the opcodes.
   unsigned HighOpcode = getOpcodeForOffset(NewOpcode, HighOffsetOp.getImm());
   unsigned LowOpcode = getOpcodeForOffset(NewOpcode, LowOffsetOp.getImm());
   assert(HighOpcode && LowOpcode && "Both offsets should be in range");
+  HighPartMI->setDesc(get(HighOpcode));
+  LowPartMI->setDesc(get(LowOpcode));
+
+  MachineInstr *FirstMI = HighPartMI;
+  if (MI->mayStore()) {
+    FirstMI->getOperand(0).setIsKill(false);
+    // Add implicit uses of the super register in case one of the subregs is
+    // undefined. We could track liveness and skip storing an undefined
+    // subreg, but this is hopefully rare (discovered with llvm-stress).
+    // If Reg128 was killed, set kill flag on MI.
+    unsigned Reg128UndefImpl = (Reg128Undef | RegState::Implicit);
+    MachineInstrBuilder(MF, HighPartMI).addReg(Reg128, Reg128UndefImpl);
+    MachineInstrBuilder(MF, LowPartMI).addReg(Reg128, (Reg128UndefImpl | Reg128Killed));
+  } else {
+    // If HighPartMI clobbers any of the address registers, it needs to come
+    // after LowPartMI.
+    auto overlapsAddressReg = [&](Register Reg) -> bool {
+      return RI.regsOverlap(Reg, MI->getOperand(1).getReg()) ||
+             RI.regsOverlap(Reg, MI->getOperand(3).getReg());
+    };
+    if (overlapsAddressReg(HighRegOp.getReg())) {
+      assert(!overlapsAddressReg(LowRegOp.getReg()) &&
+             "Both loads clobber address!");
+      MBB->splice(HighPartMI, MBB, LowPartMI);
+      FirstMI = LowPartMI;
+    }
+  }
 
-  EarlierMI->setDesc(get(HighOpcode));
-  MI->setDesc(get(LowOpcode));
+  // Clear the kill flags on the address registers in the first instruction.
+  FirstMI->getOperand(1).setIsKill(false);
+  FirstMI->getOperand(3).setIsKill(false);
 }
 
 // Split ADJDYNALLOC instruction MI.
diff --git a/contrib/llvm-project/llvm/lib/Target/X86/X86.td b/contrib/llvm-project/llvm/lib/Target/X86/X86.td
index e89ddcc570c9..1aff5f9fad97 100644
--- a/contrib/llvm-project/llvm/lib/Target/X86/X86.td
+++ b/contrib/llvm-project/llvm/lib/Target/X86/X86.td
@@ -867,6 +867,7 @@ def ProcessorFeatures {
   // Nehalem
   list<SubtargetFeature> NHMFeatures = X86_64V2Features;
   list<SubtargetFeature> NHMTuning = [TuningMacroFusion,
+                                      TuningSlowDivide64,
                                       TuningInsertVZEROUPPER,
                                       TuningNoDomainDelayMov];
 
@@ -1336,6 +1337,7 @@ def ProcessorFeatures {
                                               FeatureCMOV,
                                               FeatureX86_64];
   list<SubtargetFeature> BarcelonaTuning = [TuningFastScalarShiftMasks,
+                                            TuningSlowDivide64,
                                             TuningSlowSHLD,
                                             TuningSBBDepBreaking,
                                             TuningInsertVZEROUPPER];
@@ -1358,6 +1360,7 @@ def ProcessorFeatures {
   list<SubtargetFeature> BtVer1Tuning = [TuningFast15ByteNOP,
                                          TuningFastScalarShiftMasks,
                                          TuningFastVectorShiftMasks,
+                                         TuningSlowDivide64,
                                          TuningSlowSHLD,
                                          TuningSBBDepBreaking,
                                          TuningInsertVZEROUPPER];
@@ -1380,6 +1383,7 @@ def ProcessorFeatures {
                                          TuningFastVectorShiftMasks,
                                          TuningFastMOVBE,
                                          TuningSBBDepBreaking,
+                                         TuningSlowDivide64,
                                          TuningSlowSHLD];
   list<SubtargetFeature> BtVer2Features =
     !listconcat(BtVer1Features, BtVer2AdditionalFeatures);
@@ -1404,6 +1408,7 @@ def ProcessorFeatures {
                                            FeatureLWP,
                                            FeatureLAHFSAHF64];
   list<SubtargetFeature> BdVer1Tuning = [TuningSlowSHLD,
+                                         TuningSlowDivide64,
                                          TuningFast11ByteNOP,
                                          TuningFastScalarShiftMasks,
                                          TuningBranchFusion,
@@ -1483,6 +1488,7 @@ def ProcessorFeatures {
                                      TuningFastScalarShiftMasks,
                                      TuningFastVariablePerLaneShuffle,
                                      TuningFastMOVBE,
+                                     TuningSlowDivide64,
                                      TuningSlowSHLD,
                                      TuningSBBDepBreaking,
                                      TuningInsertVZEROUPPER,
diff --git a/contrib/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp b/contrib/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp
index 201dd8382536..911d9986a879 100644
--- a/contrib/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/contrib/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -7295,7 +7295,7 @@ static SDValue lowerBuildVectorAsBroadcast(BuildVectorSDNode *BVOp,
     // With pattern matching, the VBROADCAST node may become a VMOVDDUP.
     if (ScalarSize == 32 ||
         (ScalarSize == 64 && (IsGE256 || Subtarget.hasVLX())) ||
-        CVT == MVT::f16 ||
+        (CVT == MVT::f16 && Subtarget.hasAVX2()) ||
         (OptForSize && (ScalarSize == 64 || Subtarget.hasAVX2()))) {
       const Constant *C = nullptr;
       if (ConstantSDNode *CI = dyn_cast<ConstantSDNode>(Ld))
@@ -29844,7 +29844,9 @@ static SDValue LowerRotate(SDValue Op, const X86Subtarget &Subtarget,
     return R;
 
   // AVX512 implicitly uses modulo rotation amounts.
-  if (Subtarget.hasAVX512() && 32 <= EltSizeInBits) {
+  if ((Subtarget.hasVLX() ||
+       (Subtarget.hasAVX512() && Subtarget.hasEVEX512())) &&
+      32 <= EltSizeInBits) {
     // Attempt to rotate by immediate.
     if (IsCstSplat) {
       unsigned RotOpc = IsROTL ? X86ISD::VROTLI : X86ISD::VROTRI;
diff --git a/contrib/llvm-project/llvm/lib/Target/X86/X86InstrAVX512.td b/contrib/llvm-project/llvm/lib/Target/X86/X86InstrAVX512.td
index fdca58141f0f..12d3b889c211 100644
--- a/contrib/llvm-project/llvm/lib/Target/X86/X86InstrAVX512.td
+++ b/contrib/llvm-project/llvm/lib/Target/X86/X86InstrAVX512.td
@@ -826,7 +826,7 @@ defm : vextract_for_size_lowering<"VEXTRACTF64x4Z", v32bf16_info, v16bf16x_info,
 
 // A 128-bit extract from bits [255:128] of a 512-bit vector should use a
 // smaller extract to enable EVEX->VEX.
-let Predicates = [NoVLX] in {
+let Predicates = [NoVLX, HasEVEX512] in {
 def : Pat<(v2i64 (extract_subvector (v8i64 VR512:$src), (iPTR 2))),
           (v2i64 (VEXTRACTI128rr
                   (v4i64 (EXTRACT_SUBREG (v8i64 VR512:$src), sub_ymm)),
@@ -3080,7 +3080,7 @@ def : Pat<(Narrow.KVT (and Narrow.KRC:$mask,
            addr:$src2, (X86cmpm_imm_commute timm:$cc)), Narrow.KRC)>;
 }
 
-let Predicates = [HasAVX512, NoVLX] in {
+let Predicates = [HasAVX512, NoVLX, HasEVEX512] in {
   defm : axv512_icmp_packed_cc_no_vlx_lowering<X86pcmpm, X86pcmpm_su, "VPCMPD", v8i32x_info, v16i32_info>;
   defm : axv512_icmp_packed_cc_no_vlx_lowering<X86pcmpum, X86pcmpum_su, "VPCMPUD", v8i32x_info, v16i32_info>;
 
@@ -3111,7 +3111,7 @@ let Predicates = [HasAVX512, NoVLX] in {
   defm : axv512_cmp_packed_cc_no_vlx_lowering<"VCMPPD", v2f64x_info, v8f64_info>;
 }
 
-let Predicates = [HasBWI, NoVLX] in {
+let Predicates = [HasBWI, NoVLX, HasEVEX512] in {
   defm : axv512_icmp_packed_cc_no_vlx_lowering<X86pcmpm, X86pcmpm_su, "VPCMPB", v32i8x_info, v64i8_info>;
   defm : axv512_icmp_packed_cc_no_vlx_lowering<X86pcmpum, X86pcmpum_su, "VPCMPUB", v32i8x_info, v64i8_info>;
 
@@ -3505,7 +3505,7 @@ multiclass mask_move_lowering<string InstrStr, X86VectorVTInfo Narrow,
 
 // Patterns for handling v8i1 selects of 256-bit vectors when VLX isn't
 // available. Use a 512-bit operation and extract.
-let Predicates = [HasAVX512, NoVLX] in {
+let Predicates = [HasAVX512, NoVLX, HasEVEX512] in {
   defm : mask_move_lowering<"VMOVAPSZ", v4f32x_info, v16f32_info>;
   defm : mask_move_lowering<"VMOVDQA32Z", v4i32x_info, v16i32_info>;
   defm : mask_move_lowering<"VMOVAPSZ", v8f32x_info, v16f32_info>;
@@ -3517,7 +3517,7 @@ let Predicates = [HasAVX512, NoVLX] in {
   defm : mask_move_lowering<"VMOVDQA64Z", v4i64x_info, v8i64_info>;
 }
 
-let Predicates = [HasBWI, NoVLX] in {
+let Predicates = [HasBWI, NoVLX, HasEVEX512] in {
   defm : mask_move_lowering<"VMOVDQU8Z", v16i8x_info, v64i8_info>;
   defm : mask_move_lowering<"VMOVDQU8Z", v32i8x_info, v64i8_info>;
 
@@ -5010,8 +5010,8 @@ defm VPMINUD : avx512_binop_rm_vl_d<0x3B, "vpminud", umin,
 defm VPMINUQ : avx512_binop_rm_vl_q<0x3B, "vpminuq", umin,
                                     SchedWriteVecALU, HasAVX512, 1>, T8;
 
-// PMULLQ: Use 512bit version to implement 128/256 bit in case NoVLX.
-let Predicates = [HasDQI, NoVLX] in {
+// PMULLQ: Use 512bit version to implement 128/256 bit in case NoVLX, HasEVEX512.
+let Predicates = [HasDQI, NoVLX, HasEVEX512] in {
   def : Pat<(v4i64 (mul (v4i64 VR256X:$src1), (v4i64 VR256X:$src2))),
             (EXTRACT_SUBREG
                 (VPMULLQZrr
@@ -5067,7 +5067,7 @@ multiclass avx512_min_max_lowering<string Instr, SDNode OpNode> {
              sub_xmm)>;
 }
 
-let Predicates = [HasAVX512, NoVLX] in {
+let Predicates = [HasAVX512, NoVLX, HasEVEX512] in {
   defm : avx512_min_max_lowering<"VPMAXUQZ", umax>;
   defm : avx512_min_max_lowering<"VPMINUQZ", umin>;
   defm : avx512_min_max_lowering<"VPMAXSQZ", smax>;
@@ -6044,7 +6044,7 @@ defm VPSRL : avx512_shift_types<0xD2, 0xD3, 0xD1, "vpsrl", X86vsrl,
                                 SchedWriteVecShift>;
 
 // Use 512bit VPSRA/VPSRAI version to implement v2i64/v4i64 in case NoVLX.
-let Predicates = [HasAVX512, NoVLX] in {
+let Predicates = [HasAVX512, NoVLX, HasEVEX512] in {
   def : Pat<(v4i64 (X86vsra (v4i64 VR256X:$src1), (v2i64 VR128X:$src2))),
             (EXTRACT_SUBREG (v8i64
               (VPSRAQZrr
@@ -6173,14 +6173,14 @@ defm VPSRLV : avx512_var_shift_types<0x45, "vpsrlv", X86vsrlv, SchedWriteVarVecS
 defm VPRORV : avx512_var_shift_types<0x14, "vprorv", rotr, SchedWriteVarVecShift>;
 defm VPROLV : avx512_var_shift_types<0x15, "vprolv", rotl, SchedWriteVarVecShift>;
 
-defm : avx512_var_shift_lowering<avx512vl_i64_info, "VPSRAVQ", X86vsrav, [HasAVX512, NoVLX]>;
-defm : avx512_var_shift_lowering<avx512vl_i16_info, "VPSLLVW", X86vshlv, [HasBWI, NoVLX]>;
-defm : avx512_var_shift_lowering<avx512vl_i16_info, "VPSRAVW", X86vsrav, [HasBWI, NoVLX]>;
-defm : avx512_var_shift_lowering<avx512vl_i16_info, "VPSRLVW", X86vsrlv, [HasBWI, NoVLX]>;
+defm : avx512_var_shift_lowering<avx512vl_i64_info, "VPSRAVQ", X86vsrav, [HasAVX512, NoVLX, HasEVEX512]>;
+defm : avx512_var_shift_lowering<avx512vl_i16_info, "VPSLLVW", X86vshlv, [HasBWI, NoVLX, HasEVEX512]>;
+defm : avx512_var_shift_lowering<avx512vl_i16_info, "VPSRAVW", X86vsrav, [HasBWI, NoVLX, HasEVEX512]>;
+defm : avx512_var_shift_lowering<avx512vl_i16_info, "VPSRLVW", X86vsrlv, [HasBWI, NoVLX, HasEVEX512]>;
 
 
 // Use 512bit VPROL/VPROLI version to implement v2i64/v4i64 + v4i32/v8i32 in case NoVLX.
-let Predicates = [HasAVX512, NoVLX] in {
+let Predicates = [HasAVX512, NoVLX, HasEVEX512] in {
   def : Pat<(v2i64 (rotl (v2i64 VR128X:$src1), (v2i64 VR128X:$src2))),
             (EXTRACT_SUBREG (v8i64
               (VPROLVQZrr
@@ -6231,7 +6231,7 @@ let Predicates = [HasAVX512, NoVLX] in {
 }
 
 // Use 512bit VPROR/VPRORI version to implement v2i64/v4i64 + v4i32/v8i32 in case NoVLX.
-let Predicates = [HasAVX512, NoVLX] in {
+let Predicates = [HasAVX512, NoVLX, HasEVEX512] in {
   def : Pat<(v2i64 (rotr (v2i64 VR128X:$src1), (v2i64 VR128X:$src2))),
             (EXTRACT_SUBREG (v8i64
               (VPRORVQZrr
@@ -9828,7 +9828,7 @@ defm VPMOVUSWB  : avx512_trunc_wb<0x10, "vpmovuswb", X86vtruncus,
                                   truncstore_us_vi8, masked_truncstore_us_vi8,
                                   X86vtruncus, X86vmtruncus>;
 
-let Predicates = [HasAVX512, NoVLX] in {
+let Predicates = [HasAVX512, NoVLX, HasEVEX512] in {
 def: Pat<(v8i16 (trunc (v8i32 VR256X:$src))),
          (v8i16 (EXTRACT_SUBREG
                  (v16i16 (VPMOVDWZrr (v16i32 (INSERT_SUBREG (IMPLICIT_DEF),
@@ -9839,7 +9839,7 @@ def: Pat<(v4i32 (trunc (v4i64 VR256X:$src))),
                                            VR256X:$src, sub_ymm)))), sub_xmm))>;
 }
 
-let Predicates = [HasBWI, NoVLX] in {
+let Predicates = [HasBWI, NoVLX, HasEVEX512] in {
 def: Pat<(v16i8 (trunc (v16i16 VR256X:$src))),
          (v16i8 (EXTRACT_SUBREG (VPMOVWBZrr (v32i16 (INSERT_SUBREG (IMPLICIT_DEF),
                                             VR256X:$src, sub_ymm))), sub_xmm))>;
@@ -10382,7 +10382,7 @@ multiclass avx512_convert_vector_to_mask<bits<8> opc, string OpcodeStr,
     defm Z128 : convert_vector_to_mask_common<opc, VTInfo.info128, OpcodeStr>,
                                                EVEX_V128;
   }
-  let Predicates = [prd, NoVLX] in {
+  let Predicates = [prd, NoVLX, HasEVEX512] in {
     defm Z256_Alt : convert_vector_to_mask_lowering<VTInfo.info512, VTInfo.info256, NAME>;
     defm Z128_Alt : convert_vector_to_mask_lowering<VTInfo.info512, VTInfo.info128, NAME>;
   }
@@ -11169,7 +11169,7 @@ defm VPABS : avx512_unary_rm_vl_all<0x1C, 0x1D, 0x1E, 0x1F, "vpabs", abs,
                                     SchedWriteVecALU>;
 
 // VPABS: Use 512bit version to implement 128/256 bit in case NoVLX.
-let Predicates = [HasAVX512, NoVLX] in {
+let Predicates = [HasAVX512, NoVLX, HasEVEX512] in {
   def : Pat<(v4i64 (abs VR256X:$src)),
             (EXTRACT_SUBREG
                 (VPABSQZrr
@@ -11185,7 +11185,7 @@ let Predicates = [HasAVX512, NoVLX] in {
 // Use 512bit version to implement 128/256 bit.
 multiclass avx512_unary_lowering<string InstrStr, SDNode OpNode,
                                  AVX512VLVectorVTInfo _, Predicate prd> {
-  let Predicates = [prd, NoVLX] in {
+  let Predicates = [prd, NoVLX, HasEVEX512] in {
     def : Pat<(_.info256.VT (OpNode (_.info256.VT _.info256.RC:$src1))),
               (EXTRACT_SUBREG
                 (!cast<Instruction>(InstrStr # "Zrr")
@@ -11804,7 +11804,7 @@ let Predicates = [HasAVX512] in {
             (VPTERNLOGQZrri VR512:$src, VR512:$src, VR512:$src, (i8 15))>;
 }
 
-let Predicates = [HasAVX512, NoVLX] in {
+let Predicates = [HasAVX512, NoVLX, HasEVEX512] in {
   def : Pat<(v16i8 (vnot VR128X:$src)),
             (EXTRACT_SUBREG
              (VPTERNLOGQZrri
diff --git a/contrib/llvm-project/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/contrib/llvm-project/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
index 7ebf265e17ba..27c411250d53 100644
--- a/contrib/llvm-project/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
+++ b/contrib/llvm-project/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -1186,10 +1186,15 @@ static bool isReturnNonNull(Function *F, const SCCNodeSet &SCCNodes,
     switch (RVI->getOpcode()) {
     // Extend the analysis by looking upwards.
     case Instruction::BitCast:
-    case Instruction::GetElementPtr:
     case Instruction::AddrSpaceCast:
       FlowsToReturn.insert(RVI->getOperand(0));
       continue;
+    case Instruction::GetElementPtr:
+      if (cast<GEPOperator>(RVI)->isInBounds()) {
+        FlowsToReturn.insert(RVI->getOperand(0));
+        continue;
+      }
+      return false;
     case Instruction::Select: {
       SelectInst *SI = cast<SelectInst>(RVI);
       FlowsToReturn.insert(SI->getTrueValue());
diff --git a/contrib/llvm-project/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/contrib/llvm-project/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index 951372adcfa9..619b3f612f25 100644
--- a/contrib/llvm-project/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/contrib/llvm-project/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -2212,6 +2212,9 @@ static bool mayHaveOtherReferences(GlobalValue &GV, const LLVMUsed &U) {
 
 static bool hasUsesToReplace(GlobalAlias &GA, const LLVMUsed &U,
                              bool &RenameTarget) {
+  if (GA.isWeakForLinker())
+    return false;
+
   RenameTarget = false;
   bool Ret = false;
   if (hasUseOtherThanLLVMUsed(GA, U))
diff --git a/contrib/llvm-project/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/contrib/llvm-project/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index 8cc7901cbac7..86a39cf2ee93 100644
--- a/contrib/llvm-project/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/contrib/llvm-project/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -3201,7 +3201,8 @@ Instruction *InstCombinerImpl::foldSelectOfBools(SelectInst &SI) {
 // pattern.
 static bool isSafeToRemoveBitCeilSelect(ICmpInst::Predicate Pred, Value *Cond0,
                                         const APInt *Cond1, Value *CtlzOp,
-                                        unsigned BitWidth) {
+                                        unsigned BitWidth,
+                                        bool &ShouldDropNUW) {
   // The challenge in recognizing std::bit_ceil(X) is that the operand is used
   // for the CTLZ proper and select condition, each possibly with some
   // operation like add and sub.
@@ -3224,6 +3225,8 @@ static bool isSafeToRemoveBitCeilSelect(ICmpInst::Predicate Pred, Value *Cond0,
   ConstantRange CR = ConstantRange::makeExactICmpRegion(
       CmpInst::getInversePredicate(Pred), *Cond1);
 
+  ShouldDropNUW = false;
+
   // Match the operation that's used to compute CtlzOp from CommonAncestor.  If
   // CtlzOp == CommonAncestor, return true as no operation is needed.  If a
   // match is found, execute the operation on CR, update CR, and return true.
@@ -3237,6 +3240,7 @@ static bool isSafeToRemoveBitCeilSelect(ICmpInst::Predicate Pred, Value *Cond0,
       return true;
     }
     if (match(CtlzOp, m_Sub(m_APInt(C), m_Specific(CommonAncestor)))) {
+      ShouldDropNUW = true;
       CR = ConstantRange(*C).sub(CR);
       return true;
     }
@@ -3306,14 +3310,20 @@ static Instruction *foldBitCeil(SelectInst &SI, IRBuilderBase &Builder) {
     Pred = CmpInst::getInversePredicate(Pred);
   }
 
+  bool ShouldDropNUW;
+
   if (!match(FalseVal, m_One()) ||
       !match(TrueVal,
              m_OneUse(m_Shl(m_One(), m_OneUse(m_Sub(m_SpecificInt(BitWidth),
                                                     m_Value(Ctlz)))))) ||
       !match(Ctlz, m_Intrinsic<Intrinsic::ctlz>(m_Value(CtlzOp), m_Zero())) ||
-      !isSafeToRemoveBitCeilSelect(Pred, Cond0, Cond1, CtlzOp, BitWidth))
+      !isSafeToRemoveBitCeilSelect(Pred, Cond0, Cond1, CtlzOp, BitWidth,
+                                   ShouldDropNUW))
     return nullptr;
 
+  if (ShouldDropNUW)
+    cast<Instruction>(CtlzOp)->setHasNoUnsignedWrap(false);
+
   // Build 1 << (-CTLZ & (BitWidth-1)).  The negation likely corresponds to a
   // single hardware instruction as opposed to BitWidth - CTLZ, where BitWidth
   // is an integer constant.  Masking with BitWidth-1 comes free on some
diff --git a/contrib/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/contrib/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 1fbd69e38eae..0a9e2c7f49f5 100644
--- a/contrib/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/contrib/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -11653,12 +11653,12 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
       if (UseIntrinsic && isVectorIntrinsicWithOverloadTypeAtArg(ID, -1))
         TysForDecl.push_back(
             FixedVectorType::get(CI->getType(), E->Scalars.size()));
-      auto *CEI = cast<CallInst>(VL0);
       for (unsigned I : seq<unsigned>(0, CI->arg_size())) {
         ValueList OpVL;
         // Some intrinsics have scalar arguments. This argument should not be
         // vectorized.
         if (UseIntrinsic && isVectorIntrinsicWithScalarOpAtArg(ID, I)) {
+          CallInst *CEI = cast<CallInst>(VL0);
           ScalarArg = CEI->getArgOperand(I);
           OpVecs.push_back(CEI->getArgOperand(I));
           if (isVectorIntrinsicWithOverloadTypeAtArg(ID, I))
@@ -11671,25 +11671,6 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
           LLVM_DEBUG(dbgs() << "SLP: Diamond merged for " << *VL0 << ".\n");
           return E->VectorizedValue;
         }
-        auto GetOperandSignedness = [&](unsigned Idx) {
-          const TreeEntry *OpE = getOperandEntry(E, Idx);
-          bool IsSigned = false;
-          auto It = MinBWs.find(OpE);
-          if (It != MinBWs.end())
-            IsSigned = It->second.second;
-          else
-            IsSigned = any_of(OpE->Scalars, [&](Value *R) {
-              return !isKnownNonNegative(R, SimplifyQuery(*DL));
-            });
-          return IsSigned;
-        };
-        ScalarArg = CEI->getArgOperand(I);
-        if (cast<VectorType>(OpVec->getType())->getElementType() !=
-            ScalarArg->getType()) {
-          auto *CastTy = FixedVectorType::get(ScalarArg->getType(),
-                                              VecTy->getNumElements());
-          OpVec = Builder.CreateIntCast(OpVec, CastTy, GetOperandSignedness(I));
-        }
         LLVM_DEBUG(dbgs() << "SLP: OpVec[" << I << "]: " << *OpVec << "\n");
         OpVecs.push_back(OpVec);
         if (UseIntrinsic && isVectorIntrinsicWithOverloadTypeAtArg(ID, I))
diff --git a/contrib/ncurses/ANNOUNCE b/contrib/ncurses/ANNOUNCE
index e0603d622394..6abf551c684d 100644
--- a/contrib/ncurses/ANNOUNCE
+++ b/contrib/ncurses/ANNOUNCE
@@ -1,4 +1,4 @@
-                            Announcing ncurses 6.2
+                            Announcing ncurses 6.5
 
 Overview
 
@@ -40,19 +40,19 @@ Overview
 
    The ncurses distribution is available at ncurses' homepage:
 
-     ftp://ftp.invisible-island.net/ncurses/ or
+     https://invisible-island.net/archives/ncurses/ or
      https://invisible-mirror.net/archives/ncurses/ .
 
-   It is also available via anonymous FTP at the GNU distribution site
+   It is also available at the GNU distribution site
 
-     ftp://ftp.gnu.org/gnu/ncurses/ .
+     https://ftp.gnu.org/gnu/ncurses/ .
 
 Release Notes
 
-   These notes are for ncurses 6.2, released February 12, 2020.
+   These notes are for ncurses 6.5, released April 27, 2024.
 
    This  release  is  designed  to  be source-compatible with ncurses 5.0
-   through  6.1; providing extensions to the application binary interface
+   through  6.4; providing extensions to the application binary interface
    (ABI).  Although  the  source  can  still be configured to support the
    ncurses  5  ABI, the reason for the release is to reflect improvements
    to the ncurses 6 ABI and the supporting utility programs.
@@ -60,340 +60,192 @@ Release Notes
    There  are,  of  course,  numerous  other improvements, listed in this
    announcement.
 
-   The  most  important  bug-fixes/improvements  dealt  with user-defined
-   capabilities  in terminal descriptions. The release notes also mention
-   some other bug-fixes, but are focused on new features and improvements
-   to existing features since ncurses 6.1 release.
+   The   most  important  bug-fixes/improvements  dealt  with  robustness
+   issues.  The  release notes also mention some other bug-fixes, but are
+   focused  on  new  features and improvements to existing features since
+   ncurses 6.4 release.
 
   Library improvements
 
     New features
 
-   There are several new features:
-     * O_EDGE_INSERT_STAY  tells  the  form  library  to optionally delay
-       cursor movement on a field edge/boundary
-     * O_INPUT_FIELD  extension to form library allows a dynamic field to
-       shrink if the new limit is smaller than the current field size.
-     * added  exit_curses  and  exit_terminfo to replace internal symbols
-       for leak-checking.
-     * added curses_trace, to replace trace().
-
-   Additionally,  to  improve  performance other changes (and extensions)
-   are provided in this release:
-     * mouse  decoding  now handles shift/control/alt logic when decoding
-       xterm's 1006 mode
-     * ncurses  now  defines a limit for wgetnstr, wgetn_wstr when length
-       is negative or "too large".
-     * reordered  loop-limit checks in winsnstr in case the string has no
-       terminating null and only the number of characters is used.
-     * there  is  now  no  buffer-size  limit  when  reading the $TERMCAP
-       variable.
-     * the  $TERMCAP  variable  may  be  interpreted  as  a fallback to a
-       terminfo entry
-     * mvcur  now decides whether to use hard-tabs, using xt, tbc and hts
-       as clues.
-     * extended  colors  are  improved  by  modifying an internal call to
-       vid_puts  to pass extended color pairs e.g., from tty_update.c and
-       lib_mvcur.c
-     * the  initialization  functions  now  avoid relying upon persistent
-       data for the result from getenv
-     * scrolling is improved:
-          + a limit check in newline_forces_scroll handles the case where
-            the row is inside scroll-margins, but not at the end.
-          + improved loop limits in _nc_scroll_window handle a case where
-            the scrolled data is a pad which is taller than the window.
+   These are new features:
+     * The low-level terminfo and termcap interfaces are used both by the
+       higher-level curses library, as well as by many applications.
+       The  functions  which  convert  parameterized  terminal capability
+       strings  for output to the terminal (tiparm and tparm) analyze the
+       capability string to determine which parameters are strings (i.e.,
+       addresses), versus numbers (not addresses).
+       The  library's analysis of a capability string may differ from the
+       calling  application's design if environment variables are used to
+       point  to  an  invalid  terminal  database. This is a longstanding
+       problem  with  all  implementations  of  terminfo, dating from the
+       early 1980s.
+       Two  new  functions  address this problem: by providing a function
+       which  allows  the  calling  application  to tell ncurses how many
+       string-parameters to expect:
+          + tiscan_s  helps  applications  check  formatting capabilities
+            that would be passed to tiparm_s.
+          + tiparm_s provides applications a way to tell ncurses what the
+            expected parameters are for a capability.
+     * The  ncurses library supports a compile-time feature (enabled with
+       the   configure   --enable-check-size   option)  which  simplifies
+       initialization  with  terminals  which  do  not  negotiate  window
+       (screen)  size.  This is done in setupterm, by providing for using
+       ANSI cursor-position report (in user6/user7 terminfo capabilities)
+       to  obtain  the  screen  size  if neither environment variables or
+       ioctl is used.
+       The  ncurses  test-program  with options "-E -T" demonstrates this
+       feature.
+     * add functions to query tty-flags in SCREEN
+
+   This release drops compatibility with obsolete versions of tack, e.g.,
+   pre-1.08
 
     Other improvements
 
-   These are revised features:
-     * used  "const"  in  some prototypes rather than NCURSES_CONST where
-       X/Open  Curses  was updated to do this, e.g., wscanw, newterm, the
-       terminfo  interface.  Also  use  "const"  for  consistency  in the
-       termcap interface, which was withdrawn by X/Open Curses in Issue 5
-       (2007).  As  of  Issue  7,  X/Open  Curses still lacks "const" for
-       certain return values, e.g., keyname.
-     * modified  wbkgd  and  wbkgrnd  to  improve compatibility with SVr4
-       curses,  changing the way the window rendition is updated when the
-       background character is modified
-     * improved  terminfo  write/read by modifying the fourth item of the
-       extended  header  to  denote  the  number  of valid strings in the
-       extended string table (see term(5)).
-     * modified   the   initialization  checks  for  mouse  so  that  the
-       xterm+sm+1006  block  will  work  with  terminal  descriptions not
-       mentioning xterm.
-
-   These were done to limit or ultimately deprecate features:
-     * deprecated  safe-sprintf, since the vsnprintf function, which does
-       what was needed, was standardized long ago.
-     * marked   vwprintw  and  vwscanw  as  deprecated;  recommend  using
-       vw_printw and vw_scanw, respectively.
-     * added  deprecation warnings for internal functions called by older
-       versions of tack.
-     * removed unused _nc_import_termtype2 function.
-
    These are improvements to existing features:
-     * check parameter of set_escdelay, return ERR if negative.
-     * check  parameter  of  set_tabsize,  return ERR if not greater than
-       zero
-     * correct  a status-check in _nc_read_tic_entry() so that if reading
-       a hex/b64 $TERMINFO, and the $TERM does not match, fall-through to
-       the compiled-in search list.
-     * amend check for repeat_char to handle a case where setlocale() was
-       called after initscr
-     * move macro for is_linetouched inside NCURSES_NOMACROS ifndef.
-     * use _nc_copy_termtype2 rather than direct assignment in setupterm,
-       in   case   it   is  called  repeatedly  using  fallback  terminfo
-       descriptions
-     * improve   workaround   for  Solaris  wcwidth  versus  line-drawing
-       characters
-     * add  checks  in repair_subwindows to keep the current position and
-       scroll-margins inside the resized subwindow.
-     * correct  a  buffer-limit  in  write_entry.c  for  systems that use
-       caseless filenames.
-     * improved build-time utility report_offsets:
-          + add categories, e.g., "w" for wide-character, "t" for threads
-            to  make the report more readable. Reorganized the structures
-            reported to make the categories more apparent.
-          + add  NCURSES_GLOBALS  and NCURSES_PRESCREEN to report to show
-            how similar the different libtinfo configurations are.
-     * modified  some header files to ensure that those include necessary
-       files except for the previously-documented cases
-     * added  some  traces  in  initialization to show whether a fallback
-       entry is used.
-     * made minor optimization to reduce calls to _nc_reserve_pairs
+     * In  addition  to  the  new,  safer function tiparm_s, ncurses adds
+       checks to make the older tiparm, tparm and tgoto functions safer:
+          + the  terminfo  functions  tiparm  and  tparm  ensure that the
+            capability  string  comes from the terminal description which
+            ncurses  loads,  rather  than  from  random  data  which  the
+            application happens to have.
+          + the  tgoto function disallows capabilities which its analysis
+            shows will attempt to use string parameters.
+          + ncurses  uses  internal functions which correspond to tiparm,
+            and  tgoto which ensure that the capability strings which are
+            passed  to  these  functions  come  from  the loaded terminal
+            description.
+     * improve  check  in  lib_tparm.c, ensuring that a char* fits into a
+       TPARM_ARG
+     * modify  _nc_syserr_abort  to  use _nc_env_access, rather than only
+       checking root uid
+     * improve thread lock in lib_trace.c
+     * modify  flushinp  to  use  file descriptors in SCREEN, rather than
+       from TERMINAL, and check if they are for a terminal, like SVr4
+     * modify mcprint to use file descriptor in SCREEN, for consistency
+     * modify  internal  function  _nc_read_file_entry  to  show relevant
+       filename in warnings
+     * improve  checks  in  internal  function convert_string for corrupt
+       terminfo entry
+     * review/improve handling of out-of-memory conditions
+     * limit  delays  to 30 seconds, i.e., padding delays in terminfo, as
+       well as napms and delay_output functions
+     * fix  reallocation  loop  for  vsnprintf  in  _nc_sprintf_string by
+       copying the va_list variable
+     * modify  delscreen  to  limit  the windows which it creates to just
+       those associated with the screen
+     * modify  endwin to return an error if it is called again without an
+       intervening screen update
+     * modify wenclose to handle pads
+     * eliminate use of PATH_MAX in lib_trace.c
+     * provide for any CCHARW_MAX greater than 1
 
    These are corrections to existing features:
-     * fix  a  special  case  in  PutAttrChar  where  a cell is marked as
-       alternate-character  set,  but  the  terminal  does  not  actually
-       support the given graphic character. This would happen in an older
-       terminal such as vt52, which lacks most line-drawing capability.
-     * corrected  flag  for "seq" method of db 1.8.5 interface, needed by
-       toe on some of the BSDs.
-     * modify  comparison  in  make_hash.c  to  correct a special case in
-       collision handling for Caps-hpux11
-     * add    extended_slk_color{,_sp}   symbols   to   the   appropriate
-       package/*.{map,sym} files
-     * modify  lib_setup  to  avoid  calling pthread_self() without first
-       verifying that the address is valid, i.e., for weak symbols
-     * add  a  couple  of  broken-linker symbols to the list of versioned
-       symbols to help with link-time optimization versus weak symbols.
+     * correct loop termination condition in waddnstr and waddnwstr
+     * improve  parsing  in  internal  function _nc_msec_cost, allowing a
+       single decimal point
+     * amend  parameter check for entire string versus specific length in
+       winsnstr  and wins_nwstr to match Solaris; make similar correction
+       to wins_nwstr
+     * correct   internal   function   wadd_wch_literal   when  adding  a
+       non-spacing character to a double-width character
+     * correct  definition of Charable macro for non-wide ncurses library
+       .
 
   Program improvements
 
-   Several improvements were made to the utility programs:
-
-   clear
-
-          + improved  logic  for  clearing with the E3 extension, in case
-            the  terminal  scrolls  content  onto  its saved-lines before
-            actually  clearing  the  display, by clearing the saved-lines
-            after clearing the display
+   Several improvements were made to the utility programs. Some were done
+   to  make  the  infocmp  option  "-u" option help refactor the terminal
+   database.
 
    infocmp
 
-          + omit  filtering  of  "OTxx" names which are used for obsolete
-            capabilities,  when  the output is sorted by long-names. This
-            change helps when making a table of the short/long capability
-            names.
+          + add  limit  checks  for processing extended capabilities with
+            the "-u" option
+          + correct  initial  alignment of extended capabilities, so that
+            the "-u" option can be used for more than two terminal types
+          + modify  "-u"  option  to not report cancels for strings which
+            were already cancelled in a use'd chunk.
+          + correct  an  assignment  "-u"  for  detecting if a boolean is
+            unset  in  a base entry and set in a use'd chunk, i.e., if it
+            was cancelled.
 
    tic
 
-          + added   check   for   consistent   alternate   character  set
-            capabilities.
-          + added check for paired indn/rin.
-          + added check for terminals with parm_dch vs parm_ich.
-          + added  check  for  the  case  where setf/setb are given using
-            different   strings,   but   provide   identical  results  to
-            setaf/setab.
-          + corrected check for ich1.
-          + changed  a  too-large  terminal entry from a fatal error to a
-            warning.
-
-   toe
-
-          + ignores  any  hex/b64 $TERMINFO value in the list of terminfo
-            databases.
-
-   tset
-
-          + replace  check  in reset command for obsolete "pt" capability
-            using tbc and hts capabilities as clues
-          + modify reset to allow for tabstops at intervals other than 8.
-          + change   reset's   behavior   for  margins  to  simply  clear
-            soft-margins  if  possible,  rather  than  clearing  and then
-            setting them according to the terminal's width.
-
-   tput
-
-          + add "x" to getopt string so that "tput -x clear" works.
-
-   Several  changes were made to the generated ncurses*config scripts and
-   the   analogous   ".pc"   files  to  reduce  differences  between  the
-   configurations they report:
-     * modified the ncurse*-config and pc-files to more closely match for
-       the -I and -l options.
-     * filtered out linker-specs from the --libs report.
-     * amended  the ncurses*-config and pc-files to take into account the
-       rpath hack which differed between those files.
-     * modified  generated  ncurses*config  and  ncurses.pc, ncursesw.pc,
-       etc., to list helper libraries such as gpm for static linking.
+          + correct limit-check when dumping tc/use clause via "-I"
+          + check  return  value  of  _nc_save_str, in special case where
+            extended   capabilities   are   processed  but  the  terminal
+            description was not initialized
+          + modify  check for multiply defined aliases to report problems
+            within  the  current  runtime  rather than for conflicts with
+            pre-existing terminal descriptions.
+          + disallow  using $TERMINFO or $HOME/.terminfo when "-o" option
+            is used
+
+   tput and tset
+
+          + add "-v" option to tput, to show warnings
+          + modify reset command to avoid altering clocal if the terminal
+            uses a modem
+          + modify  reset feature to avoid 1-second sleep if running in a
+            pseudo-terminal
 
     Examples
 
    Along  with  the  library and utilities, improvements were made to the
-   ncurses-examples.  Most  of  this  activity  aimed  at  improving  the
-   test-packages.  A few changes are more generally useful, e.g., for the
-   main   ncurses  test-program,  and  for  analyzing  traces  using  the
-   tracemunch script:
-     * improve  recovery  from  error  when  reading command-character in
-       test/ncurses.c, showing the relevant error message and not exiting
-       on EINTR.
-     * improve  tracemunch,  by keeping track of TERMINAL* values, and if
-       tracing  was first turned on after initialization, attempt to show
-       distinct screen, window and terminal names anyway.
-     * modify tracemunch to accept filename parameters in addition to use
-       as a pipe/filter.
-     * update  tracemunch  to  work  with  perl 5.26.2, which changed the
-       rules for escaping regular expressions.
-     * add some checks in tracemunch for undefined variables.
-     * modify TurnOn/TurnOff macros (in lib_vidattr.c and lib_vid_attr.c)
-       to avoid expansion of "CUR" in trace.
-
-   There are other new demo/test programs and reusable examples:
-
-   color_content
-          Demonstrate   the   color_content   and  extended_color_content
-          functions.
-
-   demo_tabs
-          A simple demo of tabs in curses.
-
-   dump_window
-          A  portable  curses screen-dump, used to compare ncurses screen
-          contents with Solaris.
-
-   pair_content
-          Demonstrate    the   pair_content   and   extended_pair_content
-          functions.
-
-   report_hashing
-          Check hash-tables used for terminfo and termcap names.
-
-   parse_rgb
-          Sample   implementation  of  the  ncurses  RGB  extension  from
-          user_caps.5, used in picsmap and savescreen programs.
-
-   A  variety  of  improvements  were made to existing programs, both new
-   features  as  well  as  options added to make the set of programs more
-   consistent.
-     * add  "-l"  option to test/background, to dump screen contents in a
-       form that lets different curses implementations be compared.
-     * add  "@"  command  to  test/ncurses F-test, to allow rapid jump to
-       different character pages.
-     * added enum, regex examples to test/demo_forms
-     * amend  Scaled256() macro in test/picsmap.c to cover the full range
-       0..1000
-     * corrected  pathname used in Ada95 sample programs for explain.txt,
-       to  work  with  test-packages, and used an awk script to split the
-       resulting pathname when it would be too long for a single line.
-     * ignore  interrupted  system-call  in  test/ncurses's command-line,
-       e.g., if the terminal were resized.
-     * improved  ifdef's  for  TABSIZE  variable,  to  help with AIX/HPUX
-       ports.
+   ncurses-examples:
+     * modify test_tparm to account for extended capabilities
+     * corrected mouse mask in test/testcurs.c
+     * modify test/clip_printw.c to optionally test non-wrapped updates
+     * modify test/test_mouse.c to use curses api for raw/noraw
+     * modify test/clip_printw.c to optionally test non-wrapped updates
+
+   There is one new demo/test programs:
+
+   test/test_endwin.c
+          This program shows the return-status from endwin with different
+          combinations of endwin (repeated), initscr, newterm.
 
   Terminal database
 
    There are several new terminal descriptions:
-
-     alacritty,  domterm,  kitty,  mintty,  mintty-direct,  ms-terminal,
-     n7900,   nsterm-build309,  nsterm-direct,  screen5,  ti703,  ti707,
-     ti703-w, ti707-w vscode, vscode-direct, xterm-mono, xterm.js
+     * ansi+apparrows
+     * contour
+     * linux+kbs for terminals which imitate xterm's behavior with Linux
+     * rio, rio-direct
+     * mostlike
+     * ms-vt100-16color, winconsole
+     * vt100+noapp,   vt100+noapp+pc,  xterm+app+pc,  xterm+decedit  from
+       xterm #389
+     * putty+cursor to reflect amending of modified cursor-keys in 2021
+     * wezterm
 
    There  are  many  changes to existing terminal descriptions. Some were
-   updates to several descriptions:
-     * use ansi+rep in a dozen places
-     * add rs1 to konsole, mlterm
-     * improve several flash capabilities with trailing mandatory delays
-     * drop   ich1   from   rxvt-basic,   Eterm  and  mlterm  to  improve
-       compatibility with old non-curses programs
-     * add/use xterm+keypad in xterm-new
-     * use xterm+sl-twm for consistency, nine places
-     * improve xm example in xterm+x11mouse and xterm+sm_1006.
-
-   while  others  affected specific descriptions. These were retested, to
-   take into account changes by their developers:
-
-     terminator, st
-
-   while  these are specific fixes based on reviewing documentation, user
-   reports, or warnings from tic:
-
-   adds200:
-
-          + fix typo
-
-   gnome-256color
-
-          + base entry on "gnome", not "vte", for consistency
-
-   interix
-
-          + trim unnecessary setf/setb
-
-   linux-16color
-
-          + accommodate  Linux  console driver incompatibility introduced
-            in early 2018
-
-   nsterm-256color:
-
-          + add nsterm-build309 to replace nsterm-256color, assigning the
-            latter  as  an  alias  of  nsterm,  to  make  mouse work with
-            nsterm-256color
-
-   regent40:
-
-          + renumber function-keys to match manual
-
-   regent60:
-
-          + add cd (clr_eos)
-          + corrected acsc
-          + add shifted function-keys
-
-   tvi950:
-
-          + added  function-key  definitions  to agree with Televideo 950
-            manual
-          + corrected acsc
-          + remove bogus kf0
-          + add bel
-
-   tvi955:
-
-          + fix typo
-
-   vi200:
-
-          + add acsc string, including right/down-arrow
-
-   wy50:
-
-          + corrected acsc
-
-   wy50 and wy60:
-
-          + add shifted function-keys as kF1 to kF16
-
-   xterm+x11hilite:
-
-          + eliminate unused p5 parameter.
-
-   A few entries use extensions (user-defined terminal capabilities):
-     * use  xterm+sm+1006  (aka  "SGR  1006  mouse") for konsole-base and
-       putty
-     * add Smol/Rmol user-defined capability to tmux and vte-2018
-     * add Smulx user-defined capability to tmux, vte-2018
+   updates  to  several  descriptions, using the infocmp "-u" option in a
+   script  to  determine  which  building-block  entries could be used to
+   replace multiple capability settings (and trim redundant information).
+
+   Other changes include:
+     * document XF, kxIN and kxOUT
+     * add note on sun regarding wscons/cmdtool/shelltool
+     * remove DECCOLM+DECSCLM from foot
+     * add xterm+focus to foot+base
+     * add ecma+strikeout to putty
+     * use CSI 3J in vte-2017
+     * use oldxterm+sm+1006 in vte-2014
+     * modify xgterm to work around line-drawing bug
+     * add  xterm  focus  mode 1004 to xterm+focus as fe/fd capabilities,
+       like vim.
+     * add xterm+focus to alacritty+common
+     * add  XR/xr,  to work with vim, and use RV/rv to denote DA2 and its
+       response
+     * add  XF  flag  to  xterm+focus so that termcap applications can be
+       aware of terminals which may support focus in/out
+     * use xterm+focus in xterm-p370 and tmux
+     * remove xterm+sm+1006 from tmux
+     * NetBSD-related fixes for x68k and wsvt25
 
   Documentation
 
@@ -408,273 +260,157 @@ Release Notes
    features   and   show   how   they  evolved,  there  are  corrections,
    clarifications, etc.:
      * Corrections:
-          + correct  error-returns  listed in manual pages for a few form
-            functions
-          + corrected  prototypes  in  several  manpages  using script to
-            extract those in compilable form.
-          + fix typo in term.5, improve explanation of format
-     * Clarify in manual pages that vwprintw and vwscanw are obsolete.
-       They have not been part of X/Open Curses since 2007.
+          + add   assignment   in  CF_MAN_PAGES  to  fill  in  value  for
+            TERMINFO_DIRS in ncurses, terminfo and tic manpages.
+          + clarify  interaction  of  -R  option  versus -C, -I and -r in
+            infocmp manpage.
+          + correct manpage description of panel_hidden.
+          + improve  manpage  description  for addch versus unctrl format
+            used for non-printable characters.
+          + improve  manpages  discussing  file  descriptors in low-level
+            functions.
+          + improve description of search rules for terminal descriptions
+            in terminfo manpage.
+          + modify  dist.mk  to  avoid  passing  developer's  comments in
+            manpages into the generated html documentation.
+          + modify  test-package  "ncurses6-doc"  to use manpage-aliases,
+            which  in  turn  required a change to the configure script to
+            factor in the extra-suffix option when deriving alias names.
      * New/improved history and portability sections:
-          + curs_addch.3x gives some background for ACS symbols.
-          + curs_getcchar.3x  explains  a  difference between ncurses and
-            X/Open Curses.
-          + curs_getstr.3x  gives  historical/portability  background for
-            the length parameter of wgetnstr.
-          + curs_slk.3x  lists  a few differences between SVr4 curses and
-            X/Open Curses for soft-keys.
-          + curs_terminfo.3x  explains that the initial implementation of
-            terminfo  in  SVr2 was mostly replaced by other developers in
-            SVr3.
-          + infocmp.1  explains  that the initial version of terminfo had
-            no  tool  for decompiling descriptions. That came later, with
-            SVr3, with a different developer.
-          + tabs.1 tells more than you wanted to know about the tool.
-          + tic.1  explains  that  the  initial version of terminfo had a
-            rudimentary  tool  (based  on termcap) for compiling entries.
-            The tool used with Unix was developed by others for SVr3.
-          + toe.1 explains the origin of this tool.
-     * Improvements for user_caps.5:
-          + mention meml, memu and box1
-          + expanded description of XM
-          + add a clarification regarding the RGB capability.
-          + mention user_caps.5 in the tic and infocmp manual pages.
+          + add  information  about  "ttycap",  termcap's  forerunner, to
+            tset.1
+          + document   limitations   of   tparm,   and  error-returns  in
+            curs_terminfo.3x
+          + document   limitations   of   tgoto,   and  error-returns  in
+            curs_termcap.3x
      * Other improvements:
-          + curs_add_wch.3x  adds  note about Unicode terminology for the
-            line-drawing characters.
-          + curs_color.3x   improves  discussion  of  error  returns  and
-            extensions.
-          + curs_mouse.3x  explains how the kmous and XM capabilities are
-            used for xterm-mouse input.
-          + curs_refresh.3x  improves documentation regarding the virtual
-            and physical screens.
-          + curs_util.3x  mentions  a  difference between SVr4 and X/Open
-            Curses for unctrl.h
-          + curs_variables.3x   improves  description  of  the  init_tabs
-            capability and TABSIZE variable.
-          + ncurses.3x   improves  documentation  regarding  feature-test
-            macros in curses.h
-          + resizeterm.3x   about   top-level  windows  which  touch  the
-            screen's borders.
-          + tput.1 clarifies how tput determines the terminal size.
+          + This  release  has many changes to improve the formatting and
+            style of the manpages.
+          + Manpages  now use consistent section-naming, page headers and
+            footers (including the modification date for each page).
+          + Table layout has been revised.
 
    There  are  no new manual pages (all of the manual page updates are to
    existing pages).
 
-   Some  of  the  improvements  are  more subtle, relating to the way the
-   information  is presented. For instance, the generated terminfo.5 file
-   uses  a  different  table  layout,  allowing  it  to use space on wide
-   terminals more effectively.
-
   Interesting bug-fixes
 
-   While  there  were  many bugs fixed during development of ncurses 6.2,
-   only  a  few  (the  reason  for  this release) were both important and
-   interesting. Most of the bug-fixes were for local issues which did not
-   affect  compatibility across releases. Since those are detailed in the
-   NEWS file no elaboration is needed here.
-
-   The  interesting  bugs  were in tic/infocmp's handling of user-defined
-   capabilities.  These  were  not recent bugs. Initially it was a simple
-   problem:
-     * The  user-defined capabilities can be any type (boolean, number or
-       string),  but  once given a type all uses of the name must conform
-       to  that  type--unless  some  special  support  for  a  particular
-       multi-typed name is built into ncurses.
-     * One of simpleterm's contributors copied some definitions for using
-       tmux's user-defined capabilities in late in 2016.
-
-diff --git a/st.info b/st.info
-@@ -185,7 +185,10 @@ st| simpleterm,
-  tsl=\E]0;,
-  xenl,
-  vpa=\E[%i%p1%dd,
--
-+# Tmux unofficial extensions, see TERMINFO EXTENSIONS in tmux(1)
-+ Se,
-+ Ss,
-+ Tc,
-
- st-256color| simpleterm with 256 colors,
-  use=st,
-
-     * Later,  in (referring to a version from mid-2017), a user asked to
-       have it updated in ncurses.
-     * However,  it  had  an  error  from  the  change  in late 2016. The
-       terminal description made what tmux expected to be string actually
-       a boolean.
-       Over  the  years,  there  were  problems with each of simpleterm's
-       terminal  descriptions.  I  repaired those, and usually dealt with
-       the problem.
-     * The  difference  in this case was that when compiling the terminal
-       database, tic may have in memory the definitions for more than one
-       terminal  description  (so  that  it  can resolve "use=" clauses).
-       Seeing   two  different  types  for  the  same  name,  in  certain
-       situations  it  would  incorrectly merge the symbol tables for the
-       two terminal descriptions.
-     * On  simpleterm's  side,  their bug was finally fixed in late 2019,
-       three years after the bug was created.
-
-   For  ncurses,  the  elapsed  time  to fix this bug was less than three
-   years.  Someone reported a problem with the terminal description a few
-   weeks  after  releasing  ncurses 6.1 (in tmux #1264), and the terminal
-   description was updated that week (ncurses patch 20180224):
-
-20180224
-        + modify _nc_resolve_uses2() to detect incompatible types when merging
-          a "use=" clause of extended capabilities.  The problem was seen in a
-          defective terminfo integrated from simpleterm sources in 20171111,
-          compounded by repair in 20180121.
-        + correct Ss/Ms interchange in st-0.7 entry (tmux #1264) -TD
-
-   The larger part of that change added a check to prevent a simple merge
-   of  terminal  descriptions  where  the same user-defined name was used
-   with different types. But it raised some questions:
-     * Was  there  a  reliable  way to manage terminal descriptions which
-       used the same extended name in different ways?
-     * Should  ncurses  provide  a registry of well-known extended names,
-       with their types?
-
-   Since  the  correction to terminfo.src could have been readily adopted
-   by  packagers,  there  was  nothing  more  to  be  done  from ncurses'
-   standpoint  on that part. But improving ncurses to prevent issues like
-   that is the reason for making a release.
-
-   Nothing  more  (constructive) was mentioned with regard to simpleterm.
-   But  a  few  problems  were  found  in  the  handling  of user-defined
-   capabilities:
-     * Forward-references to user-defined capabilities in a "use=" clause
-       did  not  allocate  new  data  for  each  use.  In tic, successive
-       compilation   of   terminal   entries   could   add   user-defined
-       capabilities to the wrong terminal entry.
-       This  was  not noticed before, since xterm's terminal descriptions
-       were  the main users of the feature, and almost all of the uses of
-       the building-blocks which contained user-defined capabilities were
-       backward-references.
-     * There  is  one  (documented)  case  where  ncurses  6.1 supports a
-       user-defined  capability that could be any type (i.e., "RGB"). The
-       check  added  in February 2018 to guard against mismatches did not
-       handle all of the combinations needed.
-
-   Both  of  these  issues  dated  from  the  original  implementation of
-   user-defined  capabilities.  Fixing  them does not change the terminal
-   database, but a older tic without the fixes will not be able to handle
-   terminfo  sources  which rely upon those fixes. Starting in June 2019,
-   the  download  link  for  the  terminfo source file was capped at that
-   date. The development sources have an up-to-date copy of the file, for
-   people with a legitimate need for it.
-
-   The  "-c"  (check) option of tic is not very useful if it cannot offer
-   advice on parameters needed for user-defined capabilities. The various
-   Caps  files  were  reorganized to reduce redundancy, and in the common
-   portion  (Caps-ncurses),  a  registry  of user-defined capabilities is
-   provided for use by tic. While users can still define their own custom
-   capabilities,  tic  will not offer any advice when their parameters do
-   not match.
-
-   In  ncurses  6.2, tic makes a special check to allow any type for RGB,
-   but  its  being  able to do this relies upon fixes made in the ncurses
-   library in mid-2019.
+   The  changes to tparm, tgoto which improve the design of the low-level
+   interfaces are interesting, but are not bug-fixes per se.
 
   Configuration changes
 
     Major changes
 
-   There  are  no  major  changes. Several new options were added to ease
-   integration  of packages with systems using different versions of GNAT
-   and ncurses. Also, improvements were made to configure checks.
+   These are the major changes (aside from introducing tiparm_s):
+     * use wide-character (ncursesw) by default
+     * use opaque typedefs by default
+
+   However,  most  of  the  work  on configure scripts was done to reduce
+   warnings within the configure script:
+     * intrusive warnings from GNU grep regarding fgrep and egrep
+     * fatal  errors  in  compile-checks,  arising from recent "Modern C"
+       efforts  by  some  developers  which caused longstanding configure
+       checks to fail.
+       After  repairing  the  configure  script,  none  of  that activity
+       affected  ncurses  because stricter warnings are used routinely in
+       development.
+
+   Other improvements made to configure checks include
+     * use  string-hacks in alloc_entry.c, alloc_type.c and hardscroll.c,
+       overlooked due to compiler changes in recent OpenBSD releases
+     * revise progs.priv.h to provide for NC_ISATTY reuse
+     * configure check for MB_LEN_MAX provides warning as needed
+     * trim   a   space  after  some  "-R"  options,  fixing  builds  for
+       applications built using clang and ncurses on Solaris
+     * work  around  misconfiguration  of  MacPorts  gcc13, which exposes
+       invalid  definition  of  MB_LEN_MAX  in  gcc's  fallback  copy  of
+       limits.h
+     * modified  experimental  Windows  driver  works  with  xterm  mouse
+       protocol
 
     Configuration options
 
-   There are a few new/modified configure options:
+   There are a few new configure options:
+
+   --disable-setuid-environ
+          Compile  with  environment  restriction, so certain environment
+          variables  are  not  available when running via a setuid/setgid
+          application. These are (for example $TERMINFO) those that allow
+          the  search  path  for  the  terminfo  or  termcap  entry to be
+          customized.
+
+          A  setuid/setgid application inherits its environment variables
+          from  the current user, in contrast to sudo which may limit the
+          environment variables that ncurses uses.
 
-   --with-config-suffix
-          helps  work  around  a  filename  conflict with Debian packages
-          versus test-packages.
+   --enable-check-size
+          Compile-in  feature to detect screensize for terminals which do
+          not advertise their screensize, e.g., serial terminals.
 
-   --with-ada-libname
-          allows  one  to  rename  the  "AdaCurses" library (at least one
-          packager prefers a lowercase name).
+   --with-abi-altered=NUM
+          Override  the  displayed  (rather  than  compiled-in) ABI. Only
+          packagers who have created configurations where the ABI differs
+          from ncurses should be interested in this option.
 
-   --with-fallbacks
-          now ensures there is a value, and adds the fallback information
-          to top-level Makefile summary.
+   --with-strip-program=XXX
+          When  stripping  executables  during install, use the specified
+          program  rather  than  "strip" overriding program chosen by the
+          install program for stripping executables.
 
-   --with-pcre2
-          check for pcre-posix library to help with MinGW port.
+   These configure options are modified:
 
-   --with-tic-path and
+   --with-pkg-config-libdir[=DIR]
+          The  optional  DIR parameter can now be "auto" to automatically
+          use pkg-config's library directory.
 
-   --with-infocmp-path
-          help  work  around  problems  building  fallback  source  using
-          pre-6.0 tic/infocmp.
+          The default is $(libdir).
 
-   --with-versioned-syms
-          option value can now be a relative pathname.
+   --with-xterm-kbs[=XXX]
+          The  default  is  "auto"  which  tells  the configure script to
+          choose BS or DEL according to platform defaults.
 
   Portability
 
    Many  of  the  portability  changes  are implemented via the configure
    script:
-     * ignore $TERMINFO as a default value in configure script if it came
-       from the infocmp -Q option.
-     * distinguish  gcc  from  icc  and  clang when the --enable-warnings
-       option   is   not   used,  to  avoid  unnecessary  warnings  about
-       unrecognized inline options
-     * consistently  prepend  new  libraries  as  they  are  found during
-       configuration,  rather  than  relying  upon  the linker to resolve
-       order dependencies of libraries.
-     * modified  configure  scripts  to  reduce  relinking/ranlib  during
-       library install :
-          + use  "install -p" when available, to avoid need for ranlib of
-            static libraries.
-          + scripts which use "--disable-relink;" add a 1-second sleep to
-            work around tools which use whole-second timestamps, e.g., in
-            utime rather than the actual file system resolution.
-     * add configure check for getenv to work around implementation shown
-       in  Emscripten  which overwrites the previous return value on each
-       call.
-       Use  that  to optionally suppress START_TRACE macro, whose call to
-       getenv may not work properly
-     * change  target configure level for _XOPEN_SOURCE to 600 to address
-       use of vsscanf and setenv.
-     * reduce  use of _GNU_SOURCE for current glibc where _DEFAULT_SOURCE
-       combines with _XOPEN_SOURCE
-       Allow  for  Cygwin's  newlib when checking for the _DEFAULT_SOURCE
-       symbol.
-       MidnightBSD   is   now   checked   for  the  _XOPEN_SOURCE-related
-       definitions.
-     * If the check for va_copy or __va_copy fails,
-          + configure  now  tries copying the pointers for va_list, or as
-            an array.
-          + alternatively, it checks for __builtin_va_copy(), which could
-            be used with AIX xlc in c89 mode.
-     * several changes to support a port to Ultrix 3.1:
-          + check if "b" binary feature of fopen works
-          + check for missing feature of locale.h
-          + add fallback for strstr() in test-programs
-          + add fallback for STDOUT_FILENO in test-programs
-     * The test/configure script (used for ncurses-examples) is improved:
-          + work around non-ncurses termcap.h file, e.g., in Slackware.
-          + check for TABSIZE variable.
-          + checks  for  the  X11/Intrinsic.h  header, accommodate recent
-            MacOS changes which largely emptied /usr/include.
+     * add/use   configure   check   for   clock_gettime,   to  supersede
+       gettimeofday.
+     * modify  configure script check for pkg-config library directory to
+       take   into   account   an   older   version   0.15.0  which  used
+       PKG_CONFIG_PATH but not PKG_CONFIG_LIBDIR
+     * allow for MinGW32-/64-bit configurations to use _DEFAULT_SOURCE
+     * modify   CF_XOPEN_SOURCE  macro's  amend  default  case  to  avoid
+       undefining _XOPEN_SOURCE if _POSIX_C_SOURCE is defined
+     * updated configure script macro CF_XOPEN_SOURCE, for uClibc-ng
+     * modify version-check for gcc/g++, now works for msys2
+     * build-fixes related to configure-options and/or platform:
+          + fix for --enable-fvisibility
+          + fix for unusual values of --with-rel-version
+          + fix for unusual values of --with-abi-version
+          + fix for --disable-tcap-names
+          + fix for termcap in nc_access.h
+     * other configure-script improvements:
+          + recent msys2 headers work with _DEFAULT_SOURCE; amend check
+          + use  $ac_includes_default in most cases where stdlib.h should
+            work
+          + use #error consistently vs "make an error"
+          + add configure macro for gettimeofday vs inline check
 
    Here are some of the other portability fixes:
-     * added  dummy  "check"  rule  in  top-level  and  test-Makefile  to
-       simplify building test-packages for ArchLinux.
-     * dropped   library-dependency   on  psapi  for  MinGW  port,  since
-       win_driver.c   defines   PSAPI_VERSION   to   2,   making  it  use
-       GetProcessImageFileName from kernel32.dll
-     * made  build-fixes  for  configuration  using --program-suffix with
-       Ada95,  noticed  with  MacOS  but  applicable  to  other platforms
-       without libpanelw, etc.
-     * modified  ncurses/Makefile.in  to  fix a case where Debian/testing
-       changes to the ld --as-needed configuration broke ncurses-examples
-       test packages.
-     * used   _WIN32/_WIN64   in  preference  to  __MINGW32__/__MINGW64__
-       symbols  to simplify building with Microsoft Visual C++, since the
-       former are defined in both compiler configurations.
+     * modify  configure  scripts/makefiles  to  omit  KEY_RESIZE  if the
+       corresponding SIGWINCH feature is disabled
+     * increase MB_CUR_MAX to 16, matching glibc's MB_LEN_MAX
+     * add BSD erase2 to characters handled by tset/reset
+     * use getauxval when available, to improve setuid/setgid checks
+     * set dwShareMode in calls to CreateConsoleScreenBuffer
+     * use  CreateFile  with "CONIN$", "CONOUT$" rather than GetStdHandle
+       to  obtain a handle on the actual console, avoiding redirection in
+       the MinGW/Win32 configurations
+     * modify  MinGW  driver  to  return KEY_BACKSPACE when an unmodified
+       VK_BACK virtual key is entered
+     * modify  MinGW  configuration  to provide for running in MSYS/MSYS2
+       shells, assuming ConPTY support
      _________________________________________________________________
 
 Features of ncurses
@@ -682,20 +418,21 @@ Features of ncurses
    The  ncurses  package  is  fully upward-compatible with SVr4 (System V
    Release 4) curses:
      * All of the SVr4 calls have been implemented (and are documented).
-     * ncurses  supports  all  of  the for SVr4 curses features including
-       keyboard  mapping,  color,  forms-drawing with ACS characters, and
-       automatic recognition of keypad and function keys.
-     * ncurses  provides  these SVr4 add-on libraries (not part of X/Open
-       Curses):
-          + the  panels  library,  supporting  a  stack  of  windows with
-            backing store.
-          + the   menus   library,  supporting  a  uniform  but  flexible
-            interface for menu programming.
+     * ncurses  supports  the  features of SVr4 curses including keyboard
+       mapping,  color,  form  drawing with ACS characters, and automatic
+       recognition of keypad and function keys.
+     * ncurses  provides  work-alike  replacements  of  SVr4 supplemental
+       libraries  based on curses, but which were not specified by X/Open
+       Curses:
+          + the panel library, supporting a stack of windows with backing
+            store
+          + the menu library, supporting a uniform but flexible interface
+            for menu programming
           + the   form   library,   supporting  data  collection  through
-            on-screen forms.
+            on-screen forms
      * ncurses's  terminal database is fully compatible with that used by
        SVr4 curses.
-          + ncurses  supports user-defined capabilities which it can see,
+          + ncurses  supports  user-defined capabilities that it can see,
             but  which are hidden from SVr4 curses applications using the
             same terminal database.
           + It  can  be optionally configured to match the format used in
@@ -705,14 +442,15 @@ Features of ncurses
             curses.
      * The ncurses utilities have options to allow you to filter terminfo
        entries for use with less capable curses/terminfo versions such as
-       the HP/UX and AIX ports.
+       the HP-UX and AIX ports.
 
    The ncurses package also has many useful extensions over SVr4:
-     * The  API  is 8-bit clean and base-level conformant with the X/OPEN
-       curses  specification, XSI curses (that is, it implements all BASE
-       level  features,  and  most  EXTENDED  features). It includes many
-       function calls not supported under SVr4 curses (but portability of
-       all calls is documented so you can use the SVr4 subset only).
+     * The  API  is 8-bit clean and base-level conformant with the X/Open
+       Curses  specification, XSI curses (that is, it implements all BASE
+       level  features,  and  almost  all EXTENDED features). It includes
+       many   function   calls  not  supported  under  SVr4  curses  (but
+       portability  of  all  calls  is documented so you can use the SVr4
+       subset only).
      * Unlike  SVr3 curses, ncurses can write to the rightmost-bottommost
        corner  of  the  screen  if  your terminal has an insert-character
        capability.
@@ -729,6 +467,7 @@ Features of ncurses
        use of function keys, e.g., disabling the ncurses KEY_MOUSE, or by
        defining  more  than  one  control  sequence to map to a given key
        code.
+     * Support for direct-color terminals, such as modern xterm.
      * Support for 256-color terminals, such as modern xterm.
      * Support for 16-color terminals, such as aixterm and modern xterm.
      * Better  cursor-movement  optimization.  The package now features a
@@ -771,10 +510,19 @@ Features of ncurses
        user's $HOME/.terminfo directory.
      * The  table-of-entries  utility  toe makes it easy for users to see
        exactly what terminal types are available on the system.
-     * The library meets the XSI requirement that every macro entry point
-       have  a  corresponding  function  which may be linked (and will be
-       prototype-checked)  if  the  macro  definition  is  disabled  with
-       #undef.
+     * X/Open  Curses  permits  most  functions  it  specifies to be made
+       available as macros as well. ncurses does this
+          + to  improve  performance,  e.g.,  for  operations composed of
+            simpler functions such as cursor movement following by adding
+            text to the screen,
+          + to simplify the implementation by reusing functions which use
+            common parameters, e.g., the standard screen stdscr, and
+          + to provide functions that return values via their parameters
+       Except   for   the   last   case,  ncurses  provides  a  non-macro
+       implementation  of  the  function.  If  the  macro  definition  is
+       disabled with #undef, or by defining NCURSES_NOMACROS the function
+       may  be  linked  (and  its  calls  will  be  checked  against  the
+       prototype).
      * Extensive  documentation  is  provided (see the Additional Reading
        section of the ncurses FAQ for online documentation).
 
@@ -827,7 +575,8 @@ Applications using ncurses
    nvi
           New vi uses ncurses.
 
-          https://sites.google.com/a/bostic.com/keithbostic/vi
+          https://sites.google.com/a/bostic.com/keithbostic/the-berkeley-
+          vi-editor-home-page
 
    ranger
           A console file manager with VI key bindings in Python.
@@ -849,12 +598,12 @@ Applications using ncurses
    minicom
           terminal emulator for serial modem connections
 
-          https://alioth.debian.org/projects/minicom/
+          https://salsa.debian.org/minicom-team/minicom
 
    mosh
           a replacement for ssh.
 
-          https://mosh.mit.edu/
+          https://mosh.org/
 
    tack
           terminfo action checker
@@ -903,7 +652,7 @@ Development activities
 
    Ongoing development work is done by Thomas E. Dickey. Thomas E. Dickey
    has  acted  as  the maintainer for the Free Software Foundation, which
-   holds  a  copyright on ncurses for releases 4.2 through 6.1. Following
+   held  a  copyright  on ncurses for releases 4.2 through 6.1. Following
    the release of ncurses 6.1, effective as of release 6.2, copyright for
    ncurses  reverted  to  Thomas  E.  Dickey  (see  the  ncurses  FAQ for
    additional information).
@@ -925,17 +674,17 @@ Development activities
 
    Beta versions of ncurses are made available at
 
-     ftp://ftp.invisible-island.net/ncurses/current/ and
+     https://invisible-island.net/archives/ncurses/current/ and
      https://invisible-mirror.net/archives/ncurses/current/ .
 
    Patches to the current release are made available at
 
-     ftp://ftp.invisible-island.net/ncurses/6.1/ and
-     https://invisible-mirror.net/archives/ncurses/6.1/ .
+     https://invisible-island.net/archives/ncurses/6.4/ and
+     https://invisible-mirror.net/archives/ncurses/6.4/ .
 
    There is an archive of the mailing list here:
 
-     http://lists.gnu.org/archive/html/bug-ncurses (also https)
+     https://lists.gnu.org/archive/html/bug-ncurses .
 
 Related resources
 
@@ -944,6 +693,7 @@ Related resources
      * ncurses licensing
      * Symbol versioning in ncurses
      * Comments on ncurses versus slang (S-Lang)
+     * Comments on OpenBSD
      * tack - terminfo action checker
      * tctest - termcap library checker
      * Terminal Database
@@ -954,11 +704,12 @@ Other resources
    terminal description file once maintained by Eric Raymond . Unlike the
    older  version, the termcap and terminfo data are provided in the same
    file, which also provides several user-definable extensions beyond the
-   X/Open specification.
+   X/Open Curses specification.
 
    You  can  find  lots  of  information  on  terminal-related topics not
-   covered  in  the  terminfo  file  at  Richard  Shuford's archive . The
-   collection of computer manuals at bitsavers.org has also been useful.
+   covered  in the terminfo file in Richard Shuford's archive (original).
+   The  collection  of  computer  manuals  at bitsavers.org has also been
+   useful.
 
      * Overview
      * Release Notes
diff --git a/contrib/ncurses/AUTHORS b/contrib/ncurses/AUTHORS
index 0018842ca099..09dfc9a9efa6 100644
--- a/contrib/ncurses/AUTHORS
+++ b/contrib/ncurses/AUTHORS
@@ -1,5 +1,5 @@
 -------------------------------------------------------------------------------
--- Copyright 2020 Thomas E. Dickey                                           --
+-- Copyright 2020,2021 Thomas E. Dickey                                      --
 -- Copyright 2006,2017 Free Software Foundation, Inc.                        --
 --                                                                           --
 -- Permission is hereby granted, free of charge, to any person obtaining a   --
@@ -26,13 +26,13 @@
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
--- $Id: AUTHORS,v 1.4 2020/02/02 23:34:34 tom Exp $
+-- $Id: AUTHORS,v 1.5 2021/06/17 21:20:30 tom Exp $
 -------------------------------------------------------------------------------
 These are the principal authors/contributors of ncurses since 1.9.9e,
 in decreasing order of their contribution:
 
 TD	Thomas E. Dickey
-JPF	Juergen Pfeifer 
+JPF	Juergen Pfeifer
 ESR	Eric S Raymond
 AVL	Alexander V Lukyanov
 PB	Philippe Blain
diff --git a/contrib/ncurses/COPYING b/contrib/ncurses/COPYING
index 3a2297536813..540047f121f1 100644
--- a/contrib/ncurses/COPYING
+++ b/contrib/ncurses/COPYING
@@ -1,4 +1,4 @@
-Copyright 2018-2020,2021 Thomas E. Dickey
+Copyright 2018-2023,2024 Thomas E. Dickey
 Copyright 1998-2017,2018 Free Software Foundation, Inc.
 
 Permission is hereby granted, free of charge, to any person obtaining a
@@ -26,4 +26,4 @@ sale, use or other dealings in this Software without prior written
 authorization.
 
 -- vile:txtmode fc=72
--- $Id: COPYING,v 1.10 2021/01/01 09:54:30 tom Exp $
+-- $Id: COPYING,v 1.13 2024/01/05 21:13:17 tom Exp $
diff --git a/contrib/ncurses/INSTALL b/contrib/ncurses/INSTALL
index 95f5a3931683..a2076eeec261 100644
--- a/contrib/ncurses/INSTALL
+++ b/contrib/ncurses/INSTALL
@@ -1,5 +1,5 @@
 -------------------------------------------------------------------------------
--- Copyright 2018-2019,2020 Thomas E. Dickey                                 --
+-- Copyright 2018-2023,2024 Thomas E. Dickey                                 --
 -- Copyright 1998-2017,2018 Free Software Foundation, Inc.                   --
 --                                                                           --
 -- Permission is hereby granted, free of charge, to any person obtaining a   --
@@ -26,7 +26,7 @@
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
--- $Id: INSTALL,v 1.226 2020/09/06 23:41:16 tom Exp $
+-- $Id: INSTALL,v 1.254 2024/04/27 14:21:05 tom Exp $
 ---------------------------------------------------------------------
              How to install Ncurses/Terminfo on your system
 ---------------------------------------------------------------------
@@ -35,10 +35,10 @@
     * READ ALL OF THIS FILE BEFORE YOU TRY TO INSTALL NCURSES. *
     ************************************************************
 
-You should be reading the file INSTALL in a directory called ncurses-d.d, where
-d.d is the current version number.  There should be several subdirectories,
-including `c++', `form', `man', `menu', 'misc', `ncurses', `panel', `progs',
-and `test'.  See the README file for a roadmap to the package.
+You should be reading the file INSTALL in a directory called ncurses-d.d,
+where d.d is the current version number.  There should be several
+subdirectories, including 'c++', 'form', 'man', 'menu', 'misc', 'ncurses',
+'panel', 'progs', and 'test'.  See 'README' for a roadmap to the package.
 
 If you are a distribution integrator or packager, please read and act on the
 section titled FOR SYSTEM INTEGRATORS below.
@@ -47,9 +47,10 @@ If you are converting from BSD curses and do not have root access, be sure
 to read the BSD CONVERSION NOTES section below.
 
 If you are trying to build applications using gpm with ncurses,
-read the USING NCURSES WITH GPM section below.
+read the USING GPM section below.
 
-If you are cross-compiling, see the note below on BUILDING WITH A CROSS-COMPILER.
+If you are cross-compiling, see the note below on
+BUILDING WITH A CROSS-COMPILER.
 
 If you want to build the Ada95 binding, go to the Ada95 directory and
 follow the instructions there.  The Ada95 binding is not covered below.
@@ -72,14 +73,14 @@ Ncurses has been also built in the OS/2 EMX environment.
 INSTALLATION PROCEDURE:
 ----------------------
 
-1.  First, decide whether you want ncurses to replace your existing library (in
-    which case you'll need super-user privileges) or be installed in parallel
-    with it.
+1.  First, decide whether you want ncurses to replace your existing library
+    (in which case you'll need super-user privileges) or be installed in
+    parallel with it.
 
     The --prefix option to configure changes the root directory for installing
     ncurses.  The default is normally in subdirectories of /usr/local, except
     for systems where ncurses is normally installed as a system library (see
-    "IF YOU ARE A SYSTEM INTEGRATOR").  Use --prefix=/usr to replace your
+    "FOR SYSTEM INTEGRATORS").  Use --prefix=/usr to replace your
     default curses distribution.
 
     The package gets installed beneath the --prefix directory as follows:
@@ -106,16 +107,16 @@ INSTALLATION PROCEDURE:
 
     See also the discussion of --with-install-prefix.
 
-2.  Type `./configure' in the top-level directory of the distribution to
+2.  Type './configure' in the top-level directory of the distribution to
     configure ncurses for your operating system and create the Makefiles.
     Besides --prefix, various configuration options are available to customize
-    the installation; use `./configure --help' to list the available options.
+    the installation; use './configure --help' to list the available options.
 
     If your operating system is not supported, read the PORTABILITY section in
     the file ncurses/README for information on how to create a configuration
     file for your system.
 
-    The `configure' script generates makefile rules for one or more object
+    The 'configure' script generates makefile rules for one or more object
     models and their associated libraries:
 
 	libncurses.a (normal)
@@ -145,7 +146,7 @@ INSTALLATION PROCEDURE:
     the library names (e.g., libncursest.a, libncursestw.a).
 
     If you do not specify any models, the normal and debug libraries will be
-    configured.  Typing `configure' with no arguments is equivalent to:
+    configured.  Typing 'configure' with no arguments is equivalent to:
 
 	./configure --with-normal --with-debug --enable-overwrite
 
@@ -176,10 +177,10 @@ INSTALLATION PROCEDURE:
     You can make curses and terminfo fall back to an existing file of termcap
     definitions by configuring with --enable-termcap.  If you do this, the
     library will search /etc/termcap before the terminfo database, and will
-    also interpret the contents of the TERM environment variable.  See the
+    also interpret the contents of the $TERM environment variable.  See the
     section BSD CONVERSION NOTES below.
 
-3.  Type `make'.  Ignore any warnings, no error messages should be produced.
+3.  Type 'make'.  Ignore any warnings; no error messages should be produced.
     This should compile the ncurses library, the terminfo compiler tic(1),
     captoinfo(1), infocmp(1), toe(1), clear(1) tset(1), reset(1), and tput(1)
     programs (see the manual pages for explanation of what they do), some test
@@ -195,8 +196,9 @@ INSTALLATION PROCEDURE:
     database before running the test programs.  Not all vendors' terminfo
     databases are SVr4-compatible, but most seem to be.
 
-    It is possible to configure ncurses to use other terminfo database formats.
-    A few are provided as examples in the include-directory (see --with-caps).
+    It is possible to configure ncurses to use other terminfo database
+    formats.  A few are provided as examples in the include-directory (see
+    --with-caps).
 
     If you run the test programs WITHOUT installing terminfo, ncurses may
     read the termcap file and cache that in $HOME/.terminfo, which will
@@ -207,21 +209,21 @@ INSTALLATION PROCEDURE:
     You can use it to verify that the screen highlights work correctly, that
     cursor addressing and window scrolling works OK, etc.
 
-5.  Once you've tested, you can type `make install' to install libraries,
-    the programs, the terminfo database and the manual pages.  Alternately, you
-    can type `make install' in each directory you want to install.  In the
+5.  Once you've tested, you can type 'make install' to install libraries,
+    the programs, the terminfo database and the manual pages.  Alternately,
+    you can type 'make install' in each directory you want to install.  In the
     top-level directory, you can do a partial install using these commands:
 
 	'make install.progs'    installs tic, infocmp, etc...
 	'make install.includes' installs the headers.
 	'make install.libs'     installs the libraries (and the headers).
-	'make install.data'     installs the terminfo data. (Note: `tic' must
+	'make install.data'     installs the terminfo data. (Note: 'tic' must
 				be installed before the terminfo data can be
 				compiled).
 	'make install.man'      installs the manual pages.
 
   ############################################################################
-  #     CAVEAT EMPTOR: `install.data' run as root will NUKE any existing     #
+  #     CAVEAT EMPTOR: 'install.data' run as root will NUKE any existing     #
   #  terminfo database. If you have any custom or unusual entries SAVE them  #
   #  before you install ncurses.                                             #
   ############################################################################
@@ -242,8 +244,8 @@ INSTALLATION PROCEDURE:
     compile using its curses.h you'll end up with a large number of
     undefined symbols at link time.
 
-    IF YOU DO NOT HAVE ROOT: Change directory to the `progs' subdirectory
-    and run the `capconvert' script.  This script will deduce various things
+    IF YOU DO NOT HAVE ROOT: Change directory to the 'progs' subdirectory
+    and run the 'capconvert' script.  This script will deduce various things
     about your environment and use them to build you a private terminfo tree,
     so you can use ncurses applications.
 
@@ -273,13 +275,13 @@ CONFIGURE OPTIONS:
 
 	./configure --help
 
-    The --help and several options are common to all configure scripts that are
-    generated with autoconf.  Those are all listed before the line
+    The --help and several options are common to all configure scripts that
+    are generated with autoconf.  Those are all listed before the line
 
 	--enable and --with options recognized:
 
-    The other options are specific to this package.  We list them in alphabetic
-    order.
+    The other options are specific to this package.  We list them in
+    alphabetic order.
 
     --disable-assumed-color
 	With ncurses 5.1, we introduced a new function, assume_default_colors()
@@ -444,7 +446,7 @@ CONFIGURE OPTIONS:
 		--with-menu-libname=XXX
 		--with-panel-libname=XXX
 
-	Rather than renaming them abitrarily, a prefix or suffix is
+	Rather than renaming them arbitrarily, a prefix or suffix is
 	recommended.  An "n" prefix provides consistency with ncurses versus
 	curses, i.e.,
 
@@ -453,8 +455,8 @@ CONFIGURE OPTIONS:
 		--with-panel-libname=npanel
 
     --disable-pkg-ldflags
-	Omit options in $EXTRA_LDFLAGS from the pkg-config ".pc" and
-	corresponding ncurses*-config script which normally are listed via
+	Omit options in $LDFLAGS and $EXTRA_LDFLAGS from the pkg-config ".pc"
+	and corresponding ncurses*-config script which normally are listed via
 	the "--libs" option.  These options are normally used to facilitate
 	linking to ncurses when it was configured to use the rpath feature.
 
@@ -475,11 +477,19 @@ CONFIGURE OPTIONS:
 	filesystems.  This option adds a 1-second sleep to help those tools
 	avoid unnecessary relinking during the install process.
 
+    --disable-root-access
+	Compile with environment restriction, so most file-access is limited
+	when running as root, or via a setuid/setgid application.
+
     --disable-root-environ
 	Compile with environment restriction, so certain environment variables
-	are not available when running as root, or via a setuid/setgid
-	application.  These are (for example $TERMINFO) those that allow the
-	search path for the terminfo or termcap entry to be customized.
+	are not available when running as root.  These are (for example
+	$TERMINFO) those that allow the search path for the terminfo or termcap
+	entry to be customized.
+
+	Disabling the root environment variables also disables the setuid
+	environment variables by default.  Use the --disable-setuid-environ
+	option to modify this behavior.
 
     --disable-rpath-hack
 	Normally the configure script helps link libraries found in unusual
@@ -494,6 +504,16 @@ CONFIGURE OPTIONS:
     --disable-stripping
 	Do not strip installed executables.
 
+    --disable-setuid-environ
+	Compile with environment restriction, so certain environment variables
+	are not available when running via a setuid/setgid application.  These
+	are (for example $TERMINFO) those that allow the search path for the
+	terminfo or termcap entry to be customized.
+
+	A setuid/setgid application inherits its environment variables from
+	the current user, in contrast to sudo which may limit the environment
+	variables that ncurses uses.
+
     --disable-tic-depends
 	When building shared libraries, normally the tic library is linked to
 	depend upon the ncurses library (or equivalently, on the tinfo-library
@@ -512,26 +532,6 @@ CONFIGURE OPTIONS:
 	list documented in X/Open.  ncurses provides varargs support for this
 	function.  Use --disable-tparm-varargs to disable this support.
 
-    --disable-wattr-macros
-	The 6.0 ABI adds support for extended colors and for extended mouse.
-	The former is a noticeable problem when developers inadvertently
-	compile using the ncurses6 header files and link with an ncurses5
-	library, because the wattr* macros use a new field in the WINDOW
-	structure.  These macros are used in several applications.
-
-	Since ncurses provides an actual function for each of these macros,
-	suppressing them from the curses.h header allows the ncurses5 libraries
-	to be used in most applications.
-
-	NOTE: The extended colors also are used in the cchar_t structure, but
-	fewer applications use that.
-
-	NOTE: This workaround does not help with mismatches in the ncurses
-	mouse version.  The extended mouse feature uses one less fewer bit for
-	each button, so that only the first button will work as expected with
-	a mismatch between header and library.  Again, most applications will
-	work, since most use only the first button.
-
     --enable-assertions
 	For testing, compile-in assertion code.  This is used only for a few
 	places where ncurses cannot easily recover by returning an error code.
@@ -553,6 +553,10 @@ CONFIGURE OPTIONS:
 	Recognize BSD-style prefix padding.  Some ancient BSD programs (such as
 	nethack) call tputs("50") to implement delays.
 
+    --enable-check-size
+	Compile-in feature to detect screensize for terminals which do not
+	advertise their screensize, e.g., serial terminals.
+
     --enable-colorfgbg
 	Compile with experimental $COLORFGBG code.  That environment variable
 	is set by some terminal emulators as a hint to applications, by
@@ -666,9 +670,17 @@ CONFIGURE OPTIONS:
     --enable-opaque-form
     --enable-opaque-menu
     --enable-opaque-panel
-	Define symbol in curses.h which controls whether some library
-	structures are treated as "opaque".  The --enable-opaque-curses option
-	is overridden by the --enable-reentrant option.
+	Define symbol in curses.h controlling whether some library structures
+	are opaque, meaning that their members are accessible only via the
+	documented API.  The --enable-opaque-curses option may be overridden
+	by the --enable-reentrant option.
+
+	Enabling opaque-curses enables opaque for the form, menu, and panel
+	libraries.  Use their corresponding options to disable the feature
+	individually.
+
+	NOTE: beginning with ncurses 6.5 this option is enabled by default;
+	older versions disable it by default.
 
     --enable-pc-files
 	If pkg-config is found (see --with-pkg-config), generate ".pc" files
@@ -728,6 +740,14 @@ CONFIGURE OPTIONS:
 	reducing the need for juggling the global SP value with set_term() and
 	delscreen().
 
+    --enable-stdnoreturn
+	When enabled, check if the <stdnoreturn.h> header exists, and if found
+	define GCC_NORETURN to _Noreturn rather than either the gcc-specific
+	__attribute__((noreturn)) or an empty token.  Doing this may require
+	calling programs which use GCC_NORETURN in their own function
+	definitions to be modified, because _Noreturn is only accepted as
+	the first token in a declaration.
+
     --enable-string-hacks
 	Controls whether strlcat and strlcpy may be used.  The same issue
 	applies to OpenBSD's warnings about snprintf, noting that this function
@@ -766,6 +786,26 @@ CONFIGURE OPTIONS:
     --enable-warnings
 	Turn on GCC compiler warnings.  There should be only a few.
 
+    --enable-wattr-macros
+	The 6.0 ABI adds support for extended colors and for extended mouse.
+	The former is a noticeable problem when developers inadvertently
+	compile using the ncurses6 header files and link with an ncurses5
+	library, because the wattr* macros use a new field in the WINDOW
+	structure.  These macros are used in several applications.
+
+	Since ncurses provides an actual function for each of these macros,
+	suppressing them from the curses.h header allows the ncurses5 libraries
+	to be used in most applications.
+
+	NOTE: The extended colors also are used in the cchar_t structure, but
+	fewer applications use that.
+
+	NOTE: This workaround does not help with mismatches in the ncurses
+	mouse version.  The extended mouse feature uses one less fewer bit for
+	each button, so that only the first button will work as expected with
+	a mismatch between header and library.  Again, most applications will
+	work, since most use only the first button.
+
     --enable-weak-symbols
 	If the --with-pthread option is set, check if the compiler supports
 	weak-symbols.  If it does, then name the thread-capable library without
@@ -786,14 +826,22 @@ CONFIGURE OPTIONS:
 	symbolic link to equate libncurses.so with libncursesw.so
 
 	NOTE: the Ada95 binding may be built against either version of the the
-	ncurses library, but you must decide which:  the binding installs the
-	same set of files for either version.  Currently (2002/6/22) it does
+	ncurses library, but you must decide which: the binding installs the
+	same set of files for either version.  Currently (2023/10/21) it does
 	not use the extended features from the wide-character code, so it is
 	probably better to not install the binding for that configuration.
 
+	NOTE: beginning with ncurses 6.5 this option is enabled by default;
+	older versions disable it by default.
+
     --enable-xmc-glitch
 	Compile-in support experimental xmc (magic cookie) code.
 
+    --with-abi-altered=NUM
+	Override the displayed (rather than compiled-in) ABI.  Only packagers
+	who have created configurations where the ABI differs from ncurses
+	should be interested in this option.
+
     --with-abi-version=NUM
 	Override the ABI version, which is used in shared library filenames.
 	Normally this is the same as the release version; some ports have
@@ -891,8 +939,9 @@ CONFIGURE OPTIONS:
 	script supplies "unsigned").
 
     --with-config-suffix=XXX
-	Specify a suffix for the ncursesw6-config file, etc., used to work
-	around conflicts with packages.
+	Specify an suffix for "ncurses*" in the ncurses*-config filename to
+	work around conflicts with packages.  The suffix is placed before the
+	dash.
 
     --with-cxx-libname=NAME
 	Override the basename of the ncurses++ library (default: "ncurses++")
@@ -997,7 +1046,7 @@ CONFIGURE OPTIONS:
 	See also the --enable-getcap option.
 
     --with-infocmp-path[=XXX]
-	Use this option to override the automatic detection of tic in your
+	Use this option to override the automatic detection of infocmp in your
 	$PATH when building fallbacks (see "--with-fallbacks").
 
     --with-install-prefix=XXX
@@ -1113,9 +1162,10 @@ CONFIGURE OPTIONS:
 	Override the basename of the panel library (default: "panel")
 
     --with-pc-suffix=SUFFIX
-	If ".pc" files are installed, optionally add a suffix to the files
-	and corresponding package names to separate unusual configurations.
-	If no option value is given (or if it is "none"), no suffix is added.
+	If ".pc" files are installed (see --enable-pc-files), optionally add a
+	suffix to the files and corresponding package names to separate
+	unusual configurations.  If no option value is given (or if it is
+	"none"), no suffix is added.
 
     --with-pcre2
 	Add PCRE2 (Perl-compatible regular expressions v2) to the build if it
@@ -1126,12 +1176,28 @@ CONFIGURE OPTIONS:
 	not supplied by the development environment, while ncurses' form
 	library uses a regular expression feature for one of the field types.
 
-    --with-pkg-config=[DIR]
-	Check for pkg-config, optionally specifying its path.
+    --with-pkg-config[=CMD]
+	Check for pkg-config, optionally specifying its pathname.
 
-    --with-pkg-config-libdir=[DIR]
+    --with-pkg-config-libdir[=DIR]
 	If pkg-config was found, override the automatic check for its library
-	path.
+	path.  The optional DIR value can be
+	
+	"auto", automatically use pkg-config's library directory, or
+	
+	"libdir", use a ${libdir}/pkgconfig (based on the configuration), or
+	
+	a directory path, i.e., beginning with "/".
+
+	The configure script allows only a single directory, because
+	that is used as the directory in which to install ".pc" files.
+
+	The automatic check for the library path prefers the first directory
+	which currently exists.  If none of the directories listed by
+	pkg-config exist, the check prefers a pkgconfig directory under the
+	"libdir" set by the configure script (which may not be the system
+	default), or if pkg-config lists nothing suitable, the first one which
+	is listed by pkg-config is used.
 
     --with-profile
 	Generate profile-libraries These are named by adding "_p" to the root,
@@ -1191,6 +1257,10 @@ CONFIGURE OPTIONS:
 	This is normally chosen automatically based on the type of system
 	which you are building on.  We use it for testing the configure script.
 
+    --with-strip-program=XXX
+    	When stripping executables during install, use the specified program
+	rather than "strip".
+
     --with-sysmouse
 	use FreeBSD sysmouse interface provide mouse support on the console.
 
@@ -1205,7 +1275,7 @@ CONFIGURE OPTIONS:
 	Specify a search-list of terminfo directories which will be compiled
 	into the ncurses library (default: DATADIR/terminfo)
 
-	This is a colon-separated list, like the TERMINFO_DIRS environment
+	This is a colon-separated list, like the $TERMINFO_DIRS environment
 	variable.
 
     --with-termlib[=XXX]
@@ -1311,7 +1381,8 @@ CONFIGURE OPTIONS:
     --with-xterm-kbs=XXX
 	Configure xterm's terminfo entries to use either BS (^H, i.e., ASCII
 	backspace) or DEL (^?, or 127).  XXX can be BS (or bs, 8) or DEL
-	(or del, 127).
+	(or del, 127).  If XXX is "auto", the configure script chooses BS or
+	DEL according to platform defaults.
 
 	During installation, the makefile and scripts modifies the "xterm+kbs"
 	terminfo entry to use this setting.
@@ -1355,11 +1426,6 @@ CONFIGURE OPTIONS:
 	programs (e.g., tic).  The test applications will still be built if you
 	type "make", though not if you simply do "make install".
 
-    --without-tack
-	Suppress build/install with tack program, if it happens to be
-	in the same build-tree (tack was moved out of the ncurses source-tree
-	in 20070203).
-
     --without-tests
 	Tell the configure script to suppress the build of ncurses' test
 	programs.
@@ -1385,6 +1451,88 @@ COMPATIBILITY WITH OLDER RELEASES:
     you may encounter when building a system with different versions of
     ncurses:
 
+    6.5 (Apt 27, 2024)
+	Interface changes:
+
+	+ the WINDOW structure and some related internal data types declared
+	  in <curses.h> have been made opaque by default;
+	+ the FORM, MENU, and PANEL structures and related internal data types
+	  from their corresponding header files have been made opqaue by
+	  default; and
+	+ support for wide characters is now enabled by default.
+
+	Added extensions:
+
+	+ is_cbreak, is_echo, is_nl, and is_raw, as well as "_sp" variants
+
+	+ tiparm_s and tiscan_s
+
+	Added internal functions (other than "_sp" variants):
+
+	+ _nc_env_access
+
+	Removed internal functions:
+
+	+ none
+
+	Modified internal functions:
+
+	+ These now pass a const parameter: _nc_delink_entry, _nc_str_copy,
+	  and _nc_trans_string
+
+    6.4 (Dec 31, 2022)
+	Interface changes:
+
+	+ none
+
+	Added extensions:
+
+	+ none
+
+	Added internal functions (other than "_sp" variants):
+
+	+ add _nc_free_termtype1 and _nc_free_tparm, for memory-leaks
+
+	Removed internal functions:
+
+	+ none
+
+	Modified internal functions:
+
+	+ none
+
+    6.3 (Oct 21, 2021)
+	Interface changes:
+
+	+ the definition of TERMTYPE2 is now internal, not visible in the ABI,
+	  like the enclosing TERMINAL which was previously made opaque.  This
+	  was done to provide SCREEN-specific "static" variables in terminfo.
+
+	Added extensions:
+
+	+ add sp-funcs for erasewchar, killwchar.
+
+	Added internal functions (other than "_sp" variants):
+
+	+ _nc_safe_fopen and _nc_safe_open3 limit privileges if possible when
+	  opening a file; otherwise disallow access for updating files.
+
+	+ _nc_tiparm is a variant of tiparm which is used when all of the
+	  parameters are known to be numbers rather than possibly strings.
+
+	+ _nc_reset_tparm improves tic's checks by resetting the terminfo
+	  "static variables" before calling functions which may update them.
+
+	Removed internal functions:
+
+	+ none
+
+	Modified internal functions:
+
+	+ _nc_trace_ttymode passes pointer to const data
+
+	+ _nc_tparm_analyze passes pointer to int*, not int[]
+
     6.2 (Feb 12, 2020)
 	Interface changes:
 
@@ -2147,15 +2295,15 @@ FOR SYSTEM INTEGRATORS:
     Naming the Console Terminal
 
 	In various systems there has been a practice of designating the system
-	console driver type as `console'.  Please do not do this!  It
+	console driver type as 'console'.  Please do not do this!  It
 	complicates peoples' lives, because it can mean that several different
 	terminfo entries from different operating systems all logically want to
-	be called `console'.
+	be called 'console'.
 
 	Please pick a name unique to your console driver and set that up
 	in the /etc/inittab table or local equivalent.  Send the entry to the
 	terminfo maintainer (listed in the misc/terminfo file) to be included
-	in the terminfo file, if it's not already there.  See the
+	in the terminfo file, if it is not already there.  See the
 	term(7) manual page included with this distribution for more on
 	conventions for choosing type names.
 
@@ -2189,7 +2337,7 @@ CONFIGURING FALLBACK ENTRIES:
 	tree is accessible (that is, in single-user mode or at OS installation
 	time) the ncurses library can be compiled to include an array of
 	pre-fetched fallback entries.
-	
+
 	NOTE: This must be done on a machine which has ncurses' infocmp and
 	terminfo database installed (as well as ncurses' tic and infocmp
 	programs).  That is because the fallback sources are generated and
@@ -2388,4 +2536,4 @@ BUG REPORTS:
 	The Hacker's Guide in the doc directory includes some guidelines
 	on how to report bugs in ways that will get them fixed most quickly.
 
--- vile:txtmode
+-- vile:txtmode fc=78
diff --git a/contrib/ncurses/MANIFEST b/contrib/ncurses/MANIFEST
index 1dbfb96b7a1c..a9395d2f8a09 100644
--- a/contrib/ncurses/MANIFEST
+++ b/contrib/ncurses/MANIFEST
@@ -33,6 +33,7 @@
 ./Ada95/include/ncurses_defs
 ./Ada95/make-tar.sh
 ./Ada95/mk-1st.awk
+./Ada95/mk-pkg.awk
 ./Ada95/package/AdaCurses-doc.spec
 ./Ada95/package/AdaCurses.spec
 ./Ada95/package/debian/compat
@@ -342,7 +343,7 @@
 ./doc/html/announce.html
 ./doc/html/hackguide.html
 ./doc/html/index.html
-./doc/html/man/adacurses6-config.1.html
+./doc/html/man/adacursesw6-config.1.html
 ./doc/html/man/captoinfo.1m.html
 ./doc/html/man/clear.1.html
 ./doc/html/man/curs_add_wch.3x.html
@@ -463,7 +464,7 @@
 ./doc/html/man/mitem_value.3x.html
 ./doc/html/man/mitem_visible.3x.html
 ./doc/html/man/ncurses.3x.html
-./doc/html/man/ncurses6-config.1.html
+./doc/html/man/ncursesw6-config.1.html
 ./doc/html/man/new_pair.3x.html
 ./doc/html/man/panel.3x.html
 ./doc/html/man/resizeterm.3x.html
@@ -553,6 +554,7 @@
 ./include/edit_cfg.sh
 ./include/hashed_db.h
 ./include/headers
+./include/nc_access.h
 ./include/nc_alloc.h
 ./include/nc_mingw.h
 ./include/nc_panel.h
@@ -670,7 +672,7 @@
 ./man/keyok.3x
 ./man/legacy_coding.3x
 ./man/make_sed.sh
-./man/man_db.renames
+./man/man_db.renames.in
 ./man/manhtml.aliases
 ./man/manhtml.externs
 ./man/manlinks.sed
@@ -768,6 +770,7 @@
 ./misc/makellib
 ./misc/menu.def
 ./misc/menu.ref
+./misc/ncu2openbsd
 ./misc/ncurses-config.in
 ./misc/ncurses.def
 ./misc/ncurses.ref
@@ -899,6 +902,7 @@
 ./ncurses/new_pair.h
 ./ncurses/report_hashing.c
 ./ncurses/report_offsets.c
+./ncurses/term.priv.h
 ./ncurses/tinfo/MKcaptab.awk
 ./ncurses/tinfo/MKcaptab.sh
 ./ncurses/tinfo/MKcodes.awk
@@ -1108,6 +1112,7 @@
 ./test/color_content.c
 ./test/color_name.h
 ./test/color_set.c
+./test/combine.c
 ./test/configure
 ./test/configure.in
 ./test/demo_altkeys.c
@@ -1212,15 +1217,19 @@
 ./test/test_addstr.c
 ./test/test_addwstr.c
 ./test/test_arrays.c
+./test/test_delwin.c
+./test/test_endwin.c
 ./test/test_get_wstr.c
 ./test/test_getstr.c
 ./test/test_instr.c
 ./test/test_inwstr.c
+./test/test_mouse.c
 ./test/test_opaque.c
 ./test/test_setupterm.c
 ./test/test_sgr.c
 ./test/test_termattrs.c
 ./test/test_tparm.c
+./test/test_unget_wch.c
 ./test/test_vid_puts.c
 ./test/test_vidputs.c
 ./test/testaddch.c
diff --git a/contrib/ncurses/Makefile.in b/contrib/ncurses/Makefile.in
index 7be6e7677637..1303e171cfa1 100644
--- a/contrib/ncurses/Makefile.in
+++ b/contrib/ncurses/Makefile.in
@@ -1,6 +1,6 @@
-# $Id: Makefile.in,v 1.43 2020/02/02 23:34:34 tom Exp $
+# $Id: Makefile.in,v 1.46 2022/10/01 22:53:36 tom Exp $
 ##############################################################################
-# Copyright 2018-2019,2020 Thomas E. Dickey                                  #
+# Copyright 2018-2021,2022 Thomas E. Dickey                                  #
 # Copyright 1998-2014,2015 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -62,11 +62,26 @@ pkgdir		= @PKG_CONFIG_LIBDIR@
 
 include_dir	= ${includedir}${includesubdir}
 
+FGREP		= @FGREP@
+
 INSTALL		= @INSTALL@
 INSTALL_DATA	= @INSTALL_DATA@
 
 DIRS_TO_MAKE	= @DIRS_TO_MAKE@
 
+@MAKE_PHONY@.PHONY :	all
+@MAKE_PHONY@.PHONY :	check
+@MAKE_PHONY@.PHONY :	clean
+@MAKE_PHONY@.PHONY :	depend
+@MAKE_PHONY@.PHONY :	distclean
+@MAKE_PHONY@.PHONY :	install
+@MAKE_PHONY@.PHONY :	mostlyclean
+@MAKE_PHONY@.PHONY :	preinstall
+@MAKE_PHONY@.PHONY :	realclean
+@MAKE_PHONY@.PHONY :	sources
+@MAKE_PHONY@.PHONY :	tags
+@MAKE_PHONY@.PHONY :	uninstall
+
 all ::	$(DIRS_TO_MAKE)
 
 $(DIRS_TO_MAKE) :
@@ -90,16 +105,16 @@ preinstall :
 	@ test "$(include_dir)" = "$(prefix)/include" || \
 		echo '** Include-directory is not in a standard location'
 	@ test ! -f $(include_dir)/termcap.h || \
-		fgrep NCURSES_VERSION $(include_dir)/termcap.h >/dev/null || \
+		$(FGREP) NCURSES_VERSION $(include_dir)/termcap.h >/dev/null || \
 		echo '** Will overwrite non-ncurses termcap.h'
 	@ test ! -f $(include_dir)/curses.h || \
-		fgrep NCURSES_VERSION $(include_dir)/curses.h >/dev/null || \
+		$(FGREP) NCURSES_VERSION $(include_dir)/curses.h >/dev/null || \
 		echo '** Will overwrite non-ncurses curses.h'
 
 distclean \
 realclean ::
 
-check:
+check :
 	@ echo The test-programs are interactive
 
 
diff --git a/contrib/ncurses/Makefile.os2 b/contrib/ncurses/Makefile.os2
index 960c2bdb8bad..bc3407d65750 100644
--- a/contrib/ncurses/Makefile.os2
+++ b/contrib/ncurses/Makefile.os2
@@ -1,5 +1,5 @@
 ##############################################################################
-# Copyright 2020 Thomas E. Dickey                                            #
+# Copyright 2020,2021 Thomas E. Dickey                                       #
 # Copyright 1998-2000,2006 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -26,7 +26,7 @@
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ################################################################################
-# $Id: Makefile.os2,v 1.12 2020/02/02 23:34:34 tom Exp $
+# $Id: Makefile.os2,v 1.13 2021/06/17 21:20:30 tom Exp $
 #
 # Wrapper Makefile for ncurses library under OS/2.
 # Author:  Juan Jose Garcia Ripoll <worm@arrakis.es>.
@@ -70,7 +70,7 @@
 # disappear are not essential.
 #
 # I first thought about killing '_nc_*' symbols, but it seems that some of
-# them --_nc_panel_hook, _nc_ada*, etc-- are needed outside ncurses.dll. 
+# them --_nc_panel_hook, _nc_ada*, etc-- are needed outside ncurses.dll.
 # However, the whole size of the export table will not be larger than 1k or
 # so.
 #
diff --git a/contrib/ncurses/NEWS b/contrib/ncurses/NEWS
index 4203d188f7f4..8bedbc8264e1 100644
--- a/contrib/ncurses/NEWS
+++ b/contrib/ncurses/NEWS
@@ -1,5 +1,5 @@
 -------------------------------------------------------------------------------
--- Copyright 2018-2020,2021 Thomas E. Dickey                                 --
+-- Copyright 2018-2023,2024 Thomas E. Dickey                                 --
 -- Copyright 1998-2017,2018 Free Software Foundation, Inc.                   --
 --                                                                           --
 -- Permission is hereby granted, free of charge, to any person obtaining a   --
@@ -26,7 +26,7 @@
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
--- $Id: NEWS,v 1.3634 2021/02/21 00:18:55 tom Exp $
+-- $Id: NEWS,v 1.4114 2024/04/27 18:00:35 tom Exp $
 -------------------------------------------------------------------------------
 
 This is a log of changes that ncurses has gone through since Zeyd started
@@ -46,6 +46,1171 @@ See the AUTHORS file for the corresponding full names.
 Changes through 1.9.9e did not credit all contributions;
 it is not possible to add this information.
 
+20240427 6.5 release for upload to ftp.gnu.org
+	+ update announcement
+	+ fixes/corrections for manpages (patches by Branden Robinson).
+	+ fix redefinition of CASTxPTR, for legacy Unix.
+
+20240420
+	+ improve formatting/style of manpages (patches by Branden Robinson).
+	+ compiler warning/portability fixes.
+
+20240414
+	+ build/bug-fix for check-size feature (reports by Sam James, Gabriele
+	  Balducci).
+
+20240413
+	+ improve formatting/style of manpages (patches by Branden Robinson).
+	+ provide for padding in check-size feature, using new_prescr() to
+	  pass interim SCREEN pointer.
+	+ complete change for opaque options (Gentoo #928973, cf: 20231021).
+	+ update package /debian/rules and related lintian overrides
+	+ revise progs.priv.h to provide for NC_ISATTY reuse
+
+20240330
+	+ remove masking of ISIG in cbreak() (report by Benno Schulenberg).
+	+ modify test/test_mouse.c to use curses api for raw/noraw.
+	> improved configure macros from other program development:
+	  + build-fix for clang on Solaris
+	  + suppress filename/timestamp in gzip'd manpages (suggested for
+	    byacc by Andrin Geiger)
+
+20240323
+	+ modify tput/tset reset feature to avoid 1-second sleep if running in
+	  a pseudo-terminal.
+	+ modify check-size feature to avoid using it in a pseudoterminal
+	  (cf: 20231016)
+	+ improve formatting/style of manpages (patches by Branden Robinson).
+	+ trim a space after some "-R" options, fixing builds for applications
+	  built using clang and ncurses on Solaris.
+
+20240309
+	+ modify xgterm to work around line-drawing bug -TD
+	+ use CSI 3J in vte-2017 (report by Sven Joachim)
+
+20240302
+	+ add configure check for MB_LEN_MAX, to provide warning as needed.
+	+ improve formatting/style of manpages (patches by Branden Robinson).
+	+ fix regression in tput which disallowed hex/octal parameters (report
+	  by Werner Fink, cf:  20230408)
+	+ update config.guess, config.sub
+
+20240224
+	+ improve man/curs_mouse.3x style (Branden Robinson, Sven Joachim).
+	+ provide for CCHARW_MAX greater than 1
+	+ eliminate use of PATH_MAX in lib_trace.c
+	+ work around misconfiguration of MacPorts gcc13, which exposes invalid
+	  definition of MB_LEN_MAX in gcc's fallback copy of limits.h (MacPorts
+	  #69374).
+
+20240217
+	+ add vt100+noapp, vt100+noapp+pc, xterm+app+pc, xterm+decedit from
+	  xterm #389 -TD
+	+ fix inconsistent description of wmouse_trafo() (Debian #1059778).
+	+ modify wenclose() to handle pads (Debian #1059783).
+	+ improve manpage discussion of mouseinterval() (Debian #1058560).
+
+20240210
+	+ compiler-warning fixes, while investigating an optimizer bug in
+	  "gcc (MacPorts gcc13 13.2.0_4+stdlib_flag) 13.2.0"
+	  which results in only the first byte of a multibyte character being
+	  printed to the screen.
+
+20240203
+	+ minor changes to tracing and locale-checks.
+
+20240127
+	+ amend change to z39-a (report by Sven Joachim).
+	+ use xterm+nopcfkeys, vt52-basic, dec+pp, dec+sl, vt52+arrows,
+	  hp+pfk+cr, klone+acs, klone+color, klone+sgr, ncr160wy50+pp
+	  to trim -TD
+	+ NetBSD-related fixes for x68k and wsvt25 (patch by Thomas Klausner)
+
+20240120
+	+ improve formatting/style of manpages (patches by Branden Robinson).
+	+ amend discussion of aliases in tput.1
+	+ use ansi+sgrbold, ansi+sgrdim, ansi+sgrso, ansi+sgrul, ansi+tabs
+	  ecma+color, ecma+sgr, vt100+4bsd, vt100+pfkeys, vt220+pcedit
+	  xterm+256color, xterm+acs, xterm+nopcfkeys, xterm+pcf2 to trim -TD
+	+ modify configure scripts/makefiles to omit KEY_RESIZE if the
+	  corresponding SIGWINCH feature is disabled.
+
+20240113
+	+ improve formatting/style of manpages (patches by Branden Robinson).
+	+ modify dist.mk to avoid passing developer's comments in manpages into
+	  the generated html documentation.
+	+ use ansi+local, ansi+local1, ansi+pp, ansi+rca, ansi+rca2, ansi+sgr
+	  to trim -TD
+	+ restore padding for wy520* and vt320-k311 (report by Sven Joachim).
+
+20240106
+	+ use ansi+arrows, ansi+apparrows, ansi+csr, ansi+erase, ansi+idc,
+	  ansi+idc1, ansi+idl, ansi+idl1, ansi+inittabs to trim -TD
+	+ minor manpage formatting changes for consistency.
+	+ modify doc-html test package's install-directory, per lintian.
+	+ add attr_get.3x to man_db.renames.in (patch by Sven Joachim).
+
+20231230
+	+ improve formatting/style of manpages (patches by Branden Robinson).
+	+ add ms-vt100-16color, winconsole -TD
+	+ add rio, rio-direct -TD
+	+ add mostlike -TD
+	+ add wezterm, contour -TD
+
+20231223
+	+ improve formatting/style of manpages (patches by Branden Robinson).
+
+20231217
+	+ improve formatting/style of manpages (patches by Branden Robinson).
+	+ correct an assignment in infocmp "-u" for detecting if a boolean
+	  is unset in a base entry and set in a use'd chunk, i.e., if it was
+	  cancelled.
+	+ modify infocmp "-u" option to not report cancels for strings which
+	  were already cancelled in a use'd chunk.
+	+ join two lines in infotocap.3x to eliminate a spurious "description"
+	  link in installed manpages (report by Sven Joachim).
+	+ fix typo in NEWS (report by Sven Joachim).
+
+20231209
+	+ modify infocmp "-u" option to not report cancels in use'd chunks
+	  which are not mentioned in the top-level terminal description.
+	+ remove xterm+sm+1006 from tmux (Debian #1057688).
+	+ used "infocmp -u" to help trim redundant capabilities -TD
+	+ updated man/edit_man.sh to allow for "\%" markers embedded after
+	  bold font escapes in manpage cross-references (Debian #1057651).
+	+ reduce compiler-warnings in configure checks
+
+20231202
+	+ correct initial alignment of extended capabilities in infocmp, so
+	  that the "-u" option can be used for more than two terminal types.
+	+ improve formatting/style of manpages, changing environment variables
+	  to italics (patches by Branden Robinson).
+
+20231125
+	+ add information about "ttycap", termcap's forerunner, to tset.1
+	  (patch by Branden Robinson).
+	+ improve formatting/style of manpages, including section reordering
+	  (patches by Branden Robinson).
+	+ modify usage messages in configure script, bracketing optional values
+	  (report by Branden Robinson).
+
+20231121
+	+ amend fix for Debian #1055882, correcting nul terminator check in
+	  waddnstr (Debian #1056340).
+
+20231118
+	+ improve description of length-parameter and error-returns in several
+	  manpages:  curs_addchstr.3x, curs_addstr.3x, curs_addwstr.3x,
+	  curs_in_wch.3x, curs_in_wchstr.3x, curs_inchstr.3x, curs_ins_wstr.3x,
+	  curs_insstr.3x, curs_instr.3x, curs_inwstr.3x
+	+ amend parameter check for entire string versus specific length in
+	  winsnstr() and wins_nwstr() to match Solaris.
+	+ make similar correction to wins_nwstr().
+	+ correct loop termination condition in waddnstr() and waddnwstr()
+	  (Debian #1055882, cf: 20201205).
+
+20231111
+	+ used "infocmp -u" to help trim redundant capabilities -TD
+	+ add limit checks in infocmp needed when processing extended
+	  capabilities with the "-u" option.
+	+ fix inconsistent sort-order in see-also sections of manpages.
+	+ fix a few compiler warnings for Solaris 10.
+	+ modify endwin() to return an error if it is called again without an
+	  intervening screen update (report by Rajeev Pillai, NetBSD #57592).
+
+20231104
+	+ modify reset command to avoid altering clocal if the terminal uses a
+	  modem (prompted by discussion with Werner Fink, Michal Suchanek,
+	  OpenSUSE #1201384, Debian #60377).
+	+ build-fixes for --with-caps variations.
+	+ correct a couple of section-references in INSTALL.
+
+20231028
+	+ move xterm focus mode 1004 from xterm+sm+1006 into xterm+focus as
+	  fe/fd capabilities, like vim (vim-pr #13440).
+	+ modify --with-pkg-config-libdir option to make "libdir" the default,
+	  as documented, rather than "auto" (report by Branden Robinson).
+	+ improve messages from configure script (patches by Branden Robinson).
+
+20231021
+	+ use oldxterm+sm+1006 in vte-2014 (report by Benno Schulenberg) -TD
+	+ add ansi+apparrows -TD
+	+ change defaults for configure opaque and widec options (prompted by
+	  discussion with Branden Robinson).
+	+ minor cleanup of compiler- and manpage-warnings.
+
+20231016
+	+ make the recent change to setupterm optional "--enable-check-size"
+	  (Debian #1054022).
+
+20231014
+	+ improve formatting/style of manpages (patches by Branden Robinson).
+	+ updated configure script macro CF_XOPEN_SOURCE, for uClibc-ng
+	+ update config.guess, config.sub
+
+20231007
+	+ improve loop-limit for get_position().
+	+ improve manual description of immedok (Debian #1053603).
+	+ fix a few formatting issues with manpages (Debian #1053123).
+	+ improve formatting/style of manpages (patches by Branden Robinson).
+
+20231001
+	+ modify setupterm to provide for using ANSI cursor-position report (in
+	  user6/user7 terminfo capabilities) to obtain screensize if neither
+	  environment variables or ioctl is used.  The ncurses test-program
+	  with options "-E -T" demonstrates this feature.
+	+ improve error messages in tic (patch by Branden Robinson).
+	+ improve formatting/style of manpages (patches by Branden Robinson).
+	+ modify test/clip_printw.c to optionally test non-wrapped updates.
+	+ fix reallocation loop for vsnprintf() in _nc_sprintf_string() by
+	  copying the va_list variable (patch by Ian Abbott).
+
+20230923
+	+ improve formatting of manpages (patches by Branden Robinson).
+	+ amend change to delscreen() to limit the windows which it creates to
+	  just those associated with the screen (report by Frederic Boiteux,
+	  cf: 20220813).
+
+20230918
+	+ new tarball/errata (report by Sven Joachim).
+
+20230917
+	+ improve formatting of manpages (integrated patches by Branden
+	  Robinson).
+	+ correct limit for name-length in write_entry.c (report/testcase by
+	  Luna Saphie Mittelbach).
+	+ limit delays to 30 seconds, i.e., padding delays in terminfo, as well
+	  as napms() and delay_output() functions.
+	+ improve a few pointer-checks.
+	+ improve parsing in _nc_msec_cost, allowing a single decimal point.
+
+20230909
+	+ improve formatting of manpages (patches by Branden Robinson), for
+	  captoinfo.1m and terminfo.5
+	> patches by Nicholas Marriott:
+	  + use string-hacks in alloc_entry.c, alloc_type.c and hardscroll.c,
+	    overlooked due to compiler changes in recent OpenBSD releases.
+	  + add "-6" option to ncu2openbsd script.
+
+20230902
+	+ improve description of search rules for terminal descriptions in
+	  terminfo manpage (report by Sven Joachim).
+
+20230826
+	+ fixes for compiler-warnings.
+	+ update config.guess, config.sub
+
+20230819
+	+ various manpage-formatting fixes.
+	+ correct formatting of table header in curs_inopts.3x (Branden
+	  Robinson).
+	+ correct manpage description of panel_hidden (report by Benjamin
+	  Mordaunt).
+
+20230812
+	+ add/use putty+cursor to reflect amending of modified cursor-keys in
+	  2021 -TD
+	+ add ecma+strikeout to putty -TD
+	+ add functions to query tty-flags in SCREEN (request by Bill Gray).
+
+20230805
+	+ fix a few manpages needing tbl marker, seen by lintian warning.
+	+ fixes for compiler-warnings.
+	+ minor grammatical fix for manpages (Branden Robinson).
+
+20230729
+	+ improve manpages for wgetnstr() and wget_wnstr().
+	+ modify MinGW configuration to provide for running in MSYS/MSYS2
+	  shells, assuming ConPTY support (patch by Pavel Fedin).
+	+ add assignment in CF_MAN_PAGES to fill in value for TERMINFO_DIRS in
+	  ncurses, terminfo and tic manpages (patch by Sven Joachim).
+
+20230722
+	+ add "auto" default for --with-xterm-kbs configure option.
+
+20230715
+	+ correct wadd_wch_literal() when adding a non-spacing character to a
+	  double-width character.
+	+ improve manual page for curs_util.
+	+ improve manual page for wadd_wch().
+
+20230708
+	+ add linux+kbs for terminals which imitate xterm's behavior with
+	  Linux -TD
+	+ modify MinGW driver to return KEY_BACKSPACE when an unmodified
+	  VK_BACK virtual key is entered (prompted by patch by Pavel Fedin,
+	  Savannah #64292).
+	+ disallow using $TERMINFO or $HOME/.terminfo when tic "-o" option is
+	  used (report by Sven Joachim, Debian #1040048).
+
+20230701
+	+ fix mandoc warnings about unnecessary markup.
+	+ improve parameter check in tparm_setup()
+
+20230625
+	+ adjust man/make_sed.sh to work with dates as the third field of TH.
+	+ fixes for out-of-memory condition (report by "eaglegai").
+
+20230624
+	+ fixes for out-of-memory condition (report by "eaglegai").
+
+20230617
+	+ markup manpages with revision information (prompted by discussion
+	  with Bjarni Ingi Gislason).
+
+20230615
+	+ modify _nc_read_file_entry() to show relevant filename in warnings.
+	+ improve checks in convert_string() for corrupt terminfo entry (report
+	  and test-case by Gregory James Duck).
+
+20230610
+	+ improve manpages discussing file descriptors in low-level functions.
+	+ modify flushinp to use file descriptors in SCREEN, rather than from
+	  TERMINAL, and check if they are for a terminal, like SVr4.
+	+ modify mcprint to use file descriptor in SCREEN, for consistency.
+	+ add xterm+focus to foot+base (patch by Daniel Ekloef).
+	+ correct definition of Charable() for non-wide ncurses library (report
+	  and test-case by Zbigniew Baniewski).
+
+20230603
+	+ add configure option --with-strip-program, to override program
+	  chosen by the install program for stripping executables (prompted
+	  by discussion with Aapo Rantalainen).
+	+ fix typo in INSTALL (report/patch by Aapo Rantalainen).
+	+ improve error-checks for isEILSEQ()
+	+ increase MB_CUR_MAX to 16, matching glibc's MB_LEN_MAX.
+	+ corrected mouse mask in test/testcurs.c
+	+ improve thread lock in lib_trace.c
+
+20230527
+	+ fixes for compiler warnings/cppcheck.
+
+20230520
+	+ fixes for compiler warnings in MinGW environments.
+
+20230514
+	+ modify test-package "ncurses6-doc" to use manpage-aliases, which in
+	  turn required a change to the configure script to factor in the
+	  extra-suffix option when deriving alias names.
+	+ add mode 1004 to xterm+sm+1006 from xterm #380 -TD
+
+20230506
+	> build-fixes related to configure-options and/or platform:
+	  + fix for --enable-fvisibility
+	  + fix for unusual values of --with-rel-version
+	  + fix for unusual values of --with-abi-version
+	  + fix for --disable-tcap-names
+	  + fix for termcap in nc_access.h (report by Werner Fink).
+
+20230429
+	+ revise recent change to _nc_write_entry to isolate it to a Cygwin bug
+	  (cf: 20230311)
+	+ amend fix for wgetnstr, wgetn_wstr to use cbreak mode unless raw
+	  mode was set (cf: 20210522).
+	+ fix a few warnings from cppcheck, etc.
+	+ correct copy/paste error in nc_access.h (report by Werner Fink).
+
+20230424
+	+ check return value of _nc_save_str(), in special case for tic where
+	  extended capabilities are processed but the terminal description was
+	  not initialized (report by Ziqiao Kong).
+	+ regenerate llib-* files.
+
+20230423
+	+ add tiscan_s() to help applications check formatting capabilities
+	  that would be passed to tiparm_s, etc.
+	+ add tiparm_s() to provide applications a way to tell ncurses what
+	  the expected parameters are for a capability (tmux #3531).
+	+ improve check in lib_tparm.c, ensuring that a char* fits into a
+	  TPARM_ARG.
+	+ add --disable-setuid-environ configure option (request by Sven
+	  Joachim).
+	+ drop compatibility with obsolete versions of tack, e.g., pre-1.08
+	  (Debian #1034549, cf: 20170722).
+
+20230418
+	+ improve checks for limits on privileged execution:
+	  + modify _nc_syserr_abort() to use _nc_env_access(), rather than
+	    only checking root uid.
+	  + use getauxval() when available, to improve setuid/setgid checks.
+	  + modify test packages to disable root access/environ options.
+	+ modify tgoto() to accept no-parameter capabilities, for joe editor
+	  (OpenSUSE #1210485, Gentoo #904263).
+
+20230415
+	+ configure script fixes:
+	  + fix copy/paste error in configure option --disable-root-access
+	    (report/patch by Sven Joachim).
+	  + modify CF_XOPEN_SOURCE macro's amend default case to avoid
+	    undefining _XOPEN_SOURCE if _POSIX_C_SOURCE is defined.
+	+ modify test_tparm to account for extended capabilities.
+	+ add checks in tparm() and tiparm() for misuse of numeric parameters,
+	  overlooked in 20230408.
+	+ fix errata in clear.1 and curs_terminfo.3x
+
+20230408
+	+ document limitations of tparm, and error-returns in curs_terminfo.3x
+	+ document limitations of tgoto, and error-returns in curs_termcap.3x
+	+ add xterm+focus to alacritty+common (patch by Christian Duerr).
+	+ add "-v" option to tput, to show warnings.
+	> improve checks for malformed terminfo data (report/analysis by
+	  Jonathan Bar Or, Michael Pearse, Emanuele Cozzi).
+	  + make the parameter type/count checks in _nc_tiparm() more stringent
+	  + update tgoto() to account for _nc_tiparm() changes
+	  + add checks in tparm() and tiparm() for misuse of string parameters
+	  + add special cases in tput to handle extensions Cs/Ms parameters
+	  + ignore compiled-terminfo where the array sizes exceed the standard
+
+20230401
+	+ modify experimental Windows driver to work with xterm mouse protocol.
+	+ remove DECCOLM+DECSCLM from foot (patch by Daniel Ekloef).
+
+20230311
+	+ improve manpage description for addch versus unctrl format used for
+	  non-printable characters.
+	+ modify version-check for gcc/g++, now works for msys2.
+	+ modify check in _nc_write_entry() for multiply defined aliases to
+	  report problems within the current runtime of tic rather than for
+	  conflicts with pre-existing terminal descriptions.
+	+ allow for MinGW32-/64-bit configurations to use _DEFAULT_SOURCE
+	+ clarify interaction of -R option versus -C, -I and -r in infocmp
+	  manpage.
+	+ build-fix in lib_win32con.c (cf: 20230211).
+
+20230225
+	+ build-fixes for rpm test-packages.
+	+ add/use configure check for clock_gettime(), to supersede
+	  gettimeofday().
+
+20230218
+	+ configure-script improvements:
+	  + recent msys2 headers work with _DEFAULT_SOURCE; amend check
+	  + use $ac_includes_default in most cases where stdlib.h should work
+	  + use #error consistently vs "make an error"
+	  + add configure macro for gettimeofday vs inline check
+
+20230211
+	+ set dwShareMode in calls to CreateConsoleScreenBuffer() (patch by
+	  Hannes Domani).
+	+ use CreateFile with "CONIN$", "CONOUT$" rather than GetStdHandle to
+	  obtain a handle on the actual console, avoiding redirection in the
+	  MinGW/Win32 configurations (adapted from patch by LIU Hao).
+
+20230128
+	+ document XF, kxIN and kxOUT -TD
+	+ add note on sun/wscons/cmdtool/shelltool -TD
+	+ modify configure script check for pkg-config library directory to
+	  take into account an older version 0.15.0 which used PKG_CONFIG_PATH
+	  but not PKG_CONFIG_LIBDIR
+
+20230121
+	+ correct limit-check when dumping tc/use clause via tic -I (report by
+	  Gabriel Ravier).
+	+ correct a check for manpage-alias in edit_man.sh, to work with out of
+	  tree builds (report by Sven Joachim).
+
+20230114
+	+ change RV to XR/xr, to avoid conflict with pre-existing usage in vim,
+	  to use RV/rv to denote DA2 and its response (discussion with Bram
+	  Moolenaar) -TD
+	+ add XF flag to xterm+focus so that termcap applications can be aware
+	  of terminals which may support focus in/out -TD
+	+ use xterm+focus in xterm-p370 and tmux -TD
+	+ improve configure-script macros vs compiler warnings.
+
+20230107
+	+ add --with-abi-altered configure option (prompted by discussion with
+	  Brian Inglis).
+	+ add BSD erase2 to characters handled by tset/reset.
+	+ improve configure-script macros vs compiler warnings.
+	+ regenerate configure scripts with autoconf 2.52.20221202
+	+ add RV report+version (suggested by Bram Moolenaar).
+	+ add comment to bracketed+paste explaining that vim patch 9.0.1117 is
+	  needed for use with the updated xterm descriptions (suggested by Bram
+	  Moolenaar).
+
+20221231 6.4 release for upload to ftp.gnu.org
+	+ update release notes
+	+ regenerate llib-* files.
+	+ correct PS vs PE names in bracketed+paste (report by Bram Moolenaar)
+	  -TD
+
+20221224
+	+ add mutex lock/unlock in a few places reported by thread-sanitizer
+	+ add/use bracketed+paste to help identify terminals supporting this
+	  xterm feature (prompted by discussion with Bram Moolenaar) -TD
+
+20221217
+	+ install Ada95 sample programs in libexecdir, adding a wrapper
+	  script to invoke those.
+
+20221210
+	+ add minimal -h/-V getopt logic to the remaining test-programs.
+	+ free new_pair() data in delscreen (report by "magiblot").
+	+ add clarification of the scope of dynamic variables in terminfo(5).
+	+ remove a stray '/' from description of %g in terminfo(5).
+
+20221203
+	+ add -h usage and -V version options to the test-programs which use
+	  getopt.
+	+ use "command -v" rather than "type" in Ada95/gen/Makefile.in to fix
+	  a portability issue (patch by Nicolas Boulenguez).
+	+ update ncurses-howto, more documentation fixes along with corrections
+	  to example programs.
+
+20221126
+	+ fix an error in pathname of explain.txt (cf: 20200201).
+	+ fix an error in "@" command in test/ncurses.c F-menu (cf: 20190121).
+	+ improve formatting of ncurses-intro.html and hackguide.html
+	+ improve man/curs_clear.3x links to other pages
+
+20221119
+	+ use static libraries for AdaCurses test-package for Mageia, since no
+	  gprbuild package is available.
+	+ updated test packages for Debian.
+
+20221112
+	+ build-fixes for AdaCurses RPM test-package.
+
+20221105
+	+ regenerate configure scripts with autoconf 2.52.20221009
+	+ modify "--with-manpage-format" to support bzip2 and xz compression
+	  (prompted by discussion with Sam James).
+	+ modify make-tar.sh scripts to make timestamps more predictable.
+
+20221029
+	+ improve curs_slk.3x discussion of extensions and portability (report
+	  by Bill Gray).
+
+20221023
+	+ change man_db.renames to template, to handle ncurses*-config script
+	  with the extra-suffix configure option.
+
+20221015
+	+ fix another memory-leak in tic.
+	+ update install-sh script from autoconf, to fix install problem for
+	  Ada95 with Arch; as noted in
+	  https://lists.gnu.org/archive/html/automake/2018-09/msg00005.html
+	  there are unaddressed issues.
+	+ update CF_XOPEN_SOURCE, adding GNU libc suffixes for abi64, abin32,
+	  x32 (report by Sven Joachim):
+	+ correct ifdef's for _nc_set_read_thread() (patch by Mikhail Korolev,
+	  cf: 20220813).
+
+20221008
+	+ correct a switch-statement case in configure script to allow for test
+	  builds with ABI=7.
+	+ modify misc/gen-pkgconfig.in to allow for the case where the library
+	  directory does not yet exist, since this is processed before doing an
+	  install (report by Michal Liszcz).
+
+20221001
+	+ modify configure/scripts to work around interference by GNU grep 3.8
+	  (report by Sam James).
+	+ update CF_XOPEN_SOURCE, adding variants "gnueabi" and "gnueabihf" to
+	  get _DEFAULT_SOURCE special case (report by Adam Sampson)
+
+20220924
+	+ modify configure macro CF_BUILD_CC to check if the build-compiler
+	  works, rather than that it is different from the cross-compiler, e.g.,
+	  to accommodate a compiler which can be used for either purpose with
+	  different flags (report by Mikhail Korolev).
+	+ fix another memory-leak in tic.
+	+ correct change for cppcheck in menu library (report/analysis by
+	  "tuxway", cf: 20220903).
+	+ update config.guess, config.sub
+
+20220917
+	+ reduce memory-leak in tic by separating allocations for struct entry
+	  from TERMTYPE2 (cf: 20220430).
+	+ improve interaction between tic -v option and NCURSES_TRACE, by
+	  processing the latter only when -v option does not set _nc_tracing.
+	+ modify curses_trace() to show the trace-mask as symbols, e.g.,
+	  TRACE_ORDINARY, DEBUG_LEVEL(3).
+
+20220910
+	+ amend verbose-option change to make this affect level 3, e.g., using
+	  "tic -cv3 terminfo".
+	+ work around musl's nonstandard use of feature test macros by adding
+	  a definition for NCURSES_WIDECHAR to the generated ".pc" and *-config
+	  files (report by Sam James).
+
+20220903
+	+ modify verbose-option of infocmp, tic, toe to enable debug-tracing
+	  if that is configured.
+
+20220827
+	+ modify configure scripts to use overlooked cases for LD and
+	  PKG_CONFIG variables (report by Alan Webb, Gentoo #866398).
+	+ modify nsterm to use xterm+alt1049 (report by Paul Handly) -TD
+	+ modify putty to use xterm+alt1049 -TD
+
+20220820
+	+ fix some cppcheck warnings, mostly style, in ncurses and c++
+	  libraries and progs directory.
+	+ add curses_trace to ifdef's for START_TRACE in test/test.priv.h
+	+ update config.guess
+
+20220813
+	+ modify delscreen to more effectively delete all windows on the given
+	  screen.
+	+ amend portability note for delwin in manual page.
+	+ adapt test/test_delwin.c from example by Bill Gray.
+	+ account for prescreen data if freeing leaks in pthread-configuration
+	+ split-out _nc_set_read_thread(), to reduce compiler warnings about
+	  pthread_self(), which may/may not be a weak symbol.
+	+ improve pthread-configuration for test/worm.c
+
+20220806
+	+ amend end_of_stream() to allow for input files without a final
+	  newline.
+	+ check for non-textfiles to tic.
+
+20220729
+	+ fixes to build with dietlibc:
+	  + add configure check for fpathconf (report by Georg Lehner).
+	  + add configure check for math sine/cosine, needed in test/tclock,
+	    and eliminate pow() from test/hanoi (report by Georg Lehner).
+	  + use wcsnlen as an alternative to wmemchr if it is not found
+	    (adapted from patch by Georg Lehner).
+	+ trim out some unwanted linker options from ncurses*config and .pc
+	  files seen in Fedora 36+.
+
+20220724
+	+ add portability notes for delscreen and delwin in manual.
+	+ improve pthread-configuration for test/worm.c, test/rain.c
+	+ improve pointer/limit checks associated with deleting a screen
+	  (Debian #1015756).
+
+20220716
+	+ build-fix for test_mouse.c, for non-standard cfmakeraw.
+	+ improve shell-scripts with shellcheck
+	+ fix typo in run_tic.in (report/patch by Jan Starke).
+
+20220709
+	+ lock the prescreen data consistently in newterm, etc., for the
+	  pthreads configuration (report by Tom de Vries).
+
+20220703
+	+ add consistency check in tic for u6/u7/u8/u9 and NQ capabilities.
+	+ use NQ to flag entries where the terminal does not support query and
+	  response -TD
+	+ use ansi+enq and decid+cpr in cases where the terminal probably
+	  supported the u6-u9 extension -TD
+	+ add/use apollo+vt132, xterm+alt47 -TD
+
+20220625
+	+ improve man/curs_bkgd.3x, explaining that bkgdset can affect results
+	  for bkgd (report by Anton Vidovic).
+	+ correct dsl in dec+sl (report by Rajeev Pillai) -TD
+	+ add/use ansi+cpr, decid+cpr -TD
+
+20220618
+	+ add a null-pointer check for term_names field in copy_termtype(),
+	  needed for MinGW port (report by Peiyuan Song, cf: 20220521).
+	+ revise kon/kon2/jfbterm to undo "linux2.6" change to
+	  smacs/rmacs/enacs (Debian #1012800) -TD
+	+ amended note for att610+cvis0, as per documentation for att610,
+	  att620, att730 -TD
+
+20220612
+	+ modify waddch_literal() to allow for double-width base character when
+	  merging a combining character (report by Gavin Troy).
+	+ improve _tracecchar_t2() formatting of base+combining character.
+
+20220604
+	+ add note on portable memory-leak checking in man/curs_memleaks.3x
+	+ remove u6-u9 from teken-2018 -TD
+	+ set "xterm-new" to "xterm-p370", add "xterm-p371" -TD
+
+20220529
+	+ expanded notes for teken/syscons -TD
+	+ fix overlooked copying of extended string-heap in copy_termtype
+	  (cf: 20220430).
+	+ update config.guess
+
+20220521
+	+ improve memory-leak checking in several test-programs.
+	+ set trailing null on string passed from winsnstr() to wins_nwstr().
+	+ modify del_curterm() to fix memory-leak introduced by change to
+	  copy_termtype().
+
+20220514
+	+ further improvements to test/test_mouse.c; compare with ncurses test
+	  program menu A/a.
+
+20220507
+	+ add test/test_mouse.c (patch by Leonid S Usov).
+	+ add a few debug-traces for tic, fix a couple of memory-leaks.
+
+20220501
+	+ build-fix for debug-traces (report/patch by Chris Clayton).
+
+20220430
+	+ modify samples for xterm mouse 1002/1003 modes to use 1006 mode, and
+	  also provide for focus in/out responses -TD
+	+ modify default case in handle_wheel() to always report button-release
+	  events, e.g., for xterm mouse mode 1003 (patch by Leonid S Usov).
+	+ improve valid_entryname() to disallow characters used in terminfo
+	  syntax: '#', '=', '|', '\'.
+	+ alter copy_termtype() to allocate new str_table and ext_str_table
+	  data rather than relying upon its callers.
+	+ use calloc in _nc_init_entry() when allocating stringbuf, to ensure
+	  it is initialized.
+	+ add library-level TYPE_CALLOC for consistency with TYPE_MALLOC.
+	+ add some debug-traces for tic/infocmp.
+
+20220423
+	+ in-progress work on invalid_merge(), disable it (cf: 20220402).
+	+ fix memory leak in _nc_tic_dir() when called from _nc_set_writedir().
+	+ fix memory leak in tic when "-c" option is used.
+
+20220416
+	+ add a limit-check to guard against corrupt terminfo data
+	  (report/testcase by NCNIPC of China).
+	+ add check/warning in configure script if option --with-xterm-kbs is
+	  missing or inconsistent (Arch #74379).
+	+ add setlocale call to several test-programs.
+	+ allow extended-color number in opts parameter of wattr_on.
+
+20220409
+	+ add test/test_unget_wch.c
+
+20220402
+	+ amend extended_captype(), returning CANCEL if a string is explicitly
+	  cancelled.
+	+ make description-fields distinct -TD
+
+20220326
+	+ update teken -TD
+	+ add teken-16color, teken-vt and teken-sc -TD
+	+ add a few missing details for vte-2018 (report by Robert Lange) -TD
+
+20220319
+	+ add xgterm -TD
+	+ correct setal in mintty/tmux entries, add to vte-2018 (report by
+	  Robert Lange)
+	+ add blink to vte-2018 (report by Robert Lange)
+	+ improve tic warning about XT versus redundant tsl, etc.
+
+20220312
+	+ add xterm+acs building-block -TD
+	+ add xterm-p370, for use in older terminals -TD
+	+ add dec+sl to xterm-new, per xterm patch #371 -TD
+	+ add mosh and mosh-256color -TD
+
+20220305
+	+ replace obsolescent "-gnatg" option with "-gnatwa" and "-gnatyg", to
+	  work around build problems with gnat 12.
+	+ update external links in Ada95.html
+	+ trim unused return-value from canonical_name().
+
+20220226
+	+ fix issues found with coverity:
+	  + rewrite canonical_name() function of infocmp to ensure buffer size
+	  + corrected use of original tty-modes in tput init/reset subcommands
+	  + modify tabs program to limit tab-stop values to max-columns
+	  + add limit-checks for palette rgb values in test/ncurses.c
+	+ add a few null-pointer checks to help with static-analysis.
+	+ enforce limit on number of soft-keys used in c++ binding.
+	+ adjust a buffer-limit in write_entry.c to quiet a bogus warning from
+	  gcc 12.0.1
+
+20220219
+	+ expanded description in man/resizeterm.3x
+	+ additional workaround for ImageMagick in test/picsmap.c
+
+20220212
+	+ improve font-formatting in other manpages, for consistency.
+	+ correct/improve font-formatting in curs_wgetch.3x (patch by Benno
+	  Schulenberg).
+
+20220205
+	+ workaround in test/picsmap.c for use of floating point for rgb values
+	  by ImageMagick 6.9.11, which appears to use the wrong upper limit.
+	+ improve use of "trap" in shell scripts, using "fixup-trap".
+
+20220129
+	+ minor updates for test-packages
+	+ improve handling of --with-pkg-config-libdir option, allowing for the
+	  case where either $PKG_CONFIG_LIBDIR or the option value has a
+	  colon-separated list of directories (report by Rudi Heitbaum,
+	  cf: 20211113).
+	+ update kitty -TD
+
+20220122
+	+ add ABI 7 defaults to configure script.
+	+ add warning in configure script if file specified for "--with-caps"
+	  does not exist.
+	+ use fix for CF_FIX_WARNINGS from cdk-perl, ignoring error-exit on
+	  format-warnings.
+	+ improve readability of long parameterized expressions with the
+	  infocmp "-f" option by allowing split before a "%p" marker.
+
+20220115
+	+ improve checks for valid mouse events when an intermediate mouse
+	  state is not part of the mousemask specified by the caller (report by
+	  Anton Vidovic, cf: 20111022).
+	+ use newer version 1.36 of gnathtml for generating Ada html files.
+
+20220101
+	+ add section on releasing memory to curs_termcap.3x and
+	  curs_terminfo.3x manpages.
+
+20211225
+	+ improve markup, e.g., for external manpage links in the manpages
+	  (prompted by report by Helge Kreutzmann).
+
+20211219
+	+ install ncurses-examples programs in libexecdir, adding a wrapper
+	  script to invoke those.
+	+ add help-screen and screen-dump to test/combine.c
+
+20211211
+	+ add test/combine.c, to demo/test combining characters.
+
+20211204
+	+ improve configure check for getttynam (report by Werner Fink).
+
+20211127
+	+ fix errata in description fields (report by Eric Lindblad) -TD
+	+ add x10term+sl, aixterm+sl, ncr260vp+sl, ncr260vp+vt, wyse+sl -TD
+
+20211120
+	+ add dim, ecma+strikeout to st-0.6 -TD
+	+ deallocate the tparm cache when del_curterm is called for the last
+	  allocated TERMINAL structure (report/testcase by Bram Moolenaar,
+	  cf: 20200531).
+	+ modify test-package to more closely conform to Debian multi-arch.
+	+ if the --with-pkg-config-libdir option is not given, use
+	  ${libdir}/pkgconfig as a default (prompted by discussion with Ross
+	  Burton).
+
+20211115
+	+ fix memory-leak in delwin for pads (report by Werner Fink, OpenSUSE
+	  #1192668, cf:  20211106),
+
+20211113
+	+ minor clarification to clear.1 (Debian #999437).
+	+ add xterm+sl-alt, use that in foot+base (report by Jonas Grosse
+	  Sundrup) -TD
+	+ improve search-path check for pkg-config, for Debian testing which
+	  installs pkg-config with architecture-prefixes.
+
+20211106
+	+ improve check in misc/Makefile.in for empty $PKG_CONFIG_LIBDIR
+	+ modify wnoutrefresh to call pnoutrefresh if its parameter is a pad,
+	  rather than treating it as an error, and modify new_panel to permit
+	  its window-parameter to be a pad (report by Giorgos Xou).
+	+ fix a memory-leak in del_curterm (prompted by discussion with Bram
+	  Moolenaar, cf: 20210821).
+
+20211030
+	+ simplify some references to WINDOWS._flags using macros.
+	+ add a "check" rule in Ada95 makefile, to help with test-packages.
+	+ build-fix for cross-compiling to MingW, conditionally add -lssp
+
+20211026
+	+ corrected regex needed for older pkg-config used in Solaris 10.
+	+ amend configure option's auto-search to account for systems where
+	  none of the directories known to pkg-config exist, adapted from
+	  mailing-list comment (report by Milan P. Stanic).
+
+20211021 6.3 release for upload to ftp.gnu.org
+	+ update release notes
+	+ add "ncu2openbsd" script, to illustrate how to update an OpenBSD
+	  system to use a current ncurses release.
+
+20211018
+	+ check for screen size-change in scr_init() and scr_restore(), in case
+	  a screen dump does not match the current screen dimensions (report by
+	  Frank Tkalcevic).
+
+20211017
+	+ amend change for pkg-config to account for "none" being returned in
+	  the libdir-path result rather than "no" (report by Gabriele Balducci).
+
+20211016
+	+ build-fix for pmake with libtool.
+	+ improve make-tar.sh scripts, adding COPYING to tar file, and clean up
+	  shellcheck warnings.
+	+ add link for "reset6" manpage in test-package ncurses6-doc
+	+ revise configure option --with-pkg-config-libdir, using the actual
+	  search path from pkg-config or pkgconf using the output from --debug
+	  (report by Pascal Pignard).
+	+ freeze ABI in ".map" files.
+
+20211009
+	+ implement "+m" option in tabs program.
+	+ fill in some details for infoton -TD
+	+ fix spelling/consistency in several descriptions -TD
+	+ use vt420+lrmm in vt420 -TD
+	+ modify save_tty_settings() to avoid opening /dev/tty for cases other
+	  than reset/init, e.g., for clear.
+	+ modify output of "toe -as" to show first description found rather
+	  than the last.
+	+ improve tic checks for number of parameters of smglp, smgrp, smgtp,
+	  and smgbp (cf: 20020525).
+	+ correct off-by-one comparison in last_char(), which did not allow
+	  special case of ":" in a terminfo description field (cf: 20120407).
+	+ remove check in tic that assumes that none or both parameterized and
+	  non-parameterized margin-setting capabilities are present
+	  (cf: 20101002).
+
+20211002
+	+ use return-value from vsnprintf to reallocate as needed to allow for
+	  buffers larger than the screen size (report by "_RuRo_").
+	+ modify tset "-q" option to refrain from modifying terminal modes, to
+	  match the documentation.
+	+ add section on margins to terminfo.5, adapted from X/Open Curses.
+	+ make tput/tset warning messages consistently using alias names when
+	  those are used, rather than the underlying program's name.
+	+ improve tput usage message for aliases such as clear, by eliminating
+	  tput-specific portions.
+	+ add a check in toe to ensure that a "termcap file" is text rather
+	  than binary.
+	+ further build-fixes for OpenBSD 6.9, whose header files differ from
+	  the other BSDs.
+
+20210925
+	+ add kbeg to xterm+keypad to accommodate termcap applications -TD
+	+ add smglp and smgrp to vt420+lrmm, to provide useful data for the
+	  "tabs" +m option -TD
+	+ build-fix for gcc 3.4.3 with Solaris10, which does not allow forward
+	  reference of anonymous struct typedef.
+	+ modify tput to allow multiple commands per line.
+	+ minor fixes for tset manpage.
+
+20210911
+	+ adjust ifdef in test_opaque.c to fix build with ncurses 5.7
+	+ add testing note for xterm-{hp|sco|sun} -TD
+	+ corrected description for ansi.sys-old -TD
+	+ add xterm+nopcfkeys, to fill in keys for xterm-hp, xterm-sun -TD
+	+ use hp+arrows in a few places -TD
+	+ use hp+pfk-cr in a few places -TD
+
+20210905
+	+ correct logic in filtering of redefinitions (report by Sven Joachim,
+	  cf: 20210828).
+
+20210904
+	+ modify linux3.0 entry to reflect default mapping of shift-tab by
+	  kbd 1.14 (report by Jan Engelhardt) -TD
+	+ add historical note to tput, curses-terminfo and curses-color
+	  manpages based on source-code for SVr2, SVr3 and SVr4.
+	+ minor grammatical fixes for "it's" vs "its" (report by Nick Black).
+	+ amend fix for --disable-root-environ (report by Arnav Singh).
+	+ build-fix for compiling link_test
+	+ drop symbols GCC_PRINTF and GCC_SCANF from curses.h.in, to simplify
+	  use (Debian #993179).
+
+20210828
+	+ correct reversed check for --disable-root-environ (report/analysis
+	  by Arnav Singh, cf: 20210626).
+	+ apply gcc format attribute to prototypes which use a va_list
+	  parameter rather than a "..." variable-length parameter list
+	  (prompted by discussion in a tmux pull-request).
+	+ modify configure scripts to filter out redefinitions of _XOPEN_SOURCE,
+	  e.g., for NetBSD which generally supports 500, but 600 is needed for
+	  ncursesw.
+	+ improve documentation for tparm and static/dynamic variables.
+	+ improve typography in terminfo.5 (patch by Branden Robinson).
+
+20210821
+	+ improve tparm implementation of %P and %g, more closely matching
+	  SVr4 terminfo.
+	+ move internals of TERMINAL structure to new header term.priv.h
+	+ add "check" rule for ncurses/Makefile
+	+ corrected tsl capability for terminator -TD
+	+ add check in tic to report instances where tparm would detect an
+	  error in an expression (cf: 20201010).
+	+ correct a few places where SP->_pair_limit was used rather than
+	  SP->_pair_alloc (cf: 20170812).
+	+ fix missing "%d" for setaf/setab code 8-15 in xterm+direct16 (report
+	  by Florian Weimer) -TD
+	+ fix some documentation errata from OpenBSD changes.
+	+ update config.sub
+
+20210814
+	+ add workaround for broken pcre2 package in Debian 10, from xterm #369.
+
+20210807
+	+ ignore "--dynamic-linker" option in generated pkg/config files,
+	  adapted from "distr1" patch.
+	+ add CF_SHARED_OPTS case for Haiku, from patch in haikuports.
+
+20210731
+	+ add extensions in xterm+tmux and ecma+strikeout to ms-terminal,
+	  but cancel the non-working Cr and Ms capabilities -TD
+	+ add foot and foot-direct -TD
+
+20210724
+	+ add workaround for Windows Terminal's problems with CR/LF mapping to
+	  ms-terminal (patch by Juergen Pfeifer).
+	+ review/update current Windows Terminal vs ms-terminal -TD
+
+20210718
+	+ correct typo in "vip" comments (report by Nick Black), reviewed this
+	  against Glink manual -TD
+	+ fill in some missing pieces for pccons, to make it comparable to the
+	  vt220 entry -TD
+	+ modify mk-1st.awk to account for extra-suffix configure option
+	  (report by Juergen Pfeifer).
+	+ change default for --disable-wattr-macros option to help packagers
+	  who reuse wide ncursesw header file with non-wide ncurses library.
+	+ build-fix for test/test_opaque.c, for configurations without opaque
+	  curses structs.
+
+20210710
+	+ improve history section for tset manpage based on the 1BSD tarball,
+	  which preceded BSD's SCCS checkins by more than three years.
+	+ improve CF_XOPEN_CURSES macro used in test/configure (report by Urs
+	  Jansen).
+	+ further improvement of libtool configuration, adding a dependency of
+	  the install.tic rule, etc., on the library in the build-tree.
+	+ update config.sub
+
+20210703
+	+ amend libtool configuration to add dependency for install.tic, etc.,
+	  in ncurses/Makefile on the lower-level libraries.
+	+ modify configure script to support ".PHONY" make program feature.
+
+20210626
+	+ add configure option --disable-root-access, which tells ncurses to
+	  disallow most file-opens by setuid processes.
+	+ use default colors in pccon "op" -TD
+	+ correct rmacs/smacs in aaa+dec, aaa+rv -TD
+	+ add hpterm-color2 and hp98550-color (Martin Trusler)
+	+ regenerate man-html documentation.
+
+20210619
+	+ improve configure-macro used for dependencies of --disable-leaks such
+	  as --with-valgrind
+	+ trim trailing blanks from files
+
+20210612
+	+ fixes for scan-build, valgrind build/testing.
+	+ update config.guess
+
+20210605
+	+ add a summary of ncurses-specific preprocessor symbols to curses.h
+	  (prompted by discussion with Peter Farley, Bill Gray).
+
+20210522
+	+ regenerate configure scripts with autoconf 2.52.20210509 to eliminate
+	  an unnecessary warning in config.log (report by Miroslav Lichvar).
+	+ add a note in manual page to explain ungetch vs unget_wch (prompted
+	  by discussion with Peter Farley).
+	+ add sp-funcs for erasewchar, killwchar.
+	+ modify wgetnstr, wgetn_wstr to improve compatibility with SVr4 curses
+	  in its treatment of interrupt and quit characters (prompted by
+	  report/testcase by Bill Gray)
+	+ update config.guess, config.sub
+
+20210515
+	+ improve manual pages for wgetnstr, newwin (prompted by
+	  report/testcase by Bill Gray).
+
+20210508
+	+ modify tputs' error check to allow it to be used without first
+	  calling tgetent or setupterm, noting that terminfo initialization
+	  is required for supporting the terminfo delay feature (report by
+	  Sebastiano Vigna).
+	+ fix several warnings from clang --analyze
+	+ add null-pointer check in comp_parse.c, when a "use=" clause refers
+	  to a nonexisting terminal description (report/patch by Miroslav
+	  Lichvar, cf: 20210227).
+
+20210501
+	+ add a special case in the configure script to work around one of the
+	  build-time breakages reported for OpenBSD 6 here:
+	     https://www.mail-archive.com/bugs@openbsd.org/msg13200.html
+	  There is no workaround for the other issue, a broken linker spec.
+	+ modify configure check for libtool to prevent accidental use of an
+	  OpenBSD program which uses the same name.
+	+ update config.guess, config.sub
+
+20210424
+	+ avoid using broken system macros for snprintf which interfere with
+	  _nc_SLIMIT's conditionally adding a parameter when the string-hacks
+	  configure option is enabled.
+	+ add a "all::" rule before the new "check" rule in test/Makefile.in
+
+20210418
+	+ improve CF_LINK_FUNCS by ensuring that the source-file is closed
+	  before linking to the target.
+	+ add "check" rules for headers in c++, progs and test-directories.
+	+ build-fix for termsort module when configured with termcap (reports
+	  by Rajeev V Pillai, Rudi Heitbaum).
+
+20210417
+	+ extend --disable-pkg-ldflags option to also control whether $LDFLAGS
+	  from the build is provided in -config and .pc files (Debian #986764).
+	+ fix some cppcheck warnings, mostly style, in ncurses and c++
+	  libraries and progs directory.
+	+ fix off-by-one limit for tput's processing command-line arguments
+	  (patch by Hadrien Lacour).
+
+20210403
+	+ fix some cppcheck warnings, mostly style, in ncurses library and
+	  progs directory.
+	+ improve description of BSD-style padding in curs_termcap.3x
+	+ improved CF_C11_NORETURN macro, from byacc changes.
+	+ fix "--enable-leak" in CF_DISABLE_LEAKS to allow turning
+	  leak-checking off later in a set of options.
+	+ relax modification-time comparison in CF_LINK_FUNCS to allow it to
+	  accept link() function with NFS filesystems which change the mtime
+	  on the link target, e.g., several BSD systems.
+	+ call delay_output_sp to handle BSD-style padding when tputs_sp is
+	  called, whether directly or internally, to ensure that the SCREEN
+	  pointer is passed correctly (reports by Henric Jungheim, Juraj
+	  Lutter).
+
+20210327
+	+ build-fixes for Solaris10 /bin/sh
+	+ fix some cppcheck warnings, mostly style, in ncurses test-programs,
+	  form and menu libraries.
+
+20210323
+	+ add configure option --enable-stdnoreturn, making the _Noreturn
+	  keyword optional to ease transition (prompted by report by
+	  Rajeev V Pillai).
+
+20210320
+	+ improve parameter-checking in tput by forcing it to analyze any
+	  extended string capability, e.g., as used in the Cs and Ms
+	  capabilities of the tmux description (report by Brad Town,
+	  cf: 20200531).
+	+ remove an incorrect free in the fallback (non-checking) version of
+	  _nc_free_and_exit (report by Miroslav Lichvar).
+	+ correct use-ordering in some xterm-direct flavors -TD
+	+ add hterm, hterm-256color (Mike Frysinger)
+	+ if the build-time compiler accepts c11's _Noreturn keyword, use that
+	  rather than gcc's attribute.
+	+ change configure-check for gcc's noreturn attribute to assume it is
+	  a prefix rather than suffix, matching c11's _Noreturn convention.
+	+ add "lint" rule to c++/Makefile, e.g., with cppcheck.
+
+20210313
+	+ improve configure CF_LD_SEARCHPATH macro used for ncurses*-config and
+	  ".pc" files, from dialog changes.
+	+ reduce dependency of math-library in test programs.
+	+ minor fixes for test_tparm.c (cf: 20210306)
+	+ mention "ncurses" prefix in curses_version() manpage (report by
+	  Michal Bielinski).
+
+20210306
+	+ improved test/test_tparm.c, by limiting the tests to capabilities
+	  that might have parameters or padding, and combined with tputs test.
+	+ improve discussion of padding versus tparm and tputs in
+	  man/curs_terminfo.3x
+	+ update portability note for FreeBSD in man/tput.1
+
+20210227
+	+ modify tic/infocmp to eliminate unnecessary "\" to escape ":" in
+	  terminfo format.
+	+ add check in tic for duplicate "use=" clauses.
+
 20210220
 	+ improve tic warning when oc/op do not mention SGR 39/49 for xterm
 	  compatible XT flag.
@@ -380,7 +1545,7 @@ it is not possible to add this information.
 	+ re-enable "bel" in konsole-base (report by Nia Huang)
 	+ add linux-s entry (patch by Alexandre Montaron).
 	+ drop long-obsolete convert_configure.pl
-	+ add test/test_parm.c, for checking tparm changes.
+	+ add test/test_tparm.c, for checking tparm changes.
 	+ improve parameter-checking for tparm, adding function _nc_tiparm() to
 	  handle the most-used case, which accepts only numeric parameters
 	  (report/testcase by "puppet-meteor").
@@ -4598,7 +5763,7 @@ it is not possible to add this information.
 	  function pointer passed to tputs().
 	+ modify init_pair() to accept -1's for color value after
 	  assume_default_colors() has been called (Debian #337095).
-	+ modify test/background.c, adding commmand-line options to demonstrate
+	+ modify test/background.c, adding command-line options to demonstrate
 	  assume_default_colors() and use_default_colors().
 
 20110416
@@ -10333,7 +11498,7 @@ it is not possible to add this information.
 	+ add mgterm terminfo entry from NetBSD, minor adjustments to sun-ss5,
 	  aixterm entries -TD
 	+ modify tack/ansi.c to make it more tolerant of bad ANSI replies.  An
-	  example of an illegal ANSI resonse can be found using Microsoft's
+	  example of an illegal ANSI response can be found using Microsoft's
 	  Telnet client.  A correct display can be found using a VT-4xx
 	  terminal or XFree86 xterm with:
 		XTerm*VT100*decTerminalID:  450
@@ -11227,7 +12392,7 @@ it is not possible to add this information.
 	+ correct a typo in term.7 (Todd C Miller).
 	+ add configure --with-shlib-version option to allow installing shared
 	  libraries named according to release or ABI versions.  This
-	  parameterizes some existing logic in the configure script, and is
+	  parametrizes some existing logic in the configure script, and is
 	  intended for compatibility upgrades on Digital Unix, which used
 	  versioned libraries in ncurses 4.2, but no longer does (cf:  980425).
 	+ resync configure script against autoconf 2.13 + patches
diff --git a/contrib/ncurses/README b/contrib/ncurses/README
index a48e3f6155d9..5587f5b70bce 100644
--- a/contrib/ncurses/README
+++ b/contrib/ncurses/README
@@ -1,5 +1,5 @@
 -------------------------------------------------------------------------------
--- Copyright 2020 Thomas E. Dickey                                           --
+-- Copyright 2020-2021,2023 Thomas E. Dickey                                 --
 -- Copyright 1998-2012,2018 Free Software Foundation, Inc.                   --
 --                                                                           --
 -- Permission is hereby granted, free of charge, to any person obtaining a   --
@@ -26,7 +26,7 @@
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
--- $Id: README,v 1.28 2020/02/02 23:34:34 tom Exp $
+-- $Id: README,v 1.31 2023/10/28 14:49:04 tom Exp $
 -------------------------------------------------------------------------------
 		README file for the ncurses package
 
@@ -35,18 +35,19 @@ See the file INSTALL for instructions on how to build and install ncurses.
 See the file NEWS for a release history and bug-fix notes.
 See the file TO-DO for things that still need doing, including known bugs.
 
-Browse the file misc/ncurses-intro.html for narrative descriptions of how
+Browse the file doc/html/ncurses-intro.html for narrative descriptions of how
 to use ncurses and the panel, menu, and form libraries.
- 
+
 Browse the file doc/html/hackguide.html for a tour of the package internals.
 
+Find plain text versions of both of these documents in doc/.
+
 ROADMAP AND PACKAGE OVERVIEW:
 
 You should be reading this file in a directory called:  ncurses-d.d, where d.d
 is the current version number (see the dist.mk file in this directory for
 that).  There should be a number of subdirectories, including `c++', `form',
-`man', `menu', `misc', `ncurses', `panel', `progs', `test', 'tack' and `Ada95'. 
-(The 'tack' program may be distributed separately).
+`man', `menu', `misc', `ncurses', `panel', `progs', `test', and `Ada95'.
 
 A full build/install of this package typically installs several libraries, a
 handful of utilities, and a database hierarchy.  Here is an inventory of the
@@ -81,7 +82,7 @@ version.
 
 If you configure using the --enable-reentrant option, a "t" is appended to the
 library names (e.g., libncursest.a) and the resulting libraries have a
-different binary interface which makes the ncurses interface more "opaque".
+different binary interface, making the ncurses interface more opaque.
 
 The ncurses libraries implement the curses API.  The panel, menu and forms
 libraries implement clones of the SVr4 panel, menu and forms APIs.  The source
@@ -89,9 +90,9 @@ code for these lives in the `ncurses', `panel', `menu', and `form' directories
 respectively.
 
 In the `c++' directory, you'll find code that defines an interface to the
-curses, forms, menus and panels library packaged as C++ classes, and a demo program in C++
-to test it.  These class definition modules are not installed by the 'make
-install.libs' rule as libncurses++.
+curses, forms, menus and panels library packaged as C++ classes, and a demo
+program in C++ to test it.  These class definition modules are not installed
+by the 'make install.libs' rule as libncurses++.
 
 In the `Ada95' directory, you'll find code and documentation for an
 Ada95 binding of the curses API, to be used with the GNAT compiler.
@@ -102,8 +103,8 @@ for documentation of the binding.
 
 To do its job, the ncurses code needs your terminal type to be set in the
 environment variable TERM (normally set by your OS; under UNIX, getty(1)
-typically does this, but you can override it in your .profile); and, it needs a
-database of terminal descriptions in which to look up your terminal type's
+typically does this, but you can override it in your .profile); and, it needs
+a database of terminal descriptions in which to look up your terminal type's
 capabilities.
 
 In older (V7/BSD) versions of curses, the database was a flat text file,
@@ -117,10 +118,10 @@ second form.
 In the `misc' directory, there is a text file terminfo.src, in editable
 terminfo format, which can be used to generate the terminfo binaries (that's
 what make install.data does).  If the package was built with the
---enable-termcap option enabled, and the ncurses library cannot find a terminfo
-description for your terminal, it will fall back to the termcap file supplied
-with your system (which the ncurses package installation leaves strictly
-alone).
+--enable-termcap option enabled, and the ncurses library cannot find a
+terminfo description for your terminal, it will fall back to the termcap file
+supplied with your system (which the ncurses package installation leaves
+strictly alone).
 
 The utilities are as follows:
 
@@ -149,7 +150,7 @@ help you systematically exercise the library functions.
 
 AUTHORS:
 
-Pavel Curtis: 
+Pavel Curtis:
 	wrote the original ncurses
 
 Zeyd M. Ben-Halim:
@@ -176,8 +177,8 @@ Eric S. Raymond:
 	xterm mouse support, and the ncurses test program.
 
 Juergen Pfeifer
-	The menu and form libraries, C++ bindings for ncurses, menus, forms and
-	panels, as well as the Ada95 binding.  Ongoing support for panel.
+	The menu and form libraries, C++ bindings for ncurses, menus, forms
+	and panels, as well as the Ada95 binding.  Ongoing support for panel.
 
 CONTRIBUTORS:
 
@@ -216,3 +217,5 @@ BUGS:
 	See the INSTALL file for bug and developer-list addresses.
 	The Hacker's Guide in the doc directory includes some guidelines
 	on how to report bugs in ways that will get them fixed most quickly.
+
+-- vile:txtmode fc=78
diff --git a/contrib/ncurses/README.emx b/contrib/ncurses/README.emx
index c48b312c1979..666eaec73647 100644
--- a/contrib/ncurses/README.emx
+++ b/contrib/ncurses/README.emx
@@ -1,5 +1,5 @@
 -------------------------------------------------------------------------------
--- Copyright 2020 Thomas E. Dickey                                           --
+-- Copyright 2020,2021 Thomas E. Dickey                                      --
 -- Copyright 1998-2006,2018 Free Software Foundation, Inc.                   --
 --                                                                           --
 -- Permission is hereby granted, free of charge, to any person obtaining a   --
@@ -26,7 +26,7 @@
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
--- $Id: README.emx,v 1.11 2020/02/02 23:34:34 tom Exp $
+-- $Id: README.emx,v 1.12 2021/06/17 21:20:30 tom Exp $
 -- Author: Thomas Dickey
 -------------------------------------------------------------------------------
 
@@ -34,7 +34,7 @@ You can build ncurses on OS/2 in the EMX environment.  But you must build and
 acquire tools.  Not all of the tools distributed with EMX work properly, and
 some additional ones are required.
 
-First, the configure script distributed with ncurses will not run as-is in EMX. 
+First, the configure script distributed with ncurses will not run as-is in EMX.
 You can generate a new one if you have autoconf built for EMX.  You will need
 the EMX development tools, of course.  Get these programs to start:
 
@@ -65,7 +65,7 @@ may fix these problems:
 
 	+ I also built from sources (because the distributed binaries did not
 	  work) the cmp, diff programs.
-	  
+
 	  Other required utilities such as ar, cat, chmod, cp, gawk, grep, mv,
 	  ls, rm, mkdir, sed, sort and tr worked.
 
diff --git a/contrib/ncurses/VERSION b/contrib/ncurses/VERSION
index f8f03afcea5f..8ebef8fe8eb8 100644
--- a/contrib/ncurses/VERSION
+++ b/contrib/ncurses/VERSION
@@ -1 +1 @@
-5:0:10	6.2	20210220
+5:0:10	6.5	20240427
diff --git a/contrib/ncurses/aclocal.m4 b/contrib/ncurses/aclocal.m4
index d498939330c1..1c2b788bf1ff 100644
--- a/contrib/ncurses/aclocal.m4
+++ b/contrib/ncurses/aclocal.m4
@@ -1,5 +1,5 @@
 dnl***************************************************************************
-dnl Copyright 2018-2020,2021 Thomas E. Dickey                                *
+dnl Copyright 2018-2023,2024 Thomas E. Dickey                                *
 dnl Copyright 1998-2017,2018 Free Software Foundation, Inc.                  *
 dnl                                                                          *
 dnl Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -29,7 +29,7 @@ dnl***************************************************************************
 dnl
 dnl Author: Thomas E. Dickey 1995-on
 dnl
-dnl $Id: aclocal.m4,v 1.950 2021/01/26 23:45:12 tom Exp $
+dnl $Id: aclocal.m4,v 1.1069 2024/03/30 22:15:45 tom Exp $
 dnl Macros used in NCURSES auto-configuration script.
 dnl
 dnl These macros are maintained separately from NCURSES.  The copyright on
@@ -42,7 +42,7 @@ dnl		https://invisible-island.net/autoconf/my-autoconf.html
 dnl
 dnl ---------------------------------------------------------------------------
 dnl ---------------------------------------------------------------------------
-dnl AM_LANGINFO_CODESET version: 6 updated: 2021/01/01 16:53:59
+dnl AM_LANGINFO_CODESET version: 7 updated: 2023/01/11 04:05:23
 dnl -------------------
 dnl Inserted as requested by gettext 0.10.40
 dnl File from /usr/share/aclocal
@@ -54,7 +54,9 @@ dnl From Bruno Haible.
 AC_DEFUN([AM_LANGINFO_CODESET],
 [
 AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
-	[AC_TRY_LINK([#include <langinfo.h>],
+	[AC_TRY_LINK([
+$ac_includes_default
+#include <langinfo.h>],
 	[char* cs = nl_langinfo(CODESET); (void)cs],
 	am_cv_langinfo_codeset=yes,
 	am_cv_langinfo_codeset=no)
@@ -65,37 +67,57 @@ AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
 	fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_ABI_DEFAULTS version: 2 updated: 2015/06/06 13:49:58
+dnl CF_ABI_DEFAULTS version: 5 updated: 2023/10/21 08:54:23
 dnl ---------------
 dnl Provide configure-script defaults for different ncurses ABIs.
 AC_DEFUN([CF_ABI_DEFAULTS],[
 AC_REQUIRE([CF_NCURSES_WITH_ABI_VERSION])
-case x$cf_cv_abi_version in
+
+# ABI 5 defaults:
+cf_dft_ccharw_max=5
+cf_dft_chtype=auto
+cf_dft_ext_colors=no
+cf_dft_ext_const=no
+cf_dft_ext_mouse=no
+cf_dft_ext_putwin=no
+cf_dft_ext_spfuncs=no
+cf_dft_filter_syms=no
+cf_dft_interop=no
+cf_dft_mmask_t=auto
+cf_dft_opaque_curses=no
+cf_dft_ordinate_type=short
+cf_dft_signed_char=no
+cf_dft_tparm_arg=long
+cf_dft_widec=no
+cf_dft_with_lp64=no
+
+# ABI 6 default differences from ABI 5:
+case x$cf_cv_abi_default in
 (x[[6789]])
+	cf_dft_chtype=uint32_t
 	cf_dft_ext_colors=yes
 	cf_dft_ext_const=yes
 	cf_dft_ext_mouse=yes
 	cf_dft_ext_putwin=yes
 	cf_dft_ext_spfuncs=yes
 	cf_dft_filter_syms=yes
-	cf_dft_chtype=uint32_t
-	cf_dft_mmask_t=uint32_t
 	cf_dft_interop=yes
+	cf_dft_mmask_t=uint32_t
+	cf_dft_opaque_curses=yes
 	cf_dft_tparm_arg=intptr_t
+	cf_dft_widec=yes
 	cf_dft_with_lp64=yes
 	;;
-(*)
-	cf_dft_ext_colors=no
-	cf_dft_ext_const=no
-	cf_dft_ext_mouse=no
-	cf_dft_ext_putwin=no
-	cf_dft_ext_spfuncs=no
-	cf_dft_filter_syms=no
-	cf_dft_chtype=auto
-	cf_dft_mmask_t=auto
-	cf_dft_interop=no
-	cf_dft_tparm_arg=long
-	cf_dft_with_lp64=no
+esac
+
+# ABI 7 default differences from ABI 6:
+case x$cf_cv_abi_default in
+(x[[789]])
+	cf_dft_ccharw_max=6
+	cf_dft_mmask_t=uint64_t
+	cf_dft_ordinate_type=int
+	cf_dft_signed_char=yes
+	# also: remove the wgetch-events feature in ABI 7
 	;;
 esac
 ])dnl
@@ -264,9 +286,9 @@ CXXFLAGS="$CFLAGS"
 CFLAGS="$cf_save_CXXFLAGS"
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_ADD_INCDIR version: 16 updated: 2020/12/31 20:19:42
+dnl CF_ADD_INCDIR version: 17 updated: 2021/09/04 06:35:04
 dnl -------------
-dnl Add an include-directory to $CPPFLAGS.  Don't add /usr/include, since it's
+dnl Add an include-directory to $CPPFLAGS.  Don't add /usr/include, since it is
 dnl redundant.  We don't normally need to add -I/usr/local/include for gcc,
 dnl but old versions (and some misinstalled ones) need that.  To make things
 dnl worse, gcc 3.x may give error messages if -I/usr/local/include is added to
@@ -415,6 +437,25 @@ ifelse([$5],NONE,,[{ test -z "$5" || test "x$5" = xNONE || test "x$4" != "x$5";
 }
 ])dnl
 dnl ---------------------------------------------------------------------------
+dnl CF_APPEND_CFLAGS version: 3 updated: 2021/09/05 17:25:40
+dnl ----------------
+dnl Use CF_ADD_CFLAGS after first checking for potential redefinitions.
+dnl $1 = flags to add
+dnl $2 = if given makes this macro verbose.
+define([CF_APPEND_CFLAGS],
+[
+for cf_add_cflags in $1
+do
+	case "x$cf_add_cflags" in
+	(x-[[DU]]*)
+		CF_REMOVE_CFLAGS($cf_add_cflags,CFLAGS,[$2])
+		CF_REMOVE_CFLAGS($cf_add_cflags,CPPFLAGS,[$2])
+		;;
+	esac
+	CF_ADD_CFLAGS([$cf_add_cflags],[$2])
+done
+])dnl
+dnl ---------------------------------------------------------------------------
 dnl CF_APPEND_TEXT version: 1 updated: 2017/02/25 18:58:55
 dnl --------------
 dnl use this macro for appending text without introducing an extra blank at
@@ -557,7 +598,7 @@ AC_DEFUN([CF_AWK_BIG_PRINTF],
 	esac
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_BOOL_DECL version: 8 updated: 2004/01/30 15:51:18
+dnl CF_BOOL_DECL version: 9 updated: 2023/12/03 09:21:34
 dnl ------------
 dnl Test if 'bool' is a builtin type in the configured C++ compiler.  Some
 dnl older compilers (e.g., gcc 2.5.8) don't support 'bool' directly; gcc
@@ -572,13 +613,13 @@ AC_DEFUN([CF_BOOL_DECL],
 AC_MSG_CHECKING(if we should include stdbool.h)
 
 AC_CACHE_VAL(cf_cv_header_stdbool_h,[
-	AC_TRY_COMPILE([],[bool foo = false],
+	AC_TRY_COMPILE([],[bool foo = false; (void)foo],
 		[cf_cv_header_stdbool_h=0],
 		[AC_TRY_COMPILE([
 #ifndef __BEOS__
 #include <stdbool.h>
 #endif
-],[bool foo = false],
+],[bool foo = false; (void)foo],
 			[cf_cv_header_stdbool_h=1],
 			[cf_cv_header_stdbool_h=0])])])
 
@@ -593,7 +634,7 @@ AC_CACHE_VAL(ifelse($1,,cf_cv_builtin_bool,[$1]),[
 	AC_TRY_COMPILE([
 #include <stdio.h>
 #include <sys/types.h>
-],[bool x = false],
+],[bool x = false; (void)x],
 		[ifelse($1,,cf_cv_builtin_bool,[$1])=1],
 		[ifelse($1,,cf_cv_builtin_bool,[$1])=0])
 	])
@@ -604,18 +645,17 @@ else	AC_MSG_RESULT(no)
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_BOOL_SIZE version: 17 updated: 2020/10/24 19:48:55
+dnl CF_BOOL_SIZE version: 20 updated: 2023/02/18 17:41:25
 dnl ------------
 dnl Test for the size of 'bool' in the configured C++ compiler (e.g., a type).
-dnl Don't bother looking for bool.h, since it's been deprecated.
+dnl Don't bother looking for bool.h, since it has been deprecated.
 dnl
 dnl If the current compiler is C rather than C++, we get the bool definition
 dnl from <stdbool.h>.
 AC_DEFUN([CF_BOOL_SIZE],
 [
 AC_CHECK_SIZEOF(bool,,[
-#include <stdlib.h>
-#include <stdio.h>
+$ac_includes_default
 
 #if defined(__cplusplus)
 
@@ -639,8 +679,7 @@ AC_CHECK_SIZEOF(bool,,[
 AC_CACHE_CHECK(for type of bool, cf_cv_type_of_bool,[
 	rm -f cf_test.out
 	AC_TRY_RUN([
-#include <stdlib.h>
-#include <stdio.h>
+$ac_includes_default
 
 #if defined(__cplusplus)
 
@@ -702,7 +741,7 @@ if test "$cf_cv_type_of_bool" = unknown ; then
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_BUILD_CC version: 9 updated: 2021/01/02 09:31:20
+dnl CF_BUILD_CC version: 11 updated: 2022/12/04 15:40:08
 dnl -----------
 dnl If we're cross-compiling, allow the user to override the tools and their
 dnl options.  The configure script is oriented toward identifying the host
@@ -768,7 +807,32 @@ if test "$cross_compiling" = yes ; then
 
 	: ${BUILD_CC:='${CC}'}
 
-	if { test "$BUILD_CC" = "$CC" || test "$BUILD_CC" = '${CC}'; } ; then
+	AC_MSG_CHECKING(if the build-compiler "$BUILD_CC" works)
+
+	cf_save_crossed=$cross_compiling
+	cf_save_ac_link=$ac_link
+	cross_compiling=no
+	cf_build_cppflags=$BUILD_CPPFLAGS
+	test "$cf_build_cppflags" = "#" && cf_build_cppflags=
+	ac_link='$BUILD_CC -o "conftest$ac_exeext" $BUILD_CFLAGS $cf_build_cppflags $BUILD_LDFLAGS "conftest.$ac_ext" $BUILD_LIBS >&AS_MESSAGE_LOG_FD'
+
+	AC_TRY_RUN([#include <stdio.h>
+		int main(int argc, char *argv[])
+		{
+			${cf_cv_main_return:-return}(argc < 0 || argv == 0 || argv[0] == 0);
+		}
+	],
+		cf_ok_build_cc=yes,
+		cf_ok_build_cc=no,
+		cf_ok_build_cc=unknown)
+
+	cross_compiling=$cf_save_crossed
+	ac_link=$cf_save_ac_link
+
+	AC_MSG_RESULT($cf_ok_build_cc)
+
+	if test "$cf_ok_build_cc" != yes
+	then
 		AC_MSG_ERROR([Cross-build requires two compilers.
 Use --with-build-cc to specify the native compiler.])
 	fi
@@ -794,7 +858,45 @@ AC_SUBST(BUILD_EXEEXT)
 AC_SUBST(BUILD_OBJEXT)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_CC_ENV_FLAGS version: 10 updated: 2020/12/31 18:40:20
+dnl CF_C11_NORETURN version: 4 updated: 2023/02/18 17:41:25
+dnl ---------------
+AC_DEFUN([CF_C11_NORETURN],
+[
+AC_MSG_CHECKING(if you want to use C11 _Noreturn feature)
+CF_ARG_ENABLE(stdnoreturn,
+	[  --enable-stdnoreturn    enable C11 _Noreturn feature for diagnostics],
+	[enable_stdnoreturn=yes],
+	[enable_stdnoreturn=no])
+AC_MSG_RESULT($enable_stdnoreturn)
+
+if test $enable_stdnoreturn = yes; then
+AC_CACHE_CHECK([for C11 _Noreturn feature], cf_cv_c11_noreturn,
+	[AC_TRY_COMPILE([
+$ac_includes_default
+#include <stdnoreturn.h>
+static _Noreturn void giveup(void) { exit(0); }
+	],
+	[if (feof(stdin)) giveup()],
+	cf_cv_c11_noreturn=yes,
+	cf_cv_c11_noreturn=no)
+	])
+else
+	cf_cv_c11_noreturn=no,
+fi
+
+if test "$cf_cv_c11_noreturn" = yes; then
+	AC_DEFINE(HAVE_STDNORETURN_H, 1,[Define if <stdnoreturn.h> header is available and working])
+	AC_DEFINE_UNQUOTED(STDC_NORETURN,_Noreturn,[Define if C11 _Noreturn keyword is supported])
+	HAVE_STDNORETURN_H=1
+else
+	HAVE_STDNORETURN_H=0
+fi
+
+AC_SUBST(HAVE_STDNORETURN_H)
+AC_SUBST(STDC_NORETURN)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_CC_ENV_FLAGS version: 11 updated: 2023/02/20 11:15:46
 dnl ---------------
 dnl Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
 dnl into CC.  This will not help with broken scripts that wrap the compiler
@@ -835,7 +937,7 @@ case "$CC" in
 	AC_MSG_WARN(your environment uses the CC variable to hold CFLAGS/CPPFLAGS options)
 	# humor him...
 	cf_prog=`echo "$CC" | sed -e 's/	/ /g' -e 's/[[ ]]* / /g' -e 's/[[ ]]*[[ ]]-[[^ ]].*//'`
-	cf_flags=`echo "$CC" | ${AWK:-awk} -v prog="$cf_prog" '{ printf("%s", [substr]([$]0,1+length(prog))); }'`
+	cf_flags=`echo "$CC" | sed -e "s%^$cf_prog%%"`
 	CC="$cf_prog"
 	for cf_arg in $cf_flags
 	do
@@ -913,14 +1015,14 @@ AC_MSG_RESULT($includedir)
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_CGETENT version: 6 updated: 2017/01/21 11:06:25
+dnl CF_CGETENT version: 7 updated: 2023/02/18 17:41:25
 dnl ----------
 dnl Check if the terminal-capability database functions are available.  If not,
 dnl ncurses has a much-reduced version.
 AC_DEFUN([CF_CGETENT],[
 AC_CACHE_CHECK(for terminal-capability database functions,cf_cv_cgetent,[
 AC_TRY_LINK([
-#include <stdlib.h>],[
+$ac_includes_default],[
 	char temp[128];
 	char *buf = temp;
 	char *db_array = temp;
@@ -938,7 +1040,7 @@ then
 AC_CACHE_CHECK(if cgetent uses const parameter,cf_cv_cgetent_const,[
 AC_TRY_LINK([
 #pragma GCC diagnostic error "-Wincompatible-pointer-types-discards-qualifiers"
-#include <stdlib.h>],[
+$ac_includes_default],[
 	char temp[128];
 	char *buf = temp;
 #ifndef _NETBSD_SOURCE			/* given, since April 2004 in stdlib.h */
@@ -993,7 +1095,7 @@ if test ".$system_name" != ".$cf_cv_system_name" ; then
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_CHECK_ENVIRON version: 3 updated: 2010/05/26 16:44:57
+dnl CF_CHECK_ENVIRON version: 5 updated: 2023/02/18 17:41:25
 dnl ----------------
 dnl Check for data that is usually declared in <unistd.h>, e.g., the 'environ'
 dnl variable.  Define a DECL_xxx symbol if we must declare it ourselves.
@@ -1004,11 +1106,8 @@ AC_DEFUN([CF_CHECK_ENVIRON],
 [
 AC_CACHE_CHECK(if external $1 is declared, cf_cv_dcl_$1,[
     AC_TRY_COMPILE([
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#include <unistd.h> ],
-    ifelse([$2],,int,[$2]) x = (ifelse([$2],,int,[$2])) $1,
+$ac_includes_default],
+    ifelse([$2],,void*,[$2]) x = (ifelse([$2],,void*,[$2])) $1; (void)x,
     [cf_cv_dcl_$1=yes],
     [cf_cv_dcl_$1=no])
 ])
@@ -1022,7 +1121,7 @@ fi
 CF_CHECK_EXTERN_DATA($1,ifelse([$2],,int,[$2]))
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_CHECK_ERRNO version: 13 updated: 2020/03/10 18:53:47
+dnl CF_CHECK_ERRNO version: 14 updated: 2023/02/18 17:41:25
 dnl --------------
 dnl Check for data that is usually declared in <stdio.h> or <errno.h>, e.g.,
 dnl the 'errno' variable.  Define a DECL_xxx symbol if we must declare it
@@ -1034,11 +1133,7 @@ AC_DEFUN([CF_CHECK_ERRNO],
 [
 AC_CACHE_CHECK(if external $1 is declared, cf_cv_dcl_$1,[
 	AC_TRY_COMPILE([
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#include <stdio.h>
-#include <sys/types.h>
+$ac_includes_default
 #include <errno.h> ],
 	ifelse([$2],,int,[$2]) x = (ifelse([$2],,int,[$2])) $1; (void)x,
 	[cf_cv_dcl_$1=yes],
@@ -1054,10 +1149,10 @@ fi
 CF_CHECK_EXTERN_DATA($1,ifelse([$2],,int,[$2]))
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_CHECK_EXTERN_DATA version: 4 updated: 2015/04/18 08:56:57
+dnl CF_CHECK_EXTERN_DATA version: 5 updated: 2021/09/04 06:35:04
 dnl --------------------
 dnl Check for existence of external data in the current set of libraries.  If
-dnl we can modify it, it's real enough.
+dnl we can modify it, it is real enough.
 dnl $1 = the name to check
 dnl $2 = its type
 AC_DEFUN([CF_CHECK_EXTERN_DATA],
@@ -1101,7 +1196,7 @@ __attribute__ ((visibility("default"))) int somefunc() {return 42;}
 ])
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_CHECK_GETENV version: 2 updated: 2021/01/02 17:09:14
+dnl CF_CHECK_GETENV version: 4 updated: 2023/12/03 10:18:09
 dnl ---------------
 dnl Check if repeated getenv calls return the same pointer, e.g., it does not
 dnl discard the previous pointer when returning a new one.
@@ -1112,11 +1207,7 @@ AC_CHECK_FUNC( getenv, ,, AC_MSG_ERROR(getenv not found) )
 AC_CHECK_FUNCS( putenv setenv strdup )
 AC_CACHE_CHECK(if getenv returns consistent values,cf_cv_consistent_getenv,[
 AC_TRY_RUN([
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
+$ac_includes_default
 
 #if defined(HAVE_ENVIRON) && defined(DECL_ENVIRON) && !defined(environ)
 extern char **environ;	/* POSIX, but some systems are not... */
@@ -1182,7 +1273,7 @@ int main(void)
 				}
 			}
 		} while (found);
-		sprintf(value, "%lu:%p", (unsigned long) k, &mynames[j]);
+		sprintf(value, "%lu:%p", (unsigned long) k, (void*)&mynames[j]);
 		set_value(name, value);
 		mynames[j] = str_alloc(name);
 		myvalues[j] = str_alloc(value);
@@ -1289,28 +1380,72 @@ if test "$cf_cv_check_gpm_wgetch" != yes ; then
 fi
 ])])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_CHECK_LIBTOOL_VERSION version: 1 updated: 2013/04/06 18:03:09
+dnl CF_CHECK_LIBSSP version: 1 updated: 2021/10/30 10:40:19
+dnl ---------------
+dnl Check if libssp is needed, e.g., to work around misconfigured libraries
+dnl used in cross-compiling to MinGW.
+AC_DEFUN([CF_CHECK_LIBSSP],[
+AC_CACHE_CHECK(if ssp library is needed,cf_cv_need_libssp,[
+AC_TRY_LINK([
+#include <sys/types.h>
+#include <dirent.h>
+],[
+       DIR *dp = opendir(".");
+],cf_cv_need_libssp=no,[
+	cf_save_LIBS="$LIBS"
+	LIBS="$LIBS -lssp"
+	AC_TRY_LINK([
+#include <sys/types.h>
+#include <dirent.h>
+	],[
+		   DIR *dp = opendir(".");
+	],cf_cv_need_libssp=yes,
+	  cf_cv_need_libssp=maybe)
+	LIBS="$cf_save_LIBS"
+])dnl
+])
+
+if test "x$cf_cv_need_libssp" = xyes
+then
+	CF_ADD_LIB(ssp)
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_CHECK_LIBTOOL_VERSION version: 2 updated: 2021/05/01 16:24:34
 dnl ------------------------
 dnl Show the version of libtool
 dnl
 dnl Save the version in a cache variable - this is not entirely a good thing,
 dnl but the version string from libtool is very ugly, and for bug reports it
 dnl might be useful to have the original string.
+dnl
+dnl There is an imitation in OpenBSD, which has no apparent use other than to
+dnl deny that it is GNU libtool.  Just ignore it.
 AC_DEFUN([CF_CHECK_LIBTOOL_VERSION],[
 if test -n "$LIBTOOL" && test "$LIBTOOL" != none
 then
 	AC_MSG_CHECKING(version of $LIBTOOL)
 	CF_LIBTOOL_VERSION
 	AC_MSG_RESULT($cf_cv_libtool_version)
-	if test -z "$cf_cv_libtool_version" ; then
-		AC_MSG_ERROR(This is not GNU libtool)
+	if test -n "$cf_cv_libtool_version"
+	then
+		cf_check_libtool_version=`$LIBTOOL --version 2>&1 | sed -e '/^$/d' -e 's,[[()]],...,g' -e 's,[[ ]],-,g' -e '2,$d'`
+		case "x$cf_check_libtool_version" in
+		(*...GNU-libtool...*)
+			;;
+		(*)
+			AC_MSG_ERROR(This is not GNU libtool)
+			;;
+		esac
+	else
+		AC_MSG_ERROR(No version found for $LIBTOOL)
 	fi
 else
 	AC_MSG_ERROR(GNU libtool has not been found)
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_CHECK_WCHAR_H version: 3 updated: 2021/01/01 13:31:04
+dnl CF_CHECK_WCHAR_H version: 5 updated: 2023/12/03 09:21:34
 dnl ----------------
 dnl Check if wchar.h can be used, i.e., without defining _XOPEN_SOURCE_EXTENDED
 AC_DEFUN([CF_CHECK_WCHAR_H],[
@@ -1321,7 +1456,7 @@ wctype.h \
 AC_CACHE_CHECK(if wchar.h can be used as is,cf_cv_wchar_h_okay,[
 AC_TRY_COMPILE(
 [
-#include <stdlib.h>
+$ac_includes_default
 #ifdef HAVE_WCHAR_H
 #include <wchar.h>
 #endif
@@ -1330,7 +1465,7 @@ AC_TRY_COMPILE(
 #endif
 ],[
 	wint_t foo = 0;
-	int bar = iswpunct(foo)],
+	int bar = iswpunct(foo); (void) bar],
 	[cf_cv_wchar_h_okay=yes],
 	[cf_cv_wchar_h_okay=no])])
 
@@ -1340,7 +1475,7 @@ then
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_CHECK_WCWIDTH_GRAPHICS version: 2 updated: 2021/01/02 17:09:14
+dnl CF_CHECK_WCWIDTH_GRAPHICS version: 4 updated: 2023/12/03 10:17:07
 dnl -------------------------
 dnl Most "modern" terminal emulators are based to some degree on VT100, and
 dnl should support line-drawing.  Even with Unicode.  There is a problem.
@@ -1438,8 +1573,9 @@ cat >conftest.in <<CF_EOF
 0x256c	large plus or crossover
 CF_EOF
 AC_TRY_RUN([
+$ac_includes_default
+
 #include <locale.h>
-#include <stdio.h>
 #include <wchar.h>
 
 #define MY_LEN 80
@@ -1448,7 +1584,7 @@ int
 main(void)
 {
 	FILE *fp;
-	int value;
+	unsigned value;
 	char buffer[MY_LEN + 1];
 	char notes[MY_LEN + 1];
 	int totals = 0;
@@ -1464,9 +1600,9 @@ main(void)
 					fprintf(stderr, "\\t%s", buffer);
 				} else if (sscanf(buffer, "%x %s", &value, notes) == 2) {
 					++totals;
-					if (wcwidth(value) == 1)
+					if (wcwidth((int)value) == 1)
 						++passed;
-					fprintf(stderr, "%d\\t%s", wcwidth(value), buffer);
+					fprintf(stderr, "%d\\t%s", wcwidth((int)value), buffer);
 				} else {
 					fprintf(stderr, "?\\t%s", buffer);
 				}
@@ -1483,7 +1619,7 @@ main(void)
 ])
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_CLANG_COMPILER version: 8 updated: 2021/01/01 13:31:04
+dnl CF_CLANG_COMPILER version: 9 updated: 2023/02/18 17:41:25
 dnl -----------------
 dnl Check if the given compiler is really clang.  clang's C driver defines
 dnl __GNUC__ (fooling the configure script into setting $GCC to yes) but does
@@ -1505,7 +1641,7 @@ if test "$ifelse([$1],,[$1],GCC)" = yes ; then
 	AC_TRY_COMPILE([],[
 #ifdef __clang__
 #else
-make an error
+#error __clang__ is not defined
 #endif
 ],[ifelse([$2],,CLANG_COMPILER,[$2])=yes
 ],[])
@@ -1551,7 +1687,7 @@ if test "x$ifelse([$2],,CLANG_COMPILER,[$2])" = "xyes" ; then
 fi
 ])
 dnl ---------------------------------------------------------------------------
-dnl CF_CONST_X_STRING version: 6 updated: 2021/01/01 13:31:04
+dnl CF_CONST_X_STRING version: 8 updated: 2023/12/01 17:22:50
 dnl -----------------
 dnl The X11R4-X11R6 Xt specification uses an ambiguous String type for most
 dnl character-strings.
@@ -1581,11 +1717,12 @@ AC_TRY_COMPILE(
 #include <stdlib.h>
 #include <X11/Intrinsic.h>
 ],
-[String foo = malloc(1); (void)foo],[
+[String foo = malloc(1); free((void*)foo)],[
 
 AC_CACHE_CHECK(for X11/Xt const-feature,cf_cv_const_x_string,[
 	AC_TRY_COMPILE(
 		[
+#undef  _CONST_X_STRING
 #define _CONST_X_STRING	/* X11R7.8 (perhaps) */
 #undef  XTSTRINGDEFINES	/* X11R5 and later */
 #include <stdlib.h>
@@ -1611,6 +1748,42 @@ esac
 ])
 ])dnl
 dnl ---------------------------------------------------------------------------
+dnl CF_CPP_OVERRIDE version: 1 updated: 2022/08/20 16:07:10
+dnl ---------------
+dnl Check if the C++ compiler accepts the override keyword.  This is a C++-11
+dnl feature.
+AC_DEFUN([CF_CPP_OVERRIDE],
+[
+if test -n "$CXX"; then
+AC_CACHE_CHECK(if $CXX accepts override keyword,cf_cv_cpp_override,[
+	AC_LANG_SAVE
+	AC_LANG_CPLUSPLUS
+	AC_TRY_RUN([
+
+class base
+{
+public:
+	virtual int foo(float x) = 0; 
+};
+
+
+class derived: public base
+{
+public:
+	int foo(float x) override { return x != 0.0 ? 1 : 0; }
+};
+
+int main(void) { }
+],
+	[cf_cv_cpp_override=yes],
+	[cf_cv_cpp_override=no],
+	[cf_cv_cpp_override=unknown])
+	AC_LANG_RESTORE
+])
+fi
+test "$cf_cv_cpp_override" = yes && AC_DEFINE(CPP_HAS_OVERRIDE,1,[Define to 1 if C++ has override keyword])
+])dnl
+dnl ---------------------------------------------------------------------------
 dnl CF_CPP_PARAM_INIT version: 7 updated: 2017/01/21 11:06:25
 dnl -----------------
 dnl Check if the C++ compiler accepts duplicate parameter initialization.  This
@@ -1812,9 +1985,9 @@ done
 AC_SUBST(DIRS_TO_MAKE)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_DISABLE_ECHO version: 13 updated: 2015/04/18 08:56:57
+dnl CF_DISABLE_ECHO version: 14 updated: 2021/09/04 06:35:04
 dnl ---------------
-dnl You can always use "make -n" to see the actual options, but it's hard to
+dnl You can always use "make -n" to see the actual options, but it is hard to
 dnl pick out/analyze warning messages when the compile-line is long.
 dnl
 dnl Sets:
@@ -1860,7 +2033,7 @@ CF_ARG_DISABLE(gnat-projects,
 AC_MSG_RESULT($enable_gnat_projects)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_DISABLE_LEAKS version: 8 updated: 2021/01/05 20:05:09
+dnl CF_DISABLE_LEAKS version: 9 updated: 2021/04/03 16:41:50
 dnl ----------------
 dnl Combine no-leak checks with the libraries or tools that are used for the
 dnl checks.
@@ -1873,9 +2046,9 @@ AC_REQUIRE([CF_WITH_VALGRIND])
 AC_MSG_CHECKING(if you want to perform memory-leak testing)
 AC_ARG_ENABLE(leaks,
 	[  --disable-leaks         test: free permanent memory, analyze leaks],
-	[enable_leaks=no],
+	[enable_leaks=$enableval],
 	[enable_leaks=yes])
-dnl TODO - drop with_no_leaks
+dnl with_no_leaks is more readable...
 if test "x$enable_leaks" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi
 AC_MSG_RESULT($with_no_leaks)
 
@@ -1970,7 +2143,7 @@ fi
 AC_SUBST(BROKEN_LINKER)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_ENABLE_PC_FILES version: 13 updated: 2015/11/01 05:27:39
+dnl CF_ENABLE_PC_FILES version: 16 updated: 2021/11/20 12:48:37
 dnl ------------------
 dnl This is the "--enable-pc-files" option, which is available if there is a
 dnl pkg-config configuration on the local machine.
@@ -1995,11 +2168,12 @@ if test "x$enable_pc_files" != xno
 then
 	MAKE_PC_FILES=
 	case "x$PKG_CONFIG_LIBDIR" in
-	(xno|xyes)
+	(xno|xnone|xyes|x)
 		AC_MSG_WARN(no PKG_CONFIG_LIBDIR was found)
 		;;
 	(*)
-		CF_PATH_SYNTAX(PKG_CONFIG_LIBDIR)
+		cf_pkg_config_libdir="$PKG_CONFIG_LIBDIR"
+		CF_PATH_SYNTAX(cf_pkg_config_libdir)
 		;;
 	esac
 else
@@ -2100,7 +2274,7 @@ AC_DEFUN([CF_ERRNO],
 CF_CHECK_ERRNO(errno)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_ETIP_DEFINES version: 6 updated: 2021/01/02 17:09:14
+dnl CF_ETIP_DEFINES version: 7 updated: 2023/10/28 11:59:01
 dnl ---------------
 dnl Test for conflicting definitions of exception in gcc 2.8.0, etc., between
 dnl math.h and builtin.h, only for ncurses
@@ -2132,7 +2306,7 @@ AC_TRY_COMPILE([
 ],[])
 done
 done
-AC_MSG_RESULT($cf_result)
+AC_MSG_RESULT([${cf_result:-(none)}])
 CXXFLAGS="$cf_save_CXXFLAGS"
 ])
 dnl ---------------------------------------------------------------------------
@@ -2320,7 +2494,7 @@ AC_DEFUN([CF_FIXUP_ADAFLAGS],[
 	AC_MSG_RESULT($ADAFLAGS)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_FIX_WARNINGS version: 3 updated: 2020/12/31 18:40:20
+dnl CF_FIX_WARNINGS version: 4 updated: 2021/12/16 18:22:31
 dnl ---------------
 dnl Warning flags do not belong in CFLAGS, CPPFLAGS, etc.  Any of gcc's
 dnl "-Werror" flags can interfere with configure-checks.  Those go into
@@ -2332,11 +2506,13 @@ if test "$GCC" = yes || test "$GXX" = yes
 then
 	case [$]$1 in
 	(*-Werror=*)
-		CF_VERBOSE(repairing $1: [$]$1)
 		cf_temp_flags=
 		for cf_temp_scan in [$]$1
 		do
 			case "x$cf_temp_scan" in
+			(x-Werror=format*)
+				CF_APPEND_TEXT(cf_temp_flags,$cf_temp_scan)
+				;;
 			(x-Werror=*)
 				CF_APPEND_TEXT(EXTRA_CFLAGS,$cf_temp_scan)
 				;;
@@ -2345,16 +2521,20 @@ then
 				;;
 			esac
 		done
-		$1="$cf_temp_flags"
-		CF_VERBOSE(... fixed [$]$1)
-		CF_VERBOSE(... extra $EXTRA_CFLAGS)
+		if test "x[$]$1" != "x$cf_temp_flags"
+		then
+			CF_VERBOSE(repairing $1: [$]$1)
+			$1="$cf_temp_flags"
+			CF_VERBOSE(... fixed [$]$1)
+			CF_VERBOSE(... extra $EXTRA_CFLAGS)
+		fi
 		;;
 	esac
 fi
 AC_SUBST(EXTRA_CFLAGS)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_FOPEN_BIN_R version: 2 updated: 2019/12/31 08:53:54
+dnl CF_FOPEN_BIN_R version: 3 updated: 2023/01/05 18:05:46
 dnl --------------
 dnl Check if fopen works when the "b" (binary) flag is added to the mode
 dnl parameter.  POSIX ignores the "b", which c89 specified.  Some very old
@@ -2362,8 +2542,10 @@ dnl systems do not accept it.
 AC_DEFUN([CF_FOPEN_BIN_R],[
 AC_CACHE_CHECK(if fopen accepts explicit binary mode,cf_cv_fopen_bin_r,[
 	AC_TRY_RUN([
-#include <stdio.h>
-int main(void) {
+$ac_includes_default
+
+int main(void)
+{
 	FILE *fp = fopen("conftest.tmp", "wb");
 	int rc = 0;
 	if (fp != 0) {
@@ -2441,7 +2623,91 @@ else
 fi
 ])
 dnl ---------------------------------------------------------------------------
-dnl CF_FUNC_MEMMOVE version: 9 updated: 2017/01/21 11:06:25
+dnl CF_FUNC_GETTIME version: 2 updated: 2023/02/25 08:45:56
+dnl ---------------
+dnl Check for gettimeofday or clock_gettime.  In 2023, the former is still more
+dnl widely supported, but "deprecated" (2008), so we will use the latter if it
+dnl is available, to reduce compiler warnings.
+AC_DEFUN([CF_FUNC_GETTIME],[
+AC_CACHE_CHECK(for clock_gettime,cf_cv_func_clock_gettime,[
+		AC_TRY_LINK([#include <time.h>],
+		[struct timespec ts;
+		int rc = clock_gettime(CLOCK_REALTIME, &ts); (void) rc; (void)ts],
+		[cf_cv_func_clock_gettime=yes],
+		[cf_cv_func_clock_gettime=no])
+])
+
+if test "$cf_cv_func_clock_gettime" = yes
+then
+	AC_DEFINE(HAVE_CLOCK_GETTIME,1,[Define to 1 if we have clock_gettime function])
+else
+AC_CHECK_FUNC(gettimeofday,
+	AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define to 1 if we have gettimeofday function]),[
+
+AC_CHECK_LIB(bsd, gettimeofday,
+	AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define to 1 if we have gettimeofday function])
+	CF_ADD_LIB(bsd))])dnl CLIX: bzero, select, gettimeofday
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_FUNC_GETTTYNAM version: 2 updated: 2023/01/05 18:06:28
+dnl -----------------
+dnl Check if the 4.3BSD function getttyname exists, as well as if <ttyent.h>
+dnl defines the _PATH_TTYS symbol.  If the corresponding file exists, but the
+dnl other checks fail, just define HAVE_PATH_TTYS.
+AC_DEFUN([CF_FUNC_GETTTYNAM],[
+AC_CACHE_CHECK(if _PATH_TTYS is defined in ttyent.h,cf_cv_PATH_TTYS,[
+AC_TRY_COMPILE([
+#include <stdio.h>
+#include <ttyent.h>],[
+FILE *fp = fopen(_PATH_TTYS, "r"); (void)fp],
+	[cf_cv_PATH_TTYS=yes],
+	[cf_cv_PATH_TTYS=no])])
+
+if test $cf_cv_PATH_TTYS = no
+then
+	for cf_ttys in /etc/ttytype /etc/ttys
+	do
+		if test -f $cf_ttys
+		then
+			cf_cv_PATH_TTYS=maybe
+			AC_DEFINE(_PATH_TTYS,$cf_ttys,[define to pathname of file containing mapping from tty name to terminal type])
+			break
+		fi
+	done
+fi
+
+if test $cf_cv_PATH_TTYS != no
+then
+	AC_CACHE_CHECK(if _PATH_TTYS file exists,cf_cv_have_PATH_TTYS,[
+		AC_TRY_RUN([
+$ac_includes_default
+
+#include <ttyent.h>
+
+int main(void) {
+	FILE *fp = fopen(_PATH_TTYS, "r");
+	${cf_cv_main_return:-return} (fp == 0);
+}],
+			[cf_cv_have_PATH_TTYS=yes],
+			[cf_cv_have_PATH_TTYS=no],
+			[cf_cv_have_PATH_TTYS=unknown])])
+	test "$cf_cv_have_PATH_TTYS" = no && cf_cv_PATH_TTYS=no
+fi
+
+if test $cf_cv_PATH_TTYS != no
+then
+	AC_DEFINE(HAVE_PATH_TTYS,1,[define to 1 if system can map tty name to terminal type])
+	AC_CACHE_CHECK(for getttynam,cf_cv_func_getttynam,[
+		AC_TRY_LINK([#include <ttyent.h>],
+		[struct ttyent *fp = getttynam("/dev/tty"); (void)fp],
+		[cf_cv_func_getttynam=yes],
+		[cf_cv_func_getttynam=no])])
+	test "$cf_cv_func_getttynam" = yes && AC_DEFINE(HAVE_GETTTYNAM)
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_FUNC_MEMMOVE version: 10 updated: 2023/01/05 18:51:28
 dnl ---------------
 dnl Check for memmove, or a bcopy that can handle overlapping copy.  If neither
 dnl is found, add our own version of memmove to the list of objects.
@@ -2451,6 +2717,8 @@ AC_CHECK_FUNC(memmove,,[
 AC_CHECK_FUNC(bcopy,[
 	AC_CACHE_CHECK(if bcopy does overlapping moves,cf_cv_good_bcopy,[
 		AC_TRY_RUN([
+$ac_includes_default
+
 int main(void) {
 	static char data[] = "abcdefghijklmnopqrstuwwxyz";
 	char temp[40];
@@ -2472,14 +2740,15 @@ int main(void) {
 	fi
 ])])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_FUNC_NANOSLEEP version: 5 updated: 2017/01/21 11:06:25
+dnl CF_FUNC_NANOSLEEP version: 6 updated: 2023/01/05 18:51:33
 dnl -----------------
 dnl Check for existence of workable nanosleep() function.  Some systems, e.g.,
 dnl AIX 4.x, provide a non-working version.
 AC_DEFUN([CF_FUNC_NANOSLEEP],[
 AC_CACHE_CHECK(if nanosleep really works,cf_cv_func_nanosleep,[
 AC_TRY_RUN([
-#include <stdio.h>
+$ac_includes_default
+
 #include <errno.h>
 #include <time.h>
 
@@ -2506,7 +2775,7 @@ int main(void) {
 test "$cf_cv_func_nanosleep" = "yes" && AC_DEFINE(HAVE_NANOSLEEP,1,[Define to 1 if we have nanosleep()])
 ])
 dnl ---------------------------------------------------------------------------
-dnl CF_FUNC_OPENPTY version: 6 updated: 2021/01/01 13:31:04
+dnl CF_FUNC_OPENPTY version: 7 updated: 2023/12/03 09:21:34
 dnl ---------------
 dnl Check for openpty() function, along with <pty.h> header.  It may need the
 dnl "util" library as well.
@@ -2523,6 +2792,7 @@ AC_CACHE_CHECK(for openpty header,cf_cv_func_openpty,[
 ],[
 	int x = openpty((int *)0, (int *)0, (char *)0,
 				   (struct termios *)0, (struct winsize *)0);
+	(void)x;
 ],[
 		cf_cv_func_openpty=$cf_header
 		break
@@ -2534,7 +2804,7 @@ AC_CACHE_CHECK(for openpty header,cf_cv_func_openpty,[
 ])
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_FUNC_POLL version: 10 updated: 2021/01/04 19:13:57
+dnl CF_FUNC_POLL version: 11 updated: 2023/01/05 18:51:40
 dnl ------------
 dnl See if the poll function really works.  Some platforms have poll(), but
 dnl it does not work for terminals or files.
@@ -2542,15 +2812,16 @@ AC_DEFUN([CF_FUNC_POLL],[
 tty >/dev/null 2>&1 || { AC_CHECK_FUNCS(posix_openpt) }
 AC_CACHE_CHECK(if poll really works,cf_cv_working_poll,[
 AC_TRY_RUN([
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
+$ac_includes_default
+
 #include <fcntl.h>
+
 #ifdef HAVE_POLL_H
 #include <poll.h>
 #else
 #include <sys/poll.h>
 #endif
+
 int main(void) {
 	struct pollfd myfds;
 	int ret;
@@ -2624,19 +2895,29 @@ tcgetattr(1, &foo);],
 test "$cf_cv_have_tcgetattr" = yes && AC_DEFINE(HAVE_TCGETATTR,1,[Define to 1 if we have tcgetattr])
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_FUNC_VSSCANF version: 7 updated: 2021/01/01 13:31:04
+dnl CF_FUNC_VSSCANF version: 8 updated: 2023/12/03 19:09:59
 dnl ---------------
 dnl Check for vsscanf() function, which is in c9x but generally not in earlier
-dnl versions of C.  It is in the GNU C library, and can often be simulated by
-dnl other functions.
+dnl versions of C.  It can often be simulated by other functions on older
+dnl systems (where FILE is not opaque).
 AC_DEFUN([CF_FUNC_VSSCANF],
 [
 AC_CACHE_CHECK(for vsscanf function or workaround,cf_cv_func_vsscanf,[
 AC_TRY_LINK([
 #include <stdarg.h>
-#include <stdio.h>],[
+#include <stdio.h>
+
+static void
+myfunc(const char *str, const char *fmt, ...)
+{
 	va_list ap;
-	vsscanf("from", "%d", ap)],[cf_cv_func_vsscanf=vsscanf],[
+	va_start(ap, fmt);
+	vsscanf(str, fmt, ap);
+	va_end(ap);
+}
+],[
+	myfunc("55", "%d");
+],[cf_cv_func_vsscanf=vsscanf],[
 AC_TRY_LINK([
 #include <stdarg.h>
 #include <stdio.h>],[
@@ -2669,13 +2950,14 @@ esac
 
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_GCC_ATTRIBUTES version: 23 updated: 2021/01/03 18:30:50
+dnl CF_GCC_ATTRIBUTES version: 24 updated: 2021/03/20 12:00:25
 dnl -----------------
 dnl Test for availability of useful gcc __attribute__ directives to quiet
 dnl compiler warnings.  Though useful, not all are supported -- and contrary
 dnl to documentation, unrecognized directives cause older compilers to barf.
 AC_DEFUN([CF_GCC_ATTRIBUTES],
 [AC_REQUIRE([AC_PROG_FGREP])dnl
+AC_REQUIRE([CF_C11_NORETURN])dnl
 
 if test "$GCC" = yes || test "$GXX" = yes
 then
@@ -2698,6 +2980,7 @@ then
 	AC_CHECKING([for $CC __attribute__ directives])
 cat > "conftest.$ac_ext" <<EOF
 #line __oline__ "${as_me:-configure}"
+#include <stdio.h>
 #include "confdefs.h"
 #include "conftest.h"
 #include "conftest.i"
@@ -2712,8 +2995,8 @@ cat > "conftest.$ac_ext" <<EOF
 #define GCC_SCANFLIKE(fmt,var)  /*nothing*/
 #endif
 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
-extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
-extern void foo(void) GCC_NORETURN;
+extern GCC_NORETURN void oops(char *,...) GCC_PRINTFLIKE(1,2);
+extern GCC_NORETURN void foo(void);
 int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { (void)argc; (void)argv; return 0; }
 EOF
 	cf_printf_attribute=no
@@ -2780,7 +3063,7 @@ rm -rf ./conftest*
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_GCC_VERSION version: 8 updated: 2019/09/07 13:38:36
+dnl CF_GCC_VERSION version: 9 updated: 2023/03/05 14:30:13
 dnl --------------
 dnl Find version of gcc, and (because icc/clang pretend to be gcc without being
 dnl compatible), attempt to determine if icc/clang is actually used.
@@ -2789,7 +3072,7 @@ AC_REQUIRE([AC_PROG_CC])
 GCC_VERSION=none
 if test "$GCC" = yes ; then
 	AC_MSG_CHECKING(version of $CC)
-	GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC[[^)]]*) //' -e 's/^.*(Debian[[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
+	GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^[[^(]]*([[^)]][[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
 	test -z "$GCC_VERSION" && GCC_VERSION=unknown
 	AC_MSG_RESULT($GCC_VERSION)
 fi
@@ -2911,7 +3194,7 @@ rm -rf ./conftest*
 AC_SUBST(EXTRA_CFLAGS)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_GETOPT_HEADER version: 7 updated: 2021/01/01 13:31:04
+dnl CF_GETOPT_HEADER version: 8 updated: 2021/06/19 19:16:16
 dnl ----------------
 dnl Check for getopt's variables which are commonly defined in stdlib.h,
 dnl unistd.h or (nonstandard) in getopt.h
@@ -2924,7 +3207,7 @@ for cf_header in stdio.h stdlib.h unistd.h getopt.h
 do
 AC_TRY_COMPILE([
 #include <$cf_header>],
-[int x = optind; char *y = optarg],
+[int x = optind; char *y = optarg; (void)x; (void)y],
 [cf_cv_getopt_header=$cf_header
  break])
 done
@@ -3372,7 +3655,7 @@ if test "$GXX" = yes; then
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_GXX_VERSION version: 8 updated: 2017/02/11 14:48:57
+dnl CF_GXX_VERSION version: 9 updated: 2023/03/05 14:30:13
 dnl --------------
 dnl Check for version of g++
 AC_DEFUN([CF_GXX_VERSION],[
@@ -3380,7 +3663,7 @@ AC_REQUIRE([AC_PROG_CPP])
 GXX_VERSION=none
 if test "$GXX" = yes; then
 	AC_MSG_CHECKING(version of ${CXX:-g++})
-	GXX_VERSION="`${CXX:-g++} --version| sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
+	GXX_VERSION="`${CXX:-g++} --version 2>/dev/null | sed -e '2,$d' -e 's/^[[^(]]*([[^)]][[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
 	if test -z "$GXX_VERSION"
 	then
 		GXX_VERSION=unknown
@@ -3625,7 +3908,7 @@ done
 ])
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_HASHED_DB_VERSION version: 4 updated: 2014/04/12 16:47:01
+dnl CF_HASHED_DB_VERSION version: 5 updated: 2023/02/18 17:41:25
 dnl --------------------
 dnl Given that we have the header file for hashed database, find the version
 dnl information.
@@ -3646,13 +3929,13 @@ $ac_includes_default
 #if $cf_db_version == DB_VERSION_MAJOR
 	/* ok */
 #else
-	make an error
+	#error $cf_db_version is not DB_VERSION_MAJOR
 #endif
 #else
 #if $cf_db_version == 1
 	/* ok: assuming this is DB 1.8.5 */
 #else
-	make an error
+	#error $cf_db_version is not 1
 #endif
 #endif
 ],[DBT *foo = 0],[
@@ -3734,7 +4017,7 @@ CPPFLAGS="-I. $CPPFLAGS"
 AC_SUBST(CPPFLAGS)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_INSTALL_OPTS version: 2 updated: 2018/08/18 12:19:21
+dnl CF_INSTALL_OPTS version: 3 updated: 2023/06/03 15:17:30
 dnl ---------------
 dnl prompt for/fill-in useful install-program options
 AC_DEFUN([CF_INSTALL_OPTS],
@@ -3742,6 +4025,7 @@ AC_DEFUN([CF_INSTALL_OPTS],
 CF_INSTALL_OPT_S
 CF_INSTALL_OPT_P
 CF_INSTALL_OPT_O
+CF_INSTALL_OPT_STRIP_PROG
 ])dnl
 dnl ---------------------------------------------------------------------------
 dnl CF_INSTALL_OPT_O version: 3 updated: 2020/12/31 20:19:42
@@ -3828,7 +4112,73 @@ fi
 AC_SUBST(INSTALL_OPT_S)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_INTEL_COMPILER version: 8 updated: 2021/01/01 16:53:59
+dnl CF_INSTALL_OPT_STRIP_PROG version: 1 updated: 2023/06/03 15:17:30
+dnl -------------------------
+dnl Provide an option for overriding the strip program used in install "-s"
+dnl
+dnl coreutils install provides a --strip-program option
+dnl FreeBSD uses STRIPBIN environment variable, while NetBSD and OpenBSD use
+dnl STRIP environment variable.  Other versions of install do not support this.
+AC_DEFUN([CF_INSTALL_OPT_STRIP_PROG],
+[
+AC_REQUIRE([CF_INSTALL_OPT_S])
+if test -n "$INSTALL_OPT_S"
+then
+	AC_MSG_CHECKING(if you want to specify strip-program)
+	AC_ARG_WITH(strip-program,
+		[  --with-strip-program=XX specify program to use when stripping in install],
+		[with_strip_program=$withval],
+		[with_strip_program=no])
+	AC_MSG_RESULT($with_strip_program)
+	if test "$with_strip_program" != no
+	then
+		AC_MSG_CHECKING(if strip-program is supported with this installer)
+		cf_install_program=`echo "$INSTALL" | sed -e 's%[[ ]]*[[ ]]-.%%'`
+		check_install_strip=no
+		if test -f "$cf_install_program"
+		then
+			check_install_version=`"$cf_install_program" --version 2>/dev/null | head -n 1 | grep coreutils`
+			if test -n "$check_install_version"
+			then
+				check_install_strip="option"
+			else
+				for check_strip_variable in STRIPBIN STRIP
+				do
+					if strings "$cf_install_program" | grep "^$check_strip_variable[$]" >/dev/null
+					then
+						check_install_strip="environ"
+						break
+					fi
+				done
+			fi
+		fi
+		AC_MSG_RESULT($check_install_strip)
+		case "$check_install_strip" in
+		(no)
+			AC_MSG_WARN($cf_install_program does not support strip program option)
+			with_strip_program=no
+			;;
+		(environ)
+			cat >install.tmp <<-CF_EOF
+			#! $SHELL
+			STRIPBIN="$with_strip_program" \\
+			STRIP="$with_strip_program" \\
+			$INSTALL "[$]@"
+			CF_EOF
+			INSTALL="`pwd`/install.tmp"
+			chmod +x "$INSTALL"
+			CF_VERBOSE(created $INSTALL)
+			;;
+		(option)
+			INSTALL_OPT_S="$INSTALL_OPT_S --strip-program=\"$with_strip_program\""
+			;;
+		esac
+	fi
+fi
+AC_SUBST(INSTALL_OPT_S)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_INTEL_COMPILER version: 9 updated: 2023/02/18 17:41:25
 dnl -----------------
 dnl Check if the given compiler is really the Intel compiler for Linux.  It
 dnl tries to imitate gcc, but does not return an error when it finds a mismatch
@@ -3854,7 +4204,7 @@ if test "$ifelse([$1],,[$1],GCC)" = yes ; then
 		AC_TRY_COMPILE([],[
 #ifdef __INTEL_COMPILER
 #else
-make an error
+#error __INTEL_COMPILER is not defined
 #endif
 ],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
 cf_save_CFLAGS="$cf_save_CFLAGS -we147"
@@ -3866,14 +4216,14 @@ cf_save_CFLAGS="$cf_save_CFLAGS -we147"
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_ISASCII version: 4 updated: 2012/10/06 17:56:13
+dnl CF_ISASCII version: 5 updated: 2023/12/03 09:21:34
 dnl ----------
 dnl Check if we have either a function or macro for 'isascii()'.
 AC_DEFUN([CF_ISASCII],
 [
 AC_MSG_CHECKING(for isascii)
 AC_CACHE_VAL(cf_cv_have_isascii,[
-	AC_TRY_LINK([#include <ctype.h>],[int x = isascii(' ')],
+	AC_TRY_LINK([#include <ctype.h>],[int x = isascii(' '); (void)x],
 	[cf_cv_have_isascii=yes],
 	[cf_cv_have_isascii=no])
 ])dnl
@@ -3881,7 +4231,7 @@ AC_MSG_RESULT($cf_cv_have_isascii)
 test "$cf_cv_have_isascii" = yes && AC_DEFINE(HAVE_ISASCII,1,[Define to 1 if we have isascii()])
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_LARGEFILE version: 12 updated: 2020/03/19 20:23:48
+dnl CF_LARGEFILE version: 13 updated: 2023/12/03 19:09:59
 dnl ------------
 dnl Add checks for large file support.
 AC_DEFUN([CF_LARGEFILE],[
@@ -3915,11 +4265,15 @@ ifdef([AC_FUNC_FSEEKO],[
 #pragma GCC diagnostic error "-Wincompatible-pointer-types"
 #include <sys/types.h>
 #include <dirent.h>
+
+#ifndef __REDIRECT
+/* if transitional largefile support is setup, this is true */
+extern struct dirent64 * readdir(DIR *);
+#endif
 		],[
-		/* if transitional largefile support is setup, this is true */
-		extern struct dirent64 * readdir(DIR *);
-		struct dirent64 *x = readdir((DIR *)0);
-		struct dirent *y = readdir((DIR *)0);
+		DIR *dp = opendir(".");
+		struct dirent64 *x = readdir(dp);
+		struct dirent *y = readdir(dp);
 		int z = x - y;
 		(void)z;
 		],
@@ -4090,7 +4444,7 @@ then
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_LD_SEARCHPATH version: 2 updated: 2019/09/26 20:34:14
+dnl CF_LD_SEARCHPATH version: 4 updated: 2022/08/27 15:43:08
 dnl ----------------
 dnl Try to obtain the linker's search-path, for use in scripts.
 dnl
@@ -4101,19 +4455,19 @@ AC_CACHE_CHECK(for linker search path,cf_cv_ld_searchpath,[
 if test "$cross_compiling" != yes ; then
 
 # GNU binutils' ld does not involve permissions which may stop ldconfig.
-cf_pathlist=`ld --verbose 2>/dev/null | grep SEARCH_DIR | sed -e 's,SEARCH_DIR[[("=]][[("=]]*,,g' -e 's/"[[)]];//gp' | sort -u`
+cf_pathlist=`${LD:-ld} --verbose 2>/dev/null | grep SEARCH_DIR | sed -e 's,SEARCH_DIR[[("=]][[("=]]*,,g' -e 's/"[[)]];//gp' | sort -u`
 
 # The -NX options tell newer versions of Linux ldconfig to not attempt to
 # update the cache, which makes it run faster.
 test -z "$cf_pathlist" && \
-	cf_pathlist=`ldconfig -NX -v 2>/dev/null | sed -e '/^[[ 	]]/d' -e 's/:$//' | sort -u`
+	cf_pathlist=`(ldconfig -NX -v) 2>/dev/null | sed -e '/^[[ 	]]/d' -e 's/:$//' | sort -u`
 
 test -z "$cf_pathlist" &&
-	cf_pathlist=`ldconfig -v 2>/dev/null | sed -n -e '/^[[ 	]]/d' -e 's/:$//p' | sort -u`
+	cf_pathlist=`(ldconfig -v) 2>/dev/null | sed -n -e '/^[[ 	]]/d' -e 's/:$//p' | sort -u`
 
 # This works with OpenBSD 6.5, which lists only filenames
 test -z "$cf_pathlist" &&
-	cf_pathlist=`ldconfig -v 2>/dev/null | sed -n -e 's,^Adding \(.*\)/.*[$],\1,p' | sort -u`
+	cf_pathlist=`(ldconfig -v) 2>/dev/null | sed -n -e 's,^Adding \(.*\)/.*[$],\1,p' | sort -u`
 
 if test -z "$cf_pathlist"
 then
@@ -4128,13 +4482,37 @@ fi
 
 if test -z "$cf_pathlist"
 then
-	# Solaris is hardcoded
-	if test -d /opt/SUNWspro/lib
+	# Solaris is "SunOS"
+	if test -f /usr/bin/isainfo && test "x`uname -s`" = xSunOS
 	then
-		cf_pathlist="/opt/SUNWspro/lib /usr/ccs/lib /usr/lib"
-	elif test -d /usr/ccs/lib
+		case x`(isainfo -b)` in
+		(x64)
+			cf_pathlist="$cf_pathlist /lib/64 /usr/lib/64"
+			;;
+		(x32)
+			test -d /usr/ccs/lib && cf_pathlist="$cf_pathlist /usr/ccs/lib"
+			cf_pathlist="$cf_pathlist /lib /usr/lib"
+			;;
+		(*)
+			AC_MSG_WARN(problem with Solaris architecture)
+			;;
+		esac
+	fi
+fi
+
+if test -z "$cf_pathlist"
+then
+	# HP-UX
+	if test x"`uname -s`" = xHP-UX
 	then
-		cf_pathlist="/usr/ccs/lib /usr/lib"
+		case x`getconf LONG_BIT` in
+		(x64)
+			cf_pathlist="/usr/lib/hpux64"
+			;;
+		(x*)
+			cf_pathlist="/usr/lib/hpux32"
+			;;
+		esac
 	fi
 fi
 
@@ -4225,7 +4603,7 @@ ifelse($1,,,[$1=$LIB_PREFIX])
 	AC_SUBST(LIB_PREFIX)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_LIB_RULES version: 94 updated: 2021/01/23 15:37:41
+dnl CF_LIB_RULES version: 100 updated: 2023/06/03 15:17:30
 dnl ------------
 dnl Append definitions and rules for the given models to the subdirectory
 dnl Makefiles, and the recursion rule for the top-level Makefile.  If the
@@ -4242,6 +4620,7 @@ dnl
 dnl Note: Libs_To_Make is mixed case, since it is not a pure autoconf variable.
 AC_DEFUN([CF_LIB_RULES],
 [AC_REQUIRE([AC_PROG_FGREP])dnl
+AC_REQUIRE([CF_MAKE_PHONY])dnl
 
 cf_prefix=$LIB_PREFIX
 AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
@@ -4279,11 +4658,11 @@ do
 		SHARED_LIB=
 		Libs_To_Make=
 		cf_awk_program=
-		if test -n "${cf_cv_abi_version}" && test "x${cf_cv_abi_version}" != "x5"
+		if test -n "${cf_cv_abi_default}" && test "x${cf_cv_abi_default}" != "x5"
 		then
 			cf_awk_program="$cf_awk_program\
-/deprecated in ABI${cf_cv_abi_version}/ { next; }\
-{ sub(\"NCURSES([[WT]]+)?\", \"&${cf_cv_abi_version}\"); }\
+/deprecated in ABI${cf_cv_abi_default}/ { next; }\
+{ sub(\"NCURSES([[WT]]+)?\", \"&${cf_cv_abi_default}\"); }\
 "
 		fi
 
@@ -4562,6 +4941,9 @@ CF_EOF
 				traces=$LIB_TRACING \
 				MODEL=$cf_ITEM \
 				CXX_MODEL=$CXX_MODEL \
+				LIB_SUFFIX=$LIB_SUFFIX \
+				USE_LIB_SUFFIX=$USE_LIB_SUFFIX \
+				make_phony="${cf_cv_make_PHONY:-no}" \
 				model=$cf_subdir \
 				prefix=$cf_prefix \
 				suffix=$cf_suffix \
@@ -4609,6 +4991,21 @@ CF_EOF
 	echo '	( cd '$cf_dir' && ${MAKE} ${TOP_MFLAGS} [$]@ )' >>Makefile
 done
 
+echo >> Makefile
+echo '# generated by CF_LIB_RULES' >> Makefile
+
+if test "x$cf_cv_make_PHONY" = xyes ; then
+	cat >> Makefile <<-CF_EOF
+
+	.PHONY :	libs
+	.PHONY :	lintlib
+	.PHONY :	install.includes
+	.PHONY :	uninstall.includes
+	.PHONY :	install.libs
+	.PHONY :	uninstall.libs
+CF_EOF
+fi
+
 for cf_dir in $SRC_SUBDIRS
 do
 	if test ! -d "$srcdir/$cf_dir" ; then
@@ -4627,6 +5024,15 @@ do
 	fi
 
 	if test -f "$srcdir/$cf_dir/modules" ; then
+
+		if test "x$cf_cv_make_PHONY" = xyes ; then
+			cat >> Makefile <<-CF_EOF
+
+			.PHONY :	install.$cf_dir
+			.PHONY :	uninstall.$cf_dir
+CF_EOF
+		fi
+
 		echo >> Makefile
 		if test -f "$srcdir/$cf_dir/headers" ; then
 cat >> Makefile <<CF_EOF
@@ -4634,10 +5040,9 @@ install.includes \\
 uninstall.includes \\
 CF_EOF
 		fi
-if test "$cf_dir" != "c++" ; then
-echo 'lint \' >> Makefile
-fi
+
 cat >> Makefile <<CF_EOF
+lint \\
 libs \\
 lintlib \\
 install.libs \\
@@ -4659,6 +5064,14 @@ CF_EOF
 fi
 done
 
+if test "x$cf_cv_make_PHONY" = xyes ; then
+	cat >> Makefile <<-CF_EOF
+
+	.PHONY :	install.data
+	.PHONY :	uninstall.data
+CF_EOF
+fi
+
 if test "x$cf_with_db_install" = xyes; then
 cat >> Makefile <<CF_EOF
 
@@ -4675,6 +5088,15 @@ CF_EOF
 fi
 
 if test "x$cf_with_manpages" = xyes; then
+
+if test "x$cf_cv_make_PHONY" = xyes ; then
+	cat >> Makefile <<-CF_EOF
+
+	.PHONY :	install.man
+	.PHONY :	uninstall.man
+CF_EOF
+fi
+
 cat >> Makefile <<CF_EOF
 
 install.man \\
@@ -4688,22 +5110,10 @@ cat >> Makefile <<CF_EOF
 distclean ::
 	rm -f config.cache config.log config.status Makefile include/ncurses_cfg.h
 	rm -f headers.sh headers.sed mk_shared_lib.sh
-	rm -f edit_man.* man_alias.*
+	rm -f edit_man.* man_alias.* *.tmp
 	rm -rf \${DIRS_TO_MAKE}
 CF_EOF
 
-# Special case: tack's manpage lives in its own directory.
-if test "x$cf_with_manpages" = xyes; then
-if test "x$cf_with_tack" = "xyes"; then
-cat >> Makefile <<CF_EOF
-
-install.man \\
-uninstall.man ::
-	( cd tack && \${MAKE} \${TOP_MFLAGS} \[$]@ )
-CF_EOF
-fi
-fi
-
 dnl If we're installing into a subdirectory of /usr/include, etc., we should
 dnl prepend the subdirectory's name to the "#include" paths.  It won't hurt
 dnl anything, and will make it more standardized.  It's awkward to decide this
@@ -4807,6 +5217,13 @@ do
 
 	if test -f "$srcdir/$cf_dir/modules" ; then
 		if test "$cf_dir" != "c++" ; then
+			if test "x$cf_cv_make_PHONY" = xyes ; then
+				cat >> $cf_dir/Makefile <<-CF_EOF
+
+				.PHONY :	depend
+CF_EOF
+			fi
+
 			cat >>$cf_dir/Makefile <<"CF_EOF"
 depend : ${AUTO_SRC}
 	makedepend -- ${CPPFLAGS} -- ${C_SRC}
@@ -4966,7 +5383,7 @@ AC_DEFUN([CF_LIB_TYPE],
 	test -n "$LIB_SUFFIX" && $2="${LIB_SUFFIX}[$]{$2}"
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_LINK_DATAONLY version: 13 updated: 2020/02/08 15:59:30
+dnl CF_LINK_DATAONLY version: 15 updated: 2023/12/03 10:03:10
 dnl ----------------
 dnl Some systems have a non-ANSI linker that doesn't pull in modules that have
 dnl only data (i.e., no functions), for example NeXT.  On those systems we'll
@@ -4988,17 +5405,21 @@ EOF
 	rm -f conftest.$ac_ext data.o
 	cat >conftest.$ac_ext <<EOF
 #line __oline__ "configure"
+extern int testfunc(void);
+#if defined(NeXT)
 int	testfunc(void)
 {
-#if defined(NeXT)
 	${cf_cv_main_return:-return}(1);	/* I'm told this linker is broken */
+}
 #else
-	extern int testdata[[3]];
+extern int testdata[[3]];
+int	testfunc(void)
+{
 	return testdata[[0]] == 123
 	   &&  testdata[[1]] == 456
 	   &&  testdata[[2]] == 789;
-#endif
 }
+#endif
 EOF
 	if AC_TRY_EVAL(ac_compile); then
 		mv conftest.o func.o && \
@@ -5009,9 +5430,9 @@ EOF
 	cf_saveLIBS="$LIBS"
 	LIBS="conftest.a $LIBS"
 	AC_TRY_RUN([
+	extern int testfunc(void);
 	int main(void)
 	{
-		extern int testfunc();
 		${cf_cv_main_return:-return} (!testfunc());
 	}
 	],
@@ -5030,11 +5451,14 @@ AC_SUBST(BROKEN_LINKER)
 
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_LINK_FUNCS version: 9 updated: 2017/01/21 11:11:02
+dnl CF_LINK_FUNCS version: 13 updated: 2023/12/03 09:24:04
 dnl -------------
 dnl Most Unix systems have both link and symlink, a few don't have symlink.
 dnl A few non-Unix systems implement symlink, but not link.
 dnl A few non-systems implement neither (or have nonfunctional versions).
+dnl
+dnl This allows for a 2-second difference in modification times to allow for
+dnl some marginal NFS implementations.
 AC_DEFUN([CF_LINK_FUNCS],
 [
 AC_CHECK_HEADERS( \
@@ -5053,27 +5477,31 @@ else
 		cf_cv_link_funcs=
 		for cf_func in link symlink ; do
 			AC_TRY_RUN([
-#include <sys/types.h>
-#include <sys/stat.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
+$ac_includes_default
+
 int main(void)
 {
 	int fail = 0;
-	char *src = "config.log";
-	char *dst = "conftest.chk";
-	struct stat src_sb;
-	struct stat dst_sb;
-
-	stat(src, &src_sb);
-	fail = ($cf_func("config.log", "conftest.chk") < 0)
-	    || (stat(dst, &dst_sb) < 0)
-	    || (dst_sb.st_mtime != src_sb.st_mtime);
+	char src[] = "conftest.tmp";
+	char dst[] = "conftest.chk";
+	struct stat src_sb, dst_sb;
+	FILE *fp = fopen(src, "w");
+	if (fp == 0) { fail = 3; } else {
+		fclose(fp); stat(src, &src_sb);
+		if ($cf_func(src, dst) < 0) {
+			fail = 1;
+		} else if (stat(dst, &dst_sb) < 0) {
+			fail = 2;
+		} else {
+			long diff = (dst_sb.st_mtime - src_sb.st_mtime);
+			if (diff < 0) diff = -diff;
+			if (diff > 2) fail = 3;
+		}
+	}
 #ifdef HAVE_UNLINK
-	unlink(dst);
+	unlink(dst); unlink(src);
 #else
-	remove(dst);
+	remove(dst); remove(src);
 #endif
 	${cf_cv_main_return:-return} (fail);
 }
@@ -5090,10 +5518,10 @@ int main(void)
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_MAKEFLAGS version: 20 updated: 2021/01/03 19:29:49
+dnl CF_MAKEFLAGS version: 21 updated: 2021/09/04 06:47:34
 dnl ------------
 dnl Some 'make' programs support ${MAKEFLAGS}, some ${MFLAGS}, to pass 'make'
-dnl options to lower-levels.  It's very useful for "make -n" -- if we have it.
+dnl options to lower-levels.  It is very useful for "make -n" -- if we have it.
 dnl (GNU 'make' does both, something POSIX 'make', which happens to make the
 dnl ${MAKEFLAGS} variable incompatible because it adds the assignments :-)
 AC_DEFUN([CF_MAKEFLAGS],
@@ -5133,6 +5561,89 @@ CF_EOF
 AC_SUBST(cf_cv_makeflags)
 ])dnl
 dnl ---------------------------------------------------------------------------
+dnl CF_MAKE_PHONY version: 3 updated: 2021/01/08 16:08:21
+dnl -------------
+dnl Check if the make-program handles a ".PHONY" target, e.g,. a target which
+dnl acts as a placeholder.
+dnl
+dnl The ".PHONY" feature was proposed in 2011 here
+dnl     https://www.austingroupbugs.net/view.php?id=523
+dnl and is scheduled for release in P1003.1 Issue 8 (late 2022).
+dnl
+dnl This is not supported by SVr4 make (or SunOS 4, 4.3SD, etc), but works with
+dnl a few others (i.e., GNU make and the non-POSIX "BSD" make):
+dnl
+dnl + This is a GNU make feature (since April 1988, but in turn from binutils,
+dnl   date unspecified).
+dnl
+dnl + It was adopted in NetBSD make in June 1995.
+dnl
+dnl + The other BSD make programs are derived from the NetBSD make (and for
+dnl   that reason are not actually different "implementations").
+dnl
+dnl + Some features of NetBSD make were actually adapted from pmake, which
+dnl   began as a modified GNU make starting in 1993.
+dnl
+dnl + Version 3.8 of the dmake program in January 1992 also implemented this
+dnl   GNU make extension, but is less well known than the BSD make.
+AC_DEFUN([CF_MAKE_PHONY],[
+AC_CACHE_CHECK(for \".PHONY\" make-support, cf_cv_make_PHONY,[
+	rm -rf conftest*
+	(
+		mkdir conftest || exit 1
+		cd conftest
+		cat >makefile <<'CF_EOF'
+.PHONY: always
+DATA=0
+always:	always.out
+	@echo "** making [$]@ [$](DATA)"
+once: once.out
+	@echo "** making [$]@ [$](DATA)"
+always.out:
+	@echo "** making [$]@ [$](DATA)"
+	echo [$](DATA) > [$]@
+once.out:
+	@echo "** making [$]@ [$](DATA)"
+	echo [$](DATA) > [$]@
+CF_EOF
+		for cf_data in 1 2 3
+		do
+			${MAKE:-make} always DATA=$cf_data
+			${MAKE:-make} once   DATA=$cf_data
+			${MAKE:-make} -t always once
+			if test -f always ; then
+				echo "no (case 1)" > ../conftest.tmp
+			elif test ! -f always.out ; then
+				echo "no (case 2)" > ../conftest.tmp
+			elif test ! -f once.out ; then
+				echo "no (case 3)" > ../conftest.tmp
+			elif ! cmp -s always.out once.out ; then
+				echo "no (case 4)" > ../conftest.tmp
+				diff always.out once.out
+			else
+				cf_check="`cat always.out`"
+				if test "x$cf_check" != "x$cf_data" ; then
+					echo "no (case 5)" > ../conftest.tmp
+				else
+					echo yes > ../conftest.tmp
+					rm -f ./*.out
+					continue
+				fi
+			fi
+			break
+		done
+	) >&AC_FD_CC 2>&1
+	cf_cv_make_PHONY="`cat conftest.tmp`"
+	rm -rf conftest*
+])
+MAKE_NO_PHONY="#"
+MAKE_PHONY="#"
+test "x$cf_cv_make_PHONY" = xyes && MAKE_PHONY=
+test "x$cf_cv_make_PHONY" != xyes && MAKE_NO_PHONY=
+AC_SUBST(MAKE_NO_PHONY)
+AC_SUBST(MAKE_PHONY)
+])dnl
+dnl ---------------------------------------------------------------------------
 dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
 dnl ------------
 dnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
@@ -5170,13 +5681,16 @@ AC_SUBST(MAKE_UPPER_TAGS)
 AC_SUBST(MAKE_LOWER_TAGS)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_MANPAGE_FORMAT version: 14 updated: 2021/01/02 17:09:14
+dnl CF_MANPAGE_FORMAT version: 19 updated: 2024/03/30 08:27:40
 dnl -----------------
 dnl Option to allow user to override automatic configuration of manpage format.
 dnl There are several special cases:
 dnl
-dnl	gzip - man checks for, can display gzip'd files
 dnl	compress - man checks for, can display compressed files
+dnl	bzip2 - man checks for, can display bzip2'd files
+dnl	gzip - man checks for, can display gzip'd files
+dnl	xz - man checks for, can display xz'd files
+dnl
 dnl	BSDI - files in the cat-directories are suffixed ".0"
 dnl	formatted - installer should format (put files in cat-directory)
 dnl	catonly - installer should only format, e.g., for a turnkey system.
@@ -5190,8 +5704,9 @@ AC_REQUIRE([CF_PATHSEP])
 AC_MSG_CHECKING(format of man-pages)
 
 AC_ARG_WITH(manpage-format,
-	[  --with-manpage-format   specify manpage-format: gzip/compress/BSDI/normal and
-                          optionally formatted/catonly, e.g., gzip,formatted],
+	[  --with-manpage-format   specify manpage-format: gzip/compress/bzip2/xz,
+                          BSDI/normal and optionally formatted/catonly,
+                          e.g., gzip,formatted],
 	[MANPAGE_FORMAT=$withval],
 	[MANPAGE_FORMAT=unknown])
 
@@ -5206,7 +5721,7 @@ case "$MANPAGE_FORMAT" in
 		MANPATH="/usr/man:/usr/share/man"
 	fi
 
-	# look for the 'date' man-page (it's most likely to be installed!)
+	# look for the 'date' man-page (it is most likely to be installed!)
 	MANPAGE_FORMAT=
 	cf_preform="no"
 	cf_catonly="yes"
@@ -5221,10 +5736,12 @@ case "$MANPAGE_FORMAT" in
 			if test "x$cf_test" = "x$cf_name" ; then
 
 				case "$cf_name" in
-				(*.gz) MANPAGE_FORMAT="$MANPAGE_FORMAT gzip";;
-				(*.Z)  MANPAGE_FORMAT="$MANPAGE_FORMAT compress";;
-				(*.0)  MANPAGE_FORMAT="$MANPAGE_FORMAT BSDI";;
-				(*)    MANPAGE_FORMAT="$MANPAGE_FORMAT normal";;
+				(*.bz2) MANPAGE_FORMAT="$MANPAGE_FORMAT bzip2";;
+				(*.xz)  MANPAGE_FORMAT="$MANPAGE_FORMAT xz";;
+				(*.gz)  MANPAGE_FORMAT="$MANPAGE_FORMAT gzip";;
+				(*.Z)   MANPAGE_FORMAT="$MANPAGE_FORMAT compress";;
+				(*.0)   MANPAGE_FORMAT="$MANPAGE_FORMAT BSDI";;
+				(*)     MANPAGE_FORMAT="$MANPAGE_FORMAT normal";;
 				esac
 
 				case "$cf_name" in
@@ -5263,7 +5780,7 @@ case "$MANPAGE_FORMAT" in
 (*)
 	for cf_option in $MANPAGE_FORMAT; do
 	case "$cf_option" in
-	(gzip|compress|BSDI|normal|formatted|catonly)
+	(xz|bzip2|gzip|compress|BSDI|normal|formatted|catonly)
 		;;
 	(*)
 		cf_unknown="$cf_unknown $cf_option"
@@ -5277,9 +5794,53 @@ AC_MSG_RESULT($MANPAGE_FORMAT)
 if test -n "$cf_unknown" ; then
 	AC_MSG_WARN(Unexpected manpage-format $cf_unknown)
 fi
+
+cf_manpage_format=no
+cf_manpage_inboth=no
+cf_manpage_so_strip=
+cf_manpage_compress=
+cf_manpage_coptions=
+
+for cf_item in $MANPAGE_FORMAT
+do
+case "$cf_item" in
+(catonly)
+	cf_manpage_format=yes
+	cf_manpage_inboth=no
+	;;
+(formatted)
+	cf_manpage_format=yes
+	cf_manpage_inboth=yes
+	;;
+(compress)
+	cf_manpage_so_strip="Z"
+	cf_manpage_compress=compress
+	;;
+(gzip)
+	cf_manpage_so_strip="gz"
+	cf_manpage_compress=gzip
+	cf_manpage_coptions=-n
+	;;
+(bzip2)
+	cf_manpage_so_strip="bz2"
+	cf_manpage_compress=bzip2
+	;;
+(xz)
+	cf_manpage_so_strip="xz"
+	cf_manpage_compress=xz
+	;;
+esac
+done
+
+AC_SUBST(cf_manpage_format)
+AC_SUBST(cf_manpage_inboth)
+AC_SUBST(cf_manpage_so_strip)
+AC_SUBST(cf_manpage_compress)
+AC_SUBST(cf_manpage_coptions)
+
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_MANPAGE_RENAMES version: 12 updated: 2021/01/01 16:53:59
+dnl CF_MANPAGE_RENAMES version: 17 updated: 2022/10/23 07:46:29
 dnl ------------------
 dnl The Debian people have their own naming convention for manpages.  This
 dnl option lets us override the name of the file containing renaming, or
@@ -5299,34 +5860,26 @@ case ".$MANPAGE_RENAMES" in
 (.|.yes)
 	# Debian 'man' program?
 	if test -f /etc/debian_version ; then
-		MANPAGE_RENAMES=`cd "$srcdir" && pwd`/man/man_db.renames
+		MANPAGE_RENAMES=man/man_db.renames
 	else
 		MANPAGE_RENAMES=no
 	fi
 	;;
 esac
 
-if test "$MANPAGE_RENAMES" != no ; then
-	if test -f "$srcdir/man/$MANPAGE_RENAMES" ; then
-		MANPAGE_RENAMES=`cd "$srcdir/man" && pwd`/$MANPAGE_RENAMES
-	elif test ! -f "$MANPAGE_RENAMES" ; then
-		AC_MSG_ERROR(not a filename: $MANPAGE_RENAMES)
-	fi
-
-	test ! -d man && mkdir man
-
-	# Construct a sed-script to perform renaming within man-pages
-	if test -n "$MANPAGE_RENAMES" ; then
-		test ! -d man && mkdir man
-		$SHELL "$srcdir/man/make_sed.sh" "$MANPAGE_RENAMES" >./edit_man.sed
-	fi
+if test "$MANPAGE_RENAMES" = man/man_db.renames ; then
+	MANPAGE_RENAMES=`pwd`/$MANPAGE_RENAMES
+elif test "$MANPAGE_RENAMES" = no ; then
+	:
+elif test ! -f "$MANPAGE_RENAMES" ; then
+	AC_MSG_ERROR(not a filename: $MANPAGE_RENAMES)
 fi
 
 AC_MSG_RESULT($MANPAGE_RENAMES)
 AC_SUBST(MANPAGE_RENAMES)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_MANPAGE_SYMLINKS version: 6 updated: 2015/04/17 21:13:04
+dnl CF_MANPAGE_SYMLINKS version: 7 updated: 2023/01/21 16:37:17
 dnl -------------------
 dnl Some people expect each tool to make all aliases for manpages in the
 dnl man-directory.  This accommodates the older, less-capable implementations
@@ -5360,7 +5913,7 @@ AC_ARG_WITH(manpage-symlinks,
 	[MANPAGE_SYMLINKS=$withval],
 	[MANPAGE_SYMLINKS=$cf_use_symlinks])
 
-if test "$$cf_use_symlinks" = no; then
+if test "$cf_use_symlinks" = no; then
 if test "$MANPAGE_SYMLINKS" = yes ; then
 	AC_MSG_WARN(cannot make symlinks, will use .so files)
 	MANPAGE_SYMLINKS=no
@@ -5388,7 +5941,32 @@ AC_ARG_WITH(manpage-tbl,
 AC_MSG_RESULT($MANPAGE_TBL)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_MAN_PAGES version: 51 updated: 2021/01/05 16:29:19
+dnl CF_MB_LEN_MAX version: 1 updated: 2024/03/02 15:45:10
+dnl -------------
+dnl Check if <limits.h> defines a usable MB_LEN_MAX.  That may be because it is
+dnl not defined, or it may be a bogus value.
+AC_DEFUN([CF_MB_LEN_MAX],[
+AC_CACHE_CHECK(if MB_LEN_MAX is usable,cf_cv_mb_len_max,[
+AC_TRY_COMPILE([
+$ac_includes_default
+#include <limits.h>],
+[
+#if defined(MB_LEN_MAX) && MB_LEN_MAX >= 6
+	${cf_cv_main_return:-return}(0);
+#else
+#error MB_LEN_MAX is not usable
+#endif
+],	[cf_cv_mb_len_max=yes],
+	[cf_cv_mb_len_max=no])])
+if test "$cf_cv_mb_len_max" = yes
+then
+	AC_DEFINE(HAVE_CONSISTENT_MB_LEN_MAX,1,[Define to 1 if MB_LEN_MAX is usable])
+else
+	AC_MSG_WARN(MB_LEN_MAX is missing/inconsistent in system headers)
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_MAN_PAGES version: 59 updated: 2024/03/30 08:27:40
 dnl ------------
 dnl Try to determine if the man-pages on the system are compressed, and if
 dnl so, what format is used.  Use this information to construct a script that
@@ -5407,36 +5985,8 @@ else
 	cf_prefix="$prefix"
 fi
 
-case "$MANPAGE_FORMAT" in
-(*catonly*)
-	cf_format=yes
-	cf_inboth=no
-	;;
-(*formatted*)
-	cf_format=yes
-	cf_inboth=yes
-	;;
-(*)
-	cf_format=no
-	cf_inboth=no
-	;;
-esac
-
 test ! -d man && mkdir man
 
-cf_so_strip=
-cf_compress=
-case "$MANPAGE_FORMAT" in
-(*compress*)
-	cf_so_strip="Z"
-	cf_compress=compress
-	;;
-(*gzip*)
-	cf_so_strip="gz"
-	cf_compress=gzip
-	;;
-esac
-
 cf_edit_man=./edit_man.sh
 cf_man_alias=`pwd`/man_alias.sed
 
@@ -5454,6 +6004,7 @@ NCURSES_PATCH="$NCURSES_PATCH"
 
 NCURSES_OSPEED="$NCURSES_OSPEED"
 TERMINFO="$TERMINFO"
+TERMINFO_DIRS="$TERMINFO_DIRS"
 
 INSTALL="$INSTALL"
 INSTALL_DATA="$INSTALL_DATA"
@@ -5461,7 +6012,8 @@ INSTALL_DATA="$INSTALL_DATA"
 transform="$program_transform_name"
 
 TMP=\${TMPDIR:=/tmp}/man\$\$
-trap "rm -f \$TMP" 0 1 2 3 15
+trap "rm -f \$TMP; exit 1" 1 2 3 15
+trap "rm -f \$TMP" 0
 
 form=\[$]1
 shift || exit 1
@@ -5477,8 +6029,8 @@ top_srcdir=\[$]srcdir/..
 shift || exit 1
 
 if test "\$form" = normal ; then
-	if test "$cf_format" = yes ; then
-	if test "$cf_inboth" = no ; then
+	if test "$cf_manpage_format" = yes ; then
+	if test "$cf_manpage_inboth" = no ; then
 		$SHELL "\[$]0" format "\$verb" "\$mandir" "\$srcdir" "\[$]@"
 		exit $?
 	fi
@@ -5530,9 +6082,9 @@ CF_EOF2
 
 	aliases=
 	cf_source=\`basename "\$i"\`
-	inalias=\$cf_source
-	test ! -f "\$inalias" && inalias="\$srcdir/\$inalias"
-	if test ! -f "\$inalias" ; then
+	cf_full_alias=\$cf_source
+	test ! -f "\$cf_full_alias" && cf_full_alias="\$srcdir/\$cf_full_alias"
+	if test ! -f "\$cf_full_alias" ; then
 		echo ".. skipped \$cf_source"
 		continue
 	fi
@@ -5541,8 +6093,9 @@ CF_EOF
 if test "$MANPAGE_ALIASES" != no ; then
 cat >>$cf_edit_man <<CF_EOF
 	nCurses=ignore.3x
+	cf_part_alias=\`echo \$cf_full_alias| sed -e 's,^.*/,,'\`
 	test "$with_curses_h" = yes && nCurses=ncurses.3x
-	aliases=\`sed -f "\$top_srcdir/man/manlinks.sed" "\$inalias" |sed -f "$cf_man_alias" | sort -u; test "\$inalias" = "\$nCurses" && echo curses\`
+	aliases=\`sed -f "\$top_srcdir/man/manlinks.sed" "\$cf_full_alias" |sed -f "$cf_man_alias" | sort -u; test "\$cf_part_alias" = "\$nCurses" && echo curses\`
 CF_EOF
 fi
 
@@ -5571,7 +6124,7 @@ cat >>$cf_edit_man <<CF_EOF
 	sed	-f "$cf_man_alias" \\
 CF_EOF
 
-if test -f "$MANPAGE_RENAMES" ; then
+if test "$MANPAGE_RENAMES" != no ; then
 cat >>$cf_edit_man <<CF_EOF
 		< "\$i" | sed -f `pwd`/edit_man.sed >\$TMP
 CF_EOF
@@ -5609,15 +6162,15 @@ cat >>$cf_edit_man <<CF_EOF
 	fi
 CF_EOF
 
-if test -n "$cf_compress" ; then
+if test -n "$cf_manpage_compress" ; then
 cat >>$cf_edit_man <<CF_EOF
 	if test "\$verb" = installing ; then
-	if ( "$cf_compress" -f \$TMP )
+	if ( "$cf_manpage_compress" -f \$TMP )
 	then
-		mv \$TMP.$cf_so_strip \$TMP
+		mv \$TMP.$cf_manpage_so_strip \$TMP
 	fi
 	fi
-	cf_target="\$cf_target.$cf_so_strip"
+	cf_target="\$cf_target.$cf_manpage_so_strip"
 CF_EOF
 fi
 
@@ -5634,6 +6187,14 @@ esac
 
 cat >>$cf_edit_man <<CF_EOF
 	suffix=\`basename "\$cf_target" | sed -e 's%^[[^.]]*%%'\`
+	extra_suffix=
+	if test -n "$EXTRA_SUFFIX" ; then
+		case \$cf_target in
+		(*${EXTRA_SUFFIX}\$suffix)
+			extra_suffix="$EXTRA_SUFFIX"
+			;;
+		esac
+	fi
 	if test "\$verb" = installing ; then
 		echo "\$verb \$cf_target"
 		\$INSTALL_DATA \$TMP "\$cf_target"
@@ -5641,13 +6202,14 @@ cat >>$cf_edit_man <<CF_EOF
 		test -n "\$aliases" && (
 			cd "\$cf_subdir\${section}" && (
 				cf_source=\`echo "\$cf_target" |sed -e 's%^.*/\\([[^/]][[^/]]*/[[^/]][[^/]]*$\\)%\\1%'\`
-				test -n "$cf_so_strip" && cf_source=\`echo "\$cf_source" |sed -e 's%\\.$cf_so_strip\$%%'\`
+				test -n "$cf_manpage_so_strip" && cf_source=\`echo "\$cf_source" |sed -e 's%\\.$cf_manpage_so_strip\$%%'\`
 				cf_target=\`basename "\$cf_target"\`
 				for cf_alias in \$aliases
 				do
 					if test "\$section" = 1 ; then
 						cf_alias=\`echo "\$cf_alias" |sed "\${transform}"\`
 					fi
+					cf_alias="\${cf_alias}\${extra_suffix}"
 
 					if test "$MANPAGE_SYMLINKS" = yes ; then
 						if test -f "\$cf_alias\${suffix}" ; then
@@ -5675,11 +6237,11 @@ cat >>$cf_edit_man <<CF_EOF
 					elif test "\$cf_target" != "\$cf_alias\${suffix}" ; then
 						echo ".so \$cf_source" >\$TMP
 CF_EOF
-if test -n "$cf_compress" ; then
+if test -n "$cf_manpage_compress" ; then
 cat >>$cf_edit_man <<CF_EOF
-						if test -n "$cf_so_strip" ; then
-							"$cf_compress" -f \$TMP
-							mv \$TMP.$cf_so_strip \$TMP
+						if test -n "$cf_manpage_so_strip" ; then
+							"$cf_manpage_compress" $cf_manpage_coptions -f \$TMP
+							mv \$TMP.$cf_manpage_so_strip \$TMP
 						fi
 CF_EOF
 fi
@@ -5704,6 +6266,7 @@ cat >>$cf_edit_man <<CF_EOF
 					if test "\$section" = 1 ; then
 						cf_alias=\`echo "\$cf_alias" |sed "\${transform}"\`
 					fi
+					cf_alias="\${cf_alias}\${extra_suffix}"
 
 					echo ".. \$verb alias \$cf_alias\${suffix}"
 					rm -f "\$cf_alias\${suffix}"
@@ -5718,7 +6281,7 @@ cat >>$cf_edit_man <<CF_EOF
 esac
 done
 
-if test "$cf_inboth" = yes ; then
+if test "$cf_manpage_inboth" = yes ; then
 if test "\$form" != format ; then
 	$SHELL "\[$]0" format "\$verb" "\$mandir" "\$srcdir" "\[$]@"
 fi
@@ -5741,7 +6304,7 @@ CF_UPPER(cf_map_lib_basename,$2)
 eval $1="\$${cf_map_lib_basename}_NAME"
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_MATH_LIB version: 10 updated: 2020/12/31 18:40:20
+dnl CF_MATH_LIB version: 11 updated: 2022/07/27 19:01:48
 dnl -----------
 dnl Checks for libraries.  At least one UNIX system, Apple Macintosh
 dnl Rhapsody 5.5, does not have -lm.  We cannot use the simpler
@@ -5751,18 +6314,42 @@ AC_DEFUN([CF_MATH_LIB],
 AC_CACHE_CHECK(if -lm needed for math functions,
 	cf_cv_need_libm,[
 	AC_TRY_LINK([
-	#include <stdio.h>
-	#include <stdlib.h>
-	#include <math.h>
+		#include <stdio.h>
+		#include <stdlib.h>
+		#include <math.h>
 	],
 	[double x = rand(); printf("result = %g\\n", ]ifelse([$2],,sin(x),$2)[)],
 	[cf_cv_need_libm=no],
 	[cf_cv_need_libm=yes])])
+
 if test "$cf_cv_need_libm" = yes
 then
-ifelse($1,,[
-	CF_ADD_LIB(m)
-],[$1=-lm])
+
+	cf_save_LIBS="$LIBS"
+	LIBS="$LIBS -lm"
+	AC_CACHE_CHECK(if -lm is available for math functions,
+	cf_cv_have_libm,[
+	AC_TRY_LINK([
+		#include <stdio.h>
+		#include <stdlib.h>
+		#include <math.h>
+	],
+	[double x = rand(); printf("result = %g\\n", ]ifelse([$2],,sin(x),$2)[)],
+	[cf_cv_have_libm=yes],
+	[cf_cv_have_libm=no])])
+	LIBS="$cf_save_LIBS"
+
+	if test "$cf_cv_have_libm" = yes
+	then
+		ifelse($1,,[CF_ADD_LIB(m)],[$1=-lm])
+	fi
+else
+	cf_cv_have_libm=yes
+fi
+
+if test "$cf_cv_have_libm" = yes
+then
+	AC_DEFINE(HAVE_MATH_FUNCS,1,[Define to 1 if math functions are available])
 fi
 ])
 dnl ---------------------------------------------------------------------------
@@ -5796,7 +6383,7 @@ fi
 test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,1,[Define to 1 if filesystem supports mixed-case filenames.])
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_MKSTEMP version: 11 updated: 2021/01/01 13:31:04
+dnl CF_MKSTEMP version: 13 updated: 2023/12/01 17:22:50
 dnl ----------
 dnl Check for a working mkstemp.  This creates two files, checks that they are
 dnl successfully created and distinct (AmigaOS apparently fails on the last).
@@ -5807,17 +6394,11 @@ unistd.h \
 AC_CACHE_CHECK(for working mkstemp, cf_cv_func_mkstemp,[
 rm -rf ./conftest*
 AC_TRY_RUN([
-#include <sys/types.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/stat.h>
+$ac_includes_default
+
 int main(void)
 {
-	char *tmpl = "conftestXXXXXX";
+	static char tmpl[] = "conftestXXXXXX";
 	char name[2][80];
 	int n;
 	int result = 0;
@@ -5862,7 +6443,7 @@ AC_DEFUN([CF_MSG_LOG],[
 echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_NCURSES_ABI_6 version: 4 updated: 2021/01/01 13:31:04
+dnl CF_NCURSES_ABI_6 version: 5 updated: 2023/01/07 16:32:06
 dnl ----------------
 dnl Set ncurses' ABI to 6 unless overridden by explicit configure option, and
 dnl warn about this.
@@ -5872,7 +6453,8 @@ if test "${with_abi_version+set}" != set; then
 	(5.*)
 		cf_cv_rel_version=6.0
 		cf_cv_abi_version=6
-		AC_MSG_WARN(overriding ABI version to $cf_cv_abi_version)
+		cf_cv_abi_default=6
+		AC_MSG_WARN(overriding ABI version to $cf_cv_abi_default)
 		;;
 	esac
 fi
@@ -5898,19 +6480,29 @@ then
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_NO_LEAKS_OPTION version: 8 updated: 2021/01/05 20:05:09
+dnl CF_NO_LEAKS_OPTION version: 9 updated: 2021/06/13 19:45:41
 dnl ------------------
 dnl see CF_WITH_NO_LEAKS
+dnl
+dnl $1 = option/name
+dnl $2 = help-text
+dnl $3 = symbol to define if the option is set
+dnl $4 = additional actions to take if the option is set
 AC_DEFUN([CF_NO_LEAKS_OPTION],[
 AC_MSG_CHECKING(if you want to use $1 for testing)
 AC_ARG_WITH($1,
 	[$2],
-	[AC_DEFINE_UNQUOTED($3,1,"Define to 1 if you want to use $1 for testing.")ifelse([$4],,[
+	[case "x$withval" in
+	(x|xno) ;;
+	(*)
+		: "${with_cflags:=-g}"
+		: "${enable_leaks:=no}"
+		with_$1=yes
+		AC_DEFINE_UNQUOTED($3,1,"Define to 1 if you want to use $1 for testing.")ifelse([$4],,[
 	 $4
 ])
-	: "${with_cflags:=-g}"
-	: "${enable_leaks:=no}"
-	 with_$1=yes],
+		;;
+	esac],
 	[with_$1=])
 AC_MSG_RESULT(${with_$1:-no})
 
@@ -5927,15 +6519,15 @@ case ".$with_cflags" in
 esac
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_NUMBER_SYNTAX version: 2 updated: 2015/04/17 21:13:04
+dnl CF_NUMBER_SYNTAX version: 3 updated: 2023/05/06 16:14:29
 dnl ----------------
-dnl Check if the given variable is a number.  If not, report an error.
+dnl Check if the given variable is a positive integer.  Report an error if not.
 dnl $1 is the variable
 dnl $2 is the message
 AC_DEFUN([CF_NUMBER_SYNTAX],[
 if test -n "$1" ; then
-  case $1 in
-  ([[0-9]]*)
+  case `echo "$1" | sed -e 's/^[[0-9]]*$/0/g'` in
+  (0)
  	;;
   (*)
 	AC_MSG_ERROR($2 is not a number: $1)
@@ -5966,6 +6558,21 @@ AC_DEFUN([CF_OBJ_SUBDIR],
 	esac
 ])dnl
 dnl ---------------------------------------------------------------------------
+dnl CF_OUTPUT_MANPAGE_RENAMES version: 2 updated: 2022/10/22 19:12:31
+dnl -------------------------
+dnl This runs in the output step to config.status, after man_db.renames has
+dnl been generated.
+AC_DEFUN([CF_OUTPUT_MANPAGE_RENAMES],
+[
+AC_REQUIRE([CF_MANPAGE_RENAMES])
+if test "$MANPAGE_RENAMES" != no ; then
+	# Construct a sed-script to perform renaming within man-pages
+	test -n "$verbose" && echo "creating edit_man.sed"
+	test ! -d man && mkdir man
+	FGREP="${FGREP-grep -F}" $SHELL "$srcdir/man/make_sed.sh" "$MANPAGE_RENAMES" >./edit_man.sed
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
 dnl CF_PATHSEP version: 8 updated: 2021/01/01 13:31:04
 dnl ----------
 dnl Provide a value for the $PATH and similar separator (or amend the value
@@ -6064,14 +6671,16 @@ case ".[$]$1" in
 esac
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_PKG_CONFIG version: 11 updated: 2021/01/01 13:31:04
+dnl CF_PKG_CONFIG version: 13 updated: 2023/10/28 11:59:01
 dnl -------------
 dnl Check for the package-config program, unless disabled by command-line.
+dnl
+dnl Sets $PKG_CONFIG to the pathname of the pkg-config program.
 AC_DEFUN([CF_PKG_CONFIG],
 [
 AC_MSG_CHECKING(if you want to use pkg-config)
 AC_ARG_WITH(pkg-config,
-	[  --with-pkg-config{=path} enable/disable use of pkg-config],
+	[[  --with-pkg-config[=CMD] enable/disable use of pkg-config and its name CMD]],
 	[cf_pkg_config=$withval],
 	[cf_pkg_config=yes])
 AC_MSG_RESULT($cf_pkg_config)
@@ -6100,7 +6709,7 @@ fi
 AC_SUBST(PKG_CONFIG)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_POSIX_C_SOURCE version: 11 updated: 2018/12/31 20:46:17
+dnl CF_POSIX_C_SOURCE version: 12 updated: 2023/02/18 17:41:25
 dnl -----------------
 dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
 dnl
@@ -6131,7 +6740,7 @@ AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
 	CF_MSG_LOG(if the symbol is already defined go no further)
 	AC_TRY_COMPILE([#include <sys/types.h>],[
 #ifndef _POSIX_C_SOURCE
-make an error
+#error _POSIX_C_SOURCE is not defined
 #endif],
 	[cf_cv_posix_c_source=no],
 	[cf_want_posix_source=no
@@ -6150,7 +6759,7 @@ make an error
 	 if test "$cf_want_posix_source" = yes ; then
 		AC_TRY_COMPILE([#include <sys/types.h>],[
 #ifdef _POSIX_SOURCE
-make an error
+#error _POSIX_SOURCE is defined
 #endif],[],
 		cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
 	 fi
@@ -6161,7 +6770,7 @@ make an error
 	 CF_MSG_LOG(if the second compile does not leave our definition intact error)
 	 AC_TRY_COMPILE([#include <sys/types.h>],[
 #ifndef _POSIX_C_SOURCE
-make an error
+#error _POSIX_C_SOURCE is not defined
 #endif],,
 	 [cf_cv_posix_c_source=no])
 	 CFLAGS="$cf_save_CFLAGS"
@@ -6206,7 +6815,7 @@ AC_TRY_COMPILE([#include <stdio.h>],[
 ])
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_PREDEFINE version: 2 updated: 2010/05/26 16:44:57
+dnl CF_PREDEFINE version: 3 updated: 2023/02/18 17:41:25
 dnl ------------
 dnl Add definitions to CPPFLAGS to ensure they're predefined for all compiles.
 dnl
@@ -6218,7 +6827,7 @@ AC_MSG_CHECKING(if we must define $1)
 AC_TRY_COMPILE([#include <sys/types.h>
 ],[
 #ifndef $1
-make an error
+#error $1 is not defined
 #endif],[cf_result=no],[cf_result=yes])
 AC_MSG_RESULT($cf_result)
 
@@ -6229,7 +6838,7 @@ elif test "x$2" != "x" ; then
 	AC_TRY_COMPILE([#include <sys/types.h>
 ],[
 #if $1-$2 < 0
-make an error
+#error $1-$2 is negative
 #endif],[cf_result=yes],[cf_result=no])
 	AC_MSG_RESULT($cf_result)
 	if test "$cf_result" = no ; then
@@ -6480,7 +7089,7 @@ fi
 AC_SUBST(LDCONFIG)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_PROG_LINT version: 4 updated: 2019/11/20 18:55:37
+dnl CF_PROG_LINT version: 5 updated: 2022/08/20 15:44:13
 dnl ------------
 AC_DEFUN([CF_PROG_LINT],
 [
@@ -6491,6 +7100,7 @@ case "x$LINT" in
 	;;
 esac
 AC_SUBST(LINT_OPTS)
+AC_SUBST(LINT_LIBS)
 ])dnl
 dnl ---------------------------------------------------------------------------
 dnl CF_PROG_LN_S version: 2 updated: 2010/08/14 18:25:37
@@ -6611,6 +7221,24 @@ case "$cf_cv_regex_hdrs" in
 esac
 ])dnl
 dnl ---------------------------------------------------------------------------
+dnl CF_REMOVE_CFLAGS version: 3 updated: 2021/09/05 17:25:40
+dnl ----------------
+dnl Remove a given option from CFLAGS/CPPFLAGS
+dnl $1 = option to remove
+dnl $2 = variable to update
+dnl $3 = nonempty to allow verbose message
+define([CF_REMOVE_CFLAGS],
+[
+cf_tmp_cflag=`echo "x$1" | sed -e 's/^.//' -e 's/=.*//'`
+while true
+do
+	cf_old_cflag=`echo "x[$]$2" | sed -e 's/^.//' -e 's/[[ 	]][[ 	]]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[[^ 	]][[^ 	]]*\\)\?%%" -e 's/^[[ 	]]*//' -e 's%[[ ]][[ ]]*-D% -D%g' -e 's%[[ ]][[ ]]*-I% -I%g'`
+	test "[$]$2" != "$cf_old_cflag" || break
+	ifelse([$3],,,[CF_VERBOSE(removing old option $1 from $2)])
+	$2="$cf_old_cflag"
+done
+])dnl
+dnl ---------------------------------------------------------------------------
 dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
 dnl ----------------
 dnl Remove all -U and -D options that refer to the given symbol from a list
@@ -6795,7 +7423,7 @@ do
 done
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_SHARED_OPTS version: 105 updated: 2021/01/02 17:09:14
+dnl CF_SHARED_OPTS version: 111 updated: 2024/03/29 20:08:49
 dnl --------------
 dnl --------------
 dnl Attempt to determine the appropriate CC/LD options for creating a shared
@@ -6819,7 +7447,7 @@ dnl The variable 'cf_cv_shlib_version_infix' controls whether shared library
 dnl version numbers are infix (ex: libncurses.<ver>.dylib) or postfix
 dnl (ex: libncurses.so.<ver>).
 dnl
-dnl Some loaders leave 'so_locations' lying around.  It's nice to clean up.
+dnl Some loaders leave 'so_locations' lying around.  It is nice to clean up.
 AC_DEFUN([CF_SHARED_OPTS],
 [
 	AC_REQUIRE([CF_LD_RPATH_OPT])
@@ -6841,9 +7469,9 @@ AC_DEFUN([CF_SHARED_OPTS],
 	cf_ld_rpath_opt=
 	test "$cf_cv_enable_rpath" = yes && cf_ld_rpath_opt="$LD_RPATH_OPT"
 
-	AC_MSG_CHECKING(if release/abi version should be used for shared libs)
+	AC_MSG_CHECKING(whether to use release or ABI version in shared library file names)
 	AC_ARG_WITH(shlib-version,
-	[  --with-shlib-version=X  Specify rel or abi version for shared libs],
+	[[  --with-shlib-version[={rel|abi}] use release or ABI version in shared library file names]],
 	[test -z "$withval" && withval=auto
 	case "$withval" in
 	(yes)
@@ -6885,7 +7513,7 @@ AC_DEFUN([CF_SHARED_OPTS],
 		for CC_SHARED_OPTS in -fPIC -fpic ''
 		do
 			CFLAGS="$cf_save_CFLAGS $CC_SHARED_OPTS"
-			AC_TRY_COMPILE([#include <stdio.h>],[int x = 1],[break],[])
+			AC_TRY_COMPILE([#include <stdio.h>],[int x = 1; (void)x],[break],[])
 		done
 		AC_MSG_RESULT($CC_SHARED_OPTS)
 		CFLAGS="$cf_save_CFLAGS"
@@ -6966,6 +7594,10 @@ CF_EOF
 			LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
 		fi
 		;;
+	(haiku*)
+		CF_SHARED_SONAME
+		MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]'
+		;;
 	(hpux[[7-8]]*)
 		# HP-UX 8.07 ld lacks "+b" option used for libdir search-list
 		if test "$GCC" != yes; then
@@ -7251,11 +7883,11 @@ CF_EOF
 		# tested with SunOS 5.5.1 (solaris 2.5.1) and gcc 2.7.2
 		# tested with SunOS 5.10 (solaris 10) and gcc 3.4.3
 		if test "$DFT_LWR_MODEL" = "shared" ; then
-			LOCAL_LDFLAGS="-R \$(LOCAL_LIBDIR):\${libdir}"
+			LOCAL_LDFLAGS="-R\$(LOCAL_LIBDIR):\${libdir}"
 			LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
 		fi
 		if test "$cf_cv_enable_rpath" = yes ; then
-			EXTRA_LDFLAGS="-R \${libdir} $EXTRA_LDFLAGS"
+			EXTRA_LDFLAGS="-R\${libdir} $EXTRA_LDFLAGS"
 		fi
 		CF_SHARED_SONAME
 		if test "$GCC" != yes; then
@@ -7267,9 +7899,9 @@ CF_EOF
 			done
 			CFLAGS="$cf_save_CFLAGS"
 			CC_SHARED_OPTS=$cf_shared_opts
-			MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -dy -G -h '$cf_cv_shared_soname' -o $[@]'
+			MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -dy -G -Wl,-h,'$cf_cv_shared_soname' -o $[@]'
 		else
-			MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -dy -G -h '$cf_cv_shared_soname' -o $[@]'
+			MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -dy -G -Wl,-h,'$cf_cv_shared_soname' -o $[@]'
 		fi
 		;;
 	(sysv5uw7*|unix_sv*)
@@ -7370,7 +8002,7 @@ define([CF_SHARED_SONAME],
 	fi
 ])
 dnl ---------------------------------------------------------------------------
-dnl CF_SIGWINCH version: 6 updated: 2021/01/01 13:31:04
+dnl CF_SIGWINCH version: 7 updated: 2023/02/18 17:41:25
 dnl -----------
 dnl Use this macro after CF_XOPEN_SOURCE, but do not require it (not all
 dnl programs need this test).
@@ -7413,7 +8045,7 @@ do
 #include <sys/signal.h>
 ],[
 #if SIGWINCH != $cf_sigwinch
-make an error
+#error SIGWINCH is not $cf_sigwinch
 #endif
 int x = SIGWINCH; (void)x],
 	[cf_cv_fixup_sigwinch=$cf_sigwinch
@@ -7465,7 +8097,7 @@ AC_MSG_RESULT($cf_cv_sig_atomic_t)
 test "$cf_cv_sig_atomic_t" != no && AC_DEFINE_UNQUOTED(SIG_ATOMIC_T, $cf_cv_sig_atomic_t,[Define to signal global datatype])
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_SIZECHANGE version: 17 updated: 2021/01/01 13:31:04
+dnl CF_SIZECHANGE version: 18 updated: 2021/09/04 06:35:04
 dnl -------------
 dnl Check for definitions & structures needed for window size-changing
 dnl
@@ -7496,7 +8128,7 @@ do
 
 #ifdef NEED_PTEM_H
 /* This is a workaround for SCO:  they neglected to define struct winsize in
- * termios.h -- it's only in termio.h and ptem.h
+ * termios.h -- it is only in termio.h and ptem.h
  */
 #include <sys/stream.h>
 #include <sys/ptem.h>
@@ -7545,7 +8177,7 @@ if test "$cf_cv_sizechange" != no ; then
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_SRC_MODULES version: 33 updated: 2021/01/01 13:31:04
+dnl CF_SRC_MODULES version: 34 updated: 2023/04/22 11:51:06
 dnl --------------
 dnl For each parameter, test if the source-directory exists, and if it contains
 dnl a 'modules' file.  If so, add to the list $cf_cv_src_modules which we'll
@@ -7575,14 +8207,6 @@ for cf_dir in $1
 do
 	if test -f "$srcdir/$cf_dir/modules" ; then
 
-		# We may/may not have tack in the distribution, though the
-		# makefile is.
-		if test "$cf_dir" = tack ; then
-			if test "x$cf_with_tack" != "xyes"; then
-				continue
-			fi
-		fi
-
 		if test -z "$cf_cv_src_modules"; then
 			cf_cv_src_modules=$cf_dir
 		else
@@ -7593,9 +8217,7 @@ do
 		# well.  These are header files that are the same name as their
 		# directory.  Ncurses is the only library that does not follow
 		# that pattern.
-		if test "$cf_dir" = tack ; then
-			continue
-		elif test -f "$srcdir/${cf_dir}/${cf_dir}.h" ; then
+		if test -f "$srcdir/${cf_dir}/${cf_dir}.h" ; then
 			CF_UPPER(cf_have_include,$cf_dir)
 			AC_DEFINE_UNQUOTED(HAVE_${cf_have_include}_H)
 			AC_DEFINE_UNQUOTED(HAVE_LIB${cf_have_include})
@@ -7730,7 +8352,7 @@ dnl	Remove "-g" option from the compiler options
 AC_DEFUN([CF_STRIP_G_OPT],
 [$1=`echo "${$1}" | CF__SED_TRIMBLANKS(-e 's%-g %%' -e 's%-g$%%')`])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_STRUCT_SIGACTION version: 5 updated: 2012/10/06 17:56:13
+dnl CF_STRUCT_SIGACTION version: 6 updated: 2023/12/03 09:21:34
 dnl -------------------
 dnl Check if we need _POSIX_SOURCE defined to use struct sigaction.  We'll only
 dnl do this if we've found the sigaction function.
@@ -7742,14 +8364,14 @@ AC_MSG_CHECKING(whether sigaction needs _POSIX_SOURCE)
 AC_TRY_COMPILE([
 #include <sys/types.h>
 #include <signal.h>],
-	[struct sigaction act],
+	[struct sigaction act; (void)act],
 	[sigact_bad=no],
 	[
 AC_TRY_COMPILE([
 #define _POSIX_SOURCE
 #include <sys/types.h>
 #include <signal.h>],
-	[struct sigaction act],
+	[struct sigaction act; (void)act],
 	[sigact_bad=yes
 	 AC_DEFINE(_POSIX_SOURCE,1,[Define to 1 if we must define _POSIX_SOURCE])],
 	 [sigact_bad=unknown])])
@@ -7757,7 +8379,7 @@ AC_MSG_RESULT($sigact_bad)
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_STRUCT_TERMIOS version: 11 updated: 2020/03/19 20:46:13
+dnl CF_STRUCT_TERMIOS version: 13 updated: 2023/12/03 19:38:54
 dnl -----------------
 dnl Some machines require _POSIX_SOURCE to completely define struct termios.
 AC_DEFUN([CF_STRUCT_TERMIOS],[
@@ -7780,12 +8402,12 @@ if test "$ac_cv_header_termios_h" = yes ; then
 	if test "$termios_bad" = maybe ; then
 	AC_MSG_CHECKING(whether termios.h needs _POSIX_SOURCE)
 	AC_TRY_COMPILE([#include <termios.h>],
-		[struct termios foo; int x = foo.c_iflag = 1; (void)x],
+		[struct termios foo; int x = (int)(foo.c_iflag = 1); (void)x],
 		termios_bad=no, [
 		AC_TRY_COMPILE([
 #define _POSIX_SOURCE
 #include <termios.h>],
-			[struct termios foo; int x = foo.c_iflag = 2; (void)x],
+			[struct termios foo; int x = (int)(foo.c_iflag = 2); (void)x],
 			termios_bad=unknown,
 			termios_bad=yes AC_DEFINE(_POSIX_SOURCE,1,[Define to 1 if we must define _POSIX_SOURCE]))
 			])
@@ -7837,7 +8459,7 @@ fi
 AC_SUBST($2)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_SUBST_NCURSES_VERSION version: 10 updated: 2021/01/04 18:48:01
+dnl CF_SUBST_NCURSES_VERSION version: 11 updated: 2023/01/07 16:32:06
 dnl ------------------------
 dnl Get the version-number for use in shared-library naming, etc.
 AC_DEFUN([CF_SUBST_NCURSES_VERSION],
@@ -7847,10 +8469,11 @@ NCURSES_MAJOR="`${EGREP-egrep} '^NCURSES_MAJOR[[ 	]]*=' "$srcdir/dist.mk" | sed
 NCURSES_MINOR="`${EGREP-egrep} '^NCURSES_MINOR[[ 	]]*=' "$srcdir/dist.mk" | sed -e 's/^[[^0-9]]*//'`"
 NCURSES_PATCH="`${EGREP-egrep} '^NCURSES_PATCH[[ 	]]*=' "$srcdir/dist.mk" | sed -e 's/^[[^0-9]]*//'`"
 cf_cv_abi_version=${NCURSES_MAJOR}
+cf_cv_abi_default=${NCURSES_MAJOR}
 cf_cv_rel_version=${NCURSES_MAJOR}.${NCURSES_MINOR}
 dnl Show the computed version, for logging
 cf_cv_timestamp=`date`
-AC_MSG_RESULT(Configuring NCURSES $cf_cv_rel_version ABI $cf_cv_abi_version ($cf_cv_timestamp))
+AC_MSG_RESULT(Configuring NCURSES $cf_cv_rel_version ABI $cf_cv_abi_default ($cf_cv_timestamp))
 dnl We need these values in the generated headers
 AC_SUBST(NCURSES_MAJOR)
 AC_SUBST(NCURSES_MINOR)
@@ -7858,6 +8481,7 @@ AC_SUBST(NCURSES_PATCH)
 dnl We need these values in the generated makefiles
 AC_SUBST(cf_cv_rel_version)
 AC_SUBST(cf_cv_abi_version)
+AC_SUBST(cf_cv_abi_default)
 AC_SUBST(cf_cv_builtin_bool)
 AC_SUBST(cf_cv_header_stdbool_h)
 AC_SUBST(cf_cv_type_of_bool)dnl
@@ -7922,34 +8546,20 @@ else
 fi
 ])
 dnl ---------------------------------------------------------------------------
-dnl CF_TRY_XOPEN_SOURCE version: 2 updated: 2018/06/20 20:23:13
+dnl CF_TRY_XOPEN_SOURCE version: 4 updated: 2022/09/10 15:16:16
 dnl -------------------
 dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
 dnl can define it successfully.
 AC_DEFUN([CF_TRY_XOPEN_SOURCE],[
 AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
-	AC_TRY_COMPILE([
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-],[
-#ifndef _XOPEN_SOURCE
-make an error
-#endif],
+	AC_TRY_COMPILE(CF__XOPEN_SOURCE_HEAD,CF__XOPEN_SOURCE_BODY,
 	[cf_cv_xopen_source=no],
 	[cf_save="$CPPFLAGS"
 	 CF_APPEND_TEXT(CPPFLAGS,-D_XOPEN_SOURCE=$cf_XOPEN_SOURCE)
-	 AC_TRY_COMPILE([
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-],[
-#ifdef _XOPEN_SOURCE
-make an error
-#endif],
-	[cf_cv_xopen_source=no],
-	[cf_cv_xopen_source=$cf_XOPEN_SOURCE])
-	CPPFLAGS="$cf_save"
+	 AC_TRY_COMPILE(CF__XOPEN_SOURCE_HEAD,CF__XOPEN_SOURCE_BODY,
+		[cf_cv_xopen_source=no],
+		[cf_cv_xopen_source=$cf_XOPEN_SOURCE])
+		CPPFLAGS="$cf_save"
 	])
 ])
 
@@ -7957,11 +8567,11 @@ if test "$cf_cv_xopen_source" != no ; then
 	CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
 	CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
 	cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
-	CF_ADD_CFLAGS($cf_temp_xopen_source)
+	CF_APPEND_CFLAGS($cf_temp_xopen_source)
 fi
 ])
 dnl ---------------------------------------------------------------------------
-dnl CF_TYPEOF_CHTYPE version: 10 updated: 2017/01/21 11:06:25
+dnl CF_TYPEOF_CHTYPE version: 11 updated: 2023/01/05 17:57:59
 dnl ----------------
 dnl Determine the type we should use for chtype (and attr_t, which is treated
 dnl as the same thing).  We want around 32 bits, so on most machines want a
@@ -7972,8 +8582,8 @@ AC_DEFUN([CF_TYPEOF_CHTYPE],
 AC_MSG_CHECKING([for type of chtype])
 AC_CACHE_VAL(cf_cv_typeof_chtype,[
 		AC_TRY_RUN([
+$ac_includes_default
 #define WANT_BITS 31
-#include <stdio.h>
 int main(void)
 {
 	FILE *fp = fopen("cf_test.out", "w");
@@ -8013,7 +8623,7 @@ AC_SUBST(cf_cv_typeof_chtype)
 AC_DEFINE_UNQUOTED(TYPEOF_CHTYPE,$cf_cv_typeof_chtype,[Define to actual type if needed for chtype])
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_TYPE_SIGACTION version: 4 updated: 2012/10/06 17:56:13
+dnl CF_TYPE_SIGACTION version: 5 updated: 2023/12/03 09:21:34
 dnl -----------------
 dnl
 AC_DEFUN([CF_TYPE_SIGACTION],
@@ -8022,14 +8632,14 @@ AC_MSG_CHECKING([for type sigaction_t])
 AC_CACHE_VAL(cf_cv_type_sigaction,[
 	AC_TRY_COMPILE([
 #include <signal.h>],
-		[sigaction_t x],
+		[sigaction_t x; (void)x],
 		[cf_cv_type_sigaction=yes],
 		[cf_cv_type_sigaction=no])])
 AC_MSG_RESULT($cf_cv_type_sigaction)
 test "$cf_cv_type_sigaction" = yes && AC_DEFINE(HAVE_TYPE_SIGACTION,1,[Define to 1 if we have the sigaction_t type])
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_UNSIGNED_LITERALS version: 2 updated: 1998/02/07 22:10:16
+dnl CF_UNSIGNED_LITERALS version: 3 updated: 2023/12/03 10:02:17
 dnl --------------------
 dnl Test if the compiler supports 'U' and 'L' suffixes.  Only old compilers
 dnl won't, but they're still there.
@@ -8037,7 +8647,7 @@ AC_DEFUN([CF_UNSIGNED_LITERALS],
 [
 AC_MSG_CHECKING([if unsigned literals are legal])
 AC_CACHE_VAL(cf_cv_unsigned_literals,[
-	AC_TRY_COMPILE([],[long x = 1L + 1UL + 1U + 1],
+	AC_TRY_COMPILE([],[long x = 1L + 1UL + 1U + 1; (void)x],
 		[cf_cv_unsigned_literals=yes],
 		[cf_cv_unsigned_literals=no])
 	])
@@ -8053,15 +8663,20 @@ AC_DEFUN([CF_UPPER],
 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_UTF8_LIB version: 8 updated: 2012/10/06 08:57:51
+dnl CF_UTF8_LIB version: 10 updated: 2023/01/11 04:05:23
 dnl -----------
 dnl Check for multibyte support, and if not found, utf8 compatibility library
 AC_DEFUN([CF_UTF8_LIB],
 [
+AC_HAVE_HEADERS(wchar.h)
 AC_CACHE_CHECK(for multibyte character support,cf_cv_utf8_lib,[
 	cf_save_LIBS="$LIBS"
 	AC_TRY_LINK([
-#include <stdlib.h>],[putwc(0,0);],
+$ac_includes_default
+#ifdef HAVE_WCHAR_H
+#include <wchar.h>
+#endif
+],[putwc(0,0);],
 	[cf_cv_utf8_lib=yes],
 	[CF_FIND_LINKAGE([
 #include <libutf8.h>],[putwc(0,0);],utf8,
@@ -8260,7 +8875,7 @@ ifelse($1,,,[
 ])
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_WCHAR_TYPE version: 4 updated: 2012/10/06 16:39:58
+dnl CF_WCHAR_TYPE version: 5 updated: 2023/12/03 09:21:34
 dnl -------------
 dnl Check if type wide-character type $1 is declared, and if so, which header
 dnl file is needed.  The second parameter is used to set a shell variable when
@@ -8277,7 +8892,7 @@ AC_TRY_COMPILE([
 #ifdef HAVE_LIBUTF8_H
 #include <libutf8.h>
 #endif],
-	[$1 state],
+	[$1 state; (void)state],
 	[cf_cv_$1=no],
 	[AC_TRY_COMPILE([
 #include <stdlib.h>
@@ -8287,7 +8902,7 @@ AC_TRY_COMPILE([
 #ifdef HAVE_LIBUTF8_H
 #include <libutf8.h>
 #endif],
-	[$1 value],
+	[$1 value; (void) value],
 	[cf_cv_$1=yes],
 	[cf_cv_$1=unknown])])])
 
@@ -8336,7 +8951,25 @@ weak_symbol(fopen);
 ])
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_WITH_ABI_VERSION version: 4 updated: 2021/01/01 13:31:04
+dnl CF_WITH_ABI_ALTERED version: 1 updated: 2023/01/07 16:32:06
+dnl -------------------
+dnl Provide a way to override the displayed ABI version, e.g., in filenames.
+dnl Check this option after using the ABI version in configuration decisions.
+AC_DEFUN([CF_WITH_ABI_ALTERED],[
+AC_REQUIRE([CF_WITH_ABI_VERSION])
+AC_REQUIRE([CF_ABI_DEFAULTS])
+AC_ARG_WITH(abi-altered,
+[  --with-abi-altered=XXX  override visible ABI version, for packaging],[
+	CF_NUMBER_SYNTAX($withval,ABI altered)
+	if test "$cf_cv_abi_version" != "$withval"
+	then
+		AC_MSG_WARN(altering visible ABI from $cf_cv_abi_version to $withval)
+		cf_cv_abi_version=$withval
+	fi
+])dnl
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_WITH_ABI_VERSION version: 5 updated: 2023/01/07 16:32:06
 dnl -------------------
 dnl Allow library's ABI to be overridden.  Generally this happens when a
 dnl packager has incremented the ABI past that used in the original package,
@@ -8365,28 +8998,29 @@ AC_ARG_WITH(abi-version,
 ifelse($1,,,[
 $1_ABI=$cf_cv_abi_version
 ])
+cf_cv_abi_default=$cf_cv_abi_version
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_WITH_ADA_COMPILER version: 2 updated: 2010/06/26 17:35:58
+dnl CF_WITH_ADA_COMPILER version: 3 updated: 2023/10/28 11:59:01
 dnl --------------------
 dnl Command-line option to specify the Ada95 compiler.
 AC_DEFUN([CF_WITH_ADA_COMPILER],[
-AC_MSG_CHECKING(for ada-compiler)
+AC_MSG_CHECKING(for Ada95 compiler)
 AC_ARG_WITH(ada-compiler,
-	[  --with-ada-compiler=CMD specify Ada95 compiler command (default gnatmake)],
+	[[  --with-ada-compiler[=CMD] use CMD as Ada95 compiler (default: gnatmake)]],
 	[cf_ada_compiler=$withval],
 	[cf_ada_compiler=gnatmake])
 AC_SUBST(cf_ada_compiler)
 AC_MSG_RESULT($cf_ada_compiler)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_WITH_ADA_INCLUDE version: 2 updated: 2010/06/26 17:35:58
+dnl CF_WITH_ADA_INCLUDE version: 3 updated: 2023/10/28 11:59:01
 dnl -------------------
 dnl Command-line option to specify where Ada includes will install.
 AC_DEFUN([CF_WITH_ADA_INCLUDE],[
-AC_MSG_CHECKING(for ada-include)
+AC_MSG_CHECKING(for Ada95 include directory)
 CF_WITH_PATH(ada-include,
-   [  --with-ada-include=DIR  Ada includes are in DIR],
+   [  --with-ada-include=DIR  find Ada95 includes in DIR],
    ADA_INCLUDE,
    PREFIX/share/ada/adainclude,
    [$]prefix/share/ada/adainclude)
@@ -8394,16 +9028,16 @@ AC_SUBST(ADA_INCLUDE)
 AC_MSG_RESULT($ADA_INCLUDE)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_WITH_ADA_LIBNAME version: 1 updated: 2019/09/07 18:59:41
+dnl CF_WITH_ADA_LIBNAME version: 3 updated: 2023/11/22 20:48:30
 dnl -------------------
 dnl CF_WITH_ADA_LIBNAME
 dnl -------------------
 dnl Command-line option to specify how to name the resulting Ada library.
 dnl $1 = default value
 AC_DEFUN([CF_WITH_ADA_LIBNAME],[
-AC_MSG_CHECKING(for ada-libname)
+AC_MSG_CHECKING(for Ada95 curses library name)
 AC_ARG_WITH(ada-libname,
-   [  --with-ada-libname=XXX  override default Ada library-name],
+   [[  --with-ada-libname[=XXX]  use XXX as Ada95 library name]],
    ADA_LIBNAME=[$]withval,
    ADA_LIBNAME=$1)
 case "x$ADA_LIBNAME" in
@@ -8415,13 +9049,13 @@ AC_SUBST(ADA_LIBNAME)
 AC_MSG_RESULT($ADA_LIBNAME)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_WITH_ADA_OBJECTS version: 2 updated: 2010/06/26 17:35:58
+dnl CF_WITH_ADA_OBJECTS version: 3 updated: 2023/10/28 11:59:01
 dnl -------------------
 dnl Command-line option to specify where Ada objects will install.
 AC_DEFUN([CF_WITH_ADA_OBJECTS],[
-AC_MSG_CHECKING(for ada-objects)
+AC_MSG_CHECKING(for Ada95 object directory)
 CF_WITH_PATH(ada-objects,
-   [  --with-ada-objects=DIR  Ada objects are in DIR],
+   [  --with-ada-objects=DIR  find Ada95 objects in DIR],
    ADA_OBJECTS,
    PREFIX/lib/ada/adalib,
    [$]prefix/lib/ada/adalib)
@@ -8429,28 +9063,34 @@ AC_SUBST(ADA_OBJECTS)
 AC_MSG_RESULT($ADA_OBJECTS)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_WITH_ADA_SHAREDLIB version: 5 updated: 2018/07/21 19:10:35
+dnl CF_WITH_ADA_SHAREDLIB version: 6 updated: 2023/10/28 11:59:01
 dnl ---------------------
-dnl Command-line option to specify if an Ada95 shared-library should be built,
+dnl Command-line option to specify if an Ada95 shared library should be built,
 dnl and optionally what its soname should be.
 AC_DEFUN([CF_WITH_ADA_SHAREDLIB],[
 AC_REQUIRE([CF_GNAT_PROJECTS])
-AC_MSG_CHECKING(if an Ada95 shared-library should be built)
+AC_MSG_CHECKING(whether to build an Ada95 shared library)
 AC_ARG_WITH(ada-sharedlib,
-	[  --with-ada-sharedlib=soname build shared-library (requires GNAT projects)],
+	[  --with-ada-sharedlib    build Ada95 shared library; requires GNAT project support],
 	[with_ada_sharedlib=$withval],
 	[with_ada_sharedlib=no])
-AC_MSG_RESULT($with_ada_sharedlib)
+cf_ada_sharedlib_warn=no
 
 if test "x$with_ada_sharedlib" != xno
 then
 	if test "x$cf_gnat_projects" != xyes
 	then
-		AC_MSG_WARN(disabling shared-library since GNAT projects are not supported)
 		with_ada_sharedlib=no
+		cf_ada_sharedlib_warn=yes
 	fi
 fi
 
+AC_MSG_RESULT($with_ada_sharedlib)
+if test "x$cf_ada_sharedlib_warn" != xno
+then
+	AC_MSG_WARN(disabling Ada95 shared library since GNAT projects are not supported)
+fi
+
 ADA_SHAREDLIB='lib$(LIB_NAME).so.1'
 MAKE_ADA_SHAREDLIB="#"
 
@@ -8497,7 +9137,7 @@ if test "$with_dmalloc" = yes ; then
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_WITH_EXPORT_SYMS version: 3 updated: 2014/12/20 19:16:08
+dnl CF_WITH_EXPORT_SYMS version: 5 updated: 2023/11/22 20:48:30
 dnl -------------------
 dnl Use this with libtool to specify the list of symbols that may be exported.
 dnl The input file contains one symbol per line; comments work with "#".
@@ -8507,7 +9147,7 @@ AC_DEFUN([CF_WITH_EXPORT_SYMS],
 [
 AC_MSG_CHECKING(if exported-symbols file should be used)
 AC_ARG_WITH(export-syms,
-	[  --with-export-syms=XXX  limit exported symbols using libtool],
+	[[  --with-export-syms[=SYM-FILE] limit symbols exported by libtool to those listed in SYM-FILE]],
 	[with_export_syms=$withval],
 	[with_export_syms=no])
 if test "x$with_export_syms" = xyes
@@ -8699,7 +9339,7 @@ AC_SUBST(LIB_UNINSTALL)
 
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_WITH_LIBTOOL_OPTS version: 4 updated: 2015/04/17 21:13:04
+dnl CF_WITH_LIBTOOL_OPTS version: 6 updated: 2023/11/22 20:48:30
 dnl --------------------
 dnl Allow user to pass additional libtool options into the library creation
 dnl and link steps.  The main use for this is to do something like
@@ -8709,7 +9349,7 @@ dnl	./configure --enable-static
 AC_DEFUN([CF_WITH_LIBTOOL_OPTS],[
 AC_MSG_CHECKING(for additional libtool options)
 AC_ARG_WITH(libtool-opts,
-	[  --with-libtool-opts=XXX specify additional libtool options],
+	[[  --with-libtool-opts[=XXX] give libtool additional options XXX]],
 	[with_libtool_opts=$withval],
 	[with_libtool_opts=no])
 AC_MSG_RESULT($with_libtool_opts)
@@ -8725,7 +9365,7 @@ esac
 AC_SUBST(LIBTOOL_OPTS)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_WITH_LIB_BASENAME version: 1 updated: 2020/03/07 20:05:14
+dnl CF_WITH_LIB_BASENAME version: 2 updated: 2023/11/22 20:48:30
 dnl --------------------
 dnl Allow for overriding the basename of a library, i.e., the part to which
 dnl prefixes/suffixes are attached.
@@ -8737,7 +9377,7 @@ AC_DEFUN([CF_WITH_LIB_BASENAME],
 [
 AC_MSG_CHECKING(for desired basename for $2 library)
 AC_ARG_WITH($2-libname,
-	[  --with-$2-libname=XXX override ifelse($3,,$2,$3) basename of library],
+	[[  --with-$2-libname[=XXX] override ifelse($3,,$2,$3) basename of library]],
 	[with_lib_basename=$withval],
 	[with_lib_basename=ifelse($3,,$2,$3)])
 $1="$with_lib_basename"
@@ -8780,7 +9420,7 @@ else
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_WITH_PATH version: 11 updated: 2012/09/29 15:04:19
+dnl CF_WITH_PATH version: 12 updated: 2021/09/04 06:35:04
 dnl ------------
 dnl Wrapper for AC_ARG_WITH to ensure that user supplies a pathname, not just
 dnl defaulting to yes/no.
@@ -8789,7 +9429,7 @@ dnl $1 = option name
 dnl $2 = help-text
 dnl $3 = environment variable to set
 dnl $4 = default value, shown in the help-message, must be a constant
-dnl $5 = default value, if it's an expression & cannot be in the help-message
+dnl $5 = default value, if it is an expression & cannot be in the help-message
 dnl
 AC_DEFUN([CF_WITH_PATH],
 [AC_ARG_WITH($1,[$2 ](default: ifelse([$4],,empty,[$4])),,
@@ -8801,7 +9441,7 @@ eval $3="$withval"
 AC_SUBST($3)dnl
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_WITH_PATHLIST version: 12 updated: 2021/01/01 13:31:04
+dnl CF_WITH_PATHLIST version: 13 updated: 2021/09/04 06:35:04
 dnl ----------------
 dnl Process an option specifying a list of colon-separated paths.
 dnl
@@ -8809,7 +9449,7 @@ dnl $1 = option name
 dnl $2 = help-text
 dnl $3 = environment variable to set
 dnl $4 = default value, shown in the help-message, must be a constant
-dnl $5 = default value, if it's an expression & cannot be in the help-message
+dnl $5 = default value, if it is an expression & cannot be in the help-message
 dnl $6 = flag to tell if we want to define or substitute
 dnl
 AC_DEFUN([CF_WITH_PATHLIST],[
@@ -8879,7 +9519,7 @@ AC_ARG_WITH($2-path,
 	])
 ])
 dnl ---------------------------------------------------------------------------
-dnl CF_WITH_PCRE2 version: 5 updated: 2021/01/26 18:45:12
+dnl CF_WITH_PCRE2 version: 6 updated: 2021/08/11 20:35:34
 dnl -------------
 dnl Add PCRE2 (Perl-compatible regular expressions v2) to the build if it is
 dnl available and the user requests it.  Assume the application will otherwise
@@ -8921,12 +9561,23 @@ if test "x$with_pcre2" != xno ; then
 
 	# either way, check for the library header files
 	AC_CHECK_HEADERS(pcre2posix.h pcreposix.h)
+	AC_CHECK_FUNCS(PCRE2regcomp)
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_WITH_PKG_CONFIG_LIBDIR version: 11 updated: 2021/01/01 16:16:30
+dnl CF_WITH_PKG_CONFIG_LIBDIR version: 23 updated: 2023/11/22 20:48:30
 dnl -------------------------
 dnl Allow the choice of the pkg-config library directory to be overridden.
+dnl
+dnl pkg-config uses a search-list built from these colon-separated lists of
+dnl directories:
+dnl a) $PKG_CONFIG_PATH (tested first, added if set)
+dnl b) $PKG_CONFIG_LIBDIR (tested second, added if set)
+dnl c) builtin-list (added if $PKG_CONFIG_LIBDIR is not set)
+dnl
+dnl pkgconf (used with some systems such as FreeBSD in place of pkg-config)
+dnl optionally ignores $PKG_CONFIG_LIBDIR.  Very old versions of pkg-config,
+dnl e.g., Solaris 10 also do not recognize $PKG_CONFIG_LIBDIR.
 AC_DEFUN([CF_WITH_PKG_CONFIG_LIBDIR],[
 
 case "$PKG_CONFIG" in
@@ -8938,68 +9589,119 @@ case "$PKG_CONFIG" in
 	;;
 esac
 
-PKG_CONFIG_LIBDIR=no
+# if $PKG_CONFIG_LIBDIR is set, try to use that
+if test -n "$PKG_CONFIG_PATH"; then
+	cf_search_path=`echo "$PKG_CONFIG_PATH" | sed -e 's/:/ /g' -e 's,^[[ 	]]*,,' -e 's,[[ 	]]*$,,'`
+elif test -n "$PKG_CONFIG_LIBDIR"; then
+	cf_search_path=`echo "$PKG_CONFIG_LIBDIR" | sed -e 's/:/ /g' -e 's,^[[ 	]]*,,' -e 's,[[ 	]]*$,,'`
+else
+	cf_search_path=auto
+fi
+
+# if the option is used, let that override.  otherwise default to "libdir"
 AC_ARG_WITH(pkg-config-libdir,
-	[  --with-pkg-config-libdir=XXX use given directory for installing pc-files],
-	[PKG_CONFIG_LIBDIR=$withval],
-	[test "x$PKG_CONFIG" != xnone && PKG_CONFIG_LIBDIR=yes])
+	[[  --with-pkg-config-libdir[=XXX] use given directory for installing pc-files]],
+	[cf_search_path=$withval],
+	[test "x$PKG_CONFIG" != xnone && test -z "$cf_search_path" && cf_search_path=libdir])
 
-case x$PKG_CONFIG_LIBDIR in
+case "x$cf_search_path" in
+(xlibdir)
+	PKG_CONFIG_LIBDIR='${libdir}/pkgconfig'
+	AC_MSG_RESULT($PKG_CONFIG_LIBDIR)
+	cf_search_path=
+	;;
+(x)
+	;;
+(x/*\ *)
+	PKG_CONFIG_LIBDIR=
+	;;
 (x/*)
+	PKG_CONFIG_LIBDIR="$cf_search_path"
+	AC_MSG_RESULT($PKG_CONFIG_LIBDIR)
+	cf_search_path=
 	;;
-(xyes)
+(xyes|xauto)
+	AC_MSG_RESULT(auto)
+	cf_search_path=
 	# Look for the library directory using the same prefix as the executable
-	if test "x$PKG_CONFIG" = xnone
+	AC_MSG_CHECKING(for search-list)
+	if test "x$PKG_CONFIG" != xnone
 	then
-		cf_path=$prefix
-	else
-		cf_path=`echo "$PKG_CONFIG" | sed -e 's,/[[^/]]*/[[^/]]*$,,'`
+		# works for pkg-config since version 0.24 (2009)
+		# works for pkgconf since version 0.8.3 (2012)
+		for cf_pkg_program in \
+			`echo "$PKG_CONFIG" | sed -e 's,^.*/,,'` \
+			pkg-config \
+			pkgconf
+		do
+			cf_search_path=`"$PKG_CONFIG" --variable=pc_path "$cf_pkg_program" 2>/dev/null | tr : ' '`
+			test -n "$cf_search_path" && break
+		done
+
+		# works for pkg-config since import in 2005 of original 2001 HP code.
+		test -z "$cf_search_path" && \
+		cf_search_path=`
+		"$PKG_CONFIG" --debug --exists no-such-package 2>&1 | $AWK "\
+/^Scanning directory (#[1-9][0-9]* )?'.*'$/{ \
+	sub(\"^[[^']]*'\",\"\"); \
+	sub(\"'.*\",\"\"); \
+	printf \" %s\", \\[$]0; } \
+{ next; } \
+"`
 	fi
 
-	# If you don't like using the default architecture, you have to specify the
-	# intended library directory and corresponding compiler/linker options.
-	#
-	# This case allows for Debian's 2014-flavor of multiarch, along with the
-	# most common variations before that point.  Some other variants spell the
-	# directory differently, e.g., "pkg-config", and put it in unusual places.
-	# pkg-config has always been poorly standardized, which is ironic...
-	case x`(arch) 2>/dev/null` in
-	(*64)
-		cf_search_path="\
-			$cf_path/lib/*64-linux-gnu \
-			$cf_path/share \
-			$cf_path/lib64 \
-			$cf_path/lib32 \
-			$cf_path/lib"
-		;;
-	(*)
-		cf_search_path="\
-			$cf_path/lib/*-linux-gnu \
-			$cf_path/share \
-			$cf_path/lib32 \
-			$cf_path/lib \
-			$cf_path/libdata"
-		;;
-	esac
+	AC_MSG_RESULT($cf_search_path)
+	;;
+(*)
+	AC_MSG_ERROR(Unexpected option value: $cf_search_path)
+	;;
+esac
 
-	CF_VERBOSE(list...)
+if test -n "$cf_search_path"
+then
+	AC_MSG_CHECKING(for first directory)
+	cf_pkg_config_path=none
 	for cf_config in $cf_search_path
 	do
-		CF_VERBOSE(checking $cf_config/pkgconfig)
-		if test -d "$cf_config/pkgconfig"
+		if test -d "$cf_config"
 		then
-			PKG_CONFIG_LIBDIR=$cf_config/pkgconfig
-			AC_MSG_CHECKING(done)
+			cf_pkg_config_path=$cf_config
 			break
 		fi
 	done
-	;;
-(*)
-	;;
-esac
+	AC_MSG_RESULT($cf_pkg_config_path)
 
-if test "x$PKG_CONFIG_LIBDIR" != xno ; then
-	AC_MSG_RESULT($PKG_CONFIG_LIBDIR)
+	if test "x$cf_pkg_config_path" != xnone ; then
+		# limit this to the first directory found
+		PKG_CONFIG_LIBDIR="$cf_pkg_config_path"
+	fi
+
+	if test -z "$PKG_CONFIG_LIBDIR" && test -n "$cf_search_path"
+	then
+		AC_MSG_CHECKING(for workaround)
+		if test "$prefix" = "NONE" ; then
+			cf_prefix="$ac_default_prefix"
+		else
+			cf_prefix="$prefix"
+		fi
+		eval cf_libdir=$libdir
+		cf_libdir=`echo "$cf_libdir" | sed -e "s,^NONE,$cf_prefix,"`
+		cf_backup=
+		for cf_config in $cf_search_path
+		do
+			case $cf_config in
+			$cf_libdir/pkgconfig)
+				PKG_CONFIG_LIBDIR=$cf_libdir/pkgconfig
+				break
+				;;
+			*)
+				test -z "$cf_backup" && cf_backup=$cf_config
+				;;
+			esac
+		done
+		test -z "$PKG_CONFIG_LIBDIR" && PKG_CONFIG_LIBDIR=$cf_backup
+		AC_MSG_RESULT($PKG_CONFIG_LIBDIR)
+	fi
 fi
 
 AC_SUBST(PKG_CONFIG_LIBDIR)
@@ -9047,7 +9749,7 @@ if test "$with_pthread" != no ; then
 fi
 ])
 dnl ---------------------------------------------------------------------------
-dnl CF_WITH_REL_VERSION version: 1 updated: 2003/09/20 18:12:49
+dnl CF_WITH_REL_VERSION version: 2 updated: 2023/05/06 18:18:18
 dnl -------------------
 dnl Allow library's release-version to be overridden.  Generally this happens when a
 dnl packager has incremented the release-version past that used in the original package,
@@ -9067,6 +9769,7 @@ ifelse($1,,[
 ],[
  $1_MAJOR=`echo "$cf_cv_rel_version" | sed -e 's/\..*//'`
  $1_MINOR=`echo "$cf_cv_rel_version" | sed -e 's/^[[^.]]*//' -e 's/^\.//' -e 's/\..*//'`
+ test -n "$1_MINOR" || $1_MINOR=0
  CF_NUMBER_SYNTAX([$]$1_MAJOR,Release major-version)
  CF_NUMBER_SYNTAX([$]$1_MINOR,Release minor-version)
 ])
@@ -9122,6 +9825,27 @@ AC_ARG_WITH(system-type,
 ])
 ])dnl
 dnl ---------------------------------------------------------------------------
+dnl CF_WITH_TYPE version: 2 updated: 2023/11/25 16:11:47
+dnl ------------
+dnl Accept a TYPE for substitution:
+dnl $1 = name of type
+dnl $2 = help/usage message
+dnl $3 = symbol to set
+dnl $4 = default value
+AC_DEFUN([CF_WITH_TYPE],[
+AC_MSG_CHECKING(for type of $1)
+AC_ARG_WITH([$1], [$2],
+	[$3="$withval"],
+	[$3=$4])
+AC_MSG_RESULT([$]$3)
+case x[$]$3 in
+(x|xyes|xno)
+	AC_MSG_ERROR(expected a type name for $1)
+	;;
+esac
+AC_SUBST($3)
+])dnl
+dnl ---------------------------------------------------------------------------
 dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
 dnl ----------------
 AC_DEFUN([CF_WITH_VALGRIND],[
@@ -9130,7 +9854,7 @@ CF_NO_LEAKS_OPTION(valgrind,
 	[USE_VALGRIND])
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_WITH_VERSIONED_SYMS version: 10 updated: 2021/01/04 18:48:01
+dnl CF_WITH_VERSIONED_SYMS version: 13 updated: 2023/12/03 09:24:04
 dnl ----------------------
 dnl Use this when building shared library with ELF, to markup symbols with the
 dnl version identifier from the given input file.  Generally that identifier is
@@ -9143,7 +9867,7 @@ AC_REQUIRE([AC_PROG_EGREP])dnl
 
 AC_MSG_CHECKING(if versioned-symbols file should be used)
 AC_ARG_WITH(versioned-syms,
-	[  --with-versioned-syms=X markup versioned symbols using ld],
+	[[  --with-versioned-syms[=MAP-FILE] version ELF shared library symbols per MAP-FILE]],
 	[with_versioned_syms=$withval],
 	[with_versioned_syms=no])
 case "x$with_versioned_syms" in
@@ -9230,15 +9954,15 @@ local:
 EOF
 		cat >conftest.$ac_ext <<EOF
 #line __oline__ "configure"
-int	_ismissing(void) { return 1; }
-int	_localf1(void) { return 1; }
-int	_localf2(void) { return 2; }
-int	globalf1(void) { return 1; }
-int	globalf2(void) { return 2; }
-int	_sublocalf1(void) { return 1; }
-int	_sublocalf2(void) { return 2; }
-int	subglobalf1(void) { return 1; }
-int	subglobalf2(void) { return 2; }
+extern int _ismissing(void);    int _ismissing(void)  { return 1; }
+extern int _localf1(void);      int _localf1(void)    { return 1; }
+extern int _localf2(void);      int _localf2(void)    { return 2; }
+extern int globalf1(void);      int globalf1(void)    { return 1; }
+extern int globalf2(void);      int globalf2(void)    { return 2; }
+extern int _sublocalf1(void);   int _sublocalf1(void) { return 1; }
+extern int _sublocalf2(void);   int _sublocalf2(void) { return 2; }
+extern int subglobalf1(void);   int subglobalf1(void) { return 1; }
+extern int subglobalf2(void);   int subglobalf2(void) { return 2; }
 EOF
 		cat >conftest.mk <<EOF
 CC=${CC}
@@ -9269,7 +9993,7 @@ AC_SUBST(VERSIONED_SYMS)
 AC_SUBST(WILDCARD_SYMS)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_WITH_X11_RGB version: 2 updated: 2019/12/31 08:53:54
+dnl CF_WITH_X11_RGB version: 3 updated: 2023/10/28 11:59:01
 dnl ---------------
 dnl Handle configure option "--with-x11-rgb", setting these shell
 dnl variables:
@@ -9309,7 +10033,7 @@ dnl 	/usr/X11/lib/X11/rgb.txt
 AC_DEFUN([CF_WITH_X11_RGB],[
 AC_MSG_CHECKING(for X11 rgb file)
 AC_ARG_WITH(x11-rgb,
-	[  --with-x11-rgb=FILE   file containing X11 rgb information (EPREFIX/lib/X11/rgb.txt)],
+	[  --with-x11-rgb=FILE     obtain X11 color definitions from FILE (default: EPREFIX/lib/X11/rgb.txt)],
 	[RGB_PATH=$withval],
 	[RGB_PATH=auto])
 
@@ -9355,7 +10079,7 @@ fi
 AC_SUBST(no_x11_rgb)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_XOPEN_SOURCE version: 57 updated: 2021/01/01 16:53:59
+dnl CF_XOPEN_SOURCE version: 67 updated: 2023/09/06 18:55:27
 dnl ---------------
 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
 dnl or adapt to the vendor's definitions to get equivalent functionality,
@@ -9364,6 +10088,18 @@ dnl
 dnl Parameters:
 dnl	$1 is the nominal value for _XOPEN_SOURCE
 dnl	$2 is the nominal value for _POSIX_C_SOURCE
+dnl
+dnl The default case prefers _XOPEN_SOURCE over _POSIX_C_SOURCE if the
+dnl implementation predefines it, because X/Open and most implementations agree
+dnl that the latter is a legacy or "aligned" value.
+dnl
+dnl Because _XOPEN_SOURCE is preferred, if defining _POSIX_C_SOURCE turns
+dnl that off, then refrain from setting _POSIX_C_SOURCE explicitly.
+dnl
+dnl References:
+dnl https://pubs.opengroup.org/onlinepubs/007904975/functions/xsh_chap02_02.html
+dnl https://docs.oracle.com/cd/E19253-01/816-5175/standards-5/index.html
+dnl https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html
 AC_DEFUN([CF_XOPEN_SOURCE],[
 AC_REQUIRE([AC_CANONICAL_HOST])
 AC_REQUIRE([CF_POSIX_VISIBLE])
@@ -9378,9 +10114,6 @@ case "$host_os" in
 (aix[[4-7]]*)
 	cf_xopen_source="-D_ALL_SOURCE"
 	;;
-(msys)
-	cf_XOPEN_SOURCE=600
-	;;
 (darwin[[0-8]].*)
 	cf_xopen_source="-D_APPLE_C_SOURCE"
 	;;
@@ -9406,7 +10139,7 @@ case "$host_os" in
 	cf_xopen_source="-D_SGI_SOURCE"
 	cf_XOPEN_SOURCE=
 	;;
-(linux*|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin)
+(linux*gnu|linux*gnuabi64|linux*gnuabin32|linux*gnueabi|linux*gnueabihf|linux*gnux32|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin|msys|mingw*|linux*uclibc)
 	CF_GNU_SOURCE($cf_XOPEN_SOURCE)
 	;;
 (minix*)
@@ -9420,7 +10153,15 @@ case "$host_os" in
 (netbsd*)
 	cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
 	;;
-(openbsd[[4-9]]*)
+(openbsd[[6-9]]*)
+	# OpenBSD 6.x has broken locale support, both compile-time and runtime.
+	# see https://www.mail-archive.com/bugs@openbsd.org/msg13200.html
+	# Abusing the conformance level is a workaround.
+	AC_MSG_WARN(this system does not provide usable locale support)
+	cf_xopen_source="-D_BSD_SOURCE"
+	cf_XOPEN_SOURCE=700
+	;;
+(openbsd[[4-5]]*)
 	# setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
 	cf_xopen_source="-D_BSD_SOURCE"
 	cf_XOPEN_SOURCE=600
@@ -9447,12 +10188,20 @@ case "$host_os" in
 	;;
 (*)
 	CF_TRY_XOPEN_SOURCE
+	cf_save_xopen_cppflags="$CPPFLAGS"
 	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
+	# Some of these niche implementations use copy/paste, double-check...
+	if test "$cf_cv_xopen_source" = no ; then
+		CF_VERBOSE(checking if _POSIX_C_SOURCE interferes with _XOPEN_SOURCE)
+		AC_TRY_COMPILE(CF__XOPEN_SOURCE_HEAD,CF__XOPEN_SOURCE_BODY,,[
+			AC_MSG_WARN(_POSIX_C_SOURCE definition is not usable)
+			CPPFLAGS="$cf_save_xopen_cppflags"])
+	fi
 	;;
 esac
 
 if test -n "$cf_xopen_source" ; then
-	CF_ADD_CFLAGS($cf_xopen_source,true)
+	CF_APPEND_CFLAGS($cf_xopen_source,true)
 fi
 
 dnl In anything but the default case, we may have system-specific setting
@@ -9462,7 +10211,7 @@ if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
 	AC_MSG_CHECKING(if _XOPEN_SOURCE really is set)
 	AC_TRY_COMPILE([#include <stdlib.h>],[
 #ifndef _XOPEN_SOURCE
-make an error
+#error _XOPEN_SOURCE is not defined
 #endif],
 	[cf_XOPEN_SOURCE_set=yes],
 	[cf_XOPEN_SOURCE_set=no])
@@ -9471,7 +10220,7 @@ make an error
 	then
 		AC_TRY_COMPILE([#include <stdlib.h>],[
 #if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
-make an error
+#error (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
 #endif],
 		[cf_XOPEN_SOURCE_set_ok=yes],
 		[cf_XOPEN_SOURCE_set_ok=no])
@@ -9491,3 +10240,21 @@ dnl ------------------
 dnl Trim something using sed, then trim extra whitespace
 dnl $1 = extra parameters, e.g., in CF_STRIP_G_OPT
 define([CF__SED_TRIMBLANKS],[sed ifelse($1,,,[$1] )-e 's%[[	]]% %g' -e 's% [[ ]]*% %g' -e 's%^ %%' -e 's% [$]%%'])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF__XOPEN_SOURCE_BODY version: 2 updated: 2023/02/18 17:41:25
+dnl ---------------------
+dnl body of test when test-compiling for _XOPEN_SOURCE check
+define([CF__XOPEN_SOURCE_BODY],
+[
+#ifndef _XOPEN_SOURCE
+#error _XOPEN_SOURCE is not defined
+#endif
+])
+dnl ---------------------------------------------------------------------------
+dnl CF__XOPEN_SOURCE_HEAD version: 2 updated: 2023/02/18 17:41:25
+dnl ---------------------
+dnl headers to include when test-compiling for _XOPEN_SOURCE check
+define([CF__XOPEN_SOURCE_HEAD],
+[
+$ac_includes_default
+])
diff --git a/contrib/ncurses/announce.html.in b/contrib/ncurses/announce.html.in
index 84b9d4297de5..9889ef1bfb6c 100644
--- a/contrib/ncurses/announce.html.in
+++ b/contrib/ncurses/announce.html.in
@@ -1,7 +1,7 @@
 <!--
-  $Id: announce.html.in,v 1.99 2020/10/19 08:18:12 tom Exp $
+  $Id: announce.html.in,v 1.107 2024/04/27 16:45:27 tom Exp $
   ****************************************************************************
-  * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+  * Copyright 2018-2023,2024 Thomas E. Dickey                                *
   *                                                                          *
   * Permission is hereby granted, free of charge, to any person obtaining a  *
   * copy of this software and associated documentation files (the            *
@@ -29,12 +29,10 @@
   ****************************************************************************
 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
-
 <html>
 <head>
   <meta name="generator" content=
-  "HTML Tidy for HTML5 for Linux version 5.2.0">
-
+  "HTML Tidy for HTML5 for Linux version 5.6.0">
   <title>Announcing ncurses @VERSION@</title>
   <link rel="author" href="mailto:bug-ncurses@gnu.org">
   <meta http-equiv="Content-Type" content=
@@ -57,7 +55,6 @@
   }
   </style>
 </head>
-
 <body>
   <h1 class="no-header">Announcing ncurses @VERSION@</h1>
 
@@ -140,28 +137,27 @@
 
   <blockquote>
     <p><a href=
-    "ftp://ftp.invisible-island.net/ncurses/">ftp://ftp.invisible-island.net/ncurses/</a>
+    "https://invisible-island.net/archives/ncurses/">https://invisible-island.net/archives/ncurses/</a>
     or<br>
     <a href=
     "https://invisible-mirror.net/archives/ncurses/">https://invisible-mirror.net/archives/ncurses/</a>&nbsp;.</p>
   </blockquote>
 
-  <p>It is also available via anonymous FTP at the GNU distribution
-  site</p>
+  <p>It is also available at the GNU distribution site</p>
 
   <blockquote>
     <p><a href=
-    "ftp://ftp.gnu.org/gnu/ncurses/">ftp://ftp.gnu.org/gnu/ncurses/</a>&nbsp;.</p>
+    "https://ftp.gnu.org/gnu/ncurses/">https://ftp.gnu.org/gnu/ncurses/</a>&nbsp;.</p>
   </blockquote>
 
   <h2><a name="h2-release-notes" id="h2-release-notes">Release
   Notes</a></h2>
 
   <p>These notes are for <span class="main-name">ncurses</span>
-  @VERSION@, released <strong>February 12, 2020</strong>.</p>
+  @VERSION@, released <strong>April 27, 2024</strong>.</p>
 
   <p>This release is designed to be source-compatible with
-  <span class="main-name">ncurses</span> 5.0 through 6.1; providing
+  <span class="main-name">ncurses</span> 5.0 through 6.4; providing
   extensions to the application binary interface (ABI). Although
   the source can still be configured to support the <span class=
   "main-name">ncurses</span> 5 ABI, the reason for the release is
@@ -173,292 +169,181 @@
   this announcement.</p>
 
   <p>The most <a href="#h3-bug-fixes">important
-  bug-fixes/improvements</a> dealt with user-defined capabilities
-  in terminal descriptions. The release notes also mention some
-  other bug-fixes, but are focused on new features and improvements
-  to existing features since <span class="main-name">ncurses</span>
-  6.1 release.</p>
+  bug-fixes/improvements</a> dealt with robustness issues. The
+  release notes also mention some other bug-fixes, but are focused
+  on new features and improvements to existing features since
+  <span class="main-name">ncurses</span> 6.4 release.</p>
 
   <h3><a name="h3-library" id="h3-library">Library improvements</a></h3>
 
   <h4><a name="h4-new-library" id="h4-new-library">New features</a></h4>
 
-  <p>There are several new features:</p>
+  <p>These are new features:</p>
 
   <ul>
     <li>
-      <p><a href=
-      "@HOMEPAGE@/man/form_field_opts.3x.html">O_EDGE_INSERT_STAY</a>
-      tells the form library to optionally delay cursor movement on
-      a field edge/boundary</p>
-    </li>
+      <p>The low-level terminfo and termcap interfaces are used
+      both by the higher-level curses library, as well as by many
+      applications.</p>
 
-    <li>
-      <p><a href=
-      "@HOMEPAGE@/man/form_field_opts.3x.html">O_INPUT_FIELD</a>
-      extension to form library allows a dynamic field to shrink if
-      the new limit is smaller than the current field size.</p>
-    </li>
+      <p>The functions which convert parameterized terminal
+      capability strings for output to the terminal
+      (<code>tiparm</code> and <code>tparm</code>) analyze the
+      capability string to determine which parameters are strings
+      (i.e., addresses), versus numbers (not addresses).</p>
 
-    <li>
-      <p>added <a href=
-      "@HOMEPAGE@/man/curs_memleaks.3x.html">exit_curses</a> and
-      <a href=
-      "@HOMEPAGE@/man/curs_memleaks.3x.html">exit_terminfo</a> to
-      replace internal symbols for leak-checking.</p>
-    </li>
-
-    <li>
-      <p>added <a href=
-      "@HOMEPAGE@/man/curs_trace.3x.html#h3-Functions">curses_trace</a>,
-      to replace trace().</p>
-    </li>
-  </ul>
+      <p>The library's analysis of a capability string may differ
+      from the calling application's design if environment
+      variables are used to point to an invalid terminal database.
+      This is a longstanding problem with <em>all</em>
+      implementations of terminfo, dating from the early 1980s.</p>
 
-  <p>Additionally, to improve performance other changes (and
-  extensions) are provided in this release:</p>
+      <p>Two new functions address this problem: by providing a
+      function which allows the calling application to tell ncurses
+      how many string-parameters to expect:</p>
 
-  <ul>
-    <li>
-      <p>mouse decoding now handles shift/control/alt logic when
-      decoding xterm's 1006 mode</p>
-    </li>
-
-    <li>
-      <p>ncurses now defines a limit for <a href=
-      "@HOMEPAGE@/man/curs_getstr.3x.html">wgetnstr</a>, <a href=
-      "@HOMEPAGE@/man/curs_get_wstr.3x.html">wgetn_wstr</a> when
-      length is negative or &ldquo;too large&rdquo;.</p>
-    </li>
-
-    <li>reordered loop-limit checks in <a href=
-    "@HOMEPAGE@/man/curs_insstr.3x.html">winsnstr</a> in case the
-    string has no terminating null and only the number of
-    characters is used.</li>
-
-    <li>
-      <p>there is now no buffer-size limit when reading the
-      <a href="@HOMEPAGE@/man/ncurses.3x.html#h3-TERMCAP"><tt>$TERMCAP</tt></a>
-      variable.</p>
-    </li>
-
-    <li>
-      <p>the <a href=
-      "@HOMEPAGE@/man/ncurses.3x.html#h3-TERMCAP"><tt>$TERMCAP</tt></a>
-      variable may be interpreted as a fallback to a terminfo
-      entry</p>
-    </li>
+      <ul>
+        <li><code>tiscan_s</code> helps applications check
+        formatting capabilities that would be passed to
+        <code>tiparm_s</code>.</li>
 
-    <li>
-      <p><a href=
-      "@HOMEPAGE@/man/curs_terminfo.3x.html#h3-Output-Functions"><tt>
-      mvcur</tt></a> now decides whether to use hard-tabs, using
-      <strong><tt>xt</tt></strong>, <strong><tt>tbc</tt></strong>
-      and <strong><tt>hts</tt></strong> as clues.</p>
+        <li><code>tiparm_s</code> provides applications a way to
+        tell ncurses what the expected parameters are for a
+        capability.</li>
+      </ul>
     </li>
 
     <li>
-      <p>extended colors are improved by modifying an internal call
-      to <a href=
-      "@HOMEPAGE@/man/curs_terminfo.3x.html#h3-Output-Functions"><tt>
-      vid_puts</tt></a> to pass extended color pairs e.g., from
-      <tt>tty_update.c</tt> and <tt>lib_mvcur.c</tt></p>
-    </li>
+      <p>The ncurses library supports a compile-time feature
+      (enabled with the configure <code>--enable-check-size</code>
+      option) which simplifies initialization with terminals which
+      do not negotiate window (screen) size. This is done in
+      <code>setupterm</code>, by providing for using ANSI
+      cursor-position report (in user6/user7 terminfo capabilities)
+      to obtain the screen size if neither environment variables or
+      ioctl is used.</p>
 
-    <li>
-      <p id="getenv-fixes">the initialization functions now avoid
-      relying upon persistent data for the result from <a href=
-      "#getenv-check"><tt>getenv</tt></a></p>
+      <p>The ncurses test-program with options
+      &ldquo;<code>-E&nbsp;-T</code>&rdquo; demonstrates this
+      feature.</p>
     </li>
 
-    <li>
-      <p>scrolling is improved:</p>
-
-      <ul>
-        <li>a limit check in <tt>newline_forces_scroll</tt> handles
-        the case where the row is inside scroll-margins, but not at
-        the end.</li>
-
-        <li>
-          <p>improved loop limits in <tt>_nc_scroll_window</tt>
-          handle a case where the scrolled data is a pad which is
-          taller than the window.</p>
-        </li>
-      </ul>
-    </li>
+    <li>add functions to query tty-flags in
+    <code>SCREEN</code></li>
   </ul>
 
+  <p>This release drops compatibility with obsolete versions of
+  <a href="@HOMEPAGE@/tack/">tack</a>, e.g., pre-1.08</p>
+
   <h4><a name="h4-fixes-library" id="h4-fixes-library">Other
   improvements</a></h4>
 
-  <p>These are revised features:</p>
+  <p>These are improvements to existing features:</p>
 
   <ul>
     <li>
-      <p>used &ldquo;<tt>const</tt>&rdquo; in some prototypes
-      rather than <tt>NCURSES_CONST</tt> where X/Open Curses was
-      updated to do this, e.g., <tt>wscanw</tt>, <tt>newterm</tt>,
-      the terminfo interface. Also use &ldquo;<tt>const</tt>&rdquo;
-      for consistency in the termcap interface, which was withdrawn
-      by X/Open Curses in Issue 5 (2007). As of Issue 7, X/Open
-      Curses still lacks &ldquo;<tt>const</tt>&rdquo; for certain
-      return values, e.g., <a href=
-      "@HOMEPAGE@/man/curs_util.3x.html#h3-keyname_key_name">keyname</a>.</p>
-    </li>
-
-    <li>
-      <p>modified <a href=
-      "@HOMEPAGE@/man/curs_bkgd.3x.html#h3-bkgd"><tt>wbkgd</tt></a>
-      and <a href=
-      "@HOMEPAGE@/man/curs_bkgrnd.3x.html#h3-bkgrnd"><tt>wbkgrnd</tt></a>
-      to improve compatibility with SVr4 curses, changing the way
-      the window rendition is updated when the background character
-      is modified</p>
-    </li>
-
-    <li>
-      <p>improved terminfo write/read by modifying the fourth item
-      of the extended header to denote the number of valid strings
-      in the extended string table (see <a href=
-      "@HOMEPAGE@/man/term.5.html#h3-EXTENDED-STORAGE-FORMAT">term(5)</a>).</p>
-    </li>
-
-    <li>
-      <p>modified the initialization checks for mouse so that the
-      <a href=
-      "/ncurses/terminfo.src.html#tic-xterm_sm_1006"><tt>xterm+sm+1006</tt></a>
-      block will work with terminal descriptions not mentioning
-      <em>xterm</em>.</p>
-    </li>
-  </ul>
+      <p>In addition to the new, safer function
+      <code>tiparm_s</code>, ncurses adds checks to make the older
+      <code>tiparm</code>, <code>tparm</code> and
+      <code>tgoto</code> functions safer:</p>
 
-  <p>These were done to limit or ultimately deprecate features:</p>
+      <ul>
+        <li>
+          <p>the terminfo functions <code>tiparm</code> and
+          <code>tparm</code> ensure that the capability string
+          comes from the terminal description which ncurses loads,
+          rather than from random data which the application
+          happens to have.</p>
+        </li>
 
-  <ul>
-    <li>
-      <p>deprecated <a href=
-      "@HOMEPAGE@/NEWS.html#t970831">safe-sprintf</a>, since the
-      <tt>vsnprintf</tt> function, which does what was needed, was
-      standardized long ago.</p>
-    </li>
+        <li>
+          <p>the <code>tgoto</code> function disallows capabilities
+          which its analysis shows will attempt to use string
+          parameters.</p>
+        </li>
 
-    <li>
-      <p>marked <a href=
-      "@HOMEPAGE@/man/curs_printw.3x.html#h2-PORTABILITY"><tt>vwprintw</tt></a>
-      and <tt>vwscanw</tt> as deprecated; recommend using <a href=
-      "@HOMEPAGE@/man/curs_printw.3x.html"><tt>vw_printw</tt></a>
-      and <tt>vw_scanw</tt>, respectively.</p>
+        <li>
+          <p>ncurses uses internal functions which correspond to
+          <code>tiparm</code>, and <code>tgoto</code> which ensure
+          that the capability strings which are passed to these
+          functions come from the loaded terminal description.</p>
+        </li>
+      </ul>
     </li>
 
     <li>
-      <p>added deprecation warnings for internal functions called
-      by older versions of <a href=
-      "@HOMEPAGE@/tack.html">tack</a>.</p>
+      <p>improve check in <code>lib_tparm.c</code>, ensuring that a
+      char* fits into a <code>TPARM_ARG</code></p>
     </li>
 
     <li>
-      <p>removed unused <tt>_nc_import_termtype2</tt> function.</p>
+      <p>modify <code>_nc_syserr_abort</code> to use
+      <code>_nc_env_access</code>, rather than only checking root
+      uid</p>
     </li>
-  </ul>
 
-  <p>These are improvements to existing features:</p>
-
-  <ul>
     <li>
-      <p>check parameter of <a href=
-      "@HOMEPAGE@/man/curs_threads.3x.html">set_escdelay</a>,
-      return ERR if negative.</p>
+      <p>improve thread lock in <code>lib_trace.c</code></p>
     </li>
 
     <li>
-      <p>check parameter of <a href=
-      "@HOMEPAGE@/man/curs_threads.3x.html">set_tabsize</a>, return
-      ERR if not greater than zero</p>
+      <p>modify <code>flushinp</code> to use file descriptors in
+      <code>SCREEN</code>, rather than from <code>TERMINAL</code>,
+      and check if they are for a terminal, like SVr4</p>
     </li>
 
     <li>
-      <p>correct a status-check in _nc_read_tic_entry() so that if
-      reading a hex/b64 <a href=
-      "@HOMEPAGE@/man/ncurses.3x.html#h3-TERMINFO"><tt>$TERMINFO</tt></a>,
-      and the <a href=
-      "@HOMEPAGE@/man/ncurses.3x.html#h3-TERM"><tt>$TERM</tt></a>
-      does not match, fall-through to the compiled-in search
-      list.</p>
+      <p>modify <code>mcprint</code> to use file descriptor in
+      <code>SCREEN</code>, for consistency</p>
     </li>
 
     <li>
-      <p>amend check for <a href=
-      "@HOMEPAGE@/man/terminfo.5.html#h3-Predefined-Capabilities"><tt>
-      repeat_char</tt></a> to handle a case where setlocale() was
-      called after <a href=
-      "@HOMEPAGE@/man/curs_initscr.3x.html"><tt>initscr</tt></a></p>
+      <p>modify internal function <code>_nc_read_file_entry</code>
+      to show relevant filename in warnings</p>
     </li>
 
     <li>
-      <p>move macro for <a href=
-      "@HOMEPAGE@/man/curs_touch.3x.html"><tt>is_linetouched</tt></a>
-      inside <strong><tt>NCURSES_NOMACROS</tt></strong>
-      <em><tt>ifndef</tt></em>.</p>
+      <p>improve checks in internal function
+      <code>convert_string</code> for corrupt terminfo entry</p>
     </li>
 
     <li>
-      <p>use <tt>_nc_copy_termtype2</tt> rather than direct
-      assignment in <a href=
-      "@HOMEPAGE@/man/curs_terminfo.3x.html#h3-Initialization">setupterm</a>,
-      in case it is called repeatedly using fallback terminfo
-      descriptions</p>
+      <p>review/improve handling of out-of-memory conditions</p>
     </li>
 
     <li>
-      <p>improve workaround for Solaris wcwidth versus line-drawing
-      characters</p>
+      <p>limit delays to 30 seconds, i.e., padding delays in
+      terminfo, as well as <code>napms</code> and
+      <code>delay_output</code> functions</p>
     </li>
 
     <li>
-      <p>add checks in <a href=
-      "@HOMEPAGE@/man/resizeterm.3x.html"><tt>repair_subwindows</tt></a>
-      to keep the current position and scroll-margins inside the
-      resized subwindow.</p>
+      <p>fix reallocation loop for <code>vsnprintf</code> in
+      <code>_nc_sprintf_string</code> by copying the va_list
+      variable</p>
     </li>
 
     <li>
-      <p>correct a buffer-limit in <tt>write_entry.c</tt> for
-      systems that use caseless filenames.</p>
+      <p>modify <code>delscreen</code> to limit the windows which
+      it creates to just those associated with the screen</p>
     </li>
 
     <li>
-      <p>improved build-time utility <em>report_offsets</em>:</p>
-
-      <ul>
-        <li>
-          <p>add categories, e.g., "w" for wide-character, "t" for
-          threads to make the report more readable. Reorganized the
-          structures reported to make the categories more
-          apparent.</p>
-        </li>
-
-        <li>
-          <p>add <tt>NCURSES_GLOBALS</tt> and
-          <tt>NCURSES_PRESCREEN</tt> to report to show how similar
-          the different <em>libtinfo</em> configurations are.</p>
-        </li>
-      </ul>
+      <p>modify <code>endwin</code> to return an error if it is
+      called again without an intervening screen update</p>
     </li>
 
     <li>
-      <p>modified some header files to ensure that those include
-      necessary files except for the previously-documented
-      cases</p>
+      <p>modify <code>wenclose</code> to handle pads</p>
     </li>
 
     <li>
-      <p>added some traces in initialization to show whether a
-      fallback entry is used.</p>
+      <p>eliminate use of <code>PATH_MAX</code> in
+      <code>lib_trace.c</code></p>
     </li>
 
     <li>
-      <p>made minor optimization to reduce calls to
-      _nc_reserve_pairs</p>
+      <p>provide for any <code>CCHARW_MAX</code> greater than 1</p>
     </li>
   </ul>
 
@@ -466,504 +351,336 @@
 
   <ul>
     <li>
-      <p>fix a special case in <tt>PutAttrChar</tt> where a cell is
-      marked as alternate-character set, but the terminal does not
-      actually support the given graphic character. This would
-      happen in an older terminal such as <em>vt52</em>, which
-      lacks most line-drawing capability.</p>
+      <p>correct loop termination condition in
+      <code>waddnstr</code> and <code>waddnwstr</code></p>
     </li>
 
     <li>
-      <p>corrected flag for "seq" method of db 1.8.5 interface,
-      needed by toe on some of the BSDs.</p>
+      <p>improve parsing in internal function
+      <code>_nc_msec_cost</code>, allowing a single decimal
+      point</p>
     </li>
 
     <li>
-      <p>modify comparison in make_hash.c to correct a special case
-      in collision handling for Caps-hpux11</p>
+      <p>amend parameter check for entire string versus specific
+      length in <code>winsnstr</code> and <code>wins_nwstr</code>
+      to match Solaris; make similar correction to
+      <code>wins_nwstr</code></p>
     </li>
 
     <li>
-      <p>add extended_slk_color{,_sp} symbols to the appropriate
-      package/*.{map,sym} files</p>
+      <p>correct internal function <code>wadd_wch_literal</code>
+      when adding a non-spacing character to a double-width
+      character</p>
     </li>
 
     <li>
-      <p>modify lib_setup to avoid calling pthread_self() without
-      first verifying that the address is valid, i.e., for weak
-      symbols</p>
-    </li>
-
-    <li>
-      <p>add a couple of broken-linker symbols to the list of
-      versioned symbols to help with link-time optimization versus
-      weak symbols.</p>
+      <p>correct definition of <code>Charable</code> macro for
+      non-wide ncurses library .</p>
     </li>
   </ul>
 
   <h3><a name="h3-programs" id="h3-programs">Program
   improvements</a></h3>
 
-  <p id="h4-utilities">Several improvements were made to the utility programs:</p>
+  <p id="h4-utilities">Several improvements were made to the
+  utility programs. Some were done to make the <code>infocmp</code>
+  option &ldquo;<tt>-u</tt>&rdquo; option help refactor the
+  terminal database.</p>
 
   <dl>
-    <dt><span class="part-name">clear</span>
+    <dt><span class="part-name"><a href=
+    "@HOMEPAGE@/man/infocmp.1m.html">infocmp</a></span>
     </dt>
 
     <dd>
       <ul>
-        <li>improved logic for clearing with the <em>E3</em>
-        extension, in case the terminal scrolls content onto its
-        saved-lines before actually clearing the display, by
-        clearing the saved-lines after clearing the display</li>
-      </ul>
-    </dd>
+        <li>
+          <p>add limit checks for processing extended capabilities
+          with the &ldquo;<code>-u</code>&rdquo; option</p>
+        </li>
 
-    <dt><span class="part-name">infocmp</span>
-    </dt>
+        <li>
+          <p>correct initial alignment of extended capabilities, so
+          that the &ldquo;<code>-u</code>&rdquo; option can be used
+          for more than two terminal types</p>
+        </li>
 
-    <dd>
-      <ul>
-        <li>omit filtering of &ldquo;<tt>OTxx</tt>&rdquo; names
-        which are used for obsolete capabilities, when the output
-        is sorted by long-names. This change helps when making a
-        table of the short/long capability names.</li>
+        <li>
+          <p>modify &ldquo;<code>-u</code>&rdquo; option to not
+          report cancels for strings which were already cancelled
+          in a use'd chunk.</p>
+        </li>
+
+        <li>
+          <p>correct an assignment &ldquo;<code>-u</code>&rdquo;
+          for detecting if a boolean is unset in a base entry and
+          set in a use'd chunk, i.e., if it was cancelled.</p>
+        </li>
       </ul>
     </dd>
 
-    <dt><span class="part-name">tic</span>
+    <dt><span class="part-name"><a href=
+    "@HOMEPAGE@/man/tic.1m.html">tic</a></span>
     </dt>
 
     <dd>
       <ul>
-        <li>added check for consistent alternate character set
-        capabilities.</li>
-
-        <li>added check for paired <tt>indn</tt>/<tt>rin</tt>.</li>
-
-        <li>added check for terminals with <tt>parm_dch</tt> vs
-        <tt>parm_ich</tt>.</li>
-
-        <li>added check for the case where
-        <tt>setf</tt>/<tt>setb</tt> are given using different
-        strings, but provide identical results to
-        <tt>setaf</tt>/<tt>setab</tt>.</li>
-
-        <li>corrected check for <tt>ich1</tt>.</li>
+        <li>
+          <p>correct limit-check when dumping tc/use clause via
+          &ldquo;<code>-I</code>&rdquo;</p>
+        </li>
 
-        <li>changed a too-large terminal entry from a fatal error
-        to a warning.</li>
-      </ul>
-    </dd>
+        <li>
+          <p>check return value of <code>_nc_save_str</code>, in
+          special case where extended capabilities are processed
+          but the terminal description was not initialized</p>
+        </li>
 
-    <dt><span class="part-name">toe</span>
-    </dt>
+        <li>
+          <p>modify check for multiply defined aliases to report
+          problems within the current runtime rather than for
+          conflicts with pre-existing terminal descriptions.</p>
+        </li>
 
-    <dd>
-      <ul>
-        <li>ignores any hex/b64 <tt>$TERMINFO</tt> value in the
-        list of terminfo databases.</li>
+        <li>
+          <p>disallow using <code>$TERMINFO</code> or
+          <code>$HOME/.terminfo</code> when
+          &ldquo;<code>-o</code>&rdquo; option is used</p>
+        </li>
       </ul>
     </dd>
 
-    <dt><span class="part-name">tset</span>
-    </dt>
+    <dt><span class="part-name"><a href=
+    "@HOMEPAGE@/man/tput.1.html">tput</a></span> and <span class=
+    "part-name"><a href=
+    "@HOMEPAGE@/man/tset.1.html">tset</a></span></dt>
 
     <dd>
       <ul>
-        <li>replace check in <span class="part-name">reset</span>
-        command for obsolete &ldquo;<tt>pt</tt>&rdquo; capability
-        using <tt>tbc</tt> and <tt>hts</tt> capabilities as
-        clues</li>
-
-        <li>modify <span class="part-name">reset</span> to allow
-        for tabstops at intervals other than 8.</li>
-
-        <li>change <span class="part-name">reset</span>'s behavior
-        for margins to simply clear soft-margins if possible,
-        rather than clearing and then setting them according to the
-        terminal's width.</li>
-      </ul>
-    </dd>
+        <li>
+          <p>add &ldquo;<code>-v</code>&rdquo; option to tput, to
+          show warnings</p>
+        </li>
 
-    <dt><span class="part-name">tput</span>
-    </dt>
+        <li>
+          <p>modify <em>reset</em> command to avoid altering clocal
+          if the terminal uses a modem</p>
+        </li>
 
-    <dd>
-      <ul>
-        <li>add &ldquo;<tt>x</tt>&rdquo; to <tt>getopt</tt> string
-        so that &ldquo;<tt>tput&nbsp;-x&nbsp;clear</tt>&rdquo;
-        works.</li>
+        <li>
+          <p>modify <em>reset</em> feature to avoid 1-second sleep
+          if running in a pseudo-terminal</p>
+        </li>
       </ul>
     </dd>
   </dl>
 
-  <p>Several changes were made to the generated ncurses*config
-  scripts and the analogous &ldquo;<tt>.pc</tt>&rdquo; files to
-  reduce differences between the configurations they report:</p>
-
-  <ul>
-    <li>
-      <p>modified the ncurse*-config and pc-files to more closely
-      match for the <tt>-I</tt> and <tt>-l</tt> options.</p>
-    </li>
-
-    <li>
-      <p>filtered out linker-specs from the <tt>--libs</tt>
-      report.</p>
-    </li>
-
-    <li>
-      <p>amended the ncurses*-config and pc-files to take into
-      account the rpath hack which differed between those
-      files.</p>
-    </li>
-
-    <li>
-      <p>modified generated ncurses*config and ncurses.pc,
-      ncursesw.pc, etc., to list helper libraries such as gpm for
-      static linking.</p>
-    </li>
-  </ul>
-
   <h4><a name="h4-examples" id="h4-examples">Examples</a></h4>
 
   <p>Along with the library and utilities, improvements were made
   to the <a href=
-  "@HOMEPAGE@/ncurses-examples.html">ncurses-examples</a>. Most of
-  this activity aimed at improving the test-packages. A few changes
-  are more generally useful, e.g., for the main ncurses
-  test-program, and for analyzing traces using the
-  <em>tracemunch</em> script:</p>
+  "@HOMEPAGE@/ncurses-examples.html">ncurses-examples</a>:</p>
 
   <ul>
     <li>
-      <p>improve recovery from error when reading command-character
-      in <tt>test/ncurses.c</tt>, showing the relevant error
-      message and not exiting on EINTR.</p>
+      <p>modify <code>test_tparm</code> to account for extended
+      capabilities</p>
     </li>
 
     <li>
-      <p>improve <em>tracemunch</em>, by keeping track of
-      <tt>TERMINAL*</tt> values, and if tracing was first turned on
-      after initialization, attempt to show distinct screen, window
-      and terminal names anyway.</p>
+      <p>corrected mouse mask in <code>test/testcurs.c</code></p>
     </li>
 
     <li>
-      <p>modify <em>tracemunch</em> to accept filename parameters
-      in addition to use as a pipe/filter.</p>
+      <p>modify <code>test/clip_printw.c</code> to optionally test
+      non-wrapped updates</p>
     </li>
 
     <li>
-      <p>update <em>tracemunch</em> to work with <em>perl
-      5.26.2</em>, which changed the rules for escaping regular
-      expressions.</p>
+      <p>modify <code>test/test_mouse.c</code> to use curses api
+      for raw/noraw</p>
     </li>
 
     <li>
-      <p>add some checks in <em>tracemunch</em> for undefined
-      variables.</p>
-    </li>
-
-    <li>
-      <p>modify <tt>TurnOn</tt>/<tt>TurnOff</tt> macros (in
-      lib_vidattr.c and lib_vid_attr.c) to avoid expansion of
-      &ldquo;<tt>CUR</tt>&rdquo; in trace.</p>
+      <p>modify <code>test/clip_printw.c</code> to optionally test
+      non-wrapped updates</p>
     </li>
   </ul>
 
-  <p>There are other new demo/test programs and reusable
-  examples:</p>
+  <p>There is one new demo/test programs:</p>
 
   <dl>
-    <dt><span class="part-name">color_content</span>
-    </dt>
-
-    <dd>Demonstrate the <tt>color_content</tt> and
-    <tt>extended_color_content</tt> functions.</dd>
-
-    <dt><span class="part-name">demo_tabs</span>
-    </dt>
-
-    <dd>A simple demo of tabs in curses.</dd>
-
-    <dt><span class="part-name">dump_window</span>
-    </dt>
-
-    <dd>A portable curses screen-dump, used to compare ncurses
-    screen contents with Solaris.</dd>
-
-    <dt><span class="part-name">pair_content</span>
-    </dt>
-
-    <dd>Demonstrate the <tt>pair_content</tt> and
-    <tt>extended_pair_content</tt> functions.</dd>
-
-    <dt><span class="part-name">report_hashing</span>
-    </dt>
-
-    <dd>Check hash-tables used for terminfo and termcap names.</dd>
-
-    <dt><span class="part-name">parse_rgb</span>
+    <dt><span class="part-name"><em>test/test_endwin.c</em></span>
     </dt>
 
-    <dd>Sample implementation of the ncurses RGB extension from
-    <a href="@HOMEPAGE@/man/user_caps.5.html">user_caps.5</a>, used
-    in <em>picsmap</em> and <em>savescreen</em> programs.</dd>
+    <dd>
+      <p>This program shows the return-status from
+      <code>endwin</code> with different combinations of
+      <code>endwin</code> (repeated), <code>initscr</code>,
+      <code>newterm</code>.</p>
+    </dd>
   </dl>
 
-  <p>A variety of improvements were made to existing programs, both
-  new features as well as options added to make the set of programs
-  more consistent.</p>
+  <h3><a name="h3-database" id="h3-database">Terminal database</a></h3>
+
+  <p>There are several new terminal descriptions:</p>
 
   <ul>
     <li>
-      <p>add &ldquo;<tt>-l</tt>&rdquo; option to test/background,
-      to dump screen contents in a form that lets different curses
-      implementations be compared.</p>
+      <p><a href=
+      "@HOMEPAGE@/terminfo.src.html#tic-ansi_apparrows"><tt>ansi+apparrows</tt></a></p>
     </li>
 
     <li>
-      <p>add &ldquo;<tt>@</tt>&rdquo; command to test/ncurses
-      F-test, to allow rapid jump to different character pages.</p>
+      <p><a href=
+      "@HOMEPAGE@/terminfo.src.html#tic-contour"><tt>contour</tt></a></p>
     </li>
 
     <li>
-      <p>added enum, regex examples to test/demo_forms</p>
+      <p><a href=
+      "@HOMEPAGE@/terminfo.src.html#tic-linux_kbs"><tt>linux+kbs</tt></a>
+      for terminals which imitate xterm's behavior with Linux</p>
     </li>
 
     <li>
-      <p>amend Scaled256() macro in test/picsmap.c to cover the
-      full range 0..1000</p>
+      <p><a href=
+      "@HOMEPAGE@/terminfo.src.html#tic-rio"><tt>rio</tt></a>,
+      <a href=
+      "@HOMEPAGE@/terminfo.src.html#tic-rio-direct"><tt>rio-direct</tt></a></p>
     </li>
 
     <li>
-      <p>corrected pathname used in Ada95 sample programs for
-      <tt>explain.txt</tt>, to work with test-packages, and used an
-      awk script to split the resulting pathname when it would be
-      too long for a single line.</p>
+      <p><a href=
+      "@HOMEPAGE@/terminfo.src.html#tic-mostlike"><tt>mostlike</tt></a></p>
     </li>
 
     <li>
-      <p>ignore interrupted system-call in test/ncurses's
-      command-line, e.g., if the terminal were resized.</p>
+      <p><a href=
+      "@HOMEPAGE@/terminfo.src.html#tic-ms-vt100-16color"><tt>ms-vt100-16color</tt></a>,
+      <a href=
+      "@HOMEPAGE@/terminfo.src.html#tic-winconsole"><tt>winconsole</tt></a></p>
     </li>
 
     <li>
-      <p>improved ifdef's for <tt>TABSIZE</tt> variable, to help
-      with AIX/HPUX ports.</p>
+      <p><a href=
+      "@HOMEPAGE@/terminfo.src.html#tic-vt100_noapp"><tt>vt100+noapp</tt></a>,
+      <a href=
+      "@HOMEPAGE@/terminfo.src.html#tic-vt100_noapp_pc"><tt>vt100+noapp+pc</tt></a>,
+      <a href=
+      "@HOMEPAGE@/terminfo.src.html#tic-xterm_app_pc"><tt>xterm+app+pc</tt></a>,
+      <a href=
+      "@HOMEPAGE@/terminfo.src.html#tic-xterm_decedit"><tt>xterm+decedit</tt></a>
+      from <a href="@WEBSITE@/xterm/xterm.log.html#xterm_389">xterm
+      #389</a></p>
     </li>
-  </ul>
-
-  <h3><a name="h3-database" id="h3-database">Terminal database</a></h3>
-
-  <p>There are several new terminal descriptions:</p>
-
-  <blockquote style="word-break:keep-all">
-    <p><tt>alacritty</tt>, <tt>domterm</tt>, <tt>kitty</tt>,
-    <tt>mintty</tt>, <tt>mintty-direct</tt>, <tt>ms-terminal</tt>,
-    <tt>n7900</tt>, <tt>nsterm-build309</tt>,
-    <tt>nsterm-direct</tt>, <tt>screen5</tt>, <tt>ti703</tt>,
-    <tt>ti707</tt>, <tt>ti703-w</tt>, <tt>ti707-w</tt>
-    <tt>vscode</tt>, <tt>vscode-direct</tt>, <tt>xterm-mono</tt>,
-    <tt>xterm.js</tt></p>
-  </blockquote>
 
-  <p>There are many changes to existing terminal descriptions. Some
-  were updates to several descriptions:</p>
-
-  <ul>
-    <li>use <a href=
-    "/ncurses/terminfo.src.html#tic-ansi_rep"><tt>ansi+rep</tt></a>
-    in a dozen places</li>
-
-    <li>add rs1 to konsole, mlterm</li>
-
-    <li>improve several flash capabilities with trailing mandatory
-    delays</li>
-
-    <li>drop <tt>ich1</tt> from <tt>rxvt-basic</tt>, <tt>Eterm</tt>
-    and <tt>mlterm</tt> to improve compatibility with old
-    non-curses programs</li>
-
-    <li>add/use <a href=
-    "/ncurses/terminfo.src.html#tic-xterm_keypad"><tt>xterm+keypad</tt></a>
-    in <tt>xterm-new</tt></li>
-
-    <li>use <a href=
-    "/ncurses/terminfo.src.html#tic-xterm_sl-twm"><tt>xterm+sl-twm</tt></a>
-    for consistency, nine places</li>
+    <li>
+      <p><a href=
+      "@HOMEPAGE@/terminfo.src.html#tic-putty_cursor"><tt>putty+cursor</tt></a>
+      to reflect amending of modified cursor-keys in 2021</p>
+    </li>
 
-    <li>improve <em>xm</em> example in <a href=
-    "/ncurses/terminfo.src.html#tic-xterm_x11mouse">xterm+x11mouse</a>
-    and <a href=
-    "/ncurses/terminfo.src.html#tic-xterm_sm_1006">xterm+sm_1006</a>.</li>
+    <li>
+      <p><a href=
+      "@HOMEPAGE@/terminfo.src.html#tic-wezterm"><tt>wezterm</tt></a></p>
+    </li>
   </ul>
 
-  <p>while others affected specific descriptions. These were
-  retested, to take into account changes by their developers:</p>
-
-  <blockquote>
-    <p><tt>terminator</tt>, <tt>st</tt></p>
-  </blockquote>
-
-  <p>while these are specific fixes based on reviewing
-  documentation, user reports, or warnings from <span class=
-  "part-name">tic</span>:</p>
-
-  <dl>
-    <dt><a href=
-    "/ncurses/terminfo.src.html#tic-adds200">adds200</a>:</dt>
-
-    <dd>
-      <ul>
-        <li>fix typo</li>
-      </ul>
-    </dd>
-
-    <dt><a href=
-    "/ncurses/terminfo.src.html#tic-gnome-256color">gnome-256color</a>
-    </dt>
-
-    <dd>
-      <ul>
-        <li>base entry on "gnome", not "vte", for consistency</li>
-      </ul>
-    </dd>
-
-    <dt><a href=
-    "/ncurses/terminfo.src.html#tic-interix">interix</a>
-    </dt>
-
-    <dd>
-      <ul>
-        <li>trim unnecessary setf/setb</li>
-      </ul>
-    </dd>
-
-    <dt><a href=
-    "/ncurses/terminfo.src.html#tic-linux-16color">linux-16color</a>
-    </dt>
-
-    <dd>
-      <ul>
-        <li>accommodate <a href=
-        "https://lists.gnu.org/archive/html/bug-ncurses/2019-10/msg00061.html">
-        Linux console driver</a> incompatibility introduced in
-        early 2018</li>
-      </ul>
-    </dd>
-
-    <dt><a href=
-    "/ncurses/terminfo.src.html#tic-nsterm-256color">nsterm-256color</a>:</dt>
-
-    <dd>
-      <ul>
-        <li>add nsterm-build309 to replace nsterm-256color,
-        assigning the latter as an alias of nsterm, to make mouse
-        work with nsterm-256color</li>
-      </ul>
-    </dd>
-
-    <dt><a href=
-    "/ncurses/terminfo.src.html#tic-regent40">regent40</a>:</dt>
-
-    <dd>
-      <ul>
-        <li>renumber function-keys to match manual</li>
-      </ul>
-    </dd>
-
-    <dt><a href=
-    "/ncurses/terminfo.src.html#tic-regent60">regent60</a>:</dt>
-
-    <dd>
-      <ul>
-        <li>add cd (clr_eos)</li>
-
-        <li>corrected acsc</li>
-
-        <li>add shifted function-keys</li>
-      </ul>
-    </dd>
-
-    <dt><a href=
-    "/ncurses/terminfo.src.html#tic-tvi950">tvi950</a>:</dt>
-
-    <dd>
-      <ul>
-        <li>added function-key definitions to agree with Televideo
-        950 manual</li>
-
-        <li>corrected acsc</li>
+  <p>There are many changes to existing terminal descriptions. Some
+  were updates to several descriptions, using the
+  <code>infocmp</code> &ldquo;<code>-u</code>&rdquo; option in a
+  script to determine which <em>building-block</em> entries could
+  be used to replace multiple capability settings (and trim
+  redundant information).</p>
 
-        <li>remove bogus kf0</li>
+  <p>Other changes include:</p>
 
-        <li>add bel</li>
-      </ul>
-    </dd>
+  <ul>
+    <li>
+      <p><a href=
+      "@HOMEPAGE@/terminfo.src.html#toc-_X_T_E_R_M__Extensions_">document</a>
+      XF, kxIN and kxOUT</p>
+    </li>
 
-    <dt><a href=
-    "/ncurses/terminfo.src.html#tic-tvi955">tvi955</a>:</dt>
+    <li>
+      <p>add note on <a href=
+      "@HOMEPAGE@/terminfo.src.html#tic-sun"><tt>sun</tt></a>
+      regarding wscons/cmdtool/shelltool</p>
+    </li>
 
-    <dd>
-      <ul>
-        <li>fix typo</li>
-      </ul>
-    </dd>
+    <li>
+      <p>remove DECCOLM+DECSCLM from <a href=
+      "@HOMEPAGE@/terminfo.src.html#tic-foot"><tt>foot</tt></a></p>
+    </li>
 
-    <dt><a href=
-    "/ncurses/terminfo.src.html#tic-vi200">vi200</a>:</dt>
+    <li>
+      <p>add xterm+focus to <a href=
+      "@HOMEPAGE@/terminfo.src.html#tic-foot_base"><tt>foot+base</tt></a></p>
+    </li>
 
-    <dd>
-      <ul>
-        <li>add acsc string, including right/down-arrow</li>
-      </ul>
-    </dd>
+    <li>
+      <p>add ecma+strikeout to <a href=
+      "@HOMEPAGE@/terminfo.src.html#tic-putty"><tt>putty</tt></a></p>
+    </li>
 
-    <dt><a href=
-    "/ncurses/terminfo.src.html#tic-wy50">wy50</a>:</dt>
+    <li>
+      <p>use CSI 3J in <a href=
+      "@HOMEPAGE@/terminfo.src.html#tic-vte-2017"><tt>vte-2017</tt></a></p>
+    </li>
 
-    <dd>
-      <ul>
-        <li>corrected acsc</li>
-      </ul>
-    </dd>
+    <li>
+      <p>use oldxterm+sm+1006 in <a href=
+      "@HOMEPAGE@/terminfo.src.html#tic-vte-2014"><tt>vte-2014</tt></a></p>
+    </li>
 
-    <dt><a href="/ncurses/terminfo.src.html#tic-wy50">wy50</a> and
-    <a href="/ncurses/terminfo.src.html#tic-wy60">wy60</a>:</dt>
+    <li>
+      <p>modify <a href=
+      "@HOMEPAGE@/terminfo.src.html#tic-xgterm"><tt>xgterm</tt></a>
+      to work around line-drawing bug</p>
+    </li>
 
-    <dd>
-      <ul>
-        <li>add shifted function-keys as kF1 to kF16</li>
-      </ul>
-    </dd>
+    <li>
+      <p>add xterm focus mode 1004 to <a href=
+      "@HOMEPAGE@/terminfo.src.html#tic-xterm_focus"><tt>xterm+focus</tt></a>
+      as fe/fd capabilities, like vim.</p>
+    </li>
 
-    <dt><a href=
-    "/ncurses/terminfo.src.html#tic-xterm_x11hilite">xterm+x11hilite</a>:</dt>
+    <li>
+      <p>add xterm+focus to <a href=
+      "@HOMEPAGE@/terminfo.src.html#tic-alacritty_common"><tt>alacritty+common</tt></a></p>
+    </li>
 
-    <dd>
-      <ul>
-        <li>eliminate unused <em>p5</em> parameter.</li>
-      </ul>
-    </dd>
-  </dl>
+    <li>
+      <p>add XR/xr, to work with vim, and use RV/rv to denote DA2
+      and its response</p>
+    </li>
 
-  <p>A few entries use extensions (user-defined terminal
-  capabilities):</p>
+    <li>
+      <p>add XF flag to <a href=
+      "@HOMEPAGE@/terminfo.src.html#tic-xterm_focus"><tt>xterm+focus</tt></a>
+      so that termcap applications can be aware of terminals which
+      may support focus in/out</p>
+    </li>
 
-  <ul>
-    <li>use <a href=
-    "/ncurses/terminfo.src.html#tic-xterm_sm_1006"><tt>xterm+sm+1006</tt></a>
-    (aka &ldquo;SGR 1006 mouse&rdquo;) for konsole-base and
-    putty</li>
+    <li>
+      <p>use xterm+focus in <a href=
+      "@HOMEPAGE@/terminfo.src.html#tic-xterm-p370"><tt>xterm-p370</tt></a>
+      and <a href=
+      "@HOMEPAGE@/terminfo.src.html#tic-tmux"><tt>tmux</tt></a></p>
+    </li>
 
-    <li>add <em><tt>Smol/Rmol</tt></em> user-defined capability to
-    <tt>tmux</tt> and <tt>vte-2018</tt></li>
+    <li>
+      <p>remove xterm+sm+1006 from <a href=
+      "@HOMEPAGE@/terminfo.src.html#tic-tmux"><tt>tmux</tt></a></p>
+    </li>
 
-    <li>add <em><tt>Smulx</tt></em> user-defined capability to
-    <tt>tmux</tt>, <tt>vte-2018</tt></li>
+    <li>
+      <p>NetBSD-related fixes for <a href=
+      "@HOMEPAGE@/terminfo.src.html#tic-x68k"><tt>x68k</tt></a> and
+      <a href=
+      "@HOMEPAGE@/terminfo.src.html#tic-wsvt25"><tt>wsvt25</tt></a></p>
+    </li>
   </ul>
 
   <h3><a name="h3-documentation" id=
@@ -997,88 +714,69 @@
       <p>Corrections:</p>
 
       <ul>
-        <li>correct error-returns listed in manual pages for a few
-        form functions</li>
+        <li>
+          <p>add assignment in <code>CF_MAN_PAGES</code> to fill in
+          value for <code>TERMINFO_DIRS</code> in ncurses, terminfo
+          and tic manpages.</p>
+        </li>
 
-        <li>corrected prototypes in several manpages using script
-        to extract those in compilable form.</li>
+        <li>
+          <p>clarify interaction of <code>-R</code> option versus
+          <code>-C</code>, <code>-I</code> and <code>-r</code> in
+          <code>infocmp</code> manpage.</p>
+        </li>
 
-        <li>fix typo in <a href=
-        "@HOMEPAGE@/man/term.5.html#h3-EXTENDED-NUMBER-FORMAT">term.5</a>,
-        improve explanation of format</li>
-      </ul>
-    </li>
+        <li>
+          <p>correct manpage description of panel_hidden.</p>
+        </li>
 
-    <li>
-      <p>Clarify in manual pages that <a href=
-      "@HOMEPAGE@/man/curs_printw.3x.html#h2-PORTABILITY">vwprintw</a>
-      and <a href=
-      "@HOMEPAGE@/man/curs_scanw.3x.html#h2-PORTABILITY">vwscanw</a>
-      are obsolete.<br>
-      They have not been part of X/Open Curses since 2007.</p>
-    </li>
+        <li>
+          <p>improve manpage description for addch versus unctrl
+          format used for non-printable characters.</p>
+        </li>
 
-    <li>
-      <p>New/improved history and portability sections:</p>
+        <li>
+          <p>improve manpages discussing file descriptors in
+          low-level functions.</p>
+        </li>
 
-      <ul>
-        <li><a href=
-        "@HOMEPAGE@/man/curs_addch.3x.html#h3-ACS-Symbols">curs_addch.3x</a>
-        gives some background for ACS symbols.</li>
-
-        <li><a href=
-        "@HOMEPAGE@/man/curs_getcchar.3x.html#h2-PORTABILITY">curs_getcchar.3x</a>
-        explains a difference between ncurses and X/Open
-        Curses.</li>
-
-        <li><a href=
-        "@HOMEPAGE@/man/curs_getstr.3x.html#h2-PORTABILITY">curs_getstr.3x</a>
-        gives historical/portability background for the length
-        parameter of <tt>wgetnstr</tt>.</li>
-
-        <li><a href=
-        "@HOMEPAGE@/man/curs_slk.3x.html">curs_slk.3x</a> lists a
-        few differences between SVr4 curses and X/Open Curses for
-        soft-keys.</li>
-
-        <li><a href=
-        "@HOMEPAGE@/man/curs_terminfo.3x.html">curs_terminfo.3x</a>
-        explains that the initial implementation of terminfo in
-        SVr2 was mostly replaced by other developers in SVr3.</li>
-
-        <li><a href="@HOMEPAGE@/man/infocmp.1m.html">infocmp.1</a>
-        explains that the initial version of terminfo had no tool
-        for decompiling descriptions. That came later, with SVr3,
-        with a different developer.</li>
-
-        <li><a href="@HOMEPAGE@/man/tabs.1.html">tabs.1</a> tells more
-        than you wanted to know about the tool.</li>
-
-        <li><a href="@HOMEPAGE@/man/tic.1m.html">tic.1</a> explains
-        that the initial version of terminfo had a rudimentary tool
-        (based on termcap) for compiling entries. The tool used
-        with Unix was developed by others for SVr3.</li>
-
-        <li><a href="@HOMEPAGE@/man/toe.1m.html">toe.1</a> explains
-        the origin of this tool.</li>
+        <li>
+          <p>improve description of search rules for terminal
+          descriptions in terminfo manpage.</p>
+        </li>
+
+        <li>
+          <p>modify dist.mk to avoid passing developer's comments
+          in manpages into the generated html documentation.</p>
+        </li>
+
+        <li>
+          <p>modify test-package "ncurses6-doc" to use
+          manpage-aliases, which in turn required a change to the
+          configure script to factor in the extra-suffix option
+          when deriving alias names.</p>
+        </li>
       </ul>
     </li>
 
     <li>
-      <p>Improvements for <a href=
-      "@HOMEPAGE@/man/user_caps.5.html">user_caps.5</a>:</p>
+      <p>New/improved history and portability sections:</p>
 
       <ul>
-        <li>mention <tt>meml</tt>, <tt>memu</tt> and
-        <tt>box1</tt></li>
-
-        <li>expanded description of <tt>XM</tt></li>
+        <li>
+          <p>add information about "ttycap", termcap's forerunner,
+          to tset.1</p>
+        </li>
 
-        <li>add a clarification regarding the <tt>RGB</tt>
-        capability.</li>
+        <li>
+          <p>document limitations of tparm, and error-returns in
+          curs_terminfo.3x</p>
+        </li>
 
-        <li>mention user_caps.5 in the tic and infocmp manual
-        pages.</li>
+        <li>
+          <p>document limitations of tgoto, and error-returns in
+          curs_termcap.3x</p>
+        </li>
       </ul>
     </li>
 
@@ -1086,49 +784,20 @@
       <p>Other improvements:</p>
 
       <ul>
-        <li><a href=
-        "@HOMEPAGE@/man/curs_add_wch.3x.html#h3-Line-Graphics">curs_add_wch.3x</a>
-        adds note about Unicode terminology for the line-drawing
-        characters.</li>
-
-        <li><a href=
-        "@HOMEPAGE@/man/curs_color.3x.html#h2-RETURN-VALUE">curs_color.3x</a>
-        improves discussion of error returns and extensions.</li>
-
-        <li><a href=
-        "@HOMEPAGE@/man/curs_mouse.3x.html">curs_mouse.3x</a>
-        explains how the <tt>kmous</tt> and <tt>XM</tt>
-        capabilities are used for xterm-mouse input.</li>
-
-        <li><a href=
-        "@HOMEPAGE@/man/curs_refresh.3x.html#h3-wnoutrefresh_doupdate">
-        curs_refresh.3x</a> improves documentation regarding the
-        virtual and physical screens.</li>
-
-        <li><a href=
-        "@HOMEPAGE@/man/curs_util.3x.html">curs_util.3x</a>
-        mentions a difference between SVr4 and X/Open Curses for
-        <tt>unctrl.h</tt></li>
-
-        <li><a href=
-        "@HOMEPAGE@/man/curs_variables.3x.html#h2-PORTABILITY">curs_variables.3x</a>
-        improves description of the <em>init_tabs</em> capability
-        and <tt>TABSIZE</tt> variable.</li>
-
-        <li><a href=
-        "@HOMEPAGE@/man/ncurses.3x.html#h2-ALTERNATE-CONFIGURATIONS">
-        ncurses.3x</a> improves documentation regarding
-        feature-test macros in curses.h</li>
-
-        <li><a href=
-        "@HOMEPAGE@/man/resizeterm.3x.html#h3-resize_term">resizeterm.3x</a>
-        about top-level windows which touch the screen's
-        borders.</li>
-
-        <li><a href=
-        "@HOMEPAGE@/man/tput.1.html#h3-Terminal-Size">tput.1</a>
-        clarifies how <em>tput</em> determines the terminal
-        size.</li>
+        <li>
+          <p>This release has many changes to improve the
+          formatting and style of the manpages.</p>
+        </li>
+
+        <li>
+          <p>Manpages now use consistent section-naming, page
+          headers and footers (including the modification date for
+          each page).</p>
+        </li>
+
+        <li>
+          <p>Table layout has been revised.</p>
+        </li>
       </ul>
     </li>
   </ul>
@@ -1136,248 +805,165 @@
   <p>There are no new manual pages (all of the manual page updates
   are to existing pages).</p>
 
-  <p>Some of the improvements are more subtle, relating to the way
-  the information is presented. For instance, the generated
-  terminfo.5 file uses a different table layout, allowing it to use
-  space on wide terminals more effectively.</p>
-
   <h3><a name="h3-bug-fixes" id="h3-bug-fixes">Interesting
   bug-fixes</a></h3>
 
-  <p>While there were many bugs fixed during development of ncurses
-  6.2, only a few (the reason for this release) were both important
-  and interesting. Most of the bug-fixes were for local issues
-  which did not affect compatibility across releases. Since those
-  are detailed in the NEWS file no elaboration is needed here.</p>
-
-  <p>The interesting bugs were in tic/infocmp's handling of
-  user-defined capabilities. These were not recent bugs. Initially
-  it was a simple problem:</p>
+  <p>The changes to <tt>tparm</tt>, <tt>tgoto</tt> which improve
+  the design of the low-level interfaces are <em>interesting</em>,
+  but are not bug-fixes <em>per se</em>.</p>
 
-  <ul>
-    <li>The user-defined capabilities can be any type (boolean,
-    number or string), but once given a type all uses of the name
-    must conform to that type&mdash;unless some special support for
-    a particular multi-typed name is built into ncurses.</li>
+  <h3><a name="h3-config-config" id=
+  "h3-config-config">Configuration changes</a></h3>
 
-    <li>
-      <p>One of simpleterm's contributors copied some definitions
-      for using <em>tmux</em>'s user-defined capabilities in
-      <a href=
-      "https://git.suckless.org/st/commit/06f8cf8ca87a81db15816658c40b2afcd1ad5332.html">
-      late in 2016</a>.</p>
+  <h4><a name="h4-config-major" id="h4-config-major">Major
+  changes</a></h4>
 
-      <blockquote>
-        <pre class="demo-name">
-diff --git a/st.info b/st.info
-@@ -185,7 +185,10 @@ st| simpleterm,
-  tsl=\E]0;,
-  xenl,
-  vpa=\E[%i%p1%dd,
--
-+# Tmux unofficial extensions, see TERMINFO EXTENSIONS in tmux(1)
-+ Se,
-+ Ss,
-+ Tc,
- 
- st-256color| simpleterm with 256 colors,
-  use=st,
-</pre>
-      </blockquote>
-    </li>
+  <p>These are the major changes (aside from introducing <a href=
+  "#h4-new-library"><tt>tiparm_s</tt></a>):</p>
 
+  <ul>
     <li>
-      <p>Later, in (referring to a version from <a href=
-      "https://git.suckless.org/st/commit/c0882f2ed1d7a2dd0fa2efa52157e6fc6fde3652.html">
-      mid-2017</a>), a user asked to have it updated in
-      ncurses.</p>
+      <p>use wide-character (ncursesw) by default</p>
     </li>
 
     <li>
-      <p>However, it had an error from the change in late 2016. The
-      terminal description made what <em>tmux</em> expected to be
-      <strong>string</strong> actually a
-      <strong>boolean</strong>.</p>
-
-      <p>Over the years, there were problems with each of
-      simpleterm's terminal descriptions. I repaired those, and
-      usually dealt with the problem.</p>
+      <p>use opaque typedefs by default</p>
     </li>
+  </ul>
+
+  <p>However, most of the work on configure scripts was done to
+  reduce warnings within the configure script:</p>
 
+  <ul>
     <li>
-      <p>The difference in this case was that when compiling the
-      terminal database, <em>tic</em> may have in memory the
-      definitions for more than one terminal description (so that
-      it can resolve &ldquo;<tt>use=</tt>&rdquo; clauses). Seeing
-      two different types for the same name, in certain situations
-      it would incorrectly merge the symbol tables for the two
-      terminal descriptions.</p>
+      <p>intrusive warnings from GNU grep regarding fgrep and
+      egrep</p>
     </li>
 
     <li>
-      <p>On simpleterm's side, their bug was finally fixed in
-      <a href=
-      "https://git.suckless.org/st/commit/83866428de031300eab03fbb116bcf7d2b1d4f60.html">
-      late 2019</a>, three years after the bug was created.</p>
+      <p>fatal errors in compile-checks, arising from recent
+      &ldquo;Modern&nbsp;C&rdquo; efforts by some developers which
+      caused longstanding configure checks to fail.</p>
+
+      <p>After repairing the configure script, none of that
+      activity affected ncurses because stricter warnings are used
+      routinely in development.</p>
     </li>
   </ul>
 
-  <p>For ncurses, the elapsed time to fix this bug was less than
-  three years. Someone reported a problem with the terminal
-  description a few weeks after releasing ncurses 6.1 (in <a href=
-  "https://github.com/tmux/tmux/issues/1264">tmux #1264</a>), and
-  the terminal description was updated that week (ncurses patch
-  <a href="@HOMEPAGE@/NEWS.html#t20180224">20180224</a>):</p>
-
-  <blockquote>
-    <pre class="demo-name">
-20180224
-        + modify _nc_resolve_uses2() to detect incompatible types when merging
-          a "use=" clause of extended capabilities.  The problem was seen in a
-          defective terminfo integrated from simpleterm sources in 20171111,
-          compounded by repair in 20180121.
-        + correct Ss/Ms interchange in st-0.7 entry (tmux #1264) -TD
-</pre>
-  </blockquote>
-
-  <p>The larger part of that change added a check to prevent a
-  simple merge of terminal descriptions where the same user-defined
-  name was used with different types. But it raised some
-  questions:</p>
+  <p>Other improvements made to configure checks include</p>
 
   <ul>
     <li>
-      <p>Was there a reliable way to manage terminal descriptions
-      which used the same extended name in different ways?</p>
+      <p>use <a href=
+      "@HOMEPAGE@/INSTALL.html#option:enable-string-hacks">string-hacks</a>
+      in alloc_entry.c, alloc_type.c and hardscroll.c, overlooked
+      due to compiler changes in recent OpenBSD releases</p>
     </li>
 
     <li>
-      <p>Should ncurses provide a registry of well-known extended
-      names, with their types?</p>
+      <p>revise progs.priv.h to provide for NC_ISATTY reuse</p>
     </li>
-  </ul>
-
-  <p>Since the correction to <a href=
-  "@HOMEPAGE@/ncurses.html#download_database"><tt>terminfo.src</tt></a>
-  could have been readily adopted by packagers, there was nothing
-  more to be done from ncurses' standpoint on that part. But
-  improving ncurses to prevent issues like that is the reason for
-  making a release.</p>
 
-  <p>Nothing more (constructive) was mentioned with regard to
-  simpleterm. But a few problems were found in the handling of
-  user-defined capabilities:</p>
+    <li>
+      <p>configure check for MB_LEN_MAX provides warning as
+      needed</p>
+    </li>
 
-  <ul>
     <li>
-      <p>Forward-references to user-defined capabilities in a
-      &ldquo;<tt>use=</tt>&rdquo; clause did not allocate new data
-      for each use. In <em>tic</em>, successive compilation of
-      terminal entries could add user-defined capabilities to the
-      wrong terminal entry.</p>
+      <p>trim a space after some "-R" options, fixing builds for
+      applications built using clang and ncurses on Solaris</p>
+    </li>
 
-      <p>This was not noticed before, since xterm's terminal
-      descriptions were the main users of the feature, and almost
-      all of the uses of the building-blocks which contained
-      user-defined capabilities were backward-references.</p>
+    <li>
+      <p>work around misconfiguration of MacPorts gcc13, which
+      exposes invalid definition of <tt>MB_LEN_MAX</tt> in gcc's
+      fallback copy of <tt>limits.h</tt></p>
     </li>
 
     <li>
-      <p>There is one (documented) case where ncurses 6.1 supports
-      a user-defined capability that could be any type (i.e.,
-      &ldquo;RGB&rdquo;). The check added in February 2018 to guard
-      against mismatches did not handle all of the combinations
-      needed.</p>
+      <p>modified experimental Windows driver works with xterm
+      mouse protocol</p>
     </li>
   </ul>
 
-  <p>Both of these issues dated from the original implementation of
-  user-defined capabilities. Fixing them does not change the
-  terminal database, but a older <em>tic</em> without the fixes
-  will not be able to handle terminfo sources which rely upon those
-  fixes. Starting in June 2019, the download link for the terminfo
-  source file was capped at that date. The development sources have
-  an up-to-date copy of the file, for people with a legitimate need
-  for it.</p>
-
-  <p>The &ldquo;<tt>-c</tt>&rdquo; (check) option of <em>tic</em>
-  is not very useful if it cannot offer advice on parameters needed
-  for user-defined capabilities. The various <em>Caps</em> files
-  were reorganized to reduce redundancy, and in the common portion
-  (<a href=
-  "https://github.com/ThomasDickey/ncurses-snapshots/blob/master/include/Caps-ncurses">Caps-ncurses</a>),
-  a registry of user-defined capabilities is provided for use by
-  <em>tic</em>. While users can still define their own custom
-  capabilities, <em>tic</em> will not offer any advice when their
-  parameters do not match.</p>
-
-  <p>In ncurses 6.2, <em>tic</em> makes a special check to allow
-  any type for <em>RGB</em>, but its being able to do this relies
-  upon fixes made in the ncurses library in mid-2019.</p>
-
-  <h3><a name="h3-config-config" id=
-  "h3-config-config">Configuration changes</a></h3>
-
-  <h4><a name="h4-config-major" id="h4-config-major">Major
-  changes</a></h4>
-
-  <p>There are no major changes. Several new options were added to
-  ease integration of packages with systems using different
-  versions of <em>GNAT</em> and <em>ncurses</em>. Also,
-  improvements were made to configure checks.</p>
-
   <h4><a name="h4-config-options" id=
   "h4-config-options">Configuration options</a></h4>
 
-  <p>There are a few new/modified configure options:</p>
+  <p>There are a few new configure options:</p>
 
   <dl>
-    <dt><tt>--with-config-suffix</tt>
+    <dt><a href=
+    "@HOMEPAGE@/INSTALL.html#option:disable-setuid-environ"><tt>--disable-setuid-environ</tt></a>
     </dt>
 
     <dd>
-      <p>helps work around a filename conflict with Debian packages
-      versus test-packages.</p>
+      <p>Compile with environment restriction, so certain
+      environment variables are not available when running via a
+      setuid/setgid application. These are (for example
+      <tt>$TERMINFO</tt>) those that allow the search path for the
+      terminfo or termcap entry to be customized.</p>
+
+      <p>A setuid/setgid application inherits its environment
+      variables from the current user, in contrast to sudo which
+      may limit the environment variables that ncurses uses.</p>
     </dd>
 
-    <dt><tt>--with-ada-libname</tt>
+    <dt><a href=
+    "@HOMEPAGE@/INSTALL.html#option:enable-check-size"><tt>--enable-check-size</tt></a>
     </dt>
 
     <dd>
-      <p>allows one to rename the &ldquo;AdaCurses&rdquo; library
-      (at least one packager prefers a lowercase name).</p>
+      <p>Compile-in feature to detect screensize for terminals
+      which do not advertise their screensize, e.g., serial
+      terminals.</p>
     </dd>
 
-    <dt><tt>--with-fallbacks</tt>
+    <dt><a href=
+    "@HOMEPAGE@/INSTALL.html#option:with-abi-altered"><tt>--with-abi-altered=<em>NUM</em></tt></a>
     </dt>
 
     <dd>
-      <p>now ensures there is a value, and adds the fallback
-      information to top-level Makefile summary.</p>
+      <p>Override the displayed (rather than compiled-in) ABI. Only
+      packagers who have created configurations where the ABI
+      differs from ncurses should be interested in this option.</p>
     </dd>
 
-    <dt><tt>--with-pcre2</tt>
+    <dt><a href=
+    "@HOMEPAGE@/INSTALL.html#option:with-strip-program"><tt>--with-strip-program=<em>XXX</em></tt></a>
     </dt>
 
     <dd>
-      <p>check for pcre-posix library to help with MinGW port.</p>
+      <p>When stripping executables during install, use the
+      specified program rather than &ldquo;strip&rdquo; overriding
+      program chosen by the install program for stripping
+      executables.</p>
     </dd>
+  </dl>
 
-    <dt><tt>--with-tic-path</tt> and<br></dt>
+  <p>These configure options are modified:</p>
 
-    <dt><tt>--with-infocmp-path</tt>
+  <dl>
+    <dt><a href=
+    "@HOMEPAGE@/INSTALL.html#option:with-pkg-config-libdir"><tt>--with-pkg-config-libdir[=<em>DIR</em>]</tt></a>
     </dt>
 
     <dd>
-      <p>help work around problems building fallback source using
-      pre-6.0 tic/infocmp.</p>
+      <p>The optional <em>DIR</em> parameter can now be
+      &ldquo;auto&rdquo; to automatically use pkg-config's library
+      directory.</p>
+
+      <p>The default is <tt>$(libdir)</tt>.</p>
     </dd>
 
-    <dt><tt>--with-versioned-syms</tt>
+    <dt><a href=
+    "@HOMEPAGE@/INSTALL.html#option:with-xterm-kbs"><tt>--with-xterm-kbs[=<em>XXX</em>]</tt></a>
     </dt>
 
     <dd>
-      <p>option value can now be a relative pathname.</p>
+      <p>The default is &ldquo;auto&rdquo; which tells the
+      configure script to choose BS or DEL according to platform
+      defaults.</p>
     </dd>
   </dl>
 
@@ -1388,148 +974,117 @@ diff --git a/st.info b/st.info
 
   <ul>
     <li>
-      <p>ignore <a href=
-      "/ncurses/man/ncurses.3x.html#h3-TERMINFO"><tt>$TERMINFO</tt></a>
-      as a default value in configure script if it came from the
-      <tt>infocmp</tt> <strong><tt>-Q</tt></strong> option.</p>
+      <p>add/use configure check for <code>clock_gettime</code>, to
+      supersede <code>gettimeofday</code>.</p>
     </li>
 
     <li>
-      <p>distinguish gcc from icc and clang when the
-      <tt>--enable-warnings</tt> option is not used, to avoid
-      unnecessary warnings about unrecognized inline options</p>
+      <p>modify configure script check for pkg-config library
+      directory to take into account an older version 0.15.0 which
+      used PKG_CONFIG_PATH but not PKG_CONFIG_LIBDIR</p>
     </li>
 
     <li>
-      <p>consistently prepend new libraries as they are found
-      during configuration, rather than relying upon the linker to
-      resolve order dependencies of libraries.</p>
+      <p>allow for MinGW32-/64-bit configurations to use
+      _DEFAULT_SOURCE</p>
     </li>
 
     <li>
-      <p>modified configure scripts to reduce relinking/ranlib
-      during library install :</p>
-
-      <ul>
-        <li>use &ldquo;<tt>install -p</tt>&rdquo; when available,
-        to avoid need for ranlib of static libraries.</li>
-
-        <li>scripts which use
-        &ldquo;<tt>--disable-relink</tt>;&rdquo; add a 1-second
-        sleep to work around tools which use whole-second
-        timestamps, e.g., in <tt>utime</tt> rather than the actual
-        file system resolution.</li>
-      </ul>
+      <p>modify CF_XOPEN_SOURCE macro's amend default case to avoid
+      undefining _XOPEN_SOURCE if _POSIX_C_SOURCE is defined</p>
     </li>
 
     <li>
-      <p id="getenv-check">add configure check for <a href=
-      "#getenv-fixes"><tt>getenv</tt></a> to work around
-      implementation shown in Emscripten which overwrites the
-      previous return value on each call.</p>
-
-      <p>Use that to optionally suppress <tt>START_TRACE</tt>
-      macro, whose call to <tt>getenv</tt> may not work
-      properly</p>
+      <p>updated configure script macro CF_XOPEN_SOURCE, for
+      uClibc-ng</p>
     </li>
 
     <li>
-      <p>change target configure level for <tt>_XOPEN_SOURCE</tt>
-      to 600 to address use of <tt>vsscanf</tt> and
-      <tt>setenv</tt>.</p>
+      <p>modify version-check for gcc/g++, now works for msys2</p>
     </li>
 
     <li>
-      <p>reduce use of <tt>_GNU_SOURCE</tt> for current glibc where
-      <tt>_DEFAULT_SOURCE</tt> combines with
-      <tt>_XOPEN_SOURCE</tt></p>
+      <p>build-fixes related to configure-options and/or
+      platform:</p>
 
-      <p>Allow for Cygwin's newlib when checking for the
-      _DEFAULT_SOURCE symbol.</p>
+      <ul>
+        <li>fix for <tt>--enable-fvisibility</tt></li>
 
-      <p>MidnightBSD is now checked for the
-      <tt>_XOPEN_SOURCE</tt>-related definitions.</p>
-    </li>
+        <li>fix for unusual values of
+        <tt>--with-rel-version</tt></li>
 
-    <li>
-      <p>If the check for <tt>va_copy</tt> or <tt>__va_copy</tt>
-      fails,</p>
+        <li>fix for unusual values of
+        <tt>--with-abi-version</tt></li>
 
-      <ul>
-        <li>configure now tries copying the pointers for
-        <tt>va_list</tt>, or as an array.</li>
+        <li>fix for <tt>--disable-tcap-names</tt></li>
 
-        <li>alternatively, it checks for
-        <tt>__builtin_va_copy</tt>(), which could be used with AIX
-        <tt>xlc</tt> in <em>c89</em> mode.</li>
+        <li>fix for termcap in <tt>nc_access.h</tt></li>
       </ul>
     </li>
 
     <li>
-      <p>several changes to support a port to Ultrix 3.1:</p>
+      <p>other configure-script improvements:</p>
 
       <ul>
-        <li>check if "b" binary feature of fopen works</li>
+        <li>recent msys2 headers work with
+        <tt>_DEFAULT_SOURCE</tt>; amend check</li>
 
-        <li>check for missing feature of locale.h</li>
+        <li>use <tt>$ac_includes_default</tt> in most cases where
+        stdlib.h should work</li>
 
-        <li>add fallback for strstr() in test-programs</li>
+        <li>use <tt>#error</tt> consistently vs "make an
+        error"</li>
 
-        <li>add fallback for STDOUT_FILENO in test-programs</li>
+        <li>add configure macro for <tt>gettimeofday</tt> vs inline
+        check</li>
       </ul>
     </li>
+  </ul>
 
-    <li>
-      <p>The <em>test/configure</em> script (used for <a href=
-      "/ncurses/ncurses-examples.html"><em>ncurses-examples</em></a>)
-      is improved:</p>
-
-      <ul>
-        <li>work around non-ncurses termcap.h file, e.g., in
-        Slackware.</li>
+  <p>Here are some of the other portability fixes:</p>
 
-        <li>check for <a href=
-        "/ncurses/man/curs_variables.3x.html#h3-TABSIZE"><tt>TABSIZE</tt></a>
-        variable.</li>
+  <ul>
+    <li>
+      <p>modify configure scripts/makefiles to omit
+      <tt>KEY_RESIZE</tt> if the corresponding <tt>SIGWINCH</tt>
+      feature is disabled</p>
+    </li>
 
-        <li>checks for the X11/Intrinsic.h header, accommodate
-        recent MacOS changes which largely emptied
-        <tt>/usr/include</tt>.</li>
-      </ul>
+    <li>
+      <p>increase <tt>MB_CUR_MAX</tt> to 16, matching glibc's
+      <tt>MB_LEN_MAX</tt></p>
     </li>
-  </ul>
 
-  <p>Here are some of the other portability fixes:</p>
+    <li>
+      <p>add BSD <tt>erase2</tt> to characters handled by
+      tset/reset</p>
+    </li>
 
-  <ul>
     <li>
-      <p>added dummy "check" rule in top-level and test-Makefile to
-      simplify building test-packages for ArchLinux.</p>
+      <p>use <tt>getauxval</tt> when available, to improve
+      <tt>setuid</tt>/<tt>setgid</tt> checks</p>
     </li>
 
     <li>
-      <p>dropped library-dependency on psapi for MinGW port, since
-      win_driver.c defines <tt>PSAPI_VERSION</tt> to 2, making it
-      use <tt>GetProcessImageFileName</tt> from kernel32.dll</p>
+      <p>set <tt>dwShareMode</tt> in calls to
+      <tt>CreateConsoleScreenBuffer</tt></p>
     </li>
 
     <li>
-      <p>made build-fixes for configuration using --program-suffix
-      with Ada95, noticed with MacOS but applicable to other
-      platforms without libpanelw, etc.</p>
+      <p>use <tt>CreateFile</tt> with "<tt>CONIN$</tt>",
+      "<tt>CONOUT$</tt>" rather than <tt>GetStdHandle</tt> to
+      obtain a handle on the actual console, avoiding redirection
+      in the MinGW/Win32 configurations</p>
     </li>
 
     <li>
-      <p>modified ncurses/Makefile.in to fix a case where
-      Debian/testing changes to the ld --as-needed configuration
-      broke ncurses-examples test packages.</p>
+      <p>modify MinGW driver to return <tt>KEY_BACKSPACE</tt> when
+      an unmodified <tt>VK_BACK</tt> virtual key is entered</p>
     </li>
 
     <li>
-      <p>used <tt>_WIN32</tt>/<tt>_WIN64</tt> in preference to
-      <tt>__MINGW32__</tt>/<tt>__MINGW64__</tt> symbols to simplify
-      building with Microsoft Visual C++, since the former are
-      defined in both compiler configurations.</p>
+      <p>modify MinGW configuration to provide for running in
+      MSYS/MSYS2 shells, assuming ConPTY support</p>
     </li>
   </ul>
 
@@ -1548,30 +1103,31 @@ diff --git a/st.info b/st.info
     </li>
 
     <li>
-      <p><span class="main-name">ncurses</span> supports all of the
-      for SVr4 curses features including keyboard mapping, color,
-      forms-drawing with ACS characters, and automatic recognition
+      <p><span class="main-name">ncurses</span> supports the
+      features of SVr4 curses including keyboard mapping, color,
+      form drawing with ACS characters, and automatic recognition
       of keypad and function keys.</p>
     </li>
 
     <li>
-      <p><span class="main-name">ncurses</span> provides these SVr4
-      add-on libraries (not part of X/Open Curses):</p>
+      <p><span class="main-name">ncurses</span> provides work-alike
+      replacements of SVr4 supplemental libraries based on curses,
+      but which were not specified by X/Open Curses:</p>
 
       <ul>
         <li>
-          <p>the panels library, supporting a stack of windows with
-          backing store.</p>
+          <p>the panel library, supporting a stack of windows with
+          backing store</p>
         </li>
 
         <li>
-          <p>the menus library, supporting a uniform but flexible
-          interface for menu programming.</p>
+          <p>the menu library, supporting a uniform but flexible
+          interface for menu programming</p>
         </li>
 
         <li>
           <p>the form library, supporting data collection through
-          on-screen forms.</p>
+          on-screen forms</p>
         </li>
       </ul>
     </li>
@@ -1583,7 +1139,7 @@ diff --git a/st.info b/st.info
       <ul>
         <li>
           <p><span class="main-name">ncurses</span> supports
-          user-defined capabilities which it can see, but which are
+          user-defined capabilities that it can see, but which are
           hidden from SVr4 curses applications using the
           <em>same</em> terminal database.</p>
         </li>
@@ -1605,7 +1161,7 @@ diff --git a/st.info b/st.info
       <p>The <span class="main-name">ncurses</span> utilities have
       options to allow you to filter terminfo entries for use with
       less capable <em>curses</em>/<em>terminfo</em> versions such
-      as the HP/UX and AIX ports.</p>
+      as the HP-UX and AIX ports.</p>
     </li>
   </ul>
 
@@ -1615,11 +1171,11 @@ diff --git a/st.info b/st.info
   <ul>
     <li>
       <p>The API is 8-bit clean and base-level conformant with the
-      X/OPEN curses specification, XSI curses (that is, it
-      implements all BASE level features, and most EXTENDED
-      features). It includes many function calls not supported
-      under SVr4 curses (but portability of all calls is documented
-      so you can use the SVr4 subset only).</p>
+      X/Open Curses specification, XSI curses (that is, it
+      implements all <em>BASE</em> level features, and almost all
+      <em>EXTENDED</em> features). It includes many function calls
+      not supported under SVr4 curses (but portability of all calls
+      is documented so you can use the SVr4 subset only).</p>
     </li>
 
     <li>
@@ -1661,6 +1217,11 @@ diff --git a/st.info b/st.info
       than one control sequence to map to a given key code.</p>
     </li>
 
+    <li>
+      <p>Support for direct-color terminals, such as modern
+      xterm.</p>
+    </li>
+
     <li>
       <p>Support for 256-color terminals, such as modern xterm.</p>
     </li>
@@ -1751,10 +1312,27 @@ diff --git a/st.info b/st.info
     </li>
 
     <li>
-      <p>The library meets the XSI requirement that every macro
-      entry point have a corresponding function which may be linked
-      (and will be prototype-checked) if the macro definition is
-      disabled with <code>#undef</code>.</p>
+      <p>X/Open Curses permits most functions it specifies to be
+      made available as macros as well. ncurses does this</p>
+
+      <ul>
+        <li>to improve performance, e.g., for operations composed
+        of simpler functions such as cursor movement following by
+        adding text to the screen,</li>
+
+        <li>to simplify the implementation by reusing functions
+        which use common parameters, e.g., the standard screen
+        <code>stdscr</code>, and</li>
+
+        <li>to provide functions that return values via their
+        parameters</li>
+      </ul>
+
+      <p>Except for the last case, ncurses provides a non-macro
+      implementation of the function. If the macro definition is
+      disabled with <code>#undef</code>, or by defining
+      <code>NCURSES_NOMACROS</code> the function may be linked (and
+      its calls will be checked against the prototype).</p>
     </li>
 
     <li>
@@ -1856,7 +1434,8 @@ diff --git a/st.info b/st.info
         <p>New vi uses ncurses.</p>
 
         <p><a href=
-        "https://sites.google.com/a/bostic.com/keithbostic/vi">https://sites.google.com/a/bostic.com/keithbostic/vi</a><br>
+        "https://sites.google.com/a/bostic.com/keithbostic/the-berkeley-vi-editor-home-page">
+        https://sites.google.com/a/bostic.com/keithbostic/the-berkeley-vi-editor-home-page</a><br>
 
         </p>
       </dd>
@@ -1904,7 +1483,7 @@ diff --git a/st.info b/st.info
         <p>terminal emulator for serial modem connections</p>
 
         <p><a href=
-        "https://alioth.debian.org/projects/minicom/">https://alioth.debian.org/projects/minicom/</a></p>
+        "https://salsa.debian.org/minicom-team/minicom">https://salsa.debian.org/minicom-team/minicom</a></p>
       </dd>
 
       <dt><span class="part-name">mosh</span>
@@ -1913,8 +1492,7 @@ diff --git a/st.info b/st.info
       <dd>
         <p>a replacement for <code>ssh</code>.</p>
 
-        <p><a href=
-        "https://mosh.mit.edu/">https://mosh.mit.edu/</a></p>
+        <p><a href="https://mosh.org/">https://mosh.org/</a></p>
       </dd>
 
       <dt><span class="part-name">tack</span>
@@ -2005,7 +1583,7 @@ diff --git a/st.info b/st.info
   <p>Ongoing development work is done by <a href=
   "mailto:dickey@invisible-island.net">Thomas E. Dickey</a>. Thomas
   E. Dickey has acted as the maintainer for the Free Software
-  Foundation, which holds a <a href=
+  Foundation, which held a <a href=
   "@HOMEPAGE@/ncurses-license.html">copyright on ncurses</a> for
   releases 4.2 through 6.1. Following the release of ncurses 6.1,
   effective as of release 6.2, copyright for ncurses reverted to
@@ -2026,7 +1604,6 @@ diff --git a/st.info b/st.info
     "mailto:bug-ncurses-request@gnu.org">bug-ncurses-request@gnu.org</a>
   </blockquote>
   containing the line:
-
   <blockquote>
     <p><code>subscribe</code>
     <em>&lt;name&gt;@&lt;host.domain&gt;</em></p>
@@ -2040,7 +1617,7 @@ diff --git a/st.info b/st.info
 
   <blockquote>
     <p><a href=
-    "ftp://ftp.invisible-island.net/ncurses/current/">ftp://ftp.invisible-island.net/ncurses/current/</a>
+    "https://invisible-island.net/archives/ncurses/current/">https://invisible-island.net/archives/ncurses/current/</a>
     and<br>
     <a href=
     "https://invisible-mirror.net/archives/ncurses/current/">https://invisible-mirror.net/archives/ncurses/current/</a>&nbsp;.</p>
@@ -2050,19 +1627,17 @@ diff --git a/st.info b/st.info
 
   <blockquote>
     <p><a href=
-    "ftp://ftp.invisible-island.net/ncurses/6.1/">ftp://ftp.invisible-island.net/ncurses/6.1/</a>
+    "https://invisible-island.net/archives/ncurses/6.4/">https://invisible-island.net/archives/ncurses/6.4/</a>
     and<br>
     <a href=
-    "https://invisible-mirror.net/archives/ncurses/6.1/">https://invisible-mirror.net/archives/ncurses/6.1/</a>&nbsp;.</p>
+    "https://invisible-mirror.net/archives/ncurses/6.4/">https://invisible-mirror.net/archives/ncurses/6.4/</a>&nbsp;.</p>
   </blockquote>
 
   <p>There is an archive of the mailing list here:</p>
 
   <blockquote>
     <p><a href=
-    "http://lists.gnu.org/archive/html/bug-ncurses">http://lists.gnu.org/archive/html/bug-ncurses</a>
-    (also <a href=
-    "https://lists.gnu.org/archive/html/bug-ncurses">https</a>)</p>
+    "https://lists.gnu.org/archive/html/bug-ncurses">https://lists.gnu.org/archive/html/bug-ncurses</a>&nbsp;.</p>
   </blockquote>
 
   <h2><a name="h2-this-stuff" id="h2-this-stuff">Related
@@ -2082,6 +1657,9 @@ diff --git a/st.info b/st.info
     <span class="main-name">ncurses</span> versus <span class=
     "main-name">slang</span> (S-Lang)</a></li>
 
+    <li><a href="@HOMEPAGE@/ncurses-openbsd.html">Comments on
+    <span class="main-name">OpenBSD</span></a></li>
+
     <li><a href="@HOMEPAGE@/tack.html">tack &ndash; terminfo action
     checker</a></li>
 
@@ -2101,14 +1679,15 @@ diff --git a/st.info b/st.info
   <a href="http://www.catb.org/~esr/terminfo/">Eric
   Raymond</a>&nbsp;. Unlike the older version, the termcap and
   terminfo data are provided in the same file, which also provides
-  several user-definable extensions beyond the X/Open
+  several user-definable extensions beyond the X/Open Curses
   specification.</p>
 
   <p>You can find lots of information on terminal-related topics
-  not covered in the terminfo file at <a href=
-  "http://web.archive.org/web/*/http://www.cs.utk.edu/~shuford/terminal">
-  Richard Shuford's archive</a>&nbsp;. The collection of computer
-  manuals at <a href=
+  not covered in the terminfo file in <a href=
+  "https://shuford.invisible-island.net/">Richard Shuford's
+  archive</a> (<a href=
+  "http://web.archive.org/web/*/http://www.cs.utk.edu/~shuford/terminal">original</a>).
+  The collection of computer manuals at <a href=
   "http://www.bitsavers.org/pdf/">bitsavers.org</a> has also been
   useful.</p>
 
@@ -2118,11 +1697,9 @@ diff --git a/st.info b/st.info
 
       <li>
         <a href="#h2-release-notes">Release Notes</a>
-
         <ul>
           <li>
             <a href="#h3-library">Library improvements</a>
-
             <ul>
               <li><a href="#h4-new-library">New features</a></li>
 
@@ -2133,7 +1710,6 @@ diff --git a/st.info b/st.info
 
           <li>
             <a href="#h3-programs">Program improvements</a>
-
             <ul>
               <li><a href="#h4-utilities">Utilities</a></li>
 
@@ -2149,7 +1725,6 @@ diff --git a/st.info b/st.info
 
           <li>
             <a href="#h3-config-config">Configuration changes</a>
-
             <ul>
               <li><a href="#h4-config-major">Major changes</a></li>
 
diff --git a/contrib/ncurses/config.guess b/contrib/ncurses/config.guess
index 95b16c7747a1..f47d666d340b 100755
--- a/contrib/ncurses/config.guess
+++ b/contrib/ncurses/config.guess
@@ -1,12 +1,14 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
-#   Copyright 1992-2019 Free Software Foundation, Inc.
+#   Copyright 1992-2023 Free Software Foundation, Inc.
 
-timestamp='2019-12-21'
+# shellcheck disable=SC2006,SC2268 # see below for rationale
+
+timestamp='2023-10-19'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
+# the Free Software Foundation, either version 3 of the License, or
 # (at your option) any later version.
 #
 # This program is distributed in the hope that it will be useful, but
@@ -27,17 +29,25 @@ timestamp='2019-12-21'
 # Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
 #
 # You can get the latest version of this script from:
-# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
+# https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
 #
 # Please send patches to <config-patches@gnu.org>.
 
 
+# The "shellcheck disable" line above the timestamp inhibits complaints
+# about features and limitations of the classic Bourne shell that were
+# superseded or lifted in POSIX.  However, this script identifies a wide
+# variety of pre-POSIX systems that do not have POSIX shells at all, and
+# even some reasonably current systems (Solaris 10 as case-in-point) still
+# have a pre-POSIX /bin/sh.
+
+
 me=`echo "$0" | sed -e 's,.*/,,'`
 
 usage="\
 Usage: $0 [OPTION]
 
-Output the configuration name of the system \`$me' is run on.
+Output the configuration name of the system '$me' is run on.
 
 Options:
   -h, --help         print this help, then exit
@@ -50,13 +60,13 @@ version="\
 GNU config.guess ($timestamp)
 
 Originally written by Per Bothner.
-Copyright 1992-2019 Free Software Foundation, Inc.
+Copyright 1992-2023 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
 
 help="
-Try \`$me --help' for more information."
+Try '$me --help' for more information."
 
 # Parse command line
 while test $# -gt 0 ; do
@@ -84,13 +94,16 @@ if test $# != 0; then
   exit 1
 fi
 
+# Just in case it came from the environment.
+GUESS=
+
 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a
 # compiler to aid in system detection is discouraged as it requires
 # temporary files to be created and, as you can see below, it is a
 # headache to deal with in a portable fashion.
 
-# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
-# use `HOST_CC' if defined, but it is deprecated.
+# Historically, 'CC_FOR_BUILD' used to be named 'HOST_CC'. We still
+# use 'HOST_CC' if defined, but it is deprecated.
 
 # Portable tmp directory creation inspired by the Autoconf team.
 
@@ -102,7 +115,7 @@ set_cc_for_build() {
     # prevent multiple calls if $tmp is already set
     test "$tmp" && return 0
     : "${TMPDIR=/tmp}"
-    # shellcheck disable=SC2039
+    # shellcheck disable=SC2039,SC3028
     { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
 	{ test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } ||
 	{ tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } ||
@@ -112,7 +125,7 @@ set_cc_for_build() {
 	,,)    echo "int x;" > "$dummy.c"
 	       for driver in cc gcc c89 c99 ; do
 		   if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
-		       CC_FOR_BUILD="$driver"
+		       CC_FOR_BUILD=$driver
 		       break
 		   fi
 	       done
@@ -133,40 +146,57 @@ fi
 
 UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
 UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
-UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
 UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
 
-case "$UNAME_SYSTEM" in
+case $UNAME_SYSTEM in
 Linux|GNU|GNU/*)
-	# If the system lacks a compiler, then just pick glibc.
-	# We could probably try harder.
-	LIBC=gnu
+	LIBC=unknown
 
 	set_cc_for_build
 	cat <<-EOF > "$dummy.c"
+	#if defined(__ANDROID__)
+	LIBC=android
+	#else
 	#include <features.h>
 	#if defined(__UCLIBC__)
 	LIBC=uclibc
 	#elif defined(__dietlibc__)
 	LIBC=dietlibc
-	#else
+	#elif defined(__GLIBC__)
 	LIBC=gnu
+	#elif defined(__LLVM_LIBC__)
+	LIBC=llvm
+	#else
+	#include <stdarg.h>
+	/* First heuristic to detect musl libc.  */
+	#ifdef __DEFINED_va_list
+	LIBC=musl
+	#endif
+	#endif
 	#endif
 	EOF
-	eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`"
+	cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
+	eval "$cc_set_libc"
 
-	# If ldd exists, use it to detect musl libc.
-	if command -v ldd >/dev/null && \
-		ldd --version 2>&1 | grep -q ^musl
-	then
-	    LIBC=musl
+	# Second heuristic to detect musl libc.
+	if [ "$LIBC" = unknown ] &&
+	   command -v ldd >/dev/null &&
+	   ldd --version 2>&1 | grep -q ^musl; then
+		LIBC=musl
+	fi
+
+	# If the system lacks a compiler, then just pick glibc.
+	# We could probably try harder.
+	if [ "$LIBC" = unknown ]; then
+		LIBC=gnu
 	fi
 	;;
 esac
 
 # Note: order is significant - the case branches are not exclusive.
 
-case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
+case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in
     *:NetBSD:*:*)
 	# NetBSD (nbsd) targets should (where applicable) match one or
 	# more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
@@ -178,12 +208,12 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
 	#
 	# Note: NetBSD doesn't particularly care about the vendor
 	# portion of the name.  We always set it to "unknown".
-	sysctl="sysctl -n hw.machine_arch"
 	UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
-	    "/sbin/$sysctl" 2>/dev/null || \
-	    "/usr/sbin/$sysctl" 2>/dev/null || \
+	    /sbin/sysctl -n hw.machine_arch 2>/dev/null || \
+	    /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \
 	    echo unknown)`
-	case "$UNAME_MACHINE_ARCH" in
+	case $UNAME_MACHINE_ARCH in
+	    aarch64eb) machine=aarch64_be-unknown ;;
 	    armeb) machine=armeb-unknown ;;
 	    arm*) machine=arm-unknown ;;
 	    sh3el) machine=shl-unknown ;;
@@ -192,13 +222,13 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
 	    earmv*)
 		arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
 		endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'`
-		machine="${arch}${endian}"-unknown
+		machine=${arch}${endian}-unknown
 		;;
-	    *) machine="$UNAME_MACHINE_ARCH"-unknown ;;
+	    *) machine=$UNAME_MACHINE_ARCH-unknown ;;
 	esac
 	# The Operating System including object format, if it has switched
 	# to ELF recently (or will in the future) and ABI.
-	case "$UNAME_MACHINE_ARCH" in
+	case $UNAME_MACHINE_ARCH in
 	    earm*)
 		os=netbsdelf
 		;;
@@ -219,7 +249,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
 		;;
 	esac
 	# Determine ABI tags.
-	case "$UNAME_MACHINE_ARCH" in
+	case $UNAME_MACHINE_ARCH in
 	    earm*)
 		expr='s/^earmv[0-9]/-eabi/;s/eb$//'
 		abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"`
@@ -230,7 +260,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
 	# thus, need a distinct triplet. However, they do not need
 	# kernel version information, so it can be replaced with a
 	# suitable tag, in the style of linux-gnu.
-	case "$UNAME_VERSION" in
+	case $UNAME_VERSION in
 	    Debian*)
 		release='-gnu'
 		;;
@@ -241,51 +271,57 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
 	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
 	# contains redundant information, the shorter form:
 	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
-	echo "$machine-${os}${release}${abi-}"
-	exit ;;
+	GUESS=$machine-${os}${release}${abi-}
+	;;
     *:Bitrig:*:*)
 	UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
-	echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE"
-	exit ;;
+	GUESS=$UNAME_MACHINE_ARCH-unknown-bitrig$UNAME_RELEASE
+	;;
     *:OpenBSD:*:*)
 	UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
-	echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE"
-	exit ;;
+	GUESS=$UNAME_MACHINE_ARCH-unknown-openbsd$UNAME_RELEASE
+	;;
+    *:SecBSD:*:*)
+	UNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'`
+	GUESS=$UNAME_MACHINE_ARCH-unknown-secbsd$UNAME_RELEASE
+	;;
     *:LibertyBSD:*:*)
 	UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'`
-	echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE"
-	exit ;;
+	GUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE
+	;;
     *:MidnightBSD:*:*)
-	echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE"
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE
+	;;
     *:ekkoBSD:*:*)
-	echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE"
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE
+	;;
     *:SolidBSD:*:*)
-	echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE"
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-solidbsd$UNAME_RELEASE
+	;;
     *:OS108:*:*)
-	echo "$UNAME_MACHINE"-unknown-os108_"$UNAME_RELEASE"
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-os108_$UNAME_RELEASE
+	;;
     macppc:MirBSD:*:*)
-	echo powerpc-unknown-mirbsd"$UNAME_RELEASE"
-	exit ;;
+	GUESS=powerpc-unknown-mirbsd$UNAME_RELEASE
+	;;
     *:MirBSD:*:*)
-	echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE"
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-mirbsd$UNAME_RELEASE
+	;;
     *:Sortix:*:*)
-	echo "$UNAME_MACHINE"-unknown-sortix
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-sortix
+	;;
     *:Twizzler:*:*)
-	echo "$UNAME_MACHINE"-unknown-twizzler
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-twizzler
+	;;
     *:Redox:*:*)
-	echo "$UNAME_MACHINE"-unknown-redox
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-redox
+	;;
     mips:OSF1:*.*)
-	echo mips-dec-osf1
-	exit ;;
+	GUESS=mips-dec-osf1
+	;;
     alpha:OSF1:*:*)
+	# Reset EXIT trap before exiting to avoid spurious non-zero exit code.
+	trap '' 0
 	case $UNAME_RELEASE in
 	*4.0)
 		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
@@ -299,7 +335,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
 	# covers most systems running today.  This code pipes the CPU
 	# types through head -n 1, so we only detect the type of CPU 0.
 	ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
-	case "$ALPHA_CPU_TYPE" in
+	case $ALPHA_CPU_TYPE in
 	    "EV4 (21064)")
 		UNAME_MACHINE=alpha ;;
 	    "EV4.5 (21064)")
@@ -336,117 +372,121 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
 	# A Tn.n version is a released field test version.
 	# A Xn.n version is an unreleased experimental baselevel.
 	# 1.2 uses "1.2" for uname -r.
-	echo "$UNAME_MACHINE"-dec-osf"`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`"
-	# Reset EXIT trap before exiting to avoid spurious non-zero exit code.
-	exitcode=$?
-	trap '' 0
-	exit $exitcode ;;
+	OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
+	GUESS=$UNAME_MACHINE-dec-osf$OSF_REL
+	;;
     Amiga*:UNIX_System_V:4.0:*)
-	echo m68k-unknown-sysv4
-	exit ;;
+	GUESS=m68k-unknown-sysv4
+	;;
     *:[Aa]miga[Oo][Ss]:*:*)
-	echo "$UNAME_MACHINE"-unknown-amigaos
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-amigaos
+	;;
     *:[Mm]orph[Oo][Ss]:*:*)
-	echo "$UNAME_MACHINE"-unknown-morphos
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-morphos
+	;;
     *:OS/390:*:*)
-	echo i370-ibm-openedition
-	exit ;;
+	GUESS=i370-ibm-openedition
+	;;
     *:z/VM:*:*)
-	echo s390-ibm-zvmoe
-	exit ;;
+	GUESS=s390-ibm-zvmoe
+	;;
     *:OS400:*:*)
-	echo powerpc-ibm-os400
-	exit ;;
+	GUESS=powerpc-ibm-os400
+	;;
     arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
-	echo arm-acorn-riscix"$UNAME_RELEASE"
-	exit ;;
+	GUESS=arm-acorn-riscix$UNAME_RELEASE
+	;;
     arm*:riscos:*:*|arm*:RISCOS:*:*)
-	echo arm-unknown-riscos
-	exit ;;
+	GUESS=arm-unknown-riscos
+	;;
     SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
-	echo hppa1.1-hitachi-hiuxmpp
-	exit ;;
+	GUESS=hppa1.1-hitachi-hiuxmpp
+	;;
     Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
 	# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
-	if test "`(/bin/universe) 2>/dev/null`" = att ; then
-		echo pyramid-pyramid-sysv3
-	else
-		echo pyramid-pyramid-bsd
-	fi
-	exit ;;
+	case `(/bin/universe) 2>/dev/null` in
+	    att) GUESS=pyramid-pyramid-sysv3 ;;
+	    *)   GUESS=pyramid-pyramid-bsd   ;;
+	esac
+	;;
     NILE*:*:*:dcosx)
-	echo pyramid-pyramid-svr4
-	exit ;;
+	GUESS=pyramid-pyramid-svr4
+	;;
     DRS?6000:unix:4.0:6*)
-	echo sparc-icl-nx6
-	exit ;;
+	GUESS=sparc-icl-nx6
+	;;
     DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
 	case `/usr/bin/uname -p` in
-	    sparc) echo sparc-icl-nx7; exit ;;
-	esac ;;
+	    sparc) GUESS=sparc-icl-nx7 ;;
+	esac
+	;;
     s390x:SunOS:*:*)
-	echo "$UNAME_MACHINE"-ibm-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`"
-	exit ;;
+	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
+	GUESS=$UNAME_MACHINE-ibm-solaris2$SUN_REL
+	;;
     sun4H:SunOS:5.*:*)
-	echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
-	exit ;;
+	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
+	GUESS=sparc-hal-solaris2$SUN_REL
+	;;
     sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
-	echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`"
-	exit ;;
+	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
+	GUESS=sparc-sun-solaris2$SUN_REL
+	;;
     i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
-	echo i386-pc-auroraux"$UNAME_RELEASE"
-	exit ;;
+	GUESS=i386-pc-auroraux$UNAME_RELEASE
+	;;
     i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
 	set_cc_for_build
 	SUN_ARCH=i386
 	# If there is a compiler, see if it is configured for 64-bit objects.
 	# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
 	# This test works for both compilers.
-	if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
+	if test "$CC_FOR_BUILD" != no_compiler_found; then
 	    if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
-		(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
+		(CCOPTS="" $CC_FOR_BUILD -m64 -E - 2>/dev/null) | \
 		grep IS_64BIT_ARCH >/dev/null
 	    then
 		SUN_ARCH=x86_64
 	    fi
 	fi
-	echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
-	exit ;;
+	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
+	GUESS=$SUN_ARCH-pc-solaris2$SUN_REL
+	;;
     sun4*:SunOS:6*:*)
 	# According to config.sub, this is the proper way to canonicalize
 	# SunOS6.  Hard to guess exactly what SunOS6 will be like, but
 	# it's likely to be more like Solaris than SunOS4.
-	echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
-	exit ;;
+	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
+	GUESS=sparc-sun-solaris3$SUN_REL
+	;;
     sun4*:SunOS:*:*)
-	case "`/usr/bin/arch -k`" in
+	case `/usr/bin/arch -k` in
 	    Series*|S4*)
 		UNAME_RELEASE=`uname -v`
 		;;
 	esac
-	# Japanese Language versions have a version number like `4.1.3-JL'.
-	echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`"
-	exit ;;
+	# Japanese Language versions have a version number like '4.1.3-JL'.
+	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'`
+	GUESS=sparc-sun-sunos$SUN_REL
+	;;
     sun3*:SunOS:*:*)
-	echo m68k-sun-sunos"$UNAME_RELEASE"
-	exit ;;
+	GUESS=m68k-sun-sunos$UNAME_RELEASE
+	;;
     sun*:*:4.2BSD:*)
 	UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
 	test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3
-	case "`/bin/arch`" in
+	case `/bin/arch` in
 	    sun3)
-		echo m68k-sun-sunos"$UNAME_RELEASE"
+		GUESS=m68k-sun-sunos$UNAME_RELEASE
 		;;
 	    sun4)
-		echo sparc-sun-sunos"$UNAME_RELEASE"
+		GUESS=sparc-sun-sunos$UNAME_RELEASE
 		;;
 	esac
-	exit ;;
+	;;
     aushp:SunOS:*:*)
-	echo sparc-auspex-sunos"$UNAME_RELEASE"
-	exit ;;
+	GUESS=sparc-auspex-sunos$UNAME_RELEASE
+	;;
     # The situation for MiNT is a little confusing.  The machine name
     # can be virtually everything (everything which is not
     # "atarist" or "atariste" at least should have a processor
@@ -456,41 +496,41 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
     # MiNT.  But MiNT is downward compatible to TOS, so this should
     # be no problem.
     atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
-	echo m68k-atari-mint"$UNAME_RELEASE"
-	exit ;;
+	GUESS=m68k-atari-mint$UNAME_RELEASE
+	;;
     atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
-	echo m68k-atari-mint"$UNAME_RELEASE"
-	exit ;;
+	GUESS=m68k-atari-mint$UNAME_RELEASE
+	;;
     *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
-	echo m68k-atari-mint"$UNAME_RELEASE"
-	exit ;;
+	GUESS=m68k-atari-mint$UNAME_RELEASE
+	;;
     milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
-	echo m68k-milan-mint"$UNAME_RELEASE"
-	exit ;;
+	GUESS=m68k-milan-mint$UNAME_RELEASE
+	;;
     hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
-	echo m68k-hades-mint"$UNAME_RELEASE"
-	exit ;;
+	GUESS=m68k-hades-mint$UNAME_RELEASE
+	;;
     *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
-	echo m68k-unknown-mint"$UNAME_RELEASE"
-	exit ;;
+	GUESS=m68k-unknown-mint$UNAME_RELEASE
+	;;
     m68k:machten:*:*)
-	echo m68k-apple-machten"$UNAME_RELEASE"
-	exit ;;
+	GUESS=m68k-apple-machten$UNAME_RELEASE
+	;;
     powerpc:machten:*:*)
-	echo powerpc-apple-machten"$UNAME_RELEASE"
-	exit ;;
+	GUESS=powerpc-apple-machten$UNAME_RELEASE
+	;;
     RISC*:Mach:*:*)
-	echo mips-dec-mach_bsd4.3
-	exit ;;
+	GUESS=mips-dec-mach_bsd4.3
+	;;
     RISC*:ULTRIX:*:*)
-	echo mips-dec-ultrix"$UNAME_RELEASE"
-	exit ;;
+	GUESS=mips-dec-ultrix$UNAME_RELEASE
+	;;
     VAX*:ULTRIX*:*:*)
-	echo vax-dec-ultrix"$UNAME_RELEASE"
-	exit ;;
+	GUESS=vax-dec-ultrix$UNAME_RELEASE
+	;;
     2020:CLIX:*:* | 2430:CLIX:*:*)
-	echo clipper-intergraph-clix"$UNAME_RELEASE"
-	exit ;;
+	GUESS=clipper-intergraph-clix$UNAME_RELEASE
+	;;
     mips:*:*:UMIPS | mips:*:*:RISCos)
 	set_cc_for_build
 	sed 's/^	//' << EOF > "$dummy.c"
@@ -518,75 +558,76 @@ EOF
 	  dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` &&
 	  SYSTEM_NAME=`"$dummy" "$dummyarg"` &&
 	    { echo "$SYSTEM_NAME"; exit; }
-	echo mips-mips-riscos"$UNAME_RELEASE"
-	exit ;;
+	GUESS=mips-mips-riscos$UNAME_RELEASE
+	;;
     Motorola:PowerMAX_OS:*:*)
-	echo powerpc-motorola-powermax
-	exit ;;
+	GUESS=powerpc-motorola-powermax
+	;;
     Motorola:*:4.3:PL8-*)
-	echo powerpc-harris-powermax
-	exit ;;
+	GUESS=powerpc-harris-powermax
+	;;
     Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
-	echo powerpc-harris-powermax
-	exit ;;
+	GUESS=powerpc-harris-powermax
+	;;
     Night_Hawk:Power_UNIX:*:*)
-	echo powerpc-harris-powerunix
-	exit ;;
+	GUESS=powerpc-harris-powerunix
+	;;
     m88k:CX/UX:7*:*)
-	echo m88k-harris-cxux7
-	exit ;;
+	GUESS=m88k-harris-cxux7
+	;;
     m88k:*:4*:R4*)
-	echo m88k-motorola-sysv4
-	exit ;;
+	GUESS=m88k-motorola-sysv4
+	;;
     m88k:*:3*:R3*)
-	echo m88k-motorola-sysv3
-	exit ;;
+	GUESS=m88k-motorola-sysv3
+	;;
     AViiON:dgux:*:*)
 	# DG/UX returns AViiON for all architectures
 	UNAME_PROCESSOR=`/usr/bin/uname -p`
-	if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ]
+	if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110
 	then
-	    if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \
-	       [ "$TARGET_BINARY_INTERFACE"x = x ]
+	    if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \
+	       test "$TARGET_BINARY_INTERFACE"x = x
 	    then
-		echo m88k-dg-dgux"$UNAME_RELEASE"
+		GUESS=m88k-dg-dgux$UNAME_RELEASE
 	    else
-		echo m88k-dg-dguxbcs"$UNAME_RELEASE"
+		GUESS=m88k-dg-dguxbcs$UNAME_RELEASE
 	    fi
 	else
-	    echo i586-dg-dgux"$UNAME_RELEASE"
+	    GUESS=i586-dg-dgux$UNAME_RELEASE
 	fi
-	exit ;;
+	;;
     M88*:DolphinOS:*:*)	# DolphinOS (SVR3)
-	echo m88k-dolphin-sysv3
-	exit ;;
+	GUESS=m88k-dolphin-sysv3
+	;;
     M88*:*:R3*:*)
 	# Delta 88k system running SVR3
-	echo m88k-motorola-sysv3
-	exit ;;
+	GUESS=m88k-motorola-sysv3
+	;;
     XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
-	echo m88k-tektronix-sysv3
-	exit ;;
+	GUESS=m88k-tektronix-sysv3
+	;;
     Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
-	echo m68k-tektronix-bsd
-	exit ;;
+	GUESS=m68k-tektronix-bsd
+	;;
     *:IRIX*:*:*)
-	echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`"
-	exit ;;
+	IRIX_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/g'`
+	GUESS=mips-sgi-irix$IRIX_REL
+	;;
     ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
-	echo romp-ibm-aix     # uname -m gives an 8 hex-code CPU id
-	exit ;;               # Note that: echo "'`uname -s`'" gives 'AIX '
+	GUESS=romp-ibm-aix    # uname -m gives an 8 hex-code CPU id
+	;;                    # Note that: echo "'`uname -s`'" gives 'AIX '
     i*86:AIX:*:*)
-	echo i386-ibm-aix
-	exit ;;
+	GUESS=i386-ibm-aix
+	;;
     ia64:AIX:*:*)
-	if [ -x /usr/bin/oslevel ] ; then
+	if test -x /usr/bin/oslevel ; then
 		IBM_REV=`/usr/bin/oslevel`
 	else
-		IBM_REV="$UNAME_VERSION.$UNAME_RELEASE"
+		IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
 	fi
-	echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV"
-	exit ;;
+	GUESS=$UNAME_MACHINE-ibm-aix$IBM_REV
+	;;
     *:AIX:2:3)
 	if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
 		set_cc_for_build
@@ -603,16 +644,16 @@ EOF
 EOF
 		if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"`
 		then
-			echo "$SYSTEM_NAME"
+			GUESS=$SYSTEM_NAME
 		else
-			echo rs6000-ibm-aix3.2.5
+			GUESS=rs6000-ibm-aix3.2.5
 		fi
 	elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
-		echo rs6000-ibm-aix3.2.4
+		GUESS=rs6000-ibm-aix3.2.4
 	else
-		echo rs6000-ibm-aix3.2
+		GUESS=rs6000-ibm-aix3.2
 	fi
-	exit ;;
+	;;
     *:AIX:*:[4567])
 	IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
 	if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then
@@ -620,56 +661,56 @@ EOF
 	else
 		IBM_ARCH=powerpc
 	fi
-	if [ -x /usr/bin/lslpp ] ; then
-		IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc |
+	if test -x /usr/bin/lslpp ; then
+		IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | \
 			   awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
 	else
-		IBM_REV="$UNAME_VERSION.$UNAME_RELEASE"
+		IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
 	fi
-	echo "$IBM_ARCH"-ibm-aix"$IBM_REV"
-	exit ;;
+	GUESS=$IBM_ARCH-ibm-aix$IBM_REV
+	;;
     *:AIX:*:*)
-	echo rs6000-ibm-aix
-	exit ;;
+	GUESS=rs6000-ibm-aix
+	;;
     ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*)
-	echo romp-ibm-bsd4.4
-	exit ;;
+	GUESS=romp-ibm-bsd4.4
+	;;
     ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
-	echo romp-ibm-bsd"$UNAME_RELEASE"   # 4.3 with uname added to
-	exit ;;                             # report: romp-ibm BSD 4.3
+	GUESS=romp-ibm-bsd$UNAME_RELEASE    # 4.3 with uname added to
+	;;                                  # report: romp-ibm BSD 4.3
     *:BOSX:*:*)
-	echo rs6000-bull-bosx
-	exit ;;
+	GUESS=rs6000-bull-bosx
+	;;
     DPX/2?00:B.O.S.:*:*)
-	echo m68k-bull-sysv3
-	exit ;;
+	GUESS=m68k-bull-sysv3
+	;;
     9000/[34]??:4.3bsd:1.*:*)
-	echo m68k-hp-bsd
-	exit ;;
+	GUESS=m68k-hp-bsd
+	;;
     hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
-	echo m68k-hp-bsd4.4
-	exit ;;
+	GUESS=m68k-hp-bsd4.4
+	;;
     9000/[34678]??:HP-UX:*:*)
-	HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'`
-	case "$UNAME_MACHINE" in
+	HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
+	case $UNAME_MACHINE in
 	    9000/31?)            HP_ARCH=m68000 ;;
 	    9000/[34]??)         HP_ARCH=m68k ;;
 	    9000/[678][0-9][0-9])
-		if [ -x /usr/bin/getconf ]; then
+		if test -x /usr/bin/getconf; then
 		    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
 		    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
-		    case "$sc_cpu_version" in
+		    case $sc_cpu_version in
 		      523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0
 		      528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1
 		      532)                      # CPU_PA_RISC2_0
-			case "$sc_kernel_bits" in
+			case $sc_kernel_bits in
 			  32) HP_ARCH=hppa2.0n ;;
 			  64) HP_ARCH=hppa2.0w ;;
 			  '') HP_ARCH=hppa2.0 ;;   # HP-UX 10.20
 			esac ;;
 		    esac
 		fi
-		if [ "$HP_ARCH" = "" ]; then
+		if test "$HP_ARCH" = ""; then
 		    set_cc_for_build
 		    sed 's/^		//' << EOF > "$dummy.c"
 
@@ -708,7 +749,7 @@ EOF
 		    test -z "$HP_ARCH" && HP_ARCH=hppa
 		fi ;;
 	esac
-	if [ "$HP_ARCH" = hppa2.0w ]
+	if test "$HP_ARCH" = hppa2.0w
 	then
 	    set_cc_for_build
 
@@ -729,12 +770,12 @@ EOF
 		HP_ARCH=hppa64
 	    fi
 	fi
-	echo "$HP_ARCH"-hp-hpux"$HPUX_REV"
-	exit ;;
+	GUESS=$HP_ARCH-hp-hpux$HPUX_REV
+	;;
     ia64:HP-UX:*:*)
-	HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'`
-	echo ia64-hp-hpux"$HPUX_REV"
-	exit ;;
+	HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
+	GUESS=ia64-hp-hpux$HPUX_REV
+	;;
     3050*:HI-UX:*:*)
 	set_cc_for_build
 	sed 's/^	//' << EOF > "$dummy.c"
@@ -764,36 +805,36 @@ EOF
 EOF
 	$CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` &&
 		{ echo "$SYSTEM_NAME"; exit; }
-	echo unknown-hitachi-hiuxwe2
-	exit ;;
+	GUESS=unknown-hitachi-hiuxwe2
+	;;
     9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*)
-	echo hppa1.1-hp-bsd
-	exit ;;
+	GUESS=hppa1.1-hp-bsd
+	;;
     9000/8??:4.3bsd:*:*)
-	echo hppa1.0-hp-bsd
-	exit ;;
+	GUESS=hppa1.0-hp-bsd
+	;;
     *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
-	echo hppa1.0-hp-mpeix
-	exit ;;
+	GUESS=hppa1.0-hp-mpeix
+	;;
     hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*)
-	echo hppa1.1-hp-osf
-	exit ;;
+	GUESS=hppa1.1-hp-osf
+	;;
     hp8??:OSF1:*:*)
-	echo hppa1.0-hp-osf
-	exit ;;
+	GUESS=hppa1.0-hp-osf
+	;;
     i*86:OSF1:*:*)
-	if [ -x /usr/sbin/sysversion ] ; then
-	    echo "$UNAME_MACHINE"-unknown-osf1mk
+	if test -x /usr/sbin/sysversion ; then
+	    GUESS=$UNAME_MACHINE-unknown-osf1mk
 	else
-	    echo "$UNAME_MACHINE"-unknown-osf1
+	    GUESS=$UNAME_MACHINE-unknown-osf1
 	fi
-	exit ;;
+	;;
     parisc*:Lites*:*:*)
-	echo hppa1.1-hp-lites
-	exit ;;
+	GUESS=hppa1.1-hp-lites
+	;;
     C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
-	echo c1-convex-bsd
-	exit ;;
+	GUESS=c1-convex-bsd
+	;;
     C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
 	if getsysinfo -f scalar_acc
 	then echo c32-convex-bsd
@@ -801,17 +842,18 @@ EOF
 	fi
 	exit ;;
     C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
-	echo c34-convex-bsd
-	exit ;;
+	GUESS=c34-convex-bsd
+	;;
     C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
-	echo c38-convex-bsd
-	exit ;;
+	GUESS=c38-convex-bsd
+	;;
     C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
-	echo c4-convex-bsd
-	exit ;;
+	GUESS=c4-convex-bsd
+	;;
     CRAY*Y-MP:*:*:*)
-	echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
-	exit ;;
+	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
+	GUESS=ymp-cray-unicos$CRAY_REL
+	;;
     CRAY*[A-Z]90:*:*:*)
 	echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \
 	| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
@@ -819,112 +861,153 @@ EOF
 	      -e 's/\.[^.]*$/.X/'
 	exit ;;
     CRAY*TS:*:*:*)
-	echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
-	exit ;;
+	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
+	GUESS=t90-cray-unicos$CRAY_REL
+	;;
     CRAY*T3E:*:*:*)
-	echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
-	exit ;;
+	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
+	GUESS=alphaev5-cray-unicosmk$CRAY_REL
+	;;
     CRAY*SV1:*:*:*)
-	echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
-	exit ;;
+	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
+	GUESS=sv1-cray-unicos$CRAY_REL
+	;;
     *:UNICOS/mp:*:*)
-	echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
-	exit ;;
+	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
+	GUESS=craynv-cray-unicosmp$CRAY_REL
+	;;
     F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
 	FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
 	FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
 	FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'`
-	echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
-	exit ;;
+	GUESS=${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
+	;;
     5000:UNIX_System_V:4.*:*)
 	FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
 	FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'`
-	echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
-	exit ;;
+	GUESS=sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
+	;;
     i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
-	echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE"
-	exit ;;
+	GUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE
+	;;
     sparc*:BSD/OS:*:*)
-	echo sparc-unknown-bsdi"$UNAME_RELEASE"
-	exit ;;
+	GUESS=sparc-unknown-bsdi$UNAME_RELEASE
+	;;
     *:BSD/OS:*:*)
-	echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE"
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-bsdi$UNAME_RELEASE
+	;;
     arm:FreeBSD:*:*)
 	UNAME_PROCESSOR=`uname -p`
 	set_cc_for_build
 	if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
 	    | grep -q __ARM_PCS_VFP
 	then
-	    echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabi
+	    FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
+	    GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabi
 	else
-	    echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabihf
+	    FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
+	    GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf
 	fi
-	exit ;;
+	;;
     *:FreeBSD:*:*)
-	UNAME_PROCESSOR=`/usr/bin/uname -p`
-	case "$UNAME_PROCESSOR" in
+	UNAME_PROCESSOR=`uname -p`
+	case $UNAME_PROCESSOR in
 	    amd64)
 		UNAME_PROCESSOR=x86_64 ;;
 	    i386)
 		UNAME_PROCESSOR=i586 ;;
 	esac
-	echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`"
-	exit ;;
+	FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
+	GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL
+	;;
     i*:CYGWIN*:*)
-	echo "$UNAME_MACHINE"-pc-cygwin
-	exit ;;
+	GUESS=$UNAME_MACHINE-pc-cygwin
+	;;
     *:MINGW64*:*)
-	echo "$UNAME_MACHINE"-pc-mingw64
-	exit ;;
+	GUESS=$UNAME_MACHINE-pc-mingw64
+	;;
     *:MINGW*:*)
-	echo "$UNAME_MACHINE"-pc-mingw32
-	exit ;;
+	GUESS=$UNAME_MACHINE-pc-mingw32
+	;;
     *:MSYS*:*)
-	echo "$UNAME_MACHINE"-pc-msys
-	exit ;;
+	GUESS=$UNAME_MACHINE-pc-msys
+	;;
     i*:PW*:*)
-	echo "$UNAME_MACHINE"-pc-pw32
-	exit ;;
+	GUESS=$UNAME_MACHINE-pc-pw32
+	;;
+    *:SerenityOS:*:*)
+        GUESS=$UNAME_MACHINE-pc-serenity
+        ;;
     *:Interix*:*)
-	case "$UNAME_MACHINE" in
+	case $UNAME_MACHINE in
 	    x86)
-		echo i586-pc-interix"$UNAME_RELEASE"
-		exit ;;
+		GUESS=i586-pc-interix$UNAME_RELEASE
+		;;
 	    authenticamd | genuineintel | EM64T)
-		echo x86_64-unknown-interix"$UNAME_RELEASE"
-		exit ;;
+		GUESS=x86_64-unknown-interix$UNAME_RELEASE
+		;;
 	    IA64)
-		echo ia64-unknown-interix"$UNAME_RELEASE"
-		exit ;;
+		GUESS=ia64-unknown-interix$UNAME_RELEASE
+		;;
 	esac ;;
     i*:UWIN*:*)
-	echo "$UNAME_MACHINE"-pc-uwin
-	exit ;;
+	GUESS=$UNAME_MACHINE-pc-uwin
+	;;
     amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
-	echo x86_64-pc-cygwin
-	exit ;;
+	GUESS=x86_64-pc-cygwin
+	;;
     prep*:SunOS:5.*:*)
-	echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
-	exit ;;
+	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
+	GUESS=powerpcle-unknown-solaris2$SUN_REL
+	;;
     *:GNU:*:*)
 	# the GNU system
-	echo "`echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo "$UNAME_RELEASE"|sed -e 's,/.*$,,'`"
-	exit ;;
+	GNU_ARCH=`echo "$UNAME_MACHINE" | sed -e 's,[-/].*$,,'`
+	GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's,/.*$,,'`
+	GUESS=$GNU_ARCH-unknown-$LIBC$GNU_REL
+	;;
     *:GNU/*:*:*)
 	# other systems with GNU libc and userland
-	echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC"
-	exit ;;
+	GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"`
+	GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
+	GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC
+	;;
+    x86_64:[Mm]anagarm:*:*|i?86:[Mm]anagarm:*:*)
+	GUESS="$UNAME_MACHINE-pc-managarm-mlibc"
+	;;
+    *:[Mm]anagarm:*:*)
+	GUESS="$UNAME_MACHINE-unknown-managarm-mlibc"
+	;;
     *:Minix:*:*)
-	echo "$UNAME_MACHINE"-unknown-minix
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-minix
+	;;
     aarch64:Linux:*:*)
-	echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
-	exit ;;
+	set_cc_for_build
+	CPU=$UNAME_MACHINE
+	LIBCABI=$LIBC
+	if test "$CC_FOR_BUILD" != no_compiler_found; then
+	    ABI=64
+	    sed 's/^	    //' << EOF > "$dummy.c"
+	    #ifdef __ARM_EABI__
+	    #ifdef __ARM_PCS_VFP
+	    ABI=eabihf
+	    #else
+	    ABI=eabi
+	    #endif
+	    #endif
+EOF
+	    cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'`
+	    eval "$cc_set_abi"
+	    case $ABI in
+		eabi | eabihf) CPU=armv8l; LIBCABI=$LIBC$ABI ;;
+	    esac
+	fi
+	GUESS=$CPU-unknown-linux-$LIBCABI
+	;;
     aarch64_be:Linux:*:*)
 	UNAME_MACHINE=aarch64_be
-	echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+	;;
     alpha:Linux:*:*)
 	case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in
 	  EV5)   UNAME_MACHINE=alphaev5 ;;
@@ -937,60 +1020,72 @@ EOF
 	esac
 	objdump --private-headers /bin/sh | grep -q ld.so.1
 	if test "$?" = 0 ; then LIBC=gnulibc1 ; fi
-	echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
-	exit ;;
-    arc:Linux:*:* | arceb:Linux:*:*)
-	echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+	;;
+    arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*)
+	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+	;;
     arm*:Linux:*:*)
 	set_cc_for_build
 	if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
 	    | grep -q __ARM_EABI__
 	then
-	    echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
+	    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
 	else
 	    if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
 		| grep -q __ARM_PCS_VFP
 	    then
-		echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi
+		GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabi
 	    else
-		echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf
+		GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabihf
 	    fi
 	fi
-	exit ;;
+	;;
     avr32*:Linux:*:*)
-	echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+	;;
     cris:Linux:*:*)
-	echo "$UNAME_MACHINE"-axis-linux-"$LIBC"
-	exit ;;
+	GUESS=$UNAME_MACHINE-axis-linux-$LIBC
+	;;
     crisv32:Linux:*:*)
-	echo "$UNAME_MACHINE"-axis-linux-"$LIBC"
-	exit ;;
+	GUESS=$UNAME_MACHINE-axis-linux-$LIBC
+	;;
     e2k:Linux:*:*)
-	echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+	;;
     frv:Linux:*:*)
-	echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+	;;
     hexagon:Linux:*:*)
-	echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+	;;
     i*86:Linux:*:*)
-	echo "$UNAME_MACHINE"-pc-linux-"$LIBC"
-	exit ;;
+	GUESS=$UNAME_MACHINE-pc-linux-$LIBC
+	;;
     ia64:Linux:*:*)
-	echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+	;;
     k1om:Linux:*:*)
-	echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+	;;
+    kvx:Linux:*:*)
+	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+	;;
+    kvx:cos:*:*)
+	GUESS=$UNAME_MACHINE-unknown-cos
+	;;
+    kvx:mbr:*:*)
+	GUESS=$UNAME_MACHINE-unknown-mbr
+	;;
+    loongarch32:Linux:*:* | loongarch64:Linux:*:*)
+	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+	;;
     m32r*:Linux:*:*)
-	echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+	;;
     m68*:Linux:*:*)
-	echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+	;;
     mips:Linux:*:* | mips64:Linux:*:*)
 	set_cc_for_build
 	IS_GLIBC=0
@@ -1035,113 +1130,135 @@ EOF
 	#endif
 	#endif
 EOF
-	eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'`"
+	cc_set_vars=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'`
+	eval "$cc_set_vars"
 	test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; }
 	;;
     mips64el:Linux:*:*)
-	echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+	;;
     openrisc*:Linux:*:*)
-	echo or1k-unknown-linux-"$LIBC"
-	exit ;;
+	GUESS=or1k-unknown-linux-$LIBC
+	;;
     or32:Linux:*:* | or1k*:Linux:*:*)
-	echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+	;;
     padre:Linux:*:*)
-	echo sparc-unknown-linux-"$LIBC"
-	exit ;;
+	GUESS=sparc-unknown-linux-$LIBC
+	;;
     parisc64:Linux:*:* | hppa64:Linux:*:*)
-	echo hppa64-unknown-linux-"$LIBC"
-	exit ;;
+	GUESS=hppa64-unknown-linux-$LIBC
+	;;
     parisc:Linux:*:* | hppa:Linux:*:*)
 	# Look for CPU level
 	case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
-	  PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;;
-	  PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;;
-	  *)    echo hppa-unknown-linux-"$LIBC" ;;
+	  PA7*) GUESS=hppa1.1-unknown-linux-$LIBC ;;
+	  PA8*) GUESS=hppa2.0-unknown-linux-$LIBC ;;
+	  *)    GUESS=hppa-unknown-linux-$LIBC ;;
 	esac
-	exit ;;
+	;;
     ppc64:Linux:*:*)
-	echo powerpc64-unknown-linux-"$LIBC"
-	exit ;;
+	GUESS=powerpc64-unknown-linux-$LIBC
+	;;
     ppc:Linux:*:*)
-	echo powerpc-unknown-linux-"$LIBC"
-	exit ;;
+	GUESS=powerpc-unknown-linux-$LIBC
+	;;
     ppc64le:Linux:*:*)
-	echo powerpc64le-unknown-linux-"$LIBC"
-	exit ;;
+	GUESS=powerpc64le-unknown-linux-$LIBC
+	;;
     ppcle:Linux:*:*)
-	echo powerpcle-unknown-linux-"$LIBC"
-	exit ;;
-    riscv32:Linux:*:* | riscv64:Linux:*:*)
-	echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
-	exit ;;
+	GUESS=powerpcle-unknown-linux-$LIBC
+	;;
+    riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*)
+	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+	;;
     s390:Linux:*:* | s390x:Linux:*:*)
-	echo "$UNAME_MACHINE"-ibm-linux-"$LIBC"
-	exit ;;
+	GUESS=$UNAME_MACHINE-ibm-linux-$LIBC
+	;;
     sh64*:Linux:*:*)
-	echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+	;;
     sh*:Linux:*:*)
-	echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+	;;
     sparc:Linux:*:* | sparc64:Linux:*:*)
-	echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+	;;
     tile*:Linux:*:*)
-	echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+	;;
     vax:Linux:*:*)
-	echo "$UNAME_MACHINE"-dec-linux-"$LIBC"
-	exit ;;
+	GUESS=$UNAME_MACHINE-dec-linux-$LIBC
+	;;
     x86_64:Linux:*:*)
-	echo "$UNAME_MACHINE"-pc-linux-"$LIBC"
-	exit ;;
+	set_cc_for_build
+	CPU=$UNAME_MACHINE
+	LIBCABI=$LIBC
+	if test "$CC_FOR_BUILD" != no_compiler_found; then
+	    ABI=64
+	    sed 's/^	    //' << EOF > "$dummy.c"
+	    #ifdef __i386__
+	    ABI=x86
+	    #else
+	    #ifdef __ILP32__
+	    ABI=x32
+	    #endif
+	    #endif
+EOF
+	    cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'`
+	    eval "$cc_set_abi"
+	    case $ABI in
+		x86) CPU=i686 ;;
+		x32) LIBCABI=${LIBC}x32 ;;
+	    esac
+	fi
+	GUESS=$CPU-pc-linux-$LIBCABI
+	;;
     xtensa*:Linux:*:*)
-	echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+	;;
     i*86:DYNIX/ptx:4*:*)
 	# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
 	# earlier versions are messed up and put the nodename in both
 	# sysname and nodename.
-	echo i386-sequent-sysv4
-	exit ;;
+	GUESS=i386-sequent-sysv4
+	;;
     i*86:UNIX_SV:4.2MP:2.*)
 	# Unixware is an offshoot of SVR4, but it has its own version
 	# number series starting with 2...
 	# I am not positive that other SVR4 systems won't match this,
 	# I just have to hope.  -- rms.
 	# Use sysv4.2uw... so that sysv4* matches it.
-	echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION"
-	exit ;;
+	GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION
+	;;
     i*86:OS/2:*:*)
-	# If we were able to find `uname', then EMX Unix compatibility
+	# If we were able to find 'uname', then EMX Unix compatibility
 	# is probably installed.
-	echo "$UNAME_MACHINE"-pc-os2-emx
-	exit ;;
+	GUESS=$UNAME_MACHINE-pc-os2-emx
+	;;
     i*86:XTS-300:*:STOP)
-	echo "$UNAME_MACHINE"-unknown-stop
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-stop
+	;;
     i*86:atheos:*:*)
-	echo "$UNAME_MACHINE"-unknown-atheos
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-atheos
+	;;
     i*86:syllable:*:*)
-	echo "$UNAME_MACHINE"-pc-syllable
-	exit ;;
+	GUESS=$UNAME_MACHINE-pc-syllable
+	;;
     i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
-	echo i386-unknown-lynxos"$UNAME_RELEASE"
-	exit ;;
+	GUESS=i386-unknown-lynxos$UNAME_RELEASE
+	;;
     i*86:*DOS:*:*)
-	echo "$UNAME_MACHINE"-pc-msdosdjgpp
-	exit ;;
+	GUESS=$UNAME_MACHINE-pc-msdosdjgpp
+	;;
     i*86:*:4.*:*)
 	UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'`
 	if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
-		echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL"
+		GUESS=$UNAME_MACHINE-univel-sysv$UNAME_REL
 	else
-		echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL"
+		GUESS=$UNAME_MACHINE-pc-sysv$UNAME_REL
 	fi
-	exit ;;
+	;;
     i*86:*:5:[678]*)
 	# UnixWare 7.x, OpenUNIX and OpenServer 6.
 	case `/bin/uname -X | grep "^Machine"` in
@@ -1149,12 +1266,12 @@ EOF
 	    *Pentium)	     UNAME_MACHINE=i586 ;;
 	    *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
 	esac
-	echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}"
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+	;;
     i*86:*:3.2:*)
 	if test -f /usr/options/cb.name; then
 		UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
-		echo "$UNAME_MACHINE"-pc-isc"$UNAME_REL"
+		GUESS=$UNAME_MACHINE-pc-isc$UNAME_REL
 	elif /bin/uname -X 2>/dev/null >/dev/null ; then
 		UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
 		(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
@@ -1164,11 +1281,11 @@ EOF
 			&& UNAME_MACHINE=i686
 		(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
 			&& UNAME_MACHINE=i686
-		echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL"
+		GUESS=$UNAME_MACHINE-pc-sco$UNAME_REL
 	else
-		echo "$UNAME_MACHINE"-pc-sysv32
+		GUESS=$UNAME_MACHINE-pc-sysv32
 	fi
-	exit ;;
+	;;
     pc:*:*:*)
 	# Left here for compatibility:
 	# uname -m prints for DJGPP always 'pc', but it prints nothing about
@@ -1176,31 +1293,31 @@ EOF
 	# Note: whatever this is, it MUST be the same as what config.sub
 	# prints for the "djgpp" host, or else GDB configure will decide that
 	# this is a cross-build.
-	echo i586-pc-msdosdjgpp
-	exit ;;
+	GUESS=i586-pc-msdosdjgpp
+	;;
     Intel:Mach:3*:*)
-	echo i386-pc-mach3
-	exit ;;
+	GUESS=i386-pc-mach3
+	;;
     paragon:*:*:*)
-	echo i860-intel-osf1
-	exit ;;
+	GUESS=i860-intel-osf1
+	;;
     i860:*:4.*:*) # i860-SVR4
 	if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
-	  echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4
+	  GUESS=i860-stardent-sysv$UNAME_RELEASE    # Stardent Vistra i860-SVR4
 	else # Add other i860-SVR4 vendors below as they are discovered.
-	  echo i860-unknown-sysv"$UNAME_RELEASE"  # Unknown i860-SVR4
+	  GUESS=i860-unknown-sysv$UNAME_RELEASE     # Unknown i860-SVR4
 	fi
-	exit ;;
+	;;
     mini*:CTIX:SYS*5:*)
 	# "miniframe"
-	echo m68010-convergent-sysv
-	exit ;;
+	GUESS=m68010-convergent-sysv
+	;;
     mc68k:UNIX:SYSTEM5:3.51m)
-	echo m68k-convergent-sysv
-	exit ;;
+	GUESS=m68k-convergent-sysv
+	;;
     M680?0:D-NIX:5.3:*)
-	echo m68k-diab-dnix
-	exit ;;
+	GUESS=m68k-diab-dnix
+	;;
     M68*:*:R3V[5678]*:*)
 	test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
     3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
@@ -1225,113 +1342,119 @@ EOF
 	/bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
 	    && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
     m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
-	echo m68k-unknown-lynxos"$UNAME_RELEASE"
-	exit ;;
+	GUESS=m68k-unknown-lynxos$UNAME_RELEASE
+	;;
     mc68030:UNIX_System_V:4.*:*)
-	echo m68k-atari-sysv4
-	exit ;;
+	GUESS=m68k-atari-sysv4
+	;;
     TSUNAMI:LynxOS:2.*:*)
-	echo sparc-unknown-lynxos"$UNAME_RELEASE"
-	exit ;;
+	GUESS=sparc-unknown-lynxos$UNAME_RELEASE
+	;;
     rs6000:LynxOS:2.*:*)
-	echo rs6000-unknown-lynxos"$UNAME_RELEASE"
-	exit ;;
+	GUESS=rs6000-unknown-lynxos$UNAME_RELEASE
+	;;
     PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
-	echo powerpc-unknown-lynxos"$UNAME_RELEASE"
-	exit ;;
+	GUESS=powerpc-unknown-lynxos$UNAME_RELEASE
+	;;
     SM[BE]S:UNIX_SV:*:*)
-	echo mips-dde-sysv"$UNAME_RELEASE"
-	exit ;;
+	GUESS=mips-dde-sysv$UNAME_RELEASE
+	;;
     RM*:ReliantUNIX-*:*:*)
-	echo mips-sni-sysv4
-	exit ;;
+	GUESS=mips-sni-sysv4
+	;;
     RM*:SINIX-*:*:*)
-	echo mips-sni-sysv4
-	exit ;;
+	GUESS=mips-sni-sysv4
+	;;
     *:SINIX-*:*:*)
 	if uname -p 2>/dev/null >/dev/null ; then
 		UNAME_MACHINE=`(uname -p) 2>/dev/null`
-		echo "$UNAME_MACHINE"-sni-sysv4
+		GUESS=$UNAME_MACHINE-sni-sysv4
 	else
-		echo ns32k-sni-sysv
+		GUESS=ns32k-sni-sysv
 	fi
-	exit ;;
-    PENTIUM:*:4.0*:*)	# Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+	;;
+    PENTIUM:*:4.0*:*)	# Unisys 'ClearPath HMP IX 4000' SVR4/MP effort
 			# says <Richard.M.Bartel@ccMail.Census.GOV>
-	echo i586-unisys-sysv4
-	exit ;;
+	GUESS=i586-unisys-sysv4
+	;;
     *:UNIX_System_V:4*:FTX*)
 	# From Gerald Hewes <hewes@openmarket.com>.
 	# How about differentiating between stratus architectures? -djm
-	echo hppa1.1-stratus-sysv4
-	exit ;;
+	GUESS=hppa1.1-stratus-sysv4
+	;;
     *:*:*:FTX*)
 	# From seanf@swdc.stratus.com.
-	echo i860-stratus-sysv4
-	exit ;;
+	GUESS=i860-stratus-sysv4
+	;;
     i*86:VOS:*:*)
 	# From Paul.Green@stratus.com.
-	echo "$UNAME_MACHINE"-stratus-vos
-	exit ;;
+	GUESS=$UNAME_MACHINE-stratus-vos
+	;;
     *:VOS:*:*)
 	# From Paul.Green@stratus.com.
-	echo hppa1.1-stratus-vos
-	exit ;;
+	GUESS=hppa1.1-stratus-vos
+	;;
     mc68*:A/UX:*:*)
-	echo m68k-apple-aux"$UNAME_RELEASE"
-	exit ;;
+	GUESS=m68k-apple-aux$UNAME_RELEASE
+	;;
     news*:NEWS-OS:6*:*)
-	echo mips-sony-newsos6
-	exit ;;
+	GUESS=mips-sony-newsos6
+	;;
     R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
-	if [ -d /usr/nec ]; then
-		echo mips-nec-sysv"$UNAME_RELEASE"
+	if test -d /usr/nec; then
+		GUESS=mips-nec-sysv$UNAME_RELEASE
 	else
-		echo mips-unknown-sysv"$UNAME_RELEASE"
+		GUESS=mips-unknown-sysv$UNAME_RELEASE
 	fi
-	exit ;;
+	;;
     BeBox:BeOS:*:*)	# BeOS running on hardware made by Be, PPC only.
-	echo powerpc-be-beos
-	exit ;;
+	GUESS=powerpc-be-beos
+	;;
     BeMac:BeOS:*:*)	# BeOS running on Mac or Mac clone, PPC only.
-	echo powerpc-apple-beos
-	exit ;;
+	GUESS=powerpc-apple-beos
+	;;
     BePC:BeOS:*:*)	# BeOS running on Intel PC compatible.
-	echo i586-pc-beos
-	exit ;;
+	GUESS=i586-pc-beos
+	;;
     BePC:Haiku:*:*)	# Haiku running on Intel PC compatible.
-	echo i586-pc-haiku
-	exit ;;
-    x86_64:Haiku:*:*)
-	echo x86_64-unknown-haiku
-	exit ;;
+	GUESS=i586-pc-haiku
+	;;
+    ppc:Haiku:*:*)	# Haiku running on Apple PowerPC
+	GUESS=powerpc-apple-haiku
+	;;
+    *:Haiku:*:*)	# Haiku modern gcc (not bound by BeOS compat)
+	GUESS=$UNAME_MACHINE-unknown-haiku
+	;;
     SX-4:SUPER-UX:*:*)
-	echo sx4-nec-superux"$UNAME_RELEASE"
-	exit ;;
+	GUESS=sx4-nec-superux$UNAME_RELEASE
+	;;
     SX-5:SUPER-UX:*:*)
-	echo sx5-nec-superux"$UNAME_RELEASE"
-	exit ;;
+	GUESS=sx5-nec-superux$UNAME_RELEASE
+	;;
     SX-6:SUPER-UX:*:*)
-	echo sx6-nec-superux"$UNAME_RELEASE"
-	exit ;;
+	GUESS=sx6-nec-superux$UNAME_RELEASE
+	;;
     SX-7:SUPER-UX:*:*)
-	echo sx7-nec-superux"$UNAME_RELEASE"
-	exit ;;
+	GUESS=sx7-nec-superux$UNAME_RELEASE
+	;;
     SX-8:SUPER-UX:*:*)
-	echo sx8-nec-superux"$UNAME_RELEASE"
-	exit ;;
+	GUESS=sx8-nec-superux$UNAME_RELEASE
+	;;
     SX-8R:SUPER-UX:*:*)
-	echo sx8r-nec-superux"$UNAME_RELEASE"
-	exit ;;
+	GUESS=sx8r-nec-superux$UNAME_RELEASE
+	;;
     SX-ACE:SUPER-UX:*:*)
-	echo sxace-nec-superux"$UNAME_RELEASE"
-	exit ;;
+	GUESS=sxace-nec-superux$UNAME_RELEASE
+	;;
     Power*:Rhapsody:*:*)
-	echo powerpc-apple-rhapsody"$UNAME_RELEASE"
-	exit ;;
+	GUESS=powerpc-apple-rhapsody$UNAME_RELEASE
+	;;
     *:Rhapsody:*:*)
-	echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE"
-	exit ;;
+	GUESS=$UNAME_MACHINE-apple-rhapsody$UNAME_RELEASE
+	;;
+    arm64:Darwin:*:*)
+	GUESS=aarch64-apple-darwin$UNAME_RELEASE
+	;;
     *:Darwin:*:*)
 	UNAME_PROCESSOR=`uname -p`
 	case $UNAME_PROCESSOR in
@@ -1346,7 +1469,7 @@ EOF
 	else
 	    set_cc_for_build
 	fi
-	if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
+	if test "$CC_FOR_BUILD" != no_compiler_found; then
 	    if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
 		   (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
 		   grep IS_64BIT_ARCH >/dev/null
@@ -1367,109 +1490,122 @@ EOF
 	    # uname -m returns i386 or x86_64
 	    UNAME_PROCESSOR=$UNAME_MACHINE
 	fi
-	echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE"
-	exit ;;
+	GUESS=$UNAME_PROCESSOR-apple-darwin$UNAME_RELEASE
+	;;
     *:procnto*:*:* | *:QNX:[0123456789]*:*)
 	UNAME_PROCESSOR=`uname -p`
 	if test "$UNAME_PROCESSOR" = x86; then
 		UNAME_PROCESSOR=i386
 		UNAME_MACHINE=pc
 	fi
-	echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE"
-	exit ;;
+	GUESS=$UNAME_PROCESSOR-$UNAME_MACHINE-nto-qnx$UNAME_RELEASE
+	;;
     *:QNX:*:4*)
-	echo i386-pc-qnx
-	exit ;;
+	GUESS=i386-pc-qnx
+	;;
     NEO-*:NONSTOP_KERNEL:*:*)
-	echo neo-tandem-nsk"$UNAME_RELEASE"
-	exit ;;
+	GUESS=neo-tandem-nsk$UNAME_RELEASE
+	;;
     NSE-*:NONSTOP_KERNEL:*:*)
-	echo nse-tandem-nsk"$UNAME_RELEASE"
-	exit ;;
+	GUESS=nse-tandem-nsk$UNAME_RELEASE
+	;;
     NSR-*:NONSTOP_KERNEL:*:*)
-	echo nsr-tandem-nsk"$UNAME_RELEASE"
-	exit ;;
+	GUESS=nsr-tandem-nsk$UNAME_RELEASE
+	;;
     NSV-*:NONSTOP_KERNEL:*:*)
-	echo nsv-tandem-nsk"$UNAME_RELEASE"
-	exit ;;
+	GUESS=nsv-tandem-nsk$UNAME_RELEASE
+	;;
     NSX-*:NONSTOP_KERNEL:*:*)
-	echo nsx-tandem-nsk"$UNAME_RELEASE"
-	exit ;;
+	GUESS=nsx-tandem-nsk$UNAME_RELEASE
+	;;
     *:NonStop-UX:*:*)
-	echo mips-compaq-nonstopux
-	exit ;;
+	GUESS=mips-compaq-nonstopux
+	;;
     BS2000:POSIX*:*:*)
-	echo bs2000-siemens-sysv
-	exit ;;
+	GUESS=bs2000-siemens-sysv
+	;;
     DS/*:UNIX_System_V:*:*)
-	echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE"
-	exit ;;
+	GUESS=$UNAME_MACHINE-$UNAME_SYSTEM-$UNAME_RELEASE
+	;;
     *:Plan9:*:*)
 	# "uname -m" is not consistent, so use $cputype instead. 386
 	# is converted to i386 for consistency with other x86
 	# operating systems.
-	# shellcheck disable=SC2154
-	if test "$cputype" = 386; then
+	if test "${cputype-}" = 386; then
 	    UNAME_MACHINE=i386
-	else
-	    UNAME_MACHINE="$cputype"
+	elif test "x${cputype-}" != x; then
+	    UNAME_MACHINE=$cputype
 	fi
-	echo "$UNAME_MACHINE"-unknown-plan9
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-plan9
+	;;
     *:TOPS-10:*:*)
-	echo pdp10-unknown-tops10
-	exit ;;
+	GUESS=pdp10-unknown-tops10
+	;;
     *:TENEX:*:*)
-	echo pdp10-unknown-tenex
-	exit ;;
+	GUESS=pdp10-unknown-tenex
+	;;
     KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
-	echo pdp10-dec-tops20
-	exit ;;
+	GUESS=pdp10-dec-tops20
+	;;
     XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
-	echo pdp10-xkl-tops20
-	exit ;;
+	GUESS=pdp10-xkl-tops20
+	;;
     *:TOPS-20:*:*)
-	echo pdp10-unknown-tops20
-	exit ;;
+	GUESS=pdp10-unknown-tops20
+	;;
     *:ITS:*:*)
-	echo pdp10-unknown-its
-	exit ;;
+	GUESS=pdp10-unknown-its
+	;;
     SEI:*:*:SEIUX)
-	echo mips-sei-seiux"$UNAME_RELEASE"
-	exit ;;
+	GUESS=mips-sei-seiux$UNAME_RELEASE
+	;;
     *:DragonFly:*:*)
-	echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`"
-	exit ;;
+	DRAGONFLY_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
+	GUESS=$UNAME_MACHINE-unknown-dragonfly$DRAGONFLY_REL
+	;;
     *:*VMS:*:*)
 	UNAME_MACHINE=`(uname -p) 2>/dev/null`
-	case "$UNAME_MACHINE" in
-	    A*) echo alpha-dec-vms ; exit ;;
-	    I*) echo ia64-dec-vms ; exit ;;
-	    V*) echo vax-dec-vms ; exit ;;
+	case $UNAME_MACHINE in
+	    A*) GUESS=alpha-dec-vms ;;
+	    I*) GUESS=ia64-dec-vms ;;
+	    V*) GUESS=vax-dec-vms ;;
 	esac ;;
     *:XENIX:*:SysV)
-	echo i386-pc-xenix
-	exit ;;
+	GUESS=i386-pc-xenix
+	;;
     i*86:skyos:*:*)
-	echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`"
-	exit ;;
+	SKYOS_REL=`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`
+	GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL
+	;;
     i*86:rdos:*:*)
-	echo "$UNAME_MACHINE"-pc-rdos
-	exit ;;
-    i*86:AROS:*:*)
-	echo "$UNAME_MACHINE"-pc-aros
-	exit ;;
+	GUESS=$UNAME_MACHINE-pc-rdos
+	;;
+    i*86:Fiwix:*:*)
+	GUESS=$UNAME_MACHINE-pc-fiwix
+	;;
+    *:AROS:*:*)
+	GUESS=$UNAME_MACHINE-unknown-aros
+	;;
     x86_64:VMkernel:*:*)
-	echo "$UNAME_MACHINE"-unknown-esx
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-esx
+	;;
     amd64:Isilon\ OneFS:*:*)
-	echo x86_64-unknown-onefs
-	exit ;;
+	GUESS=x86_64-unknown-onefs
+	;;
     *:Unleashed:*:*)
-	echo "$UNAME_MACHINE"-unknown-unleashed"$UNAME_RELEASE"
-	exit ;;
+	GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE
+	;;
+    *:Ironclad:*:*)
+	GUESS=$UNAME_MACHINE-unknown-ironclad
+	;;
 esac
 
+# Do we have a guess based on uname results?
+if test "x$GUESS" != x; then
+    echo "$GUESS"
+    exit
+fi
+
 # No uname command or uname output not recognized.
 set_cc_for_build
 cat > "$dummy.c" <<EOF
@@ -1601,7 +1737,7 @@ main ()
 }
 EOF
 
-$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`$dummy` &&
+$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`"$dummy"` &&
 	{ echo "$SYSTEM_NAME"; exit; }
 
 # Apollos put the system type in the environment.
@@ -1609,7 +1745,7 @@ test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; }
 
 echo "$0: unable to guess system type" >&2
 
-case "$UNAME_MACHINE:$UNAME_SYSTEM" in
+case $UNAME_MACHINE:$UNAME_SYSTEM in
     mips:Linux | mips64:Linux)
 	# If we got here on MIPS GNU/Linux, output extra information.
 	cat >&2 <<EOF
@@ -1626,9 +1762,17 @@ This script (version $timestamp), has failed to recognize the
 operating system you are using. If your script is old, overwrite *all*
 copies of config.guess and config.sub with the latest versions from:
 
-  https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
+  https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
 and
-  https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
+  https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
+EOF
+
+our_year=`echo $timestamp | sed 's,-.*,,'`
+thisyear=`date +%Y`
+# shellcheck disable=SC2003
+script_age=`expr "$thisyear" - "$our_year"`
+if test "$script_age" -lt 3 ; then
+   cat >&2 <<EOF
 
 If $0 has already been updated, send the following data and any
 information you think might be pertinent to config-patches@gnu.org to
@@ -1656,6 +1800,7 @@ UNAME_RELEASE = "$UNAME_RELEASE"
 UNAME_SYSTEM  = "$UNAME_SYSTEM"
 UNAME_VERSION = "$UNAME_VERSION"
 EOF
+fi
 
 exit 1
 
diff --git a/contrib/ncurses/config.sub b/contrib/ncurses/config.sub
index 0f2234c174d4..e4c4e09b6540 100755
--- a/contrib/ncurses/config.sub
+++ b/contrib/ncurses/config.sub
@@ -1,12 +1,14 @@
 #! /bin/sh
 # Configuration validation subroutine script.
-#   Copyright 1992-2019 Free Software Foundation, Inc.
+#   Copyright 1992-2023 Free Software Foundation, Inc.
 
-timestamp='2019-06-30'
+# shellcheck disable=SC2006,SC2268 # see below for rationale
+
+timestamp='2023-12-02'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
+# the Free Software Foundation, either version 3 of the License, or
 # (at your option) any later version.
 #
 # This program is distributed in the hope that it will be useful, but
@@ -33,7 +35,7 @@ timestamp='2019-06-30'
 # Otherwise, we print the canonical config type on stdout and succeed.
 
 # You can get the latest version of this script from:
-# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
+# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
 
 # This file is supposed to be the same for all GNU packages
 # and recognize all the CPU types, system types and aliases
@@ -50,6 +52,13 @@ timestamp='2019-06-30'
 #	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
 # It is wrong to echo any other type of specification.
 
+# The "shellcheck disable" line above the timestamp inhibits complaints
+# about features and limitations of the classic Bourne shell that were
+# superseded or lifted in POSIX.  However, this script identifies a wide
+# variety of pre-POSIX systems that do not have POSIX shells at all, and
+# even some reasonably current systems (Solaris 10 as case-in-point) still
+# have a pre-POSIX /bin/sh.
+
 me=`echo "$0" | sed -e 's,.*/,,'`
 
 usage="\
@@ -67,13 +76,13 @@ Report bugs and patches to <config-patches@gnu.org>."
 version="\
 GNU config.sub ($timestamp)
 
-Copyright 1992-2019 Free Software Foundation, Inc.
+Copyright 1992-2023 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
 
 help="
-Try \`$me --help' for more information."
+Try '$me --help' for more information."
 
 # Parse command line
 while test $# -gt 0 ; do
@@ -112,40 +121,42 @@ esac
 
 # Split fields of configuration type
 # shellcheck disable=SC2162
+saved_IFS=$IFS
 IFS="-" read field1 field2 field3 field4 <<EOF
 $1
 EOF
+IFS=$saved_IFS
 
 # Separate into logical components for further validation
 case $1 in
 	*-*-*-*-*)
-		echo Invalid configuration \`"$1"\': more than four components >&2
+		echo "Invalid configuration '$1': more than four components" >&2
 		exit 1
 		;;
 	*-*-*-*)
 		basic_machine=$field1-$field2
-		os=$field3-$field4
+		basic_os=$field3-$field4
 		;;
 	*-*-*)
 		# Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
 		# parts
 		maybe_os=$field2-$field3
 		case $maybe_os in
-			nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc \
-			| linux-newlib* | linux-musl* | linux-uclibc* | uclinux-uclibc* \
+			nto-qnx* | linux-* | uclinux-uclibc* \
 			| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
 			| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
-			| storm-chaos* | os2-emx* | rtmk-nova*)
+			| storm-chaos* | os2-emx* | rtmk-nova* | managarm-* \
+			| windows-* )
 				basic_machine=$field1
-				os=$maybe_os
+				basic_os=$maybe_os
 				;;
 			android-linux)
 				basic_machine=$field1-unknown
-				os=linux-android
+				basic_os=linux-android
 				;;
 			*)
 				basic_machine=$field1-$field2
-				os=$field3
+				basic_os=$field3
 				;;
 		esac
 		;;
@@ -154,7 +165,7 @@ case $1 in
 		case $field1-$field2 in
 			decstation-3100)
 				basic_machine=mips-dec
-				os=
+				basic_os=
 				;;
 			*-*)
 				# Second component is usually, but not always the OS
@@ -162,7 +173,11 @@ case $1 in
 					# Prevent following clause from handling this valid os
 					sun*os*)
 						basic_machine=$field1
-						os=$field2
+						basic_os=$field2
+						;;
+					zephyr*)
+						basic_machine=$field1-unknown
+						basic_os=$field2
 						;;
 					# Manufacturers
 					dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
@@ -175,11 +190,11 @@ case $1 in
 					| microblaze* | sim | cisco \
 					| oki | wec | wrs | winbond)
 						basic_machine=$field1-$field2
-						os=
+						basic_os=
 						;;
 					*)
 						basic_machine=$field1
-						os=$field2
+						basic_os=$field2
 						;;
 				esac
 			;;
@@ -191,447 +206,451 @@ case $1 in
 		case $field1 in
 			386bsd)
 				basic_machine=i386-pc
-				os=bsd
+				basic_os=bsd
 				;;
 			a29khif)
 				basic_machine=a29k-amd
-				os=udi
+				basic_os=udi
 				;;
 			adobe68k)
 				basic_machine=m68010-adobe
-				os=scout
+				basic_os=scout
 				;;
 			alliant)
 				basic_machine=fx80-alliant
-				os=
+				basic_os=
 				;;
 			altos | altos3068)
 				basic_machine=m68k-altos
-				os=
+				basic_os=
 				;;
 			am29k)
 				basic_machine=a29k-none
-				os=bsd
+				basic_os=bsd
 				;;
 			amdahl)
 				basic_machine=580-amdahl
-				os=sysv
+				basic_os=sysv
 				;;
 			amiga)
 				basic_machine=m68k-unknown
-				os=
+				basic_os=
 				;;
 			amigaos | amigados)
 				basic_machine=m68k-unknown
-				os=amigaos
+				basic_os=amigaos
 				;;
 			amigaunix | amix)
 				basic_machine=m68k-unknown
-				os=sysv4
+				basic_os=sysv4
 				;;
 			apollo68)
 				basic_machine=m68k-apollo
-				os=sysv
+				basic_os=sysv
 				;;
 			apollo68bsd)
 				basic_machine=m68k-apollo
-				os=bsd
+				basic_os=bsd
 				;;
 			aros)
 				basic_machine=i386-pc
-				os=aros
+				basic_os=aros
 				;;
 			aux)
 				basic_machine=m68k-apple
-				os=aux
+				basic_os=aux
 				;;
 			balance)
 				basic_machine=ns32k-sequent
-				os=dynix
+				basic_os=dynix
 				;;
 			blackfin)
 				basic_machine=bfin-unknown
-				os=linux
+				basic_os=linux
 				;;
 			cegcc)
 				basic_machine=arm-unknown
-				os=cegcc
+				basic_os=cegcc
 				;;
 			convex-c1)
 				basic_machine=c1-convex
-				os=bsd
+				basic_os=bsd
 				;;
 			convex-c2)
 				basic_machine=c2-convex
-				os=bsd
+				basic_os=bsd
 				;;
 			convex-c32)
 				basic_machine=c32-convex
-				os=bsd
+				basic_os=bsd
 				;;
 			convex-c34)
 				basic_machine=c34-convex
-				os=bsd
+				basic_os=bsd
 				;;
 			convex-c38)
 				basic_machine=c38-convex
-				os=bsd
+				basic_os=bsd
 				;;
 			cray)
 				basic_machine=j90-cray
-				os=unicos
+				basic_os=unicos
 				;;
 			crds | unos)
 				basic_machine=m68k-crds
-				os=
+				basic_os=
 				;;
 			da30)
 				basic_machine=m68k-da30
-				os=
+				basic_os=
 				;;
 			decstation | pmax | pmin | dec3100 | decstatn)
 				basic_machine=mips-dec
-				os=
+				basic_os=
 				;;
 			delta88)
 				basic_machine=m88k-motorola
-				os=sysv3
+				basic_os=sysv3
 				;;
 			dicos)
 				basic_machine=i686-pc
-				os=dicos
+				basic_os=dicos
 				;;
 			djgpp)
 				basic_machine=i586-pc
-				os=msdosdjgpp
+				basic_os=msdosdjgpp
 				;;
 			ebmon29k)
 				basic_machine=a29k-amd
-				os=ebmon
+				basic_os=ebmon
 				;;
 			es1800 | OSE68k | ose68k | ose | OSE)
 				basic_machine=m68k-ericsson
-				os=ose
+				basic_os=ose
 				;;
 			gmicro)
 				basic_machine=tron-gmicro
-				os=sysv
+				basic_os=sysv
 				;;
 			go32)
 				basic_machine=i386-pc
-				os=go32
+				basic_os=go32
 				;;
 			h8300hms)
 				basic_machine=h8300-hitachi
-				os=hms
+				basic_os=hms
 				;;
 			h8300xray)
 				basic_machine=h8300-hitachi
-				os=xray
+				basic_os=xray
 				;;
 			h8500hms)
 				basic_machine=h8500-hitachi
-				os=hms
+				basic_os=hms
 				;;
 			harris)
 				basic_machine=m88k-harris
-				os=sysv3
+				basic_os=sysv3
 				;;
 			hp300 | hp300hpux)
 				basic_machine=m68k-hp
-				os=hpux
+				basic_os=hpux
 				;;
 			hp300bsd)
 				basic_machine=m68k-hp
-				os=bsd
+				basic_os=bsd
 				;;
 			hppaosf)
 				basic_machine=hppa1.1-hp
-				os=osf
+				basic_os=osf
 				;;
 			hppro)
 				basic_machine=hppa1.1-hp
-				os=proelf
+				basic_os=proelf
 				;;
 			i386mach)
 				basic_machine=i386-mach
-				os=mach
+				basic_os=mach
 				;;
 			isi68 | isi)
 				basic_machine=m68k-isi
-				os=sysv
+				basic_os=sysv
 				;;
 			m68knommu)
 				basic_machine=m68k-unknown
-				os=linux
+				basic_os=linux
 				;;
 			magnum | m3230)
 				basic_machine=mips-mips
-				os=sysv
+				basic_os=sysv
 				;;
 			merlin)
 				basic_machine=ns32k-utek
-				os=sysv
+				basic_os=sysv
 				;;
 			mingw64)
 				basic_machine=x86_64-pc
-				os=mingw64
+				basic_os=mingw64
 				;;
 			mingw32)
 				basic_machine=i686-pc
-				os=mingw32
+				basic_os=mingw32
 				;;
 			mingw32ce)
 				basic_machine=arm-unknown
-				os=mingw32ce
+				basic_os=mingw32ce
 				;;
 			monitor)
 				basic_machine=m68k-rom68k
-				os=coff
+				basic_os=coff
 				;;
 			morphos)
 				basic_machine=powerpc-unknown
-				os=morphos
+				basic_os=morphos
 				;;
 			moxiebox)
 				basic_machine=moxie-unknown
-				os=moxiebox
+				basic_os=moxiebox
 				;;
 			msdos)
 				basic_machine=i386-pc
-				os=msdos
+				basic_os=msdos
 				;;
 			msys)
 				basic_machine=i686-pc
-				os=msys
+				basic_os=msys
 				;;
 			mvs)
 				basic_machine=i370-ibm
-				os=mvs
+				basic_os=mvs
 				;;
 			nacl)
 				basic_machine=le32-unknown
-				os=nacl
+				basic_os=nacl
 				;;
 			ncr3000)
 				basic_machine=i486-ncr
-				os=sysv4
+				basic_os=sysv4
 				;;
 			netbsd386)
 				basic_machine=i386-pc
-				os=netbsd
+				basic_os=netbsd
 				;;
 			netwinder)
 				basic_machine=armv4l-rebel
-				os=linux
+				basic_os=linux
 				;;
 			news | news700 | news800 | news900)
 				basic_machine=m68k-sony
-				os=newsos
+				basic_os=newsos
 				;;
 			news1000)
 				basic_machine=m68030-sony
-				os=newsos
+				basic_os=newsos
 				;;
 			necv70)
 				basic_machine=v70-nec
-				os=sysv
+				basic_os=sysv
 				;;
 			nh3000)
 				basic_machine=m68k-harris
-				os=cxux
+				basic_os=cxux
 				;;
 			nh[45]000)
 				basic_machine=m88k-harris
-				os=cxux
+				basic_os=cxux
 				;;
 			nindy960)
 				basic_machine=i960-intel
-				os=nindy
+				basic_os=nindy
 				;;
 			mon960)
 				basic_machine=i960-intel
-				os=mon960
+				basic_os=mon960
 				;;
 			nonstopux)
 				basic_machine=mips-compaq
-				os=nonstopux
+				basic_os=nonstopux
 				;;
 			os400)
 				basic_machine=powerpc-ibm
-				os=os400
+				basic_os=os400
 				;;
 			OSE68000 | ose68000)
 				basic_machine=m68000-ericsson
-				os=ose
+				basic_os=ose
 				;;
 			os68k)
 				basic_machine=m68k-none
-				os=os68k
+				basic_os=os68k
 				;;
 			paragon)
 				basic_machine=i860-intel
-				os=osf
+				basic_os=osf
 				;;
 			parisc)
 				basic_machine=hppa-unknown
-				os=linux
+				basic_os=linux
+				;;
+			psp)
+				basic_machine=mipsallegrexel-sony
+				basic_os=psp
 				;;
 			pw32)
 				basic_machine=i586-unknown
-				os=pw32
+				basic_os=pw32
 				;;
 			rdos | rdos64)
 				basic_machine=x86_64-pc
-				os=rdos
+				basic_os=rdos
 				;;
 			rdos32)
 				basic_machine=i386-pc
-				os=rdos
+				basic_os=rdos
 				;;
 			rom68k)
 				basic_machine=m68k-rom68k
-				os=coff
+				basic_os=coff
 				;;
 			sa29200)
 				basic_machine=a29k-amd
-				os=udi
+				basic_os=udi
 				;;
 			sei)
 				basic_machine=mips-sei
-				os=seiux
+				basic_os=seiux
 				;;
 			sequent)
 				basic_machine=i386-sequent
-				os=
+				basic_os=
 				;;
 			sps7)
 				basic_machine=m68k-bull
-				os=sysv2
+				basic_os=sysv2
 				;;
 			st2000)
 				basic_machine=m68k-tandem
-				os=
+				basic_os=
 				;;
 			stratus)
 				basic_machine=i860-stratus
-				os=sysv4
+				basic_os=sysv4
 				;;
 			sun2)
 				basic_machine=m68000-sun
-				os=
+				basic_os=
 				;;
 			sun2os3)
 				basic_machine=m68000-sun
-				os=sunos3
+				basic_os=sunos3
 				;;
 			sun2os4)
 				basic_machine=m68000-sun
-				os=sunos4
+				basic_os=sunos4
 				;;
 			sun3)
 				basic_machine=m68k-sun
-				os=
+				basic_os=
 				;;
 			sun3os3)
 				basic_machine=m68k-sun
-				os=sunos3
+				basic_os=sunos3
 				;;
 			sun3os4)
 				basic_machine=m68k-sun
-				os=sunos4
+				basic_os=sunos4
 				;;
 			sun4)
 				basic_machine=sparc-sun
-				os=
+				basic_os=
 				;;
 			sun4os3)
 				basic_machine=sparc-sun
-				os=sunos3
+				basic_os=sunos3
 				;;
 			sun4os4)
 				basic_machine=sparc-sun
-				os=sunos4
+				basic_os=sunos4
 				;;
 			sun4sol2)
 				basic_machine=sparc-sun
-				os=solaris2
+				basic_os=solaris2
 				;;
 			sun386 | sun386i | roadrunner)
 				basic_machine=i386-sun
-				os=
+				basic_os=
 				;;
 			sv1)
 				basic_machine=sv1-cray
-				os=unicos
+				basic_os=unicos
 				;;
 			symmetry)
 				basic_machine=i386-sequent
-				os=dynix
+				basic_os=dynix
 				;;
 			t3e)
 				basic_machine=alphaev5-cray
-				os=unicos
+				basic_os=unicos
 				;;
 			t90)
 				basic_machine=t90-cray
-				os=unicos
+				basic_os=unicos
 				;;
 			toad1)
 				basic_machine=pdp10-xkl
-				os=tops20
+				basic_os=tops20
 				;;
 			tpf)
 				basic_machine=s390x-ibm
-				os=tpf
+				basic_os=tpf
 				;;
 			udi29k)
 				basic_machine=a29k-amd
-				os=udi
+				basic_os=udi
 				;;
 			ultra3)
 				basic_machine=a29k-nyu
-				os=sym1
+				basic_os=sym1
 				;;
 			v810 | necv810)
 				basic_machine=v810-nec
-				os=none
+				basic_os=none
 				;;
 			vaxv)
 				basic_machine=vax-dec
-				os=sysv
+				basic_os=sysv
 				;;
 			vms)
 				basic_machine=vax-dec
-				os=vms
+				basic_os=vms
 				;;
 			vsta)
 				basic_machine=i386-pc
-				os=vsta
+				basic_os=vsta
 				;;
 			vxworks960)
 				basic_machine=i960-wrs
-				os=vxworks
+				basic_os=vxworks
 				;;
 			vxworks68)
 				basic_machine=m68k-wrs
-				os=vxworks
+				basic_os=vxworks
 				;;
 			vxworks29k)
 				basic_machine=a29k-wrs
-				os=vxworks
+				basic_os=vxworks
 				;;
 			xbox)
 				basic_machine=i686-pc
-				os=mingw32
+				basic_os=mingw32
 				;;
 			ymp)
 				basic_machine=ymp-cray
-				os=unicos
+				basic_os=unicos
 				;;
 			*)
 				basic_machine=$1
-				os=
+				basic_os=
 				;;
 		esac
 		;;
@@ -683,17 +702,17 @@ case $basic_machine in
 	bluegene*)
 		cpu=powerpc
 		vendor=ibm
-		os=cnk
+		basic_os=cnk
 		;;
 	decsystem10* | dec10*)
 		cpu=pdp10
 		vendor=dec
-		os=tops10
+		basic_os=tops10
 		;;
 	decsystem20* | dec20*)
 		cpu=pdp10
 		vendor=dec
-		os=tops20
+		basic_os=tops20
 		;;
 	delta | 3300 | motorola-3300 | motorola-delta \
 	      | 3300-motorola | delta-motorola)
@@ -703,7 +722,7 @@ case $basic_machine in
 	dpx2*)
 		cpu=m68k
 		vendor=bull
-		os=sysv3
+		basic_os=sysv3
 		;;
 	encore | umax | mmax)
 		cpu=ns32k
@@ -712,7 +731,7 @@ case $basic_machine in
 	elxsi)
 		cpu=elxsi
 		vendor=elxsi
-		os=${os:-bsd}
+		basic_os=${basic_os:-bsd}
 		;;
 	fx2800)
 		cpu=i860
@@ -725,7 +744,7 @@ case $basic_machine in
 	h3050r* | hiux*)
 		cpu=hppa1.1
 		vendor=hitachi
-		os=hiuxwe2
+		basic_os=hiuxwe2
 		;;
 	hp3k9[0-9][0-9] | hp9[0-9][0-9])
 		cpu=hppa1.0
@@ -768,36 +787,36 @@ case $basic_machine in
 	i*86v32)
 		cpu=`echo "$1" | sed -e 's/86.*/86/'`
 		vendor=pc
-		os=sysv32
+		basic_os=sysv32
 		;;
 	i*86v4*)
 		cpu=`echo "$1" | sed -e 's/86.*/86/'`
 		vendor=pc
-		os=sysv4
+		basic_os=sysv4
 		;;
 	i*86v)
 		cpu=`echo "$1" | sed -e 's/86.*/86/'`
 		vendor=pc
-		os=sysv
+		basic_os=sysv
 		;;
 	i*86sol2)
 		cpu=`echo "$1" | sed -e 's/86.*/86/'`
 		vendor=pc
-		os=solaris2
+		basic_os=solaris2
 		;;
 	j90 | j90-cray)
 		cpu=j90
 		vendor=cray
-		os=${os:-unicos}
+		basic_os=${basic_os:-unicos}
 		;;
 	iris | iris4d)
 		cpu=mips
 		vendor=sgi
-		case $os in
+		case $basic_os in
 		    irix*)
 			;;
 		    *)
-			os=irix4
+			basic_os=irix4
 			;;
 		esac
 		;;
@@ -808,26 +827,26 @@ case $basic_machine in
 	*mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
 		cpu=m68k
 		vendor=atari
-		os=mint
+		basic_os=mint
 		;;
 	news-3600 | risc-news)
 		cpu=mips
 		vendor=sony
-		os=newsos
+		basic_os=newsos
 		;;
 	next | m*-next)
 		cpu=m68k
 		vendor=next
-		case $os in
+		case $basic_os in
 		    openstep*)
 		        ;;
 		    nextstep*)
 			;;
 		    ns2*)
-		      os=nextstep2
+		      basic_os=nextstep2
 			;;
 		    *)
-		      os=nextstep3
+		      basic_os=nextstep3
 			;;
 		esac
 		;;
@@ -838,12 +857,12 @@ case $basic_machine in
 	op50n-* | op60c-*)
 		cpu=hppa1.1
 		vendor=oki
-		os=proelf
+		basic_os=proelf
 		;;
 	pa-hitachi)
 		cpu=hppa1.1
 		vendor=hitachi
-		os=hiuxwe2
+		basic_os=hiuxwe2
 		;;
 	pbd)
 		cpu=sparc
@@ -880,12 +899,12 @@ case $basic_machine in
 	sde)
 		cpu=mipsisa32
 		vendor=sde
-		os=${os:-elf}
+		basic_os=${basic_os:-elf}
 		;;
 	simso-wrs)
 		cpu=sparclite
 		vendor=wrs
-		os=vxworks
+		basic_os=vxworks
 		;;
 	tower | tower-32)
 		cpu=m68k
@@ -902,7 +921,7 @@ case $basic_machine in
 	w89k-*)
 		cpu=hppa1.1
 		vendor=winbond
-		os=proelf
+		basic_os=proelf
 		;;
 	none)
 		cpu=none
@@ -919,11 +938,13 @@ case $basic_machine in
 
 	*-*)
 		# shellcheck disable=SC2162
+		saved_IFS=$IFS
 		IFS="-" read cpu vendor <<EOF
 $basic_machine
 EOF
+		IFS=$saved_IFS
 		;;
-	# We use `pc' rather than `unknown'
+	# We use 'pc' rather than 'unknown'
 	# because (1) that's what they normally are, and
 	# (2) the word "unknown" tends to confuse beginning users.
 	i*86 | x86_64)
@@ -955,11 +976,11 @@ case $cpu-$vendor in
 	# some cases the only manufacturer, in others, it is the most popular.
 	craynv-unknown)
 		vendor=cray
-		os=${os:-unicosmp}
+		basic_os=${basic_os:-unicosmp}
 		;;
 	c90-unknown | c90-cray)
 		vendor=cray
-		os=${os:-unicos}
+		basic_os=${Basic_os:-unicos}
 		;;
 	fx80-unknown)
 		vendor=alliant
@@ -1000,10 +1021,15 @@ case $cpu-$vendor in
 		;;
 
 	# Here we normalize CPU types with a missing or matching vendor
+	armh-unknown | armh-alt)
+		cpu=armv7l
+		vendor=alt
+		basic_os=${basic_os:-linux-gnueabihf}
+		;;
 	dpx20-unknown | dpx20-bull)
 		cpu=rs6000
 		vendor=bull
-		os=${os:-bosx}
+		basic_os=${basic_os:-bosx}
 		;;
 
 	# Here we normalize CPU types irrespective of the vendor
@@ -1012,7 +1038,7 @@ case $cpu-$vendor in
 		;;
 	blackfin-*)
 		cpu=bfin
-		os=linux
+		basic_os=linux
 		;;
 	c54x-*)
 		cpu=tic54x
@@ -1025,7 +1051,7 @@ case $cpu-$vendor in
 		;;
 	e500v[12]-*)
 		cpu=powerpc
-		os=$os"spe"
+		basic_os=${basic_os}"spe"
 		;;
 	mips3*-*)
 		cpu=mips64
@@ -1035,7 +1061,7 @@ case $cpu-$vendor in
 		;;
 	m68knommu-*)
 		cpu=m68k
-		os=linux
+		basic_os=linux
 		;;
 	m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
 		cpu=s12z
@@ -1045,12 +1071,12 @@ case $cpu-$vendor in
 		;;
 	parisc-*)
 		cpu=hppa
-		os=linux
+		basic_os=linux
 		;;
 	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
 		cpu=i586
 		;;
-	pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*)
+	pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*)
 		cpu=i686
 		;;
 	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
@@ -1101,11 +1127,14 @@ case $cpu-$vendor in
 	xscale-* | xscalee[bl]-*)
 		cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
 		;;
+	arm64-* | aarch64le-*)
+		cpu=aarch64
+		;;
 
 	# Recognize the canonical CPU Types that limit and/or modify the
 	# company names they are paired with.
 	cr16-*)
-		os=${os:-elf}
+		basic_os=${basic_os:-elf}
 		;;
 	crisv32-* | etraxfs*-*)
 		cpu=crisv32
@@ -1116,7 +1145,7 @@ case $cpu-$vendor in
 		vendor=axis
 		;;
 	crx-*)
-		os=${os:-elf}
+		basic_os=${basic_os:-elf}
 		;;
 	neo-tandem)
 		cpu=neo
@@ -1138,16 +1167,12 @@ case $cpu-$vendor in
 		cpu=nsx
 		vendor=tandem
 		;;
-	s390-*)
-		cpu=s390
-		vendor=ibm
-		;;
-	s390x-*)
-		cpu=s390x
-		vendor=ibm
+	mipsallegrexel-sony)
+		cpu=mipsallegrexel
+		vendor=sony
 		;;
 	tile*-*)
-		os=${os:-linux-gnu}
+		basic_os=${basic_os:-linux-gnu}
 		;;
 
 	*)
@@ -1156,15 +1181,15 @@ case $cpu-$vendor in
 		case $cpu in
 			1750a | 580 \
 			| a29k \
-			| aarch64 | aarch64_be \
+			| aarch64 | aarch64_be | aarch64c | arm64ec \
 			| abacus \
 			| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
 			| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
 			| alphapca5[67] | alpha64pca5[67] \
 			| am33_2.0 \
 			| amdgcn \
-			| arc | arceb \
-			| arm  | arm[lb]e | arme[lb] | armv* \
+			| arc | arceb | arc32 | arc64 \
+			| arm | arm[lb]e | arme[lb] | armv* \
 			| avr | avr32 \
 			| asmjs \
 			| ba \
@@ -1175,45 +1200,29 @@ case $cpu-$vendor in
 			| d10v | d30v | dlx | dsp16xx \
 			| e2k | elxsi | epiphany \
 			| f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
+			| javascript \
 			| h8300 | h8500 \
 			| hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
 			| hexagon \
 			| i370 | i*86 | i860 | i960 | ia16 | ia64 \
 			| ip2k | iq2000 \
 			| k1om \
+			| kvx \
 			| le32 | le64 \
 			| lm32 \
+			| loongarch32 | loongarch64 \
 			| m32c | m32r | m32rle \
 			| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
 			| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
 			| m88110 | m88k | maxq | mb | mcore | mep | metag \
 			| microblaze | microblazeel \
-			| mips | mipsbe | mipseb | mipsel | mipsle \
-			| mips16 \
-			| mips64 | mips64eb | mips64el \
-			| mips64octeon | mips64octeonel \
-			| mips64orion | mips64orionel \
-			| mips64r5900 | mips64r5900el \
-			| mips64vr | mips64vrel \
-			| mips64vr4100 | mips64vr4100el \
-			| mips64vr4300 | mips64vr4300el \
-			| mips64vr5000 | mips64vr5000el \
-			| mips64vr5900 | mips64vr5900el \
-			| mipsisa32 | mipsisa32el \
-			| mipsisa32r2 | mipsisa32r2el \
-			| mipsisa32r6 | mipsisa32r6el \
-			| mipsisa64 | mipsisa64el \
-			| mipsisa64r2 | mipsisa64r2el \
-			| mipsisa64r6 | mipsisa64r6el \
-			| mipsisa64sb1 | mipsisa64sb1el \
-			| mipsisa64sr71k | mipsisa64sr71kel \
-			| mipsr5900 | mipsr5900el \
-			| mipstx39 | mipstx39el \
+			| mips* \
 			| mmix \
 			| mn10200 | mn10300 \
 			| moxie \
 			| mt \
 			| msp430 \
+			| nanomips* \
 			| nds32 | nds32le | nds32be \
 			| nfp \
 			| nios | nios2 | nios2eb | nios2el \
@@ -1227,8 +1236,9 @@ case $cpu-$vendor in
 			| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
 			| pru \
 			| pyramid \
-			| riscv | riscv32 | riscv64 \
+			| riscv | riscv32 | riscv32be | riscv64 | riscv64be \
 			| rl78 | romp | rs6000 | rx \
+			| s390 | s390x \
 			| score \
 			| sh | shl \
 			| sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
@@ -1238,11 +1248,13 @@ case $cpu-$vendor in
 			| sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
 			| spu \
 			| tahoe \
+			| thumbv7* \
 			| tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
 			| tron \
 			| ubicom32 \
 			| v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
 			| vax \
+			| vc4 \
 			| visium \
 			| w65 \
 			| wasm32 | wasm64 \
@@ -1254,7 +1266,7 @@ case $cpu-$vendor in
 				;;
 
 			*)
-				echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2
+				echo "Invalid configuration '$1': machine '$cpu-$vendor' not recognized" 1>&2
 				exit 1
 				;;
 		esac
@@ -1275,8 +1287,54 @@ esac
 
 # Decode manufacturer-specific aliases for certain operating systems.
 
-if [ x$os != x ]
+if test x"$basic_os" != x
 then
+
+# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just
+# set os.
+obj=
+case $basic_os in
+	gnu/linux*)
+		kernel=linux
+		os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
+		;;
+	os2-emx)
+		kernel=os2
+		os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'`
+		;;
+	nto-qnx*)
+		kernel=nto
+		os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
+		;;
+	*-*)
+		# shellcheck disable=SC2162
+		saved_IFS=$IFS
+		IFS="-" read kernel os <<EOF
+$basic_os
+EOF
+		IFS=$saved_IFS
+		;;
+	# Default OS when just kernel was specified
+	nto*)
+		kernel=nto
+		os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
+		;;
+	linux*)
+		kernel=linux
+		os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
+		;;
+	managarm*)
+		kernel=managarm
+		os=`echo "$basic_os" | sed -e 's|managarm|mlibc|'`
+		;;
+	*)
+		kernel=
+		os=$basic_os
+		;;
+esac
+
+# Now, normalize the OS (knowing we just have one component, it's not a kernel,
+# etc.)
 case $os in
 	# First match some system type aliases that might get confused
 	# with valid system types.
@@ -1288,7 +1346,7 @@ case $os in
 		os=cnk
 		;;
 	solaris1 | solaris1.*)
-		os=`echo $os | sed -e 's|solaris1|sunos4|'`
+		os=`echo "$os" | sed -e 's|solaris1|sunos4|'`
 		;;
 	solaris)
 		os=solaris2
@@ -1296,9 +1354,6 @@ case $os in
 	unixware*)
 		os=sysv4.2uw
 		;;
-	gnu/linux*)
-		os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
-		;;
 	# es1800 is here to avoid being matched by es* (a different OS)
 	es1800*)
 		os=ose
@@ -1320,12 +1375,9 @@ case $os in
 		os=sco3.2v4
 		;;
 	sco3.2.[4-9]*)
-		os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
-		;;
-	sco3.2v[4-9]* | sco5v6*)
-		# Don't forget version if it is 3.2v4 or newer.
+		os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'`
 		;;
-	scout)
+	sco*v* | scout)
 		# Don't match below
 		;;
 	sco*)
@@ -1334,78 +1386,25 @@ case $os in
 	psos*)
 		os=psos
 		;;
-	# Now accept the basic system types.
-	# The portable systems comes first.
-	# Each alternative MUST end in a * to match a version number.
-	# sysv* is not here because it comes later, after sysvr4.
-	gnu* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
-	     | *vms* | esix* | aix* | cnk* | sunos | sunos[34]*\
-	     | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
-	     | sym* | kopensolaris* | plan9* \
-	     | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
-	     | aos* | aros* | cloudabi* | sortix* | twizzler* \
-	     | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
-	     | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
-	     | knetbsd* | mirbsd* | netbsd* \
-	     | bitrig* | openbsd* | solidbsd* | libertybsd* | os108* \
-	     | ekkobsd* | kfreebsd* | freebsd* | riscix* | lynxos* \
-	     | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
-	     | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
-	     | udi* | eabi* | lites* | ieee* | go32* | aux* | hcos* \
-	     | chorusrdb* | cegcc* | glidix* \
-	     | cygwin* | msys* | pe* | moss* | proelf* | rtems* \
-	     | midipix* | mingw32* | mingw64* | linux-gnu* | linux-android* \
-	     | linux-newlib* | linux-musl* | linux-uclibc* \
-	     | uxpv* | beos* | mpeix* | udk* | moxiebox* \
-	     | interix* | uwin* | mks* | rhapsody* | darwin* \
-	     | openstep* | oskit* | conix* | pw32* | nonstopux* \
-	     | storm-chaos* | tops10* | tenex* | tops20* | its* \
-	     | os2* | vos* | palmos* | uclinux* | nucleus* \
-	     | morphos* | superux* | rtmk* | windiss* \
-	     | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
-	     | skyos* | haiku* | rdos* | toppers* | drops* | es* \
-	     | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
-	     | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
-	     | nsk* | powerunix)
-	# Remember, each alternative MUST END IN *, to match a version number.
-		;;
 	qnx*)
-		case $cpu in
-		    x86 | i*86)
-			;;
-		    *)
-			os=nto-$os
-			;;
-		esac
+		os=qnx
 		;;
 	hiux*)
 		os=hiuxwe2
 		;;
-	nto-qnx*)
-		;;
-	nto*)
-		os=`echo $os | sed -e 's|nto|nto-qnx|'`
-		;;
-	sim | xray | os68k* | v88r* \
-	    | windows* | osx | abug | netware* | os9* \
-	    | macos* | mpw* | magic* | mmixware* | mon960* | lnews*)
-		;;
-	linux-dietlibc)
-		os=linux-dietlibc
-		;;
-	linux*)
-		os=`echo $os | sed -e 's|linux|linux-gnu|'`
-		;;
 	lynx*178)
 		os=lynxos178
 		;;
 	lynx*5)
 		os=lynxos5
 		;;
+	lynxos*)
+		# don't get caught up in next wildcard
+		;;
 	lynx*)
 		os=lynxos
 		;;
-	mac*)
+	mac[0-9]*)
 		os=`echo "$os" | sed -e 's|mac|macos|'`
 		;;
 	opened*)
@@ -1452,7 +1451,7 @@ case $os in
 		;;
 	# Preserve the version number of sinix5.
 	sinix5.*)
-		os=`echo $os | sed -e 's|sinix|sysv|'`
+		os=`echo "$os" | sed -e 's|sinix|sysv|'`
 		;;
 	sinix*)
 		os=sysv4
@@ -1475,18 +1474,12 @@ case $os in
 	sysvr4)
 		os=sysv4
 		;;
-	# This must come after sysvr4.
-	sysv*)
-		;;
 	ose*)
 		os=ose
 		;;
 	*mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
 		os=mint
 		;;
-	zvmoe)
-		os=zvmoe
-		;;
 	dicos*)
 		os=dicos
 		;;
@@ -1499,23 +1492,21 @@ case $os in
 			os=eabi
 			;;
 		    *)
-			os=elf
+			os=
+			obj=elf
 			;;
 		esac
 		;;
-	nacl*)
-		;;
-	ios)
-		;;
-	none)
-		;;
-	*-eabi)
+	aout* | coff* | elf* | pe*)
+		# These are machine code file formats, not OSes
+		obj=$os
+		os=
 		;;
 	*)
-		echo Invalid configuration \`"$1"\': system \`"$os"\' not recognized 1>&2
-		exit 1
+		# No normalization, but not necessarily accepted, that comes below.
 		;;
 esac
+
 else
 
 # Here we handle the default operating systems that come with various machines.
@@ -1528,42 +1519,54 @@ else
 # will signal an error saying that MANUFACTURER isn't an operating
 # system, and we'll never get to this point.
 
+kernel=
+obj=
 case $cpu-$vendor in
 	score-*)
-		os=elf
+		os=
+		obj=elf
 		;;
 	spu-*)
-		os=elf
+		os=
+		obj=elf
 		;;
 	*-acorn)
 		os=riscix1.2
 		;;
 	arm*-rebel)
-		os=linux
+		kernel=linux
+		os=gnu
 		;;
 	arm*-semi)
-		os=aout
+		os=
+		obj=aout
 		;;
 	c4x-* | tic4x-*)
-		os=coff
+		os=
+		obj=coff
 		;;
 	c8051-*)
-		os=elf
+		os=
+		obj=elf
 		;;
 	clipper-intergraph)
 		os=clix
 		;;
 	hexagon-*)
-		os=elf
+		os=
+		obj=elf
 		;;
 	tic54x-*)
-		os=coff
+		os=
+		obj=coff
 		;;
 	tic55x-*)
-		os=coff
+		os=
+		obj=coff
 		;;
 	tic6x-*)
-		os=coff
+		os=
+		obj=coff
 		;;
 	# This must come before the *-dec entry.
 	pdp10-*)
@@ -1585,19 +1588,24 @@ case $cpu-$vendor in
 		os=sunos3
 		;;
 	m68*-cisco)
-		os=aout
+		os=
+		obj=aout
 		;;
 	mep-*)
-		os=elf
+		os=
+		obj=elf
 		;;
 	mips*-cisco)
-		os=elf
+		os=
+		obj=elf
 		;;
-	mips*-*)
-		os=elf
+	mips*-*|nanomips*-*)
+		os=
+		obj=elf
 		;;
 	or32-*)
-		os=coff
+		os=
+		obj=coff
 		;;
 	*-tti)	# must be before sparc entry or we get the wrong os.
 		os=sysv3
@@ -1606,7 +1614,8 @@ case $cpu-$vendor in
 		os=sunos4.1.1
 		;;
 	pru-*)
-		os=elf
+		os=
+		obj=elf
 		;;
 	*-be)
 		os=beos
@@ -1687,10 +1696,12 @@ case $cpu-$vendor in
 		os=uxpv
 		;;
 	*-rom68k)
-		os=coff
+		os=
+		obj=coff
 		;;
 	*-*bug)
-		os=coff
+		os=
+		obj=coff
 		;;
 	*-apple)
 		os=macos
@@ -1705,84 +1716,251 @@ case $cpu-$vendor in
 		os=none
 		;;
 esac
+
 fi
 
+# Now, validate our (potentially fixed-up) individual pieces (OS, OBJ).
+
+case $os in
+	# Sometimes we do "kernel-libc", so those need to count as OSes.
+	llvm* | musl* | newlib* | relibc* | uclibc*)
+		;;
+	# Likewise for "kernel-abi"
+	eabi* | gnueabi*)
+		;;
+	# VxWorks passes extra cpu info in the 4th filed.
+	simlinux | simwindows | spe)
+		;;
+	# See `case $cpu-$os` validation below
+	ghcjs)
+		;;
+	# Now accept the basic system types.
+	# The portable systems comes first.
+	# Each alternative MUST end in a * to match a version number.
+	gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
+	     | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \
+	     | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
+	     | sym* |  plan9* | psp* | sim* | xray* | os68k* | v88r* \
+	     | hiux* | abug | nacl* | netware* | windows* \
+	     | os9* | macos* | osx* | ios* | tvos* | watchos* \
+	     | mpw* | magic* | mmixware* | mon960* | lnews* \
+	     | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
+	     | aos* | aros* | cloudabi* | sortix* | twizzler* \
+	     | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
+	     | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
+	     | mirbsd* | netbsd* | dicos* | openedition* | ose* \
+	     | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \
+	     | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
+	     | bosx* | nextstep* | cxux* | oabi* \
+	     | ptx* | ecoff* | winnt* | domain* | vsta* \
+	     | udi* | lites* | ieee* | go32* | aux* | hcos* \
+	     | chorusrdb* | cegcc* | glidix* | serenity* \
+	     | cygwin* | msys* | moss* | proelf* | rtems* \
+	     | midipix* | mingw32* | mingw64* | mint* \
+	     | uxpv* | beos* | mpeix* | udk* | moxiebox* \
+	     | interix* | uwin* | mks* | rhapsody* | darwin* \
+	     | openstep* | oskit* | conix* | pw32* | nonstopux* \
+	     | storm-chaos* | tops10* | tenex* | tops20* | its* \
+	     | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
+	     | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
+	     | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
+	     | skyos* | haiku* | rdos* | toppers* | drops* | es* \
+	     | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
+	     | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
+	     | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
+	     | fiwix* | mlibc* | cos* | mbr* | ironclad* )
+		;;
+	# This one is extra strict with allowed versions
+	sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
+		# Don't forget version if it is 3.2v4 or newer.
+		;;
+	# This refers to builds using the UEFI calling convention
+	# (which depends on the architecture) and PE file format.
+	# Note that this is both a different calling convention and
+	# different file format than that of GNU-EFI
+	# (x86_64-w64-mingw32).
+	uefi)
+		;;
+	none)
+		;;
+	kernel* | msvc* )
+		# Restricted further below
+		;;
+	'')
+		if test x"$obj" = x
+		then
+			echo "Invalid configuration '$1': Blank OS only allowed with explicit machine code file format" 1>&2
+		fi
+		;;
+	*)
+		echo "Invalid configuration '$1': OS '$os' not recognized" 1>&2
+		exit 1
+		;;
+esac
+
+case $obj in
+	aout* | coff* | elf* | pe*)
+		;;
+	'')
+		# empty is fine
+		;;
+	*)
+		echo "Invalid configuration '$1': Machine code format '$obj' not recognized" 1>&2
+		exit 1
+		;;
+esac
+
+# Here we handle the constraint that a (synthetic) cpu and os are
+# valid only in combination with each other and nowhere else.
+case $cpu-$os in
+	# The "javascript-unknown-ghcjs" triple is used by GHC; we
+	# accept it here in order to tolerate that, but reject any
+	# variations.
+	javascript-ghcjs)
+		;;
+	javascript-* | *-ghcjs)
+		echo "Invalid configuration '$1': cpu '$cpu' is not valid with os '$os$obj'" 1>&2
+		exit 1
+		;;
+esac
+
+# As a final step for OS-related things, validate the OS-kernel combination
+# (given a valid OS), if there is a kernel.
+case $kernel-$os-$obj in
+	linux-gnu*- | linux-android*- | linux-dietlibc*- | linux-llvm*- \
+		    | linux-mlibc*- | linux-musl*- | linux-newlib*- \
+		    | linux-relibc*- | linux-uclibc*- )
+		;;
+	uclinux-uclibc*- )
+		;;
+	managarm-mlibc*- | managarm-kernel*- )
+		;;
+	windows*-msvc*-)
+		;;
+	-dietlibc*- | -llvm*- | -mlibc*- | -musl*- | -newlib*- | -relibc*- \
+		    | -uclibc*- )
+		# These are just libc implementations, not actual OSes, and thus
+		# require a kernel.
+		echo "Invalid configuration '$1': libc '$os' needs explicit kernel." 1>&2
+		exit 1
+		;;
+	-kernel*- )
+		echo "Invalid configuration '$1': '$os' needs explicit kernel." 1>&2
+		exit 1
+		;;
+	*-kernel*- )
+		echo "Invalid configuration '$1': '$kernel' does not support '$os'." 1>&2
+		exit 1
+		;;
+	*-msvc*- )
+		echo "Invalid configuration '$1': '$os' needs 'windows'." 1>&2
+		exit 1
+		;;
+	kfreebsd*-gnu*- | kopensolaris*-gnu*-)
+		;;
+	vxworks-simlinux- | vxworks-simwindows- | vxworks-spe-)
+		;;
+	nto-qnx*-)
+		;;
+	os2-emx-)
+		;;
+	*-eabi*- | *-gnueabi*-)
+		;;
+	none--*)
+		# None (no kernel, i.e. freestanding / bare metal),
+		# can be paired with an machine code file format
+		;;
+	-*-)
+		# Blank kernel with real OS is always fine.
+		;;
+	--*)
+		# Blank kernel and OS with real machine code file format is always fine.
+		;;
+	*-*-*)
+		echo "Invalid configuration '$1': Kernel '$kernel' not known to work with OS '$os'." 1>&2
+		exit 1
+		;;
+esac
+
 # Here we handle the case where we know the os, and the CPU type, but not the
 # manufacturer.  We pick the logical manufacturer.
 case $vendor in
 	unknown)
-		case $os in
-			riscix*)
+		case $cpu-$os in
+			*-riscix*)
 				vendor=acorn
 				;;
-			sunos*)
+			*-sunos*)
 				vendor=sun
 				;;
-			cnk*|-aix*)
+			*-cnk* | *-aix*)
 				vendor=ibm
 				;;
-			beos*)
+			*-beos*)
 				vendor=be
 				;;
-			hpux*)
+			*-hpux*)
 				vendor=hp
 				;;
-			mpeix*)
+			*-mpeix*)
 				vendor=hp
 				;;
-			hiux*)
+			*-hiux*)
 				vendor=hitachi
 				;;
-			unos*)
+			*-unos*)
 				vendor=crds
 				;;
-			dgux*)
+			*-dgux*)
 				vendor=dg
 				;;
-			luna*)
+			*-luna*)
 				vendor=omron
 				;;
-			genix*)
+			*-genix*)
 				vendor=ns
 				;;
-			clix*)
+			*-clix*)
 				vendor=intergraph
 				;;
-			mvs* | opened*)
+			*-mvs* | *-opened*)
+				vendor=ibm
+				;;
+			*-os400*)
 				vendor=ibm
 				;;
-			os400*)
+			s390-* | s390x-*)
 				vendor=ibm
 				;;
-			ptx*)
+			*-ptx*)
 				vendor=sequent
 				;;
-			tpf*)
+			*-tpf*)
 				vendor=ibm
 				;;
-			vxsim* | vxworks* | windiss*)
+			*-vxsim* | *-vxworks* | *-windiss*)
 				vendor=wrs
 				;;
-			aux*)
+			*-aux*)
 				vendor=apple
 				;;
-			hms*)
+			*-hms*)
 				vendor=hitachi
 				;;
-			mpw* | macos*)
+			*-mpw* | *-macos*)
 				vendor=apple
 				;;
-			*mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
+			*-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*)
 				vendor=atari
 				;;
-			vos*)
+			*-vos*)
 				vendor=stratus
 				;;
 		esac
 		;;
 esac
 
-echo "$cpu-$vendor-$os"
+echo "$cpu-$vendor${kernel:+-$kernel}${os:+-$os}${obj:+-$obj}"
 exit
 
 # Local variables:
diff --git a/contrib/ncurses/configure b/contrib/ncurses/configure
index af702ddda06e..488d93fc1c02 100755
--- a/contrib/ncurses/configure
+++ b/contrib/ncurses/configure
@@ -1,9 +1,9 @@
 #! /bin/sh
-# From configure.in Revision: 1.729 .
+# From configure.in Revision: 1.779 .
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by Autoconf 2.52.20210105.
+# Generated by Autoconf 2.52.20231210.
 #
-# Copyright 2003-2020,2021	Thomas E. Dickey
+# Copyright 2003-2022,2023	Thomas E. Dickey
 # Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
 # Free Software Foundation, Inc.
 # This configure script is free software; the Free Software Foundation
@@ -34,9 +34,9 @@ fi
 as_me=`echo "$0" |sed 's,.*[\\/],,'`
 
 if expr a : '\(a\)' >/dev/null 2>&1; then
-  as_expr=expr
+  as_expr="expr"
 else
-  as_expr=false
+  as_expr="false"
 fi
 
 rm -f conf$$ conf$$.exe conf$$.file
@@ -51,7 +51,7 @@ if ln -s conf$$.file conf$$ 2>/dev/null; then
     as_ln_s='ln -s'
   fi
 elif ln conf$$.file conf$$ 2>/dev/null; then
-  as_ln_s=ln
+  as_ln_s='ln'
 else
   as_ln_s='cp -p'
 fi
@@ -716,22 +716,22 @@ Optional Features:
   --with-rel-version=XXX  override derived release version
   --with-abi-version=XXX  override derived ABI version
   --with-system-type=XXX  test: override derived host system-type
+  --with-abi-altered=XXX  override visible ABI version, for packaging
   --without-ada           suppress check for Ada compiler, don't build demo
   --without-cxx           do not adjust ncurses bool to match C++
   --without-cxx-binding   do not build C++ binding and demo
   --disable-db-install    suppress install of terminal database
   --without-manpages      suppress install of manpages
   --without-progs         suppress build/install with programs (e.g., tic)
-  --without-tack          suppress build/install with tack program
   --without-tests         suppress build/install with test-programs
   --without-curses-h      install curses.h as ncurses.h only
-  --with-config-suffix=X  suffixes ncursesXX-config file
-  --with-pkg-config{=path} enable/disable use of pkg-config
-  --with-pkg-config-libdir=XXX use given directory for installing pc-files
+  --with-config-suffix=X  name ncurses*X-config file with X
+  --with-pkg-config[=CMD] enable/disable use of pkg-config and its name CMD
+  --with-pkg-config-libdir[=XXX] use given directory for installing pc-files
   --enable-pc-files       generate and install .pc files for pkg-config
-  --with-pc-suffix        suffixes pc-files
+  --with-pc-suffix[=XXX]  suffix pkg-config files with XXX
   --enable-mixed-case     tic should assume mixed-case filenames
-  --with-install-prefix   prefixes actual install-location ($DESTDIR)
+  --with-install-prefix=DESTDIR use DESTDIR as installation directory prefix
 Build-Tools Needed to Compile Temporary Applications for Cross-compiling:
   --with-build-cc=XXX     the build C compiler ($BUILD_CC)
   --with-build-cpp=XXX    the build C preprocessor ($BUILD_CPP)
@@ -752,10 +752,10 @@ Options to Specify the Libraries Built/Used:
   --with-ticlib           generate separate tic library
   --enable-rpath          use rpath option when generating shared libraries
   --disable-relink        relink shared libraries during install
-  --with-shlib-version=X  Specify rel or abi version for shared libs
-  --with-libtool-opts=XXX specify additional libtool options
-  --with-export-syms=XXX  limit exported symbols using libtool
-  --with-versioned-syms=X markup versioned symbols using ld
+  --with-shlib-version[={rel|abi}] use release or ABI version in shared library file names
+  --with-libtool-opts[=XXX] give libtool additional options XXX
+  --with-export-syms[=SYM-FILE] limit symbols exported by libtool to those listed in SYM-FILE
+  --with-versioned-syms[=MAP-FILE] version ELF shared library symbols per MAP-FILE
   --with-gpm              use Alessandro Rubini's GPM library
   --without-dlsym         do not use dlsym() to load GPM dynamically
   --with-pcre2            use PCRE2 for regular-expressions
@@ -764,7 +764,7 @@ Options to Specify the Libraries Built/Used:
   --disable-rpath-hack    don't add rpath options for additional libraries
   --disable-pkg-ldflags   disable extra LDFLAGS for package-scripts
 Fine-Tuning Your Configuration:
-  --with-extra-suffix=X   append extra suffix to header/library paths
+  --with-extra-suffix[=X] append extra suffix X to header/library paths
   --disable-overwrite     put headers in subdir, omit link to -lcurses
   --disable-database      do not use terminfo, only fallbacks/termcap
   --with-database=XXX     specify terminfo source to install
@@ -773,7 +773,7 @@ Fine-Tuning Your Configuration:
   --with-tic-path=XXX     specify path of tic for fallbacks
   --with-infocmp-path=XXX     specify path of infocmp for fallbacks
   --without-xterm-new     specify if xterm terminfo should be old version
-  --with-xterm-kbs=XXX    specify if xterm backspace sends BS or DEL
+  --with-xterm-kbs[=XXX]  specify if xterm backspace sends BS or DEL
   --with-terminfo-dirs=XXX specify list of terminfo directories (default: DATADIR/terminfo)
   --with-default-terminfo-dir=DIR default terminfo directory (default: DATADIR/terminfo)
   --disable-big-core      assume machine has little memory
@@ -783,29 +783,32 @@ Fine-Tuning Your Configuration:
   --enable-getcap         fast termcap load, no xrefs to terminfo
   --enable-getcap-cache   cache translated termcaps in ~/.terminfo
   --disable-home-terminfo drop ~/.terminfo from terminfo search-path
-  --disable-root-environ  restrict environment when running as root
+  --disable-root-environ  restrict root use of ncurses environment variables
+  --disable-root-access   restrict file-access when running setuid
+  --disable-setuid-environ restrict setuid use of ncurses environment variables
   --enable-symlinks       make tic use symbolic links not hard links
   --enable-broken_linker  compile with broken-linker support code
   --enable-bsdpad         recognize BSD-style prefix padding
-  --enable-widec          compile with wide-char/UTF-8 code
+  --disable-widec         compile without wide character and UTF-8 support
   --disable-lp64          allow chtype to be long (ignore _LP64)
   --disable-largefile     omit support for large files
   --disable-tparm-varargs compile tparm() without varargs interface
   --disable-tic-depends   link tic library without explicit dependency on ncurses library
-  --disable-wattr-macros  suppress wattr* macros to help with ncurses5/ncurses6 transition
-  --with-x11-rgb=FILE   file containing X11 rgb information (EPREFIX/lib/X11/rgb.txt)
-  --with-bool=TYPE        override fallback type of bool variable
+  --enable-wattr-macros   enable wattr* macros
+  --with-x11-rgb=FILE     obtain X11 color definitions from FILE (default: EPREFIX/lib/X11/rgb.txt)
+  --with-bool=TYPE        fall back to TYPE for curses 'bool' typedef
   --with-caps=alt         compile with alternate Caps file
   --with-chtype=TYPE      override type of chtype
   --with-ospeed=TYPE      override type of ospeed variable
   --with-mmask-t=TYPE     override type of mmask_t
   --with-ccharw-max=XXX   override size CCHARW_MAX
-  --enable-signed-char    compile using signed Boolean's in term.h
+  --enable-signed-char    use signed chars for Boolean array in term.h
   --with-tparm-arg=TYPE   override parameter type of tparm
   --with-rcs-ids          compile-in RCS identifiers
 Options to Specify How Manpages are Installed:
-  --with-manpage-format   specify manpage-format: gzip/compress/BSDI/normal and
-                          optionally formatted/catonly, e.g., gzip,formatted
+  --with-manpage-format   specify manpage-format: gzip/compress/bzip2/xz,
+                          BSDI/normal and optionally formatted/catonly,
+                          e.g., gzip,formatted
   --with-manpage-renames  specify manpage-renaming
   --with-manpage-aliases  specify manpage-aliases using .so
   --with-manpage-symlinks specify manpage-aliases using symlinks
@@ -826,13 +829,14 @@ Reentrant Code:
   --enable-pthreads-eintr enable EINTR in wgetch with pthreads
   --enable-weak-symbols   enable weak-symbols for pthreads
   --enable-reentrant      compile with reentrant code
-  --enable-opaque-curses  make curses WINDOW, etc., "opaque"
-  --enable-opaque-form    make form-library structures "opaque"
-  --enable-opaque-menu    make menu-library structures "opaque"
-  --enable-opaque-panel   make panel-library structures "opaque"
+  --disable-opaque-curses do not make WINDOW, etc., structures opaque
+  --disable-opaque-form   do not make form library structures opaque
+  --disable-opaque-menu   do not make menu library structures opaque
+  --disable-opaque-panel  do not make panel library structures opaque
   --with-wrap-prefix=XXX  override prefix used for public variables
 Development Code:
   --without-develop       disable development options
+  --enable-check-size     compile-in code to detect screensize of serial terminals
   --enable-hard-tabs      compile with hard-tabs code
   --enable-xmc-glitch     compile with support for xmc (magic-cookie)
 Experimental Code:
@@ -848,7 +852,9 @@ Experimental Code:
 Testing/development Options:
   --disable-echo          do not display "compiling" commands
   --disable-stripping     do not strip (debug info) installed executables
+  --with-strip-program=XX specify program to use when stripping in install
   --enable-warnings       test: turn on gcc compiler warnings
+  --enable-stdnoreturn    enable C11 _Noreturn feature for diagnostics
   --enable-string-hacks   work around bogus compiler/loader warnings
   --enable-assertions     test: turn on generation of assertion code
   --with-dmalloc          test: use Gray Watson's dmalloc library
@@ -860,15 +866,16 @@ Testing/development Options:
   --with-trace            test: add trace() function to all models of ncurses
   --disable-gnat-projects test: disable GNAT projects even if usable
 Ada Binding Options:
-  --with-ada-compiler=CMD specify Ada95 compiler command (default gnatmake)
-  --with-ada-include=DIR  Ada includes are in DIR (default: PREFIX/share/ada/adainclude)
-  --with-ada-objects=DIR  Ada objects are in DIR (default: PREFIX/lib/ada/adalib)
-  --with-ada-sharedlib=soname build shared-library (requires GNAT projects)
-  --with-ada-libname=XXX  override default Ada library-name
-  --with-form-libname=XXX override form basename of library
-  --with-menu-libname=XXX override menu basename of library
-  --with-panel-libname=XXX override panel basename of library
-  --with-cxx-libname=XXX override ncurses++ basename of library
+  --with-ada-compiler[=CMD] use CMD as Ada95 compiler (default: gnatmake)
+  --with-ada-include=DIR  find Ada95 includes in DIR (default: PREFIX/share/ada/adainclude)
+  --with-ada-objects=DIR  find Ada95 objects in DIR (default: PREFIX/lib/ada/adalib)
+  --with-ada-sharedlib    build Ada95 shared library; requires GNAT project support
+  --with-ada-libname[=XXX]  use XXX as Ada95 library name
+Library basenames for pkgsrc:
+  --with-form-libname[=XXX] override ifelse(,,form,) basename of library
+  --with-menu-libname[=XXX] override ifelse(,,menu,) basename of library
+  --with-panel-libname[=XXX] override ifelse(,,panel,) basename of library
+  --with-cxx-libname[=XXX] override ifelse(ncurses++,,cxx,ncurses++) basename of library
 
 Some influential environment variables:
   CC          C compiler command
@@ -928,7 +935,7 @@ test -n "$ac_init_help" && exit 0
 if "$ac_init_version"; then
   cat <<\EOF
 
-Copyright 2003-2020,2021	Thomas E. Dickey
+Copyright 2003-2022,2023	Thomas E. Dickey
 Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
 Free Software Foundation, Inc.
 This configure script is free software; the Free Software Foundation
@@ -942,7 +949,7 @@ This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
 It was created by $as_me, which was
-generated by GNU Autoconf 2.52.20210105.  Invocation command line was
+generated by GNU Autoconf 2.52.20231210.  Invocation command line was
 
   $ $0 $@
 
@@ -1066,7 +1073,7 @@ if test -z "$CONFIG_SITE"; then
 fi
 for ac_site_file in $CONFIG_SITE; do
   if test -r "$ac_site_file"; then
-    { echo "$as_me:1069: loading site script $ac_site_file" >&5
+    { echo "$as_me:1076: loading site script $ac_site_file" >&5
 echo "$as_me: loading site script $ac_site_file" >&6;}
     cat "$ac_site_file" >&5
     . "$ac_site_file"
@@ -1077,7 +1084,7 @@ if test -r "$cache_file"; then
   # Some versions of bash will fail to source /dev/null (special
   # files actually), so we avoid doing that.
   if test -f "$cache_file"; then
-    { echo "$as_me:1080: loading cache $cache_file" >&5
+    { echo "$as_me:1087: loading cache $cache_file" >&5
 echo "$as_me: loading cache $cache_file" >&6;}
     case $cache_file in
       [\\/]* | ?:[\\/]* ) . $cache_file;;
@@ -1085,7 +1092,7 @@ echo "$as_me: loading cache $cache_file" >&6;}
     esac
   fi
 else
-  { echo "$as_me:1088: creating cache $cache_file" >&5
+  { echo "$as_me:1095: creating cache $cache_file" >&5
 echo "$as_me: creating cache $cache_file" >&6;}
   >$cache_file
 fi
@@ -1101,21 +1108,21 @@ for ac_var in `(set) 2>&1 |
   eval ac_new_val="\$ac_env_${ac_var}_value"
   case "$ac_old_set,$ac_new_set" in
     set,)
-      { echo "$as_me:1104: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+      { echo "$as_me:1111: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
 echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
       ac_cache_corrupted=: ;;
     ,set)
-      { echo "$as_me:1108: error: \`$ac_var' was not set in the previous run" >&5
+      { echo "$as_me:1115: error: \`$ac_var' was not set in the previous run" >&5
 echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
       ac_cache_corrupted=: ;;
     ,);;
     *)
       if test "x$ac_old_val" != "x$ac_new_val"; then
-        { echo "$as_me:1114: error: \`$ac_var' has changed since the previous run:" >&5
+        { echo "$as_me:1121: error: \`$ac_var' has changed since the previous run:" >&5
 echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
-        { echo "$as_me:1116:   former value:  $ac_old_val" >&5
+        { echo "$as_me:1123:   former value:  $ac_old_val" >&5
 echo "$as_me:   former value:  $ac_old_val" >&2;}
-        { echo "$as_me:1118:   current value: $ac_new_val" >&5
+        { echo "$as_me:1125:   current value: $ac_new_val" >&5
 echo "$as_me:   current value: $ac_new_val" >&2;}
         ac_cache_corrupted=:
       fi;;
@@ -1134,9 +1141,9 @@ echo "$as_me:   current value: $ac_new_val" >&2;}
   fi
 done
 if "$ac_cache_corrupted"; then
-  { echo "$as_me:1137: error: changes in the environment can compromise the build" >&5
+  { echo "$as_me:1144: error: changes in the environment can compromise the build" >&5
 echo "$as_me: error: changes in the environment can compromise the build" >&2;}
-  { { echo "$as_me:1139: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
+  { { echo "$as_me:1146: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
 echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -1165,10 +1172,10 @@ esac
 echo "#! $SHELL" >conftest.sh
 echo  "exit 0"   >>conftest.sh
 chmod +x conftest.sh
-if { (echo "$as_me:1168: PATH=\".;.\"; conftest.sh") >&5
+if { (echo "$as_me:1175: PATH=\".;.\"; conftest.sh") >&5
   (PATH=".;."; conftest.sh) 2>&5
   ac_status=$?
-  echo "$as_me:1171: \$? = $ac_status" >&5
+  echo "$as_me:1178: \$? = $ac_status" >&5
   (exit "$ac_status"); }; then
   ac_path_separator=';'
 else
@@ -1185,7 +1192,7 @@ for ac_prog in ggrep grep
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:1188: checking for $ac_word" >&5
+echo "$as_me:1195: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_GREP+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1200,7 +1207,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_GREP="$ac_prog"
-echo "$as_me:1203: found $ac_dir/$ac_word" >&5
+echo "$as_me:1210: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -1208,10 +1215,10 @@ fi
 fi
 GREP=$ac_cv_prog_GREP
 if test -n "$GREP"; then
-  echo "$as_me:1211: result: $GREP" >&5
+  echo "$as_me:1218: result: $GREP" >&5
 echo "${ECHO_T}$GREP" >&6
 else
-  echo "$as_me:1214: result: no" >&5
+  echo "$as_me:1221: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -1219,7 +1226,7 @@ fi
 done
 test -n "$GREP" || GREP=": "
 
-echo "$as_me:1222: checking for egrep" >&5
+echo "$as_me:1229: checking for egrep" >&5
 echo $ECHO_N "checking for egrep... $ECHO_C" >&6
 if test "${ac_cv_path_EGREP+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1231,7 +1238,7 @@ else
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:1234: checking for $ac_word" >&5
+echo "$as_me:1241: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_path_EGREP+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1248,7 +1255,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   if $as_executable_p "$ac_dir/$ac_word"; then
    ac_cv_path_EGREP="$ac_dir/$ac_word"
-   echo "$as_me:1251: found $ac_dir/$ac_word" >&5
+   echo "$as_me:1258: found $ac_dir/$ac_word" >&5
    break
 fi
 done
@@ -1259,10 +1266,10 @@ fi
 EGREP=$ac_cv_path_EGREP
 
 if test -n "$EGREP"; then
-  echo "$as_me:1262: result: $EGREP" >&5
+  echo "$as_me:1269: result: $EGREP" >&5
 echo "${ECHO_T}$EGREP" >&6
 else
-  echo "$as_me:1265: result: no" >&5
+  echo "$as_me:1272: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -1270,12 +1277,12 @@ fi
 done
 test -n "$EGREP" || EGREP=": "
 
-     test "x$ac_cv_path_EGREP" = "x:" && { { echo "$as_me:1273: error: cannot find workable egrep" >&5
+     test "x$ac_cv_path_EGREP" = "x:" && { { echo "$as_me:1280: error: cannot find workable egrep" >&5
 echo "$as_me: error: cannot find workable egrep" >&2;}
    { (exit 1); exit 1; }; }
    fi
 fi
-echo "$as_me:1278: result: $ac_cv_path_EGREP" >&5
+echo "$as_me:1285: result: $ac_cv_path_EGREP" >&5
 echo "${ECHO_T}$ac_cv_path_EGREP" >&6
  EGREP="$ac_cv_path_EGREP"
 
@@ -1283,13 +1290,14 @@ NCURSES_MAJOR="`${EGREP-egrep} '^NCURSES_MAJOR[ 	]*=' "$srcdir/dist.mk" | sed -e
 NCURSES_MINOR="`${EGREP-egrep} '^NCURSES_MINOR[ 	]*=' "$srcdir/dist.mk" | sed -e 's/^[^0-9]*//'`"
 NCURSES_PATCH="`${EGREP-egrep} '^NCURSES_PATCH[ 	]*=' "$srcdir/dist.mk" | sed -e 's/^[^0-9]*//'`"
 cf_cv_abi_version=${NCURSES_MAJOR}
+cf_cv_abi_default=${NCURSES_MAJOR}
 cf_cv_rel_version=${NCURSES_MAJOR}.${NCURSES_MINOR}
 cf_cv_timestamp=`date`
-echo "$as_me:1288: result: Configuring NCURSES $cf_cv_rel_version ABI $cf_cv_abi_version ($cf_cv_timestamp)" >&5
-echo "${ECHO_T}Configuring NCURSES $cf_cv_rel_version ABI $cf_cv_abi_version ($cf_cv_timestamp)" >&6
+echo "$as_me:1296: result: Configuring NCURSES $cf_cv_rel_version ABI $cf_cv_abi_default ($cf_cv_timestamp)" >&5
+echo "${ECHO_T}Configuring NCURSES $cf_cv_rel_version ABI $cf_cv_abi_default ($cf_cv_timestamp)" >&6
 
 if test -f "$srcdir/VERSION" ; then
-	echo "$as_me:1292: checking for package version" >&5
+	echo "$as_me:1300: checking for package version" >&5
 echo $ECHO_N "checking for package version... $ECHO_C" >&6
 
 	# if there are not enough fields, cut returns the last one...
@@ -1301,39 +1309,39 @@ echo $ECHO_N "checking for package version... $ECHO_C" >&6
 	VERSION="$cf_field1"
 
 	VERSION_MAJOR=`echo "$cf_field2" | sed -e 's/\..*//'`
-	test -z "$VERSION_MAJOR" && { { echo "$as_me:1304: error: missing major-version" >&5
+	test -z "$VERSION_MAJOR" && { { echo "$as_me:1312: error: missing major-version" >&5
 echo "$as_me: error: missing major-version" >&2;}
    { (exit 1); exit 1; }; }
 
 	VERSION_MINOR=`echo "$cf_field2" | sed -e 's/^[^.]*\.//' -e 's/-.*//'`
-	test -z "$VERSION_MINOR" && { { echo "$as_me:1309: error: missing minor-version" >&5
+	test -z "$VERSION_MINOR" && { { echo "$as_me:1317: error: missing minor-version" >&5
 echo "$as_me: error: missing minor-version" >&2;}
    { (exit 1); exit 1; }; }
 
-	echo "$as_me:1313: result: ${VERSION_MAJOR}.${VERSION_MINOR}" >&5
+	echo "$as_me:1321: result: ${VERSION_MAJOR}.${VERSION_MINOR}" >&5
 echo "${ECHO_T}${VERSION_MAJOR}.${VERSION_MINOR}" >&6
 
-	echo "$as_me:1316: checking for package patch date" >&5
+	echo "$as_me:1324: checking for package patch date" >&5
 echo $ECHO_N "checking for package patch date... $ECHO_C" >&6
 	VERSION_PATCH=`echo "$cf_field3" | sed -e 's/^[^-]*-//'`
 	case .$VERSION_PATCH in
 	(.)
-		{ { echo "$as_me:1321: error: missing patch-date $VERSION_PATCH" >&5
+		{ { echo "$as_me:1329: error: missing patch-date $VERSION_PATCH" >&5
 echo "$as_me: error: missing patch-date $VERSION_PATCH" >&2;}
    { (exit 1); exit 1; }; }
 		;;
 	(.[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9])
 		;;
 	(*)
-		{ { echo "$as_me:1328: error: illegal patch-date $VERSION_PATCH" >&5
+		{ { echo "$as_me:1336: error: illegal patch-date $VERSION_PATCH" >&5
 echo "$as_me: error: illegal patch-date $VERSION_PATCH" >&2;}
    { (exit 1); exit 1; }; }
 		;;
 	esac
-	echo "$as_me:1333: result: $VERSION_PATCH" >&5
+	echo "$as_me:1341: result: $VERSION_PATCH" >&5
 echo "${ECHO_T}$VERSION_PATCH" >&6
 else
-	{ { echo "$as_me:1336: error: did not find $srcdir/VERSION" >&5
+	{ { echo "$as_me:1344: error: did not find $srcdir/VERSION" >&5
 echo "$as_me: error: did not find $srcdir/VERSION" >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -1341,19 +1349,19 @@ fi
 # show the actual data that we have for versions:
 test -n "$verbose" && echo "	ABI VERSION $VERSION" 1>&6
 
-echo "${as_me:-configure}:1344: testing ABI VERSION $VERSION ..." 1>&5
+echo "${as_me:-configure}:1352: testing ABI VERSION $VERSION ..." 1>&5
 
 test -n "$verbose" && echo "	VERSION_MAJOR $VERSION_MAJOR" 1>&6
 
-echo "${as_me:-configure}:1348: testing VERSION_MAJOR $VERSION_MAJOR ..." 1>&5
+echo "${as_me:-configure}:1356: testing VERSION_MAJOR $VERSION_MAJOR ..." 1>&5
 
 test -n "$verbose" && echo "	VERSION_MINOR $VERSION_MINOR" 1>&6
 
-echo "${as_me:-configure}:1352: testing VERSION_MINOR $VERSION_MINOR ..." 1>&5
+echo "${as_me:-configure}:1360: testing VERSION_MINOR $VERSION_MINOR ..." 1>&5
 
 test -n "$verbose" && echo "	VERSION_PATCH $VERSION_PATCH" 1>&6
 
-echo "${as_me:-configure}:1356: testing VERSION_PATCH $VERSION_PATCH ..." 1>&5
+echo "${as_me:-configure}:1364: testing VERSION_PATCH $VERSION_PATCH ..." 1>&5
 
 	cf_PACKAGE=NCURSES
 	PACKAGE=ncurses
@@ -1377,42 +1385,43 @@ test -z "$cf_cv_rel_version" && cf_cv_rel_version=0.0
 # Check whether --with-rel-version or --without-rel-version was given.
 if test "${with_rel_version+set}" = set; then
   withval="$with_rel_version"
-  { echo "$as_me:1380: WARNING: overriding release version $cf_cv_rel_version to $withval" >&5
+  { echo "$as_me:1388: WARNING: overriding release version $cf_cv_rel_version to $withval" >&5
 echo "$as_me: WARNING: overriding release version $cf_cv_rel_version to $withval" >&2;}
  cf_cv_rel_version=$withval
 fi;
 
  NCURSES_MAJOR=`echo "$cf_cv_rel_version" | sed -e 's/\..*//'`
  NCURSES_MINOR=`echo "$cf_cv_rel_version" | sed -e 's/^[^.]*//' -e 's/^\.//' -e 's/\..*//'`
+ test -n "NCURSES_MINOR" || NCURSES_MINOR=0
 
 if test -n "$NCURSES_MAJOR" ; then
-  case $NCURSES_MAJOR in
-  ([0-9]*)
+  case `echo "$NCURSES_MAJOR" | sed -e 's/^[0-9]*$/0/g'` in
+  (0)
  	;;
   (*)
-	{ { echo "$as_me:1393: error: Release major-version is not a number: $NCURSES_MAJOR" >&5
+	{ { echo "$as_me:1402: error: Release major-version is not a number: $NCURSES_MAJOR" >&5
 echo "$as_me: error: Release major-version is not a number: $NCURSES_MAJOR" >&2;}
    { (exit 1); exit 1; }; }
  	;;
   esac
 else
-  { { echo "$as_me:1399: error: Release major-version value is empty" >&5
+  { { echo "$as_me:1408: error: Release major-version value is empty" >&5
 echo "$as_me: error: Release major-version value is empty" >&2;}
    { (exit 1); exit 1; }; }
 fi
 
 if test -n "$NCURSES_MINOR" ; then
-  case $NCURSES_MINOR in
-  ([0-9]*)
+  case `echo "$NCURSES_MINOR" | sed -e 's/^[0-9]*$/0/g'` in
+  (0)
  	;;
   (*)
-	{ { echo "$as_me:1409: error: Release minor-version is not a number: $NCURSES_MINOR" >&5
+	{ { echo "$as_me:1418: error: Release minor-version is not a number: $NCURSES_MINOR" >&5
 echo "$as_me: error: Release minor-version is not a number: $NCURSES_MINOR" >&2;}
    { (exit 1); exit 1; }; }
  	;;
   esac
 else
-  { { echo "$as_me:1415: error: Release minor-version value is empty" >&5
+  { { echo "$as_me:1424: error: Release minor-version value is empty" >&5
 echo "$as_me: error: Release minor-version value is empty" >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -1425,7 +1434,7 @@ if test "${with_abi_version+set}" = set; then
 
 	if test "x$cf_cv_abi_version" != "x$withval"
 	then
-		{ echo "$as_me:1428: WARNING: overriding ABI version $cf_cv_abi_version to $withval" >&5
+		{ echo "$as_me:1437: WARNING: overriding ABI version $cf_cv_abi_version to $withval" >&5
 echo "$as_me: WARNING: overriding ABI version $cf_cv_abi_version to $withval" >&2;}
 		case "$cf_cv_rel_version" in
 		(5.*)
@@ -1440,21 +1449,23 @@ echo "$as_me: WARNING: overriding ABI version $cf_cv_abi_version to $withval" >&
 fi;
 
 if test -n "$cf_cv_abi_version" ; then
-  case $cf_cv_abi_version in
-  ([0-9]*)
+  case `echo "$cf_cv_abi_version" | sed -e 's/^[0-9]*$/0/g'` in
+  (0)
  	;;
   (*)
-	{ { echo "$as_me:1447: error: ABI version is not a number: $cf_cv_abi_version" >&5
+	{ { echo "$as_me:1456: error: ABI version is not a number: $cf_cv_abi_version" >&5
 echo "$as_me: error: ABI version is not a number: $cf_cv_abi_version" >&2;}
    { (exit 1); exit 1; }; }
  	;;
   esac
 else
-  { { echo "$as_me:1453: error: ABI version value is empty" >&5
+  { { echo "$as_me:1462: error: ABI version value is empty" >&5
 echo "$as_me: error: ABI version value is empty" >&2;}
    { (exit 1); exit 1; }; }
 fi
 
+cf_cv_abi_default=$cf_cv_abi_version
+
 if test "x$cf_cv_abi_version" != "x$with_abi_version"
 then
 	case "$cf_cv_rel_version" in
@@ -1481,7 +1492,7 @@ for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
   fi
 done
 if test -z "$ac_aux_dir"; then
-  { { echo "$as_me:1484: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5
+  { { echo "$as_me:1495: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5
 echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -1491,11 +1502,11 @@ ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure.
 
 # Make sure we can run config.sub.
 $ac_config_sub sun4 >/dev/null 2>&1 ||
-  { { echo "$as_me:1494: error: cannot run $ac_config_sub" >&5
+  { { echo "$as_me:1505: error: cannot run $ac_config_sub" >&5
 echo "$as_me: error: cannot run $ac_config_sub" >&2;}
    { (exit 1); exit 1; }; }
 
-echo "$as_me:1498: checking build system type" >&5
+echo "$as_me:1509: checking build system type" >&5
 echo $ECHO_N "checking build system type... $ECHO_C" >&6
 if test "${ac_cv_build+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1504,23 +1515,23 @@ else
 test -z "$ac_cv_build_alias" &&
   ac_cv_build_alias=`$ac_config_guess`
 test -z "$ac_cv_build_alias" &&
-  { { echo "$as_me:1507: error: cannot guess build type; you must specify one" >&5
+  { { echo "$as_me:1518: error: cannot guess build type; you must specify one" >&5
 echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
    { (exit 1); exit 1; }; }
 ac_cv_build=`$ac_config_sub "$ac_cv_build_alias"` ||
-  { { echo "$as_me:1511: error: $ac_config_sub $ac_cv_build_alias failed." >&5
+  { { echo "$as_me:1522: error: $ac_config_sub $ac_cv_build_alias failed." >&5
 echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed." >&2;}
    { (exit 1); exit 1; }; }
 
 fi
-echo "$as_me:1516: result: $ac_cv_build" >&5
+echo "$as_me:1527: result: $ac_cv_build" >&5
 echo "${ECHO_T}$ac_cv_build" >&6
 build=$ac_cv_build
 build_cpu=`echo "$ac_cv_build" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
 build_vendor=`echo "$ac_cv_build" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
 build_os=`echo "$ac_cv_build" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
 
-echo "$as_me:1523: checking host system type" >&5
+echo "$as_me:1534: checking host system type" >&5
 echo $ECHO_N "checking host system type... $ECHO_C" >&6
 if test "${ac_cv_host+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1529,12 +1540,12 @@ else
 test -z "$ac_cv_host_alias" &&
   ac_cv_host_alias=$ac_cv_build_alias
 ac_cv_host=`$ac_config_sub "$ac_cv_host_alias"` ||
-  { { echo "$as_me:1532: error: $ac_config_sub $ac_cv_host_alias failed" >&5
+  { { echo "$as_me:1543: error: $ac_config_sub $ac_cv_host_alias failed" >&5
 echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;}
    { (exit 1); exit 1; }; }
 
 fi
-echo "$as_me:1537: result: $ac_cv_host" >&5
+echo "$as_me:1548: result: $ac_cv_host" >&5
 echo "${ECHO_T}$ac_cv_host" >&6
 host=$ac_cv_host
 host_cpu=`echo "$ac_cv_host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
@@ -1542,7 +1553,7 @@ host_vendor=`echo "$ac_cv_host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
 host_os=`echo "$ac_cv_host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
 
 if test -f "$srcdir/config.guess" || test -f "$ac_aux_dir/config.guess" ; then
-	echo "$as_me:1545: checking target system type" >&5
+	echo "$as_me:1556: checking target system type" >&5
 echo $ECHO_N "checking target system type... $ECHO_C" >&6
 if test "${ac_cv_target+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1551,12 +1562,12 @@ else
 test "x$ac_cv_target_alias" = "x" &&
   ac_cv_target_alias=$ac_cv_host_alias
 ac_cv_target=`$ac_config_sub "$ac_cv_target_alias"` ||
-  { { echo "$as_me:1554: error: $ac_config_sub $ac_cv_target_alias failed" >&5
+  { { echo "$as_me:1565: error: $ac_config_sub $ac_cv_target_alias failed" >&5
 echo "$as_me: error: $ac_config_sub $ac_cv_target_alias failed" >&2;}
    { (exit 1); exit 1; }; }
 
 fi
-echo "$as_me:1559: result: $ac_cv_target" >&5
+echo "$as_me:1570: result: $ac_cv_target" >&5
 echo "${ECHO_T}$ac_cv_target" >&6
 target=$ac_cv_target
 target_cpu=`echo "$ac_cv_target" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
@@ -1588,13 +1599,13 @@ else
 fi
 
 test -z "$system_name" && system_name="$cf_cv_system_name"
-test -n "$cf_cv_system_name" && echo "$as_me:1591: result: Configuring for $cf_cv_system_name" >&5
+test -n "$cf_cv_system_name" && echo "$as_me:1602: result: Configuring for $cf_cv_system_name" >&5
 echo "${ECHO_T}Configuring for $cf_cv_system_name" >&6
 
 if test ".$system_name" != ".$cf_cv_system_name" ; then
-	echo "$as_me:1595: result: Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)" >&5
+	echo "$as_me:1606: result: Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)" >&5
 echo "${ECHO_T}Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)" >&6
-	{ { echo "$as_me:1597: error: \"Please remove config.cache and try again.\"" >&5
+	{ { echo "$as_me:1608: error: \"Please remove config.cache and try again.\"" >&5
 echo "$as_me: error: \"Please remove config.cache and try again.\"" >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -1602,7 +1613,7 @@ fi
 # Check whether --with-system-type or --without-system-type was given.
 if test "${with_system_type+set}" = set; then
   withval="$with_system_type"
-  { echo "$as_me:1605: WARNING: overriding system type to $withval" >&5
+  { echo "$as_me:1616: WARNING: overriding system type to $withval" >&5
 echo "$as_me: WARNING: overriding system type to $withval" >&2;}
 	cf_cv_system_name=$withval
 	host_os=$withval
@@ -1613,7 +1624,7 @@ fi;
 cf_user_CFLAGS="$CFLAGS"
 
 ###	Default install-location
-echo "$as_me:1616: checking for fgrep" >&5
+echo "$as_me:1627: checking for fgrep" >&5
 echo $ECHO_N "checking for fgrep... $ECHO_C" >&6
 if test "${ac_cv_path_FGREP+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1625,7 +1636,7 @@ else
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:1628: checking for $ac_word" >&5
+echo "$as_me:1639: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_path_FGREP+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1642,7 +1653,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   if $as_executable_p "$ac_dir/$ac_word"; then
    ac_cv_path_FGREP="$ac_dir/$ac_word"
-   echo "$as_me:1645: found $ac_dir/$ac_word" >&5
+   echo "$as_me:1656: found $ac_dir/$ac_word" >&5
    break
 fi
 done
@@ -1653,10 +1664,10 @@ fi
 FGREP=$ac_cv_path_FGREP
 
 if test -n "$FGREP"; then
-  echo "$as_me:1656: result: $FGREP" >&5
+  echo "$as_me:1667: result: $FGREP" >&5
 echo "${ECHO_T}$FGREP" >&6
 else
-  echo "$as_me:1659: result: no" >&5
+  echo "$as_me:1670: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -1664,16 +1675,16 @@ fi
 done
 test -n "$FGREP" || FGREP=": "
 
-     test "x$ac_cv_path_FGREP" = "x:" && { { echo "$as_me:1667: error: cannot find workable fgrep" >&5
+     test "x$ac_cv_path_FGREP" = "x:" && { { echo "$as_me:1678: error: cannot find workable fgrep" >&5
 echo "$as_me: error: cannot find workable fgrep" >&2;}
    { (exit 1); exit 1; }; }
    fi
 fi
-echo "$as_me:1672: result: $ac_cv_path_FGREP" >&5
+echo "$as_me:1683: result: $ac_cv_path_FGREP" >&5
 echo "${ECHO_T}$ac_cv_path_FGREP" >&6
  FGREP="$ac_cv_path_FGREP"
 
-echo "$as_me:1676: checking for prefix" >&5
+echo "$as_me:1687: checking for prefix" >&5
 echo $ECHO_N "checking for prefix... $ECHO_C" >&6
 if test "x$prefix" = "xNONE" ; then
 	case "$cf_cv_system_name" in
@@ -1685,11 +1696,11 @@ if test "x$prefix" = "xNONE" ; then
 		;;
 	esac
 fi
-echo "$as_me:1688: result: $prefix" >&5
+echo "$as_me:1699: result: $prefix" >&5
 echo "${ECHO_T}$prefix" >&6
 
 if test "x$prefix" = "xNONE" ; then
-echo "$as_me:1692: checking for default include-directory" >&5
+echo "$as_me:1703: checking for default include-directory" >&5
 echo $ECHO_N "checking for default include-directory... $ECHO_C" >&6
 test -n "$verbose" && echo 1>&6
 for cf_symbol in \
@@ -1712,41 +1723,91 @@ do
 	fi
 	test -n "$verbose"  && echo "	tested $cf_dir" 1>&6
 done
-echo "$as_me:1715: result: $includedir" >&5
+echo "$as_me:1726: result: $includedir" >&5
 echo "${ECHO_T}$includedir" >&6
 fi
 
 ### Defaults for ncurses ABI
 
-case x$cf_cv_abi_version in
+# ABI 5 defaults:
+cf_dft_ccharw_max=5
+cf_dft_chtype=auto
+cf_dft_ext_colors=no
+cf_dft_ext_const=no
+cf_dft_ext_mouse=no
+cf_dft_ext_putwin=no
+cf_dft_ext_spfuncs=no
+cf_dft_filter_syms=no
+cf_dft_interop=no
+cf_dft_mmask_t=auto
+cf_dft_opaque_curses=no
+cf_dft_ordinate_type=short
+cf_dft_signed_char=no
+cf_dft_tparm_arg=long
+cf_dft_widec=no
+cf_dft_with_lp64=no
+
+# ABI 6 default differences from ABI 5:
+case x$cf_cv_abi_default in
 (x[6789])
+	cf_dft_chtype=uint32_t
 	cf_dft_ext_colors=yes
 	cf_dft_ext_const=yes
 	cf_dft_ext_mouse=yes
 	cf_dft_ext_putwin=yes
 	cf_dft_ext_spfuncs=yes
 	cf_dft_filter_syms=yes
-	cf_dft_chtype=uint32_t
-	cf_dft_mmask_t=uint32_t
 	cf_dft_interop=yes
+	cf_dft_mmask_t=uint32_t
+	cf_dft_opaque_curses=yes
 	cf_dft_tparm_arg=intptr_t
+	cf_dft_widec=yes
 	cf_dft_with_lp64=yes
 	;;
-(*)
-	cf_dft_ext_colors=no
-	cf_dft_ext_const=no
-	cf_dft_ext_mouse=no
-	cf_dft_ext_putwin=no
-	cf_dft_ext_spfuncs=no
-	cf_dft_filter_syms=no
-	cf_dft_chtype=auto
-	cf_dft_mmask_t=auto
-	cf_dft_interop=no
-	cf_dft_tparm_arg=long
-	cf_dft_with_lp64=no
+esac
+
+# ABI 7 default differences from ABI 6:
+case x$cf_cv_abi_default in
+(x[789])
+	cf_dft_ccharw_max=6
+	cf_dft_mmask_t=uint64_t
+	cf_dft_ordinate_type=int
+	cf_dft_signed_char=yes
+	# also: remove the wgetch-events feature in ABI 7
 	;;
 esac
 
+### override ABI version, e.g., packagers
+
+# Check whether --with-abi-altered or --without-abi-altered was given.
+if test "${with_abi_altered+set}" = set; then
+  withval="$with_abi_altered"
+
+if test -n "$withval" ; then
+  case `echo "$withval" | sed -e 's/^[0-9]*$/0/g'` in
+  (0)
+ 	;;
+  (*)
+	{ { echo "$as_me:1791: error: ABI altered is not a number: $withval" >&5
+echo "$as_me: error: ABI altered is not a number: $withval" >&2;}
+   { (exit 1); exit 1; }; }
+ 	;;
+  esac
+else
+  { { echo "$as_me:1797: error: ABI altered value is empty" >&5
+echo "$as_me: error: ABI altered value is empty" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+	if test "$cf_cv_abi_version" != "$withval"
+	then
+		{ echo "$as_me:1804: WARNING: altering visible ABI from $cf_cv_abi_version to $withval" >&5
+echo "$as_me: WARNING: altering visible ABI from $cf_cv_abi_version to $withval" >&2;}
+		cf_cv_abi_version=$withval
+	fi
+
+fi;
+
 ###	Checks for programs.
 
 # Check whether --with-ada or --without-ada was given.
@@ -1775,7 +1836,7 @@ if test -n "$ac_tool_prefix"; then
   do
     # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:1778: checking for $ac_word" >&5
+echo "$as_me:1839: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1790,7 +1851,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
-echo "$as_me:1793: found $ac_dir/$ac_word" >&5
+echo "$as_me:1854: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -1798,10 +1859,10 @@ fi
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  echo "$as_me:1801: result: $CC" >&5
+  echo "$as_me:1862: result: $CC" >&5
 echo "${ECHO_T}$CC" >&6
 else
-  echo "$as_me:1804: result: no" >&5
+  echo "$as_me:1865: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -1814,7 +1875,7 @@ if test -z "$CC"; then
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:1817: checking for $ac_word" >&5
+echo "$as_me:1878: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1829,7 +1890,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_ac_ct_CC="$ac_prog"
-echo "$as_me:1832: found $ac_dir/$ac_word" >&5
+echo "$as_me:1893: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -1837,10 +1898,10 @@ fi
 fi
 ac_ct_CC=$ac_cv_prog_ac_ct_CC
 if test -n "$ac_ct_CC"; then
-  echo "$as_me:1840: result: $ac_ct_CC" >&5
+  echo "$as_me:1901: result: $ac_ct_CC" >&5
 echo "${ECHO_T}$ac_ct_CC" >&6
 else
-  echo "$as_me:1843: result: no" >&5
+  echo "$as_me:1904: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -1850,32 +1911,32 @@ done
   CC=$ac_ct_CC
 fi
 
-test -z "$CC" && { { echo "$as_me:1853: error: no acceptable cc found in \$PATH" >&5
+test -z "$CC" && { { echo "$as_me:1914: error: no acceptable cc found in \$PATH" >&5
 echo "$as_me: error: no acceptable cc found in \$PATH" >&2;}
    { (exit 1); exit 1; }; }
 
 # Provide some information about the compiler.
-echo "$as_me:1858:" \
+echo "$as_me:1919:" \
      "checking for C compiler version" >&5
 ac_compiler=`set X $ac_compile; echo "$2"`
-{ (eval echo "$as_me:1861: \"$ac_compiler --version </dev/null >&5\"") >&5
+{ (eval echo "$as_me:1922: \"$ac_compiler --version </dev/null >&5\"") >&5
   (eval $ac_compiler --version </dev/null >&5) 2>&5
   ac_status=$?
-  echo "$as_me:1864: \$? = $ac_status" >&5
+  echo "$as_me:1925: \$? = $ac_status" >&5
   (exit "$ac_status"); }
-{ (eval echo "$as_me:1866: \"$ac_compiler -v </dev/null >&5\"") >&5
+{ (eval echo "$as_me:1927: \"$ac_compiler -v </dev/null >&5\"") >&5
   (eval $ac_compiler -v </dev/null >&5) 2>&5
   ac_status=$?
-  echo "$as_me:1869: \$? = $ac_status" >&5
+  echo "$as_me:1930: \$? = $ac_status" >&5
   (exit "$ac_status"); }
-{ (eval echo "$as_me:1871: \"$ac_compiler -V </dev/null >&5\"") >&5
+{ (eval echo "$as_me:1932: \"$ac_compiler -V </dev/null >&5\"") >&5
   (eval $ac_compiler -V </dev/null >&5) 2>&5
   ac_status=$?
-  echo "$as_me:1874: \$? = $ac_status" >&5
+  echo "$as_me:1935: \$? = $ac_status" >&5
   (exit "$ac_status"); }
 
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 1878 "configure"
+#line 1939 "configure"
 #include "confdefs.h"
 
 int
@@ -1891,13 +1952,13 @@ ac_clean_files="$ac_clean_files a.out a.exe"
 # Try to create an executable without -o first, disregard a.out.
 # It will help us diagnose broken compilers, and finding out an intuition
 # of exeext.
-echo "$as_me:1894: checking for C compiler default output" >&5
+echo "$as_me:1955: checking for C compiler default output" >&5
 echo $ECHO_N "checking for C compiler default output... $ECHO_C" >&6
 ac_link_default=`echo "$ac_link" | sed 's/ -o *"conftest[^"]*"//'`
-if { (eval echo "$as_me:1897: \"$ac_link_default\"") >&5
+if { (eval echo "$as_me:1958: \"$ac_link_default\"") >&5
   (eval $ac_link_default) 2>&5
   ac_status=$?
-  echo "$as_me:1900: \$? = $ac_status" >&5
+  echo "$as_me:1961: \$? = $ac_status" >&5
   (exit "$ac_status"); }; then
   # Find the output, starting from the most likely.  This scheme is
 # not robust to junk in `.', hence go to wildcards (a.*) only as a last
@@ -1920,34 +1981,34 @@ done
 else
   echo "$as_me: failed program was:" >&5
 cat "conftest.$ac_ext" >&5
-{ { echo "$as_me:1923: error: C compiler cannot create executables" >&5
+{ { echo "$as_me:1984: error: C compiler cannot create executables" >&5
 echo "$as_me: error: C compiler cannot create executables" >&2;}
    { (exit 77); exit 77; }; }
 fi
 
 ac_exeext=$ac_cv_exeext
-echo "$as_me:1929: result: $ac_file" >&5
+echo "$as_me:1990: result: $ac_file" >&5
 echo "${ECHO_T}$ac_file" >&6
 
 # Check the compiler produces executables we can run.  If not, either
 # the compiler is broken, or we cross compile.
-echo "$as_me:1934: checking whether the C compiler works" >&5
+echo "$as_me:1995: checking whether the C compiler works" >&5
 echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6
 # FIXME: These cross compiler hacks should be removed for Autoconf 3.0
 # If not cross compiling, check that we can run a simple program.
 if test "$cross_compiling" != yes; then
   if { ac_try='./$ac_file'
-  { (eval echo "$as_me:1940: \"$ac_try\"") >&5
+  { (eval echo "$as_me:2001: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:1943: \$? = $ac_status" >&5
+  echo "$as_me:2004: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
     cross_compiling=no
   else
     if test "$cross_compiling" = maybe; then
 	cross_compiling=yes
     else
-	{ { echo "$as_me:1950: error: cannot run C compiled programs.
+	{ { echo "$as_me:2011: error: cannot run C compiled programs.
 If you meant to cross compile, use \`--host'." >&5
 echo "$as_me: error: cannot run C compiled programs.
 If you meant to cross compile, use \`--host'." >&2;}
@@ -1955,24 +2016,24 @@ If you meant to cross compile, use \`--host'." >&2;}
     fi
   fi
 fi
-echo "$as_me:1958: result: yes" >&5
+echo "$as_me:2019: result: yes" >&5
 echo "${ECHO_T}yes" >&6
 
 rm -f a.out a.exe "conftest$ac_cv_exeext"
 ac_clean_files=$ac_clean_files_save
 # Check the compiler produces executables we can run.  If not, either
 # the compiler is broken, or we cross compile.
-echo "$as_me:1965: checking whether we are cross compiling" >&5
+echo "$as_me:2026: checking whether we are cross compiling" >&5
 echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6
-echo "$as_me:1967: result: $cross_compiling" >&5
+echo "$as_me:2028: result: $cross_compiling" >&5
 echo "${ECHO_T}$cross_compiling" >&6
 
-echo "$as_me:1970: checking for executable suffix" >&5
+echo "$as_me:2031: checking for executable suffix" >&5
 echo $ECHO_N "checking for executable suffix... $ECHO_C" >&6
-if { (eval echo "$as_me:1972: \"$ac_link\"") >&5
+if { (eval echo "$as_me:2033: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:1975: \$? = $ac_status" >&5
+  echo "$as_me:2036: \$? = $ac_status" >&5
   (exit "$ac_status"); }; then
   # If both `conftest.exe' and `conftest' are `present' (well, observable)
 # catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
@@ -1988,25 +2049,25 @@ for ac_file in `(ls conftest.exe; ls conftest; ls conftest.*) 2>/dev/null`; do
   esac
 done
 else
-  { { echo "$as_me:1991: error: cannot compute EXEEXT: cannot compile and link" >&5
+  { { echo "$as_me:2052: error: cannot compute EXEEXT: cannot compile and link" >&5
 echo "$as_me: error: cannot compute EXEEXT: cannot compile and link" >&2;}
    { (exit 1); exit 1; }; }
 fi
 
 rm -f "conftest$ac_cv_exeext"
-echo "$as_me:1997: result: $ac_cv_exeext" >&5
+echo "$as_me:2058: result: $ac_cv_exeext" >&5
 echo "${ECHO_T}$ac_cv_exeext" >&6
 
 rm -f "conftest.$ac_ext"
 EXEEXT=$ac_cv_exeext
 ac_exeext=$EXEEXT
-echo "$as_me:2003: checking for object suffix" >&5
+echo "$as_me:2064: checking for object suffix" >&5
 echo $ECHO_N "checking for object suffix... $ECHO_C" >&6
 if test "${ac_cv_objext+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 2009 "configure"
+#line 2070 "configure"
 #include "confdefs.h"
 
 int
@@ -2018,10 +2079,10 @@ main (void)
 }
 _ACEOF
 rm -f conftest.o conftest.obj
-if { (eval echo "$as_me:2021: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:2082: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:2024: \$? = $ac_status" >&5
+  echo "$as_me:2085: \$? = $ac_status" >&5
   (exit "$ac_status"); }; then
   for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
   case $ac_file in
@@ -2033,24 +2094,24 @@ done
 else
   echo "$as_me: failed program was:" >&5
 cat "conftest.$ac_ext" >&5
-{ { echo "$as_me:2036: error: cannot compute OBJEXT: cannot compile" >&5
+{ { echo "$as_me:2097: error: cannot compute OBJEXT: cannot compile" >&5
 echo "$as_me: error: cannot compute OBJEXT: cannot compile" >&2;}
    { (exit 1); exit 1; }; }
 fi
 
 rm -f "conftest.$ac_cv_objext" "conftest.$ac_ext"
 fi
-echo "$as_me:2043: result: $ac_cv_objext" >&5
+echo "$as_me:2104: result: $ac_cv_objext" >&5
 echo "${ECHO_T}$ac_cv_objext" >&6
 OBJEXT=$ac_cv_objext
 ac_objext=$OBJEXT
-echo "$as_me:2047: checking whether we are using the GNU C compiler" >&5
+echo "$as_me:2108: checking whether we are using the GNU C compiler" >&5
 echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
 if test "${ac_cv_c_compiler_gnu+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 2053 "configure"
+#line 2114 "configure"
 #include "confdefs.h"
 
 int
@@ -2065,16 +2126,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:2068: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:2129: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:2071: \$? = $ac_status" >&5
+  echo "$as_me:2132: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:2074: \"$ac_try\"") >&5
+  { (eval echo "$as_me:2135: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:2077: \$? = $ac_status" >&5
+  echo "$as_me:2138: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_compiler_gnu=yes
 else
@@ -2086,19 +2147,19 @@ rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 ac_cv_c_compiler_gnu=$ac_compiler_gnu
 
 fi
-echo "$as_me:2089: result: $ac_cv_c_compiler_gnu" >&5
+echo "$as_me:2150: result: $ac_cv_c_compiler_gnu" >&5
 echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
 GCC=`test $ac_compiler_gnu = yes && echo yes`
 ac_test_CFLAGS=${CFLAGS+set}
 ac_save_CFLAGS=$CFLAGS
 CFLAGS="-g"
-echo "$as_me:2095: checking whether $CC accepts -g" >&5
+echo "$as_me:2156: checking whether $CC accepts -g" >&5
 echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
 if test "${ac_cv_prog_cc_g+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 2101 "configure"
+#line 2162 "configure"
 #include "confdefs.h"
 
 int
@@ -2110,16 +2171,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:2113: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:2174: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:2116: \$? = $ac_status" >&5
+  echo "$as_me:2177: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:2119: \"$ac_try\"") >&5
+  { (eval echo "$as_me:2180: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:2122: \$? = $ac_status" >&5
+  echo "$as_me:2183: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_prog_cc_g=yes
 else
@@ -2129,7 +2190,7 @@ ac_cv_prog_cc_g=no
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 fi
-echo "$as_me:2132: result: $ac_cv_prog_cc_g" >&5
+echo "$as_me:2193: result: $ac_cv_prog_cc_g" >&5
 echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
 if test "$ac_test_CFLAGS" = set; then
   CFLAGS=$ac_save_CFLAGS
@@ -2156,16 +2217,16 @@ cat >"conftest.$ac_ext" <<_ACEOF
 #endif
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:2159: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:2220: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:2162: \$? = $ac_status" >&5
+  echo "$as_me:2223: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:2165: \"$ac_try\"") >&5
+  { (eval echo "$as_me:2226: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:2168: \$? = $ac_status" >&5
+  echo "$as_me:2229: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   for ac_declaration in \
    ''\
@@ -2177,7 +2238,7 @@ if { (eval echo "$as_me:2159: \"$ac_compile\"") >&5
    'void exit (int);'
 do
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 2180 "configure"
+#line 2241 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 $ac_declaration
@@ -2190,16 +2251,16 @@ exit (42);
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:2193: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:2254: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:2196: \$? = $ac_status" >&5
+  echo "$as_me:2257: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:2199: \"$ac_try\"") >&5
+  { (eval echo "$as_me:2260: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:2202: \$? = $ac_status" >&5
+  echo "$as_me:2263: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   :
 else
@@ -2209,7 +2270,7 @@ continue
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 2212 "configure"
+#line 2273 "configure"
 #include "confdefs.h"
 $ac_declaration
 int
@@ -2221,16 +2282,16 @@ exit (42);
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:2224: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:2285: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:2227: \$? = $ac_status" >&5
+  echo "$as_me:2288: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:2230: \"$ac_try\"") >&5
+  { (eval echo "$as_me:2291: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:2233: \$? = $ac_status" >&5
+  echo "$as_me:2294: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   break
 else
@@ -2260,11 +2321,11 @@ ac_main_return="return"
 
 GCC_VERSION=none
 if test "$GCC" = yes ; then
-	echo "$as_me:2263: checking version of $CC" >&5
+	echo "$as_me:2324: checking version of $CC" >&5
 echo $ECHO_N "checking version of $CC... $ECHO_C" >&6
-	GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC[^)]*) //' -e 's/^.*(Debian[^)]*) //' -e 's/^[^0-9.]*//' -e 's/[^0-9.].*//'`"
+	GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^[^(]*([^)][^)]*) //' -e 's/^[^0-9.]*//' -e 's/[^0-9.].*//'`"
 	test -z "$GCC_VERSION" && GCC_VERSION=unknown
-	echo "$as_me:2267: result: $GCC_VERSION" >&5
+	echo "$as_me:2328: result: $GCC_VERSION" >&5
 echo "${ECHO_T}$GCC_VERSION" >&6
 fi
 
@@ -2273,12 +2334,12 @@ INTEL_COMPILER=no
 if test "$GCC" = yes ; then
 	case "$host_os" in
 	(linux*|gnu*)
-		echo "$as_me:2276: checking if this is really Intel C compiler" >&5
+		echo "$as_me:2337: checking if this is really Intel C compiler" >&5
 echo $ECHO_N "checking if this is really Intel C compiler... $ECHO_C" >&6
 		cf_save_CFLAGS="$CFLAGS"
 		CFLAGS="$CFLAGS -no-gcc"
 		cat >"conftest.$ac_ext" <<_ACEOF
-#line 2281 "configure"
+#line 2342 "configure"
 #include "confdefs.h"
 
 int
@@ -2287,7 +2348,7 @@ main (void)
 
 #ifdef __INTEL_COMPILER
 #else
-make an error
+#error __INTEL_COMPILER is not defined
 #endif
 
   ;
@@ -2295,16 +2356,16 @@ make an error
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:2298: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:2359: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:2301: \$? = $ac_status" >&5
+  echo "$as_me:2362: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:2304: \"$ac_try\"") >&5
+  { (eval echo "$as_me:2365: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:2307: \$? = $ac_status" >&5
+  echo "$as_me:2368: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   INTEL_COMPILER=yes
 cf_save_CFLAGS="$cf_save_CFLAGS -we147"
@@ -2315,7 +2376,7 @@ cat "conftest.$ac_ext" >&5
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 		CFLAGS="$cf_save_CFLAGS"
-		echo "$as_me:2318: result: $INTEL_COMPILER" >&5
+		echo "$as_me:2379: result: $INTEL_COMPILER" >&5
 echo "${ECHO_T}$INTEL_COMPILER" >&6
 		;;
 	esac
@@ -2324,11 +2385,11 @@ fi
 CLANG_COMPILER=no
 
 if test "$GCC" = yes ; then
-	echo "$as_me:2327: checking if this is really Clang C compiler" >&5
+	echo "$as_me:2388: checking if this is really Clang C compiler" >&5
 echo $ECHO_N "checking if this is really Clang C compiler... $ECHO_C" >&6
 	cf_save_CFLAGS="$CFLAGS"
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 2331 "configure"
+#line 2392 "configure"
 #include "confdefs.h"
 
 int
@@ -2337,7 +2398,7 @@ main (void)
 
 #ifdef __clang__
 #else
-make an error
+#error __clang__ is not defined
 #endif
 
   ;
@@ -2345,16 +2406,16 @@ make an error
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:2348: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:2409: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:2351: \$? = $ac_status" >&5
+  echo "$as_me:2412: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:2354: \"$ac_try\"") >&5
+  { (eval echo "$as_me:2415: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:2357: \$? = $ac_status" >&5
+  echo "$as_me:2418: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   CLANG_COMPILER=yes
 
@@ -2364,7 +2425,7 @@ cat "conftest.$ac_ext" >&5
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 	CFLAGS="$cf_save_CFLAGS"
-	echo "$as_me:2367: result: $CLANG_COMPILER" >&5
+	echo "$as_me:2428: result: $CLANG_COMPILER" >&5
 echo "${ECHO_T}$CLANG_COMPILER" >&6
 fi
 
@@ -2373,30 +2434,30 @@ CLANG_VERSION=none
 if test "x$CLANG_COMPILER" = "xyes" ; then
 	case "$CC" in
 	(c[1-9][0-9]|*/c[1-9][0-9])
-		{ echo "$as_me:2376: WARNING: replacing broken compiler alias $CC" >&5
+		{ echo "$as_me:2437: WARNING: replacing broken compiler alias $CC" >&5
 echo "$as_me: WARNING: replacing broken compiler alias $CC" >&2;}
 		CFLAGS="$CFLAGS -std=`echo "$CC" | sed -e 's%.*/%%'`"
 		CC=clang
 		;;
 	esac
 
-	echo "$as_me:2383: checking version of $CC" >&5
+	echo "$as_me:2444: checking version of $CC" >&5
 echo $ECHO_N "checking version of $CC... $ECHO_C" >&6
 	CLANG_VERSION="`$CC --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(CLANG[^)]*) //' -e 's/^.*(Debian[^)]*) //' -e 's/^[^0-9.]*//' -e 's/[^0-9.].*//'`"
 	test -z "$CLANG_VERSION" && CLANG_VERSION=unknown
-	echo "$as_me:2387: result: $CLANG_VERSION" >&5
+	echo "$as_me:2448: result: $CLANG_VERSION" >&5
 echo "${ECHO_T}$CLANG_VERSION" >&6
 
 	for cf_clang_opt in \
 		-Qunused-arguments \
 		-Wno-error=implicit-function-declaration
 	do
-		echo "$as_me:2394: checking if option $cf_clang_opt works" >&5
+		echo "$as_me:2455: checking if option $cf_clang_opt works" >&5
 echo $ECHO_N "checking if option $cf_clang_opt works... $ECHO_C" >&6
 		cf_save_CFLAGS="$CFLAGS"
 		CFLAGS="$CFLAGS $cf_clang_opt"
 		cat >"conftest.$ac_ext" <<_ACEOF
-#line 2399 "configure"
+#line 2460 "configure"
 #include "confdefs.h"
 
 			#include <stdio.h>
@@ -2410,16 +2471,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:2413: \"$ac_link\"") >&5
+if { (eval echo "$as_me:2474: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:2416: \$? = $ac_status" >&5
+  echo "$as_me:2477: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:2419: \"$ac_try\"") >&5
+  { (eval echo "$as_me:2480: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:2422: \$? = $ac_status" >&5
+  echo "$as_me:2483: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
 
 			cf_clang_optok=yes
@@ -2430,13 +2491,13 @@ cat "conftest.$ac_ext" >&5
 			cf_clang_optok=no
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
-		echo "$as_me:2433: result: $cf_clang_optok" >&5
+		echo "$as_me:2494: result: $cf_clang_optok" >&5
 echo "${ECHO_T}$cf_clang_optok" >&6
 		CFLAGS="$cf_save_CFLAGS"
 		if test "$cf_clang_optok" = yes; then
 			test -n "$verbose" && echo "	adding option $cf_clang_opt" 1>&6
 
-echo "${as_me:-configure}:2439: testing adding option $cf_clang_opt ..." 1>&5
+echo "${as_me:-configure}:2500: testing adding option $cf_clang_opt ..." 1>&5
 
 	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
 	CFLAGS="${CFLAGS}$cf_clang_opt"
@@ -2445,7 +2506,7 @@ echo "${as_me:-configure}:2439: testing adding option $cf_clang_opt ..." 1>&5
 	done
 fi
 
-echo "$as_me:2448: checking for $CC option to accept ANSI C" >&5
+echo "$as_me:2509: checking for $CC option to accept ANSI C" >&5
 echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
 if test "${ac_cv_prog_cc_stdc+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -2453,7 +2514,7 @@ else
   ac_cv_prog_cc_stdc=no
 ac_save_CC=$CC
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 2456 "configure"
+#line 2517 "configure"
 #include "confdefs.h"
 #include <stdarg.h>
 #include <stdio.h>
@@ -2462,9 +2523,7 @@ cat >"conftest.$ac_ext" <<_ACEOF
 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
 struct buf { int x; };
 FILE * (*rcsopen) (struct buf *, struct stat *, int);
-static char *e (p, i)
-     char **p;
-     int i;
+static char *e (char **p, int i)
 {
   return p[i];
 }
@@ -2502,16 +2561,16 @@ for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIO
 do
   CC="$ac_save_CC $ac_arg"
   rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:2505: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:2564: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:2508: \$? = $ac_status" >&5
+  echo "$as_me:2567: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:2511: \"$ac_try\"") >&5
+  { (eval echo "$as_me:2570: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:2514: \$? = $ac_status" >&5
+  echo "$as_me:2573: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_prog_cc_stdc=$ac_arg
 break
@@ -2528,10 +2587,10 @@ fi
 
 case "x$ac_cv_prog_cc_stdc" in
   x|xno)
-    echo "$as_me:2531: result: none needed" >&5
+    echo "$as_me:2590: result: none needed" >&5
 echo "${ECHO_T}none needed" >&6 ;;
   *)
-    echo "$as_me:2534: result: $ac_cv_prog_cc_stdc" >&5
+    echo "$as_me:2593: result: $ac_cv_prog_cc_stdc" >&5
 echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
     CC="$CC $ac_cv_prog_cc_stdc" ;;
 esac
@@ -2539,13 +2598,13 @@ esac
 # This should have been defined by AC_PROG_CC
 : "${CC:=cc}"
 
-echo "$as_me:2542: checking \$CFLAGS variable" >&5
+echo "$as_me:2601: checking \$CFLAGS variable" >&5
 echo $ECHO_N "checking \$CFLAGS variable... $ECHO_C" >&6
 case "x$CFLAGS" in
 (*-[IUD]*)
-	echo "$as_me:2546: result: broken" >&5
+	echo "$as_me:2605: result: broken" >&5
 echo "${ECHO_T}broken" >&6
-	{ echo "$as_me:2548: WARNING: your environment uses the CFLAGS variable to hold CPPFLAGS options" >&5
+	{ echo "$as_me:2607: WARNING: your environment uses the CFLAGS variable to hold CPPFLAGS options" >&5
 echo "$as_me: WARNING: your environment uses the CFLAGS variable to hold CPPFLAGS options" >&2;}
 	cf_flags="$CFLAGS"
 	CFLAGS=
@@ -2653,22 +2712,22 @@ fi
 	done
 	;;
 (*)
-	echo "$as_me:2656: result: ok" >&5
+	echo "$as_me:2715: result: ok" >&5
 echo "${ECHO_T}ok" >&6
 	;;
 esac
 
-echo "$as_me:2661: checking \$CC variable" >&5
+echo "$as_me:2720: checking \$CC variable" >&5
 echo $ECHO_N "checking \$CC variable... $ECHO_C" >&6
 case "$CC" in
 (*[\ \	]-*)
-	echo "$as_me:2665: result: broken" >&5
+	echo "$as_me:2724: result: broken" >&5
 echo "${ECHO_T}broken" >&6
-	{ echo "$as_me:2667: WARNING: your environment uses the CC variable to hold CFLAGS/CPPFLAGS options" >&5
+	{ echo "$as_me:2726: WARNING: your environment uses the CC variable to hold CFLAGS/CPPFLAGS options" >&5
 echo "$as_me: WARNING: your environment uses the CC variable to hold CFLAGS/CPPFLAGS options" >&2;}
 	# humor him...
 	cf_prog=`echo "$CC" | sed -e 's/	/ /g' -e 's/[ ]* / /g' -e 's/[ ]*[ ]-[^ ].*//'`
-	cf_flags=`echo "$CC" | ${AWK:-awk} -v prog="$cf_prog" '{ printf("%s", substr($0,1+length(prog))); }'`
+	cf_flags=`echo "$CC" | sed -e "s%^$cf_prog%%"`
 	CC="$cf_prog"
 	for cf_arg in $cf_flags
 	do
@@ -2781,19 +2840,19 @@ fi
 	done
 	test -n "$verbose" && echo "	resulting CC: '$CC'" 1>&6
 
-echo "${as_me:-configure}:2784: testing resulting CC: '$CC' ..." 1>&5
+echo "${as_me:-configure}:2843: testing resulting CC: '$CC' ..." 1>&5
 
 	test -n "$verbose" && echo "	resulting CFLAGS: '$CFLAGS'" 1>&6
 
-echo "${as_me:-configure}:2788: testing resulting CFLAGS: '$CFLAGS' ..." 1>&5
+echo "${as_me:-configure}:2847: testing resulting CFLAGS: '$CFLAGS' ..." 1>&5
 
 	test -n "$verbose" && echo "	resulting CPPFLAGS: '$CPPFLAGS'" 1>&6
 
-echo "${as_me:-configure}:2792: testing resulting CPPFLAGS: '$CPPFLAGS' ..." 1>&5
+echo "${as_me:-configure}:2851: testing resulting CPPFLAGS: '$CPPFLAGS' ..." 1>&5
 
 	;;
 (*)
-	echo "$as_me:2796: result: ok" >&5
+	echo "$as_me:2855: result: ok" >&5
 echo "${ECHO_T}ok" >&6
 	;;
 esac
@@ -2804,7 +2863,7 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS "conftest.$ac_ext" >&5'
 ac_link='$CC -o "conftest$ac_exeext" $CFLAGS $CPPFLAGS $LDFLAGS "conftest.$ac_ext" $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 ac_main_return="return"
-echo "$as_me:2807: checking how to run the C preprocessor" >&5
+echo "$as_me:2866: checking how to run the C preprocessor" >&5
 echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
@@ -2825,18 +2884,18 @@ do
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp. "Syntax error" is here to catch this case.
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 2828 "configure"
+#line 2887 "configure"
 #include "confdefs.h"
 #include <assert.h>
                      Syntax error
 _ACEOF
-if { (eval echo "$as_me:2833: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+if { (eval echo "$as_me:2892: \"$ac_cpp "conftest.$ac_ext"\"") >&5
   (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:2839: \$? = $ac_status" >&5
+  echo "$as_me:2898: \$? = $ac_status" >&5
   (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -2859,17 +2918,17 @@ rm -f conftest.err "conftest.$ac_ext"
   # OK, works on sane cases.  Now check whether non-existent headers
   # can be detected and how.
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 2862 "configure"
+#line 2921 "configure"
 #include "confdefs.h"
 #include <ac_nonexistent.h>
 _ACEOF
-if { (eval echo "$as_me:2866: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+if { (eval echo "$as_me:2925: \"$ac_cpp "conftest.$ac_ext"\"") >&5
   (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:2872: \$? = $ac_status" >&5
+  echo "$as_me:2931: \$? = $ac_status" >&5
   (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -2906,7 +2965,7 @@ fi
 else
   ac_cv_prog_CPP=$CPP
 fi
-echo "$as_me:2909: result: $CPP" >&5
+echo "$as_me:2968: result: $CPP" >&5
 echo "${ECHO_T}$CPP" >&6
 ac_preproc_ok=false
 for ac_c_preproc_warn_flag in '' yes
@@ -2916,18 +2975,18 @@ do
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp. "Syntax error" is here to catch this case.
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 2919 "configure"
+#line 2978 "configure"
 #include "confdefs.h"
 #include <assert.h>
                      Syntax error
 _ACEOF
-if { (eval echo "$as_me:2924: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+if { (eval echo "$as_me:2983: \"$ac_cpp "conftest.$ac_ext"\"") >&5
   (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:2930: \$? = $ac_status" >&5
+  echo "$as_me:2989: \$? = $ac_status" >&5
   (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -2950,17 +3009,17 @@ rm -f conftest.err "conftest.$ac_ext"
   # OK, works on sane cases.  Now check whether non-existent headers
   # can be detected and how.
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 2953 "configure"
+#line 3012 "configure"
 #include "confdefs.h"
 #include <ac_nonexistent.h>
 _ACEOF
-if { (eval echo "$as_me:2957: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+if { (eval echo "$as_me:3016: \"$ac_cpp "conftest.$ac_ext"\"") >&5
   (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:2963: \$? = $ac_status" >&5
+  echo "$as_me:3022: \$? = $ac_status" >&5
   (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -2988,7 +3047,7 @@ rm -f conftest.err "conftest.$ac_ext"
 if $ac_preproc_ok; then
   :
 else
-  { { echo "$as_me:2991: error: C preprocessor \"$CPP\" fails sanity check" >&5
+  { { echo "$as_me:3050: error: C preprocessor \"$CPP\" fails sanity check" >&5
 echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check" >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -3001,14 +3060,14 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 ac_main_return="return"
 
 if test $ac_cv_c_compiler_gnu = yes; then
-    echo "$as_me:3004: checking whether $CC needs -traditional" >&5
+    echo "$as_me:3063: checking whether $CC needs -traditional" >&5
 echo $ECHO_N "checking whether $CC needs -traditional... $ECHO_C" >&6
 if test "${ac_cv_prog_gcc_traditional+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
     ac_pattern="Autoconf.*'x'"
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 3011 "configure"
+#line 3070 "configure"
 #include "confdefs.h"
 #include <sgtty.h>
 int Autoconf = TIOCGETP;
@@ -3023,7 +3082,7 @@ rm -rf conftest*
 
   if test $ac_cv_prog_gcc_traditional = no; then
     cat >"conftest.$ac_ext" <<_ACEOF
-#line 3026 "configure"
+#line 3085 "configure"
 #include "confdefs.h"
 #include <termio.h>
 int Autoconf = TCGETA;
@@ -3036,14 +3095,14 @@ rm -rf conftest*
 
   fi
 fi
-echo "$as_me:3039: result: $ac_cv_prog_gcc_traditional" >&5
+echo "$as_me:3098: result: $ac_cv_prog_gcc_traditional" >&5
 echo "${ECHO_T}$ac_cv_prog_gcc_traditional" >&6
   if test $ac_cv_prog_gcc_traditional = yes; then
     CC="$CC -traditional"
   fi
 fi
 
-echo "$as_me:3046: checking whether $CC understands -c and -o together" >&5
+echo "$as_me:3105: checking whether $CC understands -c and -o together" >&5
 echo $ECHO_N "checking whether $CC understands -c and -o together... $ECHO_C" >&6
 if test "${cf_cv_prog_CC_c_o+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -3058,15 +3117,15 @@ CF_EOF
 # We do the test twice because some compilers refuse to overwrite an
 # existing .o file with -o, though they will create one.
 ac_try='$CC $CFLAGS $CPPFLAGS -c conftest.$ac_ext -o conftest2.$ac_objext >&5'
-if { (eval echo "$as_me:3061: \"$ac_try\"") >&5
+if { (eval echo "$as_me:3120: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:3064: \$? = $ac_status" >&5
+  echo "$as_me:3123: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
-  test -f conftest2.$ac_objext && { (eval echo "$as_me:3066: \"$ac_try\"") >&5
+  test -f conftest2.$ac_objext && { (eval echo "$as_me:3125: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:3069: \$? = $ac_status" >&5
+  echo "$as_me:3128: \$? = $ac_status" >&5
   (exit "$ac_status"); };
 then
   eval cf_cv_prog_CC_c_o=yes
@@ -3077,10 +3136,10 @@ rm -rf ./conftest*
 
 fi
 if test "$cf_cv_prog_CC_c_o" = yes; then
-  echo "$as_me:3080: result: yes" >&5
+  echo "$as_me:3139: result: yes" >&5
 echo "${ECHO_T}yes" >&6
 else
-  echo "$as_me:3083: result: no" >&5
+  echo "$as_me:3142: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -3094,7 +3153,7 @@ else
 	(*) LDPATH=$PATH:/sbin:/usr/sbin
 		# Extract the first word of "ldconfig", so it can be a program name with args.
 set dummy ldconfig; ac_word=$2
-echo "$as_me:3097: checking for $ac_word" >&5
+echo "$as_me:3156: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_path_LDCONFIG+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -3111,7 +3170,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   if $as_executable_p "$ac_dir/$ac_word"; then
    ac_cv_path_LDCONFIG="$ac_dir/$ac_word"
-   echo "$as_me:3114: found $ac_dir/$ac_word" >&5
+   echo "$as_me:3173: found $ac_dir/$ac_word" >&5
    break
 fi
 done
@@ -3122,10 +3181,10 @@ fi
 LDCONFIG=$ac_cv_path_LDCONFIG
 
 if test -n "$LDCONFIG"; then
-  echo "$as_me:3125: result: $LDCONFIG" >&5
+  echo "$as_me:3184: result: $LDCONFIG" >&5
 echo "${ECHO_T}$LDCONFIG" >&6
 else
-  echo "$as_me:3128: result: no" >&5
+  echo "$as_me:3187: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -3133,7 +3192,7 @@ fi
 	esac
 fi
 
-echo "$as_me:3136: checking if you want to ensure bool is consistent with C++" >&5
+echo "$as_me:3195: checking if you want to ensure bool is consistent with C++" >&5
 echo $ECHO_N "checking if you want to ensure bool is consistent with C++... $ECHO_C" >&6
 
 # Check whether --with-cxx or --without-cxx was given.
@@ -3143,7 +3202,7 @@ if test "${with_cxx+set}" = set; then
 else
   cf_with_cxx=yes
 fi;
-echo "$as_me:3146: result: $cf_with_cxx" >&5
+echo "$as_me:3205: result: $cf_with_cxx" >&5
 echo "${ECHO_T}$cf_with_cxx" >&6
 if test "X$cf_with_cxx" = Xno ; then
 	CXX=""
@@ -3161,7 +3220,7 @@ if test -n "$ac_tool_prefix"; then
   do
     # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:3164: checking for $ac_word" >&5
+echo "$as_me:3223: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_CXX+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -3176,7 +3235,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
-echo "$as_me:3179: found $ac_dir/$ac_word" >&5
+echo "$as_me:3238: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -3184,10 +3243,10 @@ fi
 fi
 CXX=$ac_cv_prog_CXX
 if test -n "$CXX"; then
-  echo "$as_me:3187: result: $CXX" >&5
+  echo "$as_me:3246: result: $CXX" >&5
 echo "${ECHO_T}$CXX" >&6
 else
-  echo "$as_me:3190: result: no" >&5
+  echo "$as_me:3249: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -3200,7 +3259,7 @@ if test -z "$CXX"; then
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:3203: checking for $ac_word" >&5
+echo "$as_me:3262: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -3215,7 +3274,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_ac_ct_CXX="$ac_prog"
-echo "$as_me:3218: found $ac_dir/$ac_word" >&5
+echo "$as_me:3277: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -3223,10 +3282,10 @@ fi
 fi
 ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
 if test -n "$ac_ct_CXX"; then
-  echo "$as_me:3226: result: $ac_ct_CXX" >&5
+  echo "$as_me:3285: result: $ac_ct_CXX" >&5
 echo "${ECHO_T}$ac_ct_CXX" >&6
 else
-  echo "$as_me:3229: result: no" >&5
+  echo "$as_me:3288: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -3238,32 +3297,32 @@ test -n "$ac_ct_CXX" || ac_ct_CXX="g++"
 fi
 
 # Provide some information about the compiler.
-echo "$as_me:3241:" \
+echo "$as_me:3300:" \
      "checking for C++ compiler version" >&5
 ac_compiler=`set X $ac_compile; echo $2`
-{ (eval echo "$as_me:3244: \"$ac_compiler --version </dev/null >&5\"") >&5
+{ (eval echo "$as_me:3303: \"$ac_compiler --version </dev/null >&5\"") >&5
   (eval $ac_compiler --version </dev/null >&5) 2>&5
   ac_status=$?
-  echo "$as_me:3247: \$? = $ac_status" >&5
+  echo "$as_me:3306: \$? = $ac_status" >&5
   (exit "$ac_status"); }
-{ (eval echo "$as_me:3249: \"$ac_compiler -v </dev/null >&5\"") >&5
+{ (eval echo "$as_me:3308: \"$ac_compiler -v </dev/null >&5\"") >&5
   (eval $ac_compiler -v </dev/null >&5) 2>&5
   ac_status=$?
-  echo "$as_me:3252: \$? = $ac_status" >&5
+  echo "$as_me:3311: \$? = $ac_status" >&5
   (exit "$ac_status"); }
-{ (eval echo "$as_me:3254: \"$ac_compiler -V </dev/null >&5\"") >&5
+{ (eval echo "$as_me:3313: \"$ac_compiler -V </dev/null >&5\"") >&5
   (eval $ac_compiler -V </dev/null >&5) 2>&5
   ac_status=$?
-  echo "$as_me:3257: \$? = $ac_status" >&5
+  echo "$as_me:3316: \$? = $ac_status" >&5
   (exit "$ac_status"); }
 
-echo "$as_me:3260: checking whether we are using the GNU C++ compiler" >&5
+echo "$as_me:3319: checking whether we are using the GNU C++ compiler" >&5
 echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6
 if test "${ac_cv_cxx_compiler_gnu+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 3266 "configure"
+#line 3325 "configure"
 #include "confdefs.h"
 
 int
@@ -3278,16 +3337,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:3281: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:3340: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:3284: \$? = $ac_status" >&5
+  echo "$as_me:3343: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:3287: \"$ac_try\"") >&5
+  { (eval echo "$as_me:3346: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:3290: \$? = $ac_status" >&5
+  echo "$as_me:3349: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_compiler_gnu=yes
 else
@@ -3299,19 +3358,19 @@ rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
 
 fi
-echo "$as_me:3302: result: $ac_cv_cxx_compiler_gnu" >&5
+echo "$as_me:3361: result: $ac_cv_cxx_compiler_gnu" >&5
 echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6
 GXX=`test $ac_compiler_gnu = yes && echo yes`
 ac_test_CXXFLAGS=${CXXFLAGS+set}
 ac_save_CXXFLAGS=$CXXFLAGS
 CXXFLAGS="-g"
-echo "$as_me:3308: checking whether $CXX accepts -g" >&5
+echo "$as_me:3367: checking whether $CXX accepts -g" >&5
 echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6
 if test "${ac_cv_prog_cxx_g+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 3314 "configure"
+#line 3373 "configure"
 #include "confdefs.h"
 
 int
@@ -3323,16 +3382,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:3326: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:3385: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:3329: \$? = $ac_status" >&5
+  echo "$as_me:3388: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:3332: \"$ac_try\"") >&5
+  { (eval echo "$as_me:3391: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:3335: \$? = $ac_status" >&5
+  echo "$as_me:3394: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_prog_cxx_g=yes
 else
@@ -3342,7 +3401,7 @@ ac_cv_prog_cxx_g=no
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 fi
-echo "$as_me:3345: result: $ac_cv_prog_cxx_g" >&5
+echo "$as_me:3404: result: $ac_cv_prog_cxx_g" >&5
 echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6
 if test "$ac_test_CXXFLAGS" = set; then
   CXXFLAGS=$ac_save_CXXFLAGS
@@ -3369,7 +3428,7 @@ for ac_declaration in \
    'void exit (int);'
 do
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 3372 "configure"
+#line 3431 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 $ac_declaration
@@ -3382,16 +3441,16 @@ exit (42);
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:3385: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:3444: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:3388: \$? = $ac_status" >&5
+  echo "$as_me:3447: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:3391: \"$ac_try\"") >&5
+  { (eval echo "$as_me:3450: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:3394: \$? = $ac_status" >&5
+  echo "$as_me:3453: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   :
 else
@@ -3401,7 +3460,7 @@ continue
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 3404 "configure"
+#line 3463 "configure"
 #include "confdefs.h"
 $ac_declaration
 int
@@ -3413,16 +3472,16 @@ exit (42);
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:3416: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:3475: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:3419: \$? = $ac_status" >&5
+  echo "$as_me:3478: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:3422: \"$ac_try\"") >&5
+  { (eval echo "$as_me:3481: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:3425: \$? = $ac_status" >&5
+  echo "$as_me:3484: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   break
 else
@@ -3456,7 +3515,7 @@ ac_main_return="return"
 	then
 		# Several of the C++ configurations do not work, particularly when
 		# cross-compiling (20140913 -TD)
-		echo "$as_me:3459: checking if $CXX works" >&5
+		echo "$as_me:3518: checking if $CXX works" >&5
 echo $ECHO_N "checking if $CXX works... $ECHO_C" >&6
 
 		save_CPPFLAGS="$CPPFLAGS"
@@ -3464,7 +3523,7 @@ echo $ECHO_N "checking if $CXX works... $ECHO_C" >&6
 		CPPFLAGS="$CPPFLAGS -I${cf_includedir}"
 
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 3467 "configure"
+#line 3526 "configure"
 #include "confdefs.h"
 
 #include <stdlib.h>
@@ -3481,16 +3540,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:3484: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:3543: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:3487: \$? = $ac_status" >&5
+  echo "$as_me:3546: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:3490: \"$ac_try\"") >&5
+  { (eval echo "$as_me:3549: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:3493: \$? = $ac_status" >&5
+  echo "$as_me:3552: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cxx_works=yes
 else
@@ -3501,11 +3560,11 @@ fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 		CPPFLAGS="$save_CPPFLAGS"
 
-		echo "$as_me:3504: result: $cf_cxx_works" >&5
+		echo "$as_me:3563: result: $cf_cxx_works" >&5
 echo "${ECHO_T}$cf_cxx_works" >&6
 		if test "x$cf_cxx_works" = xno
 		then
-			{ echo "$as_me:3508: WARNING: Ignore $CXX, since it cannot compile hello-world." >&5
+			{ echo "$as_me:3567: WARNING: Ignore $CXX, since it cannot compile hello-world." >&5
 echo "$as_me: WARNING: Ignore $CXX, since it cannot compile hello-world." >&2;}
 			cf_with_cxx=no; CXX=""; GXX="";
 		fi
@@ -3521,7 +3580,7 @@ ac_main_return="return"
 	if test "$CXX" = "g++" ; then
 		# Extract the first word of "g++", so it can be a program name with args.
 set dummy g++; ac_word=$2
-echo "$as_me:3524: checking for $ac_word" >&5
+echo "$as_me:3583: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_path_CXX+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -3538,7 +3597,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   if $as_executable_p "$ac_dir/$ac_word"; then
    ac_cv_path_CXX="$ac_dir/$ac_word"
-   echo "$as_me:3541: found $ac_dir/$ac_word" >&5
+   echo "$as_me:3600: found $ac_dir/$ac_word" >&5
    break
 fi
 done
@@ -3549,17 +3608,17 @@ fi
 CXX=$ac_cv_path_CXX
 
 if test -n "$CXX"; then
-  echo "$as_me:3552: result: $CXX" >&5
+  echo "$as_me:3611: result: $CXX" >&5
 echo "${ECHO_T}$CXX" >&6
 else
-  echo "$as_me:3555: result: no" >&5
+  echo "$as_me:3614: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
 	fi
 	case "x$CXX" in
 	(x|xg++)
-		{ echo "$as_me:3562: WARNING: You don't have any C++ compiler, too bad" >&5
+		{ echo "$as_me:3621: WARNING: You don't have any C++ compiler, too bad" >&5
 echo "$as_me: WARNING: You don't have any C++ compiler, too bad" >&2;}
 		cf_with_cxx=no; CXX=""; GXX="";
 		;;
@@ -3568,15 +3627,15 @@ fi
 
 GXX_VERSION=none
 if test "$GXX" = yes; then
-	echo "$as_me:3571: checking version of ${CXX:-g++}" >&5
+	echo "$as_me:3630: checking version of ${CXX:-g++}" >&5
 echo $ECHO_N "checking version of ${CXX:-g++}... $ECHO_C" >&6
-	GXX_VERSION="`${CXX:-g++} --version| sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[^0-9.]*//' -e 's/[^0-9.].*//'`"
+	GXX_VERSION="`${CXX:-g++} --version 2>/dev/null | sed -e '2,$d' -e 's/^[^(]*([^)][^)]*) //' -e 's/^[^0-9.]*//' -e 's/[^0-9.].*//'`"
 	if test -z "$GXX_VERSION"
 	then
 		GXX_VERSION=unknown
 		GXX=no
 	fi
-	echo "$as_me:3579: result: $GXX_VERSION" >&5
+	echo "$as_me:3638: result: $GXX_VERSION" >&5
 echo "${ECHO_T}$GXX_VERSION" >&6
 fi
 
@@ -3584,12 +3643,12 @@ case "$GXX_VERSION" in
 ([1-9][0-9].*)
 	;;
 (1.*|2.[0-6]*)
-	{ echo "$as_me:3587: WARNING: templates do not work" >&5
+	{ echo "$as_me:3646: WARNING: templates do not work" >&5
 echo "$as_me: WARNING: templates do not work" >&2;}
 	;;
 esac
 
-echo "$as_me:3592: checking if you want to build C++ binding and demo" >&5
+echo "$as_me:3651: checking if you want to build C++ binding and demo" >&5
 echo $ECHO_N "checking if you want to build C++ binding and demo... $ECHO_C" >&6
 
 # Check whether --with-cxx-binding or --without-cxx-binding was given.
@@ -3599,15 +3658,15 @@ if test "${with_cxx_binding+set}" = set; then
 else
   cf_with_cxx_binding=$cf_with_cxx
 fi;
-echo "$as_me:3602: result: $cf_with_cxx_binding" >&5
+echo "$as_me:3661: result: $cf_with_cxx_binding" >&5
 echo "${ECHO_T}$cf_with_cxx_binding" >&6
 
-echo "$as_me:3605: checking if you want to build with Ada" >&5
+echo "$as_me:3664: checking if you want to build with Ada" >&5
 echo $ECHO_N "checking if you want to build with Ada... $ECHO_C" >&6
-echo "$as_me:3607: result: $cf_with_ada" >&5
+echo "$as_me:3666: result: $cf_with_ada" >&5
 echo "${ECHO_T}$cf_with_ada" >&6
 
-echo "$as_me:3610: checking if you want to install terminal database" >&5
+echo "$as_me:3669: checking if you want to install terminal database" >&5
 echo $ECHO_N "checking if you want to install terminal database... $ECHO_C" >&6
 
 # Check whether --enable-db-install or --disable-db-install was given.
@@ -3617,10 +3676,10 @@ if test "${enable_db_install+set}" = set; then
 else
   cf_with_db_install=yes
 fi;
-echo "$as_me:3620: result: $cf_with_db_install" >&5
+echo "$as_me:3679: result: $cf_with_db_install" >&5
 echo "${ECHO_T}$cf_with_db_install" >&6
 
-echo "$as_me:3623: checking if you want to install manpages" >&5
+echo "$as_me:3682: checking if you want to install manpages" >&5
 echo $ECHO_N "checking if you want to install manpages... $ECHO_C" >&6
 
 # Check whether --with-manpages or --without-manpages was given.
@@ -3630,10 +3689,10 @@ if test "${with_manpages+set}" = set; then
 else
   cf_with_manpages=yes
 fi;
-echo "$as_me:3633: result: $cf_with_manpages" >&5
+echo "$as_me:3692: result: $cf_with_manpages" >&5
 echo "${ECHO_T}$cf_with_manpages" >&6
 
-echo "$as_me:3636: checking if you want to build programs such as tic" >&5
+echo "$as_me:3695: checking if you want to build programs such as tic" >&5
 echo $ECHO_N "checking if you want to build programs such as tic... $ECHO_C" >&6
 
 # Check whether --with-progs or --without-progs was given.
@@ -3643,35 +3702,10 @@ if test "${with_progs+set}" = set; then
 else
   cf_with_progs=yes
 fi;
-echo "$as_me:3646: result: $cf_with_progs" >&5
+echo "$as_me:3705: result: $cf_with_progs" >&5
 echo "${ECHO_T}$cf_with_progs" >&6
 
-if test -f "$srcdir/tack/tack.h" ; then
-	if test "x$cross_compiling" = xyes ; then
-		test -n "$verbose" && echo "	ignoring tack because we are cross-compiling" 1>&6
-
-echo "${as_me:-configure}:3653: testing ignoring tack because we are cross-compiling ..." 1>&5
-
-		cf_with_tack=no
-	else
-		echo "$as_me:3657: checking if you want to build the tack program" >&5
-echo $ECHO_N "checking if you want to build the tack program... $ECHO_C" >&6
-
-# Check whether --with-tack or --without-tack was given.
-if test "${with_tack+set}" = set; then
-  withval="$with_tack"
-  cf_with_tack=$withval
-else
-  cf_with_tack=$cf_with_progs
-fi;
-		echo "$as_me:3667: result: $cf_with_tack" >&5
-echo "${ECHO_T}$cf_with_tack" >&6
-	fi
-else
-	cf_with_tack=no
-fi
-
-echo "$as_me:3674: checking if you want to build test-programs" >&5
+echo "$as_me:3708: checking if you want to build test-programs" >&5
 echo $ECHO_N "checking if you want to build test-programs... $ECHO_C" >&6
 
 # Check whether --with-tests or --without-tests was given.
@@ -3681,10 +3715,10 @@ if test "${with_tests+set}" = set; then
 else
   cf_with_tests=yes
 fi;
-echo "$as_me:3684: result: $cf_with_tests" >&5
+echo "$as_me:3718: result: $cf_with_tests" >&5
 echo "${ECHO_T}$cf_with_tests" >&6
 
-echo "$as_me:3687: checking if you wish to install curses.h" >&5
+echo "$as_me:3721: checking if you wish to install curses.h" >&5
 echo $ECHO_N "checking if you wish to install curses.h... $ECHO_C" >&6
 
 # Check whether --with-curses-h or --without-curses-h was given.
@@ -3694,12 +3728,11 @@ if test "${with_curses_h+set}" = set; then
 else
   with_curses_h=yes
 fi;
-echo "$as_me:3697: result: $with_curses_h" >&5
+echo "$as_me:3731: result: $with_curses_h" >&5
 echo "${ECHO_T}$with_curses_h" >&6
 
 modules_to_build="ncurses"
 test "X$cf_with_progs" != Xno && modules_to_build="$modules_to_build progs"
-test "X$cf_with_tack"  != Xno && modules_to_build="$modules_to_build tack"
 modules_to_build="$modules_to_build panel menu form"
 
 test "$program_prefix" != NONE &&
@@ -3719,7 +3752,7 @@ for ac_prog in mawk gawk nawk awk
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:3722: checking for $ac_word" >&5
+echo "$as_me:3755: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_AWK+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -3734,7 +3767,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_AWK="$ac_prog"
-echo "$as_me:3737: found $ac_dir/$ac_word" >&5
+echo "$as_me:3770: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -3742,17 +3775,17 @@ fi
 fi
 AWK=$ac_cv_prog_AWK
 if test -n "$AWK"; then
-  echo "$as_me:3745: result: $AWK" >&5
+  echo "$as_me:3778: result: $AWK" >&5
 echo "${ECHO_T}$AWK" >&6
 else
-  echo "$as_me:3748: result: no" >&5
+  echo "$as_me:3781: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
   test -n "$AWK" && break
 done
 
-test -z "$AWK" && { { echo "$as_me:3755: error: No awk program found" >&5
+test -z "$AWK" && { { echo "$as_me:3788: error: No awk program found" >&5
 echo "$as_me: error: No awk program found" >&2;}
    { (exit 1); exit 1; }; }
 
@@ -3768,7 +3801,7 @@ echo "$as_me: error: No awk program found" >&2;}
 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
 # ./install, which can be erroneously created by make from ./install.sh.
-echo "$as_me:3771: checking for a BSD compatible install" >&5
+echo "$as_me:3804: checking for a BSD compatible install" >&5
 echo $ECHO_N "checking for a BSD compatible install... $ECHO_C" >&6
 if test -z "$INSTALL"; then
 if test "${ac_cv_path_install+set}" = set; then
@@ -3817,7 +3850,7 @@ fi
     INSTALL=$ac_install_sh
   fi
 fi
-echo "$as_me:3820: result: $INSTALL" >&5
+echo "$as_me:3853: result: $INSTALL" >&5
 echo "${ECHO_T}$INSTALL" >&6
 
 # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
@@ -3842,7 +3875,7 @@ for ac_prog in lint cppcheck splint
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:3845: checking for $ac_word" >&5
+echo "$as_me:3878: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_LINT+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -3857,7 +3890,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_LINT="$ac_prog"
-echo "$as_me:3860: found $ac_dir/$ac_word" >&5
+echo "$as_me:3893: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -3865,10 +3898,10 @@ fi
 fi
 LINT=$ac_cv_prog_LINT
 if test -n "$LINT"; then
-  echo "$as_me:3868: result: $LINT" >&5
+  echo "$as_me:3901: result: $LINT" >&5
 echo "${ECHO_T}$LINT" >&6
 else
-  echo "$as_me:3871: result: no" >&5
+  echo "$as_me:3904: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -3881,18 +3914,18 @@ case "x$LINT" in
 	;;
 esac
 
-echo "$as_me:3884: checking whether ln -s works" >&5
+echo "$as_me:3917: checking whether ln -s works" >&5
 echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6
 LN_S=$as_ln_s
 if test "$LN_S" = "ln -s"; then
-  echo "$as_me:3888: result: yes" >&5
+  echo "$as_me:3921: result: yes" >&5
 echo "${ECHO_T}yes" >&6
 else
-  echo "$as_me:3891: result: no, using $LN_S" >&5
+  echo "$as_me:3924: result: no, using $LN_S" >&5
 echo "${ECHO_T}no, using $LN_S" >&6
 fi
 
-echo "$as_me:3895: checking if $LN_S -f options work" >&5
+echo "$as_me:3928: checking if $LN_S -f options work" >&5
 echo $ECHO_N "checking if $LN_S -f options work... $ECHO_C" >&6
 
 rm -f conf$$.src conf$$dst
@@ -3904,12 +3937,12 @@ else
 	cf_prog_ln_sf=no
 fi
 rm -f conf$$.dst conf$$src
-echo "$as_me:3907: result: $cf_prog_ln_sf" >&5
+echo "$as_me:3940: result: $cf_prog_ln_sf" >&5
 echo "${ECHO_T}$cf_prog_ln_sf" >&6
 
 test "$cf_prog_ln_sf" = yes && LN_S="$LN_S -f"
 
-echo "$as_me:3912: checking for long file names" >&5
+echo "$as_me:3945: checking for long file names" >&5
 echo $ECHO_N "checking for long file names... $ECHO_C" >&6
 if test "${ac_cv_sys_long_file_names+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -3948,7 +3981,7 @@ for ac_dir in  . $ac_tmpdirs `eval echo "$prefix/lib" "$exec_prefix/lib"` ; do
   rm -rf "$ac_xdir" 2>/dev/null
 done
 fi
-echo "$as_me:3951: result: $ac_cv_sys_long_file_names" >&5
+echo "$as_me:3984: result: $ac_cv_sys_long_file_names" >&5
 echo "${ECHO_T}$ac_cv_sys_long_file_names" >&6
 if test "$ac_cv_sys_long_file_names" = yes; then
 
@@ -3967,7 +4000,7 @@ if test "${with_config_suffix+set}" = set; then
   withval="$with_config_suffix"
   case "x$withval" in
 	(xyes|xno)
-		{ echo "$as_me:3970: WARNING: expected a value for config-suffix option" >&5
+		{ echo "$as_me:4003: WARNING: expected a value for config-suffix option" >&5
 echo "$as_me: WARNING: expected a value for config-suffix option" >&2;}
 		;;
 	(*)	cf_config_suffix="$withval"
@@ -3977,7 +4010,7 @@ fi;
 
 # If we find pkg-config, check if we should install the ".pc" files.
 
-echo "$as_me:3980: checking if you want to use pkg-config" >&5
+echo "$as_me:4013: checking if you want to use pkg-config" >&5
 echo $ECHO_N "checking if you want to use pkg-config... $ECHO_C" >&6
 
 # Check whether --with-pkg-config or --without-pkg-config was given.
@@ -3987,7 +4020,7 @@ if test "${with_pkg_config+set}" = set; then
 else
   cf_pkg_config=yes
 fi;
-echo "$as_me:3990: result: $cf_pkg_config" >&5
+echo "$as_me:4023: result: $cf_pkg_config" >&5
 echo "${ECHO_T}$cf_pkg_config" >&6
 
 case "$cf_pkg_config" in
@@ -3999,7 +4032,7 @@ case "$cf_pkg_config" in
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
 set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
-echo "$as_me:4002: checking for $ac_word" >&5
+echo "$as_me:4035: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_path_PKG_CONFIG+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -4016,7 +4049,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   if $as_executable_p "$ac_dir/$ac_word"; then
    ac_cv_path_PKG_CONFIG="$ac_dir/$ac_word"
-   echo "$as_me:4019: found $ac_dir/$ac_word" >&5
+   echo "$as_me:4052: found $ac_dir/$ac_word" >&5
    break
 fi
 done
@@ -4027,10 +4060,10 @@ fi
 PKG_CONFIG=$ac_cv_path_PKG_CONFIG
 
 if test -n "$PKG_CONFIG"; then
-  echo "$as_me:4030: result: $PKG_CONFIG" >&5
+  echo "$as_me:4063: result: $PKG_CONFIG" >&5
 echo "${ECHO_T}$PKG_CONFIG" >&6
 else
-  echo "$as_me:4033: result: no" >&5
+  echo "$as_me:4066: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -4039,7 +4072,7 @@ if test -z "$ac_cv_path_PKG_CONFIG"; then
   ac_pt_PKG_CONFIG=$PKG_CONFIG
   # Extract the first word of "pkg-config", so it can be a program name with args.
 set dummy pkg-config; ac_word=$2
-echo "$as_me:4042: checking for $ac_word" >&5
+echo "$as_me:4075: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -4056,7 +4089,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   if $as_executable_p "$ac_dir/$ac_word"; then
    ac_cv_path_ac_pt_PKG_CONFIG="$ac_dir/$ac_word"
-   echo "$as_me:4059: found $ac_dir/$ac_word" >&5
+   echo "$as_me:4092: found $ac_dir/$ac_word" >&5
    break
 fi
 done
@@ -4068,10 +4101,10 @@ fi
 ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
 
 if test -n "$ac_pt_PKG_CONFIG"; then
-  echo "$as_me:4071: result: $ac_pt_PKG_CONFIG" >&5
+  echo "$as_me:4104: result: $ac_pt_PKG_CONFIG" >&5
 echo "${ECHO_T}$ac_pt_PKG_CONFIG" >&6
 else
-  echo "$as_me:4074: result: no" >&5
+  echo "$as_me:4107: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -4114,110 +4147,164 @@ case ".$PKG_CONFIG" in
 	PKG_CONFIG=`echo "$PKG_CONFIG" | sed -e s%NONE%$cf_path_syntax%`
 	;;
 (*)
-	{ { echo "$as_me:4117: error: expected a pathname, not \"$PKG_CONFIG\"" >&5
+	{ { echo "$as_me:4150: error: expected a pathname, not \"$PKG_CONFIG\"" >&5
 echo "$as_me: error: expected a pathname, not \"$PKG_CONFIG\"" >&2;}
    { (exit 1); exit 1; }; }
 	;;
 esac
 
 elif test "x$cf_pkg_config" != xno ; then
-	{ echo "$as_me:4124: WARNING: pkg-config is not installed" >&5
+	{ echo "$as_me:4157: WARNING: pkg-config is not installed" >&5
 echo "$as_me: WARNING: pkg-config is not installed" >&2;}
 fi
 
 case "$PKG_CONFIG" in
 (no|none|yes)
-	echo "$as_me:4130: checking for pkg-config library directory" >&5
+	echo "$as_me:4163: checking for pkg-config library directory" >&5
 echo $ECHO_N "checking for pkg-config library directory... $ECHO_C" >&6
 	;;
 (*)
-	echo "$as_me:4134: checking for $PKG_CONFIG library directory" >&5
+	echo "$as_me:4167: checking for $PKG_CONFIG library directory" >&5
 echo $ECHO_N "checking for $PKG_CONFIG library directory... $ECHO_C" >&6
 	;;
 esac
 
-PKG_CONFIG_LIBDIR=no
+# if $PKG_CONFIG_LIBDIR is set, try to use that
+if test -n "$PKG_CONFIG_PATH"; then
+	cf_search_path=`echo "$PKG_CONFIG_PATH" | sed -e 's/:/ /g' -e 's,^[ 	]*,,' -e 's,[ 	]*$,,'`
+elif test -n "$PKG_CONFIG_LIBDIR"; then
+	cf_search_path=`echo "$PKG_CONFIG_LIBDIR" | sed -e 's/:/ /g' -e 's,^[ 	]*,,' -e 's,[ 	]*$,,'`
+else
+	cf_search_path=auto
+fi
+
+# if the option is used, let that override.  otherwise default to "libdir"
 
 # Check whether --with-pkg-config-libdir or --without-pkg-config-libdir was given.
 if test "${with_pkg_config_libdir+set}" = set; then
   withval="$with_pkg_config_libdir"
-  PKG_CONFIG_LIBDIR=$withval
+  cf_search_path=$withval
 else
-  test "x$PKG_CONFIG" != xnone && PKG_CONFIG_LIBDIR=yes
+  test "x$PKG_CONFIG" != xnone && test -z "$cf_search_path" && cf_search_path=libdir
 fi;
 
-case x$PKG_CONFIG_LIBDIR in
+case "x$cf_search_path" in
+(xlibdir)
+	PKG_CONFIG_LIBDIR='${libdir}/pkgconfig'
+	echo "$as_me:4194: result: $PKG_CONFIG_LIBDIR" >&5
+echo "${ECHO_T}$PKG_CONFIG_LIBDIR" >&6
+	cf_search_path=
+	;;
+(x)
+	;;
+(x/*\ *)
+	PKG_CONFIG_LIBDIR=
+	;;
 (x/*)
+	PKG_CONFIG_LIBDIR="$cf_search_path"
+	echo "$as_me:4205: result: $PKG_CONFIG_LIBDIR" >&5
+echo "${ECHO_T}$PKG_CONFIG_LIBDIR" >&6
+	cf_search_path=
 	;;
-(xyes)
+(xyes|xauto)
+	echo "$as_me:4210: result: auto" >&5
+echo "${ECHO_T}auto" >&6
+	cf_search_path=
 	# Look for the library directory using the same prefix as the executable
-	if test "x$PKG_CONFIG" = xnone
+	echo "$as_me:4214: checking for search-list" >&5
+echo $ECHO_N "checking for search-list... $ECHO_C" >&6
+	if test "x$PKG_CONFIG" != xnone
 	then
-		cf_path=$prefix
-	else
-		cf_path=`echo "$PKG_CONFIG" | sed -e 's,/[^/]*/[^/]*$,,'`
-	fi
-
-	# If you don't like using the default architecture, you have to specify the
-	# intended library directory and corresponding compiler/linker options.
-	#
-	# This case allows for Debian's 2014-flavor of multiarch, along with the
-	# most common variations before that point.  Some other variants spell the
-	# directory differently, e.g., "pkg-config", and put it in unusual places.
-	# pkg-config has always been poorly standardized, which is ironic...
-	case x`(arch) 2>/dev/null` in
-	(*64)
-		cf_search_path="\
-			$cf_path/lib/*64-linux-gnu \
-			$cf_path/share \
-			$cf_path/lib64 \
-			$cf_path/lib32 \
-			$cf_path/lib"
-		;;
-	(*)
-		cf_search_path="\
-			$cf_path/lib/*-linux-gnu \
-			$cf_path/share \
-			$cf_path/lib32 \
-			$cf_path/lib \
-			$cf_path/libdata"
-		;;
-	esac
+		# works for pkg-config since version 0.24 (2009)
+		# works for pkgconf since version 0.8.3 (2012)
+		for cf_pkg_program in \
+			`echo "$PKG_CONFIG" | sed -e 's,^.*/,,'` \
+			pkg-config \
+			pkgconf
+		do
+			cf_search_path=`"$PKG_CONFIG" --variable=pc_path "$cf_pkg_program" 2>/dev/null | tr : ' '`
+			test -n "$cf_search_path" && break
+		done
 
-	test -n "$verbose" && echo "	list..." 1>&6
+		# works for pkg-config since import in 2005 of original 2001 HP code.
+		test -z "$cf_search_path" && \
+		cf_search_path=`
+		"$PKG_CONFIG" --debug --exists no-such-package 2>&1 | $AWK "\
+/^Scanning directory (#[1-9][0-9]* )?'.*'$/{ \
+	sub(\"^[^']*'\",\"\"); \
+	sub(\"'.*\",\"\"); \
+	printf \" %s\", \\$0; } \
+{ next; } \
+"`
+	fi
 
-echo "${as_me:-configure}:4189: testing list... ..." 1>&5
+	echo "$as_me:4241: result: $cf_search_path" >&5
+echo "${ECHO_T}$cf_search_path" >&6
+	;;
+(*)
+	{ { echo "$as_me:4245: error: Unexpected option value: $cf_search_path" >&5
+echo "$as_me: error: Unexpected option value: $cf_search_path" >&2;}
+   { (exit 1); exit 1; }; }
+	;;
+esac
 
+if test -n "$cf_search_path"
+then
+	echo "$as_me:4253: checking for first directory" >&5
+echo $ECHO_N "checking for first directory... $ECHO_C" >&6
+	cf_pkg_config_path=none
 	for cf_config in $cf_search_path
 	do
-		test -n "$verbose" && echo "	checking $cf_config/pkgconfig" 1>&6
-
-echo "${as_me:-configure}:4195: testing checking $cf_config/pkgconfig ..." 1>&5
-
-		if test -d "$cf_config/pkgconfig"
+		if test -d "$cf_config"
 		then
-			PKG_CONFIG_LIBDIR=$cf_config/pkgconfig
-			echo "$as_me:4200: checking done" >&5
-echo $ECHO_N "checking done... $ECHO_C" >&6
+			cf_pkg_config_path=$cf_config
 			break
 		fi
 	done
-	;;
-(*)
-	;;
-esac
+	echo "$as_me:4264: result: $cf_pkg_config_path" >&5
+echo "${ECHO_T}$cf_pkg_config_path" >&6
+
+	if test "x$cf_pkg_config_path" != xnone ; then
+		# limit this to the first directory found
+		PKG_CONFIG_LIBDIR="$cf_pkg_config_path"
+	fi
 
-if test "x$PKG_CONFIG_LIBDIR" != xno ; then
-	echo "$as_me:4211: result: $PKG_CONFIG_LIBDIR" >&5
+	if test -z "$PKG_CONFIG_LIBDIR" && test -n "$cf_search_path"
+	then
+		echo "$as_me:4274: checking for workaround" >&5
+echo $ECHO_N "checking for workaround... $ECHO_C" >&6
+		if test "$prefix" = "NONE" ; then
+			cf_prefix="$ac_default_prefix"
+		else
+			cf_prefix="$prefix"
+		fi
+		eval cf_libdir=$libdir
+		cf_libdir=`echo "$cf_libdir" | sed -e "s,^NONE,$cf_prefix,"`
+		cf_backup=
+		for cf_config in $cf_search_path
+		do
+			case $cf_config in
+			$cf_libdir/pkgconfig)
+				PKG_CONFIG_LIBDIR=$cf_libdir/pkgconfig
+				break
+				;;
+			*)
+				test -z "$cf_backup" && cf_backup=$cf_config
+				;;
+			esac
+		done
+		test -z "$PKG_CONFIG_LIBDIR" && PKG_CONFIG_LIBDIR=$cf_backup
+		echo "$as_me:4297: result: $PKG_CONFIG_LIBDIR" >&5
 echo "${ECHO_T}$PKG_CONFIG_LIBDIR" >&6
+	fi
 fi
 
 if test "x$PKG_CONFIG" != xnone
 then
-	echo "$as_me:4217: checking if we should install .pc files for $PKG_CONFIG" >&5
+	echo "$as_me:4304: checking if we should install .pc files for $PKG_CONFIG" >&5
 echo $ECHO_N "checking if we should install .pc files for $PKG_CONFIG... $ECHO_C" >&6
 else
-	echo "$as_me:4220: checking if we should install .pc files" >&5
+	echo "$as_me:4307: checking if we should install .pc files" >&5
 echo $ECHO_N "checking if we should install .pc files... $ECHO_C" >&6
 fi
 
@@ -4228,18 +4315,19 @@ if test "${enable_pc_files+set}" = set; then
 else
   enable_pc_files=no
 fi;
-echo "$as_me:4231: result: $enable_pc_files" >&5
+echo "$as_me:4318: result: $enable_pc_files" >&5
 echo "${ECHO_T}$enable_pc_files" >&6
 
 if test "x$enable_pc_files" != xno
 then
 	MAKE_PC_FILES=
 	case "x$PKG_CONFIG_LIBDIR" in
-	(xno|xyes)
-		{ echo "$as_me:4239: WARNING: no PKG_CONFIG_LIBDIR was found" >&5
+	(xno|xnone|xyes|x)
+		{ echo "$as_me:4326: WARNING: no PKG_CONFIG_LIBDIR was found" >&5
 echo "$as_me: WARNING: no PKG_CONFIG_LIBDIR was found" >&2;}
 		;;
 	(*)
+		cf_pkg_config_libdir="$PKG_CONFIG_LIBDIR"
 
 if test "x$prefix" != xNONE; then
 	cf_path_syntax="$prefix"
@@ -4247,7 +4335,7 @@ else
 	cf_path_syntax="$ac_default_prefix"
 fi
 
-case ".$PKG_CONFIG_LIBDIR" in
+case ".$cf_pkg_config_libdir" in
 (.\$\(*\)*|.\'*\'*)
 	;;
 (..|./*|.\\*)
@@ -4255,19 +4343,19 @@ case ".$PKG_CONFIG_LIBDIR" in
 (.[a-zA-Z]:[\\/]*) # OS/2 EMX
 	;;
 (.\$\{*prefix\}*|.\$\{*dir\}*)
-	eval PKG_CONFIG_LIBDIR="$PKG_CONFIG_LIBDIR"
-	case ".$PKG_CONFIG_LIBDIR" in
+	eval cf_pkg_config_libdir="$cf_pkg_config_libdir"
+	case ".$cf_pkg_config_libdir" in
 	(.NONE/*)
-		PKG_CONFIG_LIBDIR=`echo "$PKG_CONFIG_LIBDIR" | sed -e s%NONE%$cf_path_syntax%`
+		cf_pkg_config_libdir=`echo "$cf_pkg_config_libdir" | sed -e s%NONE%$cf_path_syntax%`
 		;;
 	esac
 	;;
 (.no|.NONE/*)
-	PKG_CONFIG_LIBDIR=`echo "$PKG_CONFIG_LIBDIR" | sed -e s%NONE%$cf_path_syntax%`
+	cf_pkg_config_libdir=`echo "$cf_pkg_config_libdir" | sed -e s%NONE%$cf_path_syntax%`
 	;;
 (*)
-	{ { echo "$as_me:4269: error: expected a pathname, not \"$PKG_CONFIG_LIBDIR\"" >&5
-echo "$as_me: error: expected a pathname, not \"$PKG_CONFIG_LIBDIR\"" >&2;}
+	{ { echo "$as_me:4357: error: expected a pathname, not \"$cf_pkg_config_libdir\"" >&5
+echo "$as_me: error: expected a pathname, not \"$cf_pkg_config_libdir\"" >&2;}
    { (exit 1); exit 1; }; }
 	;;
 esac
@@ -4280,8 +4368,8 @@ fi
 
 if test -z "$MAKE_PC_FILES"
 then
-	echo "$as_me:4283: checking for suffix to add to pc-files" >&5
-echo $ECHO_N "checking for suffix to add to pc-files... $ECHO_C" >&6
+	echo "$as_me:4371: checking for suffix to add to pkg-config files" >&5
+echo $ECHO_N "checking for suffix to add to pkg-config files... $ECHO_C" >&6
 
 # Check whether --with-pc-suffix or --without-pc-suffix was given.
 if test "${with_pc_suffix+set}" = set; then
@@ -4295,13 +4383,13 @@ if test "${with_pc_suffix+set}" = set; then
 	esac
 fi;
 	test -z "$PC_MODULE_SUFFIX" && PC_MODULE_SUFFIX=none
-	echo "$as_me:4298: result: $PC_MODULE_SUFFIX" >&5
+	echo "$as_me:4386: result: $PC_MODULE_SUFFIX" >&5
 echo "${ECHO_T}$PC_MODULE_SUFFIX" >&6
 	test "$PC_MODULE_SUFFIX" = none && PC_MODULE_SUFFIX=
 
 fi
 
-echo "$as_me:4304: checking if we should assume mixed-case filenames" >&5
+echo "$as_me:4392: checking if we should assume mixed-case filenames" >&5
 echo $ECHO_N "checking if we should assume mixed-case filenames... $ECHO_C" >&6
 
 # Check whether --enable-mixed-case or --disable-mixed-case was given.
@@ -4311,11 +4399,11 @@ if test "${enable_mixed_case+set}" = set; then
 else
   enable_mixedcase=auto
 fi;
-echo "$as_me:4314: result: $enable_mixedcase" >&5
+echo "$as_me:4402: result: $enable_mixedcase" >&5
 echo "${ECHO_T}$enable_mixedcase" >&6
 if test "$enable_mixedcase" = "auto" ; then
 
-echo "$as_me:4318: checking if filesystem supports mixed-case filenames" >&5
+echo "$as_me:4406: checking if filesystem supports mixed-case filenames" >&5
 echo $ECHO_N "checking if filesystem supports mixed-case filenames... $ECHO_C" >&6
 if test "${cf_cv_mixedcase+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -4342,7 +4430,7 @@ else
 fi
 
 fi
-echo "$as_me:4345: result: $cf_cv_mixedcase" >&5
+echo "$as_me:4433: result: $cf_cv_mixedcase" >&5
 echo "${ECHO_T}$cf_cv_mixedcase" >&6
 test "$cf_cv_mixedcase" = yes &&
 cat >>confdefs.h <<\EOF
@@ -4361,7 +4449,7 @@ EOF
 fi
 
 # do this after mixed-case option (tags/TAGS is not as important as tic).
-echo "$as_me:4364: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "$as_me:4452: checking whether ${MAKE-make} sets \${MAKE}" >&5
 echo $ECHO_N "checking whether ${MAKE-make} sets \${MAKE}... $ECHO_C" >&6
 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,./+-,__p_,'`
 if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then
@@ -4381,20 +4469,82 @@ fi
 rm -f conftest.make
 fi
 if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
-  echo "$as_me:4384: result: yes" >&5
+  echo "$as_me:4472: result: yes" >&5
 echo "${ECHO_T}yes" >&6
   SET_MAKE=
 else
-  echo "$as_me:4388: result: no" >&5
+  echo "$as_me:4476: result: no" >&5
 echo "${ECHO_T}no" >&6
   SET_MAKE="MAKE=${MAKE-make}"
 fi
 
+echo "$as_me:4481: checking for \".PHONY\" make-support" >&5
+echo $ECHO_N "checking for \".PHONY\" make-support... $ECHO_C" >&6
+if test "${cf_cv_make_PHONY+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+	rm -rf conftest*
+	(
+		mkdir conftest || exit 1
+		cd conftest
+		cat >makefile <<'CF_EOF'
+.PHONY: always
+DATA=0
+always:	always.out
+	@echo "** making $@ $(DATA)"
+once: once.out
+	@echo "** making $@ $(DATA)"
+always.out:
+	@echo "** making $@ $(DATA)"
+	echo $(DATA) > $@
+once.out:
+	@echo "** making $@ $(DATA)"
+	echo $(DATA) > $@
+CF_EOF
+		for cf_data in 1 2 3
+		do
+			${MAKE:-make} always DATA=$cf_data
+			${MAKE:-make} once   DATA=$cf_data
+			${MAKE:-make} -t always once
+			if test -f always ; then
+				echo "no (case 1)" > ../conftest.tmp
+			elif test ! -f always.out ; then
+				echo "no (case 2)" > ../conftest.tmp
+			elif test ! -f once.out ; then
+				echo "no (case 3)" > ../conftest.tmp
+			elif ! cmp -s always.out once.out ; then
+				echo "no (case 4)" > ../conftest.tmp
+				diff always.out once.out
+			else
+				cf_check="`cat always.out`"
+				if test "x$cf_check" != "x$cf_data" ; then
+					echo "no (case 5)" > ../conftest.tmp
+				else
+					echo yes > ../conftest.tmp
+					rm -f ./*.out
+					continue
+				fi
+			fi
+			break
+		done
+	) >&5 2>&1
+	cf_cv_make_PHONY="`cat conftest.tmp`"
+	rm -rf conftest*
+
+fi
+echo "$as_me:4536: result: $cf_cv_make_PHONY" >&5
+echo "${ECHO_T}$cf_cv_make_PHONY" >&6
+MAKE_NO_PHONY="#"
+MAKE_PHONY="#"
+test "x$cf_cv_make_PHONY" = xyes && MAKE_PHONY=
+test "x$cf_cv_make_PHONY" != xyes && MAKE_NO_PHONY=
+
 for ac_prog in exctags ctags
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:4397: checking for $ac_word" >&5
+echo "$as_me:4547: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_CTAGS+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -4409,7 +4559,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_CTAGS="$ac_prog"
-echo "$as_me:4412: found $ac_dir/$ac_word" >&5
+echo "$as_me:4562: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -4417,10 +4567,10 @@ fi
 fi
 CTAGS=$ac_cv_prog_CTAGS
 if test -n "$CTAGS"; then
-  echo "$as_me:4420: result: $CTAGS" >&5
+  echo "$as_me:4570: result: $CTAGS" >&5
 echo "${ECHO_T}$CTAGS" >&6
 else
-  echo "$as_me:4423: result: no" >&5
+  echo "$as_me:4573: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -4431,7 +4581,7 @@ for ac_prog in exetags etags
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:4434: checking for $ac_word" >&5
+echo "$as_me:4584: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ETAGS+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -4446,7 +4596,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_ETAGS="$ac_prog"
-echo "$as_me:4449: found $ac_dir/$ac_word" >&5
+echo "$as_me:4599: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -4454,10 +4604,10 @@ fi
 fi
 ETAGS=$ac_cv_prog_ETAGS
 if test -n "$ETAGS"; then
-  echo "$as_me:4457: result: $ETAGS" >&5
+  echo "$as_me:4607: result: $ETAGS" >&5
 echo "${ECHO_T}$ETAGS" >&6
 else
-  echo "$as_me:4460: result: no" >&5
+  echo "$as_me:4610: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -4466,7 +4616,7 @@ done
 
 # Extract the first word of "${CTAGS:-ctags}", so it can be a program name with args.
 set dummy ${CTAGS:-ctags}; ac_word=$2
-echo "$as_me:4469: checking for $ac_word" >&5
+echo "$as_me:4619: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_MAKE_LOWER_TAGS+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -4481,7 +4631,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_MAKE_LOWER_TAGS="yes"
-echo "$as_me:4484: found $ac_dir/$ac_word" >&5
+echo "$as_me:4634: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -4490,17 +4640,17 @@ fi
 fi
 MAKE_LOWER_TAGS=$ac_cv_prog_MAKE_LOWER_TAGS
 if test -n "$MAKE_LOWER_TAGS"; then
-  echo "$as_me:4493: result: $MAKE_LOWER_TAGS" >&5
+  echo "$as_me:4643: result: $MAKE_LOWER_TAGS" >&5
 echo "${ECHO_T}$MAKE_LOWER_TAGS" >&6
 else
-  echo "$as_me:4496: result: no" >&5
+  echo "$as_me:4646: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
 if test "$cf_cv_mixedcase" = yes ; then
 	# Extract the first word of "${ETAGS:-etags}", so it can be a program name with args.
 set dummy ${ETAGS:-etags}; ac_word=$2
-echo "$as_me:4503: checking for $ac_word" >&5
+echo "$as_me:4653: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_MAKE_UPPER_TAGS+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -4515,7 +4665,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_MAKE_UPPER_TAGS="yes"
-echo "$as_me:4518: found $ac_dir/$ac_word" >&5
+echo "$as_me:4668: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -4524,10 +4674,10 @@ fi
 fi
 MAKE_UPPER_TAGS=$ac_cv_prog_MAKE_UPPER_TAGS
 if test -n "$MAKE_UPPER_TAGS"; then
-  echo "$as_me:4527: result: $MAKE_UPPER_TAGS" >&5
+  echo "$as_me:4677: result: $MAKE_UPPER_TAGS" >&5
 echo "${ECHO_T}$MAKE_UPPER_TAGS" >&6
 else
-  echo "$as_me:4530: result: no" >&5
+  echo "$as_me:4680: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -4547,7 +4697,7 @@ else
 	MAKE_LOWER_TAGS="#"
 fi
 
-echo "$as_me:4550: checking for makeflags variable" >&5
+echo "$as_me:4700: checking for makeflags variable" >&5
 echo $ECHO_N "checking for makeflags variable... $ECHO_C" >&6
 if test "${cf_cv_makeflags+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -4577,7 +4727,7 @@ CF_EOF
 			;;
 		(*)
 
-echo "${as_me:-configure}:4580: testing given option \"$cf_option\",no match \"$cf_result\" ..." 1>&5
+echo "${as_me:-configure}:4730: testing given option \"$cf_option\",no match \"$cf_result\" ..." 1>&5
 
 			;;
 		esac
@@ -4585,13 +4735,13 @@ echo "${as_me:-configure}:4580: testing given option \"$cf_option\",no match \"$
 	rm -f cf_makeflags.tmp
 
 fi
-echo "$as_me:4588: result: $cf_cv_makeflags" >&5
+echo "$as_me:4738: result: $cf_cv_makeflags" >&5
 echo "${ECHO_T}$cf_cv_makeflags" >&6
 
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
 set dummy ${ac_tool_prefix}ranlib; ac_word=$2
-echo "$as_me:4594: checking for $ac_word" >&5
+echo "$as_me:4744: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_RANLIB+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -4606,7 +4756,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
-echo "$as_me:4609: found $ac_dir/$ac_word" >&5
+echo "$as_me:4759: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -4614,10 +4764,10 @@ fi
 fi
 RANLIB=$ac_cv_prog_RANLIB
 if test -n "$RANLIB"; then
-  echo "$as_me:4617: result: $RANLIB" >&5
+  echo "$as_me:4767: result: $RANLIB" >&5
 echo "${ECHO_T}$RANLIB" >&6
 else
-  echo "$as_me:4620: result: no" >&5
+  echo "$as_me:4770: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -4626,7 +4776,7 @@ if test -z "$ac_cv_prog_RANLIB"; then
   ac_ct_RANLIB=$RANLIB
   # Extract the first word of "ranlib", so it can be a program name with args.
 set dummy ranlib; ac_word=$2
-echo "$as_me:4629: checking for $ac_word" >&5
+echo "$as_me:4779: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -4641,7 +4791,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_ac_ct_RANLIB="ranlib"
-echo "$as_me:4644: found $ac_dir/$ac_word" >&5
+echo "$as_me:4794: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -4650,10 +4800,10 @@ fi
 fi
 ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
 if test -n "$ac_ct_RANLIB"; then
-  echo "$as_me:4653: result: $ac_ct_RANLIB" >&5
+  echo "$as_me:4803: result: $ac_ct_RANLIB" >&5
 echo "${ECHO_T}$ac_ct_RANLIB" >&6
 else
-  echo "$as_me:4656: result: no" >&5
+  echo "$as_me:4806: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -4665,7 +4815,7 @@ fi
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}ld", so it can be a program name with args.
 set dummy ${ac_tool_prefix}ld; ac_word=$2
-echo "$as_me:4668: checking for $ac_word" >&5
+echo "$as_me:4818: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_LD+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -4680,7 +4830,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_LD="${ac_tool_prefix}ld"
-echo "$as_me:4683: found $ac_dir/$ac_word" >&5
+echo "$as_me:4833: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -4688,10 +4838,10 @@ fi
 fi
 LD=$ac_cv_prog_LD
 if test -n "$LD"; then
-  echo "$as_me:4691: result: $LD" >&5
+  echo "$as_me:4841: result: $LD" >&5
 echo "${ECHO_T}$LD" >&6
 else
-  echo "$as_me:4694: result: no" >&5
+  echo "$as_me:4844: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -4700,7 +4850,7 @@ if test -z "$ac_cv_prog_LD"; then
   ac_ct_LD=$LD
   # Extract the first word of "ld", so it can be a program name with args.
 set dummy ld; ac_word=$2
-echo "$as_me:4703: checking for $ac_word" >&5
+echo "$as_me:4853: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ac_ct_LD+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -4715,7 +4865,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_ac_ct_LD="ld"
-echo "$as_me:4718: found $ac_dir/$ac_word" >&5
+echo "$as_me:4868: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -4724,10 +4874,10 @@ fi
 fi
 ac_ct_LD=$ac_cv_prog_ac_ct_LD
 if test -n "$ac_ct_LD"; then
-  echo "$as_me:4727: result: $ac_ct_LD" >&5
+  echo "$as_me:4877: result: $ac_ct_LD" >&5
 echo "${ECHO_T}$ac_ct_LD" >&6
 else
-  echo "$as_me:4730: result: no" >&5
+  echo "$as_me:4880: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -4739,7 +4889,7 @@ fi
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
 set dummy ${ac_tool_prefix}ar; ac_word=$2
-echo "$as_me:4742: checking for $ac_word" >&5
+echo "$as_me:4892: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_AR+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -4754,7 +4904,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_AR="${ac_tool_prefix}ar"
-echo "$as_me:4757: found $ac_dir/$ac_word" >&5
+echo "$as_me:4907: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -4762,10 +4912,10 @@ fi
 fi
 AR=$ac_cv_prog_AR
 if test -n "$AR"; then
-  echo "$as_me:4765: result: $AR" >&5
+  echo "$as_me:4915: result: $AR" >&5
 echo "${ECHO_T}$AR" >&6
 else
-  echo "$as_me:4768: result: no" >&5
+  echo "$as_me:4918: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -4774,7 +4924,7 @@ if test -z "$ac_cv_prog_AR"; then
   ac_ct_AR=$AR
   # Extract the first word of "ar", so it can be a program name with args.
 set dummy ar; ac_word=$2
-echo "$as_me:4777: checking for $ac_word" >&5
+echo "$as_me:4927: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ac_ct_AR+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -4789,7 +4939,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_ac_ct_AR="ar"
-echo "$as_me:4792: found $ac_dir/$ac_word" >&5
+echo "$as_me:4942: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -4798,10 +4948,10 @@ fi
 fi
 ac_ct_AR=$ac_cv_prog_ac_ct_AR
 if test -n "$ac_ct_AR"; then
-  echo "$as_me:4801: result: $ac_ct_AR" >&5
+  echo "$as_me:4951: result: $ac_ct_AR" >&5
 echo "${ECHO_T}$ac_ct_AR" >&6
 else
-  echo "$as_me:4804: result: no" >&5
+  echo "$as_me:4954: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -4813,7 +4963,7 @@ fi
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}nm", so it can be a program name with args.
 set dummy ${ac_tool_prefix}nm; ac_word=$2
-echo "$as_me:4816: checking for $ac_word" >&5
+echo "$as_me:4966: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_NM+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -4828,7 +4978,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_NM="${ac_tool_prefix}nm"
-echo "$as_me:4831: found $ac_dir/$ac_word" >&5
+echo "$as_me:4981: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -4836,10 +4986,10 @@ fi
 fi
 NM=$ac_cv_prog_NM
 if test -n "$NM"; then
-  echo "$as_me:4839: result: $NM" >&5
+  echo "$as_me:4989: result: $NM" >&5
 echo "${ECHO_T}$NM" >&6
 else
-  echo "$as_me:4842: result: no" >&5
+  echo "$as_me:4992: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -4848,7 +4998,7 @@ if test -z "$ac_cv_prog_NM"; then
   ac_ct_NM=$NM
   # Extract the first word of "nm", so it can be a program name with args.
 set dummy nm; ac_word=$2
-echo "$as_me:4851: checking for $ac_word" >&5
+echo "$as_me:5001: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ac_ct_NM+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -4863,7 +5013,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_ac_ct_NM="nm"
-echo "$as_me:4866: found $ac_dir/$ac_word" >&5
+echo "$as_me:5016: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -4872,10 +5022,10 @@ fi
 fi
 ac_ct_NM=$ac_cv_prog_ac_ct_NM
 if test -n "$ac_ct_NM"; then
-  echo "$as_me:4875: result: $ac_ct_NM" >&5
+  echo "$as_me:5025: result: $ac_ct_NM" >&5
 echo "${ECHO_T}$ac_ct_NM" >&6
 else
-  echo "$as_me:4878: result: no" >&5
+  echo "$as_me:5028: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -4887,7 +5037,7 @@ fi
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
 set dummy ${ac_tool_prefix}ar; ac_word=$2
-echo "$as_me:4890: checking for $ac_word" >&5
+echo "$as_me:5040: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_AR+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -4902,7 +5052,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_AR="${ac_tool_prefix}ar"
-echo "$as_me:4905: found $ac_dir/$ac_word" >&5
+echo "$as_me:5055: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -4910,10 +5060,10 @@ fi
 fi
 AR=$ac_cv_prog_AR
 if test -n "$AR"; then
-  echo "$as_me:4913: result: $AR" >&5
+  echo "$as_me:5063: result: $AR" >&5
 echo "${ECHO_T}$AR" >&6
 else
-  echo "$as_me:4916: result: no" >&5
+  echo "$as_me:5066: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -4922,7 +5072,7 @@ if test -z "$ac_cv_prog_AR"; then
   ac_ct_AR=$AR
   # Extract the first word of "ar", so it can be a program name with args.
 set dummy ar; ac_word=$2
-echo "$as_me:4925: checking for $ac_word" >&5
+echo "$as_me:5075: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ac_ct_AR+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -4937,7 +5087,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_ac_ct_AR="ar"
-echo "$as_me:4940: found $ac_dir/$ac_word" >&5
+echo "$as_me:5090: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -4946,10 +5096,10 @@ fi
 fi
 ac_ct_AR=$ac_cv_prog_ac_ct_AR
 if test -n "$ac_ct_AR"; then
-  echo "$as_me:4949: result: $ac_ct_AR" >&5
+  echo "$as_me:5099: result: $ac_ct_AR" >&5
 echo "${ECHO_T}$ac_ct_AR" >&6
 else
-  echo "$as_me:4952: result: no" >&5
+  echo "$as_me:5102: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -4958,7 +5108,7 @@ else
   AR="$ac_cv_prog_AR"
 fi
 
-echo "$as_me:4961: checking for options to update archives" >&5
+echo "$as_me:5111: checking for options to update archives" >&5
 echo $ECHO_N "checking for options to update archives... $ECHO_C" >&6
 if test "${cf_cv_ar_flags+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -4995,13 +5145,13 @@ else
 			rm -f conftest.a
 
 			cat >"conftest.$ac_ext" <<EOF
-#line 4998 "configure"
+#line 5148 "configure"
 int	testdata[3] = { 123, 456, 789 };
 EOF
-			if { (eval echo "$as_me:5001: \"$ac_compile\"") >&5
+			if { (eval echo "$as_me:5151: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:5004: \$? = $ac_status" >&5
+  echo "$as_me:5154: \$? = $ac_status" >&5
   (exit "$ac_status"); } ; then
 				echo "$AR $ARFLAGS $cf_ar_flags conftest.a conftest.$ac_cv_objext" >&5
 				$AR $ARFLAGS "$cf_ar_flags" conftest.a "conftest.$ac_cv_objext" 2>&5 1>/dev/null
@@ -5012,7 +5162,7 @@ EOF
 			else
 				test -n "$verbose" && echo "	cannot compile test-program" 1>&6
 
-echo "${as_me:-configure}:5015: testing cannot compile test-program ..." 1>&5
+echo "${as_me:-configure}:5165: testing cannot compile test-program ..." 1>&5
 
 				break
 			fi
@@ -5022,7 +5172,7 @@ echo "${as_me:-configure}:5015: testing cannot compile test-program ..." 1>&5
 	esac
 
 fi
-echo "$as_me:5025: result: $cf_cv_ar_flags" >&5
+echo "$as_me:5175: result: $cf_cv_ar_flags" >&5
 echo "${ECHO_T}$cf_cv_ar_flags" >&6
 
 if test -n "$ARFLAGS" ; then
@@ -5033,8 +5183,8 @@ else
 	ARFLAGS=$cf_cv_ar_flags
 fi
 
-echo "$as_me:5036: checking if you have specified an install-prefix" >&5
-echo $ECHO_N "checking if you have specified an install-prefix... $ECHO_C" >&6
+echo "$as_me:5186: checking for an installation directory prefix" >&5
+echo $ECHO_N "checking for an installation directory prefix... $ECHO_C" >&6
 
 # Check whether --with-install-prefix or --without-install-prefix was given.
 if test "${with_install_prefix+set}" = set; then
@@ -5046,8 +5196,8 @@ if test "${with_install_prefix+set}" = set; then
 		;;
 	esac
 fi;
-echo "$as_me:5049: result: $DESTDIR" >&5
-echo "${ECHO_T}$DESTDIR" >&6
+echo "$as_me:5199: result: ${DESTDIR:-(none)}" >&5
+echo "${ECHO_T}${DESTDIR:-(none)}" >&6
 
 ###############################################################################
 
@@ -5081,7 +5231,7 @@ else
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:5084: checking for $ac_word" >&5
+echo "$as_me:5234: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_BUILD_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -5096,7 +5246,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_BUILD_CC="$ac_prog"
-echo "$as_me:5099: found $ac_dir/$ac_word" >&5
+echo "$as_me:5249: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -5104,10 +5254,10 @@ fi
 fi
 BUILD_CC=$ac_cv_prog_BUILD_CC
 if test -n "$BUILD_CC"; then
-  echo "$as_me:5107: result: $BUILD_CC" >&5
+  echo "$as_me:5257: result: $BUILD_CC" >&5
 echo "${ECHO_T}$BUILD_CC" >&6
 else
-  echo "$as_me:5110: result: no" >&5
+  echo "$as_me:5260: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -5116,12 +5266,12 @@ done
 test -n "$BUILD_CC" || BUILD_CC="none"
 
 fi;
-	echo "$as_me:5119: checking for native build C compiler" >&5
+	echo "$as_me:5269: checking for native build C compiler" >&5
 echo $ECHO_N "checking for native build C compiler... $ECHO_C" >&6
-	echo "$as_me:5121: result: $BUILD_CC" >&5
+	echo "$as_me:5271: result: $BUILD_CC" >&5
 echo "${ECHO_T}$BUILD_CC" >&6
 
-	echo "$as_me:5124: checking for native build C preprocessor" >&5
+	echo "$as_me:5274: checking for native build C preprocessor" >&5
 echo $ECHO_N "checking for native build C preprocessor... $ECHO_C" >&6
 
 # Check whether --with-build-cpp or --without-build-cpp was given.
@@ -5131,10 +5281,10 @@ if test "${with_build_cpp+set}" = set; then
 else
   BUILD_CPP='${BUILD_CC} -E'
 fi;
-	echo "$as_me:5134: result: $BUILD_CPP" >&5
+	echo "$as_me:5284: result: $BUILD_CPP" >&5
 echo "${ECHO_T}$BUILD_CPP" >&6
 
-	echo "$as_me:5137: checking for native build C flags" >&5
+	echo "$as_me:5287: checking for native build C flags" >&5
 echo $ECHO_N "checking for native build C flags... $ECHO_C" >&6
 
 # Check whether --with-build-cflags or --without-build-cflags was given.
@@ -5142,10 +5292,10 @@ if test "${with_build_cflags+set}" = set; then
   withval="$with_build_cflags"
   BUILD_CFLAGS="$withval"
 fi;
-	echo "$as_me:5145: result: $BUILD_CFLAGS" >&5
+	echo "$as_me:5295: result: $BUILD_CFLAGS" >&5
 echo "${ECHO_T}$BUILD_CFLAGS" >&6
 
-	echo "$as_me:5148: checking for native build C preprocessor-flags" >&5
+	echo "$as_me:5298: checking for native build C preprocessor-flags" >&5
 echo $ECHO_N "checking for native build C preprocessor-flags... $ECHO_C" >&6
 
 # Check whether --with-build-cppflags or --without-build-cppflags was given.
@@ -5153,10 +5303,10 @@ if test "${with_build_cppflags+set}" = set; then
   withval="$with_build_cppflags"
   BUILD_CPPFLAGS="$withval"
 fi;
-	echo "$as_me:5156: result: $BUILD_CPPFLAGS" >&5
+	echo "$as_me:5306: result: $BUILD_CPPFLAGS" >&5
 echo "${ECHO_T}$BUILD_CPPFLAGS" >&6
 
-	echo "$as_me:5159: checking for native build linker-flags" >&5
+	echo "$as_me:5309: checking for native build linker-flags" >&5
 echo $ECHO_N "checking for native build linker-flags... $ECHO_C" >&6
 
 # Check whether --with-build-ldflags or --without-build-ldflags was given.
@@ -5164,10 +5314,10 @@ if test "${with_build_ldflags+set}" = set; then
   withval="$with_build_ldflags"
   BUILD_LDFLAGS="$withval"
 fi;
-	echo "$as_me:5167: result: $BUILD_LDFLAGS" >&5
+	echo "$as_me:5317: result: $BUILD_LDFLAGS" >&5
 echo "${ECHO_T}$BUILD_LDFLAGS" >&6
 
-	echo "$as_me:5170: checking for native build linker-libraries" >&5
+	echo "$as_me:5320: checking for native build linker-libraries" >&5
 echo $ECHO_N "checking for native build linker-libraries... $ECHO_C" >&6
 
 # Check whether --with-build-libs or --without-build-libs was given.
@@ -5175,7 +5325,7 @@ if test "${with_build_libs+set}" = set; then
   withval="$with_build_libs"
   BUILD_LIBS="$withval"
 fi;
-	echo "$as_me:5178: result: $BUILD_LIBS" >&5
+	echo "$as_me:5328: result: $BUILD_LIBS" >&5
 echo "${ECHO_T}$BUILD_LIBS" >&6
 
 	# this assumes we're on Unix.
@@ -5184,8 +5334,59 @@ echo "${ECHO_T}$BUILD_LIBS" >&6
 
 	: ${BUILD_CC:='${CC}'}
 
-	if { test "$BUILD_CC" = "$CC" || test "$BUILD_CC" = '${CC}'; } ; then
-		{ { echo "$as_me:5188: error: Cross-build requires two compilers.
+	echo "$as_me:5337: checking if the build-compiler \"$BUILD_CC\" works" >&5
+echo $ECHO_N "checking if the build-compiler \"$BUILD_CC\" works... $ECHO_C" >&6
+
+	cf_save_crossed=$cross_compiling
+	cf_save_ac_link=$ac_link
+	cross_compiling=no
+	cf_build_cppflags=$BUILD_CPPFLAGS
+	test "$cf_build_cppflags" = "#" && cf_build_cppflags=
+	ac_link='$BUILD_CC -o "conftest$ac_exeext" $BUILD_CFLAGS $cf_build_cppflags $BUILD_LDFLAGS "conftest.$ac_ext" $BUILD_LIBS >&5'
+
+	if test "$cross_compiling" = yes; then
+  cf_ok_build_cc=unknown
+else
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 5351 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+		int main(int argc, char *argv[])
+		{
+			${cf_cv_main_return:-return}(argc < 0 || argv == 0 || argv[0] == 0);
+		}
+
+_ACEOF
+rm -f "conftest$ac_exeext"
+if { (eval echo "$as_me:5361: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:5364: \$? = $ac_status" >&5
+  (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
+  { (eval echo "$as_me:5366: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:5369: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  cf_ok_build_cc=yes
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+cf_ok_build_cc=no
+fi
+rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftest.$ac_ext"
+fi
+
+	cross_compiling=$cf_save_crossed
+	ac_link=$cf_save_ac_link
+
+	echo "$as_me:5384: result: $cf_ok_build_cc" >&5
+echo "${ECHO_T}$cf_ok_build_cc" >&6
+
+	if test "$cf_ok_build_cc" != yes
+	then
+		{ { echo "$as_me:5389: error: Cross-build requires two compilers.
 Use --with-build-cc to specify the native compiler." >&5
 echo "$as_me: error: Cross-build requires two compilers.
 Use --with-build-cc to specify the native compiler." >&2;}
@@ -5210,7 +5411,7 @@ fi
 ### shared, for example.
 cf_list_models=""
 
-echo "$as_me:5213: checking if libtool -version-number should be used" >&5
+echo "$as_me:5414: checking if libtool -version-number should be used" >&5
 echo $ECHO_N "checking if libtool -version-number should be used... $ECHO_C" >&6
 
 # Check whether --enable-libtool-version or --disable-libtool-version was given.
@@ -5227,7 +5428,7 @@ else
 	cf_libtool_version=yes
 
 fi;
-echo "$as_me:5230: result: $cf_libtool_version" >&5
+echo "$as_me:5431: result: $cf_libtool_version" >&5
 echo "${ECHO_T}$cf_libtool_version" >&6
 
 if test "$cf_libtool_version" = yes ; then
@@ -5236,25 +5437,25 @@ else
 	LIBTOOL_VERSION="-version-info"
 	case "x$VERSION" in
 	(x)
-		{ echo "$as_me:5239: WARNING: VERSION was not set" >&5
+		{ echo "$as_me:5440: WARNING: VERSION was not set" >&5
 echo "$as_me: WARNING: VERSION was not set" >&2;}
 		;;
 	(x*.*.*)
 		ABI_VERSION="$VERSION"
 		test -n "$verbose" && echo "	ABI_VERSION: $ABI_VERSION" 1>&6
 
-echo "${as_me:-configure}:5246: testing ABI_VERSION: $ABI_VERSION ..." 1>&5
+echo "${as_me:-configure}:5447: testing ABI_VERSION: $ABI_VERSION ..." 1>&5
 
 		;;
 	(x*:*:*)
 		ABI_VERSION=`echo "$VERSION" | sed -e 's/:/./g'`
 		test -n "$verbose" && echo "	ABI_VERSION: $ABI_VERSION" 1>&6
 
-echo "${as_me:-configure}:5253: testing ABI_VERSION: $ABI_VERSION ..." 1>&5
+echo "${as_me:-configure}:5454: testing ABI_VERSION: $ABI_VERSION ..." 1>&5
 
 		;;
 	(*)
-		{ echo "$as_me:5257: WARNING: unexpected VERSION value: $VERSION" >&5
+		{ echo "$as_me:5458: WARNING: unexpected VERSION value: $VERSION" >&5
 echo "$as_me: WARNING: unexpected VERSION value: $VERSION" >&2;}
 		;;
 	esac
@@ -5276,7 +5477,7 @@ LIB_LINK='${CC}'
 LIB_INSTALL=
 LIB_UNINSTALL=
 
-echo "$as_me:5279: checking if you want to build libraries with libtool" >&5
+echo "$as_me:5480: checking if you want to build libraries with libtool" >&5
 echo $ECHO_N "checking if you want to build libraries with libtool... $ECHO_C" >&6
 
 # Check whether --with-libtool or --without-libtool was given.
@@ -5286,7 +5487,7 @@ if test "${with_libtool+set}" = set; then
 else
   with_libtool=no
 fi;
-echo "$as_me:5289: result: $with_libtool" >&5
+echo "$as_me:5490: result: $with_libtool" >&5
 echo "${ECHO_T}$with_libtool" >&6
 if test "$with_libtool" != "no"; then
 
@@ -5317,7 +5518,7 @@ case ".$with_libtool" in
 	with_libtool=`echo "$with_libtool" | sed -e s%NONE%$cf_path_syntax%`
 	;;
 (*)
-	{ { echo "$as_me:5320: error: expected a pathname, not \"$with_libtool\"" >&5
+	{ { echo "$as_me:5521: error: expected a pathname, not \"$with_libtool\"" >&5
 echo "$as_me: error: expected a pathname, not \"$with_libtool\"" >&2;}
    { (exit 1); exit 1; }; }
 	;;
@@ -5330,7 +5531,7 @@ esac
   do
     # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:5333: checking for $ac_word" >&5
+echo "$as_me:5534: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_LIBTOOL+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -5345,7 +5546,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_LIBTOOL="$ac_tool_prefix$ac_prog"
-echo "$as_me:5348: found $ac_dir/$ac_word" >&5
+echo "$as_me:5549: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -5353,10 +5554,10 @@ fi
 fi
 LIBTOOL=$ac_cv_prog_LIBTOOL
 if test -n "$LIBTOOL"; then
-  echo "$as_me:5356: result: $LIBTOOL" >&5
+  echo "$as_me:5557: result: $LIBTOOL" >&5
 echo "${ECHO_T}$LIBTOOL" >&6
 else
-  echo "$as_me:5359: result: no" >&5
+  echo "$as_me:5560: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -5369,7 +5570,7 @@ if test -z "$LIBTOOL"; then
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:5372: checking for $ac_word" >&5
+echo "$as_me:5573: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ac_ct_LIBTOOL+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -5384,7 +5585,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_ac_ct_LIBTOOL="$ac_prog"
-echo "$as_me:5387: found $ac_dir/$ac_word" >&5
+echo "$as_me:5588: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -5392,10 +5593,10 @@ fi
 fi
 ac_ct_LIBTOOL=$ac_cv_prog_ac_ct_LIBTOOL
 if test -n "$ac_ct_LIBTOOL"; then
-  echo "$as_me:5395: result: $ac_ct_LIBTOOL" >&5
+  echo "$as_me:5596: result: $ac_ct_LIBTOOL" >&5
 echo "${ECHO_T}$ac_ct_LIBTOOL" >&6
 else
-  echo "$as_me:5398: result: no" >&5
+  echo "$as_me:5599: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -5426,7 +5627,7 @@ unset LIBTOOL
   do
     # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:5429: checking for $ac_word" >&5
+echo "$as_me:5630: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_LIBTOOL+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -5441,7 +5642,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_LIBTOOL="$ac_tool_prefix$ac_prog"
-echo "$as_me:5444: found $ac_dir/$ac_word" >&5
+echo "$as_me:5645: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -5449,10 +5650,10 @@ fi
 fi
 LIBTOOL=$ac_cv_prog_LIBTOOL
 if test -n "$LIBTOOL"; then
-  echo "$as_me:5452: result: $LIBTOOL" >&5
+  echo "$as_me:5653: result: $LIBTOOL" >&5
 echo "${ECHO_T}$LIBTOOL" >&6
 else
-  echo "$as_me:5455: result: no" >&5
+  echo "$as_me:5656: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -5465,7 +5666,7 @@ if test -z "$LIBTOOL"; then
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:5468: checking for $ac_word" >&5
+echo "$as_me:5669: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ac_ct_LIBTOOL+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -5480,7 +5681,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_ac_ct_LIBTOOL="$ac_prog"
-echo "$as_me:5483: found $ac_dir/$ac_word" >&5
+echo "$as_me:5684: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -5488,10 +5689,10 @@ fi
 fi
 ac_ct_LIBTOOL=$ac_cv_prog_ac_ct_LIBTOOL
 if test -n "$ac_ct_LIBTOOL"; then
-  echo "$as_me:5491: result: $ac_ct_LIBTOOL" >&5
+  echo "$as_me:5692: result: $ac_ct_LIBTOOL" >&5
 echo "${ECHO_T}$ac_ct_LIBTOOL" >&6
 else
-  echo "$as_me:5494: result: no" >&5
+  echo "$as_me:5695: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -5513,7 +5714,7 @@ test -z "$cf_cv_libtool_version" && unset cf_cv_libtool_version
 		fi
 	fi
 	if test -z "$LIBTOOL" ; then
-		{ { echo "$as_me:5516: error: Cannot find libtool" >&5
+		{ { echo "$as_me:5717: error: Cannot find libtool" >&5
 echo "$as_me: error: Cannot find libtool" >&2;}
    { (exit 1); exit 1; }; }
 	fi
@@ -5529,7 +5730,7 @@ echo "$as_me: error: Cannot find libtool" >&2;}
 
 if test -n "$LIBTOOL" && test "$LIBTOOL" != none
 then
-	echo "$as_me:5532: checking version of $LIBTOOL" >&5
+	echo "$as_me:5733: checking version of $LIBTOOL" >&5
 echo $ECHO_N "checking version of $LIBTOOL... $ECHO_C" >&6
 
 if test -n "$LIBTOOL" && test "$LIBTOOL" != none
@@ -5540,15 +5741,27 @@ else
 fi
 test -z "$cf_cv_libtool_version" && unset cf_cv_libtool_version
 
-	echo "$as_me:5543: result: $cf_cv_libtool_version" >&5
+	echo "$as_me:5744: result: $cf_cv_libtool_version" >&5
 echo "${ECHO_T}$cf_cv_libtool_version" >&6
-	if test -z "$cf_cv_libtool_version" ; then
-		{ { echo "$as_me:5546: error: This is not GNU libtool" >&5
+	if test -n "$cf_cv_libtool_version"
+	then
+		cf_check_libtool_version=`$LIBTOOL --version 2>&1 | sed -e '/^$/d' -e 's,[()],...,g' -e 's,[ ],-,g' -e '2,$d'`
+		case "x$cf_check_libtool_version" in
+		(*...GNU-libtool...*)
+			;;
+		(*)
+			{ { echo "$as_me:5753: error: This is not GNU libtool" >&5
 echo "$as_me: error: This is not GNU libtool" >&2;}
+   { (exit 1); exit 1; }; }
+			;;
+		esac
+	else
+		{ { echo "$as_me:5759: error: No version found for $LIBTOOL" >&5
+echo "$as_me: error: No version found for $LIBTOOL" >&2;}
    { (exit 1); exit 1; }; }
 	fi
 else
-	{ { echo "$as_me:5551: error: GNU libtool has not been found" >&5
+	{ { echo "$as_me:5764: error: GNU libtool has not been found" >&5
 echo "$as_me: error: GNU libtool has not been found" >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -5584,7 +5797,7 @@ cf_list_models="$cf_list_models libtool"
 
 else
 
-echo "$as_me:5587: checking if you want to build shared libraries" >&5
+echo "$as_me:5800: checking if you want to build shared libraries" >&5
 echo $ECHO_N "checking if you want to build shared libraries... $ECHO_C" >&6
 
 # Check whether --with-shared or --without-shared was given.
@@ -5594,11 +5807,11 @@ if test "${with_shared+set}" = set; then
 else
   with_shared=no
 fi;
-echo "$as_me:5597: result: $with_shared" >&5
+echo "$as_me:5810: result: $with_shared" >&5
 echo "${ECHO_T}$with_shared" >&6
 test "x$with_shared" = "xyes" && cf_list_models="$cf_list_models shared"
 
-echo "$as_me:5601: checking if you want to build static libraries" >&5
+echo "$as_me:5814: checking if you want to build static libraries" >&5
 echo $ECHO_N "checking if you want to build static libraries... $ECHO_C" >&6
 
 # Check whether --with-normal or --without-normal was given.
@@ -5608,11 +5821,11 @@ if test "${with_normal+set}" = set; then
 else
   with_normal=yes
 fi;
-echo "$as_me:5611: result: $with_normal" >&5
+echo "$as_me:5824: result: $with_normal" >&5
 echo "${ECHO_T}$with_normal" >&6
 test "x$with_normal" = "xyes" && cf_list_models="$cf_list_models normal"
 
-echo "$as_me:5615: checking if you want to build debug libraries" >&5
+echo "$as_me:5828: checking if you want to build debug libraries" >&5
 echo $ECHO_N "checking if you want to build debug libraries... $ECHO_C" >&6
 
 # Check whether --with-debug or --without-debug was given.
@@ -5622,11 +5835,11 @@ if test "${with_debug+set}" = set; then
 else
   with_debug=yes
 fi;
-echo "$as_me:5625: result: $with_debug" >&5
+echo "$as_me:5838: result: $with_debug" >&5
 echo "${ECHO_T}$with_debug" >&6
 test "x$with_debug" = "xyes" && cf_list_models="$cf_list_models debug"
 
-echo "$as_me:5629: checking if you want to build profiling libraries" >&5
+echo "$as_me:5842: checking if you want to build profiling libraries" >&5
 echo $ECHO_N "checking if you want to build profiling libraries... $ECHO_C" >&6
 
 # Check whether --with-profile or --without-profile was given.
@@ -5636,7 +5849,7 @@ if test "${with_profile+set}" = set; then
 else
   with_profile=no
 fi;
-echo "$as_me:5639: result: $with_profile" >&5
+echo "$as_me:5852: result: $with_profile" >&5
 echo "${ECHO_T}$with_profile" >&6
 test "x$with_profile" = "xyes" && cf_list_models="$cf_list_models profile"
 
@@ -5644,7 +5857,7 @@ fi
 
 if test "X$cf_with_cxx_binding" != Xno; then
 if test "x$with_shared" = "xyes"; then
-echo "$as_me:5647: checking if you want to build C++ shared libraries" >&5
+echo "$as_me:5860: checking if you want to build C++ shared libraries" >&5
 echo $ECHO_N "checking if you want to build C++ shared libraries... $ECHO_C" >&6
 
 # Check whether --with-cxx-shared or --without-cxx-shared was given.
@@ -5654,26 +5867,26 @@ if test "${with_cxx_shared+set}" = set; then
 else
   with_shared_cxx=no
 fi;
-echo "$as_me:5657: result: $with_shared_cxx" >&5
+echo "$as_me:5870: result: $with_shared_cxx" >&5
 echo "${ECHO_T}$with_shared_cxx" >&6
 fi
 fi
 
 ###############################################################################
 
-echo "$as_me:5664: checking for specified models" >&5
+echo "$as_me:5877: checking for specified models" >&5
 echo $ECHO_N "checking for specified models... $ECHO_C" >&6
 test -z "$cf_list_models" && cf_list_models=normal
 test "$with_libtool" != "no" && cf_list_models=libtool
-echo "$as_me:5668: result: $cf_list_models" >&5
+echo "$as_me:5881: result: $cf_list_models" >&5
 echo "${ECHO_T}$cf_list_models" >&6
 
 ### Use the first model as the default, and save its suffix for use in building
 ### up test-applications.
-echo "$as_me:5673: checking for default model" >&5
+echo "$as_me:5886: checking for default model" >&5
 echo $ECHO_N "checking for default model... $ECHO_C" >&6
 DFT_LWR_MODEL=`echo "$cf_list_models" | $AWK '{print $1}'`
-echo "$as_me:5676: result: $DFT_LWR_MODEL" >&5
+echo "$as_me:5889: result: $DFT_LWR_MODEL" >&5
 echo "${ECHO_T}$DFT_LWR_MODEL" >&6
 
 DFT_UPR_MODEL=`echo "$DFT_LWR_MODEL" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
@@ -5687,7 +5900,7 @@ LIB_NAME=ncurses
 LIB_DIR=../lib
 LIB_2ND=../../lib
 
-echo "$as_me:5690: checking if you want to have a library-prefix" >&5
+echo "$as_me:5903: checking if you want to have a library-prefix" >&5
 echo $ECHO_N "checking if you want to have a library-prefix... $ECHO_C" >&6
 
 # Check whether --with-lib-prefix or --without-lib-prefix was given.
@@ -5697,7 +5910,7 @@ if test "${with_lib_prefix+set}" = set; then
 else
   with_lib_prefix=auto
 fi;
-echo "$as_me:5700: result: $with_lib_prefix" >&5
+echo "$as_me:5913: result: $with_lib_prefix" >&5
 echo "${ECHO_T}$with_lib_prefix" >&6
 
 if test "$with_lib_prefix" = auto
@@ -5728,104 +5941,498 @@ fi
 
 LIB_SUFFIX=
 
-	echo "$as_me:5731: checking for PATH separator" >&5
+	echo "$as_me:5944: checking for PATH separator" >&5
 echo $ECHO_N "checking for PATH separator... $ECHO_C" >&6
 	case "$cf_cv_system_name" in
 	(os2*)	PATH_SEPARATOR=';'  ;;
 	(*)	${PATH_SEPARATOR:=':'}  ;;
 	esac
 
-	echo "$as_me:5738: result: $PATH_SEPARATOR" >&5
+	echo "$as_me:5951: result: $PATH_SEPARATOR" >&5
 echo "${ECHO_T}$PATH_SEPARATOR" >&6
 
-###############################################################################
-
-echo "$as_me:5743: checking if you want to build a separate terminfo library" >&5
-echo $ECHO_N "checking if you want to build a separate terminfo library... $ECHO_C" >&6
+# headers needed for checks...
+echo "$as_me:5955: checking for ANSI C header files" >&5
+echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
+if test "${ac_cv_header_stdc+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 5961 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
 
-# Check whether --with-termlib or --without-termlib was given.
-if test "${with_termlib+set}" = set; then
-  withval="$with_termlib"
-  with_termlib=$withval
+_ACEOF
+if { (eval echo "$as_me:5969: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+  (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  $EGREP -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:5975: \$? = $ac_status" >&5
+  (exit "$ac_status"); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
 else
-  with_termlib=no
-fi;
-echo "$as_me:5753: result: $with_termlib" >&5
-echo "${ECHO_T}$with_termlib" >&6
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  ac_cv_header_stdc=yes
+else
+  echo "$as_me: failed program was:" >&5
+  cat "conftest.$ac_ext" >&5
+  ac_cv_header_stdc=no
+fi
+rm -f conftest.err "conftest.$ac_ext"
 
-echo "$as_me:5756: checking if you want to build a separate tic library" >&5
-echo $ECHO_N "checking if you want to build a separate tic library... $ECHO_C" >&6
+if test $ac_cv_header_stdc = yes; then
+  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 5997 "configure"
+#include "confdefs.h"
+#include <string.h>
 
-# Check whether --with-ticlib or --without-ticlib was given.
-if test "${with_ticlib+set}" = set; then
-  withval="$with_ticlib"
-  with_ticlib=$withval
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "memchr" >/dev/null 2>&1; then
+  :
 else
-  with_ticlib=no
-fi;
-echo "$as_me:5766: result: $with_ticlib" >&5
-echo "${ECHO_T}$with_ticlib" >&6
-
-if test X"$CC_G_OPT" = X"" ; then
-	CC_G_OPT='-g'
-	test -n "$GCC" && test "x${ac_cv_prog_cc_g}" != xyes && CC_G_OPT=''
+  ac_cv_header_stdc=no
 fi
+rm -rf conftest*
 
-if test X"$CXX_G_OPT" = X"" ; then
-	CXX_G_OPT='-g'
-	test -n "$GXX" && test "x${ac_cv_prog_cxx_g}" != xyes && CXX_G_OPT=''
 fi
 
-echo "$as_me:5779: checking for default loader flags" >&5
-echo $ECHO_N "checking for default loader flags... $ECHO_C" >&6
-case "$DFT_LWR_MODEL" in
-(libtool) LD_MODEL=''   ;;
-(normal)  LD_MODEL=''   ;;
-(debug)   LD_MODEL=$CC_G_OPT ;;
-(profile) LD_MODEL='-pg';;
-(shared)  LD_MODEL=''   ;;
-esac
-echo "$as_me:5788: result: $LD_MODEL" >&5
-echo "${ECHO_T}$LD_MODEL" >&6
-
-case "$DFT_LWR_MODEL" in
-(shared)
-
-echo "$as_me:5794: checking if rpath option should be used" >&5
-echo $ECHO_N "checking if rpath option should be used... $ECHO_C" >&6
+if test $ac_cv_header_stdc = yes; then
+  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 6015 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
 
-# Check whether --enable-rpath or --disable-rpath was given.
-if test "${enable_rpath+set}" = set; then
-  enableval="$enable_rpath"
-  cf_cv_enable_rpath=$enableval
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "free" >/dev/null 2>&1; then
+  :
 else
-  cf_cv_enable_rpath=no
-fi;
-echo "$as_me:5804: result: $cf_cv_enable_rpath" >&5
-echo "${ECHO_T}$cf_cv_enable_rpath" >&6
+  ac_cv_header_stdc=no
+fi
+rm -rf conftest*
 
-echo "$as_me:5807: checking if shared libraries should be relinked during install" >&5
-echo $ECHO_N "checking if shared libraries should be relinked during install... $ECHO_C" >&6
+fi
 
-# Check whether --enable-relink or --disable-relink was given.
-if test "${enable_relink+set}" = set; then
-  enableval="$enable_relink"
-  cf_cv_do_relink=$enableval
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+  if test "$cross_compiling" = yes; then
+  :
 else
-  cf_cv_do_relink=yes
-fi;
-echo "$as_me:5817: result: $cf_cv_do_relink" >&5
-echo "${ECHO_T}$cf_cv_do_relink" >&6
-	;;
-esac
-
-# we will build libraries one-level down.
-rel_builddir=..
-
-LD_RPATH_OPT=
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 6036 "configure"
+#include "confdefs.h"
+#include <ctype.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \
+                     || ('j' <= (c) && (c) <= 'r') \
+                     || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main (void)
+{
+  int i;
+  for (i = 0; i < 256; i++)
+    if (XOR (islower (i), ISLOWER (i))
+        || toupper (i) != TOUPPER (i))
+      $ac_main_return(2);
+  $ac_main_return (0);
+}
+_ACEOF
+rm -f "conftest$ac_exeext"
+if { (eval echo "$as_me:6062: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:6065: \$? = $ac_status" >&5
+  (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
+  { (eval echo "$as_me:6067: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6070: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  :
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+ac_cv_header_stdc=no
+fi
+rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftest.$ac_ext"
+fi
+fi
+fi
+echo "$as_me:6083: result: $ac_cv_header_stdc" >&5
+echo "${ECHO_T}$ac_cv_header_stdc" >&6
+if test $ac_cv_header_stdc = yes; then
+
+cat >>confdefs.h <<\EOF
+#define STDC_HEADERS 1
+EOF
+
+fi
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+                  inttypes.h stdint.h unistd.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:6099: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 6105 "configure"
+#include "confdefs.h"
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:6111: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:6114: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:6117: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6120: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+eval "$as_ac_Header=no"
+fi
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+fi
+echo "$as_me:6130: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
+echo "${ECHO_T}`eval echo '${'"$as_ac_Header"'}'`" >&6
+if test "`eval echo '${'"$as_ac_Header"'}'`" = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+EOF
+
+fi
+done
+
+echo "$as_me:6140: checking whether exit is declared" >&5
+echo $ECHO_N "checking whether exit is declared... $ECHO_C" >&6
+if test "${ac_cv_have_decl_exit+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 6146 "configure"
+#include "confdefs.h"
+$ac_includes_default
+int
+main (void)
+{
+#ifndef exit
+  (void) exit;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:6161: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:6164: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:6167: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6170: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  ac_cv_have_decl_exit=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+ac_cv_have_decl_exit=no
+fi
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+fi
+echo "$as_me:6180: result: $ac_cv_have_decl_exit" >&5
+echo "${ECHO_T}$ac_cv_have_decl_exit" >&6
+
+ac_header_dirent=no
+for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
+  as_ac_Header=`echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh`
+echo "$as_me:6186: checking for $ac_hdr that defines DIR" >&5
+echo $ECHO_N "checking for $ac_hdr that defines DIR... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 6192 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <$ac_hdr>
+
+int
+main (void)
+{
+if ((DIR *) 0)
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:6207: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:6210: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:6213: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6216: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+eval "$as_ac_Header=no"
+fi
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+fi
+echo "$as_me:6226: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
+echo "${ECHO_T}`eval echo '${'"$as_ac_Header"'}'`" >&6
+if test "`eval echo '${'"$as_ac_Header"'}'`" = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_hdr" | $as_tr_cpp` 1
+EOF
+
+ac_header_dirent=$ac_hdr; break
+fi
+
+done
+# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
+if test $ac_header_dirent = dirent.h; then
+  echo "$as_me:6239: checking for opendir in -ldir" >&5
+echo $ECHO_N "checking for opendir in -ldir... $ECHO_C" >&6
+if test "${ac_cv_lib_dir_opendir+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldir  $LIBS"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 6247 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char opendir (void);
+int
+main (void)
+{
+opendir ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:6266: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:6269: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:6272: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6275: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  ac_cv_lib_dir_opendir=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+ac_cv_lib_dir_opendir=no
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:6286: result: $ac_cv_lib_dir_opendir" >&5
+echo "${ECHO_T}$ac_cv_lib_dir_opendir" >&6
+if test "$ac_cv_lib_dir_opendir" = yes; then
+  LIBS="$LIBS -ldir"
+fi
+
+else
+  echo "$as_me:6293: checking for opendir in -lx" >&5
+echo $ECHO_N "checking for opendir in -lx... $ECHO_C" >&6
+if test "${ac_cv_lib_x_opendir+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lx  $LIBS"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 6301 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char opendir (void);
+int
+main (void)
+{
+opendir ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:6320: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:6323: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:6326: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6329: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  ac_cv_lib_x_opendir=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+ac_cv_lib_x_opendir=no
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:6340: result: $ac_cv_lib_x_opendir" >&5
+echo "${ECHO_T}$ac_cv_lib_x_opendir" >&6
+if test "$ac_cv_lib_x_opendir" = yes; then
+  LIBS="$LIBS -lx"
+fi
+
+fi
+
+###############################################################################
+
+echo "$as_me:6350: checking if you want to build a separate terminfo library" >&5
+echo $ECHO_N "checking if you want to build a separate terminfo library... $ECHO_C" >&6
+
+# Check whether --with-termlib or --without-termlib was given.
+if test "${with_termlib+set}" = set; then
+  withval="$with_termlib"
+  with_termlib=$withval
+else
+  with_termlib=no
+fi;
+echo "$as_me:6360: result: $with_termlib" >&5
+echo "${ECHO_T}$with_termlib" >&6
+
+echo "$as_me:6363: checking if you want to build a separate tic library" >&5
+echo $ECHO_N "checking if you want to build a separate tic library... $ECHO_C" >&6
+
+# Check whether --with-ticlib or --without-ticlib was given.
+if test "${with_ticlib+set}" = set; then
+  withval="$with_ticlib"
+  with_ticlib=$withval
+else
+  with_ticlib=no
+fi;
+echo "$as_me:6373: result: $with_ticlib" >&5
+echo "${ECHO_T}$with_ticlib" >&6
+
+if test X"$CC_G_OPT" = X"" ; then
+	CC_G_OPT='-g'
+	test -n "$GCC" && test "x${ac_cv_prog_cc_g}" != xyes && CC_G_OPT=''
+fi
+
+if test X"$CXX_G_OPT" = X"" ; then
+	CXX_G_OPT='-g'
+	test -n "$GXX" && test "x${ac_cv_prog_cxx_g}" != xyes && CXX_G_OPT=''
+fi
+
+echo "$as_me:6386: checking for default loader flags" >&5
+echo $ECHO_N "checking for default loader flags... $ECHO_C" >&6
+case "$DFT_LWR_MODEL" in
+(libtool) LD_MODEL=''   ;;
+(normal)  LD_MODEL=''   ;;
+(debug)   LD_MODEL=$CC_G_OPT ;;
+(profile) LD_MODEL='-pg';;
+(shared)  LD_MODEL=''   ;;
+esac
+echo "$as_me:6395: result: ${LD_MODEL:-(none)}" >&5
+echo "${ECHO_T}${LD_MODEL:-(none)}" >&6
+
+case "$DFT_LWR_MODEL" in
+(shared)
+
+echo "$as_me:6401: checking if rpath option should be used" >&5
+echo $ECHO_N "checking if rpath option should be used... $ECHO_C" >&6
+
+# Check whether --enable-rpath or --disable-rpath was given.
+if test "${enable_rpath+set}" = set; then
+  enableval="$enable_rpath"
+  cf_cv_enable_rpath=$enableval
+else
+  cf_cv_enable_rpath=no
+fi;
+echo "$as_me:6411: result: $cf_cv_enable_rpath" >&5
+echo "${ECHO_T}$cf_cv_enable_rpath" >&6
+
+echo "$as_me:6414: checking if shared libraries should be relinked during install" >&5
+echo $ECHO_N "checking if shared libraries should be relinked during install... $ECHO_C" >&6
+
+# Check whether --enable-relink or --disable-relink was given.
+if test "${enable_relink+set}" = set; then
+  enableval="$enable_relink"
+  cf_cv_do_relink=$enableval
+else
+  cf_cv_do_relink=yes
+fi;
+echo "$as_me:6424: result: $cf_cv_do_relink" >&5
+echo "${ECHO_T}$cf_cv_do_relink" >&6
+	;;
+esac
+
+# we will build libraries one-level down.
+rel_builddir=..
+
+LD_RPATH_OPT=
 if test "x$cf_cv_enable_rpath" != xno
 then
-	echo "$as_me:5828: checking for an rpath option" >&5
+	echo "$as_me:6435: checking for an rpath option" >&5
 echo $ECHO_N "checking for an rpath option... $ECHO_C" >&6
 	case "$cf_cv_system_name" in
 	(irix*)
@@ -5856,12 +6463,12 @@ echo $ECHO_N "checking for an rpath option... $ECHO_C" >&6
 	(*)
 		;;
 	esac
-	echo "$as_me:5859: result: $LD_RPATH_OPT" >&5
+	echo "$as_me:6466: result: $LD_RPATH_OPT" >&5
 echo "${ECHO_T}$LD_RPATH_OPT" >&6
 
 	case "x$LD_RPATH_OPT" in
 	(x-R*)
-		echo "$as_me:5864: checking if we need a space after rpath option" >&5
+		echo "$as_me:6471: checking if we need a space after rpath option" >&5
 echo $ECHO_N "checking if we need a space after rpath option... $ECHO_C" >&6
 		cf_save_LIBS="$LIBS"
 
@@ -5882,7 +6489,7 @@ done
 LIBS="$cf_add_libs"
 
 		cat >"conftest.$ac_ext" <<_ACEOF
-#line 5885 "configure"
+#line 6492 "configure"
 #include "confdefs.h"
 
 int
@@ -5894,16 +6501,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:5897: \"$ac_link\"") >&5
+if { (eval echo "$as_me:6504: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:5900: \$? = $ac_status" >&5
+  echo "$as_me:6507: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:5903: \"$ac_try\"") >&5
+  { (eval echo "$as_me:6510: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:5906: \$? = $ac_status" >&5
+  echo "$as_me:6513: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_rpath_space=no
 else
@@ -5913,7 +6520,7 @@ cf_rpath_space=yes
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 		LIBS="$cf_save_LIBS"
-		echo "$as_me:5916: result: $cf_rpath_space" >&5
+		echo "$as_me:6523: result: $cf_rpath_space" >&5
 echo "${ECHO_T}$cf_rpath_space" >&6
 		test "$cf_rpath_space" = yes && LD_RPATH_OPT="$LD_RPATH_OPT "
 		;;
@@ -5935,8 +6542,8 @@ fi
 	cf_ld_rpath_opt=
 	test "$cf_cv_enable_rpath" = yes && cf_ld_rpath_opt="$LD_RPATH_OPT"
 
-	echo "$as_me:5938: checking if release/abi version should be used for shared libs" >&5
-echo $ECHO_N "checking if release/abi version should be used for shared libs... $ECHO_C" >&6
+	echo "$as_me:6545: checking whether to use release or ABI version in shared library file names" >&5
+echo $ECHO_N "checking whether to use release or ABI version in shared library file names... $ECHO_C" >&6
 
 # Check whether --with-shlib-version or --without-shlib-version was given.
 if test "${with_shlib_version+set}" = set; then
@@ -5950,9 +6557,9 @@ if test "${with_shlib_version+set}" = set; then
 		cf_cv_shlib_version=$withval
 		;;
 	(*)
-		echo "$as_me:5953: result: $withval" >&5
+		echo "$as_me:6560: result: $withval" >&5
 echo "${ECHO_T}$withval" >&6
-		{ { echo "$as_me:5955: error: option value must be one of: rel, abi, or auto" >&5
+		{ { echo "$as_me:6562: error: option value must be one of: rel, abi, or auto" >&5
 echo "$as_me: error: option value must be one of: rel, abi, or auto" >&2;}
    { (exit 1); exit 1; }; }
 		;;
@@ -5961,7 +6568,7 @@ echo "$as_me: error: option value must be one of: rel, abi, or auto" >&2;}
 else
   cf_cv_shlib_version=auto
 fi;
-	echo "$as_me:5964: result: $cf_cv_shlib_version" >&5
+	echo "$as_me:6571: result: $cf_cv_shlib_version" >&5
 echo "${ECHO_T}$cf_cv_shlib_version" >&6
 
 	cf_cv_rm_so_locs=no
@@ -5984,35 +6591,35 @@ echo "${ECHO_T}$cf_cv_shlib_version" >&6
 
 	if test "$cf_try_fPIC" = yes
 	then
-		echo "$as_me:5987: checking which $CC option to use" >&5
+		echo "$as_me:6594: checking which $CC option to use" >&5
 echo $ECHO_N "checking which $CC option to use... $ECHO_C" >&6
 		cf_save_CFLAGS="$CFLAGS"
 		for CC_SHARED_OPTS in -fPIC -fpic ''
 		do
 			CFLAGS="$cf_save_CFLAGS $CC_SHARED_OPTS"
 			cat >"conftest.$ac_ext" <<_ACEOF
-#line 5994 "configure"
+#line 6601 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int
 main (void)
 {
-int x = 1
+int x = 1; (void)x
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:6006: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:6613: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:6009: \$? = $ac_status" >&5
+  echo "$as_me:6616: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:6012: \"$ac_try\"") >&5
+  { (eval echo "$as_me:6619: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:6015: \$? = $ac_status" >&5
+  echo "$as_me:6622: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   break
 else
@@ -6021,7 +6628,7 @@ cat "conftest.$ac_ext" >&5
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 		done
-		echo "$as_me:6024: result: $CC_SHARED_OPTS" >&5
+		echo "$as_me:6631: result: $CC_SHARED_OPTS" >&5
 echo "${ECHO_T}$CC_SHARED_OPTS" >&6
 		CFLAGS="$cf_save_CFLAGS"
 	fi
@@ -6092,7 +6699,7 @@ CF_EOF
 		MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -dynamiclib -install_name ${libdir}/`basename $@` -compatibility_version ${ABI_VERSION} -current_version ${ABI_VERSION} -o $@'
 		test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=abi
 		cf_cv_shlib_version_infix=yes
-		echo "$as_me:6095: checking if ld -search_paths_first works" >&5
+		echo "$as_me:6702: checking if ld -search_paths_first works" >&5
 echo $ECHO_N "checking if ld -search_paths_first works... $ECHO_C" >&6
 if test "${cf_cv_ldflags_search_paths_first+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -6101,7 +6708,7 @@ else
 			cf_save_LDFLAGS=$LDFLAGS
 			LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
 			cat >"conftest.$ac_ext" <<_ACEOF
-#line 6104 "configure"
+#line 6711 "configure"
 #include "confdefs.h"
 
 int
@@ -6113,16 +6720,16 @@ int i;
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:6116: \"$ac_link\"") >&5
+if { (eval echo "$as_me:6723: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:6119: \$? = $ac_status" >&5
+  echo "$as_me:6726: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:6122: \"$ac_try\"") >&5
+  { (eval echo "$as_me:6729: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:6125: \$? = $ac_status" >&5
+  echo "$as_me:6732: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_ldflags_search_paths_first=yes
 else
@@ -6133,12 +6740,23 @@ fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 				LDFLAGS=$cf_save_LDFLAGS
 fi
-echo "$as_me:6136: result: $cf_cv_ldflags_search_paths_first" >&5
+echo "$as_me:6743: result: $cf_cv_ldflags_search_paths_first" >&5
 echo "${ECHO_T}$cf_cv_ldflags_search_paths_first" >&6
 		if test "$cf_cv_ldflags_search_paths_first" = yes; then
 			LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
 		fi
 		;;
+	(haiku*)
+
+	test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
+	if test "$cf_cv_shlib_version" = rel; then
+		cf_cv_shared_soname='`basename $@ .${REL_VERSION}`.${ABI_VERSION}'
+	else
+		cf_cv_shared_soname='`basename $@`'
+	fi
+
+		MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname',-stats,-lc -o $@'
+		;;
 	(hpux[7-8]*)
 		# HP-UX 8.07 ld lacks "+b" option used for libdir search-list
 		if test "$GCC" != yes; then
@@ -6452,11 +7070,11 @@ CF_EOF
 		# tested with SunOS 5.5.1 (solaris 2.5.1) and gcc 2.7.2
 		# tested with SunOS 5.10 (solaris 10) and gcc 3.4.3
 		if test "$DFT_LWR_MODEL" = "shared" ; then
-			LOCAL_LDFLAGS="-R \$(LOCAL_LIBDIR):\${libdir}"
+			LOCAL_LDFLAGS="-R\$(LOCAL_LIBDIR):\${libdir}"
 			LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
 		fi
 		if test "$cf_cv_enable_rpath" = yes ; then
-			EXTRA_LDFLAGS="-R \${libdir} $EXTRA_LDFLAGS"
+			EXTRA_LDFLAGS="-R\${libdir} $EXTRA_LDFLAGS"
 		fi
 
 	test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
@@ -6472,7 +7090,7 @@ CF_EOF
 			do
 				CFLAGS="$cf_shared_opts $cf_save_CFLAGS"
 				cat >"conftest.$ac_ext" <<_ACEOF
-#line 6475 "configure"
+#line 7093 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int
@@ -6484,16 +7102,16 @@ printf("Hello\\n");
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:6487: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:7105: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:6490: \$? = $ac_status" >&5
+  echo "$as_me:7108: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:6493: \"$ac_try\"") >&5
+  { (eval echo "$as_me:7111: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:6496: \$? = $ac_status" >&5
+  echo "$as_me:7114: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   break
 else
@@ -6504,9 +7122,9 @@ rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 			done
 			CFLAGS="$cf_save_CFLAGS"
 			CC_SHARED_OPTS=$cf_shared_opts
-			MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -dy -G -h '$cf_cv_shared_soname' -o $@'
+			MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -dy -G -Wl,-h,'$cf_cv_shared_soname' -o $@'
 		else
-			MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -dy -G -h '$cf_cv_shared_soname' -o $@'
+			MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -dy -G -Wl,-h,'$cf_cv_shared_soname' -o $@'
 		fi
 		;;
 	(sysv5uw7*|unix_sv*)
@@ -6530,7 +7148,7 @@ rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 			test "$cf_cv_do_symlinks" = no && cf_cv_do_symlinks=yes
 			;;
 		(*)
-			{ echo "$as_me:6533: WARNING: ignored --with-shlib-version" >&5
+			{ echo "$as_me:7151: WARNING: ignored --with-shlib-version" >&5
 echo "$as_me: WARNING: ignored --with-shlib-version" >&2;}
 			;;
 		esac
@@ -6540,7 +7158,7 @@ echo "$as_me: WARNING: ignored --with-shlib-version" >&2;}
 	if test -n "$cf_try_cflags"
 	then
 cat > conftest.$ac_ext <<EOF
-#line 6543 "${as_me:-configure}"
+#line 7161 "${as_me:-configure}"
 #include <stdio.h>
 int main(int argc, char *argv[])
 {
@@ -6552,18 +7170,18 @@ EOF
 		for cf_opt in $cf_try_cflags
 		do
 			CFLAGS="$cf_save_CFLAGS -$cf_opt"
-			echo "$as_me:6555: checking if CFLAGS option -$cf_opt works" >&5
+			echo "$as_me:7173: checking if CFLAGS option -$cf_opt works" >&5
 echo $ECHO_N "checking if CFLAGS option -$cf_opt works... $ECHO_C" >&6
-			if { (eval echo "$as_me:6557: \"$ac_compile\"") >&5
+			if { (eval echo "$as_me:7175: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:6560: \$? = $ac_status" >&5
+  echo "$as_me:7178: \$? = $ac_status" >&5
   (exit "$ac_status"); }; then
-				echo "$as_me:6562: result: yes" >&5
+				echo "$as_me:7180: result: yes" >&5
 echo "${ECHO_T}yes" >&6
 				cf_save_CFLAGS="$CFLAGS"
 			else
-				echo "$as_me:6566: result: no" >&5
+				echo "$as_me:7184: result: no" >&5
 echo "${ECHO_T}no" >&6
 			fi
 		done
@@ -6578,17 +7196,17 @@ echo "${ECHO_T}no" >&6
 
 	test -n "$verbose" && echo "	CC_SHARED_OPTS: $CC_SHARED_OPTS" 1>&6
 
-echo "${as_me:-configure}:6581: testing CC_SHARED_OPTS: $CC_SHARED_OPTS ..." 1>&5
+echo "${as_me:-configure}:7199: testing CC_SHARED_OPTS: $CC_SHARED_OPTS ..." 1>&5
 
 	test -n "$verbose" && echo "	MK_SHARED_LIB:  $MK_SHARED_LIB" 1>&6
 
-echo "${as_me:-configure}:6585: testing MK_SHARED_LIB:  $MK_SHARED_LIB ..." 1>&5
+echo "${as_me:-configure}:7203: testing MK_SHARED_LIB:  $MK_SHARED_LIB ..." 1>&5
 
 for model in $cf_list_models ; do
 	case "$model" in
 	(libtool)
 
-echo "$as_me:6591: checking for additional libtool options" >&5
+echo "$as_me:7209: checking for additional libtool options" >&5
 echo $ECHO_N "checking for additional libtool options... $ECHO_C" >&6
 
 # Check whether --with-libtool-opts or --without-libtool-opts was given.
@@ -6598,7 +7216,7 @@ if test "${with_libtool_opts+set}" = set; then
 else
   with_libtool_opts=no
 fi;
-echo "$as_me:6601: result: $with_libtool_opts" >&5
+echo "$as_me:7219: result: $with_libtool_opts" >&5
 echo "${ECHO_T}$with_libtool_opts" >&6
 
 case .$with_libtool_opts in
@@ -6609,7 +7227,7 @@ case .$with_libtool_opts in
 	;;
 esac
 
-echo "$as_me:6612: checking if exported-symbols file should be used" >&5
+echo "$as_me:7230: checking if exported-symbols file should be used" >&5
 echo $ECHO_N "checking if exported-symbols file should be used... $ECHO_C" >&6
 
 # Check whether --with-export-syms or --without-export-syms was given.
@@ -6624,7 +7242,7 @@ then
 	with_export_syms='${top_srcdir}/package/${PACKAGE}.sym'
 
 fi
-echo "$as_me:6627: result: $with_export_syms" >&5
+echo "$as_me:7245: result: $with_export_syms" >&5
 echo "${ECHO_T}$with_export_syms" >&6
 if test "x$with_export_syms" != xno
 then
@@ -6635,15 +7253,15 @@ fi
 		;;
 	(shared)
 		if test "$CC_SHARED_OPTS" = "unknown"; then
-			{ { echo "$as_me:6638: error: Shared libraries are not supported in this version" >&5
+			{ { echo "$as_me:7256: error: Shared libraries are not supported in this version" >&5
 echo "$as_me: error: Shared libraries are not supported in this version" >&2;}
    { (exit 1); exit 1; }; }
 		fi
 		# workaround for inept transition to PIE vs PIC...
-		echo "$as_me:6643: checking if current CFLAGS link properly" >&5
+		echo "$as_me:7261: checking if current CFLAGS link properly" >&5
 echo $ECHO_N "checking if current CFLAGS link properly... $ECHO_C" >&6
 		cat >"conftest.$ac_ext" <<_ACEOF
-#line 6646 "configure"
+#line 7264 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int
@@ -6655,16 +7273,16 @@ printf("Hello work\\n");
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:6658: \"$ac_link\"") >&5
+if { (eval echo "$as_me:7276: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:6661: \$? = $ac_status" >&5
+  echo "$as_me:7279: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:6664: \"$ac_try\"") >&5
+  { (eval echo "$as_me:7282: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:6667: \$? = $ac_status" >&5
+  echo "$as_me:7285: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cflags_work=yes
 else
@@ -6673,18 +7291,18 @@ cat "conftest.$ac_ext" >&5
 cf_cflags_work=no
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
-		echo "$as_me:6676: result: $cf_cflags_work" >&5
+		echo "$as_me:7294: result: $cf_cflags_work" >&5
 echo "${ECHO_T}$cf_cflags_work" >&6
 		if test "$cf_cflags_work" = no
 		then
 			test -n "$verbose" && echo "	try to work around by appending shared-options" 1>&6
 
-echo "${as_me:-configure}:6682: testing try to work around by appending shared-options ..." 1>&5
+echo "${as_me:-configure}:7300: testing try to work around by appending shared-options ..." 1>&5
 
 			CFLAGS="$CFLAGS $CC_SHARED_OPTS"
 		fi
 
-echo "$as_me:6687: checking if versioned-symbols file should be used" >&5
+echo "$as_me:7305: checking if versioned-symbols file should be used" >&5
 echo $ECHO_N "checking if versioned-symbols file should be used... $ECHO_C" >&6
 
 # Check whether --with-versioned-syms or --without-versioned-syms was given.
@@ -6702,18 +7320,18 @@ case "x$with_versioned_syms" in
 (xno)
 	;;
 (x/*)
-	test -f "$with_versioned_syms" || { { echo "$as_me:6705: error: expected a filename: $with_versioned_syms" >&5
+	test -f "$with_versioned_syms" || { { echo "$as_me:7323: error: expected a filename: $with_versioned_syms" >&5
 echo "$as_me: error: expected a filename: $with_versioned_syms" >&2;}
    { (exit 1); exit 1; }; }
 	;;
 (*)
-	test -f "$with_versioned_syms" || { { echo "$as_me:6710: error: expected a filename: $with_versioned_syms" >&5
+	test -f "$with_versioned_syms" || { { echo "$as_me:7328: error: expected a filename: $with_versioned_syms" >&5
 echo "$as_me: error: expected a filename: $with_versioned_syms" >&2;}
    { (exit 1); exit 1; }; }
 	with_versioned_syms=`pwd`/"$with_versioned_syms"
 	;;
 esac
-echo "$as_me:6716: result: $with_versioned_syms" >&5
+echo "$as_me:7334: result: $with_versioned_syms" >&5
 echo "${ECHO_T}$with_versioned_syms" >&6
 
 RESULTING_SYMS=
@@ -6729,7 +7347,7 @@ then
 		MK_SHARED_LIB=`echo "$MK_SHARED_LIB" | sed -e "s%-Wl,%\\${VERSIONED_SYMS} -Wl,%"`
 		test -n "$verbose" && echo "	MK_SHARED_LIB:  $MK_SHARED_LIB" 1>&6
 
-echo "${as_me:-configure}:6732: testing MK_SHARED_LIB:  $MK_SHARED_LIB ..." 1>&5
+echo "${as_me:-configure}:7350: testing MK_SHARED_LIB:  $MK_SHARED_LIB ..." 1>&5
 
 		;;
 	(*-dy\ *)
@@ -6737,11 +7355,11 @@ echo "${as_me:-configure}:6732: testing MK_SHARED_LIB:  $MK_SHARED_LIB ..." 1>&5
 		MK_SHARED_LIB=`echo "$MK_SHARED_LIB" | sed -e "s%-dy%\\${VERSIONED_SYMS} -dy%"`
 		test -n "$verbose" && echo "	MK_SHARED_LIB:  $MK_SHARED_LIB" 1>&6
 
-echo "${as_me:-configure}:6740: testing MK_SHARED_LIB:  $MK_SHARED_LIB ..." 1>&5
+echo "${as_me:-configure}:7358: testing MK_SHARED_LIB:  $MK_SHARED_LIB ..." 1>&5
 
 		;;
 	(*)
-		{ echo "$as_me:6744: WARNING: this system does not support versioned-symbols" >&5
+		{ echo "$as_me:7362: WARNING: this system does not support versioned-symbols" >&5
 echo "$as_me: WARNING: this system does not support versioned-symbols" >&2;}
 		;;
 	esac
@@ -6753,7 +7371,7 @@ echo "$as_me: WARNING: this system does not support versioned-symbols" >&2;}
 	# symbols.
 	if test "x$VERSIONED_SYMS" != "x"
 	then
-		echo "$as_me:6756: checking if wildcards can be used to selectively omit symbols" >&5
+		echo "$as_me:7374: checking if wildcards can be used to selectively omit symbols" >&5
 echo $ECHO_N "checking if wildcards can be used to selectively omit symbols... $ECHO_C" >&6
 		WILDCARD_SYMS=no
 
@@ -6790,16 +7408,16 @@ local:
 } submodule_1.0;
 EOF
 		cat >conftest.$ac_ext <<EOF
-#line 6793 "configure"
-int	_ismissing(void) { return 1; }
-int	_localf1(void) { return 1; }
-int	_localf2(void) { return 2; }
-int	globalf1(void) { return 1; }
-int	globalf2(void) { return 2; }
-int	_sublocalf1(void) { return 1; }
-int	_sublocalf2(void) { return 2; }
-int	subglobalf1(void) { return 1; }
-int	subglobalf2(void) { return 2; }
+#line 7411 "configure"
+extern int _ismissing(void);    int _ismissing(void)  { return 1; }
+extern int _localf1(void);      int _localf1(void)    { return 1; }
+extern int _localf2(void);      int _localf2(void)    { return 2; }
+extern int globalf1(void);      int globalf1(void)    { return 1; }
+extern int globalf2(void);      int globalf2(void)    { return 2; }
+extern int _sublocalf1(void);   int _sublocalf1(void) { return 1; }
+extern int _sublocalf2(void);   int _sublocalf2(void) { return 2; }
+extern int subglobalf1(void);   int subglobalf1(void) { return 1; }
+extern int subglobalf2(void);   int subglobalf2(void) { return 2; }
 EOF
 		cat >conftest.mk <<EOF
 CC=${CC}
@@ -6821,7 +7439,7 @@ EOF
 			cf_missing="`nm -P conftest.so 2>&5 |${FGREP-fgrep} _ismissing | ${EGREP-egrep} '[ 	][DT][ 	]'`"
 			test -n "$cf_missing" && WILDCARD_SYMS=yes
 		fi
-		echo "$as_me:6824: result: $WILDCARD_SYMS" >&5
+		echo "$as_me:7442: result: $WILDCARD_SYMS" >&5
 echo "${ECHO_T}$WILDCARD_SYMS" >&6
 		rm -f conftest.*
 	fi
@@ -6834,7 +7452,7 @@ done
 ### Checks for special libraries, must be done up-front.
 SHLIB_LIST=""
 
-echo "$as_me:6837: checking if you want to link with the GPM mouse library" >&5
+echo "$as_me:7455: checking if you want to link with the GPM mouse library" >&5
 echo $ECHO_N "checking if you want to link with the GPM mouse library... $ECHO_C" >&6
 
 # Check whether --with-gpm or --without-gpm was given.
@@ -6844,27 +7462,27 @@ if test "${with_gpm+set}" = set; then
 else
   with_gpm=maybe
 fi;
-echo "$as_me:6847: result: $with_gpm" >&5
+echo "$as_me:7465: result: $with_gpm" >&5
 echo "${ECHO_T}$with_gpm" >&6
 
 if test "$with_gpm" != no ; then
-	echo "$as_me:6851: checking for gpm.h" >&5
+	echo "$as_me:7469: checking for gpm.h" >&5
 echo $ECHO_N "checking for gpm.h... $ECHO_C" >&6
 if test "${ac_cv_header_gpm_h+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 6857 "configure"
+#line 7475 "configure"
 #include "confdefs.h"
 #include <gpm.h>
 _ACEOF
-if { (eval echo "$as_me:6861: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+if { (eval echo "$as_me:7479: \"$ac_cpp "conftest.$ac_ext"\"") >&5
   (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:6867: \$? = $ac_status" >&5
+  echo "$as_me:7485: \$? = $ac_status" >&5
   (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -6883,7 +7501,7 @@ else
 fi
 rm -f conftest.err "conftest.$ac_ext"
 fi
-echo "$as_me:6886: result: $ac_cv_header_gpm_h" >&5
+echo "$as_me:7504: result: $ac_cv_header_gpm_h" >&5
 echo "${ECHO_T}$ac_cv_header_gpm_h" >&6
 if test "$ac_cv_header_gpm_h" = yes; then
 
@@ -6894,7 +7512,7 @@ EOF
 		if test "$with_gpm" != yes && test "$with_gpm" != maybe ; then
 			test -n "$verbose" && echo "	assuming we really have GPM library" 1>&6
 
-echo "${as_me:-configure}:6897: testing assuming we really have GPM library ..." 1>&5
+echo "${as_me:-configure}:7515: testing assuming we really have GPM library ..." 1>&5
 
 cat >>confdefs.h <<\EOF
 #define HAVE_LIBGPM 1
@@ -6902,7 +7520,7 @@ EOF
 
 			with_gpm=yes
 		else
-			echo "$as_me:6905: checking for Gpm_Open in -lgpm" >&5
+			echo "$as_me:7523: checking for Gpm_Open in -lgpm" >&5
 echo $ECHO_N "checking for Gpm_Open in -lgpm... $ECHO_C" >&6
 if test "${ac_cv_lib_gpm_Gpm_Open+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -6910,7 +7528,7 @@ else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lgpm  $LIBS"
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 6913 "configure"
+#line 7531 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -6919,7 +7537,7 @@ extern "C"
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char Gpm_Open ();
+char Gpm_Open (void);
 int
 main (void)
 {
@@ -6929,16 +7547,16 @@ Gpm_Open ();
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:6932: \"$ac_link\"") >&5
+if { (eval echo "$as_me:7550: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:6935: \$? = $ac_status" >&5
+  echo "$as_me:7553: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:6938: \"$ac_try\"") >&5
+  { (eval echo "$as_me:7556: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:6941: \$? = $ac_status" >&5
+  echo "$as_me:7559: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_lib_gpm_Gpm_Open=yes
 else
@@ -6949,18 +7567,18 @@ fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:6952: result: $ac_cv_lib_gpm_Gpm_Open" >&5
+echo "$as_me:7570: result: $ac_cv_lib_gpm_Gpm_Open" >&5
 echo "${ECHO_T}$ac_cv_lib_gpm_Gpm_Open" >&6
 if test "$ac_cv_lib_gpm_Gpm_Open" = yes; then
   with_gpm=yes
 else
 
 				if test "$with_gpm" = maybe; then
-					{ echo "$as_me:6959: WARNING: Cannot link with GPM library" >&5
+					{ echo "$as_me:7577: WARNING: Cannot link with GPM library" >&5
 echo "$as_me: WARNING: Cannot link with GPM library" >&2;}
 					with_gpm=no
 				else
-					{ { echo "$as_me:6963: error: Cannot link with GPM library" >&5
+					{ { echo "$as_me:7581: error: Cannot link with GPM library" >&5
 echo "$as_me: error: Cannot link with GPM library" >&2;}
    { (exit 1); exit 1; }; }
 				fi
@@ -6971,7 +7589,7 @@ fi
 
 else
 
-		test "$with_gpm" != maybe && { echo "$as_me:6974: WARNING: Cannot find GPM header" >&5
+		test "$with_gpm" != maybe && { echo "$as_me:7592: WARNING: Cannot find GPM header" >&5
 echo "$as_me: WARNING: Cannot find GPM header" >&2;}
 		with_gpm=no
 
@@ -6980,7 +7598,7 @@ fi
 fi
 
 if test "$with_gpm" != no ; then
-	echo "$as_me:6983: checking if you want to load GPM dynamically" >&5
+	echo "$as_me:7601: checking if you want to load GPM dynamically" >&5
 echo $ECHO_N "checking if you want to load GPM dynamically... $ECHO_C" >&6
 
 # Check whether --with-dlsym or --without-dlsym was given.
@@ -6990,18 +7608,18 @@ if test "${with_dlsym+set}" = set; then
 else
   with_dlsym=yes
 fi;
-	echo "$as_me:6993: result: $with_dlsym" >&5
+	echo "$as_me:7611: result: $with_dlsym" >&5
 echo "${ECHO_T}$with_dlsym" >&6
 	if test "x$with_dlsym" = xyes ; then
 
 cf_have_dlsym=no
-echo "$as_me:6998: checking for dlsym" >&5
+echo "$as_me:7616: checking for dlsym" >&5
 echo $ECHO_N "checking for dlsym... $ECHO_C" >&6
 if test "${ac_cv_func_dlsym+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 7004 "configure"
+#line 7622 "configure"
 #include "confdefs.h"
 #define dlsym autoconf_temporary
 #include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
@@ -7032,16 +7650,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:7035: \"$ac_link\"") >&5
+if { (eval echo "$as_me:7653: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7038: \$? = $ac_status" >&5
+  echo "$as_me:7656: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:7041: \"$ac_try\"") >&5
+  { (eval echo "$as_me:7659: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7044: \$? = $ac_status" >&5
+  echo "$as_me:7662: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_func_dlsym=yes
 else
@@ -7051,14 +7669,14 @@ ac_cv_func_dlsym=no
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:7054: result: $ac_cv_func_dlsym" >&5
+echo "$as_me:7672: result: $ac_cv_func_dlsym" >&5
 echo "${ECHO_T}$ac_cv_func_dlsym" >&6
 if test "$ac_cv_func_dlsym" = yes; then
   cf_have_dlsym=yes
 else
 
 cf_have_libdl=no
-echo "$as_me:7061: checking for dlsym in -ldl" >&5
+echo "$as_me:7679: checking for dlsym in -ldl" >&5
 echo $ECHO_N "checking for dlsym in -ldl... $ECHO_C" >&6
 if test "${ac_cv_lib_dl_dlsym+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -7066,7 +7684,7 @@ else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-ldl  $LIBS"
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 7069 "configure"
+#line 7687 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -7075,7 +7693,7 @@ extern "C"
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char dlsym ();
+char dlsym (void);
 int
 main (void)
 {
@@ -7085,16 +7703,16 @@ dlsym ();
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:7088: \"$ac_link\"") >&5
+if { (eval echo "$as_me:7706: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7091: \$? = $ac_status" >&5
+  echo "$as_me:7709: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:7094: \"$ac_try\"") >&5
+  { (eval echo "$as_me:7712: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7097: \$? = $ac_status" >&5
+  echo "$as_me:7715: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_lib_dl_dlsym=yes
 else
@@ -7105,7 +7723,7 @@ fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:7108: result: $ac_cv_lib_dl_dlsym" >&5
+echo "$as_me:7726: result: $ac_cv_lib_dl_dlsym" >&5
 echo "${ECHO_T}$ac_cv_lib_dl_dlsym" >&6
 if test "$ac_cv_lib_dl_dlsym" = yes; then
 
@@ -7134,10 +7752,10 @@ done
 LIBS="$cf_add_libs"
  }
 
-	echo "$as_me:7137: checking whether able to link to dl*() functions" >&5
+	echo "$as_me:7755: checking whether able to link to dl*() functions" >&5
 echo $ECHO_N "checking whether able to link to dl*() functions... $ECHO_C" >&6
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 7140 "configure"
+#line 7758 "configure"
 #include "confdefs.h"
 #include <dlfcn.h>
 int
@@ -7155,16 +7773,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:7158: \"$ac_link\"") >&5
+if { (eval echo "$as_me:7776: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7161: \$? = $ac_status" >&5
+  echo "$as_me:7779: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:7164: \"$ac_try\"") >&5
+  { (eval echo "$as_me:7782: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7167: \$? = $ac_status" >&5
+  echo "$as_me:7785: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
 
 cat >>confdefs.h <<\EOF
@@ -7175,15 +7793,15 @@ else
   echo "$as_me: failed program was:" >&5
 cat "conftest.$ac_ext" >&5
 
-		{ { echo "$as_me:7178: error: Cannot link test program for libdl" >&5
+		{ { echo "$as_me:7796: error: Cannot link test program for libdl" >&5
 echo "$as_me: error: Cannot link test program for libdl" >&2;}
    { (exit 1); exit 1; }; }
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
-	echo "$as_me:7183: result: ok" >&5
+	echo "$as_me:7801: result: ok" >&5
 echo "${ECHO_T}ok" >&6
 else
-	{ { echo "$as_me:7186: error: Cannot find dlsym function" >&5
+	{ { echo "$as_me:7804: error: Cannot find dlsym function" >&5
 echo "$as_me: error: Cannot find dlsym function" >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -7191,12 +7809,12 @@ fi
 		if test "x$with_gpm" != xyes ; then
 			test -n "$verbose" && echo "	assuming soname for gpm is $with_gpm" 1>&6
 
-echo "${as_me:-configure}:7194: testing assuming soname for gpm is $with_gpm ..." 1>&5
+echo "${as_me:-configure}:7812: testing assuming soname for gpm is $with_gpm ..." 1>&5
 
 			cf_cv_gpm_soname="$with_gpm"
 		else
 
-echo "$as_me:7199: checking for soname of gpm library" >&5
+echo "$as_me:7817: checking for soname of gpm library" >&5
 echo $ECHO_N "checking for soname of gpm library... $ECHO_C" >&6
 if test "${cf_cv_gpm_soname+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -7230,15 +7848,15 @@ for cf_add_1lib in $cf_add_0lib; do
 done
 LIBS="$cf_add_libs"
 
-	if { (eval echo "$as_me:7233: \"$ac_compile\"") >&5
+	if { (eval echo "$as_me:7851: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:7236: \$? = $ac_status" >&5
+  echo "$as_me:7854: \$? = $ac_status" >&5
   (exit "$ac_status"); } ; then
-		if { (eval echo "$as_me:7238: \"$ac_link\"") >&5
+		if { (eval echo "$as_me:7856: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7241: \$? = $ac_status" >&5
+  echo "$as_me:7859: \$? = $ac_status" >&5
   (exit "$ac_status"); } ; then
 			cf_cv_gpm_soname="`ldd \"conftest$ac_exeext\" 2>/dev/null | sed -e 's,^.*/,,' -e 's, .*$,,' | ${FGREP-fgrep} libgpm.`"
 			test -z "$cf_cv_gpm_soname" && cf_cv_gpm_soname=unknown
@@ -7249,7 +7867,7 @@ LIBS="$cf_save_LIBS"
 fi
 
 fi
-echo "$as_me:7252: result: $cf_cv_gpm_soname" >&5
+echo "$as_me:7870: result: $cf_cv_gpm_soname" >&5
 echo "${ECHO_T}$cf_cv_gpm_soname" >&6
 
 		fi
@@ -7317,7 +7935,7 @@ cat >>confdefs.h <<\EOF
 #define HAVE_LIBGPM 1
 EOF
 
-echo "$as_me:7320: checking for Gpm_Wgetch in -lgpm" >&5
+echo "$as_me:7938: checking for Gpm_Wgetch in -lgpm" >&5
 echo $ECHO_N "checking for Gpm_Wgetch in -lgpm... $ECHO_C" >&6
 if test "${ac_cv_lib_gpm_Gpm_Wgetch+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -7325,7 +7943,7 @@ else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lgpm  $LIBS"
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 7328 "configure"
+#line 7946 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -7334,7 +7952,7 @@ extern "C"
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char Gpm_Wgetch ();
+char Gpm_Wgetch (void);
 int
 main (void)
 {
@@ -7344,16 +7962,16 @@ Gpm_Wgetch ();
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:7347: \"$ac_link\"") >&5
+if { (eval echo "$as_me:7965: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7350: \$? = $ac_status" >&5
+  echo "$as_me:7968: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:7353: \"$ac_try\"") >&5
+  { (eval echo "$as_me:7971: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7356: \$? = $ac_status" >&5
+  echo "$as_me:7974: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_lib_gpm_Gpm_Wgetch=yes
 else
@@ -7364,11 +7982,11 @@ fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:7367: result: $ac_cv_lib_gpm_Gpm_Wgetch" >&5
+echo "$as_me:7985: result: $ac_cv_lib_gpm_Gpm_Wgetch" >&5
 echo "${ECHO_T}$ac_cv_lib_gpm_Gpm_Wgetch" >&6
 if test "$ac_cv_lib_gpm_Gpm_Wgetch" = yes; then
 
-echo "$as_me:7371: checking if GPM is weakly bound to curses library" >&5
+echo "$as_me:7989: checking if GPM is weakly bound to curses library" >&5
 echo $ECHO_N "checking if GPM is weakly bound to curses library... $ECHO_C" >&6
 if test "${cf_cv_check_gpm_wgetch+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -7392,15 +8010,15 @@ CF_EOF
 	# to rely on the static library, noting that some packagers may not
 	# include it.
 	LIBS="-static -lgpm -dynamic $LIBS"
-	if { (eval echo "$as_me:7395: \"$ac_compile\"") >&5
+	if { (eval echo "$as_me:8013: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:7398: \$? = $ac_status" >&5
+  echo "$as_me:8016: \$? = $ac_status" >&5
   (exit "$ac_status"); } ; then
-		if { (eval echo "$as_me:7400: \"$ac_link\"") >&5
+		if { (eval echo "$as_me:8018: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7403: \$? = $ac_status" >&5
+  echo "$as_me:8021: \$? = $ac_status" >&5
   (exit "$ac_status"); } ; then
 			cf_cv_check_gpm_wgetch="`nm \"conftest$ac_exeext\" | ${EGREP-egrep} '\<wgetch\>' | ${EGREP-egrep} '\<[vVwW]\>'`"
 			test -n "$cf_cv_check_gpm_wgetch" && cf_cv_check_gpm_wgetch=yes
@@ -7412,11 +8030,11 @@ CF_EOF
 fi
 
 fi
-echo "$as_me:7415: result: $cf_cv_check_gpm_wgetch" >&5
+echo "$as_me:8033: result: $cf_cv_check_gpm_wgetch" >&5
 echo "${ECHO_T}$cf_cv_check_gpm_wgetch" >&6
 
 if test "$cf_cv_check_gpm_wgetch" != yes ; then
-	{ echo "$as_me:7419: WARNING: GPM library is already linked with curses - read the FAQ" >&5
+	{ echo "$as_me:8037: WARNING: GPM library is already linked with curses - read the FAQ" >&5
 echo "$as_me: WARNING: GPM library is already linked with curses - read the FAQ" >&2;}
 fi
 
@@ -7424,7 +8042,7 @@ fi
 
 fi
 
-echo "$as_me:7427: checking if you want to use PCRE2 for regular-expressions" >&5
+echo "$as_me:8045: checking if you want to use PCRE2 for regular-expressions" >&5
 echo $ECHO_N "checking if you want to use PCRE2 for regular-expressions... $ECHO_C" >&6
 
 # Check whether --with-pcre2 or --without-pcre2 was given.
@@ -7433,7 +8051,7 @@ if test "${with_pcre2+set}" = set; then
 
 fi;
 test -z "$with_pcre2" && with_pcre2=no
-echo "$as_me:7436: result: $with_pcre2" >&5
+echo "$as_me:8054: result: $with_pcre2" >&5
 echo "${ECHO_T}$with_pcre2" >&6
 
 if test "x$with_pcre2" != xno ; then
@@ -7444,17 +8062,17 @@ if test "x$with_pcre2" != xno ; then
 if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists "$cf_with_pcre2"; then
 	test -n "$verbose" && echo "	found package $cf_with_pcre2" 1>&6
 
-echo "${as_me:-configure}:7447: testing found package $cf_with_pcre2 ..." 1>&5
+echo "${as_me:-configure}:8065: testing found package $cf_with_pcre2 ..." 1>&5
 
 	cf_pkgconfig_incs="`$PKG_CONFIG --cflags "$cf_with_pcre2" 2>/dev/null`"
 	cf_pkgconfig_libs="`$PKG_CONFIG --libs   "$cf_with_pcre2" 2>/dev/null`"
 	test -n "$verbose" && echo "	package $cf_with_pcre2 CFLAGS: $cf_pkgconfig_incs" 1>&6
 
-echo "${as_me:-configure}:7453: testing package $cf_with_pcre2 CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+echo "${as_me:-configure}:8071: testing package $cf_with_pcre2 CFLAGS: $cf_pkgconfig_incs ..." 1>&5
 
 	test -n "$verbose" && echo "	package $cf_with_pcre2 LIBS: $cf_pkgconfig_libs" 1>&6
 
-echo "${as_me:-configure}:7457: testing package $cf_with_pcre2 LIBS: $cf_pkgconfig_libs ..." 1>&5
+echo "${as_me:-configure}:8075: testing package $cf_with_pcre2 LIBS: $cf_pkgconfig_libs ..." 1>&5
 
 cf_fix_cppflags=no
 cf_new_cflags=
@@ -7578,7 +8196,7 @@ else
 fi
 
 	done
-	cf_with_pcre2_ok=yes || { { echo "$as_me:7581: error: Cannot find PCRE2 library" >&5
+	cf_with_pcre2_ok=yes || { { echo "$as_me:8199: error: Cannot find PCRE2 library" >&5
 echo "$as_me: error: Cannot find PCRE2 library" >&2;}
    { (exit 1); exit 1; }; }
 
@@ -7591,7 +8209,7 @@ EOF
 	(*pcre2-posix*|*pcreposix*)
 		;;
 	(*)
-		echo "$as_me:7594: checking for regcomp in -lpcre2-posix" >&5
+		echo "$as_me:8212: checking for regcomp in -lpcre2-posix" >&5
 echo $ECHO_N "checking for regcomp in -lpcre2-posix... $ECHO_C" >&6
 if test "${ac_cv_lib_pcre2_posix_regcomp+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -7599,7 +8217,7 @@ else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lpcre2-posix  $LIBS"
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 7602 "configure"
+#line 8220 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -7608,7 +8226,7 @@ extern "C"
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char regcomp ();
+char regcomp (void);
 int
 main (void)
 {
@@ -7618,16 +8236,16 @@ regcomp ();
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:7621: \"$ac_link\"") >&5
+if { (eval echo "$as_me:8239: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7624: \$? = $ac_status" >&5
+  echo "$as_me:8242: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:7627: \"$ac_try\"") >&5
+  { (eval echo "$as_me:8245: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7630: \$? = $ac_status" >&5
+  echo "$as_me:8248: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_lib_pcre2_posix_regcomp=yes
 else
@@ -7638,7 +8256,7 @@ fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:7641: result: $ac_cv_lib_pcre2_posix_regcomp" >&5
+echo "$as_me:8259: result: $ac_cv_lib_pcre2_posix_regcomp" >&5
 echo "${ECHO_T}$ac_cv_lib_pcre2_posix_regcomp" >&6
 if test "$ac_cv_lib_pcre2_posix_regcomp" = yes; then
 
@@ -7659,7 +8277,7 @@ done
 LIBS="$cf_add_libs"
 
 else
-  echo "$as_me:7662: checking for regcomp in -lpcreposix" >&5
+  echo "$as_me:8280: checking for regcomp in -lpcreposix" >&5
 echo $ECHO_N "checking for regcomp in -lpcreposix... $ECHO_C" >&6
 if test "${ac_cv_lib_pcreposix_regcomp+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -7667,7 +8285,7 @@ else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lpcreposix  $LIBS"
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 7670 "configure"
+#line 8288 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -7676,7 +8294,7 @@ extern "C"
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char regcomp ();
+char regcomp (void);
 int
 main (void)
 {
@@ -7686,16 +8304,16 @@ regcomp ();
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:7689: \"$ac_link\"") >&5
+if { (eval echo "$as_me:8307: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7692: \$? = $ac_status" >&5
+  echo "$as_me:8310: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:7695: \"$ac_try\"") >&5
+  { (eval echo "$as_me:8313: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7698: \$? = $ac_status" >&5
+  echo "$as_me:8316: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_lib_pcreposix_regcomp=yes
 else
@@ -7706,7 +8324,7 @@ fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:7709: result: $ac_cv_lib_pcreposix_regcomp" >&5
+echo "$as_me:8327: result: $ac_cv_lib_pcreposix_regcomp" >&5
 echo "${ECHO_T}$ac_cv_lib_pcreposix_regcomp" >&6
 if test "$ac_cv_lib_pcreposix_regcomp" = yes; then
 
@@ -7727,7 +8345,7 @@ done
 LIBS="$cf_add_libs"
 
 else
-  { { echo "$as_me:7730: error: Cannot find PCRE2 POSIX library" >&5
+  { { echo "$as_me:8348: error: Cannot find PCRE2 POSIX library" >&5
 echo "$as_me: error: Cannot find PCRE2 POSIX library" >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -7742,23 +8360,23 @@ fi
 for ac_header in pcre2posix.h pcreposix.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:7745: checking for $ac_header" >&5
+echo "$as_me:8363: checking for $ac_header" >&5
 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 7751 "configure"
+#line 8369 "configure"
 #include "confdefs.h"
 #include <$ac_header>
 _ACEOF
-if { (eval echo "$as_me:7755: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+if { (eval echo "$as_me:8373: \"$ac_cpp "conftest.$ac_ext"\"") >&5
   (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:7761: \$? = $ac_status" >&5
+  echo "$as_me:8379: \$? = $ac_status" >&5
   (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -7777,7 +8395,7 @@ else
 fi
 rm -f conftest.err "conftest.$ac_ext"
 fi
-echo "$as_me:7780: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
+echo "$as_me:8398: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
 echo "${ECHO_T}`eval echo '${'"$as_ac_Header"'}'`" >&6
 if test "`eval echo '${'"$as_ac_Header"'}'`" = yes; then
   cat >>confdefs.h <<EOF
@@ -7787,11 +8405,80 @@ EOF
 fi
 done
 
+for ac_func in PCRE2regcomp
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:8411: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 8417 "configure"
+#include "confdefs.h"
+#define $ac_func autoconf_temporary
+#include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
+#undef $ac_func
+
+#ifdef __cplusplus
+extern "C"
+#endif
+
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char $ac_func (void);
+
+int
+main (void)
+{
+
+/* The GNU C library defines stubs for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+#error found stub for $ac_func
+#endif
+
+	return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:8448: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:8451: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:8454: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:8457: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+eval "$as_ac_var=no"
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+fi
+echo "$as_me:8467: result: `eval echo '${'"$as_ac_var"'}'`" >&5
+echo "${ECHO_T}`eval echo '${'"$as_ac_var"'}'`" >&6
+if test "`eval echo '${'"$as_ac_var"'}'`" = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+EOF
+
+fi
+done
+
 fi
 
 # not everyone has "test -c"
 if test -c /dev/sysmouse 2>/dev/null ; then
-echo "$as_me:7794: checking if you want to use sysmouse" >&5
+echo "$as_me:8481: checking if you want to use sysmouse" >&5
 echo $ECHO_N "checking if you want to use sysmouse... $ECHO_C" >&6
 
 # Check whether --with-sysmouse or --without-sysmouse was given.
@@ -7803,7 +8490,7 @@ else
 fi;
 	if test "$cf_with_sysmouse" != no ; then
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 7806 "configure"
+#line 8493 "configure"
 #include "confdefs.h"
 
 #include <osreldate.h>
@@ -7826,16 +8513,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:7829: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:8516: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:7832: \$? = $ac_status" >&5
+  echo "$as_me:8519: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:7835: \"$ac_try\"") >&5
+  { (eval echo "$as_me:8522: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7838: \$? = $ac_status" >&5
+  echo "$as_me:8525: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_with_sysmouse=yes
 else
@@ -7845,7 +8532,7 @@ cf_with_sysmouse=no
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 	fi
-echo "$as_me:7848: result: $cf_with_sysmouse" >&5
+echo "$as_me:8535: result: $cf_with_sysmouse" >&5
 echo "${ECHO_T}$cf_with_sysmouse" >&6
 test "$cf_with_sysmouse" = yes &&
 cat >>confdefs.h <<\EOF
@@ -7855,7 +8542,7 @@ EOF
 fi
 
 # pretend that ncurses==ncursesw==ncursest
-echo "$as_me:7858: checking if you want to disable library suffixes" >&5
+echo "$as_me:8545: checking if you want to disable library suffixes" >&5
 echo $ECHO_N "checking if you want to disable library suffixes... $ECHO_C" >&6
 
 # Check whether --enable-lib-suffixes or --disable-lib-suffixes was given.
@@ -7872,13 +8559,13 @@ else
 	disable_lib_suffixes=no
 
 fi;
-echo "$as_me:7875: result: $disable_lib_suffixes" >&5
+echo "$as_me:8562: result: $disable_lib_suffixes" >&5
 echo "${ECHO_T}$disable_lib_suffixes" >&6
 
 ### If we're building with rpath, try to link non-standard libs that way too.
 if test "$DFT_LWR_MODEL" = "shared" && test "x$cf_cv_enable_rpath" != xno; then
 
-echo "$as_me:7881: checking if rpath-hack should be disabled" >&5
+echo "$as_me:8568: checking if rpath-hack should be disabled" >&5
 echo $ECHO_N "checking if rpath-hack should be disabled... $ECHO_C" >&6
 
 # Check whether --enable-rpath-hack or --disable-rpath-hack was given.
@@ -7896,22 +8583,22 @@ else
 
 fi;
 if test "x$enable_rpath_hack" = xno; then cf_disable_rpath_hack=yes; else cf_disable_rpath_hack=no; fi
-echo "$as_me:7899: result: $cf_disable_rpath_hack" >&5
+echo "$as_me:8586: result: $cf_disable_rpath_hack" >&5
 echo "${ECHO_T}$cf_disable_rpath_hack" >&6
 
 if test "$enable_rpath_hack" = yes ; then
 
-echo "$as_me:7904: checking for updated LDFLAGS" >&5
+echo "$as_me:8591: checking for updated LDFLAGS" >&5
 echo $ECHO_N "checking for updated LDFLAGS... $ECHO_C" >&6
 if test -n "$LD_RPATH_OPT" ; then
-	echo "$as_me:7907: result: maybe" >&5
+	echo "$as_me:8594: result: maybe" >&5
 echo "${ECHO_T}maybe" >&6
 
 	for ac_prog in ldd
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:7914: checking for $ac_word" >&5
+echo "$as_me:8601: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_cf_ldd_prog+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -7926,7 +8613,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_cf_ldd_prog="$ac_prog"
-echo "$as_me:7929: found $ac_dir/$ac_word" >&5
+echo "$as_me:8616: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -7934,10 +8621,10 @@ fi
 fi
 cf_ldd_prog=$ac_cv_prog_cf_ldd_prog
 if test -n "$cf_ldd_prog"; then
-  echo "$as_me:7937: result: $cf_ldd_prog" >&5
+  echo "$as_me:8624: result: $cf_ldd_prog" >&5
 echo "${ECHO_T}$cf_ldd_prog" >&6
 else
-  echo "$as_me:7940: result: no" >&5
+  echo "$as_me:8627: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -7951,7 +8638,7 @@ test -n "$cf_ldd_prog" || cf_ldd_prog="no"
 		cf_rpath_oops=
 
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 7954 "configure"
+#line 8641 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int
@@ -7963,16 +8650,16 @@ printf("Hello");
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:7966: \"$ac_link\"") >&5
+if { (eval echo "$as_me:8653: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7969: \$? = $ac_status" >&5
+  echo "$as_me:8656: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:7972: \"$ac_try\"") >&5
+  { (eval echo "$as_me:8659: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7975: \$? = $ac_status" >&5
+  echo "$as_me:8662: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_rpath_oops=`"$cf_ldd_prog" "conftest$ac_exeext" | ${FGREP-fgrep} ' not found' | sed -e 's% =>.*$%%' |sort | uniq`
 		 cf_rpath_list=`"$cf_ldd_prog" "conftest$ac_exeext" | ${FGREP-fgrep} / | sed -e 's%^.*[ 	]/%/%' -e 's%/[^/][^/]*$%%' |sort | uniq`
@@ -8000,7 +8687,7 @@ rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 					then
 						test -n "$verbose" && echo "	...adding -L$cf_rpath_dir/lib to LDFLAGS for $cf_rpath_src" 1>&6
 
-echo "${as_me:-configure}:8003: testing ...adding -L$cf_rpath_dir/lib to LDFLAGS for $cf_rpath_src ..." 1>&5
+echo "${as_me:-configure}:8690: testing ...adding -L$cf_rpath_dir/lib to LDFLAGS for $cf_rpath_src ..." 1>&5
 
 						LDFLAGS="$LDFLAGS -L$cf_rpath_dir/lib"
 						break
@@ -8012,11 +8699,11 @@ echo "${as_me:-configure}:8003: testing ...adding -L$cf_rpath_dir/lib to LDFLAGS
 
 	test -n "$verbose" && echo "	...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS" 1>&6
 
-echo "${as_me:-configure}:8015: testing ...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS ..." 1>&5
+echo "${as_me:-configure}:8702: testing ...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS ..." 1>&5
 
 test -n "$verbose" && echo "	...checking LDFLAGS $LDFLAGS" 1>&6
 
-echo "${as_me:-configure}:8019: testing ...checking LDFLAGS $LDFLAGS ..." 1>&5
+echo "${as_me:-configure}:8706: testing ...checking LDFLAGS $LDFLAGS ..." 1>&5
 
 cf_rpath_dst=
 for cf_rpath_src in $LDFLAGS
@@ -8053,7 +8740,7 @@ do
 			then
 				test -n "$verbose" && echo "	...Filter $cf_rpath_src ->$cf_rpath_tmp" 1>&6
 
-echo "${as_me:-configure}:8056: testing ...Filter $cf_rpath_src ->$cf_rpath_tmp ..." 1>&5
+echo "${as_me:-configure}:8743: testing ...Filter $cf_rpath_src ->$cf_rpath_tmp ..." 1>&5
 
 				EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
 			fi
@@ -8066,11 +8753,11 @@ LDFLAGS=$cf_rpath_dst
 
 test -n "$verbose" && echo "	...checked LDFLAGS $LDFLAGS" 1>&6
 
-echo "${as_me:-configure}:8069: testing ...checked LDFLAGS $LDFLAGS ..." 1>&5
+echo "${as_me:-configure}:8756: testing ...checked LDFLAGS $LDFLAGS ..." 1>&5
 
 test -n "$verbose" && echo "	...checking LIBS $LIBS" 1>&6
 
-echo "${as_me:-configure}:8073: testing ...checking LIBS $LIBS ..." 1>&5
+echo "${as_me:-configure}:8760: testing ...checking LIBS $LIBS ..." 1>&5
 
 cf_rpath_dst=
 for cf_rpath_src in $LIBS
@@ -8107,7 +8794,7 @@ do
 			then
 				test -n "$verbose" && echo "	...Filter $cf_rpath_src ->$cf_rpath_tmp" 1>&6
 
-echo "${as_me:-configure}:8110: testing ...Filter $cf_rpath_src ->$cf_rpath_tmp ..." 1>&5
+echo "${as_me:-configure}:8797: testing ...Filter $cf_rpath_src ->$cf_rpath_tmp ..." 1>&5
 
 				EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
 			fi
@@ -8120,14 +8807,14 @@ LIBS=$cf_rpath_dst
 
 test -n "$verbose" && echo "	...checked LIBS $LIBS" 1>&6
 
-echo "${as_me:-configure}:8123: testing ...checked LIBS $LIBS ..." 1>&5
+echo "${as_me:-configure}:8810: testing ...checked LIBS $LIBS ..." 1>&5
 
 	test -n "$verbose" && echo "	...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS" 1>&6
 
-echo "${as_me:-configure}:8127: testing ...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS ..." 1>&5
+echo "${as_me:-configure}:8814: testing ...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS ..." 1>&5
 
 else
-	echo "$as_me:8130: result: no" >&5
+	echo "$as_me:8817: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -8138,10 +8825,10 @@ fi
 ### Depending on the system, someone may use rpath to build ncurses but not
 # want users of the package to rely upon that feature.  Give those people an
 # option to suppress that detail from EXTRA_LDFLAGS.
-EXTRA_PKG_LDFLAGS="$EXTRA_LDFLAGS"
+EXTRA_PKG_LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
 if test -n "$EXTRA_PKG_LDFLAGS"
 then
-	echo "$as_me:8144: checking if you want to disable extra LDFLAGS for package-scripts" >&5
+	echo "$as_me:8831: checking if you want to disable extra LDFLAGS for package-scripts" >&5
 echo $ECHO_N "checking if you want to disable extra LDFLAGS for package-scripts... $ECHO_C" >&6
 
 # Check whether --enable-pkg-ldflags or --disable-pkg-ldflags was given.
@@ -8158,7 +8845,7 @@ else
 	disable_pkg_ldflags=no
 
 fi;
-	echo "$as_me:8161: result: $disable_pkg_ldflags" >&5
+	echo "$as_me:8848: result: $disable_pkg_ldflags" >&5
 echo "${ECHO_T}$disable_pkg_ldflags" >&6
 	test "$disable_pkg_ldflags" = yes && EXTRA_PKG_LDFLAGS=
 fi
@@ -8166,8 +8853,8 @@ fi
 ###############################################################################
 
 ###	use option --with-extra-suffix to append suffix to headers and libraries
-echo "$as_me:8169: checking if you wish to append extra suffix to header/library paths" >&5
-echo $ECHO_N "checking if you wish to append extra suffix to header/library paths... $ECHO_C" >&6
+echo "$as_me:8856: checking for extra suffix to append to header/library paths" >&5
+echo $ECHO_N "checking for extra suffix to append to header/library paths... $ECHO_C" >&6
 EXTRA_SUFFIX=
 
 # Check whether --with-extra-suffix or --without-extra-suffix was given.
@@ -8185,11 +8872,11 @@ if test "${with_extra_suffix+set}" = set; then
 	esac
 
 fi;
-echo "$as_me:8188: result: $EXTRA_SUFFIX" >&5
-echo "${ECHO_T}$EXTRA_SUFFIX" >&6
+echo "$as_me:8875: result: ${EXTRA_SUFFIX:-(none)}" >&5
+echo "${ECHO_T}${EXTRA_SUFFIX:-(none)}" >&6
 
 ###	use option --disable-overwrite to leave out the link to -lcurses
-echo "$as_me:8192: checking if you wish to install ncurses overwriting curses" >&5
+echo "$as_me:8879: checking if you wish to install ncurses overwriting curses" >&5
 echo $ECHO_N "checking if you wish to install ncurses overwriting curses... $ECHO_C" >&6
 
 # Check whether --enable-overwrite or --disable-overwrite was given.
@@ -8199,10 +8886,10 @@ if test "${enable_overwrite+set}" = set; then
 else
   if test "$prefix" = "/usr" ; then with_overwrite=yes; else with_overwrite=no; fi
 fi;
-echo "$as_me:8202: result: $with_overwrite" >&5
+echo "$as_me:8889: result: $with_overwrite" >&5
 echo "${ECHO_T}$with_overwrite" >&6
 
-echo "$as_me:8205: checking if external terminfo-database is used" >&5
+echo "$as_me:8892: checking if external terminfo-database is used" >&5
 echo $ECHO_N "checking if external terminfo-database is used... $ECHO_C" >&6
 
 # Check whether --enable-database or --disable-database was given.
@@ -8212,7 +8899,7 @@ if test "${enable_database+set}" = set; then
 else
   use_database=yes
 fi;
-echo "$as_me:8215: result: $use_database" >&5
+echo "$as_me:8902: result: $use_database" >&5
 echo "${ECHO_T}$use_database" >&6
 
 case "$host_os" in
@@ -8228,7 +8915,7 @@ NCURSES_USE_DATABASE=0
 if test "$use_database" != no ; then
 	NCURSES_USE_DATABASE=1
 
-	echo "$as_me:8231: checking which terminfo source-file will be installed" >&5
+	echo "$as_me:8918: checking which terminfo source-file will be installed" >&5
 echo $ECHO_N "checking which terminfo source-file will be installed... $ECHO_C" >&6
 
 # Check whether --with-database or --without-database was given.
@@ -8236,10 +8923,10 @@ if test "${with_database+set}" = set; then
   withval="$with_database"
   TERMINFO_SRC=$withval
 fi;
-	echo "$as_me:8239: result: $TERMINFO_SRC" >&5
+	echo "$as_me:8926: result: $TERMINFO_SRC" >&5
 echo "${ECHO_T}$TERMINFO_SRC" >&6
 
-	echo "$as_me:8242: checking whether to use hashed database instead of directory/tree" >&5
+	echo "$as_me:8929: checking whether to use hashed database instead of directory/tree" >&5
 echo $ECHO_N "checking whether to use hashed database instead of directory/tree... $ECHO_C" >&6
 
 # Check whether --with-hashed-db or --without-hashed-db was given.
@@ -8249,14 +8936,14 @@ if test "${with_hashed_db+set}" = set; then
 else
   with_hashed_db=no
 fi;
-	echo "$as_me:8252: result: $with_hashed_db" >&5
+	echo "$as_me:8939: result: $with_hashed_db" >&5
 echo "${ECHO_T}$with_hashed_db" >&6
 else
 	with_hashed_db=no
 fi
 
-echo "$as_me:8258: checking for list of fallback descriptions" >&5
-echo $ECHO_N "checking for list of fallback descriptions... $ECHO_C" >&6
+echo "$as_me:8945: checking for list of fallback terminal descriptions" >&5
+echo $ECHO_N "checking for list of fallback terminal descriptions... $ECHO_C" >&6
 
 # Check whether --with-fallbacks or --without-fallbacks was given.
 if test "${with_fallbacks+set}" = set; then
@@ -8265,15 +8952,15 @@ if test "${with_fallbacks+set}" = set; then
 else
   with_fallback=
 fi;
-echo "$as_me:8268: result: $with_fallback" >&5
-echo "${ECHO_T}$with_fallback" >&6
+echo "$as_me:8955: result: ${with_fallback:-(none)}" >&5
+echo "${ECHO_T}${with_fallback:-(none)}" >&6
 
 case ".$with_fallback" in
 (.|.no)
 	FALLBACK_LIST=
 	;;
 (.yes)
-	{ echo "$as_me:8276: WARNING: expected a list of terminal descriptions" >&5
+	{ echo "$as_me:8963: WARNING: expected a list of terminal descriptions" >&5
 echo "$as_me: WARNING: expected a list of terminal descriptions" >&2;}
 	;;
 (*)
@@ -8289,7 +8976,7 @@ esac
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}tic", so it can be a program name with args.
 set dummy ${ac_tool_prefix}tic; ac_word=$2
-echo "$as_me:8292: checking for $ac_word" >&5
+echo "$as_me:8979: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_TIC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -8304,7 +8991,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_TIC="${ac_tool_prefix}tic"
-echo "$as_me:8307: found $ac_dir/$ac_word" >&5
+echo "$as_me:8994: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -8312,10 +8999,10 @@ fi
 fi
 TIC=$ac_cv_prog_TIC
 if test -n "$TIC"; then
-  echo "$as_me:8315: result: $TIC" >&5
+  echo "$as_me:9002: result: $TIC" >&5
 echo "${ECHO_T}$TIC" >&6
 else
-  echo "$as_me:8318: result: no" >&5
+  echo "$as_me:9005: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -8324,7 +9011,7 @@ if test -z "$ac_cv_prog_TIC"; then
   ac_ct_TIC=$TIC
   # Extract the first word of "tic", so it can be a program name with args.
 set dummy tic; ac_word=$2
-echo "$as_me:8327: checking for $ac_word" >&5
+echo "$as_me:9014: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ac_ct_TIC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -8339,7 +9026,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_ac_ct_TIC="tic"
-echo "$as_me:8342: found $ac_dir/$ac_word" >&5
+echo "$as_me:9029: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -8347,10 +9034,10 @@ fi
 fi
 ac_ct_TIC=$ac_cv_prog_ac_ct_TIC
 if test -n "$ac_ct_TIC"; then
-  echo "$as_me:8350: result: $ac_ct_TIC" >&5
+  echo "$as_me:9037: result: $ac_ct_TIC" >&5
 echo "${ECHO_T}$ac_ct_TIC" >&6
 else
-  echo "$as_me:8353: result: no" >&5
+  echo "$as_me:9040: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -8362,7 +9049,7 @@ fi
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}infocmp", so it can be a program name with args.
 set dummy ${ac_tool_prefix}infocmp; ac_word=$2
-echo "$as_me:8365: checking for $ac_word" >&5
+echo "$as_me:9052: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_INFOCMP+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -8377,7 +9064,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_INFOCMP="${ac_tool_prefix}infocmp"
-echo "$as_me:8380: found $ac_dir/$ac_word" >&5
+echo "$as_me:9067: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -8385,10 +9072,10 @@ fi
 fi
 INFOCMP=$ac_cv_prog_INFOCMP
 if test -n "$INFOCMP"; then
-  echo "$as_me:8388: result: $INFOCMP" >&5
+  echo "$as_me:9075: result: $INFOCMP" >&5
 echo "${ECHO_T}$INFOCMP" >&6
 else
-  echo "$as_me:8391: result: no" >&5
+  echo "$as_me:9078: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -8397,7 +9084,7 @@ if test -z "$ac_cv_prog_INFOCMP"; then
   ac_ct_INFOCMP=$INFOCMP
   # Extract the first word of "infocmp", so it can be a program name with args.
 set dummy infocmp; ac_word=$2
-echo "$as_me:8400: checking for $ac_word" >&5
+echo "$as_me:9087: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ac_ct_INFOCMP+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -8412,7 +9099,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_ac_ct_INFOCMP="infocmp"
-echo "$as_me:8415: found $ac_dir/$ac_word" >&5
+echo "$as_me:9102: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -8420,10 +9107,10 @@ fi
 fi
 ac_ct_INFOCMP=$ac_cv_prog_ac_ct_INFOCMP
 if test -n "$ac_ct_INFOCMP"; then
-  echo "$as_me:8423: result: $ac_ct_INFOCMP" >&5
+  echo "$as_me:9110: result: $ac_ct_INFOCMP" >&5
 echo "${ECHO_T}$ac_ct_INFOCMP" >&6
 else
-  echo "$as_me:8426: result: no" >&5
+  echo "$as_me:9113: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -8438,10 +9125,10 @@ then
 # Check whether --with-tic-path or --without-tic-path was given.
 if test "${with_tic_path+set}" = set; then
   withval="$with_tic_path"
-  echo "$as_me:8441: checking for tic program for fallbacks" >&5
+  echo "$as_me:9128: checking for tic program for fallbacks" >&5
 echo $ECHO_N "checking for tic program for fallbacks... $ECHO_C" >&6
 		TIC=$withval
-		echo "$as_me:8444: result: $TIC" >&5
+		echo "$as_me:9131: result: $TIC" >&5
 echo "${ECHO_T}$TIC" >&6
 
 if test "x$prefix" != xNONE; then
@@ -8469,7 +9156,7 @@ case ".$TIC" in
 	TIC=`echo "$TIC" | sed -e s%NONE%$cf_path_syntax%`
 	;;
 (*)
-	{ { echo "$as_me:8472: error: expected a pathname, not \"$TIC\"" >&5
+	{ { echo "$as_me:9159: error: expected a pathname, not \"$TIC\"" >&5
 echo "$as_me: error: expected a pathname, not \"$TIC\"" >&2;}
    { (exit 1); exit 1; }; }
 	;;
@@ -8482,7 +9169,7 @@ for ac_prog in $TIC tic
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:8485: checking for $ac_word" >&5
+echo "$as_me:9172: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_path_TIC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -8499,7 +9186,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   if $as_executable_p "$ac_dir/$ac_word"; then
    ac_cv_path_TIC="$ac_dir/$ac_word"
-   echo "$as_me:8502: found $ac_dir/$ac_word" >&5
+   echo "$as_me:9189: found $ac_dir/$ac_word" >&5
    break
 fi
 done
@@ -8510,10 +9197,10 @@ fi
 TIC=$ac_cv_path_TIC
 
 if test -n "$TIC"; then
-  echo "$as_me:8513: result: $TIC" >&5
+  echo "$as_me:9200: result: $TIC" >&5
 echo "${ECHO_T}$TIC" >&6
 else
-  echo "$as_me:8516: result: no" >&5
+  echo "$as_me:9203: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -8572,7 +9259,7 @@ IFS="$cf_save_ifs"
 
 if test -n "$cf_path_prog" ; then
 
-echo "${as_me:-configure}:8575: testing defining path for ${cf_path_prog} ..." 1>&5
+echo "${as_me:-configure}:9262: testing defining path for ${cf_path_prog} ..." 1>&5
 
 cat >>confdefs.h <<EOF
 #define TIC_PATH "$cf_path_prog"
@@ -8587,7 +9274,7 @@ fi
 
 		if test -z "$TIC"
 		then
-			{ echo "$as_me:8590: WARNING: no tic program found for fallbacks" >&5
+			{ echo "$as_me:9277: WARNING: no tic program found for fallbacks" >&5
 echo "$as_me: WARNING: no tic program found for fallbacks" >&2;}
 		fi
 
@@ -8596,10 +9283,10 @@ fi;
 # Check whether --with-infocmp-path or --without-infocmp-path was given.
 if test "${with_infocmp_path+set}" = set; then
   withval="$with_infocmp_path"
-  echo "$as_me:8599: checking for infocmp program for fallbacks" >&5
+  echo "$as_me:9286: checking for infocmp program for fallbacks" >&5
 echo $ECHO_N "checking for infocmp program for fallbacks... $ECHO_C" >&6
 		INFOCMP=$withval
-		echo "$as_me:8602: result: $INFOCMP" >&5
+		echo "$as_me:9289: result: $INFOCMP" >&5
 echo "${ECHO_T}$INFOCMP" >&6
 
 if test "x$prefix" != xNONE; then
@@ -8627,7 +9314,7 @@ case ".$INFOCMP" in
 	INFOCMP=`echo "$INFOCMP" | sed -e s%NONE%$cf_path_syntax%`
 	;;
 (*)
-	{ { echo "$as_me:8630: error: expected a pathname, not \"$INFOCMP\"" >&5
+	{ { echo "$as_me:9317: error: expected a pathname, not \"$INFOCMP\"" >&5
 echo "$as_me: error: expected a pathname, not \"$INFOCMP\"" >&2;}
    { (exit 1); exit 1; }; }
 	;;
@@ -8640,7 +9327,7 @@ for ac_prog in $INFOCMP infocmp
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:8643: checking for $ac_word" >&5
+echo "$as_me:9330: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_path_INFOCMP+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -8657,7 +9344,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   if $as_executable_p "$ac_dir/$ac_word"; then
    ac_cv_path_INFOCMP="$ac_dir/$ac_word"
-   echo "$as_me:8660: found $ac_dir/$ac_word" >&5
+   echo "$as_me:9347: found $ac_dir/$ac_word" >&5
    break
 fi
 done
@@ -8668,10 +9355,10 @@ fi
 INFOCMP=$ac_cv_path_INFOCMP
 
 if test -n "$INFOCMP"; then
-  echo "$as_me:8671: result: $INFOCMP" >&5
+  echo "$as_me:9358: result: $INFOCMP" >&5
 echo "${ECHO_T}$INFOCMP" >&6
 else
-  echo "$as_me:8674: result: no" >&5
+  echo "$as_me:9361: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -8730,7 +9417,7 @@ IFS="$cf_save_ifs"
 
 if test -n "$cf_path_prog" ; then
 
-echo "${as_me:-configure}:8733: testing defining path for ${cf_path_prog} ..." 1>&5
+echo "${as_me:-configure}:9420: testing defining path for ${cf_path_prog} ..." 1>&5
 
 cat >>confdefs.h <<EOF
 #define INFOCMP_PATH "$cf_path_prog"
@@ -8745,7 +9432,7 @@ fi
 
 		if test -z "$INFOCMP"
 		then
-			{ echo "$as_me:8748: WARNING: no infocmp program found for fallbacks" >&5
+			{ echo "$as_me:9435: WARNING: no infocmp program found for fallbacks" >&5
 echo "$as_me: WARNING: no infocmp program found for fallbacks" >&2;}
 		fi
 
@@ -8755,7 +9442,7 @@ fi;
 	test -z "$INFOCMP" && FALLBACK_LIST=
 	if test -z "$FALLBACK_LIST"
 	then
-		{ echo "$as_me:8758: WARNING: ignoring fallback option because tic/infocmp are not available" >&5
+		{ echo "$as_me:9445: WARNING: ignoring fallback option because tic/infocmp are not available" >&5
 echo "$as_me: WARNING: ignoring fallback option because tic/infocmp are not available" >&2;}
 	fi
 fi
@@ -8763,7 +9450,7 @@ fi
 USE_FALLBACKS=
 test -z "$FALLBACK_LIST" && USE_FALLBACKS="#"
 
-echo "$as_me:8766: checking if you want modern xterm or antique" >&5
+echo "$as_me:9453: checking if you want modern xterm or antique" >&5
 echo $ECHO_N "checking if you want modern xterm or antique... $ECHO_C" >&6
 
 # Check whether --with-xterm-new or --without-xterm-new was given.
@@ -8777,11 +9464,20 @@ case "$with_xterm_new" in
 (no) with_xterm_new=xterm-old;;
 (*)	 with_xterm_new=xterm-new;;
 esac
-echo "$as_me:8780: result: $with_xterm_new" >&5
+echo "$as_me:9467: result: $with_xterm_new" >&5
 echo "${ECHO_T}$with_xterm_new" >&6
 WHICH_XTERM=$with_xterm_new
 
-echo "$as_me:8784: checking if xterm backspace sends BS or DEL" >&5
+case $host_os in
+(*linux-gnu|*cygwin|*mingw32|*msys)
+	want_xterm_kbs=DEL
+	;;
+(*)
+	want_xterm_kbs=BS
+	;;
+esac
+
+echo "$as_me:9480: checking if xterm backspace sends BS or DEL" >&5
 echo $ECHO_N "checking if xterm backspace sends BS or DEL... $ECHO_C" >&6
 
 # Check whether --with-xterm-kbs or --without-xterm-kbs was given.
@@ -8789,7 +9485,7 @@ if test "${with_xterm_kbs+set}" = set; then
   withval="$with_xterm_kbs"
   with_xterm_kbs=$withval
 else
-  with_xterm_kbs=BS
+  with_xterm_kbs=auto
 fi;
 case x$with_xterm_kbs in
 (xyes|xno|xBS|xbs|x8)
@@ -8798,21 +9494,30 @@ case x$with_xterm_kbs in
 (xDEL|xdel|x127)
 	with_xterm_kbs=DEL
 	;;
+(xauto)
+	with_xterm_kbs=$want_xterm_kbs
+	;;
 (*)
 	with_xterm_kbs=$withval
 	;;
 esac
-echo "$as_me:8805: result: $with_xterm_kbs" >&5
+echo "$as_me:9504: result: $with_xterm_kbs" >&5
 echo "${ECHO_T}$with_xterm_kbs" >&6
 XTERM_KBS=$with_xterm_kbs
 
+if test "x$with_xterm_kbs" != "x$want_xterm_kbs"
+then
+	{ echo "$as_me:9510: WARNING: expected --with-xterm-kbs=$want_xterm_kbs for $host_os, have $with_xterm_kbs" >&5
+echo "$as_me: WARNING: expected --with-xterm-kbs=$want_xterm_kbs for $host_os, have $with_xterm_kbs" >&2;}
+fi
+
 MAKE_TERMINFO=
 if test "$use_database" = no ; then
 	TERMINFO="${datadir}/terminfo"
 	MAKE_TERMINFO="#"
 else
 
-echo "$as_me:8815: checking for list of terminfo directories" >&5
+echo "$as_me:9520: checking for list of terminfo directories" >&5
 echo $ECHO_N "checking for list of terminfo directories... $ECHO_C" >&6
 
 # Check whether --with-terminfo-dirs or --without-terminfo-dirs was given.
@@ -8852,7 +9557,7 @@ case ".$cf_src_path" in
 	cf_src_path=`echo "$cf_src_path" | sed -e s%NONE%$cf_path_syntax%`
 	;;
 (*)
-	{ { echo "$as_me:8855: error: expected a pathname, not \"$cf_src_path\"" >&5
+	{ { echo "$as_me:9560: error: expected a pathname, not \"$cf_src_path\"" >&5
 echo "$as_me: error: expected a pathname, not \"$cf_src_path\"" >&2;}
    { (exit 1); exit 1; }; }
 	;;
@@ -8875,7 +9580,7 @@ case "x$cf_dst_eval" in
 	;;
 esac
 
-echo "$as_me:8878: result: $TERMINFO_DIRS" >&5
+echo "$as_me:9583: result: $TERMINFO_DIRS" >&5
 echo "${ECHO_T}$TERMINFO_DIRS" >&6
 test -n "$TERMINFO_DIRS" &&
 cat >>confdefs.h <<EOF
@@ -8884,13 +9589,13 @@ EOF
 
 case "x$TERMINFO" in
 x???:*)
-	{ echo "$as_me:8887: WARNING: ignoring non-directory/file TERMINFO value" >&5
+	{ echo "$as_me:9592: WARNING: ignoring non-directory/file TERMINFO value" >&5
 echo "$as_me: WARNING: ignoring non-directory/file TERMINFO value" >&2;}
 	unset TERMINFO
 	;;
 esac
 
-echo "$as_me:8893: checking for default terminfo directory" >&5
+echo "$as_me:9598: checking for default terminfo directory" >&5
 echo $ECHO_N "checking for default terminfo directory... $ECHO_C" >&6
 
 # Check whether --with-default-terminfo-dir or --without-default-terminfo-dir was given.
@@ -8926,7 +9631,7 @@ case ".$withval" in
 	withval=`echo "$withval" | sed -e s%NONE%$cf_path_syntax%`
 	;;
 (*)
-	{ { echo "$as_me:8929: error: expected a pathname, not \"$withval\"" >&5
+	{ { echo "$as_me:9634: error: expected a pathname, not \"$withval\"" >&5
 echo "$as_me: error: expected a pathname, not \"$withval\"" >&2;}
    { (exit 1); exit 1; }; }
 	;;
@@ -8935,7 +9640,7 @@ esac
 fi
 eval TERMINFO="$withval"
 
-echo "$as_me:8938: result: $TERMINFO" >&5
+echo "$as_me:9643: result: $TERMINFO" >&5
 echo "${ECHO_T}$TERMINFO" >&6
 
 cat >>confdefs.h <<EOF
@@ -8946,7 +9651,7 @@ fi
 
 ###	use option --disable-big-core to make tic run on small machines
 ###	We need 4Mb, check if we can allocate 50% more than that.
-echo "$as_me:8949: checking if big-core option selected" >&5
+echo "$as_me:9654: checking if big-core option selected" >&5
 echo $ECHO_N "checking if big-core option selected... $ECHO_C" >&6
 
 # Check whether --enable-big-core or --disable-big-core was given.
@@ -8958,12 +9663,12 @@ else
   with_big_core=no
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 8961 "configure"
+#line 9666 "configure"
 #include "confdefs.h"
 
 #include <stdlib.h>
 #include <string.h>
-int main() {
+int main(void) {
 	unsigned long n = 6000000L;
 	char *s = malloc(n);
 	if (s != 0)
@@ -8972,15 +9677,15 @@ int main() {
 }
 _ACEOF
 rm -f "conftest$ac_exeext"
-if { (eval echo "$as_me:8975: \"$ac_link\"") >&5
+if { (eval echo "$as_me:9680: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:8978: \$? = $ac_status" >&5
+  echo "$as_me:9683: \$? = $ac_status" >&5
   (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
-  { (eval echo "$as_me:8980: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9685: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8983: \$? = $ac_status" >&5
+  echo "$as_me:9688: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   with_big_core=yes
 else
@@ -8992,7 +9697,7 @@ fi
 rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftest.$ac_ext"
 fi
 fi;
-echo "$as_me:8995: result: $with_big_core" >&5
+echo "$as_me:9700: result: $with_big_core" >&5
 echo "${ECHO_T}$with_big_core" >&6
 test "x$with_big_core" = "xyes" &&
 cat >>confdefs.h <<\EOF
@@ -9002,7 +9707,7 @@ EOF
 ### ISO C only guarantees 512-char strings, we have tables which load faster
 ### when constructed using "big" strings.  More than the C compiler, the awk
 ### program is a limit on most vendor UNIX systems.  Check that we can build.
-echo "$as_me:9005: checking if big-strings option selected" >&5
+echo "$as_me:9710: checking if big-strings option selected" >&5
 echo $ECHO_N "checking if big-strings option selected... $ECHO_C" >&6
 
 # Check whether --enable-big-strings or --disable-big-strings was given.
@@ -9026,14 +9731,14 @@ else
 	esac
 
 fi;
-echo "$as_me:9029: result: $with_big_strings" >&5
+echo "$as_me:9734: result: $with_big_strings" >&5
 echo "${ECHO_T}$with_big_strings" >&6
 
 USE_BIG_STRINGS=0
 test "x$with_big_strings" = "xyes" && USE_BIG_STRINGS=1
 
 ###	use option --enable-termcap to compile in the termcap fallback support
-echo "$as_me:9036: checking if you want termcap-fallback support" >&5
+echo "$as_me:9741: checking if you want termcap-fallback support" >&5
 echo $ECHO_N "checking if you want termcap-fallback support... $ECHO_C" >&6
 
 # Check whether --enable-termcap or --disable-termcap was given.
@@ -9043,14 +9748,14 @@ if test "${enable_termcap+set}" = set; then
 else
   with_termcap=no
 fi;
-echo "$as_me:9046: result: $with_termcap" >&5
+echo "$as_me:9751: result: $with_termcap" >&5
 echo "${ECHO_T}$with_termcap" >&6
 
 NCURSES_USE_TERMCAP=0
 if test "x$with_termcap" != "xyes" ; then
 	if test "$use_database" = no ; then
 		if test -z "$with_fallback" ; then
-			{ { echo "$as_me:9053: error: You have disabled the database w/o specifying fallbacks" >&5
+			{ { echo "$as_me:9758: error: You have disabled the database w/o specifying fallbacks" >&5
 echo "$as_me: error: You have disabled the database w/o specifying fallbacks" >&2;}
    { (exit 1); exit 1; }; }
 		fi
@@ -9063,13 +9768,13 @@ EOF
 else
 
 	if test "$with_ticlib" != no ; then
-		{ { echo "$as_me:9066: error: Options --with-ticlib and --enable-termcap cannot be combined" >&5
+		{ { echo "$as_me:9771: error: Options --with-ticlib and --enable-termcap cannot be combined" >&5
 echo "$as_me: error: Options --with-ticlib and --enable-termcap cannot be combined" >&2;}
    { (exit 1); exit 1; }; }
 	fi
 
 	NCURSES_USE_TERMCAP=1
-	echo "$as_me:9072: checking for list of termcap files" >&5
+	echo "$as_me:9777: checking for list of termcap files" >&5
 echo $ECHO_N "checking for list of termcap files... $ECHO_C" >&6
 
 # Check whether --with-termpath or --without-termpath was given.
@@ -9109,7 +9814,7 @@ case ".$cf_src_path" in
 	cf_src_path=`echo "$cf_src_path" | sed -e s%NONE%$cf_path_syntax%`
 	;;
 (*)
-	{ { echo "$as_me:9112: error: expected a pathname, not \"$cf_src_path\"" >&5
+	{ { echo "$as_me:9817: error: expected a pathname, not \"$cf_src_path\"" >&5
 echo "$as_me: error: expected a pathname, not \"$cf_src_path\"" >&2;}
    { (exit 1); exit 1; }; }
 	;;
@@ -9132,7 +9837,7 @@ case "x$cf_dst_eval" in
 	;;
 esac
 
-	echo "$as_me:9135: result: $TERMPATH" >&5
+	echo "$as_me:9840: result: $TERMPATH" >&5
 echo "${ECHO_T}$TERMPATH" >&6
 	test -n "$TERMPATH" &&
 cat >>confdefs.h <<EOF
@@ -9140,7 +9845,7 @@ cat >>confdefs.h <<EOF
 EOF
 
 	###	use option --enable-getcap to use a hacked getcap for reading termcaps
-	echo "$as_me:9143: checking if fast termcap-loader is needed" >&5
+	echo "$as_me:9848: checking if fast termcap-loader is needed" >&5
 echo $ECHO_N "checking if fast termcap-loader is needed... $ECHO_C" >&6
 
 # Check whether --enable-getcap or --disable-getcap was given.
@@ -9150,14 +9855,14 @@ if test "${enable_getcap+set}" = set; then
 else
   with_getcap=no
 fi;
-	echo "$as_me:9153: result: $with_getcap" >&5
+	echo "$as_me:9858: result: $with_getcap" >&5
 echo "${ECHO_T}$with_getcap" >&6
 	test "x$with_getcap" = "xyes" &&
 cat >>confdefs.h <<\EOF
 #define USE_GETCAP 1
 EOF
 
-	echo "$as_me:9160: checking if translated termcaps will be cached in ~/.terminfo" >&5
+	echo "$as_me:9865: checking if translated termcaps will be cached in ~/.terminfo" >&5
 echo $ECHO_N "checking if translated termcaps will be cached in ~/.terminfo... $ECHO_C" >&6
 
 # Check whether --enable-getcap-cache or --disable-getcap-cache was given.
@@ -9167,7 +9872,7 @@ if test "${enable_getcap_cache+set}" = set; then
 else
   with_getcap_cache=no
 fi;
-	echo "$as_me:9170: result: $with_getcap_cache" >&5
+	echo "$as_me:9875: result: $with_getcap_cache" >&5
 echo "${ECHO_T}$with_getcap_cache" >&6
 	test "x$with_getcap_cache" = "xyes" &&
 cat >>confdefs.h <<\EOF
@@ -9177,7 +9882,7 @@ EOF
 fi
 
 ###   Use option --disable-home-terminfo to completely remove ~/.terminfo
-echo "$as_me:9180: checking if ~/.terminfo is wanted" >&5
+echo "$as_me:9885: checking if ~/.terminfo is wanted" >&5
 echo $ECHO_N "checking if ~/.terminfo is wanted... $ECHO_C" >&6
 
 # Check whether --enable-home-terminfo or --disable-home-terminfo was given.
@@ -9187,15 +9892,15 @@ if test "${enable_home_terminfo+set}" = set; then
 else
   with_home_terminfo=yes
 fi;
-echo "$as_me:9190: result: $with_home_terminfo" >&5
+echo "$as_me:9895: result: $with_home_terminfo" >&5
 echo "${ECHO_T}$with_home_terminfo" >&6
 test "x$with_home_terminfo" = "xyes" &&
 cat >>confdefs.h <<\EOF
 #define USE_HOME_TERMINFO 1
 EOF
 
-echo "$as_me:9197: checking if you want to use restricted environment when running as root" >&5
-echo $ECHO_N "checking if you want to use restricted environment when running as root... $ECHO_C" >&6
+echo "$as_me:9902: checking if you want to permit root to use ncurses environment variables" >&5
+echo $ECHO_N "checking if you want to permit root to use ncurses environment variables... $ECHO_C" >&6
 
 # Check whether --enable-root-environ or --disable-root-environ was given.
 if test "${enable_root_environ+set}" = set; then
@@ -9204,13 +9909,47 @@ if test "${enable_root_environ+set}" = set; then
 else
   with_root_environ=yes
 fi;
-echo "$as_me:9207: result: $with_root_environ" >&5
+echo "$as_me:9912: result: $with_root_environ" >&5
 echo "${ECHO_T}$with_root_environ" >&6
 test "x$with_root_environ" = xyes &&
 cat >>confdefs.h <<\EOF
 #define USE_ROOT_ENVIRON 1
 EOF
 
+echo "$as_me:9919: checking if you want to permit setuid programs to access all files" >&5
+echo $ECHO_N "checking if you want to permit setuid programs to access all files... $ECHO_C" >&6
+
+# Check whether --enable-root-access or --disable-root-access was given.
+if test "${enable_root_access+set}" = set; then
+  enableval="$enable_root_access"
+  with_root_access=$enableval
+else
+  with_root_access=yes
+fi;
+echo "$as_me:9929: result: $with_root_access" >&5
+echo "${ECHO_T}$with_root_access" >&6
+test "x$with_root_access" = xyes &&
+cat >>confdefs.h <<\EOF
+#define USE_ROOT_ACCESS 1
+EOF
+
+echo "$as_me:9936: checking if you want to permit setuid use of ncurses environment variables" >&5
+echo $ECHO_N "checking if you want to permit setuid use of ncurses environment variables... $ECHO_C" >&6
+
+# Check whether --enable-setuid-environ or --disable-setuid-environ was given.
+if test "${enable_setuid_environ+set}" = set; then
+  enableval="$enable_setuid_environ"
+  with_setuid_environ=$enableval
+else
+  with_setuid_environ=$with_root_environ
+fi;
+echo "$as_me:9946: result: $with_setuid_environ" >&5
+echo "${ECHO_T}$with_setuid_environ" >&6
+test "x$with_setuid_environ" = xyes &&
+cat >>confdefs.h <<\EOF
+#define USE_SETUID_ENVIRON 1
+EOF
+
 ###   Use option --enable-symlinks to make tic use symlinks, not hard links
 ###   to reduce storage requirements for the terminfo database.
 
@@ -9219,23 +9958,23 @@ unistd.h \
 
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:9222: checking for $ac_header" >&5
+echo "$as_me:9961: checking for $ac_header" >&5
 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 9228 "configure"
+#line 9967 "configure"
 #include "confdefs.h"
 #include <$ac_header>
 _ACEOF
-if { (eval echo "$as_me:9232: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+if { (eval echo "$as_me:9971: \"$ac_cpp "conftest.$ac_ext"\"") >&5
   (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:9238: \$? = $ac_status" >&5
+  echo "$as_me:9977: \$? = $ac_status" >&5
   (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -9254,7 +9993,7 @@ else
 fi
 rm -f conftest.err "conftest.$ac_ext"
 fi
-echo "$as_me:9257: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
+echo "$as_me:9996: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
 echo "${ECHO_T}`eval echo '${'"$as_ac_Header"'}'`" >&6
 if test "`eval echo '${'"$as_ac_Header"'}'`" = yes; then
   cat >>confdefs.h <<EOF
@@ -9269,13 +10008,13 @@ for ac_func in \
 	unlink
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:9272: checking for $ac_func" >&5
+echo "$as_me:10011: checking for $ac_func" >&5
 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
 if eval "test \"\${$as_ac_var+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 9278 "configure"
+#line 10017 "configure"
 #include "confdefs.h"
 #define $ac_func autoconf_temporary
 #include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
@@ -9306,16 +10045,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:9309: \"$ac_link\"") >&5
+if { (eval echo "$as_me:10048: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:9312: \$? = $ac_status" >&5
+  echo "$as_me:10051: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:9315: \"$ac_try\"") >&5
+  { (eval echo "$as_me:10054: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9318: \$? = $ac_status" >&5
+  echo "$as_me:10057: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   eval "$as_ac_var=yes"
 else
@@ -9325,7 +10064,7 @@ eval "$as_ac_var=no"
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:9328: result: `eval echo '${'"$as_ac_var"'}'`" >&5
+echo "$as_me:10067: result: `eval echo '${'"$as_ac_var"'}'`" >&5
 echo "${ECHO_T}`eval echo '${'"$as_ac_var"'}'`" >&6
 if test "`eval echo '${'"$as_ac_var"'}'`" = yes; then
   cat >>confdefs.h <<EOF
@@ -9342,13 +10081,13 @@ for ac_func in \
 		symlink
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:9345: checking for $ac_func" >&5
+echo "$as_me:10084: checking for $ac_func" >&5
 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
 if eval "test \"\${$as_ac_var+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 9351 "configure"
+#line 10090 "configure"
 #include "confdefs.h"
 #define $ac_func autoconf_temporary
 #include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
@@ -9379,16 +10118,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:9382: \"$ac_link\"") >&5
+if { (eval echo "$as_me:10121: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:9385: \$? = $ac_status" >&5
+  echo "$as_me:10124: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:9388: \"$ac_try\"") >&5
+  { (eval echo "$as_me:10127: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9391: \$? = $ac_status" >&5
+  echo "$as_me:10130: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   eval "$as_ac_var=yes"
 else
@@ -9398,7 +10137,7 @@ eval "$as_ac_var=no"
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:9401: result: `eval echo '${'"$as_ac_var"'}'`" >&5
+echo "$as_me:10140: result: `eval echo '${'"$as_ac_var"'}'`" >&5
 echo "${ECHO_T}`eval echo '${'"$as_ac_var"'}'`" >&6
 if test "`eval echo '${'"$as_ac_var"'}'`" = yes; then
   cat >>confdefs.h <<EOF
@@ -9409,7 +10148,7 @@ fi
 done
 
 else
-	echo "$as_me:9412: checking if link/symlink functions work" >&5
+	echo "$as_me:10151: checking if link/symlink functions work" >&5
 echo $ECHO_N "checking if link/symlink functions work... $ECHO_C" >&6
 if test "${cf_cv_link_funcs+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -9422,45 +10161,49 @@ else
 			eval 'ac_cv_func_'$cf_func'=error'
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 9425 "configure"
+#line 10164 "configure"
 #include "confdefs.h"
 
-#include <sys/types.h>
-#include <sys/stat.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
+$ac_includes_default
+
 int main(void)
 {
 	int fail = 0;
-	char *src = "config.log";
-	char *dst = "conftest.chk";
-	struct stat src_sb;
-	struct stat dst_sb;
-
-	stat(src, &src_sb);
-	fail = ($cf_func("config.log", "conftest.chk") < 0)
-	    || (stat(dst, &dst_sb) < 0)
-	    || (dst_sb.st_mtime != src_sb.st_mtime);
+	char src[] = "conftest.tmp";
+	char dst[] = "conftest.chk";
+	struct stat src_sb, dst_sb;
+	FILE *fp = fopen(src, "w");
+	if (fp == 0) { fail = 3; } else {
+		fclose(fp); stat(src, &src_sb);
+		if ($cf_func(src, dst) < 0) {
+			fail = 1;
+		} else if (stat(dst, &dst_sb) < 0) {
+			fail = 2;
+		} else {
+			long diff = (dst_sb.st_mtime - src_sb.st_mtime);
+			if (diff < 0) diff = -diff;
+			if (diff > 2) fail = 3;
+		}
+	}
 #ifdef HAVE_UNLINK
-	unlink(dst);
+	unlink(dst); unlink(src);
 #else
-	remove(dst);
+	remove(dst); remove(src);
 #endif
 	${cf_cv_main_return:-return} (fail);
 }
 
 _ACEOF
 rm -f "conftest$ac_exeext"
-if { (eval echo "$as_me:9455: \"$ac_link\"") >&5
+if { (eval echo "$as_me:10198: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:9458: \$? = $ac_status" >&5
+  echo "$as_me:10201: \$? = $ac_status" >&5
   (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
-  { (eval echo "$as_me:9460: \"$ac_try\"") >&5
+  { (eval echo "$as_me:10203: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9463: \$? = $ac_status" >&5
+  echo "$as_me:10206: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
 
 			cf_cv_link_funcs="$cf_cv_link_funcs $cf_func"
@@ -9478,7 +10221,7 @@ fi
 		test -z "$cf_cv_link_funcs" && cf_cv_link_funcs=no
 
 fi
-echo "$as_me:9481: result: $cf_cv_link_funcs" >&5
+echo "$as_me:10224: result: $cf_cv_link_funcs" >&5
 echo "${ECHO_T}$cf_cv_link_funcs" >&6
 	test "$ac_cv_func_link"    = yes &&
 cat >>confdefs.h <<\EOF
@@ -9498,7 +10241,7 @@ with_symlinks=no
 # soft links (symbolic links) are useful for some systems where hard links do
 # not work, or to make it simpler to copy terminfo trees around.
 if test "x$ac_cv_func_symlink" = xyes ; then
-	echo "$as_me:9501: checking if tic should use symbolic links" >&5
+	echo "$as_me:10244: checking if tic should use symbolic links" >&5
 echo $ECHO_N "checking if tic should use symbolic links... $ECHO_C" >&6
 
 # Check whether --enable-symlinks or --disable-symlinks was given.
@@ -9508,21 +10251,21 @@ if test "${enable_symlinks+set}" = set; then
 else
   with_symlinks=no
 fi;
-	echo "$as_me:9511: result: $with_symlinks" >&5
+	echo "$as_me:10254: result: $with_symlinks" >&5
 echo "${ECHO_T}$with_symlinks" >&6
 fi
 
 # If we have hard links and did not choose to use soft links instead, there is
 # no reason to make this choice optional - use the hard links.
 if test "$with_symlinks" = no ; then
-	echo "$as_me:9518: checking if tic should use hard links" >&5
+	echo "$as_me:10261: checking if tic should use hard links" >&5
 echo $ECHO_N "checking if tic should use hard links... $ECHO_C" >&6
 	if test "x$ac_cv_func_link" = xyes ; then
 		with_links=yes
 	else
 		with_links=no
 	fi
-	echo "$as_me:9525: result: $with_links" >&5
+	echo "$as_me:10268: result: $with_links" >&5
 echo "${ECHO_T}$with_links" >&6
 fi
 
@@ -9538,7 +10281,7 @@ EOF
 
 ###   use option --enable-broken-linker to force on use of broken-linker support
 
-echo "$as_me:9541: checking if you want broken-linker support code" >&5
+echo "$as_me:10284: checking if you want broken-linker support code" >&5
 echo $ECHO_N "checking if you want broken-linker support code... $ECHO_C" >&6
 
 # Check whether --enable-broken_linker or --disable-broken_linker was given.
@@ -9548,7 +10291,7 @@ if test "${enable_broken_linker+set}" = set; then
 else
   with_broken_linker=no
 fi;
-echo "$as_me:9551: result: $with_broken_linker" >&5
+echo "$as_me:10294: result: $with_broken_linker" >&5
 echo "${ECHO_T}$with_broken_linker" >&6
 
 : "${BROKEN_LINKER:=0}"
@@ -9562,7 +10305,7 @@ EOF
 fi
 
 ###   use option --enable-bsdpad to have tputs process BSD-style prefix padding
-echo "$as_me:9565: checking if tputs should process BSD-style prefix padding" >&5
+echo "$as_me:10308: checking if tputs should process BSD-style prefix padding" >&5
 echo $ECHO_N "checking if tputs should process BSD-style prefix padding... $ECHO_C" >&6
 
 # Check whether --enable-bsdpad or --disable-bsdpad was given.
@@ -9572,7 +10315,7 @@ if test "${enable_bsdpad+set}" = set; then
 else
   with_bsdpad=no
 fi;
-echo "$as_me:9575: result: $with_bsdpad" >&5
+echo "$as_me:10318: result: $with_bsdpad" >&5
 echo "${ECHO_T}$with_bsdpad" >&6
 test "x$with_bsdpad" = xyes &&
 cat >>confdefs.h <<\EOF
@@ -9591,14 +10334,14 @@ NCURSES_WINT_T=0
 # Check to define _XOPEN_SOURCE "automatically"
 CPPFLAGS_before_XOPEN="$CPPFLAGS"
 
-echo "$as_me:9594: checking if the POSIX test-macros are already defined" >&5
+echo "$as_me:10337: checking if the POSIX test-macros are already defined" >&5
 echo $ECHO_N "checking if the POSIX test-macros are already defined... $ECHO_C" >&6
 if test "${cf_cv_posix_visible+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 9601 "configure"
+#line 10344 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int
@@ -9617,16 +10360,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:9620: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:10363: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:9623: \$? = $ac_status" >&5
+  echo "$as_me:10366: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:9626: \"$ac_try\"") >&5
+  { (eval echo "$as_me:10369: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9629: \$? = $ac_status" >&5
+  echo "$as_me:10372: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_posix_visible=no
 else
@@ -9637,7 +10380,7 @@ fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 
 fi
-echo "$as_me:9640: result: $cf_cv_posix_visible" >&5
+echo "$as_me:10383: result: $cf_cv_posix_visible" >&5
 echo "${ECHO_T}$cf_cv_posix_visible" >&6
 
 if test "$cf_cv_posix_visible" = no; then
@@ -9650,9 +10393,6 @@ case "$host_os" in
 (aix[4-7]*)
 	cf_xopen_source="-D_ALL_SOURCE"
 	;;
-(msys)
-	cf_XOPEN_SOURCE=600
-	;;
 (darwin[0-8].*)
 	cf_xopen_source="-D_APPLE_C_SOURCE"
 	;;
@@ -9678,18 +10418,18 @@ case "$host_os" in
 	cf_xopen_source="-D_SGI_SOURCE"
 	cf_XOPEN_SOURCE=
 	;;
-(linux*|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin)
+(linux*gnu|linux*gnuabi64|linux*gnuabin32|linux*gnueabi|linux*gnueabihf|linux*gnux32|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin|msys|mingw*|linux*uclibc)
 
 cf_gnu_xopen_source=$cf_XOPEN_SOURCE
 
-echo "$as_me:9685: checking if this is the GNU C library" >&5
+echo "$as_me:10425: checking if this is the GNU C library" >&5
 echo $ECHO_N "checking if this is the GNU C library... $ECHO_C" >&6
 if test "${cf_cv_gnu_library+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 9692 "configure"
+#line 10432 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 int
@@ -9708,16 +10448,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:9711: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:10451: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:9714: \$? = $ac_status" >&5
+  echo "$as_me:10454: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:9717: \"$ac_try\"") >&5
+  { (eval echo "$as_me:10457: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9720: \$? = $ac_status" >&5
+  echo "$as_me:10460: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_gnu_library=yes
 else
@@ -9728,7 +10468,7 @@ fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 
 fi
-echo "$as_me:9731: result: $cf_cv_gnu_library" >&5
+echo "$as_me:10471: result: $cf_cv_gnu_library" >&5
 echo "${ECHO_T}$cf_cv_gnu_library" >&6
 
 if test x$cf_cv_gnu_library = xyes; then
@@ -9736,7 +10476,7 @@ if test x$cf_cv_gnu_library = xyes; then
 	# With glibc 2.19 (13 years after this check was begun), _DEFAULT_SOURCE
 	# was changed to help a little.  newlib incorporated the change about 4
 	# years later.
-	echo "$as_me:9739: checking if _DEFAULT_SOURCE can be used as a basis" >&5
+	echo "$as_me:10479: checking if _DEFAULT_SOURCE can be used as a basis" >&5
 echo $ECHO_N "checking if _DEFAULT_SOURCE can be used as a basis... $ECHO_C" >&6
 if test "${cf_cv_gnu_library_219+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -9748,7 +10488,7 @@ else
 	CPPFLAGS="${CPPFLAGS}-D_DEFAULT_SOURCE"
 
 		cat >"conftest.$ac_ext" <<_ACEOF
-#line 9751 "configure"
+#line 10491 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 int
@@ -9767,16 +10507,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:9770: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:10510: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:9773: \$? = $ac_status" >&5
+  echo "$as_me:10513: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:9776: \"$ac_try\"") >&5
+  { (eval echo "$as_me:10516: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9779: \$? = $ac_status" >&5
+  echo "$as_me:10519: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_gnu_library_219=yes
 else
@@ -9788,12 +10528,12 @@ rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 		CPPFLAGS="$cf_save"
 
 fi
-echo "$as_me:9791: result: $cf_cv_gnu_library_219" >&5
+echo "$as_me:10531: result: $cf_cv_gnu_library_219" >&5
 echo "${ECHO_T}$cf_cv_gnu_library_219" >&6
 
 	if test "x$cf_cv_gnu_library_219" = xyes; then
 		cf_save="$CPPFLAGS"
-		echo "$as_me:9796: checking if _XOPEN_SOURCE=$cf_gnu_xopen_source works with _DEFAULT_SOURCE" >&5
+		echo "$as_me:10536: checking if _XOPEN_SOURCE=$cf_gnu_xopen_source works with _DEFAULT_SOURCE" >&5
 echo $ECHO_N "checking if _XOPEN_SOURCE=$cf_gnu_xopen_source works with _DEFAULT_SOURCE... $ECHO_C" >&6
 if test "${cf_cv_gnu_dftsrc_219+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -9898,7 +10638,7 @@ if test -n "$cf_new_extra_cppflags" ; then
 fi
 
 			cat >"conftest.$ac_ext" <<_ACEOF
-#line 9901 "configure"
+#line 10641 "configure"
 #include "confdefs.h"
 
 				#include <limits.h>
@@ -9918,16 +10658,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:9921: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:10661: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:9924: \$? = $ac_status" >&5
+  echo "$as_me:10664: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:9927: \"$ac_try\"") >&5
+  { (eval echo "$as_me:10667: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9930: \$? = $ac_status" >&5
+  echo "$as_me:10670: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_gnu_dftsrc_219=yes
 else
@@ -9938,7 +10678,7 @@ fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 
 fi
-echo "$as_me:9941: result: $cf_cv_gnu_dftsrc_219" >&5
+echo "$as_me:10681: result: $cf_cv_gnu_dftsrc_219" >&5
 echo "${ECHO_T}$cf_cv_gnu_dftsrc_219" >&6
 		test "x$cf_cv_gnu_dftsrc_219" = "xyes" || CPPFLAGS="$cf_save"
 	else
@@ -9947,14 +10687,14 @@ echo "${ECHO_T}$cf_cv_gnu_dftsrc_219" >&6
 
 	if test "x$cf_cv_gnu_dftsrc_219" != xyes; then
 
-		echo "$as_me:9950: checking if we must define _GNU_SOURCE" >&5
+		echo "$as_me:10690: checking if we must define _GNU_SOURCE" >&5
 echo $ECHO_N "checking if we must define _GNU_SOURCE... $ECHO_C" >&6
 if test "${cf_cv_gnu_source+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 		cat >"conftest.$ac_ext" <<_ACEOF
-#line 9957 "configure"
+#line 10697 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 int
@@ -9969,16 +10709,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:9972: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:10712: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:9975: \$? = $ac_status" >&5
+  echo "$as_me:10715: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:9978: \"$ac_try\"") >&5
+  { (eval echo "$as_me:10718: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9981: \$? = $ac_status" >&5
+  echo "$as_me:10721: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_gnu_source=no
 else
@@ -10085,7 +10825,7 @@ if test -n "$cf_new_extra_cppflags" ; then
 fi
 
 			 cat >"conftest.$ac_ext" <<_ACEOF
-#line 10088 "configure"
+#line 10828 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 int
@@ -10100,16 +10840,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:10103: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:10843: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:10106: \$? = $ac_status" >&5
+  echo "$as_me:10846: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:10109: \"$ac_try\"") >&5
+  { (eval echo "$as_me:10849: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10112: \$? = $ac_status" >&5
+  echo "$as_me:10852: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_gnu_source=no
 else
@@ -10124,12 +10864,12 @@ fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 
 fi
-echo "$as_me:10127: result: $cf_cv_gnu_source" >&5
+echo "$as_me:10867: result: $cf_cv_gnu_source" >&5
 echo "${ECHO_T}$cf_cv_gnu_source" >&6
 
 		if test "$cf_cv_gnu_source" = yes
 		then
-		echo "$as_me:10132: checking if we should also define _DEFAULT_SOURCE" >&5
+		echo "$as_me:10872: checking if we should also define _DEFAULT_SOURCE" >&5
 echo $ECHO_N "checking if we should also define _DEFAULT_SOURCE... $ECHO_C" >&6
 if test "${cf_cv_default_source+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -10139,7 +10879,7 @@ else
 	CPPFLAGS="${CPPFLAGS}-D_GNU_SOURCE"
 
 			cat >"conftest.$ac_ext" <<_ACEOF
-#line 10142 "configure"
+#line 10882 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 int
@@ -10154,16 +10894,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:10157: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:10897: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:10160: \$? = $ac_status" >&5
+  echo "$as_me:10900: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:10163: \"$ac_try\"") >&5
+  { (eval echo "$as_me:10903: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10166: \$? = $ac_status" >&5
+  echo "$as_me:10906: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_default_source=no
 else
@@ -10174,7 +10914,7 @@ fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 
 fi
-echo "$as_me:10177: result: $cf_cv_default_source" >&5
+echo "$as_me:10917: result: $cf_cv_default_source" >&5
 echo "${ECHO_T}$cf_cv_default_source" >&6
 			if test "$cf_cv_default_source" = yes
 			then
@@ -10211,16 +10951,16 @@ cf_trim_CPPFLAGS=`echo "$cf_save_CPPFLAGS" | \
 	sed	-e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ 	]*\)\?[ 	]/ /g' \
 		-e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ 	]*\)\?$//g'`
 
-echo "$as_me:10214: checking if we should define _POSIX_C_SOURCE" >&5
+echo "$as_me:10954: checking if we should define _POSIX_C_SOURCE" >&5
 echo $ECHO_N "checking if we should define _POSIX_C_SOURCE... $ECHO_C" >&6
 if test "${cf_cv_posix_c_source+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-echo "${as_me:-configure}:10220: testing if the symbol is already defined go no further ..." 1>&5
+echo "${as_me:-configure}:10960: testing if the symbol is already defined go no further ..." 1>&5
 
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 10223 "configure"
+#line 10963 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 int
@@ -10228,23 +10968,23 @@ main (void)
 {
 
 #ifndef _POSIX_C_SOURCE
-make an error
+#error _POSIX_C_SOURCE is not defined
 #endif
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:10238: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:10978: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:10241: \$? = $ac_status" >&5
+  echo "$as_me:10981: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:10244: \"$ac_try\"") >&5
+  { (eval echo "$as_me:10984: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10247: \$? = $ac_status" >&5
+  echo "$as_me:10987: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_posix_c_source=no
 else
@@ -10265,7 +11005,7 @@ cf_want_posix_source=no
 	 esac
 	 if test "$cf_want_posix_source" = yes ; then
 		cat >"conftest.$ac_ext" <<_ACEOF
-#line 10268 "configure"
+#line 11008 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 int
@@ -10273,23 +11013,23 @@ main (void)
 {
 
 #ifdef _POSIX_SOURCE
-make an error
+#error _POSIX_SOURCE is defined
 #endif
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:10283: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:11023: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:10286: \$? = $ac_status" >&5
+  echo "$as_me:11026: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:10289: \"$ac_try\"") >&5
+  { (eval echo "$as_me:11029: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10292: \$? = $ac_status" >&5
+  echo "$as_me:11032: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   :
 else
@@ -10300,7 +11040,7 @@ fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 	 fi
 
-echo "${as_me:-configure}:10303: testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5
+echo "${as_me:-configure}:11043: testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5
 
 	 CFLAGS="$cf_trim_CFLAGS"
 	 CPPFLAGS="$cf_trim_CPPFLAGS"
@@ -10308,10 +11048,10 @@ echo "${as_me:-configure}:10303: testing ifdef from value $cf_POSIX_C_SOURCE ...
 	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
 	CPPFLAGS="${CPPFLAGS}$cf_cv_posix_c_source"
 
-echo "${as_me:-configure}:10311: testing if the second compile does not leave our definition intact error ..." 1>&5
+echo "${as_me:-configure}:11051: testing if the second compile does not leave our definition intact error ..." 1>&5
 
 	 cat >"conftest.$ac_ext" <<_ACEOF
-#line 10314 "configure"
+#line 11054 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 int
@@ -10319,23 +11059,23 @@ main (void)
 {
 
 #ifndef _POSIX_C_SOURCE
-make an error
+#error _POSIX_C_SOURCE is not defined
 #endif
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:10329: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:11069: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:10332: \$? = $ac_status" >&5
+  echo "$as_me:11072: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:10335: \"$ac_try\"") >&5
+  { (eval echo "$as_me:11075: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10338: \$? = $ac_status" >&5
+  echo "$as_me:11078: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   :
 else
@@ -10351,7 +11091,7 @@ fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 
 fi
-echo "$as_me:10354: result: $cf_cv_posix_c_source" >&5
+echo "$as_me:11094: result: $cf_cv_posix_c_source" >&5
 echo "${ECHO_T}$cf_cv_posix_c_source" >&6
 
 if test "$cf_cv_posix_c_source" != no ; then
@@ -10464,7 +11204,16 @@ fi # cf_cv_posix_visible
 (netbsd*)
 	cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
 	;;
-(openbsd[4-9]*)
+(openbsd[6-9]*)
+	# OpenBSD 6.x has broken locale support, both compile-time and runtime.
+	# see https://www.mail-archive.com/bugs@openbsd.org/msg13200.html
+	# Abusing the conformance level is a workaround.
+	{ echo "$as_me:11211: WARNING: this system does not provide usable locale support" >&5
+echo "$as_me: WARNING: this system does not provide usable locale support" >&2;}
+	cf_xopen_source="-D_BSD_SOURCE"
+	cf_XOPEN_SOURCE=700
+	;;
+(openbsd[4-5]*)
 	# setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
 	cf_xopen_source="-D_BSD_SOURCE"
 	cf_XOPEN_SOURCE=600
@@ -10491,42 +11240,41 @@ fi # cf_cv_posix_visible
 	;;
 (*)
 
-echo "$as_me:10494: checking if we should define _XOPEN_SOURCE" >&5
+echo "$as_me:11243: checking if we should define _XOPEN_SOURCE" >&5
 echo $ECHO_N "checking if we should define _XOPEN_SOURCE... $ECHO_C" >&6
 if test "${cf_cv_xopen_source+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 10501 "configure"
+#line 11250 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
+$ac_includes_default
 
 int
 main (void)
 {
 
 #ifndef _XOPEN_SOURCE
-make an error
+#error _XOPEN_SOURCE is not defined
 #endif
+
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:10520: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:11268: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:10523: \$? = $ac_status" >&5
+  echo "$as_me:11271: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:10526: \"$ac_try\"") >&5
+  { (eval echo "$as_me:11274: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10529: \$? = $ac_status" >&5
+  echo "$as_me:11277: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_xopen_source=no
 else
@@ -10538,35 +11286,34 @@ cf_save="$CPPFLAGS"
 	CPPFLAGS="${CPPFLAGS}-D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
 
 	 cat >"conftest.$ac_ext" <<_ACEOF
-#line 10541 "configure"
+#line 11289 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
+$ac_includes_default
 
 int
 main (void)
 {
 
-#ifdef _XOPEN_SOURCE
-make an error
+#ifndef _XOPEN_SOURCE
+#error _XOPEN_SOURCE is not defined
 #endif
+
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:10560: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:11307: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:10563: \$? = $ac_status" >&5
+  echo "$as_me:11310: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:10566: \"$ac_try\"") >&5
+  { (eval echo "$as_me:11313: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10569: \$? = $ac_status" >&5
+  echo "$as_me:11316: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_xopen_source=no
 else
@@ -10575,13 +11322,13 @@ cat "conftest.$ac_ext" >&5
 cf_cv_xopen_source=$cf_XOPEN_SOURCE
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
-	CPPFLAGS="$cf_save"
+		CPPFLAGS="$cf_save"
 
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 
 fi
-echo "$as_me:10584: result: $cf_cv_xopen_source" >&5
+echo "$as_me:11331: result: $cf_cv_xopen_source" >&5
 echo "${ECHO_T}$cf_cv_xopen_source" >&6
 
 if test "$cf_cv_xopen_source" != no ; then
@@ -10596,12 +11343,38 @@ CPPFLAGS=`echo "$CPPFLAGS" | \
 
 	cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
 
+for cf_add_cflags in $cf_temp_xopen_source
+do
+	case "x$cf_add_cflags" in
+	(x-[DU]*)
+
+cf_tmp_cflag=`echo "x$cf_add_cflags" | sed -e 's/^.//' -e 's/=.*//'`
+while true
+do
+	cf_old_cflag=`echo "x$CFLAGS" | sed -e 's/^.//' -e 's/[ 	][ 	]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[^ 	][^ 	]*\\)\?%%" -e 's/^[ 	]*//' -e 's%[ ][ ]*-D% -D%g' -e 's%[ ][ ]*-I% -I%g'`
+	test "$CFLAGS" != "$cf_old_cflag" || break
+
+	CFLAGS="$cf_old_cflag"
+done
+
+cf_tmp_cflag=`echo "x$cf_add_cflags" | sed -e 's/^.//' -e 's/=.*//'`
+while true
+do
+	cf_old_cflag=`echo "x$CPPFLAGS" | sed -e 's/^.//' -e 's/[ 	][ 	]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[^ 	][^ 	]*\\)\?%%" -e 's/^[ 	]*//' -e 's%[ ][ ]*-D% -D%g' -e 's%[ ][ ]*-I% -I%g'`
+	test "$CPPFLAGS" != "$cf_old_cflag" || break
+
+	CPPFLAGS="$cf_old_cflag"
+done
+
+		;;
+	esac
+
 cf_fix_cppflags=no
 cf_new_cflags=
 cf_new_cppflags=
 cf_new_extra_cppflags=
 
-for cf_add_cflags in $cf_temp_xopen_source
+for cf_add_cflags in $cf_add_cflags
 do
 case "$cf_fix_cppflags" in
 (no)
@@ -10694,8 +11467,12 @@ if test -n "$cf_new_extra_cppflags" ; then
 
 fi
 
+done
+
 fi
 
+	cf_save_xopen_cppflags="$CPPFLAGS"
+
 if test "$cf_cv_posix_visible" = no; then
 
 cf_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE
@@ -10711,16 +11488,16 @@ cf_trim_CPPFLAGS=`echo "$cf_save_CPPFLAGS" | \
 	sed	-e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ 	]*\)\?[ 	]/ /g' \
 		-e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ 	]*\)\?$//g'`
 
-echo "$as_me:10714: checking if we should define _POSIX_C_SOURCE" >&5
+echo "$as_me:11491: checking if we should define _POSIX_C_SOURCE" >&5
 echo $ECHO_N "checking if we should define _POSIX_C_SOURCE... $ECHO_C" >&6
 if test "${cf_cv_posix_c_source+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-echo "${as_me:-configure}:10720: testing if the symbol is already defined go no further ..." 1>&5
+echo "${as_me:-configure}:11497: testing if the symbol is already defined go no further ..." 1>&5
 
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 10723 "configure"
+#line 11500 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 int
@@ -10728,23 +11505,23 @@ main (void)
 {
 
 #ifndef _POSIX_C_SOURCE
-make an error
+#error _POSIX_C_SOURCE is not defined
 #endif
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:10738: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:11515: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:10741: \$? = $ac_status" >&5
+  echo "$as_me:11518: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:10744: \"$ac_try\"") >&5
+  { (eval echo "$as_me:11521: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10747: \$? = $ac_status" >&5
+  echo "$as_me:11524: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_posix_c_source=no
 else
@@ -10765,7 +11542,7 @@ cf_want_posix_source=no
 	 esac
 	 if test "$cf_want_posix_source" = yes ; then
 		cat >"conftest.$ac_ext" <<_ACEOF
-#line 10768 "configure"
+#line 11545 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 int
@@ -10773,23 +11550,23 @@ main (void)
 {
 
 #ifdef _POSIX_SOURCE
-make an error
+#error _POSIX_SOURCE is defined
 #endif
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:10783: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:11560: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:10786: \$? = $ac_status" >&5
+  echo "$as_me:11563: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:10789: \"$ac_try\"") >&5
+  { (eval echo "$as_me:11566: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10792: \$? = $ac_status" >&5
+  echo "$as_me:11569: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   :
 else
@@ -10800,7 +11577,7 @@ fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 	 fi
 
-echo "${as_me:-configure}:10803: testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5
+echo "${as_me:-configure}:11580: testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5
 
 	 CFLAGS="$cf_trim_CFLAGS"
 	 CPPFLAGS="$cf_trim_CPPFLAGS"
@@ -10808,10 +11585,10 @@ echo "${as_me:-configure}:10803: testing ifdef from value $cf_POSIX_C_SOURCE ...
 	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
 	CPPFLAGS="${CPPFLAGS}$cf_cv_posix_c_source"
 
-echo "${as_me:-configure}:10811: testing if the second compile does not leave our definition intact error ..." 1>&5
+echo "${as_me:-configure}:11588: testing if the second compile does not leave our definition intact error ..." 1>&5
 
 	 cat >"conftest.$ac_ext" <<_ACEOF
-#line 10814 "configure"
+#line 11591 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 int
@@ -10819,23 +11596,23 @@ main (void)
 {
 
 #ifndef _POSIX_C_SOURCE
-make an error
+#error _POSIX_C_SOURCE is not defined
 #endif
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:10829: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:11606: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:10832: \$? = $ac_status" >&5
+  echo "$as_me:11609: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:10835: \"$ac_try\"") >&5
+  { (eval echo "$as_me:11612: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10838: \$? = $ac_status" >&5
+  echo "$as_me:11615: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   :
 else
@@ -10851,7 +11628,7 @@ fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 
 fi
-echo "$as_me:10854: result: $cf_cv_posix_c_source" >&5
+echo "$as_me:11631: result: $cf_cv_posix_c_source" >&5
 echo "${ECHO_T}$cf_cv_posix_c_source" >&6
 
 if test "$cf_cv_posix_c_source" != no ; then
@@ -10960,17 +11737,96 @@ fi
 
 fi # cf_cv_posix_visible
 
+	# Some of these niche implementations use copy/paste, double-check...
+	if test "$cf_cv_xopen_source" = no ; then
+		test -n "$verbose" && echo "	checking if _POSIX_C_SOURCE interferes with _XOPEN_SOURCE" 1>&6
+
+echo "${as_me:-configure}:11744: testing checking if _POSIX_C_SOURCE interferes with _XOPEN_SOURCE ..." 1>&5
+
+		cat >"conftest.$ac_ext" <<_ACEOF
+#line 11747 "configure"
+#include "confdefs.h"
+
+$ac_includes_default
+
+int
+main (void)
+{
+
+#ifndef _XOPEN_SOURCE
+#error _XOPEN_SOURCE is not defined
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:11765: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:11768: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:11771: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:11774: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+
+			{ echo "$as_me:11781: WARNING: _POSIX_C_SOURCE definition is not usable" >&5
+echo "$as_me: WARNING: _POSIX_C_SOURCE definition is not usable" >&2;}
+			CPPFLAGS="$cf_save_xopen_cppflags"
+fi
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+	fi
 	;;
 esac
 
 if test -n "$cf_xopen_source" ; then
 
+for cf_add_cflags in $cf_xopen_source
+do
+	case "x$cf_add_cflags" in
+	(x-[DU]*)
+
+cf_tmp_cflag=`echo "x$cf_add_cflags" | sed -e 's/^.//' -e 's/=.*//'`
+while true
+do
+	cf_old_cflag=`echo "x$CFLAGS" | sed -e 's/^.//' -e 's/[ 	][ 	]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[^ 	][^ 	]*\\)\?%%" -e 's/^[ 	]*//' -e 's%[ ][ ]*-D% -D%g' -e 's%[ ][ ]*-I% -I%g'`
+	test "$CFLAGS" != "$cf_old_cflag" || break
+	test -n "$verbose" && echo "	removing old option $cf_add_cflags from CFLAGS" 1>&6
+
+echo "${as_me:-configure}:11804: testing removing old option $cf_add_cflags from CFLAGS ..." 1>&5
+
+	CFLAGS="$cf_old_cflag"
+done
+
+cf_tmp_cflag=`echo "x$cf_add_cflags" | sed -e 's/^.//' -e 's/=.*//'`
+while true
+do
+	cf_old_cflag=`echo "x$CPPFLAGS" | sed -e 's/^.//' -e 's/[ 	][ 	]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[^ 	][^ 	]*\\)\?%%" -e 's/^[ 	]*//' -e 's%[ ][ ]*-D% -D%g' -e 's%[ ][ ]*-I% -I%g'`
+	test "$CPPFLAGS" != "$cf_old_cflag" || break
+	test -n "$verbose" && echo "	removing old option $cf_add_cflags from CPPFLAGS" 1>&6
+
+echo "${as_me:-configure}:11816: testing removing old option $cf_add_cflags from CPPFLAGS ..." 1>&5
+
+	CPPFLAGS="$cf_old_cflag"
+done
+
+		;;
+	esac
+
 cf_fix_cppflags=no
 cf_new_cflags=
 cf_new_cppflags=
 cf_new_extra_cppflags=
 
-for cf_add_cflags in $cf_xopen_source
+for cf_add_cflags in $cf_add_cflags
 do
 case "$cf_fix_cppflags" in
 (no)
@@ -11045,7 +11901,7 @@ done
 if test -n "$cf_new_cflags" ; then
 	test -n "$verbose" && echo "	add to \$CFLAGS $cf_new_cflags" 1>&6
 
-echo "${as_me:-configure}:11048: testing add to \$CFLAGS $cf_new_cflags ..." 1>&5
+echo "${as_me:-configure}:11904: testing add to \$CFLAGS $cf_new_cflags ..." 1>&5
 
 	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
 	CFLAGS="${CFLAGS}$cf_new_cflags"
@@ -11055,7 +11911,7 @@ fi
 if test -n "$cf_new_cppflags" ; then
 	test -n "$verbose" && echo "	add to \$CPPFLAGS $cf_new_cppflags" 1>&6
 
-echo "${as_me:-configure}:11058: testing add to \$CPPFLAGS $cf_new_cppflags ..." 1>&5
+echo "${as_me:-configure}:11914: testing add to \$CPPFLAGS $cf_new_cppflags ..." 1>&5
 
 	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
 	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
@@ -11065,20 +11921,22 @@ fi
 if test -n "$cf_new_extra_cppflags" ; then
 	test -n "$verbose" && echo "	add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags" 1>&6
 
-echo "${as_me:-configure}:11068: testing add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags ..." 1>&5
+echo "${as_me:-configure}:11924: testing add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags ..." 1>&5
 
 	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
 	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
 
 fi
 
+done
+
 fi
 
 if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
-	echo "$as_me:11078: checking if _XOPEN_SOURCE really is set" >&5
+	echo "$as_me:11936: checking if _XOPEN_SOURCE really is set" >&5
 echo $ECHO_N "checking if _XOPEN_SOURCE really is set... $ECHO_C" >&6
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 11081 "configure"
+#line 11939 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 int
@@ -11086,23 +11944,23 @@ main (void)
 {
 
 #ifndef _XOPEN_SOURCE
-make an error
+#error _XOPEN_SOURCE is not defined
 #endif
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:11096: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:11954: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:11099: \$? = $ac_status" >&5
+  echo "$as_me:11957: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:11102: \"$ac_try\"") >&5
+  { (eval echo "$as_me:11960: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:11105: \$? = $ac_status" >&5
+  echo "$as_me:11963: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_XOPEN_SOURCE_set=yes
 else
@@ -11111,12 +11969,12 @@ cat "conftest.$ac_ext" >&5
 cf_XOPEN_SOURCE_set=no
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
-	echo "$as_me:11114: result: $cf_XOPEN_SOURCE_set" >&5
+	echo "$as_me:11972: result: $cf_XOPEN_SOURCE_set" >&5
 echo "${ECHO_T}$cf_XOPEN_SOURCE_set" >&6
 	if test "$cf_XOPEN_SOURCE_set" = yes
 	then
 		cat >"conftest.$ac_ext" <<_ACEOF
-#line 11119 "configure"
+#line 11977 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 int
@@ -11124,23 +11982,23 @@ main (void)
 {
 
 #if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
-make an error
+#error (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
 #endif
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:11134: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:11992: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:11137: \$? = $ac_status" >&5
+  echo "$as_me:11995: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:11140: \"$ac_try\"") >&5
+  { (eval echo "$as_me:11998: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:11143: \$? = $ac_status" >&5
+  echo "$as_me:12001: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_XOPEN_SOURCE_set_ok=yes
 else
@@ -11151,47 +12009,46 @@ fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 		if test "$cf_XOPEN_SOURCE_set_ok" = no
 		then
-			{ echo "$as_me:11154: WARNING: _XOPEN_SOURCE is lower than requested" >&5
+			{ echo "$as_me:12012: WARNING: _XOPEN_SOURCE is lower than requested" >&5
 echo "$as_me: WARNING: _XOPEN_SOURCE is lower than requested" >&2;}
 		fi
 	else
 
-echo "$as_me:11159: checking if we should define _XOPEN_SOURCE" >&5
+echo "$as_me:12017: checking if we should define _XOPEN_SOURCE" >&5
 echo $ECHO_N "checking if we should define _XOPEN_SOURCE... $ECHO_C" >&6
 if test "${cf_cv_xopen_source+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 11166 "configure"
+#line 12024 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
+$ac_includes_default
 
 int
 main (void)
 {
 
 #ifndef _XOPEN_SOURCE
-make an error
+#error _XOPEN_SOURCE is not defined
 #endif
+
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:11185: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:12042: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:11188: \$? = $ac_status" >&5
+  echo "$as_me:12045: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:11191: \"$ac_try\"") >&5
+  { (eval echo "$as_me:12048: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:11194: \$? = $ac_status" >&5
+  echo "$as_me:12051: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_xopen_source=no
 else
@@ -11203,35 +12060,34 @@ cf_save="$CPPFLAGS"
 	CPPFLAGS="${CPPFLAGS}-D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
 
 	 cat >"conftest.$ac_ext" <<_ACEOF
-#line 11206 "configure"
+#line 12063 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
+$ac_includes_default
 
 int
 main (void)
 {
 
-#ifdef _XOPEN_SOURCE
-make an error
+#ifndef _XOPEN_SOURCE
+#error _XOPEN_SOURCE is not defined
 #endif
+
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:11225: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:12081: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:11228: \$? = $ac_status" >&5
+  echo "$as_me:12084: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:11231: \"$ac_try\"") >&5
+  { (eval echo "$as_me:12087: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:11234: \$? = $ac_status" >&5
+  echo "$as_me:12090: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_xopen_source=no
 else
@@ -11240,33 +12096,59 @@ cat "conftest.$ac_ext" >&5
 cf_cv_xopen_source=$cf_XOPEN_SOURCE
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
-	CPPFLAGS="$cf_save"
+		CPPFLAGS="$cf_save"
 
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 
 fi
-echo "$as_me:11249: result: $cf_cv_xopen_source" >&5
+echo "$as_me:12105: result: $cf_cv_xopen_source" >&5
 echo "${ECHO_T}$cf_cv_xopen_source" >&6
 
 if test "$cf_cv_xopen_source" != no ; then
 
-CFLAGS=`echo "$CFLAGS" | \
-	sed	-e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^ 	]*\)\?[ 	]/ /g' \
-		-e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^ 	]*\)\?$//g'`
+CFLAGS=`echo "$CFLAGS" | \
+	sed	-e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^ 	]*\)\?[ 	]/ /g' \
+		-e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^ 	]*\)\?$//g'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+	sed	-e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^ 	]*\)\?[ 	]/ /g' \
+		-e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^ 	]*\)\?$//g'`
+
+	cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
+
+for cf_add_cflags in $cf_temp_xopen_source
+do
+	case "x$cf_add_cflags" in
+	(x-[DU]*)
+
+cf_tmp_cflag=`echo "x$cf_add_cflags" | sed -e 's/^.//' -e 's/=.*//'`
+while true
+do
+	cf_old_cflag=`echo "x$CFLAGS" | sed -e 's/^.//' -e 's/[ 	][ 	]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[^ 	][^ 	]*\\)\?%%" -e 's/^[ 	]*//' -e 's%[ ][ ]*-D% -D%g' -e 's%[ ][ ]*-I% -I%g'`
+	test "$CFLAGS" != "$cf_old_cflag" || break
+
+	CFLAGS="$cf_old_cflag"
+done
+
+cf_tmp_cflag=`echo "x$cf_add_cflags" | sed -e 's/^.//' -e 's/=.*//'`
+while true
+do
+	cf_old_cflag=`echo "x$CPPFLAGS" | sed -e 's/^.//' -e 's/[ 	][ 	]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[^ 	][^ 	]*\\)\?%%" -e 's/^[ 	]*//' -e 's%[ ][ ]*-D% -D%g' -e 's%[ ][ ]*-I% -I%g'`
+	test "$CPPFLAGS" != "$cf_old_cflag" || break
 
-CPPFLAGS=`echo "$CPPFLAGS" | \
-	sed	-e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^ 	]*\)\?[ 	]/ /g' \
-		-e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^ 	]*\)\?$//g'`
+	CPPFLAGS="$cf_old_cflag"
+done
 
-	cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
+		;;
+	esac
 
 cf_fix_cppflags=no
 cf_new_cflags=
 cf_new_cppflags=
 cf_new_extra_cppflags=
 
-for cf_add_cflags in $cf_temp_xopen_source
+for cf_add_cflags in $cf_add_cflags
 do
 case "$cf_fix_cppflags" in
 (no)
@@ -11359,6 +12241,8 @@ if test -n "$cf_new_extra_cppflags" ; then
 
 fi
 
+done
+
 fi
 
 	fi
@@ -11369,14 +12253,14 @@ CPPFLAGS_after_XOPEN="$CPPFLAGS"
 
 # Work around breakage on OS X
 
-echo "$as_me:11372: checking if SIGWINCH is defined" >&5
+echo "$as_me:12256: checking if SIGWINCH is defined" >&5
 echo $ECHO_N "checking if SIGWINCH is defined... $ECHO_C" >&6
 if test "${cf_cv_define_sigwinch+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 11379 "configure"
+#line 12263 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -11391,23 +12275,23 @@ int x = SIGWINCH; (void)x
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:11394: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:12278: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:11397: \$? = $ac_status" >&5
+  echo "$as_me:12281: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:11400: \"$ac_try\"") >&5
+  { (eval echo "$as_me:12284: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:11403: \$? = $ac_status" >&5
+  echo "$as_me:12287: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_define_sigwinch=yes
 else
   echo "$as_me: failed program was:" >&5
 cat "conftest.$ac_ext" >&5
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 11410 "configure"
+#line 12294 "configure"
 #include "confdefs.h"
 
 #undef _XOPEN_SOURCE
@@ -11425,16 +12309,16 @@ int x = SIGWINCH; (void)x
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:11428: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:12312: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:11431: \$? = $ac_status" >&5
+  echo "$as_me:12315: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:11434: \"$ac_try\"") >&5
+  { (eval echo "$as_me:12318: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:11437: \$? = $ac_status" >&5
+  echo "$as_me:12321: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_define_sigwinch=maybe
 else
@@ -11448,11 +12332,11 @@ fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 
 fi
-echo "$as_me:11451: result: $cf_cv_define_sigwinch" >&5
+echo "$as_me:12335: result: $cf_cv_define_sigwinch" >&5
 echo "${ECHO_T}$cf_cv_define_sigwinch" >&6
 
 if test "$cf_cv_define_sigwinch" = maybe ; then
-echo "$as_me:11455: checking for actual SIGWINCH definition" >&5
+echo "$as_me:12339: checking for actual SIGWINCH definition" >&5
 echo $ECHO_N "checking for actual SIGWINCH definition... $ECHO_C" >&6
 if test "${cf_cv_fixup_sigwinch+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -11463,7 +12347,7 @@ cf_sigwinch=32
 while test "$cf_sigwinch" != 1
 do
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 11466 "configure"
+#line 12350 "configure"
 #include "confdefs.h"
 
 #undef _XOPEN_SOURCE
@@ -11477,7 +12361,7 @@ main (void)
 {
 
 #if SIGWINCH != $cf_sigwinch
-make an error
+#error SIGWINCH is not $cf_sigwinch
 #endif
 int x = SIGWINCH; (void)x
   ;
@@ -11485,16 +12369,16 @@ int x = SIGWINCH; (void)x
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:11488: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:12372: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:11491: \$? = $ac_status" >&5
+  echo "$as_me:12375: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:11494: \"$ac_try\"") >&5
+  { (eval echo "$as_me:12378: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:11497: \$? = $ac_status" >&5
+  echo "$as_me:12381: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_fixup_sigwinch=$cf_sigwinch
 	 break
@@ -11508,7 +12392,7 @@ cf_sigwinch="`expr "$cf_sigwinch" - 1`"
 done
 
 fi
-echo "$as_me:11511: result: $cf_cv_fixup_sigwinch" >&5
+echo "$as_me:12395: result: $cf_cv_fixup_sigwinch" >&5
 echo "${ECHO_T}$cf_cv_fixup_sigwinch" >&6
 
 	if test "$cf_cv_fixup_sigwinch" != unknown ; then
@@ -11518,14 +12402,16 @@ fi
 
 # Checks for CODESET support.
 
-echo "$as_me:11521: checking for nl_langinfo and CODESET" >&5
+echo "$as_me:12405: checking for nl_langinfo and CODESET" >&5
 echo $ECHO_N "checking for nl_langinfo and CODESET... $ECHO_C" >&6
 if test "${am_cv_langinfo_codeset+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 11527 "configure"
+#line 12411 "configure"
 #include "confdefs.h"
+
+$ac_includes_default
 #include <langinfo.h>
 int
 main (void)
@@ -11536,16 +12422,16 @@ char* cs = nl_langinfo(CODESET); (void)cs
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:11539: \"$ac_link\"") >&5
+if { (eval echo "$as_me:12425: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:11542: \$? = $ac_status" >&5
+  echo "$as_me:12428: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:11545: \"$ac_try\"") >&5
+  { (eval echo "$as_me:12431: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:11548: \$? = $ac_status" >&5
+  echo "$as_me:12434: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   am_cv_langinfo_codeset=yes
 else
@@ -11556,7 +12442,7 @@ fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 
 fi
-echo "$as_me:11559: result: $am_cv_langinfo_codeset" >&5
+echo "$as_me:12445: result: $am_cv_langinfo_codeset" >&5
 echo "${ECHO_T}$am_cv_langinfo_codeset" >&6
 	if test "$am_cv_langinfo_codeset" = yes; then
 
@@ -11570,7 +12456,7 @@ EOF
 NCURSES_OK_WCHAR_T=
 NCURSES_OK_WINT_T=
 
-echo "$as_me:11573: checking if you want wide-character code" >&5
+echo "$as_me:12459: checking if you want wide-character code" >&5
 echo $ECHO_N "checking if you want wide-character code... $ECHO_C" >&6
 
 # Check whether --enable-widec or --disable-widec was given.
@@ -11578,9 +12464,9 @@ if test "${enable_widec+set}" = set; then
   enableval="$enable_widec"
   with_widec=$enableval
 else
-  with_widec=no
+  with_widec=$cf_dft_widec
 fi;
-echo "$as_me:11583: result: $with_widec" >&5
+echo "$as_me:12469: result: $with_widec" >&5
 echo "${ECHO_T}$with_widec" >&6
 
 NCURSES_WCWIDTH_GRAPHICS=1
@@ -11598,29 +12484,40 @@ cat >>confdefs.h <<\EOF
 #define NCURSES_WIDECHAR 1
 EOF
 
+	case "$CPPFLAGS" in
+	(*_XOPEN_SOURCE=*)
+		;;
+	(*)
+		{ echo "$as_me:12491: WARNING: _XOPEN_SOURCE feature test macro appears to be predefined" >&5
+echo "$as_me: WARNING: _XOPEN_SOURCE feature test macro appears to be predefined" >&2;}
+		# CPPFLAGS="$CPPFLAGS -DNCURSES_WIDECHAR"
+		CPPFLAGS_after_XOPEN="$CPPFLAGS_after_XOPEN -DNCURSES_WIDECHAR"
+		;;
+	esac
+
 for ac_header in \
 wchar.h \
 wctype.h \
 
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:11607: checking for $ac_header" >&5
+echo "$as_me:12504: checking for $ac_header" >&5
 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 11613 "configure"
+#line 12510 "configure"
 #include "confdefs.h"
 #include <$ac_header>
 _ACEOF
-if { (eval echo "$as_me:11617: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+if { (eval echo "$as_me:12514: \"$ac_cpp "conftest.$ac_ext"\"") >&5
   (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:11623: \$? = $ac_status" >&5
+  echo "$as_me:12520: \$? = $ac_status" >&5
   (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -11639,7 +12536,7 @@ else
 fi
 rm -f conftest.err "conftest.$ac_ext"
 fi
-echo "$as_me:11642: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
+echo "$as_me:12539: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
 echo "${ECHO_T}`eval echo '${'"$as_ac_Header"'}'`" >&6
 if test "`eval echo '${'"$as_ac_Header"'}'`" = yes; then
   cat >>confdefs.h <<EOF
@@ -11649,17 +12546,17 @@ EOF
 fi
 done
 
-echo "$as_me:11652: checking if wchar.h can be used as is" >&5
+echo "$as_me:12549: checking if wchar.h can be used as is" >&5
 echo $ECHO_N "checking if wchar.h can be used as is... $ECHO_C" >&6
 if test "${cf_cv_wchar_h_okay+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 11659 "configure"
+#line 12556 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
+$ac_includes_default
 #ifdef HAVE_WCHAR_H
 #include <wchar.h>
 #endif
@@ -11672,22 +12569,22 @@ main (void)
 {
 
 	wint_t foo = 0;
-	int bar = iswpunct(foo)
+	int bar = iswpunct(foo); (void) bar
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:11681: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:12578: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:11684: \$? = $ac_status" >&5
+  echo "$as_me:12581: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:11687: \"$ac_try\"") >&5
+  { (eval echo "$as_me:12584: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:11690: \$? = $ac_status" >&5
+  echo "$as_me:12587: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_wchar_h_okay=yes
 else
@@ -11697,16 +12594,16 @@ cf_cv_wchar_h_okay=no
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 fi
-echo "$as_me:11700: result: $cf_cv_wchar_h_okay" >&5
+echo "$as_me:12597: result: $cf_cv_wchar_h_okay" >&5
 echo "${ECHO_T}$cf_cv_wchar_h_okay" >&6
 
 if test "$cf_cv_wchar_h_okay" = no
 then
 
-echo "$as_me:11706: checking if we must define _XOPEN_SOURCE_EXTENDED" >&5
+echo "$as_me:12603: checking if we must define _XOPEN_SOURCE_EXTENDED" >&5
 echo $ECHO_N "checking if we must define _XOPEN_SOURCE_EXTENDED... $ECHO_C" >&6
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 11709 "configure"
+#line 12606 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 
@@ -11715,23 +12612,23 @@ main (void)
 {
 
 #ifndef _XOPEN_SOURCE_EXTENDED
-make an error
+#error _XOPEN_SOURCE_EXTENDED is not defined
 #endif
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:11725: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:12622: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:11728: \$? = $ac_status" >&5
+  echo "$as_me:12625: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:11731: \"$ac_try\"") >&5
+  { (eval echo "$as_me:12628: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:11734: \$? = $ac_status" >&5
+  echo "$as_me:12631: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_result=no
 else
@@ -11740,16 +12637,16 @@ cat "conftest.$ac_ext" >&5
 cf_result=yes
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
-echo "$as_me:11743: result: $cf_result" >&5
+echo "$as_me:12640: result: $cf_result" >&5
 echo "${ECHO_T}$cf_result" >&6
 
 if test "$cf_result" = yes ; then
 	CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
 elif test "x" != "x" ; then
-	echo "$as_me:11749: checking checking for compatible value versus " >&5
+	echo "$as_me:12646: checking checking for compatible value versus " >&5
 echo $ECHO_N "checking checking for compatible value versus ... $ECHO_C" >&6
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 11752 "configure"
+#line 12649 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 
@@ -11758,23 +12655,23 @@ main (void)
 {
 
 #if _XOPEN_SOURCE_EXTENDED- < 0
-make an error
+#error _XOPEN_SOURCE_EXTENDED- is negative
 #endif
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:11768: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:12665: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:11771: \$? = $ac_status" >&5
+  echo "$as_me:12668: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:11774: \"$ac_try\"") >&5
+  { (eval echo "$as_me:12671: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:11777: \$? = $ac_status" >&5
+  echo "$as_me:12674: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_result=yes
 else
@@ -11783,7 +12680,7 @@ cat "conftest.$ac_ext" >&5
 cf_result=no
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
-	echo "$as_me:11786: result: $cf_result" >&5
+	echo "$as_me:12683: result: $cf_result" >&5
 echo "${ECHO_T}$cf_result" >&6
 	if test "$cf_result" = no ; then
 		# perhaps we can override it - try...
@@ -11793,7 +12690,7 @@ fi
 
 fi
 
-echo "$as_me:11796: checking if wcwidth agrees graphics are single-width" >&5
+echo "$as_me:12693: checking if wcwidth agrees graphics are single-width" >&5
 echo $ECHO_N "checking if wcwidth agrees graphics are single-width... $ECHO_C" >&6
 if test "${cf_cv_wcwidth_graphics+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -11864,11 +12761,12 @@ if test "$cross_compiling" = yes; then
   cf_cv_wcwidth_graphics=unknown
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 11867 "configure"
+#line 12764 "configure"
 #include "confdefs.h"
 
+$ac_includes_default
+
 #include <locale.h>
-#include <stdio.h>
 #include <wchar.h>
 
 #define MY_LEN 80
@@ -11877,7 +12775,7 @@ int
 main(void)
 {
 	FILE *fp;
-	int value;
+	unsigned value;
 	char buffer[MY_LEN + 1];
 	char notes[MY_LEN + 1];
 	int totals = 0;
@@ -11893,9 +12791,9 @@ main(void)
 					fprintf(stderr, "\\t%s", buffer);
 				} else if (sscanf(buffer, "%x %s", &value, notes) == 2) {
 					++totals;
-					if (wcwidth(value) == 1)
+					if (wcwidth((int)value) == 1)
 						++passed;
-					fprintf(stderr, "%d\\t%s", wcwidth(value), buffer);
+					fprintf(stderr, "%d\\t%s", wcwidth((int)value), buffer);
 				} else {
 					fprintf(stderr, "?\\t%s", buffer);
 				}
@@ -11908,15 +12806,15 @@ main(void)
 
 _ACEOF
 rm -f "conftest$ac_exeext"
-if { (eval echo "$as_me:11911: \"$ac_link\"") >&5
+if { (eval echo "$as_me:12809: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:11914: \$? = $ac_status" >&5
+  echo "$as_me:12812: \$? = $ac_status" >&5
   (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
-  { (eval echo "$as_me:11916: \"$ac_try\"") >&5
+  { (eval echo "$as_me:12814: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:11919: \$? = $ac_status" >&5
+  echo "$as_me:12817: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_wcwidth_graphics=yes
 else
@@ -11929,7 +12827,7 @@ rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftes
 fi
 
 fi
-echo "$as_me:11932: result: $cf_cv_wcwidth_graphics" >&5
+echo "$as_me:12830: result: $cf_cv_wcwidth_graphics" >&5
 echo "${ECHO_T}$cf_cv_wcwidth_graphics" >&6
 
 	test "$cf_cv_wcwidth_graphics" = no && NCURSES_WCWIDTH_GRAPHICS=0
@@ -11937,16 +12835,16 @@ echo "${ECHO_T}$cf_cv_wcwidth_graphics" >&6
 	# with_overwrite=no
 	NCURSES_CH_T=cchar_t
 
-for ac_func in putwc btowc wctob mbtowc wctomb mblen mbrlen mbrtowc wcsrtombs mbsrtowcs wcstombs mbstowcs
+for ac_func in putwc btowc wctob wmemchr mbtowc wctomb mblen mbrlen mbrtowc wcsrtombs mbsrtowcs wcstombs mbstowcs
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:11943: checking for $ac_func" >&5
+echo "$as_me:12841: checking for $ac_func" >&5
 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
 if eval "test \"\${$as_ac_var+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 11949 "configure"
+#line 12847 "configure"
 #include "confdefs.h"
 #define $ac_func autoconf_temporary
 #include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
@@ -11977,16 +12875,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:11980: \"$ac_link\"") >&5
+if { (eval echo "$as_me:12878: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:11983: \$? = $ac_status" >&5
+  echo "$as_me:12881: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:11986: \"$ac_try\"") >&5
+  { (eval echo "$as_me:12884: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:11989: \$? = $ac_status" >&5
+  echo "$as_me:12887: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   eval "$as_ac_var=yes"
 else
@@ -11996,7 +12894,7 @@ eval "$as_ac_var=no"
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:11999: result: `eval echo '${'"$as_ac_var"'}'`" >&5
+echo "$as_me:12897: result: `eval echo '${'"$as_ac_var"'}'`" >&5
 echo "${ECHO_T}`eval echo '${'"$as_ac_var"'}'`" >&6
 if test "`eval echo '${'"$as_ac_var"'}'`" = yes; then
   cat >>confdefs.h <<EOF
@@ -12008,7 +12906,55 @@ done
 
 	if test "x$ac_cv_func_putwc" != xyes ; then
 
-echo "$as_me:12011: checking for multibyte character support" >&5
+for ac_header in wchar.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:12912: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 12918 "configure"
+#include "confdefs.h"
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:12922: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+  (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  $EGREP -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:12928: \$? = $ac_status" >&5
+  (exit "$ac_status"); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+  cat "conftest.$ac_ext" >&5
+  eval "$as_ac_Header=no"
+fi
+rm -f conftest.err "conftest.$ac_ext"
+fi
+echo "$as_me:12947: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
+echo "${ECHO_T}`eval echo '${'"$as_ac_Header"'}'`" >&6
+if test "`eval echo '${'"$as_ac_Header"'}'`" = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+EOF
+
+fi
+done
+
+echo "$as_me:12957: checking for multibyte character support" >&5
 echo $ECHO_N "checking for multibyte character support... $ECHO_C" >&6
 if test "${cf_cv_utf8_lib+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -12016,10 +12962,14 @@ else
 
 	cf_save_LIBS="$LIBS"
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 12019 "configure"
+#line 12965 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
+$ac_includes_default
+#ifdef HAVE_WCHAR_H
+#include <wchar.h>
+#endif
+
 int
 main (void)
 {
@@ -12029,16 +12979,16 @@ putwc(0,0);
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:12032: \"$ac_link\"") >&5
+if { (eval echo "$as_me:12982: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:12035: \$? = $ac_status" >&5
+  echo "$as_me:12985: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:12038: \"$ac_try\"") >&5
+  { (eval echo "$as_me:12988: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:12041: \$? = $ac_status" >&5
+  echo "$as_me:12991: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_utf8_lib=yes
 else
@@ -12050,12 +13000,12 @@ cat "conftest.$ac_ext" >&5
 cf_cv_header_path_utf8=
 cf_cv_library_path_utf8=
 
-echo "${as_me:-configure}:12053: testing Starting FIND_LINKAGE(utf8,) ..." 1>&5
+echo "${as_me:-configure}:13003: testing Starting FIND_LINKAGE(utf8,) ..." 1>&5
 
 cf_save_LIBS="$LIBS"
 
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 12058 "configure"
+#line 13008 "configure"
 #include "confdefs.h"
 
 #include <libutf8.h>
@@ -12068,16 +13018,16 @@ putwc(0,0);
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:12071: \"$ac_link\"") >&5
+if { (eval echo "$as_me:13021: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:12074: \$? = $ac_status" >&5
+  echo "$as_me:13024: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:12077: \"$ac_try\"") >&5
+  { (eval echo "$as_me:13027: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:12080: \$? = $ac_status" >&5
+  echo "$as_me:13030: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
 
 	cf_cv_find_linkage_utf8=yes
@@ -12091,7 +13041,7 @@ cat "conftest.$ac_ext" >&5
 LIBS="-lutf8  $cf_save_LIBS"
 
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 12094 "configure"
+#line 13044 "configure"
 #include "confdefs.h"
 
 #include <libutf8.h>
@@ -12104,16 +13054,16 @@ putwc(0,0);
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:12107: \"$ac_link\"") >&5
+if { (eval echo "$as_me:13057: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:12110: \$? = $ac_status" >&5
+  echo "$as_me:13060: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:12113: \"$ac_try\"") >&5
+  { (eval echo "$as_me:13063: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:12116: \$? = $ac_status" >&5
+  echo "$as_me:13066: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
 
 	cf_cv_find_linkage_utf8=yes
@@ -12130,9 +13080,9 @@ cat "conftest.$ac_ext" >&5
 
 	test -n "$verbose" && echo "	find linkage for utf8 library" 1>&6
 
-echo "${as_me:-configure}:12133: testing find linkage for utf8 library ..." 1>&5
+echo "${as_me:-configure}:13083: testing find linkage for utf8 library ..." 1>&5
 
-echo "${as_me:-configure}:12135: testing Searching for headers in FIND_LINKAGE(utf8,) ..." 1>&5
+echo "${as_me:-configure}:13085: testing Searching for headers in FIND_LINKAGE(utf8,) ..." 1>&5
 
 	cf_save_CPPFLAGS="$CPPFLAGS"
 	cf_test_CPPFLAGS="$CPPFLAGS"
@@ -12223,7 +13173,7 @@ cf_search="$cf_search $cf_header_path_list"
 		if test -d "$cf_cv_header_path_utf8" ; then
 			test -n "$verbose" && echo "	... testing $cf_cv_header_path_utf8" 1>&6
 
-echo "${as_me:-configure}:12226: testing ... testing $cf_cv_header_path_utf8 ..." 1>&5
+echo "${as_me:-configure}:13176: testing ... testing $cf_cv_header_path_utf8 ..." 1>&5
 
 			CPPFLAGS="$cf_save_CPPFLAGS"
 
@@ -12231,7 +13181,7 @@ echo "${as_me:-configure}:12226: testing ... testing $cf_cv_header_path_utf8 ...
 	CPPFLAGS="${CPPFLAGS}-I$cf_cv_header_path_utf8"
 
 			cat >"conftest.$ac_ext" <<_ACEOF
-#line 12234 "configure"
+#line 13184 "configure"
 #include "confdefs.h"
 
 #include <libutf8.h>
@@ -12244,21 +13194,21 @@ putwc(0,0);
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:12247: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:13197: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:12250: \$? = $ac_status" >&5
+  echo "$as_me:13200: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:12253: \"$ac_try\"") >&5
+  { (eval echo "$as_me:13203: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:12256: \$? = $ac_status" >&5
+  echo "$as_me:13206: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
 
 				test -n "$verbose" && echo "	... found utf8 headers in $cf_cv_header_path_utf8" 1>&6
 
-echo "${as_me:-configure}:12261: testing ... found utf8 headers in $cf_cv_header_path_utf8 ..." 1>&5
+echo "${as_me:-configure}:13211: testing ... found utf8 headers in $cf_cv_header_path_utf8 ..." 1>&5
 
 				cf_cv_find_linkage_utf8=maybe
 				cf_test_CPPFLAGS="$CPPFLAGS"
@@ -12276,7 +13226,7 @@ rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 
 	if test "$cf_cv_find_linkage_utf8" = maybe ; then
 
-echo "${as_me:-configure}:12279: testing Searching for utf8 library in FIND_LINKAGE(utf8,) ..." 1>&5
+echo "${as_me:-configure}:13229: testing Searching for utf8 library in FIND_LINKAGE(utf8,) ..." 1>&5
 
 		cf_save_LIBS="$LIBS"
 		cf_save_LDFLAGS="$LDFLAGS"
@@ -12351,13 +13301,13 @@ cf_search="$cf_library_path_list $cf_search"
 				if test -d "$cf_cv_library_path_utf8" ; then
 					test -n "$verbose" && echo "	... testing $cf_cv_library_path_utf8" 1>&6
 
-echo "${as_me:-configure}:12354: testing ... testing $cf_cv_library_path_utf8 ..." 1>&5
+echo "${as_me:-configure}:13304: testing ... testing $cf_cv_library_path_utf8 ..." 1>&5
 
 					CPPFLAGS="$cf_test_CPPFLAGS"
 					LIBS="-lutf8  $cf_save_LIBS"
 					LDFLAGS="$cf_save_LDFLAGS -L$cf_cv_library_path_utf8"
 					cat >"conftest.$ac_ext" <<_ACEOF
-#line 12360 "configure"
+#line 13310 "configure"
 #include "confdefs.h"
 
 #include <libutf8.h>
@@ -12370,21 +13320,21 @@ putwc(0,0);
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:12373: \"$ac_link\"") >&5
+if { (eval echo "$as_me:13323: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:12376: \$? = $ac_status" >&5
+  echo "$as_me:13326: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:12379: \"$ac_try\"") >&5
+  { (eval echo "$as_me:13329: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:12382: \$? = $ac_status" >&5
+  echo "$as_me:13332: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
 
 					test -n "$verbose" && echo "	... found utf8 library in $cf_cv_library_path_utf8" 1>&6
 
-echo "${as_me:-configure}:12387: testing ... found utf8 library in $cf_cv_library_path_utf8 ..." 1>&5
+echo "${as_me:-configure}:13337: testing ... found utf8 library in $cf_cv_library_path_utf8 ..." 1>&5
 
 					cf_cv_find_linkage_utf8=yes
 					cf_cv_library_file_utf8="-lutf8"
@@ -12426,7 +13376,7 @@ fi
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:12429: result: $cf_cv_utf8_lib" >&5
+echo "$as_me:13379: result: $cf_cv_utf8_lib" >&5
 echo "${ECHO_T}$cf_cv_utf8_lib" >&6
 
 # HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between
@@ -12464,7 +13414,7 @@ if test -n "$cf_cv_header_path_utf8" ; then
 	CPPFLAGS="${CPPFLAGS}-I$cf_add_incdir"
 
 			  cat >"conftest.$ac_ext" <<_ACEOF
-#line 12467 "configure"
+#line 13417 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int
@@ -12476,16 +13426,16 @@ printf("Hello")
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:12479: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:13429: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:12482: \$? = $ac_status" >&5
+  echo "$as_me:13432: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:12485: \"$ac_try\"") >&5
+  { (eval echo "$as_me:13435: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:12488: \$? = $ac_status" >&5
+  echo "$as_me:13438: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   :
 else
@@ -12502,7 +13452,7 @@ rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 		if test "$cf_have_incdir" = no ; then
 		  test -n "$verbose" && echo "	adding $cf_add_incdir to include-path" 1>&6
 
-echo "${as_me:-configure}:12505: testing adding $cf_add_incdir to include-path ..." 1>&5
+echo "${as_me:-configure}:13455: testing adding $cf_add_incdir to include-path ..." 1>&5
 
 		  CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
 
@@ -12538,7 +13488,7 @@ if test -n "$cf_cv_library_path_utf8" ; then
 			if test "$cf_have_libdir" = no ; then
 				test -n "$verbose" && echo "	adding $cf_add_libdir to library-path" 1>&6
 
-echo "${as_me:-configure}:12541: testing adding $cf_add_libdir to library-path ..." 1>&5
+echo "${as_me:-configure}:13491: testing adding $cf_add_libdir to library-path ..." 1>&5
 
 				LDFLAGS="-L$cf_add_libdir $LDFLAGS"
 			fi
@@ -12570,14 +13520,14 @@ fi
 	fi
 
 # This is needed on Tru64 5.0 to declare mbstate_t
-echo "$as_me:12573: checking if we must include wchar.h to declare mbstate_t" >&5
+echo "$as_me:13523: checking if we must include wchar.h to declare mbstate_t" >&5
 echo $ECHO_N "checking if we must include wchar.h to declare mbstate_t... $ECHO_C" >&6
 if test "${cf_cv_mbstate_t+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 12580 "configure"
+#line 13530 "configure"
 #include "confdefs.h"
 
 #include <stdlib.h>
@@ -12589,29 +13539,29 @@ cat >"conftest.$ac_ext" <<_ACEOF
 int
 main (void)
 {
-mbstate_t state
+mbstate_t state; (void)state
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:12598: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:13548: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:12601: \$? = $ac_status" >&5
+  echo "$as_me:13551: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:12604: \"$ac_try\"") >&5
+  { (eval echo "$as_me:13554: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:12607: \$? = $ac_status" >&5
+  echo "$as_me:13557: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_mbstate_t=no
 else
   echo "$as_me: failed program was:" >&5
 cat "conftest.$ac_ext" >&5
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 12614 "configure"
+#line 13564 "configure"
 #include "confdefs.h"
 
 #include <stdlib.h>
@@ -12624,22 +13574,22 @@ cat >"conftest.$ac_ext" <<_ACEOF
 int
 main (void)
 {
-mbstate_t value
+mbstate_t value; (void) value
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:12633: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:13583: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:12636: \$? = $ac_status" >&5
+  echo "$as_me:13586: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:12639: \"$ac_try\"") >&5
+  { (eval echo "$as_me:13589: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:12642: \$? = $ac_status" >&5
+  echo "$as_me:13592: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_mbstate_t=yes
 else
@@ -12651,7 +13601,7 @@ rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 fi
-echo "$as_me:12654: result: $cf_cv_mbstate_t" >&5
+echo "$as_me:13604: result: $cf_cv_mbstate_t" >&5
 echo "${ECHO_T}$cf_cv_mbstate_t" >&6
 
 if test "$cf_cv_mbstate_t" = yes ; then
@@ -12669,14 +13619,14 @@ if test "$cf_cv_mbstate_t" = unknown ; then
 fi
 
 # This is needed on Tru64 5.0 to declare wchar_t
-echo "$as_me:12672: checking if we must include wchar.h to declare wchar_t" >&5
+echo "$as_me:13622: checking if we must include wchar.h to declare wchar_t" >&5
 echo $ECHO_N "checking if we must include wchar.h to declare wchar_t... $ECHO_C" >&6
 if test "${cf_cv_wchar_t+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 12679 "configure"
+#line 13629 "configure"
 #include "confdefs.h"
 
 #include <stdlib.h>
@@ -12688,29 +13638,29 @@ cat >"conftest.$ac_ext" <<_ACEOF
 int
 main (void)
 {
-wchar_t state
+wchar_t state; (void)state
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:12697: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:13647: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:12700: \$? = $ac_status" >&5
+  echo "$as_me:13650: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:12703: \"$ac_try\"") >&5
+  { (eval echo "$as_me:13653: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:12706: \$? = $ac_status" >&5
+  echo "$as_me:13656: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_wchar_t=no
 else
   echo "$as_me: failed program was:" >&5
 cat "conftest.$ac_ext" >&5
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 12713 "configure"
+#line 13663 "configure"
 #include "confdefs.h"
 
 #include <stdlib.h>
@@ -12723,22 +13673,22 @@ cat >"conftest.$ac_ext" <<_ACEOF
 int
 main (void)
 {
-wchar_t value
+wchar_t value; (void) value
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:12732: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:13682: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:12735: \$? = $ac_status" >&5
+  echo "$as_me:13685: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:12738: \"$ac_try\"") >&5
+  { (eval echo "$as_me:13688: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:12741: \$? = $ac_status" >&5
+  echo "$as_me:13691: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_wchar_t=yes
 else
@@ -12750,7 +13700,7 @@ rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 fi
-echo "$as_me:12753: result: $cf_cv_wchar_t" >&5
+echo "$as_me:13703: result: $cf_cv_wchar_t" >&5
 echo "${ECHO_T}$cf_cv_wchar_t" >&6
 
 if test "$cf_cv_wchar_t" = yes ; then
@@ -12773,14 +13723,14 @@ if test "$cf_cv_wchar_t" != unknown ; then
 fi
 
 # This is needed on Tru64 5.0 to declare wint_t
-echo "$as_me:12776: checking if we must include wchar.h to declare wint_t" >&5
+echo "$as_me:13726: checking if we must include wchar.h to declare wint_t" >&5
 echo $ECHO_N "checking if we must include wchar.h to declare wint_t... $ECHO_C" >&6
 if test "${cf_cv_wint_t+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 12783 "configure"
+#line 13733 "configure"
 #include "confdefs.h"
 
 #include <stdlib.h>
@@ -12792,29 +13742,29 @@ cat >"conftest.$ac_ext" <<_ACEOF
 int
 main (void)
 {
-wint_t state
+wint_t state; (void)state
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:12801: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:13751: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:12804: \$? = $ac_status" >&5
+  echo "$as_me:13754: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:12807: \"$ac_try\"") >&5
+  { (eval echo "$as_me:13757: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:12810: \$? = $ac_status" >&5
+  echo "$as_me:13760: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_wint_t=no
 else
   echo "$as_me: failed program was:" >&5
 cat "conftest.$ac_ext" >&5
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 12817 "configure"
+#line 13767 "configure"
 #include "confdefs.h"
 
 #include <stdlib.h>
@@ -12827,22 +13777,22 @@ cat >"conftest.$ac_ext" <<_ACEOF
 int
 main (void)
 {
-wint_t value
+wint_t value; (void) value
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:12836: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:13786: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:12839: \$? = $ac_status" >&5
+  echo "$as_me:13789: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:12842: \"$ac_try\"") >&5
+  { (eval echo "$as_me:13792: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:12845: \$? = $ac_status" >&5
+  echo "$as_me:13795: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_wint_t=yes
 else
@@ -12854,7 +13804,7 @@ rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 fi
-echo "$as_me:12857: result: $cf_cv_wint_t" >&5
+echo "$as_me:13807: result: $cf_cv_wint_t" >&5
 echo "${ECHO_T}$cf_cv_wint_t" >&6
 
 if test "$cf_cv_wint_t" = yes ; then
@@ -12886,7 +13836,7 @@ EOF
 fi
 
 ###   use option --disable-lp64 to allow long chtype
-echo "$as_me:12889: checking whether to enable _LP64 definition in curses.h" >&5
+echo "$as_me:13839: checking whether to enable _LP64 definition in curses.h" >&5
 echo $ECHO_N "checking whether to enable _LP64 definition in curses.h... $ECHO_C" >&6
 
 # Check whether --enable-lp64 or --disable-lp64 was given.
@@ -12896,7 +13846,7 @@ if test "${enable_lp64+set}" = set; then
 else
   with_lp64=$cf_dft_with_lp64
 fi;
-echo "$as_me:12899: result: $with_lp64" >&5
+echo "$as_me:13849: result: $with_lp64" >&5
 echo "${ECHO_T}$with_lp64" >&6
 
 if test "x$with_lp64" = xyes ; then
@@ -12912,7 +13862,7 @@ if test "${enable_largefile+set}" = set; then
 fi;
 if test "$enable_largefile" != no; then
 
-  echo "$as_me:12915: checking for special C compiler options needed for large files" >&5
+  echo "$as_me:13865: checking for special C compiler options needed for large files" >&5
 echo $ECHO_N "checking for special C compiler options needed for large files... $ECHO_C" >&6
 if test "${ac_cv_sys_largefile_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -12924,7 +13874,7 @@ else
      	 # IRIX 6.2 and later do not support large files by default,
      	 # so use the C compiler's -n32 option if that helps.
          cat >"conftest.$ac_ext" <<_ACEOF
-#line 12927 "configure"
+#line 13877 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
  /* Check that off_t can represent 2**63 - 1 correctly.
@@ -12944,16 +13894,16 @@ main (void)
 }
 _ACEOF
      	 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:12947: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:13897: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:12950: \$? = $ac_status" >&5
+  echo "$as_me:13900: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:12953: \"$ac_try\"") >&5
+  { (eval echo "$as_me:13903: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:12956: \$? = $ac_status" >&5
+  echo "$as_me:13906: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   break
 else
@@ -12963,16 +13913,16 @@ fi
 rm -f "conftest.$ac_objext"
      	 CC="$CC -n32"
      	 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:12966: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:13916: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:12969: \$? = $ac_status" >&5
+  echo "$as_me:13919: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:12972: \"$ac_try\"") >&5
+  { (eval echo "$as_me:13922: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:12975: \$? = $ac_status" >&5
+  echo "$as_me:13925: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_sys_largefile_CC=' -n32'; break
 else
@@ -12986,13 +13936,13 @@ rm -f "conftest.$ac_objext"
        rm -f "conftest.$ac_ext"
     fi
 fi
-echo "$as_me:12989: result: $ac_cv_sys_largefile_CC" >&5
+echo "$as_me:13939: result: $ac_cv_sys_largefile_CC" >&5
 echo "${ECHO_T}$ac_cv_sys_largefile_CC" >&6
   if test "$ac_cv_sys_largefile_CC" != no; then
     CC=$CC$ac_cv_sys_largefile_CC
   fi
 
-  echo "$as_me:12995: checking for _FILE_OFFSET_BITS value needed for large files" >&5
+  echo "$as_me:13945: checking for _FILE_OFFSET_BITS value needed for large files" >&5
 echo $ECHO_N "checking for _FILE_OFFSET_BITS value needed for large files... $ECHO_C" >&6
 if test "${ac_cv_sys_file_offset_bits+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -13000,7 +13950,7 @@ else
   while :; do
   ac_cv_sys_file_offset_bits=no
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 13003 "configure"
+#line 13953 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
  /* Check that off_t can represent 2**63 - 1 correctly.
@@ -13020,16 +13970,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:13023: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:13973: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:13026: \$? = $ac_status" >&5
+  echo "$as_me:13976: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:13029: \"$ac_try\"") >&5
+  { (eval echo "$as_me:13979: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:13032: \$? = $ac_status" >&5
+  echo "$as_me:13982: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   break
 else
@@ -13038,7 +13988,7 @@ cat "conftest.$ac_ext" >&5
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 13041 "configure"
+#line 13991 "configure"
 #include "confdefs.h"
 #define _FILE_OFFSET_BITS 64
 #include <sys/types.h>
@@ -13059,16 +14009,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:13062: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:14012: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:13065: \$? = $ac_status" >&5
+  echo "$as_me:14015: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:13068: \"$ac_try\"") >&5
+  { (eval echo "$as_me:14018: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:13071: \$? = $ac_status" >&5
+  echo "$as_me:14021: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_sys_file_offset_bits=64; break
 else
@@ -13079,7 +14029,7 @@ rm -f "conftest.$ac_objext" "conftest.$ac_ext"
   break
 done
 fi
-echo "$as_me:13082: result: $ac_cv_sys_file_offset_bits" >&5
+echo "$as_me:14032: result: $ac_cv_sys_file_offset_bits" >&5
 echo "${ECHO_T}$ac_cv_sys_file_offset_bits" >&6
 if test "$ac_cv_sys_file_offset_bits" != no; then
 
@@ -13089,7 +14039,7 @@ EOF
 
 fi
 rm -rf conftest*
-  echo "$as_me:13092: checking for _LARGE_FILES value needed for large files" >&5
+  echo "$as_me:14042: checking for _LARGE_FILES value needed for large files" >&5
 echo $ECHO_N "checking for _LARGE_FILES value needed for large files... $ECHO_C" >&6
 if test "${ac_cv_sys_large_files+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -13097,7 +14047,7 @@ else
   while :; do
   ac_cv_sys_large_files=no
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 13100 "configure"
+#line 14050 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
  /* Check that off_t can represent 2**63 - 1 correctly.
@@ -13117,16 +14067,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:13120: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:14070: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:13123: \$? = $ac_status" >&5
+  echo "$as_me:14073: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:13126: \"$ac_try\"") >&5
+  { (eval echo "$as_me:14076: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:13129: \$? = $ac_status" >&5
+  echo "$as_me:14079: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   break
 else
@@ -13135,7 +14085,7 @@ cat "conftest.$ac_ext" >&5
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 13138 "configure"
+#line 14088 "configure"
 #include "confdefs.h"
 #define _LARGE_FILES 1
 #include <sys/types.h>
@@ -13156,16 +14106,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:13159: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:14109: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:13162: \$? = $ac_status" >&5
+  echo "$as_me:14112: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:13165: \"$ac_try\"") >&5
+  { (eval echo "$as_me:14115: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:13168: \$? = $ac_status" >&5
+  echo "$as_me:14118: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_sys_large_files=1; break
 else
@@ -13176,7 +14126,7 @@ rm -f "conftest.$ac_objext" "conftest.$ac_ext"
   break
 done
 fi
-echo "$as_me:13179: result: $ac_cv_sys_large_files" >&5
+echo "$as_me:14129: result: $ac_cv_sys_large_files" >&5
 echo "${ECHO_T}$ac_cv_sys_large_files" >&6
 if test "$ac_cv_sys_large_files" != no; then
 
@@ -13189,7 +14139,7 @@ rm -rf conftest*
 fi
 
 	if test "$enable_largefile" != no ; then
-	echo "$as_me:13192: checking for _LARGEFILE_SOURCE value needed for large files" >&5
+	echo "$as_me:14142: checking for _LARGEFILE_SOURCE value needed for large files" >&5
 echo $ECHO_N "checking for _LARGEFILE_SOURCE value needed for large files... $ECHO_C" >&6
 if test "${ac_cv_sys_largefile_source+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -13197,28 +14147,31 @@ else
   while :; do
   ac_cv_sys_largefile_source=no
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 13200 "configure"
+#line 14150 "configure"
 #include "confdefs.h"
 #include <stdio.h>
+    #include <sys/types.h>
 int
 main (void)
 {
-return !fseeko;
+
+    int (*my_fseeko)(FILE *, off_t, int) = fseeko;
+    return my_fseeko(stdin, 0, 0);
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:13212: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:14165: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:13215: \$? = $ac_status" >&5
+  echo "$as_me:14168: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:13218: \"$ac_try\"") >&5
+  { (eval echo "$as_me:14171: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:13221: \$? = $ac_status" >&5
+  echo "$as_me:14174: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   break
 else
@@ -13227,29 +14180,32 @@ cat "conftest.$ac_ext" >&5
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 13230 "configure"
+#line 14183 "configure"
 #include "confdefs.h"
 #define _LARGEFILE_SOURCE 1
 #include <stdio.h>
+    #include <sys/types.h>
 int
 main (void)
 {
-return !fseeko;
+
+    int (*my_fseeko)(FILE *, off_t, int) = fseeko;
+    return my_fseeko(stdin, 0, 0);
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:13243: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:14199: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:13246: \$? = $ac_status" >&5
+  echo "$as_me:14202: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:13249: \"$ac_try\"") >&5
+  { (eval echo "$as_me:14205: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:13252: \$? = $ac_status" >&5
+  echo "$as_me:14208: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_sys_largefile_source=1; break
 else
@@ -13260,7 +14216,7 @@ rm -f "conftest.$ac_objext" "conftest.$ac_ext"
   break
 done
 fi
-echo "$as_me:13263: result: $ac_cv_sys_largefile_source" >&5
+echo "$as_me:14219: result: $ac_cv_sys_largefile_source" >&5
 echo "${ECHO_T}$ac_cv_sys_largefile_source" >&6
 if test "$ac_cv_sys_largefile_source" != no; then
 
@@ -13274,34 +14230,36 @@ rm -rf conftest*
 # We used to try defining _XOPEN_SOURCE=500 too, to work around a bug
 # in glibc 2.1.3, but that breaks too many other things.
 # If you want fseeko and ftello with glibc, upgrade to a fixed glibc.
-echo "$as_me:13277: checking for fseeko" >&5
+echo "$as_me:14233: checking for fseeko" >&5
 echo $ECHO_N "checking for fseeko... $ECHO_C" >&6
 if test "${ac_cv_func_fseeko+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 13283 "configure"
+#line 14239 "configure"
 #include "confdefs.h"
 #include <stdio.h>
+                             #include <sys/types.h>
 int
 main (void)
 {
-return fseeko && fseeko (stdin, 0, 0);
+int (*my_fseeko)(FILE *, off_t, int) = fseeko;
+                            return my_fseeko && my_fseeko (stdin, 0, 0);
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:13295: \"$ac_link\"") >&5
+if { (eval echo "$as_me:14253: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:13298: \$? = $ac_status" >&5
+  echo "$as_me:14256: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:13301: \"$ac_try\"") >&5
+  { (eval echo "$as_me:14259: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:13304: \$? = $ac_status" >&5
+  echo "$as_me:14262: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_func_fseeko=yes
 else
@@ -13311,7 +14269,7 @@ ac_cv_func_fseeko=no
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:13314: result: $ac_cv_func_fseeko" >&5
+echo "$as_me:14272: result: $ac_cv_func_fseeko" >&5
 echo "${ECHO_T}$ac_cv_func_fseeko" >&6
 if test $ac_cv_func_fseeko = yes; then
 
@@ -13350,28 +14308,32 @@ fi
 
 	fi
 
-	echo "$as_me:13353: checking whether to use struct dirent64" >&5
+	echo "$as_me:14311: checking whether to use struct dirent64" >&5
 echo $ECHO_N "checking whether to use struct dirent64... $ECHO_C" >&6
 if test "${cf_cv_struct_dirent64+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 		cat >"conftest.$ac_ext" <<_ACEOF
-#line 13360 "configure"
+#line 14318 "configure"
 #include "confdefs.h"
 
 #pragma GCC diagnostic error "-Wincompatible-pointer-types"
 #include <sys/types.h>
 #include <dirent.h>
 
+#ifndef __REDIRECT
+/* if transitional largefile support is setup, this is true */
+extern struct dirent64 * readdir(DIR *);
+#endif
+
 int
 main (void)
 {
 
-		/* if transitional largefile support is setup, this is true */
-		extern struct dirent64 * readdir(DIR *);
-		struct dirent64 *x = readdir((DIR *)0);
-		struct dirent *y = readdir((DIR *)0);
+		DIR *dp = opendir(".");
+		struct dirent64 *x = readdir(dp);
+		struct dirent *y = readdir(dp);
 		int z = x - y;
 		(void)z;
 
@@ -13380,16 +14342,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:13383: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:14345: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:13386: \$? = $ac_status" >&5
+  echo "$as_me:14348: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:13389: \"$ac_try\"") >&5
+  { (eval echo "$as_me:14351: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:13392: \$? = $ac_status" >&5
+  echo "$as_me:14354: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_struct_dirent64=yes
 else
@@ -13400,7 +14362,7 @@ fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 
 fi
-echo "$as_me:13403: result: $cf_cv_struct_dirent64" >&5
+echo "$as_me:14365: result: $cf_cv_struct_dirent64" >&5
 echo "${ECHO_T}$cf_cv_struct_dirent64" >&6
 	test "$cf_cv_struct_dirent64" = yes &&
 cat >>confdefs.h <<\EOF
@@ -13410,7 +14372,7 @@ EOF
 	fi
 
 ###   use option --disable-tparm-varargs to make tparm() conform to X/Open
-echo "$as_me:13413: checking if you want tparm not to use X/Open fixed-parameter list" >&5
+echo "$as_me:14375: checking if you want tparm not to use X/Open fixed-parameter list" >&5
 echo $ECHO_N "checking if you want tparm not to use X/Open fixed-parameter list... $ECHO_C" >&6
 
 # Check whether --enable-tparm-varargs or --disable-tparm-varargs was given.
@@ -13420,14 +14382,14 @@ if test "${enable_tparm_varargs+set}" = set; then
 else
   with_tparm_varargs=yes
 fi;
-echo "$as_me:13423: result: $with_tparm_varargs" >&5
+echo "$as_me:14385: result: $with_tparm_varargs" >&5
 echo "${ECHO_T}$with_tparm_varargs" >&6
 NCURSES_TPARM_VARARGS=0
 test "x$with_tparm_varargs" = xyes && NCURSES_TPARM_VARARGS=1
 
 ###   use option --disable-tic-depends to make libtic not explicitly depend on ncurses/ncursesw
 if test "$with_ticlib" != no ; then
-echo "$as_me:13430: checking if you want tic library to use explicit dependency on ncurses$LIB_SUFFIX library" >&5
+echo "$as_me:14392: checking if you want tic library to use explicit dependency on ncurses$LIB_SUFFIX library" >&5
 echo $ECHO_N "checking if you want tic library to use explicit dependency on ncurses$LIB_SUFFIX library... $ECHO_C" >&6
 
 # Check whether --enable-tic-depends or --disable-tic-depends was given.
@@ -13437,34 +14399,34 @@ if test "${enable_tic_depends+set}" = set; then
 else
   with_tic_depends=yes
 fi;
-echo "$as_me:13440: result: $with_tic_depends" >&5
+echo "$as_me:14402: result: $with_tic_depends" >&5
 echo "${ECHO_T}$with_tic_depends" >&6
 else
 	with_tic_depends=no
 fi
 
-###   use option --disable-wattr-macros to suppress wattr* macros from curses.h
-echo "$as_me:13447: checking if you want to suppress wattr* macros to help with ncurses5/ncurses6 transition" >&5
-echo $ECHO_N "checking if you want to suppress wattr* macros to help with ncurses5/ncurses6 transition... $ECHO_C" >&6
+###   use option --enable-wattr-macros to enable wattr* macros in curses.h
+echo "$as_me:14409: checking if you want to enable wattr* macros" >&5
+echo $ECHO_N "checking if you want to enable wattr* macros... $ECHO_C" >&6
 
 # Check whether --enable-wattr-macros or --disable-wattr-macros was given.
 if test "${enable_wattr_macros+set}" = set; then
   enableval="$enable_wattr_macros"
   with_wattr_macros=$enableval
 else
-  with_wattr_macros=yes
+  with_wattr_macros=no
 fi;
 if [ "x$with_wattr_macros" != xyes ]; then
 	NCURSES_WATTR_MACROS=0
-	echo "$as_me:13459: result: yes" >&5
-echo "${ECHO_T}yes" >&6
+	echo "$as_me:14421: result: no" >&5
+echo "${ECHO_T}no" >&6
 else
 	NCURSES_WATTR_MACROS=1
-	echo "$as_me:13463: result: no" >&5
-echo "${ECHO_T}no" >&6
+	echo "$as_me:14425: result: yes" >&5
+echo "${ECHO_T}yes" >&6
 fi
 
-echo "$as_me:13467: checking for X11 rgb file" >&5
+echo "$as_me:14429: checking for X11 rgb file" >&5
 echo $ECHO_N "checking for X11 rgb file... $ECHO_C" >&6
 
 # Check whether --with-x11-rgb or --without-x11-rgb was given.
@@ -13528,7 +14490,7 @@ case ".$cf_path" in
 	cf_path=`echo "$cf_path" | sed -e s%NONE%$cf_path_syntax%`
 	;;
 (*)
-	{ { echo "$as_me:13531: error: expected a pathname, not \"$cf_path\"" >&5
+	{ { echo "$as_me:14493: error: expected a pathname, not \"$cf_path\"" >&5
 echo "$as_me: error: expected a pathname, not \"$cf_path\"" >&2;}
    { (exit 1); exit 1; }; }
 	;;
@@ -13536,7 +14498,7 @@ esac
 
 fi
 
-echo "$as_me:13539: result: $RGB_PATH" >&5
+echo "$as_me:14501: result: $RGB_PATH" >&5
 echo "${ECHO_T}$RGB_PATH" >&6
 
 cat >>confdefs.h <<EOF
@@ -13550,7 +14512,8 @@ then
 fi
 
 ###   use option --with-bool to override bool's type
-echo "$as_me:13553: checking for type of bool" >&5
+
+echo "$as_me:14516: checking for type of bool" >&5
 echo $ECHO_N "checking for type of bool... $ECHO_C" >&6
 
 # Check whether --with-bool or --without-bool was given.
@@ -13560,10 +14523,17 @@ if test "${with_bool+set}" = set; then
 else
   NCURSES_BOOL=auto
 fi;
-echo "$as_me:13563: result: $NCURSES_BOOL" >&5
+echo "$as_me:14526: result: $NCURSES_BOOL" >&5
 echo "${ECHO_T}$NCURSES_BOOL" >&6
+case x$NCURSES_BOOL in
+(x|xyes|xno)
+	{ { echo "$as_me:14530: error: expected a type name for bool" >&5
+echo "$as_me: error: expected a type name for bool" >&2;}
+   { (exit 1); exit 1; }; }
+	;;
+esac
 
-echo "$as_me:13566: checking for alternate terminal capabilities file" >&5
+echo "$as_me:14536: checking for alternate terminal capabilities file" >&5
 echo $ECHO_N "checking for alternate terminal capabilities file... $ECHO_C" >&6
 
 # Check whether --with-caps or --without-caps was given.
@@ -13573,258 +14543,102 @@ if test "${with_caps+set}" = set; then
 else
   TERMINFO_CAPS=Caps
 fi;
-test -f "${srcdir}/include/${TERMINFO_CAPS}" || TERMINFO_CAPS=Caps
-echo "$as_me:13577: result: $TERMINFO_CAPS" >&5
-echo "${ECHO_T}$TERMINFO_CAPS" >&6
-
-###   use option --with-chtype to override chtype's type
-echo "$as_me:13581: checking for type of chtype" >&5
-echo $ECHO_N "checking for type of chtype... $ECHO_C" >&6
-
-# Check whether --with-chtype or --without-chtype was given.
-if test "${with_chtype+set}" = set; then
-  withval="$with_chtype"
-  NCURSES_CHTYPE="$withval"
-else
-  NCURSES_CHTYPE=$cf_dft_chtype
-fi;
-echo "$as_me:13591: result: $NCURSES_CHTYPE" >&5
-echo "${ECHO_T}$NCURSES_CHTYPE" >&6
-
-###   use option --with-ospeed to override ospeed's type
-echo "$as_me:13595: checking for type of ospeed" >&5
-echo $ECHO_N "checking for type of ospeed... $ECHO_C" >&6
-
-# Check whether --with-ospeed or --without-ospeed was given.
-if test "${with_ospeed+set}" = set; then
-  withval="$with_ospeed"
-  NCURSES_OSPEED="$withval"
-else
-  NCURSES_OSPEED=short
-fi;
-echo "$as_me:13605: result: $NCURSES_OSPEED" >&5
-echo "${ECHO_T}$NCURSES_OSPEED" >&6
-
-###   use option --with-mmask-t to override mmask_t's type
-echo "$as_me:13609: checking for type of mmask_t" >&5
-echo $ECHO_N "checking for type of mmask_t... $ECHO_C" >&6
-
-# Check whether --with-mmask-t or --without-mmask-t was given.
-if test "${with_mmask_t+set}" = set; then
-  withval="$with_mmask_t"
-  NCURSES_MMASK_T="$withval"
-else
-  NCURSES_MMASK_T=$cf_dft_mmask_t
-fi;
-echo "$as_me:13619: result: $NCURSES_MMASK_T" >&5
-echo "${ECHO_T}$NCURSES_MMASK_T" >&6
-
-###   use option --with-ccharw-max to override CCHARW_MAX size
-echo "$as_me:13623: checking for size CCHARW_MAX" >&5
-echo $ECHO_N "checking for size CCHARW_MAX... $ECHO_C" >&6
-
-# Check whether --with-ccharw-max or --without-ccharw-max was given.
-if test "${with_ccharw_max+set}" = set; then
-  withval="$with_ccharw_max"
-  NCURSES_CCHARW_MAX="$withval"
-else
-  NCURSES_CCHARW_MAX=5
-fi;
-echo "$as_me:13633: result: $NCURSES_CCHARW_MAX" >&5
-echo "${ECHO_T}$NCURSES_CCHARW_MAX" >&6
-
-echo "$as_me:13636: checking for ANSI C header files" >&5
-echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
-if test "${ac_cv_header_stdc+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >"conftest.$ac_ext" <<_ACEOF
-#line 13642 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-
-_ACEOF
-if { (eval echo "$as_me:13650: \"$ac_cpp "conftest.$ac_ext"\"") >&5
-  (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
-  ac_status=$?
-  $EGREP -v '^ *\+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:13656: \$? = $ac_status" >&5
-  (exit "$ac_status"); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
-  ac_cv_header_stdc=yes
-else
-  echo "$as_me: failed program was:" >&5
-  cat "conftest.$ac_ext" >&5
-  ac_cv_header_stdc=no
-fi
-rm -f conftest.err "conftest.$ac_ext"
-
-if test $ac_cv_header_stdc = yes; then
-  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
-  cat >"conftest.$ac_ext" <<_ACEOF
-#line 13678 "configure"
-#include "confdefs.h"
-#include <string.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "memchr" >/dev/null 2>&1; then
-  :
-else
-  ac_cv_header_stdc=no
-fi
-rm -rf conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
-  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
-  cat >"conftest.$ac_ext" <<_ACEOF
-#line 13696 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "free" >/dev/null 2>&1; then
-  :
-else
-  ac_cv_header_stdc=no
-fi
-rm -rf conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
-  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
-  if test "$cross_compiling" = yes; then
-  :
-else
-  cat >"conftest.$ac_ext" <<_ACEOF
-#line 13717 "configure"
-#include "confdefs.h"
-#include <ctype.h>
-#if ((' ' & 0x0FF) == 0x020)
-# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#else
-# define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \
-                     || ('j' <= (c) && (c) <= 'r') \
-                     || ('s' <= (c) && (c) <= 'z'))
-# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
-#endif
-
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
-int
-main (void)
-{
-  int i;
-  for (i = 0; i < 256; i++)
-    if (XOR (islower (i), ISLOWER (i))
-        || toupper (i) != TOUPPER (i))
-      $ac_main_return(2);
-  $ac_main_return (0);
-}
-_ACEOF
-rm -f "conftest$ac_exeext"
-if { (eval echo "$as_me:13743: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:13746: \$? = $ac_status" >&5
-  (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
-  { (eval echo "$as_me:13748: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:13751: \$? = $ac_status" >&5
-  (exit "$ac_status"); }; }; then
-  :
-else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-cat "conftest.$ac_ext" >&5
-ac_cv_header_stdc=no
-fi
-rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftest.$ac_ext"
-fi
-fi
+if test ! -f "${srcdir}/include/${TERMINFO_CAPS}"
+then
+	{ echo "$as_me:14548: WARNING: file not found: \"${srcdir}/include/${TERMINFO_CAPS}\"" >&5
+echo "$as_me: WARNING: file not found: \"${srcdir}/include/${TERMINFO_CAPS}\"" >&2;}
+	TERMINFO_CAPS=Caps
 fi
-echo "$as_me:13764: result: $ac_cv_header_stdc" >&5
-echo "${ECHO_T}$ac_cv_header_stdc" >&6
-if test $ac_cv_header_stdc = yes; then
+echo "$as_me:14552: result: $TERMINFO_CAPS" >&5
+echo "${ECHO_T}$TERMINFO_CAPS" >&6
 
-cat >>confdefs.h <<\EOF
-#define STDC_HEADERS 1
-EOF
+###   use option --with-chtype to override chtype's type
 
-fi
+echo "$as_me:14557: checking for type of chtype" >&5
+echo $ECHO_N "checking for type of chtype... $ECHO_C" >&6
 
-# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+# Check whether --with-chtype or --without-chtype was given.
+if test "${with_chtype+set}" = set; then
+  withval="$with_chtype"
+  NCURSES_CHTYPE="$withval"
+else
+  NCURSES_CHTYPE=$cf_dft_chtype
+fi;
+echo "$as_me:14567: result: $NCURSES_CHTYPE" >&5
+echo "${ECHO_T}$NCURSES_CHTYPE" >&6
+case x$NCURSES_CHTYPE in
+(x|xyes|xno)
+	{ { echo "$as_me:14571: error: expected a type name for chtype" >&5
+echo "$as_me: error: expected a type name for chtype" >&2;}
+   { (exit 1); exit 1; }; }
+	;;
+esac
 
-for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
-                  inttypes.h stdint.h unistd.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:13780: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+###   use option --with-ospeed to override ospeed's type
+
+echo "$as_me:14579: checking for type of ospeed" >&5
+echo $ECHO_N "checking for type of ospeed... $ECHO_C" >&6
+
+# Check whether --with-ospeed or --without-ospeed was given.
+if test "${with_ospeed+set}" = set; then
+  withval="$with_ospeed"
+  NCURSES_OSPEED="$withval"
 else
-  cat >"conftest.$ac_ext" <<_ACEOF
-#line 13786 "configure"
-#include "confdefs.h"
-$ac_includes_default
-#include <$ac_header>
-_ACEOF
-rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:13792: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:13795: \$? = $ac_status" >&5
-  (exit "$ac_status"); } &&
-         { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:13798: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:13801: \$? = $ac_status" >&5
-  (exit "$ac_status"); }; }; then
-  eval "$as_ac_Header=yes"
+  NCURSES_OSPEED=short
+fi;
+echo "$as_me:14589: result: $NCURSES_OSPEED" >&5
+echo "${ECHO_T}$NCURSES_OSPEED" >&6
+case x$NCURSES_OSPEED in
+(x|xyes|xno)
+	{ { echo "$as_me:14593: error: expected a type name for ospeed" >&5
+echo "$as_me: error: expected a type name for ospeed" >&2;}
+   { (exit 1); exit 1; }; }
+	;;
+esac
+
+###   use option --with-mmask-t to override mmask_t's type
+
+echo "$as_me:14601: checking for type of mmask-t" >&5
+echo $ECHO_N "checking for type of mmask-t... $ECHO_C" >&6
+
+# Check whether --with-mmask-t or --without-mmask-t was given.
+if test "${with_mmask_t+set}" = set; then
+  withval="$with_mmask_t"
+  NCURSES_MMASK_T="$withval"
 else
-  echo "$as_me: failed program was:" >&5
-cat "conftest.$ac_ext" >&5
-eval "$as_ac_Header=no"
-fi
-rm -f "conftest.$ac_objext" "conftest.$ac_ext"
-fi
-echo "$as_me:13811: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
-echo "${ECHO_T}`eval echo '${'"$as_ac_Header"'}'`" >&6
-if test "`eval echo '${'"$as_ac_Header"'}'`" = yes; then
-  cat >>confdefs.h <<EOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-EOF
+  NCURSES_MMASK_T=$cf_dft_mmask_t
+fi;
+echo "$as_me:14611: result: $NCURSES_MMASK_T" >&5
+echo "${ECHO_T}$NCURSES_MMASK_T" >&6
+case x$NCURSES_MMASK_T in
+(x|xyes|xno)
+	{ { echo "$as_me:14615: error: expected a type name for mmask-t" >&5
+echo "$as_me: error: expected a type name for mmask-t" >&2;}
+   { (exit 1); exit 1; }; }
+	;;
+esac
 
-fi
-done
+###   use option --with-ccharw-max to override CCHARW_MAX size
+echo "$as_me:14622: checking for size CCHARW_MAX" >&5
+echo $ECHO_N "checking for size CCHARW_MAX... $ECHO_C" >&6
+
+# Check whether --with-ccharw-max or --without-ccharw-max was given.
+if test "${with_ccharw_max+set}" = set; then
+  withval="$with_ccharw_max"
+  NCURSES_CCHARW_MAX="$withval"
+else
+  NCURSES_CCHARW_MAX=$cf_dft_ccharw_max
+fi;
+echo "$as_me:14632: result: $NCURSES_CCHARW_MAX" >&5
+echo "${ECHO_T}$NCURSES_CCHARW_MAX" >&6
 
-echo "$as_me:13821: checking for signed char" >&5
+echo "$as_me:14635: checking for signed char" >&5
 echo $ECHO_N "checking for signed char... $ECHO_C" >&6
 if test "${ac_cv_type_signed_char+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 13827 "configure"
+#line 14641 "configure"
 #include "confdefs.h"
 $ac_includes_default
 int
@@ -13839,16 +14653,16 @@ if (sizeof (signed char))
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:13842: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:14656: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:13845: \$? = $ac_status" >&5
+  echo "$as_me:14659: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:13848: \"$ac_try\"") >&5
+  { (eval echo "$as_me:14662: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:13851: \$? = $ac_status" >&5
+  echo "$as_me:14665: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_type_signed_char=yes
 else
@@ -13858,10 +14672,10 @@ ac_cv_type_signed_char=no
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 fi
-echo "$as_me:13861: result: $ac_cv_type_signed_char" >&5
+echo "$as_me:14675: result: $ac_cv_type_signed_char" >&5
 echo "${ECHO_T}$ac_cv_type_signed_char" >&6
 
-echo "$as_me:13864: checking size of signed char" >&5
+echo "$as_me:14678: checking size of signed char" >&5
 echo $ECHO_N "checking size of signed char... $ECHO_C" >&6
 if test "${ac_cv_sizeof_signed_char+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -13870,7 +14684,7 @@ else
   if test "$cross_compiling" = yes; then
   # Depending upon the size, compute the lo and hi bounds.
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 13873 "configure"
+#line 14687 "configure"
 #include "confdefs.h"
 $ac_includes_default
 int
@@ -13882,21 +14696,21 @@ int _array_ [1 - 2 * !((sizeof (signed char)) >= 0)]
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:13885: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:14699: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:13888: \$? = $ac_status" >&5
+  echo "$as_me:14702: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:13891: \"$ac_try\"") >&5
+  { (eval echo "$as_me:14705: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:13894: \$? = $ac_status" >&5
+  echo "$as_me:14708: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_lo=0 ac_mid=0
   while :; do
     cat >"conftest.$ac_ext" <<_ACEOF
-#line 13899 "configure"
+#line 14713 "configure"
 #include "confdefs.h"
 $ac_includes_default
 int
@@ -13908,16 +14722,16 @@ int _array_ [1 - 2 * !((sizeof (signed char)) <= $ac_mid)]
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:13911: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:14725: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:13914: \$? = $ac_status" >&5
+  echo "$as_me:14728: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:13917: \"$ac_try\"") >&5
+  { (eval echo "$as_me:14731: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:13920: \$? = $ac_status" >&5
+  echo "$as_me:14734: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_hi=$ac_mid; break
 else
@@ -13933,7 +14747,7 @@ cat "conftest.$ac_ext" >&5
 ac_hi=-1 ac_mid=-1
   while :; do
     cat >"conftest.$ac_ext" <<_ACEOF
-#line 13936 "configure"
+#line 14750 "configure"
 #include "confdefs.h"
 $ac_includes_default
 int
@@ -13945,16 +14759,16 @@ int _array_ [1 - 2 * !((sizeof (signed char)) >= $ac_mid)]
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:13948: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:14762: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:13951: \$? = $ac_status" >&5
+  echo "$as_me:14765: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:13954: \"$ac_try\"") >&5
+  { (eval echo "$as_me:14768: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:13957: \$? = $ac_status" >&5
+  echo "$as_me:14771: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_lo=$ac_mid; break
 else
@@ -13970,7 +14784,7 @@ rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 while test "x$ac_lo" != "x$ac_hi"; do
   ac_mid=`expr '(' "$ac_hi" - "$ac_lo" ')' / 2 + "$ac_lo"`
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 13973 "configure"
+#line 14787 "configure"
 #include "confdefs.h"
 $ac_includes_default
 int
@@ -13982,16 +14796,16 @@ int _array_ [1 - 2 * !((sizeof (signed char)) <= $ac_mid)]
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:13985: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:14799: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:13988: \$? = $ac_status" >&5
+  echo "$as_me:14802: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:13991: \"$ac_try\"") >&5
+  { (eval echo "$as_me:14805: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:13994: \$? = $ac_status" >&5
+  echo "$as_me:14808: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_hi=$ac_mid
 else
@@ -14004,12 +14818,12 @@ done
 ac_cv_sizeof_signed_char=$ac_lo
 else
   if test "$cross_compiling" = yes; then
-  { { echo "$as_me:14007: error: cannot run test program while cross compiling" >&5
+  { { echo "$as_me:14821: error: cannot run test program while cross compiling" >&5
 echo "$as_me: error: cannot run test program while cross compiling" >&2;}
    { (exit 1); exit 1; }; }
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 14012 "configure"
+#line 14826 "configure"
 #include "confdefs.h"
 $ac_includes_default
 int
@@ -14018,22 +14832,22 @@ main (void)
 FILE *f = fopen ("conftest.val", "w");
 if (!f)
   $ac_main_return (1);
-fprintf (f, "%d", (sizeof (signed char)));
+fprintf (f, "%ld", (long)(sizeof (signed char)));
 fclose (f);
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest$ac_exeext"
-if { (eval echo "$as_me:14028: \"$ac_link\"") >&5
+if { (eval echo "$as_me:14842: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:14031: \$? = $ac_status" >&5
+  echo "$as_me:14845: \$? = $ac_status" >&5
   (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
-  { (eval echo "$as_me:14033: \"$ac_try\"") >&5
+  { (eval echo "$as_me:14847: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:14036: \$? = $ac_status" >&5
+  echo "$as_me:14850: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_sizeof_signed_char=`cat conftest.val`
 else
@@ -14049,7 +14863,7 @@ else
   ac_cv_sizeof_signed_char=0
 fi
 fi
-echo "$as_me:14052: result: $ac_cv_sizeof_signed_char" >&5
+echo "$as_me:14866: result: $ac_cv_sizeof_signed_char" >&5
 echo "${ECHO_T}$ac_cv_sizeof_signed_char" >&6
 cat >>confdefs.h <<EOF
 #define SIZEOF_SIGNED_CHAR $ac_cv_sizeof_signed_char
@@ -14060,23 +14874,24 @@ if test "$ac_cv_sizeof_signed_char" = 1 ; then
 else
 	NCURSES_SBOOL="char"
 fi
-echo "$as_me:14063: checking if you want to use signed Boolean array in term.h" >&5
-echo $ECHO_N "checking if you want to use signed Boolean array in term.h... $ECHO_C" >&6
+echo "$as_me:14877: checking whether to use signed chars for Boolean array in term.h" >&5
+echo $ECHO_N "checking whether to use signed chars for Boolean array in term.h... $ECHO_C" >&6
 
 # Check whether --enable-signed-char or --disable-signed-char was given.
 if test "${enable_signed_char+set}" = set; then
   enableval="$enable_signed_char"
   with_signed_char=$enableval
 else
-  with_signed_char=no
+  with_signed_char=$cf_dft_signed_char
 fi;
-echo "$as_me:14073: result: $with_signed_char" >&5
+echo "$as_me:14887: result: $with_signed_char" >&5
 echo "${ECHO_T}$with_signed_char" >&6
 test "x$with_signed_char" != xyes && NCURSES_SBOOL="char"
 
 ###   use option --with-tparm-arg to override tparm's argument type
-echo "$as_me:14078: checking for type of tparm args" >&5
-echo $ECHO_N "checking for type of tparm args... $ECHO_C" >&6
+
+echo "$as_me:14893: checking for type of tparm-arg" >&5
+echo $ECHO_N "checking for type of tparm-arg... $ECHO_C" >&6
 
 # Check whether --with-tparm-arg or --without-tparm-arg was given.
 if test "${with_tparm_arg+set}" = set; then
@@ -14085,11 +14900,18 @@ if test "${with_tparm_arg+set}" = set; then
 else
   NCURSES_TPARM_ARG=$cf_dft_tparm_arg
 fi;
-echo "$as_me:14088: result: $NCURSES_TPARM_ARG" >&5
+echo "$as_me:14903: result: $NCURSES_TPARM_ARG" >&5
 echo "${ECHO_T}$NCURSES_TPARM_ARG" >&6
+case x$NCURSES_TPARM_ARG in
+(x|xyes|xno)
+	{ { echo "$as_me:14907: error: expected a type name for tparm-arg" >&5
+echo "$as_me: error: expected a type name for tparm-arg" >&2;}
+   { (exit 1); exit 1; }; }
+	;;
+esac
 
 ### Enable compiling-in rcs id's
-echo "$as_me:14092: checking if RCS identifiers should be compiled-in" >&5
+echo "$as_me:14914: checking if RCS identifiers should be compiled-in" >&5
 echo $ECHO_N "checking if RCS identifiers should be compiled-in... $ECHO_C" >&6
 
 # Check whether --with-rcs-ids or --without-rcs-ids was given.
@@ -14099,7 +14921,7 @@ if test "${with_rcs_ids+set}" = set; then
 else
   with_rcs_ids=no
 fi;
-echo "$as_me:14102: result: $with_rcs_ids" >&5
+echo "$as_me:14924: result: $with_rcs_ids" >&5
 echo "${ECHO_T}$with_rcs_ids" >&6
 test "x$with_rcs_ids" = xyes &&
 cat >>confdefs.h <<\EOF
@@ -14108,7 +14930,7 @@ EOF
 
 ###############################################################################
 
-echo "$as_me:14111: checking format of man-pages" >&5
+echo "$as_me:14933: checking format of man-pages" >&5
 echo $ECHO_N "checking format of man-pages... $ECHO_C" >&6
 
 # Check whether --with-manpage-format or --without-manpage-format was given.
@@ -14130,7 +14952,7 @@ case "$MANPAGE_FORMAT" in
 		MANPATH="/usr/man:/usr/share/man"
 	fi
 
-	# look for the 'date' man-page (it's most likely to be installed!)
+	# look for the 'date' man-page (it is most likely to be installed!)
 	MANPAGE_FORMAT=
 	cf_preform="no"
 	cf_catonly="yes"
@@ -14145,10 +14967,12 @@ case "$MANPAGE_FORMAT" in
 			if test "x$cf_test" = "x$cf_name" ; then
 
 				case "$cf_name" in
-				(*.gz) MANPAGE_FORMAT="$MANPAGE_FORMAT gzip";;
-				(*.Z)  MANPAGE_FORMAT="$MANPAGE_FORMAT compress";;
-				(*.0)  MANPAGE_FORMAT="$MANPAGE_FORMAT BSDI";;
-				(*)    MANPAGE_FORMAT="$MANPAGE_FORMAT normal";;
+				(*.bz2) MANPAGE_FORMAT="$MANPAGE_FORMAT bzip2";;
+				(*.xz)  MANPAGE_FORMAT="$MANPAGE_FORMAT xz";;
+				(*.gz)  MANPAGE_FORMAT="$MANPAGE_FORMAT gzip";;
+				(*.Z)   MANPAGE_FORMAT="$MANPAGE_FORMAT compress";;
+				(*.0)   MANPAGE_FORMAT="$MANPAGE_FORMAT BSDI";;
+				(*)     MANPAGE_FORMAT="$MANPAGE_FORMAT normal";;
 				esac
 
 				case "$cf_name" in
@@ -14187,7 +15011,7 @@ case "$MANPAGE_FORMAT" in
 (*)
 	for cf_option in $MANPAGE_FORMAT; do
 	case "$cf_option" in
-	(gzip|compress|BSDI|normal|formatted|catonly)
+	(xz|bzip2|gzip|compress|BSDI|normal|formatted|catonly)
 		;;
 	(*)
 		cf_unknown="$cf_unknown $cf_option"
@@ -14197,14 +15021,51 @@ case "$MANPAGE_FORMAT" in
 	;;
 esac
 
-echo "$as_me:14200: result: $MANPAGE_FORMAT" >&5
+echo "$as_me:15024: result: $MANPAGE_FORMAT" >&5
 echo "${ECHO_T}$MANPAGE_FORMAT" >&6
 if test -n "$cf_unknown" ; then
-	{ echo "$as_me:14203: WARNING: Unexpected manpage-format $cf_unknown" >&5
+	{ echo "$as_me:15027: WARNING: Unexpected manpage-format $cf_unknown" >&5
 echo "$as_me: WARNING: Unexpected manpage-format $cf_unknown" >&2;}
 fi
 
-echo "$as_me:14207: checking for manpage renaming" >&5
+cf_manpage_format=no
+cf_manpage_inboth=no
+cf_manpage_so_strip=
+cf_manpage_compress=
+cf_manpage_coptions=
+
+for cf_item in $MANPAGE_FORMAT
+do
+case "$cf_item" in
+(catonly)
+	cf_manpage_format=yes
+	cf_manpage_inboth=no
+	;;
+(formatted)
+	cf_manpage_format=yes
+	cf_manpage_inboth=yes
+	;;
+(compress)
+	cf_manpage_so_strip="Z"
+	cf_manpage_compress=compress
+	;;
+(gzip)
+	cf_manpage_so_strip="gz"
+	cf_manpage_compress=gzip
+	cf_manpage_coptions=-n
+	;;
+(bzip2)
+	cf_manpage_so_strip="bz2"
+	cf_manpage_compress=bzip2
+	;;
+(xz)
+	cf_manpage_so_strip="xz"
+	cf_manpage_compress=xz
+	;;
+esac
+done
+
+echo "$as_me:15068: checking for manpage renaming" >&5
 echo $ECHO_N "checking for manpage renaming... $ECHO_C" >&6
 
 # Check whether --with-manpage-renames or --without-manpage-renames was given.
@@ -14221,35 +15082,27 @@ case ".$MANPAGE_RENAMES" in
 (.|.yes)
 	# Debian 'man' program?
 	if test -f /etc/debian_version ; then
-		MANPAGE_RENAMES=`cd "$srcdir" && pwd`/man/man_db.renames
+		MANPAGE_RENAMES=man/man_db.renames
 	else
 		MANPAGE_RENAMES=no
 	fi
 	;;
 esac
 
-if test "$MANPAGE_RENAMES" != no ; then
-	if test -f "$srcdir/man/$MANPAGE_RENAMES" ; then
-		MANPAGE_RENAMES=`cd "$srcdir/man" && pwd`/$MANPAGE_RENAMES
-	elif test ! -f "$MANPAGE_RENAMES" ; then
-		{ { echo "$as_me:14235: error: not a filename: $MANPAGE_RENAMES" >&5
+if test "$MANPAGE_RENAMES" = man/man_db.renames ; then
+	MANPAGE_RENAMES=`pwd`/$MANPAGE_RENAMES
+elif test "$MANPAGE_RENAMES" = no ; then
+	:
+elif test ! -f "$MANPAGE_RENAMES" ; then
+	{ { echo "$as_me:15097: error: not a filename: $MANPAGE_RENAMES" >&5
 echo "$as_me: error: not a filename: $MANPAGE_RENAMES" >&2;}
    { (exit 1); exit 1; }; }
-	fi
-
-	test ! -d man && mkdir man
-
-	# Construct a sed-script to perform renaming within man-pages
-	if test -n "$MANPAGE_RENAMES" ; then
-		test ! -d man && mkdir man
-		$SHELL "$srcdir/man/make_sed.sh" "$MANPAGE_RENAMES" >./edit_man.sed
-	fi
 fi
 
-echo "$as_me:14249: result: $MANPAGE_RENAMES" >&5
+echo "$as_me:15102: result: $MANPAGE_RENAMES" >&5
 echo "${ECHO_T}$MANPAGE_RENAMES" >&6
 
-echo "$as_me:14252: checking if manpage aliases will be installed" >&5
+echo "$as_me:15105: checking if manpage aliases will be installed" >&5
 echo $ECHO_N "checking if manpage aliases will be installed... $ECHO_C" >&6
 
 # Check whether --with-manpage-aliases or --without-manpage-aliases was given.
@@ -14260,7 +15113,7 @@ else
   MANPAGE_ALIASES=yes
 fi;
 
-echo "$as_me:14263: result: $MANPAGE_ALIASES" >&5
+echo "$as_me:15116: result: $MANPAGE_ALIASES" >&5
 echo "${ECHO_T}$MANPAGE_ALIASES" >&6
 
 case "x$LN_S" in
@@ -14274,7 +15127,7 @@ esac
 
 MANPAGE_SYMLINKS=no
 if test "$MANPAGE_ALIASES" = yes ; then
-echo "$as_me:14277: checking if manpage symlinks should be used" >&5
+echo "$as_me:15130: checking if manpage symlinks should be used" >&5
 echo $ECHO_N "checking if manpage symlinks should be used... $ECHO_C" >&6
 
 # Check whether --with-manpage-symlinks or --without-manpage-symlinks was given.
@@ -14285,19 +15138,19 @@ else
   MANPAGE_SYMLINKS=$cf_use_symlinks
 fi;
 
-if test "$$cf_use_symlinks" = no; then
+if test "$cf_use_symlinks" = no; then
 if test "$MANPAGE_SYMLINKS" = yes ; then
-	{ echo "$as_me:14290: WARNING: cannot make symlinks" >&5
+	{ echo "$as_me:15143: WARNING: cannot make symlinks" >&5
 echo "$as_me: WARNING: cannot make symlinks" >&2;}
 	MANPAGE_SYMLINKS=no
 fi
 fi
 
-echo "$as_me:14296: result: $MANPAGE_SYMLINKS" >&5
+echo "$as_me:15149: result: $MANPAGE_SYMLINKS" >&5
 echo "${ECHO_T}$MANPAGE_SYMLINKS" >&6
 fi
 
-echo "$as_me:14300: checking for manpage tbl" >&5
+echo "$as_me:15153: checking for manpage tbl" >&5
 echo $ECHO_N "checking for manpage tbl... $ECHO_C" >&6
 
 # Check whether --with-manpage-tbl or --without-manpage-tbl was given.
@@ -14308,7 +15161,7 @@ else
   MANPAGE_TBL=no
 fi;
 
-echo "$as_me:14311: result: $MANPAGE_TBL" >&5
+echo "$as_me:15164: result: $MANPAGE_TBL" >&5
 echo "${ECHO_T}$MANPAGE_TBL" >&6
 
 if test "$prefix" = "NONE" ; then
@@ -14317,36 +15170,8 @@ else
 	cf_prefix="$prefix"
 fi
 
-case "$MANPAGE_FORMAT" in
-(*catonly*)
-	cf_format=yes
-	cf_inboth=no
-	;;
-(*formatted*)
-	cf_format=yes
-	cf_inboth=yes
-	;;
-(*)
-	cf_format=no
-	cf_inboth=no
-	;;
-esac
-
 test ! -d man && mkdir man
 
-cf_so_strip=
-cf_compress=
-case "$MANPAGE_FORMAT" in
-(*compress*)
-	cf_so_strip="Z"
-	cf_compress=compress
-	;;
-(*gzip*)
-	cf_so_strip="gz"
-	cf_compress=gzip
-	;;
-esac
-
 cf_edit_man=./edit_man.sh
 cf_man_alias=`pwd`/man_alias.sed
 
@@ -14364,6 +15189,7 @@ NCURSES_PATCH="$NCURSES_PATCH"
 
 NCURSES_OSPEED="$NCURSES_OSPEED"
 TERMINFO="$TERMINFO"
+TERMINFO_DIRS="$TERMINFO_DIRS"
 
 INSTALL="$INSTALL"
 INSTALL_DATA="$INSTALL_DATA"
@@ -14371,7 +15197,8 @@ INSTALL_DATA="$INSTALL_DATA"
 transform="$program_transform_name"
 
 TMP=\${TMPDIR:=/tmp}/man\$\$
-trap "rm -f \$TMP" 0 1 2 3 15
+trap "rm -f \$TMP; exit 1" 1 2 3 15
+trap "rm -f \$TMP" 0
 
 form=\$1
 shift || exit 1
@@ -14387,8 +15214,8 @@ top_srcdir=\$srcdir/..
 shift || exit 1
 
 if test "\$form" = normal ; then
-	if test "$cf_format" = yes ; then
-	if test "$cf_inboth" = no ; then
+	if test "$cf_manpage_format" = yes ; then
+	if test "$cf_manpage_inboth" = no ; then
 		$SHELL "\$0" format "\$verb" "\$mandir" "\$srcdir" "\$@"
 		exit $?
 	fi
@@ -14440,9 +15267,9 @@ CF_EOF2
 
 	aliases=
 	cf_source=\`basename "\$i"\`
-	inalias=\$cf_source
-	test ! -f "\$inalias" && inalias="\$srcdir/\$inalias"
-	if test ! -f "\$inalias" ; then
+	cf_full_alias=\$cf_source
+	test ! -f "\$cf_full_alias" && cf_full_alias="\$srcdir/\$cf_full_alias"
+	if test ! -f "\$cf_full_alias" ; then
 		echo ".. skipped \$cf_source"
 		continue
 	fi
@@ -14451,8 +15278,9 @@ CF_EOF
 if test "$MANPAGE_ALIASES" != no ; then
 cat >>$cf_edit_man <<CF_EOF
 	nCurses=ignore.3x
+	cf_part_alias=\`echo \$cf_full_alias| sed -e 's,^.*/,,'\`
 	test "$with_curses_h" = yes && nCurses=ncurses.3x
-	aliases=\`sed -f "\$top_srcdir/man/manlinks.sed" "\$inalias" |sed -f "$cf_man_alias" | sort -u; test "\$inalias" = "\$nCurses" && echo curses\`
+	aliases=\`sed -f "\$top_srcdir/man/manlinks.sed" "\$cf_full_alias" |sed -f "$cf_man_alias" | sort -u; test "\$cf_part_alias" = "\$nCurses" && echo curses\`
 CF_EOF
 fi
 
@@ -14481,7 +15309,7 @@ cat >>$cf_edit_man <<CF_EOF
 	sed	-f "$cf_man_alias" \\
 CF_EOF
 
-if test -f "$MANPAGE_RENAMES" ; then
+if test "$MANPAGE_RENAMES" != no ; then
 cat >>$cf_edit_man <<CF_EOF
 		< "\$i" | sed -f `pwd`/edit_man.sed >\$TMP
 CF_EOF
@@ -14519,15 +15347,15 @@ cat >>$cf_edit_man <<CF_EOF
 	fi
 CF_EOF
 
-if test -n "$cf_compress" ; then
+if test -n "$cf_manpage_compress" ; then
 cat >>$cf_edit_man <<CF_EOF
 	if test "\$verb" = installing ; then
-	if ( "$cf_compress" -f \$TMP )
+	if ( "$cf_manpage_compress" -f \$TMP )
 	then
-		mv \$TMP.$cf_so_strip \$TMP
+		mv \$TMP.$cf_manpage_so_strip \$TMP
 	fi
 	fi
-	cf_target="\$cf_target.$cf_so_strip"
+	cf_target="\$cf_target.$cf_manpage_so_strip"
 CF_EOF
 fi
 
@@ -14544,6 +15372,14 @@ esac
 
 cat >>$cf_edit_man <<CF_EOF
 	suffix=\`basename "\$cf_target" | sed -e 's%^[^.]*%%'\`
+	extra_suffix=
+	if test -n "$EXTRA_SUFFIX" ; then
+		case \$cf_target in
+		(*${EXTRA_SUFFIX}\$suffix)
+			extra_suffix="$EXTRA_SUFFIX"
+			;;
+		esac
+	fi
 	if test "\$verb" = installing ; then
 		echo "\$verb \$cf_target"
 		\$INSTALL_DATA \$TMP "\$cf_target"
@@ -14551,13 +15387,14 @@ cat >>$cf_edit_man <<CF_EOF
 		test -n "\$aliases" && (
 			cd "\$cf_subdir\${section}" && (
 				cf_source=\`echo "\$cf_target" |sed -e 's%^.*/\\([^/][^/]*/[^/][^/]*$\\)%\\1%'\`
-				test -n "$cf_so_strip" && cf_source=\`echo "\$cf_source" |sed -e 's%\\.$cf_so_strip\$%%'\`
+				test -n "$cf_manpage_so_strip" && cf_source=\`echo "\$cf_source" |sed -e 's%\\.$cf_manpage_so_strip\$%%'\`
 				cf_target=\`basename "\$cf_target"\`
 				for cf_alias in \$aliases
 				do
 					if test "\$section" = 1 ; then
 						cf_alias=\`echo "\$cf_alias" |sed "\${transform}"\`
 					fi
+					cf_alias="\${cf_alias}\${extra_suffix}"
 
 					if test "$MANPAGE_SYMLINKS" = yes ; then
 						if test -f "\$cf_alias\${suffix}" ; then
@@ -14585,11 +15422,11 @@ cat >>$cf_edit_man <<CF_EOF
 					elif test "\$cf_target" != "\$cf_alias\${suffix}" ; then
 						echo ".so \$cf_source" >\$TMP
 CF_EOF
-if test -n "$cf_compress" ; then
+if test -n "$cf_manpage_compress" ; then
 cat >>$cf_edit_man <<CF_EOF
-						if test -n "$cf_so_strip" ; then
-							"$cf_compress" -f \$TMP
-							mv \$TMP.$cf_so_strip \$TMP
+						if test -n "$cf_manpage_so_strip" ; then
+							"$cf_manpage_compress" $cf_manpage_coptions -f \$TMP
+							mv \$TMP.$cf_manpage_so_strip \$TMP
 						fi
 CF_EOF
 fi
@@ -14614,6 +15451,7 @@ cat >>$cf_edit_man <<CF_EOF
 					if test "\$section" = 1 ; then
 						cf_alias=\`echo "\$cf_alias" |sed "\${transform}"\`
 					fi
+					cf_alias="\${cf_alias}\${extra_suffix}"
 
 					echo ".. \$verb alias \$cf_alias\${suffix}"
 					rm -f "\$cf_alias\${suffix}"
@@ -14628,7 +15466,7 @@ cat >>$cf_edit_man <<CF_EOF
 esac
 done
 
-if test "$cf_inboth" = yes ; then
+if test "$cf_manpage_inboth" = yes ; then
 if test "\$form" != format ; then
 	$SHELL "\$0" format "\$verb" "\$mandir" "\$srcdir" "\$@"
 fi
@@ -14641,7 +15479,7 @@ chmod 755 "$cf_edit_man"
 ###############################################################################
 
 ### Note that some functions (such as const) are normally disabled anyway.
-echo "$as_me:14644: checking if you want to build with function extensions" >&5
+echo "$as_me:15482: checking if you want to build with function extensions" >&5
 echo $ECHO_N "checking if you want to build with function extensions... $ECHO_C" >&6
 
 # Check whether --enable-ext-funcs or --disable-ext-funcs was given.
@@ -14651,7 +15489,7 @@ if test "${enable_ext_funcs+set}" = set; then
 else
   with_ext_funcs=yes
 fi;
-echo "$as_me:14654: result: $with_ext_funcs" >&5
+echo "$as_me:15492: result: $with_ext_funcs" >&5
 echo "${ECHO_T}$with_ext_funcs" >&6
 if test "x$with_ext_funcs" = xyes ; then
 	NCURSES_EXT_FUNCS=1
@@ -14688,10 +15526,6 @@ cat >>confdefs.h <<\EOF
 #define HAVE_USE_DEFAULT_COLORS 1
 EOF
 
-cat >>confdefs.h <<\EOF
-#define HAVE_USE_EXTENDED_NAMES 1
-EOF
-
 cat >>confdefs.h <<\EOF
 #define HAVE_USE_SCREEN 1
 EOF
@@ -14711,7 +15545,7 @@ else
 	GENERATED_EXT_FUNCS=
 fi
 
-echo "$as_me:14714: checking if you want to build with SCREEN extensions" >&5
+echo "$as_me:15548: checking if you want to build with SCREEN extensions" >&5
 echo $ECHO_N "checking if you want to build with SCREEN extensions... $ECHO_C" >&6
 
 # Check whether --enable-sp-funcs or --disable-sp-funcs was given.
@@ -14721,7 +15555,7 @@ if test "${enable_sp_funcs+set}" = set; then
 else
   with_sp_funcs=$cf_dft_ext_spfuncs
 fi;
-echo "$as_me:14724: result: $with_sp_funcs" >&5
+echo "$as_me:15558: result: $with_sp_funcs" >&5
 echo "${ECHO_T}$with_sp_funcs" >&6
 if test "x$with_sp_funcs" = xyes ; then
 	NCURSES_SP_FUNCS=1
@@ -14740,7 +15574,7 @@ else
 	GENERATED_SP_FUNCS=
 fi
 
-echo "$as_me:14743: checking if you want to build with terminal-driver" >&5
+echo "$as_me:15577: checking if you want to build with terminal-driver" >&5
 echo $ECHO_N "checking if you want to build with terminal-driver... $ECHO_C" >&6
 
 # Check whether --enable-term-driver or --disable-term-driver was given.
@@ -14750,7 +15584,7 @@ if test "${enable_term_driver+set}" = set; then
 else
   with_term_driver=no
 fi;
-echo "$as_me:14753: result: $with_term_driver" >&5
+echo "$as_me:15587: result: $with_term_driver" >&5
 echo "${ECHO_T}$with_term_driver" >&6
 if test "x$with_term_driver" = xyes ; then
 
@@ -14759,19 +15593,19 @@ cat >>confdefs.h <<\EOF
 EOF
 
 	if test "x$with_termlib" != xno ; then
-		{ { echo "$as_me:14762: error: The term-driver option conflicts with the termlib option" >&5
+		{ { echo "$as_me:15596: error: The term-driver option conflicts with the termlib option" >&5
 echo "$as_me: error: The term-driver option conflicts with the termlib option" >&2;}
    { (exit 1); exit 1; }; }
 	fi
 	if test "x$with_sp_funcs" != xyes ; then
-		{ { echo "$as_me:14767: error: The term-driver option relies upon sp-funcs" >&5
+		{ { echo "$as_me:15601: error: The term-driver option relies upon sp-funcs" >&5
 echo "$as_me: error: The term-driver option relies upon sp-funcs" >&2;}
    { (exit 1); exit 1; }; }
 	fi
 fi
 
 ###   use option --enable-const to turn on use of const beyond that in XSI.
-echo "$as_me:14774: checking for extended use of const keyword" >&5
+echo "$as_me:15608: checking for extended use of const keyword" >&5
 echo $ECHO_N "checking for extended use of const keyword... $ECHO_C" >&6
 
 # Check whether --enable-const or --disable-const was given.
@@ -14781,7 +15615,7 @@ if test "${enable_const+set}" = set; then
 else
   with_ext_const=$cf_dft_ext_const
 fi;
-echo "$as_me:14784: result: $with_ext_const" >&5
+echo "$as_me:15618: result: $with_ext_const" >&5
 echo "${ECHO_T}$with_ext_const" >&6
 NCURSES_CONST='/*nothing*/'
 if test "x$with_ext_const" = xyes ; then
@@ -14789,7 +15623,7 @@ if test "x$with_ext_const" = xyes ; then
 fi
 
 ###   use option --enable-ext-colors to turn on use of colors beyond 16.
-echo "$as_me:14792: checking if you want to use extended colors" >&5
+echo "$as_me:15626: checking if you want to use extended colors" >&5
 echo $ECHO_N "checking if you want to use extended colors... $ECHO_C" >&6
 
 # Check whether --enable-ext-colors or --disable-ext-colors was given.
@@ -14799,12 +15633,12 @@ if test "${enable_ext_colors+set}" = set; then
 else
   with_ext_colors=$cf_dft_ext_colors
 fi;
-echo "$as_me:14802: result: $with_ext_colors" >&5
+echo "$as_me:15636: result: $with_ext_colors" >&5
 echo "${ECHO_T}$with_ext_colors" >&6
 NCURSES_EXT_COLORS=0
 if test "x$with_ext_colors" = xyes ; then
 	if test "x$with_widec" != xyes ; then
-		{ echo "$as_me:14807: WARNING: This option applies only to wide-character library" >&5
+		{ echo "$as_me:15641: WARNING: This option applies only to wide-character library" >&5
 echo "$as_me: WARNING: This option applies only to wide-character library" >&2;}
 	else
 		# cannot be ABI 5 since it changes sizeof(cchar_t)
@@ -14814,8 +15648,9 @@ if test "${with_abi_version+set}" != set; then
 	(5.*)
 		cf_cv_rel_version=6.0
 		cf_cv_abi_version=6
-		{ echo "$as_me:14817: WARNING: overriding ABI version to $cf_cv_abi_version" >&5
-echo "$as_me: WARNING: overriding ABI version to $cf_cv_abi_version" >&2;}
+		cf_cv_abi_default=6
+		{ echo "$as_me:15652: WARNING: overriding ABI version to $cf_cv_abi_default" >&5
+echo "$as_me: WARNING: overriding ABI version to $cf_cv_abi_default" >&2;}
 		;;
 	esac
 fi
@@ -14842,7 +15677,7 @@ EOF
 fi
 
 ###   use option --enable-ext-mouse to modify coding to support 5-button mice
-echo "$as_me:14845: checking if you want to use extended mouse encoding" >&5
+echo "$as_me:15680: checking if you want to use extended mouse encoding" >&5
 echo $ECHO_N "checking if you want to use extended mouse encoding... $ECHO_C" >&6
 
 # Check whether --enable-ext-mouse or --disable-ext-mouse was given.
@@ -14852,27 +15687,34 @@ if test "${enable_ext_mouse+set}" = set; then
 else
   with_ext_mouse=$cf_dft_ext_mouse
 fi;
-echo "$as_me:14855: result: $with_ext_mouse" >&5
+echo "$as_me:15690: result: $with_ext_mouse" >&5
 echo "${ECHO_T}$with_ext_mouse" >&6
-NCURSES_MOUSE_VERSION=1
 if test "x$with_ext_mouse" = xyes ; then
-	NCURSES_MOUSE_VERSION=2
 
 if test "${with_abi_version+set}" != set; then
 	case "$cf_cv_rel_version" in
 	(5.*)
 		cf_cv_rel_version=6.0
 		cf_cv_abi_version=6
-		{ echo "$as_me:14866: WARNING: overriding ABI version to $cf_cv_abi_version" >&5
-echo "$as_me: WARNING: overriding ABI version to $cf_cv_abi_version" >&2;}
+		cf_cv_abi_default=6
+		{ echo "$as_me:15700: WARNING: overriding ABI version to $cf_cv_abi_default" >&5
+echo "$as_me: WARNING: overriding ABI version to $cf_cv_abi_default" >&2;}
 		;;
 	esac
 fi
 
 fi
 
+if test $cf_cv_abi_default -le 5 ; then
+	NCURSES_MOUSE_VERSION=1
+elif test $cf_cv_abi_default -le 6 ; then
+	NCURSES_MOUSE_VERSION=2
+else
+	NCURSES_MOUSE_VERSION=3
+fi
+
 ###   use option --enable-ext-putwin to turn on extended screendumps
-echo "$as_me:14875: checking if you want to use extended putwin/screendump" >&5
+echo "$as_me:15717: checking if you want to use extended putwin/screendump" >&5
 echo $ECHO_N "checking if you want to use extended putwin/screendump... $ECHO_C" >&6
 
 # Check whether --enable-ext-putwin or --disable-ext-putwin was given.
@@ -14882,7 +15724,7 @@ if test "${enable_ext_putwin+set}" = set; then
 else
   with_ext_putwin=$cf_dft_ext_putwin
 fi;
-echo "$as_me:14885: result: $with_ext_putwin" >&5
+echo "$as_me:15727: result: $with_ext_putwin" >&5
 echo "${ECHO_T}$with_ext_putwin" >&6
 if test "x$with_ext_putwin" = xyes ; then
 
@@ -14892,7 +15734,7 @@ EOF
 
 fi
 
-echo "$as_me:14895: checking if you want \$NCURSES_NO_PADDING code" >&5
+echo "$as_me:15737: checking if you want \$NCURSES_NO_PADDING code" >&5
 echo $ECHO_N "checking if you want \$NCURSES_NO_PADDING code... $ECHO_C" >&6
 
 # Check whether --enable-no-padding or --disable-no-padding was given.
@@ -14902,7 +15744,7 @@ if test "${enable_no_padding+set}" = set; then
 else
   with_no_padding=$with_ext_funcs
 fi;
-echo "$as_me:14905: result: $with_no_padding" >&5
+echo "$as_me:15747: result: $with_no_padding" >&5
 echo "${ECHO_T}$with_no_padding" >&6
 test "x$with_no_padding" = xyes &&
 cat >>confdefs.h <<\EOF
@@ -14910,7 +15752,7 @@ cat >>confdefs.h <<\EOF
 EOF
 
 ###   use option --enable-sigwinch to turn on use of SIGWINCH logic
-echo "$as_me:14913: checking if you want SIGWINCH handler" >&5
+echo "$as_me:15755: checking if you want SIGWINCH handler" >&5
 echo $ECHO_N "checking if you want SIGWINCH handler... $ECHO_C" >&6
 
 # Check whether --enable-sigwinch or --disable-sigwinch was given.
@@ -14920,15 +15762,22 @@ if test "${enable_sigwinch+set}" = set; then
 else
   with_sigwinch=$with_ext_funcs
 fi;
-echo "$as_me:14923: result: $with_sigwinch" >&5
+echo "$as_me:15765: result: $with_sigwinch" >&5
 echo "${ECHO_T}$with_sigwinch" >&6
-test "x$with_sigwinch" = xyes &&
+if test "x$with_sigwinch" = xyes
+then
+
 cat >>confdefs.h <<\EOF
 #define USE_SIGWINCH 1
 EOF
 
+	cf_cv_enable_sigwinch=1
+else
+	cf_cv_enable_sigwinch=0
+fi
+
 ###   use option --enable-tcap-names to allow user to define new capabilities
-echo "$as_me:14931: checking if you want user-definable terminal capabilities like termcap" >&5
+echo "$as_me:15780: checking if you want user-definable terminal capabilities like termcap" >&5
 echo $ECHO_N "checking if you want user-definable terminal capabilities like termcap... $ECHO_C" >&6
 
 # Check whether --enable-tcap-names or --disable-tcap-names was given.
@@ -14938,14 +15787,21 @@ if test "${enable_tcap_names+set}" = set; then
 else
   with_tcap_names=$with_ext_funcs
 fi;
-echo "$as_me:14941: result: $with_tcap_names" >&5
+echo "$as_me:15790: result: $with_tcap_names" >&5
 echo "${ECHO_T}$with_tcap_names" >&6
 NCURSES_XNAMES=0
-test "x$with_tcap_names" = xyes && NCURSES_XNAMES=1
+if test "x$with_tcap_names" = xyes; then
+	NCURSES_XNAMES=1
+
+cat >>confdefs.h <<\EOF
+#define NCURSES_XNAMES 1
+EOF
+
+fi
 
 ##############################################################################
 
-echo "$as_me:14948: checking if you want to link with the pthread library" >&5
+echo "$as_me:15804: checking if you want to link with the pthread library" >&5
 echo $ECHO_N "checking if you want to link with the pthread library... $ECHO_C" >&6
 
 # Check whether --with-pthread or --without-pthread was given.
@@ -14955,27 +15811,27 @@ if test "${with_pthread+set}" = set; then
 else
   with_pthread=no
 fi;
-echo "$as_me:14958: result: $with_pthread" >&5
+echo "$as_me:15814: result: $with_pthread" >&5
 echo "${ECHO_T}$with_pthread" >&6
 
 if test "$with_pthread" != no ; then
-	echo "$as_me:14962: checking for pthread.h" >&5
+	echo "$as_me:15818: checking for pthread.h" >&5
 echo $ECHO_N "checking for pthread.h... $ECHO_C" >&6
 if test "${ac_cv_header_pthread_h+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 14968 "configure"
+#line 15824 "configure"
 #include "confdefs.h"
 #include <pthread.h>
 _ACEOF
-if { (eval echo "$as_me:14972: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+if { (eval echo "$as_me:15828: \"$ac_cpp "conftest.$ac_ext"\"") >&5
   (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:14978: \$? = $ac_status" >&5
+  echo "$as_me:15834: \$? = $ac_status" >&5
   (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -14994,7 +15850,7 @@ else
 fi
 rm -f conftest.err "conftest.$ac_ext"
 fi
-echo "$as_me:14997: result: $ac_cv_header_pthread_h" >&5
+echo "$as_me:15853: result: $ac_cv_header_pthread_h" >&5
 echo "${ECHO_T}$ac_cv_header_pthread_h" >&6
 if test "$ac_cv_header_pthread_h" = yes; then
 
@@ -15004,7 +15860,7 @@ EOF
 
 	for cf_lib_pthread in pthread c_r
 	do
-	    echo "$as_me:15007: checking if we can link with the $cf_lib_pthread library" >&5
+	    echo "$as_me:15863: checking if we can link with the $cf_lib_pthread library" >&5
 echo $ECHO_N "checking if we can link with the $cf_lib_pthread library... $ECHO_C" >&6
 	    cf_save_LIBS="$LIBS"
 
@@ -15025,7 +15881,7 @@ done
 LIBS="$cf_add_libs"
 
 	    cat >"conftest.$ac_ext" <<_ACEOF
-#line 15028 "configure"
+#line 15884 "configure"
 #include "confdefs.h"
 
 #include <pthread.h>
@@ -15042,16 +15898,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:15045: \"$ac_link\"") >&5
+if { (eval echo "$as_me:15901: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:15048: \$? = $ac_status" >&5
+  echo "$as_me:15904: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:15051: \"$ac_try\"") >&5
+  { (eval echo "$as_me:15907: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15054: \$? = $ac_status" >&5
+  echo "$as_me:15910: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   with_pthread=yes
 else
@@ -15061,7 +15917,7 @@ with_pthread=no
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 	    LIBS="$cf_save_LIBS"
-	    echo "$as_me:15064: result: $with_pthread" >&5
+	    echo "$as_me:15920: result: $with_pthread" >&5
 echo "${ECHO_T}$with_pthread" >&6
 	    test "$with_pthread" = yes && break
 	done
@@ -15089,7 +15945,7 @@ cat >>confdefs.h <<\EOF
 EOF
 
 	else
-	    { { echo "$as_me:15092: error: Cannot link with pthread library" >&5
+	    { { echo "$as_me:15948: error: Cannot link with pthread library" >&5
 echo "$as_me: error: Cannot link with pthread library" >&2;}
    { (exit 1); exit 1; }; }
 	fi
@@ -15099,13 +15955,13 @@ fi
 fi
 
 if test "x$with_pthread" != xno; then
-	echo "$as_me:15102: checking for pthread_kill" >&5
+	echo "$as_me:15958: checking for pthread_kill" >&5
 echo $ECHO_N "checking for pthread_kill... $ECHO_C" >&6
 if test "${ac_cv_func_pthread_kill+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 15108 "configure"
+#line 15964 "configure"
 #include "confdefs.h"
 #define pthread_kill autoconf_temporary
 #include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
@@ -15136,16 +15992,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:15139: \"$ac_link\"") >&5
+if { (eval echo "$as_me:15995: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:15142: \$? = $ac_status" >&5
+  echo "$as_me:15998: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:15145: \"$ac_try\"") >&5
+  { (eval echo "$as_me:16001: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15148: \$? = $ac_status" >&5
+  echo "$as_me:16004: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_func_pthread_kill=yes
 else
@@ -15155,11 +16011,11 @@ ac_cv_func_pthread_kill=no
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:15158: result: $ac_cv_func_pthread_kill" >&5
+echo "$as_me:16014: result: $ac_cv_func_pthread_kill" >&5
 echo "${ECHO_T}$ac_cv_func_pthread_kill" >&6
 if test "$ac_cv_func_pthread_kill" = yes; then
 
-		echo "$as_me:15162: checking if you want to allow EINTR in wgetch with pthreads" >&5
+		echo "$as_me:16018: checking if you want to allow EINTR in wgetch with pthreads" >&5
 echo $ECHO_N "checking if you want to allow EINTR in wgetch with pthreads... $ECHO_C" >&6
 
 # Check whether --enable-pthreads-eintr or --disable-pthreads-eintr was given.
@@ -15169,7 +16025,7 @@ if test "${enable_pthreads_eintr+set}" = set; then
 else
   use_pthreads_eintr=no
 fi;
-		echo "$as_me:15172: result: $use_pthreads_eintr" >&5
+		echo "$as_me:16028: result: $use_pthreads_eintr" >&5
 echo "${ECHO_T}$use_pthreads_eintr" >&6
 		if test "x$use_pthreads_eintr" = xyes ; then
 
@@ -15180,7 +16036,7 @@ EOF
 		fi
 fi
 
-	echo "$as_me:15183: checking if you want to use weak-symbols for pthreads" >&5
+	echo "$as_me:16039: checking if you want to use weak-symbols for pthreads" >&5
 echo $ECHO_N "checking if you want to use weak-symbols for pthreads... $ECHO_C" >&6
 
 # Check whether --enable-weak-symbols or --disable-weak-symbols was given.
@@ -15190,18 +16046,18 @@ if test "${enable_weak_symbols+set}" = set; then
 else
   use_weak_symbols=no
 fi;
-	echo "$as_me:15193: result: $use_weak_symbols" >&5
+	echo "$as_me:16049: result: $use_weak_symbols" >&5
 echo "${ECHO_T}$use_weak_symbols" >&6
 	if test "x$use_weak_symbols" = xyes ; then
 
-echo "$as_me:15197: checking if $CC supports weak symbols" >&5
+echo "$as_me:16053: checking if $CC supports weak symbols" >&5
 echo $ECHO_N "checking if $CC supports weak symbols... $ECHO_C" >&6
 if test "${cf_cv_weak_symbols+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 15204 "configure"
+#line 16060 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -15227,16 +16083,16 @@ weak_symbol(fopen);
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:15230: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:16086: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:15233: \$? = $ac_status" >&5
+  echo "$as_me:16089: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:15236: \"$ac_try\"") >&5
+  { (eval echo "$as_me:16092: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15239: \$? = $ac_status" >&5
+  echo "$as_me:16095: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_weak_symbols=yes
 else
@@ -15247,7 +16103,7 @@ fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 
 fi
-echo "$as_me:15250: result: $cf_cv_weak_symbols" >&5
+echo "$as_me:16106: result: $cf_cv_weak_symbols" >&5
 echo "${ECHO_T}$cf_cv_weak_symbols" >&6
 
 	else
@@ -15297,7 +16153,7 @@ fi
 # opaque outside of that, so there is no --enable-opaque option.  We can use
 # this option without --with-pthreads, but this will be always set for
 # pthreads.
-echo "$as_me:15300: checking if you want reentrant code" >&5
+echo "$as_me:16156: checking if you want reentrant code" >&5
 echo $ECHO_N "checking if you want reentrant code... $ECHO_C" >&6
 
 # Check whether --enable-reentrant or --disable-reentrant was given.
@@ -15307,7 +16163,7 @@ if test "${enable_reentrant+set}" = set; then
 else
   with_reentrant=no
 fi;
-echo "$as_me:15310: result: $with_reentrant" >&5
+echo "$as_me:16166: result: $with_reentrant" >&5
 echo "${ECHO_T}$with_reentrant" >&6
 if test "x$with_reentrant" = xyes ; then
 	cf_cv_enable_reentrant=1
@@ -15395,8 +16251,9 @@ if test "${with_abi_version+set}" != set; then
 	(5.*)
 		cf_cv_rel_version=6.0
 		cf_cv_abi_version=6
-		{ echo "$as_me:15398: WARNING: overriding ABI version to $cf_cv_abi_version" >&5
-echo "$as_me: WARNING: overriding ABI version to $cf_cv_abi_version" >&2;}
+		cf_cv_abi_default=6
+		{ echo "$as_me:16255: WARNING: overriding ABI version to $cf_cv_abi_default" >&5
+echo "$as_me: WARNING: overriding ABI version to $cf_cv_abi_default" >&2;}
 		;;
 	esac
 fi
@@ -15404,77 +16261,98 @@ fi
 else
 	cf_cv_enable_reentrant=0
 	cf_cv_enable_opaque="NCURSES_OPAQUE"
-	NCURSES_SIZE_T=short
+	NCURSES_SIZE_T=$cf_dft_ordinate_type
 fi
 
-echo "$as_me:15410: checking if you want opaque curses-library structures" >&5
-echo $ECHO_N "checking if you want opaque curses-library structures... $ECHO_C" >&6
+echo "$as_me:16267: checking whether curses library structures should be opaque" >&5
+echo $ECHO_N "checking whether curses library structures should be opaque... $ECHO_C" >&6
 
 # Check whether --enable-opaque-curses or --disable-opaque-curses was given.
 if test "${enable_opaque_curses+set}" = set; then
   enableval="$enable_opaque_curses"
-  test "$enableval" != yes && enableval=no
-	if test "$enableval" != "no" ; then
-    enable_opaque_curses=yes
+  test "$enableval" != no && enableval=yes
+	if test "$enableval" != "yes" ; then
+    enable_opaque_curses=no
 	else
 
 	 test "$cf_cv_enable_reentrant" = 1 && enable_opaque_curses=yes
-	 test "$cf_cv_enable_reentrant" = 1 || enable_opaque_curses=no
+	 test "$cf_cv_enable_reentrant" = 1 || enable_opaque_curses=$cf_dft_opaque_curses
 
 	fi
 else
-  enableval=no
+  enableval=yes
 
 	 test "$cf_cv_enable_reentrant" = 1 && enable_opaque_curses=yes
-	 test "$cf_cv_enable_reentrant" = 1 || enable_opaque_curses=no
+	 test "$cf_cv_enable_reentrant" = 1 || enable_opaque_curses=$cf_dft_opaque_curses
 
 fi;
-echo "$as_me:15432: result: $enable_opaque_curses" >&5
+echo "$as_me:16289: result: $enable_opaque_curses" >&5
 echo "${ECHO_T}$enable_opaque_curses" >&6
 
 test "$cf_cv_enable_reentrant" = 1 && \
 test "$enable_opaque_curses" = no && \
-{ { echo "$as_me:15437: error: reentrant configuration requires opaque library" >&5
+{ { echo "$as_me:16294: error: reentrant configuration requires opaque library" >&5
 echo "$as_me: error: reentrant configuration requires opaque library" >&2;}
    { (exit 1); exit 1; }; }
 
-echo "$as_me:15441: checking if you want opaque form-library structures" >&5
-echo $ECHO_N "checking if you want opaque form-library structures... $ECHO_C" >&6
+echo "$as_me:16298: checking whether form library structures should be opaque" >&5
+echo $ECHO_N "checking whether form library structures should be opaque... $ECHO_C" >&6
 
 # Check whether --enable-opaque-form or --disable-opaque-form was given.
 if test "${enable_opaque_form+set}" = set; then
   enableval="$enable_opaque_form"
-  enable_opaque_form=yes
+  test "$enableval" != no && enableval=yes
+	if test "$enableval" != "yes" ; then
+    enable_opaque_form=no
+	else
+		enable_opaque_form=$cf_dft_opaque_curses
+	fi
 else
-  enable_opaque_form=no
+  enableval=yes
+	enable_opaque_form=$cf_dft_opaque_curses
+
 fi;
-echo "$as_me:15451: result: $enable_opaque_form" >&5
+echo "$as_me:16315: result: $enable_opaque_form" >&5
 echo "${ECHO_T}$enable_opaque_form" >&6
 
-echo "$as_me:15454: checking if you want opaque menu-library structures" >&5
-echo $ECHO_N "checking if you want opaque menu-library structures... $ECHO_C" >&6
+echo "$as_me:16318: checking whether menu library structures should be opaque" >&5
+echo $ECHO_N "checking whether menu library structures should be opaque... $ECHO_C" >&6
 
 # Check whether --enable-opaque-menu or --disable-opaque-menu was given.
 if test "${enable_opaque_menu+set}" = set; then
   enableval="$enable_opaque_menu"
-  enable_opaque_menu=yes
+  test "$enableval" != no && enableval=yes
+	if test "$enableval" != "yes" ; then
+    enable_opaque_menu=no
+	else
+		enable_opaque_menu=$cf_dft_opaque_curses
+	fi
 else
-  enable_opaque_menu=no
+  enableval=yes
+	enable_opaque_menu=$cf_dft_opaque_curses
+
 fi;
-echo "$as_me:15464: result: $enable_opaque_menu" >&5
+echo "$as_me:16335: result: $enable_opaque_menu" >&5
 echo "${ECHO_T}$enable_opaque_menu" >&6
 
-echo "$as_me:15467: checking if you want opaque panel-library structures" >&5
-echo $ECHO_N "checking if you want opaque panel-library structures... $ECHO_C" >&6
+echo "$as_me:16338: checking whether panel library structures should be opaque" >&5
+echo $ECHO_N "checking whether panel library structures should be opaque... $ECHO_C" >&6
 
 # Check whether --enable-opaque-panel or --disable-opaque-panel was given.
 if test "${enable_opaque_panel+set}" = set; then
   enableval="$enable_opaque_panel"
-  enable_opaque_panel=yes
+  test "$enableval" != no && enableval=yes
+	if test "$enableval" != "yes" ; then
+    enable_opaque_panel=no
+	else
+		enable_opaque_panel=$cf_dft_opaque_curses
+	fi
 else
-  enable_opaque_panel=no
+  enableval=yes
+	enable_opaque_panel=$cf_dft_opaque_curses
+
 fi;
-echo "$as_me:15477: result: $enable_opaque_panel" >&5
+echo "$as_me:16355: result: $enable_opaque_panel" >&5
 echo "${ECHO_T}$enable_opaque_panel" >&6
 
 NCURSES_OPAQUE=0;		test "$enable_opaque_curses" = yes && NCURSES_OPAQUE=1
@@ -15484,7 +16362,7 @@ NCURSES_OPAQUE_PANEL=0;	test "$enable_opaque_panel"  = yes && NCURSES_OPAQUE_PAN
 
 ### Allow using a different wrap-prefix
 if test "$cf_cv_enable_reentrant" != 0 || test "$BROKEN_LINKER" = 1 ; then
-	echo "$as_me:15487: checking for prefix used to wrap public variables" >&5
+	echo "$as_me:16365: checking for prefix used to wrap public variables" >&5
 echo $ECHO_N "checking for prefix used to wrap public variables... $ECHO_C" >&6
 
 # Check whether --with-wrap-prefix or --without-wrap-prefix was given.
@@ -15494,7 +16372,7 @@ if test "${with_wrap_prefix+set}" = set; then
 else
   NCURSES_WRAP_PREFIX=_nc_
 fi;
-	echo "$as_me:15497: result: $NCURSES_WRAP_PREFIX" >&5
+	echo "$as_me:16375: result: $NCURSES_WRAP_PREFIX" >&5
 echo "${ECHO_T}$NCURSES_WRAP_PREFIX" >&6
 else
 	NCURSES_WRAP_PREFIX=_nc_
@@ -15507,7 +16385,7 @@ EOF
 ###############################################################################
 # These options are relatively safe to experiment with.
 
-echo "$as_me:15510: checking if you want all development code" >&5
+echo "$as_me:16388: checking if you want all development code" >&5
 echo $ECHO_N "checking if you want all development code... $ECHO_C" >&6
 
 # Check whether --with-develop or --without-develop was given.
@@ -15517,11 +16395,29 @@ if test "${with_develop+set}" = set; then
 else
   with_develop=no
 fi;
-echo "$as_me:15520: result: $with_develop" >&5
+echo "$as_me:16398: result: $with_develop" >&5
 echo "${ECHO_T}$with_develop" >&6
 
+###   use option --enable-check-size to detect screensize with CPR
+echo "$as_me:16402: checking if you want to check screensize of serial terminals" >&5
+echo $ECHO_N "checking if you want to check screensize of serial terminals... $ECHO_C" >&6
+
+# Check whether --enable-check-size or --disable-check-size was given.
+if test "${enable_check_size+set}" = set; then
+  enableval="$enable_check_size"
+
+else
+  enable_check_size=$with_develop
+fi;
+echo "$as_me:16412: result: $enable_check_size" >&5
+echo "${ECHO_T}$enable_check_size" >&6
+test "x$enable_check_size" = xyes &&
+cat >>confdefs.h <<\EOF
+#define USE_CHECK_SIZE 1
+EOF
+
 ###   use option --enable-hard-tabs to turn on use of hard-tabs optimize
-echo "$as_me:15524: checking if you want hard-tabs code" >&5
+echo "$as_me:16420: checking if you want hard-tabs code" >&5
 echo $ECHO_N "checking if you want hard-tabs code... $ECHO_C" >&6
 
 # Check whether --enable-hard-tabs or --disable-hard-tabs was given.
@@ -15531,7 +16427,7 @@ if test "${enable_hard_tabs+set}" = set; then
 else
   enable_hard_tabs=$with_develop
 fi;
-echo "$as_me:15534: result: $enable_hard_tabs" >&5
+echo "$as_me:16430: result: $enable_hard_tabs" >&5
 echo "${ECHO_T}$enable_hard_tabs" >&6
 test "x$enable_hard_tabs" = xyes &&
 cat >>confdefs.h <<\EOF
@@ -15539,7 +16435,7 @@ cat >>confdefs.h <<\EOF
 EOF
 
 ###   use option --enable-xmc-glitch to turn on use of magic-cookie optimize
-echo "$as_me:15542: checking if you want limited support for xmc" >&5
+echo "$as_me:16438: checking if you want limited support for xmc" >&5
 echo $ECHO_N "checking if you want limited support for xmc... $ECHO_C" >&6
 
 # Check whether --enable-xmc-glitch or --disable-xmc-glitch was given.
@@ -15549,7 +16445,7 @@ if test "${enable_xmc_glitch+set}" = set; then
 else
   enable_xmc_glitch=$with_develop
 fi;
-echo "$as_me:15552: result: $enable_xmc_glitch" >&5
+echo "$as_me:16448: result: $enable_xmc_glitch" >&5
 echo "${ECHO_T}$enable_xmc_glitch" >&6
 test "x$enable_xmc_glitch" = xyes &&
 cat >>confdefs.h <<\EOF
@@ -15559,7 +16455,7 @@ EOF
 ###############################################################################
 # These are just experimental, probably should not be in a package:
 
-echo "$as_me:15562: checking if you do not want to assume colors are white-on-black" >&5
+echo "$as_me:16458: checking if you do not want to assume colors are white-on-black" >&5
 echo $ECHO_N "checking if you do not want to assume colors are white-on-black... $ECHO_C" >&6
 
 # Check whether --enable-assumed-color or --disable-assumed-color was given.
@@ -15569,7 +16465,7 @@ if test "${enable_assumed_color+set}" = set; then
 else
   with_assumed_color=yes
 fi;
-echo "$as_me:15572: result: $with_assumed_color" >&5
+echo "$as_me:16468: result: $with_assumed_color" >&5
 echo "${ECHO_T}$with_assumed_color" >&6
 test "x$with_assumed_color" = xyes &&
 cat >>confdefs.h <<\EOF
@@ -15577,7 +16473,7 @@ cat >>confdefs.h <<\EOF
 EOF
 
 ###   use option --enable-hashmap to turn on use of hashmap scrolling logic
-echo "$as_me:15580: checking if you want hashmap scrolling-optimization code" >&5
+echo "$as_me:16476: checking if you want hashmap scrolling-optimization code" >&5
 echo $ECHO_N "checking if you want hashmap scrolling-optimization code... $ECHO_C" >&6
 
 # Check whether --enable-hashmap or --disable-hashmap was given.
@@ -15587,7 +16483,7 @@ if test "${enable_hashmap+set}" = set; then
 else
   with_hashmap=yes
 fi;
-echo "$as_me:15590: result: $with_hashmap" >&5
+echo "$as_me:16486: result: $with_hashmap" >&5
 echo "${ECHO_T}$with_hashmap" >&6
 test "x$with_hashmap" = xyes &&
 cat >>confdefs.h <<\EOF
@@ -15595,7 +16491,7 @@ cat >>confdefs.h <<\EOF
 EOF
 
 ###   use option --enable-colorfgbg to turn on use of $COLORFGBG environment
-echo "$as_me:15598: checking if you want colorfgbg code" >&5
+echo "$as_me:16494: checking if you want colorfgbg code" >&5
 echo $ECHO_N "checking if you want colorfgbg code... $ECHO_C" >&6
 
 # Check whether --enable-colorfgbg or --disable-colorfgbg was given.
@@ -15605,7 +16501,7 @@ if test "${enable_colorfgbg+set}" = set; then
 else
   with_colorfgbg=no
 fi;
-echo "$as_me:15608: result: $with_colorfgbg" >&5
+echo "$as_me:16504: result: $with_colorfgbg" >&5
 echo "${ECHO_T}$with_colorfgbg" >&6
 test "x$with_colorfgbg" = xyes &&
 cat >>confdefs.h <<\EOF
@@ -15613,7 +16509,7 @@ cat >>confdefs.h <<\EOF
 EOF
 
 ###   use option --enable-fvisibility to turn on use of gcc-specific feature
-echo "$as_me:15616: checking if you want to use gcc -fvisibility option" >&5
+echo "$as_me:16512: checking if you want to use gcc -fvisibility option" >&5
 echo $ECHO_N "checking if you want to use gcc -fvisibility option... $ECHO_C" >&6
 
 # Check whether --enable-fvisibility or --disable-fvisibility was given.
@@ -15623,14 +16519,14 @@ if test "${enable_fvisibility+set}" = set; then
 else
   cf_with_fvisibility=no
 fi;
-echo "$as_me:15626: result: $cf_with_fvisibility" >&5
+echo "$as_me:16522: result: $cf_with_fvisibility" >&5
 echo "${ECHO_T}$cf_with_fvisibility" >&6
 
 NCURSES_IMPEXP=
 NCURSES_CXX_IMPEXP=
 if test "x$cf_with_fvisibility" = xyes; then
 
-echo "$as_me:15633: checking if $CC -fvisibility=hidden option works" >&5
+echo "$as_me:16529: checking if $CC -fvisibility=hidden option works" >&5
 echo $ECHO_N "checking if $CC -fvisibility=hidden option works... $ECHO_C" >&6
 if test "${cf_cv_fvisibility_hidden+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -15639,7 +16535,7 @@ else
     cf_save_cflags="$CFLAGS"
     CFLAGS="$CFLAGS -fvisibility=hidden"
     cat >"conftest.$ac_ext" <<_ACEOF
-#line 15642 "configure"
+#line 16538 "configure"
 #include "confdefs.h"
 
 __attribute__ ((visibility("default"))) int somefunc() {return 42;}
@@ -15655,16 +16551,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:15658: \"$ac_link\"") >&5
+if { (eval echo "$as_me:16554: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:15661: \$? = $ac_status" >&5
+  echo "$as_me:16557: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:15664: \"$ac_try\"") >&5
+  { (eval echo "$as_me:16560: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15667: \$? = $ac_status" >&5
+  echo "$as_me:16563: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_fvisibility_hidden=yes
 else
@@ -15676,7 +16572,7 @@ rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
     CFLAGS=$cf_save_cflags
 
 fi
-echo "$as_me:15679: result: $cf_cv_fvisibility_hidden" >&5
+echo "$as_me:16575: result: $cf_cv_fvisibility_hidden" >&5
 echo "${ECHO_T}$cf_cv_fvisibility_hidden" >&6
 
 	if test "x$cf_cv_fvisibility_hidden" = xyes
@@ -15791,7 +16687,7 @@ ac_link='$CXX -o "conftest$ac_exeext" $CXXFLAGS $CPPFLAGS $LDFLAGS "conftest.$ac
 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
 ac_main_return="return"
 
-echo "$as_me:15794: checking if $CXX -fvisibility=hidden option works" >&5
+echo "$as_me:16690: checking if $CXX -fvisibility=hidden option works" >&5
 echo $ECHO_N "checking if $CXX -fvisibility=hidden option works... $ECHO_C" >&6
 if test "${cf_cv_fvisibility_hidden2+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -15800,7 +16696,7 @@ else
     cf_save_cflags="$CXXFLAGS"
     CXXFLAGS="$CXXFLAGS -fvisibility=hidden"
     cat >"conftest.$ac_ext" <<_ACEOF
-#line 15803 "configure"
+#line 16699 "configure"
 #include "confdefs.h"
 
 __attribute__ ((visibility("default"))) int somefunc() {return 42;}
@@ -15816,16 +16712,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:15819: \"$ac_link\"") >&5
+if { (eval echo "$as_me:16715: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:15822: \$? = $ac_status" >&5
+  echo "$as_me:16718: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:15825: \"$ac_try\"") >&5
+  { (eval echo "$as_me:16721: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:15828: \$? = $ac_status" >&5
+  echo "$as_me:16724: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_fvisibility_hidden2=yes
 else
@@ -15837,7 +16733,7 @@ rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
     CXXFLAGS=$cf_save_cflags
 
 fi
-echo "$as_me:15840: result: $cf_cv_fvisibility_hidden2" >&5
+echo "$as_me:16736: result: $cf_cv_fvisibility_hidden2" >&5
 echo "${ECHO_T}$cf_cv_fvisibility_hidden2" >&6
 
 		if test "x$cf_cv_fvisibility_hidden2" = xyes
@@ -15960,7 +16856,7 @@ ac_main_return="return"
 fi
 
 ###   use option --enable-interop to turn on use of bindings used for interop
-echo "$as_me:15963: checking if you want interop bindings" >&5
+echo "$as_me:16859: checking if you want interop bindings" >&5
 echo $ECHO_N "checking if you want interop bindings... $ECHO_C" >&6
 
 # Check whether --enable-interop or --disable-interop was given.
@@ -15970,13 +16866,13 @@ if test "${enable_interop+set}" = set; then
 else
   with_exp_interop=$cf_dft_interop
 fi;
-echo "$as_me:15973: result: $with_exp_interop" >&5
+echo "$as_me:16869: result: $with_exp_interop" >&5
 echo "${ECHO_T}$with_exp_interop" >&6
 
 NCURSES_INTEROP_FUNCS=0
 test "x$with_exp_interop" = xyes && NCURSES_INTEROP_FUNCS=1
 
-echo "$as_me:15979: checking if you want experimental safe-sprintf code" >&5
+echo "$as_me:16875: checking if you want experimental safe-sprintf code" >&5
 echo $ECHO_N "checking if you want experimental safe-sprintf code... $ECHO_C" >&6
 
 # Check whether --enable-safe-sprintf or --disable-safe-sprintf was given.
@@ -15986,13 +16882,13 @@ if test "${enable_safe_sprintf+set}" = set; then
 else
   with_safe_sprintf=no
 fi;
-echo "$as_me:15989: result: $with_safe_sprintf" >&5
+echo "$as_me:16885: result: $with_safe_sprintf" >&5
 echo "${ECHO_T}$with_safe_sprintf" >&6
 
 ###   use option --disable-scroll-hints to turn off use of scroll-hints scrolling logic
 # when hashmap is used scroll hints are useless
 if test "$with_hashmap" = no ; then
-echo "$as_me:15995: checking if you want to experiment without scrolling-hints code" >&5
+echo "$as_me:16891: checking if you want to experiment without scrolling-hints code" >&5
 echo $ECHO_N "checking if you want to experiment without scrolling-hints code... $ECHO_C" >&6
 
 # Check whether --enable-scroll-hints or --disable-scroll-hints was given.
@@ -16002,7 +16898,7 @@ if test "${enable_scroll_hints+set}" = set; then
 else
   with_scroll_hints=yes
 fi;
-echo "$as_me:16005: result: $with_scroll_hints" >&5
+echo "$as_me:16901: result: $with_scroll_hints" >&5
 echo "${ECHO_T}$with_scroll_hints" >&6
 test "x$with_scroll_hints" = xyes &&
 cat >>confdefs.h <<\EOF
@@ -16011,7 +16907,7 @@ EOF
 
 fi
 
-echo "$as_me:16014: checking if you want wgetch-events code" >&5
+echo "$as_me:16910: checking if you want wgetch-events code" >&5
 echo $ECHO_N "checking if you want wgetch-events code... $ECHO_C" >&6
 
 # Check whether --enable-wgetch-events or --disable-wgetch-events was given.
@@ -16021,7 +16917,7 @@ if test "${enable_wgetch_events+set}" = set; then
 else
   with_wgetch_events=no
 fi;
-echo "$as_me:16024: result: $with_wgetch_events" >&5
+echo "$as_me:16920: result: $with_wgetch_events" >&5
 echo "${ECHO_T}$with_wgetch_events" >&6
 if test "x$with_wgetch_events" = xyes ; then
 
@@ -16036,7 +16932,7 @@ fi
 
 case "$cf_cv_system_name" in
 (*mingw32*|*mingw64*|*-msvc*)
-	echo "$as_me:16039: checking if you want experimental-Windows driver" >&5
+	echo "$as_me:16935: checking if you want experimental-Windows driver" >&5
 echo $ECHO_N "checking if you want experimental-Windows driver... $ECHO_C" >&6
 
 # Check whether --enable-exp-win32 or --disable-exp-win32 was given.
@@ -16046,7 +16942,7 @@ if test "${enable_exp_win32+set}" = set; then
 else
   with_exp_win32=no
 fi;
-	echo "$as_me:16049: result: $with_exp_win32" >&5
+	echo "$as_me:16945: result: $with_exp_win32" >&5
 echo "${ECHO_T}$with_exp_win32" >&6
 	if test "x$with_exp_win32" = xyes
 	then
@@ -16072,7 +16968,7 @@ esac
 
 ###	use option --disable-echo to suppress full display compiling commands
 
-echo "$as_me:16075: checking if you want to see long compiling messages" >&5
+echo "$as_me:16971: checking if you want to see long compiling messages" >&5
 echo $ECHO_N "checking if you want to see long compiling messages... $ECHO_C" >&6
 
 # Check whether --enable-echo or --disable-echo was given.
@@ -16106,7 +17002,7 @@ else
 	ECHO_CC=''
 
 fi;
-echo "$as_me:16109: result: $enableval" >&5
+echo "$as_me:17005: result: $enableval" >&5
 echo "${ECHO_T}$enableval" >&6
 
 if test "x$enable_echo" = xyes; then
@@ -16119,7 +17015,7 @@ fi
 
 # --disable-stripping is used for debugging
 
-echo "$as_me:16122: checking if you want to install stripped executables" >&5
+echo "$as_me:17018: checking if you want to install stripped executables" >&5
 echo $ECHO_N "checking if you want to install stripped executables... $ECHO_C" >&6
 
 # Check whether --enable-stripping or --disable-stripping was given.
@@ -16136,7 +17032,7 @@ else
 	enable_stripping=yes
 
 fi;
-echo "$as_me:16139: result: $enable_stripping" >&5
+echo "$as_me:17035: result: $enable_stripping" >&5
 echo "${ECHO_T}$enable_stripping" >&6
 
 if test "$enable_stripping" = yes
@@ -16147,7 +17043,7 @@ else
 fi
 
 : "${INSTALL:=install}"
-echo "$as_me:16150: checking if install accepts -p option" >&5
+echo "$as_me:17046: checking if install accepts -p option" >&5
 echo $ECHO_N "checking if install accepts -p option... $ECHO_C" >&6
 if test "${cf_cv_install_p+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -16178,10 +17074,10 @@ else
 	rm -rf ./conftest*
 
 fi
-echo "$as_me:16181: result: $cf_cv_install_p" >&5
+echo "$as_me:17077: result: $cf_cv_install_p" >&5
 echo "${ECHO_T}$cf_cv_install_p" >&6
 
-echo "$as_me:16184: checking if install needs to be told about ownership" >&5
+echo "$as_me:17080: checking if install needs to be told about ownership" >&5
 echo $ECHO_N "checking if install needs to be told about ownership... $ECHO_C" >&6
 case `$ac_config_guess` in
 (*minix)
@@ -16192,30 +17088,180 @@ case `$ac_config_guess` in
 	;;
 esac
 
-echo "$as_me:16195: result: $with_install_o" >&5
+echo "$as_me:17091: result: $with_install_o" >&5
 echo "${ECHO_T}$with_install_o" >&6
 if test "x$with_install_o" = xyes
 then
 	INSTALL_OPT_O="`id root|sed -e 's/uid=[0-9]*(/ -o /' -e 's/gid=[0-9]*(/ -g /' -e 's/ [^=[:space:]][^=[:space:]]*=.*/ /' -e 's/)//g'`"
 else
-	INSTALL_OPT_O=
+	INSTALL_OPT_O=
+fi
+
+if test -n "$INSTALL_OPT_S"
+then
+	echo "$as_me:17102: checking if you want to specify strip-program" >&5
+echo $ECHO_N "checking if you want to specify strip-program... $ECHO_C" >&6
+
+# Check whether --with-strip-program or --without-strip-program was given.
+if test "${with_strip_program+set}" = set; then
+  withval="$with_strip_program"
+  with_strip_program=$withval
+else
+  with_strip_program=no
+fi;
+	echo "$as_me:17112: result: $with_strip_program" >&5
+echo "${ECHO_T}$with_strip_program" >&6
+	if test "$with_strip_program" != no
+	then
+		echo "$as_me:17116: checking if strip-program is supported with this installer" >&5
+echo $ECHO_N "checking if strip-program is supported with this installer... $ECHO_C" >&6
+		cf_install_program=`echo "$INSTALL" | sed -e 's%[ ]*[ ]-.%%'`
+		check_install_strip=no
+		if test -f "$cf_install_program"
+		then
+			check_install_version=`"$cf_install_program" --version 2>/dev/null | head -n 1 | grep coreutils`
+			if test -n "$check_install_version"
+			then
+				check_install_strip="option"
+			else
+				for check_strip_variable in STRIPBIN STRIP
+				do
+					if strings "$cf_install_program" | grep "^$check_strip_variable$" >/dev/null
+					then
+						check_install_strip="environ"
+						break
+					fi
+				done
+			fi
+		fi
+		echo "$as_me:17137: result: $check_install_strip" >&5
+echo "${ECHO_T}$check_install_strip" >&6
+		case "$check_install_strip" in
+		(no)
+			{ echo "$as_me:17141: WARNING: $cf_install_program does not support strip program option" >&5
+echo "$as_me: WARNING: $cf_install_program does not support strip program option" >&2;}
+			with_strip_program=no
+			;;
+		(environ)
+			cat >install.tmp <<-CF_EOF
+			#! $SHELL
+			STRIPBIN="$with_strip_program" \\
+			STRIP="$with_strip_program" \\
+			$INSTALL "$@"
+			CF_EOF
+			INSTALL="`pwd`/install.tmp"
+			chmod +x "$INSTALL"
+			test -n "$verbose" && echo "	created $INSTALL" 1>&6
+
+echo "${as_me:-configure}:17156: testing created $INSTALL ..." 1>&5
+
+			;;
+		(option)
+			INSTALL_OPT_S="$INSTALL_OPT_S --strip-program=\"$with_strip_program\""
+			;;
+		esac
+	fi
+fi
+
+# If we're avoiding relinking of shared libraries during install, that is to
+# avoid modifying the build-tree.  For the same reason, avoid doing ranlib if
+# the install program has "-p" (for preserving timestamps).
+cf_cv_do_reranlib=yes
+if test "x$cf_cv_install_p" = xyes
+then
+	if test "x$cf_cv_do_relink" != xyes
+	then
+		cf_cv_do_reranlib=no
+		INSTALL_OPT_P="-p"
+		INSTALL_LIB="$INSTALL_LIB $INSTALL_OPT_P"
+	fi
+fi
+
+###	use option --enable-warnings to turn on all gcc warnings
+
+echo "$as_me:17182: checking if you want to use C11 _Noreturn feature" >&5
+echo $ECHO_N "checking if you want to use C11 _Noreturn feature... $ECHO_C" >&6
+
+# Check whether --enable-stdnoreturn or --disable-stdnoreturn was given.
+if test "${enable_stdnoreturn+set}" = set; then
+  enableval="$enable_stdnoreturn"
+  test "$enableval" != yes && enableval=no
+	if test "$enableval" != "no" ; then
+    enable_stdnoreturn=yes
+	else
+		enable_stdnoreturn=no
+	fi
+else
+  enableval=no
+	enable_stdnoreturn=no
+
+fi;
+echo "$as_me:17199: result: $enable_stdnoreturn" >&5
+echo "${ECHO_T}$enable_stdnoreturn" >&6
+
+if test $enable_stdnoreturn = yes; then
+echo "$as_me:17203: checking for C11 _Noreturn feature" >&5
+echo $ECHO_N "checking for C11 _Noreturn feature... $ECHO_C" >&6
+if test "${cf_cv_c11_noreturn+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 17209 "configure"
+#include "confdefs.h"
+
+$ac_includes_default
+#include <stdnoreturn.h>
+static _Noreturn void giveup(void) { exit(0); }
+
+int
+main (void)
+{
+if (feof(stdin)) giveup()
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:17225: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:17228: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:17231: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:17234: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  cf_cv_c11_noreturn=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+cf_cv_c11_noreturn=no
 fi
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 
-# If we're avoiding relinking of shared libraries during install, that is to
-# avoid modifying the build-tree.  For the same reason, avoid doing ranlib if
-# the install program has "-p" (for preserving timestamps).
-cf_cv_do_reranlib=yes
-if test "x$cf_cv_install_p" = xyes
-then
-	if test "x$cf_cv_do_relink" != xyes
-	then
-		cf_cv_do_reranlib=no
-		INSTALL_OPT_P="-p"
-		INSTALL_LIB="$INSTALL_LIB $INSTALL_OPT_P"
-	fi
+fi
+echo "$as_me:17245: result: $cf_cv_c11_noreturn" >&5
+echo "${ECHO_T}$cf_cv_c11_noreturn" >&6
+else
+	cf_cv_c11_noreturn=no,
 fi
 
-###	use option --enable-warnings to turn on all gcc warnings
+if test "$cf_cv_c11_noreturn" = yes; then
+
+cat >>confdefs.h <<\EOF
+#define HAVE_STDNORETURN_H 1
+EOF
+
+cat >>confdefs.h <<EOF
+#define STDC_NORETURN _Noreturn
+EOF
+
+	HAVE_STDNORETURN_H=1
+else
+	HAVE_STDNORETURN_H=0
+fi
 
 if test "$GCC" = yes || test "$GXX" = yes
 then
@@ -16224,14 +17270,16 @@ if test "$GCC" = yes || test "$GXX" = yes
 then
 	case $CFLAGS in
 	(*-Werror=*)
-		test -n "$verbose" && echo "	repairing CFLAGS: $CFLAGS" 1>&6
-
-echo "${as_me:-configure}:16229: testing repairing CFLAGS: $CFLAGS ..." 1>&5
-
 		cf_temp_flags=
 		for cf_temp_scan in $CFLAGS
 		do
 			case "x$cf_temp_scan" in
+			(x-Werror=format*)
+
+	test -n "$cf_temp_flags" && cf_temp_flags="$cf_temp_flags "
+	cf_temp_flags="${cf_temp_flags}$cf_temp_scan"
+
+				;;
 			(x-Werror=*)
 
 	test -n "$EXTRA_CFLAGS" && EXTRA_CFLAGS="$EXTRA_CFLAGS "
@@ -16246,15 +17294,22 @@ echo "${as_me:-configure}:16229: testing repairing CFLAGS: $CFLAGS ..." 1>&5
 				;;
 			esac
 		done
-		CFLAGS="$cf_temp_flags"
-		test -n "$verbose" && echo "	... fixed $CFLAGS" 1>&6
+		if test "x$CFLAGS" != "x$cf_temp_flags"
+		then
+			test -n "$verbose" && echo "	repairing CFLAGS: $CFLAGS" 1>&6
+
+echo "${as_me:-configure}:17301: testing repairing CFLAGS: $CFLAGS ..." 1>&5
+
+			CFLAGS="$cf_temp_flags"
+			test -n "$verbose" && echo "	... fixed $CFLAGS" 1>&6
 
-echo "${as_me:-configure}:16252: testing ... fixed $CFLAGS ..." 1>&5
+echo "${as_me:-configure}:17306: testing ... fixed $CFLAGS ..." 1>&5
 
-		test -n "$verbose" && echo "	... extra $EXTRA_CFLAGS" 1>&6
+			test -n "$verbose" && echo "	... extra $EXTRA_CFLAGS" 1>&6
 
-echo "${as_me:-configure}:16256: testing ... extra $EXTRA_CFLAGS ..." 1>&5
+echo "${as_me:-configure}:17310: testing ... extra $EXTRA_CFLAGS ..." 1>&5
 
+		fi
 		;;
 	esac
 fi
@@ -16263,14 +17318,16 @@ if test "$GCC" = yes || test "$GXX" = yes
 then
 	case $CPPFLAGS in
 	(*-Werror=*)
-		test -n "$verbose" && echo "	repairing CPPFLAGS: $CPPFLAGS" 1>&6
-
-echo "${as_me:-configure}:16268: testing repairing CPPFLAGS: $CPPFLAGS ..." 1>&5
-
 		cf_temp_flags=
 		for cf_temp_scan in $CPPFLAGS
 		do
 			case "x$cf_temp_scan" in
+			(x-Werror=format*)
+
+	test -n "$cf_temp_flags" && cf_temp_flags="$cf_temp_flags "
+	cf_temp_flags="${cf_temp_flags}$cf_temp_scan"
+
+				;;
 			(x-Werror=*)
 
 	test -n "$EXTRA_CFLAGS" && EXTRA_CFLAGS="$EXTRA_CFLAGS "
@@ -16285,15 +17342,22 @@ echo "${as_me:-configure}:16268: testing repairing CPPFLAGS: $CPPFLAGS ..." 1>&5
 				;;
 			esac
 		done
-		CPPFLAGS="$cf_temp_flags"
-		test -n "$verbose" && echo "	... fixed $CPPFLAGS" 1>&6
+		if test "x$CPPFLAGS" != "x$cf_temp_flags"
+		then
+			test -n "$verbose" && echo "	repairing CPPFLAGS: $CPPFLAGS" 1>&6
+
+echo "${as_me:-configure}:17349: testing repairing CPPFLAGS: $CPPFLAGS ..." 1>&5
 
-echo "${as_me:-configure}:16291: testing ... fixed $CPPFLAGS ..." 1>&5
+			CPPFLAGS="$cf_temp_flags"
+			test -n "$verbose" && echo "	... fixed $CPPFLAGS" 1>&6
 
-		test -n "$verbose" && echo "	... extra $EXTRA_CFLAGS" 1>&6
+echo "${as_me:-configure}:17354: testing ... fixed $CPPFLAGS ..." 1>&5
 
-echo "${as_me:-configure}:16295: testing ... extra $EXTRA_CFLAGS ..." 1>&5
+			test -n "$verbose" && echo "	... extra $EXTRA_CFLAGS" 1>&6
 
+echo "${as_me:-configure}:17358: testing ... extra $EXTRA_CFLAGS ..." 1>&5
+
+		fi
 		;;
 	esac
 fi
@@ -16302,14 +17366,16 @@ if test "$GCC" = yes || test "$GXX" = yes
 then
 	case $LDFLAGS in
 	(*-Werror=*)
-		test -n "$verbose" && echo "	repairing LDFLAGS: $LDFLAGS" 1>&6
-
-echo "${as_me:-configure}:16307: testing repairing LDFLAGS: $LDFLAGS ..." 1>&5
-
 		cf_temp_flags=
 		for cf_temp_scan in $LDFLAGS
 		do
 			case "x$cf_temp_scan" in
+			(x-Werror=format*)
+
+	test -n "$cf_temp_flags" && cf_temp_flags="$cf_temp_flags "
+	cf_temp_flags="${cf_temp_flags}$cf_temp_scan"
+
+				;;
 			(x-Werror=*)
 
 	test -n "$EXTRA_CFLAGS" && EXTRA_CFLAGS="$EXTRA_CFLAGS "
@@ -16324,20 +17390,27 @@ echo "${as_me:-configure}:16307: testing repairing LDFLAGS: $LDFLAGS ..." 1>&5
 				;;
 			esac
 		done
-		LDFLAGS="$cf_temp_flags"
-		test -n "$verbose" && echo "	... fixed $LDFLAGS" 1>&6
+		if test "x$LDFLAGS" != "x$cf_temp_flags"
+		then
+			test -n "$verbose" && echo "	repairing LDFLAGS: $LDFLAGS" 1>&6
 
-echo "${as_me:-configure}:16330: testing ... fixed $LDFLAGS ..." 1>&5
+echo "${as_me:-configure}:17397: testing repairing LDFLAGS: $LDFLAGS ..." 1>&5
 
-		test -n "$verbose" && echo "	... extra $EXTRA_CFLAGS" 1>&6
+			LDFLAGS="$cf_temp_flags"
+			test -n "$verbose" && echo "	... fixed $LDFLAGS" 1>&6
 
-echo "${as_me:-configure}:16334: testing ... extra $EXTRA_CFLAGS ..." 1>&5
+echo "${as_me:-configure}:17402: testing ... fixed $LDFLAGS ..." 1>&5
 
+			test -n "$verbose" && echo "	... extra $EXTRA_CFLAGS" 1>&6
+
+echo "${as_me:-configure}:17406: testing ... extra $EXTRA_CFLAGS ..." 1>&5
+
+		fi
 		;;
 	esac
 fi
 
-echo "$as_me:16340: checking if you want to turn on gcc warnings" >&5
+echo "$as_me:17413: checking if you want to turn on gcc warnings" >&5
 echo $ECHO_N "checking if you want to turn on gcc warnings... $ECHO_C" >&6
 
 # Check whether --enable-warnings or --disable-warnings was given.
@@ -16354,7 +17427,7 @@ else
 	enable_warnings=no
 
 fi;
-echo "$as_me:16357: result: $enable_warnings" >&5
+echo "$as_me:17430: result: $enable_warnings" >&5
 echo "${ECHO_T}$enable_warnings" >&6
 if test "$enable_warnings" = "yes"
 then
@@ -16378,7 +17451,7 @@ do
 done
 
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 16381 "configure"
+#line 17454 "configure"
 #include "confdefs.h"
 
 #include <stdlib.h>
@@ -16387,34 +17460,35 @@ cat >"conftest.$ac_ext" <<_ACEOF
 int
 main (void)
 {
-String foo = malloc(1); (void)foo
+String foo = malloc(1); free((void*)foo)
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:16396: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:17469: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:16399: \$? = $ac_status" >&5
+  echo "$as_me:17472: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:16402: \"$ac_try\"") >&5
+  { (eval echo "$as_me:17475: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:16405: \$? = $ac_status" >&5
+  echo "$as_me:17478: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
 
-echo "$as_me:16408: checking for X11/Xt const-feature" >&5
+echo "$as_me:17481: checking for X11/Xt const-feature" >&5
 echo $ECHO_N "checking for X11/Xt const-feature... $ECHO_C" >&6
 if test "${cf_cv_const_x_string+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 16415 "configure"
+#line 17488 "configure"
 #include "confdefs.h"
 
+#undef  _CONST_X_STRING
 #define _CONST_X_STRING	/* X11R7.8 (perhaps) */
 #undef  XTSTRINGDEFINES	/* X11R5 and later */
 #include <stdlib.h>
@@ -16429,16 +17503,16 @@ String foo = malloc(1); *foo = 0
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:16432: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:17506: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:16435: \$? = $ac_status" >&5
+  echo "$as_me:17509: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:16438: \"$ac_try\"") >&5
+  { (eval echo "$as_me:17512: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:16441: \$? = $ac_status" >&5
+  echo "$as_me:17515: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
 
 			cf_cv_const_x_string=no
@@ -16453,7 +17527,7 @@ fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 
 fi
-echo "$as_me:16456: result: $cf_cv_const_x_string" >&5
+echo "$as_me:17530: result: $cf_cv_const_x_string" >&5
 echo "${ECHO_T}$cf_cv_const_x_string" >&6
 
 LIBS="$cf_save_LIBS_CF_CONST_X_STRING"
@@ -16482,7 +17556,7 @@ fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
  fi
 cat > "conftest.$ac_ext" <<EOF
-#line 16485 "${as_me:-configure}"
+#line 17559 "${as_me:-configure}"
 int main(int argc, char *argv[]) { return (argv[argc-1] == 0) ; }
 EOF
 if test "$INTEL_COMPILER" = yes
@@ -16498,7 +17572,7 @@ then
 # remark #981: operands are evaluated in unspecified order
 # warning #279: controlling expression is constant
 
-	{ echo "$as_me:16501: checking for $CC warning options..." >&5
+	{ echo "$as_me:17575: checking for $CC warning options..." >&5
 echo "$as_me: checking for $CC warning options..." >&6;}
 	cf_save_CFLAGS="$CFLAGS"
 	EXTRA_CFLAGS="$EXTRA_CFLAGS -Wall"
@@ -16514,12 +17588,12 @@ echo "$as_me: checking for $CC warning options..." >&6;}
 		wd981
 	do
 		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
-		if { (eval echo "$as_me:16517: \"$ac_compile\"") >&5
+		if { (eval echo "$as_me:17591: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:16520: \$? = $ac_status" >&5
+  echo "$as_me:17594: \$? = $ac_status" >&5
   (exit "$ac_status"); }; then
-			test -n "$verbose" && echo "$as_me:16522: result: ... -$cf_opt" >&5
+			test -n "$verbose" && echo "$as_me:17596: result: ... -$cf_opt" >&5
 echo "${ECHO_T}... -$cf_opt" >&6
 			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
 		fi
@@ -16527,7 +17601,7 @@ echo "${ECHO_T}... -$cf_opt" >&6
 	CFLAGS="$cf_save_CFLAGS"
 elif test "$GCC" = yes && test "$GCC_VERSION" != "unknown"
 then
-	{ echo "$as_me:16530: checking for $CC warning options..." >&5
+	{ echo "$as_me:17604: checking for $CC warning options..." >&5
 echo "$as_me: checking for $CC warning options..." >&6;}
 	cf_save_CFLAGS="$CFLAGS"
 	cf_warn_CONST=""
@@ -16550,12 +17624,12 @@ echo "$as_me: checking for $CC warning options..." >&6;}
 		Wundef Wno-inline $cf_gcc_warnings $cf_warn_CONST Wno-unknown-pragmas Wswitch-enum
 	do
 		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
-		if { (eval echo "$as_me:16553: \"$ac_compile\"") >&5
+		if { (eval echo "$as_me:17627: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:16556: \$? = $ac_status" >&5
+  echo "$as_me:17630: \$? = $ac_status" >&5
   (exit "$ac_status"); }; then
-			test -n "$verbose" && echo "$as_me:16558: result: ... -$cf_opt" >&5
+			test -n "$verbose" && echo "$as_me:17632: result: ... -$cf_opt" >&5
 echo "${ECHO_T}... -$cf_opt" >&6
 			case "$cf_opt" in
 			(Winline)
@@ -16563,7 +17637,7 @@ echo "${ECHO_T}... -$cf_opt" >&6
 				([34].*)
 					test -n "$verbose" && echo "	feature is broken in gcc $GCC_VERSION" 1>&6
 
-echo "${as_me:-configure}:16566: testing feature is broken in gcc $GCC_VERSION ..." 1>&5
+echo "${as_me:-configure}:17640: testing feature is broken in gcc $GCC_VERSION ..." 1>&5
 
 					continue;;
 				esac
@@ -16573,7 +17647,7 @@ echo "${as_me:-configure}:16566: testing feature is broken in gcc $GCC_VERSION .
 				([12].*)
 					test -n "$verbose" && echo "	feature is broken in gcc $GCC_VERSION" 1>&6
 
-echo "${as_me:-configure}:16576: testing feature is broken in gcc $GCC_VERSION ..." 1>&5
+echo "${as_me:-configure}:17650: testing feature is broken in gcc $GCC_VERSION ..." 1>&5
 
 					continue;;
 				esac
@@ -16606,10 +17680,11 @@ cat > conftest.i <<EOF
 EOF
 if test "$GCC" = yes
 then
-	{ echo "$as_me:16609: checking for $CC __attribute__ directives..." >&5
+	{ echo "$as_me:17683: checking for $CC __attribute__ directives..." >&5
 echo "$as_me: checking for $CC __attribute__ directives..." >&6;}
 cat > "conftest.$ac_ext" <<EOF
-#line 16612 "${as_me:-configure}"
+#line 17686 "${as_me:-configure}"
+#include <stdio.h>
 #include "confdefs.h"
 #include "conftest.h"
 #include "conftest.i"
@@ -16624,8 +17699,8 @@ cat > "conftest.$ac_ext" <<EOF
 #define GCC_SCANFLIKE(fmt,var)  /*nothing*/
 #endif
 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
-extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
-extern void foo(void) GCC_NORETURN;
+extern GCC_NORETURN void oops(char *,...) GCC_PRINTFLIKE(1,2);
+extern GCC_NORETURN void foo(void);
 int main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED) { (void)argc; (void)argv; return 0; }
 EOF
 	cf_printf_attribute=no
@@ -16658,12 +17733,12 @@ EOF
 			;;
 		esac
 
-		if { (eval echo "$as_me:16661: \"$ac_compile\"") >&5
+		if { (eval echo "$as_me:17736: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:16664: \$? = $ac_status" >&5
+  echo "$as_me:17739: \$? = $ac_status" >&5
   (exit "$ac_status"); }; then
-			test -n "$verbose" && echo "$as_me:16666: result: ... $cf_attribute" >&5
+			test -n "$verbose" && echo "$as_me:17741: result: ... $cf_attribute" >&5
 echo "${ECHO_T}... $cf_attribute" >&6
 			cat conftest.h >>confdefs.h
 			case "$cf_attribute" in
@@ -16726,7 +17801,7 @@ fi
 
 if test "x$enable_warnings" = "xyes"; then
 
- 	ADAFLAGS="$ADAFLAGS -gnatg"
+ 	ADAFLAGS="$ADAFLAGS -gnatwa -gnatyg"
 
 	if test "x$cf_with_cxx" = xyes ; then
 
@@ -16735,12 +17810,12 @@ INTEL_CPLUSPLUS=no
 if test "$GCC" = yes ; then
 	case "$host_os" in
 	(linux*|gnu*)
-		echo "$as_me:16738: checking if this is really Intel C++ compiler" >&5
+		echo "$as_me:17813: checking if this is really Intel C++ compiler" >&5
 echo $ECHO_N "checking if this is really Intel C++ compiler... $ECHO_C" >&6
 		cf_save_CFLAGS="$CXXFLAGS"
 		CXXFLAGS="$CXXFLAGS -no-gcc"
 		cat >"conftest.$ac_ext" <<_ACEOF
-#line 16743 "configure"
+#line 17818 "configure"
 #include "confdefs.h"
 
 int
@@ -16749,7 +17824,7 @@ main (void)
 
 #ifdef __INTEL_COMPILER
 #else
-make an error
+#error __INTEL_COMPILER is not defined
 #endif
 
   ;
@@ -16757,16 +17832,16 @@ make an error
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:16760: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:17835: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:16763: \$? = $ac_status" >&5
+  echo "$as_me:17838: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:16766: \"$ac_try\"") >&5
+  { (eval echo "$as_me:17841: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:16769: \$? = $ac_status" >&5
+  echo "$as_me:17844: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   INTEL_CPLUSPLUS=yes
 cf_save_CFLAGS="$cf_save_CFLAGS -we147"
@@ -16777,7 +17852,7 @@ cat "conftest.$ac_ext" >&5
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 		CXXFLAGS="$cf_save_CFLAGS"
-		echo "$as_me:16780: result: $INTEL_CPLUSPLUS" >&5
+		echo "$as_me:17855: result: $INTEL_CPLUSPLUS" >&5
 echo "${ECHO_T}$INTEL_CPLUSPLUS" >&6
 		;;
 	esac
@@ -16786,11 +17861,11 @@ fi
 CLANG_CPLUSPLUS=no
 
 if test "$GCC" = yes ; then
-	echo "$as_me:16789: checking if this is really Clang C++ compiler" >&5
+	echo "$as_me:17864: checking if this is really Clang C++ compiler" >&5
 echo $ECHO_N "checking if this is really Clang C++ compiler... $ECHO_C" >&6
 	cf_save_CFLAGS="$CXXFLAGS"
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 16793 "configure"
+#line 17868 "configure"
 #include "confdefs.h"
 
 int
@@ -16799,7 +17874,7 @@ main (void)
 
 #ifdef __clang__
 #else
-make an error
+#error __clang__ is not defined
 #endif
 
   ;
@@ -16807,16 +17882,16 @@ make an error
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:16810: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:17885: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:16813: \$? = $ac_status" >&5
+  echo "$as_me:17888: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:16816: \"$ac_try\"") >&5
+  { (eval echo "$as_me:17891: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:16819: \$? = $ac_status" >&5
+  echo "$as_me:17894: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   CLANG_CPLUSPLUS=yes
 
@@ -16826,7 +17901,7 @@ cat "conftest.$ac_ext" >&5
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 	CXXFLAGS="$cf_save_CFLAGS"
-	echo "$as_me:16829: result: $CLANG_CPLUSPLUS" >&5
+	echo "$as_me:17904: result: $CLANG_CPLUSPLUS" >&5
 echo "${ECHO_T}$CLANG_CPLUSPLUS" >&6
 fi
 
@@ -16835,30 +17910,30 @@ CLANG_VERSION=none
 if test "x$CLANG_CPLUSPLUS" = "xyes" ; then
 	case "$CC" in
 	(c[1-9][0-9]|*/c[1-9][0-9])
-		{ echo "$as_me:16838: WARNING: replacing broken compiler alias $CC" >&5
+		{ echo "$as_me:17913: WARNING: replacing broken compiler alias $CC" >&5
 echo "$as_me: WARNING: replacing broken compiler alias $CC" >&2;}
 		CFLAGS="$CFLAGS -std=`echo "$CC" | sed -e 's%.*/%%'`"
 		CC=clang
 		;;
 	esac
 
-	echo "$as_me:16845: checking version of $CC" >&5
+	echo "$as_me:17920: checking version of $CC" >&5
 echo $ECHO_N "checking version of $CC... $ECHO_C" >&6
 	CLANG_VERSION="`$CC --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(CLANG[^)]*) //' -e 's/^.*(Debian[^)]*) //' -e 's/^[^0-9.]*//' -e 's/[^0-9.].*//'`"
 	test -z "$CLANG_VERSION" && CLANG_VERSION=unknown
-	echo "$as_me:16849: result: $CLANG_VERSION" >&5
+	echo "$as_me:17924: result: $CLANG_VERSION" >&5
 echo "${ECHO_T}$CLANG_VERSION" >&6
 
 	for cf_clang_opt in \
 		-Qunused-arguments \
 		-Wno-error=implicit-function-declaration
 	do
-		echo "$as_me:16856: checking if option $cf_clang_opt works" >&5
+		echo "$as_me:17931: checking if option $cf_clang_opt works" >&5
 echo $ECHO_N "checking if option $cf_clang_opt works... $ECHO_C" >&6
 		cf_save_CFLAGS="$CFLAGS"
 		CFLAGS="$CFLAGS $cf_clang_opt"
 		cat >"conftest.$ac_ext" <<_ACEOF
-#line 16861 "configure"
+#line 17936 "configure"
 #include "confdefs.h"
 
 			#include <stdio.h>
@@ -16872,16 +17947,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:16875: \"$ac_link\"") >&5
+if { (eval echo "$as_me:17950: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:16878: \$? = $ac_status" >&5
+  echo "$as_me:17953: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:16881: \"$ac_try\"") >&5
+  { (eval echo "$as_me:17956: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:16884: \$? = $ac_status" >&5
+  echo "$as_me:17959: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
 
 			cf_clang_optok=yes
@@ -16892,13 +17967,13 @@ cat "conftest.$ac_ext" >&5
 			cf_clang_optok=no
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
-		echo "$as_me:16895: result: $cf_clang_optok" >&5
+		echo "$as_me:17970: result: $cf_clang_optok" >&5
 echo "${ECHO_T}$cf_clang_optok" >&6
 		CFLAGS="$cf_save_CFLAGS"
 		if test "$cf_clang_optok" = yes; then
 			test -n "$verbose" && echo "	adding option $cf_clang_opt" 1>&6
 
-echo "${as_me:-configure}:16901: testing adding option $cf_clang_opt ..." 1>&5
+echo "${as_me:-configure}:17976: testing adding option $cf_clang_opt ..." 1>&5
 
 	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
 	CFLAGS="${CFLAGS}$cf_clang_opt"
@@ -16915,7 +17990,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
 ac_main_return="return"
 
 cat > conftest.$ac_ext <<EOF
-#line 16918 "configure"
+#line 17993 "configure"
 int main(int argc, char *argv[]) { return (argv[argc-1] == 0) ; }
 EOF
 
@@ -16933,7 +18008,7 @@ then
 # remark #981: operands are evaluated in unspecified order
 # warning #269: invalid format string conversion
 
-	{ echo "$as_me:16936: checking for $CC warning options..." >&5
+	{ echo "$as_me:18011: checking for $CC warning options..." >&5
 echo "$as_me: checking for $CC warning options..." >&6;}
 	cf_save_CXXFLAGS="$CXXFLAGS"
 	EXTRA_CXXFLAGS="-Wall"
@@ -16950,12 +18025,12 @@ echo "$as_me: checking for $CC warning options..." >&6;}
 		wd981
 	do
 		CXXFLAGS="$cf_save_CXXFLAGS $EXTRA_CXXFLAGS -$cf_opt"
-		if { (eval echo "$as_me:16953: \"$ac_compile\"") >&5
+		if { (eval echo "$as_me:18028: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:16956: \$? = $ac_status" >&5
+  echo "$as_me:18031: \$? = $ac_status" >&5
   (exit "$ac_status"); }; then
-			test -n "$verbose" && echo "$as_me:16958: result: ... -$cf_opt" >&5
+			test -n "$verbose" && echo "$as_me:18033: result: ... -$cf_opt" >&5
 echo "${ECHO_T}... -$cf_opt" >&6
 			EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS -$cf_opt"
 		fi
@@ -16964,7 +18039,7 @@ echo "${ECHO_T}... -$cf_opt" >&6
 
 elif test "$GXX" = yes
 then
-	{ echo "$as_me:16967: checking for $CXX warning options..." >&5
+	{ echo "$as_me:18042: checking for $CXX warning options..." >&5
 echo "$as_me: checking for $CXX warning options..." >&6;}
 	cf_save_CXXFLAGS="$CXXFLAGS"
 	EXTRA_CXXFLAGS="-W -Wall"
@@ -16994,16 +18069,16 @@ echo "$as_me: checking for $CXX warning options..." >&6;}
 		Wundef $cf_gxx_extra_warnings Wno-unused
 	do
 		CXXFLAGS="$cf_save_CXXFLAGS $EXTRA_CXXFLAGS -Werror -$cf_opt"
-		if { (eval echo "$as_me:16997: \"$ac_compile\"") >&5
+		if { (eval echo "$as_me:18072: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:17000: \$? = $ac_status" >&5
+  echo "$as_me:18075: \$? = $ac_status" >&5
   (exit "$ac_status"); }; then
-			test -n "$verbose" && echo "$as_me:17002: result: ... -$cf_opt" >&5
+			test -n "$verbose" && echo "$as_me:18077: result: ... -$cf_opt" >&5
 echo "${ECHO_T}... -$cf_opt" >&6
 			EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS -$cf_opt"
 		else
-			test -n "$verbose" && echo "$as_me:17006: result: ... no -$cf_opt" >&5
+			test -n "$verbose" && echo "$as_me:18081: result: ... no -$cf_opt" >&5
 echo "${ECHO_T}... no -$cf_opt" >&6
 		fi
 	done
@@ -17021,7 +18096,7 @@ ac_main_return="return"
 	fi
 fi
 
-echo "$as_me:17024: checking if you want to work around bogus compiler/loader warnings" >&5
+echo "$as_me:18099: checking if you want to work around bogus compiler/loader warnings" >&5
 echo $ECHO_N "checking if you want to work around bogus compiler/loader warnings... $ECHO_C" >&6
 
 # Check whether --enable-string-hacks or --disable-string-hacks was given.
@@ -17031,7 +18106,7 @@ if test "${enable_string_hacks+set}" = set; then
 else
   enable_string_hacks=no
 fi;
-echo "$as_me:17034: result: $enable_string_hacks" >&5
+echo "$as_me:18109: result: $enable_string_hacks" >&5
 echo "${ECHO_T}$enable_string_hacks" >&6
 
 if test "x$enable_string_hacks" = "xyes"; then
@@ -17040,15 +18115,15 @@ cat >>confdefs.h <<\EOF
 #define USE_STRING_HACKS 1
 EOF
 
-	{ echo "$as_me:17043: WARNING: enabling string-hacks to work around bogus compiler/loader warnings" >&5
+	{ echo "$as_me:18118: WARNING: enabling string-hacks to work around bogus compiler/loader warnings" >&5
 echo "$as_me: WARNING: enabling string-hacks to work around bogus compiler/loader warnings" >&2;}
-	echo "$as_me:17045: checking for strlcat" >&5
+	echo "$as_me:18120: checking for strlcat" >&5
 echo $ECHO_N "checking for strlcat... $ECHO_C" >&6
 if test "${ac_cv_func_strlcat+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 17051 "configure"
+#line 18126 "configure"
 #include "confdefs.h"
 #define strlcat autoconf_temporary
 #include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
@@ -17079,16 +18154,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:17082: \"$ac_link\"") >&5
+if { (eval echo "$as_me:18157: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:17085: \$? = $ac_status" >&5
+  echo "$as_me:18160: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:17088: \"$ac_try\"") >&5
+  { (eval echo "$as_me:18163: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:17091: \$? = $ac_status" >&5
+  echo "$as_me:18166: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_func_strlcat=yes
 else
@@ -17098,7 +18173,7 @@ ac_cv_func_strlcat=no
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:17101: result: $ac_cv_func_strlcat" >&5
+echo "$as_me:18176: result: $ac_cv_func_strlcat" >&5
 echo "${ECHO_T}$ac_cv_func_strlcat" >&6
 if test "$ac_cv_func_strlcat" = yes; then
 
@@ -17108,7 +18183,7 @@ EOF
 
 else
 
-		echo "$as_me:17111: checking for strlcat in -lbsd" >&5
+		echo "$as_me:18186: checking for strlcat in -lbsd" >&5
 echo $ECHO_N "checking for strlcat in -lbsd... $ECHO_C" >&6
 if test "${ac_cv_lib_bsd_strlcat+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -17116,7 +18191,7 @@ else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lbsd  $LIBS"
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 17119 "configure"
+#line 18194 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -17125,7 +18200,7 @@ extern "C"
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char strlcat ();
+char strlcat (void);
 int
 main (void)
 {
@@ -17135,16 +18210,16 @@ strlcat ();
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:17138: \"$ac_link\"") >&5
+if { (eval echo "$as_me:18213: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:17141: \$? = $ac_status" >&5
+  echo "$as_me:18216: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:17144: \"$ac_try\"") >&5
+  { (eval echo "$as_me:18219: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:17147: \$? = $ac_status" >&5
+  echo "$as_me:18222: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_lib_bsd_strlcat=yes
 else
@@ -17155,7 +18230,7 @@ fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:17158: result: $ac_cv_lib_bsd_strlcat" >&5
+echo "$as_me:18233: result: $ac_cv_lib_bsd_strlcat" >&5
 echo "${ECHO_T}$ac_cv_lib_bsd_strlcat" >&6
 if test "$ac_cv_lib_bsd_strlcat" = yes; then
 
@@ -17178,23 +18253,23 @@ LIBS="$cf_add_libs"
 for ac_header in bsd/string.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:17181: checking for $ac_header" >&5
+echo "$as_me:18256: checking for $ac_header" >&5
 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 17187 "configure"
+#line 18262 "configure"
 #include "confdefs.h"
 #include <$ac_header>
 _ACEOF
-if { (eval echo "$as_me:17191: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+if { (eval echo "$as_me:18266: \"$ac_cpp "conftest.$ac_ext"\"") >&5
   (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:17197: \$? = $ac_status" >&5
+  echo "$as_me:18272: \$? = $ac_status" >&5
   (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -17213,7 +18288,7 @@ else
 fi
 rm -f conftest.err "conftest.$ac_ext"
 fi
-echo "$as_me:17216: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
+echo "$as_me:18291: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
 echo "${ECHO_T}`eval echo '${'"$as_ac_Header"'}'`" >&6
 if test "`eval echo '${'"$as_ac_Header"'}'`" = yes; then
   cat >>confdefs.h <<EOF
@@ -17234,13 +18309,13 @@ fi
 for ac_func in strlcpy snprintf
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:17237: checking for $ac_func" >&5
+echo "$as_me:18312: checking for $ac_func" >&5
 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
 if eval "test \"\${$as_ac_var+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 17243 "configure"
+#line 18318 "configure"
 #include "confdefs.h"
 #define $ac_func autoconf_temporary
 #include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
@@ -17271,16 +18346,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:17274: \"$ac_link\"") >&5
+if { (eval echo "$as_me:18349: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:17277: \$? = $ac_status" >&5
+  echo "$as_me:18352: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:17280: \"$ac_try\"") >&5
+  { (eval echo "$as_me:18355: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:17283: \$? = $ac_status" >&5
+  echo "$as_me:18358: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   eval "$as_ac_var=yes"
 else
@@ -17290,7 +18365,7 @@ eval "$as_ac_var=no"
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:17293: result: `eval echo '${'"$as_ac_var"'}'`" >&5
+echo "$as_me:18368: result: `eval echo '${'"$as_ac_var"'}'`" >&5
 echo "${ECHO_T}`eval echo '${'"$as_ac_var"'}'`" >&6
 if test "`eval echo '${'"$as_ac_var"'}'`" = yes; then
   cat >>confdefs.h <<EOF
@@ -17303,7 +18378,7 @@ done
 fi
 
 ###	use option --enable-assertions to turn on generation of assertion code
-echo "$as_me:17306: checking if you want to enable runtime assertions" >&5
+echo "$as_me:18381: checking if you want to enable runtime assertions" >&5
 echo $ECHO_N "checking if you want to enable runtime assertions... $ECHO_C" >&6
 
 # Check whether --enable-assertions or --disable-assertions was given.
@@ -17313,7 +18388,7 @@ if test "${enable_assertions+set}" = set; then
 else
   with_assertions=no
 fi;
-echo "$as_me:17316: result: $with_assertions" >&5
+echo "$as_me:18391: result: $with_assertions" >&5
 echo "${ECHO_T}$with_assertions" >&6
 if test -n "$GCC"
 then
@@ -17329,24 +18404,29 @@ fi
 
 ###	use option --disable-leaks to suppress "permanent" leaks, for testing
 
-echo "$as_me:17332: checking if you want to use dmalloc for testing" >&5
+echo "$as_me:18407: checking if you want to use dmalloc for testing" >&5
 echo $ECHO_N "checking if you want to use dmalloc for testing... $ECHO_C" >&6
 
 # Check whether --with-dmalloc or --without-dmalloc was given.
 if test "${with_dmalloc+set}" = set; then
   withval="$with_dmalloc"
+  case "x$withval" in
+	(x|xno) ;;
+	(*)
+		: "${with_cflags:=-g}"
+		: "${enable_leaks:=no}"
+		with_dmalloc=yes
 
 cat >>confdefs.h <<EOF
 #define USE_DMALLOC 1
 EOF
 
-	: "${with_cflags:=-g}"
-	: "${enable_leaks:=no}"
-	 with_dmalloc=yes
+		;;
+	esac
 else
   with_dmalloc=
 fi;
-echo "$as_me:17349: result: ${with_dmalloc:-no}" >&5
+echo "$as_me:18429: result: ${with_dmalloc:-no}" >&5
 echo "${ECHO_T}${with_dmalloc:-no}" >&6
 
 case ".$with_cflags" in
@@ -17460,23 +18540,23 @@ fi
 esac
 
 if test "$with_dmalloc" = yes ; then
-	echo "$as_me:17463: checking for dmalloc.h" >&5
+	echo "$as_me:18543: checking for dmalloc.h" >&5
 echo $ECHO_N "checking for dmalloc.h... $ECHO_C" >&6
 if test "${ac_cv_header_dmalloc_h+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 17469 "configure"
+#line 18549 "configure"
 #include "confdefs.h"
 #include <dmalloc.h>
 _ACEOF
-if { (eval echo "$as_me:17473: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+if { (eval echo "$as_me:18553: \"$ac_cpp "conftest.$ac_ext"\"") >&5
   (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:17479: \$? = $ac_status" >&5
+  echo "$as_me:18559: \$? = $ac_status" >&5
   (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -17495,11 +18575,11 @@ else
 fi
 rm -f conftest.err "conftest.$ac_ext"
 fi
-echo "$as_me:17498: result: $ac_cv_header_dmalloc_h" >&5
+echo "$as_me:18578: result: $ac_cv_header_dmalloc_h" >&5
 echo "${ECHO_T}$ac_cv_header_dmalloc_h" >&6
 if test "$ac_cv_header_dmalloc_h" = yes; then
 
-echo "$as_me:17502: checking for dmalloc_debug in -ldmalloc" >&5
+echo "$as_me:18582: checking for dmalloc_debug in -ldmalloc" >&5
 echo $ECHO_N "checking for dmalloc_debug in -ldmalloc... $ECHO_C" >&6
 if test "${ac_cv_lib_dmalloc_dmalloc_debug+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -17507,7 +18587,7 @@ else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-ldmalloc  $LIBS"
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 17510 "configure"
+#line 18590 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -17516,7 +18596,7 @@ extern "C"
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char dmalloc_debug ();
+char dmalloc_debug (void);
 int
 main (void)
 {
@@ -17526,16 +18606,16 @@ dmalloc_debug ();
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:17529: \"$ac_link\"") >&5
+if { (eval echo "$as_me:18609: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:17532: \$? = $ac_status" >&5
+  echo "$as_me:18612: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:17535: \"$ac_try\"") >&5
+  { (eval echo "$as_me:18615: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:17538: \$? = $ac_status" >&5
+  echo "$as_me:18618: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_lib_dmalloc_dmalloc_debug=yes
 else
@@ -17546,7 +18626,7 @@ fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:17549: result: $ac_cv_lib_dmalloc_dmalloc_debug" >&5
+echo "$as_me:18629: result: $ac_cv_lib_dmalloc_dmalloc_debug" >&5
 echo "${ECHO_T}$ac_cv_lib_dmalloc_dmalloc_debug" >&6
 if test "$ac_cv_lib_dmalloc_dmalloc_debug" = yes; then
   cat >>confdefs.h <<EOF
@@ -17561,24 +18641,29 @@ fi
 
 fi
 
-echo "$as_me:17564: checking if you want to use dbmalloc for testing" >&5
+echo "$as_me:18644: checking if you want to use dbmalloc for testing" >&5
 echo $ECHO_N "checking if you want to use dbmalloc for testing... $ECHO_C" >&6
 
 # Check whether --with-dbmalloc or --without-dbmalloc was given.
 if test "${with_dbmalloc+set}" = set; then
   withval="$with_dbmalloc"
+  case "x$withval" in
+	(x|xno) ;;
+	(*)
+		: "${with_cflags:=-g}"
+		: "${enable_leaks:=no}"
+		with_dbmalloc=yes
 
 cat >>confdefs.h <<EOF
 #define USE_DBMALLOC 1
 EOF
 
-	: "${with_cflags:=-g}"
-	: "${enable_leaks:=no}"
-	 with_dbmalloc=yes
+		;;
+	esac
 else
   with_dbmalloc=
 fi;
-echo "$as_me:17581: result: ${with_dbmalloc:-no}" >&5
+echo "$as_me:18666: result: ${with_dbmalloc:-no}" >&5
 echo "${ECHO_T}${with_dbmalloc:-no}" >&6
 
 case ".$with_cflags" in
@@ -17692,23 +18777,23 @@ fi
 esac
 
 if test "$with_dbmalloc" = yes ; then
-	echo "$as_me:17695: checking for dbmalloc.h" >&5
+	echo "$as_me:18780: checking for dbmalloc.h" >&5
 echo $ECHO_N "checking for dbmalloc.h... $ECHO_C" >&6
 if test "${ac_cv_header_dbmalloc_h+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 17701 "configure"
+#line 18786 "configure"
 #include "confdefs.h"
 #include <dbmalloc.h>
 _ACEOF
-if { (eval echo "$as_me:17705: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+if { (eval echo "$as_me:18790: \"$ac_cpp "conftest.$ac_ext"\"") >&5
   (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:17711: \$? = $ac_status" >&5
+  echo "$as_me:18796: \$? = $ac_status" >&5
   (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -17727,11 +18812,11 @@ else
 fi
 rm -f conftest.err "conftest.$ac_ext"
 fi
-echo "$as_me:17730: result: $ac_cv_header_dbmalloc_h" >&5
+echo "$as_me:18815: result: $ac_cv_header_dbmalloc_h" >&5
 echo "${ECHO_T}$ac_cv_header_dbmalloc_h" >&6
 if test "$ac_cv_header_dbmalloc_h" = yes; then
 
-echo "$as_me:17734: checking for debug_malloc in -ldbmalloc" >&5
+echo "$as_me:18819: checking for debug_malloc in -ldbmalloc" >&5
 echo $ECHO_N "checking for debug_malloc in -ldbmalloc... $ECHO_C" >&6
 if test "${ac_cv_lib_dbmalloc_debug_malloc+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -17739,7 +18824,7 @@ else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-ldbmalloc  $LIBS"
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 17742 "configure"
+#line 18827 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -17748,7 +18833,7 @@ extern "C"
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char debug_malloc ();
+char debug_malloc (void);
 int
 main (void)
 {
@@ -17758,16 +18843,16 @@ debug_malloc ();
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:17761: \"$ac_link\"") >&5
+if { (eval echo "$as_me:18846: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:17764: \$? = $ac_status" >&5
+  echo "$as_me:18849: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:17767: \"$ac_try\"") >&5
+  { (eval echo "$as_me:18852: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:17770: \$? = $ac_status" >&5
+  echo "$as_me:18855: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_lib_dbmalloc_debug_malloc=yes
 else
@@ -17778,7 +18863,7 @@ fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:17781: result: $ac_cv_lib_dbmalloc_debug_malloc" >&5
+echo "$as_me:18866: result: $ac_cv_lib_dbmalloc_debug_malloc" >&5
 echo "${ECHO_T}$ac_cv_lib_dbmalloc_debug_malloc" >&6
 if test "$ac_cv_lib_dbmalloc_debug_malloc" = yes; then
   cat >>confdefs.h <<EOF
@@ -17793,24 +18878,29 @@ fi
 
 fi
 
-echo "$as_me:17796: checking if you want to use valgrind for testing" >&5
+echo "$as_me:18881: checking if you want to use valgrind for testing" >&5
 echo $ECHO_N "checking if you want to use valgrind for testing... $ECHO_C" >&6
 
 # Check whether --with-valgrind or --without-valgrind was given.
 if test "${with_valgrind+set}" = set; then
   withval="$with_valgrind"
+  case "x$withval" in
+	(x|xno) ;;
+	(*)
+		: "${with_cflags:=-g}"
+		: "${enable_leaks:=no}"
+		with_valgrind=yes
 
 cat >>confdefs.h <<EOF
 #define USE_VALGRIND 1
 EOF
 
-	: "${with_cflags:=-g}"
-	: "${enable_leaks:=no}"
-	 with_valgrind=yes
+		;;
+	esac
 else
   with_valgrind=
 fi;
-echo "$as_me:17813: result: ${with_valgrind:-no}" >&5
+echo "$as_me:18903: result: ${with_valgrind:-no}" >&5
 echo "${ECHO_T}${with_valgrind:-no}" >&6
 
 case ".$with_cflags" in
@@ -17923,18 +19013,18 @@ fi
 	;;
 esac
 
-echo "$as_me:17926: checking if you want to perform memory-leak testing" >&5
+echo "$as_me:19016: checking if you want to perform memory-leak testing" >&5
 echo $ECHO_N "checking if you want to perform memory-leak testing... $ECHO_C" >&6
 
 # Check whether --enable-leaks or --disable-leaks was given.
 if test "${enable_leaks+set}" = set; then
   enableval="$enable_leaks"
-  enable_leaks=no
+  enable_leaks=$enableval
 else
   enable_leaks=yes
 fi;
 if test "x$enable_leaks" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi
-echo "$as_me:17937: result: $with_no_leaks" >&5
+echo "$as_me:19027: result: $with_no_leaks" >&5
 echo "${ECHO_T}$with_no_leaks" >&6
 
 if test "$enable_leaks" = no ; then
@@ -17986,7 +19076,7 @@ case "$CFLAGS $CPPFLAGS" in
 	;;
 esac
 
-echo "$as_me:17989: checking whether to add trace feature to all models" >&5
+echo "$as_me:19079: checking whether to add trace feature to all models" >&5
 echo $ECHO_N "checking whether to add trace feature to all models... $ECHO_C" >&6
 
 # Check whether --with-trace or --without-trace was given.
@@ -17996,7 +19086,7 @@ if test "${with_trace+set}" = set; then
 else
   cf_with_trace=$cf_all_traces
 fi;
-echo "$as_me:17999: result: $cf_with_trace" >&5
+echo "$as_me:19089: result: $cf_with_trace" >&5
 echo "${ECHO_T}$cf_with_trace" >&6
 
 if test "x$cf_with_trace" = xyes ; then
@@ -18083,567 +19173,296 @@ done
 if test -n "$cf_new_cflags" ; then
 
 	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
-	CFLAGS="${CFLAGS}$cf_new_cflags"
-
-fi
-
-if test -n "$cf_new_cppflags" ; then
-
-	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
-	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
-
-fi
-
-if test -n "$cf_new_extra_cppflags" ; then
-
-	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
-	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
-
-fi
-
-cat >>confdefs.h <<\EOF
-#define HAVE__TRACEF 1
-EOF
-
-else
-	LIB_TRACING=DEBUG
-	ADA_TRACE=FALSE
-fi
-
-echo "$as_me:18113: checking if we want to use GNAT projects" >&5
-echo $ECHO_N "checking if we want to use GNAT projects... $ECHO_C" >&6
-
-# Check whether --enable-gnat-projects or --disable-gnat-projects was given.
-if test "${enable_gnat_projects+set}" = set; then
-  enableval="$enable_gnat_projects"
-  test "$enableval" != no && enableval=yes
-	if test "$enableval" != "yes" ; then
-    enable_gnat_projects=no
-	else
-		enable_gnat_projects=yes
-	fi
-else
-  enableval=yes
-	enable_gnat_projects=yes
-
-fi;
-echo "$as_me:18130: result: $enable_gnat_projects" >&5
-echo "${ECHO_T}$enable_gnat_projects" >&6
-
-###	Checks for libraries.
-case "$cf_cv_system_name" in
-(*mingw32*|*mingw64*)
-	if test "x$with_exp_win32" = xyes ; then
-	CPPFLAGS="$CPPFLAGS -DWINVER=0x0600 -DWIN32_LEAN_AND_MEAN"
-	else
-	CPPFLAGS="$CPPFLAGS -DWINVER=0x0501 -DWIN32_LEAN_AND_MEAN"
-	fi
-	# Note: WINVER may be a problem with Windows 10
-	;;
-(*)
-echo "$as_me:18144: checking for gettimeofday" >&5
-echo $ECHO_N "checking for gettimeofday... $ECHO_C" >&6
-if test "${ac_cv_func_gettimeofday+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >"conftest.$ac_ext" <<_ACEOF
-#line 18150 "configure"
-#include "confdefs.h"
-#define gettimeofday autoconf_temporary
-#include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
-#undef gettimeofday
-
-#ifdef __cplusplus
-extern "C"
-#endif
-
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char gettimeofday (void);
-
-int
-main (void)
-{
-
-/* The GNU C library defines stubs for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_gettimeofday) || defined (__stub___gettimeofday)
-#error found stub for gettimeofday
-#endif
-
-	return gettimeofday ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:18181: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:18184: \$? = $ac_status" >&5
-  (exit "$ac_status"); } &&
-         { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:18187: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:18190: \$? = $ac_status" >&5
-  (exit "$ac_status"); }; }; then
-  ac_cv_func_gettimeofday=yes
-else
-  echo "$as_me: failed program was:" >&5
-cat "conftest.$ac_ext" >&5
-ac_cv_func_gettimeofday=no
-fi
-rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
-fi
-echo "$as_me:18200: result: $ac_cv_func_gettimeofday" >&5
-echo "${ECHO_T}$ac_cv_func_gettimeofday" >&6
-if test "$ac_cv_func_gettimeofday" = yes; then
-
-cat >>confdefs.h <<\EOF
-#define HAVE_GETTIMEOFDAY 1
-EOF
-
-else
-
-echo "$as_me:18210: checking for gettimeofday in -lbsd" >&5
-echo $ECHO_N "checking for gettimeofday in -lbsd... $ECHO_C" >&6
-if test "${ac_cv_lib_bsd_gettimeofday+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lbsd  $LIBS"
-cat >"conftest.$ac_ext" <<_ACEOF
-#line 18218 "configure"
-#include "confdefs.h"
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char gettimeofday ();
-int
-main (void)
-{
-gettimeofday ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:18237: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:18240: \$? = $ac_status" >&5
-  (exit "$ac_status"); } &&
-         { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:18243: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:18246: \$? = $ac_status" >&5
-  (exit "$ac_status"); }; }; then
-  ac_cv_lib_bsd_gettimeofday=yes
-else
-  echo "$as_me: failed program was:" >&5
-cat "conftest.$ac_ext" >&5
-ac_cv_lib_bsd_gettimeofday=no
-fi
-rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:18257: result: $ac_cv_lib_bsd_gettimeofday" >&5
-echo "${ECHO_T}$ac_cv_lib_bsd_gettimeofday" >&6
-if test "$ac_cv_lib_bsd_gettimeofday" = yes; then
-
-cat >>confdefs.h <<\EOF
-#define HAVE_GETTIMEOFDAY 1
-EOF
-
-cf_add_libs="$LIBS"
-# reverse order
-cf_add_0lib=
-for cf_add_1lib in -lbsd; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
-# filter duplicates
-for cf_add_1lib in $cf_add_0lib; do
-	for cf_add_2lib in $cf_add_libs; do
-		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
-			cf_add_1lib=
-			break
-		fi
-	done
-	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
-done
-LIBS="$cf_add_libs"
+	CFLAGS="${CFLAGS}$cf_new_cflags"
 
 fi
 
-fi
-	;;
-esac
+if test -n "$cf_new_cppflags" ; then
 
-echo "$as_me:18287: checking if -lm needed for math functions" >&5
-echo $ECHO_N "checking if -lm needed for math functions... $ECHO_C" >&6
-if test "${cf_cv_need_libm+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
+	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
+	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"
 
-	cat >"conftest.$ac_ext" <<_ACEOF
-#line 18294 "configure"
-#include "confdefs.h"
+fi
 
-	#include <stdio.h>
-	#include <stdlib.h>
-	#include <math.h>
+if test -n "$cf_new_extra_cppflags" ; then
+
+	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
+	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"
 
-int
-main (void)
-{
-double x = rand(); printf("result = %g\\n", pow(sin(x),x))
-  ;
-  return 0;
-}
-_ACEOF
-rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:18310: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:18313: \$? = $ac_status" >&5
-  (exit "$ac_status"); } &&
-         { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:18316: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:18319: \$? = $ac_status" >&5
-  (exit "$ac_status"); }; }; then
-  cf_cv_need_libm=no
-else
-  echo "$as_me: failed program was:" >&5
-cat "conftest.$ac_ext" >&5
-cf_cv_need_libm=yes
-fi
-rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
-fi
-echo "$as_me:18329: result: $cf_cv_need_libm" >&5
-echo "${ECHO_T}$cf_cv_need_libm" >&6
-if test "$cf_cv_need_libm" = yes
-then
-MATH_LIB=-lm
 fi
 
-###	Checks for header files.
-echo "$as_me:18337: checking for ANSI C header files" >&5
-echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
-if test "${ac_cv_header_stdc+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >"conftest.$ac_ext" <<_ACEOF
-#line 18343 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
+cat >>confdefs.h <<\EOF
+#define HAVE__TRACEF 1
+EOF
 
-_ACEOF
-if { (eval echo "$as_me:18351: \"$ac_cpp "conftest.$ac_ext"\"") >&5
-  (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
-  ac_status=$?
-  $EGREP -v '^ *\+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:18357: \$? = $ac_status" >&5
-  (exit "$ac_status"); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
-  ac_cv_header_stdc=yes
 else
-  echo "$as_me: failed program was:" >&5
-  cat "conftest.$ac_ext" >&5
-  ac_cv_header_stdc=no
+	LIB_TRACING=DEBUG
+	ADA_TRACE=FALSE
 fi
-rm -f conftest.err "conftest.$ac_ext"
 
-if test $ac_cv_header_stdc = yes; then
-  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
-  cat >"conftest.$ac_ext" <<_ACEOF
-#line 18379 "configure"
-#include "confdefs.h"
-#include <string.h>
+echo "$as_me:19203: checking if we want to use GNAT projects" >&5
+echo $ECHO_N "checking if we want to use GNAT projects... $ECHO_C" >&6
 
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "memchr" >/dev/null 2>&1; then
-  :
+# Check whether --enable-gnat-projects or --disable-gnat-projects was given.
+if test "${enable_gnat_projects+set}" = set; then
+  enableval="$enable_gnat_projects"
+  test "$enableval" != no && enableval=yes
+	if test "$enableval" != "yes" ; then
+    enable_gnat_projects=no
+	else
+		enable_gnat_projects=yes
+	fi
 else
-  ac_cv_header_stdc=no
-fi
-rm -rf conftest*
+  enableval=yes
+	enable_gnat_projects=yes
 
-fi
+fi;
+echo "$as_me:19220: result: $enable_gnat_projects" >&5
+echo "${ECHO_T}$enable_gnat_projects" >&6
 
-if test $ac_cv_header_stdc = yes; then
-  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
-  cat >"conftest.$ac_ext" <<_ACEOF
-#line 18397 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
+###	Checks for libraries.
+case "$cf_cv_system_name" in
+(*mingw32*|*mingw64*)
+	# Note: WINVER may be a problem with Windows 10
+	if test "x$with_exp_win32" = xyes ; then
+		CPPFLAGS="$CPPFLAGS -DWINVER=0x0600 -DWIN32_LEAN_AND_MEAN"
+	else
+		CPPFLAGS="$CPPFLAGS -DWINVER=0x0501 -DWIN32_LEAN_AND_MEAN"
+	fi
 
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "free" >/dev/null 2>&1; then
-  :
+echo "$as_me:19233: checking if ssp library is needed" >&5
+echo $ECHO_N "checking if ssp library is needed... $ECHO_C" >&6
+if test "${cf_cv_need_libssp+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_cv_header_stdc=no
-fi
-rm -rf conftest*
-
-fi
 
-if test $ac_cv_header_stdc = yes; then
-  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
-  if test "$cross_compiling" = yes; then
-  :
-else
-  cat >"conftest.$ac_ext" <<_ACEOF
-#line 18418 "configure"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 19240 "configure"
 #include "confdefs.h"
-#include <ctype.h>
-#if ((' ' & 0x0FF) == 0x020)
-# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#else
-# define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \
-                     || ('j' <= (c) && (c) <= 'r') \
-                     || ('s' <= (c) && (c) <= 'z'))
-# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
-#endif
 
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+#include <sys/types.h>
+#include <dirent.h>
+
 int
 main (void)
 {
-  int i;
-  for (i = 0; i < 256; i++)
-    if (XOR (islower (i), ISLOWER (i))
-        || toupper (i) != TOUPPER (i))
-      $ac_main_return(2);
-  $ac_main_return (0);
+
+       DIR *dp = opendir(".");
+
+  ;
+  return 0;
 }
 _ACEOF
-rm -f "conftest$ac_exeext"
-if { (eval echo "$as_me:18444: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:19257: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:18447: \$? = $ac_status" >&5
-  (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
-  { (eval echo "$as_me:18449: \"$ac_try\"") >&5
+  echo "$as_me:19260: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:19263: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:18452: \$? = $ac_status" >&5
+  echo "$as_me:19266: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
-  :
+  cf_cv_need_libssp=no
 else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
+  echo "$as_me: failed program was:" >&5
 cat "conftest.$ac_ext" >&5
-ac_cv_header_stdc=no
-fi
-rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftest.$ac_ext"
-fi
-fi
-fi
-echo "$as_me:18465: result: $ac_cv_header_stdc" >&5
-echo "${ECHO_T}$ac_cv_header_stdc" >&6
-if test $ac_cv_header_stdc = yes; then
-
-cat >>confdefs.h <<\EOF
-#define STDC_HEADERS 1
-EOF
-
-fi
 
-ac_header_dirent=no
-for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
-  as_ac_Header=`echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh`
-echo "$as_me:18478: checking for $ac_hdr that defines DIR" >&5
-echo $ECHO_N "checking for $ac_hdr that defines DIR... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >"conftest.$ac_ext" <<_ACEOF
-#line 18484 "configure"
+	cf_save_LIBS="$LIBS"
+	LIBS="$LIBS -lssp"
+	cat >"conftest.$ac_ext" <<_ACEOF
+#line 19276 "configure"
 #include "confdefs.h"
+
 #include <sys/types.h>
-#include <$ac_hdr>
+#include <dirent.h>
 
 int
 main (void)
 {
-if ((DIR *) 0)
-return 0;
+
+		   DIR *dp = opendir(".");
+
   ;
   return 0;
 }
 _ACEOF
-rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:18499: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:19293: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:18502: \$? = $ac_status" >&5
+  echo "$as_me:19296: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
-         { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:18505: \"$ac_try\"") >&5
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:19299: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:18508: \$? = $ac_status" >&5
+  echo "$as_me:19302: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
-  eval "$as_ac_Header=yes"
+  cf_cv_need_libssp=yes
 else
   echo "$as_me: failed program was:" >&5
 cat "conftest.$ac_ext" >&5
-eval "$as_ac_Header=no"
-fi
-rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+cf_cv_need_libssp=maybe
 fi
-echo "$as_me:18518: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
-echo "${ECHO_T}`eval echo '${'"$as_ac_Header"'}'`" >&6
-if test "`eval echo '${'"$as_ac_Header"'}'`" = yes; then
-  cat >>confdefs.h <<EOF
-#define `echo "HAVE_$ac_hdr" | $as_tr_cpp` 1
-EOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+	LIBS="$cf_save_LIBS"
 
-ac_header_dirent=$ac_hdr; break
 fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+fi
+echo "$as_me:19316: result: $cf_cv_need_libssp" >&5
+echo "${ECHO_T}$cf_cv_need_libssp" >&6
+
+if test "x$cf_cv_need_libssp" = xyes
+then
 
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in -lssp; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
+			cf_add_1lib=
+			break
+		fi
+	done
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
 done
-# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
-if test $ac_header_dirent = dirent.h; then
-  echo "$as_me:18531: checking for opendir in -ldir" >&5
-echo $ECHO_N "checking for opendir in -ldir... $ECHO_C" >&6
-if test "${ac_cv_lib_dir_opendir+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldir  $LIBS"
-cat >"conftest.$ac_ext" <<_ACEOF
-#line 18539 "configure"
+LIBS="$cf_add_libs"
+
+fi
+
+	;;
+(*)
+	;;
+esac
+
+echo "$as_me:19345: checking if -lm needed for math functions" >&5
+echo $ECHO_N "checking if -lm needed for math functions... $ECHO_C" >&6
+if test "${cf_cv_need_libm+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+	cat >"conftest.$ac_ext" <<_ACEOF
+#line 19352 "configure"
 #include "confdefs.h"
 
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char opendir ();
+		#include <stdio.h>
+		#include <stdlib.h>
+		#include <math.h>
+
 int
 main (void)
 {
-opendir ();
+double x = rand(); printf("result = %g\\n", pow(sin(x),x))
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:18558: \"$ac_link\"") >&5
+if { (eval echo "$as_me:19368: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:18561: \$? = $ac_status" >&5
+  echo "$as_me:19371: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:18564: \"$ac_try\"") >&5
+  { (eval echo "$as_me:19374: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:18567: \$? = $ac_status" >&5
+  echo "$as_me:19377: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
-  ac_cv_lib_dir_opendir=yes
+  cf_cv_need_libm=no
 else
   echo "$as_me: failed program was:" >&5
 cat "conftest.$ac_ext" >&5
-ac_cv_lib_dir_opendir=no
+cf_cv_need_libm=yes
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:18578: result: $ac_cv_lib_dir_opendir" >&5
-echo "${ECHO_T}$ac_cv_lib_dir_opendir" >&6
-if test "$ac_cv_lib_dir_opendir" = yes; then
-  LIBS="$LIBS -ldir"
 fi
+echo "$as_me:19387: result: $cf_cv_need_libm" >&5
+echo "${ECHO_T}$cf_cv_need_libm" >&6
 
-else
-  echo "$as_me:18585: checking for opendir in -lx" >&5
-echo $ECHO_N "checking for opendir in -lx... $ECHO_C" >&6
-if test "${ac_cv_lib_x_opendir+set}" = set; then
+if test "$cf_cv_need_libm" = yes
+then
+
+	cf_save_LIBS="$LIBS"
+	LIBS="$LIBS -lm"
+	echo "$as_me:19395: checking if -lm is available for math functions" >&5
+echo $ECHO_N "checking if -lm is available for math functions... $ECHO_C" >&6
+if test "${cf_cv_have_libm+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lx  $LIBS"
-cat >"conftest.$ac_ext" <<_ACEOF
-#line 18593 "configure"
+
+	cat >"conftest.$ac_ext" <<_ACEOF
+#line 19402 "configure"
 #include "confdefs.h"
 
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char opendir ();
+		#include <stdio.h>
+		#include <stdlib.h>
+		#include <math.h>
+
 int
 main (void)
 {
-opendir ();
+double x = rand(); printf("result = %g\\n", pow(sin(x),x))
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:18612: \"$ac_link\"") >&5
+if { (eval echo "$as_me:19418: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:18615: \$? = $ac_status" >&5
+  echo "$as_me:19421: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:18618: \"$ac_try\"") >&5
+  { (eval echo "$as_me:19424: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:18621: \$? = $ac_status" >&5
+  echo "$as_me:19427: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
-  ac_cv_lib_x_opendir=yes
+  cf_cv_have_libm=yes
 else
   echo "$as_me: failed program was:" >&5
 cat "conftest.$ac_ext" >&5
-ac_cv_lib_x_opendir=no
+cf_cv_have_libm=no
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
-LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:18632: result: $ac_cv_lib_x_opendir" >&5
-echo "${ECHO_T}$ac_cv_lib_x_opendir" >&6
-if test "$ac_cv_lib_x_opendir" = yes; then
-  LIBS="$LIBS -lx"
+echo "$as_me:19437: result: $cf_cv_have_libm" >&5
+echo "${ECHO_T}$cf_cv_have_libm" >&6
+	LIBS="$cf_save_LIBS"
+
+	if test "$cf_cv_have_libm" = yes
+	then
+		MATH_LIB=-lm
+	fi
+else
+	cf_cv_have_libm=yes
 fi
 
+if test "$cf_cv_have_libm" = yes
+then
+
+cat >>confdefs.h <<\EOF
+#define HAVE_MATH_FUNCS 1
+EOF
+
 fi
 
-echo "$as_me:18640: checking whether time.h and sys/time.h may both be included" >&5
+###	Checks for header files.
+echo "$as_me:19459: checking whether time.h and sys/time.h may both be included" >&5
 echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6
 if test "${ac_cv_header_time+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 18646 "configure"
+#line 19465 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/time.h>
@@ -18659,16 +19478,16 @@ return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:18662: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:19481: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:18665: \$? = $ac_status" >&5
+  echo "$as_me:19484: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:18668: \"$ac_try\"") >&5
+  { (eval echo "$as_me:19487: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:18671: \$? = $ac_status" >&5
+  echo "$as_me:19490: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_header_time=yes
 else
@@ -18678,7 +19497,7 @@ ac_cv_header_time=no
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 fi
-echo "$as_me:18681: result: $ac_cv_header_time" >&5
+echo "$as_me:19500: result: $ac_cv_header_time" >&5
 echo "${ECHO_T}$ac_cv_header_time" >&6
 if test $ac_cv_header_time = yes; then
 
@@ -18693,7 +19512,7 @@ cf_regex_libs=
 case "$host_os" in
 (mingw*)
 	# -lsystre -ltre -lintl -liconv
-	echo "$as_me:18696: checking for regcomp in -lsystre" >&5
+	echo "$as_me:19515: checking for regcomp in -lsystre" >&5
 echo $ECHO_N "checking for regcomp in -lsystre... $ECHO_C" >&6
 if test "${ac_cv_lib_systre_regcomp+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -18701,7 +19520,7 @@ else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lsystre  $LIBS"
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 18704 "configure"
+#line 19523 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -18710,7 +19529,7 @@ extern "C"
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char regcomp ();
+char regcomp (void);
 int
 main (void)
 {
@@ -18720,16 +19539,16 @@ regcomp ();
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:18723: \"$ac_link\"") >&5
+if { (eval echo "$as_me:19542: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:18726: \$? = $ac_status" >&5
+  echo "$as_me:19545: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:18729: \"$ac_try\"") >&5
+  { (eval echo "$as_me:19548: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:18732: \$? = $ac_status" >&5
+  echo "$as_me:19551: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_lib_systre_regcomp=yes
 else
@@ -18740,11 +19559,11 @@ fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:18743: result: $ac_cv_lib_systre_regcomp" >&5
+echo "$as_me:19562: result: $ac_cv_lib_systre_regcomp" >&5
 echo "${ECHO_T}$ac_cv_lib_systre_regcomp" >&6
 if test "$ac_cv_lib_systre_regcomp" = yes; then
 
-		echo "$as_me:18747: checking for libiconv_open in -liconv" >&5
+		echo "$as_me:19566: checking for libiconv_open in -liconv" >&5
 echo $ECHO_N "checking for libiconv_open in -liconv... $ECHO_C" >&6
 if test "${ac_cv_lib_iconv_libiconv_open+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -18752,7 +19571,7 @@ else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-liconv  $LIBS"
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 18755 "configure"
+#line 19574 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -18761,7 +19580,7 @@ extern "C"
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char libiconv_open ();
+char libiconv_open (void);
 int
 main (void)
 {
@@ -18771,16 +19590,16 @@ libiconv_open ();
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:18774: \"$ac_link\"") >&5
+if { (eval echo "$as_me:19593: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:18777: \$? = $ac_status" >&5
+  echo "$as_me:19596: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:18780: \"$ac_try\"") >&5
+  { (eval echo "$as_me:19599: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:18783: \$? = $ac_status" >&5
+  echo "$as_me:19602: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_lib_iconv_libiconv_open=yes
 else
@@ -18791,7 +19610,7 @@ fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:18794: result: $ac_cv_lib_iconv_libiconv_open" >&5
+echo "$as_me:19613: result: $ac_cv_lib_iconv_libiconv_open" >&5
 echo "${ECHO_T}$ac_cv_lib_iconv_libiconv_open" >&6
 if test "$ac_cv_lib_iconv_libiconv_open" = yes; then
 
@@ -18813,7 +19632,7 @@ LIBS="$cf_add_libs"
 
 fi
 
-		echo "$as_me:18816: checking for libintl_gettext in -lintl" >&5
+		echo "$as_me:19635: checking for libintl_gettext in -lintl" >&5
 echo $ECHO_N "checking for libintl_gettext in -lintl... $ECHO_C" >&6
 if test "${ac_cv_lib_intl_libintl_gettext+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -18821,7 +19640,7 @@ else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lintl  $LIBS"
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 18824 "configure"
+#line 19643 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -18830,7 +19649,7 @@ extern "C"
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char libintl_gettext ();
+char libintl_gettext (void);
 int
 main (void)
 {
@@ -18840,16 +19659,16 @@ libintl_gettext ();
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:18843: \"$ac_link\"") >&5
+if { (eval echo "$as_me:19662: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:18846: \$? = $ac_status" >&5
+  echo "$as_me:19665: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:18849: \"$ac_try\"") >&5
+  { (eval echo "$as_me:19668: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:18852: \$? = $ac_status" >&5
+  echo "$as_me:19671: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_lib_intl_libintl_gettext=yes
 else
@@ -18860,7 +19679,7 @@ fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:18863: result: $ac_cv_lib_intl_libintl_gettext" >&5
+echo "$as_me:19682: result: $ac_cv_lib_intl_libintl_gettext" >&5
 echo "${ECHO_T}$ac_cv_lib_intl_libintl_gettext" >&6
 if test "$ac_cv_lib_intl_libintl_gettext" = yes; then
 
@@ -18882,7 +19701,7 @@ LIBS="$cf_add_libs"
 
 fi
 
-		echo "$as_me:18885: checking for tre_regcomp in -ltre" >&5
+		echo "$as_me:19704: checking for tre_regcomp in -ltre" >&5
 echo $ECHO_N "checking for tre_regcomp in -ltre... $ECHO_C" >&6
 if test "${ac_cv_lib_tre_tre_regcomp+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -18890,7 +19709,7 @@ else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-ltre  $LIBS"
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 18893 "configure"
+#line 19712 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -18899,7 +19718,7 @@ extern "C"
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char tre_regcomp ();
+char tre_regcomp (void);
 int
 main (void)
 {
@@ -18909,16 +19728,16 @@ tre_regcomp ();
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:18912: \"$ac_link\"") >&5
+if { (eval echo "$as_me:19731: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:18915: \$? = $ac_status" >&5
+  echo "$as_me:19734: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:18918: \"$ac_try\"") >&5
+  { (eval echo "$as_me:19737: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:18921: \$? = $ac_status" >&5
+  echo "$as_me:19740: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_lib_tre_tre_regcomp=yes
 else
@@ -18929,7 +19748,7 @@ fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:18932: result: $ac_cv_lib_tre_tre_regcomp" >&5
+echo "$as_me:19751: result: $ac_cv_lib_tre_tre_regcomp" >&5
 echo "${ECHO_T}$ac_cv_lib_tre_tre_regcomp" >&6
 if test "$ac_cv_lib_tre_tre_regcomp" = yes; then
 
@@ -18971,7 +19790,7 @@ LIBS="$cf_add_libs"
 
 else
 
-		echo "$as_me:18974: checking for regcomp in -lgnurx" >&5
+		echo "$as_me:19793: checking for regcomp in -lgnurx" >&5
 echo $ECHO_N "checking for regcomp in -lgnurx... $ECHO_C" >&6
 if test "${ac_cv_lib_gnurx_regcomp+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -18979,7 +19798,7 @@ else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lgnurx  $LIBS"
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 18982 "configure"
+#line 19801 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -18988,7 +19807,7 @@ extern "C"
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char regcomp ();
+char regcomp (void);
 int
 main (void)
 {
@@ -18998,16 +19817,16 @@ regcomp ();
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:19001: \"$ac_link\"") >&5
+if { (eval echo "$as_me:19820: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:19004: \$? = $ac_status" >&5
+  echo "$as_me:19823: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:19007: \"$ac_try\"") >&5
+  { (eval echo "$as_me:19826: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:19010: \$? = $ac_status" >&5
+  echo "$as_me:19829: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_lib_gnurx_regcomp=yes
 else
@@ -19018,7 +19837,7 @@ fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:19021: result: $ac_cv_lib_gnurx_regcomp" >&5
+echo "$as_me:19840: result: $ac_cv_lib_gnurx_regcomp" >&5
 echo "${ECHO_T}$ac_cv_lib_gnurx_regcomp" >&6
 if test "$ac_cv_lib_gnurx_regcomp" = yes; then
 
@@ -19046,13 +19865,13 @@ fi
 	;;
 (*)
 	cf_regex_libs="regex re"
-	echo "$as_me:19049: checking for regcomp" >&5
+	echo "$as_me:19868: checking for regcomp" >&5
 echo $ECHO_N "checking for regcomp... $ECHO_C" >&6
 if test "${ac_cv_func_regcomp+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 19055 "configure"
+#line 19874 "configure"
 #include "confdefs.h"
 #define regcomp autoconf_temporary
 #include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
@@ -19083,16 +19902,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:19086: \"$ac_link\"") >&5
+if { (eval echo "$as_me:19905: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:19089: \$? = $ac_status" >&5
+  echo "$as_me:19908: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:19092: \"$ac_try\"") >&5
+  { (eval echo "$as_me:19911: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:19095: \$? = $ac_status" >&5
+  echo "$as_me:19914: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_func_regcomp=yes
 else
@@ -19102,7 +19921,7 @@ ac_cv_func_regcomp=no
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:19105: result: $ac_cv_func_regcomp" >&5
+echo "$as_me:19924: result: $ac_cv_func_regcomp" >&5
 echo "${ECHO_T}$ac_cv_func_regcomp" >&6
 if test "$ac_cv_func_regcomp" = yes; then
   cf_regex_func=regcomp
@@ -19111,7 +19930,7 @@ else
 		for cf_regex_lib in $cf_regex_libs
 		do
 			as_ac_Lib=`echo "ac_cv_lib_$cf_regex_lib''_regcomp" | $as_tr_sh`
-echo "$as_me:19114: checking for regcomp in -l$cf_regex_lib" >&5
+echo "$as_me:19933: checking for regcomp in -l$cf_regex_lib" >&5
 echo $ECHO_N "checking for regcomp in -l$cf_regex_lib... $ECHO_C" >&6
 if eval "test \"\${$as_ac_Lib+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -19119,7 +19938,7 @@ else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-l$cf_regex_lib  $LIBS"
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 19122 "configure"
+#line 19941 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -19128,7 +19947,7 @@ extern "C"
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char regcomp ();
+char regcomp (void);
 int
 main (void)
 {
@@ -19138,16 +19957,16 @@ regcomp ();
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:19141: \"$ac_link\"") >&5
+if { (eval echo "$as_me:19960: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:19144: \$? = $ac_status" >&5
+  echo "$as_me:19963: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:19147: \"$ac_try\"") >&5
+  { (eval echo "$as_me:19966: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:19150: \$? = $ac_status" >&5
+  echo "$as_me:19969: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   eval "$as_ac_Lib=yes"
 else
@@ -19158,7 +19977,7 @@ fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:19161: result: `eval echo '${'"$as_ac_Lib"'}'`" >&5
+echo "$as_me:19980: result: `eval echo '${'"$as_ac_Lib"'}'`" >&5
 echo "${ECHO_T}`eval echo '${'"$as_ac_Lib"'}'`" >&6
 if test "`eval echo '${'"$as_ac_Lib"'}'`" = yes; then
 
@@ -19190,13 +20009,13 @@ fi
 esac
 
 if test "$cf_regex_func" = no ; then
-	echo "$as_me:19193: checking for compile" >&5
+	echo "$as_me:20012: checking for compile" >&5
 echo $ECHO_N "checking for compile... $ECHO_C" >&6
 if test "${ac_cv_func_compile+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 19199 "configure"
+#line 20018 "configure"
 #include "confdefs.h"
 #define compile autoconf_temporary
 #include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
@@ -19227,16 +20046,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:19230: \"$ac_link\"") >&5
+if { (eval echo "$as_me:20049: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:19233: \$? = $ac_status" >&5
+  echo "$as_me:20052: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:19236: \"$ac_try\"") >&5
+  { (eval echo "$as_me:20055: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:19239: \$? = $ac_status" >&5
+  echo "$as_me:20058: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_func_compile=yes
 else
@@ -19246,13 +20065,13 @@ ac_cv_func_compile=no
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:19249: result: $ac_cv_func_compile" >&5
+echo "$as_me:20068: result: $ac_cv_func_compile" >&5
 echo "${ECHO_T}$ac_cv_func_compile" >&6
 if test "$ac_cv_func_compile" = yes; then
   cf_regex_func=compile
 else
 
-		echo "$as_me:19255: checking for compile in -lgen" >&5
+		echo "$as_me:20074: checking for compile in -lgen" >&5
 echo $ECHO_N "checking for compile in -lgen... $ECHO_C" >&6
 if test "${ac_cv_lib_gen_compile+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -19260,7 +20079,7 @@ else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lgen  $LIBS"
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 19263 "configure"
+#line 20082 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -19269,7 +20088,7 @@ extern "C"
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char compile ();
+char compile (void);
 int
 main (void)
 {
@@ -19279,16 +20098,16 @@ compile ();
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:19282: \"$ac_link\"") >&5
+if { (eval echo "$as_me:20101: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:19285: \$? = $ac_status" >&5
+  echo "$as_me:20104: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:19288: \"$ac_try\"") >&5
+  { (eval echo "$as_me:20107: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:19291: \$? = $ac_status" >&5
+  echo "$as_me:20110: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_lib_gen_compile=yes
 else
@@ -19299,7 +20118,7 @@ fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:19302: result: $ac_cv_lib_gen_compile" >&5
+echo "$as_me:20121: result: $ac_cv_lib_gen_compile" >&5
 echo "${ECHO_T}$ac_cv_lib_gen_compile" >&6
 if test "$ac_cv_lib_gen_compile" = yes; then
 
@@ -19327,11 +20146,11 @@ fi
 fi
 
 if test "$cf_regex_func" = no ; then
-	{ echo "$as_me:19330: WARNING: cannot find regular expression library" >&5
+	{ echo "$as_me:20149: WARNING: cannot find regular expression library" >&5
 echo "$as_me: WARNING: cannot find regular expression library" >&2;}
 fi
 
-echo "$as_me:19334: checking for regular-expression headers" >&5
+echo "$as_me:20153: checking for regular-expression headers" >&5
 echo $ECHO_N "checking for regular-expression headers... $ECHO_C" >&6
 if test "${cf_cv_regex_hdrs+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -19343,7 +20162,7 @@ case "$cf_regex_func" in
 	for cf_regex_hdr in regexp.h regexpr.h
 	do
 		cat >"conftest.$ac_ext" <<_ACEOF
-#line 19346 "configure"
+#line 20165 "configure"
 #include "confdefs.h"
 #include <$cf_regex_hdr>
 int
@@ -19360,16 +20179,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:19363: \"$ac_link\"") >&5
+if { (eval echo "$as_me:20182: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:19366: \$? = $ac_status" >&5
+  echo "$as_me:20185: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:19369: \"$ac_try\"") >&5
+  { (eval echo "$as_me:20188: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:19372: \$? = $ac_status" >&5
+  echo "$as_me:20191: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
 
 			cf_cv_regex_hdrs=$cf_regex_hdr
@@ -19386,7 +20205,7 @@ rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 	for cf_regex_hdr in regex.h
 	do
 		cat >"conftest.$ac_ext" <<_ACEOF
-#line 19389 "configure"
+#line 20208 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <$cf_regex_hdr>
@@ -19406,16 +20225,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:19409: \"$ac_link\"") >&5
+if { (eval echo "$as_me:20228: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:19412: \$? = $ac_status" >&5
+  echo "$as_me:20231: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:19415: \"$ac_try\"") >&5
+  { (eval echo "$as_me:20234: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:19418: \$? = $ac_status" >&5
+  echo "$as_me:20237: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
 
 			cf_cv_regex_hdrs=$cf_regex_hdr
@@ -19431,11 +20250,11 @@ rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 esac
 
 fi
-echo "$as_me:19434: result: $cf_cv_regex_hdrs" >&5
+echo "$as_me:20253: result: $cf_cv_regex_hdrs" >&5
 echo "${ECHO_T}$cf_cv_regex_hdrs" >&6
 
 case "$cf_cv_regex_hdrs" in
-	(no)		{ echo "$as_me:19438: WARNING: no regular expression header found" >&5
+	(no)		{ echo "$as_me:20257: WARNING: no regular expression header found" >&5
 echo "$as_me: WARNING: no regular expression header found" >&2;} ;;
 	(regex.h)
 cat >>confdefs.h <<\EOF
@@ -19461,35 +20280,35 @@ limits.h \
 locale.h \
 math.h \
 poll.h \
+sys/auxv.h \
 sys/ioctl.h \
 sys/param.h \
 sys/poll.h \
 sys/select.h \
 sys/time.h \
 sys/times.h \
-ttyent.h \
 unistd.h \
 wctype.h \
 
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:19476: checking for $ac_header" >&5
+echo "$as_me:20295: checking for $ac_header" >&5
 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 19482 "configure"
+#line 20301 "configure"
 #include "confdefs.h"
 #include <$ac_header>
 _ACEOF
-if { (eval echo "$as_me:19486: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+if { (eval echo "$as_me:20305: \"$ac_cpp "conftest.$ac_ext"\"") >&5
   (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:19492: \$? = $ac_status" >&5
+  echo "$as_me:20311: \$? = $ac_status" >&5
   (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -19508,7 +20327,7 @@ else
 fi
 rm -f conftest.err "conftest.$ac_ext"
 fi
-echo "$as_me:19511: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
+echo "$as_me:20330: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
 echo "${ECHO_T}`eval echo '${'"$as_ac_Header"'}'`" >&6
 if test "`eval echo '${'"$as_ac_Header"'}'`" = yes; then
   cat >>confdefs.h <<EOF
@@ -19521,23 +20340,23 @@ done
 for ac_header in unistd.h getopt.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:19524: checking for $ac_header" >&5
+echo "$as_me:20343: checking for $ac_header" >&5
 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 19530 "configure"
+#line 20349 "configure"
 #include "confdefs.h"
 #include <$ac_header>
 _ACEOF
-if { (eval echo "$as_me:19534: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+if { (eval echo "$as_me:20353: \"$ac_cpp "conftest.$ac_ext"\"") >&5
   (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:19540: \$? = $ac_status" >&5
+  echo "$as_me:20359: \$? = $ac_status" >&5
   (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -19556,7 +20375,7 @@ else
 fi
 rm -f conftest.err "conftest.$ac_ext"
 fi
-echo "$as_me:19559: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
+echo "$as_me:20378: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
 echo "${ECHO_T}`eval echo '${'"$as_ac_Header"'}'`" >&6
 if test "`eval echo '${'"$as_ac_Header"'}'`" = yes; then
   cat >>confdefs.h <<EOF
@@ -19566,7 +20385,7 @@ EOF
 fi
 done
 
-echo "$as_me:19569: checking for header declaring getopt variables" >&5
+echo "$as_me:20388: checking for header declaring getopt variables" >&5
 echo $ECHO_N "checking for header declaring getopt variables... $ECHO_C" >&6
 if test "${cf_cv_getopt_header+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -19576,29 +20395,29 @@ cf_cv_getopt_header=none
 for cf_header in stdio.h stdlib.h unistd.h getopt.h
 do
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 19579 "configure"
+#line 20398 "configure"
 #include "confdefs.h"
 
 #include <$cf_header>
 int
 main (void)
 {
-int x = optind; char *y = optarg
+int x = optind; char *y = optarg; (void)x; (void)y
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:19592: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:20411: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:19595: \$? = $ac_status" >&5
+  echo "$as_me:20414: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:19598: \"$ac_try\"") >&5
+  { (eval echo "$as_me:20417: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:19601: \$? = $ac_status" >&5
+  echo "$as_me:20420: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_getopt_header=$cf_header
  break
@@ -19610,7 +20429,7 @@ rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 done
 
 fi
-echo "$as_me:19613: result: $cf_cv_getopt_header" >&5
+echo "$as_me:20432: result: $cf_cv_getopt_header" >&5
 echo "${ECHO_T}$cf_cv_getopt_header" >&6
 if test "$cf_cv_getopt_header" != none ; then
 
@@ -19627,39 +20446,36 @@ EOF
 
 fi
 
-echo "$as_me:19630: checking if external environ is declared" >&5
+echo "$as_me:20449: checking if external environ is declared" >&5
 echo $ECHO_N "checking if external environ is declared... $ECHO_C" >&6
 if test "${cf_cv_dcl_environ+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
     cat >"conftest.$ac_ext" <<_ACEOF
-#line 19637 "configure"
+#line 20456 "configure"
 #include "confdefs.h"
 
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#include <unistd.h>
+$ac_includes_default
 int
 main (void)
 {
-int x = (int) environ
+void* x = (void*) environ; (void)x
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:19653: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:20469: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:19656: \$? = $ac_status" >&5
+  echo "$as_me:20472: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:19659: \"$ac_try\"") >&5
+  { (eval echo "$as_me:20475: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:19662: \$? = $ac_status" >&5
+  echo "$as_me:20478: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_dcl_environ=yes
 else
@@ -19670,7 +20486,7 @@ fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 
 fi
-echo "$as_me:19673: result: $cf_cv_dcl_environ" >&5
+echo "$as_me:20489: result: $cf_cv_dcl_environ" >&5
 echo "${ECHO_T}$cf_cv_dcl_environ" >&6
 
 if test "$cf_cv_dcl_environ" = no ; then
@@ -19685,14 +20501,14 @@ fi
 
 # It's possible (for near-UNIX clones) that the data doesn't exist
 
-echo "$as_me:19688: checking if external environ exists" >&5
+echo "$as_me:20504: checking if external environ exists" >&5
 echo $ECHO_N "checking if external environ exists... $ECHO_C" >&6
 if test "${cf_cv_have_environ+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 19695 "configure"
+#line 20511 "configure"
 #include "confdefs.h"
 
 #undef environ
@@ -19707,16 +20523,16 @@ environ = 2
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:19710: \"$ac_link\"") >&5
+if { (eval echo "$as_me:20526: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:19713: \$? = $ac_status" >&5
+  echo "$as_me:20529: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:19716: \"$ac_try\"") >&5
+  { (eval echo "$as_me:20532: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:19719: \$? = $ac_status" >&5
+  echo "$as_me:20535: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_have_environ=yes
 else
@@ -19727,7 +20543,7 @@ fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 
 fi
-echo "$as_me:19730: result: $cf_cv_have_environ" >&5
+echo "$as_me:20546: result: $cf_cv_have_environ" >&5
 echo "${ECHO_T}$cf_cv_have_environ" >&6
 
 if test "$cf_cv_have_environ" = yes ; then
@@ -19740,13 +20556,13 @@ EOF
 
 fi
 
-echo "$as_me:19743: checking for getenv" >&5
+echo "$as_me:20559: checking for getenv" >&5
 echo $ECHO_N "checking for getenv... $ECHO_C" >&6
 if test "${ac_cv_func_getenv+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 19749 "configure"
+#line 20565 "configure"
 #include "confdefs.h"
 #define getenv autoconf_temporary
 #include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
@@ -19777,16 +20593,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:19780: \"$ac_link\"") >&5
+if { (eval echo "$as_me:20596: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:19783: \$? = $ac_status" >&5
+  echo "$as_me:20599: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:19786: \"$ac_try\"") >&5
+  { (eval echo "$as_me:20602: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:19789: \$? = $ac_status" >&5
+  echo "$as_me:20605: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_func_getenv=yes
 else
@@ -19796,19 +20612,19 @@ ac_cv_func_getenv=no
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:19799: result: $ac_cv_func_getenv" >&5
+echo "$as_me:20615: result: $ac_cv_func_getenv" >&5
 echo "${ECHO_T}$ac_cv_func_getenv" >&6
 
 for ac_func in putenv setenv strdup
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:19805: checking for $ac_func" >&5
+echo "$as_me:20621: checking for $ac_func" >&5
 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
 if eval "test \"\${$as_ac_var+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 19811 "configure"
+#line 20627 "configure"
 #include "confdefs.h"
 #define $ac_func autoconf_temporary
 #include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
@@ -19839,16 +20655,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:19842: \"$ac_link\"") >&5
+if { (eval echo "$as_me:20658: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:19845: \$? = $ac_status" >&5
+  echo "$as_me:20661: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:19848: \"$ac_try\"") >&5
+  { (eval echo "$as_me:20664: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:19851: \$? = $ac_status" >&5
+  echo "$as_me:20667: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   eval "$as_ac_var=yes"
 else
@@ -19858,7 +20674,7 @@ eval "$as_ac_var=no"
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:19861: result: `eval echo '${'"$as_ac_var"'}'`" >&5
+echo "$as_me:20677: result: `eval echo '${'"$as_ac_var"'}'`" >&5
 echo "${ECHO_T}`eval echo '${'"$as_ac_var"'}'`" >&6
 if test "`eval echo '${'"$as_ac_var"'}'`" = yes; then
   cat >>confdefs.h <<EOF
@@ -19868,7 +20684,7 @@ EOF
 fi
 done
 
-echo "$as_me:19871: checking if getenv returns consistent values" >&5
+echo "$as_me:20687: checking if getenv returns consistent values" >&5
 echo $ECHO_N "checking if getenv returns consistent values... $ECHO_C" >&6
 if test "${cf_cv_consistent_getenv+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -19878,14 +20694,10 @@ if test "$cross_compiling" = yes; then
   cf_cv_consistent_getenv=unknown
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 19881 "configure"
+#line 20697 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
+$ac_includes_default
 
 #if defined(HAVE_ENVIRON) && defined(DECL_ENVIRON) && !defined(environ)
 extern char **environ;	/* POSIX, but some systems are not... */
@@ -19951,7 +20763,7 @@ int main(void)
 				}
 			}
 		} while (found);
-		sprintf(value, "%lu:%p", (unsigned long) k, &mynames[j]);
+		sprintf(value, "%lu:%p", (unsigned long) k, (void*)&mynames[j]);
 		set_value(name, value);
 		mynames[j] = str_alloc(name);
 		myvalues[j] = str_alloc(value);
@@ -19987,15 +20799,15 @@ int main(void)
 
 _ACEOF
 rm -f "conftest$ac_exeext"
-if { (eval echo "$as_me:19990: \"$ac_link\"") >&5
+if { (eval echo "$as_me:20802: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:19993: \$? = $ac_status" >&5
+  echo "$as_me:20805: \$? = $ac_status" >&5
   (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
-  { (eval echo "$as_me:19995: \"$ac_try\"") >&5
+  { (eval echo "$as_me:20807: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:19998: \$? = $ac_status" >&5
+  echo "$as_me:20810: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_consistent_getenv=yes
 else
@@ -20008,7 +20820,7 @@ rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftes
 fi
 
 fi
-echo "$as_me:20011: result: $cf_cv_consistent_getenv" >&5
+echo "$as_me:20823: result: $cf_cv_consistent_getenv" >&5
 echo "${ECHO_T}$cf_cv_consistent_getenv" >&6
 
 if test "x$cf_cv_consistent_getenv" = xno
@@ -20023,18 +20835,18 @@ fi
 if test "x$cf_cv_consistent_getenv" = xno && \
 	test "x$cf_with_trace" = xyes
 then
-	{ echo "$as_me:20026: WARNING: The NCURSES_TRACE environment variable is not supported with this configuration" >&5
+	{ echo "$as_me:20838: WARNING: The NCURSES_TRACE environment variable is not supported with this configuration" >&5
 echo "$as_me: WARNING: The NCURSES_TRACE environment variable is not supported with this configuration" >&2;}
 fi
 
-echo "$as_me:20030: checking if sys/time.h works with sys/select.h" >&5
+echo "$as_me:20842: checking if sys/time.h works with sys/select.h" >&5
 echo $ECHO_N "checking if sys/time.h works with sys/select.h... $ECHO_C" >&6
 if test "${cf_cv_sys_time_select+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 20037 "configure"
+#line 20849 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -20054,16 +20866,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:20057: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:20869: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:20060: \$? = $ac_status" >&5
+  echo "$as_me:20872: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:20063: \"$ac_try\"") >&5
+  { (eval echo "$as_me:20875: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:20066: \$? = $ac_status" >&5
+  echo "$as_me:20878: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_sys_time_select=yes
 else
@@ -20075,7 +20887,7 @@ rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 
 fi
 
-echo "$as_me:20078: result: $cf_cv_sys_time_select" >&5
+echo "$as_me:20890: result: $cf_cv_sys_time_select" >&5
 echo "${ECHO_T}$cf_cv_sys_time_select" >&6
 test "$cf_cv_sys_time_select" = yes &&
 cat >>confdefs.h <<\EOF
@@ -20090,13 +20902,13 @@ ac_link='$CC -o "conftest$ac_exeext" $CFLAGS $CPPFLAGS $LDFLAGS "conftest.$ac_ex
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 ac_main_return="return"
 
-echo "$as_me:20093: checking for an ANSI C-conforming const" >&5
+echo "$as_me:20905: checking for an ANSI C-conforming const" >&5
 echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6
 if test "${ac_cv_c_const+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 20099 "configure"
+#line 20911 "configure"
 #include "confdefs.h"
 
 int
@@ -20106,13 +20918,13 @@ main (void)
 #ifndef __cplusplus
   /* Ultrix mips cc rejects this.  */
   typedef int charset[2];
-  const charset x;
+  const charset x; (void)x;
   /* SunOS 4.1.1 cc rejects this.  */
   char const *const *ccp;
   char **p;
   /* NEC SVR4.0.2 mips cc rejects this.  */
   struct point {int x, y;};
-  static struct point const zero = {0,0};
+  static struct point const zero = {0,0}; (void)zero;
   /* AIX XL C 1.02.0.0 rejects this.
      It does not let you subtract one const X* pointer from another in
      an arm of an if-expression whose if-part is not a constant
@@ -20128,16 +20940,19 @@ main (void)
     char const *s = 0 ? (char *) 0 : (char const *) 0;
 
     *t++ = 0;
+	(void)s;
   }
   { /* Someone thinks the Sun supposedly-ANSI compiler will reject this.  */
     int x[] = {25, 17};
     const int *foo = &x[0];
     ++foo;
+	(void)foo;
   }
   { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
     typedef const int *iptr;
     iptr p = 0;
     ++p;
+	(void)p;
   }
   { /* AIX XL C 1.02.0.0 rejects this saying
        "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
@@ -20146,6 +20961,7 @@ main (void)
   }
   { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
     const int foo = 10;
+	(void)foo;
   }
 #endif
 
@@ -20154,16 +20970,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:20157: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:20973: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:20160: \$? = $ac_status" >&5
+  echo "$as_me:20976: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:20163: \"$ac_try\"") >&5
+  { (eval echo "$as_me:20979: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:20166: \$? = $ac_status" >&5
+  echo "$as_me:20982: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_c_const=yes
 else
@@ -20173,7 +20989,7 @@ ac_cv_c_const=no
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 fi
-echo "$as_me:20176: result: $ac_cv_c_const" >&5
+echo "$as_me:20992: result: $ac_cv_c_const" >&5
 echo "${ECHO_T}$ac_cv_c_const" >&6
 if test $ac_cv_c_const = no; then
 
@@ -20183,7 +20999,7 @@ EOF
 
 fi
 
-echo "$as_me:20186: checking for inline" >&5
+echo "$as_me:21002: checking for inline" >&5
 echo $ECHO_N "checking for inline... $ECHO_C" >&6
 if test "${ac_cv_c_inline+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -20191,25 +21007,25 @@ else
   ac_cv_c_inline=no
 for ac_kw in inline __inline__ __inline; do
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 20194 "configure"
+#line 21010 "configure"
 #include "confdefs.h"
 #ifndef __cplusplus
-static $ac_kw int static_foo () {return 0; }
-$ac_kw int foo () {return 0; }
+static $ac_kw int static_foo (void) {return 0; }
+$ac_kw int foo (void) {return 0; }
 #endif
 
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:20203: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:21019: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:20206: \$? = $ac_status" >&5
+  echo "$as_me:21022: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:20209: \"$ac_try\"") >&5
+  { (eval echo "$as_me:21025: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:20212: \$? = $ac_status" >&5
+  echo "$as_me:21028: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_c_inline=$ac_kw; break
 else
@@ -20220,7 +21036,7 @@ rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 done
 
 fi
-echo "$as_me:20223: result: $ac_cv_c_inline" >&5
+echo "$as_me:21039: result: $ac_cv_c_inline" >&5
 echo "${ECHO_T}$ac_cv_c_inline" >&6
 case $ac_cv_c_inline in
   inline | yes) ;;
@@ -20246,7 +21062,7 @@ if test "$ac_cv_c_inline" != no ; then
 		:
 	elif test "$GCC" = yes
 	then
-		echo "$as_me:20249: checking if $CC supports options to tune inlining" >&5
+		echo "$as_me:21065: checking if $CC supports options to tune inlining" >&5
 echo $ECHO_N "checking if $CC supports options to tune inlining... $ECHO_C" >&6
 if test "${cf_cv_gcc_inline+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -20255,7 +21071,7 @@ else
 		cf_save_CFLAGS=$CFLAGS
 		CFLAGS="$CFLAGS --param max-inline-insns-single=1200"
 		cat >"conftest.$ac_ext" <<_ACEOF
-#line 20258 "configure"
+#line 21074 "configure"
 #include "confdefs.h"
 inline int foo(void) { return 1; }
 int
@@ -20267,16 +21083,16 @@ ${cf_cv_main_return:-return} foo()
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:20270: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:21086: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:20273: \$? = $ac_status" >&5
+  echo "$as_me:21089: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:20276: \"$ac_try\"") >&5
+  { (eval echo "$as_me:21092: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:20279: \$? = $ac_status" >&5
+  echo "$as_me:21095: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_gcc_inline=yes
 else
@@ -20288,7 +21104,7 @@ rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 		CFLAGS=$cf_save_CFLAGS
 
 fi
-echo "$as_me:20291: result: $cf_cv_gcc_inline" >&5
+echo "$as_me:21107: result: $cf_cv_gcc_inline" >&5
 echo "${ECHO_T}$cf_cv_gcc_inline" >&6
 		if test "$cf_cv_gcc_inline" = yes ; then
 
@@ -20394,7 +21210,7 @@ fi
 	fi
 fi
 
-echo "$as_me:20397: checking for signal global datatype" >&5
+echo "$as_me:21213: checking for signal global datatype" >&5
 echo $ECHO_N "checking for signal global datatype... $ECHO_C" >&6
 if test "${cf_cv_sig_atomic_t+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -20406,7 +21222,7 @@ else
 		"int"
 	do
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 20409 "configure"
+#line 21225 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -20430,16 +21246,16 @@ signal(SIGINT, handler);
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:20433: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:21249: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:20436: \$? = $ac_status" >&5
+  echo "$as_me:21252: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:20439: \"$ac_try\"") >&5
+  { (eval echo "$as_me:21255: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:20442: \$? = $ac_status" >&5
+  echo "$as_me:21258: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_sig_atomic_t=$cf_type
 else
@@ -20453,7 +21269,7 @@ rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 
 fi
 
-echo "$as_me:20456: result: $cf_cv_sig_atomic_t" >&5
+echo "$as_me:21272: result: $cf_cv_sig_atomic_t" >&5
 echo "${ECHO_T}$cf_cv_sig_atomic_t" >&6
 test "$cf_cv_sig_atomic_t" != no &&
 cat >>confdefs.h <<EOF
@@ -20462,7 +21278,7 @@ EOF
 
 if test "$NCURSES_CHTYPE" = auto ; then
 
-echo "$as_me:20465: checking for type of chtype" >&5
+echo "$as_me:21281: checking for type of chtype" >&5
 echo $ECHO_N "checking for type of chtype... $ECHO_C" >&6
 if test "${cf_cv_typeof_chtype+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -20472,11 +21288,11 @@ else
   cf_cv_typeof_chtype=long
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 20475 "configure"
+#line 21291 "configure"
 #include "confdefs.h"
 
+$ac_includes_default
 #define WANT_BITS 31
-#include <stdio.h>
 int main(void)
 {
 	FILE *fp = fopen("cf_test.out", "w");
@@ -20507,15 +21323,15 @@ int main(void)
 
 _ACEOF
 rm -f "conftest$ac_exeext"
-if { (eval echo "$as_me:20510: \"$ac_link\"") >&5
+if { (eval echo "$as_me:21326: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:20513: \$? = $ac_status" >&5
+  echo "$as_me:21329: \$? = $ac_status" >&5
   (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
-  { (eval echo "$as_me:20515: \"$ac_try\"") >&5
+  { (eval echo "$as_me:21331: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:20518: \$? = $ac_status" >&5
+  echo "$as_me:21334: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_typeof_chtype=`cat cf_test.out`
 else
@@ -20530,7 +21346,7 @@ fi
 
 fi
 
-echo "$as_me:20533: result: $cf_cv_typeof_chtype" >&5
+echo "$as_me:21349: result: $cf_cv_typeof_chtype" >&5
 echo "${ECHO_T}$cf_cv_typeof_chtype" >&6
 
 cat >>confdefs.h <<EOF
@@ -20542,35 +21358,35 @@ else
 fi
 test "$cf_cv_typeof_chtype" = unsigned && cf_cv_typeof_chtype=""
 
-echo "$as_me:20545: checking if unsigned literals are legal" >&5
+echo "$as_me:21361: checking if unsigned literals are legal" >&5
 echo $ECHO_N "checking if unsigned literals are legal... $ECHO_C" >&6
 if test "${cf_cv_unsigned_literals+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 20552 "configure"
+#line 21368 "configure"
 #include "confdefs.h"
 
 int
 main (void)
 {
-long x = 1L + 1UL + 1U + 1
+long x = 1L + 1UL + 1U + 1; (void)x
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:20564: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:21380: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:20567: \$? = $ac_status" >&5
+  echo "$as_me:21383: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:20570: \"$ac_try\"") >&5
+  { (eval echo "$as_me:21386: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:20573: \$? = $ac_status" >&5
+  echo "$as_me:21389: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_unsigned_literals=yes
 else
@@ -20582,7 +21398,7 @@ rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 
 fi
 
-echo "$as_me:20585: result: $cf_cv_unsigned_literals" >&5
+echo "$as_me:21401: result: $cf_cv_unsigned_literals" >&5
 echo "${ECHO_T}$cf_cv_unsigned_literals" >&6
 
 cf_cv_1UL="1"
@@ -20598,21 +21414,17 @@ test "$cf_cv_typeof_mmask_t" = unsigned && cf_cv_typeof_mmask_t=""
 
 ###	Checks for external-data
 
-echo "$as_me:20601: checking if external errno is declared" >&5
+echo "$as_me:21417: checking if external errno is declared" >&5
 echo $ECHO_N "checking if external errno is declared... $ECHO_C" >&6
 if test "${cf_cv_dcl_errno+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 20608 "configure"
+#line 21424 "configure"
 #include "confdefs.h"
 
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#include <stdio.h>
-#include <sys/types.h>
+$ac_includes_default
 #include <errno.h>
 int
 main (void)
@@ -20623,16 +21435,16 @@ int x = (int) errno; (void)x
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:20626: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:21438: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:20629: \$? = $ac_status" >&5
+  echo "$as_me:21441: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:20632: \"$ac_try\"") >&5
+  { (eval echo "$as_me:21444: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:20635: \$? = $ac_status" >&5
+  echo "$as_me:21447: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_dcl_errno=yes
 else
@@ -20643,7 +21455,7 @@ fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 
 fi
-echo "$as_me:20646: result: $cf_cv_dcl_errno" >&5
+echo "$as_me:21458: result: $cf_cv_dcl_errno" >&5
 echo "${ECHO_T}$cf_cv_dcl_errno" >&6
 
 if test "$cf_cv_dcl_errno" = no ; then
@@ -20658,14 +21470,14 @@ fi
 
 # It's possible (for near-UNIX clones) that the data doesn't exist
 
-echo "$as_me:20661: checking if external errno exists" >&5
+echo "$as_me:21473: checking if external errno exists" >&5
 echo $ECHO_N "checking if external errno exists... $ECHO_C" >&6
 if test "${cf_cv_have_errno+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 20668 "configure"
+#line 21480 "configure"
 #include "confdefs.h"
 
 #undef errno
@@ -20674,158 +21486,356 @@ extern int errno;
 int
 main (void)
 {
-errno = 2
+errno = 2
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:21495: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:21498: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:21501: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:21504: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  cf_cv_have_errno=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+cf_cv_have_errno=no
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+
+fi
+echo "$as_me:21515: result: $cf_cv_have_errno" >&5
+echo "${ECHO_T}$cf_cv_have_errno" >&6
+
+if test "$cf_cv_have_errno" = yes ; then
+
+cf_result=`echo "have_errno" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+
+	cat >>confdefs.h <<EOF
+#define $cf_result 1
+EOF
+
+fi
+
+echo "$as_me:21528: checking if data-only library module links" >&5
+echo $ECHO_N "checking if data-only library module links... $ECHO_C" >&6
+if test "${cf_cv_link_dataonly+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+	rm -f conftest.a
+	cat >conftest.$ac_ext <<EOF
+#line 21536 "configure"
+int	testdata[3] = { 123, 456, 789 };
+EOF
+	if { (eval echo "$as_me:21539: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:21542: \$? = $ac_status" >&5
+  (exit "$ac_status"); } ; then
+		mv conftest.o data.o && \
+		( $AR $ARFLAGS conftest.a data.o ) 2>&5 1>/dev/null
+	fi
+	rm -f conftest.$ac_ext data.o
+	cat >conftest.$ac_ext <<EOF
+#line 21549 "configure"
+extern int testfunc(void);
+#if defined(NeXT)
+int	testfunc(void)
+{
+	${cf_cv_main_return:-return}(1);	/* I'm told this linker is broken */
+}
+#else
+extern int testdata[3];
+int	testfunc(void)
+{
+	return testdata[0] == 123
+	   &&  testdata[1] == 456
+	   &&  testdata[2] == 789;
+}
+#endif
+EOF
+	if { (eval echo "$as_me:21566: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:21569: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; then
+		mv conftest.o func.o && \
+		( $AR $ARFLAGS conftest.a func.o ) 2>&5 1>/dev/null
+	fi
+	rm -f conftest.$ac_ext func.o
+	( eval $RANLIB conftest.a ) 2>&5 >/dev/null
+	cf_saveLIBS="$LIBS"
+	LIBS="conftest.a $LIBS"
+	if test "$cross_compiling" = yes; then
+  cf_cv_link_dataonly=unknown
+else
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 21582 "configure"
+#include "confdefs.h"
+
+	extern int testfunc(void);
+	int main(void)
+	{
+		${cf_cv_main_return:-return} (!testfunc());
+	}
+
+_ACEOF
+rm -f "conftest$ac_exeext"
+if { (eval echo "$as_me:21593: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:21596: \$? = $ac_status" >&5
+  (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
+  { (eval echo "$as_me:21598: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:21601: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  cf_cv_link_dataonly=yes
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+cf_cv_link_dataonly=no
+fi
+rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftest.$ac_ext"
+fi
+	LIBS="$cf_saveLIBS"
+
+fi
+
+echo "$as_me:21616: result: $cf_cv_link_dataonly" >&5
+echo "${ECHO_T}$cf_cv_link_dataonly" >&6
+
+if test "$cf_cv_link_dataonly" = no ; then
+
+cat >>confdefs.h <<\EOF
+#define BROKEN_LINKER 1
+EOF
+
+	BROKEN_LINKER=1
+fi
+
+###	Checks for library functions.
+
+echo "$as_me:21630: checking for clock_gettime" >&5
+echo $ECHO_N "checking for clock_gettime... $ECHO_C" >&6
+if test "${cf_cv_func_clock_gettime+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+		cat >"conftest.$ac_ext" <<_ACEOF
+#line 21637 "configure"
+#include "confdefs.h"
+#include <time.h>
+int
+main (void)
+{
+struct timespec ts;
+		int rc = clock_gettime(CLOCK_REALTIME, &ts); (void) rc; (void)ts
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:21650: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:21653: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:21656: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:21659: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  cf_cv_func_clock_gettime=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+cf_cv_func_clock_gettime=no
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+
+fi
+echo "$as_me:21670: result: $cf_cv_func_clock_gettime" >&5
+echo "${ECHO_T}$cf_cv_func_clock_gettime" >&6
+
+if test "$cf_cv_func_clock_gettime" = yes
+then
+
+cat >>confdefs.h <<\EOF
+#define HAVE_CLOCK_GETTIME 1
+EOF
+
+else
+echo "$as_me:21681: checking for gettimeofday" >&5
+echo $ECHO_N "checking for gettimeofday... $ECHO_C" >&6
+if test "${ac_cv_func_gettimeofday+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 21687 "configure"
+#include "confdefs.h"
+#define gettimeofday autoconf_temporary
+#include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
+#undef gettimeofday
+
+#ifdef __cplusplus
+extern "C"
+#endif
+
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char gettimeofday (void);
+
+int
+main (void)
+{
+
+/* The GNU C library defines stubs for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_gettimeofday) || defined (__stub___gettimeofday)
+#error found stub for gettimeofday
+#endif
+
+	return gettimeofday ();
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:20683: \"$ac_link\"") >&5
+if { (eval echo "$as_me:21718: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:20686: \$? = $ac_status" >&5
+  echo "$as_me:21721: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:20689: \"$ac_try\"") >&5
+  { (eval echo "$as_me:21724: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:20692: \$? = $ac_status" >&5
+  echo "$as_me:21727: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
-  cf_cv_have_errno=yes
+  ac_cv_func_gettimeofday=yes
 else
   echo "$as_me: failed program was:" >&5
 cat "conftest.$ac_ext" >&5
-cf_cv_have_errno=no
+ac_cv_func_gettimeofday=no
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
-
 fi
-echo "$as_me:20703: result: $cf_cv_have_errno" >&5
-echo "${ECHO_T}$cf_cv_have_errno" >&6
-
-if test "$cf_cv_have_errno" = yes ; then
-
-cf_result=`echo "have_errno" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+echo "$as_me:21737: result: $ac_cv_func_gettimeofday" >&5
+echo "${ECHO_T}$ac_cv_func_gettimeofday" >&6
+if test "$ac_cv_func_gettimeofday" = yes; then
 
-	cat >>confdefs.h <<EOF
-#define $cf_result 1
+cat >>confdefs.h <<\EOF
+#define HAVE_GETTIMEOFDAY 1
 EOF
 
-fi
+else
 
-echo "$as_me:20716: checking if data-only library module links" >&5
-echo $ECHO_N "checking if data-only library module links... $ECHO_C" >&6
-if test "${cf_cv_link_dataonly+set}" = set; then
+echo "$as_me:21747: checking for gettimeofday in -lbsd" >&5
+echo $ECHO_N "checking for gettimeofday in -lbsd... $ECHO_C" >&6
+if test "${ac_cv_lib_bsd_gettimeofday+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lbsd  $LIBS"
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 21755 "configure"
+#include "confdefs.h"
 
-	rm -f conftest.a
-	cat >conftest.$ac_ext <<EOF
-#line 20724 "configure"
-int	testdata[3] = { 123, 456, 789 };
-EOF
-	if { (eval echo "$as_me:20727: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:20730: \$? = $ac_status" >&5
-  (exit "$ac_status"); } ; then
-		mv conftest.o data.o && \
-		( $AR $ARFLAGS conftest.a data.o ) 2>&5 1>/dev/null
-	fi
-	rm -f conftest.$ac_ext data.o
-	cat >conftest.$ac_ext <<EOF
-#line 20737 "configure"
-int	testfunc(void)
-{
-#if defined(NeXT)
-	${cf_cv_main_return:-return}(1);	/* I'm told this linker is broken */
-#else
-	extern int testdata[3];
-	return testdata[0] == 123
-	   &&  testdata[1] == 456
-	   &&  testdata[2] == 789;
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
 #endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char gettimeofday (void);
+int
+main (void)
+{
+gettimeofday ();
+  ;
+  return 0;
 }
-EOF
-	if { (eval echo "$as_me:20750: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:20753: \$? = $ac_status" >&5
-  (exit "$ac_status"); }; then
-		mv conftest.o func.o && \
-		( $AR $ARFLAGS conftest.a func.o ) 2>&5 1>/dev/null
-	fi
-	rm -f conftest.$ac_ext func.o
-	( eval $RANLIB conftest.a ) 2>&5 >/dev/null
-	cf_saveLIBS="$LIBS"
-	LIBS="conftest.a $LIBS"
-	if test "$cross_compiling" = yes; then
-  cf_cv_link_dataonly=unknown
-else
-  cat >"conftest.$ac_ext" <<_ACEOF
-#line 20766 "configure"
-#include "confdefs.h"
-
-	int main(void)
-	{
-		extern int testfunc();
-		${cf_cv_main_return:-return} (!testfunc());
-	}
-
 _ACEOF
-rm -f "conftest$ac_exeext"
-if { (eval echo "$as_me:20777: \"$ac_link\"") >&5
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:21774: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:20780: \$? = $ac_status" >&5
-  (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
-  { (eval echo "$as_me:20782: \"$ac_try\"") >&5
+  echo "$as_me:21777: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:21780: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:20785: \$? = $ac_status" >&5
+  echo "$as_me:21783: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
-  cf_cv_link_dataonly=yes
+  ac_cv_lib_bsd_gettimeofday=yes
 else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
+  echo "$as_me: failed program was:" >&5
 cat "conftest.$ac_ext" >&5
-cf_cv_link_dataonly=no
-fi
-rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftest.$ac_ext"
+ac_cv_lib_bsd_gettimeofday=no
 fi
-	LIBS="$cf_saveLIBS"
-
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+LIBS=$ac_check_lib_save_LIBS
 fi
-
-echo "$as_me:20800: result: $cf_cv_link_dataonly" >&5
-echo "${ECHO_T}$cf_cv_link_dataonly" >&6
-
-if test "$cf_cv_link_dataonly" = no ; then
+echo "$as_me:21794: result: $ac_cv_lib_bsd_gettimeofday" >&5
+echo "${ECHO_T}$ac_cv_lib_bsd_gettimeofday" >&6
+if test "$ac_cv_lib_bsd_gettimeofday" = yes; then
 
 cat >>confdefs.h <<\EOF
-#define BROKEN_LINKER 1
+#define HAVE_GETTIMEOFDAY 1
 EOF
 
-	BROKEN_LINKER=1
+cf_add_libs="$LIBS"
+# reverse order
+cf_add_0lib=
+for cf_add_1lib in -lbsd; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
+# filter duplicates
+for cf_add_1lib in $cf_add_0lib; do
+	for cf_add_2lib in $cf_add_libs; do
+		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
+			cf_add_1lib=
+			break
+		fi
+	done
+	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
+done
+LIBS="$cf_add_libs"
+
 fi
 
-###	Checks for library functions.
+fi
+fi
 
 for ac_func in \
+fpathconf \
 getcwd \
+getauxval \
 getegid \
 geteuid \
 getopt \
-getttynam \
+getuid \
 issetugid \
 localeconv \
 poll \
-putenv \
 remove \
 select \
 setbuf \
 setbuffer \
-setenv \
+setfsuid \
 setvbuf \
 sigaction \
 sigvec \
@@ -20840,13 +21850,13 @@ vsnprintf \
 
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:20843: checking for $ac_func" >&5
+echo "$as_me:21853: checking for $ac_func" >&5
 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
 if eval "test \"\${$as_ac_var+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 20849 "configure"
+#line 21859 "configure"
 #include "confdefs.h"
 #define $ac_func autoconf_temporary
 #include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
@@ -20877,16 +21887,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:20880: \"$ac_link\"") >&5
+if { (eval echo "$as_me:21890: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:20883: \$? = $ac_status" >&5
+  echo "$as_me:21893: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:20886: \"$ac_try\"") >&5
+  { (eval echo "$as_me:21896: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:20889: \$? = $ac_status" >&5
+  echo "$as_me:21899: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   eval "$as_ac_var=yes"
 else
@@ -20896,7 +21906,7 @@ eval "$as_ac_var=no"
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:20899: result: `eval echo '${'"$as_ac_var"'}'`" >&5
+echo "$as_me:21909: result: `eval echo '${'"$as_ac_var"'}'`" >&5
 echo "${ECHO_T}`eval echo '${'"$as_ac_var"'}'`" >&6
 if test "`eval echo '${'"$as_ac_var"'}'`" = yes; then
   cat >>confdefs.h <<EOF
@@ -20906,9 +21916,173 @@ EOF
 fi
 done
 
+echo "$as_me:21919: checking if _PATH_TTYS is defined in ttyent.h" >&5
+echo $ECHO_N "checking if _PATH_TTYS is defined in ttyent.h... $ECHO_C" >&6
+if test "${cf_cv_PATH_TTYS+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 21926 "configure"
+#include "confdefs.h"
+
+#include <stdio.h>
+#include <ttyent.h>
+int
+main (void)
+{
+
+FILE *fp = fopen(_PATH_TTYS, "r"); (void)fp
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:21941: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:21944: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:21947: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:21950: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  cf_cv_PATH_TTYS=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+cf_cv_PATH_TTYS=no
+fi
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+fi
+echo "$as_me:21960: result: $cf_cv_PATH_TTYS" >&5
+echo "${ECHO_T}$cf_cv_PATH_TTYS" >&6
+
+if test $cf_cv_PATH_TTYS = no
+then
+	for cf_ttys in /etc/ttytype /etc/ttys
+	do
+		if test -f $cf_ttys
+		then
+			cf_cv_PATH_TTYS=maybe
+
+cat >>confdefs.h <<\EOF
+#define _PATH_TTYS $cf_ttys
+EOF
+
+			break
+		fi
+	done
+fi
+
+if test $cf_cv_PATH_TTYS != no
+then
+	echo "$as_me:21982: checking if _PATH_TTYS file exists" >&5
+echo $ECHO_N "checking if _PATH_TTYS file exists... $ECHO_C" >&6
+if test "${cf_cv_have_PATH_TTYS+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+		if test "$cross_compiling" = yes; then
+  cf_cv_have_PATH_TTYS=unknown
+else
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 21992 "configure"
+#include "confdefs.h"
+
+$ac_includes_default
+
+#include <ttyent.h>
+
+int main(void) {
+	FILE *fp = fopen(_PATH_TTYS, "r");
+	${cf_cv_main_return:-return} (fp == 0);
+}
+_ACEOF
+rm -f "conftest$ac_exeext"
+if { (eval echo "$as_me:22005: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:22008: \$? = $ac_status" >&5
+  (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
+  { (eval echo "$as_me:22010: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:22013: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  cf_cv_have_PATH_TTYS=yes
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+cf_cv_have_PATH_TTYS=no
+fi
+rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftest.$ac_ext"
+fi
+fi
+echo "$as_me:22025: result: $cf_cv_have_PATH_TTYS" >&5
+echo "${ECHO_T}$cf_cv_have_PATH_TTYS" >&6
+	test "$cf_cv_have_PATH_TTYS" = no && cf_cv_PATH_TTYS=no
+fi
+
+if test $cf_cv_PATH_TTYS != no
+then
+
+cat >>confdefs.h <<\EOF
+#define HAVE_PATH_TTYS 1
+EOF
+
+	echo "$as_me:22037: checking for getttynam" >&5
+echo $ECHO_N "checking for getttynam... $ECHO_C" >&6
+if test "${cf_cv_func_getttynam+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+		cat >"conftest.$ac_ext" <<_ACEOF
+#line 22044 "configure"
+#include "confdefs.h"
+#include <ttyent.h>
+int
+main (void)
+{
+struct ttyent *fp = getttynam("/dev/tty"); (void)fp
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext" "conftest$ac_exeext"
+if { (eval echo "$as_me:22056: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:22059: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest$ac_exeext"'
+  { (eval echo "$as_me:22062: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:22065: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  cf_cv_func_getttynam=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+cf_cv_func_getttynam=no
+fi
+rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
+fi
+echo "$as_me:22075: result: $cf_cv_func_getttynam" >&5
+echo "${ECHO_T}$cf_cv_func_getttynam" >&6
+	test "$cf_cv_func_getttynam" = yes && cat >>confdefs.h <<\EOF
+#define HAVE_GETTTYNAM 1
+EOF
+
+fi
+
 if test "x$ac_cv_func_getopt" = xno && \
    test "x$cf_with_progs$cf_with_tests" != xnono; then
-	{ { echo "$as_me:20911: error: getopt is required for building programs" >&5
+	{ { echo "$as_me:22085: error: getopt is required for building programs" >&5
 echo "$as_me: error: getopt is required for building programs" >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -20917,7 +22091,7 @@ if test "x$with_safe_sprintf" = xyes
 then
 	if test "x$ac_cv_func_vsnprintf" = xyes
 	then
-		{ echo "$as_me:20920: WARNING: will use vsnprintf instead of safe-sprintf option" >&5
+		{ echo "$as_me:22094: WARNING: will use vsnprintf instead of safe-sprintf option" >&5
 echo "$as_me: WARNING: will use vsnprintf instead of safe-sprintf option" >&2;}
 	else
 
@@ -20930,17 +22104,17 @@ fi
 
 if test "x$with_getcap" = "xyes" ; then
 
-echo "$as_me:20933: checking for terminal-capability database functions" >&5
+echo "$as_me:22107: checking for terminal-capability database functions" >&5
 echo $ECHO_N "checking for terminal-capability database functions... $ECHO_C" >&6
 if test "${cf_cv_cgetent+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 20940 "configure"
+#line 22114 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
+$ac_includes_default
 int
 main (void)
 {
@@ -20957,16 +22131,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:20960: \"$ac_link\"") >&5
+if { (eval echo "$as_me:22134: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:20963: \$? = $ac_status" >&5
+  echo "$as_me:22137: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:20966: \"$ac_try\"") >&5
+  { (eval echo "$as_me:22140: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:20969: \$? = $ac_status" >&5
+  echo "$as_me:22143: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_cgetent=yes
 else
@@ -20977,7 +22151,7 @@ fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 
 fi
-echo "$as_me:20980: result: $cf_cv_cgetent" >&5
+echo "$as_me:22154: result: $cf_cv_cgetent" >&5
 echo "${ECHO_T}$cf_cv_cgetent" >&6
 
 if test "$cf_cv_cgetent" = yes
@@ -20987,18 +22161,18 @@ cat >>confdefs.h <<\EOF
 #define HAVE_BSD_CGETENT 1
 EOF
 
-echo "$as_me:20990: checking if cgetent uses const parameter" >&5
+echo "$as_me:22164: checking if cgetent uses const parameter" >&5
 echo $ECHO_N "checking if cgetent uses const parameter... $ECHO_C" >&6
 if test "${cf_cv_cgetent_const+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 20997 "configure"
+#line 22171 "configure"
 #include "confdefs.h"
 
 #pragma GCC diagnostic error "-Wincompatible-pointer-types-discards-qualifiers"
-#include <stdlib.h>
+$ac_includes_default
 int
 main (void)
 {
@@ -21017,16 +22191,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:21020: \"$ac_link\"") >&5
+if { (eval echo "$as_me:22194: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:21023: \$? = $ac_status" >&5
+  echo "$as_me:22197: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:21026: \"$ac_try\"") >&5
+  { (eval echo "$as_me:22200: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:21029: \$? = $ac_status" >&5
+  echo "$as_me:22203: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_cgetent_const=yes
 else
@@ -21037,7 +22211,7 @@ fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 
 fi
-echo "$as_me:21040: result: $cf_cv_cgetent_const" >&5
+echo "$as_me:22214: result: $cf_cv_cgetent_const" >&5
 echo "${ECHO_T}$cf_cv_cgetent_const" >&6
 	if test "$cf_cv_cgetent_const" = yes
 	then
@@ -21051,35 +22225,35 @@ fi
 
 fi
 
-echo "$as_me:21054: checking for isascii" >&5
+echo "$as_me:22228: checking for isascii" >&5
 echo $ECHO_N "checking for isascii... $ECHO_C" >&6
 if test "${cf_cv_have_isascii+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 21061 "configure"
+#line 22235 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 int
 main (void)
 {
-int x = isascii(' ')
+int x = isascii(' '); (void)x
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:21073: \"$ac_link\"") >&5
+if { (eval echo "$as_me:22247: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:21076: \$? = $ac_status" >&5
+  echo "$as_me:22250: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:21079: \"$ac_try\"") >&5
+  { (eval echo "$as_me:22253: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:21082: \$? = $ac_status" >&5
+  echo "$as_me:22256: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_have_isascii=yes
 else
@@ -21090,7 +22264,7 @@ fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 
 fi
-echo "$as_me:21093: result: $cf_cv_have_isascii" >&5
+echo "$as_me:22267: result: $cf_cv_have_isascii" >&5
 echo "${ECHO_T}$cf_cv_have_isascii" >&6
 test "$cf_cv_have_isascii" = yes &&
 cat >>confdefs.h <<\EOF
@@ -21098,10 +22272,10 @@ cat >>confdefs.h <<\EOF
 EOF
 
 if test "$ac_cv_func_sigaction" = yes; then
-echo "$as_me:21101: checking whether sigaction needs _POSIX_SOURCE" >&5
+echo "$as_me:22275: checking whether sigaction needs _POSIX_SOURCE" >&5
 echo $ECHO_N "checking whether sigaction needs _POSIX_SOURCE... $ECHO_C" >&6
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 21104 "configure"
+#line 22278 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -21109,22 +22283,22 @@ cat >"conftest.$ac_ext" <<_ACEOF
 int
 main (void)
 {
-struct sigaction act
+struct sigaction act; (void)act
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:21118: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:22292: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:21121: \$? = $ac_status" >&5
+  echo "$as_me:22295: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:21124: \"$ac_try\"") >&5
+  { (eval echo "$as_me:22298: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:21127: \$? = $ac_status" >&5
+  echo "$as_me:22301: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   sigact_bad=no
 else
@@ -21132,7 +22306,7 @@ else
 cat "conftest.$ac_ext" >&5
 
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 21135 "configure"
+#line 22309 "configure"
 #include "confdefs.h"
 
 #define _POSIX_SOURCE
@@ -21141,22 +22315,22 @@ cat >"conftest.$ac_ext" <<_ACEOF
 int
 main (void)
 {
-struct sigaction act
+struct sigaction act; (void)act
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:21150: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:22324: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:21153: \$? = $ac_status" >&5
+  echo "$as_me:22327: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:21156: \"$ac_try\"") >&5
+  { (eval echo "$as_me:22330: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:21159: \$? = $ac_status" >&5
+  echo "$as_me:22333: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   sigact_bad=yes
 
@@ -21172,11 +22346,11 @@ fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
-echo "$as_me:21175: result: $sigact_bad" >&5
+echo "$as_me:22349: result: $sigact_bad" >&5
 echo "${ECHO_T}$sigact_bad" >&6
 fi
 
-echo "$as_me:21179: checking if nanosleep really works" >&5
+echo "$as_me:22353: checking if nanosleep really works" >&5
 echo $ECHO_N "checking if nanosleep really works... $ECHO_C" >&6
 if test "${cf_cv_func_nanosleep+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -21186,10 +22360,11 @@ if test "$cross_compiling" = yes; then
   cf_cv_func_nanosleep=unknown
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 21189 "configure"
+#line 22363 "configure"
 #include "confdefs.h"
 
-#include <stdio.h>
+$ac_includes_default
+
 #include <errno.h>
 #include <time.h>
 
@@ -21211,15 +22386,15 @@ int main(void) {
 
 _ACEOF
 rm -f "conftest$ac_exeext"
-if { (eval echo "$as_me:21214: \"$ac_link\"") >&5
+if { (eval echo "$as_me:22389: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:21217: \$? = $ac_status" >&5
+  echo "$as_me:22392: \$? = $ac_status" >&5
   (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
-  { (eval echo "$as_me:21219: \"$ac_try\"") >&5
+  { (eval echo "$as_me:22394: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:21222: \$? = $ac_status" >&5
+  echo "$as_me:22397: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_func_nanosleep=yes
 else
@@ -21231,7 +22406,7 @@ fi
 rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftest.$ac_ext"
 fi
 fi
-echo "$as_me:21234: result: $cf_cv_func_nanosleep" >&5
+echo "$as_me:22409: result: $cf_cv_func_nanosleep" >&5
 echo "${ECHO_T}$cf_cv_func_nanosleep" >&6
 
 test "$cf_cv_func_nanosleep" = "yes" &&
@@ -21248,23 +22423,23 @@ sys/termio.h \
 
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:21251: checking for $ac_header" >&5
+echo "$as_me:22426: checking for $ac_header" >&5
 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 21257 "configure"
+#line 22432 "configure"
 #include "confdefs.h"
 #include <$ac_header>
 _ACEOF
-if { (eval echo "$as_me:21261: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+if { (eval echo "$as_me:22436: \"$ac_cpp "conftest.$ac_ext"\"") >&5
   (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:21267: \$? = $ac_status" >&5
+  echo "$as_me:22442: \$? = $ac_status" >&5
   (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -21283,7 +22458,7 @@ else
 fi
 rm -f conftest.err "conftest.$ac_ext"
 fi
-echo "$as_me:21286: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
+echo "$as_me:22461: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
 echo "${ECHO_T}`eval echo '${'"$as_ac_Header"'}'`" >&6
 if test "`eval echo '${'"$as_ac_Header"'}'`" = yes; then
   cat >>confdefs.h <<EOF
@@ -21300,31 +22475,31 @@ if test "$ac_cv_header_termios_h" = yes ; then
 	(*)	termios_bad=maybe ;;
 	esac
 	if test "$termios_bad" = maybe ; then
-	echo "$as_me:21303: checking whether termios.h needs _POSIX_SOURCE" >&5
+	echo "$as_me:22478: checking whether termios.h needs _POSIX_SOURCE" >&5
 echo $ECHO_N "checking whether termios.h needs _POSIX_SOURCE... $ECHO_C" >&6
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 21306 "configure"
+#line 22481 "configure"
 #include "confdefs.h"
 #include <termios.h>
 int
 main (void)
 {
-struct termios foo; int x = foo.c_iflag = 1; (void)x
+struct termios foo; int x = (int)(foo.c_iflag = 1); (void)x
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:21318: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:22493: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:21321: \$? = $ac_status" >&5
+  echo "$as_me:22496: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:21324: \"$ac_try\"") >&5
+  { (eval echo "$as_me:22499: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:21327: \$? = $ac_status" >&5
+  echo "$as_me:22502: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   termios_bad=no
 else
@@ -21332,7 +22507,7 @@ else
 cat "conftest.$ac_ext" >&5
 
 		cat >"conftest.$ac_ext" <<_ACEOF
-#line 21335 "configure"
+#line 22510 "configure"
 #include "confdefs.h"
 
 #define _POSIX_SOURCE
@@ -21340,22 +22515,22 @@ cat "conftest.$ac_ext" >&5
 int
 main (void)
 {
-struct termios foo; int x = foo.c_iflag = 2; (void)x
+struct termios foo; int x = (int)(foo.c_iflag = 2); (void)x
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:21349: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:22524: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:21352: \$? = $ac_status" >&5
+  echo "$as_me:22527: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:21355: \"$ac_try\"") >&5
+  { (eval echo "$as_me:22530: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:21358: \$? = $ac_status" >&5
+  echo "$as_me:22533: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   termios_bad=unknown
 else
@@ -21371,19 +22546,19 @@ rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
-	echo "$as_me:21374: result: $termios_bad" >&5
+	echo "$as_me:22549: result: $termios_bad" >&5
 echo "${ECHO_T}$termios_bad" >&6
 	fi
 fi
 
-echo "$as_me:21379: checking for tcgetattr" >&5
+echo "$as_me:22554: checking for tcgetattr" >&5
 echo $ECHO_N "checking for tcgetattr... $ECHO_C" >&6
 if test "${cf_cv_have_tcgetattr+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 21386 "configure"
+#line 22561 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -21411,16 +22586,16 @@ tcgetattr(1, &foo);
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:21414: \"$ac_link\"") >&5
+if { (eval echo "$as_me:22589: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:21417: \$? = $ac_status" >&5
+  echo "$as_me:22592: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:21420: \"$ac_try\"") >&5
+  { (eval echo "$as_me:22595: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:21423: \$? = $ac_status" >&5
+  echo "$as_me:22598: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_have_tcgetattr=yes
 else
@@ -21430,46 +22605,56 @@ cf_cv_have_tcgetattr=no
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:21433: result: $cf_cv_have_tcgetattr" >&5
+echo "$as_me:22608: result: $cf_cv_have_tcgetattr" >&5
 echo "${ECHO_T}$cf_cv_have_tcgetattr" >&6
 test "$cf_cv_have_tcgetattr" = yes &&
 cat >>confdefs.h <<\EOF
 #define HAVE_TCGETATTR 1
 EOF
 
-echo "$as_me:21440: checking for vsscanf function or workaround" >&5
+echo "$as_me:22615: checking for vsscanf function or workaround" >&5
 echo $ECHO_N "checking for vsscanf function or workaround... $ECHO_C" >&6
 if test "${cf_cv_func_vsscanf+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 21447 "configure"
+#line 22622 "configure"
 #include "confdefs.h"
 
 #include <stdarg.h>
 #include <stdio.h>
+
+static void
+myfunc(const char *str, const char *fmt, ...)
+{
+	va_list ap;
+	va_start(ap, fmt);
+	vsscanf(str, fmt, ap);
+	va_end(ap);
+}
+
 int
 main (void)
 {
 
-	va_list ap;
-	vsscanf("from", "%d", ap)
+	myfunc("55", "%d");
+
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:21463: \"$ac_link\"") >&5
+if { (eval echo "$as_me:22648: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:21466: \$? = $ac_status" >&5
+  echo "$as_me:22651: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:21469: \"$ac_try\"") >&5
+  { (eval echo "$as_me:22654: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:21472: \$? = $ac_status" >&5
+  echo "$as_me:22657: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_func_vsscanf=vsscanf
 else
@@ -21477,7 +22662,7 @@ else
 cat "conftest.$ac_ext" >&5
 
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 21480 "configure"
+#line 22665 "configure"
 #include "confdefs.h"
 
 #include <stdarg.h>
@@ -21499,16 +22684,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:21502: \"$ac_link\"") >&5
+if { (eval echo "$as_me:22687: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:21505: \$? = $ac_status" >&5
+  echo "$as_me:22690: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:21508: \"$ac_try\"") >&5
+  { (eval echo "$as_me:22693: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:21511: \$? = $ac_status" >&5
+  echo "$as_me:22696: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_func_vsscanf=vfscanf
 else
@@ -21516,7 +22701,7 @@ else
 cat "conftest.$ac_ext" >&5
 
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 21519 "configure"
+#line 22704 "configure"
 #include "confdefs.h"
 
 #include <stdarg.h>
@@ -21538,16 +22723,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:21541: \"$ac_link\"") >&5
+if { (eval echo "$as_me:22726: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:21544: \$? = $ac_status" >&5
+  echo "$as_me:22729: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:21547: \"$ac_try\"") >&5
+  { (eval echo "$as_me:22732: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:21550: \$? = $ac_status" >&5
+  echo "$as_me:22735: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_func_vsscanf=_doscan
 else
@@ -21562,7 +22747,7 @@ rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:21565: result: $cf_cv_func_vsscanf" >&5
+echo "$as_me:22750: result: $cf_cv_func_vsscanf" >&5
 echo "${ECHO_T}$cf_cv_func_vsscanf" >&6
 
 case "$cf_cv_func_vsscanf" in
@@ -21588,23 +22773,23 @@ unistd.h \
 
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:21591: checking for $ac_header" >&5
+echo "$as_me:22776: checking for $ac_header" >&5
 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 21597 "configure"
+#line 22782 "configure"
 #include "confdefs.h"
 #include <$ac_header>
 _ACEOF
-if { (eval echo "$as_me:21601: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+if { (eval echo "$as_me:22786: \"$ac_cpp "conftest.$ac_ext"\"") >&5
   (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:21607: \$? = $ac_status" >&5
+  echo "$as_me:22792: \$? = $ac_status" >&5
   (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -21623,7 +22808,7 @@ else
 fi
 rm -f conftest.err "conftest.$ac_ext"
 fi
-echo "$as_me:21626: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
+echo "$as_me:22811: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
 echo "${ECHO_T}`eval echo '${'"$as_ac_Header"'}'`" >&6
 if test "`eval echo '${'"$as_ac_Header"'}'`" = yes; then
   cat >>confdefs.h <<EOF
@@ -21633,7 +22818,7 @@ EOF
 fi
 done
 
-echo "$as_me:21636: checking for working mkstemp" >&5
+echo "$as_me:22821: checking for working mkstemp" >&5
 echo $ECHO_N "checking for working mkstemp... $ECHO_C" >&6
 if test "${cf_cv_func_mkstemp+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -21644,20 +22829,14 @@ if test "$cross_compiling" = yes; then
   cf_cv_func_mkstemp=maybe
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 21647 "configure"
+#line 22832 "configure"
 #include "confdefs.h"
 
-#include <sys/types.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/stat.h>
+$ac_includes_default
+
 int main(void)
 {
-	char *tmpl = "conftestXXXXXX";
+	static char tmpl[] = "conftestXXXXXX";
 	char name[2][80];
 	int n;
 	int result = 0;
@@ -21685,15 +22864,15 @@ int main(void)
 
 _ACEOF
 rm -f "conftest$ac_exeext"
-if { (eval echo "$as_me:21688: \"$ac_link\"") >&5
+if { (eval echo "$as_me:22867: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:21691: \$? = $ac_status" >&5
+  echo "$as_me:22870: \$? = $ac_status" >&5
   (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
-  { (eval echo "$as_me:21693: \"$ac_try\"") >&5
+  { (eval echo "$as_me:22872: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:21696: \$? = $ac_status" >&5
+  echo "$as_me:22875: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_func_mkstemp=yes
 
@@ -21708,16 +22887,16 @@ rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftes
 fi
 
 fi
-echo "$as_me:21711: result: $cf_cv_func_mkstemp" >&5
+echo "$as_me:22890: result: $cf_cv_func_mkstemp" >&5
 echo "${ECHO_T}$cf_cv_func_mkstemp" >&6
 if test "x$cf_cv_func_mkstemp" = xmaybe ; then
-	echo "$as_me:21714: checking for mkstemp" >&5
+	echo "$as_me:22893: checking for mkstemp" >&5
 echo $ECHO_N "checking for mkstemp... $ECHO_C" >&6
 if test "${ac_cv_func_mkstemp+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 21720 "configure"
+#line 22899 "configure"
 #include "confdefs.h"
 #define mkstemp autoconf_temporary
 #include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
@@ -21748,16 +22927,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:21751: \"$ac_link\"") >&5
+if { (eval echo "$as_me:22930: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:21754: \$? = $ac_status" >&5
+  echo "$as_me:22933: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:21757: \"$ac_try\"") >&5
+  { (eval echo "$as_me:22936: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:21760: \$? = $ac_status" >&5
+  echo "$as_me:22939: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_func_mkstemp=yes
 else
@@ -21767,7 +22946,7 @@ ac_cv_func_mkstemp=no
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:21770: result: $ac_cv_func_mkstemp" >&5
+echo "$as_me:22949: result: $ac_cv_func_mkstemp" >&5
 echo "${ECHO_T}$ac_cv_func_mkstemp" >&6
 
 fi
@@ -21788,21 +22967,21 @@ else
 fi
 
 if test "x$cross_compiling" = xyes ; then
-	{ echo "$as_me:21791: WARNING: cross compiling: assume setvbuf params not reversed" >&5
+	{ echo "$as_me:22970: WARNING: cross compiling: assume setvbuf params not reversed" >&5
 echo "$as_me: WARNING: cross compiling: assume setvbuf params not reversed" >&2;}
 else
-	echo "$as_me:21794: checking whether setvbuf arguments are reversed" >&5
+	echo "$as_me:22973: checking whether setvbuf arguments are reversed" >&5
 echo $ECHO_N "checking whether setvbuf arguments are reversed... $ECHO_C" >&6
 if test "${ac_cv_func_setvbuf_reversed+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   if test "$cross_compiling" = yes; then
-  { { echo "$as_me:21800: error: cannot run test program while cross compiling" >&5
+  { { echo "$as_me:22979: error: cannot run test program while cross compiling" >&5
 echo "$as_me: error: cannot run test program while cross compiling" >&2;}
    { (exit 1); exit 1; }; }
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 21805 "configure"
+#line 22984 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 /* If setvbuf has the reversed format, exit 0. */
@@ -21815,19 +22994,19 @@ main (void)
   if (setvbuf(stdout, _IOLBF, (char *) main, BUFSIZ) != 0)
     $ac_main_return(1);
   putc('\r', stdout);
-  $ac_main_return(0);			/* Non-reversed systems segv here.  */
+  $ac_main_return(0);                   /* Non-reversed systems segv here.  */
 }
 _ACEOF
 rm -f "conftest$ac_exeext"
-if { (eval echo "$as_me:21822: \"$ac_link\"") >&5
+if { (eval echo "$as_me:23001: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:21825: \$? = $ac_status" >&5
+  echo "$as_me:23004: \$? = $ac_status" >&5
   (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
-  { (eval echo "$as_me:21827: \"$ac_try\"") >&5
+  { (eval echo "$as_me:23006: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:21830: \$? = $ac_status" >&5
+  echo "$as_me:23009: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_func_setvbuf_reversed=yes
 else
@@ -21840,7 +23019,7 @@ rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftes
 fi
 rm -f core ./core.* ./*.core
 fi
-echo "$as_me:21843: result: $ac_cv_func_setvbuf_reversed" >&5
+echo "$as_me:23022: result: $ac_cv_func_setvbuf_reversed" >&5
 echo "${ECHO_T}$ac_cv_func_setvbuf_reversed" >&6
 if test $ac_cv_func_setvbuf_reversed = yes; then
 
@@ -21851,13 +23030,13 @@ EOF
 fi
 
 fi
-echo "$as_me:21854: checking for intptr_t" >&5
+echo "$as_me:23033: checking for intptr_t" >&5
 echo $ECHO_N "checking for intptr_t... $ECHO_C" >&6
 if test "${ac_cv_type_intptr_t+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 21860 "configure"
+#line 23039 "configure"
 #include "confdefs.h"
 $ac_includes_default
 int
@@ -21872,16 +23051,16 @@ if (sizeof (intptr_t))
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:21875: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:23054: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:21878: \$? = $ac_status" >&5
+  echo "$as_me:23057: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:21881: \"$ac_try\"") >&5
+  { (eval echo "$as_me:23060: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:21884: \$? = $ac_status" >&5
+  echo "$as_me:23063: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_type_intptr_t=yes
 else
@@ -21891,7 +23070,7 @@ ac_cv_type_intptr_t=no
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 fi
-echo "$as_me:21894: result: $ac_cv_type_intptr_t" >&5
+echo "$as_me:23073: result: $ac_cv_type_intptr_t" >&5
 echo "${ECHO_T}$ac_cv_type_intptr_t" >&6
 if test "$ac_cv_type_intptr_t" = yes; then
   :
@@ -21903,13 +23082,13 @@ EOF
 
 fi
 
-echo "$as_me:21906: checking for ssize_t" >&5
+echo "$as_me:23085: checking for ssize_t" >&5
 echo $ECHO_N "checking for ssize_t... $ECHO_C" >&6
 if test "${ac_cv_type_ssize_t+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 21912 "configure"
+#line 23091 "configure"
 #include "confdefs.h"
 $ac_includes_default
 int
@@ -21924,16 +23103,16 @@ if (sizeof (ssize_t))
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:21927: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:23106: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:21930: \$? = $ac_status" >&5
+  echo "$as_me:23109: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:21933: \"$ac_try\"") >&5
+  { (eval echo "$as_me:23112: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:21936: \$? = $ac_status" >&5
+  echo "$as_me:23115: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_type_ssize_t=yes
 else
@@ -21943,7 +23122,7 @@ ac_cv_type_ssize_t=no
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 fi
-echo "$as_me:21946: result: $ac_cv_type_ssize_t" >&5
+echo "$as_me:23125: result: $ac_cv_type_ssize_t" >&5
 echo "${ECHO_T}$ac_cv_type_ssize_t" >&6
 if test "$ac_cv_type_ssize_t" = yes; then
   :
@@ -21955,36 +23134,36 @@ EOF
 
 fi
 
-echo "$as_me:21958: checking for type sigaction_t" >&5
+echo "$as_me:23137: checking for type sigaction_t" >&5
 echo $ECHO_N "checking for type sigaction_t... $ECHO_C" >&6
 if test "${cf_cv_type_sigaction+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 21965 "configure"
+#line 23144 "configure"
 #include "confdefs.h"
 
 #include <signal.h>
 int
 main (void)
 {
-sigaction_t x
+sigaction_t x; (void)x
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:21978: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:23157: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:21981: \$? = $ac_status" >&5
+  echo "$as_me:23160: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:21984: \"$ac_try\"") >&5
+  { (eval echo "$as_me:23163: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:21987: \$? = $ac_status" >&5
+  echo "$as_me:23166: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_type_sigaction=yes
 else
@@ -21995,14 +23174,14 @@ fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 fi
 
-echo "$as_me:21998: result: $cf_cv_type_sigaction" >&5
+echo "$as_me:23177: result: $cf_cv_type_sigaction" >&5
 echo "${ECHO_T}$cf_cv_type_sigaction" >&6
 test "$cf_cv_type_sigaction" = yes &&
 cat >>confdefs.h <<\EOF
 #define HAVE_TYPE_SIGACTION 1
 EOF
 
-echo "$as_me:22005: checking declaration of size-change" >&5
+echo "$as_me:23184: checking declaration of size-change" >&5
 echo $ECHO_N "checking declaration of size-change... $ECHO_C" >&6
 if test "${cf_cv_sizechange+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -22023,7 +23202,7 @@ do
 
 	fi
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 22026 "configure"
+#line 23205 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #ifdef HAVE_TERMIOS_H
@@ -22036,7 +23215,7 @@ do
 
 #ifdef NEED_PTEM_H
 /* This is a workaround for SCO:  they neglected to define struct winsize in
- * termios.h -- it's only in termio.h and ptem.h
+ * termios.h -- it is only in termio.h and ptem.h
  */
 #include <sys/stream.h>
 #include <sys/ptem.h>
@@ -22073,16 +23252,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:22076: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:23255: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:22079: \$? = $ac_status" >&5
+  echo "$as_me:23258: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:22082: \"$ac_try\"") >&5
+  { (eval echo "$as_me:23261: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:22085: \$? = $ac_status" >&5
+  echo "$as_me:23264: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_sizechange=yes
 else
@@ -22101,7 +23280,7 @@ rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 done
 
 fi
-echo "$as_me:22104: result: $cf_cv_sizechange" >&5
+echo "$as_me:23283: result: $cf_cv_sizechange" >&5
 echo "${ECHO_T}$cf_cv_sizechange" >&6
 if test "$cf_cv_sizechange" != no ; then
 
@@ -22119,13 +23298,13 @@ EOF
 	esac
 fi
 
-echo "$as_me:22122: checking for memmove" >&5
+echo "$as_me:23301: checking for memmove" >&5
 echo $ECHO_N "checking for memmove... $ECHO_C" >&6
 if test "${ac_cv_func_memmove+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 22128 "configure"
+#line 23307 "configure"
 #include "confdefs.h"
 #define memmove autoconf_temporary
 #include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
@@ -22156,16 +23335,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:22159: \"$ac_link\"") >&5
+if { (eval echo "$as_me:23338: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:22162: \$? = $ac_status" >&5
+  echo "$as_me:23341: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:22165: \"$ac_try\"") >&5
+  { (eval echo "$as_me:23344: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:22168: \$? = $ac_status" >&5
+  echo "$as_me:23347: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_func_memmove=yes
 else
@@ -22175,19 +23354,19 @@ ac_cv_func_memmove=no
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:22178: result: $ac_cv_func_memmove" >&5
+echo "$as_me:23357: result: $ac_cv_func_memmove" >&5
 echo "${ECHO_T}$ac_cv_func_memmove" >&6
 if test "$ac_cv_func_memmove" = yes; then
   :
 else
 
-echo "$as_me:22184: checking for bcopy" >&5
+echo "$as_me:23363: checking for bcopy" >&5
 echo $ECHO_N "checking for bcopy... $ECHO_C" >&6
 if test "${ac_cv_func_bcopy+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 22190 "configure"
+#line 23369 "configure"
 #include "confdefs.h"
 #define bcopy autoconf_temporary
 #include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
@@ -22218,16 +23397,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:22221: \"$ac_link\"") >&5
+if { (eval echo "$as_me:23400: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:22224: \$? = $ac_status" >&5
+  echo "$as_me:23403: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:22227: \"$ac_try\"") >&5
+  { (eval echo "$as_me:23406: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:22230: \$? = $ac_status" >&5
+  echo "$as_me:23409: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_func_bcopy=yes
 else
@@ -22237,11 +23416,11 @@ ac_cv_func_bcopy=no
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:22240: result: $ac_cv_func_bcopy" >&5
+echo "$as_me:23419: result: $ac_cv_func_bcopy" >&5
 echo "${ECHO_T}$ac_cv_func_bcopy" >&6
 if test "$ac_cv_func_bcopy" = yes; then
 
-	echo "$as_me:22244: checking if bcopy does overlapping moves" >&5
+	echo "$as_me:23423: checking if bcopy does overlapping moves" >&5
 echo $ECHO_N "checking if bcopy does overlapping moves... $ECHO_C" >&6
 if test "${cf_cv_good_bcopy+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -22251,9 +23430,11 @@ else
   cf_cv_good_bcopy=unknown
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 22254 "configure"
+#line 23433 "configure"
 #include "confdefs.h"
 
+$ac_includes_default
+
 int main(void) {
 	static char data[] = "abcdefghijklmnopqrstuwwxyz";
 	char temp[40];
@@ -22265,15 +23446,15 @@ int main(void) {
 
 _ACEOF
 rm -f "conftest$ac_exeext"
-if { (eval echo "$as_me:22268: \"$ac_link\"") >&5
+if { (eval echo "$as_me:23449: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:22271: \$? = $ac_status" >&5
+  echo "$as_me:23452: \$? = $ac_status" >&5
   (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
-  { (eval echo "$as_me:22273: \"$ac_try\"") >&5
+  { (eval echo "$as_me:23454: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:22276: \$? = $ac_status" >&5
+  echo "$as_me:23457: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_good_bcopy=yes
 else
@@ -22286,7 +23467,7 @@ rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftes
 fi
 
 fi
-echo "$as_me:22289: result: $cf_cv_good_bcopy" >&5
+echo "$as_me:23470: result: $cf_cv_good_bcopy" >&5
 echo "${ECHO_T}$cf_cv_good_bcopy" >&6
 
 else
@@ -22313,13 +23494,13 @@ tty >/dev/null 2>&1 || {
 for ac_func in posix_openpt
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:22316: checking for $ac_func" >&5
+echo "$as_me:23497: checking for $ac_func" >&5
 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
 if eval "test \"\${$as_ac_var+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 22322 "configure"
+#line 23503 "configure"
 #include "confdefs.h"
 #define $ac_func autoconf_temporary
 #include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
@@ -22350,16 +23531,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:22353: \"$ac_link\"") >&5
+if { (eval echo "$as_me:23534: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:22356: \$? = $ac_status" >&5
+  echo "$as_me:23537: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:22359: \"$ac_try\"") >&5
+  { (eval echo "$as_me:23540: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:22362: \$? = $ac_status" >&5
+  echo "$as_me:23543: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   eval "$as_ac_var=yes"
 else
@@ -22369,7 +23550,7 @@ eval "$as_ac_var=no"
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:22372: result: `eval echo '${'"$as_ac_var"'}'`" >&5
+echo "$as_me:23553: result: `eval echo '${'"$as_ac_var"'}'`" >&5
 echo "${ECHO_T}`eval echo '${'"$as_ac_var"'}'`" >&6
 if test "`eval echo '${'"$as_ac_var"'}'`" = yes; then
   cat >>confdefs.h <<EOF
@@ -22379,7 +23560,7 @@ EOF
 fi
 done
  }
-echo "$as_me:22382: checking if poll really works" >&5
+echo "$as_me:23563: checking if poll really works" >&5
 echo $ECHO_N "checking if poll really works... $ECHO_C" >&6
 if test "${cf_cv_working_poll+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -22389,18 +23570,19 @@ if test "$cross_compiling" = yes; then
   cf_cv_working_poll=unknown
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 22392 "configure"
+#line 23573 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
+$ac_includes_default
+
 #include <fcntl.h>
+
 #ifdef HAVE_POLL_H
 #include <poll.h>
 #else
 #include <sys/poll.h>
 #endif
+
 int main(void) {
 	struct pollfd myfds;
 	int ret;
@@ -22441,15 +23623,15 @@ int main(void) {
 }
 _ACEOF
 rm -f "conftest$ac_exeext"
-if { (eval echo "$as_me:22444: \"$ac_link\"") >&5
+if { (eval echo "$as_me:23626: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:22447: \$? = $ac_status" >&5
+  echo "$as_me:23629: \$? = $ac_status" >&5
   (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
-  { (eval echo "$as_me:22449: \"$ac_try\"") >&5
+  { (eval echo "$as_me:23631: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:22452: \$? = $ac_status" >&5
+  echo "$as_me:23634: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_working_poll=yes
 else
@@ -22461,21 +23643,81 @@ fi
 rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftest.$ac_ext"
 fi
 fi
-echo "$as_me:22464: result: $cf_cv_working_poll" >&5
+echo "$as_me:23646: result: $cf_cv_working_poll" >&5
 echo "${ECHO_T}$cf_cv_working_poll" >&6
 test "$cf_cv_working_poll" = "yes" &&
 cat >>confdefs.h <<\EOF
 #define HAVE_WORKING_POLL 1
 EOF
 
-echo "$as_me:22471: checking for va_copy" >&5
+echo "$as_me:23653: checking if MB_LEN_MAX is usable" >&5
+echo $ECHO_N "checking if MB_LEN_MAX is usable... $ECHO_C" >&6
+if test "${cf_cv_mb_len_max+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cat >"conftest.$ac_ext" <<_ACEOF
+#line 23660 "configure"
+#include "confdefs.h"
+
+$ac_includes_default
+#include <limits.h>
+int
+main (void)
+{
+
+#if defined(MB_LEN_MAX) && MB_LEN_MAX >= 6
+	${cf_cv_main_return:-return}(0);
+#else
+#error MB_LEN_MAX is not usable
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f "conftest.$ac_objext"
+if { (eval echo "$as_me:23680: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:23683: \$? = $ac_status" >&5
+  (exit "$ac_status"); } &&
+         { ac_try='test -s "conftest.$ac_objext"'
+  { (eval echo "$as_me:23686: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:23689: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  cf_cv_mb_len_max=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+cf_cv_mb_len_max=no
+fi
+rm -f "conftest.$ac_objext" "conftest.$ac_ext"
+fi
+echo "$as_me:23699: result: $cf_cv_mb_len_max" >&5
+echo "${ECHO_T}$cf_cv_mb_len_max" >&6
+if test "$cf_cv_mb_len_max" = yes
+then
+
+cat >>confdefs.h <<\EOF
+#define HAVE_CONSISTENT_MB_LEN_MAX 1
+EOF
+
+else
+	{ echo "$as_me:23709: WARNING: MB_LEN_MAX is missing/inconsistent in system headers" >&5
+echo "$as_me: WARNING: MB_LEN_MAX is missing/inconsistent in system headers" >&2;}
+fi
+
+echo "$as_me:23713: checking for va_copy" >&5
 echo $ECHO_N "checking for va_copy... $ECHO_C" >&6
 if test "${cf_cv_have_va_copy+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 22478 "configure"
+#line 23720 "configure"
 #include "confdefs.h"
 
 #include <stdarg.h>
@@ -22492,16 +23734,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:22495: \"$ac_link\"") >&5
+if { (eval echo "$as_me:23737: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:22498: \$? = $ac_status" >&5
+  echo "$as_me:23740: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:22501: \"$ac_try\"") >&5
+  { (eval echo "$as_me:23743: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:22504: \$? = $ac_status" >&5
+  echo "$as_me:23746: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_have_va_copy=yes
 else
@@ -22511,7 +23753,7 @@ cf_cv_have_va_copy=no
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:22514: result: $cf_cv_have_va_copy" >&5
+echo "$as_me:23756: result: $cf_cv_have_va_copy" >&5
 echo "${ECHO_T}$cf_cv_have_va_copy" >&6
 
 if test "$cf_cv_have_va_copy" = yes;
@@ -22523,14 +23765,14 @@ EOF
 
 else # !cf_cv_have_va_copy
 
-echo "$as_me:22526: checking for __va_copy" >&5
+echo "$as_me:23768: checking for __va_copy" >&5
 echo $ECHO_N "checking for __va_copy... $ECHO_C" >&6
 if test "${cf_cv_have___va_copy+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 22533 "configure"
+#line 23775 "configure"
 #include "confdefs.h"
 
 #include <stdarg.h>
@@ -22547,16 +23789,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:22550: \"$ac_link\"") >&5
+if { (eval echo "$as_me:23792: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:22553: \$? = $ac_status" >&5
+  echo "$as_me:23795: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:22556: \"$ac_try\"") >&5
+  { (eval echo "$as_me:23798: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:22559: \$? = $ac_status" >&5
+  echo "$as_me:23801: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_have___va_copy=yes
 else
@@ -22566,7 +23808,7 @@ cf_cv_have___va_copy=no
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:22569: result: $cf_cv_have___va_copy" >&5
+echo "$as_me:23811: result: $cf_cv_have___va_copy" >&5
 echo "${ECHO_T}$cf_cv_have___va_copy" >&6
 
 if test "$cf_cv_have___va_copy" = yes
@@ -22578,14 +23820,14 @@ EOF
 
 else # !cf_cv_have___va_copy
 
-echo "$as_me:22581: checking for __builtin_va_copy" >&5
+echo "$as_me:23823: checking for __builtin_va_copy" >&5
 echo $ECHO_N "checking for __builtin_va_copy... $ECHO_C" >&6
 if test "${cf_cv_have___builtin_va_copy+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 22588 "configure"
+#line 23830 "configure"
 #include "confdefs.h"
 
 #include <stdarg.h>
@@ -22602,16 +23844,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:22605: \"$ac_link\"") >&5
+if { (eval echo "$as_me:23847: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:22608: \$? = $ac_status" >&5
+  echo "$as_me:23850: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:22611: \"$ac_try\"") >&5
+  { (eval echo "$as_me:23853: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:22614: \$? = $ac_status" >&5
+  echo "$as_me:23856: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_have___builtin_va_copy=yes
 else
@@ -22621,7 +23863,7 @@ cf_cv_have___builtin_va_copy=no
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:22624: result: $cf_cv_have___builtin_va_copy" >&5
+echo "$as_me:23866: result: $cf_cv_have___builtin_va_copy" >&5
 echo "${ECHO_T}$cf_cv_have___builtin_va_copy" >&6
 
 test "$cf_cv_have___builtin_va_copy" = yes &&
@@ -22639,14 +23881,14 @@ case "${cf_cv_have_va_copy}${cf_cv_have___va_copy}${cf_cv_have___builtin_va_copy
 	;;
 
 (*)
-	echo "$as_me:22642: checking if we can simply copy va_list" >&5
+	echo "$as_me:23884: checking if we can simply copy va_list" >&5
 echo $ECHO_N "checking if we can simply copy va_list... $ECHO_C" >&6
 if test "${cf_cv_pointer_va_list+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 22649 "configure"
+#line 23891 "configure"
 #include "confdefs.h"
 
 #include <stdarg.h>
@@ -22663,16 +23905,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:22666: \"$ac_link\"") >&5
+if { (eval echo "$as_me:23908: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:22669: \$? = $ac_status" >&5
+  echo "$as_me:23911: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:22672: \"$ac_try\"") >&5
+  { (eval echo "$as_me:23914: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:22675: \$? = $ac_status" >&5
+  echo "$as_me:23917: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_pointer_va_list=yes
 else
@@ -22682,19 +23924,19 @@ cf_cv_pointer_va_list=no
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:22685: result: $cf_cv_pointer_va_list" >&5
+echo "$as_me:23927: result: $cf_cv_pointer_va_list" >&5
 echo "${ECHO_T}$cf_cv_pointer_va_list" >&6
 
 	if test "$cf_cv_pointer_va_list" = no
 	then
-		echo "$as_me:22690: checking if we can copy va_list indirectly" >&5
+		echo "$as_me:23932: checking if we can copy va_list indirectly" >&5
 echo $ECHO_N "checking if we can copy va_list indirectly... $ECHO_C" >&6
 if test "${cf_cv_array_va_list+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 22697 "configure"
+#line 23939 "configure"
 #include "confdefs.h"
 
 #include <stdarg.h>
@@ -22711,16 +23953,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:22714: \"$ac_link\"") >&5
+if { (eval echo "$as_me:23956: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:22717: \$? = $ac_status" >&5
+  echo "$as_me:23959: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:22720: \"$ac_try\"") >&5
+  { (eval echo "$as_me:23962: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:22723: \$? = $ac_status" >&5
+  echo "$as_me:23965: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_array_va_list=yes
 else
@@ -22730,7 +23972,7 @@ cf_cv_array_va_list=no
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:22733: result: $cf_cv_array_va_list" >&5
+echo "$as_me:23975: result: $cf_cv_array_va_list" >&5
 echo "${ECHO_T}$cf_cv_array_va_list" >&6
 		test "$cf_cv_array_va_list" = yes &&
 cat >>confdefs.h <<\EOF
@@ -22741,13 +23983,13 @@ EOF
 	;;
 esac
 
-echo "$as_me:22744: checking for pid_t" >&5
+echo "$as_me:23986: checking for pid_t" >&5
 echo $ECHO_N "checking for pid_t... $ECHO_C" >&6
 if test "${ac_cv_type_pid_t+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 22750 "configure"
+#line 23992 "configure"
 #include "confdefs.h"
 $ac_includes_default
 int
@@ -22762,16 +24004,16 @@ if (sizeof (pid_t))
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:22765: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:24007: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:22768: \$? = $ac_status" >&5
+  echo "$as_me:24010: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:22771: \"$ac_try\"") >&5
+  { (eval echo "$as_me:24013: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:22774: \$? = $ac_status" >&5
+  echo "$as_me:24016: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_type_pid_t=yes
 else
@@ -22781,7 +24023,7 @@ ac_cv_type_pid_t=no
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 fi
-echo "$as_me:22784: result: $ac_cv_type_pid_t" >&5
+echo "$as_me:24026: result: $ac_cv_type_pid_t" >&5
 echo "${ECHO_T}$ac_cv_type_pid_t" >&6
 if test "$ac_cv_type_pid_t" = yes; then
   :
@@ -22796,23 +24038,23 @@ fi
 for ac_header in unistd.h vfork.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:22799: checking for $ac_header" >&5
+echo "$as_me:24041: checking for $ac_header" >&5
 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 22805 "configure"
+#line 24047 "configure"
 #include "confdefs.h"
 #include <$ac_header>
 _ACEOF
-if { (eval echo "$as_me:22809: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+if { (eval echo "$as_me:24051: \"$ac_cpp "conftest.$ac_ext"\"") >&5
   (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:22815: \$? = $ac_status" >&5
+  echo "$as_me:24057: \$? = $ac_status" >&5
   (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -22831,7 +24073,7 @@ else
 fi
 rm -f conftest.err "conftest.$ac_ext"
 fi
-echo "$as_me:22834: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
+echo "$as_me:24076: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
 echo "${ECHO_T}`eval echo '${'"$as_ac_Header"'}'`" >&6
 if test "`eval echo '${'"$as_ac_Header"'}'`" = yes; then
   cat >>confdefs.h <<EOF
@@ -22844,13 +24086,13 @@ done
 for ac_func in fork vfork
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:22847: checking for $ac_func" >&5
+echo "$as_me:24089: checking for $ac_func" >&5
 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
 if eval "test \"\${$as_ac_var+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 22853 "configure"
+#line 24095 "configure"
 #include "confdefs.h"
 #define $ac_func autoconf_temporary
 #include <limits.h>	/* least-intrusive standard header which defines gcc2 __stub macros */
@@ -22881,16 +24123,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:22884: \"$ac_link\"") >&5
+if { (eval echo "$as_me:24126: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:22887: \$? = $ac_status" >&5
+  echo "$as_me:24129: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:22890: \"$ac_try\"") >&5
+  { (eval echo "$as_me:24132: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:22893: \$? = $ac_status" >&5
+  echo "$as_me:24135: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   eval "$as_ac_var=yes"
 else
@@ -22900,7 +24142,7 @@ eval "$as_ac_var=no"
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
-echo "$as_me:22903: result: `eval echo '${'"$as_ac_var"'}'`" >&5
+echo "$as_me:24145: result: `eval echo '${'"$as_ac_var"'}'`" >&5
 echo "${ECHO_T}`eval echo '${'"$as_ac_var"'}'`" >&6
 if test "`eval echo '${'"$as_ac_var"'}'`" = yes; then
   cat >>confdefs.h <<EOF
@@ -22912,7 +24154,7 @@ done
 
 ac_cv_func_fork_works=$ac_cv_func_fork
 if test "x$ac_cv_func_fork" = xyes; then
-  echo "$as_me:22915: checking for working fork" >&5
+  echo "$as_me:24157: checking for working fork" >&5
 echo $ECHO_N "checking for working fork... $ECHO_C" >&6
 if test "${ac_cv_func_fork_works+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -22935,15 +24177,15 @@ else
       }
 _ACEOF
 rm -f "conftest$ac_exeext"
-if { (eval echo "$as_me:22938: \"$ac_link\"") >&5
+if { (eval echo "$as_me:24180: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:22941: \$? = $ac_status" >&5
+  echo "$as_me:24183: \$? = $ac_status" >&5
   (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
-  { (eval echo "$as_me:22943: \"$ac_try\"") >&5
+  { (eval echo "$as_me:24185: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:22946: \$? = $ac_status" >&5
+  echo "$as_me:24188: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_func_fork_works=yes
 else
@@ -22955,7 +24197,7 @@ fi
 rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftest.$ac_ext"
 fi
 fi
-echo "$as_me:22958: result: $ac_cv_func_fork_works" >&5
+echo "$as_me:24200: result: $ac_cv_func_fork_works" >&5
 echo "${ECHO_T}$ac_cv_func_fork_works" >&6
 
 fi
@@ -22969,12 +24211,12 @@ if test "x$ac_cv_func_fork_works" = xcross; then
       ac_cv_func_fork_works=yes
       ;;
   esac
-  { echo "$as_me:22972: WARNING: CROSS: Result $ac_cv_func_fork_works guessed due to cross-compiling." >&5
+  { echo "$as_me:24214: WARNING: CROSS: Result $ac_cv_func_fork_works guessed due to cross-compiling." >&5
 echo "$as_me: WARNING: CROSS: Result $ac_cv_func_fork_works guessed due to cross-compiling." >&2;}
 fi
 ac_cv_func_vfork_works=$ac_cv_func_vfork
 if test "x$ac_cv_func_vfork" = xyes; then
-  echo "$as_me:22977: checking for working vfork" >&5
+  echo "$as_me:24219: checking for working vfork" >&5
 echo $ECHO_N "checking for working vfork... $ECHO_C" >&6
 if test "${ac_cv_func_vfork_works+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -22983,7 +24225,7 @@ else
   ac_cv_func_vfork_works=cross
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 22986 "configure"
+#line 24228 "configure"
 #include "confdefs.h"
 /* Thanks to Paul Eggert for this test.  */
 #include <stdio.h>
@@ -23002,11 +24244,7 @@ else
    static variable whose address is put into a register that is
    clobbered by the vfork.  */
 static
-#ifdef __cplusplus
 sparc_address_test (int arg)
-# else
-sparc_address_test (arg) int arg;
-#endif
 {
   static pid_t child;
   if (!child) {
@@ -23049,7 +24287,7 @@ main (void)
     /* Convince the compiler that p..p7 are live; otherwise, it might
        use the same hardware register for all 8 local variables.  */
     if (p != p1 || p != p2 || p != p3 || p != p4
-	|| p != p5 || p != p6 || p != p7)
+        || p != p5 || p != p6 || p != p7)
       _exit(1);
 
     /* On some systems (e.g. IRIX 3.3), vfork doesn't separate parent
@@ -23064,31 +24302,31 @@ main (void)
     while (wait(&status) != child)
       ;
     $ac_main_return(
-	 /* Was there some problem with vforking?  */
-	 child < 0
+         /* Was there some problem with vforking?  */
+         child < 0
 
-	 /* Did the child fail?  (This shouldn't happen.)  */
-	 || status
+         /* Did the child fail?  (This shouldn't happen.)  */
+         || status
 
-	 /* Did the vfork/compiler bug occur?  */
-	 || parent != getpid()
+         /* Did the vfork/compiler bug occur?  */
+         || parent != getpid()
 
-	 /* Did the file descriptor bug occur?  */
-	 || fstat(fileno(stdout), &st) != 0
-	 );
+         /* Did the file descriptor bug occur?  */
+         || fstat(fileno(stdout), &st) != 0
+         );
   }
 }
 _ACEOF
 rm -f "conftest$ac_exeext"
-if { (eval echo "$as_me:23083: \"$ac_link\"") >&5
+if { (eval echo "$as_me:24321: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:23086: \$? = $ac_status" >&5
+  echo "$as_me:24324: \$? = $ac_status" >&5
   (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
-  { (eval echo "$as_me:23088: \"$ac_try\"") >&5
+  { (eval echo "$as_me:24326: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:23091: \$? = $ac_status" >&5
+  echo "$as_me:24329: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_func_vfork_works=yes
 else
@@ -23100,13 +24338,13 @@ fi
 rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftest.$ac_ext"
 fi
 fi
-echo "$as_me:23103: result: $ac_cv_func_vfork_works" >&5
+echo "$as_me:24341: result: $ac_cv_func_vfork_works" >&5
 echo "${ECHO_T}$ac_cv_func_vfork_works" >&6
 
 fi;
 if test "x$ac_cv_func_fork_works" = xcross; then
   ac_cv_func_vfork_works=ac_cv_func_vfork
-  { echo "$as_me:23109: WARNING: CROSS: Result $ac_cv_func_vfork_works guessed due to cross-compiling." >&5
+  { echo "$as_me:24347: WARNING: CROSS: Result $ac_cv_func_vfork_works guessed due to cross-compiling." >&5
 echo "$as_me: WARNING: CROSS: Result $ac_cv_func_vfork_works guessed due to cross-compiling." >&2;}
 fi
 
@@ -23131,7 +24369,7 @@ EOF
 
 fi
 
-echo "$as_me:23134: checking if fopen accepts explicit binary mode" >&5
+echo "$as_me:24372: checking if fopen accepts explicit binary mode" >&5
 echo $ECHO_N "checking if fopen accepts explicit binary mode... $ECHO_C" >&6
 if test "${cf_cv_fopen_bin_r+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -23141,11 +24379,13 @@ else
   cf_cv_fopen_bin_r=unknown
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 23144 "configure"
+#line 24382 "configure"
 #include "confdefs.h"
 
-#include <stdio.h>
-int main(void) {
+$ac_includes_default
+
+int main(void)
+{
 	FILE *fp = fopen("conftest.tmp", "wb");
 	int rc = 0;
 	if (fp != 0) {
@@ -23174,15 +24414,15 @@ int main(void) {
 
 _ACEOF
 rm -f "conftest$ac_exeext"
-if { (eval echo "$as_me:23177: \"$ac_link\"") >&5
+if { (eval echo "$as_me:24417: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:23180: \$? = $ac_status" >&5
+  echo "$as_me:24420: \$? = $ac_status" >&5
   (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
-  { (eval echo "$as_me:23182: \"$ac_try\"") >&5
+  { (eval echo "$as_me:24422: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:23185: \$? = $ac_status" >&5
+  echo "$as_me:24425: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_fopen_bin_r=yes
 else
@@ -23195,7 +24435,7 @@ rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftes
 fi
 
 fi
-echo "$as_me:23198: result: $cf_cv_fopen_bin_r" >&5
+echo "$as_me:24438: result: $cf_cv_fopen_bin_r" >&5
 echo "${ECHO_T}$cf_cv_fopen_bin_r" >&6
 test "x$cf_cv_fopen_bin_r" != xno &&
 cat >>confdefs.h <<\EOF
@@ -23204,7 +24444,7 @@ EOF
 
 # special check for test/ditto.c
 
-echo "$as_me:23207: checking for openpty in -lutil" >&5
+echo "$as_me:24447: checking for openpty in -lutil" >&5
 echo $ECHO_N "checking for openpty in -lutil... $ECHO_C" >&6
 if test "${ac_cv_lib_util_openpty+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -23212,7 +24452,7 @@ else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lutil  $LIBS"
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 23215 "configure"
+#line 24455 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -23221,7 +24461,7 @@ extern "C"
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char openpty ();
+char openpty (void);
 int
 main (void)
 {
@@ -23231,16 +24471,16 @@ openpty ();
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:23234: \"$ac_link\"") >&5
+if { (eval echo "$as_me:24474: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:23237: \$? = $ac_status" >&5
+  echo "$as_me:24477: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:23240: \"$ac_try\"") >&5
+  { (eval echo "$as_me:24480: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:23243: \$? = $ac_status" >&5
+  echo "$as_me:24483: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_lib_util_openpty=yes
 else
@@ -23251,7 +24491,7 @@ fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:23254: result: $ac_cv_lib_util_openpty" >&5
+echo "$as_me:24494: result: $ac_cv_lib_util_openpty" >&5
 echo "${ECHO_T}$ac_cv_lib_util_openpty" >&6
 if test "$ac_cv_lib_util_openpty" = yes; then
   cf_cv_lib_util=yes
@@ -23259,7 +24499,7 @@ else
   cf_cv_lib_util=no
 fi
 
-echo "$as_me:23262: checking for openpty header" >&5
+echo "$as_me:24502: checking for openpty header" >&5
 echo $ECHO_N "checking for openpty header... $ECHO_C" >&6
 if test "${cf_cv_func_openpty+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -23286,7 +24526,7 @@ LIBS="$cf_add_libs"
 	for cf_header in pty.h libutil.h util.h
 	do
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 23289 "configure"
+#line 24529 "configure"
 #include "confdefs.h"
 
 #include <$cf_header>
@@ -23297,22 +24537,23 @@ main (void)
 
 	int x = openpty((int *)0, (int *)0, (char *)0,
 				   (struct termios *)0, (struct winsize *)0);
+	(void)x;
 
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:23306: \"$ac_link\"") >&5
+if { (eval echo "$as_me:24547: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:23309: \$? = $ac_status" >&5
+  echo "$as_me:24550: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:23312: \"$ac_try\"") >&5
+  { (eval echo "$as_me:24553: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:23315: \$? = $ac_status" >&5
+  echo "$as_me:24556: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
 
 		cf_cv_func_openpty=$cf_header
@@ -23330,7 +24571,7 @@ rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 	LIBS="$cf_save_LIBS"
 
 fi
-echo "$as_me:23333: result: $cf_cv_func_openpty" >&5
+echo "$as_me:24574: result: $cf_cv_func_openpty" >&5
 echo "${ECHO_T}$cf_cv_func_openpty" >&6
 
 if test "$cf_cv_func_openpty" != no ; then
@@ -23403,7 +24644,7 @@ if test -n "$with_hashed_db/include" ; then
 	CPPFLAGS="${CPPFLAGS}-I$cf_add_incdir"
 
 			  cat >"conftest.$ac_ext" <<_ACEOF
-#line 23406 "configure"
+#line 24647 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int
@@ -23415,16 +24656,16 @@ printf("Hello")
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:23418: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:24659: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:23421: \$? = $ac_status" >&5
+  echo "$as_me:24662: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:23424: \"$ac_try\"") >&5
+  { (eval echo "$as_me:24665: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:23427: \$? = $ac_status" >&5
+  echo "$as_me:24668: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   :
 else
@@ -23441,7 +24682,7 @@ rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 		if test "$cf_have_incdir" = no ; then
 		  test -n "$verbose" && echo "	adding $cf_add_incdir to include-path" 1>&6
 
-echo "${as_me:-configure}:23444: testing adding $cf_add_incdir to include-path ..." 1>&5
+echo "${as_me:-configure}:24685: testing adding $cf_add_incdir to include-path ..." 1>&5
 
 		  CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
 
@@ -23477,7 +24718,7 @@ if test -n "$with_hashed_db/lib" ; then
 			if test "$cf_have_libdir" = no ; then
 				test -n "$verbose" && echo "	adding $cf_add_libdir to library-path" 1>&6
 
-echo "${as_me:-configure}:23480: testing adding $cf_add_libdir to library-path ..." 1>&5
+echo "${as_me:-configure}:24721: testing adding $cf_add_libdir to library-path ..." 1>&5
 
 				LDFLAGS="-L$cf_add_libdir $LDFLAGS"
 			fi
@@ -23488,7 +24729,7 @@ fi
 	else
 		case "$with_hashed_db" in
 		(./*|../*|/*)
-			{ echo "$as_me:23491: WARNING: no such directory $with_hashed_db" >&5
+			{ echo "$as_me:24732: WARNING: no such directory $with_hashed_db" >&5
 echo "$as_me: WARNING: no such directory $with_hashed_db" >&2;}
 			;;
 		(*)
@@ -23560,7 +24801,7 @@ if test -n "$cf_item" ; then
 	CPPFLAGS="${CPPFLAGS}-I$cf_add_incdir"
 
 			  cat >"conftest.$ac_ext" <<_ACEOF
-#line 23563 "configure"
+#line 24804 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int
@@ -23572,16 +24813,16 @@ printf("Hello")
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:23575: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:24816: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:23578: \$? = $ac_status" >&5
+  echo "$as_me:24819: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:23581: \"$ac_try\"") >&5
+  { (eval echo "$as_me:24822: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:23584: \$? = $ac_status" >&5
+  echo "$as_me:24825: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   :
 else
@@ -23598,7 +24839,7 @@ rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 		if test "$cf_have_incdir" = no ; then
 		  test -n "$verbose" && echo "	adding $cf_add_incdir to include-path" 1>&6
 
-echo "${as_me:-configure}:23601: testing adding $cf_add_incdir to include-path ..." 1>&5
+echo "${as_me:-configure}:24842: testing adding $cf_add_incdir to include-path ..." 1>&5
 
 		  CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
 
@@ -23678,7 +24919,7 @@ if test -n "$cf_item" ; then
 			if test "$cf_have_libdir" = no ; then
 				test -n "$verbose" && echo "	adding $cf_add_libdir to library-path" 1>&6
 
-echo "${as_me:-configure}:23681: testing adding $cf_add_libdir to library-path ..." 1>&5
+echo "${as_me:-configure}:24922: testing adding $cf_add_libdir to library-path ..." 1>&5
 
 				LDFLAGS="-L$cf_add_libdir $LDFLAGS"
 			fi
@@ -23695,23 +24936,23 @@ fi
 	fi
 esac
 
-echo "$as_me:23698: checking for db.h" >&5
+echo "$as_me:24939: checking for db.h" >&5
 echo $ECHO_N "checking for db.h... $ECHO_C" >&6
 if test "${ac_cv_header_db_h+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 23704 "configure"
+#line 24945 "configure"
 #include "confdefs.h"
 #include <db.h>
 _ACEOF
-if { (eval echo "$as_me:23708: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+if { (eval echo "$as_me:24949: \"$ac_cpp "conftest.$ac_ext"\"") >&5
   (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:23714: \$? = $ac_status" >&5
+  echo "$as_me:24955: \$? = $ac_status" >&5
   (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -23730,11 +24971,11 @@ else
 fi
 rm -f conftest.err "conftest.$ac_ext"
 fi
-echo "$as_me:23733: result: $ac_cv_header_db_h" >&5
+echo "$as_me:24974: result: $ac_cv_header_db_h" >&5
 echo "${ECHO_T}$ac_cv_header_db_h" >&6
 if test "$ac_cv_header_db_h" = yes; then
 
-echo "$as_me:23737: checking for version of db" >&5
+echo "$as_me:24978: checking for version of db" >&5
 echo $ECHO_N "checking for version of db... $ECHO_C" >&6
 if test "${cf_cv_hashed_db_version+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -23745,10 +24986,10 @@ cf_cv_hashed_db_version=unknown
 for cf_db_version in 1 2 3 4 5 6
 do
 
-echo "${as_me:-configure}:23748: testing checking for db version $cf_db_version ..." 1>&5
+echo "${as_me:-configure}:24989: testing checking for db version $cf_db_version ..." 1>&5
 
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 23751 "configure"
+#line 24992 "configure"
 #include "confdefs.h"
 
 $ac_includes_default
@@ -23759,13 +25000,13 @@ $ac_includes_default
 #if $cf_db_version == DB_VERSION_MAJOR
 	/* ok */
 #else
-	make an error
+	#error $cf_db_version is not DB_VERSION_MAJOR
 #endif
 #else
 #if $cf_db_version == 1
 	/* ok: assuming this is DB 1.8.5 */
 #else
-	make an error
+	#error $cf_db_version is not 1
 #endif
 #endif
 
@@ -23778,16 +25019,16 @@ DBT *foo = 0
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:23781: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:25022: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:23784: \$? = $ac_status" >&5
+  echo "$as_me:25025: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:23787: \"$ac_try\"") >&5
+  { (eval echo "$as_me:25028: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:23790: \$? = $ac_status" >&5
+  echo "$as_me:25031: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
 
 	cf_cv_hashed_db_version=$cf_db_version
@@ -23801,16 +25042,16 @@ rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 done
 
 fi
-echo "$as_me:23804: result: $cf_cv_hashed_db_version" >&5
+echo "$as_me:25045: result: $cf_cv_hashed_db_version" >&5
 echo "${ECHO_T}$cf_cv_hashed_db_version" >&6
 
 if test "$cf_cv_hashed_db_version" = unknown ; then
-	{ { echo "$as_me:23808: error: Cannot determine version of db" >&5
+	{ { echo "$as_me:25049: error: Cannot determine version of db" >&5
 echo "$as_me: error: Cannot determine version of db" >&2;}
    { (exit 1); exit 1; }; }
 else
 
-echo "$as_me:23813: checking for db libraries" >&5
+echo "$as_me:25054: checking for db libraries" >&5
 echo $ECHO_N "checking for db libraries... $ECHO_C" >&6
 if test "${cf_cv_hashed_db_libs+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -23840,10 +25081,10 @@ LIBS="$cf_add_libs"
 
 	fi
 
-echo "${as_me:-configure}:23843: testing checking for library $cf_db_libs ..." 1>&5
+echo "${as_me:-configure}:25084: testing checking for library $cf_db_libs ..." 1>&5
 
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 23846 "configure"
+#line 25087 "configure"
 #include "confdefs.h"
 
 $ac_includes_default
@@ -23898,16 +25139,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:23901: \"$ac_link\"") >&5
+if { (eval echo "$as_me:25142: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:23904: \$? = $ac_status" >&5
+  echo "$as_me:25145: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:23907: \"$ac_try\"") >&5
+  { (eval echo "$as_me:25148: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:23910: \$? = $ac_status" >&5
+  echo "$as_me:25151: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
 
 	if test -n "$cf_db_libs" ; then
@@ -23927,11 +25168,11 @@ rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 done
 
 fi
-echo "$as_me:23930: result: $cf_cv_hashed_db_libs" >&5
+echo "$as_me:25171: result: $cf_cv_hashed_db_libs" >&5
 echo "${ECHO_T}$cf_cv_hashed_db_libs" >&6
 
 	if test "$cf_cv_hashed_db_libs" = unknown ; then
-		{ { echo "$as_me:23934: error: Cannot determine library for db" >&5
+		{ { echo "$as_me:25175: error: Cannot determine library for db" >&5
 echo "$as_me: error: Cannot determine library for db" >&2;}
    { (exit 1); exit 1; }; }
 	elif test "$cf_cv_hashed_db_libs" != default ; then
@@ -23957,7 +25198,7 @@ fi
 
 else
 
-	{ { echo "$as_me:23960: error: Cannot find db.h" >&5
+	{ { echo "$as_me:25201: error: Cannot find db.h" >&5
 echo "$as_me: error: Cannot find db.h" >&2;}
    { (exit 1); exit 1; }; }
 
@@ -23972,7 +25213,7 @@ fi
 
 # Just in case, check if the C compiler has a bool type.
 
-echo "$as_me:23975: checking if we should include stdbool.h" >&5
+echo "$as_me:25216: checking if we should include stdbool.h" >&5
 echo $ECHO_N "checking if we should include stdbool.h... $ECHO_C" >&6
 
 if test "${cf_cv_header_stdbool_h+set}" = set; then
@@ -23980,35 +25221,35 @@ if test "${cf_cv_header_stdbool_h+set}" = set; then
 else
 
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 23983 "configure"
+#line 25224 "configure"
 #include "confdefs.h"
 
 int
 main (void)
 {
-bool foo = false
+bool foo = false; (void)foo
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:23995: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:25236: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:23998: \$? = $ac_status" >&5
+  echo "$as_me:25239: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:24001: \"$ac_try\"") >&5
+  { (eval echo "$as_me:25242: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:24004: \$? = $ac_status" >&5
+  echo "$as_me:25245: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_header_stdbool_h=0
 else
   echo "$as_me: failed program was:" >&5
 cat "conftest.$ac_ext" >&5
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 24011 "configure"
+#line 25252 "configure"
 #include "confdefs.h"
 
 #ifndef __BEOS__
@@ -24018,22 +25259,22 @@ cat >"conftest.$ac_ext" <<_ACEOF
 int
 main (void)
 {
-bool foo = false
+bool foo = false; (void)foo
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:24027: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:25268: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:24030: \$? = $ac_status" >&5
+  echo "$as_me:25271: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:24033: \"$ac_try\"") >&5
+  { (eval echo "$as_me:25274: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:24036: \$? = $ac_status" >&5
+  echo "$as_me:25277: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_header_stdbool_h=1
 else
@@ -24047,13 +25288,13 @@ rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 fi
 
 if test "$cf_cv_header_stdbool_h" = 1
-then	echo "$as_me:24050: result: yes" >&5
+then	echo "$as_me:25291: result: yes" >&5
 echo "${ECHO_T}yes" >&6
-else	echo "$as_me:24052: result: no" >&5
+else	echo "$as_me:25293: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
-echo "$as_me:24056: checking for builtin bool type" >&5
+echo "$as_me:25297: checking for builtin bool type" >&5
 echo $ECHO_N "checking for builtin bool type... $ECHO_C" >&6
 
 if test "${cf_cv_cc_bool_type+set}" = set; then
@@ -24061,7 +25302,7 @@ if test "${cf_cv_cc_bool_type+set}" = set; then
 else
 
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 24064 "configure"
+#line 25305 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -24070,22 +25311,22 @@ else
 int
 main (void)
 {
-bool x = false
+bool x = false; (void)x
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:24079: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:25320: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:24082: \$? = $ac_status" >&5
+  echo "$as_me:25323: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:24085: \"$ac_try\"") >&5
+  { (eval echo "$as_me:25326: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:24088: \$? = $ac_status" >&5
+  echo "$as_me:25329: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_cc_bool_type=1
 else
@@ -24098,9 +25339,9 @@ rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 fi
 
 if test "$cf_cv_cc_bool_type" = 1
-then	echo "$as_me:24101: result: yes" >&5
+then	echo "$as_me:25342: result: yes" >&5
 echo "${ECHO_T}yes" >&6
-else	echo "$as_me:24103: result: no" >&5
+else	echo "$as_me:25344: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -24117,10 +25358,10 @@ if test -n "$GXX" ; then
 
 	cf_save="$LIBS"
 	LIBS="$LIBS $CXXLIBS"
-	echo "$as_me:24120: checking if we already have C++ library" >&5
+	echo "$as_me:25361: checking if we already have C++ library" >&5
 echo $ECHO_N "checking if we already have C++ library... $ECHO_C" >&6
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 24123 "configure"
+#line 25364 "configure"
 #include "confdefs.h"
 
 			#include <iostream>
@@ -24134,16 +25375,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:24137: \"$ac_link\"") >&5
+if { (eval echo "$as_me:25378: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:24140: \$? = $ac_status" >&5
+  echo "$as_me:25381: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:24143: \"$ac_try\"") >&5
+  { (eval echo "$as_me:25384: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:24146: \$? = $ac_status" >&5
+  echo "$as_me:25387: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_have_libstdcpp=yes
 else
@@ -24152,7 +25393,7 @@ cat "conftest.$ac_ext" >&5
 cf_have_libstdcpp=no
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
-	echo "$as_me:24155: result: $cf_have_libstdcpp" >&5
+	echo "$as_me:25396: result: $cf_have_libstdcpp" >&5
 echo "${ECHO_T}$cf_have_libstdcpp" >&6
 	LIBS="$cf_save"
 
@@ -24171,7 +25412,7 @@ echo "${ECHO_T}$cf_have_libstdcpp" >&6
 			;;
 		esac
 
-		echo "$as_me:24174: checking for library $cf_stdcpp_libname" >&5
+		echo "$as_me:25415: checking for library $cf_stdcpp_libname" >&5
 echo $ECHO_N "checking for library $cf_stdcpp_libname... $ECHO_C" >&6
 if test "${cf_cv_libstdcpp+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -24197,7 +25438,7 @@ done
 LIBS="$cf_add_libs"
 
 		cat >"conftest.$ac_ext" <<_ACEOF
-#line 24200 "configure"
+#line 25441 "configure"
 #include "confdefs.h"
 
 				#include <iostream>
@@ -24211,16 +25452,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:24214: \"$ac_link\"") >&5
+if { (eval echo "$as_me:25455: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:24217: \$? = $ac_status" >&5
+  echo "$as_me:25458: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:24220: \"$ac_try\"") >&5
+  { (eval echo "$as_me:25461: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:24223: \$? = $ac_status" >&5
+  echo "$as_me:25464: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_libstdcpp=yes
 else
@@ -24232,7 +25473,7 @@ rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 			LIBS="$cf_save"
 
 fi
-echo "$as_me:24235: result: $cf_cv_libstdcpp" >&5
+echo "$as_me:25476: result: $cf_cv_libstdcpp" >&5
 echo "${ECHO_T}$cf_cv_libstdcpp" >&6
 		test "$cf_cv_libstdcpp" = yes && {
 cf_add_libs="$CXXLIBS"
@@ -24254,7 +25495,7 @@ CXXLIBS="$cf_add_libs"
 	fi
 fi
 
-	echo "$as_me:24257: checking whether $CXX understands -c and -o together" >&5
+	echo "$as_me:25498: checking whether $CXX understands -c and -o together" >&5
 echo $ECHO_N "checking whether $CXX understands -c and -o together... $ECHO_C" >&6
 if test "${cf_cv_prog_CXX_c_o+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -24269,15 +25510,15 @@ CF_EOF
 # We do the test twice because some compilers refuse to overwrite an
 # existing .o file with -o, though they will create one.
 ac_try='$CXX $CXXFLAGS $CPPFLAGS -c conftest.$ac_ext -o conftest2.$ac_objext >&5'
-if { (eval echo "$as_me:24272: \"$ac_try\"") >&5
+if { (eval echo "$as_me:25513: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:24275: \$? = $ac_status" >&5
+  echo "$as_me:25516: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
-  test -f conftest2.$ac_objext && { (eval echo "$as_me:24277: \"$ac_try\"") >&5
+  test -f conftest2.$ac_objext && { (eval echo "$as_me:25518: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:24280: \$? = $ac_status" >&5
+  echo "$as_me:25521: \$? = $ac_status" >&5
   (exit "$ac_status"); };
 then
   eval cf_cv_prog_CXX_c_o=yes
@@ -24288,10 +25529,10 @@ rm -rf ./conftest*
 
 fi
 if test "$cf_cv_prog_CXX_c_o" = yes; then
-  echo "$as_me:24291: result: yes" >&5
+  echo "$as_me:25532: result: yes" >&5
 echo "${ECHO_T}yes" >&6
 else
-  echo "$as_me:24294: result: no" >&5
+  echo "$as_me:25535: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -24311,7 +25552,7 @@ case "$cf_cv_system_name" in
 	;;
 esac
 if test "$GXX" = yes; then
-	echo "$as_me:24314: checking for lib$cf_gpp_libname" >&5
+	echo "$as_me:25555: checking for lib$cf_gpp_libname" >&5
 echo $ECHO_N "checking for lib$cf_gpp_libname... $ECHO_C" >&6
 	cf_save="$LIBS"
 
@@ -24332,7 +25573,7 @@ done
 LIBS="$cf_add_libs"
 
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 24335 "configure"
+#line 25576 "configure"
 #include "confdefs.h"
 
 #include <$cf_gpp_libname/builtin.h>
@@ -24346,16 +25587,16 @@ two_arg_error_handler_t foo2 = lib_error_handler
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:24349: \"$ac_link\"") >&5
+if { (eval echo "$as_me:25590: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:24352: \$? = $ac_status" >&5
+  echo "$as_me:25593: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:24355: \"$ac_try\"") >&5
+  { (eval echo "$as_me:25596: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:24358: \$? = $ac_status" >&5
+  echo "$as_me:25599: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cxx_library=yes
 
@@ -24392,7 +25633,7 @@ else
   echo "$as_me: failed program was:" >&5
 cat "conftest.$ac_ext" >&5
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 24395 "configure"
+#line 25636 "configure"
 #include "confdefs.h"
 
 #include <builtin.h>
@@ -24406,16 +25647,16 @@ two_arg_error_handler_t foo2 = lib_error_handler
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:24409: \"$ac_link\"") >&5
+if { (eval echo "$as_me:25650: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:24412: \$? = $ac_status" >&5
+  echo "$as_me:25653: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:24415: \"$ac_try\"") >&5
+  { (eval echo "$as_me:25656: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:24418: \$? = $ac_status" >&5
+  echo "$as_me:25659: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cxx_library=yes
 
@@ -24448,7 +25689,7 @@ rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 fi
 rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 	LIBS="$cf_save"
-	echo "$as_me:24451: result: $cf_cxx_library" >&5
+	echo "$as_me:25692: result: $cf_cxx_library" >&5
 echo "${ECHO_T}$cf_cxx_library" >&6
 fi
 
@@ -24464,7 +25705,7 @@ ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS "conftest.$ac_ext" >&5'
 ac_link='$CXX -o "conftest$ac_exeext" $CXXFLAGS $CPPFLAGS $LDFLAGS "conftest.$ac_ext" $LIBS >&5'
 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
 ac_main_return="return"
-echo "$as_me:24467: checking how to run the C++ preprocessor" >&5
+echo "$as_me:25708: checking how to run the C++ preprocessor" >&5
 echo $ECHO_N "checking how to run the C++ preprocessor... $ECHO_C" >&6
 if test -z "$CXXCPP"; then
   if test "${ac_cv_prog_CXXCPP+set}" = set; then
@@ -24481,18 +25722,18 @@ do
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp. "Syntax error" is here to catch this case.
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 24484 "configure"
+#line 25725 "configure"
 #include "confdefs.h"
 #include <assert.h>
                      Syntax error
 _ACEOF
-if { (eval echo "$as_me:24489: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+if { (eval echo "$as_me:25730: \"$ac_cpp "conftest.$ac_ext"\"") >&5
   (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:24495: \$? = $ac_status" >&5
+  echo "$as_me:25736: \$? = $ac_status" >&5
   (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_cxx_preproc_warn_flag
@@ -24515,17 +25756,17 @@ rm -f conftest.err "conftest.$ac_ext"
   # OK, works on sane cases.  Now check whether non-existent headers
   # can be detected and how.
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 24518 "configure"
+#line 25759 "configure"
 #include "confdefs.h"
 #include <ac_nonexistent.h>
 _ACEOF
-if { (eval echo "$as_me:24522: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+if { (eval echo "$as_me:25763: \"$ac_cpp "conftest.$ac_ext"\"") >&5
   (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:24528: \$? = $ac_status" >&5
+  echo "$as_me:25769: \$? = $ac_status" >&5
   (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_cxx_preproc_warn_flag
@@ -24562,7 +25803,7 @@ fi
 else
   ac_cv_prog_CXXCPP=$CXXCPP
 fi
-echo "$as_me:24565: result: $CXXCPP" >&5
+echo "$as_me:25806: result: $CXXCPP" >&5
 echo "${ECHO_T}$CXXCPP" >&6
 ac_preproc_ok=false
 for ac_cxx_preproc_warn_flag in '' yes
@@ -24572,18 +25813,18 @@ do
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp. "Syntax error" is here to catch this case.
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 24575 "configure"
+#line 25816 "configure"
 #include "confdefs.h"
 #include <assert.h>
                      Syntax error
 _ACEOF
-if { (eval echo "$as_me:24580: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+if { (eval echo "$as_me:25821: \"$ac_cpp "conftest.$ac_ext"\"") >&5
   (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:24586: \$? = $ac_status" >&5
+  echo "$as_me:25827: \$? = $ac_status" >&5
   (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_cxx_preproc_warn_flag
@@ -24606,17 +25847,17 @@ rm -f conftest.err "conftest.$ac_ext"
   # OK, works on sane cases.  Now check whether non-existent headers
   # can be detected and how.
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 24609 "configure"
+#line 25850 "configure"
 #include "confdefs.h"
 #include <ac_nonexistent.h>
 _ACEOF
-if { (eval echo "$as_me:24613: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+if { (eval echo "$as_me:25854: \"$ac_cpp "conftest.$ac_ext"\"") >&5
   (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:24619: \$? = $ac_status" >&5
+  echo "$as_me:25860: \$? = $ac_status" >&5
   (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_cxx_preproc_warn_flag
@@ -24644,7 +25885,7 @@ rm -f conftest.err "conftest.$ac_ext"
 if $ac_preproc_ok; then
   :
 else
-  { { echo "$as_me:24647: error: C++ preprocessor \"$CXXCPP\" fails sanity check" >&5
+  { { echo "$as_me:25888: error: C++ preprocessor \"$CXXCPP\" fails sanity check" >&5
 echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check" >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -24659,23 +25900,23 @@ ac_main_return="return"
 for ac_header in typeinfo
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:24662: checking for $ac_header" >&5
+echo "$as_me:25903: checking for $ac_header" >&5
 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 24668 "configure"
+#line 25909 "configure"
 #include "confdefs.h"
 #include <$ac_header>
 _ACEOF
-if { (eval echo "$as_me:24672: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+if { (eval echo "$as_me:25913: \"$ac_cpp "conftest.$ac_ext"\"") >&5
   (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:24678: \$? = $ac_status" >&5
+  echo "$as_me:25919: \$? = $ac_status" >&5
   (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_cxx_preproc_warn_flag
@@ -24694,7 +25935,7 @@ else
 fi
 rm -f conftest.err "conftest.$ac_ext"
 fi
-echo "$as_me:24697: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
+echo "$as_me:25938: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
 echo "${ECHO_T}`eval echo '${'"$as_ac_Header"'}'`" >&6
 if test "`eval echo '${'"$as_ac_Header"'}'`" = yes; then
   cat >>confdefs.h <<EOF
@@ -24707,23 +25948,23 @@ done
 for ac_header in iostream
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:24710: checking for $ac_header" >&5
+echo "$as_me:25951: checking for $ac_header" >&5
 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 24716 "configure"
+#line 25957 "configure"
 #include "confdefs.h"
 #include <$ac_header>
 _ACEOF
-if { (eval echo "$as_me:24720: \"$ac_cpp "conftest.$ac_ext"\"") >&5
+if { (eval echo "$as_me:25961: \"$ac_cpp "conftest.$ac_ext"\"") >&5
   (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   $EGREP -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:24726: \$? = $ac_status" >&5
+  echo "$as_me:25967: \$? = $ac_status" >&5
   (exit "$ac_status"); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_cxx_preproc_warn_flag
@@ -24742,7 +25983,7 @@ else
 fi
 rm -f conftest.err "conftest.$ac_ext"
 fi
-echo "$as_me:24745: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
+echo "$as_me:25986: result: `eval echo '${'"$as_ac_Header"'}'`" >&5
 echo "${ECHO_T}`eval echo '${'"$as_ac_Header"'}'`" >&6
 if test "`eval echo '${'"$as_ac_Header"'}'`" = yes; then
   cat >>confdefs.h <<EOF
@@ -24753,10 +25994,10 @@ fi
 done
 
 if test x"$ac_cv_header_iostream" = xyes ; then
-	echo "$as_me:24756: checking if iostream uses std-namespace" >&5
+	echo "$as_me:25997: checking if iostream uses std-namespace" >&5
 echo $ECHO_N "checking if iostream uses std-namespace... $ECHO_C" >&6
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 24759 "configure"
+#line 26000 "configure"
 #include "confdefs.h"
 
 #include <iostream>
@@ -24773,16 +26014,16 @@ cerr << "testing" << endl;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:24776: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:26017: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:24779: \$? = $ac_status" >&5
+  echo "$as_me:26020: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:24782: \"$ac_try\"") >&5
+  { (eval echo "$as_me:26023: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:24785: \$? = $ac_status" >&5
+  echo "$as_me:26026: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_iostream_namespace=yes
 else
@@ -24791,7 +26032,7 @@ cat "conftest.$ac_ext" >&5
 cf_iostream_namespace=no
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
-	echo "$as_me:24794: result: $cf_iostream_namespace" >&5
+	echo "$as_me:26035: result: $cf_iostream_namespace" >&5
 echo "${ECHO_T}$cf_iostream_namespace" >&6
 	if test "$cf_iostream_namespace" = yes ; then
 
@@ -24802,7 +26043,7 @@ EOF
 	fi
 fi
 
-echo "$as_me:24805: checking if we should include stdbool.h" >&5
+echo "$as_me:26046: checking if we should include stdbool.h" >&5
 echo $ECHO_N "checking if we should include stdbool.h... $ECHO_C" >&6
 
 if test "${cf_cv_header_stdbool_h+set}" = set; then
@@ -24810,35 +26051,35 @@ if test "${cf_cv_header_stdbool_h+set}" = set; then
 else
 
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 24813 "configure"
+#line 26054 "configure"
 #include "confdefs.h"
 
 int
 main (void)
 {
-bool foo = false
+bool foo = false; (void)foo
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:24825: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:26066: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:24828: \$? = $ac_status" >&5
+  echo "$as_me:26069: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:24831: \"$ac_try\"") >&5
+  { (eval echo "$as_me:26072: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:24834: \$? = $ac_status" >&5
+  echo "$as_me:26075: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_header_stdbool_h=0
 else
   echo "$as_me: failed program was:" >&5
 cat "conftest.$ac_ext" >&5
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 24841 "configure"
+#line 26082 "configure"
 #include "confdefs.h"
 
 #ifndef __BEOS__
@@ -24848,22 +26089,22 @@ cat >"conftest.$ac_ext" <<_ACEOF
 int
 main (void)
 {
-bool foo = false
+bool foo = false; (void)foo
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:24857: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:26098: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:24860: \$? = $ac_status" >&5
+  echo "$as_me:26101: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:24863: \"$ac_try\"") >&5
+  { (eval echo "$as_me:26104: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:24866: \$? = $ac_status" >&5
+  echo "$as_me:26107: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_header_stdbool_h=1
 else
@@ -24877,13 +26118,13 @@ rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 fi
 
 if test "$cf_cv_header_stdbool_h" = 1
-then	echo "$as_me:24880: result: yes" >&5
+then	echo "$as_me:26121: result: yes" >&5
 echo "${ECHO_T}yes" >&6
-else	echo "$as_me:24882: result: no" >&5
+else	echo "$as_me:26123: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
-echo "$as_me:24886: checking for builtin bool type" >&5
+echo "$as_me:26127: checking for builtin bool type" >&5
 echo $ECHO_N "checking for builtin bool type... $ECHO_C" >&6
 
 if test "${cf_cv_builtin_bool+set}" = set; then
@@ -24891,7 +26132,7 @@ if test "${cf_cv_builtin_bool+set}" = set; then
 else
 
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 24894 "configure"
+#line 26135 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -24900,22 +26141,22 @@ else
 int
 main (void)
 {
-bool x = false
+bool x = false; (void)x
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:24909: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:26150: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:24912: \$? = $ac_status" >&5
+  echo "$as_me:26153: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:24915: \"$ac_try\"") >&5
+  { (eval echo "$as_me:26156: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:24918: \$? = $ac_status" >&5
+  echo "$as_me:26159: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_builtin_bool=1
 else
@@ -24928,23 +26169,22 @@ rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 fi
 
 if test "$cf_cv_builtin_bool" = 1
-then	echo "$as_me:24931: result: yes" >&5
+then	echo "$as_me:26172: result: yes" >&5
 echo "${ECHO_T}yes" >&6
-else	echo "$as_me:24933: result: no" >&5
+else	echo "$as_me:26174: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
-echo "$as_me:24937: checking for bool" >&5
+echo "$as_me:26178: checking for bool" >&5
 echo $ECHO_N "checking for bool... $ECHO_C" >&6
 if test "${ac_cv_type_bool+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 24943 "configure"
+#line 26184 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
-#include <stdio.h>
+$ac_includes_default
 
 #if defined(__cplusplus)
 
@@ -24976,16 +26216,16 @@ if (sizeof (bool))
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:24979: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:26219: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:24982: \$? = $ac_status" >&5
+  echo "$as_me:26222: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:24985: \"$ac_try\"") >&5
+  { (eval echo "$as_me:26225: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:24988: \$? = $ac_status" >&5
+  echo "$as_me:26228: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_type_bool=yes
 else
@@ -24995,10 +26235,10 @@ ac_cv_type_bool=no
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 fi
-echo "$as_me:24998: result: $ac_cv_type_bool" >&5
+echo "$as_me:26238: result: $ac_cv_type_bool" >&5
 echo "${ECHO_T}$ac_cv_type_bool" >&6
 
-echo "$as_me:25001: checking size of bool" >&5
+echo "$as_me:26241: checking size of bool" >&5
 echo $ECHO_N "checking size of bool... $ECHO_C" >&6
 if test "${ac_cv_sizeof_bool+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -25007,11 +26247,10 @@ else
   if test "$cross_compiling" = yes; then
   # Depending upon the size, compute the lo and hi bounds.
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 25010 "configure"
+#line 26250 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
-#include <stdio.h>
+$ac_includes_default
 
 #if defined(__cplusplus)
 
@@ -25040,25 +26279,24 @@ int _array_ [1 - 2 * !((sizeof (bool)) >= 0)]
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:25043: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:26282: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:25046: \$? = $ac_status" >&5
+  echo "$as_me:26285: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:25049: \"$ac_try\"") >&5
+  { (eval echo "$as_me:26288: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:25052: \$? = $ac_status" >&5
+  echo "$as_me:26291: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_lo=0 ac_mid=0
   while :; do
     cat >"conftest.$ac_ext" <<_ACEOF
-#line 25057 "configure"
+#line 26296 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
-#include <stdio.h>
+$ac_includes_default
 
 #if defined(__cplusplus)
 
@@ -25087,16 +26325,16 @@ int _array_ [1 - 2 * !((sizeof (bool)) <= $ac_mid)]
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:25090: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:26328: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:25093: \$? = $ac_status" >&5
+  echo "$as_me:26331: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:25096: \"$ac_try\"") >&5
+  { (eval echo "$as_me:26334: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:25099: \$? = $ac_status" >&5
+  echo "$as_me:26337: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_hi=$ac_mid; break
 else
@@ -25112,11 +26350,10 @@ cat "conftest.$ac_ext" >&5
 ac_hi=-1 ac_mid=-1
   while :; do
     cat >"conftest.$ac_ext" <<_ACEOF
-#line 25115 "configure"
+#line 26353 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
-#include <stdio.h>
+$ac_includes_default
 
 #if defined(__cplusplus)
 
@@ -25145,16 +26382,16 @@ int _array_ [1 - 2 * !((sizeof (bool)) >= $ac_mid)]
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:25148: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:26385: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:25151: \$? = $ac_status" >&5
+  echo "$as_me:26388: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:25154: \"$ac_try\"") >&5
+  { (eval echo "$as_me:26391: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:25157: \$? = $ac_status" >&5
+  echo "$as_me:26394: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_lo=$ac_mid; break
 else
@@ -25170,11 +26407,10 @@ rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 while test "x$ac_lo" != "x$ac_hi"; do
   ac_mid=`expr '(' "$ac_hi" - "$ac_lo" ')' / 2 + "$ac_lo"`
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 25173 "configure"
+#line 26410 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
-#include <stdio.h>
+$ac_includes_default
 
 #if defined(__cplusplus)
 
@@ -25203,16 +26439,16 @@ int _array_ [1 - 2 * !((sizeof (bool)) <= $ac_mid)]
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:25206: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:26442: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:25209: \$? = $ac_status" >&5
+  echo "$as_me:26445: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:25212: \"$ac_try\"") >&5
+  { (eval echo "$as_me:26448: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:25215: \$? = $ac_status" >&5
+  echo "$as_me:26451: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_hi=$ac_mid
 else
@@ -25225,16 +26461,15 @@ done
 ac_cv_sizeof_bool=$ac_lo
 else
   if test "$cross_compiling" = yes; then
-  { { echo "$as_me:25228: error: cannot run test program while cross compiling" >&5
+  { { echo "$as_me:26464: error: cannot run test program while cross compiling" >&5
 echo "$as_me: error: cannot run test program while cross compiling" >&2;}
    { (exit 1); exit 1; }; }
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 25233 "configure"
+#line 26469 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
-#include <stdio.h>
+$ac_includes_default
 
 #if defined(__cplusplus)
 
@@ -25260,22 +26495,22 @@ main (void)
 FILE *f = fopen ("conftest.val", "w");
 if (!f)
   $ac_main_return (1);
-fprintf (f, "%d", (sizeof (bool)));
+fprintf (f, "%ld", (long)(sizeof (bool)));
 fclose (f);
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest$ac_exeext"
-if { (eval echo "$as_me:25270: \"$ac_link\"") >&5
+if { (eval echo "$as_me:26505: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:25273: \$? = $ac_status" >&5
+  echo "$as_me:26508: \$? = $ac_status" >&5
   (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
-  { (eval echo "$as_me:25275: \"$ac_try\"") >&5
+  { (eval echo "$as_me:26510: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:25278: \$? = $ac_status" >&5
+  echo "$as_me:26513: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_sizeof_bool=`cat conftest.val`
 else
@@ -25291,13 +26526,13 @@ else
   ac_cv_sizeof_bool=0
 fi
 fi
-echo "$as_me:25294: result: $ac_cv_sizeof_bool" >&5
+echo "$as_me:26529: result: $ac_cv_sizeof_bool" >&5
 echo "${ECHO_T}$ac_cv_sizeof_bool" >&6
 cat >>confdefs.h <<EOF
 #define SIZEOF_BOOL $ac_cv_sizeof_bool
 EOF
 
-echo "$as_me:25300: checking for type of bool" >&5
+echo "$as_me:26535: checking for type of bool" >&5
 echo $ECHO_N "checking for type of bool... $ECHO_C" >&6
 if test "${cf_cv_type_of_bool+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -25316,11 +26551,10 @@ else
 
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 25319 "configure"
+#line 26554 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
-#include <stdio.h>
+$ac_includes_default
 
 #if defined(__cplusplus)
 
@@ -25358,15 +26592,15 @@ int main(void)
 
 _ACEOF
 rm -f "conftest$ac_exeext"
-if { (eval echo "$as_me:25361: \"$ac_link\"") >&5
+if { (eval echo "$as_me:26595: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:25364: \$? = $ac_status" >&5
+  echo "$as_me:26598: \$? = $ac_status" >&5
   (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
-  { (eval echo "$as_me:25366: \"$ac_try\"") >&5
+  { (eval echo "$as_me:26600: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:25369: \$? = $ac_status" >&5
+  echo "$as_me:26603: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_type_of_bool=`cat cf_test.out`
 		 if test -z "$cf_cv_type_of_bool"; then
@@ -25383,19 +26617,19 @@ fi
 	rm -f cf_test.out
 
 fi
-echo "$as_me:25386: result: $cf_cv_type_of_bool" >&5
+echo "$as_me:26620: result: $cf_cv_type_of_bool" >&5
 echo "${ECHO_T}$cf_cv_type_of_bool" >&6
 
 if test "$cf_cv_type_of_bool" = unknown ; then
 	case .$NCURSES_BOOL in
 	(.auto|.) NCURSES_BOOL=unsigned;;
 	esac
-	{ echo "$as_me:25393: WARNING: Assuming $NCURSES_BOOL for type of bool" >&5
+	{ echo "$as_me:26627: WARNING: Assuming $NCURSES_BOOL for type of bool" >&5
 echo "$as_me: WARNING: Assuming $NCURSES_BOOL for type of bool" >&2;}
 	cf_cv_type_of_bool=$NCURSES_BOOL
 fi
 
-echo "$as_me:25398: checking for special defines needed for etip.h" >&5
+echo "$as_me:26632: checking for special defines needed for etip.h" >&5
 echo $ECHO_N "checking for special defines needed for etip.h... $ECHO_C" >&6
 cf_save_CXXFLAGS="$CXXFLAGS"
 cf_result="none"
@@ -25413,7 +26647,7 @@ do
 	test -n "$cf_math" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_math}"
 	test -n "$cf_excp" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_excp}"
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 25416 "configure"
+#line 26650 "configure"
 #include "confdefs.h"
 
 #include <etip.h.in>
@@ -25427,16 +26661,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:25430: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:26664: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:25433: \$? = $ac_status" >&5
+  echo "$as_me:26667: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:25436: \"$ac_try\"") >&5
+  { (eval echo "$as_me:26670: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:25439: \$? = $ac_status" >&5
+  echo "$as_me:26673: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
 
 	test -n "$cf_math" && cat >>confdefs.h <<EOF
@@ -25457,12 +26691,84 @@ fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 done
 done
-echo "$as_me:25460: result: $cf_result" >&5
-echo "${ECHO_T}$cf_result" >&6
+echo "$as_me:26694: result: ${cf_result:-(none)}" >&5
+echo "${ECHO_T}${cf_result:-(none)}" >&6
 CXXFLAGS="$cf_save_CXXFLAGS"
 
 if test -n "$CXX"; then
-echo "$as_me:25465: checking if $CXX accepts parameter initialization" >&5
+echo "$as_me:26699: checking if $CXX accepts override keyword" >&5
+echo $ECHO_N "checking if $CXX accepts override keyword... $ECHO_C" >&6
+if test "${cf_cv_cpp_override+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+	ac_ext=cc
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS "conftest.$ac_ext" >&5'
+ac_link='$CXX -o "conftest$ac_exeext" $CXXFLAGS $CPPFLAGS $LDFLAGS "conftest.$ac_ext" $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+ac_main_return="return"
+
+	if test "$cross_compiling" = yes; then
+  cf_cv_cpp_override=unknown
+else
+  cat >"conftest.$ac_ext" <<_ACEOF
+#line 26716 "configure"
+#include "confdefs.h"
+
+class base
+{
+public:
+	virtual int foo(float x) = 0;
+};
+
+class derived: public base
+{
+public:
+	int foo(float x) override { return x != 0.0 ? 1 : 0; }
+};
+
+int main(void) { }
+
+_ACEOF
+rm -f "conftest$ac_exeext"
+if { (eval echo "$as_me:26735: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:26738: \$? = $ac_status" >&5
+  (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
+  { (eval echo "$as_me:26740: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:26743: \$? = $ac_status" >&5
+  (exit "$ac_status"); }; }; then
+  cf_cv_cpp_override=yes
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+cat "conftest.$ac_ext" >&5
+cf_cv_cpp_override=no
+fi
+rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftest.$ac_ext"
+fi
+	ac_ext=cc
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS "conftest.$ac_ext" >&5'
+ac_link='$CXX -o "conftest$ac_exeext" $CXXFLAGS $CPPFLAGS $LDFLAGS "conftest.$ac_ext" $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+ac_main_return="return"
+
+fi
+echo "$as_me:26762: result: $cf_cv_cpp_override" >&5
+echo "${ECHO_T}$cf_cv_cpp_override" >&6
+fi
+test "$cf_cv_cpp_override" = yes &&
+cat >>confdefs.h <<\EOF
+#define CPP_HAS_OVERRIDE 1
+EOF
+
+if test -n "$CXX"; then
+echo "$as_me:26771: checking if $CXX accepts parameter initialization" >&5
 echo $ECHO_N "checking if $CXX accepts parameter initialization... $ECHO_C" >&6
 if test "${cf_cv_cpp_param_init+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -25479,7 +26785,7 @@ ac_main_return="return"
   cf_cv_cpp_param_init=unknown
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 25482 "configure"
+#line 26788 "configure"
 #include "confdefs.h"
 
 class TEST {
@@ -25498,15 +26804,15 @@ int main(void) { }
 
 _ACEOF
 rm -f "conftest$ac_exeext"
-if { (eval echo "$as_me:25501: \"$ac_link\"") >&5
+if { (eval echo "$as_me:26807: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:25504: \$? = $ac_status" >&5
+  echo "$as_me:26810: \$? = $ac_status" >&5
   (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
-  { (eval echo "$as_me:25506: \"$ac_try\"") >&5
+  { (eval echo "$as_me:26812: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:25509: \$? = $ac_status" >&5
+  echo "$as_me:26815: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_cpp_param_init=yes
 else
@@ -25525,7 +26831,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
 ac_main_return="return"
 
 fi
-echo "$as_me:25528: result: $cf_cv_cpp_param_init" >&5
+echo "$as_me:26834: result: $cf_cv_cpp_param_init" >&5
 echo "${ECHO_T}$cf_cv_cpp_param_init" >&6
 fi
 test "$cf_cv_cpp_param_init" = yes &&
@@ -25535,7 +26841,7 @@ EOF
 
 if test -n "$CXX"; then
 
-echo "$as_me:25538: checking if $CXX accepts static_cast" >&5
+echo "$as_me:26844: checking if $CXX accepts static_cast" >&5
 echo $ECHO_N "checking if $CXX accepts static_cast... $ECHO_C" >&6
 if test "${cf_cv_cpp_static_cast+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -25549,7 +26855,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
 ac_main_return="return"
 
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 25552 "configure"
+#line 26858 "configure"
 #include "confdefs.h"
 
 class NCursesPanel
@@ -25593,16 +26899,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:25596: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:26902: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:25599: \$? = $ac_status" >&5
+  echo "$as_me:26905: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:25602: \"$ac_try\"") >&5
+  { (eval echo "$as_me:26908: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:25605: \$? = $ac_status" >&5
+  echo "$as_me:26911: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_cpp_static_cast=yes
 else
@@ -25620,7 +26926,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
 ac_main_return="return"
 
 fi
-echo "$as_me:25623: result: $cf_cv_cpp_static_cast" >&5
+echo "$as_me:26929: result: $cf_cv_cpp_static_cast" >&5
 echo "${ECHO_T}$cf_cv_cpp_static_cast" >&6
 
 fi
@@ -25669,17 +26975,16 @@ else
 	else
 		if test "$cf_cv_header_stdbool_h" = 1 ; then
 
-echo "$as_me:25672: checking for bool" >&5
+echo "$as_me:26978: checking for bool" >&5
 echo $ECHO_N "checking for bool... $ECHO_C" >&6
 if test "${ac_cv_type_bool+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 25678 "configure"
+#line 26984 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
-#include <stdio.h>
+$ac_includes_default
 
 #if defined(__cplusplus)
 
@@ -25711,16 +27016,16 @@ if (sizeof (bool))
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:25714: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:27019: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:25717: \$? = $ac_status" >&5
+  echo "$as_me:27022: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:25720: \"$ac_try\"") >&5
+  { (eval echo "$as_me:27025: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:25723: \$? = $ac_status" >&5
+  echo "$as_me:27028: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_type_bool=yes
 else
@@ -25730,10 +27035,10 @@ ac_cv_type_bool=no
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 fi
-echo "$as_me:25733: result: $ac_cv_type_bool" >&5
+echo "$as_me:27038: result: $ac_cv_type_bool" >&5
 echo "${ECHO_T}$ac_cv_type_bool" >&6
 
-echo "$as_me:25736: checking size of bool" >&5
+echo "$as_me:27041: checking size of bool" >&5
 echo $ECHO_N "checking size of bool... $ECHO_C" >&6
 if test "${ac_cv_sizeof_bool+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -25742,11 +27047,10 @@ else
   if test "$cross_compiling" = yes; then
   # Depending upon the size, compute the lo and hi bounds.
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 25745 "configure"
+#line 27050 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
-#include <stdio.h>
+$ac_includes_default
 
 #if defined(__cplusplus)
 
@@ -25775,25 +27079,24 @@ int _array_ [1 - 2 * !((sizeof (bool)) >= 0)]
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:25778: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:27082: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:25781: \$? = $ac_status" >&5
+  echo "$as_me:27085: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:25784: \"$ac_try\"") >&5
+  { (eval echo "$as_me:27088: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:25787: \$? = $ac_status" >&5
+  echo "$as_me:27091: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_lo=0 ac_mid=0
   while :; do
     cat >"conftest.$ac_ext" <<_ACEOF
-#line 25792 "configure"
+#line 27096 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
-#include <stdio.h>
+$ac_includes_default
 
 #if defined(__cplusplus)
 
@@ -25822,16 +27125,16 @@ int _array_ [1 - 2 * !((sizeof (bool)) <= $ac_mid)]
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:25825: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:27128: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:25828: \$? = $ac_status" >&5
+  echo "$as_me:27131: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:25831: \"$ac_try\"") >&5
+  { (eval echo "$as_me:27134: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:25834: \$? = $ac_status" >&5
+  echo "$as_me:27137: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_hi=$ac_mid; break
 else
@@ -25847,11 +27150,10 @@ cat "conftest.$ac_ext" >&5
 ac_hi=-1 ac_mid=-1
   while :; do
     cat >"conftest.$ac_ext" <<_ACEOF
-#line 25850 "configure"
+#line 27153 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
-#include <stdio.h>
+$ac_includes_default
 
 #if defined(__cplusplus)
 
@@ -25880,16 +27182,16 @@ int _array_ [1 - 2 * !((sizeof (bool)) >= $ac_mid)]
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:25883: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:27185: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:25886: \$? = $ac_status" >&5
+  echo "$as_me:27188: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:25889: \"$ac_try\"") >&5
+  { (eval echo "$as_me:27191: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:25892: \$? = $ac_status" >&5
+  echo "$as_me:27194: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_lo=$ac_mid; break
 else
@@ -25905,11 +27207,10 @@ rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 while test "x$ac_lo" != "x$ac_hi"; do
   ac_mid=`expr '(' "$ac_hi" - "$ac_lo" ')' / 2 + "$ac_lo"`
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 25908 "configure"
+#line 27210 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
-#include <stdio.h>
+$ac_includes_default
 
 #if defined(__cplusplus)
 
@@ -25938,16 +27239,16 @@ int _array_ [1 - 2 * !((sizeof (bool)) <= $ac_mid)]
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:25941: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:27242: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:25944: \$? = $ac_status" >&5
+  echo "$as_me:27245: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:25947: \"$ac_try\"") >&5
+  { (eval echo "$as_me:27248: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:25950: \$? = $ac_status" >&5
+  echo "$as_me:27251: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_hi=$ac_mid
 else
@@ -25960,16 +27261,15 @@ done
 ac_cv_sizeof_bool=$ac_lo
 else
   if test "$cross_compiling" = yes; then
-  { { echo "$as_me:25963: error: cannot run test program while cross compiling" >&5
+  { { echo "$as_me:27264: error: cannot run test program while cross compiling" >&5
 echo "$as_me: error: cannot run test program while cross compiling" >&2;}
    { (exit 1); exit 1; }; }
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 25968 "configure"
+#line 27269 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
-#include <stdio.h>
+$ac_includes_default
 
 #if defined(__cplusplus)
 
@@ -25995,22 +27295,22 @@ main (void)
 FILE *f = fopen ("conftest.val", "w");
 if (!f)
   $ac_main_return (1);
-fprintf (f, "%d", (sizeof (bool)));
+fprintf (f, "%ld", (long)(sizeof (bool)));
 fclose (f);
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest$ac_exeext"
-if { (eval echo "$as_me:26005: \"$ac_link\"") >&5
+if { (eval echo "$as_me:27305: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:26008: \$? = $ac_status" >&5
+  echo "$as_me:27308: \$? = $ac_status" >&5
   (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
-  { (eval echo "$as_me:26010: \"$ac_try\"") >&5
+  { (eval echo "$as_me:27310: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:26013: \$? = $ac_status" >&5
+  echo "$as_me:27313: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_sizeof_bool=`cat conftest.val`
 else
@@ -26026,13 +27326,13 @@ else
   ac_cv_sizeof_bool=0
 fi
 fi
-echo "$as_me:26029: result: $ac_cv_sizeof_bool" >&5
+echo "$as_me:27329: result: $ac_cv_sizeof_bool" >&5
 echo "${ECHO_T}$ac_cv_sizeof_bool" >&6
 cat >>confdefs.h <<EOF
 #define SIZEOF_BOOL $ac_cv_sizeof_bool
 EOF
 
-echo "$as_me:26035: checking for type of bool" >&5
+echo "$as_me:27335: checking for type of bool" >&5
 echo $ECHO_N "checking for type of bool... $ECHO_C" >&6
 if test "${cf_cv_type_of_bool+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -26051,11 +27351,10 @@ else
 
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 26054 "configure"
+#line 27354 "configure"
 #include "confdefs.h"
 
-#include <stdlib.h>
-#include <stdio.h>
+$ac_includes_default
 
 #if defined(__cplusplus)
 
@@ -26093,15 +27392,15 @@ int main(void)
 
 _ACEOF
 rm -f "conftest$ac_exeext"
-if { (eval echo "$as_me:26096: \"$ac_link\"") >&5
+if { (eval echo "$as_me:27395: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:26099: \$? = $ac_status" >&5
+  echo "$as_me:27398: \$? = $ac_status" >&5
   (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
-  { (eval echo "$as_me:26101: \"$ac_try\"") >&5
+  { (eval echo "$as_me:27400: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:26104: \$? = $ac_status" >&5
+  echo "$as_me:27403: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   cf_cv_type_of_bool=`cat cf_test.out`
 		 if test -z "$cf_cv_type_of_bool"; then
@@ -26118,26 +27417,26 @@ fi
 	rm -f cf_test.out
 
 fi
-echo "$as_me:26121: result: $cf_cv_type_of_bool" >&5
+echo "$as_me:27420: result: $cf_cv_type_of_bool" >&5
 echo "${ECHO_T}$cf_cv_type_of_bool" >&6
 
 if test "$cf_cv_type_of_bool" = unknown ; then
 	case .$NCURSES_BOOL in
 	(.auto|.) NCURSES_BOOL=unsigned;;
 	esac
-	{ echo "$as_me:26128: WARNING: Assuming $NCURSES_BOOL for type of bool" >&5
+	{ echo "$as_me:27427: WARNING: Assuming $NCURSES_BOOL for type of bool" >&5
 echo "$as_me: WARNING: Assuming $NCURSES_BOOL for type of bool" >&2;}
 	cf_cv_type_of_bool=$NCURSES_BOOL
 fi
 
 		else
-			echo "$as_me:26134: checking for fallback type of bool" >&5
+			echo "$as_me:27433: checking for fallback type of bool" >&5
 echo $ECHO_N "checking for fallback type of bool... $ECHO_C" >&6
 			case "$host_cpu" in
 			(i?86)	cf_cv_type_of_bool=char	;;
 			(*)	cf_cv_type_of_bool=int	;;
 			esac
-			echo "$as_me:26140: result: $cf_cv_type_of_bool" >&5
+			echo "$as_me:27439: result: $cf_cv_type_of_bool" >&5
 echo "${ECHO_T}$cf_cv_type_of_bool" >&6
 		fi
 	fi
@@ -26166,7 +27465,7 @@ if test -f "${srcdir}/Ada95/Makefile.in" ; then
 
 	if test "$cf_with_ada" != "no" ; then
 		if test "$with_libtool" != "no"; then
-			{ echo "$as_me:26169: WARNING: libtool does not support Ada - disabling feature" >&5
+			{ echo "$as_me:27468: WARNING: libtool does not support Ada - disabling feature" >&5
 echo "$as_me: WARNING: libtool does not support Ada - disabling feature" >&2;}
 			cf_with_ada=no
 		fi
@@ -26183,7 +27482,7 @@ cf_upper_prog_gnat=`echo "${cf_prog_gnat}" | sed y%abcdefghijklmnopqrstuvwxyz./-
 	unset cf_TEMP_gnat
 	# Extract the first word of "$cf_prog_gnat", so it can be a program name with args.
 set dummy $cf_prog_gnat; ac_word=$2
-echo "$as_me:26186: checking for $ac_word" >&5
+echo "$as_me:27485: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_path_cf_TEMP_gnat+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -26200,7 +27499,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   if $as_executable_p "$ac_dir/$ac_word"; then
    ac_cv_path_cf_TEMP_gnat="$ac_dir/$ac_word"
-   echo "$as_me:26203: found $ac_dir/$ac_word" >&5
+   echo "$as_me:27502: found $ac_dir/$ac_word" >&5
    break
 fi
 done
@@ -26212,10 +27511,10 @@ fi
 cf_TEMP_gnat=$ac_cv_path_cf_TEMP_gnat
 
 if test -n "$cf_TEMP_gnat"; then
-  echo "$as_me:26215: result: $cf_TEMP_gnat" >&5
+  echo "$as_me:27514: result: $cf_TEMP_gnat" >&5
 echo "${ECHO_T}$cf_TEMP_gnat" >&6
 else
-  echo "$as_me:26218: result: no" >&5
+  echo "$as_me:27517: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -26225,7 +27524,7 @@ fi
 		unset cf_cv_gnat_version
 		unset cf_TEMP_gnat
 
-echo "$as_me:26228: checking for $cf_prog_gnat version" >&5
+echo "$as_me:27527: checking for $cf_prog_gnat version" >&5
 echo $ECHO_N "checking for $cf_prog_gnat version... $ECHO_C" >&6
 if test "${cf_cv_gnat_version+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -26236,7 +27535,7 @@ cf_cv_gnat_version=`$cf_prog_gnat --version 2>&1 | \
 	sed -e '2,$d' -e 's/[^0-9 \.]//g' -e 's/^[ ]*//' -e 's/ .*//'`
 
 fi
-echo "$as_me:26239: result: $cf_cv_gnat_version" >&5
+echo "$as_me:27538: result: $cf_cv_gnat_version" >&5
 echo "${ECHO_T}$cf_cv_gnat_version" >&6
 test -z "$cf_cv_gnat_version" && cf_cv_gnat_version=no
 eval cf_TEMP_gnat=$cf_cv_gnat_version; unset cf_cv_gnat_version
@@ -26265,7 +27564,7 @@ else
 			cd conftest.src
 			for cf_gprconfig in Ada C
 			do
-				echo "$as_me:26268: checking for gprconfig name for $cf_gprconfig" >&5
+				echo "$as_me:27567: checking for gprconfig name for $cf_gprconfig" >&5
 echo $ECHO_N "checking for gprconfig name for $cf_gprconfig... $ECHO_C" >&6
 				if test "$cf_gprconfig" = C
 				then
@@ -26284,10 +27583,10 @@ echo $ECHO_N "checking for gprconfig name for $cf_gprconfig... $ECHO_C" >&6
 				if test -n "$cf_gprconfig_value"
 				then
 					eval "cf_ada_config_$cf_gprconfig=$cf_gprconfig_value"
-					echo "$as_me:26287: result: $cf_gprconfig_value" >&5
+					echo "$as_me:27586: result: $cf_gprconfig_value" >&5
 echo "${ECHO_T}$cf_gprconfig_value" >&6
 				else
-					echo "$as_me:26290: result: missing" >&5
+					echo "$as_me:27589: result: missing" >&5
 echo "${ECHO_T}missing" >&6
 					cf_ada_config="#"
 					break
@@ -26300,7 +27599,7 @@ echo "${ECHO_T}missing" >&6
 	if test "x$cf_ada_config" != "x#"
 	then
 
-echo "$as_me:26303: checking for gnat version" >&5
+echo "$as_me:27602: checking for gnat version" >&5
 echo $ECHO_N "checking for gnat version... $ECHO_C" >&6
 if test "${cf_cv_gnat_version+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -26311,7 +27610,7 @@ cf_cv_gnat_version=`${cf_ada_make:-gnatmake} --version 2>&1 | \
 	sed -e '2,$d' -e 's/[^0-9 \.]//g' -e 's/^[ ]*//' -e 's/ .*//'`
 
 fi
-echo "$as_me:26314: result: $cf_cv_gnat_version" >&5
+echo "$as_me:27613: result: $cf_cv_gnat_version" >&5
 echo "${ECHO_T}$cf_cv_gnat_version" >&6
 test -z "$cf_cv_gnat_version" && cf_cv_gnat_version=no
 
@@ -26320,7 +27619,7 @@ case "$cf_cv_gnat_version" in
 	cf_cv_prog_gnat_correct=yes
 	;;
 (*)
-	{ echo "$as_me:26323: WARNING: Unsupported GNAT version $cf_cv_gnat_version. We require 3.11 or better. Disabling Ada95 binding." >&5
+	{ echo "$as_me:27622: WARNING: Unsupported GNAT version $cf_cv_gnat_version. We require 3.11 or better. Disabling Ada95 binding." >&5
 echo "$as_me: WARNING: Unsupported GNAT version $cf_cv_gnat_version. We require 3.11 or better. Disabling Ada95 binding." >&2;}
 	cf_cv_prog_gnat_correct=no
 	;;
@@ -26328,7 +27627,7 @@ esac
 
 		# Extract the first word of "m4", so it can be a program name with args.
 set dummy m4; ac_word=$2
-echo "$as_me:26331: checking for $ac_word" >&5
+echo "$as_me:27630: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_M4_exists+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -26343,7 +27642,7 @@ for ac_dir in $ac_dummy; do
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_M4_exists="yes"
-echo "$as_me:26346: found $ac_dir/$ac_word" >&5
+echo "$as_me:27645: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -26352,20 +27651,20 @@ fi
 fi
 M4_exists=$ac_cv_prog_M4_exists
 if test -n "$M4_exists"; then
-  echo "$as_me:26355: result: $M4_exists" >&5
+  echo "$as_me:27654: result: $M4_exists" >&5
 echo "${ECHO_T}$M4_exists" >&6
 else
-  echo "$as_me:26358: result: no" >&5
+  echo "$as_me:27657: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
 		if test "$ac_cv_prog_M4_exists" = no; then
 			cf_cv_prog_gnat_correct=no
-			{ echo "$as_me:26364: WARNING: Ada95 binding required program m4 not found. Ada95 binding disabled" >&5
+			{ echo "$as_me:27663: WARNING: Ada95 binding required program m4 not found. Ada95 binding disabled" >&5
 echo "$as_me: WARNING: Ada95 binding required program m4 not found. Ada95 binding disabled" >&2;}
 		fi
 		if test "$cf_cv_prog_gnat_correct" = yes; then
-			echo "$as_me:26368: checking if GNAT works" >&5
+			echo "$as_me:27667: checking if GNAT works" >&5
 echo $ECHO_N "checking if GNAT works... $ECHO_C" >&6
 
 rm -rf ./conftest* ./*~conftest*
@@ -26393,7 +27692,7 @@ else
 fi
 rm -rf ./conftest* ./*~conftest*
 
-			echo "$as_me:26396: result: $cf_cv_prog_gnat_correct" >&5
+			echo "$as_me:27695: result: $cf_cv_prog_gnat_correct" >&5
 echo "${ECHO_T}$cf_cv_prog_gnat_correct" >&6
 		fi
 	else
@@ -26405,7 +27704,7 @@ fi
 
  	ADAFLAGS="$ADAFLAGS -gnatpn"
 
-	echo "$as_me:26408: checking optimization options for ADAFLAGS" >&5
+	echo "$as_me:27707: checking optimization options for ADAFLAGS" >&5
 echo $ECHO_N "checking optimization options for ADAFLAGS... $ECHO_C" >&6
 	case "$CFLAGS" in
 	(*-g*)
@@ -26422,10 +27721,10 @@ echo $ECHO_N "checking optimization options for ADAFLAGS... $ECHO_C" >&6
 
 		;;
 	esac
-	echo "$as_me:26425: result: $ADAFLAGS" >&5
+	echo "$as_me:27724: result: $ADAFLAGS" >&5
 echo "${ECHO_T}$ADAFLAGS" >&6
 
-echo "$as_me:26428: checking if GNATPREP supports -T option" >&5
+echo "$as_me:27727: checking if GNATPREP supports -T option" >&5
 echo $ECHO_N "checking if GNATPREP supports -T option... $ECHO_C" >&6
 if test "${cf_cv_gnatprep_opt_t+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -26435,11 +27734,11 @@ cf_cv_gnatprep_opt_t=no
 gnatprep -T 2>/dev/null >/dev/null && cf_cv_gnatprep_opt_t=yes
 
 fi
-echo "$as_me:26438: result: $cf_cv_gnatprep_opt_t" >&5
+echo "$as_me:27737: result: $cf_cv_gnatprep_opt_t" >&5
 echo "${ECHO_T}$cf_cv_gnatprep_opt_t" >&6
 test "$cf_cv_gnatprep_opt_t" = yes && GNATPREP_OPTS="-T $GNATPREP_OPTS"
 
-echo "$as_me:26442: checking if GNAT supports generics" >&5
+echo "$as_me:27741: checking if GNAT supports generics" >&5
 echo $ECHO_N "checking if GNAT supports generics... $ECHO_C" >&6
 case "$cf_cv_gnat_version" in
 (3.1[1-9]*|3.[2-9]*|[4-9].*|[1-9][0-9].[0-9]*|20[0-9][0-9])
@@ -26449,7 +27748,7 @@ case "$cf_cv_gnat_version" in
 	cf_gnat_generics=no
 	;;
 esac
-echo "$as_me:26452: result: $cf_gnat_generics" >&5
+echo "$as_me:27751: result: $cf_gnat_generics" >&5
 echo "${ECHO_T}$cf_gnat_generics" >&6
 
 if test "$cf_gnat_generics" = yes
@@ -26461,7 +27760,7 @@ else
 	cf_generic_objects=
 fi
 
-echo "$as_me:26464: checking if GNAT supports SIGINT" >&5
+echo "$as_me:27763: checking if GNAT supports SIGINT" >&5
 echo $ECHO_N "checking if GNAT supports SIGINT... $ECHO_C" >&6
 if test "${cf_cv_gnat_sigint+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -26509,7 +27808,7 @@ fi
 rm -rf ./conftest* ./*~conftest*
 
 fi
-echo "$as_me:26512: result: $cf_cv_gnat_sigint" >&5
+echo "$as_me:27811: result: $cf_cv_gnat_sigint" >&5
 echo "${ECHO_T}$cf_cv_gnat_sigint" >&6
 
 if test "$cf_cv_gnat_sigint" = yes ; then
@@ -26522,7 +27821,7 @@ cf_gnat_libraries=no
 cf_gnat_projects=no
 
 if test "$enable_gnat_projects" != no ; then
-echo "$as_me:26525: checking if GNAT supports project files" >&5
+echo "$as_me:27824: checking if GNAT supports project files" >&5
 echo $ECHO_N "checking if GNAT supports project files... $ECHO_C" >&6
 case "$cf_cv_gnat_version" in
 (3.[0-9]*)
@@ -26585,15 +27884,15 @@ CF_EOF
 	esac
 	;;
 esac
-echo "$as_me:26588: result: $cf_gnat_projects" >&5
+echo "$as_me:27887: result: $cf_gnat_projects" >&5
 echo "${ECHO_T}$cf_gnat_projects" >&6
 fi # enable_gnat_projects
 
 if test "$cf_gnat_projects" = yes
 then
-	echo "$as_me:26594: checking if GNAT supports libraries" >&5
+	echo "$as_me:27893: checking if GNAT supports libraries" >&5
 echo $ECHO_N "checking if GNAT supports libraries... $ECHO_C" >&6
-	echo "$as_me:26596: result: $cf_gnat_libraries" >&5
+	echo "$as_me:27895: result: $cf_gnat_libraries" >&5
 echo "${ECHO_T}$cf_gnat_libraries" >&6
 fi
 
@@ -26613,7 +27912,7 @@ then
 	then
 		USE_GNAT_MAKE_GPR=""
 	else
-		{ echo "$as_me:26616: WARNING: use old makefile rules since tools are missing" >&5
+		{ echo "$as_me:27915: WARNING: use old makefile rules since tools are missing" >&5
 echo "$as_me: WARNING: use old makefile rules since tools are missing" >&2;}
 	fi
 fi
@@ -26625,8 +27924,8 @@ else
 	USE_GNAT_LIBRARIES="#"
 fi
 
-echo "$as_me:26628: checking for ada-compiler" >&5
-echo $ECHO_N "checking for ada-compiler... $ECHO_C" >&6
+echo "$as_me:27927: checking for Ada95 compiler" >&5
+echo $ECHO_N "checking for Ada95 compiler... $ECHO_C" >&6
 
 # Check whether --with-ada-compiler or --without-ada-compiler was given.
 if test "${with_ada_compiler+set}" = set; then
@@ -26636,13 +27935,13 @@ else
   cf_ada_compiler=gnatmake
 fi;
 
-echo "$as_me:26639: result: $cf_ada_compiler" >&5
+echo "$as_me:27938: result: $cf_ada_compiler" >&5
 echo "${ECHO_T}$cf_ada_compiler" >&6
 
 			cf_ada_package=terminal_interface
 
-echo "$as_me:26644: checking for ada-include" >&5
-echo $ECHO_N "checking for ada-include... $ECHO_C" >&6
+echo "$as_me:27943: checking for Ada95 include directory" >&5
+echo $ECHO_N "checking for Ada95 include directory... $ECHO_C" >&6
 
 # Check whether --with-ada-include or --without-ada-include was given.
 if test "${with_ada_include+set}" = set; then
@@ -26677,7 +27976,7 @@ case ".$withval" in
 	withval=`echo "$withval" | sed -e s%NONE%$cf_path_syntax%`
 	;;
 (*)
-	{ { echo "$as_me:26680: error: expected a pathname, not \"$withval\"" >&5
+	{ { echo "$as_me:27979: error: expected a pathname, not \"$withval\"" >&5
 echo "$as_me: error: expected a pathname, not \"$withval\"" >&2;}
    { (exit 1); exit 1; }; }
 	;;
@@ -26686,11 +27985,11 @@ esac
 fi
 eval ADA_INCLUDE="$withval"
 
-echo "$as_me:26689: result: $ADA_INCLUDE" >&5
+echo "$as_me:27988: result: $ADA_INCLUDE" >&5
 echo "${ECHO_T}$ADA_INCLUDE" >&6
 
-echo "$as_me:26692: checking for ada-objects" >&5
-echo $ECHO_N "checking for ada-objects... $ECHO_C" >&6
+echo "$as_me:27991: checking for Ada95 object directory" >&5
+echo $ECHO_N "checking for Ada95 object directory... $ECHO_C" >&6
 
 # Check whether --with-ada-objects or --without-ada-objects was given.
 if test "${with_ada_objects+set}" = set; then
@@ -26725,7 +28024,7 @@ case ".$withval" in
 	withval=`echo "$withval" | sed -e s%NONE%$cf_path_syntax%`
 	;;
 (*)
-	{ { echo "$as_me:26728: error: expected a pathname, not \"$withval\"" >&5
+	{ { echo "$as_me:28027: error: expected a pathname, not \"$withval\"" >&5
 echo "$as_me: error: expected a pathname, not \"$withval\"" >&2;}
    { (exit 1); exit 1; }; }
 	;;
@@ -26734,11 +28033,11 @@ esac
 fi
 eval ADA_OBJECTS="$withval"
 
-echo "$as_me:26737: result: $ADA_OBJECTS" >&5
+echo "$as_me:28036: result: $ADA_OBJECTS" >&5
 echo "${ECHO_T}$ADA_OBJECTS" >&6
 
-echo "$as_me:26740: checking if an Ada95 shared-library should be built" >&5
-echo $ECHO_N "checking if an Ada95 shared-library should be built... $ECHO_C" >&6
+echo "$as_me:28039: checking whether to build an Ada95 shared library" >&5
+echo $ECHO_N "checking whether to build an Ada95 shared library... $ECHO_C" >&6
 
 # Check whether --with-ada-sharedlib or --without-ada-sharedlib was given.
 if test "${with_ada_sharedlib+set}" = set; then
@@ -26747,19 +28046,25 @@ if test "${with_ada_sharedlib+set}" = set; then
 else
   with_ada_sharedlib=no
 fi;
-echo "$as_me:26750: result: $with_ada_sharedlib" >&5
-echo "${ECHO_T}$with_ada_sharedlib" >&6
+cf_ada_sharedlib_warn=no
 
 if test "x$with_ada_sharedlib" != xno
 then
 	if test "x$cf_gnat_projects" != xyes
 	then
-		{ echo "$as_me:26757: WARNING: disabling shared-library since GNAT projects are not supported" >&5
-echo "$as_me: WARNING: disabling shared-library since GNAT projects are not supported" >&2;}
 		with_ada_sharedlib=no
+		cf_ada_sharedlib_warn=yes
 	fi
 fi
 
+echo "$as_me:28060: result: $with_ada_sharedlib" >&5
+echo "${ECHO_T}$with_ada_sharedlib" >&6
+if test "x$cf_ada_sharedlib_warn" != xno
+then
+	{ echo "$as_me:28064: WARNING: disabling Ada95 shared library since GNAT projects are not supported" >&5
+echo "$as_me: WARNING: disabling Ada95 shared library since GNAT projects are not supported" >&2;}
+fi
+
 ADA_SHAREDLIB='lib$(LIB_NAME).so.1'
 MAKE_ADA_SHAREDLIB="#"
 
@@ -26774,8 +28079,8 @@ fi
 
 			# allow the Ada binding to be renamed
 
-echo "$as_me:26777: checking for ada-libname" >&5
-echo $ECHO_N "checking for ada-libname... $ECHO_C" >&6
+echo "$as_me:28082: checking for Ada95 curses library name" >&5
+echo $ECHO_N "checking for Ada95 curses library name... $ECHO_C" >&6
 
 # Check whether --with-ada-libname or --without-ada-libname was given.
 if test "${with_ada_libname+set}" = set; then
@@ -26790,7 +28095,7 @@ case "x$ADA_LIBNAME" in
 	;;
 esac
 
-echo "$as_me:26793: result: $ADA_LIBNAME" >&5
+echo "$as_me:28098: result: $ADA_LIBNAME" >&5
 echo "${ECHO_T}$ADA_LIBNAME" >&6
 
 		fi
@@ -26801,13 +28106,13 @@ fi
 
 # do this "late" to avoid conflict with header-checks
 if test "x$with_widec" = xyes ; then
-	echo "$as_me:26804: checking for wchar_t" >&5
+	echo "$as_me:28109: checking for wchar_t" >&5
 echo $ECHO_N "checking for wchar_t... $ECHO_C" >&6
 if test "${ac_cv_type_wchar_t+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 26810 "configure"
+#line 28115 "configure"
 #include "confdefs.h"
 $ac_includes_default
 int
@@ -26822,16 +28127,16 @@ if (sizeof (wchar_t))
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:26825: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:28130: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:26828: \$? = $ac_status" >&5
+  echo "$as_me:28133: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:26831: \"$ac_try\"") >&5
+  { (eval echo "$as_me:28136: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:26834: \$? = $ac_status" >&5
+  echo "$as_me:28139: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_type_wchar_t=yes
 else
@@ -26841,10 +28146,10 @@ ac_cv_type_wchar_t=no
 fi
 rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 fi
-echo "$as_me:26844: result: $ac_cv_type_wchar_t" >&5
+echo "$as_me:28149: result: $ac_cv_type_wchar_t" >&5
 echo "${ECHO_T}$ac_cv_type_wchar_t" >&6
 
-echo "$as_me:26847: checking size of wchar_t" >&5
+echo "$as_me:28152: checking size of wchar_t" >&5
 echo $ECHO_N "checking size of wchar_t... $ECHO_C" >&6
 if test "${ac_cv_sizeof_wchar_t+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -26853,7 +28158,7 @@ else
   if test "$cross_compiling" = yes; then
   # Depending upon the size, compute the lo and hi bounds.
 cat >"conftest.$ac_ext" <<_ACEOF
-#line 26856 "configure"
+#line 28161 "configure"
 #include "confdefs.h"
 $ac_includes_default
 int
@@ -26865,21 +28170,21 @@ int _array_ [1 - 2 * !((sizeof (wchar_t)) >= 0)]
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:26868: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:28173: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:26871: \$? = $ac_status" >&5
+  echo "$as_me:28176: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:26874: \"$ac_try\"") >&5
+  { (eval echo "$as_me:28179: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:26877: \$? = $ac_status" >&5
+  echo "$as_me:28182: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_lo=0 ac_mid=0
   while :; do
     cat >"conftest.$ac_ext" <<_ACEOF
-#line 26882 "configure"
+#line 28187 "configure"
 #include "confdefs.h"
 $ac_includes_default
 int
@@ -26891,16 +28196,16 @@ int _array_ [1 - 2 * !((sizeof (wchar_t)) <= $ac_mid)]
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:26894: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:28199: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:26897: \$? = $ac_status" >&5
+  echo "$as_me:28202: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:26900: \"$ac_try\"") >&5
+  { (eval echo "$as_me:28205: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:26903: \$? = $ac_status" >&5
+  echo "$as_me:28208: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_hi=$ac_mid; break
 else
@@ -26916,7 +28221,7 @@ cat "conftest.$ac_ext" >&5
 ac_hi=-1 ac_mid=-1
   while :; do
     cat >"conftest.$ac_ext" <<_ACEOF
-#line 26919 "configure"
+#line 28224 "configure"
 #include "confdefs.h"
 $ac_includes_default
 int
@@ -26928,16 +28233,16 @@ int _array_ [1 - 2 * !((sizeof (wchar_t)) >= $ac_mid)]
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:26931: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:28236: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:26934: \$? = $ac_status" >&5
+  echo "$as_me:28239: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:26937: \"$ac_try\"") >&5
+  { (eval echo "$as_me:28242: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:26940: \$? = $ac_status" >&5
+  echo "$as_me:28245: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_lo=$ac_mid; break
 else
@@ -26953,7 +28258,7 @@ rm -f "conftest.$ac_objext" "conftest.$ac_ext"
 while test "x$ac_lo" != "x$ac_hi"; do
   ac_mid=`expr '(' "$ac_hi" - "$ac_lo" ')' / 2 + "$ac_lo"`
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 26956 "configure"
+#line 28261 "configure"
 #include "confdefs.h"
 $ac_includes_default
 int
@@ -26965,16 +28270,16 @@ int _array_ [1 - 2 * !((sizeof (wchar_t)) <= $ac_mid)]
 }
 _ACEOF
 rm -f "conftest.$ac_objext"
-if { (eval echo "$as_me:26968: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:28273: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:26971: \$? = $ac_status" >&5
+  echo "$as_me:28276: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest.$ac_objext"'
-  { (eval echo "$as_me:26974: \"$ac_try\"") >&5
+  { (eval echo "$as_me:28279: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:26977: \$? = $ac_status" >&5
+  echo "$as_me:28282: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_hi=$ac_mid
 else
@@ -26987,12 +28292,12 @@ done
 ac_cv_sizeof_wchar_t=$ac_lo
 else
   if test "$cross_compiling" = yes; then
-  { { echo "$as_me:26990: error: cannot run test program while cross compiling" >&5
+  { { echo "$as_me:28295: error: cannot run test program while cross compiling" >&5
 echo "$as_me: error: cannot run test program while cross compiling" >&2;}
    { (exit 1); exit 1; }; }
 else
   cat >"conftest.$ac_ext" <<_ACEOF
-#line 26995 "configure"
+#line 28300 "configure"
 #include "confdefs.h"
 $ac_includes_default
 int
@@ -27001,22 +28306,22 @@ main (void)
 FILE *f = fopen ("conftest.val", "w");
 if (!f)
   $ac_main_return (1);
-fprintf (f, "%d", (sizeof (wchar_t)));
+fprintf (f, "%ld", (long)(sizeof (wchar_t)));
 fclose (f);
   ;
   return 0;
 }
 _ACEOF
 rm -f "conftest$ac_exeext"
-if { (eval echo "$as_me:27011: \"$ac_link\"") >&5
+if { (eval echo "$as_me:28316: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:27014: \$? = $ac_status" >&5
+  echo "$as_me:28319: \$? = $ac_status" >&5
   (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"'
-  { (eval echo "$as_me:27016: \"$ac_try\"") >&5
+  { (eval echo "$as_me:28321: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:27019: \$? = $ac_status" >&5
+  echo "$as_me:28324: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
   ac_cv_sizeof_wchar_t=`cat conftest.val`
 else
@@ -27032,7 +28337,7 @@ else
   ac_cv_sizeof_wchar_t=0
 fi
 fi
-echo "$as_me:27035: result: $ac_cv_sizeof_wchar_t" >&5
+echo "$as_me:28340: result: $ac_cv_sizeof_wchar_t" >&5
 echo "${ECHO_T}$ac_cv_sizeof_wchar_t" >&6
 cat >>confdefs.h <<EOF
 #define SIZEOF_WCHAR_T $ac_cv_sizeof_wchar_t
@@ -27045,7 +28350,7 @@ EOF
 	then
 		test -n "$verbose" && echo "	test failed (assume 2)" 1>&6
 
-echo "${as_me:-configure}:27048: testing test failed (assume 2) ..." 1>&5
+echo "${as_me:-configure}:28353: testing test failed (assume 2) ..." 1>&5
 
 		sed /SIZEOF_WCHAR_T/d confdefs.h >confdefs.tmp
 		mv confdefs.tmp confdefs.h
@@ -27063,7 +28368,7 @@ fi
 ### chooses to split module lists into libraries.
 ###
 ### (see CF_LIB_RULES).
-echo "$as_me:27066: checking for library subsets" >&5
+echo "$as_me:28371: checking for library subsets" >&5
 echo $ECHO_N "checking for library subsets... $ECHO_C" >&6
 LIB_SUBSETS=
 
@@ -27117,7 +28422,7 @@ fi
 test "x$with_widec"     = xyes && LIB_SUBSETS="${LIB_SUBSETS}+widechar"
 test "x$with_ext_funcs" = xyes && LIB_SUBSETS="${LIB_SUBSETS}+ext_funcs"
 
-echo "$as_me:27120: result: $LIB_SUBSETS" >&5
+echo "$as_me:28425: result: $LIB_SUBSETS" >&5
 echo "${ECHO_T}$LIB_SUBSETS" >&6
 
 ### Construct the list of include-directories to be generated
@@ -27148,7 +28453,7 @@ elif test "$includedir" != "/usr/include"; then
 fi
 
 ### Build up pieces for makefile rules
-echo "$as_me:27151: checking default library suffix" >&5
+echo "$as_me:28456: checking default library suffix" >&5
 echo $ECHO_N "checking default library suffix... $ECHO_C" >&6
 
 	case $DFT_LWR_MODEL in
@@ -27159,10 +28464,10 @@ echo $ECHO_N "checking default library suffix... $ECHO_C" >&6
 	(shared)  DFT_ARG_SUFFIX=''   ;;
 	esac
 	test -n "$LIB_SUFFIX" && DFT_ARG_SUFFIX="${LIB_SUFFIX}${DFT_ARG_SUFFIX}"
-echo "$as_me:27162: result: $DFT_ARG_SUFFIX" >&5
+echo "$as_me:28467: result: $DFT_ARG_SUFFIX" >&5
 echo "${ECHO_T}$DFT_ARG_SUFFIX" >&6
 
-echo "$as_me:27165: checking default library-dependency suffix" >&5
+echo "$as_me:28470: checking default library-dependency suffix" >&5
 echo $ECHO_N "checking default library-dependency suffix... $ECHO_C" >&6
 
 	case X$DFT_LWR_MODEL in
@@ -27245,10 +28550,10 @@ echo $ECHO_N "checking default library-dependency suffix... $ECHO_C" >&6
 		DFT_LIB_SUFFIX="${LIB_SUFFIX}${EXTRA_SUFFIX}${DFT_LIB_SUFFIX}"
 		DFT_DEP_SUFFIX="${LIB_SUFFIX}${EXTRA_SUFFIX}${DFT_DEP_SUFFIX}"
 	fi
-echo "$as_me:27248: result: $DFT_DEP_SUFFIX" >&5
+echo "$as_me:28553: result: $DFT_DEP_SUFFIX" >&5
 echo "${ECHO_T}$DFT_DEP_SUFFIX" >&6
 
-echo "$as_me:27251: checking default object directory" >&5
+echo "$as_me:28556: checking default object directory" >&5
 echo $ECHO_N "checking default object directory... $ECHO_C" >&6
 
 	case $DFT_LWR_MODEL in
@@ -27264,11 +28569,11 @@ echo $ECHO_N "checking default object directory... $ECHO_C" >&6
 			DFT_OBJ_SUBDIR='obj_s' ;;
 		esac
 	esac
-echo "$as_me:27267: result: $DFT_OBJ_SUBDIR" >&5
+echo "$as_me:28572: result: $DFT_OBJ_SUBDIR" >&5
 echo "${ECHO_T}$DFT_OBJ_SUBDIR" >&6
 
 if test "x$cf_with_cxx" = xyes ; then
-echo "$as_me:27271: checking c++ library-dependency suffix" >&5
+echo "$as_me:28576: checking c++ library-dependency suffix" >&5
 echo $ECHO_N "checking c++ library-dependency suffix... $ECHO_C" >&6
 if test "$with_libtool" != "no"; then
 	# libtool thinks it can make c++ shared libraries (perhaps only g++)
@@ -27361,7 +28666,7 @@ else
 	fi
 
 fi
-echo "$as_me:27364: result: $CXX_LIB_SUFFIX" >&5
+echo "$as_me:28669: result: $CXX_LIB_SUFFIX" >&5
 echo "${ECHO_T}$CXX_LIB_SUFFIX" >&6
 
 fi
@@ -27537,19 +28842,19 @@ fi
 
 if test -n "$LDFLAGS_STATIC" && test -n "$LDFLAGS_SHARED"
 then
-	echo "$as_me:27540: checking if linker supports switching between static/dynamic" >&5
+	echo "$as_me:28845: checking if linker supports switching between static/dynamic" >&5
 echo $ECHO_N "checking if linker supports switching between static/dynamic... $ECHO_C" >&6
 
 	rm -f libconftest.a
 	cat >conftest.$ac_ext <<EOF
-#line 27545 "configure"
+#line 28850 "configure"
 #include <stdio.h>
 int cf_ldflags_static(FILE *fp) { return fflush(fp); }
 EOF
-	if { (eval echo "$as_me:27549: \"$ac_compile\"") >&5
+	if { (eval echo "$as_me:28854: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:27552: \$? = $ac_status" >&5
+  echo "$as_me:28857: \$? = $ac_status" >&5
   (exit "$ac_status"); } ; then
 		( $AR $ARFLAGS libconftest.a conftest.o ) 2>&5 1>/dev/null
 		( eval $RANLIB libconftest.a ) 2>&5 >/dev/null
@@ -27560,10 +28865,10 @@ EOF
 
 	LIBS="$LDFLAGS_STATIC -L`pwd` -lconftest $LDFLAGS_DYNAMIC $LIBS"
 	cat >"conftest.$ac_ext" <<_ACEOF
-#line 27563 "configure"
+#line 28868 "configure"
 #include "confdefs.h"
 
-#line 27566 "configure"
+#line 28871 "configure"
 #include <stdio.h>
 int cf_ldflags_static(FILE *fp);
 
@@ -27578,16 +28883,16 @@ main (void)
 }
 _ACEOF
 rm -f "conftest.$ac_objext" "conftest$ac_exeext"
-if { (eval echo "$as_me:27581: \"$ac_link\"") >&5
+if { (eval echo "$as_me:28886: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:27584: \$? = $ac_status" >&5
+  echo "$as_me:28889: \$? = $ac_status" >&5
   (exit "$ac_status"); } &&
          { ac_try='test -s "conftest$ac_exeext"'
-  { (eval echo "$as_me:27587: \"$ac_try\"") >&5
+  { (eval echo "$as_me:28892: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:27590: \$? = $ac_status" >&5
+  echo "$as_me:28895: \$? = $ac_status" >&5
   (exit "$ac_status"); }; }; then
 
 	# some linkers simply ignore the -dynamic
@@ -27610,7 +28915,7 @@ rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext"
 	rm -f libconftest.*
 	LIBS="$cf_save_LIBS"
 
-	echo "$as_me:27613: result: $cf_ldflags_static" >&5
+	echo "$as_me:28918: result: $cf_ldflags_static" >&5
 echo "${ECHO_T}$cf_ldflags_static" >&6
 
 	if test "$cf_ldflags_static" != yes
@@ -27626,7 +28931,7 @@ fi
 	;;
 esac
 
-echo "$as_me:27629: checking where we will install curses.h" >&5
+echo "$as_me:28934: checking where we will install curses.h" >&5
 echo $ECHO_N "checking where we will install curses.h... $ECHO_C" >&6
 
 includesubdir=
@@ -27636,7 +28941,7 @@ if test "$with_overwrite" = no && \
 then
 	includesubdir="/ncurses${USE_LIB_SUFFIX}"
 fi
-echo "$as_me:27639: result: ${includedir}${includesubdir}" >&5
+echo "$as_me:28944: result: ${includedir}${includesubdir}" >&5
 echo "${ECHO_T}${includedir}${includesubdir}" >&6
 
 ### Resolve a conflict between normal and wide-curses by forcing applications
@@ -27644,7 +28949,7 @@ echo "${ECHO_T}${includedir}${includesubdir}" >&6
 if test "$with_overwrite" != no ; then
 if test "$NCURSES_LIBUTF8" = 1 ; then
 	NCURSES_LIBUTF8='defined(HAVE_LIBUTF8_H)'
-	{ echo "$as_me:27647: WARNING: Wide-character applications must define HAVE_LIBUTF8_H to include curses.h" >&5
+	{ echo "$as_me:28952: WARNING: Wide-character applications must define HAVE_LIBUTF8_H to include curses.h" >&5
 echo "$as_me: WARNING: Wide-character applications must define HAVE_LIBUTF8_H to include curses.h" >&2;}
 fi
 fi
@@ -27661,9 +28966,6 @@ case "$cf_cv_system_name" in
 *)	;;
 esac
 
-# used to separate tack out of the tree
-NCURSES_TREE=
-
 ### predefined stuff for the test programs
 
 cat >>confdefs.h <<\EOF
@@ -27672,7 +28974,7 @@ EOF
 
 # pkgsrc uses these
 
-echo "$as_me:27675: checking for desired basename for form library" >&5
+echo "$as_me:28977: checking for desired basename for form library" >&5
 echo $ECHO_N "checking for desired basename for form library... $ECHO_C" >&6
 
 # Check whether --with-form-libname or --without-form-libname was given.
@@ -27692,10 +28994,10 @@ case "x$FORM_NAME" in
 	;;
 esac
 
-echo "$as_me:27695: result: $FORM_NAME" >&5
+echo "$as_me:28997: result: $FORM_NAME" >&5
 echo "${ECHO_T}$FORM_NAME" >&6
 
-echo "$as_me:27698: checking for desired basename for menu library" >&5
+echo "$as_me:29000: checking for desired basename for menu library" >&5
 echo $ECHO_N "checking for desired basename for menu library... $ECHO_C" >&6
 
 # Check whether --with-menu-libname or --without-menu-libname was given.
@@ -27715,10 +29017,10 @@ case "x$MENU_NAME" in
 	;;
 esac
 
-echo "$as_me:27718: result: $MENU_NAME" >&5
+echo "$as_me:29020: result: $MENU_NAME" >&5
 echo "${ECHO_T}$MENU_NAME" >&6
 
-echo "$as_me:27721: checking for desired basename for panel library" >&5
+echo "$as_me:29023: checking for desired basename for panel library" >&5
 echo $ECHO_N "checking for desired basename for panel library... $ECHO_C" >&6
 
 # Check whether --with-panel-libname or --without-panel-libname was given.
@@ -27738,10 +29040,10 @@ case "x$PANEL_NAME" in
 	;;
 esac
 
-echo "$as_me:27741: result: $PANEL_NAME" >&5
+echo "$as_me:29043: result: $PANEL_NAME" >&5
 echo "${ECHO_T}$PANEL_NAME" >&6
 
-echo "$as_me:27744: checking for desired basename for cxx library" >&5
+echo "$as_me:29046: checking for desired basename for cxx library" >&5
 echo $ECHO_N "checking for desired basename for cxx library... $ECHO_C" >&6
 
 # Check whether --with-cxx-libname or --without-cxx-libname was given.
@@ -27761,13 +29063,13 @@ case "x$CXX_NAME" in
 	;;
 esac
 
-echo "$as_me:27764: result: $CXX_NAME" >&5
+echo "$as_me:29066: result: $CXX_NAME" >&5
 echo "${ECHO_T}$CXX_NAME" >&6
 
 ### Construct the list of subdirectories for which we'll customize makefiles
 ### with the appropriate compile-rules.
 
-echo "$as_me:27770: checking for src modules" >&5
+echo "$as_me:29072: checking for src modules" >&5
 echo $ECHO_N "checking for src modules... $ECHO_C" >&6
 
 # dependencies and linker-arguments for test-programs
@@ -27787,14 +29089,6 @@ for cf_dir in $modules_to_build
 do
 	if test -f "$srcdir/$cf_dir/modules" ; then
 
-		# We may/may not have tack in the distribution, though the
-		# makefile is.
-		if test "$cf_dir" = tack ; then
-			if test "x$cf_with_tack" != "xyes"; then
-				continue
-			fi
-		fi
-
 		if test -z "$cf_cv_src_modules"; then
 			cf_cv_src_modules=$cf_dir
 		else
@@ -27805,9 +29099,7 @@ do
 		# well.  These are header files that are the same name as their
 		# directory.  Ncurses is the only library that does not follow
 		# that pattern.
-		if test "$cf_dir" = tack ; then
-			continue
-		elif test -f "$srcdir/${cf_dir}/${cf_dir}.h" ; then
+		if test -f "$srcdir/${cf_dir}/${cf_dir}.h" ; then
 
 cf_have_include=`echo "$cf_dir" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
 
@@ -27836,7 +29128,7 @@ eval TEST_ROOT="\$${cf_map_lib_basename}_NAME"
 		fi
 	fi
 done
-echo "$as_me:27839: result: $cf_cv_src_modules" >&5
+echo "$as_me:29131: result: $cf_cv_src_modules" >&5
 echo "${ECHO_T}$cf_cv_src_modules" >&6
 
 TEST_ARGS="-L${LIB_DIR} $TEST_ARGS"
@@ -27997,7 +29289,7 @@ case "$cf_cv_system_name" in
 	(*-D_XOPEN_SOURCE_EXTENDED*)
 		test -n "$verbose" && echo "	moving _XOPEN_SOURCE_EXTENDED to work around g++ problem" 1>&6
 
-echo "${as_me:-configure}:28000: testing moving _XOPEN_SOURCE_EXTENDED to work around g++ problem ..." 1>&5
+echo "${as_me:-configure}:29292: testing moving _XOPEN_SOURCE_EXTENDED to work around g++ problem ..." 1>&5
 
 		CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED"
 		CPPFLAGS=`echo "x$CPPFLAGS" | sed -e  's/^.//' -e 's/-D_XOPEN_SOURCE_EXTENDED//'`
@@ -28008,8 +29300,8 @@ esac
 
 # Help to automatically enable the extended curses features when using either
 # the *-config or the ".pc" files by adding defines.
-echo "$as_me:28011: checking for defines to add to ncurses${USE_CFG_SUFFIX}-config script" >&5
-echo $ECHO_N "checking for defines to add to ncurses${USE_CFG_SUFFIX}-config script... $ECHO_C" >&6
+echo "$as_me:29303: checking for defines to add to ncurses${USE_CFG_SUFFIX}${cf_config_suffix}-config script" >&5
+echo $ECHO_N "checking for defines to add to ncurses${USE_CFG_SUFFIX}${cf_config_suffix}-config script... $ECHO_C" >&6
 PKG_CFLAGS=
 for cf_loop1 in $CPPFLAGS_after_XOPEN
 do
@@ -28024,7 +29316,7 @@ do
 	done
 	test "$cf_found" = no && PKG_CFLAGS="$PKG_CFLAGS $cf_loop1"
 done
-echo "$as_me:28027: result: $PKG_CFLAGS" >&5
+echo "$as_me:29319: result: $PKG_CFLAGS" >&5
 echo "${ECHO_T}$PKG_CFLAGS" >&6
 
 # AC_CHECK_SIZEOF demands a literal parameter, no variables.  So we do this.
@@ -28083,9 +29375,9 @@ cf_filter_syms=no
 if test -n "$RESULTING_SYMS"
 then
 	cf_filter_syms=$cf_dft_filter_syms
-	test -n "$verbose" && echo "	will map symbols to ABI=$cf_cv_abi_version" 1>&6
+	test -n "$verbose" && echo "	will map symbols to ABI=$cf_cv_abi_default" 1>&6
 
-echo "${as_me:-configure}:28088: testing will map symbols to ABI=$cf_cv_abi_version ..." 1>&5
+echo "${as_me:-configure}:29380: testing will map symbols to ABI=$cf_cv_abi_default ..." 1>&5
 
 fi
 
@@ -28112,7 +29404,7 @@ fi
 
 # This is used for the *-config script and *.pc data files.
 
-echo "$as_me:28115: checking for linker search path" >&5
+echo "$as_me:29407: checking for linker search path" >&5
 echo $ECHO_N "checking for linker search path... $ECHO_C" >&6
 if test "${cf_cv_ld_searchpath+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -28121,19 +29413,19 @@ else
 if test "$cross_compiling" != yes ; then
 
 # GNU binutils' ld does not involve permissions which may stop ldconfig.
-cf_pathlist=`ld --verbose 2>/dev/null | grep SEARCH_DIR | sed -e 's,SEARCH_DIR[("=][("=]*,,g' -e 's/"[)];//gp' | sort -u`
+cf_pathlist=`${LD:-ld} --verbose 2>/dev/null | grep SEARCH_DIR | sed -e 's,SEARCH_DIR[("=][("=]*,,g' -e 's/"[)];//gp' | sort -u`
 
 # The -NX options tell newer versions of Linux ldconfig to not attempt to
 # update the cache, which makes it run faster.
 test -z "$cf_pathlist" && \
-	cf_pathlist=`ldconfig -NX -v 2>/dev/null | sed -e '/^[ 	]/d' -e 's/:$//' | sort -u`
+	cf_pathlist=`(ldconfig -NX -v) 2>/dev/null | sed -e '/^[ 	]/d' -e 's/:$//' | sort -u`
 
 test -z "$cf_pathlist" &&
-	cf_pathlist=`ldconfig -v 2>/dev/null | sed -n -e '/^[ 	]/d' -e 's/:$//p' | sort -u`
+	cf_pathlist=`(ldconfig -v) 2>/dev/null | sed -n -e '/^[ 	]/d' -e 's/:$//p' | sort -u`
 
 # This works with OpenBSD 6.5, which lists only filenames
 test -z "$cf_pathlist" &&
-	cf_pathlist=`ldconfig -v 2>/dev/null | sed -n -e 's,^Adding \(.*\)/.*$,\1,p' | sort -u`
+	cf_pathlist=`(ldconfig -v) 2>/dev/null | sed -n -e 's,^Adding \(.*\)/.*$,\1,p' | sort -u`
 
 if test -z "$cf_pathlist"
 then
@@ -28148,13 +29440,38 @@ fi
 
 if test -z "$cf_pathlist"
 then
-	# Solaris is hardcoded
-	if test -d /opt/SUNWspro/lib
+	# Solaris is "SunOS"
+	if test -f /usr/bin/isainfo && test "x`uname -s`" = xSunOS
 	then
-		cf_pathlist="/opt/SUNWspro/lib /usr/ccs/lib /usr/lib"
-	elif test -d /usr/ccs/lib
+		case x`(isainfo -b)` in
+		(x64)
+			cf_pathlist="$cf_pathlist /lib/64 /usr/lib/64"
+			;;
+		(x32)
+			test -d /usr/ccs/lib && cf_pathlist="$cf_pathlist /usr/ccs/lib"
+			cf_pathlist="$cf_pathlist /lib /usr/lib"
+			;;
+		(*)
+			{ echo "$as_me:29455: WARNING: problem with Solaris architecture" >&5
+echo "$as_me: WARNING: problem with Solaris architecture" >&2;}
+			;;
+		esac
+	fi
+fi
+
+if test -z "$cf_pathlist"
+then
+	# HP-UX
+	if test x"`uname -s`" = xHP-UX
 	then
-		cf_pathlist="/usr/ccs/lib /usr/lib"
+		case x`getconf LONG_BIT` in
+		(x64)
+			cf_pathlist="/usr/lib/hpux64"
+			;;
+		(x*)
+			cf_pathlist="/usr/lib/hpux32"
+			;;
+		esac
 	fi
 fi
 
@@ -28176,16 +29493,12 @@ done
 test -z "$cf_cv_ld_searchpath" && cf_cv_ld_searchpath=/usr/lib
 
 fi
-echo "$as_me:28179: result: $cf_cv_ld_searchpath" >&5
+echo "$as_me:29496: result: $cf_cv_ld_searchpath" >&5
 echo "${ECHO_T}$cf_cv_ld_searchpath" >&6
 
 LD_SEARCHPATH=`echo "$cf_cv_ld_searchpath"|sed -e 's/ /|/g'`
 
-cat >>confdefs.h <<\EOF
-#define HAVE_CURSES_DATA_BOOLNAMES 1
-EOF
-
-ac_config_files="$ac_config_files include/MKterm.h.awk include/curses.head:include/curses.h.in include/ncurses_dll.h include/termcap.h include/unctrl.h $SUB_MAKEFILES Makefile"
+ac_config_files="$ac_config_files include/MKterm.h.awk include/curses.head:include/curses.h.in include/ncurses_dll.h include/termcap.h include/unctrl.h man/man_db.renames $SUB_MAKEFILES Makefile"
 ac_config_commands="$ac_config_commands default"
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
@@ -28197,7 +29510,7 @@ cat >confcache <<\_ACEOF
 # config.status only pays attention to the cache file if you give it
 # the --recheck option to rerun configure.
 #
-# `ac_cv_env_foo' variables (set or unset) will be overriden when
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
 # loading this file, other *unset* `ac_cv_foo' will be assigned the
 # following values.
 
@@ -28266,7 +29579,7 @@ DEFS=-DHAVE_CONFIG_H
 : "${CONFIG_STATUS=./config.status}"
 ac_clean_files_save=$ac_clean_files
 ac_clean_files="$ac_clean_files $CONFIG_STATUS"
-{ echo "$as_me:28269: creating $CONFIG_STATUS" >&5
+{ echo "$as_me:29582: creating $CONFIG_STATUS" >&5
 echo "$as_me: creating $CONFIG_STATUS" >&6;}
 cat >"$CONFIG_STATUS" <<_ACEOF
 #! $SHELL
@@ -28275,6 +29588,8 @@ cat >"$CONFIG_STATUS" <<_ACEOF
 # Compiler output produced by configure, useful for debugging
 # configure, is in config.log if it exists.
 
+me=\`echo "\$0" | sed -e 's,.*\\/,,'\`
+
 debug=false
 SHELL=\${CONFIG_SHELL-$SHELL}
 ac_cs_invocation="\$0 \$@"
@@ -28296,9 +29611,9 @@ fi
 as_me=`echo "$0" |sed 's,.*[\\/],,'`
 
 if expr a : '\(a\)' >/dev/null 2>&1; then
-  as_expr=expr
+  as_expr="expr"
 else
-  as_expr=false
+  as_expr="false"
 fi
 
 rm -f conf$$ conf$$.exe conf$$.file
@@ -28313,7 +29628,7 @@ if ln -s conf$$.file conf$$ 2>/dev/null; then
     as_ln_s='ln -s'
   fi
 elif ln conf$$.file conf$$ 2>/dev/null; then
-  as_ln_s=ln
+  as_ln_s='ln'
 else
   as_ln_s='cp -p'
 fi
@@ -28400,10 +29715,10 @@ EOF
 cat >>"$CONFIG_STATUS" <<EOF
 ac_cs_version="\\
 config.status
-configured by $0, generated by GNU Autoconf 2.52.20210105,
+configured by $0, generated by GNU Autoconf 2.52.20231210,
   with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
 
-Copyright 2003-2020,2021	Thomas E. Dickey
+Copyright 2003-2022,2023	Thomas E. Dickey
 Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
 Free Software Foundation, Inc.
 This config.status script is free software; the Free Software Foundation
@@ -28445,7 +29760,7 @@ cat >>"$CONFIG_STATUS" <<\EOF
     echo "$ac_cs_version"; exit 0 ;;
   --he | --h)
     # Conflict between --help and --header
-    { { echo "$as_me:28448: error: ambiguous option: $1
+    { { echo "$as_me:29763: error: ambiguous option: $1
 Try \`$0 --help' for more information." >&5
 echo "$as_me: error: ambiguous option: $1
 Try \`$0 --help' for more information." >&2;}
@@ -28464,7 +29779,7 @@ Try \`$0 --help' for more information." >&2;}
     ac_need_defaults=false;;
 
   # This is an error.
-  -*) { { echo "$as_me:28467: error: unrecognized option: $1
+  -*) { { echo "$as_me:29782: error: unrecognized option: $1
 Try \`$0 --help' for more information." >&5
 echo "$as_me: error: unrecognized option: $1
 Try \`$0 --help' for more information." >&2;}
@@ -28483,7 +29798,7 @@ cat >&5 << _ACEOF
 ## Running config.status.  ##
 ## ----------------------- ##
 
-This file was extended by $as_me 2.52.20210105, executed with
+This file was extended by $as_me 2.52.20231210, executed with
   CONFIG_FILES    = $CONFIG_FILES
   CONFIG_HEADERS  = $CONFIG_HEADERS
   CONFIG_LINKS    = $CONFIG_LINKS
@@ -28519,6 +29834,7 @@ LIB_SUFFIX="$LIB_SUFFIX"
 LIB_TRACING="$LIB_TRACING"
 LN_S="$LN_S"
 MAKE_TERMINFO="$MAKE_TERMINFO"
+MANPAGE_RENAMES="$MANPAGE_RENAMES"
 MENU_NAME="$MENU_NAME"
 NCURSES_MAJOR="$NCURSES_MAJOR"
 NCURSES_MINOR="$NCURSES_MINOR"
@@ -28548,12 +29864,14 @@ WITH_OVERWRITE="$with_overwrite"
 cf_LIST_MODELS="$cf_list_models"
 cf_cv_VERSION_GNATMAKE=$cf_cv_VERSION_GNATMAKE
 cf_cv_VERSION_GPRBUILD=$cf_cv_VERSION_GPRBUILD
+cf_cv_abi_default="$cf_cv_abi_default"
 cf_cv_abi_version="$cf_cv_abi_version"
 cf_cv_do_relink="$cf_cv_do_relink"
 cf_cv_do_reranlib="$cf_cv_do_reranlib"
 cf_cv_do_symlinks="$cf_cv_do_symlinks"
 cf_cv_enable_lp64="$cf_cv_enable_lp64"
 cf_cv_enable_opaque="$cf_cv_enable_opaque"
+cf_cv_make_PHONY="$cf_cv_make_PHONY"
 cf_cv_prog_CC_c_o=$cf_cv_prog_CC_c_o
 cf_cv_prog_CXX_c_o=$cf_cv_prog_CXX_c_o
 cf_cv_prog_gnat_correct=$cf_cv_prog_gnat_correct
@@ -28571,6 +29889,7 @@ cf_with_manpages="$cf_with_manpages"
 cf_with_tests="$cf_with_tests"
 host="$host"
 target="$target"
+verbose="$verbose"
 with_shared_cxx="$with_shared_cxx"
 
 EOF
@@ -28585,11 +29904,12 @@ do
   "include/ncurses_dll.h" ) CONFIG_FILES="$CONFIG_FILES include/ncurses_dll.h" ;;
   "include/termcap.h" ) CONFIG_FILES="$CONFIG_FILES include/termcap.h" ;;
   "include/unctrl.h" ) CONFIG_FILES="$CONFIG_FILES include/unctrl.h" ;;
+  "man/man_db.renames" ) CONFIG_FILES="$CONFIG_FILES man/man_db.renames" ;;
   "$SUB_MAKEFILES" ) CONFIG_FILES="$CONFIG_FILES $SUB_MAKEFILES" ;;
   "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
   "default" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;;
   "include/ncurses_cfg.h" ) CONFIG_HEADERS="$CONFIG_HEADERS include/ncurses_cfg.h:include/ncurses_cfg.hin" ;;
-  *) { { echo "$as_me:28592: error: invalid argument: $ac_config_target" >&5
+  *) { { echo "$as_me:29912: error: invalid argument: $ac_config_target" >&5
 echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
    { (exit 1); exit 1; }; };;
   esac
@@ -28613,14 +29933,14 @@ $debug ||
 }
 
 # Create a (secure) tmp directory for tmp files.
-: ${TMPDIR=/tmp}
+: "${TMPDIR=/tmp}"
 {
   tmp=`(umask 077 && mktemp -d -q "$TMPDIR/csXXXXXX") 2>/dev/null` &&
   test -n "$tmp" && test -d "$tmp"
 }  ||
 {
   tmp=$TMPDIR/cs$$-$RANDOM
-  (umask 077 && mkdir $tmp)
+  (umask 077 && mkdir "$tmp")
 } ||
 {
    echo "$me: cannot create a temporary directory in $TMPDIR" >&2
@@ -28640,7 +29960,7 @@ cat >>"$CONFIG_STATUS" <<EOF
 if test -n "\$CONFIG_FILES"; then
   # Protect against being on the right side of a sed subst in config.status.
   sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g;
-   s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF
+   s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >"\$tmp"/subs.sed <<\\CEOF
 s,@SHELL@,$SHELL,;t t
 s,@exec_prefix@,$exec_prefix,;t t
 s,@prefix@,$prefix,;t t
@@ -28681,6 +30001,7 @@ s,@NCURSES_MINOR@,$NCURSES_MINOR,;t t
 s,@NCURSES_PATCH@,$NCURSES_PATCH,;t t
 s,@cf_cv_rel_version@,$cf_cv_rel_version,;t t
 s,@cf_cv_abi_version@,$cf_cv_abi_version,;t t
+s,@cf_cv_abi_default@,$cf_cv_abi_default,;t t
 s,@cf_cv_builtin_bool@,$cf_cv_builtin_bool,;t t
 s,@cf_cv_header_stdbool_h@,$cf_cv_header_stdbool_h,;t t
 s,@cf_cv_type_of_bool@,$cf_cv_type_of_bool,;t t
@@ -28721,6 +30042,7 @@ s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t
 s,@INSTALL_DATA@,$INSTALL_DATA,;t t
 s,@LINT@,$LINT,;t t
 s,@LINT_OPTS@,$LINT_OPTS,;t t
+s,@LINT_LIBS@,$LINT_LIBS,;t t
 s,@LN_S@,$LN_S,;t t
 s,@cf_config_suffix@,$cf_config_suffix,;t t
 s,@PKG_CONFIG@,$PKG_CONFIG,;t t
@@ -28729,6 +30051,8 @@ s,@PKG_CONFIG_LIBDIR@,$PKG_CONFIG_LIBDIR,;t t
 s,@MAKE_PC_FILES@,$MAKE_PC_FILES,;t t
 s,@PC_MODULE_SUFFIX@,$PC_MODULE_SUFFIX,;t t
 s,@SET_MAKE@,$SET_MAKE,;t t
+s,@MAKE_NO_PHONY@,$MAKE_NO_PHONY,;t t
+s,@MAKE_PHONY@,$MAKE_PHONY,;t t
 s,@CTAGS@,$CTAGS,;t t
 s,@ETAGS@,$ETAGS,;t t
 s,@MAKE_LOWER_TAGS@,$MAKE_LOWER_TAGS,;t t
@@ -28832,10 +30156,17 @@ s,@RGB_PATH@,$RGB_PATH,;t t
 s,@no_x11_rgb@,$no_x11_rgb,;t t
 s,@NCURSES_BOOL@,$NCURSES_BOOL,;t t
 s,@TERMINFO_CAPS@,$TERMINFO_CAPS,;t t
+s,@NCURSES_CHTYPE@,$NCURSES_CHTYPE,;t t
 s,@NCURSES_OSPEED@,$NCURSES_OSPEED,;t t
+s,@NCURSES_MMASK_T@,$NCURSES_MMASK_T,;t t
 s,@NCURSES_CCHARW_MAX@,$NCURSES_CCHARW_MAX,;t t
 s,@NCURSES_SBOOL@,$NCURSES_SBOOL,;t t
 s,@NCURSES_TPARM_ARG@,$NCURSES_TPARM_ARG,;t t
+s,@cf_manpage_format@,$cf_manpage_format,;t t
+s,@cf_manpage_inboth@,$cf_manpage_inboth,;t t
+s,@cf_manpage_so_strip@,$cf_manpage_so_strip,;t t
+s,@cf_manpage_compress@,$cf_manpage_compress,;t t
+s,@cf_manpage_coptions@,$cf_manpage_coptions,;t t
 s,@MANPAGE_RENAMES@,$MANPAGE_RENAMES,;t t
 s,@NCURSES_EXT_FUNCS@,$NCURSES_EXT_FUNCS,;t t
 s,@GENERATED_EXT_FUNCS@,$GENERATED_EXT_FUNCS,;t t
@@ -28844,6 +30175,7 @@ s,@GENERATED_SP_FUNCS@,$GENERATED_SP_FUNCS,;t t
 s,@NCURSES_CONST@,$NCURSES_CONST,;t t
 s,@NCURSES_EXT_COLORS@,$NCURSES_EXT_COLORS,;t t
 s,@NCURSES_MOUSE_VERSION@,$NCURSES_MOUSE_VERSION,;t t
+s,@cf_cv_enable_sigwinch@,$cf_cv_enable_sigwinch,;t t
 s,@NCURSES_XNAMES@,$NCURSES_XNAMES,;t t
 s,@PTHREAD@,$PTHREAD,;t t
 s,@cf_cv_enable_reentrant@,$cf_cv_enable_reentrant,;t t
@@ -28870,6 +30202,8 @@ s,@INSTALL_OPT_S@,$INSTALL_OPT_S,;t t
 s,@INSTALL_OPT_O@,$INSTALL_OPT_O,;t t
 s,@INSTALL_OPT_P@,$INSTALL_OPT_P,;t t
 s,@EXTRA_CFLAGS@,$EXTRA_CFLAGS,;t t
+s,@HAVE_STDNORETURN_H@,$HAVE_STDNORETURN_H,;t t
+s,@STDC_NORETURN@,$STDC_NORETURN,;t t
 s,@ADAFLAGS@,$ADAFLAGS,;t t
 s,@EXTRA_CXXFLAGS@,$EXTRA_CXXFLAGS,;t t
 s,@ADA_TRACE@,$ADA_TRACE,;t t
@@ -28935,7 +30269,6 @@ s,@WITH_OVERWRITE@,$WITH_OVERWRITE,;t t
 s,@TICS_LIST@,$TICS_LIST,;t t
 s,@TINFO_LIST@,$TINFO_LIST,;t t
 s,@SHLIB_LIST@,$SHLIB_LIST,;t t
-s,@NCURSES_TREE@,$NCURSES_TREE,;t t
 s,@FORM_NAME@,$FORM_NAME,;t t
 s,@MENU_NAME@,$MENU_NAME,;t t
 s,@PANEL_NAME@,$PANEL_NAME,;t t
@@ -28980,11 +30313,11 @@ EOF
   ac_sed_cmds=
   while "$ac_more_lines"; do
     if test "$ac_beg" -gt 1; then
-      sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
+      sed "1,${ac_beg}d; ${ac_end}q" "$tmp"/subs.sed >"$tmp"/subs.frag
     else
-      sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
+      sed "${ac_end}q" "$tmp"/subs.sed >"$tmp"/subs.frag
     fi
-    if test ! -s $tmp/subs.frag; then
+    if test ! -s "$tmp"/subs.frag; then
       ac_more_lines=false
     else
       # The purpose of the label and of the branching condition is to
@@ -28992,17 +30325,17 @@ EOF
       # is no need to browse any of the substitutions).
       # These are the two extra sed commands mentioned above.
       (echo ':t
-  /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed
+  /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat "$tmp"/subs.frag) >"$tmp"/subs-$ac_sed_frag.sed
       # It is possible to make a multiline substitution using escaped newlines.
       # Ensure that we do not split the substitution between script fragments.
       ac_BEG=$ac_end
       ac_END=`expr "$ac_end" + "$ac_max_sed_lines"`
-      sed "1,${ac_BEG}d; ${ac_END}p; q" $tmp/subs.sed >$tmp/subs.next
-      if test -s $tmp/subs.next; then
-        grep '^s,@[^@,][^@,]*@,.*\\$' $tmp/subs.next >$tmp/subs.edit
-        if test ! -s $tmp/subs.edit; then
-          grep "^s,@[^@,][^@,]*@,.*,;t t$" $tmp/subs.next >$tmp/subs.edit
-          if test ! -s $tmp/subs.edit; then
+      sed "1,${ac_BEG}d; ${ac_END}p; q" "$tmp"/subs.sed >"$tmp"/subs.next
+      if test -s "$tmp"/subs.next; then
+        grep '^s,@[^@,][^@,]*@,.*\\$' "$tmp"/subs.next >"$tmp"/subs.edit
+        if test ! -s "$tmp"/subs.edit; then
+          grep "^s,@[^@,][^@,]*@,.*,;t t$" "$tmp"/subs.next >"$tmp"/subs.edit
+          if test ! -s "$tmp"/subs.edit; then
             if test "$ac_beg" -gt 1; then
               ac_end=`expr "$ac_end" - 1`
               continue
@@ -29012,9 +30345,9 @@ EOF
       fi
 
       if test -z "$ac_sed_cmds"; then
-        ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed"
+        ac_sed_cmds="sed -f \"$tmp\"/subs-$ac_sed_frag.sed"
       else
-        ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed"
+        ac_sed_cmds="$ac_sed_cmds | sed -f \"$tmp\"/subs-$ac_sed_frag.sed"
       fi
       ac_sed_frag=`expr "$ac_sed_frag" + 1`
       ac_beg=$ac_end
@@ -29022,7 +30355,7 @@ EOF
     fi
   done
   if test -z "$ac_sed_cmds"; then
-    ac_sed_cmds=cat
+    ac_sed_cmds="cat"
   fi
 fi # test -n "$CONFIG_FILES"
 
@@ -29032,7 +30365,7 @@ for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
   # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
   case "$ac_file" in
   - | *:- | *:-:* ) # input from stdin
-        cat >$tmp/stdin
+        cat >"$tmp"/stdin
         ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
         ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
   *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
@@ -29069,7 +30402,7 @@ for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do
   esac
 done; }
 
-    ac_dir_suffix="/`echo $ac_dir|sed 's,^\./,,'`"
+    ac_dir_suffix="/`echo "$ac_dir"|sed 's,^\./,,'`"
     # A "../" for each directory in $ac_dir_suffix.
     ac_dots=`echo "$ac_dir_suffix" | sed 's,/[^/]*,../,g'`
   else
@@ -29097,7 +30430,7 @@ done; }
   esac
 
   if test x"$ac_file" != x-; then
-    { echo "$as_me:29100: creating $ac_file" >&5
+    { echo "$as_me:30433: creating $ac_file" >&5
 echo "$as_me: creating $ac_file" >&6;}
     rm -f "$ac_file"
   fi
@@ -29112,23 +30445,23 @@ echo "$as_me: creating $ac_file" >&6;}
   ac_file_inputs=`IFS=:
     for f in $ac_file_in; do
       case $f in
-      -) echo $tmp/stdin ;;
+      -) echo "$tmp"/stdin ;;
       [\\/$]*)
          # Absolute (can't be DOS-style, as IFS=:)
-         test -f "$f" || { { echo "$as_me:29118: error: cannot find input file: $f" >&5
+         test -f "$f" || { { echo "$as_me:30451: error: cannot find input file: $f" >&5
 echo "$as_me: error: cannot find input file: $f" >&2;}
    { (exit 1); exit 1; }; }
-         echo $f;;
+         echo "$f";;
       *) # Relative
          if test -f "$f"; then
            # Build tree
-           echo $f
+           echo "$f"
          elif test -f "$srcdir/$f"; then
            # Source tree
            echo "$srcdir/$f"
          else
            # /dev/null tree
-           { { echo "$as_me:29131: error: cannot find input file: $f" >&5
+           { { echo "$as_me:30464: error: cannot find input file: $f" >&5
 echo "$as_me: error: cannot find input file: $f" >&2;}
    { (exit 1); exit 1; }; }
          fi;;
@@ -29144,7 +30477,7 @@ cat >>"$CONFIG_STATUS" <<\EOF
       if test -n "$ac_seen"; then
         ac_used=`grep '@datarootdir@' "$ac_item"`
         if test -z "$ac_used"; then
-          { echo "$as_me:29147: WARNING: datarootdir was used implicitly but not set:
+          { echo "$as_me:30480: WARNING: datarootdir was used implicitly but not set:
 $ac_seen" >&5
 echo "$as_me: WARNING: datarootdir was used implicitly but not set:
 $ac_seen" >&2;}
@@ -29153,7 +30486,7 @@ $ac_seen" >&2;}
       fi
       ac_seen=`grep '${datarootdir}' "$ac_item"`
       if test -n "$ac_seen"; then
-        { echo "$as_me:29156: WARNING: datarootdir was used explicitly but not set:
+        { echo "$as_me:30489: WARNING: datarootdir was used explicitly but not set:
 $ac_seen" >&5
 echo "$as_me: WARNING: datarootdir was used explicitly but not set:
 $ac_seen" >&2;}
@@ -29178,38 +30511,46 @@ s,@configure_input@,$configure_input,;t t
 s,@srcdir@,$ac_srcdir,;t t
 s,@top_srcdir@,$ac_top_srcdir,;t t
 s,@INSTALL@,$ac_INSTALL,;t t
-" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out
-  rm -f $tmp/stdin
+" $ac_file_inputs | (eval "$ac_sed_cmds") >"$tmp"/out
+  rm -f "$tmp"/stdin
+EOF
+test -n "${FGREP}" || FGREP="grep -F"
+test -n "${EGREP}" || EGREP="grep -E"
+cat >>"$CONFIG_STATUS" <<EOF
+  test -n "\${FGREP}" || FGREP="$FGREP"
+  test -n "\${EGREP}" || EGREP="$EGREP"
+EOF
+cat >>"$CONFIG_STATUS" <<\EOF
   if test x"$ac_file" != x-; then
     cp "$tmp/out" "$ac_file"
 
     for ac_name in prefix exec_prefix datarootdir
     do
-        ac_seen=`${FGREP-fgrep} -n '${'$ac_name'[:=].*}' "$ac_file"`
+        ac_seen=`$FGREP -n '${'$ac_name'[:=].*}' "$ac_file"`
         if test -n "$ac_seen"; then
-            ac_init=`${EGREP-egrep} '[ 	]*'$ac_name'[ 	]*=' "$ac_file"`
+            ac_init=`$EGREP '[ 	]*'$ac_name'[ 	]*=' "$ac_file"`
             if test -z "$ac_init"; then
-              ac_seen=`echo "$ac_seen" |sed -e 's,^,'$ac_file':,'`
-              { echo "$as_me:29193: WARNING: Variable $ac_name is used but was not set:
+              ac_seen=`echo "$ac_seen" |sed -e 's,^,'"$ac_file"':,'`
+              { echo "$as_me:30534: WARNING: Variable $ac_name is used but was not set:
 $ac_seen" >&5
 echo "$as_me: WARNING: Variable $ac_name is used but was not set:
 $ac_seen" >&2;}
             fi
         fi
     done
-    ${EGREP-egrep} -n '@[a-z_][a-z_0-9]+@' "$ac_file" >$tmp/out
-    ${EGREP-egrep} -n '@[A-Z_][A-Z_0-9]+@' "$ac_file" >>$tmp/out
-    if test -s $tmp/out; then
-      ac_seen=`sed -e 's,^,'$ac_file':,' < $tmp/out`
-      { echo "$as_me:29204: WARNING: Some variables may not be substituted:
+    $EGREP -n '@[a-z_][a-z_0-9]+@' "$ac_file" >"$tmp"/out
+    $EGREP -n '@[A-Z_][A-Z_0-9]+@' "$ac_file" >>"$tmp"/out
+    if test -s "$tmp"/out; then
+      ac_seen=`sed -e 's,^,'"$ac_file"':,' < "$tmp"/out`
+      { echo "$as_me:30545: WARNING: Some variables may not be substituted:
 $ac_seen" >&5
 echo "$as_me: WARNING: Some variables may not be substituted:
 $ac_seen" >&2;}
     fi
   else
-    cat $tmp/out
+    cat "$tmp"/out
   fi
-  rm -f $tmp/out
+  rm -f "$tmp"/out
 
 done
 EOF
@@ -29242,7 +30583,7 @@ for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
   # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
   case "$ac_file" in
   - | *:- | *:-:* ) # input from stdin
-        cat >$tmp/stdin
+        cat >"$tmp"/stdin
         ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
         ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
   *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
@@ -29250,7 +30591,7 @@ for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
   * )   ac_file_in=$ac_file.in ;;
   esac
 
-  test x"$ac_file" != x- && { echo "$as_me:29253: creating $ac_file" >&5
+  test x"$ac_file" != x- && { echo "$as_me:30594: creating $ac_file" >&5
 echo "$as_me: creating $ac_file" >&6;}
 
   # First look for the input files in the build tree, otherwise in the
@@ -29258,10 +30599,10 @@ echo "$as_me: creating $ac_file" >&6;}
   ac_file_inputs=`IFS=:
     for f in $ac_file_in; do
       case $f in
-      -) echo $tmp/stdin ;;
+      -) echo "$tmp"/stdin ;;
       [\\/$]*)
          # Absolute (can't be DOS-style, as IFS=:)
-         test -f "$f" || { { echo "$as_me:29264: error: cannot find input file: $f" >&5
+         test -f "$f" || { { echo "$as_me:30605: error: cannot find input file: $f" >&5
 echo "$as_me: error: cannot find input file: $f" >&2;}
    { (exit 1); exit 1; }; }
          echo $f;;
@@ -29274,14 +30615,14 @@ echo "$as_me: error: cannot find input file: $f" >&2;}
            echo "$srcdir/$f"
          else
            # /dev/null tree
-           { { echo "$as_me:29277: error: cannot find input file: $f" >&5
+           { { echo "$as_me:30618: error: cannot find input file: $f" >&5
 echo "$as_me: error: cannot find input file: $f" >&2;}
    { (exit 1); exit 1; }; }
          fi;;
       esac
     done` || { (exit 1); exit 1; }
   # Remove the trailing spaces.
-  sed 's/[ 	]*$//' $ac_file_inputs >$tmp/in
+  sed 's/[ 	]*$//' $ac_file_inputs >"$tmp"/in
 
 EOF
 
@@ -29313,9 +30654,9 @@ echo '  cat >> conftest.edit <<CEOF
 /@DEFS@/r conftest.frag
 /@DEFS@/d
 CEOF
-sed -f conftest.edit $tmp/in > $tmp/out
-rm -f $tmp/in
-mv $tmp/out $tmp/in
+sed -f conftest.edit "$tmp"/in > "$tmp"/out
+rm -f "$tmp"/in
+mv "$tmp"/out "$tmp"/in
 rm -f conftest.edit conftest.frag
 ' >> "$CONFIG_STATUS"
 
@@ -29324,15 +30665,15 @@ cat >>"$CONFIG_STATUS" <<\EOF
   # use $as_me), people would be surprised to read:
   #    /* config.h.  Generated automatically by config.status.  */
   if test x"$ac_file" = x-; then
-    echo "/* Generated automatically by configure.  */" >$tmp/config.h
+    echo "/* Generated automatically by configure.  */" >"$tmp"/config.h
   else
-    echo "/* $ac_file.  Generated automatically by configure.  */" >$tmp/config.h
+    echo "/* $ac_file.  Generated automatically by configure.  */" >"$tmp"/config.h
   fi
-  cat $tmp/in >>$tmp/config.h
-  rm -f $tmp/in
+  cat "$tmp"/in >>"$tmp"/config.h
+  rm -f "$tmp"/in
   if test x"$ac_file" != x-; then
     if cmp -s "$ac_file" "$tmp/config.h" 2>/dev/null; then
-      { echo "$as_me:29335: $ac_file is unchanged" >&5
+      { echo "$as_me:30676: $ac_file is unchanged" >&5
 echo "$as_me: $ac_file is unchanged" >&6;}
     else
       ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
@@ -29368,8 +30709,8 @@ done; }
       mv "$tmp/config.h" "$ac_file"
     fi
   else
-    cat $tmp/config.h
-    rm -f $tmp/config.h
+    cat "$tmp"/config.h
+    rm -f "$tmp"/config.h
   fi
 done
 EOF
@@ -29431,11 +30772,11 @@ do
 		SHARED_LIB=
 		Libs_To_Make=
 		cf_awk_program=
-		if test -n "${cf_cv_abi_version}" && test "x${cf_cv_abi_version}" != "x5"
+		if test -n "${cf_cv_abi_default}" && test "x${cf_cv_abi_default}" != "x5"
 		then
 			cf_awk_program="$cf_awk_program\
-/deprecated in ABI${cf_cv_abi_version}/ { next; }\
-{ sub(\"NCURSES([WT]+)?\", \"&${cf_cv_abi_version}\"); }\
+/deprecated in ABI${cf_cv_abi_default}/ { next; }\
+{ sub(\"NCURSES([WT]+)?\", \"&${cf_cv_abi_default}\"); }\
 "
 		fi
 
@@ -29719,7 +31060,7 @@ cf_ITEM=`echo "$cf_item" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQ
 				(cygdll|msysdll|mingw|msvcdll)
 					test "x$with_shared_cxx" = xno && test -n "$verbose" && echo "	overriding CXX_MODEL to SHARED" 1>&6
 
-echo "${as_me:-configure}:29722: testing overriding CXX_MODEL to SHARED ..." 1>&5
+echo "${as_me:-configure}:31063: testing overriding CXX_MODEL to SHARED ..." 1>&5
 
 					with_shared_cxx=yes
 					;;
@@ -29907,6 +31248,9 @@ eval cf_libname="\$${cf_map_lib_basename}_NAME"
 				traces=$LIB_TRACING \
 				MODEL=$cf_ITEM \
 				CXX_MODEL=$CXX_MODEL \
+				LIB_SUFFIX=$LIB_SUFFIX \
+				USE_LIB_SUFFIX=$USE_LIB_SUFFIX \
+				make_phony="${cf_cv_make_PHONY:-no}" \
 				model=$cf_subdir \
 				prefix=$cf_prefix \
 				suffix=$cf_suffix \
@@ -29954,6 +31298,21 @@ eval cf_libname="\$${cf_map_lib_basename}_NAME"
 	echo '	( cd '$cf_dir' && ${MAKE} ${TOP_MFLAGS} $@ )' >>Makefile
 done
 
+echo >> Makefile
+echo '# generated by CF_LIB_RULES' >> Makefile
+
+if test "x$cf_cv_make_PHONY" = xyes ; then
+	cat >> Makefile <<-CF_EOF
+
+	.PHONY :	libs
+	.PHONY :	lintlib
+	.PHONY :	install.includes
+	.PHONY :	uninstall.includes
+	.PHONY :	install.libs
+	.PHONY :	uninstall.libs
+CF_EOF
+fi
+
 for cf_dir in $SRC_SUBDIRS
 do
 	if test ! -d "$srcdir/$cf_dir" ; then
@@ -29972,6 +31331,15 @@ do
 	fi
 
 	if test -f "$srcdir/$cf_dir/modules" ; then
+
+		if test "x$cf_cv_make_PHONY" = xyes ; then
+			cat >> Makefile <<-CF_EOF
+
+			.PHONY :	install.$cf_dir
+			.PHONY :	uninstall.$cf_dir
+CF_EOF
+		fi
+
 		echo >> Makefile
 		if test -f "$srcdir/$cf_dir/headers" ; then
 cat >> Makefile <<CF_EOF
@@ -29979,10 +31347,9 @@ install.includes \\
 uninstall.includes \\
 CF_EOF
 		fi
-if test "$cf_dir" != "c++" ; then
-echo 'lint \' >> Makefile
-fi
+
 cat >> Makefile <<CF_EOF
+lint \\
 libs \\
 lintlib \\
 install.libs \\
@@ -30004,6 +31371,14 @@ CF_EOF
 fi
 done
 
+if test "x$cf_cv_make_PHONY" = xyes ; then
+	cat >> Makefile <<-CF_EOF
+
+	.PHONY :	install.data
+	.PHONY :	uninstall.data
+CF_EOF
+fi
+
 if test "x$cf_with_db_install" = xyes; then
 cat >> Makefile <<CF_EOF
 
@@ -30020,6 +31395,15 @@ CF_EOF
 fi
 
 if test "x$cf_with_manpages" = xyes; then
+
+if test "x$cf_cv_make_PHONY" = xyes ; then
+	cat >> Makefile <<-CF_EOF
+
+	.PHONY :	install.man
+	.PHONY :	uninstall.man
+CF_EOF
+fi
+
 cat >> Makefile <<CF_EOF
 
 install.man \\
@@ -30033,22 +31417,10 @@ cat >> Makefile <<CF_EOF
 distclean ::
 	rm -f config.cache config.log config.status Makefile include/ncurses_cfg.h
 	rm -f headers.sh headers.sed mk_shared_lib.sh
-	rm -f edit_man.* man_alias.*
+	rm -f edit_man.* man_alias.* *.tmp
 	rm -rf \${DIRS_TO_MAKE}
 CF_EOF
 
-# Special case: tack's manpage lives in its own directory.
-if test "x$cf_with_manpages" = xyes; then
-if test "x$cf_with_tack" = "xyes"; then
-cat >> Makefile <<CF_EOF
-
-install.man \\
-uninstall.man ::
-	( cd tack && \${MAKE} \${TOP_MFLAGS} \$@ )
-CF_EOF
-fi
-fi
-
 rm -f headers.sed headers.sh
 
 echo creating headers.sh
@@ -30145,6 +31517,13 @@ do
 
 	if test -f "$srcdir/$cf_dir/modules" ; then
 		if test "$cf_dir" != "c++" ; then
+			if test "x$cf_cv_make_PHONY" = xyes ; then
+				cat >> $cf_dir/Makefile <<-CF_EOF
+
+				.PHONY :	depend
+CF_EOF
+			fi
+
 			cat >>$cf_dir/Makefile <<"CF_EOF"
 depend : ${AUTO_SRC}
 	makedepend -- ${CPPFLAGS} -- ${C_SRC}
@@ -30155,6 +31534,13 @@ CF_EOF
 	fi
 done
 
+if test "$MANPAGE_RENAMES" != no ; then
+	# Construct a sed-script to perform renaming within man-pages
+	test -n "$verbose" && echo "creating edit_man.sed"
+	test ! -d man && mkdir man
+	FGREP="${FGREP-grep -F}" $SHELL "$srcdir/man/make_sed.sh" "$MANPAGE_RENAMES" >./edit_man.sed
+fi
+
 if test "x$cf_with_ada" = "xyes" && test "x$cf_cv_prog_gnat_correct" = "xyes"; then
 if test -z "$USE_OLD_MAKERULES" ; then
 	$AWK -f "$srcdir/Ada95/mk-1st.awk" <"$srcdir/Ada95/src/modules" >>Ada95/src/Makefile
diff --git a/contrib/ncurses/configure.in b/contrib/ncurses/configure.in
index f2013a9fbbe9..2d6836cb7190 100644
--- a/contrib/ncurses/configure.in
+++ b/contrib/ncurses/configure.in
@@ -1,5 +1,5 @@
 dnl***************************************************************************
-dnl Copyright 2018-2020,2021 Thomas E. Dickey                                *
+dnl Copyright 2018-2023,2024 Thomas E. Dickey                                *
 dnl Copyright 1998-2017,2018 Free Software Foundation, Inc.                  *
 dnl                                                                          *
 dnl Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -29,7 +29,7 @@ dnl***************************************************************************
 dnl
 dnl Author: Thomas E. Dickey 1995-on
 dnl
-dnl $Id: configure.in,v 1.729 2021/01/09 11:20:52 tom Exp $
+dnl $Id: configure.in,v 1.779 2024/04/10 08:04:00 tom Exp $
 dnl Process this file with autoconf to produce a configure script.
 dnl
 dnl For additional information, see
@@ -38,7 +38,7 @@ dnl     https://invisible-island.net/autoconf/my-autoconf.html
 dnl
 dnl ---------------------------------------------------------------------------
 AC_PREREQ(2.52.20210101)
-AC_REVISION($Revision: 1.729 $)
+AC_REVISION($Revision: 1.779 $)
 AC_INIT(ncurses/base/lib_initscr.c)
 AC_CONFIG_HEADER(include/ncurses_cfg.h:include/ncurses_cfg.hin)
 
@@ -61,6 +61,9 @@ CF_CFG_DEFAULTS
 ### Defaults for ncurses ABI
 CF_ABI_DEFAULTS
 
+### override ABI version, e.g., packagers
+CF_WITH_ABI_ALTERED
+
 ###	Checks for programs.
 AC_ARG_WITH(ada,
 	[  --without-ada           suppress check for Ada compiler, don't build demo],
@@ -183,22 +186,6 @@ AC_ARG_WITH(progs,
 	[cf_with_progs=yes])
 AC_MSG_RESULT($cf_with_progs)
 
-if test -f "$srcdir/tack/tack.h" ; then
-	if test "x$cross_compiling" = xyes ; then
-		CF_VERBOSE(ignoring tack because we are cross-compiling)
-		cf_with_tack=no
-	else
-		AC_MSG_CHECKING(if you want to build the tack program)
-		AC_ARG_WITH(tack,
-			[  --without-tack          suppress build/install with tack program],
-			[cf_with_tack=$withval],
-			[cf_with_tack=$cf_with_progs])
-		AC_MSG_RESULT($cf_with_tack)
-	fi
-else
-	cf_with_tack=no
-fi
-
 AC_MSG_CHECKING(if you want to build test-programs)
 AC_ARG_WITH(tests,
 	[  --without-tests         suppress build/install with test-programs],
@@ -215,7 +202,6 @@ AC_MSG_RESULT($with_curses_h)
 
 modules_to_build="ncurses"
 test "X$cf_with_progs" != Xno && modules_to_build="$modules_to_build progs"
-test "X$cf_with_tack"  != Xno && modules_to_build="$modules_to_build tack"
 modules_to_build="$modules_to_build panel menu form"
 
 AC_ARG_PROGRAM
@@ -231,7 +217,7 @@ AC_SYS_LONG_FILE_NAMES
 # of package conflict.
 cf_config_suffix=
 AC_ARG_WITH(config-suffix,
-	[  --with-config-suffix=X  suffixes ncursesXX-config file],
+	[  --with-config-suffix=X  name ncurses*X-config file with X],
 	[case "x$withval" in
 	(xyes|xno)
 		AC_MSG_WARN(expected a value for config-suffix option)
@@ -247,9 +233,9 @@ CF_WITH_PKG_CONFIG_LIBDIR
 CF_ENABLE_PC_FILES
 if test -z "$MAKE_PC_FILES"
 then
-	AC_MSG_CHECKING(for suffix to add to pc-files)
+	AC_MSG_CHECKING(for suffix to add to pkg-config files)
 AC_ARG_WITH(pc-suffix,
-	[  --with-pc-suffix        suffixes pc-files],
+	[[  --with-pc-suffix[=XXX]  suffix pkg-config files with XXX]],
 	[case "x$withval" in
 	(xyes|xno)
 		PC_MODULE_SUFFIX=
@@ -280,6 +266,7 @@ fi
 
 # do this after mixed-case option (tags/TAGS is not as important as tic).
 AC_PROG_MAKE_SET
+CF_MAKE_PHONY
 CF_MAKE_TAGS
 CF_MAKEFLAGS
 
@@ -293,16 +280,16 @@ CF_AR_FLAGS
 dnl Special option for use by system-builders: the install-prefix is used to
 dnl adjust the location into which the actual install is done, so that an
 dnl archive can be built without modifying the host system's configuration.
-AC_MSG_CHECKING(if you have specified an install-prefix)
+AC_MSG_CHECKING(for an installation directory prefix)
 AC_ARG_WITH(install-prefix,
-	[  --with-install-prefix   prefixes actual install-location ($DESTDIR)],
+	[  --with-install-prefix=DESTDIR use DESTDIR as installation directory prefix],
 	[case "x$withval" in
 	(xyes|xno)
 		;;
 	(*)	DESTDIR="$withval"
 		;;
 	esac])
-AC_MSG_RESULT($DESTDIR)
+AC_MSG_RESULT([${DESTDIR:-(none)}])
 AC_SUBST(DESTDIR)
 
 ###############################################################################
@@ -419,6 +406,10 @@ LIB_SUFFIX=
 AC_SUBST(LIB_SUFFIX)
 CF_PATHSEP
 
+# headers needed for checks...
+AC_CHECK_DECL(exit)
+AC_HEADER_DIRENT
+
 ###############################################################################
 
 AC_MSG_CHECKING(if you want to build a separate terminfo library)
@@ -458,7 +449,7 @@ case "$DFT_LWR_MODEL" in
 (shared)  LD_MODEL=''   ;;
 esac
 AC_SUBST(LD_MODEL)dnl		the type of link (e.g., -g or -pg)
-AC_MSG_RESULT($LD_MODEL)
+AC_MSG_RESULT([${LD_MODEL:-(none)}])
 
 case "$DFT_LWR_MODEL" in
 (shared)
@@ -553,7 +544,7 @@ fi
 ### Depending on the system, someone may use rpath to build ncurses but not
 # want users of the package to rely upon that feature.  Give those people an
 # option to suppress that detail from EXTRA_LDFLAGS.
-EXTRA_PKG_LDFLAGS="$EXTRA_LDFLAGS"
+EXTRA_PKG_LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
 if test -n "$EXTRA_PKG_LDFLAGS"
 then
 	AC_MSG_CHECKING(if you want to disable extra LDFLAGS for package-scripts)
@@ -571,10 +562,10 @@ AC_SUBST(EXTRA_PKG_LDFLAGS)
 CF_HELP_MESSAGE(Fine-Tuning Your Configuration:)
 
 ###	use option --with-extra-suffix to append suffix to headers and libraries
-AC_MSG_CHECKING(if you wish to append extra suffix to header/library paths)
+AC_MSG_CHECKING(for extra suffix to append to header/library paths)
 EXTRA_SUFFIX=
 AC_ARG_WITH(extra-suffix,
-	[  --with-extra-suffix=X   append extra suffix to header/library paths],
+	[[  --with-extra-suffix[=X] append extra suffix X to header/library paths]],
 	[case x$withval in
 	(xno)
 		;;
@@ -586,7 +577,7 @@ AC_ARG_WITH(extra-suffix,
 		;;
 	esac
 	])
-AC_MSG_RESULT($EXTRA_SUFFIX)
+AC_MSG_RESULT([${EXTRA_SUFFIX:-(none)}])
 AC_SUBST(EXTRA_SUFFIX)
 
 ###	use option --disable-overwrite to leave out the link to -lcurses
@@ -634,12 +625,12 @@ else
 fi
 AC_SUBST(NCURSES_USE_DATABASE)
 
-AC_MSG_CHECKING(for list of fallback descriptions)
+AC_MSG_CHECKING(for list of fallback terminal descriptions)
 AC_ARG_WITH(fallbacks,
 	[  --with-fallbacks=XXX    specify list of fallback terminal descriptions],
 	[with_fallback=$withval],
 	[with_fallback=])
-AC_MSG_RESULT($with_fallback)
+AC_MSG_RESULT([${with_fallback:-(none)}])
 
 case ".$with_fallback" in
 (.|.no)
@@ -692,11 +683,20 @@ AC_MSG_RESULT($with_xterm_new)
 WHICH_XTERM=$with_xterm_new
 AC_SUBST(WHICH_XTERM)
 
+case $host_os in
+(*linux-gnu|*cygwin|*mingw32|*msys)
+	want_xterm_kbs=DEL
+	;;
+(*)
+	want_xterm_kbs=BS
+	;;
+esac
+
 AC_MSG_CHECKING(if xterm backspace sends BS or DEL)
 AC_ARG_WITH(xterm-kbs,
-	[  --with-xterm-kbs=XXX    specify if xterm backspace sends BS or DEL],
+	[[  --with-xterm-kbs[=XXX]  specify if xterm backspace sends BS or DEL]],
 	[with_xterm_kbs=$withval],
-	[with_xterm_kbs=BS])
+	[with_xterm_kbs=auto])
 case x$with_xterm_kbs in
 (xyes|xno|xBS|xbs|x8)
 	with_xterm_kbs=BS
@@ -704,6 +704,9 @@ case x$with_xterm_kbs in
 (xDEL|xdel|x127)
 	with_xterm_kbs=DEL
 	;;
+(xauto)
+	with_xterm_kbs=$want_xterm_kbs
+	;;
 (*)
 	with_xterm_kbs=$withval
 	;;
@@ -712,6 +715,11 @@ AC_MSG_RESULT($with_xterm_kbs)
 XTERM_KBS=$with_xterm_kbs
 AC_SUBST(XTERM_KBS)
 
+if test "x$with_xterm_kbs" != "x$want_xterm_kbs"
+then
+	AC_MSG_WARN([expected --with-xterm-kbs=$want_xterm_kbs for $host_os, have $with_xterm_kbs])
+fi
+
 MAKE_TERMINFO=
 if test "$use_database" = no ; then
 	TERMINFO="${datadir}/terminfo"
@@ -757,7 +765,7 @@ AC_ARG_ENABLE(big-core,
 	[AC_TRY_RUN([
 #include <stdlib.h>
 #include <string.h>
-int main() {
+int main(void) {
 	unsigned long n = 6000000L;
 	char *s = malloc(n);
 	if (s != 0)
@@ -844,13 +852,29 @@ AC_ARG_ENABLE(home-terminfo,
 AC_MSG_RESULT($with_home_terminfo)
 test "x$with_home_terminfo" = "xyes" && AC_DEFINE(USE_HOME_TERMINFO,1,[Define to 1 if $HOME/.terminfo feature is wanted])
 
-AC_MSG_CHECKING(if you want to use restricted environment when running as root)
+AC_MSG_CHECKING(if you want to permit root to use ncurses environment variables)
 AC_ARG_ENABLE(root-environ,
-	[  --disable-root-environ  restrict environment when running as root],
+	[  --disable-root-environ  restrict root use of ncurses environment variables],
 	[with_root_environ=$enableval],
 	[with_root_environ=yes])
 AC_MSG_RESULT($with_root_environ)
-test "x$with_root_environ" = xyes && AC_DEFINE(USE_ROOT_ENVIRON,1,[Define to 1 if environment should be restricted for root user])
+test "x$with_root_environ" = xyes && AC_DEFINE(USE_ROOT_ENVIRON,1,[Define to 1 if root/setuid application is allowed to use ncurses environment])
+
+AC_MSG_CHECKING(if you want to permit setuid programs to access all files)
+AC_ARG_ENABLE(root-access,
+	[  --disable-root-access   restrict file-access when running setuid],
+	[with_root_access=$enableval],
+	[with_root_access=yes])
+AC_MSG_RESULT($with_root_access)
+test "x$with_root_access" = xyes && AC_DEFINE(USE_ROOT_ACCESS,1,[Define to 1 if setuid is allowed all file-access])
+
+AC_MSG_CHECKING(if you want to permit setuid use of ncurses environment variables)
+AC_ARG_ENABLE(setuid-environ,
+	[  --disable-setuid-environ restrict setuid use of ncurses environment variables],
+	[with_setuid_environ=$enableval],
+	[with_setuid_environ=$with_root_environ])
+AC_MSG_RESULT($with_setuid_environ)
+test "x$with_setuid_environ" = xyes && AC_DEFINE(USE_SETUID_ENVIRON,1,[Define to 1 if setuid/setgid application is allowed to use ncurses environment])
 
 ###   Use option --enable-symlinks to make tic use symlinks, not hard links
 ###   to reduce storage requirements for the terminfo database.
@@ -923,9 +947,9 @@ NCURSES_OK_WINT_T=
 
 AC_MSG_CHECKING(if you want wide-character code)
 AC_ARG_ENABLE(widec,
-	[  --enable-widec          compile with wide-char/UTF-8 code],
+	[  --disable-widec         compile without wide character and UTF-8 support],
 	[with_widec=$enableval],
-	[with_widec=no])
+	[with_widec=$cf_dft_widec])
 AC_MSG_RESULT($with_widec)
 
 NCURSES_WCWIDTH_GRAPHICS=1
@@ -935,8 +959,17 @@ if test "x$with_widec" = xyes ; then
 	if test "x$disable_lib_suffixes" = xno ; then
 		LIB_SUFFIX="w${LIB_SUFFIX}"
 	fi
-	AC_DEFINE(USE_WIDEC_SUPPORT,1,[Define to 1 to compile with wide-char/UTF-8 code])
-	AC_DEFINE(NCURSES_WIDECHAR,1,[Define to 1 to compile with wide-char/UTF-8 code])
+	AC_DEFINE(USE_WIDEC_SUPPORT,1,[Define to 1 to compile with wide character and UTF-8 support])
+	AC_DEFINE(NCURSES_WIDECHAR,1,[Define to 1 to compile with wide character and UTF-8 support])
+	case "$CPPFLAGS" in
+	(*_XOPEN_SOURCE=*)
+		;;
+	(*)
+		AC_MSG_WARN(_XOPEN_SOURCE feature test macro appears to be predefined)
+		# CPPFLAGS="$CPPFLAGS -DNCURSES_WIDECHAR"
+		CPPFLAGS_after_XOPEN="$CPPFLAGS_after_XOPEN -DNCURSES_WIDECHAR"
+		;;
+	esac
 
 	CF_CHECK_WCHAR_H
 	CF_CHECK_WCWIDTH_GRAPHICS
@@ -944,7 +977,7 @@ if test "x$with_widec" = xyes ; then
 
 	# with_overwrite=no
 	NCURSES_CH_T=cchar_t
-	AC_CHECK_FUNCS(putwc btowc wctob mbtowc wctomb mblen mbrlen mbrtowc wcsrtombs mbsrtowcs wcstombs mbstowcs)
+	AC_CHECK_FUNCS(putwc btowc wctob wmemchr mbtowc wctomb mblen mbrlen mbrtowc wcsrtombs mbsrtowcs wcstombs mbstowcs)
 	if test "x$ac_cv_func_putwc" != xyes ; then
 		CF_UTF8_LIB
 		if test "$cf_cv_utf8_lib" != no ; then
@@ -1010,72 +1043,66 @@ else
 	with_tic_depends=no
 fi
 
-###   use option --disable-wattr-macros to suppress wattr* macros from curses.h
-AC_MSG_CHECKING(if you want to suppress wattr* macros to help with ncurses5/ncurses6 transition)
+###   use option --enable-wattr-macros to enable wattr* macros in curses.h
+AC_MSG_CHECKING(if you want to enable wattr* macros)
 AC_ARG_ENABLE(wattr-macros,
-	[  --disable-wattr-macros  suppress wattr* macros to help with ncurses5/ncurses6 transition],
+	[  --enable-wattr-macros   enable wattr* macros],
 	[with_wattr_macros=$enableval],
-	[with_wattr_macros=yes])
+	[with_wattr_macros=no])
 if [[ "x$with_wattr_macros" != xyes ]]; then
 	NCURSES_WATTR_MACROS=0
-	AC_MSG_RESULT(yes)
+	AC_MSG_RESULT(no)
 else
 	NCURSES_WATTR_MACROS=1
-	AC_MSG_RESULT(no)
+	AC_MSG_RESULT(yes)
 fi
 AC_SUBST(NCURSES_WATTR_MACROS)
 
 CF_WITH_X11_RGB
 
 ###   use option --with-bool to override bool's type
-AC_MSG_CHECKING(for type of bool)
-AC_ARG_WITH(bool,
-	[  --with-bool=TYPE        override fallback type of bool variable],
-	[NCURSES_BOOL="$withval"],
-	[NCURSES_BOOL=auto])
-AC_MSG_RESULT($NCURSES_BOOL)
-AC_SUBST(NCURSES_BOOL)
+CF_WITH_TYPE(bool,
+	[  --with-bool=TYPE        fall back to TYPE for curses 'bool' typedef],
+	NCURSES_BOOL,
+	auto)
 
 AC_MSG_CHECKING(for alternate terminal capabilities file)
 AC_ARG_WITH(caps,
 	[  --with-caps=alt         compile with alternate Caps file],
 	[TERMINFO_CAPS=Caps.$withval],
 	[TERMINFO_CAPS=Caps])
-test -f "${srcdir}/include/${TERMINFO_CAPS}" || TERMINFO_CAPS=Caps
+if test ! -f "${srcdir}/include/${TERMINFO_CAPS}"
+then
+	AC_MSG_WARN(file not found: "${srcdir}/include/${TERMINFO_CAPS}")
+	TERMINFO_CAPS=Caps
+fi
 AC_MSG_RESULT($TERMINFO_CAPS)
 AC_SUBST(TERMINFO_CAPS)
 
 ###   use option --with-chtype to override chtype's type
-AC_MSG_CHECKING(for type of chtype)
-AC_ARG_WITH(chtype,
+CF_WITH_TYPE(chtype,
 	[  --with-chtype=TYPE      override type of chtype],
-	[NCURSES_CHTYPE="$withval"],
-	[NCURSES_CHTYPE=$cf_dft_chtype])
-AC_MSG_RESULT($NCURSES_CHTYPE)
+	NCURSES_CHTYPE,
+	$cf_dft_chtype)
 
 ###   use option --with-ospeed to override ospeed's type
-AC_MSG_CHECKING(for type of ospeed)
-AC_ARG_WITH(ospeed,
+CF_WITH_TYPE(ospeed,
 	[  --with-ospeed=TYPE      override type of ospeed variable],
-	[NCURSES_OSPEED="$withval"],
-	[NCURSES_OSPEED=short])
-AC_MSG_RESULT($NCURSES_OSPEED)
-AC_SUBST(NCURSES_OSPEED)
+	NCURSES_OSPEED,
+	short)
 
 ###   use option --with-mmask-t to override mmask_t's type
-AC_MSG_CHECKING(for type of mmask_t)
-AC_ARG_WITH(mmask-t,
+CF_WITH_TYPE(mmask-t,
 	[  --with-mmask-t=TYPE     override type of mmask_t],
-	[NCURSES_MMASK_T="$withval"],
-	[NCURSES_MMASK_T=$cf_dft_mmask_t])
-AC_MSG_RESULT($NCURSES_MMASK_T)
+	NCURSES_MMASK_T,
+	$cf_dft_mmask_t)
 
 ###   use option --with-ccharw-max to override CCHARW_MAX size
 AC_MSG_CHECKING(for size CCHARW_MAX)
 AC_ARG_WITH(ccharw-max,
 	[  --with-ccharw-max=XXX   override size CCHARW_MAX],
 	[NCURSES_CCHARW_MAX="$withval"],
-	[NCURSES_CCHARW_MAX=5])
+	[NCURSES_CCHARW_MAX=$cf_dft_ccharw_max])
 AC_MSG_RESULT($NCURSES_CCHARW_MAX)
 AC_SUBST(NCURSES_CCHARW_MAX)
 
@@ -1085,23 +1112,20 @@ if test "$ac_cv_sizeof_signed_char" = 1 ; then
 else
 	NCURSES_SBOOL="char"
 fi
-AC_MSG_CHECKING(if you want to use signed Boolean array in term.h)
+AC_MSG_CHECKING(whether to use signed chars for Boolean array in term.h)
 AC_ARG_ENABLE(signed-char,
-	[  --enable-signed-char    compile using signed Boolean's in term.h],
+	[  --enable-signed-char    use signed chars for Boolean array in term.h],
 	[with_signed_char=$enableval],
-	[with_signed_char=no])
+	[with_signed_char=$cf_dft_signed_char])
 AC_MSG_RESULT($with_signed_char)
 test "x$with_signed_char" != xyes && NCURSES_SBOOL="char"
 AC_SUBST(NCURSES_SBOOL)
 
 ###   use option --with-tparm-arg to override tparm's argument type
-AC_MSG_CHECKING(for type of tparm args)
-AC_ARG_WITH(tparm-arg,
+CF_WITH_TYPE(tparm-arg,
 	[  --with-tparm-arg=TYPE   override parameter type of tparm],
-	[NCURSES_TPARM_ARG="$withval"],
-	[NCURSES_TPARM_ARG=$cf_dft_tparm_arg])
-AC_MSG_RESULT($NCURSES_TPARM_ARG)
-AC_SUBST(NCURSES_TPARM_ARG)
+	NCURSES_TPARM_ARG,
+	$cf_dft_tparm_arg)
 
 ### Enable compiling-in rcs id's
 AC_MSG_CHECKING(if RCS identifiers should be compiled-in)
@@ -1135,7 +1159,6 @@ if test "x$with_ext_funcs" = xyes ; then
 	AC_DEFINE(HAVE_RESIZE_TERM,1,[Define to 1 to enable resize_term() function in test-programs])
 	AC_DEFINE(HAVE_TERM_ENTRY_H,1,[Define to 1 to enable term_entry() function in test-programs])
 	AC_DEFINE(HAVE_USE_DEFAULT_COLORS,1,[Define to 1 to enable use_default_colors() function in test-programs])
-	AC_DEFINE(HAVE_USE_EXTENDED_NAMES,1,[Define to 1 to enable use_extended_names() function in test-programs])
 	AC_DEFINE(HAVE_USE_SCREEN,1,[Define to 1 to enable use_screen() function in test-programs])
 	AC_DEFINE(HAVE_USE_WINDOW,1,[Define to 1 to enable use_window() function in test-programs])
 	AC_DEFINE(HAVE_WRESIZE,1,[Define to 1 to enable wresize() function in test-programs])
@@ -1225,11 +1248,18 @@ AC_ARG_ENABLE(ext-mouse,
 	[with_ext_mouse=$enableval],
 	[with_ext_mouse=$cf_dft_ext_mouse])
 AC_MSG_RESULT($with_ext_mouse)
-NCURSES_MOUSE_VERSION=1
 if test "x$with_ext_mouse" = xyes ; then
-	NCURSES_MOUSE_VERSION=2
 	CF_NCURSES_ABI_6
 fi
+
+if test $cf_cv_abi_default -le 5 ; then
+	NCURSES_MOUSE_VERSION=1
+elif test $cf_cv_abi_default -le 6 ; then
+	NCURSES_MOUSE_VERSION=2
+else
+	NCURSES_MOUSE_VERSION=3
+fi
+
 AC_SUBST(NCURSES_MOUSE_VERSION)
 
 ###   use option --enable-ext-putwin to turn on extended screendumps
@@ -1258,7 +1288,14 @@ AC_ARG_ENABLE(sigwinch,
 	[with_sigwinch=$enableval],
 	[with_sigwinch=$with_ext_funcs])
 AC_MSG_RESULT($with_sigwinch)
-test "x$with_sigwinch" = xyes && AC_DEFINE(USE_SIGWINCH,1,[Define to 1 to compile with SIGWINCH handler])
+if test "x$with_sigwinch" = xyes
+then
+	AC_DEFINE(USE_SIGWINCH,1,[Define to 1 to compile with SIGWINCH handler])
+	cf_cv_enable_sigwinch=1
+else
+	cf_cv_enable_sigwinch=0
+fi
+AC_SUBST(cf_cv_enable_sigwinch)
 
 ###   use option --enable-tcap-names to allow user to define new capabilities
 AC_MSG_CHECKING(if you want user-definable terminal capabilities like termcap)
@@ -1268,7 +1305,10 @@ AC_ARG_ENABLE(tcap-names,
 	[with_tcap_names=$with_ext_funcs])
 AC_MSG_RESULT($with_tcap_names)
 NCURSES_XNAMES=0
-test "x$with_tcap_names" = xyes && NCURSES_XNAMES=1
+if test "x$with_tcap_names" = xyes; then
+	NCURSES_XNAMES=1
+	AC_DEFINE(NCURSES_XNAMES,1,[Define to 1 to compile with user-definable terminal capabilities])
+fi
 AC_SUBST(NCURSES_XNAMES)
 
 ##############################################################################
@@ -1358,19 +1398,19 @@ if test "x$with_reentrant" = xyes ; then
 else
 	cf_cv_enable_reentrant=0
 	cf_cv_enable_opaque="NCURSES_OPAQUE"
-	NCURSES_SIZE_T=short
+	NCURSES_SIZE_T=$cf_dft_ordinate_type
 fi
 AC_SUBST(cf_cv_enable_reentrant)
 AC_SUBST(cf_cv_enable_opaque)
 
 AC_SUBST(NCURSES_SIZE_T)
 
-AC_MSG_CHECKING(if you want opaque curses-library structures)
-CF_ARG_ENABLE(opaque-curses,
-	[  --enable-opaque-curses  make curses WINDOW, etc., "opaque"],
-	[enable_opaque_curses=yes],[
+AC_MSG_CHECKING(whether curses library structures should be opaque)
+CF_ARG_DISABLE(opaque-curses,
+	[  --disable-opaque-curses do not make WINDOW, etc., structures opaque],
+	[enable_opaque_curses=no],[
 	 test "$cf_cv_enable_reentrant" = 1 && enable_opaque_curses=yes
-	 test "$cf_cv_enable_reentrant" = 1 || enable_opaque_curses=no
+	 test "$cf_cv_enable_reentrant" = 1 || enable_opaque_curses=$cf_dft_opaque_curses
 	])
 AC_MSG_RESULT($enable_opaque_curses)
 
@@ -1378,22 +1418,22 @@ test "$cf_cv_enable_reentrant" = 1 && \
 test "$enable_opaque_curses" = no && \
 AC_MSG_ERROR(reentrant configuration requires opaque library)
 
-AC_MSG_CHECKING(if you want opaque form-library structures)
-AC_ARG_ENABLE(opaque-form,
-	[  --enable-opaque-form    make form-library structures "opaque"],
-	[enable_opaque_form=yes],[enable_opaque_form=no])
+AC_MSG_CHECKING(whether form library structures should be opaque)
+CF_ARG_DISABLE(opaque-form,
+	[  --disable-opaque-form   do not make form library structures opaque],
+	[enable_opaque_form=no],[enable_opaque_form=$cf_dft_opaque_curses])
 AC_MSG_RESULT($enable_opaque_form)
 
-AC_MSG_CHECKING(if you want opaque menu-library structures)
-AC_ARG_ENABLE(opaque-menu,
-	[  --enable-opaque-menu    make menu-library structures "opaque"],
-	[enable_opaque_menu=yes],[enable_opaque_menu=no])
+AC_MSG_CHECKING(whether menu library structures should be opaque)
+CF_ARG_DISABLE(opaque-menu,
+	[  --disable-opaque-menu   do not make menu library structures opaque],
+	[enable_opaque_menu=no],[enable_opaque_menu=$cf_dft_opaque_curses])
 AC_MSG_RESULT($enable_opaque_menu)
 
-AC_MSG_CHECKING(if you want opaque panel-library structures)
-AC_ARG_ENABLE(opaque-panel,
-	[  --enable-opaque-panel   make panel-library structures "opaque"],
-	[enable_opaque_panel=yes],[enable_opaque_panel=no])
+AC_MSG_CHECKING(whether panel library structures should be opaque)
+CF_ARG_DISABLE(opaque-panel,
+	[  --disable-opaque-panel  do not make panel library structures opaque],
+	[enable_opaque_panel=no],[enable_opaque_panel=$cf_dft_opaque_curses])
 AC_MSG_RESULT($enable_opaque_panel)
 
 NCURSES_OPAQUE=0;		test "$enable_opaque_curses" = yes && NCURSES_OPAQUE=1
@@ -1430,6 +1470,14 @@ AC_ARG_WITH(develop,
 	[with_develop=no])
 AC_MSG_RESULT($with_develop)
 
+###   use option --enable-check-size to detect screensize with CPR
+AC_MSG_CHECKING(if you want to check screensize of serial terminals)
+AC_ARG_ENABLE(check-size,
+	[  --enable-check-size     compile-in code to detect screensize of serial terminals],,
+	[enable_check_size=$with_develop])
+AC_MSG_RESULT($enable_check_size)
+test "x$enable_check_size" = xyes && AC_DEFINE(USE_CHECK_SIZE,1,[Define to 1 to compile-in code to detect screensize])
+
 ###   use option --enable-hard-tabs to turn on use of hard-tabs optimize
 AC_MSG_CHECKING(if you want hard-tabs code)
 AC_ARG_ENABLE(hard-tabs,
@@ -1616,7 +1664,7 @@ AC_SUBST(INSTALL_OPT_P)
 CF_ENABLE_WARNINGS(Wno-unknown-pragmas Wswitch-enum,yes)
 
 if test "x$enable_warnings" = "xyes"; then
- 	CF_ADD_ADAFLAGS(-gnatg)
+ 	CF_ADD_ADAFLAGS(-gnatwa -gnatyg)
 	if test "x$cf_with_cxx" = xyes ; then
 		CF_GXX_WARNINGS(Wno-unused)
 	fi
@@ -1687,20 +1735,15 @@ CF_DISABLE_GNAT_PROJECTS
 ###	Checks for libraries.
 case "$cf_cv_system_name" in
 (*mingw32*|*mingw64*)
+	# Note: WINVER may be a problem with Windows 10
 	if test "x$with_exp_win32" = xyes ; then
-	CPPFLAGS="$CPPFLAGS -DWINVER=0x0600 -DWIN32_LEAN_AND_MEAN"
+		CPPFLAGS="$CPPFLAGS -DWINVER=0x0600 -DWIN32_LEAN_AND_MEAN"
 	else
-	CPPFLAGS="$CPPFLAGS -DWINVER=0x0501 -DWIN32_LEAN_AND_MEAN"
+		CPPFLAGS="$CPPFLAGS -DWINVER=0x0501 -DWIN32_LEAN_AND_MEAN"
 	fi
-	# Note: WINVER may be a problem with Windows 10
+	CF_CHECK_LIBSSP
 	;;
 (*)
-AC_CHECK_FUNC(gettimeofday,
-	AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define to 1 if we have gettimeofday function]),[
-
-AC_CHECK_LIB(bsd, gettimeofday,
-	AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define to 1 if we have gettimeofday function])
-	CF_ADD_LIB(bsd))])dnl CLIX: bzero, select, gettimeofday
 	;;
 esac
 
@@ -1708,8 +1751,6 @@ CF_MATH_LIB(MATH_LIB,pow(sin(x),x))
 AC_SUBST(MATH_LIB)
 
 ###	Checks for header files.
-AC_STDC_HEADERS
-AC_HEADER_DIRENT
 AC_HEADER_TIME
 CF_REGEX
 
@@ -1721,13 +1762,13 @@ limits.h \
 locale.h \
 math.h \
 poll.h \
+sys/auxv.h \
 sys/ioctl.h \
 sys/param.h \
 sys/poll.h \
 sys/select.h \
 sys/time.h \
 sys/times.h \
-ttyent.h \
 unistd.h \
 wctype.h \
 )
@@ -1777,21 +1818,23 @@ CF_ERRNO
 CF_LINK_DATAONLY
 
 ###	Checks for library functions.
+CF_FUNC_GETTIME
 AC_CHECK_FUNCS( \
+fpathconf \
 getcwd \
+getauxval \
 getegid \
 geteuid \
 getopt \
-getttynam \
+getuid \
 issetugid \
 localeconv \
 poll \
-putenv \
 remove \
 select \
 setbuf \
 setbuffer \
-setenv \
+setfsuid \
 setvbuf \
 sigaction \
 sigvec \
@@ -1805,6 +1848,8 @@ tsearch \
 vsnprintf \
 )
 
+CF_FUNC_GETTTYNAM
+
 if test "x$ac_cv_func_getopt" = xno && \
    test "x$cf_with_progs$cf_with_tests" != xnono; then
 	AC_MSG_ERROR(getopt is required for building programs)
@@ -1846,6 +1891,7 @@ CF_TYPE_SIGACTION
 CF_SIZECHANGE
 CF_FUNC_MEMMOVE
 CF_FUNC_POLL
+CF_MB_LEN_MAX
 CF_VA_COPY
 AC_FUNC_VFORK
 CF_FOPEN_BIN_R
@@ -1899,6 +1945,7 @@ if test -n "$CXX" ; then
 	CF_BOOL_DECL
 	CF_BOOL_SIZE
 	CF_ETIP_DEFINES
+	CF_CPP_OVERRIDE
 	CF_CPP_PARAM_INIT
 	CF_CPP_STATIC_CAST
 	CF_CXX_AR_FLAGS
@@ -2293,14 +2340,11 @@ AC_SUBST(TICS_LIST)
 AC_SUBST(TINFO_LIST)
 AC_SUBST(SHLIB_LIST)
 
-# used to separate tack out of the tree
-NCURSES_TREE=
-AC_SUBST(NCURSES_TREE)
-
 ### predefined stuff for the test programs
 AC_DEFINE(HAVE_SLK_COLOR,1,[Define to 1 if we have slk_color for test-programs])
 
 # pkgsrc uses these
+CF_HELP_MESSAGE(Library basenames for pkgsrc:)
 CF_WITH_LIB_BASENAME(FORM_NAME,form)
 CF_WITH_LIB_BASENAME(MENU_NAME,menu)
 CF_WITH_LIB_BASENAME(PANEL_NAME,panel)
@@ -2382,7 +2426,7 @@ esac
 
 # Help to automatically enable the extended curses features when using either
 # the *-config or the ".pc" files by adding defines.
-AC_MSG_CHECKING(for defines to add to ncurses${USE_CFG_SUFFIX}-config script)
+AC_MSG_CHECKING(for defines to add to ncurses${USE_CFG_SUFFIX}${cf_config_suffix}-config script)
 PKG_CFLAGS=
 for cf_loop1 in $CPPFLAGS_after_XOPEN
 do
@@ -2457,7 +2501,7 @@ cf_filter_syms=no
 if test -n "$RESULTING_SYMS"
 then
 	cf_filter_syms=$cf_dft_filter_syms
-	CF_VERBOSE(will map symbols to ABI=$cf_cv_abi_version)
+	CF_VERBOSE(will map symbols to ABI=$cf_cv_abi_default)
 fi
 
 if test "x$WILDCARD_SYMS" = xno
@@ -2488,20 +2532,20 @@ AC_SUBST(PRIVATE_LIBS)
 # This is used for the *-config script and *.pc data files.
 CF_LD_SEARCHPATH
 
-AC_DEFINE(HAVE_CURSES_DATA_BOOLNAMES,1,[definition needed for in-tree build of tack])
-
 AC_OUTPUT( \
 	include/MKterm.h.awk \
 	include/curses.head:include/curses.h.in \
 	include/ncurses_dll.h \
 	include/termcap.h \
 	include/unctrl.h \
+	man/man_db.renames \
 	$SUB_MAKEFILES \
 	Makefile,[
 if test "x$cf_with_tests" != xno ; then
 	CF_PRG_RULES(["$srcdir/test/mk-test.awk" INSTALL=no ECHO_LINK="$ECHO_LD"], test)
 fi
 CF_LIB_RULES($SRC_SUBDIRS)
+CF_OUTPUT_MANPAGE_RENAMES
 
 if test "x$cf_with_ada" = "xyes" && test "x$cf_cv_prog_gnat_correct" = "xyes"; then
 if test -z "$USE_OLD_MAKERULES" ; then
@@ -2529,6 +2573,7 @@ LIB_SUFFIX="$LIB_SUFFIX"
 LIB_TRACING="$LIB_TRACING"
 LN_S="$LN_S"
 MAKE_TERMINFO="$MAKE_TERMINFO"
+MANPAGE_RENAMES="$MANPAGE_RENAMES"
 MENU_NAME="$MENU_NAME"
 NCURSES_MAJOR="$NCURSES_MAJOR"
 NCURSES_MINOR="$NCURSES_MINOR"
@@ -2558,12 +2603,14 @@ WITH_OVERWRITE="$with_overwrite"
 cf_LIST_MODELS="$cf_list_models"
 cf_cv_VERSION_GNATMAKE=$cf_cv_VERSION_GNATMAKE
 cf_cv_VERSION_GPRBUILD=$cf_cv_VERSION_GPRBUILD
+cf_cv_abi_default="$cf_cv_abi_default"
 cf_cv_abi_version="$cf_cv_abi_version"
 cf_cv_do_relink="$cf_cv_do_relink"
 cf_cv_do_reranlib="$cf_cv_do_reranlib"
 cf_cv_do_symlinks="$cf_cv_do_symlinks"
 cf_cv_enable_lp64="$cf_cv_enable_lp64"
 cf_cv_enable_opaque="$cf_cv_enable_opaque"
+cf_cv_make_PHONY="$cf_cv_make_PHONY"
 cf_cv_prog_CC_c_o=$cf_cv_prog_CC_c_o
 cf_cv_prog_CXX_c_o=$cf_cv_prog_CXX_c_o
 cf_cv_prog_gnat_correct=$cf_cv_prog_gnat_correct
@@ -2581,6 +2628,7 @@ cf_with_manpages="$cf_with_manpages"
 cf_with_tests="$cf_with_tests"
 host="$host"
 target="$target"
+verbose="$verbose"
 with_shared_cxx="$with_shared_cxx"
 
 ],cat)dnl
diff --git a/contrib/ncurses/dist.mk b/contrib/ncurses/dist.mk
index ceead1705338..18484d8ca5c9 100644
--- a/contrib/ncurses/dist.mk
+++ b/contrib/ncurses/dist.mk
@@ -1,5 +1,5 @@
 ##############################################################################
-# Copyright 2018-2020,2021 Thomas E. Dickey                                  #
+# Copyright 2018-2023,2024 Thomas E. Dickey                                  #
 # Copyright 1998-2017,2018 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -26,7 +26,7 @@
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
-# $Id: dist.mk,v 1.1401 2021/02/20 12:06:34 tom Exp $
+# $Id: dist.mk,v 1.1610 2024/04/27 13:55:54 tom Exp $
 # Makefile for creating ncurses distributions.
 #
 # This only needs to be used directly as a makefile by developers, but
@@ -37,8 +37,8 @@ SHELL = /bin/sh
 
 # These define the major/minor/patch versions of ncurses.
 NCURSES_MAJOR = 6
-NCURSES_MINOR = 2
-NCURSES_PATCH = 20210220
+NCURSES_MINOR = 5
+NCURSES_PATCH = 20240427
 
 # We don't append the patch to the version, since this only applies to releases
 VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)
@@ -63,7 +63,7 @@ GNATHTML= gnathtml
 # would remove some text.  The man program on Redhat 6.1 appears to work with
 # man2html if we set the top/bottom margins to 6 (the default is 7).  Newer
 # versions of 'man' leave no margin (and make it harder to sync with pages).
-MAN2HTML= man2html -botm=0 -topm=0 -cgiurl '$$title.$$section$$subsection.html' -index
+MAN2HTML= man2html -botm=0 -topm=0 -cgiurl '$$title.$$section$$subsection.html' -index -mixsecs
 
 ALL	= ANNOUNCE doc/html/announce.html doc/ncurses-intro.doc doc/hackguide.doc manhtml adahtml
 
@@ -124,19 +124,20 @@ manhtml:
 	@echo 's/<I>/<EM>/g'         >> subst.tmp
 	@echo 's/<\/I>/<\/EM>/g'     >> subst.tmp
 	@misc/csort < subst.tmp | uniq > subst.sed
-	@echo '/<\/TITLE>/a\' >> subst.sed
-	@echo '<link rel="author" href="mailto:bug-ncurses@gnu.org">\' >> subst.sed
-	@echo '<meta http-equiv="Content-Type" content="text\/html; charset=iso-8859-1">' >> subst.sed
+	@echo 's%[_-]*_-[_-]*%_%g'   >> subst.sed
+	@echo '/<\/TITLE>/a\\'       >> subst.sed
+	@echo '<link rel="author" href="mailto:bug-ncurses@gnu.org">\\' >> subst.sed
 	@rm -f subst.tmp
 	@for f in man/*.[0-9]* ; do \
 	   m=`basename $$f` ;\
-	   T=`egrep '^.TH' $$f|sed -e 's/^.TH //' -e s'/"//g' -e 's/[ 	]\+$$//'` ; \
+	   T=`$${EGREP-grep -E} '^.TH' $$f|sed -e 's/^.TH //' -e s'/"//g' -e 's/[ 	]\+$$//'` ; \
 	   g=$${m}.html ;\
 	   if [ -f doc/html/$$g ]; then chmod +w doc/html/$$g; fi;\
 	   echo "Converting $$m to HTML" ;\
-	   echo '<!-- ' > doc/html/man/$$g ;\
-	   egrep '^.\\"[^#]' $$f | \
-	   	sed	-e 's/\$$/@/g' \
+	   echo '<!--' > doc/html/man/$$g ;\
+		sed	-e '/^\.[a-zA-Z]/,99999d' $$f | \
+		$${EGREP-grep -E} '^.\\"[^#]' | \
+		sed	-e 's/\$$/@/g' \
 			-e 's/^.../  */' \
 			-e 's/</\&lt;/g' \
 			-e 's/>/\&gt;/g' \
diff --git a/contrib/ncurses/doc/hackguide.doc b/contrib/ncurses/doc/hackguide.doc
index 1bafad2ad10b..a464d0336597 100644
--- a/contrib/ncurses/doc/hackguide.doc
+++ b/contrib/ncurses/doc/hackguide.doc
@@ -1,6 +1,8 @@
                           A Hacker's Guide to NCURSES
 
-                                   Contents
+A Hacker's Guide to NCURSES
+
+Contents
 
      * Abstract
      * Objective of the Package
@@ -24,7 +26,7 @@
      * Style Tips for Developers
      * Porting Hints
 
-                                   Abstract
+Abstract
 
    This document is a hacker's tour of the ncurses library and utilities.
    It  discusses  design  philosophy,  implementation  methods,  and  the
@@ -32,7 +34,7 @@
    reading  for  anyone  who  is  interested  in  porting,  extending  or
    improving the package.
 
-                           Objective of the Package
+Objective of the Package
 
    The objective of the ncurses package is to provide a free software API
    for character-cell terminals and terminal emulators with the following
@@ -52,7 +54,7 @@
    cannot  add  features  if  it  means  breaking  the portion of the API
    corresponding to historical curses versions.
 
-Why System V Curses?
+  Why System V Curses?
 
    We  used System V curses as a model, reverse-engineering their API, in
    order to fulfill the first two objectives.
@@ -65,7 +67,7 @@ Why System V Curses?
    X/Open  is  explicitly and closely modeled on System V. So conformance
    with System V took us most of the way to base-level XSI conformance.
 
-How to Design Extensions
+  How to Design Extensions
 
    The  third  objective (standards conformance) requires that it be easy
    to  condition  source  code  using  ncurses  so  that  the  absence of
@@ -80,7 +82,7 @@ How to Design Extensions
    does  not  define, but which is defined in the ncurses library header.
    You can use this to condition the calls to the mouse API calls.
 
-                         Portability and Configuration
+Portability and Configuration
 
    Code  written  for  ncurses may assume an ANSI-standard C compiler and
    POSIX-compatible  OS  interface.  It may also assume the presence of a
@@ -101,7 +103,7 @@ How to Design Extensions
    specification  files  (configure.in  and  aclocal.m4)  to set up a new
    feature macro, which you then use to condition your code.
 
-                           Documentation Conventions
+Documentation Conventions
 
    There  are  three kinds of documentation associated with this package.
    Each has a different preferred format:
@@ -111,7 +113,7 @@ How to Design Extensions
 
    Our conventions are simple:
     1. Maintain package-internal files in plain text. The expected viewer
-       for  them  more(1)  or  an  editor  window;  there  is no point in
+       for  them  is  more(1)  or  an editor window; there is no point in
        elaborate mark-up.
     2. Mark  up manual pages in the man macros. These have to be viewable
        through traditional man(1) programs.
@@ -127,7 +129,7 @@ How to Design Extensions
    nice-looking  printed  version  from  it.  Also,  of  course,  it make
    exporting things like the announcement document to WWW pretty trivial.
 
-                              How to Report Bugs
+How to Report Bugs
 
    The  reporting  address  for  bugs  is  bug-ncurses@gnu.org. This is a
    majordomo  list;  to join, write to bug-ncurses-request@gnu.org with a
@@ -228,9 +230,9 @@ How to Design Extensions
    comments  of hardscroll.c and hashmap.c; then try it out. You can also
    test the hardware-scrolling optimization separately with hardscroll.
 
-                         A Tour of the Ncurses Library
+A Tour of the Ncurses Library
 
-Library Overview
+  Library Overview
 
    Most  of  the  library is superstructure -- fairly trivial convenience
    interfaces  to a small set of basic functions and data structures used
@@ -303,9 +305,9 @@ Library Overview
 
    We will discuss these in the compiler tour.
 
-The Engine Room
+  The Engine Room
 
-  Keyboard Input
+    Keyboard Input
 
    All  ncurses  input  funnels through the function wgetch(), defined in
    lib_getch.c.  This function is tricky; it has to poll for keyboard and
@@ -328,7 +330,7 @@ The Engine Room
    value.  The  function  timed_wait()  effectively  simulates a System V
    select.
 
-  Mouse Events
+    Mouse Events
 
    If the mouse interface is active, wgetch() polls for mouse events each
    call,  before  it  goes  to  the  keyboard  for  input.  It  is  up to
@@ -368,7 +370,7 @@ The Engine Room
    accepted to parse the digested mouse reports (low-level events) into a
    gesture (a high-level or composite event).
 
-  Output and Screen Updating
+    Output and Screen Updating
 
    With the single exception of character echoes during a wgetnstr() call
    (which  simulates  cooked-mode line editing in an ncurses window), the
@@ -412,7 +414,7 @@ The Engine Room
    variable  _nc_optimize_enable.  See  the  file include/curses.h.in for
    mask values, near the end.
 
-                         The Forms and Menu Libraries
+The Forms and Menu Libraries
 
    The  forms  and menu libraries should work reliably in any environment
    you  can  port ncurses to. The only portability issue anywhere in them
@@ -428,7 +430,7 @@ The Engine Room
    panels  support; u386mon 2.10 and beyond use it. This version has been
    slightly cleaned up for ncurses.
 
-                        A Tour of the Terminfo Compiler
+A Tour of the Terminfo Compiler
 
    The ncurses implementation of tic is rather complex internally; it has
    to  do  a  trying  combination  of missions. This starts with the fact
@@ -443,7 +445,7 @@ The Engine Room
    the  grammar above it is trivial, just "parse entries till you run out
    of file".
 
-Translation of Non-use Capabilities
+  Translation of Non-use Capabilities
 
    Translation   of  most  things  besides  use  capabilities  is  pretty
    straightforward.   The   lexical   analyzer's   tokenizer  hands  each
@@ -464,7 +466,7 @@ Translation of Non-use Capabilities
    of  adding one line to the include/Caps file. We will have more to say
    about this in the section on Source-Form Translation.
 
-Use Capability Resolution
+  Use Capability Resolution
 
    The  background  problem  that  makes tic tricky is not the capability
    translation  itself,  it  is the resolution of use capabilities. Older
@@ -512,7 +514,7 @@ Use Capability Resolution
    complain  about overwriting entries newly made during the tic run, but
    not about overwriting ones that predate it.
 
-Source-Form Translation
+  Source-Form Translation
 
    Another use of tic is to do source translation between various termcap
    and terminfo formats. There are more variants out there than you might
@@ -536,7 +538,7 @@ Source-Form Translation
    for  example,  is  where  the AIX box1 capability get translated to an
    acsc string.
 
-                                Other Utilities
+Other Utilities
 
    The  infocmp  utility  is just a wrapper around the same entry-dumping
    code  used  by tic for source translation. Perhaps the one interesting
@@ -548,7 +550,7 @@ Source-Form Translation
    The  tput  and  clear  utilities  just  do an entry load followed by a
    tputs() of a selected capability.
 
-                           Style Tips for Developers
+Style Tips for Developers
 
    See   the  TO-DO  file  in  the  top-level  directory  of  the  source
    distribution for additions that would be particularly useful.
@@ -575,7 +577,7 @@ Source-Form Translation
 
    Have fun!
 
-                                 Porting Hints
+Porting Hints
 
    The  following  notes  are intended to be a first step towards DOS and
    Macintosh ports of the ncurses libraries.
diff --git a/contrib/ncurses/doc/html/NCURSES-Programming-HOWTO.html b/contrib/ncurses/doc/html/NCURSES-Programming-HOWTO.html
deleted file mode 100644
index d3eeb95dbccc..000000000000
--- a/contrib/ncurses/doc/html/NCURSES-Programming-HOWTO.html
+++ /dev/null
@@ -1,7415 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
-"http://www.w3.org/TR/html4/strict.dtd">
-
-<html>
-<head>
-  <meta name="generator" content=
-  "HTML Tidy for Linux (vers 25 March 2009), see www.w3.org">
-
-  <title>NCURSES Programming HOWTO</title>
-  <meta name="GENERATOR" content=
-  "Modular DocBook HTML Stylesheet Version 1.79">
-</head>
-
-<body class="ARTICLE" bgcolor="#FFFFFF" text="#000000" link=
-"#0000FF" vlink="#840084" alink="#0000FF">
-  <div class="ARTICLE">
-    <div class="TITLEPAGE">
-      <h1 class="TITLE"><a name="AEN2" id="AEN2">NCURSES
-      Programming HOWTO</a></h1>
-
-      <h3 class="AUTHOR"><a name="AEN4" id="AEN4">Pradeep
-      Padala</a></h3>
-
-      <div class="AFFILIATION">
-        <div class="ADDRESS">
-          <p class="ADDRESS"><code class="EMAIL">&lt;<a href=
-          "mailto:ppadala@gmail.com">ppadala@gmail.com</a>&gt;</code></p>
-        </div>
-      </div>
-
-      <p class="PUBDATE">v1.9, 2005-06-20<br></p>
-
-      <div class="REVHISTORY">
-        <table width="100%" border="0" summary="revisions">
-          <tr>
-            <th align="left" valign="top" colspan="3"><b>Revision
-            History</b></th>
-          </tr>
-
-          <tr>
-            <td align="left">Revision 1.9</td>
-
-            <td align="left">2005-06-20</td>
-
-            <td align="left">Revised by: ppadala</td>
-          </tr>
-
-          <tr>
-            <td align="left" colspan="3">The license has been
-            changed to the MIT-style license used by NCURSES. Note
-            that the programs are also re-licensed under this.</td>
-          </tr>
-
-          <tr>
-            <td align="left">Revision 1.8</td>
-
-            <td align="left">2005-06-17</td>
-
-            <td align="left">Revised by: ppadala</td>
-          </tr>
-
-          <tr>
-            <td align="left" colspan="3">Lots of updates. Added
-            references and perl examples. Changes to examples. Many
-            grammatical and stylistic changes to the content.
-            Changes to NCURSES history.</td>
-          </tr>
-
-          <tr>
-            <td align="left">Revision 1.7.1</td>
-
-            <td align="left">2002-06-25</td>
-
-            <td align="left">Revised by: ppadala</td>
-          </tr>
-
-          <tr>
-            <td align="left" colspan="3">Added a README file for
-            building and instructions for building from
-            source.</td>
-          </tr>
-
-          <tr>
-            <td align="left">Revision 1.7</td>
-
-            <td align="left">2002-06-25</td>
-
-            <td align="left">Revised by: ppadala</td>
-          </tr>
-
-          <tr>
-            <td align="left" colspan="3">Added "Other formats"
-            section and made a lot of fancy changes to the
-            programs. Inlining of programs is gone.</td>
-          </tr>
-
-          <tr>
-            <td align="left">Revision 1.6.1</td>
-
-            <td align="left">2002-02-24</td>
-
-            <td align="left">Revised by: ppadala</td>
-          </tr>
-
-          <tr>
-            <td align="left" colspan="3">Removed the old Changelog
-            section, cleaned the makefiles</td>
-          </tr>
-
-          <tr>
-            <td align="left">Revision 1.6</td>
-
-            <td align="left">2002-02-16</td>
-
-            <td align="left">Revised by: ppadala</td>
-          </tr>
-
-          <tr>
-            <td align="left" colspan="3">Corrected a lot of
-            spelling mistakes, added ACS variables section</td>
-          </tr>
-
-          <tr>
-            <td align="left">Revision 1.5</td>
-
-            <td align="left">2002-01-05</td>
-
-            <td align="left">Revised by: ppadala</td>
-          </tr>
-
-          <tr>
-            <td align="left" colspan="3">Changed structure to
-            present proper TOC</td>
-          </tr>
-
-          <tr>
-            <td align="left">Revision 1.3.1</td>
-
-            <td align="left">2001-07-26</td>
-
-            <td align="left">Revised by: ppadala</td>
-          </tr>
-
-          <tr>
-            <td align="left" colspan="3">Corrected maintainers
-            paragraph, Corrected stable release number</td>
-          </tr>
-
-          <tr>
-            <td align="left">Revision 1.3</td>
-
-            <td align="left">2001-07-24</td>
-
-            <td align="left">Revised by: ppadala</td>
-          </tr>
-
-          <tr>
-            <td align="left" colspan="3">Added copyright notices to
-            main document (LDP license) and programs (GPL),
-            Corrected printw_example.</td>
-          </tr>
-
-          <tr>
-            <td align="left">Revision 1.2</td>
-
-            <td align="left">2001-06-05</td>
-
-            <td align="left">Revised by: ppadala</td>
-          </tr>
-
-          <tr>
-            <td align="left" colspan="3">Incorporated ravi's
-            changes. Mainly to introduction, menu, form, justforfun
-            sections</td>
-          </tr>
-
-          <tr>
-            <td align="left">Revision 1.1</td>
-
-            <td align="left">2001-05-22</td>
-
-            <td align="left">Revised by: ppadala</td>
-          </tr>
-
-          <tr>
-            <td align="left" colspan="3">Added "a word about
-            window" section, Added scanw_example.</td>
-          </tr>
-        </table>
-      </div>
-
-      <div>
-        <div class="ABSTRACT">
-          <a name="AEN67" id="AEN67"></a>
-
-          <p><span class="emphasis"><i class="EMPHASIS">This
-          document is intended to be an "All in One" guide for
-          programming with ncurses and its sister libraries. We
-          graduate from a simple "Hello World" program to more
-          complex form manipulation. No prior experience in ncurses
-          is assumed. Send comments to <a href=
-          "mailto:ppadala@gmail.com" target="_top">this
-          address</a></i></span></p>
-        </div>
-      </div>
-      <hr>
-    </div>
-
-    <div class="TOC">
-      <dl>
-        <dt><b>Table of Contents</b></dt>
-
-        <dt>1. <a href="#INTRO">Introduction</a></dt>
-
-        <dd>
-          <dl>
-            <dt>1.1. <a href="#WHATIS">What is NCURSES?</a></dt>
-
-            <dt>1.2. <a href="#WHATCANWEDO">What we can do with
-            NCURSES</a></dt>
-
-            <dt>1.3. <a href="#WHERETOGETIT">Where to get
-            it</a></dt>
-
-            <dt>1.4. <a href="#PURPOSE">Purpose/Scope of the
-            document</a></dt>
-
-            <dt>1.5. <a href="#ABOUTPROGRAMS">About the
-            Programs</a></dt>
-
-            <dt>1.6. <a href="#OTHERFORMATS">Other Formats of the
-            document</a></dt>
-
-            <dd>
-              <dl>
-                <dt>1.6.1. <a href="#LISTFORMATS">Readily available
-                formats from tldp.org</a></dt>
-
-                <dt>1.6.2. <a href="#BUILDSOURCE">Building from
-                source</a></dt>
-              </dl>
-            </dd>
-
-            <dt>1.7. <a href="#CREDITS">Credits</a></dt>
-
-            <dt>1.8. <a href="#WISHLIST">Wish List</a></dt>
-
-            <dt>1.9. <a href="#COPYRIGHT">Copyright</a></dt>
-          </dl>
-        </dd>
-
-        <dt>2. <a href="#HELLOWORLD">Hello World !!!</a></dt>
-
-        <dd>
-          <dl>
-            <dt>2.1. <a href="#COMPILECURSES">Compiling With the
-            NCURSES Library</a></dt>
-
-            <dt>2.2. <a href="#DISSECTION">Dissection</a></dt>
-
-            <dd>
-              <dl>
-                <dt>2.2.1. <a href="#ABOUT-INITSCR">About
-                initscr()</a></dt>
-
-                <dt>2.2.2. <a href="#MYST-REFRESH">The mysterious
-                refresh()</a></dt>
-
-                <dt>2.2.3. <a href="#ABOUT-ENDWIN">About
-                endwin()</a></dt>
-              </dl>
-            </dd>
-          </dl>
-        </dd>
-
-        <dt>3. <a href="#GORY">The Gory Details</a></dt>
-
-        <dt>4. <a href="#INIT">Initialization</a></dt>
-
-        <dd>
-          <dl>
-            <dt>4.1. <a href="#ABOUTINIT">Initialization
-            functions</a></dt>
-
-            <dt>4.2. <a href="#RAWCBREAK">raw() and
-            cbreak()</a></dt>
-
-            <dt>4.3. <a href="#ECHONOECHO">echo() and
-            noecho()</a></dt>
-
-            <dt>4.4. <a href="#KEYPAD">keypad()</a></dt>
-
-            <dt>4.5. <a href="#HALFDELAY">halfdelay()</a></dt>
-
-            <dt>4.6. <a href="#MISCINIT">Miscellaneous
-            Initialization functions</a></dt>
-
-            <dt>4.7. <a href="#INITEX">An Example</a></dt>
-          </dl>
-        </dd>
-
-        <dt>5. <a href="#AWORDWINDOWS">A Word about
-        Windows</a></dt>
-
-        <dt>6. <a href="#PRINTW">Output functions</a></dt>
-
-        <dd>
-          <dl>
-            <dt>6.1. <a href="#ADDCHCLASS">addch() class of
-            functions</a></dt>
-
-            <dt>6.2. <a href="#AEN298">mvaddch(), waddch() and
-            mvwaddch()</a></dt>
-
-            <dt>6.3. <a href="#PRINTWCLASS">printw() class of
-            functions</a></dt>
-
-            <dd>
-              <dl>
-                <dt>6.3.1. <a href="#PRINTWMVPRINTW">printw() and
-                mvprintw</a></dt>
-
-                <dt>6.3.2. <a href="#WPRINTWMVWPRINTW">wprintw()
-                and mvwprintw</a></dt>
-
-                <dt>6.3.3. <a href="#VWPRINTW">vw_printw()</a></dt>
-
-                <dt>6.3.4. <a href="#SIMPLEPRINTWEX">A Simple
-                printw example</a></dt>
-              </dl>
-            </dd>
-
-            <dt>6.4. <a href="#ADDSTRCLASS">addstr() class of
-            functions</a></dt>
-
-            <dt>6.5. <a href="#ACAUTION">A word of caution</a></dt>
-          </dl>
-        </dd>
-
-        <dt>7. <a href="#SCANW">Input functions</a></dt>
-
-        <dd>
-          <dl>
-            <dt>7.1. <a href="#GETCHCLASS">getch() class of
-            functions</a></dt>
-
-            <dt>7.2. <a href="#SCANWCLASS">scanw() class of
-            functions</a></dt>
-
-            <dd>
-              <dl>
-                <dt>7.2.1. <a href="#SCANWMVSCANW">scanw() and
-                mvscanw</a></dt>
-
-                <dt>7.2.2. <a href="#WSCANWMVWSCANW">wscanw() and
-                mvwscanw()</a></dt>
-
-                <dt>7.2.3. <a href="#VWSCANW">vw_scanw()</a></dt>
-              </dl>
-            </dd>
-
-            <dt>7.3. <a href="#GETSTRCLASS">getstr() class of
-            functions</a></dt>
-
-            <dt>7.4. <a href="#GETSTREX">Some examples</a></dt>
-          </dl>
-        </dd>
-
-        <dt>8. <a href="#ATTRIB">Attributes</a></dt>
-
-        <dd>
-          <dl>
-            <dt>8.1. <a href="#ATTRIBDETAILS">The details</a></dt>
-
-            <dt>8.2. <a href="#ATTRONVSATTRSET">attron() vs
-            attrset()</a></dt>
-
-            <dt>8.3. <a href="#ATTRGET">attr_get()</a></dt>
-
-            <dt>8.4. <a href="#ATTRFUNCS">attr_ functions</a></dt>
-
-            <dt>8.5. <a href="#WATTRFUNCS">wattr functions</a></dt>
-
-            <dt>8.6. <a href="#CHGAT">chgat() functions</a></dt>
-          </dl>
-        </dd>
-
-        <dt>9. <a href="#WINDOWS">Windows</a></dt>
-
-        <dd>
-          <dl>
-            <dt>9.1. <a href="#WINDOWBASICS">The basics</a></dt>
-
-            <dt>9.2. <a href="#LETBEWINDOW">Let there be a Window
-            !!!</a></dt>
-
-            <dt>9.3. <a href="#BORDEREXEXPL">Explanation</a></dt>
-
-            <dt>9.4. <a href="#OTHERSTUFF">The other stuff in the
-            example</a></dt>
-
-            <dt>9.5. <a href="#OTHERBORDERFUNCS">Other Border
-            functions</a></dt>
-          </dl>
-        </dd>
-
-        <dt>10. <a href="#COLOR">Colors</a></dt>
-
-        <dd>
-          <dl>
-            <dt>10.1. <a href="#COLORBASICS">The basics</a></dt>
-
-            <dt>10.2. <a href="#CHANGECOLORDEFS">Changing Color
-            Definitions</a></dt>
-
-            <dt>10.3. <a href="#COLORCONTENT">Color
-            Content</a></dt>
-          </dl>
-        </dd>
-
-        <dt>11. <a href="#KEYS">Interfacing with the key
-        board</a></dt>
-
-        <dd>
-          <dl>
-            <dt>11.1. <a href="#KEYSBASICS">The Basics</a></dt>
-
-            <dt>11.2. <a href="#SIMPLEKEYEX">A Simple Key Usage
-            example</a></dt>
-          </dl>
-        </dd>
-
-        <dt>12. <a href="#MOUSE">Interfacing with the
-        mouse</a></dt>
-
-        <dd>
-          <dl>
-            <dt>12.1. <a href="#MOUSEBASICS">The Basics</a></dt>
-
-            <dt>12.2. <a href="#GETTINGEVENTS">Getting the
-            events</a></dt>
-
-            <dt>12.3. <a href="#MOUSETOGETHER">Putting it all
-            Together</a></dt>
-
-            <dt>12.4. <a href="#MISCMOUSEFUNCS">Miscellaneous
-            Functions</a></dt>
-          </dl>
-        </dd>
-
-        <dt>13. <a href="#SCREEN">Screen Manipulation</a></dt>
-
-        <dd>
-          <dl>
-            <dt>13.1. <a href="#GETYX">getyx() functions</a></dt>
-
-            <dt>13.2. <a href="#SCREENDUMP">Screen Dumping</a></dt>
-
-            <dt>13.3. <a href="#WINDOWDUMP">Window Dumping</a></dt>
-          </dl>
-        </dd>
-
-        <dt>14. <a href="#MISC">Miscellaneous features</a></dt>
-
-        <dd>
-          <dl>
-            <dt>14.1. <a href="#CURSSET">curs_set()</a></dt>
-
-            <dt>14.2. <a href="#TEMPLEAVE">Temporarily Leaving
-            Curses mode</a></dt>
-
-            <dt>14.3. <a href="#ACSVARS">ACS_ variables</a></dt>
-          </dl>
-        </dd>
-
-        <dt>15. <a href="#OTHERLIB">Other libraries</a></dt>
-
-        <dt>16. <a href="#PANELS">Panel Library</a></dt>
-
-        <dd>
-          <dl>
-            <dt>16.1. <a href="#PANELBASICS">The Basics</a></dt>
-
-            <dt>16.2. <a href="#COMPILEPANELS">Compiling With the
-            Panels Library</a></dt>
-
-            <dt>16.3. <a href="#PANELBROWSING">Panel Window
-            Browsing</a></dt>
-
-            <dt>16.4. <a href="#USERPTRUSING">Using User
-            Pointers</a></dt>
-
-            <dt>16.5. <a href="#PANELMOVERESIZE">Moving and
-            Resizing Panels</a></dt>
-
-            <dt>16.6. <a href="#PANELSHOWHIDE">Hiding and Showing
-            Panels</a></dt>
-
-            <dt>16.7. <a href="#PANELABOVE">panel_above() and
-            panel_below() Functions</a></dt>
-          </dl>
-        </dd>
-
-        <dt>17. <a href="#MENUS">Menus Library</a></dt>
-
-        <dd>
-          <dl>
-            <dt>17.1. <a href="#MENUBASICS">The Basics</a></dt>
-
-            <dt>17.2. <a href="#COMPILEMENUS">Compiling With the
-            Menu Library</a></dt>
-
-            <dt>17.3. <a href="#MENUDRIVER">Menu Driver: The work
-            horse of the menu system</a></dt>
-
-            <dt>17.4. <a href="#MENUWINDOWS">Menu Windows</a></dt>
-
-            <dt>17.5. <a href="#SCROLLMENUS">Scrolling
-            Menus</a></dt>
-
-            <dt>17.6. <a href="#MULTICOLUMN">Multi Columnar
-            Menus</a></dt>
-
-            <dt>17.7. <a href="#MULTIVALUEMENUS">Multi Valued
-            Menus</a></dt>
-
-            <dt>17.8. <a href="#MENUOPT">Menu Options</a></dt>
-
-            <dt>17.9. <a href="#MENUUSERPTR">The useful User
-            Pointer</a></dt>
-          </dl>
-        </dd>
-
-        <dt>18. <a href="#FORMS">Forms Library</a></dt>
-
-        <dd>
-          <dl>
-            <dt>18.1. <a href="#FORMBASICS">The Basics</a></dt>
-
-            <dt>18.2. <a href="#COMPILEFORMS">Compiling With the
-            Forms Library</a></dt>
-
-            <dt>18.3. <a href="#PLAYFIELDS">Playing with
-            Fields</a></dt>
-
-            <dd>
-              <dl>
-                <dt>18.3.1. <a href="#FETCHINFO">Fetching Size and
-                Location of Field</a></dt>
-
-                <dt>18.3.2. <a href="#MOVEFIELD">Moving the
-                field</a></dt>
-
-                <dt>18.3.3. <a href="#JUSTIFYFIELD">Field
-                Justification</a></dt>
-
-                <dt>18.3.4. <a href="#FIELDDISPATTRIB">Field
-                Display Attributes</a></dt>
-
-                <dt>18.3.5. <a href="#FIELDOPTIONBITS">Field Option
-                Bits</a></dt>
-
-                <dt>18.3.6. <a href="#FIELDSTATUS">Field
-                Status</a></dt>
-
-                <dt>18.3.7. <a href="#FIELDUSERPTR">Field User
-                Pointer</a></dt>
-
-                <dt>18.3.8. <a href=
-                "#VARIABLESIZEFIELDS">Variable-Sized
-                Fields</a></dt>
-              </dl>
-            </dd>
-
-            <dt>18.4. <a href="#FORMWINDOWS">Form Windows</a></dt>
-
-            <dt>18.5. <a href="#FILEDVALIDATE">Field
-            Validation</a></dt>
-
-            <dt>18.6. <a href="#FORMDRIVER">Form Driver: The work
-            horse of the forms system</a></dt>
-
-            <dd>
-              <dl>
-                <dt>18.6.1. <a href="#PAGENAVREQ">Page Navigation
-                Requests</a></dt>
-
-                <dt>18.6.2. <a href="#INTERFIELDNAVREQ">Inter-Field
-                Navigation Requests</a></dt>
-
-                <dt>18.6.3. <a href="#INTRAFIELDNAVREQ">Intra-Field
-                Navigation Requests</a></dt>
-
-                <dt>18.6.4. <a href="#SCROLLREQ">Scrolling
-                Requests</a></dt>
-
-                <dt>18.6.5. <a href="#EDITREQ">Editing
-                Requests</a></dt>
-
-                <dt>18.6.6. <a href="#ORDERREQ">Order
-                Requests</a></dt>
-
-                <dt>18.6.7. <a href="#APPLICCOMMANDS">Application
-                Commands</a></dt>
-              </dl>
-            </dd>
-          </dl>
-        </dd>
-
-        <dt>19. <a href="#TOOLS">Tools and Widget
-        Libraries</a></dt>
-
-        <dd>
-          <dl>
-            <dt>19.1. <a href="#CDK">CDK (Curses Development
-            Kit)</a></dt>
-
-            <dd>
-              <dl>
-                <dt>19.1.1. <a href="#WIDGETLIST">Widget
-                List</a></dt>
-
-                <dt>19.1.2. <a href="#CDKATTRACT">Some Attractive
-                Features</a></dt>
-
-                <dt>19.1.3. <a href=
-                "#CDKCONCLUSION">Conclusion</a></dt>
-              </dl>
-            </dd>
-
-            <dt>19.2. <a href="#DIALOG">The dialog</a></dt>
-
-            <dt>19.3. <a href="#PERLCURSES">Perl Curses Modules
-            CURSES::FORM and CURSES::WIDGETS</a></dt>
-          </dl>
-        </dd>
-
-        <dt>20. <a href="#JUSTFORFUN">Just For Fun !!!</a></dt>
-
-        <dd>
-          <dl>
-            <dt>20.1. <a href="#GAMEOFLIFE">The Game of
-            Life</a></dt>
-
-            <dt>20.2. <a href="#MAGIC">Magic Square</a></dt>
-
-            <dt>20.3. <a href="#HANOI">Towers of Hanoi</a></dt>
-
-            <dt>20.4. <a href="#QUEENS">Queens Puzzle</a></dt>
-
-            <dt>20.5. <a href="#SHUFFLE">Shuffle</a></dt>
-
-            <dt>20.6. <a href="#TT">Typing Tutor</a></dt>
-          </dl>
-        </dd>
-
-        <dt>21. <a href="#REF">References</a></dt>
-      </dl>
-    </div>
-
-    <div class="SECT1">
-      <h2 class="SECT1"><a name="INTRO" id="INTRO">1.
-      Introduction</a></h2>
-
-      <p>In the olden days of teletype terminals, terminals were
-      away from computers and were connected to them through serial
-      cables. The terminals could be configured by sending a series
-      of bytes. All the capabilities (such as moving the cursor to
-      a new location, erasing part of the screen, scrolling the
-      screen, changing modes etc.) of terminals could be accessed
-      through these series of bytes. These control seeuqnces are
-      usually called escape sequences, because they start with an
-      escape(0x1B) character. Even today, with proper emulation, we
-      can send escape sequences to the emulator and achieve the
-      same effect on a terminal window.</p>
-
-      <p>Suppose you wanted to print a line in color. Try typing
-      this on your console.</p>
-      <pre class="PROGRAMLISTING">
-echo "^[[0;31;40mIn Color"
-</pre>
-
-      <p>The first character is an escape character, which looks
-      like two characters ^ and [. To be able to print it, you have
-      to press CTRL+V and then the ESC key. All the others are
-      normal printable characters. You should be able to see the
-      string "In Color" in red. It stays that way and to revert
-      back to the original mode type this.</p>
-      <pre class="PROGRAMLISTING">
-echo "^[[0;37;40m"
-</pre>
-
-      <p>Now, what do these magic characters mean? Difficult to
-      comprehend? They might even be different for different
-      terminals. So the designers of UNIX invented a mechanism
-      named <tt class="LITERAL">termcap</tt>. It is a file that
-      lists all the capabilities of a particular terminal, along
-      with the escape sequences needed to achieve a particular
-      effect. In the later years, this was replaced by <tt class=
-      "LITERAL">terminfo</tt>. Without delving too much into
-      details, this mechanism allows application programs to query
-      the terminfo database and obtain the control characters to be
-      sent to a terminal or terminal emulator.</p>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="WHATIS" id="WHATIS">1.1. What is
-        NCURSES?</a></h3>
-
-        <p>You might be wondering, what the import of all this
-        technical gibberish is. In the above scenario, every
-        application program is supposed to query the terminfo and
-        perform the necessary stuff (sending control characters
-        etc.). It soon became difficult to manage this complexity
-        and this gave birth to 'CURSES'. Curses is a pun on the
-        name "cursor optimization". The Curses library forms a
-        wrapper over working with raw terminal codes, and provides
-        highly flexible and efficient API (Application Programming
-        Interface). It provides functions to move the cursor,
-        create windows, produce colors, play with mouse etc. The
-        application programs need not worry about the underlying
-        terminal capabilities.</p>
-
-        <p>So what is NCURSES? NCURSES is a clone of the original
-        System V Release 4.0 (SVr4) curses. It is a freely
-        distributable library, fully compatible with older version
-        of curses. In short, it is a library of functions that
-        manages an application's display on character-cell
-        terminals. In the remainder of the document, the terms
-        curses and ncurses are used interchangeably.</p>
-
-        <p>A detailed history of NCURSES can be found in the NEWS
-        file from the source distribution. The current package is
-        maintained by <a href="mailto:dickey@his.com" target=
-        "_top">Thomas Dickey</a>. You can contact the maintainers
-        at <a href="mailto:bug-ncurses@gnu.org" target=
-        "_top">bug-ncurses@gnu.org</a>.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="WHATCANWEDO" id=
-        "WHATCANWEDO">1.2. What we can do with NCURSES</a></h3>
-
-        <p>NCURSES not only creates a wrapper over terminal
-        capabilities, but also gives a robust framework to create
-        nice looking UI (User Interface)s in text mode. It provides
-        functions to create windows etc. Its sister libraries
-        panel, menu and form provide an extension to the basic
-        curses library. These libraries usually come along with
-        curses. One can create applications that contain multiple
-        windows, menus, panels and forms. Windows can be managed
-        independently, can provide 'scrollability' and even can be
-        hidden.</p>
-
-        <p>Menus provide the user with an easy command selection
-        option. Forms allow the creation of easy-to-use data entry
-        and display windows. Panels extend the capabilities of
-        ncurses to deal with overlapping and stacked windows.</p>
-
-        <p>These are just some of the basic things we can do with
-        ncurses. As we move along, We will see all the capabilities
-        of these libraries.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="WHERETOGETIT" id=
-        "WHERETOGETIT">1.3. Where to get it</a></h3>
-
-        <p>All right, now that you know what you can do with
-        ncurses, you must be rearing to get started. NCURSES is
-        usually shipped with your installation. In case you don't
-        have the library or want to compile it on your own, read
-        on.</p>
-
-        <p><span class="emphasis"><i class="EMPHASIS">Compiling the
-        package</i></span></p>
-
-        <p>NCURSES can be obtained from <a href=
-        "ftp://ftp.gnu.org/pub/gnu/ncurses/ncurses.tar.gz" target=
-        "_top">ftp://ftp.gnu.org/pub/gnu/ncurses/ncurses.tar.gz</a>
-        or any of the ftp sites mentioned in <a href=
-        "http://www.gnu.org/order/ftp.html" target=
-        "_top">http://www.gnu.org/order/ftp.html</a>.</p>
-
-        <p>Read the README and INSTALL files for details on to how
-        to install it. It usually involves the following
-        operations.</p>
-        <pre class="PROGRAMLISTING">
-    tar zxvf ncurses&lt;version&gt;.tar.gz  # unzip and untar the archive
-    cd ncurses&lt;version&gt;               # cd to the directory
-    ./configure                             # configure the build according to your 
-                                            # environment
-    make                                    # make it
-    su root                                 # become root
-    make install                            # install it
-</pre>
-
-        <p><span class="emphasis"><i class="EMPHASIS">Using the
-        RPM</i></span></p>
-
-        <p>NCURSES RPM can be found and downloaded from <a href=
-        "http://rpmfind.net" target="_top">http://rpmfind.net</a> .
-        The RPM can be installed with the following command after
-        becoming root.</p>
-        <pre class="PROGRAMLISTING">
-    rpm -i &lt;downloaded rpm&gt;
-</pre>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="PURPOSE" id="PURPOSE">1.4.
-        Purpose/Scope of the document</a></h3>
-
-        <p>This document is intended to be a "All in One" guide for
-        programming with ncurses and its sister libraries. We
-        graduate from a simple "Hello World" program to more
-        complex form manipulation. No prior experience in ncurses
-        is assumed. The writing is informal, but a lot of detail is
-        provided for each of the examples.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="ABOUTPROGRAMS" id=
-        "ABOUTPROGRAMS">1.5. About the Programs</a></h3>
-
-        <p>All the programs in the document are available in zipped
-        form <a href=
-        "http://www.tldp.org/HOWTO/NCURSES-Programming-HOWTO/ncurses_programs.tar.gz"
-        target="_top">here</a>. Unzip and untar it. The directory
-        structure looks like this.</p>
-        <pre class="PROGRAMLISTING">
-ncurses
-   |
-   |----&gt; JustForFun     -- just for fun programs
-   |----&gt; basics         -- basic programs
-   |----&gt; demo           -- output files go into this directory after make
-   |          |
-   |          |----&gt; exe -- exe files of all example programs
-   |----&gt; forms          -- programs related to form library
-   |----&gt; menus          -- programs related to menus library
-   |----&gt; panels         -- programs related to panels library
-   |----&gt; perl           -- perl equivalents of the examples (contributed
-   |                            by Anuradha Ratnaweera)
-   |----&gt; Makefile       -- the top level Makefile
-   |----&gt; README         -- the top level README file. contains instructions
-   |----&gt; COPYING        -- copyright notice
-</pre>
-
-        <p>The individual directories contain the following
-        files.</p>
-        <pre class="PROGRAMLISTING">
-Description of files in each directory
---------------------------------------
-JustForFun
-    |
-    |----&gt; hanoi.c   -- The Towers of Hanoi Solver
-    |----&gt; life.c    -- The Game of Life demo
-    |----&gt; magic.c   -- An Odd Order Magic Square builder 
-    |----&gt; queens.c  -- The famous N-Queens Solver
-    |----&gt; shuffle.c -- A fun game, if you have time to kill
-    |----&gt; tt.c      -- A very trivial typing tutor
-
-  basics
-    |
-    |----&gt; acs_vars.c            -- ACS_ variables example
-    |----&gt; hello_world.c         -- Simple "Hello World" Program
-    |----&gt; init_func_example.c   -- Initialization functions example
-    |----&gt; key_code.c            -- Shows the scan code of the key pressed
-    |----&gt; mouse_menu.c          -- A menu accessible by mouse
-    |----&gt; other_border.c        -- Shows usage of other border functions apa
-    |                               -- rt from box()
-    |----&gt; printw_example.c      -- A very simple printw() example
-    |----&gt; scanw_example.c       -- A very simple getstr() example
-    |----&gt; simple_attr.c         -- A program that can print a c file with 
-    |                               -- comments in attribute
-    |----&gt; simple_color.c        -- A simple example demonstrating colors
-    |----&gt; simple_key.c          -- A menu accessible with keyboard UP, DOWN 
-    |                               -- arrows
-    |----&gt; temp_leave.c          -- Demonstrates temporarily leaving curses mode
-    |----&gt; win_border.c          -- Shows Creation of windows and borders
-    |----&gt; with_chgat.c          -- chgat() usage example
-
-  forms 
-    |
-    |----&gt; form_attrib.c     -- Usage of field attributes
-    |----&gt; form_options.c    -- Usage of field options
-    |----&gt; form_simple.c     -- A simple form example
-    |----&gt; form_win.c        -- Demo of windows associated with forms
-
-  menus 
-    |
-    |----&gt; menu_attrib.c     -- Usage of menu attributes
-    |----&gt; menu_item_data.c  -- Usage of item_name() etc.. functions
-    |----&gt; menu_multi_column.c    -- Creates multi columnar menus
-    |----&gt; menu_scroll.c     -- Demonstrates scrolling capability of menus
-    |----&gt; menu_simple.c     -- A simple menu accessed by arrow keys
-    |----&gt; menu_toggle.c     -- Creates multi valued menus and explains
-    |                           -- REQ_TOGGLE_ITEM
-    |----&gt; menu_userptr.c    -- Usage of user pointer
-    |----&gt; menu_win.c        -- Demo of windows associated with menus
-
-  panels 
-    |
-    |----&gt; panel_browse.c    -- Panel browsing through tab. Usage of user 
-    |                           -- pointer
-    |----&gt; panel_hide.c      -- Hiding and Un hiding of panels
-    |----&gt; panel_resize.c    -- Moving and resizing of panels
-    |----&gt; panel_simple.c    -- A simple panel example
-
-  perl
-    |----&gt; 01-10.pl          -- Perl equivalents of first ten example programs
-</pre>
-
-        <p>There is a top level Makefile included in the main
-        directory. It builds all the files and puts the
-        ready-to-use exes in demo/exe directory. You can also do
-        selective make by going into the corresponding directory.
-        Each directory contains a README file explaining the
-        purpose of each c file in the directory.</p>
-
-        <p>For every example, I have included path name for the
-        file relative to the examples directory.</p>
-
-        <p>If you prefer browsing individual programs, point your
-        browser to <a href=
-        "http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/ncurses_programs/"
-        target=
-        "_top">http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/ncurses_programs/</a></p>
-
-        <p>All the programs are released under the same license
-        that is used by ncurses (MIT-style). This gives you the
-        ability to do pretty much anything other than claiming them
-        as yours. Feel free to use them in your programs as
-        appropriate.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="OTHERFORMATS" id=
-        "OTHERFORMATS">1.6. Other Formats of the document</a></h3>
-
-        <p>This howto is also availabe in various other formats on
-        the tldp.org site. Here are the links to other formats of
-        this document.</p>
-
-        <div class="SECT3">
-          <hr>
-
-          <h4 class="SECT3"><a name="LISTFORMATS" id=
-          "LISTFORMATS">1.6.1. Readily available formats from
-          tldp.org</a></h4>
-
-          <ul>
-            <li>
-              <p><a href=
-              "http://www.ibiblio.org/pub/Linux/docs/HOWTO/other-formats/pdf/NCURSES-Programming-HOWTO.pdf"
-              target="_top">Acrobat PDF Format</a></p>
-            </li>
-
-            <li>
-              <p><a href=
-              "http://www.ibiblio.org/pub/Linux/docs/HOWTO/other-formats/ps/NCURSES-Programming-HOWTO.ps.gz"
-              target="_top">PostScript Format</a></p>
-            </li>
-
-            <li>
-              <p><a href=
-              "http://www.ibiblio.org/pub/Linux/docs/HOWTO/other-formats/html/NCURSES-Programming-HOWTO-html.tar.gz"
-              target="_top">In Multiple HTML pages</a></p>
-            </li>
-
-            <li>
-              <p><a href=
-              "http://www.ibiblio.org/pub/Linux/docs/HOWTO/other-formats/html_single/NCURSES-Programming-HOWTO.html"
-              target="_top">In One big HTML format</a></p>
-            </li>
-          </ul>
-        </div>
-
-        <div class="SECT3">
-          <hr>
-
-          <h4 class="SECT3"><a name="BUILDSOURCE" id=
-          "BUILDSOURCE">1.6.2. Building from source</a></h4>
-
-          <p>If above links are broken or if you want to experiment
-          with sgml read on.</p>
-          <pre class="PROGRAMLISTING">
-&#13;    Get both the source and the tar,gzipped programs, available at
-        http://cvsview.tldp.org/index.cgi/LDP/howto/docbook/
-        NCURSES-HOWTO/NCURSES-Programming-HOWTO.sgml
-        http://cvsview.tldp.org/index.cgi/LDP/howto/docbook/
-        NCURSES-HOWTO/ncurses_programs.tar.gz
-
-    Unzip ncurses_programs.tar.gz with
-    tar zxvf ncurses_programs.tar.gz
-
-    Use jade to create various formats. For example if you just want to create
-    the multiple html files, you would use
-        jade -t sgml -i html -d &lt;path to docbook html stylesheet&gt;
-        NCURSES-Programming-HOWTO.sgml
-    to get pdf, first create a single html file of the HOWTO with 
-        jade -t sgml -i html -d &lt;path to docbook html stylesheet&gt; -V nochunks
-        NCURSES-Programming-HOWTO.sgml &gt; NCURSES-ONE-BIG-FILE.html
-    then use htmldoc to get pdf file with
-        htmldoc --size universal -t pdf --firstpage p1 -f &lt;output file name.pdf&gt;
-        NCURSES-ONE-BIG-FILE.html
-    for ps, you would use
-        htmldoc --size universal -t ps --firstpage p1 -f &lt;output file name.ps&gt;
-        NCURSES-ONE-BIG-FILE.html
-</pre>
-
-          <p>See <a href=
-          "http://www.tldp.org/LDP/LDP-Author-Guide/" target=
-          "_top">LDP Author guide</a> for more details. If all else
-          failes, mail me at <a href="ppadala@gmail.com" target=
-          "_top">ppadala@gmail.com</a></p>
-        </div>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="CREDITS" id="CREDITS">1.7.
-        Credits</a></h3>
-
-        <p>I thank <a href="mailto:sharath_1@usa.net" target=
-        "_top">Sharath</a> and Emre Akbas for helping me with few
-        sections. The introduction was initially written by
-        sharath. I rewrote it with few excerpts taken from his
-        initial work. Emre helped in writing printw and scanw
-        sections.</p>
-
-        <p>Perl equivalents of the example programs are contributed
-        by <a href="mailto:Aratnaweera@virtusa.com" target=
-        "_top">Anuradha Ratnaweera</a>.</p>
-
-        <p>Then comes <a href="mailto:parimi@ece.arizona.edu"
-        target="_top">Ravi Parimi</a>, my dearest friend, who has
-        been on this project before even one line was written. He
-        constantly bombarded me with suggestions and patiently
-        reviewed the whole text. He also checked each program on
-        Linux and Solaris.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="WISHLIST" id="WISHLIST">1.8.
-        Wish List</a></h3>
-
-        <p>This is the wish list, in the order of priority. If you
-        have a wish or you want to work on completing the wish,
-        mail <a href="mailto:ppadala@gmail.com" target=
-        "_top">me</a>.</p>
-
-        <ul>
-          <li>
-            <p>Add examples to last parts of forms section.</p>
-          </li>
-
-          <li>
-            <p>Prepare a Demo showing all the programs and allow
-            the user to browse through description of each program.
-            Let the user compile and see the program in action. A
-            dialog based interface is preferred.</p>
-          </li>
-
-          <li>
-            <p>Add debug info. _tracef, _tracemouse stuff.</p>
-          </li>
-
-          <li>
-            <p>Accessing termcap, terminfo using functions provided
-            by ncurses package.</p>
-          </li>
-
-          <li>
-            <p>Working on two terminals simultaneously.</p>
-          </li>
-
-          <li>
-            <p>Add more stuff to miscellaneous section.</p>
-          </li>
-        </ul>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="COPYRIGHT" id="COPYRIGHT">1.9.
-        Copyright</a></h3>
-
-        <p>Copyright &copy; 2001 by Pradeep Padala.</p>
-
-        <p>Permission is hereby granted, free of charge, to any
-        person obtaining a copy of this software and associated
-        documentation files (the "Software"), to deal in the
-        Software without restriction, including without limitation
-        the rights to use, copy, modify, merge, publish,
-        distribute, distribute with modifications, sublicense,
-        and/or sell copies of the Software, and to permit persons
-        to whom the Software is furnished to do so, subject to the
-        following conditions:</p>
-
-        <p>The above copyright notice and this permission notice
-        shall be included in all copies or substantial portions of
-        the Software.</p>
-
-        <p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
-        ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-        THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
-        PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE
-        COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-        OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-        SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
-
-        <p>Except as contained in this notice, the name(s) of the
-        above copyright holders shall not be used in advertising or
-        otherwise to promote the sale, use or other dealings in
-        this Software without prior written authorization.</p>
-      </div>
-    </div>
-
-    <div class="SECT1">
-      <hr>
-
-      <h2 class="SECT1"><a name="HELLOWORLD" id="HELLOWORLD">2.
-      Hello World !!!</a></h2>
-
-      <p>Welcome to the world of curses. Before we plunge into the
-      library and look into its various features, let's write a
-      simple program and say hello to the world.</p>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="COMPILECURSES" id=
-        "COMPILECURSES">2.1. Compiling With the NCURSES
-        Library</a></h3>
-
-        <p>To use ncurses library functions, you have to include
-        ncurses.h in your programs. To link the program with
-        ncurses the flag -lncurses should be added.</p>
-        <pre class="PROGRAMLISTING">
-    #include &lt;ncurses.h&gt;
-    .
-    .
-    .
-
-    compile and link: gcc &lt;program file&gt; -lncurses
-</pre>
-
-        <div class="EXAMPLE">
-          <a name="BHW" id="BHW"></a>
-
-          <p><b>Example 1. The Hello World !!! Program</b></p>
-          <pre class="PROGRAMLISTING">
-<span class="INLINEMEDIAOBJECT">#include &lt;ncurses.h&gt;
-
-int main()
-{       
-        initscr();                      /* Start curses mode              */
-        printw("Hello World !!!");      /* Print Hello World              */
-        refresh();                      /* Print it on to the real screen */
-        getch();                        /* Wait for user input */
-        endwin();                       /* End curses mode                */
-
-        return 0;
-}</span>
-</pre>
-        </div>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="DISSECTION" id="DISSECTION">2.2.
-        Dissection</a></h3>
-
-        <p>The above program prints "Hello World !!!" to the screen
-        and exits. This program shows how to initialize curses and
-        do screen manipulation and end curses mode. Let's dissect
-        it line by line.</p>
-
-        <div class="SECT3">
-          <hr>
-
-          <h4 class="SECT3"><a name="ABOUT-INITSCR" id=
-          "ABOUT-INITSCR">2.2.1. About initscr()</a></h4>
-
-          <p>The function initscr() initializes the terminal in
-          curses mode. In some implementations, it clears the
-          screen and presents a blank screen. To do any screen
-          manipulation using curses package this has to be called
-          first. This function initializes the curses system and
-          allocates memory for our present window (called
-          <tt class="LITERAL">stdscr</tt>) and some other
-          data-structures. Under extreme cases this function might
-          fail due to insufficient memory to allocate memory for
-          curses library's data structures.</p>
-
-          <p>After this is done, we can do a variety of
-          initializations to customize our curses settings. These
-          details will be explained <a href="#INIT">later</a> .</p>
-        </div>
-
-        <div class="SECT3">
-          <hr>
-
-          <h4 class="SECT3"><a name="MYST-REFRESH" id=
-          "MYST-REFRESH">2.2.2. The mysterious refresh()</a></h4>
-
-          <p>The next line printw prints the string "Hello World
-          !!!" on to the screen. This function is analogous to
-          normal printf in all respects except that it prints the
-          data on a window called stdscr at the current (y,x)
-          co-ordinates. Since our present co-ordinates are at 0,0
-          the string is printed at the left hand corner of the
-          window.</p>
-
-          <p>This brings us to that mysterious refresh(). Well,
-          when we called printw the data is actually written to an
-          imaginary window, which is not updated on the screen yet.
-          The job of printw is to update a few flags and data
-          structures and write the data to a buffer corresponding
-          to stdscr. In order to show it on the screen, we need to
-          call refresh() and tell the curses system to dump the
-          contents on the screen.</p>
-
-          <p>The philosophy behind all this is to allow the
-          programmer to do multiple updates on the imaginary screen
-          or windows and do a refresh once all his screen update is
-          done. refresh() checks the window and updates only the
-          portion which has been changed. This improves performance
-          and offers greater flexibility too. But, it is sometimes
-          frustrating to beginners. A common mistake committed by
-          beginners is to forget to call refresh() after they did
-          some update through printw() class of functions. I still
-          forget to add it sometimes :-)</p>
-        </div>
-
-        <div class="SECT3">
-          <hr>
-
-          <h4 class="SECT3"><a name="ABOUT-ENDWIN" id=
-          "ABOUT-ENDWIN">2.2.3. About endwin()</a></h4>
-
-          <p>And finally don't forget to end the curses mode.
-          Otherwise your terminal might behave strangely after the
-          program quits. endwin() frees the memory taken by curses
-          sub-system and its data structures and puts the terminal
-          in normal mode. This function must be called after you
-          are done with the curses mode.</p>
-        </div>
-      </div>
-    </div>
-
-    <div class="SECT1">
-      <hr>
-
-      <h2 class="SECT1"><a name="GORY" id="GORY">3. The Gory
-      Details</a></h2>
-
-      <p>Now that we have seen how to write a simple curses program
-      let's get into the details. There are many functions that
-      help customize what you see on screen and many features which
-      can be put to full use.</p>
-
-      <p>Here we go...</p>
-    </div>
-
-    <div class="SECT1">
-      <hr>
-
-      <h2 class="SECT1"><a name="INIT" id="INIT">4.
-      Initialization</a></h2>
-
-      <p>We now know that to initialize curses system the function
-      initscr() has to be called. There are functions which can be
-      called after this initialization to customize our curses
-      session. We may ask the curses system to set the terminal in
-      raw mode or initialize color or initialize the mouse etc..
-      Let's discuss some of the functions that are normally called
-      immediately after initscr();</p>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="ABOUTINIT" id="ABOUTINIT">4.1.
-        Initialization functions</a></h3>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="RAWCBREAK" id="RAWCBREAK">4.2.
-        raw() and cbreak()</a></h3>
-
-        <p>Normally the terminal driver buffers the characters a
-        user types until a new line or carriage return is
-        encountered. But most programs require that the characters
-        be available as soon as the user types them. The above two
-        functions are used to disable line buffering. The
-        difference between these two functions is in the way
-        control characters like suspend (CTRL-Z), interrupt and
-        quit (CTRL-C) are passed to the program. In the raw() mode
-        these characters are directly passed to the program without
-        generating a signal. In the <tt class=
-        "LITERAL">cbreak()</tt> mode these control characters are
-        interpreted as any other character by the terminal driver.
-        I personally prefer to use raw() as I can exercise greater
-        control over what the user does.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="ECHONOECHO" id="ECHONOECHO">4.3.
-        echo() and noecho()</a></h3>
-
-        <p>These functions control the echoing of characters typed
-        by the user to the terminal. <tt class=
-        "LITERAL">noecho()</tt> switches off echoing. The reason
-        you might want to do this is to gain more control over
-        echoing or to suppress unnecessary echoing while taking
-        input from the user through the getch() etc. functions.
-        Most of the interactive programs call <tt class=
-        "LITERAL">noecho()</tt> at initialization and do the
-        echoing of characters in a controlled manner. It gives the
-        programmer the flexibility of echoing characters at any
-        place in the window without updating current (y,x)
-        co-ordinates.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="KEYPAD" id="KEYPAD">4.4.
-        keypad()</a></h3>
-
-        <p>This is my favorite initialization function. It enables
-        the reading of function keys like F1, F2, arrow keys etc.
-        Almost every interactive program enables this, as arrow
-        keys are a major part of any User Interface. Do <tt class=
-        "LITERAL">keypad(stdscr, TRUE)</tt> to enable this feature
-        for the regular screen (stdscr). You will learn more about
-        key management in later sections of this document.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="HALFDELAY" id="HALFDELAY">4.5.
-        halfdelay()</a></h3>
-
-        <p>This function, though not used very often, is a useful
-        one at times. halfdelay()is called to enable the half-delay
-        mode, which is similar to the cbreak() mode in that
-        characters typed are immediately available to program.
-        However, it waits for 'X' tenths of a second for input and
-        then returns ERR, if no input is available. 'X' is the
-        timeout value passed to the function halfdelay(). This
-        function is useful when you want to ask the user for input,
-        and if he doesn't respond with in certain time, we can do
-        some thing else. One possible example is a timeout at the
-        password prompt.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="MISCINIT" id="MISCINIT">4.6.
-        Miscellaneous Initialization functions</a></h3>
-
-        <p>There are few more functions which are called at
-        initialization to customize curses behavior. They are not
-        used as extensively as those mentioned above. Some of them
-        are explained where appropriate.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="INITEX" id="INITEX">4.7. An
-        Example</a></h3>
-
-        <p>Let's write a program which will clarify the usage of
-        these functions.</p>
-
-        <div class="EXAMPLE">
-          <a name="BINFU" id="BINFU"></a>
-
-          <p><b>Example 2. Initialization Function Usage
-          example</b></p>
-          <pre class="PROGRAMLISTING">
-<span class="INLINEMEDIAOBJECT">#include &lt;ncurses.h&gt;
-
-int main()
-{       int ch;
-
-        initscr();                      /* Start curses mode            */
-        raw();                          /* Line buffering disabled      */
-        keypad(stdscr, TRUE);           /* We get F1, F2 etc..          */
-        noecho();                       /* Don't echo() while we do getch */
-
-        printw("Type any character to see it in bold\n");
-        ch = getch();                   /* If raw() hadn't been called
-                                         * we have to press enter before it
-                                         * gets to the program          */
-        if(ch == KEY_F(1))              /* Without keypad enabled this will */
-                printw("F1 Key pressed");/*  not get to us either       */
-                                        /* Without noecho() some ugly escape
-                                         * charachters might have been printed
-                                         * on screen                    */
-        else
-        {       printw("The pressed key is ");
-                attron(A_BOLD);
-                printw("%c", ch);
-                attroff(A_BOLD);
-        }
-        refresh();                      /* Print it on to the real screen */
-        getch();                        /* Wait for user input */
-        endwin();                       /* End curses mode                */
-
-        return 0;
-}</span>
-</pre>
-        </div>
-
-        <p>This program is self-explanatory. But I used functions
-        which aren't explained yet. The function <tt class=
-        "LITERAL">getch()</tt> is used to get a character from
-        user. It is equivalent to normal <tt class=
-        "LITERAL">getchar()</tt> except that we can disable the
-        line buffering to avoid &lt;enter&gt; after input. Look for
-        more about <tt class="LITERAL">getch()</tt>and reading keys
-        in the <a href="#KEYS">key management section</a> . The
-        functions attron and attroff are used to switch some
-        attributes on and off respectively. In the example I used
-        them to print the character in bold. These functions are
-        explained in detail later.</p>
-      </div>
-    </div>
-
-    <div class="SECT1">
-      <hr>
-
-      <h2 class="SECT1"><a name="AWORDWINDOWS" id="AWORDWINDOWS">5.
-      A Word about Windows</a></h2>
-
-      <p>Before we plunge into the myriad ncurses functions, let me
-      clear few things about windows. Windows are explained in
-      detail in following <a href="#WINDOWS">sections</a></p>
-
-      <p>A Window is an imaginary screen defined by curses system.
-      A window does not mean a bordered window which you usually
-      see on Win9X platforms. When curses is initialized, it
-      creates a default window named <tt class=
-      "LITERAL">stdscr</tt> which represents your 80x25 (or the
-      size of window in which you are running) screen. If you are
-      doing simple tasks like printing few strings, reading input
-      etc., you can safely use this single window for all of your
-      purposes. You can also create windows and call functions
-      which explicitly work on the specified window.</p>
-
-      <p>For example, if you call</p>
-      <pre class="PROGRAMLISTING">
-    printw("Hi There !!!");
-    refresh();
-</pre>
-
-      <p>It prints the string on stdscr at the present cursor
-      position. Similarly the call to refresh(), works on stdscr
-      only.</p>
-
-      <p>Say you have created <a href="#WINDOWS">windows</a> then
-      you have to call a function with a 'w' added to the usual
-      function.</p>
-      <pre class="PROGRAMLISTING">
-    wprintw(win, "Hi There !!!");
-    wrefresh(win);
-</pre>
-
-      <p>As you will see in the rest of the document, naming of
-      functions follow the same convention. For each function there
-      usually are three more functions.</p>
-      <pre class="PROGRAMLISTING">
-    printw(string);        /* Print on stdscr at present cursor position */
-    mvprintw(y, x, string);/* Move to (y, x) then print string     */
-    wprintw(win, string);  /* Print on window win at present cursor position */
-                           /* in the window */
-    mvwprintw(win, y, x, string);   /* Move to (y, x) relative to window */
-                                    /* co-ordinates and then print         */
-</pre>
-
-      <p>Usually the w-less functions are macros which expand to
-      corresponding w-function with stdscr as the window
-      parameter.</p>
-    </div>
-
-    <div class="SECT1">
-      <hr>
-
-      <h2 class="SECT1"><a name="PRINTW" id="PRINTW">6. Output
-      functions</a></h2>
-
-      <p>I guess you can't wait any more to see some action. Back
-      to our odyssey of curses functions. Now that curses is
-      initialized, let's interact with world.</p>
-
-      <p>There are three classes of functions which you can use to
-      do output on screen.</p>
-
-      <ol type="1">
-        <li>
-          <p>addch() class: Print single character with
-          attributes</p>
-        </li>
-
-        <li>
-          <p>printw() class: Print formatted output similar to
-          printf()</p>
-        </li>
-
-        <li>
-          <p>addstr() class: Print strings</p>
-        </li>
-      </ol>
-
-      <p>These functions can be used interchangeably and it's a
-      matter of style as to which class is used. Let's see each one
-      in detail.</p>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="ADDCHCLASS" id="ADDCHCLASS">6.1.
-        addch() class of functions</a></h3>
-
-        <p>These functions put a single character into the current
-        cursor location and advance the position of the cursor. You
-        can give the character to be printed but they usually are
-        used to print a character with some attributes. Attributes
-        are explained in detail in later <a href=
-        "#ATTRIB">sections</a> of the document. If a character is
-        associated with an attribute(bold, reverse video etc.),
-        when curses prints the character, it is printed in that
-        attribute.</p>
-
-        <p>In order to combine a character with some attributes,
-        you have two options:</p>
-
-        <ul>
-          <li>
-            <p>By OR'ing a single character with the desired
-            attribute macros. These attribute macros could be found
-            in the header file <tt class="LITERAL">ncurses.h</tt>.
-            For example, you want to print a character ch(of type
-            char) bold and underlined, you would call addch() as
-            below.</p>
-            <pre class="PROGRAMLISTING">
-    addch(ch | A_BOLD | A_UNDERLINE);
-</pre>
-          </li>
-
-          <li>
-            <p>By using functions like <tt class=
-            "LITERAL">attrset(),attron(),attroff()</tt>. These
-            functions are explained in the <a href=
-            "#ATTRIB">Attributes</a> section. Briefly, they
-            manipulate the current attributes of the given window.
-            Once set, the character printed in the window are
-            associated with the attributes until it is turned
-            off.</p>
-          </li>
-        </ul>
-
-        <p>Additionally, <tt class="LITERAL">curses</tt> provides
-        some special characters for character-based graphics. You
-        can draw tables, horizontal or vertical lines, etc. You can
-        find all avaliable characters in the header file <tt class=
-        "LITERAL">ncurses.h</tt>. Try looking for macros beginning
-        with <tt class="LITERAL">ACS_</tt> in this file.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="AEN298" id="AEN298">6.2.
-        mvaddch(), waddch() and mvwaddch()</a></h3>
-
-        <p><tt class="LITERAL">mvaddch()</tt> is used to move the
-        cursor to a given point, and then print. Thus, the
-        calls:</p>
-        <pre class="PROGRAMLISTING">
-    move(row,col);    /* moves the cursor to row<span class=
-"emphasis"><i class=
-"EMPHASIS">th</i></span> row and col<span class="emphasis"><i class="EMPHASIS">th</i></span> column */
-    addch(ch);
-</pre>can be replaced by
-        <pre class="PROGRAMLISTING">
-    mvaddch(row,col,ch);
-</pre>
-
-        <p><tt class="LITERAL">waddch()</tt> is similar to
-        <tt class="LITERAL">addch()</tt>, except that it adds a
-        character into the given window. (Note that <tt class=
-        "LITERAL">addch()</tt> adds a character into the window
-        <tt class="LITERAL">stdscr</tt>.)</p>
-
-        <p>In a similar fashion <tt class="LITERAL">mvwaddch()</tt>
-        function is used to add a character into the given window
-        at the given coordinates.</p>
-
-        <p>Now, we are familiar with the basic output function
-        <tt class="LITERAL">addch()</tt>. But, if we want to print
-        a string, it would be very annoying to print it character
-        by character. Fortunately, <tt class="LITERAL">ncurses</tt>
-        provides <tt class="LITERAL">printf</tt><span class=
-        "emphasis"><i class="EMPHASIS">-like</i></span> or
-        <tt class="LITERAL">puts</tt><span class=
-        "emphasis"><i class="EMPHASIS">-like</i></span>
-        functions.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="PRINTWCLASS" id=
-        "PRINTWCLASS">6.3. printw() class of functions</a></h3>
-
-        <p>These functions are similar to <tt class=
-        "LITERAL">printf()</tt> with the added capability of
-        printing at any position on the screen.</p>
-
-        <div class="SECT3">
-          <hr>
-
-          <h4 class="SECT3"><a name="PRINTWMVPRINTW" id=
-          "PRINTWMVPRINTW">6.3.1. printw() and mvprintw</a></h4>
-
-          <p>These two functions work much like <tt class=
-          "LITERAL">printf()</tt>. <tt class=
-          "LITERAL">mvprintw()</tt> can be used to move the cursor
-          to a position and then print. If you want to move the
-          cursor first and then print using <tt class=
-          "LITERAL">printw()</tt> function, use <tt class=
-          "LITERAL">move()</tt> first and then use <tt class=
-          "LITERAL">printw()</tt> though I see no point why one
-          should avoid using <tt class="LITERAL">mvprintw()</tt>,
-          you have the flexibility to manipulate.</p>
-        </div>
-
-        <div class="SECT3">
-          <hr>
-
-          <h4 class="SECT3"><a name="WPRINTWMVWPRINTW" id=
-          "WPRINTWMVWPRINTW">6.3.2. wprintw() and
-          mvwprintw</a></h4>
-
-          <p>These two functions are similar to above two except
-          that they print in the corresponding window given as
-          argument.</p>
-        </div>
-
-        <div class="SECT3">
-          <hr>
-
-          <h4 class="SECT3"><a name="VWPRINTW" id="VWPRINTW">6.3.3.
-          vw_printw()</a></h4>
-
-          <p>This function is similar to <tt class=
-          "LITERAL">vprintf()</tt>. This can be used when variable
-          number of arguments are to be printed.</p>
-        </div>
-
-        <div class="SECT3">
-          <hr>
-
-          <h4 class="SECT3"><a name="SIMPLEPRINTWEX" id=
-          "SIMPLEPRINTWEX">6.3.4. A Simple printw example</a></h4>
-
-          <div class="EXAMPLE">
-            <a name="BPREX" id="BPREX"></a>
-
-            <p><b>Example 3. A Simple printw example</b></p>
-            <pre class="PROGRAMLISTING">
-<span class=
-"INLINEMEDIAOBJECT">#include &lt;ncurses.h&gt;                   /* ncurses.h includes stdio.h */  
-#include &lt;string.h&gt; 
- 
-int main()
-{
- char mesg[]="Just a string";           /* message to be appeared on the screen */
- int row,col;                           /* to store the number of rows and *
-                                         * the number of colums of the screen */
- initscr();                             /* start the curses mode */
- getmaxyx(stdscr,row,col);              /* get the number of rows and columns */
- mvprintw(row/2,(col-strlen(mesg))/2,"%s",mesg);
-                                        /* print the message at the center of the screen */
- mvprintw(row-2,0,"This screen has %d rows and %d columns\n",row,col);
- printw("Try resizing your window(if possible) and then run this program again");
- refresh();
- getch();
- endwin();
-
- return 0;
-}</span>
-</pre>
-          </div>
-
-          <p>Above program demonstrates how easy it is to use
-          <tt class="LITERAL">printw</tt>. You just feed the
-          coordinates and the message to be appeared on the screen,
-          then it does what you want.</p>
-
-          <p>The above program introduces us to a new function
-          <tt class="LITERAL">getmaxyx()</tt>, a macro defined in
-          <tt class="LITERAL">ncurses.h</tt>. It gives the number
-          of columns and the number of rows in a given window.
-          <tt class="LITERAL">getmaxyx()</tt> does this by updating
-          the variables given to it. Since <tt class=
-          "LITERAL">getmaxyx()</tt> is not a function we don't pass
-          pointers to it, we just give two integer variables.</p>
-        </div>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="ADDSTRCLASS" id=
-        "ADDSTRCLASS">6.4. addstr() class of functions</a></h3>
-
-        <p><tt class="LITERAL">addstr()</tt> is used to put a
-        character string into a given window. This function is
-        similar to calling <tt class="LITERAL">addch()</tt> once
-        for each character in a given string. This is true for all
-        output functions. There are other functions from this
-        family such as <tt class=
-        "LITERAL">mvaddstr(),mvwaddstr()</tt> and <tt class=
-        "LITERAL">waddstr()</tt>, which obey the naming convention
-        of curses.(e.g. mvaddstr() is similar to the respective
-        calls move() and then addstr().) Another function of this
-        family is addnstr(), which takes an integer parameter(say
-        n) additionally. This function puts at most n characters
-        into the screen. If n is negative, then the entire string
-        will be added.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="ACAUTION" id="ACAUTION">6.5. A
-        word of caution</a></h3>
-
-        <p>All these functions take y co-ordinate first and then x
-        in their arguments. A common mistake by beginners is to
-        pass x,y in that order. If you are doing too many
-        manipulations of (y,x) co-ordinates, think of dividing the
-        screen into windows and manipulate each one separately.
-        Windows are explained in the <a href="#WINDOWS">windows</a>
-        section.</p>
-      </div>
-    </div>
-
-    <div class="SECT1">
-      <hr>
-
-      <h2 class="SECT1"><a name="SCANW" id="SCANW">7. Input
-      functions</a></h2>
-
-      <p>Well, printing without taking input, is boring. Let's see
-      functions which allow us to get input from user. These
-      functions also can be divided into three categories.</p>
-
-      <ol type="1">
-        <li>
-          <p>getch() class: Get a character</p>
-        </li>
-
-        <li>
-          <p>scanw() class: Get formatted input</p>
-        </li>
-
-        <li>
-          <p>getstr() class: Get strings</p>
-        </li>
-      </ol>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="GETCHCLASS" id="GETCHCLASS">7.1.
-        getch() class of functions</a></h3>
-
-        <p>These functions read a single character from the
-        terminal. But there are several subtle facts to consider.
-        For example if you don't use the function cbreak(), curses
-        will not read your input characters contiguously but will
-        begin read them only after a new line or an EOF is
-        encountered. In order to avoid this, the cbreak() function
-        must used so that characters are immediately available to
-        your program. Another widely used function is noecho(). As
-        the name suggests, when this function is set (used), the
-        characters that are keyed in by the user will not show up
-        on the screen. The two functions cbreak() and noecho() are
-        typical examples of key management. Functions of this genre
-        are explained in the <a href="#KEYS">key management
-        section</a> .</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="SCANWCLASS" id="SCANWCLASS">7.2.
-        scanw() class of functions</a></h3>
-
-        <p>These functions are similar to <tt class=
-        "LITERAL">scanf()</tt> with the added capability of getting
-        the input from any location on the screen.</p>
-
-        <div class="SECT3">
-          <hr>
-
-          <h4 class="SECT3"><a name="SCANWMVSCANW" id=
-          "SCANWMVSCANW">7.2.1. scanw() and mvscanw</a></h4>
-
-          <p>The usage of these functions is similar to that of
-          <tt class="LITERAL">sscanf()</tt>, where the line to be
-          scanned is provided by <tt class="LITERAL">wgetstr()</tt>
-          function. That is, these functions call to <tt class=
-          "LITERAL">wgetstr()</tt> function(explained below) and
-          uses the resulting line for a scan.</p>
-        </div>
-
-        <div class="SECT3">
-          <hr>
-
-          <h4 class="SECT3"><a name="WSCANWMVWSCANW" id=
-          "WSCANWMVWSCANW">7.2.2. wscanw() and mvwscanw()</a></h4>
-
-          <p>These are similar to above two functions except that
-          they read from a window, which is supplied as one of the
-          arguments to these functions.</p>
-        </div>
-
-        <div class="SECT3">
-          <hr>
-
-          <h4 class="SECT3"><a name="VWSCANW" id="VWSCANW">7.2.3.
-          vw_scanw()</a></h4>
-
-          <p>This function is similar to <tt class=
-          "LITERAL">vscanf()</tt>. This can be used when a variable
-          number of arguments are to be scanned.</p>
-        </div>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="GETSTRCLASS" id=
-        "GETSTRCLASS">7.3. getstr() class of functions</a></h3>
-
-        <p>These functions are used to get strings from the
-        terminal. In essence, this function performs the same task
-        as would be achieved by a series of calls to <tt class=
-        "LITERAL">getch()</tt> until a newline, carriage return, or
-        end-of-file is received. The resulting string of characters
-        are pointed to by <tt class="LITERAL">str</tt>, which is a
-        character pointer provided by the user.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="GETSTREX" id="GETSTREX">7.4.
-        Some examples</a></h3>
-
-        <div class="EXAMPLE">
-          <a name="BSCEX" id="BSCEX"></a>
-
-          <p><b>Example 4. A Simple scanw example</b></p>
-          <pre class="PROGRAMLISTING">
-<span class=
-"INLINEMEDIAOBJECT">#include &lt;ncurses.h&gt;                   /* ncurses.h includes stdio.h */  
-#include &lt;string.h&gt; 
- 
-int main()
-{
- char mesg[]="Enter a string: ";                /* message to be appeared on the screen */
- char str[80];
- int row,col;                           /* to store the number of rows and *
-                                         * the number of colums of the screen */
- initscr();                             /* start the curses mode */
- getmaxyx(stdscr,row,col);              /* get the number of rows and columns */
- mvprintw(row/2,(col-strlen(mesg))/2,"%s",mesg);
-                                /* print the message at the center of the screen */
- getstr(str);
- mvprintw(LINES - 2, 0, "You Entered: %s", str);
- getch();
- endwin();
-
- return 0;
-}</span>
-</pre>
-        </div>
-      </div>
-    </div>
-
-    <div class="SECT1">
-      <hr>
-
-      <h2 class="SECT1"><a name="ATTRIB" id="ATTRIB">8.
-      Attributes</a></h2>
-
-      <p>We have seen an example of how attributes can be used to
-      print characters with some special effects. Attributes, when
-      set prudently, can present information in an easy,
-      understandable manner. The following program takes a C file
-      as input and prints the file with comments in bold. Scan
-      through the code.</p>
-
-      <div class="EXAMPLE">
-        <a name="BSIAT" id="BSIAT"></a>
-
-        <p><b>Example 5. A Simple Attributes example</b></p>
-        <pre class="PROGRAMLISTING">
-<span class=
-"INLINEMEDIAOBJECT">/* pager functionality by Joseph Spainhour" &lt;spainhou@bellsouth.net&gt; */
-#include &lt;ncurses.h&gt;
-#include &lt;stdlib.h&gt;
-
-int main(int argc, char *argv[])
-{ 
-  int ch, prev, row, col;
-  prev = EOF;
-  FILE *fp;
-  int y, x;
-
-  if(argc != 2)
-  {
-    printf("Usage: %s &lt;a c file name&gt;\n", argv[0]);
-    exit(1);
-  }
-  fp = fopen(argv[1], "r");
-  if(fp == NULL)
-  {
-    perror("Cannot open input file");
-    exit(1);
-  }
-  initscr();                            /* Start curses mode */
-  getmaxyx(stdscr, row, col);           /* find the boundaries of the screeen */
-  while((ch = fgetc(fp)) != EOF)        /* read the file till we reach the end */
-  {
-    getyx(stdscr, y, x);                /* get the current curser position */
-    if(y == (row - 1))                  /* are we are at the end of the screen */
-    {
-      printw("&lt;-Press Any Key-&gt;");      /* tell the user to press a key */
-      getch();
-      clear();                          /* clear the screen */
-      move(0, 0);                       /* start at the beginning of the screen */
-    }
-    if(prev == '/' &amp;&amp; ch == '*')        /* If it is / and * then only
-                                         * switch bold on */    
-    {
-      attron(A_BOLD);                   /* cut bold on */
-      getyx(stdscr, y, x);              /* get the current curser position */
-      move(y, x - 1);                   /* back up one space */
-      printw("%c%c", '/', ch);          /* The actual printing is done here */
-    }
-    else
-      printw("%c", ch);
-    refresh();
-    if(prev == '*' &amp;&amp; ch == '/')
-      attroff(A_BOLD);                  /* Switch it off once we got *
-                                         * and then / */
-    prev = ch;
-  }
-  endwin();                             /* End curses mode */
-  fclose(fp);
-  return 0;
-}</span>
-</pre>
-      </div>
-
-      <p>Don't worry about all those initialization and other crap.
-      Concentrate on the while loop. It reads each character in the
-      file and searches for the pattern /*. Once it spots the
-      pattern, it switches the BOLD attribute on with <tt class=
-      "LITERAL">attron()</tt> . When we get the pattern */ it is
-      switched off by <tt class="LITERAL">attroff()</tt> .</p>
-
-      <p>The above program also introduces us to two useful
-      functions <tt class="LITERAL">getyx()</tt> and <tt class=
-      "LITERAL">move()</tt>. The first function gets the
-      co-ordinates of the present cursor into the variables y, x.
-      Since getyx() is a macro we don't have to pass pointers to
-      variables. The function <tt class="LITERAL">move()</tt> moves
-      the cursor to the co-ordinates given to it.</p>
-
-      <p>The above program is really a simple one which doesn't do
-      much. On these lines one could write a more useful program
-      which reads a C file, parses it and prints it in different
-      colors. One could even extend it to other languages as
-      well.</p>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="ATTRIBDETAILS" id=
-        "ATTRIBDETAILS">8.1. The details</a></h3>
-
-        <p>Let's get into more details of attributes. The functions
-        <tt class="LITERAL">attron(), attroff(), attrset()</tt> ,
-        and their sister functions <tt class=
-        "LITERAL">attr_get()</tt> etc.. can be used to switch
-        attributes on/off , get attributes and produce a colorful
-        display.</p>
-
-        <p>The functions attron and attroff take a bit-mask of
-        attributes and switch them on or off, respectively. The
-        following video attributes, which are defined in
-        &lt;curses.h&gt; can be passed to these functions.</p>
-        <pre class="PROGRAMLISTING">
-    
-    A_NORMAL        Normal display (no highlight)
-    A_STANDOUT      Best highlighting mode of the terminal.
-    A_UNDERLINE     Underlining
-    A_REVERSE       Reverse video
-    A_BLINK         Blinking
-    A_DIM           Half bright
-    A_BOLD          Extra bright or bold
-    A_PROTECT       Protected mode
-    A_INVIS         Invisible or blank mode
-    A_ALTCHARSET    Alternate character set
-    A_CHARTEXT      Bit-mask to extract a character
-    COLOR_PAIR(n)   Color-pair number n 
-    
-</pre>
-
-        <p>The last one is the most colorful one :-) Colors are
-        explained in the <a href="#color" target="_top">next
-        sections</a>.</p>
-
-        <p>We can OR(|) any number of above attributes to get a
-        combined effect. If you wanted reverse video with blinking
-        characters you can use</p>
-        <pre class="PROGRAMLISTING">
-    attron(A_REVERSE | A_BLINK);
-</pre>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="ATTRONVSATTRSET" id=
-        "ATTRONVSATTRSET">8.2. attron() vs attrset()</a></h3>
-
-        <p>Then what is the difference between attron() and
-        attrset()? attrset sets the attributes of window whereas
-        attron just switches on the attribute given to it. So
-        attrset() fully overrides whatever attributes the window
-        previously had and sets it to the new attribute(s).
-        Similarly attroff() just switches off the attribute(s)
-        given to it as an argument. This gives us the flexibility
-        of managing attributes easily.But if you use them
-        carelessly you may loose track of what attributes the
-        window has and garble the display. This is especially true
-        while managing menus with colors and highlighting. So
-        decide on a consistent policy and stick to it. You can
-        always use <tt class="LITERAL">standend()</tt> which is
-        equivalent to <tt class="LITERAL">attrset(A_NORMAL)</tt>
-        which turns off all attributes and brings you to normal
-        mode.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="ATTRGET" id="ATTRGET">8.3.
-        attr_get()</a></h3>
-
-        <p>The function attr_get() gets the current attributes and
-        color pair of the window. Though we might not use this as
-        often as the above functions, this is useful in scanning
-        areas of screen. Say we wanted to do some complex update on
-        screen and we are not sure what attribute each character is
-        associated with. Then this function can be used with either
-        attrset or attron to produce the desired effect.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="ATTRFUNCS" id="ATTRFUNCS">8.4.
-        attr_ functions</a></h3>
-
-        <p>There are series of functions like attr_set(), attr_on
-        etc.. These are similar to above functions except that they
-        take parameters of type <tt class=
-        "LITERAL">attr_t</tt>.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="WATTRFUNCS" id="WATTRFUNCS">8.5.
-        wattr functions</a></h3>
-
-        <p>For each of the above functions we have a corresponding
-        function with 'w' which operates on a particular window.
-        The above functions operate on stdscr.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="CHGAT" id="CHGAT">8.6. chgat()
-        functions</a></h3>
-
-        <p>The function chgat() is listed in the end of the man
-        page curs_attr. It actually is a useful one. This function
-        can be used to set attributes for a group of characters
-        without moving. I mean it !!! without moving the cursor :-)
-        It changes the attributes of a given number of characters
-        starting at the current cursor location.</p>
-
-        <p>We can give -1 as the character count to update till end
-        of line. If you want to change attributes of characters
-        from current position to end of line, just use this.</p>
-        <pre class="PROGRAMLISTING">
-    chgat(-1, A_REVERSE, 0, NULL);
-</pre>
-
-        <p>This function is useful when changing attributes for
-        characters that are already on the screen. Move to the
-        character from which you want to change and change the
-        attribute.</p>
-
-        <p>Other functions wchgat(), mvchgat(), wchgat() behave
-        similarly except that the w functions operate on the
-        particular window. The mv functions first move the cursor
-        then perform the work given to them. Actually chgat is a
-        macro which is replaced by a wchgat() with stdscr as the
-        window. Most of the "w-less" functions are macros.</p>
-
-        <div class="EXAMPLE">
-          <a name="BWICH" id="BWICH"></a>
-
-          <p><b>Example 6. Chgat() Usage example</b></p>
-          <pre class="PROGRAMLISTING">
-<span class="INLINEMEDIAOBJECT">#include &lt;ncurses.h&gt;
-
-int main(int argc, char *argv[])
-{       initscr();                      /* Start curses mode            */
-        start_color();                  /* Start color functionality    */
-        
-        init_pair(1, COLOR_CYAN, COLOR_BLACK);
-        printw("A Big string which i didn't care to type fully ");
-        mvchgat(0, 0, -1, A_BLINK, 1, NULL);    
-        /* 
-         * First two parameters specify the position at which to start 
-         * Third parameter number of characters to update. -1 means till 
-         * end of line
-         * Forth parameter is the normal attribute you wanted to give 
-         * to the charcter
-         * Fifth is the color index. It is the index given during init_pair()
-         * use 0 if you didn't want color
-         * Sixth one is always NULL 
-         */
-        refresh();
-        getch();
-        endwin();                       /* End curses mode                */
-        return 0;
-}</span>
-</pre>
-        </div>
-
-        <p>This example also introduces us to the color world of
-        curses. Colors will be explained in detail later. Use 0 for
-        no color.</p>
-      </div>
-    </div>
-
-    <div class="SECT1">
-      <hr>
-
-      <h2 class="SECT1"><a name="WINDOWS" id="WINDOWS">9.
-      Windows</a></h2>
-
-      <p>Windows form the most important concept in curses. You
-      have seen the standard window stdscr above where all the
-      functions implicitly operated on this window. Now to make
-      design even a simplest GUI, you need to resort to windows.
-      The main reason you may want to use windows is to manipulate
-      parts of the screen separately, for better efficiency, by
-      updating only the windows that need to be changed and for a
-      better design. I would say the last reason is the most
-      important in going for windows. You should always strive for
-      a better and easy-to-manage design in your programs. If you
-      are writing big, complex GUIs this is of pivotal importance
-      before you start doing anything.</p>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="WINDOWBASICS" id=
-        "WINDOWBASICS">9.1. The basics</a></h3>
-
-        <p>A Window can be created by calling the function
-        <tt class="LITERAL">newwin()</tt>. It doesn't create any
-        thing on the screen actually. It allocates memory for a
-        structure to manipulate the window and updates the
-        structure with data regarding the window like it's size,
-        beginy, beginx etc.. Hence in curses, a window is just an
-        abstraction of an imaginary window, which can be
-        manipulated independent of other parts of screen. The
-        function newwin() returns a pointer to structure WINDOW,
-        which can be passed to window related functions like
-        wprintw() etc.. Finally the window can be destroyed with
-        delwin(). It will deallocate the memory associated with the
-        window structure.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="LETBEWINDOW" id=
-        "LETBEWINDOW">9.2. Let there be a Window !!!</a></h3>
-
-        <p>What fun is it, if a window is created and we can't see
-        it. So the fun part begins by displaying the window. The
-        function <tt class="LITERAL">box()</tt> can be used to draw
-        a border around the window. Let's explore these functions
-        in more detail in this example.</p>
-
-        <div class="EXAMPLE">
-          <a name="BWIBO" id="BWIBO"></a>
-
-          <p><b>Example 7. Window Border example</b></p>
-          <pre class="PROGRAMLISTING">
-<span class="INLINEMEDIAOBJECT">#include &lt;ncurses.h&gt;
-
-
-WINDOW *create_newwin(int height, int width, int starty, int startx);
-void destroy_win(WINDOW *local_win);
-
-int main(int argc, char *argv[])
-{       WINDOW *my_win;
-        int startx, starty, width, height;
-        int ch;
-
-        initscr();                      /* Start curses mode            */
-        cbreak();                       /* Line buffering disabled, Pass on
-                                         * everty thing to me           */
-        keypad(stdscr, TRUE);           /* I need that nifty F1         */
-
-        height = 3;
-        width = 10;
-        starty = (LINES - height) / 2;  /* Calculating for a center placement */
-        startx = (COLS - width) / 2;    /* of the window                */
-        printw("Press F1 to exit");
-        refresh();
-        my_win = create_newwin(height, width, starty, startx);
-
-        while((ch = getch()) != KEY_F(1))
-        {       switch(ch)
-                {       case KEY_LEFT:
-                                destroy_win(my_win);
-                                my_win = create_newwin(height, width, starty,--startx);
-                                break;
-                        case KEY_RIGHT:
-                                destroy_win(my_win);
-                                my_win = create_newwin(height, width, starty,++startx);
-                                break;
-                        case KEY_UP:
-                                destroy_win(my_win);
-                                my_win = create_newwin(height, width, --starty,startx);
-                                break;
-                        case KEY_DOWN:
-                                destroy_win(my_win);
-                                my_win = create_newwin(height, width, ++starty,startx);
-                                break;  
-                }
-        }
-                
-        endwin();                       /* End curses mode                */
-        return 0;
-}
-
-WINDOW *create_newwin(int height, int width, int starty, int startx)
-{       WINDOW *local_win;
-
-        local_win = newwin(height, width, starty, startx);
-        box(local_win, 0 , 0);          /* 0, 0 gives default characters 
-                                         * for the vertical and horizontal
-                                         * lines                        */
-        wrefresh(local_win);            /* Show that box                */
-
-        return local_win;
-}
-
-void destroy_win(WINDOW *local_win)
-{       
-        /* box(local_win, ' ', ' '); : This won't produce the desired
-         * result of erasing the window. It will leave it's four corners 
-         * and so an ugly remnant of window. 
-         */
-        wborder(local_win, ' ', ' ', ' ',' ',' ',' ',' ',' ');
-        /* The parameters taken are 
-         * 1. win: the window on which to operate
-         * 2. ls: character to be used for the left side of the window 
-         * 3. rs: character to be used for the right side of the window 
-         * 4. ts: character to be used for the top side of the window 
-         * 5. bs: character to be used for the bottom side of the window 
-         * 6. tl: character to be used for the top left corner of the window 
-         * 7. tr: character to be used for the top right corner of the window 
-         * 8. bl: character to be used for the bottom left corner of the window 
-         * 9. br: character to be used for the bottom right corner of the window
-         */
-        wrefresh(local_win);
-        delwin(local_win);
-}</span>
-</pre>
-        </div>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="BORDEREXEXPL" id=
-        "BORDEREXEXPL">9.3. Explanation</a></h3>
-
-        <p>Don't scream. I know it's a big example. But I have to
-        explain some important things here :-). This program
-        creates a rectangular window that can be moved with left,
-        right, up, down arrow keys. It repeatedly creates and
-        destroys windows as user press a key. Don't go beyond the
-        screen limits. Checking for those limits is left as an
-        exercise for the reader. Let's dissect it by line by
-        line.</p>
-
-        <p>The <tt class="LITERAL">create_newwin()</tt> function
-        creates a window with <tt class="LITERAL">newwin()</tt> and
-        displays a border around it with box. The function
-        <tt class="LITERAL">destroy_win()</tt> first erases the
-        window from screen by painting a border with ' ' character
-        and then calling <tt class="LITERAL">delwin()</tt> to
-        deallocate memory related to it. Depending on the key the
-        user presses, starty or startx is changed and a new window
-        is created.</p>
-
-        <p>In the destroy_win, as you can see, I used wborder
-        instead of box. The reason is written in the comments (You
-        missed it. I know. Read the code :-)). wborder draws a
-        border around the window with the characters given to it as
-        the 4 corner points and the 4 lines. To put it clearly, if
-        you have called wborder as below:</p>
-        <pre class="PROGRAMLISTING">
-    wborder(win, '|', '|', '-', '-', '+', '+', '+', '+');
-</pre>
-
-        <p>it produces some thing like</p>
-        <pre class="PROGRAMLISTING">
-    +------------+
-    |            |
-    |            |
-    |            |
-    |            |
-    |            |
-    |            |
-    +------------+
-</pre>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="OTHERSTUFF" id="OTHERSTUFF">9.4.
-        The other stuff in the example</a></h3>
-
-        <p>You can also see in the above examples, that I have used
-        the variables COLS, LINES which are initialized to the
-        screen sizes after initscr(). They can be useful in finding
-        screen dimensions and finding the center co-ordinate of the
-        screen as above. The function <tt class=
-        "LITERAL">getch()</tt> as usual gets the key from keyboard
-        and according to the key it does the corresponding work.
-        This type of switch- case is very common in any GUI based
-        programs.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="OTHERBORDERFUNCS" id=
-        "OTHERBORDERFUNCS">9.5. Other Border functions</a></h3>
-
-        <p>Above program is grossly inefficient in that with each
-        press of a key, a window is destroyed and another is
-        created. So let's write a more efficient program which uses
-        other border related functions.</p>
-
-        <p>The following program uses <tt class=
-        "LITERAL">mvhline()</tt> and <tt class=
-        "LITERAL">mvvline()</tt> to achieve similar effect. These
-        two functions are simple. They create a horizontal or
-        vertical line of the specified length at the specified
-        position.</p>
-
-        <div class="EXAMPLE">
-          <a name="BOTBO" id="BOTBO"></a>
-
-          <p><b>Example 8. More border functions</b></p>
-          <pre class="PROGRAMLISTING">
-<span class="INLINEMEDIAOBJECT">#include &lt;ncurses.h&gt;
-
-typedef struct _win_border_struct {
-        chtype  ls, rs, ts, bs, 
-                tl, tr, bl, br;
-}WIN_BORDER;
-
-typedef struct _WIN_struct {
-
-        int startx, starty;
-        int height, width;
-        WIN_BORDER border;
-}WIN;
-
-void init_win_params(WIN *p_win);
-void print_win_params(WIN *p_win);
-void create_box(WIN *win, bool flag);
-
-int main(int argc, char *argv[])
-{       WIN win;
-        int ch;
-
-        initscr();                      /* Start curses mode            */
-        start_color();                  /* Start the color functionality */
-        cbreak();                       /* Line buffering disabled, Pass on
-                                         * everty thing to me           */
-        keypad(stdscr, TRUE);           /* I need that nifty F1         */
-        noecho();
-        init_pair(1, COLOR_CYAN, COLOR_BLACK);
-
-        /* Initialize the window parameters */
-        init_win_params(&amp;win);
-        print_win_params(&amp;win);
-
-        attron(COLOR_PAIR(1));
-        printw("Press F1 to exit");
-        refresh();
-        attroff(COLOR_PAIR(1));
-        
-        create_box(&amp;win, TRUE);
-        while((ch = getch()) != KEY_F(1))
-        {       switch(ch)
-                {       case KEY_LEFT:
-                                create_box(&amp;win, FALSE);
-                                --win.startx;
-                                create_box(&amp;win, TRUE);
-                                break;
-                        case KEY_RIGHT:
-                                create_box(&amp;win, FALSE);
-                                ++win.startx;
-                                create_box(&amp;win, TRUE);
-                                break;
-                        case KEY_UP:
-                                create_box(&amp;win, FALSE);
-                                --win.starty;
-                                create_box(&amp;win, TRUE);
-                                break;
-                        case KEY_DOWN:
-                                create_box(&amp;win, FALSE);
-                                ++win.starty;
-                                create_box(&amp;win, TRUE);
-                                break;  
-                }
-        }
-        endwin();                       /* End curses mode                */
-        return 0;
-}
-void init_win_params(WIN *p_win)
-{
-        p_win-&gt;height = 3;
-        p_win-&gt;width = 10;
-        p_win-&gt;starty = (LINES - p_win-&gt;height)/2;      
-        p_win-&gt;startx = (COLS - p_win-&gt;width)/2;
-
-        p_win-&gt;border.ls = '|';
-        p_win-&gt;border.rs = '|';
-        p_win-&gt;border.ts = '-';
-        p_win-&gt;border.bs = '-';
-        p_win-&gt;border.tl = '+';
-        p_win-&gt;border.tr = '+';
-        p_win-&gt;border.bl = '+';
-        p_win-&gt;border.br = '+';
-
-}
-void print_win_params(WIN *p_win)
-{
-#ifdef _DEBUG
-        mvprintw(25, 0, "%d %d %d %d", p_win-&gt;startx, p_win-&gt;starty, 
-                                p_win-&gt;width, p_win-&gt;height);
-        refresh();
-#endif
-}
-void create_box(WIN *p_win, bool flag)
-{       int i, j;
-        int x, y, w, h;
-
-        x = p_win-&gt;startx;
-        y = p_win-&gt;starty;
-        w = p_win-&gt;width;
-        h = p_win-&gt;height;
-
-        if(flag == TRUE)
-        {       mvaddch(y, x, p_win-&gt;border.tl);
-                mvaddch(y, x + w, p_win-&gt;border.tr);
-                mvaddch(y + h, x, p_win-&gt;border.bl);
-                mvaddch(y + h, x + w, p_win-&gt;border.br);
-                mvhline(y, x + 1, p_win-&gt;border.ts, w - 1);
-                mvhline(y + h, x + 1, p_win-&gt;border.bs, w - 1);
-                mvvline(y + 1, x, p_win-&gt;border.ls, h - 1);
-                mvvline(y + 1, x + w, p_win-&gt;border.rs, h - 1);
-
-        }
-        else
-                for(j = y; j &lt;= y + h; ++j)
-                        for(i = x; i &lt;= x + w; ++i)
-                                mvaddch(j, i, ' ');
-                                
-        refresh();
-
-}</span>
-</pre>
-        </div>
-      </div>
-    </div>
-
-    <div class="SECT1">
-      <hr>
-
-      <h2 class="SECT1"><a name="COLOR" id="COLOR">10.
-      Colors</a></h2>
-
-      <div class="SECT2">
-        <h3 class="SECT2"><a name="COLORBASICS" id=
-        "COLORBASICS">10.1. The basics</a></h3>
-
-        <p>Life seems dull with no colors. Curses has a nice
-        mechanism to handle colors. Let's get into the thick of the
-        things with a small program.</p>
-
-        <div class="EXAMPLE">
-          <a name="BSICO" id="BSICO"></a>
-
-          <p><b>Example 9. A Simple Color example</b></p>
-          <pre class="PROGRAMLISTING">
-<span class="INLINEMEDIAOBJECT">#include &lt;ncurses.h&gt;
-
-void print_in_middle(WINDOW *win, int starty, int startx, int width, char *string);
-int main(int argc, char *argv[])
-{       initscr();                      /* Start curses mode            */
-        if(has_colors() == FALSE)
-        {       endwin();
-                printf("Your terminal does not support color\n");
-                exit(1);
-        }
-        start_color();                  /* Start color                  */
-        init_pair(1, COLOR_RED, COLOR_BLACK);
-
-        attron(COLOR_PAIR(1));
-        print_in_middle(stdscr, LINES / 2, 0, 0, "Viola !!! In color ...");
-        attroff(COLOR_PAIR(1));
-        getch();
-        endwin();
-}
-void print_in_middle(WINDOW *win, int starty, int startx, int width, char *string)
-{       int length, x, y;
-        float temp;
-
-        if(win == NULL)
-                win = stdscr;
-        getyx(win, y, x);
-        if(startx != 0)
-                x = startx;
-        if(starty != 0)
-                y = starty;
-        if(width == 0)
-                width = 80;
-
-        length = strlen(string);
-        temp = (width - length)/ 2;
-        x = startx + (int)temp;
-        mvwprintw(win, y, x, "%s", string);
-        refresh();
-}
-</span>
-</pre>
-        </div>
-
-        <p>As you can see, to start using color, you should first
-        call the function <tt class="LITERAL">start_color()</tt>.
-        After that, you can use color capabilities of your
-        terminals using various functions. To find out whether a
-        terminal has color capabilities or not, you can use
-        <tt class="LITERAL">has_colors()</tt> function, which
-        returns FALSE if the terminal does not support color.</p>
-
-        <p>Curses initializes all the colors supported by terminal
-        when start_color() is called. These can be accessed by the
-        define constants like <tt class="LITERAL">COLOR_BLACK</tt>
-        etc. Now to actually start using colors, you have to define
-        pairs. Colors are always used in pairs. That means you have
-        to use the function <tt class="LITERAL">init_pair()</tt> to
-        define the foreground and background for the pair number
-        you give. After that that pair number can be used as a
-        normal attribute with <tt class=
-        "LITERAL">COLOR_PAIR()</tt>function. This may seem to be
-        cumbersome at first. But this elegant solution allows us to
-        manage color pairs very easily. To appreciate it, you have
-        to look into the the source code of "dialog", a utility for
-        displaying dialog boxes from shell scripts. The developers
-        have defined foreground and background combinations for all
-        the colors they might need and initialized at the
-        beginning. This makes it very easy to set attributes just
-        by accessing a pair which we already have defined as a
-        constant.</p>
-
-        <p>The following colors are defined in <tt class=
-        "LITERAL">curses.h</tt>. You can use these as parameters
-        for various color functions.</p>
-        <pre class="PROGRAMLISTING">
-        COLOR_BLACK   0
-        COLOR_RED     1
-        COLOR_GREEN   2
-        COLOR_YELLOW  3
-        COLOR_BLUE    4
-        COLOR_MAGENTA 5
-        COLOR_CYAN    6
-        COLOR_WHITE   7
-</pre>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="CHANGECOLORDEFS" id=
-        "CHANGECOLORDEFS">10.2. Changing Color Definitions</a></h3>
-
-        <p>The function <tt class="LITERAL">init_color()</tt>can be
-        used to change the rgb values for the colors defined by
-        curses initially. Say you wanted to lighten the intensity
-        of red color by a minuscule. Then you can use this function
-        as</p>
-        <pre class="PROGRAMLISTING">
-    init_color(COLOR_RED, 700, 0, 0);
-    /* param 1     : color name
-     * param 2, 3, 4 : rgb content min = 0, max = 1000 */
-</pre>
-
-        <p>If your terminal cannot change the color definitions,
-        the function returns ERR. The function <tt class=
-        "LITERAL">can_change_color()</tt> can be used to find out
-        whether the terminal has the capability of changing color
-        content or not. The rgb content is scaled from 0 to 1000.
-        Initially RED color is defined with content 1000(r), 0(g),
-        0(b).</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="COLORCONTENT" id=
-        "COLORCONTENT">10.3. Color Content</a></h3>
-
-        <p>The functions <tt class="LITERAL">color_content()</tt>
-        and <tt class="LITERAL">pair_content()</tt> can be used to
-        find the color content and foreground, background
-        combination for the pair.</p>
-      </div>
-    </div>
-
-    <div class="SECT1">
-      <hr>
-
-      <h2 class="SECT1"><a name="KEYS" id="KEYS">11. Interfacing
-      with the key board</a></h2>
-
-      <div class="SECT2">
-        <h3 class="SECT2"><a name="KEYSBASICS" id=
-        "KEYSBASICS">11.1. The Basics</a></h3>
-
-        <p>No GUI is complete without a strong user interface and
-        to interact with the user, a curses program should be
-        sensitive to key presses or the mouse actions done by the
-        user. Let's deal with the keys first.</p>
-
-        <p>As you have seen in almost all of the above examples,
-        it's very easy to get key input from the user. A simple way
-        of getting key presses is to use <tt class=
-        "LITERAL">getch()</tt> function. The cbreak mode should be
-        enabled to read keys when you are interested in reading
-        individual key hits rather than complete lines of text
-        (which usually end with a carriage return). keypad should
-        be enabled to get the Functions keys, arrow keys etc. See
-        the initialization section for details.</p>
-
-        <p><tt class="LITERAL">getch()</tt> returns an integer
-        corresponding to the key pressed. If it is a normal
-        character, the integer value will be equivalent to the
-        character. Otherwise it returns a number which can be
-        matched with the constants defined in <tt class=
-        "LITERAL">curses.h</tt>. For example if the user presses
-        F1, the integer returned is 265. This can be checked using
-        the macro KEY_F() defined in curses.h. This makes reading
-        keys portable and easy to manage.</p>
-
-        <p>For example, if you call getch() like this</p>
-        <pre class="PROGRAMLISTING">
-    int ch;
-
-    ch = getch();
-</pre>
-
-        <p>getch() will wait for the user to press a key, (unless
-        you specified a timeout) and when user presses a key, the
-        corresponding integer is returned. Then you can check the
-        value returned with the constants defined in curses.h to
-        match against the keys you want.</p>
-
-        <p>The following code piece will do that job.</p>
-        <pre class="PROGRAMLISTING">
-    if(ch == KEY_LEFT)
-        printw("Left arrow is pressed\n");
-</pre>
-
-        <p>Let's write a small program which creates a menu which
-        can be navigated by up and down arrows.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="SIMPLEKEYEX" id=
-        "SIMPLEKEYEX">11.2. A Simple Key Usage example</a></h3>
-
-        <div class="EXAMPLE">
-          <a name="BSIKE" id="BSIKE"></a>
-
-          <p><b>Example 10. A Simple Key Usage example</b></p>
-          <pre class="PROGRAMLISTING">
-<span class="INLINEMEDIAOBJECT">#include &lt;stdio.h&gt;
-#include &lt;ncurses.h&gt;
-
-#define WIDTH 30
-#define HEIGHT 10 
-
-int startx = 0;
-int starty = 0;
-
-char *choices[] = { 
-                        "Choice 1",
-                        "Choice 2",
-                        "Choice 3",
-                        "Choice 4",
-                        "Exit",
-                  };
-int n_choices = sizeof(choices) / sizeof(char *);
-void print_menu(WINDOW *menu_win, int highlight);
-
-int main()
-{       WINDOW *menu_win;
-        int highlight = 1;
-        int choice = 0;
-        int c;
-
-        initscr();
-        clear();
-        noecho();
-        cbreak();       /* Line buffering disabled. pass on everything */
-        startx = (80 - WIDTH) / 2;
-        starty = (24 - HEIGHT) / 2;
-                
-        menu_win = newwin(HEIGHT, WIDTH, starty, startx);
-        keypad(menu_win, TRUE);
-        mvprintw(0, 0, "Use arrow keys to go up and down, Press enter to select a choice");
-        refresh();
-        print_menu(menu_win, highlight);
-        while(1)
-        {       c = wgetch(menu_win);
-                switch(c)
-                {       case KEY_UP:
-                                if(highlight == 1)
-                                        highlight = n_choices;
-                                else
-                                        --highlight;
-                                break;
-                        case KEY_DOWN:
-                                if(highlight == n_choices)
-                                        highlight = 1;
-                                else 
-                                        ++highlight;
-                                break;
-                        case 10:
-                                choice = highlight;
-                                break;
-                        default:
-                                mvprintw(24, 0, "Charcter pressed is = %3d Hopefully it can be printed as '%c'", c, c);
-                                refresh();
-                                break;
-                }
-                print_menu(menu_win, highlight);
-                if(choice != 0) /* User did a choice come out of the infinite loop */
-                        break;
-        }       
-        mvprintw(23, 0, "You chose choice %d with choice string %s\n", choice, choices[choice - 1]);
-        clrtoeol();
-        refresh();
-        endwin();
-        return 0;
-}
-
-
-void print_menu(WINDOW *menu_win, int highlight)
-{
-        int x, y, i;    
-
-        x = 2;
-        y = 2;
-        box(menu_win, 0, 0);
-        for(i = 0; i &lt; n_choices; ++i)
-        {       if(highlight == i + 1) /* High light the present choice */
-                {       wattron(menu_win, A_REVERSE); 
-                        mvwprintw(menu_win, y, x, "%s", choices[i]);
-                        wattroff(menu_win, A_REVERSE);
-                }
-                else
-                        mvwprintw(menu_win, y, x, "%s", choices[i]);
-                ++y;
-        }
-        wrefresh(menu_win);
-}
-</span>
-</pre>
-        </div>
-      </div>
-    </div>
-
-    <div class="SECT1">
-      <hr>
-
-      <h2 class="SECT1"><a name="MOUSE" id="MOUSE">12. Interfacing
-      with the mouse</a></h2>
-
-      <p>Now that you have seen how to get keys, lets do the same
-      thing from mouse. Usually each UI allows the user to interact
-      with both keyboard and mouse.</p>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="MOUSEBASICS" id=
-        "MOUSEBASICS">12.1. The Basics</a></h3>
-
-        <p>Before you do any thing else, the events you want to
-        receive have to be enabled with <tt class=
-        "LITERAL">mousemask()</tt>.</p>
-        <pre class="PROGRAMLISTING">
-    mousemask(  mmask_t newmask,    /* The events you want to listen to */
-                mmask_t *oldmask)    /* The old events mask                */
-</pre>
-
-        <p>The first parameter to above function is a bit mask of
-        events you would like to listen. By default, all the events
-        are turned off. The bit mask <tt class=
-        "LITERAL">ALL_MOUSE_EVENTS</tt> can be used to get all the
-        events.</p>
-
-        <p>The following are all the event masks:</p>
-        <pre class="PROGRAMLISTING">
-    Name            Description
-       ---------------------------------------------------------------------
-       BUTTON1_PRESSED          mouse button 1 down
-       BUTTON1_RELEASED         mouse button 1 up
-       BUTTON1_CLICKED          mouse button 1 clicked
-       BUTTON1_DOUBLE_CLICKED   mouse button 1 double clicked
-       BUTTON1_TRIPLE_CLICKED   mouse button 1 triple clicked
-       BUTTON2_PRESSED          mouse button 2 down
-       BUTTON2_RELEASED         mouse button 2 up
-       BUTTON2_CLICKED          mouse button 2 clicked
-       BUTTON2_DOUBLE_CLICKED   mouse button 2 double clicked
-       BUTTON2_TRIPLE_CLICKED   mouse button 2 triple clicked
-       BUTTON3_PRESSED          mouse button 3 down
-       BUTTON3_RELEASED         mouse button 3 up
-       BUTTON3_CLICKED          mouse button 3 clicked
-       BUTTON3_DOUBLE_CLICKED   mouse button 3 double clicked
-       BUTTON3_TRIPLE_CLICKED   mouse button 3 triple clicked
-       BUTTON4_PRESSED          mouse button 4 down
-       BUTTON4_RELEASED         mouse button 4 up
-       BUTTON4_CLICKED          mouse button 4 clicked
-       BUTTON4_DOUBLE_CLICKED   mouse button 4 double clicked
-       BUTTON4_TRIPLE_CLICKED   mouse button 4 triple clicked
-       BUTTON_SHIFT             shift was down during button state change
-       BUTTON_CTRL              control was down during button state change
-       BUTTON_ALT               alt was down during button state change
-       ALL_MOUSE_EVENTS         report all button state changes
-       REPORT_MOUSE_POSITION    report mouse movement
-</pre>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="GETTINGEVENTS" id=
-        "GETTINGEVENTS">12.2. Getting the events</a></h3>
-
-        <p>Once a class of mouse events have been enabled, getch()
-        class of functions return KEY_MOUSE every time some mouse
-        event happens. Then the mouse event can be retrieved with
-        <tt class="LITERAL">getmouse()</tt>.</p>
-
-        <p>The code approximately looks like this:</p>
-        <pre class="PROGRAMLISTING">
-    MEVENT event;
-
-    ch = getch();
-    if(ch == KEY_MOUSE)
-        if(getmouse(&amp;event) == OK)
-            .    /* Do some thing with the event */
-            .
-            .
-</pre>
-
-        <p>getmouse() returns the event into the pointer given to
-        it. It's a structure which contains</p>
-        <pre class="PROGRAMLISTING">
-    typedef struct
-    {
-        short id;         /* ID to distinguish multiple devices */
-        int x, y, z;      /* event coordinates */
-        mmask_t bstate;   /* button state bits */
-    }    
-</pre>
-
-        <p>The <tt class="LITERAL">bstate</tt> is the main variable
-        we are interested in. It tells the button state of the
-        mouse.</p>
-
-        <p>Then with a code snippet like the following, we can find
-        out what happened.</p>
-        <pre class="PROGRAMLISTING">
-    if(event.bstate &amp; BUTTON1_PRESSED)
-        printw("Left Button Pressed");
-</pre>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="MOUSETOGETHER" id=
-        "MOUSETOGETHER">12.3. Putting it all Together</a></h3>
-
-        <p>That's pretty much interfacing with mouse. Let's create
-        the same menu and enable mouse interaction. To make things
-        simpler, key handling is removed.</p>
-
-        <div class="EXAMPLE">
-          <a name="BMOME" id="BMOME"></a>
-
-          <p><b>Example 11. Access the menu with mouse !!!</b></p>
-          <pre class="PROGRAMLISTING">
-<span class="INLINEMEDIAOBJECT">#include &lt;ncurses.h&gt;
-
-#define WIDTH 30
-#define HEIGHT 10 
-
-int startx = 0;
-int starty = 0;
-
-char *choices[] = {     "Choice 1",
-                        "Choice 2",
-                        "Choice 3",
-                        "Choice 4",
-                        "Exit",
-                  };
-
-int n_choices = sizeof(choices) / sizeof(char *);
-
-void print_menu(WINDOW *menu_win, int highlight);
-void report_choice(int mouse_x, int mouse_y, int *p_choice);
-
-int main()
-{       int c, choice = 0;
-        WINDOW *menu_win;
-        MEVENT event;
-
-        /* Initialize curses */
-        initscr();
-        clear();
-        noecho();
-        cbreak();       //Line buffering disabled. pass on everything
-
-        /* Try to put the window in the middle of screen */
-        startx = (80 - WIDTH) / 2;
-        starty = (24 - HEIGHT) / 2;
-        
-        attron(A_REVERSE);
-        mvprintw(23, 1, "Click on Exit to quit (Works best in a virtual console)");
-        refresh();
-        attroff(A_REVERSE);
-
-        /* Print the menu for the first time */
-        menu_win = newwin(HEIGHT, WIDTH, starty, startx);
-        print_menu(menu_win, 1);
-        /* Get all the mouse events */
-        mousemask(ALL_MOUSE_EVENTS, NULL);
-        
-        while(1)
-        {       c = wgetch(menu_win);
-                switch(c)
-                {       case KEY_MOUSE:
-                        if(getmouse(&amp;event) == OK)
-                        {       /* When the user clicks left mouse button */
-                                if(event.bstate &amp; BUTTON1_PRESSED)
-                                {       report_choice(event.x + 1, event.y + 1, &amp;choice);
-                                        if(choice == -1) //Exit chosen
-                                                goto end;
-                                        mvprintw(22, 1, "Choice made is : %d String Chosen is \"%10s\"", choice, choices[choice - 1]);
-                                        refresh(); 
-                                }
-                        }
-                        print_menu(menu_win, choice);
-                        break;
-                }
-        }               
-end:
-        endwin();
-        return 0;
-}
-
-
-void print_menu(WINDOW *menu_win, int highlight)
-{
-        int x, y, i;    
-
-        x = 2;
-        y = 2;
-        box(menu_win, 0, 0);
-        for(i = 0; i &lt; n_choices; ++i)
-        {       if(highlight == i + 1)
-                {       wattron(menu_win, A_REVERSE); 
-                        mvwprintw(menu_win, y, x, "%s", choices[i]);
-                        wattroff(menu_win, A_REVERSE);
-                }
-                else
-                        mvwprintw(menu_win, y, x, "%s", choices[i]);
-                ++y;
-        }
-        wrefresh(menu_win);
-}
-
-/* Report the choice according to mouse position */
-void report_choice(int mouse_x, int mouse_y, int *p_choice)
-{       int i,j, choice;
-
-        i = startx + 2;
-        j = starty + 3;
-        
-        for(choice = 0; choice &lt; n_choices; ++choice)
-                if(mouse_y == j + choice &amp;&amp; mouse_x &gt;= i &amp;&amp; mouse_x &lt;= i + strlen(choices[choice]))
-                {       if(choice == n_choices - 1)
-                                *p_choice = -1;         
-                        else
-                                *p_choice = choice + 1; 
-                        break;
-                }
-}</span>
-</pre>
-        </div>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="MISCMOUSEFUNCS" id=
-        "MISCMOUSEFUNCS">12.4. Miscellaneous Functions</a></h3>
-
-        <p>The functions mouse_trafo() and wmouse_trafo() can be
-        used to convert to mouse co-ordinates to screen relative
-        co-ordinates. See curs_mouse(3X) man page for details.</p>
-
-        <p>The mouseinterval function sets the maximum time (in
-        thousands of a second) that can elapse between press and
-        release events in order for them to be recognized as a
-        click. This function returns the previous interval value.
-        The default is one fifth of a second.</p>
-      </div>
-    </div>
-
-    <div class="SECT1">
-      <hr>
-
-      <h2 class="SECT1"><a name="SCREEN" id="SCREEN">13. Screen
-      Manipulation</a></h2>
-
-      <p>In this section, we will look into some functions, which
-      allow us to manage the screen efficiently and to write some
-      fancy programs. This is especially important in writing
-      games.</p>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="GETYX" id="GETYX">13.1. getyx()
-        functions</a></h3>
-
-        <p>The function <tt class="LITERAL">getyx()</tt> can be
-        used to find out the present cursor co-ordinates. It will
-        fill the values of x and y co-ordinates in the arguments
-        given to it. Since getyx() is a macro you don't have to
-        pass the address of the variables. It can be called as</p>
-        <pre class="PROGRAMLISTING">
-    getyx(win, y, x);
-    /* win: window pointer
-     *   y, x: y, x co-ordinates will be put into this variables 
-     */
-</pre>
-
-        <p>The function getparyx() gets the beginning co-ordinates
-        of the sub window relative to the main window. This is some
-        times useful to update a sub window. When designing fancy
-        stuff like writing multiple menus, it becomes difficult to
-        store the menu positions, their first option co-ordinates
-        etc. A simple solution to this problem, is to create menus
-        in sub windows and later find the starting co-ordinates of
-        the menus by using getparyx().</p>
-
-        <p>The functions getbegyx() and getmaxyx() store current
-        window's beginning and maximum co-ordinates. These
-        functions are useful in the same way as above in managing
-        the windows and sub windows effectively.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="SCREENDUMP" id=
-        "SCREENDUMP">13.2. Screen Dumping</a></h3>
-
-        <p>While writing games, some times it becomes necessary to
-        store the state of the screen and restore it back to the
-        same state. The function scr_dump() can be used to dump the
-        screen contents to a file given as an argument. Later it
-        can be restored by scr_restore function. These two simple
-        functions can be used effectively to maintain a fast moving
-        game with changing scenarios.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="WINDOWDUMP" id=
-        "WINDOWDUMP">13.3. Window Dumping</a></h3>
-
-        <p>To store and restore windows, the functions <tt class=
-        "LITERAL">putwin()</tt> and <tt class=
-        "LITERAL">getwin()</tt> can be used. <tt class=
-        "LITERAL">putwin()</tt> puts the present window state into
-        a file, which can be later restored by <tt class=
-        "LITERAL">getwin()</tt>.</p>
-
-        <p>The function <tt class="LITERAL">copywin()</tt> can be
-        used to copy a window completely onto another window. It
-        takes the source and destination windows as parameters and
-        according to the rectangle specified, it copies the
-        rectangular region from source to destination window. It's
-        last parameter specifies whether to overwrite or just
-        overlay the contents on to the destination window. If this
-        argument is true, then the copying is non-destructive.</p>
-      </div>
-    </div>
-
-    <div class="SECT1">
-      <hr>
-
-      <h2 class="SECT1"><a name="MISC" id="MISC">14. Miscellaneous
-      features</a></h2>
-
-      <p>Now you know enough features to write a good curses
-      program, with all bells and whistles. There are some
-      miscellaneous functions which are useful in various cases.
-      Let's go headlong into some of those.</p>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="CURSSET" id="CURSSET">14.1.
-        curs_set()</a></h3>
-
-        <p>This function can be used to make the cursor invisible.
-        The parameter to this function should be</p>
-        <pre class="PROGRAMLISTING">
-    0 : invisible      or
-    1 : normal    or
-    2 : very visible.
-</pre>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="TEMPLEAVE" id="TEMPLEAVE">14.2.
-        Temporarily Leaving Curses mode</a></h3>
-
-        <p>Some times you may want to get back to cooked mode
-        (normal line buffering mode) temporarily. In such a case
-        you will first need to save the tty modes with a call to
-        <tt class="LITERAL">def_prog_mode()</tt> and then call
-        <tt class="LITERAL">endwin()</tt> to end the curses mode.
-        This will leave you in the original tty mode. To get back
-        to curses once you are done, call <tt class=
-        "LITERAL">reset_prog_mode()</tt> . This function returns
-        the tty to the state stored by <tt class=
-        "LITERAL">def_prog_mode()</tt>. Then do refresh(), and you
-        are back to the curses mode. Here is an example showing the
-        sequence of things to be done.</p>
-
-        <div class="EXAMPLE">
-          <a name="BTELE" id="BTELE"></a>
-
-          <p><b>Example 12. Temporarily Leaving Curses Mode</b></p>
-          <pre class="PROGRAMLISTING">
-<span class="INLINEMEDIAOBJECT">#include &lt;ncurses.h&gt;
-
-int main()
-{       
-        initscr();                      /* Start curses mode              */
-        printw("Hello World !!!\n");    /* Print Hello World              */
-        refresh();                      /* Print it on to the real screen */
-        def_prog_mode();                /* Save the tty modes             */
-        endwin();                       /* End curses mode temporarily    */
-        system("/bin/sh");              /* Do whatever you like in cooked mode */
-        reset_prog_mode();              /* Return to the previous tty mode*/
-                                        /* stored by def_prog_mode()      */
-        refresh();                      /* Do refresh() to restore the    */
-                                        /* Screen contents                */
-        printw("Another String\n");     /* Back to curses use the full    */
-        refresh();                      /* capabilities of curses         */
-        endwin();                       /* End curses mode                */
-
-        return 0;
-}</span>
-</pre>
-        </div>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="ACSVARS" id="ACSVARS">14.3. ACS_
-        variables</a></h3>
-
-        <p>If you have ever programmed in DOS, you know about those
-        nifty characters in extended character set. They are
-        printable only on some terminals. NCURSES functions like
-        <tt class="LITERAL">box()</tt> use these characters. All
-        these variables start with ACS meaning alternative
-        character set. You might have noticed me using these
-        characters in some of the programs above. Here's an example
-        showing all the characters.</p>
-
-        <div class="EXAMPLE">
-          <a name="BACSVARS" id="BACSVARS"></a>
-
-          <p><b>Example 13. ACS Variables Example</b></p>
-          <pre class="PROGRAMLISTING">
-<span class="INLINEMEDIAOBJECT">#include &lt;ncurses.h&gt;
-
-int main()
-{
-        initscr();
-
-        printw("Upper left corner           "); addch(ACS_ULCORNER); printw("\n"); 
-        printw("Lower left corner           "); addch(ACS_LLCORNER); printw("\n");
-        printw("Lower right corner          "); addch(ACS_LRCORNER); printw("\n");
-        printw("Tee pointing right          "); addch(ACS_LTEE); printw("\n");
-        printw("Tee pointing left           "); addch(ACS_RTEE); printw("\n");
-        printw("Tee pointing up             "); addch(ACS_BTEE); printw("\n");
-        printw("Tee pointing down           "); addch(ACS_TTEE); printw("\n");
-        printw("Horizontal line             "); addch(ACS_HLINE); printw("\n");
-        printw("Vertical line               "); addch(ACS_VLINE); printw("\n");
-        printw("Large Plus or cross over    "); addch(ACS_PLUS); printw("\n");
-        printw("Scan Line 1                 "); addch(ACS_S1); printw("\n");
-        printw("Scan Line 3                 "); addch(ACS_S3); printw("\n");
-        printw("Scan Line 7                 "); addch(ACS_S7); printw("\n");
-        printw("Scan Line 9                 "); addch(ACS_S9); printw("\n");
-        printw("Diamond                     "); addch(ACS_DIAMOND); printw("\n");
-        printw("Checker board (stipple)     "); addch(ACS_CKBOARD); printw("\n");
-        printw("Degree Symbol               "); addch(ACS_DEGREE); printw("\n");
-        printw("Plus/Minus Symbol           "); addch(ACS_PLMINUS); printw("\n");
-        printw("Bullet                      "); addch(ACS_BULLET); printw("\n");
-        printw("Arrow Pointing Left         "); addch(ACS_LARROW); printw("\n");
-        printw("Arrow Pointing Right        "); addch(ACS_RARROW); printw("\n");
-        printw("Arrow Pointing Down         "); addch(ACS_DARROW); printw("\n");
-        printw("Arrow Pointing Up           "); addch(ACS_UARROW); printw("\n");
-        printw("Board of squares            "); addch(ACS_BOARD); printw("\n");
-        printw("Lantern Symbol              "); addch(ACS_LANTERN); printw("\n");
-        printw("Solid Square Block          "); addch(ACS_BLOCK); printw("\n");
-        printw("Less/Equal sign             "); addch(ACS_LEQUAL); printw("\n");
-        printw("Greater/Equal sign          "); addch(ACS_GEQUAL); printw("\n");
-        printw("Pi                          "); addch(ACS_PI); printw("\n");
-        printw("Not equal                   "); addch(ACS_NEQUAL); printw("\n");
-        printw("UK pound sign               "); addch(ACS_STERLING); printw("\n");
-
-        refresh();
-        getch();
-        endwin();
-
-        return 0;
-}</span>
-</pre>
-        </div>
-      </div>
-    </div>
-
-    <div class="SECT1">
-      <hr>
-
-      <h2 class="SECT1"><a name="OTHERLIB" id="OTHERLIB">15. Other
-      libraries</a></h2>
-
-      <p>Apart from the curses library, there are few text mode
-      libraries, which provide more functionality and a lot of
-      features. The following sections explain three standard
-      libraries which are usually distributed along with
-      curses.</p>
-    </div>
-
-    <div class="SECT1">
-      <hr>
-
-      <h2 class="SECT1"><a name="PANELS" id="PANELS">16. Panel
-      Library</a></h2>
-
-      <p>Now that you are proficient in curses, you wanted to do
-      some thing big. You created a lot of overlapping windows to
-      give a professional windows-type look. Unfortunately, it soon
-      becomes difficult to manage these. The multiple refreshes,
-      updates plunge you into a nightmare. The overlapping windows
-      create blotches, whenever you forget to refresh the windows
-      in the proper order.</p>
-
-      <p>Don't despair. There's an elegant solution provided in
-      panels library. In the words of developers of ncurses</p>
-
-      <p><span class="emphasis"><i class="EMPHASIS">When your
-      interface design is such that windows may dive deeper into
-      the visibility stack or pop to the top at runtime, the
-      resulting book-keeping can be tedious and difficult to get
-      right. Hence the panels library.</i></span></p>
-
-      <p>If you have lot of overlapping windows, then panels
-      library is the way to go. It obviates the need of doing
-      series of wnoutrefresh(), doupdate() and relieves the burden
-      of doing it correctly(bottom up). The library maintains
-      information about the order of windows, their overlapping and
-      update the screen properly. So why wait? Let's take a close
-      peek into panels.</p>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="PANELBASICS" id=
-        "PANELBASICS">16.1. The Basics</a></h3>
-
-        <p>Panel object is a window that is implicitly treated as
-        part of a deck including all other panel objects. The deck
-        is treated as a stack with the top panel being completely
-        visible and the other panels may or may not be obscured
-        according to their positions. So the basic idea is to
-        create a stack of overlapping panels and use panels library
-        to display them correctly. There is a function similar to
-        refresh() which, when called , displays panels in the
-        correct order. Functions are provided to hide or show
-        panels, move panels, change its size etc.. The overlapping
-        problem is managed by the panels library during all the
-        calls to these functions.</p>
-
-        <p>The general flow of a panel program goes like this:</p>
-
-        <ol type="1">
-          <li>
-            <p>Create the windows (with newwin()) to be attached to
-            the panels.</p>
-          </li>
-
-          <li>
-            <p>Create panels with the chosen visibility order.
-            Stack them up according to the desired visibility. The
-            function new_panel() is used to created panels.</p>
-          </li>
-
-          <li>
-            <p>Call update_panels() to write the panels to the
-            virtual screen in correct visibility order. Do a
-            doupdate() to show it on the screen.</p>
-          </li>
-
-          <li>
-            <p>Mainpulate the panels with show_panel(),
-            hide_panel(), move_panel() etc. Make use of helper
-            functions like panel_hidden() and panel_window(). Make
-            use of user pointer to store custom data for a panel.
-            Use the functions set_panel_userptr() and
-            panel_userptr() to set and get the user pointer for a
-            panel.</p>
-          </li>
-
-          <li>
-            <p>When you are done with the panel use del_panel() to
-            delete the panel.</p>
-          </li>
-        </ol>
-
-        <p>Let's make the concepts clear, with some programs. The
-        following is a simple program which creates 3 overlapping
-        panels and shows them on the screen.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="COMPILEPANELS" id=
-        "COMPILEPANELS">16.2. Compiling With the Panels
-        Library</a></h3>
-
-        <p>To use panels library functions, you have to include
-        panel.h and to link the program with panels library the
-        flag -lpanel should be added along with -lncurses in that
-        order.</p>
-        <pre class="PROGRAMLISTING">
-    #include &lt;panel.h&gt;
-    .
-    .
-    .
-
-    compile and link: gcc &lt;program file&gt; -lpanel -lncurses
-</pre>
-
-        <div class="EXAMPLE">
-          <a name="PPASI" id="PPASI"></a>
-
-          <p><b>Example 14. Panel basics</b></p>
-          <pre class="PROGRAMLISTING">
-<span class="INLINEMEDIAOBJECT">#include &lt;panel.h&gt;
-
-int main()
-{       WINDOW *my_wins[3];
-        PANEL  *my_panels[3];
-        int lines = 10, cols = 40, y = 2, x = 4, i;
-
-        initscr();
-        cbreak();
-        noecho();
-
-        /* Create windows for the panels */
-        my_wins[0] = newwin(lines, cols, y, x);
-        my_wins[1] = newwin(lines, cols, y + 1, x + 5);
-        my_wins[2] = newwin(lines, cols, y + 2, x + 10);
-
-        /* 
-         * Create borders around the windows so that you can see the effect
-         * of panels
-         */
-        for(i = 0; i &lt; 3; ++i)
-                box(my_wins[i], 0, 0);
-
-        /* Attach a panel to each window */     /* Order is bottom up */
-        my_panels[0] = new_panel(my_wins[0]);   /* Push 0, order: stdscr-0 */
-        my_panels[1] = new_panel(my_wins[1]);   /* Push 1, order: stdscr-0-1 */
-        my_panels[2] = new_panel(my_wins[2]);   /* Push 2, order: stdscr-0-1-2 */
-
-        /* Update the stacking order. 2nd panel will be on top */
-        update_panels();
-
-        /* Show it on the screen */
-        doupdate();
-        
-        getch();
-        endwin();
-}
-</span>
-</pre>
-        </div>
-
-        <p>As you can see, above program follows a simple flow as
-        explained. The windows are created with newwin() and then
-        they are attached to panels with new_panel(). As we attach
-        one panel after another, the stack of panels gets updated.
-        To put them on screen update_panels() and doupdate() are
-        called.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="PANELBROWSING" id=
-        "PANELBROWSING">16.3. Panel Window Browsing</a></h3>
-
-        <p>A slightly complicated example is given below. This
-        program creates 3 windows which can be cycled through using
-        tab. Have a look at the code.</p>
-
-        <div class="EXAMPLE">
-          <a name="PPABR" id="PPABR"></a>
-
-          <p><b>Example 15. Panel Window Browsing Example</b></p>
-          <pre class="PROGRAMLISTING">
-<span class="INLINEMEDIAOBJECT">#include &lt;panel.h&gt;
-
-#define NLINES 10
-#define NCOLS 40
-
-void init_wins(WINDOW **wins, int n);
-void win_show(WINDOW *win, char *label, int label_color);
-void print_in_middle(WINDOW *win, int starty, int startx, int width, char *string, chtype color);
-
-int main()
-{       WINDOW *my_wins[3];
-        PANEL  *my_panels[3];
-        PANEL  *top;
-        int ch;
-
-        /* Initialize curses */
-        initscr();
-        start_color();
-        cbreak();
-        noecho();
-        keypad(stdscr, TRUE);
-
-        /* Initialize all the colors */
-        init_pair(1, COLOR_RED, COLOR_BLACK);
-        init_pair(2, COLOR_GREEN, COLOR_BLACK);
-        init_pair(3, COLOR_BLUE, COLOR_BLACK);
-        init_pair(4, COLOR_CYAN, COLOR_BLACK);
-
-        init_wins(my_wins, 3);
-        
-        /* Attach a panel to each window */     /* Order is bottom up */
-        my_panels[0] = new_panel(my_wins[0]);   /* Push 0, order: stdscr-0 */
-        my_panels[1] = new_panel(my_wins[1]);   /* Push 1, order: stdscr-0-1 */
-        my_panels[2] = new_panel(my_wins[2]);   /* Push 2, order: stdscr-0-1-2 */
-
-        /* Set up the user pointers to the next panel */
-        set_panel_userptr(my_panels[0], my_panels[1]);
-        set_panel_userptr(my_panels[1], my_panels[2]);
-        set_panel_userptr(my_panels[2], my_panels[0]);
-
-        /* Update the stacking order. 2nd panel will be on top */
-        update_panels();
-
-        /* Show it on the screen */
-        attron(COLOR_PAIR(4));
-        mvprintw(LINES - 2, 0, "Use tab to browse through the windows (F1 to Exit)");
-        attroff(COLOR_PAIR(4));
-        doupdate();
-
-        top = my_panels[2];
-        while((ch = getch()) != KEY_F(1))
-        {       switch(ch)
-                {       case 9:
-                                top = (PANEL *)panel_userptr(top);
-                                top_panel(top);
-                                break;
-                }
-                update_panels();
-                doupdate();
-        }
-        endwin();
-        return 0;
-}
-
-/* Put all the windows */
-void init_wins(WINDOW **wins, int n)
-{       int x, y, i;
-        char label[80];
-
-        y = 2;
-        x = 10;
-        for(i = 0; i &lt; n; ++i)
-        {       wins[i] = newwin(NLINES, NCOLS, y, x);
-                sprintf(label, "Window Number %d", i + 1);
-                win_show(wins[i], label, i + 1);
-                y += 3;
-                x += 7;
-        }
-}
-
-/* Show the window with a border and a label */
-void win_show(WINDOW *win, char *label, int label_color)
-{       int startx, starty, height, width;
-
-        getbegyx(win, starty, startx);
-        getmaxyx(win, height, width);
-
-        box(win, 0, 0);
-        mvwaddch(win, 2, 0, ACS_LTEE); 
-        mvwhline(win, 2, 1, ACS_HLINE, width - 2); 
-        mvwaddch(win, 2, width - 1, ACS_RTEE); 
-        
-        print_in_middle(win, 1, 0, width, label, COLOR_PAIR(label_color));
-}
-
-void print_in_middle(WINDOW *win, int starty, int startx, int width, char *string, chtype color)
-{       int length, x, y;
-        float temp;
-
-        if(win == NULL)
-                win = stdscr;
-        getyx(win, y, x);
-        if(startx != 0)
-                x = startx;
-        if(starty != 0)
-                y = starty;
-        if(width == 0)
-                width = 80;
-
-        length = strlen(string);
-        temp = (width - length)/ 2;
-        x = startx + (int)temp;
-        wattron(win, color);
-        mvwprintw(win, y, x, "%s", string);
-        wattroff(win, color);
-        refresh();
-}</span>
-</pre>
-        </div>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="USERPTRUSING" id=
-        "USERPTRUSING">16.4. Using User Pointers</a></h3>
-
-        <p>In the above example I used user pointers to find out
-        the next window in the cycle. We can attach custom
-        information to the panel by specifying a user pointer,
-        which can point to any information you want to store. In
-        this case I stored the pointer to the next panel in the
-        cycle. User pointer for a panel can be set with the
-        function <tt class="LITERAL">set_panel_userptr()</tt>. It
-        can be accessed using the function <tt class=
-        "LITERAL">panel_userptr()</tt> which will return the user
-        pointer for the panel given as argument. After finding the
-        next panel in the cycle It's brought to the top by the
-        function top_panel(). This function brings the panel given
-        as argument to the top of the panel stack.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="PANELMOVERESIZE" id=
-        "PANELMOVERESIZE">16.5. Moving and Resizing Panels</a></h3>
-
-        <p>The function <tt class="LITERAL">move_panel()</tt> can
-        be used to move a panel to the desired location. It does
-        not change the position of the panel in the stack. Make
-        sure that you use move_panel() instead mvwin() on the
-        window associated with the panel.</p>
-
-        <p>Resizing a panel is slightly complex. There is no
-        straight forward function just to resize the window
-        associated with a panel. A solution to resize a panel is to
-        create a new window with the desired sizes, change the
-        window associated with the panel using replace_panel().
-        Don't forget to delete the old window. The window
-        associated with a panel can be found by using the function
-        panel_window().</p>
-
-        <p>The following program shows these concepts, in
-        supposedly simple program. You can cycle through the window
-        with &lt;TAB&gt; as usual. To resize or move the active
-        panel press 'r' for resize 'm' for moving. Then use arrow
-        keys to resize or move it to the desired way and press
-        enter to end your resizing or moving. This example makes
-        use of user data to get the required data to do the
-        operations.</p>
-
-        <div class="EXAMPLE">
-          <a name="PPARE" id="PPARE"></a>
-
-          <p><b>Example 16. Panel Moving and Resizing
-          example</b></p>
-          <pre class="PROGRAMLISTING">
-<span class="INLINEMEDIAOBJECT">#include &lt;panel.h&gt;
-
-typedef struct _PANEL_DATA {
-        int x, y, w, h;
-        char label[80]; 
-        int label_color;
-        PANEL *next;
-}PANEL_DATA;
-
-#define NLINES 10
-#define NCOLS 40
-
-void init_wins(WINDOW **wins, int n);
-void win_show(WINDOW *win, char *label, int label_color);
-void print_in_middle(WINDOW *win, int starty, int startx, int width, char *string, chtype color);
-void set_user_ptrs(PANEL **panels, int n);
-
-int main()
-{       WINDOW *my_wins[3];
-        PANEL  *my_panels[3];
-        PANEL_DATA  *top;
-        PANEL *stack_top;
-        WINDOW *temp_win, *old_win;
-        int ch;
-        int newx, newy, neww, newh;
-        int size = FALSE, move = FALSE;
-
-        /* Initialize curses */
-        initscr();
-        start_color();
-        cbreak();
-        noecho();
-        keypad(stdscr, TRUE);
-
-        /* Initialize all the colors */
-        init_pair(1, COLOR_RED, COLOR_BLACK);
-        init_pair(2, COLOR_GREEN, COLOR_BLACK);
-        init_pair(3, COLOR_BLUE, COLOR_BLACK);
-        init_pair(4, COLOR_CYAN, COLOR_BLACK);
-
-        init_wins(my_wins, 3);
-        
-        /* Attach a panel to each window */     /* Order is bottom up */
-        my_panels[0] = new_panel(my_wins[0]);   /* Push 0, order: stdscr-0 */
-        my_panels[1] = new_panel(my_wins[1]);   /* Push 1, order: stdscr-0-1 */
-        my_panels[2] = new_panel(my_wins[2]);   /* Push 2, order: stdscr-0-1-2 */
-
-        set_user_ptrs(my_panels, 3);
-        /* Update the stacking order. 2nd panel will be on top */
-        update_panels();
-
-        /* Show it on the screen */
-        attron(COLOR_PAIR(4));
-        mvprintw(LINES - 3, 0, "Use 'm' for moving, 'r' for resizing");
-        mvprintw(LINES - 2, 0, "Use tab to browse through the windows (F1 to Exit)");
-        attroff(COLOR_PAIR(4));
-        doupdate();
-
-        stack_top = my_panels[2];
-        top = (PANEL_DATA *)panel_userptr(stack_top);
-        newx = top-&gt;x;
-        newy = top-&gt;y;
-        neww = top-&gt;w;
-        newh = top-&gt;h;
-        while((ch = getch()) != KEY_F(1))
-        {       switch(ch)
-                {       case 9:         /* Tab */
-                                top = (PANEL_DATA *)panel_userptr(stack_top);
-                                top_panel(top-&gt;next);
-                                stack_top = top-&gt;next;
-                                top = (PANEL_DATA *)panel_userptr(stack_top);
-                                newx = top-&gt;x;
-                                newy = top-&gt;y;
-                                neww = top-&gt;w;
-                                newh = top-&gt;h;
-                                break;
-                        case 'r':       /* Re-Size*/
-                                size = TRUE;
-                                attron(COLOR_PAIR(4));
-                                mvprintw(LINES - 4, 0, "Entered Resizing :Use Arrow Keys to resize and press &lt;ENTER&gt; to end resizing");
-                                refresh();
-                                attroff(COLOR_PAIR(4));
-                                break;
-                        case 'm':       /* Move */
-                                attron(COLOR_PAIR(4));
-                                mvprintw(LINES - 4, 0, "Entered Moving: Use Arrow Keys to Move and press &lt;ENTER&gt; to end moving");
-                                refresh();
-                                attroff(COLOR_PAIR(4));
-                                move = TRUE;
-                                break;
-                        case KEY_LEFT:
-                                if(size == TRUE)
-                                {       --newx;
-                                        ++neww;
-                                }
-                                if(move == TRUE)
-                                        --newx;
-                                break;
-                        case KEY_RIGHT:
-                                if(size == TRUE)
-                                {       ++newx;
-                                        --neww;
-                                }
-                                if(move == TRUE)
-                                        ++newx;
-                                break;
-                        case KEY_UP:
-                                if(size == TRUE)
-                                {       --newy;
-                                        ++newh;
-                                }
-                                if(move == TRUE)
-                                        --newy;
-                                break;
-                        case KEY_DOWN:
-                                if(size == TRUE)
-                                {       ++newy;
-                                        --newh;
-                                }
-                                if(move == TRUE)
-                                        ++newy;
-                                break;
-                        case 10:        /* Enter */
-                                move(LINES - 4, 0);
-                                clrtoeol();
-                                refresh();
-                                if(size == TRUE)
-                                {       old_win = panel_window(stack_top);
-                                        temp_win = newwin(newh, neww, newy, newx);
-                                        replace_panel(stack_top, temp_win);
-                                        win_show(temp_win, top-&gt;label, top-&gt;label_color); 
-                                        delwin(old_win);
-                                        size = FALSE;
-                                }
-                                if(move == TRUE)
-                                {       move_panel(stack_top, newy, newx);
-                                        move = FALSE;
-                                }
-                                break;
-                        
-                }
-                attron(COLOR_PAIR(4));
-                mvprintw(LINES - 3, 0, "Use 'm' for moving, 'r' for resizing");
-                mvprintw(LINES - 2, 0, "Use tab to browse through the windows (F1 to Exit)");
-                attroff(COLOR_PAIR(4));
-                refresh();      
-                update_panels();
-                doupdate();
-        }
-        endwin();
-        return 0;
-}
-
-/* Put all the windows */
-void init_wins(WINDOW **wins, int n)
-{       int x, y, i;
-        char label[80];
-
-        y = 2;
-        x = 10;
-        for(i = 0; i &lt; n; ++i)
-        {       wins[i] = newwin(NLINES, NCOLS, y, x);
-                sprintf(label, "Window Number %d", i + 1);
-                win_show(wins[i], label, i + 1);
-                y += 3;
-                x += 7;
-        }
-}
-
-/* Set the PANEL_DATA structures for individual panels */
-void set_user_ptrs(PANEL **panels, int n)
-{       PANEL_DATA *ptrs;
-        WINDOW *win;
-        int x, y, w, h, i;
-        char temp[80];
-        
-        ptrs = (PANEL_DATA *)calloc(n, sizeof(PANEL_DATA));
-
-        for(i = 0;i &lt; n; ++i)
-        {       win = panel_window(panels[i]);
-                getbegyx(win, y, x);
-                getmaxyx(win, h, w);
-                ptrs[i].x = x;
-                ptrs[i].y = y;
-                ptrs[i].w = w;
-                ptrs[i].h = h;
-                sprintf(temp, "Window Number %d", i + 1);
-                strcpy(ptrs[i].label, temp);
-                ptrs[i].label_color = i + 1;
-                if(i + 1 == n)
-                        ptrs[i].next = panels[0];
-                else
-                        ptrs[i].next = panels[i + 1];
-                set_panel_userptr(panels[i], &amp;ptrs[i]);
-        }
-}
-
-/* Show the window with a border and a label */
-void win_show(WINDOW *win, char *label, int label_color)
-{       int startx, starty, height, width;
-
-        getbegyx(win, starty, startx);
-        getmaxyx(win, height, width);
-
-        box(win, 0, 0);
-        mvwaddch(win, 2, 0, ACS_LTEE); 
-        mvwhline(win, 2, 1, ACS_HLINE, width - 2); 
-        mvwaddch(win, 2, width - 1, ACS_RTEE); 
-        
-        print_in_middle(win, 1, 0, width, label, COLOR_PAIR(label_color));
-}
-
-void print_in_middle(WINDOW *win, int starty, int startx, int width, char *string, chtype color)
-{       int length, x, y;
-        float temp;
-
-        if(win == NULL)
-                win = stdscr;
-        getyx(win, y, x);
-        if(startx != 0)
-                x = startx;
-        if(starty != 0)
-                y = starty;
-        if(width == 0)
-                width = 80;
-
-        length = strlen(string);
-        temp = (width - length)/ 2;
-        x = startx + (int)temp;
-        wattron(win, color);
-        mvwprintw(win, y, x, "%s", string);
-        wattroff(win, color);
-        refresh();
-}</span>
-</pre>
-        </div>
-
-        <p>Concentrate on the main while loop. Once it finds out
-        the type of key pressed, it takes appropriate action. If
-        'r' is pressed resizing mode is started. After this the new
-        sizes are updated as the user presses the arrow keys. When
-        the user presses &lt;ENTER&gt; present selection ends and
-        panel is resized by using the concept explained. While in
-        resizing mode the program doesn't show how the window is
-        getting resized. It's left as an exercise to the reader to
-        print a dotted border while it gets resized to a new
-        position.</p>
-
-        <p>When the user presses 'm' the move mode starts. This is
-        a bit simpler than resizing. As the arrow keys are pressed
-        the new position is updated and pressing of &lt;ENTER&gt;
-        causes the panel to be moved by calling the function
-        move_panel().</p>
-
-        <p>In this program the user data which is represented as
-        PANEL_DATA, plays very important role in finding the
-        associated information with a panel. As written in the
-        comments, the PANEL_DATA stores the panel sizes, label,
-        label color and a pointer to the next panel in the
-        cycle.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="PANELSHOWHIDE" id=
-        "PANELSHOWHIDE">16.6. Hiding and Showing Panels</a></h3>
-
-        <p>A Panel can be hidden by using the function
-        hide_panel(). This function merely removes it form the
-        stack of panels, thus hiding it on the screen once you do
-        update_panels() and doupdate(). It doesn't destroy the
-        PANEL structure associated with the hidden panel. It can be
-        shown again by using the show_panel() function.</p>
-
-        <p>The following program shows the hiding of panels. Press
-        'a' or 'b' or 'c' to show or hide first, second and third
-        windows respectively. It uses a user data with a small
-        variable hide, which keeps track of whether the window is
-        hidden or not. For some reason the function <tt class=
-        "LITERAL">panel_hidden()</tt> which tells whether a panel
-        is hidden or not is not working. A bug report was also
-        presented by Michael Andres <a href=
-        "http://www.geocrawler.com/archives/3/344/1999/9/0/2643549/"
-        target="_top">here</a></p>
-
-        <div class="EXAMPLE">
-          <a name="PPAHI" id="PPAHI"></a>
-
-          <p><b>Example 17. Panel Hiding and Showing
-          example</b></p>
-          <pre class="PROGRAMLISTING">
-<span class="INLINEMEDIAOBJECT">#include &lt;panel.h&gt;
-
-typedef struct _PANEL_DATA {
-        int hide;       /* TRUE if panel is hidden */
-}PANEL_DATA;
-
-#define NLINES 10
-#define NCOLS 40
-
-void init_wins(WINDOW **wins, int n);
-void win_show(WINDOW *win, char *label, int label_color);
-void print_in_middle(WINDOW *win, int starty, int startx, int width, char *string, chtype color);
-
-int main()
-{       WINDOW *my_wins[3];
-        PANEL  *my_panels[3];
-        PANEL_DATA panel_datas[3];
-        PANEL_DATA *temp;
-        int ch;
-
-        /* Initialize curses */
-        initscr();
-        start_color();
-        cbreak();
-        noecho();
-        keypad(stdscr, TRUE);
-
-        /* Initialize all the colors */
-        init_pair(1, COLOR_RED, COLOR_BLACK);
-        init_pair(2, COLOR_GREEN, COLOR_BLACK);
-        init_pair(3, COLOR_BLUE, COLOR_BLACK);
-        init_pair(4, COLOR_CYAN, COLOR_BLACK);
-
-        init_wins(my_wins, 3);
-        
-        /* Attach a panel to each window */     /* Order is bottom up */
-        my_panels[0] = new_panel(my_wins[0]);   /* Push 0, order: stdscr-0 */
-        my_panels[1] = new_panel(my_wins[1]);   /* Push 1, order: stdscr-0-1 */
-        my_panels[2] = new_panel(my_wins[2]);   /* Push 2, order: stdscr-0-1-2 */
-
-        /* Initialize panel datas saying that nothing is hidden */
-        panel_datas[0].hide = FALSE;
-        panel_datas[1].hide = FALSE;
-        panel_datas[2].hide = FALSE;
-
-        set_panel_userptr(my_panels[0], &amp;panel_datas[0]);
-        set_panel_userptr(my_panels[1], &amp;panel_datas[1]);
-        set_panel_userptr(my_panels[2], &amp;panel_datas[2]);
-
-        /* Update the stacking order. 2nd panel will be on top */
-        update_panels();
-
-        /* Show it on the screen */
-        attron(COLOR_PAIR(4));
-        mvprintw(LINES - 3, 0, "Show or Hide a window with 'a'(first window)  'b'(Second Window)  'c'(Third Window)");
-        mvprintw(LINES - 2, 0, "F1 to Exit");
-
-        attroff(COLOR_PAIR(4));
-        doupdate();
-        
-        while((ch = getch()) != KEY_F(1))
-        {       switch(ch)
-                {       case 'a':                       
-                                temp = (PANEL_DATA *)panel_userptr(my_panels[0]);
-                                if(temp-&gt;hide == FALSE)
-                                {       hide_panel(my_panels[0]);
-                                        temp-&gt;hide = TRUE;
-                                }
-                                else
-                                {       show_panel(my_panels[0]);
-                                        temp-&gt;hide = FALSE;
-                                }
-                                break;
-                        case 'b':
-                                temp = (PANEL_DATA *)panel_userptr(my_panels[1]);
-                                if(temp-&gt;hide == FALSE)
-                                {       hide_panel(my_panels[1]);
-                                        temp-&gt;hide = TRUE;
-                                }
-                                else
-                                {       show_panel(my_panels[1]);
-                                        temp-&gt;hide = FALSE;
-                                }
-                                break;
-                        case 'c':
-                                temp = (PANEL_DATA *)panel_userptr(my_panels[2]);
-                                if(temp-&gt;hide == FALSE)
-                                {       hide_panel(my_panels[2]);
-                                        temp-&gt;hide = TRUE;
-                                }
-                                else
-                                {       show_panel(my_panels[2]);
-                                        temp-&gt;hide = FALSE;
-                                }
-                                break;
-                }
-                update_panels();
-                doupdate();
-        }
-        endwin();
-        return 0;
-}
-
-/* Put all the windows */
-void init_wins(WINDOW **wins, int n)
-{       int x, y, i;
-        char label[80];
-
-        y = 2;
-        x = 10;
-        for(i = 0; i &lt; n; ++i)
-        {       wins[i] = newwin(NLINES, NCOLS, y, x);
-                sprintf(label, "Window Number %d", i + 1);
-                win_show(wins[i], label, i + 1);
-                y += 3;
-                x += 7;
-        }
-}
-
-/* Show the window with a border and a label */
-void win_show(WINDOW *win, char *label, int label_color)
-{       int startx, starty, height, width;
-
-        getbegyx(win, starty, startx);
-        getmaxyx(win, height, width);
-
-        box(win, 0, 0);
-        mvwaddch(win, 2, 0, ACS_LTEE); 
-        mvwhline(win, 2, 1, ACS_HLINE, width - 2); 
-        mvwaddch(win, 2, width - 1, ACS_RTEE); 
-        
-        print_in_middle(win, 1, 0, width, label, COLOR_PAIR(label_color));
-}
-
-void print_in_middle(WINDOW *win, int starty, int startx, int width, char *string, chtype color)
-{       int length, x, y;
-        float temp;
-
-        if(win == NULL)
-                win = stdscr;
-        getyx(win, y, x);
-        if(startx != 0)
-                x = startx;
-        if(starty != 0)
-                y = starty;
-        if(width == 0)
-                width = 80;
-
-        length = strlen(string);
-        temp = (width - length)/ 2;
-        x = startx + (int)temp;
-        wattron(win, color);
-        mvwprintw(win, y, x, "%s", string);
-        wattroff(win, color);
-        refresh();
-}</span>
-</pre>
-        </div>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="PANELABOVE" id=
-        "PANELABOVE">16.7. panel_above() and panel_below()
-        Functions</a></h3>
-
-        <p>The functions <tt class="LITERAL">panel_above()</tt> and
-        <tt class="LITERAL">panel_below()</tt> can be used to find
-        out the panel above and below a panel. If the argument to
-        these functions is NULL, then they return a pointer to
-        bottom panel and top panel respectively.</p>
-      </div>
-    </div>
-
-    <div class="SECT1">
-      <hr>
-
-      <h2 class="SECT1"><a name="MENUS" id="MENUS">17. Menus
-      Library</a></h2>
-
-      <p>The menus library provides a nice extension to basic
-      curses, through which you can create menus. It provides a set
-      of functions to create menus. But they have to be customized
-      to give a nicer look, with colors etc. Let's get into the
-      details.</p>
-
-      <p>A menu is a screen display that assists the user to choose
-      some subset of a given set of items. To put it simple, a menu
-      is a collection of items from which one or more items can be
-      chosen. Some readers might not be aware of multiple item
-      selection capability. Menu library provides functionality to
-      write menus from which the user can chose more than one item
-      as the preferred choice. This is dealt with in a later
-      section. Now it is time for some rudiments.</p>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="MENUBASICS" id=
-        "MENUBASICS">17.1. The Basics</a></h3>
-
-        <p>To create menus, you first create items, and then post
-        the menu to the display. After that, all the processing of
-        user responses is done in an elegant function menu_driver()
-        which is the work horse of any menu program.</p>
-
-        <p>The general flow of control of a menu program looks like
-        this.</p>
-
-        <ol type="1">
-          <li>
-            <p>Initialize curses</p>
-          </li>
-
-          <li>
-            <p>Create items using new_item(). You can specify a
-            name and description for the items.</p>
-          </li>
-
-          <li>
-            <p>Create the menu with new_menu() by specifying the
-            items to be attached with.</p>
-          </li>
-
-          <li>
-            <p>Post the menu with menu_post() and refresh the
-            screen.</p>
-          </li>
-
-          <li>
-            <p>Process the user requests with a loop and do
-            necessary updates to menu with menu_driver.</p>
-          </li>
-
-          <li>
-            <p>Unpost the menu with menu_unpost()</p>
-          </li>
-
-          <li>
-            <p>Free the memory allocated to menu by free_menu()</p>
-          </li>
-
-          <li>
-            <p>Free the memory allocated to the items with
-            free_item()</p>
-          </li>
-
-          <li>
-            <p>End curses</p>
-          </li>
-        </ol>
-
-        <p>Let's see a program which prints a simple menu and
-        updates the current selection with up, down arrows.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="COMPILEMENUS" id=
-        "COMPILEMENUS">17.2. Compiling With the Menu
-        Library</a></h3>
-
-        <p>To use menu library functions, you have to include
-        menu.h and to link the program with menu library the flag
-        -lmenu should be added along with -lncurses in that
-        order.</p>
-        <pre class="PROGRAMLISTING">
-    #include &lt;menu.h&gt;
-    .
-    .
-    .
-
-    compile and link: gcc &lt;program file&gt; -lmenu -lncurses
-</pre>
-
-        <div class="EXAMPLE">
-          <a name="MMESI" id="MMESI"></a>
-
-          <p><b>Example 18. Menu Basics</b></p>
-          <pre class="PROGRAMLISTING">
-<span class="INLINEMEDIAOBJECT">#include &lt;curses.h&gt;
-#include &lt;menu.h&gt;
-
-#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
-#define CTRLD   4
-
-char *choices[] = {
-                        "Choice 1",
-                        "Choice 2",
-                        "Choice 3",
-                        "Choice 4",
-                        "Exit",
-                  };
-
-int main()
-{       ITEM **my_items;
-        int c;                          
-        MENU *my_menu;
-        int n_choices, i;
-        ITEM *cur_item;
-        
-        
-        initscr();
-        cbreak();
-        noecho();
-        keypad(stdscr, TRUE);
-        
-        n_choices = ARRAY_SIZE(choices);
-        my_items = (ITEM **)calloc(n_choices + 1, sizeof(ITEM *));
-
-        for(i = 0; i &lt; n_choices; ++i)
-                my_items[i] = new_item(choices[i], choices[i]);
-        my_items[n_choices] = (ITEM *)NULL;
-
-        my_menu = new_menu((ITEM **)my_items);
-        mvprintw(LINES - 2, 0, "F1 to Exit");
-        post_menu(my_menu);
-        refresh();
-
-        while((c = getch()) != KEY_F(1))
-        {   switch(c)
-            {   case KEY_DOWN:
-                        menu_driver(my_menu, REQ_DOWN_ITEM);
-                                break;
-                        case KEY_UP:
-                                menu_driver(my_menu, REQ_UP_ITEM);
-                                break;
-                }
-        }       
-
-        free_item(my_items[0]);
-        free_item(my_items[1]);
-        free_menu(my_menu);
-        endwin();
-}
-        </span>
-</pre>
-        </div>
-
-        <p>This program demonstrates the basic concepts involved in
-        creating a menu using menus library. First we create the
-        items using new_item() and then attach them to the menu
-        with new_menu() function. After posting the menu and
-        refreshing the screen, the main processing loop starts. It
-        reads user input and takes corresponding action. The
-        function menu_driver() is the main work horse of the menu
-        system. The second parameter to this function tells what's
-        to be done with the menu. According to the parameter,
-        menu_driver() does the corresponding task. The value can be
-        either a menu navigational request, an ascii character, or
-        a KEY_MOUSE special key associated with a mouse event.</p>
-
-        <p>The menu_driver accepts following navigational
-        requests.</p>
-        <pre class="PROGRAMLISTING">
-&#13;     REQ_LEFT_ITEM         Move left to an item.
-     REQ_RIGHT_ITEM      Move right to an item.
-     REQ_UP_ITEM         Move up to an item.
-     REQ_DOWN_ITEM       Move down to an item.
-     REQ_SCR_ULINE       Scroll up a line.
-     REQ_SCR_DLINE          Scroll down a line.
-     REQ_SCR_DPAGE          Scroll down a page.
-     REQ_SCR_UPAGE         Scroll up a page.
-     REQ_FIRST_ITEM     Move to the first item.
-     REQ_LAST_ITEM         Move to the last item.
-     REQ_NEXT_ITEM         Move to the next item.
-     REQ_PREV_ITEM         Move to the previous item. 
-     REQ_TOGGLE_ITEM     Select/deselect an item.
-     REQ_CLEAR_PATTERN     Clear the menu pattern buffer.
-     REQ_BACK_PATTERN      Delete the previous character from the pattern buffer.
-     REQ_NEXT_MATCH     Move to the next item matching the pattern match.
-     REQ_PREV_MATCH     Move to the previous item matching the pattern match.&#13;
-</pre>
-
-        <p>Don't get overwhelmed by the number of options. We will
-        see them slowly one after another. The options of interest
-        in this example are REQ_UP_ITEM and REQ_DOWN_ITEM. These
-        two options when passed to menu_driver, menu driver updates
-        the current item to one item up or down respectively.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="MENUDRIVER" id=
-        "MENUDRIVER">17.3. Menu Driver: The work horse of the menu
-        system</a></h3>
-
-        <p>As you have seen in the above example, menu_driver plays
-        an important role in updating the menu. It is very
-        important to understand various options it takes and what
-        they do. As explained above, the second parameter to
-        menu_driver() can be either a navigational request, a
-        printable character or a KEY_MOUSE key. Let's dissect the
-        different navigational requests.</p>
-
-        <ul>
-          <li>
-            <p><span class="emphasis"><i class=
-            "EMPHASIS">REQ_LEFT_ITEM and
-            REQ_RIGHT_ITEM</i></span></p>
-
-            <p>A Menu can be displayed with multiple columns for
-            more than one item. This can be done by using the
-            <tt class="LITERAL">menu_format()</tt>function. When a
-            multi columnar menu is displayed these requests cause
-            the menu driver to move the current selection to left
-            or right.</p>
-          </li>
-
-          <li>
-            <p><span class="emphasis"><i class=
-            "EMPHASIS">REQ_UP_ITEM and REQ_DOWN_ITEM</i></span></p>
-
-            <p>These two options you have seen in the above
-            example. These options when given, makes the
-            menu_driver to move the current selection to an item up
-            or down.</p>
-          </li>
-
-          <li>
-            <p><span class="emphasis"><i class="EMPHASIS">REQ_SCR_*
-            options</i></span></p>
-
-            <p>The four options REQ_SCR_ULINE, REQ_SCR_DLINE,
-            REQ_SCR_DPAGE, REQ_SCR_UPAGE are related to scrolling.
-            If all the items in the menu cannot be displayed in the
-            menu sub window, then the menu is scrollable. These
-            requests can be given to the menu_driver to do the
-            scrolling either one line up, down or one page down or
-            up respectively.</p>
-          </li>
-
-          <li>
-            <p><span class="emphasis"><i class=
-            "EMPHASIS">REQ_FIRST_ITEM, REQ_LAST_ITEM, REQ_NEXT_ITEM
-            and REQ_PREV_ITEM</i></span></p>
-
-            <p>These requests are self explanatory.</p>
-          </li>
-
-          <li>
-            <p><span class="emphasis"><i class=
-            "EMPHASIS">REQ_TOGGLE_ITEM</i></span></p>
-
-            <p>This request when given, toggles the present
-            selection. This option is to be used only in a multi
-            valued menu. So to use this request the option
-            O_ONEVALUE must be off. This option can be made off or
-            on with set_menu_opts().</p>
-          </li>
-
-          <li>
-            <p><span class="emphasis"><i class="EMPHASIS">Pattern
-            Requests</i></span></p>
-
-            <p>Every menu has an associated pattern buffer, which
-            is used to find the nearest match to the ascii
-            characters entered by the user. Whenever ascii
-            characters are given to menu_driver, it puts in to the
-            pattern buffer. It also tries to find the nearest match
-            to the pattern in the items list and moves current
-            selection to that item. The request REQ_CLEAR_PATTERN
-            clears the pattern buffer. The request REQ_BACK_PATTERN
-            deletes the previous character in the pattern buffer.
-            In case the pattern matches more than one item then the
-            matched items can be cycled through REQ_NEXT_MATCH and
-            REQ_PREV_MATCH which move the current selection to the
-            next and previous matches respectively.</p>
-          </li>
-
-          <li>
-            <p><span class="emphasis"><i class="EMPHASIS">Mouse
-            Requests</i></span></p>
-
-            <p>In case of KEY_MOUSE requests, according to the
-            mouse position an action is taken accordingly. The
-            action to be taken is explained in the man page as,</p>
-            <pre class="PROGRAMLISTING">
-<span class="emphasis"><i class=
-"EMPHASIS">       If  the  second argument is the KEY_MOUSE special key, the
-       associated mouse event is translated into one of the above
-       pre-defined  requests.   Currently only clicks in the user
-       window (e.g. inside the menu display area or  the  decora&shy;
-       tion  window)  are handled. If you click above the display
-       region of the menu, a REQ_SCR_ULINE is generated,  if  you
-       doubleclick  a  REQ_SCR_UPAGE  is  generated  and  if  you
-       tripleclick a REQ_FIRST_ITEM is generated.  If  you  click
-       below  the  display region of the menu, a REQ_SCR_DLINE is
-       generated, if you doubleclick a REQ_SCR_DPAGE is generated
-       and  if  you  tripleclick a REQ_LAST_ITEM is generated. If
-       you click at an item inside the display area of the  menu,
-       the menu cursor is positioned to that item.</i></span>
-</pre>
-          </li>
-        </ul>
-
-        <p>Each of the above requests will be explained in the
-        following lines with several examples whenever
-        appropriate.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="MENUWINDOWS" id=
-        "MENUWINDOWS">17.4. Menu Windows</a></h3>
-
-        <p>Every menu created is associated with a window and a sub
-        window. The menu window displays any title or border
-        associated with the menu. The menu sub window displays the
-        menu items currently available for selection. But we didn't
-        specify any window or sub window in the simple example.
-        When a window is not specified, stdscr is taken as the main
-        window, and then menu system calculates the sub window size
-        required for the display of items. Then items are displayed
-        in the calculated sub window. So let's play with these
-        windows and display a menu with a border and a title.</p>
-
-        <div class="EXAMPLE">
-          <a name="MMEWI" id="MMEWI"></a>
-
-          <p><b>Example 19. Menu Windows Usage example</b></p>
-          <pre class="PROGRAMLISTING">
-<span class="INLINEMEDIAOBJECT">#include &lt;menu.h&gt;
-
-#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
-#define CTRLD   4
-
-char *choices[] = {
-                        "Choice 1",
-                        "Choice 2",
-                        "Choice 3",
-                        "Choice 4",
-                        "Exit",
-                        (char *)NULL,
-                  };
-void print_in_middle(WINDOW *win, int starty, int startx, int width, char *string, chtype color);
-
-int main()
-{       ITEM **my_items;
-        int c;                          
-        MENU *my_menu;
-        WINDOW *my_menu_win;
-        int n_choices, i;
-        
-        /* Initialize curses */
-        initscr();
-        start_color();
-        cbreak();
-        noecho();
-        keypad(stdscr, TRUE);
-        init_pair(1, COLOR_RED, COLOR_BLACK);
-
-        /* Create items */
-        n_choices = ARRAY_SIZE(choices);
-        my_items = (ITEM **)calloc(n_choices, sizeof(ITEM *));
-        for(i = 0; i &lt; n_choices; ++i)
-                my_items[i] = new_item(choices[i], choices[i]);
-
-        /* Crate menu */
-        my_menu = new_menu((ITEM **)my_items);
-
-        /* Create the window to be associated with the menu */
-        my_menu_win = newwin(10, 40, 4, 4);
-        keypad(my_menu_win, TRUE);
-     
-        /* Set main window and sub window */
-        set_menu_win(my_menu, my_menu_win);
-        set_menu_sub(my_menu, derwin(my_menu_win, 6, 38, 3, 1));
-
-        /* Set menu mark to the string " * " */
-        set_menu_mark(my_menu, " * ");
-
-        /* Print a border around the main window and print a title */
-        box(my_menu_win, 0, 0);
-        print_in_middle(my_menu_win, 1, 0, 40, "My Menu", COLOR_PAIR(1));
-        mvwaddch(my_menu_win, 2, 0, ACS_LTEE);
-        mvwhline(my_menu_win, 2, 1, ACS_HLINE, 38);
-        mvwaddch(my_menu_win, 2, 39, ACS_RTEE);
-        mvprintw(LINES - 2, 0, "F1 to exit");
-        refresh();
-        
-        /* Post the menu */
-        post_menu(my_menu);
-        wrefresh(my_menu_win);
-
-        while((c = wgetch(my_menu_win)) != KEY_F(1))
-        {       switch(c)
-                {       case KEY_DOWN:
-                                menu_driver(my_menu, REQ_DOWN_ITEM);
-                                break;
-                        case KEY_UP:
-                                menu_driver(my_menu, REQ_UP_ITEM);
-                                break;
-                }
-                wrefresh(my_menu_win);
-        }       
-
-        /* Unpost and free all the memory taken up */
-        unpost_menu(my_menu);
-        free_menu(my_menu);
-        for(i = 0; i &lt; n_choices; ++i)
-                free_item(my_items[i]);
-        endwin();
-}
-
-void print_in_middle(WINDOW *win, int starty, int startx, int width, char *string, chtype color)
-{       int length, x, y;
-        float temp;
-
-        if(win == NULL)
-                win = stdscr;
-        getyx(win, y, x);
-        if(startx != 0)
-                x = startx;
-        if(starty != 0)
-                y = starty;
-        if(width == 0)
-                width = 80;
-
-        length = strlen(string);
-        temp = (width - length)/ 2;
-        x = startx + (int)temp;
-        wattron(win, color);
-        mvwprintw(win, y, x, "%s", string);
-        wattroff(win, color);
-        refresh();
-}</span>
-</pre>
-        </div>
-
-        <p>This example creates a menu with a title, border, a
-        fancy line separating title and the items. As you can see,
-        in order to attach a window to a menu the function
-        set_menu_win() has to be used. Then we attach the sub
-        window also. This displays the items in the sub window. You
-        can also set the mark string which gets displayed to the
-        left of the selected item with set_menu_mark().</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="SCROLLMENUS" id=
-        "SCROLLMENUS">17.5. Scrolling Menus</a></h3>
-
-        <p>If the sub window given for a window is not big enough
-        to show all the items, then the menu will be scrollable.
-        When you are on the last item in the present list, if you
-        send REQ_DOWN_ITEM, it gets translated into REQ_SCR_DLINE
-        and the menu scrolls by one item. You can manually give
-        REQ_SCR_ operations to do scrolling. Let's see how it can
-        be done.</p>
-
-        <div class="EXAMPLE">
-          <a name="MMESC" id="MMESC"></a>
-
-          <p><b>Example 20. Scrolling Menus example</b></p>
-          <pre class="PROGRAMLISTING">
-<span class="INLINEMEDIAOBJECT">#include &lt;curses.h&gt;
-#include &lt;menu.h&gt;
-
-#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
-#define CTRLD   4
-
-char *choices[] = {
-                        "Choice 1",
-                        "Choice 2",
-                        "Choice 3",
-                        "Choice 4",
-                        "Choice 5",
-                        "Choice 6",
-                        "Choice 7",
-                        "Choice 8",
-                        "Choice 9",
-                        "Choice 10",
-                        "Exit",
-                        (char *)NULL,
-                  };
-void print_in_middle(WINDOW *win, int starty, int startx, int width, char *string, chtype color);
-
-int main()
-{       ITEM **my_items;
-        int c;                          
-        MENU *my_menu;
-        WINDOW *my_menu_win;
-        int n_choices, i;
-        
-        /* Initialize curses */
-        initscr();
-        start_color();
-        cbreak();
-        noecho();
-        keypad(stdscr, TRUE);
-        init_pair(1, COLOR_RED, COLOR_BLACK);
-        init_pair(2, COLOR_CYAN, COLOR_BLACK);
-
-        /* Create items */
-        n_choices = ARRAY_SIZE(choices);
-        my_items = (ITEM **)calloc(n_choices, sizeof(ITEM *));
-        for(i = 0; i &lt; n_choices; ++i)
-                my_items[i] = new_item(choices[i], choices[i]);
-
-        /* Crate menu */
-        my_menu = new_menu((ITEM **)my_items);
-
-        /* Create the window to be associated with the menu */
-        my_menu_win = newwin(10, 40, 4, 4);
-        keypad(my_menu_win, TRUE);
-     
-        /* Set main window and sub window */
-        set_menu_win(my_menu, my_menu_win);
-        set_menu_sub(my_menu, derwin(my_menu_win, 6, 38, 3, 1));
-        set_menu_format(my_menu, 5, 1);
-                        
-        /* Set menu mark to the string " * " */
-        set_menu_mark(my_menu, " * ");
-
-        /* Print a border around the main window and print a title */
-        box(my_menu_win, 0, 0);
-        print_in_middle(my_menu_win, 1, 0, 40, "My Menu", COLOR_PAIR(1));
-        mvwaddch(my_menu_win, 2, 0, ACS_LTEE);
-        mvwhline(my_menu_win, 2, 1, ACS_HLINE, 38);
-        mvwaddch(my_menu_win, 2, 39, ACS_RTEE);
-        
-        /* Post the menu */
-        post_menu(my_menu);
-        wrefresh(my_menu_win);
-        
-        attron(COLOR_PAIR(2));
-        mvprintw(LINES - 2, 0, "Use PageUp and PageDown to scoll down or up a page of items");
-        mvprintw(LINES - 1, 0, "Arrow Keys to navigate (F1 to Exit)");
-        attroff(COLOR_PAIR(2));
-        refresh();
-
-        while((c = wgetch(my_menu_win)) != KEY_F(1))
-        {       switch(c)
-                {       case KEY_DOWN:
-                                menu_driver(my_menu, REQ_DOWN_ITEM);
-                                break;
-                        case KEY_UP:
-                                menu_driver(my_menu, REQ_UP_ITEM);
-                                break;
-                        case KEY_NPAGE:
-                                menu_driver(my_menu, REQ_SCR_DPAGE);
-                                break;
-                        case KEY_PPAGE:
-                                menu_driver(my_menu, REQ_SCR_UPAGE);
-                                break;
-                }
-                wrefresh(my_menu_win);
-        }       
-
-        /* Unpost and free all the memory taken up */
-        unpost_menu(my_menu);
-        free_menu(my_menu);
-        for(i = 0; i &lt; n_choices; ++i)
-                free_item(my_items[i]);
-        endwin();
-}
-
-void print_in_middle(WINDOW *win, int starty, int startx, int width, char *string, chtype color)
-{       int length, x, y;
-        float temp;
-
-        if(win == NULL)
-                win = stdscr;
-        getyx(win, y, x);
-        if(startx != 0)
-                x = startx;
-        if(starty != 0)
-                y = starty;
-        if(width == 0)
-                width = 80;
-
-        length = strlen(string);
-        temp = (width - length)/ 2;
-        x = startx + (int)temp;
-        wattron(win, color);
-        mvwprintw(win, y, x, "%s", string);
-        wattroff(win, color);
-        refresh();
-}</span>
-</pre>
-        </div>
-
-        <p>This program is self-explanatory. In this example the
-        number of choices has been increased to ten, which is
-        larger than our sub window size which can hold 6 items.
-        This message has to be explicitly conveyed to the menu
-        system with the function set_menu_format(). In here we
-        specify the number of rows and columns we want to be
-        displayed for a single page. We can specify any number of
-        items to be shown, in the rows variables, if it is less
-        than the height of the sub window. If the key pressed by
-        the user is a PAGE UP or PAGE DOWN, the menu is scrolled a
-        page due to the requests (REQ_SCR_DPAGE and REQ_SCR_UPAGE)
-        given to menu_driver().</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="MULTICOLUMN" id=
-        "MULTICOLUMN">17.6. Multi Columnar Menus</a></h3>
-
-        <p>In the above example you have seen how to use the
-        function set_menu_format(). I didn't mention what the cols
-        variable (third parameter) does. Well, If your sub window
-        is wide enough, you can opt to display more than one item
-        per row. This can be specified in the cols variable. To
-        make things simpler, the following example doesn't show
-        descriptions for the items.</p>
-
-        <div class="EXAMPLE">
-          <a name="MMEMUCO" id="MMEMUCO"></a>
-
-          <p><b>Example 21. Milt Columnar Menus Example</b></p>
-          <pre class="PROGRAMLISTING">
-<span class="INLINEMEDIAOBJECT">#include &lt;curses.h&gt;
-#include &lt;menu.h&gt;
-
-#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
-#define CTRLD   4
-
-char *choices[] = {
-                        "Choice 1", "Choice 2", "Choice 3", "Choice 4", "Choice 5",
-                        "Choice 6", "Choice 7", "Choice 8", "Choice 9", "Choice 10",
-                        "Choice 11", "Choice 12", "Choice 13", "Choice 14", "Choice 15",
-                        "Choice 16", "Choice 17", "Choice 18", "Choice 19", "Choice 20",
-                        "Exit",
-                        (char *)NULL,
-                  };
-
-int main()
-{       ITEM **my_items;
-        int c;                          
-        MENU *my_menu;
-        WINDOW *my_menu_win;
-        int n_choices, i;
-        
-        /* Initialize curses */
-        initscr();
-        start_color();
-        cbreak();
-        noecho();
-        keypad(stdscr, TRUE);
-        init_pair(1, COLOR_RED, COLOR_BLACK);
-        init_pair(2, COLOR_CYAN, COLOR_BLACK);
-
-        /* Create items */
-        n_choices = ARRAY_SIZE(choices);
-        my_items = (ITEM **)calloc(n_choices, sizeof(ITEM *));
-        for(i = 0; i &lt; n_choices; ++i)
-                my_items[i] = new_item(choices[i], choices[i]);
-
-        /* Crate menu */
-        my_menu = new_menu((ITEM **)my_items);
-
-        /* Set menu option not to show the description */
-        menu_opts_off(my_menu, O_SHOWDESC);
-
-        /* Create the window to be associated with the menu */
-        my_menu_win = newwin(10, 70, 4, 4);
-        keypad(my_menu_win, TRUE);
-     
-        /* Set main window and sub window */
-        set_menu_win(my_menu, my_menu_win);
-        set_menu_sub(my_menu, derwin(my_menu_win, 6, 68, 3, 1));
-        set_menu_format(my_menu, 5, 3);
-        set_menu_mark(my_menu, " * ");
-
-        /* Print a border around the main window and print a title */
-        box(my_menu_win, 0, 0);
-        
-        attron(COLOR_PAIR(2));
-        mvprintw(LINES - 3, 0, "Use PageUp and PageDown to scroll");
-        mvprintw(LINES - 2, 0, "Use Arrow Keys to navigate (F1 to Exit)");
-        attroff(COLOR_PAIR(2));
-        refresh();
-
-        /* Post the menu */
-        post_menu(my_menu);
-        wrefresh(my_menu_win);
-        
-        while((c = wgetch(my_menu_win)) != KEY_F(1))
-        {       switch(c)
-                {       case KEY_DOWN:
-                                menu_driver(my_menu, REQ_DOWN_ITEM);
-                                break;
-                        case KEY_UP:
-                                menu_driver(my_menu, REQ_UP_ITEM);
-                                break;
-                        case KEY_LEFT:
-                                menu_driver(my_menu, REQ_LEFT_ITEM);
-                                break;
-                        case KEY_RIGHT:
-                                menu_driver(my_menu, REQ_RIGHT_ITEM);
-                                break;
-                        case KEY_NPAGE:
-                                menu_driver(my_menu, REQ_SCR_DPAGE);
-                                break;
-                        case KEY_PPAGE:
-                                menu_driver(my_menu, REQ_SCR_UPAGE);
-                                break;
-                }
-                wrefresh(my_menu_win);
-        }       
-
-        /* Unpost and free all the memory taken up */
-        unpost_menu(my_menu);
-        free_menu(my_menu);
-        for(i = 0; i &lt; n_choices; ++i)
-                free_item(my_items[i]);
-        endwin();
-}</span>
-</pre>
-        </div>
-
-        <p>Watch the function call to set_menu_format(). It
-        specifies the number of columns to be 3, thus displaying 3
-        items per row. We have also switched off the showing
-        descriptions with the function menu_opts_off(). There are
-        couple of functions set_menu_opts(), menu_opts_on() and
-        menu_opts() which can be used to manipulate menu options.
-        The following menu options can be specified.</p>
-        <pre class="PROGRAMLISTING">
-       O_ONEVALUE
-            Only one item can be selected for this menu.
-
-       O_SHOWDESC
-            Display  the  item  descriptions  when  the  menu  is
-            posted.
-
-       O_ROWMAJOR
-            Display the menu in row-major order.
-
-       O_IGNORECASE
-            Ignore the case when pattern-matching.
-
-       O_SHOWMATCH
-            Move the cursor to within the item  name  while  pat&shy;
-            tern-matching.
-
-       O_NONCYCLIC
-            Don't   wrap   around  next-item  and  previous-item,
-            requests to the other end of the menu.
-</pre>
-
-        <p>All options are on by default. You can switch specific
-        attributes on or off with menu_opts_on() and
-        menu_opts_off() functions. You can also use set_menu_opts()
-        to directly specify the options. The argument to this
-        function should be a OR ed value of some of those above
-        constants. The function menu_opts() can be used to find out
-        a menu's present options.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="MULTIVALUEMENUS" id=
-        "MULTIVALUEMENUS">17.7. Multi Valued Menus</a></h3>
-
-        <p>You might be wondering what if you switch off the option
-        O_ONEVALUE. Then the menu becomes multi-valued. That means
-        you can select more than one item. This brings us to the
-        request REQ_TOGGLE_ITEM. Let's see it in action.</p>
-
-        <div class="EXAMPLE">
-          <a name="MMETO" id="MMETO"></a>
-
-          <p><b>Example 22. Multi Valued Menus example</b></p>
-          <pre class="PROGRAMLISTING">
-<span class="INLINEMEDIAOBJECT">#include &lt;curses.h&gt;
-#include &lt;menu.h&gt;
-
-#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
-#define CTRLD   4
-
-char *choices[] = {
-                        "Choice 1",
-                        "Choice 2",
-                        "Choice 3",
-                        "Choice 4",
-                        "Choice 5",
-                        "Choice 6",
-                        "Choice 7",
-                        "Exit",
-                  };
-
-int main()
-{       ITEM **my_items;
-        int c;                          
-        MENU *my_menu;
-        int n_choices, i;
-        ITEM *cur_item;
-        
-        /* Initialize curses */ 
-        initscr();
-        cbreak();
-        noecho();
-        keypad(stdscr, TRUE);
-
-        /* Initialize items */
-        n_choices = ARRAY_SIZE(choices);
-        my_items = (ITEM **)calloc(n_choices + 1, sizeof(ITEM *));
-        for(i = 0; i &lt; n_choices; ++i)
-                my_items[i] = new_item(choices[i], choices[i]);
-        my_items[n_choices] = (ITEM *)NULL;
-
-        my_menu = new_menu((ITEM **)my_items);
-
-        /* Make the menu multi valued */
-        menu_opts_off(my_menu, O_ONEVALUE);
-
-        mvprintw(LINES - 3, 0, "Use &lt;SPACE&gt; to select or unselect an item.");
-        mvprintw(LINES - 2, 0, "&lt;ENTER&gt; to see presently selected items(F1 to Exit)");
-        post_menu(my_menu);
-        refresh();
-
-        while((c = getch()) != KEY_F(1))
-        {       switch(c)
-                {       case KEY_DOWN:
-                                menu_driver(my_menu, REQ_DOWN_ITEM);
-                                break;
-                        case KEY_UP:
-                                menu_driver(my_menu, REQ_UP_ITEM);
-                                break;
-                        case ' ':
-                                menu_driver(my_menu, REQ_TOGGLE_ITEM);
-                                break;
-                        case 10:        /* Enter */
-                        {       char temp[200];
-                                ITEM **items;
-
-                                items = menu_items(my_menu);
-                                temp[0] = '\0';
-                                for(i = 0; i &lt; item_count(my_menu); ++i)
-                                        if(item_value(items[i]) == TRUE)
-                                        {       strcat(temp, item_name(items[i]));
-                                                strcat(temp, " ");
-                                        }
-                                move(20, 0);
-                                clrtoeol();
-                                mvprintw(20, 0, temp);
-                                refresh();
-                        }
-                        break;
-                }
-        }       
-
-        free_item(my_items[0]);
-        free_item(my_items[1]);
-        free_menu(my_menu);
-        endwin();
-}
-        </span>
-</pre>
-        </div>
-
-        <p>Whew, A lot of new functions. Let's take them one after
-        another. Firstly, the REQ_TOGGLE_ITEM. In a multi-valued
-        menu, the user should be allowed to select or un select
-        more than one item. The request REQ_TOGGLE_ITEM toggles the
-        present selection. In this case when space is pressed
-        REQ_TOGGLE_ITEM request is sent to menu_driver to achieve
-        the result.</p>
-
-        <p>Now when the user presses &lt;ENTER&gt; we show the
-        items he presently selected. First we find out the items
-        associated with the menu using the function menu_items().
-        Then we loop through the items to find out if the item is
-        selected or not. The function item_value() returns TRUE if
-        an item is selected. The function item_count() returns the
-        number of items in the menu. The item name can be found
-        with item_name(). You can also find the description
-        associated with an item using item_description().</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="MENUOPT" id="MENUOPT">17.8. Menu
-        Options</a></h3>
-
-        <p>Well, by this time you must be itching for some
-        difference in your menu, with lots of functionality. I
-        know. You want Colors !!!. You want to create nice menus
-        similar to those text mode <a href=
-        "http://www.jersey.net/~debinjoe/games/" target="_top">dos
-        games</a>. The functions set_menu_fore() and
-        set_menu_back() can be used to change the attribute of the
-        selected item and unselected item. The names are
-        misleading. They don't change menu's foreground or
-        background which would have been useless.</p>
-
-        <p>The function set_menu_grey() can be used to set the
-        display attribute for the non-selectable items in the menu.
-        This brings us to the interesting option for an item the
-        one and only O_SELECTABLE. We can turn it off by the
-        function item_opts_off() and after that that item is not
-        selectable. It's like a grayed item in those fancy windows
-        menus. Let's put these concepts in practice with this
-        example</p>
-
-        <div class="EXAMPLE">
-          <a name="MMEAT" id="MMEAT"></a>
-
-          <p><b>Example 23. Menu Options example</b></p>
-          <pre class="PROGRAMLISTING">
-<span class="INLINEMEDIAOBJECT">#include &lt;menu.h&gt;
-
-#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
-#define CTRLD   4
-
-char *choices[] = {
-                        "Choice 1",
-                        "Choice 2",
-                        "Choice 3",
-                        "Choice 4",
-                        "Choice 5",
-                        "Choice 6",
-                        "Choice 7",
-                        "Exit",
-                  };
-
-int main()
-{       ITEM **my_items;
-        int c;                          
-        MENU *my_menu;
-        int n_choices, i;
-        ITEM *cur_item;
-        
-        /* Initialize curses */ 
-        initscr();
-        start_color();
-        cbreak();
-        noecho();
-        keypad(stdscr, TRUE);
-        init_pair(1, COLOR_RED, COLOR_BLACK);
-        init_pair(2, COLOR_GREEN, COLOR_BLACK);
-        init_pair(3, COLOR_MAGENTA, COLOR_BLACK);
-
-        /* Initialize items */
-        n_choices = ARRAY_SIZE(choices);
-        my_items = (ITEM **)calloc(n_choices + 1, sizeof(ITEM *));
-        for(i = 0; i &lt; n_choices; ++i)
-                my_items[i] = new_item(choices[i], choices[i]);
-        my_items[n_choices] = (ITEM *)NULL;
-        item_opts_off(my_items[3], O_SELECTABLE);
-        item_opts_off(my_items[6], O_SELECTABLE);
-
-        /* Create menu */
-        my_menu = new_menu((ITEM **)my_items);
-
-        /* Set fore ground and back ground of the menu */
-        set_menu_fore(my_menu, COLOR_PAIR(1) | A_REVERSE);
-        set_menu_back(my_menu, COLOR_PAIR(2));
-        set_menu_grey(my_menu, COLOR_PAIR(3));
-
-        /* Post the menu */
-        mvprintw(LINES - 3, 0, "Press &lt;ENTER&gt; to see the option selected");
-        mvprintw(LINES - 2, 0, "Up and Down arrow keys to naviage (F1 to Exit)");
-        post_menu(my_menu);
-        refresh();
-
-        while((c = getch()) != KEY_F(1))
-        {       switch(c)
-                {       case KEY_DOWN:
-                                menu_driver(my_menu, REQ_DOWN_ITEM);
-                                break;
-                        case KEY_UP:
-                                menu_driver(my_menu, REQ_UP_ITEM);
-                                break;
-                        case 10: /* Enter */
-                                move(20, 0);
-                                clrtoeol();
-                                mvprintw(20, 0, "Item selected is : %s", 
-                                                item_name(current_item(my_menu)));
-                                pos_menu_cursor(my_menu);
-                                break;
-                }
-        }       
-        unpost_menu(my_menu);
-        for(i = 0; i &lt; n_choices; ++i)
-                free_item(my_items[i]);
-        free_menu(my_menu);
-        endwin();
-}
-        </span>
-</pre>
-        </div>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="MENUUSERPTR" id=
-        "MENUUSERPTR">17.9. The useful User Pointer</a></h3>
-
-        <p>We can associate a user pointer with each item in the
-        menu. It works the same way as user pointer in panels. It's
-        not touched by menu system. You can store any thing you
-        like in that. I usually use it to store the function to be
-        executed when the menu option is chosen (It's selected and
-        may be the user pressed &lt;ENTER&gt;);</p>
-
-        <div class="EXAMPLE">
-          <a name="MMEUS" id="MMEUS"></a>
-
-          <p><b>Example 24. Menu User Pointer Usage</b></p>
-          <pre class="PROGRAMLISTING">
-<span class="INLINEMEDIAOBJECT">#include &lt;curses.h&gt;
-#include &lt;menu.h&gt;
-
-#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
-#define CTRLD   4
-
-char *choices[] = {
-                        "Choice 1",
-                        "Choice 2",
-                        "Choice 3",
-                        "Choice 4",
-                        "Choice 5",
-                        "Choice 6",
-                        "Choice 7",
-                        "Exit",
-                  };
-void func(char *name);
-
-int main()
-{       ITEM **my_items;
-        int c;                          
-        MENU *my_menu;
-        int n_choices, i;
-        ITEM *cur_item;
-        
-        /* Initialize curses */ 
-        initscr();
-        start_color();
-        cbreak();
-        noecho();
-        keypad(stdscr, TRUE);
-        init_pair(1, COLOR_RED, COLOR_BLACK);
-        init_pair(2, COLOR_GREEN, COLOR_BLACK);
-        init_pair(3, COLOR_MAGENTA, COLOR_BLACK);
-
-        /* Initialize items */
-        n_choices = ARRAY_SIZE(choices);
-        my_items = (ITEM **)calloc(n_choices + 1, sizeof(ITEM *));
-        for(i = 0; i &lt; n_choices; ++i)
-        {       my_items[i] = new_item(choices[i], choices[i]);
-                /* Set the user pointer */
-                set_item_userptr(my_items[i], func);
-        }
-        my_items[n_choices] = (ITEM *)NULL;
-
-        /* Create menu */
-        my_menu = new_menu((ITEM **)my_items);
-
-        /* Post the menu */
-        mvprintw(LINES - 3, 0, "Press &lt;ENTER&gt; to see the option selected");
-        mvprintw(LINES - 2, 0, "Up and Down arrow keys to naviage (F1 to Exit)");
-        post_menu(my_menu);
-        refresh();
-
-        while((c = getch()) != KEY_F(1))
-        {       switch(c)
-                {       case KEY_DOWN:
-                                menu_driver(my_menu, REQ_DOWN_ITEM);
-                                break;
-                        case KEY_UP:
-                                menu_driver(my_menu, REQ_UP_ITEM);
-                                break;
-                        case 10: /* Enter */
-                        {       ITEM *cur;
-                                void (*p)(char *);
-
-                                cur = current_item(my_menu);
-                                p = item_userptr(cur);
-                                p((char *)item_name(cur));
-                                pos_menu_cursor(my_menu);
-                                break;
-                        }
-                        break;
-                }
-        }       
-        unpost_menu(my_menu);
-        for(i = 0; i &lt; n_choices; ++i)
-                free_item(my_items[i]);
-        free_menu(my_menu);
-        endwin();
-}
-
-void func(char *name)
-{       move(20, 0);
-        clrtoeol();
-        mvprintw(20, 0, "Item selected is : %s", name);
-}       </span>
-</pre>
-        </div>
-      </div>
-    </div>
-
-    <div class="SECT1">
-      <hr>
-
-      <h2 class="SECT1"><a name="FORMS" id="FORMS">18. Forms
-      Library</a></h2>
-
-      <p>Well. If you have seen those forms on web pages which take
-      input from users and do various kinds of things, you might be
-      wondering how would any one create such forms in text mode
-      display. It's quite difficult to write those nifty forms in
-      plain ncurses. Forms library tries to provide a basic frame
-      work to build and maintain forms with ease. It has lot of
-      features(functions) which manage validation, dynamic
-      expansion of fields etc.. Let's see it in full flow.</p>
-
-      <p>A form is a collection of fields; each field can be either
-      a label(static text) or a data-entry location. The forms also
-      library provides functions to divide forms into multiple
-      pages.</p>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="FORMBASICS" id=
-        "FORMBASICS">18.1. The Basics</a></h3>
-
-        <p>Forms are created in much the same way as menus. First
-        the fields related to the form are created with
-        new_field(). You can set options for the fields, so that
-        they can be displayed with some fancy attributes, validated
-        before the field looses focus etc.. Then the fields are
-        attached to form. After this, the form can be posted to
-        display and is ready to receive inputs. On the similar
-        lines to menu_driver(), the form is manipulated with
-        form_driver(). We can send requests to form_driver to move
-        focus to a certain field, move cursor to end of the field
-        etc.. After the user enters values in the fields and
-        validation done, form can be unposted and memory allocated
-        can be freed.</p>
-
-        <p>The general flow of control of a forms program looks
-        like this.</p>
-
-        <ol type="1">
-          <li>
-            <p>Initialize curses</p>
-          </li>
-
-          <li>
-            <p>Create fields using new_field(). You can specify the
-            height and width of the field, and its position on the
-            form.</p>
-          </li>
-
-          <li>
-            <p>Create the forms with new_form() by specifying the
-            fields to be attached with.</p>
-          </li>
-
-          <li>
-            <p>Post the form with form_post() and refresh the
-            screen.</p>
-          </li>
-
-          <li>
-            <p>Process the user requests with a loop and do
-            necessary updates to form with form_driver.</p>
-          </li>
-
-          <li>
-            <p>Unpost the menu with form_unpost()</p>
-          </li>
-
-          <li>
-            <p>Free the memory allocated to menu by free_form()</p>
-          </li>
-
-          <li>
-            <p>Free the memory allocated to the items with
-            free_field()</p>
-          </li>
-
-          <li>
-            <p>End curses</p>
-          </li>
-        </ol>
-
-        <p>As you can see, working with forms library is much
-        similar to handling menu library. The following examples
-        will explore various aspects of form processing. Let's
-        start the journey with a simple example. first.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="COMPILEFORMS" id=
-        "COMPILEFORMS">18.2. Compiling With the Forms
-        Library</a></h3>
-
-        <p>To use forms library functions, you have to include
-        form.h and to link the program with forms library the flag
-        -lform should be added along with -lncurses in that
-        order.</p>
-        <pre class="PROGRAMLISTING">
-    #include &lt;form.h&gt;
-    .
-    .
-    .
-
-    compile and link: gcc &lt;program file&gt; -lform -lncurses
-</pre>
-
-        <div class="EXAMPLE">
-          <a name="FFOSI" id="FFOSI"></a>
-
-          <p><b>Example 25. Forms Basics</b></p>
-          <pre class="PROGRAMLISTING">
-<span class="INLINEMEDIAOBJECT">#include &lt;form.h&gt;
-
-int main()
-{       FIELD *field[3];
-        FORM  *my_form;
-        int ch;
-        
-        /* Initialize curses */
-        initscr();
-        cbreak();
-        noecho();
-        keypad(stdscr, TRUE);
-
-        /* Initialize the fields */
-        field[0] = new_field(1, 10, 4, 18, 0, 0);
-        field[1] = new_field(1, 10, 6, 18, 0, 0);
-        field[2] = NULL;
-
-        /* Set field options */
-        set_field_back(field[0], A_UNDERLINE);  /* Print a line for the option  */
-        field_opts_off(field[0], O_AUTOSKIP);   /* Don't go to next field when this */
-                                                /* Field is filled up           */
-        set_field_back(field[1], A_UNDERLINE); 
-        field_opts_off(field[1], O_AUTOSKIP);
-
-        /* Create the form and post it */
-        my_form = new_form(field);
-        post_form(my_form);
-        refresh();
-        
-        mvprintw(4, 10, "Value 1:");
-        mvprintw(6, 10, "Value 2:");
-        refresh();
-
-        /* Loop through to get user requests */
-        while((ch = getch()) != KEY_F(1))
-        {       switch(ch)
-                {       case KEY_DOWN:
-                                /* Go to next field */
-                                form_driver(my_form, REQ_NEXT_FIELD);
-                                /* Go to the end of the present buffer */
-                                /* Leaves nicely at the last character */
-                                form_driver(my_form, REQ_END_LINE);
-                                break;
-                        case KEY_UP:
-                                /* Go to previous field */
-                                form_driver(my_form, REQ_PREV_FIELD);
-                                form_driver(my_form, REQ_END_LINE);
-                                break;
-                        default:
-                                /* If this is a normal character, it gets */
-                                /* Printed                                */    
-                                form_driver(my_form, ch);
-                                break;
-                }
-        }
-
-        /* Un post form and free the memory */
-        unpost_form(my_form);
-        free_form(my_form);
-        free_field(field[0]);
-        free_field(field[1]); 
-
-        endwin();
-        return 0;
-}</span>
-</pre>
-        </div>
-
-        <p>Above example is pretty straight forward. It creates two
-        fields with <tt class="LITERAL">new_field()</tt>.
-        new_field() takes height, width, starty, startx, number of
-        offscreen rows and number of additional working buffers.
-        The fifth argument number of offscreen rows specifies how
-        much of the field to be shown. If it is zero, the entire
-        field is always displayed otherwise the form will be
-        scrollable when the user accesses not displayed parts of
-        the field. The forms library allocates one buffer per field
-        to store the data user enters. Using the last parameter to
-        new_field() we can specify it to allocate some additional
-        buffers. These can be used for any purpose you like.</p>
-
-        <p>After creating the fields, back ground attribute of both
-        of them is set to an underscore with set_field_back(). The
-        AUTOSKIP option is turned off using field_opts_off(). If
-        this option is turned on, focus will move to the next field
-        in the form once the active field is filled up
-        completely.</p>
-
-        <p>After attaching the fields to the form, it is posted.
-        Here on, user inputs are processed in the while loop, by
-        making corresponding requests to form_driver. The details
-        of all the requests to the form_driver() are explained
-        later.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="PLAYFIELDS" id=
-        "PLAYFIELDS">18.3. Playing with Fields</a></h3>
-
-        <p>Each form field is associated with a lot of attributes.
-        They can be manipulated to get the required effect and to
-        have fun !!!. So why wait?</p>
-
-        <div class="SECT3">
-          <hr>
-
-          <h4 class="SECT3"><a name="FETCHINFO" id=
-          "FETCHINFO">18.3.1. Fetching Size and Location of
-          Field</a></h4>
-
-          <p>The parameters we have given at the time of creation
-          of a field can be retrieved with field_info(). It returns
-          height, width, starty, startx, number of offscreen rows,
-          and number of additional buffers into the parameters
-          given to it. It is a sort of inverse of new_field().</p>
-          <pre class="PROGRAMLISTING">
-int field_info(     FIELD *field,              /* field from which to fetch */
-                    int *height, *int width,   /* field size */ 
-                    int *top, int *left,       /* upper left corner */
-                    int *offscreen,            /* number of offscreen rows */
-                    int *nbuf);                /* number of working buffers */
-</pre>
-        </div>
-
-        <div class="SECT3">
-          <hr>
-
-          <h4 class="SECT3"><a name="MOVEFIELD" id=
-          "MOVEFIELD">18.3.2. Moving the field</a></h4>
-
-          <p>The location of the field can be moved to a different
-          position with move_field().</p>
-          <pre class="PROGRAMLISTING">
-int move_field(    FIELD *field,              /* field to alter */
-                   int top, int left);        /* new upper-left corner */
-</pre>
-
-          <p>As usual, the changed position can be queried with
-          field_infor().</p>
-        </div>
-
-        <div class="SECT3">
-          <hr>
-
-          <h4 class="SECT3"><a name="JUSTIFYFIELD" id=
-          "JUSTIFYFIELD">18.3.3. Field Justification</a></h4>
-
-          <p>The justification to be done for the field can be
-          fixed using the function set_field_just().</p>
-          <pre class="PROGRAMLISTING">
-    int set_field_just(FIELD *field,          /* field to alter */
-               int justmode);         /* mode to set */
-    int field_just(FIELD *field);          /* fetch justify mode of field */
-</pre>
-
-          <p>The justification mode valued accepted and returned by
-          these functions are NO_JUSTIFICATION, JUSTIFY_RIGHT,
-          JUSTIFY_LEFT, or JUSTIFY_CENTER.</p>
-        </div>
-
-        <div class="SECT3">
-          <hr>
-
-          <h4 class="SECT3"><a name="FIELDDISPATTRIB" id=
-          "FIELDDISPATTRIB">18.3.4. Field Display
-          Attributes</a></h4>
-
-          <p>As you have seen, in the above example, display
-          attribute for the fields can be set with set_field_fore()
-          and setfield_back(). These functions set foreground and
-          background attribute of the fields. You can also specify
-          a pad character which will be filled in the unfilled
-          portion of the field. The pad character is set with a
-          call to set_field_pad(). Default pad value is a space.
-          The functions field_fore(), field_back, field_pad() can
-          be used to query the present foreground, background
-          attributes and pad character for the field. The following
-          list gives the usage of functions.</p>
-          <pre class="PROGRAMLISTING">
-&#13;int set_field_fore(FIELD *field,        /* field to alter */
-                   chtype attr);        /* attribute to set */ 
-
-chtype field_fore(FIELD *field);        /* field to query */
-                                        /* returns foreground attribute */
-
-int set_field_back(FIELD *field,        /* field to alter */
-                   chtype attr);        /* attribute to set */ 
-
-chtype field_back(FIELD *field);        /* field to query */
-                                        /* returns background attribute */
-
-int set_field_pad(FIELD *field,         /* field to alter */
-                  int pad);             /* pad character to set */ 
-
-chtype field_pad(FIELD *field);         /* field to query */  
-                                        /* returns present pad character */&#13;
-</pre>
-
-          <p>Though above functions seem quite simple, using colors
-          with set_field_fore() may be frustrating in the
-          beginning. Let me first explain about foreground and
-          background attributes of a field. The foreground
-          attribute is associated with the character. That means a
-          character in the field is printed with the attribute you
-          have set with set_field_fore(). Background attribute is
-          the attribute used to fill background of field, whether
-          any character is there or not. So what about colors?
-          Since colors are always defined in pairs, what is the
-          right way to display colored fields? Here's an example
-          clarifying color attributes.</p>
-
-          <div class="EXAMPLE">
-            <a name="FFOAT" id="FFOAT"></a>
-
-            <p><b>Example 26. Form Attributes example</b></p>
-            <pre class="PROGRAMLISTING">
-<span class="INLINEMEDIAOBJECT">#include &lt;form.h&gt;
-
-int main()
-{       FIELD *field[3];
-        FORM  *my_form;
-        int ch;
-        
-        /* Initialize curses */
-        initscr();
-        start_color();
-        cbreak();
-        noecho();
-        keypad(stdscr, TRUE);
-
-        /* Initialize few color pairs */
-        init_pair(1, COLOR_WHITE, COLOR_BLUE);
-        init_pair(2, COLOR_WHITE, COLOR_BLUE);
-
-        /* Initialize the fields */
-        field[0] = new_field(1, 10, 4, 18, 0, 0);
-        field[1] = new_field(1, 10, 6, 18, 0, 0);
-        field[2] = NULL;
-
-        /* Set field options */
-        set_field_fore(field[0], COLOR_PAIR(1));/* Put the field with blue background */
-        set_field_back(field[0], COLOR_PAIR(2));/* and white foreground (characters */
-                                                /* are printed in white         */
-        field_opts_off(field[0], O_AUTOSKIP);   /* Don't go to next field when this */
-                                                /* Field is filled up           */
-        set_field_back(field[1], A_UNDERLINE); 
-        field_opts_off(field[1], O_AUTOSKIP);
-
-        /* Create the form and post it */
-        my_form = new_form(field);
-        post_form(my_form);
-        refresh();
-        
-        set_current_field(my_form, field[0]); /* Set focus to the colored field */
-        mvprintw(4, 10, "Value 1:");
-        mvprintw(6, 10, "Value 2:");
-        mvprintw(LINES - 2, 0, "Use UP, DOWN arrow keys to switch between fields");
-        refresh();
-
-        /* Loop through to get user requests */
-        while((ch = getch()) != KEY_F(1))
-        {       switch(ch)
-                {       case KEY_DOWN:
-                                /* Go to next field */
-                                form_driver(my_form, REQ_NEXT_FIELD);
-                                /* Go to the end of the present buffer */
-                                /* Leaves nicely at the last character */
-                                form_driver(my_form, REQ_END_LINE);
-                                break;
-                        case KEY_UP:
-                                /* Go to previous field */
-                                form_driver(my_form, REQ_PREV_FIELD);
-                                form_driver(my_form, REQ_END_LINE);
-                                break;
-                        default:
-                                /* If this is a normal character, it gets */
-                                /* Printed                                */    
-                                form_driver(my_form, ch);
-                                break;
-                }
-        }
-
-        /* Un post form and free the memory */
-        unpost_form(my_form);
-        free_form(my_form);
-        free_field(field[0]);
-        free_field(field[1]); 
-
-        endwin();
-        return 0;
-}</span>
-</pre>
-          </div>
-
-          <p>Play with the color pairs and try to understand the
-          foreground and background attributes. In my programs
-          using color attributes, I usually set only the background
-          with set_field_back(). Curses simply doesn't allow
-          defining individual color attributes.</p>
-        </div>
-
-        <div class="SECT3">
-          <hr>
-
-          <h4 class="SECT3"><a name="FIELDOPTIONBITS" id=
-          "FIELDOPTIONBITS">18.3.5. Field Option Bits</a></h4>
-
-          <p>There is also a large collection of field option bits
-          you can set to control various aspects of forms
-          processing. You can manipulate them with these
-          functions:</p>
-          <pre class="PROGRAMLISTING">
-int set_field_opts(FIELD *field,          /* field to alter */
-                   int attr);             /* attribute to set */ 
-
-int field_opts_on(FIELD *field,           /* field to alter */
-                  int attr);              /* attributes to turn on */ 
-
-int field_opts_off(FIELD *field,          /* field to alter */
-                  int attr);              /* attributes to turn off */ 
-
-int field_opts(FIELD *field);             /* field to query */ 
-</pre>
-
-          <p>The function set_field_opts() can be used to directly
-          set attributes of a field or you can choose to switch a
-          few attributes on and off with field_opts_on() and
-          field_opts_off() selectively. Anytime you can query the
-          attributes of a field with field_opts(). The following is
-          the list of available options. By default, all options
-          are on.</p>
-
-          <div class="VARIABLELIST">
-            <dl>
-              <dt>O_VISIBLE</dt>
-
-              <dd>
-                <p>Controls whether the field is visible on the
-                screen. Can be used during form processing to hide
-                or pop up fields depending on the value of parent
-                fields.</p>
-              </dd>
-
-              <dt>O_ACTIVE</dt>
-
-              <dd>
-                <p>Controls whether the field is active during
-                forms processing (i.e. visited by form navigation
-                keys). Can be used to make labels or derived fields
-                with buffer values alterable by the forms
-                application, not the user.</p>
-              </dd>
-
-              <dt>O_PUBLIC</dt>
-
-              <dd>
-                <p>Controls whether data is displayed during field
-                entry. If this option is turned off on a field, the
-                library will accept and edit data in that field,
-                but it will not be displayed and the visible field
-                cursor will not move. You can turn off the O_PUBLIC
-                bit to define password fields.</p>
-              </dd>
-
-              <dt>O_EDIT</dt>
-
-              <dd>
-                <p>Controls whether the field's data can be
-                modified. When this option is off, all editing
-                requests except <tt class=
-                "LITERAL">REQ_PREV_CHOICE</tt> and <tt class=
-                "LITERAL">REQ_NEXT_CHOICE</tt>will fail. Such
-                read-only fields may be useful for help
-                messages.</p>
-              </dd>
-
-              <dt>O_WRAP</dt>
-
-              <dd>
-                <p>Controls word-wrapping in multi-line fields.
-                Normally, when any character of a (blank-separated)
-                word reaches the end of the current line, the
-                entire word is wrapped to the next line (assuming
-                there is one). When this option is off, the word
-                will be split across the line break.</p>
-              </dd>
-
-              <dt>O_BLANK</dt>
-
-              <dd>
-                <p>Controls field blanking. When this option is on,
-                entering a character at the first field position
-                erases the entire field (except for the
-                just-entered character).</p>
-              </dd>
-
-              <dt>O_AUTOSKIP</dt>
-
-              <dd>
-                <p>Controls automatic skip to next field when this
-                one fills. Normally, when the forms user tries to
-                type more data into a field than will fit, the
-                editing location jumps to next field. When this
-                option is off, the user's cursor will hang at the
-                end of the field. This option is ignored in dynamic
-                fields that have not reached their size limit.</p>
-              </dd>
-
-              <dt>O_NULLOK</dt>
-
-              <dd>
-                <p>Controls whether validation is applied to blank
-                fields. Normally, it is not; the user can leave a
-                field blank without invoking the usual validation
-                check on exit. If this option is off on a field,
-                exit from it will invoke a validation check.</p>
-              </dd>
-
-              <dt>O_PASSOK</dt>
-
-              <dd>
-                <p>Controls whether validation occurs on every
-                exit, or only after the field is modified. Normally
-                the latter is true. Setting O_PASSOK may be useful
-                if your field's validation function may change
-                during forms processing.</p>
-              </dd>
-
-              <dt>O_STATIC</dt>
-
-              <dd>
-                <p>Controls whether the field is fixed to its
-                initial dimensions. If you turn this off, the field
-                becomes dynamic and will stretch to fit entered
-                data.</p>
-              </dd>
-            </dl>
-          </div>
-
-          <p>A field's options cannot be changed while the field is
-          currently selected. However, options may be changed on
-          posted fields that are not current.</p>
-
-          <p>The option values are bit-masks and can be composed
-          with logical-or in the obvious way. You have seen the
-          usage of switching off O_AUTOSKIP option. The following
-          example clarifies usage of some more options. Other
-          options are explained where appropriate.</p>
-
-          <div class="EXAMPLE">
-            <a name="FFOOP" id="FFOOP"></a>
-
-            <p><b>Example 27. Field Options Usage example</b></p>
-            <pre class="PROGRAMLISTING">
-<span class="INLINEMEDIAOBJECT">#include &lt;form.h&gt;
-
-#define STARTX 15
-#define STARTY 4
-#define WIDTH 25
-
-#define N_FIELDS 3
-
-int main()
-{       FIELD *field[N_FIELDS];
-        FORM  *my_form;
-        int ch, i;
-        
-        /* Initialize curses */
-        initscr();
-        cbreak();
-        noecho();
-        keypad(stdscr, TRUE);
-
-        /* Initialize the fields */
-        for(i = 0; i &lt; N_FIELDS - 1; ++i)
-                field[i] = new_field(1, WIDTH, STARTY + i * 2, STARTX, 0, 0);
-        field[N_FIELDS - 1] = NULL;
-
-        /* Set field options */
-        set_field_back(field[1], A_UNDERLINE);  /* Print a line for the option  */
-        
-        field_opts_off(field[0], O_ACTIVE); /* This field is a static label */
-        field_opts_off(field[1], O_PUBLIC); /* This filed is like a password field*/
-        field_opts_off(field[1], O_AUTOSKIP); /* To avoid entering the same field */
-                                              /* after last character is entered */
-        
-        /* Create the form and post it */
-        my_form = new_form(field);
-        post_form(my_form);
-        refresh();
-        
-        set_field_just(field[0], JUSTIFY_CENTER); /* Center Justification */
-        set_field_buffer(field[0], 0, "This is a static Field"); 
-                                                  /* Initialize the field  */
-        mvprintw(STARTY, STARTX - 10, "Field 1:");
-        mvprintw(STARTY + 2, STARTX - 10, "Field 2:");
-        refresh();
-
-        /* Loop through to get user requests */
-        while((ch = getch()) != KEY_F(1))
-        {       switch(ch)
-                {       case KEY_DOWN:
-                                /* Go to next field */
-                                form_driver(my_form, REQ_NEXT_FIELD);
-                                /* Go to the end of the present buffer */
-                                /* Leaves nicely at the last character */
-                                form_driver(my_form, REQ_END_LINE);
-                                break;
-                        case KEY_UP:
-                                /* Go to previous field */
-                                form_driver(my_form, REQ_PREV_FIELD);
-                                form_driver(my_form, REQ_END_LINE);
-                                break;
-                        default:
-                                /* If this is a normal character, it gets */
-                                /* Printed                                */    
-                                form_driver(my_form, ch);
-                                break;
-                }
-        }
-
-        /* Un post form and free the memory */
-        unpost_form(my_form);
-        free_form(my_form);
-        free_field(field[0]);
-        free_field(field[1]); 
-
-        endwin();
-        return 0;
-}</span>
-</pre>
-          </div>
-
-          <p>This example, though useless, shows the usage of
-          options. If used properly, they can present information
-          very effectively in a form. The second field being not
-          O_PUBLIC, does not show the characters you are
-          typing.</p>
-        </div>
-
-        <div class="SECT3">
-          <hr>
-
-          <h4 class="SECT3"><a name="FIELDSTATUS" id=
-          "FIELDSTATUS">18.3.6. Field Status</a></h4>
-
-          <p>The field status specifies whether the field has got
-          edited or not. It is initially set to FALSE and when user
-          enters something and the data buffer gets modified it
-          becomes TRUE. So a field's status can be queried to find
-          out whether it has been modified or not. The following
-          functions can assist in those operations.</p>
-          <pre class="PROGRAMLISTING">
-int set_field_status(FIELD *field,      /* field to alter */
-                   int status);         /* status to set */
-
-int field_status(FIELD *field);         /* fetch status of field */
-</pre>
-
-          <p>It's better to check the field's status only after
-          after leaving the field, as data buffer might not have
-          been updated yet as the validation is still due. To
-          guarantee that right status is returned, call
-          field_status() either (1) in the field's exit validation
-          check routine, (2) from the field's or form's
-          initialization or termination hooks, or (3) just after a
-          REQ_VALIDATION request has been processed by the forms
-          driver</p>
-        </div>
-
-        <div class="SECT3">
-          <hr>
-
-          <h4 class="SECT3"><a name="FIELDUSERPTR" id=
-          "FIELDUSERPTR">18.3.7. Field User Pointer</a></h4>
-
-          <p>Every field structure contains one pointer that can be
-          used by the user for various purposes. It is not touched
-          by forms library and can be used for any purpose by the
-          user. The following functions set and fetch user
-          pointer.</p>
-          <pre class="PROGRAMLISTING">
-int set_field_userptr(FIELD *field,   
-           char *userptr);      /* the user pointer you wish to associate */
-                                /* with the field    */
-
-char *field_userptr(FIELD *field);      /* fetch user pointer of the field */
-</pre>
-        </div>
-
-        <div class="SECT3">
-          <hr>
-
-          <h4 class="SECT3"><a name="VARIABLESIZEFIELDS" id=
-          "VARIABLESIZEFIELDS">18.3.8. Variable-Sized
-          Fields</a></h4>
-
-          <p>If you want a dynamically changing field with variable
-          width, this is the feature you want to put to full use.
-          This will allow the user to enter more data than the
-          original size of the field and let the field grow.
-          According to the field orientation it will scroll
-          horizontally or vertically to incorporate the new
-          data.</p>
-
-          <p>To make a field dynamically growable, the option
-          O_STATIC should be turned off. This can be done with
-          a</p>
-          <pre class="PROGRAMLISTING">
-    field_opts_off(field_pointer, O_STATIC);
-</pre>
-
-          <p>But it's usually not advisable to allow a field to
-          grow infinitely. You can set a maximum limit to the
-          growth of the field with</p>
-          <pre class="PROGRAMLISTING">
-int set_max_field(FIELD *field,    /* Field on which to operate */
-                  int max_growth); /* maximum growth allowed for the field */
-</pre>
-
-          <p>The field info for a dynamically growable field can be
-          retrieved by</p>
-          <pre class="PROGRAMLISTING">
-int dynamic_field_info( FIELD *field,     /* Field on which to operate */
-            int   *prows,     /* number of rows will be filled in this */
-            int   *pcols,     /* number of columns will be filled in this*/
-            int   *pmax)      /* maximum allowable growth will be filled */
-                              /* in this */
-</pre>Though field_info work as usual, it is advisable to use this
-function to get the proper attributes of a dynamically growable
-field.
-
-          <p>Recall the library routine new_field; a new field
-          created with height set to one will be defined to be a
-          one line field. A new field created with height greater
-          than one will be defined to be a multi line field.</p>
-
-          <p>A one line field with O_STATIC turned off (dynamically
-          growable field) will contain a single fixed row, but the
-          number of columns can increase if the user enters more
-          data than the initial field will hold. The number of
-          columns displayed will remain fixed and the additional
-          data will scroll horizontally.</p>
-
-          <p>A multi line field with O_STATIC turned off
-          (dynamically growable field) will contain a fixed number
-          of columns, but the number of rows can increase if the
-          user enters more data than the initial field will hold.
-          The number of rows displayed will remain fixed and the
-          additional data will scroll vertically.</p>
-
-          <p>The above two paragraphs pretty much describe a
-          dynamically growable field's behavior. The way other
-          parts of forms library behaves is described below:</p>
-
-          <ol type="1">
-            <li>
-              <p>The field option O_AUTOSKIP will be ignored if the
-              option O_STATIC is off and there is no maximum growth
-              specified for the field. Currently, O_AUTOSKIP
-              generates an automatic REQ_NEXT_FIELD form driver
-              request when the user types in the last character
-              position of a field. On a growable field with no
-              maximum growth specified, there is no last character
-              position. If a maximum growth is specified, the
-              O_AUTOSKIP option will work as normal if the field
-              has grown to its maximum size.</p>
-            </li>
-
-            <li>
-              <p>The field justification will be ignored if the
-              option O_STATIC is off. Currently, set_field_just can
-              be used to JUSTIFY_LEFT, JUSTIFY_RIGHT,
-              JUSTIFY_CENTER the contents of a one line field. A
-              growable one line field will, by definition, grow and
-              scroll horizontally and may contain more data than
-              can be justified. The return from field_just will be
-              unchanged.</p>
-            </li>
-
-            <li>
-              <p>The overloaded form driver request REQ_NEW_LINE
-              will operate the same way regardless of the
-              O_NL_OVERLOAD form option if the field option
-              O_STATIC is off and there is no maximum growth
-              specified for the field. Currently, if the form
-              option O_NL_OVERLOAD is on, REQ_NEW_LINE implicitly
-              generates a REQ_NEXT_FIELD if called from the last
-              line of a field. If a field can grow without bound,
-              there is no last line, so REQ_NEW_LINE will never
-              implicitly generate a REQ_NEXT_FIELD. If a maximum
-              growth limit is specified and the O_NL_OVERLOAD form
-              option is on, REQ_NEW_LINE will only implicitly
-              generate REQ_NEXT_FIELD if the field has grown to its
-              maximum size and the user is on the last line.</p>
-            </li>
-
-            <li>
-              <p>The library call dup_field will work as usual; it
-              will duplicate the field, including the current
-              buffer size and contents of the field being
-              duplicated. Any specified maximum growth will also be
-              duplicated.</p>
-            </li>
-
-            <li>
-              <p>The library call link_field will work as usual; it
-              will duplicate all field attributes and share buffers
-              with the field being linked. If the O_STATIC field
-              option is subsequently changed by a field sharing
-              buffers, how the system reacts to an attempt to enter
-              more data into the field than the buffer will
-              currently hold will depend on the setting of the
-              option in the current field.</p>
-            </li>
-
-            <li>
-              <p>The library call field_info will work as usual;
-              the variable nrow will contain the value of the
-              original call to new_field. The user should use
-              dynamic_field_info, described above, to query the
-              current size of the buffer.</p>
-            </li>
-          </ol>
-
-          <p>Some of the above points make sense only after
-          explaining form driver. We will be looking into that in
-          next few sections.</p>
-        </div>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="FORMWINDOWS" id=
-        "FORMWINDOWS">18.4. Form Windows</a></h3>
-
-        <p>The form windows concept is pretty much similar to menu
-        windows. Every form is associated with a main window and a
-        sub window. The form main window displays any title or
-        border associated or whatever the user wishes. Then the sub
-        window contains all the fields and displays them according
-        to their position. This gives the flexibility of
-        manipulating fancy form displaying very easily.</p>
-
-        <p>Since this is pretty much similar to menu windows, I am
-        providing an example with out much explanation. The
-        functions are similar and they work the same way.</p>
-
-        <div class="EXAMPLE">
-          <a name="FFOWI" id="FFOWI"></a>
-
-          <p><b>Example 28. Form Windows Example</b></p>
-          <pre class="PROGRAMLISTING">
-<span class="INLINEMEDIAOBJECT">#include &lt;form.h&gt;
-
-void print_in_middle(WINDOW *win, int starty, int startx, int width, char *string, chtype color);
-
-int main()
-{
-        FIELD *field[3];
-        FORM  *my_form;
-        WINDOW *my_form_win;
-        int ch, rows, cols;
-        
-        /* Initialize curses */
-        initscr();
-        start_color();
-        cbreak();
-        noecho();
-        keypad(stdscr, TRUE);
-
-        /* Initialize few color pairs */
-        init_pair(1, COLOR_RED, COLOR_BLACK);
-
-        /* Initialize the fields */
-        field[0] = new_field(1, 10, 6, 1, 0, 0);
-        field[1] = new_field(1, 10, 8, 1, 0, 0);
-        field[2] = NULL;
-
-        /* Set field options */
-        set_field_back(field[0], A_UNDERLINE);
-        field_opts_off(field[0], O_AUTOSKIP); /* Don't go to next field when this */
-                                              /* Field is filled up             */
-        set_field_back(field[1], A_UNDERLINE); 
-        field_opts_off(field[1], O_AUTOSKIP);
-        
-        /* Create the form and post it */
-        my_form = new_form(field);
-        
-        /* Calculate the area required for the form */
-        scale_form(my_form, &amp;rows, &amp;cols);
-
-        /* Create the window to be associated with the form */
-        my_form_win = newwin(rows + 4, cols + 4, 4, 4);
-        keypad(my_form_win, TRUE);
-
-        /* Set main window and sub window */
-        set_form_win(my_form, my_form_win);
-        set_form_sub(my_form, derwin(my_form_win, rows, cols, 2, 2));
-
-        /* Print a border around the main window and print a title */
-        box(my_form_win, 0, 0);
-        print_in_middle(my_form_win, 1, 0, cols + 4, "My Form", COLOR_PAIR(1));
-        
-        post_form(my_form);
-        wrefresh(my_form_win);
-
-        mvprintw(LINES - 2, 0, "Use UP, DOWN arrow keys to switch between fields");
-        refresh();
-
-        /* Loop through to get user requests */
-        while((ch = wgetch(my_form_win)) != KEY_F(1))
-        {       switch(ch)
-                {       case KEY_DOWN:
-                                /* Go to next field */
-                                form_driver(my_form, REQ_NEXT_FIELD);
-                                /* Go to the end of the present buffer */
-                                /* Leaves nicely at the last character */
-                                form_driver(my_form, REQ_END_LINE);
-                                break;
-                        case KEY_UP:
-                                /* Go to previous field */
-                                form_driver(my_form, REQ_PREV_FIELD);
-                                form_driver(my_form, REQ_END_LINE);
-                                break;
-                        default:
-                                /* If this is a normal character, it gets */
-                                /* Printed                                */    
-                                form_driver(my_form, ch);
-                                break;
-                }
-        }
-
-        /* Un post form and free the memory */
-        unpost_form(my_form);
-        free_form(my_form);
-        free_field(field[0]);
-        free_field(field[1]); 
-
-        endwin();
-        return 0;
-}
-
-void print_in_middle(WINDOW *win, int starty, int startx, int width, char *string, chtype color)
-{       int length, x, y;
-        float temp;
-
-        if(win == NULL)
-                win = stdscr;
-        getyx(win, y, x);
-        if(startx != 0)
-                x = startx;
-        if(starty != 0)
-                y = starty;
-        if(width == 0)
-                width = 80;
-
-        length = strlen(string);
-        temp = (width - length)/ 2;
-        x = startx + (int)temp;
-        wattron(win, color);
-        mvwprintw(win, y, x, "%s", string);
-        wattroff(win, color);
-        refresh();
-}</span>
-</pre>
-        </div>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="FILEDVALIDATE" id=
-        "FILEDVALIDATE">18.5. Field Validation</a></h3>
-
-        <p>By default, a field will accept any data input by the
-        user. It is possible to attach validation to the field.
-        Then any attempt by the user to leave the field, while it
-        contains data that doesn't match the validation type will
-        fail. Some validation types also have a character-validity
-        check for each time a character is entered in the
-        field.</p>
-
-        <p>Validation can be attached to a field with the following
-        function.</p>
-        <pre class="PROGRAMLISTING">
-int set_field_type(FIELD *field,          /* field to alter */
-                   FIELDTYPE *ftype,      /* type to associate */
-                   ...);                  /* additional arguments*/
-</pre>Once set, the validation type for a field can be queried with
-        <pre class="PROGRAMLISTING">
-FIELDTYPE *field_type(FIELD *field);      /* field to query */
-</pre>
-
-        <p>The form driver validates the data in a field only when
-        data is entered by the end-user. Validation does not occur
-        when</p>
-
-        <ul>
-          <li>
-            <p>the application program changes the field value by
-            calling set_field_buffer.</p>
-          </li>
-
-          <li>
-            <p>linked field values are changed indirectly -- by
-            changing the field to which they are linked</p>
-          </li>
-        </ul>
-
-        <p>The following are the pre-defined validation types. You
-        can also specify custom validation, though it's a bit
-        tricky and cumbersome.</p>
-
-        <h1 class="BRIDGEHEAD"><a name="AEN1069" id=
-        "AEN1069"></a>TYPE_ALPHA</h1>
-
-        <p>This field type accepts alphabetic data; no blanks, no
-        digits, no special characters (this is checked at
-        character-entry time). It is set up with:</p>
-        <pre class="PROGRAMLISTING">
-int set_field_type(FIELD *field,          /* field to alter */
-                   TYPE_ALPHA,            /* type to associate */
-                   int width);            /* minimum width of field */
-</pre>
-
-        <p>The width argument sets a minimum width of data. The
-        user has to enter at-least width number of characters
-        before he can leave the field. Typically you'll want to set
-        this to the field width; if it's greater than the field
-        width, the validation check will always fail. A minimum
-        width of zero makes field completion optional.</p>
-
-        <h1 class="BRIDGEHEAD"><a name="AEN1073" id=
-        "AEN1073"></a>TYPE_ALNUM</h1>
-
-        <p>This field type accepts alphabetic data and digits; no
-        blanks, no special characters (this is checked at
-        character-entry time). It is set up with:</p>
-        <pre class="PROGRAMLISTING">
-int set_field_type(FIELD *field,          /* field to alter */
-                   TYPE_ALNUM,            /* type to associate */
-                   int width);            /* minimum width of field */
-</pre>
-
-        <p>The width argument sets a minimum width of data. As with
-        TYPE_ALPHA, typically you'll want to set this to the field
-        width; if it's greater than the field width, the validation
-        check will always fail. A minimum width of zero makes field
-        completion optional.</p>
-
-        <h1 class="BRIDGEHEAD"><a name="AEN1077" id=
-        "AEN1077"></a>TYPE_ENUM</h1>
-
-        <p>This type allows you to restrict a field's values to be
-        among a specified set of string values (for example, the
-        two-letter postal codes for U.S. states). It is set up
-        with:</p>
-        <pre class="PROGRAMLISTING">
-int set_field_type(FIELD *field,          /* field to alter */
-                   TYPE_ENUM,             /* type to associate */
-                   char **valuelist;      /* list of possible values */
-                   int checkcase;         /* case-sensitive? */
-                   int checkunique);      /* must specify uniquely? */
-</pre>
-
-        <p>The valuelist parameter must point at a NULL-terminated
-        list of valid strings. The checkcase argument, if true,
-        makes comparison with the string case-sensitive.</p>
-
-        <p>When the user exits a TYPE_ENUM field, the validation
-        procedure tries to complete the data in the buffer to a
-        valid entry. If a complete choice string has been entered,
-        it is of course valid. But it is also possible to enter a
-        prefix of a valid string and have it completed for you.</p>
-
-        <p>By default, if you enter such a prefix and it matches
-        more than one value in the string list, the prefix will be
-        completed to the first matching value. But the checkunique
-        argument, if true, requires prefix matches to be unique in
-        order to be valid.</p>
-
-        <p>The REQ_NEXT_CHOICE and REQ_PREV_CHOICE input requests
-        can be particularly useful with these fields.</p>
-
-        <h1 class="BRIDGEHEAD"><a name="AEN1084" id=
-        "AEN1084"></a>TYPE_INTEGER</h1>
-
-        <p>This field type accepts an integer. It is set up as
-        follows:</p>
-        <pre class="PROGRAMLISTING">
-int set_field_type(FIELD *field,          /* field to alter */
-                   TYPE_INTEGER,          /* type to associate */
-                   int padding,           /* # places to zero-pad to */
-                   int vmin, int vmax);   /* valid range */
-</pre>
-
-        <p>Valid characters consist of an optional leading minus
-        and digits. The range check is performed on exit. If the
-        range maximum is less than or equal to the minimum, the
-        range is ignored.</p>
-
-        <p>If the value passes its range check, it is padded with
-        as many leading zero digits as necessary to meet the
-        padding argument.</p>
-
-        <p>A TYPE_INTEGER value buffer can conveniently be
-        interpreted with the C library function atoi(3).</p>
-
-        <h1 class="BRIDGEHEAD"><a name="AEN1090" id=
-        "AEN1090"></a>TYPE_NUMERIC</h1>
-
-        <p>This field type accepts a decimal number. It is set up
-        as follows:</p>
-        <pre class="PROGRAMLISTING">
-int set_field_type(FIELD *field,          /* field to alter */
-                   TYPE_NUMERIC,          /* type to associate */
-                   int padding,           /* # places of precision */
-                   int vmin, int vmax);   /* valid range */
-</pre>
-
-        <p>Valid characters consist of an optional leading minus
-        and digits. possibly including a decimal point. The range
-        check is performed on exit. If the range maximum is less
-        than or equal to the minimum, the range is ignored.</p>
-
-        <p>If the value passes its range check, it is padded with
-        as many trailing zero digits as necessary to meet the
-        padding argument.</p>
-
-        <p>A TYPE_NUMERIC value buffer can conveniently be
-        interpreted with the C library function atof(3).</p>
-
-        <h1 class="BRIDGEHEAD"><a name="AEN1096" id=
-        "AEN1096"></a>TYPE_REGEXP</h1>
-
-        <p>This field type accepts data matching a regular
-        expression. It is set up as follows:</p>
-        <pre class="PROGRAMLISTING">
-int set_field_type(FIELD *field,          /* field to alter */
-                   TYPE_REGEXP,           /* type to associate */
-                   char *regexp);         /* expression to match */
-</pre>
-
-        <p>The syntax for regular expressions is that of
-        regcomp(3). The check for regular-expression match is
-        performed on exit.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="FORMDRIVER" id=
-        "FORMDRIVER">18.6. Form Driver: The work horse of the forms
-        system</a></h3>
-
-        <p>As in the menu system, form_driver() plays a very
-        important role in forms system. All types of requests to
-        forms system should be funneled through form_driver().</p>
-        <pre class="PROGRAMLISTING">
-int form_driver(FORM *form,     /* form on which to operate     */
-                int request)    /* form request code         */
-</pre>
-
-        <p>As you have seen some of the examples above, you have to
-        be in a loop looking for user input and then decide whether
-        it's a field data or a form request. The form requests are
-        then passed to form_driver() to do the work.</p>
-
-        <p>The requests roughly can be divided into following
-        categories. Different requests and their usage is explained
-        below:</p>
-
-        <div class="SECT3">
-          <hr>
-
-          <h4 class="SECT3"><a name="PAGENAVREQ" id=
-          "PAGENAVREQ">18.6.1. Page Navigation Requests</a></h4>
-
-          <p>These requests cause page-level moves through the
-          form, triggering display of a new form screen. A form can
-          be made of multiple pages. If you have a big form with
-          lot of fields and logical sections, then you can divide
-          the form into pages. The function set_new_page() to set a
-          new page at the field specified.</p>
-          <pre class="PROGRAMLISTING">
-int set_new_page(FIELD *field,/* Field at which page break to be set or unset */
-         bool new_page_flag); /* should be TRUE to put a break */
-</pre>
-
-          <p>The following requests allow you to move to different
-          pages</p>
-
-          <ul>
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_NEXT_PAGE</i></span> Move to the next
-              form page.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_PREV_PAGE</i></span> Move to the
-              previous form page.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_FIRST_PAGE</i></span> Move to the
-              first form page.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_LAST_PAGE</i></span> Move to the last
-              form page.</p>
-            </li>
-          </ul>
-
-          <p>These requests treat the list as cyclic; that is,
-          REQ_NEXT_PAGE from the last page goes to the first, and
-          REQ_PREV_PAGE from the first page goes to the last.</p>
-        </div>
-
-        <div class="SECT3">
-          <hr>
-
-          <h4 class="SECT3"><a name="INTERFIELDNAVREQ" id=
-          "INTERFIELDNAVREQ">18.6.2. Inter-Field Navigation
-          Requests</a></h4>
-
-          <p>These requests handle navigation between fields on the
-          same page.</p>
-
-          <ul>
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_NEXT_FIELD</i></span> Move to next
-              field.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_PREV_FIELD</i></span> Move to previous
-              field.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_FIRST_FIELD</i></span> Move to the
-              first field.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_LAST_FIELD</i></span> Move to the last
-              field.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_SNEXT_FIELD</i></span> Move to sorted
-              next field.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_SPREV_FIELD</i></span> Move to sorted
-              previous field.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_SFIRST_FIELD</i></span> Move to the
-              sorted first field.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_SLAST_FIELD</i></span> Move to the
-              sorted last field.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_LEFT_FIELD</i></span> Move left to
-              field.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_RIGHT_FIELD</i></span> Move right to
-              field.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_UP_FIELD</i></span> Move up to
-              field.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_DOWN_FIELD</i></span> Move down to
-              field.</p>
-            </li>
-          </ul>
-
-          <p>These requests treat the list of fields on a page as
-          cyclic; that is, REQ_NEXT_FIELD from the last field goes
-          to the first, and REQ_PREV_FIELD from the first field
-          goes to the last. The order of the fields for these (and
-          the REQ_FIRST_FIELD and REQ_LAST_FIELD requests) is
-          simply the order of the field pointers in the form array
-          (as set up by new_form() or set_form_fields()</p>
-
-          <p>It is also possible to traverse the fields as if they
-          had been sorted in screen-position order, so the sequence
-          goes left-to-right and top-to-bottom. To do this, use the
-          second group of four sorted-movement requests.</p>
-
-          <p>Finally, it is possible to move between fields using
-          visual directions up, down, right, and left. To
-          accomplish this, use the third group of four requests.
-          Note, however, that the position of a form for purposes
-          of these requests is its upper-left corner.</p>
-
-          <p>For example, suppose you have a multi-line field B,
-          and two single-line fields A and C on the same line with
-          B, with A to the left of B and C to the right of B. A
-          REQ_MOVE_RIGHT from A will go to B only if A, B, and C
-          all share the same first line; otherwise it will skip
-          over B to C.</p>
-        </div>
-
-        <div class="SECT3">
-          <hr>
-
-          <h4 class="SECT3"><a name="INTRAFIELDNAVREQ" id=
-          "INTRAFIELDNAVREQ">18.6.3. Intra-Field Navigation
-          Requests</a></h4>
-
-          <p>These requests drive movement of the edit cursor
-          within the currently selected field.</p>
-
-          <ul>
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_NEXT_CHAR</i></span> Move to next
-              character.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_PREV_CHAR</i></span> Move to previous
-              character.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_NEXT_LINE</i></span> Move to next
-              line.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_PREV_LINE</i></span> Move to previous
-              line.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_NEXT_WORD</i></span> Move to next
-              word.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_PREV_WORD</i></span> Move to previous
-              word.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_BEG_FIELD</i></span> Move to beginning
-              of field.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_END_FIELD</i></span> Move to end of
-              field.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_BEG_LINE</i></span> Move to beginning
-              of line.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_END_LINE</i></span> Move to end of
-              line.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_LEFT_CHAR</i></span> Move left in
-              field.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_RIGHT_CHAR</i></span> Move right in
-              field.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_UP_CHAR</i></span> Move up in
-              field.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_DOWN_CHAR</i></span> Move down in
-              field.</p>
-            </li>
-          </ul>
-
-          <p>Each word is separated from the previous and next
-          characters by whitespace. The commands to move to
-          beginning and end of line or field look for the first or
-          last non-pad character in their ranges.</p>
-        </div>
-
-        <div class="SECT3">
-          <hr>
-
-          <h4 class="SECT3"><a name="SCROLLREQ" id=
-          "SCROLLREQ">18.6.4. Scrolling Requests</a></h4>
-
-          <p>Fields that are dynamic and have grown and fields
-          explicitly created with offscreen rows are scrollable.
-          One-line fields scroll horizontally; multi-line fields
-          scroll vertically. Most scrolling is triggered by editing
-          and intra-field movement (the library scrolls the field
-          to keep the cursor visible). It is possible to explicitly
-          request scrolling with the following requests:</p>
-
-          <ul>
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_SCR_FLINE</i></span> Scroll vertically
-              forward a line.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_SCR_BLINE</i></span> Scroll vertically
-              backward a line.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_SCR_FPAGE</i></span> Scroll vertically
-              forward a page.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_SCR_BPAGE</i></span> Scroll vertically
-              backward a page.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_SCR_FHPAGE</i></span> Scroll
-              vertically forward half a page.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_SCR_BHPAGE</i></span> Scroll
-              vertically backward half a page.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_SCR_FCHAR</i></span> Scroll
-              horizontally forward a character.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_SCR_BCHAR</i></span> Scroll
-              horizontally backward a character.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_SCR_HFLINE</i></span> Scroll
-              horizontally one field width forward.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_SCR_HBLINE</i></span> Scroll
-              horizontally one field width backward.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_SCR_HFHALF</i></span> Scroll
-              horizontally one half field width forward.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_SCR_HBHALF</i></span> Scroll
-              horizontally one half field width backward.</p>
-            </li>
-          </ul>
-
-          <p>For scrolling purposes, a page of a field is the
-          height of its visible part.</p>
-        </div>
-
-        <div class="SECT3">
-          <hr>
-
-          <h4 class="SECT3"><a name="EDITREQ" id="EDITREQ">18.6.5.
-          Editing Requests</a></h4>
-
-          <p>When you pass the forms driver an ASCII character, it
-          is treated as a request to add the character to the
-          field's data buffer. Whether this is an insertion or a
-          replacement depends on the field's edit mode (insertion
-          is the default.</p>
-
-          <p>The following requests support editing the field and
-          changing the edit mode:</p>
-
-          <ul>
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_INS_MODE</i></span> Set insertion
-              mode.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_OVL_MODE</i></span> Set overlay
-              mode.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_NEW_LINE</i></span> New line request
-              (see below for explanation).</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_INS_CHAR</i></span> Insert space at
-              character location.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_INS_LINE</i></span> Insert blank line
-              at character location.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_DEL_CHAR</i></span> Delete character
-              at cursor.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_DEL_PREV</i></span> Delete previous
-              word at cursor.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_DEL_LINE</i></span> Delete line at
-              cursor.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_DEL_WORD</i></span> Delete word at
-              cursor.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_CLR_EOL</i></span> Clear to end of
-              line.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_CLR_EOF</i></span> Clear to end of
-              field.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_CLR_FIELD</i></span> Clear entire
-              field.</p>
-            </li>
-          </ul>
-
-          <p>The behavior of the REQ_NEW_LINE and REQ_DEL_PREV
-          requests is complicated and partly controlled by a pair
-          of forms options. The special cases are triggered when
-          the cursor is at the beginning of a field, or on the last
-          line of the field.</p>
-
-          <p>First, we consider REQ_NEW_LINE:</p>
-
-          <p>The normal behavior of REQ_NEW_LINE in insert mode is
-          to break the current line at the position of the edit
-          cursor, inserting the portion of the current line after
-          the cursor as a new line following the current and moving
-          the cursor to the beginning of that new line (you may
-          think of this as inserting a newline in the field
-          buffer).</p>
-
-          <p>The normal behavior of REQ_NEW_LINE in overlay mode is
-          to clear the current line from the position of the edit
-          cursor to end of line. The cursor is then moved to the
-          beginning of the next line.</p>
-
-          <p>However, REQ_NEW_LINE at the beginning of a field, or
-          on the last line of a field, instead does a
-          REQ_NEXT_FIELD. O_NL_OVERLOAD option is off, this special
-          action is disabled.</p>
-
-          <p>Now, let us consider REQ_DEL_PREV:</p>
-
-          <p>The normal behavior of REQ_DEL_PREV is to delete the
-          previous character. If insert mode is on, and the cursor
-          is at the start of a line, and the text on that line will
-          fit on the previous one, it instead appends the contents
-          of the current line to the previous one and deletes the
-          current line (you may think of this as deleting a newline
-          from the field buffer).</p>
-
-          <p>However, REQ_DEL_PREV at the beginning of a field is
-          instead treated as a REQ_PREV_FIELD.</p>
-
-          <p>If the O_BS_OVERLOAD option is off, this special
-          action is disabled and the forms driver just returns
-          E_REQUEST_DENIED.</p>
-        </div>
-
-        <div class="SECT3">
-          <hr>
-
-          <h4 class="SECT3"><a name="ORDERREQ" id=
-          "ORDERREQ">18.6.6. Order Requests</a></h4>
-
-          <p>If the type of your field is ordered, and has
-          associated functions for getting the next and previous
-          values of the type from a given value, there are requests
-          that can fetch that value into the field buffer:</p>
-
-          <ul>
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_NEXT_CHOICE</i></span> Place the
-              successor value of the current value in the
-              buffer.</p>
-            </li>
-
-            <li>
-              <p><span class="emphasis"><i class=
-              "EMPHASIS">REQ_PREV_CHOICE</i></span> Place the
-              predecessor value of the current value in the
-              buffer.</p>
-            </li>
-          </ul>
-
-          <p>Of the built-in field types, only TYPE_ENUM has
-          built-in successor and predecessor functions. When you
-          define a field type of your own (see Custom Validation
-          Types), you can associate our own ordering functions.</p>
-        </div>
-
-        <div class="SECT3">
-          <hr>
-
-          <h4 class="SECT3"><a name="APPLICCOMMANDS" id=
-          "APPLICCOMMANDS">18.6.7. Application Commands</a></h4>
-
-          <p>Form requests are represented as integers above the
-          curses value greater than KEY_MAX and less than or equal
-          to the constant MAX_COMMAND. A value within this range
-          gets ignored by form_driver(). So this can be used for
-          any purpose by the application. It can be treated as an
-          application specific action and take corresponding
-          action.</p>
-        </div>
-      </div>
-    </div>
-
-    <div class="SECT1">
-      <hr>
-
-      <h2 class="SECT1"><a name="TOOLS" id="TOOLS">19. Tools and
-      Widget Libraries</a></h2>
-
-      <p>Now that you have seen the capabilities of ncurses and its
-      sister libraries, you are rolling your sleeves up and gearing
-      for a project that heavily manipulates screen. But wait.. It
-      can be pretty difficult to write and maintain complex GUI
-      widgets in plain ncurses or even with the additional
-      libraries. There are some ready-to-use tools and widget
-      libraries that can be used instead of writing your own
-      widgets. You can use some of them, get ideas from the code,
-      or even extend them.</p>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="CDK" id="CDK">19.1. CDK (Curses
-        Development Kit)</a></h3>
-
-        <p>In the author's words</p>
-
-        <p><span class="emphasis"><i class="EMPHASIS">CDK stands
-        for 'Curses Development Kit' and it currently contains 21
-        ready to use widgets which facilitate the speedy
-        development of full screen curses programs.</i></span></p>
-
-        <p>The kit provides some useful widgets, which can be used
-        in your programs directly. It's pretty well written and the
-        documentation is very good. The examples in the examples
-        directory can be a good place to start for beginners. The
-        CDK can be downloaded from <a href=
-        "https://invisible-island.net/cdk/" target=
-        "_top">https://invisible-island.net/cdk/</a> . Follow the
-        instructions in README file to install it.</p>
-
-        <div class="SECT3">
-          <hr>
-
-          <h4 class="SECT3"><a name="WIDGETLIST" id=
-          "WIDGETLIST">19.1.1. Widget List</a></h4>
-
-          <p>The following is the list of widgets provided with cdk
-          and their description.</p>
-          <pre class="PROGRAMLISTING">
-Widget Type           Quick Description
-===========================================================================
-Alphalist             Allows a user to select from a list of words, with
-                      the ability to narrow the search list by typing in a
-                      few characters of the desired word.
-Buttonbox             This creates a multiple button widget. 
-Calendar              Creates a little simple calendar widget.
-Dialog                Prompts the user with a message, and the user
-                      can pick an answer from the buttons provided.
-Entry                 Allows the user to enter various types of information.
-File Selector         A file selector built from Cdk base widgets. This
-                      example shows how to create more complicated widgets
-                      using the Cdk widget library.
-Graph                 Draws a graph.
-Histogram             Draws a histogram.
-Item List             Creates a pop up field which allows the user to select
-                      one of several choices in a small field. Very useful
-                      for things like days of the week or month names.
-Label                 Displays messages in a pop up box, or the label can be
-                      considered part of the screen.
-Marquee               Displays a message in a scrolling marquee.
-Matrix                Creates a complex matrix with lots of options.
-Menu                  Creates a pull-down menu interface.
-Multiple Line Entry   A multiple line entry field. Very useful
-                      for long fields. (like a description
-                      field)
-Radio List            Creates a radio button list.
-Scale                 Creates a numeric scale. Used for allowing a user to
-                      pick a numeric value and restrict them to a range of 
-                      values.
-Scrolling List        Creates a scrolling list/menu list.
-Scrolling Window      Creates a scrolling log file viewer. Can add 
-                      information into the window while its running. 
-                      A good widget for displaying the progress of
-                      something. (akin to a console window)
-Selection List        Creates a multiple option selection list.
-Slider                Akin to the scale widget, this widget provides a
-                      visual slide bar to represent the numeric value.
-Template              Creates a entry field with character sensitive 
-                      positions. Used for pre-formatted fields like
-                      dates and phone numbers.
-Viewer                This is a file/information viewer. Very useful
-                      when you need to display loads of information.
-===========================================================================
-</pre>
-
-          <p>A few of the widgets are modified by Thomas Dickey in
-          recent versions.</p>
-        </div>
-
-        <div class="SECT3">
-          <hr>
-
-          <h4 class="SECT3"><a name="CDKATTRACT" id=
-          "CDKATTRACT">19.1.2. Some Attractive Features</a></h4>
-
-          <p>Apart from making our life easier with readily usable
-          widgets, cdk solves one frustrating problem with printing
-          multi colored strings, justified strings elegantly.
-          Special formatting tags can be embedded in the strings
-          which are passed to CDK functions. For Example</p>
-
-          <p>If the string</p>
-          <pre class="PROGRAMLISTING">
-"&lt;/B/1&gt;This line should have a yellow foreground and a blue
-background.&lt;!1&gt;"
-</pre>
-
-          <p>given as a parameter to newCDKLabel(), it prints the
-          line with yellow foreground and blue background. There
-          are other tags available for justifying string, embedding
-          special drawing characters etc.. Please refer to the man
-          page cdk_display(3X) for details. The man page explains
-          the usage with nice examples.</p>
-        </div>
-
-        <div class="SECT3">
-          <hr>
-
-          <h4 class="SECT3"><a name="CDKCONCLUSION" id=
-          "CDKCONCLUSION">19.1.3. Conclusion</a></h4>
-
-          <p>All in all, CDK is a well-written package of widgets,
-          which if used properly can form a strong frame work for
-          developing complex GUI.</p>
-        </div>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="DIALOG" id="DIALOG">19.2. The
-        dialog</a></h3>
-
-        <p>Long long ago, in September 1994, when few people knew
-        linux, Jeff Tranter wrote an <a href=
-        "http://www2.linuxjournal.com/lj-issues/issue5/2807.html"
-        target="_top">article</a> on dialog in Linux Journal. He
-        starts the article with these words..</p>
-
-        <p><span class="emphasis"><i class="EMPHASIS">Linux is
-        based on the Unix operating system, but also features a
-        number of unique and useful kernel features and application
-        programs that often go beyond what is available under Unix.
-        One little-known gem is "dialog", a utility for creating
-        professional-looking dialog boxes from within shell
-        scripts. This article presents a tutorial introduction to
-        the dialog utility, and shows examples of how and where it
-        can be used</i></span></p>
-
-        <p>As he explains, dialog is a real gem in making
-        professional-looking dialog boxes with ease. It creates a
-        variety of dialog boxes, menus, check lists etc.. It is
-        usually installed by default. If not, you can download it
-        from <a href="https://invisible-island.net/dialog/" target=
-        "_top">Thomas Dickey</a>'s site.</p>
-
-        <p>The above-mentioned article gives a very good overview
-        of its uses and capabilites. The man page has more details.
-        It can be used in variety of situations. One good example
-        is building of linux kernel in text mode. Linux kernel uses
-        a modified version of dialog tailored for its needs.</p>
-
-        <p>dialog was initially designed to be used with shell
-        scripts. If you want to use its functionality in a c
-        program, then you can use libdialog. The documentation
-        regarding this is sparse. Definitive reference is the
-        dialog.h header file which comes with the library. You may
-        need to hack here and there to get the required output. The
-        source is easily customizable. I have used it on a number
-        of occasions by modifying the code.</p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="PERLCURSES" id=
-        "PERLCURSES">19.3. Perl Curses Modules CURSES::FORM and
-        CURSES::WIDGETS</a></h3>
-
-        <p>The perl module Curses, Curses::Form and Curses::Widgets
-        give access to curses from perl. If you have curses and
-        basic perl is installed, you can get these modules from
-        <a href="http://www.cpan.org/modules/01modules.index.html"
-        target="_top">CPAN All Modules page</a>. Get the three
-        zipped modules in the Curses category. Once installed you
-        can use these modules from perl scripts like any other
-        module. For more information on perl modules see perlmod
-        man page. The above modules come with good documentation
-        and they have some demo scripts to test the functionality.
-        Though the widgets provided are very rudimentary, these
-        modules provide good access to curses library from
-        perl.</p>
-
-        <p>Some of my code examples are converted to perl by
-        Anuradha Ratnaweera and they are available in the
-        <tt class="LITERAL">perl</tt> directory.</p>
-
-        <p>For more information see man pages Curses(3) ,
-        Curses::Form(3) and Curses::Widgets(3). These pages are
-        installed only when the above modules are acquired and
-        installed.</p>
-      </div>
-    </div>
-
-    <div class="SECT1">
-      <hr>
-
-      <h2 class="SECT1"><a name="JUSTFORFUN" id="JUSTFORFUN">20.
-      Just For Fun !!!</a></h2>
-
-      <p>This section contains few programs written by me just for
-      fun. They don't signify a better programming practice or the
-      best way of using ncurses. They are provided here so as to
-      allow beginners to get ideas and add more programs to this
-      section. If you have written a couple of nice, simple
-      programs in curses and want them to included here, contact
-      <a href="mailto:ppadala@gmail.com" target="_top">me</a>.</p>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="GAMEOFLIFE" id=
-        "GAMEOFLIFE">20.1. The Game of Life</a></h3>
-
-        <p>Game of life is a wonder of math. In <a href=
-        "http://www.math.com/students/wonders/life/life.html"
-        target="_top">Paul Callahan</a>'s words</p>
-        <pre class="PROGRAMLISTING">
-<span class="emphasis"><i class=
-"EMPHASIS">The Game of Life (or simply Life) is not a game in the conventional sense. There
-are no players, and no winning or losing. Once the "pieces" are placed in the
-starting position, the rules determine everything that happens later.
-Nevertheless, Life is full of surprises! In most cases, it is impossible to look
-at a starting position (or pattern) and see what will happen in the future. The
-only way to find out is to follow the rules of the game.</i></span>
-</pre>
-
-        <p>This program starts with a simple inverted U pattern and
-        shows how wonderful life works. There is a lot of room for
-        improvement in the program. You can let the user enter
-        pattern of his choice or even take input from a file. You
-        can also change rules and play with a lot of variations.
-        Search on <a href="http://www.google.com" target=
-        "_top">google</a> for interesting information on game of
-        life.</p>
-
-        <p><span class="emphasis"><i class="EMPHASIS">File Path:
-        JustForFun/life.c</i></span></p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="MAGIC" id="MAGIC">20.2. Magic
-        Square</a></h3>
-
-        <p>Magic Square, another wonder of math, is very simple to
-        understand but very difficult to make. In a magic square
-        sum of the numbers in each row, each column is equal. Even
-        diagnol sum can be equal. There are many variations which
-        have special properties.</p>
-
-        <p>This program creates a simple magic square of odd
-        order.</p>
-
-        <p><span class="emphasis"><i class="EMPHASIS">File Path:
-        JustForFun/magic.c</i></span></p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="HANOI" id="HANOI">20.3. Towers
-        of Hanoi</a></h3>
-
-        <p>The famous towers of hanoi solver. The aim of the game
-        is to move the disks on the first peg to last peg, using
-        middle peg as a temporary stay. The catch is not to place a
-        larger disk over a small disk at any time.</p>
-
-        <p><span class="emphasis"><i class="EMPHASIS">File Path:
-        JustForFun/hanoi.c</i></span></p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="QUEENS" id="QUEENS">20.4. Queens
-        Puzzle</a></h3>
-
-        <p>The objective of the famous N-Queen puzzle is to put N
-        queens on a N X N chess board without attacking each
-        other.</p>
-
-        <p>This program solves it with a simple backtracking
-        technique.</p>
-
-        <p><span class="emphasis"><i class="EMPHASIS">File Path:
-        JustForFun/queens.c</i></span></p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="SHUFFLE" id="SHUFFLE">20.5.
-        Shuffle</a></h3>
-
-        <p>A fun game, if you have time to kill.</p>
-
-        <p><span class="emphasis"><i class="EMPHASIS">File Path:
-        JustForFun/shuffle.c</i></span></p>
-      </div>
-
-      <div class="SECT2">
-        <hr>
-
-        <h3 class="SECT2"><a name="TT" id="TT">20.6. Typing
-        Tutor</a></h3>
-
-        <p>A simple typing tutor, I created more out of need than
-        for ease of use. If you know how to put your fingers
-        correctly on the keyboard, but lack practice, this can be
-        helpful.</p>
-
-        <p><span class="emphasis"><i class="EMPHASIS">File Path:
-        JustForFun/tt.c</i></span></p>
-      </div>
-    </div>
-
-    <div class="SECT1">
-      <hr>
-
-      <h2 class="SECT1"><a name="REF" id="REF">21.
-      References</a></h2>
-
-      <ul>
-        <li>
-          <p>NCURSES man pages</p>
-        </li>
-
-        <li>
-          <p>NCURSES FAQ at <a href=
-          "https://invisible-island.net/ncurses/ncurses.faq.html"
-          target=
-          "_top">https://invisible-island.net/ncurses/ncurses.faq.html</a></p>
-        </li>
-
-        <li>
-          <p>Writing programs with NCURSES by Eric Raymond and Zeyd
-          M. Ben-Halim at <a href=
-          "https://invisible-island.net/ncurses/ncurses-intro.html"
-          target=
-          "_top">https://invisible-island.net/ncurses/ncurses-intro.html</a>
-          - somewhat obsolete. I was inspired by this document and
-          the structure of this HOWTO follows from the original
-          document</p>
-        </li>
-      </ul>
-    </div>
-  </div>
-</body>
-</html>
diff --git a/contrib/ncurses/doc/html/announce.html b/contrib/ncurses/doc/html/announce.html
deleted file mode 100644
index 699372019b83..000000000000
--- a/contrib/ncurses/doc/html/announce.html
+++ /dev/null
@@ -1,2220 +0,0 @@
-<!--
-  $Id: announce.html,v 1.64 2020/10/19 08:18:48 tom Exp $
-  ****************************************************************************
-  * Copyright 2018-2019,2020 Thomas E. Dickey                                *
-  *                                                                          *
-  * Permission is hereby granted, free of charge, to any person obtaining a  *
-  * copy of this software and associated documentation files (the            *
-  * "Software"), to deal in the Software without restriction, including      *
-  * without limitation the rights to use, copy, modify, merge, publish,      *
-  * distribute, distribute with modifications, sublicense, and/or sell       *
-  * copies of the Software, and to permit persons to whom the Software is    *
-  * furnished to do so, subject to the following conditions:                 *
-  *                                                                          *
-  * The above copyright notice and this permission notice shall be included  *
-  * in all copies or substantial portions of the Software.                   *
-  *                                                                          *
-  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
-  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
-  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
-  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
-  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
-  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
-  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
-  *                                                                          *
-  * Except as contained in this notice, the name(s) of the above copyright   *
-  * holders shall not be used in advertising or otherwise to promote the     *
-  * sale, use or other dealings in this Software without prior written       *
-  * authorization.                                                           *
-  ****************************************************************************
--->
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
-
-<html>
-<head>
-  <meta name="generator" content=
-  "HTML Tidy for HTML5 for Linux version 5.2.0">
-
-  <title>Announcing ncurses 6.2</title>
-  <link rel="author" href="mailto:bug-ncurses@gnu.org">
-  <meta http-equiv="Content-Type" content=
-  "text/html; charset=us-ascii">
-  <style type="text/css">
-  p,li { max-width:700px; }
-  dd { max-width:630px; }
-  *.main-name {
-        font-style: italic;
-        font-variant: small-caps;
-  }
-  *.part-name {
-        font-family: "Andale Mono", "Monotype.com", monospace;
-        font-size: 12pt;
-        font-weight: bold;
-  }
-  *.demo-name {
-        font-family: "Andale Mono", "Monotype.com", monospace;
-        font-size: 10pt;
-  }
-  </style>
-</head>
-
-<body>
-  <h1 class="no-header">Announcing ncurses 6.2</h1>
-
-  <h2><a name="h2-overview" id="h2-overview">Overview</a></h2>
-
-  <p>The <span class="main-name">ncurses</span> (new curses)
-  library is a free software emulation of curses in System V
-  Release 4.0 (SVr4), and more. It uses terminfo format, supports
-  pads and color and multiple highlights and forms characters and
-  function-key mapping, and has all the other SVr4-curses
-  enhancements over BSD curses. SVr4 curses became the basis of
-  X/Open Curses.</p>
-
-  <p>In mid-June 1995, the maintainer of 4.4BSD curses declared
-  that he considered 4.4BSD curses obsolete, and encouraged the
-  keepers of <span class="main-name">unix</span> releases such as
-  BSD/OS, FreeBSD and NetBSD to switch over to <span class=
-  "main-name">ncurses</span>.</p>
-
-  <p>Since 1995, <span class="main-name">ncurses</span> has been
-  ported to many systems:</p>
-
-  <ul>
-    <li>It is used in almost every system based on the Linux kernel
-    (aside from some embedded applications).</li>
-
-    <li>It is used as the system curses library on OpenBSD, FreeBSD
-    and MacOS.</li>
-
-    <li>It is used in environments such as Cygwin and MinGW. The
-    first of these was EMX on OS/2 Warp.</li>
-
-    <li>It is used (though usually not as the <em>system</em>
-    curses) on all of the vendor <span class=
-    "main-name">unix</span> systems, e.g., AIX, HP-UX, IRIX64, SCO,
-    Solaris, Tru64.</li>
-
-    <li>It should work readily on any ANSI/POSIX-conforming
-    <span class="main-name">unix</span>.</li>
-  </ul>
-
-  <p>The distribution includes the library and support utilities,
-  including</p>
-
-  <ul>
-    <li><a href=
-    "https://invisible-island.net/ncurses/man/captoinfo.1m.html"><span class="part-name">
-    captoinfo</span></a>, a termcap conversion tool</li>
-
-    <li><a href=
-    "https://invisible-island.net/ncurses/man/clear.1.html"><span class="part-name">
-    clear</span></a>, utility for clearing the screen</li>
-
-    <li><a href=
-    "https://invisible-island.net/ncurses/man/infocmp.1m.html"><span class="part-name">
-    infocmp</span></a>, the terminfo decompiler</li>
-
-    <li><a href=
-    "https://invisible-island.net/ncurses/man/tabs.1.html"><span class="part-name">
-    tabs</span></a>, set tabs on a terminal</li>
-
-    <li><a href=
-    "https://invisible-island.net/ncurses/man/tic.1m.html"><span class="part-name">
-    tic</span></a>, the terminfo compiler</li>
-
-    <li><a href=
-    "https://invisible-island.net/ncurses/man/toe.1m.html"><span class="part-name">
-    toe</span></a>, list (table of) terminfo entries</li>
-
-    <li><a href=
-    "https://invisible-island.net/ncurses/man/tput.1.html"><span class="part-name">
-    tput</span></a>, utility for retrieving terminal capabilities
-    in shell scripts</li>
-
-    <li><a href=
-    "https://invisible-island.net/ncurses/man/tset.1.html"><span class="part-name">
-    tset</span></a>, to initialize the terminal</li>
-  </ul>
-
-  <p>Full manual pages are provided for the library and tools.</p>
-
-  <p>The <span class="main-name">ncurses</span> distribution is
-  available at <span class="main-name">ncurses</span>' <a href=
-  "https://invisible-island.net/ncurses/">homepage</a>:</p>
-
-  <blockquote>
-    <p><a href=
-    "ftp://ftp.invisible-island.net/ncurses/">ftp://ftp.invisible-island.net/ncurses/</a>
-    or<br>
-    <a href=
-    "https://invisible-mirror.net/archives/ncurses/">https://invisible-mirror.net/archives/ncurses/</a>&nbsp;.</p>
-  </blockquote>
-
-  <p>It is also available via anonymous FTP at the GNU distribution
-  site</p>
-
-  <blockquote>
-    <p><a href=
-    "ftp://ftp.gnu.org/gnu/ncurses/">ftp://ftp.gnu.org/gnu/ncurses/</a>&nbsp;.</p>
-  </blockquote>
-
-  <h2><a name="h2-release-notes" id="h2-release-notes">Release
-  Notes</a></h2>
-
-  <p>These notes are for <span class="main-name">ncurses</span>
-  6.2, released <strong>February 12, 2020</strong>.</p>
-
-  <p>This release is designed to be source-compatible with
-  <span class="main-name">ncurses</span> 5.0 through 6.1; providing
-  extensions to the application binary interface (ABI). Although
-  the source can still be configured to support the <span class=
-  "main-name">ncurses</span> 5 ABI, the reason for the release is
-  to reflect improvements to the <span class=
-  "main-name">ncurses</span> 6 ABI and the supporting utility
-  programs.</p>
-
-  <p>There are, of course, numerous other improvements, listed in
-  this announcement.</p>
-
-  <p>The most <a href="#h3-bug-fixes">important
-  bug-fixes/improvements</a> dealt with user-defined capabilities
-  in terminal descriptions. The release notes also mention some
-  other bug-fixes, but are focused on new features and improvements
-  to existing features since <span class="main-name">ncurses</span>
-  6.1 release.</p>
-
-  <h3><a name="h3-library" id="h3-library">Library improvements</a></h3>
-
-  <h4><a name="h4-new-library" id="h4-new-library">New features</a></h4>
-
-  <p>There are several new features:</p>
-
-  <ul>
-    <li>
-      <p><a href=
-      "https://invisible-island.net/ncurses/man/form_field_opts.3x.html">
-      O_EDGE_INSERT_STAY</a> tells the form library to optionally
-      delay cursor movement on a field edge/boundary</p>
-    </li>
-
-    <li>
-      <p><a href=
-      "https://invisible-island.net/ncurses/man/form_field_opts.3x.html">
-      O_INPUT_FIELD</a> extension to form library allows a dynamic
-      field to shrink if the new limit is smaller than the current
-      field size.</p>
-    </li>
-
-    <li>
-      <p>added <a href=
-      "https://invisible-island.net/ncurses/man/curs_memleaks.3x.html">
-      exit_curses</a> and <a href=
-      "https://invisible-island.net/ncurses/man/curs_memleaks.3x.html">
-      exit_terminfo</a> to replace internal symbols for
-      leak-checking.</p>
-    </li>
-
-    <li>
-      <p>added <a href=
-      "https://invisible-island.net/ncurses/man/curs_trace.3x.html#h3-Functions">
-      curses_trace</a>, to replace trace().</p>
-    </li>
-  </ul>
-
-  <p>Additionally, to improve performance other changes (and
-  extensions) are provided in this release:</p>
-
-  <ul>
-    <li>
-      <p>mouse decoding now handles shift/control/alt logic when
-      decoding xterm's 1006 mode</p>
-    </li>
-
-    <li>
-      <p>ncurses now defines a limit for <a href=
-      "https://invisible-island.net/ncurses/man/curs_getstr.3x.html">
-      wgetnstr</a>, <a href=
-      "https://invisible-island.net/ncurses/man/curs_get_wstr.3x.html">
-      wgetn_wstr</a> when length is negative or &ldquo;too
-      large&rdquo;.</p>
-    </li>
-
-    <li>reordered loop-limit checks in <a href=
-    "https://invisible-island.net/ncurses/man/curs_insstr.3x.html">winsnstr</a>
-    in case the string has no terminating null and only the number
-    of characters is used.</li>
-
-    <li>
-      <p>there is now no buffer-size limit when reading the
-      <a href="https://invisible-island.net/ncurses/man/ncurses.3x.html#h3-TERMCAP">
-      <tt>$TERMCAP</tt></a> variable.</p>
-    </li>
-
-    <li>
-      <p>the <a href=
-      "https://invisible-island.net/ncurses/man/ncurses.3x.html#h3-TERMCAP">
-      <tt>$TERMCAP</tt></a> variable may be interpreted as a
-      fallback to a terminfo entry</p>
-    </li>
-
-    <li>
-      <p><a href=
-      "https://invisible-island.net/ncurses/man/curs_terminfo.3x.html#h3-Output-Functions">
-      <tt>mvcur</tt></a> now decides whether to use hard-tabs,
-      using <strong><tt>xt</tt></strong>,
-      <strong><tt>tbc</tt></strong> and
-      <strong><tt>hts</tt></strong> as clues.</p>
-    </li>
-
-    <li>
-      <p>extended colors are improved by modifying an internal call
-      to <a href=
-      "https://invisible-island.net/ncurses/man/curs_terminfo.3x.html#h3-Output-Functions">
-      <tt>vid_puts</tt></a> to pass extended color pairs e.g., from
-      <tt>tty_update.c</tt> and <tt>lib_mvcur.c</tt></p>
-    </li>
-
-    <li>
-      <p id="getenv-fixes">the initialization functions now avoid
-      relying upon persistent data for the result from <a href=
-      "#getenv-check"><tt>getenv</tt></a></p>
-    </li>
-
-    <li>
-      <p>scrolling is improved:</p>
-
-      <ul>
-        <li>a limit check in <tt>newline_forces_scroll</tt> handles
-        the case where the row is inside scroll-margins, but not at
-        the end.</li>
-
-        <li>
-          <p>improved loop limits in <tt>_nc_scroll_window</tt>
-          handle a case where the scrolled data is a pad which is
-          taller than the window.</p>
-        </li>
-      </ul>
-    </li>
-  </ul>
-
-  <h4><a name="h4-fixes-library" id="h4-fixes-library">Other
-  improvements</a></h4>
-
-  <p>These are revised features:</p>
-
-  <ul>
-    <li>
-      <p>used &ldquo;<tt>const</tt>&rdquo; in some prototypes
-      rather than <tt>NCURSES_CONST</tt> where X/Open Curses was
-      updated to do this, e.g., <tt>wscanw</tt>, <tt>newterm</tt>,
-      the terminfo interface. Also use &ldquo;<tt>const</tt>&rdquo;
-      for consistency in the termcap interface, which was withdrawn
-      by X/Open Curses in Issue 5 (2007). As of Issue 7, X/Open
-      Curses still lacks &ldquo;<tt>const</tt>&rdquo; for certain
-      return values, e.g., <a href=
-      "https://invisible-island.net/ncurses/man/curs_util.3x.html#h3-keyname_key_name">
-      keyname</a>.</p>
-    </li>
-
-    <li>
-      <p>modified <a href=
-      "https://invisible-island.net/ncurses/man/curs_bkgd.3x.html#h3-bkgd">
-      <tt>wbkgd</tt></a> and <a href=
-      "https://invisible-island.net/ncurses/man/curs_bkgrnd.3x.html#h3-bkgrnd">
-      <tt>wbkgrnd</tt></a> to improve compatibility with SVr4
-      curses, changing the way the window rendition is updated when
-      the background character is modified</p>
-    </li>
-
-    <li>
-      <p>improved terminfo write/read by modifying the fourth item
-      of the extended header to denote the number of valid strings
-      in the extended string table (see <a href=
-      "https://invisible-island.net/ncurses/man/term.5.html#h3-EXTENDED-STORAGE-FORMAT">
-      term(5)</a>).</p>
-    </li>
-
-    <li>
-      <p>modified the initialization checks for mouse so that the
-      <a href=
-      "/ncurses/terminfo.src.html#tic-xterm_sm_1006"><tt>xterm+sm+1006</tt></a>
-      block will work with terminal descriptions not mentioning
-      <em>xterm</em>.</p>
-    </li>
-  </ul>
-
-  <p>These were done to limit or ultimately deprecate features:</p>
-
-  <ul>
-    <li>
-      <p>deprecated <a href=
-      "https://invisible-island.net/ncurses/NEWS.html#t970831">safe-sprintf</a>,
-      since the <tt>vsnprintf</tt> function, which does what was
-      needed, was standardized long ago.</p>
-    </li>
-
-    <li>
-      <p>marked <a href=
-      "https://invisible-island.net/ncurses/man/curs_printw.3x.html#h2-PORTABILITY">
-      <tt>vwprintw</tt></a> and <tt>vwscanw</tt> as deprecated;
-      recommend using <a href=
-      "https://invisible-island.net/ncurses/man/curs_printw.3x.html">
-      <tt>vw_printw</tt></a> and <tt>vw_scanw</tt>,
-      respectively.</p>
-    </li>
-
-    <li>
-      <p>added deprecation warnings for internal functions called
-      by older versions of <a href=
-      "https://invisible-island.net/ncurses/tack.html">tack</a>.</p>
-    </li>
-
-    <li>
-      <p>removed unused <tt>_nc_import_termtype2</tt> function.</p>
-    </li>
-  </ul>
-
-  <p>These are improvements to existing features:</p>
-
-  <ul>
-    <li>
-      <p>check parameter of <a href=
-      "https://invisible-island.net/ncurses/man/curs_threads.3x.html">
-      set_escdelay</a>, return ERR if negative.</p>
-    </li>
-
-    <li>
-      <p>check parameter of <a href=
-      "https://invisible-island.net/ncurses/man/curs_threads.3x.html">
-      set_tabsize</a>, return ERR if not greater than zero</p>
-    </li>
-
-    <li>
-      <p>correct a status-check in _nc_read_tic_entry() so that if
-      reading a hex/b64 <a href=
-      "https://invisible-island.net/ncurses/man/ncurses.3x.html#h3-TERMINFO">
-      <tt>$TERMINFO</tt></a>, and the <a href=
-      "https://invisible-island.net/ncurses/man/ncurses.3x.html#h3-TERM">
-      <tt>$TERM</tt></a> does not match, fall-through to the
-      compiled-in search list.</p>
-    </li>
-
-    <li>
-      <p>amend check for <a href=
-      "https://invisible-island.net/ncurses/man/terminfo.5.html#h3-Predefined-Capabilities">
-      <tt>repeat_char</tt></a> to handle a case where setlocale()
-      was called after <a href=
-      "https://invisible-island.net/ncurses/man/curs_initscr.3x.html">
-      <tt>initscr</tt></a></p>
-    </li>
-
-    <li>
-      <p>move macro for <a href=
-      "https://invisible-island.net/ncurses/man/curs_touch.3x.html">
-      <tt>is_linetouched</tt></a> inside
-      <strong><tt>NCURSES_NOMACROS</tt></strong>
-      <em><tt>ifndef</tt></em>.</p>
-    </li>
-
-    <li>
-      <p>use <tt>_nc_copy_termtype2</tt> rather than direct
-      assignment in <a href=
-      "https://invisible-island.net/ncurses/man/curs_terminfo.3x.html#h3-Initialization">
-      setupterm</a>, in case it is called repeatedly using fallback
-      terminfo descriptions</p>
-    </li>
-
-    <li>
-      <p>improve workaround for Solaris wcwidth versus line-drawing
-      characters</p>
-    </li>
-
-    <li>
-      <p>add checks in <a href=
-      "https://invisible-island.net/ncurses/man/resizeterm.3x.html">
-      <tt>repair_subwindows</tt></a> to keep the current position
-      and scroll-margins inside the resized subwindow.</p>
-    </li>
-
-    <li>
-      <p>correct a buffer-limit in <tt>write_entry.c</tt> for
-      systems that use caseless filenames.</p>
-    </li>
-
-    <li>
-      <p>improved build-time utility <em>report_offsets</em>:</p>
-
-      <ul>
-        <li>
-          <p>add categories, e.g., "w" for wide-character, "t" for
-          threads to make the report more readable. Reorganized the
-          structures reported to make the categories more
-          apparent.</p>
-        </li>
-
-        <li>
-          <p>add <tt>NCURSES_GLOBALS</tt> and
-          <tt>NCURSES_PRESCREEN</tt> to report to show how similar
-          the different <em>libtinfo</em> configurations are.</p>
-        </li>
-      </ul>
-    </li>
-
-    <li>
-      <p>modified some header files to ensure that those include
-      necessary files except for the previously-documented
-      cases</p>
-    </li>
-
-    <li>
-      <p>added some traces in initialization to show whether a
-      fallback entry is used.</p>
-    </li>
-
-    <li>
-      <p>made minor optimization to reduce calls to
-      _nc_reserve_pairs</p>
-    </li>
-  </ul>
-
-  <p>These are corrections to existing features:</p>
-
-  <ul>
-    <li>
-      <p>fix a special case in <tt>PutAttrChar</tt> where a cell is
-      marked as alternate-character set, but the terminal does not
-      actually support the given graphic character. This would
-      happen in an older terminal such as <em>vt52</em>, which
-      lacks most line-drawing capability.</p>
-    </li>
-
-    <li>
-      <p>corrected flag for "seq" method of db 1.8.5 interface,
-      needed by toe on some of the BSDs.</p>
-    </li>
-
-    <li>
-      <p>modify comparison in make_hash.c to correct a special case
-      in collision handling for Caps-hpux11</p>
-    </li>
-
-    <li>
-      <p>add extended_slk_color{,_sp} symbols to the appropriate
-      package/*.{map,sym} files</p>
-    </li>
-
-    <li>
-      <p>modify lib_setup to avoid calling pthread_self() without
-      first verifying that the address is valid, i.e., for weak
-      symbols</p>
-    </li>
-
-    <li>
-      <p>add a couple of broken-linker symbols to the list of
-      versioned symbols to help with link-time optimization versus
-      weak symbols.</p>
-    </li>
-  </ul>
-
-  <h3><a name="h3-programs" id="h3-programs">Program
-  improvements</a></h3>
-
-  <p id="h4-utilities">Several improvements were made to the
-  utility programs:</p>
-
-  <dl>
-    <dt><span class="part-name">clear</span>
-    </dt>
-
-    <dd>
-      <ul>
-        <li>improved logic for clearing with the <em>E3</em>
-        extension, in case the terminal scrolls content onto its
-        saved-lines before actually clearing the display, by
-        clearing the saved-lines after clearing the display</li>
-      </ul>
-    </dd>
-
-    <dt><span class="part-name">infocmp</span>
-    </dt>
-
-    <dd>
-      <ul>
-        <li>omit filtering of &ldquo;<tt>OTxx</tt>&rdquo; names
-        which are used for obsolete capabilities, when the output
-        is sorted by long-names. This change helps when making a
-        table of the short/long capability names.</li>
-      </ul>
-    </dd>
-
-    <dt><span class="part-name">tic</span>
-    </dt>
-
-    <dd>
-      <ul>
-        <li>added check for consistent alternate character set
-        capabilities.</li>
-
-        <li>added check for paired <tt>indn</tt>/<tt>rin</tt>.</li>
-
-        <li>added check for terminals with <tt>parm_dch</tt> vs
-        <tt>parm_ich</tt>.</li>
-
-        <li>added check for the case where
-        <tt>setf</tt>/<tt>setb</tt> are given using different
-        strings, but provide identical results to
-        <tt>setaf</tt>/<tt>setab</tt>.</li>
-
-        <li>corrected check for <tt>ich1</tt>.</li>
-
-        <li>changed a too-large terminal entry from a fatal error
-        to a warning.</li>
-      </ul>
-    </dd>
-
-    <dt><span class="part-name">toe</span>
-    </dt>
-
-    <dd>
-      <ul>
-        <li>ignores any hex/b64 <tt>$TERMINFO</tt> value in the
-        list of terminfo databases.</li>
-      </ul>
-    </dd>
-
-    <dt><span class="part-name">tset</span>
-    </dt>
-
-    <dd>
-      <ul>
-        <li>replace check in <span class="part-name">reset</span>
-        command for obsolete &ldquo;<tt>pt</tt>&rdquo; capability
-        using <tt>tbc</tt> and <tt>hts</tt> capabilities as
-        clues</li>
-
-        <li>modify <span class="part-name">reset</span> to allow
-        for tabstops at intervals other than 8.</li>
-
-        <li>change <span class="part-name">reset</span>'s behavior
-        for margins to simply clear soft-margins if possible,
-        rather than clearing and then setting them according to the
-        terminal's width.</li>
-      </ul>
-    </dd>
-
-    <dt><span class="part-name">tput</span>
-    </dt>
-
-    <dd>
-      <ul>
-        <li>add &ldquo;<tt>x</tt>&rdquo; to <tt>getopt</tt> string
-        so that &ldquo;<tt>tput&nbsp;-x&nbsp;clear</tt>&rdquo;
-        works.</li>
-      </ul>
-    </dd>
-  </dl>
-
-  <p>Several changes were made to the generated ncurses*config
-  scripts and the analogous &ldquo;<tt>.pc</tt>&rdquo; files to
-  reduce differences between the configurations they report:</p>
-
-  <ul>
-    <li>
-      <p>modified the ncurse*-config and pc-files to more closely
-      match for the <tt>-I</tt> and <tt>-l</tt> options.</p>
-    </li>
-
-    <li>
-      <p>filtered out linker-specs from the <tt>--libs</tt>
-      report.</p>
-    </li>
-
-    <li>
-      <p>amended the ncurses*-config and pc-files to take into
-      account the rpath hack which differed between those
-      files.</p>
-    </li>
-
-    <li>
-      <p>modified generated ncurses*config and ncurses.pc,
-      ncursesw.pc, etc., to list helper libraries such as gpm for
-      static linking.</p>
-    </li>
-  </ul>
-
-  <h4><a name="h4-examples" id="h4-examples">Examples</a></h4>
-
-  <p>Along with the library and utilities, improvements were made
-  to the <a href=
-  "https://invisible-island.net/ncurses/ncurses-examples.html">ncurses-examples</a>.
-  Most of this activity aimed at improving the test-packages. A few
-  changes are more generally useful, e.g., for the main ncurses
-  test-program, and for analyzing traces using the
-  <em>tracemunch</em> script:</p>
-
-  <ul>
-    <li>
-      <p>improve recovery from error when reading command-character
-      in <tt>test/ncurses.c</tt>, showing the relevant error
-      message and not exiting on EINTR.</p>
-    </li>
-
-    <li>
-      <p>improve <em>tracemunch</em>, by keeping track of
-      <tt>TERMINAL*</tt> values, and if tracing was first turned on
-      after initialization, attempt to show distinct screen, window
-      and terminal names anyway.</p>
-    </li>
-
-    <li>
-      <p>modify <em>tracemunch</em> to accept filename parameters
-      in addition to use as a pipe/filter.</p>
-    </li>
-
-    <li>
-      <p>update <em>tracemunch</em> to work with <em>perl
-      5.26.2</em>, which changed the rules for escaping regular
-      expressions.</p>
-    </li>
-
-    <li>
-      <p>add some checks in <em>tracemunch</em> for undefined
-      variables.</p>
-    </li>
-
-    <li>
-      <p>modify <tt>TurnOn</tt>/<tt>TurnOff</tt> macros (in
-      lib_vidattr.c and lib_vid_attr.c) to avoid expansion of
-      &ldquo;<tt>CUR</tt>&rdquo; in trace.</p>
-    </li>
-  </ul>
-
-  <p>There are other new demo/test programs and reusable
-  examples:</p>
-
-  <dl>
-    <dt><span class="part-name">color_content</span>
-    </dt>
-
-    <dd>Demonstrate the <tt>color_content</tt> and
-    <tt>extended_color_content</tt> functions.</dd>
-
-    <dt><span class="part-name">demo_tabs</span>
-    </dt>
-
-    <dd>A simple demo of tabs in curses.</dd>
-
-    <dt><span class="part-name">dump_window</span>
-    </dt>
-
-    <dd>A portable curses screen-dump, used to compare ncurses
-    screen contents with Solaris.</dd>
-
-    <dt><span class="part-name">pair_content</span>
-    </dt>
-
-    <dd>Demonstrate the <tt>pair_content</tt> and
-    <tt>extended_pair_content</tt> functions.</dd>
-
-    <dt><span class="part-name">report_hashing</span>
-    </dt>
-
-    <dd>Check hash-tables used for terminfo and termcap names.</dd>
-
-    <dt><span class="part-name">parse_rgb</span>
-    </dt>
-
-    <dd>Sample implementation of the ncurses RGB extension from
-    <a href=
-    "https://invisible-island.net/ncurses/man/user_caps.5.html">user_caps.5</a>,
-    used in <em>picsmap</em> and <em>savescreen</em> programs.</dd>
-  </dl>
-
-  <p>A variety of improvements were made to existing programs, both
-  new features as well as options added to make the set of programs
-  more consistent.</p>
-
-  <ul>
-    <li>
-      <p>add &ldquo;<tt>-l</tt>&rdquo; option to test/background,
-      to dump screen contents in a form that lets different curses
-      implementations be compared.</p>
-    </li>
-
-    <li>
-      <p>add &ldquo;<tt>@</tt>&rdquo; command to test/ncurses
-      F-test, to allow rapid jump to different character pages.</p>
-    </li>
-
-    <li>
-      <p>added enum, regex examples to test/demo_forms</p>
-    </li>
-
-    <li>
-      <p>amend Scaled256() macro in test/picsmap.c to cover the
-      full range 0..1000</p>
-    </li>
-
-    <li>
-      <p>corrected pathname used in Ada95 sample programs for
-      <tt>explain.txt</tt>, to work with test-packages, and used an
-      awk script to split the resulting pathname when it would be
-      too long for a single line.</p>
-    </li>
-
-    <li>
-      <p>ignore interrupted system-call in test/ncurses's
-      command-line, e.g., if the terminal were resized.</p>
-    </li>
-
-    <li>
-      <p>improved ifdef's for <tt>TABSIZE</tt> variable, to help
-      with AIX/HPUX ports.</p>
-    </li>
-  </ul>
-
-  <h3><a name="h3-database" id="h3-database">Terminal database</a></h3>
-
-  <p>There are several new terminal descriptions:</p>
-
-  <blockquote style="word-break:keep-all">
-    <p><tt>alacritty</tt>, <tt>domterm</tt>, <tt>kitty</tt>,
-    <tt>mintty</tt>, <tt>mintty-direct</tt>, <tt>ms-terminal</tt>,
-    <tt>n7900</tt>, <tt>nsterm-build309</tt>,
-    <tt>nsterm-direct</tt>, <tt>screen5</tt>, <tt>ti703</tt>,
-    <tt>ti707</tt>, <tt>ti703-w</tt>, <tt>ti707-w</tt>
-    <tt>vscode</tt>, <tt>vscode-direct</tt>, <tt>xterm-mono</tt>,
-    <tt>xterm.js</tt></p>
-  </blockquote>
-
-  <p>There are many changes to existing terminal descriptions. Some
-  were updates to several descriptions:</p>
-
-  <ul>
-    <li>use <a href=
-    "/ncurses/terminfo.src.html#tic-ansi_rep"><tt>ansi+rep</tt></a>
-    in a dozen places</li>
-
-    <li>add rs1 to konsole, mlterm</li>
-
-    <li>improve several flash capabilities with trailing mandatory
-    delays</li>
-
-    <li>drop <tt>ich1</tt> from <tt>rxvt-basic</tt>, <tt>Eterm</tt>
-    and <tt>mlterm</tt> to improve compatibility with old
-    non-curses programs</li>
-
-    <li>add/use <a href=
-    "/ncurses/terminfo.src.html#tic-xterm_keypad"><tt>xterm+keypad</tt></a>
-    in <tt>xterm-new</tt></li>
-
-    <li>use <a href=
-    "/ncurses/terminfo.src.html#tic-xterm_sl-twm"><tt>xterm+sl-twm</tt></a>
-    for consistency, nine places</li>
-
-    <li>improve <em>xm</em> example in <a href=
-    "/ncurses/terminfo.src.html#tic-xterm_x11mouse">xterm+x11mouse</a>
-    and <a href=
-    "/ncurses/terminfo.src.html#tic-xterm_sm_1006">xterm+sm_1006</a>.</li>
-  </ul>
-
-  <p>while others affected specific descriptions. These were
-  retested, to take into account changes by their developers:</p>
-
-  <blockquote>
-    <p><tt>terminator</tt>, <tt>st</tt></p>
-  </blockquote>
-
-  <p>while these are specific fixes based on reviewing
-  documentation, user reports, or warnings from <span class=
-  "part-name">tic</span>:</p>
-
-  <dl>
-    <dt><a href=
-    "/ncurses/terminfo.src.html#tic-adds200">adds200</a>:</dt>
-
-    <dd>
-      <ul>
-        <li>fix typo</li>
-      </ul>
-    </dd>
-
-    <dt><a href=
-    "/ncurses/terminfo.src.html#tic-gnome-256color">gnome-256color</a>
-    </dt>
-
-    <dd>
-      <ul>
-        <li>base entry on "gnome", not "vte", for consistency</li>
-      </ul>
-    </dd>
-
-    <dt><a href=
-    "/ncurses/terminfo.src.html#tic-interix">interix</a>
-    </dt>
-
-    <dd>
-      <ul>
-        <li>trim unnecessary setf/setb</li>
-      </ul>
-    </dd>
-
-    <dt><a href=
-    "/ncurses/terminfo.src.html#tic-linux-16color">linux-16color</a>
-    </dt>
-
-    <dd>
-      <ul>
-        <li>accommodate <a href=
-        "https://lists.gnu.org/archive/html/bug-ncurses/2019-10/msg00061.html">
-        Linux console driver</a> incompatibility introduced in
-        early 2018</li>
-      </ul>
-    </dd>
-
-    <dt><a href=
-    "/ncurses/terminfo.src.html#tic-nsterm-256color">nsterm-256color</a>:</dt>
-
-    <dd>
-      <ul>
-        <li>add nsterm-build309 to replace nsterm-256color,
-        assigning the latter as an alias of nsterm, to make mouse
-        work with nsterm-256color</li>
-      </ul>
-    </dd>
-
-    <dt><a href=
-    "/ncurses/terminfo.src.html#tic-regent40">regent40</a>:</dt>
-
-    <dd>
-      <ul>
-        <li>renumber function-keys to match manual</li>
-      </ul>
-    </dd>
-
-    <dt><a href=
-    "/ncurses/terminfo.src.html#tic-regent60">regent60</a>:</dt>
-
-    <dd>
-      <ul>
-        <li>add cd (clr_eos)</li>
-
-        <li>corrected acsc</li>
-
-        <li>add shifted function-keys</li>
-      </ul>
-    </dd>
-
-    <dt><a href=
-    "/ncurses/terminfo.src.html#tic-tvi950">tvi950</a>:</dt>
-
-    <dd>
-      <ul>
-        <li>added function-key definitions to agree with Televideo
-        950 manual</li>
-
-        <li>corrected acsc</li>
-
-        <li>remove bogus kf0</li>
-
-        <li>add bel</li>
-      </ul>
-    </dd>
-
-    <dt><a href=
-    "/ncurses/terminfo.src.html#tic-tvi955">tvi955</a>:</dt>
-
-    <dd>
-      <ul>
-        <li>fix typo</li>
-      </ul>
-    </dd>
-
-    <dt><a href=
-    "/ncurses/terminfo.src.html#tic-vi200">vi200</a>:</dt>
-
-    <dd>
-      <ul>
-        <li>add acsc string, including right/down-arrow</li>
-      </ul>
-    </dd>
-
-    <dt><a href=
-    "/ncurses/terminfo.src.html#tic-wy50">wy50</a>:</dt>
-
-    <dd>
-      <ul>
-        <li>corrected acsc</li>
-      </ul>
-    </dd>
-
-    <dt><a href="/ncurses/terminfo.src.html#tic-wy50">wy50</a> and
-    <a href="/ncurses/terminfo.src.html#tic-wy60">wy60</a>:</dt>
-
-    <dd>
-      <ul>
-        <li>add shifted function-keys as kF1 to kF16</li>
-      </ul>
-    </dd>
-
-    <dt><a href=
-    "/ncurses/terminfo.src.html#tic-xterm_x11hilite">xterm+x11hilite</a>:</dt>
-
-    <dd>
-      <ul>
-        <li>eliminate unused <em>p5</em> parameter.</li>
-      </ul>
-    </dd>
-  </dl>
-
-  <p>A few entries use extensions (user-defined terminal
-  capabilities):</p>
-
-  <ul>
-    <li>use <a href=
-    "/ncurses/terminfo.src.html#tic-xterm_sm_1006"><tt>xterm+sm+1006</tt></a>
-    (aka &ldquo;SGR 1006 mouse&rdquo;) for konsole-base and
-    putty</li>
-
-    <li>add <em><tt>Smol/Rmol</tt></em> user-defined capability to
-    <tt>tmux</tt> and <tt>vte-2018</tt></li>
-
-    <li>add <em><tt>Smulx</tt></em> user-defined capability to
-    <tt>tmux</tt>, <tt>vte-2018</tt></li>
-  </ul>
-
-  <h3><a name="h3-documentation" id=
-  "h3-documentation">Documentation</a></h3>
-
-  <p>As usual, this release</p>
-
-  <ul>
-    <li>
-      <p>improves documentation by describing new features,</p>
-    </li>
-
-    <li>
-      <p>attempts to improve the description of features which
-      users have found confusing</p>
-    </li>
-
-    <li>
-      <p>fills in overlooked descriptions of features which were
-      described in the <a href=
-      "https://invisible-island.net/ncurses/NEWS.html">NEWS</a>
-      file but treated sketchily in manual pages.</p>
-    </li>
-  </ul>
-
-  <p>In addition to providing background information to explain
-  these features and show how they evolved, there are corrections,
-  clarifications, etc.:</p>
-
-  <ul>
-    <li>
-      <p>Corrections:</p>
-
-      <ul>
-        <li>correct error-returns listed in manual pages for a few
-        form functions</li>
-
-        <li>corrected prototypes in several manpages using script
-        to extract those in compilable form.</li>
-
-        <li>fix typo in <a href=
-        "https://invisible-island.net/ncurses/man/term.5.html#h3-EXTENDED-NUMBER-FORMAT">
-        term.5</a>, improve explanation of format</li>
-      </ul>
-    </li>
-
-    <li>
-      <p>Clarify in manual pages that <a href=
-      "https://invisible-island.net/ncurses/man/curs_printw.3x.html#h2-PORTABILITY">
-      vwprintw</a> and <a href=
-      "https://invisible-island.net/ncurses/man/curs_scanw.3x.html#h2-PORTABILITY">
-      vwscanw</a> are obsolete.<br>
-      They have not been part of X/Open Curses since 2007.</p>
-    </li>
-
-    <li>
-      <p>New/improved history and portability sections:</p>
-
-      <ul>
-        <li><a href=
-        "https://invisible-island.net/ncurses/man/curs_addch.3x.html#h3-ACS-Symbols">
-        curs_addch.3x</a> gives some background for ACS
-        symbols.</li>
-
-        <li><a href=
-        "https://invisible-island.net/ncurses/man/curs_getcchar.3x.html#h2-PORTABILITY">
-        curs_getcchar.3x</a> explains a difference between ncurses
-        and X/Open Curses.</li>
-
-        <li><a href=
-        "https://invisible-island.net/ncurses/man/curs_getstr.3x.html#h2-PORTABILITY">
-        curs_getstr.3x</a> gives historical/portability background
-        for the length parameter of <tt>wgetnstr</tt>.</li>
-
-        <li><a href=
-        "https://invisible-island.net/ncurses/man/curs_slk.3x.html">
-        curs_slk.3x</a> lists a few differences between SVr4 curses
-        and X/Open Curses for soft-keys.</li>
-
-        <li><a href=
-        "https://invisible-island.net/ncurses/man/curs_terminfo.3x.html">
-        curs_terminfo.3x</a> explains that the initial
-        implementation of terminfo in SVr2 was mostly replaced by
-        other developers in SVr3.</li>
-
-        <li><a href=
-        "https://invisible-island.net/ncurses/man/infocmp.1m.html">infocmp.1</a>
-        explains that the initial version of terminfo had no tool
-        for decompiling descriptions. That came later, with SVr3,
-        with a different developer.</li>
-
-        <li><a href=
-        "https://invisible-island.net/ncurses/man/tabs.1.html">tabs.1</a>
-        tells more than you wanted to know about the tool.</li>
-
-        <li><a href=
-        "https://invisible-island.net/ncurses/man/tic.1m.html">tic.1</a>
-        explains that the initial version of terminfo had a
-        rudimentary tool (based on termcap) for compiling entries.
-        The tool used with Unix was developed by others for
-        SVr3.</li>
-
-        <li><a href=
-        "https://invisible-island.net/ncurses/man/toe.1m.html">toe.1</a>
-        explains the origin of this tool.</li>
-      </ul>
-    </li>
-
-    <li>
-      <p>Improvements for <a href=
-      "https://invisible-island.net/ncurses/man/user_caps.5.html">user_caps.5</a>:</p>
-
-      <ul>
-        <li>mention <tt>meml</tt>, <tt>memu</tt> and
-        <tt>box1</tt></li>
-
-        <li>expanded description of <tt>XM</tt></li>
-
-        <li>add a clarification regarding the <tt>RGB</tt>
-        capability.</li>
-
-        <li>mention user_caps.5 in the tic and infocmp manual
-        pages.</li>
-      </ul>
-    </li>
-
-    <li>
-      <p>Other improvements:</p>
-
-      <ul>
-        <li><a href=
-        "https://invisible-island.net/ncurses/man/curs_add_wch.3x.html#h3-Line-Graphics">
-        curs_add_wch.3x</a> adds note about Unicode terminology for
-        the line-drawing characters.</li>
-
-        <li><a href=
-        "https://invisible-island.net/ncurses/man/curs_color.3x.html#h2-RETURN-VALUE">
-        curs_color.3x</a> improves discussion of error returns and
-        extensions.</li>
-
-        <li><a href=
-        "https://invisible-island.net/ncurses/man/curs_mouse.3x.html">
-        curs_mouse.3x</a> explains how the <tt>kmous</tt> and
-        <tt>XM</tt> capabilities are used for xterm-mouse
-        input.</li>
-
-        <li><a href=
-        "https://invisible-island.net/ncurses/man/curs_refresh.3x.html#h3-wnoutrefresh_doupdate">
-        curs_refresh.3x</a> improves documentation regarding the
-        virtual and physical screens.</li>
-
-        <li><a href=
-        "https://invisible-island.net/ncurses/man/curs_util.3x.html">
-        curs_util.3x</a> mentions a difference between SVr4 and
-        X/Open Curses for <tt>unctrl.h</tt></li>
-
-        <li><a href=
-        "https://invisible-island.net/ncurses/man/curs_variables.3x.html#h2-PORTABILITY">
-        curs_variables.3x</a> improves description of the
-        <em>init_tabs</em> capability and <tt>TABSIZE</tt>
-        variable.</li>
-
-        <li><a href=
-        "https://invisible-island.net/ncurses/man/ncurses.3x.html#h2-ALTERNATE-CONFIGURATIONS">
-        ncurses.3x</a> improves documentation regarding
-        feature-test macros in curses.h</li>
-
-        <li><a href=
-        "https://invisible-island.net/ncurses/man/resizeterm.3x.html#h3-resize_term">
-        resizeterm.3x</a> about top-level windows which touch the
-        screen's borders.</li>
-
-        <li><a href=
-        "https://invisible-island.net/ncurses/man/tput.1.html#h3-Terminal-Size">
-        tput.1</a> clarifies how <em>tput</em> determines the
-        terminal size.</li>
-      </ul>
-    </li>
-  </ul>
-
-  <p>There are no new manual pages (all of the manual page updates
-  are to existing pages).</p>
-
-  <p>Some of the improvements are more subtle, relating to the way
-  the information is presented. For instance, the generated
-  terminfo.5 file uses a different table layout, allowing it to use
-  space on wide terminals more effectively.</p>
-
-  <h3><a name="h3-bug-fixes" id="h3-bug-fixes">Interesting
-  bug-fixes</a></h3>
-
-  <p>While there were many bugs fixed during development of ncurses
-  6.2, only a few (the reason for this release) were both important
-  and interesting. Most of the bug-fixes were for local issues
-  which did not affect compatibility across releases. Since those
-  are detailed in the NEWS file no elaboration is needed here.</p>
-
-  <p>The interesting bugs were in tic/infocmp's handling of
-  user-defined capabilities. These were not recent bugs. Initially
-  it was a simple problem:</p>
-
-  <ul>
-    <li>The user-defined capabilities can be any type (boolean,
-    number or string), but once given a type all uses of the name
-    must conform to that type&mdash;unless some special support for
-    a particular multi-typed name is built into ncurses.</li>
-
-    <li>
-      <p>One of simpleterm's contributors copied some definitions
-      for using <em>tmux</em>'s user-defined capabilities in
-      <a href=
-      "https://git.suckless.org/st/commit/06f8cf8ca87a81db15816658c40b2afcd1ad5332.html">
-      late in 2016</a>.</p>
-
-      <blockquote>
-        <pre class="demo-name">
-diff --git a/st.info b/st.info
-@@ -185,7 +185,10 @@ st| simpleterm,
-  tsl=\E]0;,
-  xenl,
-  vpa=\E[%i%p1%dd,
--
-+# Tmux unofficial extensions, see TERMINFO EXTENSIONS in tmux(1)
-+ Se,
-+ Ss,
-+ Tc,
- 
- st-256color| simpleterm with 256 colors,
-  use=st,
-</pre>
-      </blockquote>
-    </li>
-
-    <li>
-      <p>Later, in (referring to a version from <a href=
-      "https://git.suckless.org/st/commit/c0882f2ed1d7a2dd0fa2efa52157e6fc6fde3652.html">
-      mid-2017</a>), a user asked to have it updated in
-      ncurses.</p>
-    </li>
-
-    <li>
-      <p>However, it had an error from the change in late 2016. The
-      terminal description made what <em>tmux</em> expected to be
-      <strong>string</strong> actually a
-      <strong>boolean</strong>.</p>
-
-      <p>Over the years, there were problems with each of
-      simpleterm's terminal descriptions. I repaired those, and
-      usually dealt with the problem.</p>
-    </li>
-
-    <li>
-      <p>The difference in this case was that when compiling the
-      terminal database, <em>tic</em> may have in memory the
-      definitions for more than one terminal description (so that
-      it can resolve &ldquo;<tt>use=</tt>&rdquo; clauses). Seeing
-      two different types for the same name, in certain situations
-      it would incorrectly merge the symbol tables for the two
-      terminal descriptions.</p>
-    </li>
-
-    <li>
-      <p>On simpleterm's side, their bug was finally fixed in
-      <a href=
-      "https://git.suckless.org/st/commit/83866428de031300eab03fbb116bcf7d2b1d4f60.html">
-      late 2019</a>, three years after the bug was created.</p>
-    </li>
-  </ul>
-
-  <p>For ncurses, the elapsed time to fix this bug was less than
-  three years. Someone reported a problem with the terminal
-  description a few weeks after releasing ncurses 6.1 (in <a href=
-  "https://github.com/tmux/tmux/issues/1264">tmux #1264</a>), and
-  the terminal description was updated that week (ncurses patch
-  <a href=
-  "https://invisible-island.net/ncurses/NEWS.html#t20180224">20180224</a>):</p>
-
-  <blockquote>
-    <pre class="demo-name">
-20180224
-        + modify _nc_resolve_uses2() to detect incompatible types when merging
-          a "use=" clause of extended capabilities.  The problem was seen in a
-          defective terminfo integrated from simpleterm sources in 20171111,
-          compounded by repair in 20180121.
-        + correct Ss/Ms interchange in st-0.7 entry (tmux #1264) -TD
-</pre>
-  </blockquote>
-
-  <p>The larger part of that change added a check to prevent a
-  simple merge of terminal descriptions where the same user-defined
-  name was used with different types. But it raised some
-  questions:</p>
-
-  <ul>
-    <li>
-      <p>Was there a reliable way to manage terminal descriptions
-      which used the same extended name in different ways?</p>
-    </li>
-
-    <li>
-      <p>Should ncurses provide a registry of well-known extended
-      names, with their types?</p>
-    </li>
-  </ul>
-
-  <p>Since the correction to <a href=
-  "https://invisible-island.net/ncurses/ncurses.html#download_database">
-  <tt>terminfo.src</tt></a> could have been readily adopted by
-  packagers, there was nothing more to be done from ncurses'
-  standpoint on that part. But improving ncurses to prevent issues
-  like that is the reason for making a release.</p>
-
-  <p>Nothing more (constructive) was mentioned with regard to
-  simpleterm. But a few problems were found in the handling of
-  user-defined capabilities:</p>
-
-  <ul>
-    <li>
-      <p>Forward-references to user-defined capabilities in a
-      &ldquo;<tt>use=</tt>&rdquo; clause did not allocate new data
-      for each use. In <em>tic</em>, successive compilation of
-      terminal entries could add user-defined capabilities to the
-      wrong terminal entry.</p>
-
-      <p>This was not noticed before, since xterm's terminal
-      descriptions were the main users of the feature, and almost
-      all of the uses of the building-blocks which contained
-      user-defined capabilities were backward-references.</p>
-    </li>
-
-    <li>
-      <p>There is one (documented) case where ncurses 6.1 supports
-      a user-defined capability that could be any type (i.e.,
-      &ldquo;RGB&rdquo;). The check added in February 2018 to guard
-      against mismatches did not handle all of the combinations
-      needed.</p>
-    </li>
-  </ul>
-
-  <p>Both of these issues dated from the original implementation of
-  user-defined capabilities. Fixing them does not change the
-  terminal database, but a older <em>tic</em> without the fixes
-  will not be able to handle terminfo sources which rely upon those
-  fixes. Starting in June 2019, the download link for the terminfo
-  source file was capped at that date. The development sources have
-  an up-to-date copy of the file, for people with a legitimate need
-  for it.</p>
-
-  <p>The &ldquo;<tt>-c</tt>&rdquo; (check) option of <em>tic</em>
-  is not very useful if it cannot offer advice on parameters needed
-  for user-defined capabilities. The various <em>Caps</em> files
-  were reorganized to reduce redundancy, and in the common portion
-  (<a href=
-  "https://github.com/ThomasDickey/ncurses-snapshots/blob/master/include/Caps-ncurses">Caps-ncurses</a>),
-  a registry of user-defined capabilities is provided for use by
-  <em>tic</em>. While users can still define their own custom
-  capabilities, <em>tic</em> will not offer any advice when their
-  parameters do not match.</p>
-
-  <p>In ncurses 6.2, <em>tic</em> makes a special check to allow
-  any type for <em>RGB</em>, but its being able to do this relies
-  upon fixes made in the ncurses library in mid-2019.</p>
-
-  <h3><a name="h3-config-config" id=
-  "h3-config-config">Configuration changes</a></h3>
-
-  <h4><a name="h4-config-major" id="h4-config-major">Major
-  changes</a></h4>
-
-  <p>There are no major changes. Several new options were added to
-  ease integration of packages with systems using different
-  versions of <em>GNAT</em> and <em>ncurses</em>. Also,
-  improvements were made to configure checks.</p>
-
-  <h4><a name="h4-config-options" id=
-  "h4-config-options">Configuration options</a></h4>
-
-  <p>There are a few new/modified configure options:</p>
-
-  <dl>
-    <dt><tt>--with-config-suffix</tt>
-    </dt>
-
-    <dd>
-      <p>helps work around a filename conflict with Debian packages
-      versus test-packages.</p>
-    </dd>
-
-    <dt><tt>--with-ada-libname</tt>
-    </dt>
-
-    <dd>
-      <p>allows one to rename the &ldquo;AdaCurses&rdquo; library
-      (at least one packager prefers a lowercase name).</p>
-    </dd>
-
-    <dt><tt>--with-fallbacks</tt>
-    </dt>
-
-    <dd>
-      <p>now ensures there is a value, and adds the fallback
-      information to top-level Makefile summary.</p>
-    </dd>
-
-    <dt><tt>--with-pcre2</tt>
-    </dt>
-
-    <dd>
-      <p>check for pcre-posix library to help with MinGW port.</p>
-    </dd>
-
-    <dt><tt>--with-tic-path</tt> and<br></dt>
-
-    <dt><tt>--with-infocmp-path</tt>
-    </dt>
-
-    <dd>
-      <p>help work around problems building fallback source using
-      pre-6.0 tic/infocmp.</p>
-    </dd>
-
-    <dt><tt>--with-versioned-syms</tt>
-    </dt>
-
-    <dd>
-      <p>option value can now be a relative pathname.</p>
-    </dd>
-  </dl>
-
-  <h3><a name="h3-portability" id="h3-portability">Portability</a></h3>
-
-  <p>Many of the portability changes are implemented via the
-  configure script:</p>
-
-  <ul>
-    <li>
-      <p>ignore <a href=
-      "/ncurses/man/ncurses.3x.html#h3-TERMINFO"><tt>$TERMINFO</tt></a>
-      as a default value in configure script if it came from the
-      <tt>infocmp</tt> <strong><tt>-Q</tt></strong> option.</p>
-    </li>
-
-    <li>
-      <p>distinguish gcc from icc and clang when the
-      <tt>--enable-warnings</tt> option is not used, to avoid
-      unnecessary warnings about unrecognized inline options</p>
-    </li>
-
-    <li>
-      <p>consistently prepend new libraries as they are found
-      during configuration, rather than relying upon the linker to
-      resolve order dependencies of libraries.</p>
-    </li>
-
-    <li>
-      <p>modified configure scripts to reduce relinking/ranlib
-      during library install :</p>
-
-      <ul>
-        <li>use &ldquo;<tt>install -p</tt>&rdquo; when available,
-        to avoid need for ranlib of static libraries.</li>
-
-        <li>scripts which use
-        &ldquo;<tt>--disable-relink</tt>;&rdquo; add a 1-second
-        sleep to work around tools which use whole-second
-        timestamps, e.g., in <tt>utime</tt> rather than the actual
-        file system resolution.</li>
-      </ul>
-    </li>
-
-    <li>
-      <p id="getenv-check">add configure check for <a href=
-      "#getenv-fixes"><tt>getenv</tt></a> to work around
-      implementation shown in Emscripten which overwrites the
-      previous return value on each call.</p>
-
-      <p>Use that to optionally suppress <tt>START_TRACE</tt>
-      macro, whose call to <tt>getenv</tt> may not work
-      properly</p>
-    </li>
-
-    <li>
-      <p>change target configure level for <tt>_XOPEN_SOURCE</tt>
-      to 600 to address use of <tt>vsscanf</tt> and
-      <tt>setenv</tt>.</p>
-    </li>
-
-    <li>
-      <p>reduce use of <tt>_GNU_SOURCE</tt> for current glibc where
-      <tt>_DEFAULT_SOURCE</tt> combines with
-      <tt>_XOPEN_SOURCE</tt></p>
-
-      <p>Allow for Cygwin's newlib when checking for the
-      _DEFAULT_SOURCE symbol.</p>
-
-      <p>MidnightBSD is now checked for the
-      <tt>_XOPEN_SOURCE</tt>-related definitions.</p>
-    </li>
-
-    <li>
-      <p>If the check for <tt>va_copy</tt> or <tt>__va_copy</tt>
-      fails,</p>
-
-      <ul>
-        <li>configure now tries copying the pointers for
-        <tt>va_list</tt>, or as an array.</li>
-
-        <li>alternatively, it checks for
-        <tt>__builtin_va_copy</tt>(), which could be used with AIX
-        <tt>xlc</tt> in <em>c89</em> mode.</li>
-      </ul>
-    </li>
-
-    <li>
-      <p>several changes to support a port to Ultrix 3.1:</p>
-
-      <ul>
-        <li>check if "b" binary feature of fopen works</li>
-
-        <li>check for missing feature of locale.h</li>
-
-        <li>add fallback for strstr() in test-programs</li>
-
-        <li>add fallback for STDOUT_FILENO in test-programs</li>
-      </ul>
-    </li>
-
-    <li>
-      <p>The <em>test/configure</em> script (used for <a href=
-      "/ncurses/ncurses-examples.html"><em>ncurses-examples</em></a>)
-      is improved:</p>
-
-      <ul>
-        <li>work around non-ncurses termcap.h file, e.g., in
-        Slackware.</li>
-
-        <li>check for <a href=
-        "/ncurses/man/curs_variables.3x.html#h3-TABSIZE"><tt>TABSIZE</tt></a>
-        variable.</li>
-
-        <li>checks for the X11/Intrinsic.h header, accommodate
-        recent MacOS changes which largely emptied
-        <tt>/usr/include</tt>.</li>
-      </ul>
-    </li>
-  </ul>
-
-  <p>Here are some of the other portability fixes:</p>
-
-  <ul>
-    <li>
-      <p>added dummy "check" rule in top-level and test-Makefile to
-      simplify building test-packages for ArchLinux.</p>
-    </li>
-
-    <li>
-      <p>dropped library-dependency on psapi for MinGW port, since
-      win_driver.c defines <tt>PSAPI_VERSION</tt> to 2, making it
-      use <tt>GetProcessImageFileName</tt> from kernel32.dll</p>
-    </li>
-
-    <li>
-      <p>made build-fixes for configuration using --program-suffix
-      with Ada95, noticed with MacOS but applicable to other
-      platforms without libpanelw, etc.</p>
-    </li>
-
-    <li>
-      <p>modified ncurses/Makefile.in to fix a case where
-      Debian/testing changes to the ld --as-needed configuration
-      broke ncurses-examples test packages.</p>
-    </li>
-
-    <li>
-      <p>used <tt>_WIN32</tt>/<tt>_WIN64</tt> in preference to
-      <tt>__MINGW32__</tt>/<tt>__MINGW64__</tt> symbols to simplify
-      building with Microsoft Visual C++, since the former are
-      defined in both compiler configurations.</p>
-    </li>
-  </ul>
-
-  <hr>
-
-  <h2><a name="h2-features" id="h2-features">Features of
-  <span class="main-name">ncurses</span></a></h2>
-
-  <p>The <span class="main-name">ncurses</span> package is fully
-  upward-compatible with SVr4 (System V Release 4) curses:</p>
-
-  <ul>
-    <li>
-      <p>All of the SVr4 calls have been implemented (and are
-      documented).</p>
-    </li>
-
-    <li>
-      <p><span class="main-name">ncurses</span> supports all of the
-      for SVr4 curses features including keyboard mapping, color,
-      forms-drawing with ACS characters, and automatic recognition
-      of keypad and function keys.</p>
-    </li>
-
-    <li>
-      <p><span class="main-name">ncurses</span> provides these SVr4
-      add-on libraries (not part of X/Open Curses):</p>
-
-      <ul>
-        <li>
-          <p>the panels library, supporting a stack of windows with
-          backing store.</p>
-        </li>
-
-        <li>
-          <p>the menus library, supporting a uniform but flexible
-          interface for menu programming.</p>
-        </li>
-
-        <li>
-          <p>the form library, supporting data collection through
-          on-screen forms.</p>
-        </li>
-      </ul>
-    </li>
-
-    <li>
-      <p><span class="main-name">ncurses</span>'s terminal database
-      is fully compatible with that used by SVr4 curses.</p>
-
-      <ul>
-        <li>
-          <p><span class="main-name">ncurses</span> supports
-          user-defined capabilities which it can see, but which are
-          hidden from SVr4 curses applications using the
-          <em>same</em> terminal database.</p>
-        </li>
-
-        <li>
-          <p>It can be optionally configured to match the format
-          used in related systems such as AIX and Tru64.</p>
-        </li>
-
-        <li>
-          <p>Alternatively, <span class="main-name">ncurses</span>
-          can be configured to use hashed databases rather than the
-          directory of files used by SVr4 curses.</p>
-        </li>
-      </ul>
-    </li>
-
-    <li>
-      <p>The <span class="main-name">ncurses</span> utilities have
-      options to allow you to filter terminfo entries for use with
-      less capable <em>curses</em>/<em>terminfo</em> versions such
-      as the HP/UX and AIX ports.</p>
-    </li>
-  </ul>
-
-  <p>The <span class="main-name">ncurses</span> package also has
-  many useful extensions over SVr4:</p>
-
-  <ul>
-    <li>
-      <p>The API is 8-bit clean and base-level conformant with the
-      X/OPEN curses specification, XSI curses (that is, it
-      implements all BASE level features, and most EXTENDED
-      features). It includes many function calls not supported
-      under SVr4 curses (but portability of all calls is documented
-      so you can use the SVr4 subset only).</p>
-    </li>
-
-    <li>
-      <p>Unlike SVr3 curses, <span class="main-name">ncurses</span>
-      can write to the rightmost-bottommost corner of the screen if
-      your terminal has an insert-character capability.</p>
-    </li>
-
-    <li>
-      <p>Ada95 and C++ bindings.</p>
-    </li>
-
-    <li>
-      <p>Support for mouse event reporting with X Window xterm and
-      FreeBSD and OS/2 console windows.</p>
-    </li>
-
-    <li>
-      <p>Extended mouse support via Alessandro Rubini's gpm
-      package.</p>
-    </li>
-
-    <li>
-      <p>The function <code>wresize</code> allows you to resize
-      windows, preserving their data.</p>
-    </li>
-
-    <li>
-      <p>The function <code>use_default_colors</code> allows you to
-      use the terminal's default colors for the default color pair,
-      achieving the effect of transparent colors.</p>
-    </li>
-
-    <li>
-      <p>The functions <code>keyok</code> and
-      <code>define_key</code> allow you to better control the use
-      of function keys, e.g., disabling the <span class=
-      "main-name">ncurses</span> KEY_MOUSE, or by defining more
-      than one control sequence to map to a given key code.</p>
-    </li>
-
-    <li>
-      <p>Support for 256-color terminals, such as modern xterm.</p>
-    </li>
-
-    <li>
-      <p>Support for 16-color terminals, such as <em>aixterm</em>
-      and <em>modern xterm</em>.</p>
-    </li>
-
-    <li>
-      <p>Better cursor-movement optimization. The package now
-      features a cursor-local-movement computation more efficient
-      than either BSD's or System V's.</p>
-    </li>
-
-    <li>
-      <p>Super hardware scrolling support. The screen-update code
-      incorporates a novel, simple, and cheap algorithm that
-      enables it to make optimal use of hardware scrolling,
-      line-insertion, and line-deletion for screen-line movements.
-      This algorithm is more powerful than the 4.4BSD curses
-      <code>quickch</code> routine.</p>
-    </li>
-
-    <li>
-      <p>Real support for terminals with the magic-cookie glitch.
-      The screen-update code will refrain from drawing a highlight
-      if the magic- cookie unattributed spaces required just before
-      the beginning and after the end would step on a non-space
-      character. It will automatically shift highlight boundaries
-      when doing so would make it possible to draw the highlight
-      without changing the visual appearance of the screen.</p>
-    </li>
-
-    <li>
-      <p>It is possible to generate the library with a list of
-      pre-loaded fallback entries linked to it so that it can serve
-      those terminal types even when no terminfo tree or termcap
-      file is accessible (this may be useful for support of
-      screen-oriented programs that must run in single-user
-      mode).</p>
-    </li>
-
-    <li>
-      <p>The <a href=
-      "https://invisible-island.net/ncurses/man/tic.1m.html"><span class="part-name">
-      tic</span></a>/<a href=
-      "https://invisible-island.net/ncurses/man/captoinfo.1m.html">captoinfo</a>
-      utility provided with <span class="main-name">ncurses</span>
-      has the ability to translate many termcaps from the XENIX,
-      IBM and AT&amp;T extension sets.</p>
-    </li>
-
-    <li>
-      <p>A BSD-like <a href=
-      "https://invisible-island.net/ncurses/man/tset.1.html"><span class="part-name">
-      tset</span></a> utility is provided.</p>
-    </li>
-
-    <li>
-      <p>The <span class="main-name">ncurses</span> library and
-      utilities will automatically read terminfo entries from
-      $HOME/.terminfo if it exists, and compile to that directory
-      if it exists and the user has no write access to the system
-      directory. This feature makes it easier for users to have
-      personal terminfo entries without giving up access to the
-      system terminfo directory.</p>
-    </li>
-
-    <li>
-      <p>You may specify a path of directories to search for
-      compiled descriptions with the environment variable
-      TERMINFO_DIRS (this generalizes the feature provided by
-      TERMINFO under stock System V.)</p>
-    </li>
-
-    <li>
-      <p>In terminfo source files, use capabilities may refer not
-      just to other entries in the same source file (as in System
-      V) but also to compiled entries in either the system terminfo
-      directory or the user's $HOME/.terminfo directory.</p>
-    </li>
-
-    <li>
-      <p>The table-of-entries utility <a href=
-      "https://invisible-island.net/ncurses/man/toe.1m.html"><span class="part-name">
-      toe</span></a> makes it easy for users to see exactly what
-      terminal types are available on the system.</p>
-    </li>
-
-    <li>
-      <p>The library meets the XSI requirement that every macro
-      entry point have a corresponding function which may be linked
-      (and will be prototype-checked) if the macro definition is
-      disabled with <code>#undef</code>.</p>
-    </li>
-
-    <li>
-      <p>Extensive documentation is provided (see the <em><a href=
-      "https://invisible-island.net/ncurses/ncurses.faq.html#additional_reading">
-      Additional Reading</a></em> section of the <em><a href=
-      "https://invisible-island.net/ncurses/ncurses.faq.html"><span class="main-name">
-      ncurses</span> FAQ</a></em> for online documentation).</p>
-    </li>
-  </ul>
-
-  <h2><a name="h2-who-uses" id="h2-who-uses">Applications using
-  <span class="main-name">ncurses</span></a></h2>
-
-  <p>The <span class="main-name">ncurses</span> distribution
-  includes a selection of test programs (including a few games).
-  These are available separately as <a href=
-  "https://invisible-island.net/ncurses/ncurses-examples.html">ncurses-examples</a></p>
-
-  <p>The ncurses library has been tested with a wide variety of
-  applications including:</p>
-
-  <blockquote>
-    <dl>
-      <dt><span class="part-name">aptitude</span>
-      </dt>
-
-      <dd>
-        <p>FrontEnd to Apt, the debian package manager</p>
-
-        <p><a href=
-        "https://wiki.debian.org/Aptitude">https://wiki.debian.org/Aptitude</a></p>
-      </dd>
-
-      <dt><span class="part-name">cdk</span>
-      </dt>
-
-      <dd>
-        <p>Curses Development Kit</p>
-
-        <p><a href=
-        "https://invisible-island.net/cdk/">https://invisible-island.net/cdk/</a><br>
-
-        </p>
-      </dd>
-
-      <dt><span class="part-name">ded</span>
-      </dt>
-
-      <dd>
-        <p>directory-editor</p>
-
-        <p><a href=
-        "https://invisible-island.net/ded/">https://invisible-island.net/ded/</a></p>
-      </dd>
-
-      <dt><span class="part-name">dialog</span>
-      </dt>
-
-      <dd>
-        <p>the underlying application used in Slackware's setup,
-        and the basis for similar install/configure applications on
-        many systems.</p>
-
-        <p><a href=
-        "https://invisible-island.net/dialog/">https://invisible-island.net/dialog/</a></p>
-      </dd>
-
-      <dt><span class="part-name">lynx</span>
-      </dt>
-
-      <dd>
-        <p>the text WWW browser</p>
-
-        <p><a href=
-        "https://lynx.invisible-island.net/">https://lynx.invisible-island.net/</a></p>
-      </dd>
-
-      <dt><span class="part-name">mutt</span>
-      </dt>
-
-      <dd>
-        <p>mail utility</p>
-
-        <p><a href="http://www.mutt.org/">http://www.mutt.org/</a></p>
-      </dd>
-
-      <dt><span class="part-name">ncftp</span>
-      </dt>
-
-      <dd>
-        <p>file-transfer utility</p>
-
-        <p><a href=
-        "https://www.ncftp.com/">https://www.ncftp.com/</a></p>
-      </dd>
-
-      <dt><span class="part-name">nvi</span>
-      </dt>
-
-      <dd>
-        <p>New vi uses ncurses.</p>
-
-        <p><a href=
-        "https://sites.google.com/a/bostic.com/keithbostic/vi">https://sites.google.com/a/bostic.com/keithbostic/vi</a><br>
-
-        </p>
-      </dd>
-
-      <dt><span class="part-name">ranger</span>
-      </dt>
-
-      <dd>
-        <p>A console file manager with VI key bindings in
-        <em>Python</em>.</p>
-
-        <p><a href=
-        "https://ranger.github.io/">https://ranger.github.io/</a></p>
-      </dd>
-
-      <dt><span class="part-name">tin</span>
-      </dt>
-
-      <dd>
-        <p>newsreader, supporting color, MIME</p>
-
-        <p><a href="http://www.tin.org/">http://www.tin.org/</a></p>
-      </dd>
-
-      <dt><span class="part-name">vifm</span>
-      </dt>
-
-      <dd>
-        <p>File manager with vi like keybindings</p>
-
-        <p><a href="https://vifm.info/">https://vifm.info/</a></p>
-      </dd>
-    </dl>
-  </blockquote>
-
-  <p>as well as some that use <span class=
-  "main-name">ncurses</span> for the terminfo support alone:</p>
-
-  <blockquote>
-    <dl>
-      <dt><span class="part-name">minicom</span>
-      </dt>
-
-      <dd>
-        <p>terminal emulator for serial modem connections</p>
-
-        <p><a href=
-        "https://alioth.debian.org/projects/minicom/">https://alioth.debian.org/projects/minicom/</a></p>
-      </dd>
-
-      <dt><span class="part-name">mosh</span>
-      </dt>
-
-      <dd>
-        <p>a replacement for <code>ssh</code>.</p>
-
-        <p><a href=
-        "https://mosh.mit.edu/">https://mosh.mit.edu/</a></p>
-      </dd>
-
-      <dt><span class="part-name">tack</span>
-      </dt>
-
-      <dd>
-        <p>terminfo action checker</p>
-
-        <p><a href=
-        "https://invisible-island.net/ncurses/tack.html">https://invisible-island.net/ncurses/tack.html</a></p>
-      </dd>
-
-      <dt><span class="part-name">tmux</span>
-      </dt>
-
-      <dd>
-        <p>terminal multiplexor</p>
-
-        <p><a href=
-        "https://github.com/tmux/tmux/wiki">https://github.com/tmux/tmux/wiki</a></p>
-      </dd>
-
-      <dt><span class="part-name">vile</span>
-      </dt>
-
-      <dd>
-        <p><em>vi-like-emacs</em> may be built to use the terminfo,
-        termcap or curses interfaces.</p>
-
-        <p><a href=
-        "https://invisible-island.net/vile/">https://invisible-island.net/vile/</a></p>
-      </dd>
-    </dl>
-  </blockquote>
-
-  <p>and finally, those which use only the termcap interface:</p>
-
-  <blockquote>
-    <dl>
-      <dt><span class="part-name">emacs</span>
-      </dt>
-
-      <dd>
-        <p>text editor</p>
-
-        <p><a href=
-        "https://www.gnu.org/software/emacs/">https://www.gnu.org/software/emacs/</a></p>
-      </dd>
-
-      <dt><span class="part-name">less</span>
-      </dt>
-
-      <dd>
-        <p>The most commonly used <em>pager</em> (a program that
-        displays text files).</p>
-
-        <p><a href=
-        "http://www.greenwoodsoftware.com/less/">http://www.greenwoodsoftware.com/less/</a></p>
-      </dd>
-
-      <dt><span class="part-name">screen</span>
-      </dt>
-
-      <dd>
-        <p>terminal multiplexor</p>
-
-        <p><a href=
-        "https://www.gnu.org/software/screen/">https://www.gnu.org/software/screen/</a></p>
-      </dd>
-
-      <dt><span class="part-name">vim</span>
-      </dt>
-
-      <dd>
-        <p>text editor</p>
-
-        <p><a href="https://www.vim.org/">https://www.vim.org/</a></p>
-      </dd>
-    </dl>
-  </blockquote>
-
-  <h2><a name="h2-development" id="h2-development">Development
-  activities</a></h2>
-
-  <p>Zeyd Ben-Halim started <span class="main-name">ncurses</span>
-  from a previous package pcurses, written by Pavel Curtis. Eric S.
-  Raymond continued development. J&uuml;rgen Pfeifer wrote most of
-  the form and menu libraries.</p>
-
-  <p>Ongoing development work is done by <a href=
-  "mailto:dickey@invisible-island.net">Thomas E. Dickey</a>. Thomas
-  E. Dickey has acted as the maintainer for the Free Software
-  Foundation, which holds a <a href=
-  "https://invisible-island.net/ncurses/ncurses-license.html">copyright
-  on ncurses</a> for releases 4.2 through 6.1. Following the
-  release of ncurses 6.1, effective as of release 6.2, copyright
-  for ncurses reverted to Thomas E. Dickey (see the <a href=
-  "https://invisible-island.net/ncurses/ncurses.faq.html#relicensed">
-  ncurses FAQ</a> for additional information).</p>
-
-  <p>Contact the current maintainers at</p>
-
-  <blockquote>
-    <a href="mailto:bug-ncurses@gnu.org">bug-ncurses@gnu.org</a>
-  </blockquote>
-
-  <p>To join the ncurses mailing list, please write email to</p>
-
-  <blockquote>
-    <a href=
-    "mailto:bug-ncurses-request@gnu.org">bug-ncurses-request@gnu.org</a>
-  </blockquote>
-  containing the line:
-
-  <blockquote>
-    <p><code>subscribe</code>
-    <em>&lt;name&gt;@&lt;host.domain&gt;</em></p>
-  </blockquote>
-
-  <p>This list is open to anyone interested in helping with the
-  development and testing of this package.</p>
-
-  <p>Beta versions of <span class="main-name">ncurses</span> are
-  made available at</p>
-
-  <blockquote>
-    <p><a href=
-    "ftp://ftp.invisible-island.net/ncurses/current/">ftp://ftp.invisible-island.net/ncurses/current/</a>
-    and<br>
-    <a href=
-    "https://invisible-mirror.net/archives/ncurses/current/">https://invisible-mirror.net/archives/ncurses/current/</a>&nbsp;.</p>
-  </blockquote>
-
-  <p>Patches to the current release are made available at</p>
-
-  <blockquote>
-    <p><a href=
-    "ftp://ftp.invisible-island.net/ncurses/6.1/">ftp://ftp.invisible-island.net/ncurses/6.1/</a>
-    and<br>
-    <a href=
-    "https://invisible-mirror.net/archives/ncurses/6.1/">https://invisible-mirror.net/archives/ncurses/6.1/</a>&nbsp;.</p>
-  </blockquote>
-
-  <p>There is an archive of the mailing list here:</p>
-
-  <blockquote>
-    <p><a href=
-    "http://lists.gnu.org/archive/html/bug-ncurses">http://lists.gnu.org/archive/html/bug-ncurses</a>
-    (also <a href=
-    "https://lists.gnu.org/archive/html/bug-ncurses">https</a>)</p>
-  </blockquote>
-
-  <h2><a name="h2-this-stuff" id="h2-this-stuff">Related
-  resources</a></h2>
-
-  <p>The release notes make scattered references to these pages,
-  which may be interesting by themselves:</p>
-
-  <ul>
-    <li><a href=
-    "https://invisible-island.net/ncurses/ncurses-license.html"><span class="main-name">
-    ncurses</span> licensing</a></li>
-
-    <li><a href=
-    "https://invisible-island.net/ncurses/ncurses-mapsyms.html">Symbol
-    versioning in <span class="main-name">ncurses</span></a></li>
-
-    <li><a href=
-    "https://invisible-island.net/ncurses/ncurses-slang.html">Comments
-    on <span class="main-name">ncurses</span> versus <span class=
-    "main-name">slang</span> (S-Lang)</a></li>
-
-    <li><a href=
-    "https://invisible-island.net/ncurses/tack.html">tack &ndash;
-    terminfo action checker</a></li>
-
-    <li><a href=
-    "https://invisible-island.net/ncurses/tctest.html">tctest
-    &ndash; termcap library checker</a></li>
-
-    <li><a href=
-    "https://invisible-island.net/ncurses/ncurses.html#download_database">
-    Terminal Database</a></li>
-  </ul>
-
-  <h2><a name="h2-other-stuff" id="h2-other-stuff">Other
-  resources</a></h2>
-
-  <p>The distribution provides a newer version of the
-  terminfo-format terminal description file once maintained by
-  <a href="http://www.catb.org/~esr/terminfo/">Eric
-  Raymond</a>&nbsp;. Unlike the older version, the termcap and
-  terminfo data are provided in the same file, which also provides
-  several user-definable extensions beyond the X/Open
-  specification.</p>
-
-  <p>You can find lots of information on terminal-related topics
-  not covered in the terminfo file at <a href=
-  "http://web.archive.org/web/*/http://www.cs.utk.edu/~shuford/terminal">
-  Richard Shuford's archive</a>&nbsp;. The collection of computer
-  manuals at <a href=
-  "http://www.bitsavers.org/pdf/">bitsavers.org</a> has also been
-  useful.</p>
-
-  <div class="nav">
-    <ul>
-      <li><a href="#h2-overview">Overview</a></li>
-
-      <li>
-        <a href="#h2-release-notes">Release Notes</a>
-
-        <ul>
-          <li>
-            <a href="#h3-library">Library improvements</a>
-
-            <ul>
-              <li><a href="#h4-new-library">New features</a></li>
-
-              <li><a href="#h4-fixes-library">Other
-              improvements</a></li>
-            </ul>
-          </li>
-
-          <li>
-            <a href="#h3-programs">Program improvements</a>
-
-            <ul>
-              <li><a href="#h4-utilities">Utilities</a></li>
-
-              <li><a href="#h4-examples">Examples</a></li>
-            </ul>
-          </li>
-
-          <li><a href="#h3-database">Terminal database</a></li>
-
-          <li><a href="#h3-documentation">Documentation</a></li>
-
-          <li><a href="#h3-bug-fixes">Interesting bug-fixes</a></li>
-
-          <li>
-            <a href="#h3-config-config">Configuration changes</a>
-
-            <ul>
-              <li><a href="#h4-config-major">Major changes</a></li>
-
-              <li><a href="#h4-config-options">Configuration
-              options</a></li>
-            </ul>
-          </li>
-
-          <li><a href="#h3-portability">Portability</a></li>
-        </ul>
-      </li>
-
-      <li><a href="#h2-features">Features of <span class=
-      "main-name">ncurses</span></a></li>
-
-      <li><a href="#h2-who-uses">Applications using <span class=
-      "main-name">ncurses</span></a></li>
-
-      <li><a href="#h2-development">Development activities</a></li>
-
-      <li><a href="#h2-this-stuff">Related resources</a></li>
-
-      <li><a href="#h2-other-stuff">Other resources</a></li>
-    </ul>
-  </div>
-</body>
-</html>
diff --git a/contrib/ncurses/doc/html/hackguide.html b/contrib/ncurses/doc/html/hackguide.html
index 71312a565f4c..2b9445538dc8 100644
--- a/contrib/ncurses/doc/html/hackguide.html
+++ b/contrib/ncurses/doc/html/hackguide.html
@@ -1,7 +1,7 @@
 <!--
-  $Id: hackguide.html,v 1.33 2020/02/02 23:34:34 tom Exp $
+  $Id: hackguide.html,v 1.36 2022/11/26 19:31:56 tom Exp $
   ****************************************************************************
-  * Copyright 2019,2020 Thomas E. Dickey                                     *
+  * Copyright 2019-2020,2022 Thomas E. Dickey                                *
   * Copyright 2000-2013,2017 Free Software Foundation, Inc.                  *
   *                                                                          *
   * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -30,12 +30,10 @@
   ****************************************************************************
 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
-
 <html>
 <head>
   <meta name="generator" content=
-  "HTML Tidy for HTML5 for Linux version 5.2.0">
-
+  "HTML Tidy for HTML5 for Linux version 5.6.0">
   <title>A Hacker's Guide to Ncurses Internals</title>
   <link rel="author" href="mailto:bugs-ncurses@gnu.org">
   <meta http-equiv="Content-Type" content=
@@ -45,70 +43,70 @@ the ncurses-intro.html document, expected to be in the same directory with
 this one.
 -->
 </head>
-
 <body>
-  <h1>A Hacker's Guide to NCURSES</h1>
+  <h1 class="no-header">A Hacker's Guide to NCURSES</h1>
 
-  <h1>Contents</h1>
+  <h2>A Hacker's Guide to NCURSES</h2>
 
-  <ul>
-    <li><a href="#abstract">Abstract</a></li>
+  <div class="nav">
+    <h2>Contents</h2>
 
-    <li>
-      <a href="#objective">Objective of the Package</a>
+    <ul>
+      <li><a href="#abstract">Abstract</a></li>
 
-      <ul>
-        <li><a href="#whysvr4">Why System V Curses?</a></li>
+      <li>
+        <a href="#objective">Objective of the Package</a>
+        <ul>
+          <li><a href="#whysvr4">Why System V Curses?</a></li>
 
-        <li><a href="#extensions">How to Design Extensions</a></li>
-      </ul>
-    </li>
-
-    <li><a href="#portability">Portability and Configuration</a></li>
+          <li><a href="#extensions">How to Design Extensions</a></li>
+        </ul>
+      </li>
 
-    <li><a href="#documentation">Documentation Conventions</a></li>
+      <li><a href="#portability">Portability and Configuration</a></li>
 
-    <li><a href="#bugtrack">How to Report Bugs</a></li>
-
-    <li>
-      <a href="#ncurslib">A Tour of the Ncurses Library</a>
+      <li><a href="#documentation">Documentation Conventions</a></li>
 
-      <ul>
-        <li><a href="#loverview">Library Overview</a></li>
+      <li><a href="#bugtrack">How to Report Bugs</a></li>
 
-        <li><a href="#engine">The Engine Room</a></li>
+      <li>
+        <a href="#ncurslib">A Tour of the Ncurses Library</a>
+        <ul>
+          <li><a href="#loverview">Library Overview</a></li>
 
-        <li><a href="#input">Keyboard Input</a></li>
+          <li><a href="#engine">The Engine Room</a></li>
 
-        <li><a href="#mouse">Mouse Events</a></li>
+          <li><a href="#input">Keyboard Input</a></li>
 
-        <li><a href="#output">Output and Screen Updating</a></li>
-      </ul>
-    </li>
+          <li><a href="#mouse">Mouse Events</a></li>
 
-    <li><a href="#fmnote">The Forms and Menu Libraries</a></li>
+          <li><a href="#output">Output and Screen Updating</a></li>
+        </ul>
+      </li>
 
-    <li>
-      <a href="#tic">A Tour of the Terminfo Compiler</a>
+      <li><a href="#fmnote">The Forms and Menu Libraries</a></li>
 
-      <ul>
-        <li><a href="#nonuse">Translation of
-        Non-<strong>use</strong> Capabilities</a></li>
+      <li>
+        <a href="#tic">A Tour of the Terminfo Compiler</a>
+        <ul>
+          <li><a href="#nonuse">Translation of
+          Non-<strong>use</strong> Capabilities</a></li>
 
-        <li><a href="#uses">Use Capability Resolution</a></li>
+          <li><a href="#uses">Use Capability Resolution</a></li>
 
-        <li><a href="#translation">Source-Form Translation</a></li>
-      </ul>
-    </li>
+          <li><a href="#translation">Source-Form Translation</a></li>
+        </ul>
+      </li>
 
-    <li><a href="#utils">Other Utilities</a></li>
+      <li><a href="#utils">Other Utilities</a></li>
 
-    <li><a href="#style">Style Tips for Developers</a></li>
+      <li><a href="#style">Style Tips for Developers</a></li>
 
-    <li><a href="#port">Porting Hints</a></li>
-  </ul>
+      <li><a href="#port">Porting Hints</a></li>
+    </ul>
+  </div>
 
-  <h1><a name="abstract" id="abstract">Abstract</a></h1>
+  <h2><a name="abstract" id="abstract">Abstract</a></h2>
 
   <p>This document is a hacker's tour of the
   <strong>ncurses</strong> library and utilities. It discusses
@@ -117,8 +115,8 @@ this one.
   anyone who is interested in porting, extending or improving the
   package.</p>
 
-  <h1><a name="objective" id="objective">Objective of the
-  Package</a></h1>
+  <h2><a name="objective" id="objective">Objective of the
+  Package</a></h2>
 
   <p>The objective of the <strong>ncurses</strong> package is to
   provide a free software API for character-cell terminals and
@@ -144,7 +142,7 @@ this one.
   &mdash; we cannot add features if it means breaking the portion
   of the API corresponding to historical curses versions.</p>
 
-  <h2><a name="whysvr4" id="whysvr4">Why System V Curses?</a></h2>
+  <h3><a name="whysvr4" id="whysvr4">Why System V Curses?</a></h3>
 
   <p>We used System V curses as a model, reverse-engineering their
   API, in order to fulfill the first two objectives.</p>
@@ -158,8 +156,8 @@ this one.
   So conformance with System V took us most of the way to
   base-level XSI conformance.</p>
 
-  <h2><a name="extensions" id="extensions">How to Design
-  Extensions</a></h2>
+  <h3><a name="extensions" id="extensions">How to Design
+  Extensions</a></h3>
 
   <p>The third objective (standards conformance) requires that it
   be easy to condition source code using <strong>ncurses</strong>
@@ -177,8 +175,8 @@ this one.
   library header. You can use this to condition the calls to the
   mouse API calls.</p>
 
-  <h1><a name="portability" id="portability">Portability and
-  Configuration</a></h1>
+  <h2><a name="portability" id="portability">Portability and
+  Configuration</a></h2>
 
   <p>Code written for <strong>ncurses</strong> may assume an
   ANSI-standard C compiler and POSIX-compatible OS interface. It
@@ -208,8 +206,8 @@ this one.
   (configure.in and aclocal.m4) to set up a new feature macro,
   which you then use to condition your code.</p>
 
-  <h1><a name="documentation" id="documentation">Documentation
-  Conventions</a></h1>
+  <h2><a name="documentation" id="documentation">Documentation
+  Conventions</a></h2>
 
   <p>There are three kinds of documentation associated with this
   package. Each has a different preferred format:</p>
@@ -226,7 +224,7 @@ this one.
 
   <ol>
     <li><strong>Maintain package-internal files in plain
-    text.</strong> The expected viewer for them <em>more(1)</em> or
+    text.</strong> The expected viewer for them is <em>more(1)</em> or
     an editor window; there is no point in elaborate mark-up.</li>
 
     <li><strong>Mark up manual pages in the man macros.</strong>
@@ -249,7 +247,7 @@ this one.
   course, it make exporting things like the announcement document
   to WWW pretty trivial.</p>
 
-  <h1><a name="bugtrack" id="bugtrack">How to Report Bugs</a></h1>
+  <h2><a name="bugtrack" id="bugtrack">How to Report Bugs</a></h2>
 
   <p>The <a name="bugreport" id="bugreport">reporting address for
   bugs</a> is <a href=
@@ -258,10 +256,9 @@ this one.
   <code>bug-ncurses-request@gnu.org</code> with a message
   containing the line:</p>
 
-  <pre>
+  <pre class="code-block">
              subscribe &lt;name&gt;@&lt;host.domain&gt;
 </pre>
-
   <p>The <code>ncurses</code> code is maintained by a small group
   of volunteers. While we try our best to fix bugs promptly, we
   simply do not have a lot of hours to spend on elementary
@@ -276,8 +273,7 @@ this one.
   tail end and have to wait a while.</p>
 
   <ol>
-    <li>Develop a recipe to reproduce the bug.
-
+    <li><p>Develop a recipe to reproduce the bug.
       <p>Bugs we can reproduce are likely to be fixed very quickly,
       often within days. The most effective single thing you can do
       to get a quick fix is develop a way we can duplicate the bad
@@ -287,8 +283,7 @@ this one.
       with the distribution.)</p>
     </li>
 
-    <li>Try to reproduce the bug on a different terminal type.
-
+    <li><p>Try to reproduce the bug on a different terminal type.
       <p>In our experience, most of the behaviors people report as
       library bugs are actually due to subtle problems in terminal
       descriptions. This is especially likely to be true if you are
@@ -309,8 +304,7 @@ this one.
       triggered or masked by these.</p>
     </li>
 
-    <li>Generate and examine a trace file for the broken behavior.
-
+    <li><p>Generate and examine a trace file for the broken behavior.
       <p>Recompile your program with the debugging versions of the
       libraries. Insert a <code>trace()</code> call with the
       argument set to <code>TRACE_UPDATE</code>. (See <a href=
@@ -341,8 +335,7 @@ this one.
       screen-update logic quite exactly.</p>
     </li>
 
-    <li>Report details and symptoms, not just interpretations.
-
+    <li><p>Report details and symptoms, not just interpretations.
       <p>If you do the preceding two steps, it is very likely that
       you will discover the nature of the problem yourself and be
       able to send us a fix. This will create happy feelings all
@@ -397,10 +390,10 @@ this one.
   out. You can also test the hardware-scrolling optimization
   separately with <code>hardscroll</code>.</p>
 
-  <h1><a name="ncurslib" id="ncurslib">A Tour of the Ncurses
-  Library</a></h1>
+  <h2><a name="ncurslib" id="ncurslib">A Tour of the Ncurses
+  Library</a></h2>
 
-  <h2><a name="loverview" id="loverview">Library Overview</a></h2>
+  <h3><a name="loverview" id="loverview">Library Overview</a></h3>
 
   <p>Most of the library is superstructure &mdash; fairly trivial
   convenience interfaces to a small set of basic functions and data
@@ -495,9 +488,9 @@ this one.
 
   <p>We will discuss these in the compiler tour.</p>
 
-  <h2><a name="engine" id="engine">The Engine Room</a></h2>
+  <h3><a name="engine" id="engine">The Engine Room</a></h3>
 
-  <h3><a name="input" id="input">Keyboard Input</a></h3>
+  <h4><a name="input" id="input">Keyboard Input</a></h4>
 
   <p>All <code>ncurses</code> input funnels through the function
   <code>wgetch()</code>, defined in <code>lib_getch.c</code>. This
@@ -523,7 +516,7 @@ this one.
   The function <code>timed_wait()</code> effectively simulates a
   System V select.</p>
 
-  <h3><a name="mouse" id="mouse">Mouse Events</a></h3>
+  <h4><a name="mouse" id="mouse">Mouse Events</a></h4>
 
   <p>If the mouse interface is active, <code>wgetch()</code> polls
   for mouse events each call, before it goes to the keyboard for
@@ -568,7 +561,7 @@ this one.
   reports (low-level events) into a gesture (a high-level or
   composite event).</p>
 
-  <h3><a name="output" id="output">Output and Screen Updating</a></h3>
+  <h4><a name="output" id="output">Output and Screen Updating</a></h4>
 
   <p>With the single exception of character echoes during a
   <code>wgetnstr()</code> call (which simulates cooked-mode line
@@ -630,7 +623,7 @@ this one.
   <code>include/curses.h.in</code> for mask values, near the
   end.</p>
 
-  <h1><a name="fmnote" id="fmnote">The Forms and Menu Libraries</a></h1>
+  <h2><a name="fmnote" id="fmnote">The Forms and Menu Libraries</a></h2>
 
   <p>The forms and menu libraries should work reliably in any
   environment you can port ncurses to. The only portability issue
@@ -647,7 +640,7 @@ this one.
   This version has been slightly cleaned up for
   <code>ncurses</code>.</p>
 
-  <h1><a name="tic" id="tic">A Tour of the Terminfo Compiler</a></h1>
+  <h2><a name="tic" id="tic">A Tour of the Terminfo Compiler</a></h2>
 
   <p>The <strong>ncurses</strong> implementation of
   <strong>tic</strong> is rather complex internally; it has to do a
@@ -664,8 +657,8 @@ this one.
   values; the grammar above it is trivial, just "parse entries till
   you run out of file".</p>
 
-  <h2><a name="nonuse" id="nonuse">Translation of
-  Non-<strong>use</strong> Capabilities</a></h2>
+  <h3><a name="nonuse" id="nonuse">Translation of
+  Non-<strong>use</strong> Capabilities</a></h3>
 
   <p>Translation of most things besides <strong>use</strong>
   capabilities is pretty straightforward. The lexical analyzer's
@@ -689,7 +682,7 @@ this one.
   file. We will have more to say about this in the section on
   <a href="#translation">Source-Form Translation</a>.</p>
 
-  <h2><a name="uses" id="uses">Use Capability Resolution</a></h2>
+  <h3><a name="uses" id="uses">Use Capability Resolution</a></h3>
 
   <p>The background problem that makes <strong>tic</strong> tricky
   is not the capability translation itself, it is the resolution of
@@ -744,8 +737,8 @@ this one.
   overwriting entries newly made during the <strong>tic</strong>
   run, but not about overwriting ones that predate it.</p>
 
-  <h2><a name="translation" id="translation">Source-Form
-  Translation</a></h2>
+  <h3><a name="translation" id="translation">Source-Form
+  Translation</a></h3>
 
   <p>Another use of <strong>tic</strong> is to do source
   translation between various termcap and terminfo formats. There
@@ -773,7 +766,7 @@ this one.
   where the AIX <strong>box1</strong> capability get translated to
   an <strong>acsc</strong> string.</p>
 
-  <h1><a name="utils" id="utils">Other Utilities</a></h1>
+  <h2><a name="utils" id="utils">Other Utilities</a></h2>
 
   <p>The <strong>infocmp</strong> utility is just a wrapper around
   the same entry-dumping code used by <strong>tic</strong> for
@@ -787,7 +780,7 @@ this one.
   just do an entry load followed by a <code>tputs()</code> of a
   selected capability.</p>
 
-  <h1><a name="style" id="style">Style Tips for Developers</a></h1>
+  <h2><a name="style" id="style">Style Tips for Developers</a></h2>
 
   <p>See the TO-DO file in the top-level directory of the source
   distribution for additions that would be particularly useful.</p>
@@ -816,7 +809,7 @@ this one.
 
   <p>Have fun!</p>
 
-  <h1><a name="port" id="port">Porting Hints</a></h1>
+  <h2><a name="port" id="port">Porting Hints</a></h2>
 
   <p>The following notes are intended to be a first step towards
   DOS and Macintosh ports of the ncurses libraries.</p>
diff --git a/contrib/ncurses/doc/html/ncurses-intro.html b/contrib/ncurses/doc/html/ncurses-intro.html
index ebf2e2e03dda..194850246fa6 100644
--- a/contrib/ncurses/doc/html/ncurses-intro.html
+++ b/contrib/ncurses/doc/html/ncurses-intro.html
@@ -1,7 +1,7 @@
 <!--
-  $Id: ncurses-intro.html,v 1.54 2020/02/02 23:34:34 tom Exp $
+  $Id: ncurses-intro.html,v 1.57 2022/11/26 19:33:46 tom Exp $
   ****************************************************************************
-  * Copyright 2019,2020 Thomas E. Dickey                                     *
+  * Copyright 2019-2020,2022 Thomas E. Dickey                                *
   * Copyright 2000-2013,2017 Free Software Foundation, Inc.                  *
   *                                                                          *
   * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -30,288 +30,279 @@
   ****************************************************************************
 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
-
 <html>
 <head>
   <meta name="generator" content=
-  "HTML Tidy for HTML5 for Linux version 5.2.0">
-
+  "HTML Tidy for HTML5 for Linux version 5.6.0">
   <title>Writing Programs with NCURSES</title>
   <link rel="author" href="mailto:bugs-ncurses@gnu.org">
   <meta http-equiv="Content-Type" content=
   "text/html; charset=us-ascii">
 </head>
-
 <body>
-  <h1>Writing Programs with NCURSES</h1>
+  <h1 class="no-header">Writing Programs with NCURSES</h1>
+
+  <h2>Writing Programs with NCURSES</h2>
 
   <blockquote>
     by Eric S. Raymond and Zeyd M. Ben-Halim<br>
     updates since release 1.9.9e by Thomas Dickey
   </blockquote>
 
-  <h1>Contents</h1>
-
-  <ul>
-    <li>
-      <a href="#introduction">Introduction</a>
-
-      <ul>
-        <li><a href="#history">A Brief History of Curses</a></li>
-
-        <li><a href="#scope">Scope of This Document</a></li>
-
-        <li><a href="#terminology">Terminology</a></li>
-      </ul>
-    </li>
-
-    <li>
-      <a href="#curses">The Curses Library</a>
-
-      <ul>
-        <li>
-          <a href="#overview">An Overview of Curses</a>
-
-          <ul>
-            <li><a href="#compiling">Compiling Programs using
-            Curses</a></li>
-
-            <li><a href="#updating">Updating the Screen</a></li>
-
-            <li><a href="#stdscr">Standard Windows and Function
-            Naming Conventions</a></li>
-
-            <li><a href="#variables">Variables</a></li>
-          </ul>
-        </li>
-
-        <li>
-          <a href="#using">Using the Library</a>
-
-          <ul>
-            <li><a href="#starting">Starting up</a></li>
+  <div class="nav">
+    <h2>Contents</h2>
 
-            <li><a href="#output">Output</a></li>
+    <ul>
+      <li>
+        <a href="#introduction">Introduction</a>
+        <ul>
+          <li><a href="#history">A Brief History of Curses</a></li>
 
-            <li><a href="#input">Input</a></li>
+          <li><a href="#scope">Scope of This Document</a></li>
 
-            <li><a href="#formschars">Using Forms Characters</a></li>
+          <li><a href="#terminology">Terminology</a></li>
+        </ul>
+      </li>
 
-            <li><a href="#attributes">Character Attributes and
-            Color</a></li>
+      <li>
+        <a href="#curses">The Curses Library</a>
+        <ul>
+          <li>
+            <a href="#overview">An Overview of Curses</a>
+            <ul>
+              <li><a href="#compiling">Compiling Programs using
+              Curses</a></li>
 
-            <li><a href="#mouse">Mouse Interfacing</a></li>
+              <li><a href="#updating">Updating the Screen</a></li>
 
-            <li><a href="#finishing">Finishing Up</a></li>
-          </ul>
-        </li>
+              <li><a href="#stdscr">Standard Windows and Function
+              Naming Conventions</a></li>
 
-        <li>
-          <a href="#functions">Function Descriptions</a>
+              <li><a href="#variables">Variables</a></li>
+            </ul>
+          </li>
 
-          <ul>
-            <li><a href="#init">Initialization and Wrapup</a></li>
+          <li>
+            <a href="#using">Using the Library</a>
+            <ul>
+              <li><a href="#starting">Starting up</a></li>
 
-            <li><a href="#flush">Causing Output to the Terminal</a></li>
+              <li><a href="#output">Output</a></li>
 
-            <li><a href="#lowlevel">Low-Level Capability Access</a></li>
+              <li><a href="#input">Input</a></li>
 
-            <li><a href="#debugging">Debugging</a></li>
-          </ul>
-        </li>
+              <li><a href="#formschars">Using Forms Characters</a></li>
 
-        <li>
-          <a href="#hints">Hints, Tips, and Tricks</a>
+              <li><a href="#attributes">Character Attributes and
+              Color</a></li>
 
-          <ul>
-            <li><a href="#caution">Some Notes of Caution</a></li>
+              <li><a href="#mouse">Mouse Interfacing</a></li>
 
-            <li><a href="#leaving">Temporarily Leaving ncurses
-            Mode</a></li>
+              <li><a href="#finishing">Finishing Up</a></li>
+            </ul>
+          </li>
 
-            <li><a href="#xterm">Using <code>ncurses</code> under
-            <code>xterm</code></a></li>
+          <li>
+            <a href="#functions">Function Descriptions</a>
+            <ul>
+              <li><a href="#init">Initialization and Wrapup</a></li>
 
-            <li><a href="#screens">Handling Multiple Terminal
-            Screens</a></li>
+              <li><a href="#flush">Causing Output to the
+              Terminal</a></li>
 
-            <li><a href="#testing">Testing for Terminal
-            Capabilities</a></li>
+              <li><a href="#lowlevel">Low-Level Capability
+              Access</a></li>
 
-            <li><a href="#tuning">Tuning for Speed</a></li>
+              <li><a href="#debugging">Debugging</a></li>
+            </ul>
+          </li>
 
-            <li><a href="#special">Special Features of
-            <code>ncurses</code></a></li>
-          </ul>
-        </li>
+          <li>
+            <a href="#hints">Hints, Tips, and Tricks</a>
+            <ul>
+              <li><a href="#caution">Some Notes of Caution</a></li>
 
-        <li>
-          <a href="#compat">Compatibility with Older Versions</a>
+              <li><a href="#leaving">Temporarily Leaving ncurses
+              Mode</a></li>
 
-          <ul>
-            <li><a href="#refbug">Refresh of Overlapping
-            Windows</a></li>
+              <li><a href="#xterm">Using <code>ncurses</code> under
+              <code>xterm</code></a></li>
 
-            <li><a href="#backbug">Background Erase</a></li>
-          </ul>
-        </li>
+              <li><a href="#screens">Handling Multiple Terminal
+              Screens</a></li>
 
-        <li><a href="#xsifuncs">XSI Curses Conformance</a></li>
-      </ul>
-    </li>
+              <li><a href="#testing">Testing for Terminal
+              Capabilities</a></li>
 
-    <li>
-      <a href="#panels">The Panels Library</a>
+              <li><a href="#tuning">Tuning for Speed</a></li>
 
-      <ul>
-        <li><a href="#pcompile">Compiling With the Panels
-        Library</a></li>
+              <li><a href="#special">Special Features of
+              <code>ncurses</code></a></li>
+            </ul>
+          </li>
 
-        <li><a href="#poverview">Overview of Panels</a></li>
+          <li>
+            <a href="#compat">Compatibility with Older Versions</a>
+            <ul>
+              <li><a href="#refbug">Refresh of Overlapping
+              Windows</a></li>
 
-        <li><a href="#pstdscr">Panels, Input, and the Standard
-        Screen</a></li>
+              <li><a href="#backbug">Background Erase</a></li>
+            </ul>
+          </li>
 
-        <li><a href="#hiding">Hiding Panels</a></li>
+          <li><a href="#xsifuncs">XSI Curses Conformance</a></li>
+        </ul>
+      </li>
 
-        <li><a href="#pmisc">Miscellaneous Other Facilities</a></li>
-      </ul>
-    </li>
+      <li>
+        <a href="#panels">The Panels Library</a>
+        <ul>
+          <li><a href="#pcompile">Compiling With the Panels
+          Library</a></li>
 
-    <li>
-      <a href="#menu">The Menu Library</a>
+          <li><a href="#poverview">Overview of Panels</a></li>
 
-      <ul>
-        <li><a href="#mcompile">Compiling with the menu Library</a></li>
+          <li><a href="#pstdscr">Panels, Input, and the Standard
+          Screen</a></li>
 
-        <li><a href="#moverview">Overview of Menus</a></li>
+          <li><a href="#hiding">Hiding Panels</a></li>
 
-        <li><a href="#mselect">Selecting items</a></li>
+          <li><a href="#pmisc">Miscellaneous Other Facilities</a></li>
+        </ul>
+      </li>
 
-        <li><a href="#mdisplay">Menu Display</a></li>
+      <li>
+        <a href="#menu">The Menu Library</a>
+        <ul>
+          <li><a href="#mcompile">Compiling with the menu
+          Library</a></li>
 
-        <li><a href="#mwindows">Menu Windows</a></li>
+          <li><a href="#moverview">Overview of Menus</a></li>
 
-        <li><a href="#minput">Processing Menu Input</a></li>
+          <li><a href="#mselect">Selecting items</a></li>
 
-        <li><a href="#mmisc">Miscellaneous Other Features</a></li>
-      </ul>
-    </li>
+          <li><a href="#mdisplay">Menu Display</a></li>
 
-    <li>
-      <a href="#form">The Forms Library</a>
+          <li><a href="#mwindows">Menu Windows</a></li>
 
-      <ul>
-        <li><a href="#fcompile">Compiling with the forms
-        Library</a></li>
+          <li><a href="#minput">Processing Menu Input</a></li>
 
-        <li><a href="#foverview">Overview of Forms</a></li>
+          <li><a href="#mmisc">Miscellaneous Other Features</a></li>
+        </ul>
+      </li>
 
-        <li><a href="#fcreate">Creating and Freeing Fields and
-        Forms</a></li>
+      <li>
+        <a href="#form">The Forms Library</a>
+        <ul>
+          <li><a href="#fcompile">Compiling with the forms
+          Library</a></li>
 
-        <li>
-          <a href="#fattributes">Fetching and Changing Field
-          Attributes</a>
+          <li><a href="#foverview">Overview of Forms</a></li>
 
-          <ul>
-            <li><a href="#fsizes">Fetching Size and Location
-            Data</a></li>
+          <li><a href="#fcreate">Creating and Freeing Fields and
+          Forms</a></li>
 
-            <li><a href="#flocation">Changing the Field
-            Location</a></li>
+          <li>
+            <a href="#fattributes">Fetching and Changing Field
+            Attributes</a>
+            <ul>
+              <li><a href="#fsizes">Fetching Size and Location
+              Data</a></li>
 
-            <li><a href="#fjust">The Justification Attribute</a></li>
+              <li><a href="#flocation">Changing the Field
+              Location</a></li>
 
-            <li><a href="#fdispatts">Field Display Attributes</a></li>
+              <li><a href="#fjust">The Justification Attribute</a></li>
 
-            <li><a href="#foptions">Field Option Bits</a></li>
+              <li><a href="#fdispatts">Field Display Attributes</a></li>
 
-            <li><a href="#fstatus">Field Status</a></li>
+              <li><a href="#foptions">Field Option Bits</a></li>
 
-            <li><a href="#fuser">Field User Pointer</a></li>
-          </ul>
-        </li>
+              <li><a href="#fstatus">Field Status</a></li>
 
-        <li><a href="#fdynamic">Variable-Sized Fields</a></li>
+              <li><a href="#fuser">Field User Pointer</a></li>
+            </ul>
+          </li>
 
-        <li>
-          <a href="#fvalidation">Field Validation</a>
+          <li><a href="#fdynamic">Variable-Sized Fields</a></li>
 
-          <ul>
-            <li><a href="#ftype_alpha">TYPE_ALPHA</a></li>
+          <li>
+            <a href="#fvalidation">Field Validation</a>
+            <ul>
+              <li><a href="#ftype_alpha">TYPE_ALPHA</a></li>
 
-            <li><a href="#ftype_alnum">TYPE_ALNUM</a></li>
+              <li><a href="#ftype_alnum">TYPE_ALNUM</a></li>
 
-            <li><a href="#ftype_enum">TYPE_ENUM</a></li>
+              <li><a href="#ftype_enum">TYPE_ENUM</a></li>
 
-            <li><a href="#ftype_integer">TYPE_INTEGER</a></li>
+              <li><a href="#ftype_integer">TYPE_INTEGER</a></li>
 
-            <li><a href="#ftype_numeric">TYPE_NUMERIC</a></li>
+              <li><a href="#ftype_numeric">TYPE_NUMERIC</a></li>
 
-            <li><a href="#ftype_regexp">TYPE_REGEXP</a></li>
-          </ul>
-        </li>
+              <li><a href="#ftype_regexp">TYPE_REGEXP</a></li>
+            </ul>
+          </li>
 
-        <li><a href="#fbuffer">Direct Field Buffer Manipulation</a></li>
+          <li><a href="#fbuffer">Direct Field Buffer
+          Manipulation</a></li>
 
-        <li><a href="#formattrs">Attributes of Forms</a></li>
+          <li><a href="#formattrs">Attributes of Forms</a></li>
 
-        <li><a href="#fdisplay">Control of Form Display</a></li>
+          <li><a href="#fdisplay">Control of Form Display</a></li>
 
-        <li>
-          <a href="#fdriver">Input Processing in the Forms
-          Driver</a>
+          <li>
+            <a href="#fdriver">Input Processing in the Forms
+            Driver</a>
+            <ul>
+              <li><a href="#fpage">Page Navigation Requests</a></li>
 
-          <ul>
-            <li><a href="#fpage">Page Navigation Requests</a></li>
+              <li><a href="#ffield">Inter-Field Navigation
+              Requests</a></li>
 
-            <li><a href="#ffield">Inter-Field Navigation
-            Requests</a></li>
+              <li><a href="#fifield">Intra-Field Navigation
+              Requests</a></li>
 
-            <li><a href="#fifield">Intra-Field Navigation
-            Requests</a></li>
+              <li><a href="#fscroll">Scrolling Requests</a></li>
 
-            <li><a href="#fscroll">Scrolling Requests</a></li>
+              <li><a href="#fedit">Field Editing Requests</a></li>
 
-            <li><a href="#fedit">Field Editing Requests</a></li>
+              <li><a href="#forder">Order Requests</a></li>
 
-            <li><a href="#forder">Order Requests</a></li>
+              <li><a href="#fappcmds">Application Commands</a></li>
+            </ul>
+          </li>
 
-            <li><a href="#fappcmds">Application Commands</a></li>
-          </ul>
-        </li>
+          <li><a href="#fhooks">Field Change Hooks</a></li>
 
-        <li><a href="#fhooks">Field Change Hooks</a></li>
+          <li><a href="#ffocus">Field Change Commands</a></li>
 
-        <li><a href="#ffocus">Field Change Commands</a></li>
+          <li><a href="#frmoptions">Form Options</a></li>
 
-        <li><a href="#frmoptions">Form Options</a></li>
+          <li>
+            <a href="#fcustom">Custom Validation Types</a>
+            <ul>
+              <li><a href="#flinktypes">Union Types</a></li>
 
-        <li>
-          <a href="#fcustom">Custom Validation Types</a>
+              <li><a href="#fnewtypes">New Field Types</a></li>
 
-          <ul>
-            <li><a href="#flinktypes">Union Types</a></li>
+              <li><a href="#fcheckargs">Validation Function
+              Arguments</a></li>
 
-            <li><a href="#fnewtypes">New Field Types</a></li>
+              <li><a href="#fcustorder">Order Functions For Custom
+              Types</a></li>
 
-            <li><a href="#fcheckargs">Validation Function
-            Arguments</a></li>
-
-            <li><a href="#fcustorder">Order Functions For Custom
-            Types</a></li>
-
-            <li><a href="#fcustprobs">Avoiding Problems</a></li>
-          </ul>
-        </li>
-      </ul>
-    </li>
-  </ul>
+              <li><a href="#fcustprobs">Avoiding Problems</a></li>
+            </ul>
+          </li>
+        </ul>
+      </li>
+    </ul>
+  </div>
 
   <hr>
 
-  <h1><a name="introduction" id="introduction">Introduction</a></h1>
+  <h2><a name="introduction" id="introduction">Introduction</a></h2>
 
   <p>This document is an introduction to programming with
   <code>curses</code>. It is not an exhaustive reference for the
@@ -349,7 +340,7 @@
   <code>curses</code> will typically be a great deal simpler and
   less expensive than one using an X toolkit.</p>
 
-  <h2><a name="history" id="history">A Brief History of Curses</a></h2>
+  <h3><a name="history" id="history">A Brief History of Curses</a></h3>
 
   <p>Historically, the first ancestor of <code>curses</code> was
   the routines written to provide screen-handling for the
@@ -387,7 +378,7 @@
   to use more facilities and offer more capabilities, going far
   beyond BSD curses in power and flexibility.</p>
 
-  <h2><a name="scope" id="scope">Scope of This Document</a></h2>
+  <h3><a name="scope" id="scope">Scope of This Document</a></h3>
 
   <p>This document describes <code>ncurses</code>, a free
   implementation of the System V <code>curses</code> API with some
@@ -448,7 +439,7 @@
   libraries, also cloned from System V, which support easy
   construction and sequences of menus and fill-in forms.</p>
 
-  <h2><a name="terminology" id="terminology">Terminology</a></h2>
+  <h3><a name="terminology" id="terminology">Terminology</a></h3>
 
   <p>In this document, the following terminology is used with
   reasonable consistency:</p>
@@ -476,21 +467,20 @@
     screen.</dd>
   </dl>
 
-  <h1><a name="curses" id="curses">The Curses Library</a></h1>
+  <h2><a name="curses" id="curses">The Curses Library</a></h2>
 
-  <h2><a name="overview" id="overview">An Overview of Curses</a></h2>
+  <h3><a name="overview" id="overview">An Overview of Curses</a></h3>
 
-  <h3><a name="compiling" id="compiling">Compiling Programs using
-  Curses</a></h3>
+  <h4><a name="compiling" id="compiling">Compiling Programs using
+  Curses</a></h4>
 
   <p>In order to use the library, it is necessary to have certain
   types and variables defined. Therefore, the programmer must have
   a line:</p>
 
-  <pre>
+  <pre class="code-block">
           #include &lt;curses.h&gt;
 </pre>
-
   <p>at the top of the program source. The screen package uses the
   Standard I/O library, so <code>&lt;curses.h&gt;</code> includes
   <code>&lt;stdio.h&gt;</code>. <code>&lt;curses.h&gt;</code> also
@@ -502,7 +492,7 @@
   your LDFLAGS or on the command line. There is no need for any
   other libraries.</p>
 
-  <h3><a name="updating" id="updating">Updating the Screen</a></h3>
+  <h4><a name="updating" id="updating">Updating the Screen</a></h4>
 
   <p>In order to update the screen optimally, it is necessary for
   the routines to know what the screen currently looks like and
@@ -533,8 +523,8 @@
   like this,&rdquo; and let the package implementation determine
   the most efficient way to repaint the screen.</p>
 
-  <h3><a name="stdscr" id="stdscr">Standard Windows and Function
-  Naming Conventions</a></h3>
+  <h4><a name="stdscr" id="stdscr">Standard Windows and Function
+  Naming Conventions</a></h4>
 
   <p>As hinted above, the routines can use several windows, but two
   are automatically given: <code>curscr</code>, which knows what
@@ -563,46 +553,41 @@
   &ldquo;mv&rdquo; and the desired (y, x) coordinates prepended to
   the arguments to the function. For example, the calls</p>
 
-  <pre>
+  <pre class="code-block">
           move(y, x);
           addch(ch);
 </pre>
-
   <p>can be replaced by</p>
 
-  <pre>
+  <pre class="code-block">
           mvaddch(y, x, ch);
 </pre>
-
   <p>and</p>
 
-  <pre>
+  <pre class="code-block">
           wmove(win, y, x);
           waddch(win, ch);
 </pre>
-
   <p>can be replaced by</p>
 
-  <pre>
+  <pre class="code-block">
           mvwaddch(win, y, x, ch);
 </pre>
-
   <p>Note that the window description pointer (win) comes before
   the added (y, x) coordinates. If a function requires a window
   pointer, it is always the first parameter passed.</p>
 
-  <h3><a name="variables" id="variables">Variables</a></h3>
+  <h4><a name="variables" id="variables">Variables</a></h4>
 
   <p>The <code>curses</code> library sets some variables describing
   the terminal capabilities.</p>
 
-  <pre>
+  <pre class="code-block">
       type   name      description
       ------------------------------------------------------------------
       int    LINES     number of lines on the terminal
       int    COLS      number of columns on the terminal
 </pre>
-
   <p>The <code>curses.h</code> also introduces some
   <code>#define</code> constants and types of general
   usefulness:</p>
@@ -635,7 +620,7 @@
     <dd>error flag returned by routines when things go right.</dd>
   </dl>
 
-  <h2><a name="using" id="using">Using the Library</a></h2>
+  <h3><a name="using" id="using">Using the Library</a></h3>
 
   <p>Now we describe how to actually use the screen package. In it,
   we assume all updating, reading, etc. is applied to
@@ -645,7 +630,7 @@
 
   <p>Here is a sample program to motivate the discussion:</p>
 
-  <pre>
+  <pre class="code-block">
 #include &lt;stdlib.h&gt;
 #include &lt;curses.h&gt;
 #include &lt;signal.h&gt;
@@ -707,8 +692,7 @@ static void finish(int sig)
     exit(0);
 }
 </pre>
-
-  <h3><a name="starting" id="starting">Starting up</a></h3>
+  <h4><a name="starting" id="starting">Starting up</a></h4>
 
   <p>In order to use the screen package, the routines must know
   about terminal characteristics, and the space for
@@ -740,7 +724,7 @@ static void finish(int sig)
   allow you to get rid of old windows. All the options described
   above can be applied to any window.</p>
 
-  <h3><a name="output" id="output">Output</a></h3>
+  <h4><a name="output" id="output">Output</a></h4>
 
   <p>Now that we have set things up, we will want to actually
   update the terminal. The basic functions used to change what will
@@ -775,7 +759,7 @@ static void finish(int sig)
   implementing a command which would redraw the screen in case it
   get messed up.</p>
 
-  <h3><a name="input" id="input">Input</a></h3>
+  <h4><a name="input" id="input">Input</a></h4>
 
   <p>The complementary function to <code>addch()</code> is
   <code>getch()</code> which, if echo is set, will call
@@ -804,8 +788,8 @@ static void finish(int sig)
   <code>#define</code> values is determined by <code>key_</code>
   capabilities in the terminal's terminfo entry.</p>
 
-  <h3><a name="formschars" id="formschars">Using Forms
-  Characters</a></h3>
+  <h4><a name="formschars" id="formschars">Using Forms
+  Characters</a></h4>
 
   <p>The <code>addch()</code> function (and some others, including
   <code>box()</code> and <code>border()</code>) can accept some
@@ -820,8 +804,8 @@ static void finish(int sig)
   <code>curses.h</code> will map them to a recognizable (though
   ugly) set of ASCII defaults.</p>
 
-  <h3><a name="attributes" id="attributes">Character Attributes and
-  Color</a></h3>
+  <h4><a name="attributes" id="attributes">Character Attributes and
+  Color</a></h4>
 
   <p>The <code>ncurses</code> package supports screen highlights
   including standout, reverse-video, underline, and blink. It also
@@ -859,7 +843,7 @@ static void finish(int sig)
   that <code>COLOR_PAIR(N)</code>, for constant N, is itself a
   compile-time constant and can be used in initializers.</p>
 
-  <h3><a name="mouse" id="mouse">Mouse Interfacing</a></h3>
+  <h4><a name="mouse" id="mouse">Mouse Interfacing</a></h4>
 
   <p>The <code>ncurses</code> library also provides a mouse
   interface.</p>
@@ -947,7 +931,7 @@ static void finish(int sig)
   <p>See the manual page <code>curs_mouse(3X)</code> for full
   details of the mouse-interface functions.</p>
 
-  <h3><a name="finishing" id="finishing">Finishing Up</a></h3>
+  <h4><a name="finishing" id="finishing">Finishing Up</a></h4>
 
   <p>In order to clean up after the <code>ncurses</code> routines,
   the routine <code>endwin()</code> is provided. It restores tty
@@ -956,13 +940,13 @@ static void finish(int sig)
   anytime after the call to initscr, <code>endwin()</code> should
   be called before exiting.</p>
 
-  <h2><a name="functions" id="functions">Function Descriptions</a></h2>
+  <h3><a name="functions" id="functions">Function Descriptions</a></h3>
 
   <p>We describe the detailed behavior of some important curses
   functions here, as a supplement to the manual page
   descriptions.</p>
 
-  <h3><a name="init" id="init">Initialization and Wrapup</a></h3>
+  <h4><a name="init" id="init">Initialization and Wrapup</a></h4>
 
   <dl>
     <dt><code>initscr()</code>
@@ -1025,7 +1009,7 @@ static void finish(int sig)
     reference.</dd>
   </dl>
 
-  <h3><a name="flush" id="flush">Causing Output to the Terminal</a></h3>
+  <h4><a name="flush" id="flush">Causing Output to the Terminal</a></h4>
 
   <dl>
     <dt><code>refresh()</code> and <code>wrefresh(win)</code></dt>
@@ -1064,8 +1048,8 @@ static void finish(int sig)
     each update).</dd>
   </dl>
 
-  <h3><a name="lowlevel" id="lowlevel">Low-Level Capability
-  Access</a></h3>
+  <h4><a name="lowlevel" id="lowlevel">Low-Level Capability
+  Access</a></h4>
 
   <dl>
     <dt><code>setupterm(term, filenum, errret)</code>
@@ -1082,7 +1066,6 @@ static void finish(int sig)
       indication is returned. The values returned can be 1 (all is
       well), 0 (no such terminal), or -1 (some problem locating the
       terminfo database).
-
       <p>The value of <code>term</code> can be given as NULL, which
       will cause the value of <code>TERM</code> in the environment
       to be used. The <code>errret</code> pointer can also be given
@@ -1107,7 +1090,7 @@ static void finish(int sig)
     </dd>
   </dl>
 
-  <h3><a name="debugging" id="debugging">Debugging</a></h3>
+  <h4><a name="debugging" id="debugging">Debugging</a></h4>
 
   <blockquote>
     <strong>NOTE:</strong> These functions are not part of the
@@ -1149,14 +1132,14 @@ static void finish(int sig)
   be distinguished by the fact that they are named in capital
   letters.</p>
 
-  <h2><a name="hints" id="hints">Hints, Tips, and Tricks</a></h2>
+  <h3><a name="hints" id="hints">Hints, Tips, and Tricks</a></h3>
 
   <p>The <code>ncurses</code> manual pages are a complete reference
   for this library. In the remainder of this document, we discuss
   various useful methods that may not be obvious from the manual
   page descriptions.</p>
 
-  <h3><a name="caution" id="caution">Some Notes of Caution</a></h3>
+  <h4><a name="caution" id="caution">Some Notes of Caution</a></h4>
 
   <p>If you find yourself thinking you need to use
   <code>noraw()</code> or <code>nocbreak()</code>, think again and
@@ -1196,8 +1179,8 @@ static void finish(int sig)
   with window resizes, in which case several screens could be open
   with different sizes.</p>
 
-  <h3><a name="leaving" id="leaving">Temporarily Leaving NCURSES
-  Mode</a></h3>
+  <h4><a name="leaving" id="leaving">Temporarily Leaving NCURSES
+  Mode</a></h4>
 
   <p>Sometimes you will want to write a program that spends most of
   its time in screen mode, but occasionally returns to ordinary
@@ -1220,7 +1203,7 @@ static void finish(int sig)
 
   <p>Here is some sample code for shellout:</p>
 
-  <pre>
+  <pre class="code-block">
     addstr("Shelling out...");
     def_prog_mode();           /* save current tty modes */
     endwin();                  /* restore original tty modes */
@@ -1228,8 +1211,7 @@ static void finish(int sig)
     addstr("returned.\n");     /* prepare return message */
     refresh();                 /* restore save modes, repaint screen */
 </pre>
-
-  <h3><a name="xterm" id="xterm">Using NCURSES under XTERM</a></h3>
+  <h4><a name="xterm" id="xterm">Using NCURSES under XTERM</a></h4>
 
   <p>A resize operation in X sends <code>SIGWINCH</code> to the
   application running under xterm. The easiest way to handle
@@ -1258,8 +1240,8 @@ static void finish(int sig)
   special-purpose code to handle <code>KEY_RESIZE</code>
   yourself.</p>
 
-  <h3><a name="screens" id="screens">Handling Multiple Terminal
-  Screens</a></h3>
+  <h4><a name="screens" id="screens">Handling Multiple Terminal
+  Screens</a></h4>
 
   <p>The <code>initscr()</code> function actually calls a function
   named <code>newterm()</code> to do most of its work. If you are
@@ -1274,8 +1256,8 @@ static void finish(int sig)
   <code>def_shell_mode</code> and <code>def_prog_mode</code> on
   each tty yourself.</p>
 
-  <h3><a name="testing" id="testing">Testing for Terminal
-  Capabilities</a></h3>
+  <h4><a name="testing" id="testing">Testing for Terminal
+  Capabilities</a></h4>
 
   <p>Sometimes you may want to write programs that test for the
   presence of various capabilities before deciding whether to go
@@ -1292,7 +1274,7 @@ static void finish(int sig)
   include the <code>term.h</code> file and test the value of the
   macro <code>cursor_address</code>.</p>
 
-  <h3><a name="tuning" id="tuning">Tuning for Speed</a></h3>
+  <h4><a name="tuning" id="tuning">Tuning for Speed</a></h4>
 
   <p>Use the <code>addchstr()</code> family of functions for fast
   screen-painting of text when you know the text does not contain
@@ -1300,8 +1282,8 @@ static void finish(int sig)
   on your screens. Do not use the <code>immedok()</code>
   option!</p>
 
-  <h3><a name="special" id="special">Special Features of
-  NCURSES</a></h3>
+  <h4><a name="special" id="special">Special Features of
+  NCURSES</a></h4>
 
   <p>The <code>wresize()</code> function allows you to resize a
   window in place. The associated <code>resizeterm()</code>
@@ -1325,16 +1307,16 @@ static void finish(int sig)
   only 8 colors, about a quarter (including XFree86 xterm) support
   16 colors.</p>
 
-  <h2><a name="compat" id="compat">Compatibility with Older
-  Versions</a></h2>
+  <h3><a name="compat" id="compat">Compatibility with Older
+  Versions</a></h3>
 
   <p>Despite our best efforts, there are some differences between
   <code>ncurses</code> and the (undocumented!) behavior of older
   curses implementations. These arise from ambiguities or omissions
   in the documentation of the API.</p>
 
-  <h3><a name="refbug" id="refbug">Refresh of Overlapping
-  Windows</a></h3>
+  <h4><a name="refbug" id="refbug">Refresh of Overlapping
+  Windows</a></h4>
 
   <p>If you define two windows A and B that overlap, and then
   alternately scribble on and refresh them, the changes made to the
@@ -1392,7 +1374,7 @@ static void finish(int sig)
   <code>doupdate()</code> and there will be a <em>single</em> burst
   of physical I/O that will do all your updates.</p>
 
-  <h3><a name="backbug" id="backbug">Background Erase</a></h3>
+  <h4><a name="backbug" id="backbug">Background Erase</a></h4>
 
   <p>If you have been using a very old versions of
   <code>ncurses</code> (1.8.7 or older) you may be surprised by the
@@ -1409,7 +1391,7 @@ static void finish(int sig)
   <p>This change in behavior conforms <code>ncurses</code> to
   System V Release 4 and the XSI Curses standard.</p>
 
-  <h2><a name="xsifuncs" id="xsifuncs">XSI Curses Conformance</a></h2>
+  <h3><a name="xsifuncs" id="xsifuncs">XSI Curses Conformance</a></h3>
 
   <p>The <code>ncurses</code> library is intended to be base-level
   conformant with the XSI Curses standard from X/Open. Many
@@ -1426,7 +1408,7 @@ static void finish(int sig)
   be linked (and will be prototype-checked) if the macro definition
   is disabled with <code>#undef</code>.</p>
 
-  <h1><a name="panels" id="panels">The Panels Library</a></h1>
+  <h2><a name="panels" id="panels">The Panels Library</a></h2>
 
   <p>The <code>ncurses</code> library by itself provides good
   support for screen displays in which the windows are tiled
@@ -1446,16 +1428,15 @@ static void finish(int sig)
   System V. The version documented here is the <code>panel</code>
   code distributed with <code>ncurses</code>.</p>
 
-  <h2><a name="pcompile" id="pcompile">Compiling With the Panels
-  Library</a></h2>
+  <h3><a name="pcompile" id="pcompile">Compiling With the Panels
+  Library</a></h3>
 
   <p>Your panels-using modules must import the panels library
   declarations with</p>
 
-  <pre>
+  <pre class="code-block">
           #include &lt;panel.h&gt;
 </pre>
-
   <p>and must be linked explicitly with the panels library using an
   <code>-lpanel</code> argument. Note that they must also link the
   <code>ncurses</code> library with <code>-lncurses</code>. Many
@@ -1463,7 +1444,7 @@ static void finish(int sig)
   still good practice to put <code>-lpanel</code> first and
   <code>-lncurses</code> second.</p>
 
-  <h2><a name="poverview" id="poverview">Overview of Panels</a></h2>
+  <h3><a name="poverview" id="poverview">Overview of Panels</a></h3>
 
   <p>A panel object is a window that is implicitly treated as part
   of a <dfn>deck</dfn> including all other panel objects. The deck
@@ -1514,8 +1495,8 @@ static void finish(int sig)
   you will generate a lot of unnecessary refresh activity and
   screen flicker.</p>
 
-  <h2><a name="pstdscr" id="pstdscr">Panels, Input, and the
-  Standard Screen</a></h2>
+  <h3><a name="pstdscr" id="pstdscr">Panels, Input, and the
+  Standard Screen</a></h3>
 
   <p>You should not mix <code>wnoutrefresh()</code> or
   <code>wrefresh()</code> operations with panels code; this will
@@ -1536,7 +1517,7 @@ static void finish(int sig)
   <p>There is presently no way to display changes to one obscured
   panel without repainting all panels.</p>
 
-  <h2><a name="hiding" id="hiding">Hiding Panels</a></h2>
+  <h3><a name="hiding" id="hiding">Hiding Panels</a></h3>
 
   <p>It is possible to remove a panel from the deck temporarily;
   use <code>hide_panel</code> for this. Use
@@ -1548,7 +1529,7 @@ static void finish(int sig)
   cannot do <code>top_panel()</code> or <code>bottom_panel</code>
   on a hidden panel(). Other panels operations are applicable.</p>
 
-  <h2><a name="pmisc" id="pmisc">Miscellaneous Other Facilities</a></h2>
+  <h3><a name="pmisc" id="pmisc">Miscellaneous Other Facilities</a></h3>
 
   <p>It is possible to navigate the deck using the functions
   <code>panel_above()</code> and <code>panel_below</code>. Handed a
@@ -1561,7 +1542,7 @@ static void finish(int sig)
   page documentation of <code>set_panel_userptr()</code> and
   <code>panel_userptr</code> for details.</p>
 
-  <h1><a name="menu" id="menu">The Menu Library</a></h1>
+  <h2><a name="menu" id="menu">The Menu Library</a></h2>
 
   <p>A menu is a screen display that assists the user to choose
   some subset of a given set of items. The <code>menu</code>
@@ -1572,16 +1553,15 @@ static void finish(int sig)
   System V. The version documented here is the <code>menu</code>
   code distributed with <code>ncurses</code>.</p>
 
-  <h2><a name="mcompile" id="mcompile">Compiling With the menu
-  Library</a></h2>
+  <h3><a name="mcompile" id="mcompile">Compiling With the menu
+  Library</a></h3>
 
   <p>Your menu-using modules must import the menu library
   declarations with</p>
 
-  <pre>
+  <pre class="code-block">
           #include &lt;menu.h&gt;
 </pre>
-
   <p>and must be linked explicitly with the menus library using an
   <code>-lmenu</code> argument. Note that they must also link the
   <code>ncurses</code> library with <code>-lncurses</code>. Many
@@ -1589,7 +1569,7 @@ static void finish(int sig)
   still good practice to put <code>-lmenu</code> first and
   <code>-lncurses</code> second.</p>
 
-  <h2><a name="moverview" id="moverview">Overview of Menus</a></h2>
+  <h3><a name="moverview" id="moverview">Overview of Menus</a></h3>
 
   <p>The menus created by this library consist of collections of
   <dfn>items</dfn> including a name string part and a description
@@ -1633,7 +1613,7 @@ static void finish(int sig)
     <li>Terminate <code>curses</code>.</li>
   </ol>
 
-  <h2><a name="mselect" id="mselect">Selecting items</a></h2>
+  <h3><a name="mselect" id="mselect">Selecting items</a></h3>
 
   <p>Menus may be multi-valued or (the default) single-valued (see
   the manual page <code>menu_opts(3x)</code> to see how to change
@@ -1654,7 +1634,7 @@ static void finish(int sig)
   so far defined for menus, but it is good practice to code as
   though other option bits might be on.</p>
 
-  <h2><a name="mdisplay" id="mdisplay">Menu Display</a></h2>
+  <h3><a name="mdisplay" id="mdisplay">Menu Display</a></h3>
 
   <p>The menu library calculates a minimum display size for your
   window, based on the following variables:</p>
@@ -1710,7 +1690,7 @@ static void finish(int sig)
   which the library allows you to change (see the
   <code>menu_attribs(3x)</code> manual page.</p>
 
-  <h2><a name="mwindows" id="mwindows">Menu Windows</a></h2>
+  <h3><a name="mwindows" id="mwindows">Menu Windows</a></h3>
 
   <p>Each menu has, as mentioned previously, a pair of associated
   windows. Both these windows are painted when the menu is posted
@@ -1732,7 +1712,7 @@ static void finish(int sig)
   the screen. To do that, call <code>wrefresh()</code> or some
   equivalent.</p>
 
-  <h2><a name="minput" id="minput">Processing Menu Input</a></h2>
+  <h3><a name="minput" id="minput">Processing Menu Input</a></h3>
 
   <p>The main loop of your menu-processing code should call
   <code>menu_driver()</code> repeatedly. The first argument of this
@@ -1784,7 +1764,7 @@ static void finish(int sig)
   commands. The <code>menu_driver()</code> code ignores them and
   returns <code>E_UNKNOWN_COMMAND</code>.</p>
 
-  <h2><a name="mmisc" id="mmisc">Miscellaneous Other Features</a></h2>
+  <h3><a name="mmisc" id="mmisc">Miscellaneous Other Features</a></h3>
 
   <p>Various menu options can affect the processing and visual
   appearance and input processing of menus. See <code>menu_opts(3x)
@@ -1807,7 +1787,7 @@ static void finish(int sig)
   <code>mitem_userptr(3x)</code> and
   <code>menu_userptr(3x)</code>.</p>
 
-  <h1><a name="form" id="form">The Forms Library</a></h1>
+  <h2><a name="form" id="form">The Forms Library</a></h2>
 
   <p>The <code>form</code> library is a curses extension that
   supports easy programming of on-screen forms for data entry and
@@ -1817,16 +1797,15 @@ static void finish(int sig)
   System V. The version documented here is the <code>form</code>
   code distributed with <code>ncurses</code>.</p>
 
-  <h2><a name="fcompile" id="fcompile">Compiling With the form
-  Library</a></h2>
+  <h3><a name="fcompile" id="fcompile">Compiling With the form
+  Library</a></h3>
 
   <p>Your form-using modules must import the form library
   declarations with</p>
 
-  <pre>
+  <pre class="code-block">
           #include &lt;form.h&gt;
 </pre>
-
   <p>and must be linked explicitly with the forms library using an
   <code>-lform</code> argument. Note that they must also link the
   <code>ncurses</code> library with <code>-lncurses</code>. Many
@@ -1834,7 +1813,7 @@ static void finish(int sig)
   still good practice to put <code>-lform</code> first and
   <code>-lncurses</code> second.</p>
 
-  <h2><a name="foverview" id="foverview">Overview of Forms</a></h2>
+  <h3><a name="foverview" id="foverview">Overview of Forms</a></h3>
 
   <p>A form is a collection of fields; each field may be either a
   label (explanatory text) or a data-entry location. Long forms may
@@ -1903,19 +1882,18 @@ static void finish(int sig)
   Besides menu-like navigation operations, the menu driver loop has
   to support field editing and data validation.</p>
 
-  <h2><a name="fcreate" id="fcreate">Creating and Freeing Fields
-  and Forms</a></h2>
+  <h3><a name="fcreate" id="fcreate">Creating and Freeing Fields
+  and Forms</a></h3>
 
   <p>The basic function for creating fields is
   <code>new_field()</code>:</p>
 
-  <pre>
+  <pre class="code-block">
 FIELD *new_field(int height, int width,   /* new field size */
                  int top, int left,       /* upper left corner */
                  int offscreen,           /* number of offscreen rows */
                  int nbuf);               /* number of working buffers */
 </pre>
-
   <p>Menu items always occupy a single row, but forms fields may
   have multiple rows. So <code>new_field()</code> requires you to
   specify a width and height (the first two arguments, which mist
@@ -1943,21 +1921,19 @@ FIELD *new_field(int height, int width,   /* new field size */
   buffers to allocate for the field; your application can use them
   for its own purposes.</p>
 
-  <pre>
+  <pre class="code-block">
 FIELD *dup_field(FIELD *field,            /* field to copy */
                  int top, int left);      /* location of new copy */
 </pre>
-
   <p>The function <code>dup_field()</code> duplicates an existing
   field at a new location. Size and buffering information are
   copied; some attribute flags and status bits are not (see the
   <code>form_field_new(3X)</code> for details).</p>
 
-  <pre>
+  <pre class="code-block">
 FIELD *link_field(FIELD *field,           /* field to copy */
                   int top, int left);     /* location of new copy */
 </pre>
-
   <p>The function <code>link_field()</code> also duplicates an
   existing field at a new location. The difference from
   <code>dup_field()</code> is that it arranges for the new field's
@@ -1978,10 +1954,9 @@ FIELD *link_field(FIELD *field,           /* field to copy */
 
   <p>To connect fields to a form, use</p>
 
-  <pre>
+  <pre class="code-block">
 FORM *new_form(FIELD **fields);
 </pre>
-
   <p>This function expects to see a NULL-terminated array of field
   pointers. Said fields are connected to a newly-allocated form
   object; its address is returned (or else NULL if the allocation
@@ -1999,8 +1974,8 @@ FORM *new_form(FIELD **fields);
   form, but not vice-versa; thus, you will generally free your form
   objects first.</p>
 
-  <h2><a name="fattributes" id="fattributes">Fetching and Changing
-  Field Attributes</a></h2>
+  <h3><a name="fattributes" id="fattributes">Fetching and Changing
+  Field Attributes</a></h3>
 
   <p>Each form field has a number of location and size attributes
   associated with it. There are other field attributes used to
@@ -2016,56 +1991,53 @@ FORM *new_form(FIELD **fields);
   to it persist as defaults until your forms application
   terminates.</p>
 
-  <h3><a name="fsizes" id="fsizes">Fetching Size and Location
-  Data</a></h3>
+  <h4><a name="fsizes" id="fsizes">Fetching Size and Location
+  Data</a></h4>
 
   <p>You can retrieve field sizes and locations through:</p>
 
-  <pre>
+  <pre class="code-block">
 int field_info(FIELD *field,              /* field from which to fetch */
                int *height, *int width,   /* field size */
                int *top, int *left,       /* upper left corner */
                int *offscreen,            /* number of offscreen rows */
                int *nbuf);                /* number of working buffers */
 </pre>
-
   <p>This function is a sort of inverse of
   <code>new_field()</code>; instead of setting size and location
   attributes of a new field, it fetches them from an existing
   one.</p>
 
-  <h3><a name="flocation" id="flocation">Changing the Field
-  Location</a></h3>
+  <h4><a name="flocation" id="flocation">Changing the Field
+  Location</a></h4>
 
   <p>It is possible to move a field's location on the screen:</p>
 
-  <pre>
+  <pre class="code-block">
 int move_field(FIELD *field,              /* field to alter */
                int top, int left);        /* new upper-left corner */
 </pre>
-
   <p>You can, of course. query the current location through
   <code>field_info()</code>.</p>
 
-  <h3><a name="fjust" id="fjust">The Justification Attribute</a></h3>
+  <h4><a name="fjust" id="fjust">The Justification Attribute</a></h4>
 
   <p>One-line fields may be unjustified, justified right, justified
   left, or centered. Here is how you manipulate this attribute:</p>
 
-  <pre>
+  <pre class="code-block">
 int set_field_just(FIELD *field,          /* field to alter */
                    int justmode);         /* mode to set */
 
 int field_just(FIELD *field);             /* fetch mode of field */
 </pre>
-
   <p>The mode values accepted and returned by this functions are
   preprocessor macros <code>NO_JUSTIFICATION</code>,
   <code>JUSTIFY_RIGHT</code>, <code>JUSTIFY_LEFT</code>, or
   <code>JUSTIFY_CENTER</code>.</p>
 
-  <h3><a name="fdispatts" id="fdispatts">Field Display
-  Attributes</a></h3>
+  <h4><a name="fdispatts" id="fdispatts">Field Display
+  Attributes</a></h4>
 
   <p>For each field, you can set a foreground attribute for entered
   characters, a background attribute for the entire field, and a
@@ -2076,7 +2048,7 @@ int field_just(FIELD *field);             /* fetch mode of field */
   appearance of the field on the screen, without affecting in any
   way the data in the field buffer.</p>
 
-  <pre>
+  <pre class="code-block">
 int set_field_fore(FIELD *field,          /* field to alter */
                    chtype attr);          /* attribute to set */
 
@@ -2097,20 +2069,19 @@ int set_new_page(FIELD *field,            /* field to alter */
 
 chtype new_page(FIELD *field);            /* field to query */
 </pre>
-
   <p>The attributes set and returned by the first four functions
   are normal <code>curses(3x)</code> display attribute values
   (<code>A_STANDOUT</code>, <code>A_BOLD</code>,
   <code>A_REVERSE</code> etc). The page bit of a field controls
   whether it is displayed at the start of a new form screen.</p>
 
-  <h3><a name="foptions" id="foptions">Field Option Bits</a></h3>
+  <h4><a name="foptions" id="foptions">Field Option Bits</a></h4>
 
   <p>There is also a large collection of field option bits you can
   set to control various aspects of forms processing. You can
   manipulate them with these functions:</p>
 
-  <pre>
+  <pre class="code-block">
 int set_field_opts(FIELD *field,          /* field to alter */
                    int attr);             /* attribute to set */
 
@@ -2122,7 +2093,6 @@ int field_opts_off(FIELD *field,          /* field to alter */
 
 int field_opts(FIELD *field);             /* field to query */
 </pre>
-
   <p>By default, all options are on. Here are the available option
   bits:</p>
 
@@ -2209,19 +2179,18 @@ int field_opts(FIELD *field);             /* field to query */
   <p>The option values are bit-masks and can be composed with
   logical-or in the obvious way.</p>
 
-  <h2><a name="fstatus" id="fstatus">Field Status</a></h2>
+  <h3><a name="fstatus" id="fstatus">Field Status</a></h3>
 
   <p>Every field has a status flag, which is set to FALSE when the
   field is created and TRUE when the value in field buffer 0
   changes. This flag can be queried and set directly:</p>
 
-  <pre>
+  <pre class="code-block">
 int set_field_status(FIELD *field,      /* field to alter */
                    int status);         /* mode to set */
 
 int field_status(FIELD *field);         /* fetch mode of field */
 </pre>
-
   <p>Setting this flag under program control can be useful if you
   use the same form repeatedly, looking for modified fields each
   time.</p>
@@ -2238,14 +2207,14 @@ int field_status(FIELD *field);         /* fetch mode of field */
   just after a <code>REQ_VALIDATION</code> request has been
   processed by the forms driver.</p>
 
-  <h2><a name="fuser" id="fuser">Field User Pointer</a></h2>
+  <h3><a name="fuser" id="fuser">Field User Pointer</a></h3>
 
   <p>Each field structure contains one character pointer slot that
   is not used by the forms library. It is intended to be used by
   applications to store private per-field data. You can manipulate
   it with:</p>
 
-  <pre>
+  <pre class="code-block">
 int set_field_userptr(FIELD *field,       /* field to alter */
                    char *userptr);        /* mode to set */
 
@@ -2253,13 +2222,12 @@ char *field_userptr(FIELD *field);        /* fetch mode of field */
 </pre>(Properly, this user pointer field ought to have <code>(void
 *)</code> type. The <code>(char *)</code> type is retained for
 System V compatibility.)
-
   <p>It is valid to set the user pointer of the default field (with
   a <code>set_field_userptr()</code> call passed a NULL field
   pointer.) When a new field is created, the default-field user
   pointer is copied to initialize the new field's user pointer.</p>
 
-  <h2><a name="fdynamic" id="fdynamic">Variable-Sized Fields</a></h2>
+  <h3><a name="fdynamic" id="fdynamic">Variable-Sized Fields</a></h3>
 
   <p>Normally, a field is fixed at the size specified for it at
   creation time. If, however, you turn off its O_STATIC bit, it
@@ -2279,11 +2247,10 @@ System V compatibility.)
   But it is possible to set an upper limit on the size of a dynamic
   field. You do it with this function:</p>
 
-  <pre>
+  <pre class="code-block">
 int set_max_field(FIELD *field,     /* field to alter (may not be NULL) */
                    int max_size);   /* upper limit on field size */
 </pre>
-
   <p>If the field is one-line, <code>max_size</code> is taken to be
   a column size limit; if it is multi-line, it is taken to be a
   line size limit. To disable any limit, use an argument of zero.
@@ -2314,7 +2281,7 @@ int set_max_field(FIELD *field,     /* field to alter (may not be NULL) */
     size.</li>
   </ul>
 
-  <h2><a name="fvalidation" id="fvalidation">Field Validation</a></h2>
+  <h3><a name="fvalidation" id="fvalidation">Field Validation</a></h3>
 
   <p>By default, a field will accept any data that will fit in its
   input buffer. However, it is possible to attach a validation type
@@ -2332,14 +2299,13 @@ int set_max_field(FIELD *field,     /* field to alter (may not be NULL) */
   define custom ones of your own. You can examine and change field
   validation attributes with the following functions:</p>
 
-  <pre>
+  <pre class="code-block">
 int set_field_type(FIELD *field,          /* field to alter */
                    FIELDTYPE *ftype,      /* type to associate */
                    ...);                  /* additional arguments*/
 
 FIELDTYPE *field_type(FIELD *field);      /* field to query */
 </pre>
-
   <p>The validation type of a field is considered an attribute of
   the field. As with other field attributes, Also, doing
   <code>set_field_type()</code> with a <code>NULL</code> field
@@ -2348,56 +2314,53 @@ FIELDTYPE *field_type(FIELD *field);      /* field to query */
 
   <p>Here are the pre-defined validation types:</p>
 
-  <h3><a name="ftype_alpha" id="ftype_alpha">TYPE_ALPHA</a></h3>
+  <h4><a name="ftype_alpha" id="ftype_alpha">TYPE_ALPHA</a></h4>
 
   <p>This field type accepts alphabetic data; no blanks, no digits,
   no special characters (this is checked at character-entry time).
   It is set up with:</p>
 
-  <pre>
+  <pre class="code-block">
 int set_field_type(FIELD *field,          /* field to alter */
                    TYPE_ALPHA,            /* type to associate */
                    int width);            /* maximum width of field */
 </pre>
-
   <p>The <code>width</code> argument sets a minimum width of data.
   Typically you will want to set this to the field width; if it is
   greater than the field width, the validation check will always
   fail. A minimum width of zero makes field completion
   optional.</p>
 
-  <h3><a name="ftype_alnum" id="ftype_alnum">TYPE_ALNUM</a></h3>
+  <h4><a name="ftype_alnum" id="ftype_alnum">TYPE_ALNUM</a></h4>
 
   <p>This field type accepts alphabetic data and digits; no blanks,
   no special characters (this is checked at character-entry time).
   It is set up with:</p>
 
-  <pre>
+  <pre class="code-block">
 int set_field_type(FIELD *field,          /* field to alter */
                    TYPE_ALNUM,            /* type to associate */
                    int width);            /* maximum width of field */
 </pre>
-
   <p>The <code>width</code> argument sets a minimum width of data.
   As with TYPE_ALPHA, typically you will want to set this to the
   field width; if it is greater than the field width, the
   validation check will always fail. A minimum width of zero makes
   field completion optional.</p>
 
-  <h3><a name="ftype_enum" id="ftype_enum">TYPE_ENUM</a></h3>
+  <h4><a name="ftype_enum" id="ftype_enum">TYPE_ENUM</a></h4>
 
   <p>This type allows you to restrict a field's values to be among
   a specified set of string values (for example, the two-letter
   postal codes for U.S. states). It is set up with:</p>
 
-  <pre>
+  <pre class="code-block">
 int set_field_type(FIELD *field,          /* field to alter */
                    TYPE_ENUM,             /* type to associate */
                    char **valuelist;      /* list of possible values */
                    int checkcase;         /* case-sensitive? */
                    int checkunique);      /* must specify uniquely? */
 </pre>
-
   <p>The <code>valuelist</code> parameter must point at a
   NULL-terminated list of valid strings. The <code>checkcase</code>
   argument, if true, makes comparison with the string
@@ -2419,18 +2382,17 @@ int set_field_type(FIELD *field,          /* field to alter */
   <code>REQ_PREV_CHOICE</code> input requests can be particularly
   useful with these fields.</p>
 
-  <h3><a name="ftype_integer" id="ftype_integer">TYPE_INTEGER</a></h3>
+  <h4><a name="ftype_integer" id="ftype_integer">TYPE_INTEGER</a></h4>
 
   <p>This field type accepts an integer. It is set up as
   follows:</p>
 
-  <pre>
+  <pre class="code-block">
 int set_field_type(FIELD *field,          /* field to alter */
                    TYPE_INTEGER,          /* type to associate */
                    int padding,           /* # places to zero-pad to */
                    int vmin, int vmax);   /* valid range */
 </pre>
-
   <p>Valid characters consist of an optional leading minus and
   digits. The range check is performed on exit. If the range
   maximum is less than or equal to the minimum, the range is
@@ -2443,18 +2405,17 @@ int set_field_type(FIELD *field,          /* field to alter */
   <p>A <code>TYPE_INTEGER</code> value buffer can conveniently be
   interpreted with the C library function <code>atoi(3)</code>.</p>
 
-  <h3><a name="ftype_numeric" id="ftype_numeric">TYPE_NUMERIC</a></h3>
+  <h4><a name="ftype_numeric" id="ftype_numeric">TYPE_NUMERIC</a></h4>
 
   <p>This field type accepts a decimal number. It is set up as
   follows:</p>
 
-  <pre>
+  <pre class="code-block">
 int set_field_type(FIELD *field,              /* field to alter */
                    TYPE_NUMERIC,              /* type to associate */
                    int padding,               /* # places of precision */
                    double vmin, double vmax); /* valid range */
 </pre>
-
   <p>Valid characters consist of an optional leading minus and
   digits. possibly including a decimal point. If your system
   supports locale's, the decimal point character used must be the
@@ -2469,44 +2430,41 @@ int set_field_type(FIELD *field,              /* field to alter */
   <p>A <code>TYPE_NUMERIC</code> value buffer can conveniently be
   interpreted with the C library function <code>atof(3)</code>.</p>
 
-  <h3><a name="ftype_regexp" id="ftype_regexp">TYPE_REGEXP</a></h3>
+  <h4><a name="ftype_regexp" id="ftype_regexp">TYPE_REGEXP</a></h4>
 
   <p>This field type accepts data matching a regular expression. It
   is set up as follows:</p>
 
-  <pre>
+  <pre class="code-block">
 int set_field_type(FIELD *field,          /* field to alter */
                    TYPE_REGEXP,           /* type to associate */
                    char *regexp);         /* expression to match */
 </pre>
-
   <p>The syntax for regular expressions is that of
   <code>regcomp(3)</code>. The check for regular-expression match
   is performed on exit.</p>
 
-  <h2><a name="fbuffer" id="fbuffer">Direct Field Buffer
-  Manipulation</a></h2>
+  <h3><a name="fbuffer" id="fbuffer">Direct Field Buffer
+  Manipulation</a></h3>
 
   <p>The chief attribute of a field is its buffer contents. When a
   form has been completed, your application usually needs to know
   the state of each field buffer. You can find this out with:</p>
 
-  <pre>
+  <pre class="code-block">
 char *field_buffer(FIELD *field,          /* field to query */
                    int bufindex);         /* number of buffer to query */
 </pre>
-
   <p>Normally, the state of the zero-numbered buffer for each field
   is set by the user's editing actions on that field. It is
   sometimes useful to be able to set the value of the zero-numbered
   (or some other) buffer from your application:</p>
 
-  <pre>
+  <pre class="code-block">
 int set_field_buffer(FIELD *field,        /* field to alter */
                    int bufindex,          /* number of buffer to alter */
                    char *value);          /* string value to set */
 </pre>
-
   <p>If the field is not large enough and cannot be resized to a
   sufficiently large size to contain the specified value, the value
   will be truncated to fit.</p>
@@ -2525,7 +2483,7 @@ int set_field_buffer(FIELD *field,        /* field to alter */
   <code>REQ_VALIDATION</code> request has been processed by the
   forms driver.</p>
 
-  <h2><a name="formattrs" id="formattrs">Attributes of Forms</a></h2>
+  <h3><a name="formattrs" id="formattrs">Attributes of Forms</a></h3>
 
   <p>As with field attributes, form attributes inherit a default
   from a system default form structure. These defaults can be
@@ -2535,7 +2493,7 @@ int set_field_buffer(FIELD *field,        /* field to alter */
   <p>The principal attribute of a form is its field list. You can
   query and change this list with:</p>
 
-  <pre>
+  <pre class="code-block">
 int set_form_fields(FORM *form,           /* form to alter */
                     FIELD **fields);      /* fields to connect */
 
@@ -2543,7 +2501,6 @@ char *form_fields(FORM *form);            /* fetch fields of form */
 
 int field_count(FORM *form);              /* count connect fields */
 </pre>
-
   <p>The second argument of <code>set_form_fields()</code> may be a
   NULL-terminated field pointer array like the one required by
   <code>new_form()</code>. In that case, the old fields of the form
@@ -2557,7 +2514,7 @@ int field_count(FORM *form);              /* count connect fields */
   number of fields connected to a given from. It returns -1 if the
   form-pointer argument is NULL.</p>
 
-  <h2><a name="fdisplay" id="fdisplay">Control of Form Display</a></h2>
+  <h3><a name="fdisplay" id="fdisplay">Control of Form Display</a></h3>
 
   <p>In the overview section, you saw that to display a form you
   normally start by defining its size (and fields), posting it, and
@@ -2589,17 +2546,16 @@ int field_count(FORM *form);              /* count connect fields */
   need to know the size of the form's bounding rectangle. You can
   get this information with:</p>
 
-  <pre>
+  <pre class="code-block">
 int scale_form(FORM *form,                /* form to query */
                int *rows,                 /* form rows */
                int *cols);                /* form cols */
 </pre>
-
   <p>The form dimensions are passed back in the locations pointed
   to by the arguments. Once you have this information, you can use
   it to declare of windows, then use one of these functions:</p>
 
-  <pre>
+  <pre class="code-block">
 int set_form_win(FORM *form,              /* form to alter */
                  WINDOW *win);            /* frame window to connect */
 
@@ -2610,7 +2566,6 @@ int set_form_sub(FORM *form,              /* form to alter */
 
 WINDOW *form_sub(FORM *form);             /* fetch form subwindow of form */
 </pre>
-
   <p>Note that curses operations, including <code>refresh()</code>,
   on the form, should be done on the frame window, not the form
   subwindow.</p>
@@ -2619,12 +2574,11 @@ WINDOW *form_sub(FORM *form);             /* fetch form subwindow of form */
   scrollable field is actually displayed within the menu subwindow.
   Use these functions:</p>
 
-  <pre>
+  <pre class="code-block">
 int data_ahead(FORM *form);               /* form to be queried */
 
 int data_behind(FORM *form);              /* form to be queried */
 </pre>
-
   <p>The function <code>data_ahead()</code> returns TRUE if (a) the
   current field is one-line and has undisplayed data off to the
   right, (b) the current field is multi-line and there is data
@@ -2637,27 +2591,25 @@ int data_behind(FORM *form);              /* form to be queried */
   <p>Finally, there is a function to restore the form window's
   cursor to the value expected by the forms driver:</p>
 
-  <pre>
+  <pre class="code-block">
 int pos_form_cursor(FORM *)               /* form to be queried */
 </pre>
-
   <p>If your application changes the form window cursor, call this
   function before handing control back to the forms driver in order
   to re-synchronize it.</p>
 
-  <h2><a name="fdriver" id="fdriver">Input Processing in the Forms
-  Driver</a></h2>
+  <h3><a name="fdriver" id="fdriver">Input Processing in the Forms
+  Driver</a></h3>
 
   <p>The function <code>form_driver()</code> handles virtualized
   input requests for form navigation, editing, and validation
   requests, just as <code>menu_driver</code> does for menus (see
   the section on <a href="#minput">menu input handling</a>).</p>
 
-  <pre>
+  <pre class="code-block">
 int form_driver(FORM *form,               /* form to pass input to */
                 int request);             /* form request code */
 </pre>
-
   <p>Your input virtualization function needs to take input and
   then convert it to either an alphanumeric character (which is
   treated as data to be entered in the currently-selected field),
@@ -2668,7 +2620,7 @@ int form_driver(FORM *form,               /* form to pass input to */
   check that the input taken by the driver matched what was
   expected.</p>
 
-  <h3><a name="fpage" id="fpage">Page Navigation Requests</a></h3>
+  <h4><a name="fpage" id="fpage">Page Navigation Requests</a></h4>
 
   <p>These requests cause page-level moves through the form,
   triggering display of a new form screen.</p>
@@ -2700,8 +2652,8 @@ int form_driver(FORM *form,               /* form to pass input to */
   and <code>REQ_PREV_PAGE</code> from the first page goes to the
   last.</p>
 
-  <h3><a name="ffield" id="ffield">Inter-Field Navigation
-  Requests</a></h3>
+  <h4><a name="ffield" id="ffield">Inter-Field Navigation
+  Requests</a></h4>
 
   <p>These requests handle navigation between fields on the same
   page.</p>
@@ -2794,8 +2746,8 @@ int form_driver(FORM *form,               /* form to pass input to */
   from A will go to B only if A, B, and C <em>all</em> share the
   same first line; otherwise it will skip over B to C.</p>
 
-  <h3><a name="fifield" id="fifield">Intra-Field Navigation
-  Requests</a></h3>
+  <h4><a name="fifield" id="fifield">Intra-Field Navigation
+  Requests</a></h4>
 
   <p>These requests drive movement of the edit cursor within the
   currently selected field.</p>
@@ -2877,7 +2829,7 @@ int form_driver(FORM *form,               /* form to pass input to */
   end of line or field look for the first or last non-pad character
   in their ranges.</p>
 
-  <h3><a name="fscroll" id="fscroll">Scrolling Requests</a></h3>
+  <h4><a name="fscroll" id="fscroll">Scrolling Requests</a></h4>
 
   <p>Fields that are dynamic and have grown and fields explicitly
   created with offscreen rows are scrollable. One-line fields
@@ -2952,7 +2904,7 @@ int form_driver(FORM *form,               /* form to pass input to */
   <p>For scrolling purposes, a <em>page</em> of a field is the
   height of its visible part.</p>
 
-  <h3><a name="fedit" id="fedit">Editing Requests</a></h3>
+  <h4><a name="fedit" id="fedit">Editing Requests</a></h4>
 
   <p>When you pass the forms driver an ASCII character, it is
   treated as a request to add the character to the field's data
@@ -3068,7 +3020,7 @@ int form_driver(FORM *form,               /* form to pass input to */
   <p>See <a href="#frmoptions">Form Options</a> for discussion of
   how to set and clear the overload options.</p>
 
-  <h3><a name="forder" id="forder">Order Requests</a></h3>
+  <h4><a name="forder" id="forder">Order Requests</a></h4>
 
   <p>If the type of your field is ordered, and has associated
   functions for getting the next and previous values of the type
@@ -3094,7 +3046,7 @@ int form_driver(FORM *form,               /* form to pass input to */
   field type of your own (see <a href="#fcustom">Custom Validation
   Types</a>), you can associate our own ordering functions.</p>
 
-  <h3><a name="fappcmds" id="fappcmds">Application Commands</a></h3>
+  <h4><a name="fappcmds" id="fappcmds">Application Commands</a></h4>
 
   <p>Form requests are represented as integers above the
   <code>curses</code> value greater than <code>KEY_MAX</code> and
@@ -3102,13 +3054,13 @@ int form_driver(FORM *form,               /* form to pass input to */
   your input-virtualization routine returns a value above
   <code>MAX_COMMAND</code>, the forms driver will ignore it.</p>
 
-  <h2><a name="fhooks" id="fhooks">Field Change Hooks</a></h2>
+  <h3><a name="fhooks" id="fhooks">Field Change Hooks</a></h3>
 
   <p>It is possible to set function hooks to be executed whenever
   the current field or form changes. Here are the functions that
   support this:</p>
 
-  <pre>
+  <pre class="code-block">
 typedef void    (*HOOK)();       /* pointer to function returning void */
 
 int set_form_init(FORM *form,    /* form to alter */
@@ -3131,7 +3083,6 @@ int set_field_term(FORM *form,   /* form to alter */
 
 HOOK field_term(FORM *form);     /* form to query */
 </pre>
-
   <p>These functions allow you to either set or query four
   different hooks. In each of the set functions, the second
   argument should be the address of a hook function. These
@@ -3182,7 +3133,7 @@ HOOK field_term(FORM *form);     /* form to query */
   <p>You can disable any of these hooks by (re)setting them to
   NULL, the default value.</p>
 
-  <h2><a href="#ffocus">Field Change Commands</a></h2>
+  <h3><a href="#ffocus">Field Change Commands</a></h3>
 
   <p>Normally, navigation through the form will be driven by the
   user's input requests. But sometimes it is useful to be able to
@@ -3190,7 +3141,7 @@ HOOK field_term(FORM *form);     /* form to query */
   application, or ask which field it currently is in. The following
   functions help you accomplish this:</p>
 
-  <pre>
+  <pre class="code-block">
 int set_current_field(FORM *form,         /* form to alter */
                       FIELD *field);      /* field to shift to */
 
@@ -3199,7 +3150,6 @@ FIELD *current_field(FORM *form);         /* form to query */
 int field_index(FORM *form,               /* form to query */
                 FIELD *field);            /* field to get index of */
 </pre>
-
   <p>The function <code>field_index()</code> returns the index of
   the given field in the given form's field array (the array passed
   to <code>new_form()</code> or
@@ -3211,22 +3161,21 @@ int field_index(FORM *form,               /* form to query */
 
   <p>It is also possible to move around by pages.</p>
 
-  <pre>
+  <pre class="code-block">
 int set_form_page(FORM *form,             /* form to alter */
                   int page);              /* page to go to (0-origin) */
 
 int form_page(FORM *form);                /* return form's current page */
 </pre>
-
   <p>The initial page of a newly-created form is 0. The function
   <code>set_form_fields()</code> resets this.</p>
 
-  <h2><a name="frmoptions" id="frmoptions">Form Options</a></h2>
+  <h3><a name="frmoptions" id="frmoptions">Form Options</a></h3>
 
   <p>Like fields, forms may have control option bits. They can be
   changed or queried with these functions:</p>
 
-  <pre>
+  <pre class="code-block">
 int set_form_opts(FORM *form,             /* form to alter */
                   int attr);              /* attribute to set */
 
@@ -3238,7 +3187,6 @@ int form_opts_off(FORM *form,             /* form to alter */
 
 int form_opts(FORM *form);                /* form to query */
 </pre>
-
   <p>By default, all options are on. Here are the available option
   bits:</p>
 
@@ -3261,7 +3209,7 @@ int form_opts(FORM *form);                /* form to query */
   <p>The option values are bit-masks and can be composed with
   logical-or in the obvious way.</p>
 
-  <h2><a name="fcustom" id="fcustom">Custom Validation Types</a></h2>
+  <h3><a name="fcustom" id="fcustom">Custom Validation Types</a></h3>
 
   <p>The <code>form</code> library gives you the capability to
   define custom validation types of your own. Further, the optional
@@ -3271,16 +3219,15 @@ int form_opts(FORM *form);                /* form to query */
   the handling of the additional arguments within custom validation
   functions.</p>
 
-  <h3><a name="flinktypes" id="flinktypes">Union Types</a></h3>
+  <h4><a name="flinktypes" id="flinktypes">Union Types</a></h4>
 
   <p>The simplest way to create a custom data type is to compose it
   from two preexisting ones:</p>
 
-  <pre>
+  <pre class="code-block">
 FIELD *link_fieldtype(FIELDTYPE *type1,
                       FIELDTYPE *type2);
 </pre>
-
   <p>This function creates a field type that will accept any of the
   values legal for either of its argument field types (which may be
   either predefined or programmer-defined). If a
@@ -3292,7 +3239,7 @@ FIELD *link_fieldtype(FIELDTYPE *type1,
   function for the first type, then for the second, to figure what
   type the buffer contents should be treated as.</p>
 
-  <h3><a name="fnewtypes" id="fnewtypes">New Field Types</a></h3>
+  <h4><a name="fnewtypes" id="fnewtypes">New Field Types</a></h4>
 
   <p>To create a field type from scratch, you need to specify one
   or both of the following things:</p>
@@ -3307,7 +3254,7 @@ FIELD *link_fieldtype(FIELDTYPE *type1,
 
   <p>Here is how you do that:</p>
 
-  <pre>
+  <pre class="code-block">
 typedef int     (*HOOK)();       /* pointer to function returning int */
 
 FIELDTYPE *new_fieldtype(HOOK f_validate, /* field validator */
@@ -3315,7 +3262,6 @@ FIELDTYPE *new_fieldtype(HOOK f_validate, /* field validator */
 
 int free_fieldtype(FIELDTYPE *ftype);     /* type to free */
 </pre>
-
   <p>At least one of the arguments of <code>new_fieldtype()</code>
   must be non-NULL. The forms driver will automatically call the
   new type's validation functions at appropriate points in
@@ -3334,8 +3280,8 @@ int free_fieldtype(FIELDTYPE *ftype);     /* type to free */
   argument. It too should return TRUE if the character is valid,
   FALSE otherwise.</p>
 
-  <h3><a name="fcheckargs" id="fcheckargs">Validation Function
-  Arguments</a></h3>
+  <h4><a name="fcheckargs" id="fcheckargs">Validation Function
+  Arguments</a></h4>
 
   <p>Your field- and character- validation functions will be passed
   a second argument as well. This second argument is the address of
@@ -3353,7 +3299,7 @@ int free_fieldtype(FIELDTYPE *ftype);     /* type to free */
 
   <p>Here is how you make the association:</p>
 
-  <pre>
+  <pre class="code-block">
 typedef char    *(*PTRHOOK)();    /* pointer to function returning (char *) */
 typedef void    (*VOIDHOOK)();    /* pointer to function returning void */
 
@@ -3362,7 +3308,6 @@ int set_fieldtype_arg(FIELDTYPE *type,    /* type to alter */
                       PTRHOOK copy_str,   /* make copy of structure */
                       VOIDHOOK free_str); /* free structure storage */
 </pre>
-
   <p>Here is how the storage-management hooks are used:</p>
 
   <dl>
@@ -3398,8 +3343,8 @@ int set_fieldtype_arg(FIELDTYPE *type,    /* type to alter */
   this happens. Thus, your validation functions should never see a
   NULL file pointer and need not check specially for it.</p>
 
-  <h3><a name="fcustorder" id="fcustorder">Order Functions For
-  Custom Types</a></h3>
+  <h4><a name="fcustorder" id="fcustorder">Order Functions For
+  Custom Types</a></h4>
 
   <p>Some custom field types are simply ordered in the same
   well-defined way that <code>TYPE_ENUM</code> is. For such types,
@@ -3407,14 +3352,13 @@ int set_fieldtype_arg(FIELDTYPE *type,    /* type to alter */
   support the <code>REQ_NEXT_CHOICE</code> and
   <code>REQ_PREV_CHOICE</code> requests. Here is how:</p>
 
-  <pre>
+  <pre class="code-block">
 typedef int     (*INTHOOK)();     /* pointer to function returning int */
 
 int set_fieldtype_arg(FIELDTYPE *type,    /* type to alter */
                       INTHOOK succ,       /* get successor value */
                       INTHOOK pred);      /* get predecessor value */
 </pre>
-
   <p>The successor and predecessor arguments will each be passed
   two arguments; a field pointer, and a pile pointer (as for the
   validation functions). They are expected to use the function
@@ -3424,7 +3368,7 @@ int set_fieldtype_arg(FIELDTYPE *type,    /* type to alter */
   (a legal next or previous value was set) or FALSE to indicate
   failure.</p>
 
-  <h3><a name="fcustprobs" id="fcustprobs">Avoiding Problems</a></h3>
+  <h4><a name="fcustprobs" id="fcustprobs">Avoiding Problems</a></h4>
 
   <p>The interface for defining custom types is complicated and
   tricky. Rather than attempting to create a custom type entirely
diff --git a/contrib/ncurses/doc/ncurses-intro.doc b/contrib/ncurses/doc/ncurses-intro.doc
index 4e752ed0fc54..a20ee1a1d271 100644
--- a/contrib/ncurses/doc/ncurses-intro.doc
+++ b/contrib/ncurses/doc/ncurses-intro.doc
@@ -1,9 +1,11 @@
                          Writing Programs with NCURSES
 
+Writing Programs with NCURSES
+
      by Eric S. Raymond and Zeyd M. Ben-Halim
      updates since release 1.9.9e by Thomas Dickey
 
-                                   Contents
+Contents
 
      * Introduction
           + A Brief History of Curses
@@ -96,7 +98,7 @@
                o Avoiding Problems
      _________________________________________________________________
 
-                                 Introduction
+Introduction
 
    This document is an introduction to programming with curses. It is not
    an   exhaustive  reference  for  the  curses  Application  Programming
@@ -129,7 +131,7 @@
    will  typically  be  a  great deal simpler and less expensive than one
    using an X toolkit.
 
-A Brief History of Curses
+  A Brief History of Curses
 
    Historically, the first ancestor of curses was the routines written to
    provide  screen-handling  for  the  vi  editor; these used the termcap
@@ -163,7 +165,7 @@ A Brief History of Curses
    releases,  curses  evolved  to  use  more  facilities  and  offer more
    capabilities, going far beyond BSD curses in power and flexibility.
 
-Scope of This Document
+  Scope of This Document
 
    This document describes ncurses, a free implementation of the System V
    curses  API  with  some  clearly  marked  extensions.  It includes the
@@ -206,7 +208,7 @@ Scope of This Document
    extension  libraries,  also  cloned  from System V, which support easy
    construction and sequences of menus and fill-in forms.
 
-Terminology
+  Terminology
 
    In  this  document,  the following terminology is used with reasonable
    consistency:
@@ -227,11 +229,11 @@ Terminology
           The package's idea of what the terminal display currently looks
           like, i.e., what the user sees now. This is a special screen.
 
-                              The Curses Library
+The Curses Library
 
-An Overview of Curses
+  An Overview of Curses
 
-  Compiling Programs using Curses
+    Compiling Programs using Curses
 
    In order to use the library, it is necessary to have certain types and
    variables defined. Therefore, the programmer must have a line:
@@ -245,7 +247,7 @@ An Overview of Curses
    your  LDFLAGS  or  on the command line. There is no need for any other
    libraries.
 
-  Updating the Screen
+    Updating the Screen
 
    In  order  to  update  the  screen  optimally, it is necessary for the
    routines  to  know  what  the screen currently looks like and what the
@@ -273,7 +275,7 @@ An Overview of Curses
    package implementation determine the most efficient way to repaint the
    screen.
 
-  Standard Windows and Function Naming Conventions
+    Standard Windows and Function Naming Conventions
 
    As  hinted  above,  the  routines can use several windows, but two are
    automatically given: curscr, which knows what the terminal looks like,
@@ -313,7 +315,7 @@ An Overview of Curses
    (y,  x)  coordinates.  If  a function requires a window pointer, it is
    always the first parameter passed.
 
-  Variables
+    Variables
 
    The  curses  library  sets  some  variables  describing  the  terminal
    capabilities.
@@ -340,7 +342,7 @@ An Overview of Curses
    OK
           error flag returned by routines when things go right.
 
-Using the Library
+  Using the Library
 
    Now  we  describe  how  to  actually use the screen package. In it, we
    assume  all  updating,  reading,  etc.  is  applied  to  stdscr. These
@@ -409,7 +411,7 @@ static void finish(int sig)
     exit(0);
 }
 
-  Starting up
+    Starting up
 
    In  order  to  use  the  screen  package, the routines must know about
    terminal  characteristics, and the space for curscr and stdscr must be
@@ -435,7 +437,7 @@ static void finish(int sig)
    of  old windows. All the options described above can be applied to any
    window.
 
-  Output
+    Output
 
    Now  that  we  have set things up, we will want to actually update the
    terminal.  The basic functions used to change what will go on a window
@@ -464,7 +466,7 @@ static void finish(int sig)
    implementing  a  command  which would redraw the screen in case it get
    messed up.
 
-  Input
+    Input
 
    The  complementary  function  to  addch() is getch() which, if echo is
    set, will call addch() to echo the character. Since the screen package
@@ -488,7 +490,7 @@ static void finish(int sig)
    curses.h The mapping from sequences to #define values is determined by
    key_ capabilities in the terminal's terminfo entry.
 
-  Using Forms Characters
+    Using Forms Characters
 
    The  addch()  function (and some others, including box() and border())
    can accept some pseudo-character arguments which are specially defined
@@ -500,7 +502,7 @@ static void finish(int sig)
    the  terminal does not have such characters, curses.h will map them to
    a recognizable (though ugly) set of ASCII defaults.
 
-  Character Attributes and Color
+    Character Attributes and Color
 
    The  ncurses  package  supports  screen highlights including standout,
    reverse-video,  underline, and blink. It also supports color, which is
@@ -531,7 +533,7 @@ static void finish(int sig)
    combination.  Note  that  COLOR_PAIR(N),  for  constant N, is itself a
    compile-time constant and can be used in initializers.
 
-  Mouse Interfacing
+    Mouse Interfacing
 
    The ncurses library also provides a mouse interface.
 
@@ -603,7 +605,7 @@ static void finish(int sig)
    See   the   manual   page  curs_mouse(3X)  for  full  details  of  the
    mouse-interface functions.
 
-  Finishing Up
+    Finishing Up
 
    In  order to clean up after the ncurses routines, the routine endwin()
    is  provided.  It  restores tty modes to what they were when initscr()
@@ -611,12 +613,12 @@ static void finish(int sig)
    Thus,  anytime  after  the  call to initscr, endwin() should be called
    before exiting.
 
-Function Descriptions
+  Function Descriptions
 
    We  describe  the detailed behavior of some important curses functions
    here, as a supplement to the manual page descriptions.
 
-  Initialization and Wrapup
+    Initialization and Wrapup
 
    initscr()
           The  first  function  called should almost always be initscr().
@@ -660,7 +662,7 @@ Function Descriptions
           The  inverse  of  newterm();  deallocates  the  data structures
           associated with a given SCREEN reference.
 
-  Causing Output to the Terminal
+    Causing Output to the Terminal
 
    refresh() and wrefresh(win)
           These  functions  must  be called to actually get any output on
@@ -689,7 +691,7 @@ Function Descriptions
           with  fewer  total  characters  transmitted (this also avoids a
           visually annoying flicker at each update).
 
-  Low-Level Capability Access
+    Low-Level Capability Access
 
    setupterm(term, filenum, errret)
           This  routine is called to initialize a terminal's description,
@@ -719,7 +721,7 @@ Function Descriptions
           array ttytype[]. Subsequent calls to setupterm() will overwrite
           this array, so you will have to save it yourself if need be.
 
-  Debugging
+    Debugging
 
      NOTE: These functions are not part of the standard curses API!
 
@@ -747,13 +749,13 @@ Function Descriptions
    single-line  pseudo-operations.  These pseudo-ops can be distinguished
    by the fact that they are named in capital letters.
 
-Hints, Tips, and Tricks
+  Hints, Tips, and Tricks
 
    The ncurses manual pages are a complete reference for this library. In
    the remainder of this document, we discuss various useful methods that
    may not be obvious from the manual page descriptions.
 
-  Some Notes of Caution
+    Some Notes of Caution
 
    If  you  find yourself thinking you need to use noraw() or nocbreak(),
    think  again  and  move carefully. It is probably better design to use
@@ -787,7 +789,7 @@ Hints, Tips, and Tricks
    in  an  environment with window resizes, in which case several screens
    could be open with different sizes.
 
-  Temporarily Leaving NCURSES Mode
+    Temporarily Leaving NCURSES Mode
 
    Sometimes  you  will  want  to write a program that spends most of its
    time  in  screen  mode,  but occasionally returns to ordinary "cooked"
@@ -812,7 +814,7 @@ Hints, Tips, and Tricks
     addstr("returned.\n");     /* prepare return message */
     refresh();                 /* restore save modes, repaint screen */
 
-  Using NCURSES under XTERM
+    Using NCURSES under XTERM
 
    A  resize  operation  in  X  sends SIGWINCH to the application running
    under  xterm.  The  easiest way to handle SIGWINCH is to do an endwin,
@@ -835,7 +837,7 @@ Hints, Tips, and Tricks
    it  cannot  know  how you want the screen re-painted. You will usually
    have to write special-purpose code to handle KEY_RESIZE yourself.
 
-  Handling Multiple Terminal Screens
+    Handling Multiple Terminal Screens
 
    The initscr() function actually calls a function named newterm() to do
    most  of  its  work.  If you are writing a program that opens multiple
@@ -847,7 +849,7 @@ Hints, Tips, and Tricks
    with  the  set_term  call.  Note  that  you  will  also  have  to call
    def_shell_mode and def_prog_mode on each tty yourself.
 
-  Testing for Terminal Capabilities
+    Testing for Terminal Capabilities
 
    Sometimes you may want to write programs that test for the presence of
    various  capabilities before deciding whether to go into ncurses mode.
@@ -861,14 +863,14 @@ Hints, Tips, and Tricks
    can  include  the  term.h  file  and  test  the  value  of  the  macro
    cursor_address.
 
-  Tuning for Speed
+    Tuning for Speed
 
    Use  the  addchstr()  family  of functions for fast screen-painting of
    text  when  you know the text does not contain any control characters.
    Try  to  make attribute changes infrequent on your screens. Do not use
    the immedok() option!
 
-  Special Features of NCURSES
+    Special Features of NCURSES
 
    The  wresize()  function  allows  you to resize a window in place. The
    associated   resizeterm()  function  simplifies  the  construction  of
@@ -888,14 +890,14 @@ Hints, Tips, and Tricks
    8. While most terminals which provide color allow only 8 colors, about
    a quarter (including XFree86 xterm) support 16 colors.
 
-Compatibility with Older Versions
+  Compatibility with Older Versions
 
    Despite  our  best efforts, there are some differences between ncurses
    and  the  (undocumented!)  behavior  of  older curses implementations.
    These  arise from ambiguities or omissions in the documentation of the
    API.
 
-  Refresh of Overlapping Windows
+    Refresh of Overlapping Windows
 
    If  you  define two windows A and B that overlap, and then alternately
    scribble  on  and  refresh  them,  the changes made to the overlapping
@@ -947,7 +949,7 @@ Compatibility with Older Versions
    you  have  defined. Then you can do one doupdate() and there will be a
    single burst of physical I/O that will do all your updates.
 
-  Background Erase
+    Background Erase
 
    If you have been using a very old versions of ncurses (1.8.7 or older)
    you  may be surprised by the behavior of the erase functions. In older
@@ -962,7 +964,7 @@ Compatibility with Older Versions
    This change in behavior conforms ncurses to System V Release 4 and the
    XSI Curses standard.
 
-XSI Curses Conformance
+  XSI Curses Conformance
 
    The  ncurses  library is intended to be base-level conformant with the
    XSI  Curses  standard  from  X/Open.  Many extended-level features (in
@@ -976,7 +978,7 @@ XSI Curses Conformance
    have  a  corresponding  function  which  may  be  linked  (and will be
    prototype-checked) if the macro definition is disabled with #undef.
 
-                              The Panels Library
+The Panels Library
 
    The  ncurses  library  by  itself  provides  good  support  for screen
    displays in which the windows are tiled (non-overlapping). In the more
@@ -993,7 +995,7 @@ XSI Curses Conformance
    The  panel  library  first  appeared  in  AT&T  System  V. The version
    documented here is the panel code distributed with ncurses.
 
-Compiling With the Panels Library
+  Compiling With the Panels Library
 
    Your  panels-using modules must import the panels library declarations
    with
@@ -1004,7 +1006,7 @@ Compiling With the Panels Library
    -lncurses. Many linkers are two-pass and will accept either order, but
    it is still good practice to put -lpanel first and -lncurses second.
 
-Overview of Panels
+  Overview of Panels
 
    A  panel  object  is  a window that is implicitly treated as part of a
    deck  including  all  other  panel  objects.  The deck has an implicit
@@ -1047,7 +1049,7 @@ Overview of Panels
    write,  you  will  generate  a lot of unnecessary refresh activity and
    screen flicker.
 
-Panels, Input, and the Standard Screen
+  Panels, Input, and the Standard Screen
 
    You should not mix wnoutrefresh() or wrefresh() operations with panels
    code;  this will work only if the argument window is either in the top
@@ -1065,7 +1067,7 @@ Panels, Input, and the Standard Screen
    There  is  presently  no  way to display changes to one obscured panel
    without repainting all panels.
 
-Hiding Panels
+  Hiding Panels
 
    It  is  possible  to  remove  a  panel  from the deck temporarily; use
    hide_panel  for this. Use show_panel() to render it visible again. The
@@ -1076,7 +1078,7 @@ Hiding Panels
    or  bottom_panel  on  a  hidden  panel().  Other panels operations are
    applicable.
 
-Miscellaneous Other Facilities
+  Miscellaneous Other Facilities
 
    It  is possible to navigate the deck using the functions panel_above()
    and  panel_below.  Handed a panel pointer, they return the panel above
@@ -1087,7 +1089,7 @@ Miscellaneous Other Facilities
    code,  to  which  you  can  attach  application data. See the man page
    documentation of set_panel_userptr() and panel_userptr for details.
 
-                               The Menu Library
+The Menu Library
 
    A menu is a screen display that assists the user to choose some subset
    of  a  given set of items. The menu library is a curses extension that
@@ -1097,7 +1099,7 @@ Miscellaneous Other Facilities
    The  menu  library  first  appeared  in  AT&T  System  V.  The version
    documented here is the menu code distributed with ncurses.
 
-Compiling With the menu Library
+  Compiling With the menu Library
 
    Your menu-using modules must import the menu library declarations with
           #include <menu.h>
@@ -1107,7 +1109,7 @@ Compiling With the menu Library
    -lncurses. Many linkers are two-pass and will accept either order, but
    it is still good practice to put -lmenu first and -lncurses second.
 
-Overview of Menus
+  Overview of Menus
 
    The  menus  created  by  this  library consist of collections of items
    including  a  name  string part and a description string part. To make
@@ -1137,7 +1139,7 @@ Overview of Menus
     9. Free the items using free_item().
    10. Terminate curses.
 
-Selecting items
+  Selecting items
 
    Menus  may  be  multi-valued  or  (the default) single-valued (see the
    manual  page  menu_opts(3x)  to  see  how to change the default). Both
@@ -1154,7 +1156,7 @@ Selecting items
    option  so  far  defined for menus, but it is good practice to code as
    though other option bits might be on.
 
-Menu Display
+  Menu Display
 
    The  menu  library  calculates a minimum display size for your window,
    based on the following variables:
@@ -1197,7 +1199,7 @@ Menu Display
    have  reasonable  defaults which the library allows you to change (see
    the menu_attribs(3x) manual page.
 
-Menu Windows
+  Menu Windows
 
    Each  menu has, as mentioned previously, a pair of associated windows.
    Both these windows are painted when the menu is posted and erased when
@@ -1217,7 +1219,7 @@ Menu Windows
    these  actually  modifies  the  screen. To do that, call wrefresh() or
    some equivalent.
 
-Processing Menu Input
+  Processing Menu Input
 
    The  main  loop of your menu-processing code should call menu_driver()
    repeatedly.  The first argument of this routine is a menu pointer; the
@@ -1261,7 +1263,7 @@ Processing Menu Input
    considered   application-specific  commands.  The  menu_driver()  code
    ignores them and returns E_UNKNOWN_COMMAND.
 
-Miscellaneous Other Features
+  Miscellaneous Other Features
 
    Various  menu  options can affect the processing and visual appearance
    and input processing of menus. See menu_opts(3x) for details.
@@ -1280,7 +1282,7 @@ Miscellaneous Other Features
    Each  item, and each menu, has an associated user pointer on which you
    can hang application data. See mitem_userptr(3x) and menu_userptr(3x).
 
-                               The Forms Library
+The Forms Library
 
    The  form library is a curses extension that supports easy programming
    of on-screen forms for data entry and program control.
@@ -1288,7 +1290,7 @@ Miscellaneous Other Features
    The  form  library  first  appeared  in  AT&T  System  V.  The version
    documented here is the form code distributed with ncurses.
 
-Compiling With the form Library
+  Compiling With the form Library
 
    Your form-using modules must import the form library declarations with
           #include <form.h>
@@ -1298,7 +1300,7 @@ Compiling With the form Library
    -lncurses. Many linkers are two-pass and will accept either order, but
    it is still good practice to put -lform first and -lncurses second.
 
-Overview of Forms
+  Overview of Forms
 
    A  form  is  a  collection of fields; each field may be either a label
    (explanatory  text)  or  a  data-entry  location.  Long  forms  may be
@@ -1347,7 +1349,7 @@ Overview of Forms
    operations, the menu driver loop has to support field editing and data
    validation.
 
-Creating and Freeing Fields and Forms
+  Creating and Freeing Fields and Forms
 
    The basic function for creating fields is new_field():
 FIELD *new_field(int height, int width,   /* new field size */
@@ -1423,7 +1425,7 @@ FORM *new_form(FIELD **fields);
    to a form, but not vice-versa; thus, you will generally free your form
    objects first.
 
-Fetching and Changing Field Attributes
+  Fetching and Changing Field Attributes
 
    Each  form  field  has  a  number  of  location  and  size  attributes
    associated  with  it. There are other field attributes used to control
@@ -1438,7 +1440,7 @@ Fetching and Changing Field Attributes
    to mean this field. Changes to it persist as defaults until your forms
    application terminates.
 
-  Fetching Size and Location Data
+    Fetching Size and Location Data
 
    You can retrieve field sizes and locations through:
 int field_info(FIELD *field,              /* field from which to fetch */
@@ -1451,7 +1453,7 @@ int field_info(FIELD *field,              /* field from which to fetch */
    size  and  location attributes of a new field, it fetches them from an
    existing one.
 
-  Changing the Field Location
+    Changing the Field Location
 
    It is possible to move a field's location on the screen:
 int move_field(FIELD *field,              /* field to alter */
@@ -1459,7 +1461,7 @@ int move_field(FIELD *field,              /* field to alter */
 
    You can, of course. query the current location through field_info().
 
-  The Justification Attribute
+    The Justification Attribute
 
    One-line  fields  may be unjustified, justified right, justified left,
    or centered. Here is how you manipulate this attribute:
@@ -1472,7 +1474,7 @@ int field_just(FIELD *field);             /* fetch mode of field */
    preprocessor  macros NO_JUSTIFICATION, JUSTIFY_RIGHT, JUSTIFY_LEFT, or
    JUSTIFY_CENTER.
 
-  Field Display Attributes
+    Field Display Attributes
 
    For  each  field,  you  can  set  a  foreground  attribute for entered
    characters,  a  background  attribute  for the entire field, and a pad
@@ -1507,7 +1509,7 @@ chtype new_page(FIELD *field);            /* field to query */
    etc).  The page bit of a field controls whether it is displayed at the
    start of a new form screen.
 
-  Field Option Bits
+    Field Option Bits
 
    There  is  also a large collection of field option bits you can set to
    control  various  aspects of forms processing. You can manipulate them
@@ -1593,7 +1595,7 @@ int field_opts(FIELD *field);             /* field to query */
    The option values are bit-masks and can be composed with logical-or in
    the obvious way.
 
-Field Status
+  Field Status
 
    Every field has a status flag, which is set to FALSE when the field is
    created  and  TRUE when the value in field buffer 0 changes. This flag
@@ -1616,7 +1618,7 @@ int field_status(FIELD *field);         /* fetch mode of field */
    initialization   or   termination   hooks,   or   (3)   just  after  a
    REQ_VALIDATION request has been processed by the forms driver.
 
-Field User Pointer
+  Field User Pointer
 
    Each  field  structure contains one character pointer slot that is not
    used  by  the forms library. It is intended to be used by applications
@@ -1634,7 +1636,7 @@ char *field_userptr(FIELD *field);        /* fetch mode of field */
    field  is  created,  the  default-field  user  pointer  is  copied  to
    initialize the new field's user pointer.
 
-Variable-Sized Fields
+  Variable-Sized Fields
 
    Normally,  a  field  is fixed at the size specified for it at creation
    time.  If,  however, you turn off its O_STATIC bit, it becomes dynamic
@@ -1673,7 +1675,7 @@ int set_max_field(FIELD *field,     /* field to alter (may not be NULL) */
        the  field;  use  dynamic_field_info()  to  get the actual dynamic
        size.
 
-Field Validation
+  Field Validation
 
    By  default,  a  field will accept any data that will fit in its input
    buffer.  However,  it  is  possible  to  attach a validation type to a
@@ -1703,7 +1705,7 @@ FIELDTYPE *field_type(FIELD *field);      /* field to query */
 
    Here are the pre-defined validation types:
 
-  TYPE_ALPHA
+    TYPE_ALPHA
 
    This  field  type  accepts  alphabetic  data; no blanks, no digits, no
    special  characters  (this  is checked at character-entry time). It is
@@ -1717,7 +1719,7 @@ int set_field_type(FIELD *field,          /* field to alter */
    width,  the validation check will always fail. A minimum width of zero
    makes field completion optional.
 
-  TYPE_ALNUM
+    TYPE_ALNUM
 
    This  field  type  accepts  alphabetic  data and digits; no blanks, no
    special  characters  (this  is checked at character-entry time). It is
@@ -1731,7 +1733,7 @@ int set_field_type(FIELD *field,          /* field to alter */
    greater than the field width, the validation check will always fail. A
    minimum width of zero makes field completion optional.
 
-  TYPE_ENUM
+    TYPE_ENUM
 
    This  type  allows  you  to  restrict  a  field's values to be among a
    specified  set  of  string  values (for example, the two-letter postal
@@ -1760,7 +1762,7 @@ int set_field_type(FIELD *field,          /* field to alter */
    The   REQ_NEXT_CHOICE   and  REQ_PREV_CHOICE  input  requests  can  be
    particularly useful with these fields.
 
-  TYPE_INTEGER
+    TYPE_INTEGER
 
    This field type accepts an integer. It is set up as follows:
 int set_field_type(FIELD *field,          /* field to alter */
@@ -1778,7 +1780,7 @@ int set_field_type(FIELD *field,          /* field to alter */
    A TYPE_INTEGER value buffer can conveniently be interpreted with the C
    library function atoi(3).
 
-  TYPE_NUMERIC
+    TYPE_NUMERIC
 
    This field type accepts a decimal number. It is set up as follows:
 int set_field_type(FIELD *field,              /* field to alter */
@@ -1798,7 +1800,7 @@ int set_field_type(FIELD *field,              /* field to alter */
    A TYPE_NUMERIC value buffer can conveniently be interpreted with the C
    library function atof(3).
 
-  TYPE_REGEXP
+    TYPE_REGEXP
 
    This  field type accepts data matching a regular expression. It is set
    up as follows:
@@ -1809,7 +1811,7 @@ int set_field_type(FIELD *field,          /* field to alter */
    The  syntax  for  regular expressions is that of regcomp(3). The check
    for regular-expression match is performed on exit.
 
-Direct Field Buffer Manipulation
+  Direct Field Buffer Manipulation
 
    The chief attribute of a field is its buffer contents. When a form has
    been  completed,  your  application usually needs to know the state of
@@ -1840,7 +1842,7 @@ int set_field_buffer(FIELD *field,        /* field to alter */
    or  form's  initialization  or  termination hooks, or (3) just after a
    REQ_VALIDATION request has been processed by the forms driver.
 
-Attributes of Forms
+  Attributes of Forms
 
    As  with  field  attributes,  form attributes inherit a default from a
    system default form structure. These defaults can be queried or set by
@@ -1868,7 +1870,7 @@ int field_count(FORM *form);              /* count connect fields */
    connected  to a given from. It returns -1 if the form-pointer argument
    is NULL.
 
-Control of Form Display
+  Control of Form Display
 
    In  the  overview section, you saw that to display a form you normally
    start  by  defining  its size (and fields), posting it, and refreshing
@@ -1938,7 +1940,7 @@ int pos_form_cursor(FORM *)               /* form to be queried */
    before   handing  control  back  to  the  forms  driver  in  order  to
    re-synchronize it.
 
-Input Processing in the Forms Driver
+  Input Processing in the Forms Driver
 
    The function form_driver() handles virtualized input requests for form
    navigation, editing, and validation requests, just as menu_driver does
@@ -1955,7 +1957,7 @@ int form_driver(FORM *form,               /* form to pass input to */
    field-termination  functions)  with  which  your  application code can
    check that the input taken by the driver matched what was expected.
 
-  Page Navigation Requests
+    Page Navigation Requests
 
    These  requests  cause  page-level  moves through the form, triggering
    display of a new form screen.
@@ -1976,7 +1978,7 @@ int form_driver(FORM *form,               /* form to pass input to */
    the last page goes to the first, and REQ_PREV_PAGE from the first page
    goes to the last.
 
-  Inter-Field Navigation Requests
+    Inter-Field Navigation Requests
 
    These requests handle navigation between fields on the same page.
 
@@ -2039,7 +2041,7 @@ int form_driver(FORM *form,               /* form to pass input to */
    only  if  A, B, and C all share the same first line; otherwise it will
    skip over B to C.
 
-  Intra-Field Navigation Requests
+    Intra-Field Navigation Requests
 
    These  requests drive movement of the edit cursor within the currently
    selected field.
@@ -2090,7 +2092,7 @@ int form_driver(FORM *form,               /* form to pass input to */
    whitespace. The commands to move to beginning and end of line or field
    look for the first or last non-pad character in their ranges.
 
-  Scrolling Requests
+    Scrolling Requests
 
    Fields  that  are dynamic and have grown and fields explicitly created
    with   offscreen   rows   are   scrollable.   One-line  fields  scroll
@@ -2138,7 +2140,7 @@ int form_driver(FORM *form,               /* form to pass input to */
    For scrolling purposes, a page of a field is the height of its visible
    part.
 
-  Editing Requests
+    Editing Requests
 
    When  you pass the forms driver an ASCII character, it is treated as a
    request  to add the character to the field's data buffer. Whether this
@@ -2223,7 +2225,7 @@ int form_driver(FORM *form,               /* form to pass input to */
    See  Form  Options for discussion of how to set and clear the overload
    options.
 
-  Order Requests
+    Order Requests
 
    If the type of your field is ordered, and has associated functions for
    getting  the  next and previous values of the type from a given value,
@@ -2240,14 +2242,14 @@ int form_driver(FORM *form,               /* form to pass input to */
    Custom   Validation   Types),  you  can  associate  our  own  ordering
    functions.
 
-  Application Commands
+    Application Commands
 
    Form  requests  are  represented  as  integers  above the curses value
    greater   than  KEY_MAX  and  less  than  or  equal  to  the  constant
    MAX_COMMAND.  If  your  input-virtualization  routine  returns a value
    above MAX_COMMAND, the forms driver will ignore it.
 
-Field Change Hooks
+  Field Change Hooks
 
    It  is  possible  to  set  function  hooks to be executed whenever the
    current  field  or  form  changes. Here are the functions that support
@@ -2309,7 +2311,7 @@ HOOK field_term(FORM *form);     /* form to query */
    You  can  disable  any of these hooks by (re)setting them to NULL, the
    default value.
 
-Field Change Commands
+  Field Change Commands
 
    Normally,  navigation  through  the  form will be driven by the user's
    input  requests.  But  sometimes  it  is useful to be able to move the
@@ -2340,7 +2342,7 @@ int form_page(FORM *form);                /* return form's current page */
    The   initial  page  of  a  newly-created  form  is  0.  The  function
    set_form_fields() resets this.
 
-Form Options
+  Form Options
 
    Like  fields,  forms may have control option bits. They can be changed
    or queried with these functions:
@@ -2371,7 +2373,7 @@ int form_opts(FORM *form);                /* form to query */
    The option values are bit-masks and can be composed with logical-or in
    the obvious way.
 
-Custom Validation Types
+  Custom Validation Types
 
    The  form library gives you the capability to define custom validation
    types  of  your  own.  Further,  the  optional additional arguments of
@@ -2380,7 +2382,7 @@ Custom Validation Types
    with the handling of the additional arguments within custom validation
    functions.
 
-  Union Types
+    Union Types
 
    The  simplest  way  to create a custom data type is to compose it from
    two preexisting ones:
@@ -2397,7 +2399,7 @@ FIELD *link_fieldtype(FIELDTYPE *type1,
    first  type,  then  for  the  second,  to  figure what type the buffer
    contents should be treated as.
 
-  New Field Types
+    New Field Types
 
    To  create  a field type from scratch, you need to specify one or both
    of the following things:
@@ -2430,7 +2432,7 @@ int free_fieldtype(FIELDTYPE *ftype);     /* type to free */
    argument.  It  too should return TRUE if the character is valid, FALSE
    otherwise.
 
-  Validation Function Arguments
+    Validation Function Arguments
 
    Your  field-  and  character-  validation  functions  will be passed a
    second  argument  as  well.  This  second argument is the address of a
@@ -2479,7 +2481,7 @@ int set_fieldtype_arg(FIELDTYPE *type,    /* type to alter */
    functions  should  never  see  a  NULL file pointer and need not check
    specially for it.
 
-  Order Functions For Custom Types
+    Order Functions For Custom Types
 
    Some  custom  field  types are simply ordered in the same well-defined
    way  that  TYPE_ENUM  is.  For  such  types,  it is possible to define
@@ -2499,7 +2501,7 @@ int set_fieldtype_arg(FIELDTYPE *type,    /* type to alter */
    success  (a legal next or previous value was set) or FALSE to indicate
    failure.
 
-  Avoiding Problems
+    Avoiding Problems
 
    The  interface  for  defining  custom types is complicated and tricky.
    Rather  than attempting to create a custom type entirely from scratch,
diff --git a/contrib/ncurses/form/Makefile.in b/contrib/ncurses/form/Makefile.in
index 3d713469fe0c..a950a3e8ae14 100644
--- a/contrib/ncurses/form/Makefile.in
+++ b/contrib/ncurses/form/Makefile.in
@@ -1,4 +1,4 @@
-# $Id: Makefile.in,v 1.71 2021/01/23 20:42:08 tom Exp $
+# $Id: Makefile.in,v 1.72 2021/07/03 15:45:33 tom Exp $
 ##############################################################################
 # Copyright 2020,2021 Thomas E. Dickey                                       #
 # Copyright 1998-2015,2018 Free Software Foundation, Inc.                    #
@@ -134,6 +134,19 @@ AUTO_SRC	= \
 		../include/form.h
 
 ################################################################################
+
+@MAKE_PHONY@.PHONY :	all
+@MAKE_PHONY@.PHONY :	clean
+@MAKE_PHONY@.PHONY :	distclean
+@MAKE_PHONY@.PHONY :	install
+@MAKE_PHONY@.PHONY :	install.libs
+@MAKE_PHONY@.PHONY :	libs
+@MAKE_PHONY@.PHONY :	mostlyclean
+@MAKE_PHONY@.PHONY :	realclean
+@MAKE_PHONY@.PHONY :	sources
+@MAKE_PHONY@.PHONY :	uninstall
+@MAKE_PHONY@.PHONY :	uninstall.libs
+
 all \
 libs \
 install ::	$(AUTO_SRC) $(LIBRARIES)
diff --git a/contrib/ncurses/form/READ.ME b/contrib/ncurses/form/READ.ME
index 0cefd57d1965..7c6ad972e576 100644
--- a/contrib/ncurses/form/READ.ME
+++ b/contrib/ncurses/form/READ.ME
@@ -1,5 +1,5 @@
 -------------------------------------------------------------------------------
--- Copyright 2020 Thomas E. Dickey                                           --
+-- Copyright 2020,2021 Thomas E. Dickey                                      --
 -- Copyright 1998-2003,2006 Free Software Foundation, Inc.                   --
 --                                                                           --
 -- Permission is hereby granted, free of charge, to any person obtaining a   --
@@ -26,18 +26,18 @@
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
--- $Id: READ.ME,v 0.8 2020/02/02 23:34:34 tom Exp $
+-- $Id: READ.ME,v 0.9 2021/06/17 21:20:30 tom Exp $
 -------------------------------------------------------------------------------
 
 This is a clone of the form library that is available with typical
 System V curses implementations (ETI).
 
 It is modelled after the documentation that comes for this library with
-a 386 based SVR4 implementation (ESIX).  
+a 386 based SVR4 implementation (ESIX).
 
 The development environment was and is an ELF based Linux system.
 
-For things that still need doing, see the TO-DO file in the top-level 
+For things that still need doing, see the TO-DO file in the top-level
 directory.
 
 Juergen Pfeifer
diff --git a/contrib/ncurses/form/fld_def.c b/contrib/ncurses/form/fld_def.c
index de664eb5f803..51bdc6485800 100644
--- a/contrib/ncurses/form/fld_def.c
+++ b/contrib/ncurses/form/fld_def.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2012,2014 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -33,7 +33,7 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: fld_def.c,v 1.43 2020/05/24 01:40:20 anonymous.maarten Exp $")
+MODULE_ID("$Id: fld_def.c,v 1.44 2021/03/27 23:49:53 tom Exp $")
 
 /* this can't be readonly */
 static FIELD default_field =
@@ -86,14 +86,13 @@ FORM_EXPORT(TypeArgument *)
 _nc_Make_Argument(const FIELDTYPE *typ, va_list *ap, int *err)
 {
   TypeArgument *res = (TypeArgument *)0;
-  TypeArgument *p;
 
   if (typ != 0 && (typ->status & _HAS_ARGS) != 0)
     {
       assert(err != 0 && ap != (va_list *)0);
       if ((typ->status & _LINKED_TYPE) != 0)
 	{
-	  p = typeMalloc(TypeArgument, 1);
+	  TypeArgument *p = typeMalloc(TypeArgument, 1);
 
 	  if (p != 0)
 	    {
@@ -134,14 +133,13 @@ FORM_EXPORT(TypeArgument *)
 _nc_Copy_Argument(const FIELDTYPE *typ, const TypeArgument *argp, int *err)
 {
   TypeArgument *res = (TypeArgument *)0;
-  TypeArgument *p;
 
   if (typ != 0 && (typ->status & _HAS_ARGS) != 0)
     {
       assert(err != 0 && argp != 0);
       if ((typ->status & _LINKED_TYPE) != 0)
 	{
-	  p = typeMalloc(TypeArgument, 1);
+	  TypeArgument *p = typeMalloc(TypeArgument, 1);
 
 	  if (p != 0)
 	    {
diff --git a/contrib/ncurses/form/fld_ftchoice.c b/contrib/ncurses/form/fld_ftchoice.c
index 265f94f869c3..dfaca149c087 100644
--- a/contrib/ncurses/form/fld_ftchoice.c
+++ b/contrib/ncurses/form/fld_ftchoice.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2018-2020,2021 Thomas E. Dickey                                *
  * Copyright 1998-2012,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -33,10 +33,10 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: fld_ftchoice.c,v 1.17 2020/05/24 01:40:20 anonymous.maarten Exp $")
+MODULE_ID("$Id: fld_ftchoice.c,v 1.18 2021/06/17 21:26:02 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int set_fieldtype_choice(
 |                          FIELDTYPE *typ,
 |                          bool (* const next_choice)(FIELD *,const void *),
diff --git a/contrib/ncurses/form/fld_ftlink.c b/contrib/ncurses/form/fld_ftlink.c
index 3d8af84de999..ed16920078bb 100644
--- a/contrib/ncurses/form/fld_ftlink.c
+++ b/contrib/ncurses/form/fld_ftlink.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2010,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -33,17 +33,17 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: fld_ftlink.c,v 1.17 2020/05/24 01:40:20 anonymous.maarten Exp $")
+MODULE_ID("$Id: fld_ftlink.c,v 1.18 2021/06/17 21:20:30 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  FIELDTYPE *link_fieldtype(
 |                                FIELDTYPE *type1,
 |                                FIELDTYPE *type2)
-|   
+|
 |   Description   :  Create a new fieldtype built from the two given types.
 |                    They are connected by an logical 'OR'.
-|                    If an error occurs, errno is set to                    
+|                    If an error occurs, errno is set to
 |                       E_BAD_ARGUMENT  - invalid arguments
 |                       E_SYSTEM_ERROR  - system error (no memory)
 |
diff --git a/contrib/ncurses/form/fld_info.c b/contrib/ncurses/form/fld_info.c
index 188a31563ef2..bc8399dca743 100644
--- a/contrib/ncurses/form/fld_info.c
+++ b/contrib/ncurses/form/fld_info.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2004,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -33,15 +33,15 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: fld_info.c,v 1.15 2020/12/12 01:05:42 tom Exp $")
+MODULE_ID("$Id: fld_info.c,v 1.16 2021/06/17 21:20:30 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int field_info(const FIELD *field,
 |                                   int *rows, int *cols,
 |                                   int *frow, int *fcol,
 |                                   int *nrow, int *nbuf)
-|   
+|
 |   Description   :  Retrieve information about the field's creation parameters.
 |
 |   Return Values :  E_OK           - success
@@ -78,11 +78,11 @@ field_info(const FIELD *field,
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int dynamic_field_info(const FIELD *field,
 |                                           int *drows, int *dcols,
 |                                           int *maxgrow)
-|   
+|
 |   Description   :  Retrieve information about a dynamic field's current
 |                    dynamic parameters.
 |
diff --git a/contrib/ncurses/form/fld_just.c b/contrib/ncurses/form/fld_just.c
index 050e66f5d311..62253bcf77b6 100644
--- a/contrib/ncurses/form/fld_just.c
+++ b/contrib/ncurses/form/fld_just.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2010,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -33,12 +33,12 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: fld_just.c,v 1.16 2020/12/11 23:16:37 tom Exp $")
+MODULE_ID("$Id: fld_just.c,v 1.17 2021/06/17 21:20:30 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int set_field_just(FIELD *field, int just)
-|   
+|
 |   Description   :  Set the field's type of justification.
 |
 |   Return Values :  E_OK            - success
@@ -70,9 +70,9 @@ set_field_just(FIELD *field, int just)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int field_just( const FIELD *field )
-|   
+|
 |   Description   :  Retrieve the field's type of justification
 |
 |   Return Values :  The justification type.
diff --git a/contrib/ncurses/form/fld_link.c b/contrib/ncurses/form/fld_link.c
index dda6c97ee6d1..c0604584179f 100644
--- a/contrib/ncurses/form/fld_link.c
+++ b/contrib/ncurses/form/fld_link.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2010,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -33,17 +33,17 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: fld_link.c,v 1.16 2020/12/11 23:20:32 tom Exp $")
+MODULE_ID("$Id: fld_link.c,v 1.17 2021/06/17 21:20:30 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
-|   Function      :  FIELD *link_field(FIELD *field, int frow, int fcol)  
-|   
+|   Facility      :  libnform
+|   Function      :  FIELD *link_field(FIELD *field, int frow, int fcol)
+|
 |   Description   :  Duplicates the field at the specified position. The
 |                    new field shares its buffers with the original one,
 |                    the attributes are independent.
 |                    If an error occurs, errno is set to
-|                    
+|
 |                    E_BAD_ARGUMENT - invalid argument
 |                    E_SYSTEM_ERROR - system error
 |
diff --git a/contrib/ncurses/form/fld_max.c b/contrib/ncurses/form/fld_max.c
index bfeadf9b7fa8..325541a373b5 100644
--- a/contrib/ncurses/form/fld_max.c
+++ b/contrib/ncurses/form/fld_max.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 2019-2020,2021 Thomas E. Dickey                                *
  * Copyright 1998-2012,2013 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -33,12 +33,12 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: fld_max.c,v 1.17 2020/05/24 01:40:20 anonymous.maarten Exp $")
+MODULE_ID("$Id: fld_max.c,v 1.18 2021/06/17 21:26:02 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int set_max_field(FIELD *field, int maxgrow)
-|   
+|
 |   Description   :  Set the maximum growth for a dynamic field. If maxgrow=0
 |                    the field may grow to any possible size.
 |
diff --git a/contrib/ncurses/form/fld_move.c b/contrib/ncurses/form/fld_move.c
index c4b8313639d5..0d9ac4aebc9c 100644
--- a/contrib/ncurses/form/fld_move.c
+++ b/contrib/ncurses/form/fld_move.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2010,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -33,12 +33,12 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: fld_move.c,v 1.15 2020/12/11 23:48:05 tom Exp $")
+MODULE_ID("$Id: fld_move.c,v 1.16 2021/06/17 21:20:30 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int move_field(FIELD *field,int frow, int fcol)
-|   
+|
 |   Description   :  Moves the disconnected field to the new location in
 |                    the form's subwindow.
 |
diff --git a/contrib/ncurses/form/fld_opts.c b/contrib/ncurses/form/fld_opts.c
index a0bbbf41cc5d..ab4d55943a07 100644
--- a/contrib/ncurses/form/fld_opts.c
+++ b/contrib/ncurses/form/fld_opts.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2004,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -33,16 +33,16 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: fld_opts.c,v 1.15 2020/12/11 22:05:24 tom Exp $")
+MODULE_ID("$Id: fld_opts.c,v 1.16 2021/06/17 21:20:30 tom Exp $")
 
 /*----------------------------------------------------------------------------
   Field-Options manipulation routines
   --------------------------------------------------------------------------*/
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int set_field_opts(FIELD *field, Field_Options opts)
-|   
+|
 |   Description   :  Turns on the named options for this field and turns
 |                    off all the remaining options.
 |
@@ -65,9 +65,9 @@ set_field_opts(FIELD *field, Field_Options opts)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  Field_Options field_opts(const FIELD *field)
-|   
+|
 |   Description   :  Retrieve the field's options.
 |
 |   Return Values :  The options.
@@ -81,10 +81,10 @@ field_opts(const FIELD *field)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int field_opts_on(FIELD *field, Field_Options opts)
-|   
-|   Description   :  Turns on the named options for this field and all the 
+|
+|   Description   :  Turns on the named options for this field and all the
 |                    remaining options are unchanged.
 |
 |   Return Values :  E_OK            - success
@@ -109,10 +109,10 @@ field_opts_on(FIELD *field, Field_Options opts)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int field_opts_off(FIELD *field, Field_Options opts)
-|   
-|   Description   :  Turns off the named options for this field and all the 
+|
+|   Description   :  Turns off the named options for this field and all the
 |                    remaining options are unchanged.
 |
 |   Return Values :  E_OK            - success
diff --git a/contrib/ncurses/form/fld_pad.c b/contrib/ncurses/form/fld_pad.c
index 962958f501b6..fdd803fee07e 100644
--- a/contrib/ncurses/form/fld_pad.c
+++ b/contrib/ncurses/form/fld_pad.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2004,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -33,12 +33,12 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: fld_pad.c,v 1.13 2020/12/11 22:05:24 tom Exp $")
+MODULE_ID("$Id: fld_pad.c,v 1.14 2021/06/17 21:20:30 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int set_field_pad(FIELD *field, int ch)
-|   
+|
 |   Description   :  Set the pad character used to fill the field. This must
 |                    be a printable character.
 |
@@ -68,9 +68,9 @@ set_field_pad(FIELD *field, int ch)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int field_pad(const FIELD *field)
-|   
+|
 |   Description   :  Retrieve the field's pad character.
 |
 |   Return Values :  The pad character.
diff --git a/contrib/ncurses/form/fld_page.c b/contrib/ncurses/form/fld_page.c
index 9029768ce2ba..6972d310396d 100644
--- a/contrib/ncurses/form/fld_page.c
+++ b/contrib/ncurses/form/fld_page.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2010,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -33,13 +33,13 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: fld_page.c,v 1.15 2020/12/11 23:15:26 tom Exp $")
+MODULE_ID("$Id: fld_page.c,v 1.16 2021/06/17 21:20:30 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int set_new_page(FIELD *field, bool new_page_flag)
-|   
-|   Description   :  Marks the field as the beginning of a new page of 
+|
+|   Description   :  Marks the field as the beginning of a new page of
 |                    the form.
 |
 |   Return Values :  E_OK         - success
@@ -63,9 +63,9 @@ set_new_page(FIELD *field, bool new_page_flag)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  bool new_page(const FIELD *field)
-|   
+|
 |   Description   :  Retrieve the information whether or not the field starts
 |                    a new page on the form.
 |
diff --git a/contrib/ncurses/form/fld_stat.c b/contrib/ncurses/form/fld_stat.c
index 7b504bf449fe..62d782edd89d 100644
--- a/contrib/ncurses/form/fld_stat.c
+++ b/contrib/ncurses/form/fld_stat.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2010,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -33,12 +33,12 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: fld_stat.c,v 1.17 2020/12/11 22:05:24 tom Exp $")
+MODULE_ID("$Id: fld_stat.c,v 1.18 2021/06/17 21:20:30 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int set_field_status(FIELD *field, bool status)
-|   
+|
 |   Description   :  Set or clear the 'changed' indication flag for that
 |                    field's primary buffer.
 |
@@ -60,11 +60,11 @@ set_field_status(FIELD *field, bool status)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  bool field_status(const FIELD *field)
-|   
+|
 |   Description   :  Retrieve the value of the 'changed' indication flag
-|                    for that field's primary buffer. 
+|                    for that field's primary buffer.
 |
 |   Return Values :  TRUE  - buffer has been changed
 |                    FALSE - buffer has not been changed
diff --git a/contrib/ncurses/form/fld_type.c b/contrib/ncurses/form/fld_type.c
index 12c92cf6e268..c557e053c00c 100644
--- a/contrib/ncurses/form/fld_type.c
+++ b/contrib/ncurses/form/fld_type.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2004,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -33,12 +33,12 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: fld_type.c,v 1.19 2020/12/11 23:20:37 tom Exp $")
+MODULE_ID("$Id: fld_type.c,v 1.20 2021/06/17 21:20:30 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int set_field_type(FIELD *field, FIELDTYPE *type,...)
-|   
+|
 |   Description   :  Associate the specified fieldtype with the field.
 |                    Certain field types take additional arguments. Look
 |                    at the spec of the field types !
@@ -81,9 +81,9 @@ set_field_type(FIELD *field, FIELDTYPE *type, ...)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  FIELDTYPE *field_type(const FIELD *field)
-|   
+|
 |   Description   :  Retrieve the associated fieldtype for this field.
 |
 |   Return Values :  Pointer to fieldtype of NULL if none is defined.
diff --git a/contrib/ncurses/form/fld_user.c b/contrib/ncurses/form/fld_user.c
index 2f51fa67e3dc..1b13e626506b 100644
--- a/contrib/ncurses/form/fld_user.c
+++ b/contrib/ncurses/form/fld_user.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2004,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -33,12 +33,12 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: fld_user.c,v 1.19 2020/12/12 01:05:34 tom Exp $")
+MODULE_ID("$Id: fld_user.c,v 1.20 2021/06/17 21:20:30 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int set_field_userptr(FIELD *field, void *usrptr)
-|   
+|
 |   Description   :  Set the pointer that is reserved in any field to store
 |                    application relevant information.
 |
@@ -54,9 +54,9 @@ set_field_userptr(FIELD *field, void *usrptr)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  void *field_userptr(const FIELD *field)
-|   
+|
 |   Description   :  Return the pointer that is reserved in any field to
 |                    store application relevant information.
 |
diff --git a/contrib/ncurses/form/form.h b/contrib/ncurses/form/form.h
index 59a97a3d0691..3b62e3901b8e 100644
--- a/contrib/ncurses/form/form.h
+++ b/contrib/ncurses/form/form.h
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2019-2020,2021 Thomas E. Dickey                           *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -31,7 +31,7 @@
  *   Author:  Juergen Pfeifer, 1995,1997                                    *
  ****************************************************************************/
 
-/* $Id: form.h,v 0.31 2020/07/04 20:38:43 tom Exp $ */
+/* $Id: form.h,v 0.32 2021/06/17 21:26:02 tom Exp $ */
 
 #ifndef FORM_H
 #define FORM_H
@@ -116,7 +116,7 @@ typedef struct fieldnode
   /*
    * The wide-character configuration requires extra information.  Because
    * there are existing applications that manipulate the members of FIELD
-   * directly, we cannot make the struct opaque, except by changing the ABI. 
+   * directly, we cannot make the struct opaque, except by changing the ABI.
    * Offsets of members up to this point are the same in the narrow- and
    * wide-character configuration.  But note that the type of buf depends on
    * the configuration, and is made opaque for that reason.
diff --git a/contrib/ncurses/form/form.priv.h b/contrib/ncurses/form/form.priv.h
index 048d9f84592e..ad5af63ad807 100644
--- a/contrib/ncurses/form/form.priv.h
+++ b/contrib/ncurses/form/form.priv.h
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2021,2024 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -31,7 +31,7 @@
  *   Author:  Juergen Pfeifer, 1995,1997                                    *
  ****************************************************************************/
 
-/* $Id: form.priv.h,v 0.47 2020/12/11 23:20:11 tom Exp $ */
+/* $Id: form.priv.h,v 0.49 2024/02/24 12:17:31 tom Exp $ */
 
 #ifndef FORM_PRIV_H
 #define FORM_PRIV_H 1
@@ -47,10 +47,6 @@
 #include <wctype.h>
 #endif
 
-#ifndef MB_LEN_MAX
-#define MB_LEN_MAX 8 /* should be >= MB_CUR_MAX, but that may be a function */
-#endif
-
 #define FIELD_CELL NCURSES_CH_T
 
 #define NCURSES_FIELD_INTERNALS char** expanded; WINDOW *working;
@@ -202,12 +198,12 @@ extern FORM_EXPORT(FIELDTYPE *) _nc_TYPE_REGEXP(void);
 extern FORM_EXPORT(FIELDTYPE *) _nc_TYPE_IPV4(void);
 
 extern FORM_EXPORT(FIELDTYPE *)
-_nc_generic_fieldtype(bool (*const field_check) (FORM*, 
-						 FIELD *, 
+_nc_generic_fieldtype(bool (*const field_check) (FORM*,
+						 FIELD *,
 						 const void *),
-		      bool (*const char_check)  (int, 
-						 FORM*, 
-						 FIELD*, 
+		      bool (*const char_check)  (int,
+						 FORM*,
+						 FIELD*,
 						 const void *),
 		      bool (*const next)(FORM*,FIELD*,const void*),
 		      bool (*const prev)(FORM*,FIELD*,const void*),
diff --git a/contrib/ncurses/form/frm_cursor.c b/contrib/ncurses/form/frm_cursor.c
index daa6c5b7775a..a54b4837a7de 100644
--- a/contrib/ncurses/form/frm_cursor.c
+++ b/contrib/ncurses/form/frm_cursor.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2004,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -33,12 +33,12 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: frm_cursor.c,v 1.12 2020/05/24 01:40:20 anonymous.maarten Exp $")
+MODULE_ID("$Id: frm_cursor.c,v 1.13 2021/06/17 21:20:30 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int pos_form_cursor(FORM * form)
-|   
+|
 |   Description   :  Moves the form window cursor to the location required
 |                    by the form driver to resume form processing. This may
 |                    be needed after the application calls a curses library
diff --git a/contrib/ncurses/form/frm_data.c b/contrib/ncurses/form/frm_data.c
index 0856afb845e2..940c32db99c6 100644
--- a/contrib/ncurses/form/frm_data.c
+++ b/contrib/ncurses/form/frm_data.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2010,2013 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -33,12 +33,12 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: frm_data.c,v 1.19 2020/12/11 23:20:37 tom Exp $")
+MODULE_ID("$Id: frm_data.c,v 1.21 2021/06/17 21:11:08 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  bool data_behind(const FORM *form)
-|   
+|
 |   Description   :  Check for off-screen data behind. This is nearly trivial
 |                    because the beginning of a field is fixed.
 |
@@ -70,12 +70,12 @@ data_behind(const FORM *form)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static char * Only_Padding(
 |                                    WINDOW *w,
 |                                    int len,
 |                                    int pad)
-|   
+|
 |   Description   :  Test if 'length' cells starting at the current position
 |                    contain a padding character.
 |
@@ -123,11 +123,11 @@ Only_Padding(WINDOW *w, int len, int pad)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  bool data_ahead(const FORM *form)
-|   
+|
 |   Description   :  Check for off-screen data ahead. This is more difficult
-|                    because a dynamic field has a variable end. 
+|                    because a dynamic field has a variable end.
 |
 |   Return Values :  TRUE   - there are off-screen data ahead
 |                    FALSE  - there are no off-screen data ahead
@@ -150,12 +150,11 @@ data_ahead(const FORM *form)
 
       if (Single_Line_Field(field))
 	{
-	  int check_len;
-
 	  pos = form->begincol + field->cols;
 	  while (pos < field->dcols)
 	    {
-	      check_len = field->dcols - pos;
+	      int check_len = field->dcols - pos;
+
 	      if (check_len >= field->cols)
 		check_len = field->cols;
 	      cursor_moved = TRUE;
diff --git a/contrib/ncurses/form/frm_def.c b/contrib/ncurses/form/frm_def.c
index 89ae4ec39c54..a9f21f28a944 100644
--- a/contrib/ncurses/form/frm_def.c
+++ b/contrib/ncurses/form/frm_def.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2010,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -33,7 +33,7 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: frm_def.c,v 1.29 2020/12/11 23:47:16 tom Exp $")
+MODULE_ID("$Id: frm_def.c,v 1.30 2021/03/27 23:49:58 tom Exp $")
 
 /* this can't be readonly */
 static FORM default_form =
@@ -158,7 +158,6 @@ Connect_Fields(FORM *form, FIELD **fields)
 {
   int field_cnt, j;
   int page_nr;
-  int maximum_row_in_field, maximum_col_in_field;
   _PAGE *pg;
 
   T((T_CALLED("Connect_Fields(%p,%p)"), (void *)form, (void *)fields));
@@ -199,6 +198,9 @@ Connect_Fields(FORM *form, FIELD **fields)
      size of the form */
   for (j = 0; j < field_cnt; j++)
     {
+      int maximum_row_in_field;
+      int maximum_col_in_field;
+
       if (j == 0)
 	pg->pmin = (short)j;
       else
diff --git a/contrib/ncurses/form/frm_driver.c b/contrib/ncurses/form/frm_driver.c
index ad82643ed2f7..75656d69ea2a 100644
--- a/contrib/ncurses/form/frm_driver.c
+++ b/contrib/ncurses/form/frm_driver.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2020,2021 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -33,7 +33,7 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: frm_driver.c,v 1.133 2020/12/12 00:36:42 tom Exp $")
+MODULE_ID("$Id: frm_driver.c,v 1.135 2021/09/01 23:34:01 tom Exp $")
 
 /*----------------------------------------------------------------------------
   This is the core module of the form library. It contains the majority
@@ -217,10 +217,10 @@ static FIELD_CELL myZEROS;
 static void
 check_pos(FORM *form, int lineno)
 {
-  int y, x;
-
   if (form && form->w)
     {
+      int y, x;
+
       getyx(form->w, y, x);
       if (y != form->currow || x != form->curcol)
 	{
@@ -265,10 +265,11 @@ static int
 wide_winsnstr(WINDOW *w, const cchar_t *s, int n)
 {
   int code = ERR;
-  int y, x;
 
   while (n-- > 0)
     {
+      int y, x;
+
       getyx(w, y, x);
       if ((code = wins_wch(w, s++)) != OK)
 	break;
@@ -511,7 +512,6 @@ Buffer_To_Window(const FIELD *field, WINDOW *win)
 {
   int width, height;
   int y, x;
-  int len;
   int row;
   FIELD_CELL *pBuffer;
 
@@ -525,6 +525,8 @@ Buffer_To_Window(const FIELD *field, WINDOW *win)
        row < height;
        row++, pBuffer += width)
     {
+      int len;
+
       if ((len = (int)(After_End_Of_Data(pBuffer, width) - pBuffer)) > 0)
 	{
 	  wmove(win, row, 0);
@@ -706,8 +708,6 @@ Field_Grown(FIELD *field, int amount)
 	   * realloc().
 	   */
 	  int i, j;
-	  FIELD_CELL *old_bp;
-	  FIELD_CELL *new_bp;
 
 	  result = TRUE;	/* allow sharing of recovery on failure */
 
@@ -715,8 +715,9 @@ Field_Grown(FIELD *field, int amount)
 	  field->buf = newbuf;
 	  for (i = 0; i <= field->nbuf; i++)
 	    {
-	      new_bp = Address_Of_Nth_Buffer(field, i);
-	      old_bp = oldbuf + i * (1 + old_buflen);
+	      FIELD_CELL *new_bp = Address_Of_Nth_Buffer(field, i);
+	      FIELD_CELL *old_bp = oldbuf + i * (1 + old_buflen);
+
 	      for (j = 0; j < old_buflen; ++j)
 		new_bp[j] = old_bp[j];
 	      while (j < new_buflen)
@@ -917,11 +918,12 @@ _nc_Refresh_Current_Field(FORM *form)
       else
 	{
 	  /* A multi-line, i.e. vertical scrolling field */
-	  int row_after_bottom, first_modified_row, first_unmodified_row;
+	  int first_modified_row, first_unmodified_row;
 
 	  if (field->drows > field->rows)
 	    {
-	      row_after_bottom = form->toprow + field->rows;
+	      int row_after_bottom = form->toprow + field->rows;
+
 	      if (form->currow < form->toprow)
 		{
 		  form->toprow = form->currow;
@@ -1005,7 +1007,6 @@ Perform_Justification(FIELD *field, WINDOW *win)
 {
   FIELD_CELL *bp;
   int len;
-  int col = 0;
 
   bp = (Field_Has_Option(field, O_NO_LEFT_STRIP)
 	? field->buf
@@ -1014,6 +1015,8 @@ Perform_Justification(FIELD *field, WINDOW *win)
 
   if (len > 0)
     {
+      int col = 0;
+
       assert(win && (field->drows == 1));
 
       if (field->cols - len >= 0)
@@ -1240,7 +1243,6 @@ Synchronize_Linked_Fields(FIELD *field)
 {
   FIELD *linked_field;
   int res = E_OK;
-  int syncres;
 
   if (!field)
     return (E_BAD_ARGUMENT);
@@ -1252,6 +1254,8 @@ Synchronize_Linked_Fields(FIELD *field)
        (linked_field != field) && (linked_field != 0);
        linked_field = linked_field->link)
     {
+      int syncres;
+
       if (((syncres = Synchronize_Field(linked_field)) != E_OK) &&
 	  (res == E_OK))
 	res = syncres;
@@ -1276,7 +1280,6 @@ _nc_Synchronize_Attributes(FIELD *field)
 {
   FORM *form;
   int res = E_OK;
-  WINDOW *formwin;
 
   T((T_CALLED("_nc_Synchronize_Attributes(%p)"), (void *)field));
 
@@ -1303,7 +1306,8 @@ _nc_Synchronize_Attributes(FIELD *field)
 	    }
 	  else
 	    {
-	      formwin = Get_Form_Window(form);
+	      WINDOW *formwin = Get_Form_Window(form);
+
 	      copywin(form->w, formwin,
 		      0, 0,
 		      field->frow, field->fcol,
@@ -2422,7 +2426,6 @@ Insert_String(FORM *form, int row, FIELD_CELL *txt, int len)
   int datalen = (int)(After_End_Of_Data(bp, field->dcols) - bp);
   int freelen = field->dcols - datalen;
   int requiredlen = len + 1;
-  FIELD_CELL *split;
   int result = E_REQUEST_DENIED;
 
   if (freelen >= requiredlen)
@@ -2431,7 +2434,7 @@ Insert_String(FORM *form, int row, FIELD_CELL *txt, int len)
       myINSNSTR(form->w, txt, len);
       wmove(form->w, row, len);
       myINSNSTR(form->w, &myBLANK, 1);
-      return E_OK;
+      result = E_OK;
     }
   else
     {
@@ -2447,6 +2450,8 @@ Insert_String(FORM *form, int row, FIELD_CELL *txt, int len)
 
       if (row < (field->drows - 1))
 	{
+	  FIELD_CELL *split;
+
 	  split =
 	    After_Last_Whitespace_Character(bp,
 					    (int)(Get_Start_Of_Data(bp
@@ -2470,8 +2475,8 @@ Insert_String(FORM *form, int row, FIELD_CELL *txt, int len)
 	      return E_OK;
 	    }
 	}
-      return (result);
     }
+  return (result);
 }
 
 /*---------------------------------------------------------------------------
@@ -3551,7 +3556,7 @@ Upper_Neighbor_Field(FIELD *field)
 |   Function      :  static FIELD *Down_Neighbor_Field(FIELD * field)
 |
 |   Description   :  Because of the row-major nature of sorting the fields,
-|                    it's more difficult to define what the down neighbor
+|                    it is more difficult to define what the down neighbor
 |                    field really means. We define that it must be on a
 |                    'next' line (cyclic order!) and is the leftmost
 |                    field laying on the right side of the given field. If
@@ -4474,14 +4479,13 @@ form_driver(FORM *form, int c)
 		}
 	      else if (wenclose(sub, event.y, event.x))
 		{		/* Inside the area we try to find the hit item */
-		  int i;
-
 		  ry = event.y;
 		  rx = event.x;
 		  if (wmouse_trafo(sub, &ry, &rx, FALSE))
 		    {
 		      int min_field = form->page[form->curpage].pmin;
 		      int max_field = form->page[form->curpage].pmax;
+		      int i;
 
 		      for (i = min_field; i <= max_field; ++i)
 			{
@@ -4676,14 +4680,13 @@ form_driver_w(FORM *form, int type, wchar_t c)
 		}
 	      else if (wenclose(sub, event.y, event.x))
 		{		/* Inside the area we try to find the hit item */
-		  int i;
-
 		  ry = event.y;
 		  rx = event.x;
 		  if (wmouse_trafo(sub, &ry, &rx, FALSE))
 		    {
 		      int min_field = form->page[form->curpage].pmin;
 		      int max_field = form->page[form->curpage].pmax;
+		      int i;
 
 		      for (i = min_field; i <= max_field; ++i)
 			{
diff --git a/contrib/ncurses/form/frm_opts.c b/contrib/ncurses/form/frm_opts.c
index cab044598042..62e2bebdc431 100644
--- a/contrib/ncurses/form/frm_opts.c
+++ b/contrib/ncurses/form/frm_opts.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2012,2013 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -33,12 +33,12 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: frm_opts.c,v 1.20 2020/12/12 00:37:00 tom Exp $")
+MODULE_ID("$Id: frm_opts.c,v 1.21 2021/06/17 21:20:30 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int set_form_opts(FORM *form, Form_Options opts)
-|   
+|
 |   Description   :  Turns on the named options and turns off all the
 |                    remaining options for that form.
 |
@@ -61,9 +61,9 @@ set_form_opts(FORM *form, Form_Options opts)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  Form_Options form_opts(const FORM *)
-|   
+|
 |   Description   :  Retrieves the current form options.
 |
 |   Return Values :  The option flags.
@@ -76,13 +76,13 @@ form_opts(const FORM *form)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int form_opts_on(FORM *form, Form_Options opts)
-|   
-|   Description   :  Turns on the named options; no other options are 
+|
+|   Description   :  Turns on the named options; no other options are
 |                    changed.
 |
-|   Return Values :  E_OK            - success 
+|   Return Values :  E_OK            - success
 |                    E_BAD_ARGUMENT  - invalid options
 +--------------------------------------------------------------------------*/
 FORM_EXPORT(int)
@@ -101,13 +101,13 @@ form_opts_on(FORM *form, Form_Options opts)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int form_opts_off(FORM *form, Form_Options opts)
-|   
-|   Description   :  Turns off the named options; no other options are 
+|
+|   Description   :  Turns off the named options; no other options are
 |                    changed.
 |
-|   Return Values :  E_OK            - success 
+|   Return Values :  E_OK            - success
 |                    E_BAD_ARGUMENT  - invalid options
 +--------------------------------------------------------------------------*/
 FORM_EXPORT(int)
diff --git a/contrib/ncurses/form/frm_page.c b/contrib/ncurses/form/frm_page.c
index a4030a2b5f62..ee8dd3837f6b 100644
--- a/contrib/ncurses/form/frm_page.c
+++ b/contrib/ncurses/form/frm_page.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2010,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -33,12 +33,12 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: frm_page.c,v 1.14 2020/05/24 01:40:20 anonymous.maarten Exp $")
+MODULE_ID("$Id: frm_page.c,v 1.15 2021/06/17 21:20:30 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int set_form_page(FORM * form,int  page)
-|   
+|
 |   Description   :  Set the page number of the form.
 |
 |   Return Values :  E_OK              - success
@@ -88,9 +88,9 @@ set_form_page(FORM *form, int page)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int form_page(const FORM * form)
-|   
+|
 |   Description   :  Return the current page of the form.
 |
 |   Return Values :  >= 0  : current page number
diff --git a/contrib/ncurses/form/frm_req_name.c b/contrib/ncurses/form/frm_req_name.c
index 27d4696619f4..8b76a8e4f542 100644
--- a/contrib/ncurses/form/frm_req_name.c
+++ b/contrib/ncurses/form/frm_req_name.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2012,2015 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -38,7 +38,7 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: frm_req_name.c,v 1.21 2020/05/24 01:40:20 anonymous.maarten Exp $")
+MODULE_ID("$Id: frm_req_name.c,v 1.23 2021/06/17 21:11:08 tom Exp $")
 
 #define DATA(s) { s }
 
@@ -112,9 +112,9 @@ static const char request_names[MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1][13] =
 #define A_SIZE (sizeof(request_names)/sizeof(request_names[0]))
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  const char * form_request_name (int request);
-|   
+|
 |   Description   :  Get the external name of a form request.
 |
 |   Return Values :  Pointer to name      - on success
@@ -135,9 +135,9 @@ form_request_name(int request)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int form_request_by_name (const char *str);
-|   
+|
 |   Description   :  Search for a request with this name.
 |
 |   Return Values :  Request Id       - on success
@@ -150,12 +150,13 @@ form_request_by_name(const char *str)
      to run sequentially through it.
    */
   size_t i = 0;
-  char buf[16];			/* longest name is 10 chars */
 
   T((T_CALLED("form_request_by_name(%s)"), _nc_visbuf(str)));
 
   if (str != 0 && (i = strlen(str)) != 0)
     {
+      char buf[16];		/* longest name is 10 chars */
+
       if (i > sizeof(buf) - 2)
 	i = sizeof(buf) - 2;
       memcpy(buf, str, i);
diff --git a/contrib/ncurses/form/frm_scale.c b/contrib/ncurses/form/frm_scale.c
index 833f74eb97e8..d53798e1bcee 100644
--- a/contrib/ncurses/form/frm_scale.c
+++ b/contrib/ncurses/form/frm_scale.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2004,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -33,12 +33,12 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: frm_scale.c,v 1.12 2020/05/24 01:40:20 anonymous.maarten Exp $")
+MODULE_ID("$Id: frm_scale.c,v 1.13 2021/06/17 21:20:30 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int scale_form( const FORM *form, int *rows, int *cols )
-|   
+|
 |   Description   :  Retrieve size of form
 |
 |   Return Values :  E_OK              - no error
diff --git a/contrib/ncurses/form/frm_sub.c b/contrib/ncurses/form/frm_sub.c
index f718ea4679a6..8f1de099cdf6 100644
--- a/contrib/ncurses/form/frm_sub.c
+++ b/contrib/ncurses/form/frm_sub.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2009,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -33,13 +33,13 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: frm_sub.c,v 1.14 2020/05/24 01:40:20 anonymous.maarten Exp $")
+MODULE_ID("$Id: frm_sub.c,v 1.15 2021/06/17 21:20:30 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int set_form_sub(FORM *form, WINDOW *win)
-|   
-|   Description   :  Set the subwindow of the form to win. 
+|
+|   Description   :  Set the subwindow of the form to win.
 |
 |   Return Values :  E_OK       - success
 |                    E_POSTED   - form is posted
@@ -66,9 +66,9 @@ set_form_sub(FORM *form, WINDOW *win)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  WINDOW *form_sub(const FORM *)
-|   
+|
 |   Description   :  Retrieve the window of the form.
 |
 |   Return Values :  The pointer to the Subwindow.
diff --git a/contrib/ncurses/form/frm_user.c b/contrib/ncurses/form/frm_user.c
index e4f86bb6ead0..a4a2249780ad 100644
--- a/contrib/ncurses/form/frm_user.c
+++ b/contrib/ncurses/form/frm_user.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2004,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -33,12 +33,12 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: frm_user.c,v 1.18 2020/12/12 01:05:20 tom Exp $")
+MODULE_ID("$Id: frm_user.c,v 1.19 2021/06/17 21:20:30 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int set_form_userptr(FORM *form, void *usrptr)
-|   
+|
 |   Description   :  Set the pointer that is reserved in any form to store
 |                    application relevant information.
 |
@@ -54,9 +54,9 @@ set_form_userptr(FORM *form, void *usrptr)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  void *form_userptr(const FORM *form)
-|   
+|
 |   Description   :  Return the pointer that is reserved in any form to
 |                    store application relevant information.
 |
diff --git a/contrib/ncurses/form/frm_win.c b/contrib/ncurses/form/frm_win.c
index 5f3bc3c658f7..eeea27d37366 100644
--- a/contrib/ncurses/form/frm_win.c
+++ b/contrib/ncurses/form/frm_win.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2009,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -33,13 +33,13 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: frm_win.c,v 1.18 2020/05/24 01:40:20 anonymous.maarten Exp $")
+MODULE_ID("$Id: frm_win.c,v 1.19 2021/06/17 21:20:30 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int set_form_win(FORM *form,WINDOW *win)
-|   
-|   Description   :  Set the window of the form to win. 
+|
+|   Description   :  Set the window of the form to win.
 |
 |   Return Values :  E_OK       - success
 |                    E_POSTED   - form is posted
@@ -66,9 +66,9 @@ set_form_win(FORM *form, WINDOW *win)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  WINDOW *form_win(const FORM *)
-|   
+|
 |   Description   :  Retrieve the window of the form.
 |
 |   Return Values :  The pointer to the Window or stdscr if there is none.
diff --git a/contrib/ncurses/form/fty_enum.c b/contrib/ncurses/form/fty_enum.c
index 62242b56b42f..16ffae11036f 100644
--- a/contrib/ncurses/form/fty_enum.c
+++ b/contrib/ncurses/form/fty_enum.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2009,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -35,7 +35,7 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: fty_enum.c,v 1.31 2020/12/12 01:15:37 tom Exp $")
+MODULE_ID("$Id: fty_enum.c,v 1.33 2021/06/17 21:11:08 tom Exp $")
 
 typedef struct
   {
@@ -55,9 +55,9 @@ typedef struct
 enumParams;
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static void *Generic_Enum_Type(void * arg)
-|   
+|
 |   Description   :  Allocate structure for enumeration type argument.
 |
 |   Return Values :  Pointer to argument structure or NULL on error
@@ -77,7 +77,6 @@ Generic_Enum_Type(void *arg)
 	  int cnt = 0;
 	  char **kp = (char **)0;
 	  char **kwds = (char **)0;
-	  char **kptarget;
 	  int ccase, cunique;
 
 	  T((T_CREATE("enumARG %p"), (void *)argp));
@@ -96,6 +95,8 @@ Generic_Enum_Type(void *arg)
 
 	  if (cnt > 0)
 	    {
+	      char **kptarget;
+
 	      /* We copy the keywords, because we can't rely on the fact
 	         that the caller doesn't relocate or free the memory used
 	         for the keywords (maybe he has GC)
@@ -118,9 +119,9 @@ Generic_Enum_Type(void *arg)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static void *Make_Enum_Type( va_list * ap )
-|   
+|
 |   Description   :  Allocate structure for enumeration type argument.
 |
 |   Return Values :  Pointer to argument structure or NULL on error
@@ -138,10 +139,10 @@ Make_Enum_Type(va_list *ap)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static void *Copy_Enum_Type( const void * argp )
-|   
-|   Description   :  Copy structure for enumeration type argument.  
+|
+|   Description   :  Copy structure for enumeration type argument.
 |
 |   Return Values :  Pointer to argument structure or NULL on error.
 +--------------------------------------------------------------------------*/
@@ -182,9 +183,9 @@ Copy_Enum_Type(const void *argp)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static void Free_Enum_Type( void * argp )
-|   
+|
 |   Description   :  Free structure for enumeration type argument.
 |
 |   Return Values :  -
@@ -219,11 +220,11 @@ Free_Enum_Type(void *argp)
 #define EXACT   2
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
-|   Function      :  static int Compare(const unsigned char * s,  
+|   Facility      :  libnform
+|   Function      :  static int Compare(const unsigned char * s,
 |                                       const unsigned char * buf,
 |                                       bool  ccase )
-|   
+|
 |   Description   :  Check whether or not the text in 'buf' matches the
 |                    text in 's', at least partial.
 |
@@ -274,11 +275,11 @@ Compare(const unsigned char *s, const unsigned char *buf,
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static bool Check_Enum_Field(
 |                                      FIELD * field,
 |                                      const void  * argp)
-|   
+|
 |   Description   :  Validate buffer content to be a valid enumeration value
 |
 |   Return Values :  TRUE  - field is valid
@@ -292,10 +293,11 @@ Check_Enum_Field(FIELD *field, const void *argp)
   bool unique = ((const enumARG *)argp)->checkunique;
   unsigned char *bp = (unsigned char *)field_buffer(field, 0);
   char *s, *t, *p;
-  int res;
 
   while (kwds && (s = (*kwds++)))
     {
+      int res;
+
       if ((res = Compare((unsigned char *)s, bp, ccase)) != NOMATCH)
 	{
 	  p = t = s;		/* t is at least a partial match */
@@ -331,10 +333,10 @@ static const char *dummy[] =
 {(char *)0};
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static bool Next_Enum(FIELD * field,
 |                                          const void * argp)
-|   
+|
 |   Description   :  Check for the next enumeration value
 |
 |   Return Values :  TRUE  - next value found and loaded
@@ -368,11 +370,11 @@ Next_Enum(FIELD *field, const void *argp)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static bool Previous_Enum(
 |                                          FIELD * field,
 |                                          const void * argp)
-|   
+|
 |   Description   :  Check for the previous enumeration value
 |
 |   Return Values :  TRUE  - previous value found and loaded
diff --git a/contrib/ncurses/form/fty_generic.c b/contrib/ncurses/form/fty_generic.c
index 3672d658cb31..301c80a1f07a 100644
--- a/contrib/ncurses/form/fty_generic.c
+++ b/contrib/ncurses/form/fty_generic.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2018-2020,2021 Thomas E. Dickey                                *
  * Copyright 2008-2012,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -35,7 +35,7 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: fty_generic.c,v 1.14 2020/12/12 17:27:44 tom Exp $")
+MODULE_ID("$Id: fty_generic.c,v 1.15 2021/03/27 23:49:53 tom Exp $")
 
 /*
  * This is not a full implementation of a field type, but adds some
@@ -282,7 +282,7 @@ _nc_form_cursor(const FORM *form, int *pRow, int *pCol)
   int code = E_SYSTEM_ERROR;
   WINDOW *res = (WINDOW *)0;
 
-  if (!(form == 0 || pRow == 0 || pCol == 0))
+  if (form != 0 && pRow != 0 && pCol != 0)
     {
       *pRow = form->currow;
       *pCol = form->curcol;
diff --git a/contrib/ncurses/form/fty_int.c b/contrib/ncurses/form/fty_int.c
index d06ab8b6f389..c7e3135c882b 100644
--- a/contrib/ncurses/form/fty_int.c
+++ b/contrib/ncurses/form/fty_int.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2010,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -35,7 +35,7 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: fty_int.c,v 1.31 2020/12/12 01:15:37 tom Exp $")
+MODULE_ID("$Id: fty_int.c,v 1.33 2021/06/17 21:11:08 tom Exp $")
 
 #if USE_WIDEC_SUPPORT
 #define isDigit(c) (iswdigit((wint_t)(c)) || isdigit(UChar(c)))
@@ -62,9 +62,9 @@ typedef struct
 integerPARM;
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static void *Generic_This_Type( void * arg )
-|   
+|
 |   Description   :  Allocate structure for integer type argument.
 |
 |   Return Values :  Pointer to argument structure or NULL on error
@@ -89,9 +89,9 @@ Generic_This_Type(void *arg)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static void *Make_This_Type( va_list * ap )
-|   
+|
 |   Description   :  Allocate structure for integer type argument.
 |
 |   Return Values :  Pointer to argument structure or NULL on error
@@ -109,10 +109,10 @@ Make_This_Type(va_list *ap)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static void *Copy_This_Type(const void * argp)
-|   
-|   Description   :  Copy structure for integer type argument.  
+|
+|   Description   :  Copy structure for integer type argument.
 |
 |   Return Values :  Pointer to argument structure or NULL on error.
 +--------------------------------------------------------------------------*/
@@ -136,9 +136,9 @@ Copy_This_Type(const void *argp)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static void Free_This_Type(void * argp)
-|   
+|
 |   Description   :  Free structure for integer type argument.
 |
 |   Return Values :  -
@@ -151,11 +151,11 @@ Free_This_Type(void *argp)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static bool Check_This_Field(
 |                                                 FIELD * field,
 |                                                 const void * argp)
-|   
+|
 |   Description   :  Validate buffer content to be a valid integer value
 |
 |   Return Values :  TRUE  - field is valid
@@ -170,11 +170,9 @@ Check_This_Field(FIELD *field, const void *argp)
   int prec = argi->precision;
   unsigned char *bp = (unsigned char *)field_buffer(field, 0);
   char *s = (char *)bp;
-  long val;
-  char buf[100];
   bool result = FALSE;
 
-  while (*bp && *bp == ' ')
+  while (*bp == ' ')
     bp++;
   if (*bp)
     {
@@ -183,13 +181,14 @@ Check_This_Field(FIELD *field, const void *argp)
 #if USE_WIDEC_SUPPORT
       if (*bp)
 	{
-	  bool blank = FALSE;
 	  int len;
-	  int n;
 	  wchar_t *list = _nc_Widen_String((char *)bp, &len);
 
 	  if (list != 0)
 	    {
+	      bool blank = FALSE;
+	      int n;
+
 	      result = TRUE;
 	      for (n = 0; n < len; ++n)
 		{
@@ -227,7 +226,8 @@ Check_This_Field(FIELD *field, const void *argp)
 #endif
       if (result)
 	{
-	  val = atol(s);
+	  long val = atol(s);
+
 	  if (low < high)
 	    {
 	      if (val < low || val > high)
@@ -235,6 +235,8 @@ Check_This_Field(FIELD *field, const void *argp)
 	    }
 	  if (result)
 	    {
+	      char buf[100];
+
 	      _nc_SPRINTF(buf, _nc_SLIMIT(sizeof(buf))
 			  "%.*ld", (prec > 0 ? prec : 0), val);
 	      set_field_buffer(field, 0, buf);
@@ -245,11 +247,11 @@ Check_This_Field(FIELD *field, const void *argp)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static bool Check_This_Character(
 |                                      int c,
 |                                      const void * argp)
-|   
+|
 |   Description   :  Check a character for the integer type.
 |
 |   Return Values :  TRUE  - character is valid
diff --git a/contrib/ncurses/form/fty_ipv4.c b/contrib/ncurses/form/fty_ipv4.c
index d79683de68d3..108f7b4bb177 100644
--- a/contrib/ncurses/form/fty_ipv4.c
+++ b/contrib/ncurses/form/fty_ipv4.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2006,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -35,14 +35,14 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: fty_ipv4.c,v 1.14 2020/12/12 01:15:37 tom Exp $")
+MODULE_ID("$Id: fty_ipv4.c,v 1.16 2021/06/17 21:11:08 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static bool Check_IPV4_Field(
 |                                      FIELD * field,
 |                                      const void * argp)
-|   
+|
 |   Description   :  Validate buffer content to be a valid IP number (Ver. 4)
 |
 |   Return Values :  TRUE  - field is valid
@@ -53,7 +53,7 @@ Check_IPV4_Field(FIELD *field, const void *argp GCC_UNUSED)
 {
   char *bp = field_buffer(field, 0);
   int num = 0, len;
-  unsigned int d1, d2, d3, d4;
+  unsigned int d1 = 0, d2 = 0, d3 = 0, d4 = 0;
 
   if (isdigit(UChar(*bp)))	/* Must start with digit */
     {
@@ -70,11 +70,11 @@ Check_IPV4_Field(FIELD *field, const void *argp GCC_UNUSED)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static bool Check_IPV4_Character(
-|                                      int c, 
+|                                      int c,
 |                                      const void *argp )
-|   
+|
 |   Description   :  Check a character for unsigned type or period.
 |
 |   Return Values :  TRUE  - character is valid
diff --git a/contrib/ncurses/form/fty_num.c b/contrib/ncurses/form/fty_num.c
index 9eafaecb726c..34cef6364bdb 100644
--- a/contrib/ncurses/form/fty_num.c
+++ b/contrib/ncurses/form/fty_num.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 2019-2020,2021 Thomas E. Dickey                                *
  * Copyright 1998-2010,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -35,7 +35,7 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: fty_num.c,v 1.36 2020/12/12 01:15:37 tom Exp $")
+MODULE_ID("$Id: fty_num.c,v 1.37 2021/03/27 23:49:58 tom Exp $")
 
 #if HAVE_LOCALE_H
 #include <locale.h>
@@ -188,12 +188,10 @@ Check_This_Field(FIELD *field, const void *argp)
   int prec = argn->precision;
   unsigned char *bp = (unsigned char *)field_buffer(field, 0);
   char *s = (char *)bp;
-  double val = 0.0;
   struct lconv *L = argn->L;
-  char buf[64];
   bool result = FALSE;
 
-  while (*bp && *bp == ' ')
+  while (*bp == ' ')
     bp++;
   if (*bp)
     {
@@ -202,14 +200,15 @@ Check_This_Field(FIELD *field, const void *argp)
 #if USE_WIDEC_SUPPORT
       if (*bp)
 	{
-	  bool blank = FALSE;
-	  int state = 0;
 	  int len;
-	  int n;
 	  wchar_t *list = _nc_Widen_String((char *)bp, &len);
 
 	  if (list != 0)
 	    {
+	      bool blank = FALSE;
+	      int state = 0;
+	      int n;
+
 	      result = TRUE;
 	      for (n = 0; n < len; ++n)
 		{
@@ -265,7 +264,8 @@ Check_This_Field(FIELD *field, const void *argp)
 #endif
       if (result)
 	{
-	  val = atof(s);
+	  double val = atof(s);
+
 	  if (low < high)
 	    {
 	      if (val < low || val > high)
@@ -273,6 +273,8 @@ Check_This_Field(FIELD *field, const void *argp)
 	    }
 	  if (result)
 	    {
+	      char buf[64];
+
 	      _nc_SPRINTF(buf, _nc_SLIMIT(sizeof(buf))
 			  "%.*f", (prec > 0 ? prec : 0), val);
 	      set_field_buffer(field, 0, buf);
diff --git a/contrib/ncurses/form/fty_regex.c b/contrib/ncurses/form/fty_regex.c
index 616b383ad49e..62dcab58c352 100644
--- a/contrib/ncurses/form/fty_regex.c
+++ b/contrib/ncurses/form/fty_regex.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2018-2020,2021 Thomas E. Dickey                                *
  * Copyright 1998-2012,2015 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -35,12 +35,43 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: fty_regex.c,v 1.32 2020/12/12 01:15:37 tom Exp $")
+MODULE_ID("$Id: fty_regex.c,v 1.33 2021/08/14 15:01:52 tom Exp $")
 
 #if HAVE_REGEX_H_FUNCS || HAVE_LIB_PCRE2	/* We prefer POSIX regex */
 
 #if HAVE_PCRE2POSIX_H
 #include <pcre2posix.h>
+
+/* pcre2 used to provide its "POSIX" entrypoints using the same names as the
+ * standard ones in the C runtime, but that never worked because the linker
+ * would use the C runtime.  Debian patched the library to fix this symbol
+ * conflict, but overlooked the header file, and Debian's patch was made
+ * obsolete when pcre2 was changed early in 2019 to provide different names.
+ *
+ * Here is a workaround to make the older version of Debian's package work.
+ */
+#if !defined(PCRE2regcomp) && defined(HAVE_PCRE2REGCOMP)
+
+#undef regcomp
+#undef regexec
+#undef regfree
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+  PCRE2POSIX_EXP_DECL int PCRE2regcomp(regex_t *, const char *, int);
+  PCRE2POSIX_EXP_DECL int PCRE2regexec(const regex_t *, const char *, size_t,
+				       regmatch_t *, int);
+  PCRE2POSIX_EXP_DECL void PCRE2regfree(regex_t *);
+#ifdef __cplusplus
+}				/* extern "C" */
+#endif
+#define regcomp(r,s,n)          PCRE2regcomp(r,s,n)
+#define regexec(r,s,n,m,x)      PCRE2regexec(r,s,n,m,x)
+#define regfree(r)              PCRE2regfree(r)
+#endif
+/* end workaround... */
 #elif HAVE_PCREPOSIX_H
 #include <pcreposix.h>
 #else
diff --git a/contrib/ncurses/form/llib-lform b/contrib/ncurses/form/llib-lform
index b7f2acb05332..334f8cb1c819 100644
--- a/contrib/ncurses/form/llib-lform
+++ b/contrib/ncurses/form/llib-lform
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2015,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -65,11 +65,11 @@ Form_Hook _nc_retrace_form_hook(
 
 #undef set_fieldtype_arg
 int	set_fieldtype_arg(
-		FIELDTYPE *typ, 
+		FIELDTYPE *typ,
 		void	*(*const make_arg)(
-		va_list	*p1), 
+		va_list	*p1),
 		void	*(*const copy_arg)(
-		const void *p1), 
+		const void *p1),
 		void	(*const free_arg)(
 		void	*p1))
 		{ return(*(int *)0); }
@@ -83,7 +83,7 @@ void	*field_arg(
 
 #undef set_field_fore
 int	set_field_fore(
-		FIELD	*field, 
+		FIELD	*field,
 		chtype	attr)
 		{ return(*(int *)0); }
 
@@ -94,7 +94,7 @@ chtype	field_fore(
 
 #undef set_field_back
 int	set_field_back(
-		FIELD	*field, 
+		FIELD	*field,
 		chtype	attr)
 		{ return(*(int *)0); }
 
@@ -107,7 +107,7 @@ chtype	field_back(
 
 #undef set_current_field
 int	set_current_field(
-		FORM	*form, 
+		FORM	*form,
 		FIELD	*field)
 		{ return(*(int *)0); }
 
@@ -133,27 +133,27 @@ FIELD	*_nc_Default_Field;
 
 #undef _nc_Make_Argument
 TypeArgument *_nc_Make_Argument(
-		const FIELDTYPE *typ, 
-		va_list	*ap, 
+		const FIELDTYPE *typ,
+		va_list	*ap,
 		int	*err)
 		{ return(*(TypeArgument **)0); }
 
 #undef _nc_Copy_Argument
 TypeArgument *_nc_Copy_Argument(
-		const FIELDTYPE *typ, 
-		const TypeArgument *argp, 
+		const FIELDTYPE *typ,
+		const TypeArgument *argp,
 		int	*err)
 		{ return(*(TypeArgument **)0); }
 
 #undef _nc_Free_Argument
 void	_nc_Free_Argument(
-		const FIELDTYPE *typ, 
+		const FIELDTYPE *typ,
 		TypeArgument *argp)
 		{ /* void */ }
 
 #undef _nc_Copy_Type
 NCURSES_BOOL _nc_Copy_Type(
-		FIELD	*dst, 
+		FIELD	*dst,
 		FIELD const *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -164,11 +164,11 @@ void	_nc_Free_Type(
 
 #undef new_field
 FIELD	*new_field(
-		int	rows, 
-		int	cols, 
-		int	frow, 
-		int	fcol, 
-		int	nrow, 
+		int	rows,
+		int	cols,
+		int	frow,
+		int	fcol,
+		int	nrow,
 		int	nbuf)
 		{ return(*(FIELD **)0); }
 
@@ -181,8 +181,8 @@ int	free_field(
 
 #undef dup_field
 FIELD	*dup_field(
-		FIELD	*field, 
-		int	frow, 
+		FIELD	*field,
+		int	frow,
 		int	fcol)
 		{ return(*(FIELD **)0); }
 
@@ -190,12 +190,12 @@ FIELD	*dup_field(
 
 #undef set_fieldtype_choice
 int	set_fieldtype_choice(
-		FIELDTYPE *typ, 
+		FIELDTYPE *typ,
 		NCURSES_BOOL (*const next_choice)(
-		FIELD	*p1, 
-		const void *p2), 
+		FIELD	*p1,
+		const void *p2),
 		NCURSES_BOOL (*const prev_choice)(
-		FIELD	*p1, 
+		FIELD	*p1,
 		const void *p2))
 		{ return(*(int *)0); }
 
@@ -203,7 +203,7 @@ int	set_fieldtype_choice(
 
 #undef link_fieldtype
 FIELDTYPE *link_fieldtype(
-		FIELDTYPE *type1, 
+		FIELDTYPE *type1,
 		FIELDTYPE *type2)
 		{ return(*(FIELDTYPE **)0); }
 
@@ -211,20 +211,20 @@ FIELDTYPE *link_fieldtype(
 
 #undef field_info
 int	field_info(
-		const FIELD *field, 
-		int	*rows, 
-		int	*cols, 
-		int	*frow, 
-		int	*fcol, 
-		int	*nrow, 
+		const FIELD *field,
+		int	*rows,
+		int	*cols,
+		int	*frow,
+		int	*fcol,
+		int	*nrow,
 		int	*nbuf)
 		{ return(*(int *)0); }
 
 #undef dynamic_field_info
 int	dynamic_field_info(
-		const FIELD *field, 
-		int	*drows, 
-		int	*dcols, 
+		const FIELD *field,
+		int	*drows,
+		int	*dcols,
 		int	*maxgrow)
 		{ return(*(int *)0); }
 
@@ -232,7 +232,7 @@ int	dynamic_field_info(
 
 #undef set_field_just
 int	set_field_just(
-		FIELD	*field, 
+		FIELD	*field,
 		int	just)
 		{ return(*(int *)0); }
 
@@ -245,8 +245,8 @@ int	field_just(
 
 #undef link_field
 FIELD	*link_field(
-		FIELD	*field, 
-		int	frow, 
+		FIELD	*field,
+		int	frow,
 		int	fcol)
 		{ return(*(FIELD **)0); }
 
@@ -254,7 +254,7 @@ FIELD	*link_field(
 
 #undef set_max_field
 int	set_max_field(
-		FIELD	*field, 
+		FIELD	*field,
 		int	maxgrow)
 		{ return(*(int *)0); }
 
@@ -262,8 +262,8 @@ int	set_max_field(
 
 #undef move_field
 int	move_field(
-		FIELD	*field, 
-		int	frow, 
+		FIELD	*field,
+		int	frow,
 		int	fcol)
 		{ return(*(int *)0); }
 
@@ -275,10 +275,10 @@ FIELDTYPE *_nc_Default_FieldType;
 #undef new_fieldtype
 FIELDTYPE *new_fieldtype(
 		NCURSES_BOOL (*const field_check)(
-		FIELD	*p1, 
-		const void *p2), 
+		FIELD	*p1,
+		const void *p2),
 		NCURSES_BOOL (*const char_check)(
-		int	p1, 
+		int	p1,
 		const void *p2))
 		{ return(*(FIELDTYPE **)0); }
 
@@ -291,7 +291,7 @@ int	free_fieldtype(
 
 #undef set_field_opts
 int	set_field_opts(
-		FIELD	*field, 
+		FIELD	*field,
 		Field_Options opts)
 		{ return(*(int *)0); }
 
@@ -302,13 +302,13 @@ Field_Options field_opts(
 
 #undef field_opts_on
 int	field_opts_on(
-		FIELD	*field, 
+		FIELD	*field,
 		Field_Options opts)
 		{ return(*(int *)0); }
 
 #undef field_opts_off
 int	field_opts_off(
-		FIELD	*field, 
+		FIELD	*field,
 		Field_Options opts)
 		{ return(*(int *)0); }
 
@@ -316,7 +316,7 @@ int	field_opts_off(
 
 #undef set_field_pad
 int	set_field_pad(
-		FIELD	*field, 
+		FIELD	*field,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -329,7 +329,7 @@ int	field_pad(
 
 #undef set_new_page
 int	set_new_page(
-		FIELD	*field, 
+		FIELD	*field,
 		NCURSES_BOOL new_page_flag)
 		{ return(*(int *)0); }
 
@@ -342,7 +342,7 @@ NCURSES_BOOL new_page(
 
 #undef set_field_status
 int	set_field_status(
-		FIELD	*field, 
+		FIELD	*field,
 		NCURSES_BOOL status)
 		{ return(*(int *)0); }
 
@@ -355,8 +355,8 @@ NCURSES_BOOL field_status(
 
 #undef set_field_type
 int	set_field_type(
-		FIELD	*field, 
-		FIELDTYPE *type, 
+		FIELD	*field,
+		FIELDTYPE *type,
 		...)
 		{ return(*(int *)0); }
 
@@ -369,7 +369,7 @@ FIELDTYPE *field_type(
 
 #undef set_field_userptr
 int	set_field_userptr(
-		FIELD	*field, 
+		FIELD	*field,
 		void	*usrptr)
 		{ return(*(int *)0); }
 
@@ -404,7 +404,7 @@ FORM	*_nc_Default_Form;
 
 #undef new_form_sp
 FORM	*new_form_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		FIELD	**fields)
 		{ return(*(FORM **)0); }
 
@@ -420,7 +420,7 @@ int	free_form(
 
 #undef set_form_fields
 int	set_form_fields(
-		FORM	*form, 
+		FORM	*form,
 		FIELD	**fields)
 		{ return(*(int *)0); }
 
@@ -438,8 +438,8 @@ int	field_count(
 
 #undef _nc_get_fieldbuffer
 void	_nc_get_fieldbuffer(
-		FORM	*form, 
-		FIELD	*field, 
+		FORM	*form,
+		FIELD	*field,
 		char	*buf)
 		{ /* void */ }
 
@@ -460,7 +460,7 @@ int	_nc_Synchronize_Attributes(
 
 #undef _nc_Synchronize_Options
 int	_nc_Synchronize_Options(
-		FIELD	*field, 
+		FIELD	*field,
 		Field_Options newopts)
 		{ return(*(int *)0); }
 
@@ -471,7 +471,7 @@ void	_nc_Unset_Current_Field(
 
 #undef _nc_Set_Current_Field
 int	_nc_Set_Current_Field(
-		FORM	*form, 
+		FORM	*form,
 		FIELD	*newfield)
 		{ return(*(int *)0); }
 
@@ -487,34 +487,34 @@ FIELD	*_nc_First_Active_Field(
 
 #undef _nc_Set_Form_Page
 int	_nc_Set_Form_Page(
-		FORM	*form, 
-		int	page, 
+		FORM	*form,
+		int	page,
 		FIELD	*field)
 		{ return(*(int *)0); }
 
 typedef struct
 {
-  int keycode; 
-  int (*cmd) (FORM *); 
+  int keycode;
+  int (*cmd) (FORM *);
 }
 Binding_Info;
 
 #undef form_driver
 int	form_driver(
-		FORM	*form, 
+		FORM	*form,
 		int	c)
 		{ return(*(int *)0); }
 
 #undef set_field_buffer
 int	set_field_buffer(
-		FIELD	*field, 
-		int	buffer, 
+		FIELD	*field,
+		int	buffer,
 		const char *value)
 		{ return(*(int *)0); }
 
 #undef field_buffer
 char	*field_buffer(
-		const FIELD *field, 
+		const FIELD *field,
 		int	buffer)
 		{ return(*(char **)0); }
 
@@ -522,7 +522,7 @@ char	*field_buffer(
 
 #undef set_field_init
 int	set_field_init(
-		FORM	*form, 
+		FORM	*form,
 		Form_Hook func)
 		{ return(*(int *)0); }
 
@@ -533,7 +533,7 @@ Form_Hook field_init(
 
 #undef set_field_term
 int	set_field_term(
-		FORM	*form, 
+		FORM	*form,
 		Form_Hook func)
 		{ return(*(int *)0); }
 
@@ -544,7 +544,7 @@ Form_Hook field_term(
 
 #undef set_form_init
 int	set_form_init(
-		FORM	*form, 
+		FORM	*form,
 		Form_Hook func)
 		{ return(*(int *)0); }
 
@@ -555,7 +555,7 @@ Form_Hook form_init(
 
 #undef set_form_term
 int	set_form_term(
-		FORM	*form, 
+		FORM	*form,
 		Form_Hook func)
 		{ return(*(int *)0); }
 
@@ -568,7 +568,7 @@ Form_Hook form_term(
 
 #undef set_form_opts
 int	set_form_opts(
-		FORM	*form, 
+		FORM	*form,
 		Form_Options opts)
 		{ return(*(int *)0); }
 
@@ -579,13 +579,13 @@ Form_Options form_opts(
 
 #undef form_opts_on
 int	form_opts_on(
-		FORM	*form, 
+		FORM	*form,
 		Form_Options opts)
 		{ return(*(int *)0); }
 
 #undef form_opts_off
 int	form_opts_off(
-		FORM	*form, 
+		FORM	*form,
 		Form_Options opts)
 		{ return(*(int *)0); }
 
@@ -593,7 +593,7 @@ int	form_opts_off(
 
 #undef set_form_page
 int	set_form_page(
-		FORM	*form, 
+		FORM	*form,
 		int	page)
 		{ return(*(int *)0); }
 
@@ -630,8 +630,8 @@ int	form_request_by_name(
 
 #undef scale_form
 int	scale_form(
-		const FORM *form, 
-		int	*rows, 
+		const FORM *form,
+		int	*rows,
 		int	*cols)
 		{ return(*(int *)0); }
 
@@ -639,7 +639,7 @@ int	scale_form(
 
 #undef set_form_sub
 int	set_form_sub(
-		FORM	*form, 
+		FORM	*form,
 		WINDOW	*win)
 		{ return(*(int *)0); }
 
@@ -652,7 +652,7 @@ WINDOW	*form_sub(
 
 #undef set_form_userptr
 int	set_form_userptr(
-		FORM	*form, 
+		FORM	*form,
 		void	*usrptr)
 		{ return(*(int *)0); }
 
@@ -665,7 +665,7 @@ void	*form_userptr(
 
 #undef set_form_win
 int	set_form_win(
-		FORM	*form, 
+		FORM	*form,
 		WINDOW	*win)
 		{ return(*(int *)0); }
 
@@ -735,38 +735,38 @@ FIELDTYPE *_nc_TYPE_ENUM(void)
 #undef _nc_generic_fieldtype
 FIELDTYPE *_nc_generic_fieldtype(
 		NCURSES_BOOL (*const field_check)(
-		FORM	*p1, 
-		FIELD	*p2, 
-		const void *p3), 
+		FORM	*p1,
+		FIELD	*p2,
+		const void *p3),
 		NCURSES_BOOL (*const char_check)(
-		int	p1, 
-		FORM	*p2, 
-		FIELD	*p3, 
-		const void *p4), 
+		int	p1,
+		FORM	*p2,
+		FIELD	*p3,
+		const void *p4),
 		NCURSES_BOOL (*const next)(
-		FORM	*p1, 
-		FIELD	*p2, 
-		const void *p3), 
+		FORM	*p1,
+		FIELD	*p2,
+		const void *p3),
 		NCURSES_BOOL (*const prev)(
-		FORM	*p1, 
-		FIELD	*p2, 
-		const void *p3), 
+		FORM	*p1,
+		FIELD	*p2,
+		const void *p3),
 		void	(*freecallback)(
 		void	*p1))
 		{ return(*(FIELDTYPE **)0); }
 
 #undef _nc_set_generic_fieldtype
 int	_nc_set_generic_fieldtype(
-		FIELD	*field, 
-		FIELDTYPE *ftyp, 
+		FIELD	*field,
+		FIELDTYPE *ftyp,
 		int	(*argiterator)(
 		void	**p1))
 		{ return(*(int *)0); }
 
 #undef _nc_form_cursor
 WINDOW	*_nc_form_cursor(
-		const FORM *form, 
-		int	*pRow, 
+		const FORM *form,
+		int	*pRow,
 		int	*pCol)
 		{ return(*(WINDOW **)0); }
 
diff --git a/contrib/ncurses/form/llib-lformt b/contrib/ncurses/form/llib-lformt
index 6460016175f1..d91b3f079eb0 100644
--- a/contrib/ncurses/form/llib-lformt
+++ b/contrib/ncurses/form/llib-lformt
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 2010-2015,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -65,11 +65,11 @@ Form_Hook _nc_retrace_form_hook(
 
 #undef set_fieldtype_arg
 int	set_fieldtype_arg(
-		FIELDTYPE *typ, 
+		FIELDTYPE *typ,
 		void	*(*const make_arg)(
-		va_list	*p1), 
+		va_list	*p1),
 		void	*(*const copy_arg)(
-		const void *p1), 
+		const void *p1),
 		void	(*const free_arg)(
 		void	*p1))
 		{ return(*(int *)0); }
@@ -83,7 +83,7 @@ void	*field_arg(
 
 #undef set_field_fore
 int	set_field_fore(
-		FIELD	*field, 
+		FIELD	*field,
 		chtype	attr)
 		{ return(*(int *)0); }
 
@@ -94,7 +94,7 @@ chtype	field_fore(
 
 #undef set_field_back
 int	set_field_back(
-		FIELD	*field, 
+		FIELD	*field,
 		chtype	attr)
 		{ return(*(int *)0); }
 
@@ -107,7 +107,7 @@ chtype	field_back(
 
 #undef set_current_field
 int	set_current_field(
-		FORM	*form, 
+		FORM	*form,
 		FIELD	*field)
 		{ return(*(int *)0); }
 
@@ -133,27 +133,27 @@ FIELD	*_nc_Default_Field;
 
 #undef _nc_Make_Argument
 TypeArgument *_nc_Make_Argument(
-		const FIELDTYPE *typ, 
-		va_list	*ap, 
+		const FIELDTYPE *typ,
+		va_list	*ap,
 		int	*err)
 		{ return(*(TypeArgument **)0); }
 
 #undef _nc_Copy_Argument
 TypeArgument *_nc_Copy_Argument(
-		const FIELDTYPE *typ, 
-		const TypeArgument *argp, 
+		const FIELDTYPE *typ,
+		const TypeArgument *argp,
 		int	*err)
 		{ return(*(TypeArgument **)0); }
 
 #undef _nc_Free_Argument
 void	_nc_Free_Argument(
-		const FIELDTYPE *typ, 
+		const FIELDTYPE *typ,
 		TypeArgument *argp)
 		{ /* void */ }
 
 #undef _nc_Copy_Type
 NCURSES_BOOL _nc_Copy_Type(
-		FIELD	*dst, 
+		FIELD	*dst,
 		FIELD const *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -164,11 +164,11 @@ void	_nc_Free_Type(
 
 #undef new_field
 FIELD	*new_field(
-		int	rows, 
-		int	cols, 
-		int	frow, 
-		int	fcol, 
-		int	nrow, 
+		int	rows,
+		int	cols,
+		int	frow,
+		int	fcol,
+		int	nrow,
 		int	nbuf)
 		{ return(*(FIELD **)0); }
 
@@ -181,8 +181,8 @@ int	free_field(
 
 #undef dup_field
 FIELD	*dup_field(
-		FIELD	*field, 
-		int	frow, 
+		FIELD	*field,
+		int	frow,
 		int	fcol)
 		{ return(*(FIELD **)0); }
 
@@ -190,12 +190,12 @@ FIELD	*dup_field(
 
 #undef set_fieldtype_choice
 int	set_fieldtype_choice(
-		FIELDTYPE *typ, 
+		FIELDTYPE *typ,
 		NCURSES_BOOL (*const next_choice)(
-		FIELD	*p1, 
-		const void *p2), 
+		FIELD	*p1,
+		const void *p2),
 		NCURSES_BOOL (*const prev_choice)(
-		FIELD	*p1, 
+		FIELD	*p1,
 		const void *p2))
 		{ return(*(int *)0); }
 
@@ -203,7 +203,7 @@ int	set_fieldtype_choice(
 
 #undef link_fieldtype
 FIELDTYPE *link_fieldtype(
-		FIELDTYPE *type1, 
+		FIELDTYPE *type1,
 		FIELDTYPE *type2)
 		{ return(*(FIELDTYPE **)0); }
 
@@ -211,20 +211,20 @@ FIELDTYPE *link_fieldtype(
 
 #undef field_info
 int	field_info(
-		const FIELD *field, 
-		int	*rows, 
-		int	*cols, 
-		int	*frow, 
-		int	*fcol, 
-		int	*nrow, 
+		const FIELD *field,
+		int	*rows,
+		int	*cols,
+		int	*frow,
+		int	*fcol,
+		int	*nrow,
 		int	*nbuf)
 		{ return(*(int *)0); }
 
 #undef dynamic_field_info
 int	dynamic_field_info(
-		const FIELD *field, 
-		int	*drows, 
-		int	*dcols, 
+		const FIELD *field,
+		int	*drows,
+		int	*dcols,
 		int	*maxgrow)
 		{ return(*(int *)0); }
 
@@ -232,7 +232,7 @@ int	dynamic_field_info(
 
 #undef set_field_just
 int	set_field_just(
-		FIELD	*field, 
+		FIELD	*field,
 		int	just)
 		{ return(*(int *)0); }
 
@@ -245,8 +245,8 @@ int	field_just(
 
 #undef link_field
 FIELD	*link_field(
-		FIELD	*field, 
-		int	frow, 
+		FIELD	*field,
+		int	frow,
 		int	fcol)
 		{ return(*(FIELD **)0); }
 
@@ -254,7 +254,7 @@ FIELD	*link_field(
 
 #undef set_max_field
 int	set_max_field(
-		FIELD	*field, 
+		FIELD	*field,
 		int	maxgrow)
 		{ return(*(int *)0); }
 
@@ -262,8 +262,8 @@ int	set_max_field(
 
 #undef move_field
 int	move_field(
-		FIELD	*field, 
-		int	frow, 
+		FIELD	*field,
+		int	frow,
 		int	fcol)
 		{ return(*(int *)0); }
 
@@ -275,10 +275,10 @@ FIELDTYPE *_nc_Default_FieldType;
 #undef new_fieldtype
 FIELDTYPE *new_fieldtype(
 		NCURSES_BOOL (*const field_check)(
-		FIELD	*p1, 
-		const void *p2), 
+		FIELD	*p1,
+		const void *p2),
 		NCURSES_BOOL (*const char_check)(
-		int	p1, 
+		int	p1,
 		const void *p2))
 		{ return(*(FIELDTYPE **)0); }
 
@@ -291,7 +291,7 @@ int	free_fieldtype(
 
 #undef set_field_opts
 int	set_field_opts(
-		FIELD	*field, 
+		FIELD	*field,
 		Field_Options opts)
 		{ return(*(int *)0); }
 
@@ -302,13 +302,13 @@ Field_Options field_opts(
 
 #undef field_opts_on
 int	field_opts_on(
-		FIELD	*field, 
+		FIELD	*field,
 		Field_Options opts)
 		{ return(*(int *)0); }
 
 #undef field_opts_off
 int	field_opts_off(
-		FIELD	*field, 
+		FIELD	*field,
 		Field_Options opts)
 		{ return(*(int *)0); }
 
@@ -316,7 +316,7 @@ int	field_opts_off(
 
 #undef set_field_pad
 int	set_field_pad(
-		FIELD	*field, 
+		FIELD	*field,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -329,7 +329,7 @@ int	field_pad(
 
 #undef set_new_page
 int	set_new_page(
-		FIELD	*field, 
+		FIELD	*field,
 		NCURSES_BOOL new_page_flag)
 		{ return(*(int *)0); }
 
@@ -342,7 +342,7 @@ NCURSES_BOOL new_page(
 
 #undef set_field_status
 int	set_field_status(
-		FIELD	*field, 
+		FIELD	*field,
 		NCURSES_BOOL status)
 		{ return(*(int *)0); }
 
@@ -355,8 +355,8 @@ NCURSES_BOOL field_status(
 
 #undef set_field_type
 int	set_field_type(
-		FIELD	*field, 
-		FIELDTYPE *type, 
+		FIELD	*field,
+		FIELDTYPE *type,
 		...)
 		{ return(*(int *)0); }
 
@@ -369,7 +369,7 @@ FIELDTYPE *field_type(
 
 #undef set_field_userptr
 int	set_field_userptr(
-		FIELD	*field, 
+		FIELD	*field,
 		void	*usrptr)
 		{ return(*(int *)0); }
 
@@ -404,7 +404,7 @@ FORM	*_nc_Default_Form;
 
 #undef new_form_sp
 FORM	*new_form_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		FIELD	**fields)
 		{ return(*(FORM **)0); }
 
@@ -420,7 +420,7 @@ int	free_form(
 
 #undef set_form_fields
 int	set_form_fields(
-		FORM	*form, 
+		FORM	*form,
 		FIELD	**fields)
 		{ return(*(int *)0); }
 
@@ -438,8 +438,8 @@ int	field_count(
 
 #undef _nc_get_fieldbuffer
 void	_nc_get_fieldbuffer(
-		FORM	*form, 
-		FIELD	*field, 
+		FORM	*form,
+		FIELD	*field,
 		char	*buf)
 		{ /* void */ }
 
@@ -460,7 +460,7 @@ int	_nc_Synchronize_Attributes(
 
 #undef _nc_Synchronize_Options
 int	_nc_Synchronize_Options(
-		FIELD	*field, 
+		FIELD	*field,
 		Field_Options newopts)
 		{ return(*(int *)0); }
 
@@ -471,7 +471,7 @@ void	_nc_Unset_Current_Field(
 
 #undef _nc_Set_Current_Field
 int	_nc_Set_Current_Field(
-		FORM	*form, 
+		FORM	*form,
 		FIELD	*newfield)
 		{ return(*(int *)0); }
 
@@ -487,34 +487,34 @@ FIELD	*_nc_First_Active_Field(
 
 #undef _nc_Set_Form_Page
 int	_nc_Set_Form_Page(
-		FORM	*form, 
-		int	page, 
+		FORM	*form,
+		int	page,
 		FIELD	*field)
 		{ return(*(int *)0); }
 
 typedef struct
 {
-  int keycode; 
-  int (*cmd) (FORM *); 
+  int keycode;
+  int (*cmd) (FORM *);
 }
 Binding_Info;
 
 #undef form_driver
 int	form_driver(
-		FORM	*form, 
+		FORM	*form,
 		int	c)
 		{ return(*(int *)0); }
 
 #undef set_field_buffer
 int	set_field_buffer(
-		FIELD	*field, 
-		int	buffer, 
+		FIELD	*field,
+		int	buffer,
 		const char *value)
 		{ return(*(int *)0); }
 
 #undef field_buffer
 char	*field_buffer(
-		const FIELD *field, 
+		const FIELD *field,
 		int	buffer)
 		{ return(*(char **)0); }
 
@@ -522,7 +522,7 @@ char	*field_buffer(
 
 #undef set_field_init
 int	set_field_init(
-		FORM	*form, 
+		FORM	*form,
 		Form_Hook func)
 		{ return(*(int *)0); }
 
@@ -533,7 +533,7 @@ Form_Hook field_init(
 
 #undef set_field_term
 int	set_field_term(
-		FORM	*form, 
+		FORM	*form,
 		Form_Hook func)
 		{ return(*(int *)0); }
 
@@ -544,7 +544,7 @@ Form_Hook field_term(
 
 #undef set_form_init
 int	set_form_init(
-		FORM	*form, 
+		FORM	*form,
 		Form_Hook func)
 		{ return(*(int *)0); }
 
@@ -555,7 +555,7 @@ Form_Hook form_init(
 
 #undef set_form_term
 int	set_form_term(
-		FORM	*form, 
+		FORM	*form,
 		Form_Hook func)
 		{ return(*(int *)0); }
 
@@ -568,7 +568,7 @@ Form_Hook form_term(
 
 #undef set_form_opts
 int	set_form_opts(
-		FORM	*form, 
+		FORM	*form,
 		Form_Options opts)
 		{ return(*(int *)0); }
 
@@ -579,13 +579,13 @@ Form_Options form_opts(
 
 #undef form_opts_on
 int	form_opts_on(
-		FORM	*form, 
+		FORM	*form,
 		Form_Options opts)
 		{ return(*(int *)0); }
 
 #undef form_opts_off
 int	form_opts_off(
-		FORM	*form, 
+		FORM	*form,
 		Form_Options opts)
 		{ return(*(int *)0); }
 
@@ -593,7 +593,7 @@ int	form_opts_off(
 
 #undef set_form_page
 int	set_form_page(
-		FORM	*form, 
+		FORM	*form,
 		int	page)
 		{ return(*(int *)0); }
 
@@ -630,8 +630,8 @@ int	form_request_by_name(
 
 #undef scale_form
 int	scale_form(
-		const FORM *form, 
-		int	*rows, 
+		const FORM *form,
+		int	*rows,
 		int	*cols)
 		{ return(*(int *)0); }
 
@@ -639,7 +639,7 @@ int	scale_form(
 
 #undef set_form_sub
 int	set_form_sub(
-		FORM	*form, 
+		FORM	*form,
 		WINDOW	*win)
 		{ return(*(int *)0); }
 
@@ -652,7 +652,7 @@ WINDOW	*form_sub(
 
 #undef set_form_userptr
 int	set_form_userptr(
-		FORM	*form, 
+		FORM	*form,
 		void	*usrptr)
 		{ return(*(int *)0); }
 
@@ -665,7 +665,7 @@ void	*form_userptr(
 
 #undef set_form_win
 int	set_form_win(
-		FORM	*form, 
+		FORM	*form,
 		WINDOW	*win)
 		{ return(*(int *)0); }
 
@@ -735,38 +735,38 @@ FIELDTYPE *_nc_TYPE_ENUM(void)
 #undef _nc_generic_fieldtype
 FIELDTYPE *_nc_generic_fieldtype(
 		NCURSES_BOOL (*const field_check)(
-		FORM	*p1, 
-		FIELD	*p2, 
-		const void *p3), 
+		FORM	*p1,
+		FIELD	*p2,
+		const void *p3),
 		NCURSES_BOOL (*const char_check)(
-		int	p1, 
-		FORM	*p2, 
-		FIELD	*p3, 
-		const void *p4), 
+		int	p1,
+		FORM	*p2,
+		FIELD	*p3,
+		const void *p4),
 		NCURSES_BOOL (*const next)(
-		FORM	*p1, 
-		FIELD	*p2, 
-		const void *p3), 
+		FORM	*p1,
+		FIELD	*p2,
+		const void *p3),
 		NCURSES_BOOL (*const prev)(
-		FORM	*p1, 
-		FIELD	*p2, 
-		const void *p3), 
+		FORM	*p1,
+		FIELD	*p2,
+		const void *p3),
 		void	(*freecallback)(
 		void	*p1))
 		{ return(*(FIELDTYPE **)0); }
 
 #undef _nc_set_generic_fieldtype
 int	_nc_set_generic_fieldtype(
-		FIELD	*field, 
-		FIELDTYPE *ftyp, 
+		FIELD	*field,
+		FIELDTYPE *ftyp,
 		int	(*argiterator)(
 		void	**p1))
 		{ return(*(int *)0); }
 
 #undef _nc_form_cursor
 WINDOW	*_nc_form_cursor(
-		const FORM *form, 
-		int	*pRow, 
+		const FORM *form,
+		int	*pRow,
 		int	*pCol)
 		{ return(*(WINDOW **)0); }
 
diff --git a/contrib/ncurses/form/llib-lformtw b/contrib/ncurses/form/llib-lformtw
index a24dd1a484d8..340bf59cba53 100644
--- a/contrib/ncurses/form/llib-lformtw
+++ b/contrib/ncurses/form/llib-lformtw
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 2010-2015,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -65,11 +65,11 @@ Form_Hook _nc_retrace_form_hook(
 
 #undef set_fieldtype_arg
 int	set_fieldtype_arg(
-		FIELDTYPE *typ, 
+		FIELDTYPE *typ,
 		void	*(*const make_arg)(
-		va_list	*p1), 
+		va_list	*p1),
 		void	*(*const copy_arg)(
-		const void *p1), 
+		const void *p1),
 		void	(*const free_arg)(
 		void	*p1))
 		{ return(*(int *)0); }
@@ -83,7 +83,7 @@ void	*field_arg(
 
 #undef set_field_fore
 int	set_field_fore(
-		FIELD	*field, 
+		FIELD	*field,
 		chtype	attr)
 		{ return(*(int *)0); }
 
@@ -94,7 +94,7 @@ chtype	field_fore(
 
 #undef set_field_back
 int	set_field_back(
-		FIELD	*field, 
+		FIELD	*field,
 		chtype	attr)
 		{ return(*(int *)0); }
 
@@ -107,7 +107,7 @@ chtype	field_back(
 
 #undef set_current_field
 int	set_current_field(
-		FORM	*form, 
+		FORM	*form,
 		FIELD	*field)
 		{ return(*(int *)0); }
 
@@ -133,27 +133,27 @@ FIELD	*_nc_Default_Field;
 
 #undef _nc_Make_Argument
 TypeArgument *_nc_Make_Argument(
-		const FIELDTYPE *typ, 
-		va_list	*ap, 
+		const FIELDTYPE *typ,
+		va_list	*ap,
 		int	*err)
 		{ return(*(TypeArgument **)0); }
 
 #undef _nc_Copy_Argument
 TypeArgument *_nc_Copy_Argument(
-		const FIELDTYPE *typ, 
-		const TypeArgument *argp, 
+		const FIELDTYPE *typ,
+		const TypeArgument *argp,
 		int	*err)
 		{ return(*(TypeArgument **)0); }
 
 #undef _nc_Free_Argument
 void	_nc_Free_Argument(
-		const FIELDTYPE *typ, 
+		const FIELDTYPE *typ,
 		TypeArgument *argp)
 		{ /* void */ }
 
 #undef _nc_Copy_Type
 NCURSES_BOOL _nc_Copy_Type(
-		FIELD	*dst, 
+		FIELD	*dst,
 		FIELD const *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -164,11 +164,11 @@ void	_nc_Free_Type(
 
 #undef new_field
 FIELD	*new_field(
-		int	rows, 
-		int	cols, 
-		int	frow, 
-		int	fcol, 
-		int	nrow, 
+		int	rows,
+		int	cols,
+		int	frow,
+		int	fcol,
+		int	nrow,
 		int	nbuf)
 		{ return(*(FIELD **)0); }
 
@@ -181,8 +181,8 @@ int	free_field(
 
 #undef dup_field
 FIELD	*dup_field(
-		FIELD	*field, 
-		int	frow, 
+		FIELD	*field,
+		int	frow,
 		int	fcol)
 		{ return(*(FIELD **)0); }
 
@@ -190,12 +190,12 @@ FIELD	*dup_field(
 
 #undef set_fieldtype_choice
 int	set_fieldtype_choice(
-		FIELDTYPE *typ, 
+		FIELDTYPE *typ,
 		NCURSES_BOOL (*const next_choice)(
-		FIELD	*p1, 
-		const void *p2), 
+		FIELD	*p1,
+		const void *p2),
 		NCURSES_BOOL (*const prev_choice)(
-		FIELD	*p1, 
+		FIELD	*p1,
 		const void *p2))
 		{ return(*(int *)0); }
 
@@ -203,7 +203,7 @@ int	set_fieldtype_choice(
 
 #undef link_fieldtype
 FIELDTYPE *link_fieldtype(
-		FIELDTYPE *type1, 
+		FIELDTYPE *type1,
 		FIELDTYPE *type2)
 		{ return(*(FIELDTYPE **)0); }
 
@@ -211,20 +211,20 @@ FIELDTYPE *link_fieldtype(
 
 #undef field_info
 int	field_info(
-		const FIELD *field, 
-		int	*rows, 
-		int	*cols, 
-		int	*frow, 
-		int	*fcol, 
-		int	*nrow, 
+		const FIELD *field,
+		int	*rows,
+		int	*cols,
+		int	*frow,
+		int	*fcol,
+		int	*nrow,
 		int	*nbuf)
 		{ return(*(int *)0); }
 
 #undef dynamic_field_info
 int	dynamic_field_info(
-		const FIELD *field, 
-		int	*drows, 
-		int	*dcols, 
+		const FIELD *field,
+		int	*drows,
+		int	*dcols,
 		int	*maxgrow)
 		{ return(*(int *)0); }
 
@@ -232,7 +232,7 @@ int	dynamic_field_info(
 
 #undef set_field_just
 int	set_field_just(
-		FIELD	*field, 
+		FIELD	*field,
 		int	just)
 		{ return(*(int *)0); }
 
@@ -245,8 +245,8 @@ int	field_just(
 
 #undef link_field
 FIELD	*link_field(
-		FIELD	*field, 
-		int	frow, 
+		FIELD	*field,
+		int	frow,
 		int	fcol)
 		{ return(*(FIELD **)0); }
 
@@ -254,7 +254,7 @@ FIELD	*link_field(
 
 #undef set_max_field
 int	set_max_field(
-		FIELD	*field, 
+		FIELD	*field,
 		int	maxgrow)
 		{ return(*(int *)0); }
 
@@ -262,8 +262,8 @@ int	set_max_field(
 
 #undef move_field
 int	move_field(
-		FIELD	*field, 
-		int	frow, 
+		FIELD	*field,
+		int	frow,
 		int	fcol)
 		{ return(*(int *)0); }
 
@@ -275,10 +275,10 @@ FIELDTYPE *_nc_Default_FieldType;
 #undef new_fieldtype
 FIELDTYPE *new_fieldtype(
 		NCURSES_BOOL (*const field_check)(
-		FIELD	*p1, 
-		const void *p2), 
+		FIELD	*p1,
+		const void *p2),
 		NCURSES_BOOL (*const char_check)(
-		int	p1, 
+		int	p1,
 		const void *p2))
 		{ return(*(FIELDTYPE **)0); }
 
@@ -291,7 +291,7 @@ int	free_fieldtype(
 
 #undef set_field_opts
 int	set_field_opts(
-		FIELD	*field, 
+		FIELD	*field,
 		Field_Options opts)
 		{ return(*(int *)0); }
 
@@ -302,13 +302,13 @@ Field_Options field_opts(
 
 #undef field_opts_on
 int	field_opts_on(
-		FIELD	*field, 
+		FIELD	*field,
 		Field_Options opts)
 		{ return(*(int *)0); }
 
 #undef field_opts_off
 int	field_opts_off(
-		FIELD	*field, 
+		FIELD	*field,
 		Field_Options opts)
 		{ return(*(int *)0); }
 
@@ -316,7 +316,7 @@ int	field_opts_off(
 
 #undef set_field_pad
 int	set_field_pad(
-		FIELD	*field, 
+		FIELD	*field,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -329,7 +329,7 @@ int	field_pad(
 
 #undef set_new_page
 int	set_new_page(
-		FIELD	*field, 
+		FIELD	*field,
 		NCURSES_BOOL new_page_flag)
 		{ return(*(int *)0); }
 
@@ -342,7 +342,7 @@ NCURSES_BOOL new_page(
 
 #undef set_field_status
 int	set_field_status(
-		FIELD	*field, 
+		FIELD	*field,
 		NCURSES_BOOL status)
 		{ return(*(int *)0); }
 
@@ -355,8 +355,8 @@ NCURSES_BOOL field_status(
 
 #undef set_field_type
 int	set_field_type(
-		FIELD	*field, 
-		FIELDTYPE *type, 
+		FIELD	*field,
+		FIELDTYPE *type,
 		...)
 		{ return(*(int *)0); }
 
@@ -369,7 +369,7 @@ FIELDTYPE *field_type(
 
 #undef set_field_userptr
 int	set_field_userptr(
-		FIELD	*field, 
+		FIELD	*field,
 		void	*usrptr)
 		{ return(*(int *)0); }
 
@@ -404,7 +404,7 @@ FORM	*_nc_Default_Form;
 
 #undef new_form_sp
 FORM	*new_form_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		FIELD	**fields)
 		{ return(*(FORM **)0); }
 
@@ -420,7 +420,7 @@ int	free_form(
 
 #undef set_form_fields
 int	set_form_fields(
-		FORM	*form, 
+		FORM	*form,
 		FIELD	**fields)
 		{ return(*(int *)0); }
 
@@ -438,8 +438,8 @@ int	field_count(
 
 #undef _nc_get_fieldbuffer
 void	_nc_get_fieldbuffer(
-		FORM	*form, 
-		FIELD	*field, 
+		FORM	*form,
+		FIELD	*field,
 		cchar_t	*buf)
 		{ /* void */ }
 
@@ -460,7 +460,7 @@ int	_nc_Synchronize_Attributes(
 
 #undef _nc_Synchronize_Options
 int	_nc_Synchronize_Options(
-		FIELD	*field, 
+		FIELD	*field,
 		Field_Options newopts)
 		{ return(*(int *)0); }
 
@@ -471,7 +471,7 @@ void	_nc_Unset_Current_Field(
 
 #undef _nc_Set_Current_Field
 int	_nc_Set_Current_Field(
-		FORM	*form, 
+		FORM	*form,
 		FIELD	*newfield)
 		{ return(*(int *)0); }
 
@@ -487,47 +487,47 @@ FIELD	*_nc_First_Active_Field(
 
 #undef _nc_Set_Form_Page
 int	_nc_Set_Form_Page(
-		FORM	*form, 
-		int	page, 
+		FORM	*form,
+		int	page,
 		FIELD	*field)
 		{ return(*(int *)0); }
 
 typedef struct
 {
-  int keycode; 
-  int (*cmd) (FORM *); 
+  int keycode;
+  int (*cmd) (FORM *);
 }
 Binding_Info;
 
 #undef form_driver
 int	form_driver(
-		FORM	*form, 
+		FORM	*form,
 		int	c)
 		{ return(*(int *)0); }
 
 #undef form_driver_w
 int	form_driver_w(
-		FORM	*form, 
-		int	type, 
+		FORM	*form,
+		int	type,
 		wchar_t	c)
 		{ return(*(int *)0); }
 
 #undef set_field_buffer
 int	set_field_buffer(
-		FIELD	*field, 
-		int	buffer, 
+		FIELD	*field,
+		int	buffer,
 		const char *value)
 		{ return(*(int *)0); }
 
 #undef field_buffer
 char	*field_buffer(
-		const FIELD *field, 
+		const FIELD *field,
 		int	buffer)
 		{ return(*(char **)0); }
 
 #undef _nc_Widen_String
 wchar_t	*_nc_Widen_String(
-		char	*source, 
+		char	*source,
 		int	*lengthp)
 		{ return(*(wchar_t **)0); }
 
@@ -535,7 +535,7 @@ wchar_t	*_nc_Widen_String(
 
 #undef set_field_init
 int	set_field_init(
-		FORM	*form, 
+		FORM	*form,
 		Form_Hook func)
 		{ return(*(int *)0); }
 
@@ -546,7 +546,7 @@ Form_Hook field_init(
 
 #undef set_field_term
 int	set_field_term(
-		FORM	*form, 
+		FORM	*form,
 		Form_Hook func)
 		{ return(*(int *)0); }
 
@@ -557,7 +557,7 @@ Form_Hook field_term(
 
 #undef set_form_init
 int	set_form_init(
-		FORM	*form, 
+		FORM	*form,
 		Form_Hook func)
 		{ return(*(int *)0); }
 
@@ -568,7 +568,7 @@ Form_Hook form_init(
 
 #undef set_form_term
 int	set_form_term(
-		FORM	*form, 
+		FORM	*form,
 		Form_Hook func)
 		{ return(*(int *)0); }
 
@@ -581,7 +581,7 @@ Form_Hook form_term(
 
 #undef set_form_opts
 int	set_form_opts(
-		FORM	*form, 
+		FORM	*form,
 		Form_Options opts)
 		{ return(*(int *)0); }
 
@@ -592,13 +592,13 @@ Form_Options form_opts(
 
 #undef form_opts_on
 int	form_opts_on(
-		FORM	*form, 
+		FORM	*form,
 		Form_Options opts)
 		{ return(*(int *)0); }
 
 #undef form_opts_off
 int	form_opts_off(
-		FORM	*form, 
+		FORM	*form,
 		Form_Options opts)
 		{ return(*(int *)0); }
 
@@ -606,7 +606,7 @@ int	form_opts_off(
 
 #undef set_form_page
 int	set_form_page(
-		FORM	*form, 
+		FORM	*form,
 		int	page)
 		{ return(*(int *)0); }
 
@@ -643,8 +643,8 @@ int	form_request_by_name(
 
 #undef scale_form
 int	scale_form(
-		const FORM *form, 
-		int	*rows, 
+		const FORM *form,
+		int	*rows,
 		int	*cols)
 		{ return(*(int *)0); }
 
@@ -652,7 +652,7 @@ int	scale_form(
 
 #undef set_form_sub
 int	set_form_sub(
-		FORM	*form, 
+		FORM	*form,
 		WINDOW	*win)
 		{ return(*(int *)0); }
 
@@ -665,7 +665,7 @@ WINDOW	*form_sub(
 
 #undef set_form_userptr
 int	set_form_userptr(
-		FORM	*form, 
+		FORM	*form,
 		void	*usrptr)
 		{ return(*(int *)0); }
 
@@ -678,7 +678,7 @@ void	*form_userptr(
 
 #undef set_form_win
 int	set_form_win(
-		FORM	*form, 
+		FORM	*form,
 		WINDOW	*win)
 		{ return(*(int *)0); }
 
@@ -748,38 +748,38 @@ FIELDTYPE *_nc_TYPE_ENUM(void)
 #undef _nc_generic_fieldtype
 FIELDTYPE *_nc_generic_fieldtype(
 		NCURSES_BOOL (*const field_check)(
-		FORM	*p1, 
-		FIELD	*p2, 
-		const void *p3), 
+		FORM	*p1,
+		FIELD	*p2,
+		const void *p3),
 		NCURSES_BOOL (*const char_check)(
-		int	p1, 
-		FORM	*p2, 
-		FIELD	*p3, 
-		const void *p4), 
+		int	p1,
+		FORM	*p2,
+		FIELD	*p3,
+		const void *p4),
 		NCURSES_BOOL (*const next)(
-		FORM	*p1, 
-		FIELD	*p2, 
-		const void *p3), 
+		FORM	*p1,
+		FIELD	*p2,
+		const void *p3),
 		NCURSES_BOOL (*const prev)(
-		FORM	*p1, 
-		FIELD	*p2, 
-		const void *p3), 
+		FORM	*p1,
+		FIELD	*p2,
+		const void *p3),
 		void	(*freecallback)(
 		void	*p1))
 		{ return(*(FIELDTYPE **)0); }
 
 #undef _nc_set_generic_fieldtype
 int	_nc_set_generic_fieldtype(
-		FIELD	*field, 
-		FIELDTYPE *ftyp, 
+		FIELD	*field,
+		FIELDTYPE *ftyp,
 		int	(*argiterator)(
 		void	**p1))
 		{ return(*(int *)0); }
 
 #undef _nc_form_cursor
 WINDOW	*_nc_form_cursor(
-		const FORM *form, 
-		int	*pRow, 
+		const FORM *form,
+		int	*pRow,
 		int	*pCol)
 		{ return(*(WINDOW **)0); }
 
diff --git a/contrib/ncurses/form/llib-lformw b/contrib/ncurses/form/llib-lformw
index de4900dcff83..199e26c34655 100644
--- a/contrib/ncurses/form/llib-lformw
+++ b/contrib/ncurses/form/llib-lformw
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 2002-2015,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -65,11 +65,11 @@ Form_Hook _nc_retrace_form_hook(
 
 #undef set_fieldtype_arg
 int	set_fieldtype_arg(
-		FIELDTYPE *typ, 
+		FIELDTYPE *typ,
 		void	*(*const make_arg)(
-		va_list	*p1), 
+		va_list	*p1),
 		void	*(*const copy_arg)(
-		const void *p1), 
+		const void *p1),
 		void	(*const free_arg)(
 		void	*p1))
 		{ return(*(int *)0); }
@@ -83,7 +83,7 @@ void	*field_arg(
 
 #undef set_field_fore
 int	set_field_fore(
-		FIELD	*field, 
+		FIELD	*field,
 		chtype	attr)
 		{ return(*(int *)0); }
 
@@ -94,7 +94,7 @@ chtype	field_fore(
 
 #undef set_field_back
 int	set_field_back(
-		FIELD	*field, 
+		FIELD	*field,
 		chtype	attr)
 		{ return(*(int *)0); }
 
@@ -107,7 +107,7 @@ chtype	field_back(
 
 #undef set_current_field
 int	set_current_field(
-		FORM	*form, 
+		FORM	*form,
 		FIELD	*field)
 		{ return(*(int *)0); }
 
@@ -133,27 +133,27 @@ FIELD	*_nc_Default_Field;
 
 #undef _nc_Make_Argument
 TypeArgument *_nc_Make_Argument(
-		const FIELDTYPE *typ, 
-		va_list	*ap, 
+		const FIELDTYPE *typ,
+		va_list	*ap,
 		int	*err)
 		{ return(*(TypeArgument **)0); }
 
 #undef _nc_Copy_Argument
 TypeArgument *_nc_Copy_Argument(
-		const FIELDTYPE *typ, 
-		const TypeArgument *argp, 
+		const FIELDTYPE *typ,
+		const TypeArgument *argp,
 		int	*err)
 		{ return(*(TypeArgument **)0); }
 
 #undef _nc_Free_Argument
 void	_nc_Free_Argument(
-		const FIELDTYPE *typ, 
+		const FIELDTYPE *typ,
 		TypeArgument *argp)
 		{ /* void */ }
 
 #undef _nc_Copy_Type
 NCURSES_BOOL _nc_Copy_Type(
-		FIELD	*dst, 
+		FIELD	*dst,
 		FIELD const *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -164,11 +164,11 @@ void	_nc_Free_Type(
 
 #undef new_field
 FIELD	*new_field(
-		int	rows, 
-		int	cols, 
-		int	frow, 
-		int	fcol, 
-		int	nrow, 
+		int	rows,
+		int	cols,
+		int	frow,
+		int	fcol,
+		int	nrow,
 		int	nbuf)
 		{ return(*(FIELD **)0); }
 
@@ -181,8 +181,8 @@ int	free_field(
 
 #undef dup_field
 FIELD	*dup_field(
-		FIELD	*field, 
-		int	frow, 
+		FIELD	*field,
+		int	frow,
 		int	fcol)
 		{ return(*(FIELD **)0); }
 
@@ -190,12 +190,12 @@ FIELD	*dup_field(
 
 #undef set_fieldtype_choice
 int	set_fieldtype_choice(
-		FIELDTYPE *typ, 
+		FIELDTYPE *typ,
 		NCURSES_BOOL (*const next_choice)(
-		FIELD	*p1, 
-		const void *p2), 
+		FIELD	*p1,
+		const void *p2),
 		NCURSES_BOOL (*const prev_choice)(
-		FIELD	*p1, 
+		FIELD	*p1,
 		const void *p2))
 		{ return(*(int *)0); }
 
@@ -203,7 +203,7 @@ int	set_fieldtype_choice(
 
 #undef link_fieldtype
 FIELDTYPE *link_fieldtype(
-		FIELDTYPE *type1, 
+		FIELDTYPE *type1,
 		FIELDTYPE *type2)
 		{ return(*(FIELDTYPE **)0); }
 
@@ -211,20 +211,20 @@ FIELDTYPE *link_fieldtype(
 
 #undef field_info
 int	field_info(
-		const FIELD *field, 
-		int	*rows, 
-		int	*cols, 
-		int	*frow, 
-		int	*fcol, 
-		int	*nrow, 
+		const FIELD *field,
+		int	*rows,
+		int	*cols,
+		int	*frow,
+		int	*fcol,
+		int	*nrow,
 		int	*nbuf)
 		{ return(*(int *)0); }
 
 #undef dynamic_field_info
 int	dynamic_field_info(
-		const FIELD *field, 
-		int	*drows, 
-		int	*dcols, 
+		const FIELD *field,
+		int	*drows,
+		int	*dcols,
 		int	*maxgrow)
 		{ return(*(int *)0); }
 
@@ -232,7 +232,7 @@ int	dynamic_field_info(
 
 #undef set_field_just
 int	set_field_just(
-		FIELD	*field, 
+		FIELD	*field,
 		int	just)
 		{ return(*(int *)0); }
 
@@ -245,8 +245,8 @@ int	field_just(
 
 #undef link_field
 FIELD	*link_field(
-		FIELD	*field, 
-		int	frow, 
+		FIELD	*field,
+		int	frow,
 		int	fcol)
 		{ return(*(FIELD **)0); }
 
@@ -254,7 +254,7 @@ FIELD	*link_field(
 
 #undef set_max_field
 int	set_max_field(
-		FIELD	*field, 
+		FIELD	*field,
 		int	maxgrow)
 		{ return(*(int *)0); }
 
@@ -262,8 +262,8 @@ int	set_max_field(
 
 #undef move_field
 int	move_field(
-		FIELD	*field, 
-		int	frow, 
+		FIELD	*field,
+		int	frow,
 		int	fcol)
 		{ return(*(int *)0); }
 
@@ -275,10 +275,10 @@ FIELDTYPE *_nc_Default_FieldType;
 #undef new_fieldtype
 FIELDTYPE *new_fieldtype(
 		NCURSES_BOOL (*const field_check)(
-		FIELD	*p1, 
-		const void *p2), 
+		FIELD	*p1,
+		const void *p2),
 		NCURSES_BOOL (*const char_check)(
-		int	p1, 
+		int	p1,
 		const void *p2))
 		{ return(*(FIELDTYPE **)0); }
 
@@ -291,7 +291,7 @@ int	free_fieldtype(
 
 #undef set_field_opts
 int	set_field_opts(
-		FIELD	*field, 
+		FIELD	*field,
 		Field_Options opts)
 		{ return(*(int *)0); }
 
@@ -302,13 +302,13 @@ Field_Options field_opts(
 
 #undef field_opts_on
 int	field_opts_on(
-		FIELD	*field, 
+		FIELD	*field,
 		Field_Options opts)
 		{ return(*(int *)0); }
 
 #undef field_opts_off
 int	field_opts_off(
-		FIELD	*field, 
+		FIELD	*field,
 		Field_Options opts)
 		{ return(*(int *)0); }
 
@@ -316,7 +316,7 @@ int	field_opts_off(
 
 #undef set_field_pad
 int	set_field_pad(
-		FIELD	*field, 
+		FIELD	*field,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -329,7 +329,7 @@ int	field_pad(
 
 #undef set_new_page
 int	set_new_page(
-		FIELD	*field, 
+		FIELD	*field,
 		NCURSES_BOOL new_page_flag)
 		{ return(*(int *)0); }
 
@@ -342,7 +342,7 @@ NCURSES_BOOL new_page(
 
 #undef set_field_status
 int	set_field_status(
-		FIELD	*field, 
+		FIELD	*field,
 		NCURSES_BOOL status)
 		{ return(*(int *)0); }
 
@@ -355,8 +355,8 @@ NCURSES_BOOL field_status(
 
 #undef set_field_type
 int	set_field_type(
-		FIELD	*field, 
-		FIELDTYPE *type, 
+		FIELD	*field,
+		FIELDTYPE *type,
 		...)
 		{ return(*(int *)0); }
 
@@ -369,7 +369,7 @@ FIELDTYPE *field_type(
 
 #undef set_field_userptr
 int	set_field_userptr(
-		FIELD	*field, 
+		FIELD	*field,
 		void	*usrptr)
 		{ return(*(int *)0); }
 
@@ -404,7 +404,7 @@ FORM	*_nc_Default_Form;
 
 #undef new_form_sp
 FORM	*new_form_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		FIELD	**fields)
 		{ return(*(FORM **)0); }
 
@@ -420,7 +420,7 @@ int	free_form(
 
 #undef set_form_fields
 int	set_form_fields(
-		FORM	*form, 
+		FORM	*form,
 		FIELD	**fields)
 		{ return(*(int *)0); }
 
@@ -438,8 +438,8 @@ int	field_count(
 
 #undef _nc_get_fieldbuffer
 void	_nc_get_fieldbuffer(
-		FORM	*form, 
-		FIELD	*field, 
+		FORM	*form,
+		FIELD	*field,
 		cchar_t	*buf)
 		{ /* void */ }
 
@@ -460,7 +460,7 @@ int	_nc_Synchronize_Attributes(
 
 #undef _nc_Synchronize_Options
 int	_nc_Synchronize_Options(
-		FIELD	*field, 
+		FIELD	*field,
 		Field_Options newopts)
 		{ return(*(int *)0); }
 
@@ -471,7 +471,7 @@ void	_nc_Unset_Current_Field(
 
 #undef _nc_Set_Current_Field
 int	_nc_Set_Current_Field(
-		FORM	*form, 
+		FORM	*form,
 		FIELD	*newfield)
 		{ return(*(int *)0); }
 
@@ -487,47 +487,47 @@ FIELD	*_nc_First_Active_Field(
 
 #undef _nc_Set_Form_Page
 int	_nc_Set_Form_Page(
-		FORM	*form, 
-		int	page, 
+		FORM	*form,
+		int	page,
 		FIELD	*field)
 		{ return(*(int *)0); }
 
 typedef struct
 {
-  int keycode; 
-  int (*cmd) (FORM *); 
+  int keycode;
+  int (*cmd) (FORM *);
 }
 Binding_Info;
 
 #undef form_driver
 int	form_driver(
-		FORM	*form, 
+		FORM	*form,
 		int	c)
 		{ return(*(int *)0); }
 
 #undef form_driver_w
 int	form_driver_w(
-		FORM	*form, 
-		int	type, 
+		FORM	*form,
+		int	type,
 		wchar_t	c)
 		{ return(*(int *)0); }
 
 #undef set_field_buffer
 int	set_field_buffer(
-		FIELD	*field, 
-		int	buffer, 
+		FIELD	*field,
+		int	buffer,
 		const char *value)
 		{ return(*(int *)0); }
 
 #undef field_buffer
 char	*field_buffer(
-		const FIELD *field, 
+		const FIELD *field,
 		int	buffer)
 		{ return(*(char **)0); }
 
 #undef _nc_Widen_String
 wchar_t	*_nc_Widen_String(
-		char	*source, 
+		char	*source,
 		int	*lengthp)
 		{ return(*(wchar_t **)0); }
 
@@ -535,7 +535,7 @@ wchar_t	*_nc_Widen_String(
 
 #undef set_field_init
 int	set_field_init(
-		FORM	*form, 
+		FORM	*form,
 		Form_Hook func)
 		{ return(*(int *)0); }
 
@@ -546,7 +546,7 @@ Form_Hook field_init(
 
 #undef set_field_term
 int	set_field_term(
-		FORM	*form, 
+		FORM	*form,
 		Form_Hook func)
 		{ return(*(int *)0); }
 
@@ -557,7 +557,7 @@ Form_Hook field_term(
 
 #undef set_form_init
 int	set_form_init(
-		FORM	*form, 
+		FORM	*form,
 		Form_Hook func)
 		{ return(*(int *)0); }
 
@@ -568,7 +568,7 @@ Form_Hook form_init(
 
 #undef set_form_term
 int	set_form_term(
-		FORM	*form, 
+		FORM	*form,
 		Form_Hook func)
 		{ return(*(int *)0); }
 
@@ -581,7 +581,7 @@ Form_Hook form_term(
 
 #undef set_form_opts
 int	set_form_opts(
-		FORM	*form, 
+		FORM	*form,
 		Form_Options opts)
 		{ return(*(int *)0); }
 
@@ -592,13 +592,13 @@ Form_Options form_opts(
 
 #undef form_opts_on
 int	form_opts_on(
-		FORM	*form, 
+		FORM	*form,
 		Form_Options opts)
 		{ return(*(int *)0); }
 
 #undef form_opts_off
 int	form_opts_off(
-		FORM	*form, 
+		FORM	*form,
 		Form_Options opts)
 		{ return(*(int *)0); }
 
@@ -606,7 +606,7 @@ int	form_opts_off(
 
 #undef set_form_page
 int	set_form_page(
-		FORM	*form, 
+		FORM	*form,
 		int	page)
 		{ return(*(int *)0); }
 
@@ -643,8 +643,8 @@ int	form_request_by_name(
 
 #undef scale_form
 int	scale_form(
-		const FORM *form, 
-		int	*rows, 
+		const FORM *form,
+		int	*rows,
 		int	*cols)
 		{ return(*(int *)0); }
 
@@ -652,7 +652,7 @@ int	scale_form(
 
 #undef set_form_sub
 int	set_form_sub(
-		FORM	*form, 
+		FORM	*form,
 		WINDOW	*win)
 		{ return(*(int *)0); }
 
@@ -665,7 +665,7 @@ WINDOW	*form_sub(
 
 #undef set_form_userptr
 int	set_form_userptr(
-		FORM	*form, 
+		FORM	*form,
 		void	*usrptr)
 		{ return(*(int *)0); }
 
@@ -678,7 +678,7 @@ void	*form_userptr(
 
 #undef set_form_win
 int	set_form_win(
-		FORM	*form, 
+		FORM	*form,
 		WINDOW	*win)
 		{ return(*(int *)0); }
 
@@ -748,38 +748,38 @@ FIELDTYPE *_nc_TYPE_ENUM(void)
 #undef _nc_generic_fieldtype
 FIELDTYPE *_nc_generic_fieldtype(
 		NCURSES_BOOL (*const field_check)(
-		FORM	*p1, 
-		FIELD	*p2, 
-		const void *p3), 
+		FORM	*p1,
+		FIELD	*p2,
+		const void *p3),
 		NCURSES_BOOL (*const char_check)(
-		int	p1, 
-		FORM	*p2, 
-		FIELD	*p3, 
-		const void *p4), 
+		int	p1,
+		FORM	*p2,
+		FIELD	*p3,
+		const void *p4),
 		NCURSES_BOOL (*const next)(
-		FORM	*p1, 
-		FIELD	*p2, 
-		const void *p3), 
+		FORM	*p1,
+		FIELD	*p2,
+		const void *p3),
 		NCURSES_BOOL (*const prev)(
-		FORM	*p1, 
-		FIELD	*p2, 
-		const void *p3), 
+		FORM	*p1,
+		FIELD	*p2,
+		const void *p3),
 		void	(*freecallback)(
 		void	*p1))
 		{ return(*(FIELDTYPE **)0); }
 
 #undef _nc_set_generic_fieldtype
 int	_nc_set_generic_fieldtype(
-		FIELD	*field, 
-		FIELDTYPE *ftyp, 
+		FIELD	*field,
+		FIELDTYPE *ftyp,
 		int	(*argiterator)(
 		void	**p1))
 		{ return(*(int *)0); }
 
 #undef _nc_form_cursor
 WINDOW	*_nc_form_cursor(
-		const FORM *form, 
-		int	*pRow, 
+		const FORM *form,
+		int	*pRow,
 		int	*pCol)
 		{ return(*(WINDOW **)0); }
 
diff --git a/contrib/ncurses/include/Caps b/contrib/ncurses/include/Caps
index 4528cffb80ed..cd077b969192 100644
--- a/contrib/ncurses/include/Caps
+++ b/contrib/ncurses/include/Caps
@@ -1,5 +1,5 @@
 ##############################################################################
-# Copyright 2019,2020 Thomas E. Dickey                                       #
+# Copyright 2019-2023,2024 Thomas E. Dickey                                  #
 # Copyright 1998-2015,2016 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -30,7 +30,7 @@
 # Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995
 #    and: Eric S. Raymond <esr@snark.thyrsus.com>
 #
-# $Id: Caps,v 1.46 2020/10/17 21:30:19 tom Exp $
+# $Id: Caps,v 1.56 2024/04/20 21:05:02 tom Exp $
 #
 # This is the master termcap/terminfo capability table.
 #
@@ -48,7 +48,7 @@
 #
 # Column 1: terminfo variable name
 # Column 2: terminfo capability name
-# Column 3: capability type (boolean, numeric, or string)
+# Column 3: capability type (Boolean, numeric, or string)
 # Column 4: termcap capability name
 # Column 5: KEY_xxx name, if any, `-' otherwise
 # Column 6: value for KEY_xxx name, if any, `-' otherwise
@@ -58,7 +58,7 @@
 #
 # The codes following [Y-] in column 7 describe the versions of termcap which
 # use the given capability.  This information is not used by the curses library
-# proper; rather, it's there to help the terminfo maintainer avoid emitting
+# proper; rather, it is there to help the terminfo maintainer avoid emitting
 # termcap entry translations that are more than 1023 bytes long (and tank a
 # lot of old termcap-using programs).  The codes read as follows:
 #	B = mentioned in the BSD man page for 4.4BSD curses
@@ -98,8 +98,8 @@
 # 3. List it in the standard table.  You almost certainly do *not* want
 # to do this -- the capabilities in that one, and their order, have been
 # carefully chosen to be SVr4-binary-compatible when they're written out
-# as a terminfo object, and breaking this would be bad.  It's up to the ncurses
-# library what to do with the terminfo data after it's read in.
+# as a terminfo object, and breaking this would be bad.  It is up to the ncurses
+# library what to do with the terminfo data after it is read in.
 #
 # 4. List it in the aliases table with an IGNORE target field.  If you
 # do this, the capability will be ignored on input (though the user will
@@ -108,7 +108,7 @@
 # 5. List it in the extensions table. If you do this, the compiler will
 # silently accept the capability, but the curses library proper will never
 # see it (because it won't be written out as part of the terminfo object
-# format).  It's up to you what you have the compiler do with it.
+# format).  It is up to you what you have the compiler do with it.
 #
 # There are two opposite reasons to choose option 5.  One is when you want
 # to eat the capability silently and discard it when doing translations
@@ -153,67 +153,103 @@
 # to buy space for non-essentials Emacs is still using.  Capabilities high
 # on that hit list: rc, sc, uc.
 #
+# FORMATTING THE TABLES
+#
+# We manually specify a (minimum) column width for the capability name
+# and terminfo code columns in the tables to achieve a consistent
+# arrangement; as used here, tbl(1) cannot know the width required by
+# one table's data while formatting another's.
+#
+# The longest capability names (C variables) are
+# "enter_near_letter_quality" and "bit_image_carriage_return" (tied at
+# 25n), and the longest terminfo code is "setcolor" (8n).
+#
+# The tables are a tight fit on traditional man(7) implementations that
+# use a line length of 65n, and the "Description" column has little room
+# within which the formatter can make breaking or adjustment decisions.
+# Words like "micro_..._address" and "parm_..._micro" don't break.
+# Reducing the inter-column gaps to 2 ens gives them enough room.  --GBR
+#
 #############################################################################
 #
 # STANDARD CAPABILITIES
 #
-#%The following is a complete table of the capabilities included in a
-#%terminfo description block and available to terminfo-using code.  In each
-#%line of the table,
-#%
-#%The \fBvariable\fR is the name by which the programmer (at the terminfo level)
-#%accesses the capability.
-#%
-#%The \fBcapname\fR is the short name used in the text of the database,
-#%and is used by a person updating the database.
-#%Whenever possible, capnames are chosen to be the same as or similar to
-#%the ANSI X3.64-1979 standard (now superseded by ECMA-48, which uses
-#%identical or very similar names).  Semantics are also intended to match
-#%those of the specification.
-#%
-#%The termcap code is the old
-#%.B termcap
-#%capability name (some capabilities are new, and have names which termcap
-#%did not originate).
-#%.P
-#%Capability names have no hard length limit, but an informal limit of 5
-#%characters has been adopted to keep them short and to allow the tabs in
-#%the source file
-#%.B Caps
+#%Tables of capabilities
+#%.I \%ncurses
+#%recognizes in a
+#%.I \%term\%info
+#%terminal type description and available to
+#%.IR \%term\%info -using
+#%code follow.
+#%.bP
+#%The capability name identifies the symbol by which the programmer
+#%using the
+#%.I \%term\%info
+#%API accesses the capability.
+#%.bP
+#%The TI
+#%.RI ( \%term\%info )
+#%code is the short name used by a person composing or updating a
+#%terminal type entry.
+#%.IP
+#%Whenever possible,
+#%these codes are the same as or similar to those of the ANSI X3.64-1979
+#%standard
+#%(now superseded by ECMA-48,
+#%which uses identical or very similar names).
+#%Semantics are also intended to match those of the specification.
+#%.IP
+#%.I \%term\%info
+#%codes have no hard length limit,
+#%but
+#%.I \%ncurses
+#%maintains an informal one of 5 characters to keep them short and to
+#%allow the tabs in the source file
+#%.I Caps
 #%to line up nicely.
-#%
-#%Finally, the description field attempts to convey the semantics of the
-#%capability.  You may find some codes in the description field:
-#%.TP
-#%(P)
-#%indicates that padding may be specified
+#%(Some standard codes exceed this limit regardless.)
+#%.bP
+#%The TC
+#%.RI ( termcap )
+#%code is that used by the corresponding API of
+#%.IR \%ncurses .
+#%(Some capabilities are new,
+#%and have names that BSD
+#%.I termcap
+#%did not originate.)
+#%.bP
+#%The description field attempts to convey the capability's semantics.
+#%.PP
+#%The description field employs a handful of notations.
 #%.TP
-#%#[1-9]
-#%in the description field indicates that the string is passed
-#%through \fBtparm\fP(3X) with parameters as given (#\fIi\fP).
-#%.IP
-#%If no parameters are listed in the description,
-#%passing the string through \fBtparm\fP(3X) may give unexpected results,
-#%e.g., if it contains percent (%%) signs.
+#%.B (P)
+#%indicates that padding may be specified.
 #%.TP
-#%(P*)
-#%indicates that padding may vary in proportion to the number of
-#%lines affected
+#%.B (P*)
+#%indicates that padding may vary in proportion to the number of output
+#%lines affected.
 #%.TP
-#%(#\d\fIi\fP\u)
-#%indicates the \fIi\fP\uth\d parameter.
-#%
+#%.BI # i
+#%indicates the
+#%.IR i th
+#%parameter of a string capability;
+#%the programmer should pass the string to \fB\%tparm\fP(3X) with the
+#%parameters listed.
+#%.IP
+#%If the description lists no parameters,
+#%passing the string to \fB\%tparm\fP(3X) may produce unexpected
+#%behavior,
+#%for instance if the string contains percent signs.
+#%.
 #%.PP
-#% These are the boolean capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBBooleans	name	Code\fR
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%Boolean Capability Name	TI	TC	Description
+#%_
 auto_left_margin		bw	bool	bw	-	-	YB-G-	cub1 wraps from column 0 to last column
 auto_right_margin		am	bool	am	-	-	YBCGE	terminal has automatic margins
 no_esc_ctlc			xsb	bool	xb	-	-	YBCG-	beehive (f1=escape, f2=ctrl C)
@@ -252,18 +288,16 @@ semi_auto_right_margin		sam	bool	YE	-	-	-----	printing in last column causes cr
 cpi_changes_res			cpix	bool	YF	-	-	-----	changing character pitch changes resolution
 lpi_changes_res			lpix	bool	YG	-	-	-----	changing line pitch changes resolution
 #%.TE
-#%.ad
-#%
-#%These are the numeric capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBNumeric	name	Code\fR
+#%.PP
+#%.
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%Numeric Capability Name	TI	TC	Description
+#%_
 columns				cols	num	co	-	-	YBCGE	number of columns in a line
 init_tabs			it	num	it	-	-	YB-G-	tabs initially every # spaces
 lines				lines	num	li	-	-	YBCGE	number of lines on screen or page
@@ -282,20 +316,21 @@ max_colors			colors	num	Co	-	-	-----	maximum number of colors on screen
 max_pairs			pairs	num	pa	-	-	-----	maximum number of color-pairs on the screen
 no_color_video			ncv	num	NC	-	-	-----	video attributes that cannot be used with colors
 #%.TE
-#%.ad
-#%
+#%.PP
+#%.
 #%The following numeric capabilities are present in the SVr4.0 term structure,
-#%but are not yet documented in the man page.  They came in with SVr4's
-#%printer support.
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBNumeric	name	Code\fR
+#%but are not yet documented in the man page.
+#%They came in with SVr4's printer support.
+#%.
+#%.PP
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%Numeric Capability Name	TI	TC	Description
+#%_
 buffer_capacity			bufsz	num	Ya	-	-	-----	numbers of bytes buffered before printing
 dot_vert_spacing		spinv	num	Yb	-	-	-----	spacing of pins vertically in pins per inch
 dot_horz_spacing		spinh	num	Yc	-	-	-----	spacing of dots horizontally in dots per inch
@@ -314,18 +349,16 @@ buttons				btns	num	BT	-	-	-----	number of buttons on mouse
 bit_image_entwining		bitwin	num	Yo	-	-	-----	number of passes for each bit-image row
 bit_image_type			bitype	num	Yp	-	-	-----	type of bit-image device
 #%.TE
-#%.ad
-#%
-#%These are the string capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBString	name	Code\fR
+#%.PP
+#%.
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%String Capability Name	TI	TC	Description
+#%_
 back_tab			cbt	str	bt	-		-	YBCGE	back tab (P)
 bell				bel	str	bl	-		-	YB-GE	audible signal (bell) (P)
 carriage_return			cr	str	cr	-		-	YBCGE	carriage return (P*) (P*)
@@ -388,6 +421,10 @@ key_ctab			kctab	str	kt	KEY_CTAB	0525	-B-G-*	clear-tab key
 key_dc				kdch1	str	kD	KEY_DC		0512	YB-G-	delete-character key
 key_dl				kdl1	str	kL	KEY_DL		0510	-B-G-*	delete-line key
 key_down			kcud1	str	kd	KEY_DOWN	0402	YBCGE	down-arrow key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 key_eic				krmir	str	kM	KEY_EIC		0514	-B-G-*	sent by rmir or smir in insert mode
 key_eol				kel	str	kE	KEY_EOL		0517	-B-G-*	clear-to-end-of-line key
 key_eos				ked	str	kS	KEY_EOS		0516	-B-G-*	clear-to-end-of-screen key
@@ -414,8 +451,8 @@ key_sf				kind	str	kF	KEY_SF		0520	-B-G-*	scroll-forward key
 key_sr				kri	str	kR	KEY_SR		0521	-B-G-*	scroll-backward key
 key_stab			khts	str	kT	KEY_STAB	0524	-B-G-*	set-tab key
 key_up				kcuu1	str	ku	KEY_UP		0403	YBCGE	up-arrow key
-keypad_local			rmkx	str	ke	-		-	YBCGE	leave 'keyboard_transmit' mode
-keypad_xmit			smkx	str	ks	-		-	YBCGE	enter 'keyboard_transmit' mode
+keypad_local			rmkx	str	ke	-		-	YBCGE	leave keyboard transmit mode
+keypad_xmit			smkx	str	ks	-		-	YBCGE	enter keyboard transmit mode
 lab_f0				lf0	str	l0	-		-	-B-G-*	label on function key f0 if not f0
 lab_f1				lf1	str	l1	-		-	-B-G-*	label on function key f1 if not f1
 lab_f10				lf10	str	la	-		-	-----	label on function key f10 if not f10
@@ -450,6 +487,10 @@ prtr_on				mc5	str	po	-		-	-B-G-*	turn on printer
 repeat_char			rep	str	rp	-		-	YB-GE	repeat char #1 #2 times (P*)
 reset_1string			rs1	str	r1	-		-	-B---	reset string
 reset_2string			rs2	str	r2	-		-	-B---	reset string
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 reset_3string			rs3	str	r3	-		-	-B---	reset string
 reset_file			rf	str	rf	-		-	-B---	name of reset file
 restore_cursor			rc	str	rc	-		-	YBCG-	restore cursor to position of last save_cursor
@@ -516,6 +557,10 @@ key_resume			kres	str	&5	KEY_RESUME	0570	-----	resume key
 key_save			ksav	str	&6	KEY_SAVE	0571	-----	save key
 key_suspend			kspd	str	&7	KEY_SUSPEND	0627	-----	suspend key
 key_undo			kund	str	&8	KEY_UNDO	0630	-----	undo key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 key_sbeg			kBEG	str	&9	KEY_SBEG	0572	-----	shifted begin key
 key_scancel			kCAN	str	&0	KEY_SCANCEL	0573	-----	shifted cancel key
 key_scommand			kCMD	str	*1	KEY_SCOMMAND	0574	-----	shifted command key
@@ -578,6 +623,10 @@ key_f39				kf39	str	FT	KEY_F(39)	-	----E	F39 function key
 key_f40				kf40	str	FU	KEY_F(40)	-	----E	F40 function key
 key_f41				kf41	str	FV	KEY_F(41)	-	----E	F41 function key
 key_f42				kf42	str	FW	KEY_F(42)	-	----E	F42 function key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 key_f43				kf43	str	FX	KEY_F(43)	-	----E	F43 function key
 key_f44				kf44	str	FY	KEY_F(44)	-	----E	F44 function key
 key_f45				kf45	str	FZ	KEY_F(45)	-	----E	F45 function key
@@ -601,7 +650,7 @@ key_f62				kf62	str	Fq	KEY_F(62)	-	----E	F62 function key
 key_f63				kf63	str	Fr	KEY_F(63)	-	----E	F63 function key
 clr_bol				el1	str	cb	-		-	-----	Clear to beginning of line
 clear_margins			mgc	str	MC	-		-	-----	clear right and left soft margins
-set_left_margin			smgl	str	ML	-		-	-----	set left soft margin at current column.	 See smgl. (ML is not in BSD termcap).
+set_left_margin			smgl	str	ML	-		-	-----	set left soft margin at current column (not in BSD \fItermcap\fP)
 set_right_margin		smgr	str	MR	-		-	-----	set right soft margin at current column
 label_format			fln	str	Lf	-		-	-----	label format
 set_clock			sclk	str	SC	-		-	-----	set clock, #1 hrs #2 mins #3 secs
@@ -646,6 +695,10 @@ change_res_horz			chr	str	ZC	-		-	-----	Change horizontal resolution to #1
 change_res_vert			cvr	str	ZD	-		-	-----	Change vertical resolution to #1
 define_char			defc	str	ZE	-		-	-----	Define a character #1, #2 dots wide, descender #3
 enter_doublewide_mode		swidm	str	ZF	-		-	-----	Enter double-wide mode
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 enter_draft_quality		sdrfq	str	ZG	-		-	-----	Enter draft-quality mode
 enter_italics_mode		sitm	str	ZH	-		-	-----	Enter italic mode
 enter_leftward_mode		slm	str	ZI	-		-	-----	Start leftward carriage motion
@@ -691,19 +744,20 @@ superscript_characters		supcs	str	Zv	-		-	-----	List of superscriptable characte
 these_cause_cr			docr	str	Zw	-		-	-----	Printing any of these characters causes CR
 zero_motion			zerom	str	Zx	-		-	-----	No motion for subsequent character
 #%.TE
-#%.ad
-#%
+#%.PP
+#%.
 #%The following string capabilities are present in the SVr4.0 term structure,
 #%but were originally not documented in the man page.
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw18.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBString	name	Code\fR
+#%.
+#%.PP
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%String Capability Name	TI	TC	Description
+#%_
 char_set_names			csnm	str	Zy	-		-	-----	Produce #1'th item from list of character set names
 key_mouse			kmous	str	Km	KEY_MOUSE	0631	-----	Mouse event has occurred
 mouse_info			minfo	str	Mi	-		-	-----	Mouse status information
@@ -712,7 +766,7 @@ get_mouse			getm	str	Gm	-		-	-----	Curses should get button events, parameter #1
 set_a_foreground		setaf	str	AF	-		-	-----	Set foreground color to #1, using ANSI escape
 set_a_background		setab	str	AB	-		-	-----	Set background color to #1, using ANSI escape
 pkey_plab			pfxl	str	xl	-		-	-----	Program function key #1 to type string #2 and show string #3
-device_type			devt	str	dv	-		-	-----	Indicate language/codeset support
+device_type			devt	str	dv	-		-	-----	Indicate language, codeset support
 code_set_init			csin	str	ci	-		-	-----	Init sequence for multiple codesets
 set0_des_seq			s0ds	str	s0	-		-	-----	Shift to codeset 0 (EUC set 0, ASCII)
 set1_des_seq			s1ds	str	s1	-		-	-----	Shift to codeset 1
@@ -740,9 +794,8 @@ pc_term_options			pctrm	str	S6	-		-	-----	PC terminal options
 scancode_escape			scesc	str	S7	-		-	-----	Escape for scancode emulation
 alt_scancode_esc		scesa	str	S8	-		-	-----	Alternate escape for scancode emulation
 #%.TE
-#%.ad
-#%
-#%.in .8i
+#%.PP
+#%.
 #%The XSI Curses standard added these hardcopy capabilities.
 #%They were used in some post-4.1 versions of System V curses,
 #%e.g., Solaris 2.5 and IRIX 6.x.
@@ -751,15 +804,16 @@ alt_scancode_esc		scesa	str	S8	-		-	-----	Alternate escape for scancode emulatio
 #%If your compiled terminfo entries use these,
 #%they may not be binary-compatible with System V terminfo
 #%entries after SVr4.1; beware!
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBString	name	Code\fR
+#%.
+#%.PP
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%String Capability Name	TI	TC	Description
+#%_
 enter_horizontal_hl_mode	ehhlm	str	Xh	-		-	-----	Enter horizontal highlight mode
 enter_left_hl_mode		elhlm	str	Xl	-		-	-----	Enter left highlight mode
 enter_low_hl_mode		elohlm	str	Xo	-		-	-----	Enter low highlight mode
@@ -769,7 +823,6 @@ enter_vertical_hl_mode		evhlm	str	Xv	-		-	-----	Enter vertical highlight mode
 set_a_attributes		sgr1	str	sA	-		-	-----	Define second set of video attributes #1-#6
 set_pglen_inch			slength	str	YI	-		-	-----	Set page length to #1 hundredth of an inch (some implementations use sL for termcap).
 #%.TE
-#%.ad
 #
 # The magic token below tells the tic compiler-generator code that all the caps
 # past it should be ignored (not written out) when dumping terminfo objects. It
@@ -883,7 +936,7 @@ has_hardware_tabs		OTpt	bool	pt	-		-	YB---	has 8-char tabs invoked with ^I
 return_does_clr_eol		OTxr	bool	xr	-		-	YB---	return clears the line
 # tek_4025_insert_line		OTxx	bool	xx	-		-	-BC--	Tektronix 4025 insert-line glitch
 #
-# mytinfo described this as a termcap capability, but it's not listed in the
+# mytinfo described this as a termcap capability, but it is not listed in the
 # 4.4BSD man pages, and not found in the 4.4BSD termcap file.  The ncurses
 # package, like System V, behaves as though it is always true.
 #
diff --git a/contrib/ncurses/include/Caps-ncurses b/contrib/ncurses/include/Caps-ncurses
index d8c8baca1fb3..f9a5da06911a 100644
--- a/contrib/ncurses/include/Caps-ncurses
+++ b/contrib/ncurses/include/Caps-ncurses
@@ -1,5 +1,5 @@
 ##############################################################################
-# Copyright 2019,2020 Thomas E. Dickey                                       #
+# Copyright 2019-2022,2023 Thomas E. Dickey                                  #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
 # copy of this software and associated documentation files (the "Software"), #
@@ -28,7 +28,7 @@
 #
 # Author: Thomas E. Dickey
 #
-# $Id: Caps-ncurses,v 1.10 2020/09/29 19:05:19 tom Exp $
+# $Id: Caps-ncurses,v 1.15 2023/10/28 21:55:47 tom Exp $
 #
 #############################################################################
 #
@@ -344,6 +344,7 @@ infoalias	ksel	kslt	IBM	key_select
 used_by ncurses
 userdef	CO 	num	n	number of indexed colors overlaying RGB space
 userdef	E3	str	-	clears the terminal's scrollback buffer.
+userdef	NQ	bool	-	terminal does not support query/response
 userdef	RGB	bool	-	use direct colors with 1/3 of color-pair bits per color.
 userdef	RGB	num	n	use direct colors with given number of bits per color.
 userdef	RGB	str	-	use direct colors with given bit-layout.
@@ -401,7 +402,21 @@ userdef	Ss	str	n	change the cursor style.
 userdef	rmxx	str	-	reset ECMA-48 strikeout/crossed-out attributes.
 userdef	smxx	str	-	set ECMA-48 strikeout/crossed-out attributes.
 #
+used_by vim
+userdef	BD	str	-	disables bracketed paste
+userdef	BE	str	-	enables bracketed paste
+userdef	PE	str	-	is sent after pasted text
+userdef	PS	str	-	is sent before pasted text
+userdef	RV	str	-	report terminal secondary device attributes
+userdef	XR	str	-	report terminal version as a free-format string.
+userdef	XF	bool	-	terminal supports xterm focus in/out
+userdef	fd	str	-	disable xterm focus-events
+userdef	fe	str	-	enable xterm focus-events
+userdef	rv	str	-	response to RV, regular expression
+userdef	xr	str	-	response to XR, regular expression
+#
 used_by xterm
+userdef	csl	str	-	clear status line
 userdef	kDC3	str	-	alt delete-character
 userdef	kDC4	str	-	shift+alt delete-character
 userdef	kDC5	str	-	control delete-character
@@ -458,4 +473,6 @@ userdef	ka2	str	-	vt220-keypad extensions
 userdef	kb1	str	-	vt220-keypad extensions
 userdef	kb3	str	-	vt220-keypad extensions
 userdef	kc2	str	-	vt220-keypad extensions
+userdef	kxIN	str	-	mouse response on focus-in
+userdef	kxOUT	str	-	mouse response on focus-out
 #############################################################################
diff --git a/contrib/ncurses/include/Caps.aix4 b/contrib/ncurses/include/Caps.aix4
index a27f2699582b..1adb848e08b1 100644
--- a/contrib/ncurses/include/Caps.aix4
+++ b/contrib/ncurses/include/Caps.aix4
@@ -1,5 +1,5 @@
 ##############################################################################
-# Copyright 2019,2020 Thomas E. Dickey                                       #
+# Copyright 2019-2023,2024 Thomas E. Dickey                                  #
 # Copyright 2001-2015,2016 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -29,7 +29,7 @@
 #
 # Author: Thomas Dickey
 #
-# $Id: Caps.aix4,v 1.18 2020/10/17 21:30:19 tom Exp $
+# $Id: Caps.aix4,v 1.28 2024/04/20 21:05:02 tom Exp $
 #
 # This is an adaptation of ncurses' termcap/terminfo capability table, which
 # is designed to align with AIX 4.x's terminfo.
@@ -48,7 +48,7 @@
 #
 # Column 1: terminfo variable name
 # Column 2: terminfo capability name
-# Column 3: capability type (boolean, numeric, or string)
+# Column 3: capability type (Boolean, numeric, or string)
 # Column 4: termcap capability name
 # Column 5: KEY_xxx name, if any, `-' otherwise
 # Column 6: value for KEY_xxx name, if any, `-' otherwise
@@ -58,7 +58,7 @@
 #
 # The codes following [Y-] in column 7 describe the versions of termcap which
 # use the given capability.  This information is not used by the curses library
-# proper; rather, it's there to help the terminfo maintainer avoid emitting
+# proper; rather, it is there to help the terminfo maintainer avoid emitting
 # termcap entry translations that are more than 1023 bytes long (and tank a
 # lot of old termcap-using programs).  The codes read as follows:
 #	B = mentioned in the BSD man page for 4.4BSD curses
@@ -98,8 +98,8 @@
 # 3. List it in the standard table.  You almost certainly do *not* want
 # to do this -- the capabilities in that one, and their order, have been
 # carefully chosen to be SVr4-binary-compatible when they're written out
-# as a terminfo object, and breaking this would be bad.  It's up to the ncurses
-# library what to do with the terminfo data after it's read in.
+# as a terminfo object, and breaking this would be bad.  It is up to the ncurses
+# library what to do with the terminfo data after it is read in.
 #
 # 4. List it in the aliases table with an IGNORE target field.  If you
 # do this, the capability will be ignored on input (though the user will
@@ -108,7 +108,7 @@
 # 5. List it in the extensions table. If you do this, the compiler will
 # silently accept the capability, but the curses library proper will never
 # see it (because it won't be written out as part of the terminfo object
-# format).  It's up to you what you have the compiler do with it.
+# format).  It is up to you what you have the compiler do with it.
 #
 # There are two opposite reasons to choose option 5.  One is when you want
 # to eat the capability silently and discard it when doing translations
@@ -153,67 +153,103 @@
 # to buy space for non-essentials Emacs is still using.  Capabilities high
 # on that hit list: rc, sc, uc.
 #
+# FORMATTING THE TABLES
+#
+# We manually specify a (minimum) column width for the capability name
+# and terminfo code columns in the tables to achieve a consistent
+# arrangement; as used here, tbl(1) cannot know the width required by
+# one table's data while formatting another's.
+#
+# The longest capability names (C variables) are
+# "enter_near_letter_quality" and "bit_image_carriage_return" (tied at
+# 25n), and the longest terminfo code is "setcolor" (8n).
+#
+# The tables are a tight fit on traditional man(7) implementations that
+# use a line length of 65n, and the "Description" column has little room
+# within which the formatter can make breaking or adjustment decisions.
+# Words like "micro_..._address" and "parm_..._micro" don't break.
+# Reducing the inter-column gaps to 2 ens gives them enough room.  --GBR
+#
 #############################################################################
 #
 # STANDARD CAPABILITIES
 #
-#%The following is a complete table of the capabilities included in a
-#%terminfo description block and available to terminfo-using code.  In each
-#%line of the table,
-#%
-#%The \fBvariable\fR is the name by which the programmer (at the terminfo level)
-#%accesses the capability.
-#%
-#%The \fBcapname\fR is the short name used in the text of the database,
-#%and is used by a person updating the database.
-#%Whenever possible, capnames are chosen to be the same as or similar to
-#%the ANSI X3.64-1979 standard (now superseded by ECMA-48, which uses
-#%identical or very similar names).  Semantics are also intended to match
-#%those of the specification.
-#%
-#%The termcap code is the old
-#%.B termcap
-#%capability name (some capabilities are new, and have names which termcap
-#%did not originate).
-#%.P
-#%Capability names have no hard length limit, but an informal limit of 5
-#%characters has been adopted to keep them short and to allow the tabs in
-#%the source file
-#%.B Caps
+#%Tables of capabilities
+#%.I \%ncurses
+#%recognizes in a
+#%.I \%term\%info
+#%terminal type description and available to
+#%.IR \%term\%info -using
+#%code follow.
+#%.bP
+#%The capability name identifies the symbol by which the programmer
+#%using the
+#%.I \%term\%info
+#%API accesses the capability.
+#%.bP
+#%The TI
+#%.RI ( \%term\%info )
+#%code is the short name used by a person composing or updating a
+#%terminal type entry.
+#%.IP
+#%Whenever possible,
+#%these codes are the same as or similar to those of the ANSI X3.64-1979
+#%standard
+#%(now superseded by ECMA-48,
+#%which uses identical or very similar names).
+#%Semantics are also intended to match those of the specification.
+#%.IP
+#%.I \%term\%info
+#%codes have no hard length limit,
+#%but
+#%.I \%ncurses
+#%maintains an informal one of 5 characters to keep them short and to
+#%allow the tabs in the source file
+#%.I Caps
 #%to line up nicely.
-#%
-#%Finally, the description field attempts to convey the semantics of the
-#%capability.  You may find some codes in the description field:
-#%.TP
-#%(P)
-#%indicates that padding may be specified
+#%(Some standard codes exceed this limit regardless.)
+#%.bP
+#%The TC
+#%.RI ( termcap )
+#%code is that used by the corresponding API of
+#%.IR \%ncurses .
+#%(Some capabilities are new,
+#%and have names that BSD
+#%.I termcap
+#%did not originate.)
+#%.bP
+#%The description field attempts to convey the capability's semantics.
+#%.PP
+#%The description field employs a handful of notations.
 #%.TP
-#%#[1-9]
-#%in the description field indicates that the string is passed
-#%through \fBtparm\fP(3X) with parameters as given (#\fIi\fP).
-#%.IP
-#%If no parameters are listed in the description,
-#%passing the string through \fBtparm\fP(3X) may give unexpected results,
-#%e.g., if it contains percent (%%) signs.
+#%.B (P)
+#%indicates that padding may be specified.
 #%.TP
-#%(P*)
-#%indicates that padding may vary in proportion to the number of
-#%lines affected
+#%.B (P*)
+#%indicates that padding may vary in proportion to the number of output
+#%lines affected.
 #%.TP
-#%(#\d\fIi\fP\u)
-#%indicates the \fIi\fP\uth\d parameter.
-#%
+#%.BI # i
+#%indicates the
+#%.IR i th
+#%parameter of a string capability;
+#%the programmer should pass the string to \fB\%tparm\fP(3X) with the
+#%parameters listed.
+#%.IP
+#%If the description lists no parameters,
+#%passing the string to \fB\%tparm\fP(3X) may produce unexpected
+#%behavior,
+#%for instance if the string contains percent signs.
+#%.
 #%.PP
-#% These are the boolean capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBBooleans	name	Code\fR
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%Boolean Capability Name	TI	TC	Description
+#%_
 auto_left_margin		bw	bool	bw	-	-	YB-G-	cub1 wraps from column 0 to last column
 auto_right_margin		am	bool	am	-	-	YBCGE	terminal has automatic margins
 no_esc_ctlc			xsb	bool	xb	-	-	YBCG-	beehive (f1=escape, f2=ctrl C)
@@ -252,18 +288,16 @@ semi_auto_right_margin		sam	bool	YE	-	-	-----	printing in last column causes cr
 cpi_changes_res			cpix	bool	YF	-	-	-----	changing character pitch changes resolution
 lpi_changes_res			lpix	bool	YG	-	-	-----	changing line pitch changes resolution
 #%.TE
-#%.ad
-#%
-#%These are the numeric capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBNumeric	name	Code\fR
+#%.PP
+#%.
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%Numeric Capability Name	TI	TC	Description
+#%_
 columns				cols	num	co	-	-	YBCGE	number of columns in a line
 init_tabs			it	num	it	-	-	YB-G-	tabs initially every # spaces
 lines				lines	num	li	-	-	YBCGE	number of lines on screen or page
@@ -282,20 +316,21 @@ max_colors			colors	num	Co	-	-	-----	maximum number of colors on screen
 max_pairs			pairs	num	pa	-	-	-----	maximum number of color-pairs on the screen
 no_color_video			ncv	num	NC	-	-	-----	video attributes that cannot be used with colors
 #%.TE
-#%.ad
-#%
+#%.PP
+#%.
 #%The following numeric capabilities are present in the SVr4.0 term structure,
-#%but are not yet documented in the man page.  They came in with SVr4's
-#%printer support.
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBNumeric	name	Code\fR
+#%but are not yet documented in the man page.
+#%They came in with SVr4's printer support.
+#%.
+#%.PP
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%Numeric Capability Name	TI	TC	Description
+#%_
 buffer_capacity			bufsz	num	Ya	-	-	-----	numbers of bytes buffered before printing
 dot_vert_spacing		spinv	num	Yb	-	-	-----	spacing of pins vertically in pins per inch
 dot_horz_spacing		spinh	num	Yc	-	-	-----	spacing of dots horizontally in dots per inch
@@ -314,18 +349,16 @@ buttons				btns	num	BT	-	-	-----	number of buttons on mouse
 bit_image_entwining		bitwin	num	Yo	-	-	-----	number of passes for each bit-image row
 bit_image_type			bitype	num	Yp	-	-	-----	type of bit-image device
 #%.TE
-#%.ad
-#%
-#%These are the string capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBString	name	Code\fR
+#%.PP
+#%.
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%String Capability Name	TI	TC	Description
+#%_
 back_tab			cbt	str	bt	-		-	YBCGE	back tab (P)
 bell				bel	str	bl	-		-	YB-GE	audible signal (bell) (P)
 carriage_return			cr	str	cr	-		-	YBCGE	carriage return (P*) (P*)
@@ -388,6 +421,10 @@ key_ctab			kctab	str	kt	KEY_CTAB	0525	-B-G-*	clear-tab key
 key_dc				kdch1	str	kD	KEY_DC		0512	YB-G-	delete-character key
 key_dl				kdl1	str	kL	KEY_DL		0510	-B-G-*	delete-line key
 key_down			kcud1	str	kd	KEY_DOWN	0402	YBCGE	down-arrow key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 key_eic				krmir	str	kM	KEY_EIC		0514	-B-G-*	sent by rmir or smir in insert mode
 key_eol				kel	str	kE	KEY_EOL		0517	-B-G-*	clear-to-end-of-line key
 key_eos				ked	str	kS	KEY_EOS		0516	-B-G-*	clear-to-end-of-screen key
@@ -450,6 +487,10 @@ prtr_on				mc5	str	po	-		-	-B-G-*	turn on printer
 repeat_char			rep	str	rp	-		-	YB-GE	repeat char #1 #2 times (P*)
 reset_1string			rs1	str	r1	-		-	-B---	reset string
 reset_2string			rs2	str	r2	-		-	-B---	reset string
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 reset_3string			rs3	str	r3	-		-	-B---	reset string
 reset_file			rf	str	rf	-		-	-B---	name of reset file
 restore_cursor			rc	str	rc	-		-	YBCG-	restore cursor to position of last save_cursor
@@ -598,6 +639,10 @@ key_f39				kf39	str	FT	KEY_F(39)	-	----E	F39 function key
 key_f40				kf40	str	FU	KEY_F(40)	-	----E	F40 function key
 key_f41				kf41	str	FV	KEY_F(41)	-	----E	F41 function key
 key_f42				kf42	str	FW	KEY_F(42)	-	----E	F42 function key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 key_f43				kf43	str	FX	KEY_F(43)	-	----E	F43 function key
 key_f44				kf44	str	FY	KEY_F(44)	-	----E	F44 function key
 key_f45				kf45	str	FZ	KEY_F(45)	-	----E	F45 function key
@@ -671,6 +716,10 @@ key_resume			kres	str	&5	KEY_RESUME	0570	-----	resume key
 key_save			ksav	str	&6	KEY_SAVE	0571	-----	save key
 key_suspend			kspd	str	&7	KEY_SUSPEND	0627	-----	suspend key
 key_undo			kund	str	&8	KEY_UNDO	0630	-----	undo key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 key_sbeg			kBEG	str	&9	KEY_SBEG	0572	-----	shifted begin key
 key_scancel			kCAN	str	&0	KEY_SCANCEL	0573	-----	shifted cancel key
 key_scommand			kCMD	str	*1	KEY_SCOMMAND	0574	-----	shifted command key
@@ -703,7 +752,7 @@ key_sundo			kUND	str	!3	KEY_SUNDO	0626	-----	shifted undo key
 req_for_input			rfi	str	RF	-		-	-----	send next input char (for ptys)
 clr_bol				el1	str	cb	-		-	-----	Clear to beginning of line
 clear_margins			mgc	str	MC	-		-	-----	clear right and left soft margins
-set_left_margin			smgl	str	ML	-		-	-----	set left soft margin at current column.	 See smgl. (ML is not in BSD termcap).
+set_left_margin			smgl	str	ML	-		-	-----	set left soft margin at current column (not in BSD \fItermcap\fP)
 set_right_margin		smgr	str	MR	-		-	-----	set right soft margin at current column
 label_format			fln	str	Lf	-		-	-----	label format
 set_clock			sclk	str	SC	-		-	-----	set clock, #1 hrs #2 mins #3 secs
@@ -748,6 +797,10 @@ change_res_horz			chr	str	ZC	-		-	-----	Change horizontal resolution to #1
 change_res_vert			cvr	str	ZD	-		-	-----	Change vertical resolution to #1
 define_char			defc	str	ZE	-		-	-----	Define a character #1, #2 dots wide, descender #3
 enter_doublewide_mode		swidm	str	ZF	-		-	-----	Enter double-wide mode
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 enter_draft_quality		sdrfq	str	ZG	-		-	-----	Enter draft-quality mode
 enter_italics_mode		sitm	str	ZH	-		-	-----	Enter italic mode
 enter_leftward_mode		slm	str	ZI	-		-	-----	Start leftward carriage motion
@@ -793,19 +846,20 @@ superscript_characters		supcs	str	Zv	-		-	-----	List of superscriptable characte
 these_cause_cr			docr	str	Zw	-		-	-----	Printing any of these characters causes CR
 zero_motion			zerom	str	Zx	-		-	-----	No motion for subsequent character
 #%.TE
-#%.ad
-#%
+#%.PP
+#%.
 #%The following string capabilities are present in the SVr4.0 term structure,
 #%but were originally not documented in the man page.
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw18.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBString	name	Code\fR
+#%.
+#%.PP
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%String Capability Name	TI	TC	Description
+#%_
 char_set_names			csnm	str	Zy	-		-	-----	Produce #1'th item from list of character set names
 key_mouse			kmous	str	Km	KEY_MOUSE	0631	-----	Mouse event has occurred
 mouse_info			minfo	str	Mi	-		-	-----	Mouse status information
@@ -842,9 +896,8 @@ pc_term_options			pctrm	str	S6	-		-	-----	PC terminal options
 scancode_escape			scesc	str	S7	-		-	-----	Escape for scancode emulation
 alt_scancode_esc		scesa	str	S8	-		-	-----	Alternate escape for scancode emulation
 #%.TE
-#%.ad
-#%
-#%.in .8i
+#%.PP
+#%.
 #%The XSI Curses standard added these hardcopy capabilities.
 #%They were used in some post-4.1 versions of System V curses,
 #%e.g., Solaris 2.5 and IRIX 6.x.
@@ -853,15 +906,16 @@ alt_scancode_esc		scesa	str	S8	-		-	-----	Alternate escape for scancode emulatio
 #%If your compiled terminfo entries use these,
 #%they may not be binary-compatible with System V terminfo
 #%entries after SVr4.1; beware!
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBString	name	Code\fR
+#%.
+#%.PP
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%String Capability Name	TI	TC	Description
+#%_
 #enter_horizontal_hl_mode	ehhlm	str	Xh	-		-	-----	Enter horizontal highlight mode
 #enter_left_hl_mode		elhlm	str	Xl	-		-	-----	Enter left highlight mode
 #enter_low_hl_mode		elohlm	str	Xo	-		-	-----	Enter low highlight mode
@@ -871,7 +925,6 @@ alt_scancode_esc		scesa	str	S8	-		-	-----	Alternate escape for scancode emulatio
 #set_a_attributes		sgr1	str	sA	-		-	-----	Define second set of video attributes #1-#6
 set_pglen_inch			slength	str	YI	-		-	-----	Set page length to #1 hundredth of an inch (some implementations use sL for termcap).
 #%.TE
-#%.ad
 #
 # The magic token below tells the tic compiler-generator code that all the caps
 # past it should be ignored (not written out) when dumping terminfo objects. It
@@ -985,7 +1038,7 @@ has_hardware_tabs		OTpt	bool	pt	-		-	YB---	has 8-char tabs invoked with ^I
 return_does_clr_eol		OTxr	bool	xr	-		-	YB---	return clears the line
 # tek_4025_insert_line		OTxx	bool	xx	-		-	-BC--	Tektronix 4025 insert-line glitch
 #
-# mytinfo described this as a termcap capability, but it's not listed in the
+# mytinfo described this as a termcap capability, but it is not listed in the
 # 4.4BSD man pages, and not found in the 4.4BSD termcap file.  The ncurses
 # package, like System V, behaves as though it is always true.
 #
diff --git a/contrib/ncurses/include/Caps.hpux11 b/contrib/ncurses/include/Caps.hpux11
index 712a74297f6a..723556fa18f4 100644
--- a/contrib/ncurses/include/Caps.hpux11
+++ b/contrib/ncurses/include/Caps.hpux11
@@ -1,5 +1,5 @@
 ##############################################################################
-# Copyright 2019,2020 Thomas E. Dickey                                       #
+# Copyright 2019-2023,2024 Thomas E. Dickey                                  #
 # Copyright 2002-2015,2016 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -29,7 +29,7 @@
 #
 # Author: Thomas Dickey
 #
-# $Id: Caps.hpux11,v 1.16 2020/10/17 21:30:19 tom Exp $
+# $Id: Caps.hpux11,v 1.26 2024/04/20 21:05:02 tom Exp $
 #
 # This is an adaptation of ncurses' termcap/terminfo capability table, which
 # is designed to align with HPUX 11.x's terminfo.
@@ -48,7 +48,7 @@
 #
 # Column 1: terminfo variable name
 # Column 2: terminfo capability name
-# Column 3: capability type (boolean, numeric, or string)
+# Column 3: capability type (Boolean, numeric, or string)
 # Column 4: termcap capability name
 # Column 5: KEY_xxx name, if any, `-' otherwise
 # Column 6: value for KEY_xxx name, if any, `-' otherwise
@@ -58,7 +58,7 @@
 #
 # The codes following [Y-] in column 7 describe the versions of termcap which
 # use the given capability.  This information is not used by the curses library
-# proper; rather, it's there to help the terminfo maintainer avoid emitting
+# proper; rather, it is there to help the terminfo maintainer avoid emitting
 # termcap entry translations that are more than 1023 bytes long (and tank a
 # lot of old termcap-using programs).  The codes read as follows:
 #	B = mentioned in the BSD man page for 4.4BSD curses
@@ -98,8 +98,8 @@
 # 3. List it in the standard table.  You almost certainly do *not* want
 # to do this -- the capabilities in that one, and their order, have been
 # carefully chosen to be SVr4-binary-compatible when they're written out
-# as a terminfo object, and breaking this would be bad.  It's up to the ncurses
-# library what to do with the terminfo data after it's read in.
+# as a terminfo object, and breaking this would be bad.  It is up to the ncurses
+# library what to do with the terminfo data after it is read in.
 #
 # 4. List it in the aliases table with an IGNORE target field.  If you
 # do this, the capability will be ignored on input (though the user will
@@ -108,7 +108,7 @@
 # 5. List it in the extensions table. If you do this, the compiler will
 # silently accept the capability, but the curses library proper will never
 # see it (because it won't be written out as part of the terminfo object
-# format).  It's up to you what you have the compiler do with it.
+# format).  It is up to you what you have the compiler do with it.
 #
 # There are two opposite reasons to choose option 5.  One is when you want
 # to eat the capability silently and discard it when doing translations
@@ -153,67 +153,103 @@
 # to buy space for non-essentials Emacs is still using.  Capabilities high
 # on that hit list: rc, sc, uc.
 #
+# FORMATTING THE TABLES
+#
+# We manually specify a (minimum) column width for the capability name
+# and terminfo code columns in the tables to achieve a consistent
+# arrangement; as used here, tbl(1) cannot know the width required by
+# one table's data while formatting another's.
+#
+# The longest capability names (C variables) are
+# "enter_near_letter_quality" and "bit_image_carriage_return" (tied at
+# 25n), and the longest terminfo code is "setcolor" (8n).
+#
+# The tables are a tight fit on traditional man(7) implementations that
+# use a line length of 65n, and the "Description" column has little room
+# within which the formatter can make breaking or adjustment decisions.
+# Words like "micro_..._address" and "parm_..._micro" don't break.
+# Reducing the inter-column gaps to 2 ens gives them enough room.  --GBR
+#
 #############################################################################
 #
 # STANDARD CAPABILITIES
 #
-#%The following is a complete table of the capabilities included in a
-#%terminfo description block and available to terminfo-using code.  In each
-#%line of the table,
-#%
-#%The \fBvariable\fR is the name by which the programmer (at the terminfo level)
-#%accesses the capability.
-#%
-#%The \fBcapname\fR is the short name used in the text of the database,
-#%and is used by a person updating the database.
-#%Whenever possible, capnames are chosen to be the same as or similar to
-#%the ANSI X3.64-1979 standard (now superseded by ECMA-48, which uses
-#%identical or very similar names).  Semantics are also intended to match
-#%those of the specification.
-#%
-#%The termcap code is the old
-#%.B termcap
-#%capability name (some capabilities are new, and have names which termcap
-#%did not originate).
-#%.P
-#%Capability names have no hard length limit, but an informal limit of 5
-#%characters has been adopted to keep them short and to allow the tabs in
-#%the source file
-#%.B Caps
+#%Tables of capabilities
+#%.I \%ncurses
+#%recognizes in a
+#%.I \%term\%info
+#%terminal type description and available to
+#%.IR \%term\%info -using
+#%code follow.
+#%.bP
+#%The capability name identifies the symbol by which the programmer
+#%using the
+#%.I \%term\%info
+#%API accesses the capability.
+#%.bP
+#%The TI
+#%.RI ( \%term\%info )
+#%code is the short name used by a person composing or updating a
+#%terminal type entry.
+#%.IP
+#%Whenever possible,
+#%these codes are the same as or similar to those of the ANSI X3.64-1979
+#%standard
+#%(now superseded by ECMA-48,
+#%which uses identical or very similar names).
+#%Semantics are also intended to match those of the specification.
+#%.IP
+#%.I \%term\%info
+#%codes have no hard length limit,
+#%but
+#%.I \%ncurses
+#%maintains an informal one of 5 characters to keep them short and to
+#%allow the tabs in the source file
+#%.I Caps
 #%to line up nicely.
-#%
-#%Finally, the description field attempts to convey the semantics of the
-#%capability.  You may find some codes in the description field:
-#%.TP
-#%(P)
-#%indicates that padding may be specified
+#%(Some standard codes exceed this limit regardless.)
+#%.bP
+#%The TC
+#%.RI ( termcap )
+#%code is that used by the corresponding API of
+#%.IR \%ncurses .
+#%(Some capabilities are new,
+#%and have names that BSD
+#%.I termcap
+#%did not originate.)
+#%.bP
+#%The description field attempts to convey the capability's semantics.
+#%.PP
+#%The description field employs a handful of notations.
 #%.TP
-#%#[1-9]
-#%in the description field indicates that the string is passed
-#%through \fBtparm\fP(3X) with parameters as given (#\fIi\fP).
-#%.IP
-#%If no parameters are listed in the description,
-#%passing the string through \fBtparm\fP(3X) may give unexpected results,
-#%e.g., if it contains percent (%%) signs.
+#%.B (P)
+#%indicates that padding may be specified.
 #%.TP
-#%(P*)
-#%indicates that padding may vary in proportion to the number of
-#%lines affected
+#%.B (P*)
+#%indicates that padding may vary in proportion to the number of output
+#%lines affected.
 #%.TP
-#%(#\d\fIi\fP\u)
-#%indicates the \fIi\fP\uth\d parameter.
-#%
+#%.BI # i
+#%indicates the
+#%.IR i th
+#%parameter of a string capability;
+#%the programmer should pass the string to \fB\%tparm\fP(3X) with the
+#%parameters listed.
+#%.IP
+#%If the description lists no parameters,
+#%passing the string to \fB\%tparm\fP(3X) may produce unexpected
+#%behavior,
+#%for instance if the string contains percent signs.
+#%.
 #%.PP
-#% These are the boolean capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBBooleans	name	Code\fR
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%Boolean Capability Name	TI	TC	Description
+#%_
 auto_left_margin		bw	bool	bw	-	-	YB-G-	cub1 wraps from column 0 to last column
 auto_right_margin		am	bool	am	-	-	YBCGE	terminal has automatic margins
 no_esc_ctlc			xsb	bool	xb	-	-	YBCG-	beehive (f1=escape, f2=ctrl C)
@@ -235,7 +271,7 @@ dest_tabs_magic_smso		xt	bool	xt	-	-	YBCGE	tabs destructive, magic so char (t106
 tilde_glitch			hz	bool	hz	-	-	YB-GE	cannot print ~'s (Hazeltine)
 transparent_underline		ul	bool	ul	-	-	YBCGE	underline character overstrikes
 xon_xoff			xon	bool	xo	-	-	YB---	terminal uses xon/xoff handshaking
-# end booleans for HPUX 9, 10 (non-color curses)
+# end Booleans for HPUX 9, 10 (non-color curses)
 needs_xon_xoff			nxon	bool	nx	-	-	-----	padding will not work, xon/xoff required
 prtr_silent			mc5i	bool	5i	-	-	-----	printer will not echo on screen
 hard_cursor			chts	bool	HC	-	-	-----	cursor is hard to see
@@ -253,18 +289,16 @@ semi_auto_right_margin		sam	bool	YE	-	-	-----	printing in last column causes cr
 cpi_changes_res			cpix	bool	YF	-	-	-----	changing character pitch changes resolution
 lpi_changes_res			lpix	bool	YG	-	-	-----	changing line pitch changes resolution
 #%.TE
-#%.ad
-#%
-#%These are the numeric capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBNumeric	name	Code\fR
+#%.PP
+#%.
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%Numeric Capability Name	TI	TC	Description
+#%_
 columns				cols	num	co	-	-	YBCGE	number of columns in a line
 init_tabs			it	num	it	-	-	YB-G-	tabs initially every # spaces
 lines				lines	num	li	-	-	YBCGE	number of lines on screen or page
@@ -284,20 +318,21 @@ max_colors			colors	num	Co	-	-	-----	maximum number of colors on screen
 max_pairs			pairs	num	pa	-	-	-----	maximum number of color-pairs on the screen
 no_color_video			ncv	num	NC	-	-	-----	video attributes that cannot be used with colors
 #%.TE
-#%.ad
-#%
+#%.PP
+#%.
 #%The following numeric capabilities are present in the SVr4.0 term structure,
-#%but are not yet documented in the man page.  They came in with SVr4's
-#%printer support.
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBNumeric	name	Code\fR
+#%but are not yet documented in the man page.
+#%They came in with SVr4's printer support.
+#%.
+#%.PP
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%Numeric Capability Name	TI	TC	Description
+#%_
 buffer_capacity			bufsz	num	Ya	-	-	-----	numbers of bytes buffered before printing
 dot_vert_spacing		spinv	num	Yb	-	-	-----	spacing of pins vertically in pins per inch
 dot_horz_spacing		spinh	num	Yc	-	-	-----	spacing of dots horizontally in dots per inch
@@ -316,18 +351,16 @@ buttons				btns	num	BT	-	-	-----	number of buttons on mouse
 bit_image_entwining		bitwin	num	Yo	-	-	-----	number of passes for each bit-image row
 bit_image_type			bitype	num	Yp	-	-	-----	type of bit-image device
 #%.TE
-#%.ad
-#%
-#%These are the string capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBString	name	Code\fR
+#%.PP
+#%.
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%String Capability Name	TI	TC	Description
+#%_
 back_tab			cbt	str	bt	-		-	YBCGE	back tab (P)
 bell				bel	str	bl	-		-	YB-GE	audible signal (bell) (P)
 carriage_return			cr	str	cr	-		-	YBCGE	carriage return (P*) (P*)
@@ -390,6 +423,10 @@ key_ctab			kctab	str	kt	KEY_CTAB	0525	-B-G-*	clear-tab key
 key_dc				kdch1	str	kD	KEY_DC		0512	YB-G-	delete-character key
 key_dl				kdl1	str	kL	KEY_DL		0510	-B-G-*	delete-line key
 key_down			kcud1	str	kd	KEY_DOWN	0402	YBCGE	down-arrow key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 key_eic				krmir	str	kM	KEY_EIC		0514	-B-G-*	sent by rmir or smir in insert mode
 key_eol				kel	str	kE	KEY_EOL		0517	-B-G-*	clear-to-end-of-line key
 key_eos				ked	str	kS	KEY_EOS		0516	-B-G-*	clear-to-end-of-screen key
@@ -452,6 +489,10 @@ prtr_on				mc5	str	po	-		-	-B-G-*	turn on printer
 repeat_char			rep	str	rp	-		-	YB-GE	repeat char #1 #2 times (P*)
 reset_1string			rs1	str	r1	-		-	-B---	reset string
 reset_2string			rs2	str	r2	-		-	-B---	reset string
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 reset_3string			rs3	str	r3	-		-	-B---	reset string
 reset_file			rf	str	rf	-		-	-B---	name of reset file
 restore_cursor			rc	str	rc	-		-	YBCG-	restore cursor to position of last save_cursor
@@ -517,6 +558,10 @@ key_f39				kf39	str	FT	KEY_F(39)	-	----E	F39 function key
 key_f40				kf40	str	FU	KEY_F(40)	-	----E	F40 function key
 key_f41				kf41	str	FV	KEY_F(41)	-	----E	F41 function key
 key_f42				kf42	str	FW	KEY_F(42)	-	----E	F42 function key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 key_f43				kf43	str	FX	KEY_F(43)	-	----E	F43 function key
 key_f44				kf44	str	FY	KEY_F(44)	-	----E	F44 function key
 key_f45				kf45	str	FZ	KEY_F(45)	-	----E	F45 function key
@@ -577,6 +622,10 @@ key_resume			kres	str	&5	KEY_RESUME	0570	-----	resume key
 key_save			ksav	str	&6	KEY_SAVE	0571	-----	save key
 key_suspend			kspd	str	&7	KEY_SUSPEND	0627	-----	suspend key
 key_undo			kund	str	&8	KEY_UNDO	0630	-----	undo key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 key_sbeg			kBEG	str	&9	KEY_SBEG	0572	-----	shifted begin key
 key_scancel			kCAN	str	&0	KEY_SCANCEL	0573	-----	shifted cancel key
 key_scommand			kCMD	str	*1	KEY_SCOMMAND	0574	-----	shifted command key
@@ -609,7 +658,7 @@ key_sundo			kUND	str	!3	KEY_SUNDO	0626	-----	shifted undo key
 req_for_input			rfi	str	RF	-		-	-----	send next input char (for ptys)
 clr_bol				el1	str	cb	-		-	-----	Clear to beginning of line
 clear_margins			mgc	str	MC	-		-	-----	clear right and left soft margins
-set_left_margin			smgl	str	ML	-		-	-----	set left soft margin at current column.	 See smgl. (ML is not in BSD termcap).
+set_left_margin			smgl	str	ML	-		-	-----	set left soft margin at current column (not in BSD \fItermcap\fP)
 set_right_margin		smgr	str	MR	-		-	-----	set right soft margin at current column
 label_format			fln	str	Lf	-		-	-----	label format
 set_clock			sclk	str	SC	-		-	-----	set clock, #1 hrs #2 mins #3 secs
@@ -654,6 +703,10 @@ change_res_horz			chr	str	ZC	-		-	-----	Change horizontal resolution to #1
 change_res_vert			cvr	str	ZD	-		-	-----	Change vertical resolution to #1
 define_char			defc	str	ZE	-		-	-----	Define a character #1, #2 dots wide, descender #3
 enter_doublewide_mode		swidm	str	ZF	-		-	-----	Enter double-wide mode
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 enter_draft_quality		sdrfq	str	ZG	-		-	-----	Enter draft-quality mode
 enter_italics_mode		sitm	str	ZH	-		-	-----	Enter italic mode
 enter_leftward_mode		slm	str	ZI	-		-	-----	Start leftward carriage motion
@@ -699,19 +752,20 @@ superscript_characters		supcs	str	Zv	-		-	-----	List of superscriptable characte
 these_cause_cr			docr	str	Zw	-		-	-----	Printing any of these characters causes CR
 zero_motion			zerom	str	Zx	-		-	-----	No motion for subsequent character
 #%.TE
-#%.ad
-#%
+#%.PP
+#%.
 #%The following string capabilities are present in the SVr4.0 term structure,
 #%but were originally not documented in the man page.
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw18.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBString	name	Code\fR
+#%.
+#%.PP
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%String Capability Name	TI	TC	Description
+#%_
 char_set_names			csnm	str	Zy	-		-	-----	Produce #1'th item from list of character set names
 key_mouse			kmous	str	Km	KEY_MOUSE	0631	-----	Mouse event has occurred
 mouse_info			minfo	str	Mi	-		-	-----	Mouse status information
@@ -748,9 +802,8 @@ pc_term_options			pctrm	str	S6	-		-	-----	PC terminal options
 scancode_escape			scesc	str	S7	-		-	-----	Escape for scancode emulation
 alt_scancode_esc		scesa	str	S8	-		-	-----	Alternate escape for scancode emulation
 #%.TE
-#%.ad
-#%
-#%.in .8i
+#%.PP
+#%.
 #%The XSI Curses standard added these hardcopy capabilities.
 #%They were used in some post-4.1 versions of System V curses,
 #%e.g., Solaris 2.5 and IRIX 6.x.
@@ -759,17 +812,18 @@ alt_scancode_esc		scesa	str	S8	-		-	-----	Alternate escape for scancode emulatio
 #%If your compiled terminfo entries use these,
 #%they may not be binary-compatible with System V terminfo
 #%entries after SVr4.1; beware!
-#%
+#%.
 #%AIX and Solaris do not provide termcap names for these; HPUX does.
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBString	name	Code\fR
+#%.
+#%.PP
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%String Capability Name	TI	TC	Description
+#%_
 set_pglen_inch			slength	str	YI	-		-	-----	Set page length to #1 hundredth of an inch (some implementations use sL for termcap).
 enter_horizontal_hl_mode	ehhlm	str	Q1	-		-	-----	Enter horizontal highlight mode
 enter_left_hl_mode		elhlm	str	Q2	-		-	-----	Enter left highlight mode
@@ -785,7 +839,6 @@ exit_right_hl_mode 		rmrhlm	str	Qb	-		-	----K	Exit right highlight mode
 exit_top_hl_mode 		rmthlm	str	Qc	-		-	----K	Exit top highlight mode
 exit_vertical_hl_mode 		rmvhlm	str	Qd	-		-	----K	Exit vertical highlight mode
 #%.TE
-#%.ad
 #
 # The magic token below tells the tic compiler-generator code that all the caps
 # past it should be ignored (not written out) when dumping terminfo objects. It
@@ -899,7 +952,7 @@ has_hardware_tabs		OTpt	bool	pt	-		-	YB---	has 8-char tabs invoked with ^I
 return_does_clr_eol		OTxr	bool	xr	-		-	YB---	return clears the line
 # tek_4025_insert_line		OTxx	bool	xx	-		-	-BC--	Tektronix 4025 insert-line glitch
 #
-# mytinfo described this as a termcap capability, but it's not listed in the
+# mytinfo described this as a termcap capability, but it is not listed in the
 # 4.4BSD man pages, and not found in the 4.4BSD termcap file.  The ncurses
 # package, like System V, behaves as though it is always true.
 #
diff --git a/contrib/ncurses/include/Caps.keys b/contrib/ncurses/include/Caps.keys
index 018f68474fda..6f8a84e3455f 100644
--- a/contrib/ncurses/include/Caps.keys
+++ b/contrib/ncurses/include/Caps.keys
@@ -1,5 +1,5 @@
 ##############################################################################
-# Copyright 2019,2020 Thomas E. Dickey                                       #
+# Copyright 2019-2023,2024 Thomas E. Dickey                                  #
 # Copyright 2001-2015,2016 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -30,7 +30,7 @@
 # Author: Thomas Dickey
 #    and: Ilya Zakharevich
 #
-# $Id: Caps.keys,v 1.15 2020/10/17 21:30:19 tom Exp $
+# $Id: Caps.keys,v 1.25 2024/04/20 21:05:02 tom Exp $
 #
 # This is an adaptation of ncurses' termcap/terminfo capability table, which
 # is illustrates an experimental extension to describe alt-, shift- and
@@ -50,7 +50,7 @@
 #
 # Column 1: terminfo variable name
 # Column 2: terminfo capability name
-# Column 3: capability type (boolean, numeric, or string)
+# Column 3: capability type (Boolean, numeric, or string)
 # Column 4: termcap capability name
 # Column 5: KEY_xxx name, if any, `-' otherwise
 # Column 6: value for KEY_xxx name, if any, `-' otherwise
@@ -60,7 +60,7 @@
 #
 # The codes following [Y-] in column 7 describe the versions of termcap which
 # use the given capability.  This information is not used by the curses library
-# proper; rather, it's there to help the terminfo maintainer avoid emitting
+# proper; rather, it is there to help the terminfo maintainer avoid emitting
 # termcap entry translations that are more than 1023 bytes long (and tank a
 # lot of old termcap-using programs).  The codes read as follows:
 #	B = mentioned in the BSD man page for 4.4BSD curses
@@ -100,8 +100,8 @@
 # 3. List it in the standard table.  You almost certainly do *not* want
 # to do this -- the capabilities in that one, and their order, have been
 # carefully chosen to be SVr4-binary-compatible when they're written out
-# as a terminfo object, and breaking this would be bad.  It's up to the ncurses
-# library what to do with the terminfo data after it's read in.
+# as a terminfo object, and breaking this would be bad.  It is up to the ncurses
+# library what to do with the terminfo data after it is read in.
 #
 # 4. List it in the aliases table with an IGNORE target field.  If you
 # do this, the capability will be ignored on input (though the user will
@@ -110,7 +110,7 @@
 # 5. List it in the extensions table. If you do this, the compiler will
 # silently accept the capability, but the curses library proper will never
 # see it (because it won't be written out as part of the terminfo object
-# format).  It's up to you what you have the compiler do with it.
+# format).  It is up to you what you have the compiler do with it.
 #
 # There are two opposite reasons to choose option 5.  One is when you want
 # to eat the capability silently and discard it when doing translations
@@ -155,67 +155,104 @@
 # to buy space for non-essentials Emacs is still using.  Capabilities high
 # on that hit list: rc, sc, uc.
 #
+# FORMATTING THE TABLES
+#
+# We manually specify a (minimum) column width for the capability name
+# and terminfo code columns in the tables to achieve a consistent
+# arrangement; as used here, tbl(1) cannot know the width required by
+# one table's data while formatting another's.
+#
+# The longest capability names (C variables) are
+# "enter_near_letter_quality" and "bit_image_carriage_return" (tied at
+# 25n), and the longest terminfo codes are "setcolor", "kcdelete",
+# "kcinsert", "kadelete", and "kcinsert" (8n).
+#
+# The tables are a tight fit on traditional man(7) implementations that
+# use a line length of 65n, and the "Description" column has little room
+# within which the formatter can make breaking or adjustment decisions.
+# Words like "micro_..._address" and "parm_..._micro" don't break.
+# Reducing the inter-column gaps to 2 ens gives them enough room.  --GBR
+#
 #############################################################################
 #
 # STANDARD CAPABILITIES
 #
-#%The following is a complete table of the capabilities included in a
-#%terminfo description block and available to terminfo-using code.  In each
-#%line of the table,
-#%
-#%The \fBvariable\fR is the name by which the programmer (at the terminfo level)
-#%accesses the capability.
-#%
-#%The \fBcapname\fR is the short name used in the text of the database,
-#%and is used by a person updating the database.
-#%Whenever possible, capnames are chosen to be the same as or similar to
-#%the ANSI X3.64-1979 standard (now superseded by ECMA-48, which uses
-#%identical or very similar names).  Semantics are also intended to match
-#%those of the specification.
-#%
-#%The termcap code is the old
-#%.B termcap
-#%capability name (some capabilities are new, and have names which termcap
-#%did not originate).
-#%.P
-#%Capability names have no hard length limit, but an informal limit of 5
-#%characters has been adopted to keep them short and to allow the tabs in
-#%the source file
-#%.B Caps
+#%Tables of capabilities
+#%.I \%ncurses
+#%recognizes in a
+#%.I \%term\%info
+#%terminal type description and available to
+#%.IR \%term\%info -using
+#%code follow.
+#%.bP
+#%The capability name identifies the symbol by which the programmer
+#%using the
+#%.I \%term\%info
+#%API accesses the capability.
+#%.bP
+#%The TI
+#%.RI ( \%term\%info )
+#%code is the short name used by a person composing or updating a
+#%terminal type entry.
+#%.IP
+#%Whenever possible,
+#%these codes are the same as or similar to those of the ANSI X3.64-1979
+#%standard
+#%(now superseded by ECMA-48,
+#%which uses identical or very similar names).
+#%Semantics are also intended to match those of the specification.
+#%.IP
+#%.I \%term\%info
+#%codes have no hard length limit,
+#%but
+#%.I \%ncurses
+#%maintains an informal one of 5 characters to keep them short and to
+#%allow the tabs in the source file
+#%.I Caps
 #%to line up nicely.
-#%
-#%Finally, the description field attempts to convey the semantics of the
-#%capability.  You may find some codes in the description field:
-#%.TP
-#%(P)
-#%indicates that padding may be specified
+#%(Some standard codes exceed this limit regardless.)
+#%.bP
+#%The TC
+#%.RI ( termcap )
+#%code is that used by the corresponding API of
+#%.IR \%ncurses .
+#%(Some capabilities are new,
+#%and have names that BSD
+#%.I termcap
+#%did not originate.)
+#%.bP
+#%The description field attempts to convey the capability's semantics.
+#%.PP
+#%The description field employs a handful of notations.
 #%.TP
-#%#[1-9]
-#%in the description field indicates that the string is passed
-#%through \fBtparm\fP(3X) with parameters as given (#\fIi\fP).
-#%.IP
-#%If no parameters are listed in the description,
-#%passing the string through \fBtparm\fP(3X) may give unexpected results,
-#%e.g., if it contains percent (%%) signs.
+#%.B (P)
+#%indicates that padding may be specified.
 #%.TP
-#%(P*)
-#%indicates that padding may vary in proportion to the number of
-#%lines affected
+#%.B (P*)
+#%indicates that padding may vary in proportion to the number of output
+#%lines affected.
 #%.TP
-#%(#\d\fIi\fP\u)
-#%indicates the \fIi\fP\uth\d parameter.
-#%
+#%.BI # i
+#%indicates the
+#%.IR i th
+#%parameter of a string capability;
+#%the programmer should pass the string to \fB\%tparm\fP(3X) with the
+#%parameters listed.
+#%.IP
+#%If the description lists no parameters,
+#%passing the string to \fB\%tparm\fP(3X) may produce unexpected
+#%behavior,
+#%for instance if the string contains percent signs.
+#%.
 #%.PP
-#% These are the boolean capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBBooleans	name	Code\fR
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%Boolean Capability Name	TI	TC	Description
+#%_
 auto_left_margin		bw	bool	bw	-	-	YB-G-	cub1 wraps from column 0 to last column
 auto_right_margin		am	bool	am	-	-	YBCGE	terminal has automatic margins
 no_esc_ctlc			xsb	bool	xb	-	-	YBCG-	beehive (f1=escape, f2=ctrl C)
@@ -254,18 +291,16 @@ semi_auto_right_margin		sam	bool	YE	-	-	-----	printing in last column causes cr
 cpi_changes_res			cpix	bool	YF	-	-	-----	changing character pitch changes resolution
 lpi_changes_res			lpix	bool	YG	-	-	-----	changing line pitch changes resolution
 #%.TE
-#%.ad
-#%
-#%These are the numeric capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBNumeric	name	Code\fR
+#%.PP
+#%.
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%Numeric Capability Name	TI	TC	Description
+#%_
 columns				cols	num	co	-	-	YBCGE	number of columns in a line
 init_tabs			it	num	it	-	-	YB-G-	tabs initially every # spaces
 lines				lines	num	li	-	-	YBCGE	number of lines on screen or page
@@ -284,20 +319,21 @@ max_colors			colors	num	Co	-	-	-----	maximum number of colors on screen
 max_pairs			pairs	num	pa	-	-	-----	maximum number of color-pairs on the screen
 no_color_video			ncv	num	NC	-	-	-----	video attributes that cannot be used with colors
 #%.TE
-#%.ad
-#%
+#%.PP
+#%.
 #%The following numeric capabilities are present in the SVr4.0 term structure,
-#%but are not yet documented in the man page.  They came in with SVr4's
-#%printer support.
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBNumeric	name	Code\fR
+#%but are not yet documented in the man page.
+#%They came in with SVr4's printer support.
+#%.
+#%.PP
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%Numeric Capability Name	TI	TC	Description
+#%_
 buffer_capacity			bufsz	num	Ya	-	-	-----	numbers of bytes buffered before printing
 dot_vert_spacing		spinv	num	Yb	-	-	-----	spacing of pins vertically in pins per inch
 dot_horz_spacing		spinh	num	Yc	-	-	-----	spacing of dots horizontally in dots per inch
@@ -316,18 +352,16 @@ buttons				btns	num	BT	-	-	-----	number of buttons on mouse
 bit_image_entwining		bitwin	num	Yo	-	-	-----	number of passes for each bit-image row
 bit_image_type			bitype	num	Yp	-	-	-----	type of bit-image device
 #%.TE
-#%.ad
-#%
-#%These are the string capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBString	name	Code\fR
+#%.PP
+#%.
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%String Capability Name	TI	TC	Description
+#%_
 back_tab			cbt	str	bt	-		-	YBCGE	back tab (P)
 bell				bel	str	bl	-		-	YB-GE	audible signal (bell) (P)
 carriage_return			cr	str	cr	-		-	YBCGE	carriage return (P*) (P*)
@@ -390,6 +424,10 @@ key_ctab			kctab	str	kt	KEY_CTAB	0525	-B-G-*	clear-tab key
 key_dc				kdch1	str	kD	KEY_DC		0512	YB-G-	delete-character key
 key_dl				kdl1	str	kL	KEY_DL		0510	-B-G-*	delete-line key
 key_down			kcud1	str	kd	KEY_DOWN	0402	YBCGE	down-arrow key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 key_eic				krmir	str	kM	KEY_EIC		0514	-B-G-*	sent by rmir or smir in insert mode
 key_eol				kel	str	kE	KEY_EOL		0517	-B-G-*	clear-to-end-of-line key
 key_eos				ked	str	kS	KEY_EOS		0516	-B-G-*	clear-to-end-of-screen key
@@ -452,6 +490,10 @@ prtr_on				mc5	str	po	-		-	-B-G-*	turn on printer
 repeat_char			rep	str	rp	-		-	YB-GE	repeat char #1 #2 times (P*)
 reset_1string			rs1	str	r1	-		-	-B---	reset string
 reset_2string			rs2	str	r2	-		-	-B---	reset string
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 reset_3string			rs3	str	r3	-		-	-B---	reset string
 reset_file			rf	str	rf	-		-	-B---	name of reset file
 restore_cursor			rc	str	rc	-		-	YBCG-	restore cursor to position of last save_cursor
@@ -518,6 +560,10 @@ key_resume			kres	str	&5	KEY_RESUME	0570	-----	resume key
 key_save			ksav	str	&6	KEY_SAVE	0571	-----	save key
 key_suspend			kspd	str	&7	KEY_SUSPEND	0627	-----	suspend key
 key_undo			kund	str	&8	KEY_UNDO	0630	-----	undo key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 key_sbeg			kBEG	str	&9	KEY_SBEG	0572	-----	shifted begin key
 key_scancel			kCAN	str	&0	KEY_SCANCEL	0573	-----	shifted cancel key
 key_scommand			kCMD	str	*1	KEY_SCOMMAND	0574	-----	shifted command key
@@ -580,6 +626,10 @@ key_f39				kf39	str	FT	KEY_F(39)	-	----E	F39 function key
 key_f40				kf40	str	FU	KEY_F(40)	-	----E	F40 function key
 key_f41				kf41	str	FV	KEY_F(41)	-	----E	F41 function key
 key_f42				kf42	str	FW	KEY_F(42)	-	----E	F42 function key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 key_f43				kf43	str	FX	KEY_F(43)	-	----E	F43 function key
 key_f44				kf44	str	FY	KEY_F(44)	-	----E	F44 function key
 key_f45				kf45	str	FZ	KEY_F(45)	-	----E	F45 function key
@@ -603,7 +653,7 @@ key_f62				kf62	str	Fq	KEY_F(62)	-	----E	F62 function key
 key_f63				kf63	str	Fr	KEY_F(63)	-	----E	F63 function key
 clr_bol				el1	str	cb	-		-	-----	Clear to beginning of line
 clear_margins			mgc	str	MC	-		-	-----	clear right and left soft margins
-set_left_margin			smgl	str	ML	-		-	-----	set left soft margin at current column.	 See smgl. (ML is not in BSD termcap).
+set_left_margin			smgl	str	ML	-		-	-----	set left soft margin at current column (not in BSD \fItermcap\fP)
 set_right_margin		smgr	str	MR	-		-	-----	set right soft margin at current column
 label_format			fln	str	Lf	-		-	-----	label format
 set_clock			sclk	str	SC	-		-	-----	set clock, #1 hrs #2 mins #3 secs
@@ -736,6 +786,10 @@ change_res_horz			chr	str	ZC	-		-	-----	Change horizontal resolution to #1
 change_res_vert			cvr	str	ZD	-		-	-----	Change vertical resolution to #1
 define_char			defc	str	ZE	-		-	-----	Define a character #1, #2 dots wide, descender #3
 enter_doublewide_mode		swidm	str	ZF	-		-	-----	Enter double-wide mode
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 enter_draft_quality		sdrfq	str	ZG	-		-	-----	Enter draft-quality mode
 enter_italics_mode		sitm	str	ZH	-		-	-----	Enter italic mode
 enter_leftward_mode		slm	str	ZI	-		-	-----	Start leftward carriage motion
@@ -781,19 +835,20 @@ superscript_characters		supcs	str	Zv	-		-	-----	List of superscriptable characte
 these_cause_cr			docr	str	Zw	-		-	-----	Printing any of these characters causes CR
 zero_motion			zerom	str	Zx	-		-	-----	No motion for subsequent character
 #%.TE
-#%.ad
-#%
+#%.PP
+#%.
 #%The following string capabilities are present in the SVr4.0 term structure,
 #%but were originally not documented in the man page.
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw18.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBString	name	Code\fR
+#%.
+#%.PP
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%String Capability Name	TI	TC	Description
+#%_
 char_set_names			csnm	str	Zy	-		-	-----	Produce #1'th item from list of character set names
 key_mouse			kmous	str	Km	KEY_MOUSE	0631	-----	Mouse event has occurred
 mouse_info			minfo	str	Mi	-		-	-----	Mouse status information
@@ -830,9 +885,8 @@ pc_term_options			pctrm	str	S6	-		-	-----	PC terminal options
 scancode_escape			scesc	str	S7	-		-	-----	Escape for scancode emulation
 alt_scancode_esc		scesa	str	S8	-		-	-----	Alternate escape for scancode emulation
 #%.TE
-#%.ad
-#%
-#%.in .8i
+#%.PP
+#%.
 #%The XSI Curses standard added these hardcopy capabilities.
 #%They were used in some post-4.1 versions of System V curses,
 #%e.g., Solaris 2.5 and IRIX 6.x.
@@ -841,15 +895,16 @@ alt_scancode_esc		scesa	str	S8	-		-	-----	Alternate escape for scancode emulatio
 #%If your compiled terminfo entries use these,
 #%they may not be binary-compatible with System V terminfo
 #%entries after SVr4.1; beware!
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBString	name	Code\fR
+#%.
+#%.PP
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%String Capability Name	TI	TC	Description
+#%_
 enter_horizontal_hl_mode	ehhlm	str	Xh	-		-	-----	Enter horizontal highlight mode
 enter_left_hl_mode		elhlm	str	Xl	-		-	-----	Enter left highlight mode
 enter_low_hl_mode		elohlm	str	Xo	-		-	-----	Enter low highlight mode
@@ -859,7 +914,6 @@ enter_vertical_hl_mode		evhlm	str	Xv	-		-	-----	Enter vertical highlight mode
 set_a_attributes		sgr1	str	sA	-		-	-----	Define second set of video attributes #1-#6
 set_pglen_inch			slength	str	YI	-		-	-----	Set page length to #1 hundredth of an inch (some implementations use sL for termcap).
 #%.TE
-#%.ad
 #
 # The magic token below tells the tic compiler-generator code that all the caps
 # past it should be ignored (not written out) when dumping terminfo objects. It
@@ -973,7 +1027,7 @@ has_hardware_tabs		OTpt	bool	pt	-		-	YB---	has 8-char tabs invoked with ^I
 return_does_clr_eol		OTxr	bool	xr	-		-	YB---	return clears the line
 # tek_4025_insert_line		OTxx	bool	xx	-		-	-BC--	Tektronix 4025 insert-line glitch
 #
-# mytinfo described this as a termcap capability, but it's not listed in the
+# mytinfo described this as a termcap capability, but it is not listed in the
 # 4.4BSD man pages, and not found in the 4.4BSD termcap file.  The ncurses
 # package, like System V, behaves as though it is always true.
 #
diff --git a/contrib/ncurses/include/Caps.osf1r5 b/contrib/ncurses/include/Caps.osf1r5
index 8a2955486ee9..ece14aef2ea7 100644
--- a/contrib/ncurses/include/Caps.osf1r5
+++ b/contrib/ncurses/include/Caps.osf1r5
@@ -1,5 +1,5 @@
 ##############################################################################
-# Copyright 2019,2020 Thomas E. Dickey                                       #
+# Copyright 2019-2023,2024 Thomas E. Dickey                                  #
 # Copyright 2002-2015,2016 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -29,7 +29,7 @@
 #
 # Author: Thomas Dickey
 #
-# $Id: Caps.osf1r5,v 1.14 2020/10/17 21:30:19 tom Exp $
+# $Id: Caps.osf1r5,v 1.24 2024/04/20 21:05:02 tom Exp $
 #
 # This is an adaptation of ncurses' termcap/terminfo capability table, which
 # is designed to align with OSF/1 version 5 (Tru64) terminfo.
@@ -48,7 +48,7 @@
 #
 # Column 1: terminfo variable name
 # Column 2: terminfo capability name
-# Column 3: capability type (boolean, numeric, or string)
+# Column 3: capability type (Boolean, numeric, or string)
 # Column 4: termcap capability name
 # Column 5: KEY_xxx name, if any, `-' otherwise
 # Column 6: value for KEY_xxx name, if any, `-' otherwise
@@ -58,7 +58,7 @@
 #
 # The codes following [Y-] in column 7 describe the versions of termcap which
 # use the given capability.  This information is not used by the curses library
-# proper; rather, it's there to help the terminfo maintainer avoid emitting
+# proper; rather, it is there to help the terminfo maintainer avoid emitting
 # termcap entry translations that are more than 1023 bytes long (and tank a
 # lot of old termcap-using programs).  The codes read as follows:
 #	B = mentioned in the BSD man page for 4.4BSD curses
@@ -98,8 +98,8 @@
 # 3. List it in the standard table.  You almost certainly do *not* want
 # to do this -- the capabilities in that one, and their order, have been
 # carefully chosen to be SVr4-binary-compatible when they're written out
-# as a terminfo object, and breaking this would be bad.  It's up to the ncurses
-# library what to do with the terminfo data after it's read in.
+# as a terminfo object, and breaking this would be bad.  It is up to the ncurses
+# library what to do with the terminfo data after it is read in.
 #
 # 4. List it in the aliases table with an IGNORE target field.  If you
 # do this, the capability will be ignored on input (though the user will
@@ -108,7 +108,7 @@
 # 5. List it in the extensions table. If you do this, the compiler will
 # silently accept the capability, but the curses library proper will never
 # see it (because it won't be written out as part of the terminfo object
-# format).  It's up to you what you have the compiler do with it.
+# format).  It is up to you what you have the compiler do with it.
 #
 # There are two opposite reasons to choose option 5.  One is when you want
 # to eat the capability silently and discard it when doing translations
@@ -153,67 +153,103 @@
 # to buy space for non-essentials Emacs is still using.  Capabilities high
 # on that hit list: rc, sc, uc.
 #
+# FORMATTING THE TABLES
+#
+# We manually specify a (minimum) column width for the capability name
+# and terminfo code columns in the tables to achieve a consistent
+# arrangement; as used here, tbl(1) cannot know the width required by
+# one table's data while formatting another's.
+#
+# The longest capability names (C variables) are
+# "enter_near_letter_quality" and "bit_image_carriage_return" (tied at
+# 25n), and the longest terminfo code is "setcolor" (8n).
+#
+# The tables are a tight fit on traditional man(7) implementations that
+# use a line length of 65n, and the "Description" column has little room
+# within which the formatter can make breaking or adjustment decisions.
+# Words like "micro_..._address" and "parm_..._micro" don't break.
+# Reducing the inter-column gaps to 2 ens gives them enough room.  --GBR
+#
 #############################################################################
 #
 # STANDARD CAPABILITIES
 #
-#%The following is a complete table of the capabilities included in a
-#%terminfo description block and available to terminfo-using code.  In each
-#%line of the table,
-#%
-#%The \fBvariable\fR is the name by which the programmer (at the terminfo level)
-#%accesses the capability.
-#%
-#%The \fBcapname\fR is the short name used in the text of the database,
-#%and is used by a person updating the database.
-#%Whenever possible, capnames are chosen to be the same as or similar to
-#%the ANSI X3.64-1979 standard (now superseded by ECMA-48, which uses
-#%identical or very similar names).  Semantics are also intended to match
-#%those of the specification.
-#%
-#%The termcap code is the old
-#%.B termcap
-#%capability name (some capabilities are new, and have names which termcap
-#%did not originate).
-#%.P
-#%Capability names have no hard length limit, but an informal limit of 5
-#%characters has been adopted to keep them short and to allow the tabs in
-#%the source file
-#%.B Caps
+#%Tables of capabilities
+#%.I \%ncurses
+#%recognizes in a
+#%.I \%term\%info
+#%terminal type description and available to
+#%.IR \%term\%info -using
+#%code follow.
+#%.bP
+#%The capability name identifies the symbol by which the programmer
+#%using the
+#%.I \%term\%info
+#%API accesses the capability.
+#%.bP
+#%The TI
+#%.RI ( \%term\%info )
+#%code is the short name used by a person composing or updating a
+#%terminal type entry.
+#%.IP
+#%Whenever possible,
+#%these codes are the same as or similar to those of the ANSI X3.64-1979
+#%standard
+#%(now superseded by ECMA-48,
+#%which uses identical or very similar names).
+#%Semantics are also intended to match those of the specification.
+#%.IP
+#%.I \%term\%info
+#%codes have no hard length limit,
+#%but
+#%.I \%ncurses
+#%maintains an informal one of 5 characters to keep them short and to
+#%allow the tabs in the source file
+#%.I Caps
 #%to line up nicely.
-#%
-#%Finally, the description field attempts to convey the semantics of the
-#%capability.  You may find some codes in the description field:
-#%.TP
-#%(P)
-#%indicates that padding may be specified
+#%(Some standard codes exceed this limit regardless.)
+#%.bP
+#%The TC
+#%.RI ( termcap )
+#%code is that used by the corresponding API of
+#%.IR \%ncurses .
+#%(Some capabilities are new,
+#%and have names that BSD
+#%.I termcap
+#%did not originate.)
+#%.bP
+#%The description field attempts to convey the capability's semantics.
+#%.PP
+#%The description field employs a handful of notations.
 #%.TP
-#%#[1-9]
-#%in the description field indicates that the string is passed
-#%through \fBtparm\fP(3X) with parameters as given (#\fIi\fP).
-#%.IP
-#%If no parameters are listed in the description,
-#%passing the string through \fBtparm\fP(3X) may give unexpected results,
-#%e.g., if it contains percent (%%) signs.
+#%.B (P)
+#%indicates that padding may be specified.
 #%.TP
-#%(P*)
-#%indicates that padding may vary in proportion to the number of
-#%lines affected
+#%.B (P*)
+#%indicates that padding may vary in proportion to the number of output
+#%lines affected.
 #%.TP
-#%(#\d\fIi\fP\u)
-#%indicates the \fIi\fP\uth\d parameter.
-#%
+#%.BI # i
+#%indicates the
+#%.IR i th
+#%parameter of a string capability;
+#%the programmer should pass the string to \fB\%tparm\fP(3X) with the
+#%parameters listed.
+#%.IP
+#%If the description lists no parameters,
+#%passing the string to \fB\%tparm\fP(3X) may produce unexpected
+#%behavior,
+#%for instance if the string contains percent signs.
+#%.
 #%.PP
-#% These are the boolean capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBBooleans	name	Code\fR
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%Boolean Capability Name	TI	TC	Description
+#%_
 auto_left_margin		bw	bool	bw	-	-	YB-G-	cub1 wraps from column 0 to last column
 auto_right_margin		am	bool	am	-	-	YBCGE	terminal has automatic margins
 no_esc_ctlc			xsb	bool	xb	-	-	YBCG-	beehive (f1=escape, f2=ctrl C)
@@ -252,18 +288,16 @@ prtr_silent			mc5i	bool	5i	-	-	-----	printer will not echo on screen
 row_addr_glitch			xvpa	bool	YD	-	-	-----	only positive motion for vpa/mvpa caps
 semi_auto_right_margin		sam	bool	YE	-	-	-----	printing in last column causes cr
 #%.TE
-#%.ad
-#%
-#%These are the numeric capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBNumeric	name	Code\fR
+#%.PP
+#%.
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%Numeric Capability Name	TI	TC	Description
+#%_
 columns				cols	num	co	-	-	YBCGE	number of columns in a line
 init_tabs			it	num	it	-	-	YB-G-	tabs initially every # spaces
 lines				lines	num	li	-	-	YBCGE	number of lines on screen or page
@@ -298,18 +332,16 @@ output_res_vert_inch		orvi	num	Yl	-	-	-----	vertical resolution in units per inc
 print_rate			cps	num	Ym	-	-	-----	print rate in characters per second
 wide_char_size			widcs	num	Yn	-	-	-----	character step size when in double wide mode
 #%.TE
-#%.ad
-#%
-#%These are the string capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBString	name	Code\fR
+#%.PP
+#%.
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%String Capability Name	TI	TC	Description
+#%_
 back_tab			cbt	str	bt	-		-	YBCGE	back tab (P)
 bell				bel	str	bl	-		-	YB-GE	audible signal (bell) (P)
 carriage_return			cr	str	cr	-		-	YBCGE	carriage return (P*) (P*)
@@ -372,6 +404,10 @@ key_ctab			kctab	str	kt	KEY_CTAB	0525	-B-G-*	clear-tab key
 key_dc				kdch1	str	kD	KEY_DC		0512	YB-G-	delete-character key
 key_dl				kdl1	str	kL	KEY_DL		0510	-B-G-*	delete-line key
 key_down			kcud1	str	kd	KEY_DOWN	0402	YBCGE	down-arrow key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 key_eic				krmir	str	kM	KEY_EIC		0514	-B-G-*	sent by rmir or smir in insert mode
 key_eol				kel	str	kE	KEY_EOL		0517	-B-G-*	clear-to-end-of-line key
 key_eos				ked	str	kS	KEY_EOS		0516	-B-G-*	clear-to-end-of-screen key
@@ -434,6 +470,10 @@ prtr_on				mc5	str	po	-		-	-B-G-*	turn on printer
 repeat_char			rep	str	rp	-		-	YB-GE	repeat char #1 #2 times (P*)
 reset_1string			rs1	str	r1	-		-	-B---	reset string
 reset_2string			rs2	str	r2	-		-	-B---	reset string
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 reset_3string			rs3	str	r3	-		-	-B---	reset string
 reset_file			rf	str	rf	-		-	-B---	name of reset file
 restore_cursor			rc	str	rc	-		-	YBCG-	restore cursor to position of last save_cursor
@@ -589,6 +629,10 @@ ena_acs				enacs	str	eA	-		-	-----	enable alternate char set
 end_bit_image_region		endbi	str	Yy	-		-	-----	End a bit-image region
 enter_am_mode			smam	str	SA	-		-	-----	turn on automatic margins
 enter_doublewide_mode		swidm	str	ZF	-		-	-----	Enter double-wide mode
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 enter_draft_quality		sdrfq	str	ZG	-		-	-----	Enter draft-quality mode
 enter_italics_mode		sitm	str	ZH	-		-	-----	Enter italic mode
 enter_leftward_mode		slm	str	ZI	-		-	-----	Start leftward carriage motion
@@ -635,6 +679,10 @@ key_f39				kf39	str	FT	KEY_F(39)	-	----E	F39 function key
 key_f40				kf40	str	FU	KEY_F(40)	-	----E	F40 function key
 key_f41				kf41	str	FV	KEY_F(41)	-	----E	F41 function key
 key_f42				kf42	str	FW	KEY_F(42)	-	----E	F42 function key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 key_f43				kf43	str	FX	KEY_F(43)	-	----E	F43 function key
 key_f44				kf44	str	FY	KEY_F(44)	-	----E	F44 function key
 key_f45				kf45	str	FZ	KEY_F(45)	-	----E	F45 function key
@@ -673,6 +721,10 @@ key_replace			krpl	str	&3	KEY_REPLACE	0566	-----	replace key
 key_restart			krst	str	&4	KEY_RESTART	0567	-----	restart key
 key_resume			kres	str	&5	KEY_RESUME	0570	-----	resume key
 key_save			ksav	str	&6	KEY_SAVE	0571	-----	save key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 key_sbeg			kBEG	str	&9	KEY_SBEG	0572	-----	shifted begin key
 key_scancel			kCAN	str	&0	KEY_SCANCEL	0573	-----	shifted cancel key
 key_scommand			kCMD	str	*1	KEY_SCOMMAND	0574	-----	shifted command key
@@ -743,7 +795,7 @@ set_clock			sclk	str	SC	-		-	-----	set clock, #1 hrs #2 mins #3 secs
 set_color_band		setcolor	str	Yz	-		-	-----	Change to ribbon color #1
 set_color_pair			scp	str	sp	-		-	-----	Set current color pair to #1
 set_foreground			setf	str	Sf	-		-	-----	Set foreground color #1
-set_left_margin			smgl	str	ML	-		-	-----	set left soft margin at current column.	 See smgl. (ML is not in BSD termcap).
+set_left_margin			smgl	str	ML	-		-	-----	set left soft margin at current column (not in BSD \fItermcap\fP)
 set_left_margin_parm		smglp	str	Zm	-		-	-----	Set left (right) margin at column #1
 set_lr_margin			smglr	str	ML	-		-	-----	Set both left and right margins to #1, #2.  (ML is not in BSD termcap).
 set_page_length			slines	str	YZ	-		-	-----	Set page length to #1 lines
@@ -891,7 +943,7 @@ has_hardware_tabs		OTpt	bool	pt	-		-	YB---	has 8-char tabs invoked with ^I
 return_does_clr_eol		OTxr	bool	xr	-		-	YB---	return clears the line
 # tek_4025_insert_line		OTxx	bool	xx	-		-	-BC--	Tektronix 4025 insert-line glitch
 #
-# mytinfo described this as a termcap capability, but it's not listed in the
+# mytinfo described this as a termcap capability, but it is not listed in the
 # 4.4BSD man pages, and not found in the 4.4BSD termcap file.  The ncurses
 # package, like System V, behaves as though it is always true.
 #
diff --git a/contrib/ncurses/include/Caps.uwin b/contrib/ncurses/include/Caps.uwin
index de0d5b77cae9..a41e9eca7a30 100644
--- a/contrib/ncurses/include/Caps.uwin
+++ b/contrib/ncurses/include/Caps.uwin
@@ -1,5 +1,5 @@
 ##############################################################################
-# Copyright 2019,2020 Thomas E. Dickey                                       #
+# Copyright 2019-2023,2024 Thomas E. Dickey                                  #
 # Copyright 2001-2015,2016 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -29,7 +29,7 @@
 #
 # Author: Thomas Dickey
 #
-# $Id: Caps.uwin,v 1.13 2020/10/17 21:30:19 tom Exp $
+# $Id: Caps.uwin,v 1.23 2024/04/20 21:05:02 tom Exp $
 #
 # This is an adaptation of ncurses' termcap/terminfo capability table, which
 # is designed to align with U/Win's terminfo.
@@ -48,7 +48,7 @@
 #
 # Column 1: terminfo variable name
 # Column 2: terminfo capability name
-# Column 3: capability type (boolean, numeric, or string)
+# Column 3: capability type (Boolean, numeric, or string)
 # Column 4: termcap capability name
 # Column 5: KEY_xxx name, if any, `-' otherwise
 # Column 6: value for KEY_xxx name, if any, `-' otherwise
@@ -58,7 +58,7 @@
 #
 # The codes following [Y-] in column 7 describe the versions of termcap which
 # use the given capability.  This information is not used by the curses library
-# proper; rather, it's there to help the terminfo maintainer avoid emitting
+# proper; rather, it is there to help the terminfo maintainer avoid emitting
 # termcap entry translations that are more than 1023 bytes long (and tank a
 # lot of old termcap-using programs).  The codes read as follows:
 #	B = mentioned in the BSD man page for 4.4BSD curses
@@ -98,8 +98,8 @@
 # 3. List it in the standard table.  You almost certainly do *not* want
 # to do this -- the capabilities in that one, and their order, have been
 # carefully chosen to be SVr4-binary-compatible when they're written out
-# as a terminfo object, and breaking this would be bad.  It's up to the ncurses
-# library what to do with the terminfo data after it's read in.
+# as a terminfo object, and breaking this would be bad.  It is up to the ncurses
+# library what to do with the terminfo data after it is read in.
 #
 # 4. List it in the aliases table with an IGNORE target field.  If you
 # do this, the capability will be ignored on input (though the user will
@@ -108,7 +108,7 @@
 # 5. List it in the extensions table. If you do this, the compiler will
 # silently accept the capability, but the curses library proper will never
 # see it (because it won't be written out as part of the terminfo object
-# format).  It's up to you what you have the compiler do with it.
+# format).  It is up to you what you have the compiler do with it.
 #
 # There are two opposite reasons to choose option 5.  One is when you want
 # to eat the capability silently and discard it when doing translations
@@ -153,67 +153,103 @@
 # to buy space for non-essentials Emacs is still using.  Capabilities high
 # on that hit list: rc, sc, uc.
 #
+# FORMATTING THE TABLES
+#
+# We manually specify a (minimum) column width for the capability name
+# and terminfo code columns in the tables to achieve a consistent
+# arrangement; as used here, tbl(1) cannot know the width required by
+# one table's data while formatting another's.
+#
+# The longest capability names (C variable) is
+# "hue_lightness_saturation" (24n), and the longest terminfo code is
+# "colornm" (7n).
+#
+# The tables are a tight fit on traditional man(7) implementations that
+# use a line length of 65n, and the "Description" column has little room
+# within which the formatter can make breaking or adjustment decisions.
+# Words like "micro_..._address" and "parm_..._micro" don't break.
+# Reducing the inter-column gaps to 2 ens gives them enough room.  --GBR
+#
 #############################################################################
 #
 # STANDARD CAPABILITIES
 #
-#%The following is a complete table of the capabilities included in a
-#%terminfo description block and available to terminfo-using code.  In each
-#%line of the table,
-#%
-#%The \fBvariable\fR is the name by which the programmer (at the terminfo level)
-#%accesses the capability.
-#%
-#%The \fBcapname\fR is the short name used in the text of the database,
-#%and is used by a person updating the database.
-#%Whenever possible, capnames are chosen to be the same as or similar to
-#%the ANSI X3.64-1979 standard (now superseded by ECMA-48, which uses
-#%identical or very similar names).  Semantics are also intended to match
-#%those of the specification.
-#%
-#%The termcap code is the old
-#%.B termcap
-#%capability name (some capabilities are new, and have names which termcap
-#%did not originate).
-#%.P
-#%Capability names have no hard length limit, but an informal limit of 5
-#%characters has been adopted to keep them short and to allow the tabs in
-#%the source file
-#%.B Caps
+#%Tables of capabilities
+#%.I \%ncurses
+#%recognizes in a
+#%.I \%term\%info
+#%terminal type description and available to
+#%.IR \%term\%info -using
+#%code follow.
+#%.bP
+#%The capability name identifies the symbol by which the programmer
+#%using the
+#%.I \%term\%info
+#%API accesses the capability.
+#%.bP
+#%The TI
+#%.RI ( \%term\%info )
+#%code is the short name used by a person composing or updating a
+#%terminal type entry.
+#%.IP
+#%Whenever possible,
+#%these codes are the same as or similar to those of the ANSI X3.64-1979
+#%standard
+#%(now superseded by ECMA-48,
+#%which uses identical or very similar names).
+#%Semantics are also intended to match those of the specification.
+#%.IP
+#%.I \%term\%info
+#%codes have no hard length limit,
+#%but
+#%.I \%ncurses
+#%maintains an informal one of 5 characters to keep them short and to
+#%allow the tabs in the source file
+#%.I Caps
 #%to line up nicely.
-#%
-#%Finally, the description field attempts to convey the semantics of the
-#%capability.  You may find some codes in the description field:
-#%.TP
-#%(P)
-#%indicates that padding may be specified
+#%(Some standard codes exceed this limit regardless.)
+#%.bP
+#%The TC
+#%.RI ( termcap )
+#%code is that used by the corresponding API of
+#%.IR \%ncurses .
+#%(Some capabilities are new,
+#%and have names that BSD
+#%.I termcap
+#%did not originate.)
+#%.bP
+#%The description field attempts to convey the capability's semantics.
+#%.PP
+#%The description field employs a handful of notations.
 #%.TP
-#%#[1-9]
-#%in the description field indicates that the string is passed
-#%through \fBtparm\fP(3X) with parameters as given (#\fIi\fP).
-#%.IP
-#%If no parameters are listed in the description,
-#%passing the string through \fBtparm\fP(3X) may give unexpected results,
-#%e.g., if it contains percent (%%) signs.
+#%.B (P)
+#%indicates that padding may be specified.
 #%.TP
-#%(P*)
-#%indicates that padding may vary in proportion to the number of
-#%lines affected
+#%.B (P*)
+#%indicates that padding may vary in proportion to the number of output
+#%lines affected.
 #%.TP
-#%(#\d\fIi\fP\u)
-#%indicates the \fIi\fP\uth\d parameter.
-#%
+#%.BI # i
+#%indicates the
+#%.IR i th
+#%parameter of a string capability;
+#%the programmer should pass the string to \fB\%tparm\fP(3X) with the
+#%parameters listed.
+#%.IP
+#%If the description lists no parameters,
+#%passing the string to \fB\%tparm\fP(3X) may produce unexpected
+#%behavior,
+#%for instance if the string contains percent signs.
+#%.
 #%.PP
-#% These are the boolean capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBBooleans	name	Code\fR
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(24n)2 Lbw(7n)2 Lb2 Lx.
+#%\&	Code	\&
+#%Boolean Capability Name	TI	TC	Description
+#%_
 auto_left_margin		bw	bool	bw	-	-	YB-G-	cub1 wraps from column 0 to last column
 auto_right_margin		am	bool	am	-	-	YBCGE	terminal has automatic margins
 no_esc_ctlc			xsb	bool	xb	-	-	YBCG-	beehive (f1=escape, f2=ctrl C)
@@ -245,18 +281,16 @@ back_color_erase		bce	bool	ut	-	-	-----	screen erased with background color
 can_change			ccc	bool	cc	-	-	-----	terminal can re-define existing colors
 hue_lightness_saturation	hls	bool	hl	-	-	-----	terminal uses only HLS color notation (Tektronix)
 #%.TE
-#%.ad
-#%
-#%These are the numeric capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBNumeric	name	Code\fR
+#%.PP
+#%.
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(24n)2 Lbw(7n)2 Lb2 Lx.
+#%\&	Code	\&
+#%Numeric Capability Name	TI	TC	Description
+#%_
 columns				cols	num	co	-	-	YBCGE	number of columns in a line
 init_tabs			it	num	it	-	-	YB-G-	tabs initially every # spaces
 lines				lines	num	li	-	-	YBCGE	number of lines on screen or page
@@ -276,24 +310,16 @@ max_colors			colors	num	Co	-	-	-----	maximum number of colors on screen
 max_pairs			pairs	num	pa	-	-	-----	maximum number of color-pairs on the screen
 no_color_video			ncv	num	NC	-	-	-----	video attributes that cannot be used with colors
 #%.TE
-#%.ad
-#%
-#%The following numeric capabilities are present in the SVr4.0 term structure,
-#%but are not yet documented in the man page.  They came in with SVr4's
-#%printer support.
-#%
-#%.na
-#%
-#%These are the string capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBString	name	Code\fR
+#%.PP
+#%.
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(24n)2 Lbw(7n)2 Lb2 Lx.
+#%\&	Code	\&
+#%String Capability Name	TI	TC	Description
+#%_
 back_tab			cbt	str	bt	-		-	YBCGE	back tab (P)
 bell				bel	str	bl	-		-	YB-GE	audible signal (bell) (P)
 carriage_return			cr	str	cr	-		-	YBCGE	carriage return (P*) (P*)
@@ -356,6 +382,10 @@ key_ctab			kctab	str	kt	KEY_CTAB	0525	-B-G-*	clear-tab key
 key_dc				kdch1	str	kD	KEY_DC		0512	YB-G-	delete-character key
 key_dl				kdl1	str	kL	KEY_DL		0510	-B-G-*	delete-line key
 key_down			kcud1	str	kd	KEY_DOWN	0402	YBCGE	down-arrow key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(24n)2 Lbw(7n)2 Lb2 Lx.
 key_eic				krmir	str	kM	KEY_EIC		0514	-B-G-*	sent by rmir or smir in insert mode
 key_eol				kel	str	kE	KEY_EOL		0517	-B-G-*	clear-to-end-of-line key
 key_eos				ked	str	kS	KEY_EOS		0516	-B-G-*	clear-to-end-of-screen key
@@ -418,6 +448,10 @@ prtr_on				mc5	str	po	-		-	-B-G-*	turn on printer
 repeat_char			rep	str	rp	-		-	YB-GE	repeat char #1 #2 times (P*)
 reset_1string			rs1	str	r1	-		-	-B---	reset string
 reset_2string			rs2	str	r2	-		-	-B---	reset string
+#%.TE
+#%.TS
+#%center;
+#%Lbw(24n)2 Lbw(7n)2 Lb2 Lx.
 reset_3string			rs3	str	r3	-		-	-B---	reset string
 reset_file			rf	str	rf	-		-	-B---	name of reset file
 restore_cursor			rc	str	rc	-		-	YBCG-	restore cursor to position of last save_cursor
@@ -484,6 +518,10 @@ key_resume			kres	str	&5	KEY_RESUME	0570	-----	resume key
 key_save			ksav	str	&6	KEY_SAVE	0571	-----	save key
 key_suspend			kspd	str	&7	KEY_SUSPEND	0627	-----	suspend key
 key_undo			kund	str	&8	KEY_UNDO	0630	-----	undo key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(24n)2 Lbw(7n)2 Lb2 Lx.
 key_sbeg			kBEG	str	&9	KEY_SBEG	0572	-----	shifted begin key
 key_scancel			kCAN	str	&0	KEY_SCANCEL	0573	-----	shifted cancel key
 key_scommand			kCMD	str	*1	KEY_SCOMMAND	0574	-----	shifted command key
@@ -546,6 +584,10 @@ key_f39				kf39	str	FT	KEY_F(39)	-	----E	F39 function key
 key_f40				kf40	str	FU	KEY_F(40)	-	----E	F40 function key
 key_f41				kf41	str	FV	KEY_F(41)	-	----E	F41 function key
 key_f42				kf42	str	FW	KEY_F(42)	-	----E	F42 function key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(24n)2 Lbw(7n)2 Lb2 Lx.
 key_f43				kf43	str	FX	KEY_F(43)	-	----E	F43 function key
 key_f44				kf44	str	FY	KEY_F(44)	-	----E	F44 function key
 key_f45				kf45	str	FZ	KEY_F(45)	-	----E	F45 function key
@@ -569,7 +611,7 @@ key_f62				kf62	str	Fq	KEY_F(62)	-	----E	F62 function key
 key_f63				kf63	str	Fr	KEY_F(63)	-	----E	F63 function key
 clr_bol				el1	str	cb	-		-	-----	Clear to beginning of line
 clear_margins			mgc	str	MC	-		-	-----	clear right and left soft margins
-set_left_margin			smgl	str	ML	-		-	-----	set left soft margin at current column.	 See smgl. (ML is not in BSD termcap).
+set_left_margin			smgl	str	ML	-		-	-----	set left soft margin at current column (not in BSD \fItermcap\fP)
 set_right_margin		smgr	str	MR	-		-	-----	set right soft margin at current column
 device_type			devt	str	dv	-		-	-----	Indicate language/codeset support
 code_set_init			csin	str	ci	-		-	-----	Init sequence for multiple codesets
@@ -593,7 +635,6 @@ set_background			setb	str	Sb	-		-	-----	Set background color #1
 set_color_pair			scp	str	sp	-		-	-----	Set current color pair to #1
 set_foreground			setf	str	Sf	-		-	-----	Set foreground color #1
 #%.TE
-#%.ad
 #%
 # The magic token below tells the tic compiler-generator code that all the caps
 # past it should be ignored (not written out) when dumping terminfo objects. It
@@ -707,7 +748,7 @@ has_hardware_tabs		OTpt	bool	pt	-		-	YB---	has 8-char tabs invoked with ^I
 return_does_clr_eol		OTxr	bool	xr	-		-	YB---	return clears the line
 # tek_4025_insert_line		OTxx	bool	xx	-		-	-BC--	Tektronix 4025 insert-line glitch
 #
-# mytinfo described this as a termcap capability, but it's not listed in the
+# mytinfo described this as a termcap capability, but it is not listed in the
 # 4.4BSD man pages, and not found in the 4.4BSD termcap file.  The ncurses
 # package, like System V, behaves as though it is always true.
 #
diff --git a/contrib/ncurses/include/MKkey_defs.sh b/contrib/ncurses/include/MKkey_defs.sh
index 86d6891c3693..e58ee2b65d79 100755
--- a/contrib/ncurses/include/MKkey_defs.sh
+++ b/contrib/ncurses/include/MKkey_defs.sh
@@ -1,7 +1,7 @@
 #! /bin/sh
-# $Id: MKkey_defs.sh,v 1.21 2020/08/17 10:45:33 tom Exp $
+# $Id: MKkey_defs.sh,v 1.24 2024/01/19 12:26:17 tom Exp $
 ##############################################################################
-# Copyright 2019,2020 Thomas E. Dickey                                       #
+# Copyright 2019-2022,2024 Thomas E. Dickey                                  #
 # Copyright 2001-2013,2017 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -35,7 +35,7 @@
 #
 # Extract function-key definitions from the Caps file
 #
-: ${AWK-awk}
+: "${AWK-awk}"
 
 test $# = 0 && set Caps
 
@@ -44,7 +44,8 @@ pass1=pass1_$$
 pass2=pass2_$$
 pass3=pass3_$$
 pass4=pass4_$$
-trap 'rm -f $data pass[1234]_$$' EXIT INT QUIT TERM HUP
+trap 'rm -f $data pass[1234]_$$; exit 1' 1 2 3 15
+trap 'rm -f $data pass[1234]_$$' 0
 
 # change repeated tabs (used for readability) to single tabs (needed to make
 # awk see the right field alignment of the corresponding columns):
@@ -63,10 +64,10 @@ fi
 
 # add keys that we generate automatically:
 cat >>$data <<EOF
-key_resize	kr1	str	R1	KEY_RESIZE	+	NCURSES_EXT_FUNCS 	Terminal resize event
+key_resize	kr1	str	R1	KEY_RESIZE	+	NCURSES_SIGWINCH 	Terminal resize event
 EOF
 
-THIS=./`basename $0`
+THIS=./`basename "$0"`
 
 cat <<EOF
 /*
@@ -145,7 +146,7 @@ $5 != "-" && $6 != "-" {
 			if (index($7,"NCURSES_") == 1) {
 				ifdef = 1;
 				printf "\n";
-				printf "#ifdef %s\n", $7;
+				printf "#if %s\n", $7;
 			}
 			if ($5 == "KEY_F(0)" ) {
 				printf "#define "
diff --git a/contrib/ncurses/include/MKncurses_def.sh b/contrib/ncurses/include/MKncurses_def.sh
index 81f39d23161e..22d80c2331ae 100755
--- a/contrib/ncurses/include/MKncurses_def.sh
+++ b/contrib/ncurses/include/MKncurses_def.sh
@@ -1,7 +1,7 @@
 #! /bin/sh
-# $Id: MKncurses_def.sh,v 1.4 2020/02/02 23:34:34 tom Exp $
+# $Id: MKncurses_def.sh,v 1.5 2022/07/16 17:03:59 tom Exp $
 ##############################################################################
-# Copyright 2020 Thomas E. Dickey                                            #
+# Copyright 2020,2022 Thomas E. Dickey                                       #
 # Copyright 2000,2003 Free Software Foundation, Inc.                         #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -56,7 +56,7 @@ cat <<EOF
 
 EOF
 
-${AWK-awk} <$DEFS '
+"${AWK-awk}" <"$DEFS" '
 !/^[@#]/ {
 	if ( NF == 1 )
 	{
diff --git a/contrib/ncurses/include/MKterm.h.awk.in b/contrib/ncurses/include/MKterm.h.awk.in
index c93cdeac6971..a93d8e86e9c1 100644
--- a/contrib/ncurses/include/MKterm.h.awk.in
+++ b/contrib/ncurses/include/MKterm.h.awk.in
@@ -26,7 +26,7 @@ BEGIN {
 	lcurl = "{";
 	rcurl = "}";
 	print  "/****************************************************************************"
-	print  " * Copyright 2018-2019,2020 Thomas E. Dickey                                *"
+	print  " * Copyright 2018-2021,2023 Thomas E. Dickey                                *"
 	print  " * Copyright 1998-2013,2017 Free Software Foundation, Inc.                  *"
 	print  " *                                                                          *"
 	print  " * Permission is hereby granted, free of charge, to any person obtaining a  *"
@@ -60,7 +60,7 @@ BEGIN {
 	print  "/*    and: Thomas E. Dickey                        1995-on                  */"
 	print  "/****************************************************************************/"
 	print  ""
-	print  "/* $Id: MKterm.h.awk.in,v 1.78 2020/10/31 23:14:24 tom Exp $ */"
+	print  "/* $Id: MKterm.h.awk.in,v 1.85 2023/04/23 19:15:36 tom Exp $ */"
 	print  ""
 	print  "/*"
 	print  "**	term.h -- Definition of struct term"
@@ -244,28 +244,28 @@ END {
 	print  " * The only reason these structures are visible is for read-only use."
 	print  " * Programs which modify the data are not, never were, portable across"
 	print  " * curses implementations."
+	print  " *"
+	print  " * The first field in TERMINAL is used in macros."
+	print  " * The remaining fields are private."
 	print  " */"
 	print  "#ifdef NCURSES_INTERNALS"
 	print  ""
+	print  "#undef TERMINAL"
+	print  "#define TERMINAL struct term"
+	print  "TERMINAL;"
+	print  ""
 	if (@NCURSES_EXT_COLORS@) {
 	declare_termtype("int","2");
 	} else {
-	print  "typedef TERMTYPE TERMTYPE2;"
+	print  "#undef TERMTYPE2"
+	print  "#define TERMTYPE2 TERMTYPE"
 	}
+	print  "#else"
 	print  ""
 	print  "typedef struct term {		/* describe an actual terminal */"
 	print  "    TERMTYPE	type;		/* terminal type description */"
-	print  "    short	Filedes;	/* file description being written to */"
-	print  "    TTY		Ottyb;		/* original state of the terminal */"
-	print  "    TTY		Nttyb;		/* current state of the terminal */"
-	print  "    int		_baudrate;	/* used to compute padding */"
-	print  "    char *	_termname;	/* used for termname() */"
-	if (@NCURSES_EXT_COLORS@) {
-	print  "    TERMTYPE2	type2;		/* extended terminal type description */"
-	}
 	print  "} TERMINAL;"
-	print  "#else"
-	print  "typedef struct term TERMINAL;"
+	print  ""
 	print  "#endif /* NCURSES_INTERNALS */"
 	print  ""
 	print  ""
@@ -325,16 +325,11 @@ END {
 	print  "extern NCURSES_EXPORT(char *) _nc_first_name (const char *const);"
 	print  "extern NCURSES_EXPORT(int) _nc_name_match (const char *const, const char *const, const char *const);"
 	print  "extern NCURSES_EXPORT(char *) _nc_tiparm(int, const char *, ...);"
-	print  ""
-	print  "#endif /* NCURSES_INTERNALS */"
-	print  ""
-	print  ""
-	print  "/*"
-	print  " * These entrypoints are used by tack 1.07."
-	print  " */"
 	print  "extern NCURSES_EXPORT(const TERMTYPE *) _nc_fallback (const char *);"
 	print  "extern NCURSES_EXPORT(int) _nc_read_entry (const char * const, char * const, TERMTYPE *const);"
 	print  ""
+	print  "#endif /* NCURSES_INTERNALS */"
+	print  ""
 	print  "/*"
 	print  " * Normal entry points"
 	print  " */"
@@ -360,6 +355,8 @@ END {
 	print  "#endif"
 	print  ""
 	print  "extern NCURSES_EXPORT(char *) tiparm (const char *, ...);		/* special */"
+	print  "extern NCURSES_EXPORT(char *) tiparm_s (int, int, const char *, ...);	/* special */"
+	print  "extern NCURSES_EXPORT(int) tiscan_s (int *, int *, const char *);	/* special */"
 	print  ""
 	print  "#endif /* __NCURSES_H */"
 	print  ""
@@ -406,7 +403,7 @@ END {
 	print  "/*"
 	print  " * Debugging features."
 	print  " */"
-	print  "extern NCURSES_EXPORT(void)    exit_terminfo(int) GCC_NORETURN;"
+	print  "extern GCC_NORETURN NCURSES_EXPORT(void)    exit_terminfo(int);"
 	print  ""
 	print  "#ifdef __cplusplus"
 	printf "%s\n", rcurl;
diff --git a/contrib/ncurses/include/Makefile.in b/contrib/ncurses/include/Makefile.in
index b911f8eadce1..351383b0ebc9 100644
--- a/contrib/ncurses/include/Makefile.in
+++ b/contrib/ncurses/include/Makefile.in
@@ -1,6 +1,6 @@
-# $Id: Makefile.in,v 1.51 2020/09/18 22:55:10 tom Exp $
+# $Id: Makefile.in,v 1.53 2021/07/03 18:56:51 tom Exp $
 ##############################################################################
-# Copyright 2019,2020 Thomas E. Dickey                                       #
+# Copyright 2019-2020,2021 Thomas E. Dickey                                  #
 # Copyright 1998-2013,2015 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -92,6 +92,21 @@ AUTO_SRC = \
 	term.h
 
 ################################################################################
+
+@MAKE_PHONY@.PHONY :	all
+@MAKE_PHONY@.PHONY :	check
+@MAKE_PHONY@.PHONY :	clean
+@MAKE_PHONY@.PHONY :	depend
+@MAKE_PHONY@.PHONY :	distclean
+@MAKE_PHONY@.PHONY :	install
+@MAKE_PHONY@.PHONY :	install.libs
+@MAKE_PHONY@.PHONY :	libs
+@MAKE_PHONY@.PHONY :	mostlyclean
+@MAKE_PHONY@.PHONY :	realclean
+@MAKE_PHONY@.PHONY :	sources
+@MAKE_PHONY@.PHONY :	uninstall
+@MAKE_PHONY@.PHONY :	uninstall.libs
+
 all \
 libs \
 depend \
diff --git a/contrib/ncurses/include/capdefaults.c b/contrib/ncurses/include/capdefaults.c
index 951a9ca4bb5c..0bdda14dee2d 100644
--- a/contrib/ncurses/include/capdefaults.c
+++ b/contrib/ncurses/include/capdefaults.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2000,2008 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -33,11 +33,11 @@
  *     and: Thomas E. Dickey                        1996-on                 *
  ****************************************************************************/
 
-/* $Id: capdefaults.c,v 1.15 2020/02/02 23:34:34 tom Exp $ */
+/* $Id: capdefaults.c,v 1.16 2021/09/04 10:52:55 tom Exp $ */
 
     /*
      * Compute obsolete capabilities.  The reason this is an include file is
-     * that the two places where it's needed want the macros to generate
+     * that the two places where it is needed require the macros to generate
      * offsets to different structures.  See the file Caps for explanations of
      * these conversions.
      *
diff --git a/contrib/ncurses/include/curses.events b/contrib/ncurses/include/curses.events
index 25a2583fc9b5..2509b1bf703a 100644
--- a/contrib/ncurses/include/curses.events
+++ b/contrib/ncurses/include/curses.events
@@ -1,4 +1,4 @@
-/* $Id*/
+/* $Id: curses.events,v 1.4 2024/01/19 09:24:17 tom Exp $ */
 /*
  * vile:cmode:
  * This file is part of ncurses, designed to be appended after curses.h.in
@@ -50,6 +50,6 @@ typedef struct
 extern NCURSES_EXPORT(int) wgetch_events (WINDOW *, _nc_eventlist *) GCC_DEPRECATED(experimental option); /* experimental */
 extern NCURSES_EXPORT(int) wgetnstr_events (WINDOW *,char *,int,_nc_eventlist *) GCC_DEPRECATED(experimental option); /* experimental */
 
-#define KEY_EVENT	0633		/* We were interrupted by an event */
+#define KEY_EVENT	0634		/* We were interrupted by an event */
 
 #endif /* NCURSES_WGETCH_EVENTS */
diff --git a/contrib/ncurses/include/curses.h.in b/contrib/ncurses/include/curses.h.in
index c516b22c1fe4..8cfa0b9ff8d6 100644
--- a/contrib/ncurses/include/curses.h.in
+++ b/contrib/ncurses/include/curses.h.in
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2023,2024 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -33,11 +33,40 @@
  *     and: Thomas E. Dickey                        1996-on                 *
  ****************************************************************************/
 
-/* $Id: curses.h.in,v 1.269 2020/08/17 14:14:12 tom Exp $ */
+/* $Id: curses.h.in,v 1.282 2024/01/19 11:50:07 tom Exp $ */
 
 #ifndef __NCURSES_H
 #define __NCURSES_H
 
+/*
+ The symbols beginning NCURSES_ or USE_ are configuration choices.
+ A few of the former can be overridden by applications at compile-time.
+ Most of the others correspond to configure-script options (or checks
+ by the configure-script for features of the system on which it is built).
+
+ These symbols can be overridden by applications at compile-time:
+ NCURSES_NOMACROS suppresses macro definitions in favor of functions
+ NCURSES_WATTR_MACROS suppresses wattr_* macro definitions
+ NCURSES_WIDECHAR is an alternative for declaring wide-character functions.
+
+ These symbols are used only when building ncurses:
+ NCURSES_ATTR_T
+ NCURSES_FIELD_INTERNALS
+ NCURSES_INTERNALS
+
+ These symbols are set by the configure script:
+ NCURSES_ENABLE_STDBOOL_H
+ NCURSES_EXPANDED
+ NCURSES_EXT_COLORS
+ NCURSES_EXT_FUNCS
+ NCURSES_EXT_PUTWIN
+ NCURSES_NO_PADDING
+ NCURSES_OSPEED_COMPAT
+ NCURSES_PATHSEP
+ NCURSES_REENTRANT
+ NCURSES_SIGWINCH
+ */
+
 #define CURSES 1
 #define CURSES_H 1
 
@@ -60,10 +89,22 @@
  */
 #include <ncurses_dll.h>
 
+/*
+ * Extra headers.
+ */
 #if @HAVE_STDINT_H@
 #include <stdint.h>
 #endif
 
+#ifdef __cplusplus
+#else
+#if @HAVE_STDNORETURN_H@
+#include <stdnoreturn.h>
+#undef GCC_NORETURN
+#define GCC_NORETURN _Noreturn
+#endif
+#endif
+
 /*
  * User-definable tweak to disable the include of <stdbool.h>.
  */
@@ -130,6 +171,19 @@
 #define NCURSES_REENTRANT @cf_cv_enable_reentrant@
 #endif
 
+/*
+ * KEY_RESIZE is an extended feature that relies upon the SIGWINCH handler
+ * in ncurses.
+ */
+#if @NCURSES_EXT_FUNCS@
+#ifndef NCURSES_SIGWINCH
+#define NCURSES_SIGWINCH @cf_cv_enable_sigwinch@
+#endif
+#else
+#undef NCURSES_SIGWINCH
+#define NCURSES_SIGWINCH 0
+#endif
+
 /*
  * In certain environments, we must work around linker problems for data
  */
@@ -391,7 +445,14 @@ extern NCURSES_EXPORT_VAR(chtype) acs_map[];
  */
 #define _NEWINDEX	-1
 
+#ifdef NCURSES_INTERNALS
+#undef SCREEN
+#define SCREEN struct screen
+SCREEN;
+#else
 typedef struct screen  SCREEN;
+#endif
+
 typedef struct _win_st WINDOW;
 
 typedef	chtype	attr_t;		/* ...must be at least as wide as chtype */
@@ -510,14 +571,10 @@ struct _win_st
 
 /*
  * We cannot define these in ncurses_cfg.h, since they require parameters to be
- * passed (that is non-portable).  If you happen to be using gcc with warnings
- * enabled, define
- *	GCC_PRINTF
- *	GCC_SCANF
- * to improve checking of calls to printw(), etc.
+ * passed (that is non-portable).
  */
 #ifndef GCC_PRINTFLIKE
-#if defined(GCC_PRINTF) && !defined(printf)
+#ifndef printf
 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
 #else
 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
@@ -525,7 +582,7 @@ struct _win_st
 #endif
 
 #ifndef GCC_SCANFLIKE
-#if defined(GCC_SCANF) && !defined(scanf)
+#ifndef scanf
 #define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
 #else
 #define GCC_SCANFLIKE(fmt,var)  /*nothing*/
@@ -773,10 +830,14 @@ extern NCURSES_EXPORT(void) use_tioctl (bool);				/* implemented */
 extern NCURSES_EXPORT(int) vidattr (chtype);				/* implemented */
 extern NCURSES_EXPORT(int) vidputs (chtype, NCURSES_OUTC);		/* implemented */
 extern NCURSES_EXPORT(int) vline (chtype, int);				/* generated */
-extern NCURSES_EXPORT(int) vwprintw (WINDOW *, const char *,va_list) GCC_DEPRECATED(use vw_printw);	/* implemented */
-extern NCURSES_EXPORT(int) vw_printw (WINDOW *, const char *,va_list);	/* implemented */
-extern NCURSES_EXPORT(int) vwscanw (WINDOW *, const char *,va_list) GCC_DEPRECATED(use vw_scanw);	/* implemented */
-extern NCURSES_EXPORT(int) vw_scanw (WINDOW *, const char *,va_list);	/* implemented */
+extern NCURSES_EXPORT(int) vwprintw (WINDOW *, const char *, va_list) GCC_DEPRECATED(use vw_printw)	/* implemented */
+		GCC_PRINTFLIKE(2,0);
+extern NCURSES_EXPORT(int) vw_printw (WINDOW *, const char *, va_list)	/* implemented */
+		GCC_PRINTFLIKE(2,0);	
+extern NCURSES_EXPORT(int) vwscanw (WINDOW *, const char *, va_list) GCC_DEPRECATED(use vw_scanw)	/* implemented */
+		GCC_SCANFLIKE(2,0);
+extern NCURSES_EXPORT(int) vw_scanw (WINDOW *, const char *, va_list)	/* implemented */
+		GCC_SCANFLIKE(2,0);
 extern NCURSES_EXPORT(int) waddch (WINDOW *, const chtype);		/* implemented */
 extern NCURSES_EXPORT(int) waddchnstr (WINDOW *,const chtype *,int);	/* implemented */
 extern NCURSES_EXPORT(int) waddchstr (WINDOW *,const chtype *);		/* generated */
@@ -849,6 +910,8 @@ extern NCURSES_EXPORT(char *) tparm (const char *, NCURSES_TPARM_ARG,NCURSES_TPA
 #endif
 
 extern NCURSES_EXPORT(char *) tiparm (const char *, ...);		/* special */
+extern NCURSES_EXPORT(char *) tiparm_s (int, int, const char *, ...);	/* special */
+extern NCURSES_EXPORT(int) tiscan_s (int *, int *, const char *);	/* special */
 
 /*
  * These functions are not in X/Open, but we use them in macro definitions:
@@ -878,11 +941,9 @@ extern NCURSES_EXPORT(int) getpary (const WINDOW *);			/* generated */
 #define NCURSES_EXT_FUNCS @NCURSES_PATCH@
 typedef int (*NCURSES_WINDOW_CB)(WINDOW *, void *);
 typedef int (*NCURSES_SCREEN_CB)(SCREEN *, void *);
-extern NCURSES_EXPORT(bool) is_term_resized (int, int);
-extern NCURSES_EXPORT(char *) keybound (int, int);
-extern NCURSES_EXPORT(const char *) curses_version (void);
 extern NCURSES_EXPORT(int) alloc_pair (int, int);
 extern NCURSES_EXPORT(int) assume_default_colors (int, int);
+extern NCURSES_EXPORT(const char *) curses_version (void);
 extern NCURSES_EXPORT(int) define_key (const char *, int);
 extern NCURSES_EXPORT(int) extended_color_content(int, int *, int *, int *);
 extern NCURSES_EXPORT(int) extended_pair_content(int, int *, int *);
@@ -892,20 +953,31 @@ extern NCURSES_EXPORT(int) free_pair (int);
 extern NCURSES_EXPORT(int) get_escdelay (void);
 extern NCURSES_EXPORT(int) init_extended_color(int, int, int, int);
 extern NCURSES_EXPORT(int) init_extended_pair(int, int, int);
+extern NCURSES_EXPORT(int) is_cbreak(void);
+extern NCURSES_EXPORT(int) is_echo(void);
+extern NCURSES_EXPORT(int) is_nl(void);
+extern NCURSES_EXPORT(int) is_raw(void);
+extern NCURSES_EXPORT(bool) is_term_resized (int, int);
 extern NCURSES_EXPORT(int) key_defined (const char *);
+extern NCURSES_EXPORT(char *) keybound (int, int);
 extern NCURSES_EXPORT(int) keyok (int, bool);
+extern NCURSES_EXPORT(void) nofilter(void);
 extern NCURSES_EXPORT(void) reset_color_pairs (void);
 extern NCURSES_EXPORT(int) resize_term (int, int);
 extern NCURSES_EXPORT(int) resizeterm (int, int);
 extern NCURSES_EXPORT(int) set_escdelay (int);
 extern NCURSES_EXPORT(int) set_tabsize (int);
 extern NCURSES_EXPORT(int) use_default_colors (void);
-extern NCURSES_EXPORT(int) use_extended_names (bool);
 extern NCURSES_EXPORT(int) use_legacy_coding (int);
 extern NCURSES_EXPORT(int) use_screen (SCREEN *, NCURSES_SCREEN_CB, void *);
 extern NCURSES_EXPORT(int) use_window (WINDOW *, NCURSES_WINDOW_CB, void *);
 extern NCURSES_EXPORT(int) wresize (WINDOW *, int, int);
-extern NCURSES_EXPORT(void) nofilter(void);
+
+#if @NCURSES_XNAMES@
+#undef  NCURSES_XNAMES
+#define NCURSES_XNAMES @NCURSES_XNAMES@
+extern NCURSES_EXPORT(int) use_extended_names (bool);
+#endif
 
 /*
  * These extensions provide access to information stored in the WINDOW even
@@ -1020,20 +1092,24 @@ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(use_tioctl) (SCREEN*, bool); /* impl
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vidattr) (SCREEN*, chtype);	/* implemented:SP_FUNC */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vidputs) (SCREEN*, chtype, NCURSES_SP_OUTC); /* implemented:SP_FUNC */
 #if @NCURSES_EXT_FUNCS@
-extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(keybound) (SCREEN*, int, int);	/* implemented:EXT_SP_FUNC */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(alloc_pair) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(assume_default_colors) (SCREEN*, int, int);	/* implemented:EXT_SP_FUNC */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(define_key) (SCREEN*, const char *, int);	/* implemented:EXT_SP_FUNC */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(extended_color_content) (SCREEN*, int, int *, int *, int *);	/* implemented:EXT_SP_FUNC */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(extended_pair_content) (SCREEN*, int, int *, int *);	/* implemented:EXT_SP_FUNC */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(extended_slk_color) (SCREEN*, int);	/* implemented:EXT_SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(get_escdelay) (SCREEN*);	/* implemented:EXT_SP_FUNC */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(find_pair) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(free_pair) (SCREEN*, int); /* implemented:EXT_SP_FUNC */
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(get_escdelay) (SCREEN*);	/* implemented:EXT_SP_FUNC */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_extended_color) (SCREEN*, int, int, int, int);	/* implemented:EXT_SP_FUNC */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_extended_pair) (SCREEN*, int, int, int);	/* implemented:EXT_SP_FUNC */
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(is_cbreak) (SCREEN*);	/* implemented:EXT_SP_FUNC */
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(is_echo) (SCREEN*);	/* implemented:EXT_SP_FUNC */
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(is_nl) (SCREEN*);	/* implemented:EXT_SP_FUNC */
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(is_raw) (SCREEN*);	/* implemented:EXT_SP_FUNC */
 extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(is_term_resized) (SCREEN*, int, int);	/* implemented:EXT_SP_FUNC */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(key_defined) (SCREEN*, const char *);	/* implemented:EXT_SP_FUNC */
+extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(keybound) (SCREEN*, int, int);	/* implemented:EXT_SP_FUNC */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(keyok) (SCREEN*, int, bool);	/* implemented:EXT_SP_FUNC */
 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(nofilter) (SCREEN*); /* implemented */	/* implemented:EXT_SP_FUNC */
 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(reset_color_pairs) (SCREEN*); /* implemented:EXT_SP_FUNC */
diff --git a/contrib/ncurses/include/curses.tail b/contrib/ncurses/include/curses.tail
index 05f7439eff9d..9c9135656048 100644
--- a/contrib/ncurses/include/curses.tail
+++ b/contrib/ncurses/include/curses.tail
@@ -1,4 +1,4 @@
-/* $Id: curses.tail,v 1.25 2019/12/14 22:28:39 tom Exp $ */
+/* $Id: curses.tail,v 1.27 2023/08/05 19:43:46 tom Exp $ */
 /*
  * vile:cmode:
  * This file is part of ncurses, designed to be appended after curses.h.in
@@ -13,12 +13,12 @@
 #define NCURSES_MOUSE_MASK(b,m) ((m) << (((b) - 1) * 6))
 #endif
 
-#define	NCURSES_BUTTON_RELEASED	001L
-#define	NCURSES_BUTTON_PRESSED	002L
-#define	NCURSES_BUTTON_CLICKED	004L
-#define	NCURSES_DOUBLE_CLICKED	010L
-#define	NCURSES_TRIPLE_CLICKED	020L
-#define	NCURSES_RESERVED_EVENT	040L
+#define	NCURSES_BUTTON_RELEASED	001UL
+#define	NCURSES_BUTTON_PRESSED	002UL
+#define	NCURSES_BUTTON_CLICKED	004UL
+#define	NCURSES_DOUBLE_CLICKED	010UL
+#define	NCURSES_TRIPLE_CLICKED	020UL
+#define	NCURSES_RESERVED_EVENT	040UL
 
 /* event masks */
 #define	BUTTON1_RELEASED	NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_RELEASED)
@@ -174,7 +174,7 @@ extern NCURSES_EXPORT(const char *) _nc_visbuf (const char *);
 #define OPTIMIZE_ALL		0xff	/* enable all optimizations (dflt) */
 #endif
 
-extern NCURSES_EXPORT(void) exit_curses (int) GCC_NORETURN;
+extern GCC_NORETURN NCURSES_EXPORT(void) exit_curses (int);
 
 #include <unctrl.h>
 
diff --git a/contrib/ncurses/include/curses.wide b/contrib/ncurses/include/curses.wide
index 7a8ae7d5fa13..33adb070d7b1 100644
--- a/contrib/ncurses/include/curses.wide
+++ b/contrib/ncurses/include/curses.wide
@@ -1,4 +1,4 @@
-/* $Id: curses.wide,v 1.50 2017/03/26 16:05:21 tom Exp $ */
+/* $Id: curses.wide,v 1.51 2021/05/22 20:28:29 tom Exp $ */
 /*
  * vile:cmode:
  * This file is part of ncurses, designed to be appended after curses.h.in
@@ -219,10 +219,12 @@ extern NCURSES_EXPORT(int) wvline_set (WINDOW *, const cchar_t *, int);	/* imple
 
 #if NCURSES_SP_FUNCS
 extern NCURSES_EXPORT(attr_t) NCURSES_SP_NAME(term_attrs) (SCREEN*);		/* implemented:SP_FUNC */
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(erasewchar) (SCREEN*, wchar_t *);	/* implemented:SP_FUNC */
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(killwchar) (SCREEN*, wchar_t *);	/* implemented:SP_FUNC */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(unget_wch) (SCREEN*, const wchar_t);	/* implemented:SP_FUNC */
-extern NCURSES_EXPORT(wchar_t*) NCURSES_SP_NAME(wunctrl) (SCREEN*, cchar_t *);	/* implemented:SP_FUNC */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vid_attr) (SCREEN*, attr_t, NCURSES_PAIRS_T, void *);	/* implemented:SP_FUNC */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vid_puts) (SCREEN*, attr_t, NCURSES_PAIRS_T, void *, NCURSES_SP_OUTC);	/* implemented:SP_FUNC */
+extern NCURSES_EXPORT(wchar_t*) NCURSES_SP_NAME(wunctrl) (SCREEN*, cchar_t *);	/* implemented:SP_FUNC */
 #endif
 
 #ifndef NCURSES_NOMACROS
diff --git a/contrib/ncurses/include/edit_cfg.sh b/contrib/ncurses/include/edit_cfg.sh
index f7f1795654f2..559b1575443f 100755
--- a/contrib/ncurses/include/edit_cfg.sh
+++ b/contrib/ncurses/include/edit_cfg.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
-# $Id: edit_cfg.sh,v 1.14 2020/02/02 23:34:34 tom Exp $
+# $Id: edit_cfg.sh,v 1.16 2022/07/16 18:02:32 tom Exp $
 ##############################################################################
-# Copyright 2020 Thomas E. Dickey                                            #
+# Copyright 2020,2022 Thomas E. Dickey                                       #
 # Copyright 1998-2001,2017 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -39,15 +39,16 @@
 #
 BAK=save$$
 TMP=edit$$
-trap "rm -f $BAK $TMP" 0 1 2 3 15
+trap "rm -f $BAK $TMP; exit 1" 1 2 3 15
+trap "rm -f $BAK $TMP" 0
 for name in \
 	HAVE_TCGETATTR \
 	HAVE_TERMIOS_H \
 	HAVE_TERMIO_H \
 	BROKEN_LINKER
 do
-	mv $2 $BAK
-	if ( grep "[ 	]$name[ 	]" $1 2>&1 >$TMP )
+	mv "$2" "$BAK"
+	if ( grep "[ 	]${name}[ 	]" "$1" >$TMP 2>&1 )
 	then
 		value=1
 	else
@@ -58,11 +59,11 @@ do
 		-e "s@#define ${name}.*\$@#define $name $value@" \
 		-e "s@#if $name\$@#if $value /* $name */@" \
 		-e "s@#if !$name\$@#if $value /* !$name */@" \
-		$BAK >$2
-	if (cmp -s $2 $BAK)
+		"$BAK" >"$2"
+	if (cmp -s "$2" "$BAK")
 	then
-		mv $BAK $2
+		mv "$BAK" "$2"
 	else
-		rm -f $BAK
+		rm -f "$BAK"
 	fi
 done
diff --git a/contrib/ncurses/include/headers b/contrib/ncurses/include/headers
index 32e33fdbc734..e1293b28a549 100644
--- a/contrib/ncurses/include/headers
+++ b/contrib/ncurses/include/headers
@@ -1,6 +1,6 @@
-# $Id: headers,v 1.15 2020/08/29 18:51:13 tom Exp $
+# $Id: headers,v 1.16 2023/04/22 12:09:09 tom Exp $
 ##############################################################################
-# Copyright 2020 Thomas E. Dickey                                            #
+# Copyright 2020,2023 Thomas E. Dickey                                       #
 # Copyright 1998-2012,2013 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -39,11 +39,9 @@ ncurses_dll.h
 term.h
 termcap.h
 
-# Headers used only for tic, other programs using internal interfaces
+# Header used by tack 1.08
 @ ticlib
-$(srcdir)/tic.h
 $(srcdir)/term_entry.h
-$(srcdir)/nc_tparm.h
 
 # Porting
 @ port_win32con
diff --git a/contrib/ncurses/include/nc_access.h b/contrib/ncurses/include/nc_access.h
new file mode 100644
index 000000000000..1d2fb0a4ec5e
--- /dev/null
+++ b/contrib/ncurses/include/nc_access.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+ * Copyright 2021,2023 Thomas E. Dickey                                     *
+ *                                                                          *
+ * Permission is hereby granted, free of charge, to any person obtaining a  *
+ * copy of this software and associated documentation files (the            *
+ * "Software"), to deal in the Software without restriction, including      *
+ * without limitation the rights to use, copy, modify, merge, publish,      *
+ * distribute, distribute with modifications, sublicense, and/or sell       *
+ * copies of the Software, and to permit persons to whom the Software is    *
+ * furnished to do so, subject to the following conditions:                 *
+ *                                                                          *
+ * The above copyright notice and this permission notice shall be included  *
+ * in all copies or substantial portions of the Software.                   *
+ *                                                                          *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
+ *                                                                          *
+ * Except as contained in this notice, the name(s) of the above copyright   *
+ * holders shall not be used in advertising or otherwise to promote the     *
+ * sale, use or other dealings in this Software without prior written       *
+ * authorization.                                                           *
+ ****************************************************************************/
+
+/* $Id: nc_access.h,v 1.6 2023/05/06 10:54:55 tom Exp $ */
+
+#ifndef NC_ACCESS_included
+#define NC_ACCESS_included 1
+/* *INDENT-OFF* */
+
+#include <ncurses_cfg.h>
+#include <curses.h>
+#include <sys/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Turn off the 'use_terminfo_vars()' symbol to limit access to environment
+ * variables when running with privileges.
+ */
+#if defined(USE_ROOT_ENVIRON) && defined(USE_SETUID_ENVIRON)
+#define use_terminfo_vars() 1
+#else
+#define use_terminfo_vars() _nc_env_access()
+#endif
+
+extern NCURSES_EXPORT(int) _nc_env_access (void);
+
+/*
+ * Turn off this symbol to limit access to files when running setuid.
+ */
+#ifdef USE_ROOT_ACCESS
+
+#define safe_fopen(name,mode)       fopen(name,mode)
+#define safe_open2(name,flags)      open(name,flags)
+#define safe_open3(name,flags,mode) open(name,flags,mode)
+
+#else
+
+#define safe_fopen(name,mode)       _nc_safe_fopen(name,mode)
+#define safe_open2(name,flags)      _nc_safe_open3(name,flags,0)
+#define safe_open3(name,flags,mode) _nc_safe_open3(name,flags,mode)
+extern NCURSES_EXPORT(FILE *)       _nc_safe_fopen (const char *, const char *);
+extern NCURSES_EXPORT(int)          _nc_safe_open3 (const char *, int, mode_t);
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+/* *INDENT-ON* */
+
+#endif /* NC_ACCESS_included */
diff --git a/contrib/ncurses/include/nc_alloc.h b/contrib/ncurses/include/nc_alloc.h
index 8d19f98e0f67..cfea2beb6daf 100644
--- a/contrib/ncurses/include/nc_alloc.h
+++ b/contrib/ncurses/include/nc_alloc.h
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 2019-2020,2021 Thomas E. Dickey                                *
  * Copyright 1998-2013,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -30,7 +30,7 @@
 /****************************************************************************
  *  Author: Thomas E. Dickey                    1996-on                     *
  ****************************************************************************/
-/* $Id: nc_alloc.h,v 1.27 2020/07/04 20:01:13 tom Exp $ */
+/* $Id: nc_alloc.h,v 1.30 2021/11/20 23:33:38 tom Exp $ */
 
 #ifndef NC_ALLOC_included
 #define NC_ALLOC_included 1
@@ -73,27 +73,26 @@ extern "C" {
 #if HAVE_LIBDBMALLOC || HAVE_LIBDMALLOC || NO_LEAKS
 #define HAVE_NC_FREEALL 1
 struct termtype;
-extern NCURSES_EXPORT(void) _nc_free_tinfo(int) GCC_NORETURN GCC_DEPRECATED("use exit_terminfo");
+extern GCC_NORETURN  NCURSES_EXPORT(void) _nc_free_tinfo(int) GCC_DEPRECATED("use exit_terminfo");
 
 #ifdef NCURSES_INTERNALS
-extern NCURSES_EXPORT(void) _nc_free_tic(int) GCC_NORETURN;
-extern NCURSES_EXPORT(void) _nc_free_tparm(void);
+extern GCC_NORETURN NCURSES_EXPORT(void) _nc_free_tic(int);
 extern void _nc_leaks_dump_entry(void);
 extern NCURSES_EXPORT(void) _nc_leaks_tic(void);
 
 #if NCURSES_SP_FUNCS
-extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_free_and_exit)(SCREEN*, int) GCC_NORETURN;
+extern GCC_NORETURN NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_free_and_exit)(SCREEN*, int);
 #endif
-extern NCURSES_EXPORT(void) _nc_free_and_exit(int) GCC_NORETURN;
+extern GCC_NORETURN NCURSES_EXPORT(void) _nc_free_and_exit(int);
 
 #else /* !NCURSES_INTERNALS */
-extern NCURSES_EXPORT(void) _nc_free_and_exit(int) GCC_NORETURN GCC_DEPRECATED("use exit_curses");
+extern GCC_NORETURN NCURSES_EXPORT(void) _nc_free_and_exit(int) GCC_DEPRECATED("use exit_curses");
 #endif
 
 #define ExitProgram(code) exit_curses(code)
 
 #else
-extern NCURSES_EXPORT(void) _nc_free_and_exit(int) GCC_NORETURN GCC_DEPRECATED("use exit_curses");
+extern GCC_NORETURN NCURSES_EXPORT(void) _nc_free_and_exit(int) GCC_DEPRECATED("use exit_curses");
 #endif /* NO_LEAKS, etc */
 
 #ifndef HAVE_NC_FREEALL
diff --git a/contrib/ncurses/include/nc_mingw.h b/contrib/ncurses/include/nc_mingw.h
index 6729b29d3d09..1bfc4b0d37c1 100644
--- a/contrib/ncurses/include/nc_mingw.h
+++ b/contrib/ncurses/include/nc_mingw.h
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2020,2023 Thomas E. Dickey                                *
  * Copyright 2008-2010,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -31,7 +31,7 @@
  * Author: Thomas Dickey, 2008-on                                           *
  ****************************************************************************/
 
-/* $Id: nc_mingw.h,v 1.9 2020/07/11 22:13:19 tom Exp $ */
+/* $Id: nc_mingw.h,v 1.10 2023/02/25 19:59:24 tom Exp $ */
 
 #ifndef NC_MINGW_H
 #define NC_MINGW_H 1
@@ -50,9 +50,6 @@
 #undef sleep
 #define sleep(n) Sleep((n) * 1000)
 
-#undef gettimeofday
-#define gettimeofday(tv,tz) _nc_gettimeofday(tv,tz)
-
 #if HAVE_SYS_TIME_H
 #include <sys/time.h>		/* for struct timeval */
 #endif
@@ -67,10 +64,12 @@ extern "C" {
 
 #include <ncurses_dll.h>
 
+#if !HAVE_CLOCK_GETTIME && !HAVE_GETTIMEOFDAY
 NCURSES_EXPORT(int) _nc_gettimeofday(struct timeval *, void *);
-
 #undef HAVE_GETTIMEOFDAY
-#define HAVE_GETTIMEOFDAY 1
+#define HAVE_GETTIMEOFDAY 2
+#define gettimeofday(tv,tz) _nc_gettimeofday(tv,tz)
+#endif
 
 #define SIGHUP  1
 #define SIGKILL 9
diff --git a/contrib/ncurses/include/nc_string.h b/contrib/ncurses/include/nc_string.h
index 93cf201507c7..546aa0695ba0 100644
--- a/contrib/ncurses/include/nc_string.h
+++ b/contrib/ncurses/include/nc_string.h
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 2012-2013,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -41,7 +41,7 @@
 #endif
 
 /*
- * $Id: nc_string.h,v 1.8 2020/02/02 23:34:34 tom Exp $
+ * $Id: nc_string.h,v 1.9 2021/04/25 00:10:43 tom Exp $
  *
  * String-hacks.  Use these macros to stifle warnings on (presumably) correct
  * uses of strcat, strcpy and sprintf.
@@ -76,7 +76,11 @@
 #endif
 
 #if USE_STRING_HACKS && HAVE_SNPRINTF
+#ifdef __cplusplus
 #define _nc_SPRINTF             NCURSES_VOID snprintf
+#else
+#define _nc_SPRINTF             NCURSES_VOID (snprintf)
+#endif
 #define _nc_SLIMIT(n)           NCURSES_CAST(size_t,n),
 #else
 #define _nc_SPRINTF             NCURSES_VOID sprintf
diff --git a/contrib/ncurses/include/nc_tparm.h b/contrib/ncurses/include/nc_tparm.h
index 943d9476055d..78170993fa17 100644
--- a/contrib/ncurses/include/nc_tparm.h
+++ b/contrib/ncurses/include/nc_tparm.h
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2018-2020,2023 Thomas E. Dickey                                *
  * Copyright 2006-2012,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -31,7 +31,7 @@
  *  Author: Thomas E. Dickey                        2006                    *
  ****************************************************************************/
 
-/* $Id: nc_tparm.h,v 1.11 2020/05/27 23:33:31 tom Exp $ */
+/* $Id: nc_tparm.h,v 1.12 2023/04/16 17:57:28 tom Exp $ */
 
 #ifndef NC_TPARM_included
 #define NC_TPARM_included 1
@@ -78,6 +78,7 @@
 #endif
 
 #ifdef NCURSES_INTERNALS
+#define TIPARM_0(s) _nc_tiparm(0,s)
 #define TIPARM_1(s,a) _nc_tiparm(1,s,a)
 #define TIPARM_2(s,a,b) _nc_tiparm(2,s,a,b)
 #define TIPARM_3(s,a,b,c) _nc_tiparm(3,s,a,b,c)
diff --git a/contrib/ncurses/include/nc_win32.h b/contrib/ncurses/include/nc_win32.h
index 790e8dfe9388..e67b8e045506 100644
--- a/contrib/ncurses/include/nc_win32.h
+++ b/contrib/ncurses/include/nc_win32.h
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2020,2023 Thomas E. Dickey                                *
  * Copyright 2008-2010,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -31,7 +31,7 @@
  * Author: Thomas Dickey, 2008-on                                           *
  ****************************************************************************/
 
-/* $Id: nc_win32.h,v 1.9 2020/09/13 00:17:30 tom Exp $ */
+/* $Id: nc_win32.h,v 1.10 2023/02/25 20:09:23 tom Exp $ */
 
 #ifndef NC_WIN32_H
 #define NC_WIN32_H 1
@@ -79,9 +79,11 @@ extern "C" {
 
 #include <ncurses_dll.h>
 
+#if !HAVE_CLOCK_GETTIME && !HAVE_GETTIMEOFDAY
 #undef HAVE_GETTIMEOFDAY
-#define HAVE_GETTIMEOFDAY 1
+#define HAVE_GETTIMEOFDAY 2
 extern NCURSES_EXPORT(int) _nc_gettimeofday(struct timeval *, void *);
+#endif
 
 #undef wcwidth
 #define wcwidth(ucs)  _nc_wcwidth((wchar_t)(ucs))
diff --git a/contrib/ncurses/include/ncurses_defs b/contrib/ncurses/include/ncurses_defs
index b805c8414182..c0da3ad53ecc 100644
--- a/contrib/ncurses/include/ncurses_defs
+++ b/contrib/ncurses/include/ncurses_defs
@@ -1,6 +1,6 @@
-# $Id: ncurses_defs,v 1.95 2020/08/01 19:48:21 tom Exp $
+# $Id: ncurses_defs,v 1.110 2024/03/02 20:38:23 tom Exp $
 ##############################################################################
-# Copyright 2018-2019,2020 Thomas E. Dickey                                  #
+# Copyright 2018-2023,2024 Thomas E. Dickey                                  #
 # Copyright 2000-2016,2017 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -48,16 +48,19 @@ HAVE_BIG_CORE
 HAVE_BSD_CGETENT
 HAVE_BSD_SIGNAL_H
 HAVE_BSD_STRING_H
-HAVE_BTOWC 
+HAVE_BTOWC
 HAVE_BUILTIN_H
 HAVE_CHGAT	1
+HAVE_CLOCK_GETTIME
 HAVE_COLOR_CONTENT	1
 HAVE_COLOR_SET	1
 HAVE_CONSISTENT_GETENV
+HAVE_CONSISTENT_MB_LEN_MAX
 HAVE_COPYWIN	1
 HAVE_CURSCR	1
 HAVE_CURSES_DATA_TABSIZE	1
 HAVE_CURSES_DATA_TTYTYPE	1
+HAVE_CURSES_TRACE	1
 HAVE_DELSCREEN	1
 HAVE_DERWIN	1
 HAVE_DIRENT_H
@@ -68,6 +71,8 @@ HAVE_EXIT_TERMINFO	1
 HAVE_FCNTL_H
 HAVE_FILTER	1
 HAVE_FORM_H
+HAVE_FPATHCONF
+HAVE_GETAUXVAL
 HAVE_GETBEGX	1
 HAVE_GETCURX	1
 HAVE_GETCWD
@@ -79,6 +84,7 @@ HAVE_GETOPT_H
 HAVE_GETPARX	1
 HAVE_GETTIMEOFDAY
 HAVE_GETTTYNAM
+HAVE_GETUID
 HAVE_GETWIN	1
 HAVE_GPM_H
 HAVE_GPP_BUILTIN_H
@@ -105,6 +111,7 @@ HAVE_LINK
 HAVE_LOCALECONV
 HAVE_LOCALE_H
 HAVE_LONG_FILE_NAMES
+HAVE_MATH_FUNCS
 HAVE_MATH_H
 HAVE_MBLEN
 HAVE_MBRLEN
@@ -119,16 +126,18 @@ HAVE_MVVLINE	1
 HAVE_MVWIN	1
 HAVE_MVWVLINE	1
 HAVE_NANOSLEEP
+HAVE_NAPMS	1
 HAVE_NC_ALLOC_H
 HAVE_NEWPAD	1
 HAVE_PANEL_H
+HAVE_PATH_TTYS
 HAVE_PCRE2POSIX_H
 HAVE_PCREPOSIX_H
 HAVE_POLL
 HAVE_POLL_H
 HAVE_PURIFY
 HAVE_PUTENV
-HAVE_PUTWC 
+HAVE_PUTWC
 HAVE_PUTWIN	1
 HAVE_REGEXPR_H_FUNCS
 HAVE_REGEXP_H_FUNCS
@@ -144,6 +153,7 @@ HAVE_SELECT
 HAVE_SETBUF
 HAVE_SETBUFFER
 HAVE_SETENV
+HAVE_SETFSUID
 HAVE_SETUPTERM	1
 HAVE_SETVBUF
 HAVE_SGTTY_H
@@ -161,6 +171,7 @@ HAVE_STRSTR
 HAVE_SYMLINK
 HAVE_SYSCONF
 HAVE_SYS_BSDTYPES_H
+HAVE_SYS_AUXV_H
 HAVE_SYS_IOCTL_H
 HAVE_SYS_PARAM_H
 HAVE_SYS_POLL_H
@@ -182,20 +193,23 @@ HAVE_TERM_H	1
 HAVE_TGETENT	1
 HAVE_TIGETNUM	1
 HAVE_TIGETSTR	1
+HAVE_TIPARM	1
+HAVE_TIPARM_S	1
+HAVE_TISCAN_S	1
 HAVE_TIMES
 HAVE_TPUTS_SP
 HAVE_TSEARCH
-HAVE_TTYENT_H
 HAVE_TYPEAHEAD	1
 HAVE_TYPEINFO
 HAVE_TYPE_ATTR_T
 HAVE_TYPE_SIGACTION
 HAVE_UNCTRL_H	1
+HAVE_UNGET_WCH	1
 HAVE_UNISTD_H
 HAVE_UNLINK
 HAVE_USE_DEFAULT_COLORS
 HAVE_USE_ENV	1
-HAVE_USE_EXTENDED_NAMES
+HAVE_USE_EXTENDED_NAMES	NCURSES_XNAMES
 HAVE_USE_SCREEN
 HAVE_USE_WINDOW
 HAVE_VFSCANF
@@ -207,16 +221,18 @@ HAVE_VW_PRINTW	1
 HAVE_WCHGAT	1
 HAVE_WCSRTOMBS
 HAVE_WCSTOMBS
-HAVE_WCTOB 
+HAVE_WCTOB
 HAVE_WCTOMB
 HAVE_WCTYPE_H
 HAVE_WINSDELLN	1
 HAVE_WINSSTR	1
+HAVE_WMEMCHR
 HAVE_WORKING_POLL
 HAVE_WRESIZE
 HAVE_WSYNCDOWN	1
 HAVE__DOSCAN
 HAVE__TRACEF
+HAVE__NC_TPARM_ANALYZE 1
 MIXEDCASE_FILENAMES
 NCURSES_CHAR_EQ
 NCURSES_EXPANDED
diff --git a/contrib/ncurses/include/ncurses_dll.h.in b/contrib/ncurses/include/ncurses_dll.h.in
index 437c54de0271..401d47a81667 100644
--- a/contrib/ncurses/include/ncurses_dll.h.in
+++ b/contrib/ncurses/include/ncurses_dll.h.in
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2018-2020,2023 Thomas E. Dickey                                *
  * Copyright 2009,2014 Free Software Foundation, Inc.                       *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -26,7 +26,7 @@
  * sale, use or other dealings in this Software without prior written       *
  * authorization.                                                           *
  ****************************************************************************/
-/* $Id: ncurses_dll.h.in,v 1.17 2020/09/05 17:58:47 juergen Exp $ */
+/* $Id: ncurses_dll.h.in,v 1.18 2023/05/06 20:12:43 tom Exp $ */
 
 #ifndef NCURSES_DLL_H_incl
 #define NCURSES_DLL_H_incl 1
@@ -92,7 +92,11 @@
 # define NCURSES_API __cdecl
 #else
 # define NCURSES_EXPORT_GENERAL_IMPORT
-# define NCURSES_EXPORT_GENERAL_EXPORT
+# if (__GNUC__ >= 4) && !defined(__cplusplus)
+#   define NCURSES_EXPORT_GENERAL_EXPORT __attribute__((visibility ("default")))
+# else
+#   define NCURSES_EXPORT_GENERAL_EXPORT
+# endif
 # define NCURSES_API /* FIXME: __attribute__ ((cdecl)) is only available on x86 */
 #endif
 
diff --git a/contrib/ncurses/include/ncurses_mingw.h b/contrib/ncurses/include/ncurses_mingw.h
index fc77aca8b050..8b11272de64d 100644
--- a/contrib/ncurses/include/ncurses_mingw.h
+++ b/contrib/ncurses/include/ncurses_mingw.h
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2018-2020,2021 Thomas E. Dickey                                *
  * Copyright 2008-2014,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,10 +28,10 @@
  ****************************************************************************/
 
 /****************************************************************************
- * Author: Juergen Pfeifer, 2008-on                                         * 
+ * Author: Juergen Pfeifer, 2008-on                                         *
  ****************************************************************************/
 
-/* $Id: ncurses_mingw.h,v 1.6 2020/02/02 23:34:34 tom Exp $ */
+/* $Id: ncurses_mingw.h,v 1.7 2021/06/17 21:26:02 tom Exp $ */
 
 /*
  * This is a placeholder up to now and describes what needs to be implemented
@@ -67,14 +67,14 @@ struct termios
 };
 
 extern NCURSES_EXPORT(int)  _nc_mingw_tcsetattr(
-    int fd, 
-    int optional_actions, 
+    int fd,
+    int optional_actions,
     const struct termios* arg);
 extern NCURSES_EXPORT(int)  _nc_mingw_tcgetattr(
-    int fd, 
+    int fd,
     struct termios* arg);
 extern NCURSES_EXPORT(int)  _nc_mingw_tcflush(
-    int fd, 
+    int fd,
     int queue);
 extern NCURSES_EXPORT(void) _nc_set_term_driver(void* term);
 
diff --git a/contrib/ncurses/include/term_entry.h b/contrib/ncurses/include/term_entry.h
index 18e4b87aab77..24389ad3837e 100644
--- a/contrib/ncurses/include/term_entry.h
+++ b/contrib/ncurses/include/term_entry.h
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
  * Copyright 1998-2015,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -33,7 +33,7 @@
  *     and: Thomas E. Dickey                        1998-on                 *
  ****************************************************************************/
 
-/* $Id: term_entry.h,v 1.60 2020/02/29 15:46:00 anonymous.maarten Exp $ */
+/* $Id: term_entry.h,v 1.64 2023/04/22 13:37:14 tom Exp $ */
 
 /*
  *	term_entry.h -- interface to entry-manipulation code
@@ -135,6 +135,7 @@ struct entry {
 extern NCURSES_EXPORT_VAR(ENTRY *) _nc_head;
 extern NCURSES_EXPORT_VAR(ENTRY *) _nc_tail;
 #define for_entry_list(qp)	for (qp = _nc_head; qp; qp = qp->next)
+#define for_entry_list2(qp,q0)	for (qp = q0; qp; qp = qp->next)
 
 #define MAX_LINE	132
 
@@ -142,7 +143,7 @@ extern NCURSES_EXPORT_VAR(ENTRY *) _nc_tail;
 
 /*
  * Note that WANTED and PRESENT are not simple inverses!  If a capability
- * has been explicitly cancelled, it's not considered WANTED.
+ * has been explicitly cancelled, it is not considered WANTED.
  */
 #define WANTED(s)	((s) == ABSENT_STRING)
 #define PRESENT(s)	(((s) != ABSENT_STRING) && ((s) != CANCELLED_STRING))
@@ -176,6 +177,8 @@ extern NCURSES_EXPORT(void) _nc_wrap_entry (ENTRY *const, bool);
 extern NCURSES_EXPORT(void) _nc_align_termtype (TERMTYPE2 *, TERMTYPE2 *);
 
 /* free_ttype.c: elementary allocation code */
+extern NCURSES_EXPORT(void) _nc_free_termtype (TERMTYPE *);
+extern NCURSES_EXPORT(void) _nc_free_termtype1 (TERMTYPE *);
 extern NCURSES_EXPORT(void) _nc_free_termtype2 (TERMTYPE2 *);
 
 /* lib_termcap.c: trim sgr0 string for termcap users */
@@ -208,26 +211,6 @@ extern NCURSES_EXPORT(void) _nc_trace_xnames (TERMTYPE *);
 
 #endif /* NCURSES_INTERNALS */
 
-/*
- * These entrypoints were used by tack before 1.08.
- */
-
-#undef  NCURSES_TACK_1_08
-#ifdef  NCURSES_INTERNALS
-#define NCURSES_TACK_1_08 /* nothing */
-#else
-#define NCURSES_TACK_1_08 GCC_DEPRECATED("upgrade to tack 1.08")
-#endif
-
-/* alloc_ttype.c: elementary allocation code */
-extern NCURSES_EXPORT(void) _nc_copy_termtype (TERMTYPE *, const TERMTYPE *) NCURSES_TACK_1_08;
-
-/* lib_acs.c */
-extern NCURSES_EXPORT(void) _nc_init_acs (void) NCURSES_TACK_1_08;	/* corresponds to traditional 'init_acs()' */
-
-/* free_ttype.c: elementary allocation code */
-extern NCURSES_EXPORT(void) _nc_free_termtype (TERMTYPE *) NCURSES_TACK_1_08;
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/contrib/ncurses/include/termcap.h.in b/contrib/ncurses/include/termcap.h.in
index dc8d8fc949a8..7b7c70378153 100644
--- a/contrib/ncurses/include/termcap.h.in
+++ b/contrib/ncurses/include/termcap.h.in
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2018-2020,2021 Thomas E. Dickey                                *
  * Copyright 1998-2000,2001 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -32,7 +32,7 @@
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
  ****************************************************************************/
 
-/* $Id: termcap.h.in,v 1.19 2020/02/02 23:34:34 tom Exp $ */
+/* $Id: termcap.h.in,v 1.20 2021/06/17 21:26:02 tom Exp $ */
 
 #ifndef NCURSES_TERMCAP_H_incl
 #define NCURSES_TERMCAP_H_incl	1
@@ -49,13 +49,13 @@ extern "C"
 
 #include <sys/types.h>
 
-#undef  NCURSES_OSPEED 
-#define NCURSES_OSPEED @NCURSES_OSPEED@ 
+#undef  NCURSES_OSPEED
+#define NCURSES_OSPEED @NCURSES_OSPEED@
 
 extern NCURSES_EXPORT_VAR(char) PC;
 extern NCURSES_EXPORT_VAR(char *) UP;
 extern NCURSES_EXPORT_VAR(char *) BC;
-extern NCURSES_EXPORT_VAR(NCURSES_OSPEED) ospeed; 
+extern NCURSES_EXPORT_VAR(NCURSES_OSPEED) ospeed;
 
 #if !defined(NCURSES_TERM_H_incl)
 extern NCURSES_EXPORT(char *) tgetstr (const char *, char **);
diff --git a/contrib/ncurses/include/tic.h b/contrib/ncurses/include/tic.h
index 8210936cc857..7569aae9fb5f 100644
--- a/contrib/ncurses/include/tic.h
+++ b/contrib/ncurses/include/tic.h
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
  * Copyright 1998-2012,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -34,7 +34,7 @@
  ****************************************************************************/
 
 /*
- * $Id: tic.h,v 1.81 2020/02/02 23:34:34 tom Exp $
+ * $Id: tic.h,v 1.87 2023/04/22 13:37:21 tom Exp $
  *	tic.h - Global variables and structures for the terminfo compiler.
  */
 
@@ -135,8 +135,7 @@ extern "C" {
 #define DEBUG_LEVEL(n)	((n) << TRACE_SHIFT)
 
 #define set_trace_level(n) \
-	_nc_tracing &= DEBUG_LEVEL(MAX_DEBUG_LEVEL) \
-		     + DEBUG_LEVEL(MAX_DEBUG_LEVEL) - 1, \
+	_nc_tracing &= TRACE_MAXIMUM, \
 	_nc_tracing |= DEBUG_LEVEL(n)
 
 #ifdef TRACE
@@ -302,11 +301,11 @@ extern NCURSES_EXPORT_VAR(long) _nc_start_line;
 
 /* comp_error.c: warning & abort messages */
 extern NCURSES_EXPORT(const char *) _nc_get_source (void);
-extern NCURSES_EXPORT(void) _nc_err_abort (const char *const,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
+extern GCC_NORETURN NCURSES_EXPORT(void) _nc_err_abort (const char *const,...) GCC_PRINTFLIKE(1,2);
 extern NCURSES_EXPORT(void) _nc_get_type (char *name);
 extern NCURSES_EXPORT(void) _nc_set_source (const char *const);
 extern NCURSES_EXPORT(void) _nc_set_type (const char *const);
-extern NCURSES_EXPORT(void) _nc_syserr_abort (const char *const,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
+extern GCC_NORETURN NCURSES_EXPORT(void) _nc_syserr_abort (const char *const,...) GCC_PRINTFLIKE(1,2);
 extern NCURSES_EXPORT(void) _nc_warning (const char *const,...) GCC_PRINTFLIKE(1,2);
 extern NCURSES_EXPORT_VAR(bool) _nc_suppress_warnings;
 
@@ -337,7 +336,8 @@ extern NCURSES_EXPORT_VAR(const struct tinfo_fkeys) _nc_tinfo_fkeys[];
 
 extern NCURSES_EXPORT_VAR(int) _nc_tparm_err;
 
-extern NCURSES_EXPORT(int) _nc_tparm_analyze(const char *, char **, int *);
+extern NCURSES_EXPORT(int) _nc_tparm_analyze(TERMINAL *, const char *, char **, int *);
+extern NCURSES_EXPORT(void) _nc_reset_tparm(TERMINAL *);
 
 /* lib_trace.c */
 extern NCURSES_EXPORT_VAR(unsigned) _nc_tracing;
@@ -347,6 +347,14 @@ extern NCURSES_EXPORT(const char *) _nc_visbuf2 (int, const char *);
 /* lib_tputs.c */
 extern NCURSES_EXPORT_VAR(int) _nc_nulls_sent;	/* Add one for every null sent */
 
+/* comp_expand.c: expand string into readable form */
+extern NCURSES_EXPORT(char *) _nc_tic_expand (const char *, bool, int);
+
+/* comp_hash.c: name lookup */
+extern NCURSES_EXPORT(struct name_table_entry const *) _nc_find_entry
+	(const char *, const HashValue *);
+extern NCURSES_EXPORT(const HashValue *) _nc_get_hash_table (bool);
+
 /* comp_main.c: compiler main */
 extern const char * _nc_progname;
 
@@ -361,31 +369,6 @@ extern NCURSES_EXPORT(int) _nc_tic_written (void);
 
 #endif /* NCURSES_INTERNALS */
 
-/*
- * These entrypoints were used by tack before 1.08.
- */
-
-#undef  NCURSES_TACK_1_08
-#ifdef  NCURSES_INTERNALS
-#define NCURSES_TACK_1_08 /* nothing */
-#else
-#define NCURSES_TACK_1_08 GCC_DEPRECATED("upgrade to tack 1.08")
-#endif
-
-/* comp_hash.c: name lookup */
-extern NCURSES_EXPORT(struct name_table_entry const *) _nc_find_entry
-	(const char *, const HashValue *) NCURSES_TACK_1_08;
-extern NCURSES_EXPORT(const HashValue *) _nc_get_hash_table (bool) NCURSES_TACK_1_08;
-
-/* comp_scan.c: lexical analysis */
-extern NCURSES_EXPORT(void) _nc_reset_input (FILE *, char *) NCURSES_TACK_1_08;
-
-/* comp_expand.c: expand string into readable form */
-extern NCURSES_EXPORT(char *) _nc_tic_expand (const char *, bool, int) NCURSES_TACK_1_08;
-
-/* comp_scan.c: decode string from readable form */
-extern NCURSES_EXPORT(int) _nc_trans_string (char *, char *) NCURSES_TACK_1_08;
-
 #endif /* NCURSES_TERM_ENTRY_H_incl */
 
 #ifdef __cplusplus
diff --git a/contrib/ncurses/include/win32_curses.h b/contrib/ncurses/include/win32_curses.h
index 5babf47d214a..0c807a022b15 100644
--- a/contrib/ncurses/include/win32_curses.h
+++ b/contrib/ncurses/include/win32_curses.h
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2018-2020,2021 Thomas E. Dickey                                *
  * Copyright 2008-2014,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,10 +28,10 @@
  ****************************************************************************/
 
 /****************************************************************************
- * Author: Juergen Pfeifer, 2008-on                                         * 
+ * Author: Juergen Pfeifer, 2008-on                                         *
  ****************************************************************************/
 
-/* $Id: win32_curses.h,v 1.2 2020/11/14 23:52:46 tom Exp $ */
+/* $Id: win32_curses.h,v 1.3 2021/06/17 21:26:02 tom Exp $ */
 
 /*
  * This is the interface we use on Windows to mimic the control of the settings
diff --git a/contrib/ncurses/install-sh b/contrib/ncurses/install-sh
index 462fa9c3d57b..ec298b537402 100755
--- a/contrib/ncurses/install-sh
+++ b/contrib/ncurses/install-sh
@@ -1,7 +1,8 @@
-#! /bin/sh
-#
+#!/bin/sh
 # install - install a program, script, or datafile
-#
+
+scriptversion=2020-11-14.01; # UTC
+
 # This originates from X11R5 (mit/util/scripts/install.sh), which was
 # later released in X11R6 (xc/config/util/install.sh) with the
 # following copyright and license.
@@ -34,261 +35,507 @@
 # FSF changes to this file are in the public domain.
 #
 # Calling this script install-sh is preferred over install.sh, to prevent
-# `make' implicit rules from creating a file called install from it
+# 'make' implicit rules from creating a file called install from it
 # when there is no Makefile.
 #
 # This script is compatible with the BSD install script, but was written
-# from scratch.  It can only install one file at a time, a restriction
-# shared with many OS's install programs.
+# from scratch.
+
+tab='	'
+nl='
+'
+IFS=" $tab$nl"
+
+# Set DOITPROG to "echo" to test this script.
 
+doit=${DOITPROG-}
+doit_exec=${doit:-exec}
 
-# set DOITPROG to echo to test this script
+# Put in absolute file names if you don't have them in your path;
+# or use environment vars.
 
-# Don't use :- since 4.3BSD and earlier shells don't like it.
-doit="${DOITPROG-}"
+chgrpprog=${CHGRPPROG-chgrp}
+chmodprog=${CHMODPROG-chmod}
+chownprog=${CHOWNPROG-chown}
+cmpprog=${CMPPROG-cmp}
+cpprog=${CPPROG-cp}
+mkdirprog=${MKDIRPROG-mkdir}
+mvprog=${MVPROG-mv}
+rmprog=${RMPROG-rm}
+stripprog=${STRIPPROG-strip}
 
+posix_mkdir=
 
-# put in absolute paths if you don't have them in your path; or use env. vars.
+# Desired mode of installed file.
+mode=0755
 
-mvprog="${MVPROG-mv}"
-cpprog="${CPPROG-cp}"
-chmodprog="${CHMODPROG-chmod}"
-chownprog="${CHOWNPROG-chown}"
-chgrpprog="${CHGRPPROG-chgrp}"
-stripprog="${STRIPPROG-strip}"
-rmprog="${RMPROG-rm}"
-mkdirprog="${MKDIRPROG-mkdir}"
+# Create dirs (including intermediate dirs) using mode 755.
+# This is like GNU 'install' as of coreutils 8.32 (2020).
+mkdir_umask=22
 
-transformbasename=""
-transform_arg=""
-instcmd="$mvprog"
-chmodcmd="$chmodprog 0755"
-chowncmd=""
-chgrpcmd=""
-stripcmd=""
+backupsuffix=
+chgrpcmd=
+chmodcmd=$chmodprog
+chowncmd=
+mvcmd=$mvprog
 rmcmd="$rmprog -f"
-mvcmd="$mvprog"
-src=""
-dst=""
-dir_arg=""
-
-while [ x"$1" != x ]; do
-    case $1 in
-	-c) instcmd=$cpprog
-	    shift
-	    continue;;
-
-	-d) dir_arg=true
-	    shift
-	    continue;;
-
-	-m) chmodcmd="$chmodprog $2"
-	    shift
-	    shift
-	    continue;;
-
-	-o) chowncmd="$chownprog $2"
-	    shift
-	    shift
-	    continue;;
-
-	-g) chgrpcmd="$chgrpprog $2"
-	    shift
-	    shift
-	    continue;;
-
-	-s) stripcmd=$stripprog
-	    shift
-	    continue;;
-
-	-t=*) transformarg=`echo $1 | sed 's/-t=//'`
-	    shift
-	    continue;;
-
-	-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
-	    shift
-	    continue;;
-
-	*)  if [ x"$src" = x ]
-	    then
-		src=$1
-	    else
-		# this colon is to work around a 386BSD /bin/sh bug
-		:
-		dst=$1
-	    fi
-	    shift
-	    continue;;
-    esac
-done
+stripcmd=
 
-if [ x"$src" = x ]
-then
-	echo "$0: no input file specified" >&2
-	exit 1
-else
-	:
-fi
+src=
+dst=
+dir_arg=
+dst_arg=
 
-if [ x"$dir_arg" != x ]; then
-	dst=$src
-	src=""
+copy_on_change=false
+is_target_a_directory=possibly
 
-	if [ -d "$dst" ]; then
-		instcmd=:
-		chmodcmd=""
-	else
-		instcmd=$mkdirprog
-	fi
-else
+usage="\
+Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
+   or: $0 [OPTION]... SRCFILES... DIRECTORY
+   or: $0 [OPTION]... -t DIRECTORY SRCFILES...
+   or: $0 [OPTION]... -d DIRECTORIES...
 
-# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
-# might cause directories to be created, which would be especially bad
-# if $src (and thus $dsttmp) contains '*'.
+In the 1st form, copy SRCFILE to DSTFILE.
+In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
+In the 4th, create DIRECTORIES.
 
-	if [ -f "$src" ] || [ -d "$src" ]
-	then
-		:
-	else
-		echo "$0: $src does not exist" >&2
-		exit 1
-	fi
+Options:
+     --help     display this help and exit.
+     --version  display version info and exit.
 
-	if [ x"$dst" = x ]
-	then
-		echo "$0: no destination specified" >&2
-		exit 1
-	else
-		:
-	fi
+  -c            (ignored)
+  -C            install only if different (preserve data modification time)
+  -d            create directories instead of installing files.
+  -g GROUP      $chgrpprog installed files to GROUP.
+  -m MODE       $chmodprog installed files to MODE.
+  -o USER       $chownprog installed files to USER.
+  -p            pass -p to $cpprog.
+  -s            $stripprog installed files.
+  -S SUFFIX     attempt to back up existing files, with suffix SUFFIX.
+  -t DIRECTORY  install into DIRECTORY.
+  -T            report an error if DSTFILE is a directory.
 
-# If destination is a directory, append the input filename; if your system
-# does not like double slashes in filenames, you may need to add some logic
+Environment variables override the default commands:
+  CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
+  RMPROG STRIPPROG
 
-	if [ -d "$dst" ]
-	then
-		dst=$dst/`basename "$src"`
-	else
-		:
-	fi
-fi
+By default, rm is invoked with -f; when overridden with RMPROG,
+it's up to you to specify -f if you want it.
 
-## this sed command emulates the dirname command
-dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+If -S is not specified, no backups are attempted.
 
-# Make sure that the destination directory exists.
-#  this part is taken from Noah Friedman's mkinstalldirs script
+Email bug reports to bug-automake@gnu.org.
+Automake home page: https://www.gnu.org/software/automake/
+"
 
-# Skip lots of stat calls in the usual case.
-if [ ! -d "$dstdir" ]; then
-defaultIFS='
-	'
-IFS="${IFS-$defaultIFS}"
+while test $# -ne 0; do
+  case $1 in
+    -c) ;;
 
-oIFS=$IFS
-# Some sh's can't handle IFS=/ for some reason.
-IFS='%'
-set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
-IFS=$oIFS
+    -C) copy_on_change=true;;
 
-pathcomp=''
+    -d) dir_arg=true;;
 
-while [ $# -ne 0 ] ; do
-	pathcomp=$pathcomp$1
-	shift
+    -g) chgrpcmd="$chgrpprog $2"
+        shift;;
 
-	if [ ! -d "$pathcomp" ] ;
-        then
-		$mkdirprog "$pathcomp"
-	else
-		:
-	fi
+    --help) echo "$usage"; exit $?;;
 
-	pathcomp=$pathcomp/
-done
-fi
+    -m) mode=$2
+        case $mode in
+          *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
+            echo "$0: invalid mode: $mode" >&2
+            exit 1;;
+        esac
+        shift;;
 
-if [ x"$dir_arg" != x ]
-then
-	$doit $instcmd "$dst" &&
+    -o) chowncmd="$chownprog $2"
+        shift;;
 
-	if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dst"; else : ; fi &&
-	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dst"; else : ; fi &&
-	if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dst"; else : ; fi &&
-	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dst"; else : ; fi
-else
+    -p) cpprog="$cpprog -p";;
 
-# If we're going to rename the final executable, determine the name now.
+    -s) stripcmd=$stripprog;;
 
-	if [ x"$transformarg" = x ]
-	then
-		dstfile=`basename "$dst"`
-	else
-		dstfile=`basename "$dst" $transformbasename |
-			sed $transformarg`$transformbasename
-	fi
+    -S) backupsuffix="$2"
+        shift;;
 
-# don't allow the sed command to completely eliminate the filename
+    -t)
+        is_target_a_directory=always
+        dst_arg=$2
+        # Protect names problematic for 'test' and other utilities.
+        case $dst_arg in
+          -* | [=\(\)!]) dst_arg=./$dst_arg;;
+        esac
+        shift;;
 
-	if [ x"$dstfile" = x ]
-	then
-		dstfile=`basename "$dst"`
-	else
-		:
-	fi
+    -T) is_target_a_directory=never;;
 
-# Make a couple of temp file names in the proper directory.
+    --version) echo "$0 $scriptversion"; exit $?;;
 
-	dsttmp=$dstdir/#inst.$$#
-	rmtmp=$dstdir/#rm.$$#
+    --) shift
+        break;;
 
-# Trap to clean up temp files at exit.
+    -*) echo "$0: invalid option: $1" >&2
+        exit 1;;
 
-	trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0
-	trap '(exit $?); exit' 1 2 13 15
+    *)  break;;
+  esac
+  shift
+done
 
-# Move or copy the file name to the temp name
+# We allow the use of options -d and -T together, by making -d
+# take the precedence; this is for compatibility with GNU install.
 
-	$doit $instcmd "$src" "$dsttmp" &&
+if test -n "$dir_arg"; then
+  if test -n "$dst_arg"; then
+    echo "$0: target directory not allowed when installing a directory." >&2
+    exit 1
+  fi
+fi
 
-# and set any options; do chmod last to preserve setuid bits
+if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
+  # When -d is used, all remaining arguments are directories to create.
+  # When -t is used, the destination is already specified.
+  # Otherwise, the last argument is the destination.  Remove it from $@.
+  for arg
+  do
+    if test -n "$dst_arg"; then
+      # $@ is not empty: it contains at least $arg.
+      set fnord "$@" "$dst_arg"
+      shift # fnord
+    fi
+    shift # arg
+    dst_arg=$arg
+    # Protect names problematic for 'test' and other utilities.
+    case $dst_arg in
+      -* | [=\(\)!]) dst_arg=./$dst_arg;;
+    esac
+  done
+fi
 
-# If any of these fail, we abort the whole thing.  If we want to
-# ignore errors from any of these, just make sure not to ignore
-# errors from the above "$doit $instcmd $src $dsttmp" command.
+if test $# -eq 0; then
+  if test -z "$dir_arg"; then
+    echo "$0: no input file specified." >&2
+    exit 1
+  fi
+  # It's OK to call 'install-sh -d' without argument.
+  # This can happen when creating conditional directories.
+  exit 0
+fi
 
-	if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else :;fi &&
-	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else :;fi &&
-	if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dsttmp"; else :;fi &&
-	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else :;fi &&
+if test -z "$dir_arg"; then
+  if test $# -gt 1 || test "$is_target_a_directory" = always; then
+    if test ! -d "$dst_arg"; then
+      echo "$0: $dst_arg: Is not a directory." >&2
+      exit 1
+    fi
+  fi
+fi
 
-# Now remove or move aside any old file at destination location.  We try this
-# two ways since rm can't unlink itself on some systems and the destination
-# file might be busy for other reasons.  In this case, the final cleanup
-# might fail but the new file should still install successfully.
+if test -z "$dir_arg"; then
+  do_exit='(exit $ret); exit $ret'
+  trap "ret=129; $do_exit" 1
+  trap "ret=130; $do_exit" 2
+  trap "ret=141; $do_exit" 13
+  trap "ret=143; $do_exit" 15
+
+  # Set umask so as not to create temps with too-generous modes.
+  # However, 'strip' requires both read and write access to temps.
+  case $mode in
+    # Optimize common cases.
+    *644) cp_umask=133;;
+    *755) cp_umask=22;;
+
+    *[0-7])
+      if test -z "$stripcmd"; then
+        u_plus_rw=
+      else
+        u_plus_rw='% 200'
+      fi
+      cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
+    *)
+      if test -z "$stripcmd"; then
+        u_plus_rw=
+      else
+        u_plus_rw=,u+rw
+      fi
+      cp_umask=$mode$u_plus_rw;;
+  esac
+fi
 
-{
-	if [ -f "$dstdir/$dstfile" ]
+for src
+do
+  # Protect names problematic for 'test' and other utilities.
+  case $src in
+    -* | [=\(\)!]) src=./$src;;
+  esac
+
+  if test -n "$dir_arg"; then
+    dst=$src
+    dstdir=$dst
+    test -d "$dstdir"
+    dstdir_status=$?
+    # Don't chown directories that already exist.
+    if test $dstdir_status = 0; then
+      chowncmd=""
+    fi
+  else
+
+    # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
+    # might cause directories to be created, which would be especially bad
+    # if $src (and thus $dsttmp) contains '*'.
+    if test ! -f "$src" && test ! -d "$src"; then
+      echo "$0: $src does not exist." >&2
+      exit 1
+    fi
+
+    if test -z "$dst_arg"; then
+      echo "$0: no destination specified." >&2
+      exit 1
+    fi
+    dst=$dst_arg
+
+    # If destination is a directory, append the input filename.
+    if test -d "$dst"; then
+      if test "$is_target_a_directory" = never; then
+        echo "$0: $dst_arg: Is a directory" >&2
+        exit 1
+      fi
+      dstdir=$dst
+      dstbase=`basename "$src"`
+      case $dst in
+	*/) dst=$dst$dstbase;;
+	*)  dst=$dst/$dstbase;;
+      esac
+      dstdir_status=0
+    else
+      dstdir=`dirname "$dst"`
+      test -d "$dstdir"
+      dstdir_status=$?
+    fi
+  fi
+
+  case $dstdir in
+    */) dstdirslash=$dstdir;;
+    *)  dstdirslash=$dstdir/;;
+  esac
+
+  obsolete_mkdir_used=false
+
+  if test $dstdir_status != 0; then
+    case $posix_mkdir in
+      '')
+        # With -d, create the new directory with the user-specified mode.
+        # Otherwise, rely on $mkdir_umask.
+        if test -n "$dir_arg"; then
+          mkdir_mode=-m$mode
+        else
+          mkdir_mode=
+        fi
+
+        posix_mkdir=false
+	# The $RANDOM variable is not portable (e.g., dash).  Use it
+	# here however when possible just to lower collision chance.
+	tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
+
+	trap '
+	  ret=$?
+	  rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null
+	  exit $ret
+	' 0
+
+	# Because "mkdir -p" follows existing symlinks and we likely work
+	# directly in world-writeable /tmp, make sure that the '$tmpdir'
+	# directory is successfully created first before we actually test
+	# 'mkdir -p'.
+	if (umask $mkdir_umask &&
+	    $mkdirprog $mkdir_mode "$tmpdir" &&
+	    exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
 	then
-		$doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null ||
-		$doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null ||
-		{
-		  echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
-		  (exit 1); exit
-		}
+	  if test -z "$dir_arg" || {
+	       # Check for POSIX incompatibilities with -m.
+	       # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
+	       # other-writable bit of parent directory when it shouldn't.
+	       # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
+	       test_tmpdir="$tmpdir/a"
+	       ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
+	       case $ls_ld_tmpdir in
+		 d????-?r-*) different_mode=700;;
+		 d????-?--*) different_mode=755;;
+		 *) false;;
+	       esac &&
+	       $mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
+		 ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
+		 test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
+	       }
+	     }
+	  then posix_mkdir=:
+	  fi
+	  rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
 	else
-		:
+	  # Remove any dirs left behind by ancient mkdir implementations.
+	  rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
 	fi
-} &&
-
-# Now rename the file to the real destination.
-
-	$doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
-
-fi &&
+	trap '' 0;;
+    esac
 
-# The final little trick to "correctly" pass the exit status to the exit trap.
+    if
+      $posix_mkdir && (
+        umask $mkdir_umask &&
+        $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
+      )
+    then :
+    else
+
+      # mkdir does not conform to POSIX,
+      # or it failed possibly due to a race condition.  Create the
+      # directory the slow way, step by step, checking for races as we go.
+
+      case $dstdir in
+        /*) prefix='/';;
+        [-=\(\)!]*) prefix='./';;
+        *)  prefix='';;
+      esac
+
+      oIFS=$IFS
+      IFS=/
+      set -f
+      set fnord $dstdir
+      shift
+      set +f
+      IFS=$oIFS
+
+      prefixes=
+
+      for d
+      do
+        test X"$d" = X && continue
+
+        prefix=$prefix$d
+        if test -d "$prefix"; then
+          prefixes=
+        else
+          if $posix_mkdir; then
+            (umask $mkdir_umask &&
+             $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
+            # Don't fail if two instances are running concurrently.
+            test -d "$prefix" || exit 1
+          else
+            case $prefix in
+              *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
+              *) qprefix=$prefix;;
+            esac
+            prefixes="$prefixes '$qprefix'"
+          fi
+        fi
+        prefix=$prefix/
+      done
+
+      if test -n "$prefixes"; then
+        # Don't fail if two instances are running concurrently.
+        (umask $mkdir_umask &&
+         eval "\$doit_exec \$mkdirprog $prefixes") ||
+          test -d "$dstdir" || exit 1
+        obsolete_mkdir_used=true
+      fi
+    fi
+  fi
+
+  if test -n "$dir_arg"; then
+    { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
+    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
+    { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
+      test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
+  else
+
+    # Make a couple of temp file names in the proper directory.
+    dsttmp=${dstdirslash}_inst.$$_
+    rmtmp=${dstdirslash}_rm.$$_
+
+    # Trap to clean up those temp files at exit.
+    trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
+
+    # Copy the file name to the temp name.
+    (umask $cp_umask &&
+     { test -z "$stripcmd" || {
+	 # Create $dsttmp read-write so that cp doesn't create it read-only,
+	 # which would cause strip to fail.
+	 if test -z "$doit"; then
+	   : >"$dsttmp" # No need to fork-exec 'touch'.
+	 else
+	   $doit touch "$dsttmp"
+	 fi
+       }
+     } &&
+     $doit_exec $cpprog "$src" "$dsttmp") &&
+
+    # and set any options; do chmod last to preserve setuid bits.
+    #
+    # If any of these fail, we abort the whole thing.  If we want to
+    # ignore errors from any of these, just make sure not to ignore
+    # errors from the above "$doit $cpprog $src $dsttmp" command.
+    #
+    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
+    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
+    { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
+    { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
+
+    # If -C, don't bother to copy if it wouldn't change the file.
+    if $copy_on_change &&
+       old=`LC_ALL=C ls -dlL "$dst"     2>/dev/null` &&
+       new=`LC_ALL=C ls -dlL "$dsttmp"  2>/dev/null` &&
+       set -f &&
+       set X $old && old=:$2:$4:$5:$6 &&
+       set X $new && new=:$2:$4:$5:$6 &&
+       set +f &&
+       test "$old" = "$new" &&
+       $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
+    then
+      rm -f "$dsttmp"
+    else
+      # If $backupsuffix is set, and the file being installed
+      # already exists, attempt a backup.  Don't worry if it fails,
+      # e.g., if mv doesn't support -f.
+      if test -n "$backupsuffix" && test -f "$dst"; then
+        $doit $mvcmd -f "$dst" "$dst$backupsuffix" 2>/dev/null
+      fi
+
+      # Rename the file to the real destination.
+      $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
+
+      # The rename failed, perhaps because mv can't rename something else
+      # to itself, or perhaps because mv is so ancient that it does not
+      # support -f.
+      {
+        # Now remove or move aside any old file at destination location.
+        # We try this two ways since rm can't unlink itself on some
+        # systems and the destination file might be busy for other
+        # reasons.  In this case, the final cleanup might fail but the new
+        # file should still install successfully.
+        {
+          test ! -f "$dst" ||
+          $doit $rmcmd "$dst" 2>/dev/null ||
+          { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
+            { $doit $rmcmd "$rmtmp" 2>/dev/null; :; }
+          } ||
+          { echo "$0: cannot unlink or rename $dst" >&2
+            (exit 1); exit 1
+          }
+        } &&
+
+        # Now rename the file to the real destination.
+        $doit $mvcmd "$dsttmp" "$dst"
+      }
+    fi || exit 1
+
+    trap '' 0
+  fi
+done
 
-{
-	(exit 0); exit
-}
+# Local variables:
+# eval: (add-hook 'before-save-hook 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC0"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/contrib/ncurses/man/MKada_config.in b/contrib/ncurses/man/MKada_config.in
index 5f34cff4124b..ee037ff4fdc0 100644
--- a/contrib/ncurses/man/MKada_config.in
+++ b/contrib/ncurses/man/MKada_config.in
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2019,2020 Thomas E. Dickey                                     *
+.\" Copyright 2019-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 2010-2014,2016 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,98 +27,123 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: MKada_config.in,v 1.12 2020/02/02 23:34:34 tom Exp $
+.\" $Id: MKada_config.in,v 1.35 2024/04/20 21:13:27 tom Exp $
+.TH adacurses@USE_CFG_SUFFIX@\-config 1 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "User commands"
 .ds C adacurses@USE_CFG_SUFFIX@\-config
-.TH ADACURSES "1" "" "" "User Commands"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.ds '  \(aq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.ie t .ds '  \(aq
+.el   .ds '  '
+.\}
+.
+.\" Fix broken EX/EE macros on DWB troff.
+.\" Detect it: only DWB sets up a `)Y` register.
+.if !\n(.g .if \n()Y \{\
+.\" Revert the undesired changes to indentation.
+.am EX
+.in -5n
+..
+.am EE
+.in +5n
+..
+.\}
+.
 .SH NAME
-adacurses@USE_CFG_SUFFIX@\-config \- helper script for @ADA_LIBNAME@ libraries
+\fB\%adacurses@USE_CFG_SUFFIX@\-config\fP \-
+configuration helper for \fI@ADA_LIBNAME@\fP libraries
 .SH SYNOPSIS
 .B \*C
-[\fIoptions\fR]
+.RB [ \-\-cflags ]
+.RB [ \-\-libs ]
+.PP
+.B \*C \-\-version
+.PP
+.B \*C \-\-help
 .SH DESCRIPTION
-This is a shell script which simplifies configuring an application to use
-the @ADA_LIBNAME@ library binding to ncurses.
+This program development aid simplifies the process of configuring
+applications to use the \fI@ADA_LIBNAME@\fP library binding to
+\fI\%ncurses\fP.
 .SH OPTIONS
+.TP 11 \" "--version" + 2n
+\fB\-\-cflags\fP
+reports the GNAT (Ada compiler) flags needed to compile with
+\fI@ADA_LIBNAME@\fP.
 .TP
-\fB\-\-cflags\fR
-echos the gnat (Ada compiler) flags needed to compile with @ADA_LIBNAME@.
+\fB\-\-libs\fP
+reports the GNAT libraries needed to link with \fI@ADA_LIBNAME@\fP.
 .TP
-\fB\-\-libs\fR
-echos the gnat libraries needed to link with @ADA_LIBNAME@.
+\fB\-\-version\fP
+reports the release and patch date information of the \fI\%ncurses\fP
+libraries used to configure and build \fI@ADA_LIBNAME@\fP and exits
+successfully.
 .TP
-\fB\-\-version\fR
-echos the release+patchdate version of the ncurses libraries used
-to configure and build @ADA_LIBNAME@.
-.TP
-\fB\-\-help\fR
-prints a list of the \fB\*C\fP script's options.
+\fB\-\-help\fP
+issues a usage message and exits successfully.
 .PP
-If no options are given, \fB\*C\fP prints the combination
-of 
-\fB\-\-cflags\fR and
-\fB\-\-libs\fR
-that \fBgnatmake\fP expects (see example).
-.SH EXAMPLE
+Omitting options implies \*(``\fB\-\-cflags \-\-libs\fP\*(''.
+.SH EXAMPLES
+Consider a program using \fI@ADA_LIBNAME@\fP to write the message
+\*(``Hello, world!\*('' in the center of the screen and wait for the
+user to press the \*(``q\*('' key before exiting.
+Populate a file \fIhello.adb\fP with the following.
 .PP
-For example, supposing that you want to compile the "Hello World!"
-program for @ADA_LIBNAME@.
-Make a file named "hello.adb":
-.RS
-.nf
-.ft CW
+.if \n(LL>67n .RS 4
+.EX
 with Terminal_Interface.Curses; use Terminal_Interface.Curses;
 
 procedure Hello is
-
    Visibility : Cursor_Visibility := Invisible;
+   Message : constant String := "Hello, World!";
    done : Boolean := False;
    c : Key_Code;
-
 begin
-
    Init_Screen;
    Set_Echo_Mode (False);
-
    Set_Cursor_Visibility (Visibility);
    Set_Timeout_Mode (Standard_Window, Non_Blocking, 0);
 
-   Move_Cursor (Line => Lines / 2, Column => (Columns - 12) / 2);
-   Add (Str => "Hello World!");
+   Move_Cursor (Line => Lines / 2,
+                Column => (Columns \- Message\*'Length) / 2);
+   Add (Str => Message);
 
    while not done loop
-
       c := Get_Keystroke (Standard_Window);
+
       case c is
-      when Character'Pos ('q') => done := True;
-      when others => null;
+          when Character\*'Pos (\*'q\*') => done := True;
+          when others => null;
       end case;
 
       Nap_Milli_Seconds (50);
    end loop;
 
    End_Windows;
-
 end Hello;
-.fi
-.RE
+.EE
+.if \n(LL>67n .RE
+.ne 2
 .PP
 Then, using
-.RS
-.ft CW
-gnatmake `adacurses-config --cflags` hello -largs `adacurses-config --libs`
-.ft
+.RS 4
+.EX
+gnatmake \(gaadacurses@USE_CFG_SUFFIX@\-config \-\-cflags\(ga hello \e
+    \-largs \(gaadacurses@USE_CFG_SUFFIX@\-config \-\-libs\(ga
+.EE
 .RE
-.PP
-or (simpler):
-.RS
-.ft CW
-gnatmake hello `adacurses-config`
-.ft
+or, more simply,
+.RS 4
+.EX
+gnatmake hello \(gaadacurses@USE_CFG_SUFFIX@\-config\(ga
+.EE
 .RE
-.PP
-you will compile and link the program.
+you can compile and link the program.
 .SH "SEE ALSO"
-\fBcurses\fR(3X)
-.PP
-This describes \fBncurses\fR
-version @NCURSES_MAJOR@.@NCURSES_MINOR@ (patch @NCURSES_PATCH@).
+\fB\%curses\fP(3X)
diff --git a/contrib/ncurses/man/MKncu_config.in b/contrib/ncurses/man/MKncu_config.in
index 15d5190bd350..14690a544c5e 100644
--- a/contrib/ncurses/man/MKncu_config.in
+++ b/contrib/ncurses/man/MKncu_config.in
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2020 Thomas E. Dickey                                          *
+.\" Copyright 2020-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 2010 Free Software Foundation, Inc.                            *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,73 +27,78 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: MKncu_config.in,v 1.4 2020/02/02 23:34:34 tom Exp $
-.TH @LIB_NAME@@DFT_ARG_SUFFIX@@cf_cv_abi_version@-config 1 ""
+.\" $Id: MKncu_config.in,v 1.24 2024/04/20 21:13:38 tom Exp $
+.TH @LIB_NAME@@DFT_ARG_SUFFIX@@cf_cv_abi_version@-config 1 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "User commands"
 .SH NAME
-@LIB_NAME@@DFT_ARG_SUFFIX@@cf_cv_abi_version@-config \- helper script for ncurses libraries
+\fB\%@LIB_NAME@@DFT_ARG_SUFFIX@@cf_cv_abi_version@-config\fP \-
+configuration helper for \fI\%ncurses\fP libraries
 .SH SYNOPSIS
-.B @LIB_NAME@@DFT_ARG_SUFFIX@@cf_cv_abi_version@-config 
-[\fIoptions\fR]
+.B @LIB_NAME@@DFT_ARG_SUFFIX@@cf_cv_abi_version@-config
+.I option
+\&.\|.\|.
+.PP
+.B "@LIB_NAME@@DFT_ARG_SUFFIX@@cf_cv_abi_version@-config \-\-version"
+.PP
+.B "@LIB_NAME@@DFT_ARG_SUFFIX@@cf_cv_abi_version@-config \-\-help"
 .SH DESCRIPTION
-This is a shell script which simplifies configuring applications against
-a particular set of ncurses libraries.
+This program development aid simplifies the process of configuring
+applications against a particular set of \fI\%ncurses\fP libraries.
 .SH OPTIONS
+.TP 18 \" "--mouse-version" + 2n + adjustment for PDF
+\fB\-\-prefix\fP
+reports the package prefix of \fI\%ncurses\fP.
 .TP
-\fB\-\-prefix\fR
-echos the package\-prefix of ncurses
-.TP
-\fB\-\-exec\-prefix\fR
-echos the executable\-prefix of ncurses
-.TP
-\fB\-\-cflags\fR
-echos the C compiler flags needed to compile with ncurses
+\fB\-\-exec\-prefix\fP
+reports the executable prefix of \fI\%ncurses\fP.
 .TP
-\fB\-\-libs\fR
-echos the libraries needed to link with ncurses
+\fB\-\-cflags\fP
+reports the C compiler flags needed to compile with \fI\%ncurses\fP.
 .TP
-\fB\-\-version\fR
-echos the release+patchdate version of ncurses
+\fB\-\-libs\fP
+reports the libraries needed to link with \fI\%ncurses\fP.
 .TP
-\fB\-\-abi\-version\fR
-echos the ABI version of ncurses
+\fB\-\-abi\-version\fP
+reports the ABI version of \fI\%ncurses\fP.
 .TP
-\fB\-\-mouse\-version\fR
-echos the mouse\-interface version of ncurses
+\fB\-\-mouse\-version\fP
+reports the mouse\-interface version of \fI\%ncurses\fP.
 .TP
-\fB\-\-bindir\fR
-echos the directory containing ncurses programs
+\fB\-\-bindir\fP
+reports the directory containing \fI\%ncurses\fP programs.
 .TP
-\fB\-\-datadir\fR
-echos the directory containing ncurses data
+\fB\-\-datadir\fP
+reports the directory containing \fI\%ncurses\fP data.
 .TP
-\fB\-\-includedir\fR
-echos the directory containing ncurses header files
+\fB\-\-includedir\fP
+reports the directory containing \fI\%ncurses\fP header files.
 .TP
-\fB\-\-libdir\fR
-echos the directory containing ncurses libraries
+\fB\-\-libdir\fP
+reports the directory containing \fI\%ncurses\fP libraries.
 .TP
-\fB\-\-mandir\fR
-echos the directory containing ncurses manpages
+\fB\-\-mandir\fP
+reports the directory containing \fI\%ncurses\fP man pages.
 .TP
-\fB\-\-terminfo\fR
-echos the $TERMINFO terminfo database path, e.g.,
-.RS
-@TERMINFO@
-.RE
+\fB\-\-terminfo\fP
+reports the \fI\%TERMINFO\fP \fIterminfo\fP database path,
+for example \fI\%@TERMINFO@\fP.
 .TP
-\fB\-\-terminfo\-dirs\fR
-echos the $TERMINFO_DIRS directory list, e.g.,
-.RS
-@TERMINFO_DIRS@
-.RE
+\fB\-\-terminfo\-dirs\fP
+reports the \fI\%TERMINFO_DIRS\fP supplemental search path for the
+\fIterminfo\fP database,
+for example \fI\%@TERMINFO_DIRS@\fP.
 .TP
-\fB\-\-termpath\fR
-echos the $TERMPATH termcap list, if support for termcap is configured.
-.TP
-\fB\-\-help\fR
-prints this message
-.SH "SEE ALSO"
-\fBcurses\fR(3X)
+\fB\-\-termpath\fP
+reports the \fI\%TERMPATH\fP supplemental search path for the
+\fItermcap\fP database,
+if support for \fItermcap\fP is configured.
 .PP
-This describes \fBncurses\fR
-version @NCURSES_MAJOR@.@NCURSES_MINOR@ (patch @NCURSES_PATCH@).
+The following options cause all others to be ignored.
+.TP 11 .\" "--version" + 2n
+\fB\-\-help\fP
+issues a usage message and exits successfully.
+.TP
+\fB\-\-version\fP
+issues the release and patch date information of \fI\%ncurses\fP and
+exits successfully.
+.SH "SEE ALSO"
+\fB\%curses\fP(3X)
diff --git a/contrib/ncurses/man/MKterminfo.sh b/contrib/ncurses/man/MKterminfo.sh
index c79dbd8ff946..882ef2ad093b 100755
--- a/contrib/ncurses/man/MKterminfo.sh
+++ b/contrib/ncurses/man/MKterminfo.sh
@@ -1,10 +1,10 @@
 #!/bin/sh
-# $Id: MKterminfo.sh,v 1.18 2020/02/02 23:34:34 tom Exp $
+# $Id: MKterminfo.sh,v 1.20 2024/01/13 20:37:40 tom Exp $
 #
 # MKterminfo.sh -- generate terminfo.5 from Caps tabular data
 #
 #***************************************************************************
-# Copyright 2018-2019,2020 Thomas E. Dickey                                *
+# Copyright 2018-2020,2022 Thomas E. Dickey                                *
 # Copyright 1998-2003,2017 Free Software Foundation, Inc.                  *
 #                                                                          *
 # Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -50,7 +50,7 @@ if test "${LC_CTYPE+set}"    = set; then LC_CTYPE=C;    export LC_CTYPE;    fi
 if test "${LC_COLLATE+set}"  = set; then LC_COLLATE=C;  export LC_COLLATE;  fi
 
 #
-head=$1
+head="$1"
 shift 1
 caps=
 while test $# -gt 1
@@ -58,7 +58,7 @@ do
 	caps="$caps $1"
 	shift 1
 done
-tail=$1
+tail="$1"
 cat <<EOF
 '\\" t
 .\\" DO NOT EDIT THIS FILE BY HAND!
@@ -67,12 +67,12 @@ cat <<EOF
 .\\" Note: this must be run through tbl before nroff.
 .\\" The magic cookie on the first line triggers this under some man programs.
 EOF
-cat $head
+cat "$head"
 
 temp=temp$$
 sorted=sorted$$
 unsorted=unsorted$$
-trap "code=\$?; rm -f $sorted $temp $unsorted; exit \$code" EXIT HUP INT QUIT TERM
+trap 'code=$?; rm -f $sorted $temp $unsorted; exit $code' EXIT HUP INT QUIT TERM
 rm -f $sorted $temp $unsorted
 
 cat $caps | sed -n "\
@@ -83,7 +83,9 @@ cat $caps | sed -n "\
 /^#/d
 s/[	][	]*/	/g
 s/$/T}/
-s/	[A-Z0-9_()\-][A-Z0-9_()\-]*	[0-9\-][0-9\-]*	[Y\-][B\-][C\-][G\-][EK\-]\**	/	T{/
+s/	[A-Z0-9_()\-][A-Z0-9_()\-]*	[0-9\-][0-9\-]*	[Y\-][B\-][C\-][G\-][EK\-]\**	/	T{\\
+.ad l\
+/
 s/	bool	/	/p
 s/	num	/	/p
 s/	str	/	/p
@@ -118,4 +120,4 @@ sed -e 's/^\.\.$//' $sorted | tr "\005\006" "\012\134"
 
 sed	-e '/^center expand;/s, expand,,' \
 	-e '/^\.TS/,/^\\/s, lw[1-9][0-9]*\., l.,' \
-	$tail
+	"$tail"
diff --git a/contrib/ncurses/man/Makefile.in b/contrib/ncurses/man/Makefile.in
index f379db1224ed..9d08a7eed8ba 100644
--- a/contrib/ncurses/man/Makefile.in
+++ b/contrib/ncurses/man/Makefile.in
@@ -1,6 +1,6 @@
-# $Id: Makefile.in,v 1.50 2020/02/02 23:34:34 tom Exp $
+# $Id: Makefile.in,v 1.54 2022/10/22 16:36:40 tom Exp $
 ##############################################################################
-# Copyright 2019,2020 Thomas E. Dickey                                       #
+# Copyright 2019-2021,2022 Thomas E. Dickey                                  #
 # Copyright 1998-2013,2015 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -52,6 +52,21 @@ INCLUDEDIR	= $(DESTDIR)$(includedir)$(includesubdir)
 INSTALL		= @INSTALL@
 INSTALL_DATA	= @INSTALL_DATA@
 
+################################################################################
+
+@MAKE_PHONY@.PHONY :	all
+@MAKE_PHONY@.PHONY :	clean
+@MAKE_PHONY@.PHONY :	depend
+@MAKE_PHONY@.PHONY :	distclean
+@MAKE_PHONY@.PHONY :	install
+@MAKE_PHONY@.PHONY :	install.man
+@MAKE_PHONY@.PHONY :	libs
+@MAKE_PHONY@.PHONY :	mostlyclean
+@MAKE_PHONY@.PHONY :	realclean
+@MAKE_PHONY@.PHONY :	sources
+@MAKE_PHONY@.PHONY :	uninstall
+@MAKE_PHONY@.PHONY :	uninstall.man
+
 all \
 sources :	terminfo.5
 depend :
@@ -84,8 +99,8 @@ mostlyclean :
 clean:	mostlyclean
 	rm -f terminfo.5
 
-../edit_man.sed : make_sed.sh @MANPAGE_RENAMES@
+../edit_man.sed : make_sed.sh
 	$(SHELL) $(srcdir)/make_sed.sh @MANPAGE_RENAMES@ >../edit_man.sed
 
 distclean realclean: clean
-	rm -f Makefile *-config.1 ../edit_man.* ../man_alias.*
+	-rm -f Makefile *-config.1 ../edit_man.* ../man_alias.* man_db.renames
diff --git a/contrib/ncurses/man/captoinfo.1m b/contrib/ncurses/man/captoinfo.1m
index 4c46da67b348..4693b06b36e8 100644
--- a/contrib/ncurses/man/captoinfo.1m
+++ b/contrib/ncurses/man/captoinfo.1m
@@ -1,6 +1,6 @@
 '\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2016 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,64 +28,76 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: captoinfo.1m,v 1.30 2020/02/02 23:34:34 tom Exp $
-.TH @CAPTOINFO@ 1M ""
-.ds n 5
-.ds d @TERMINFO@
+.\" $Id: captoinfo.1m,v 1.63 2024/03/23 20:37:25 tom Exp $
+.TH @CAPTOINFO@ 1M 2024-03-23 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "User commands"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
 .SH NAME
-\fB@CAPTOINFO@\fR \- convert a \fItermcap\fR description into a \fIterminfo\fR description
+\fB\%@CAPTOINFO@\fP \-
+convert a \fItermcap\fP description into a \fI\%term\%info\fP description
 .SH SYNOPSIS
-\fB@CAPTOINFO@\fR [\fB\-v\fR\fIn\fR \fIwidth\fR]  [\fB\-V\fR] [\fB\-1\fR] [\fB\-w\fR \fIwidth\fR] \fIfile\fR ...
+.B @CAPTOINFO@
+.RI [ tic-option ]
+.RI [ file
+\&.\|.\|.]
+.P
+.B "@CAPTOINFO@ \-V"
 .SH DESCRIPTION
-\fB@CAPTOINFO@\fR looks in each given text
-\fIfile\fR for \fBtermcap\fR descriptions.
-For each
-one found, an equivalent \fBterminfo\fR description is written to standard
-output.
-Termcap \fBtc\fR capabilities are translated directly to terminfo
-\fBuse\fR capabilities.
+\fB\%@CAPTOINFO@\fP translates terminal descriptions.
+It looks in each given text \fIfile\fP for \fI\%termcap\fP entries and,
+for each one found,
+writes an equivalent \fI\%\%term\%info\fP description to the standard
+output stream.
+\fI\%termcap\fP \fBtc\fP capabilities translate to \fI\%\%term\%info\fP
+\*(``\fBuse\fP\*('' capabilities.
 .PP
-If no \fIfile\fR is given, then the environment variable \fBTERMCAP\fR is used
-for the filename or entry.
-If \fBTERMCAP\fR is a full pathname to a file, only
-the terminal whose name is specified in the environment variable \fBTERM\fR is
-extracted from that file.
-If the environment variable \fBTERMCAP\fR is not
-set, then the file \fB\*d\fR is read.
-.TP 5
-\fB\-v\fR
-print out tracing information on standard error as the program runs.
-.TP 5
-\fB\-V\fR
-print out the version of the program in use on standard error and exit.
-.TP 5
-\fB\-1\fR
-cause the fields to print out one to a line.
-Otherwise, the fields
-will be printed several to a line to a maximum width of 60
-characters.
-.TP 5
-\fB\-w\fR
-change the output to \fIwidth\fR characters.
-.SH FILES
-.TP 20
-\*d
-Compiled terminal description database.
-.SH TRANSLATIONS FROM NONSTANDARD CAPABILITIES
+If no \fIfile\fPs are specified,
+\fB\%@CAPTOINFO@\fP interprets the content of the environment variable
+\fI\%TERMCAP\fP as a file name,
+and extracts only the entry for the terminal named in the environment
+variable \fITERM\fP from it.
+If the environment variable \fI\%TERMCAP\fP is not set,
+\fB\%@CAPTOINFO@\fP reads
+.IR \%/etc/termcap .
 .PP
-Some obsolete nonstandard capabilities will automatically be translated
-into standard (SVr4/XSI Curses) terminfo capabilities by \fB@CAPTOINFO@\fR.
-Whenever one of these automatic translations is done, the program
-will issue an notification to stderr, inviting the user to check that
-it has not mistakenly translated a completely unknown and random
-capability and/or syntax error.
+This utility is implemented as a link to \fB\%@TIC@\fP(1M),
+with the latter's
+.B \-I
+option implied.
+You can use other \fB\%@TIC@\fP options such as
+.BR \-1 ,
+.BR \-f ,
+.BR \-v ,
+.BR \-w ,
+and
+.BR \-x .
+The \fB\-V\fP option reports the version of \fI\%ncurses\fP associated
+with this program and exits with a successful status.
+.SS "Translations from Nonstandard Capabilities"
+\fB\%@CAPTOINFO@\fP translates some obsolete,
+nonstandard capabilities into standard
+(SVr4/XSI Curses)
+\fI\%\%term\%info\fP capabilities.
+It issues a diagnostic to the standard error stream for each,
+inviting the user to check that it has not mistakenly translated an
+unknown or mistyped capability name.
 .PP
-.TS H
-c c c c
-c c c c
-l l l l.
-Nonstd	Std	From	Terminfo
-name	name		capability
+.\" DWB 3.3 tbl requires the two junk "L" specifiers in the first row.
+.TS
+center;
+Cb S  L  L
+Cb Cb Cb Cb
+Cb Cb C  Lb.
+Name
+Obsolete	Standard	Origin	\f(BIterminfo\fP capability
 _
 BO	mr	AT&T	enter_reverse_mode
 CI	vi	AT&T	cursor_invisible
@@ -106,64 +118,72 @@ PS	pf	XENIX	prtr_on
 PU	kP	XENIX	key_ppage
 RT	@8	XENIX	kent
 UP	ku	XENIX	kcuu1
-KA	k;	Tek	key_f10
-KB	F1	Tek	key_f11
-KC	F2	Tek	key_f12
-KD	F3	Tek	key_f13
-KE	F4	Tek	key_f14
-KF	F5	Tek	key_f15
-BC	Sb	Tek	set_background
-FC	Sf	Tek	set_foreground
-HS	mh	Iris	enter_dim_mode
+KA	k;	Tektronix	key_f10
+KB	F1	Tektronix	key_f11
+KC	F2	Tektronix	key_f12
+KD	F3	Tektronix	key_f13
+KE	F4	Tektronix	key_f14
+KF	F5	Tektronix	key_f15
+BC	Sb	Tektronix	set_background
+FC	Sf	Tektronix	set_foreground
+HS	mh	IRIX	enter_dim_mode
 .TE
 .PP
-XENIX termcap also used to have a set of extension capabilities
-for forms drawing, designed to take advantage of the IBM PC
-high-half graphics.
-They were as follows:
+XENIX \fI\%termcap\fP had a set of extension capabilities,
+corresponding to box drawing characters of CCSID
+(\*(``code page\*('') 437,
+as follows.
 .PP
-.TS H
-c c
-l l.
-Cap	Graphic
+.TS
+center;
+cb cb
+cb l .
+\f(BItermcap\fP Name	Graphic
 _
-G2	upper left
-G3	lower left
-G1	upper right
-G4	lower right
-GR	pointing right
-GL	pointing left
-GU	pointing up
-GD	pointing down
+G2	upper left corner
+G3	lower left corner
+G1	upper right corner
+G4	lower right corner
+GR	tee pointing right
+GL	tee pointing left
+GU	tee pointing up
+GD	tee pointing down
 GH	horizontal line
 GV	vertical line
 GC	intersection
-G6	upper left
-G7	lower left
-G5	upper right
-G8	lower right
-Gr	tee pointing right
-Gr	tee pointing left
-Gu	tee pointing up
-Gd	tee pointing down
-Gh	horizontal line
-Gv	vertical line
-Gc	intersection
-GG	acs magic cookie count
+G6	double upper left corner
+G7	double lower left corner
+G5	double upper right corner
+G8	double lower right corner
+Gr	double tee pointing right
+Gr	double tee pointing left
+Gu	double tee pointing up
+Gd	double tee pointing down
+Gh	double horizontal line
+Gv	double vertical line
+Gc	double intersection
+.\" TODO: There are about 40 box drawing code points in CCSID 437;
+.\" were there no XENIX capabilities for the mixed single- and double-
+.\" line intersections?
+.\"
+.\" TODO: GG doesn't seem to fit with the others; explain it.
+GG	ACS magic cookie count
 .TE
 .PP
-If the single-line capabilities occur in an entry, they will automatically
-be composed into an \fBacsc\fR string.
-The double-line capabilities and
-\fBGG\fR are discarded with a warning message.
+\fB\%@CAPTOINFO@\fP composes single-line capabilities into an \fBacsc\fP
+string,
+and discards \fBGG\fP and double-line capabilities with a warning
+diagnostic.
+.PP
+IBM's AIX has a \fI\%\%term\%info\fP facility descended from SVr1
+\fI\%\%term\%info\fP,
+but which is incompatible with the SVr4 format.
+\fB\%@CAPTOINFO@\fP translates the following AIX extensions.
 .PP
-IBM's AIX has a terminfo facility descended from SVr1 terminfo but incompatible
-with the SVr4 format.
-The following AIX extensions are automatically
-translated:
 .TS
-c c
-l l.
+center;
+cb cb
+l  l .
 IBM	XSI
 _
 ksel	kslt
@@ -174,34 +194,42 @@ font2	s2ds
 font3	s3ds
 .TE
 .PP
-Additionally, the AIX \fIbox1\fR capability will be automatically translated to
-an \fBacsc\fR string.
+Additionally,
+this program translates the AIX \fBbox1\fP capability to an \fBacsc\fP
+string.
 .PP
-Hewlett-Packard's terminfo library supports two nonstandard terminfo
-capabilities \fBmeml\fR (memory lock) and \fBmemu\fR (memory unlock).
-These will be discarded with a warning message.
-.SH NOTES
-This utility is actually a link to \fB@TIC@\fR(1M), running in \fI\-I\fR mode.
-You can use other \fB@TIC@\fR options such as \fB\-f\fR and  \fB\-x\fR.
-.PP
-The verbose option is not identical to SVr4's.
-Under SVr4, instead of following
-the \fB\-v\fR with a trace level n, you repeat it n times.
+The HP-UX \fI\%\%term\%info\fP library supports two nonstandard
+\fI\%\%term\%info\fP capabilities,
+\fBmeml\fP (memory lock) and \fBmemu\fP (memory unlock).
+\fB\%@CAPTOINFO@\fP discards these with a warning message.
+.SH FILES
+.TP
+.I /etc/termcap
+default \fI\%termcap\fP terminal capability database
 .SH PORTABILITY
-X/Open Curses, Issue 7 (2009) describes \fBtic\fP briefly,
+X/Open Curses,
+Issue 7 (2009) describes \fBtic\fP briefly,
 but omits this program.
-SVr4 systems provide \fBcaptoinfo\fP as a separate application from \fBtic\fP.
 .PP
-NetBSD does not provide this application.
-.SH SEE ALSO
-\fB@INFOCMP@\fR(1M),
-\fBcurses\fR(3X),
-\fBterminfo\fR(\*n)
+SVr4 systems provide \fB\%captoinfo\fP as a separate application from
+\fBtic\fP.
+Its
+.B \-v
+option does not accept a trace level argument
+.IR n ;
+repeat
+.B \-v
+.I n
+times instead.
 .PP
-This describes \fBncurses\fR
-version @NCURSES_MAJOR@.@NCURSES_MINOR@ (patch @NCURSES_PATCH@).
-.SH AUTHOR
+NetBSD does not provide this application.
+.SH AUTHORS
 Eric S. Raymond <esr@snark.thyrsus.com>
 and
 .br
-Thomas E. Dickey <dickey@invisible-island.net>
+Thomas E. Dickey <dickey@invisible\-island.net>
+.SH SEE ALSO
+\fB\%@INFOCMP@\fP(1M),
+\fB\%@TIC@\fP(1M),
+\fB\%curses\fP(3X),
+\fB\%terminfo\fP(5)
diff --git a/contrib/ncurses/man/clear.1 b/contrib/ncurses/man/clear.1
index a79bdf15bc1b..a1034db7cb1a 100644
--- a/contrib/ncurses/man/clear.1
+++ b/contrib/ncurses/man/clear.1
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,137 +27,160 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: clear.1,v 1.23 2020/02/02 23:34:34 tom Exp $
-.TH @CLEAR@ 1 ""
-.\" these would be fallbacks for DS/DE,
-.\" but groff changed the meaning of the macros.
-.de NS
-.ie n  .sp
-.el    .sp .5
-.ie n  .in +4
-.el    .in +2
-.nf
-.ft C			\" Courier
-..
-.de NE
-.fi
-.ft R
-.ie n  .in -4
-.el    .in -2
-..
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: clear.1,v 1.48 2024/03/16 15:35:01 tom Exp $
+.TH @CLEAR@ 1 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "User commands"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.ds '  \(aq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.ie t .ds '  \(aq
+.el   .ds '  '
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.ds n 5
+.
 .SH NAME
-\fB@CLEAR@\fR \- clear the terminal screen
+\fB\%@CLEAR@\fP \-
+clear the terminal screen
 .SH SYNOPSIS
-\fB@CLEAR@\fR [\fB\-T\fR\fItype\fR] [\fB\-V\fP] [\fB\-x\fP]
-.br
+.B @CLEAR@
+.RB [ \-x ]
+.RB [ \-T\ \c
+.IR terminal-type ]
+.PP
+.B "@CLEAR@ \-V"
 .SH DESCRIPTION
-\fB@CLEAR@\fR clears your screen if this is possible,
-including its scrollback buffer
-(if the extended \*(``E3\*('' capability is defined).
-\fB@CLEAR@\fR looks in the environment for the terminal type
-given by the environment variable \fBTERM\fP,
-and then in the
-\fBterminfo\fR database to determine how to clear the screen.
+\fB\%@CLEAR@\fP clears your terminal's screen and its scrollback buffer,
+if any.
+\fB\%@CLEAR@\fP retrieves the terminal type from the environment
+variable \fITERM\fP,
+then consults the \fIterminfo\fP terminal capability database entry for
+that type to determine how to perform these actions.
 .PP
-\fB@CLEAR@\fR writes to the standard output.
-You can redirect the standard output to a file (which prevents
-\fB@CLEAR@\fR from actually clearing the screen),
-and later \fBcat\fP the file to the screen, clearing it at that point.
+The capabilities to clear the screen and scrollback buffer are named
+\*(``clear\*('' and \*(``E3\*('', respectively.
+The latter is a \fIuser-defined capability\fP,
+applying an extension mechanism introduced in \fI\%ncurses\fP 5.0
+(1999).
 .SH OPTIONS
-.PP
-.TP 5
+\fB\%@CLEAR@\fP recognizes the following options.
+.TP 9 \" "-T type" + 2n
 .B \-T \fItype\fP
-indicates the \fItype\fR of terminal.
-Normally this option is
-unnecessary, because the default is taken from the environment
-variable \fBTERM\fR.
-If \fB\-T\fR is specified, then the shell
-variables \fBLINES\fR and \fBCOLUMNS\fR will also be ignored.
+produces instructions suitable for the terminal \fItype\fP.
+Normally,
+this option is unnecessary,
+because the terminal type is inferred from the environment variable
+\fITERM\fP.
+If this option is specified,
+\fB\%@CLEAR@\fP ignores the environment variables \fILINES\fP and
+\fI\%COLUMNS\fP as well.
 .TP
 .B \-V
-reports the version of ncurses which was used in this program, and exits.
-The options are as follows:
+reports the version of \fI\%ncurses\fP associated with this program and
+exits with a successful status.
 .TP
 .B \-x
-do not attempt to clear the terminal's scrollback buffer
-using the extended \*(``E3\*('' capability.
+prevents \fB\%@CLEAR@\fP from attempting to clear the scrollback buffer.
+.SH PORTABILITY
+Neither IEEE Std 1003.1/The Open Group Base Specifications Issue 7
+(POSIX.1-2008) nor X/Open Curses Issue 7 documents \fB\%@CLEAR@\fP.
+.PP
+The latter documents \fBtput\fP,
+which could be used to replace this utility either via a shell script or
+by an alias
+(such as a symbolic link)
+to run \fB\%@TPUT@\fP as \fB\%@CLEAR@\fP.
 .SH HISTORY
-A \fBclear\fP command appeared in 2.79BSD dated February 24, 1979.
-Later that was provided in Unix 8th edition (1985).
+A \fBclear\fP command using the \fItermcap\fP database and library
+appeared in 2BSD (1979).
+.\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=2BSD/src/clear.c
+Eighth Edition Unix (1985) later included it.
+.PP
+The commercial Unix arm of AT&T adapted a different BSD program
+(\fBtset\fP) to make a new command,
+\fBtput\fP,
+and replaced the \fBclear\fP program with a shell script that called
+\*(``\fBtput clear\fP\*(''.
 .PP
-AT&T adapted a different BSD program (\fBtset\fP) to make
-a new command (\fBtput\fP),
-and used this to replace the \fBclear\fP command with a shell script
-which calls \fBtput clear\fP, e.g.,
-.NS
-/usr/bin/tput ${1:+-T$1} clear 2> /dev/null
+.RS 4
+.EX
+/usr/bin/tput ${1:+\-T$1} clear 2> /dev/null
 exit
-.NE
+.EE
+.RE
 .PP
 In 1989, when Keith Bostic revised the BSD \fBtput\fP command
-to make it similar to the AT&T \fBtput\fP,
-he added a shell script for the \fBclear\fP command:
-.NS
+to make it similar to AT&T's \fBtput\fP,
+he added a \fBclear\fP shell script as well.
+.\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=Net2/usr/src/usr.bin/\
+.\"   tput/clear.sh
+.PP
+.RS 4
+.EX
 exec tput clear
-.NE
+.EE
+.RE
 .PP
 The remainder of the script in each case is a copyright notice.
 .PP
-The ncurses \fBclear\fP command began in 1995 by adapting the original
-BSD \fBclear\fP command (with terminfo, of course).
-.PP
-The \fBE3\fP extension came later:
+In 1995,
+\fI\%ncurses\fP's \fBclear\fP began by adapting BSD's original
+\fBclear\fP command to use \fIterminfo\fP.
+The \fBE3\fP extension came later.
 .bP
-In June 1999, xterm provided an extension to the standard control
+In June 1999, \fIxterm\fP provided an extension to the standard control
 sequence for clearing the screen.
 Rather than clearing just the visible part of the screen using
-.NS
-printf '\\033[2J'
-.NE
+.RS 8
+.PP
+.EX
+printf \*'\e033[2J\*'
+.EE
+.RE
 .IP
-one could clear the \fIscrollback\fP using
-.NS
-printf '\\033[\fB3\fPJ'
-.NE
+one could clear the scrollback buffer as well by using
+.RS 8
+.PP
+.EX
+printf \*'\e033[\fB3\fPJ\*'
+.EE
+.RE
 .IP
-This is documented in \fIXTerm Control Sequences\fP as a feature originating
-with xterm.
+instead.
+\*(``XTerm Control Sequences\fP\*('' documents this feature as
+originating with \fIxterm\fP.
 .bP
-A few other terminal developers adopted the feature, e.g., PuTTY in 2006.
+A few other terminal emulators adopted it,
+such as PuTTY in 2006.
 .bP
 In April 2011, a Red Hat developer submitted a patch to the Linux
 kernel, modifying its console driver to do the same thing.
-The Linux change, part of the 3.0 release, did not mention xterm,
-although it was cited in the Red Hat bug report (#683733)
-which led to the change.
+Documentation of this change,
+appearing in Linux 3.0,
+did not mention \fIxterm\fP,
+although that program was cited in the Red Hat bug report (#683733)
+motivating the feature.
 .bP
-Again, a few other terminal developers adopted the feature.
-But the
-next relevant step was a change to the \fBclear\fP program in 2013
-to incorporate this extension.
+Subsequently,
+more terminal developers adopted the feature.
+The next relevant step was to change the \fI\%ncurses\fP \fBclear\fP
+program in 2013 to incorporate this extension.
 .bP
-In 2013, the \fBE3\fP extension was overlooked in \fB@TPUT@\fP with
-the \*(``clear\*('' parameter.
-That was addressed in 2016 by reorganizing \fB@TPUT@\fP to share
-its logic with \fB@CLEAR@\fP and \fB@TSET@\fP.
-.SH PORTABILITY
-Neither IEEE Std 1003.1/The Open  Group  Base  Specifications  Issue  7
-(POSIX.1-2008) nor X/Open Curses Issue 7 documents @TSET@ or @RESET@.
-.PP
-The latter documents \fBtput\fP, which could be used to replace this utility
-either via a shell script or by an alias (such as a symbolic link) to
-run \fB@TPUT@\fP as \fB@CLEAR@\fP.
+In 2013,
+the \fBE3\fP capability was not exercised by
+\*(``\fB\%@TPUT@ clear\fP\*(''.
+That oversight was addressed in 2016 by reorganizing \fB\%@TPUT@\fP to
+share its logic with \fB\%@CLEAR@\fP and \fB\%@TSET@\fP.
 .SH SEE ALSO
-\fB@TPUT@\fR(1), \fBterminfo\fR(\*n)
-.PP
-This describes \fBncurses\fR
-version @NCURSES_MAJOR@.@NCURSES_MINOR@ (patch @NCURSES_PATCH@).
+\fB\%@TPUT@\fP(1),
+\fB\%xterm\fP(1),
+\fB\%terminfo\fP(5)
diff --git a/contrib/ncurses/man/curs_add_wch.3x b/contrib/ncurses/man/curs_add_wch.3x
index 446020839cd1..d1eb9a311fc8 100644
--- a/contrib/ncurses/man/curs_add_wch.3x
+++ b/contrib/ncurses/man/curs_add_wch.3x
@@ -1,5 +1,6 @@
+'\" t
 .\"***************************************************************************
-.\" Copyright 2019,2020 Thomas E. Dickey                                     *
+.\" Copyright 2019-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 2001-2015,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,42 +28,45 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_add_wch.3x,v 1.28 2020/10/17 23:10:38 tom Exp $
-.TH curs_add_wch 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: curs_add_wch.3x,v 1.62 2024/04/20 21:20:07 tom Exp $
+.TH curs_add_wch 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
 .SH NAME
-\fBadd_wch\fP,
-\fBwadd_wch\fP,
-\fBmvadd_wch\fP,
-\fBmvwadd_wch\fP,
-\fBecho_wchar\fP,
-\fBwecho_wchar\fP \- add a complex character and rendition to a \fBcurses\fR window, then advance the cursor
+\fB\%add_wch\fP,
+\fB\%wadd_wch\fP,
+\fB\%mvadd_wch\fP,
+\fB\%mvwadd_wch\fP,
+\fB\%echo_wchar\fP,
+\fB\%wecho_wchar\fP \-
+add a \fIcurses\fR complex character to a window and advance the cursor
 .SH SYNOPSIS
+.nf
+\fB#include <curses.h>
 .PP
-\fB#include <curses.h>\fP
-.sp
-.B "int add_wch( const cchar_t *\fIwch\fB );"
-.br
-.B "int wadd_wch( WINDOW *\fIwin\fP, const cchar_t *\fIwch\fB );"
-.br
-.B "int mvadd_wch( int \fIy\fP, int \fIx\fP, const cchar_t *\fIwch\fB );"
-.br
-.B "int mvwadd_wch( WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, const cchar_t *\fIwch\fB );"
-.sp
-.B "int echo_wchar( const cchar_t *\fIwch\fB );"
-.br
-.B "int wecho_wchar( WINDOW *\fIwin\fP, const cchar_t *\fIwch\fB );"
-.br
+\fBint add_wch(const cchar_t *\fIwch\fP);
+\fBint wadd_wch(WINDOW *\fIwin\fP, const cchar_t *\fIwch\fP);
+\fBint mvadd_wch(int \fIy\fP, int \fIx\fP, const cchar_t *\fIwch\fP);
+\fBint mvwadd_wch(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, const cchar_t *\fIwch\fP);
+.PP
+\fBint echo_wchar(const cchar_t *\fIwch\fP);
+\fBint wecho_wchar(WINDOW *\fIwin\fP, const cchar_t *\fIwch\fP);
+.fi
 .SH DESCRIPTION
 .SS add_wch
-.PP
 The
 \fBadd_wch\fP,
 \fBwadd_wch\fP,
@@ -78,25 +82,31 @@ If \fIwch\fP refers to a spacing character,
 then any previous character at that location is removed.
 A new character specified by \fIwch\fP is
 placed at that location with rendition specified by \fIwch\fP.
-The cursor then advances to
-the next spacing character on the screen.
+The cursor then advances after this spacing character,
+to prepare for writing the next character on the screen.
+.IP
+The newly added spacing character is the base of the active complex character.
+Subsequent non-spacing characters can be combined with this base
+until another spacing character is written to the screen,
+or the cursor is moved, e.g., using \fBwmove\fP.
 .bP
 If \fIwch\fP refers to a non-spacing character,
-all previous characters at that location are preserved.
-The non-spacing characters of \fIwch\fP
-are added to the spacing complex character,
-and the rendition specified by \fIwch\fP is ignored.
+it is appended to the active complex character,
+retaining the previous characters at that location.
+The rendition specified by \fIwch\fP is ignored.
+.IP
+The cursor is not advanced after adding a non-spacing character.
+Subsequent calls to add non-spacing characters will update the same position.
 .bP
 If the character part of \fIwch\fP is
 a tab, newline, backspace or other control character,
-the window is updated and the cursor moves as if \fBaddch\fR were called.
+the window is updated and the cursor moves as if \fBaddch\fP were called.
 .SS echo_wchar
-.PP
 The \fBecho_wchar\fP
 function is functionally equivalent to a call to
 \fBadd_wch\fP
 followed by a call to
-\fBrefresh\fP(3X).
+\fB\%refresh\fP(3X).
 Similarly, the
 \fBwecho_wchar\fP
 is functionally equivalent to a call to
@@ -107,99 +117,171 @@ The knowledge
 that only a single character is being output is taken into consideration and,
 for non-control characters, a considerable performance gain might be seen
 by using the *\fBecho\fP* functions instead of their equivalents.
-.SS Line Graphics
-Like \fBaddch\fP(3X),
+.SS "Line Graphics"
+Like \fB\%addch\fP(3X),
 \fBaddch_wch\fP accepts symbols which make it simple to draw lines and other
 frequently used special characters.
 These symbols correspond to the same VT100 line-drawing set as
-\fBaddch\fP(3X).
+\fB\%addch\fP(3X).
 .PP
 .TS
-l l l l l
-l l l l l
-_ _ _ _ _
-lw(1.5i) lw5 lw5 lw5 lw20.
-\fBACS\fR	\fBUnicode\fP	\fBASCII\fR	\fBacsc\fP	\fBGlyph\fR
-\fBName\fR	\fBDefault\fP	\fBDefault\fR	\fBchar\fP	\fBName\fR
-WACS_BLOCK	0x25ae 	#	0	solid square block
-WACS_BOARD	0x2592 	#	h	board of squares
-WACS_BTEE	0x2534 	+	v	bottom tee
-WACS_BULLET	0x00b7 	o	~	bullet
-WACS_CKBOARD	0x2592 	:	a	checker board (stipple)
-WACS_DARROW	0x2193 	v	.	arrow pointing down
-WACS_DEGREE	0x00b0 	'	f	degree symbol
-WACS_DIAMOND	0x25c6 	+	`	diamond
-WACS_GEQUAL	0x2265 	>	>	greater-than-or-equal-to
-WACS_HLINE	0x2500 	\-	q	horizontal line
-WACS_LANTERN	0x2603 	#	i	lantern symbol
-WACS_LARROW	0x2190 	<	,	arrow pointing left
-WACS_LEQUAL	0x2264 	<	y	less-than-or-equal-to
-WACS_LLCORNER	0x2514 	+	m	lower left-hand corner
-WACS_LRCORNER	0x2518 	+	j	lower right-hand corner
-WACS_LTEE	0x2524 	+	t	left tee
-WACS_NEQUAL	0x2260 	!	|	not-equal
-WACS_PI	0x03c0 	*	{	greek pi
-WACS_PLMINUS	0x00b1 	#	g	plus/minus
-WACS_PLUS	0x253c 	+	n	plus
-WACS_RARROW	0x2192 	>	+	arrow pointing right
-WACS_RTEE	0x251c 	+	u	right tee
-WACS_S1	0x23ba 	\-	o	scan line 1
-WACS_S3	0x23bb 	\-	p	scan line 3
-WACS_S7	0x23bc 	\-	r	scan line 7
-WACS_S9	0x23bd 	\&_	s	scan line 9
-WACS_STERLING	0x00a3 	f	}	pound-sterling symbol
-WACS_TTEE	0x252c 	+	w	top tee
-WACS_UARROW	0x2191  	^	\-	arrow pointing up
-WACS_ULCORNER	0x250c 	+	l	upper left-hand corner
-WACS_URCORNER	0x2510 	+	k	upper right-hand corner
-WACS_VLINE	0x2502 	|	x	vertical line
+Lb Lb Lb Lb Lb
+Lb Lb Lb Lb Lb
+Lb L  L  L  Lx.
+\&	Unicode	ASCII	acsc	\&
+ACS Name	Default	Default	Char	Glyph Name
+_
+WACS_BLOCK	0x25ae	#	0	T{
+solid square block
+T}
+WACS_BOARD	0x2592	#	h	board of squares
+WACS_BTEE	0x2534	+	v	bottom tee
+WACS_BULLET	0x00b7	o	~	bullet
+WACS_CKBOARD	0x2592	:	a	T{
+checker board (stipple)
+T}
+WACS_DARROW	0x2193	v	.	T{
+arrow pointing down
+T}
+WACS_DEGREE	0x00b0	'	f	degree symbol
+WACS_DIAMOND	0x25c6	+	\(ga	diamond
+WACS_GEQUAL	0x2265	>	>	T{
+greater-than-or-equal-to
+T}
+WACS_HLINE	0x2500	\-	q	horizontal line
+WACS_LANTERN	0x2603	#	i	lantern symbol
+WACS_LARROW	0x2190	<	,	T{
+arrow pointing left
+T}
+WACS_LEQUAL	0x2264	<	y	T{
+less-than-or-equal-to
+T}
+WACS_LLCORNER	0x2514	+	m	T{
+lower left-hand corner
+T}
+WACS_LRCORNER	0x2518	+	j	T{
+lower right-hand corner
+T}
+WACS_LTEE	0x2524	+	t	left tee
+WACS_NEQUAL	0x2260	!	|	not-equal
+WACS_PI	0x03c0	*	{	greek pi
+WACS_PLMINUS	0x00b1	#	g	plus/minus
+WACS_PLUS	0x253c	+	n	plus
+WACS_RARROW	0x2192	>	+	T{
+arrow pointing right
+T}
+WACS_RTEE	0x251c	+	u	right tee
+WACS_S1	0x23ba	\-	o	scan line 1
+WACS_S3	0x23bb	\-	p	scan line 3
+WACS_S7	0x23bc	\-	r	scan line 7
+WACS_S9	0x23bd	\&_	s	scan line 9
+WACS_STERLING	0x00a3	f	}	T{
+pound-sterling symbol
+T}
+WACS_TTEE	0x252c	+	w	top tee
+WACS_UARROW	0x2191 	^	\-	T{
+arrow pointing up
+T}
+WACS_ULCORNER	0x250c	+	l	T{
+upper left-hand corner
+T}
+WACS_URCORNER	0x2510	+	k	T{
+upper right-hand corner
+T}
+WACS_VLINE	0x2502	|	x	vertical line
 .TE
 .PP
-The wide-character configuration of ncurses also defines symbols
+The wide-character configuration of \fI\%ncurses\fP also defines symbols
 for thick lines (\fBacsc\fP \*(``J\*('' to \*(``V\*(''):
+.PP
 .TS
-l l l l l
-l l l l l
-_ _ _ _ _
-lw(1.5i) lw5 lw5 lw5 lw20.
-\fBACS\fR	\fBUnicode\fP	\fBASCII\fR	\fBacsc\fP	\fBGlyph\fR
-\fBName\fR	\fBDefault\fP	\fBDefault\fR	\fBchar\fP	\fBName\fR
-WACS_T_BTEE	0x253b	+	V	thick tee pointing up
-WACS_T_HLINE	0x2501	-	Q	thick horizontal line
-WACS_T_LLCORNER	0x2517	+	M	thick lower left corner
-WACS_T_LRCORNER	0x251b	+	J	thick lower right corner
-WACS_T_LTEE	0x252b	+	T	thick tee pointing right
-WACS_T_PLUS	0x254b	+	N	thick large plus
-WACS_T_RTEE	0x2523	+	U	thick tee pointing left
-WACS_T_TTEE	0x2533	+	W	thick tee pointing down
-WACS_T_ULCORNER	0x250f	+	L	thick upper left corner
-WACS_T_URCORNER	0x2513	+	K	thick upper right corner
-WACS_T_VLINE	0x2503	|	X	thick vertical line
+Lb Lb Lb Lb Lb
+Lb Lb Lb Lb Lb
+Lb L  L  L  Lx.
+\&	Unicode	ASCII	acsc	\&
+ACS Name	Default	Default	Char	Glyph Name
+_
+WACS_T_BTEE	0x253b	+	V	T{
+thick tee pointing up
+T}
+WACS_T_HLINE	0x2501	-	Q	T{
+thick horizontal line
+T}
+WACS_T_LLCORNER	0x2517	+	M	T{
+thick lower left corner
+T}
+WACS_T_LRCORNER	0x251b	+	J	T{
+thick lower right corner
+T}
+WACS_T_LTEE	0x252b	+	T	T{
+thick tee pointing right
+T}
+WACS_T_PLUS	0x254b	+	N	T{
+thick large plus
+T}
+WACS_T_RTEE	0x2523	+	U	T{
+thick tee pointing left
+T}
+WACS_T_TTEE	0x2533	+	W	T{
+thick tee pointing down
+T}
+WACS_T_ULCORNER	0x250f	+	L	T{
+thick upper left corner
+T}
+WACS_T_URCORNER	0x2513	+	K	T{
+thick upper right corner
+T}
+WACS_T_VLINE	0x2503	|	X	T{
+thick vertical line
+T}
 .TE
 .PP
 and for double-lines (\fBacsc\fP \*(``A\*('' to \*(``I\*(''):
 .PP
 .TS
-l l l l l
-l l l l l
-_ _ _ _ _
-lw(1.5i) lw5 lw5 lw5 lw20.
-\fBACS\fR	\fBUnicode\fP	\fBASCII\fR	\fBacsc\fP	\fBGlyph\fR
-\fBName\fR	\fBDefault\fP	\fBDefault\fR	\fBchar\fP	\fBName\fR
-WACS_D_BTEE	0x2569	+	H	double tee pointing up
-WACS_D_HLINE	0x2550	-	R	double horizontal line
-WACS_D_LLCORNER	0x255a	+	D	double lower left corner
-WACS_D_LRCORNER	0x255d	+	A	double lower right corner
-WACS_D_LTEE	0x2560	+	F	double tee pointing right
-WACS_D_PLUS	0x256c	+	E	double large plus
-WACS_D_RTEE	0x2563	+	G	double tee pointing left
-WACS_D_TTEE	0x2566	+	I	double tee pointing down
-WACS_D_ULCORNER	0x2554	+	C	double upper left corner
-WACS_D_URCORNER	0x2557	+	B	double upper right corner
-WACS_D_VLINE	0x2551	|	Y	double vertical line
+Lb Lb Lb Lb Lb
+Lb Lb Lb Lb Lb
+Lb L  L  L  Lx.
+\&	Unicode	ASCII	acsc	\&
+ACS Name	Default	Default	Char	Glyph Name
+_
+WACS_D_BTEE	0x2569	+	H	T{
+double tee pointing up
+T}
+WACS_D_HLINE	0x2550	-	R	T{
+double horizontal line
+T}
+WACS_D_LLCORNER	0x255a	+	D	T{
+double lower left corner
+T}
+WACS_D_LRCORNER	0x255d	+	A	T{
+double lower right corner
+T}
+WACS_D_LTEE	0x2560	+	F	T{
+double tee pointing right
+T}
+WACS_D_PLUS	0x256c	+	E	T{
+double large plus
+T}
+WACS_D_RTEE	0x2563	+	G	T{
+double tee pointing left
+T}
+WACS_D_TTEE	0x2566	+	I	T{
+double tee pointing down
+T}
+WACS_D_ULCORNER	0x2554	+	C	T{
+double upper left corner
+T}
+WACS_D_URCORNER	0x2557	+	B	T{
+double upper right corner
+T}
+WACS_D_VLINE	0x2551	|	Y	T{
+double vertical line
+T}
 .TE
 .PP
-Unicode's descriptions for these characters differs slightly from ncurses,
+Unicode's descriptions for these characters differs slightly from
+\fI\%ncurses\fP,
 by introducing the term \*(``light\*('' (along with less important details).
 Here are its descriptions for the normal, thick, and double horizontal lines:
 .bP
@@ -209,10 +291,9 @@ U+2501 BOX DRAWINGS HEAVY HORIZONTAL
 .bP
 U+2550 BOX DRAWINGS DOUBLE HORIZONTAL
 .SH RETURN VALUE
+All routines return the integer \fBERR\fP upon failure and \fBOK\fP on success.
 .PP
-All routines return the integer \fBERR\fR upon failure and \fBOK\fR on success.
-.PP
-X/Open does not define any error conditions.
+X/Open Curses does not specify any error conditions.
 This implementation returns an error
 .bP
 if the window pointer is null or
@@ -221,21 +302,22 @@ if it is not possible to add a complete character in the window.
 .PP
 The latter may be due to different causes:
 .bP
-If \fBscrollok\fR is not enabled,
+If \fB\%scrollok\fP(3X) is not enabled,
 writing a character at the lower right margin succeeds.
-However, an error is returned because
-it is not possible to wrap to a new line
+However,
+an error is returned because it is not possible to wrap to a new line.
 .bP
 If an error is detected when converting a multibyte character to a sequence
 of bytes,
 or if it is not possible to add all of the resulting bytes in the window,
 an error is returned.
 .PP
-Functions with a \*(``mv\*('' prefix first perform a cursor movement using
-\fBwmove\fP, and return an error if the position is outside the window,
-or if the window pointer is null.
+Functions prefixed with \*(``mv\*('' first perform cursor movement and
+fail if the position
+.RI ( y ,
+.IR x )
+is outside the window boundaries.
 .SH NOTES
-.PP
 Note that
 \fBadd_wch\fP,
 \fBmvadd_wch\fP,
@@ -243,23 +325,22 @@ Note that
 \fBecho_wchar\fP
 may be macros.
 .SH PORTABILITY
-.PP
-All of these functions are described in the XSI Curses standard, Issue 4.
+These functions are described in X/Open Curses, Issue 4.
 The defaults specified for line-drawing characters apply in the POSIX locale.
-.PP
+.SS "WACS Symbols"
 X/Open Curses makes it clear that the WACS_ symbols should be defined as
-a pointer to \fBcchar_t\fP data, e.g., in the discussion of \fBborder_set\fR.
+a pointer to \fBcchar_t\fP data, e.g., in the discussion of \fBborder_set\fP.
 A few implementations are problematic:
 .bP
 NetBSD curses defines the symbols as a \fBwchar_t\fP within a \fBcchar_t\fP.
 .bP
-HPUX curses equates some of the \fIACS_\fP symbols
-to the analogous \fIWACS_\fP symbols as if the \fIACS_\fP symbols were
+HP-UX curses equates some of the \fBACS_\fP symbols
+to the analogous \fBWACS_\fP symbols as if the \fBACS_\fP symbols were
 wide characters.
 The misdefined symbols are the arrows
 and other symbols which are not used for line-drawing.
 .PP
-X/Open Curses does not define symbols for thick- or double-lines.
+X/Open Curses does not specify symbols for thick- or double-lines.
 SVr4 curses implementations defined their line-drawing symbols in
 terms of intermediate symbols.
 This implementation extends those symbols, providing new definitions
@@ -270,18 +351,20 @@ alternate character sets (i.e., the \fBacsc\fP capability),
 with their corresponding line-drawing characters.
 X/Open Curses did not address the aspect of integrating Unicode with
 line-drawing characters.
-Existing implementations of Unix curses (AIX, HPUX, Solaris)
+Existing implementations of Unix curses (AIX, HP-UX, Solaris)
 use only the \fBacsc\fP character-mapping to provide this feature.
 As a result, those implementations can only use single-byte line-drawing
 characters.
-Ncurses 5.3 (2002) provided a table of Unicode values to solve these problems.
+\fI\%ncurses\fP 5.3 (2002) provided a table of Unicode values to solve
+these problems.
 NetBSD curses incorporated that table in 2010.
 .PP
 In this implementation, the Unicode values are used instead of the
-terminal description's \fBacsc\fP mapping as discussed in ncurses(3X)
-for the environment variable \fBNCURSES_NO_UTF8_ACS\fP.
+terminal description's \fBacsc\fP mapping as discussed in
+\fB\%ncurses\fP(3X) for the environment variable
+\fINCURSES_NO_UTF8_ACS\fP.
 In contrast, for the same cases, the line-drawing characters
-described in \fBcurs_addch\fP(3X) will use only the ASCII default values.
+described in \fB\%addch\fP(3X) will use only the ASCII default values.
 .PP
 Having Unicode available does not solve all of the problems with
 line-drawing for curses:
@@ -322,13 +405,45 @@ Others have suggested these alternatives:
 \[u2327] U+2327 (x in a rectangle),
 \[u256C] U+256C (forms double vertical and horizontal), and
 \[u2612] U+2612 (ballot box with x).
+.SS "Complex Characters"
+The complex character type \fBcchar_t\fR
+can store more than one wide character (\fBwchar_t\fR).
+The X/Open Curses description does not mention this possibility,
+describing only the cases where \fIwch\fP is a spacing character
+or a non-spacing character.
+.PP
+This implementation assumes that \fIwch\fP is constructed using
+\fB\%setcchar\fP(3X), and in turn that the result
+.bP
+contains at most one spacing character in the beginning of its list of wide
+characters,
+and zero or more non-spacing characters
+or
+.bP
+may hold one non-spacing character.
+.PP
+In the latter case,
+\fI\%ncurses\fP adds the non-spacing character to the active
+(base) spacing character.
+.SS TABSIZE
+The
+.B TABSIZE
+variable is implemented in SVr4 and other versions of
+.IR curses ,
+but is not specified by X/Open Curses
+(see \fBcurs_variables\fP(3X)).
 .SH SEE ALSO
-.na
+\fB\%curs_addch\fP(3X) describes comparable functions of the
+.I \%ncurses
+library in its non-wide-character configuration.
 .PP
-\fBcurses\fR(3X),
-\fBcurs_addch\fR(3X),
-\fBcurs_attr\fR(3X),
-\fBcurs_clear\fR(3X),
-\fBcurs_outopts\fR(3X),
-\fBcurs_refresh\fR(3X),
-\fBputwc\fR(3)
+\fB\%curses\fP(3X),
+\fB\%curs_addwstr\fP(3X),
+\fB\%curs_add_wchstr\fP(3X),
+\fB\%curs_attr\fP(3X),
+\fB\%curs_clear\fP(3X),
+\fB\%curs_getcchar\fP(3X),
+\fB\%curs_outopts\fP(3X),
+\fB\%curs_refresh\fP(3X),
+\fB\%curs_variables\fP(3X),
+\fB\%putwc\fP(3)
diff --git a/contrib/ncurses/man/curs_add_wchstr.3x b/contrib/ncurses/man/curs_add_wchstr.3x
index c037be632ebe..5dd3e8f4e131 100644
--- a/contrib/ncurses/man/curs_add_wchstr.3x
+++ b/contrib/ncurses/man/curs_add_wchstr.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2019,2020 Thomas E. Dickey                                     *
+.\" Copyright 2019-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 2002-2012,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,62 +27,61 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_add_wchstr.3x,v 1.15 2020/12/19 21:39:06 tom Exp $
-.TH curs_add_wchstr 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: curs_add_wchstr.3x,v 1.39 2024/04/20 21:20:07 tom Exp $
+.TH curs_add_wchstr 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.na
-.hy 0
 .SH NAME
-\fBadd_wchstr\fR,
-\fBadd_wchnstr\fR,
-\fBwadd_wchstr\fR,
-\fBwadd_wchnstr\fR,
-\fBmvadd_wchstr\fR,
-\fBmvadd_wchnstr\fR,
-\fBmvwadd_wchstr\fR,
-\fBmvwadd_wchnstr\fR \- add an array of complex characters (and attributes) to a curses window
-.ad
-.hy
+\fB\%add_wchstr\fP,
+\fB\%add_wchnstr\fP,
+\fB\%wadd_wchstr\fP,
+\fB\%wadd_wchnstr\fP,
+\fB\%mvadd_wchstr\fP,
+\fB\%mvadd_wchnstr\fP,
+\fB\%mvwadd_wchstr\fP,
+\fB\%mvwadd_wchnstr\fP \-
+add a \fIcurses\fR complex character string to a window
 .SH SYNOPSIS
 .nf
-\fB#include <curses.h>\fR
+\fB#include <curses.h>
 .PP
-\fBint add_wchstr(const cchar_t *\fR\fIwchstr\fR\fB);\fR
-.br
-\fBint add_wchnstr(const cchar_t *\fR\fIwchstr\fR\fB, int \fR\fIn\fR\fB);\fR
-.br
-\fBint wadd_wchstr(WINDOW *\fR \fIwin\fR\fB, const cchar_t *\fR\fIwchstr\fR\fB);\fR
-.br
-\fBint wadd_wchnstr(WINDOW *\fR \fIwin\fR\fB, const cchar_t *\fR\fIwchstr\fR\fB, int \fR\fIn\fR\fB);\fR
-.sp
-\fBint mvadd_wchstr(int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, const cchar_t *\fR\fIwchstr\fR\fB);\fR
-.br
-\fBint mvadd_wchnstr(int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, const cchar_t *\fR\fIwchstr\fR\fB, int \fR\fIn\fR\fB);\fR
-.br
-\fBint mvwadd_wchstr(WINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, const cchar_t *\fR\fIwchstr\fR\fB);\fR
-.br
-\fBint mvwadd_wchnstr(WINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, const cchar_t *\fR\fIwchstr\fR\fB, int \fR\fIn\fR\fB);\fR
+\fBint add_wchstr(const cchar_t *\fIwchstr\fP);
+\fBint wadd_wchstr(WINDOW * \fIwin\fP, const cchar_t *\fIwchstr\fP);
+\fBint mvadd_wchstr(int \fIy\fP, int \fIx\fP, const cchar_t *\fIwchstr\fP);
+\fBint mvwadd_wchstr(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, const cchar_t *\fIwchstr\fP);
+.PP
+\fBint add_wchnstr(const cchar_t *\fIwchstr\fP, int \fIn\fP);
+\fBint wadd_wchnstr(WINDOW * \fIwin\fP, const cchar_t *\fIwchstr\fP, int \fIn\fP);
+\fBint mvadd_wchnstr(int \fIy\fP, int \fIx\fP, const cchar_t *\fIwchstr\fP, int \fIn\fP);
+\fBint mvwadd_wchnstr(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, const cchar_t *\fIwchstr\fP, int \fIn\fP);
 .fi
 .SH DESCRIPTION
 These functions copy the (null-terminated)
-array of complex characters \fIwchstr\fR
+array of complex characters \fIwchstr\fP
 into the window image structure
 starting at the current cursor position.
-The four functions with \fIn\fR as the last
-argument copy at most \fIn\fR elements,
+.PP
+The four functions with \fIn\fP as the last
+argument copy at most \fIn\fP elements,
 but no more than will fit on the line.
-If \fBn\fR=\fB\-1\fR then the whole array is copied,
+If \fBn\fP=\fB\-1\fP then the whole array is copied,
 to the maximum number of characters that will fit on the line.
 .PP
-The window cursor is \fInot\fR advanced.
-These functions work faster than \fBwaddnstr\fR.
+The window cursor is \fInot\fP advanced.
+These functions are faster than \fBwaddnstr\fP.
 On the other hand:
 .bP
 they do not perform checking
@@ -96,28 +95,34 @@ they truncate the string if it crosses the right margin,
 rather than wrapping it around to the new line.
 .PP
 These functions end successfully
-on encountering a null \fIcchar_t\fR, or
+on encountering a null \fBcchar_t\fP, or
 when they have filled the current line.
 If a complex character cannot completely fit at the end of the current line,
 the remaining columns are filled with the background character and rendition.
 .SH RETURN VALUE
-All functions return the integer \fBERR\fR upon failure and \fBOK\fR on success.
+All functions return the integer \fBERR\fP upon failure and \fBOK\fP on success.
 .PP
-X/Open does not define any error conditions.
+X/Open Curses does not specify any error conditions.
 This implementation returns an error
-if the window pointer is null.
+.bP
+if the \fIwin\fP parameter is null or
+.bP
+if the \fIwchstr\fP parameter is null.
 .PP
-Functions with a \*(``mv\*('' prefix first perform a cursor movement using
-\fBwmove\fP, and return an error if the position is outside the window,
-or if the window pointer is null.
+Functions prefixed with \*(``mv\*('' first perform cursor movement and
+fail if the position
+.RI ( y ,
+.IR x )
+is outside the window boundaries.
 .SH NOTES
-All functions except \fBwadd_wchnstr\fR may be macros.
+All functions except \fBwadd_wchnstr\fP may be macros.
 .SH PORTABILITY
-These entry points are described in the XSI Curses standard, Issue 4.
+These functions are described in X/Open Curses, Issue 4.
 .SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_addwstr\fR(3X).
+\fB\%curs_addchstr\fP(3X) describes comparable functions of the
+.I \%ncurses
+library in its non-wide-character configuration.
 .PP
-Comparable functions in the narrow-character (ncurses) library are
-described in
-\fBcurs_addchstr\fR(3X).
+\fB\%curses\fP(3X),
+\fB\%curs_addwstr\fP(3X),
+\fB\%curs_add_wch\fP(3X)
diff --git a/contrib/ncurses/man/curs_addch.3x b/contrib/ncurses/man/curs_addch.3x
index 338a6e27855f..ad548520ce84 100644
--- a/contrib/ncurses/man/curs_addch.3x
+++ b/contrib/ncurses/man/curs_addch.3x
@@ -1,6 +1,6 @@
 '\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2015,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,120 +28,176 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_addch.3x,v 1.55 2020/10/24 09:12:31 tom Exp $
-.TH curs_addch 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: curs_addch.3x,v 1.85 2024/04/20 19:03:47 tom Exp $
+.TH curs_addch 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.ds '  \(aq
+.ds ^  \(ha
+.ds ~  \(ti
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.ds       '  '
+.ds       ^  ^
+.ds       ~  ~
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
 .SH NAME
-\fBaddch\fR,
-\fBwaddch\fR,
-\fBmvaddch\fR,
-\fBmvwaddch\fR,
-\fBechochar\fR,
-\fBwechochar\fR \- add a character (with attributes) to a \fBcurses\fR window, then advance the cursor
+\fB\%addch\fP,
+\fB\%waddch\fP,
+\fB\%mvaddch\fP,
+\fB\%mvwaddch\fP,
+\fB\%echochar\fP,
+\fB\%wechochar\fP \-
+add a \fIcurses\fP character to a window and advance the cursor
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
+.nf
+\fB#include <curses.h>
 .PP
-\fBint addch(const chtype \fP\fIch\fP\fB);\fR
-.br
-\fBint waddch(WINDOW *\fP\fIwin\fP\fB, const chtype \fP\fIch\fP\fB);\fR
-.br
-\fBint mvaddch(int \fP\fIy\fP\fB, int \fP\fIx\fP\fB, const chtype \fP\fIch\fP\fB);\fR
-.br
-\fBint mvwaddch(WINDOW *\fP\fIwin\fP\fB, int \fP\fIy\fP\fB, int \fP\fIx\fP\fB, const chtype \fP\fIch\fP\fB);\fR
-.sp
-\fBint echochar(const chtype \fP\fIch\fP\fB);\fR
-.br
-\fBint wechochar(WINDOW *\fP\fIwin\fP\fB, const chtype \fP\fIch\fP\fB);\fR
-.br
+\fBint addch(const chtype \fIch\fP);
+\fBint waddch(WINDOW *\fIwin\fP, const chtype \fIch\fP);
+\fBint mvaddch(int \fIy\fP, int \fIx\fP, const chtype \fIch\fP);
+\fBint mvwaddch(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, const chtype \fIch\fP);
+.PP
+\fBint echochar(const chtype \fIch\fP);
+\fBint wechochar(WINDOW *\fIwin\fP, const chtype \fIch\fP);
+.fi
 .SH DESCRIPTION
-.SS Adding characters
-The \fBaddch\fR, \fBwaddch\fR, \fBmvaddch\fR and \fBmvwaddch\fR routines put
-the character \fIch\fR into the given window at its current window position,
-which is then advanced.
-They are analogous to \fBputchar\fR(3) in \fBstdio\fR(3).
-If the advance is at the right margin:
-.bP
-The cursor automatically wraps to the beginning of the next line.
+.SS "Adding Characters"
+.B \%waddch
+puts the character
+.I ch
+at the cursor position of window
+.IR win ,
+then advances the cursor position,
+analogously to the standard C library's \fI\%putchar\fP(3).
+\fB\%ncurses\fP(3X) describes the variants of this function.
+.PP
+If advancement occurs at the right margin,
 .bP
-At the bottom of the current scrolling region,
-and if \fBscrollok\fR is enabled,
-the scrolling region is scrolled up one line.
+the cursor automatically wraps to the beginning of the next line;
+and
 .bP
-If \fBscrollok\fR is not enabled,
-writing a character at the lower right margin succeeds.
-However, an error is returned because
-it is not possible to wrap to a new line
+at the bottom of the current scrolling region,
+and if \fB\%scrollok\fP(3X) is enabled for
+.IR win ,
+the scrolling region scrolls up one line.
 .PP
-If \fIch\fR is a tab, newline, carriage return or backspace,
-the cursor is moved appropriately within the window:
+If
+.I ch
+is a
+backspace,
+carriage return,
+line feed,
+or
+tab,
+the cursor moves appropriately within the window.
 .bP
-Backspace moves the cursor one character left; at the left
-edge of a window it does nothing.
+Backspace moves the cursor one character left;
+at the left margin of a window,
+it does nothing.
 .bP
-Carriage return moves the cursor to the window left margin on the current line.
+Carriage return moves the cursor to the left margin on the current line
+of the window.
 .bP
-Newline does a \fBclrtoeol\fR,
-then moves the cursor to the window left margin on the next line,
-scrolling the window if on the last line.
+Line feed does a \fB\%clrtoeol\fP(3X),
+then moves the cursor to the left margin on the next line of the window,
+and if \fB\%scrollok\fP(3X) is enabled for
+.IR win ,
+scrolls the window if the cursor was already on the last line.
 .bP
-Tabs are considered to be at every eighth column.
-The tab interval may be altered by setting the \fBTABSIZE\fR variable.
+Tab advances the cursor to the next tab stop
+(possibly on the next line);
+these are placed at every eighth column by default.
+Alter the tab interval with the
+.B \%TABSIZE
+extension;
+see \fB\%curs_variables\fP(3X).
 .PP
-If \fIch\fR is any other nonprintable character,
+If
+.I ch
+is any other nonprintable character,
 it is drawn in printable form,
-i.e., the \fB^\fR\fIX\fR notation used by \fBunctrl\fR(3X).
-Calling \fBwinch\fR after adding a
-nonprintable character does not return the character itself,
-but instead returns the printable representation of the character.
-.PP
-Video attributes can be combined with a character argument passed to
-\fBaddch\fR or related functions by logical-ORing them into the character.
-(Thus, text, including attributes, can be copied from one place to another
-using \fBinch\fR(3X) and \fBaddch\fR.)  See the \fBcurs_attr\fR(3X) page for
-values of predefined video attribute constants that can be usefully OR'ed
-into characters.
-.SS Echoing characters
+using the same convention as \fB\%unctrl\fP(3X).
 .PP
-The \fBechochar\fR and \fBwechochar\fR routines are equivalent to a call to
-\fBaddch\fR followed by a call to \fBrefresh\fR(3X), or a call to \fBwaddch\fR
-followed by a call to \fBwrefresh\fR.
-The knowledge that only a single
-character is being output is used and, for non-control characters, a
-considerable performance gain may be seen by using these routines instead of
-their equivalents.
-.SS Line Graphics
-The following variables may be used to add line drawing characters to the
-screen with routines of the \fBaddch\fR family.
-The default character listed
-below is used if the \fBacsc\fR capability does not define a terminal-specific
-replacement for it,
-or if the terminal and locale configuration requires Unicode but the
-library is unable to use Unicode.
+Calling \fB\%winch\fP(3X) on the location of a nonprintable character
+does not return the character itself,
+but its \fB\%unctrl\fP(3X) representation.
 .PP
-The names are taken from VT100 nomenclature.
+.I ch
+may contain rendering and/or color attributes,
+and others can be combined with the parameter
+by logically \*(``or\*(''ing with it.
+(A character with its attributes can be copied from place to place
+using \fB\%winch\fP(3X) and
+.BR \%waddch .)
+See \fB\%curs_attr\fP(3X) for values of predefined video attribute
+constants that can be usefully \*(``or\*(''ed with characters.
+.SS "Echoing Characters"
+.B \%echochar
+and
+.B \%wechochar
+are equivalent to calling
+.RB \%( w ) addch
+followed by
+.RB \%( w ) refresh .
+.I curses
+interprets these functions as a hint that only a single character is
+being output;
+for non-control characters,
+a considerable performance gain may be enjoyed by employing them.
+.\" TODO: Combine the following with the "Line Drawing" subsection of
+.\" terminfo(5) and replace this with a cross reference there.
+.SS "Forms-Drawing Characters"
+.I curses
+defines macros starting with
+.B \%ACS_
+that can be used with
+.B \%waddch
+to write line-drawing and other special characters to the screen.
+.I \%ncurses
+terms these
+.I "forms-drawing characters."
+The ACS default listed below is used if the
+.B \%acs_chars
+.RB ( \%acsc )
+.I \%term\%info
+capability does not define a terminal-specific replacement for it,
+or if the terminal and locale configuration requires Unicode to access
+these characters but the library is unable to use Unicode.
+The \*(``acsc char\*('' column corresponds to how the characters are
+specified in the
+.B \%acs_chars
+string capability,
+and the characters in it may appear on the screen if the terminal's
+database entry incorrectly advertises ACS support.
+The name \*(``ACS\*('' originates in the Alternate Character Set feature
+of the DEC VT100 terminal.
 .PP
 .TS
-l l l l
-l l l l
-_ _ _ _
-l l l l.
-\fBACS\fR	\fBACS\fR	\fBacsc\fP	\fBGlyph\fR
-\fBName\fR	\fBDefault\fR	\fBchar\fP	\fBName\fR
+Lb Lb Lb Lb
+Lb Lb Lb Lb
+Lb L  L  Lx.
+\&	ACS	acsc	\&
+Symbol	Default	char	Glyph Name
+_
 ACS_BLOCK	#	0	solid square block
 ACS_BOARD	#	h	board of squares
 ACS_BTEE	+	v	bottom tee
-ACS_BULLET	o	~	bullet
+ACS_BULLET	o	\*~	bullet
 ACS_CKBOARD	:	a	checker board (stipple)
 ACS_DARROW	v	.	arrow pointing down
-ACS_DEGREE	'	f	degree symbol
-ACS_DIAMOND	+	`	diamond
+ACS_DEGREE	\*'	f	degree symbol
+ACS_DIAMOND	+	\(ga	diamond
 ACS_GEQUAL	>	>	greater-than-or-equal-to
 ACS_HLINE	\-	q	horizontal line
 ACS_LANTERN	#	i	lantern symbol
@@ -162,153 +218,260 @@ ACS_S7	\-	r	scan line 7
 ACS_S9	\&_	s	scan line 9
 ACS_STERLING	f	}	pound-sterling symbol
 ACS_TTEE	+	w	top tee
-ACS_UARROW	^	\-	arrow pointing up
+ACS_UARROW	\*^	\-	arrow pointing up
 ACS_ULCORNER	+	l	upper left-hand corner
 ACS_URCORNER	+	k	upper right-hand corner
 ACS_VLINE	|	x	vertical line
 .TE
 .SH RETURN VALUE
-All routines return the integer \fBERR\fR upon failure and \fBOK\fR on success
-(the SVr4 manuals specify only
-\*(``an integer value other than \fBERR\fR\*('') upon successful completion,
-unless otherwise noted in the preceding routine descriptions.
+These functions return
+.B OK
+on success and
+.B ERR
+on failure.
 .PP
-Functions with a \*(``mv\*('' prefix first perform a cursor movement using
-\fBwmove\fP, and return an error if the position is outside the window,
-or if the window pointer is null.
+In
+.IR \%ncurses ,
+.B \%waddch
+returns
+.B ERR
+if it is not possible to add a complete character at the cursor
+position,
+as when conversion of a multibyte character to a byte sequence fails,
+or at least one of the resulting bytes cannot be added to the window.
+See section \*(``PORTABILITY\*('' below regarding the use of
+.B \%waddch
+with multibyte characters.
 .PP
-If it is not possible to add a complete character,
-an error is returned:
-.bP
-If \fBscrollok\fR is not enabled,
-writing a character at the lower right margin succeeds.
-However, an error is returned because
-it is not possible to wrap to a new line
-.bP
-If an error is detected when converting a multibyte character to a sequence
-of bytes,
-or if it is not possible to add all of the resulting bytes in the window,
-an error is returned.
+.B \%waddch
+can successfully write a character at the bottom right location of the
+window.
+However,
+.I \%ncurses
+returns
+.B ERR
+if \fB\%scrollok\fP(3X) is not enabled in that event,
+because it is not possible to wrap to a new line.
+.PP
+Functions prefixed with \*(``mv\*('' first perform cursor movement and
+fail if the position
+.RI ( y ,
+.IR x )
+is outside the window boundaries.
 .SH NOTES
-Note that \fBaddch\fR, \fBmvaddch\fR, \fBmvwaddch\fR, and
-\fBechochar\fR may be macros.
+.BR \%addch ,
+.BR \%mvaddch ,
+.BR \%mvwaddch ,
+and
+.B \%echochar
+may be implemented as macros.
 .SH PORTABILITY
-All these functions are described in the XSI Curses standard, Issue 4.
-The defaults specified for forms-drawing characters apply in the POSIX locale.
-.SS ACS Symbols
-.LP
-X/Open Curses states that the \fIACS_\fP definitions are \fBchar\fP constants.
-For the wide-character implementation (see \fBcurs_add_wch\fP),
-there are analogous \fIWACS_\fP definitions which are \fBcchar_t\fP constants.
-Some implementations are problematic:
+X/Open Curses,
+Issue 4 describes these functions.
+It specifies no error conditions for them.
+.PP
+SVr4
+.I curses
+describes a successful return value only as
+\*(``an integer value other than
+.BR ERR \*(''.
+.PP
+The defaults specified for forms-drawing characters apply in the POSIX
+locale.
+.SS "ACS Symbols"
+X/Open Curses states that the
+.B \%ACS_
+definitions are
+.I char
+constants.
+.PP
+Some implementations are problematic.
 .bP
-Some implementations define the ACS symbols to a constant
-(such as Solaris), while others define those to entries in an array.
+Solaris
+.IR curses ,
+for example,
+define the ACS symbols as constants;
+others define them as elements of an array.
 .IP
-This implementation uses an array \fBacs_map\fP, as done in SVr4 curses.
-NetBSD also uses an array, actually named \fB_acs_char\fP, with a \fB#define\fP
+This implementation uses an array,
+.BR \%acs_map ,
+as did SVr4
+.IR curses .
+NetBSD also uses an array,
+actually named
+.BR \%_acs_char ,
+with a
+.B \%#define
 for compatibility.
 .bP
-HPUX curses equates some of the \fIACS_\fP symbols
-to the analogous \fIWACS_\fP symbols as if the \fIACS_\fP symbols were
-wide characters.
-The misdefined symbols are the arrows
-and other symbols which are not used for line-drawing.
+HP-UX
+.I curses
+equates some of the
+.B \%ACS_
+symbols to the analogous
+.B \%WACS_
+symbols as if the
+.B \%ACS_
+symbols were wide characters
+(see \fB\%curs_add_wch\fP(3X)).
+The misdefined symbols are the arrows and others that are not used for
+line drawing.
 .bP
-X/Open Curses (issues 2 through 7) has a typographical error
-for the ACS_LANTERN symbol, equating its \*(``VT100+ Character\*(''
-to \fBI\fP (capital I), while the header files for SVr4 curses
-and the various implementations use \fBi\fP (lowercase).
+X/Open Curses
+(Issues 2 through 7)
+has a typographical error
+for the
+.B \%ACS_LANTERN
+symbol, equating its \*(``VT100+ Character\*('' to \*(``I\*(''
+(capital I),
+while the header files for SVr4
+.I curses
+and other implementations use \*(``i\*(''
+(small i).
 .IP
-None of the terminal descriptions on Unix platforms use uppercase-I,
-except for Solaris (i.e., \fIscreen\fP's terminal description,
+None of the terminal descriptions on Unix platforms use uppercase I,
+except for Solaris
+(in its
+.I \%term\%info
+entry for \fI\%screen\fP(1),
 apparently based on the X/Open documentation around 1995).
-On the other hand, the terminal description \fIgs6300\fP
-(AT&T PC6300 with EMOTS Terminal Emulator) uses lowercase-i.
-.LP
+On the other hand,
+its
+.B \%gs6300
+(AT&T PC6300 with EMOTS Terminal Emulator)
+description uses lowercase i.
+.PP
 Some ACS symbols
-(ACS_S3,
-ACS_S7,
-ACS_LEQUAL,
-ACS_GEQUAL,
-ACS_PI,
-ACS_NEQUAL,
-ACS_STERLING)
-were not documented in
-any publicly released System V.
-However, many publicly available terminfos
-include \fBacsc\fR strings in which their key characters (pryz{|}) are
-embedded, and a second-hand list of their character descriptions has come
-to light.
-The ACS-prefixed names for them were invented for \fBncurses\fR(3X).
-.LP
-The \fIdisplayed\fP values for the \fIACS_\fP and \fIWACS_\fP constants
-depend on 
+.RB ( \%ACS_S3 ,
+.BR \%ACS_S7 ,
+.BR \%ACS_LEQUAL ,
+.BR \%ACS_GEQUAL ,
+.BR \%ACS_PI ,
+.BR \%ACS_NEQUAL ,
+and
+.BR \%ACS_STERLING )
+were not documented in any publicly released System\ V.
+However,
+many publicly available
+.I \%term\%info
+entries include
+.B \%acsc
+strings in which their key characters
+.BR ( pryz{|} )
+are embedded,
+and a second-hand list of their character descriptions has come to
+light.
+The
+.I \%ncurses
+developers invented ACS-prefixed names for them.
+.PP
+The
+.I displayed
+values of
+.B \%ACS_
+constants depend on
 .bP
-the library configuration, i.e., \fBncurses\fP versus \fBncursesw\fP,
-where the latter is capable of displaying Unicode while the former is not, and
+the
+.I \%ncurses
+ABI\(emfor example,
+wide-character versus non-wide-character configurations
+(the former is capable of displaying Unicode while the latter is not),
+and
 .bP
-whether the \fIlocale\fP uses UTF-8 encoding.
-.LP
-In certain cases, the terminal is unable to display line-drawing characters
-except by using UTF-8 (see the discussion of \fBNCURSES_NO_UTF8_ACS\fP in
-ncurses(3X)).
-.SS Character Set
-X/Open Curses assumes that the parameter passed to \fBwaddch\fP contains
-a single character.
-As discussed in \fBcurs_attr\fP(3X), that character may have been
-more than eight bits in an SVr3 or SVr4 implementation,
-but in the X/Open Curses model, the details are not given.
-The important distinction between SVr4 curses and X/Open Curses is
-that the non-character information (attributes and color) was
-separated from the character information which is packed in a \fBchtype\fP
-to pass to \fBwaddch\fP.
+whether the locale uses UTF-8 encoding.
+.PP
+In certain cases,
+the terminal is unable to display forms-drawing characters
+.I except
+by using UTF-8;
+see the discussion of the
+.I \%NCURSES_NO_UTF8_ACS
+environment variable in \fB\%ncurses\fP(3X)).
+.SS "Character Set"
+X/Open Curses assumes that the parameter passed to
+.B \%waddch
+contains a single character.
+As discussed in \fB\%curs_attr\fP(3X),
+that character may have been more than eight bits wide in an SVr3 or
+SVr4 implementation,
+but in the X/Open Curses model,
+the details are not given.
+The important distinction between SVr4
+.I curses
+and X/Open Curses is that the latter separates non-character information
+(attributes and color)
+from the character code,
+which SVr4 packs into a
+.I \%chtype
+for passage to
+.BR \%waddch .
 .PP
-In this implementation, \fBchtype\fP holds an eight-bit character.
-But ncurses allows multibyte characters to be passed in a succession
-of calls to \fBwaddch\fP.
-The other implementations do not do this;
-a call to \fBwaddch\fP passes exactly one character
-which may be rendered as one or more cells on the screen
-depending on whether it is printable.
+In
+.IR \%ncurses ,
+.I \%chtype
+holds an eight-bit character.
+But the library allows a multibyte character to be passed in a
+succession of calls to
+.BR \%waddch .
+Other implementations do not;
+a
+.B \%waddch
+call transmits exactly one character,
+which may be rendered in one or more screen locations depending on
+whether it is printable.
 .PP
 Depending on the locale settings,
-ncurses will inspect the byte passed in each call to \fBwaddch\fP,
-and check if the latest call will continue a multibyte sequence.
-When a character is \fIcomplete\fP,
-ncurses displays the character and moves to the next position in the screen.
+.I \%ncurses
+inspects the byte passed in each
+.B \%waddch
+call,
+and checks whether the latest call continues a multibyte sequence.
+When a character is
+.IR complete ,
+.I \%ncurses
+displays the character and advances the cursor.
 .PP
 If the calling application interrupts the succession of bytes in
-a multibyte character by moving the current location (e.g., using \fBwmove\fP),
-ncurses discards the partially built character,
-starting over again.
+a multibyte character sequence by changing the current location\(emfor
+example,
+with \fB\%wmove\fP(3X)\(em\c
+.I \%ncurses
+discards the incomplete character.
 .PP
 For portability to other implementations,
-do not rely upon this behavior:
+do not rely upon this behavior.
+Check whether a character can be represented as a single byte in the
+current locale.
 .bP
-check if a character can be represented as a single byte in the current locale
-before attempting call \fBwaddch\fP, and
+If it can,
+call either
+.B \%waddch
+or \fB\%wadd_wch\fP(3X).
 .bP
-call \fBwadd_wch\fP for characters which cannot be handled by \fBwaddch\fP.
+If it cannot,
+use only
+\fB\%wadd_wch\fP(3X).
 .SS TABSIZE
-.LP
-The \fBTABSIZE\fR variable is implemented in SVr4 and other versions of curses,
-but is not part of X/Open curses
-(see \fBcurs_variables\fR(3X) for more details).
-.LP
-If \fIch\fR is a carriage return,
-the cursor is moved to the beginning of the current row of the window.
-This is true of other implementations, but is not documented.
+SVr4 and other versions of
+.I curses
+implement the
+.B \%TABSIZE
+variable,
+but X/Open Curses does not specify it
+(see \fB\%curs_variables\fP(3X)).
 .SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_attr\fR(3X),
-\fBcurs_clear\fR(3X),
-\fBcurs_inch\fR(3X),
-\fBcurs_outopts\fR(3X),
-\fBcurs_refresh\fR(3X),
-\fBcurs_variables\fR(3X),
-\fBputc\fR(3).
+\fB\%curs_add_wch\fP(3X) describes comparable functions of the
+.I \%ncurses
+library in its wide-character configuration
+.RI ( \%ncursesw ).
 .PP
-Comparable functions in the wide-character (ncursesw) library are
-described in
-\fBcurs_add_wch\fR(3X).
+\fB\%curses\fP(3X),
+\fB\%curs_addchstr\fP(3X),
+\fB\%curs_addstr\fP(3X),
+\fB\%curs_attr\fP(3X),
+\fB\%curs_clear\fP(3X),
+\fB\%curs_inch\fP(3X),
+\fB\%curs_outopts\fP(3X),
+\fB\%curs_refresh\fP(3X),
+\fB\%curs_variables\fP(3X),
+\fB\%putchar\fP(3)
diff --git a/contrib/ncurses/man/curs_addchstr.3x b/contrib/ncurses/man/curs_addchstr.3x
index 09d70d6e8e1f..25d322aff0be 100644
--- a/contrib/ncurses/man/curs_addchstr.3x
+++ b/contrib/ncurses/man/curs_addchstr.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2019,2020 Thomas E. Dickey                                     *
+.\" Copyright 2019-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2012,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,62 +27,61 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_addchstr.3x,v 1.22 2020/12/19 21:39:20 tom Exp $
-.TH curs_addchstr 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: curs_addchstr.3x,v 1.45 2024/04/20 21:20:07 tom Exp $
+.TH curs_addchstr 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.na
-.hy 0
 .SH NAME
-\fBaddchstr\fR,
-\fBaddchnstr\fR,
-\fBwaddchstr\fR,
-\fBwaddchnstr\fR,
-\fBmvaddchstr\fR,
-\fBmvaddchnstr\fR,
-\fBmvwaddchstr\fR,
-\fBmvwaddchnstr\fR \- add a string of characters (and attributes) to a \fBcurses\fR window
-.ad
-.hy
+\fB\%addchstr\fP,
+\fB\%addchnstr\fP,
+\fB\%waddchstr\fP,
+\fB\%waddchnstr\fP,
+\fB\%mvaddchstr\fP,
+\fB\%mvaddchnstr\fP,
+\fB\%mvwaddchstr\fP,
+\fB\%mvwaddchnstr\fP \-
+add a \fIcurses\fR character string to a window
 .SH SYNOPSIS
 .nf
-\fB#include <curses.h>\fR
+\fB#include <curses.h>
 .PP
-\fBint addchstr(const chtype *\fP\fIchstr\fP\fB);\fR
-.br
-\fBint addchnstr(const chtype *\fP\fIchstr\fP\fB, int \fP\fIn\fP\fB);\fR
-.br
-\fBint waddchstr(WINDOW *\fP\fIwin\fP\fB, const chtype *\fP\fIchstr\fP\fB);\fR
-.br
-\fBint waddchnstr(WINDOW *\fP\fIwin\fP\fB, const chtype *\fP\fIchstr\fP\fB, int \fP\fIn\fP\fB);\fR
-.sp
-\fBint mvaddchstr(int \fP\fIy\fP\fB, int \fP\fIx\fP\fB, const chtype *\fP\fIchstr\fP\fB);\fR
-.br
-\fBint mvaddchnstr(int \fP\fIy\fP\fB, int \fP\fIx\fP\fB, const chtype *\fP\fIchstr\fP\fB, int \fP\fIn\fP\fB);\fR
-.br
-\fBint mvwaddchstr(WINDOW *\fP\fIwin\fP\fB, int \fP\fIy\fP\fB, int \fP\fIx\fP\fB, const chtype *\fP\fIchstr\fP\fB);\fR
-.br
-\fBint mvwaddchnstr(WINDOW *\fP\fIwin\fP\fB, int \fP\fIy\fP\fB, int \fP\fIx\fP\fB, const chtype *\fP\fIchstr\fP\fB, int \fP\fIn\fP\fB);\fR
+\fBint addchstr(const chtype *\fIchstr\fP);
+\fBint waddchstr(WINDOW *\fIwin\fP, const chtype *\fIchstr\fP);
+\fBint mvaddchstr(int \fIy\fP, int \fIx\fP, const chtype *\fIchstr\fP);
+\fBint mvwaddchstr(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, const chtype *\fIchstr\fP);
+.PP
+\fBint addchnstr(const chtype *\fIchstr\fP, int \fIn\fP);
+\fBint waddchnstr(WINDOW *\fIwin\fP, const chtype *\fIchstr\fP, int \fIn\fP);
+\fBint mvaddchnstr(int \fIy\fP, int \fIx\fP, const chtype *\fIchstr\fP, int \fIn\fP);
+\fBint mvwaddchnstr(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, const chtype *\fIchstr\fP, int \fIn\fP);
 .fi
 .SH DESCRIPTION
 These functions copy the (null-terminated)
-\fIchstr\fR array
+\fIchstr\fP array
 into the window image structure
 starting at the current cursor position.
-The four functions with \fIn\fR as the last
-argument copy at most \fIn\fR elements,
+.PP
+The four functions with \fIn\fP as the last
+argument copy at most \fIn\fP elements,
 but no more than will fit on the line.
-If \fBn\fR=\fB\-1\fR then the whole array is copied,
+If \fBn\fP=\fB\-1\fP then the whole array is copied,
 to the maximum number of characters that will fit on the line.
 .PP
-The window cursor is \fInot\fR advanced.
-These functions work faster than \fBwaddnstr\fR.
+The window cursor is \fInot\fP advanced.
+These functions are faster than \fBwaddnstr\fP.
 On the other hand:
 .bP
 they do not perform checking
@@ -95,23 +94,30 @@ they do not expand other control characters to ^-escapes, and
 they truncate the string if it crosses the right margin,
 rather than wrapping it around to the new line.
 .SH RETURN VALUE
-All functions return the integer \fBERR\fR upon failure and \fBOK\fR on success.
+All functions return the integer \fBERR\fP upon failure and \fBOK\fP on success.
 .PP
-X/Open does not define any error conditions.
+X/Open Curses does not specify any error conditions.
 This implementation returns an error
-if the window pointer is null.
+.bP
+if the \fIwin\fP parameter is null or
+.bP
+if the \fIwchstr\fP parameter is null.
 .PP
-Functions with a \*(``mv\*('' prefix first perform a cursor movement using
-\fBwmove\fP, and return an error if the position is outside the window,
-or if the window pointer is null.
+Functions prefixed with \*(``mv\*('' first perform cursor movement and
+fail if the position
+.RI ( y ,
+.IR x )
+is outside the window boundaries.
 .SH NOTES
-All functions except \fBwaddchnstr\fR may be macros.
+All functions except \fBwaddchnstr\fP may be macros.
 .SH PORTABILITY
-These entry points are described in the XSI Curses standard, Issue 4.
+These functions are described in X/Open Curses, Issue 4.
 .SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_addstr\fR(3X).
+\fB\%curs_add_wchstr\fP(3X) describes comparable functions of the
+.I \%ncurses
+library in its wide-character configuration
+.RI ( \%ncursesw ).
 .PP
-Comparable functions in the wide-character (ncursesw) library are
-described in
-\fBcurs_add_wchstr\fR(3X).
+\fB\%curses\fP(3X),
+\fB\%curs_addch\fP(3X),
+\fB\%curs_addstr\fP(3X)
diff --git a/contrib/ncurses/man/curs_addstr.3x b/contrib/ncurses/man/curs_addstr.3x
index 6f280e64ee1b..1244001dbd95 100644
--- a/contrib/ncurses/man/curs_addstr.3x
+++ b/contrib/ncurses/man/curs_addstr.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2019,2020 Thomas E. Dickey                                     *
+.\" Copyright 2019-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2012,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,93 +27,109 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_addstr.3x,v 1.23 2020/10/17 23:11:02 tom Exp $
-.TH curs_addstr 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: curs_addstr.3x,v 1.45 2024/04/20 19:18:18 tom Exp $
+.TH curs_addstr 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.na
-.hy 0
 .SH NAME
-\fBaddstr\fR,
-\fBaddnstr\fR,
-\fBwaddstr\fR,
-\fBwaddnstr\fR,
-\fBmvaddstr\fR,
-\fBmvaddnstr\fR,
-\fBmvwaddstr\fR,
-\fBmvwaddnstr\fR \- add a string of characters to a \fBcurses\fR window and advance cursor
-.ad
-.hy
+\fB\%addstr\fP,
+\fB\%addnstr\fP,
+\fB\%waddstr\fP,
+\fB\%waddnstr\fP,
+\fB\%mvaddstr\fP,
+\fB\%mvaddnstr\fP,
+\fB\%mvwaddstr\fP,
+\fB\%mvwaddnstr\fP \-
+add a string to a \fIcurses\fR window and advance the cursor
 .SH SYNOPSIS
 .nf
-\fB#include <curses.h>\fR
+\fB#include <curses.h>
 .PP
-\fBint addstr(const char *\fR\fIstr\fR\fB);\fR
-.br
-\fBint addnstr(const char *\fR\fIstr\fR\fB, int \fR\fIn\fR\fB);\fR
-.br
-\fBint waddstr(WINDOW *\fR\fIwin\fR\fB, const char *\fR\fIstr\fR\fB);\fR
-.br
-\fBint waddnstr(WINDOW *\fR\fIwin\fR\fB, const char *\fR\fIstr\fR\fB, int \fR\fIn\fR\fB);\fR
-.sp
-\fBint mvaddstr(int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, const char *\fR\fIstr\fR\fB);\fR
-.br
-\fBint mvaddnstr(int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, const char *\fR\fIstr\fR\fB, int \fR\fIn\fR\fB);\fR
-.br
-\fBint mvwaddstr(WINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, const char *\fR\fIstr\fR\fB);\fR
-.br
-\fBint mvwaddnstr(WINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, const char *\fR\fIstr, int \fR\fIn\fR\fB);\fR
+\fBint addstr(const char *\fIstr\fP);
+\fBint mvaddstr(int \fIy\fP, int \fIx\fP, const char *\fIstr\fP);
+\fBint mvwaddstr(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, const char *\fIstr\fP);
+\fBint waddstr(WINDOW *\fIwin\fP, const char *\fIstr\fP);
+.PP
+\fBint addnstr(const char *\fIstr\fP, int \fIn\fP);
+\fBint mvaddnstr(int \fIy\fP, int \fIx\fP, const char *\fIstr\fP, int \fIn\fP);
+\fBint mvwaddnstr(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, const char *\fIstr\fP, int \fIn\fP);
+\fBint waddnstr(WINDOW *\fIwin\fP, const char *\fIstr\fP, int \fIn\fP);
 .fi
 .SH DESCRIPTION
-These functions write the (null-terminated) character string
-\fIstr\fR on the given window.
-It is similar to calling \fBwaddch\fR once for each byte in the string.
+.B waddstr
+writes the characters of the (null-terminated) string
+.I str
+to the window
+.IR win .
+Its process is similar to calling \fB\%waddch\fP(3X) for each
+.I char
+in
+.IR str .
+Control characters are processed as in \fB\%waddch\fP(3X).
 .PP
-The \fImv\fR functions perform cursor movement once, before writing any
-characters.
-Thereafter, the cursor is advanced as a side-effect of writing to the window.
+.B waddnstr
+writes at most
+.I n
+characters,
+or until a terminating null character occurs in
+.IR str .
+If
+.I n
+is \-1,
+.B
+.B waddnstr
+writes the entire string.
 .PP
-The four functions with \fIn\fR as the last argument
-write at most \fIn\fR bytes,
-or until a terminating null is reached.
-If \fIn\fR is \-1, then the entire string will be added.
+\fB\%ncurses\fP(3X) describes the variants of these functions.
 .SH RETURN VALUE
-All functions return the integer \fBERR\fR upon failure and \fBOK\fR on success.
+These functions return
+.B OK
+on success and
+.B ERR
+on failure.
 .PP
-X/Open does not define any error conditions.
-This implementation returns an error
+X/Open Curses does not specify any error conditions.
+.I \%ncurses
+returns an error
 .bP
-if the window pointer is null or
+if the window pointer is
+.BR NULL ,
 .bP
-if the string pointer is null or
+if the string pointer is
+.BR NULL ,
+or
 .bP
-if the corresponding calls to \fBwaddch\fP return an error.
-.PP
-Functions with a \*(``mv\*('' prefix first perform a cursor movement using
-\fBwmove\fP, and return an error if the position is outside the window,
-or if the window pointer is null.
-If an error is returned by the \fBwmove\fP,
-no characters are added to the window.
+if an internal \fB\%waddch\fP(3X) call returns an error.
 .PP
-If an error is returned by \fBwaddch\fP
-(e.g.,
-because the window is not large enough,
-or an illegal byte sequence was detected)
-only part of the string may be added.
-Aside from that,
-there is a special case in \fBwaddch\fP where an error may be
-returned after successfully writing a character to the lower-right corner
-of a window when \fBscrollok\fP is disabled.
+Functions prefixed with \*(``mv\*('' first perform cursor movement and
+fail if the position
+.RI ( y ,
+.IR x )
+is outside the window boundaries.
 .SH NOTES
-All of these functions except \fBwaddnstr\fR may be macros.
+All of these functions except \fBwaddnstr\fP may be macros.
 .SH PORTABILITY
-These functions are described in the XSI Curses standard, Issue 4.
+X/Open Curses,
+Issue 4 describes these functions.
 .SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_addch\fR(3X).
+\fB\%curs_addwstr\fP(3X) describes comparable functions of the
+.I \%ncurses
+library in its wide-character configuration
+.RI ( \%ncursesw ).
+.PP
+\fB\%curses\fP(3X),
+\fB\%curs_addch\fP(3X),
+\fB\%curs_addchstr\fP(3X)
diff --git a/contrib/ncurses/man/curs_addwstr.3x b/contrib/ncurses/man/curs_addwstr.3x
index 6f7c3dbe17f7..78d5788ebc22 100644
--- a/contrib/ncurses/man/curs_addwstr.3x
+++ b/contrib/ncurses/man/curs_addwstr.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2019,2020 Thomas E. Dickey                                     *
+.\" Copyright 2019-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 2002-2012,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,83 +27,120 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_addwstr.3x,v 1.15 2020/10/17 23:12:22 tom Exp $
-.TH curs_addwstr 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: curs_addwstr.3x,v 1.37 2024/04/20 19:18:18 tom Exp $
+.TH curs_addwstr 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.na
-.hy 0
 .SH NAME
-\fBaddwstr\fR,
-\fBaddnwstr\fR,
-\fBwaddwstr\fR,
-\fBwaddnwstr\fR,
-\fBmvaddwstr\fR,
-\fBmvaddnwstr\fR,
-\fBmvwaddwstr\fR,
-\fBmvwaddnwstr\fR \- add a string of wide characters to a \fBcurses\fR window and advance cursor
-.ad
-.hy
+\fB\%addwstr\fP,
+\fB\%addnwstr\fP,
+\fB\%waddwstr\fP,
+\fB\%waddnwstr\fP,
+\fB\%mvaddwstr\fP,
+\fB\%mvaddnwstr\fP,
+\fB\%mvwaddwstr\fP,
+\fB\%mvwaddnwstr\fP \-
+add a wide-character string to a \fIcurses\fR window and advance the cursor
 .SH SYNOPSIS
 .nf
-\fB#include <curses.h>\fR
+\fB#include <curses.h>
 .PP
-\fBint addwstr(const wchar_t *\fR\fIwstr\fR\fB);\fR
-.br
-\fBint addnwstr(const wchar_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR
-.br
-\fBint waddwstr(WINDOW *\fR\fIwin\fR\fB, const wchar_t *\fR\fIwstr\fR\fB);\fR
-.br
-\fBint waddnwstr(WINDOW *\fR\fIwin\fR\fB, const wchar_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR
-.sp
-\fBint mvaddwstr(int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, const wchar_t *\fR\fIwstr\fR\fB);\fR
-.br
-\fBint mvaddnwstr(int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, const wchar_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR
-.br
-\fBint mvwaddwstr(WINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, const wchar_t *\fR\fIwstr\fR\fB);\fR
-.br
-\fBint mvwaddnwstr(WINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, const wchar_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR
+\fBint addwstr(const wchar_t *\fIwstr\fP);
+\fBint mvaddwstr(int \fIy\fP, int \fIx\fP, const wchar_t *\fIwstr\fP);
+\fBint mvwaddwstr(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, const wchar_t *\fIwstr\fP);
+\fBint waddwstr(WINDOW *\fIwin\fP, const wchar_t *\fIwstr\fP);
+.PP
+\fBint addnwstr(const wchar_t *\fIwstr\fP, int \fIn\fP);
+\fBint mvaddnwstr(int \fIy\fP, int \fIx\fP, const wchar_t *\fIwstr\fP, int \fIn\fP);
+\fBint mvwaddnwstr(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, const wchar_t *\fIwstr\fP, int \fIn\fP);
+\fBint waddnwstr(WINDOW *\fIwin\fP, const wchar_t *\fIwstr\fP, int \fIn\fP);
 .fi
 .SH DESCRIPTION
-These functions write the characters of the
-(null-terminated) \fBwchar_t\fR character string
-\fIwstr\fR on the given window.
-It is similar to constructing a \fBcchar_t\fR for each wchar_t in the string,
-then calling \fBwadd_wch\fR for the resulting \fBcchar_t\fR.
+.B waddwstr
+writes the characters of the (wide-null-terminated) wide-character
+string
+.I wstr
+to the window
+.IR win .
+Its process is similar to constructing a
+.I cchar_t
+for each
+.I wchar_t
+in
+.IR wstr ,
+then calling \fB\%wadd_wch\fP(3X) with the resulting
+.IR cchar_t .
+.bP
+Spacing and non-spacing characters in the string
+are processed one at a time,
+and
+.bP
+control characters are processed as in \fB\%wadd_wch\fP(3X).
 .PP
-The \fImv\fR functions perform cursor movement once, before writing any
-characters.
-Thereafter, the cursor is advanced as a side-effect of writing to the window.
+.B waddnwstr
+writes at most
+.I n
+wide characters,
+or until a terminating wide null character occurs in
+.IR wstr .
+If
+.I n
+is \-1,
+.B
+.B waddnwstr
+writes the entire wide string.
 .PP
-The four functions with \fIn\fR as the last argument
-write at most \fIn\fR \fBwchar_t\fR characters,
-or until a terminating null is reached.
-If \fIn\fR is \-1, then the entire string will be added.
+\fB\%ncurses\fP(3X) describes the variants of these functions.
 .SH RETURN VALUE
-All functions return the integer \fBERR\fR upon failure and \fBOK\fR on success.
+These functions return
+.B OK
+on success and
+.B ERR
+on failure.
 .PP
-X/Open does not define any error conditions.
-This implementation returns an error
+X/Open Curses does not specify any error conditions.
+.I \%ncurses
+returns an error
 .bP
-if the window pointer is null or
+if the window pointer is
+.BR NULL ,
 .bP
-if the string pointer is null or
+if the string pointer is
+.BR NULL ,
+or
 .bP
-if the corresponding calls to \fBwadd_wch\fP return an error.
+if an internal \fB\%wadd_wch\fP(3X) call returns an error.
 .PP
-Functions with a \*(``mv\*('' prefix first perform a cursor movement using
-\fBwmove\fP, and return an error if the position is outside the window,
-or if the window pointer is null.
+Functions prefixed with \*(``mv\*('' first perform cursor movement and
+fail if the position
+.RI ( y ,
+.IR x )
+is outside the window boundaries.
 .SH NOTES
-All of these functions except \fBwaddnwstr\fR may be macros.
+All of these functions except
+.B waddnwstr
+may be implemented as macros.
 .SH PORTABILITY
-These functions are described in the XSI Curses standard, Issue 4.
+X/Open Curses,
+Issue 4 describes these functions.
 .SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_add_wch\fR(3X)
+\fB\%curs_addstr\fP(3X) describes comparable functions of the
+.I \%ncurses
+library in its non-wide-character configuration.
+.PP
+\fB\%curses\fP(3X),
+\fB\%curs_add_wch\fP(3X),
+\fB\%curs_add_wchstr\fP(3X)
diff --git a/contrib/ncurses/man/curs_attr.3x b/contrib/ncurses/man/curs_attr.3x
index 8199977ab690..37774602be8c 100644
--- a/contrib/ncurses/man/curs_attr.3x
+++ b/contrib/ncurses/man/curs_attr.3x
@@ -1,6 +1,6 @@
 '\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,126 +28,93 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_attr.3x,v 1.66 2020/02/02 23:34:34 tom Exp $
-.TH curs_attr 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
-.de NS
-.ie n  .sp
-.el    .sp .5
-.ie n  .in +4
-.el    .in +2
-.nf
-.ft C			\" Courier
-..
-.de NE
-.fi
-.ft R
-.ie n  .in -4
-.el    .in -2
-..
+.\" $Id: curs_attr.3x,v 1.105 2024/04/27 17:54:42 tom Exp $
+.TH curs_attr 3X 2024-04-27 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.na
-.hy 0
 .\" ---------------------------------------------------------------------------
 .SH NAME
-.\" attr_get
-\fBattr_get\fR,
-\fBwattr_get\fR,
-\fBattr_set\fR,
-\fBwattr_set\fR,
-.\" .br
-\fBattr_off\fR,
-\fBwattr_off\fR,
-\fBattr_on\fR,
-\fBwattr_on\fR,
-.\" .br
-\fBattroff\fR,
-\fBwattroff\fR,
-\fBattron\fR,
-\fBwattron\fR,
-\fBattrset\fR,
-\fBwattrset\fR,
-.\" .br
-\fBchgat\fR,
-\fBwchgat\fR,
-\fBmvchgat\fR,
-\fBmvwchgat\fR,
-.\" .br
-\fBcolor_set\fR,
-\fBwcolor_set\fR,
-.\" .br
-\fBstandend\fR,
-\fBwstandend\fR,
-\fBstandout\fR,
-\fBwstandout\fR \- \fBcurses\fR character and window attribute control routines
-.ad
-.hy
+\fB\%attr_get\fP,
+\fB\%wattr_get\fP,
+\fB\%attr_set\fP,
+\fB\%wattr_set\fP,
+\fB\%attr_off\fP,
+\fB\%wattr_off\fP,
+\fB\%attr_on\fP,
+\fB\%wattr_on\fP,
+\fB\%attroff\fP,
+\fB\%wattroff\fP,
+\fB\%attron\fP,
+\fB\%wattron\fP,
+\fB\%attrset\fP,
+\fB\%wattrset\fP,
+\fB\%chgat\fP,
+\fB\%wchgat\fP,
+\fB\%mvchgat\fP,
+\fB\%mvwchgat\fP,
+\fB\%color_set\fP,
+\fB\%wcolor_set\fP,
+\fB\%standend\fP,
+\fB\%wstandend\fP,
+\fB\%standout\fP,
+\fB\%wstandout\fP \-
+manipulate attributes of character cells in \fIcurses\fR windows
 .\" ---------------------------------------------------------------------------
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBint attr_get(attr_t *\fP\fIattrs\fP\fB, short *\fP\fIpair\fP\fB, void *\fP\fIopts\fP\fB);\fR
-.br
-\fBint wattr_get(WINDOW *\fP\fIwin\fP\fB, attr_t *\fP\fIattrs\fP\fB, short *\fP\fIpair\fP\fB,\fR \fBvoid *\fP\fIopts\fP\fB);\fR
-.br
-\fBint attr_set(attr_t \fP\fIattrs\fP\fB, short \fP\fIpair\fP\fB, void *\fP\fIopts\fP\fB);\fR
-.br
-\fBint wattr_set(WINDOW *\fP\fIwin\fP\fB, attr_t \fP\fIattrs\fP\fB, short \fP\fIpair\fP\fB, void *\fP\fIopts\fP\fB);\fR
-.sp
-\fBint attr_off(attr_t \fP\fIattrs\fP\fB, void *\fP\fIopts\fP\fB);\fR
-.br
-\fBint wattr_off(WINDOW *\fP\fIwin\fP\fB, attr_t \fP\fIattrs\fP\fB, void *\fP\fIopts\fP\fB);\fR
-.br
-\fBint attr_on(attr_t \fP\fIattrs\fP\fB, void *\fP\fIopts\fP\fB);\fR
-.br
-\fBint wattr_on(WINDOW *\fP\fIwin\fP\fB, attr_t \fP\fIattrs\fP\fB, void *\fP\fIopts\fP\fB);\fR
-.sp
-\fBint attroff(int \fP\fIattrs);\fR
-.br
-\fBint wattroff(WINDOW *\fP\fIwin\fP\fB, int \fP\fIattrs\fP\fB);\fR
-.br
-\fBint attron(int \fP\fIattrs\fP\fB);\fR
-.br
-\fBint wattron(WINDOW *\fP\fIwin\fP\fB, int \fP\fIattrs\fP\fB);\fR
-.br
-\fBint attrset(int \fP\fIattrs\fP\fB);\fR
-.br
-\fBint wattrset(WINDOW *\fP\fIwin\fP\fB, int \fP\fIattrs\fP\fB);\fR
-.sp
-\fBint chgat(int \fP\fIn\fP\fB, attr_t \fP\fIattr\fP\fB, short \fP\fIpair\fP\fB,\fR \fBconst void *\fP\fIopts\fP\fB);\fR
-.br
-\fBint wchgat(WINDOW *\fP\fIwin\fP\fB,\fP
-      \fBint \fP\fIn\fP\fB, attr_t \fP\fIattr\fP\fB,\fR \fBshort \fP\fIpair\fP\fB, const void *\fP\fIopts\fP\fB);\fR
-.br
-\fBint mvchgat(int \fP\fIy\fP\fB, int \fP\fIx\fP\fB,\fP
-      \fBint \fP\fIn\fP\fB, attr_t \fP\fIattr\fP\fB,\fR \fBshort \fP\fIpair\fP\fB, const void *\fP\fIopts\fP\fB);\fR
-.br
-\fBint mvwchgat(WINDOW *\fP\fIwin, int \fP\fIy, int \fP\fIx\fP\fB,\fP
-      \fBint \fP\fIn,\fR \fBattr_t \fP\fIattr\fP\fB, short \fP\fIpair\fP\fB, const void *\fP\fIopts\fP\fB);\fR
-.sp
-\fBint color_set(short \fP\fIpair\fP\fB, void* \fP\fIopts\fP\fB);\fR
-.br
-\fBint wcolor_set(WINDOW *\fP\fIwin\fP\fB, short \fP\fIpair\fP\fB,\fR \fBvoid* \fP\fIopts);\fR
-.sp
-\fBint standend(void);\fR
-.br
-\fBint wstandend(WINDOW *\fP\fIwin\fP\fB);\fR
-.br
-\fBint standout(void);\fR
-.br
-\fBint wstandout(WINDOW *\fP\fIwin\fP\fB);\fR
+.nf
+\fB#include <curses.h>
+.PP
+\fBint attr_get(attr_t *\fIattrs\fP, short *\fIpair\fP, void *\fIopts\fP);
+\fBint wattr_get(WINDOW *\fIwin\fP, attr_t *\fIattrs\fP, short *\fIpair\fP,\fR \fPvoid *\fIopts\fP);
+\fBint attr_set(attr_t \fIattrs\fP, short \fIpair\fP, void *\fIopts\fP);
+\fBint wattr_set(WINDOW *\fIwin\fP, attr_t \fIattrs\fP, short \fIpair\fP, void *\fIopts\fP);
+.PP
+\fBint attr_off(attr_t \fIattrs\fP, void *\fIopts\fP);
+\fBint wattr_off(WINDOW *\fIwin\fP, attr_t \fIattrs\fP, void *\fIopts\fP);
+\fBint attr_on(attr_t \fIattrs\fP, void *\fIopts\fP);
+\fBint wattr_on(WINDOW *\fIwin\fP, attr_t \fIattrs\fP, void *\fIopts\fP);
+.PP
+\fBint attroff(int \fIattrs\fP);
+\fBint wattroff(WINDOW *\fIwin\fP, int \fIattrs\fP);
+\fBint attron(int \fIattrs\fP);
+\fBint wattron(WINDOW *\fIwin\fP, int \fIattrs\fP);
+\fBint attrset(int \fIattrs\fP);
+\fBint wattrset(WINDOW *\fIwin\fP, int \fIattrs\fP);
+.PP
+\fBint chgat(int \fIn\fP, attr_t \fIattr\fP, short \fIpair\fP,\fR \fPconst void *\fIopts\fP);
+\fBint wchgat(WINDOW *\fIwin\fP,
+      \fBint \fIn\fB, attr_t \fIattr\fB,\fR \fBshort \fIpair\fB, const void *\fIopts\fB);\fR
+\fBint mvchgat(int \fIy\fB, int \fIx\fB,\fR
+      \fBint \fIn\fB, attr_t \fIattr\fB, short \fIpair\fB, const void *\fIopts\fB);\fR
+\fBint mvwchgat(WINDOW *\fIwin\fB, int \fIy\fB, int \fIx\fB,\fR
+      \fBint \fIn\fB, attr_t \fIattr\fB, short \fIpair\fB, const void *\fIopts\fB);\fR
+.PP
+\fBint color_set(short \fIpair\fB, void* \fIopts\fB);\fR
+\fBint wcolor_set(WINDOW *\fIwin\fB, short \fIpair\fB,\fR \fBvoid* \fIopts\fP);\fR
+.PP
+\fBint standend(void);\fP
+\fBint wstandend(WINDOW *\fIwin\fB);\fR
+\fBint standout(void);\fP
+\fBint wstandout(WINDOW *\fIwin\fB);\fR
+.fi
 .\" ---------------------------------------------------------------------------
 .SH DESCRIPTION
-.PP
 These routines manipulate the current attributes of the named window,
 which then apply to all characters that are written into
-the window with \fBwaddch\fR, \fBwaddstr\fR and \fBwprintw\fR.
+the window with \fBwaddch\fP, \fBwaddstr\fP and \fBwprintw\fP.
 Attributes are
 a property of the character, and move with the character through any scrolling
 and insert/delete line/character operations.
@@ -157,15 +124,10 @@ put on the screen.
 .PP
 These routines do not affect the attributes used
 when erasing portions of the window.
-See \fBcurs_bkgd\fR(3X) for functions which modify the attributes used for
+See \fBcurs_bkgd\fP(3X) for functions which modify the attributes used for
 erasing and clearing.
-.PP
-Routines which do not have a \fBWINDOW*\fP parameter apply to \fBstdscr\fP.
-For example,
-\fBattr_set\fP is the \fBstdscr\fP variant of \fBwattr_set\fP.
 .\" ---------------------------------------------------------------------------
-.SS Window attributes
-.PP
+.SS "Window Attributes"
 There are two sets of functions:
 .bP
 functions for manipulating the window attributes and color:
@@ -186,7 +148,7 @@ Use \fBattr_off\fP and \fBwattr_off\fP to turn off window attributes,
 again values OR'd together in \fIattr\fP,
 without affecting other attributes.
 .\" ---------------------------------------------------------------------------
-.SS Legacy window attributes
+.SS "Legacy Window Attributes"
 The X/Open window attribute routines which \fIset\fP or \fIget\fP,
 turn \fIon\fP or \fIoff\fP
 are extensions of older routines
@@ -204,135 +166,293 @@ the attribute parameter.
 For example,
 as long as that value fits into the \fBA_COLOR\fP mask,
 then these calls produce similar results:
-.NS
+.PP
+.RS 4
+.EX
 attrset(A_BOLD | COLOR_PAIR(\fIpair\fP));
 attr_set(A_BOLD, \fIpair\fP, NULL);
-.NE
+.EE
+.RE
 .PP
 However, if the value does not fit, then the \fBCOLOR_PAIR\fP macro
 uses only the bits that fit.
-For example, because in ncurses \fBA_COLOR\fP has eight (8) bits,
-then \fBCOLOR_PAIR(\fP\fI259\fP\fB)\fP is 4
+For example,
+because in \fI\%ncurses\fP \fBA_COLOR\fP has eight (8) bits,
+then \fBCOLOR_PAIR(\fI259\fB)\fR is 4
 (i.e., 259 is 4 more than the limit 255).
 .PP
 The \fBPAIR_NUMBER\fP macro extracts a pair number from an \fBint\fP
 (or \fBchtype\fP).
 For example, the \fIinput\fP and \fIoutput\fP values in these statements
 would be the same:
-.NS
+.PP
+.RS 4
+.EX
 int value = A_BOLD | COLOR_PAIR(\fIinput\fP);
 int \fIoutput\fP = PAIR_NUMBER(value);
-.NE
+.EE
+.RE
 .PP
 The \fBattrset\fP routine is a legacy feature predating SVr4 curses
 but kept in X/Open Curses for the same reason that SVr4 curses kept it:
 compatibility.
 .PP
-The remaining \fBattr\fR* functions operate exactly like the corresponding
-\fBattr_\fR* functions, except that they take arguments of type \fBint\fR
-rather than \fBattr_t\fR.
+The remaining \fBattr\fP* functions operate exactly like the corresponding
+\fBattr_\fP* functions, except that they take arguments of type \fBint\fP
+rather than \fBattr_t\fP.
 .PP
-There is no corresponding \fBattrget\fP function as such in X/Open Curses,
-although ncurses provides \fBgetattrs\fP (see curs_legacy(3X)).
+There is no corresponding \fB\%attrget\fP function as such
+in X/Open Curses,
+although \fI\%ncurses\fP provides \fB\%getattrs\fP
+(see \fB\%curs_legacy\fP(3X)).
 .\" ---------------------------------------------------------------------------
-.SS Change character rendition
-.PP
-The routine \fBchgat\fR changes the attributes of a given number of characters
-starting at the current cursor location of \fBstdscr\fR.
+.SS "Change Character Rendition"
+The routine \fBchgat\fP changes the attributes of a given number of characters
+starting at the current cursor location of \fBstdscr\fP.
 It does not update
 the cursor and does not perform wrapping.
 A character count of \-1 or greater
 than the remaining window width means to change attributes all the way to the
 end of the current line.
-The \fBwchgat\fR function generalizes this to any window;
-the \fBmvwchgat\fR function does a cursor move before acting.
+The \fBwchgat\fP function generalizes this to any window;
+the \fBmvwchgat\fP function does a cursor move before acting.
 .PP
 In these functions,
-the color \fIpair\fP argument is a color-pair index
-(as in the first argument of \fBinit_pair\fR, see \fBcurs_color\fR(3X)).
+the color \fIpair\fP argument is a color pair index
+(as in the first argument of \fBinit_pair\fP, see \fBcurs_color\fP(3X)).
 .\" ---------------------------------------------------------------------------
-.SS Change window color
-The routine \fBcolor_set\fR sets the current color of the given window to the
+.SS "Change Window Color"
+The routine \fBcolor_set\fP sets the current color of the given window to the
 foreground/background combination described by the color \fIpair\fP parameter.
 .\" ---------------------------------------------------------------------------
 .SS Standout
-.PP
-The routine \fBstandout\fR is
-the same as \fBattron(A_STANDOUT)\fR.
-The routine \fBstandend\fR is the same
-as \fBattrset(A_NORMAL)\fR or \fBattrset(0)\fR, that is, it turns off all
+The routine \fBstandout\fP is
+the same as \fBattron(A_STANDOUT)\fP.
+The routine \fBstandend\fP is the same
+as \fBattrset(A_NORMAL)\fP or \fBattrset(0)\fP, that is, it turns off all
 attributes.
 .PP
-X/Open does not mark these \*(``restricted\*('', because
+X/Open Curses does not mark these \*(``restricted\*('', because
 .bP
 they have well established legacy use, and
 .bP
 there is no ambiguity about the way the attributes
 might be combined with a color pair.
 .\" ---------------------------------------------------------------------------
-.SH VIDEO ATTRIBUTES
-The following video attributes, defined in \fB<curses.h>\fR, can be passed to
-the routines \fBattron\fR, \fBattroff\fR, and \fBattrset\fR, or OR'd with the
-characters passed to \fBaddch\fR (see \fBcurs_addch\fR(3X)).
+.SS "Video Attributes"
+The following video attributes, defined in \fB<curses.h>\fP, can be passed to
+the routines \fBattron\fP, \fBattroff\fP, and \fBattrset\fP, or OR'd with the
+characters passed to \fBaddch\fP (see \fBcurs_addch\fP(3X)).
 .PP
+.ne 15
 .RS
 .TS
-l l
-_ _ _
-l l .
-\fIName\fR	\fIDescription\fR
-\fBA_NORMAL\fR	Normal display (no highlight)
-\fBA_STANDOUT\fR	Best highlighting mode of the terminal.
-\fBA_UNDERLINE\fR	Underlining
-\fBA_REVERSE\fR	Reverse video
-\fBA_BLINK\fR	Blinking
-\fBA_DIM\fR	Half bright
-\fBA_BOLD\fR	Extra bright or bold
-\fBA_PROTECT\fR	Protected mode
-\fBA_INVIS\fR	Invisible or blank mode
-\fBA_ALTCHARSET\fR	Alternate character set
-\fBA_ITALIC\fR	Italics (non-X/Open extension)
-\fBA_CHARTEXT\fR	Bit-mask to extract a character
-\fBA_COLOR\fR	Bit-mask to extract a color (legacy routines)
+Lb Lb
+Lb Lx.
+Name	Description
+_
+A_NORMAL	Normal display (no highlight)
+A_STANDOUT	T{
+Best highlighting mode of the terminal
+T}
+A_UNDERLINE	Underlining
+A_REVERSE	Reverse video
+A_BLINK	Blinking
+A_DIM	Half bright
+A_BOLD	Extra bright or bold
+A_PROTECT	Protected mode
+A_INVIS	Invisible or blank mode
+A_ALTCHARSET	Alternate character set
+A_ITALIC	Italics (non-X/Open extension)
+A_CHARTEXT	Bit-mask to extract a character
+A_COLOR	T{
+Bit-mask to extract a color (legacy routines)
+T}
 .TE
 .RE
 .PP
 These video attributes are supported by \fBattr_on\fP and related functions
 (which also support the attributes recognized by \fBattron\fP, etc.):
+.PP
 .RS
 .TS
-l l
-_ _ _
-l l .
-\fIName\fR	\fIDescription\fR
-\fBWA_HORIZONTAL\fR	Horizontal highlight
-\fBWA_LEFT\fR	Left highlight
-\fBWA_LOW\fR	Low highlight
-\fBWA_RIGHT\fR	Right highlight
-\fBWA_TOP\fR	Top highlight
-\fBWA_VERTICAL\fR	Vertical highlight
+Lb Lb
+Lb Lx.
+Name	Description
+_
+WA_HORIZONTAL	Horizontal highlight
+WA_LEFT	Left highlight
+WA_LOW	Low highlight
+WA_RIGHT	Right highlight
+WA_TOP	Top highlight
+WA_VERTICAL	Vertical highlight
 .TE
 .RE
 .PP
 The return values of many of these routines are not meaningful (they are
 implemented as macro-expanded assignments and simply return their argument).
-The SVr4 manual page claims (falsely) that these routines always return \fB1\fR.
+The SVr4 manual page claims (falsely) that these routines always return \fB1\fP.
+.\" ---------------------------------------------------------------------------
+.SH RETURN VALUE
+All routines return the integer \fBOK\fP on success, or \fBERR\fP on failure.
+.PP
+X/Open Curses does not specify any error conditions.
+.PP
+This implementation
+.bP
+returns an error if the window pointer is null.
+.bP
+returns an error if the color pair parameter
+for \fBwcolor_set\fP is outside the range 0..COLOR_PAIRS\-1.
+.bP
+does not return an error if either of the parameters of \fBwattr_get\fP
+used for retrieving attribute or color pair values is \fBNULL\fP.
+.PP
+Functions prefixed with \*(``mv\*('' first perform cursor movement and
+fail if the position
+.RI ( y ,
+.IR x )
+is outside the window boundaries.
 .\" ---------------------------------------------------------------------------
 .SH NOTES
 These functions may be macros:
 .sp
 .RS
-\fBattroff\fR, \fBwattroff\fR, \fBattron\fR, \fBwattron\fR,
-\fBattrset\fR, \fBwattrset\fR, \fBstandend\fR and \fBstandout\fR.
+\fBattroff\fP, \fBwattroff\fP, \fBattron\fP, \fBwattron\fP,
+\fBattrset\fP, \fBwattrset\fP, \fBstandend\fP and \fBstandout\fP.
 .RE
 .PP
 Color pair values can only be OR'd with attributes if the pair
 number is less than 256.
 The alternate functions such as \fBcolor_set\fP can pass a color pair
 value directly.
-However, ncurses ABI 4 and 5 simply OR this value
+However, \fI\%ncurses\fP ABI 4 and 5 simply OR this value
 within the alternate functions.
-You must use ncurses ABI 6 to support more than 256 color pairs.
+You must use \fI\%ncurses\fP ABI 6 to support more than 256 color pairs.
+.\" ---------------------------------------------------------------------------
+.SH EXTENSIONS
+This implementation provides the \fBA_ITALIC\fP attribute for terminals
+which have the \fBenter_italics_mode\fP (\fBsitm\fP)
+and \fBexit_italics_mode\fP (\fBritm\fP) capabilities.
+Italics are not mentioned in X/Open Curses.
+Unlike the other video attributes, \fBA_ITALIC\fP is unrelated
+to the \fBset_attributes\fP capabilities.
+This implementation makes the assumption that
+\fBexit_attribute_mode\fP may also reset italics.
+.PP
+Each of the functions added by XSI Curses has a parameter \fIopts\fP,
+which X/Open Curses still (after more than twenty years) documents
+as reserved for future use, saying that it should be \fBNULL\fP.
+This implementation uses that parameter in ABI 6 for the functions which
+have a color pair parameter to support \fIextended color pairs\fP:
+.bP
+For functions which modify the color, e.g.,
+\fBwattr_set\fP and \fBwattr_on\fP,
+if \fIopts\fP is set it is treated as a pointer to \fBint\fP,
+and used to set the color pair instead of the \fBshort\fP \fIpair\fP parameter.
+.bP
+For functions which retrieve the color, e.g.,
+\fBwattr_get\fP,
+if \fIopts\fP is set it is treated as a pointer to \fBint\fP,
+and used to retrieve the color pair as an \fBint\fP value,
+in addition to
+retrieving it via the standard pointer to \fBshort\fP parameter.
+.bP
+For functions which turn attributes off, e.g.,
+\fBwattr_off\fP,
+the \fIopts\fP parameter is ignored except
+except to check that it is \fBNULL\fP.
+.\" ---------------------------------------------------------------------------
+.SH PORTABILITY
+These functions are described in X/Open Curses, Issue 4.
+The standard defined the dedicated type for highlights,
+\fBattr_t\fP, which was not defined in SVr4 curses.
+The functions taking \fBattr_t\fP arguments were not supported under SVr4.
+.PP
+Very old versions of this library did not force an update of the screen
+when changing the attributes.
+Use \fBtouchwin\fP to force the screen to match the updated attributes.
+.PP
+X/Open Curses states that whether the traditional functions
+\fBattron\fP/\fBattroff\fP/\fBattrset\fP can manipulate attributes other than
+\fBA_BLINK\fP, \fBA_BOLD\fP, \fBA_DIM\fP, \fBA_REVERSE\fP, \fBA_STANDOUT\fP, or
+\fBA_UNDERLINE\fP is \*(``unspecified\*(''.
+Under this implementation as well as
+SVr4 curses, these functions correctly manipulate all other highlights
+(specifically, \fBA_ALTCHARSET\fP, \fBA_PROTECT\fP, and \fBA_INVIS\fP).
+.PP
+X/Open Curses added these entry points:
+.sp
+.RS
+\fBattr_get\fP, \fBattr_on\fP,
+\fBattr_off\fP, \fBattr_set\fP, \fBwattr_on\fP, \fBwattr_off\fP,
+\fBwattr_get\fP, \fBwattr_set\fP
+.RE
+.PP
+The new functions are intended to work with
+a new series of highlight macros prefixed with \fBWA_\fP.
+The older macros have direct counterparts in the newer set of names:
+.PP
+.RS
+.ne 9
+.TS
+Lb Lb
+Lb Lx.
+Name	Description
+_
+WA_NORMAL	Normal display (no highlight)
+WA_STANDOUT	T{
+Best highlighting mode of the terminal
+T}
+WA_UNDERLINE	Underlining
+WA_REVERSE	Reverse video
+WA_BLINK	Blinking
+WA_DIM	Half bright
+WA_BOLD	Extra bright or bold
+WA_ALTCHARSET	Alternate character set
+.TE
+.RE
+.PP
+X/Open Curses does not assign values to these symbols,
+nor does it state whether or not they are related to the
+similarly-named A_NORMAL, etc.:
+.bP
+X/Open Curses specifies that each pair of corresponding \fBA_\fP
+and \fBWA_\fP-using functions operates on the same current-highlight
+information.
+.bP
+However, in some implementations, those symbols have unrelated values.
+.IP
+For example, the Solaris \fIxpg4\fP (X/Open) curses declares
+\fBattr_t\fP to be an unsigned short integer (16-bits),
+while \fBchtype\fP is a unsigned integer (32-bits).
+The \fBWA_\fP symbols in this case are different from the \fBA_\fP symbols
+because they are used for a smaller datatype which does not
+represent \fBA_CHARTEXT\fP or \fBA_COLOR\fP.
+.IP
+In this implementation (as in many others), the values happen to be
+the same because it simplifies copying information between
+\fBchtype\fP and \fBcchar_t\fP variables.
+.bP
+Because \fI\%ncurses\fP's \fBattr_t\fP can hold a color pair
+(in the \fBA_COLOR\fP field),
+a call to
+\fBwattr_on\fP,
+\fBwattr_off\fP, or
+\fBwattr_set\fP
+may alter the window's color.
+If the color pair information in the attribute parameter is zero,
+no change is made to the window's color.
+.IP
+This is consistent with SVr4 curses;
+X/Open Curses does not specify this.
+.PP
+The X/Open Curses extended conformance level adds new highlights
+\fBA_HORIZONTAL\fP, \fBA_LEFT\fP, \fBA_LOW\fP, \fBA_RIGHT\fP, \fBA_TOP\fP,
+\fBA_VERTICAL\fP (and corresponding \fBWA_\fP macros for each).
+As of August 2013,
+no known terminal provides these highlights
+(i.e., via the \fBsgr1\fP capability).
 .\" ---------------------------------------------------------------------------
 .SH HISTORY
 X/Open Curses is largely based on SVr4 curses,
@@ -391,25 +511,26 @@ the format and size of the defined constants
 as well as clues such as the alternate character set implementation.
 A 32-bit library can be used on a 64-bit system,
 but not necessarily the reverse.
-.RS
+.PP
 .TS
-l l l l l l
-_ _ _ _ _ _
-l l l l l l .
-\fIYear\fR	\fISystem\fR	\fIArch\fP	\fIColor\fR	\fIChar\fR	\fINotes\fR
-1992	Solaris 5.2	32	6	17	SVr4 curses
-1992	HPUX 9	32	no	8	SVr2 curses
-1992	AIX 3.2	32	no	23	SVr2 curses
-1994	OSF/1 r3	32	no	23	SVr2 curses
-1995	HP-UX 10.00	32	6	16	SVr3 \*(``curses_colr\*(''
-1995	HP-UX 10.00	32	6	8	SVr4, X/Open curses
-1995	Solaris 5.4	32/64	7	16	X/Open curses
-1996	AIX 4.2	32	7	16	X/Open curses
-1996	OSF/1 r4	32	6	16	X/Open curses
-1997	HP-UX 11.00	32	6	8	X/Open curses
-2000	U/Win	32/64	7/31	16	uses \fBchtype\fP
+Lb  Lb Lb  Cb  S   Lb
+Lb2 Lb Lb2 Lb2 Lb2 Lb
+L   L  L   L   L   Lx.
+\&	\&	\&	Bits	\&
+Year	System	Arch	Color	Char	Notes
+_
+1992	Solaris 5.2	32	6	17	SVr4 \fIcurses\fP
+1992	HP-UX 9	32	no	8	SVr2 \fIcurses\fP
+1992	AIX 3.2	32	no	23	SVr2 \fIcurses\fP
+1994	OSF/1 r3	32	no	23	SVr2 \fIcurses\fP
+1995	HP-UX 10.00	32	6	16	SVr3 \fIcurses_colr\fP
+1995	HP-UX 10.00	32	6	8	SVr4, X/Open \fIcurses\fP
+1995	Solaris 5.4	32/64	7	16	X/Open \fIcurses\fP
+1996	AIX 4.2	32	7	16	X/Open \fIcurses\fP
+1996	OSF/1 r4	32	6	16	X/Open \fIcurses\fP
+1997	HP-UX 11.00	32	6	8	X/Open \fIcurses\fP
+2000	U/Win	32/64	7/31	16	uses \fIchtype\fP
 .TE
-.RE
 .PP
 Notes:
 .RS 3
@@ -424,8 +545,9 @@ That version of curses was dropped with HP-UX 11.30 in 2006.
 Regarding OSF/1 (and Tru64),
 .bP
 These used 64-bit hardware.
-Like ncurses, the OSF/1 curses interface is not customized for 32-bit
-and 64-bit versions.
+Like \fI\%ncurses\fP,
+the OSF/1 curses interface is not customized for 32-bit and 64-bit
+versions.
 .bP
 Unlike other systems which evolved from AT&T code,
 OSF/1 provided a new implementation for X/Open curses.
@@ -459,147 +581,18 @@ members are not specified in X/Open Curses) could be extended as needed.
 Other interfaces are rarely used now:
 .bP
 BSD curses was improved slightly in 1993/1994 using Keith Bostic's
-modification to make the library 8-bit clean for \fBnvi\fP.
+modification to make the library 8-bit clean for \fBnvi\fP(1).
 He moved \fIstandout\fP attribute to a structure member.
 .IP
-The resulting 4.4BSD curses was replaced by ncurses over the next ten years.
+The resulting 4.4BSD curses was replaced by \fI\%ncurses\fP over the
+next ten years.
 .bP
 U/Win is rarely used now.
 .\" ---------------------------------------------------------------------------
-.SH EXTENSIONS
-.PP
-This implementation provides the \fBA_ITALIC\fP attribute for terminals
-which have the \fBenter_italics_mode\fP (\fBsitm\fP)
-and \fBexit_italics_mode\fP (\fBritm\fP) capabilities.
-Italics are not mentioned in X/Open Curses.
-Unlike the other video attributes, \fBA_ITALIC\fP is unrelated
-to the \fBset_attributes\fP capabilities.
-This implementation makes the assumption that
-\fBexit_attribute_mode\fP may also reset italics.
-.PP
-Each of the functions added by XSI Curses has a parameter \fIopts\fP,
-which X/Open Curses still (after more than twenty years) documents
-as reserved for future use, saying that it should be \fBNULL\fP.
-This implementation uses that parameter in ABI 6 for the functions which
-have a color-pair parameter to support \fIextended color pairs\fP:
-.bP
-For functions which modify the color, e.g.,
-\fBwattr_set\fP,
-if \fIopts\fP is set it is treated as a pointer to \fBint\fP,
-and used to set the color pair instead of the \fBshort\fP \fIpair\fP parameter.
-.bP
-For functions which retrieve the color, e.g.,
-\fBwattr_get\fP,
-if \fIopts\fP is set it is treated as a pointer to \fBint\fP,
-and used to retrieve the color pair as an \fBint\fP value,
-in addition
-retrieving it via the standard pointer to \fBshort\fP parameter.
-.PP
-The remaining functions which have \fIopts\fP,
-but do not manipulate color,
-e.g., \fBwattr_on\fP and \fBwattr_off\fP
-are not used by this implementation except to check that they are \fBNULL\fP.
-.\" ---------------------------------------------------------------------------
-.SH PORTABILITY
-These functions are supported in the XSI Curses standard, Issue 4.
-The standard defined the dedicated type for highlights,
-\fBattr_t\fR, which was not defined in SVr4 curses.
-The functions taking \fBattr_t\fR arguments were not supported under SVr4.
-.PP
-Very old versions of this library did not force an update of the screen
-when changing the attributes.
-Use \fBtouchwin\fR to force the screen to match the updated attributes.
-.PP
-The XSI Curses standard states that whether the traditional functions
-\fBattron\fR/\fBattroff\fR/\fBattrset\fR can manipulate attributes other than
-\fBA_BLINK\fR, \fBA_BOLD\fR, \fBA_DIM\fR, \fBA_REVERSE\fR, \fBA_STANDOUT\fR, or
-\fBA_UNDERLINE\fR is \*(``unspecified\*(''.
-Under this implementation as well as
-SVr4 curses, these functions correctly manipulate all other highlights
-(specifically, \fBA_ALTCHARSET\fR, \fBA_PROTECT\fR, and \fBA_INVIS\fR).
-.PP
-XSI Curses added these entry points:
-.sp
-.RS
-\fBattr_get\fR, \fBattr_on\fR,
-\fBattr_off\fR, \fBattr_set\fR, \fBwattr_on\fR, \fBwattr_off\fR,
-\fBwattr_get\fR, \fBwattr_set\fR
-.RE
-.PP
-The new functions are intended to work with
-a new series of highlight macros prefixed with \fBWA_\fR.
-The older macros have direct counterparts in the newer set of names:
-.PP
-.RS
-.ne 9
-.TS
-l l
-_ _ _
-l l .
-\fIName\fR	\fIDescription\fR
-\fBWA_NORMAL\fR	Normal display (no highlight)
-\fBWA_STANDOUT\fR	Best highlighting mode of the terminal.
-\fBWA_UNDERLINE\fR	Underlining
-\fBWA_REVERSE\fR	Reverse video
-\fBWA_BLINK\fR	Blinking
-\fBWA_DIM\fR	Half bright
-\fBWA_BOLD\fR	Extra bright or bold
-\fBWA_ALTCHARSET\fR	Alternate character set
-.TE
-.RE
-.PP
-XSI curses does not assign values to these symbols,
-nor does it state whether or not they are related to the
-similarly-named A_NORMAL, etc.:
-.bP
-The XSI curses standard specifies that each pair of corresponding \fBA_\fR
-and \fBWA_\fR-using functions operates on the same current-highlight
-information.
-.bP
-However, in some implementations, those symbols have unrelated values.
-.IP
-For example, the Solaris \fIxpg4\fP (X/Open) curses declares
-\fBattr_t\fP to be an unsigned short integer (16-bits),
-while \fBchtype\fP is a unsigned integer (32-bits).
-The \fBWA_\fP symbols in this case are different from the \fBA_\fP symbols
-because they are used for a smaller datatype which does not
-represent \fBA_CHARTEXT\fP or \fBA_COLOR\fP.
-.IP
-In this implementation (as in many others), the values happen to be
-the same because it simplifies copying information between
-\fBchtype\fP and \fBcchar_t\fP variables.
-.PP
-The XSI standard extended conformance level adds new highlights
-\fBA_HORIZONTAL\fR, \fBA_LEFT\fR, \fBA_LOW\fR, \fBA_RIGHT\fR, \fBA_TOP\fR,
-\fBA_VERTICAL\fR (and corresponding \fBWA_\fR macros for each).
-As of August 2013,
-no known terminal provides these highlights
-(i.e., via the \fBsgr1\fP capability).
-.\" ---------------------------------------------------------------------------
-.SH RETURN VALUE
-All routines return the integer \fBOK\fR on success, or \fBERR\fP on failure.
-.PP
-X/Open does not define any error conditions.
-.PP
-This implementation
-.bP
-returns an error if the window pointer is null.
-.bP
-returns an error if the color pair parameter
-for \fBwcolor_set\fP is outside the range 0..COLOR_PAIRS\-1.
-.bP
-does not return an error if either of the parameters of \fBwattr_get\fP
-used for retrieving attribute or color-pair values is \fBNULL\fP.
-.PP
-Functions with a \*(``mv\*('' prefix first perform a cursor movement using
-\fBwmove\fP, and return an error if the position is outside the window,
-or if the window pointer is null.
-.\" ---------------------------------------------------------------------------
 .SH SEE ALSO
-.na
-\fBcurses\fR(3X),
-\fBcurs_addch\fR(3X),
-\fBcurs_addstr\fR(3X),
-\fBcurs_bkgd\fR(3X),
-\fBcurs_printw\fR(3X),
-\fBcurs_variables\fR(3X)
+\fB\%curses\fP(3X),
+\fB\%curs_addch\fP(3X),
+\fB\%curs_addstr\fP(3X),
+\fB\%curs_bkgd\fP(3X),
+\fB\%curs_printw\fP(3X),
+\fB\%curs_variables\fP(3X)
diff --git a/contrib/ncurses/man/curs_beep.3x b/contrib/ncurses/man/curs_beep.3x
index bea861bc9ce0..9806f42b3ad8 100644
--- a/contrib/ncurses/man/curs_beep.3x
+++ b/contrib/ncurses/man/curs_beep.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2005,2010 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,35 +27,37 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_beep.3x,v 1.14 2020/02/02 23:34:34 tom Exp $
-.TH curs_beep 3X ""
+.\" $Id: curs_beep.3x,v 1.29 2024/04/20 21:20:07 tom Exp $
+.TH curs_beep 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
-\fBbeep\fR, \fBflash\fR \- \fBcurses\fR bell and screen flash routines
+\fB\%beep\fP,
+\fB\%flash\fP \-
+ring the (visual) bell of the terminal with \fIcurses\fR
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
+.nf
+\fB#include <curses.h>
 .PP
-\fBint beep(void);\fR
-.br
-\fBint flash(void);\fR
-.br
+\fBint beep(void);
+\fBint flash(void);
+.fi
 .SH DESCRIPTION
-The \fBbeep\fR and \fBflash\fR routines are used to alert the terminal user.
-The routine \fBbeep\fR sounds an audible alarm on the terminal, if possible;
+The \fBbeep\fP and \fBflash\fP routines are used to alert the terminal user.
+The routine \fBbeep\fP sounds an audible alarm on the terminal, if possible;
 otherwise it flashes the screen (visible bell).
-The routine \fBflash\fR
+The routine \fBflash\fP
 flashes the screen, and if that is not possible, sounds the alert.
 If neither
 alert is possible, nothing happens.
 Nearly all terminals have an audible alert
 (bell or beep), but only some can flash the screen.
 .SH RETURN VALUE
-These routines return \fBOK\fR if they succeed in beeping or flashing,
-\fBERR\fR otherwise.
+These routines return \fBOK\fP if they succeed in beeping or flashing,
+\fBERR\fP otherwise.
 .SH EXTENSIONS
-SVr4's beep and flash routines always returned \fBOK\fR, so it was not
+SVr4's beep and flash routines always returned \fBOK\fP, so it was not
 possible to tell when the beep or flash failed.
 .SH PORTABILITY
-These functions are described in the XSI Curses standard, Issue 4.
-Like SVr4, it specifies that they always return \fBOK\fR.
+These functions are described in X/Open Curses, Issue 4.
+Like SVr4, it specifies that they always return \fBOK\fP.
 .SH SEE ALSO
-\fBcurses\fR(3X)
+\fB\%curses\fP(3X)
diff --git a/contrib/ncurses/man/curs_bkgd.3x b/contrib/ncurses/man/curs_bkgd.3x
index 051d5fda0683..25ba1f9f72c8 100644
--- a/contrib/ncurses/man/curs_bkgd.3x
+++ b/contrib/ncurses/man/curs_bkgd.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2015,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,135 +27,200 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_bkgd.3x,v 1.31 2020/10/17 23:12:52 tom Exp $
+.\" $Id: curs_bkgd.3x,v 1.61 2024/04/20 18:54:36 tom Exp $
+.TH curs_bkgd 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.TH curs_bkgd 3X ""
 .SH NAME
-\fBbkgdset\fR, \fBwbkgdset\fR,
-\fBbkgd\fR, \fBwbkgd\fR,
-\fBgetbkgd\fR \- \fBcurses\fR window background manipulation routines
+\fB\%bkgdset\fP,
+\fB\%wbkgdset\fP,
+\fB\%bkgd\fP,
+\fB\%wbkgd\fP,
+\fB\%getbkgd\fP \-
+manipulate background of a \fIcurses\fR window of characters
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.PP
-\fBvoid bkgdset(chtype \fP\fIch\fP\fB);\fR
-.br
-\fBvoid wbkgdset(WINDOW *\fP\fIwin, chtype \fP\fIch\fP\fB);\fR
-.sp
-\fBint bkgd(chtype \fP\fIch\fP\fB);\fR
-.br
-\fBint wbkgd(WINDOW *\fP\fIwin\fP\fB, chtype \fP\fIch\fP\fB);\fR
-.sp
-\fBchtype getbkgd(WINDOW *\fP\fIwin\fP\fB);\fR
-.br
-.SH DESCRIPTION
-.SS bkgdset
-The \fBbkgdset\fR and \fBwbkgdset\fR routines manipulate the
-background of the named window.
-The window background is a \fBchtype\fR consisting of
-any combination of attributes (i.e., rendition) and a character.
-The attribute part of the background is combined (OR'ed) with all non-blank
-characters that are written into the window with \fBwaddch\fR.
-Both the character and attribute parts of the background are combined with
-the blank characters.
-The background becomes a property of the
-character and moves with the character through any scrolling and
-insert/delete line/character operations.
-.PP
-To the extent possible on a particular terminal,
-the attribute part of the background is displayed
-as the graphic rendition of the character put on the screen.
-.SS bkgd
-.PP
-The \fBbkgd\fR and \fBwbkgd\fR functions
-set the background property of the current or specified window
-and then apply this setting to every character position in that window.
-According to X/Open Curses, it should do this:
+.nf
+\fB#include <curses.h>
+.PP
+\fBint bkgd(chtype \fIch\fP);
+\fBint wbkgd(WINDOW *\fIwin\fP, chtype \fIch\fP);
+.PP
+\fBvoid bkgdset(chtype \fIch\fP);
+\fBvoid wbkgdset(WINDOW *\fIwin\fP, chtype \fIch\fP);
 .PP
+\fBchtype getbkgd(WINDOW *\fIwin\fP);
+.fi
+.SH DESCRIPTION
+The
+.I background
+of a
+.I curses
+window
+(in the library's non-\*(``wide\*('' configuration)
+is a
+.I \%chtype
+combining a set of attributes
+(see \fB\%curs_attr\fP(3X))
+with a character called the
+.I "blank character."
+.PP
+The blank character is a spacing character that populates a window's
+character cells when their contents are erased without replacement.
+The background's attributes are combined with all non-blank characters
+written to the window,
+as with the \fB\%waddch\fP(3X) and \fB\%winsch\fP(3X) families of
+functions.
+.PP
+The blank character and attributes of the background combine with
+characters written to the window as described below.
+The background becomes a property of the character and moves with it
+through any scrolling and insert/delete line/character operations.
+.PP
+To the extent possible on a given terminal,
+the attribute part of the background is displayed as the graphic
+rendition of the character put on the screen.
+.SS "bkgd, wbkgd"
+\fB\%bkgd\fP and \fB\%wbkgd\fP set the background property of
+\fB\%stdscr\fP or the specified window and then apply this setting to
+every character cell in that window.
 .bP
-The rendition of every character on the screen is changed to
-the new background rendition.
+The rendition of every character in the window changes to the new
+background rendition.
 .bP
-Wherever the former background character
-appears, it is changed to the new background character.
-.PP
-Neither X/Open Curses nor the SVr4 manual pages give details about
-the way the rendition of characters on the screen is updated when
-\fBbkgd\fP or \fBwbkgd\fP is used to change the background character.
-.PP
-This implementation, like SVr4 curses, does not store the background
-and window attribute contributions to each cell separately.
-It updates the rendition by comparing the character, non-color attributes and
-colors contained in the background.
-For each cell in the window, whether or not it is blank:
+Wherever the former background character appears,
+it changes to the new background character.
+.PP
+.I \%ncurses
+updates the rendition of each character cell by comparing the character,
+non-color attributes,
+and colors.
+The library applies to following procedure to each cell in the window,
+whether or not it is blank.
 .bP
-The library first compares the \fIcharacter\fP,
-and if it matches the current character part of the background,
-it replaces that with the new background character.
+.I \%ncurses
+first compares the cell's character to the previously specified blank
+character;
+if they match,
+.I \%ncurses
+writes the new blank character to the cell.
 .bP
-The library then checks if the cell uses color,
-i.e., its color pair value is nonzero.
-If not, it simply replaces the attributes and color pair in the
-cell with those from the new background character.
+.I \%ncurses
+then checks if the cell uses color,
+that is,
+its color pair value is nonzero.
+If not,
+it simply replaces the attributes and color pair in the cell with those
+from the new background character.
 .bP
 If the cell uses color,
-and that matches the color in the current background,
-the library removes attributes
-which may have come from the current background 
-and adds attributes from the new background.
-It finishes by setting the cell
-to use the color from the new background.
+and its background color matches that of the current window background,
+.I \%ncurses
+removes attributes that may have come from the current background and
+adds those from the new background.
+It finishes by setting the cell's background to use the new window
+background color.
 .bP
 If the cell uses color,
-and that does not match the color in the current background,
-the library updates only the non-color attributes,
-first removing those which may have come from the current background,
+and its background color does not match that of the current window
+background,
+.I \%ncurses
+updates only the non-color attributes,
+first removing those that may have come from the current background,
 and then adding attributes from the new background.
 .PP
-If the background's character value is zero, a space is assumed.
+.I \%ncurses
+treats a background character value of zero (0) as a blank character.
 .PP
 If the terminal does not support color,
-or if color has not been started with \fBstart_color\fP,
-the new background character's color attribute will be ignored.
+or if color has not been initialized with \fB\%start_color\fP(3X),
+.I \%ncurses
+ignores the new background character's color attribute.
+.SS "bkgdset, wbkgdset"
+\fB\%bkgdset\fP and \fB\%wbkgdset\fP manipulate the background of
+the applicable window,
+without updating the character cells as \fB\%bkgd\fP and
+\fB\%wbkgd\fP do;
+only future writes reflect the updated background.
 .SS getbkgd
-.PP
-The \fBgetbkgd\fR function returns the given window's current background
-character/attribute pair.
+\fB\%getbkgd\fP obtains the given window's background character and
+attribute combination.
 .SH RETURN VALUE
+Functions returning an \fIint\fP return \fBOK\fP on success.
+\fB\%bkgd\fP returns \fBERR\fP if the library has not been initialized.
+\fB\%wbkgd\fP and \fB\%getbkgd\fP return \fBERR\fP if a \fI\%WINDOW\fP
+pointer argument is null.
 .PP
-These functions are described in the XSI Curses standard, Issue 4.
-It specifies that \fBbkgd\fR and \fBwbkgd\fR return \fBERR\fR on failure,
-but gives no failure conditions.
+\fB\%bkgdset\fP and \fBwbkgdset\fP do not return a value.
 .PP
-The routines \fBbkgd\fR and \fBwbkgd\fR return the integer \fBOK\fR,
-unless the library has not been initialized.
-.PP
-In contrast,
-the SVr4.0 manual says \fBbkgd\fR and \fBwbkgd\fR may return \fBOK\fP
-"or a non-negative integer if \fBimmedok\fR is set",
-which refers to the return value from \fBwrefresh\fP
-(used to implement the immediate repainting).
-The SVr4 curses \fBwrefresh\fP returns the number of characters
-written to the screen during the refresh.
-This implementation does not do that.
+\fB\%getbkgd\fP returns a window's background character and attribute
+combination.
 .SH NOTES
+Unusually,
+there is no \fB\%wgetbkgd\fP function;
+\fB\%getbkgd\fP behaves as one would expect \fB\%wgetbkgd\fP to,
+accepting a \fI\%WINDOW\fP pointer argument.
 .PP
-Note that \fBbkgdset\fR and \fBbkgd\fR may be macros.
+\fB\%bkgd\fP and
+\fB\%bkgdset\fP
+may be implemented as macros.
 .PP
 X/Open Curses mentions that the character part of the background must
 be a single-byte value.
-This implementation, like SVr4, checks to ensure that,
+\fI\%ncurses\fP,
+like SVr4 \fIcurses\fP,
+checks to ensure that,
 and will reuse the old background character if the check fails.
 .SH PORTABILITY
-.PP
-These functions are described in the XSI Curses standard, Issue 4
-(X/Open Curses).
+X/Open Curses,
+Issue 4 describes these functions.
+It specifies that
+\fB\%bkgd\fP,
+\fB\%wbkgd\fP,
+and
+\fB\%getbkgd\fP
+return \fBERR\fP on failure
+(in the case of the last,
+this value is cast to
+.IR \%chtype ),
+but describes no failure conditions.
+.PP
+The SVr4.0 manual says that \fB\%bkgd\fP and \fB\%wbkgd\fP may return
+\fBOK\fP
+\*(``or a non-negative integer if \fB\%immedok\fP is set\*('',
+which refers to the return value from \fB\%wrefresh\fP(3X),
+used to implement the immediate repainting.
+SVr4 \fIcurses\fP's \fB\%wrefresh\fP returns the number of characters
+written to the screen during the refresh.
+\fI\%ncurses\fP does not do that.
+.PP
+Neither X/Open Curses nor the SVr4 manual pages detail how the rendition
+of characters on the screen updates when \fB\%bkgd\fP or \fB\%wbkgd\fP
+changes the background character.
+.IR \%ncurses ,
+like SVr4
+.IR curses ,
+does not
+(in its non-\*(``wide\*('' configuration)
+store the background and window attribute contributions to each
+character cell separately.
 .SH SEE ALSO
-.na
+\fB\%curs_bkgrnd\fP(3X) describes the corresponding functions in the
+\*(``wide\*('' configuration of
+.IR \%ncurses .
 .PP
-\fBcurses\fR(3X),
-\fBcurs_addch\fR(3X),
-\fBcurs_attr\fR(3X),
-\fBcurs_outopts\fR(3X)
+\fB\%curses\fP(3X),
+\fB\%curs_addch\fP(3X),
+\fB\%curs_attr\fP(3X)
diff --git a/contrib/ncurses/man/curs_bkgrnd.3x b/contrib/ncurses/man/curs_bkgrnd.3x
index 84a2984bc0ec..2551924c11a3 100644
--- a/contrib/ncurses/man/curs_bkgrnd.3x
+++ b/contrib/ncurses/man/curs_bkgrnd.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 2002-2015,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,95 +27,190 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_bkgrnd.3x,v 1.12 2020/10/17 23:13:15 tom Exp $
+.\" $Id: curs_bkgrnd.3x,v 1.42 2024/04/20 18:54:36 tom Exp $
+.TH curs_bkgrnd 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.TH curs_bkgrnd 3X ""
 .SH NAME
-\fBbkgrnd\fR,
-\fBwbkgrnd\fR,
-\fBbkgrndset\fR,
-\fBwbkgrndset\fR,
-\fBgetbkgrnd\fR,
-\fBwgetbkgrnd\fR \- \fBcurses\fR window complex background manipulation routines
+\fB\%bkgrnd\fP,
+\fB\%wbkgrnd\fP,
+\fB\%bkgrndset\fP,
+\fB\%wbkgrndset\fP,
+\fB\%getbkgrnd\fP,
+\fB\%wgetbkgrnd\fP \-
+manipulate background of a \fIcurses\fP window of wide characters
 .SH SYNOPSIS
+.nf
+\fB#include <curses.h>
 .PP
-.B #include <curses.h>
-.sp
-\fBint bkgrnd(\fR\fB const cchar_t *\fR\fIwch\fR\fB);\fR
-.br
-\fBint wbkgrnd(\fR\fB WINDOW *\fR\fIwin\fR\fB, const cchar_t *\fR\fIwch\fR\fB);\fR
-.sp
-\fBvoid bkgrndset(const cchar_t *\fR\fIwch\fR \fB);\fR
-.br
-\fBvoid wbkgrndset(WINDOW *\fR\fIwin\fR\fB, const cchar_t *\fR\fIwch\fR\fB);\fR
-.sp
-\fBint getbkgrnd(cchar_t *\fR\fIwch\fR\fB);\fR
-.br
-\fBint wgetbkgrnd(WINDOW *\fR\fIwin\fR\fB, cchar_t *\fR\fIwch\fR\fB);\fR
-.br
+\fBint bkgrnd(const cchar_t *\fIwch\fP);
+\fBint wbkgrnd(WINDOW *\fIwin\fP, const cchar_t *\fIwch\fP);
+.PP
+\fBvoid bkgrndset(const cchar_t *\fIwch\fP);
+\fBvoid wbkgrndset(WINDOW *\fIwin\fP, const cchar_t *\fIwch\fP);
+.PP
+\fBint getbkgrnd(cchar_t *\fIwch\fP);
+\fBint wgetbkgrnd(WINDOW *\fIwin\fP, cchar_t *\fIwch\fP);
+.fi
 .SH DESCRIPTION
-.SS bkgrndset
+The
+.I background
+of a
+.I curses
+window
+(in the library's \*(``wide\*('' configuration)
+is a
+.I \%cchar_t
+combining a set of attributes
+(see \fB\%curs_attr\fP(3X))
+with a complex character called the
+.I "blank character."
 .PP
-The \fBbkgrndset\fR and \fBwbkgrndset\fR routines manipulate the
-background of the named window.
-The window background is a \fBcchar_t\fR consisting of
-any combination of attributes (i.e., rendition) and a complex character.
-The attribute part of the background is combined (OR'ed) with all non-blank
-characters that are written into the window with \fBwaddch\fR.
-Both
-the character and attribute parts of the background are combined with
-the blank characters.
-The background becomes a property of the
-character and moves with the character through any scrolling and
-insert/delete line/character operations.
+The blank character is a spacing character that populates a window's
+character cells when their contents are erased without replacement.
+The background's attributes are combined with all non-blank characters
+written to the window,
+as with the \fB\%wadd_wch\fP(3X) and \fB\%wins_wch\fP(3X) families of
+functions.
 .PP
-To the extent possible on a
-particular terminal, the attribute part of the background is displayed
-as the graphic rendition of the character put on the screen.
-.SS bkgrnd
+The blank character and attributes of the background combine with
+characters written to the window as described below.
+The background becomes a property of the character and moves with it
+through any scrolling and insert/delete line/character operations.
 .PP
-The \fBbkgrnd\fR and \fBwbkgrnd\fR functions
-set the background property of the current or specified window
-and then apply this setting to every character position in that window:
+To the extent possible on a given terminal,
+the attribute part of the background is displayed as the graphic
+rendition of the character put on the screen.
+.SS "bkgrnd, wbkgrnd"
+\fB\%bkgrnd\fP and \fB\%wbkgrnd\fP set the background property of
+\fB\%stdscr\fP or the specified window and then apply this setting to
+every character cell in that window.
 .bP
-The rendition of every character on the screen is changed to
-the new background rendition.
+The rendition of every character in the window changes to the new
+background rendition.
 .bP
-Wherever the former background character
-appears, it is changed to the new background character.
-.SS getbkgrnd
+Wherever the former background character appears,
+it changes to the new background character.
 .PP
-The \fBgetbkgrnd\fR function returns the given window's current background
-character/attribute pair via the \fBwch\fR pointer.
-If the given window pointer is null,
-the character is not updated (but no error returned).
-.SH NOTES
-Note that
-\fBbkgrnd\fR,
-\fBbkgrndset\fR, and
-\fBgetbkgrnd\fR
-may be macros.
+.I \%ncurses
+updates the rendition of each character cell by comparing the character,
+non-color attributes,
+and colors.
+The library applies to following procedure to each cell in the window,
+whether or not it is blank.
+.bP
+.I \%ncurses
+first compares the cell's character to the previously specified blank
+character;
+if they match,
+.I \%ncurses
+writes the new blank character to the cell.
+.bP
+.I \%ncurses
+then checks if the cell uses color,
+that is,
+its color pair value is nonzero.
+If not,
+it simply replaces the attributes and color pair in the cell with those
+from the new background character.
+.bP
+If the cell uses color,
+and its background color matches that of the current window background,
+.I \%ncurses
+removes attributes that may have come from the current background and
+adds those from the new background.
+It finishes by setting the cell's background to use the new window
+background color.
+.bP
+If the cell uses color,
+and its background color does not match that of the current window
+background,
+.I \%ncurses
+updates only the non-color attributes,
+first removing those that may have come from the current background,
+and then adding attributes from the new background.
 .PP
-X/Open Curses does not provide details on how the rendition is changed.
-This implementation follows the approach used in SVr4 curses,
-which is explained in the manual page for \fBwbkgd\fP.
-.SH RETURN VALUE
+.I \%ncurses
+treats a background character value of zero (0) as a blank character.
 .PP
-The \fBbkgrndset\fR and \fBwbkgrndset\fR routines do not return a value.
+If the terminal does not support color,
+or if color has not been initialized with \fB\%start_color\fP(3X),
+.I \%ncurses
+ignores the new background character's color attribute.
+.SS "bkgrndset, wbkgrndset"
+\fB\%bkgrndset\fP and \fB\%wbkgrndset\fP manipulate the background of
+the applicable window,
+without updating the character cells as \fB\%bkgrnd\fP and
+\fB\%wbkgrnd\fP do;
+only future writes reflect the updated background.
+.SS "getbkgrnd, wgetbkgrnd"
+The \fB\%getbkgrnd\fP and \fB\%wgetbkgrnd\fP functions obtain the
+background character and attribute pair of \fB\%stdscr\fP or the
+specified window and store it via the
+.I wch
+pointer.
+.SH RETURN VALUE
+\fBbkgrndset\fP and \fBwbkgrndset\fP do not return a value.
 .PP
-Upon successful completion, the other functions return \fBOK\fR.
-Otherwise, they return \fBERR\fR:
+The other functions return
+.B ERR
+upon failure and
+.B OK
+upon success.
+In
+.IR \%ncurses ,
+failure occurs if
 .bP
-A null window pointer is treated as an error.
+a
+.I \%WINDOW
+pointer
+.I win
+is null, or
 .bP
-A null character pointer is treated as an error.
+a
+.I \%cchar_t
+pointer
+.I wch
+is null.
+.SH NOTES
+\fB\%bkgrnd\fP,
+\fB\%bkgrndset\fP, and
+\fB\%getbkgrnd\fP
+may be implemented as macros.
+.PP
+Unlike their counterparts in the non-\*(``wide\*('' configuration of
+.IR \%ncurses ,
+\fB\%getbkgrnd\fP and \fB\%wgetbkgrnd\fP supply the background character
+and attribute in a modifiable
+.I \%cchar_t
+parameter,
+not as the return value.
 .SH PORTABILITY
+X/Open Curses,
+Issue 4 describes these functions.
+It specifies no error conditions for them.
 .PP
-These functions are described in the XSI Curses standard, Issue 4
-(X/Open Curses).
+X/Open Curses does not provide details of how the rendition is updated.
+This implementation follows the approach used in SVr4
+.IR curses .
 .SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_bkgd\fR(3X)
+\fB\%curs_bkgd\fP(3X) describes the corresponding functions in the
+non-\*(``wide\*('' configuration of
+.IR \%ncurses .
+.PP
+\fB\%curses\fP(3X),
+\fB\%curs_add_wch\fP(3X),
+\fB\%curs_attr\fP(3X)
diff --git a/contrib/ncurses/man/curs_border.3x b/contrib/ncurses/man/curs_border.3x
index 7b41da530445..2a5e72c141e2 100644
--- a/contrib/ncurses/man/curs_border.3x
+++ b/contrib/ncurses/man/curs_border.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2007,2010 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,137 +27,136 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_border.3x,v 1.27 2020/10/18 00:33:06 tom Exp $
-.TH curs_border 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
-.na
-.hy 0
+.\" $Id: curs_border.3x,v 1.49 2024/04/20 21:20:07 tom Exp $
+.TH curs_border 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
 .SH NAME
-\fBborder\fR,
-\fBwborder\fR,
-\fBbox\fR,
-\fBhline\fR,
-\fBwhline\fR,
-\fBvline\fR,
-\fBwvline\fR,
-\fBmvhline\fR,
-\fBmvwhline\fR,
-\fBmvvline\fR,
-\fBmvwvline\fR \- create \fBcurses\fR borders, horizontal and vertical lines
-.ad
-.hy
+\fB\%border\fP,
+\fB\%wborder\fP,
+\fB\%box\fP,
+\fB\%hline\fP,
+\fB\%whline\fP,
+\fB\%vline\fP,
+\fB\%wvline\fP,
+\fB\%mvhline\fP,
+\fB\%mvwhline\fP,
+\fB\%mvvline\fP,
+\fB\%mvwvline\fP \-
+draw borders and lines in a \fIcurses\fR window of characters
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBint border(chtype \fP\fIls\fP\fB, chtype \fP\fIrs\fP\fB, chtype \fP\fIts\fP\fB, chtype \fP\fIbs\fP\fB,\fR
-           \fBchtype \fP\fItl\fP\fB, chtype \fP\fItr\fP\fB, chtype \fP\fIbl\fP\fB, chtype \fP\fIbr\fP\fB);\fR
-.br
-\fBint wborder(WINDOW *\fP\fIwin\fP\fB, chtype \fP\fIls\fP\fB, chtype \fP\fIrs\fP\fB,\fR
-            \fBchtype \fP\fIts\fP\fB, chtype \fP\fIbs\fP\fB, chtype \fP\fItl\fP\fB, chtype \fP\fItr\fP\fB,\fR
-            \fBchtype \fP\fIbl\fP\fB, chtype \fP\fIbr\fP\fB);\fR
-.sp
-\fBint box(WINDOW *\fP\fIwin\fP\fB, chtype \fP\fIverch\fP\fB, chtype \fP\fIhorch\fP\fB);\fR
-.sp
-\fBint hline(chtype \fP\fIch\fP\fB, int \fP\fIn\fP\fB);\fR
-.br
-\fBint whline(WINDOW *\fP\fIwin\fP\fB, chtype \fP\fIch\fP\fB, int \fP\fIn\fP\fB);\fR
-.br
-\fBint vline(chtype \fP\fIch\fP\fB, int \fP\fIn\fP\fB);\fR
-.br
-\fBint wvline(WINDOW *\fP\fIwin\fP\fB, chtype \fP\fIch\fP\fB, int \fP\fIn\fP\fB);\fR
-.sp
-\fBint mvhline(int \fP\fIy\fP\fB, int \fP\fIx\fP\fB, chtype \fP\fIch\fP\fB, int \fP\fIn\fP\fB);\fR
-.br
-\fBint mvwhline(WINDOW *\fP\fIwin\fP\fB, int \fP\fIy\fP\fB, int \fP\fIx\fP\fB, chtype \fP\fIch\fP\fB, int \fP\fIn\fP\fB);\fR
-.br
-\fBint mvvline(int \fP\fIy\fP\fB, int \fP\fIx\fP\fB, chtype \fP\fIch\fP\fB, int \fP\fIn\fP\fB);\fR
-.br
-\fBint mvwvline(WINDOW *\fP\fIwin\fP\fB, int \fP\fIy\fP\fB, int \fP\fIx\fP\fB, chtype \fP\fIch\fP\fB, int \fP\fIn\fP\fB);\fR
-.br
+.nf
+\fB#include <curses.h>
+.PP
+\fBint border(chtype \fIls\fP, chtype \fIrs\fP, chtype \fIts\fP, chtype \fIbs\fP,
+           \fBchtype \fItl\fB, chtype \fItr\fB, chtype \fIbl\fB, chtype \fIbr\fB);\fR
+\fBint wborder(WINDOW *\fIwin\fB, chtype \fIls\fB, chtype \fIrs\fB,\fR
+            \fBchtype \fIts\fB, chtype \fIbs\fB, chtype \fItl\fB, chtype \fItr\fB,\fR
+            \fBchtype \fIbl\fB, chtype \fIbr\fB);\fR
+.PP
+\fBint box(WINDOW *\fIwin\fB, chtype \fIverch\fB, chtype \fIhorch\fB);\fR
+.PP
+\fBint hline(chtype \fIch\fB, int \fIn\fB);\fR
+\fBint whline(WINDOW *\fIwin\fB, chtype \fIch\fB, int \fIn\fB);\fR
+\fBint vline(chtype \fIch\fB, int \fIn\fB);\fR
+\fBint wvline(WINDOW *\fIwin\fB, chtype \fIch\fB, int \fIn\fB);\fR
+.PP
+\fBint mvhline(int \fIy\fB, int \fIx\fB, chtype \fIch\fB, int \fIn\fB);\fR
+\fBint mvwhline(WINDOW *\fIwin\fB, int \fIy\fB, int \fIx\fB, chtype \fIch\fB, int \fIn\fB);\fR
+\fBint mvvline(int \fIy\fB, int \fIx\fB, chtype \fIch\fB, int \fIn\fB);\fR
+\fBint mvwvline(WINDOW *\fIwin\fB, int \fIy\fB, int \fIx\fB, chtype \fIch\fB, int \fIn\fB);\fR
+.fi
 .SH DESCRIPTION
-The \fBborder\fR, \fBwborder\fR and \fBbox\fR routines
+The \fBborder\fP, \fBwborder\fP and \fBbox\fP routines
 draw a box around the edges of a window.
 Other than the window, each argument is a character with attributes:
 .sp
 .RS
-\fIls\fR \- left side,
+\fIls\fP \- left side,
 .br
-\fIrs\fR \- right side,
+\fIrs\fP \- right side,
 .br
-\fIts\fR \- top side,
+\fIts\fP \- top side,
 .br
-\fIbs\fR \- bottom side,
+\fIbs\fP \- bottom side,
 .br
-\fItl\fR \- top left-hand corner,
+\fItl\fP \- top left-hand corner,
 .br
-\fItr\fR \- top right-hand corner,
+\fItr\fP \- top right-hand corner,
 .br
-\fIbl\fR \- bottom left-hand corner, and
+\fIbl\fP \- bottom left-hand corner, and
 .br
-\fIbr\fR \- bottom right-hand corner.
+\fIbr\fP \- bottom right-hand corner.
 .RE
 .PP
 If any of these arguments is zero, then the corresponding
-default values (defined in \fBcurses.h\fR) are used instead:
+default values (defined in \fBcurses.h\fP) are used instead:
 .sp
 .RS
-\fBACS_VLINE\fR,
+\fBACS_VLINE\fP,
 .br
-\fBACS_VLINE\fR,
+\fBACS_VLINE\fP,
 .br
-\fBACS_HLINE\fR,
+\fBACS_HLINE\fP,
 .br
-\fBACS_HLINE\fR,
+\fBACS_HLINE\fP,
 .br
-\fBACS_ULCORNER\fR,
+\fBACS_ULCORNER\fP,
 .br
-\fBACS_URCORNER\fR,
+\fBACS_URCORNER\fP,
 .br
-\fBACS_LLCORNER\fR,
+\fBACS_LLCORNER\fP,
 .br
-\fBACS_LRCORNER\fR.
+\fBACS_LRCORNER\fP.
 .RE
 .PP
-\fBbox(\fR\fIwin\fR\fB, \fR\fIverch\fR\fB, \fR\fIhorch\fR\fB)\fR is a shorthand
-for the following call: \fBwborder(\fR\fIwin\fR\fB,\fR \fIverch\fR\fB,\fR
-\fIverch\fR\fB,\fR \fIhorch\fR\fB,\fR \fIhorch\fR\fB, 0, 0, 0, 0)\fR.
+\fBbox(\fIwin\fB, \fIverch\fB, \fIhorch\fB)\fR is a shorthand
+for the following call: \fBwborder(\fIwin\fB,\fR \fIverch\fB,\fR
+\fIverch\fB,\fR \fIhorch\fB,\fR \fIhorch\fB, 0, 0, 0, 0)\fR.
 .PP
-The \fBhline\fR and \fBwhline\fR functions draw a horizontal (left to right)
-line using \fIch\fR starting at the current cursor position in the window.
+The \fBhline\fP and \fBwhline\fP functions draw a horizontal (left to right)
+line using \fIch\fP starting at the current cursor position in the window.
 The
 current cursor position is not changed.
-The line is at most \fIn\fR characters
+The line is at most \fIn\fP characters
 long, or as many as fit into the window.
 .PP
-The \fBvline\fR and \fBwvline\fR functions draw a vertical (top to bottom) line
-using \fIch\fR starting at the current cursor position in the window.
+The \fBvline\fP and \fBwvline\fP functions draw a vertical (top to bottom) line
+using \fIch\fP starting at the current cursor position in the window.
 The
 current cursor position is not changed.
-The line is at most \fIn\fR characters
+The line is at most \fIn\fP characters
 long, or as many as fit into the window.
 .SH RETURN VALUE
-All routines return the integer \fBOK\fR.
-The SVr4.0 manual says "or a
-non-negative integer if \fBimmedok\fR is set", but this appears to be an error.
+All routines return the integer \fBOK\fP.
+The SVr4.0 manual says
+\*(``or a non-negative integer if \fB\%immedok\fP is set\*('',
+but this appears to be an error.
 .PP
-X/Open does not define any error conditions.
+X/Open Curses does not specify any error conditions.
 This implementation returns an error
 if the window pointer is null.
 .PP
-Functions with a \*(``mv\*('' prefix first perform a cursor movement using
-\fBwmove\fP, and return an error if the position is outside the window,
-or if the window pointer is null.
+Functions prefixed with \*(``mv\*('' first perform cursor movement and
+fail if the position
+.RI ( y ,
+.IR x )
+is outside the window boundaries.
 .SH NOTES
-The borders generated by these functions are \fIinside\fR borders (this
+The borders generated by these functions are \fIinside\fP borders (this
 is also true of SVr4 curses, though the fact is not documented).
 .PP
-Note that \fBborder\fR and \fBbox\fR may be macros.
+Note that \fBborder\fP and \fBbox\fP may be macros.
 .SH PORTABILITY
-These functions are described in the XSI Curses standard, Issue 4.
-The standard specifies that they return \fBERR\fR on failure,
-but specifies no error conditions.
+These functions are described in X/Open Curses, Issue 4.
 .SH SEE ALSO
-\fBcurses\fR(3X), \fBcurs_outopts\fR(3X).
+\fB\%curses\fP(3X),
+\fB\%curs_outopts\fP(3X)
diff --git a/contrib/ncurses/man/curs_border_set.3x b/contrib/ncurses/man/curs_border_set.3x
index b156b77dab95..3077da6b49f7 100644
--- a/contrib/ncurses/man/curs_border_set.3x
+++ b/contrib/ncurses/man/curs_border_set.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2019,2020 Thomas E. Dickey                                     *
+.\" Copyright 2019-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 2002-2011,2012 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,185 +27,177 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_border_set.3x,v 1.13 2020/02/02 23:34:34 tom Exp $
-.TH curs_border_set 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
-.na
-.hy 0
+.\" $Id: curs_border_set.3x,v 1.36 2024/04/20 21:20:07 tom Exp $
+.TH curs_border_set 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
 .SH NAME
-\fBborder_set\fR,
-\fBwborder_set\fR,
-\fBbox_set\fR,
-\fBhline_set\fR,
-\fBwhline_set\fR,
-\fBmvhline_set\fR,
-\fBmvwhline_set\fR,
-\fBvline_set\fR,
-\fBwvline_set\fR,
-\fBmvvline_set\fR,
-\fBmvwvline_set\fR \- create \fBcurses\fR borders or lines using complex characters and renditions
-.ad
-.hy
+\fB\%border_set\fP,
+\fB\%wborder_set\fP,
+\fB\%box_set\fP,
+\fB\%hline_set\fP,
+\fB\%whline_set\fP,
+\fB\%mvhline_set\fP,
+\fB\%mvwhline_set\fP,
+\fB\%vline_set\fP,
+\fB\%wvline_set\fP,
+\fB\%mvvline_set\fP,
+\fB\%mvwvline_set\fP \-
+draw borders and lines in a \fIcurses\fR window of wide characters
 .SH SYNOPSIS
+.nf
+\fB#include <curses.h>
 .PP
-\fB#include <curses.h>\fR
-.sp
-\fBint border_set(\fR
-   \fBconst cchar_t *\fR\fIls\fR, \fBconst cchar_t *\fR\fIrs\fR,
-   \fBconst cchar_t *\fR\fIts\fR, \fBconst cchar_t *\fR\fIbs\fR,
-   \fBconst cchar_t *\fR\fItl\fR, \fBconst cchar_t *\fR\fItr\fR,
-   \fBconst cchar_t *\fR\fIbl\fR, \fBconst cchar_t *\fR\fIbr\fR
-\fB);\fR
-.br
-\fBint wborder_set(\fR
-   \fBWINDOW *win\fR,
-   \fBconst cchar_t *\fR\fIls\fR, \fBconst cchar_t *\fR\fIrs\fR,
-   \fBconst cchar_t *\fR\fIts\fR, \fBconst cchar_t *\fR\fIbs\fR,
-   \fBconst cchar_t *\fR\fItl\fR, \fBconst cchar_t *\fR\fItr\fR,
-   \fBconst cchar_t *\fR\fIbl\fR, \fBconst cchar_t *\fR\fIbr\fR\fB);\fR
-.br
-\fBint box_set(\fR
-   \fBWINDOW *win\fR,
-   \fBconst cchar_t *\fR\fIverch\fR,
-   \fBconst cchar_t *\fR\fIhorch\fR\fB);\fR
-.br
-\fBint hline_set(\fR
-   \fBconst cchar_t *\fR\fIwch\fR, \fBint \fR\fIn\fR\fB);\fR
-.br
-\fBint whline_set(\fR
-   \fBWINDOW *\fR\fIwin\fR,
-   \fBconst cchar_t *\fR\fIwch\fR, \fBint \fR\fIn\fR\fB);\fR
-.br
-\fBint mvhline_set(\fR
-   \fBint \fR\fIy\fR, \fBint \fR\fIx\fR,
-   \fBconst cchar_t *\fR\fIwch\fR, \fBint \fR\fIn\fR\fB);\fR
-.br
-\fBint mvwhline_set(\fR
-   \fBWINDOW *\fR\fIwin\fR,
-   \fBint \fR\fIy\fR, \fBint \fR\fIx\fR,
-   \fBconst cchar_t *\fR\fIwch\fR, \fBint \fR\fIn\fR\fB);\fR
-.br
-\fBint vline_set(\fR
-   \fBconst cchar_t *\fR\fIwch\fR, \fBint \fR\fIn\fR\fB);\fR
-.br
-\fBint wvline_set(\fR
-   \fBWINDOW *\fR\fIwin\fR,
-   \fBconst cchar_t *\fR\fIwch\fR, \fBint \fR\fIn\fR\fB);\fR
-.br
-\fBint mvvline_set(\fR
-   \fBint \fR\fIy\fR, \fBint \fR\fIx\fR,
-   \fBconst cchar_t *\fR\fIwch\fR, \fBint \fR\fIn\fR\fB);\fR
-.br
-\fBint mvwvline_set(\fR
-   \fBWINDOW *\fR\fIwin\fR,
-   \fBint \fR\fIy\fR, \fBint \fR\fIx\fR,
-   \fBconst cchar_t *\fR\fIwch\fR, \fBint \fR\fIn\fR\fB);\fR
-.br
+\fBint border_set(
+   \fBconst cchar_t *\fIls\fB, const cchar_t *\fIrs\fP,
+   \fBconst cchar_t *\fIts\fB, const cchar_t *\fIbs\fP,
+   \fBconst cchar_t *\fItl\fB, const cchar_t *\fItr\fP,
+   \fBconst cchar_t *\fIbl\fB, const cchar_t *\fIbr\fB);\fR
+.br
+\fBint wborder_set(\fP
+   \fBWINDOW *\fIwin\fP,
+   \fBconst cchar_t *\fIls\fB, const cchar_t *\fIrs\fP,
+   \fBconst cchar_t *\fIts\fB, const cchar_t *\fIbs\fP,
+   \fBconst cchar_t *\fItl\fB, const cchar_t *\fItr\fP,
+   \fBconst cchar_t *\fIbl\fB, const cchar_t *\fIbr\fB);\fR
+\fBint box_set(\fP
+   \fBWINDOW *\fIwin\fP,
+   \fBconst cchar_t *\fIverch\fP,
+   \fBconst cchar_t *\fIhorch\fB);\fR
+\fBint hline_set(\fP
+   \fBconst cchar_t *\fIwch\fB, int \fIn\fB);\fR
+\fBint whline_set(\fP
+   \fBWINDOW *\fIwin\fP,
+   \fBconst cchar_t *\fIwch\fB, int \fIn\fB);\fR
+\fBint mvhline_set(\fP
+   \fBint \fIy\fB, int \fIx\fP,
+   \fBconst cchar_t *\fIwch\fB, int \fIn\fB);\fR
+\fBint mvwhline_set(\fP
+   \fBWINDOW *\fIwin\fP,
+   \fBint \fIy\fB, int \fIx\fP,
+   \fBconst cchar_t *\fIwch\fB, int \fIn\fB);\fR
+\fBint vline_set(\fP
+   \fBconst cchar_t *\fIwch\fB, int \fIn\fB);\fR
+\fBint wvline_set(\fP
+   \fBWINDOW *\fIwin\fP,
+   \fBconst cchar_t *\fIwch\fB, int \fIn\fB);\fR
+\fBint mvvline_set(\fP
+   \fBint \fIy\fB, int \fIx\fP,
+   \fBconst cchar_t *\fIwch\fB, int \fIn\fB);\fR
+\fBint mvwvline_set(\fP
+   \fBWINDOW *\fIwin\fP,
+   \fBint \fIy\fB, int \fIx\fP,
+   \fBconst cchar_t *\fIwch\fB, int \fIn\fB);\fR
+.fi
 .SH DESCRIPTION
-.PP
 The
-\fBborder_set\fR
+\fBborder_set\fP
 and
-\fBwborder_set\fR
+\fBwborder_set\fP
 functions draw a border around the edges of the current or specified window.
 These functions do not change the cursor position, and do not wrap.
 .PP
 Other than the window, each argument is a complex character with attributes:
 .RS
-\fIls\fR \- left side,
+\fIls\fP \- left side,
 .br
-\fIrs\fR \- right side,
+\fIrs\fP \- right side,
 .br
-\fIts\fR \- top side,
+\fIts\fP \- top side,
 .br
-\fIbs\fR \- bottom side,
+\fIbs\fP \- bottom side,
 .br
-\fItl\fR \- top left-hand corner,
+\fItl\fP \- top left-hand corner,
 .br
-\fItr\fR \- top right-hand corner,
+\fItr\fP \- top right-hand corner,
 .br
-\fIbl\fR \- bottom left-hand corner, and
+\fIbl\fP \- bottom left-hand corner, and
 .br
-\fIbr\fR \- bottom right-hand corner.
+\fIbr\fP \- bottom right-hand corner.
 .RE
 .PP
 If any of these arguments is zero, then the corresponding
-default values (defined in \fBcurses.h\fR) are used instead:
+default values (defined in \fBcurses.h\fP) are used instead:
 .RS
-\fBWACS_VLINE\fR,
+\fBWACS_VLINE\fP,
 .br
-\fBWACS_VLINE\fR,
+\fBWACS_VLINE\fP,
 .br
-\fBWACS_HLINE\fR,
+\fBWACS_HLINE\fP,
 .br
-\fBWACS_HLINE\fR,
+\fBWACS_HLINE\fP,
 .br
-\fBWACS_ULCORNER\fR,
+\fBWACS_ULCORNER\fP,
 .br
-\fBWACS_URCORNER\fR,
+\fBWACS_URCORNER\fP,
 .br
-\fBWACS_LLCORNER\fR, and
+\fBWACS_LLCORNER\fP, and
 .br
-\fBWACS_LRCORNER\fR.
+\fBWACS_LRCORNER\fP.
 .RE
 .PP
-\fBbox_set(\fR\fIwin\fR, \fIverch\fR\fB, \fR\fIhorch\fR\fB);\fR
+\fBbox_set(\fIwin\fR, \fIverch\fB, \fIhorch\fB);\fR
 is a shorthand for the following call:
 .PP
-\fBwborder_set(\fR\fIwin\fR\fB, \fR\fIverch\fR\fB, \fR\fIverch\fR\fB,\fR
-    \fIhorch\fR\fB, \fR\fIhorch\fR\fB, NULL, NULL, NULL, NULL);\fR
+\fBwborder_set(\fIwin\fB, \fIverch\fB, \fIverch\fB,\fR
+    \fIhorch\fB, \fIhorch\fB, NULL, NULL, NULL, NULL);\fR
 .PP
 The
-\fB*line_set\fR
+\fB*line_set\fP
 functions use
-\fIwch\fR
+\fIwch\fP
 to draw a line starting at the current cursor position in the window.
-The line is at most \fIn\fR characters long or as many as fit into the window.
+The line is at most \fIn\fP characters long or as many as fit into the window.
 The current cursor position is not changed.
 .PP
 The
-\fBhline_set\fR,
-\fBmvhline_set\fR,
-\fBmvwhline_set\fR, and
-\fBwhline_set\fR
+\fBhline_set\fP,
+\fBmvhline_set\fP,
+\fBmvwhline_set\fP, and
+\fBwhline_set\fP
 functions draw a line proceeding toward the last column of the same line.
 .PP
 The
-\fBvline_set\fR,
-\fBmvvline_set\fR,
-\fBmvwvline_set\fR, and
-\fBwvline_set\fR
+\fBvline_set\fP,
+\fBmvvline_set\fP,
+\fBmvwvline_set\fP, and
+\fBwvline_set\fP
 functions draw a line proceeding toward the last line of the window.
-.br
-.SH NOTES
-.PP
-Note that
-\fBborder_set\fR,
-\fBhline_set\fR,
-\fBmvhline_set\fR,
-\fBmvvline_set\fR,
-\fBmvwhline_set\fR,
-\fBmvwvline_set\fR, and
-\fBvline_set\fR
-may be macros.
-.br
 .SH RETURN VALUE
-.PP
 Upon successful completion, these functions return
-\fBOK\fR.
+\fBOK\fP.
 Otherwise, they return
-\fBERR\fR.
+\fBERR\fP.
 .PP
 Functions using a window parameter return an error if it is null.
 .PP
-Functions with a \*(``mv\*('' prefix first perform a cursor movement using
-\fBwmove\fP, and return an error if the position is outside the window,
-or if the window pointer is null.
+Functions prefixed with \*(``mv\*('' first perform cursor movement and
+fail if the position
+.RI ( y ,
+.IR x )
+is outside the window boundaries.
+.SH NOTES
+Note that
+\fBborder_set\fP,
+\fBhline_set\fP,
+\fBmvhline_set\fP,
+\fBmvvline_set\fP,
+\fBmvwhline_set\fP,
+\fBmvwvline_set\fP, and
+\fBvline_set\fP
+may be macros.
+.SH PORTABILITY
+These functions are described in X/Open Curses, Issue 4.
 .SH SEE ALSO
-\fBncurses\fR(3X),
-\fBcurs_add_wch\fR(3X),
-\fBcurs_border\fR(3X),
-\fBcurs_outopts\fR(3X)
+\fB\%curses\fP(3X),
+\fB\%curs_add_wch\fP(3X),
+\fB\%curs_border\fP(3X),
+\fB\%curs_outopts\fP(3X)
diff --git a/contrib/ncurses/man/curs_clear.3x b/contrib/ncurses/man/curs_clear.3x
index d86acbde6b00..0ab00645197a 100644
--- a/contrib/ncurses/man/curs_clear.3x
+++ b/contrib/ncurses/man/curs_clear.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2016 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,65 +27,71 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_clear.3x,v 1.20 2020/10/24 09:19:37 tom Exp $
-.TH curs_clear 3X ""
-.na
-.hy 0
+.\" $Id: curs_clear.3x,v 1.48 2024/04/20 21:20:07 tom Exp $
+.TH curs_clear 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
 .SH NAME
-\fBerase\fR,
-\fBwerase\fR,
-\fBclear\fR,
-\fBwclear\fR,
-\fBclrtobot\fR,
-\fBwclrtobot\fR,
-\fBclrtoeol\fR,
-\fBwclrtoeol\fR \- clear all or part of a \fBcurses\fR window
-.ad
-.hy
+\fB\%erase\fP,
+\fB\%werase\fP,
+\fB\%clear\fP,
+\fB\%wclear\fP,
+\fB\%clrtobot\fP,
+\fB\%wclrtobot\fP,
+\fB\%clrtoeol\fP,
+\fB\%wclrtoeol\fP \-
+clear all or part of a \fIcurses\fR window
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBint erase(void);\fR
-.br
-\fBint werase(WINDOW *\fP\fIwin\fP\fB);\fR
-.sp
-\fBint clear(void);\fR
-.br
-\fBint wclear(WINDOW *\fP\fIwin\fP\fB);\fR
-.sp
-\fBint clrtobot(void);\fR
-.br
-\fBint wclrtobot(WINDOW *\fP\fIwin\fP\fB);\fR
-.sp
-\fBint clrtoeol(void);\fR
-.br
-\fBint wclrtoeol(WINDOW *\fP\fIwin\fP\fB);\fR
-.br
+.nf
+\fB#include <curses.h>
+.PP
+\fBint erase(void);
+\fBint werase(WINDOW *\fIwin\fP);
+.PP
+\fBint clear(void);
+\fBint wclear(WINDOW *\fIwin\fP);
+.PP
+\fBint clrtobot(void);
+\fBint wclrtobot(WINDOW *\fIwin\fP);
+.PP
+\fBint clrtoeol(void);
+\fBint wclrtoeol(WINDOW *\fIwin\fP);
+.fi
 .SH DESCRIPTION
-The \fBerase\fR and \fBwerase\fR routines copy blanks to every
+.SS "erase, werase"
+The \fBerase\fP and \fBwerase\fP routines copy blanks to every
 position in the window, clearing the screen.
 .PP
-The \fBclear\fR and \fBwclear\fR routines are like \fBerase\fR and
-\fBwerase\fR, but they also call \fBclearok\fR, so that the screen is
-cleared completely on the next call to \fBwrefresh\fR for that window
+Blanks created by erasure have the current background rendition (as set
+by \fBwbkgdset\fP(3X)) merged into them.
+.SS "clear, wclear"
+The \fBclear\fP and \fBwclear\fP routines are like \fBerase\fP and
+\fBwerase\fP, but they also call \fBclearok\fP(3X), so that the screen is
+cleared completely on the next call to \fBwrefresh\fP for that window
 and repainted from scratch.
-.PP
-The \fBclrtobot\fR and \fBwclrtobot\fR routines erase from the cursor to the
+.SS "clrtobot, wclrtobot"
+The \fBclrtobot\fP and \fBwclrtobot\fP routines erase from the cursor to the
 end of screen.
 That is, they erase all lines below the cursor in the window.
 Also, the current line to the right of the cursor, inclusive, is erased.
-.PP
-The \fBclrtoeol\fR and \fBwclrtoeol\fR routines erase the current line
+.SS "clrtoeol, wclrtoeol"
+The \fBclrtoeol\fP and \fBwclrtoeol\fP routines erase the current line
 to the right of the cursor, inclusive, to the end of the current line.
-.PP
-Blanks created by erasure have the current background rendition (as set
-by \fBwbkgdset\fR) merged into them.
 .SH RETURN VALUE
-All routines return the integer \fBOK\fR on success and \fBERR\fP on failure.
+All routines return the integer \fBOK\fP on success and \fBERR\fP on failure.
 .PP
 X/Open defines no error conditions.
 In this implementation,
@@ -95,25 +101,22 @@ functions using a window pointer parameter return an error if it is null
 \fBwclrtoeol\fP returns an error
 if the cursor position is about to wrap.
 .SH NOTES
-Note that \fBerase\fR, \fBwerase\fR, \fBclear\fR, \fBwclear\fR,
-\fBclrtobot\fR, and \fBclrtoeol\fR may be macros.
+Note that \fBerase\fP, \fBwerase\fP, \fBclear\fP, \fBwclear\fP,
+\fBclrtobot\fP, and \fBclrtoeol\fP may be macros.
 .SH PORTABILITY
-These functions are described in the XSI Curses standard, Issue 4.
-The
-standard specifies that they return \fBERR\fR on failure, but specifies no
-error conditions.
+These functions are described in X/Open Curses, Issue 4.
 .PP
-The SVr4.0 manual says that these functions could
-return "a non-negative integer if \fBimmedok\fR is set",
+The SVr4.0 manual says that these functions could return
+\*(``or a non-negative integer if \fB\%immedok\fP is set\*('',
 referring to the return-value of \fBwrefresh\fP.
 In that implementation, \fBwrefresh\fP would return a count of
 the number of characters written to the terminal.
 .PP
 Some historic curses implementations had, as an undocumented feature, the
-ability to do the equivalent of \fBclearok(..., 1)\fR by saying
-\fBtouchwin(stdscr)\fR or \fBclear(stdscr)\fR.
+ability to do the equivalent of \fBclearok(..., 1)\fP by saying
+\fBtouchwin(stdscr)\fP or \fBclear(stdscr)\fP.
 This will not work under
-ncurses.
+\fI\%ncurses\fP.
 .PP
 This implementation, and others such as Solaris,
 sets the current position to 0,0 after erasing
@@ -128,7 +131,7 @@ even for a subwindow or derived window.
 If you do not want to clear the screen during the next \fBwrefresh\fP,
 use \fBwerase\fP instead.
 .SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_outopts\fR(3X),
-\fBcurs_refresh\fR(3X),
-\fBcurs_variables\fR(3X)
+\fB\%curses\fP(3X),
+\fB\%curs_outopts\fP(3X),
+\fB\%curs_refresh\fP(3X),
+\fB\%curs_variables\fP(3X)
diff --git a/contrib/ncurses/man/curs_color.3x b/contrib/ncurses/man/curs_color.3x
index 02defb6a793c..7a5a02f27de3 100644
--- a/contrib/ncurses/man/curs_color.3x
+++ b/contrib/ncurses/man/curs_color.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,194 +27,226 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_color.3x,v 1.63 2020/10/24 09:35:23 tom Exp $
-.TH curs_color 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: curs_color.3x,v 1.100 2024/04/20 21:24:19 tom Exp $
+.TH curs_color 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.ds n 5
-.na
-.hy 0
+.
 .SH NAME
-\fBstart_color\fR,
-\fBhas_colors\fR,
-\fBcan_change_color\fR,
-\fBinit_pair\fR,
-\fBinit_color\fR,
-\fBinit_extended_pair\fR,
-\fBinit_extended_color\fR,
-\fBcolor_content\fR,
-\fBpair_content\fR,
-\fBextended_color_content\fR,
-\fBextended_pair_content\fR,
-\fBreset_color_pairs\fR,
-\fBCOLOR_PAIR\fR,
-\fBPAIR_NUMBER\fR \- \fBcurses\fR color manipulation routines
-.ad
-.hy
+\fB\%start_color\fP,
+\fB\%has_colors\fP,
+\fB\%can_change_color\fP,
+\fB\%init_pair\fP,
+\fB\%init_color\fP,
+\fB\%init_extended_pair\fP,
+\fB\%init_extended_color\fP,
+\fB\%color_content\fP,
+\fB\%pair_content\fP,
+\fB\%extended_color_content\fP,
+\fB\%extended_pair_content\fP,
+\fB\%reset_color_pairs\fP,
+\fB\%COLOR_PAIR\fP,
+\fB\%PAIR_NUMBER\fP,
+\fB\%COLORS\fP,
+\fB\%COLOR_PAIRS\fP,
+\fB\%COLOR_BLACK\fP,
+\fB\%COLOR_RED\fP,
+\fB\%COLOR_GREEN\fP,
+\fB\%COLOR_YELLOW\fP,
+\fB\%COLOR_BLUE\fP,
+\fB\%COLOR_MAGENTA\fP,
+\fB\%COLOR_CYAN\fP,
+\fB\%COLOR_WHITE\fP \-
+manipulate terminal colors with \fIcurses\fR
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBint start_color(void);\fR
-.sp
-\fBbool has_colors(void);\fR
-.br
-\fBbool can_change_color(void);\fR
-.sp
-\fBint init_pair(short \fP\fIpair\fP\fB, short \fP\fIf\fP\fB, short \fP\fIb\fP\fB);\fR
-.br
-\fBint init_color(short \fP\fIcolor\fP\fB, short \fP\fIr\fP\fB, short \fP\fIg\fP\fB, short \fP\fIb\fP\fB);\fR
-.br
-/* extensions */
-.br
-\fBint init_extended_pair(int \fP\fIpair\fP\fB, int \fP\fIf\fP\fB, int \fP\fIb\fP\fB);\fR
-.br
-\fBint init_extended_color(int \fP\fIcolor\fP\fB, int \fP\fIr\fP\fB, int \fP\fIg\fP\fB, int \fP\fIb\fP\fB);\fR
-.sp
-\fBint color_content(short \fP\fIcolor\fP\fB, short *\fP\fIr\fP\fB, short *\fP\fIg\fP\fB, short *\fP\fIb\fP\fB);\fR
-.br
-\fBint pair_content(short \fP\fIpair\fP\fB, short *\fP\fIf\fP\fB, short *\fP\fIb\fP\fB);\fR
-.br
-/* extensions */
-.br
-\fBint extended_color_content(int \fP\fIcolor\fP\fB, int *\fP\fIr\fP\fB, int *\fP\fIg\fP\fB, int *\fP\fIb\fP\fB);\fR
-.br
-\fBint extended_pair_content(int \fP\fIpair\fP\fB, int *\fP\fIf\fP\fB, int *\fP\fIb\fP\fB);\fR
-.sp
-/* extensions */
-.br
-\fBvoid reset_color_pairs(void);\fR
-.sp
-\fBint COLOR_PAIR(int \fP\fIn\fP\fB);\fR
-.br
-\fBPAIR_NUMBER(\fR\fIattrs\fR\fB);\fP
-.br
+.nf
+\fB#include <curses.h>
+.PP
+\fI/* variables */
+\fBint COLOR_PAIRS;
+\fBint COLORS;
+.PP
+\fBint start_color(void);
+.PP
+\fBbool has_colors(void);
+\fBbool can_change_color(void);
+.PP
+\fBint init_pair(short \fIpair\fP, short \fIf\fP, short \fIb\fP);
+\fBint init_color(short \fIcolor\fP, short \fIr\fP, short \fIg\fP, short \fIb\fP);
+\fI/* extensions */
+\fBint init_extended_pair(int \fIpair\fP, int \fIf\fP, int \fIb\fP);
+\fBint init_extended_color(int \fIcolor\fP, int \fIr\fP, int \fIg\fP, int \fIb\fP);
+.PP
+\fBint color_content(short \fIcolor\fP, short *\fIr\fP, short *\fIg\fP, short *\fIb\fP);
+\fBint pair_content(short \fIpair\fP, short *\fIf\fP, short *\fIb\fP);
+\fI/* extensions */
+\fBint extended_color_content(int \fIcolor\fP, int *\fIr\fP, int *\fIg\fP, int *\fIb\fP);
+\fBint extended_pair_content(int \fIpair\fP, int *\fIf\fP, int *\fIb\fP);
+.PP
+\fI/* extension */
+\fBvoid reset_color_pairs(void);
+.PP
+\fBint COLOR_PAIR(int \fIn\fP);
+\fBPAIR_NUMBER(int \fIattr\fP);
+.fi
 .SH DESCRIPTION
 .SS Overview
-\fBcurses\fR supports color attributes on terminals with that capability.
-To use these routines \fBstart_color\fR must be called, usually right after
-\fBinitscr\fR.
-Colors are always used in pairs (referred to as color-pairs).
-A color-pair consists of a foreground color (for characters) and a background
-color (for the blank field on which the characters are displayed).
-A programmer initializes a color-pair with the routine \fBinit_pair\fR.
-After it has been initialized, \fBCOLOR_PAIR\fR(\fIn\fR)
-can be used to convert the pair to a video attribute.
-.PP
-If a terminal is capable of redefining colors, the programmer can use the
-routine \fBinit_color\fR to change the definition of a color.
-The routines \fBhas_colors\fR and \fBcan_change_color\fR
-return \fBTRUE\fR or \fBFALSE\fR,
-depending on whether the terminal has color capabilities and whether the
+\fIcurses\fP supports color attributes on terminals with that
+capability.
+Call \fB\%start_color\fP
+(typically right after \fB\%initscr\fP(3X))
+to enable this feature.
+Colors are always used in pairs.
+A
+.I "color pair"
+couples a foreground color for characters with a background color for
+the blank field on which characters are rendered.
+\fB\%init_pair\fP initializes a color pair.
+The macro \fB\%COLOR_PAIR\fP(\fIn\fP) can then convert the pair to a
+video attribute.
+.PP
+If a terminal has the relevant capability,
+\fB\%init_color\fP permits (re)definition of a color.
+\fB\%has_colors\fP and \fB\%can_change_color\fP
+return \fBTRUE\fP or \fBFALSE\fP,
+depending on whether the terminal has color capability and whether the
 programmer can change the colors.
-The routine \fBcolor_content\fR allows a
-programmer to extract the amounts of red, green, and blue components in an
-initialized color.
-The routine \fBpair_content\fR allows a programmer to find
-out how a given color-pair is currently defined.
-.SS Color Rendering
-The \fBcurses\fP library combines these inputs to produce the
-actual foreground and background colors shown on the screen:
+\fB\%color_content\fP permits extraction of the
+red,
+green,
+and blue components of an initialized color.
+\fB\%pair_content\fP permits discovery of a color pair's current
+definition.
+.SS Rendering
+.I curses
+combines the following data to render a character cell.
+Any of them can include color information.
 .bP
-per-character video attributes (e.g., via \fBwaddch\fP),
+.I curses
+character attributes,
+as from \fB\%waddch\fP(3X) or \fB\%wadd_wch\fP(3X)
 .bP
-the window attribute (e.g., by \fBwattrset\fP), and
+window attributes,
+as from \fB\%wattrset\fP(3X) or \fB\%wattr_set\fP(3X)
 .bP
-the background character (e.g., \fBwbkgdset\fP).
+window background character attributes,
+as from \fB\%wbkgdset\fP(3X) or \fB\%wbkgrndset\fP(3X)
 .PP
-Per-character and window attributes are usually set by a parameter containing
-video attributes including a color pair value.
-Some functions such as \fBwattr_set\fP use a separate parameter which
-is the color pair number.
+Per-character and window attributes are usually set through a function
+parameter containing attributes including a color pair value.
+Some functions,
+such as \fB\%wattr_set\fP,
+use a separate color pair number parameter.
 .PP
-The background character is a special case: it includes a character value,
-just as if it were passed to \fBwaddch\fP.
+The background character is a special case:
+it includes a character code,
+just as if it were passed to \fB\%waddch\fP.
 .PP
-The \fBcurses\fP library does the actual work of combining these color
-pairs in an internal function called from \fBwaddch\fP:
+The \fIcurses\fP library does the actual work of combining these color
+pairs in an internal function called from \fB\%waddch\fP:
 .bP
-If the parameter passed to \fBwaddch\fP is \fIblank\fP,
+If the parameter passed to \fB\%waddch\fP is \fIblank\fP,
 and it uses the special color pair 0,
 .RS
 .bP
-\fBcurses\fP next checks the window attribute.
+\fIcurses\fP next checks the window attribute.
 .bP
 If the window attribute does not use color pair 0,
-\fBcurses\fP uses the color pair from the window attribute.
+\fIcurses\fP uses the color pair from the window attribute.
 .bP
-Otherwise, \fBcurses\fP uses the background character.
+Otherwise, \fIcurses\fP uses the background character.
 .RE
 .bP
-If the parameter passed to \fBwaddch\fP is \fInot blank\fP,
+If the parameter passed to \fB\%waddch\fP is \fInot blank\fP,
 or it does not use the special color pair 0,
-\fBcurses\fP prefers the color pair from the parameter,
+\fIcurses\fP prefers the color pair from the parameter,
 if it is nonzero.
 Otherwise, it tries the window attribute next, and finally the
 background character.
 .PP
-Some \fBcurses\fP functions such as \fBwprintw\fP call \fBwaddch\fP.
+Some \fIcurses\fP functions such as \fB\%wprintw\fP call \fB\%waddch\fP.
 Those do not combine its parameter with a color pair.
 Consequently those calls use only the window attribute or
 the background character.
 .SH CONSTANTS
-.PP
-In \fB<curses.h>\fR the following macros are defined.
+In \fB\%<curses.h>\fP the following macros are defined.
 These are the standard colors (ISO-6429).
-\fBcurses\fR also assumes that \fBCOLOR_BLACK\fR is the default
+\fIcurses\fP also assumes that \fB\%COLOR_BLACK\fP is the default
 background color for all terminals.
 .PP
 .nf
-      \fBCOLOR_BLACK\fR
-      \fBCOLOR_RED\fR
-      \fBCOLOR_GREEN\fR
-      \fBCOLOR_YELLOW\fR
-      \fBCOLOR_BLUE\fR
-      \fBCOLOR_MAGENTA\fR
-      \fBCOLOR_CYAN\fR
-      \fBCOLOR_WHITE\fR
+      \fBCOLOR_BLACK\fP
+      \fBCOLOR_RED\fP
+      \fBCOLOR_GREEN\fP
+      \fBCOLOR_YELLOW\fP
+      \fBCOLOR_BLUE\fP
+      \fBCOLOR_MAGENTA\fP
+      \fBCOLOR_CYAN\fP
+      \fBCOLOR_WHITE\fP
 .fi
 .PP
 Some terminals support more than the eight (8) \*(``ANSI\*('' colors.
 There are no standard names for those additional colors.
 .SH VARIABLES
 .SS COLORS
-is initialized by \fBstart_color\fP to the maximum number of colors
+is initialized by \fB\%start_color\fP to the maximum number of colors
 the terminal can support.
 .SS COLOR_PAIRS
-is initialized by \fBstart_color\fP to the maximum number of color pairs
-the terminal can support.
+is initialized by \fB\%start_color\fP to the maximum number of color
+pairs the terminal can support.
+Often,
+its value is the product \fB\%COLORS\fP \(mu \fB\%COLORS\fP,
+but this is not always true.
+.bP
+A few terminals use the HLS color space
+(see \fB\%start_color\fP below),
+ignoring this rule;
+and
+.bP
+terminals supporting a large number of colors are limited to the number
+of color pairs that a
+.I "signed short"
+value can represent.
 .SH FUNCTIONS
 .SS start_color
-The \fBstart_color\fR routine requires no arguments.
+The \fB\%start_color\fP routine requires no arguments.
 It must be called if the programmer wants to use colors, and before any other
 color manipulation routine is called.
-It is good practice to call this routine right after \fBinitscr\fR.
-\fBstart_color\fR does this:
+It is good practice to call this routine right after \fB\%initscr\fP.
+\fB\%start_color\fP does this:
 .bP
-It initializes two global variables, \fBCOLORS\fR and
-\fBCOLOR_PAIRS\fR (respectively defining the maximum number of colors
-and color-pairs the terminal can support).
+It initializes two global variables, \fB\%COLORS\fP and
+\fB\%COLOR_PAIRS\fP (respectively defining the maximum number of colors
+and color pairs the terminal can support).
 .bP
-It initializes the special color pair \fB0\fP to the default foreground
+It initializes the special color pair \fB\%0\fP to the default foreground
 and background colors.
 No other color pairs are initialized.
 .bP
 It restores the colors on the terminal to the values
 they had when the terminal was just turned on.
 .bP
-If the terminal supports the \fBinitc\fP (\fBinitialize_color\fP) capability,
-\fBstart_color\fP
+If the terminal supports the \fBinitc\fP \%(\fBinitialize_color\fP) capability,
+\fB\%start_color\fP
 initializes its internal table representing the
 red, green, and blue components of the color palette.
 .IP
 The components depend on whether the terminal uses
 CGA (aka \*(``ANSI\*('') or
-HLS (i.e., the \fBhls\fP (\fBhue_lightness_saturation\fP) capability is set).
+HLS (i.e., the \fBhls\fP \%(\fBhue_lightness_saturation\fP) capability is set).
 The table is initialized first for eight basic colors
 (black, red, green, yellow, blue, magenta, cyan, and white),
 using weights that depend upon the CGA/HLS choice.
@@ -229,28 +261,28 @@ but with weights of \fB1000\fP.
 SVr4 uses a similar scheme, but uses \fB1000\fP
 for the components of the initial eight colors.
 .IP
-\fBstart_color\fP does not attempt to set the terminal's color palette
+\fB\%start_color\fP does not attempt to set the terminal's color palette
 to match its built-in table.
-An application may use \fBinit_color\fP to alter the internal table
+An application may use \fB\%init_color\fP to alter the internal table
 along with the terminal's color.
 .PP
 These limits apply to color values and color pairs.
-Values outside these limits are not legal, and may result in a runtime error:
+Values outside these limits are not valid, and may result in a runtime error:
 .bP
-\fBCOLORS\fP corresponds to the terminal database's \fBmax_colors\fR capability,
-(see \fBterminfo\fR(\*n)).
+\fBCOLORS\fP corresponds to the terminal database's \fB\%max_colors\fP capability,
+(see \fB\%terminfo\fP(5)).
 .bP
-color values are expected to be in the range \fB0\fP to \fBCOLORS\-1\fP,
-inclusive (including \fB0\fP and \fBCOLORS\-1\fP).
+color values are expected to be in the range \fB0\fP to \fB\%COLORS\-1\fP,
+inclusive (including \fB0\fP and \fB\%COLORS\-1\fP).
 .bP
 a special color value \fB\-1\fP is used in certain extended functions
-to denote the \fIdefault color\fP (see \fBuse_default_colors\fP(3X)).
+to denote the \fIdefault color\fP (see \fB\%use_default_colors\fP(3X)).
 .bP
-\fBCOLOR_PAIRS\fP corresponds to
-the terminal database's \fBmax_pairs\fP capability,
-(see \fBterminfo\fR(\*n)).
+\fB\%COLOR_PAIRS\fP corresponds to
+the terminal database's \fB\%max_pairs\fP capability,
+(see \fB\%terminfo\fP(5)).
 .bP
-legal color pair values are in the range \fB1\fP to \fBCOLOR_PAIRS\-1\fP,
+valid color pair values are in the range \fB1\fP to \fB\%COLOR_PAIRS\-1\fP,
 inclusive.
 .bP
 color pair \fB0\fP is special; it denotes \*(``no color\*(''.
@@ -259,171 +291,162 @@ Color pair \fB0\fP is assumed to be white on black,
 but is actually whatever the terminal implements before color is initialized.
 It cannot be modified by the application.
 .SS has_colors
-.PP
-The \fBhas_colors\fR routine requires no arguments.
-It returns \fBTRUE\fR if
-the terminal can manipulate colors; otherwise, it returns \fBFALSE\fR.
+The \fB\%has_colors\fP routine requires no arguments.
+It returns \fBTRUE\fP if
+the terminal can manipulate colors; otherwise, it returns \fBFALSE\fP.
 This routine facilitates writing terminal-independent programs.
 For example, a programmer can use it to decide
 whether to use color or some other video attribute.
 .SS can_change_color
-.PP
-The \fBcan_change_color\fR routine requires no arguments.
-It returns \fBTRUE\fR if the terminal supports colors
+The \fB\%can_change_color\fP routine requires no arguments.
+It returns \fBTRUE\fP if the terminal supports colors
 and can change their definitions;
-other, it returns \fBFALSE\fR.
+other, it returns \fBFALSE\fP.
 This routine facilitates writing terminal-independent programs.
 .SS init_pair
-.PP
-The \fBinit_pair\fR routine changes the definition of a color-pair.
+The \fB\%init_pair\fP routine changes the definition of a color pair.
 It takes three arguments:
-the number of the color-pair to be changed, the foreground
+the number of the color pair to be changed, the foreground
 color number, and the background color number.
 For portable applications:
 .bP
-The first argument must be a legal color pair value.
-If default colors are used (see \fBuse_default_colors\fP(3X))
+The first argument must be a valid color pair value.
+If default colors are used (see \fB\%use_default_colors\fP(3X))
 the upper limit is adjusted to allow for extra pairs which use
 a default color in foreground and/or background.
 .bP
-The second and third arguments must be legal color values.
+The second and third arguments must be valid color values.
 .PP
-If the color-pair was previously initialized,
-the screen is refreshed and all occurrences of that color-pair
+If the color pair was previously initialized,
+the screen is refreshed and all occurrences of that color pair
 are changed to the new definition.
 .PP
-As an extension, ncurses allows you to set color pair \fB0\fP via
-the \fBassume_default_colors\fR(3X) routine, or to specify the use of
-default colors (color number \fB\-1\fR) if you first invoke the
-\fBuse_default_colors\fR(3X) routine.
+As an extension,
+\fI\%ncurses\fP allows you to set color pair \fB0\fP via the
+\fB\%assume_default_colors\fP(3X) routine, or to specify the use of
+default colors (color number \fB\-1\fP) if you first invoke the
+\fB\%use_default_colors\fP(3X) routine.
 .SS init_extended_pair
-.PP
-Because \fBinit_pair\fP uses signed \fBshort\fPs for its parameters,
-that limits color-pairs and color-values
+Because \fB\%init_pair\fP uses signed \fBshort\fPs for its parameters,
+that limits color pairs and color-values
 to 32767 on modern hardware.
-The extension \fBinit_extended_pair\fP uses \fBint\fPs
-for the color-pair and color-value,
+The extension \fB\%init_extended_pair\fP uses \fBint\fPs
+for the color pair and color-value,
 allowing a larger number of colors to be supported.
 .SS init_color
-.PP
-The \fBinit_color\fR routine changes the definition of a color.
+The \fB\%init_color\fP routine changes the definition of a color.
 It takes four arguments:
 the number of the color to be changed followed by three RGB values
 (for the amounts of red, green, and blue components).
 .bP
-The first argument must be a legal color value;
+The first argument must be a valid color value;
 default colors are not allowed here.
-(See the section \fBColors\fR for the default color index.)
+(See the section \fB\%Colors\fP for the default color index.)
 .bP
 Each of the last three arguments
 must be a value in the range \fB0\fP through \fB1000\fP.
 .PP
-When \fBinit_color\fR is used, all
+When \fB\%init_color\fP is used, all
 occurrences of that color on the screen immediately change to the new
 definition.
 .SS init_extended_color
-.PP
-Because \fBinit_color\fP uses signed \fBshort\fPs for its parameters,
+Because \fB\%init_color\fP uses signed \fBshort\fPs for its parameters,
 that limits color-values and their red, green, and blue components
 to 32767 on modern hardware.
-The extension \fBinit_extended_color\fP uses \fBint\fPs
+The extension \fB\%init_extended_color\fP uses \fBint\fPs
 for the color value and
 for setting the red, green, and blue components,
 allowing a larger number of colors to be supported.
 .SS color_content
-.PP
-The \fBcolor_content\fR routine gives programmers a way to find the intensity
+The \fB\%color_content\fP routine gives programmers a way to find the intensity
 of the red, green, and blue (RGB) components in a color.
 It requires four arguments: the color number, and three addresses
 of \fBshort\fRs for storing
 the information about the amounts of red, green, and blue components in the
 given color.
 .bP
-The first argument must be a legal color value, i.e.,
-\fB0\fP through \fBCOLORS\-1\fP, inclusive.
+The first argument must be a valid color value, i.e.,
+\fB0\fP through \fB\%COLORS\-1\fP, inclusive.
 .bP
 The values that are stored at the addresses pointed to by the
 last three arguments are in the range
 \fB0\fP (no component) through \fB1000\fP
 (maximum amount of component), inclusive.
 .SS extended_color_content
-.PP
-Because \fBcolor_content\fP uses signed \fBshort\fPs for its parameters,
+Because \fB\%color_content\fP uses signed \fBshort\fPs for its parameters,
 that limits color-values and their red, green, and blue components
 to 32767 on modern hardware.
-The extension \fBextended_color_content\fP uses \fBint\fPs
+The extension \fB\%extended_color_content\fP uses \fBint\fPs
 for the color value and
 for returning the red, green, and blue components,
 allowing a larger number of colors to be supported.
 .SS pair_content
-.PP
-The \fBpair_content\fR routine allows programmers to find out what colors a
-given color-pair consists of.
-It requires three arguments: the color-pair
+The \fB\%pair_content\fP routine allows programmers to find out what colors a
+given color pair consists of.
+It requires three arguments: the color pair
 number, and two addresses of \fBshort\fRs for storing the foreground and the
 background color numbers.
 .bP
-The first argument must be a legal color value,
-i.e., in the range \fB1\fP through \fBCOLOR_PAIRS\-1\fR, inclusive.
+The first argument must be a valid color value,
+i.e., in the range \fB1\fP through \fB\%COLOR_PAIRS\-1\fP, inclusive.
 .bP
 The values that are stored at the addresses pointed
 to by the second and third arguments are in the
-range \fB0\fP through \fBCOLORS\fR, inclusive.
+range \fB0\fP through \fB\%COLORS\fP, inclusive.
 .SS extended_pair_content
-.PP
-Because \fBpair_content\fP uses signed \fBshort\fPs for its parameters,
-that limits color-pair and color-values to 32767 on modern hardware.
-The extension \fBextended_pair_content\fP uses \fBint\fPs
+Because \fB\%pair_content\fP uses signed \fBshort\fPs for its parameters,
+that limits color pair and color-values to 32767 on modern hardware.
+The extension \fB\%extended_pair_content\fP uses \fBint\fPs
 for the color pair and
 for returning the foreground and background colors,
 allowing a larger number of colors to be supported.
 .SS reset_color_pairs
-.PP
-The extension \fBreset_color_pairs\fP tells ncurses to discard all
-of the color-pair information which was set with \fBinit_pair\fP.
+The extension \fB\%reset_color_pairs\fP tells \fI\%ncurses\fP to discard
+all of the color pair information which was set with \fB\%init_pair\fP.
 It also touches the current- and standard-screens, allowing an application to
 switch color palettes rapidly.
-.SS PAIR_NUMBER
-.PP
-\fBPAIR_NUMBER(\fR\fIattrs\fR) extracts the color
-value from its \fIattrs\fP parameter and returns it as a color pair number.
 .SS COLOR_PAIR
-Its inverse \fBCOLOR_PAIR(\fR\fIn\fR\fB)\fR converts a color pair number
-to an attribute.
+\fB\%COLOR_PAIR(\fIn\fB)\fR converts a color pair number to an
+attribute.
 Attributes can hold color pairs in the range 0 to 255.
-If you need a color pair larger than that, you must use functions
-such as \fBattr_set\fP (which pass the color pair as a separate parameter)
-rather than the legacy functions such as \fBattrset\fP.
+If you need a color pair larger than that,
+you must use functions such as \fB\%attr_set\fP
+(which pass the color pair as a separate parameter)
+rather than the legacy functions such as \fB\%attrset\fP.
+.SS PAIR_NUMBER
+\fB\%PAIR_NUMBER(\fIattr\fR) extracts the color information from its
+\fIattr\fP parameter and returns it as a color pair number;
+it is the inverse operation of \fB\%COLOR_PAIR\fP.
 .SH RETURN VALUE
-The routines \fBcan_change_color\fR and \fBhas_colors\fR return \fBTRUE\fR
-or \fBFALSE\fR.
+The routines \fB\%can_change_color\fP and \fB\%has_colors\fP return \fBTRUE\fP
+or \fBFALSE\fP.
 .PP
-All other routines return the integer \fBERR\fR upon failure and an \fBOK\fR
+All other routines return the integer \fBERR\fP upon failure and an \fBOK\fP
 (SVr4 specifies only \*(``an integer value
-other than \fBERR\fR\*('') upon successful completion.
+other than \fBERR\fP\*('') upon successful completion.
 .PP
 X/Open defines no error conditions.
 SVr4 does document some error conditions which apply in general:
 .bP
-This implementation will return \fBERR\fR on attempts to
-use color values outside the range \fB0\fP to \fBCOLORS\fP\-1
+This implementation will return \fBERR\fP on attempts to
+use color values outside the range \fB0\fP to \fB\%COLORS\fP\-1
 (except for the default colors extension),
-or use color pairs outside the range \fB0\fP to \fBCOLOR_PAIRS\-1\fP.
+or use color pairs outside the range \fB0\fP to \fB\%COLOR_PAIRS\-1\fP.
 .IP
-Color values used in \fBinit_color\fP must be
+Color values used in \fB\%init_color\fP must be
 in the range \fB0\fP to \fB1000\fP.
 .IP
 An error is returned from all functions
 if the terminal has not been initialized.
 .IP
-An error is returned from secondary functions such as \fBinit_pair\fP
-if \fBstart_color\fP was not called.
+An error is returned from secondary functions such as \fB\%init_pair\fP
+if \fB\%start_color\fP was not called.
 .bP
 SVr4 does much the same, except that
-it returns \fBERR\fP from \fBpair_content\fP if the pair was not initialized
-using \fBinit_pairs\fP
-and 
-it returns \fBERR\fP from \fBcolor_content\fP
+it returns \fBERR\fP from \fB\%pair_content\fP if the pair was not initialized
+using \fB\%init_pairs\fP
+and
+it returns \fBERR\fP from \fB\%color_content\fP
 if the terminal does not support changing colors.
 .IP
 This implementation does not return \fBERR\fP for either case.
@@ -431,19 +454,20 @@ This implementation does not return \fBERR\fP for either case.
 Specific functions make additional checks:
 .RS 3
 .TP 5
-\fBinit_color\fP
+\fB\%init_color\fP
 returns an error if the terminal does not support
-this feature, e.g., if the \fBinitialize_color\fP capability is absent
+this feature, e.g., if the \fB\%initialize_color\fP capability is absent
 from the terminal description.
 .TP 5
-\fBstart_color\fP
+\fB\%start_color\fP
 returns an error if the color table cannot be allocated.
 .RE
 .SH NOTES
-In the \fBncurses\fR implementation, there is a separate color activation flag,
+In the \fI\%ncurses\fP implementation,
+there is a separate color activation flag,
 color palette, color pairs table,
-and associated \fBCOLORS\fP and \fBCOLOR_PAIRS\fP counts
-for each screen; the \fBstart_color\fR function only affects the current
+and associated \fB\%COLORS\fP and \fB\%COLOR_PAIRS\fP counts
+for each screen; the \fB\%start_color\fP function only affects the current
 screen.
 The SVr4/XSI interface is not really designed with this in mind, and
 historical implementations may use a single shared color palette.
@@ -452,13 +476,13 @@ Setting an implicit background color via a color pair affects only
 character cells that a character write operation explicitly touches.
 To change
 the background color used when parts of a window are blanked by erasing or
-scrolling operations, see \fBcurs_bkgd\fR(3X).
+scrolling operations, see \fB\%curs_bkgd\fP(3X).
 .PP
 Several caveats apply on older x86 machines
 (e.g., i386, i486) with VGA-compatible graphics:
 .bP
 COLOR_YELLOW is actually brown.
-To get yellow, use COLOR_YELLOW combined with the \fBA_BOLD\fR attribute.
+To get yellow, use COLOR_YELLOW combined with the \fBA_BOLD\fP attribute.
 .bP
 The A_BLINK attribute should in theory cause the background to go bright.
 This often fails to work, and even some cards for which it mostly works
@@ -467,21 +491,35 @@ Paradise and compatibles) do the wrong thing when you try to set a bright
 \*(``yellow\*('' background (you get a blinking yellow foreground instead).
 .bP
 Color RGB values are not settable.
+.SH EXTENSIONS
+The functions marked as extensions were designed for
+\fB\%ncurses\fP(3X),
+and are not found in SVr4
+.IR curses ,
+4.4BSD
+.IR curses ,
+or any other previous curses implementation.
 .SH PORTABILITY
-This implementation satisfies XSI Curses's minimum maximums
-for \fBCOLORS\fR and \fBCOLOR_PAIRS\fR.
+Applications employing
+.I \%ncurses
+extensions should condition their use on the visibility of the
+.B \%NCURSES_VERSION
+preprocessor macro.
 .PP
-The \fBinit_pair\fP routine accepts negative values of foreground
-and background color to support the \fBuse_default_colors\fR(3X) extension,
+This implementation satisfies X/Open Curses's minimum maximums
+for \fB\%COLORS\fP and \fB\%COLOR_PAIRS\fP.
+.PP
+The \fB\%init_pair\fP routine accepts negative values of foreground
+and background color to support the \fB\%use_default_colors\fP(3X) extension,
 but only if that routine has been first invoked.
 .PP
-The assumption that \fBCOLOR_BLACK\fR is the default
+The assumption that \fB\%COLOR_BLACK\fP is the default
 background color for all terminals can be modified using the
-\fBassume_default_colors\fR(3X) extension.
+\fB\%assume_default_colors\fP(3X) extension.
 .PP
 This implementation checks the pointers,
 e.g., for the values returned by
-\fBcolor_content\fP and \fBpair_content\fP,
+\fB\%color_content\fP and \fB\%pair_content\fP,
 and will treat those as optional parameters when null.
 .PP
 X/Open Curses does not specify a limit for the number of colors and
@@ -493,10 +531,59 @@ This implementation provides extended versions of those functions
 which use \fBshort\fP parameters,
 allowing applications to use larger color- and pair-numbers.
 .PP
-The \fBreset_color_pairs\fP function is an extension of ncurses.
+The \fB\%reset_color_pairs\fP function is an extension of
+\fI\%ncurses\fP.
+.SH HISTORY
+SVr3.2 introduced color support to curses in 1987.
+.PP
+SVr4 made internal changes,
+e.g., moving the storage for the color state
+from \fBSP\fP (the \fISCREEN\fP structure)
+to \fB\%cur_term\fP (the \fI\%TERMINAL\fP structure),
+but provided the same set of library functions.
+.PP
+SVr4 curses limits the number of color pairs to 64,
+reserving color pair zero (0) as the terminal's initial uncolored state.
+This limit arises because the color pair information is a bitfield
+in the \fB\%chtype\fP data type (denoted by \fB\%A_COLOR\fP).
+.PP
+Other implementations of curses had different limits:
+.bP
+PCCurses (1987-1990) provided for only eight (8) colors.
+.bP
+PDCurses (1992-present) inherited the 8-color limitation from PCCurses,
+but changed this to 256 in version 2.5 (2001),
+along with changing \fB\%chtype\fP from 16-bits to 32-bits.
+.bP
+X/Open Curses (1992-present)
+added a new structure \fB\%cchar_t\fP to store the character,
+attributes and color pair values, allowing increased range of color pairs.
+Both color pairs and color-values used a signed \fBshort\fP,
+limiting values to 15 bits.
+.bP
+\fI\%ncurses\fP (1992-present) uses eight bits
+for \fB\%A_COLOR\fP in \fB\%chtype\fP values.
+.IP
+Version 5.3 provided a wide-character interface (2002),
+but left color pairs as part of the attributes-field.
+.IP
+Since version 6 (2015),
+ncurses uses a separate \fBint\fP for color pairs in the \fB\%cchar_t\fP values.
+When those color pair values fit in 8 bits,
+ncurses allows color pairs to be manipulated
+via the functions using \fB\%chtype\fP values.
+.bP
+NetBSD curses used 6 bits from
+2000 (when colors were first supported) until 2004.
+At that point, NetBSD changed to use 10 bits.
+As of 2021, that size is unchanged.
+Like \fI\%ncurses\fP before version 6,
+the NetBSD color pair information is stored in
+the attributes field of \fB\%cchar_t\fP, limiting the number of color pairs
+by the size of the bitfield.
 .SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_initscr\fR(3X),
-\fBcurs_attr\fR(3X),
-\fBcurs_variables\fR(3X),
-\fBdefault_colors\fR(3X)
+\fB\%curses\fP(3X),
+\fB\%curs_attr\fP(3X),
+\fB\%curs_initscr\fP(3X),
+\fB\%curs_variables\fP(3X),
+\fB\%default_colors\fP(3X)
diff --git a/contrib/ncurses/man/curs_delch.3x b/contrib/ncurses/man/curs_delch.3x
index 86f0984cdbe8..e62ecc130de1 100644
--- a/contrib/ncurses/man/curs_delch.3x
+++ b/contrib/ncurses/man/curs_delch.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2006,2010 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,50 +27,87 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_delch.3x,v 1.15 2020/10/24 09:36:43 tom Exp $
-.TH curs_delch 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: curs_delch.3x,v 1.34 2024/04/20 19:24:14 tom Exp $
+.TH curs_delch 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
 .SH NAME
-\fBdelch\fR,
-\fBwdelch\fR,
-\fBmvdelch\fR,
-\fBmvwdelch\fR \- delete character under the cursor in a \fBcurses\fR window
+\fB\%delch\fP,
+\fB\%wdelch\fP,
+\fB\%mvdelch\fP,
+\fB\%mvwdelch\fP \-
+delete a character from a \fIcurses\fR window
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBint delch(void);\fR
-.br
-\fBint wdelch(WINDOW *\fP\fIwin\fP\fB);\fR
-.br
-\fBint mvdelch(int \fP\fIy\fP\fB, int \fP\fIx\fP\fB);\fR
-.br
-\fBint mvwdelch(WINDOW *\fP\fIwin\fP\fB, int \fP\fIy\fP\fB, int \fP\fIx\fP\fB);\fR
-.br
+.nf
+\fB#include <curses.h>
+.PP
+\fBint delch(void);
+\fBint wdelch(WINDOW *\fIwin\fP);
+\fBint mvdelch(int \fIy\fP, int \fIx\fP);
+\fBint mvwdelch(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP);
+.fi
 .SH DESCRIPTION
-These routines delete the character under the cursor; all characters to the
-right of the cursor on the same line are moved to the left one position and the
-last character on the line is filled with a blank.
-The cursor position does
-not change (after moving to \fIy\fR, \fIx\fR, if specified).
-(This does not
-imply use of the hardware delete character feature.)
+.B \%wdelch
+deletes the character at the cursor position in
+.IR win .
+\fB\%ncurses\fP(3X) describes the variants of this function.
+.PP
+.B \%wdelch
+moves all characters to the right of the cursor on the same line to the
+left one position and replaces the contents of the rightmost position on
+the line with the window's blank character;
+see \fB\%bkgd\fP(3X)
+(wide-character API users may consult \fB\%bkgrnd\fP(3X) instead).
+The cursor position does not change
+(after moving to
+.RI ( y ,
+.IR x ),
+if specified).
 .SH RETURN VALUE
-All routines return the integer \fBERR\fR upon failure and an \fBOK\fR (SVr4
-specifies only "an integer value other than \fBERR\fR") upon successful
-completion.
+These functions return
+.B OK
+on success and
+.B ERR
+on failure.
+.PP
+Functions taking a
+.I \%WINDOW
+pointer argument fail if the pointer is
+.BR NULL .
 .PP
-Functions with a \*(``mv\*('' prefix first perform a cursor movement using
-\fBwmove\fP, and return an error if the position is outside the window,
-or if the window pointer is null.
+Functions prefixed with \*(``mv\*('' first perform cursor movement and
+fail if the position
+.RI ( y ,
+.IR x )
+is outside the window boundaries.
 .SH NOTES
-Note that \fBdelch\fR, \fBmvdelch\fR, and \fBmvwdelch\fR may be macros.
+.BR \%delch ,
+.BR \%mvdelch ,
+and
+.B \%mvwdelch
+may be implemented as macros.
+.PP
+A terminal's
+.B \%delete_character
+.RB ( dch1 )
+capability
+is not necessarily employed.
 .SH PORTABILITY
-These functions are described in the XSI Curses standard, Issue 4.
-The
-standard specifies that they return \fBERR\fR on failure, but specifies no
-error conditions.
+X/Open Curses,
+Issue 4 describes these functions.
+.PP
+SVr4
+.I curses
+describes a successful return value only as
+\*(``an integer value other than
+.BR ERR \*(''.
 .SH SEE ALSO
-\fBcurses\fR(3X)
+\fB\%curses\fP(3X)
diff --git a/contrib/ncurses/man/curs_deleteln.3x b/contrib/ncurses/man/curs_deleteln.3x
index 391c80094192..6d70a4358c4f 100644
--- a/contrib/ncurses/man/curs_deleteln.3x
+++ b/contrib/ncurses/man/curs_deleteln.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2007,2010 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,67 +27,78 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_deleteln.3x,v 1.17 2020/10/18 00:28:51 tom Exp $
-.TH curs_deleteln 3X ""
+.\" $Id: curs_deleteln.3x,v 1.38 2024/04/20 21:20:07 tom Exp $
+.TH curs_deleteln 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .SH NAME
-\fBdeleteln\fR,
-\fBwdeleteln\fR,
-\fBinsdelln\fR,
-\fBwinsdelln\fR,
-\fBinsertln\fR,
-\fBwinsertln\fR \- delete and insert lines in a \fBcurses\fR window
+\fB\%deleteln\fP,
+\fB\%wdeleteln\fP,
+\fB\%insdelln\fP,
+\fB\%winsdelln\fP,
+\fB\%insertln\fP,
+\fB\%winsertln\fP \-
+delete or insert lines in a \fIcurses\fR window
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBint deleteln(void);\fR
-.br
-\fBint wdeleteln(WINDOW *\fP\fIwin\fP\fB);\fR
-.sp
-\fBint insdelln(int \fP\fIn\fP\fB);\fR
-.br
-\fBint winsdelln(WINDOW *\fP\fIwin\fP\fB, int \fP\fIn\fP\fB);\fR
-.sp
-\fBint insertln(void);\fR
-.br
-\fBint winsertln(WINDOW *\fP\fIwin\fP\fB);\fR
-.br
+.nf
+\fB#include <curses.h>
+.PP
+\fBint deleteln(void);
+\fBint wdeleteln(WINDOW *\fIwin\fP);
+.PP
+\fBint insdelln(int \fIn\fP);
+\fBint winsdelln(WINDOW *\fIwin\fP, int \fIn\fP);
+.PP
+\fBint insertln(void);
+\fBint winsertln(WINDOW *\fIwin\fP);
+.fi
 .SH DESCRIPTION
-The \fBdeleteln\fR and \fBwdeleteln\fR routines delete the line under the
+The \fBdeleteln\fP and \fBwdeleteln\fP routines delete the line under the
 cursor in the window; all lines below the current line are moved up one line.
 The bottom line of the window is cleared.
 The cursor position does not change.
 .PP
-The \fBinsdelln\fR and \fBwinsdelln\fR routines, for positive \fIn\fR, insert
-\fIn\fR lines into the specified window above the current line.
-The \fIn\fR
+The \fBinsdelln\fP and \fBwinsdelln\fP routines, for positive \fIn\fP, insert
+\fIn\fP lines into the specified window above the current line.
+The \fIn\fP
 bottom lines are lost.
-For negative \fIn\fR, delete \fIn\fR lines (starting
+For negative \fIn\fP, delete \fIn\fP lines (starting
 with the one under the cursor), and move the remaining lines up.
 The bottom
-\fIn\fR lines are cleared.
+\fIn\fP lines are cleared.
 The current cursor position remains the same.
 .PP
-The \fBinsertln\fR and \fBwinsertln\fR routines insert a blank line above the
+The \fBinsertln\fP and \fBwinsertln\fP routines insert a blank line above the
 current line and the bottom line is lost.
 .SH RETURN VALUE
-All routines return the integer \fBERR\fR upon failure and an \fBOK\fR (SVr4
-specifies only "an integer value other than \fBERR\fR") upon successful
-completion.
+These routines return the integer \fBERR\fP upon failure and an \fBOK\fP
+(SVr4 specifies only
+\*(``an integer value other than \fBERR\fP\*('')
+upon successful completion.
 .PP
 X/Open defines no error conditions.
 In this implementation,
 if the window parameter is null, an error is returned.
-.SH PORTABILITY
-These functions are described in the XSI Curses standard, Issue 4.
-The
-standard specifies that they return \fBERR\fR on failure, but specifies no
-error conditions.
 .SH NOTES
-Note that all but \fBwinsdelln\fR may be macros.
+Note that all but \fBwinsdelln\fP may be macros.
 .PP
 These routines do not require a hardware line delete or insert feature in the
 terminal.
 In fact, they will not use hardware line delete/insert unless
-\fBidlok(..., TRUE)\fR has been set on the current window.
+\fBidlok(..., TRUE)\fP has been set on the current window.
+.SH PORTABILITY
+These functions are described in X/Open Curses, Issue 4.
+The
+standard specifies that they return \fBERR\fP on failure, but specifies no
+error conditions.
 .SH SEE ALSO
-\fBcurses\fR(3X)
+\fB\%curses\fP(3X)
diff --git a/contrib/ncurses/man/curs_extend.3x b/contrib/ncurses/man/curs_extend.3x
index 52ba27d07fb3..01cf9d2ece71 100644
--- a/contrib/ncurses/man/curs_extend.3x
+++ b/contrib/ncurses/man/curs_extend.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1999-2010,2016 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -29,28 +29,41 @@
 .\"
 .\" Author: Thomas E. Dickey 1999-on
 .\"
-.\" $Id: curs_extend.3x,v 1.24 2020/10/24 09:37:07 tom Exp $
-.TH curs_extend 3X ""
+.\" $Id: curs_extend.3x,v 1.46 2024/03/16 15:35:01 tom Exp $
+.TH curs_extend 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
 .SH NAME
-\fBcurses_version\fP,
-\fBuse_extended_names\fP \- miscellaneous curses extensions
-.
+\fB\%curses_version\fP,
+\fB\%use_extended_names\fP \-
+miscellaneous \fIcurses\fR extensions
 .SH SYNOPSIS
-\fB#include <curses.h>\fP
-.sp
-\fBconst char * curses_version(void);\fP
-.br
-\fBint use_extended_names(bool \fP\fIenable\fP\fB);\fP
+.nf
+\fB#include <curses.h>
+.PP
+\fBconst char * curses_version(void);
+\fBint use_extended_names(bool \fIenable\fP);
+.fi
 .SH DESCRIPTION
 These functions are extensions to the curses library
 which do not fit easily into other categories.
 .SS curses_version
-.PP
 Use \fBcurses_version\fP
-to get the version number, including patch level of the library, e.g.,
-.B 5.0.19991023
+to get the version number, including patch level of the library,
+prefixed by \*(``ncurses\*('', e.g.,
+.RS
+.sp
+.B ncurses 5.0.19991023
+.RE
 .SS use_extended_names
-.PP
 The \fBuse_extended_names\fP
 function controls whether the calling application
 is able to use user-defined or nonstandard names
@@ -62,28 +75,34 @@ extended terminal definitions.
 However you can disable this feature
 to ensure compatibility with other implementations of curses.
 .SH RETURN VALUE
-.PP
 \fBcurses_version\fP returns a pointer to static memory; you should not free
 this in your application.
 .PP
 \fBuse_extended_names\fP returns the previous state, allowing you to
 save this and restore it.
+.SH EXTENSIONS
+These functions are \fB\%ncurses\fP(3X) extensions,
+and are not found in SVr4
+.IR curses ,
+4.4BSD
+.IR curses ,
+or any other previous curses implementation.
 .SH PORTABILITY
-These routines are specific to ncurses.
-They were not supported on
-Version 7, BSD or System V implementations.
-It is recommended that
-any code depending on them be conditioned using NCURSES_VERSION.
-.SH SEE ALSO
-\fBcurs_getch\fR(3X),
-\fBcurs_mouse\fR(3X),
-\fBcurs_print\fR(3X),
-\fBcurs_util\fR(3X),
-\fBdefault_colors\fR(3X),
-\fBdefine_key\fR(3X),
-\fBkeybound\fR(3X),
-\fBkeyok\fR(3X),
-\fBresizeterm\fR(3X),
-\fBwresize\fR(3X).
-.SH AUTHOR
+Applications employing
+.I \%ncurses
+extensions should condition their use on the visibility of the
+.B \%NCURSES_VERSION
+preprocessor macro.
+.SH AUTHORS
 Thomas Dickey.
+.SH SEE ALSO
+\fB\%curs_getch\fP(3X),
+\fB\%curs_mouse\fP(3X),
+\fB\%curs_print\fP(3X),
+\fB\%curs_util\fP(3X),
+\fB\%default_colors\fP(3X),
+\fB\%define_key\fP(3X),
+\fB\%keybound\fP(3X),
+\fB\%keyok\fP(3X),
+\fB\%resizeterm\fP(3X),
+\fB\%wresize\fP(3X)
diff --git a/contrib/ncurses/man/curs_get_wch.3x b/contrib/ncurses/man/curs_get_wch.3x
index dfa5c7e914de..02932b91a6e4 100644
--- a/contrib/ncurses/man/curs_get_wch.3x
+++ b/contrib/ncurses/man/curs_get_wch.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 2002-2016,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,159 +27,233 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_get_wch.3x,v 1.14 2020/10/17 23:17:05 tom Exp $
-.TH curs_get_wch 3X ""
-.na
-.hy 0
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: curs_get_wch.3x,v 1.40 2024/04/20 19:23:03 tom Exp $
+.TH curs_get_wch 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
 .SH NAME
-\fBget_wch\fR,
-\fBwget_wch\fR,
-\fBmvget_wch\fR,
-\fBmvwget_wch\fR,
-\fBunget_wch\fR \- get (or push back) a wide character from curses terminal keyboard
-.ad
-.hy
+\fB\%get_wch\fP,
+\fB\%wget_wch\fP,
+\fB\%mvget_wch\fP,
+\fB\%mvwget_wch\fP,
+\fB\%unget_wch\fP \-
+get (or push back) a wide character from \fIcurses\fR terminal keyboard
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBint get_wch(wint_t *\fR\fIwch\fR\fB);\fR
-.br
-\fBint wget_wch(WINDOW *\fR\fIwin\fR\fB, wint_t *\fR\fIwch\fR\fB);\fR
-.br
-\fBint mvget_wch(int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, wint_t *\fR\fIwch\fR\fB);\fR
-.br
-\fBint mvwget_wch(WINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, wint_t *\fR\fIwch\fR\fB);\fR
-.sp
-\fBint unget_wch(const wchar_t \fR\fIwch\fR\fB);\fR
+.nf
+\fB#include <curses.h>
+.PP
+\fBint get_wch(wint_t *\fIwch\fP);
+\fBint wget_wch(WINDOW *\fIwin\fP, wint_t *\fIwch\fP);
+\fBint mvget_wch(int \fIy\fP, int \fIx\fP, wint_t *\fIwch\fP);
+\fBint mvwget_wch(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, wint_t *\fIwch\fP);
+.PP
+\fBint unget_wch(const wchar_t \fIwc\fP);
+.fi
 .SH DESCRIPTION
-The
-\fBget_wch\fR,
-\fBwget_wch\fR,
-\fBmvget_wch\fR, and
-\fBmvwget_wch\fR
-functions read a character
-from the terminal associated with the current or specified window.
-In no-delay mode,
-if no input is waiting, the value \fBERR\fR is returned.
-In delay mode,
-the program waits until the system passes text through to the program.
-Depending on the setting of \fBcbreak\fR,
-this is after one character (cbreak mode),
-or after the first newline (nocbreak mode).
-In half-delay mode,
-the program waits until the user types a character or the specified
-timeout interval has elapsed.
+.SS "Reading Characters"
+.B \%wget_wch
+gathers a key stroke
+.I wch
+from the terminal keyboard associated with a
+.I curses
+window
+.IR win ,
+returning
+.B OK
+if a wide character is read,
+.B \%KEY_CODE_YES
+if a function key is read,
+and
+.B ERR
+if no key event is available.
+\fB\%ncurses\fP(3X) describes the variants of this function.
 .PP
-Unless \fBnoecho\fR has been set,
-these routines echo the character into the designated window.
+When input is pending,
+.B \%wget_wch
+stores an integer
+identifying the key stroke in
+.IR wch ;
+for alphanumeric and punctuation keys,
+this value corresponds to the character encoding used by the terminal.
+Use of the control key as a modifier often results in a distinct code.
+The behavior of other keys depends on whether
+.I win
+is in keypad mode;
+see subsections \*(``Keypad Mode\*('' and \*(``Predefined Key Codes\*(''
+in \fB\%getch\fP(3X).
 .PP
-If the window is not a pad and has been moved or modified since the
-last call to \fBwrefresh\fR,
-\fBwrefresh\fR will be called before another character is read.
+If no input is pending,
+then if the no-delay flag is set in the window
+(see \fB\%nodelay\fP(3X)),
+the function returns
+.BR ERR ;
+otherwise,
+.I curses
+waits until the terminal has input.
+If \fB\%cbreak\fP(3X)
+has been called,
+this happens after one character is read.
+If \fB\%nocbreak\fP(3X)
+has been called,
+it occurs when the next newline is read.
+If \fB\%halfdelay\fP(3X)
+has been called,
+.I curses
+waits until a character is typed or the specified delay elapses.
 .PP
-If \fBkeypad\fR is enabled,
-these functions respond to
-the pressing of a function key by setting the object pointed to by
-\fIwch\fR
-to the keycode assigned to the function key,
-and returning \fBKEY_CODE_YES\fR.
-If a character (such as escape) that could be the
-beginning of a function key is received, curses sets a timer.
-If the remainder
-of the sequence does arrive within the designated time, curses passes through
-the character; otherwise, curses returns the function key value.
-For this
-reason, many terminals experience a delay between the time a user presses
-the escape key and the time the escape is returned to the program.
+If \fB\%echo\fP(3X) has been called,
+and the window is not a pad,
+.I curses
+writes
+.I wch
+to the window
+(at the cursor position)
+per the following rules.
+.bP
+If
+.I wch
+matches the terminal's erase character,
+the cursor moves leftward one position
+and the new position is erased
+as if \fB\%wmove\fP(3X) and then \fB\%wdelch\fP(3X) were called.
+When the window's keypad mode is enabled
+(see below),
+.B \%KEY_LEFT
+and
+.B \%KEY_BACKSPACE
+are handled the same way.
+.bP
+.I curses
+writes any other
+.I wch
+to the window,
+as with \fB\%wecho_wchar\fP(3X).
+.bP
+If the window has been moved or modified since the last call to
+\fB\%wrefresh\fP(3X),
+.I curses
+calls
+.BR \%wrefresh .
 .PP
-The keycodes returned by these functions are the same as those
-returned by \fBwgetch\fP:
+If
+.I wch
+is a carriage return and \fBnl\fP(3X) has been called,
+.B \%wgetch
+stores the the character code for newline
+(line feed)
+in
+.I wch
+instead.
+.SS "Ungetting Characters"
+.B \%unget_wch
+places
+.I wch
+into the input queue to be returned by the next call to
+.BR \%wget_wch .
+A single input queue serves all windows.
+.SH RETURN VALUE
+.B \%wget_wch
+returns
+.B OK
+when it reads a wide character and
+.B \%KEY_CODE_YES
+when it reads a function key code.
+It returns
+.B ERR
+if
 .bP
-The predefined function
-keys are listed in \fB<curses.h>\fR as macros with values outside the range
-of 8-bit characters.
-Their names begin with \fBKEY_\fR.
+the
+.I \%WINDOW
+pointer is
+.BR NULL ,
+or
 .bP
-Other (user-defined) function keys
-which may be defined using \fBdefine_key\fP(3X) have no names,
-but also are expected to have values outside the range of 8-bit characters.
+its timeout expires without any data arriving,
+or
+.bP
+execution was interrupted by a signal,
+in which case
+.B \%errno
+is set to
+.BR \%EINTR .
+.PP
+Functions prefixed with \*(``mv\*('' first perform cursor movement and
+fail if the position
+.RI ( y ,
+.IR x )
+is outside the window boundaries.
 .PP
-The
-\fBunget_wch\fR
-function pushes the wide character
-\fIwch\fR
-back onto the head of the input queue, so the wide character
-is returned by the next call to
-\fBget_wch\fR.
-The pushback of
-one character is guaranteed.
-If the program calls
-\fBunget_wch\fR
-too many times without an intervening call to
-\fBget_wch\fR,
-the operation may fail.
+.B \%unget_wch
+returns
+.B OK
+on success and
+.B ERR
+if there is no more room in the input queue.
 .SH NOTES
-The header file
-\fB<curses.h>\fR
-automatically
-includes the header file
-\fB<stdio.h>\fR.
+See the \*(``NOTES\*('' section of \fB\%wgetch\fP(3X).
 .PP
-Applications should not define the escape key by itself as a single-character
-function.
+All of these functions except
+.B \%wget_wch
+and
+.B \%unget_wch
+may be implemented as macros.
 .PP
-When using
-\fBget_wch\fR,
-\fBwget_wch\fR,
-\fBmvget_wch\fR, or
-\fBmvwget_wch\fR, applications should
-not use
-\fBnocbreak\fR
-mode and
-\fBecho\fR
-mode
-at the same time.
-Depending on the state of the tty driver when each character
-is typed, the program may produce undesirable results.
+Unlike \fB\%wgetch\fP(3X),
+.B \%wget_wch
+and its variants store the value of the input character in an additional
+.I wch
+parameter instead of the return value.
 .PP
-All functions except \fBwget_wch\fR and \fBunget_wch\fR
-may be macros.
-.SH RETURN VALUE
-When
-\fBget_wch\fR,
-\fBwget_wch\fR,
-\fBmvget_wch\fR, and
-\fBmvwget_wch\fR
-functions successfully
-report the pressing of a function key, they return
-\fBKEY_CODE_YES\fR.
-When they successfully report a wide character, they return
-\fBOK\fR.
-Otherwise, they return
-\fBERR\fR.
+Unlike
+.BR \%ungetch ,
+.B \%unget_wch
+cannot distinguish function key codes
+.B \%wget_wch
+from conventional character codes.
+An application can overcome this limitation by pushing function key
+codes with
+.B \%ungetch
+and subsequently checking the return value of
+.B \%wget_wch
+for a match with
+.BR \%KEY_CODE_YES .
+.SH EXTENSIONS
+See the \*(``EXTENSIONS\*('' section of \fB\%wgetch\fP(3X).
+.SH PORTABILITY
+Applications employing
+.I \%ncurses
+extensions should condition their use on the visibility of the
+.B \%NCURSES_VERSION
+preprocessor macro.
 .PP
-Upon successful completion,
-\fBunget_wch\fR
-returns
-\fBOK\fR.
-Otherwise, the function returns
-\fBERR\fR.
+X/Open Curses,
+Issue 4 describes these functions.
+It specifies no error conditions for them.
 .PP
-Functions with a \*(``mv\*('' prefix first perform a cursor movement using
-\fBwmove\fP, and return an error if the position is outside the window,
-or if the window pointer is null.
+See the \*(``PORTABILITY\*('' section of \fB\%wgetch\fP(3X) regarding
+the interaction of
+.B \%wget_wch
+with signal handlers.
 .SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_getch\fR(3X),
-\fBcurs_ins_wch\fR(3X),
-\fBcurs_inopts\fR(3X),
-\fBcurs_move\fR(3X),
-\fBcurs_refresh\fR(3X)
+\fB\%curs_getch\fP(3X) describes comparable functions of the
+.I \%ncurses
+library in its non-wide-character configuration.
+.PP
+\fB\%curses\fP(3X),
+\fB\%curs_add_wch\fP(3X),
+\fB\%curs_inopts\fP(3X),
+\fB\%curs_move\fP(3X),
+\fB\%curs_refresh\fP(3X)
diff --git a/contrib/ncurses/man/curs_get_wstr.3x b/contrib/ncurses/man/curs_get_wstr.3x
index 112208ae918e..32ae541abaf9 100644
--- a/contrib/ncurses/man/curs_get_wstr.3x
+++ b/contrib/ncurses/man/curs_get_wstr.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 2002-2012,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,175 +27,180 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_get_wstr.3x,v 1.21 2020/10/17 23:17:24 tom Exp $
-.TH curs_get_wstr 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: curs_get_wstr.3x,v 1.48 2024/04/20 19:18:18 tom Exp $
+.TH curs_get_wstr 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.na
-.hy 0
 .SH NAME
-\fBget_wstr\fR,
-\fBgetn_wstr\fR,
-\fBwget_wstr\fR,
-\fBwgetn_wstr\fR,
-\fBmvget_wstr\fR,
-\fBmvgetn_wstr\fR,
-\fBmvwget_wstr\fR,
-\fBmvwgetn_wstr\fR \- get an array of wide characters from a curses terminal keyboard
-.ad
-.hy
+\fB\%get_wstr\fP,
+\fB\%getn_wstr\fP,
+\fB\%wget_wstr\fP,
+\fB\%wgetn_wstr\fP,
+\fB\%mvget_wstr\fP,
+\fB\%mvgetn_wstr\fP,
+\fB\%mvwget_wstr\fP,
+\fB\%mvwgetn_wstr\fP \-
+get a wide-character string from a \fIcurses\fR terminal keyboard
 .SH SYNOPSIS
 .nf
-\fB#include <curses.h>\fR
-.sp
-\fBint get_wstr(wint_t *\fR\fIwstr\fR\fB);\fR
-.br
-\fBint getn_wstr(wint_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR
-.br
-\fBint wget_wstr(WINDOW *\fR\fIwin\fR\fB, wint_t *\fR\fIwstr\fR\fB);\fR
-.br
-\fBint wgetn_wstr(WINDOW *\fR\fIwin\fR\fB, wint_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR
-.sp
-\fBint mvget_wstr(int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, wint_t *\fR\fIwstr\fR\fB);\fR
-.br
-\fBint mvgetn_wstr(int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, wint_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR
-.br
-\fBint mvwget_wstr(WINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, wint_t *\fR\fIwstr\fR\fB);\fR
-.br
-\fBint mvwgetn_wstr(WINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, wint_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR
+\fB#include <curses.h>
+.PP
+\fBint get_wstr(wint_t *\fIwstr\fP);
+\fBint getn_wstr(wint_t *\fIwstr\fP, int \fIn\fP);
+\fBint wget_wstr(WINDOW *\fIwin\fP, wint_t *\fIwstr\fP);
+\fBint wgetn_wstr(WINDOW *\fIwin\fP, wint_t *\fIwstr\fP, int \fIn\fP);
+.PP
+\fBint mvget_wstr(int \fIy\fP, int \fIx\fP, wint_t *\fIwstr\fP);
+\fBint mvgetn_wstr(int \fIy\fP, int \fIx\fP, wint_t *\fIwstr\fP, int \fIn\fP);
+\fBint mvwget_wstr(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, wint_t *\fIwstr\fP);
+\fBint mvwgetn_wstr(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, wint_t *\fIwstr\fP, int \fIn\fP);
 .fi
 .SH DESCRIPTION
-The effect of
-\fBget_wstr\fR
-is as though a series of calls
-to
-\fBget_wch\fR(3X)
-were made, until a newline, other end-of-line,
-or end-of-file condition is processed.
-An end-of-file condition is represented by \fBWEOF\fR,
-as defined in \fB<wchar.h>\fR.
-The newline and end-of-line conditions are represented
-by the \fB\\n\fR \fBwchar_t\fR value.
-In all instances, the end of the string is terminated by a null \fBwchar_t\fR.
-The routine places resulting values in the area pointed to by \fIwstr\fR.
-.PP
-The user's erase and kill characters are interpreted.
-If keypad
-mode is on for the window, \fBKEY_LEFT\fR and \fBKEY_BACKSPACE\fR
-are both considered equivalent to the user's kill character.
-.PP
-Characters input are echoed only if \fBecho\fR is currently on.
+The function
+\fBwgetn_wstr\fP
+is equivalent to a series of calls to
+\fBwget_wch\fP(3X)
+until a newline or carriage return terminates the series:
+.bP
+The terminating character is not included in the returned string.
+.bP
+An end-of-file condition is represented by \fBWEOF\fP,
+as defined in \fB<wchar.h>\fP.
+.bP
+In all instances, the end of the string is terminated
+by a null \fBwchar_t\fP.
+.bP
+The function stores the result in the area pointed to
+by the \fIwstr\fP parameter.
+.bP
+The function reads at most \fIn\fP characters,
+thus preventing a possible overflow of the input buffer.
+.IP
+Any attempt to enter more characters
+(other than the terminating newline or carriage return)
+causes a beep.
+.IP
+Function keys also cause a beep and are ignored.
+.PP
+The user's \fIerase\fP and \fIkill\fP characters are interpreted:
+.bP
+The \fIerase\fP character (e.g., \fB^H\fP) erases the character
+at the end of the buffer, moving the cursor to the left.
+.IP
+If \fIkeypad\fP mode is on for the window,
+\fBKEY_LEFT\fP and \fBKEY_BACKSPACE\fP
+are both considered equivalent to the user's \fIerase\fP character.
+.bP
+The \fIkill\fP character (e.g., \fB^U\fP) erases the entire buffer,
+leaving the cursor at the beginning of the buffer.
+.PP
+Characters input are echoed only if \fBecho\fP is currently on.
 In that case,
-backspace is echoed as deletion of the previous character (typically a left
-motion).
-.PP
-The effect of
-\fBwget_wstr\fR
-is as though a series of
-calls to
-\fBwget_wch\fR
-were made.
-.PP
-The effect of
-\fBmvget_wstr\fR
-is as though a call to
-\fBmove\fR
-and then a series of calls to
-\fBget_wch\fR
-were
-made.
-.PP
-The effect of
-\fBmvwget_wstr\fR
-is as though a call to
-\fBwmove\fR
-and then a series of calls to
-\fBwget_wch\fR
-were made.
+backspace is echoed as deletion of the previous character
+(typically a left motion).
 .PP
 The
-\fBgetn_wstr\fR,
-\fBmvgetn_wstr\fR,
-\fBmvwgetn_wstr\fR, and
-\fBwgetn_wstr\fR
+\fBgetn_wstr\fP,
+\fBmvgetn_wstr\fP,
+\fBmvwgetn_wstr\fP, and
+\fBwgetn_wstr\fP
 functions are identical
 to the
-\fBget_wstr\fR,
-\fBmvget_wstr\fR,
-\fBmvwget_wstr\fR, and
-\fBwget_wstr\fR
+\fBget_wstr\fP,
+\fBmvget_wstr\fP,
+\fBmvwget_wstr\fP, and
+\fBwget_wstr\fP
 functions, respectively,
 except that the
-\fB*n_*\fR
+\fB*n_*\fP
 versions read at most
-\fIn\fR
+\fIn\fP
 characters, letting the application prevent overflow of the
 input buffer.
+.SH RETURN VALUE
+All of these functions return the integer \fBOK\fP upon successful completion.
+If unsuccessful, they return \fBERR\fP.
+.PP
+X/Open defines no error conditions.
+.PP
+In this implementation,
+these functions return an error
+.bP
+if the window pointer is null,
+.bP
+if its timeout expires without having any data, or
+.bP
+if the associated call to
+\fBwget_wch\fP
+failed.
+.PP
+Functions prefixed with \*(``mv\*('' first perform cursor movement and
+fail if the position
+.RI ( y ,
+.IR x )
+is outside the window boundaries.
 .SH NOTES
+Any of these functions other than
+\fBwgetn_wstr\fP
+may be macros.
+.PP
 Using
-\fBget_wstr\fR,
-\fBmvget_wstr\fR,
-\fBmvwget_wstr\fR, or
-\fBwget_wstr\fR
+\fBget_wstr\fP,
+\fBmvget_wstr\fP,
+\fBmvwget_wstr\fP, or
+\fBwget_wstr\fP
 to read a line that
 overflows the array pointed to by
-\fBwstr\fR
+\fBwstr\fP
 causes undefined
 results.
 The use of
-\fBgetn_wstr\fR,
-\fBmvgetn_wstr\fR,
-\fBmvwgetn_wstr\fR, or
-\fBwgetn_wstr\fR, respectively, is recommended.
+\fBgetn_wstr\fP,
+\fBmvgetn_wstr\fP,
+\fBmvwgetn_wstr\fP, or
+\fBwgetn_wstr\fP,
+respectively, is recommended.
 .PP
-These functions cannot return \fBKEY_\fR values because there
-is no way to distinguish a \fBKEY_\fR value from a valid \fBwchar_t\fR value.
-.PP
-All of these routines except \fBwgetn_wstr\fR may be macros.
-.SH RETURN VALUE
-All of these functions return \fBOK\fR upon successful completion.
-Otherwise, they return \fBERR\fR.
-.PP
-Functions using a window parameter return an error if it is null.
-.RS
-.TP 5
-\fBwgetn_wstr\fP
-returns an error if the associated call to \fBwget_wch\fP failed.
-.RE
-.PP
-Functions with a \*(``mv\*('' prefix first perform a cursor movement using
-\fBwmove\fP, and return an error if the position is outside the window,
-or if the window pointer is null.
+These functions cannot return \fBKEY_\fP values because there
+is no way to distinguish a \fBKEY_\fP value from a valid \fBwchar_t\fP value.
 .SH PORTABILITY
 These functions are described in The Single Unix Specification, Version 2.
 No error conditions are defined.
+.PP
 This implementation returns \fBERR\fP if the window pointer is null,
-or if the lower-level \fBwget_wch\fR call returns an \fBERR\fP.
+or if the lower-level \fBwget_wch\fP call returns an \fBERR\fP.
 In the latter case,
 an \fBERR\fP return without other data is treated as an end-of-file condition,
-and the returned array contains a \fBWEOF\fR followed by a null \fBwchar_t\fR.
+and the returned array contains a \fBWEOF\fP followed by a null \fBwchar_t\fP.
 .PP
-X/Open curses documented these functions to pass an array of \fBwchar_t\fR
+X/Open curses documented these functions to pass an array of \fBwchar_t\fP
 in 1997, but that was an error because of this part of the description:
 .RS
 .PP
-The effect of \fIget_wstr()\fP is as though a series of calls to
-\fIget_wch()\fP were made, until a newline character, end-of-line character, or
+The effect of \fBget_wstr\fP is as though a series of calls to
+\fBget_wch\fP were made, until a newline character, end-of-line character, or
 end-of-file character is processed.
 .RE
 .PP
-The latter function \fIget_wch()\fP can return a negative value,
+The latter function \fIget_wch\fP can return a negative value,
 while \fBwchar_t\fP is a unsigned type.
-All of the vendors implement this using \fBwint_t\fR, following the standard.
+All of the vendors implement this using \fBwint_t\fP, following the standard.
 .PP
 X/Open Curses, Issue 7 (2009) is unclear regarding whether
-the terminating \fInull \fP\fBwchar_t\fP
+the terminating \fInull \fBwchar_t\fR
 value is counted in the length parameter \fIn\fP.
 X/Open Curses, Issue 7 revised the corresponding description
 of \fBwgetnstr\fP to address this issue.
@@ -205,15 +210,17 @@ This implementation counts the terminator in the length.
 X/Open Curses does not specify what happens if the length \fIn\fP is negative.
 .bP
 For analogy with \fBwgetnstr\fP,
-ncurses 6.2 uses a limit (based on \fBLINE_MAX\fP).
+\fI\%ncurses\fP 6.2 uses a limit (based on \fBLINE_MAX\fP).
 .bP
 Some other implementations (such as Solaris xcurses) do the same,
 while others (PDCurses) do not allow this.
 .bP
-NetBSD 7 curses imitates ncurses 6.1 in this regard,
+NetBSD 7 curses imitates \fI\%ncurses\fP 6.1 in this regard,
 treating a \fB\-1\fP as an indefinite number of characters.
 .SH SEE ALSO
-Functions:
-\fBcurses\fR(3X),
-\fBcurs_get_wch\fR(3X),
-\fBcurs_getstr\fR(3X).
+\fB\%curs_getstr\fP(3X) describes comparable functions of the
+.I \%ncurses
+library in its non-wide-character configuration.
+.PP
+\fB\%curses\fP(3X),
+\fB\%curs_get_wch\fP(3X)
diff --git a/contrib/ncurses/man/curs_getcchar.3x b/contrib/ncurses/man/curs_getcchar.3x
index fafe78251461..523cc99df92c 100644
--- a/contrib/ncurses/man/curs_getcchar.3x
+++ b/contrib/ncurses/man/curs_getcchar.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2019,2020 Thomas E. Dickey                                     *
+.\" Copyright 2019-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 2001-2015,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,73 +27,64 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_getcchar.3x,v 1.24 2020/02/02 23:34:34 tom Exp $
-.TH curs_getcchar 3X ""
+.\" $Id: curs_getcchar.3x,v 1.49 2024/04/20 18:55:09 tom Exp $
+.TH curs_getcchar 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
 .SH NAME
-\fBgetcchar\fP,
-\fBsetcchar\fP \- Get a wide character string and rendition from a \fBcchar_t\fP or set a \fBcchar_t\fP from a wide-character string
+\fB\%getcchar\fP,
+\fB\%setcchar\fP \-
+convert between a wide-character string and a \fIcurses\fR complex character
 .SH SYNOPSIS
-\fB#include <curses.h>\fP
-.sp
-\fBint getcchar(\fP
-.br
-.B "        const cchar_t *\fIwcval\fP,"
-.br
-.B "        wchar_t *\fIwch\fP,"
-.br
+.nf
+\fB#include <curses.h>
+.PP
+\fBint getcchar(
+.B "        const cchar_t *\fIwch\fP,"
+.B "        wchar_t *\fIwc\fP,"
 .B "        attr_t *\fIattrs\fP,"
-.br
 .B "        short *\fIcolor_pair\fP,"
-.br
 .B "        void *\fIopts\fP );"
-.sp
+.PP
 .B "int setcchar("
-.br
-.B "        cchar_t *\fIwcval\fP,"
-.br
-.B "        const wchar_t *\fIwch\fP,"
-.br
+.B "        cchar_t *\fIwch\fP,"
+.B "        const wchar_t *\fIwc\fP,"
 .B "        const attr_t \fIattrs\fP,"
-.br
 .B "        short \fIcolor_pair\fP,"
-.br
 .B "        const void *\fIopts\fP );"
+.fi
 .SH DESCRIPTION
 .SS getcchar
-.PP
 The \fBgetcchar\fP function gets a wide-character string
 and rendition from a \fBcchar_t\fP argument.
-When \fIwch\fP is not a null pointer,
+When \fIwc\fP is not a null pointer,
 the \fBgetcchar\fP function does the following:
 .bP
-Extracts information from a \fBcchar_t\fP value \fIwcval\fP
+Extracts information from a \fBcchar_t\fP value \fIwch\fP
 .bP
 Stores the character attributes in the location pointed to by \fIattrs\fP
 .bP
-Stores the color-pair in the location pointed to by \fIcolor_pair\fP
+Stores the color pair in the location pointed to by \fIcolor_pair\fP
 .bP
 Stores the wide-character string,
-characters referenced by \fIwcval\fP, into the array pointed to by \fIwch\fP.
+characters referenced by \fIwch\fP, into the array pointed to by \fIwc\fP.
 .PP
 When
-\fIwch\fP
+\fIwc\fP
 is a null pointer, the
 \fBgetcchar\fP
 function does the following:
 .bP
-Obtains the number of wide characters pointed to by \fIwcval\fP
+Obtains the number of wide characters pointed to by \fIwch\fP
 .bP
 Does not change the data referenced by
 \fIattrs\fP
 or
 \fIcolor_pair\fP
 .SS setcchar
-.PP
-The \fBsetcchar\fP function initializes the location pointed to by \fIwcval\fP
+The \fBsetcchar\fP function initializes the location pointed to by \fIwch\fP
 by using:
 .bP
 The character attributes in
@@ -102,22 +93,37 @@ The character attributes in
 The color pair in
 \fIcolor_pair\fP
 .bP
-The wide-character string pointed to by \fIwch\fP.
-The string must be L'\\0' terminated,
+The wide-character string pointed to by \fIwc\fP.
+The string must be L'\e0' terminated,
 contain at most one spacing character,
 which must be the first.
 .IP
-Up to \fBCCHARW_MAX\fP\-1 nonspacing characters may follow.
-Additional nonspacing characters are ignored.
+Up to \fBCCHARW_MAX\fP\-1 non-spacing characters may follow.
+Additional non-spacing characters are ignored.
 .IP
 The string may contain a single control character instead.
-In that case, no nonspacing characters are allowed.
-.SH EXTENSIONS
+In that case, no non-spacing characters are allowed.
+.SH RETURN VALUE
+When \fIwc\fP is a null pointer,
+\fBgetcchar\fP returns the number of wide characters referenced by
+\fIwch\fP,
+including one for a trailing null.
 .PP
+When \fIwc\fP is not a null pointer,
+\fBgetcchar\fP returns \fBOK\fP upon successful completion,
+and \fBERR\fP otherwise.
+.PP
+Upon successful completion, \fBsetcchar\fP returns \fBOK\fP.
+Otherwise, it returns \fBERR\fP.
+.SH NOTES
+The \fIwch\fP argument may be a value generated by a call to
+\fBsetcchar\fP or by a function that has a \fBcchar_t\fP output argument.
+If \fIwch\fP is constructed by any other means, the effect is unspecified.
+.SH EXTENSIONS
 X/Open Curses documents the \fIopts\fP argument as reserved for future use,
 saying that it must be null.
-This implementation 
-uses that parameter in ABI 6 for the functions which have a color-pair
+This implementation
+uses that parameter in ABI 6 for the functions which have a color pair
 parameter to support extended color pairs:
 .bP
 For  functions  which modify the color, e.g., \fBsetcchar\fP,
@@ -128,26 +134,8 @@ For functions which retrieve the color, e.g., \fBgetcchar\fP,
 if \fIopts\fP is set it is treated as a pointer to \fBint\fP,
 and  used  to  retrieve  the color pair as an \fBint\fP value,
 in addition retrieving it via the standard pointer to \fBshort\fP parameter.
-.SH NOTES
-.PP
-The \fIwcval\fP argument may be a value generated by a call to
-\fBsetcchar\fP or by a function that has a \fBcchar_t\fP output argument.
-If \fIwcval\fP is constructed by any other means, the effect is unspecified.
-.SH RETURN VALUE
-.PP
-When \fIwch\fP is a null pointer,
-\fBgetcchar\fP returns the number of wide characters referenced by
-\fIwcval\fP,
-including one for a trailing null.
-.PP
-When \fIwch\fP is not a null pointer,
-\fBgetcchar\fP returns \fBOK\fP upon successful completion,
-and \fBERR\fP otherwise.
-.PP
-Upon successful completion, \fBsetcchar\fP returns \fBOK\fP.
-Otherwise, it returns \fBERR\fP.
 .SH PORTABILITY
-The \fBCCHARW_MAX\fP symbol is specific to ncurses.
+The \fBCCHARW_MAX\fP symbol is specific to \fI\%ncurses\fP.
 X/Open Curses does not provide details for the layout of the \fBcchar_t\fP
 structure.
 It tells what data are stored in it:
@@ -177,7 +165,7 @@ characters \fIz\fP and a single spacing character \fIc\fP.
 HP-UX\ 10 uses an opaque structure with 28 bytes,
 which is large enough for the 6 \fBwchar_t\fP values.
 .bP
-Solaris xpg4 curses uses a single array of 6 \fBwchar_t\fP values.
+Solaris \fIxpg4\fP curses uses a single array of 6 \fBwchar_t\fP values.
 .PP
 This implementation's \fBcchar_t\fP was defined in 1995
 using \fB5\fP for the total of spacing and non-spacing characters
@@ -194,9 +182,7 @@ including using them for ligatures between characters
 Unicode does not limit the (analogous) number of combining characters,
 so some applications may be affected.
 .SH SEE ALSO
-.PP
-Functions:
-\fBcurs_attr\fR(3X),
-\fBcurs_color\fR(3X),
-\fBcurses\fR(3X),
-\fBwcwidth\fR(3).
+\fB\%curses\fP(3X),
+\fB\%curs_attr\fP(3X),
+\fB\%curs_color\fP(3X),
+\fB\%wcwidth\fP(3)
diff --git a/contrib/ncurses/man/curs_getch.3x b/contrib/ncurses/man/curs_getch.3x
index a8c4bc1f080b..9433c6148583 100644
--- a/contrib/ncurses/man/curs_getch.3x
+++ b/contrib/ncurses/man/curs_getch.3x
@@ -1,6 +1,6 @@
 '\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,391 +28,670 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_getch.3x,v 1.57 2020/12/19 21:38:20 tom Exp $
-.TH curs_getch 3X ""
-.na
-.hy 0
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: curs_getch.3x,v 1.87 2024/04/20 19:18:18 tom Exp $
+.TH curs_getch 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.ds ^  \(ha
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.ds       ^  ^
+.\}
+.
+.ie \n(.g .ds : \:
+.el       .ds : \" empty
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
 .SH NAME
-\fBgetch\fR,
-\fBwgetch\fR,
-\fBmvgetch\fR,
-\fBmvwgetch\fR,
-\fBungetch\fR,
-\fBhas_key\fR \- get (or push back) characters from \fBcurses\fR terminal keyboard
-.ad
-.hy
+\fB\%getch\fP,
+\fB\%wgetch\fP,
+\fB\%mvgetch\fP,
+\fB\%mvwgetch\fP,
+\fB\%ungetch\fP,
+\fB\%has_key\fP \-
+get (or push back) characters from \fIcurses\fR terminal keyboard
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
+.nf
+.B #include <curses.h>
 .PP
-\fBint getch(void);\fR
-.br
-\fBint wgetch(WINDOW *\fP\fIwin);\fR
-.sp
-\fBint mvgetch(int \fP\fIy\fP\fB, int \fP\fIx\fP\fB);\fR
-.br
-\fBint mvwgetch(WINDOW *\fP\fIwin\fP\fB, int \fP\fIy\fP\fB, int \fP\fIx\fP\fB);\fR
-.sp
-\fBint ungetch(int \fP\fIch\fP\fB);\fR
-.sp
-/* extension */
-.br
-\fBint has_key(int \fP\fIch\fP\fB);\fR
-.br
+.B int getch(void);
+.B int wgetch(WINDOW *\fIwin\fP);
+.B int mvgetch(int \fIy\fP, int \fIx\fP);
+.B int mvwgetch(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP);
+.PP
+.B int ungetch(int \fIc\fP);
+.PP
+.\" XXX: Move has_key into its own page like define_key and key_defined?
+\fI/* extension */\fP
+.B int has_key(int \fIc\fP);
+.fi
 .SH DESCRIPTION
-.SS Reading characters
-The \fBgetch\fR, \fBwgetch\fR, \fBmvgetch\fR and \fBmvwgetch\fR, routines read
-a character from the window.
-In no-delay mode, if no input is waiting, the value \fBERR\fR is returned.
-In delay mode, the program waits until the system
-passes text through to the program.
-Depending on the setting of \fBcbreak\fR,
-this is after one character (cbreak mode),
-or after the first newline (nocbreak mode).
-In half-delay mode,
-the program waits until a character is typed or the
-specified timeout has been reached.
-.PP
-If \fBecho\fR is enabled, and the window is not a pad,
-then the character will also be echoed into the
-designated window according to the following rules:
-.bP
-If the character is the current erase character, left arrow, or backspace,
-the cursor is moved one space to the left and that screen position is erased
-as if \fBdelch\fR had been called.
+.SS "Reading Characters"
+.B \%wgetch
+gathers a key stroke from the terminal keyboard associated with a
+.I curses
+window
+.IR win .
+\fB\%ncurses\fP(3X) describes the variants of this function.
+.PP
+When input is pending,
+.B \%wgetch
+returns an integer identifying the key stroke;
+for alphanumeric and punctuation keys,
+this value corresponds to the character encoding used by the terminal.
+Use of the control key as a modifier often results in a distinct code.
+The behavior of other keys depends on whether
+.I win
+is in keypad mode;
+see subsection \*(``Keypad Mode\*('' below.
+.PP
+If no input is pending,
+then if the no-delay flag is set in the window
+(see \fB\%nodelay\fP(3X)),
+the function returns
+.BR ERR ;
+otherwise,
+.I curses
+waits until the terminal has input.
+If \fB\%cbreak\fP(3X)
+has been called,
+this happens after one character is read.
+If \fB\%nocbreak\fP(3X)
+has been called,
+it occurs when the next newline is read.
+If \fB\%halfdelay\fP(3X)
+has been called,
+.I curses
+waits until a character is typed or the specified delay elapses.
+.PP
+If \fB\%echo\fP(3X) has been called,
+and the window is not a pad,
+.I curses
+writes the returned character
+.I c
+to the window
+(at the cursor position)
+per the following rules.
 .bP
-If the character value is any other \fBKEY_\fR define, the user is alerted
-with a \fBbeep\fR call.
+If
+.I c
+matches the terminal's erase character,
+the cursor moves leftward one position
+and the new position is erased
+as if \fB\%wmove\fP(3X) and then \fB\%wdelch\fP(3X) were called.
+When the window's keypad mode is enabled
+(see below),
+.B \%KEY_LEFT
+and
+.B \%KEY_BACKSPACE
+are handled the same way.
 .bP
-If the character is a carriage-return,
-and if \fBnl\fP is enabled,
-it is translated to a line-feed after echoing.
+.I curses
+writes any other
+.I c
+to the window,
+as with \fB\%wechochar\fP(3X).
 .bP
-Otherwise the character is simply output to the screen.
+If the window has been moved or modified since the last call to
+\fB\%wrefresh\fP(3X),
+.I curses
+calls
+.BR \%wrefresh .
 .PP
-If the window is not a pad, and it has been moved or modified since the last
-call to \fBwrefresh\fR, \fBwrefresh\fR will be called before another character
-is read.
-.SS Keypad mode
-.PP
-If \fBkeypad\fR is \fBTRUE\fR, and a function key is pressed, the token for
-that function key is returned instead of the raw characters:
+If
+.I c
+is a carriage return and \fBnl\fP(3X) has been called,
+.B \%wgetch
+returns the character code for line feed instead.
+.SS "Keypad Mode"
+To
+.IR curses ,
+key strokes not from the alphabetic section of the keyboard
+(those corresponding to the ECMA-6 character set\(emsee
+\fIascii\fP(7)\(emoptionally modified by either the control or shift
+keys)
+are treated as
+.I function
+keys.
+(In
+.IR curses ,
+the term \*(``function key\*('' includes but is not limited to keycaps
+engraved with \*(``F1\*('',
+\*(``PF1\*('',
+and so on.)
+If the window is in keypad mode,
+these produce a numeric code corresponding to the
+.B KEY_
+symbols listed in subsection \*(``Predefined Key Codes\*('' below;
+otherwise,
+they transmit a sequence of codes typically starting with the escape
+character,
+and which must be collected with multiple
+.B \%wgetch
+calls.
 .bP
-The predefined function
-keys are listed in \fB<curses.h>\fR as macros with values outside the range
-of 8-bit characters.
-Their names begin with \fBKEY_\fR.
+The
+.I \%curses.h
+header file declares many
+.I "predefined function keys"
+whose names begin with
+.BR KEY_ ;
+these object-like macros have values outside the range of eight-bit
+character codes.
 .bP
-Other (user-defined) function keys which may be defined
-using \fBdefine_key\fP(3X)
-have no names, but also are expected to have values outside the range of
-8-bit characters.
-.PP
-Thus, a variable
-intended to hold the return value of a function key must be of short size or
-larger.
-.PP
-When a character that could be the beginning of a function key is received
-(which, on modern terminals, means an escape character),
-\fBcurses\fR sets a timer.
-If the remainder of the sequence does not come in within the designated
-time, the character is passed through;
-otherwise, the function key value is returned.
-For this reason, many terminals experience a delay between the time
-a user presses the escape key and the escape is returned to the program.
-.PP
-In \fBncurses\fP, the timer normally expires after
-the value in \fBESCDELAY\fP (see \fBcurs_variables\fP(3X)).
-If \fBnotimeout\fP is \fBTRUE\fP, the timer does not expire;
-it is an infinite (or very large) value.
-Because function keys usually begin with an escape character,
-the terminal may appear to hang in notimeout mode after pressing the escape key
-until another key is pressed.
-.SS Ungetting characters
-.PP
-The \fBungetch\fR routine places \fIch\fR back onto the input queue to be
-returned by the next call to \fBwgetch\fR.
-There is just one input queue for all windows.
-.PP
-.SS Predefined key-codes
-The following special keys are defined in \fB<curses.h>\fR.
+In
+.IR \%ncurses ,
+.I "user-defined function keys"
+are configured with \fB\%define_key\fP(3X);
+they have no names,
+but are also expected to have values outside the range of eight-bit
+codes.
+.PP
+A variable intended to hold a function key code must thus be of type
+.I short
+or larger.
+.PP
+Most terminals one encounters follow the ECMA-48 standard insofar as
+their function keys produce character sequences prefixed with the
+escape character ESC.
+This fact implies that
+.I curses
+cannot know whether the terminal has sent an ESC key stroke or the
+beginning of a function key's character sequence without waiting to see
+if,
+and how soon,
+further input arrives.
+When
+.I curses
+reads such an ambiguous character,
+it sets a timer.
+If the remainder of the sequence does not arrive within the designated
+time,
+.B \%wgetch
+returns the prefix character;
+otherwise,
+it returns the function key code corresponding to the unique sequence
+defined by the terminal.
+Consequently,
+a user of a
+.I curses
+application may experience a delay after pressing ESC while
+.I curses
+disambiguates the input;
+see section \*(``EXTENSIONS\*('' below.
+If the window is in \*(``no time-out\*('' mode,
+the timer does not expire;
+it is an infinite
+(or very large)
+value.
+See \fB\%notimeout\fP(3X).
+Because function key sequences usually begin with an escape character,
+the terminal may appear to hang in no time-out mode after the user has
+pressed ESC.
+Generally,
+further typing \*(``awakens\*(''
+.IR curses .
+.SS "Ungetting Characters"
+.B \%ungetch
+places
+.I c
+into the input queue to be returned by the next call to
+.BR \%wgetch .
+A single input queue serves all windows.
+.SS "Predefined Key Codes"
+The header file
+.I \%curses.h
+defines the following function key codes.
 .bP
-Except for the special case \fBKEY_RESIZE\fP,
-it is necessary to enable \fBkeypad\fR for \fBgetch\fP to return these codes.
+Except for the special case of
+.BR \%KEY_RESIZE ,
+a window's keypad mode must be enabled for
+.B \%wgetch
+to read these codes from it.
 .bP
 Not all of these are necessarily supported on any particular terminal.
 .bP
-The naming convention may seem obscure, with some apparent
-misspellings (such as \*(``RSUME\*('' for \*(``resume\*('').
-The names correspond to the long terminfo capability names for the keys,
-and were defined long ago, in the 1980s.
+The naming convention may seem obscure,
+with some apparent misspellings
+(such as \*(``RSUME\*('' for \*(``resume\*('');
+the names correspond to the
+.I \%term\%info
+capability names for the keys,
+and were standardized before the IBM PC/AT keyboard layout achieved a
+dominant position in industry.
 .PP
+.RS
+.\" XXX: Move this list into ncurses(3X), rather than duplicating it in
+.\" get_wch(3X) or having that page cross reference this one?
 .TS
-center tab(/) ;
-l l .
-\fIName\fR/\fIKey\fR \fIname\fR
-_
-KEY_BREAK/Break key
-KEY_DOWN/The four arrow keys ...
-KEY_UP
-KEY_LEFT
-KEY_RIGHT
-KEY_HOME/Home key (upward+left arrow)
-KEY_BACKSPACE/Backspace
-KEY_F0/T{
-Function keys; space for 64 keys is reserved.
+Lb Lb
+Lb Lx.
+Symbol	Key name
+=
+KEY_BREAK	Break key
+KEY_DOWN	Arrow keys
+KEY_UP	\^
+KEY_LEFT	\^
+KEY_RIGHT	\^
+KEY_HOME	Home key (upward+left arrow)
+KEY_BACKSPACE	Backspace
+KEY_F0	T{
+Function keys; space for 64 keys is reserved
 T}
-KEY_F(\fIn\fR)/T{
-For 0 \(<= \fIn\fR \(<= 63
+KEY_F(\fIn\fP)	T{
+Function key \fIn\fP where 0 \(<= \fIn\fP \(<= 63
 T}
-KEY_DL/Delete line
-KEY_IL/Insert line
-KEY_DC/Delete character
-KEY_IC/Insert char or enter insert mode
-KEY_EIC/Exit insert char mode
-KEY_CLEAR/Clear screen
-KEY_EOS/Clear to end of screen
-KEY_EOL/Clear to end of line
-KEY_SF/Scroll 1 line forward
-KEY_SR/Scroll 1 line backward (reverse)
-KEY_NPAGE/Next page
-KEY_PPAGE/Previous page
-KEY_STAB/Set tab
-KEY_CTAB/Clear tab
-KEY_CATAB/Clear all tabs
-KEY_ENTER/Enter or send
-KEY_SRESET/Soft (partial) reset
-KEY_RESET/Reset or hard reset
-KEY_PRINT/Print or copy
-KEY_LL/Home down or bottom (lower left)
-KEY_A1/Upper left of keypad
-KEY_A3/Upper right of keypad
-KEY_B2/Center of keypad
-KEY_C1/Lower left of keypad
-KEY_C3/Lower right of keypad
-KEY_BTAB/Back tab key
-KEY_BEG/Beg(inning) key
-KEY_CANCEL/Cancel key
-KEY_CLOSE/Close key
-KEY_COMMAND/Cmd (command) key
-KEY_COPY/Copy key
-KEY_CREATE/Create key
-KEY_END/End key
-KEY_EXIT/Exit key
-KEY_FIND/Find key
-KEY_HELP/Help key
-KEY_MARK/Mark key
-KEY_MESSAGE/Message key
-KEY_MOUSE/Mouse event read
-KEY_MOVE/Move key
-KEY_NEXT/Next object key
-KEY_OPEN/Open key
-KEY_OPTIONS/Options key
-KEY_PREVIOUS/Previous object key
-KEY_REDO/Redo key
-KEY_REFERENCE/Ref(erence) key
-KEY_REFRESH/Refresh key
-KEY_REPLACE/Replace key
-KEY_RESIZE/Screen resized
-KEY_RESTART/Restart key
-KEY_RESUME/Resume key
-KEY_SAVE/Save key
-KEY_SBEG/Shifted beginning key
-KEY_SCANCEL/Shifted cancel key
-KEY_SCOMMAND/Shifted command key
-KEY_SCOPY/Shifted copy key
-KEY_SCREATE/Shifted create key
-KEY_SDC/Shifted delete char key
-KEY_SDL/Shifted delete line key
-KEY_SELECT/Select key
-KEY_SEND/Shifted end key
-KEY_SEOL/Shifted clear line key
-KEY_SEXIT/Shifted exit key
-KEY_SFIND/Shifted find key
-KEY_SHELP/Shifted help key
-KEY_SHOME/Shifted home key
-KEY_SIC/Shifted input key
-KEY_SLEFT/Shifted left arrow key
-KEY_SMESSAGE/Shifted message key
-KEY_SMOVE/Shifted move key
-KEY_SNEXT/Shifted next key
-KEY_SOPTIONS/Shifted options key
-KEY_SPREVIOUS/Shifted prev key
-KEY_SPRINT/Shifted print key
-KEY_SREDO/Shifted redo key
-KEY_SREPLACE/Shifted replace key
-KEY_SRIGHT/Shifted right arrow
-KEY_SRSUME/Shifted resume key
-KEY_SSAVE/Shifted save key
-KEY_SSUSPEND/Shifted suspend key
-KEY_SUNDO/Shifted undo key
-KEY_SUSPEND/Suspend key
-KEY_UNDO/Undo key
+KEY_DL	Delete line
+KEY_IL	Insert line
+KEY_DC	Delete character
+KEY_IC	Insert character/Enter insert mode
+KEY_EIC	Exit insert character mode
+KEY_CLEAR	Clear screen
+KEY_EOS	Clear to end of screen
+KEY_EOL	Clear to end of line
+KEY_SF	Scroll one line forward
+KEY_SR	Scroll one line backward (reverse)
+KEY_NPAGE	Next page/Page up
+KEY_PPAGE	Previous page/Page down
+KEY_STAB	Set tab
+KEY_CTAB	Clear tab
+KEY_CATAB	Clear all tabs
+KEY_ENTER	Enter/Send
+KEY_SRESET	Soft (partial) reset
+KEY_RESET	(Hard) reset
+KEY_PRINT	Print/Copy
+KEY_LL	Home down/Bottom (lower left)
+KEY_A1	Upper left of keypad
+KEY_A3	Upper right of keypad
+KEY_B2	Center of keypad
+KEY_C1	Lower left of keypad
+KEY_C3	Lower right of keypad
+KEY_BTAB	Back tab key
+KEY_BEG	Beg(inning) key
+KEY_CANCEL	Cancel key
+KEY_CLOSE	Close key
+KEY_COMMAND	Cmd (command) key
+KEY_COPY	Copy key
+KEY_CREATE	Create key
+KEY_END	End key
+KEY_EXIT	Exit key
+KEY_FIND	Find key
+KEY_HELP	Help key
+KEY_MARK	Mark key
+KEY_MESSAGE	Message key
+KEY_MOUSE	Mouse event occurred
+KEY_MOVE	Move key
+KEY_NEXT	Next object key
+KEY_OPEN	Open key
+KEY_OPTIONS	Options key
+KEY_PREVIOUS	Previous object key
+KEY_REDO	Redo key
+KEY_REFERENCE	Ref(erence) key
+KEY_REFRESH	Refresh key
+KEY_REPLACE	Replace key
+KEY_RESIZE	Screen resized
+KEY_RESTART	Restart key
+KEY_RESUME	Resume key
+KEY_SAVE	Save key
+KEY_SELECT	Select key
+KEY_SUSPEND	Suspend key
+KEY_UNDO	Undo key
+_
+KEY_SBEG	Shifted beginning key
+KEY_SCANCEL	Shifted cancel key
+KEY_SCOMMAND	Shifted command key
+KEY_SCOPY	Shifted copy key
+KEY_SCREATE	Shifted create key
+KEY_SDC	Shifted delete character key
+KEY_SDL	Shifted delete line key
+KEY_SEND	Shifted end key
+KEY_SEOL	Shifted clear line key
+KEY_SEXIT	Shifted exit key
+KEY_SFIND	Shifted find key
+KEY_SHELP	Shifted help key
+KEY_SHOME	Shifted home key
+KEY_SIC	Shifted insert key
+KEY_SLEFT	Shifted left arrow key
+KEY_SMESSAGE	Shifted message key
+KEY_SMOVE	Shifted move key
+KEY_SNEXT	Shifted next object key
+KEY_SOPTIONS	Shifted options key
+KEY_SPREVIOUS	Shifted previous object key
+KEY_SPRINT	Shifted print key
+KEY_SREDO	Shifted redo key
+KEY_SREPLACE	Shifted replace key
+KEY_SRIGHT	Shifted right arrow key
+KEY_SRSUME	Shifted resume key
+KEY_SSAVE	Shifted save key
+KEY_SSUSPEND	Shifted suspend key
+KEY_SUNDO	Shifted undo key
 .TE
+.RE
+.PP
+Many keyboards feature a nine-key directional pad.
 .PP
-Keypad is arranged like this:
-.br
+.RS
 .TS
-center allbox tab(/) ;
-c c c .
-\fBA1\fR/\fBup\fR/\fBA3\fR
-\fBleft\fR/\fBB2\fR/\fBright\fR
-\fBC1\fR/\fBdown\fR/\fBC3\fR
+allbox center;
+C C C.
+A1	up	A3
+left	B2	right
+C1	down	C3
 .TE
+.RE
 .sp
-A few of these predefined values do \fInot\fP correspond to a real key:
+Two of the symbols in the list above do
+.I not
+correspond to a physical key.
 .bP
-.B KEY_RESIZE
-is returned when the \fBSIGWINCH\fP signal has been detected
-(see \fBinitscr\fP(3X) and \fBresizeterm\fR(3X)).
-This code is returned whether or not \fBkeypad\fP has been enabled.
+.B \%wgetch
+returns
+.BR \%KEY_RESIZE ,
+even if the window's keypad mode is disabled,
+when
+.I \%ncurses
+handles a
+.B \%SIGWINCH
+signal;
+see \fB\%initscr\fP(3X) and \fB\%resizeterm\fP(3X).
 .bP
-.B KEY_MOUSE
-is returned for mouse-events (see \fBcurs_mouse\fR(3X)).
-This code relies upon whether or not \fBkeypad\fP(3X) has been enabled,
-because (e.g., with \fIxterm\fP mouse prototocol) ncurses must
-read escape sequences,
-just like a function key.
-.SS Testing key-codes
-.PP
-The \fBhas_key\fR routine takes a key-code value from the above list, and
-returns \fBTRUE\fP or \fBFALSE\fP according to whether
-the current terminal type recognizes a key with that value.
-.PP
-The library also supports these extensions:
-.RS 3
-.TP 5
-.B define_key
-defines a key-code for a given string (see \fBdefine_key\fP(3X)).
-.TP 5
-.B key_defined
-checks if there is a key-code defined for a given
-string (see \fBkey_defined\fP(3X)).
-.RE
-.PP
+.B \%wgetch
+returns
+.B \%KEY_MOUSE
+to indicate that a mouse event is pending collection;
+see \fB\%curs_mouse\fP(3X).
+Receipt of this code requires a window's keypad mode to be enabled,
+because to interpret mouse input
+(as with with \fI\%xterm\fP(1)'s mouse prototocol),
+.I \%ncurses
+must read an escape sequence,
+as with a function key.
+.SS "Testing Key Codes"
+In
+.IR \%ncurses ,
+.B \%has_key
+returns a Boolean value indicating whether the terminal type recognizes
+its parameter as a key code value.
+See also
+\fB\%define_key\fP(3X) and \fB\%key_defined\fP(3X).
 .SH RETURN VALUE
-All routines return the integer \fBERR\fR upon failure and an integer value
-other than \fBERR\fR (\fBOK\fR in the case of \fBungetch\fP) upon successful
-completion.
-.RS 3
-.TP 5
-\fBungetch\fP
-returns \fBERR\fP
-if there is no more room in the FIFO.
-.TP
-\fBwgetch\fP
-returns \fBERR\fP
-if the window pointer is null, or
-if its timeout expires without having any data, or
-if the execution was interrupted by a signal (\fBerrno\fR will be set to
-\fBEINTR\fR).
-.RE
+Except for
+.BR \%has_key ,
+these functions return
+.B OK
+on success and
+.B ERR
+on failure.
+.PP
+Functions taking a
+.I \%WINDOW
+pointer argument fail if the pointer is
+.BR NULL .
 .PP
-Functions with a \*(``mv\*('' prefix first perform a cursor movement using
-\fBwmove\fP, and return an error if the position is outside the window,
-or if the window pointer is null.
+Functions prefixed with \*(``mv\*('' first perform cursor movement and
+fail if the position
+.RI ( y ,
+.IR x )
+is outside the window boundaries.
+.PP
+.B \%wgetch
+also fails if
+.bP
+its timeout expires without any data arriving,
+or
+.bP
+execution was interrupted by a signal,
+in which case
+.B \%errno
+is set to
+.BR \%EINTR .
+.PP
+.B \%ungetch
+fails if there is no more room in the input queue.
+.PP
+.B \%has_key
+returns
+.B TRUE
+or
+.BR FALSE .
 .SH NOTES
-Use of the escape key by a programmer for a single character function is
-discouraged, as it will cause a delay of up to one second while the
-keypad code looks for a following function-key sequence.
-.PP
-Some keys may be the same as commonly used control
-keys, e.g.,
-\fBKEY_ENTER\fP versus control/M,
-\fBKEY_BACKSPACE\fP versus control/H.
-Some curses implementations may differ according to whether they
-treat these control keys specially (and ignore the terminfo), or
-use the terminfo definitions.
-\fBNcurses\fR uses the terminfo definition.
-If it says that \fBKEY_ENTER\fP is control/M,
-\fBgetch\fR will return \fBKEY_ENTER\fP
-when you press control/M.
-.PP
-Generally, \fBKEY_ENTER\fP denotes the character(s) sent by the \fIEnter\fP
-key on the numeric keypad:
+.I curses
+discourages assignment of the ESC key to a discrete function by the
+programmer because the library requires a delay while it awaits the
+potential remainder of a terminal escape sequence.
+.PP
+Some key strokes are indistinguishable from control characters;
+for example,
+.B \%KEY_ENTER
+may be the same as
+.BR \*^M ,
+.\" as with att630 or pccon+keys
+and
+.B \%KEY_BACKSPACE
+may be the same as
+.B \*^H
+.\" as with att505 or vt52-basic
+or
+.BR \*^? .
+.\" as with pccon+keys or vt320
+Consult the terminal's
+.I \%term\%info
+entry to determine whether this is the case;
+see \fB\%infocmp\fP(1).
+Some
+.I curses
+implementations,
+including
+.IR \%ncurses ,
+honor the
+.I \%term\%info
+key definitions;
+others treat such control characters specially.
+.PP
+.I curses
+distinguishes the Enter keys in the alphabetic and numeric keypad
+sections of a keyboard because (most) terminals do.
+.B \%KEY_ENTER
+refers to the key on the numeric keypad and,
+like other function keys,
+and is reliably recognized only if the window's keypad mode is enabled.
 .bP
-the terminal description lists the most useful keys,
+The
+.I \%term\%info
+.B \%key_enter
+.RB ( kent )
+capability describes the character (sequence) sent by the Enter key of
+a terminal's numeric
+(or similar)
+keypad.
 .bP
-the \fIEnter\fP key on the regular keyboard is already handled by
-the standard ASCII characters for carriage-return and line-feed,
+\*(``Enter or send\*('' is X/Open Curses's description of this key.
+.PP
+.I curses
+treats the Enter or Return key in the
+.I alphabetic
+section of the keyboard differently.
 .bP
-depending on whether \fBnl\fP or \fBnonl\fP was called,
-pressing \*(``Enter\*('' on the regular keyboard
-may return either a carriage-return or line-feed, and finally
+It usually produces a control code for carriage return
+.RB ( \*^M )
+or line feed
+.RB ( \*^J ).
 .bP
-\*(``Enter or send\*('' is the standard description for this key.
-.PP
-When using \fBgetch\fR, \fBwgetch\fR, \fBmvgetch\fR, or
-\fBmvwgetch\fR, nocbreak mode (\fBnocbreak\fR) and echo mode
-(\fBecho\fR) should not be used at the same time.
-Depending on the
-state of the tty driver when each character is typed, the program may
-produce undesirable results.
-.PP
-Note that \fBgetch\fR, \fBmvgetch\fR, and \fBmvwgetch\fR may be macros.
-.PP
-Historically, the set of keypad macros was largely defined by the extremely
-function-key-rich keyboard of the AT&T 7300, aka 3B1, aka Safari 4.
-Modern
-personal computers usually have only a small subset of these.
-IBM PC-style
-consoles typically support little more than \fBKEY_UP\fR, \fBKEY_DOWN\fR,
-\fBKEY_LEFT\fR, \fBKEY_RIGHT\fR, \fBKEY_HOME\fR, \fBKEY_END\fR,
-\fBKEY_NPAGE\fR, \fBKEY_PPAGE\fR, and function keys 1 through 12.
-The Ins key
-is usually mapped to \fBKEY_IC\fR.
+Depending on the terminal mode
+(raw,
+cbreak,
+or
+\*(``cooked\*(''),
+and whether \fB\%nl\fP(3X) or \fB\%nonl\fP(3X) has been called,
+.B \%wgetch
+may return either a carriage return or line feed upon an Enter or Return
+key stroke.
+.PP
+Use of
+.B \%wgetch
+with \fB\%echo\fP(3X) and neither \fB\%cbreak\fP(3X) nor \fB\%raw\fP(3X)
+is not well-defined.
+.PP
+Historically,
+the list of key code macros above was influenced by the
+function-key-rich keyboard of the AT&T 7300
+(also known variously as the \*(``3B1\*('', \*(``Safari 4\*('', and
+\*(``UNIX PC\*(''),
+a 1985 machine.
+Today's computer keyboards are based that of the IBM PC/AT and tend to
+have fewer.
+A
+.I curses
+application can expect such a keyboard to transmit key codes
+.BR \%KEY_UP ,
+.BR \%KEY_DOWN ,
+.BR \%KEY_LEFT ,
+.BR \%KEY_RIGHT ,
+.BR \%KEY_HOME ,
+.BR \%KEY_END ,
+.B \%KEY_PPAGE
+(Page Up),
+.B \%KEY_NPAGE
+(Page Down),
+.B \%KEY_IC
+(Insert),
+.B \%KEY_DC
+(Delete),
+and
+.BI \%KEY_F( n )
+for 1 \(<=
+.I n
+\(<= 12.
+.PP
+.BR \%getch ,
+.BR \%mvgetch ,
+and
+.B \%mvwgetch
+may be implemented as macros.
+.SH EXTENSIONS
+In
+.IR \%ncurses ,
+when a window's \*(``no time-out\*('' mode is
+.I not
+set,
+the
+.B \%ESCDELAY
+variable configures the duration of the timer used to disambiguate a
+function key character sequence from a series of key strokes beginning
+with ESC typed by the user;
+see
+\fB\%curs_variables\fP(3X).
+.PP
+\fB\%has_key\fP was designed for \fB\%ncurses\fP(3X),
+and is not found in SVr4
+.IR curses ,
+4.4BSD
+.IR curses ,
+or any other previous curses implementation.
 .SH PORTABILITY
-The *get* functions are described in the XSI Curses standard, Issue 4.
-They
-read single-byte characters only.
-The standard specifies that they return
-\fBERR\fR on failure, but specifies no error conditions.
-.PP
-The echo behavior of these functions on input of \fBKEY_\fR or backspace
-characters was not specified in the SVr4 documentation.
-This description is
-adopted from the XSI Curses standard.
-.PP
-The behavior of \fBgetch\fR and friends in the presence of handled signals is
-unspecified in the SVr4 and XSI Curses documentation.
-Under historical curses
-implementations, it varied depending on whether the operating system's
-implementation of handled signal receipt interrupts a \fBread\fR(2) call in
-progress or not, and also (in some implementations) depending on whether an
-input timeout or non-blocking mode has been set.
-.PP
-\fBKEY_MOUSE\fP is mentioned in XSI Curses, along with a few related
-terminfo capabilities, but no higher-level functions use the feature.
-The implementation in ncurses is an extension.
-.PP
-\fBKEY_RESIZE\fP is an extension first implemented for ncurses.
-NetBSD curses later added this extension.
-.PP
-Programmers concerned about portability should be prepared for either of two
-cases: (a) signal receipt does not interrupt \fBgetch\fR; (b) signal receipt
-interrupts \fBgetch\fR and causes it to return \fBERR\fP with \fBerrno\fR set to
-\fBEINTR\fR.
-.PP
-The \fBhas_key\fR function is unique to \fBncurses\fR.
-We recommend that
-any code using it be conditionalized on the \fBNCURSES_VERSION\fR feature macro.
+Applications employing
+.I \%ncurses
+extensions should condition their use on the visibility of the
+.B \%NCURSES_VERSION
+preprocessor macro.
+.PP
+X/Open Curses,
+Issue 4 describes
+\fB\%getch\fP,
+\fB\%wgetch\fP,
+\fB\%mvgetch\fP,
+\fB\%mvwgetch\fP,
+and
+\fB\%ungetch\fP.
+It specifies no error conditions for them.
+.PP
+.B \%wgetch
+reads only single-byte characters.
+.PP
+The echo behavior of these functions on input of
+.B KEY_
+or backspace characters was not specified in the SVr4 documentation.
+This description is adapted from X/Open Curses.
+.PP
+The behavior of
+.B \%wgetch
+in the presence of signal handlers is unspecified in the SVr4
+documentation and X/Open Curses.
+In historical
+.I curses
+implementations,
+it varied depending on whether the operating system's dispatch of a
+signal to a handler interrupting a \fIread\fP(2) call in progress,
+and also
+(in some implementations)
+whether an input timeout or non-blocking mode has been set.
+Programmers concerned about portability should be prepared for either of
+two cases:
+(a) signal receipt does not interrupt
+.BR \%wgetch ;
+or
+(b) signal receipt interrupts
+.B \%wgetch
+and causes it to return
+.B ERR
+with
+.B \%errno
+set to
+.BR \%EINTR .
+.PP
+.B \%KEY_MOUSE
+is mentioned in X/Open Curses,
+along with a few related
+.I \%term\%info
+capabilities,
+but no higher-level functions use the feature.
+The implementation in
+.I \%ncurses
+is an extension.
+.PP
+.B \%KEY_RESIZE
+and
+.B \%has_key
+are extensions first implemented for
+.IR \%ncurses .
+By 2022,
+.I \%PDCurses
+.\" https://web.archive.org/web/20220117232009/https://pdcurses.org/docs/MANUAL.html
+and
+NetBSD
+.I curses
+.\" https://web.archive.org/web/20200923185647/https://man.netbsd.org/curses_input.3
+had added them along with
+.BR \%KEY_MOUSE .
 .SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_inopts\fR(3X),
-\fBcurs_mouse\fR(3X),
-\fBcurs_move\fR(3X),
-\fBcurs_outopts\fR(3X),
-\fBcurs_refresh\fR(3X),
-\fBcurs_variables\fR(3X),
-\fBresizeterm\fR(3X).
-.PP
-Comparable functions in the wide-character (ncursesw) library are
-described in
-\fBcurs_get_wch\fR(3X).
+\fB\%curs_get_wch\fP(3X) describes comparable functions of the
+.I \%ncurses
+library in its wide-character configuration
+.RI ( \%ncursesw ).
+.PP
+\fB\%curses\fP(3X),
+\fB\%curs_addch\fP(3X),
+\fB\%curs_inopts\fP(3X),
+\fB\%curs_mouse\fP(3X),
+\fB\%curs_move\fP(3X),
+\fB\%curs_outopts\fP(3X),
+\fB\%curs_refresh\fP(3X),
+\fB\%curs_variables\fP(3X),
+\fB\%resizeterm\fP(3X),
+\fB\%ascii\fP(7)
+.PP
+ECMA-6 \*(``7-bit coded Character Set\*(''
+\%<https://\*:ecma\-international\*:.org/\
+\*:publications\-and\-standards/\*:standards/\*:ecma\-6/>
+.PP
+ECMA-48 \*(``Control Functions for Coded Character Sets\*(''
+\%<https://\*:ecma\-international\*:.org/\
+\*:publications\-and\-standards/\*:standards/\*:ecma\-48/>
diff --git a/contrib/ncurses/man/curs_getstr.3x b/contrib/ncurses/man/curs_getstr.3x
index baf56967263e..4a49352a146c 100644
--- a/contrib/ncurses/man/curs_getstr.3x
+++ b/contrib/ncurses/man/curs_getstr.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,118 +27,174 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_getstr.3x,v 1.31 2020/10/18 00:27:44 tom Exp $
-.TH curs_getstr 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: curs_getstr.3x,v 1.58 2024/04/20 19:18:18 tom Exp $
+.TH curs_getstr 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.na
-.hy 0
 .SH NAME
-\fBgetstr\fR,
-\fBgetnstr\fR,
-\fBwgetstr\fR,
-\fBwgetnstr\fR,
-\fBmvgetstr\fR,
-\fBmvgetnstr\fR,
-\fBmvwgetstr\fR,
-\fBmvwgetnstr\fR \- accept character strings from \fBcurses\fR terminal keyboard
-.ad
-.hy
+\fB\%getstr\fP,
+\fB\%getnstr\fP,
+\fB\%wgetstr\fP,
+\fB\%wgetnstr\fP,
+\fB\%mvgetstr\fP,
+\fB\%mvgetnstr\fP,
+\fB\%mvwgetstr\fP,
+\fB\%mvwgetnstr\fP \-
+accept character strings from \fIcurses\fR terminal keyboard
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBint getstr(char *\fP\fIstr\fP\fB);\fR
-.br
-\fBint getnstr(char *\fP\fIstr\fP\fB, int \fP\fIn\fP\fB);\fR
-.br
-\fBint wgetstr(WINDOW *\fP\fIwin\fP\fB, char *\fP\fIstr\fP\fB);\fR
-.br
-\fBint wgetnstr(WINDOW *\fP\fIwin\fP\fB, char *\fP\fIstr\fP\fB, int \fP\fIn\fP\fB);\fR
-.sp
-\fBint mvgetstr(int \fP\fIy\fP\fB, int \fP\fIx\fP\fB, char *\fP\fIstr\fP\fB);\fR
-.br
-\fBint mvwgetstr(WINDOW *\fP\fIwin\fP\fB, int \fP\fIy\fP\fB, int \fP\fIx\fP\fB, char *\fP\fIstr\fP\fB);\fR
-.br
-\fBint mvgetnstr(int \fP\fIy\fP\fB, int \fP\fIx\fP\fB, char *\fP\fIstr\fP\fB, int \fP\fIn\fP\fB);\fR
-.br
-\fBint mvwgetnstr(WINDOW *\fP\fIwin\fP\fB, int \fP\fIy\fP\fB, int \fP\fIx\fP\fB, char *\fP\fIstr\fP\fB, int \fP\fIn\fP\fB);\fR
-.br
+.nf
+\fB#include <curses.h>
+.PP
+\fBint getstr(char *\fIstr\fP);
+\fBint getnstr(char *\fIstr\fP, int \fIn\fP);
+\fBint wgetstr(WINDOW *\fIwin\fP, char *\fIstr\fP);
+\fBint wgetnstr(WINDOW *\fIwin\fP, char *\fIstr\fP, int \fIn\fP);
+.PP
+\fBint mvgetstr(int \fIy\fP, int \fIx\fP, char *\fIstr\fP);
+\fBint mvwgetstr(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, char *\fIstr\fP);
+\fBint mvgetnstr(int \fIy\fP, int \fIx\fP, char *\fIstr\fP, int \fIn\fP);
+\fBint mvwgetnstr(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, char *\fIstr\fP, int \fIn\fP);
+.fi
 .SH DESCRIPTION
-The function \fBgetstr\fR is equivalent to a series of calls to \fBgetch\fR,
-until a newline or carriage return is received (the terminating character is
-not included in the returned string).
-.\" X/Open says also until EOf
-.\" X/Open says then an EOS is added to the result
-.\" X/Open doesn't mention n<0
-The resulting value is placed in the
-area pointed to by the character pointer \fIstr\fR,
-followed by a NUL.
-.PP
-\fBwgetnstr\fR reads at most \fIn\fR characters, thus preventing a possible
-overflow of the input buffer.
-Any attempt to enter more characters (other
-than the terminating newline or carriage return) causes a beep.
-Function
-keys also cause a beep and are ignored.
-The \fBgetnstr\fR function reads
-from the \fIstdscr\fR default window.
-.PP
-The user's erase and kill characters are interpreted.
-If keypad
-mode is on for the window, \fBKEY_LEFT\fR and \fBKEY_BACKSPACE\fR
-are both considered equivalent to the user's kill character.
-.PP
-Characters input are echoed only if \fBecho\fR is currently on.
+The function
+\fBwgetnstr\fP
+is equivalent to a series of calls to
+\fBwgetch\fP(3X),
+until a newline or carriage return terminates the series:
+.bP
+The terminating character is not included in the returned string.
+.bP
+In all instances, the end of the string is terminated
+by a NUL.
+.bP
+The function stores the result in the area pointed to
+by the \fIstr\fP parameter.
+.bP
+The function reads at most \fIn\fP characters,
+thus preventing a possible overflow of the input buffer.
+.IP
+Any attempt to enter more characters
+(other than the terminating newline or carriage return)
+causes a beep.
+.IP
+Function keys also cause a beep and are ignored.
+.PP
+The user's \fIerase\fP and \fIkill\fP characters are interpreted:
+.bP
+The \fIerase\fP character (e.g., \fB^H\fP) erases the character
+at the end of the buffer, moving the cursor to the left.
+.IP
+If \fIkeypad\fP mode is on for the window,
+\fBKEY_LEFT\fP and \fBKEY_BACKSPACE\fP
+are both considered equivalent to the user's \fIerase\fP character.
+.bP
+The \fIkill\fP character (e.g., \fB^U\fP) erases the entire buffer,
+leaving the cursor at the beginning of the buffer.
+.PP
+Characters input are echoed only if \fBecho\fP is currently on.
 In that case,
-backspace is echoed as deletion of the previous character (typically a left
-motion).
+backspace is echoed as deletion of the previous character
+(typically a left motion).
+.PP
+The
+\fBgetnstr\fP,
+\fBmvgetnstr\fP,
+\fBmvwgetnstr\fP, and
+\fBwgetnstr\fP
+functions are identical
+to the
+\fBgetstr\fP,
+\fBmvgetstr\fP,
+\fBmvwgetstr\fP, and
+\fBwgetstr\fP
+functions, respectively,
+except that the
+\fB*n*\fP
+versions read at most
+\fIn\fP
+characters, letting the application prevent overflow of the
+input buffer.
 .SH RETURN VALUE
-All routines return the integer \fBERR\fR upon failure and an \fBOK\fR (SVr4
-specifies only \*(``an integer value other than \fBERR\fR\*('') upon successful
-completion.
+All of these functions return the integer \fBOK\fP upon successful completion.
+(SVr4 specifies only \*(``an integer value other than \fBERR\fP\*('')
+If unsuccessful, they return \fBERR\fP.
 .PP
 X/Open defines no error conditions.
 .PP
 In this implementation,
 these functions return an error
-if the window pointer is null, or
-if its timeout expires without having any data.
+.bP
+if the window pointer is null,
+.bP
+if its timeout expires without having any data, or
+.bP
+if the associated call to
+\fBwgetch\fP
+failed.
 .PP
 This implementation provides an extension as well.
 If a \fBSIGWINCH\fP interrupts the function, it will return \fBKEY_RESIZE\fP
 rather than \fBOK\fP or \fBERR\fP.
 .PP
-Functions with a \*(``mv\*('' prefix first perform a cursor movement using
-\fBwmove\fP, and return an error if the position is outside the window,
-or if the window pointer is null.
+Functions prefixed with \*(``mv\*('' first perform cursor movement and
+fail if the position
+.RI ( y ,
+.IR x )
+is outside the window boundaries.
 .SH NOTES
-Note that \fBgetstr\fR, \fBmvgetstr\fR, and \fBmvwgetstr\fR may be macros.
+Any of these functions other than
+\fBwgetnstr\fP
+may be macros.
+.PP
+Using
+\fBgetstr\fP,
+\fBmvgetstr\fP,
+\fBmvwgetstr\fP, or
+\fBwgetstr\fP
+to read a line that
+overflows the array pointed to by
+\fBstr\fP
+causes undefined
+results.
+The use of
+\fBgetnstr\fP,
+\fBmvgetnstr\fP,
+\fBmvwgetnstr\fP, or
+\fBwgetnstr\fP,
+respectively, is recommended.
 .SH PORTABILITY
-These functions are described in the XSI Curses standard, Issue 4.
-They read single-byte characters only.
-The standard does not define any error conditions.
+These functions are described in The Single Unix Specification, Version 2.
+No error conditions are defined.
+.PP
 This implementation returns \fBERR\fP if the window pointer is null,
-or if the lower-level \fBwgetch\fR(3X) call returns an \fBERR\fP.
+or if the lower-level \fBwgetch\fP(3X) call returns an \fBERR\fP.
 .PP
 SVr3 and early SVr4 curses implementations did not reject function keys;
 the SVr4.0 documentation claimed that \*(``special keys\*(''
 (such as function keys,
 \*(``home\*('' key,
 \*(``clear\*('' key,
-\fIetc\fR.) are \*(``interpreted\*('',
+\fIetc\fP.) are \*(``interpreted\*('',
 without giving details.
 It lied.
 In fact, the \*(``character\*('' value appended to the
 string by those implementations was predictable but not useful
 (being, in fact, the low-order eight bits of the key's KEY_ value).
 .PP
-The functions \fBgetnstr\fR, \fBmvgetnstr\fR, and \fBmvwgetnstr\fR were
+The functions \fBgetnstr\fP, \fBmvgetnstr\fP, and \fBmvwgetnstr\fP were
 present but not documented in SVr4.
 .PP
 X/Open Curses, Issue 5 (2007) stated that these functions
@@ -147,9 +203,9 @@ but did not state whether the terminating NUL is counted in that limit.
 X/Open Curses, Issue 7 (2009) changed that to say they
 \*(``read at most \fIn\fP\-1 bytes\*(''
 to allow for the terminating NUL.
-As of 2018, some implementations do, some do not count it:
+As of 2018, some implementations count it, some do not:
 .bP
-ncurses 6.1 and PDCurses do not count the NUL in the given limit, while
+\fI\%ncurses\fP 6.1 and PDCurses do not count the NUL in the given limit, while
 .bP
 Solaris SVr4 and NetBSD curses count the NUL as part of the limit.
 .bP
@@ -177,17 +233,69 @@ that it is greater than zero.
 .IP
 A comment in NetBSD's source code states that this is specified in SUSv2.
 .bP
-ncurses (before 6.2) assumes no particular limit for the result
+\fI\%ncurses\fP (before 6.2) assumes no particular limit for the result
 from \fBwgetstr\fP, and treats the \fIn\fP parameter of \fBwgetnstr\fP
 like SVr4 curses.
 .bP
-ncurses 6.2 uses \fBLINE_MAX\fP,
+\fI\%ncurses\fP 6.2 uses \fBLINE_MAX\fP,
 or a larger (system-dependent) value
 which the \fBsysconf\fP function may provide.
 If neither \fBLINE_MAX\fP or \fBsysconf\fP is available,
-ncurses uses the POSIX value for \fBLINE_MAX\fP (a 2048 byte limit).
+\fI\%ncurses\fP uses the POSIX value for \fBLINE_MAX\fP (a 2048 byte limit).
 In either case, it reserves a byte for the terminating NUL.
+.PP
+Although \fBgetnstr\fP is equivalent to a series of calls to \fBgetch\fP,
+it also makes changes to the curses modes to allow simple editing of
+the input buffer:
+.bP
+\fBgetnstr\fP saves the current value of the \fBnl\fP, \fBecho\fP,
+\fBraw\fP and \fBcbreak\fP modes, and sets
+\fBnl\fP,
+\fBnoecho\fP,
+\fBnoraw\fP, and
+\fBcbreak\fP.
+.IP
+\fBgetnstr\fP handles the echoing of characters,
+rather than relying on the caller to set an appropriate mode.
+.bP
+It also obtains the \fIerase\fP and \fIkill\fP characters
+from \fBerasechar\fP and \fBkillchar\fP, respectively.
+.bP
+On return, \fBgetnstr\fP restores the modes to their previous values.
+.PP
+Other implementations differ in their treatment of special characters:
+.bP
+While they may set the \fIecho\fP mode,
+other implementations do not modify the \fIraw\fP mode,
+They may take the \fIcbreak\fP
+mode set by the caller into account when deciding whether to handle
+echoing within \fBgetnstr\fP or as a side-effect of the \fBgetch\fP calls.
+.bP
+The original \fI\%ncurses\fP
+(as \fIpcurses\fP in 1986)
+set \fBnoraw\fP and \fBcbreak\fP when accepting input for \fBgetnstr\fP.
+That may have been done to make function- and cursor-keys work;
+it is not necessary with \fI\%ncurses\fP.
+.IP
+Since 1995,
+\fI\%ncurses\fP has provided signal handlers for INTR and QUIT
+(e.g., \fB^C\fP or \fB^\e\fP).
+With the \fBnoraw\fP and \fBcbreak\fP settings,
+those may catch a signal and stop the program,
+where other implementations allow one to enter those characters in the buffer.
+.bP
+Starting in 2021
+(\fI\%ncurses\fP 6.3),
+\fBgetnstr\fP sets \fBraw\fP,
+rather than \fBnoraw\fP and \fBcbreak\fP for better compatibility with
+SVr4-curses, e.g., allowing one to enter a \fB^C\fP into the buffer.
 .SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_getch\fR(3X),
-\fBcurs_variables\fR(3X).
+\fB\%curs_get_wstr\fP(3X) describes comparable functions of the
+.I \%ncurses
+library in its wide-character configuration
+.RI ( \%ncursesw ).
+.PP
+\fB\%curses\fP(3X),
+\fB\%curs_getch\fP(3X),
+\fB\%curs_termattrs\fP(3X),
+\fB\%curs_variables\fP(3X)
diff --git a/contrib/ncurses/man/curs_getyx.3x b/contrib/ncurses/man/curs_getyx.3x
index e6ff67014864..eadcecef2cad 100644
--- a/contrib/ncurses/man/curs_getyx.3x
+++ b/contrib/ncurses/man/curs_getyx.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2020 Thomas E. Dickey                                          *
+.\" Copyright 2020-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2007,2010 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,75 +27,87 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_getyx.3x,v 1.20 2020/10/24 09:38:43 tom Exp $
-.TH curs_getyx 3X ""
+.\" $Id: curs_getyx.3x,v 1.44 2024/04/20 21:20:07 tom Exp $
+.TH curs_getyx 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .SH NAME
-\fBgetyx\fR,
-\fBgetparyx\fR,
-\fBgetbegyx\fR,
-\fBgetmaxyx\fR \- get \fBcurses\fR cursor and window coordinates
+\fB\%getyx\fP,
+\fB\%getparyx\fP,
+\fB\%getbegyx\fP,
+\fB\%getmaxyx\fP \-
+get \fIcurses\fR cursor and window coordinates
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBvoid getyx(WINDOW *\fP\fIwin\fP\fB, int \fP\fIy\fP\fB, int \fP\fIx\fP\fB);\fR
-.br
-\fBvoid getparyx(WINDOW *\fP\fIwin\fP\fB, int \fP\fIy\fP\fB, int \fP\fIx\fP\fB);\fR
-.br
-\fBvoid getbegyx(WINDOW *\fP\fIwin\fP\fB, int \fP\fIy\fP\fB, int \fP\fIx\fP\fB);\fR
-.br
-\fBvoid getmaxyx(WINDOW *\fP\fIwin\fP\fB, int \fP\fIy\fP\fB, int \fP\fIx\fP\fB);\fR
-.br
+.nf
+\fB#include <curses.h>
+.PP
+\fBvoid getyx(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP);
+\fBvoid getparyx(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP);
+\fBvoid getbegyx(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP);
+\fBvoid getmaxyx(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP);
+.fi
 .SH DESCRIPTION
-The \fBgetyx\fR macro places the current cursor position of the given window in
-the two integer variables \fIy\fR and \fIx\fR.
+The \fB\%getyx\fP macro places the current cursor position
+of the given window in the two integer variables \fIy\fP and \fIx\fP.
 .PP
-If \fIwin\fR is a subwindow, the \fBgetparyx\fR macro places the beginning
+If \fIwin\fP is a subwindow, the \fB\%getparyx\fP macro places the beginning
 coordinates of the subwindow relative to the parent window into two integer
-variables \fIy\fR and \fIx\fR.
-Otherwise, \fB\-1\fR is placed into \fIy\fR and \fIx\fR.
+variables \fIy\fP and \fIx\fP.
+Otherwise, \fB\-1\fP is placed into \fIy\fP and \fIx\fP.
 .PP
-Like \fBgetyx\fR, the \fBgetbegyx\fR and \fBgetmaxyx\fR macros store
+Like \fB\%getyx\fP, the \fB\%getbegyx\fP and \fB\%getmaxyx\fP macros store
 the current beginning coordinates and size of the specified window.
 .SH RETURN VALUE
 The return values of these macros are undefined (i.e.,
 they should not be used as the right-hand side of assignment statements).
 .SH NOTES
 All of these interfaces are macros.
-A "\fB&\fR" is not necessary before the variables \fIy\fR and \fIx\fR.
+A \*(``&\*('' is not necessary before the variables \fIy\fP and \fIx\fP.
 .SH PORTABILITY
 The
-\fBgetyx\fR,
-\fBgetparyx\fR,
-\fBgetbegyx\fR and
-\fBgetmaxyx\fR
-macros are described in the XSI Curses standard, Issue 4.
+\fB\%getyx\fP,
+\fB\%getparyx\fP,
+\fB\%getbegyx\fP and
+\fB\%getmaxyx\fP
+macros are described in X/Open Curses, Issue 4.
 .PP
 This implementation also provides functions
-\fBgetbegx\fR,
-\fBgetbegy\fR,
-\fBgetcurx\fR,
-\fBgetcury\fR,
-\fBgetmaxx\fR,
-\fBgetmaxy\fR,
-\fBgetparx\fR and
-\fBgetpary\fR
-for compatibility with older versions of curses.
+\fB\%getbegx\fP,
+\fB\%getbegy\fP,
+\fB\%getcurx\fP,
+\fB\%getcury\fP,
+\fB\%getmaxx\fP,
+\fB\%getmaxy\fP,
+\fB\%getparx\fP and
+\fB\%getpary\fP
+for compatibility with older versions of \fIcurses\fP;
+see \fB\%curs_legacy\fP(3X).
 .PP
 Although X/Open Curses does not address this,
-many implementations provide members of the WINDOW structure
+many implementations provide members of the \fB\%WINDOW\fP structure
 containing values corresponding to these macros.
-For best portability, do not rely on using the data in WINDOW,
-since some implementations make WINDOW opaque (do not allow
+For best portability, do not rely on using the data in \fB\%WINDOW\fP,
+since some implementations make \fB\%WINDOW\fP opaque (do not allow
 direct use of its members).
 .PP
 Besides the problem of opaque structures,
 the data stored in like-named members may not have like-values in
 different implementations.
-For example, the WINDOW._maxx and WINDOW._maxy values in ncurses
-have (at least since release 1.8.1) differed by one from some
-other implementations.
-The difference is hidden by means of the macro \fBgetmaxyx\fP.
+For example, the \fB\%WINDOW._maxx\fP and \fB\%WINDOW._maxy\fP values
+in \fI\%ncurses\fP have
+(at least since release 1.8.1)
+differed by one from some other implementations.
+The difference is hidden by means of the macro \fB\%getmaxyx\fP.
 .SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_legacy\fR(3X),
-\fBcurs_opaque\fR(3X)
+\fB\%curses\fP(3X),
+\fB\%curs_legacy\fP(3X),
+\fB\%curs_opaque\fP(3X)
diff --git a/contrib/ncurses/man/curs_in_wch.3x b/contrib/ncurses/man/curs_in_wch.3x
index e2678997b4c6..8512e6d3b51e 100644
--- a/contrib/ncurses/man/curs_in_wch.3x
+++ b/contrib/ncurses/man/curs_in_wch.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 2002-2010,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,45 +27,58 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_in_wch.3x,v 1.10 2020/10/17 23:19:29 tom Exp $
-.TH curs_in_wch 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: curs_in_wch.3x,v 1.31 2024/04/20 21:20:07 tom Exp $
+.TH curs_in_wch 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
 .SH NAME
-\fBin_wch\fR,
-\fBmvin_wch\fR,
-\fBmvwin_wch\fR,
-\fBwin_wch\fR \- extract a complex character and rendition from a window
+\fB\%in_wch\fP,
+\fB\%mvin_wch\fP,
+\fB\%mvwin_wch\fP,
+\fB\%win_wch\fP \-
+get a \fIcurses\fR complex character from a window
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBint in_wch(cchar_t *\fR\fIwcval\fR\fB);\fR
-.br
-\fBint win_wch(WINDOW *\fR\fIwin\fR\fB, cchar_t *\fR\fIwcval\fR\fB);\fR
-.sp
-\fBint mvin_wch(int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, cchar_t *\fR\fIwcval\fR\fB);\fR
-.br
-\fBint mvwin_wch(WINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, cchar_t *\fR\fIwcval\fR\fB);\fR
+.nf
+\fB#include <curses.h>
+.PP
+\fBint in_wch(cchar_t *\fIwch\fP);
+\fBint win_wch(WINDOW *\fIwin\fP, cchar_t *\fIwch\fP);
+.PP
+\fBint mvin_wch(int \fIy\fP, int \fIx\fP, cchar_t *\fIwch\fP);
+\fBint mvwin_wch(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, cchar_t *\fIwch\fP);
+.fi
 .SH DESCRIPTION
 These functions extract the complex character and rendition from
-the current position in the named window into the \fBcchar_t\fR object
-referenced by wcval.
+the current position in the named window into the \fBcchar_t\fP object
+referenced by wch.
 .SH RETURN VALUE
-No errors are defined in the XSI Curses standard.
+No errors are defined in X/Open Curses.
 This implementation checks for null pointers, returns \fBERR\fP in that case.
-Also, the \fImv\fR routines check for error moving the cursor,
+Also, the \fImv\fP routines check for error moving the cursor,
 returning \fBERR\fP in that case.
 Otherwise they return \fBOK\fP.
 .PP
-Functions with a \*(``mv\*('' prefix first perform a cursor movement using
-\fBwmove\fP, and return an error if the position is outside the window,
-or if the window pointer is null.
+Functions prefixed with \*(``mv\*('' first perform cursor movement and
+fail if the position
+.RI ( y ,
+.IR x )
+is outside the window boundaries.
 .SH NOTES
 Note that all of these routines may be macros.
 .SH PORTABILITY
-These functions are described in the XSI Curses standard, Issue 4.
+These functions are described in X/Open Curses, Issue 4.
 .SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_inch\fR(3X).
+\fB\%curs_inch\fP(3X) describes comparable functions of the
+.I \%ncurses
+library in its non-wide-character configuration.
+.PP
+\fB\%curses\fP(3X),
+\fB\%curs_inwstr\fP(3X)
diff --git a/contrib/ncurses/man/curs_in_wchstr.3x b/contrib/ncurses/man/curs_in_wchstr.3x
index 4feae48098ca..53c984647507 100644
--- a/contrib/ncurses/man/curs_in_wchstr.3x
+++ b/contrib/ncurses/man/curs_in_wchstr.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 2002-2012,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,100 +27,106 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_in_wchstr.3x,v 1.14 2020/10/17 23:19:44 tom Exp $
-.TH curs_in_wchstr 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
-.na
-.hy 0
+.\" $Id: curs_in_wchstr.3x,v 1.39 2024/04/20 21:24:19 tom Exp $
+.TH curs_in_wchstr 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
+.de bP
+.ie n  .IP \(bu 4
+.el    .IP \(bu 2
+..
 .SH NAME
-\fBin_wchstr\fR,
-\fBin_wchnstr\fR,
-\fBwin_wchstr\fR,
-\fBwin_wchnstr\fR,
-\fBmvin_wchstr\fR,
-\fBmvin_wchnstr\fR,
-\fBmvwin_wchstr\fR,
-\fBmvwin_wchnstr\fR \- get an array of complex characters and renditions from a curses window
-.ad
-.hy
+\fB\%in_wchstr\fP,
+\fB\%in_wchnstr\fP,
+\fB\%win_wchstr\fP,
+\fB\%win_wchnstr\fP,
+\fB\%mvin_wchstr\fP,
+\fB\%mvin_wchnstr\fP,
+\fB\%mvwin_wchstr\fP,
+\fB\%mvwin_wchnstr\fP \-
+get a \fIcurses\fR complex character string from a window
 .SH SYNOPSIS
 .nf
-\fB#include <curses.h>\fR
-.sp
-\fBint in_wchstr(cchar_t *\fR\fIwchstr\fR\fB);\fR
-.br
-\fBint in_wchnstr(cchar_t *\fR\fIwchstr\fR\fB, int \fR\fIn\fR\fB);\fR
-.br
-\fBint win_wchstr(WINDOW *\fR\fIwin\fR\fB, cchar_t *\fR\fIwchstr\fR\fB);\fR
-.br
-\fBint win_wchnstr(WINDOW *\fR\fIwin\fR\fB, cchar_t *\fR\fIwchstr\fR\fB, int \fR\fIn\fR\fB);\fR
-.sp
-\fBint mvin_wchstr(int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, cchar_t *\fR\fIwchstr\fR\fB);\fR
-.br
-\fBint mvin_wchnstr(int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, cchar_t *\fR\fIwchstr\fR\fB, int \fR\fIn\fR\fB);\fR
-.br
-\fBint mvwin_wchstr(WINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, cchar_t *\fR\fIwchstr\fR\fB);\fR
-.br
-\fBint mvwin_wchnstr(WINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, cchar_t *\fR\fIwchstr\fR, int \fIn\fR\fB);\fR
+\fB#include <curses.h>
+.PP
+\fBint in_wchstr(cchar_t *\fIwchstr\fP);
+\fBint win_wchstr(WINDOW *\fIwin\fP, cchar_t *\fIwchstr\fP);
+\fBint mvin_wchstr(int \fIy\fP, int \fIx\fP, cchar_t *\fIwchstr\fP);
+\fBint mvwin_wchstr(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, cchar_t *\fIwchstr\fP);
+.PP
+\fBint in_wchnstr(cchar_t *\fIwchstr\fP, int \fIn\fP);
+\fBint win_wchnstr(WINDOW *\fIwin\fP, cchar_t *\fIwchstr\fP, int \fIn\fP);
+\fBint mvin_wchnstr(int \fIy\fP, int \fIx\fP, cchar_t *\fIwchstr\fP, int \fIn\fP);
+\fBint mvwin_wchnstr(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, cchar_t *\fIwchstr\fP, int \fIn\fP);
 .fi
 .SH DESCRIPTION
-These functions return an array of complex characters in \fIwchstr\fR,
+These functions return an array of complex characters in \fIwchstr\fP,
 starting at the current cursor position in the named window.
 Attributes (rendition) are stored with the characters.
 .PP
-The
-\fBin_wchnstr\fR,
-\fBmvin_wchnstr\fR,
-\fBmvwin_wchnstr\fR
-and
-\fBwin_wchnstr\fR
-fill the array
-with at most
-\fIn\fR
-\fBcchar_t\fR
-elements.
-.br
+The four functions with \fIn\fP as the last argument return
+a leading substring at most \fIn\fP characters long
+(exclusive of the trailing zeroed \fBcchar_t\fR.
+Transfer stops at the end of the current line, or when \fIn\fP characters have
+been stored at the location referenced by \fIwchstr\fP.
+.PP
+Constants defined in \fB<curses.h>\fP can be used with the \fB&\fP (logical
+AND) operator to extract the character or the attribute alone from any position
+in the \fIwchstr\fP [see \fBgetcchar\fP(3X)].
+.SH RETURN VALUE
+Upon successful completion, these functions return
+\fBOK\fP.
+Otherwise, they return
+\fBERR\fP.
+.PP
+X/Open Curses defines no error conditions.
+This implementation returns an error
+.bP
+if the \fIwin\fP parameter is null or
+.bP
+if the \fIwchstr\fP parameter is null.
+.PP
+Functions prefixed with \*(``mv\*('' first perform cursor movement and
+fail if the position
+.RI ( y ,
+.IR x )
+is outside the window boundaries.
 .SH NOTES
-Note that all routines except
-\fBwin_wchnstr\fR
-may be
-macros.
+All routines except \fBwin_wchnstr\fP may be macros.
 .PP
 Reading a line that overflows the array pointed to by
-\fIwchstr\fR
+\fIwchstr\fP
 with
-\fBin_wchstr\fR,
-\fBmvin_wchstr\fR,
-\fBmvwin_wchstr\fR
+\fBin_wchstr\fP,
+\fBmvin_wchstr\fP,
+\fBmvwin_wchstr\fP
 or
-\fBwin_wchstr\fR
+\fBwin_wchstr\fP
 causes undefined results.
 Therefore, the use of
-\fBin_wchnstr\fR,
-\fBmvin_wchnstr\fR,
-\fBmvwin_wchnstr\fR, or
-\fBwin_wchnstr\fR
+\fBin_wchnstr\fP,
+\fBmvin_wchnstr\fP,
+\fBmvwin_wchnstr\fP, or
+\fBwin_wchnstr\fP
 is recommended.
-.SH RETURN VALUE
-Upon successful completion, these functions return
-\fBOK\fR.
-Otherwise, they return
-\fBERR\fR.
-.PP
-Functions with a \*(``mv\*('' prefix first perform a cursor movement using
-\fBwmove\fP, and return an error if the position is outside the window,
-or if the window pointer is null.
 .SH PORTABILITY
-The XSI Curses defines no error conditions.
+X/Open Curses defines no error conditions.
 This implementation checks for null pointers,
 returning \fBERR\fP in that case.
 .SH SEE ALSO
-Functions:
-\fBcurses\fR(3X),
-\fBcurs_in_wch\fR(3X),
-\fBcurs_instr\fR(3X),
-\fBcurs_inwstr\fR(3X)
-\fBcurs_inchstr\fR(3X)
+\fB\%curs_inchstr\fP(3X) describes comparable functions of the
+.I \%ncurses
+library in its non-wide-character configuration.
+.PP
+\fB\%curses\fP(3X),
+\fB\%curs_inwstr\fP(3X),
+\fB\%curs_in_wch\fP(3X)
diff --git a/contrib/ncurses/man/curs_inch.3x b/contrib/ncurses/man/curs_inch.3x
index ab38cbb9dd06..962e9dc868d4 100644
--- a/contrib/ncurses/man/curs_inch.3x
+++ b/contrib/ncurses/man/curs_inch.3x
@@ -1,6 +1,6 @@
 '\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,54 +28,66 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_inch.3x,v 1.25 2020/10/18 00:25:23 tom Exp $
-.TH curs_inch 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: curs_inch.3x,v 1.51 2024/04/20 21:20:07 tom Exp $
+.TH curs_inch 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
 .SH NAME
-\fBinch\fR,
-\fBwinch\fR,
-\fBmvinch\fR,
-\fBmvwinch\fR \- get a character and attributes from a \fBcurses\fR window
+\fB\%inch\fP,
+\fB\%winch\fP,
+\fB\%mvinch\fP,
+\fB\%mvwinch\fP \-
+get a \fIcurses\fR character from a window
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBchtype inch(void);\fR
-.br
-\fBchtype winch(WINDOW *\fP\fIwin\fP\fB);\fR
-.sp
-\fBchtype mvinch(int \fP\fIy\fP\fB, int \fP\fIx\fP\fB);\fR
-.br
-\fBchtype mvwinch(WINDOW *\fP\fIwin\fP\fB, int \fP\fIy\fP\fB, int \fP\fIx\fP\fB);\fR
-.br
+.nf
+\fB#include <curses.h>
+.PP
+\fBchtype inch(void);
+\fBchtype winch(WINDOW *\fIwin\fP);
+.PP
+\fBchtype mvinch(int \fIy\fP, int \fIx\fP);
+\fBchtype mvwinch(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP);
+.fi
 .SH DESCRIPTION
-These routines return the character, of type \fBchtype\fR, at the current
+These routines return the character, of type \fBchtype\fP, at the current
 position in the named window.
 If any attributes are set for that position,
 their values are OR'ed into the value returned.
 Constants defined in
-\fB<curses.h>\fR can be used with the \fB&\fR (logical AND) operator to
+\fB<curses.h>\fP can be used with the \fB&\fP (logical AND) operator to
 extract the character or attributes alone.
 .
 .SS Attributes
-The following bit-masks may be AND-ed with characters returned by \fBwinch\fR.
-.
+The following bit masks may be AND-ed with characters returned by \fBwinch\fP.
+.PP
 .TS
-l l .
-\fBA_CHARTEXT\fR	Bit-mask to extract character
-\fBA_ATTRIBUTES\fR	Bit-mask to extract attributes
-\fBA_COLOR\fR	Bit-mask to extract color-pair field information
+Lb Lb
+Lb Lx.
+Name	Description
+_
+A_CHARTEXT	Extract character
+A_ATTRIBUTES	Extract attributes
+A_COLOR	Extract color pair information
 .TE
 .SH RETURN VALUE
-Functions with a \*(``mv\*('' prefix first perform a cursor movement using
-\fBwmove\fP, and return an error if the position is outside the window,
-or if the window pointer is null.
+Functions prefixed with \*(``mv\*('' first perform cursor movement and
+fail if the position
+.RI ( y ,
+.IR x )
+is outside the window boundaries.
 .PP
 The \fBwinch\fP function does not return an error if the window contains
 characters larger than 8-bits (255).
@@ -83,7 +95,7 @@ Only the low-order 8 bits of the character are used by \fBwinch\fP.
 .SH NOTES
 Note that all of these routines may be macros.
 .SH PORTABILITY
-These functions are described in the XSI Curses standard, Issue 4.
+These functions are described in X/Open Curses, Issue 4.
 .PP
 Very old systems (before standardization) provide a different function
 with the same name:
@@ -100,20 +112,17 @@ could be combined with characters in the window.
 Reflecting this improvement, the function was altered to return the
 character combined with all video attributes in a \fBchtype\fP value.
 .PP
-X/Open Curses does not specify 
+X/Open Curses does not specify
 the size and layout of attributes, color and character values in
 \fBchtype\fP; it is implementation-dependent.
 This implementation uses 8 bits for character values.
 An application using more bits, e.g., a Unicode value,
 should use the wide-character equivalents to these functions.
 .SH SEE ALSO
-.TP 5
-\fBcurses\fR(3X)
-gives an overview of the WINDOW and \fBchtype\fP data types.
-.TP 5
-\fBcurs_attr\fR(3X)
-goes into more detail, pointing out portability problems and
-constraints on the use of \fBchtype\fP for returning window information.
-.TP 5
-\fBcurs_in_wch\fR(3X)
-describes comparable functions for the wide-character (ncursesw) library.
+\fB\%curs_in_wch\fP(3X) describes comparable functions of the
+.I \%ncurses
+library in its wide-character configuration
+.RI ( \%ncursesw ).
+.PP
+\fB\%curses\fP(3X),
+\fB\%curs_instr\fP(3X)
diff --git a/contrib/ncurses/man/curs_inchstr.3x b/contrib/ncurses/man/curs_inchstr.3x
index 332604e78996..bcd5d6855e1f 100644
--- a/contrib/ncurses/man/curs_inchstr.3x
+++ b/contrib/ncurses/man/curs_inchstr.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,88 +27,109 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_inchstr.3x,v 1.21 2020/10/18 00:24:36 tom Exp $
-.TH curs_inchstr 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: curs_inchstr.3x,v 1.45 2024/04/20 21:20:07 tom Exp $
+.TH curs_inchstr 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.na
-.hy 0
 .SH NAME
-\fBinchstr\fR,
-\fBinchnstr\fR,
-\fBwinchstr\fR,
-\fBwinchnstr\fR,
-\fBmvinchstr\fR,
-\fBmvinchnstr\fR,
-\fBmvwinchstr\fR,
-\fBmvwinchnstr\fR \- get a string of characters (and attributes) from a \fBcurses\fR window
-.ad
-.hy
+\fB\%inchstr\fP,
+\fB\%inchnstr\fP,
+\fB\%winchstr\fP,
+\fB\%winchnstr\fP,
+\fB\%mvinchstr\fP,
+\fB\%mvinchnstr\fP,
+\fB\%mvwinchstr\fP,
+\fB\%mvwinchnstr\fP \-
+get a \fIcurses\fR character string from a window
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBint inchstr(chtype *\fP\fIchstr\fP\fB);\fR
-.br
-\fBint inchnstr(chtype *\fP\fIchstr\fP\fB, int \fP\fIn\fP\fB);\fR
-.br
-\fBint winchstr(WINDOW *\fP\fIwin\fP\fB, chtype *\fP\fIchstr\fP\fB);\fR
-.br
-\fBint winchnstr(WINDOW *\fP\fIwin\fP\fB, chtype *\fP\fIchstr\fP\fB, int \fP\fIn\fP\fB);\fR
-.sp
-\fBint mvinchstr(int \fP\fIy\fP\fB, int \fP\fIx\fP\fB, chtype *\fP\fIchstr\fP\fB);\fR
-.br
-\fBint mvinchnstr(int \fP\fIy\fP\fB, int \fP\fIx\fP\fB, chtype *\fP\fIchstr\fP\fB, int \fP\fIn\fP\fB);\fR
-.br
-\fBint mvwinchstr(WINDOW *\fP\fIwin\fP\fB, int \fP\fIy\fP\fB, int \fP\fIx\fP\fB, chtype *\fP\fIchstr\fP\fB);\fR
-.br
-\fBint mvwinchnstr(WINDOW *\fP\fIwin\fP\fB, int \fP\fIy\fP\fB, int \fP\fIx\fP\fB, chtype *\fP\fIchstr\fP\fB, int \fP\fIn\fP\fB);\fR
-.br
+.nf
+\fB#include <curses.h>
+.PP
+\fBint inchstr(chtype *\fIchstr\fP);
+\fBint inchnstr(chtype *\fIchstr\fP, int \fIn\fP);
+\fBint winchstr(WINDOW *\fIwin\fP, chtype *\fIchstr\fP);
+\fBint winchnstr(WINDOW *\fIwin\fP, chtype *\fIchstr\fP, int \fIn\fP);
+.PP
+\fBint mvinchstr(int \fIy\fP, int \fIx\fP, chtype *\fIchstr\fP);
+\fBint mvinchnstr(int \fIy\fP, int \fIx\fP, chtype *\fIchstr\fP, int \fIn\fP);
+\fBint mvwinchstr(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, chtype *\fIchstr\fP);
+\fBint mvwinchnstr(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, chtype *\fIchstr\fP, int \fIn\fP);
+.fi
 .SH DESCRIPTION
-These routines return a NULL-terminated array of \fBchtype\fR quantities,
+These routines return a NULL-terminated array of \fBchtype\fP quantities,
 starting at the current cursor position in the named window and ending at the
 right margin of the window.
-The four functions with \fIn\fR as
-the last argument, return a leading substring at most \fIn\fR characters long
+.PP
+The four functions with \fIn\fP as the last argument, return
+a leading substring at most \fIn\fP characters long
 (exclusive of the trailing (chtype)0).
-Constants defined in \fB<curses.h>\fR can be used with the \fB&\fR (logical
+Transfer stops at the end of the current line, or when \fIn\fP characters have
+been stored at the location referenced by \fIchstr\fP.
+.PP
+Constants defined in \fB<curses.h>\fP can be used with the \fB&\fP (logical
 AND) operator to extract the character or the attribute alone from any position
-in the \fIchstr\fR [see \fBcurs_inch\fR(3X)].
+in the \fIchstr\fP [see \fBcurs_inch\fP(3X)].
 .SH RETURN VALUE
-All routines return the integer \fBERR\fR upon failure and an integer value
-other than \fBERR\fR upon successful completion (the number of characters
+All routines return the integer \fBERR\fP upon failure and an integer value
+other than \fBERR\fP upon successful completion (the number of characters
 retrieved, exclusive of the trailing 0).
 .PP
 X/Open Curses defines no error conditions.
-In this implementation:
+This implementation returns an error
 .bP
-If the \fIwin\fP parameter is null, an error is returned,
+if the \fIwin\fP parameter is null or
 .bP
-If the \fIchstr\fP parameter is null, an error is returned,
+if the \fIchstr\fP parameter is null.
 .PP
-Functions with a \*(``mv\*('' prefix first perform a cursor movement using
-\fBwmove\fP, and return an error if the position is outside the window,
-or if the window pointer is null.
+Functions prefixed with \*(``mv\*('' first perform cursor movement and
+fail if the position
+.RI ( y ,
+.IR x )
+is outside the window boundaries.
 .SH NOTES
-Note that all routines except \fBwinchnstr\fR may be macros.
+All routines except \fBwinchnstr\fP may be macros.
+.PP
 SVr4 does not
 document whether the result string is zero-terminated; it does not document
 whether a length limit argument includes any trailing 0; and it does not
 document the meaning of the return value.
+.PP
+Reading a line that overflows the array pointed to by
+\fIchstr\fP
+with
+\fBinchstr\fP,
+\fBmvinchstr\fP,
+\fBmvwinchstr\fP
+or
+\fBwinchstr\fP
+causes undefined results.
+Therefore, the use of
+\fBinchnstr\fP,
+\fBmvinchnstr\fP,
+\fBmvwinchnstr\fP, or
+\fBwinchnstr\fP
+is recommended.
 .SH PORTABILITY
-These functions are described in the XSI Curses standard, Issue 4.
+These functions are described in X/Open Curses, Issue 4.
 It is no
 more specific than the SVr4 documentation on the trailing 0.
 It does specify
-that the successful return of the functions is \fBOK\fR.
+that the successful return of the functions is \fBOK\fP.
 .SH SEE ALSO
-\fBcurses\fR(3X), \fBcurs_inch\fR(3X).
-.PP
-Comparable functions in the wide-character (ncursesw) library are
-described in
-\fBcurs_in_wchstr\fR(3X).
+\fB\%curses\fP(3X),
+\fB\%curs_inch\fP(3X),
+\fB\%curs_inwstr\fP(3X),
+\fB\%curs_in_wchstr\fP(3X)
diff --git a/contrib/ncurses/man/curs_initscr.3x b/contrib/ncurses/man/curs_initscr.3x
index 235a5aa715bb..0f460af14eee 100644
--- a/contrib/ncurses/man/curs_initscr.3x
+++ b/contrib/ncurses/man/curs_initscr.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,88 +27,93 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_initscr.3x,v 1.33 2020/10/17 23:20:48 tom Exp $
-.TH curs_initscr 3X ""
+.\" $Id: curs_initscr.3x,v 1.69 2024/04/20 21:24:19 tom Exp $
+.TH curs_initscr 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
-.na
-.hy 0
 .SH NAME
-\fBinitscr\fR,
-\fBnewterm\fR,
-\fBendwin\fR,
-\fBisendwin\fR,
-\fBset_term\fR,
-\fBdelscreen\fR \- \fBcurses\fR screen initialization and manipulation routines
-.ad
-.hy
+\fB\%initscr\fP,
+\fB\%newterm\fP,
+\fB\%endwin\fP,
+\fB\%isendwin\fP,
+\fB\%set_term\fP,
+\fB\%delscreen\fP \-
+initialize, manipulate, or tear down \fIcurses\fR terminal interface
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBWINDOW *initscr(void);\fR
-.br
-\fBint endwin(void);\fR
-.sp
-\fBbool isendwin(void);\fR
-.sp
-\fBSCREEN *newterm(const char *\fP\fItype\fP\fB, FILE *\fP\fIoutfd\fP\fB, FILE *\fP\fIinfd\fP\fB);\fR
-.br
-\fBSCREEN *set_term(SCREEN *\fP\fInew\fP\fB);\fR
-.br
-\fBvoid delscreen(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
+.nf
+\fB#include <curses.h>
+.PP
+\fBWINDOW *initscr(void);
+\fBint endwin(void);
+.PP
+\fBbool isendwin(void);
+.PP
+\fBSCREEN *newterm(const char *\fItype\fP, FILE *\fIoutf\fP, FILE *\fIinf\fP);
+\fBSCREEN *set_term(SCREEN *\fInew\fP);
+\fBvoid delscreen(SCREEN* \fIsp\fP);
+.fi
 .SH DESCRIPTION
 .SS initscr
-\fBinitscr\fR is normally the first \fBcurses\fR routine to call when
+\fBinitscr\fP is normally the first \fBcurses\fP routine to call when
 initializing a program.
 A few special routines sometimes need to be called before it;
-these are \fBslk_init\fR(3X), \fBfilter\fR, \fBripoffline\fR,
-\fBuse_env\fR.
+these are \fBslk_init\fP(3X), \fBfilter\fP, \fBripoffline\fP,
+\fBuse_env\fP.
 For multiple-terminal applications,
-\fBnewterm\fR may be called before \fBinitscr\fR.
+\fBnewterm\fP may be called before \fBinitscr\fP.
 .PP
-The initscr code determines the terminal type and initializes all \fBcurses\fR
+The initscr code determines the terminal type and initializes all \fBcurses\fP
 data structures.
-\fBinitscr\fR also causes the first call to \fBrefresh\fR(3X)
+\fBinitscr\fP also causes the first call to \fBrefresh\fP(3X)
 to clear the screen.
-If errors occur, \fBinitscr\fR writes an appropriate error
+If errors occur, \fBinitscr\fP writes an appropriate error
 message to standard error and exits;
-otherwise, a pointer is returned to \fBstdscr\fR.
+otherwise, a pointer is returned to \fBstdscr\fP.
 .SS newterm
-.PP
-A program that outputs to more than one terminal should use the \fBnewterm\fR
-routine for each terminal instead of \fBinitscr\fR.
+A program that outputs to more than one terminal should use the \fBnewterm\fP
+routine for each terminal instead of \fBinitscr\fP.
 A program that needs to inspect capabilities,
 so it can continue to run in a line-oriented mode if the
 terminal cannot support a screen-oriented program, would also use
-\fBnewterm\fR.
-The routine \fBnewterm\fR should be called once for each terminal.
-It returns a variable of type \fBSCREEN *\fR which should be saved
+\fBnewterm\fP.
+.PP
+The routine \fBnewterm\fP should be called once for each terminal.
+It returns a variable of type \fISCREEN *\fP which should be saved
 as a reference to that terminal.
 \fBnewterm\fP's arguments are
 .bP
-the \fItype\fR of the terminal to be used in place of \fB$TERM\fR,
+the \fItype\fP of the terminal to be used in place of \fB$TERM\fP,
 .bP
-a file pointer for output to the terminal, and
+an output stream connected to the terminal, and
 .bP
-another file pointer for input from the terminal
+an input stream connected to the terminal
 .PP
-If the \fItype\fR parameter is \fBNULL\fR, \fB$TERM\fR will be used.
-.SS endwin
+If the \fItype\fP parameter is \fBNULL\fP, \fB$TERM\fP will be used.
 .PP
+The file descriptor of the output stream is passed to \fBsetupterm\fP(3X),
+which returns a pointer to a \fI\%TERMINAL\fP structure.
+\fBnewterm\fP's return value holds a pointer to the \fI\%TERMINAL\fP structure.
+.SS endwin
 The program must also call
-\fBendwin\fR for each terminal being used before exiting from \fBcurses\fR.
-If \fBnewterm\fR is called more than once for the same terminal, the first
-terminal referred to must be the last one for which \fBendwin\fR is called.
+\fBendwin\fP for each terminal being used before exiting from \fBcurses\fP.
+If \fBnewterm\fP is called more than once for the same terminal, the first
+terminal referred to must be the last one for which \fBendwin\fP is called.
 .PP
-A program should always call \fBendwin\fR before exiting or escaping from
-\fBcurses\fR mode temporarily.
+A program should always call \fBendwin\fP before exiting or escaping from
+\fBcurses\fP mode temporarily.
 This routine
 .bP
 resets colors to correspond with the default color pair 0,
@@ -123,37 +128,42 @@ stops cursor-addressing mode using the \fIexit_ca_mode\fP terminal capability,
 .bP
 restores tty modes (see \fBreset_shell_mode\fP(3X)).
 .PP
-Calling \fBrefresh\fR(3X) or \fBdoupdate\fR(3X) after a
+Calling \fBrefresh\fP(3X) or \fBdoupdate\fP(3X) after a
 temporary escape causes the program to resume visual mode.
 .SS isendwin
-.PP
-The \fBisendwin\fR routine returns \fBTRUE\fR if \fBendwin\fR has been
-called without any subsequent calls to \fBwrefresh\fR,
-and \fBFALSE\fR otherwise.
+The \fBisendwin\fP routine returns \fBTRUE\fP if \fBendwin\fP has been
+called without any subsequent calls to \fBwrefresh\fP,
+and \fBFALSE\fP otherwise.
 .SS set_term
-.PP
-The \fBset_term\fR routine is used to switch between different terminals.
-The screen reference \fBnew\fR becomes the new current terminal.
+The \fBset_term\fP routine is used to switch between different terminals.
+The screen reference \fInew\fP becomes the new current terminal.
 The previous terminal is returned by the routine.
-This is the only routine which manipulates \fBSCREEN\fR pointers;
+This is the only routine which manipulates \fISCREEN\fP pointers;
 all other routines affect only the current terminal.
 .SS delscreen
-.PP
-The \fBdelscreen\fR routine frees storage associated with the
-\fBSCREEN\fR data structure.
-The \fBendwin\fR routine does not do
-this, so \fBdelscreen\fR should be called after \fBendwin\fR if a
-particular \fBSCREEN\fR is no longer needed.
+The \fBdelscreen\fP routine frees storage associated with the
+\fISCREEN\fP data structure.
+The \fBendwin\fP routine does not do
+this, so \fBdelscreen\fP should be called after \fBendwin\fP if a
+particular \fISCREEN\fP is no longer needed.
 .SH RETURN VALUE
-\fBendwin\fR returns the integer \fBERR\fR upon failure and \fBOK\fR
+\fBendwin\fP returns the integer \fBERR\fP upon failure and \fBOK\fP
 upon successful completion.
 .PP
-Routines that return pointers always return \fBNULL\fR on error.
+Routines that return pointers always return \fBNULL\fP on error.
 .PP
 X/Open defines no error conditions.
 In this implementation
 .bP
-\fBendwin\fP returns an error if the terminal was not initialized.
+\fBendwin\fP returns an error if
+.RS
+.bP
+the terminal was not initialized, or
+.bP
+\fBendwin\fP is called more than once without updating the screen, or
+.bP
+\fBreset_shell_mode\fP(3X) returns an error.
+.RE
 .bP
 \fBnewterm\fP
 returns an error if it cannot allocate the data structures for the screen,
@@ -164,47 +174,95 @@ i.e.,
 \fBset_term\fP
 returns no error.
 .SH PORTABILITY
-These functions were described in the XSI Curses standard, Issue 4.
+These functions were described in X/Open Curses, Issue 4.
 As of 2015, the current document is X/Open Curses, Issue 7.
 .SS Differences
-X/Open specifies that portable applications must not
-call \fBinitscr\fR more than once:
+X/Open Curses specifies that portable applications must not
+call \fBinitscr\fP more than once:
 .bP
 The portable way to use \fBinitscr\fP is once only,
-using \fBrefresh\fP (see curs_refresh(3X))
+using \fB\%refresh\fP(3X)
 to restore the screen after \fBendwin\fP.
 .bP
 This implementation allows using \fBinitscr\fP after \fBendwin\fP.
 .PP
-Old versions of curses, e.g., BSD 4.4, may have returned a null pointer
-from \fBinitscr\fR when an error is detected, rather than exiting.
-It is safe but redundant to check the return value of \fBinitscr\fR
-in XSI Curses.
-.SS Unset TERM Variable
+Old versions of curses, e.g., BSD 4.4, would return a null pointer
+from \fBinitscr\fP when an error is detected, rather than exiting.
+It is safe but redundant to check the return value of \fBinitscr\fP
+in X/Open Curses.
 .PP
-If the TERM variable is missing or empty, \fBinitscr\fP uses the
+Calling \fBendwin\fP does not dispose of the memory allocated in \fBinitscr\fP
+or \fBnewterm\fP.
+Deleting a \fISCREEN\fP provides a way to do this:
+.bP
+X/Open Curses does not say what happens to \fI\%WINDOW\fPs when \fBdelscreen\fP
+\*(``frees storage associated with the \fISCREEN\fP\*(''
+nor does the SVr4 documentation help,
+adding that it should be called after \fBendwin\fP if a \fISCREEN\fP
+is no longer needed.
+.bP
+However, \fI\%WINDOW\fPs are implicitly associated with a \fISCREEN\fP.
+so that it is reasonable to expect \fBdelscreen\fP to deal with these.
+.bP
+SVr4 curses deletes the standard \fI\%WINDOW\fP structures
+\fBstdscr\fP and \fBcurscr\fP as well as a work area \fBnewscr\fP.
+SVr4 curses ignores other windows.
+.bP
+Since version 4.0 (1996),
+\fI\%ncurses\fP has maintained a list of all windows for each screen,
+using that information to delete those windows when \fBdelscreen\fP is called.
+.bP
+NetBSD copied this feature of \fI\%ncurses\fP in 2001.
+PDCurses follows the SVr4 model,
+deleting only the standard \fI\%WINDOW\fP structures.
+.SS "High-level versus Low-level"
+Different implementations may disagree regarding the level of some functions.
+For example, \fISCREEN\fP (returned by \fBnewterm\fP) and
+\fI\%TERMINAL\fP (returned by \fBsetupterm\fP(3X)) hold file descriptors for
+the output stream.
+If an application switches screens using \fBset_term\fR,
+or switches terminals using \fBset_curterm\fP(3X),
+applications which use the output file descriptor can have different
+behavior depending on which structure holds the corresponding descriptor.
+.PP
+For example
+.bP
+NetBSD's \fBbaudrate\fP(3X) function uses the descriptor in \fI\%TERMINAL\fP.
+\fI\%ncurses\fP and SVr4 use the descriptor in \fISCREEN\fP.
+.bP
+NetBSD and \fI\%ncurses\fP use the descriptor
+in \fI\%TERMINAL\fP
+for terminal I/O modes,
+e.g.,
+\fBdef_shell_mode\fP(3X),
+\fBdef_prog_mode\fP(3X).
+SVr4 curses uses the descriptor in \fISCREEN\fP.
+.SS "Unset \fITERM\fP Variable"
+If the \fITERM\fP variable is missing or empty, \fBinitscr\fP uses the
 value \*(``unknown\*('',
 which normally corresponds to a terminal entry with the \fIgeneric\fP
 (\fIgn\fP) capability.
-Generic entries are detected by \fBsetupterm\fP
-(see curs_terminfo(3X)) and cannot be used for full-screen operation.
-Other implementations may handle a missing/empty TERM variable differently.
-.SS Signal Handlers
-.PP
-Quoting from X/Open Curses, section 3.1.1:
+Generic entries are detected by \fBsetupterm\fP(3X)
+and cannot be used for full-screen operation.
+Other implementations may handle
+a missing/empty \fITERM\fP variable differently.
+.SS "Signal Handlers"
+Quoting from X/Open Curses Issue 7, section 3.1.1:
 .RS 5
 .PP
-\fICurses implementations may provide for special handling of the \fBSIGINT\fP,
-\fBSIGQUIT\fP and \fBSIGTSTP\fP signals
-if their disposition is \fBSIG_DFL\fP at the time
-\fBinitscr\fP is called \fP...
+Curses implementations may provide for special handling of the
+\%SIGINT,
+\%SIGQUIT,
+and \%SIGTSTP signals if their disposition is \%SIG_DFL at the time
+.I \%initscr
+is called.\|.\|.
 .PP
-\fIAny special handling for these signals may remain in effect for the
+Any special handling for these signals may remain in effect for the
 life of the process or until the process changes the disposition of
-the signal.\fP
+the signal.
 .PP
-\fINone of the Curses functions are required to be safe
-with respect to signals \fP...
+None of the Curses functions are required to be safe
+with respect to signals.\|.\|.
 .RE
 .PP
 This implementation establishes signal handlers during initialization,
@@ -213,18 +271,19 @@ Applications which must handle these signals should set up the corresponding
 handlers \fIafter\fP initializing the library:
 .TP 5
 .B SIGINT
-The handler \fIattempts\fP to cleanup the screen on exit.
+The handler \fIattempts\fP to clean up the screen on exit.
 Although it \fIusually\fP works as expected, there are limitations:
 .RS 5
 .bP
-Walking the \fBSCREEN\fP list is unsafe, since all list management
+Walking the \fISCREEN\fP list is unsafe, since all list management
 is done without any signal blocking.
 .bP
 On systems which have \fBREENTRANT\fP turned on, \fBset_term\fP uses
 functions which could deadlock or misbehave in other ways.
 .bP
-\fBendwin\fP calls other functions, many of which use stdio or
-other library functions which are clearly unsafe.
+\fBendwin\fP calls other functions,
+many of which use \fI\%stdio\fP(3) or other library functions which are
+clearly unsafe.
 .RE
 .TP 5
 .B SIGTERM
@@ -235,26 +294,26 @@ purpose than \fBSIGQUIT\fP (which is used in debugging).
 .B SIGTSTP
 This handles the \fIstop\fP signal, used in job control.
 When resuming the process, this implementation discards pending
-input with \fBflushinput\fP (see curs_util(3X)), and repaints the screen
+input with \fB\%flushinp\fP(3X), and repaints the screen
 assuming that it has been completely altered.
-It also updates the saved terminal modes with \fBdef_shell_mode\fP
-(see \fBcurs_kernel\fR(3X)).
+It also updates the saved terminal modes with
+\fB\%def_shell_mode\fP(3X).
 .TP 5
 .B SIGWINCH
 This handles the window-size changes which were ignored in
 the standardization efforts.
 The handler sets a (signal-safe) variable
-which is later tested in \fBwgetch\fP (see curs_getch(3X)).
+which is later tested in \fB\%wgetch\fP(3X).
 If \fBkeypad\fP has been enabled for the corresponding window,
 \fBwgetch\fP returns the key symbol \fBKEY_RESIZE\fP.
 At the same time, \fBwgetch\fP calls \fBresizeterm\fP to adjust the
 standard screen \fBstdscr\fP,
 and update other data such as \fBLINES\fP and \fBCOLS\fP.
 .SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_kernel\fR(3X),
-\fBcurs_refresh\fR(3X),
-\fBcurs_slk\fR(3X),
-\fBcurs_terminfo\fR(3X),
-\fBcurs_util\fR(3X),
-\fBcurs_variables\fR(3X).
+\fB\%curses\fP(3X),
+\fB\%curs_kernel\fP(3X),
+\fB\%curs_refresh\fP(3X),
+\fB\%curs_slk\fP(3X),
+\fB\%curs_terminfo\fP(3X),
+\fB\%curs_util\fP(3X),
+\fB\%curs_variables\fP(3X)
diff --git a/contrib/ncurses/man/curs_inopts.3x b/contrib/ncurses/man/curs_inopts.3x
index d346017ba0ea..63db4967eebc 100644
--- a/contrib/ncurses/man/curs_inopts.3x
+++ b/contrib/ncurses/man/curs_inopts.3x
@@ -1,5 +1,6 @@
+'\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,354 +28,527 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_inopts.3x,v 1.33 2020/12/05 19:38:18 Benno.Schulenberg Exp $
-.TH curs_inopts 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
-.na
-.hy 0
+.\" $Id: curs_inopts.3x,v 1.66 2024/04/13 22:20:29 tom Exp $
+.TH curs_inopts 3X 2024-04-13 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
 .SH NAME
-\fBcbreak\fR,
-\fBnocbreak\fR,
-\fBecho\fR,
-\fBnoecho\fR,
-\fBhalfdelay\fR,
-\fBintrflush\fR,
-\fBkeypad\fR,
-\fBmeta\fR,
-\fBnl\fR,
-\fBnonl\fR,
-\fBnodelay\fR,
-\fBnotimeout\fR,
-\fBraw\fR,
-\fBnoraw\fR,
-\fBqiflush\fR,
-\fBnoqiflush\fR,
-\fBtimeout\fR,
-\fBwtimeout\fR,
-\fBtypeahead\fR \- \fBcurses\fR input options
-.ad
-.hy
+\fB\%cbreak\fP,
+\fB\%echo\fP,
+\fB\%halfdelay\fP,
+\fB\%intrflush\fP,
+\fB\%is_cbreak\fP,
+\fB\%is_echo\fP,
+\fB\%is_nl\fP,
+\fB\%is_raw\fP,
+\fB\%keypad\fP,
+\fB\%meta\fP,
+\fB\%nl\fP,
+\fB\%nocbreak\fP,
+\fB\%nodelay\fP,
+\fB\%noecho\fP,
+\fB\%nonl\fP,
+\fB\%noqiflush\fP,
+\fB\%noraw\fP,
+\fB\%notimeout\fP,
+\fB\%qiflush\fP,
+\fB\%raw\fP,
+\fB\%timeout\fP,
+\fB\%wtimeout\fP,
+\fB\%typeahead\fP \-
+get and set \fIcurses\fR terminal input options
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
+.nf
+\fB#include <curses.h>
 .PP
-\fBint cbreak(void);\fR
-.br
-\fBint nocbreak(void);\fR
-.sp
-\fBint echo(void);\fR
-.br
-\fBint noecho(void);\fR
-.sp
-\fBint intrflush(WINDOW *\fP\fIwin\fP\fB, bool \fP\fIbf\fP\fB);\fR
-.br
-\fBint keypad(WINDOW *\fP\fIwin\fP\fB, bool \fP\fIbf\fP\fB);\fR
-.br
-\fBint meta(WINDOW *\fP\fIwin\fP\fB, bool \fP\fIbf\fP\fB);\fR
-.br
-\fBint nodelay(WINDOW *\fP\fIwin\fP\fB, bool \fP\fIbf\fP\fB);\fR
-.br
-\fBint notimeout(WINDOW *\fP\fIwin\fP\fB, bool \fP\fIbf\fP\fB);\fR
-.sp
-\fBint nl(void);\fR
-.br
-\fBint nonl(void);\fR
-.sp
-\fBint raw(void);\fR
-.br
-\fBint noraw(void);\fR
-.sp
-\fBvoid qiflush(void);\fR
-.br
-\fBvoid noqiflush(void);\fR
-.sp
-\fBint halfdelay(int \fP\fItenths\fP\fB);\fR
-.br
-\fBvoid timeout(int \fP\fIdelay\fP\fB);\fR
-.br
-\fBvoid wtimeout(WINDOW *\fP\fIwin\fP\fB, int \fP\fIdelay\fP\fB);\fR
-.sp
-\fBint typeahead(int \fP\fIfd\fP\fB);\fR
-.br
+\fBint cbreak(void);
+\fBint nocbreak(void);
+.PP
+\fBint echo(void);
+\fBint noecho(void);
+.PP
+\fBint intrflush(WINDOW *\fIwin\fP, bool \fIbf\fP);
+\fBint keypad(WINDOW *\fIwin\fP, bool \fIbf\fP);
+\fBint meta(WINDOW *\fIwin\fP, bool \fIbf\fP);
+\fBint nodelay(WINDOW *\fIwin\fP, bool \fIbf\fP);
+\fBint notimeout(WINDOW *\fIwin\fP, bool \fIbf\fP);
+.PP
+\fBint nl(void);
+\fBint nonl(void);
+.PP
+\fBint raw(void);
+\fBint noraw(void);
+.PP
+\fBvoid qiflush(void);
+\fBvoid noqiflush(void);
+.PP
+\fBint halfdelay(int \fItenths\fP);
+\fBvoid timeout(int \fIdelay\fP);
+\fBvoid wtimeout(WINDOW *\fIwin\fP, int \fIdelay\fP);
+.PP
+\fBint typeahead(int \fIfd\fP);
+.PP
+\fI/* extensions */
+\fBint is_cbreak(void);
+\fBint is_echo(void);
+\fBint is_nl(void);
+\fBint is_raw(void);
+.fi
 .SH DESCRIPTION
-The \fBncurses\fP library provides several functions which let an application
-change the way input from the terminal is handled.
-Some are global, applying to all windows.
+.I \%ncurses
+provides several functions that let an application change the way input
+from the terminal is handled.
+Some are global,
+applying to all windows.
 Others apply only to a specific window.
 Window-specific settings are not automatically applied to new or derived
 windows.
-An application must apply these to each window, if the same behavior
-is needed.
+An application must apply these to each window if the same behavior is
+desired.
 .\"
-.SS cbreak/nocbreak
-Normally, the tty driver buffers typed characters until a newline or carriage
+.SS "cbreak, nocbreak"
+Normally,
+the terminal driver buffers typed characters until a newline or carriage
 return is typed.
-The \fBcbreak\fR routine disables line buffering and
-erase/kill character-processing (interrupt and flow control characters are
-unaffected), making characters typed by the user immediately available to the
+The \fB\%cbreak\fP routine disables line buffering and
+erase/kill character-processing
+(interrupt and flow control characters are unaffected),
+making characters typed by the user immediately available to the
 program.
-The \fBnocbreak\fR routine returns the terminal to normal (cooked)
+The \fB\%nocbreak\fP routine returns the terminal to normal (cooked)
 mode.
 .PP
-Initially the terminal may or may not be in \fBcbreak\fR mode, as the mode is
-inherited; therefore, a program should call \fBcbreak\fR or \fBnocbreak\fR
-explicitly.
-Most interactive programs using \fBcurses\fR set the \fBcbreak\fR
-mode.
-Note that \fBcbreak\fR overrides \fBraw\fR.
-[See \fBcurs_getch\fR(3X) for a
-discussion of how these routines interact with \fBecho\fR and \fBnoecho\fR.]
+Initially the terminal may or may not be in \fB\%cbreak\fP mode,
+as the mode is inherited;
+therefore,
+a program should call \fB\%cbreak\fP or \fB\%nocbreak\fP explicitly.
+Most interactive programs using
+.I curses
+set the \fB\%cbreak\fP mode.
+Note that \fB\%cbreak\fP overrides \fBraw\fP.
+[See \fB\%curs_getch\fP(3X) for a discussion of how these routines
+interact with \fBecho\fP and \fB\%noecho\fP.]
 .\"
-.SS echo/noecho
-.PP
-The \fBecho\fR and \fBnoecho\fR routines control whether characters typed by
-the user are echoed by \fBgetch\fR(3X) as they are typed.
-Echoing by the tty
-driver is always disabled, but initially \fBgetch\fR is in echo mode, so
-characters typed are echoed.
+.SS "echo, noecho"
+The \fBecho\fP and \fB\%noecho\fP routines control whether characters
+typed by the user are echoed by \fB\%getch\fP(3X) as they are typed.
+Echoing by the terminal driver is always disabled,
+but initially \fB\%getch\fP is in echo mode,
+so characters typed are echoed.
 Authors of most interactive programs prefer to do
-their own echoing in a controlled area of the screen, or not to echo at all, so
-they disable echoing by calling \fBnoecho\fR.
-[See \fBcurs_getch\fR(3X) for a
-discussion of how these routines interact with \fBcbreak\fR and
-\fBnocbreak\fR.]
+their own echoing in a controlled area of the screen,
+or not to echo at all,
+so they disable echoing by calling \fB\%noecho\fP.
+[See \fB\%curs_getch\fP(3X) for a
+discussion of how these routines interact with \fB\%cbreak\fP and
+\fB\%nocbreak\fP.]
 .\"
 .SS halfdelay
-.PP
-The \fBhalfdelay\fR routine is used for half-delay mode, which is similar to
-\fBcbreak\fR mode in that characters typed by the user are immediately
-available to the program.
-However, after blocking for \fItenths\fR tenths of
-seconds, \fBERR\fP is returned if nothing has been typed.
-The value of \fItenths\fR
-must be a number between 1 and 255.
-Use \fBnocbreak\fR to leave half-delay
-mode.
+The \fB\%halfdelay\fP routine is used for half-delay mode,
+which is similar to \fB\%cbreak\fP mode in that characters typed by the
+user are immediately available to the program.
+However,
+after blocking for \fItenths\fP tenths of seconds,
+\fBERR\fP is returned if nothing has been typed.
+The value of \fItenths\fP must be a number between 1 and 255.
+Use \fB\%nocbreak\fP to leave half-delay mode.
 .\"
 .SS intrflush
-.PP
-If the \fBintrflush\fR option is enabled (\fIbf\fR is \fBTRUE\fR), and an
-interrupt key is pressed on the keyboard (interrupt, break, quit), all output in
-the tty driver queue will be flushed, giving the effect of faster response to
-the interrupt, but causing \fBcurses\fR to have the wrong idea of what is on
-the screen.
-Disabling the option (\fIbf\fR is \fBFALSE\fR) prevents the
-flush.
-The default for the option is inherited from the tty driver settings.
-The window argument is ignored.
+If the \fB\%intrflush\fP option is enabled
+.RI ( bf
+is
+.BR TRUE ),
+and an interrupt key is pressed on the keyboard
+(interrupt,
+break,
+quit),
+all output in the terminal driver queue is flushed,
+giving the effect of faster response to the interrupt,
+but causing
+.I curses
+to have the wrong idea of what is on the screen.
+Disabling the option
+.RI ( bf
+is
+.BR FALSE ),
+prevents the flush.
+The default for the option is inherited from the terminal driver
+settings.
+The
+.I win
+argument is ignored.
 .\"
 .SS keypad
-.PP
-The \fBkeypad\fR option enables the keypad of the user's terminal.
+The \fB\%keypad\fP option enables the keypad of the user's terminal.
 If
-enabled (\fIbf\fR is \fBTRUE\fR), the user can press a function key
-(such as an arrow key) and \fBwgetch\fR(3X) returns a single value
-representing the function key, as in \fBKEY_LEFT\fR.
+enabled
+.RI ( bf
+is
+.BR TRUE ),
+the user can press a function key
+(such as an arrow key)
+and \fB\%wgetch\fP(3X) returns a single value representing the function
+key,
+as in \fB\%KEY_LEFT\fP.
 If disabled
-(\fIbf\fR is \fBFALSE\fR), \fBcurses\fR does not treat function keys
-specially and the program has to interpret the escape sequences
-itself.
-If the keypad in the terminal can be turned on (made to
-transmit) and off (made to work locally), turning on this option
-causes the terminal keypad to be turned on when \fBwgetch\fR(3X) is
-called.
+(\fIbf\fP is \fBFALSE\fP),
+.I curses
+does not treat function keys specially and the program has to interpret
+the escape sequences itself.
+If the keypad in the terminal can be turned on
+(made to transmit)
+and off
+(made to work locally),
+turning on this option causes the terminal keypad to be turned on when
+\fB\%wgetch\fP(3X) is called.
 The default value for keypad is \fBFALSE\fP.
 .\"
 .SS meta
-.PP
-Initially, whether the terminal returns 7 or 8 significant bits on
-input depends on the control mode of the tty driver [see \fBtermios\fP(3)].
-To force 8 bits to be returned, invoke \fBmeta\fR(\fIwin\fR,
-\fBTRUE\fR); this is equivalent, under POSIX, to setting the CS8 flag
-on the terminal.
-To force 7 bits to be returned, invoke
-\fBmeta\fR(\fIwin\fR, \fBFALSE\fR); this is equivalent, under POSIX,
+Initially,
+whether the terminal returns 7 or 8 significant bits on input depends on
+the control mode of the terminal driver [see \fI\%termios\fP(3)].
+To force 8 bits to be returned,
+invoke
+\fBmeta\fP(\fIwin\fP, \fBTRUE\fP);
+this is equivalent,
+under POSIX,
+to setting the CS8 flag on the terminal.
+To force 7 bits to be returned,
+invoke
+\fBmeta\fP(\fIwin\fP, \fBFALSE\fP);
+this is equivalent,
+under POSIX,
 to setting the CS7 flag on the terminal.
 The window argument,
-\fIwin\fR, is always ignored.
-If the terminfo capabilities \fBsmm\fR
-(meta_on) and \fBrmm\fR (meta_off) are defined for the terminal,
-\fBsmm\fR is sent to the terminal when \fBmeta\fR(\fIwin\fR,
-\fBTRUE\fR) is called and \fBrmm\fR is sent when \fBmeta\fR(\fIwin\fR,
-\fBFALSE\fR) is called.
+.IR win ,
+is always ignored.
+If the terminfo capabilities
+\fBsmm\fP (meta_on) and
+\fBrmm\fP (meta_off) are defined for the terminal,
+\fBsmm\fP is sent to the terminal when
+\fBmeta\fP(\fIwin\fP, \fBTRUE\fP)
+is called and \fBrmm\fP is sent when
+\fBmeta\fP(\fIwin\fP, \fBFALSE\fP) is called.
 .\"
-.SS nl/nonl
-.PP
-The \fBnl\fR and \fBnonl\fR routines control whether the underlying display
-device translates the return key into newline on input.
+.SS "nl, nonl"
+The \fBnl\fP and \fBnonl\fP routines control whether the underlying
+display device translates the return key into newline on input.
 .\"
 .SS nodelay
-.PP
-The \fBnodelay\fR option causes \fBgetch\fR to be a non-blocking call.
-If no input is ready, \fBgetch\fR returns \fBERR\fR.
+The \fB\%nodelay\fP option causes \fB\%getch\fP to be a non-blocking
+call.
+If no input is ready,
+\fB\%getch\fP returns \fBERR\fP.
 If disabled
-(\fIbf\fR is \fBFALSE\fR), \fBgetch\fR waits until a key is pressed.
+.RI ( bf
+is
+.BR FALSE ),
+\fB\%getch\fP waits until a key is pressed.
 .SS notimeout
-.PP
-When interpreting an escape sequence, \fBwgetch\fR(3X) sets a timer
+When interpreting an escape sequence,
+\fB\%wgetch\fP(3X) sets a timer
 while waiting for the next character.
-If \fBnotimeout(\fR\fIwin\fR,
-\fBTRUE\fR) is called, then \fBwgetch\fR does not set a timer.
-The
-purpose of the timeout is to differentiate between sequences received
-from a function key and those typed by a user.
+If
+\fB\%notimeout(\fIwin\fR, \fBTRUE\fP)
+is called,
+then \fB\%wgetch\fP does not set a timer.
+The purpose of the timeout is to distinguish sequences produced by a
+function key from those typed by a user.
 .\"
-.SS raw/noraw
-.PP
-The \fBraw\fR and \fBnoraw\fR routines place the terminal into or out of raw
-mode.
-Raw mode is similar to \fBcbreak\fR mode, in that characters typed are
-immediately passed through to the user program.
-The differences are that in
-raw mode, the interrupt, quit, suspend, and flow control characters are all
-passed through uninterpreted, instead of generating a signal.
-The behavior of
-the BREAK key depends on other bits in the tty driver that are not set by
-\fBcurses\fR.
+.SS "raw, noraw"
+The \fBraw\fP and \fB\%noraw\fP routines place the terminal into or out
+of raw mode.
+Raw mode is similar to \fB\%cbreak\fP mode,
+in that characters typed are immediately passed through to the user
+program.
+The differences are that in raw mode,
+the interrupt,
+quit,
+suspend,
+and flow control characters are all
+passed through uninterpreted,
+instead of generating a signal.
+The behavior of the BREAK key depends on other bits in the terminal
+driver that are not set by
+.IR curses .
 .\"
-.SS qiflush/noqiflush
-.PP
-When the \fBnoqiflush\fR routine is used, normal flush of input and
-output queues associated with the \fBINTR\fR, \fBQUIT\fR and
-\fBSUSP\fR characters will not be done [see \fBtermios\fP(3)].
+.SS "qiflush, nqiflush"
+When the \fB\%noqiflush\fP routine is used,
+normal flush of input and output queues associated with the \fBINTR\fP,
+\fBQUIT\fP and \fBSUSP\fP characters will not be done
+[see \fB\%termios\fP(3)].
 When
-\fBqiflush\fR is called, the queues will be flushed when these control
-characters are read.
-You may want to call \fBnoqiflush\fR in a signal
-handler if you want output to continue as though the interrupt
-had not occurred, after the handler exits.
+\fB\%qiflush\fP is called,
+the queues will be flushed when these control characters are read.
+You may want to call \fB\%noqiflush\fP in a signal handler if you want
+output to continue as though the interrupt had not occurred,
+after the handler exits.
 .\"
-.SS timeout/wtimeout
-.PP
-The \fBtimeout\fR and \fBwtimeout\fR routines set blocking or
+.SS "timeout, wtimeout"
+The \fB\%timeout\fP and \fB\%wtimeout\fP routines set blocking or
 non-blocking read for a given window.
-If \fIdelay\fR is negative,
-blocking read is used (i.e., waits indefinitely for
-input).
-If \fIdelay\fR is zero, then non-blocking read is used
-(i.e., read returns \fBERR\fR if no input is waiting).
+If \fIdelay\fP is negative,
+a blocking read is used
+(i.e.,
+waits indefinitely for input).
+If \fIdelay\fP is zero,
+then a non-blocking read is used
+(i.e.,
+.I read
+returns \fBERR\fP if no input is waiting).
 If
-\fIdelay\fR is positive, then read blocks for \fIdelay\fR
-milliseconds, and returns \fBERR\fR if there is still no input.
-Hence, these routines provide the same functionality as \fBnodelay\fR,
+\fIdelay\fP is positive,
+then
+.I read
+blocks for \fIdelay\fP milliseconds,
+and returns \fBERR\fP if there is still no input.
+Hence,
+these routines provide the same functionality as \fB\%nodelay\fP,
 plus the additional capability of being able to block for only
-\fIdelay\fR milliseconds (where \fIdelay\fR is positive).
+\fIdelay\fP milliseconds
+(where \fIdelay\fP is positive).
 .\"
 .SS typeahead
-.PP
-The \fBcurses\fR library does \*(``line-breakout optimization\*(''
-by looking for typeahead periodically while updating the screen.
-If input is found, and it is coming from a tty,
+.I curses
+does \*(``line-breakout optimization\*('' by looking for typeahead
+periodically while updating the screen.
+If input is found,
+and it is coming from a terminal,
 the current update is postponed until
-\fBrefresh\fR(3X) or \fBdoupdate\fR is called again.
+\fB\%refresh\fP(3X) or \fB\%doupdate\fP is called again.
 This allows faster response to commands typed in advance.
-Normally, the input FILE
-pointer passed to \fBnewterm\fR, or \fBstdin\fR in the case that
-\fBinitscr\fR was used, will be used to do this typeahead checking.
-The \fBtypeahead\fR routine specifies that the file descriptor
-\fIfd\fR is to be used to check for typeahead instead.
-If \fIfd\fR is
-\-1, then no typeahead checking is done.
+Normally,
+the input
+.I FILE
+pointer passed to \fB\%newterm\fP,
+or \fBstdin\fP in the case that \fB\%initscr\fP was used,
+will be used to do this typeahead checking.
+The \fB\%typeahead\fP routine specifies that the file descriptor
+\fIfd\fP is to be used to check for typeahead instead.
+If \fIfd\fP is
+\-1,
+then no typeahead checking is done.
 .\"
 .SH RETURN VALUE
-All routines that return an integer return \fBERR\fR upon failure and \fBOK\fP
-(SVr4 specifies only \*(``an integer value other than \fBERR\fR\*('')
+All routines that return an integer return \fBERR\fP upon failure and
+\fBOK\fP
+(SVr4 specifies only \*(``an integer value other than \fBERR\fP\*('')
 upon successful completion,
 unless otherwise noted in the preceding routine descriptions.
 .PP
-X/Open does not define any error conditions.
+X/Open Curses does not specify any error conditions.
 In this implementation,
 functions with a window parameter will return an error if it is null.
-Any function will also return an error if the terminal was not initialized.
+Any function will also return an error if the terminal was not
+initialized.
 Also,
-.RS
+.RS 3
 .TP 5
-\fBhalfdelay\fP
+\fB\%halfdelay\fP
 returns an error
 if its parameter is outside the range 1..255.
 .RE
+.SH NOTES
+\fBecho\fP,
+\fB\%noecho\fP,
+\fB\%halfdelay\fP,
+\fB\%intrflush\fP,
+\fBmeta\fP,
+\fBnl\fP,
+\fBnonl\fP,
+\fB\%nodelay\fP,
+\fB\%notimeout\fP,
+\fB\%noqiflush\fP,
+\fB\%qiflush\fP,
+\fB\%timeout\fP,
+and
+\fB\%wtimeout\fP
+may be implemented as macros.
+.PP
+\fB\%noraw\fP and \fB\%nocbreak\fP follow historical practice in that
+they attempt to restore normal (\*(``cooked\*('') mode
+from raw and cbreak modes respectively.
+Mixing \fBraw\fP/\fB\%noraw\fP and \fB\%cbreak\fP/\fB\%nocbreak\fP calls
+leads to terminal driver control states that are hard to predict or
+understand;
+doing so is not recommended.
+.SH EXTENSIONS
+.I \%ncurses
+provides four \*(``is_\*('' functions that may be used to detect if the
+corresponding flags were set or reset.
+.PP
+.TS
+center;
+Lb Lb Lb
+L  L  L .
+Query	Set	Reset
+_
+is_cbreak	cbreak	nocbreak
+is_echo	echo	noecho
+is_nl	nl	nonl
+is_raw	raw	noraw
+.TE
+.PP
+In each case,
+the function returns
+.TP 4 \" "-1" + 2n
+1
+if the flag is set,
+.TP
+0
+if the flag is reset,
+or
+.TP
+\-1
+if the library is not initialized.
+.PP
+They were designed for
+\fB\%ncurses\fP(3X),
+and are not found in SVr4
+.IR curses ,
+4.4BSD
+.IR curses ,
+or any other previous
+.I curses
+implementation.
 .SH PORTABILITY
-These functions are described in the XSI Curses standard, Issue 4.
+Applications employing
+.I \%ncurses
+extensions should condition their use on the visibility of the
+.B \%NCURSES_VERSION
+preprocessor macro.
 .PP
-The ncurses library obeys the XPG4 standard and the historical practice of the
-AT&T curses implementations, in that the echo bit is cleared when curses
+Except as noted in section \*(``EXTENSIONS\*('' above,
+X/Open Curses, Issue 4, Version 2 describes these functions.
+.PP
+.I \%ncurses
+follows X/Open Curses
+and the historical practice of AT&T
+.I curses
+implementations,
+in that the echo bit is cleared when
+.I curses
 initializes the terminal state.
-BSD curses differed from this slightly; it
-left the echo bit on at initialization, but the BSD \fBraw\fR call turned it
-off as a side-effect.
-For best portability, set \fBecho \fPor \fBnoecho\fP explicitly
-just after initialization, even if your program remains in cooked mode.
+BSD
+.I curses
+differed from this slightly;
+it left the echo bit on at initialization,
+but the BSD \fBraw\fP call turned it off as a side effect.
+For best portability,
+set \fBecho\fP or \fB\%noecho\fP explicitly just after initialization,
+even if your program remains in cooked mode.
 .PP
-The XSI Curses standard is ambiguous on the question of whether \fBraw\fR
-should disable the CRLF translations controlled by \fBnl\fR and \fBnonl\fR.
-BSD curses did turn off these translations; AT&T curses (at least as late as
-SVr1) did not.
-We chose to do so, on the theory that a programmer requesting
-raw input wants a clean (ideally 8-bit clean) connection that the operating
-system will not alter.
+X/Open Curses is ambiguous regarding whether \fBraw\fP should disable
+the CR/LF translations controlled by \fBnl\fP and \fBnonl\fP.
+BSD
+.I curses
+did turn off these translations;
+AT&T
+.I curses
+(at least as late as SVr1)
+did not.
+.I \%ncurses
+does so,
+on the assumption that a programmer requesting raw input wants a clean
+(ideally,
+8-bit clean)
+connection that the operating system will not alter.
 .PP
-When \fBkeypad\fP is first enabled,
-ncurses loads the key-definitions for the current terminal description.
+When \fB\%keypad\fP is first enabled,
+.I \%ncurses
+loads the key definitions for the current terminal description.
 If the terminal description includes extended string capabilities,
-e.g., from using the \fB\-x\fP option of \fB@TIC@\fP,
-then ncurses also defines keys for the capabilities whose names
-begin with \*(``k\*(''.
-The corresponding keycodes are generated and (depending on previous
-loads of terminal descriptions) may differ from one execution of a
-program to the next.
-The generated keycodes are recognized by the \fBkeyname\fP function
+e.g.,
+from using the
+.B \-x
+option of \fB\%@TIC@\fP,
+then
+.I \%ncurses
+also defines keys for the capabilities whose names begin with
+\*(``k\*(''.
+The corresponding keycodes are generated and
+(depending on previous loads of terminal descriptions)
+may differ from one execution of a program to the next.
+The generated keycodes are recognized by the \fB\%keyname\fP(3X)
+function
 (which will then return a name beginning with \*(``k\*('' denoting the
-terminfo capability name rather than \*(``K\*('', used for curses key-names).
-On the other hand, an application can use \fBdefine_key\fP to establish
+terminfo capability name rather than \*(``K\*('',
+used for
+.I curses
+key names).
+On the other hand,
+an application can use \fB\%define_key\fP(3X) to establish
 a specific keycode for a given string.
 This makes it possible for an application to check for an extended
-capability's presence with \fBtigetstr\fP,
+capability's presence with \fB\%tigetstr\fP,
 and reassign the keycode to match its own needs.
 .PP
-Low-level applications can use \fBtigetstr\fP to obtain the definition
+Low-level applications can use \fB\%tigetstr\fP to obtain the definition
 of any particular string capability.
-Higher-level applications which use the curses \fBwgetch\fP
-and similar functions to return keycodes rely upon the order in which
-the strings are loaded.
+Higher-level applications which use the
+.I curses
+\fB\%wgetch\fP and similar functions to return keycodes rely upon the
+order in which the strings are loaded.
 If more than one key definition has the same string value,
-then \fBwgetch\fP can return only one keycode.
-Most curses implementations (including ncurses)
+then \fB\%wgetch\fP can return only one keycode.
+Most
+.I curses
+implementations
+(including
+.IR \%ncurses )
 load key definitions in the order
 defined by the array of string capability names.
 The last key to be loaded determines the keycode which will be returned.
-In ncurses, you may also have extended capabilities interpreted as
-key definitions.
+In
+.IR \%ncurses ,
+you may also have extended capabilities interpreted as key definitions.
 These are loaded after the predefined keys,
 and if a capability's value is the same as a previously-loaded
 key definition,
 the later definition is the one used.
-.SH NOTES
-Note that
-\fBecho\fR,
-\fBnoecho\fR,
-\fBhalfdelay\fR,
-\fBintrflush\fR,
-\fBmeta\fR,
-\fBnl\fR,
-\fBnonl\fR,
-\fBnodelay\fR,
-\fBnotimeout\fR,
-\fBnoqiflush\fR,
-\fBqiflush\fR,
-\fBtimeout\fR, and
-\fBwtimeout\fR may be macros.
-.PP
-The \fBnoraw\fR and \fBnocbreak\fR calls follow historical practice in that
-they attempt to restore to normal (\*(``cooked\*('') mode
-from raw and cbreak modes respectively.
-Mixing raw/noraw and cbreak/nocbreak calls leads to tty driver
-control states that are hard to predict or understand; it is not recommended.
+.SH HISTORY
+Formerly,
+.I \%ncurses
+used
+.B \%nl
+and
+.B \%nonl
+to control the conversion of newlines to carriage return/line feed
+on output as well as input.
+X/Open Curses documents the use of these functions only for input.
+This difference arose from converting the
+.I \%pcurses
+source (1986),
+which used
+\fI\%ioctl\fP(2) calls and the
+.I \%sgttyb
+structure,
+to
+.I \%termios
+(the POSIX terminal API).
+In the former,
+both input and output were controlled via a single option
+.BR \%CRMOD ,
+while the latter separates these features.
+Because that conversion interferes with output optimization,
+.I \%ncurses
+6.2 (2020) amended
+.B \%nl
+and
+.B \%nonl
+to eliminate their effect on output.
 .SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_getch\fR(3X),
-\fBcurs_initscr\fR(3X),
-\fBcurs_util\fR(3X),
-\fBdefine_key\fR(3X),
-\fBtermios\fR(3)
+\fB\%curses\fP(3X),
+\fB\%curs_getch\fP(3X),
+\fB\%curs_initscr\fP(3X),
+\fB\%curs_util\fP(3X),
+\fB\%define_key\fP(3X),
+\fB\%termios\fP(3)
diff --git a/contrib/ncurses/man/curs_ins_wch.3x b/contrib/ncurses/man/curs_ins_wch.3x
index 9b19a2825c41..90b03f64f4d1 100644
--- a/contrib/ncurses/man/curs_ins_wch.3x
+++ b/contrib/ncurses/man/curs_ins_wch.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2019,2020 Thomas E. Dickey                                     *
+.\" Copyright 2019-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 2002-2010,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,42 +27,89 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_ins_wch.3x,v 1.10 2020/10/18 00:22:21 tom Exp $
-.TH curs_ins_wch 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: curs_ins_wch.3x,v 1.30 2024/04/20 19:18:18 tom Exp $
+.TH curs_ins_wch 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
 .SH NAME
-\fBins_wch\fR,
-\fBmvins_wch\fR,
-\fBmvwins_wch\fR,
-\fBwins_wch\fR \- insert a complex character and rendition into a window
+\fB\%ins_wch\fP,
+\fB\%mvins_wch\fP,
+\fB\%mvwins_wch\fP,
+\fB\%wins_wch\fP \-
+insert a \fIcurses\fR complex character in a window
 .SH SYNOPSIS
-#include <curses.h>
-.sp
-\fBint ins_wch(const cchar_t *\fR\fIwch\fR\fB);\fR
-.br
-\fBint wins_wch(WINDOW *\fR\fIwin\fP\fB, const cchar_t *\fR\fIwch\fR\fB);\fR
-.sp
-\fBint mvins_wch(int \fR\fIy\fP\fB, int \fR\fIx\fP\fB, const cchar_t *\fR\fIwch\fR\fB);\fR
-.br
-\fBint mvwins_wch(WINDOW *\fR\fIwin\fP\fB, int \fR\fIy\fP\fB, int \fR\fIx\fP\fB, const cchar_t *\fR\fIwch\fR\fB);\fR
+.nf
+\fB#include <curses.h>\fP
+.PP
+\fBint ins_wch(const cchar_t *\fIwch\fP);
+\fBint wins_wch(WINDOW *\fIwin\fP, const cchar_t *\fIwch\fP);
+\fBint mvins_wch(int \fIy\fP, int \fIx\fP, const cchar_t *\fIwch\fP);
+\fBint mvwins_wch(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, const cchar_t *\fIwch\fP);
+.fi
 .SH DESCRIPTION
-These routines, insert the complex character \fIwch\fR with rendition
-before the character under the cursor.
-All characters to the right of the cursor are moved one space to the right,
-with the possibility of the rightmost character on the line being lost.
-The insertion operation does not change the cursor position.
-.SH RETURN VALUE
-If successful, these functions return \fBOK\fP.
-If not, they return \fBERR\fP.
+These functions insert the
+.I curses
+complex character
+.I wch
+at the cursor in the specified window
+.I win
+(or
+.BR \%stdscr ).
+The character previously at the cursor and any to its right move one
+cell to the right;
+the rightmost character on the line is discarded.
+The cursor does not advance.
+.SH "RETURN VALUE"
+These functions return \fBOK\fP on success and \fBERR\fP on failure.
+.PP
+Functions taking a
+.I \%WINDOW
+pointer argument fail if the pointer is
+.BR NULL .
+.PP
+Functions prefixed with \*(``mv\*('' first perform cursor movement and
+fail if the position
+.RI ( y ,
+.IR x )
+is outside the window boundaries.
+.SH NOTES
+A terminal's
+.B \%insert_character
+.RB ( ich1 )
+capability
+is not necessarily employed.
+.PP
+\fB\%ins_wch\fP,
+\fB\%mvins_wch\fP,
+and
+\fB\%mvwins_wch\fP
+may be implemented as macros.
+.SH PORTABILITY
+X/Open Curses,
+Issue 4 describes these functions.
+.PP
+SVr4 describes successful return values only as
+\*(``an integer value other than \fBERR\fP\*(''.
+.SH HISTORY
+SVr4 (1989) implemented these functions under the names
+.BR inswch ,
+.BR winswch ,
+.BR mvinswch ,
+and
+.BR mvwinswch .
+.SH "SEE ALSO"
+\fB\%curs_insch\fP(3X) describes comparable functions in the
+non-wide-character
+.I curses
+configuration.
 .PP
-Functions with a \*(``mv\*('' prefix first perform a cursor movement using
-\fBwmove\fP, and return an error if the position is outside the window,
-or if the window pointer is null.
-.SH ERRORS
-No errors are defined.
-.SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_insch\fR(3X).
+\fB\%curses\fP(3X),
+\fB\%terminfo\fP(5)
diff --git a/contrib/ncurses/man/curs_ins_wstr.3x b/contrib/ncurses/man/curs_ins_wstr.3x
index 76c44fb65cfd..4ebd3ace2c5a 100644
--- a/contrib/ncurses/man/curs_ins_wstr.3x
+++ b/contrib/ncurses/man/curs_ins_wstr.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2019,2020 Thomas E. Dickey                                     *
+.\" Copyright 2019-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 2002-2012,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,85 +27,102 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_ins_wstr.3x,v 1.11 2020/10/17 23:21:25 tom Exp $
-.TH curs_ins_wstr 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
-.na
-.hy 0
+.\" $Id: curs_ins_wstr.3x,v 1.38 2024/04/20 21:23:08 tom Exp $
+.TH curs_ins_wstr 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
+.de bP
+.ie n  .IP \(bu 4
+.el    .IP \(bu 2
+..
 .SH NAME
-\fBins_wstr\fR,
-\fBins_nwstr\fR,
-\fBwins_wstr\fR,
-\fBwins_nwstr\fR,
-\fBmvins_wstr\fR,
-\fBmvins_nwstr\fR,
-\fBmvwins_wstr\fR,
-\fBmvwins_nwstr\fR \- insert a wide-character string into a curses window
-.ad
-.hy
+\fB\%ins_wstr\fP,
+\fB\%ins_nwstr\fP,
+\fB\%wins_wstr\fP,
+\fB\%wins_nwstr\fP,
+\fB\%mvins_wstr\fP,
+\fB\%mvins_nwstr\fP,
+\fB\%mvwins_wstr\fP,
+\fB\%mvwins_nwstr\fP \-
+insert a wide-character string in a \fIcurses\fR window
 .SH SYNOPSIS
 .nf
-\fB#include <curses.h>\fR
-.sp
-\fBint ins_wstr(const wchar_t *\fR\fIwstr);\fR
-.br
-\fBint ins_nwstr(const wchar_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR
-.br
-\fBint wins_wstr(WINDOW *\fR\fIwin\fR\fB, const wchar_t *\fR\fIwstr\fR\fB);\fR
-.br
-\fBint wins_nwstr(WINDOW *\fR\fIwin\fR\fB, const wchar_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR
-.sp
-\fBint mvins_wstr(int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, const wchar_t *\fR\fIwstr\fR\fB);\fR
-.br
-\fBint mvins_nwstr(int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, const wchar_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR
-.br
-\fBint mvwins_wstr(WINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, const wchar_t *\fR\fIwstr\fR\fB);\fR
-.br
-\fBint mvwins_nwstr(WINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, const wchar_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR
+\fB#include <curses.h>
+.PP
+\fBint ins_wstr(const wchar_t *\fIwstr\fP);
+\fBint ins_nwstr(const wchar_t *\fIwstr\fP, int \fIn\fP);
+\fBint wins_wstr(WINDOW *\fIwin\fP, const wchar_t *\fIwstr\fP);
+\fBint wins_nwstr(WINDOW *\fIwin\fP, const wchar_t *\fIwstr\fP, int \fIn\fP);
+.PP
+\fBint mvins_wstr(int \fIy\fP, int \fIx\fP, const wchar_t *\fIwstr\fP);
+\fBint mvins_nwstr(int \fIy\fP, int \fIx\fP, const wchar_t *\fIwstr\fP, int \fIn\fP);
+\fBint mvwins_wstr(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, const wchar_t *\fIwstr\fP);
+\fBint mvwins_nwstr(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, const wchar_t *\fIwstr\fP, int \fIn\fP);
 .fi
 .SH DESCRIPTION
-These routines insert a \fBwchar_t\fR character string
+These routines insert a \fBwchar_t\fP character string
 (as many characters as will fit on the line)
-before the character under the cursor.
+before the character under the cursor,
+as if calling \fBwins_wch\fP(3X).
 All characters to the right of the cursor are shifted right,
 with the possibility of the rightmost characters on the line being lost.
 No wrapping is performed.
+.PP
 The cursor position does not change
-(after moving to \fIy\fR, \fIx\fR, if specified).
-The four routines with \fIn\fR as the last argument
-insert a leading substring of at most \fIn\fR \fBwchar_t\fR characters.
-If \fIn\fR is less than 1, the entire string is inserted.
+(after moving to \fIy\fP, \fIx\fP, if specified).
 .PP
-If a character in \fIwstr\fR is a tab, newline, carriage return or
-backspace, the cursor is moved appropriately within the window.
-A newline also does a \fBclrtoeol\fR before moving.
-Tabs are considered to be at every eighth column.
-If a character in \fIwstr\fR is another control character,
-it is drawn in the \fB^\fR\fIX\fR notation.
-Calling \fBwin_wch\fR after adding a control character
-(and moving to it, if necessary)
-does not return the control character,
-but instead returns a character in the ^-representation
-of the control character.
+The functions with \fIn\fP as the last argument
+insert a leading substring of at most \fIn\fP \fBwchar_t\fP characters.
+If \fIn\fP is less than zero, the entire string is inserted
+(stopping on a L'\e0' character).
+.PP
+Special characters are handled as in \fBwadd_wch\fP(3X).
+.SH RETURN VALUE
+All functions return the integer \fBERR\fP upon failure and \fBOK\fP on success.
+.PP
+X/Open Curses does not specify any error conditions.
+This implementation returns an error
+.bP
+if the \fIwin\fP parameter is null or
+.bP
+if the \fIwstr\fP parameter is null or
+.bP
+if the \fBwins_wch\fP function returns an error.
+.PP
+Functions prefixed with \*(``mv\*('' first perform cursor movement and
+fail if the position
+.RI ( y ,
+.IR x )
+is outside the window boundaries.
 .SH NOTES
-Note that all but wins_nwstr may be macros.
+All but \fBwins_nwstr\fP may be macros.
 .PP
-If the first character in the string is a nonspacing character, these
+If the first character in the string is a non-spacing character, these
 functions will fail.
-XSI does not define what will happen if a nonspacing character follows
-a control character.
-.SH RETURN VALUE
-Upon successful completion, these functions return \fBOK\fP.
-Otherwise, they return \fBERR\fP.
+X/Open Curses does not define what will happen
+if a non-spacing character follows a control character.
+.SH PORTABILITY
+These functions are described in X/Open Curses, Issue 4,
+which adds \fI\%const\fP qualifiers to the arguments.
 .PP
-Functions with a \*(``mv\*('' prefix first perform a cursor movement using
-\fBwmove\fP, and return an error if the position is outside the window,
-or if the window pointer is null.
+X/Open states that the entire string is inserted if \fIn\fP is less than 1.
+This is probably an error,
+because it is inconsistent with other functions,
+and differs from the X/Open implementation on Solaris.
 .SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_insstr\fR(3X),
-\fBcurs_in_wch\fR(3X),
-\fBcurs_ins_wch\fR(3X).
+\fB\%curs_insstr\fP(3X) describes comparable functions of the
+.I \%ncurses
+library in its non-wide-character configuration.
+.PP
+\fB\%curses\fP(3X),
+\fB\%curs_ins_wch\fP(3X),
+\fB\%curs_in_wch\fP(3X)
diff --git a/contrib/ncurses/man/curs_insch.3x b/contrib/ncurses/man/curs_insch.3x
index 1b4e3ee4c52e..baf2f6cc1bbb 100644
--- a/contrib/ncurses/man/curs_insch.3x
+++ b/contrib/ncurses/man/curs_insch.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,53 +27,89 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_insch.3x,v 1.19 2020/10/18 00:21:39 tom Exp $
-.TH curs_insch 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: curs_insch.3x,v 1.40 2024/04/20 19:03:47 tom Exp $
+.TH curs_insch 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
 .SH NAME
-\fBinsch\fR,
-\fBwinsch\fR,
-\fBmvinsch\fR,
-\fBmvwinsch\fR \- insert a character before cursor in a \fBcurses\fR window
+\fB\%insch\fP,
+\fB\%winsch\fP,
+\fB\%mvinsch\fP,
+\fB\%mvwinsch\fP \-
+insert a \fIcurses\fP character in a window
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBint insch(chtype \fP\fIch\fP\fB);\fR
-.br
-\fBint winsch(WINDOW *\fP\fIwin\fP\fB, chtype \fP\fIch\fP\fB);\fR
-.sp
-\fBint mvinsch(int \fP\fIy\fP\fB, int \fP\fIx\fP\fB, chtype \fP\fIch\fP\fB);\fR
-.br
-\fBint mvwinsch(WINDOW *\fP\fIwin\fP\fB, int \fP\fIy\fP\fB, int \fP\fIx\fP\fB, chtype \fP\fIch\fP\fB);\fR
-.br
+.nf
+\fB#include <curses.h>\fP
+.PP
+\fBint insch(chtype \fIch\fP);
+\fBint winsch(WINDOW *\fIwin\fP, chtype \fIch\fP);
+\fBint mvinsch(int \fIy\fP, int \fIx\fP, chtype \fIch\fP);
+\fBint mvwinsch(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, chtype \fIch\fP);
+.fi
 .SH DESCRIPTION
-These routines insert the character \fIch\fR before the character under the
-cursor.
-All characters to the right of the cursor are moved one space to the
-right, with the possibility of the rightmost character on the line being lost.
-The insertion operation does not change the cursor position.
-.SH RETURN VALUE
-All routines that return an integer return \fBERR\fR upon failure and \fBOK\fP
-(SVr4 specifies only "an integer value other than \fBERR\fR")
-upon successful completion,
-unless otherwise noted in the preceding routine descriptions.
+These functions insert the
+.I curses
+character
+.I ch
+at the cursor in the specified window
+.I win
+(or
+.BR \%stdscr ).
+The character previously at the cursor and any to its right move one
+cell to the right;
+the rightmost character on the line is discarded.
+The cursor does not advance.
+.SH "RETURN VALUE"
+These functions return
+.B OK
+on success and
+.B ERR
+on failure.
+.PP
+Functions taking a
+.I \%WINDOW
+pointer argument fail if the pointer is
+.BR NULL .
 .PP
-Functions with a \*(``mv\*('' prefix first perform a cursor movement using
-\fBwmove\fP, and return an error if the position is outside the window,
-or if the window pointer is null.
+Functions prefixed with \*(``mv\*('' first perform cursor movement and
+fail if the position
+.RI ( y ,
+.IR x )
+is outside the window boundaries.
 .SH NOTES
-These routines do not necessarily imply use of a hardware insert character
-feature.
+.BR \%insch ,
+.BR \%mvinsch ,
+and
+.B \%mvwinsch
+may be implemented as macros.
 .PP
-Note that \fBinsch\fR, \fBmvinsch\fR, and \fBmvwinsch\fR may be macros.
+A terminal's
+.B \%insert_character
+.RB ( ich1 )
+capability
+is not necessarily employed.
 .SH PORTABILITY
-These functions are described in the XSI Curses standard, Issue 4.
-.SH SEE ALSO
-\fBcurses\fR(3X).
+X/Open Curses,
+Issue 4 describes these functions.
+.PP
+SVr4
+.I curses
+describes a successful return value only as
+\*(``an integer value other than
+.BR ERR \*(''.
+.SH "SEE ALSO"
+\fB\%curs_ins_wch\fP(3X) describes comparable functions in the
+wide-character
+.I curses
+configuration.
 .PP
-Comparable functions in the wide-character (ncursesw) library are
-described in
-\fBcurs_ins_wch\fR(3X).
+\fB\%curses\fP(3X),
+\fB\%terminfo\fP(5)
diff --git a/contrib/ncurses/man/curs_insstr.3x b/contrib/ncurses/man/curs_insstr.3x
index 4d5f123e928b..888d4250091f 100644
--- a/contrib/ncurses/man/curs_insstr.3x
+++ b/contrib/ncurses/man/curs_insstr.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2019,2020 Thomas E. Dickey                                     *
+.\" Copyright 2019-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,79 +27,98 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_insstr.3x,v 1.26 2020/10/18 00:20:36 tom Exp $
-.TH curs_insstr 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: curs_insstr.3x,v 1.51 2024/04/20 21:20:07 tom Exp $
+.TH curs_insstr 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
+.de bP
+.ie n  .IP \(bu 4
+.el    .IP \(bu 2
+..
 .SH NAME
-\fBinsstr\fR,
-\fBinsnstr\fR,
-\fBwinsstr\fR,
-\fBwinsnstr\fR,
-\fBmvinsstr\fR,
-\fBmvinsnstr\fR,
-\fBmvwinsstr\fR,
-\fBmvwinsnstr\fR \- insert string before cursor in a \fBcurses\fR window
+\fB\%insstr\fP,
+\fB\%insnstr\fP,
+\fB\%winsstr\fP,
+\fB\%winsnstr\fP,
+\fB\%mvinsstr\fP,
+\fB\%mvinsnstr\fP,
+\fB\%mvwinsstr\fP,
+\fB\%mvwinsnstr\fP \-
+insert a string in a \fIcurses\fR window
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.br
-\fBint insstr(const char *\fP\fIstr\fP\fB);\fR
-.br
-\fBint insnstr(const char *\fP\fIstr\fP\fB, int \fP\fIn\fP\fB);\fR
-.br
-\fBint winsstr(WINDOW *\fP\fIwin\fP\fB, const char *\fP\fIstr\fP\fB);\fR
-.br
-\fBint winsnstr(WINDOW *\fP\fIwin\fP\fB, const char *\fP\fIstr\fP\fB, int \fP\fIn\fP\fB);\fR
-.sp
-\fBint mvinsstr(int \fP\fIy\fP\fB, int \fP\fIx\fP\fB, const char *\fP\fIstr\fP\fB);\fR
-.br
-\fBint mvinsnstr(int \fP\fIy\fP\fB, int \fP\fIx\fP\fB, const char *\fP\fIstr\fP\fB, int \fP\fIn\fP\fB);\fR
-.br
-\fBint mvwinsstr(WINDOW *\fP\fIwin\fP\fB, int \fP\fIy\fP\fB, int \fP\fIx\fP\fB, const char *\fP\fIstr\fP\fB);\fR
-.br
-\fBint mvwinsnstr(WINDOW *\fP\fIwin\fP\fB, int \fP\fIy\fP\fB, int \fP\fIx\fP\fB, const char *\fP\fIstr\fP\fB, int \fP\fIn\fP\fB);\fR
-.br
+.nf
+\fB#include <curses.h>
+\fBint insstr(const char *\fIstr\fP);
+\fBint insnstr(const char *\fIstr\fP, int \fIn\fP);
+\fBint winsstr(WINDOW *\fIwin\fP, const char *\fIstr\fP);
+\fBint winsnstr(WINDOW *\fIwin\fP, const char *\fIstr\fP, int \fIn\fP);
+.PP
+\fBint mvinsstr(int \fIy\fP, int \fIx\fP, const char *\fIstr\fP);
+\fBint mvinsnstr(int \fIy\fP, int \fIx\fP, const char *\fIstr\fP, int \fIn\fP);
+\fBint mvwinsstr(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, const char *\fIstr\fP);
+\fBint mvwinsnstr(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, const char *\fIstr\fP, int \fIn\fP);
+.fi
 .SH DESCRIPTION
 These routines insert a character string
 (as many characters as will fit on the line)
-before the character under the cursor.
-All characters to the right of the cursor are shifted right
+before the character under the cursor,
+as if calling \fBwinsch\fP(3X).
+All characters to the right of the cursor are shifted right,
 with the possibility of the rightmost characters on the line being lost.
+No wrapping is performed.
+.PP
 The cursor position does not change
-(after moving to \fIy\fR, \fIx\fR, if specified).
-The functions with \fIn\fR as the last argument
-insert a leading substring of at most \fIn\fR characters.
-If \fIn\fR<=0, then the entire string is inserted.
+(after moving to \fIy\fP, \fIx\fP, if specified).
+.PP
+The functions with \fIn\fP as the last argument
+insert a leading substring of at most \fIn\fP characters.
+If \fIn\fP is less than zero, the entire string is inserted
+(stopping on a NUL character).
 .PP
-Special characters are handled as in \fBaddch\fP.
+Special characters are handled as in \fBwaddch\fP(3X).
 .SH RETURN VALUE
-All routines that return an integer return \fBERR\fR upon failure and \fBOK\fP
-(SVr4 specifies only "an integer value other than \fBERR\fR")
-upon successful completion,
-unless otherwise noted in the preceding routine descriptions.
+All functions return the integer \fBERR\fP upon failure and \fBOK\fP on success.
 .PP
-X/Open defines no error conditions.
-In this implementation,
-if the window parameter is null or the str parameter is null,
-an error is returned.
+X/Open Curses does not specify any error conditions.
+This implementation returns an error
+.bP
+if the \fIwin\fP parameter is null or
+.bP
+if the \fIstr\fP parameter is null or
+.bP
+the \fBwinsch\fP(3X) function returns an error.
 .PP
-Functions with a \*(``mv\*('' prefix first perform a cursor movement using
-\fBwmove\fP, and return an error if the position is outside the window,
-or if the window pointer is null.
+Functions prefixed with \*(``mv\*('' first perform cursor movement and
+fail if the position
+.RI ( y ,
+.IR x )
+is outside the window boundaries.
 .SH NOTES
-Note that all but \fBwinsnstr\fR may be macros.
+All but \fBwinsnstr\fP may be macros.
 .SH PORTABILITY
-These functions are described in the XSI Curses standard, Issue 4, which adds
-const qualifiers to the arguments.
-.LP
-The Single Unix Specification, Version 2 states that 
+These functions are described in X/Open Curses, Issue 4,
+which adds \fI\%const\fP qualifiers to the arguments.
+.PP
+The Single Unix Specification, Version 2 states that
 \fBinsnstr\fP and \fBwinsnstr\fP perform wrapping.
 This is probably an error, since it makes this group of functions inconsistent.
 Also, no implementation of curses documents this inconsistency.
+.PP
+X/Open states that the entire string is inserted if \fIn\fP is less than 1.
+This is probably an error,
+because it is inconsistent with other functions,
+and differs from the SVr4 and X/Open implementations on Solaris.
 .SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_util\fR(3X),
-\fBcurs_clear\fR(3X),
-\fBcurs_inch\fR(3X).
+\fB\%curses\fP(3X),
+\fB\%curs_inch\fP(3X),
+\fB\%curs_ins_wstr\fP(3X),
+\fB\%curs_util\fP(3X)
diff --git a/contrib/ncurses/man/curs_instr.3x b/contrib/ncurses/man/curs_instr.3x
index 7cc4b4bc1a1c..5b6e4b760301 100644
--- a/contrib/ncurses/man/curs_instr.3x
+++ b/contrib/ncurses/man/curs_instr.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,73 +27,104 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_instr.3x,v 1.22 2020/10/18 00:18:27 tom Exp $
-.TH curs_instr 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: curs_instr.3x,v 1.51 2024/04/20 21:24:19 tom Exp $
+.TH curs_instr 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
 .SH NAME
-\fBinstr\fR,
-\fBinnstr\fR,
-\fBwinstr\fR,
-\fBwinnstr\fR,
-\fBmvinstr\fR,
-\fBmvinnstr\fR,
-\fBmvwinstr\fR,
-\fBmvwinnstr\fR \- get a string of characters from a \fBcurses\fR window
+\fB\%instr\fP,
+\fB\%innstr\fP,
+\fB\%winstr\fP,
+\fB\%winnstr\fP,
+\fB\%mvinstr\fP,
+\fB\%mvinnstr\fP,
+\fB\%mvwinstr\fP,
+\fB\%mvwinnstr\fP \-
+get a string from a \fIcurses\fR window
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBint instr(char *\fP\fIstr\fP\fB);\fR
-.br
-\fBint innstr(char *\fP\fIstr\fP\fB, int \fP\fIn\fP\fB);\fR
-.br
-\fBint winstr(WINDOW *\fP\fIwin\fP\fB, char *\fP\fIstr\fP\fB);\fR
-.br
-\fBint winnstr(WINDOW *\fP\fIwin\fP\fB, char *\fP\fIstr\fP\fB, int \fP\fIn\fP\fB);\fR
-.sp
-\fBint mvinstr(int \fP\fIy\fP\fB, int \fP\fIx\fP\fB, char *\fP\fIstr\fP\fB);\fR
-.br
-\fBint mvinnstr(int \fP\fIy\fP\fB, int \fP\fIx\fP\fB, char *\fP\fIstr\fP\fB, int \fP\fIn\fP\fB);\fR
-.br
-\fBint mvwinstr(WINDOW *\fP\fIwin\fP\fB, int \fP\fIy\fP\fB, int \fP\fIx\fP\fB, char *\fP\fIstr\fP\fB);\fR
-.br
-\fBint mvwinnstr(WINDOW *\fP\fIwin\fP\fB, int \fP\fIy\fP\fB, int \fP\fIx\fP\fB, char *\fP\fIstr\fP\fB, int \fP\fIn\fP\fB);\fR
-.br
+.nf
+\fB#include <curses.h>
+.PP
+\fBint instr(char *\fIstr\fP);
+\fBint innstr(char *\fIstr\fP, int \fIn\fP);
+\fBint winstr(WINDOW *\fIwin\fP, char *\fIstr\fP);
+\fBint winnstr(WINDOW *\fIwin\fP, char *\fIstr\fP, int \fIn\fP);
+.PP
+\fBint mvinstr(int \fIy\fP, int \fIx\fP, char *\fIstr\fP);
+\fBint mvinnstr(int \fIy\fP, int \fIx\fP, char *\fIstr\fP, int \fIn\fP);
+\fBint mvwinstr(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, char *\fIstr\fP);
+\fBint mvwinnstr(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, char *\fIstr\fP, int \fIn\fP);
+.fi
 .SH DESCRIPTION
-These routines return a string of characters in \fIstr\fR, extracted starting
-at the current cursor position in the named window.
+These routines return a string of characters in \fIstr\fP,
+starting at the current cursor position in the named window.
 Attributes are stripped from the characters.
-The four
-functions with \fIn\fR as the last argument return a leading substring at most
-\fIn\fR characters long (exclusive of the trailing NUL).
+.PP
+The four functions with \fIn\fP as the last argument return
+a leading substring at most \fIn\fP characters long
+(exclusive of the trailing NUL).
+Transfer stops at the end of the current line, or when \fIn\fP characters have
+been stored at the location referenced by \fIstr\fP.
 .SH RETURN VALUE
-All of the functions return \fBERR\fR upon failure,
+All of the functions return \fBERR\fP upon failure,
 or the number of characters actually read into the string.
 .PP
 X/Open Curses defines no error conditions.
-In this implementation:
+This implementation returns an error
 .bP
-If the \fIwin\fP parameter is null, an error is returned,
+if the \fIwin\fP parameter is null or
 .bP
-If the \fIchstr\fP parameter is null, an error is returned,
+if the \fIchstr\fP parameter is null.
 .PP
-Functions with a \*(``mv\*('' prefix first perform a cursor movement using
-\fBwmove\fP, and return an error if the position is outside the window,
-or if the window pointer is null.
+Functions prefixed with \*(``mv\*('' first perform cursor movement and
+fail if the position
+.RI ( y ,
+.IR x )
+is outside the window boundaries.
 .SH NOTES
-Note that all routines except \fBwinnstr\fR may be macros.
+All routines except \fBwinnstr\fP may be macros.
+.PP
+Reading a line that overflows the array pointed to by
+\fIstr\fP
+with
+\fBinstr\fP,
+\fBmvinstr\fP,
+\fBmvwinstr\fP
+or
+\fBwinstr\fP
+causes undefined results.
+Therefore, the use of
+\fBinnstr\fP,
+\fBmvinnstr\fP,
+\fBmvwinnstr\fP, or
+\fBwinnstr\fP
+is recommended.
 .SH PORTABILITY
 SVr4 does not
 document whether a length limit includes or excludes the trailing NUL.
 .PP
-The ncurses library extends the XSI description by allowing a negative
-value for \fIn\fR.
+The \fI\%ncurses\fP library extends the X/Open Curses description by allowing a
+negative value for \fIn\fP.
 In this case, the functions return the string ending at the right margin.
 .SH SEE ALSO
-\fBcurses\fR(3X).
+\fB\%curs_ins_wstr\fP(3X) describes comparable functions of the
+.I \%ncurses
+library in its wide-character configuration
+.RI ( \%ncursesw ).
+.PP
+\fB\%curses\fP(3X),
+\fB\%curs_inch\fP(3X),
+\fB\%curs_inchstr\fP(3X)
diff --git a/contrib/ncurses/man/curs_inwstr.3x b/contrib/ncurses/man/curs_inwstr.3x
index b3899c4b94f2..eec361d77af9 100644
--- a/contrib/ncurses/man/curs_inwstr.3x
+++ b/contrib/ncurses/man/curs_inwstr.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 2002-2012,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,80 +27,115 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_inwstr.3x,v 1.14 2020/10/17 23:22:11 tom Exp $
-.TH curs_inwstr 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: curs_inwstr.3x,v 1.41 2024/04/20 21:20:07 tom Exp $
+.TH curs_inwstr 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.de bP
+.ie n  .IP \(bu 4
+.el    .IP \(bu 2
+..
 .SH NAME
-\fBinwstr\fR,
-\fBinnwstr\fR,
-\fBwinwstr\fR,
-\fBwinnwstr\fR,
-\fBmvinwstr\fR,
-\fBmvinnwstr\fR,
-\fBmvwinwstr\fR,
-\fBmvwinnwstr\fR \- get a string of \fBwchar_t\fR characters from a curses window
+\fB\%inwstr\fP,
+\fB\%innwstr\fP,
+\fB\%winwstr\fP,
+\fB\%winnwstr\fP,
+\fB\%mvinwstr\fP,
+\fB\%mvinnwstr\fP,
+\fB\%mvwinwstr\fP,
+\fB\%mvwinnwstr\fP \-
+get a wide-character string from a \fIcurses\fR window
 .SH SYNOPSIS
 .nf
-\fB#include <curses.h> \fR
-.sp
-\fBint inwstr(\fR\fBwchar_t *\fR\fIwstr\fR\fB);\fR
-.br
-\fBint innwstr(\fR\fBwchar_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR
-.br
-\fBint winwstr(\fR\fBWINDOW *\fR\fIwin\fR\fB, wchar_t *\fR\fIwstr\fR\fB);\fR
-.br
-\fBint winnwstr(\fR\fBWINDOW *\fR\fIwin\fR\fB, wchar_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR
-.sp
-\fBint mvinwstr(\fR\fBint \fR\fIy\fR\fB, int \fR\fIx\fR\fB, wchar_t *\fR\fIwstr\fR\fB);\fR
-.br
-\fBint mvinnwstr(\fR\fBint \fR\fIy\fR\fB, int \fR\fIx\fR\fB, wchar_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR
-.br
-\fBint mvwinwstr(\fR\fBWINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, wchar_t *\fR\fIwstr\fR\fB);\fR
-.br
-\fBint mvwinnwstr(\fR\fBWINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, wchar_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR
+\fB#include <curses.h>
+.PP
+\fBint inwstr(wchar_t *\fIwstr\fP);
+\fBint innwstr(wchar_t *\fIwstr\fP, int \fIn\fP);
+\fBint winwstr(WINDOW *\fIwin\fP, wchar_t *\fIwstr\fP);
+\fBint winnwstr(WINDOW *\fIwin\fP, wchar_t *\fIwstr\fP, int \fIn\fP);
+.PP
+\fBint mvinwstr(int \fIy\fP, int \fIx\fP, wchar_t *\fIwstr\fP);
+\fBint mvinnwstr(int \fIy\fP, int \fIx\fP, wchar_t *\fIwstr\fP, int \fIn\fP);
+\fBint mvwinwstr(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, wchar_t *\fIwstr\fP);
+\fBint mvwinnwstr(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, wchar_t *\fIwstr\fP, int \fIn\fP);
 .fi
 .SH DESCRIPTION
+These routines return a string of \fBwchar_t\fP wide characters in \fIwstr\fP,
+starting at the current cursor position in the named window.
 .PP
-These routines return a string of \fBwchar_t\fR wide characters in \fIwstr\fR,
-extracted starting at the current cursor position in the named window.
-.PP
-The four functions with \fIn\fR as the last argument return
-a leading substring at most \fIn\fR characters long
+The four functions with \fIn\fP as the last argument return
+a leading substring at most \fIn\fP characters long
 (exclusive of the trailing NUL).
-Transfer stops at the end of the current line, or when \fIn\fR characters have
-been stored at the location referenced by \fIwstr\fR.
+Transfer stops at the end of the current line, or when \fIn\fP characters have
+been stored at the location referenced by \fIwstr\fP.
 .PP
-If the size \fIn\fR is not large enough to store a complete complex character,
+If the size \fIn\fP is not large enough to store a complete complex character,
 an error is generated.
-.SH NOTES
-.PP
-All routines except
-\fBwinnwstr\fR
-may be macros.
-.PP
-Each cell in the window holds a complex character (i.e., base-
-and combining-characters) together with attributes and color.
-These functions store only the wide characters,
-ignoring attributes and color.
-Use \fBin_wchstr\fP to return the complex characters from a window.
 .SH RETURN VALUE
 All routines return
-\fBERR\fR
+\fBERR\fP
 upon failure.
 Upon
-successful completion, the *\fBinwstr\fR
+successful completion, the *\fBinwstr\fP
 routines return
-\fBOK\fR, and the *\fBinnwstr\fR
+\fBOK\fP, and the *\fBinnwstr\fP
 routines return the
 number of characters read into the string.
 .PP
-Functions with a \*(``mv\*('' prefix first perform a cursor movement using
-\fBwmove\fP, and return an error if the position is outside the window,
-or if the window pointer is null.
+X/Open defines no error conditions.
+This implementation returns an error
+.bP
+if the \fIwin\fP parameter is null or
+.bP
+if the \fIwstr\fP parameter is null, or
+.bP
+if no characters could be read.
+.PP
+Functions prefixed with \*(``mv\*('' first perform cursor movement and
+fail if the position
+.RI ( y ,
+.IR x )
+is outside the window boundaries.
+.SH NOTES
+All routines except
+\fBwinnwstr\fP
+may be macros.
+.PP
+Each cell in the window holds a complex character
+(a spacing character and zero or more non-spacing characters)
+together with attributes and color.
+These functions store only the wide characters,
+ignoring attributes and color.
+Use \fBin_wchstr\fP to return the complex characters from a window.
+.PP
+Reading a line that overflows the array pointed to by
+\fIwstr\fP
+with
+\fBinwstr\fP,
+\fBmvinwstr\fP,
+\fBmvwinwstr\fP
+or
+\fBwinwstr\fP
+causes undefined results.
+Therefore, the use of
+\fBinnwstr\fP,
+\fBmvinnwstr\fP,
+\fBmvwinnwstr\fP, or
+\fBwinnwstr\fP
+is recommended.
+.SH PORTABILITY
+These functions are described in X/Open Curses, Issue 4.
 .SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_instr\fR(3X),
-\fBcurs_in_wchstr\fR(3X)
+\fB\%curses\fP(3X),
+\fB\%curs_inch\fP(3X),
+\fB\%curs_inchstr\fP(3X),
+\fB\%curs_instr\fP(3X),
+\fB\%curs_in_wchstr\fP(3X)
diff --git a/contrib/ncurses/man/curs_kernel.3x b/contrib/ncurses/man/curs_kernel.3x
index a4e6c808b08e..e85c132768a3 100644
--- a/contrib/ncurses/man/curs_kernel.3x
+++ b/contrib/ncurses/man/curs_kernel.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,129 +27,123 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_kernel.3x,v 1.29 2020/10/17 23:22:35 tom Exp $
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: curs_kernel.3x,v 1.61 2024/04/20 21:24:19 tom Exp $
+.TH curs_kernel 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.TH curs_kernel 3X ""
-.na
-.hy 0
 .SH NAME
-\fBdef_prog_mode\fR,
-\fBdef_shell_mode\fR,
-\fBreset_prog_mode\fR,
-\fBreset_shell_mode\fR,
-\fBresetty\fR,
-\fBsavetty\fR,
-\fBgetsyx\fR,
-\fBsetsyx\fR,
-\fBripoffline\fR,
-\fBcurs_set\fR,
-\fBnapms\fR \- low-level \fBcurses\fR routines
-.ad
-.hy
+\fB\%def_prog_mode\fP,
+\fB\%def_shell_mode\fP,
+\fB\%reset_prog_mode\fP,
+\fB\%reset_shell_mode\fP,
+\fB\%resetty\fP,
+\fB\%savetty\fP,
+\fB\%getsyx\fP,
+\fB\%setsyx\fP,
+\fB\%ripoffline\fP,
+\fB\%curs_set\fP,
+\fB\%napms\fP \-
+low-level \fIcurses\fR routines
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBint def_prog_mode(void);\fR
-.br
-\fBint def_shell_mode(void);\fR
-.sp
-\fBint reset_prog_mode(void);\fR
-.br
-\fBint reset_shell_mode(void);\fR
-.sp
-\fBint resetty(void);\fR
-.br
-\fBint savetty(void);\fR
-.sp
-\fBvoid getsyx(int \fP\fIy\fP\fB, int \fP\fIx\fP\fB);\fR
-.br
-\fBvoid setsyx(int \fP\fIy\fP\fB, int \fP\fIx\fP\fB);\fR
-.sp
-\fBint ripoffline(int \fP\fIline\fP\fB, int (*\fP\fIinit\fP\fB)(WINDOW *, int));\fR
-.br
-\fBint curs_set(int \fP\fIvisibility\fP\fB);\fR
-.br
-\fBint napms(int \fP\fIms\fP\fB);\fR
-.br
+.nf
+\fB#include <curses.h>
+.PP
+\fBint def_prog_mode(void);
+\fBint def_shell_mode(void);
+.PP
+\fBint reset_prog_mode(void);
+\fBint reset_shell_mode(void);
+.PP
+\fBint resetty(void);
+\fBint savetty(void);
+.PP
+\fBvoid getsyx(int \fIy\fP, int \fIx\fP);
+\fBvoid setsyx(int \fIy\fP, int \fIx\fP);
+.PP
+\fBint ripoffline(int \fIline\fP, int (*\fIinit\fP)(WINDOW *, int));
+\fBint curs_set(int \fIvisibility\fP);
+\fBint napms(int \fIms\fP);
+.fi
 .SH DESCRIPTION
 The following routines give low-level access
-to various \fBcurses\fR capabilities.
+to various \fBcurses\fP capabilities.
 These routines typically are used inside library routines.
-.SS def_prog_mode, def_shell_mode
-.PP
-The \fBdef_prog_mode\fR and \fBdef_shell_mode\fR routines save the
-current terminal modes as the \*(``program\*('' (in \fBcurses\fR) or \*(``shell\*(''
-(not in \fBcurses\fR) state for use by the \fBreset_prog_mode\fR and
-\fBreset_shell_mode\fR routines.
-This is done automatically by \fBinitscr\fR.
+.SS "def_prog_mode, def_shell_mode"
+The \fBdef_prog_mode\fP and \fBdef_shell_mode\fP routines save the
+current terminal modes as the \*(``program\*(''
+(in \fBcurses\fP) or \*(``shell\*(''
+(not in \fBcurses\fP) state for use by the \fBreset_prog_mode\fP and
+\fBreset_shell_mode\fP routines.
+This is done automatically by \fBinitscr\fP.
 There is one such save area for each screen context
-allocated by \fBnewterm\fR.
-.SS reset_prog_mode, reset_shell_mode
-.PP
-The \fBreset_prog_mode\fR and \fBreset_shell_mode\fR routines restore
-the terminal to \*(``program\*('' (in \fBcurses\fR) or \*(``shell\*('' (out of
-\fBcurses\fR) state.
-These are done automatically by \fBendwin\fR(3X) and,
-after an \fBendwin\fR, by \fBdoupdate\fR,
+allocated by \fBnewterm\fP.
+.SS "reset_prog_mode, reset_shell_mode"
+The \fBreset_prog_mode\fP and \fBreset_shell_mode\fP routines restore
+the terminal to \*(``program\*('' (in \fBcurses\fP) or \*(``shell\*('' (out of
+\fBcurses\fP) state.
+These are done automatically by \fBendwin\fP(3X) and,
+after an \fBendwin\fP, by \fBdoupdate\fP,
 so they normally are not called.
-.SS resetty, savetty
-.PP
-The \fBresetty\fR and \fBsavetty\fR routines save and restore the
+.SS "resetty, savetty"
+The \fBresetty\fP and \fBsavetty\fP routines save and restore the
 state of the terminal modes.
-\fBsavetty\fR saves the current state in
-a buffer and \fBresetty\fR restores the state to what it was at the
-last call to \fBsavetty\fR.
+\fBsavetty\fP saves the current state in
+a buffer and \fBresetty\fP restores the state to what it was at the
+last call to \fBsavetty\fP.
 .SS getsyx
-.PP
-The \fBgetsyx\fR routine returns the current coordinates
-of the \fIvirtual screen\fP cursor in \fIy\fR and \fIx\fR.
-If \fBleaveok\fR is currently \fBTRUE\fR, then
-\fB\-1\fR,\fB\-1\fR is returned.
+The \fBgetsyx\fP routine returns the current coordinates
+of the \fIvirtual screen\fP cursor in \fIy\fP and \fIx\fP.
+If \fBleaveok\fP is currently \fBTRUE\fP, then
+\fB\-1\fP,\fB\-1\fP is returned.
 If lines have been removed from the top of the
-screen, using \fBripoffline\fR, \fIy\fR and \fIx\fR include these lines;
-therefore, \fIy\fR and \fIx\fR should be used only as arguments for
-\fBsetsyx\fR.
+screen, using \fBripoffline\fP, \fIy\fP and \fIx\fP include these lines;
+therefore, \fIy\fP and \fIx\fP should be used only as arguments for
+\fBsetsyx\fP.
 .PP
 Few applications will use this feature,
 most use \fBgetyx\fP instead.
 .SS setsyx
-.PP
-The \fBsetsyx\fR routine sets
-the \fIvirtual screen\fP cursor to \fIy\fR, \fIx\fR.
-If \fIy\fR and \fIx\fR are both \fB\-1\fR, then
-\fBleaveok\fR is set.
-The two routines \fBgetsyx\fR and \fBsetsyx\fR
+The \fBsetsyx\fP routine sets
+the \fIvirtual screen\fP cursor to \fIy\fP, \fIx\fP.
+If \fIy\fP and \fIx\fP are both \fB\-1\fP, then
+\fBleaveok\fP is set.
+The two routines \fBgetsyx\fP and \fBsetsyx\fP
 are designed to be used by a library routine, which manipulates
-\fBcurses\fR windows but does not want to change the current position
+\fBcurses\fP windows but does not want to change the current position
 of the program's cursor.
-The library routine would call \fBgetsyx\fR
+The library routine would call \fBgetsyx\fP
 at the beginning, do its manipulation of its own windows, do a
-\fBwnoutrefresh\fR on its windows, call \fBsetsyx\fR, and then call
-\fBdoupdate\fR.
+\fBwnoutrefresh\fP on its windows, call \fBsetsyx\fP, and then call
+\fBdoupdate\fP.
 .PP
 Few applications will use this feature,
 most use \fBwmove\fP instead.
 .SS ripoffline
-.PP
-The \fBripoffline\fR routine provides access to the same facility that
-\fBslk_init\fR [see \fBcurs_slk\fR(3X)] uses to reduce the size of the
-screen.
-\fBripoffline\fR must be called before \fBinitscr\fR or
-\fBnewterm\fR is called, to prepare these initial actions:
+.B \%ripoffline
+provides access to the same facility that \fB\%slk_init\fP(3X) uses to
+reduce the size of the screen.
+\fB\%ripoffline\fP must be called before \fBinitscr\fP or
+\fBnewterm\fP is called, to prepare these initial actions:
 .bP
-If \fIline\fR is positive, a line is removed from the top of \fBstdscr\fR.
+If \fIline\fP is positive, a line is removed from the top of \fBstdscr\fP.
 .bP
-if \fIline\fR is negative, a line is removed from the bottom.
+if \fIline\fP is negative, a line is removed from the bottom.
 .PP
-When the resulting initialization is done inside \fBinitscr\fR, the
-routine \fBinit\fR (supplied by the user) is called with two
+When the resulting initialization is done inside \fBinitscr\fP, the
+routine \fBinit\fP (supplied by the user) is called with two
 arguments:
 .bP
 a window pointer to the one-line window that has been
@@ -157,75 +151,81 @@ allocated and
 .bP
 an integer with the number of columns in the window.
 .PP
-Inside this initialization routine, the integer variables \fBLINES\fR
-and \fBCOLS\fR (defined in \fB<curses.h>\fR) are not guaranteed to be
-accurate and \fBwrefresh\fR or \fBdoupdate\fR must not be called.
-It is allowable to call \fBwnoutrefresh\fR during the initialization routine.
+Inside this initialization routine, the integer variables \fBLINES\fP
+and \fBCOLS\fP (defined in \fB<curses.h>\fP) are not guaranteed to be
+accurate and \fBwrefresh\fP or \fBdoupdate\fP must not be called.
+It is allowable to call \fBwnoutrefresh\fP during the initialization routine.
 .PP
-\fBripoffline\fR can be called up to five times before calling \fBinitscr\fR or
-\fBnewterm\fR.
+\fBripoffline\fP can be called up to five times before calling \fBinitscr\fP or
+\fBnewterm\fP.
 .SS curs_set
-.PP
-The \fBcurs_set\fR routine sets the cursor state to invisible,
-normal, or very visible for \fBvisibility\fR equal to \fB0\fR,
-\fB1\fR, or \fB2\fR respectively.
-If the terminal supports the \fIvisibility\fR requested,
-the previous \fIcursor\fR state is returned;
-otherwise, \fBERR\fR is returned.
+The \fBcurs_set\fP routine sets the cursor state to invisible,
+normal, or very visible for \fBvisibility\fP equal to \fB0\fP,
+\fB1\fP, or \fB2\fP respectively.
+If the terminal supports the \fIvisibility\fP requested,
+the previous \fIcursor\fP state is returned;
+otherwise, \fBERR\fP is returned.
 .SS napms
-.PP
-The \fBnapms\fR routine is used to sleep for \fIms\fR milliseconds.
+.B \%napms
+sleeps for
+.I ms
+milliseconds.
+If
+.I ms
+exceeds 30,000
+(thirty seconds),
+it is capped at that value.
 .SH RETURN VALUE
-Except for \fBcurs_set\fR, these routines always return \fBOK\fR.
+Except for \fBcurs_set\fP, these routines always return \fBOK\fP.
 .PP
-\fBcurs_set\fR
-returns the previous cursor state, or \fBERR\fR if the
-requested \fIvisibility\fR is not supported.
+\fBcurs_set\fP
+returns the previous cursor state, or \fBERR\fP if the
+requested \fIvisibility\fP is not supported.
 .PP
 X/Open defines no error conditions.
 In this implementation
 .TP 5
-.na
-.hy 0
-\fBdef_prog_mode\fR, \fBdef_shell_mode\fR, \fBreset_prog_mode\fR, \fBreset_shell_mode\fR
-.hy
-.ad
+\fBdef_prog_mode\fP, \fBdef_shell_mode\fP, \fBreset_prog_mode\fP, \fBreset_shell_mode\fP
 return an error
 if the terminal was not initialized, or
 if the I/O call to obtain the terminal settings fails.
 .TP 5
 \fBripoffline\fP
 returns an error if the maximum number of ripped-off lines
-exceeds the maximum (NRIPS = 5).
+exceeds the maximum (5).
 .SH NOTES
-Note that \fBgetsyx\fR is a macro, so \fB&\fR is not necessary before
-the variables \fIy\fR and \fIx\fR.
+Note that \fBgetsyx\fP is a macro, so \fB&\fP is not necessary before
+the variables \fIy\fP and \fIx\fP.
 .PP
 Older SVr4 man pages warn that the return value
-of \fBcurs_set\fR \*(``is currently incorrect\*(''.
+of \fBcurs_set\fP \*(``is currently incorrect\*(''.
 This implementation gets it right, but it may be unwise to count
 on the correctness of the return value anywhere else.
 .PP
-Both ncurses and SVr4 will call \fBcurs_set\fR in \fBendwin\fR
-if \fBcurs_set\fR
+Both \fI\%ncurses\fP and SVr4 will call \fBcurs_set\fP in \fBendwin\fP
+if \fBcurs_set\fP
 has been called to make the cursor other than normal, i.e., either
 invisible or very visible.
-There is no way for ncurses to determine the initial cursor state to
-restore that.
+There is no way for \fI\%ncurses\fP to determine the initial cursor
+state to restore that.
 .SH PORTABILITY
-The \fIvirtual screen\fP functions \fBsetsyx\fR and \fBgetsyx\fR
-are not described in the XSI Curses standard, Issue 4.
-All other functions are as described in XSI Curses.
+The \fIvirtual screen\fP functions \fBsetsyx\fP and \fBgetsyx\fP
+are not described in X/Open Curses, Issue 4.
+All other functions are as described in X/Open Curses.
 .PP
-The SVr4 documentation describes \fBsetsyx\fR and \fBgetsyx\fR
+The SVr4 documentation describes \fBsetsyx\fP and \fBgetsyx\fP
 as having return type int.
 This is misleading, as they are macros with no documented semantics
 for the return value.
+.PP
+If interrupted, \fI\%ncurses\fP restarts \fBnapms\fP.
+That, and the limitation to 30 seconds,
+are different from other implementations.
 .SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_initscr\fR(3X),
-\fBcurs_outopts\fR(3X),
-\fBcurs_refresh\fR(3X),
-\fBcurs_scr_dump\fR(3X),
-\fBcurs_slk\fR(3X),
-\fBcurs_variables\fR(3X).
+\fB\%curses\fP(3X),
+\fB\%curs_initscr\fP(3X),
+\fB\%curs_outopts\fP(3X),
+\fB\%curs_refresh\fP(3X),
+\fB\%curs_scr_dump\fP(3X),
+\fB\%curs_slk\fP(3X),
+\fB\%curs_variables\fP(3X)
diff --git a/contrib/ncurses/man/curs_legacy.3x b/contrib/ncurses/man/curs_legacy.3x
index c2eb86b8834c..24be01b85269 100644
--- a/contrib/ncurses/man/curs_legacy.3x
+++ b/contrib/ncurses/man/curs_legacy.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2019,2020 Thomas E. Dickey                                     *
+.\" Copyright 2019-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 2007-2015,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,82 +27,112 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_legacy.3x,v 1.12 2020/10/18 00:16:04 tom Exp $
+.\" $Id: curs_legacy.3x,v 1.32 2024/03/16 15:35:01 tom Exp $
+.TH curs_legacy 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.TH curs_legacy 3X ""
 .SH NAME
-curs_legacy \- get \fBcurses\fP cursor and window coordinates, attributes
+\fB\%getattrs\fP,
+\fB\%getbegx\fP,
+\fB\%getbegy\fP,
+\fB\%getcurx\fP,
+\fB\%getcury\fP,
+\fB\%getmaxx\fP,
+\fB\%getmaxy\fP,
+\fB\%getparx\fP,
+\fB\%getpary\fP \-
+get \fIcurses\fR cursor and window coordinates or attributes (legacy)
 .SH SYNOPSIS
-\fB#include <curses.h>\fP
-.sp
-\fBint getattrs(const WINDOW *\fP\fIwin\fP\fB);\fP
-.sp
-\fBint getbegx(const WINDOW *\fP\fIwin\fP\fB);\fP
-.br
-\fBint getbegy(const WINDOW *\fP\fIwin\fP\fB);\fP
-.sp
-\fBint getcurx(const WINDOW *\fP\fIwin\fP\fB);\fP
-.br
-\fBint getcury(const WINDOW *\fP\fIwin\fP\fB);\fP
-.sp
-\fBint getmaxx(const WINDOW *\fP\fIwin\fP\fB);\fP
-.br
-\fBint getmaxy(const WINDOW *\fP\fIwin\fP\fB);\fP
-.sp
-\fBint getparx(const WINDOW *\fP\fIwin\fP\fB);\fP
-.br
-\fBint getpary(const WINDOW *\fP\fIwin\fP\fB);\fP
-.br
+.nf
+\fB#include <curses.h>
+.PP
+\fBint getattrs(const WINDOW *\fIwin\fP);
+.PP
+\fBint getbegx(const WINDOW *\fIwin\fP);
+\fBint getbegy(const WINDOW *\fIwin\fP);
+.PP
+\fBint getcurx(const WINDOW *\fIwin\fP);
+\fBint getcury(const WINDOW *\fIwin\fP);
+.PP
+\fBint getmaxx(const WINDOW *\fIwin\fP);
+\fBint getmaxy(const WINDOW *\fIwin\fP);
+.PP
+\fBint getparx(const WINDOW *\fIwin\fP);
+\fBint getpary(const WINDOW *\fIwin\fP);
+.fi
 .SH DESCRIPTION
-These legacy functions are simpler to use than the X/Open Curses functions:
+These legacy functions are simpler to use
+than the X/Open \fIcurses\fP functions:
 .bP
-The \fBgetattrs\fP function returns the same attribute data as \fBwattr_get\fP.
+The \fB\%getattrs\fP function returns the same attribute data
+as \fB\%wattr_get\fP.
 .IP
-However, \fBgetattrs\fP returns an integer (actually a \fBchtype\fP),
-while \fBwattr_get\fP returns the current color pair in a separate parameter.
+However, \fB\%getattrs\fP returns an integer (actually a \fB\%chtype\fP),
+while \fB\%wattr_get\fP returns the current color pair in a separate parameter.
 In the wide-character library configuration,
-color pairs may not fit into a \fBchtype\fP,
-so \fBwattr_get\fP is the only way to obtain the color information.
+color pairs may not fit into a \fB\%chtype\fP,
+so \fB\%wattr_get\fP is the only way to obtain the color information.
 .IP
-Because \fBgetattrs\fP returns the attributes in a single parameter,
+Because \fB\%getattrs\fP returns the attributes in a single parameter,
 it would not be possible for an application to distinguish that from
 \fBERR\fP (a \fI-1\fP).
-If the window parameter is null, \fBgetattrs\fP returns \fBA_NORMAL\fP (zero).
+If the window parameter is null, \fB\%getattrs\fP
+returns \fB\%A_NORMAL\fP (zero).
 .bP
-The \fBgetbegy\fP and \fBgetbegx\fP functions return the same
-data as \fBgetbegyx\fP.
+The \fB\%getbegy\fP and \fB\%getbegx\fP functions return the same
+data as \fB\%getbegyx\fP.
 .bP
-The \fBgetcury\fP and \fBgetcurx\fP functions return the same
-data as \fBgetyx\fP.
+The \fB\%getcury\fP and \fB\%getcurx\fP functions return the same
+data as \fB\%getyx\fP.
 .bP
-The \fBgetmaxy\fP and \fBgetmaxx\fP functions return the same
-data as \fBgetmaxyx\fP.
+The \fB\%getmaxy\fP and \fB\%getmaxx\fP functions return the same
+data as \fB\%getmaxyx\fP.
 .bP
-The \fBgetpary\fP and \fBgetparx\fP functions return the same
-data as \fBgetparyx\fP.
+The \fB\%getpary\fP and \fB\%getparx\fP functions return the same
+data as \fB\%getparyx\fP.
 .SH RETURN VALUE
 Except as noted,
 these functions return an integer,
 or \fBERR\fP if the window parameter is null.
 .SH NOTES
-All of these interfaces are provided as macros and functions.
-The macros are suppressed (and only the functions provided)
-when \fBNCURSES_OPAQUE\fP is defined.
-The standard forms such as \fBgetyx\fP must be implemented as macros,
-and (in this implementation) are defined in terms of the functions
-described here,
-to avoid reliance on internal details of the WINDOW structure.
+All of these interfaces are implemented as macros and functions.
+The macros are suppressed
+(and only the functions provided)
+in an \*(``opaque\*(''
+.I \%ncurses
+build,
+which defines the preprocessor symbol
+.BR \%NCURSES_OPAQUE .
+See section \*(``ALTERNATE CONFIGURATIONS\*('' in \fB\%ncurses\fP(3X).
+.PP
+The standard forms such as \fB\%getyx\fP
+.I must
+be implemented as macros,
+and
+(in this implementation)
+are defined in terms of the functions described here,
+to avoid reliance on internal details of the \fI\%WINDOW\fP structure.
 .SH PORTABILITY
 These functions were supported on Version 7, BSD or System V implementations.
 None of those implementations checked the window parameter.
 .PP
-The \fBgetattrs\fP function and macro are defined to return a (signed) integer
+The \fB\%getattrs\fP function and macro are defined to return a (signed) integer
 for compatibility with those implementations
 although an unsigned type would have been more appropriate.
 .SH SEE ALSO
-\fBcurses\fP(3X),
-\fBcurs_getyx\fP(3X),
-\fBcurs_opaque\fP(3X)
+\fB\%curses\fP(3X),
+\fB\%curs_getyx\fP(3X),
+\fB\%curs_opaque\fP(3X)
diff --git a/contrib/ncurses/man/curs_memleaks.3x b/contrib/ncurses/man/curs_memleaks.3x
index 59bd3e851f92..0626d774097b 100644
--- a/contrib/ncurses/man/curs_memleaks.3x
+++ b/contrib/ncurses/man/curs_memleaks.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2019-2020,2021 Thomas E. Dickey                                *
+.\" Copyright 2019-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 2008-2010,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,73 +27,80 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_memleaks.3x,v 1.11 2021/01/02 23:47:51 tom Exp $
-.TH curs_memleaks 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
-.na
-.hy 0
+.\" $Id: curs_memleaks.3x,v 1.35 2024/03/16 15:35:01 tom Exp $
+.TH curs_memleaks 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
+.de bP
+.ie n  .IP \(bu 4
+.el    .IP \(bu 2
+..
 .SH NAME
-\fBexit_curses\fP,
-\fBexit_terminfo\fP \- \fBcurses\fR memory-leak checking
-.ad
-.hy
+\fB\%exit_curses\fP,
+\fB\%exit_terminfo\fP \-
+check for memory leaks in \fIcurses\fR
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.br
-\fBvoid exit_curses(int \fP\fIcode\fP\fB);\fR
-.sp
-\fB#include <term.h>\fR
-.br
-\fBvoid exit_terminfo(int \fP\fIcode\fP\fB);\fR
-.sp
-/* deprecated (intentionally not declared in curses.h or term.h) */
-.br
-\fBvoid _nc_freeall(void);\fR
-.br
-\fBvoid _nc_free_and_exit(int \fP\fIcode\fP\fB);\fR
-.br
-\fBvoid _nc_free_tinfo(int \fP\fIcode\fP\fB);\fR
+.nf
+\fB#include <curses.h>
+\fBvoid exit_curses(int \fIcode\fP);
+.PP
+\fB#include <term.h>
+\fBvoid exit_terminfo(int \fIcode\fP);
+.PP
+\fI/* deprecated (intentionally not declared in curses.h or term.h) */
+\fBvoid _nc_freeall(void);
+\fBvoid _nc_free_and_exit(int \fIcode\fP);
+\fBvoid _nc_free_tinfo(int \fIcode\fP);
+.fi
 .SH DESCRIPTION
-These functions are used to simplify analysis of memory leaks in the ncurses
-library.
+These functions are used to simplify analysis of memory leaks in the
+\fI\%ncurses\fP library.
 .PP
 Any implementation of curses must not free the memory associated with
-a screen, since (even after calling \fBendwin\fP(3X)), it must be available
-for use in the next call to \fBrefresh\fP(3X).
+a screen, since (even after calling \fB\%endwin\fP(3X)), it must be available
+for use in the next call to \fB\%refresh\fP(3X).
 There are also chunks of memory held for performance reasons.
 That makes it hard to analyze curses applications for memory leaks.
-When using the specially configured debugging version of the ncurses library,
+When using the specially configured debugging version of the
+\fI\%ncurses\fP library,
 applications can call functions which free those chunks of memory,
 simplifying the process of memory-leak checking.
 .PP
 Some of the functions are named with a \*(``_nc_\*('' prefix
 because they are not intended for use in the non-debugging library:
 .TP 5
-\fB_nc_freeall\fP
-This frees (almost) all of the memory allocated by ncurses.
+\fB\%_nc_freeall\fP
+This frees (almost) all of the memory allocated by \fI\%ncurses\fP.
 .TP 5
-\fB_nc_free_and_exit\fP
-This frees the memory allocated by ncurses (like \fB_nc_freeall\fP),
+\fB\%_nc_free_and_exit\fP
+This frees the memory allocated by \fI\%ncurses\fP
+(like \fB\%_nc_freeall\fP),
 and exits the program.
-It is preferred over \fB_nc_freeall\fP since some of that memory
+It is preferred over \fB\%_nc_freeall\fP since some of that memory
 may be required to keep the application running.
 Simply exiting (with the given exit-code) is safer.
 .TP 5
-\fB_nc_free_tinfo\fP
+\fB\%_nc_free_tinfo\fP
 Use this function if only the low-level terminfo functions (and
 corresponding library) are used.
-Like \fB_nc_free_and_exit\fP, it exits the program after freeing memory.
+Like \fB\%_nc_free_and_exit\fP, it exits the program after freeing memory.
 .PP
 The functions prefixed \*(``_nc\*('' are normally not available;
 they must be configured into the library
-at build time using the \fB\-\-disable-leaks\fP option.
+at build time using the \fB\%\-\-disable-leaks\fP option.
 That compiles-in code that frees memory that normally would not be freed.
 .PP
-The \fBexit_curses\fP and \fBexit_terminfo\fP functions
-call \fB_nc_free_and_exit\fP and \fB_nc_free_tinfo\fP if
+The \fB\%exit_curses\fP and \fB\%exit_terminfo\fP functions
+call \fB\%_nc_free_and_exit\fP and \fB\%_nc_free_tinfo\fP if
 the library is configured to support memory-leak checking.
 If the library is not configured to support memory-leak checking,
 they simply call \fBexit\fP.
@@ -102,5 +109,23 @@ These functions do not return a value.
 .SH PORTABILITY
 These functions are not part of X/Open Curses;
 nor do other implementations of curses provide a similar feature.
+.PP
+In any implementation of X/Open Curses, an application can free part
+of the memory allocated by curses:
+.bP
+The portable part of \fB\%exit_curses\fP can be freed using \fB\%delscreen\fP,
+passing the \fISCREEN\fP pointer returned by \fB\%newterm\fP.
+.IP
+In some implementations, there is a global variable \fBsp\fP
+which could be used, e.g., if the screen were only initialized
+using \fB\%initscr\fP.
+.bP
+The portable part of \fB\%exit_terminfo\fP can be freed
+using \fB\%del_curterm\fP.
+.IP
+In this case, there is a global variable \fB\%cur_term\fP which can be
+used as parameter.
 .SH SEE ALSO
-\fBcurses\fR(3X).
+\fB\%curses\fP(3X),
+\fB\%curs_initscr\fP(3X),
+\fB\%curs_terminfo\fP(3X)
diff --git a/contrib/ncurses/man/curs_mouse.3x b/contrib/ncurses/man/curs_mouse.3x
index c18be3fa3378..8e5c70181345 100644
--- a/contrib/ncurses/man/curs_mouse.3x
+++ b/contrib/ncurses/man/curs_mouse.3x
@@ -1,6 +1,6 @@
 '\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2015,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,99 +28,102 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_mouse.3x,v 1.53 2020/10/17 23:25:08 tom Exp $
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
-.de NS
-.ie n  .sp
-.el    .sp .5
-.ie n  .in +4
-.el    .in +2
-.nf
-.ft C			\" Courier
-..
-.de NE
-.fi
-.ft R
-.ie n  .in -4
-.el    .in -2
-..
+.\" $Id: curs_mouse.3x,v 1.98 2024/04/20 19:02:07 tom Exp $
+.TH curs_mouse 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.TH curs_mouse 3X ""
-.na
-.hy 0
 .SH NAME
-\fBhas_mouse\fR,
-\fBgetmouse\fR, \fBungetmouse\fR,
-\fBmousemask\fR, \fBwenclose\fR,
-\fBmouse_trafo\fR, \fBwmouse_trafo\fR,
-\fBmouseinterval\fR \- mouse interface through curses
-.ad
-.hy
+\fB\%has_mouse\fP,
+\fB\%getmouse\fP,
+\fB\%ungetmouse\fP,
+\fB\%mousemask\fP,
+\fB\%wenclose\fP,
+\fB\%mouse_trafo\fP,
+\fB\%wmouse_trafo\fP,
+\fB\%mouseinterval\fP \-
+get mouse events in \fIcurses\fR
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
+.nf
+\fB#include <curses.h>
 .PP
-\fBtypedef unsigned long mmask_t;\fR
+\fBtypedef unsigned long mmask_t;
 .PP
-.nf
-\fBtypedef struct {\fR
-\fB    short id;         \fR\fI/* ID to distinguish multiple devices */\fR
-\fB    int x, y, z;      \fR\fI/* event coordinates */\fR
-\fB    mmask_t bstate;   \fR\fI/* button state bits */\fR
-\fB} MEVENT;\fR
-.fi
+\fBtypedef struct {
+\fB    short id;         \fI/* ID to distinguish multiple devices */
+\fB    int x, y, z;      \fI/* event coordinates */
+\fB    mmask_t bstate;   \fI/* button state bits */
+\fB} MEVENT;
+.PP
+\fBbool has_mouse(void);
 .PP
-\fBbool has_mouse(void);\fR
-.sp
-\fBint getmouse(MEVENT *\fP\fIevent\fP\fB);\fR
-.br
-\fBint ungetmouse(MEVENT *\fP\fIevent\fP\fB);\fR
-.sp
-\fBmmask_t mousemask(mmask_t \fP\fInewmask\fP\fB, mmask_t *\fP\fIoldmask\fP\fB);\fR
-.sp
-\fBbool wenclose(const WINDOW *\fP\fIwin\fP\fB, int \fP\fIy\fP\fB, int \fP\fIx\fP\fB);\fR
-.sp
-\fBbool mouse_trafo(int* \fP\fIpY\fP\fB, int* \fP\fIpX\fP\fB, bool \fP\fIto_screen\fP\fB);\fR
-.br
-\fBbool wmouse_trafo(const WINDOW* \fP\fIwin\fP\fB,\fR
-                  \fBint* \fP\fIpY\fP\fB, int* \fP\fIpX\fP\fB, bool \fP\fIto_screen\fP\fB);\fR
-.sp
-\fBint mouseinterval(int \fP\fIerval\fP\fB);\fR
-.br
+\fBmmask_t mousemask(mmask_t \fInewmask\fP, mmask_t *\fIoldmask\fP);
+.PP
+\fBint getmouse(MEVENT *\fIevent\fP);
+\fBint ungetmouse(MEVENT *\fIevent\fP);
+.PP
+\fBbool wenclose(const WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP);
+.PP
+\fBbool mouse_trafo(int* \fIpY\fP, int* \fIpX\fP, bool \fIto_screen\fP);
+\fBbool wmouse_trafo(const WINDOW* \fIwin\fP,
+.ti +18n \" "bool wmouse_trafo("
+\fBint* \fIpY\fB, int* \fIpX\fB, bool \fIto_screen\fB);
+.PP
+\fBint mouseinterval(int \fIerval\fB);\fR
+.fi
 .SH DESCRIPTION
 These functions provide an interface to mouse events from
-\fBncurses\fR(3X).
-Mouse events are represented by \fBKEY_MOUSE\fR
-pseudo-key values in the \fBwgetch\fR(3X) input stream.
-.SS mousemask
+\fB\%ncurses\fP(3X).
+Mouse events are represented by \fB\%KEY_MOUSE\fP
+pseudo-key values in the \fB\%wgetch\fP(3X) input stream.
+.SS has_mouse
+The \fB\%has_mouse\fP function returns \fBTRUE\fP if the mouse driver
+has been successfully initialized,
+and \fBFALSE\fP otherwise.
 .PP
-To make mouse events visible, use the \fBmousemask\fR function.
-This will set
-the mouse events to be reported.
+Mouse events are ignored when input is in cooked mode, and
+cause an error beep when cooked mode is being simulated in a window by a
+function such as \fB\%getstr\fP that expects a linefeed for input-loop
+termination.
+.SS mousemask
+To make mouse events visible, use the \fB\%mousemask\fP function.
+This sets the mouse events to be reported.
 By default, no mouse events are reported.
-The function will return a mask to indicate which of the specified mouse events
-can be reported; on complete failure it returns 0.
-If oldmask is non-NULL,
-this function fills the indicated location with the previous value of the given
-window's mouse event mask.
+.bP
+The function returns an updated copy of \fInewmask\fP
+to indicate which of the specified mouse events can be reported.
+.IP
+If the screen has not been initialized,
+or if the terminal does not support mouse-events,
+this function returns 0.
+.bP
+If \fIoldmask\fP is non-\fBNULL\fP,
+this function fills the indicated location with the previous value of the
+current screen's mouse event mask.
 .PP
-As a side effect, setting a zero mousemask may turn off the mouse pointer;
+As a side effect, setting a zero mouse mask may turn off the mouse pointer;
 setting a nonzero mask may turn it on.
 Whether this happens is device-dependent.
-.SS Mouse events
-.PP
+.SS "Mouse Events"
 Here are the mouse event type masks which may be defined:
 .PP
 .TS
-l l
-_ _
-l l.
-\fIName\fR	\fIDescription\fR
+Lb Lb
+Lb Lx.
+Name	Description
+=
 BUTTON1_PRESSED	mouse button 1 down
 BUTTON1_RELEASED	mouse button 1 up
 BUTTON1_CLICKED	mouse button 1 clicked
@@ -151,200 +154,156 @@ BUTTON5_CLICKED	mouse button 5 clicked
 BUTTON5_DOUBLE_CLICKED	mouse button 5 double clicked
 BUTTON5_TRIPLE_CLICKED	mouse button 5 triple clicked
 _
-BUTTON_SHIFT	shift was down during button state change
-BUTTON_CTRL	control was down during button state change
-BUTTON_ALT	alt was down during button state change
+BUTTON_SHIFT	T{
+shift was down during button state change
+T}
+BUTTON_CTRL	T{
+control was down during button state change
+T}
+BUTTON_ALT	T{
+alt was down during button state change
+T}
 ALL_MOUSE_EVENTS	report all button state changes
 REPORT_MOUSE_POSITION	report mouse movement
 _
 .TE
 .SS getmouse
-.PP
 Once a class of mouse events has been made visible in a window,
-calling the \fBwgetch\fR function on that window may return
-\fBKEY_MOUSE\fR as an indicator that a mouse event has been queued.
+calling the \fB\%wgetch\fP function on that window may return
+\fB\%KEY_MOUSE\fP as an indicator that a mouse event has been queued.
 To read the event data and pop the event off the queue, call
-\fBgetmouse\fR.
-This function will return \fBOK\fR if a mouse event
-is actually visible in the given window, \fBERR\fR otherwise.
-When \fBgetmouse\fR returns \fBOK\fR, the data deposited as y and
+\fB\%getmouse\fP.
+This function will return \fBOK\fP if a mouse event
+is actually visible in the given window, \fBERR\fP otherwise.
+When \fB\%getmouse\fP returns \fBOK\fP, the data deposited as y and
 x in the event structure coordinates will be screen-relative character-cell
 coordinates.
 The returned state mask will have exactly one bit set to
 indicate the event type.
 The corresponding data in the queue is marked invalid.
-A subsequent call to \fBgetmouse\fP will retrieve the next older
+A subsequent call to \fB\%getmouse\fP will retrieve the next older
 item from the queue.
 .SS ungetmouse
-.PP
-The \fBungetmouse\fR function behaves analogously to \fBungetch\fR.
+The \fB\%ungetmouse\fP function behaves analogously to \fB\%ungetch\fP.
 It pushes
-a \fBKEY_MOUSE\fR event onto the input queue, and associates with that event
+a \fB\%KEY_MOUSE\fP event onto the input queue, and associates with that event
 the given state data and screen-relative character-cell coordinates.
 .SS wenclose
-.PP
-The \fBwenclose\fR function tests whether a given pair of screen-relative
+The \fB\%wenclose\fP function tests whether a given pair of screen-relative
 character-cell coordinates is enclosed by a given window, returning \fBTRUE\fP
 if it is and \fBFALSE\fP otherwise.
 It is useful for determining what subset of
 the screen windows enclose the location of a mouse event.
-.SS wmouse_trafo
 .PP
-The \fBwmouse_trafo\fR function transforms a given pair of coordinates
-from stdscr-relative coordinates
+If the parameter is a pad,
+\fB\%wenclose\fP uses the most recent screen coordinates used for
+this pad in
+\fB\%prefresh\fP(3X) or
+\fB\%pnoutrefresh\fP(3X).
+.SS wmouse_trafo
+The \fB\%wmouse_trafo\fP function transforms a given pair of coordinates
+from \fB\%stdscr\fP-relative coordinates
 to coordinates relative to the given window or vice versa.
-The resulting stdscr-relative coordinates are not always identical
-to window-relative coordinates due to the mechanism to reserve lines on top
-or bottom of the screen for other purposes
-(see the \fBripoffline\fP and \fBslk_init\fR(3X) calls, for example).
+The resulting \fB\%stdscr\fP-relative coordinates are not always
+identical to screen coordinates due to the mechanism to reserve
+lines on top or bottom of the screen for other purposes
+(see the \fB\%ripoffline\fP(3X) and \fB\%slk_init\fP(3X) calls, for example).
 .bP
-If the parameter \fBto_screen\fR is \fBTRUE\fR, the pointers
-\fBpY, pX\fR must reference the coordinates of a location
-inside the window \fBwin\fR.
-They are converted to window-relative coordinates and returned
+If the parameter \fIto_screen\fP is \fBTRUE\fP, the pointers
+\fIpY, pX\fP must reference the coordinates of a location
+inside the window \fIwin\fP.
+They are converted to \fB\%stdscr\fP-relative coordinates and returned
 through the pointers.
-If the conversion was successful, the function returns \fBTRUE\fR.
-.bP
-If one of the parameters was NULL or the location is
-not inside the window, \fBFALSE\fR is returned.
-.bP
-If \fBto_screen\fR is
-\fBFALSE\fR, the pointers \fBpY, pX\fR must reference window-relative
-coordinates.
-They are converted to stdscr-relative coordinates if the
-window \fBwin\fR encloses this point.
-In this case the function returns \fBTRUE\fR.
+If the conversion was successful, the function returns \fBTRUE\fP.
+.IP
+If one of the parameters was \fBNULL\fP or the location is
+not inside the window, \fBFALSE\fP is returned.
 .bP
-If one of the parameters is NULL or the point is not inside the
-window, \fBFALSE\fR is returned.
+If \fIto_screen\fP is
+\fBFALSE\fP, the pointers \fIpY, pX\fP must reference
+\fB\%stdscr\fP-relative coordinates.
+They are converted to window-relative coordinates if the
+window \fIwin\fP encloses this point.
+In this case the function returns \fBTRUE\fP.
+.IP
+If one of the parameters is \fBNULL\fP or the point is not inside the
+window, \fBFALSE\fP is returned.
+.PP
 The referenced coordinates
 are only replaced by the converted coordinates if the transformation was
 successful.
 .SS mouse_trafo
-.PP
-The \fBmouse_trafo\fR function performs the same translation
-as \fBwmouse_trafo\fR,
-using stdscr for \fBwin\fR.
+The \fB\%mouse_trafo\fP function performs the same translation
+as \fB\%wmouse_trafo\fP,
+using \fB\%stdscr\fP for \fIwin\fP.
 .SS mouseinterval
+The \fB\%mouseinterval\fP function sets the maximum time
+(in thousands of a second)
+that can elapse between press and release events for them to
+be resolved as a
+.IR click .
+An application might interpret button press and release events separated
+by more than the mouse interval as a \*(``long press\*('',
+or,
+with motion,
+as a \*(``drag\*(''.
+.PP
+Calling \fB\%mouseinterval(0)\fP disables click resolution.
+When
+.I \%ncurses
+detects a mouse event,
+it awaits further input activity up to this interval,
+and then checks for a subsequent mouse event which can be combined
+with the first event.
+If the timeout expires without input activity
+(which would happen with a zero interval),
+then no click resolution will occur.
 .PP
-The \fBmouseinterval\fR function sets the maximum time (in thousands of a
-second) that can elapse between press and release events for them to
-be recognized as a click.
-Use \fBmouseinterval(0)\fR to disable click resolution.
 This function returns the previous interval value.
-Use \fBmouseinterval(\-1)\fR to obtain the interval without altering it.
-The default is one sixth of a second.
-.SS has_mouse
-.PP
-The \fBhas_mouse\fP function returns \fBTRUE\fP if the mouse driver has been
-successfully initialized.
+Use \fB\%mouseinterval(\-1)\fP to obtain the interval without altering it.
 .PP
-Note that mouse events will be ignored when input is in cooked mode, and will
-cause an error beep when cooked mode is being simulated in a window by a
-function such as \fBgetstr\fR that expects a linefeed for input-loop
-termination.
+The mouse interval is set to one sixth of a second
+when the corresponding screen is initialized,
+e.g., in \fBinitscr\fP(3X) or \fBsetupterm\fP(3X).
 .SH RETURN VALUE
-\fBgetmouse\fR and \fBungetmouse\fR
-return the integer \fBERR\fR upon failure or \fBOK\fR
-upon successful completion:
-.RS 3
-.TP 5
-\fBgetmouse\fP
-returns an error.
-.bP
-If no mouse driver was initialized, or
-if the mask parameter is zero,
-.bP
-It also returns an error if no more events remain in the queue.
-.TP 5
-\fBungetmouse\fP
-returns an error if the FIFO is full.
-.RE
+\fB\%has_mouse\fP,
+\fB\%wenclose\fP,
+\fB\%mouse_trafo\fP,
+and
+\fB\%wmouse_trafo\fP
+return \fBTRUE\fP or \fBFALSE\fP as noted above.
 .PP
-\fBmousemask\fR
-returns the mask of reportable events.
+\fB\%getmouse\fP and \fB\%ungetmouse\fP
+return \fBERR\fP upon failure and \fBOK\fP upon success.
 .PP
-\fBmouseinterval\fR
-returns the previous interval value, unless
-the terminal was not initialized.
-In that case, it returns the maximum interval value (166).
-.PP
-\fBwenclose\fR and \fBwmouse_trafo\fR
-are boolean functions returning \fBTRUE\fR or \fBFALSE\fR depending
-on their test result.
-.SH PORTABILITY
-These calls were designed for \fBncurses\fR(3X), and are not found in SVr4
-curses, 4.4BSD curses, or any other previous version of curses.
-.PP
-SVr4 curses had support for the mouse in a variant of \fBxterm\fP.
-It is mentioned in a few places, but with no supporting documentation:
+\fB\%getmouse\fP fails if:
 .bP
-the \*(``libcurses\*('' manual page lists functions for this feature
-which are prototyped in \fBcurses.h\fP:
-.NS
-extern int mouse_set(long int);
-extern int mouse_on(long int);
-extern int mouse_off(long int);
-extern int request_mouse_pos(void);
-extern int map_button(unsigned long);
-extern void wmouse_position(WINDOW *, int *, int *);
-extern unsigned long getmouse(void), getbmap(void);
-.NE
+no mouse driver was initialized,
 .bP
-the \*(``terminfo\*('' manual page lists capabilities for the feature
-.NS
-buttons           btns    BT       Number of buttons on the mouse
-get_mouse         getm    Gm       Curses should get button events
-key_mouse         kmous   Km       0631, Mouse event has occurred
-mouse_info        minfo   Mi       Mouse status information
-req_mouse_pos     reqmp   RQ       Request mouse position report
-.NE
+the mask of reportable events is zero,
 .bP
-the interface made assumptions (as does ncurses) about the escape sequences
-sent to and received from the terminal.
-.IP
-For instance
-the SVr4 curses library used the \fBget_mouse\fP capability to tell the
-terminal which mouse button events it should send,
-passing the mouse-button bit-mask to the terminal.
-Also, it could ask the terminal
-where the mouse was using the \fBreq_mouse_pos\fP capability.
-.IP
-Those features required a terminal which had been modified to work with curses.
-They were not part of the X Consortium's xterm.
+a mouse event was detected that does not match the mask,
+.bP
+or if no more events remain in the queue.
 .PP
-When developing the xterm mouse support for ncurses in September 1995,
-Eric Raymond was uninterested in using the same interface due to its
-lack of documentation.
-Later, in 1998, Mark Hesseling provided support in
-PDCurses 2.3 using the SVr4 interface.
-PDCurses, however, does not use video terminals,
-making it unnecessary to be concerned about compatibility with the
-escape sequences.
+\fB\%ungetmouse\fP returns an error if the event queue is full.
 .PP
-The feature macro \fBNCURSES_MOUSE_VERSION\fR is provided so the preprocessor
-can be used to test whether these features are present.
-If the interface is changed, the value of \fBNCURSES_MOUSE_VERSION\fR will be
-incremented.
-These values for \fBNCURSES_MOUSE_VERSION\fR may be
-specified when configuring ncurses:
-.RS 3
-.TP 3
-1
-has definitions for reserved events.
-The mask uses 28 bits.
-.TP 3
-2
-adds definitions for button 5,
-removes the definitions for reserved events.
-The mask uses 29 bits.
-.RE
+\fB\%mousemask\fP
+returns the mask of reportable events.
 .PP
-The order of the \fBMEVENT\fR structure members is not guaranteed.
+\fB\%mouseinterval\fP
+returns the previous interval value, unless
+the terminal was not initialized.
+In that case, it returns the maximum interval value (166).
+.SH NOTES
+The order of the \fB\%MEVENT\fP structure members is not guaranteed.
 Additional fields may be added to the structure in the future.
 .PP
-Under \fBncurses\fR(3X), these calls are implemented using either
-xterm's built-in mouse-tracking API or
+Under
+.IR \%ncurses ,
+these calls are implemented using either
+.IR \%xterm 's
+built-in mouse-tracking API or
 platform-specific drivers including
 .RS 3
 .bP
@@ -357,23 +316,31 @@ OS/2 EMX
 .PP
 If you are using an unsupported configuration,
 mouse events will not be visible to
-\fBncurses\fR(3X) (and the \fBmousemask\fR function will always
-return \fB0\fR).
-.PP
-If the terminfo entry contains a \fBXM\fR string,
-this is used in the xterm mouse driver to control the
+\fI\%ncurses\fP (and the \fB\%mousemask\fP function will always
+return \fB0\fP).
+.PP
+If the
+.I \%term\%info
+entry contains a \fBXM\fP string,
+this is used in the
+.I \%xterm
+mouse driver to control the
 way the terminal is initialized for mouse operation.
-The default, if \fBXM\fR is not found,
-corresponds to private mode 1000 of xterm:
+The default, if \fBXM\fP is not found,
+corresponds to private mode 1000 of
+.I \%xterm:
 .PP
 .RS 3
-\\E[?1000%?%p1%{1}%=%th%el%;
+\eE[?1000%?%p1%{1}%=%th%el%;
 .RE
 .PP
-The mouse driver also recognizes a newer xterm private mode 1006, e.g.,
+The mouse driver also recognizes a newer
+.I \%xterm
+private mode 1006,
+e.g.,
 .PP
 .RS 3
-\\E[?1006;1000%?%p1%{1}%=%th%el%;
+\eE[?1006;1000%?%p1%{1}%=%th%el%;
 .RE
 .PP
 The \fIz\fP member in the event structure is not presently used.
@@ -381,36 +348,178 @@ It is intended
 for use with touch screens (which may be pressure-sensitive) or with
 3D-mice/trackballs/power gloves.
 .PP
-The \fBALL_MOUSE_EVENTS\fP class does not include \fBREPORT_MOUSE_POSITION\fP.
+The \fB\%ALL_MOUSE_EVENTS\fP class does not
+include \fB\%REPORT_MOUSE_POSITION\fP.
 They are distinct.
-For example, in xterm,
+For example,
+in
+.IR \%xterm ,
 wheel/scrolling mice send position reports as a sequence of
 presses of buttons 4 or 5 without matching button-releases.
+.SH EXTENSIONS
+These functions were designed for
+\fB\%ncurses\fP(3X),
+and are not found in SVr4
+.IR curses ,
+4.4BSD
+.IR curses ,
+or any other previous curses implementation.
+(SVr4
+.I curses
+did have a
+.I \%getmouse
+function,
+which took no argument and returned a different type.)
+.SH PORTABILITY
+Applications employing the
+.I \%ncurses
+mouse extension should condition its use on the visibility of the
+.B \%NCURSES_MOUSE_VERSION
+preprocessor macro.
+When the interface changes,
+the macro's value increments.
+Multiple versions are available when
+.I \%ncurses
+is configured;
+see section \*(``ALTERNATE CONFIGURATIONS\*('' of \fB\%ncurses\fP(3X).
+The following values may be specified.
+.RS 3
+.TP 3
+1
+has definitions for reserved events.
+The mask uses 28 bits.
+.TP 3
+2
+adds definitions for button 5,
+removes the definitions for reserved events.
+The mask uses 29 bits.
+.RE
+.PP
+SVr4
+.I curses
+had support for the mouse in a variant of \fI\%xterm\fP(1).
+It is mentioned in a few places,
+with little supporting documentation.
+.bP
+Its \*(``libcurses\*('' manual page lists functions for this feature
+prototyped in \fI\%curses.h\fP.
+.PP
+.RS 8
+.EX
+extern int mouse_set(long int);
+extern int mouse_on(long int);
+extern int mouse_off(long int);
+extern int request_mouse_pos(void);
+extern int map_button(unsigned long);
+extern void wmouse_position(WINDOW *, int *, int *);
+extern unsigned long getmouse(void), getbmap(void);
+.EE
+.RE
+.bP
+Its \*(``terminfo\*('' manual page lists capabilities for the feature.
+.\" These don't appear in in the SVID 4th edition, Volume 3,
+.\" terminfo(TI_ENV) man page.  They can be found in, e.g., the "z/OS
+.\" V1R1.0 C Curses" book, Chapter 17, pp. 179-186 (PDF 213-220).
+.RS 8
+.TS
+Lb Lb Lb Lx.
+buttons	btns	BT	T{
+Number of buttons on the mouse
+T}
+get_mouse	getm	Gm	T{
+Curses should get button events
+T}
+key_mouse	kmous	Km	T{
+0631, Mouse event has occurred
+T}
+mouse_info	minfo	Mi	T{
+Mouse status information
+T}
+req_mouse_pos	reqmp	RQ	T{
+Request mouse position report
+T}
+.TE
+.RE
+.bP
+The interface made assumptions
+(as does
+.IR \%ncurses )
+about the escape sequences sent to and received from the terminal.
+.IP
+For instance,
+the SVr4
+.I curses
+library used the \fB\%get_mouse\fP capability to tell the terminal which
+mouse button events it should send,
+passing the mouse-button bit mask to the terminal.
+Also, it could ask the terminal
+where the mouse was using the \fB\%req_mouse_pos\fP capability.
+.IP
+Those features required a terminal program that had been modified
+to work with SVr4
+.IR curses .
+They were not part of the X Consortium's
+.IR \%xterm .
+.PP
+When developing the
+.I \%xterm
+mouse support for
+.I \%ncurses
+in September 1995,
+Eric Raymond was uninterested in using the same interface due to its
+lack of documentation.
+Later, in 1998, Mark Hesseling provided support in
+.I \%PDCurses
+2.3 using the SVr4 interface.
+.IR \%PDCurses ,
+however,
+does not use video terminals,
+making it unnecessary to be concerned about compatibility with the
+escape sequences.
 .SH BUGS
-Mouse events under xterm will not in fact be ignored during cooked mode,
-if they have been enabled by \fBmousemask\fR.
-Instead, the xterm mouse
-report sequence will appear in the string read.
-.PP
-Mouse events under xterm will not be detected correctly in a window with
-its keypad bit off, since they are interpreted as a variety of function key.
-Your terminfo description should have \fBkmous\fR set to \*(``\\E[M\*(''
-(the beginning of the response from xterm for mouse clicks).
-Other values for \fBkmous\fR are permitted,
-but under the same assumption,
-i.e., it is the beginning of the response.
-.PP
-Because there are no standard terminal responses that would serve to identify
-terminals which support the xterm mouse protocol, \fBncurses\fR assumes that
-if \fBkmous\fR is defined in the terminal description,
-or if the terminal description's primary name or aliases
-contain the string \*(``xterm\*('',
+Mouse events from
+.I \%xterm
+are
+.I not
+ignored in cooked mode if they have been enabled by \fB\%mousemask\fP.
+Instead,
+the
+.I \%xterm
+mouse report sequence appears in the string read.
+.PP
+Mouse event reports from
+.I \%xterm
+are not detected correctly in a window with keypad application mode
+disabled,
+since they are interpreted as a variety of function key.
+Set the terminal's
+.I \%term\%info
+capability \fB\%kmous\fP to \*(``\eE[M\*(''
+(the beginning of the response from
+.I \%xterm
+for mouse clicks).
+Other values of \fB\%kmous\fP are permitted under the same assumption,
+that is,
+the report begins with that sequence.
+.PP
+Because there are no standard response sequences that serve to identify
+terminals supporting the
+.I \%xterm
+mouse protocol,
+.I \%ncurses
+assumes that if \fB\%kmous\fP is defined in the terminal description,
+or if the terminal type's primary name or aliases contain the string
+\%\*(``xterm\*('',
 then the terminal may send mouse events.
-The \fBkmous\fP capability is checked first,
-allowing the use of newer xterm mouse protocols
-such as xterm's private mode 1006.
+The \fB\%kmous\fP capability is checked first,
+allowing use of newer
+.I \%xterm
+mouse protocols,
+such as its private mode 1006.
 .SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_kernel\fR(3X),
-\fBcurs_slk\fR(3X),
-\fBcurs_variables\fR(3X).
+\fB\%curses\fP(3X),
+\fB\%curs_inopts\fP(3X),
+\fB\%curs_kernel\fP(3X),
+\fB\%curs_pad\fP(3X),
+\fB\%curs_slk\fP(3X),
+\fB\%curs_variables\fP(3X)
diff --git a/contrib/ncurses/man/curs_move.3x b/contrib/ncurses/man/curs_move.3x
index e0c1bf5e0284..c3b68e813d1c 100644
--- a/contrib/ncurses/man/curs_move.3x
+++ b/contrib/ncurses/man/curs_move.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,40 +27,62 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_move.3x,v 1.19 2020/10/24 09:39:41 tom Exp $
-.TH curs_move 3X ""
-.na
-.hy 0
+.\" $Id: curs_move.3x,v 1.40 2024/04/27 17:56:05 tom Exp $
+.TH curs_move 3X 2024-04-27 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
-\fBmove\fR,
-\fBwmove\fR \- move \fBcurses\fR window cursor
-.ad
-.hy
+\fB\%move\fP,
+\fB\%wmove\fP \-
+move cursor in a \fIcurses\fR window
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBint move(int \fP\fIy\fP\fB, int \fP\fIx\fP\fB);\fR
-.br
-\fBint wmove(WINDOW *\fP\fIwin\fP\fB, int \fP\fIy\fP\fB, int \fP\fIx\fP\fB);\fR
-.br
+.nf
+\fB#include <curses.h>
+.PP
+\fBint move(int \fIy\fP, int \fIx\fP);
+\fBint wmove(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP);
+.fi
 .SH DESCRIPTION
-These routines move the cursor associated with the window to line \fIy\fR and
-column \fIx\fR.
-This routine does not move the physical cursor of the terminal
-until \fBrefresh\fR(3X) is called.
-The position specified is relative to the upper
-left-hand corner of the window, which is (0,0).
+.B \%wmove
+relocates the cursor associated with the
+.I curses
+window
+.I win
+to line
+.I y
+and column
+.IR x .
+The terminal's cursor does not move until \fB\%refresh\fP(3X) is called.
+The position
+.RI ( y ,
+.IR x )
+is relative to the upper left-hand corner of the window,
+which has coordinates
+(0,\ 0).
+\fB\%ncurses\fP(3X) describes the
+.B \%move
+variant of this function.
 .SH RETURN VALUE
-These routines return \fBERR\fR upon failure and \fBOK\fP (SVr4
-specifies only "an integer value other than \fBERR\fR") upon successful
-completion.
+These functions return
+.B OK
+on success and
+.B ERR
+on failure.
+.PP
+They fail if the position
+.RI ( y ,
+.IR x )
+is outside the window boundaries.
 .PP
-Specifically, they return an error
-if the window pointer is null, or
-if the position is outside the window.
+.B \%wmove
+fails if its
+.I \%WINDOW
+pointer argument is
+.BR NULL .
 .SH NOTES
-Note that \fBmove\fR may be a macro.
+.B \%move
+may be implemented as a macro.
 .SH PORTABILITY
-These functions are described in the XSI Curses standard, Issue 4.
+X/Open Curses,
+Issue 4 describes these functions.
 .SH SEE ALSO
-\fBcurses\fR(3X), \fBcurs_refresh\fR(3X)
+\fB\%curses\fP(3X),
+\fB\%curs_refresh\fP(3X)
diff --git a/contrib/ncurses/man/curs_opaque.3x b/contrib/ncurses/man/curs_opaque.3x
index 1d0cb55f2bb2..fa623eea1e96 100644
--- a/contrib/ncurses/man/curs_opaque.3x
+++ b/contrib/ncurses/man/curs_opaque.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2020 Thomas E. Dickey                                          *
+.\" Copyright 2020-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 2007-2014,2015 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,129 +27,135 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_opaque.3x,v 1.15 2020/10/24 09:41:22 tom Exp $
-.TH curs_opaque 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
-.na
-.hy 0
+.\" $Id: curs_opaque.3x,v 1.43 2024/03/16 15:35:01 tom Exp $
+.TH curs_opaque 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
 .SH NAME
-\fBis_cleared\fR,
-\fBis_idlok\fR,
-\fBis_idcok\fR,
-\fBis_immedok\fR,
-\fBis_keypad\fR,
-\fBis_leaveok\fR,
-\fBis_nodelay\fR,
-\fBis_notimeout\fR,
-\fBis_pad\fR,
-\fBis_scrollok\fR,
-\fBis_subwin\fR,
-\fBis_syncok\fR,
-\fBwgetdelay\fR,
-\fBwgetparent\fR,
-\fBwgetscrreg\fR \- \fBcurses\fR window properties
-.ad
-.hy
+\fB\%is_cleared\fP,
+\fB\%is_idlok\fP,
+\fB\%is_idcok\fP,
+\fB\%is_immedok\fP,
+\fB\%is_keypad\fP,
+\fB\%is_leaveok\fP,
+\fB\%is_nodelay\fP,
+\fB\%is_notimeout\fP,
+\fB\%is_pad\fP,
+\fB\%is_scrollok\fP,
+\fB\%is_subwin\fP,
+\fB\%is_syncok\fP,
+\fB\%wgetdelay\fP,
+\fB\%wgetparent\fP,
+\fB\%wgetscrreg\fP \-
+obtain \fIcurses\fR window properties
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBbool is_cleared(const WINDOW *\fP\fIwin\fP\fB);\fR
-.br
-\fBbool is_idcok(const WINDOW *\fP\fIwin\fP\fB);\fR
-.br
-\fBbool is_idlok(const WINDOW *\fP\fIwin\fP\fB);\fR
-.br
-\fBbool is_immedok(const WINDOW *\fP\fIwin\fP\fB);\fR
-.br
-\fBbool is_keypad(const WINDOW *\fP\fIwin\fP\fB);\fR
-.br
-\fBbool is_leaveok(const WINDOW *\fP\fIwin\fP\fB);\fR
-.br
-\fBbool is_nodelay(const WINDOW *\fP\fIwin\fP\fB);\fR
-.br
-\fBbool is_notimeout(const WINDOW *\fP\fIwin\fP\fB);\fR
-.br
-\fBbool is_pad(const WINDOW *\fP\fIwin\fP\fB);\fR
-.br
-\fBbool is_scrollok(const WINDOW *\fP\fIwin\fP\fB);\fR
-.br
-\fBbool is_subwin(const WINDOW *\fP\fIwin\fP\fB);\fR
-.br
-\fBbool is_syncok(const WINDOW *\fP\fIwin\fP\fB);\fR
-.br
-\fBWINDOW * wgetparent(const WINDOW *\fP\fIwin\fP\fB);\fR
-.br
-\fBint wgetdelay(const WINDOW *\fP\fIwin\fP\fB);\fR
-.br
-\fBint wgetscrreg(const WINDOW *\fP\fIwin\fP\fB, int *\fP\fItop\fP\fB, int *\fP\fIbottom\fP\fB);\fR
-.br
+.nf
+\fB#include <curses.h>
+.PP
+\fBbool is_cleared(const WINDOW *\fIwin\fP);
+\fBbool is_idcok(const WINDOW *\fIwin\fP);
+\fBbool is_idlok(const WINDOW *\fIwin\fP);
+\fBbool is_immedok(const WINDOW *\fIwin\fP);
+\fBbool is_keypad(const WINDOW *\fIwin\fP);
+\fBbool is_leaveok(const WINDOW *\fIwin\fP);
+\fBbool is_nodelay(const WINDOW *\fIwin\fP);
+\fBbool is_notimeout(const WINDOW *\fIwin\fP);
+\fBbool is_pad(const WINDOW *\fIwin\fP);
+\fBbool is_scrollok(const WINDOW *\fIwin\fP);
+\fBbool is_subwin(const WINDOW *\fIwin\fP);
+\fBbool is_syncok(const WINDOW *\fIwin\fP);
+.PP
+\fBWINDOW * wgetparent(const WINDOW *\fIwin\fP);
+\fBint wgetdelay(const WINDOW *\fIwin\fP);
+\fBint wgetscrreg(const WINDOW *\fIwin\fP, int *\fItop\fP, int *\fIbottom\fP);
+.fi
 .SH DESCRIPTION
-This implementation provides functions which return properties
-set in the WINDOW structure, allowing it to be \*(``opaque\*('' if
-the symbol \fBNCURSES_OPAQUE\fR is defined:
-.TP 5
-\fBis_cleared\fR
-returns the value set in \fBclearok\fR
-.TP 5
-\fBis_idcok\fR
-returns the value set in \fBidcok\fR
-.TP 5
-\fBis_idlok\fR
-returns the value set in \fBidlok\fR
-.TP 5
-\fBis_immedok\fR
-returns the value set in \fBimmedok\fR
-.TP 5
-\fBis_keypad\fR
-returns the value set in \fBkeypad\fR
-.TP 5
-\fBis_leaveok\fR
-returns the value set in \fBleaveok\fR
-.TP 5
-\fBis_nodelay\fR
-returns the value set in \fBnodelay\fR
-.TP 5
-\fBis_notimeout\fR
-returns the value set in \fBnotimeout\fR
-.TP 5
-\fBis_pad\fR
-returns \fBTRUE\fP if the window is a pad
-i.e., created by \fBnewpad\fP
-.TP 5
-\fBis_scrollok\fR
-returns the value set in \fBscrollok\fR
-.TP 5
-\fBis_subwin\fR
+\fI\%ncurses\fP provides functions returning properties of a
+\fI\%WINDOW\fP structure,
+allowing it to be \*(``opaque\*('' if
+the application defines the \fB\%NCURSES_OPAQUE\fP preprocessor symbol.
+\fIOpacity\fP in this sense means that the members of \fIstruct\fP data
+types are not directly accessible
+(for instance,
+through \*(``.\*('' or \*(``\->\*('' operators),
+but instead must be queried and/or set via library functions.
+Advantages of opacity include greater abstraction and improved
+management of concurrent accesses to data structures,
+keeping object states coherent.
+.TP
+\fBis_cleared\fP
+returns the value set by \fB\%clearok\fP(3X).
+.TP
+\fBis_idcok\fP
+returns the value set by \fB\%idcok\fP(3X).
+.TP
+\fBis_idlok\fP
+returns the value set by \fB\%idlok\fP(3X).
+.TP
+\fBis_immedok\fP
+returns the value set by \fB\%immedok\fP(3X).
+.TP
+\fBis_keypad\fP
+returns the value set by \fB\%keypad\fP(3X).
+.TP
+\fBis_leaveok\fP
+returns the value set by \fB\%leaveok\fP(3X).
+.TP
+\fBis_nodelay\fP
+returns the value set by \fB\%nodelay\fP(3X).
+.TP
+\fBis_notimeout\fP
+returns the value set by \fB\%notimeout\fP(3X).
+.TP
+\fBis_pad\fP
+returns \fBTRUE\fP if the window is a pad;
+that is,
+it was created by \fB\%newpad\fP(3X).
+.TP
+\fBis_scrollok\fP
+returns the value set by \fB\%scrollok\fP(3X).
+.TP
+\fBis_subwin\fP
 returns \fBTRUE\fP if the window is a subwindow,
-i.e., created by \fBsubwin\fP or \fBderwin\fP
-.TP 5
-\fBis_syncok\fR
-returns the value set in \fBsyncok\fR
-.TP 5
-\fBwgetdelay\fR
-returns the delay timeout as set in \fBwtimeout\fP.
-.TP 5
-\fBwgetparent\fR
-returns the parent WINDOW pointer for subwindows,
-or NULL for windows having no parent.
-.TP 5
-\fBwgetscrreg\fR
-returns the top and bottom rows for the scrolling margin
-as set in \fBwsetscrreg\fP.
+that is,
+it was created by \fB\%subwin\fP(3X) or \fB\%derwin\fP(3X).
+.TP
+\fBis_syncok\fP
+returns the value set by \fB\%syncok\fP(3X).
+.TP
+\fBwgetdelay\fP
+returns the delay timeout set by \fB\%wtimeout\fP(3X).
+.TP
+\fBwgetparent\fP
+returns the parent \fI\%WINDOW\fP pointer for subwindows,
+or \fBNULL\fP for windows having no parent.
+.TP
+\fBwgetscrreg\fP
+stores the the top and bottom rows for the scrolling margin set by
+\fB\%wsetscrreg\fP(3X) in the corresponding arguments,
+returning \fBERR\fP upon failure and \fBOK\fP upon successful
+completion.
 .SH RETURN VALUE
-These functions all return \fBTRUE\fP or \fBFALSE\fP, except as noted.
+These functions return \fBTRUE\fP or \fBFALSE\fP except as noted.
 .SH NOTES
-Both a macro and a function are provided for each name.
+\fI\%ncurses\fP provides both a C function and a preprocessor macro for
+each function documented in this page.
 .SH PORTABILITY
-These routines are specific to ncurses.
+These routines are specific to \fI\%ncurses\fP.
 They were not supported on Version 7, BSD or System V implementations.
-It is recommended that any code depending on ncurses extensions
-be conditioned using NCURSES_VERSION.
+It is recommended that any code depending on \fI\%ncurses\fP extensions
+be conditioned using \fB\%NCURSES_VERSION\fP.
 .SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_inopts\fR(3X),
-\fBcurs_outopts\fR(3X),
-\fBcurs_window\fR(3X)
+\fB\%curses\fP(3X),
+\fB\%curs_inopts\fP(3X),
+\fB\%curs_outopts\fP(3X),
+\fB\%curs_threads\fP(3X),
+\fB\%curs_window\fP(3X)
diff --git a/contrib/ncurses/man/curs_outopts.3x b/contrib/ncurses/man/curs_outopts.3x
index e4e742132744..df263f2c1a81 100644
--- a/contrib/ncurses/man/curs_outopts.3x
+++ b/contrib/ncurses/man/curs_outopts.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,67 +27,56 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_outopts.3x,v 1.33 2020/10/03 22:04:09 tom Exp $
-.TH curs_outopts 3X ""
-.na
-.hy 0
+.\" $Id: curs_outopts.3x,v 1.64 2024/04/20 21:24:19 tom Exp $
+.TH curs_outopts 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
 .SH NAME
-\fBclearok\fR,
-\fBidlok\fR,
-\fBidcok\fR,
-\fBimmedok\fR,
-\fBleaveok\fR,
-\fBsetscrreg\fR,
-\fBwsetscrreg\fR,
-\fBscrollok\fR \- \fBcurses\fR output options
-.ad
-.hy
+\fB\%clearok\fP,
+\fB\%idlok\fP,
+\fB\%idcok\fP,
+\fB\%immedok\fP,
+\fB\%leaveok\fP,
+\fB\%setscrreg\fP,
+\fB\%wsetscrreg\fP,
+\fB\%scrollok\fP \-
+set \fIcurses\fR output options
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBint clearok(WINDOW *\fP\fIwin\fP\fB, bool \fP\fIbf\fP\fB);\fR
-.br
-\fBint idlok(WINDOW *\fP\fIwin\fP\fB, bool \fP\fIbf\fP\fB);\fR
-.br
-\fBvoid idcok(WINDOW *\fP\fIwin\fP\fB, bool \fP\fIbf\fP\fB);\fR
-.br
-\fBvoid immedok(WINDOW *\fP\fIwin\fP\fB, bool \fP\fIbf\fP\fB);\fR
-.br
-\fBint leaveok(WINDOW *\fP\fIwin\fP\fB, bool \fP\fIbf\fP\fB);\fR
-.br
-\fBint scrollok(WINDOW *\fP\fIwin\fP\fB, bool \fP\fIbf\fP\fB);\fR
-.sp
-\fBint setscrreg(int \fP\fItop\fP\fB, int \fP\fIbot\fP\fB);\fR
-.br
-\fBint wsetscrreg(WINDOW *\fP\fIwin\fP\fB, int \fP\fItop\fP\fB, int \fP\fIbot\fP\fB);\fR
-.br
+.nf
+\fB#include <curses.h>
+.PP
+\fBint clearok(WINDOW *\fIwin\fP, bool \fIbf\fP);
+\fBint idlok(WINDOW *\fIwin\fP, bool \fIbf\fP);
+\fBvoid idcok(WINDOW *\fIwin\fP, bool \fIbf\fP);
+\fBvoid immedok(WINDOW *\fIwin\fP, bool \fIbf\fP);
+\fBint leaveok(WINDOW *\fIwin\fP, bool \fIbf\fP);
+\fBint scrollok(WINDOW *\fIwin\fP, bool \fIbf\fP);
+.PP
+\fBint setscrreg(int \fItop\fP, int \fIbot\fP);
+\fBint wsetscrreg(WINDOW *\fIwin\fP, int \fItop\fP, int \fIbot\fP);
+.fi
 .SH DESCRIPTION
-.PP
 These routines set options that change the style of output within
-\fBcurses\fR.
-All options are initially \fBFALSE\fR, unless otherwise stated.
-It is not necessary to turn these options off before calling \fBendwin\fR(3X).
+\fBcurses\fP.
+All options are initially \fBFALSE\fP, unless otherwise stated.
+It is not necessary to turn these options off before calling \fBendwin\fP(3X).
 .SS clearok
-.PP
-If \fBclearok\fR is called with \fBTRUE\fR as argument, the next
-call to \fBwrefresh\fR with this window will clear the screen completely and
+If \fBclearok\fP is called with \fBTRUE\fP as argument, the next
+call to \fBwrefresh\fP with this window will clear the screen completely and
 redraw the entire screen from scratch.
 This is useful when the contents of the
 screen are uncertain, or in some cases for a more pleasing visual effect.
 If
-the \fIwin\fR argument to \fBclearok\fR is the global variable \fBcurscr\fR,
-the next call to \fBwrefresh\fR with any window causes the screen to be cleared
+the \fIwin\fP argument to \fBclearok\fP is the global variable \fBcurscr\fP,
+the next call to \fBwrefresh\fP with any window causes the screen to be cleared
 and repainted from scratch.
 .SS idlok
-.PP
-If \fBidlok\fR is called with \fBTRUE\fR as second argument, \fBcurses\fR
+If \fBidlok\fP is called with \fBTRUE\fP as second argument, \fBcurses\fP
 considers using the hardware insert/delete line feature of terminals so
 equipped.
-Calling \fBidlok\fR with \fBFALSE\fR as second argument disables use
+Calling \fBidlok\fP with \fBFALSE\fP as second argument disables use
 of line insertion and deletion.
 This option should be enabled only if the
 application needs insert/delete line, for example, for a screen editor.
@@ -95,68 +84,66 @@ It is
 disabled by default because insert/delete line tends to be visually annoying
 when used in applications where it is not really needed.
 If insert/delete line
-cannot be used, \fBcurses\fR redraws the changed portions of all lines.
+cannot be used, \fBcurses\fP redraws the changed portions of all lines.
 .SS idcok
-.PP
-If \fBidcok\fR is called with \fBFALSE\fR as second argument, \fBcurses\fR
+If \fBidcok\fP is called with \fBFALSE\fP as second argument, \fBcurses\fP
 no longer considers using the hardware insert/delete character feature of
 terminals so equipped.
 Use of character insert/delete is enabled by default.
-Calling \fBidcok\fR with \fBTRUE\fR as second argument re-enables use
+Calling \fBidcok\fP with \fBTRUE\fP as second argument re-enables use
 of character insertion and deletion.
 .SS immedok
-.PP
-If \fBimmedok\fR is called with \fBTRUE as argument\fR, any change
-in the window image, such as the ones caused by \fBwaddch, wclrtobot, wscrl\fR,
-etc., automatically cause a call to \fBwrefresh\fR.
-However, it may
-degrade performance considerably, due to repeated calls to \fBwrefresh\fR.
-It is disabled by default.
+If \fBimmedok\fP is called with \fBTRUE\fP as second argument,
+any change in the window image,
+such as the ones caused by \fBwaddch, wclrtobot, wscrl\fP,
+etc., automatically causes a call to \fBwrefresh\fP.
+However, it may degrade performance considerably,
+due to repeated calls to \fBwrefresh\fP.
+Calling \fBimmedok\fP with \fBFALSE\fP as second argument
+restores the default behavior,
+i.e., deferring screen updates until a refresh is needed.
 .SS leaveok
-.PP
 Normally, the hardware cursor is left at the location of the window cursor
 being refreshed.
-The \fBleaveok\fR option allows the cursor to be left
+The \fBleaveok\fP option allows the cursor to be left
 wherever the update happens to leave it.
 It is useful for applications where
 the cursor is not used, since it reduces the need for cursor motions.
 .SS scrollok
-.PP
-The \fBscrollok\fR option controls what happens when the cursor of a window is
+The \fBscrollok\fP option controls what happens when the cursor of a window is
 moved off the edge of the window or scrolling region, either as a result of a
 newline action on the bottom line, or typing the last character of the last
 line.
-If disabled, (\fIbf\fR is \fBFALSE\fR), the cursor is left on the bottom
+If disabled, (\fIbf\fP is \fBFALSE\fP), the cursor is left on the bottom
 line.
-If enabled, (\fIbf\fR is \fBTRUE\fR), the window is scrolled up one line
+If enabled, (\fIbf\fP is \fBTRUE\fP), the window is scrolled up one line
 (Note that to get the physical scrolling effect on the terminal, it is
-also necessary to call \fBidlok\fR).
-.SS  setscrreg/wsetscrreg
-.PP
-The \fBsetscrreg\fR and \fBwsetscrreg\fR routines allow the application
+also necessary to call \fBidlok\fP).
+.SS  "setscrreg, wsetscrreg"
+The \fBsetscrreg\fP and \fBwsetscrreg\fP routines allow the application
 programmer to set a software scrolling region in a window.
-The \fItop\fR and
-\fIbot\fR parameters
+The \fItop\fP and
+\fIbot\fP parameters
 are the line numbers of the top and bottom margin of the scrolling
 region.
 (Line 0 is the top line of the window.)  If this option and
-\fBscrollok\fR are enabled, an attempt to move off the bottom margin line
+\fBscrollok\fP are enabled, an attempt to move off the bottom margin line
 causes all lines in the scrolling region to scroll one line in the direction
 of the first line.
 Only the text of the window is scrolled.
 (Note that this
 has nothing to do with the use of a physical scrolling region capability in the
 terminal, like that in the VT100.
-If \fBidlok\fR is enabled and the terminal
+If \fBidlok\fP is enabled and the terminal
 has either a scrolling region or insert/delete line capability, they will
 probably be used by the output routines.)
 .SH RETURN VALUE
-The functions \fBsetscrreg\fR and \fBwsetscrreg\fR return \fBOK\fR upon success
-and \fBERR\fR upon failure.
+The functions \fBsetscrreg\fP and \fBwsetscrreg\fP return \fBOK\fP upon success
+and \fBERR\fP upon failure.
 All other routines that return an integer always
-return \fBOK\fR.
+return \fBOK\fP.
 .PP
-X/Open Curses does not define any error conditions.
+X/Open Curses does not specify any error conditions.
 .PP
 In this implementation,
 .bP
@@ -164,60 +151,49 @@ those functions that have a window pointer
 will return an error if the window pointer is null
 .bP
 \fBwsetscrreg\fP
-returns an error if the scrolling region limits extend outside the window.
-.RE
+returns an error if the scrolling region limits extend outside the
+window boundaries.
+.SH NOTES
+Note that
+\fBclearok\fP,
+\fBleaveok\fP,
+\fBscrollok\fP,
+\fBidcok\fP, and
+\fBsetscrreg\fP may be macros.
 .PP
-X/Open does not define any error conditions.
-This implementation returns an error
-if the window pointer is null.
+The \fBimmedok\fP routine is useful for windows that are used as terminal
+emulators.
 .SH PORTABILITY
-These functions are described in the XSI Curses standard, Issue 4.
-.PP
-From the outset, ncurses used \fBnl\fP/\fBnonl\fP to control the conversion
-of newlines to carriage return/line-feed on output as well as input.
-XSI Curses documents only the use of these functions for input.
-This difference arose from converting the \fIpcurses\fP source
-(which used \fBioctl\fP calls with the \fBsgttyb\fP structure)
-to termios (i.e., the POSIX terminal interface).
-In the former, both input and output were controlled via a single
-option \fBCRMOD\fP,
-while the latter separates these features.
-Because that conversion interferes with output optimization,
-\fBnl\fP/\fBnonl\fP were amended after ncurses 6.2
-to eliminate their effect on output.
+These functions are described in X/Open Curses, Issue 4.
 .PP
 Some historic curses implementations had, as an undocumented feature, the
-ability to do the equivalent of \fBclearok(..., 1)\fR by saying
-\fBtouchwin(stdscr)\fR or \fBclear(stdscr)\fR.
-This will not work under ncurses.
+ability to do the equivalent of \fBclearok(..., 1)\fP by saying
+\fBtouchwin(stdscr)\fP or \fBclear(stdscr)\fP.
+This will not work under \fI\%ncurses\fP.
 .PP
-Earlier System V curses implementations specified that with \fBscrollok\fR
+Earlier System V curses implementations specified that with \fBscrollok\fP
 enabled, any window modification triggering a scroll also forced a physical
 refresh.
-XSI Curses does not require this, and \fBncurses\fR avoids doing
-it to perform better vertical-motion optimization at \fBwrefresh\fR
+X/Open Curses does not require this, and \fI\%ncurses\fP avoids doing
+it to perform better vertical-motion optimization at \fBwrefresh\fP
 time.
 .PP
-The XSI Curses standard does not mention that the cursor should be
-made invisible as a side-effect of \fBleaveok\fR.
+X/Open Curses does not mention that the cursor should be
+made invisible as a side-effect of \fBleaveok\fP.
 SVr4 curses documentation does this, but the code does not.
-Use \fBcurs_set\fR to make the cursor invisible.
-.SH NOTES
-Note that
-\fBclearok\fR,
-\fBleaveok\fR,
-\fBscrollok\fR,
-\fBidcok\fR, and
-\fBsetscrreg\fR may be macros.
-.PP
-The \fBimmedok\fR routine is useful for windows that are used as terminal
-emulators.
+Use \fBcurs_set\fP to make the cursor invisible.
+.SH HISTORY
+.I \%ncurses
+formerly treated \fBnl\fP(3X) and \fBnonl\fP(3X) as both input
+.I and
+output options,
+but no longer;
+see \fB\%curs_inopts\fP(3X).
 .SH SEE ALSO
-.na
-\fBcurses\fR(3X),
-\fBcurs_addch\fR(3X),
-\fBcurs_clear\fR(3X),
-\fBcurs_initscr\fR(3X),
-\fBcurs_scroll\fR(3X),
-\fBcurs_refresh\fR(3X),
-\fBcurs_variables\fR(3X).
+\fB\%curses\fP(3X),
+\fB\%curs_addch\fP(3X),
+\fB\%curs_clear\fP(3X),
+\fB\%curs_initscr\fP(3X),
+\fB\%curs_refresh\fP(3X),
+\fB\%curs_scroll\fP(3X),
+\fB\%curs_variables\fP(3X)
diff --git a/contrib/ncurses/man/curs_overlay.3x b/contrib/ncurses/man/curs_overlay.3x
index f80477f27ff5..2d4eb729bc22 100644
--- a/contrib/ncurses/man/curs_overlay.3x
+++ b/contrib/ncurses/man/curs_overlay.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2020 Thomas E. Dickey                                          *
+.\" Copyright 2020-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2013,2015 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,49 +27,57 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_overlay.3x,v 1.19 2020/02/02 23:34:34 tom Exp $
-.TH curs_overlay 3X ""
-.na
-.hy 0
+.\" $Id: curs_overlay.3x,v 1.43 2024/04/20 21:20:07 tom Exp $
+.TH curs_overlay 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .SH NAME
-\fBoverlay\fR,
-\fBoverwrite\fR,
-\fBcopywin\fR \- overlay and manipulate overlapped \fBcurses\fR windows
-.ad
-.hy
+\fB\%overlay\fP,
+\fB\%overwrite\fP,
+\fB\%copywin\fP \-
+overlay \fIcurses\fR windows and manipulate them
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBint overlay(const WINDOW *\fP\fIsrcwin\fP\fB, WINDOW *\fP\fIdstwin\fP\fB);\fR
-.br
-\fBint overwrite(const WINDOW *\fP\fIsrcwin\fP\fB, WINDOW *\fP\fIdstwin\fP\fB);\fR
-.br
-\fBint copywin(const WINDOW *\fP\fIsrcwin\fP\fB, WINDOW *\fP\fIdstwin\fP\fB, int \fP\fIsminrow\fP\fB,\fR
-      \fBint \fP\fIsmincol\fP\fB, int \fP\fIdminrow\fP\fB, int \fP\fIdmincol\fP\fB, int \fP\fIdmaxrow\fP\fB,\fR
-      \fBint \fP\fIdmaxcol\fP\fB, int \fP\fIoverlay\fP\fB);\fR
+.nf
+\fB#include <curses.h>
+.PP
+\fBint overlay(const WINDOW *\fIsrcwin\fP, WINDOW *\fIdstwin\fP);
+\fBint overwrite(const WINDOW *\fIsrcwin\fP, WINDOW *\fIdstwin\fP);
+\fBint copywin(const WINDOW *\fIsrcwin\fP, WINDOW *\fIdstwin\fP, int \fIsminrow\fP,
+      \fBint \fIsmincol\fB, int \fIdminrow\fB, int \fIdmincol\fB, int \fIdmaxrow\fB,\fR
+      \fBint \fIdmaxcol\fB, int \fIoverlay\fB);\fR
+.fi
 .SH DESCRIPTION
-.SS overlay, overwrite
-The \fBoverlay\fR and \fBoverwrite\fR routines overlay \fIsrcwin\fR on
-top of \fIdstwin\fR.
-\fIscrwin\fR and \fIdstwin\fR are not required
+.SS "overlay, overwrite"
+The \fBoverlay\fP and \fBoverwrite\fP routines overlay \fIsrcwin\fP on
+top of \fIdstwin\fP.
+\fIscrwin\fP and \fIdstwin\fP are not required
 to be the same size; only text where the two windows overlap is copied.
-The difference is that \fBoverlay\fR is non-destructive
-(blanks are not copied) whereas \fBoverwrite\fR is destructive.
+The difference is that \fBoverlay\fP is non-destructive
+(blanks are not copied) whereas \fBoverwrite\fP is destructive.
 .SS copywin
-.PP
-The \fBcopywin\fR routine provides a finer granularity of control over the
-\fBoverlay\fR and \fBoverwrite\fR routines.
-As in the \fBprefresh\fR routine,
-a rectangle is specified in the destination window, (\fIdminrow\fR,
-\fIdmincol\fR) and (\fIdmaxrow\fR, \fIdmaxcol\fR), and the upper-left-corner
-coordinates of the source window, (\fIsminrow\fR, \fIsmincol\fR).
-If the argument \fIoverlay\fR is \fBtrue\fR,
+The \fBcopywin\fP routine provides a finer granularity of control over the
+\fBoverlay\fP and \fBoverwrite\fP routines.
+As in the \fBprefresh\fP routine,
+a rectangle is specified in the destination window, (\fIdminrow\fP,
+\fIdmincol\fP) and (\fIdmaxrow\fP, \fIdmaxcol\fP), and the upper-left-corner
+coordinates of the source window, (\fIsminrow\fP, \fIsmincol\fP).
+If the argument \fIoverlay\fP is \fBtrue\fP,
 then copying is non-destructive,
-as in \fBoverlay\fR.
+as in \fBoverlay\fP.
 .SH RETURN VALUE
-Routines that return an integer return \fBERR\fR upon failure, and \fBOK\fR
-(SVr4 only specifies "an integer value other than \fBERR\fR") upon successful
-completion.
+These routines return the integer \fBERR\fP upon failure and an \fBOK\fP
+(SVr4 specifies only
+\*(``an integer value other than \fBERR\fP\*('')
+upon successful completion.
 .PP
 X/Open defines no error conditions.
 In this implementation,
@@ -78,11 +86,13 @@ In this implementation,
 if either of the window pointers are null, or
 if some part of the window would be placed off-screen.
 .SH NOTES
-Note that \fBoverlay\fR and \fBoverwrite\fR may be macros.
+Note that \fBoverlay\fP and \fBoverwrite\fP may be macros.
 .SH PORTABILITY
-The XSI Curses standard, Issue 4 describes these functions (adding the const
-qualifiers).
+These functions are described in X/Open Curses, Issue 4,
+which adds \fI\%const\fP qualifiers to the arguments.
 It further specifies their behavior in the presence of characters
 with multibyte renditions (not yet supported in this implementation).
 .SH SEE ALSO
-\fBcurses\fR(3X), \fBcurs_pad\fR(3X), \fBcurs_refresh\fR(3X)
+\fB\%curses\fP(3X),
+\fB\%curs_pad\fP(3X),
+\fB\%curs_refresh\fP(3X)
diff --git a/contrib/ncurses/man/curs_pad.3x b/contrib/ncurses/man/curs_pad.3x
index 36fca52ffbd9..21cc405c731b 100644
--- a/contrib/ncurses/man/curs_pad.3x
+++ b/contrib/ncurses/man/curs_pad.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2015,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,127 +27,161 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_pad.3x,v 1.26 2020/02/02 23:34:34 tom Exp $
+.\" $Id: curs_pad.3x,v 1.61 2024/04/27 17:55:43 tom Exp $
+.TH curs_pad 3X 2024-04-27 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.TH curs_pad 3X ""
-.na
-.hy 0
 .SH NAME
-\fBnewpad\fR,
-\fBsubpad\fR,
-\fBprefresh\fR,
-\fBpnoutrefresh\fR,
-\fBpechochar\fR,
-\fBpecho_wchar\fR \- create and display \fBcurses\fR pads
-.ad
-.hy
+\fB\%newpad\fP,
+\fB\%subpad\fP,
+\fB\%prefresh\fP,
+\fB\%pnoutrefresh\fP,
+\fB\%pechochar\fP,
+\fB\%pecho_wchar\fP \-
+create and display \fIcurses\fR pads
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBWINDOW *newpad(int \fP\fInlines\fP\fB, int \fP\fIncols\fP\fB);\fR
-.br
-\fBWINDOW *subpad(WINDOW *\fP\fIorig\fP\fB, int \fP\fInlines\fP\fB, int \fP\fIncols\fP\fB,\fR
-      \fBint \fP\fIbegin_y\fP\fB, int \fP\fIbegin_x\fP\fB);\fR
-.br
-\fBint prefresh(WINDOW *\fP\fIpad\fP\fB, int \fP\fIpminrow\fP\fB, int \fP\fIpmincol\fP\fB,\fR
-      \fBint \fP\fIsminrow\fP\fB, int \fP\fIsmincol\fP\fB, int \fP\fIsmaxrow\fP\fB, int \fP\fIsmaxcol\fP\fB);\fR
-.br
-\fBint pnoutrefresh(WINDOW *\fP\fIpad\fP\fB, int \fP\fIpminrow\fP\fB, int \fP\fIpmincol\fP\fB,\fR
-      \fBint \fP\fIsminrow\fP\fB, int \fP\fIsmincol\fP\fB, int \fP\fIsmaxrow\fP\fB, int \fP\fIsmaxcol\fP\fB);\fR
-.br
-\fBint pechochar(WINDOW *\fP\fIpad\fP\fB, chtype \fP\fIch\fP\fB);\fR
-.br
-\fBint pecho_wchar(WINDOW *\fP\fIpad\fP\fB, const cchar_t *\fP\fIwch\fP\fB);\fR
-.SH DESCRIPTION
-.SS newpad
-The \fBnewpad\fR routine creates and returns a pointer to a new pad data
-structure with the given number of lines, \fInlines\fR, and columns,
-\fIncols\fR.
-A pad is like a window, except that it is not restricted by the
-screen size, and is not necessarily associated with a particular part of the
-screen.
-Pads can be used when a large window is needed, and only a part of the
-window will be on the screen at one time.
-Automatic refreshes of pads
-(e.g., from scrolling or echoing of input) do not occur.
+.nf
+\fB#include <curses.h>
 .PP
-It is not
-legal to call \fBwrefresh\fR with a \fIpad\fR as an argument; the routines
-\fBprefresh\fR or \fBpnoutrefresh\fR should be called instead.
-Note that these
-routines require additional parameters to specify the part of the pad to be
-displayed and the location on the screen to be used for the display.
-.SS subpad
+\fBWINDOW *newpad(int \fInlines\fP, int \fIncols\fP);
+\fBWINDOW *subpad(WINDOW *\fIparent\fP, int \fInlines\fP, int \fIncols\fP,
+      \fBint \fIbegin_y\fB, int \fIbegin_x\fB);\fR
 .PP
-The \fBsubpad\fR routine creates and returns a pointer to a subwindow within a
-pad with the given number of lines, \fInlines\fR, and columns, \fIncols\fR.
-Unlike \fBsubwin\fR, which uses screen coordinates, the window is at position
-(\fIbegin\fR_\fIx\fR\fB,\fR \fIbegin\fR_\fIy\fR) on the pad.
-The window is
-made in the middle of the window \fIorig\fR, so that changes made to one window
-affect both windows.
-During the use of this routine, it will often be
-necessary to call \fBtouchwin\fR or \fBtouchline\fR on \fIorig\fR before
-calling \fBprefresh\fR.
-.SS prefresh, pnoutrefresh
+\fBint prefresh(WINDOW *\fIpad\fB, int \fIpminrow\fB, int \fIpmincol\fB,\fR
+      \fBint \fIsminrow\fB, int \fIsmincol\fB, int \fIsmaxrow\fB, int \fIsmaxcol\fB);\fR
+\fBint pnoutrefresh(WINDOW *\fIpad\fB, int \fIpminrow\fB, int \fIpmincol\fB,\fR
+      \fBint \fIsminrow\fB, int \fIsmincol\fB, int \fIsmaxrow\fB, int \fIsmaxcol\fB);\fR
+.PP
+\fBint pechochar(WINDOW *\fIpad\fB, chtype \fIch\fB);\fR
+\fBint pecho_wchar(WINDOW *\fIpad\fB, const cchar_t *\fIwch\fB);\fR
+.fi
+.SH DESCRIPTION
+A
+.I curses
+.I pad
+is like a window,
+except that it is not restricted by the screen size,
+and is not necessarily associated with a particular part of the screen.
+Pads can be used when a large window is needed,
+only part of which is to be visible on the screen.
+Pads are not automatically refreshed by scrolling or input-echoing
+operations.
 .PP
-The \fBprefresh\fR and \fBpnoutrefresh\fR routines are analogous to
-\fBwrefresh\fR and \fBwnoutrefresh\fR except that they relate to pads instead
-of windows.
-The additional parameters are needed to indicate what part of the
-pad and screen are involved.
+Pads cannot be refreshed with \fB\%wrefresh\fP(3X);
+use
+.B \%prefresh
+or
+.B \%pnoutrefresh
+instead.
+.SS newpad
+\fB\%newpad\fP creates and returns a pointer to a new pad data structure
+with the given number of lines,
+.IR nlines ,
+and columns,
+.IR ncols .
+.SS subpad
+.B \%subpad
+creates and returns a pointer to a subwindow within a pad
+with the given number of lines,
+.IR nlines ,
+and columns,
+.IR ncols .
+Unlike \fB\%subwin\fP(3X),
+which uses screen coordinates,
+the new pad is placed at position
+.RI ( begin_y ,
+.IR begin_x )
+relative to its parent.
+Thus,
+changes made to one pad can affect both.
+When operating on a subpad,
+it is often necessary to call \fB\%touchwin\fP(3X) or
+\fB\%touchline\fP(3X) on
+.I parent
+before calling
+.BR \%prefresh .
+.SS "prefresh, pnoutrefresh"
+.B \%prefresh\fP
+and
+.B \%pnoutrefresh
+are analogous to \fB\%wrefresh\fP(3X) and \fB\%wnoutrefresh\fP(3X)
+except that they operate on pads rather than windows.
+They require additional parameters are needed to indicate what portions
+of the pad and screen are involved.
 .bP
-The \fIpminrow\fR and \fIpmincol\fR parameters specify the upper
-left-hand corner of the rectangle to be displayed in the pad.
+.I pminrow
+and
+.I pmincol
+specify the upper left-hand corner of a rectangular view of the pad.
 .bP
-The \fIsminrow\fR,
-\fIsmincol\fR, \fIsmaxrow\fR, and \fIsmaxcol\fR
-parameters specify the edges of the
-rectangle to be displayed on the screen.
+.IR sminrow ,
+.IR smincol ,
+.IR smaxrow ,
+and
+.I smaxcol
+specify the vertices of the rectangle to be displayed on the screen.
 .PP
-The lower right-hand corner of the
-rectangle to be displayed in the pad is calculated from the screen coordinates,
+The lower right-hand corner
+of the rectangle to be displayed in the pad
+is calculated from the screen coordinates,
 since the rectangles must be the same size.
-Both rectangles must be entirely
-contained within their respective structures.
-Negative values of
-\fIpminrow\fR, \fIpmincol\fR, \fIsminrow\fR, or \fIsmincol\fR are treated as if
-they were zero.
+Both rectangles must be entirely contained
+within their respective structures.
+.I curses
+treats
+negative values of any of these parameters as zero.
 .SS pechochar
-.PP
-The \fBpechochar\fR routine is functionally equivalent to a call to \fBaddch\fR
-followed by a call to \fBrefresh\fR(3X),
-a call to \fBwaddch\fR followed by a call
-to \fBwrefresh\fR, or a call to \fBwaddch\fR followed by a call to
-\fBprefresh\fR.
-The knowledge that only a single character is being output is
-taken into consideration and, for non-control characters, a considerable
-performance gain might be seen by using these routines instead of their
-equivalents.
-In the case of \fBpechochar\fR, the last location of the pad on
-the screen is reused for the arguments to \fBprefresh\fR.
+.B \%pechochar
+is functionally equivalent to calling \fB\%waddch\fP(3X) followed by
+.BR \%prefresh .
+It suggests to the
+.I curses
+optimizer that only a single character is being output;
+a considerable performance benefit may be thus enjoyed.
+The location of the character
+.I ch
+written to the pad is used to populate the arguments to
+.BR \%prefresh .
 .SS pecho_wchar
-.PP
-The \fBpecho_wchar\fR function is the analogous wide-character
-form of \fBpechochar\fR.
-It outputs one character to a pad and immediately refreshes the pad.
-It does this by a call to \fBwadd_wch\fR followed by a call to \fBprefresh\fR.
+.B \%pecho_wchar\fP
+is functionally equivalent to calling \fB\%wadd_wch\fP(3X) followed by
+.BR \%prefresh .
+It suggests to the
+.I curses
+optimizer that only a single wide character is being output;
+a considerable performance benefit may be thus enjoyed.
+The location of the character
+.I wch
+written to the pad is used to populate the arguments to
+.BR \%prefresh .
 .SH RETURN VALUE
-Routines that return an integer return \fBERR\fR upon failure and \fBOK\fR
-(SVr4 only specifies "an integer value other than \fBERR\fR") upon successful
-completion.
+Functions that return an integer return \fBERR\fP upon failure and
+\fBOK\fP
+(SVr4 specifies only
+\*(``an integer value other than \fBERR\fP\*('')
+upon successful completion.
 .PP
-Routines that return pointers return \fBNULL\fR on error, and set \fBerrno\fR
-to \fBENOMEM\fR.
+Functions that return pointers return \fBNULL\fP on error,
+and set \fB\%errno\fP to \fB\%ENOMEM\fP.
 .PP
-X/Open does not define any error conditions.
+X/Open Curses does not specify any error conditions.
 In this implementation
 .RS 3
 .TP 5
-\fBprefresh\fP and \fBpnoutrefresh\fP
+\fB\%prefresh\fP and \fB\%pnoutrefresh\fP
 return an error
 if the window pointer is null, or
 if the window is not really a pad or
@@ -157,19 +191,19 @@ if the minimum coordinates are greater than the maximum.
 \fBpechochar\fP
 returns an error
 if the window is not really a pad, and the associated call
-to \fBwechochar\fP returns an error.
+to \fB\%wechochar\fP returns an error.
 .TP 5
 \fBpecho_wchar\fP
 returns an error
 if the window is not really a pad, and the associated call
-to \fBwecho_wchar\fP returns an error.
+to \fB\%wecho_wchar\fP returns an error.
 .RE
 .SH NOTES
-Note that \fBpechochar\fR may be a macro.
+\fB\%pechochar\fP may be a macro.
 .SH PORTABILITY
-BSD curses has no \fIpad\fP feature.
+BSD \fIcurses\fP has no \fIpad\fP feature.
 .PP
-SVr2 curses (1986) provided the \fBnewpad\fP and related functions,
+SVr2 \fIcurses\fP (1986) provided the \fB\%newpad\fP and related functions,
 documenting them in a single line each.
 SVr3 (1987) provided more extensive documentation.
 .PP
@@ -184,59 +218,63 @@ and select text from the pad.
 .PP
 The two uses may be related.
 .PP
-The XSI Curses standard, Issue 4 describes these functions,
+X/Open Curses, Issue 4 describes these functions,
 without significant change from the SVr3 documentation.
 It describes no error conditions.
-The behavior of \fBsubpad\fP if the parent window is not
+The behavior of \fB\%subpad\fP if the parent window is not
 a pad is undocumented,
 and is not checked by the vendor Unix implementations:
 .bP
-SVr4 curses sets a flag in the \fBWINDOW\fP structure in \fBnewpad\fP
-which tells if the window is a \fIpad\fP.
+SVr4 \fIcurses\fP sets a flag in the \fI\%WINDOW\fP structure in
+\fB\%newpad\fP which tells if the window is a \fIpad\fP.
 .IP
 However, it uses this information only in
-\fBwaddch\fP (to decide if it should call \fBwrefresh\fP) and
-\fBwscrl\fP (to avoid scrolling a pad),
-and does not check in \fBwrefresh\fP to ensure that the pad
+\fB\%waddch\fP (to decide if it should call \fB\%wrefresh\fP) and
+\fB\%wscrl\fP (to avoid scrolling a pad),
+and does not check in \fB\%wrefresh\fP to ensure that the pad
 is refreshed properly.
 .bP
-Solaris X/Open Curses checks if a window is a pad in \fBwnoutrefresh\fP,
+Solaris \fI\%xcurses\fP checks whether a window is a pad in
+\fB\%wnoutrefresh\fP,
 returning \fBERR\fP in that case.
 .IP
-However, it only sets the flag for subwindows if the parent window is a pad.
-Its \fBnewpad\fP function does not set this information.
+However,
+it only sets the flag for subwindows if the parent window is a pad.
+Its \fB\%newpad\fP function does not set this information.
 Consequently, the check will never fail.
 .IP
-It makes no comparable check in \fBpnoutrefresh\fP,
+It makes no comparable check in \fB\%pnoutrefresh\fP,
 though interestingly enough, a comment in the source code
 states that the lack of a check was an MKS extension.
 .bP
-NetBSD 7 curses
-sets a flag in the \fBWINDOW\fP structure for \fBnewpad\fP and \fBsubpad\fP,
-using this to help with the distinction between \fBwnoutrefresh\fP
-and \fBpnoutrefresh\fP.
+NetBSD 7 \fIcurses\fP
+sets a flag in the \fI\%WINDOW\fP structure
+for \fB\%newpad\fP and \fB\%subpad\fP,
+using this to help with the distinction between \fB\%wnoutrefresh\fP
+and \fB\%pnoutrefresh\fP.
 .IP
 It does not check for the case where a subwindow is created in
-a pad using \fBsubwin\fP or \fBderwin\fP.
+a pad using \fB\%subwin\fP or \fB\%derwin\fP.
 .IP
-The \fBdupwin\fP function returns a regular window when duplicating a pad.
-Likewise, \fBgetwin\fP always returns a window, even if the saved
+The \fB\%dupwin\fP function returns a regular window when duplicating a pad.
+Likewise, \fB\%getwin\fP always returns a window, even if the saved
 data was from a pad.
 .PP
 This implementation
 .bP
-sets a flag in the \fBWINDOW\fP structure for \fBnewpad\fP and \fBsubpad\fP,
+sets a flag in the \fI\%WINDOW\fP structure
+for \fB\%newpad\fP and \fB\%subpad\fP,
 .bP
-allows a \fBsubwin\fP or \fBderwin\fP call to succeed having a pad parent by
+allows a \fB\%subwin\fP or \fB\%derwin\fP call to succeed having a pad parent by
 forcing the subwindow to be a pad,
 .bP
-checks in both \fBwnoutrefresh\fP and \fBpnoutrefresh\fP to ensure
+checks in both \fB\%wnoutrefresh\fP and \fB\%pnoutrefresh\fP to ensure
 that pads and windows are handled distinctly, and
 .bP
-ensures that \fBdupwin\fP and \fBgetwin\fP treat
+ensures that \fB\%dupwin\fP and \fB\%getwin\fP treat
 pads versus windows consistently.
 .SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_refresh\fR(3X),
-\fBcurs_touch\fR(3X),
-\fBcurs_addch\fR(3X).
+\fB\%curses\fP(3X),
+\fB\%curs_addch\fP(3X),
+\fB\%curs_refresh\fP(3X),
+\fB\%curs_touch\fP(3X)
diff --git a/contrib/ncurses/man/curs_print.3x b/contrib/ncurses/man/curs_print.3x
index 8bde817d92f0..3694beffcca1 100644
--- a/contrib/ncurses/man/curs_print.3x
+++ b/contrib/ncurses/man/curs_print.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,19 +27,23 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_print.3x,v 1.16 2020/10/24 09:25:14 tom Exp $
-.TH curs_print 3X ""
+.\" $Id: curs_print.3x,v 1.38 2024/03/16 15:35:01 tom Exp $
+.TH curs_print 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
-\fBmcprint\fR \- ship binary data to printer
+\fB\%mcprint\fP \-
+write binary data to printer using \fIterminfo\fR capabilities
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBint mcprint(char *\fP\fIdata\fP\fB, int \fP\fIlen\fP\fB);\fR
+.nf
+\fB#include <curses.h>
+.PP
+\fBint mcprint(char *\fIdata\fP, int \fIlen\fP);
+.fi
 .SH DESCRIPTION
-This function uses the \fBmc5p\fR or \fBmc4\fR and \fBmc5\fR capabilities,
+This function uses the \fBmc5p\fP or \fBmc4\fP and \fBmc5\fP capabilities,
 if they are present, to ship given data to a printer attached to the terminal.
 .PP
-Note that the \fBmcprint\fR code has no way to do flow control with the printer
+Note that the \fB\%mcprint\fP code has no way
+to do flow control with the printer
 or to know how much buffering it has.
 Your application is responsible for
 keeping the rate of writes to the printer below its continuous throughput rate
@@ -49,24 +53,37 @@ Dot-matrix printers and
 rule of thumb is to sleep for a second after shipping each 80-character line.
 .
 .SH RETURN VALUE
-The \fBmcprint\fR function returns \fBERR\fR if the write operation aborted
+The \fB\%mcprint\fP function returns \fBERR\fP if the write operation aborted
 for some reason.
-In this case, \fBerrno\fP will contain either an error associated
+In this case, \fB\%errno\fP will contain either an error associated
 with \fBwrite\fP(2) or one of the following:
 .TP 5
-ENODEV
+\fBENODEV\fP
 Capabilities for printer redirection do not exist.
 .TP 5
-ENOMEM
+\fBENOMEM\fP
 Couldn't allocate sufficient memory to buffer the printer write.
 .PP
-When \fBmcprint\fR succeeds, it returns the number of characters actually
+When \fB\%mcprint\fP succeeds, it returns the number of characters actually
 sent to the printer.
+.SH EXTENSIONS
+\fB\%mcprint\fP was designed for
+\fB\%ncurses\fP(3X),
+and was not found in SVr4
+.IR curses ,
+4.4BSD
+.IR curses ,
+or any other previous curses implementation.
 .SH PORTABILITY
-The \fBmcprint\fR call was designed for \fBncurses\fR(3X), and is not found
-in SVr4 curses, 4.4BSD curses, or any other previous version of curses.
+Applications employing this
+.I \%ncurses
+extension should condition its use on the visibility of the
+.B \%NCURSES_VERSION
+preprocessor macro.
 .SH BUGS
-Padding in the \fBmc5p\fR, \fBmc4\fR and \fBmc5\fR capabilities will not be
-interpreted.
+Padding in the
+\fBmc5p\fP,
+\fBmc4\fP, and
+\fBmc5\fP capabilities is not interpreted.
 .SH SEE ALSO
-\fBcurses\fR(3X)
+\fB\%curses\fP(3X)
diff --git a/contrib/ncurses/man/curs_printw.3x b/contrib/ncurses/man/curs_printw.3x
index 4980517275d5..282536b363e0 100644
--- a/contrib/ncurses/man/curs_printw.3x
+++ b/contrib/ncurses/man/curs_printw.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,128 +27,179 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_printw.3x,v 1.28 2020/10/24 09:22:45 tom Exp $
-.TH curs_printw 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: curs_printw.3x,v 1.53 2024/04/20 19:18:18 tom Exp $
+.TH curs_printw 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.na
-.hy 0
 .SH NAME
-\fBprintw\fR,
-\fBwprintw\fR,
-\fBmvprintw\fR,
-\fBmvwprintw\fR,
-\fBvwprintw\fR, \fBvw_printw\fR \- print formatted output in \fBcurses\fR windows
-.ad
-.hy
+\fB\%printw\fP,
+\fB\%wprintw\fP,
+\fB\%mvprintw\fP,
+\fB\%mvwprintw\fP,
+\fB\%vwprintw\fP,
+\fB\%vw_printw\fP \-
+write formatted output to a \fIcurses\fR window
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBint printw(const char *\fP\fIfmt\fP\fB, ...);\fR
-.br
-\fBint wprintw(WINDOW *\fP\fIwin\fP\fB, const char *\fP\fIfmt\fP\fB, ...);\fR
-.br
-\fBint mvprintw(int \fP\fIy\fP\fB, int \fP\fIx\fP\fB, const char *\fP\fIfmt\fP\fB, ...);\fR
-.br
-\fBint mvwprintw(WINDOW *\fP\fIwin\fP\fB, int \fP\fIy\fP\fB, int \fP\fIx\fP\fB, const char *\fP\fIfmt\fP\fB, ...);\fR
-.br
-\fBint vw_printw(WINDOW *\fP\fIwin\fP\fB, const char *\fP\fIfmt\fP\fB, va_list \fP\fIvarglist\fP\fB);\fR
-.sp
-/* obsolete */
-.br
-\fBint vwprintw(WINDOW *\fP\fIwin\fP\fB, const char *\fP\fIfmt\fP\fB, va_list \fP\fIvarglist\fP\fB);\fR
+.nf
+\fB#include <curses.h>
+.PP
+\fBint printw(const char *\fIfmt\fP, ...);
+\fBint wprintw(WINDOW *\fIwin\fP, const char *\fIfmt\fP, ...);
+\fBint mvprintw(int \fIy\fP, int \fIx\fP, const char *\fIfmt\fP, ...);
+\fBint mvwprintw(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, const char *\fIfmt\fP, ...);
+.PP
+\fBint vw_printw(WINDOW *\fIwin\fP, const char *\fIfmt\fP, va_list \fIvarglist\fP);
+.PP
+\fI/* obsolete */\fP
+\fBint vwprintw(WINDOW *\fIwin\fP, const char *\fIfmt\fP, va_list \fIvarglist\fP);
+.fi
 .SH DESCRIPTION
-The \fBprintw\fR, \fBwprintw\fR, \fBmvprintw\fR and \fBmvwprintw\fR
-routines are analogous to \fBprintf\fR [see \fBprintf\fR(3)].
-In
-effect, the string that would be output by \fBprintf\fR is output
-instead as though \fBwaddstr\fR were used on the given window.
+\fB\%printw\fP,
+\fB\%wprintw\fP,
+\fB\%mvprintw\fP,
+and
+\fB\%mvwprintw\fP
+are analogous to \fI\%printf\fP(3).
+In effect,
+the string that would be output by \fI\%printf\fP(3) is instead output
+as though \fB\%waddstr\fP(3X) were used with
+.I win
+(or
+.BR \%stdscr )
+as its first argument.
 .PP
-The \fBvwprintw\fR and \fBvw_printw\fR routines are analogous
-to \fBvprintf\fR [see \fBprintf\fR(3)]
-and perform a \fBwprintw\fR using a variable argument list.
-The third argument is a \fBva_list\fR, a pointer to a
-list of arguments, as defined in \fB<stdarg.h>\fR.
+\fB\%vwprintw\fP
+and
+\fB\%vw_printw\fP are analogous to \fI\%vprintf\fP(3),
+and perform a \fB\%wprintw\fP using a variable argument list.
+The third argument is a \fI\%va_list\fP,
+a pointer to a list of arguments,
+as defined in \fI\%stdarg.h\fP.
 .SH RETURN VALUE
-Routines that return an integer return \fBERR\fR upon failure and \fBOK\fR
-(SVr4 only specifies "an integer value other than \fBERR\fR") upon successful
-completion.
+These functions return
+.B ERR
+upon failure and
+.B OK
+upon success.
 .PP
-X/Open defines no error conditions.
-In this implementation,
-an error may be returned if it cannot allocate enough memory for the
-buffer used to format the results.
-It will return an error if the window pointer is null.
+In
+.IR \%ncurses ,
+failure occurs if the library cannot allocate enough memory for the
+buffer into which the output is formatted,
+or if the window pointer
+.I win
+is null.
+.PP
+Functions prefixed with \*(``mv\*('' first perform cursor movement and
+fail if the position
+.RI ( y ,
+.IR x )
+is outside the window boundaries.
+.SH NOTES
+No wide character counterpart functions are defined by the
+\*(``wide\*(''
+.I \%ncurses
+configuration nor by any standard.
+To format and write a wide-character string to a
+.I curses
+window,
+consider using \fI\%swprintf\fP(3) and \fB\%waddwstr\fP(3X) or similar.
+.SH PORTABILITY
+X/Open Curses,
+Issue 4 describes these functions.
+It specifies no error conditions for them.
 .PP
-Functions with a \*(``mv\*('' prefix first perform a cursor movement using
-\fBwmove\fP, and return an error if the position is outside the window,
-or if the window pointer is null.
+.I \%ncurses
+defines \fB\%vw_printw\fP and \fB\%vwprintw\fP identically to support
+legacy applications.
+However,
+the latter is obsolete.
+.bP
+X/Open Curses,
+Issue 4 Version 2 (1996),
+marked \fB\%vwprintw\fP as requiring \fI\%varargs.h\fP and
+\*(``TO BE WITHDRAWN\*('',
+and specified \fB\%vw_printw\fP using the \fI\%stdarg.h\fP interface.
+.bP
+X/Open Curses, Issue 5, Draft 2
+(December 2007) marked \fBvwprintw\fP (along with
+\fBvwscanw\fP and the \fItermcap\fP interface) as withdrawn.
+After incorporating review comments,
+this became
+X/Open Curses, Issue 7 (2009).
+.bP
+.I \%ncurses
+provides \fB\%vwprintw\fP,
+but marks it as deprecated.
 .SH HISTORY
-While \fBprintw\fP was implemented in 4BSD,
-it was unused until 4.2BSD (which used it in games).
-That early version of curses was before the ANSI C standard.
-It did not use <varargs.h>, though that was available.
-In 1991 (a couple of years after SVr4 was generally available,
+While \fB\%printw\fP was implemented in 4BSD
+(November 1980),
+.\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=4BSD/usr/src/lib/\
+.\"   libcurses/printw.c
+it was unused until 4.2BSD
+(August 1983),
+which employed it for games.
+That early version of
+.I curses
+preceded the ANSI C standard of 1989.
+It did not use \fI\%varargs.h\fP,
+though that had been available since Seventh Edition Unix (1979).
+.\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/include/\
+.\"  varargs.h
+In 1991
+(a couple of years after SVr4 was generally available,
 and after the C standard was published),
 other developers updated the library,
-using <stdarg.h> internally in 4.4BSD curses.
+using \fI\%stdarg.h\fP internally in 4.4BSD
+.IR curses .
 Even with this improvement,
-BSD curses did not use function prototypes (or even declare
-functions) in the <curses.h> header until 1992.
+BSD
+.I curses
+did not use function prototypes
+(nor even declare functions)
+in \fI\%curses.h\fP until 1992.
 .PP
-SVr2 documented
-\fBprintw\fP,
-\fBwprintw\fP
-tersely as \*(``printf on \fIstdscr\fP\*('' and
-tersely as \*(``printf on \fIwin\fP\*('', respectively.
+SVr2 (1984) documented \fB\%printw\fP and \fB\%wprintw\fP tersely as
+\*(``printf on \fB\%stdscr\fP\*('' and
+\*(``printf on \fIwin\fP\*('',
+respectively.
 .PP
-SVr3 added
-\fBmvprintw\fP, and
-\fBmvwprintw\fP, with a three-line summary saying that they were analogous
-to \fBprintf\fP(3),
-explaining that the string which would be output from \fBprintf\fP(3) would
-instead be output using \fBwaddstr\fP on the given window.
-SVr3 also added \fBvwprintw\fP, saying that the third parameter
-is a \fBva_list\fP, defined in <varargs.h>,
-and referring the reader to the manual pages for \fIvarargs\fP and
-\fIvprintf\fP for detailed descriptions.
+SVr3 (1987) added \fB\%mvprintw\fP and \fB\%mvwprintw\fP,
+with a three-line summary asserting that they were analogous to
+\fI\%printf\fP(3),
+explaining that the string that \fI\%printf\fP(3) would write to the
+standard output stream would instead be output using \fB\%waddstr\fP to
+the given window.
+SVr3 also implemented \fB\%vwprintw\fP,
+describing its third parameter as a \fI\%va_list\fP,
+defined in \fI\%varargs.h\fP,
+and referred the reader to the manual pages for \fI\%varargs\fP and
+\fI\%vprintf\fP for detailed descriptions.
 .PP
-SVr4 added no new variations of \fBprintw\fP,
-but provided for using <varargs.h> or <stdarg.h> to define the \fBva_list\fP
-type.
+SVr4 (1989) introduced no new variations of \fI\%printw\fP,
+but provided for using either \fI\%varargs.h\fP or \fI\%stdarg.h\fP to
+define the \fI\%va_list\fP type.
+.\" either header declares "va_list", but only one can be used
 .PP
-X/Open Curses added \fBvw_printw\fP to replace \fBvwprintw\fP,
-stating that its \fBva_list\fP definition requires <stdarg.h>.
-.SH PORTABILITY
-In this implementation, \fBvw_printw\fP and \fBvwprintw\fP are equivalent,
-to support legacy applications.
-However, the latter (\fBvwprintw\fP) is obsolete:
-.bP
-The XSI Curses standard, Issue 4 described these functions.
-The function
-\fBvwprintw\fR is marked TO BE WITHDRAWN, and is to be replaced by a function
-\fBvw_printw\fR using the \fB<stdarg.h>\fR interface.
-.bP
-The Single Unix Specification, Version 2 states that
-\fBvw_printw\fR  is preferred to \fBvwprintw\fR since the latter requires
-including \fB<varargs.h>\fR, which
-cannot be used in the same file as \fB<stdarg.h>\fR.
-This implementation uses \fB<stdarg.h>\fR for both,
-because that header is included in \fB<curses.h\fR>.
-.bP
-X/Open Curses, Issue 5 (December 2007) marked \fBvwprintw\fP (along with
-\fBvwscanw\fP and the termcap interface) as withdrawn.
+X/Open Curses, Issue 4 (1995),
+defined \fB\%vw_printw\fP to replace \fB\%vwprintw\fP,
+stating that its \fI\%va_list\fP type is defined in \fI\%stdarg.h\fP.
 .SH SEE ALSO
-.na
-\fBcurses\fR(3X),
-\fBcurs_addstr\fR(3X),
-\fBcurs_scanw\fR(3X),
-\fBcurs_termcap\fP(3X),
-\fBprintf\fR(3),
-\fBvprintf\fR(3).
+\fB\%curses\fP(3X),
+\fB\%curs_addstr\fP(3X),
+\fB\%curs_scanw\fP(3X),
+\fB\%printf\fP(3),
+\fB\%vprintf\fP(3)
diff --git a/contrib/ncurses/man/curs_refresh.3x b/contrib/ncurses/man/curs_refresh.3x
index 4c4b8e7f28d0..ac81d1e6393e 100644
--- a/contrib/ncurses/man/curs_refresh.3x
+++ b/contrib/ncurses/man/curs_refresh.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2016 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,111 +27,113 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_refresh.3x,v 1.22 2020/10/24 09:43:49 tom Exp $
-.TH curs_refresh 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: curs_refresh.3x,v 1.46 2024/04/20 21:20:07 tom Exp $
+.TH curs_refresh 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.na
-.hy 0
 .SH NAME
-\fBdoupdate\fR,
-\fBredrawwin\fR,
-\fBrefresh\fR,
-\fBwnoutrefresh\fR,
-\fBwredrawln\fR,
-\fBwrefresh\fR \- refresh \fBcurses\fR windows and lines
-.ad
-.hy
+\fB\%doupdate\fP,
+\fB\%redrawwin\fP,
+\fB\%refresh\fP,
+\fB\%wnoutrefresh\fP,
+\fB\%wredrawln\fP,
+\fB\%wrefresh\fP \-
+refresh \fIcurses\fR windows or lines thereupon
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBint refresh(void);\fR
-.br
-\fBint wrefresh(WINDOW *\fP\fIwin\fP\fB);\fR
-.br
-\fBint wnoutrefresh(WINDOW *\fP\fIwin\fP\fB);\fR
-.br
-\fBint doupdate(void);\fR
-.sp
-\fBint redrawwin(WINDOW *\fP\fIwin\fP\fB);\fR
-.br
-\fBint wredrawln(WINDOW *\fP\fIwin\fP\fB, int \fP\fIbeg_line\fP\fB, int \fP\fInum_lines\fP\fB);\fR
-.br
+.nf
+\fB#include <curses.h>
+.PP
+\fBint refresh(void);
+\fBint wrefresh(WINDOW *\fIwin\fP);
+\fBint wnoutrefresh(WINDOW *\fIwin\fP);
+\fBint doupdate(void);
+.PP
+\fBint redrawwin(WINDOW *\fIwin\fP);
+\fBint wredrawln(WINDOW *\fIwin\fP, int \fIbeg_line\fP, int \fInum_lines\fP);
+.fi
 .SH DESCRIPTION
-.SS refresh/wrefresh
-The \fBrefresh\fR and \fBwrefresh\fR routines (or \fBwnoutrefresh\fR and
-\fBdoupdate\fR) must be called to get actual output to the terminal,
+.SS "refresh, wrefresh"
+The \fBrefresh\fP and \fBwrefresh\fP routines (or \fBwnoutrefresh\fP and
+\fBdoupdate\fP) must be called to get actual output to the terminal,
 as other routines merely manipulate data structures.
-The routine \fBwrefresh\fR copies
+The routine \fBwrefresh\fP copies
 the named window to the \fIphysical screen\fP,
 taking into account what is already there to do optimizations.
-The \fBrefresh\fR routine is the
-same, using \fBstdscr\fR as the default window.
-Unless \fBleaveok\fR has been
+The \fBrefresh\fP routine is the
+same, using \fBstdscr\fP as the default window.
+Unless \fBleaveok\fP(3X) has been
 enabled, the physical cursor of the terminal is left at the location of the
 cursor for that window.
-.SS wnoutrefresh/doupdate
-.PP
-The \fBwnoutrefresh\fR and \fBdoupdate\fR routines allow multiple updates with
-more efficiency than \fBwrefresh\fR alone.
+.SS "wnoutrefresh, doupdate"
+The \fBwnoutrefresh\fP and \fBdoupdate\fP routines allow multiple updates with
+more efficiency than \fBwrefresh\fP alone.
 In addition to all the window
-structures, \fBcurses\fR keeps two data structures representing the terminal
+structures, \fBcurses\fP keeps two data structures representing the terminal
 screen:
 .bP
-a \fIphysical screen\fP, describing what is actually on the screen, and
+a \fIphysical screen\fP,
+describing what is actually on the screen, and
 .bP
-a \fIvirtual screen\fP, describing what the programmer wants to have on the screen.
+a \fIvirtual screen\fP,
+describing what the programmer wants to have on the screen.
 .PP
-The routine \fBwrefresh\fR works by
+The routine \fBwrefresh\fP works by
 .bP
-first calling \fBwnoutrefresh\fR,
+first calling \fBwnoutrefresh\fP,
 which copies the named window to the \fIvirtual screen\fP, and
 .bP
-then calling \fBdoupdate\fR, which compares
+then calling \fBdoupdate\fP, which compares
 the \fIvirtual screen\fP to the \fIphysical screen\fP
 and does the actual update.
 .PP
 If the programmer wishes to output several windows at once, a series
-of calls to \fBwrefresh\fR results in alternating calls to \fBwnoutrefresh\fR
-and \fBdoupdate\fR, causing several bursts of output to the screen.
+of calls to \fBwrefresh\fP results in alternating calls to \fBwnoutrefresh\fP
+and \fBdoupdate\fP, causing several bursts of output to the screen.
 By first
-calling \fBwnoutrefresh\fR for each window, it is then possible to call
-\fBdoupdate\fR once, resulting in only one burst of output, with fewer total
+calling \fBwnoutrefresh\fP for each window, it is then possible to call
+\fBdoupdate\fP once, resulting in only one burst of output, with fewer total
 characters transmitted and less CPU time used.
 .PP
-If the \fIwin\fR argument to
-\fBwrefresh\fR is the \fIphysical screen\fP
-(i.e., the global variable \fBcurscr\fR),
+If the \fIwin\fP argument to
+\fBwrefresh\fP is the \fIphysical screen\fP
+(i.e., the global variable \fBcurscr\fP),
 the screen is immediately cleared and repainted from scratch.
 .PP
 The phrase \*(``copies the named window
 to the virtual screen\*('' above is ambiguous.
-What actually happens is that all \fItouched\fR (changed) lines in the window
+What actually happens is that all \fItouched\fP (changed) lines in the window
 are copied to the virtual screen.
 This affects programs that use overlapping
 windows; it means that if two windows overlap, you can refresh them in either
 order and the overlap region will be modified only when it is explicitly
 changed.
-(But see the section on \fBPORTABILITY\fR below for a warning about
+(But see the section on \fBPORTABILITY\fP below for a warning about
 exploiting this behavior.)
-.SS wredrawln/redrawwin
-.PP
-The \fBwredrawln\fR routine indicates to \fBcurses\fR that some screen lines
+.SS "wredrawln, redrawwin"
+The \fBwredrawln\fP routine indicates to \fBcurses\fP that some screen lines
 are corrupted and should be thrown away before anything is written over them.
 It touches the indicated lines (marking them changed).
-The routine \fBredrawwin\fR touches the entire window.
+The routine \fBredrawwin\fP touches the entire window.
 .SH RETURN VALUE
-Routines that return an integer return \fBERR\fR upon failure, and \fBOK\fR
-(SVr4 only specifies "an integer value other than \fBERR\fR") upon successful
-completion.
+These routines return the integer \fBERR\fP upon failure and \fBOK\fP
+(SVr4 specifies only
+\*(``an integer value other than \fBERR\fP\*('')
+upon successful completion.
 .PP
-X/Open does not define any error conditions.
+X/Open Curses does not specify any error conditions.
 In this implementation
 .RS 3
 .TP 5
@@ -145,19 +147,19 @@ returns an error
 if the associated call to \fBtouchln\fP returns an error.
 .RE
 .SH NOTES
-Note that \fBrefresh\fR and \fBredrawwin\fR may be macros.
+Note that \fBrefresh\fP and \fBredrawwin\fP may be macros.
 .SH PORTABILITY
-The XSI Curses standard, Issue 4 describes these functions.
+X/Open Curses, Issue 4 describes these functions.
 .PP
-Whether \fBwnoutrefresh\fR copies to the virtual screen the entire contents
+Whether \fBwnoutrefresh\fP copies to the virtual screen the entire contents
 of a window or just its changed portions has never been well-documented in
 historic curses versions (including SVr4).
 It might be unwise to rely on
 either behavior in programs that might have to be linked with other curses
 implementations.
-Instead, you can do an explicit \fBtouchwin\fR before the
-\fBwnoutrefresh\fR call to guarantee an entire-contents copy anywhere.
+Instead, you can do an explicit \fBtouchwin\fP before the
+\fBwnoutrefresh\fP call to guarantee an entire-contents copy anywhere.
 .SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_outopts\fR(3X)
-\fBcurs_variables\fR(3X).
+\fB\%curses\fP(3X),
+\fB\%curs_outopts\fP(3X)
+\fB\%curs_variables\fP(3X)
diff --git a/contrib/ncurses/man/curs_scanw.3x b/contrib/ncurses/man/curs_scanw.3x
index 1de9ad866839..409c297fb233 100644
--- a/contrib/ncurses/man/curs_scanw.3x
+++ b/contrib/ncurses/man/curs_scanw.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,143 +27,229 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_scanw.3x,v 1.28 2020/10/24 09:29:26 tom Exp $
-.TH curs_scanw 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: curs_scanw.3x,v 1.53 2024/04/20 19:18:18 tom Exp $
+.TH curs_scanw 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
 .SH NAME
-\fBscanw\fR,
-\fBwscanw\fR,
-\fBmvscanw\fR,
-\fBmvwscanw\fR,
-\fBvwscanw\fR, \fBvw_scanw\fR \- convert formatted input from a \fBcurses\fR window
+\fB\%scanw\fP,
+\fB\%wscanw\fP,
+\fB\%mvscanw\fP,
+\fB\%mvwscanw\fP,
+\fB\%vwscanw\fP,
+\fB\%vw_scanw\fP \-
+read formatted input from a \fIcurses\fR window
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBint scanw(const char *\fP\fIfmt\fP\fB, ...);\fR
-.br
-\fBint wscanw(WINDOW *\fP\fIwin\fP\fB, const char *\fP\fIfmt\fP\fB, ...);\fR
-.br
-\fBint mvscanw(int \fP\fIy\fP\fB, int \fP\fIx\fP\fB, const char *\fP\fIfmt\fP\fB, ...);\fR
-.br
-\fBint mvwscanw(WINDOW *\fP\fIwin\fP\fB, int \fP\fIy\fP\fB, int \fP\fIx\fP\fB, const char *\fP\fIfmt\fP\fB, ...);\fR
-.sp
-\fBint vw_scanw(WINDOW *\fP\fIwin\fP\fB, const char *\fP\fIfmt\fP\fB, va_list \fP\fIvarglist\fP\fB);\fR
-.sp
-/* obsolete */
-.br
-\fBint vwscanw(WINDOW *\fP\fIwin\fP\fB, const char *\fP\fIfmt\fP\fB, va_list \fP\fIvarglist\fP\fB);\fR
-.SH DESCRIPTION
-The \fBscanw\fR, \fBwscanw\fR and \fBmvscanw\fR routines are analogous to
-\fBscanf\fR [see \fBscanf\fR(3)].
-The effect of these routines is as though
-\fBwgetstr\fR were called on the window, and the resulting line used as input
-for \fBsscanf\fR(3).
-Fields which do not map to a variable in the \fIfmt\fR
-field are lost.
+.nf
+\fB#include <curses.h>
 .PP
-The \fBvwscanw\fR and \fBvw_scanw\fR routines are analogous to \fBvscanf\fR(3).
-They perform a \fBwscanw\fR using a variable argument list.
-The third argument is a \fIva_list\fR,
-a pointer to a list of arguments, as defined in \fB<stdarg.h>\fR.
-.SH RETURN VALUE
-\fBvwscanw\fR returns \fBERR\fR on failure and an integer equal to the
-number of fields scanned on success.
+\fBint scanw(const char *\fIfmt\fP, ...);
+\fBint wscanw(WINDOW *\fIwin\fP, const char *\fIfmt\fP, ...);
+\fBint mvscanw(int \fIy\fP, int \fIx\fP, const char *\fIfmt\fP, ...);
+\fBint mvwscanw(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, const char *\fIfmt\fP, ...);
 .PP
-Applications may use the return value from the \fBscanw\fR, \fBwscanw\fR,
-\fBmvscanw\fR and \fBmvwscanw\fR routines to determine the number of fields
-which were mapped in the call.
+\fBint vw_scanw(WINDOW *\fIwin\fP, const char *\fIfmt\fP, va_list \fIvarglist\fP);
 .PP
-Functions with a \*(``mv\*('' prefix first perform a cursor movement using
-\fBwmove\fP, and return an error if the position is outside the window,
-or if the window pointer is null.
-.SH HISTORY
-While \fBscanw\fP was implemented in 4BSD,
-none of the BSD releases used it until 4.4BSD (in a game).
-That early version of curses was before the ANSI C standard.
-It did not use <varargs.h>, though that was available.
-In 1991 (a couple of years after SVr4 was generally available,
-and after the C standard was published),
-other developers updated the library,
-using <stdarg.h> internally in 4.4BSD curses.
-Even with this improvement,
-BSD curses did not use function prototypes (or even declare
-functions) in the <curses.h> header until 1992.
+\fI/* obsolete */\fP
+\fBint vwscanw(WINDOW *\fIwin\fP, const char *\fIfmt\fP, va_list \fIvarglist\fP);
+.fi
+.SH DESCRIPTION
+\fB\%scanw\fP,
+\fB\%wscanw\fP,
+\fB\%mvscanw\fP,
+and
+\fB\%mvwscanw\fP
+are analogous to \fI\%scanf\fP(3).
+In effect,
+they call \fB\%wgetstr\fP(3X) with
+.I win
+(or
+.BR \%stdscr )
+as its first argument,
+then attempt conversion of the resulting string with \fI\%vsscanf\fP(3).
+Fields in the string that do not map to a variable in the \fIfmt\fP
+parameter are discarded.
 .PP
-SVr2 documented
-\fBscanw\fP,
-\fBwscanw\fP
-tersely as \*(``scanf through \fIstdscr\fP\*('' and
-tersely as \*(``scanf through \fIwin\fP\*('', respectively.
+\fB\%vwscanw\fP
+and
+\fB\%vw_scanw\fP are analogous to \fI\%vscanf\fP(3),
+and perform a \fB\%wscanw\fP using a variable argument list.
+The third argument is a \fI\%va_list\fP,
+a pointer to a list of arguments,
+as defined in \fI\%stdarg.h\fP.
+.SH RETURN VALUE
+These functions return
+.B ERR
+upon failure and otherwise a count of successful conversions;
+this quantity may be zero.
 .PP
-SVr3 added
-\fBmvscanw\fP, and
-\fBmvwscanw\fP, with a three-line summary saying that they were analogous
-to \fBscanf\fP(3),
-explaining that the string which would be output from \fBscanf\fP(3) would
-instead be output using \fBwaddstr\fP on the given window.
-SVr3 also added \fBvwscanw\fP, saying that the third parameter
-is a \fBva_list\fP, defined in <varargs.h>,
-and referring the reader to the manual pages for \fIvarargs\fP and
-\fIvprintf\fP for detailed descriptions.
-(Because the SVr3 documentation does not mention \fIvscanf\fP,
-that reference to \fIvprintf\fP may not be an error).
+In
+.IR \%ncurses ,
+failure occurs if \fI\%vsscanf\fP(3) returns
+\fBEOF\fP,
+or if the window pointer
+.I win
+is null.
 .PP
-SVr4 added no new variations of \fBscanw\fP,
-but provided for using <varargs.h> or <stdarg.h> to define the \fBva_list\fP
-type.
+Functions prefixed with \*(``mv\*('' first perform cursor movement and
+fail if the position
+.RI ( y ,
+.IR x )
+is outside the window boundaries.
+.SH NOTES
+No wide character counterpart functions are defined by the
+\*(``wide\*(''
+.I \%ncurses
+configuration nor by any standard.
+They are unnecessary:
+to retrieve and convert a wide-character string from a
+.I curses
+terminal keyboard,
+use these functions with the \fI\%scanf\fP(3) conversions \*(``%lc\*(''
+and \*(``%ls\*('' for wide characters and strings,
+respectively.
 .PP
-X/Open Curses added \fBvw_scanw\fP to replace \fBvwscanw\fP,
-stating that its \fBva_list\fP definition requires <stdarg.h>.
+.I \%ncurses
+implements \fI\%vsscanf\fP(3) internally if it is unavailable when the
+library is configured.
 .SH PORTABILITY
-In this implementation, \fBvw_scanw\fP and \fBvwscanw\fP are equivalent,
-to support legacy applications.
-However, the latter (\fBvwscanw\fP) is obsolete:
+X/Open Curses,
+Issue 4 describes these functions.
+It specifies no error conditions for them.
+.PP
+.I \%ncurses
+defines \fB\%vw_scanw\fP and \fB\%vwscanw\fP identically to support
+legacy applications.
+However,
+the latter is obsolete.
 .bP
-The XSI Curses standard, Issue 4 described these functions,
-noting that the function
-\fBvwscanw\fR is marked TO BE WITHDRAWN, and is to be replaced by a function
-\fBvw_scanw\fR using the \fB<stdarg.h>\fR interface.
+X/Open Curses,
+Issue 4 Version 2 (1996),
+marked \fB\%vwscanw\fP as requiring \fI\%varargs.h\fP and
+\*(``TO BE WITHDRAWN\*('',
+and specified \fB\%vw_scanw\fP using the \fI\%stdarg.h\fP interface.
 .bP
-The Single Unix Specification, Version 2 states that
-\fBvw_scanw\fR  is preferred to \fBvwscanw\fR since the latter requires
-including \fB<varargs.h>\fR, which
-cannot be used in the same file as \fB<stdarg.h>\fR.
-This implementation uses \fB<stdarg.h>\fR for both, because that header
-is included in \fB<curses.h\fR>.
+X/Open Curses,
+Issue 5,
+Draft 2 (December 2007) marked \fB\%vwscanw\fP (along with
+\fB\%vwscanw\fP and the \fItermcap\fP interface) as withdrawn.
+After incorporating review comments,
+this became
+X/Open Curses, Issue 7 (2009).
 .bP
-X/Open Curses, Issue 5 (December 2007) marked \fBvwscanw\fP (along with
-\fBvwprintw\fP and the termcap interface) as withdrawn.
-.LP
-Both XSI and The Single Unix Specification, Version 2 state that these
-functions return \fBERR\fP or \fBOK\fP.
+.I \%ncurses
+provides \fB\%vwscanw\fP,
+but marks it as deprecated.
+.PP
+X/Open Curses Issues 4 and 7 both state that these functions return
+\fBERR\fP or \fBOK\fP.
+This is likely an erratum.
 .bP
-Since the underlying \fBscanf\fR(3) can return the number of items scanned,
-and the SVr4 code was documented to use this feature,
-this is probably an editing error which was introduced in XSI,
-rather than being done intentionally.
+Since the underlying \fI\%scanf\fP(3) returns the number of successful
+conversions,
+and SVr4
+.I curses
+was documented to use this feature,
+this may have been an editorial solecism introduced by X/Open,
+rather than an intentional change.
 .bP
-This implementation returns the number of items scanned,
-for compatibility with SVr4 curses.
-As of 2018, NetBSD curses also returns the number of items scanned.
-Both ncurses and NetBSD curses call \fBvsscanf\fP to scan the string,
+This implementation retains compatibility with SVr4
+.IR curses .
+As of 2018,
+NetBSD
+.I curses
+also returns the number of successful conversions.
+Both
+.I \%ncurses\fP
+and NetBSD
+.I curses
+call \fI\%vsscanf\fP(3) to scan the string,
 which returns \fBEOF\fP on error.
 .bP
-Portable applications should only test if the return value is \fBERR\fP,
-since the \fBOK\fP value (zero) is likely to be misleading.
+Portable applications should test only if the return value is \fBERR\fP,
+and not compare it to \fBOK\fP,
+since that value (zero) might be misleading.
 .IP
-One possible way to get useful results would be to use a "%n" conversion
-at the end of the format string to ensure that something was processed.
+One portable way to get useful results would be to use a \*(``%n\*(''
+conversion at the end of the format string,
+and check the value of the corresponding variable to determine how many
+conversions succeeded.
+.SH HISTORY
+\fB\%scanw\fP was implemented in 4BSD
+(November 1980);
+.\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=4BSD/usr/src/lib/\
+.\"  libcurses/scanw.c
+that early version of
+.I curses
+preceded the ANSI C standard of 1989.
+The function was unused in Berkeley distributions for over ten years,
+until 4.4BSD,
+which employed it in a game.
+The 4BSD \fB\%scanw\fP did not use \fI\%varargs.h\fP,
+though that had been available since Seventh Edition Unix (1979).
+.\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/include/\
+.\"  varargs.h
+In 1991
+(a couple of years after SVr4 was generally available,
+and after the C standard was published),
+other developers updated the library,
+using \fI\%stdarg.h\fP internally in 4.4BSD
+.IR curses .
+Even with this improvement,
+BSD
+.I curses
+did not use function prototypes
+(nor even declare functions)
+in \fI\%curses.h\fP until 1992.
+.PP
+SVr2 (1984) documented \fB\%scanw\fP and \fB\%wscanw\fP tersely as
+\*(``scanf through \fB\%stdscr\fP\*('' and
+\*(``scanf through \fIwin\fP\*('',
+respectively.
+.PP
+SVr3 (1987) added
+\fB\%mvscanw\fP, and
+\fB\%mvwscanw\fP, stating
+.RS
+.PP
+\*(``[t]hese routines correspond to \fIscanf\fP(3S),
+as do their arguments and return values.
+\fB\%wgetstr\fP() is called on the window,
+and the resulting line is used as input for the scan.\*(''
+.RE
+.PP
+SVr3 also implemented \fB\%vwscanw\fP,
+describing its third parameter as a \fI\%va_list\fP,
+defined in \fI\%varargs.h\fP,
+and referred the reader to the manual pages for \fI\%varargs\fP and
+\fI\%vprintf\fP for detailed descriptions.
+(Because the SVr3 documentation does not mention \fI\%vscanf\fP,
+the reference to \fI\%vprintf\fP might not be an error).
+.PP
+SVr4 (1989) introduced no new variations of \fI\%scanw\fP,
+but provided for using either \fI\%varargs.h\fP or \fI\%stdarg.h\fP to
+define the \fI\%va_list\fP type.
+.\" either header declares "va_list", but only one can be used
+.PP
+X/Open Curses, Issue 4 (1995),
+defined \fI\%vw_scanw\fP to replace \fI\%vwscanw\fP,
+stating that its \fI\%va_list\fP type is defined in \fI\%stdarg.h\fP.
 .SH SEE ALSO
-.na
-\fBcurses\fR(3X),
-\fBcurs_getstr\fR(3X),
-\fBcurs_printw\fR(3X),
-\fBcurs_termcap\fP(3X),
-\fBscanf\fR(3).
+\fB\%curses\fP(3X),
+\fB\%curs_getstr\fP(3X),
+\fB\%curs_printw\fP(3X),
+\fB\%scanf\fP(3),
+\fB\%vscanf\fP(3)
diff --git a/contrib/ncurses/man/curs_scr_dump.3x b/contrib/ncurses/man/curs_scr_dump.3x
index 229acefd39d9..5f14a2287268 100644
--- a/contrib/ncurses/man/curs_scr_dump.3x
+++ b/contrib/ncurses/man/curs_scr_dump.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,89 +27,126 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_scr_dump.3x,v 1.16 2020/10/24 09:44:43 tom Exp $
-.TH curs_scr_dump 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: curs_scr_dump.3x,v 1.43 2024/04/20 18:54:36 tom Exp $
+.TH curs_scr_dump 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.na
-.hy 0
 .SH NAME
-\fBscr_dump\fR,
-\fBscr_restore\fR,
-\fBscr_init\fR,
-\fBscr_set\fR \- read (write) a \fBcurses\fR screen from (to) a file
-.ad
-.hy
+\fB\%scr_dump\fP,
+\fB\%scr_restore\fP,
+\fB\%scr_init\fP,
+\fB\%scr_set\fP \-
+read/write a \fIcurses\fR screen from/to a file
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBint scr_dump(const char *\fP\fIfilename\fP\fB);\fR
-.br
-\fBint scr_restore(const char *\fP\fIfilename\fP\fB);\fR
-.br
-\fBint scr_init(const char *\fP\fIfilename\fP\fB);\fR
-.br
-\fBint scr_set(const char *\fP\fIfilename\fP\fB);\fR
-.br
-.SH DESCRIPTION
-The \fBscr_dump\fR routine dumps the current contents
-of the \fIvirtual screen\fP
-to the file \fIfilename\fR.
+.nf
+\fB#include <curses.h>
 .PP
-The \fBscr_restore\fR routine sets the \fIvirtual screen\fP to the contents
-of \fIfilename\fR, which must have been written using \fBscr_dump\fR.
-The next call to \fBdoupdate\fR restores
-the \fIphysical screen\fP to the way it looked in the dump file.
+\fBint scr_dump(const char *\fIfilename\fP);
+\fBint scr_restore(const char *\fIfilename\fP);
+\fBint scr_init(const char *\fIfilename\fP);
+\fBint scr_set(const char *\fIfilename\fP);
+.fi
+.SH DESCRIPTION
+.I curses
+provides applications the ability to write the contents of the screen
+to a file and read them back.
+To read/write a window
+(rather than the whole screen)
+from/to a file,
+use \fB\%getwin\fP(3X) and
+\fB\%putwin\fP(3X),
+respectively.
+.SS scr_dump
+\fB\%scr_dump\fP writes to
+.I filename
+the contents of the virtual screen;
+see \fB\%curscr\fP(3X).
+.SS scr_restore
+\fB\%scr_restore\fP updates the virtual screen to contain the contents
+of
+.I filename
+(if it was validly written with \fB\%scr_dump\fP).
+No refresh is performed;
+after performing any further desired updates,
+call \fB\%doupdate\fP(3X) or similar.
+.SS scr_init
+\fB\%scr_init\fP reads
+.IR filename ,
+using it to initialize
+.I curses
+data structures describing the state of the terminal screen.
+If these data are valid,
+.I curses
+bases its next update of the screen on this information rather than
+clearing it and starting from scratch.
 .PP
-The \fBscr_init\fR routine reads in the contents of \fIfilename\fR and uses
-them to initialize the \fBcurses\fR data structures about what the terminal
-currently has on its screen.
-If the data is determined to be valid,
-\fBcurses\fR bases its next update of the screen on this information rather
-than clearing the screen and starting from scratch.
-\fBscr_init\fR is used
-after \fBinitscr\fR or a \fBsystem\fR call to share
-the screen with another process which has done a \fBscr_dump\fR after its
-\fBendwin\fR(3X) call.
-The data is declared invalid
+The data fail the validity check
 .bP
-if the terminfo capabilities \fBrmcup\fR and \fBnrrmc\fR exist, also
+if the terminal employs
+.I \%term\%info
+capabilities
+.B \%exit_ca_mode
+.RB ( \%rmcup )
+or
+.B \%non_rev_rmcup
+.RB ( \%nrrmc )
+are defined,
+or
 .bP
-if the terminal has been written to since the preceding \fBscr_dump\fR call.
+if
+.I curses
+knows that the terminal has been written to since the preceding
+\fB\%scr_dump\fP call.
 .PP
-The \fBscr_set\fR routine is a combination of \fBscr_restore\fR and
-\fBscr_init\fR.  It tells the program that the information in \fIfilename\fR is
+\fB\%scr_init\fP could be used after \fB\%initscr\fP(3X) or
+\fB\%system\fP(3) to share the screen with another process that has
+done a \fBscr_dump\fP after \fB\%endwin\fP(3X).
+.SS scr_set
+The \fBscr_set\fP routine is a combination of \fBscr_restore\fP and
+\fBscr_init\fP.  It tells the program that the information in \fIfilename\fP is
 what is currently on the screen, and also what the program wants on the screen.
 This can be thought of as a screen inheritance function.
-.PP
-To read (write) a window from (to) a file, use the \fBgetwin\fR and
-\fBputwin\fR routines [see \fBcurs_util\fR(3X)].
 .SH RETURN VALUE
-All routines return the integer \fBERR\fR upon failure and \fBOK\fR
-upon success.
+These functions return \fBOK\fP on success and \fBERR\fP on failure.
 .PP
-X/Open defines no error conditions.
+X/Open defines no failure conditions.
 In this implementation,
-each will return an error if the file cannot be opened.
+each function fails if it cannot open
+.IR filename .
 .SH NOTES
-Note that \fBscr_init\fR, \fBscr_set\fR, and \fBscr_restore\fR may be macros.
+\fB\%scr_init\fP,
+\fB\%scr_set\fP,
+and
+\fB\%scr_restore\fP may be macros.
 .SH PORTABILITY
-The XSI Curses standard, Issue 4, describes these functions (adding the const
-qualifiers).
+X/Open Curses,
+Issue 4 describes these functions.
+.PP
+.\" SVID 4, p. 529
+SVr4 omitted the
+.I \%const
+qualifiers.
 .PP
-The SVr4 docs merely say under \fBscr_init\fR that the dump data is also
-considered invalid "if the time-stamp of the tty is old" but do not define
-\*(``old\*(''.
+SVr4 documentation describes \fB\%scr_init\fP such that the dump data is
+also considered invalid \*(``if the time-stamp of the tty is old\*(''
+but does not define \*(``old\*(''.
 .SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_initscr\fR(3X),
-\fBcurs_refresh\fR(3X),
-\fBcurs_util\fR(3X),
-\fBscr_dump\fR(5),
-\fBsystem\fR(3)
+\fB\%curses\fP(3X),
+\fB\%curs_initscr\fP(3X),
+\fB\%curs_refresh\fP(3X),
+\fB\%curs_util\fP(3X),
+\fB\%system\fP(3),
+\fB\%scr_dump\fP(5)
diff --git a/contrib/ncurses/man/curs_scroll.3x b/contrib/ncurses/man/curs_scroll.3x
index d9e45f2d5bec..16d5a501094f 100644
--- a/contrib/ncurses/man/curs_scroll.3x
+++ b/contrib/ncurses/man/curs_scroll.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2006,2010 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,69 +27,111 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_scroll.3x,v 1.19 2020/10/24 09:45:48 tom Exp $
-.TH curs_scroll 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
-.na
-.hy 0
+.\" $Id: curs_scroll.3x,v 1.43 2024/04/20 18:54:36 tom Exp $
+.TH curs_scroll 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
+.de bP
+.ie n  .IP \(bu 4
+.el    .IP \(bu 2
+..
 .SH NAME
-\fBscroll\fR,
-\fBscrl\fR,
-\fBwscrl\fR \- scroll a \fBcurses\fR window
-.ad
-.hy
+\fB\%scroll\fP,
+\fB\%scrl\fP,
+\fB\%wscrl\fP \-
+scroll a \fIcurses\fR window
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBint scroll(WINDOW *\fP\fIwin\fP\fB);\fR
-.sp
-\fBint scrl(int \fP\fIn\fP\fB);\fR
-.br
-\fBint wscrl(WINDOW *\fP\fIwin\fP\fB, int \fP\fIn\fP\fB);\fR
-.br
-.SH DESCRIPTION
-The \fBscroll\fR routine scrolls the window up one line.
-This involves moving
-the lines in the window data structure.
-As an optimization, if the scrolling
-region of the window is the entire screen,
-the \fIphysical screen\fP may be scrolled at the same time.
+.nf
+\fB#include <curses.h>
+.PP
+\fBint scroll(WINDOW *\fIwin\fP);
 .PP
-For positive \fIn\fR, the \fBscrl\fR and \fBwscrl\fR routines scroll the
-window up \fIn\fR lines (line \fIi\fR+\fIn\fR becomes \fIi\fR); otherwise
-scroll the window down \fIn\fR lines.
-This involves moving the lines in the
-window character image structure.
-The current cursor position is not changed.
+\fBint scrl(int \fIn\fP);
+\fBint wscrl(WINDOW *\fIwin\fP, int \fIn\fP);
+.fi
+.SH DESCRIPTION
+\fBscroll\fP scrolls the given window up one line.
+That is,
+every visible line we might number
+.I i
+becomes line
+.IR i "\-1."
+The text of the top line in the window disappears and the bottom line
+is populated with blank characters;
+see \fB\%bkgd\fP(3X) or \fB\%bkgrnd\fP(3X).
+As an optimization,
+if the scrolling region of the window is the entire screen,
+the physical screen may be scrolled at the same time;
+see \fB\%curscr\fP(3X).
 .PP
-For these functions to work, scrolling must be enabled via \fBscrollok\fR.
-.SH RETURN VALUE
-These routines return \fBERR\fR upon failure, and \fBOK\fR (SVr4 only specifies
-"an integer value other than \fBERR\fR") upon successful completion.
+\fB\%scrl\fP and \fB\%wscrl\fP scroll
+.B \%stdscr
+or the specified window up or down depending on the sign of
+.IR n .
+.bP
+For positive
+.IR n ,
+line \fIi\fP+\fIn\fP becomes \fIi\fP (scrolling up);
+.bP
+for negative
+.IR n ,
+line \fIi\fP-\fIn\fP becomes \fIi\fP (scrolling down).
 .PP
-X/Open defines no error conditions.
+The cursor does not move.
+These functions perform no operation unless scrolling is enabled for the
+window via \fB\%scrollok\fP(3X).
+.SH "RETURN VALUE"
+These functions return
+.B ERR
+upon failure and
+.B OK
+upon success.
 .PP
-This implementation returns an error
-if the window pointer is null, or
-if scrolling is not enabled in the window, e.g., with \fBscrollok\fP.
+.I \%ncurses
+returns \fBERR\fP if scrolling is not enabled in the window,
+for example with \fB\%scrollok\fP(3X),
+or if the
+.I \%WINDOW
+pointer is null.
 .SH NOTES
-Note that \fBscrl\fR and \fBscroll\fR may be macros.
-.PP
-The SVr4 documentation says that the optimization of physically scrolling
-immediately if the scroll region is the entire screen \*(``is\*('' performed, not
-\*(``may be\*('' performed.
-This implementation deliberately does not guarantee
-that this will occur, to leave open the possibility of smarter
-optimization of multiple scroll actions on the next update.
+Unusually,
+there is no \fB\%wscroll\fP function;
+\fBscroll\fP behaves as one would expect \fB\%wscroll\fP to,
+accepting a \fI\%WINDOW\fP pointer argument.
 .PP
-Neither the SVr4 nor the XSI documentation specify whether the current
-attribute or
-current color-pair of blanks generated by the scroll function is zeroed.
-Under this implementation it is.
+\fB\%scrl\fP and \fB\%scroll\fP may be implemented as macros.
 .SH PORTABILITY
-The XSI Curses standard, Issue 4 describes these functions.
+X/Open Curses,
+Issue 4 describes these functions.
+It defines no error conditions.
+.PP
+SVr4 specifies only
+\*(``an integer value other than \fBERR\fP\*('' as a successful return
+value.
+.PP
+SVr4 indicates that the optimization of physically scrolling immediately
+if the scroll region is the entire screen \*(``is\*('' performed,
+not \*(``may be\*('' performed.
+.I \%ncurses
+deliberately does not guarantee that this will occur,
+to leave open the possibility of smarter optimization of multiple scroll
+actions on the next update.
+.PP
+Neither SVr4
+.I curses
+nor X/Open Curses specify whether the current attribute or current color
+pair of blanks generated by the scroll function are zeroed.
+.I \%ncurses
+does so.
 .SH SEE ALSO
-\fBcurses\fR(3X), \fBcurs_outopts\fR(3X)
+\fB\%curses\fP(3X),
+\fB\%curs_outopts\fP(3X)
diff --git a/contrib/ncurses/man/curs_slk.3x b/contrib/ncurses/man/curs_slk.3x
index a99be8f7c188..fbc718115434 100644
--- a/contrib/ncurses/man/curs_slk.3x
+++ b/contrib/ncurses/man/curs_slk.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,101 +27,96 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_slk.3x,v 1.37 2020/12/30 18:37:43 tom Exp $
-.TH curs_slk 3X ""
+.\" $Id: curs_slk.3x,v 1.71 2024/04/20 18:54:36 tom Exp $
+.TH curs_slk 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.na
-.hy 0
 .SH NAME
-\fBslk_init\fR,
-\fBslk_set\fR,
-\fBslk_wset\fR,
-\fBslk_refresh\fR,
-\fBslk_noutrefresh\fR,
-\fBslk_label\fR,
-\fBslk_clear\fR,
-\fBslk_restore\fR,
-\fBslk_touch\fR,
-\fBslk_attron\fR,
-\fBslk_attrset\fR,
-\fBslk_attroff\fR,
-\fBslk_attr_on\fR,
-\fBslk_attr_set\fR,
-\fBslk_attr_off\fR,
-\fBslk_attr\fR,
-\fBslk_color\fR,
-\fBextended_slk_color\fR \- \fBcurses\fR soft label routines
-.ad
-.hy
+\fB\%slk_init\fP,
+\fB\%slk_set\fP,
+\fB\%slk_wset\fP,
+\fB\%slk_refresh\fP,
+\fB\%slk_noutrefresh\fP,
+\fB\%slk_label\fP,
+\fB\%slk_clear\fP,
+\fB\%slk_restore\fP,
+\fB\%slk_touch\fP,
+\fB\%slk_attron\fP,
+\fB\%slk_attrset\fP,
+\fB\%slk_attroff\fP,
+\fB\%slk_attr_on\fP,
+\fB\%slk_attr_set\fP,
+\fB\%slk_attr_off\fP,
+\fB\%slk_attr\fP,
+\fB\%slk_color\fP,
+\fB\%extended_slk_color\fP \-
+\fIcurses\fR soft label key routines
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBint slk_init(int \fP\fIfmt\fP\fB);\fR
-.sp
-\fBint slk_set(int \fP\fIlabnum\fP\fB, const char *\fP\fIlabel\fP\fB, int \fP\fIfmt\fP\fB);\fR
-.br
-/* extension */
-.br
-\fBint slk_wset(int \fP\fIlabnum\fP\fB, const wchar_t *\fP\fIlabel\fP\fB, int \fP\fIfmt\fP\fB);\fR
-.sp
-\fBchar *slk_label(int \fP\fIlabnum\fP\fB);\fR
-.sp
-\fBint slk_refresh(void);\fR
-.br
-\fBint slk_noutrefresh(void);\fR
-.br
-\fBint slk_clear(void);\fR
-.br
-\fBint slk_restore(void);\fR
-.br
-\fBint slk_touch(void);\fR
-.sp
-\fBint slk_attron(const chtype \fP\fIattrs\fP\fB);\fR
-.br
-\fBint slk_attroff(const chtype \fP\fIattrs\fP\fB);\fR
-.br
-\fBint slk_attrset(const chtype \fP\fIattrs\fP\fB);\fR
-.br
-\fBint slk_attr_on(attr_t \fP\fIattrs\fP\fB, void* \fP\fIopts\fP\fB);\fR
-.br
-\fBint slk_attr_off(const attr_t \fP\fIattrs\fP\fB, void * \fP\fIopts\fP\fB);\fR
-.br
-\fBint slk_attr_set(const attr_t \fP\fIattrs\fP\fB, short \fP\fIpair\fP\fB, void* \fP\fIopts\fP\fB);\fR
-.sp
-\fBattr_t slk_attr(void);\fR
-.sp
-\fBint slk_color(short \fP\fIpair\fP\fB);\fR
-.br
-/* extension */
-.br
-\fBint extended_slk_color(int \fP\fIpair\fP\fB);\fR
+.nf
+\fB#include <curses.h>
+.PP
+\fBint slk_init(int \fIfmt\fP);
+.PP
+\fBint slk_set(int \fIlabnum\fP, const char *\fIlabel\fP, int \fIalign\fP);
+\fBint slk_wset(int \fIlabnum\fP, const wchar_t *\fIlabel\fP, int \fIalign\fP);
+.PP
+\fBchar *slk_label(int \fIlabnum\fP);
+.PP
+\fBint slk_refresh(void);
+\fBint slk_noutrefresh(void);
+\fBint slk_clear(void);
+\fBint slk_restore(void);
+\fBint slk_touch(void);
+.PP
+\fBint slk_attron(const chtype \fIattrs\fP);
+\fBint slk_attroff(const chtype \fIattrs\fP);
+\fBint slk_attrset(const chtype \fIattrs\fP);
+\fBint slk_attr_on(attr_t \fIattrs\fP, void *\fIopts\fP);
+\fBint slk_attr_off(const attr_t \fIattrs\fP, void *\fIopts\fP);
+\fBint slk_attr_set(const attr_t \fIattrs\fP, short \fIpair\fP, void*\fIopts\fP);
+\fI/* extension */
+\fBattr_t slk_attr(void);
+.PP
+\fBint slk_color(short \fIpair\fP);
+\fI/* extension */
+\fBint extended_slk_color(int \fIpair\fP);
+.fi
 .SH DESCRIPTION
-The slk* functions manipulate the set of soft function-key labels that exist on
-many terminals.
+These functions manipulate the soft function key labels that some
+hardware terminals support.
 For those terminals that do not have soft labels,
-\fBcurses\fR takes over the bottom line of \fBstdscr\fR, reducing the size of
-\fBstdscr\fR and the variable \fBLINES\fR.
-\fBcurses\fR standardizes on eight
-labels of up to eight characters each.
-In addition to this, the ncurses
-implementation supports a mode where it simulates 12 labels of up to five
-characters each.
-This is useful for PC-like enduser devices.
-ncurses simulates this mode by taking over up to two lines at
+\fIcurses\fP takes over the bottom line of \fB\%stdscr\fP,
+reducing its vertical size and the value of \fBLINES\fP by one.
+By default,
+\fIcurses\fP uses eight labels of up to eight characters each.
+.PP
+\fI\%ncurses\fP
+furthermore supports a mode comprising twelve labels of up to five
+characters each,
+following a convention associated with the IBM PC/AT keyboard.
+\fI\%ncurses\fP simulates this mode by taking over up to two lines at
 the bottom of the screen;
 it does not try to use any hardware support for this
 mode.
 .SS Initialization
-.PP
-The \fBslk_init\fR routine must be called before \fBinitscr\fR or \fBnewterm\fR
-is called.
-If \fBinitscr\fR eventually uses a line from \fBstdscr\fR to
+\fB\%slk_init\fP must be called before \fB\%initscr\fP or
+\fB\%newterm\fP.
+If \fB\%initscr\fP eventually uses a line from \fB\%stdscr\fP to
 emulate the soft labels,
-then \fIfmt\fR determines how the labels are arranged on the screen:
-.RS 3
+then \fIfmt\fP determines how the labels are arranged on the screen.
 .TP 3
 .B 0
 indicates a 3\-2\-3 arrangement of
@@ -135,85 +130,104 @@ indicates the PC-like 4\-4\-4 mode.
 .TP 3
 .B 3
 is again the PC-like 4\-4\-4 mode,
-but in addition an index line is generated, helping the user to
-identify the key numbers easily.
-.RE
+but in addition an index line is generated,
+helping the user to associate each label with its numbered function key.
+\fBLINES\fP and the vertical size of \fB\%stdscr\fP are further reduced.
 .SS Labels
-.PP
-The \fBslk_set\fR routine
-(and the \fBslk_wset\fR routine for the wide-character library)
-has three parameters:
-.RS 3
-.TP 5
+Populate the labels with normal strings
+(\fB\%slk_set\fP)
+or wide-character strings
+(\fB\%slk_wset\fP).
+Each function takes three parameters.
+.TP 8 \" "labnum" + 2n
 .I labnum
-is the label number, from \fB1\fR to \fB8\fR
-(12 for \fIfmt\fP in \fBslk_init\fP is \fB2\fP or \fB3\fP);
+is the label number, from \fB1\fP to \fB8\fP
+(12 if \fIfmt\fP in \fB\%slk_init\fP is \fB2\fP or \fB3\fP);
 .TP
 .I label
 is be the string to put on the label,
 up to eight
-(five for \fIfmt\fP in \fBslk_init\fP is \fB2\fP or \fB3\fP)
+(five if \fIfmt\fP in \fB\%slk_init\fP is \fB2\fP or \fB3\fP)
 characters in length.
-A null string or a null pointer sets up a blank label.
+A empty string or a null pointer sets up a blank label.
 .TP
-.I fmt
-is either
-\fB0\fR, \fB1\fR, or \fB2\fR, indicating whether the label is to be
-left-justified, centered, or right-justified, respectively, within the
-label.
-.RE
-.PP
-The \fBslk_label\fR routine returns the current label for label number
-\fIlabnum\fR, with leading and trailing blanks stripped.
-.SS Screen updates
-.PP
-The \fBslk_refresh\fR and \fBslk_noutrefresh\fR routines correspond to
-the \fBwrefresh\fR and \fBwnoutrefresh\fR routines.
+.I align
+is
+.BR 0 ,
+.BR 1 ,
+or
+.BR 2 ,
+aligning
+.I label
+to the left,
+center,
+or right,
+respectively,
+within the 8 (5) character cells housing it.
 .PP
-The \fBslk_clear\fR routine clears the soft labels from the screen.
+\fB\%slk_label\fP obtains the string assigned to label number
+\fIlabnum\fP,
+with any leading and trailing blanks stripped.
+.SS "Screen Updates"
+\fB\%slk_refresh\fP and \fB\%slk_noutrefresh\fP affect the soft key
+label lines as \fB\%wrefresh\fP and \fB\%wnoutrefresh\fP do the
+.I curses
+window.
 .PP
-The \fBslk_restore\fR routine restores the soft labels to the screen
-after a \fBslk_clear\fR has been performed.
+The \fB\%slk_clear\fP routine clears the soft labels from the screen.
 .PP
-The \fBslk_touch\fR routine forces all the soft labels to be output
-the next time a \fBslk_noutrefresh\fR is performed.
-.SS Video attributes
+The \fB\%slk_restore\fP routine restores the soft labels to the screen
+after a \fB\%slk_clear\fP has been performed.
 .PP
+The \fB\%slk_touch\fP routine forces all the soft labels to be output
+the next time a \fB\%slk_noutrefresh\fP is performed.
+.SS "Video Attributes"
 The
-\fBslk_attron\fR, \fBslk_attrset\fR, \fBslk_attroff\fR and \fBslk_attr\fR
+\fB\%slk_attron\fP,
+\fB\%slk_attrset\fP,
+\fB\%slk_attroff\fP,
+and
+\fB\%slk_attr\fP
 routines correspond to
-\fBattron\fR, \fBattrset\fR, \fBattroff\fR and \fBattr_get\fR, respectively.
-They have an effect only if soft labels are simulated on the bottom line of
-the screen.
-The default highlight for soft keys is A_STANDOUT (as in
-System V curses, which does not document this fact).
+\fB\%attron\fP,
+\fB\%attrset\fP,
+\fB\%attroff\fP,
+and
+\fB\%attr_get\fP,
+respectively.
+They have an effect only if soft labels are simulated on the bottom line
+of the screen.
+The default highlight for soft key labels is \fB\%A_STANDOUT\fP
+(as in System\ V \fIcurses\fP,
+which does not document this fact).
 .SS Colors
-.PP
-The \fBslk_color\fR routine corresponds to \fBcolor_set\fR.
+The \fB\%slk_color\fP routine corresponds to \fB\%color_set\fP.
 It has an effect only
 if soft labels are simulated on the bottom line of the screen.
 .PP
-Because \fBslk_color\fR accepts only \fBshort\fP (signed 16-bit integer) values,
-this implementation provides 
-\fBextended_slk_color\fR which accepts an integer value, e.g., 32-bits.
-.
+Because \fB\%slk_color\fP accepts
+only \fIshort\fP
+(signed 16-bit integer)
+values,
+this implementation provides
+\fB\%extended_slk_color\fP,
+which accepts an \fIint\fP value of at least 32 bits.
 .SH RETURN VALUE
-These routines return \fBERR\fR upon failure
-and \fBOK\fP (SVr4 specifies only "an integer value other than \fBERR\fR")
+Routines that return an integer return \fBERR\fP upon failure and
+\fBOK\fP
+(SVr4 specifies only
+\*(``an integer value other than \fBERR\fP\*('')
 upon successful completion.
 .PP
-X/Open defines no error conditions.
+X/Open Curses defines no error conditions.
+.PP
 In this implementation
 .RS 3
 .TP 5
-\fBslk_attr\fR
+\fBslk_attr\fP
 returns the attribute used for the soft keys.
 .TP 5
-.na
-.hy 0
 \fBslk_attroff\fP, \fBslk_attron\fP, \fBslk_clear\fP, \fBslk_noutrefresh\fP, \fBslk_refresh\fP, \fBslk_touch\fP
-.ad
-.hy
 return an error
 if the terminal or the softkeys were not initialized.
 .TP 5
@@ -224,19 +238,19 @@ if the terminal or the softkeys were not initialized.
 \fBslk_attr_set\fP
 returns an error
 if the terminal or the softkeys were not initialized, or
-the color pair is outside the range 0..COLOR_PAIRS\-1.
+the color pair is outside the range 0..\fBCOLOR_PAIRS\fP\-1.
 .TP 5
 \fBslk_color\fP
 returns an error
 if the terminal or the softkeys were not initialized, or
-the color pair is outside the range 0..COLOR_PAIRS\-1.
+the color pair is outside the range 0..\fBCOLOR_PAIRS\fP\-1.
 .TP 5
-\fBslk_init\fR
+\fBslk_init\fP
 returns an error
 if the format parameter is outside the range 0..3.
 .TP 5
-\fBslk_label\fR
-returns \fBNULL\fR on error.
+\fBslk_label\fP
+returns \fBNULL\fP on error.
 .TP 5
 \fBslk_set\fP
 returns an error
@@ -245,76 +259,121 @@ the \fIlabnum\fP parameter is outside the range of label counts, or
 if the format parameter is outside the range 0..2, or if
 memory for the labels cannot be allocated.
 .RE
-.SH HISTORY
-SVr3 introduced these functions:
-  slk_clear
-  slk_init
-  slk_label
-  slk_noutrefresh
-  slk_refresh
-  slk_restore
-  slk_set
-  slk_touch
-.PP
-SVr4 added these functions:
-  slk_attroff
-  slk_attron
-  slk_attrset
-  slk_start
-.PP
-X/Open Curses added these:
-  slk_attr_off
-  slk_attr_on
-  slk_attr_set
-  slk_color
-  slk_wset
+.SH NOTES
+Most applications would use \fB\%slk_noutrefresh\fP because a
+\fB\%wrefresh\fP is likely to follow soon.
 .SH EXTENSIONS
-.PP
-X/Open Curses documents the \fIopts\fP argument as reserved for future use,
+X/Open Curses documents the \fIopts\fP argument
+as reserved for future use,
 saying that it must be null.
-This implementation 
-uses that parameter in ABI 6 for the functions which have a color-pair
+This implementation
+uses that parameter in ABI 6 for the functions which have a color pair
 parameter to support extended color pairs.
 .PP
-For  functions  which modify the color, e.g., \fBslk_attr_set\fP,
-if \fIopts\fP is set it is treated as a pointer to \fBint\fP,
-and used to  set  the  color pair instead of the \fBshort\fP pair parameter.
-.SH NOTES
-Most applications would use \fBslk_noutrefresh\fR because a
-\fBwrefresh\fR is likely to follow soon.
+For functions which modify the color,
+e.g.,
+\fB\%slk_attr_set\fP,
+if \fIopts\fP is set it is treated as a pointer to \fIint\fP,
+and used to set the color pair instead of the \fIshort\fP pair
+parameter.
 .SH PORTABILITY
-The XSI Curses standard, Issue 4, described the soft-key functions,
-with some differences from SVr4 curses:
+X/Open Curses,
+Issue 4 describes these functions,
+with some differences from SVr4 \fIcurses\fP:
 .bP
-It added functions like the SVr4
-attribute-manipulation functions \fBslk_attron\fR,
-\fBslk_attroff\fR, \fBslk_attrset\fR,
-but which use \fBattr_t\fR parameters (rather than \fBchtype\fP),
+X/Open added functions like the SVr4 attribute-manipulation functions
+\fB\%slk_attron\fP,
+\fB\%slk_attroff\fP,
+and
+\fB\%slk_attrset\fP,
+but which use \fI\%attr_t\fP parameters
+(rather than \fI\%chtype\fP),
 along with a reserved \fIopts\fP parameter.
 .IP
-Two of these new functions (unlike the SVr4 functions) have no provision
-for color: \fBslk_attr_on\fP and \fBslk_attr_off\fP.
+Two of these new functions
+(unlike the SVr4 functions)
+have no provision for color:
+\fB\%slk_attr_on\fP and \fB\%slk_attr_off\fP.
+.IP
+The third function \%(\fBslk_attr_set\fP) has a color pair parameter.
+.bP
+It added \fIconst\fP qualifiers to parameters (unnecessarily),
+and
+.bP
+It added \fB\%slk_color\fP.
+.PP
+Although \fB\%slk_start\fP is declared in the \fIcurses\fP header file,
+it was not documented by SVr4 other than its presence in a list
+of libtermlib.so.1 symbols.
+Reading the source code (i.e., Illumos):
+.bP
+\fB\%slk_start\fP has two parameters:
+.RS
+.bP
+\fIng\fP (number of groups) and
+.bP
+\fIgp\fP (group pointer).
+.RE
+.bP
+Soft-key groups are an array of \fIng\fP integers.
+.bP
+In SVr4, \fB\%slk_init\fP calls \fB\%slk_start\fP passing a null for \fIgp\fP.
+For this case, \fB\%slk_start\fP uses the number of groups \fIng\fP
+(3 for the 3-2-3 layout, 2 for the 4-4 layout) which \fB\%slk_init\fP provided.
+.IP
+If \fIng\fP is neither 2 or 3,
+\fB\%slk_start\fP checks the terminfo \fBfln\fP (label_format) capability,
+interpreting that as a comma-separated list of numbers,
+e.g., \*(``3,2,3\*('' for the 3-2-3 layout.
 .IP
-The third function (\fBslk_attr_set\fP) has a color-pair parameter.
+Finally, if there is no \fBfln\fP capability,
+\fB\%slk_start\fP returns \fBERR\fP.
 .bP
-It added \fBconst\fR qualifiers to parameters (unnecessarily), and
+If \fB\%slk_start\fP is given a non-null \fIgp\fP,
+it copies the \fIng\fP elements of the group of soft-keys, up to 16.
+.IP
+If there are more than 16 elements, \fB\%slk_start\fP returns an error.
 .bP
-It added \fBslk_color\fP.
+The format codes \fB2\fP and \fB3\fP for \fB\%slk_init\fP
+were added by \fI\%ncurses\fP in 1996.
+PDCurses 2.4 added this feature in 2001.
 .PP
-The format codes \fB2\fR and \fB3\fR for \fBslk_init\fR and the
-function \fBslk_attr\fR are specific to ncurses.
+The function \fB\%slk_attr\fP was added by \fI\%ncurses\fP in 1996.
 .PP
 X/Open Curses does not specify a limit for the number of colors and
 color pairs which a terminal can support.
-However, in its use of \fBshort\fP for the parameters,
+However, in its use of \fIshort\fP for the parameters,
 it carries over SVr4's implementation detail for the compiled
 terminfo database, which uses signed 16-bit numbers.
 This implementation provides extended versions of those functions
-which use \fBshort\fP parameters,
+which use \fIint\fP parameters,
 allowing applications to use larger color- and pair-numbers.
+.SH HISTORY
+SVr3 introduced these functions:
+  \fBslk_clear\fP
+  \fBslk_init\fP
+  \fBslk_label\fP
+  \fBslk_noutrefresh\fP
+  \fBslk_refresh\fP
+  \fBslk_restore\fP
+  \fBslk_set\fP
+  \fBslk_touch\fP
+.PP
+SVr4 added these functions:
+  \fBslk_attroff\fP
+  \fBslk_attron\fP
+  \fBslk_attrset\fP
+  \fBslk_start\fP
+.PP
+X/Open Curses added these:
+  \fBslk_attr_off\fP
+  \fBslk_attr_on\fP
+  \fBslk_attr_set\fP
+  \fBslk_color\fP
+  \fBslk_wset\fP
 .SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_attr\fR(3X),
-\fBcurs_initscr\fR(3X),
-\fBcurs_refresh\fR(3X),
-\fBcurs_variables\fR(3X).
+\fB\%curses\fP(3X),
+\fB\%curs_attr\fP(3X),
+\fB\%curs_initscr\fP(3X),
+\fB\%curs_refresh\fP(3X),
+\fB\%curs_variables\fP(3X)
diff --git a/contrib/ncurses/man/curs_sp_funcs.3x b/contrib/ncurses/man/curs_sp_funcs.3x
index fd1c9b46bd31..e58a48e3caea 100644
--- a/contrib/ncurses/man/curs_sp_funcs.3x
+++ b/contrib/ncurses/man/curs_sp_funcs.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018-2020,2021 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 2010-2015,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,305 +27,201 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_sp_funcs.3x,v 1.24 2021/01/02 23:53:22 tom Exp $
-.TH curs_sp_funcs 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
-.na
-.hy 0
+.\" $Id: curs_sp_funcs.3x,v 1.50 2024/04/20 18:56:31 tom Exp $
+.TH curs_sp_funcs 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
 .SH NAME
-curs_sp_funcs \- \fBcurses\fR screen-pointer extension
-.ad
-.hy
+\fB\%curs_sp_funcs\fP \-
+\fIcurses\fR screen-pointer extension
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
 .nf
-.sp
-\fBint alloc_pair_sp(SCREEN* \fP\fIsp\fP\fB, int \fP\fIfg\fP\fB, int \fP\fIbg\fP\fB);\fR
-.br
-\fBint assume_default_colors_sp(SCREEN* \fP\fIsp\fP\fB, int \fP\fIfg\fP\fB, int \fP\fIbg\fP\fB);\fR
-.br
-\fBint baudrate_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBint beep_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBbool can_change_color_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBint cbreak_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBint color_content_sp(SCREEN* \fP\fIsp\fP\fB, short \fP\fIcolor\fP\fB, short* \fP\fIr\fP\fB, short* \fP\fIg\fP\fB, short* \fP\fIb\fP\fB);\fR
-.br
-\fBint curs_set_sp(SCREEN* \fP\fIsp\fP\fB, int \fP\fIvisibility\fP);\fR
-.br
-\fBint def_prog_mode_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBint def_shell_mode_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.sp
-\fBint define_key_sp(SCREEN* \fP\fIsp\fP\fB, const char * \fP\fIdefinition\fP\fB, int \fP\fIkeycode\fP\fB);\fR
-.br
-\fBint delay_output_sp(SCREEN* \fP\fIsp\fP\fB, int \fP\fIms\fP\fB);\fR
-.br
-\fBint doupdate_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBint echo_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBint endwin_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBchar erasechar_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBint extended_color_content_sp(SCREEN * \fP\fIsp\fP\fB, int \fP\fIcolor\fP\fB, int * \fP\fIr\fP\fB, int * \fP\fIg\fP\fB, int * \fP\fIb\fP\fB);\fR
-.br
-\fBint extended_pair_content_sp(SCREEN* \fP\fIsp\fP\fB, int \fP\fIpair\fP\fB, int * \fP\fIfg\fP\fB, int * \fP\fIbg\fP\fB);\fR
-.br
-\fBint extended_slk_color_sp(SCREEN* \fP\fIsp\fP\fB, int \fP\fIpair\fP\fB);\fR
-.br
-\fBvoid filter_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.sp
-\fBint find_pair_sp(SCREEN* \fP\fIsp\fP\fB, int \fP\fIfg\fP\fB, int \fP\fIbg\fP\fB);\fR
-.br
-\fBint flash_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBint flushinp_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBint free_pair_sp(SCREEN* \fP\fIsp\fP\fB, int \fP\fIpair\fP\fB);\fR
-.br
-\fBint get_escdelay_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBint getmouse_sp(SCREEN* \fP\fIsp\fP\fB, MEVENT* \fP\fBevent\fP\fB);\fR
-.br
-\fBWINDOW* getwin_sp(SCREEN* \fP\fIsp\fP\fB, FILE* \fP\fIfilep\fP\fB);\fR
-.br
-\fBint halfdelay_sp(SCREEN* \fP\fIsp\fP\fB, int \fP\fItenths\fP\fB);\fR
-.br
-\fBbool has_colors_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBbool has_ic_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.sp
-\fBbool has_il_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBint has_key_sp(SCREEN* \fP\fIsp\fP\fB, int \fP\fIch\fP\fB);\fR
-.br
-\fBbool has_mouse_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBint init_color_sp(SCREEN* \fP\fIsp\fP\fB, short \fP\fIcolor\fP\fB, short \fP\fIr\fP\fB, short \fP\fIg\fP\fB, short \fP\fIb\fP\fB);\fR
-.br
-\fBint init_extended_color_sp(SCREEN* \fP\fIsp\fP\fB, int \fP\fIcolor\fP\fB, int \fP\fIr\fP\fB, int \fP\fIg\fP\fB, int \fP\fIb\fP\fB);\fR
-.br
-\fBint init_extended_pair_sp(SCREEN* \fP\fIsp\fP\fB, int \fP\fIpair\fP\fB, int \fP\fIfg\fP\fB, int \fP\fIbg\fP\fB);\fR
-.br
-\fBint init_pair_sp(SCREEN* \fP\fIsp\fP\fB, short \fP\fIpair\fP\fB, short \fP\fIfg\fP\fB, short \fP\fIbg\fP\fB);\fR
-.br
-\fBint intrflush_sp(SCREEN* \fP\fIsp\fP\fB, WINDOW* \fP\fIwin\fP\fB, bool \fP\fIbf\fP\fB);\fR
-.br
-\fBbool is_term_resized_sp(SCREEN* \fP\fIsp\fP\fB, int \fP\fIlines\fP\fB, int \fP\fIcolumns\fP\fB);\fR
-.br
-\fBbool isendwin_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.sp
-\fBint key_defined_sp(SCREEN* \fP\fIsp\fP\fB, const char *\fP\fIdefinition\fP\fB);\fR
-.br
-\fBchar* keybound_sp(SCREEN* \fP\fIsp\fP\fB, int \fP\fIkeycode\fP\fB, int \fP\fIcount\fP\fB);\fR
-.br
-\fBNCURSES_CONST char * keyname_sp(SCREEN* \fP\fIsp\fP\fB, int \fP\fIc\fP\fB);\fR
-.br
-\fBint keyok_sp(SCREEN* \fP\fIsp\fP\fB, int \fP\fIkeycode\fP\fB, bool \fP\fIenable\fP\fB);\fR
-.br
-\fBchar killchar_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBchar* longname_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBint mcprint_sp(SCREEN* \fP\fIsp\fP\fB, char *\fP\fIdata\fP\fB, int \fP\fIlen\fP\fB);\fR
-.br
-\fBint mouseinterval_sp(SCREEN* \fP\fIsp\fP\fB, int \fP\fIerval\fP\fB);\fR
-.br
-\fBmmask_t mousemask_sp(SCREEN* \fP\fIsp\fP\fB, mmask_t \fP\fInewmask\fP\fB, mmask_t *\fP\fIoldmask\fP\fB);\fR
-.br
-\fBint mvcur_sp(SCREEN* \fP\fIsp\fP\fB, int \fP\fIoldrow\fP\fB, int \fP\fIoldcol\fP\fB, int \fP\fInewrow\fP\fB, int \fP\fInewcol\fP\fB);\fR
-.sp
-\fBint napms_sp(SCREEN* \fP\fIsp\fP\fB, int \fP\fIms\fP\fB);\fR
-.br
-\fBWINDOW* newpad_sp(SCREEN* \fP\fIsp\fP\fB, int \fP\fInrows\fP\fB, int \fP\fIncols\fP\fB);\fR
-.br
-\fBSCREEN* new_prescr(void);\fR
-.br
-\fBSCREEN* newterm_sp(SCREEN* \fP\fIsp\fP\fB, const char *\fP\fItype\fP\fB, FILE *\fP\fIoutfd\fP\fB, FILE *\fP\fIinfd\fP\fB);\fR
-.br
-\fBWINDOW* newwin_sp(SCREEN* \fP\fIsp\fP\fB, int \fP\fInlines\fP\fB, int \fP\fIncols\fP\fB, int \fP\fIbegin_y\fP\fB, int \fP\fIbegin_x\fP\fB);\fR
-.br
-\fBint nl_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBint nocbreak_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBint noecho_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBvoid nofilter_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBint nonl_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.sp
-\fBvoid noqiflush_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBint noraw_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBint pair_content_sp(SCREEN* \fP\fIsp\fP\fB, short \fP\fIpair\fP\fB, short* \fP\fIfg\fP\fB, short* \fP\fIbg\fP\fB);\fR
-.br
-\fBvoid qiflush_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBint raw_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBint reset_prog_mode_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBvoid reset_color_pairs_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBint reset_shell_mode_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBint resetty_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBint resize_term_sp(SCREEN* \fP\fIsp\fP\fB, int \fP\fIlines\fP\fB, int \fP\fIcolumns\fP\fB);\fR
-.sp
-\fBint resizeterm_sp(SCREEN* \fP\fIsp\fP\fB, int \fP\fIlines\fP\fB, int \fP\fIcolumns\fP\fB);\fR
-.br
-\fBint ripoffline_sp(SCREEN* \fP\fIsp\fP\fB, int \fP\fIline\fP\fB, int (*\fP\fIinit\fP\fB)(WINDOW* \fP\fIwin\fP\fB, int \fP\fIfmt\fP\fB));\fR
-.br
-\fBint savetty_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBint scr_init_sp(SCREEN* \fP\fIsp\fP\fB, const char *\fP\fIfilename\fP\fB);\fR
-.br
-\fBint scr_restore_sp(SCREEN* \fP\fIsp\fP\fB, const char *\fP\fIfilename\fP\fB);\fR
-.br
-\fBint scr_set_sp(SCREEN* \fP\fIsp\fP\fB, const char *\fP\fIfilename\fP\fB);\fR
-.br
-\fBint set_escdelay_sp(SCREEN* \fP\fIsp\fP\fB, int \fP\fIms\fP\fB);\fR
-.br
-\fBint set_tabsize_sp(SCREEN* \fP\fIsp\fP\fB, int \fP\fIcols\fP\fB);\fR
-.br
-\fBint slk_attr_set_sp(SCREEN* \fP\fIsp\fP\fB, const attr_t \fP\fIattrs\fP\fB, short \fP\fIpair\fP\fB, void*\fP\fIopts\fP\fB);\fR
-.sp
-\fBint slk_attrset_sp(SCREEN* \fP\fIsp\fP\fB, const chtype \fP\fIa\fP\fB);\fR
-.br
-\fBint slk_attroff_sp(SCREEN* \fP\fIsp\fP\fB, const chtype \fP\fIa\fP\fB);\fR
-.br
-\fBint slk_attron_sp(SCREEN* \fP\fIsp\fP\fB, const chtype \fP\fIa\fP\fB);\fR
-.br
-\fBattr_t slk_attr_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBint slk_clear_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBint slk_color_sp(SCREEN* \fP\fIsp\fP\fB, short \fP\fIpair\fP\fB);\fR
-.br
-\fBint slk_init_sp(SCREEN* \fP\fIsp\fP\fB, int \fP\fIfmt\fP\fB);\fR
-.br
-\fBchar* slk_label_sp(SCREEN* \fP\fIsp\fP\fB, int \fP\fIlabnum\fP\fB);\fR
-.br
-\fBint slk_noutrefresh_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBint slk_refresh_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.sp
-\fBint slk_restore_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBint slk_set_sp(SCREEN* \fP\fIsp\fP\fB, int \fP\fIlabnum\fP\fB, const char * \fP\fIlabel\fP\fB, int \fP\fIfmt\fP\fB);\fR
-.br
-\fBint slk_touch_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBint start_color_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBattr_t term_attrs_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBchtype termattrs_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBchar* termname_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBint typeahead_sp(SCREEN* \fP\fIsp\fP\fB, int \fP\fIfd\fP\fB);\fR
-.br
-\fBint unget_wch_sp(SCREEN* \fP\fIsp\fP\fB, const wchar_t \fP\fIwch\fP\fB);\fR
-.br
-\fBint ungetch_sp(SCREEN* \fP\fIsp\fP\fB, int \fP\fIch\fP\fB);\fR
-.sp
-\fBint ungetmouse_sp(SCREEN* \fP\fIsp\fP\fB,MEVENT * \fP\fBevent\fP\fB);\fR
-.br
-\fBint use_default_colors_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBvoid use_env_sp(SCREEN* \fP\fIsp\fP\fB, bool \fP\fIbf\fP\fB);\fR
-.br
-\fBint use_legacy_coding_sp(SCREEN* \fP\fIsp\fP\fB, int \fP\fIlevel\fP\fB);\fR
-.br
-\fBvoid use_tioctl_sp(SCREEN *\fP\fIsp\fP\fB, bool \fP\fIbf\fP\fB);\fR
-.br
-\fBint vid_attr_sp(SCREEN* \fP\fIsp\fP\fB, attr_t \fP\fIattrs\fP\fB, short \fP\fIpair\fP\fB, void * \fP\fIopts\fP\fB);\fR
-.br
-\fBint vid_puts_sp(SCREEN* \fP\fIsp\fP\fB, attr_t \fP\fIattrs\fP\fB, short \fP\fIpair\fP\fB, void * \fP\fIopts\fP\fB, NCURSES_SP_OUTC \fP\fIputc\fP\fB);\fR
-.br
-\fBint vidattr_sp(SCREEN* \fP\fIsp\fP\fB, chtype \fP\fIattrs\fP\fB);\fR
-.br
-\fBint vidputs_sp(SCREEN* \fP\fIsp\fP\fB, chtype \fP\fIattrs\fP\fB, NCURSES_SP_OUTC \fP\fIputc\fP\fB);\fR
-.br
-\fBwchar_t* wunctrl_sp(SCREEN* \fP\fIsp\fP\fB, cchar_t *\fP\fIch\fP\fB);\fR
-.sp
-\fB#include <form.h>\fR
-.sp
-\fBFORM* new_form_sp(SCREEN* \fP\fIsp\fP\fB, FIELD **\fP\fIfields\fP\fB);\fR
-.sp
-\fB#include <menu.h>\fR
-.sp
-\fBMENU* new_menu_sp(SCREEN* \fP\fIsp\fP\fB, ITEM **\fP\fIitems\fP\fB);\fR
-.sp
-\fB#include <panel.h>\fR
-.sp
-\fBPANEL* ceiling_panel(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBPANEL* ground_panel(SCREEN* \fP\fIsp\fP\fB);\fR
-.br
-\fBvoid update_panels_sp(SCREEN* \fP\fIsp\fP\fB);\fR
-.sp
-\fB#include <term.h>\fR
-.sp
-\fBint del_curterm_sp(SCREEN* \fP\fIsp\fP\fB, TERMINAL *\fP\fIoterm\fP\fB);\fR
-.br
-\fBint putp_sp(SCREEN* \fP\fIsp\fP\fB, const char *\fP\fIstr\fP\fB);\fR
-.br
-\fBint restartterm_sp(SCREEN* \fP\fIsp\fP\fB, NCURSES_CONST char*\fP\fIterm\fP\fB, int \fP\fIfiledes\fP\fB, int *\fP\fIerrret\fP\fB);\fR
-.br
-\fBTERMINAL* set_curterm_sp(SCREEN* \fP\fIsp\fP\fB, TERMINAL*\fP\fInterm\fP\fB);\fR
-.br
-\fBint tgetent_sp(SCREEN* \fP\fIsp\fP\fB, char *\fP\fIbp\fP\fB, const char *\fP\fIname\fP\fB);\fR
-.br
-\fBint tgetflag_sp(SCREEN* \fP\fIsp\fP\fB, const char *\fP\fIcapname\fP\fB);\fR
-.br
-\fBint tgetnum_sp(SCREEN* \fP\fIsp\fP\fB, const char *\fP\fIcapname\fP\fB);\fR
-.br
-\fBchar* tgetstr_sp(SCREEN* \fP\fIsp\fP\fB, const char *\fP\fIcapname\fP\fB, char **\fP\fIarea\fP\fB);\fR
-.br
-\fBchar* tgoto_sp(SCREEN* \fP\fIsp\fP\fB, const char *\fP\fIcapname\fP\fB, int \fP\fIcol\fP\fB, int \fP\fIrow\fP\fB);\fR
-.br
-\fBint tigetflag_sp(SCREEN* \fP\fIsp\fP\fB, const char *\fP\fIcapname\fP\fB);\fR
-.br
-\fBint tigetnum_sp(SCREEN* \fP\fIsp\fP\fB, const char *\fP\fIcapname\fP\fB);\fR
-.br
-\fBchar* tigetstr_sp(SCREEN* \fP\fIsp\fP\fB, const char *\fP\fIcapname\fP\fB);\fR
-.br
-/* may instead use 9 long parameters */
-.br
-\fBchar* tparm_sp(SCREEN* \fP\fIsp\fP\fB, const char *\fP\fIstr\fP\fB, ...);\fR
-.br
-\fBint tputs_sp(SCREEN* \fP\fIsp\fP\fB, const char *\fP\fIstr\fP\fB, int \fP\fIaffcnt\fP\fB, NCURSES_SP_OUTC \fP\fIputc\fP\fB);\fR
-.sp
-\fB#include <unctrl.h>\fR
-.sp
-\fBNCURSES_CONST char* unctrl_sp(SCREEN* \fP\fIsp\fP\fB, chtype \fP\fIc\fP\fB);\fR
-.ad
-.br
+\fB#include <curses.h>
+.PP
+\fBint alloc_pair_sp(SCREEN* \fIsp\fP, int \fIfg\fP, int \fIbg\fP);
+\fBint assume_default_colors_sp(SCREEN* \fIsp\fP, int \fIfg\fP, int \fIbg\fP);
+\fBint baudrate_sp(SCREEN* \fIsp\fP);
+\fBint beep_sp(SCREEN* \fIsp\fP);
+\fBbool can_change_color_sp(SCREEN* \fIsp\fP);
+\fBint cbreak_sp(SCREEN* \fIsp\fP);
+\fBint color_content_sp(SCREEN* \fIsp\fP, short \fIcolor\fP, short* \fIr\fP, short* \fIg\fP, short* \fIb\fP);
+\fBint curs_set_sp(SCREEN* \fIsp\fP, int \fIvisibility\fP);
+\fBint def_prog_mode_sp(SCREEN* \fIsp\fP);
+\fBint def_shell_mode_sp(SCREEN* \fIsp\fP);
+.PP
+\fBint define_key_sp(SCREEN* \fIsp\fP, const char * \fIdefinition\fP, int \fIkeycode\fP);
+\fBint delay_output_sp(SCREEN* \fIsp\fP, int \fIms\fP);
+\fBint doupdate_sp(SCREEN* \fIsp\fP);
+\fBint echo_sp(SCREEN* \fIsp\fP);
+\fBint endwin_sp(SCREEN* \fIsp\fP);
+\fBchar erasechar_sp(SCREEN* \fIsp\fP);
+\fBint erasewchar_sp(SCREEN* \fIsp\fP, wchar_t *\fIwc\fP);
+\fBint extended_color_content_sp(SCREEN * \fIsp\fP, int \fIcolor\fP, int * \fIr\fP, int * \fIg\fP, int * \fIb\fP);
+\fBint extended_pair_content_sp(SCREEN* \fIsp\fP, int \fIpair\fP, int * \fIfg\fP, int * \fIbg\fP);
+\fBint extended_slk_color_sp(SCREEN* \fIsp\fP, int \fIpair\fP);
+.PP
+\fBvoid filter_sp(SCREEN* \fIsp\fP);
+\fBint find_pair_sp(SCREEN* \fIsp\fP, int \fIfg\fP, int \fIbg\fP);
+\fBint flash_sp(SCREEN* \fIsp\fP);
+\fBint flushinp_sp(SCREEN* \fIsp\fP);
+\fBint free_pair_sp(SCREEN* \fIsp\fP, int \fIpair\fP);
+\fBint get_escdelay_sp(SCREEN* \fIsp\fP);
+\fBint getmouse_sp(SCREEN* \fIsp\fP, MEVENT* \fIevent\fP);
+\fBWINDOW* getwin_sp(SCREEN* \fIsp\fP, FILE* \fIfilep\fP);
+\fBint halfdelay_sp(SCREEN* \fIsp\fP, int \fItenths\fP);
+\fBbool has_colors_sp(SCREEN* \fIsp\fP);
+.PP
+\fBbool has_ic_sp(SCREEN* \fIsp\fP);
+\fBbool has_il_sp(SCREEN* \fIsp\fP);
+\fBint has_key_sp(SCREEN* \fIsp\fP, int \fIc\fP);
+\fBbool has_mouse_sp(SCREEN* \fIsp\fP);
+\fBint init_color_sp(SCREEN* \fIsp\fP, short \fIcolor\fP, short \fIr\fP, short \fIg\fP, short \fIb\fP);
+\fBint init_extended_color_sp(SCREEN* \fIsp\fP, int \fIcolor\fP, int \fIr\fP, int \fIg\fP, int \fIb\fP);
+\fBint init_extended_pair_sp(SCREEN* \fIsp\fP, int \fIpair\fP, int \fIfg\fP, int \fIbg\fP);
+\fBint init_pair_sp(SCREEN* \fIsp\fP, short \fIpair\fP, short \fIfg\fP, short \fIbg\fP);
+\fBint intrflush_sp(SCREEN* \fIsp\fP, WINDOW* \fIwin\fP, bool \fIbf\fP);
+\fBint is_cbreak_sp(SCREEN* \fIsp\fP);
+.PP
+\fBint is_echo_sp(SCREEN* \fIsp\fP);
+\fBint is_nl_sp(SCREEN* \fIsp\fP);
+\fBint is_raw_sp(SCREEN* \fIsp\fP);
+\fBbool is_term_resized_sp(SCREEN* \fIsp\fP, int \fIlines\fP, int \fIcolumns\fP);
+\fBbool isendwin_sp(SCREEN* \fIsp\fP);
+\fBint key_defined_sp(SCREEN* \fIsp\fP, const char *\fIdefinition\fP);
+\fBchar* keybound_sp(SCREEN* \fIsp\fP, int \fIkeycode\fP, int \fIcount\fP);
+\fBNCURSES_CONST char* keyname_sp(SCREEN* \fIsp\fP, int \fIc\fP);
+\fBint keyok_sp(SCREEN* \fIsp\fP, int \fIkeycode\fP, bool \fIenable\fP);
+\fBchar killchar_sp(SCREEN* \fIsp\fP);
+.PP
+\fBint killwchar_sp(SCREEN* \fIsp\fP, wchar_t *\fIwc\fP);
+\fBchar* longname_sp(SCREEN* \fIsp\fP);
+\fBint mcprint_sp(SCREEN* \fIsp\fP, char *\fIdata\fP, int \fIlen\fP);
+\fBint mouseinterval_sp(SCREEN* \fIsp\fP, int \fIerval\fP);
+\fBmmask_t mousemask_sp(SCREEN* \fIsp\fP, mmask_t \fInewmask\fP, mmask_t *\fIoldmask\fP);
+\fBint mvcur_sp(SCREEN* \fIsp\fP, int \fIoldrow\fP, int \fIoldcol\fP, int \fInewrow\fP, int \fInewcol\fP);
+\fBint napms_sp(SCREEN* \fIsp\fP, int \fIms\fP);
+\fBWINDOW* newpad_sp(SCREEN* \fIsp\fP, int \fInrows\fP, int \fIncols\fP);
+\fBSCREEN* new_prescr(void);
+\fBSCREEN* newterm_sp(SCREEN* \fIsp\fP, const char *\fItype\fP, FILE *\fIoutfd\fP, FILE *\fIinfd\fP);
+.PP
+\fBWINDOW* newwin_sp(SCREEN* \fIsp\fP, int \fInlines\fP, int \fIncols\fP, int \fIbegin_y\fP, int \fIbegin_x\fP);
+\fBint nl_sp(SCREEN* \fIsp\fP);
+\fBint nocbreak_sp(SCREEN* \fIsp\fP);
+\fBint noecho_sp(SCREEN* \fIsp\fP);
+\fBvoid nofilter_sp(SCREEN* \fIsp\fP);
+\fBint nonl_sp(SCREEN* \fIsp\fP);
+\fBvoid noqiflush_sp(SCREEN* \fIsp\fP);
+\fBint noraw_sp(SCREEN* \fIsp\fP);
+\fBint pair_content_sp(SCREEN* \fIsp\fP, short \fIpair\fP, short* \fIfg\fP, short* \fIbg\fP);
+\fBvoid qiflush_sp(SCREEN* \fIsp\fP);
+.PP
+\fBint raw_sp(SCREEN* \fIsp\fP);
+\fBvoid reset_color_pairs_sp(SCREEN* \fIsp\fP);
+\fBint reset_prog_mode_sp(SCREEN* \fIsp\fP);
+\fBint reset_shell_mode_sp(SCREEN* \fIsp\fP);
+\fBint resetty_sp(SCREEN* \fIsp\fP);
+\fBint resize_term_sp(SCREEN* \fIsp\fP, int \fIlines\fP, int \fIcolumns\fP);
+\fBint resizeterm_sp(SCREEN* \fIsp\fP, int \fIlines\fP, int \fIcolumns\fP);
+\fBint ripoffline_sp(SCREEN* \fIsp\fP, int \fIline\fP, int (*\fIinit\fP)(WINDOW* \fIwin\fP, int \fIfmt\fP));
+\fBint savetty_sp(SCREEN* \fIsp\fP);
+\fBint scr_init_sp(SCREEN* \fIsp\fP, const char *\fIfilename\fP);
+.PP
+\fBint scr_restore_sp(SCREEN* \fIsp\fP, const char *\fIfilename\fP);
+\fBint scr_set_sp(SCREEN* \fIsp\fP, const char *\fIfilename\fP);
+\fBint set_escdelay_sp(SCREEN* \fIsp\fP, int \fIms\fP);
+\fBint set_tabsize_sp(SCREEN* \fIsp\fP, int \fIcols\fP);
+\fBint slk_attrset_sp(SCREEN* \fIsp\fP, const chtype \fIa\fP);
+\fBint slk_attr_set_sp(SCREEN* \fIsp\fP, const attr_t \fIattrs\fP, short \fIpair\fP, void*\fIopts\fP);
+\fBint slk_attroff_sp(SCREEN* \fIsp\fP, const chtype \fIa\fP);
+\fBint slk_attron_sp(SCREEN* \fIsp\fP, const chtype \fIa\fP);
+\fBattr_t slk_attr_sp(SCREEN* \fIsp\fP);
+\fBint slk_clear_sp(SCREEN* \fIsp\fP);
+.PP
+\fBint slk_color_sp(SCREEN* \fIsp\fP, short \fIpair\fP);
+\fBint slk_init_sp(SCREEN* \fIsp\fP, int \fIfmt\fP);
+\fBchar* slk_label_sp(SCREEN* \fIsp\fP, int \fIlabnum\fP);
+\fBint slk_noutrefresh_sp(SCREEN* \fIsp\fP);
+\fBint slk_refresh_sp(SCREEN* \fIsp\fP);
+\fBint slk_restore_sp(SCREEN* \fIsp\fP);
+\fBint slk_set_sp(SCREEN* \fIsp\fP, int \fIlabnum\fP, const char * \fIlabel\fP, int \fIfmt\fP);
+\fBint slk_touch_sp(SCREEN* \fIsp\fP);
+\fBint start_color_sp(SCREEN* \fIsp\fP);
+\fBattr_t term_attrs_sp(SCREEN* \fIsp\fP);
+.PP
+\fBchtype termattrs_sp(SCREEN* \fIsp\fP);
+\fBchar* termname_sp(SCREEN* \fIsp\fP);
+\fBint typeahead_sp(SCREEN* \fIsp\fP, int \fIfd\fP);
+\fBint unget_wch_sp(SCREEN* \fIsp\fP, const wchar_t \fIwc\fP);
+\fBint ungetch_sp(SCREEN* \fIsp\fP, int \fIc\fP);
+\fBint ungetmouse_sp(SCREEN* \fIsp\fP, MEVENT* \fIevent\fP);
+\fBint use_default_colors_sp(SCREEN* \fIsp\fP);
+\fBvoid use_env_sp(SCREEN* \fIsp\fP, bool \fIbf\fP);
+\fBint use_legacy_coding_sp(SCREEN* \fIsp\fP, int \fIlevel\fP);
+\fBvoid use_tioctl_sp(SCREEN *\fIsp\fP, bool \fIbf\fP);
+.PP
+\fBint vid_attr_sp(SCREEN* \fIsp\fP, attr_t \fIattrs\fP, short \fIpair\fP, void * \fIopts\fP);
+\fBint vid_puts_sp(SCREEN* \fIsp\fP, attr_t \fIattrs\fP, short \fIpair\fP, void * \fIopts\fP, NCURSES_SP_OUTC \fIputc\fP);
+\fBint vidattr_sp(SCREEN* \fIsp\fP, chtype \fIattrs\fP);
+\fBint vidputs_sp(SCREEN* \fIsp\fP, chtype \fIattrs\fP, NCURSES_SP_OUTC \fIputc\fP);
+\fBwchar_t* wunctrl_sp(SCREEN* \fIsp\fP, cchar_t *\fIwch\fP);
+.PP
+\fB#include <form.h>
+.PP
+\fBFORM* new_form_sp(SCREEN* \fIsp\fP, FIELD **\fIfields\fP);
+.PP
+\fB#include <menu.h>
+.PP
+\fBMENU* new_menu_sp(SCREEN* \fIsp\fP, ITEM **\fIitems\fP);
+.PP
+\fB#include <panel.h>
+.PP
+\fBPANEL* ceiling_panel(SCREEN* \fIsp\fP);
+\fBPANEL* ground_panel(SCREEN* \fIsp\fP);
+\fBvoid update_panels_sp(SCREEN* \fIsp\fP);
+.PP
+\fB#include <term.h>
+.PP
+\fBint del_curterm_sp(SCREEN* \fIsp\fP, TERMINAL *\fIoterm\fP);
+\fBint putp_sp(SCREEN* \fIsp\fP, const char *\fIstr\fP);
+\fBint restartterm_sp(SCREEN* \fIsp\fP, NCURSES_CONST char*\fIterm\fP, int \fIfiledes\fP, int *\fIerrret\fP);
+\fBTERMINAL* set_curterm_sp(SCREEN* \fIsp\fP, TERMINAL*\fInterm\fP);
+\fBint tgetent_sp(SCREEN* \fIsp\fP, char *\fIbp\fP, const char *\fIname\fP);
+\fBint tgetflag_sp(SCREEN* \fIsp\fP, const char *\fIcapname\fP);
+\fBint tgetnum_sp(SCREEN* \fIsp\fP, const char *\fIcapname\fP);
+\fBchar* tgetstr_sp(SCREEN* \fIsp\fP, const char *\fIcapname\fP, char **\fIarea\fP);
+\fBchar* tgoto_sp(SCREEN* \fIsp\fP, const char *\fIcapname\fP, int \fIcol\fP, int \fIrow\fP);
+\fBint tigetflag_sp(SCREEN* \fIsp\fP, const char *\fIcapname\fP);
+.PP
+\fBint tigetnum_sp(SCREEN* \fIsp\fP, const char *\fIcapname\fP);
+\fBchar* tigetstr_sp(SCREEN* \fIsp\fP, const char *\fIcapname\fP);
+\fI/* tparm_sp may use 9 long parameters rather than being variadic */
+\fBchar* tparm_sp(SCREEN* \fIsp\fP, const char *\fIstr\fP, ...);
+\fBint tputs_sp(SCREEN* \fIsp\fP, const char *\fIstr\fP, int \fIaffcnt\fP, NCURSES_SP_OUTC \fIputc\fP);
+.PP
+\fB#include <unctrl.h>
+.PP
+\fBNCURSES_CONST char* unctrl_sp(SCREEN* \fIsp\fP, chtype \fIch\fP);
+.fi
 .SH DESCRIPTION
 This implementation can be configured to provide a set of functions which
 improve the ability to manage multiple screens.
-This feature can be added to any of the configurations supported by ncurses;
-it adds new entrypoints
+This feature can be added to any of the configurations supported by
+\fI\%ncurses\fP;
+it adds new symbols
 without changing the meaning of any of the existing ones.
-.PP
 .\" ***************************************************************************
-.SS IMPROVED FUNCTIONS
+.SS "Improved Functions"
 Most of the functions are new versions of existing functions.
 A parameter is added at the front of the parameter list.
-It is a SCREEN pointer.
+It is a \fISCREEN\fP pointer.
 .PP
 The existing functions all use the current screen,
 which is a static variable.
@@ -333,7 +229,7 @@ The extended functions use the specified screen,
 thereby reducing the number of variables which must be modified
 to update multiple screens.
 .\" ***************************************************************************
-.SS NEW FUNCTIONS
+.SS "New Functions"
 Here are the new functions:
 .TP 5
 ceiling_panel
@@ -349,8 +245,8 @@ With the screen-pointer extension,
 there are situations where it must create a current screen before
 the unextended library does.
 The \fBnew_prescr\fP function is used internally to handle these cases.
-It is also provided as an entrypoint to allow applications to customize
-the library initialization.
+It is also provided to allow applications to customize library
+initialization.
 .\" ***************************************************************************
 .SH NOTES
 This extension introduces some new names:
@@ -363,7 +259,8 @@ to make it useful for checking if the extension is provided.
 NCURSES_SP_NAME
 The new functions are named using the macro \fINCURSES_SP_NAME\fP,
 which hides the actual implementation.
-Currently this adds a \*(``_sp\*('' suffix to the name of the unextended function.
+Currently this adds a \*(``_sp\*('' suffix
+to the name of the unextended function.
 This manual page indexes the extensions showing the full name.
 However the proper usage of these functions uses the macro,
 to provide for the possibility of changing the naming convention
@@ -376,13 +273,12 @@ where an \fINCURSES_OUTC\fP is used in the unextended library.
 NCURSES_OUTC
 This is a function-pointer type used for the cases where a function passes
 characters to the output stream, e.g., \fBvidputs\fP(3X).
-.PP
 .SH PORTABILITY
-These routines are specific to ncurses.
+These routines are specific to \fI\%ncurses\fP.
 They were not supported on Version 7, BSD or System V implementations.
-It is recommended that any code depending on ncurses extensions
+It is recommended that any code depending on \fI\%ncurses\fP extensions
 be conditioned using \fINCURSES_SP_FUNCS\fP.
 .SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_opaque\fR(3X),
-\fBcurs_threads\fR(3X).
+\fB\%curses\fP(3X),
+\fB\%curs_opaque\fP(3X),
+\fB\%curs_threads\fP(3X)
diff --git a/contrib/ncurses/man/curs_termattrs.3x b/contrib/ncurses/man/curs_termattrs.3x
index ec5ec38499e0..dacd3b0f4d84 100644
--- a/contrib/ncurses/man/curs_termattrs.3x
+++ b/contrib/ncurses/man/curs_termattrs.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2015 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,115 +27,103 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_termattrs.3x,v 1.15 2020/02/02 23:34:34 tom Exp $
-.TH curs_termattrs 3X ""
+.\" $Id: curs_termattrs.3x,v 1.41 2024/04/20 21:20:07 tom Exp $
+.TH curs_termattrs 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
-\fBbaudrate\fR,
-\fBerasechar\fR,
-\fBerasewchar\fR,
-\fBhas_ic\fR,
-\fBhas_il\fR,
-\fBkillchar\fR,
-\fBkillwchar\fR,
-\fBlongname\fR,
-\fBterm_attrs\fR,
-\fBtermattrs\fR,
-\fBtermname\fR \- \fBcurses\fR environment query routines
+\fB\%baudrate\fP,
+\fB\%erasechar\fP,
+\fB\%erasewchar\fP,
+\fB\%has_ic\fP,
+\fB\%has_il\fP,
+\fB\%killchar\fP,
+\fB\%killwchar\fP,
+\fB\%longname\fP,
+\fB\%term_attrs\fP,
+\fB\%termattrs\fP,
+\fB\%termname\fP \-
+\fIcurses\fR environment query routines
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
+.nf
+\fB#include <curses.h>
 .PP
-\fBint baudrate(void);\fR
-.br
-\fBchar erasechar(void);\fR
-.br
-\fBint erasewchar(wchar_t *\fR\fIch\fR\fB);\fR
-.br
-\fBbool has_ic(void);\fR
-.br
-\fBbool has_il(void);\fR
-.br
-\fBchar killchar(void);\fR
-.br
-\fBint killwchar(wchar_t *\fR\fIch\fR\fB);\fR
-.br
-\fBchar *longname(void);\fR
-.br
-\fBattr_t term_attrs(void);\fR
-.br
-\fBchtype termattrs(void);\fR
-.br
-\fBchar *termname(void);\fR
-.br
+\fBint baudrate(void);
+\fBchar erasechar(void);
+\fBint erasewchar(wchar_t *\fIwc\fP);
+\fBbool has_ic(void);
+\fBbool has_il(void);
+\fBchar killchar(void);
+\fBint killwchar(wchar_t *\fIwc\fP);
+\fBchar *longname(void);
+\fBattr_t term_attrs(void);
+\fBchtype termattrs(void);
+\fBchar *termname(void);
+.fi
 .SH DESCRIPTION
 .SS baudrate
-The \fBbaudrate\fR routine returns the output speed of the terminal.
+The \fBbaudrate\fP routine returns the output speed of the terminal.
 The
-number returned is in bits per second, for example \fB9600\fR, and is an
+number returned is in bits per second, for example \fB9600\fP, and is an
 integer.
-.SS erasechar, erasewchar
+.SS "erasechar, erasewchar"
+The \fBerasechar\fP routine returns the user's current erase character.
 .PP
-The \fBerasechar\fR routine returns the user's current erase character.
-.PP
-The \fBerasewchar\fR routine stores the current erase character
-in the location referenced by \fIch\fR.
+The \fBerasewchar\fP routine stores the current erase character
+in the location referenced by \fIwc\fP.
 If no erase character has been defined, the routine fails
-and the location referenced by \fIch\fR is not changed.
-.SS has_is, has_il
-.PP
-The \fBhas_ic\fR routine is true if the terminal has insert- and delete-
+and the location referenced by \fIwc\fP is not changed.
+.SS "has_ic, has_il"
+The \fBhas_ic\fP routine is true if the terminal has insert- and delete-
 character capabilities.
 .PP
-The \fBhas_il\fR routine is true if the terminal has insert- and delete-line
+The \fBhas_il\fP routine is true if the terminal has insert- and delete-line
 capabilities, or can simulate them using scrolling regions.
 This might
 be used to determine if it would be appropriate to turn on physical
-scrolling using \fBscrollok\fR.
-.SS killchar, killwchar
-.PP
-The \fBkillchar\fR routine returns the user's current line kill character.
+scrolling using \fBscrollok\fP(3X).
+.SS "killchar, killwchar"
+The \fBkillchar\fP routine returns the user's current line kill character.
 .PP
-The \fBkillwchar\fR routine stores the current line-kill character
-in the location referenced by \fIch\fR.
+The \fBkillwchar\fP routine stores the current line-kill character
+in the location referenced by \fIwc\fP.
 If no line-kill character has been defined,
-the routine fails and the location referenced by \fIch\fR is not changed.
+the routine fails and the location referenced by \fIwc\fP is not changed.
 .SS longname
-.PP
-The \fBlongname\fR routine returns a pointer to a static area
+The \fBlongname\fP routine returns a pointer to a static area
 containing a verbose description of the current terminal.
 The maximum
 length of a verbose description is 128 characters.
 It is defined only
-after the call to \fBinitscr\fR or \fBnewterm\fR.  The area is
-overwritten by each call to \fBnewterm\fR and is not restored by
-\fBset_term\fR, so the value should be saved between calls to
-\fBnewterm\fR if \fBlongname\fR is going to be used with multiple
+after the call to \fBinitscr\fP or \fBnewterm\fP.  The area is
+overwritten by each call to \fBnewterm\fP and is not restored by
+\fBset_term\fP, so the value should be saved between calls to
+\fBnewterm\fP if \fBlongname\fP is going to be used with multiple
 terminals.
-.SS termattrs, term_attrs
-.PP
+.SS "termattrs, term_attrs"
 If a given terminal does not support a video attribute that an
-application program is trying to use, \fBcurses\fR may substitute a
+application program is trying to use, \fBcurses\fP may substitute a
 different video attribute for it.
-The \fBtermattrs\fR and \fBterm_attrs\fR functions
-return a logical \fBOR\fR of all video attributes supported by the
-terminal using \fIA_\fR and \fIWA_\fR constants respectively.
-This information is useful when a \fBcurses\fR program
+The \fBtermattrs\fP and \fBterm_attrs\fP functions
+return a logical \fBOR\fP of all video attributes supported by the
+terminal using \fBA_\fP and \fBWA_\fP constants respectively.
+This information is useful when a \fBcurses\fP program
 needs complete control over the appearance of the screen.
 .SS termname
-.PP
-The \fBtermname\fR routine returns the terminal name used by \fBsetupterm\fR.
+The \fBtermname\fP routine returns the terminal name used by \fBsetupterm\fP.
 .SH RETURN VALUE
-\fBlongname\fR and \fBtermname\fR return \fBNULL\fR on error.
+\fBlongname\fP and \fBtermname\fP return \fBNULL\fP on error.
 .PP
-Routines that return an integer return \fBERR\fR upon failure and \fBOK\fR
-(SVr4 only specifies "an integer value other than \fBERR\fR") upon successful
+Routines that return an integer return \fBERR\fP upon failure and \fBOK\fP
+(SVr4 only specifies "an integer value other than \fBERR\fP") upon successful
 completion.
 .SH NOTES
-Note that \fBtermattrs\fR may be a macro.
+Note that \fBtermattrs\fP may be a macro.
 .SH PORTABILITY
-The XSI Curses standard, Issue 4 describes these functions.
+X/Open Curses, Issue 4 describes these functions.
 It changes the
-return type of \fBtermattrs\fR to the new type \fBattr_t\fR.
-Most versions of curses truncate the result returned by \fBtermname\fR to
+return type of \fBtermattrs\fP to the new type \fBattr_t\fP.
+Most versions of curses truncate the result returned by \fBtermname\fP to
 14 characters.
 .SH SEE ALSO
-\fBcurses\fR(3X), \fBcurs_initscr\fR(3X), \fBcurs_outopts\fR(3X)
+\fB\%curses\fP(3X),
+\fB\%curs_initscr\fP(3X),
+\fB\%curs_outopts\fP(3X)
diff --git a/contrib/ncurses/man/curs_termcap.3x b/contrib/ncurses/man/curs_termcap.3x
index 35a8b4442f60..6bd2a66a0b55 100644
--- a/contrib/ncurses/man/curs_termcap.3x
+++ b/contrib/ncurses/man/curs_termcap.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018-2020,2021 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2017,2018 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,312 +27,521 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_termcap.3x,v 1.48 2021/01/09 11:07:15 tom Exp $
-.TH curs_termcap 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: curs_termcap.3x,v 1.85 2024/04/20 19:13:12 tom Exp $
+.TH curs_termcap 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.na
-.hy 0
-.ds n 5
+.
 .SH NAME
-\fBPC\fR,
-\fBUP\fR,
-\fBBC\fR,
-\fBospeed\fR,
-\fBtgetent\fR,
-\fBtgetflag\fR,
-\fBtgetnum\fR,
-\fBtgetstr\fR,
-\fBtgoto\fR,
-\fBtputs\fR \- \fBcurses\fR emulation of termcap
-.ad
-.hy
+\fB\%PC\fP,
+\fB\%UP\fP,
+\fB\%BC\fP,
+\fB\%ospeed\fP,
+\fB\%tgetent\fP,
+\fB\%tgetflag\fP,
+\fB\%tgetnum\fP,
+\fB\%tgetstr\fP,
+\fB\%tgoto\fP,
+\fB\%tputs\fP \-
+\fIcurses\fR emulation of \fItermcap\fR
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.br
-\fB#include <term.h>\fR
-.sp
-\fBextern char PC;\fR
-.br
-\fBextern char * UP;\fR
-.br
-\fBextern char * BC;\fR
-.br
-\fBextern @NCURSES_OSPEED@ ospeed;\fR
-.sp
-\fBint tgetent(char *\fP\fIbp\fP\fB, const char *\fP\fIname\fP\fB);\fR
-.br
-\fBint tgetflag(const char *\fP\fIid\fP\fB);\fR
-.br
-\fBint tgetnum(const char *\fP\fIid\fP\fB);\fR
-.br
-\fBchar *tgetstr(const char *\fP\fIid\fP\fB, char **\fP\fIarea\fP\fB);\fR
-.br
-\fBchar *tgoto(const char *\fP\fIcap\fP\fB, int \fP\fIcol\fP\fB, int \fP\fIrow\fP\fB);\fR
-.br
-\fBint tputs(const char *\fP\fIstr\fP\fB, int \fP\fIaffcnt\fP\fB, int (*\fP\fIputc\fP\fB)(int));\fR
-.br
-.SH DESCRIPTION
-These routines are included as a conversion aid for programs that use
-the \fItermcap\fR library.
-Their parameters are the same, but the
-routines are emulated using the \fIterminfo\fR database.
-Thus, they
-can only be used to query the capabilities of entries for which a
-terminfo entry has been compiled.
-.SS INITIALIZATION
+.nf
+\fB#include <curses.h>
+\fB#include <term.h>
 .PP
-The \fBtgetent\fR routine loads the entry for \fIname\fR.
-It returns:
+\fBchar PC;
+\fBchar * UP;
+\fBchar * BC;
+\fB@NCURSES_OSPEED@ ospeed;
+.PP
+\fBint tgetent(char *\fIbp\fP, const char *\fIname\fP);
+\fBint tgetflag(const char *\fIid\fP);
+\fBint tgetnum(const char *\fIid\fP);
+\fBchar *tgetstr(const char *\fIid\fP, char **\fIarea\fP);
+\fBchar *tgoto(const char *\fIcap\fP, int \fIcol\fP, int \fIrow\fP);
+\fBint tputs(const char *\fIstr\fP, int \fIaffcnt\fP, int (*\fIputc\fP)(int));
+.fi
+.SH DESCRIPTION
+.I \%ncurses
+provides the foregoing variables and functions as a compatibility layer
+for programs that use the \fItermcap\fP library.
+The API is the same,
+but behavior is emulated using the \fI\%term\%info\fP database.
+Thus,
+it can be used only to query the capabilities of terminal database
+entries for which a \fI\%term\%info\fP entry has been compiled.
+.SS Initialization
+\fB\%tgetent\fP loads the terminal database entry for \fIname\fP;
+see \fBterm\fP(7).
+This must be done before calling any of the other functions.
+It returns
 .RS 3
-.TP 3
+.TP 5 \" "-1" + 2n + adjust for PDF
 1
 on success,
-.TP 3
+.TP
 0
 if there is no such entry
-(or that it is a generic type, having too little information for curses
-applications to run), and
-.TP 3
+(or if the matching entry describes a generic terminal,
+having too little information for
+.I curses
+applications to run),
+and
+.TP
 \-1
-if the terminfo database could not be found.
+if the \fI\%term\%info\fP database could not be found.
 .RE
 .PP
-This differs from the \fItermcap\fP library in two ways:
+This implementation differs from those of historical \fItermcap\fP
+libraries.
 .RS 3
 .bP
-The emulation ignores the buffer pointer \fIbp\fR.
-The \fItermcap\fP library would store a copy of the terminal
+.I \%ncurses
+ignores the buffer pointer \fIbp\fP,
+as do other \fItermcap\fP implementations conforming to portions of
+X/Open Curses now withdrawn.
+The BSD \fItermcap\fP library would store a copy of the terminal type
 description in the area referenced by this pointer.
-However, ncurses stores its terminal descriptions in compiled
-binary form, which is not the same thing.
+\fI\%term\%info\fP stores terminal type descriptions in compiled form,
+which is not the same thing.
 .bP
-There is a difference in return codes.
-The \fItermcap\fP library does not check if the terminal
-description is marked with the \fIgeneric\fP capability,
-or if the terminal description has cursor-addressing.
+The meanings of the return values differ.
+The BSD \fItermcap\fP library does not check whether the terminal type
+description includes the
+.B \%generic
+.RB ( gn )
+capability,
+nor whether the terminal type description supports an addressable
+cursor,
+a property essential for any \fIcurses\fP implementation to operate.
 .RE
-.SS CAPABILITY VALUES
-.PP
-The \fBtgetflag\fR routine gets the boolean entry for \fIid\fR,
+.SS "Retrieving Capability Values"
+\fB\%tgetflag\fP reports the Boolean entry for \fIid\fP,
 or zero if it is not available.
 .PP
-The \fBtgetnum\fR routine gets the numeric entry for \fIid\fR,
+\fB\%tgetnum\fP obtains the numeric entry for \fIid\fP,
 or \-1 if it is not available.
 .PP
-The \fBtgetstr\fR routine returns the string entry for \fIid\fR,
-or zero if it is not available.
-Use \fBtputs\fR to output the returned string.
-The \fIarea\fP parameter is used as follows:
+\fB\%tgetstr\fP returns the string entry for \fIid\fP,
+or
+.B NULL
+if it is not available.
+Use \fB\%tputs\fP to output the string returned.
+The
+.I area
+parameter is used as follows.
 .RS 3
 .bP
 It is assumed to be the address of a pointer to a buffer managed by the
 calling application.
 .bP
-However, ncurses checks to ensure that \fBarea\fP is not NULL,
-and also that the resulting buffer pointer is not NULL.
-If either check fails, the \fIarea\fP parameter is ignored.
+However,
+\fI\%ncurses\fP checks to ensure that
+.I area
+is not
+.BR NULL ,
+and also that the resulting buffer pointer is not
+.BR NULL .
+If either check fails,
+.I area
+is ignored.
 .bP
-If the checks succeed, ncurses also copies the return value to
-the buffer pointed to by \fIarea\fR,
-and the \fIarea\fR value will be updated to point past the null ending
-this value.
+If the checks succeed,
+\fI\%ncurses\fP also copies the return value to the buffer pointed to by
+\fIarea\fP,
+and the library updates
+.I area
+to point past the null character terminating this value.
 .bP
-The return value itself is an address in the terminal description which
-is loaded into memory.
+The return value itself is an address in the terminal type description
+loaded into memory.
 .RE
-.PP
-Only the first two characters of the \fBid\fR parameter of
-\fBtgetflag\fR,
-\fBtgetnum\fR and
-\fBtgetstr\fR are compared in lookups.
-.SS FORMATTING CAPABILITIES
-.PP
-The \fBtgoto\fR routine expands the given capability using the parameters.
+.SS "Applying String Capabilities"
+String capabilities can be parameterized;
+see subsection \*(``Parameterized Strings\*('' in  \fB\%terminfo\fP(5).
+\fB\%tgoto\fP applies its second and third arguments to the parametric
+placeholders in the capability stored in the first argument.
 .bP
-Because the capability may have padding characters,
-the output of \fBtgoto\fP should be passed to \fBtputs\fR
-rather than some other output function such as \fBprintf\fP.
+The capability may contain padding specifications;
+see subsection \*(``Delays and Padding\*('' of \fB\%terminfo\fP(5).
+The output of \fB\%tgoto\fP should thus be passed to \fB\%tputs\fP
+rather than some other output function such as \fI\%printf\fP(3).
 .bP
-While \fBtgoto\fP is assumed to be used for the two-parameter
+While \fB\%tgoto\fP is assumed to be used for the two-parameter
 cursor positioning capability,
-termcap applications also use it for single-parameter capabilities.
+\fItermcap\fP applications also use it for single-parameter
+capabilities.
 .IP
-Doing this shows a quirk in \fBtgoto\fP: most hardware
-terminals use cursor addressing with \fIrow\fP first,
-but the original developers of the termcap interface chose to
-put the \fIcolumn\fP parameter first.
-The \fBtgoto\fP function swaps the order of parameters.
-It does this also for calls requiring only a single parameter.
-In that case, the first parameter is merely a placeholder.
+Doing so reveals a quirk in \fB\%tgoto\fP:
+most hardware terminals use cursor addressing with \fIrow\fP first,
+but the original developers of the \fItermcap\fP interface chose to
+put the \fIcol\fP (column) parameter first.
+The \fB\%tgoto\fP function swaps the order of its parameters.
+It does this even for calls requiring only a single parameter.
+In that case,
+the first parameter is merely a placeholder.
 .bP
-Normally the ncurses library is compiled with terminfo support.
-In that case, \fBtgoto\fP uses \fBtparm\fP(3X) (a more capable formatter).
+Normally the \fI\%ncurses\fP library is compiled without
+full \fI\%termcap\fP support.
+In that case,
+\fB\%tgoto\fP uses an internal version of \fB\%tparm\fP(3X)
+(a more capable function).
 .IP
-However, \fBtparm\fP is not a \fItermcap\fP feature,
-and portable \fItermcap\fP applications should not rely upon its availability.
-.PP
-The \fBtputs\fR routine is described on the \fBcurs_terminfo\fR(3X) manual
-page.
-It can retrieve capabilities by either termcap or terminfo name.
-.SS GLOBAL VARIABLES
+Because it uses \fB\%tparm\fP internally,
+\fB\%tgoto\fP is able to use some \fI\%term\%info\fP features,
+but not all.
+In particular,
+it allows only numeric parameters;
+\fB\%tparm\fP supports string parameters.
+.IP
+However,
+\fB\%tparm\fP is not a \fItermcap\fP feature,
+and portable \fItermcap\fP applications should not rely upon its
+availability.
 .PP
+\fB\%tputs\fP is described in \fB\%curs_terminfo\fP(3X).
+It can retrieve capabilities by either \fItermcap\fP or
+\fI\%term\%info\fP code.
+.SS "Global Variables"
 The variables
-\fBPC\fR,
-\fBUP\fR and
-\fBBC\fR
-are set by \fBtgetent\fR to the terminfo entry's data for
-\fBpad_char\fR,
-\fBcursor_up\fR and
-\fBbackspace_if_not_bs\fR,
+\fBPC\fP,
+\fBUP\fP and
+\fBBC\fP
+are set by \fB\%tgetent\fP to the \fI\%term\%info\fP entry's data for
+\fB\%pad_char\fP,
+\fB\%cursor_up\fP and
+\fB\%backspace_if_not_bs\fP,
 respectively.
-\fBUP\fR is not used by ncurses.
-\fBPC\fR is used in the \fBtdelay_output\fR function.
-\fBBC\fR is used in the \fBtgoto\fR emulation.
-The variable \fBospeed\fR is set by ncurses in a system-specific coding
-to reflect the terminal speed.
-.
-.SH RETURN VALUE
-Except where explicitly noted,
-routines that return an integer return \fBERR\fR upon failure and \fBOK\fR
-(SVr4 only specifies "an integer value other than \fBERR\fR") upon successful
-completion.
+\fBUP\fP is not used by \fI\%ncurses\fP.
+\fBPC\fP is used by \fB\%delay_output\fP(3X).
+\fBBC\fP is used by \fB\%tgoto\fP emulation.
+The variable \fB\%ospeed\fP is set by \fI\%ncurses\fP using a
+system-specific encoding to indicate the terminal's data rate.
+.SS "Releasing Memory"
+The \fItermcap\fP functions provide no means of freeing memory,
+because legacy \fItermcap\fP implementations used only the buffer
+areas provided by the caller via \fB\%tgetent\fP and \fB\%tgetstr\fP.
+Those buffers are unused in \fI\%term\%info\fP.
 .PP
-Routines that return pointers return \fBNULL\fR on error.
-.SH BUGS
-If you call \fBtgetstr\fR to fetch \fBca\fR or any other parameterized string,
-be aware that it will be returned in terminfo notation, not the older and
-not-quite-compatible termcap notation.
-This will not cause problems if all
-you do with it is call \fBtgoto\fR or \fBtparm\fR, which both expand
-terminfo-style strings as terminfo.
-(The \fBtgoto\fR function, if configured to support termcap, will check
-if the string is indeed terminfo-style by looking for "%p" parameters or
-"$<..>" delays, and invoke a termcap-style parser if the string does not
-appear to be terminfo).
+By contrast,
+\fI\%term\%info\fP allocates memory.
+It uses \fB\%setupterm\fP(3X) to obtain the data used by \fB\%tgetent\fP
+and the functions that retrieve capability values.
+One could use
+.RS
+.EX
+del_curterm(cur_term);
+.EE
+.RE
+to free this memory,
+but there is an additional complication with \fI\%ncurses\fP.
+It uses a fixed-size pool of storage locations,
+one per value of the terminal name parameter given to \fB\%tgetent\fP.
+The \fIscreen\fP(1) program relies upon this arrangement to improve its
+performance.
 .PP
-Because terminfo conventions for representing padding in string capabilities
-differ from termcap's, \fBtputs("50");\fR will put out a literal \*(``50\*('' rather
-than busy-waiting for 50 milliseconds.
-Cope with it.
+An application that uses only the \fItermcap\fP functions,
+not the higher level
+.I \%curses
+API,
+could release the memory using \fB\%del_curterm\fP(3X),
+because the pool is freed using other functions;
+see \fB\%curs_memleaks\fP(3X).
+.SH "RETURN VALUE"
+The return values of
+\fB\%tgetent\fP,
+\fB\%tgetflag\fP,
+\fB\%tgetname\fP,
+and
+\fB\%tgetstr\fP
+are documented above.
 .PP
-Note that termcap has nothing analogous to terminfo's \fBsgr\fR string.
-One consequence of this is that termcap applications assume \fRme\fR
-(terminfo \fBsgr0\fR) does not reset the alternate character set.
-This implementation checks for, and modifies the data shown to the
-termcap interface to accommodate termcap's limitation in this respect.
+\fB\%tgoto\fP returns
+.B NULL
+on error.
+Error conditions include:
+.bP
+uninitialized state
+(\fB\%tgetent\fP was not called successfully),
+.bP
+.I cap
+being a null pointer,
+.bP
+.I cap
+referring to a canceled capability,
+.bP
+.I cap
+being a capability with string-valued parameters
+(a \fI\%term\%info\fP-only feature),
+and
+.bP
+.I cap
+being a capability with more than two parameters.
+.PP
+See \fB\%curs_terminfo\fP(3X) regarding \fB\%tputs\fP.
+.SH NOTES
+\fI\%ncurses\fP compares only the first two characters of the \fIid\fP
+parameter of
+\fB\%tgetflag\fP,
+\fB\%tgetnum\fP,
+and
+\fB\%tgetstr\fP to the capability names in the database.
 .SH PORTABILITY
+These functions are no longer standardized
+(and the variables never were);
+\fI\%ncurses\fP provides them to support legacy applications.
+They should not be used in new programs.
 .SS Standards
-These functions are provided for supporting legacy applications,
-and should not be used in new programs:
 .bP
-The XSI Curses standard, Issue 4 describes these functions.
-However, they
-are marked TO BE WITHDRAWN and may be removed in future versions.
+X/Open Curses, Issue 4, Version 2 (1996),
+describes these functions,
+marking them as
+\*(``TO BE WITHDRAWN\*(''.
 .bP
-X/Open Curses, Issue 5 (December 2007) marked the termcap interface
-(along with \fBvwprintw\fP and \fBvwscanw\fP) as withdrawn.
+X/Open Curses, Issue 7 (2009) marks the \fItermcap\fP interface
+(along with \fB\%vwprintw\fP and \fB\%vwscanw\fP) as withdrawn.
 .PP
-Neither the XSI Curses standard nor the SVr4 man pages documented the return
-values of \fBtgetent\fR correctly, though all three were in fact returned ever
-since SVr1.
-In particular, an omission in the XSI Curses documentation has been
-misinterpreted to mean that \fBtgetent\fR returns \fBOK\fR or \fBERR\fR.
+Neither X/Open Curses nor the SVr4 man pages documented the return
+values of \fB\%tgetent\fP correctly,
+though all three shown here were in fact returned ever since SVr1.
+In particular,
+an omission in the X/Open Curses specification has been misinterpreted
+to mean that \fB\%tgetent\fP returns \fBOK\fP or \fBERR\fP.
 Because the purpose of these functions is to provide compatibility with
-the \fItermcap\fR library, that is a defect in XCurses, Issue 4, Version 2
-rather than in ncurses.
-.SS Compatibility with BSD Termcap
-.PP
-External variables are provided for support of certain termcap applications.
-However, termcap applications' use of those variables is poorly documented,
-e.g., not distinguishing between input and output.
-In particular, some applications are reported to declare and/or
-modify \fBospeed\fR.
+the \fItermcap\fP library,
+that is a defect in X/Open Curses, Issue 4, Version 2
+rather than in \fI\%ncurses\fP.
+.SS "Compatibility with BSD \fItermcap\fP"
+Externally visible variables are provided for support of certain
+\fItermcap\fP applications.
+However,
+their correct usage is poorly documented;
+for example,
+it is unclear when reading and writing them is meaningful.
+In particular,
+some applications are reported to declare and/or modify \fB\%ospeed\fP.
 .PP
-The comment that only the first two characters of the \fBid\fR parameter
-are used escapes many application developers.
-The original BSD 4.2 termcap library (and historical relics thereof)
-did not require a trailing null NUL on the parameter name passed
-to \fBtgetstr\fP, \fBtgetnum\fP and \fBtgetflag\fP.
-Some applications assume that the termcap interface does not require
-the trailing NUL for the parameter name.
-Taking into account these issues:
+The constraint that only the first two characters of the \fIid\fP
+parameter are used escapes many application developers.
+The BSD \fItermcap\fP library did not require a trailing null character
+on the capability identifier passed to \fB\%tgetstr\fP,
+\fB\%tgetnum\fP,
+and
+\fB\%tgetflag\fP.
+.\" See <https://minnie.tuhs.org/cgi-bin/utree.pl?file=2BSD/src/\
+.\"   termlib/termcap.c>.
+Some applications thus assume that the \fItermcap\fP interface does not
+require the trailing null character for the capability identifier.
 .bP
-As a special case,
-\fBtgetflag\fP matched against a single-character identifier
-provided that was at the end of the terminal description.
-You should not rely upon this behavior in portable programs.
-This implementation disallows matches against single-character capability names.
-.bP
-This implementation disallows matches by the termcap interface against
-extended capability names which are longer than two characters.
+.I \%ncurses
+disallows matches by the \fItermcap\fP interface against extended
+capability names that are longer than two characters;
+see \fB\%user_caps\fP(5).
 .PP
-The BSD termcap function \fBtgetent\fP returns the text of a termcap
-entry in the buffer passed as an argument.
-This library (like other terminfo implementations) does not store
-terminal descriptions as text.
+The BSD \fItermcap\fP function \fB\%tgetent\fP returns the text of a
+\fItermcap\fP entry in the buffer passed as an argument.
+This library,
+like other \fI\%term\%info\fP implementations,
+does not store terminal type descriptions as text.
 It sets the buffer contents to a null-terminated string.
-.SS Other Compatibility
-This library includes a termcap.h header,
-for compatibility with other implementations.
-But the header is rarely used because the other implementations
-are not strictly compatible.
+.SS "Header File"
+This library includes a \fI\%termcap.h\fP header for compatibility with
+other implementations,
+but the header is rarely used because the other implementations are not
+strictly compatible.
+.SH HISTORY
+.\" See https://www.oreilly.com/openbook/opensources/book/kirkmck.html
+.\" for much BSD release history.
+Bill Joy originated a forerunner of \fItermcap\fP called
+\*(``ttycap\*('',
+dated September 1977,
+and released in 1BSD
+(March 1978).
+.\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=1BSD/s7/ttycap.c
+.\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=1BSD/man7/ttycap.7
+It used many of the same function names as the later \fItermcap\fP,
+such as
+\fB\%tgetent\fP,
+\fB\%tgetflag\fP,
+\fB\%tgetnum\fP,
+and
+\fB\%tgetstr\fP.
+.PP
+A clear descendant,
+the \fItermlib\fP library,
+.\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=2BSD/src/termlib/
+followed in 2BSD
+(May 1979),
+adding \fB\%tgoto\fP and \fB\%tputs\fP.
+The former applied at that time only to cursor positioning capabilities,
+.\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=2BSD/bin/etc/termcap
+thus the overly specific name.
+Little changed in 3BSD
+(late 1979)
+except the addition of test programs and a \fI\%termlib\fP man page,
+which documented the API shown in section \*(``SYNOPSIS\*('' above.
+.\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=3BSD/usr/src/lib/\
+.\"   libtermlib/
+.\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=3BSD/usr/man/man3/\
+.\"   termlib.3
 .PP
-The original BSD termcap (through 4.3BSD) had no header file which
-gave function prototypes, because that was a feature of ANSI C.
-BSD termcap was written several years before C was standardized.
-However, there were two different termcap.h header files in the BSD
-sources:
+4BSD
+(November 1980)
+renamed \fItermlib\fP to \fItermcap\fP
+.\" ...except in the source tree...
+.\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=4BSD/usr/src/lib/\
+.\"   libtermlib/makefile
+and added another test program.
+The library remained much the same though 4.3BSD
+(June 1986).
+4.4BSD-Lite
+(June 1994)
+refactored it,
+.\" Observe the `tncktc()`, `tnamatch()`, `tskip()`, and `tdecode()`
+.\" entry points disappearing from termcap.c.
+leaving the API unchanged.
+.PP
+Function prototypes were a feature of ANSI C (1989).
+The library long antedated the standard and thus provided no header file
+declaring them.
+Nevertheless,
+the BSD sources included two different \fI\%termcap.h\fP header files
+over time.
 .bP
-One was used internally by the \fIjove\fP editor in 2BSD through 4.4BSD.
-It defined global symbols for the termcap variables which it used.
+One was used internally by \fBjove\fP(1) from 4.3BSD onward.
+.\" 2BSD became a branch retaining support for non-virtual memory
+.\" systems (such as the PDP-11) whereas most BSD development focused on
+.\" the VAX and other VM-enabled systems starting with 3BSD.
+.\"
+.\" This man page previously located a termcap.h in 2BSD, but that may
+.\" be confusion arising from its backport to 2.9BSD (and still present
+.\" in surviving sources for 2.11BSD, the "end of the line" for that
+.\" branch's development).
+.\"
+.\" Observe the copyright notice in
+.\"   https://minnie.tuhs.org/cgi-bin/utree.pl?file=4.3BSD/usr/contrib/\
+.\"     jove/Makefile
+.\" --much too late for 2BSD (1979).
+It declared global symbols for the \fItermcap\fP variables that it used.
 .bP
-The other appeared in 4.4BSD Lite Release 2 (mid-1993)
-as part of \fIlibedit\fP (also known as the \fIeditline\fP library).
-The CSRG source history shows that this was added in mid-1992.
-The \fIlibedit\fP header file was used internally,
-as a convenience for compiling the \fIeditline\fP library.
-It declared function prototypes, but no global variables.
-.PP
-The header file from \fIlibedit\fP was added to NetBSD's termcap
-library in mid-1994.
+The other appeared in 4.4BSD-Lite Release 2
+(June 1995)
+as part of \fIlibedit\fP
+(also known as the \fI\%edit\%line\fP library).
+CSRG source history shows that this was added in mid-1992.
+The \fIlibedit\fP header file was used internally as a convenience for
+compiling the \fI\%edit\%line\fP library.
+It declared function prototypes,
+but no global variables.
+This header file was added to NetBSD's \fItermcap\fP library in
+mid-1994.
 .PP
-Meanwhile, GNU termcap was under development, starting in 1990.
-The first release (termcap 1.0) in 1991 included a termcap.h header.
-The second release (termcap 1.1) in September 1992 modified the
-header to use \fBconst\fP for the function prototypes in the header
-where one would expect the parameters to be read-only.
-This was a difference versus the original BSD termcap.
-The prototype for \fBtputs\fP also differed,
-but in that instance, it was \fIlibedit\fP which differed from BSD termcap.
+Meanwhile,
+GNU \fItermcap\fP began development in 1990.
+Its first release (1.0) in 1991 included a \fI\%termcap.h\fP header.
+Its second (1.1) in September 1992 modified the header to use
+\fIconst\fP for the function prototypes in the header where one would
+expect the parameters to be read-only.
+BSD \fItermcap\fP did not.
+The prototype for \fB\%tputs\fP also differed,
+but in that instance,
+it was \fIlibedit\fP that differed from BSD \fItermcap\fP.
 .PP
-A copy of GNU termcap 1.3 was bundled with \fIbash\fP in mid-1993,
-to support the \fIreadline\fP library.
+GNU \fItermcap\fP 1.3 was bundled with \fIbash\fP(1) in mid-1993 to
+support the \fI\%readline\fP(3) library.
 .PP
-A termcap.h file was provided in ncurses 1.8.1 (November 1993).
-That reflected influence by \fIemacs\fP (rather than \fIjove\fP)
-and GNU termcap:
+\fI\%ncurses\fP 1.8.1
+(November 1993)
+provided a \fI\%termcap.h\fP file.
+It reflected influence from GNU \fItermcap\fP and \fBemacs\fP(1)
+(rather than \fBjove\fP(1)),
+providing the following interface:
 .bP
-it provided declarations for a few global symbols used by \fIemacs\fP
+global symbols used by \fIemacs\fP,
 .bP
-it provided function prototypes (using \fBconst\fP).
+\fIconst\fP-qualified function prototypes,
+and
 .bP
-a prototype for \fBtparam\fP (a GNU termcap feature) was provided.
+a prototype for \fBtparam\fP,
+a GNU \fItermcap\fP feature.
+.PP
+Later
+(in mid-1996)
+the \fB\%tparam\fP function was removed from \fI\%ncurses\fP.
+Any two of the four implementations thus differ,
+and programs that intend to work with all \fItermcap\fP library
+interfaces must account for that fact.
+.SH BUGS
+If you call \fB\%tgetstr\fP to fetch
+.B \%column_address
+.RB ( ch )
+or any other parameterized string capability,
+be aware that it is returned in \fI\%term\%info\fP notation,
+not the older and not-quite-compatible \fItermcap\fP notation.
+This does not cause problems if all you do with it is call \fB\%tgoto\fP
+or \fB\%tparm\fP,
+which both parametrically expand \fI\%term\%info\fP-style string
+capabilities as \fI\%term\%info\fP does.
+(If
+.I \%ncurses
+is configured to support \fItermcap,\fP
+\fB\%tgoto\fP checks whether the string is \fI\%term\%info\fP-style by
+looking for \*(``\fB%p\fP\*('' parameters or
+\*(``\fB<\fP.\|.\|.\fB>\fP\*('' delays,
+and invokes a \fItermcap\fP-style parser if the string appears not to
+use \fI\%term\%info\fP syntax.)
+.PP
+Because \fI\%term\%info\fP's syntax for padding in string capabilities
+differs from \fItermcap\fP's,
+users can be surprised.
+.IP \(bu 4
+\fB\%tputs("50")\fP in a \fI\%term\%info\fP system transmits
+\*(``50\*('' rather than busy-waiting for 50 milliseconds.
+.IP \(bu 4
+However,
+if \fI\%ncurses\fP is configured to support \fItermcap\fP,
+it may also have been configured to support BSD-style padding.
+.IP
+In that case,
+\fB\%tputs\fP inspects strings passed to it,
+looking for digits at the beginning of the string.
+.IP
+\fB\%tputs("50")\fP in a \fItermcap\fP system may busy-wait for 50
+milliseconds rather than transmitting \*(``50\*(''.
+.PP
+\fItermcap\fP has nothing analogous to \fI\%term\%info\fP's
+.B \%set_attributes
+.RB ( sgr )
+capability.
+One consequence is that \fItermcap\fP applications assume that
+.RB \*(`` me \*(''
+(equivalent to \fI\%term\%info\fP's
+.B \%exit_attribute_mode
+.RB ( sgr0 )
+capability)
+does not reset the alternate character set.
+\fI\%ncurses\fP checks for,
+and modifies the data shared with,
+the \fItermcap\fP interface to accommodate the latter's limitation in
+this respect.
+.SH "SEE ALSO"
+\fB\%curses\fP(3X),
+\fB\%curs_terminfo\fP(3X),
+\fB\%putc\fP(3),
+\fB\%term_variables\fP(3X),
+\fB\%terminfo\fP(5)
 .PP
-Later (in mid-1996) the \fBtparam\fP function was removed from ncurses.
-As a result, there are differences between any of the four implementations,
-which must be taken into account by programs which can work with all
-termcap library interfaces.
-.SH SEE ALSO
-\fBcurses\fR(3X),
-\fBputc\fR(3),
-\fBterm_variables\fR(3X),
-\fBterminfo\fR(\*n).
-.sp
-https://invisible-island.net/ncurses/tctest.html
+https://invisible\-island.net/ncurses/tctest.html
diff --git a/contrib/ncurses/man/curs_terminfo.3x b/contrib/ncurses/man/curs_terminfo.3x
index 9120a04b9a98..10d1fa78b6b4 100644
--- a/contrib/ncurses/man/curs_terminfo.3x
+++ b/contrib/ncurses/man/curs_terminfo.3x
@@ -1,5 +1,6 @@
+'\" t
 .\"***************************************************************************
-.\" Copyright 2018-2020,2021 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,641 +28,1115 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_terminfo.3x,v 1.72 2021/01/02 23:50:04 tom Exp $
-.TH curs_terminfo 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: curs_terminfo.3x,v 1.136 2024/04/14 00:14:40 tom Exp $
+.TH curs_terminfo 3X 2024-04-13 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.ds n 5
-.na
-.hy 0
+.
 .SH NAME
-\fBdel_curterm\fR,
-\fBmvcur\fR,
-\fBputp\fR,
-\fBrestartterm\fR,
-\fBset_curterm\fR,
-\fBsetupterm\fR,
-\fBtigetflag\fR,
-\fBtigetnum\fR,
-\fBtigetstr\fR,
-\fBtiparm\fR,
-\fBtparm\fR,
-\fBtputs\fR,
-\fBvid_attr\fR,
-\fBvid_puts\fR,
-\fBvidattr\fR,
-\fBvidputs\fR \- \fBcurses\fR interfaces to terminfo database
-.ad
-.hy
+\fB\%del_curterm\fP,
+\fB\%mvcur\fP,
+\fB\%putp\fP,
+\fB\%restartterm\fP,
+\fB\%set_curterm\fP,
+\fB\%setupterm\fP,
+\fB\%tigetflag\fP,
+\fB\%tigetnum\fP,
+\fB\%tigetstr\fP,
+\fB\%tiparm\fP,
+\fB\%tiparm_s\fP,
+\fB\%tiscan_s\fP,
+\fB\%tparm\fP,
+\fB\%tputs\fP,
+\fB\%vid_attr\fP,
+\fB\%vid_puts\fP,
+\fB\%vidattr\fP,
+\fB\%vidputs\fP \-
+\fIcurses\fR interfaces to \fI\%term\%info\fR database
 .SH SYNOPSIS
 .nf
-\fB#include <curses.h>\fR
-\fB#include <term.h>\fR
-.sp
-\fBTERMINAL *cur_term;\fR
-.sp
-\fBconst char * const boolnames[];\fP
-\fBconst char * const boolcodes[];\fP
-\fBconst char * const boolfnames[];\fP
-\fBconst char * const numnames[];\fP
-\fBconst char * const numcodes[];\fP
-\fBconst char * const numfnames[];\fP
-\fBconst char * const strnames[];\fP
-\fBconst char * const strcodes[];\fP
-\fBconst char * const strfnames[];\fP
-.sp
-\fBint setupterm(const char *\fR\fIterm\fR\fB, int \fR\fIfiledes\fR\fB, int *\fR\fIerrret\fR\fB);\fR
-.br
-\fBTERMINAL *set_curterm(TERMINAL *\fR\fInterm\fR\fB);\fR
-.br
-\fBint del_curterm(TERMINAL *\fR\fIoterm\fR\fB);\fR
-.br
-\fBint restartterm(const char *\fR\fIterm\fR\fB, int \fR\fIfiledes\fR\fB, int *\fR\fIerrret\fR\fB);\fR
-.sp
-\fBchar *tparm(const char *\fR\fIstr\fR\fB, ...);\fR
-.br
-\fBint tputs(const char *\fR\fIstr\fR\fB, int \fR\fIaffcnt\fR\fB, int (*\fR\fIputc\fR\fB)(int));\fR
-.br
-\fBint putp(const char *\fR\fIstr\fR\fB);\fR
-.sp
-\fBint vidputs(chtype \fR\fIattrs\fR\fB, int (*\fR\fIputc\fR\fB)(int));\fR
-.br
-\fBint vidattr(chtype \fR\fIattrs\fR\fB);\fR
-.br
-\fBint vid_puts(attr_t \fR\fIattrs\fR\fB, short \fR\fIpair\fR\fB, void *\fR\fIopts\fR\fB, int (*\fR\fIputc\fR\fB)(int));\fR
-.br
-\fBint vid_attr(attr_t \fR\fIattrs\fR\fB, short \fR\fIpair\fR\fB, void *\fR\fIopts\fR\fB);\fR
-.sp
-\fBint mvcur(int \fR\fIoldrow\fR\fB, int \fR\fIoldcol\fR\fB, int \fR\fInewrow\fR, int \fR\fInewcol\fR\fB);\fR
-.sp
-\fBint tigetflag(const char *\fR\fIcapname\fR\fB);\fR
-.br
-\fBint tigetnum(const char *\fR\fIcapname\fR\fB);\fR
-.br
-\fBchar *tigetstr(const char *\fR\fIcapname\fR\fB);\fR
-.sp
-\fBchar *tiparm(const char *\fR\fIstr\fR\fB, ...);\fR
-.br
+\fB#include <curses.h>
+\fB#include <term.h>
+.PP
+\fBTERMINAL *cur_term;
+.PP
+\fBconst char * const boolnames[];
+\fBconst char * const boolcodes[];
+\fBconst char * const boolfnames[];
+\fBconst char * const numnames[];
+\fBconst char * const numcodes[];
+\fBconst char * const numfnames[];
+\fBconst char * const strnames[];
+\fBconst char * const strcodes[];
+\fBconst char * const strfnames[];
+.PP
+\fBint setupterm(const char *\fIterm\fP, int \fIfiledes\fP, int *\fIerrret\fP);
+\fBTERMINAL *set_curterm(TERMINAL *\fInterm\fP);
+\fBint del_curterm(TERMINAL *\fIoterm\fP);
+\fBint restartterm(const char *\fIterm\fP, int \fIfiledes\fP, int *\fIerrret\fP);
+.PP
+\fBchar *tparm(const char *\fIstr\fP, \fR.\|.\|.\fP);
+	\fI/* or */
+\fBchar *tparm(const char *\fIstr\fP, long \fIp1\fP \fR.\|.\|.\fP \fBlong\fP \fIp9\fP);
+.PP
+\fBint tputs(const char *\fIstr\fP, int \fIaffcnt\fP, int (*\fIputc\fP)(int));
+\fBint putp(const char *\fIstr\fP);
+.PP
+\fBint vidputs(chtype \fIattrs\fP, int (*\fIputc\fP)(int));
+\fBint vidattr(chtype \fIattrs\fP);
+\fBint vid_puts(attr_t \fIattrs\fP, short \fIpair\fP, void *\fIopts\fP, int (*\fIputc\fP)(int));
+\fBint vid_attr(attr_t \fIattrs\fP, short \fIpair\fP, void *\fIopts\fP);
+.PP
+\fBint mvcur(int \fIoldrow\fP, int \fIoldcol\fP, int \fInewrow\fP, int \fInewcol\fP);
+.PP
+\fBint tigetflag(const char *\fIcap-code\fP);
+\fBint tigetnum(const char *\fIcap-code\fP);
+\fBchar *tigetstr(const char *\fIcap-code\fP);
+.PP
+\fBchar *tiparm(const char *\fIstr\fP, \fR.\|.\|.\fP);
+.PP
+\fI/* extensions */
+\fBchar *tiparm_s(int \fIexpected\fP, int \fImask\fP, const char *\fIstr\fP, ...);
+\fBint tiscan_s(int *\fIexpected\fP, int *\fImask\fP, const char *\fIstr\fP);
+.PP
+\fI/* deprecated */
+\fBint setterm(const char *\fIterm\fP);
 .fi
 .SH DESCRIPTION
-These low-level routines must be called by programs that have to deal
-directly with the \fBterminfo\fR database to handle certain terminal
-capabilities, such as programming function keys.
-For all other
-functionality, \fBcurses\fR routines are more suitable and their use is
-recommended.
+These low-level functions must be called by programs that deal directly
+with the
+.I \%term\%info
+database to handle certain terminal capabilities,
+such as programming function keys.
+For all other functionality,
+.I curses
+functions are more suitable and their use is recommended.
 .PP
-None of these functions use (or are aware of) multibyte character strings
-such as UTF-8:
+None of these functions use
+(or are aware of)
+multibyte character strings such as UTF-8.
 .bP
-capability names use the POSIX portable character set
+Capability names and codes use the POSIX portable character set.
 .bP
-capability string values have no associated encoding;
+Capability string values have no associated encoding;
 they are strings of 8-bit characters.
 .SS Initialization
+Initially,
+\fB\%setupterm\fP should be called.
+The high-level
+.I curses
+functions \fB\%initscr\fP and \fB\%newterm\fP call \fB\%setupterm\fP to
+initialize the low-level set of terminal-dependent variables listed in
+\fB\%term_variables\fP(3X).
 .PP
-Initially, \fBsetupterm\fR should be called.
-The high-level curses functions \fBinitscr\fR and
-\fBnewterm\fR call \fBsetupterm\fP to initialize the
-low-level set of terminal-dependent variables
-[listed in \fBterminfo\fR(\*n)].
-.PP
-Applications can use the
-terminal capabilities either directly (via header definitions),
+Applications can use the terminal capabilities either directly
+(via header definitions),
 or by special functions.
-The header files \fBcurses.h\fR and \fBterm.h\fR should be included (in this
-order) to get the definitions for these strings, numbers, and flags.
+The header files
+.I \%curses.h
+and
+.I \%term.h
+should be included
+(in that order)
+to get the definitions for these strings,
+numbers,
+and flags.
 .PP
-The \fBterminfo\fR variables
-\fBlines\fR and \fBcolumns\fR are initialized by \fBsetupterm\fR as
-follows:
+The
+.I \%term\%info
+variables
+.B \%lines
+and
+.B \%columns
+are initialized by \fB\%setupterm\fP as follows.
 .bP
-If \fBuse_env(FALSE)\fR has been called, values for
-\fBlines\fR and \fBcolumns\fR specified in \fBterminfo\fR are used.
+If \fB\%use_env(FALSE)\fP has been called,
+values for
+.B \%lines
+and
+.B \%columns
+specified in
+.I \%term\%info
+are used.
 .bP
-Otherwise, if the environment variables \fBLINES\fR and \fBCOLUMNS\fR
-exist, their values are used.
-If these environment variables do not
-exist and the program is running in a window, the current window size
+Otherwise,
+if the environment variables
+.I LINES
+and
+.I \%COLUMNS
+exist,
+their values are used.
+If these environment variables do not exist and the program is running
+in a window,
+the current window size
 is used.
-Otherwise, if the environment variables do not exist, the
-values for \fBlines\fR and \fBcolumns\fR specified in the
-\fBterminfo\fR database are used.
-.PP
-Parameterized strings should be passed through \fBtparm\fR to instantiate them.
-All \fBterminfo\fR strings
-(including the output of \fBtparm\fR)
-should be printed
-with \fBtputs\fR or \fBputp\fR.
-Call \fBreset_shell_mode\fR to restore the
-tty modes before exiting [see \fBcurs_kernel\fR(3X)].
-.PP
-Programs which use
+Otherwise,
+if the environment variables do not exist,
+the values for
+.B \%lines
+and
+.B \%columns
+specified in the
+.I \%term\%info
+database are used.
+.PP
+Parameterized strings should be passed through \fB\%tparm\fP to
+instantiate them.
+All
+.I \%term\%info
+strings
+(including the output of \fB\%tparm\fP)
+should be sent to the terminal device with \fB\%tputs\fP or
+\fB\%putp\fP.
+Call \fB\%reset_shell_mode\fP to restore the terminal modes before
+exiting;
+see \fB\%curs_kernel\fP(3X).
+.PP
+Programs that use
 cursor addressing should
 .bP
-output \fBenter_ca_mode\fR upon startup and
+output \fB\%enter_ca_mode\fP upon startup and
 .bP
-output \fBexit_ca_mode\fR before exiting.
+output \fB\%exit_ca_mode\fP before exiting.
 .PP
-Programs which execute shell subprocesses should
+Programs that execute shell subprocesses should
 .bP
-call \fBreset_shell_mode\fR and
-output \fBexit_ca_mode\fR before the shell
+call \fB\%reset_shell_mode\fP and
+output \fB\%exit_ca_mode\fP before the shell
 is called and
 .bP
-output \fBenter_ca_mode\fR and
-call \fBreset_prog_mode\fR after returning from the shell.
+output \fB\%enter_ca_mode\fP and
+call \fB\%reset_prog_mode\fP after returning from the shell.
 .PP
-The \fBsetupterm\fR routine reads in the \fBterminfo\fR database,
-initializing the \fBterminfo\fR structures, but does not set up the
-output virtualization structures used by \fBcurses\fR.
-These are its parameters:
+\fB\%setupterm\fP reads in the
+.I \%term\%info
+database,
+initializing the
+.I \%term\%info
+structures,
+but does not set up the output virtualization structures used by
+.IR curses .
+Its parameters follow.
 .RS 3
 .TP 5
-\fIterm\fP
-is the terminal type, a character string.
-If \fIterm\fR is null, the environment variable \fBTERM\fR is used.
+.I term
+is the terminal type,
+a character string.
+If
+.I term
+is null,
+the environment variable
+.I TERM
+is read.
 .TP 5
-\fIfiledes\fP
-is the file descriptor used for all output.
+.I filedes
+is the file descriptor used for getting and setting terminal I/O modes.
+.IP
+Higher-level applications use \fB\%newterm\fP(3X) to initialize the
+terminal,
+passing an output
+.I stream
+rather than a
+.IR descriptor .
+In
+.IR curses ,
+the two are the same because \fB\%newterm\fP calls \fB\%setupterm\fP,
+passing the file descriptor derived from its output stream parameter.
 .TP 5
-\fIerrret\fP
+.I errret
 points to an optional location where an error status can be returned to
 the caller.
-If \fIerrret\fR is not null,
-then \fBsetupterm\fR returns \fBOK\fR or
-\fBERR\fR and stores a status value in the integer pointed to by
-\fIerrret\fR.
-A return value of \fBOK\fR combined with status of \fB1\fR in \fIerrret\fR
+If
+.I errret
+is not null,
+then \fB\%setupterm\fP returns
+.B OK
+or
+.B ERR
+and stores a status value in the integer pointed to by
+.IR errret .
+A return value of
+.B OK
+combined with status of
+.B 1
+in
+.I errret
 is normal.
 .IP
-If \fBERR\fR is returned, examine \fIerrret\fR:
+If
+.B ERR
+is returned,
+examine
+.I errret:
 .RS
 .TP 5
 .B 1
-means that the terminal is hardcopy, cannot be used for curses applications.
+means that the terminal is hardcopy,
+and cannot be used for
+.I curses
+applications.
 .IP
-\fBsetupterm\fP determines if the entry is a hardcopy type by
-checking the \fBhc\fP (\fBhardcopy\fP) capability.
+\fB\%setupterm\fP determines if the entry is a hardcopy type by
+checking the
+.B \%hardcopy
+.RB ( hc )
+capability.
 .TP 5
 .B 0
 means that the terminal could not be found,
 or that it is a generic type,
-having too little information for curses applications to run.
+having too little information for
+.I curses
+applications to run.
 .IP
-\fBsetupterm\fP determines if the entry is a generic type by
-checking the \fBgn\fP (\fBgeneric\fP) capability.
+\fB\%setupterm\fP determines if the entry is a generic type by
+checking the
+.B \%generic_type
+.RB ( gn )
+capability.
 .TP 5
 .B \-1
-means that the \fBterminfo\fR database could not be found.
+means that the
+.I \%term\%info
+database could not be found.
 .RE
 .IP
-If \fIerrret\fR is
-null, \fBsetupterm\fR prints an error message upon finding an error
-and exits.
-Thus, the simplest call is:
-.sp
-      \fBsetupterm((char *)0, 1, (int *)0);\fR,
-.sp
-which uses all the defaults and sends the output to \fBstdout\fR.
+If
+.I errret
+is null,
+\fB\%setupterm\fP reports an error message upon finding an error and
+exits.
+Thus,
+the simplest call is:
+.RS
+.IP
+.EX
+setupterm((char *)0, 1, (int *)0);
+.EE
 .RE
-.\" ***************************************************************************
-.SS The Terminal State
-.PP
-The \fBsetupterm\fR routine stores its information about the terminal
-in a \fBTERMINAL\fP structure pointed to by the global variable \fBcur_term\fP.
+.IP
+which uses all the defaults and sends the output to
+.BR stdout .
+.RE
+.\" ********************************************************************
+.SS "The Terminal State"
+\fB\%setupterm\fP stores its information about the terminal in a
+.I \%TERMINAL
+structure pointed to by the global variable \fB\%cur_term\fP.
 If it detects an error,
-or decides that the terminal is unsuitable (hardcopy or generic),
+or decides that the terminal is unsuitable
+(hardcopy or generic),
 it discards this information,
 making it not available to applications.
 .PP
-If \fBsetupterm\fP is called repeatedly for the same terminal type,
+If \fB\%setupterm\fP is called repeatedly for the same terminal type,
 it will reuse the information.
 It maintains only one copy of a given terminal's capabilities in memory.
 If it is called for different terminal types,
-\fBsetupterm\fP allocates new storage for each set of terminal capabilities.
-.PP
-The \fBset_curterm\fR routine sets \fBcur_term\fR to
-\fInterm\fR, and makes all of the \fBterminfo\fR boolean, numeric, and
-string variables use the values from \fInterm\fR.
-It returns the old value of \fBcur_term\fR.
-.PP
-The \fBdel_curterm\fR routine frees the space pointed to by
-\fIoterm\fR and makes it available for further use.
-If \fIoterm\fR is
-the same as \fBcur_term\fR, references to any of the \fBterminfo\fR
-boolean, numeric, and string variables thereafter may refer to invalid
-memory locations until another \fBsetupterm\fR has been called.
-.PP
-The \fBrestartterm\fR routine is similar to \fBsetupterm\fR and \fBinitscr\fR,
-except that it is called after restoring memory to a previous state (for
-example, when reloading a game saved as a core image dump).
-\fBrestartterm\fP assumes that the windows and the input and output options
-are the same as when memory was saved,
-but the terminal type and baud rate may be different.
-Accordingly, \fBrestartterm\fP saves various tty state bits,
-calls \fBsetupterm\fP, and then restores the bits.
-.\" ***************************************************************************
-.SS Formatting Output
+\fB\%setupterm\fP allocates new storage for each set of terminal
+capabilities.
 .PP
-The \fBtparm\fR routine instantiates the string \fIstr\fR with
-parameters \fIpi\fR.  A pointer is returned to the result of \fIstr\fR
+\fB\%set_curterm\fP sets \fB\%cur_term\fP to
+.IR \%nterm ,
+and makes all of the
+.I \%term\%info
+Boolean,
+numeric,
+and string variables use the values from
+.IR \%nterm .
+It returns the old value of \fB\%cur_term\fP.
+.PP
+\fB\%del_curterm\fP frees the space pointed to by
+.I \%oterm
+and makes it available for further use.
+If
+.I \%oterm
+is
+the same as \fB\%cur_term\fP,
+references to any of the
+.I \%term\%info
+Boolean,
+numeric,
+and string variables thereafter may refer to invalid memory locations
+until another \fB\%setupterm\fP has been called.
+.PP
+\fB\%restartterm\fP is similar to \fB\%setupterm\fP and \fB\%initscr\fP,
+except that it is called after restoring memory to a previous state
+(for example,
+when reloading a game saved as a core image dump).
+\fB\%restartterm\fP assumes that the windows and the input and output
+options are the same as when memory was saved,
+but the terminal type and baud rate may be different.
+Accordingly,
+\fB\%restartterm\fP saves various terminal state bits,
+calls \fB\%setupterm\fP,
+and then restores the bits.
+.\" ********************************************************************
+.SS "Formatting Output"
+\fB\%tparm\fP instantiates the string
+.I str
+with parameters
+.IR pi .
+A pointer is returned to the result of
+.I str
 with the parameters applied.
-Application developers should keep in mind these quirks of the interface:
+Application developers should keep in mind these quirks of the
+interface:
 .bP
-Although \fBtparm\fP's actual parameters may be integers or strings,
-the prototype expects \fBlong\fP (integer) values.
+Although \fB\%tparm\fP's actual parameters may be integers or strings,
+the prototype expects
+.I long
+(integer) values.
 .bP
-Aside from the \fBset_attributes\fP (\fBsgr\fP) capability,
+Aside from the
+.B \%set_attributes\fP
+.RB ( sgr )
+capability,
 most terminal capabilities require no more than one or two parameters.
+.bP
+Padding information is ignored by \fB\%tparm\fP;
+it is interpreted by \fB\%tputs\fP.
+.bP
+The capability string is null-terminated.
+Use \*(``\e200\*('' where an ASCII NUL is needed in the output.
 .PP
-\fBtiparm\fP is a newer form of \fBtparm\fP which uses \fI<stdarg.h>\fP
+\fB\%tiparm\fP is a newer form of \fB\%tparm\fP which uses
+.I \%stdarg.h
 rather than a fixed-parameter list.
-Its numeric parameters are integers (int) rather than longs.
-.\" ***************************************************************************
-.SS Output Functions
+Its numeric parameters are
+.IR int s
+rather than
+.IR long "s."
+.PP
+Both \fB\%tparm\fP and \fB\%tiparm\fP assume that the application passes
+parameters consistent with the terminal description.
+Two extensions are provided as alternatives to deal with untrusted data.
+.bP
+\fB\%tiparm_s\fP is an extension which is a safer formatting function
+than \fB\%tparm\fR or \fB\%tiparm\fR,
+because it allows the developer to tell the
+.I curses
+library how many parameters to expect in the parameter list,
+and which may be string parameters.
+.IP
+The \fImask\fP parameter has one bit set for each of the parameters
+(up to 9)
+passed as
+.I char
+pointers rather than numbers.
+.bP
+The extension \fB\%tiscan_s\fP allows the application to inspect a
+formatting capability to see what the
+.I curses
+library would assume.
+.\" ********************************************************************
+.SS "Output Functions"
+String capabilities can contain padding information,
+a time delay
+(accommodating performance limitations of hardware terminals)
+expressed as \fB$<\fIn\fB>\fR,
+where \fIn\fP is a nonnegative integral count of milliseconds.
+If \fIn\fP exceeds 30,000
+(thirty seconds),
+it is capped at that value.
 .PP
-The \fBtputs\fR routine applies padding information to the string
-\fIstr\fR and outputs it:
+\fB\%tputs\fP interprets time-delay information in the string
+.I str
+and outputs it,
+executing the delays:
 .bP
-The \fIstr\fR parameter must be a terminfo string
-variable or the return value from
-\fBtparm\fR, \fBtiparm\fP, \fBtgetstr\fR, or \fBtgoto\fR.
+The
+.I str
+parameter must be a
+.I \%term\%info
+string variable or the return value of
+\fB\%tparm\fP,
+\fB\%tiparm\fP,
+\fB\%tgetstr\fP,
+or \fB\%tgoto\fP.
 .IP
-The \fBtgetstr\fP and \fBtgoto\fP functions are part of the \fItermcap\fP
+The \fB\%tgetstr\fP and \fB\%tgoto\fP functions are part of the
+.I termcap
 interface,
-which happens to share this function name with the \fIterminfo\fP interface.
+which happens to share these function names with the
+.I \%term\%info
+API.
 .bP
-\fIaffcnt\fR is the number of lines affected, or 1 if
-not applicable.
+.I affcnt
+is the number of lines affected,
+or
+.B 1
+if not applicable.
 .bP
-\fIputc\fR is a \fBputchar\fR-like routine to which
-the characters are passed, one at a time.
+.I putc
+is a
+.IR \%putchar -like
+function to which the characters are passed,
+one at a time.
+.IP
+If \fB\%tputs\fP processes a time-delay,
+it uses the \fB\%delay_output\fP(3X) function,
+routing any resulting padding characters through this function.
 .PP
-The \fBputp\fR routine calls \fBtputs(\fR\fIstr\fR\fB, 1, putchar)\fR.
-The output of \fBputp\fR always goes to \fBstdout\fR, rather than
-the \fIfiledes\fR specified in \fBsetupterm\fR.
+\fB\%putp\fR calls
+.RB \%\*(`` tputs(\c
+.IB str ", 1, putchar)\c"
+\*(''.
+The output of \fB\%putp\fP always goes to
+.BR stdout ,
+rather than the
+.I \%file\%des
+specified in \fB\%setupterm\fP.
 .PP
-The \fBvidputs\fR routine displays the string on the terminal in the
-video attribute mode \fIattrs\fR, which is any combination of the
-attributes listed in \fBcurses\fR(3X).
-The characters are passed to
-the \fBputchar\fR-like routine \fIputc\fR.
+\fB\%vidputs\fP displays the string on the terminal in the video
+attribute mode
+.IR attrs ,
+which is any combination of the attributes listed in \fB\%curses\fP(3X).
+The characters are passed to the
+.IR \%putchar -like
+function
+.IR putc .
 .PP
-The \fBvidattr\fR routine is like the \fBvidputs\fR routine, except
-that it outputs through \fBputchar\fR.
+\fB\%vidattr\fP is like \fB\%vidputs\fP,
+except that it outputs through \fI\%putchar\fP(3).
 .PP
-The \fBvid_attr\fR and \fBvid_puts\fR routines correspond
-to vidattr and vidputs, respectively.
-They use a set of arguments for representing the video attributes plus color,
-i.e.,
+.B \%vid_attr
+and
+.B \%vid_puts
+correspond to
+.B \%vidattr
+and
+.BR \%vidputs ,
+respectively.
+They use multiple parameters to represent the character attributes and
+color;
+namely,
 .bP
-\fIattrs\fP of type \fBattr_t\fP for the attributes and
+.IR \%attrs ,
+of type
+.IR \%attr_t ,
+for the attributes and
 .bP
-\fIpair\fP of type \fBshort\fP for the color-pair number.
+.IR pair ,
+of type
+.IR short ,
+for the color pair number.
 .PP
-The \fBvid_attr\fR and \fBvid_puts\fR routines
-are designed to use the attribute constants with the \fIWA_\fR prefix.
+Use the attribute constants prefixed with
+.RB \*(`` WA_ \*(''
+with
+.B \%vid_attr
+and
+.BR \%vid_puts .
 .PP
-X/Open Curses reserves the \fIopts\fP argument for future use,
-saying that applications must provide a null pointer for that argument.
-As an extension,
-this implementation allows \fIopts\fP to be used as a pointer to \fBint\fP,
-which overrides the \fIpair\fP (\fBshort\fP) argument.
-.PP
-The \fBmvcur\fR routine provides low-level cursor motion.
-It takes effect immediately (rather than at the next refresh).
+X/Open Curses reserves the
+.I opts
+argument for future use,
+saying that applications must provide a null pointer for that argument;
+but see section \*(``EXTENSIONS\*('' below.
 .PP
-While \fBputp\fR and \fBmvcur\fP are low-level functions which
-do not use the high-level curses state,
-they are declared in \fB<curses.h>\fP because SystemV did this
-(see \fBHISTORY\fP).
-.\" ***************************************************************************
-.SS Terminal Capability Functions
+\fB\%mvcur\fP provides low-level cursor motion.
+It takes effect immediately
+(rather than at the next refresh).
+Unlike the other low-level output functions,
+which either write to the standard output or pass an output function
+parameter,
+\fB\%mvcur\fP uses an output file descriptor derived from
+the output stream parameter of \fB\%newterm\fP(3X).
 .PP
-The \fBtigetflag\fR, \fBtigetnum\fR and \fBtigetstr\fR routines return
-the value of the capability corresponding to the \fBterminfo\fR
-\fIcapname\fR passed to them, such as \fBxenl\fR.
-The \fIcapname\fR for each capability is given in the table column entitled
-\fIcapname\fR code in the capabilities section of \fBterminfo\fR(\*n).
+While \fB\%putp\fP and \fB\%mvcur\fP are low-level functions that do not
+use high-level
+.I curses
+state,
+.I \%ncurses
+declares them in
+.I \%curses.h
+because System\ V did this
+(see section \*(``HISTORY\*('' below).
+.\" ********************************************************************
+.SS "Terminal Capability Functions"
+\fB\%tigetflag\fP,
+\fB\%tigetnum\fP,
+and \fB\%tigetstr\fP return the value of the capability corresponding to
+the
+.I \%term\%info
+.IR cap-code ,
+such as
+.BR xenl ,
+passed to them.
+The
+.I cap-code
+for each capability is given in the table column entitled
+.I cap-code
+code in the capabilities section of \fB\%terminfo\fP(5).
 .PP
-These routines return special values to denote errors.
+These functions return special values to denote errors.
 .PP
-The \fBtigetflag\fR routine returns
+\fB\%tigetflag\fP returns
 .TP
-\fB\-1\fR
-if \fIcapname\fR is not a boolean capability,
+.B \-1
+if
+.I cap-code
+is not a Boolean capability,
 or
 .TP
-\fB0\fR
+.B 0
 if it is canceled or absent from the terminal description.
 .PP
-The \fBtigetnum\fR routine returns
+\fB\%tigetnum\fP returns
 .TP
-\fB\-2\fR
-if \fIcapname\fR is not a numeric capability, or
+.B \-2
+if
+.I cap-code
+is not a numeric capability,
+or
 .TP
-\fB\-1\fR
+.B \-1
 if it is canceled or absent from the terminal description.
 .PP
-The \fBtigetstr\fR routine returns
+\fB\%tigetstr\fP returns
 .TP
-\fB(char *)\-1\fR
-if \fIcapname\fR is not a string capability,
+.B "(char *)\-1"
+if
+.I cap-code
+is not a string capability,
 or
 .TP
-\fB0\fR
+.B 0
 if it is canceled or absent from the terminal description.
-.\" ***************************************************************************
-.SS Terminal Capability Names
-.PP
+.\" ********************************************************************
+.SS "Terminal Capability Names"
 These null-terminated arrays contain
 .bP
-the short terminfo names (\*(``codes\*(''),
+the short \fI\%term\%info\fP names (\*(``codes\*(''),
 .bP
-the \fBtermcap\fR names (\*(``names\*(''), and
+the \fItermcap\fP names (\*(``names\*(''),
+and
 .bP
-the long terminfo names (\*(``fnames\*('')
+the long \fI\%term\%info\fP names (\*(``fnames\*('')
+.PP
+for each of the predefined
+.I \%term\%info
+variables:
 .PP
-for each of the predefined \fBterminfo\fR variables:
-.sp
 .RS
-\fBconst char *boolnames[]\fR, \fB*boolcodes[]\fR, \fB*boolfnames[]\fR
-.br
-\fBconst char *numnames[]\fR, \fB*numcodes[]\fR, \fB*numfnames[]\fR
-.br
-\fBconst char *strnames[]\fR, \fB*strcodes[]\fR, \fB*strfnames[]\fR
+.nf
+\fBconst char *boolnames[]\fP, \fB*boolcodes[]\fP, \fB*boolfnames[]\fP
+\fBconst char *numnames[]\fP, \fB*numcodes[]\fP, \fB*numfnames[]\fP
+\fBconst char *strnames[]\fP, \fB*strcodes[]\fP, \fB*strfnames[]\fP
+.fi
 .RE
-.SH RETURN VALUE
-Routines that return an integer return \fBERR\fR upon failure and \fBOK\fR
-(SVr4 only specifies \*(``an integer value other than \fBERR\fR\*('')
-upon successful completion,
-unless otherwise noted in the preceding routine descriptions.
+.\" ********************************************************************
+.SS "Releasing Memory"
+Each successful call to \fB\%setupterm\fP allocates memory to hold the
+terminal description.
+As a side effect,
+it sets \fB\%cur_term\fP to point to this memory.
+If an application calls
+.IP
+.EX
+del_curterm(cur_term);
+.EE
 .PP
-Routines that return pointers always return \fBNULL\fR on error.
+the memory will be freed.
 .PP
-X/Open defines no error conditions.
-In this implementation
-.RS 3
+The formatting functions \fB\%tparm\fP and \fB\%tiparm\fP extend the
+storage allocated by \fB\%setupterm\fP as follows.
+.bP
+They add the \*(``static\*(''
+.I \%term\%info
+variables [a-z].
+Before
+.I \%ncurses
+6.3,
+those were shared by all screens.
+With
+.I \%ncurses
+6.3,
+those are allocated per screen.
+See \fB\%terminfo\fP(5).
+.bP
+To improve performance,
+.I \%ncurses
+6.3 caches the result of analyzing
+.I \%term\%info
+strings for their parameter types.
+That is stored as a binary tree referenced from the
+.I \%TERMINAL
+structure.
+.PP
+The higher-level \fB\%initscr\fP and \fB\%newterm\fP functions use
+\fB\%setupterm\fP.
+Normally they do not free this memory,
+but it is possible to do that using the \fB\%delscreen\fP(3X) function.
+.\" ********************************************************************
+.SH RETURN VALUE
+X/Open Curses defines no failure conditions.
+In
+.IR \%ncurses ,
 .TP 5
-\fBdel_curterm\fP
-returns an error
-if its terminal parameter is null.
+.B del_curtem
+fails if its terminal parameter is null.
 .TP 5
-\fBputp\fP
-calls \fBtputs\fP, returning the same error-codes.
+.B putp
+calls \fB\%tputs\fP,
+returning the same error codes.
 .TP 5
-\fBrestartterm\fP
-returns an error
-if the associated call to \fBsetupterm\fP returns an error.
+.B restartterm
+fails if the associated call to \fB\%setupterm\fP returns an error.
 .TP 5
-\fBsetupterm\fP
-returns an error
-if it cannot allocate enough memory, or
-create the initial windows (stdscr, curscr, newscr).
+.B setupterm
+fails if it cannot allocate enough memory,
+or create the initial windows
+.RB ( \%stdscr ,
+.BR \%curscr ,
+and
+.BR \%newscr )
 Other error conditions are documented above.
 .TP 5
-\fBtputs\fP
-returns an error if the string parameter is null.
+.B tparm
+returns a null pointer if the capability would require unexpected
+parameters;
+that is,
+too many,
+too few,
+or incorrect types
+(strings where integers are expected,
+or vice versa).
+.TP 5
+.B tputs
+fails if the string parameter is null.
 It does not detect I/O errors:
-X/Open states that \fBtputs\fP ignores the return value
-of the output function \fIputc\fP.
-.RE
-.\" ***************************************************************************
-.SS Compatibility macros
+X/Open Curses states that \fB\%tputs\fP ignores the return value
+of the output function \fI\%putc\fP.
+.\" ********************************************************************
+.SH NOTES
+The
+.B \%vid_attr
+function in
+.I \%ncurses
+is a special case.
+It was originally implemented based on a draft of X/Open Curses,
+as a macro,
+before other parts of the
+.I \%ncurses
+wide-character API were developed,
+and unlike the other wide-character functions,
+is also provided in the non-wide-character configuration.
+.\" ********************************************************************
+.SH EXTENSIONS
+The functions marked as extensions were designed for
+.IR \%ncurses ,
+and are not found in SVr4
+.IR curses ,
+4.4BSD
+.IR curses ,
+or any other previous
+.I curses
+implementation.
+.PP
+.I \%ncurses
+allows
+.I opts
+to be a pointer to
+.IR int ,
+which overrides the
+.I pair
+.RI ( short )
+argument.
+.\" ********************************************************************
+.SH PORTABILITY
+\fB\%setterm\fP is not described by X/Open and must be considered
+non-portable.
+All other functions are as described by X/Open.
+.SS "Compatibility Macros"
 This implementation provides a few macros for compatibility with systems
-before SVr4 (see \fBHISTORY\fP).
-Those include
-\fBcrmode\fP,
-\fBfixterm\fP,
-\fBgettmode\fP,
-\fBnocrmode\fP,
-\fBresetterm\fP,
-\fBsaveterm\fP, and
-\fBsetterm\fP.
-.PP
-In SVr4, those are found in \fB<curses.h>\fP,
-but except for \fBsetterm\fR, are likewise macros.
-The one function, \fBsetterm\fR, is mentioned in the manual page.
-The manual page notes that the \fBsetterm\fR routine
-was replaced by \fBsetupterm\fR, stating that the call:
-.sp
-      \fBsetupterm(\fR\fIterm\fR\fB, 1, (int *)0)\fR
-.sp
-provides the same functionality as \fBsetterm(\fR\fIterm\fR\fB)\fR,
-and is not recommended for new programs.
-This implementation provides each of those symbols
-as macros for BSD compatibility,
-.\" ***************************************************************************
+before SVr4
+(see section \*(``HISTORY\*('' below).
+They include
+\fB\%Bcrmode\fP,
+\fB\%Bfixterm\fP,
+\fB\%Bgettmode\fP,
+\fB\%Bnocrmode\fP,
+\fB\%Bresetterm\fP,
+\fB\%Bsaveterm\fP,
+and
+\fB\%Bsetterm\fP.
+.PP
+In SVr4,
+these are found in
+.IR \%curses.h ,
+but except for \fB\%setterm\fP,
+are likewise macros.
+The one function,
+\fB\%setterm\fP,
+is mentioned in the manual page.
+It further notes that \fB\%setterm\fP was replaced by \fB\%setupterm\fP,
+stating that the call
+.RS
+.EX
+setupterm(\fIterm\fP, 1, (int *)0)
+.EE
+.RE
+provides the same functionality as \fB\%setterm(\fIterm\fB)\fR,
+discouraging the latter for new programs.
+.I \%ncurses
+implements each of these symbols as macros for BSD
+.I curses
+compatibility.
+.SS "Legacy Data"
+\fB\%setupterm\fP copies the terminal name to the array \fB\%ttytype\fP.
+This is not part of X/Open Curses,
+but is assumed by some applications.
+.PP
+Other implementions may not declare the capability name arrays.
+Some provide them without declaring them.
+X/Open Curses does not specify them.
+.PP
+Extended terminal capability names,
+as defined by
+.RB \%\*(`` "@TIC@ \-x" \*('',
+are not stored in the arrays described here.
+.SS "Output Buffering"
+Older versions of \fI\%ncurses\fP assumed that the file descriptor
+passed to \fB\%setupterm\fP from \fB\%initscr\fP or \fB\%newterm\fP uses
+buffered I/O,
+and would write to the corresponding stream.
+In addition to the limitation that the terminal was left in
+block-buffered mode on exit
+(like System\ V
+.IR curses ),
+it was problematic because
+.I \%ncurses
+did not allow a reliable way to clean up on receiving
+.BR SIGTSTP .
+.PP
+The current version (ncurses6)
+uses output buffers managed directly by
+.IR \%ncurses .
+Some of the low-level functions described in this manual page write
+to the standard output.
+They are not signal-safe.
+The high-level functions in
+.I \%ncurses
+employ alternate versions of these functions using the more reliable
+buffering scheme.
+.SS "Function Prototypes"
+The X/Open Curses prototypes are based on the SVr4
+.I curses
+header declarations,
+which were defined at the same time the C language was first
+standardized in the late 1980s.
+.bP
+X/Open Curses uses
+.I \%const
+less effectively than a later design might,
+sometimes applying it needlessly to values that are already constant,
+and in most cases overlooking parameters that normally would use
+.IR \%const .
+Passing
+.IR \%const -qualified
+parameters to functions that do not declare them
+.I \%const
+may prevent the program from compiling.
+On the other hand,
+\*(``writable strings\*('' are an obsolescent feature.
+.IP
+As an extension,
+this implementation can be configured to change the function prototypes
+to use the
+.I \%const
+keyword.
+The
+.I \%ncurses
+ABI 6 enables this feature by default.
+.bP
+X/Open Curses prototypes \fB\%tparm\fP with a fixed number of
+parameters,
+rather than a variable argument list.
+.IP
+This implementation uses a variable argument list,
+but can be configured to use the fixed-parameter list.
+Portable applications should provide nine parameters after the format;
+zeroes are fine for this purpose.
+.IP
+In response to review comments by Thomas E. Dickey,
+X/Open Curses Issue 7 proposed the \fB\%tiparm\fP function in mid-2009.
+.IP
+While \fB\%tiparm\fP is always provided in \fI\%ncurses\fP,
+the older form is only available as a build-time configuration option.
+If not specially configured,
+\fB\%tparm\fP is the same as \fB\%tiparm\fP.
+.PP
+Both forms of \fB\%tparm\fP have drawbacks:
+.bP
+Most of the calls to \fB\%tparm\fP use only one or two parameters.
+Passing nine on each call is awkward.
+.IP
+Using
+.I long
+for the numeric parameter type is a workaround to make the parameter use
+the same amount of stack as a pointer.
+That approach dates back to the mid-1980s,
+before C was standardized.
+Since then,
+there is a standard
+(and pointers are not required to fit in a
+.IR long ).
+.bP
+Providing the right number of parameters for a variadic function
+such as \fB\%tiparm\fP can be a problem,
+in particular for string parameters.
+However,
+only a few
+.I \%term\%info
+capabilities use string parameters
+(for instance,
+the ones used for programmable function keys).
+.IP
+The \fI\%ncurses\fP library checks usage of these capabilities,
+and returns an error if the capability mishandles string parameters.
+But it cannot check if a calling program provides strings in the right
+places for the \fB\%tparm\fP calls.
+.IP
+The \fB\%@TPUT@\fR(1) program checks its use of these capabilities with
+a table,
+so that it calls \fB\%tparm\fP correctly.
+.SS "Special \fITERM\fP treatment"
+If configured to use the terminal driver,
+.\" XXX: as opposed to the Unix terminal driver, termio(s)?
+as with the MinGW port,
+.bP
+\fB\%setupterm\fP interprets a missing/empty \fITERM\fP variable as the
+special value \*(``unknown\*(''.
+.IP
+SVr4
+.I curses
+uses the special value \*(``dumb\*(''.
+.IP
+The difference between the two is that the former uses the
+.B \%generic_type
+.RB ( gn )
+.I \%term\%info
+capability,
+while the latter does not.
+A generic terminal is unsuitable for full-screen applications.
+.bP
+\fB\%setupterm\fP allows explicit use of the
+the windows console driver by checking if \fB$TERM\fP is set to
+\*(``#win32con\*('' or an abbreviation of that string.
+.SS "Other Portability Issues"
+In SVr4,
+\fB\%set_curterm\fP returns an
+.IR int ,
+.B OK
+or
+.BR ERR .
+We have chosen to implement the X/Open Curses semantics.
+.PP
+In SVr4,
+the third argument of \fB\%tputs\fP has the type
+.RB \*(`` "int (*putc)(char)" \*(''.
+.PP
+At least one implementation of X/Open Curses (Solaris) returns a value
+other than
+.B OK
+or
+.B ERR
+from \fB\%tputs\fP.
+It instead returns the length of the string,
+and does no error checking.
+.PP
+X/Open Curses notes that after calling \fB\%mvcur\fP,
+the
+.I curses
+state may not match the actual terminal state,
+and that an application should touch and refresh the window before
+resuming normal
+.I curses
+calls.
+Both
+.I \%ncurses
+and SVr4
+.I curses
+implement \fB\%mvcur\fP using the
+.I SCREEN
+data allocated in either \fB\%initscr\fP or \fB\%newterm\fP.
+So though it is documented as a
+.I \%term\%info
+function,
+\fB\%mvcur\fP is really a
+.I curses
+function that is not well specified.
+.PP
+X/Open Curses states that the old location must be given for
+\fB\%mvcur\fP to accommodate terminals that lack absolute cursor
+positioning.
+.\" X/Open Curses Issue 7, p. 161
+.I \%ncurses
+allows the caller to use \-1 for either or both old coordinates.
+The \-1 tells
+.I \%ncurses
+that the old location is unknown,
+and that it must use only absolute motion,
+as with the
+.B \%cursor_address
+.RB ( cup )
+capability,
+rather than the least costly combination of absolute and relative
+motion.
+.\" ********************************************************************
 .SH HISTORY
+SVr2 (1984) introduced the
+.I \%term\%info
+feature.
+Its programming manual mentioned the following low-level functions.
 .PP
-SVr2 introduced the terminfo feature.
-Its programming manual mentioned these low-level functions:
 .TS
-l l
-_ _
-l l.
-\fBFunction\fR	\fBDescription\fR
-fixterm	restore tty to \*(``in curses\*('' state
-gettmode	establish current tty modes
+lB lB
+lB lx.
+Function	Description
+_
+fixterm	restore terminal to \*(``in \fIcurses\fP\*('' state
+gettmode	establish current terminal modes
 mvcur	low level cursor motion
-putp	T{
-utility function that uses \fBtputs\fP to send characters via \fBputchar\fP.
-T}
-resetterm	set tty modes to \*(``out of curses\*('' state
-resetty	reset tty flags to stored value
-saveterm	save current modes as \*(``in curses\*('' state
-savetty	store current tty flags
+putp	use \fBtputs\fP to send characters via \fIputchar\fP
+resetterm	set terminal modes to \*(``out of \fIcurses\fP\*(''\
+ state
+resetty	reset terminal flags to stored value
+saveterm	save current modes as \*(``in \fIcurses\fP\*('' state
+savetty	store current terminal flags
 setterm	establish terminal with given type
 setupterm	establish terminal with given type
-tparm	instantiate a string expression with parameters
+tparm	interpolate parameters into string capability
 tputs	apply padding information to a string
-vidattr	like \fBvidputs\fP, but outputs through \fBputchar\fP
+vidattr	like \fBvidputs\fP, but output through \fIputchar\fP
 vidputs	T{
-output a string to put terminal in a specified video attribute mode
+write string to terminal, applying specified attributes
 T}
 .TE
 .PP
 The programming manual also mentioned
-functions provided for termcap compatibility
-(commenting that they \*(``may go away at a later date\*(''):
+functions provided for
+.I termcap
+compatibility
+(commenting that they \*(``may go away at a later date\*('').
+.PP
 .TS
-l l
-_ _
-l l.
-\fBFunction\fR	\fBDescription\fR
-tgetent	look up termcap entry for given \fIname\fP
-tgetflag	get boolean entry for given \fIid\fP
+lB lB
+lB lx.
+Function	Description
+_
+tgetent	look up \fItermcap\fP entry for given \fIname\fP
+tgetflag	get Boolean entry for given \fIid\fP
 tgetnum	get numeric entry for given \fIid\fP
 tgetstr	get string entry for given \fIid\fP
 tgoto	apply parameters to given capability
 tputs	T{
-apply padding to capability, calling a function to put characters
+write characters via a function parameter, applying padding
 T}
 .TE
 .PP
-Early terminfo programs obtained capability values from the
-\fBTERMINAL\fP structure initialized by \fBsetupterm\fR.
+Early
+.I \%term\%info
+programs obtained capability values from the
+.I \%TERMINAL
+structure initialized by \fB\%setupterm\fP.
+.PP
+SVr3 (1987) extended
+.I \%term\%info
+by adding functions to retrieve capability values
+(like the
+.I termcap
+interface),
+and reusing \fB\%tgoto\fP and \fB\%tputs\fP.
 .PP
-SVr3 extended terminfo by adding functions to retrieve capability values
-(like the termcap interface),
-and reusing tgoto and tputs:
 .TS
-l l
-_ _
-l l.
-\fBFunction\fR	\fBDescription\fR
-tigetflag	get boolean entry for given \fIid\fP
+lB lB
+lB lx.
+Function	Description
+_
+tigetflag	get Boolean entry for given \fIid\fP
 tigetnum	get numeric entry for given \fIid\fP
 tigetstr	get string entry for given \fIid\fP
 .TE
 .PP
-SVr3 also replaced several of the SVr2 terminfo functions
-which had no counterpart in the termcap interface,
-documenting them as obsolete:
+SVr3 also replaced several of the SVr2
+.I \%term\%info
+functions that had no counterpart in the
+.I termcap
+interface,
+documenting them as obsolete.
+.PP
 .TS
-l l
-_ _
-l l.
-\fBFunction\fR	\fBReplaced by\fP
-crmode	cbreak	
-fixterm	reset_prog_mode	
-gettmode	N/A	
-nocrmode	nocbreak	
-resetterm	reset_shell_mode	
-saveterm	def_prog_mode	
-setterm	setupterm	
+lB lB
+l  lx.
+Function	Replaced by
+_
+crmode	cbreak
+fixterm	reset_prog_mode
+gettmode	\fIn/a\fP
+nocrmode	nocbreak
+resetterm	reset_shell_mode
+saveterm	def_prog_mode
+setterm	setupterm
 .TE
 .PP
-SVr3 kept the \fBmvcur\fP, \fBvidattr\fP and \fBvidputs\fP functions,
-along with \fBputp\fP, \fBtparm\fP and \fBtputs\fP.
+SVr3 kept the \fB\%mvcur\fP,
+\fB\%vidattr\fP,
+and \fB\%vidputs\fP functions,
+along with \fB\%putp\fP,
+\fB\%tparm\fP,
+and \fB\%tputs\fP.
 The latter were needed to support padding,
-and handling functions such as \fBvidattr\fP
-(which used more than the two parameters supported by \fBtgoto\fP).
+and to handle capabilities accessed by functions such as \fB\%vidattr\fP
+(which used more than the two parameters supported by \fB\%tgoto\fP).
 .PP
 SVr3 introduced the functions for switching between terminal
-descriptions, e.g., \fBset_curterm\fP.
-The various global variables such as \fBboolnames\fP were mentioned
-in the programming manual at this point.
-.PP
-SVr4 added the \fBvid_attr\fP and \fBvid_puts\fP functions.
-.PP
-There are other low-level functions declared in the curses header files
-on Unix systems,
-but none were documented.
-The functions marked \*(``obsolete\*('' remained in use
-by the Unix \fBvi\fP editor.
-.SH PORTABILITY
-.SS Legacy functions
-.PP
-X/Open notes that \fBvidattr\fR and \fBvidputs\fR may be macros.
-.PP
-The function \fBsetterm\fR is not described by X/Open and must
-be considered non-portable.
-All other functions are as described by X/Open.
-.SS Legacy data
-.PP
-\fBsetupterm\fP copies the terminal name to the array \fBttytype\fP.
-This is not part of X/Open Curses, but is assumed by some applications.
-.PP
-Other implementions may not declare the capability name arrays.
-Some provide them without declaring them.
-X/Open does not specify them.
-.PP
-Extended terminal capability names, e.g., as defined by \fB@TIC@\ \-x\fP,
-are not stored in the arrays described here.
-.SS Output buffering
-.PP
-Older versions of \fBncurses\fP assumed that the file descriptor passed to
-\fBsetupterm\fP from \fBinitscr\fP or \fBnewterm\fP uses buffered I/O,
-and would write to the corresponding stream.
-In addition to the limitation that the terminal was left in block-buffered
-mode on exit (like System V curses),
-it was problematic because \fBncurses\fP
-did not allow a reliable way to cleanup on receiving SIGTSTP.
-.PP
-The current version (ncurses6)
-uses output buffers managed directly by \fBncurses\fP.
-Some of the low-level functions described in this manual page write
-to the standard output.
-They are not signal-safe.
-The high-level functions in \fBncurses\fP use
-alternate versions of these functions
-using the more reliable buffering scheme.
-.SS Function prototypes
-.PP
-The X/Open Curses prototypes are based on the SVr4 curses header declarations,
-which were defined at the same time the C language was first standardized in
-the late 1980s.
-.bP
-X/Open Curses uses \fBconst\fP less effectively than a later design might,
-in some cases applying it needlessly to values are already constant,
-and in most cases overlooking parameters which normally would use \fBconst\fP.
-Using constant parameters for functions which do not use \fBconst\fP
-may prevent the program from compiling.
-On the other hand, \fIwritable strings\fP are an obsolescent feature.
-.IP
-As an extension, this implementation can be configured to change the
-function prototypes to use the \fBconst\fP keyword.
-The ncurses ABI 6 enables this feature by default.
+descriptions;
+for example,
+\fB\%set_curterm\fP.
+Some changes reflected incremental improvements to the SVr2 library.
 .bP
-X/Open Curses prototypes \fBtparm\fR with a fixed number of parameters,
-rather than a variable argument list.
-.IP
-This implementation uses a variable argument list, but can be
-configured to use the fixed-parameter list.
-Portable applications should provide 9 parameters after the format;
-zeroes are fine for this purpose.
-.IP
-In response to review comments by Thomas E. Dickey,
-X/Open Curses Issue 7 proposed the \fBtiparm\fP function in mid-2009.
-.SS Special TERM treatment
-.PP
-If configured to use the terminal-driver,
-e.g., for the MinGW port,
-.bP
-\fBsetupterm\fP interprets a missing/empty TERM variable as the
-special value \*(``unknown\*(''.
+The
+.I \%TERMINAL
+type definition was introduced in SVr3.01,
+for the
+.I term
+structure provided in SVr2.
 .bP
-\fBsetupterm\fP allows explicit use of the
-the windows console driver by checking if $TERM is set to
-\*(``#win32con\*('' or an abbreviation of that string.
-.SS Other portability issues
+Various global variables such as \fB\%boolnames\fP were mentioned
+in the programming manual at this point,
+though the variables had been provided in SVr2.
 .PP
-In System V Release 4, \fBset_curterm\fR has an \fBint\fR return type and
-returns \fBOK\fR or \fBERR\fR.  We have chosen to implement the X/Open Curses
-semantics.
+SVr4 (1989) added the \fB\%vid_attr\fP and \fB\%vid_puts\fP functions.
 .PP
-In System V Release 4, the third argument of \fBtputs\fR has the type
-\fBint (*putc)(char)\fR.
-.PP
-At least one implementation of X/Open Curses (Solaris) returns a value
-other than \fBOK\fP/\fBERR\fP from \fBtputs\fP.
-That returns the length of the string, and does no error-checking.
-.PP
-X/Open notes that after calling \fBmvcur\fR, the curses state may not match the
-actual terminal state, and that an application should touch and refresh
-the window before resuming normal curses calls.
-Both \fBncurses\fP and System V Release 4 curses implement \fBmvcur\fR using
-the SCREEN data allocated in either \fBinitscr\fR or \fBnewterm\fR.
-So though it is documented as a terminfo function,
-\fBmvcur\fR is really a curses function which is not well specified.
-.PP
-X/Open states that the old location must be given for \fBmvcur\fP.
-This implementation allows the caller to use \-1's for the old ordinates.
-In that case, the old location is unknown.
+Other low-level functions are declared in the
+.I curses
+header files of Unix systems,
+but none are documented.
+Those noted as \*(``obsolete\*('' by SVr3 remained in use by System\ V's
+\fIvi\fP(1) editor.
 .SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_initscr\fR(3X),
-\fBcurs_kernel\fR(3X),
-\fBcurs_termcap\fR(3X),
-\fBcurs_variables\fR(3X),
-\fBterm_variables\fR(3X),
-\fBputc\fR(3),
-\fBterminfo\fR(\*n)
+\fB\%curses\fP(3X),
+\fB\%curs_initscr\fP(3X),
+\fB\%curs_kernel\fP(3X),
+\fB\%curs_memleaks\fP(3X),
+\fB\%curs_termcap\fP(3X),
+\fB\%curs_variables\fP(3X),
+\fB\%putc\fP(3),
+\fB\%term_variables\fP(3X),
+\fB\%terminfo\fP(5)
diff --git a/contrib/ncurses/man/curs_threads.3x b/contrib/ncurses/man/curs_threads.3x
index cb2da61a55df..d49c16e71f09 100644
--- a/contrib/ncurses/man/curs_threads.3x
+++ b/contrib/ncurses/man/curs_threads.3x
@@ -1,5 +1,6 @@
+'\" t
 .\"***************************************************************************
-.\" Copyright 2020 Thomas E. Dickey                                          *
+.\" Copyright 2021-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 2008-2015,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,577 +28,611 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_threads.3x,v 1.27 2020/12/30 18:28:51 tom Exp $
-.TH curs_threads 3X ""
+.\" $Id: curs_threads.3x,v 1.56 2024/03/16 15:35:01 tom Exp $
+.TH curs_threads 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.na
-.hy 0
 .SH NAME
-\fBcurs_threads\fR \- \fBcurses\fR thread support
-.ad
-.hy
+\fI\%NCURSES_WINDOW_CB\fP,
+\fI\%NCURSES_SCREEN_CB\fP,
+\fB\%get_escdelay\fP,
+\fB\%set_escdelay\fP,
+\fB\%set_tabsize\fP,
+\fB\%use_screen\fP,
+\fB\%use_window\fP \-
+\fIcurses\fR support for multi-threaded applications
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBtypedef int (*NCURSES_WINDOW_CB)(WINDOW *, void *);\fR
-.br
-\fBtypedef int (*NCURSES_SCREEN_CB)(SCREEN *, void *);\fR
-.sp
-\fBint get_escdelay(void);\fR
-.br
-\fBint set_escdelay(int \fP\fIms\fP\fB);\fR
-.br
-\fBint set_tabsize(int \fP\fIcols\fP\fB);\fR
-.sp
-\fBint use_screen(SCREEN *\fP\fIscr\fP\fB, NCURSES_SCREEN_CB \fP\fIfunc\fP\fB, void *\fP\fIdata\fP\fB);\fR
-.br
-\fBint use_window(WINDOW *\fP\fIwin\fP\fB, NCURSES_WINDOW_CB \fP\fIfunc\fP\fB, void *\fP\fIdata\fP\fB);\fR
-.br
+.nf
+\fB#include <curses.h>
+.PP
+\fI/* data types */
+\fBtypedef int (*NCURSES_WINDOW_CB)(WINDOW *, void *);
+\fBtypedef int (*NCURSES_SCREEN_CB)(SCREEN *, void *);
+.PP
+\fBint get_escdelay(void);
+\fBint set_escdelay(int \fIms\fP);
+\fBint set_tabsize(int \fIcols\fP);
+.PP
+\fBint use_screen(SCREEN *\fIscr\fP, NCURSES_SCREEN_CB \fIfunc\fP, void *\fIdata\fP);
+\fBint use_window(WINDOW *\fIwin\fP, NCURSES_WINDOW_CB \fIfunc\fP, void *\fIdata\fP);
+.fi
 .SH DESCRIPTION
-This implementation can be configured to provide rudimentary support
-for multi-threaded applications.
-This makes a different set of libraries, e.g., \fIlibncursest\fP since
-the binary interfaces are different.
+The \fI\%ncurses\fP library can be configured to support multi-threaded
+applications in a rudimentary way.
+Such configuration produces a different set of libraries,
+named \fIlibncursest\fP,
+for example,
+since doing so alters \fI\%ncurses\fP's application binary interface
+(ABI).
 .PP
-Rather than modify the interfaces to pass a thread specifier to
-each function, it adds a few functions which can be used in any
-configuration which hide the mutex's needed to prevent concurrent
-use of the global variables when configured for threading.
+Instead of modifying the programming interface (API) to make
+\fI\%ncurses\fP functions expect an additional argument specifying a
+thread,
+the library adds functions,
+usable in any configuration,
+that hide the \fImutexes\fP
+(mutual exclusion locks)
+needed to prevent concurrent access to variables shared by multiple
+threads of execution.
 .PP
-In addition to forcing access to members of the \fBWINDOW\fP structure
-to be via functions (see \fBcurs_opaque\fP(3X)),
-it makes functions of the common global variables,
-e.g.,
-COLORS,
-COLOR_PAIRS,
-COLS,
-ESCDELAY,
-LINES,
-TABSIZE
-curscr,
-newscr and
-ttytype.
-Those variables are maintained as read-only values, stored in the \fBSCREEN\fP
-structure.
+\fI\%ncurses\fP threading support requires the use of functions to
+access members of the \fI\%WINDOW\fP structure (see
+\fBcurs_opaque\fP(3X)).
+It further makes functions of the common global variables
+\fB\%COLORS\fP,
+\fB\%COLOR_PAIRS\fP,
+\fB\%COLS\fP,
+\fB\%ESCDELAY\fP,
+\fB\%LINES\fP,
+\fB\%TABSIZE\fP,
+\fB\%curscr\fP,
+\fB\%newscr\fP,
+and
+\fB\%ttytype\fP,
+maintaining them as as read-only values in the \fISCREEN\fP structure.
 .PP
-Even this is not enough to make a thread-safe application using curses.
-A multi-threaded application would be expected to have threads updating
-separate windows (within the same device),
-or updating on separate screens (on different devices).
-Also, a few of the global variables are considered writable by some
-applications.
+Even this is not enough to make an application using \fIcurses\fP
+thread-safe.
+We would expect a multi-threaded application to have threads updating
+separate windows (on the same device),
+and separate screens (on different devices).
+Further,
+applications expect a few of the global variables to be writable.
 The functions described here address these special situations.
 .PP
-The ESCDELAY and TABSIZE global variables are modified by some applications.
+The \fB\%ESCDELAY\fP and \fB\%TABSIZE\fP global variables are modified
+by some applications.
 To modify them in any configuration,
-use the \fBset_escdelay\fP or \fBset_tabsize\fP functions.
+use the \fB\%set_escdelay\fP or \fB\%set_tabsize\fP functions.
 Other global variables are not modifiable.
+\fBget_escdelay\fP retrieves \fB\%ESCDELAY\fP's value.
 .PP
-The \fBget_escdelay\fP function returns the value for ESCDELAY.
-.PP
-The \fBuse_window\fP and \fBuse_screen\fP functions provide coarse
-granularity mutexes for their respective \fBWINDOW\fP and \fBSCREEN\fP
-parameters, and call a user-supplied function,
-passing it a \fIdata\fP parameter,
-and returning the value from the user-supplied function to the application.
+The \fBuse_window\fP and \fBuse_screen\fP functions provide
+coarse-grained mutexes for their respective \fI\%WINDOW\fP and
+\fISCREEN\fP parameters;
+they call a user-supplied function,
+pass it a \fIdata\fP parameter,
+and return the value from the user-supplied function to the application.
 .\" ***************************************************************************
-.SS USAGE
-All of the ncurses library functions assume that the locale is not
+.SS Usage
+All \fI\%ncurses\fP library functions assume that the locale is not
 altered during operation.
 In addition,
-they use data which is maintained within a hierarchy of scopes.
-.RS 3
+they use data that is maintained within a hierarchy of scopes.
 .bP
-global data, e.g., used in the low-level terminfo or termcap interfaces.
+global data used in the low-level \fIterminfo\fP or \fItermcap\fP
+interfaces
 .bP
-terminal data, e.g., associated with a call to \fIset_curterm\fP.
-The terminal data are initialized when screens are created.
+terminal data associated with a call to \fBset_curterm\fP(3X)
+.IP
+Terminal data are initialized when screens are created.
 .bP
-screen data, e.g., associated with a call to \fInewterm\fP or \fIinitscr\fP.
+screen data associated with a call to \fBnewterm\fP(3X) or
+\fBinitscr\fP(3X)
 .bP
-window data, e.g., associated with a call to \fInewwin\fP or \fIsubwin\fP.
+window data associated with a call to \fBnewwin\fP(3X) or
+\fBsubwin\fP(3X)
+.IP
 Windows are associated with screens.
-Pads are not necessarily associated with a particular screen.
+Pads are not necessarily associated with any particular screen.
 .IP
-Most curses applications operate on one or more windows within a single screen.
+Most \fIcurses\fP applications operate on one or more windows within a
+single screen.
 .bP
-reentrant, i.e., it uses only the data passed as parameters.
-.RE
+reentrant data associated with \*(``pure\*('' functions that alter no
+shared variables
+.PP
+The following table lists the scope of each symbol in the
+\fI\%ncurses\fP library when configured to support multi-threaded
+applications.
 .PP
-This table lists the scope of data used for each symbol in the
-ncurses library when it is configured to support threading:
 .TS
-center tab(/);
-l l
-l l .
-Symbol/Scope
-=
-BC/global
-COLORS/screen (readonly)
-COLOR_PAIR/reentrant
-COLOR_PAIRS/screen (readonly)
-COLS/screen (readonly)
-ESCDELAY/screen (readonly, see \fIset_escdelay\fP)
-LINES/screen (readonly)
-PAIR_NUMBER/reentrant
-PC/global
-SP/global
-TABSIZE/screen (readonly)
-UP/global
-acs_map/screen (readonly)
-add_wch/window (stdscr)
-add_wchnstr/window (stdscr)
-add_wchstr/window (stdscr)
-addch/window (stdscr)
-addchnstr/window (stdscr)
-addchstr/window (stdscr)
-addnstr/window (stdscr)
-addnwstr/window (stdscr)
-addstr/window (stdscr)
-addwstr/window (stdscr)
-assume_default_colors/screen
-attr_get/window (stdscr)
-attr_off/window (stdscr)
-attr_on/window (stdscr)
-attr_set/window (stdscr)
-attroff/window (stdscr)
-attron/window (stdscr)
-attrset/window (stdscr)
-baudrate/screen
-beep/screen
-bkgd/window (stdscr)
-bkgdset/window (stdscr)
-bkgrnd/window (stdscr)
-bkgrndset/window (stdscr)
-boolcodes/global (readonly)
-boolfnames/global (readonly)
-boolnames/global (readonly)
-border/window (stdscr)
-border_set/window (stdscr)
-box/window (stdscr)
-box_set/window (stdscr)
-can_change_color/terminal
-cbreak/screen
-chgat/window (stdscr)
-clear/window (stdscr)
-clearok/window
-clrtobot/window (stdscr)
-clrtoeol/window (stdscr)
-color_content/screen
-color_set/window (stdscr)
-copywin/window locks(source, target)
-cur_term/terminal
-curs_set/screen
-curscr/screen (readonly)
-curses_version/global (readonly)
-def_prog_mode/terminal
-def_shell_mode/terminal
-define_key/screen
-del_curterm/screen
-delay_output/screen
-delch/window (stdscr)
-deleteln/window (stdscr)
-delscreen/global locks(screenlist, screen)
-delwin/global locks(windowlist)
-derwin/screen
-doupdate/screen
-dupwin/screen locks(window)
-echo/screen
-echo_wchar/window (stdscr)
-echochar/window (stdscr)
-endwin/screen
-erase/window (stdscr)
-erasechar/window (stdscr)
-erasewchar/window (stdscr)
-filter/global
-flash/terminal
-flushinp/screen
-get_wch/screen (input-operation)
-get_wstr/screen (input-operation)
-getattrs/window
-getbegx/window
-getbegy/window
-getbkgd/window
-getbkgrnd/window
-getcchar/reentrant
-getch/screen (input-operation)
-getcurx/window
-getcury/window
-getmaxx/window
-getmaxy/window
-getmouse/screen (input-operation)
-getn_wstr/screen (input-operation)
-getnstr/screen (input-operation)
-getparx/window
-getpary/window
-getstr/screen (input-operation)
-getwin/screen (input-operation)
-halfdelay/screen
-has_colors/terminal
-has_ic/terminal
-has_il/terminal
-has_key/screen
-hline/window (stdscr)
-hline_set/window (stdscr)
-idcok/window
-idlok/window
-immedok/window
-in_wch/window (stdscr)
-in_wchnstr/window (stdscr)
-in_wchstr/window (stdscr)
-inch/window (stdscr)
-inchnstr/window (stdscr)
-inchstr/window (stdscr)
-init_color/screen
-init_pair/screen
-initscr/global locks(screenlist)
-innstr/window (stdscr)
-innwstr/window (stdscr)
-ins_nwstr/window (stdscr)
-ins_wch/window (stdscr)
-ins_wstr/window (stdscr)
-insch/window (stdscr)
-insdelln/window (stdscr)
-insertln/window (stdscr)
-insnstr/window (stdscr)
-insstr/window (stdscr)
-instr/window (stdscr)
-intrflush/terminal
-inwstr/window (stdscr)
-is_cleared/window
-is_idcok/window
-is_idlok/window
-is_immedok/window
-is_keypad/window
-is_leaveok/window
-is_linetouched/window
-is_nodelay/window
-is_notimeout/window
-is_scrollok/window
-is_syncok/window
-is_term_resized/terminal
-is_wintouched/window
-isendwin/screen
-key_defined/screen
-key_name/global (static data)
-keybound/screen
-keyname/global (static data)
-keyok/screen
-keypad/window
-killchar/terminal
-killwchar/terminal
-leaveok/window
-longname/screen
-mcprint/terminal
-meta/screen
-mouse_trafo/window (stdscr)
-mouseinterval/screen
-mousemask/screen
-move/window (stdscr)
-mvadd_wch/window (stdscr)
-mvadd_wchnstr/window (stdscr)
-mvadd_wchstr/window (stdscr)
-mvaddch/window (stdscr)
-mvaddchnstr/window (stdscr)
-mvaddchstr/window (stdscr)
-mvaddnstr/window (stdscr)
-mvaddnwstr/window (stdscr)
-mvaddstr/window (stdscr)
-mvaddwstr/window (stdscr)
-mvchgat/window (stdscr)
-mvcur/screen
-mvdelch/window (stdscr)
-mvderwin/window (stdscr)
-mvget_wch/screen (input-operation)
-mvget_wstr/screen (input-operation)
-mvgetch/screen (input-operation)
-mvgetn_wstr/screen (input-operation)
-mvgetnstr/screen (input-operation)
-mvgetstr/screen (input-operation)
-mvhline/window (stdscr)
-mvhline_set/window (stdscr)
-mvin_wch/window (stdscr)
-mvin_wchnstr/window (stdscr)
-mvin_wchstr/window (stdscr)
-mvinch/window (stdscr)
-mvinchnstr/window (stdscr)
-mvinchstr/window (stdscr)
-mvinnstr/window (stdscr)
-mvinnwstr/window (stdscr)
-mvins_nwstr/window (stdscr)
-mvins_wch/window (stdscr)
-mvins_wstr/window (stdscr)
-mvinsch/window (stdscr)
-mvinsnstr/window (stdscr)
-mvinsstr/window (stdscr)
-mvinstr/window (stdscr)
-mvinwstr/window (stdscr)
-mvprintw/window (stdscr)
-mvscanw/screen
-mvvline/window (stdscr)
-mvvline_set/window (stdscr)
-mvwadd_wch/window
-mvwadd_wchnstr/window
-mvwadd_wchstr/window
-mvwaddch/window
-mvwaddchnstr/window
-mvwaddchstr/window
-mvwaddnstr/window
-mvwaddnwstr/window
-mvwaddstr/window
-mvwaddwstr/window
-mvwchgat/window
-mvwdelch/window
-mvwget_wch/screen (input-operation)
-mvwget_wstr/screen (input-operation)
-mvwgetch/screen (input-operation)
-mvwgetn_wstr/screen (input-operation)
-mvwgetnstr/screen (input-operation)
-mvwgetstr/screen (input-operation)
-mvwhline/window
-mvwhline_set/window
-mvwin/window
-mvwin_wch/window
-mvwin_wchnstr/window
-mvwin_wchstr/window
-mvwinch/window
-mvwinchnstr/window
-mvwinchstr/window
-mvwinnstr/window
-mvwinnwstr/window
-mvwins_nwstr/window
-mvwins_wch/window
-mvwins_wstr/window
-mvwinsch/window
-mvwinsnstr/window
-mvwinsstr/window
-mvwinstr/window
-mvwinwstr/window
-mvwprintw/window
-mvwscanw/screen
-mvwvline/window
-mvwvline_set/window
-napms/reentrant
-newpad/global locks(windowlist)
-newscr/screen (readonly)
-newterm/global locks(screenlist)
-newwin/global locks(windowlist)
-nl/screen
-nocbreak/screen
-nodelay/window
-noecho/screen
-nofilter/global
-nonl/screen
-noqiflush/terminal
-noraw/screen
-notimeout/window
-numcodes/global (readonly)
-numfnames/global (readonly)
-numnames/global (readonly)
-ospeed/global
-overlay/window locks(source, target)
-overwrite/window locks(source, target)
-pair_content/screen
-pecho_wchar/screen
-pechochar/screen
-pnoutrefresh/screen
-prefresh/screen
-printw/window
-putp/global
-putwin/window
-qiflush/terminal
-raw/screen
-redrawwin/window
-refresh/screen
-reset_prog_mode/screen
-reset_shell_mode/screen
-resetty/terminal
-resize_term/screen locks(windowlist)
-resizeterm/screen
-restartterm/screen
-ripoffline/global (static data)
-savetty/terminal
-scanw/screen
-scr_dump/screen
-scr_init/screen
-scr_restore/screen
-scr_set/screen
-scrl/window (stdscr)
-scroll/window
-scrollok/window
-set_curterm/screen
-set_escdelay/screen
-set_tabsize/screen
-set_term/global locks(screenlist, screen)
-setcchar/reentrant
-setscrreg/window (stdscr)
-setupterm/global
-slk_attr/screen
-slk_attr_off/screen
-slk_attr_on/screen
-slk_attr_set/screen
-slk_attroff/screen
-slk_attron/screen
-slk_attrset/screen
-slk_clear/screen
-slk_color/screen
-slk_init/screen
-slk_label/screen
-slk_noutrefresh/screen
-slk_refresh/screen
-slk_restore/screen
-slk_set/screen
-slk_touch/screen
-slk_wset/screen
-standend/window
-standout/window
-start_color/screen
-stdscr/screen (readonly)
-strcodes/global (readonly)
-strfnames/global (readonly)
-strnames/global (readonly)
-subpad/window
-subwin/window
-syncok/window
-term_attrs/screen
-termattrs/screen
-termname/terminal
-tgetent/global
-tgetflag/global
-tgetnum/global
-tgetstr/global
-tgoto/global
-tigetflag/terminal
-tigetnum/terminal
-tigetstr/terminal
-timeout/window (stdscr)
-touchline/window
-touchwin/window
-tparm/global (static data)
-tputs/screen
-trace/global (static data)
-ttytype/screen (readonly)
-typeahead/screen
-unctrl/screen
-unget_wch/screen (input-operation)
-ungetch/screen (input-operation)
-ungetmouse/screen (input-operation)
-untouchwin/window
-use_default_colors/screen
-use_env/global (static data)
-use_extended_names/global (static data)
-use_legacy_coding/screen
-use_screen/global locks(screenlist, screen)
-use_window/global locks(windowlist, window)
-vid_attr/screen
-vid_puts/screen
-vidattr/screen
-vidputs/screen
-vline/window (stdscr)
-vline_set/window (stdscr)
-vw_printw/window
-vw_scanw/screen
-vwprintw/window
-vwscanw/screen
-wadd_wch/window
-wadd_wchnstr/window
-wadd_wchstr/window
-waddch/window
-waddchnstr/window
-waddchstr/window
-waddnstr/window
-waddnwstr/window
-waddstr/window
-waddwstr/window
-wattr_get/window
-wattr_off/window
-wattr_on/window
-wattr_set/window
-wattroff/window
-wattron/window
-wattrset/window
-wbkgd/window
-wbkgdset/window
-wbkgrnd/window
-wbkgrndset/window
-wborder/window
-wborder_set/window
-wchgat/window
-wclear/window
-wclrtobot/window
-wclrtoeol/window
-wcolor_set/window
-wcursyncup/screen (affects window plus parents)
-wdelch/window
-wdeleteln/window
-wecho_wchar/window
-wechochar/window
-wenclose/window
-werase/window
-wget_wch/screen (input-operation)
-wget_wstr/screen (input-operation)
-wgetbkgrnd/window
-wgetch/screen (input-operation)
-wgetdelay/window
-wgetn_wstr/screen (input-operation)
-wgetnstr/screen (input-operation)
-wgetparent/window
-wgetscrreg/window
-wgetstr/screen (input-operation)
-whline/window
-whline_set/window
-win_wch/window
-win_wchnstr/window
-win_wchstr/window
-winch/window
-winchnstr/window
-winchstr/window
-winnstr/window
-winnwstr/window
-wins_nwstr/window
-wins_wch/window
-wins_wstr/window
-winsch/window
-winsdelln/window
-winsertln/window
-winsnstr/window
-winsstr/window
-winstr/window
-winwstr/window
-wmouse_trafo/window
-wmove/window
-wnoutrefresh/screen
-wprintw/window
-wredrawln/window
-wrefresh/screen
-wresize/window locks(windowlist)
-wscanw/screen
-wscrl/window
-wsetscrreg/window
-wstandend/window
-wstandout/window
-wsyncdown/screen (affects window plus parents)
-wsyncup/screen (affects window plus parents)
-wtimeout/window
-wtouchln/window
-wunctrl/global (static data)
-wvline/window
-wvline_set/window
+center;
+Lb2 Lb
+Lb2 Lx.
+Symbol	Scope
+_
+BC	global
+COLORS	screen (read-only)
+COLOR_PAIR	reentrant
+COLOR_PAIRS	screen (read-only)
+COLS	screen (read-only)
+ESCDELAY	screen (read-only; see \fBset_escdelay\fP)
+LINES	screen (read-only)
+PAIR_NUMBER	reentrant
+PC	global
+SP	global
+TABSIZE	screen (read-only; see \fBset_tabsize\fP)
+UP	global
+acs_map	screen (read-only)
+add_wch	window (\fBstdscr\fP)
+add_wchnstr	window (\fBstdscr\fP)
+add_wchstr	window (\fBstdscr\fP)
+addch	window (\fBstdscr\fP)
+addchnstr	window (\fBstdscr\fP)
+addchstr	window (\fBstdscr\fP)
+addnstr	window (\fBstdscr\fP)
+addnwstr	window (\fBstdscr\fP)
+addstr	window (\fBstdscr\fP)
+addwstr	window (\fBstdscr\fP)
+assume_default_colors	screen
+attr_get	window (\fBstdscr\fP)
+attr_off	window (\fBstdscr\fP)
+attr_on	window (\fBstdscr\fP)
+attr_set	window (\fBstdscr\fP)
+attroff	window (\fBstdscr\fP)
+attron	window (\fBstdscr\fP)
+attrset	window (\fBstdscr\fP)
+baudrate	screen
+beep	screen
+bkgd	window (\fBstdscr\fP)
+bkgdset	window (\fBstdscr\fP)
+bkgrnd	window (\fBstdscr\fP)
+bkgrndset	window (\fBstdscr\fP)
+boolcodes	global (read-only)
+boolfnames	global (read-only)
+boolnames	global (read-only)
+border	window (\fBstdscr\fP)
+border_set	window (\fBstdscr\fP)
+box	window (\fBstdscr\fP)
+box_set	window (\fBstdscr\fP)
+can_change_color	terminal
+cbreak	screen
+chgat	window (\fBstdscr\fP)
+clear	window (\fBstdscr\fP)
+clearok	window
+clrtobot	window (\fBstdscr\fP)
+clrtoeol	window (\fBstdscr\fP)
+color_content	screen
+color_set	window (\fBstdscr\fP)
+copywin	window (locks source, target)
+cur_term	terminal
+curs_set	screen
+curscr	screen (read-only)
+curses_version	global (read-only)
+def_prog_mode	terminal
+def_shell_mode	terminal
+define_key	screen
+del_curterm	screen
+delay_output	screen
+delch	window (\fBstdscr\fP)
+deleteln	window (\fBstdscr\fP)
+delscreen	global (locks screen list, screen)
+delwin	global (locks window list)
+derwin	screen
+doupdate	screen
+dupwin	screen (locks window)
+echo	screen
+echo_wchar	window (\fBstdscr\fP)
+echochar	window (\fBstdscr\fP)
+endwin	screen
+erase	window (\fBstdscr\fP)
+erasechar	window (\fBstdscr\fP)
+erasewchar	window (\fBstdscr\fP)
+filter	global
+flash	terminal
+flushinp	screen
+get_wch	screen (input operation)
+get_wstr	screen (input operation)
+getattrs	window
+getbegx	window
+getbegy	window
+getbkgd	window
+getbkgrnd	window
+getcchar	reentrant
+getch	screen (input operation)
+getcurx	window
+getcury	window
+getmaxx	window
+getmaxy	window
+getmouse	screen (input operation)
+getn_wstr	screen (input operation)
+getnstr	screen (input operation)
+getparx	window
+getpary	window
+getstr	screen (input operation)
+getwin	screen (input operation)
+halfdelay	screen
+has_colors	terminal
+has_ic	terminal
+has_il	terminal
+has_key	screen
+hline	window (\fBstdscr\fP)
+hline_set	window (\fBstdscr\fP)
+idcok	window
+idlok	window
+immedok	window
+in_wch	window (\fBstdscr\fP)
+in_wchnstr	window (\fBstdscr\fP)
+in_wchstr	window (\fBstdscr\fP)
+inch	window (\fBstdscr\fP)
+inchnstr	window (\fBstdscr\fP)
+inchstr	window (\fBstdscr\fP)
+init_color	screen
+init_pair	screen
+initscr	global (locks screen list)
+innstr	window (\fBstdscr\fP)
+innwstr	window (\fBstdscr\fP)
+ins_nwstr	window (\fBstdscr\fP)
+ins_wch	window (\fBstdscr\fP)
+ins_wstr	window (\fBstdscr\fP)
+insch	window (\fBstdscr\fP)
+insdelln	window (\fBstdscr\fP)
+insertln	window (\fBstdscr\fP)
+insnstr	window (\fBstdscr\fP)
+insstr	window (\fBstdscr\fP)
+instr	window (\fBstdscr\fP)
+intrflush	terminal
+inwstr	window (\fBstdscr\fP)
+is_cleared	window
+is_idcok	window
+is_idlok	window
+is_immedok	window
+is_keypad	window
+is_leaveok	window
+is_linetouched	window
+is_nodelay	window
+is_notimeout	window
+is_scrollok	window
+is_syncok	window
+is_term_resized	terminal
+is_wintouched	window
+isendwin	screen
+key_defined	screen
+key_name	global (static data)
+keybound	screen
+keyname	global (static data)
+keyok	screen
+keypad	window
+killchar	terminal
+killwchar	terminal
+leaveok	window
+longname	screen
+mcprint	terminal
+meta	screen
+mouse_trafo	window (\fBstdscr\fP)
+mouseinterval	screen
+mousemask	screen
+move	window (\fBstdscr\fP)
+mvadd_wch	window (\fBstdscr\fP)
+mvadd_wchnstr	window (\fBstdscr\fP)
+mvadd_wchstr	window (\fBstdscr\fP)
+mvaddch	window (\fBstdscr\fP)
+mvaddchnstr	window (\fBstdscr\fP)
+mvaddchstr	window (\fBstdscr\fP)
+mvaddnstr	window (\fBstdscr\fP)
+mvaddnwstr	window (\fBstdscr\fP)
+mvaddstr	window (\fBstdscr\fP)
+mvaddwstr	window (\fBstdscr\fP)
+mvchgat	window (\fBstdscr\fP)
+mvcur	screen
+mvdelch	window (\fBstdscr\fP)
+mvderwin	window (\fBstdscr\fP)
+mvget_wch	screen (input operation)
+mvget_wstr	screen (input operation)
+mvgetch	screen (input operation)
+mvgetn_wstr	screen (input operation)
+mvgetnstr	screen (input operation)
+mvgetstr	screen (input operation)
+mvhline	window (\fBstdscr\fP)
+mvhline_set	window (\fBstdscr\fP)
+mvin_wch	window (\fBstdscr\fP)
+mvin_wchnstr	window (\fBstdscr\fP)
+mvin_wchstr	window (\fBstdscr\fP)
+mvinch	window (\fBstdscr\fP)
+mvinchnstr	window (\fBstdscr\fP)
+mvinchstr	window (\fBstdscr\fP)
+mvinnstr	window (\fBstdscr\fP)
+mvinnwstr	window (\fBstdscr\fP)
+mvins_nwstr	window (\fBstdscr\fP)
+mvins_wch	window (\fBstdscr\fP)
+mvins_wstr	window (\fBstdscr\fP)
+mvinsch	window (\fBstdscr\fP)
+mvinsnstr	window (\fBstdscr\fP)
+mvinsstr	window (\fBstdscr\fP)
+mvinstr	window (\fBstdscr\fP)
+mvinwstr	window (\fBstdscr\fP)
+mvprintw	window (\fBstdscr\fP)
+mvscanw	screen
+mvvline	window (\fBstdscr\fP)
+mvvline_set	window (\fBstdscr\fP)
+mvwadd_wch	window
+mvwadd_wchnstr	window
+mvwadd_wchstr	window
+mvwaddch	window
+mvwaddchnstr	window
+mvwaddchstr	window
+mvwaddnstr	window
+mvwaddnwstr	window
+mvwaddstr	window
+mvwaddwstr	window
+mvwchgat	window
+mvwdelch	window
+mvwget_wch	screen (input operation)
+mvwget_wstr	screen (input operation)
+mvwgetch	screen (input operation)
+mvwgetn_wstr	screen (input operation)
+mvwgetnstr	screen (input operation)
+mvwgetstr	screen (input operation)
+mvwhline	window
+mvwhline_set	window
+mvwin	window
+mvwin_wch	window
+mvwin_wchnstr	window
+mvwin_wchstr	window
+mvwinch	window
+mvwinchnstr	window
+mvwinchstr	window
+mvwinnstr	window
+mvwinnwstr	window
+mvwins_nwstr	window
+mvwins_wch	window
+mvwins_wstr	window
+mvwinsch	window
+mvwinsnstr	window
+mvwinsstr	window
+mvwinstr	window
+mvwinwstr	window
+mvwprintw	window
+mvwscanw	screen
+mvwvline	window
+mvwvline_set	window
+napms	reentrant
+newpad	global (locks window list)
+newscr	screen (read-only)
+newterm	global (locks screen list)
+newwin	global (locks window list)
+nl	screen
+nocbreak	screen
+nodelay	window
+noecho	screen
+nofilter	global
+nonl	screen
+noqiflush	terminal
+noraw	screen
+notimeout	window
+numcodes	global (read-only)
+numfnames	global (read-only)
+numnames	global (read-only)
+ospeed	global
+overlay	window (locks source, target)
+overwrite	window (locks source, target)
+pair_content	screen
+pecho_wchar	screen
+pechochar	screen
+pnoutrefresh	screen
+prefresh	screen
+printw	window
+putp	global
+putwin	window
+qiflush	terminal
+raw	screen
+redrawwin	window
+refresh	screen
+reset_prog_mode	screen
+reset_shell_mode	screen
+resetty	terminal
+resize_term	screen (locks window list)
+resizeterm	screen
+restartterm	screen
+ripoffline	global (static data)
+savetty	terminal
+scanw	screen
+scr_dump	screen
+scr_init	screen
+scr_restore	screen
+scr_set	screen
+scrl	window (\fBstdscr\fP)
+scroll	window
+scrollok	window
+set_curterm	screen
+set_escdelay	screen
+set_tabsize	screen
+set_term	global (locks screen list, screen)
+setcchar	reentrant
+setscrreg	window (\fBstdscr\fP)
+setupterm	global
+slk_attr	screen
+slk_attr_off	screen
+slk_attr_on	screen
+slk_attr_set	screen
+slk_attroff	screen
+slk_attron	screen
+slk_attrset	screen
+slk_clear	screen
+slk_color	screen
+slk_init	screen
+slk_label	screen
+slk_noutrefresh	screen
+slk_refresh	screen
+slk_restore	screen
+slk_set	screen
+slk_touch	screen
+slk_wset	screen
+standend	window
+standout	window
+start_color	screen
+\fBstdscr\fP	screen (read-only)
+strcodes	global (read-only)
+strfnames	global (read-only)
+strnames	global (read-only)
+subpad	window
+subwin	window
+syncok	window
+term_attrs	screen
+termattrs	screen
+termname	terminal
+tgetent	global
+tgetflag	global
+tgetnum	global
+tgetstr	global
+tgoto	global
+tigetflag	terminal
+tigetnum	terminal
+tigetstr	terminal
+timeout	window (\fBstdscr\fP)
+touchline	window
+touchwin	window
+tparm	global (static data)
+tputs	screen
+trace	global (static data)
+ttytype	screen (read-only)
+typeahead	screen
+unctrl	screen
+unget_wch	screen (input operation)
+ungetch	screen (input operation)
+ungetmouse	screen (input operation)
+untouchwin	window
+use_default_colors	screen
+use_env	global (static data)
+use_extended_names	global (static data)
+use_legacy_coding	screen
+use_screen	global (locks screen list, screen)
+use_window	global (locks window list, window)
+vid_attr	screen
+vid_puts	screen
+vidattr	screen
+vidputs	screen
+vline	window (\fBstdscr\fP)
+vline_set	window (\fBstdscr\fP)
+vw_printw	window
+vw_scanw	screen
+vwprintw	window
+vwscanw	screen
+wadd_wch	window
+wadd_wchnstr	window
+wadd_wchstr	window
+waddch	window
+waddchnstr	window
+waddchstr	window
+waddnstr	window
+waddnwstr	window
+waddstr	window
+waddwstr	window
+wattr_get	window
+wattr_off	window
+wattr_on	window
+wattr_set	window
+wattroff	window
+wattron	window
+wattrset	window
+wbkgd	window
+wbkgdset	window
+wbkgrnd	window
+wbkgrndset	window
+wborder	window
+wborder_set	window
+wchgat	window
+wclear	window
+wclrtobot	window
+wclrtoeol	window
+wcolor_set	window
+wcursyncup	screen (affects window plus parents)
+wdelch	window
+wdeleteln	window
+wecho_wchar	window
+wechochar	window
+wenclose	window
+werase	window
+wget_wch	screen (input operation)
+wget_wstr	screen (input operation)
+wgetbkgrnd	window
+wgetch	screen (input operation)
+wgetdelay	window
+wgetn_wstr	screen (input operation)
+wgetnstr	screen (input operation)
+wgetparent	window
+wgetscrreg	window
+wgetstr	screen (input operation)
+whline	window
+whline_set	window
+win_wch	window
+win_wchnstr	window
+win_wchstr	window
+winch	window
+winchnstr	window
+winchstr	window
+winnstr	window
+winnwstr	window
+wins_nwstr	window
+wins_wch	window
+wins_wstr	window
+winsch	window
+winsdelln	window
+winsertln	window
+winsnstr	window
+winsstr	window
+winstr	window
+winwstr	window
+wmouse_trafo	window
+wmove	window
+wnoutrefresh	screen
+wprintw	window
+wredrawln	window
+wrefresh	screen
+wresize	window (locks window list)
+wscanw	screen
+wscrl	window
+wsetscrreg	window
+wstandend	window
+wstandout	window
+wsyncdown	screen (affects window plus parents)
+wsyncup	screen (affects window plus parents)
+wtimeout	window
+wtouchln	window
+wunctrl	global (static data)
+wvline	window
+wvline_set	window
 .TE
 .\" ***************************************************************************
 .SH RETURN VALUE
-These functions all return \fBTRUE\fP or \fBFALSE\fP, except as noted.
+\fB\%get_escdelay\fP returns the value of \fB\%ESCDELAY\fP.
+\fB\%set_escdelay\fP and \fB\%set_tabsize\fP return \fBERR\fP upon
+failure and \fBOK\fP upon successful completion.
+\fB\%use_screen\fP and \fB\%use_window\fP return the \fIint\fP returned
+by the user-supplied function they are called with.
 .SH NOTES
-Both a macro and a function are provided for each name.
+\fI\%ncurses\fP provides both a C function and a preprocessor macro for
+each function documented in this page.
 .SH PORTABILITY
-These routines are specific to ncurses.
+These routines are specific to \fI\%ncurses\fP.
 They were not supported on Version 7, BSD or System V implementations.
-It is recommended that any code depending on ncurses extensions
-be conditioned using NCURSES_VERSION.
+It is recommended that any code depending on \fI\%ncurses\fP extensions
+be conditioned using \fB\%NCURSES_VERSION\fP.
 .SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_opaque\fR(3X),
-\fBcurs_variables\fR(3X).
+\fB\%curses\fP(3X),
+\fB\%curs_opaque\fP(3X),
+\fB\%curs_variables\fP(3X)
diff --git a/contrib/ncurses/man/curs_touch.3x b/contrib/ncurses/man/curs_touch.3x
index b5ea35b3fa3f..613b6958268d 100644
--- a/contrib/ncurses/man/curs_touch.3x
+++ b/contrib/ncurses/man/curs_touch.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2015,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,36 +27,32 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_touch.3x,v 1.23 2020/10/24 09:51:21 tom Exp $
-.TH curs_touch 3X ""
-.na
-.hy 0
+.\" $Id: curs_touch.3x,v 1.47 2024/04/20 21:20:07 tom Exp $
+.TH curs_touch 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
-\fBtouchwin\fR,
-\fBtouchline\fR,
-\fBuntouchwin\fR,
-\fBwtouchln\fR,
-\fBis_linetouched\fR,
-\fBis_wintouched\fR \- \fBcurses\fR refresh control routines
-.ad
-.hy
+\fB\%touchwin\fP,
+\fB\%touchline\fP,
+\fB\%untouchwin\fP,
+\fB\%wtouchln\fP,
+\fB\%is_linetouched\fP,
+\fB\%is_wintouched\fP \-
+control terminal output refresh in a \fIcurses\fR window
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBint touchline(WINDOW *\fP\fIwin\fP\fB, int \fP\fIstart\fP\fB, int \fP\fIcount\fP\fB);\fR
-.sp
-\fBint touchwin(WINDOW *\fP\fIwin\fP\fB);\fR
-.br
-\fBint wtouchln(WINDOW *\fP\fIwin\fP\fB, int \fP\fIy\fP\fB, int \fP\fIn\fP\fB, int \fP\fIchanged\fP\fB);\fR
-.sp
-\fBint untouchwin(WINDOW *\fP\fIwin\fP\fB);\fR
-.sp
-\fBbool is_linetouched(WINDOW *\fP\fIwin\fP\fB, int \fP\fIline\fP\fB);\fR
-.br
-\fBbool is_wintouched(WINDOW *\fP\fIwin\fP\fB);\fR
-.br
+.nf
+\fB#include <curses.h>
+.PP
+\fBint touchline(WINDOW *\fIwin\fP, int \fIstart\fP, int \fIcount\fP);
+.PP
+\fBint touchwin(WINDOW *\fIwin\fP);
+\fBint wtouchln(WINDOW *\fIwin\fP, int \fIy\fP, int \fIn\fP, int \fIchanged\fP);
+.PP
+\fBint untouchwin(WINDOW *\fIwin\fP);
+.PP
+\fBbool is_linetouched(WINDOW *\fIwin\fP, int \fIline\fP);
+\fBbool is_wintouched(WINDOW *\fIwin\fP);
+.fi
 .SH DESCRIPTION
-The \fBtouchwin\fR and \fBtouchline\fR routines throw away all
+The \fB\%touchwin\fP and \fB\%touchline\fP routines throw away all
 optimization information about which parts of the window have been
 touched, by pretending that the entire window has been drawn on.
 This
@@ -64,35 +60,35 @@ is sometimes necessary when using overlapping windows, since a change
 to one window affects the other window, but the records of which lines
 have been changed in the other window do not reflect the change.
 The
-routine \fBtouchline\fR only pretends that \fIcount\fR lines have been
-changed, beginning with line \fIstart\fR.
+routine \fB\%touchline\fP only pretends that \fIcount\fP lines have been
+changed, beginning with line \fIstart\fP.
 .PP
-The \fBuntouchwin\fR routine marks all lines in the window as unchanged since
-the last call to \fBwrefresh\fR.
+The \fB\%untouchwin\fP routine marks all lines in the window as unchanged since
+the last call to \fB\%wrefresh\fP.
 .PP
-The \fBwtouchln\fR routine makes \fIn\fR lines in the window, starting
-at line \fIy\fR, look as if they have (\fIchanged\fR\fB=1\fR) or have
-not (\fIchanged\fR\fB=0\fR) been changed since the last call to
-\fBwrefresh\fR.
+The \fB\%wtouchln\fP routine makes \fIn\fP lines in the window, starting
+at line \fIy\fR, look as if they have (\fIchanged\fB=1\fR) or have
+not (\fIchanged\fB=0\fR) been changed since the last call to
+\fB\%wrefresh\fP.
 .PP
-The \fBis_linetouched\fR and \fBis_wintouched\fR routines return
-\fBTRUE\fR if the specified line/window was modified since the last
-call to \fBwrefresh\fR; otherwise they return \fBFALSE\fR.  In
-addition, \fBis_linetouched\fR returns \fBERR\fR if \fIline\fR is not
+The \fB\%is_linetouched\fP and \fB\%is_wintouched\fP routines return
+\fBTRUE\fP if the specified line/window was modified since the last
+call to \fB\%wrefresh\fP; otherwise they return \fBFALSE\fP.  In
+addition, \fB\%is_linetouched\fP returns \fBERR\fP if \fIline\fP is not
 valid for the given window.
 .SH RETURN VALUE
-All routines return the integer \fBERR\fR upon failure and an integer value
-other than \fBERR\fR upon successful completion, unless otherwise noted in the
+All routines return the integer \fBERR\fP upon failure and an integer value
+other than \fBERR\fP upon successful completion, unless otherwise noted in the
 preceding routine descriptions.
 .PP
-X/Open does not define any error conditions.
+X/Open Curses does not specify any error conditions.
 In this implementation
 .RS 3
 .TP 5
 \fBis_linetouched\fP
-returns an error 
+returns an error
 if the window pointer is null, or
-if the line number is outside the window.
+if the line number is outside the window boundaries.
 .IP
 The constant \fBERR\fP is distinct from \fBTRUE\fP and \fBFALSE\fP,
 which are the normal return values of this function.
@@ -101,29 +97,28 @@ returning \fBERR\fP (which is neither \fBTRUE\fP nor \fBFALSE\fP)
 may not be supported by the compiler.
 .IP
 To provide error-checking and also match the X/Open function prototype,
-the \fBERR\fP is provided by a macro named \fBis_linetouched\fP.
+the \fBERR\fP is provided by a macro named \fB\%is_linetouched\fP.
 The actual function returns \fBFALSE\fP when it detects an error.
 .TP 5
 \fBwtouchln\fP
-returns an error 
+returns an error
 if the window pointer is null, or
-if the line number is outside the window.
+if the line number is outside the window boundaries.
 .RE
+.SH NOTES
+All of these routines except \fB\%wtouchln\fP may be macros.
 .SH PORTABILITY
-.PP
 These functions were introduced by SVr4.
-The Solaris curses header file,
+The Solaris \fIcurses\fP header file,
 for instance, defines both an actual function and macro for each.
 The macros give the same result as the actual functions.
-SVr4 curses does not check the window parameter \fIwin\fP to ensure
+SVr4 \fIcurses\fP does not check the window parameter \fIwin\fP to ensure
 that it is not \fBNULL\fP;
 otherwise this implementation behaves the same as SVr4.
 .PP
-The XSI Curses standard, Issue 4 describes these functions,
+X/Open Curses, Issue 4 describes these functions,
 but defines no error conditions.
-.SH NOTES
-All of these routines except \fBwtouchln\fR may be macros.
 .SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_refresh\fR(3X),
-\fBcurs_variables\fR(3X).
+\fB\%curses\fP(3X),
+\fB\%curs_refresh\fP(3X),
+\fB\%curs_variables\fP(3X)
diff --git a/contrib/ncurses/man/curs_trace.3x b/contrib/ncurses/man/curs_trace.3x
index 513340a362f4..ddae79112541 100644
--- a/contrib/ncurses/man/curs_trace.3x
+++ b/contrib/ncurses/man/curs_trace.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2019,2020 Thomas E. Dickey                                     *
+.\" Copyright 2019-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 2000-2016,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,84 +27,93 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_trace.3x,v 1.21 2020/02/02 23:34:34 tom Exp $
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: curs_trace.3x,v 1.50 2024/04/20 21:24:19 tom Exp $
+.TH curs_trace 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.TH curs_trace 3X ""
+.
+.de dS \" Start unfilled display.
+.nr aD \n(.j
 .na
-.hy 0
+..
+.
+.de dE \" End unfilled display.
+.ad \n(.j
+.rr aD
+..
+.
 .SH NAME
-\fBcurses_trace\fR,
-\fBtrace\fR,
-\fB_tracef\fR,
-\fB_traceattr\fR,
-\fB_traceattr2\fR,
-\fB_tracecchar_t\fR,
-\fB_tracecchar_t2\fR,
-\fB_tracechar\fR,
-\fB_tracechtype\fR,
-\fB_tracechtype2\fR,
-\fB_nc_tracebits\fR,
-\fB_tracedump\fR,
-\fB_tracemouse\fR \- \fBcurses\fR debugging routines
-.ad
-.hy
+\fB\%curses_trace\fP,
+\fB\%trace\fP,
+\fB\%_tracef\fP,
+\fB\%_traceattr\fP,
+\fB\%_traceattr2\fP,
+\fB\%_tracecchar_t\fP,
+\fB\%_tracecchar_t2\fP,
+\fB\%_tracechar\fP,
+\fB\%_tracechtype\fP,
+\fB\%_tracechtype2\fP,
+\fB\%_nc_tracebits\fP,
+\fB\%_tracedump\fP,
+\fB\%_tracemouse\fP \-
+\fIcurses\fR debugging routines
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBunsigned curses_trace(const unsigned \fP\fIparam\fP\fB);\fR
-.sp
-\fBvoid _tracef(const char *\fP\fIformat\fP\fB, ...);\fR
-.sp
-\fBchar *_traceattr(attr_t \fP\fIattr\fP\fB);\fR
-.br
-\fBchar *_traceattr2(int \fP\fIbuffer\fP\fB, chtype \fP\fIch\fP\fB);\fR
-.br
-\fBchar *_tracecchar_t(const cchar_t *\fP\fIstring\fP\fB);\fR
-.br
-\fBchar *_tracecchar_t2(int \fP\fIbuffer\fP\fB, const cchar_t *\fP\fIstring\fP\fB);\fR
-.br
-\fBchar *_tracechar(int \fP\fIch\fP\fB);\fR
-.br
-\fBchar *_tracechtype(chtype \fP\fIch\fP\fB);\fR
-.br
-\fBchar *_tracechtype2(int \fP\fIbuffer\fP\fB, chtype \fP\fIch\fP\fB);\fR
-.sp
-\fBvoid _tracedump(const char *\fP\fIlabel\fP\fB, WINDOW *\fP\fIwin\fP\fB);\fR
-.br
-\fBchar *_nc_tracebits(void);\fR
-.br
-\fBchar *_tracemouse(const MEVENT *\fP\fIevent\fP\fB);\fR
-.sp
-/* deprecated */
-.br
-\fBvoid trace(const unsigned int \fP\fIparam\fP\fB);\fR
+.nf
+\fB#include <curses.h>
+.PP
+\fBunsigned curses_trace(const unsigned \fItrace-mask\fP);
+.PP
+\fBvoid _tracef(const char *\fIformat\fP, ...);
+.PP
+\fBchar *_traceattr(attr_t \fIattr\fP);
+\fBchar *_traceattr2(int \fIbuffer\fP, chtype \fIch\fP);
+\fBchar *_tracecchar_t(const cchar_t *\fIstring\fP);
+\fBchar *_tracecchar_t2(int \fIbuffer\fP, const cchar_t *\fIstring\fP);
+\fBchar *_tracechar(int \fIc\fP);
+\fBchar *_tracechtype(chtype \fIch\fP);
+\fBchar *_tracechtype2(int \fIbuffer\fP, chtype \fIch\fP);
+.PP
+\fBvoid _tracedump(const char *\fIlabel\fP, WINDOW *\fIwin\fP);
+\fBchar *_nc_tracebits(void);
+\fBchar *_tracemouse(const MEVENT *\fIevent\fP);
+.PP
+\fI/* deprecated */\fP
+\fBvoid trace(const unsigned int \fItrace-mask\fP);
+.fi
 .SH DESCRIPTION
-The \fIcurses trace\fR routines are used for debugging the ncurses libraries,
-as well as applications which use the ncurses libraries.
+The \fIcurses trace\fP routines are used for debugging the
+\fI\%ncurses\fP libraries,
+as well as applications which use the \fI\%ncurses\fP libraries.
 Some limitations apply:
 .bP
 Aside from \fBcurses_trace\fP,
 the other functions are normally available only with the debugging library
-e.g., \fIlibncurses_g.a\fR.
+e.g., \fBlibncurses_g.a\fP.
 .IP
 All of the trace functions may be compiled into any model (shared, static,
-profile) by defining the symbol \fBTRACE\fR.
+profile) by defining the symbol \fBTRACE\fP.
 .bP
 Additionally, the functions which use \fBcchar_t\fP
 are only available with the wide-character configuration of the libraries.
 .SS Functions
 The principal parts of this interface are
 .bP
-\fBcurses_trace\fR, which selectively enables different tracing features, and
+\fBcurses_trace\fP, which selectively enables different tracing features, and
 .bP
-\fB_tracef\fR, which writes formatted data to the \fItrace\fR file.
+\fB_tracef\fP, which writes formatted data to the \fItrace\fP file.
 .IP
 The other functions either return a pointer to a string-area
 (allocated by the corresponding function), or return no value
@@ -116,22 +125,22 @@ To work around the problem of a single string-area per function,
 some use a buffer-number parameter, telling the library to allocate
 additional string-areas.
 .PP
-The \fBcurses_trace\fR function is always available,
+The \fBcurses_trace\fP function is always available,
 whether or not the other trace functions are available:
 .bP
 If tracing is available,
-calling \fBcurses_trace\fR with a nonzero parameter
+calling \fBcurses_trace\fP with a nonzero parameter
 updates the trace mask,
 and returns the previous trace mask.
 .IP
 When the trace mask is nonzero,
-ncurses creates the file \*(``trace\*('' in the current directory for output.
+\fI\%ncurses\fP creates the file \*(``trace\*('' in the current directory for output.
 If the file already exists, no tracing is done.
 .bP
 If tracing is not available, \fBcurses_trace\fP returns zero (0).
-.SS Trace Parameter
+.SS "Trace Parameter"
 The trace parameter is formed by OR'ing
-values from the list of \fBTRACE_\fP\fIxxx\fR definitions in \fB<curses.h>\fR.
+values from the list of \fBTRACE_\fIxxx\fR definitions in \fB<curses.h>\fR.
 These include:
 .TP 5
 .B TRACE_DISABLE
@@ -167,7 +176,7 @@ trace all curses calls.
 The parameters for each call are traced, as well as return values.
 .TP 5
 .B TRACE_VIRTPUT
-trace virtual character puts, i.e., calls to \fBaddch\fR.
+trace virtual character puts, i.e., calls to \fBaddch\fP.
 .TP 5
 .B TRACE_IEVENT
 trace low-level input processing, including timeouts.
@@ -190,35 +199,11 @@ trace changes to video attributes and colors.
 .B TRACE_MAXIMUM
 maximum trace level, enables all of the separate trace features.
 .PP
-Some tracing features are enabled whenever the \fBcurses_trace\fR parameter
+Some tracing features are enabled whenever the \fBcurses_trace\fP parameter
 is nonzero.
 Some features overlap.
 The specific names are used as a guideline.
-.SS Initialization
-These functions check the \fBNCURSES_TRACE\fP environment variable,
-to set the tracing feature as if \fBcurses_trace\fP was called:
-.RS 4
-.PP
-.na
-.hy 0
-filter,
-initscr,
-new_prescr,
-newterm,
-nofilter,
-restartterm,
-ripoffline,
-setupterm,
-slk_init,
-tgetent,
-use_env,
-use_extended_names,
-use_tioctl
-.hy
-.ad
-.RE
-.SS Command-line Utilities
-.PP
+.SS "Command-line Utilities"
 The command-line utilities such as \fBtic\fP(1) provide a verbose option
 which extends the set of messages written using the \fBcurses_trace\fP function.
 Both of these (\fB\-v\fP and \fBcurses_trace\fP)
@@ -228,22 +213,47 @@ which determines the messages which are written.
 Because the command-line utilities may call initialization functions
 such as \fBsetupterm\fP, \fBtgetent\fP or \fBuse_extended_names\fP,
 some of their debugging output may be directed to the \fItrace\fP file
-if the \fBNCURSES_TRACE\fP environment variable is set:
+if the \fI\%NCURSES_TRACE\fP environment variable is set:
 .bP
 messages produced in the utility are written to the standard error.
 .bP
 messages produced by the underlying library are written to \fItrace\fP.
 .PP
-If ncurses is built without tracing, none of the latter are produced,
+If \fI\%ncurses\fP is built without tracing,
+none of the latter are produced,
 and fewer diagnostics are provided by the command-line utilities.
 .SH RETURN VALUE
 Routines which return a value are designed to be used as parameters
-to the \fB_tracef\fR routine.
+to the \fB_tracef\fP routine.
+.SH ENVIRONMENT
+.SS NCURSES_TRACE
+A positive integral value stored in this variable causes the following
+functions to enable the tracing feature as if
+.B \%curses_trace
+were called.
+.PP
+.dS
+.RS 4
+\fB\%filter\fP,
+\fB\%initscr\fP,
+\fB\%new_prescr\fP,
+\fB\%newterm\fP,
+\fB\%nofilter\fP,
+\fB\%restartterm\fP,
+\fB\%ripoffline\fP,
+\fB\%setupterm\fP,
+\fB\%slk_init\fP,
+\fB\%tgetent\fP,
+\fB\%use_env\fP,
+\fB\%use_extended_names\fP,
+\fB\%use_tioctl\fP
+.RE
+.dE
 .SH PORTABILITY
-These functions are not part of the XSI interface.
+These functions are not part of the X/Open Curses interface.
 Some other curses implementations are known to
 have similar features,
-but they are not compatible with ncurses:
+but they are not compatible with \fI\%ncurses\fP:
 .bP
 SVr4 provided \fBtraceon\fP and \fBtraceoff\fP,
 to control whether debugging information was written
@@ -262,21 +272,22 @@ only when a debug-library is built.
 .IP
 PDCurses has a short description of these functions,
 with a note that they are not present in X/Open Curses,
-ncurses or NetBSD.
+\fI\%ncurses\fP or NetBSD.
 It does not mention SVr4,
 but the functions' inclusion in a header file section
 labeled \*(``Quasi-standard\*('' hints at the origin.
 .bP
 NetBSD does not provide functions for enabling/disabling traces.
 It uses environment variables
-\fBCURSES_TRACE_MASK\fP and
-\fBCURSES_TRACE_FILE\fP to determine what is traced,
+\fI\%CURSES_TRACE_MASK\fP and
+\fI\%CURSES_TRACE_FILE\fP to determine what is traced,
 and where the results are written.
 This is available only when a debug-library is built.
 .IP
 The NetBSD tracing feature is undocumented.
 .PP
-A few ncurses functions are not provided when symbol versioning is used:
+A few \fI\%ncurses\fP functions are not provided when symbol versioning
+is used:
 .RS 4
 .PP
 _nc_tracebits,
@@ -287,4 +298,4 @@ _tracemouse
 The original \fBtrace\fP routine was deprecated because
 it often conflicted with application names.
 .SH SEE ALSO
-\fBcurses\fR(3X).
+\fB\%curses\fP(3X)
diff --git a/contrib/ncurses/man/curs_util.3x b/contrib/ncurses/man/curs_util.3x
index f833803a412d..1df0a1d3f394 100644
--- a/contrib/ncurses/man/curs_util.3x
+++ b/contrib/ncurses/man/curs_util.3x
@@ -1,6 +1,6 @@
 '\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2015,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,121 +28,133 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_util.3x,v 1.60 2020/12/19 22:44:46 tom Exp $
-.TH curs_util 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: curs_util.3x,v 1.101 2024/04/20 21:20:07 tom Exp $
+.TH curs_util 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.na
-.hy 0
 .SH NAME
-\fBdelay_output\fR,
-\fBfilter\fR,
-\fBflushinp\fR,
-\fBgetwin\fR,
-\fBkey_name\fR,
-\fBkeyname\fR,
-\fBnofilter\fR,
-\fBputwin\fR,
-\fBunctrl\fR,
-\fBuse_env\fR,
-\fBuse_tioctl\fR,
-\fBwunctrl\fR \- miscellaneous \fBcurses\fR utility routines
-.ad
-.hy
+\fB\%delay_output\fP,
+\fB\%filter\fP,
+\fB\%flushinp\fP,
+\fB\%getwin\fP,
+\fB\%key_name\fP,
+\fB\%keyname\fP,
+\fB\%nofilter\fP,
+\fB\%putwin\fP,
+\fB\%unctrl\fP,
+\fB\%use_env\fP,
+\fB\%use_tioctl\fP,
+\fB\%wunctrl\fP \-
+miscellaneous \fIcurses\fR utility routines
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBconst char *unctrl(chtype \fP\fIc\fP\fB);\fR
-.br
-\fBwchar_t *wunctrl(cchar_t *\fP\fIc\fP\fB);\fR
-.sp
-\fBconst char *keyname(int \fP\fIc\fP\fB);\fR
-.br
-\fBconst char *key_name(wchar_t \fP\fIw\fP\fB);\fR
-.sp
-\fBvoid filter(void);\fR
-.br
-\fBvoid nofilter(void);\fR
-.sp
-\fBvoid use_env(bool \fP\fIf\fP\fB);\fR
-.br
-\fBvoid use_tioctl(bool \fP\fIf\fP\fB);\fR
-.sp
-\fBint putwin(WINDOW *\fP\fIwin\fP\fB, FILE *\fP\fIfilep\fP\fB);\fR
-.br
-\fBWINDOW *getwin(FILE *\fP\fIfilep\fP\fB);\fR
-.sp
-\fBint delay_output(int \fP\fIms\fP\fB);\fR
-.br
-\fBint flushinp(void);\fR
-.br
-.SH DESCRIPTION
-.SS unctrl
+.nf
+\fB#include <curses.h>
 .PP
-The \fBunctrl\fR routine returns a character string which is a printable
-representation of the character \fIc\fR, ignoring attributes.
-Control characters are displayed in the \fB^\fR\fIX\fR notation.
-Printing characters are displayed as is.
-The corresponding \fBwunctrl\fR returns a printable representation of
-a wide character.
-.SS keyname/key_name
+\fBconst char *unctrl(chtype \fIch\fP);
+\fBwchar_t *wunctrl(cchar_t *\fIwch\fP);
+.PP
+\fBconst char *keyname(int \fIc\fP);
+\fBconst char *key_name(wchar_t \fIwc\fP);
+.PP
+\fBvoid filter(void);
 .PP
-The \fBkeyname\fR routine returns a character string
-corresponding to the key \fIc\fR:
+\fBvoid use_env(bool \fIf\fP);
+.PP
+\fBint putwin(WINDOW *\fIwin\fP, FILE *\fIfilep\fP);
+\fBWINDOW *getwin(FILE *\fIfilep\fP);
+.PP
+\fBint delay_output(int \fIms\fP);
+\fBint flushinp(void);
+.PP
+\fI/* extensions */
+\fBvoid nofilter(void);
+\fBvoid use_tioctl(bool \fIf\fP);
+.fi
+.SH DESCRIPTION
+.SS unctrl
+The \fBunctrl\fP routine returns a character string which is a printable
+representation of the character \fIch\fP:
 .bP
 Printable characters are displayed as themselves,
 e.g., a one-character string containing the key.
 .bP
-Control characters are displayed in the \fB^\fR\fIX\fR notation.
+Control characters are displayed in the \fB^\fIX\fR notation.
+.bP
+Printing characters are displayed as is.
 .bP
 DEL (character 127) is displayed as \fB^?\fP.
 .bP
 Values above 128 are either meta characters
 (if the screen has not been initialized,
 or if \fBmeta\fP(3X) has been called with a \fBTRUE\fP parameter),
-shown in the \fBM\-\fR\fIX\fR notation,
+shown in the \fBM\-\fIX\fR notation,
 or are displayed as themselves.
 In the latter case, the values may not be printable;
 this follows the X/Open specification.
+.PP
+The corresponding \fBwunctrl\fP returns a printable representation of
+a complex character \fIwch\fP.
+.PP
+In both \fBunctrl\fP and \fBwunctrl\fP the attributes and color associated
+with the character parameter are ignored.
+.SS "keyname, key_name"
+The \fBkeyname\fP routine returns a character string
+corresponding to the key \fIc\fP.
+Key codes are different from character codes.
+.bP
+Key codes below 256 are characters.
+They are displayed using \fBunctrl\fP.
 .bP
-Values above 256 may be the names of the names of function keys.
+Values above 256 may be the codes for function keys.
+The function key name is displayed.
 .bP
-Otherwise (if there is no corresponding name) the function returns null,
-to denote an error.
+Otherwise (if there is no corresponding name and the key is not a character)
+the function returns null, to denote an error.
 X/Open also lists an \*(``UNKNOWN KEY\*('' return value,
 which some implementations return rather than null.
 .LP
-The corresponding \fBkey_name\fR returns a character string corresponding
-to the wide-character value \fIw\fR.
-The two functions do not return the same set of strings;
-the latter returns null where the former would display a meta character.
-.SS filter/nofilter
-.PP
-The \fBfilter\fR routine, if used, must be called before \fBinitscr\fR or
-\fBnewterm\fR are called.
+The corresponding \fBkey_name\fP returns
+a multibyte character string corresponding
+to the wide-character value \fIw\fP.
+The two functions (\fBkeyname\fP and \fBkey_name\fP)
+do not return the same set of strings:
+.bP
+\fBkeyname\fP returns null where \fBkey_name\fP would display a meta character.
+.bP
+\fBkey_name\fP does not return the name of a function key.
+.SS "filter, nofilter"
+The \fBfilter\fP routine, if used, must be called before \fBinitscr\fP or
+\fBnewterm\fP are called.
 Calling \fBfilter\fP causes these changes in initialization:
 .bP
-\fBLINES\fR is set to 1;
+\fBLINES\fP is set to 1;
 .bP
 the capabilities
-\fBclear\fR,
-\fBcud1\fR,
-\fBcud\fR,
-\fBcup\fR,
-\fBcuu1\fR,
-\fBcuu\fR,
-\fBvpa\fR
+\fBclear\fP,
+\fBcud1\fP,
+\fBcud\fP,
+\fBcup\fP,
+\fBcuu1\fP,
+\fBcuu\fP,
+\fBvpa\fP
 are disabled;
 .bP
 the capability \fBed\fP is disabled if \fBbce\fP is set;
 .bP
-and the \fBhome\fR string is set to the value of \fBcr\fR.
+and the \fBhome\fP string is set to the value of \fBcr\fP.
 .PP
 The \fBnofilter\fP routine cancels the effect of a preceding \fBfilter\fP
 call.
@@ -151,15 +163,15 @@ using a different value of \fB$TERM\fP.
 The limitation arises because the \fBfilter\fP routine modifies the
 in-memory copy of the terminal information.
 .SS use_env
-.PP
-The \fBuse_env\fR routine, if used,
-should be called before \fBinitscr\fR or
-\fBnewterm\fR are called
+The \fBuse_env\fP routine, if used,
+should be called before \fBinitscr\fP or
+\fBnewterm\fP are called
 (because those compute the screen size).
-It modifies the way \fBncurses\fP treats environment variables
+It modifies the way \fI\%ncurses\fP treats environment variables
 when determining the screen size.
 .bP
-Normally \fBncurses\fP looks first at the terminal database for the screen size.
+Normally \fI\%ncurses\fP looks first at the terminal database for the
+screen size.
 .IP
 If \fBuse_env\fP was called with \fBFALSE\fP for parameter,
 it stops here unless
@@ -170,74 +182,74 @@ If successful,
 it overrides the values from the terminal database.
 .bP
 Finally (unless \fBuse_env\fP was called with \fBFALSE\fP parameter),
-\fBncurses\fP examines the \fBLINES\fR or \fBCOLUMNS\fR environment variables,
+\fI\%ncurses\fP examines the \fILINES\fP or \fI\%COLUMNS\fP environment
+variables,
 using a value in those to override the results
 from the operating system or terminal database.
 .IP
-\fBNcurses\fP also updates the screen size in response to \fBSIGWINCH\fP,
-unless overridden by the \fBLINES\fR or \fBCOLUMNS\fR environment variables,
+\fI\%curses\fP also updates the screen size in response to
+\fBSIGWINCH\fP,
+unless overridden by the \fILINES\fP or \fI\%COLUMNS\fP environment
+variables,
 .SS use_tioctl
-.PP
-The \fBuse_tioctl\fR routine, if used,
-should be called before \fBinitscr\fR or \fBnewterm\fR are called
+The \fBuse_tioctl\fP routine, if used,
+should be called before \fBinitscr\fP or \fBnewterm\fP are called
 (because those compute the screen size).
-After \fBuse_tioctl\fR is called with \fBTRUE\fR as an argument,
-\fBncurses\fP modifies the last step in its computation
+After \fBuse_tioctl\fP is called with \fBTRUE\fP as an argument,
+\fI\%ncurses\fP modifies the last step in its computation
 of screen size as follows:
 .bP
-checks if the \fBLINES\fR and \fBCOLUMNS\fR environment variables
+checks if the \fILINES\fP and \fI\%COLUMNS\fP environment variables
 are set to a number greater than zero.
 .bP
-for each, \fBncurses\fP updates the corresponding environment variable
+for each, \fI\%ncurses\fP updates the corresponding environment variable
 with the value that it has obtained via operating system call
 or from the terminal database.
 .bP
-\fBncurses\fP re-fetches the value of the environment variables so that
-it is still the environment variables which set the screen size.
+\fI\%ncurses\fP re-fetches the value of the environment variables so
+that it is still the environment variables which set the screen size.
 .PP
-The \fBuse_env\fP and \fBuse_tioctl\fP routines combine as
-summarized here:
+The \fB\%use_env\fP and \fB\%use_tioctl\fP routines combine as follows.
+.IP
 .TS
-center tab(/);
-l l l
-_ _ _
-lw7 lw7 lw40.
-\fIuse_env\fR/\fIuse_tioctl\fR/\fISummary\fR
-TRUE/FALSE/T{
+lB lB lB
+lB lB lx.
+use_env	use_tioctl	Summary
+_
+TRUE	FALSE	T{
 This is the default behavior.
-\fBncurses\fP uses operating system calls
-unless overridden by $LINES or $COLUMNS environment variables.
-T}
-TRUE/TRUE/T{
-\fBncurses\fP updates $LINES and $COLUMNS based on operating system calls.
+\fI\%ncurses\fP uses operating system calls
+unless overridden by \fILINES\fP or \fI\%COLUMNS\fP environment
+variables;
+default.
 T}
-FALSE/TRUE/T{
-\fBncurses\fP ignores $LINES and $COLUMNS,
-uses operating system calls to obtain size.
+TRUE	TRUE	T{
+\fI\%ncurses\fP updates \fILINES\fP and \fI\%COLUMNS\fP based on
+operating system calls.
 T}
-FALSE/FALSE/T{
-\fBncurses\fP relies on the terminal database to determine size.
+FALSE	TRUE	T{
+\fI\%ncurses\fP ignores \fILINES\fP and \fI\%COLUMNS\fP,
+using operating system calls to obtain size.
 T}
 .TE
-.SS putwin/getwin
-.PP
-The \fBputwin\fR routine writes all data associated
-with window (or pad) \fIwin\fR into
-the file to which \fIfilep\fR points.
+.SS "putwin, getwin"
+The \fBputwin\fP routine writes all data associated
+with window (or pad) \fIwin\fP into
+the file to which \fIfilep\fP points.
 This information can be later retrieved
-using the \fBgetwin\fR function.
+using the \fBgetwin\fP function.
 .PP
-The \fBgetwin\fR routine reads window related data stored in the file by
-\fBputwin\fR.
+The \fBgetwin\fP routine reads window related data stored in the file by
+\fBputwin\fP.
 The routine then creates and initializes a new window using that
 data.
 It returns a pointer to the new window.
 There are a few caveats:
 .bP
-the data written is a copy of the \fBWINDOW\fP structure,
+the data written is a copy of the \fI\%WINDOW\fP structure,
 and its associated character cells.
-The format differs between the wide-character (\fBncursesw\fP) and
-non-wide (\fBncurses\fP) libraries.
+The format differs between the wide-character (\fI\%ncursesw\fP) and
+non-wide (\fI\%ncurses\fP) libraries.
 You can transfer data between the two, however.
 .bP
 the retrieved window is always created as a top-level window (or pad),
@@ -249,29 +261,38 @@ If cells in the retrieved window use color pairs which have not been
 created in the application using \fBinit_pair\fP,
 they will not be colored when the window is refreshed.
 .SS delay_output
-.PP
-The \fBdelay_output\fR routine inserts an \fIms\fR millisecond pause
+The \fBdelay_output\fP routine inserts an \fIms\fP millisecond pause
 in output.
-This routine should not be used extensively because
-padding characters are used rather than a CPU pause.
-If no padding character is specified,
-this uses \fBnapms\fR to perform the delay.
-.SS flushinp
+Employ this function judiciously when terminal output uses padding,
+because \fI\%ncurses\fP transmits null characters
+(consuming CPU and I/O resources)
+instead of sleeping and requesting resumption from the operating system.
+Padding is used unless:
+.bP
+the terminal description has \fBnpc\fP (\fBno_pad_char\fP) capability, or
+.bP
+the environment variable \fB\%NCURSES_NO_PADDING\fP is set.
 .PP
-The \fBflushinp\fR routine throws away any typeahead that has been typed by the
+If padding is not in use,
+\fI\%ncurses\fP uses \fBnapms\fP to perform the delay.
+If the value of \fIms\fP exceeds 30,000
+(thirty seconds),
+it is capped at that value.
+.SS flushinp
+The \fBflushinp\fP routine throws away any typeahead that has been typed by the
 user and has not yet been read by the program.
 .SH RETURN VALUE
-Except for \fBflushinp\fR, routines that return an integer return \fBERR\fR
-upon failure and \fBOK\fR (SVr4 specifies only "an integer value other than
-\fBERR\fR") upon successful completion.
+Except for \fBflushinp\fP, routines that return an integer return \fBERR\fP
+upon failure and \fBOK\fP (SVr4 specifies only "an integer value other than
+\fBERR\fP") upon successful completion.
 .PP
-Routines that return pointers return \fBNULL\fR on error.
+Routines that return pointers return \fBNULL\fP on error.
 .PP
-X/Open does not define any error conditions.
+X/Open Curses does not specify any error conditions.
 In this implementation
 .RS 3
 .TP 5
-\fBflushinp\fR
+\fBflushinp\fP
 returns an error if the terminal was not initialized.
 .TP 5
 \fBputwin\fP
@@ -279,13 +300,22 @@ returns an error if the associated \fBfwrite\fP calls return an error.
 .RE
 .SH PORTABILITY
 .SS filter
-.PP
-The SVr4 documentation describes the action of \fBfilter\fR only in the vaguest
+The SVr4 documentation describes the action of \fBfilter\fP only in the vaguest
 terms.
-The description here is adapted from the XSI Curses standard (which
-erroneously fails to describe the disabling of \fBcuu\fR).
-.SS keyname
+The description here is adapted from X/Open Curses (which
+erroneously fails to describe the disabling of \fBcuu\fP).
+.SS "delay_output padding"
+The limitation to 30 seconds
+and the use of \fBnapms\fP
+differ from other implementations.
+.bP
+SVr4 curses does not delay if no padding character is available.
+.bP
+NetBSD curses uses \fBnapms\fP when no padding character is available,
+but does not take timing into account when using the padding character.
 .PP
+Neither limits the delay.
+.SS keyname
 The \fBkeyname\fP function may return the names of user-defined
 string capabilities which are defined in the terminfo entry via the \fB\-x\fP
 option of \fB@TIC@\fP.
@@ -296,14 +326,13 @@ the same value for different runs because user-defined codes are
 merged from all terminal descriptions which have been loaded.
 The \fBuse_extended_names\fP(3X) function controls whether this data is
 loaded when the terminal description is read by the library.
-.SS nofilter/use_tioctl
-.PP
-The \fBnofilter\fP and \fBuse_tioctl\fP routines are specific to \fBncurses\fP.
+.SS "nofilter, use_tioctl"
+The \fBnofilter\fP and \fBuse_tioctl\fP routines are specific to
+\fI\%ncurses\fP.
 They were not supported on Version 7, BSD or System V implementations.
-It is recommended that any code depending on \fBncurses\fP extensions
-be conditioned using NCURSES_VERSION.
-.SS putwin/getwin
-.PP
+It is recommended that any code depending on \fI\%ncurses\fP extensions
+be conditioned using \fBNCURSES_VERSION\fP.
+.SS "putwin/getwin file-format"
 The \fBputwin\fP and \fBgetwin\fP functions have several issues with
 portability:
 .bP
@@ -318,9 +347,10 @@ the University of California, Berkeley (in 1982)
 and were later (in 1988) incorporated into SVr4.
 Oddly, there are no such functions in the 4.3BSD curses sources.
 .bP
-Most implementations simply dump the binary \fBWINDOW\fP structure to the file.
+Most implementations simply dump the binary \fI\%WINDOW\fP structure
+to the file.
 These include SVr4 curses, NetBSD and PDCurses,
-as well as older \fBncurses\fP versions.
+as well as older \fI\%ncurses\fP versions.
 This implementation
 (as well as the X/Open variant of Solaris curses, dated 1995)
 uses textual dumps.
@@ -333,10 +363,9 @@ these functions.
 Doing that can run into problems mixing block- and buffered-I/O.
 This implementation reduces the problem on writes by flushing the output.
 However, reading from a file written using mixed schemes may not be successful.
-.SS unctrl/wunctrl
-.PP
-The XSI Curses standard, Issue 4 describes these functions.
-It states that \fBunctrl\fR and \fBwunctrl\fR will return a null pointer if
+.SS "unctrl, wunctrl"
+X/Open Curses, Issue 4 describes these functions.
+It states that \fBunctrl\fP and \fBwunctrl\fP will return a null pointer if
 unsuccessful, but does not define any error conditions.
 This implementation checks for three cases:
 .bP
@@ -358,7 +387,7 @@ and returns the \*(``~@\*('', etc., values in that case.
 parameter values outside the 0 to 255 range.
 \fBunctrl\fP returns a null pointer.
 .PP
-The strings returned by \fBunctrl\fR in this implementation are determined
+The strings returned by \fBunctrl\fP in this implementation are determined
 at compile time,
 showing C1 controls from the upper-128 codes
 with a \*(``~\*('' prefix rather than \*(``^\*(''.
@@ -384,24 +413,23 @@ When treating them as \*(``meta\*('' keys
 this implementation returns strings \*(``M\-^@\*('', \*(``M\-^A\*('', etc.
 .PP
 X/Open Curses documents \fBunctrl\fP as declared in \fB<unctrl.h>\fP,
-which \fBncurses\fP does.
-However, \fBncurses\fP' \fB<curses.h>\fP includes \fB<unctrl.h>\fP,
+which \fI\%ncurses\fP does.
+However, \fI\%ncurses\fP' \fB<curses.h>\fP includes \fB<unctrl.h>\fP,
 matching the behavior of SVr4 curses.
 Other implementations may not do that.
-.SS use_env/use_tioctl
-.PP
-If \fBncurses\fP is configured to provide the sp-functions extension,
+.SS "use_env, use_tioctl"
+If \fI\%ncurses\fP is configured to provide the sp-functions extension,
 the state of \fBuse_env\fP and \fBuse_tioctl\fP may be updated before
 creating each \fIscreen\fP rather than once only
-(\fBcurs_sp_funcs\fR(3X)).
+(\fBcurs_sp_funcs\fP(3X)).
 This feature of \fBuse_env\fP
-is not provided by other implementation of curses.
+is not provided by other implementations of curses.
 .SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_initscr\fR(3X),
-\fBcurs_inopts\fR(3X),
-\fBcurs_kernel\fR(3X),
-\fBcurs_scr_dump\fR(3X),
-\fBcurs_sp_funcs\fR(3X),
-\fBcurs_variables\fR(3X),
-\fBlegacy_coding\fR(3X).
+\fB\%curses\fP(3X),
+\fB\%curs_initscr\fP(3X),
+\fB\%curs_inopts\fP(3X),
+\fB\%curs_kernel\fP(3X),
+\fB\%curs_scr_dump\fP(3X),
+\fB\%curs_sp_funcs\fP(3X),
+\fB\%curs_variables\fP(3X),
+\fB\%legacy_coding\fP(3X)
diff --git a/contrib/ncurses/man/curs_variables.3x b/contrib/ncurses/man/curs_variables.3x
index 25294dfeabf5..467b69444565 100644
--- a/contrib/ncurses/man/curs_variables.3x
+++ b/contrib/ncurses/man/curs_variables.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 2010-2015,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,162 +27,303 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_variables.3x,v 1.15 2020/04/18 14:29:07 tom Exp $
-.TH curs_variables 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: curs_variables.3x,v 1.47 2024/04/13 22:37:35 tom Exp $
+.TH curs_variables 3X 2024-04-13 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
+.ie \n(.g .ds : \:
+.el       .ds : \" empty
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.ds n 5
-.na
-.hy 0
+.
 .SH NAME
-\fBCOLORS\fR,
-\fBCOLOR_PAIRS\fR,
-\fBCOLS\fR,
-\fBESCDELAY\fR,
-\fBLINES\fR,
-\fBTABSIZE\fR,
-\fBcurscr\fR,
-\fBnewscr\fR,
-\fBstdscr\fR
-\- \fBcurses\fR global variables
-.ad
-.hy
+\fI\%bool\fP,
+\fI\%chtype\fP,
+\fI\%cchar_t\fP,
+\fI\%attr_t\fP,
+\fI\%SCREEN\fP,
+\fI\%WINDOW\fP,
+\fB\%TRUE\fP,
+\fB\%FALSE\fP,
+\fB\%ERR\fP,
+\fB\%OK\fP,
+\fB\%curscr\fP,
+\fB\%newscr\fP,
+\fB\%stdscr\fP,
+\fB\%COLORS\fP,
+\fB\%COLOR_PAIRS\fP,
+\fB\%COLS\fP,
+\fB\%LINES\fP,
+\fB\%ESCDELAY\fP,
+\fB\%TABSIZE\fP \-
+\fIcurses\fR data types, constants, and global variables
 .SH SYNOPSIS
 .nf
-\fB#include <curses.h>\fR
-.PP
-\fBint COLOR_PAIRS;\fR
-.br
-\fBint COLORS;\fR
-.br
-\fBint COLS;\fR
-.br
-\fBint ESCDELAY;\fR
-.br
-\fBint LINES;\fR
-.br
-\fBint TABSIZE;\fR
-.br
-\fBWINDOW * curscr;\fR
-.br
-\fBWINDOW * newscr;\fR
-.br
-\fBWINDOW * stdscr;\fR
+\fB#include <curses.h>
+.PP
+\fI/* data types */
+\fBtypedef \fI/*\fP .\|.\|. \fI*/\fP bool;
+\fBtypedef \fI/*\fP .\|.\|. \fI*/\fP chtype;
+\fBtypedef \fI/*\fP .\|.\|. \fI*/\fP cchar_t;
+\fBtypedef \fI/*\fP .\|.\|. \fI*/\fP attr_t;
+\fBtypedef \fI/*\fP .\|.\|. \fI*/\fP SCREEN;
+\fBtypedef \fI/*\fP .\|.\|. \fI*/\fP WINDOW;
+.PP
+\fI/* constants */
+\fBconst bool TRUE;
+\fBconst bool FALSE;
+.PP
+\fBconst \fI/*\fP .\|.\|. \fI*/\fP ERR;
+\fBconst \fI/*\fP .\|.\|. \fI*/\fP OK;
+.PP
+\fI/* variables */
+\fBint COLORS;
+\fBint COLOR_PAIRS;
+\fBint COLS;
+\fBint LINES;
+\fBWINDOW * curscr;
+\fBWINDOW * stdscr;
+.PP
+\fI/* extensions */
+\fBint ESCDELAY;
+\fBint TABSIZE;
+\fBWINDOW * newscr;
 .fi
 .SH DESCRIPTION
-This page summarizes variables provided by the \fBcurses\fP library.
-A more complete description is given in the \fBcurses\fP(3X) manual page.
+This page summarizes data types,
+constants,
+and variables provided by the \fIcurses\fP library.
+Locate further discussion in \fB\%curses\fP(3X).
 .PP
-Depending on the configuration, these may be actual variables,
-or macros (see \fBcurs_threads\fR(3X) and \fBcurs_opaque\fR(3X))
-which provide read-only access to \fIcurses\fP's state.
-In either case, applications should treat them as read-only to avoid
+Depending on \fI\%ncurses\fP's build-time configuration,
+the variables may instead be
+macros (see \fB\%curs_threads\fP(3X) and \fB\%curs_opaque\fP(3X))
+that provide read-only access to the library's state.
+In either case,
+applications should treat them as read-only to avoid
 confusing the library.
-.SS COLOR_PAIRS
-After initializing curses, this variable contains the number of color pairs
-which the terminal can support.
-Usually the number of color pairs will be the product \fBCOLORS\fP*\fBCOLORS\fP,
-however this is not always true:
-.bP
-a few terminals use HLS colors, which do not follow this rule
-.bP
-terminals supporting a large number of colors are limited by the number
-of color pairs that can be represented in a \fIsigned short\fP value.
+.SH "CONSTANTS"
+.SS "TRUE, FALSE"
+The \fIcurses\fP library defines \fBTRUE\fP and \fBFALSE\fP
+to represent the values of the Boolean data type.
+.SS "ERR, OK"
+\fIcurses\fP and \fIterminfo\fP routines frequently return these
+constant integral values indicating failure and success,
+respectively.
+.SH "PREDEFINED TYPES"
+.SS "\fIbool\fP"
+X/Open Issue 4 \fIcurses\fP (1996) preceded the ISO C99 and ISO C++98
+standards,
+each of which also defined a Boolean data type.
+The \fIcurses\fP library requires an integral type \fIbool\fP.
+.PP
+\fB\%ncurses\fP' configure script attempts to discover the
+data type used by the system's C and C++ compilers,
+to reuse for the \fIcurses\fP \fIbool\fP.
+.SS "\fIchtype\fP"
+The \fI\%chtype\fP integral type combines a
+(\*(``narrow\*('',
+8-bit)
+character with attributes encoding the character's \fIrendition\fP,
+such as the styling of its typeface and/or foreground and background
+colors.
+See,
+for example,
+\fB\%addch\fP(3X),
+\fB\%attron\fP(3X),
+and
+\fB\%inch\fP(3X).
+.SS "\fIcchar_t\fP, \fIattr_t\fP"
+\fI\%chtype\fP is too small for the standard C library's wide-character
+type,
+\fIwchar_t\fP.
+\fI\%cchar_t\fP is a type that can accommodate an \fI\%attr_t\fP and
+enough wide characters to store what Unicode terms a \fIgrapheme cluster\fP
+(a \*(``user-perceived character\*('' [UAX #29],
+which may nevertheless require several character encoding units to
+represent).
+\fI\%attr_t\fP is an integral type storing \*(``wide\*('' attributes that
+apply to \fI\%cchar_t\fPs.
+See,
+for example,
+\fB\%add_wch\fP(3X),
+\fB\%attr_on\fP(3X),
+and
+\fB\%in_wch\fP(3X).
+.SS "\fISCREEN\fP"
+.I curses
+manages a terminal device with this structure type;
+see \fB\%initscr\fP(3X).
+.SS "\fIWINDOW\fP"
+.I curses
+represents rectangular portions of the terminal screen with the
+.I \%WINDOW
+structure type;
+see subsection \*(``Overview\*('' of \fB\%ncurses\fP(3X).
+.SH "VARIABLES"
+.SS "curscr, stdscr, newscr"
+The library records updates to the terminal screen in a window named
+\fB\%curscr\fP.
+This object is referred to as the \*(``physical screen\*('' in
+\fB\%curs_refresh\fP(3X) and
+\fB\%curs_outopts\fP(3X).
+.PP
+\fI\%ncurses\fP collects pending updates to the terminal screen in a
+window named \fB\%newscr\fP.
+This object is referred to as the \*(``virtual screen\*('' in the
+\fB\%curs_kernel\fP(3X),
+\fB\%curs_refresh\fP(3X),
+and
+\fB\%curs_outopts\fP(3X).
+When the screen is refreshed,
+\fIcurses\fP determines a minimal set of updates using the terminal's
+capabilities to make \fB\%curscr\fP look like \fB\%newscr\fP.
+.PP
+Once \fIcurses\fP is initialized,
+it creates a window named \fB\%stdscr\fP.
+It is the same size as the terminal screen and is the default window
+used by routines that do not take a parameter identifying one.
+Many \fIcurses\fP functions use this window.
 .SS COLORS
-After initializing curses, this variable contains the number of colors
-which the terminal can support.
-.SS COLS
-After initializing curses, this variable contains the width of the screen,
-i.e., the number of columns.
+Once \fIcurses\fP is initialized,
+\fB\%COLORS\fP
+contains the number of colors supported by the terminal;
+see \fB\%curs_color\fP(3X).
+.SS COLOR_PAIRS
+Once \fIcurses\fP is initialized,
+\fB\%COLOR_PAIRS\fP
+contains the number of color pairs supported by the terminal;
+see \fB\%curs_color\fP(3X).
+.SS "COLS, LINES"
+Once \fIcurses\fP is initialized,
+.B \%COLS
+and
+.B LINES
+contain the screen's width and height in character cells,
+respectively;
+that is,
+the number of columns and lines.
 .SS ESCDELAY
-This variable holds the number of milliseconds to wait after reading an
-escape character,
-to distinguish between an individual escape character entered on the
-keyboard from escape sequences sent by cursor- and function-keys
-(see curses(3X)).
-.SS LINES
-After initializing curses, this variable contains the height of the screen,
-i.e., the number of lines.
+For
+.I curses
+to distinguish the ESC character resulting from a user's press of the
+\*(``Escape\*('' key on the input device from one beginning an
+.I "escape sequence"
+(as commonly produced by function keys),
+it waits after the escape character to see if further characters are
+available on the input stream within a short interval.
+.B \%ESCDELAY
+stores this interval in milliseconds.
+.PP
+If \fB\%keypad\fP(3X) is disabled for the
+.I curses
+window receiving input,
+a program must disambiguate escape sequences itself.
 .SS TABSIZE
-This variable holds the number of columns used by the \fIcurses\fP library
-when converting a tab character to spaces as it adds the tab to a window
-(see \fBcurs_addch\fP(3X).
-.SS The Current Screen
-This implementation of curses uses a special window \fBcurscr\fP to
-record its updates to the terminal screen.
-.PP
-This is referred to as the \*(``physical screen\*('' in the
-\fBcurs_refresh\fR(3X) and
-\fBcurs_outopts\fR(3X) manual pages.
-.SS The New Screen
-This implementation of curses uses a special window \fBnewscr\fP to
-hold updates to the terminal screen before applying them to \fBcurscr\fP.
-.PP
-This is referred to as the \*(``virtual screen\*('' in the
-\fBcurs_kernel\fR(3X),
-\fBcurs_refresh\fR(3X) and
-\fBcurs_outopts\fR(3X) manual pages.
-.SS The Standard Screen
-Upon initializing curses,
-a default window called \fBstdscr\fP,
-which is the size of the terminal screen, is created.
-Many curses functions use this window.
+The \fIcurses\fP library converts a tab character to this number of
+spaces as it adds a tab to a window;
+see \fB\%curs_addch\fP(3X).
 .SH NOTES
-The curses library is initialized using either \fBinitscr\fR(3X),
-or \fBnewterm\fR(3X).
+Either \fB\%initscr\fP(3X) or \fB\%newterm\fP(3X) initializes
+\fIcurses\fP.
 .PP
-If \fBcurses\fP is configured to use separate curses/terminfo libraries,
-most of these variables reside in the curses library.
+If
+.I \%ncurses
+is configured to provide separate
+.I curses
+and
+.I \%tinfo
+libraries,
+most of these variables reside in the former.
 .SH PORTABILITY
-\fBTABSIZE\fP is a feature of SVr4 curses
-which is not documented by X/Open curses.
+The X/Open Curses standard documents all of the foregoing types and
+symbols except for \fB\%newscr\fP,
+\fB\%TABSIZE\fP,
+and \fB\%ESCDELAY\fP.
+.PP
+X/Open Curses describes \fB\%curscr\fP only as \*(``an internal data
+structure\*('';
+SVr4 gave more details,
+noting its use \*(``for certain low-level operations like clearing and
+redrawing a screen containing garbage\*(''.
+.\" SVID 4, Volume 3, p. 408
+Neither specified its interaction with the rest of the interface beyond
+use as an argument to \fB\%clearok\fP(3X) and \fB\%wrefresh\fP(3X).
+.PP
+\fB\%newscr\fP is a feature of SVr4 \fIcurses\fP.
+When refreshing the screen,
+it is used as a working area for combining the standard window
+\fB\%stdscr\fP with any others the application may have created with
+\fB\%newwin\fP(3X).
+When the update of \fB\%newscr\fP is complete,
+\fIcurses\fP modifies \fB\%curscr\fP to match \fB\%newscr\fP.
+.PP
+\fB\%TABSIZE\fP is a feature of SVr4 \fIcurses\fP.
 .bP
-In SVr4 curses, \fBTABSIZE\fP is initially set from the terminal description's
-\fBinit_tabs\fP capability.
-After that, it can be altered by the applications using SVr4 curses.
-.IP
-SVr4 curses uses the current value of \fBTABSIZE\fP to
-compute the position of tabstops for updating both
-the virtual screen with \fBaddch\fP(3X) as well as
-the physical screen with \fBmvcur\fP(3X).
+SVr4 initially sets \fB\%TABSIZE\fP from the terminal description's
+\fB\%init_tabs\fP capability.
+After that,
+it can be altered by applications using SVr4 \fIcurses\fP.
 .bP
-This implementation uses the current value of \fBTABSIZE\fP only for
-updating the virtual screen.
-It uses the terminal description's \fBit\fP (\fBinit_tabs\fP) capability for
-computing hardware tabs (i.e., tab stops on the physical screen).
+SVr4 \fIcurses\fP uses the value of \fB\%TABSIZE\fP to compute the
+position of tab stops when updating both
+the virtual screen with \fB\%addch\fP(3X) and
+the physical screen with \fB\%mvcur\fP(3X).
+.bP
+\fI\%ncurses\fP uses the value of \fB\%TABSIZE\fP only to update the
+virtual screen.
+It uses the terminal description's \*(``\fBit\fP\*(''
+(\fB\%init_tabs\fP) capability for computing hardware tabs
+(that is,
+tab stops on the physical screen).
 .bP
 Other implementations differ.
-For instance, NetBSD curses allows \fBTABSIZE\fP to be set through
-an environment variable.
-This implementation does not.
+For instance,
+NetBSD \fIcurses\fP allows \fB\%TABSIZE\fP to be set through an
+environment variable.
+\fI\%ncurses\fP does not.
 .IP
-NetBSD curses does not support hardware tabs;
-it uses the \fBinit_tabs\fP capability and the \fBTABSIZE\fP variable
-only for updating the virtual screen.
+NetBSD \fIcurses\fP does not support hardware tabs;
+it uses the \fB\%init_tabs\fP capability and the \fB\%TABSIZE\fP
+variable only for updating the virtual screen.
 .PP
-\fBESCDELAY\fP is an extension in AIX curses:
+\fB\%ESCDELAY\fP is a feature of AIX \fIcurses\fP.
 .bP
-In AIX, the units for \fBESCDELAY\fP are \fIfifths\fP of a millisecond.
+In AIX,
+the units for \fB\%ESCDELAY\fP are \fIfifths\fP of milliseconds.
 .bP
-The default value for AIX's \fBESCDELAY\fP is 0.1 seconds.
+The default value for AIX's \fB\%ESCDELAY\fP equals 0.1 seconds.
 .bP
-AIX also enforces a limit of 10,000 seconds for \fBESCDELAY\fP;
-this implementation currently has no upper limit.
+AIX also enforces a limit of 10,000 seconds for \fB\%ESCDELAY\fP;
+\fI\%ncurses\fP does not enforce any upper limit.
 .PP
-This implementation has long used \fBESCDELAY\fP with units of milliseconds,
+\fI\%ncurses\fP has long used \fB\%ESCDELAY\fP with units of
+milliseconds,
 making it impossible to be completely compatible with AIX.
-Likewise, most users have either decided to override the value,
-or rely upon its default value.
+Consequently,
+most users have decided either to override the value,
+or to rely upon its default.
 .SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_opaque\fR(3X),
-\fBcurs_terminfo\fR(3X),
-\fBcurs_threads\fR(3X),
-\fBterm_variables\fR(3X),
-\fBterminfo\fR(\*n).
+\fB\%curses\fP(3X),
+\fB\%curs_color\fP(3X),
+\fB\%curs_opaque\fP(3X),
+\fB\%curs_terminfo\fP(3X),
+\fB\%curs_threads\fP(3X),
+\fB\%term_variables\fP(3X),
+\fB\%terminfo\fP(5)
+.PP
+[UAX #29] \*(``Unicode Standard Annex #29: Unicode Text
+Segmentation\*('';
+\%<https://\*:unicode\*:.org/\*:reports/\*:tr29/>
diff --git a/contrib/ncurses/man/curs_window.3x b/contrib/ncurses/man/curs_window.3x
index 77cbffa723e6..d3d55c751444 100644
--- a/contrib/ncurses/man/curs_window.3x
+++ b/contrib/ncurses/man/curs_window.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2020 Thomas E. Dickey                                          *
+.\" Copyright 2020-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2015,2016 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,146 +27,152 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_window.3x,v 1.21 2020/02/02 23:34:34 tom Exp $
-.TH curs_window 3X ""
-.na
-.hy 0
+.\" $Id: curs_window.3x,v 1.48 2024/04/20 21:20:07 tom Exp $
+.TH curs_window 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.de bP
+.ie n  .IP \(bu 4
+.el    .IP \(bu 2
+..
 .SH NAME
-\fBnewwin\fR,
-\fBdelwin\fR,
-\fBmvwin\fR,
-\fBsubwin\fR,
-\fBderwin\fR,
-\fBmvderwin\fR,
-\fBdupwin\fR,
-\fBwsyncup\fR,
-\fBsyncok\fR,
-\fBwcursyncup\fR,
-\fBwsyncdown\fR \- create \fBcurses\fR windows
-.ad
-.hy
+\fB\%newwin\fP,
+\fB\%delwin\fP,
+\fB\%mvwin\fP,
+\fB\%subwin\fP,
+\fB\%derwin\fP,
+\fB\%mvderwin\fP,
+\fB\%dupwin\fP,
+\fB\%wsyncup\fP,
+\fB\%syncok\fP,
+\fB\%wcursyncup\fP,
+\fB\%wsyncdown\fP \-
+create and manipulate \fIcurses\fR windows
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBWINDOW *newwin(\fR
-      \fBint \fP\fInlines\fP\fB, int \fP\fIncols\fP\fB,\fR
-      \fBint \fP\fIbegin_y\fP\fB, int \fP\fIbegin_x\fP\fB);\fR
-.br
-\fBint delwin(WINDOW *\fP\fIwin\fP\fB);\fR
-.br
-\fBint mvwin(WINDOW *\fP\fIwin\fP\fB, int \fP\fIy\fP\fB, int \fP\fIx\fP\fB);\fR
-.br
-\fBWINDOW *subwin(WINDOW *\fP\fIorig\fP\fB,\fR
-      \fBint \fP\fInlines\fP\fB, int \fP\fIncols\fP\fB,\fR
-      \fBint \fP\fIbegin_y\fP\fB, int \fP\fIbegin_x\fP\fB);\fR
-.br
-\fBWINDOW *derwin(WINDOW *\fP\fIorig\fP\fB,\fR
-      \fBint \fP\fInlines\fP\fB, int \fP\fIncols\fP\fB,\fR
-      \fBint \fP\fIbegin_y\fP\fB, int \fP\fIbegin_x\fP\fB);\fR
-.br
-\fBint mvderwin(WINDOW *\fP\fIwin\fP\fB, int \fP\fIpar_y\fP\fB, int \fP\fIpar_x\fP\fB);\fR
-.br
-\fBWINDOW *dupwin(WINDOW *\fP\fIwin\fP\fB);\fR
-.br
-\fBvoid wsyncup(WINDOW *\fP\fIwin\fP\fB);\fR
-.br
-\fBint syncok(WINDOW *\fP\fIwin\fP\fB, bool \fP\fIbf\fP\fB);\fR
-.br
-\fBvoid wcursyncup(WINDOW *\fP\fIwin\fP\fB);\fR
-.br
-\fBvoid wsyncdown(WINDOW *\fP\fIwin\fP\fB);\fR
-.br
+.nf
+\fB#include <curses.h>
+.PP
+\fBWINDOW *newwin(
+      \fBint \fInlines\fB, int \fIncols\fB,\fR
+      \fBint \fIbegin_y\fB, int \fIbegin_x\fB);\fR
+\fBint delwin(WINDOW *\fIwin\fB);\fR
+\fBint mvwin(WINDOW *\fIwin\fB, int \fIy\fB, int \fIx\fB);\fR
+\fBWINDOW *subwin(WINDOW *\fIorig\fB,\fR
+      \fBint \fInlines\fB, int \fIncols\fB,\fR
+      \fBint \fIbegin_y\fB, int \fIbegin_x\fB);\fR
+\fBWINDOW *derwin(WINDOW *\fIorig\fB,\fR
+      \fBint \fInlines\fB, int \fIncols\fB,\fR
+      \fBint \fIbegin_y\fB, int \fIbegin_x\fB);\fR
+\fBint mvderwin(WINDOW *\fIwin\fB, int \fIpar_y\fB, int \fIpar_x\fB);\fR
+\fBWINDOW *dupwin(WINDOW *\fIwin\fB);\fR
+\fBvoid wsyncup(WINDOW *\fIwin\fB);\fR
+\fBint syncok(WINDOW *\fIwin\fB, bool \fIbf\fB);\fR
+\fBvoid wcursyncup(WINDOW *\fIwin\fB);\fR
+\fBvoid wsyncdown(WINDOW *\fIwin\fB);\fR
+.fi
 .SH DESCRIPTION
 .SS newwin
-Calling \fBnewwin\fR creates and returns a pointer to a new window with the
+Calling \fBnewwin\fP creates and returns a pointer to a new window with the
 given number of lines and columns.
 The upper left-hand corner of the window is
 at
 .RS
-line \fIbegin\fR_\fIy\fR,
+line \fIbegin\fR_\fIy\fP,
 .br
-column \fIbegin\fR_\fIx\fR
+column \fIbegin\fR_\fIx\fP
 .RE
 .PP
 If either
-\fInlines\fR or \fIncols\fR is zero, they default to
+\fInlines\fP or \fIncols\fP is zero, they default to
 .RS
-\fBLINES \-\fR \fIbegin\fR_\fIy\fR and
+\fBLINES \-\fP \fIbegin\fR_\fIy\fP and
 .br
-\fBCOLS \-\fR \fIbegin\fR_\fIx\fR.
+\fBCOLS \-\fP \fIbegin\fR_\fIx\fP.
 .RE
 .PP
-A new full-screen window is created by calling \fBnewwin(0,0,0,0)\fR.
-.SS delwin
+A new full-screen window is created by calling \fBnewwin(0,0,0,0)\fP.
+.PP
+Regardless of the function used for creating a new window
+(e.g., \fBnewwin\fP, \fBsubwin\fP, \fBderwin\fP, \fBnewpad\fP),
+rather than a duplicate (with \fBdupwin\fP),
+all of the window modes are initialized to the default values.
+These functions set window modes after a window is created:
+.RS
 .PP
-Calling \fBdelwin\fR deletes the named window, freeing all memory
+\fB\%idcok\fP
+\fB\%idlok\fP
+\fB\%immedok\fP
+\fB\%keypad\fP
+\fB\%leaveok\fP
+\fB\%nodelay\fP
+\fB\%scrollok\fP
+\fB\%setscrreg\fP
+\fB\%syncok\fP
+\fB\%wbkgdset\fP
+\fB\%wbkgrndset\fP and
+\fB\%wtimeout\fP.
+.RE
+.SS delwin
+Calling \fBdelwin\fP deletes the named window, freeing all memory
 associated with it (it does not actually erase the window's screen
 image).
 Subwindows must be deleted before the main window can be deleted.
 .SS mvwin
-.PP
-Calling \fBmvwin\fR moves the window so that the upper left-hand
-corner is at position (\fIx\fR, \fIy\fR).
+Calling \fBmvwin\fP moves the window so that the upper left-hand
+corner is at position (\fIx\fP, \fIy\fP).
 If the move would cause the window to be off the screen,
 it is an error and the window is not moved.
 Moving subwindows is allowed, but should be avoided.
 .SS subwin
-.PP
-Calling \fBsubwin\fR creates and returns a pointer to a new window
-with the given number of lines, \fInlines\fR, and columns, \fIncols\fR.
-The window is at position (\fIbegin\fR_\fIy\fR,
-\fIbegin\fR_\fIx\fR) on the screen.
-The subwindow shares memory with the window \fIorig\fR,
+Calling \fBsubwin\fP creates and returns a pointer to a new window
+with the given number of lines, \fInlines\fP, and columns, \fIncols\fP.
+The window is at position (\fIbegin\fR_\fIy\fP,
+\fIbegin\fR_\fIx\fP) on the screen.
+The subwindow shares memory with the window \fIorig\fP,
+its \fIancestor\fP,
 so that changes made to one window
 will affect both windows.
 When using this routine, it is necessary to call
-\fBtouchwin\fR or \fBtouchline\fR on \fIorig\fR before calling
-\fBwrefresh\fR on the subwindow.
+\fBtouchwin\fP or \fBtouchline\fP on \fIorig\fP before calling
+\fBwrefresh\fP on the subwindow.
 .SS derwin
-.PP
-Calling \fBderwin\fR is the same as calling \fBsubwin,\fR except that
-\fIbegin\fR_\fIy\fR and \fIbegin\fR_\fIx\fR are relative to the origin
-of the window \fIorig\fR rather than the screen.
+Calling \fBderwin\fP is the same as calling \fBsubwin,\fP except that
+\fIbegin\fR_\fIy\fP and \fIbegin\fR_\fIx\fP are relative to the origin
+of the window \fIorig\fP rather than the screen.
 There is no difference between the subwindows and the derived windows.
-.PP
-Calling \fBmvderwin\fR moves a derived window (or subwindow)
+.SS mvderwin
+Calling \fBmvderwin\fP moves a derived window (or subwindow)
 inside its parent window.
 The screen-relative parameters of the window are not changed.
 This routine is used to display different
 parts of the parent window at the same physical position on the
 screen.
 .SS dupwin
-.PP
-Calling \fBdupwin\fR creates an exact duplicate of the window \fIwin\fR.
+Calling \fBdupwin\fP creates an exact duplicate of the window \fIwin\fP.
 .SS wsyncup
-.PP
-Calling \fBwsyncup\fR touches all locations in ancestors of \fIwin\fR that are
-changed in \fIwin\fR.
-If \fBsyncok\fR is called with second argument
-\fBTRUE\fR then \fBwsyncup\fR is called automatically whenever there is a
+Calling \fBwsyncup\fP touches all locations in ancestors of \fIwin\fP that are
+changed in \fIwin\fP.
+If \fBsyncok\fP is called with second argument
+\fBTRUE\fP then \fBwsyncup\fP is called automatically whenever there is a
 change in the window.
 .SS wsyncdown
-.PP
-The \fBwsyncdown\fR routine touches each location in \fIwin\fR that has been
+The \fBwsyncdown\fP routine touches each location in \fIwin\fP that has been
 touched in any of its ancestor windows.
 This routine is called by
-\fBwrefresh\fR, so it should almost never be necessary to call it manually.
+\fBwrefresh\fP, so it should almost never be necessary to call it manually.
 .SS wcursyncup
-.PP
-The routine \fBwcursyncup\fR updates the current cursor position of all the
+The routine \fBwcursyncup\fP updates the current cursor position of all the
 ancestors of the window to reflect the current cursor position of the
 window.
 .SH RETURN VALUE
-Routines that return an integer return the integer \fBERR\fR upon failure and
-\fBOK\fR (SVr4 only specifies "an integer value other than \fBERR\fR") upon
+Routines that return an integer return the integer \fBERR\fP upon failure and
+\fBOK\fP (SVr4 only specifies "an integer value other than \fBERR\fP") upon
 successful completion.
 .PP
-Routines that return pointers return \fBNULL\fR on error.
+Routines that return pointers return \fBNULL\fP on error.
 .PP
 X/Open defines no error conditions.
 In this implementation
 .TP 5
-\fBdelwin\fR
+\fBdelwin\fP
 returns an error if the window pointer is null, or
 if the window is the parent of another window.
 .TP 5
@@ -211,26 +217,56 @@ may also fail if there is insufficient memory for its data structures.
 Any of these functions will fail if the screen has not been initialized,
 i.e., with \fBinitscr\fP or \fBnewterm\fP.
 .SH NOTES
-If many small changes are made to the window, the \fBwsyncup\fR option could
+If many small changes are made to the window, the \fBwsyncup\fP option could
 degrade performance.
 .PP
-Note that \fBsyncok\fR may be a macro.
+Note that \fBsyncok\fP may be a macro.
+.SH PORTABILITY
+X/Open Curses, Issue 4 describes these functions.
+.PP
+X/Open Curses states regarding \fBdelwin\fP:
+.bP
+It must delete subwindows before deleting their parent.
+.bP
+If \fBdelwin\fP is asked to delete a parent window,
+it can only succeed if the curses library keeps a list of the subwindows.
+SVr4 curses kept a count of the number of subwindows rather than a list.
+It simply returned \fBERR\fP when asked to delete a subwindow.
+Solaris X/Open curses does not even make that check,
+and will delete a parent window which still has subwindows.
+.bP
+Since release 4.0 (1996),
+\fI\%ncurses\fP maintains a list of windows for each screen,
+to ensure that a window has no subwindows before allowing deletion.
+.bP
+NetBSD copied this feature of \fI\%ncurses\fP in 2003.
+.br
+PDCurses follows the scheme used in Solaris X/Open curses.
 .SH BUGS
-The subwindow functions (\fBsubwin\fR, \fBderwin\fR, \fBmvderwin\fR,
-\fBwsyncup\fR, \fBwsyncdown\fR, \fBwcursyncup\fR, \fBsyncok\fR) are flaky,
-incompletely implemented, and not well tested.
+The subwindow functions
+\fB\%subwin\fP,
+\fB\%derwin\fP,
+\fB\%mvderwin\fP,
+\fB\%wsyncup\fP,
+\fB\%wsyncdown\fP,
+\fB\%wcursyncup\fP,
+and
+\fB\%syncok\fP
+are flaky,
+incompletely implemented,
+and not well tested.
 .PP
-The System V curses documentation is very unclear about what \fBwsyncup\fR
-and \fBwsyncdown\fR actually do.
-It seems to imply that they are only
-supposed to touch exactly those lines that are affected by ancestor changes.
-The language here, and the behavior of the \fBcurses\fR implementation,
-is patterned on the XPG4 curses standard.
-The weaker XPG4 spec may result in slower updates.
-.SH PORTABILITY
-The XSI Curses standard, Issue 4 describes these functions.
+System\ V's \fIcurses\fP documentation is unclear about what
+\fB\%wsyncup\fP and \fB\%wsyncdown\fP actually do.
+It seems to imply that they are supposed to touch only those lines that
+are affected by changes to a window's ancestors.
+The language here,
+and behavior of \fI\%ncurses\fP,
+is patterned on the X/Open Curses standard;
+this approach may result in slower updates.
 .SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_refresh\fR(3X),
-\fBcurs_touch\fR(3X),
-\fBcurs_variables\fR(3X)
+\fB\%curses\fP(3X),
+\fB\%curs_initscr\fP(3X),
+\fB\%curs_refresh\fP(3X),
+\fB\%curs_touch\fP(3X),
+\fB\%curs_variables\fP(3X)
diff --git a/contrib/ncurses/man/default_colors.3x b/contrib/ncurses/man/default_colors.3x
index c1d1bf706724..96124147cc68 100644
--- a/contrib/ncurses/man/default_colors.3x
+++ b/contrib/ncurses/man/default_colors.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 2000-2011,2016 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -29,21 +29,29 @@
 .\"
 .\" Author: Thomas E. Dickey 1997,1999,2000,2005
 .\"
-.\" $Id: default_colors.3x,v 1.31 2020/12/19 21:38:37 tom Exp $
-.TH default_colors 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: default_colors.3x,v 1.52 2024/04/13 22:17:22 tom Exp $
+.TH default_colors 3X 2024-04-13 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
 .SH NAME
-\fBuse_default_colors\fR,
-\fBassume_default_colors\fR \- use terminal's default colors
+\fB\%use_default_colors\fP,
+\fB\%assume_default_colors\fP \-
+use terminal's default colors in \fIcurses\fP
 .SH SYNOPSIS
-\fB#include <curses.h>\fP
-.sp
-\fBint use_default_colors(void);\fP
-.br
-\fBint assume_default_colors(int \fP\fIfg\fP\fB, int \fP\fIbg\fP\fB);\fP
+.nf
+\fB#include <curses.h>
+.PP
+\fBint use_default_colors(void);
+\fBint assume_default_colors(int \fIfg\fP, int \fIbg\fP);
+.fi
 .SH DESCRIPTION
 The \fBuse_default_colors\fP and \fBassume_default_colors\fP
 functions are extensions to the curses library.
@@ -57,7 +65,8 @@ Some applications are designed to work with the default background,
 using colors only for text.
 For example, there are several implementations of the \fBls\fP program
 which use colors to denote different file types or permissions.
-These \*(``color ls\*('' programs do not necessarily modify the background color,
+These \*(``color ls\*('' programs do not necessarily
+modify the background color,
 typically using only the \fBsetaf\fP terminfo capability to set the
 foreground color.
 Full-screen applications that use default colors can achieve similar
@@ -84,9 +93,9 @@ The following are equivalent:
 .I assume_default_colors(\-1,\-1);
 .RE
 .PP
-These are ncurses extensions.
+These are \fI\%ncurses\fP extensions.
 For other curses implementations, color
-number \-1 does not mean anything, just as for ncurses before a
+number \-1 does not mean anything, just as for \fI\%ncurses\fP before a
 successful call of \fBuse_default_colors\fP or \fBassume_default_colors\fP.
 .PP
 Other curses implementations do not allow an application to modify color pair 0.
@@ -97,7 +106,7 @@ If your application does not use either
 .B use_default_colors
 or
 .B assume_default_colors
-ncurses will paint a white foreground (text) with black background
+\fI\%ncurses\fP will paint a white foreground (text) with black background
 for color pair 0.
 .SH RETURN VALUE
 These functions return the integer \fBERR\fP upon failure
@@ -107,10 +116,10 @@ the \fBorig_pair\fP or \fBorig_colors\fP capability.
 If the \fBinitialize_pair\fP capability is not found, this causes an
 error as well.
 .SH NOTES
-Associated with this extension, the \fBinit_pair\fR function accepts
+Associated with this extension, the \fBinit_pair\fP function accepts
 negative arguments to specify default foreground or background colors.
 .PP
-The \fBuse_default_colors\fP function was added to support \fIded\fP.
+The \fBuse_default_colors\fP function was added to support \fBded\fP.
 This is a full-screen application which uses curses to manage only part
 of the screen.
 The bottom portion of the screen, which is of adjustable
@@ -131,14 +140,14 @@ a different problem: support for applications which would use
 environment variables and other configuration to bypass curses'
 notion of the terminal's default colors, setting specific values.
 .SH PORTABILITY
-These routines are specific to ncurses.
+These routines are specific to \fI\%ncurses\fP.
 They were not supported on
 Version 7, BSD or System V implementations.
 It is recommended that
 any code depending on them be conditioned using NCURSES_VERSION.
-.SH SEE ALSO
-\fBded\fP(1),
-\fBcurs_color\fR(3X).
-.SH AUTHOR
+.SH AUTHORS
 Thomas Dickey (from an analysis of the requirements for color xterm
 for XFree86 3.1.2C, February 1996).
+.SH SEE ALSO
+\fB\%ded\fP(1),
+\fB\%curs_color\fP(3X)
diff --git a/contrib/ncurses/man/define_key.3x b/contrib/ncurses/man/define_key.3x
index d0dbe7fccaa9..667d8cd312fe 100644
--- a/contrib/ncurses/man/define_key.3x
+++ b/contrib/ncurses/man/define_key.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -29,38 +29,43 @@
 .\"
 .\" Author: Thomas E. Dickey 1997
 .\"
-.\" $Id: define_key.3x,v 1.18 2020/10/24 09:52:54 tom Exp $
-.TH define_key 3X ""
+.\" $Id: define_key.3x,v 1.42 2024/03/16 15:35:01 tom Exp $
+.TH define_key 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
-\fBdefine_key\fP \- define a keycode
+\fB\%define_key\fP \-
+define a \fIcurses\fR keycode
 .SH SYNOPSIS
-\fB#include <curses.h>\fP
-.sp
-\fBint define_key(const char *\fP\fIdefinition\fP\fB, int \fP\fIkeycode\fP\fB);\fP
+.nf
+\fB#include <curses.h>
+.PP
+\fBint define_key(const char *\fIdefinition\fP, int \fIkeycode\fP);
+.fi
 .SH DESCRIPTION
-This is an extension to the curses library.
+This is an extension to the \fIcurses\fP library.
 It permits an application to define keycodes with their corresponding control
-strings, so that the ncurses library will interpret them just as it would
+strings,
+so that the \fI\%ncurses\fP library will interpret them just as it would
 the predefined codes in the terminfo database.
 .PP
-If the given string is null, any existing definition for the keycode is
-removed.
+If \fIdefinition\fP is \fBNULL\fP,
+any existing one for the keycode is removed.
 Similarly, if the given keycode is negative or zero, any existing string
 for the given definition is removed.
 .SH RETURN VALUE
-The keycode must be greater than zero, and the string non-null,
+Either \fIkeycode\fP must be greater than zero,
+or \fIdefinition\fP must be non-\fBNULL\fP,
 otherwise \fBERR\fP is returned.
 \fBERR\fP may also be returned if there is insufficient memory to allocate the
 data to store the definition.
 If no error is detected, \fBOK\fP is returned.
 .SH PORTABILITY
-These routines are specific to ncurses.
+These routines are specific to \fI\%ncurses\fP.
 They were not supported on
 Version 7, BSD or System V implementations.
 It is recommended that
-any code depending on them be conditioned using NCURSES_VERSION.
+any code depending on them be conditioned using \fB\%NCURSES_VERSION\fP.
+.SH AUTHORS
+Thomas Dickey
 .SH SEE ALSO
-\fBkeyok\fR(3X),
-\fBkey_defined\fR(3X).
-.SH AUTHOR
-Thomas Dickey.
+\fB\%keyok\fP(3X),
+\fB\%key_defined\fP(3X)
diff --git a/contrib/ncurses/man/form.3x b/contrib/ncurses/man/form.3x
index 685ad71f1047..2f8f884861fa 100644
--- a/contrib/ncurses/man/form.3x
+++ b/contrib/ncurses/man/form.3x
@@ -1,6 +1,6 @@
 '\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,32 +28,41 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: form.3x,v 1.36 2020/12/12 16:34:33 tom Exp $
-.TH form 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: form.3x,v 1.54 2024/03/16 15:35:01 tom Exp $
+.TH form 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
 .SH NAME
-\fBform\fR \- curses extension for programming forms
+\fBform\fP \-
+curses extension for programming forms
 .SH SYNOPSIS
-\fB#include <form.h>\fR
-.br
+.nf
+\fB#include <form.h>
+.fi
 .SH DESCRIPTION
-The \fBform\fR library provides terminal-independent facilities for composing
+The \fBform\fP library provides terminal-independent facilities for composing
 form screens on character-cell terminals.
 The library includes: field
 routines, which create and modify form fields; and form routines, which group
 fields into forms, display forms on the screen, and handle interaction with the
 user.
 .PP
-The \fBform\fR library uses the \fBcurses\fR libraries.
-To use the \fBform\fR library, link with the options
-\fB\-lform \-lcurses\fR.
+The \fBform\fP library uses the \fBcurses\fP libraries.
+To use the \fBform\fP library, link with the options
+\fB\-lform \-lcurses\fP.
 .PP
 Your program should set up the locale, e.g.,
 .sp
@@ -61,110 +70,110 @@ Your program should set up the locale, e.g.,
 .sp
 so that input/output processing will work.
 .PP
-A curses initialization routine such as \fBinitscr\fR must be called
+A curses initialization routine such as \fBinitscr\fP must be called
 before using any of these functions.
 .
-.SS Current Default Values for Field Attributes
+.SS "Current Default Values for Field Attributes"
 .
-The \fBform\fR library maintains a default value for field attributes.
+The \fBform\fP library maintains a default value for field attributes.
 You
-can get or set this default by calling the appropriate \fBset_\fR
+can get or set this default by calling the appropriate \fBset_\fP
 or retrieval
-routine with a \fBNULL\fR field pointer.
+routine with a \fBNULL\fP field pointer.
 Changing this default with a
-\fBset_\fR function affects future field creations, but does not change the
+\fBset_\fP function affects future field creations, but does not change the
 rendering of fields already created.
 .
-.SS Routine Name Index
+.SS "Routine Name Index"
 .
-The following table lists each \fBform\fR routine and the name of
+The following table lists each \fBform\fP routine and the name of
 the manual page on which it is described.
 Routines flagged with \*(``*\*(''
-are ncurses-specific, not present in SVr4.
-.
+are \fI\%ncurses\fP-specific, not present in SVr4.
+.PP
 .TS
 l l
 l l .
-\fBcurses\fR Routine Name	Manual Page Name
+\fBcurses\fP Routine Name	Manual Page Name
 =
-current_field	\fBform_page\fR(3X)
-data_ahead	\fBform_data\fR(3X)
-data_behind	\fBform_data\fR(3X)
-dup_field	\fBform_field_new\fR(3X)
-dynamic_field_info	\fBform_field_info\fR(3X)
-field_arg	\fBform_field_validation\fR(3X)
-field_back	\fBform_field_attributes\fR(3X)
-field_buffer	\fBform_field_buffer\fR(3X)
-field_count	\fBform_field\fR(3X)
-field_fore	\fBform_field_attributes\fR(3X)
-field_index	\fBform_page\fR(3X)
-field_info	\fBform_field_info\fR(3X)
-field_init	\fBform_hook\fR(3X)
-field_just	\fBform_field_just\fR(3X)
-field_opts	\fBform_field_opts\fR(3X)
-field_opts_off	\fBform_field_opts\fR(3X)
-field_opts_on	\fBform_field_opts\fR(3X)
-field_pad	\fBform_field_attributes\fR(3X)
-field_status	\fBform_field_buffer\fR(3X)
-field_term	\fBform_hook\fR(3X)
-field_type	\fBform_field_validation\fR(3X)
-field_userptr	\fBform_field_userptr\fR(3X)
-form_driver	\fBform_driver\fR(3X)
-form_driver_w	\fBform_driver\fR(3X)*
-form_fields	\fBform_field\fR(3X)
-form_init	\fBform_hook\fR(3X)
-form_opts	\fBform_opts\fR(3X)
-form_opts_off	\fBform_opts\fR(3X)
-form_opts_on	\fBform_opts\fR(3X)
-form_page	\fBform_page\fR(3X)
-form_request_by_name	\fBform_requestname\fR(3X)*
-form_request_name	\fBform_requestname\fR(3X)*
-form_sub	\fBform_win\fR(3X)
-form_term	\fBform_hook\fR(3X)
-form_userptr	\fBform_userptr\fR(3X)
-form_win	\fBform_win\fR(3X)
-free_field	\fBform_field_new\fR(3X)
-free_fieldtype	\fBform_fieldtype\fR(3X)
-free_form	\fBform_new\fR(3X)
-link_field	\fBform_field_new\fR(3X)
-link_fieldtype	\fBform_fieldtype\fR(3X)
-move_field	\fBform_field\fR(3X)
-new_field	\fBform_field_new\fR(3X)
-new_fieldtype	\fBform_fieldtype\fR(3X)
-new_form	\fBform_new\fR(3X)
-new_page	\fBform_new_page\fR(3X)
-pos_form_cursor	\fBform_cursor\fR(3X)
-post_form	\fBform_post\fR(3X)
-scale_form	\fBform_win\fR(3X)
-set_current_field	\fBform_page\fR(3X)
-set_field_back	\fBform_field_attributes\fR(3X)
-set_field_buffer	\fBform_field_buffer\fR(3X)
-set_field_fore	\fBform_field_attributes\fR(3X)
-set_field_init	\fBform_hook\fR(3X)
-set_field_just	\fBform_field_just\fR(3X)
-set_field_opts	\fBform_field_opts\fR(3X)
-set_field_pad	\fBform_field_attributes\fR(3X)
-set_field_status	\fBform_field_buffer\fR(3X)
-set_field_term	\fBform_hook\fR(3X)
-set_field_type	\fBform_field_validation\fR(3X)
-set_field_userptr	\fBform_field_userptr\fR(3X)
-set_fieldtype_arg	\fBform_fieldtype\fR(3X)
-set_fieldtype_choice	\fBform_fieldtype\fR(3X)
-set_form_fields	\fBform_field\fR(3X)
-set_form_init	\fBform_hook\fR(3X)
-set_form_opts	\fBform_field_opts\fR(3X)
-set_form_page	\fBform_page\fR(3X)
-set_form_sub	\fBform_win\fR(3X)
-set_form_term	\fBform_hook\fR(3X)
-set_form_userptr	\fBform_userptr\fR(3X)
-set_form_win	\fBform_win\fR(3X)
-set_max_field	\fBform_field_buffer\fR(3X)
-set_new_page	\fBform_new_page\fR(3X)
-unfocus_current_field	\fBform_page\fR(3X)*
-unpost_form	\fBform_post\fR(3X)
+current_field	\fBform_page\fP(3X)
+data_ahead	\fBform_data\fP(3X)
+data_behind	\fBform_data\fP(3X)
+dup_field	\fBform_field_new\fP(3X)
+dynamic_field_info	\fBform_field_info\fP(3X)
+field_arg	\fBform_field_validation\fP(3X)
+field_back	\fBform_field_attributes\fP(3X)
+field_buffer	\fBform_field_buffer\fP(3X)
+field_count	\fBform_field\fP(3X)
+field_fore	\fBform_field_attributes\fP(3X)
+field_index	\fBform_page\fP(3X)
+field_info	\fBform_field_info\fP(3X)
+field_init	\fBform_hook\fP(3X)
+field_just	\fBform_field_just\fP(3X)
+field_opts	\fBform_field_opts\fP(3X)
+field_opts_off	\fBform_field_opts\fP(3X)
+field_opts_on	\fBform_field_opts\fP(3X)
+field_pad	\fBform_field_attributes\fP(3X)
+field_status	\fBform_field_buffer\fP(3X)
+field_term	\fBform_hook\fP(3X)
+field_type	\fBform_field_validation\fP(3X)
+field_userptr	\fBform_field_userptr\fP(3X)
+form_driver	\fBform_driver\fP(3X)
+form_driver_w	\fBform_driver\fP(3X)*
+form_fields	\fBform_field\fP(3X)
+form_init	\fBform_hook\fP(3X)
+form_opts	\fBform_opts\fP(3X)
+form_opts_off	\fBform_opts\fP(3X)
+form_opts_on	\fBform_opts\fP(3X)
+form_page	\fBform_page\fP(3X)
+form_request_by_name	\fBform_requestname\fP(3X)*
+form_request_name	\fBform_requestname\fP(3X)*
+form_sub	\fBform_win\fP(3X)
+form_term	\fBform_hook\fP(3X)
+form_userptr	\fBform_userptr\fP(3X)
+form_win	\fBform_win\fP(3X)
+free_field	\fBform_field_new\fP(3X)
+free_fieldtype	\fBform_fieldtype\fP(3X)
+free_form	\fBform_new\fP(3X)
+link_field	\fBform_field_new\fP(3X)
+link_fieldtype	\fBform_fieldtype\fP(3X)
+move_field	\fBform_field\fP(3X)
+new_field	\fBform_field_new\fP(3X)
+new_fieldtype	\fBform_fieldtype\fP(3X)
+new_form	\fBform_new\fP(3X)
+new_page	\fBform_new_page\fP(3X)
+pos_form_cursor	\fBform_cursor\fP(3X)
+post_form	\fBform_post\fP(3X)
+scale_form	\fBform_win\fP(3X)
+set_current_field	\fBform_page\fP(3X)
+set_field_back	\fBform_field_attributes\fP(3X)
+set_field_buffer	\fBform_field_buffer\fP(3X)
+set_field_fore	\fBform_field_attributes\fP(3X)
+set_field_init	\fBform_hook\fP(3X)
+set_field_just	\fBform_field_just\fP(3X)
+set_field_opts	\fBform_field_opts\fP(3X)
+set_field_pad	\fBform_field_attributes\fP(3X)
+set_field_status	\fBform_field_buffer\fP(3X)
+set_field_term	\fBform_hook\fP(3X)
+set_field_type	\fBform_field_validation\fP(3X)
+set_field_userptr	\fBform_field_userptr\fP(3X)
+set_fieldtype_arg	\fBform_fieldtype\fP(3X)
+set_fieldtype_choice	\fBform_fieldtype\fP(3X)
+set_form_fields	\fBform_field\fP(3X)
+set_form_init	\fBform_hook\fP(3X)
+set_form_opts	\fBform_field_opts\fP(3X)
+set_form_page	\fBform_page\fP(3X)
+set_form_sub	\fBform_win\fP(3X)
+set_form_term	\fBform_hook\fP(3X)
+set_form_userptr	\fBform_userptr\fP(3X)
+set_form_win	\fBform_win\fP(3X)
+set_max_field	\fBform_field_buffer\fP(3X)
+set_new_page	\fBform_new_page\fP(3X)
+unfocus_current_field	\fBform_page\fP(3X)*
+unpost_form	\fBform_post\fP(3X)
 .TE
 .SH RETURN VALUE
-Routines that return pointers return \fBNULL\fR on error,
+Routines that return pointers return \fBNULL\fP on error,
 and set \fBerrno\fP to the corresponding error-code returned by functions
 returning an integer.
 Routines that return
@@ -201,44 +210,37 @@ The form is already posted.
 The form driver could not process the request.
 .TP 5
 .B E_SYSTEM_ERROR
-System error occurred (see \fBerrno\fR(3)).
+System error occurred (see \fBerrno\fP(3)).
 .TP 5
 .B E_UNKNOWN_COMMAND
 The form driver code saw an unknown request code.
 .SH NOTES
-The header file \fB<form.h>\fR automatically includes the header files
-\fB<curses.h>\fR and \fB<eti.h>\fR.
-.PP
-In your library list, libform.a should be before libncurses.a; that is,
-you want to say \*(``\-lform \-lncurses\*('', not the other way around
-(which would give you a link error when using static libraries).
+The header file \fI\%form.h\fP itself includes \fI\%curses.h\fP.
 .SH PORTABILITY
 These routines emulate the System V forms library.
 They were not supported on
 Version 7 or BSD versions.
 .PP
-The menu facility was documented in SVr4.2 in
-\fICharacter User Interface Programming (UNIX SVR4.2)\fP.
+A form facility was documented in SVr4.2's
+\fICharacter User Interface Programming\fP document.
 .PP
 It is not part of X/Open Curses.
 .PP
-Aside from ncurses, there are few implementations:
+Aside from \fI\%ncurses\fP, there are few implementations:
 .bP
 systems based on SVr4 source code, e.g., Solaris.
 .bP
 NetBSD curses.
 .PP
-A few functions in this implementation are extensions added for ncurses,
+A few functions in this implementation are extensions added for
+\fI\%ncurses\fP,
 but not provided by other implementations, e.g.,
 \fBform_driver_w\fP,
 \fBunfocus_current_field\fP.
 .SH AUTHORS
 Juergen Pfeifer.
-Manual pages and adaptation for ncurses by Eric
+Manual pages and adaptation for \fI\%ncurses\fP by Eric
 S. Raymond.
 .SH SEE ALSO
-\fBcurses\fR(3X) and related pages whose names begin \*(``form_\*('' for detailed
-descriptions of the entry points.
-.PP
-This describes \fBncurses\fR
-version @NCURSES_MAJOR@.@NCURSES_MINOR@ (patch @NCURSES_PATCH@).
+\fBcurses\fP(3X) and related pages whose names begin \*(``form_\*('' for
+detailed descriptions of the entry points.
diff --git a/contrib/ncurses/man/form_cursor.3x b/contrib/ncurses/man/form_cursor.3x
index cb9d1cd1cc33..ed8bab15f2ce 100644
--- a/contrib/ncurses/man/form_cursor.3x
+++ b/contrib/ncurses/man/form_cursor.3x
@@ -1,6 +1,6 @@
 '\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2015 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,20 +28,22 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: form_cursor.3x,v 1.14 2020/10/18 00:15:29 tom Exp $
-.TH form_cursor 3X ""
+.\" $Id: form_cursor.3x,v 1.31 2024/03/16 15:35:01 tom Exp $
+.TH form_cursor 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
-\fBpos_form_cursor\fR \- position a form window cursor
+\fBpos_form_cursor\fP \-
+position a form window cursor
 .SH SYNOPSIS
-\fB#include <form.h>\fR
-.sp
-\fBint pos_form_cursor(FORM *\fP\fIform\fP\fB);\fP
-.br
+.nf
+\fB#include <form.h>
+.PP
+\fBint pos_form_cursor(FORM *\fIform\fP);
+.fi
 .SH DESCRIPTION
-The function \fBpos_form_cursor\fR restores the cursor to the position required
+The function \fBpos_form_cursor\fP restores the cursor to the position required
 for the forms driver to continue processing requests.
 This is useful after
-\fBcurses\fR routines have been called to do screen-painting in response to a
+\fBcurses\fP routines have been called to do screen-painting in response to a
 form operation.
 .SH RETURN VALUE
 This routine returns one of the following:
@@ -56,13 +58,7 @@ Routine detected an incorrect or out-of-range argument.
 The form has not been posted.
 .TP 5
 .B E_SYSTEM_ERROR
-System error occurred (see \fBerrno\fR(3)).
-.
-.SH SEE ALSO
-\fBcurses\fR(3X), \fBform\fR(3X).
-.SH NOTES
-The header file \fB<form.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
+System error occurred (see \fBerrno\fP(3)).
 .SH PORTABILITY
 These routines emulate the System V forms library.
 They were not supported on
@@ -70,3 +66,6 @@ Version 7 or BSD versions.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%form\fP(3X)
diff --git a/contrib/ncurses/man/form_data.3x b/contrib/ncurses/man/form_data.3x
index 8a5669209a5e..ded82eba19a2 100644
--- a/contrib/ncurses/man/form_data.3x
+++ b/contrib/ncurses/man/form_data.3x
@@ -1,6 +1,6 @@
 '\" t
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2015 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,31 +28,27 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: form_data.3x,v 1.15 2020/10/18 00:15:00 tom Exp $
-.TH form_data 3X ""
+.\" $Id: form_data.3x,v 1.32 2024/03/16 15:35:01 tom Exp $
+.TH form_data 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
 \fBdata_ahead\fP,
-\fBdata_behind\fR \- test for off-screen data in given forms
+\fBdata_behind\fP \-
+test for off-screen data in given forms
 .SH SYNOPSIS
-\fB#include <form.h>\fR
-.sp
-\fBbool data_ahead(const FORM *\fP\fIform\fP\fB);\fP
-.br
-\fBbool data_behind(const FORM *\fP\fIform\fP\fB);\fP
-.br
+.nf
+\fB#include <form.h>
+.PP
+\fBbool data_ahead(const FORM *\fIform\fP);
+\fBbool data_behind(const FORM *\fIform\fP);
+.fi
 .SH DESCRIPTION
-The function \fBdata_ahead\fR tests whether there is off-screen data
+The function \fBdata_ahead\fP tests whether there is off-screen data
 ahead in the given form.
 It returns TRUE (1) or FALSE (0).
 .PP
-The function \fBdata_behind\fR tests whether there is off-screen data
+The function \fBdata_behind\fP tests whether there is off-screen data
 behind in the given form.
 It returns TRUE (1) or FALSE (0).
-.SH SEE ALSO
-\fBcurses\fR(3X), \fBform\fR(3X).
-.SH NOTES
-The header file \fB<form.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
 .SH PORTABILITY
 These routines emulate the System V forms library.
 They were not supported on
@@ -60,3 +56,6 @@ Version 7 or BSD versions.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%form\fP(3X)
diff --git a/contrib/ncurses/man/form_driver.3x b/contrib/ncurses/man/form_driver.3x
index 9c096f90d4c5..882a49dd4634 100644
--- a/contrib/ncurses/man/form_driver.3x
+++ b/contrib/ncurses/man/form_driver.3x
@@ -1,5 +1,6 @@
+'\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,26 +28,27 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: form_driver.3x,v 1.35 2020/12/19 21:34:15 tom Exp $
-.TH form_driver 3X ""
+.\" $Id: form_driver.3x,v 1.61 2024/04/20 18:55:09 tom Exp $
+.TH form_driver 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
 .SH NAME
-\fBform_driver\fR,
-\fBform_driver_w\fR \- command-processing loop of the form system
+\fBform_driver\fP,
+\fBform_driver_w\fP \-
+command-processing loop of the form system
 .SH SYNOPSIS
-\fB#include <form.h>\fR
-.sp
-\fBint form_driver(FORM *\fP\fIform\fP\fB, int \fP\fIc\fP\fB);\fP
-.br
-\fBint form_driver_w(FORM *\fP\fIform\fP\fB, int \fP\fIc\fP\fB, wchar_t \fP\fIwch\fP\fB);\fP
-.br
+.nf
+\fB#include <form.h>
+.PP
+\fBint form_driver(FORM *\fIform\fP, int \fIc\fP);
+\fBint form_driver_w(FORM *\fIform\fP, int \fIc\fP, wchar_t \fIwc\fP);
+.fi
 .SH DESCRIPTION
 .SS form_driver
 Once a form has been posted (displayed), you should funnel input events to it
-through \fBform_driver\fR.  This routine has three major input cases:
+through \fBform_driver\fP.  This routine has three major input cases:
 .bP
 The input is a form navigation request.
 Navigation request codes are constants defined in \fB<form.h>\fP,
@@ -59,33 +61,32 @@ checked according to the program's locale settings.
 .bP
 The input is the KEY_MOUSE special key associated with an mouse event.
 .SS form_driver_w
-.PP
 This extension simplifies the use of the forms library using wide characters.
 The input is either a key code (a request) or a wide character
 returned by \fBget_wch\fP(3X).
 The type must be passed as well,
 to enable the library to determine whether the parameter
 is a wide character or a request.
-.SS Form-driver requests
-.PP
+.SS "Form Driver Requests"
 The form driver requests are as follows:
+.PP
 .TS
-l l
-_ _
-l l.
-\fIName\fR	\fIDescription\fR
-REQ_BEG_FIELD	Move to the beginning of the field.
-REQ_BEG_LINE	Move to the beginning of the line.
+Lb Lb
+Lb Lx.
+Name	Description
+_
+REQ_BEG_FIELD	Move to beginning of field.
+REQ_BEG_LINE	Move to beginning of the line.
 REQ_CLR_EOF	Clear to end of field from cursor.
 REQ_CLR_EOL	Clear to end of line from cursor.
 REQ_CLR_FIELD	Clear the entire field.
 REQ_DEL_CHAR	Delete character at the cursor.
 REQ_DEL_LINE	Delete line at the cursor.
 REQ_DEL_PREV	Delete character before the cursor.
-REQ_DEL_WORD	Delete blank-delimited word at the cursor.
-REQ_DOWN_CHAR	Move down in the field.
+REQ_DEL_WORD	Delete blank-delimited word at cursor.
+REQ_DOWN_CHAR	Move down in field.
 REQ_DOWN_FIELD	Move down to a field.
-REQ_END_FIELD	Move to the end of the field.
+REQ_END_FIELD	Move to the end of field.
 REQ_END_LINE	Move to the end of the line.
 REQ_FIRST_FIELD	Move to the first field.
 REQ_FIRST_PAGE	Move to the first page.
@@ -94,7 +95,7 @@ REQ_INS_LINE	Insert a blank line at the cursor.
 REQ_INS_MODE	Enter insert mode.
 REQ_LAST_FIELD	Move to the last field.
 REQ_LAST_PAGE	Move to the last field.
-REQ_LEFT_CHAR	Move left in the field.
+REQ_LEFT_CHAR	Move left in field.
 REQ_LEFT_FIELD	Move left to a field.
 REQ_NEW_LINE	Insert or overlay a new line.
 REQ_NEXT_CHAR	Move to the next char.
@@ -111,25 +112,25 @@ REQ_PREV_FIELD	Move to the previous field.
 REQ_PREV_LINE	Move to the previous line.
 REQ_PREV_PAGE	Move to the previous page.
 REQ_PREV_WORD	Move to the previous word.
-REQ_RIGHT_CHAR	Move right in the field.
+REQ_RIGHT_CHAR	Move right in field.
 REQ_RIGHT_FIELD	Move right to a field.
-REQ_SCR_BCHAR	Scroll the field backward a character.
-REQ_SCR_BHPAGE	Scroll the field backward half a page.
-REQ_SCR_BLINE	Scroll the field backward a line.
-REQ_SCR_BPAGE	Scroll the field backward a page.
-REQ_SCR_FCHAR	Scroll the field forward a character.
-REQ_SCR_FHPAGE	Scroll the field forward half a page.
-REQ_SCR_FLINE	Scroll the field forward a line.
-REQ_SCR_FPAGE	Scroll the field forward a page.
-REQ_SCR_HBHALF	Horizontal scroll the field backward half a line.
-REQ_SCR_HBLINE	Horizontal scroll the field backward a line.
-REQ_SCR_HFHALF	Horizontal scroll the field forward half a line.
-REQ_SCR_HFLINE	Horizontal scroll the field forward a line.
+REQ_SCR_BCHAR	Scroll field backward 1 character.
+REQ_SCR_BHPAGE	Scroll field backward \(12 page.
+REQ_SCR_BLINE	Scroll field backward 1 line.
+REQ_SCR_BPAGE	Scroll field backward 1 page.
+REQ_SCR_FCHAR	Scroll field forward 1 character.
+REQ_SCR_FHPAGE	Scroll field forward \(12 page.
+REQ_SCR_FLINE	Scroll field forward 1 line.
+REQ_SCR_FPAGE	Scroll field forward 1 page.
+REQ_SCR_HBHALF	Horizontal scroll field backward \(12 line.
+REQ_SCR_HBLINE	Horizontal scroll field backward 1 line.
+REQ_SCR_HFHALF	Horizontal scroll field forward \(12 line.
+REQ_SCR_HFLINE	Horizontal scroll field forward 1 line.
 REQ_SFIRST_FIELD	Move to the sorted first field.
 REQ_SLAST_FIELD	Move to the sorted last field.
 REQ_SNEXT_FIELD	Move to the sorted next field.
 REQ_SPREV_FIELD	Move to the sorted previous field.
-REQ_UP_CHAR	Move up in the field.
+REQ_UP_CHAR	Move up in field.
 REQ_UP_FIELD	Move up to a field.
 REQ_VALIDATION	Validate field.
 .TE
@@ -138,7 +139,7 @@ If the second argument is a printable character, the driver places it
 in the current position in the current field.
 If it is one of the forms
 requests listed above, that request is executed.
-.SS Field validation
+.SS "Field Validation"
 The form library makes updates to the window associated
 with form fields rather than directly to the field buffers.
 .PP
@@ -147,7 +148,6 @@ The form driver also provides for validating modified fields
 to ensure that the contents
 meet whatever constraints an application may attach using \fBset_field_type\fP.
 .PP
-.PP
 You can validate a field without making any changes to it using
 \fBREQ_VALIDATION\fP.
 The form driver also validates a field in these cases:
@@ -166,8 +166,7 @@ In each case, the move fails if the field is invalid.
 If the modified field is valid, the form driver copies the modified
 data from the window associated with the field
 to the field buffer.
-.SS Mouse handling
-.PP
+.SS "Mouse Handling"
 If the second argument is the KEY_MOUSE special key, the associated
 mouse event is translated into one of the above pre-defined requests.
 Currently only clicks in the user window (e.g., inside the form display
@@ -200,7 +199,7 @@ the form cursor is positioned to that field.
 .bP
 If you double-click a field,
 the form cursor is positioned to that field
-and \fBE_UNKNOWN_COMMAND\fR is returned.
+and \fBE_UNKNOWN_COMMAND\fP is returned.
 This return value makes sense,
 because a double click usually means that an field-specific action should
 be returned.
@@ -208,21 +207,20 @@ It is exactly the purpose of this return value to signal that an
 application specific command should be executed.
 .bP
 If a translation
-into a request was done, \fBform_driver\fR returns the result of this request.
+into a request was done, \fBform_driver\fP returns the result of this request.
 .RE
 .PP
 If you clicked outside the user window
 or the mouse event could not be translated
-into a form request an \fBE_REQUEST_DENIED\fR is returned.
-.SS Application-defined commands
-.PP
+into a form request an \fBE_REQUEST_DENIED\fP is returned.
+.SS "Application-defined Commands"
 If the second argument is neither printable nor one of the above
 pre-defined form requests, the driver assumes it is an application-specific
-command and returns \fBE_UNKNOWN_COMMAND\fR.  Application-defined commands
-should be defined relative to \fBMAX_COMMAND\fR, the maximum value of these
+command and returns \fBE_UNKNOWN_COMMAND\fP.  Application-defined commands
+should be defined relative to \fBMAX_COMMAND\fP, the maximum value of these
 pre-defined requests.
 .SH RETURN VALUE
-\fBform_driver\fR returns one of the following error codes:
+\fBform_driver\fP returns one of the following error codes:
 .TP 5
 .B E_OK
 The routine succeeded.
@@ -246,22 +244,10 @@ No fields are connected to the form.
 The form driver could not process the request.
 .TP 5
 .B E_SYSTEM_ERROR
-System error occurred (see \fBerrno\fR(3)).
+System error occurred (see \fBerrno\fP(3)).
 .TP 5
 .B E_UNKNOWN_COMMAND
 The form driver code saw an unknown request code.
-.
-.SH SEE ALSO
-\fBcurses\fR(3X),
-\fBform\fR(3X),
-\fBform_fieldtype\fR(3X),
-\fBform_field_buffer\fR(3X),
-\fBform_field_validation\fR(3X),
-\fBform_variables\fR(3X),
-\fBgetch\fR(3X).
-.SH NOTES
-The header file \fB<form.h>\fR automatically includes the header files
-\fB<curses.h>\fR.
 .SH PORTABILITY
 These routines emulate the System V forms library.
 They were not supported on
@@ -269,3 +255,11 @@ Version 7 or BSD versions.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%form\fP(3X),
+\fB\%form_fieldtype\fP(3X),
+\fB\%form_field_buffer\fP(3X),
+\fB\%form_field_validation\fP(3X),
+\fB\%form_variables\fP(3X),
+\fB\%getch\fP(3X)
diff --git a/contrib/ncurses/man/form_field.3x b/contrib/ncurses/man/form_field.3x
index 01ff576af173..9799d0c0cfda 100644
--- a/contrib/ncurses/man/form_field.3x
+++ b/contrib/ncurses/man/form_field.3x
@@ -1,6 +1,6 @@
 '\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2012 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,39 +28,38 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: form_field.3x,v 1.17 2020/10/24 09:10:45 tom Exp $
-.TH form_field 3X ""
+.\" $Id: form_field.3x,v 1.34 2024/03/16 15:35:01 tom Exp $
+.TH form_field 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
-\fBform_field\fR \- make and break connections between fields and forms
+\fBform_field\fP \-
+make and break connections between fields and forms
 .SH SYNOPSIS
-\fB#include <form.h>\fR
-.sp
-\fBint set_form_fields(FORM *\fP\fIform\fP\fB, FIELD **\fP\fIfields\fP\fB);\fP
-.br
-\fBFIELD **form_fields(const FORM *\fP\fIform\fP\fB);\fP
-.br
-\fBint field_count(const FORM *\fP\fIform\fP\fB);\fP
-.br
-\fBint move_field(FIELD *\fP\fIfield\fP\fB, int \fP\fIfrow\fP\fB, int \fP\fIfcol\fP\fB);\fP
-.br
+.nf
+\fB#include <form.h>
+.PP
+\fBint set_form_fields(FORM *\fIform\fP, FIELD **\fIfields\fP);
+\fBFIELD **form_fields(const FORM *\fIform\fP);
+\fBint field_count(const FORM *\fIform\fP);
+\fBint move_field(FIELD *\fIfield\fP, int \fIfrow\fP, int \fIfcol\fP);
+.fi
 .SH DESCRIPTION
-The function \fBset_form_fields\fR changes the field pointer array of
-the given \fIform\fR.  The array must be terminated by a \fBNULL\fR.
+The function \fBset_form_fields\fP changes the field pointer array of
+the given \fIform\fP.  The array must be terminated by a \fBNULL\fP.
 .PP
-The function \fBform_fields\fR returns the field array of the given form.
+The function \fBform_fields\fP returns the field array of the given form.
 .PP
-The function \fBfield_count\fR returns the count of fields in \fIform\fR.
+The function \fBfield_count\fP returns the count of fields in \fIform\fP.
 .PP
-The function \fBmove_field\fR moves the given field (which must be disconnected)
+The function \fBmove_field\fP moves the given field (which must be disconnected)
 to a specified location on the screen.
 .SH RETURN VALUE
-The function \fBform_fields\fR returns a pointer (which may be \fBNULL\fR).
+The function \fBform_fields\fP returns a pointer (which may be \fBNULL\fP).
 It does not set \fBerrno\fP.
 .PP
-The function \fBfield_count\fR returns \fBERR\fR if the \fIform\fP parameter
+The function \fBfield_count\fP returns \fBERR\fP if the \fIform\fP parameter
 is \fBNULL\fP.
 .PP
-The functions \fBset_form_fields\fR and \fBmove_field\fR return one of
+The functions \fBset_form_fields\fP and \fBmove_field\fP return one of
 the following codes on error:
 .TP 5
 .B E_OK
@@ -76,19 +75,17 @@ The field is already connected to a form.
 The form is already posted.
 .TP 5
 .B E_SYSTEM_ERROR
-System error occurred (see \fBerrno\fR(3)).
-.SH SEE ALSO
-\fBcurses\fR(3X), \fBform\fR(3X).
-.SH NOTES
-The header file \fB<form.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
+System error occurred (see \fBerrno\fP(3)).
 .SH PORTABILITY
 These routines emulate the System V forms library.
 They were not supported on
 Version 7 or BSD versions.
 .PP
-The SVr4 forms library documentation specifies the \fBfield_count\fR error value
-as \-1 (which is the value of \fBERR\fR).
+The SVr4 forms library documentation specifies the \fBfield_count\fP error value
+as \-1 (which is the value of \fBERR\fP).
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%form\fP(3X)
diff --git a/contrib/ncurses/man/form_field_attributes.3x b/contrib/ncurses/man/form_field_attributes.3x
index 88778b1bc9a5..687e909e59be 100644
--- a/contrib/ncurses/man/form_field_attributes.3x
+++ b/contrib/ncurses/man/form_field_attributes.3x
@@ -1,6 +1,6 @@
 '\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2006,2010 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,45 +28,50 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: form_field_attributes.3x,v 1.18 2020/10/18 00:14:20 tom Exp $
-.TH form_field_attributes 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: form_field_attributes.3x,v 1.35 2024/03/16 15:35:01 tom Exp $
+.TH form_field_attributes 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
 .SH NAME
-\fBform_field_attributes\fR \- color and attribute control for form fields
+\fBform_field_attributes\fP \-
+color and attribute control for form fields
 .SH SYNOPSIS
-\fB#include <form.h>\fR
-.sp
-\fBint set_field_fore(FIELD *\fP\fIfield\fP\fB, chtype \fP\fIattr\fP\fB);\fP
-.br
-\fBchtype field_fore(const FIELD *\fP\fIfield\fP\fB);\fP
-.sp
-\fBint set_field_back(FIELD *\fP\fIfield\fP\fB, chtype \fP\fIattr\fP\fB);\fP
-.br
-\fBchtype field_back(const FIELD *\fP\fIfield\fP\fB);\fP
-.sp
-\fBint set_field_pad(FIELD *\fP\fIfield\fP\fB, int \fP\fIpad\fP\fB);\fP
-.br
-\fBint field_pad(const FIELD *\fP\fIfield\fP\fB);\fP
-.br
+.nf
+\fB#include <form.h>
+.PP
+\fBint set_field_fore(FIELD *\fIfield\fP, chtype \fIattr\fP);
+\fBchtype field_fore(const FIELD *\fIfield\fP);
+.PP
+\fBint set_field_back(FIELD *\fIfield\fP, chtype \fIattr\fP);
+\fBchtype field_back(const FIELD *\fIfield\fP);
+.PP
+\fBint set_field_pad(FIELD *\fIfield\fP, int \fIpad\fP);
+\fBint field_pad(const FIELD *\fIfield\fP);
+.fi
 .SH DESCRIPTION
-The function \fBset_field_fore\fR sets the foreground attribute of
-\fIfield\fR. This is the highlight used to display the field contents.  The
-function \fBfield_fore\fR returns the foreground attribute.
+The function \fBset_field_fore\fP sets the foreground attribute of
+\fIfield\fP. This is the highlight used to display the field contents.  The
+function \fBfield_fore\fP returns the foreground attribute.
 The default is
-\fBA_STANDOUT\fR.
+\fBA_STANDOUT\fP.
 .PP
-The function \fBset_field_back\fR sets the background attribute of
-\fIform\fR. This is the highlight used to display the extent fields in the
+The function \fBset_field_back\fP sets the background attribute of
+\fIform\fP. This is the highlight used to display the extent fields in the
 form.
-The function \fBfield_back\fR returns the background attribute.
+The function \fBfield_back\fP returns the background attribute.
 The
-default is \fBA_NORMAL\fR.
+default is \fBA_NORMAL\fP.
 .PP
-The function \fBset_field_pad\fR sets the character used to fill the field.
-The function \fBfield_pad\fR returns the given form's pad character.
+The function \fBset_field_pad\fP sets the character used to fill the field.
+The function \fBfield_pad\fP returns the given form's pad character.
 The
 default is a blank.
 .SH RETURN VALUE
@@ -79,14 +84,7 @@ The routine succeeded.
 Routine detected an incorrect or out-of-range argument.
 .TP 5
 .B E_SYSTEM_ERROR
-System error occurred (see \fBerrno\fR(3)).
-.
-.SH SEE ALSO
-\fBcurses\fR(3X) and related pages whose names begin \*(``form_\*('' for detailed
-descriptions of the entry points.
-.SH NOTES
-The header file \fB<form.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
+System error occurred (see \fBerrno\fP(3)).
 .SH PORTABILITY
 These routines emulate the System V forms library.
 They were not supported on
@@ -94,3 +92,6 @@ Version 7 or BSD versions.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X) and related pages whose names begin \*(``form_\*(''
+for detailed descriptions of the entry points.
diff --git a/contrib/ncurses/man/form_field_buffer.3x b/contrib/ncurses/man/form_field_buffer.3x
index 98b2e42dc831..ba176d3e122b 100644
--- a/contrib/ncurses/man/form_field_buffer.3x
+++ b/contrib/ncurses/man/form_field_buffer.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,44 +27,51 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: form_field_buffer.3x,v 1.27 2020/10/24 09:27:17 tom Exp $
-.TH form_field_buffer 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: form_field_buffer.3x,v 1.45 2024/03/16 15:35:01 tom Exp $
+.TH form_field_buffer 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
 .SH NAME
-\fBform_field_buffer\fR \- field buffer control
+\fBform_field_buffer\fP \-
+field buffer control
 .SH SYNOPSIS
-\fB#include <form.h>\fR
-.sp
-\fBint set_field_buffer(FIELD *\fP\fIfield\fP\fB, int \fP\fIbuf\fP\fB, const char *\fP\fIvalue\fP\fB);\fP
-.br
-\fBchar *field_buffer(const FIELD *\fP\fIfield\fP\fB, int \fP\fIbuffer\fP\fB);\fP
-.sp
-\fBint set_field_status(FIELD *\fP\fIfield\fP\fB, bool \fP\fIstatus\fP\fB);\fP
-.br
-\fBbool field_status(const FIELD *\fP\fIfield\fP\fB);\fP
-.sp
-\fBint set_max_field(FIELD *\fP\fIfield\fP\fB, int \fP\fImax\fP\fB);\fP
-.br
+.nf
+\fB#include <form.h>
+.PP
+\fBint set_field_buffer(FIELD *\fIfield\fP, int \fIbuf\fP, const char *\fIvalue\fP);
+\fBchar *field_buffer(const FIELD *\fIfield\fP, int \fIbuffer\fP);
+.PP
+\fBint set_field_status(FIELD *\fIfield\fP, bool \fIstatus\fP);
+\fBbool field_status(const FIELD *\fIfield\fP);
+.PP
+\fBint set_max_field(FIELD *\fIfield\fP, int \fImax\fP);
+.fi
 .SH DESCRIPTION
-The function \fBset_field_buffer\fR sets the numbered buffer of the given field
+The function \fBset_field_buffer\fP sets the numbered buffer of the given field
 to contain a given string:
 .RS 3
 .bP
 Buffer 0 is the displayed value of the field.
 .bP
-Other numbered buffers may be allocated by applications through the \fBnbuf\fR
-argument of (see \fBform_field_new\fR(3X))
+Other numbered buffers may be allocated by applications through the \fBnbuf\fP
+argument of (see \fBform_field_new\fP(3X))
 but are not manipulated by the forms library.
 .RE
 .PP
-The function \fBfield_buffer\fR returns a pointer to
+The function \fBfield_buffer\fP returns a pointer to
 the contents of the given numbered buffer:
 .RS 3
 .bP
@@ -90,15 +96,15 @@ correspond to the window, you should not rely on using buffers
 for long-term storage of form data.
 .RE
 .PP
-The function \fBset_field_status\fR sets the associated status flag of
-\fIfield\fR; \fBfield_status\fR gets the current value.
+The function \fBset_field_status\fP sets the associated status flag of
+\fIfield\fP; \fBfield_status\fP gets the current value.
 The status flag
 is set to a nonzero value whenever the field changes.
 .PP
-The function \fBset_max_field\fR sets the maximum size for a dynamic field.
+The function \fBset_max_field\fP sets the maximum size for a dynamic field.
 An argument of 0 turns off any maximum size threshold for that field.
 .SH RETURN VALUE
-The \fBfield_buffer\fR function returns NULL on error.
+The \fBfield_buffer\fP function returns NULL on error.
 It sets \fBerrno\fP according to their success:
 .TP 5
 .B E_OK
@@ -107,7 +113,7 @@ The routine succeeded.
 .B E_BAD_ARGUMENT
 Routine detected an incorrect or out-of-range argument.
 .PP
-The \fBfield_status\fR function returns \fBTRUE\fR or \fBFALSE\fR.
+The \fBfield_status\fP function returns \fBTRUE\fP or \fBFALSE\fP.
 .PP
 The remaining routines return one of the following:
 .TP 5
@@ -115,30 +121,27 @@ The remaining routines return one of the following:
 The routine succeeded.
 .TP 5
 .B E_SYSTEM_ERROR
-System error occurred (see \fBerrno\fR(3)).
+System error occurred (see \fBerrno\fP(3)).
 .TP 5
 .B E_BAD_ARGUMENT
 Routine detected an incorrect or out-of-range argument.
-.SH SEE ALSO
-\fBcurses\fR(3X) and related pages whose names begin \*(``form_\*('' for detailed
-descriptions of the entry points.
 .SH NOTES
-The header file \fB<form.h>\fR automatically includes the header file
-.PP
 When configured for wide characters, \fBfield_buffer\fP returns a pointer
 to temporary storage (allocated and freed by the library).
 The application should not attempt to modify the data.
 It will be freed on the next call to \fBfield_buffer\fP to return the
 same buffer.
-\fB<curses.h>\fR.
 .SH PORTABILITY
 These routines emulate the System V forms library.
 They were not supported on
 Version 7 or BSD versions.
 .PP
-The \fBset_max_field\fP function checks for an ncurses extension
+The \fBset_max_field\fP function checks for an \fI\%ncurses\fP extension
 \fBO_INPUT_FIELD\fP which allows a dynamic field to shrink if the new
 limit is smaller than the current field size.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X) and related pages whose names begin \*(``form_\*(''
+for detailed descriptions of the entry points.
diff --git a/contrib/ncurses/man/form_field_info.3x b/contrib/ncurses/man/form_field_info.3x
index 556c45ba22d5..84b10d96d4b8 100644
--- a/contrib/ncurses/man/form_field_info.3x
+++ b/contrib/ncurses/man/form_field_info.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2015 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,40 +27,47 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: form_field_info.3x,v 1.18 2020/10/17 23:35:05 tom Exp $
-.TH form_field_info 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: form_field_info.3x,v 1.32 2024/03/16 15:35:01 tom Exp $
+.TH form_field_info 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
 .SH NAME
 \fBdynamic_field_info\fP,
-\fBfield_info\fR \- retrieve field characteristics
+\fBfield_info\fP \-
+retrieve field characteristics
 .SH SYNOPSIS
 .nf
-\fB#include <form.h>\fR
-.sp
-\fBint field_info(const FIELD *\fP\fIfield\fP\fB,\fP
-               \fBint *\fP\fIrows\fP\fB, int *\fP\fIcols\fP\fB,\fP
-               \fBint *\fP\fIfrow\fP\fB, int *\fP\fIfcol\fP\fB,\fP
-               \fBint *\fP\fInrow\fP\fB, int *\fP\fInbuf\fB);\fP
-.sp
-\fBint dynamic_field_info(const FIELD *\fP\fIfield\fP\fB,\fP
-                       \fBint *\fP\fIrows\fP\fB, int *\fP\fIcols\fP\fB, int *\fImax\fB);\fP
+\fB#include <form.h>
+.PP
+\fBint field_info(const FIELD *\fIfield\fP,
+               \fBint *\fIrows\fB, int *\fIcols\fB,\fR
+               \fBint *\fIfrow\fB, int *\fIfcol\fB,\fR
+               \fBint *\fInrow\fB, int *\fInbuf\fB);\fR
+.PP
+\fBint dynamic_field_info(const FIELD *\fIfield\fB,\fR
+                       \fBint *\fIrows\fB, int *\fIcols\fB, int *\fImax\fB);\fR
 .fi
 .SH DESCRIPTION
-The function \fBfield_info\fR returns the sizes and other attributes passed in
+The function \fBfield_info\fP returns the sizes and other attributes passed in
 to the field at its creation time.
 The attributes are: height, width, row of
 upper-left corner, column of upper-left corner, number off-screen rows, and
 number of working buffers.
 .PP
-The function \fBdynamic_field_info\fR returns the actual size of the field, and
+The function \fBdynamic_field_info\fP returns the actual size of the field, and
 its maximum possible size.
 If the field has no size limit, the location
 addressed by the third argument will be set to 0.
 A field can be made dynamic
-by turning off the \fBO_STATIC\fR option with \fBfield_opts_off\fR.
+by turning off the \fBO_STATIC\fP option with \fBfield_opts_off\fP.
 .SH RETURN VALUE
 These routines return one of the following:
 .TP 5
@@ -69,16 +75,10 @@ These routines return one of the following:
 The routine succeeded.
 .TP 5
 .B E_SYSTEM_ERROR
-System error occurred (see \fBerrno\fR(3)).
+System error occurred (see \fBerrno\fP(3)).
 .TP 5
 .B E_BAD_ARGUMENT
 Routine detected an incorrect or out-of-range argument.
-.SH SEE ALSO
-\fBcurses\fR(3X) and related pages whose names begin \*(``form_\*('' for detailed
-descriptions of the entry points.
-.SH NOTES
-The header file \fB<form.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
 .SH PORTABILITY
 These routines emulate the System V forms library.
 They were not supported on
@@ -90,3 +90,6 @@ Not all implementations allow this, e.g., Solaris 2.7 does not.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X) and related pages whose names begin \*(``form_\*(''
+for detailed descriptions of the entry points.
diff --git a/contrib/ncurses/man/form_field_just.3x b/contrib/ncurses/man/form_field_just.3x
index d8fef7656542..c1fd5545eb8a 100644
--- a/contrib/ncurses/man/form_field_just.3x
+++ b/contrib/ncurses/man/form_field_just.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2015 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,48 +27,49 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: form_field_just.3x,v 1.18 2020/10/18 00:12:55 tom Exp $
-.TH form_field_just 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: form_field_just.3x,v 1.35 2024/03/16 15:35:01 tom Exp $
+.TH form_field_just 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
 .SH NAME
-\fBset_field_just\fR,
-\fBfield_just\fP \- retrieve field characteristics
+\fBset_field_just\fP,
+\fBfield_just\fP \-
+retrieve field characteristics
 .SH SYNOPSIS
-\fB#include <form.h>\fR
-.sp
-\fBint set_field_just(FIELD *\fP\fIfield\fP\fB, int \fP\fIjustification\fP\fB);\fP
-.br
-\fBint field_just(const FIELD *\fP\fIfield\fP\fB);\fP
-.br
+.nf
+\fB#include <form.h>
+.PP
+\fBint set_field_just(FIELD *\fIfield\fP, int \fIjustification\fP);
+\fBint field_just(const FIELD *\fIfield\fP);
+.fi
 .SH DESCRIPTION
-The function \fBset_field_just\fR sets the justification attribute of
-a field; \fBfield_just\fR returns a field's justification attribute.
+The function \fBset_field_just\fP sets the justification attribute of
+a field; \fBfield_just\fP returns a field's justification attribute.
 The attribute may be one of NO_JUSTIFICATION, JUSTIFY_RIGHT,
 JUSTIFY_LEFT, or JUSTIFY_CENTER.
 .
 .SH RETURN VALUE
-The function \fBfield_just\fR returns one of: NO_JUSTIFICATION,
+The function \fBfield_just\fP returns one of: NO_JUSTIFICATION,
 JUSTIFY_RIGHT, JUSTIFY_LEFT, or JUSTIFY_CENTER.
 .PP
-The function \fBset_field_just\fR returns one of the following:
+The function \fBset_field_just\fP returns one of the following:
 .TP 5
 .B E_OK
 The routine succeeded.
 .TP 5
 .B E_SYSTEM_ERROR
-System error occurred (see \fBerrno\fR(3)).
+System error occurred (see \fBerrno\fP(3)).
 .TP 5
 .B E_BAD_ARGUMENT
 Routine detected an incorrect or out-of-range argument.
-.SH SEE ALSO
-\fBcurses\fR(3X) and related pages whose names begin \*(``form_\*('' for detailed
-descriptions of the entry points.
-.SH NOTES
-The header file \fB<form.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
 .SH PORTABILITY
 These routines emulate the System V forms library.
 They were not supported on
@@ -77,3 +77,6 @@ Version 7 or BSD versions.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X) and related pages whose names begin \*(``form_\*(''
+for detailed descriptions of the entry points.
diff --git a/contrib/ncurses/man/form_field_new.3x b/contrib/ncurses/man/form_field_new.3x
index 1a240d0a7fc3..9cf08adb521c 100644
--- a/contrib/ncurses/man/form_field_new.3x
+++ b/contrib/ncurses/man/form_field_new.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2015 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,32 +27,31 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: form_field_new.3x,v 1.24 2020/10/24 09:09:18 tom Exp $
-.TH form_field_new 3X ""
+.\" $Id: form_field_new.3x,v 1.41 2024/03/16 15:35:01 tom Exp $
+.TH form_field_new 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
-\fBnew_field\fR,
-\fBdup_field\fR,
-\fBlink_field\fR,
-\fBfree_field\fR \- create and destroy form fields
+\fBnew_field\fP,
+\fBdup_field\fP,
+\fBlink_field\fP,
+\fBfree_field\fP \-
+create and destroy form fields
 .SH SYNOPSIS
-\fB#include <form.h>\fR
-.sp
-\fBFIELD *new_field(int \fP\fIheight\fP\fB, int \fP\fIwidth\fP\fB,\fP
-                 \fBint \fP\fItoprow\fP\fB, int \fP\fIleftcol\fP\fB,\fP
-                 \fBint \fP\fIoffscreen\fP\fB, int \fP\fInbuffers\fP\fB);\fP
-.br
-\fBFIELD *dup_field(FIELD *\fP\fIfield\fP\fB, int \fP\fItoprow\fP\fB, int \fP\fIleftcol\fP\fB);\fP
-.br
-\fBFIELD *link_field(FIELD *\fP\fIfield\fP\fB, int \fP\fItoprow\fP\fB, int \fP\fIleftcol\fP\fB);\fP
-.br
-\fBint free_field(FIELD *\fP\fIfield\fP\fB);\fP
-.br
+.nf
+\fB#include <form.h>
+.PP
+\fBFIELD *new_field(int \fIheight\fP, int \fIwidth\fP,
+                 \fBint \fItoprow\fB, int \fIleftcol\fB,\fR
+                 \fBint \fIoffscreen\fB, int \fInbuffers\fB);\fR
+\fBFIELD *dup_field(FIELD *\fIfield\fB, int \fItoprow\fB, int \fIleftcol\fB);\fR
+\fBFIELD *link_field(FIELD *\fIfield\fB, int \fItoprow\fB, int \fIleftcol\fB);\fR
+\fBint free_field(FIELD *\fIfield\fB);\fR
+.fi
 .SH DESCRIPTION
-The function \fBnew_field\fR allocates a new field and initializes it from the
+The function \fBnew_field\fP allocates a new field and initializes it from the
 parameters given: height, width, row of upper-left corner, column of upper-left
 corner, number off-screen rows, and number of additional working buffers.
 .PP
-The function \fBdup_field\fR duplicates a field at a new location.
+The function \fBdup_field\fP duplicates a field at a new location.
 Most
 attributes (including current contents, size, validation type, buffer count,
 growth threshold, justification, foreground, background, pad character,
@@ -61,14 +59,14 @@ options, and user pointer) are copied.
 Field status and the field page bit are
 not copied.
 .PP
-The function \fBlink_field\fR acts like \fBdup_field\fR, but the new field
+The function \fBlink_field\fP acts like \fBdup_field\fP, but the new field
 shares buffers with its parent.
 Attribute data is separate.
 .PP
-The function \fBfree_field\fR de-allocates storage associated with a field.
+The function \fBfree_field\fP de-allocates storage associated with a field.
 .SH RETURN VALUE
-The functions \fBnew_field\fR, \fBdup_field\fR, \fBlink_field\fR return
-\fBNULL\fR on error.
+The functions \fBnew_field\fP, \fBdup_field\fP, \fBlink_field\fP return
+\fBNULL\fP on error.
 They set \fBerrno\fP according to their success:
 .TP 5
 .B E_OK
@@ -80,7 +78,7 @@ Routine detected an incorrect or out-of-range argument.
 .B E_SYSTEM_ERROR
 System error occurred, e.g., malloc failure.
 .PP
-The function \fBfree_field\fR returns one of the following:
+The function \fBfree_field\fP returns one of the following:
 .TP 5
 .B E_OK
 The routine succeeded.
@@ -90,19 +88,17 @@ Routine detected an incorrect or out-of-range argument.
 .TP 5
 .B E_CONNECTED
 field is connected.
-.SH SEE ALSO
-\fBcurses\fR(3X), \fBform\fR(3X).
-.SH NOTES
-The header file \fB<form.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
 .SH PORTABILITY
 These routines emulate the System V forms library.
 They were not supported on
 Version 7 or BSD versions.
 .PP
 It may be unwise to count on the set of attributes copied by
-\fBdup_field\fR being portable; the System V forms library documents are
+\fBdup_field\fP being portable; the System V forms library documents are
 not very explicit about what gets copied and what does not.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%form\fP(3X)
diff --git a/contrib/ncurses/man/form_field_opts.3x b/contrib/ncurses/man/form_field_opts.3x
index 96338e295eef..9ab3ad0cb32a 100644
--- a/contrib/ncurses/man/form_field_opts.3x
+++ b/contrib/ncurses/man/form_field_opts.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2014,2015 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,35 +27,35 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: form_field_opts.3x,v 1.27 2020/10/18 00:11:45 tom Exp $
-.TH form_field_opts 3X ""
+.\" $Id: form_field_opts.3x,v 1.44 2024/03/16 15:35:01 tom Exp $
+.TH form_field_opts 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
 \fBset_field_opts\fP,
 \fBfield_opts_on\fP,
 \fBfield_opts_off\fP,
-\fBfield_opts\fP \- set and get field options
+\fBfield_opts\fP \-
+set and get field options
 .SH SYNOPSIS
-\fB#include <form.h>\fR
-.sp
-\fBint set_field_opts(FIELD *\fP\fIfield\fP\fB, Field_Options \fP\fIopts\fP\fB);\fP
-.br
-\fBField_Options field_opts(const FIELD *\fP\fIfield\fP\fB);\fP
-.sp
-\fBint field_opts_on(FIELD *\fP\fIfield\fP\fB, Field_Options \fP\fIopts\fP\fB);\fP
-.br
-\fBint field_opts_off(FIELD *\fP\fIfield\fP\fB, Field_Options \fP\fIopts\fP\fB);\fP
-.br
+.nf
+\fB#include <form.h>
+.PP
+\fBint set_field_opts(FIELD *\fIfield\fP, Field_Options \fIopts\fP);
+\fBField_Options field_opts(const FIELD *\fIfield\fP);
+.PP
+\fBint field_opts_on(FIELD *\fIfield\fP, Field_Options \fIopts\fP);
+\fBint field_opts_off(FIELD *\fIfield\fP, Field_Options \fIopts\fP);
+.fi
 .SH DESCRIPTION
-The function \fBset_field_opts\fR sets all the given field's option bits (field
+The function \fBset_field_opts\fP sets all the given field's option bits (field
 option bits may be logically-OR'ed together).
 .PP
-The function \fBfield_opts_on\fR turns on the given option bits, and leaves
+The function \fBfield_opts_on\fP turns on the given option bits, and leaves
 others alone.
 .PP
-The function \fBfield_opts_off\fR turns off the given option bits, and leaves
+The function \fBfield_opts_off\fP turns off the given option bits, and leaves
 others alone.
 .PP
-The function \fBfield_opts\fR returns the field's current option bits.
+The function \fBfield_opts\fP returns the field's current option bits.
 .PP
 The following standard options are defined (all are on by default):
 .TP 5
@@ -121,7 +120,7 @@ The \fBset_max_field\fP function checks for this extension,
 which allows a dynamic field to shrink if the new
 limit is smaller than the current field size.
 .SH RETURN VALUE
-Except for \fBfield_opts\fR, each routine returns one of the following:
+Except for \fBfield_opts\fP, each routine returns one of the following:
 .TP 5
 .B E_OK
 The routine succeeded.
@@ -133,14 +132,7 @@ Routine detected an incorrect or out-of-range argument.
 The field is the current field.
 .TP 5
 .B E_SYSTEM_ERROR
-System error occurred (see \fBerrno\fR(3)).
-.SH SEE ALSO
-\fBcurses\fR(3X),
-\fBform\fR(3X).
-\fBform_field_just\fR(3X).
-.SH NOTES
-The header file \fB<form.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
+System error occurred (see \fBerrno\fP(3)).
 .SH PORTABILITY
 These routines emulate the System V forms library.
 They were not supported on
@@ -148,3 +140,7 @@ Version 7 or BSD versions.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%form\fP(3X),
+\fB\%form_field_just\fP(3X)
diff --git a/contrib/ncurses/man/form_field_userptr.3x b/contrib/ncurses/man/form_field_userptr.3x
index 5d3ab1444c35..6eea09201e76 100644
--- a/contrib/ncurses/man/form_field_userptr.3x
+++ b/contrib/ncurses/man/form_field_userptr.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2015 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,32 +27,29 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: form_field_userptr.3x,v 1.16 2020/10/24 09:06:33 tom Exp $
-.TH form_field_userptr 3X ""
+.\" $Id: form_field_userptr.3x,v 1.30 2024/03/16 15:35:01 tom Exp $
+.TH form_field_userptr 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
-\fBset_field_userptr\fR,
-\fBfield_userptr\fR \- associate application data with a form field
+\fBset_field_userptr\fP,
+\fBfield_userptr\fP \-
+associate application data with a form field
 .SH SYNOPSIS
-\fB#include <form.h>\fR
-.sp
-\fBint set_field_userptr(FIELD *\fP\fIfield\fP\fB, void *\fP\fIuserptr\fP\fB);\fP
-.br
-\fBvoid *field_userptr(const FIELD *\fP\fIfield\fP\fB);\fP
+.nf
+\fB#include <form.h>
+.PP
+\fBint set_field_userptr(FIELD *\fIfield\fP, void *\fIuserptr\fP);
+\fBvoid *field_userptr(const FIELD *\fIfield\fP);
+.fi
 .SH DESCRIPTION
 Every form field has a field that can be used to hold application-specific data
 (that is, the form-driver code leaves it alone).
 These functions get and set
 that field.
 .SH RETURN VALUE
-The function \fBfield_userptr\fR returns a pointer (which may be \fBNULL\fR).
+The function \fBfield_userptr\fP returns a pointer (which may be \fBNULL\fP).
 It does not set \fBerrno\fP.
 .PP
-The function \fBset_field_userptr\fR returns \fBE_OK\fP (success).
-.SH SEE ALSO
-\fBcurses\fR(3X), \fBform\fR(3X).
-.SH NOTES
-The header file \fB<form.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
+The function \fBset_field_userptr\fP returns \fBE_OK\fP (success).
 .SH PORTABILITY
 These routines emulate the System V forms library.
 They were not supported on
@@ -64,3 +60,6 @@ We chose not to leave it as a char pointer for SVr4 compatibility.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%form\fP(3X)
diff --git a/contrib/ncurses/man/form_field_validation.3x b/contrib/ncurses/man/form_field_validation.3x
index 8ce9132c13c7..54fa2a72a4b4 100644
--- a/contrib/ncurses/man/form_field_validation.3x
+++ b/contrib/ncurses/man/form_field_validation.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,43 +27,43 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: form_field_validation.3x,v 1.33 2020/12/12 19:57:55 tom Exp $
-.TH form_field_validation 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: form_field_validation.3x,v 1.53 2024/03/16 15:35:01 tom Exp $
+.TH form_field_validation 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
 .SH NAME
-\fBform_field_validation\fR \- data type validation for fields
+\fBform_field_validation\fP \-
+data type validation for fields
 .SH SYNOPSIS
-\fB#include <form.h>\fR
-.sp
-\fBvoid *field_arg(const FIELD *\fP\fIfield\fP\fB);\fP
-.br
-\fBFIELDTYPE *field_type(const FIELD *\fP\fIfield\fP\fB);\fP
-.br
-\fBint set_field_type(FIELD *\fP\fIfield\fP\fB, FIELDTYPE *\fP\fItype\fP\fB, ...);\fP
-.sp
-/* predefined field types */
-.br
-\fBFIELDTYPE *TYPE_ALNUM;\fP
-.br
-\fBFIELDTYPE *TYPE_ALPHA;\fP
-.br
-\fBFIELDTYPE *TYPE_ENUM;\fP
-.br
-\fBFIELDTYPE *TYPE_INTEGER;\fP
-.br
-\fBFIELDTYPE *TYPE_NUMERIC;\fP
-.br
-\fBFIELDTYPE *TYPE_REGEXP;\fP
-.br
-\fBFIELDTYPE *TYPE_IPV4;\fP
-.br
+.nf
+\fB#include <form.h>
+.PP
+\fBvoid *field_arg(const FIELD *\fIfield\fP);
+\fBFIELDTYPE *field_type(const FIELD *\fIfield\fP);
+\fBint set_field_type(FIELD *\fIfield\fP, FIELDTYPE *\fItype\fP, ...);
+.PP
+\fI/* predefined field types */\fP
+\fBFIELDTYPE *TYPE_ALNUM;
+\fBFIELDTYPE *TYPE_ALPHA;
+\fBFIELDTYPE *TYPE_ENUM;
+\fBFIELDTYPE *TYPE_INTEGER;
+\fBFIELDTYPE *TYPE_NUMERIC;
+\fBFIELDTYPE *TYPE_REGEXP;
+\fBFIELDTYPE *TYPE_IPV4;
+.fi
 .SH DESCRIPTION
 By default, no validation is done on form fields.
 You can associate a form with with a \fIfield type\fP,
@@ -76,113 +76,94 @@ a copy of the arguments provided in a \fBset_field_type\fP call.
 Returns a pointer to the \fIfield type\fP associated with the form field,
 i.e., by calling \fBset_field_type\fP.
 .SS set_field_type
-The function \fBset_field_type\fR associates
+The function \fBset_field_type\fP associates
 a field type with a given form field.
 This is the type checked by validation functions.
 Most field types are configurable,
 via arguments which the caller provides when calling \fBset_field_type\fP.
 .PP
 Several field types are predefined by the form library.
-.SS Predefined types
-.PP
+.SH PREDEFINED TYPES
 It is possible to set up new programmer-defined field types.
 Field types are implemented via the \fBFIELDTYPE\fP data
 structure, which contains several pointers to functions.
 .PP
-See the \fBform_fieldtype\fR(3X) manual page,
+See the \fBform_fieldtype\fP(3X) manual page,
 which describes functions which can be used to construct
 a field-type dynamically.
 .PP
 The predefined types are as follows:
-.TP 5
-TYPE_ALNUM
+.SS TYPE_ALNUM
 Alphanumeric data.
 Required parameter:
-.RS
 .bP
-a third \fBint\fR argument, a minimum field width.
-.RE
-.TP 5
-TYPE_ALPHA
+a third \fBint\fP argument, a minimum field width.
+.SS TYPE_ALPHA
 Character data.
 Required parameter:
-.RS
 .bP
-a third \fBint\fR argument, a minimum field width.
-.RE
-.TP 5
-TYPE_ENUM
+a third \fBint\fP argument, a minimum field width.
+.SS TYPE_ENUM
 Accept one of a specified set of strings.
 Required parameters:
-.RS
 .bP
-a third \fB(char **)\fR argument pointing to a string list;
+a third \fB(char **)\fP argument pointing to a string list;
 .bP
-a fourth \fBint\fR flag argument to enable case-sensitivity;
+a fourth \fBint\fP flag argument to enable case-sensitivity;
 .bP
-a fifth \fBint\fR flag argument specifying whether a partial
+a fifth \fBint\fP flag argument specifying whether a partial
 match must be a unique one.
 If this flag is off, a prefix matches the first
 of any set of more than one list elements with that prefix.
-.RE
-.IP
+.PP
 The library copies the string list,
 so you may use a list that lives in automatic variables on the stack.
-.TP 5
-TYPE_INTEGER
+.SS TYPE_INTEGER
 Integer data, parsable to an integer by \fBatoi\fP(3).
 Required parameters:
-.RS
 .bP
-a third \fBint\fR argument controlling the precision,
+a third \fBint\fP argument controlling the precision,
 .bP
-a fourth \fBlong\fR argument constraining minimum value,
+a fourth \fBlong\fP argument constraining minimum value,
 .bP
-a fifth \fBlong\fR constraining maximum value.
+a fifth \fBlong\fP constraining maximum value.
 If the maximum value is less than or equal to the minimum value, the range is
 simply ignored.
-.RE
-.IP
+.PP
 On return, the field buffer is formatted according to the
-\fBprintf\fR format specification \*(``.*ld\*('',
+\fBprintf\fP format specification \*(``.*ld\*('',
 where the \*(``*\*('' is replaced by the precision argument.
-.IP
-For details of the precision handling see \fBprintf\fR(3).
-.TP 5
-TYPE_NUMERIC
+.PP
+For details of the precision handling see \fBprintf\fP(3).
+.SS TYPE_NUMERIC
 Numeric data (may have a decimal-point part).
 Required parameters:
-.RS
 .bP
-a third \fBint\fR argument controlling the precision,
+a third \fBint\fP argument controlling the precision,
 .bP
-a fourth \fBdouble\fR argument constraining minimum value,
+a fourth \fBdouble\fP argument constraining minimum value,
 .bP
-and a fifth \fBdouble\fR constraining maximum value.
+and a fifth \fBdouble\fP constraining maximum value.
 If your system supports locales,
 the decimal point character must be the one specified by your locale.
 If the maximum value is less than or equal to the minimum value,
 the range is simply ignored.
-.RE
-.IP
+.PP
 On return, the field buffer is formatted according to the
-\fBprintf\fR format specification \*(``.*f\*('',
+\fBprintf\fP format specification \*(``.*f\*('',
 where the \*(``*\*('' is replaced by the precision argument.
-.IP
-For details of the precision handling see \fBprintf\fR(3).
-.TP 5
-TYPE_REGEXP
+.PP
+For details of the precision handling see \fBprintf\fP(3).
+.SS TYPE_REGEXP
 Regular expression data.
 Required parameter:
-.RS
 .bP
-a third argument, a regular expression \fB(char *)\fR string.
+a third argument, a regular expression \fB(char *)\fP string.
 The data is valid if the regular expression matches it.
-.RE
-.IP
+.PP
 Regular expressions
-are in the format of \fBregcomp\fR and \fBregexec\fR.
-.IP
+are in the format of \fBregcomp\fP and \fBregexec\fP.
+.PP
 The regular expression must match the whole field.
 If you have for example, an eight character wide field,
 a regular expression "^[0\-9]*$" always
@@ -192,39 +173,28 @@ you may use for example "^[0\-9]* *$" which is good for
 trailing spaces (up to an empty field),
 or "^ *[0\-9]* *$" which is good for
 leading and trailing spaces around the digits.
-.TP 5
-TYPE_IPV4
+.SS TYPE_IPV4
 An Internet Protocol Version 4 address.
 Required parameter:
-.RS
 .bP
 none
-.RE
-.IP
+.PP
 The form library checks whether or not the buffer has the form \fIa.b.c.d\fP,
 where \fIa\fP, \fIb\fP, \fIc\fP, and \fId\fP are numbers in the range 0 to 255.
 Trailing blanks in the buffer are ignored.
 The address itself is not validated.
-.IP
-This is an ncurses extension;
+.PP
+This is an \fI\%ncurses\fP extension;
 this field type may not be available in other curses implementations.
 .SH RETURN VALUE
-The functions \fBfield_type\fR and \fBfield_arg\fR return \fBNULL\fR on error.
-The function \fBset_field_type\fR returns one of the following:
+The functions \fBfield_type\fP and \fBfield_arg\fP return \fBNULL\fP on error.
+The function \fBset_field_type\fP returns one of the following:
 .TP 5
 .B E_OK
 The routine succeeded.
 .TP 5
 .B E_SYSTEM_ERROR
-System error occurred (see \fBerrno\fR(3)).
-.SH SEE ALSO
-\fBcurses\fR(3X),
-\fBform\fR(3X),
-\fBform_fieldtype\fR(3X),
-\fBform_variables\fR(3X).
-.SH NOTES
-The header file \fB<form.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
+System error occurred (see \fBerrno\fP(3)).
 .SH PORTABILITY
 These routines emulate the System V forms library.
 They were not supported on
@@ -232,3 +202,8 @@ Version 7 or BSD versions.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%form\fP(3X),
+\fB\%form_fieldtype\fP(3X),
+\fB\%form_variables\fP(3X)
diff --git a/contrib/ncurses/man/form_fieldtype.3x b/contrib/ncurses/man/form_fieldtype.3x
index 767c3fcfafcd..81a58b1d8e48 100644
--- a/contrib/ncurses/man/form_fieldtype.3x
+++ b/contrib/ncurses/man/form_fieldtype.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2006,2010 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,43 +27,44 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: form_fieldtype.3x,v 1.28 2020/12/12 17:11:21 tom Exp $
+.\" $Id: form_fieldtype.3x,v 1.46 2024/03/16 15:35:01 tom Exp $
+.TH form_fieldtype 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.TH form_fieldtype 3X ""
 .SH NAME
-\fBform_fieldtype\fR \- define validation-field types
+\fBform_fieldtype\fP \-
+define validation-field types
 .SH SYNOPSIS
-\fB#include <form.h>\fR
-.sp
-\fBFIELDTYPE *new_fieldtype(\fP
-    \fBbool (* const \fP\fIfield_check\fP\fB)(FIELD *, const void *),\fP
-    \fBbool (* const \fP\fIchar_check\fP\fB)(int, const void *));\fP
-.br
-\fBint free_fieldtype(FIELDTYPE *\fP\fIfieldtype\fP\fB);\fP
-.sp
+.nf
+\fB#include <form.h>
+.PP
+\fBFIELDTYPE *new_fieldtype(
+    \fBbool (* const \fIfield_check\fB)(FIELD *, const void *),\fR
+    \fBbool (* const \fIchar_check\fB)(int, const void *));\fR
+\fBint free_fieldtype(FIELDTYPE *\fIfieldtype\fB);\fR
+.PP
 \fBint set_fieldtype_arg(\fP
-    \fBFIELDTYPE *\fP\fIfieldtype\fP\fB,\fP
-    \fBvoid *(* const \fP\fImake_arg\fP\fB)(va_list *),\fP
-    \fBvoid *(* const \fP\fIcopy_arg\fP\fB)(const void *),\fP
-    \fBvoid  (* const \fP\fIfree_arg\fP\fB)(void *));\fP
-.br
+    \fBFIELDTYPE *\fIfieldtype\fB,\fR
+    \fBvoid *(* const \fImake_arg\fB)(va_list *),\fR
+    \fBvoid *(* const \fIcopy_arg\fB)(const void *),\fR
+    \fBvoid  (* const \fIfree_arg\fB)(void *));\fR
 \fBint set_fieldtype_choice(\fP
-    \fBFIELDTYPE *\fP\fIfieldtype\fP\fB,\fP
-    \fBbool (* const \fP\fInext_choice\fP\fB)(FIELD *, const void *),\fP
-    \fBbool (* const \fP\fIprev_choice\fP\fB)(FIELD *, const void *));\fP
-.sp
-\fBFIELDTYPE *link_fieldtype(FIELDTYPE *\fP\fItype1\fP\fB,\fP
-                          \fBFIELDTYPE *\fP\fItype2\fP\fB);\fP
+    \fBFIELDTYPE *\fIfieldtype\fB,\fR
+    \fBbool (* const \fInext_choice\fB)(FIELD *, const void *),\fR
+    \fBbool (* const \fIprev_choice\fB)(FIELD *, const void *));\fR
+.PP
+\fBFIELDTYPE *link_fieldtype(FIELDTYPE *\fItype1\fB,\fR
+                          \fBFIELDTYPE *\fItype2\fB);\fR
+.fi
 .SH DESCRIPTION
 .SS new_fieldtype
-The function \fBnew_fieldtype\fR creates a new field type usable for data
+The function \fBnew_fieldtype\fP creates a new field type usable for data
 validation.
 Its parameters are function pointers:
 .TP 5
-\fIfield_check\fR
+\fIfield_check\fP
 This function checks the
 validity of an entered data string whenever the user attempts to leave a field.
 It has two arguments:
@@ -77,51 +77,47 @@ The second argument is an
 argument-block structure, about which more below.
 .RE
 .TP 5
-\fIchar_check\fR
+\fIchar_check\fP
 This function validates input characters as they are entered.
 The form library passes it the character to be checked
 and a pointer to an argument-block structure.
 .SS free_fieldtype
-.PP
-The \fBfree_fieldtype\fR function
+The \fBfree_fieldtype\fP function
 frees the space allocated for a given validation type by \fBnew_fieldtype\fP.
 .SS set_fieldtype_arg
-.PP
-The function \fBset_fieldtype_arg\fR associates
+The function \fBset_fieldtype_arg\fP associates
 three storage-management functions with a field type:
 .TP 5
-\fImake_arg\fR
+\fImake_arg\fP
 This function is automatically applied to the
-list of arguments you give \fBset_field_type\fR when attaching validation
+list of arguments you give \fBset_field_type\fP when attaching validation
 to a field.
 It stores the arguments in an allocated argument-block
 object which is used when validating input.
 .TP 5
-\fIcopy_arg\fR
+\fIcopy_arg\fP
 This function may be used by applications to copy argument-blocks.
 .TP 5
-\fIfree_arg\fR
+\fIfree_arg\fP
 Frees an argument-block structure.
 .PP
-You must supply the \fImake_arg\fR function.
+You must supply the \fImake_arg\fP function.
 The other two are optional: you may supply NULL for them.
 In this case, the form library assumes
-that \fImake_arg\fR does not allocate memory but simply loads the
+that \fImake_arg\fP does not allocate memory but simply loads the
 argument into a single scalar value.
 .SS set_fieldtype_choice
-.PP
-The form driver requests \fBREQ_NEXT_CHOICE\fR and \fBREQ_PREV_CHOICE\fR assume
+The form driver requests \fBREQ_NEXT_CHOICE\fP and \fBREQ_PREV_CHOICE\fP assume
 that the possible values of a field form an ordered set, and provide the forms
 user with a way to move through the set.
 .PP
-The \fBset_fieldtype_choice\fR
+The \fBset_fieldtype_choice\fP
 function allows forms programmers to define successor and predecessor functions
 for the field type.
 These functions take the field pointer and an
 argument-block structure as arguments.
 .SS link_fieldtype
-.PP
-The function \fBlink_fieldtype\fR creates
+The function \fBlink_fieldtype\fP creates
 a new field type from the two given types.
 They are connected by an logical 'OR'.
 .SH RETURN VALUE
@@ -153,14 +149,7 @@ The field is already connected to a form.
 The field is the current field.
 .TP 5
 .B E_SYSTEM_ERROR
-System error occurred (see \fBerrno\fR(3)).
-.SH SEE ALSO
-\fBcurses\fR(3X),
-\fBform\fR(3X),
-\fBform_field_validation\fR(3X).
-.SH NOTES
-The header file \fB<form.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
+System error occurred (see \fBerrno\fP(3)).
 .SH PORTABILITY
 These routines emulate the System V forms library.
 They were not supported on
@@ -168,3 +157,7 @@ Version 7 or BSD versions.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%form\fP(3X),
+\fB\%form_field_validation\fP(3X)
diff --git a/contrib/ncurses/man/form_hook.3x b/contrib/ncurses/man/form_hook.3x
index e84aa972f4c2..d93d8d875cb0 100644
--- a/contrib/ncurses/man/form_hook.3x
+++ b/contrib/ncurses/man/form_hook.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2007,2010 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,57 +27,56 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: form_hook.3x,v 1.16 2020/10/18 00:06:29 tom Exp $
-.TH form_hook 3X ""
+.\" $Id: form_hook.3x,v 1.37 2024/03/16 15:35:01 tom Exp $
+.TH form_hook 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
-\fBform_hook\fR \- set hooks for automatic invocation by applications
+\fBform_hook\fP \-
+set hooks for automatic invocation by applications
 .SH SYNOPSIS
-\fB#include <form.h>\fR
-.sp
-\fBint set_field_init(FORM *\fP\fIform\fP\fB, Form_Hook \fP\fIfunc\fP\fB);\fP
-.br
-\fBForm_Hook field_init(const FORM *\fP\fIform\fP\fB);\fP
-.sp
-\fBint set_field_term(FORM *\fP\fIform\fP\fB, Form_Hook \fP\fIfunc\fP\fB);\fP
-.br
-\fBForm_Hook field_term(const FORM *\fP\fIform\fP\fB);\fP
-.sp
-\fBint set_form_init(FORM *\fP\fIform\fP\fB, Form_Hook \fP\fIfunc\fP\fB);\fP
-.br
-\fBForm_Hook form_init(const FORM *\fP\fIform\fP\fB);\fP
-.sp
-\fBint set_form_term(FORM *\fP\fIform\fP\fB, Form_Hook \fP\fIfunc\fP\fB);\fP
-.br
-\fBForm_Hook form_term(const FORM *\fP\fIform\fP\fB);\fP
-.br
+.nf
+\fB#include <form.h>
+.PP
+\fBint set_field_init(FORM *\fIform\fP, Form_Hook \fIfunc\fP);
+\fBForm_Hook field_init(const FORM *\fIform\fP);
+.PP
+\fBint set_field_term(FORM *\fIform\fP, Form_Hook \fIfunc\fP);
+\fBForm_Hook field_term(const FORM *\fIform\fP);
+.PP
+\fBint set_form_init(FORM *\fIform\fP, Form_Hook \fIfunc\fP);
+\fBForm_Hook form_init(const FORM *\fIform\fP);
+.PP
+\fBint set_form_term(FORM *\fIform\fP, Form_Hook \fIfunc\fP);
+\fBForm_Hook form_term(const FORM *\fIform\fP);
+.fi
 .SH DESCRIPTION
 These functions make it possible to set hook functions to be called at various
-points in the automatic processing of input event codes by \fBform_driver\fR.
-.PP
-The function \fBset_field_init\fR sets a hook to be called at form-post time
+points in the automatic processing of input event codes by \fBform_driver\fP.
+.SS set_field_init
+sets a hook to be called at form-post time
 and each time the selected field changes (after the change).
-\fBfield_init\fR
-returns the current field init hook, if any (\fBNULL\fR if there is no such
+.SS field_init
+returns the current field init hook, if any (\fBNULL\fP if there is no such
 hook).
-.PP
-The function \fBset_field_term\fR sets a hook to be called at form-unpost time
+.SS set_field_term
+sets a hook to be called at form-unpost time
 and each time the selected field changes (before the change).
-\fBfield_term\fR
-returns the current field term hook, if any (\fBNULL\fR if there is no such
+.SS field_term
+returns the current field term hook, if any (\fBNULL\fP if there is no such
 hook).
-.PP
-The function \fBset_form_init\fR sets a hook to be called at form-post time and
+.SS set_form_init
+sets a hook to be called at form-post time and
 just after a page change once it is posted.
-\fBform_init\fR returns the
-current form init hook, if any (\fBNULL\fR if there is no such hook).
-.PP
-The function \fBset_form_term\fR sets a hook to be called at form-unpost time
+.SS form_init
+returns the current form init hook,
+if any (\fBNULL\fP if there is no such hook).
+.SS set_form_term
+sets a hook to be called at form-unpost time
 and just before a page change once it is posted.
-\fBform_init\fR
-returns the current form term hook, if any (\fBNULL\fR if there is no such
+.SS form_term
+returns the current form term hook, if any (\fBNULL\fP if there is no such
 hook).
 .SH RETURN VALUE
-Routines that return pointers return \fBNULL\fR on error.
+Routines that return pointers return \fBNULL\fP on error.
 Other routines
 return one of the following:
 .TP 5
@@ -86,12 +84,7 @@ return one of the following:
 The routine succeeded.
 .TP 5
 .B E_SYSTEM_ERROR
-System error occurred (see \fBerrno\fR(3)).
-.SH SEE ALSO
-\fBcurses\fR(3X), \fBform\fR(3X).
-.SH NOTES
-The header file \fB<form.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
+System error occurred (see \fBerrno\fP(3)).
 .SH PORTABILITY
 These routines emulate the System V forms library.
 They were not supported on
@@ -99,3 +92,6 @@ Version 7 or BSD versions.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%form\fP(3X)
diff --git a/contrib/ncurses/man/form_new.3x b/contrib/ncurses/man/form_new.3x
index 47398174fad8..dc45e183f8aa 100644
--- a/contrib/ncurses/man/form_new.3x
+++ b/contrib/ncurses/man/form_new.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2015 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,26 +27,27 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: form_new.3x,v 1.15 2020/10/24 09:02:26 tom Exp $
-.TH form_new 3X ""
+.\" $Id: form_new.3x,v 1.32 2024/03/16 15:35:01 tom Exp $
+.TH form_new 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
-\fBnew_form\fR,
-\fBfree_form\fP \- create and destroy forms
+\fBnew_form\fP,
+\fBfree_form\fP \-
+create and destroy forms
 .SH SYNOPSIS
-\fB#include <form.h>\fR
-.sp
-\fBFORM *new_form(FIELD **\fP\fIfields\fP\fB);\fP
-.br
-\fBint free_form(FORM *\fP\fIform\fP\fB);\fP
-.br
+.nf
+\fB#include <form.h>
+.PP
+\fBFORM *new_form(FIELD **\fIfields\fP);
+\fBint free_form(FORM *\fIform\fP);
+.fi
 .SH DESCRIPTION
-The function \fBnew_form\fR creates a new form connected to a specified field
-pointer array (which must be \fBNULL\fR-terminated).
+The function \fBnew_form\fP creates a new form connected to a specified field
+pointer array (which must be \fBNULL\fP-terminated).
 .PP
-The function \fBfree_form\fR disconnects \fIform\fR from its field array
+The function \fBfree_form\fP disconnects \fIform\fP from its field array
 and frees the storage allocated for the form.
 .SH RETURN VALUE
-The function \fBnew_form\fR returns \fBNULL\fR on error.
+The function \fBnew_form\fP returns \fBNULL\fP on error.
 It sets \fBerrno\fP according to the function's success:
 .TP 5
 .B E_OK
@@ -62,7 +62,7 @@ The field is already connected to a form.
 .B E_SYSTEM_ERROR
 System error occurred, e.g., malloc failure.
 .PP
-The function \fBfree_form\fR returns one of the following:
+The function \fBfree_form\fP returns one of the following:
 .TP 5
 .B E_OK
 The routine succeeded.
@@ -72,11 +72,6 @@ Routine detected an incorrect or out-of-range argument.
 .TP 5
 .B E_POSTED
 The form has already been posted.
-.SH SEE ALSO
-\fBcurses\fR(3X), \fBform\fR(3X).
-.SH NOTES
-The header file \fB<form.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
 .SH PORTABILITY
 These routines emulate the System V forms library.
 They were not supported on
@@ -84,3 +79,6 @@ Version 7 or BSD versions.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%form\fP(3X)
diff --git a/contrib/ncurses/man/form_new_page.3x b/contrib/ncurses/man/form_new_page.3x
index 478688faffbe..c47a959d3b5a 100644
--- a/contrib/ncurses/man/form_new_page.3x
+++ b/contrib/ncurses/man/form_new_page.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2015 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,44 +27,45 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: form_new_page.3x,v 1.17 2020/10/18 00:04:36 tom Exp $
-.TH form_new_page 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: form_new_page.3x,v 1.34 2024/03/16 15:35:01 tom Exp $
+.TH form_new_page 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
 .SH NAME
-\fBset_new_page\fR,
-\fBnew_page\fR \- form pagination functions
+\fBset_new_page\fP,
+\fBnew_page\fP \-
+form pagination functions
 .SH SYNOPSIS
-\fB#include <form.h>\fR
-.sp
-\fBint set_new_page(FIELD *\fP\fIfield\fP\fB, bool \fP\fInew_page_flag\fP\fB);\fP
-.br
-\fBbool new_page(const FIELD *\fP\fIfield\fP\fB);\fP
-.br
+.nf
+\fB#include <form.h>
+.PP
+\fBint set_new_page(FIELD *\fIfield\fP, bool \fInew_page_flag\fP);
+\fBbool new_page(const FIELD *\fIfield\fP);
+.fi
 .SH DESCRIPTION
-The function \fBset_new_page\fR sets or resets a flag marking the given field
+The function \fBset_new_page\fP sets or resets a flag marking the given field
 as the beginning of a new page on its form.
 .PP
-The function \fBnew_page\fR is a predicate which tests if a given field marks
+The function \fBnew_page\fP is a predicate which tests if a given field marks
 a page beginning on its form.
 .SH RETURN VALUE
-The function \fBnew_page\fR returns \fBTRUE\fR or \fBFALSE\fR.
+The function \fBnew_page\fP returns \fBTRUE\fP or \fBFALSE\fP.
 .PP
-The function \fBset_new_page\fR returns one of the following:
+The function \fBset_new_page\fP returns one of the following:
 .TP 5
 .B E_OK
 The routine succeeded.
 .TP 5
 .B E_CONNECTED
 The given field is already connected to a form.
-.SH SEE ALSO
-\fBcurses\fR(3X) and related pages whose names begin \*(``form_\*('' for detailed
-descriptions of the entry points.
-.SH NOTES
-The header file \fB<form.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
 .SH PORTABILITY
 These routines emulate the System V forms library.
 They were not supported on
@@ -73,3 +73,6 @@ Version 7 or BSD versions.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X) and related pages whose names begin \*(``form_\*(''
+for detailed descriptions of the entry points.
diff --git a/contrib/ncurses/man/form_opts.3x b/contrib/ncurses/man/form_opts.3x
index db6c491eed73..74a36d2b3d8e 100644
--- a/contrib/ncurses/man/form_opts.3x
+++ b/contrib/ncurses/man/form_opts.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2015 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,58 +27,53 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: form_opts.3x,v 1.17 2020/10/18 00:03:49 tom Exp $
-.TH form_opts 3X ""
+.\" $Id: form_opts.3x,v 1.34 2024/03/16 15:35:01 tom Exp $
+.TH form_opts 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
 \fBset_form_opts\fP,
 \fBform_opts_on\fP,
 \fBform_opts_off\fP,
-\fBform_opts\fR \- set and get form options
+\fBform_opts\fP \-
+set and get form options
 .SH SYNOPSIS
-\fB#include <form.h>\fR
-.sp
-\fBint set_form_opts(FORM *\fP\fIform\fP\fB, Field_Options \fP\fIopts\fP\fB);\fP
-.br
-\fBField_Options form_opts(const FORM *\fP\fIform\fP\fB);\fP
-.sp
-\fBint form_opts_on(FORM *\fP\fIform\fP\fB, Field_Options \fP\fIopts\fP\fB);\fP
-.br
-\fBint form_opts_off(FORM *\fP\fIform\fP\fB, Field_Options \fP\fIopts\fP\fB);\fP
-.br
+.nf
+\fB#include <form.h>
+.PP
+\fBint set_form_opts(FORM *\fIform\fP, Field_Options \fIopts\fP);
+\fBField_Options form_opts(const FORM *\fIform\fP);
+.PP
+\fBint form_opts_on(FORM *\fIform\fP, Field_Options \fIopts\fP);
+\fBint form_opts_off(FORM *\fIform\fP, Field_Options \fIopts\fP);
+.fi
 .SH DESCRIPTION
-The function \fBset_form_opts\fR sets all the given form's option bits (form
+The function \fBset_form_opts\fP sets all the given form's option bits (form
 option bits may be logically-OR'ed together).
 .PP
-The function \fBform_opts_on\fR turns on the given option bits, and leaves
+The function \fBform_opts_on\fP turns on the given option bits, and leaves
 others alone.
 .PP
-The function \fBform_opts_off\fR turns off the given option bits, and leaves
+The function \fBform_opts_off\fP turns off the given option bits, and leaves
 others alone.
 .PP
-The function \fBform_opts\fR returns the form's current option bits.
+The function \fBform_opts\fP returns the form's current option bits.
 .PP
 The following options are defined (all are on by default):
 .TP 5
 O_NL_OVERLOAD
-Overload the \fBREQ_NEW_LINE\fR forms driver request so that calling it at the
+Overload the \fBREQ_NEW_LINE\fP forms driver request so that calling it at the
 end of a field goes to the next field.
 .TP 5
 O_BS_OVERLOAD
-Overload the \fBREQ_DEL_PREV\fR forms driver request so that calling it at the
+Overload the \fBREQ_DEL_PREV\fP forms driver request so that calling it at the
 beginning of a field goes to the previous field.
 .SH RETURN VALUE
-Except for \fBform_opts\fR, each routine returns one of the following:
+Except for \fBform_opts\fP, each routine returns one of the following:
 .TP 5
 .B E_OK
 The routine succeeded.
 .TP 5
 .B E_SYSTEM_ERROR
-System error occurred (see \fBerrno\fR(3)).
-.SH SEE ALSO
-\fBcurses\fR(3X), \fBform\fR(3X).
-.SH NOTES
-The header file \fB<form.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
+System error occurred (see \fBerrno\fP(3)).
 .SH PORTABILITY
 These routines emulate the System V forms library.
 They were not supported on
@@ -87,3 +81,6 @@ Version 7 or BSD versions.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%form\fP(3X)
diff --git a/contrib/ncurses/man/form_page.3x b/contrib/ncurses/man/form_page.3x
index da1c7254b646..fa538c620143 100644
--- a/contrib/ncurses/man/form_page.3x
+++ b/contrib/ncurses/man/form_page.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2016 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,44 +27,44 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: form_page.3x,v 1.19 2020/10/18 00:02:44 tom Exp $
-.TH form_page 3X ""
+.\" $Id: form_page.3x,v 1.37 2024/03/16 15:35:01 tom Exp $
+.TH form_page 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
-\fBform_page\fR \- set and get form page number
+\fBform_page\fP \-
+set and get form page number
 .SH SYNOPSIS
-\fB#include <form.h>\fR
-.sp
-\fBint set_current_field(FORM *\fP\fIform\fP\fB, FIELD *\fP\fIfield\fP\fB);\fP
-.br
-\fBFIELD *current_field(const FORM *\fP\fIform\fP\fB);\fP
-.sp
-\fBint unfocus_current_field(FORM *\fP\fIform\fP\fB);\fP
-.sp
-\fBint set_form_page(FORM *\fP\fIform\fP\fB, int \fP\fIn\fP\fB);\fP
-.br
-\fBint form_page(const FORM *\fP\fIform\fP\fB);\fP
-.sp
-\fBint field_index(const FIELD *\fP\fIfield\fP\fB);\fP
-.br
+.nf
+\fB#include <form.h>
+.PP
+\fBint set_current_field(FORM *\fIform\fP, FIELD *\fIfield\fP);
+\fBFIELD *current_field(const FORM *\fIform\fP);
+.PP
+\fBint unfocus_current_field(FORM *\fIform\fP);
+.PP
+\fBint set_form_page(FORM *\fIform\fP, int \fIn\fP);
+\fBint form_page(const FORM *\fIform\fP);
+.PP
+\fBint field_index(const FIELD *\fIfield\fP);
+.fi
 .SH DESCRIPTION
-The function \fBset_current_field\fR sets the current field of the given
-form; \fBcurrent_field\fR returns the current field of the given form.
+The function \fBset_current_field\fP sets the current field of the given
+form; \fBcurrent_field\fP returns the current field of the given form.
 .PP
-The function \fBunfocus_current_field\fR removes the focus from the current
+The function \fBunfocus_current_field\fP removes the focus from the current
 field of the form.
-In such state, inquiries via \fBcurrent_field\fR shall return a NULL pointer.
+In such state, inquiries via \fBcurrent_field\fP shall return a NULL pointer.
 .PP
-The function \fBset_form_page\fR sets the form's page number (goes to page
-\fIn\fR of the form).
+The function \fBset_form_page\fP sets the form's page number (goes to page
+\fIn\fP of the form).
 .PP
-The function \fBform_page\fR returns the form's current page number.
+The function \fBform_page\fP returns the form's current page number.
 .PP
-The function \fBfield_index\fR returns the index of the field in the
+The function \fBfield_index\fP returns the index of the field in the
 field array of the form it is connected to.
-It returns \fBERR\fR if
+It returns \fBERR\fP if
 the argument is the null pointer or the field is not connected.
 .SH RETURN VALUE
-Except for \fBform_page\fR, each routine returns one of the following:
+Except for \fBform_page\fP, each routine returns one of the following:
 .TP 5
 .B E_OK
 The routine succeeded.
@@ -83,19 +82,17 @@ Contents of a field are not valid.
 The form driver could not process the request.
 .TP 5
 .B E_SYSTEM_ERROR
-System error occurred (see \fBerrno\fR(3)).
-.
-.SH SEE ALSO
-\fBcurses\fR(3X), \fBform\fR(3X).
-.SH NOTES
-The header file \fB<form.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
+System error occurred (see \fBerrno\fP(3)).
 .SH PORTABILITY
 These routines emulate the System V forms library.
 They were not supported on
 Version 7 or BSD versions.
 .PP
-The \fBunfocus_current_field\fP function is an ncurses extension.
+The \fBunfocus_current_field\fP function is an \fI\%ncurses\fP
+extension.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%form\fP(3X)
diff --git a/contrib/ncurses/man/form_post.3x b/contrib/ncurses/man/form_post.3x
index c0e5baa5af28..77e086e4559d 100644
--- a/contrib/ncurses/man/form_post.3x
+++ b/contrib/ncurses/man/form_post.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2015,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,26 +27,27 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: form_post.3x,v 1.16 2020/10/18 00:01:05 tom Exp $
-.TH form_post 3X ""
+.\" $Id: form_post.3x,v 1.33 2024/03/16 15:35:01 tom Exp $
+.TH form_post 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
-\fBpost_form\fR,
-\fBunpost_form\fR \- write or erase forms from associated subwindows
+\fBpost_form\fP,
+\fBunpost_form\fP \-
+write or erase forms from associated subwindows
 .SH SYNOPSIS
-\fB#include <form.h>\fR
-.sp
-\fBint post_form(FORM *\fP\fIform\fP\fB);\fP
-.br
-\fBint unpost_form(FORM *\fP\fIform\fP\fB);\fP
-.br
+.nf
+\fB#include <form.h>
+.PP
+\fBint post_form(FORM *\fIform\fP);
+\fBint unpost_form(FORM *\fIform\fP);
+.fi
 .SH DESCRIPTION
-The function \fBpost_form\fR displays a form to its associated subwindow.
+The function \fBpost_form\fP displays a form to its associated subwindow.
 To trigger physical display of the subwindow,
-use \fBrefresh\fR(3X) or some equivalent
-\fBcurses\fR routine (the implicit \fBdoupdate\fR triggered by an \fBcurses\fR
+use \fBrefresh\fP(3X) or some equivalent
+\fBcurses\fP routine (the implicit \fBdoupdate\fP triggered by an \fBcurses\fP
 input request will do).
 .PP
-The function \fBunpost_form\fR erases form from its associated subwindow.
+The function \fBunpost_form\fP erases form from its associated subwindow.
 .SH RETURN VALUE
 These routines return one of the following:
 .TP 5
@@ -73,13 +73,7 @@ Form is too large for its window.
 The form has already been posted.
 .TP 5
 .B E_SYSTEM_ERROR
-System error occurred (see \fBerrno\fR(3)).
-.
-.SH SEE ALSO
-\fBcurses\fR(3X), \fBform\fR(3X).
-.SH NOTES
-The header file \fB<form.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
+System error occurred (see \fBerrno\fP(3)).
 .SH PORTABILITY
 These routines emulate the System V forms library.
 They were not supported on
@@ -87,3 +81,6 @@ Version 7 or BSD versions.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%form\fP(3X)
diff --git a/contrib/ncurses/man/form_requestname.3x b/contrib/ncurses/man/form_requestname.3x
index 11e5c0fb54f1..4075ea73c756 100644
--- a/contrib/ncurses/man/form_requestname.3x
+++ b/contrib/ncurses/man/form_requestname.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2015 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,39 +27,33 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: form_requestname.3x,v 1.16 2020/12/12 16:37:14 tom Exp $
-.TH form_requestname 3X ""
+.\" $Id: form_requestname.3x,v 1.35 2024/03/16 15:35:01 tom Exp $
+.TH form_requestname 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
 \fBform_request_by_name\fP,
-\fBform_request_name\fR \- handle printable form request names
+\fBform_request_name\fP \-
+handle printable form request names
 .SH SYNOPSIS
-\fB#include <form.h>\fR
-.sp
-\fBconst char *form_request_name(int \fP\fIrequest\fP\fB);\fP
-.br
-\fBint form_request_by_name(const char *\fP\fIname\fP\fB);\fP
-.br
+.nf
+\fB#include <form.h>
+.PP
+\fBconst char *form_request_name(int \fIrequest\fP);
+\fBint form_request_by_name(const char *\fIname\fP);
+.fi
 .SH DESCRIPTION
-.SS form_request_name
-The function \fBform_request_name\fR returns the printable name of a form
+The function \fBform_request_name\fP returns the printable name of a form
 request code.
-.SS form_request_name_by_name
-The function \fBform_request_by_name\fR searches in the name-table for a request
+The function \fBform_request_by_name\fP searches in the name-table for a request
 with the given name and returns its request code.
 Otherwise E_NO_MATCH is returned.
 .SH RETURN VALUE
-\fBform_request_name\fR returns \fBNULL\fR on error and sets \fBerrno\fP
-to \fBE_BAD_ARGUMENT\fR.
+\fBform_request_name\fP returns \fBNULL\fP on error and sets \fBerrno\fP
+to \fBE_BAD_ARGUMENT\fP.
 .PP
-\fBform_request_by_name\fR returns \fBE_NO_MATCH\fR on error.
+\fBform_request_by_name\fP returns \fBE_NO_MATCH\fP on error.
 It does not set \fBerrno\fP.
-.SH SEE ALSO
-\fBcurses\fR(3X), \fBform\fR(3X).
-.SH NOTES
-The header file \fB<form.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
 .SH PORTABILITY
-These routines are specific to ncurses.
+These routines are specific to \fI\%ncurses\fP.
 They were not supported on
 Version 7, BSD or System V implementations.
 It is recommended that
@@ -68,3 +61,6 @@ any code depending on them be conditioned using NCURSES_VERSION.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%form\fP(3X)
diff --git a/contrib/ncurses/man/form_userptr.3x b/contrib/ncurses/man/form_userptr.3x
index 5651a95f57e1..11c990c0030b 100644
--- a/contrib/ncurses/man/form_userptr.3x
+++ b/contrib/ncurses/man/form_userptr.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2015 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,32 +27,28 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: form_userptr.3x,v 1.19 2020/10/24 09:00:52 tom Exp $
-.TH form_userptr 3X ""
+.\" $Id: form_userptr.3x,v 1.36 2024/03/16 15:35:01 tom Exp $
+.TH form_userptr 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
 \fBset_form_userptr\fP,
-\fBform_userptr\fR \- associate application data with a form item
+\fBform_userptr\fP \-
+associate application data with a form item
 .SH SYNOPSIS
-\fB#include <form.h>\fR
-.sp
-\fBint set_form_userptr(FORM *\fP\fIform\fP\fB, void *\fP\fIuserptr\fP\fB);\fP
-.br
-\fBvoid* form_userptr(const FORM *\fP\fIform\fP\fB);\fP
-.br
+.nf
+\fB#include <form.h>
+.PP
+\fBint set_form_userptr(FORM *\fIform\fP, void *\fIuserptr\fP);
+\fBvoid* form_userptr(const FORM *\fIform\fP);
+.fi
 .SH DESCRIPTION
 Every form and every form item has a field that can be used to hold
 application-specific data (that is, the form-driver code leaves it alone).
 These functions get and set the form user pointer field.
 .SH RETURN VALUE
-The function \fBform_userptr\fR returns a pointer (which may be \fBNULL\fR).
+The function \fBform_userptr\fP returns a pointer (which may be \fBNULL\fP).
 It does not set \fBerrno\fP.
 .PP
-The function \fBset_form_userptr\fR returns \fBE_OK\fP (success).
-.SH SEE ALSO
-\fBcurses\fR(3X), \fBform\fR(3X).
-.SH NOTES
-The header file \fB<form.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
+The function \fBset_form_userptr\fP returns \fBE_OK\fP (success).
 .SH PORTABILITY
 These routines emulate the System V forms library.
 They were not supported on
@@ -64,3 +59,6 @@ We chose not to leave it as a char pointer for SVr4 compatibility.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%form\fP(3X)
diff --git a/contrib/ncurses/man/form_variables.3x b/contrib/ncurses/man/form_variables.3x
index 0419cb745c93..7b11a1ab77e8 100644
--- a/contrib/ncurses/man/form_variables.3x
+++ b/contrib/ncurses/man/form_variables.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2020 Thomas E. Dickey                                          *
+.\" Copyright 2020-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 2010-2013,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,32 +27,28 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: form_variables.3x,v 1.7 2020/12/12 14:45:16 tom Exp $
-.TH form_variables 3X ""
-.na
-.hy 0
+.\" $Id: form_variables.3x,v 1.18 2024/03/16 15:35:01 tom Exp $
+.TH form_variables 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
-\fBTYPE_ALNUM\fR,
-\fBTYPE_ALPHA\fR,
-\fBTYPE_ENUM\fR,
-\fBTYPE_INTEGER\fR,
-\fBTYPE_IPV4\fR,
-\fBTYPE_NUMERIC\fR,
-\fBTYPE_REGEXP\fR
-\- form system global variables
-.ad
-.hy
+\fB\%TYPE_ALNUM\fP,
+\fB\%TYPE_ALPHA\fP,
+\fB\%TYPE_ENUM\fP,
+\fB\%TYPE_INTEGER\fP,
+\fB\%TYPE_IPV4\fP,
+\fB\%TYPE_NUMERIC\fP,
+\fB\%TYPE_REGEXP\fP \-
+form system global variables
 .SH SYNOPSIS
 .nf
-\fB#include <form.h>\fR
+\fB#include <form.h>
 .PP
-\fBFIELDTYPE * TYPE_ALNUM;\fR
-\fBFIELDTYPE * TYPE_ALPHA;\fR
-\fBFIELDTYPE * TYPE_ENUM;\fR
-\fBFIELDTYPE * TYPE_INTEGER;\fR
-\fBFIELDTYPE * TYPE_IPV4;\fR
-\fBFIELDTYPE * TYPE_NUMERIC;\fR
-\fBFIELDTYPE * TYPE_REGEXP;\fR
+\fBFIELDTYPE * TYPE_ALNUM;
+\fBFIELDTYPE * TYPE_ALPHA;
+\fBFIELDTYPE * TYPE_ENUM;
+\fBFIELDTYPE * TYPE_INTEGER;
+\fBFIELDTYPE * TYPE_IPV4;
+\fBFIELDTYPE * TYPE_NUMERIC;
+\fBFIELDTYPE * TYPE_REGEXP;
 .fi
 .SH DESCRIPTION
 These are building blocks for the form library,
@@ -78,4 +74,4 @@ This holds a regular expression.
 The \fBTYPE_IPV4\fP variable is an extension not provided by older
 implementations of the form library.
 .SH SEE ALSO
-\fBform\fR(3X).
+\fB\%form\fP(3X)
diff --git a/contrib/ncurses/man/form_win.3x b/contrib/ncurses/man/form_win.3x
index 8d4a46da3559..4a75b294ce01 100644
--- a/contrib/ncurses/man/form_win.3x
+++ b/contrib/ncurses/man/form_win.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2006,2010 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,41 +27,41 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: form_win.3x,v 1.18 2020/10/18 00:00:32 tom Exp $
-.TH form_win 3X ""
+.\" $Id: form_win.3x,v 1.35 2024/03/16 15:35:01 tom Exp $
+.TH form_win 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
-\fBform_win\fR \- make and break form window and subwindow associations
+\fBform_win\fP \-
+make and break form window and subwindow associations
 .SH SYNOPSIS
-\fB#include <form.h>\fR
-.sp
-\fBint set_form_win(FORM *\fP\fIform\fP\fB, WINDOW *\fP\fIwin\fP\fB);\fP
-.br
-\fBWINDOW *form_win(const FORM *\fP\fIform\fP\fB);\fP
-.sp
-\fBint set_form_sub(FORM *\fP\fIform\fP\fB, WINDOW *\fP\fIsub\fP\fB);\fP
-.br
-\fBWINDOW *form_sub(const FORM *\fP\fIform\fP\fB);\fP
-.sp
-\fBint scale_form(const FORM *\fP\fIform\fP\fB, int *\fP\fIrows\fP\fB, int *\fP\fIcolumns\fP\fB);\fP
-.br
+.nf
+\fB#include <form.h>
+.PP
+\fBint set_form_win(FORM *\fIform\fP, WINDOW *\fIwin\fP);
+\fBWINDOW *form_win(const FORM *\fIform\fP);
+.PP
+\fBint set_form_sub(FORM *\fIform\fP, WINDOW *\fIsub\fP);
+\fBWINDOW *form_sub(const FORM *\fIform\fP);
+.PP
+\fBint scale_form(const FORM *\fIform\fP, int *\fIrows\fP, int *\fIcolumns\fP);
+.fi
 .SH DESCRIPTION
-Every form has an associated pair of \fBcurses\fR windows.
+Every form has an associated pair of \fBcurses\fP windows.
 The form window
 displays any title and border associated with the window; the form subwindow
 displays the items of the form that are currently available for selection.
 .PP
 The first four functions get and set those windows.
 It is not necessary to set
-either window; by default, the driver code uses \fBstdscr\fR for both.
+either window; by default, the driver code uses \fBstdscr\fP for both.
 .PP
-In the \fBset_\fR functions, window argument of \fBNULL\fR is treated as though
-it were \fBstsdcr\fR.  A form argument of \fBNULL\fR is treated as a request
+In the \fBset_\fP functions, window argument of \fBNULL\fP is treated as though
+it were \fBstsdcr\fP.  A form argument of \fBNULL\fP is treated as a request
 to change the system default form window or subwindow.
 .PP
-The function \fBscale_form\fR returns the minimum size required for the
-subwindow of \fIform\fR.
+The function \fBscale_form\fP returns the minimum size required for the
+subwindow of \fIform\fP.
 .SH RETURN VALUE
-Routines that return pointers return \fBNULL\fR on error.
+Routines that return pointers return \fBNULL\fP on error.
 Routines that return
 an integer return one of the following error codes:
 .TP 5
@@ -70,7 +69,7 @@ an integer return one of the following error codes:
 The routine succeeded.
 .TP 5
 .B E_SYSTEM_ERROR
-System error occurred (see \fBerrno\fR(3)).
+System error occurred (see \fBerrno\fP(3)).
 .TP 5
 .B E_BAD_ARGUMENT
 Routine detected an incorrect or out-of-range argument.
@@ -80,13 +79,6 @@ The form has already been posted.
 .TP 5
 .B E_NOT_CONNECTED
 No items are connected to the form.
-.SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_variables\fR(3X),
-\fBform\fR(3X).
-.SH NOTES
-The header file \fB<form.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
 .SH PORTABILITY
 These routines emulate the System V forms library.
 They were not supported on
@@ -94,3 +86,7 @@ Version 7 or BSD versions.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%curs_variables\fP(3X),
+\fB\%form\fP(3X)
diff --git a/contrib/ncurses/man/infocmp.1m b/contrib/ncurses/man/infocmp.1m
index 41a50a0c33fc..5f92c96dd63b 100644
--- a/contrib/ncurses/man/infocmp.1m
+++ b/contrib/ncurses/man/infocmp.1m
@@ -1,6 +1,6 @@
 '\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2017,2018 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,92 +28,88 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: infocmp.1m,v 1.77 2020/07/25 20:37:39 tom Exp $
-.TH @INFOCMP@ 1M ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
-.ds n 5
+.\" $Id: infocmp.1m,v 1.109 2024/03/16 15:35:01 tom Exp $
+.TH @INFOCMP@ 1M 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "User commands"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.ds '  \(aq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.ie t .ds '  \(aq
+.el   .ds '  '
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.de NS
-.ie n  .sp
-.el    .sp .5
-.ie n  .in +4
-.el    .in +2
-.nf
-.ft C			\" Courier
-..
-.de NE
-.fi
-.ft R
-.ie n  .in -4
-.el    .in -2
-..
+.
 .ds d @TERMINFO@
 .SH NAME
-\fB@INFOCMP@\fR \- compare or print out \fIterminfo\fR descriptions
+\fB@INFOCMP@\fP \-
+compare or print out \fIterminfo\fP descriptions
 .SH SYNOPSIS
-\fB@INFOCMP@\fR [\fB\-\
+\fB@INFOCMP@\fP [\fB\-\
 1\
+c\
 C\
+d\
 D\
+e\
 E\
 F\
+g\
 G\
+i\
 I\
 K\
-L\
-T\
-U\
-V\
-W\
-c\
-d\
-e\
-g\
-i\
 l\
+L\
 n\
 p\
 q\
 r\
 t\
+T\
 u\
+U\
+V\
+W\
 x\
-\fR]
-.br
-      [\fB\-v\fR \fIn\fR] [\fB\-s d\fR| \fBi\fR| \fBl\fR| \fBc\fR] [\fB\-Q\fR \fIn\fR] [\fB\-R \fR\fBsubset\fR]
-.br
-      [\fB\-w\fR\ \fIwidth\fR] [\fB\-A\fR\ \fIdirectory\fR] [\fB\-B\fR\ \fIdirectory\fR]
-.br
-      [\fItermname\fR...]
+\fP]
+      [\fB\-v\fR \fIn\fR] [\fB\-s d\fR| \fBi\fR| \fBl\fR| \fBc\fR] [\fB\-Q\fR \fIn\fR] [\fB\-R \fBsubset\fR]
+      [\fB\-w\fP\ \fIwidth\fP] [\fB\-A\fP\ \fIdirectory\fP] [\fB\-B\fP\ \fIdirectory\fP]
+      [\fIterminal-type\fP ...]
 .SH DESCRIPTION
-\fB@INFOCMP@\fR can be used to compare a binary \fBterminfo\fR entry with other
-terminfo entries, rewrite a \fBterminfo\fR description to take advantage of the
-\fBuse=\fR terminfo field, or print out a \fBterminfo\fR description from the
-binary file (\fBterm\fR) in a variety of formats.
-In all cases, the boolean
+\fB@INFOCMP@\fP can be used to compare a binary \fBterminfo\fP entry with other
+terminfo entries, rewrite a \fBterminfo\fP description to take advantage of the
+\fBuse=\fP terminfo field, or print out a \fBterminfo\fP description from the
+binary file (\fBterm\fP) in a variety of formats.
+In all cases, the Boolean
 fields will be printed first, followed by the numeric fields, followed by the
 string fields.
-.SS Default Options
-If no options are specified and zero or one \fItermnames\fR are specified, the
-\fB\-I\fR option will be assumed.
-If more than one \fItermname\fR is specified,
-the \fB\-d\fR option will be assumed.
-.SS Comparison Options [\-d] [\-c] [\-n]
-\fB@INFOCMP@\fR compares the \fBterminfo\fR description of the first terminal
-\fItermname\fR with each of the descriptions given by the entries for the other
-terminal's \fItermnames\fR.
+.SS "Default Options"
+If no options are specified and zero or one \fIterminal-types\fP are
+specified,
+the
+\fB\-I\fP option will be assumed.
+If more than one \fIterminal-type\fP is specified,
+the \fB\-d\fP option will be assumed.
+.SS "Comparison Options [\-d] [\-c] [\-n]"
+\fB@INFOCMP@\fP compares the \fBterminfo\fP description of the first terminal
+\fIterminal-type\fP with each of the descriptions given by the entries
+for the other terminal's \fIterminal-types\fP.
 If a capability is defined for only one of the
 terminals, the value returned depends on the type of the capability:
 .bP
-\fBF\fR for missing boolean variables
+\fBF\fP for missing Boolean variables
 .bP
-\fBNULL\fR for missing integer or string variables
+\fBNULL\fP for missing integer or string variables
 .PP
 Use the \fB\-q\fP option to show the distinction between
 \fIabsent\fP and \fIcancelled\fP capabilities.
@@ -121,24 +117,24 @@ Use the \fB\-q\fP option to show the distinction between
 These options produce a list which you can use to compare two
 or more terminal descriptions:
 .TP 5
-\fB\-d\fR
+\fB\-d\fP
 produces a list of each capability that is \fIdifferent\fP
 between two entries.
 Each item in the list shows \*(``:\*('' after the capability name,
 followed by the capability values, separated by a comma.
 .TP
-\fB\-c\fR
+\fB\-c\fP
 produces a list of each capability that is \fIcommon\fP between
 two or more entries.
 Missing capabilities are ignored.
 Each item in the list shows \*(``=\*('' after the capability name,
 followed by the capability value.
 .IP
-The \fB\-u\fR option provides a related output,
+The \fB\-u\fP option provides a related output,
 showing the first terminal description rewritten to use the second
 as a building block via the \*(``use=\*('' clause.
 .TP
-\fB\-n\fR
+\fB\-n\fP
 produces a list of each capability that is in \fInone\fP of the given entries.
 Each item in the list shows \*(``!\*('' before the capability name.
 .IP
@@ -146,30 +142,30 @@ Normally only the conventional capabilities are shown.
 Use the \fB\-x\fP option to add the BSD-compatibility
 capabilities (names prefixed with \*(``OT\*('').
 .IP
-If no \fItermnames\fR are given,
-\fB@INFOCMP@\fR uses the environment variable \fBTERM\fR
-for each of the \fItermnames\fR.
-.SS Source Listing Options [\-I] [\-L] [\-C] [\-r]
-The \fB\-I\fR, \fB\-L\fR, and \fB\-C\fR options will produce
+If no \fIterminal-types\fP are given,
+\fB@INFOCMP@\fP uses the environment variable \fITERM\fP
+for each of the \fIterminal-types\fP.
+.SS "Source Listing Options [\-I] [\-L] [\-C] [\-r]"
+The \fB\-I\fP, \fB\-L\fP, and \fB\-C\fP options will produce
 a source listing for each terminal named.
-.
+.PP
 .TS
-center tab(/) ;
-l l .
-\fB\-I\fR/use the \fBterminfo\fR names
-\fB\-L\fR/use the long C variable name listed in <\fBterm.h\fR>
-\fB\-C\fR/use the \fBtermcap\fR names
-\fB\-r\fR/when using \fB\-C\fR, put out all capabilities in \fBtermcap\fR form
-\fB\-K\fR/modifies the \fB\-C\fP option, improving BSD-compatibility.
+center;
+Lb L.
+\-I	use \fIterminfo\fP capability codes
+\-L	use \*(``long\*('' capability names
+\-C	use \fItermcap\fP capability codes
+\-r	with \fB\-C\fP, include nonstandard capabilities
+\-K	with \fB\-C\fP, improve BSD compatibility
 .TE
 .PP
-If no \fItermnames\fR are given, the environment variable \fBTERM\fR will be
-used for the terminal name.
+If no \fIterminal-types\fP are given,
+the environment variable \fITERM\fP will be used for the terminal name.
 .PP
-The source produced by the \fB\-C\fR option may be used directly as a
-\fBtermcap\fR entry, but not all parameterized strings can be changed to
-the \fBtermcap\fR format.
-\fB@INFOCMP@\fR will attempt to convert most of the
+The source produced by the \fB\-C\fP option may be used directly as a
+\fBtermcap\fP entry, but not all parameterized strings can be changed to
+the \fBtermcap\fP format.
+\fB@INFOCMP@\fP will attempt to convert most of the
 parameterized information, and anything not converted will be plainly marked in
 the output and commented out.
 These should be edited by hand.
@@ -185,108 +181,119 @@ More often however, you must help the termcap implementation,
 and trim excess whitespace (use the \fB\-0\fP option for that).
 .PP
 All padding information for strings will be collected together and placed
-at the beginning of the string where \fBtermcap\fR expects it.
+at the beginning of the string where \fBtermcap\fP expects it.
 Mandatory
 padding (padding information with a trailing \*(``/\*('') will become optional.
 .PP
-All \fBtermcap\fR variables no longer supported by \fBterminfo\fR, but which
-are derivable from other \fBterminfo\fR variables, will be output.
+All \fBtermcap\fP variables no longer supported by \fBterminfo\fP, but which
+are derivable from other \fBterminfo\fP variables, will be output.
 Not all
-\fBterminfo\fR capabilities will be translated; only those variables which were
-part of \fBtermcap\fR will normally be output.
-Specifying the \fB\-r\fR option
+\fBterminfo\fP capabilities will be translated; only those variables which were
+part of \fBtermcap\fP will normally be output.
+Specifying the \fB\-r\fP option
 will take off this restriction, allowing all capabilities to be output in
-\fItermcap\fR form.
+\fItermcap\fP form.
 Normally you would use both the \fB\-C\fP and \fB\-r\fP options.
 The actual format used incorporates some improvements for escaped characters
 from terminfo format.
-For a stricter BSD-compatible translation, use the \fB\-K\fR option
+For a stricter BSD-compatible translation, use the \fB\-K\fP option
 rather than \fB\-C\fP.
 .PP
 Note that because padding is collected to the beginning of the capability, not
 all capabilities are output.
 Mandatory padding is not supported.
 Because
-\fBtermcap\fR strings are not as flexible, it is not always possible to convert
-a \fBterminfo\fR string capability into an equivalent \fBtermcap\fR format.
-A subsequent conversion of the \fBtermcap\fR file
-back into \fBterminfo\fR format
-will not necessarily reproduce the original \fBterminfo\fR source.
+\fBtermcap\fP strings are not as flexible, it is not always possible to convert
+a \fBterminfo\fP string capability into an equivalent \fBtermcap\fP format.
+A subsequent conversion of the \fBtermcap\fP file
+back into \fBterminfo\fP format
+will not necessarily reproduce the original \fBterminfo\fP source.
 .PP
-Some common \fBterminfo\fR parameter sequences, their \fBtermcap\fR
+Some common \fBterminfo\fP parameter sequences, their \fBtermcap\fP
 equivalents, and some terminal types which commonly have such sequences, are:
-.
+.PP
 .TS
-center tab(/) ;
-l c l
-l l l.
-\fBterminfo/termcap\fR/Representative Terminals
-=
-\fB%p1%c/%.\fR/adm
-\fB%p1%d/%d\fR/hp, ANSI standard, vt100
-\fB%p1%'x'%+%c/%+x\fR/concept
-\fB%i/%i\fRq/ANSI standard, vt100
-\fB%p1%?%'x'%>%t%p1%'y'%+%;/%>xy\fR/concept
-\fB%p2\fR is printed before \fB%p1/%r\fR/hp
+center;
+Lf(BI) Lf(BI) L
+Lb     Lb     L.
+terminfo	termcap	Terminal Types
+_
+.\" ansi-m cup (adm3a has other stuff in between, more like concept)
+%p1%c	%.	ansi\-m
+.\" ansi cub, vt100 cub
+%p1%d	%d	ansi, vt100
+.\" vt52 cup (via vt52-basic)
+%p1%\*' \*'%+%c	%+x	vt52
+.\" ansi cup, vt100 cup
+%i	%iq	ansi, vt100
+.\" annarbor4080 cup
+%p1%?%\*'x\*'%>%t%p1%\*'y\*'%+%;	%>xy	annarbor4080
+.\" hpgeneric cup
+%p2\fR\|.\|.\|.\|\fP%p1	%r	hpgeneric
 .TE
-.SS Use= Option [\-u]
-The \fB\-u\fR option produces a \fBterminfo\fR source description of the first
-terminal \fItermname\fR which is relative to the sum of the descriptions given
-by the entries for the other terminals \fItermnames\fR.
+.SS "Use= Option [\-u]"
+The \fB\-u\fP option produces a \fBterminfo\fP source description of the first
+terminal \fIterminal-type\fP which is relative to the sum of the
+descriptions given by the entries for the other \fIterminal-types\fP.
 It does this by
-analyzing the differences between the first \fItermname\fR and the other
-\fItermnames\fR and producing a description with \fBuse=\fR fields for the
-other terminals.
+analyzing the differences between the first \fIterminal-types\fP and the
+other \fIterminal-types\fP and producing a description with \fBuse=\fP
+fields for the other terminals.
 In this manner, it is possible to retrofit generic terminfo
 entries into a terminal's description.
 Or, if two similar terminals exist, but
 were coded at different times or by different people so that each description
-is a full description, using \fB@INFOCMP@\fR
+is a full description, using \fB@INFOCMP@\fP
 will show what can be done to change
 one description to be relative to the other.
 .PP
 A capability will be printed with an at-sign (@) if it no longer exists in the
-first \fItermname\fR, but one of the other \fItermname\fR entries contains a
-value for it.
+first \fIterminal-type\fP,
+but one of the other \fIterminal-type\fP entries contains a value for
+it.
 A capability's value will be printed if the value in the first
-\fItermname\fR is not found in any of the other \fItermname\fR entries, or if
-the first of the other \fItermname\fR entries that has this capability gives a
-different value for the capability than that in the first \fItermname\fR.
+\fIterminal-type\fP is not found in any of the other \fIterminal-type\fP
+entries,
+or if the first of the other \fIterminal-type\fP entries that has this
+capability gives a different value for the capability than that in the
+first \fIterminal-type\fP.
 .PP
-The order of the other \fItermname\fR entries is significant.
+The order of the other \fIterminal-type\fP entries is significant.
 Since the
-terminfo compiler \fB@TIC@\fR does a left-to-right scan of the capabilities,
-specifying two \fBuse=\fR entries that contain differing entries for the same
+terminfo compiler \fB@TIC@\fP does a left-to-right scan of the capabilities,
+specifying two \fBuse=\fP entries that contain differing entries for the same
 capabilities will produce different results depending on the order that the
 entries are given in.
-\fB@INFOCMP@\fR will flag any such inconsistencies between
-the other \fItermname\fR entries as they are found.
+\fB@INFOCMP@\fP will flag any such inconsistencies between
+the other \fIterminal-type\fP entries as they are found.
 .PP
-Alternatively, specifying a capability \fIafter\fR a \fBuse=\fR entry that
+Alternatively, specifying a capability \fIafter\fP a \fBuse=\fP entry that
 contains that capability will cause the second specification to be ignored.
-Using \fB@INFOCMP@\fR to recreate a description can be a useful check to make
+Using \fB@INFOCMP@\fP to recreate a description can be a useful check to make
 sure that everything was specified correctly in the original source
 description.
 .PP
 Another error that does not cause incorrect compiled files, but will slow down
-the compilation time, is specifying extra \fBuse=\fR fields that are
+the compilation time, is specifying extra \fBuse=\fP fields that are
 superfluous.
-\fB@INFOCMP@\fR will flag any other \fItermname use=\fR fields that
+\fB@INFOCMP@\fP will flag any other \fIterminal-type use=\fP fields that
 were not needed.
-.SS Changing Databases [\-A \fIdirectory\fR] [\-B \fIdirectory\fR]
-Like other \fBncurses\fP utilities,
+.SS "Changing Databases [\-A \fIdirectory\fR] [\-B \fIdirectory\fR]"
+Like other \fI\%ncurses\fP utilities,
 \fB@INFOCMP@\fP looks for the terminal descriptions in several places.
-You can use the \fBTERMINFO\fP and \fBTERMINFO_DIRS\fP environment variables
-to override the compiled-in default list of places to search
-(see \fBcurses\fP(3X) for details).
+You can use the \fI\%TERMINFO\fP and \fI\%TERMINFO_DIRS\fP environment
+variables to override the compiled-in default list of places to search.
+See \fBcurses\fP(3X), as well as
+the \fIFetching Compiled Descriptions\fP section in \fBterminfo\fR(5).
 .PP
-You can also use the options \fB\-A\fR
-and \fB\-B\fR to override the list of places to search
+You can also use the options \fB\-A\fP
+and \fB\-B\fP to override the list of places to search
 when comparing terminal descriptions:
 .bP
-The \fB\-A\fR option sets the location for the first \fItermname\fR
+The \fB\-A\fP option sets the location for the first \fIterminal-type\fP
 .bP
-The \fB\-B\fR option sets the location for the other \fItermnames\fR.
+The \fB\-B\fP option sets the location for the other
+\fIterminal-types\fP.
 .PP
 Using these options, it is possible to
 compare descriptions for a terminal with the same name located in two different
@@ -294,46 +301,47 @@ databases.
 For instance,
 you can use this feature for comparing descriptions for the same terminal
 created by different people.
-.SS Other Options
+.SS "Other Options"
 .TP 5
-\fB\-0\fR
+\fB\-0\fP
 causes the fields to be printed on one line, without wrapping.
 .TP 5
-\fB\-1\fR
+\fB\-1\fP
 causes the fields to be printed out one to a line.
 Otherwise,
 the fields will be printed several to a line to a maximum width
 of 60 characters.
 .TP
-\fB\-a\fR
+\fB\-a\fP
 tells \fB@INFOCMP@\fP to retain commented-out capabilities
 rather than discarding them.
 Capabilities are commented by prefixing them with a period.
 .TP
-\fB\-D\fR
+\fB\-D\fP
 tells \fB@INFOCMP@\fP to print the database locations that it knows about,
 and exit.
 .TP 5
-\fB\-E\fR
+\fB\-E\fP
 Dump the capabilities of the given terminal as tables, needed in
 the C initializer for a
-TERMTYPE structure (the terminal capability structure in the \fB<term.h>\fR).
+TERMTYPE structure (the terminal capability structure in the \fB<term.h>\fP).
 This option is useful for preparing versions of the curses library hardwired
 for a given terminal type.
 The tables are all declared static, and are named according to the type
 and the name of the corresponding terminal entry.
 .sp
-Before ncurses 5.0, the split between the \fB\-e\fP and \fB\-E\fP
-options was not needed; but support for extended names required making
-the arrays of terminal capabilities separate from the TERMTYPE structure.
+Before \fI\%ncurses\fP 5.0,
+the split between the \fB\-e\fP and \fB\-E\fP options was not needed;
+but support for extended names required making the arrays of terminal
+capabilities separate from the TERMTYPE structure.
 .TP 5
-\fB\-e\fR
+\fB\-e\fP
 Dump the capabilities of the given terminal as a C initializer for a
-TERMTYPE structure (the terminal capability structure in the \fB<term.h>\fR).
+TERMTYPE structure (the terminal capability structure in the \fB<term.h>\fP).
 This option is useful for preparing versions of the curses library hardwired
 for a given terminal type.
 .TP 5
-\fB\-F\fR
+\fB\-F\fP
 compare terminfo files.
 This assumes that two following arguments are filenames.
 The files are searched for pairwise matches between
@@ -345,23 +353,23 @@ with exactly one match it includes a difference report.
 Normally,
 to reduce the volume of the report, use references are
 not resolved before looking for differences, but resolution can be forced
-by also specifying \fB\-r\fR.
+by also specifying \fB\-r\fP.
 .TP 5
-\fB\-f\fR
+\fB\-f\fP
 Display complex terminfo strings which contain if/then/else/endif expressions
 indented for readability.
 .TP 5
-\fB\-G\fR
+\fB\-G\fP
 Display constant literals in decimal form
 rather than their character equivalents.
 .TP 5
-\fB\-g\fR
+\fB\-g\fP
 Display constant character literals in quoted form
 rather than their decimal equivalents.
 .TP 5
-\fB\-i\fR
-Analyze the initialization (\fBis1\fR, \fBis2\fR, \fBis3\fR), and reset
-(\fBrs1\fR, \fBrs2\fR, \fBrs3\fR), strings in the entry,
+\fB\-i\fP
+Analyze the initialization (\fBis1\fP, \fBis2\fP, \fBis3\fP), and reset
+(\fBrs1\fP, \fBrs2\fP, \fBrs3\fP), strings in the entry,
 as well as those used for starting/stopping cursor-positioning mode
 (\fBsmcup\fP, \fBrmcup\fP) as well as starting/stopping keymap mode
 (\fBsmkx\fP, \fBrmkx\fP).
@@ -378,45 +386,45 @@ translated into {}-bracketed descriptions.
 .IP
 Here is a list of the DEC/ANSI
 special sequences recognized:
+.PP
 .TS
-center tab(/) ;
-l l
-l l.
-Action/Meaning
-=
-RIS/full reset
-SC/save cursor
-RC/restore cursor
-LL/home-down
-RSR/reset scroll region
-=
-DECSTR/soft reset (VT320)
-S7C1T/7-bit controls (VT220)
-=
-ISO DEC G0/enable DEC graphics for G0
-ISO UK G0/enable UK chars for G0
-ISO US G0/enable US chars for G0
-ISO DEC G1/enable DEC graphics for G1
-ISO UK G1/enable UK chars for G1
-ISO US G1/enable US chars for G1
-=
-DECPAM/application keypad mode
-DECPNM/normal keypad mode
-DECANSI/enter ANSI mode
-=
-ECMA[+\-]AM/keyboard action mode
-ECMA[+\-]IRM/insert replace mode
-ECMA[+\-]SRM/send receive mode
-ECMA[+\-]LNM/linefeed mode
-=
-DEC[+\-]CKM/application cursor keys
-DEC[+\-]ANM/set VT52 mode
-DEC[+\-]COLM/132-column mode
-DEC[+\-]SCLM/smooth scroll
-DEC[+\-]SCNM/reverse video mode
-DEC[+\-]OM/origin mode
-DEC[+\-]AWM/wraparound mode
-DEC[+\-]ARM/auto-repeat mode
+center;
+L L.
+Action	Meaning
+_
+RIS	full reset
+SC	save cursor
+RC	restore cursor
+LL	home-down
+RSR	reset scroll region
+_
+DECSTR	soft reset (VT320)
+S7C1T	7-bit controls (VT220)
+_
+ISO DEC G0	enable DEC graphics for G0
+ISO UK G0	enable UK chars for G0
+ISO US G0	enable US chars for G0
+ISO DEC G1	enable DEC graphics for G1
+ISO UK G1	enable UK chars for G1
+ISO US G1	enable US chars for G1
+_
+DECPAM	application keypad mode
+DECPNM	normal keypad mode
+DECANSI	enter ANSI mode
+_
+ECMA[+\-]AM	keyboard action mode
+ECMA[+\-]IRM	insert replace mode
+ECMA[+\-]SRM	send receive mode
+ECMA[+\-]LNM	linefeed mode
+_
+DEC[+\-]CKM	application cursor keys
+DEC[+\-]ANM	set VT52 mode
+DEC[+\-]COLM	132-column mode
+DEC[+\-]SCLM	smooth scroll
+DEC[+\-]SCNM	reverse video mode
+DEC[+\-]OM	origin mode
+DEC[+\-]AWM	wraparound mode
+DEC[+\-]ARM	auto-repeat mode
 .TE
 .sp
 It also recognizes a SGR action corresponding to ANSI/ISO 6429/ECMA Set
@@ -432,13 +440,13 @@ All but NORMAL may be prefixed with
 .IP
 An SGR0 designates an empty highlight sequence (equivalent to {SGR:NORMAL}).
 .TP 5
-\fB\-l\fR
+\fB\-l\fP
 Set output format to terminfo.
 .TP 5
-\fB\-p\fR
+\fB\-p\fP
 Ignore padding specifications when comparing strings.
 .TP 5
-\fB\-Q\fR \fIn\fR
+\fB\-Q\fP \fIn\fP
 Rather than show source in terminfo (text) format,
 print the compiled (binary) format in hexadecimal or base64 form,
 depending on the option's value:
@@ -455,12 +463,15 @@ hexadecimal and base64
 .RE
 .IP
 For example, this prints the compiled terminfo value as a string
-which could be assigned to the \fBTERMINFO\fP environment variable:
-.NS
-@INFOCMP@ -0 -q -Q2
-.NE
+which could be assigned to the \fI\%TERMINFO\fP environment variable:
+.PP
+.RS 9
+.EX
+@INFOCMP@ \-0 \-q \-Q2
+.EE
+.RE
 .TP 5
-\fB\-q\fR
+\fB\-q\fP
 This makes the output a little shorter:
 .RS
 .bP
@@ -473,94 +484,144 @@ However, show differences between absent and cancelled capabilities.
 Omit the \*(``Reconstructed from\*('' comment for source listings.
 .RE
 .TP 5
-\fB\-R\fR\fIsubset\fR
+\fB\-R\fIsubset\fR
 Restrict output to a given subset.
 This option is for use with archaic
-versions of terminfo like those on SVr1, Ultrix, or HP/UX that do not support
+versions of terminfo like those on SVr1, Ultrix, or HP-UX that do not support
 the full set of SVR4/XSI Curses terminfo; and variants such as AIX
 that have their own extensions incompatible with SVr4/XSI.
 .RS
 .bP
 Available terminfo
 subsets are \*(``SVr1\*('', \*(``Ultrix\*('', \*(``HP\*('', and \*(``AIX\*('';
-see \fBterminfo\fR(\*n) for details.
+see \fBterminfo\fP(5) for details.
 .bP
 You can also choose the subset \*(``BSD\*('' which selects only capabilities
 with termcap equivalents recognized by 4.4BSD.
-The \fB\-C\fP option sets the \*(``BSD\*('' subset as a side-effect.
 .bP
 If you select any other value for \fB\-R\fP,
 it is the same as no subset, i.e., all capabilities are used.
-The \fB\-I\fP option likewise selects no subset as a side-effect.
+.RE
+.IP
+A few options override the subset selected with \fB\-R\fP,
+if they are processed later in the command parameters:
+.RS
+.TP 5
+\fB\-C\fP
+sets the \*(``BSD\*('' subset as a side-effect.
+.TP 5
+\fB\-I\fP
+sets the subset to all capabilities.
+.TP 5
+\fB\-r\fP
+sets the subset to all capabilities.
 .RE
 .TP
-\fB\-s \fR\fI[d|i|l|c]\fR
-The \fB\-s\fR option sorts the fields within each type according to the argument
+\fB\-s \fI[d|i|l|c]\fR
+The \fB\-s\fP option sorts the fields within each type according to the argument
 below:
 .br
 .RS 5
 .TP 5
-\fBd\fR
-leave fields in the order that they are stored in the \fIterminfo\fR database.
+\fBd\fP
+leave fields in the order that they are stored in the \fIterminfo\fP database.
 .TP 5
-\fBi\fR
-sort by \fIterminfo\fR name.
+\fBi\fP
+sort by \fIterminfo\fP name.
 .TP 5
-\fBl\fR
+\fBl\fP
 sort by the long C variable name.
 .TP 5
-\fBc\fR
-sort by the \fItermcap\fR name.
+\fBc\fP
+sort by the \fItermcap\fP name.
 .RE
 .IP
-If the \fB\-s\fR option is not given, the fields printed out will be
-sorted alphabetically by the \fBterminfo\fR name within each type,
-except in the case of the \fB\-C\fR or the \fB\-L\fR options, which cause the
-sorting to be done by the \fBtermcap\fR name or the long C variable
+If the \fB\-s\fP option is not given, the fields printed out will be
+sorted alphabetically by the \fBterminfo\fP name within each type,
+except in the case of the \fB\-C\fP or the \fB\-L\fP options, which cause the
+sorting to be done by the \fBtermcap\fP name or the long C variable
 name, respectively.
 .TP 5
-\fB\-T\fR
+\fB\-T\fP
 eliminates size-restrictions on the generated text.
 This is mainly useful for testing and analysis, since the compiled
 descriptions are limited (e.g., 1023 for termcap, 4096 for terminfo).
 .TP
-\fB\-t\fR
+\fB\-t\fP
 tells \fB@TIC@\fP to discard commented-out capabilities.
 Normally when translating from terminfo to termcap,
 untranslatable capabilities are commented-out.
 .TP 5
-\fB\-U\fR
+\fB\-U\fP
 tells \fB@INFOCMP@\fP to not post-process the data
 after parsing the source file.
 This feature helps when comparing the actual contents of two source files,
 since it excludes the inferences that \fB@INFOCMP@\fP makes to fill in missing
 data.
 .TP 5
-\fB\-V\fR
-reports the version of ncurses which was used in this program, and exits.
+\fB\-V\fP
+reports the version of \fI\%ncurses\fP which was used in this program,
+and exits.
 .TP 5
-\fB\-v\fR \fIn\fR
+\fB\-v\fP \fIn\fP
 prints out tracing information on standard error as the program runs.
 .IP
-The optional parameter \fIn\fR is a number from 1 to 10, inclusive,
+The optional parameter \fIn\fP is a number from 1 to 10, inclusive,
 indicating the desired level of detail of information.
-If ncurses is built without tracing support, the optional parameter is ignored.
+If \fI\%ncurses\fP is built without tracing support,
+the optional parameter is ignored.
 .TP
-\fB\-W\fR
+\fB\-W\fP
 By itself, the \fB\-w\fP option will not force long strings to be wrapped.
 Use the \fB\-W\fP option to do this.
 .TP 5
-\fB\-w\fR \fIwidth\fR
-changes the output to \fIwidth\fR characters.
+\fB\-w\fP \fIwidth\fP
+changes the output to \fIwidth\fP characters.
 .TP
-\fB\-x\fR
-print information for user-defined capabilities (see \fBuser_caps(\*n)\fP.
+\fB\-x\fP
+print information for user-defined capabilities (see \fBuser_caps\fP(5).
 These are extensions to the terminfo repertoire which can be loaded
-using the \fB\-x\fR option of \fB@TIC@\fP.
+using the \fB\-x\fP option of \fB@TIC@\fP.
 .SH FILES
-.TP 20
-\*d
-Compiled terminal description database.
+.TP
+.I \*d
+compiled terminal description database
+.SH EXTENSIONS
+The
+\fB\-0\fP,
+\fB\-1\fP,
+\fB\-E\fP,
+\fB\-F\fP,
+\fB\-G\fP,
+\fB\-Q\fP,
+\fB\-R\fP,
+\fB\-T\fP,
+\fB\-V\fP,
+\fB\-a\fP,
+\fB\-e\fP,
+\fB\-f\fP,
+\fB\-g\fP,
+\fB\-i\fP,
+\fB\-l\fP,
+\fB\-p\fP,
+\fB\-q\fP and
+\fB\-t\fP
+options are not supported in SVr4 curses.
+.PP
+SVr4 infocmp does not distinguish between absent and cancelled capabilities.
+Also, it shows missing integer capabilities as \fB\-1\fP
+(the internal value used to represent missing integers).
+This implementation shows those as \*(``NULL\*('',
+for consistency with missing strings.
+.PP
+The \fB\-r\fP option's notion of \*(``termcap\*('' capabilities
+is System V Release 4's.
+Actual BSD curses versions will have a more restricted set.
+To see only the
+4.4BSD set, use \fB\-r\fP \fB\-RBSD\fP.
+.SH PORTABILITY
+X/Open Curses, Issue 7 (2009) provides a description of \fBinfocmp\fP.
+It does not mention the options used for converting to termcap format.
 .SH HISTORY
 Although System V Release 2 provided a terminfo library,
 it had no documented tool for decompiling the terminal descriptions.
@@ -568,13 +629,13 @@ Tony Hansen (AT&T) wrote the first \fBinfocmp\fP in early 1984,
 for System V Release 3.
 .PP
 Eric Raymond used the AT&T documentation in 1995 to provide an equivalent
-\fB@INFOCMP@\fP for ncurses.
+\fB@INFOCMP@\fP for \fI\%ncurses\fP.
 In addition, he added a few new features such as:
 .bP
 the \fB\-e\fP option, to support \fIfallback\fP
 (compiled-in) terminal descriptions
 .bP
-the \fB\-i\fP option, to help with analysis 
+the \fB\-i\fP option, to help with analysis
 .PP
 Later, Thomas Dickey added the \fB\-x\fP (user-defined capabilities)
 option, and the \fB\-E\fP option to support fallback entries with
@@ -583,62 +644,24 @@ user-defined capabilities.
 For a complete list, see the \fIEXTENSIONS\fP section.
 .PP
 In 2010, Roy Marples provided an \fBinfocmp\fP program for NetBSD.
-It is less capable than the SVr4 or ncurses versions
+It is less capable than the SVr4 or \fI\%ncurses\fP versions
 (e.g., it lacks the sorting options documented in X/Open),
-but does include the \fB\-x\fP option adapted from ncurses.
-.SH PORTABILITY
-X/Open Curses, Issue 7 (2009) provides a description of \fBinfocmp\fP.
-It does not mention the options used for converting to termcap format.
-.SH EXTENSIONS
-The
-\fB\-0\fR,
-\fB\-1\fR,
-\fB\-E\fR,
-\fB\-F\fR,
-\fB\-G\fR,
-\fB\-Q\fR,
-\fB\-R\fR,
-\fB\-T\fR,
-\fB\-V\fR,
-\fB\-a\fR,
-\fB\-e\fR,
-\fB\-f\fR,
-\fB\-g\fR,
-\fB\-i\fR,
-\fB\-l\fR,
-\fB\-p\fR,
-\fB\-q\fR and
-\fB\-t\fR
-options are not supported in SVr4 curses.
-.PP
-SVr4 infocmp does not distinguish between absent and cancelled capabilities.
-Also, it shows missing integer capabilities as \fB\-1\fP
-(the internal value used to represent missing integers).
-This implementation shows those as \*(``NULL\*('',
-for consistency with missing strings.
-.PP
-The \fB\-r\fR option's notion of \*(``termcap\*('' capabilities
-is System V Release 4's.
-Actual BSD curses versions will have a more restricted set.
-To see only the
-4.4BSD set, use \fB\-r\fR \fB\-RBSD\fR.
+but does include the \fB\-x\fP option adapted from \fI\%ncurses\fP.
 .SH BUGS
-The \fB\-F\fR option of \fB@INFOCMP@\fR(1M) should be a \fB@TOE@\fR(1M) mode.
-.SH SEE ALSO
-\fB@CAPTOINFO@\fR(1M),
-\fB@INFOTOCAP@\fR(1M),
-\fB@TIC@\fR(1M),
-\fB@TOE@\fR(1M),
-\fBcurses\fR(3X),
-\fBterminfo\fR(\*n).
-\fBuser_caps\fR(\*n).
-.sp
-https://invisible-island.net/ncurses/tctest.html
-.PP
-This describes \fBncurses\fR
-version @NCURSES_MAJOR@.@NCURSES_MINOR@ (patch @NCURSES_PATCH@).
-.SH AUTHOR
+The \fB\-F\fP option of \fB\%@INFOCMP@\fP(1M) should be a
+\fB\%@TOE@\fP(1M) mode.
+.SH AUTHORS
 Eric S. Raymond <esr@snark.thyrsus.com>
 and
 .br
-Thomas E. Dickey <dickey@invisible-island.net>
+Thomas E. Dickey <dickey@invisible\-island.net>
+.SH SEE ALSO
+\fB\%@CAPTOINFO@\fP(1M),
+\fB\%@INFOTOCAP@\fP(1M),
+\fB\%@TIC@\fP(1M),
+\fB\%@TOE@\fP(1M),
+\fB\%curses\fP(3X),
+\fB\%terminfo\fP(5),
+\fB\%user_caps\fP(5)
+.PP
+https://invisible\-island.net/ncurses/tctest.html
diff --git a/contrib/ncurses/man/infotocap.1m b/contrib/ncurses/man/infotocap.1m
index 2740b5598d18..0f0335d44603 100644
--- a/contrib/ncurses/man/infotocap.1m
+++ b/contrib/ncurses/man/infotocap.1m
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1999-2010,2016 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,54 +27,71 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: infotocap.1m,v 1.17 2020/12/19 21:49:52 tom Exp $
-.TH @INFOTOCAP@ 1M ""
-.ds n 5
+.\" $Id: infotocap.1m,v 1.41 2024/03/16 15:35:01 tom Exp $
+.TH @INFOTOCAP@ 1M 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "User commands"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .ds d @TERMINFO@
 .SH NAME
-\fB@INFOTOCAP@\fR \- convert a \fIterminfo\fR description into a \fItermcap\fR description
+\fB\%@INFOTOCAP@\fP \-
+convert a \fI\%terminfo\fR description into a \fI\%termcap\fR description
 .SH SYNOPSIS
-\fB@INFOTOCAP@\fR [\fB\-v\fR\fIn\fR \fIwidth\fR]  [\fB\-V\fR] [\fB\-1\fR] [\fB\-w\fR \fIwidth\fR] \fIfile\fR ...
+.B @INFOTOCAP@
+.RI [ tic-option ]
+.I file
+\&.\|.\|.
+.P
+.B "@INFOTOCAP@ \-V"
 .SH DESCRIPTION
-\fB@INFOTOCAP@\fR looks in each given text
-\fIfile\fR for \fBterminfo\fR descriptions.
-For each terminfo description found,
-an equivalent \fBtermcap\fR description is written to standard output.
-Terminfo \fBuse\fR capabilities are translated directly to termcap
-\fBtc\fR capabilities.
-.TP 5
-\fB\-v\fR
-print out tracing information on standard error as the program runs.
-.TP 5
-\fB\-V\fR
-print out the version of the program in use on standard error and exit.
-.TP 5
-\fB\-1\fR
-cause the fields to print out one to a line.
-Otherwise, the fields
-will be printed several to a line to a maximum width of 60 characters.
-.TP 5
-\fB\-w\fR
-change the output to \fIwidth\fR characters.
+\fB\%@INFOTOCAP@\fP translates terminal descriptions.
+It looks in each given text \fIfile\fP for \fI\%terminfo\fP entries and,
+For each one found,
+it writes an analogous \fI\%termcap\fP description to the standard
+output stream.
+\fI\%terminfo\fP \*(``\fBuse\fP\*('' capabilities translate to
+\fI\%termcap\fP \fBtc\fP capabilities.
+Because \fI\%termcap\fP is a less expressive format than
+\fI\%terminfo\fP,
+some capabilities cannot be translated.
+.PP
+This utility is implemented as a link to \fB\%@TIC@\fP(1M),
+with the latter's
+.B \-C
+option implied.
+You can use other \fB\%@TIC@\fP options such as
+.BR \-1 ,
+.BR \-f ,
+.BR \-v ,
+.BR \-w ,
+and
+.BR \-x .
+The \fB\-V\fP option reports the version of \fI\%ncurses\fP associated
+with this program and exits with a successful status.
 .SH FILES
-.TP 20
-\*d
-Compiled terminal description database.
-.SH NOTES
-This utility is actually a link to \fB@TIC@\fR, running in \fI\-C\fR mode.
-You can use other \fB@TIC@\fR options such as \fB\-f\fR and  \fB\-x\fR.
+.TP
+.I \*d
+compiled terminal description database
 .SH PORTABILITY
-None of X/Open Curses, Issue 7 (2009), SVr4 or NetBSD document this application.
-.SH SEE ALSO
-\fB@INFOCMP@\fR(1M),
-\fB@TIC@\fR(1M),
-\fBcurses\fR(3X),
-\fBterminfo\fR(\*n)
-.PP
-This describes \fBncurses\fR
-version @NCURSES_MAJOR@.@NCURSES_MINOR@ (patch @NCURSES_PATCH@).
-.SH AUTHOR
+None of X/Open Curses,
+Issue 7 (2009),
+SVr4,
+or NetBSD document this application.
+.SH AUTHORS
 Eric S. Raymond <esr@snark.thyrsus.com>
 and
 .br
-Thomas E. Dickey <dickey@invisible-island.net>
+Thomas E. Dickey <dickey@invisible\-island.net>
+.SH SEE ALSO
+\fB\%@INFOCMP@\fP(1M),
+\fB\%@TIC@\fP(1M),
+\fB\%curses\fP(3X),
+\fB\%terminfo\fP(5)
diff --git a/contrib/ncurses/man/key_defined.3x b/contrib/ncurses/man/key_defined.3x
index c66c54c22464..f0184aa77df1 100644
--- a/contrib/ncurses/man/key_defined.3x
+++ b/contrib/ncurses/man/key_defined.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 2003-2006,2010 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -29,16 +29,19 @@
 .\"
 .\" Author: Thomas E. Dickey 2003
 .\"
-.\" $Id: key_defined.3x,v 1.10 2020/10/17 23:39:03 tom Exp $
-.TH key_defined 3X ""
+.\" $Id: key_defined.3x,v 1.34 2024/03/16 15:35:01 tom Exp $
+.TH key_defined 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
-\fBkey_defined\fP \- check if a keycode is defined
+\fB\%key_defined\fP \-
+test whether a \fIcurses\fR keycode is defined
 .SH SYNOPSIS
-\fB#include <curses.h>\fP
-.sp
-\fBint key_defined(const char *\fP\fIdefinition\fP\fB);\fP
+.nf
+\fB#include <curses.h>
+.PP
+\fBint key_defined(const char *\fIdefinition\fP);
+.fi
 .SH DESCRIPTION
-This is an extension to the curses library.
+This is an extension to the \fIcurses\fP library.
 It permits an application to determine if a string is currently bound
 to any keycode.
 .SH RETURN VALUE
@@ -47,12 +50,12 @@ If no keycode is bound, zero is returned.
 If the string conflicts with longer strings
 which are bound to keys, \-1 is returned.
 .SH PORTABILITY
-These routines are specific to ncurses.
-They were not supported on
+This routine is specific to \fI\%ncurses\fP.
+It was not supported on
 Version 7, BSD or System V implementations.
 It is recommended that
-any code depending on them be conditioned using NCURSES_VERSION.
+any code depending on them be conditioned using \fB\%NCURSES_VERSION\fP.
+.SH AUTHORS
+Thomas Dickey
 .SH SEE ALSO
-\fBdefine_key\fR(3X).
-.SH AUTHOR
-Thomas Dickey.
+\fB\%define_key\fP(3X)
diff --git a/contrib/ncurses/man/keybound.3x b/contrib/ncurses/man/keybound.3x
index d9a069e80df2..bd8bb80f3c44 100644
--- a/contrib/ncurses/man/keybound.3x
+++ b/contrib/ncurses/man/keybound.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1999-2008,2010 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -29,33 +29,37 @@
 .\"
 .\" Author: Thomas E. Dickey 1999
 .\"
-.\" $Id: keybound.3x,v 1.11 2020/10/17 23:39:30 tom Exp $
-.TH keybound 3X ""
+.\" $Id: keybound.3x,v 1.36 2024/03/16 15:35:01 tom Exp $
+.TH keybound 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
-\fBkeybound\fP \- return definition of keycode
+\fB\%keybound\fP \-
+get definition of \fIcurses\fR keycode
 .SH SYNOPSIS
-\fB#include <curses.h>\fP
-.sp
-\fBchar * keybound(int \fP\fIkeycode\fP\fB, int \fP\fIcount);\fP
+.nf
+\fB#include <curses.h>
+.PP
+\fBchar * keybound(int \fIkeycode\fP, int \fIcount\fP);
+.fi
 .SH DESCRIPTION
-This is an extension to the curses library.
+This is an extension to the \fIcurses\fP library.
 It permits an application to determine the string which is defined
 in the terminfo for specific keycodes.
 .SH RETURN VALUE
-The \fIkeycode\fP parameter must be greater than zero, else NULL is returned.
-If it does not correspond to a defined key, then NULL is returned.
+The \fIkeycode\fP parameter must be greater than zero,
+else \fBNULL\fP is returned.
+If it does not correspond to a defined key, then \fBNULL\fP is returned.
 The \fIcount\fP parameter is used to allow the application to iterate
 through multiple definitions, counting from zero.
 When successful,
 the function returns a string which must be freed by the caller.
 .SH PORTABILITY
-These routines are specific to ncurses.
-They were not supported on
+This routine is specific to \fI\%ncurses\fP.
+It was not supported on
 Version 7, BSD or System V implementations.
 It is recommended that
-any code depending on them be conditioned using NCURSES_VERSION.
+any code depending on them be conditioned using \fB\%NCURSES_VERSION\fP.
+.SH AUTHORS
+Thomas Dickey
 .SH SEE ALSO
-\fBdefine_key\fR(3X),
-\fBkeyok\fR(3X).
-.SH AUTHOR
-Thomas Dickey.
+\fB\%define_key\fP(3X),
+\fB\%keyok\fP(3X)
diff --git a/contrib/ncurses/man/keyok.3x b/contrib/ncurses/man/keyok.3x
index 937450e57cfb..b4c7de2b4948 100644
--- a/contrib/ncurses/man/keyok.3x
+++ b/contrib/ncurses/man/keyok.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -29,18 +29,21 @@
 .\"
 .\" Author: Thomas E. Dickey 1997
 .\"
-.\" $Id: keyok.3x,v 1.15 2020/10/17 23:39:59 tom Exp $
-.TH keyok 3X ""
+.\" $Id: keyok.3x,v 1.40 2024/03/16 15:35:01 tom Exp $
+.TH keyok 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
-\fBkeyok\fP \- enable or disable a keycode
+\fB\%keyok\fP \-
+enable or disable a \fIcurses\fR keycode
 .SH SYNOPSIS
-\fB#include <curses.h>\fP
-.sp
-\fBint keyok(int \fP\fIkeycode\fP\fB, bool \fP\fIenable\fP\fB);\fP
+.nf
+\fB#include <curses.h>
+.PP
+\fBint keyok(int \fIkeycode\fP, bool \fIenable\fP);
+.fi
 .SH DESCRIPTION
-This is an extension to the curses library.
+This is an extension to the \fIcurses\fP library.
 It permits an application to disable specific keycodes, rather than
-use the \fIkeypad\fP function to disable all keycodes.
+use the \fB\%keypad\fP function to disable all keycodes.
 Keys that have been disabled can be re-enabled.
 .SH RETURN VALUE
 The keycode must be greater than zero, else \fBERR\fP is returned.
@@ -49,12 +52,12 @@ If the \fIenable\fP parameter is true, then the key must have been disabled,
 and vice versa.
 Otherwise, the function returns \fBOK\fP.
 .SH PORTABILITY
-These routines are specific to ncurses.
-They were not supported on
+This routine is specific to \fI\%ncurses\fP.
+It was not supported on
 Version 7, BSD or System V implementations.
 It is recommended that
-any code depending on them be conditioned using NCURSES_VERSION.
+any code depending on them be conditioned using \fB\%NCURSES_VERSION\fP.
+.SH AUTHORS
+Thomas Dickey
 .SH SEE ALSO
-\fBdefine_key\fR(3X).
-.SH AUTHOR
-Thomas Dickey.
+\fB\%define_key\fP(3X)
diff --git a/contrib/ncurses/man/legacy_coding.3x b/contrib/ncurses/man/legacy_coding.3x
index fa3181a88515..ccfdd5564bb9 100644
--- a/contrib/ncurses/man/legacy_coding.3x
+++ b/contrib/ncurses/man/legacy_coding.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2020 Thomas E. Dickey                                          *
+.\" Copyright 2020-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 2005-2016,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -29,47 +29,75 @@
 .\"
 .\" Author: Thomas E. Dickey
 .\"
-.\" $Id: legacy_coding.3x,v 1.8 2020/10/17 23:40:23 tom Exp $
-.TH legacy_coding 3X ""
+.\" $Id: legacy_coding.3x,v 1.28 2024/04/20 19:13:50 tom Exp $
+.TH legacy_coding 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
-\fBuse_legacy_coding\fR \- override locale-encoding checks
+\fB\%use_legacy_coding\fP \-
+override \fIcurses\fR locale encoding checks
 .SH SYNOPSIS
-\fB#include <curses.h>\fP
-.sp
-\fBint use_legacy_coding(int \fP\fIlevel\fP\fB);\fP
+.nf
+\fB#include <curses.h>
+.PP
+\fBint use_legacy_coding(int \fIlevel\fP);
+.fi
 .SH DESCRIPTION
-The \fBuse_legacy_coding\fP function is an extension to the curses library.
-It allows the caller to change the result of \fBunctrl\fP,
-and suppress related checks within the library that would normally
-cause nonprinting characters to be rendered in visible form.
-This affects only 8-bit characters.
+.B \%use_legacy_coding
+is an extension to the
+.I curses
+library.
+It allows the caller to change the result of \fB\%unctrl\fP(3X),
+suppressing \fI\%isprint\fP(3)-based checks within the library that
+would normally cause nonprinting characters to be rendered in visible
+form.
+The alteration affects only eight-bit characters.
 .PP
-The \fIlevel\fP parameter controls the result:
+The
+.I level
+parameter controls the result.
 .RS
 .TP 5
-0
-the library functions normally,
-rendering nonprinting characters as described in \fBunctrl\fP.
+.B 0
+The library functions normally,
+rendering nonprinting characters as described in \fB\%unctrl\fP(3X),
 .TP
-1
-the library ignores \fBisprintf\fP for codes in the range 160-255.
+.B 1
+the library ignores
+.I \%isprint
+for codes in the range 160-255.
 .TP
-2
-the library ignores \fBisprintf\fP for codes in the range 128-255.
-It also modifies the output of \fBunctrl\fP, showing codes in the
-range 128-159 as is.
+.B 2
+the library ignores
+.I \%isprint
+for codes in the range 128-255.
+It also modifies the output of \fB\%unctrl\fP(3X),
+showing codes in the range 128-159 as is.
 .RE
 .SH RETURN VALUE
 If the screen has not been initialized,
-or the \fIlevel\fP parameter is out of range,
-the function returns \fBERR\fP.
-Otherwise, it returns the previous level: \fB0\fP, \fB1\fP or \fB2\fP.
+or the
+.I level
+parameter is out of range,
+.B \%use_legacy_coding
+returns
+.BR ERR .
+Otherwise,
+it returns the previous level:
+.BR 0 ,
+.BR 1 ,
+or
+.BR 2 .
 .SH PORTABILITY
-This routine is specific to ncurses.
+.B \%use_legacy_coding
+is specific to
+.IR \%ncurses .
 It was not supported on Version 7, BSD or System V implementations.
-It is recommended that any code depending on ncurses extensions
-be conditioned using NCURSES_VERSION.
+Applications employing
+.I \%ncurses
+extensions should condition their use on the visibility of the
+.B \%NCURSES_VERSION
+preprocessor macro.
+.SH AUTHORS
+Thomas Dickey
+(to support \fI\%lynx\fP(1)'s font-switching feature).
 .SH SEE ALSO
-\fBunctrl\fR.
-.SH AUTHOR
-Thomas Dickey (to support lynx's font-switching feature).
+\fB\%unctrl\fP(3X)
diff --git a/contrib/ncurses/man/make_sed.sh b/contrib/ncurses/man/make_sed.sh
index 92e35eb27e60..ee7df41775e0 100755
--- a/contrib/ncurses/man/make_sed.sh
+++ b/contrib/ncurses/man/make_sed.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
-# $Id: make_sed.sh,v 1.11 2020/02/02 23:34:34 tom Exp $
+# $Id: make_sed.sh,v 1.19 2023/12/07 01:16:43 tom Exp $
 ##############################################################################
-# Copyright 2020 Thomas E. Dickey                                            #
+# Copyright 2020-2022,2023 Thomas E. Dickey                                  #
 # Copyright 1998-2005,2017 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -29,7 +29,7 @@
 # authorization.                                                             #
 ##############################################################################
 #
-# Author: Thomas E. Dickey 1997-2005
+# Author: Thomas E. Dickey 1997
 #
 # Construct a sed-script to perform renaming within man-pages.  Originally
 # written in much simpler form, this one accounts for the common cases of
@@ -46,8 +46,9 @@ UPPER=upper$$
 SCRIPT=script$$
 RESULT=result$$
 rm -f $UPPER $SCRIPT $RESULT
-trap "rm -f $COL.* $INPUT $UPPER $SCRIPT $RESULT" 0 1 2 3 15
-fgrep -v \# $1 | \
+trap "rm -f $COL.* $INPUT $UPPER $SCRIPT $RESULT; exit 1" 1 2 3 15
+trap "rm -f $COL.* $INPUT $UPPER $SCRIPT $RESULT" 0
+${FGREP-grep -F} -v \# "$1" | \
 sed	-e 's/[	][	]*/	/g' >$INPUT
 
 for F in 1 2 3 4
@@ -58,33 +59,37 @@ done
 for F in 2 4
 do
 	tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ <$COL.$F >$UPPER
-	mv $UPPER $COL.$F 
+	mv $UPPER $COL.$F
 done
 paste $COL.* | \
 sed	-e 's/^/s\/\\</' \
 	-e 's/$/\//' >$UPPER
 
-echo "# Do the TH lines" >>$RESULT
+{
+echo "# This script was generated from '$1' by man/make_sed.sh."
+echo "# Do the TH lines"
 sed	-e 's/\//\/TH /' \
 	-e 's/	/ /' \
-	-e 's/	/ ""\/TH /' \
+	-e 's/	/ \/TH /' \
 	-e 's/	/ /' \
-	-e 's/\/$/ ""\//' \
-	$UPPER >>$RESULT
+	-e 's/\/$/ \//' \
+	$UPPER
 
-echo "# Do the embedded references" >>$RESULT
-sed	-e 's/</<fB/' \
-	-e 's/	/\\\\fR(/' \
-	-e 's/	/)\/fB/' \
-	-e 's/	/\\\\fR(/' \
+echo "# Do the embedded references"
+sed	-e 's/</<fB\\(\\\\%\\)\\?/' \
+	-e 's/\\%</\\%/' \
+	-e 's/	/\\\\fP(/' \
+	-e 's/	/)\/fB\\\\%/' \
+	-e 's/	/\\\\fP(/' \
 	-e 's/\/$/)\//' \
-	$UPPER >>$RESULT
+	$UPPER
 
-echo "# Do the \fBxxx\fR references in the .NAME section" >>$RESULT
+echo '# Do the \\fBxxx\\fP references in the .NAME section'
 sed	-e 's/\\</^\\\\fB/' \
 	-e 's/	[^	]*	/\\\\f[RP] -\/\\\\fB/' \
-	-e 's/	.*$/\\\\fR -\//' \
-	$UPPER >>$RESULT
+	-e 's/	.*$/\\\\fP -\//' \
+	$UPPER
+} >>$RESULT
 
 # Finally, send the result to standard output
 cat $RESULT
diff --git a/contrib/ncurses/man/man_db.renames b/contrib/ncurses/man/man_db.renames.in
similarity index 62%
rename from contrib/ncurses/man/man_db.renames
rename to contrib/ncurses/man/man_db.renames.in
index fd4468312c7f..2b18a016eafc 100644
--- a/contrib/ncurses/man/man_db.renames
+++ b/contrib/ncurses/man/man_db.renames.in
@@ -1,5 +1,5 @@
 ##############################################################################
-# Copyright 2019,2020 Thomas E. Dickey                                       #
+# Copyright 2019-2023,2024 Thomas E. Dickey                                  #
 # Copyright 1998-2015,2017 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -26,7 +26,7 @@
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
-# $Id: man_db.renames,v 1.56 2020/02/02 23:34:34 tom Exp $
+# $Id: man_db.renames.in,v 1.73 2024/04/13 23:39:11 tom Exp $
 # Manual-page renamings for the man_db program
 #
 # Files:
@@ -151,7 +151,7 @@ mitem_value.3x			menu_value.3menu
 mitem_visible.3x		menu_visible.3menu
 ncurses.3x			ncurses.3ncurses
 new_pair.3x			new_pair.3ncurses
-panel.3x			panel.3curses
+panel.3x			panel.3ncurses
 printf.3s			printf.3
 putc.3s 			putc.3
 resizeterm.3x			resizeterm.3ncurses
@@ -163,7 +163,6 @@ term.5				term.5
 term.7				term.7
 term_variables.3x		terminfo_variables.3ncurses
 terminfo.5			terminfo.5
-terminfo.\\\*n			terminfo.5
 tic.1m				tic.1
 toe.1m				toe.1
 tput.1				tput.1
@@ -171,10 +170,125 @@ tset.1				tset.1
 user_caps.5			user_caps.5
 wresize.3x			wresize.3ncurses
 #
-# Other:
-tack.1m				tack.1
+# Supplementary topics in the foregoing pages:
+add_wch.3x			add_wch.3ncurses
+addch.3x			addch.3ncurses
+assume_default_colors.3x	assume_default_colors.3ncurses
+attr_get.3x			attr_get.3ncurses
+attr_on.3x			attr_on.3ncurses
+attron.3x			attron.3ncurses
+baudrate.3x			baudrate.3ncurses
+bkgd.3x				bkgd.3ncurses
+bkgrnd.3x			bkgrnd.3ncurses
+cbreak.3x			cbreak.3ncurses
+clearok.3x			clearok.3ncurses
+clrtoeol.3x			clrtoeol.3ncurses
+curs_set.3x			curs_set.3ncurses
+curscr.3x			curscr.3ncurses
+curses_trace.3x			curses_trace.3ncurses
+def_prog_mode.3x		def_prog_mode.3ncurses
+def_shell_mode.3x		def_shell_mode.3ncurses
+del_curterm.3x			del_curterm.3ncurses
+delay_output.3x			delay_output.3ncurses
+delscreen.3x			delscreen.3ncurses
+derwin.3x			derwin.3ncurses
+doupdate.3x			doupdate.3ncurses
+echo.3x				echo.3ncurses
+endwin.3x			endwin.3ncurses
+extended_slk_color.3x		extended_slk_color.3ncurses
+filter.3x			filter.3ncurses
+flushinp.3x			flushinp.3ncurses
+get_wch.3x			get_wch.3ncurses
+getattr.3x			getattr.3ncurses
+getcchar.3x			getcchar.3ncurses
+getch.3x			getch.3ncurses
+getwin.3x			getwin.3ncurses
+halfdelay.3x			halfdelay.3ncurses
+has_key.3x			has_key.3ncurses
+idcok.3x			idcok.3ncurses
+idlok.3x			idlok.3ncurses
+immedok.3x			immedok.3ncurses
+in_wch.3x			in_wch.3ncurses
+inch.3x				inch.3ncurses
+initscr.3x			initscr.3ncurses
+is_scrollok.3x			is_scrollok.3ncurses
+keyname.3x			keyname.3ncurses
+keypad.3x			keypad.3ncurses
+leaveok.3x			leaveok.3ncurses
+longname.3x			longname.3ncurses
+meta.3x				meta.3ncurses
+move.3x				move.3ncurses
+mvcur.3x			mvcur.3ncurses
+mvwin.3x			mvwin.3ncurses
+newpad.3x			newpad.3ncurses
+newterm.3x			newterm.3ncurses
+newwin.3x			newwin.3ncurses
+nl.3x				nl.3ncurses
+nocbreak.3x			nocbreak.3ncurses
+nodelay.3x			nodelay.3ncurses
+nonl.3x				nonl.3ncurses
+notimeout.3x			notimeout.3ncurses
+pnoutrefresh.3x			pnoutrefresh.3ncurses
+prefresh.3x			prefresh.3ncurses
+printw.3x			printw.3ncurses
+putp.3x			putp.3ncurses
+putwin.3x			putwin.3ncurses
+raw.3x				raw.3ncurses
+refresh.3x			refresh.3ncurses
+reset_shell_mode.3x		reset_shell_mode.3ncurses
+restartterm.3x			restartterm.3ncurses
+ripoffline.3x			ripoffline.3ncurses
+scrollok.3x			scrollok.3ncurses
+set_curterm.3x			set_curterm.3ncurses
+set_term.3x			set_term.3nses
+setcchar.3x			setcchar.3ncurses
+setupterm.3x			setupterm.3ncurses
+slk_attr.3x			slk_attr.3ncurses
+slk_color.3x			slk_color.3ncurses
+slk_init.3x			slk_init.3ncurses
+slk_touch.3x			slk_touch.3ncurses
+start_color.3x			start_color.3ncurses
+subwin.3x			subwin.3ncurses
+syncok.3x			syncok.3ncurses
+terminfo.3x			terminfo.3ncurses
+tigetstr.3x			tigetstr.3ncurses
+touchline.3x			touchline.3ncurses
+touchwin.3x			touchwin.3ncurses
+tparm.3x			tparm.3ncurses
+tputs.3x			tputs.3ncurses
+trace.3x			trace.3ncurses
+unctrl.3x			unctrl.3ncurses
+use_default_colors.3x		use_default_colors.3ncurses
+use_env.3x			use_env.3ncurses
+use_extended_names.3x		use_extended_names.3ncurses
+use_legacy_coding.3x		use_legacy_coding.3ncurses
+use_tioctl.3x			use_tioctl.3ncurses
+vidputs.3x			vidputs.3ncurses
+wadd_wch.3x			wadd_wch.3ncurses
+waddch.3x			waddch.3ncurses
+waddstr.3x			waddstr.3ncurses
+waddwstr.3x			waddwstr.3ncurses
+wattr_set.3x			wattr_set.3ncurses
+wattrset.3x			wattrset.3ncurses
+wbkgdset.3x			wbkgdset.3ncurses
+wbkgrndset.3x			wbkgrndset.3ncurses
+wdelch.3x			wdelch.3ncurses
+wecho_wchar.3x			wecho_wchar.3ncurses
+wechochar.3x			wechochar.3ncurses
+wget_wch.3x			wget_wch.3ncurses
+wgetch.3x			wgetch.3ncurses
+wgetstr.3x			wgetstr.3ncurses
+winch.3x			winch.3ncurses
+wins_wch.3x			wins_wch.3ncurses
+winsch.3x			winsch.3ncurses
+wmove.3x			wmove.3ncurses
+wnoutrefresh.3x			wnoutrefresh.3ncurses
+wrefresh.3x			wrefresh.3ncurses
+wsetscrreg.3x			wsetscrreg.3ncurses
+wtimeout.3x			wtimeout.3ncurses
 #
-getty.1				getty.8
+# Other:
+getty.8				getty.8
 scanf.3				scanf.3
 ttys.5				ttys.4
 system.3			system.3
@@ -183,18 +297,7 @@ regexec.3x			regexec.3
 vprintf.3			vprintf.3
 #
 # The following are pages which may be generated depending on configuration:
-adacurses-config.1		adacurses-config.1
-adacurses5-config.1		adacurses5-config.1
-adacurses6-config.1		adacurses6-config.1
-#
-ncurses5-config.1		ncurses5-config.1
-ncursesw5-config.1		ncursesw5-config.1
-ncursest5-config.1		ncursest5-config.1
-ncursestw5-config.1		ncursestw5-config.1
-#
-ncurses6-config.1		ncurses6-config.1
-ncursesw6-config.1		ncursesw6-config.1
-ncursest6-config.1		ncursest6-config.1
-ncursestw6-config.1		ncursestw6-config.1
+adacurses@USE_CFG_SUFFIX@-config.1	adacurses@USE_CFG_SUFFIX@-config.1
+ncurses@USE_CFG_SUFFIX@-config.1	ncurses@USE_CFG_SUFFIX@-config.1
 #
 # vile:cfgmode
diff --git a/contrib/ncurses/man/manhtml.aliases b/contrib/ncurses/man/manhtml.aliases
index a9f18ca70693..7599c74a8a27 100644
--- a/contrib/ncurses/man/manhtml.aliases
+++ b/contrib/ncurses/man/manhtml.aliases
@@ -1,6 +1,6 @@
-# $Id: manhtml.aliases,v 1.19 2020/12/12 14:45:55 tom Exp $
+# $Id: manhtml.aliases,v 1.35 2024/04/14 00:36:21 tom Exp $
 #***************************************************************************
-# Copyright 2019,2020 Thomas E. Dickey                                     *
+# Copyright 2019-2023,2024 Thomas E. Dickey                                *
 # Copyright 2013,2017 Free Software Foundation, Inc.                       *
 #                                                                          *
 # Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,42 +28,106 @@
 # authorization.                                                           *
 #***************************************************************************
 # Items in this list will be linked to the corresponding manpages by man2html
+add_wch(3X)		curs_add_wch(3X)
 addch(3X)		curs_addch(3X)
 assume_default_colors(3X)	default_colors(3X)
+attr_get(3X)		curs_attr(3X)
+attr_on(3X)		curs_attr(3X)
+attron(3X)		curs_attr(3X)
+baudrate(3X)		curs_termattrs(3X)
+bkgd(3X)		curs_bkgd(3X)
+bkgrnd(3X)		curs_bkgrnd(3X)
+cbreak(3X)		curs_inopts(3X)
+clearok(3X)		curs_outopts(3X)
+clrtoeol(3X)		curs_clear(3X)
 curs_set(3X)		curs_kernel(3X)
+curscr(3X)		curs_variables(3X)
+curses_trace(3X)	curs_trace(3X)
+def_prog_mode(3X)	curs_kernel(3X)
+def_shell_mode(3X)	curs_kernel(3X)
+del_curterm(3X)		curs_terminfo(3X)
+delay_output(3X)	curs_util(3X)
 delscreen(3X)		curs_initscr(3X)
 doupdate(3X)		curs_refresh(3X)
+echo(3X)		curs_inopts(3X)
 endwin(3X)		curs_initscr(3X)
+extended_slk_color(3X)	curs_slk(3X)
 filter(3X)		curs_util(3X)
+flushinp(3X)		curs_util(3X)
 get_wch(3X)		curs_get_wch(3X)
 getcchar(3X)		curs_getcchar(3X)
 getch(3X)		curs_getch(3X)
+getwin(3X)		curs_util(3X)
+halfdelay(3X)		curs_inopts(3X)
+has_key(3X)		curs_getch(3X)
+immedok(3X)		curs_outopts(3X)
+in_wch(3X)		curs_in_wch(3X)
 inch(3X)		curs_inch(3X)
 infocmp(1)		infocmp(1M)
 initscr(3X)		curs_initscr(3X)
 is_scrollok(3X)		curs_opaque(3X)
+keyname(3X)		curs_util(3X)
 keypad(3X)		curs_inopts(3X)
 longname(3X)		curs_termattrs(3X)
 meta(3X)		curs_inopts(3X)
+move(3X)		curs_move(3X)
 mvcur(3X)		curs_terminfo(3X)
 mvwin(3X)		curs_window(3X)
 newterm(3X)		curs_initscr(3X)
+newwin(3X)		curs_window(3X)
+nl(3X)			curs_inopts(3X)
+nocbreak(3X)		curs_inopts(3X)
+nonl(3X)		curs_inopts(3X)
+pnoutrefresh(3X)	curs_pad(3X)
+prefresh(3X)		curs_pad(3X)
+printw(3X)		curs_printw(3X)
+putp(3X)		curs_terminfo(3X)
+putwin(3X)		curs_util(3X)
+raw(3X)			curs_inopts(3X)
 refresh(3X)		curs_refresh(3X)
 reset_shell_mode(3X)	curs_kernel(3X)
+restartterm(3X)		curs_terminfo(3X)
+ripoffline(3X)		curs_kernel(3X)
+set_curterm(3X)		curs_terminfo(3X)
 set_term(3X)		curs_initscr(3X)
 setcchar(3X)		curs_getcchar(3X)
 setupterm(3X)		curs_terminfo(3X)
+slk_attr(3X)		curs_slk(3X)
+slk_color(3X)		curs_slk(3X)
 slk_init(3X)		curs_slk(3X)
 slk_touch(3X)		curs_slk(3X)
+start_color(3X)		curs_color(3X)
+terminfo(3X)		curs_terminfo(3X)
 tic(1)			tic(1M)
 tigetstr(3X)		curs_terminfo(3X)
+touchline(3X)		curs_touch(3X)
+touchwin(3X)		curs_touch(3X)
 tparm(3X)		curs_terminfo(3X)
 tputs(3X)		curs_terminfo(3X)
 use_default_colors(3X)	default_colors(3X)
 use_env(3X)		curs_util(3X)
 use_extended_names(3X)	curs_extend(3X)
 use_legacy_coding(3X)	legacy_coding(3X)
+use_tioctl(3X)		curs_util(3X)
 vidputs(3X)		curs_terminfo(3X)
+wadd_wch(3X)		curs_add_wch(3X)
+waddch(3X)		curs_addch(3X)
+waddstr(3X)		curs_addstr(3X)
+waddwstr(3X)		curs_addwstr(3X)
+wattr_set(3X)		curs_attr(3X)
+wattrset(3X)		curs_attr(3X)
+wbkgdset(3X)		curs_bkgd(3X)
+wbkgrndset(3X)		curs_bkgrnd(3X)
+wdelch(3X)		curs_delch(3X)
+wecho_wchar(3X)		curs_add_wch(3X)
+wechochar(3X)		curs_addch(3X)
+wget_wch(3X)		curs_get_wch(3X)
 wgetch(3X)		curs_getch(3X)
+wgetstr(3X)		curs_getstr(3X)
+winch(3X)		curs_inch(3X)
+wins_wch(3X)		curs_ins_wch(3X)
+winsch(3X)		curs_insch(3X)
+wmove(3X)		curs_move(3X)
 wnoutrefresh(3X)	curs_refresh(3X)
 wrefresh(3X)		curs_refresh(3X)
+wsetscrreg(3X)		curs_outopts(3X)
diff --git a/contrib/ncurses/man/manhtml.externs b/contrib/ncurses/man/manhtml.externs
index 8787b2ce1778..41aa6359df10 100644
--- a/contrib/ncurses/man/manhtml.externs
+++ b/contrib/ncurses/man/manhtml.externs
@@ -1,7 +1,7 @@
-# $Id: manhtml.externs,v 1.14 2020/04/18 09:48:50 tom Exp $
+# $Id: manhtml.externs,v 1.25 2024/04/20 19:26:05 tom Exp $
 # Items in this list will not be linked by man2html
 #***************************************************************************
-# Copyright 2019,2020 Thomas E. Dickey                                     *
+# Copyright 2019-2023,2024 Thomas E. Dickey                                *
 # Copyright 2013,2017 Free Software Foundation, Inc.                       *
 #                                                                          *
 # Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,40 +28,56 @@
 # sale, use or other dealings in this Software without prior written       *
 # authorization.                                                           *
 #***************************************************************************
-ADACURSES(1)
 COLOR_PAIR(1)
 COLOR_PAIR(2)
-COLOR_PAIR(3)
+ascii(7)
 atoi(3)
+bash(1)
 conflict(1)
+cron(1)
 csh(1)
 ded(1)
+emacs(1)
 environ(7)
 errno(3)
 file(1)
-getty(1)
+getty(8)
+jove(1)
 lynx(1)
-nvi(1)
 mutt(1)
+nvi(1)
 od(1)
+ioctl(2)
+isprint(3)
 printf(3)
 profile(5)
 putc(3)
 putchar(3)
 putwc(3)
 read(2)
+readline(3)
+resize(1)
 scanf(3)
+scanf(3S)
 screen(1)
+setbuf(3)
+setgid(2)
+setlocale(3)
+setuid(2)
 sh(1)
 sscanf(3)
 stdio(3)
 stty(1)
+swprintf(3)
 system(3)
 termios(3)
 tmux(1)
 tty(4)
 ttys(5)
+vi(1)
 vprintf(3)
 vscanf(3)
+vsscanf(3)
 wcwidth(3)
 write(2)
+xterm(1)
diff --git a/contrib/ncurses/man/manlinks.sed b/contrib/ncurses/man/manlinks.sed
index 09b055f2fa04..6e2d2b869970 100644
--- a/contrib/ncurses/man/manlinks.sed
+++ b/contrib/ncurses/man/manlinks.sed
@@ -1,6 +1,6 @@
-# $Id: manlinks.sed,v 1.15 2021/01/05 20:30:00 tom Exp $
+# $Id: manlinks.sed,v 1.21 2024/04/20 22:25:36 tom Exp $
 ##############################################################################
-# Copyright 2020,2021 Thomas E. Dickey                                       #
+# Copyright 2020-2023,2024 Thomas E. Dickey                                  #
 # Copyright 2000-2003,2008 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -31,6 +31,9 @@
 # listed in the "NAME" section, i.e., the names that we would like to use
 # as aliases for the manpage -T.Dickey
 #
+# workaround for manpages without a SYNOPSIS
+s/^\.\\"SH/.SH/
+#
 # eliminate formatting controls that get in the way
 /^'\\"/d
 /\.\\"/d
@@ -39,12 +42,13 @@
 /typedef/d
 s/^\.IX//
 s/\\f.//g
+s/\\%//g
 s/[:,]/ /g
 #
 # ignore C-style comments
 s%/\*.*\*/%%
 #
-# eliminate unnecessary whitespace, convert multiple blanks to single space
+# Eliminate unnecessary whitespace, convert multiple blanks to single space.
 s/^[ 	][ 	]*//
 s/[ 	][ 	]*$//
 s/[ 	][ 	]*/ /g
@@ -54,16 +58,16 @@ s/[ 	][ 	]*/ /g
 s/\.SH[ 	][ 	]*/.SH_(/
 #
 # in ".SH NAME"
-# change "\-" to "-", eliminate text after "-", and split the remaining lines
-# at each space, making a list of names:
-/^\.SH_(NAME/,/^\.SH_(SYNOPSIS/{
-s/\\-.*/ -/
-/ -/{
-s/ -.*//
-s/ /\
-/g
-}
-/^-/{
+# Convert a list of names separated from their description by " \-" to a list
+# of names on separate lines.  Normally the list is also comma-separated, but
+# we ignore that detail here.  The description is on a separate line to make
+# the nroff source more pleasing to some eyes.
+/^\.SH_(NAME/,/ \\-$/{
+s/\\-/-/g
+s/  / /g
+/ -$/{
+s/ -$//
+n
 d
 }
 s/ /\
@@ -71,10 +75,16 @@ s/ /\
 }
 #
 # in ".SH SYNOPSIS"
-# remove any line that does not contain a '(', since we only want functions.
+# For readability, the NAME section may not contain all function names, but we
+# still want to make aliases for those.  Do this by extracting names from the
+# list of function prototypes in the synopsis.
+#
+# Remove any line that does not contain a '(', since we only want functions. 
 # then strip off return-type of each function.
-# finally, remove the parameter list, which begins with a '('.
+#
+# Finally, remove the parameter list, which begins with a '('.
 /^\.SH_(SYNOPSIS/,/^\.SH_(DESCRIPTION/{
+/^\.ti/d
 /^[^(]*$/d
 # reduce
 #	.B "int add_wch( const cchar_t *\fIwch\fB );"
diff --git a/contrib/ncurses/man/menu.3x b/contrib/ncurses/man/menu.3x
index 68117bc05054..a833c3b55123 100644
--- a/contrib/ncurses/man/menu.3x
+++ b/contrib/ncurses/man/menu.3x
@@ -1,6 +1,6 @@
 '\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2014,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,120 +28,129 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: menu.3x,v 1.27 2020/02/02 23:34:34 tom Exp $
-.TH menu 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: menu.3x,v 1.45 2024/03/16 15:35:01 tom Exp $
+.TH menu 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
 .SH NAME
-\fBmenu\fR \- curses extension for programming menus
+\fBmenu\fP \-
+curses extension for programming menus
 .SH SYNOPSIS
-\fB#include <menu.h>\fR
-.br
+.nf
+\fB#include <menu.h>
+.fi
 .SH DESCRIPTION
-The \fBmenu\fR library provides terminal-independent facilities for composing
+The \fBmenu\fP library provides terminal-independent facilities for composing
 menu systems on character-cell terminals.
 The library includes: item routines,
 which create and modify menu items; and menu routines, which group items into
 menus, display menus on the screen, and handle interaction with the user.
 .PP
-The \fBmenu\fR library uses the \fBcurses\fR libraries, and a curses
-initialization routine such as \fBinitscr\fR must be called before using any of
+The \fBmenu\fP library uses the \fBcurses\fP libraries, and a curses
+initialization routine such as \fBinitscr\fP must be called before using any of
 these functions.
-To use the \fBmenu\fR library, link with the options
-\fB\-lmenu \-lcurses\fR.
+To use the \fBmenu\fP library, link with the options
+\fB\-lmenu \-lcurses\fP.
 .
-.SS Current Default Values for Item Attributes
+.SS "Current Default Values for Item Attributes"
 .
-The \fBmenu\fR library maintains a default value for item attributes.
+The \fBmenu\fP library maintains a default value for item attributes.
 You can
-get or set this default by calling the appropriate \fBget_\fR or \fBset_\fR
-routine with a \fBNULL\fR item pointer.
+get or set this default by calling the appropriate \fBget_\fP or \fBset_\fP
+routine with a \fBNULL\fP item pointer.
 Changing this default with a
-\fBset_\fR function affects future item creations, but does not change the
+\fBset_\fP function affects future item creations, but does not change the
 rendering of items already created.
 .
-.SS Routine Name Index
+.SS "Routine Name Index"
 .
-The following table lists each \fBmenu\fR routine and the name of
+The following table lists each \fBmenu\fP routine and the name of
 the manual page on which it is described.
-.
+.PP
 .TS
 l l .
-\fBcurses\fR Routine Name	Manual Page Name
+\fBcurses\fP Routine Name	Manual Page Name
 =
-current_item	\fBmitem_current\fR(3X)
-free_item 	\fBmitem_new\fR(3X)
-free_menu 	\fBmenu_new\fR(3X)
-item_count	\fBmenu_items\fR(3X)
-item_description	\fBmitem_name\fR(3X)
-item_index	\fBmitem_current\fR(3X)
-item_init 	\fBmenu_hook\fR(3X)
-item_name 	\fBmitem_name\fR(3X)
-item_opts 	\fBmitem_opts\fR(3X)
-item_opts_off	\fBmitem_opts\fR(3X)
-item_opts_on	\fBmitem_opts\fR(3X)
-item_term 	\fBmenu_hook\fR(3X)
-item_userptr	\fBmitem_userptr\fR(3X)
-item_value	\fBmitem_value\fR(3X)
-item_visible	\fBmitem_visible\fR(3X)
-menu_back 	\fBmenu_attributes\fR(3X)
-menu_driver	\fBmenu_driver\fR(3X)
-menu_fore 	\fBmenu_attributes\fR(3X)
-menu_format	\fBmenu_format\fR(3X)
-menu_grey 	\fBmenu_attributes\fR(3X)
-menu_init 	\fBmenu_hook\fR(3X)
-menu_items	\fBmenu_items\fR(3X)
-menu_mark 	\fBmenu_mark\fR(3X)
-menu_opts 	\fBmenu_opts\fR(3X)
-menu_opts_off	\fBmenu_opts\fR(3X)
-menu_opts_on	\fBmenu_opts\fR(3X)
-menu_pad  	\fBmenu_attributes\fR(3X)
-menu_pattern	\fBmenu_pattern\fR(3X)
-menu_request_by_name	\fBmenu_requestname\fR(3X)
-menu_request_name	\fBmenu_requestname\fR(3X)
-menu_spacing	\fBmenu_spacing\fR(3X)
-menu_sub  	\fBmenu_win\fR(3X)
-menu_term 	\fBmenu_hook\fR(3X)
-menu_userptr	\fBmenu_userptr\fR(3X)
-menu_win  	\fBmenu_win\fR(3X)
-new_item  	\fBmitem_new\fR(3X)
-new_menu  	\fBmenu_new\fR(3X)
-pos_menu_cursor	\fBmenu_cursor\fR(3X)
-post_menu 	\fBmenu_post\fR(3X)
-scale_menu	\fBmenu_win\fR(3X)
-set_current_item	\fBmitem_current\fR(3X)
-set_item_init	\fBmenu_hook\fR(3X)
-set_item_opts	\fBmitem_opts\fR(3X)
-set_item_term	\fBmenu_hook\fR(3X)
-set_item_userptr	\fBmitem_userptr\fR(3X)
-set_item_value	\fBmitem_value\fR(3X)
-set_menu_back	\fBmenu_attributes\fR(3X)
-set_menu_fore	\fBmenu_attributes\fR(3X)
-set_menu_format	\fBmenu_format\fR(3X)
-set_menu_grey	\fBmenu_attributes\fR(3X)
-set_menu_init	\fBmenu_hook\fR(3X)
-set_menu_items	\fBmenu_items\fR(3X)
-set_menu_mark	\fBmenu_mark\fR(3X)
-set_menu_opts	\fBmitem_opts\fR(3X)
-set_menu_pad	\fBmenu_attributes\fR(3X)
-set_menu_pattern	\fBmenu_pattern\fR(3X)
-set_menu_spacing	\fBmenu_spacing\fR(3X)
-set_menu_sub	\fBmenu_win\fR(3X)
-set_menu_term	\fBmenu_hook\fR(3X)
-set_menu_userptr	\fBmenu_userptr\fR(3X)
-set_menu_win	\fBmenu_win\fR(3X)
-set_top_row	\fBmitem_current\fR(3X)
-top_row   	\fBmitem_current\fR(3X)
-unpost_menu	\fBmenu_post\fR(3X)
+current_item	\fBmitem_current\fP(3X)
+free_item 	\fBmitem_new\fP(3X)
+free_menu 	\fBmenu_new\fP(3X)
+item_count	\fBmenu_items\fP(3X)
+item_description	\fBmitem_name\fP(3X)
+item_index	\fBmitem_current\fP(3X)
+item_init 	\fBmenu_hook\fP(3X)
+item_name 	\fBmitem_name\fP(3X)
+item_opts 	\fBmitem_opts\fP(3X)
+item_opts_off	\fBmitem_opts\fP(3X)
+item_opts_on	\fBmitem_opts\fP(3X)
+item_term 	\fBmenu_hook\fP(3X)
+item_userptr	\fBmitem_userptr\fP(3X)
+item_value	\fBmitem_value\fP(3X)
+item_visible	\fBmitem_visible\fP(3X)
+menu_back 	\fBmenu_attributes\fP(3X)
+menu_driver	\fBmenu_driver\fP(3X)
+menu_fore 	\fBmenu_attributes\fP(3X)
+menu_format	\fBmenu_format\fP(3X)
+menu_grey 	\fBmenu_attributes\fP(3X)
+menu_init 	\fBmenu_hook\fP(3X)
+menu_items	\fBmenu_items\fP(3X)
+menu_mark 	\fBmenu_mark\fP(3X)
+menu_opts 	\fBmenu_opts\fP(3X)
+menu_opts_off	\fBmenu_opts\fP(3X)
+menu_opts_on	\fBmenu_opts\fP(3X)
+menu_pad  	\fBmenu_attributes\fP(3X)
+menu_pattern	\fBmenu_pattern\fP(3X)
+menu_request_by_name	\fBmenu_requestname\fP(3X)
+menu_request_name	\fBmenu_requestname\fP(3X)
+menu_spacing	\fBmenu_spacing\fP(3X)
+menu_sub  	\fBmenu_win\fP(3X)
+menu_term 	\fBmenu_hook\fP(3X)
+menu_userptr	\fBmenu_userptr\fP(3X)
+menu_win  	\fBmenu_win\fP(3X)
+new_item  	\fBmitem_new\fP(3X)
+new_menu  	\fBmenu_new\fP(3X)
+pos_menu_cursor	\fBmenu_cursor\fP(3X)
+post_menu 	\fBmenu_post\fP(3X)
+scale_menu	\fBmenu_win\fP(3X)
+set_current_item	\fBmitem_current\fP(3X)
+set_item_init	\fBmenu_hook\fP(3X)
+set_item_opts	\fBmitem_opts\fP(3X)
+set_item_term	\fBmenu_hook\fP(3X)
+set_item_userptr	\fBmitem_userptr\fP(3X)
+set_item_value	\fBmitem_value\fP(3X)
+set_menu_back	\fBmenu_attributes\fP(3X)
+set_menu_fore	\fBmenu_attributes\fP(3X)
+set_menu_format	\fBmenu_format\fP(3X)
+set_menu_grey	\fBmenu_attributes\fP(3X)
+set_menu_init	\fBmenu_hook\fP(3X)
+set_menu_items	\fBmenu_items\fP(3X)
+set_menu_mark	\fBmenu_mark\fP(3X)
+set_menu_opts	\fBmitem_opts\fP(3X)
+set_menu_pad	\fBmenu_attributes\fP(3X)
+set_menu_pattern	\fBmenu_pattern\fP(3X)
+set_menu_spacing	\fBmenu_spacing\fP(3X)
+set_menu_sub	\fBmenu_win\fP(3X)
+set_menu_term	\fBmenu_hook\fP(3X)
+set_menu_userptr	\fBmenu_userptr\fP(3X)
+set_menu_win	\fBmenu_win\fP(3X)
+set_top_row	\fBmitem_current\fP(3X)
+top_row   	\fBmitem_current\fP(3X)
+unpost_menu	\fBmenu_post\fP(3X)
 .TE
 .SH RETURN VALUE
-Routines that return pointers return \fBNULL\fR on error.
+Routines that return pointers return \fBNULL\fP on error.
 Routines that return
 an integer return one of the following error codes:
 .TP 5
@@ -176,38 +185,31 @@ The menu is already posted.
 The menu driver could not process the request.
 .TP 5
 .B E_SYSTEM_ERROR
-System error occurred (see \fBerrno\fR(3)).
+System error occurred (see \fBerrno\fP(3)).
 .TP 5
 .B E_UNKNOWN_COMMAND
 The menu driver code saw an unknown request code.
 .SH NOTES
-The header file \fB<menu.h>\fR automatically includes the header files
-\fB<curses.h>\fR and \fB<eti.h>\fR.
-.PP
-In your library list, libmenu.a should be before libncurses.a; that is,
-you should say \*(``\-lmenu \-lncurses\*('', not the other way around
-(which would give a link-error when using static libraries).
+The header file \fI\%menu.h\fP itself includes the header file
+\fI\%curses.h\fP.
 .SH PORTABILITY
 These routines emulate the System V menu library.
 They were not supported on
 Version 7 or BSD versions.
 .PP
-The menu facility was documented in SVr4.2 in
-\fICharacter User Interface Programming (UNIX SVR4.2)\fP.
+A menu facility was documented in SVr4.2's
+\fICharacter User Interface Programming\fP document.
 .PP
 It is not part of X/Open Curses.
 .PP
-Aside from ncurses, there are few implementations:
+Aside from \fI\%ncurses\fP, there are few implementations:
 .bP
 systems based on SVr4 source code, e.g., Solaris.
 .bP
 NetBSD curses.
 .SH AUTHORS
 Juergen Pfeifer.
-Manual pages and adaptation for ncurses by Eric S. Raymond.
+Manual pages and adaptation for \fI\%ncurses\fP by Eric S. Raymond.
 .SH SEE ALSO
-\fBcurses\fR(3X) and related pages whose names begin \*(``menu_\*(''
+\fB\%curses\fP(3X) and related pages whose names begin \*(``menu_\*(''
 for detailed descriptions of the entry points.
-.PP
-This describes \fBncurses\fR
-version @NCURSES_MAJOR@.@NCURSES_MINOR@ (patch @NCURSES_PATCH@).
diff --git a/contrib/ncurses/man/menu_attributes.3x b/contrib/ncurses/man/menu_attributes.3x
index 903e303c8dac..7bce42d24be2 100644
--- a/contrib/ncurses/man/menu_attributes.3x
+++ b/contrib/ncurses/man/menu_attributes.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2015 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,63 +27,67 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: menu_attributes.3x,v 1.19 2020/10/17 23:58:58 tom Exp $
-.TH menu_attributes 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: menu_attributes.3x,v 1.36 2024/03/16 15:35:01 tom Exp $
+.TH menu_attributes 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
 .SH NAME
-\fBmenu_back\fR,
-\fBmenu_fore\fR,
-\fBmenu_grey\fR,
-\fBmenu_pad\fR,
-\fBset_menu_back\fR,
-\fBset_menu_fore\fR,
-\fBset_menu_grey\fR,
-\fBset_menu_pad\fR \- color and attribute control for menus
+\fBmenu_back\fP,
+\fBmenu_fore\fP,
+\fBmenu_grey\fP,
+\fBmenu_pad\fP,
+\fBset_menu_back\fP,
+\fBset_menu_fore\fP,
+\fBset_menu_grey\fP,
+\fBset_menu_pad\fP \-
+color and attribute control for menus
 .SH SYNOPSIS
-\fB#include <menu.h>\fR
-.sp
-\fBint set_menu_fore(MENU *\fP\fImenu\fP\fB, chtype \fP\fIattr\fP\fB);\fP
-.br
-\fBchtype menu_fore(const MENU *\fP\fImenu\fP\fB);\fP
-.sp
-\fBint set_menu_back(MENU *\fP\fImenu\fP\fB, chtype \fP\fIattr\fP\fB);\fP
-.br
-\fBchtype menu_back(const MENU *\fP\fImenu\fP\fB);\fP
-.sp
-\fBint set_menu_grey(MENU *\fP\fImenu\fP\fB, chtype \fP\fIattr\fP\fB);\fP
-.br
-\fBchtype menu_grey(const MENU *\fP\fImenu\fP\fB);\fP
-.sp
-\fBint set_menu_pad(MENU *\fP\fImenu\fP\fB, int \fP\fIpad\fP\fB);\fP
-.br
-\fBint menu_pad(const MENU *\fP\fImenu\fP\fB);\fP
-.br
+.nf
+\fB#include <menu.h>
+.PP
+\fBint set_menu_fore(MENU *\fImenu\fP, chtype \fIattr\fP);
+\fBchtype menu_fore(const MENU *\fImenu\fP);
+.PP
+\fBint set_menu_back(MENU *\fImenu\fP, chtype \fIattr\fP);
+\fBchtype menu_back(const MENU *\fImenu\fP);
+.PP
+\fBint set_menu_grey(MENU *\fImenu\fP, chtype \fIattr\fP);
+\fBchtype menu_grey(const MENU *\fImenu\fP);
+.PP
+\fBint set_menu_pad(MENU *\fImenu\fP, int \fIpad\fP);
+\fBint menu_pad(const MENU *\fImenu\fP);
+.fi
 .SH DESCRIPTION
-The function \fBset_menu_fore\fR sets the foreground attribute of
-\fImenu\fR. This is the highlight used for selected menu items.
-\fBmenu_fore\fR returns the foreground attribute.
+The function \fBset_menu_fore\fP sets the foreground attribute of
+\fImenu\fP. This is the highlight used for selected menu items.
+\fBmenu_fore\fP returns the foreground attribute.
 The default
-is \fBA_REVERSE\fR.
+is \fBA_REVERSE\fP.
 .PP
-The function \fBset_menu_back\fR sets the background attribute of
-\fImenu\fR. This is the highlight used for selectable (but not currently
+The function \fBset_menu_back\fP sets the background attribute of
+\fImenu\fP. This is the highlight used for selectable (but not currently
 selected) menu items.
-The function \fBmenu_back\fR returns the background
+The function \fBmenu_back\fP returns the background
 attribute.
-The default is \fBA_NORMAL\fR.
+The default is \fBA_NORMAL\fP.
 .PP
-The function \fBset_menu_grey\fR sets the grey attribute of \fImenu\fR. This is
+The function \fBset_menu_grey\fP sets the grey attribute of \fImenu\fP. This is
 the highlight used for un-selectable menu items in menus that permit more than
 one selection.
-The function \fBmenu_grey\fR returns the grey attribute.
-The default is \fBA_UNDERLINE\fR.
+The function \fBmenu_grey\fP returns the grey attribute.
+The default is \fBA_UNDERLINE\fP.
 .PP
-The function \fBset_menu_pad\fR sets the character used to fill the space
+The function \fBset_menu_pad\fP sets the character used to fill the space
 between the name and description parts of a menu item.
-\fBmenu_pad\fR returns
+\fBmenu_pad\fP returns
 the given menu's pad character.
 The default is a blank.
 .SH RETURN VALUE
@@ -94,16 +97,10 @@ These routines return one of the following:
 The routine succeeded.
 .TP 5
 .B E_SYSTEM_ERROR
-System error occurred (see \fBerrno\fR(3)).
+System error occurred (see \fBerrno\fP(3)).
 .TP 5
 .B E_BAD_ARGUMENT
 Routine detected an incorrect or out-of-range argument.
-.SH SEE ALSO
-\fBcurses\fR(3X) and related pages whose names begin \*(``menu_\*('' for detailed
-descriptions of the entry points.
-.SH NOTES
-The header file \fB<menu.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
 .SH PORTABILITY
 These routines emulate the System V menu library.
 They were not supported on
@@ -111,3 +108,6 @@ Version 7 or BSD versions.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X) and related pages whose names begin \*(``menu_\*(''
+for detailed descriptions of the entry points.
diff --git a/contrib/ncurses/man/menu_cursor.3x b/contrib/ncurses/man/menu_cursor.3x
index 7a364eb5aba0..d92d8c3ad4e0 100644
--- a/contrib/ncurses/man/menu_cursor.3x
+++ b/contrib/ncurses/man/menu_cursor.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2015 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,19 +27,21 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: menu_cursor.3x,v 1.13 2020/10/17 23:41:31 tom Exp $
-.TH menu_cursor 3X ""
+.\" $Id: menu_cursor.3x,v 1.30 2024/03/16 15:35:01 tom Exp $
+.TH menu_cursor 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
-\fBpos_menu_cursor\fR \- position a menu's cursor
+\fBpos_menu_cursor\fP \-
+position a menu's cursor
 .SH SYNOPSIS
-\fB#include <menu.h>\fR
-.sp
-\fBint pos_menu_cursor(const MENU *\fP\fImenu\fP\fB);\fP
-.br
+.nf
+\fB#include <menu.h>
+.PP
+\fBint pos_menu_cursor(const MENU *\fImenu\fP);
+.fi
 .SH DESCRIPTION
-The function \fBpos_menu_cursor\fR restores the cursor to the current position
+The function \fBpos_menu_cursor\fP restores the cursor to the current position
 associated with the menu's selected item.
-This is useful after \fBcurses\fR
+This is useful after \fBcurses\fP
 routines have been called to do screen-painting in response to a menu select.
 .SH RETURN VALUE
 This routine returns one of the following:
@@ -49,18 +50,13 @@ This routine returns one of the following:
 The routine succeeded.
 .TP 5
 .B E_SYSTEM_ERROR
-System error occurred (see \fBerrno\fR(3)).
+System error occurred (see \fBerrno\fP(3)).
 .TP 5
 .B E_BAD_ARGUMENT
 Routine detected an incorrect or out-of-range argument.
 .TP 5
 .B E_NOT_POSTED
 The menu has not been posted.
-.SH SEE ALSO
-\fBcurses\fR(3X), \fBmenu\fR(3X).
-.SH NOTES
-The header file \fB<menu.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
 .SH PORTABILITY
 These routines emulate the System V menu library.
 They were not supported on
@@ -68,3 +64,6 @@ Version 7 or BSD versions.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%menu\fP(3X)
diff --git a/contrib/ncurses/man/menu_driver.3x b/contrib/ncurses/man/menu_driver.3x
index e395358296c4..6a117283705f 100644
--- a/contrib/ncurses/man/menu_driver.3x
+++ b/contrib/ncurses/man/menu_driver.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,22 +27,24 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: menu_driver.3x,v 1.28 2020/12/19 21:33:37 tom Exp $
-.TH menu_driver 3X ""
+.\" $Id: menu_driver.3x,v 1.47 2024/03/16 15:35:01 tom Exp $
+.TH menu_driver 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
 .SH NAME
-\fBmenu_driver\fR \- command-processing loop of the menu system
+\fBmenu_driver\fP \-
+command-processing loop of the menu system
 .SH SYNOPSIS
-\fB#include <menu.h>\fR
-.sp
-\fBint menu_driver(MENU *\fP\fImenu\fP\fB, int \fP\fIc\fP\fB);\fP
-.br
+.nf
+\fB#include <menu.h>
+.PP
+\fBint menu_driver(MENU *\fImenu\fP, int \fIc\fP);
+.fi
 .SH DESCRIPTION
 Once a menu has been posted (displayed), you should funnel input events to it
-through \fBmenu_driver\fR.  This routine has three major input cases:
+through \fBmenu_driver\fP.  This routine has three major input cases:
 .bP
 The input is a form navigation request.
 Navigation request codes are constants defined in \fB<form.h>\fP,
@@ -111,13 +113,12 @@ Move to the previous item matching the pattern match.
 If the second argument is a printable character, the code appends
 it to the pattern buffer and attempts to move to the next item matching
 the new pattern.
-If there is no such match, \fBmenu_driver\fR returns
-\fBE_NO_MATCH\fR and deletes the appended character from the buffer.
+If there is no such match, \fBmenu_driver\fP returns
+\fBE_NO_MATCH\fP and deletes the appended character from the buffer.
 .PP
 If the second argument is one of the above pre-defined requests, the
 corresponding action is performed.
-.SS MOUSE HANDLING
-.PP
+.SS "Mouse Handling"
 If the second argument is the KEY_MOUSE special key, the associated
 mouse event is translated into one of the above pre-defined requests.
 Currently only clicks in the user window (e.g., inside the menu display
@@ -144,7 +145,7 @@ If you click at an item inside the display area of the menu:
 the menu cursor is positioned to that item.
 .bP
 If you double-click an item a REQ_TOGGLE_ITEM
-is generated and \fBE_UNKNOWN_COMMAND\fR is returned.
+is generated and \fBE_UNKNOWN_COMMAND\fP is returned.
 This return value makes sense,
 because a double click usually means that an item-specific action should
 be returned.
@@ -152,27 +153,26 @@ It is exactly the purpose of this return value to signal that an
 application specific command should be executed.
 .bP
 If a translation
-into a request was done, \fBmenu_driver\fR returns the result of this request.
+into a request was done, \fBmenu_driver\fP returns the result of this request.
 .PP
 If you clicked outside the user window
 or the mouse event could not be translated
-into a menu request an \fBE_REQUEST_DENIED\fR is returned.
-.SS APPLICATION-DEFINED COMMANDS
-.PP
+into a menu request an \fBE_REQUEST_DENIED\fP is returned.
+.SS "Application-defined Commands"
 If the second argument is neither printable nor one of the above
 pre-defined menu requests or KEY_MOUSE,
 the drive assumes it is an application-specific
-command and returns \fBE_UNKNOWN_COMMAND\fR.  Application-defined commands
-should be defined relative to \fBMAX_COMMAND\fR, the maximum value of these
+command and returns \fBE_UNKNOWN_COMMAND\fP.  Application-defined commands
+should be defined relative to \fBMAX_COMMAND\fP, the maximum value of these
 pre-defined requests.
 .SH RETURN VALUE
-\fBmenu_driver\fR return one of the following error codes:
+\fBmenu_driver\fP return one of the following error codes:
 .TP 5
 .B E_OK
 The routine succeeded.
 .TP 5
 .B E_SYSTEM_ERROR
-System error occurred (see \fBerrno\fR(3)).
+System error occurred (see \fBerrno\fP(3)).
 .TP 5
 .B E_BAD_ARGUMENT
 Routine detected an incorrect or out-of-range argument.
@@ -191,18 +191,15 @@ Character failed to match.
 .TP 5
 .B E_REQUEST_DENIED
 The menu driver could not process the request.
-.SH SEE ALSO
-\fBcurses\fR(3X),
-\fBgetch\fR(3X),
-\fBmenu\fR(3X).
-.SH NOTES
-The header file \fB<menu.h>\fR automatically includes the header files
-\fB<curses.h>\fR.
 .SH PORTABILITY
 These routines emulate the System V menu library.
 They were not supported on
 Version 7 or BSD versions.
-The support for mouse events is ncurses specific.
+The support for mouse events is \fI\%ncurses\fP specific.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%getch\fP(3X),
+\fB\%menu\fP(3X)
diff --git a/contrib/ncurses/man/menu_format.3x b/contrib/ncurses/man/menu_format.3x
index d01f27ea26f8..9781878f7aab 100644
--- a/contrib/ncurses/man/menu_format.3x
+++ b/contrib/ncurses/man/menu_format.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2015,2016 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,35 +27,36 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: menu_format.3x,v 1.18 2020/10/17 23:43:11 tom Exp $
-.TH menu_format 3X ""
+.\" $Id: menu_format.3x,v 1.35 2024/03/16 15:35:01 tom Exp $
+.TH menu_format 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
 \fBset_menu_format\fP,
-\fBmenu_format\fP \- set and get menu sizes
+\fBmenu_format\fP \-
+set and get menu sizes
 .SH SYNOPSIS
-\fB#include <menu.h>\fR
-.sp
-\fBint set_menu_format(MENU *\fP\fImenu\fP\fB, int \fP\fIrows\fP\fB, int \fP\fIcols\fP\fB);\fP
-.br
-\fBvoid menu_format(const MENU *\fP\fImenu\fP\fB, int *\fP\fIrows\fP\fB, int *\fP\fIcols\fP\fB);\fP
-.br
+.nf
+\fB#include <menu.h>
+.PP
+\fBint set_menu_format(MENU *\fImenu\fP, int \fIrows\fP, int \fIcols\fP);
+\fBvoid menu_format(const MENU *\fImenu\fP, int *\fIrows\fP, int *\fIcols\fP);
+.fi
 .SH DESCRIPTION
-The function \fBset_menu_format\fR sets the maximum display size of the given
+The function \fBset_menu_format\fP sets the maximum display size of the given
 menu.
 If this size is too small to display all menu items, the menu will be
 made scrollable.
 If this size is larger than the menus subwindow and the
-subwindow is too small to display all menu items, \fBpost_menu\fR will fail.
+subwindow is too small to display all menu items, \fBpost_menu\fP will fail.
 .PP
 The default format is 16 rows, 1 column.
-Calling \fBset_menu_format\fR with a
+Calling \fBset_menu_format\fP with a
 null menu pointer will change this default.
 A zero row or column argument to
-\fBset_menu_format\fR is interpreted as a request not to change the current
+\fBset_menu_format\fP is interpreted as a request not to change the current
 value.
 .PP
-The function \fBmenu_format\fR returns the maximum-size constraints for the
-given menu into the storage addressed by \fBrows\fR and \fBcols\fR.
+The function \fBmenu_format\fP returns the maximum-size constraints for the
+given menu into the storage addressed by \fBrows\fP and \fBcols\fP.
 .SH RETURN VALUE
 These routines returns one of the following:
 .TP 5
@@ -64,7 +64,7 @@ These routines returns one of the following:
 The routine succeeded.
 .TP 5
 .B E_SYSTEM_ERROR
-System error occurred (see \fBerrno\fR(3)).
+System error occurred (see \fBerrno\fP(3)).
 .TP 5
 .B E_BAD_ARGUMENT
 Routine detected an incorrect or out-of-range argument.
@@ -74,11 +74,6 @@ The menu is already posted.
 .TP 5
 .B E_NOT_CONNECTED
 No items are connected to the menu.
-.SH SEE ALSO
-\fBcurses\fR(3X), \fBmenu\fR(3X).
-.SH NOTES
-The header file \fB<menu.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
 .SH PORTABILITY
 These routines emulate the System V menu library.
 They were not supported on
@@ -86,3 +81,6 @@ Version 7 or BSD versions.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%menu\fP(3X)
diff --git a/contrib/ncurses/man/menu_hook.3x b/contrib/ncurses/man/menu_hook.3x
index 17a1036fabbe..839e199b8c4f 100644
--- a/contrib/ncurses/man/menu_hook.3x
+++ b/contrib/ncurses/man/menu_hook.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2007,2010 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,57 +27,55 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: menu_hook.3x,v 1.15 2020/10/17 23:44:57 tom Exp $
-.TH menu_hook 3X ""
+.\" $Id: menu_hook.3x,v 1.32 2024/03/16 15:35:01 tom Exp $
+.TH menu_hook 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
-\fBmenu_hook\fR \- set hooks for automatic invocation by applications
+\fBmenu_hook\fP \-
+set hooks for automatic invocation by applications
 .SH SYNOPSIS
-\fB#include <menu.h>\fR
-.sp
-\fBint set_item_init(MENU *\fP\fImenu\fP\fB, Menu_Hook \fP\fIfunc);\fP
-.br
-\fBMenu_Hook item_init(const MENU *\fP\fImenu);\fP
-.sp
-\fBint set_item_term(MENU *\fP\fImenu\fP\fB, Menu_Hook \fP\fIfunc);\fP
-.br
-\fBMenu_Hook item_term(const MENU *\fP\fImenu);\fP
-.sp
-\fBint set_menu_init(MENU *\fP\fImenu\fP\fB, Menu_Hook \fP\fIfunc);\fP
-.br
-\fBMenu_Hook menu_init(const MENU *\fP\fImenu);\fP
-.sp
-\fBint set_menu_term(MENU *\fP\fImenu\fP\fB, Menu_Hook \fP\fIfunc);\fP
-.br
-\fBMenu_Hook menu_term(const MENU *\fP\fImenu);\fP
-.br
+.nf
+\fB#include <menu.h>
+.PP
+\fBint set_item_init(MENU *\fImenu\fP, Menu_Hook \fIfunc\fP);
+\fBMenu_Hook item_init(const MENU *\fImenu\fP);
+.PP
+\fBint set_item_term(MENU *\fImenu\fP, Menu_Hook \fIfunc\fP);
+\fBMenu_Hook item_term(const MENU *\fImenu\fP);
+.PP
+\fBint set_menu_init(MENU *\fImenu\fP, Menu_Hook \fIfunc\fP);
+\fBMenu_Hook menu_init(const MENU *\fImenu\fP);
+.PP
+\fBint set_menu_term(MENU *\fImenu\fP, Menu_Hook \fIfunc\fP);
+\fBMenu_Hook menu_term(const MENU *\fImenu\fP);
+.fi
 .SH DESCRIPTION
 These functions make it possible to set hook functions to be called at various
-points in the automatic processing of input event codes by \fBmenu_driver\fR.
+points in the automatic processing of input event codes by \fBmenu_driver\fP.
 .PP
-The function \fBset_item_init\fR sets a hook to be called at menu-post time and
+The function \fBset_item_init\fP sets a hook to be called at menu-post time and
 each time the selected item changes (after the change).
-\fBitem_init\fR
-returns the current item init hook, if any (\fBNULL\fR if there is no such
+\fBitem_init\fP
+returns the current item init hook, if any (\fBNULL\fP if there is no such
 hook).
 .PP
-The function \fBset_item_term\fR sets a hook to be called at menu-unpost time
+The function \fBset_item_term\fP sets a hook to be called at menu-unpost time
 and each time the selected item changes (before the change).
-\fBitem_term\fR
-returns the current item term hook, if any (\fBNULL\fR if there is no such
+\fBitem_term\fP
+returns the current item term hook, if any (\fBNULL\fP if there is no such
 hook).
 .PP
-The function \fBset_menu_init\fR sets a hook to be called at menu-post time and
+The function \fBset_menu_init\fP sets a hook to be called at menu-post time and
 just after the top row on the menu changes once it is posted.
-\fBmenu_init\fR
-returns the current menu init hook, if any (\fBNULL\fR if there is no such
+\fBmenu_init\fP
+returns the current menu init hook, if any (\fBNULL\fP if there is no such
 hook).
 .PP
-The function \fBset_menu_term\fR sets a hook to be called at menu-unpost time
+The function \fBset_menu_term\fP sets a hook to be called at menu-unpost time
 and just before the top row on the menu changes once it is posted.
-\fBmenu_term\fR returns the current menu term hook, if any (\fBNULL\fR if there
+\fBmenu_term\fP returns the current menu term hook, if any (\fBNULL\fP if there
 is no such hook).
 .SH RETURN VALUE
-Routines that return pointers return \fBNULL\fR on error.
+Routines that return pointers return \fBNULL\fP on error.
 Other routines
 return one of the following:
 .TP 5
@@ -86,12 +83,7 @@ return one of the following:
 The routine succeeded.
 .TP 5
 .B E_SYSTEM_ERROR
-System error occurred (see \fBerrno\fR(3)).
-.SH SEE ALSO
-\fBcurses\fR(3X), \fBmenu\fR(3X).
-.SH NOTES
-The header file \fB<menu.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
+System error occurred (see \fBerrno\fP(3)).
 .SH PORTABILITY
 These routines emulate the System V menu library.
 They were not supported on
@@ -100,3 +92,6 @@ Version 7 or BSD versions.
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric
 S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%menu\fP(3X)
diff --git a/contrib/ncurses/man/menu_items.3x b/contrib/ncurses/man/menu_items.3x
index 7c042435cfc7..43409fef812b 100644
--- a/contrib/ncurses/man/menu_items.3x
+++ b/contrib/ncurses/man/menu_items.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2012,2015 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,36 +27,36 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: menu_items.3x,v 1.17 2020/10/24 09:00:06 tom Exp $
-.TH menu_items 3X ""
+.\" $Id: menu_items.3x,v 1.34 2024/03/16 15:35:01 tom Exp $
+.TH menu_items 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
-\fBset_menu_items\fR,
-\fBmenu_items\fR,
-\fBitem_count\fP \- make and break connections between items and menus
+\fBset_menu_items\fP,
+\fBmenu_items\fP,
+\fBitem_count\fP \-
+make and break connections between items and menus
 .SH SYNOPSIS
-\fB#include <menu.h>\fR
-.sp
-\fBint set_menu_items(MENU *\fP\fImenu\fP\fB, ITEM **\fP\fIitems\fP\fB);\fP
-.br
-\fBITEM **menu_items(const MENU *\fP\fImenu\fP\fB);\fP
-.br
-\fBint item_count(const MENU *\fP\fImenu\fP\fB);\fP
-.br
+.nf
+\fB#include <menu.h>
+.PP
+\fBint set_menu_items(MENU *\fImenu\fP, ITEM **\fIitems\fP);
+\fBITEM **menu_items(const MENU *\fImenu\fP);
+\fBint item_count(const MENU *\fImenu\fP);
+.fi
 .SH DESCRIPTION
-The function \fBset_menu_items\fR changes the item pointer array of the given
-\fImenu\fR.  The array must be terminated by a \fBNULL\fR.
+The function \fBset_menu_items\fP changes the item pointer array of the given
+\fImenu\fP.  The array must be terminated by a \fBNULL\fP.
 .PP
-The function \fBmenu_items\fR returns the item array of the given menu.
+The function \fBmenu_items\fP returns the item array of the given menu.
 .PP
-The function \fBitem_count\fR returns the count of items in \fImenu\fR.
+The function \fBitem_count\fP returns the count of items in \fImenu\fP.
 .SH RETURN VALUE
-The function \fBmenu_items\fR returns a pointer (which may be \fBNULL\fR).
+The function \fBmenu_items\fP returns a pointer (which may be \fBNULL\fP).
 It does not set \fBerrno\fP.
 .PP
-The function \fBitem_count\fR returns \fBERR\fR (the general \fBcurses\fR error
+The function \fBitem_count\fP returns \fBERR\fP (the general \fBcurses\fP error
 return value) if its \fImenu\fP parameter is \fBNULL\fP.
 .PP
-The function \fBset_menu_items\fR returns one of the following codes on error:
+The function \fBset_menu_items\fP returns one of the following codes on error:
 .TP 5
 .B E_OK
 The routine succeeded.
@@ -72,20 +71,17 @@ No items are connected to the menu.
 The menu is already posted.
 .TP 5
 .B E_SYSTEM_ERROR
-System error occurred (see \fBerrno\fR(3)).
-.
-.SH SEE ALSO
-\fBcurses\fR(3X), \fBmenu\fR(3X).
-.SH NOTES
-The header file \fB<menu.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
+System error occurred (see \fBerrno\fP(3)).
 .SH PORTABILITY
 These routines emulate the System V menu library.
 They were not supported on
 Version 7 or BSD versions.
 .PP
-The SVr4 menu library documentation specifies the \fBitem_count\fR error value
-as \-1 (which is the value of \fBERR\fR).
+The SVr4 menu library documentation specifies the \fBitem_count\fP error value
+as \-1 (which is the value of \fBERR\fP).
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%menu\fP(3X)
diff --git a/contrib/ncurses/man/menu_mark.3x b/contrib/ncurses/man/menu_mark.3x
index 960113578f48..e3f3a92869d3 100644
--- a/contrib/ncurses/man/menu_mark.3x
+++ b/contrib/ncurses/man/menu_mark.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2015 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,39 +27,40 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: menu_mark.3x,v 1.18 2020/10/24 08:59:04 tom Exp $
-.TH menu_mark 3X ""
+.\" $Id: menu_mark.3x,v 1.35 2024/03/16 15:35:01 tom Exp $
+.TH menu_mark 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
 \fBset_menu_mark\fP,
-\fBmenu_mark\fR \- get and set the menu mark string
+\fBmenu_mark\fP \-
+get and set the menu mark string
 .SH SYNOPSIS
-\fB#include <menu.h>\fR
-.sp
-\fBint set_menu_mark(MENU *\fP\fImenu\fP\fB, const char *\fP\fImark\fP\fB);\fP
-.br
-\fBconst char *menu_mark(const MENU *\fP\fImenu\fP\fB);\fP
-.br
+.nf
+\fB#include <menu.h>
+.PP
+\fBint set_menu_mark(MENU *\fImenu\fP, const char *\fImark\fP);
+\fBconst char *menu_mark(const MENU *\fImenu\fP);
+.fi
 .SH DESCRIPTION
 In order to make menu selections visible on older terminals without
 highlighting or color capability, the menu library marks selected items
 in a menu with a prefix string.
 .PP
-The function \fBset_menu_mark\fR sets the mark string for the given menu.
-Calling \fBset_menu_mark\fR with a null menu item will abolish the mark string.
+The function \fBset_menu_mark\fP sets the mark string for the given menu.
+Calling \fBset_menu_mark\fP with a null menu item will abolish the mark string.
 Note that changing the length of the mark string for a menu while the
 menu is posted is likely to produce unhelpful behavior.
 .PP
 The default string is "\-" (a dash).
-Calling \fBset_menu_mark\fR with
-a non-\fBNULL\fR menu argument will change this default.
+Calling \fBset_menu_mark\fP with
+a non-\fBNULL\fP menu argument will change this default.
 .PP
-The function \fBmenu_mark\fR returns the menu's mark string (or \fBNULL\fR if
+The function \fBmenu_mark\fP returns the menu's mark string (or \fBNULL\fP if
 there is none).
 .SH RETURN VALUE
-The function \fBmenu_mark\fR returns a pointer (which may be \fBNULL\fR).
+The function \fBmenu_mark\fP returns a pointer (which may be \fBNULL\fP).
 It does not set \fBerrno\fP.
 .PP
-The function \fBset_menu_mark\fR may return the following error codes:
+The function \fBset_menu_mark\fP may return the following error codes:
 .TP 5
 .B E_OK
 The routine succeeded.
@@ -69,12 +69,7 @@ The routine succeeded.
 Routine detected an incorrect or out-of-range argument.
 .TP 5
 .B E_SYSTEM_ERROR
-System error occurred (see \fBerrno\fR(3)).
-.SH SEE ALSO
-\fBcurses\fR(3X), \fBmenu\fR(3X).
-.SH NOTES
-The header file \fB<menu.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
+System error occurred (see \fBerrno\fP(3)).
 .SH PORTABILITY
 These routines emulate the System V menu library.
 They were not supported on
@@ -82,3 +77,6 @@ Version 7 or BSD versions.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%menu\fP(3X)
diff --git a/contrib/ncurses/man/menu_new.3x b/contrib/ncurses/man/menu_new.3x
index 3b04f93bb162..1a133745a9b7 100644
--- a/contrib/ncurses/man/menu_new.3x
+++ b/contrib/ncurses/man/menu_new.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2015 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,26 +27,27 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: menu_new.3x,v 1.18 2020/10/24 08:57:51 tom Exp $
-.TH menu_new 3X ""
+.\" $Id: menu_new.3x,v 1.35 2024/03/16 15:35:01 tom Exp $
+.TH menu_new 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
 \fBnew_menu\fP,
-\fBfree_menu\fR \- create and destroy menus
+\fBfree_menu\fP \-
+create and destroy menus
 .SH SYNOPSIS
-\fB#include <menu.h>\fR
-.sp
-\fBMENU *new_menu(ITEM **\fP\fIitems\fP\fB);\fP
-.br
-\fBint free_menu(MENU *\fP\fImenu\fP\fB);\fP
-.br
+.nf
+\fB#include <menu.h>
+.PP
+\fBMENU *new_menu(ITEM **\fIitems\fP);
+\fBint free_menu(MENU *\fImenu\fP);
+.fi
 .SH DESCRIPTION
-The function \fBnew_menu\fR creates a new menu connected to a specified item
-pointer array (which must be \fBNULL\fR-terminated).
+The function \fBnew_menu\fP creates a new menu connected to a specified item
+pointer array (which must be \fBNULL\fP-terminated).
 .PP
-The function \fBfree_menu\fR disconnects \fImenu\fR from its item array
+The function \fBfree_menu\fP disconnects \fImenu\fP from its item array
 and frees the storage allocated for the menu.
 .SH RETURN VALUE
-The function \fBnew_menu\fR returns \fBNULL\fR on error.
+The function \fBnew_menu\fP returns \fBNULL\fP on error.
 It sets \fBerrno\fP according to the function's failure:
 .TP 5
 .B E_NOT_CONNECTED
@@ -56,24 +56,19 @@ No items are connected to the menu.
 .B E_SYSTEM_ERROR
 System error occurred, e.g., malloc failure.
 .PP
-The function \fBfree_menu\fR returns one of the following:
+The function \fBfree_menu\fP returns one of the following:
 .TP 5
 .B E_OK
 The routine succeeded.
 .TP 5
 .B E_SYSTEM_ERROR
-System error occurred (see \fBerrno\fR(3)).
+System error occurred (see \fBerrno\fP(3)).
 .TP 5
 .B E_BAD_ARGUMENT
 Routine detected an incorrect or out-of-range argument.
 .TP 5
 .B E_POSTED
 The menu has already been posted.
-.SH SEE ALSO
-\fBcurses\fR(3X), \fBmenu\fR(3X).
-.SH NOTES
-The header file \fB<menu.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
 .SH PORTABILITY
 These routines emulate the System V menu library.
 They were not supported on
@@ -81,3 +76,6 @@ Version 7 or BSD versions.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%menu\fP(3X)
diff --git a/contrib/ncurses/man/menu_opts.3x b/contrib/ncurses/man/menu_opts.3x
index 99e950e5b8d4..ad7fe97f348f 100644
--- a/contrib/ncurses/man/menu_opts.3x
+++ b/contrib/ncurses/man/menu_opts.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2015,2016 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,35 +27,35 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: menu_opts.3x,v 1.18 2020/10/17 23:46:35 tom Exp $
-.TH menu_opts 3X ""
+.\" $Id: menu_opts.3x,v 1.35 2024/03/16 15:35:01 tom Exp $
+.TH menu_opts 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
 \fBset_menu_opts\fP,
 \fBmenu_opts_on\fP,
 \fBmenu_opts_off\fP,
-\fBmenu_opts\fR \- set and get menu options
+\fBmenu_opts\fP \-
+set and get menu options
 .SH SYNOPSIS
-\fB#include <menu.h>\fR
-.sp
-\fBint set_menu_opts(MENU *\fP\fImenu\fP\fB, Menu_Options \fP\fIopts\fP\fB);\fP
-.br
-\fBMenu_Options menu_opts(const MENU *\fP\fImenu\fP\fB);\fP
-.sp
-\fBint menu_opts_on(MENU *\fP\fImenu\fP\fB, Menu_Options \fP\fIopts\fP\fB);\fP
-.br
-\fBint menu_opts_off(MENU *\fP\fImenu\fP\fB, Menu_Options \fP\fIopts\fP\fB);\fP
-.br
+.nf
+\fB#include <menu.h>
+.PP
+\fBint set_menu_opts(MENU *\fImenu\fP, Menu_Options \fIopts\fP);
+\fBMenu_Options menu_opts(const MENU *\fImenu\fP);
+.PP
+\fBint menu_opts_on(MENU *\fImenu\fP, Menu_Options \fIopts\fP);
+\fBint menu_opts_off(MENU *\fImenu\fP, Menu_Options \fIopts\fP);
+.fi
 .SH DESCRIPTION
-The function \fBset_menu_opts\fR sets all the given menu's option bits (menu
+The function \fBset_menu_opts\fP sets all the given menu's option bits (menu
 option bits may be logically-OR'ed together).
 .PP
-The function \fBmenu_opts_on\fR turns on the given option bits, and leaves
+The function \fBmenu_opts_on\fP turns on the given option bits, and leaves
 others alone.
 .PP
-The function \fBmenu_opts_off\fR turns off the given option bits, and leaves
+The function \fBmenu_opts_off\fP turns off the given option bits, and leaves
 others alone.
 .PP
-The function \fBmenu_opts\fR returns the menu's current option bits.
+The function \fBmenu_opts\fP returns the menu's current option bits.
 .PP
 The following options are defined (all are on by default):
 .TP 5
@@ -85,21 +84,16 @@ and it does not fall on the currently active menu,
 push \fBKEY_MOUSE\fP and the \fBMEVENT\fP data
 back on the queue to allow processing in another part of the calling program.
 .SH RETURN VALUE
-Except for \fBmenu_opts\fR, each routine returns one of the following:
+Except for \fBmenu_opts\fP, each routine returns one of the following:
 .TP 5
 .B E_OK
 The routine succeeded.
 .TP 5
 .B E_SYSTEM_ERROR
-System error occurred (see \fBerrno\fR(3)).
+System error occurred (see \fBerrno\fP(3)).
 .TP 5
 .B E_POSTED
 The menu is already posted.
-.SH SEE ALSO
-\fBcurses\fR(3X), \fBmenu\fR(3X).
-.SH NOTES
-The header file \fB<menu.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
 .SH PORTABILITY
 These routines emulate the System V menu library.
 They were not supported on
@@ -107,3 +101,6 @@ Version 7 or BSD versions.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%menu\fP(3X)
diff --git a/contrib/ncurses/man/menu_pattern.3x b/contrib/ncurses/man/menu_pattern.3x
index a24ffa0818c5..a66a368dd0c9 100644
--- a/contrib/ncurses/man/menu_pattern.3x
+++ b/contrib/ncurses/man/menu_pattern.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2015 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,39 +27,40 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: menu_pattern.3x,v 1.21 2020/10/18 00:41:14 tom Exp $
-.TH menu_pattern 3X ""
+.\" $Id: menu_pattern.3x,v 1.38 2024/03/16 15:35:01 tom Exp $
+.TH menu_pattern 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
 \fBset_menu_pattern\fP,
-\fBmenu_pattern\fR \- set and get a menu's pattern buffer
+\fBmenu_pattern\fP \-
+set and get a menu's pattern buffer
 .SH SYNOPSIS
-\fB#include <menu.h>\fR
-.sp
-\fBint set_menu_pattern(MENU *\fP\fImenu\fP\fB, const char *\fP\fIpattern\fP\fB);\fP
-.br
-\fBchar *menu_pattern(const MENU *\fP\fImenu\fP\fB);\fP
-.br
+.nf
+\fB#include <menu.h>
+.PP
+\fBint set_menu_pattern(MENU *\fImenu\fP, const char *\fIpattern\fP);
+\fBchar *menu_pattern(const MENU *\fImenu\fP);
+.fi
 .SH DESCRIPTION
 Every menu has an associated pattern match buffer.
 As input events that are
 printable characters come in, they are appended to this match buffer
-and tested for a match, as described in \fBmenu_driver\fR(3X).
+and tested for a match, as described in \fBmenu_driver\fP(3X).
 .PP
-The function \fBset_menu_pattern\fR sets the pattern buffer for the given menu
+The function \fBset_menu_pattern\fP sets the pattern buffer for the given menu
 and tries to find the first matching item.
 If it succeeds, that item becomes
 current; if not, the current item does not change.
 .PP
-The function \fBmenu_pattern\fR returns the pattern buffer of the given
-\fImenu\fR.
+The function \fBmenu_pattern\fP returns the pattern buffer of the given
+\fImenu\fP.
 .SH RETURN VALUE
-The function \fBmenu_pattern\fR returns a pointer,
-which is \fBNULL\fR if the \fImenu\fP parameter is \fBNULL\fP.
+The function \fBmenu_pattern\fP returns a pointer,
+which is \fBNULL\fP if the \fImenu\fP parameter is \fBNULL\fP.
 Otherwise, it is a pointer to a string which is empty
 if no pattern has been set.
 It does not set \fBerrno\fP.
 .PP
-The function \fBset_menu_pattern\fR may return the following error codes:
+The function \fBset_menu_pattern\fP may return the following error codes:
 .TP 5
 .B E_OK
 The routine succeeded.
@@ -77,12 +78,7 @@ No items are connected to menu.
 Character failed to match.
 .TP 5
 .B E_SYSTEM_ERROR
-System error occurred (see \fBerrno\fR(3)).
-.SH SEE ALSO
-\fBcurses\fR(3X), \fBmenu\fR(3X).
-.SH NOTES
-The header file \fB<menu.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
+System error occurred (see \fBerrno\fP(3)).
 .SH PORTABILITY
 These routines emulate the System V menu library.
 They were not supported on
@@ -90,3 +86,6 @@ Version 7 or BSD versions.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%menu\fP(3X)
diff --git a/contrib/ncurses/man/menu_post.3x b/contrib/ncurses/man/menu_post.3x
index 6f14a45a77c6..4a0827a16cf7 100644
--- a/contrib/ncurses/man/menu_post.3x
+++ b/contrib/ncurses/man/menu_post.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,28 +27,29 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: menu_post.3x,v 1.19 2020/10/17 23:47:21 tom Exp $
-.TH menu_post 3X ""
+.\" $Id: menu_post.3x,v 1.36 2024/03/16 15:35:01 tom Exp $
+.TH menu_post 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
-\fBpost_menu\fR,
-\fBunpost_menu\fR \- write or erase menus from associated subwindows
+\fBpost_menu\fP,
+\fBunpost_menu\fP \-
+write or erase menus from associated subwindows
 .SH SYNOPSIS
-\fB#include <menu.h>\fR
-.sp
-\fBint post_menu(MENU *\fP\fImenu\fP\fB);\fP
-.br
-\fBint unpost_menu(MENU *\fP\fImenu\fP\fB);\fP
-.br
+.nf
+\fB#include <menu.h>
+.PP
+\fBint post_menu(MENU *\fImenu\fP);
+\fBint unpost_menu(MENU *\fImenu\fP);
+.fi
 .SH DESCRIPTION
-The function \fBpost_menu\fR displays a menu to its associated subwindow.
+The function \fBpost_menu\fP displays a menu to its associated subwindow.
 To
 trigger physical display of the subwindow,
-use \fBrefresh\fR(3X) or some equivalent
-\fBcurses\fR routine (the implicit \fBdoupdate\fR triggered by an \fBcurses\fR
+use \fBrefresh\fP(3X) or some equivalent
+\fBcurses\fP routine (the implicit \fBdoupdate\fP triggered by an \fBcurses\fP
 input request will do).
-\fBpost_menu\fR resets the selection status of all items.
+\fBpost_menu\fP resets the selection status of all items.
 .PP
-The function \fBunpost_menu\fR erases menu from its associated subwindow.
+The function \fBunpost_menu\fP erases menu from its associated subwindow.
 .SH RETURN VALUE
 These routines return one of the following:
 .TP 5
@@ -57,7 +57,7 @@ These routines return one of the following:
 The routine succeeded.
 .TP 5
 .B E_SYSTEM_ERROR
-System error occurred (see \fBerrno\fR(3)).
+System error occurred (see \fBerrno\fP(3)).
 .TP 5
 .B E_BAD_ARGUMENT
 Routine detected an incorrect or out-of-range argument.
@@ -70,18 +70,13 @@ Routine was called from an initialization or termination function.
 .TP 5
 .B E_NO_ROOM
 Menu is too large for its window.
-You should consider using \fBset_menu_format\fR to solve the problem.
+You should consider using \fBset_menu_format\fP to solve the problem.
 .TP 5
 .B E_NOT_POSTED
 The menu has not been posted.
 .TP 5
 .B E_NOT_CONNECTED
 No items are connected to the menu.
-.SH SEE ALSO
-\fBcurses\fR(3X), \fBmenu\fR(3X).
-.SH NOTES
-The header file \fB<menu.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
 .SH PORTABILITY
 These routines emulate the System V menu library.
 They were not supported on
@@ -89,3 +84,6 @@ Version 7 or BSD versions.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%menu\fP(3X)
diff --git a/contrib/ncurses/man/menu_requestname.3x b/contrib/ncurses/man/menu_requestname.3x
index d10874cc4bcf..a0363fb28585 100644
--- a/contrib/ncurses/man/menu_requestname.3x
+++ b/contrib/ncurses/man/menu_requestname.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2015 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,38 +27,34 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: menu_requestname.3x,v 1.15 2020/10/18 00:40:34 tom Exp $
-.TH menu_requestname 3X ""
+.\" $Id: menu_requestname.3x,v 1.33 2024/03/16 15:35:01 tom Exp $
+.TH menu_requestname 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
 \fBmenu_request_by_name\fP,
-\fBmenu_request_name\fR \- handle printable menu request names
+\fBmenu_request_name\fP \-
+handle printable menu request names
 .SH SYNOPSIS
-\fB#include <menu.h>\fR
-.sp
-\fBconst char *menu_request_name(int \fP\fIrequest\fP\fB);\fP
-.br
-\fBint menu_request_by_name(const char *\fP\fIname\fP\fB);\fP
-.br
+.nf
+\fB#include <menu.h>
+.PP
+\fBconst char *menu_request_name(int \fIrequest\fP);
+\fBint menu_request_by_name(const char *\fIname\fP);
+.fi
 .SH DESCRIPTION
-The function \fBmenu_request_name\fR returns the printable name of a menu
+The function \fBmenu_request_name\fP returns the printable name of a menu
 request code.
 .br
-The function \fBmenu_request_by_name\fR searches in the name-table for a request
+The function \fBmenu_request_by_name\fP searches in the name-table for a request
 with the given name and returns its request code.
 Otherwise E_NO_MATCH is returned.
 .SH RETURN VALUE
-\fBmenu_request_name\fR returns \fBNULL\fR on error
-and sets \fBerrno\fP to \fBE_BAD_ARGUMENT\fR.
+\fBmenu_request_name\fP returns \fBNULL\fP on error
+and sets \fBerrno\fP to \fBE_BAD_ARGUMENT\fP.
 .br
-\fBmenu_request_by_name\fR returns \fBE_NO_MATCH\fR on error.
+\fBmenu_request_by_name\fP returns \fBE_NO_MATCH\fP on error.
 It does not set \fBerrno\fP.
-.SH SEE ALSO
-\fBcurses\fR(3X), \fBmenu\fR(3X).
-.SH NOTES
-The header file \fB<menu.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
 .SH PORTABILITY
-These routines are specific to ncurses.
+These routines are specific to \fI\%ncurses\fP.
 They were not supported on
 Version 7, BSD or System V implementations.
 It is recommended that
@@ -67,3 +62,6 @@ any code depending on them be conditioned using NCURSES_VERSION.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%menu\fP(3X)
diff --git a/contrib/ncurses/man/menu_spacing.3x b/contrib/ncurses/man/menu_spacing.3x
index 7d67f0b6aa2f..d15e77d542a5 100644
--- a/contrib/ncurses/man/menu_spacing.3x
+++ b/contrib/ncurses/man/menu_spacing.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2015 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,61 +27,60 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: menu_spacing.3x,v 1.17 2020/10/17 23:48:53 tom Exp $
-.TH menu_spacing 3X ""
+.\" $Id: menu_spacing.3x,v 1.37 2024/03/16 15:35:01 tom Exp $
+.TH menu_spacing 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
 \fBset_menu_spacing\fP,
-\fBmenu_spacing\fR \- set and get spacing between menu items.
+\fBmenu_spacing\fP \-
+set and get spacing between menu items.
 .SH SYNOPSIS
-\fB#include <menu.h>\fR
-.sp
-\fBint set_menu_spacing(MENU *\fP\fImenu\fP\fB,\fP
-                     \fBint \fP\fIspc_description\fP\fB,\fP
-                     \fBint \fP\fIspc_rows\fP\fB,\fP
-                     \fBint \fP\fIspc_columns\fP\fB);\fP
-.br
-\fBint menu_spacing(const MENU *\fP\fImenu\fP\fB,\fP
-                 \fBint* \fP\fIspc_description\fP\fB,\fP
-                 \fBint* \fP\fIspc_rows\fP\fB,\fP
-                 \fBint* \fP\fIspc_columns\fP\fB);\fP
-.br
+.nf
+\fB#include <menu.h>
+.PP
+\fBint set_menu_spacing(MENU *\fImenu\fP,
+                     \fBint \fIspc_description\fB,\fR
+                     \fBint \fIspc_rows\fB,\fR
+                     \fBint \fIspc_columns\fB);\fR
+\fBint menu_spacing(const MENU *\fImenu\fB,\fR
+                 \fBint* \fIspc_description\fB,\fR
+                 \fBint* \fIspc_rows\fB,\fR
+                 \fBint* \fIspc_columns\fB);\fR
+.fi
 .SH DESCRIPTION
-The function \fBset_menu_spacing\fR sets the spacing information for the menu.
-Its parameter \fBspc_description\fR controls the number of spaces
+The function \fBset_menu_spacing\fP sets the spacing information for the menu.
+Its parameters provide the description and the size (in rows and columns).
+.TP
+\fIspc_description\fP
+controls the number of spaces
 between an item name and an item description.
-It must not be larger than \fBTABSIZE\fR.
+It must not be larger than \fBTABSIZE\fP.
 The menu system puts in the
 middle of this spacing area the pad character.
 The remaining parts are filled with
 spaces.
-The \fBspc_rows\fR parameter controls the number of rows
+.TP
+\fIspc_rows\fP
+controls the number of rows
 that are used for an item.
 It must not be larger than 3.
 The menu system inserts the blank lines between item rows, these lines
 will contain the pad character in the appropriate positions.
-The \fBspc_columns\fR parameter controls
-the number of blanks between columns of items.
+.TP
+\fIspc_columns\fP
+controls the number of blanks between columns of items.
 It must not be larger than \fBTABSIZE\fP.
 A value of 0 for all the spacing values resets them to the default,
 which is 1 for all of them.
-.br
-The function \fBmenu_spacing\fR passes back the spacing info for the menu.
-If a
-pointer is NULL, this specific info is simply not returned.
+.PP
+The function \fBmenu_spacing\fP returns the spacing information for the menu.
+If a pointer is NULL, the corresponding information is simply not returned.
 .SH RETURN VALUE
-Both routines return \fBE_OK\fR on success.
-\fBset_menu_spacing\fR may return
-\fBE_POSTED\fR if the menu is posted, or \fBE_BAD_ARGUMENT\fR if one of the
+Both routines return \fBE_OK\fP on success.
+\fBset_menu_spacing\fP may return
+\fBE_POSTED\fP if the menu is posted, or \fBE_BAD_ARGUMENT\fP if one of the
 spacing values is out of range.
-.SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_variables\fR(3X),
-\fBmenu\fR(3X).
-.SH NOTES
-The header file \fB<menu.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
 .SH PORTABILITY
-These routines are specific to ncurses.
+These routines are specific to \fI\%ncurses\fP.
 They were not supported on
 Version 7, BSD or System V implementations.
 It is recommended that
@@ -90,3 +88,7 @@ any code depending on them be conditioned using NCURSES_VERSION.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%curs_variables\fP(3X),
+\fB\%menu\fP(3X)
diff --git a/contrib/ncurses/man/menu_userptr.3x b/contrib/ncurses/man/menu_userptr.3x
index afc393e08040..292bbd6b85e8 100644
--- a/contrib/ncurses/man/menu_userptr.3x
+++ b/contrib/ncurses/man/menu_userptr.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2015 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,32 +27,28 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: menu_userptr.3x,v 1.16 2020/10/18 00:39:49 tom Exp $
-.TH menu_userptr 3X ""
+.\" $Id: menu_userptr.3x,v 1.33 2024/03/16 15:35:01 tom Exp $
+.TH menu_userptr 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
 \fBset_menu_userptr\fP,
-\fBmenu_userptr\fR \- associate application data with a menu item
+\fBmenu_userptr\fP \-
+associate application data with a menu item
 .SH SYNOPSIS
-\fB#include <menu.h>\fR
-.sp
-\fBint set_menu_userptr(MENU *\fP\fImenu\fP\fB, void *\fP\fIuserptr\fP\fB);\fP
-.br
-\fBvoid *menu_userptr(const MENU *\fP\fImenu\fP\fB);\fP
-.br
+.nf
+\fB#include <menu.h>
+.PP
+\fBint set_menu_userptr(MENU *\fImenu\fP, void *\fIuserptr\fP);
+\fBvoid *menu_userptr(const MENU *\fImenu\fP);
+.fi
 .SH DESCRIPTION
 Every menu and every menu item has a field that can be used to hold
 application-specific data (that is, the menu-driver code leaves it alone).
 These functions get and set the menu user pointer field.
 .SH RETURN VALUE
-\fBmenu_userptr\fR returns a pointer (which may be \fBNULL\fR).
+\fBmenu_userptr\fP returns a pointer (which may be \fBNULL\fP).
 It does not set \fBerrno\fP.
 .PP
 \fBset_menu_userptr\fP returns \fBE_OK\fP (success).
-.SH SEE ALSO
-\fBcurses\fR(3X), \fBmenu\fR(3X).
-.SH NOTES
-The header file \fB<menu.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
 .SH PORTABILITY
 These routines emulate the System V menu library.
 They were not supported on
@@ -64,3 +59,6 @@ We chose not to leave it as a char pointer for SVr4 compatibility.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%menu\fP(3X)
diff --git a/contrib/ncurses/man/menu_win.3x b/contrib/ncurses/man/menu_win.3x
index ae764ec9a126..36f6129dc2a8 100644
--- a/contrib/ncurses/man/menu_win.3x
+++ b/contrib/ncurses/man/menu_win.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2006,2010 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,41 +27,41 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: menu_win.3x,v 1.15 2020/10/17 23:50:51 tom Exp $
-.TH menu_win 3X ""
+.\" $Id: menu_win.3x,v 1.32 2024/03/16 15:35:01 tom Exp $
+.TH menu_win 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
-\fBmenu_win\fR \- make and break menu window and subwindow associations
+\fBmenu_win\fP \-
+make and break menu window and subwindow associations
 .SH SYNOPSIS
-\fB#include <menu.h>\fR
-.sp
-\fBint set_menu_win(MENU *\fP\fImenu\fP\fB, WINDOW *\fP\fIwin\fP\fB);\fP
-.br
-\fBWINDOW *menu_win(const MENU *\fP\fImenu\fP\fB);\fP
-.sp
-\fBint set_menu_sub(MENU *\fP\fImenu\fP\fB, WINDOW *\fP\fIsub\fP\fB);\fP
-.br
-\fBWINDOW *menu_sub(const MENU *\fP\fImenu\fP\fB);\fP
-.sp
-\fBint scale_menu(const MENU *\fP\fImenu, int *\fP\fIrows\fP\fB, int *\fP\fIcolumns);\fP
-.br
+.nf
+\fB#include <menu.h>
+.PP
+\fBint set_menu_win(MENU *\fImenu\fP, WINDOW *\fIwin\fP);
+\fBWINDOW *menu_win(const MENU *\fImenu\fP);
+.PP
+\fBint set_menu_sub(MENU *\fImenu\fP, WINDOW *\fIsub\fP);
+\fBWINDOW *menu_sub(const MENU *\fImenu\fP);
+.PP
+\fBint scale_menu(const MENU *\fImenu\fP, int *\fIrows\fP, int *\fIcolumns\fP);
+.fi
 .SH DESCRIPTION
-Every menu has an associated pair of \fBcurses\fR windows.
+Every menu has an associated pair of \fBcurses\fP windows.
 The menu window
 displays any title and border associated with the window; the menu subwindow
 displays the items of the menu that are currently available for selection.
 .PP
 The first four functions get and set those windows.
 It is not necessary to set
-either window; by default, the driver code uses \fBstdscr\fR for both.
+either window; by default, the driver code uses \fBstdscr\fP for both.
 .PP
-In the \fBset_\fR functions, window argument of \fBNULL\fR is treated as though
-it were \fBstsdcr\fR.  A menu argument of \fBNULL\fR is treated as a request
+In the \fBset_\fP functions, window argument of \fBNULL\fP is treated as though
+it were \fBstsdcr\fP.  A menu argument of \fBNULL\fP is treated as a request
 to change the system default menu window or subwindow.
 .PP
-The function \fBscale_menu\fR returns the minimum size required for the
-subwindow of \fImenu\fR.
+The function \fBscale_menu\fP returns the minimum size required for the
+subwindow of \fImenu\fP.
 .SH RETURN VALUE
-Routines that return pointers return \fBNULL\fR on error.
+Routines that return pointers return \fBNULL\fP on error.
 Routines that return
 an integer return one of the following error codes:
 .TP 5
@@ -70,7 +69,7 @@ an integer return one of the following error codes:
 The routine succeeded.
 .TP 5
 .B E_SYSTEM_ERROR
-System error occurred (see \fBerrno\fR(3)).
+System error occurred (see \fBerrno\fP(3)).
 .TP 5
 .B E_BAD_ARGUMENT
 Routine detected an incorrect or out-of-range argument.
@@ -80,13 +79,6 @@ The menu has already been posted.
 .TP 5
 .B E_NOT_CONNECTED
 No items are connected to the menu.
-.SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_variables\fR(3X),
-\fBmenu\fR(3X).
-.SH NOTES
-The header file \fB<menu.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
 .SH PORTABILITY
 These routines emulate the System V menu library.
 They were not supported on
@@ -94,3 +86,7 @@ Version 7 or BSD versions.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%curs_variables\fP(3X),
+\fB\%menu\fP(3X)
diff --git a/contrib/ncurses/man/mitem_current.3x b/contrib/ncurses/man/mitem_current.3x
index 4cd37b6033e2..42d36c39754b 100644
--- a/contrib/ncurses/man/mitem_current.3x
+++ b/contrib/ncurses/man/mitem_current.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2006,2010 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,47 +27,47 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: mitem_current.3x,v 1.20 2020/10/18 00:39:06 tom Exp $
-.TH mitem_current 3X ""
+.\" $Id: mitem_current.3x,v 1.37 2024/03/16 15:35:01 tom Exp $
+.TH mitem_current 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
-\fBmitem_current\fR \- set and get current_menu_item
+\fBmitem_current\fP \-
+set and get current_menu_item
 .SH SYNOPSIS
-\fB#include <menu.h>\fR
-.sp
-\fBint set_current_item(MENU *\fP\fImenu\fP\fB, ITEM *\fP\fIitem\fP\fB);\fP
-.br
-\fBITEM *current_item(const MENU *\fP\fImenu\fP\fB);\fP
-.sp
-\fBint set_top_row(MENU *\fP\fImenu\fP\fB, int \fP\fIrow\fP\fB);\fP
-.br
-\fBint top_row(const MENU *\fP\fImenu\fP\fB);\fP
-.sp
-\fBint item_index(const ITEM *\fP\fIitem\fP\fB);\fP
-.br
+.nf
+\fB#include <menu.h>
+.PP
+\fBint set_current_item(MENU *\fImenu\fP, ITEM *\fIitem\fP);
+\fBITEM *current_item(const MENU *\fImenu\fP);
+.PP
+\fBint set_top_row(MENU *\fImenu\fP, int \fIrow\fP);
+\fBint top_row(const MENU *\fImenu\fP);
+.PP
+\fBint item_index(const ITEM *\fIitem\fP);
+.fi
 .SH DESCRIPTION
-The function \fBset_current_item\fR sets the current item (the item on which
+The function \fBset_current_item\fP sets the current item (the item on which
 the menu cursor is positioned).
-\fBcurrent_item\fR returns a pointer to the
+\fBcurrent_item\fP returns a pointer to the
 current item in the given menu.
 .PP
-The function \fBset_top_row\fR sets the top row of the menu to show the given
+The function \fBset_top_row\fP sets the top row of the menu to show the given
 row (the top row is initially 0, and is reset to this value whenever the
-\fBO_ROWMAJOR\fR option is toggled).
+\fBO_ROWMAJOR\fP option is toggled).
 The item leftmost on the given row
 becomes current.
-The function \fBtop_row\fR returns the number of the top menu
+The function \fBtop_row\fP returns the number of the top menu
 row being displayed.
 .PP
-The function \fBitem_index\fR returns the (zero-origin) index of \fIitem\fR in
+The function \fBitem_index\fP returns the (zero-origin) index of \fIitem\fP in
 the menu's item pointer list.
 .SH RETURN VALUE
-\fBcurrent_item\fR returns a pointer (which may be \fBNULL\fR).
+\fBcurrent_item\fP returns a pointer (which may be \fBNULL\fP).
 It does not set \fBerrno\fP.
 .PP
-\fBtop_row\fR and \fBitem_index\fR return \fBERR\fR (the general \fBcurses\fR
+\fBtop_row\fP and \fBitem_index\fP return \fBERR\fP (the general \fBcurses\fP
 error value) if their \fImenu\fP parameter is \fBNULL\fP.
 .PP
-\fBset_current_item\fR and \fBset_top_row\fR return one of the following:
+\fBset_current_item\fP and \fBset_top_row\fP return one of the following:
 .TP 5
 .B E_OK
 The routine succeeded.
@@ -83,19 +82,17 @@ Routine was called from an initialization or termination function.
 No items are connected to the menu.
 .TP 5
 .B E_SYSTEM_ERROR
-System error occurred (see \fBerrno\fR(3)).
-.SH SEE ALSO
-\fBcurses\fR(3X), \fBmenu\fR(3X).
-.SH NOTES
-The header file \fB<menu.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
+System error occurred (see \fBerrno\fP(3)).
 .SH PORTABILITY
 These routines emulate the System V menu library.
 They were not supported on
 Version 7 or BSD versions.
 .PP
-The SVr4 menu library documentation specifies the \fBtop_row\fR and
-\fBindex_item\fR error value as \-1 (which is the value of \fBERR\fR).
+The SVr4 menu library documentation specifies the \fBtop_row\fP and
+\fBindex_item\fP error value as \-1 (which is the value of \fBERR\fP).
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%menu\fP(3X)
diff --git a/contrib/ncurses/man/mitem_name.3x b/contrib/ncurses/man/mitem_name.3x
index bf50cfd8f424..3606bb5d2455 100644
--- a/contrib/ncurses/man/mitem_name.3x
+++ b/contrib/ncurses/man/mitem_name.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2015 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,34 +27,33 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: mitem_name.3x,v 1.14 2020/10/18 00:37:48 tom Exp $
-.TH mitem_name 3X ""
+.\" $Id: mitem_name.3x,v 1.31 2024/03/16 15:35:01 tom Exp $
+.TH mitem_name 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
-\fBitem_name\fR,
-\fBitem_description\fR \- get menu item name and description fields
+\fBitem_name\fP,
+\fBitem_description\fP \-
+get menu item name and description fields
 .SH SYNOPSIS
-\fB#include <menu.h>\fR
-.sp
-\fBconst char *item_name(const ITEM *\fP\fIitem\fP\fB);\fP
-.br
-\fBconst char *item_description(const ITEM *\fP\fIitem\fP\fB);\fP
-.br
+.nf
+\fB#include <menu.h>
+.PP
+\fBconst char *item_name(const ITEM *\fIitem\fP);
+\fBconst char *item_description(const ITEM *\fIitem\fP);
+.fi
 .SH DESCRIPTION
-The function \fBitem_name\fR returns the name part of the given item.
+The function \fBitem_name\fP returns the name part of the given item.
 .br
-The function \fBitem_description\fR returns the description part of the given
+The function \fBitem_description\fP returns the description part of the given
 item.
 .SH RETURN VALUE
-These routines return a pointer (which may be \fBNULL\fR).
+These routines return a pointer (which may be \fBNULL\fP).
 They do not set \fBerrno\fP.
-.SH SEE ALSO
-\fBcurses\fR(3X), \fBmenu\fR(3X).
-.SH NOTES
-The header file \fB<menu.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
 .SH PORTABILITY
 These routines emulate the System V menu library.
 They were not supported on Version 7 or BSD versions.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%menu\fP(3X)
diff --git a/contrib/ncurses/man/mitem_new.3x b/contrib/ncurses/man/mitem_new.3x
index ce52044f1280..66bd29bce3a8 100644
--- a/contrib/ncurses/man/mitem_new.3x
+++ b/contrib/ncurses/man/mitem_new.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2015 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,21 +27,22 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: mitem_new.3x,v 1.19 2020/10/18 00:37:03 tom Exp $
-.TH mitem_new 3X ""
+.\" $Id: mitem_new.3x,v 1.36 2024/03/16 15:35:01 tom Exp $
+.TH mitem_new 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
 \fBnew_item\fP,
-\fBfree_item\fR \- create and destroy menu items
+\fBfree_item\fP \-
+create and destroy menu items
 .SH SYNOPSIS
-\fB#include <menu.h>\fR
-.sp
-\fBITEM *new_item(const char *\fP\fIname\fP\fB, const char *\fP\fIdescription\fP\fB);\fP
-.br
-\fBint free_item(ITEM *\fP\fIitem\fP\fB);\fP
-.br
+.nf
+\fB#include <menu.h>
+.PP
+\fBITEM *new_item(const char *\fIname\fP, const char *\fIdescription\fP);
+\fBint free_item(ITEM *\fIitem\fP);
+.fi
 .SH DESCRIPTION
-The function \fBnew_item\fR allocates a new item and initializes it from the
-\fBname\fR and \fBdescription\fR pointers.
+The function \fBnew_item\fP allocates a new item and initializes it from the
+\fBname\fP and \fBdescription\fP pointers.
 Please notice that the item stores
 only the pointers to the name and description.
 Those pointers must be valid
@@ -50,12 +50,12 @@ during the lifetime of the item.
 So you should be very careful with names
 or descriptions allocated on the stack of some routines.
 .br
-The function \fBfree_item\fR de-allocates an item.
+The function \fBfree_item\fP de-allocates an item.
 Please notice that it
 is the responsibility of the application to release the memory for the
 name or the description of the item.
 .SH RETURN VALUE
-The function \fBnew_item\fR returns \fBNULL\fR on error.
+The function \fBnew_item\fP returns \fBNULL\fP on error.
 It sets \fBerrno\fP according to the function's failure:
 .TP 5
 .B E_BAD_ARGUMENT
@@ -64,7 +64,7 @@ Routine detected an incorrect or out-of-range argument.
 .B E_SYSTEM_ERROR
 System error occurred, e.g., malloc failure.
 .PP
-The function \fBfree_item\fR returns one of the following:
+The function \fBfree_item\fP returns one of the following:
 .TP 5
 .B E_OK
 The routine succeeded.
@@ -76,12 +76,7 @@ Routine detected an incorrect or out-of-range argument.
 Item is connected to a menu.
 .TP 5
 .B E_SYSTEM_ERROR
-System error occurred (see \fBerrno\fR(3)).
-.SH SEE ALSO
-\fBcurses\fR(3X), \fBmenu\fR(3X).
-.SH NOTES
-The header file \fB<menu.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
+System error occurred (see \fBerrno\fP(3)).
 .SH PORTABILITY
 These routines emulate the System V menu library.
 They were not supported on
@@ -89,3 +84,6 @@ Version 7 or BSD versions.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%menu\fP(3X)
diff --git a/contrib/ncurses/man/mitem_opts.3x b/contrib/ncurses/man/mitem_opts.3x
index 105f9de97a42..5a86516f5a24 100644
--- a/contrib/ncurses/man/mitem_opts.3x
+++ b/contrib/ncurses/man/mitem_opts.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2015 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,53 +27,48 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: mitem_opts.3x,v 1.16 2020/10/17 23:52:26 tom Exp $
-.TH mitem_opts 3X ""
+.\" $Id: mitem_opts.3x,v 1.33 2024/03/16 15:35:01 tom Exp $
+.TH mitem_opts 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
 \fBset_item_opts\fP,
 \fBitem_opts_on\fP,
 \fBitem_opts_off\fP,
-\fBitem_opts\fR \- set and get menu item options
+\fBitem_opts\fP \-
+set and get menu item options
 .SH SYNOPSIS
-\fB#include <menu.h>\fR
-.sp
-\fBint set_item_opts(ITEM *\fP\fIitem\fP\fB, Item_Options \fP\fIopts\fP\fB);\fP
-.br
-\fBItem_Options item_opts(const ITEM *\fP\fIitem\fP\fB);\fP
-.sp
-\fBint item_opts_on(ITEM *\fP\fIitem\fP\fB, Item_Options \fP\fIopts\fP\fB);\fP
-.br
-\fBint item_opts_off(ITEM *\fP\fIitem\fP\fB, Item_Options \fP\fIopts\fP\fB);\fP
-.br
+.nf
+\fB#include <menu.h>
+.PP
+\fBint set_item_opts(ITEM *\fIitem\fP, Item_Options \fIopts\fP);
+\fBItem_Options item_opts(const ITEM *\fIitem\fP);
+.PP
+\fBint item_opts_on(ITEM *\fIitem\fP, Item_Options \fIopts\fP);
+\fBint item_opts_off(ITEM *\fIitem\fP, Item_Options \fIopts\fP);
+.fi
 .SH DESCRIPTION
-The function \fBset_item_opts\fR sets all the given item's option bits (menu
+The function \fBset_item_opts\fP sets all the given item's option bits (menu
 option bits may be logically-OR'ed together).
 .PP
-The function \fBitem_opts_on\fR turns on the given option bits, and leaves
+The function \fBitem_opts_on\fP turns on the given option bits, and leaves
 others alone.
 .PP
-The function \fBitem_opts_off\fR turns off the given option bits, and leaves
+The function \fBitem_opts_off\fP turns off the given option bits, and leaves
 others alone.
 .PP
-The function \fBitem_opts\fR returns the item's current option bits.
+The function \fBitem_opts\fP returns the item's current option bits.
 .PP
-There is only one defined option bit mask, \fBO_SELECTABLE\fR.  When this is
+There is only one defined option bit mask, \fBO_SELECTABLE\fP.  When this is
 on, the item may be selected during menu processing.
 This option defaults
 to on.
 .SH RETURN VALUE
-Except for \fBitem_opts\fR, each routine returns one of the following:
+Except for \fBitem_opts\fP, each routine returns one of the following:
 .TP 5
 .B E_OK
 The routine succeeded.
 .TP 5
 .B E_SYSTEM_ERROR
-System error occurred (see \fBerrno\fR(3)).
-.SH SEE ALSO
-\fBcurses\fR(3X), \fBmenu\fR(3X).
-.SH NOTES
-The header file \fB<menu.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
+System error occurred (see \fBerrno\fP(3)).
 .SH PORTABILITY
 These routines emulate the System V menu library.
 They were not supported on
@@ -82,3 +76,6 @@ Version 7 or BSD versions.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%menu\fP(3X)
diff --git a/contrib/ncurses/man/mitem_userptr.3x b/contrib/ncurses/man/mitem_userptr.3x
index 3c3feb26883a..f0eab8bd8058 100644
--- a/contrib/ncurses/man/mitem_userptr.3x
+++ b/contrib/ncurses/man/mitem_userptr.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2015 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,34 +27,29 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: mitem_userptr.3x,v 1.17 2020/10/18 00:36:16 tom Exp $
-.TH mitem_userptr 3X ""
+.\" $Id: mitem_userptr.3x,v 1.34 2024/03/16 15:35:01 tom Exp $
+.TH mitem_userptr 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
 \fBset_item_userptr\fP,
-\fBitem_userptr\fR \- associate application data with a menu item
+\fBitem_userptr\fP \-
+associate application data with a menu item
 .SH SYNOPSIS
-\fB#include <menu.h>\fR
-.sp
-\fBint set_item_userptr(ITEM *\fP\fIitem\fP\fB, void *\fP\fIuserptr\fP\fB);\fP
-.br
-\fBvoid *item_userptr(const ITEM *\fP\fIitem\fP\fB);\fP
-.br
+.nf
+\fB#include <menu.h>
+.PP
+\fBint set_item_userptr(ITEM *\fIitem\fP, void *\fIuserptr\fP);
+\fBvoid *item_userptr(const ITEM *\fIitem\fP);
+.fi
 .SH DESCRIPTION
 Every menu item has a field that can be used to hold application-specific data
 (that is, the menu-driver code leaves it alone).
 These functions get and set
 that field.
 .SH RETURN VALUE
-The function \fBitem_userptr\fR returns a pointer (possibly \fBNULL\fR).
+The function \fBitem_userptr\fP returns a pointer (possibly \fBNULL\fP).
 It does not set \fBerrno\fP.
 .PP
 The \fBset_item_userptr\fP always returns \fBE_OK\fP (success).
-.
-.SH SEE ALSO
-\fBcurses\fR(3X), \fBmenu\fR(3X).
-.SH NOTES
-The header file \fB<menu.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
 .SH PORTABILITY
 These routines emulate the System V menu library.
 They were not supported on
@@ -66,3 +60,6 @@ We chose not to leave it as a char pointer for SVr4 compatibility.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%menu\fP(3X)
diff --git a/contrib/ncurses/man/mitem_value.3x b/contrib/ncurses/man/mitem_value.3x
index 3dc20f1a3c4f..daa383dae6bd 100644
--- a/contrib/ncurses/man/mitem_value.3x
+++ b/contrib/ncurses/man/mitem_value.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2015 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,43 +27,39 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: mitem_value.3x,v 1.15 2020/10/17 23:53:24 tom Exp $
-.TH mitem_value 3X ""
+.\" $Id: mitem_value.3x,v 1.32 2024/03/16 15:35:01 tom Exp $
+.TH mitem_value 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
 \fBset_item_value\fP,
-\fBitem_value\fP \- set and get menu item values
+\fBitem_value\fP \-
+set and get menu item values
 .SH SYNOPSIS
-\fB#include <menu.h>\fR
-.sp
-\fBint set_item_value(ITEM *\fP\fIitem\fP\fB, bool \fP\fIvalue\fP\fB);\fP
-.br
-\fBbool item_value(const ITEM *\fP\fIitem\fP\fB);\fP
-.br
+.nf
+\fB#include <menu.h>
+.PP
+\fBint set_item_value(ITEM *\fIitem\fP, bool \fIvalue\fP);
+\fBbool item_value(const ITEM *\fIitem\fP);
+.fi
 .SH DESCRIPTION
-If you turn off the menu option \fBO_ONEVALUE\fR (e.g., with
-\fBset_menu_opts\fR or \fBmenu_opts_off\fR; see \fBmenu_opts\fR(3X)), the menu
+If you turn off the menu option \fBO_ONEVALUE\fP (e.g., with
+\fBset_menu_opts\fP or \fBmenu_opts_off\fP; see \fBmenu_opts\fP(3X)), the menu
 becomes multi-valued; that is, more than one item may simultaneously be
 selected.
 .PP
-In a multi_valued menu, you can used \fBset_item_value\fR to select the
-given menu item (second argument \fBTRUE\fR) or deselect it (second argument
-\fBFALSE\fR).
+In a multi_valued menu, you can used \fBset_item_value\fP to select the
+given menu item (second argument \fBTRUE\fP) or deselect it (second argument
+\fBFALSE\fP).
 .SH RETURN VALUE
-The function \fBset_item_value\fR returns one of the following:
+The function \fBset_item_value\fP returns one of the following:
 .TP 5
 .B E_OK
 The routine succeeded.
 .TP 5
 .B E_SYSTEM_ERROR
-System error occurred (see \fBerrno\fR(3)).
+System error occurred (see \fBerrno\fP(3)).
 .TP 5
 .B E_REQUEST_DENIED
 The menu driver could not process the request.
-.SH SEE ALSO
-\fBcurses\fR(3X), \fBmenu\fR(3X).
-.SH NOTES
-The header file \fB<menu.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
 .SH PORTABILITY
 These routines emulate the System V menu library.
 They were not supported on
@@ -71,3 +67,6 @@ Version 7 or BSD versions.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%menu\fP(3X)
diff --git a/contrib/ncurses/man/mitem_visible.3x b/contrib/ncurses/man/mitem_visible.3x
index 5e6d1682dd0e..c28c603faeb0 100644
--- a/contrib/ncurses/man/mitem_visible.3x
+++ b/contrib/ncurses/man/mitem_visible.3x
@@ -1,6 +1,5 @@
-'\" t
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998,2010 Free Software Foundation, Inc.                       *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,24 +27,21 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: mitem_visible.3x,v 1.10 2020/10/17 23:53:55 tom Exp $
-.TH mitem_visible 3X ""
+.\" $Id: mitem_visible.3x,v 1.27 2024/03/16 15:35:01 tom Exp $
+.TH mitem_visible 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
-\fBmitem_visible\fR \- check visibility of a menu item
+\fBitem_visible\fP \-
+check visibility of a menu item
 .SH SYNOPSIS
-\fB#include <menu.h>\fR
-.sp
-\fBbool item_visible(const ITEM *\fP\fIitem\fP\fB);\fP
-.br
+.nf
+\fB#include <menu.h>
+.PP
+\fBbool item_visible(const ITEM *\fIitem\fP);
+.fi
 .SH DESCRIPTION
 A menu item is visible when it is in the portion of a posted menu that
 is mapped onto the screen (if the menu is scrollable, in particular, this
 portion will be smaller than the whole menu).
-.SH SEE ALSO
-\fBcurses\fR(3X), \fBmenu\fR(3X).
-.SH NOTES
-The header file \fB<menu.h>\fR automatically includes the header file
-\fB<curses.h>\fR.
 .SH PORTABILITY
 These routines emulate the System V menu library.
 They were not supported on
@@ -53,3 +49,6 @@ Version 7 or BSD versions.
 .SH AUTHORS
 Juergen Pfeifer.
 Manual pages and adaptation for new curses by Eric S. Raymond.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%menu\fP(3X)
diff --git a/contrib/ncurses/man/ncurses.3x b/contrib/ncurses/man/ncurses.3x
index 77083c796f47..9aaa7adf54bf 100644
--- a/contrib/ncurses/man/ncurses.3x
+++ b/contrib/ncurses/man/ncurses.3x
@@ -1,6 +1,6 @@
 '\" t
 .\"***************************************************************************
-.\" Copyright 2018-2020,2021 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2015,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,1232 +28,1691 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: ncurses.3x,v 1.152 2021/01/09 11:07:55 tom Exp $
-.hy 0
-.TH ncurses 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: ncurses.3x,v 1.214 2024/04/27 17:55:43 tom Exp $
+.TH ncurses 3X 2024-04-27 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.de NS
-.ie n  .sp
-.el    .sp .5
-.ie n  .in +4
-.el    .in +2
-.nf
-.ft C			\" Courier
-..
-.de NE
-.fi
-.ft R
-.ie n  .in -4
-.el    .in -2
+.
+.\" Add supplementary paragraph tag on its own line after TP.
+.\" Adapted from TQ (which would produce mandoc warnings).
+.de tQ
+.  br
+.  ns
+.  TP
 ..
-.ds n 5
+.
 .ds d @TERMINFO@
 .SH NAME
-\fBncurses\fR \- CRT screen handling and optimization package
+\fB\%ncurses\fP \-
+character-cell terminal interface with optimized output
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.br
+.nf
+\fB#include <curses.h>
+.fi
 .SH DESCRIPTION
-The \fBncurses\fR library routines give the user a terminal-independent method
-of updating character screens with reasonable optimization.
-This implementation is \*(``new curses\*('' (ncurses) and
-is the approved replacement for
-4.4BSD classic curses, which has been discontinued.
-This describes \fBncurses\fR
-version @NCURSES_MAJOR@.@NCURSES_MINOR@ (patch @NCURSES_PATCH@).
-.PP
-The \fBncurses\fR library emulates the curses library of
-System V Release 4 UNIX,
-and XPG4 (X/Open Portability Guide) curses (also known as XSI curses).
-XSI stands for X/Open System Interfaces Extension.
-The \fBncurses\fR library is freely redistributable in source form.
-Differences from the SVr4
-curses are summarized under the
-\fBEXTENSIONS\fP and \fBPORTABILITY\fP sections below and
-described in detail in the respective
-\fBEXTENSIONS\fP, \fBPORTABILITY\fP and \fBBUGS\fP sections
-of individual man pages.
-.PP
-The \fBncurses\fR library also provides many useful extensions,
-i.e., features which cannot be implemented by a simple add-on library
-but which require access to the internals of the library.
-.PP
-A program using these routines must be linked with the \fB\-lncurses\fR option,
-or (if it has been generated) with the debugging library \fB\-lncurses_g\fR.
-(Your system integrator may also have installed these libraries under
-the names \fB\-lcurses\fR and \fB\-lcurses_g\fR.)
-The ncurses_g library generates trace logs (in a file called 'trace' in the
-current directory) that describe curses actions.
-See also the section on \fBALTERNATE CONFIGURATIONS\fP.
-.PP
-The \fBncurses\fR package supports: overall screen, window and pad
-manipulation; output to windows and pads; reading terminal input; control over
-terminal and \fBcurses\fR input and output options; environment query
-routines; color manipulation; use of soft label keys; terminfo capabilities;
-and access to low-level terminal-manipulation routines.
-.SS Initialization
-.PP
-The library uses the locale which the calling program has initialized.
-That is normally done with \fBsetlocale\fP:
-.NS
-\fBsetlocale(LC_ALL, "");\fP
-.NE
-.PP
-If the locale is not initialized,
-the library assumes that characters are printable as in ISO\-8859\-1,
+The \*(``new curses\*('' library offers the programmer a
+terminal-independent means of reading keyboard and mouse input and
+updating character-cell terminals with output optimized to minimize
+screen updates.
+.I \%ncurses
+replaces the
+.I curses
+libraries from
+System V Release 4 Unix (\*(``SVr4\*('')
+and
+4.4BSD Unix,
+the development of which ceased in the 1990s.
+This document describes
+.I \%ncurses
+version @NCURSES_MAJOR@.@NCURSES_MINOR@
+(patch @NCURSES_PATCH@).
+.PP
+.I \%ncurses
+permits control of the terminal screen's contents;
+abstraction and subdivision thereof with
+.I windows
+and
+.IR pads ;
+the reading of terminal input;
+control of terminal input and output options;
+environment query routines;
+color manipulation;
+the definition and use of
+.I "soft label"
+keys;
+.I \%term\%info
+capability access;
+a
+.I termcap
+compatibility interface;
+and an abstraction of the system's API for manipulating the terminal
+(such as \fI\%termios\fP(3)).
+.PP
+.I \%ncurses
+implements the standard interface described by
+X/Open Curses Issue\ 7.
+In many behavioral details not standardized by X/Open,
+.I \%ncurses
+emulates the
+.I curses
+library of SVr4 and provides numerous useful extensions.
+.PP
+.I \%ncurses
+man pages employ several sections to clarify matters of usage and
+interoperability with other
+.I curses
+implementations.
+.bP
+\*(``NOTES\*('' describes issues and caveats of which any user of the
+.I \%ncurses
+API should be aware,
+such as limitations on the size of an underlying integral type or the
+availability of a preprocessor macro exclusive of a function definition
+(which prevents its address from being taken).
+This section also describes implementation details that will be
+significant to the programmer but which are not standardized.
+.bP
+\*(``EXTENSIONS\*('' presents
+.I \%ncurses
+innovations beyond the X/Open Curses standard and/or the SVr4
+.I curses
+implementation.
+They are termed
+.I extensions
+to indicate that they cannot be implemented solely by using the library
+API,
+but require access to the library's internal state.
+.bP
+\*(``PORTABILITY\*('' discusses matters
+(beyond the exercise of extensions)
+that should be considered when writing to a
+.I curses
+standard,
+or for multiple implementations.
+.bP
+\*(``HISTORY\*('' examines points of detail in
+.I \%ncurses
+and other
+.I curses
+implementations over the decades of their development,
+particularly where precedent or inertia have frustrated better design
+(and,
+in a few cases,
+where such inertia has been overcome).
+.PP
+A
+.I curses
+application must be linked with the library;
+use the
+.B \-lncurses
+option to your compiler or linker.
+A debugging version of the library may be available;
+if so,
+link with it using
+.BR \-lncurses_g .
+(Your system integrator may have installed these libraries such that you
+can use the options
+.B \-lcurses
+and
+.BR \-lcurses_g ,
+respectively.)
+The
+.I \%ncurses_g
+library generates trace logs
+(in a file called
+.I \%trace
+in the current directory)
+that describe
+.I \%ncurses
+actions.
+See section \*(``ALTERNATE CONFIGURATIONS\*('' below.
+.SS "Application Structure"
+A
+.I curses
+application uses information from the system locale;
+\fI\%setlocale\fP(3) prepares it for
+.I curses
+library calls.
+.PP
+.RS 4
+.EX
+setlocale(LC_ALL, "");
+.EE
+.RE
+.PP
+If the locale is not thus initialized,
+the library assumes that characters are printable as in ISO\ 8859-1,
 to work with certain legacy programs.
-You should initialize the locale and not rely on specific details of
-the library when the locale has not been setup.
-.PP
-The function \fBinitscr\fR or \fBnewterm\fR
-must be called to initialize the library
-before any of the other routines that deal with windows
-and screens are used.
-The routine \fBendwin\fR(3X) must be called before exiting.
-.PP
-To get character-at-a-time input without echoing (most
-interactive, screen oriented programs want this), the following
-sequence should be used:
-.NS
-\fBinitscr(); cbreak(); noecho();\fR
-.NE
-.PP
-Most programs would additionally use the sequence:
-.NS
-\fBintrflush(stdscr, FALSE);\fR
-\fBkeypad(stdscr, TRUE);\fR
-.NE
-.PP
-Before a \fBcurses\fR program is run, the tab stops of the terminal
-should be set and its initialization strings, if defined, must be output.
-This can be done by executing the \fB@TPUT@ init\fR command
-after the shell environment variable \fBTERM\fR has been exported.
-\fB@TSET@(1)\fR is usually responsible for doing this.
-[See \fBterminfo\fR(\*n) for further details.]
-.SS Datatypes
-.PP
-The \fBncurses\fR library permits manipulation of data structures,
-called \fIwindows\fR, which can be thought of as two-dimensional
-arrays of characters representing all or part of a CRT screen.
-A default window called \fBstdscr\fR, which is the size of the terminal
-screen, is supplied.
-Others may be created with \fBnewwin\fR.
-.PP
-Note that \fBcurses\fR does not handle overlapping windows, that's done by
-the \fBpanel\fR(3X) library.
-This means that you can either use
-\fBstdscr\fR or divide the screen into tiled windows and not using
-\fBstdscr\fR at all.
-Mixing the two will result in unpredictable, and undesired, effects.
-.PP
-Windows are referred to by variables declared as \fBWINDOW *\fR.
-These data structures are manipulated with routines described here and
-elsewhere in the \fBncurses\fR manual pages.
-Among those, the most basic
-routines are \fBmove\fR and \fBaddch\fR.
-More general versions of
-these routines are included with names beginning with \fBw\fR,
-allowing the user to specify a window.
-The routines not beginning
-with \fBw\fR affect \fBstdscr\fR.
-.PP
-After using routines to manipulate a window, \fBrefresh\fR(3X) is called,
-telling \fBcurses\fR to make the user's CRT screen look like
-\fBstdscr\fR.
-The characters in a window are actually of type
-\fBchtype\fR, (character and attribute data) so that other information
-about the character may also be stored with each character.
-.PP
-Special windows called \fIpads\fR may also be manipulated.
-These are windows
-which are not constrained to the size of the screen and whose contents need not
-be completely displayed.
-See \fBcurs_pad\fR(3X) for more information.
-.PP
-In addition to drawing characters on the screen, video attributes and colors
-may be supported, causing the characters to show up in such modes as
-underlined, in reverse video, or in color on terminals that support such
-display enhancements.
-Line drawing characters may be specified to be output.
-On input, \fBcurses\fR is also able to translate arrow and function keys that
-transmit escape sequences into single values.
-The video attributes, line
-drawing characters, and input values use names, defined in \fB<curses.h>\fR,
-such as \fBA_REVERSE\fR, \fBACS_HLINE\fR, and \fBKEY_LEFT\fR.
-.SS Environment variables
-.PP
-If the environment variables \fBLINES\fR and \fBCOLUMNS\fR are set, or if the
-program is executing in a window environment, line and column information in
-the environment will override information read by \fIterminfo\fR.
-This would affect a program running in an AT&T 630 layer,
-for example, where the size of a
-screen is changeable (see \fBENVIRONMENT\fR).
-.PP
-If the environment variable \fBTERMINFO\fR is defined, any program using
-\fBcurses\fR checks for a local terminal definition before checking in the
-standard place.
-For example, if \fBTERM\fR is set to \fBatt4424\fR, then the
-compiled terminal definition is found in
-.NS
-\fB\*d/a/att4424\fR.
-.NE
-.PP
-(The \fBa\fR is copied from the first letter of \fBatt4424\fR to avoid
-creation of huge directories.)  However, if \fBTERMINFO\fR is set to
-\fB$HOME/myterms\fR, \fBcurses\fR first checks
-.NS
-\fB$HOME/myterms/a/att4424\fR,
-.NE
-.PP
-and if that fails, it then checks
-.NS
-\fB\*d/a/att4424\fR.
-.NE
-.PP
-This is useful for developing experimental definitions or when write
-permission in \fB\*d\fR is not available.
-.PP
-The integer variables \fBLINES\fR and \fBCOLS\fR are defined in
-\fB<curses.h>\fR and will be filled in by \fBinitscr\fR with the size of the
-screen.
-The constants \fBTRUE\fR and \fBFALSE\fR have the values \fB1\fR and
-\fB0\fR, respectively.
-.PP
-The \fBcurses\fR routines also define the \fBWINDOW *\fR variable \fBcurscr\fR
-which is used for certain low-level operations like clearing and redrawing a
-screen containing garbage.
-The \fBcurscr\fR can be used in only a few routines.
-.\"
-.SS Routine and Argument Names
-Many \fBcurses\fR routines have two or more versions.
-The routines prefixed with \fBw\fR require a window argument.
-The routines prefixed with \fBp\fR require a pad argument.
-Those without a prefix generally use \fBstdscr\fR.
-.PP
-The routines prefixed with \fBmv\fR require a \fIy\fR and \fIx\fR
-coordinate to move to before performing the appropriate action.
-The \fBmv\fR routines imply a call to \fBmove\fR before the call to the
-other routine.
-The coordinate \fIy\fR always refers to the row (of
-the window), and \fIx\fR always refers to the column.
-The upper left-hand corner is always (0,0), not (1,1).
-.PP
-The routines prefixed with \fBmvw\fR take both a window argument and
-\fIx\fR and \fIy\fR coordinates.
-The window argument is always specified before the coordinates.
-.PP
-In each case, \fIwin\fR is the window affected, and \fIpad\fR is the
-pad affected; \fIwin\fR and \fIpad\fR are always pointers to type
-\fBWINDOW\fR.
-.PP
-Option setting routines require a Boolean flag \fIbf\fR with the value
-\fBTRUE\fR or \fBFALSE\fR; \fIbf\fR is always of type \fBbool\fR.
-Most of the data types used in the library routines,
-such as \fBWINDOW\fR, \fBSCREEN\fR, \fBbool\fR, and \fBchtype\fR
-are defined in \fB<curses.h>\fR.
-Types used for the terminfo routines such as
-\fBTERMINAL\fR are defined in \fB<term.h>\fR.
-.PP
-This manual page describes functions which may appear in any configuration
+You should initialize the locale;
+do not expect consistent behavior from the library when the locale has
+not been set up.
+.PP
+\fB\%initscr\fP(3X) or \fB\%newterm\fP(3X)
+must be called to initialize
+.I curses
+before use of any functions that deal with windows and screens.
+.PP
+To get character-at-a-time input without echoing\(emmost interactive,
+screen-oriented programs want this\(emuse the following sequence.
+.PP
+.RS 4
+.EX
+initscr(); cbreak(); noecho();
+.EE
+.RE
+.PP
+Most applications perform further setup as follows.
+.PP
+.RS 4
+.EX
+intrflush(stdscr, FALSE);
+keypad(stdscr, TRUE);
+.EE
+.RE
+.PP
+A
+.I curses
+program then often enters an event loop of some sort.
+Call \fB\%endwin\fP(3X) before exiting.
+.SS Overview
+A
+.I curses
+library abstracts the terminal screen by representing all or part of it
+as a
+.I \%WINDOW
+data structure.
+A
+.I window
+is a rectangular grid of character cells,
+addressed by row and column coordinates
+.RI ( y ,
+.IR x ),
+with the upper left corner as (0, 0).
+A window called
+.BR \%stdscr ,
+the same size as the terminal screen,
+is always available.
+Create others with \fB\%newwin\fP(3X).
+.PP
+A
+.I curses
+library does not manage overlapping windows
+(but see below).
+You can either use
+.B \%stdscr
+to manage one screen-filling window,
+or tile the screen into non-overlapping windows and not use
+.B \%stdscr
+at all.
+Mixing the two approaches will result in unpredictable and undesired
+effects.
+.PP
+Functions permit manipulation of a window and the
+.I cursor
+identifying the cell within it at which the next output operation will
+occur.
+Among those,
+the most basic are \fB\%move\fP(3X) and \fB\%addch\fP(3X):
+these place the cursor and write a character to
+.BR \%stdscr ,
+respectively.
+.PP
+Frequent changes to the terminal screen can cause unpleasant flicker or
+inefficient use of the communication channel to the device,
+so the library does not generally update it automatically.
+Therefore,
+after using
+.I curses
+functions to accumulate a set of desired updates that make sense to
+present together,
+call \fB\%refresh\fP(3X) to tell the library to make the user's screen
+look like \fBstdscr\fP.
+The library
+.\" X/Open Curses Issue 7 assumes some optimization will be done, but
+.\" does not mandate it in any way.
+.I optimizes
+its output by computing a minimal number of operations to mutate the
+screen from its state at the previous refresh to the new one.
+Effective optimization demands accurate information about the terminal
+device:
+the management of such information is the province of the
+\fB\%terminfo\fP(3X) API,
+a feature of every standard
+.I curses
+implementation.
+.PP
+Special windows called
+.I pads
+may also be manipulated.
+These are windows that are not constrained to the size of the terminal
+screen and whose contents need not be completely displayed.
+See \fB\%curs_pad\fP(3X).
+.PP
+In addition to drawing characters on the screen,
+rendering attributes and colors may be supported,
+causing the characters to show up in such modes as underlined,
+in reverse video,
+or in color on terminals that support such display enhancements.
+See \fB\%curs_attr\fP(3X).
+.PP
+.I curses
+predefines constants for a small set of forms-drawing graphics
+corresponding to the DEC Alternate Character Set (ACS),
+a feature of VT100 and other terminals.
+See \fB\%waddch\fP(3X).
+.PP
+.I curses
+is implemented using the operating system's terminal driver;
+keystroke events are received not as scan codes but as byte sequences.
+Graphical keycaps
+(alphanumeric and punctuation keys,
+and the space)
+appear as-is.
+Everything else,
+including the tab,
+enter/return,
+keypad,
+arrow,
+and function keys,
+appears as a control character or a multibyte
+.I "escape sequence."
+.I curses
+translates these into unique
+.I "key codes."
+See \fB\%getch\fP(3X).
+.PP
+.I \%ncurses
+provides reimplementations of the SVr4 \fBpanel\fP(3X), \fBform\fP(3X),
+and \fBmenu\fP(3X) libraries to ease construction of user interfaces
+with
+.IR curses .
+.SS "Initialization"
+The selection of an appropriate value of
+.I TERM
+in the process environment is essential to correct
+.I curses
+and
+.I \%term\%info
+library operation.
+A well-configured system selects a correct
+.I TERM
+value automatically;
+\fB\%tset\fP(1) may assist with troubleshooting exotic situations.
+.PP
+If you change the terminal type,
+export the
+.I TERM
+environment variable in the shell,
+then run \fB\%tset\fP(1) or the
+.RB \*(`` "@TPUT@ init" \*(''
+command.
+See subsection \*(``Tabs and Initialization\*('' of \fB\%terminfo\fP(5).
+.PP
+If the environment variables
+.I \%LINES
+and
+.I \%COLUMNS
+are set,
+or if the
+.I curses
+program is executing in a graphical windowing environment,
+the information obtained thence overrides that obtained by
+.IR \%term\%info .
+An
+.I \%ncurses
+extension supports resizable terminals;
+see \fB\%wresize\fP(3X).
+.PP
+If the environment variable
+.I \%TERMINFO
+is defined,
+a
+.I curses
+program checks first for a terminal type description in the location it
+identifies.
+.I \%TERMINFO
+is useful for developing experimental type descriptions or when write
+permission to
+.I \%\*d
+is not available.
+.PP
+See section \*(``ENVIRONMENT\*('' below.
+.SS "Naming Conventions"
+.I curses
+offers many functions in variant forms using a regular set of
+alternatives to the name of an elemental one.
+Those prefixed with \*(``w\*('' require a
+.I \%WINDOW
+pointer argument;
+those with a \*(``mv\*('' prefix first perform cursor movement using
+\fB\%wmove\fP(3X);
+a \*(``mvw\*('' prefix indicates both.
+The \*(``w\*('' function is typically the elemental one;
+the removal of this prefix usually indicates operation on
+.BR \%stdscr .
+.PP
+Four functions prefixed with \*(``p\*('' require a pad argument.
+.PP
+In function synopses,
+.I \%ncurses
+man pages apply the following names to parameters.
+.PP
+.TS
+center;
+Li L.
+bf	\fIbool\fP (\fBTRUE\fP or \fBFALSE\fP)
+c	a \fIchar\fP or \fIint\fP
+ch	a \fIchtype\fP
+wc	a \fIwchar_t\fP or \fIwint_t\fP
+wch	a \fIcchar_t\fP
+win	pointer to a \fIWINDOW\fP
+pad	pointer to a \fIWINDOW\fP that is a pad
+.TE
+.SS "Wide and Non-wide Character Configurations"
+This manual page describes functions that appear in any configuration
 of the library.
-There are two common configurations of the library:
-.RS 3
-.TP 5
-.I ncurses
-the \*(``normal\*('' library, which handles 8-bit characters.
-The normal (8-bit) library stores characters combined with attributes
-in \fBchtype\fP data.
-.IP
-Attributes alone (no corresponding character) may be stored in \fBchtype\fP
-or the equivalent \fBattr_t\fP data.
-In either case, the data is stored in something like an integer.
+There are two common configurations;
+see section \*(``ALTERNATE CONFIGURATIONS\*('' below.
+.TP 10 \" "ncursesw" + 2n
+.I \%ncurses
+is the library in its \*(``non-wide\*('' configuration,
+handling only eight-bit characters.
+It stores a character combined with attributes in a
+.I \%chtype
+datum,
+which is often an alias of
+.IR int .
 .IP
-Each cell (row and column) in a \fBWINDOW\fP is stored as a \fBchtype\fP.
-.TP 5
-.I ncursesw
-the so-called \*(``wide\*('' library, which handles multibyte characters
-(see the section on \fBALTERNATE CONFIGURATIONS\fP).
-The \*(``wide\*('' library includes all of the calls
-from the \*(``normal\*('' library.
-It adds about one third more calls using data types which store
-multibyte characters:
-.RS 5
-.TP 5
-.B cchar_t
-corresponds to \fBchtype\fP.
-However it is a structure, because more data is stored than can fit into
-an integer.
-The characters are large enough to require a full integer value \- and there
-may be more than one character per cell.
-The video attributes and color are stored in separate fields of the structure.
+Attributes alone
+(with no corresponding character)
+can be stored in variables of
+.I \%chtype
+or
+.I \%attr_t
+type.
+In either case,
+they are represented as an integral bit mask.
 .IP
-Each cell (row and column) in a \fBWINDOW\fP is stored as a \fBcchar_t\fP.
-.IP
-The \fBsetcchar\fP(3X) and \fBgetcchar\fP(3X)
-functions store and retrieve the data from
-a \fBcchar_t\fP structure.
-.TP 5
-.B wchar_t
-stores a \*(``wide\*('' character.
-Like \fBchtype\fP, this may be an integer.
-.TP 5
-.B wint_t
-stores a \fBwchar_t\fP or \fBWEOF\fP \- not the same, though both may have
-the same size.
+Each cell of a
+.I \%WINDOW
+is stored as a
+.IR \%chtype .
+.TP 10
+.I \%ncursesw
+is the library in its \*(``wide\*('' configuration,
+which handles character encodings requiring a larger data type than
+.I \%char
+(a byte-sized type)
+can represent.
+It adds about one third more calls using additional data types that
+can store such
+.I multibyte
+characters.
+.RS 10 \" same as foregoing tag width
+.TP 9 \" "cchar_t" + 2n
+.I \%cchar_t
+corresponds to the non-wide configuration's
+.IR \%chtype .
+It always a structure type,
+because it stores more data than fit into a standard scalar type.
+A character code may not be representable as a
+.IR \%char ,
+and moreover more than one character may occupy a cell
+(as with accent marks and other diacritics).
+Each character is of type
+.IR \%wchar_t ;
+a complex character contains one spacing character and zero or more
+non-spacing characters
+(see below).
+Attributes and color data are stored in separate fields of the
+structure,
+not combined as in
+.IR \%chtype .
+.PP
+Each cell of a
+.I \%WINDOW
+is stored as a
+.IR \%cchar_t .
+.PP
+\fB\%setcchar\fP(3X) and \fB\%getcchar\fP(3X)
+store and retrieve
+.I \%cchar_t
+data.
+The wide library API of
+.I \%ncurses
+depends on two data types standardized by ISO C95.
+.TP 9
+.I \%wchar_t
+stores a wide character.
+Like
+.IR \%chtype ,
+it may be an alias of
+.IR int .
+Depending on the character encoding,
+a wide character may be
+.IR spacing ,
+meaning that it occupies a character cell by itself and typically
+accompanies cursor advancement,
+or
+.IR non-spacing ,
+meaning that it occupies the same cell as a spacing character,
+is often regarded as a \*(``modifier\*('' of the base glyph with which
+it combines,
+and typically does not advance the cursor.
+.TP 9
+.I \%wint_t
+can store a
+.I \%wchar_t
+or the constant
+.BR \%WEOF ,
+analogously to the
+.IR int -sized
+character manipulation functions of ISO C and its constant
+.BR \%EOF .
 .RE
 .IP
-The \*(``wide\*('' library provides new functions which are analogous to
-functions in the \*(``normal\*('' library.
-There is a naming convention which relates many of the normal/wide variants:
-a \*(``_w\*('' is inserted into the name.
-For example, \fBwaddch\fP becomes \fBwadd_wch\fP.
-.RE
-.PP
+The wide library provides additional functions that complement those in
+the non-wide library where the size of the underlying character type is
+significant.
+A somewhat regular naming convention relates many of the wide variants
+to their non-wide counterparts;
+where a non-wide function name contains \*(``ch\*('' or \*(``str\*('',
+prefix it with \*(``_w\*('' to obtain the wide counterpart.
+For example,
+\fB\%waddch\fP becomes \fB\%wadd_wch\fP.
+(Exceptions that add only \*(``w\*('' comprise
+.BR \%addwstr ,
+.BR \%inwstr ,
+and their variants.)
+.IP
+This convention is inapplicable to some non-wide function names,
+so other transformations are used for the wide configuration:
+the window background management function \*(``bkgd\*('' becomes
+\*(``bkgrnd\*('';
+the window border-drawing and -clearing functions are suffixed with
+\*(``_set\*('';
+and character attribute manipulation functions like
+\*(``attron\*('' become \*(``attr_on\*(''.
 .\"
-.SS Routine Name Index
-The following table lists the \fBcurses\fR routines provided in
-the \*(``normal\*('' and \*(``wide\*('' libraries and the names of
-the manual pages on which they are described.
-Routines flagged with \*(``*\*(''
-are ncurses-specific, not described by XPG4 or present in SVr4.
+.SS "Function Name Index"
+The following table lists the
+.I curses
+functions provided in the non-wide and wide APIs and the corresponding
+man pages that describe them.
+Those flagged with \*(``*\*(''
+are
+.IR \%ncurses "-specific,"
+neither described by X/Open Curses nor present in SVr4.
 .PP
 .TS
 center tab(/);
-l l
 l l .
-\fBcurses\fR Routine Name/Manual Page Name
-=
-COLOR_PAIR/\fBcurs_color\fR(3X)
-PAIR_NUMBER/\fBcurs_attr\fR(3X)
-add_wch/\fBcurs_add_wch\fR(3X)
-add_wchnstr/\fBcurs_add_wchstr\fR(3X)
-add_wchstr/\fBcurs_add_wchstr\fR(3X)
-addch/\fBcurs_addch\fR(3X)
-addchnstr/\fBcurs_addchstr\fR(3X)
-addchstr/\fBcurs_addchstr\fR(3X)
-addnstr/\fBcurs_addstr\fR(3X)
-addnwstr/\fBcurs_addwstr\fR(3X)
-addstr/\fBcurs_addstr\fR(3X)
-addwstr/\fBcurs_addwstr\fR(3X)
-alloc_pair/\fBnew_pair\fR(3X)*
-assume_default_colors/\fBdefault_colors\fR(3X)*
-attr_get/\fBcurs_attr\fR(3X)
-attr_off/\fBcurs_attr\fR(3X)
-attr_on/\fBcurs_attr\fR(3X)
-attr_set/\fBcurs_attr\fR(3X)
-attroff/\fBcurs_attr\fR(3X)
-attron/\fBcurs_attr\fR(3X)
-attrset/\fBcurs_attr\fR(3X)
-baudrate/\fBcurs_termattrs\fR(3X)
-beep/\fBcurs_beep\fR(3X)
-bkgd/\fBcurs_bkgd\fR(3X)
-bkgdset/\fBcurs_bkgd\fR(3X)
-bkgrnd/\fBcurs_bkgrnd\fR(3X)
-bkgrndset/\fBcurs_bkgrnd\fR(3X)
-border/\fBcurs_border\fR(3X)
-border_set/\fBcurs_border_set\fR(3X)
-box/\fBcurs_border\fR(3X)
-box_set/\fBcurs_border_set\fR(3X)
-can_change_color/\fBcurs_color\fR(3X)
-cbreak/\fBcurs_inopts\fR(3X)
-chgat/\fBcurs_attr\fR(3X)
-clear/\fBcurs_clear\fR(3X)
-clearok/\fBcurs_outopts\fR(3X)
-clrtobot/\fBcurs_clear\fR(3X)
-clrtoeol/\fBcurs_clear\fR(3X)
-color_content/\fBcurs_color\fR(3X)
-color_set/\fBcurs_attr\fR(3X)
-copywin/\fBcurs_overlay\fR(3X)
-curs_set/\fBcurs_kernel\fR(3X)
-curses_trace/\fBcurs_trace\fR(3X)*
-curses_version/\fBcurs_extend\fR(3X)*
-def_prog_mode/\fBcurs_kernel\fR(3X)
-def_shell_mode/\fBcurs_kernel\fR(3X)
-define_key/\fBdefine_key\fR(3X)*
-del_curterm/\fBcurs_terminfo\fR(3X)
-delay_output/\fBcurs_util\fR(3X)
-delch/\fBcurs_delch\fR(3X)
-deleteln/\fBcurs_deleteln\fR(3X)
-delscreen/\fBcurs_initscr\fR(3X)
-delwin/\fBcurs_window\fR(3X)
-derwin/\fBcurs_window\fR(3X)
-doupdate/\fBcurs_refresh\fR(3X)
-dupwin/\fBcurs_window\fR(3X)
-echo/\fBcurs_inopts\fR(3X)
-echo_wchar/\fBcurs_add_wch\fR(3X)
-echochar/\fBcurs_addch\fR(3X)
-endwin/\fBcurs_initscr\fR(3X)
-erase/\fBcurs_clear\fR(3X)
-erasechar/\fBcurs_termattrs\fR(3X)
-erasewchar/\fBcurs_termattrs\fR(3X)
-exit_curses/\fBcurs_memleaks\fR(3X)*
-exit_terminfo/\fBcurs_memleaks\fR(3X)*
-extended_color_content/\fBcurs_color\fR(3X)*
-extended_pair_content/\fBcurs_color\fR(3X)*
-extended_slk_color/\fBcurs_slk\fR(3X)*
-filter/\fBcurs_util\fR(3X)
-find_pair/\fBnew_pair\fR(3X)*
-flash/\fBcurs_beep\fR(3X)
-flushinp/\fBcurs_util\fR(3X)
-free_pair/\fBnew_pair\fR(3X)*
-get_wch/\fBcurs_get_wch\fR(3X)
-get_wstr/\fBcurs_get_wstr\fR(3X)
-getattrs/\fBcurs_attr\fR(3X)
-getbegx/\fBcurs_legacy\fR(3X)*
-getbegy/\fBcurs_legacy\fR(3X)*
-getbegyx/\fBcurs_getyx\fR(3X)
-getbkgd/\fBcurs_bkgd\fR(3X)
-getbkgrnd/\fBcurs_bkgrnd\fR(3X)
-getcchar/\fBcurs_getcchar\fR(3X)
-getch/\fBcurs_getch\fR(3X)
-getcurx/\fBcurs_legacy\fR(3X)*
-getcury/\fBcurs_legacy\fR(3X)*
-getmaxx/\fBcurs_legacy\fR(3X)*
-getmaxy/\fBcurs_legacy\fR(3X)*
-getmaxyx/\fBcurs_getyx\fR(3X)
-getmouse/\fBcurs_mouse\fR(3X)*
-getn_wstr/\fBcurs_get_wstr\fR(3X)
-getnstr/\fBcurs_getstr\fR(3X)
-getparx/\fBcurs_legacy\fR(3X)*
-getpary/\fBcurs_legacy\fR(3X)*
-getparyx/\fBcurs_getyx\fR(3X)
-getstr/\fBcurs_getstr\fR(3X)
-getsyx/\fBcurs_kernel\fR(3X)
-getwin/\fBcurs_util\fR(3X)
-getyx/\fBcurs_getyx\fR(3X)
-halfdelay/\fBcurs_inopts\fR(3X)
-has_colors/\fBcurs_color\fR(3X)
-has_ic/\fBcurs_termattrs\fR(3X)
-has_il/\fBcurs_termattrs\fR(3X)
-has_key/\fBcurs_getch\fR(3X)*
-has_mouse/\fBcurs_mouse\fR(3X)*
-hline/\fBcurs_border\fR(3X)
-hline_set/\fBcurs_border_set\fR(3X)
-idcok/\fBcurs_outopts\fR(3X)
-idlok/\fBcurs_outopts\fR(3X)
-immedok/\fBcurs_outopts\fR(3X)
-in_wch/\fBcurs_in_wch\fR(3X)
-in_wchnstr/\fBcurs_in_wchstr\fR(3X)
-in_wchstr/\fBcurs_in_wchstr\fR(3X)
-inch/\fBcurs_inch\fR(3X)
-inchnstr/\fBcurs_inchstr\fR(3X)
-inchstr/\fBcurs_inchstr\fR(3X)
-init_color/\fBcurs_color\fR(3X)
-init_extended_color/\fBcurs_color\fR(3X)*
-init_extended_pair/\fBcurs_color\fR(3X)*
-init_pair/\fBcurs_color\fR(3X)
-initscr/\fBcurs_initscr\fR(3X)
-innstr/\fBcurs_instr\fR(3X)
-innwstr/\fBcurs_inwstr\fR(3X)
-ins_nwstr/\fBcurs_ins_wstr\fR(3X)
-ins_wch/\fBcurs_ins_wch\fR(3X)
-ins_wstr/\fBcurs_ins_wstr\fR(3X)
-insch/\fBcurs_insch\fR(3X)
-insdelln/\fBcurs_deleteln\fR(3X)
-insertln/\fBcurs_deleteln\fR(3X)
-insnstr/\fBcurs_insstr\fR(3X)
-insstr/\fBcurs_insstr\fR(3X)
-instr/\fBcurs_instr\fR(3X)
-intrflush/\fBcurs_inopts\fR(3X)
-inwstr/\fBcurs_inwstr\fR(3X)
-is_cleared/\fBcurs_opaque\fR(3X)*
-is_idcok/\fBcurs_opaque\fR(3X)*
-is_idlok/\fBcurs_opaque\fR(3X)*
-is_immedok/\fBcurs_opaque\fR(3X)*
-is_keypad/\fBcurs_opaque\fR(3X)*
-is_leaveok/\fBcurs_opaque\fR(3X)*
-is_linetouched/\fBcurs_touch\fR(3X)
-is_nodelay/\fBcurs_opaque\fR(3X)*
-is_notimeout/\fBcurs_opaque\fR(3X)*
-is_pad/\fBcurs_opaque\fR(3X)*
-is_scrollok/\fBcurs_opaque\fR(3X)*
-is_subwin/\fBcurs_opaque\fR(3X)*
-is_syncok/\fBcurs_opaque\fR(3X)*
-is_term_resized/\fBresizeterm\fR(3X)*
-is_wintouched/\fBcurs_touch\fR(3X)
-isendwin/\fBcurs_initscr\fR(3X)
-key_defined/\fBkey_defined\fR(3X)*
-key_name/\fBcurs_util\fR(3X)
-keybound/\fBkeybound\fR(3X)*
-keyname/\fBcurs_util\fR(3X)
-keyok/\fBkeyok\fR(3X)*
-keypad/\fBcurs_inopts\fR(3X)
-killchar/\fBcurs_termattrs\fR(3X)
-killwchar/\fBcurs_termattrs\fR(3X)
-leaveok/\fBcurs_outopts\fR(3X)
-longname/\fBcurs_termattrs\fR(3X)
-mcprint/\fBcurs_print\fR(3X)*
-meta/\fBcurs_inopts\fR(3X)
-mouse_trafo/\fBcurs_mouse\fR(3X)*
-mouseinterval/\fBcurs_mouse\fR(3X)*
-mousemask/\fBcurs_mouse\fR(3X)*
-move/\fBcurs_move\fR(3X)
-mvadd_wch/\fBcurs_add_wch\fR(3X)
-mvadd_wchnstr/\fBcurs_add_wchstr\fR(3X)
-mvadd_wchstr/\fBcurs_add_wchstr\fR(3X)
-mvaddch/\fBcurs_addch\fR(3X)
-mvaddchnstr/\fBcurs_addchstr\fR(3X)
-mvaddchstr/\fBcurs_addchstr\fR(3X)
-mvaddnstr/\fBcurs_addstr\fR(3X)
-mvaddnwstr/\fBcurs_addwstr\fR(3X)
-mvaddstr/\fBcurs_addstr\fR(3X)
-mvaddwstr/\fBcurs_addwstr\fR(3X)
-mvchgat/\fBcurs_attr\fR(3X)
-mvcur/\fBcurs_terminfo\fR(3X)
-mvdelch/\fBcurs_delch\fR(3X)
-mvderwin/\fBcurs_window\fR(3X)
-mvget_wch/\fBcurs_get_wch\fR(3X)
-mvget_wstr/\fBcurs_get_wstr\fR(3X)
-mvgetch/\fBcurs_getch\fR(3X)
-mvgetn_wstr/\fBcurs_get_wstr\fR(3X)
-mvgetnstr/\fBcurs_getstr\fR(3X)
-mvgetstr/\fBcurs_getstr\fR(3X)
-mvhline/\fBcurs_border\fR(3X)
-mvhline_set/\fBcurs_border_set\fR(3X)
-mvin_wch/\fBcurs_in_wch\fR(3X)
-mvin_wchnstr/\fBcurs_in_wchstr\fR(3X)
-mvin_wchstr/\fBcurs_in_wchstr\fR(3X)
-mvinch/\fBcurs_inch\fR(3X)
-mvinchnstr/\fBcurs_inchstr\fR(3X)
-mvinchstr/\fBcurs_inchstr\fR(3X)
-mvinnstr/\fBcurs_instr\fR(3X)
-mvinnwstr/\fBcurs_inwstr\fR(3X)
-mvins_nwstr/\fBcurs_ins_wstr\fR(3X)
-mvins_wch/\fBcurs_ins_wch\fR(3X)
-mvins_wstr/\fBcurs_ins_wstr\fR(3X)
-mvinsch/\fBcurs_insch\fR(3X)
-mvinsnstr/\fBcurs_insstr\fR(3X)
-mvinsstr/\fBcurs_insstr\fR(3X)
-mvinstr/\fBcurs_instr\fR(3X)
-mvinwstr/\fBcurs_inwstr\fR(3X)
-mvprintw/\fBcurs_printw\fR(3X)
-mvscanw/\fBcurs_scanw\fR(3X)
-mvvline/\fBcurs_border\fR(3X)
-mvvline_set/\fBcurs_border_set\fR(3X)
-mvwadd_wch/\fBcurs_add_wch\fR(3X)
-mvwadd_wchnstr/\fBcurs_add_wchstr\fR(3X)
-mvwadd_wchstr/\fBcurs_add_wchstr\fR(3X)
-mvwaddch/\fBcurs_addch\fR(3X)
-mvwaddchnstr/\fBcurs_addchstr\fR(3X)
-mvwaddchstr/\fBcurs_addchstr\fR(3X)
-mvwaddnstr/\fBcurs_addstr\fR(3X)
-mvwaddnwstr/\fBcurs_addwstr\fR(3X)
-mvwaddstr/\fBcurs_addstr\fR(3X)
-mvwaddwstr/\fBcurs_addwstr\fR(3X)
-mvwchgat/\fBcurs_attr\fR(3X)
-mvwdelch/\fBcurs_delch\fR(3X)
-mvwget_wch/\fBcurs_get_wch\fR(3X)
-mvwget_wstr/\fBcurs_get_wstr\fR(3X)
-mvwgetch/\fBcurs_getch\fR(3X)
-mvwgetn_wstr/\fBcurs_get_wstr\fR(3X)
-mvwgetnstr/\fBcurs_getstr\fR(3X)
-mvwgetstr/\fBcurs_getstr\fR(3X)
-mvwhline/\fBcurs_border\fR(3X)
-mvwhline_set/\fBcurs_border_set\fR(3X)
-mvwin/\fBcurs_window\fR(3X)
-mvwin_wch/\fBcurs_in_wch\fR(3X)
-mvwin_wchnstr/\fBcurs_in_wchstr\fR(3X)
-mvwin_wchstr/\fBcurs_in_wchstr\fR(3X)
-mvwinch/\fBcurs_inch\fR(3X)
-mvwinchnstr/\fBcurs_inchstr\fR(3X)
-mvwinchstr/\fBcurs_inchstr\fR(3X)
-mvwinnstr/\fBcurs_instr\fR(3X)
-mvwinnwstr/\fBcurs_inwstr\fR(3X)
-mvwins_nwstr/\fBcurs_ins_wstr\fR(3X)
-mvwins_wch/\fBcurs_ins_wch\fR(3X)
-mvwins_wstr/\fBcurs_ins_wstr\fR(3X)
-mvwinsch/\fBcurs_insch\fR(3X)
-mvwinsnstr/\fBcurs_insstr\fR(3X)
-mvwinsstr/\fBcurs_insstr\fR(3X)
-mvwinstr/\fBcurs_instr\fR(3X)
-mvwinwstr/\fBcurs_inwstr\fR(3X)
-mvwprintw/\fBcurs_printw\fR(3X)
-mvwscanw/\fBcurs_scanw\fR(3X)
-mvwvline/\fBcurs_border\fR(3X)
-mvwvline_set/\fBcurs_border_set\fR(3X)
-napms/\fBcurs_kernel\fR(3X)
-newpad/\fBcurs_pad\fR(3X)
-newterm/\fBcurs_initscr\fR(3X)
-newwin/\fBcurs_window\fR(3X)
-nl/\fBcurs_inopts\fR(3X)
-nocbreak/\fBcurs_inopts\fR(3X)
-nodelay/\fBcurs_inopts\fR(3X)
-noecho/\fBcurs_inopts\fR(3X)
-nofilter/\fBcurs_util\fR(3X)*
-nonl/\fBcurs_inopts\fR(3X)
-noqiflush/\fBcurs_inopts\fR(3X)
-noraw/\fBcurs_inopts\fR(3X)
-notimeout/\fBcurs_inopts\fR(3X)
-overlay/\fBcurs_overlay\fR(3X)
-overwrite/\fBcurs_overlay\fR(3X)
-pair_content/\fBcurs_color\fR(3X)
-pecho_wchar/\fBcurs_pad\fR(3X)*
-pechochar/\fBcurs_pad\fR(3X)
-pnoutrefresh/\fBcurs_pad\fR(3X)
-prefresh/\fBcurs_pad\fR(3X)
-printw/\fBcurs_printw\fR(3X)
-putp/\fBcurs_terminfo\fR(3X)
-putwin/\fBcurs_util\fR(3X)
-qiflush/\fBcurs_inopts\fR(3X)
-raw/\fBcurs_inopts\fR(3X)
-redrawwin/\fBcurs_refresh\fR(3X)
-refresh/\fBcurs_refresh\fR(3X)
-reset_color_pairs/\fBcurs_color\fR(3X)*
-reset_prog_mode/\fBcurs_kernel\fR(3X)
-reset_shell_mode/\fBcurs_kernel\fR(3X)
-resetty/\fBcurs_kernel\fR(3X)
-resize_term/\fBresizeterm\fR(3X)*
-resizeterm/\fBresizeterm\fR(3X)*
-restartterm/\fBcurs_terminfo\fR(3X)
-ripoffline/\fBcurs_kernel\fR(3X)
-savetty/\fBcurs_kernel\fR(3X)
-scanw/\fBcurs_scanw\fR(3X)
-scr_dump/\fBcurs_scr_dump\fR(3X)
-scr_init/\fBcurs_scr_dump\fR(3X)
-scr_restore/\fBcurs_scr_dump\fR(3X)
-scr_set/\fBcurs_scr_dump\fR(3X)
-scrl/\fBcurs_scroll\fR(3X)
-scroll/\fBcurs_scroll\fR(3X)
-scrollok/\fBcurs_outopts\fR(3X)
-set_curterm/\fBcurs_terminfo\fR(3X)
-set_term/\fBcurs_initscr\fR(3X)
-setcchar/\fBcurs_getcchar\fR(3X)
-setscrreg/\fBcurs_outopts\fR(3X)
-setsyx/\fBcurs_kernel\fR(3X)
-setupterm/\fBcurs_terminfo\fR(3X)
-slk_attr/\fBcurs_slk\fR(3X)*
-slk_attr_off/\fBcurs_slk\fR(3X)
-slk_attr_on/\fBcurs_slk\fR(3X)
-slk_attr_set/\fBcurs_slk\fR(3X)
-slk_attroff/\fBcurs_slk\fR(3X)
-slk_attron/\fBcurs_slk\fR(3X)
-slk_attrset/\fBcurs_slk\fR(3X)
-slk_clear/\fBcurs_slk\fR(3X)
-slk_color/\fBcurs_slk\fR(3X)
-slk_init/\fBcurs_slk\fR(3X)
-slk_label/\fBcurs_slk\fR(3X)
-slk_noutrefresh/\fBcurs_slk\fR(3X)
-slk_refresh/\fBcurs_slk\fR(3X)
-slk_restore/\fBcurs_slk\fR(3X)
-slk_set/\fBcurs_slk\fR(3X)
-slk_touch/\fBcurs_slk\fR(3X)
-slk_wset/\fBcurs_slk\fR(3X)*
-standend/\fBcurs_attr\fR(3X)
-standout/\fBcurs_attr\fR(3X)
-start_color/\fBcurs_color\fR(3X)
-subpad/\fBcurs_pad\fR(3X)
-subwin/\fBcurs_window\fR(3X)
-syncok/\fBcurs_window\fR(3X)
-term_attrs/\fBcurs_termattrs\fR(3X)
-termattrs/\fBcurs_termattrs\fR(3X)
-termname/\fBcurs_termattrs\fR(3X)
-tgetent/\fBcurs_termcap\fR(3X)
-tgetflag/\fBcurs_termcap\fR(3X)
-tgetnum/\fBcurs_termcap\fR(3X)
-tgetstr/\fBcurs_termcap\fR(3X)
-tgoto/\fBcurs_termcap\fR(3X)
-tigetflag/\fBcurs_terminfo\fR(3X)
-tigetnum/\fBcurs_terminfo\fR(3X)
-tigetstr/\fBcurs_terminfo\fR(3X)
-timeout/\fBcurs_inopts\fR(3X)
-tiparm/\fBcurs_terminfo\fR(3X)*
-touchline/\fBcurs_touch\fR(3X)
-touchwin/\fBcurs_touch\fR(3X)
-tparm/\fBcurs_terminfo\fR(3X)
-tputs/\fBcurs_termcap\fR(3X)
-tputs/\fBcurs_terminfo\fR(3X)
-trace/\fBcurs_trace\fR(3X)*
-typeahead/\fBcurs_inopts\fR(3X)
-unctrl/\fBcurs_util\fR(3X)
-unget_wch/\fBcurs_get_wch\fR(3X)
-ungetch/\fBcurs_getch\fR(3X)
-ungetmouse/\fBcurs_mouse\fR(3X)*
-untouchwin/\fBcurs_touch\fR(3X)
-use_default_colors/\fBdefault_colors\fR(3X)*
-use_env/\fBcurs_util\fR(3X)
-use_extended_names/\fBcurs_extend\fR(3X)*
-use_legacy_coding/\fBlegacy_coding\fR(3X)*
-use_tioctl/\fBcurs_util\fR(3X)*
-vid_attr/\fBcurs_terminfo\fR(3X)
-vid_puts/\fBcurs_terminfo\fR(3X)
-vidattr/\fBcurs_terminfo\fR(3X)
-vidputs/\fBcurs_terminfo\fR(3X)
-vline/\fBcurs_border\fR(3X)
-vline_set/\fBcurs_border_set\fR(3X)
-vw_printw/\fBcurs_printw\fR(3X)
-vw_scanw/\fBcurs_scanw\fR(3X)
-vwprintw/\fBcurs_printw\fR(3X)
-vwscanw/\fBcurs_scanw\fR(3X)
-wadd_wch/\fBcurs_add_wch\fR(3X)
-wadd_wchnstr/\fBcurs_add_wchstr\fR(3X)
-wadd_wchstr/\fBcurs_add_wchstr\fR(3X)
-waddch/\fBcurs_addch\fR(3X)
-waddchnstr/\fBcurs_addchstr\fR(3X)
-waddchstr/\fBcurs_addchstr\fR(3X)
-waddnstr/\fBcurs_addstr\fR(3X)
-waddnwstr/\fBcurs_addwstr\fR(3X)
-waddstr/\fBcurs_addstr\fR(3X)
-waddwstr/\fBcurs_addwstr\fR(3X)
-wattr_get/\fBcurs_attr\fR(3X)
-wattr_off/\fBcurs_attr\fR(3X)
-wattr_on/\fBcurs_attr\fR(3X)
-wattr_set/\fBcurs_attr\fR(3X)
-wattroff/\fBcurs_attr\fR(3X)
-wattron/\fBcurs_attr\fR(3X)
-wattrset/\fBcurs_attr\fR(3X)
-wbkgd/\fBcurs_bkgd\fR(3X)
-wbkgdset/\fBcurs_bkgd\fR(3X)
-wbkgrnd/\fBcurs_bkgrnd\fR(3X)
-wbkgrndset/\fBcurs_bkgrnd\fR(3X)
-wborder/\fBcurs_border\fR(3X)
-wborder_set/\fBcurs_border_set\fR(3X)
-wchgat/\fBcurs_attr\fR(3X)
-wclear/\fBcurs_clear\fR(3X)
-wclrtobot/\fBcurs_clear\fR(3X)
-wclrtoeol/\fBcurs_clear\fR(3X)
-wcolor_set/\fBcurs_attr\fR(3X)
-wcursyncup/\fBcurs_window\fR(3X)
-wdelch/\fBcurs_delch\fR(3X)
-wdeleteln/\fBcurs_deleteln\fR(3X)
-wecho_wchar/\fBcurs_add_wch\fR(3X)
-wechochar/\fBcurs_addch\fR(3X)
-wenclose/\fBcurs_mouse\fR(3X)*
-werase/\fBcurs_clear\fR(3X)
-wget_wch/\fBcurs_get_wch\fR(3X)
-wget_wstr/\fBcurs_get_wstr\fR(3X)
-wgetbkgrnd/\fBcurs_bkgrnd\fR(3X)
-wgetch/\fBcurs_getch\fR(3X)
-wgetdelay/\fBcurs_opaque\fR(3X)*
-wgetn_wstr/\fBcurs_get_wstr\fR(3X)
-wgetnstr/\fBcurs_getstr\fR(3X)
-wgetparent/\fBcurs_opaque\fR(3X)*
-wgetscrreg/\fBcurs_opaque\fR(3X)*
-wgetstr/\fBcurs_getstr\fR(3X)
-whline/\fBcurs_border\fR(3X)
-whline_set/\fBcurs_border_set\fR(3X)
-win_wch/\fBcurs_in_wch\fR(3X)
-win_wchnstr/\fBcurs_in_wchstr\fR(3X)
-win_wchstr/\fBcurs_in_wchstr\fR(3X)
-winch/\fBcurs_inch\fR(3X)
-winchnstr/\fBcurs_inchstr\fR(3X)
-winchstr/\fBcurs_inchstr\fR(3X)
-winnstr/\fBcurs_instr\fR(3X)
-winnwstr/\fBcurs_inwstr\fR(3X)
-wins_nwstr/\fBcurs_ins_wstr\fR(3X)
-wins_wch/\fBcurs_ins_wch\fR(3X)
-wins_wstr/\fBcurs_ins_wstr\fR(3X)
-winsch/\fBcurs_insch\fR(3X)
-winsdelln/\fBcurs_deleteln\fR(3X)
-winsertln/\fBcurs_deleteln\fR(3X)
-winsnstr/\fBcurs_insstr\fR(3X)
-winsstr/\fBcurs_insstr\fR(3X)
-winstr/\fBcurs_instr\fR(3X)
-winwstr/\fBcurs_inwstr\fR(3X)
-wmouse_trafo/\fBcurs_mouse\fR(3X)*
-wmove/\fBcurs_move\fR(3X)
-wnoutrefresh/\fBcurs_refresh\fR(3X)
-wprintw/\fBcurs_printw\fR(3X)
-wredrawln/\fBcurs_refresh\fR(3X)
-wrefresh/\fBcurs_refresh\fR(3X)
-wresize/\fBwresize\fR(3X)*
-wscanw/\fBcurs_scanw\fR(3X)
-wscrl/\fBcurs_scroll\fR(3X)
-wsetscrreg/\fBcurs_outopts\fR(3X)
-wstandend/\fBcurs_attr\fR(3X)
-wstandout/\fBcurs_attr\fR(3X)
-wsyncdown/\fBcurs_window\fR(3X)
-wsyncup/\fBcurs_window\fR(3X)
-wtimeout/\fBcurs_inopts\fR(3X)
-wtouchln/\fBcurs_touch\fR(3X)
-wunctrl/\fBcurs_util\fR(3X)
-wvline/\fBcurs_border\fR(3X)
-wvline_set/\fBcurs_border_set\fR(3X)
+\f(BIcurses\fP Function Name/Man Page
+_
+COLOR_PAIR/\fBcurs_color\fP(3X)
+PAIR_NUMBER/\fBcurs_color\fP(3X)
+add_wch/\fBcurs_add_wch\fP(3X)
+add_wchnstr/\fBcurs_add_wchstr\fP(3X)
+add_wchstr/\fBcurs_add_wchstr\fP(3X)
+addch/\fBcurs_addch\fP(3X)
+addchnstr/\fBcurs_addchstr\fP(3X)
+addchstr/\fBcurs_addchstr\fP(3X)
+addnstr/\fBcurs_addstr\fP(3X)
+addnwstr/\fBcurs_addwstr\fP(3X)
+addstr/\fBcurs_addstr\fP(3X)
+addwstr/\fBcurs_addwstr\fP(3X)
+alloc_pair/\fBnew_pair\fP(3X)*
+assume_default_colors/\fBdefault_colors\fP(3X)*
+attr_get/\fBcurs_attr\fP(3X)
+attr_off/\fBcurs_attr\fP(3X)
+attr_on/\fBcurs_attr\fP(3X)
+attr_set/\fBcurs_attr\fP(3X)
+attroff/\fBcurs_attr\fP(3X)
+attron/\fBcurs_attr\fP(3X)
+attrset/\fBcurs_attr\fP(3X)
+baudrate/\fBcurs_termattrs\fP(3X)
+beep/\fBcurs_beep\fP(3X)
+bkgd/\fBcurs_bkgd\fP(3X)
+bkgdset/\fBcurs_bkgd\fP(3X)
+bkgrnd/\fBcurs_bkgrnd\fP(3X)
+bkgrndset/\fBcurs_bkgrnd\fP(3X)
+border/\fBcurs_border\fP(3X)
+border_set/\fBcurs_border_set\fP(3X)
+box/\fBcurs_border\fP(3X)
+box_set/\fBcurs_border_set\fP(3X)
+can_change_color/\fBcurs_color\fP(3X)
+cbreak/\fBcurs_inopts\fP(3X)
+chgat/\fBcurs_attr\fP(3X)
+clear/\fBcurs_clear\fP(3X)
+clearok/\fBcurs_outopts\fP(3X)
+clrtobot/\fBcurs_clear\fP(3X)
+clrtoeol/\fBcurs_clear\fP(3X)
+color_content/\fBcurs_color\fP(3X)
+color_set/\fBcurs_attr\fP(3X)
+copywin/\fBcurs_overlay\fP(3X)
+curs_set/\fBcurs_kernel\fP(3X)
+curses_trace/\fBcurs_trace\fP(3X)*
+curses_version/\fBcurs_extend\fP(3X)*
+def_prog_mode/\fBcurs_kernel\fP(3X)
+def_shell_mode/\fBcurs_kernel\fP(3X)
+define_key/\fBdefine_key\fP(3X)*
+del_curterm/\fBcurs_terminfo\fP(3X)
+delay_output/\fBcurs_util\fP(3X)
+delch/\fBcurs_delch\fP(3X)
+deleteln/\fBcurs_deleteln\fP(3X)
+delscreen/\fBcurs_initscr\fP(3X)
+delwin/\fBcurs_window\fP(3X)
+derwin/\fBcurs_window\fP(3X)
+doupdate/\fBcurs_refresh\fP(3X)
+dupwin/\fBcurs_window\fP(3X)
+echo/\fBcurs_inopts\fP(3X)
+echo_wchar/\fBcurs_add_wch\fP(3X)
+echochar/\fBcurs_addch\fP(3X)
+endwin/\fBcurs_initscr\fP(3X)
+erase/\fBcurs_clear\fP(3X)
+erasechar/\fBcurs_termattrs\fP(3X)
+erasewchar/\fBcurs_termattrs\fP(3X)
+exit_curses/\fBcurs_memleaks\fP(3X)*
+exit_terminfo/\fBcurs_memleaks\fP(3X)*
+extended_color_content/\fBcurs_color\fP(3X)*
+extended_pair_content/\fBcurs_color\fP(3X)*
+extended_slk_color/\fBcurs_slk\fP(3X)*
+filter/\fBcurs_util\fP(3X)
+find_pair/\fBnew_pair\fP(3X)*
+flash/\fBcurs_beep\fP(3X)
+flushinp/\fBcurs_util\fP(3X)
+free_pair/\fBnew_pair\fP(3X)*
+get_escdelay/\fBcurs_threads\fP(3X)*
+get_wch/\fBcurs_get_wch\fP(3X)
+get_wstr/\fBcurs_get_wstr\fP(3X)
+getattrs/\fBcurs_attr\fP(3X)
+getbegx/\fBcurs_legacy\fP(3X)*
+getbegy/\fBcurs_legacy\fP(3X)*
+getbegyx/\fBcurs_getyx\fP(3X)
+getbkgd/\fBcurs_bkgd\fP(3X)
+getbkgrnd/\fBcurs_bkgrnd\fP(3X)
+getcchar/\fBcurs_getcchar\fP(3X)
+getch/\fBcurs_getch\fP(3X)
+getcurx/\fBcurs_legacy\fP(3X)*
+getcury/\fBcurs_legacy\fP(3X)*
+getmaxx/\fBcurs_legacy\fP(3X)*
+getmaxy/\fBcurs_legacy\fP(3X)*
+getmaxyx/\fBcurs_getyx\fP(3X)
+getmouse/\fBcurs_mouse\fP(3X)*
+getn_wstr/\fBcurs_get_wstr\fP(3X)
+getnstr/\fBcurs_getstr\fP(3X)
+getparx/\fBcurs_legacy\fP(3X)*
+getpary/\fBcurs_legacy\fP(3X)*
+getparyx/\fBcurs_getyx\fP(3X)
+getstr/\fBcurs_getstr\fP(3X)
+getsyx/\fBcurs_kernel\fP(3X)
+getwin/\fBcurs_util\fP(3X)
+getyx/\fBcurs_getyx\fP(3X)
+halfdelay/\fBcurs_inopts\fP(3X)
+has_colors/\fBcurs_color\fP(3X)
+has_ic/\fBcurs_termattrs\fP(3X)
+has_il/\fBcurs_termattrs\fP(3X)
+has_key/\fBcurs_getch\fP(3X)*
+has_mouse/\fBcurs_mouse\fP(3X)*
+hline/\fBcurs_border\fP(3X)
+hline_set/\fBcurs_border_set\fP(3X)
+idcok/\fBcurs_outopts\fP(3X)
+idlok/\fBcurs_outopts\fP(3X)
+immedok/\fBcurs_outopts\fP(3X)
+in_wch/\fBcurs_in_wch\fP(3X)
+in_wchnstr/\fBcurs_in_wchstr\fP(3X)
+in_wchstr/\fBcurs_in_wchstr\fP(3X)
+inch/\fBcurs_inch\fP(3X)
+inchnstr/\fBcurs_inchstr\fP(3X)
+inchstr/\fBcurs_inchstr\fP(3X)
+init_color/\fBcurs_color\fP(3X)
+init_extended_color/\fBcurs_color\fP(3X)*
+init_extended_pair/\fBcurs_color\fP(3X)*
+init_pair/\fBcurs_color\fP(3X)
+initscr/\fBcurs_initscr\fP(3X)
+innstr/\fBcurs_instr\fP(3X)
+innwstr/\fBcurs_inwstr\fP(3X)
+ins_nwstr/\fBcurs_ins_wstr\fP(3X)
+ins_wch/\fBcurs_ins_wch\fP(3X)
+ins_wstr/\fBcurs_ins_wstr\fP(3X)
+insch/\fBcurs_insch\fP(3X)
+insdelln/\fBcurs_deleteln\fP(3X)
+insertln/\fBcurs_deleteln\fP(3X)
+insnstr/\fBcurs_insstr\fP(3X)
+insstr/\fBcurs_insstr\fP(3X)
+instr/\fBcurs_instr\fP(3X)
+intrflush/\fBcurs_inopts\fP(3X)
+inwstr/\fBcurs_inwstr\fP(3X)
+is_cbreak/\fBcurs_inopts\fP(3X)*
+is_cleared/\fBcurs_opaque\fP(3X)*
+is_echo/\fBcurs_inopts\fP(3X)*
+is_idcok/\fBcurs_opaque\fP(3X)*
+is_idlok/\fBcurs_opaque\fP(3X)*
+is_immedok/\fBcurs_opaque\fP(3X)*
+is_keypad/\fBcurs_opaque\fP(3X)*
+is_leaveok/\fBcurs_opaque\fP(3X)*
+is_linetouched/\fBcurs_touch\fP(3X)
+is_nl/\fBcurs_inopts\fP(3X)*
+is_nodelay/\fBcurs_opaque\fP(3X)*
+is_notimeout/\fBcurs_opaque\fP(3X)*
+is_pad/\fBcurs_opaque\fP(3X)*
+is_raw/\fBcurs_inopts\fP(3X)*
+is_scrollok/\fBcurs_opaque\fP(3X)*
+is_subwin/\fBcurs_opaque\fP(3X)*
+is_syncok/\fBcurs_opaque\fP(3X)*
+is_term_resized/\fBresizeterm\fP(3X)*
+is_wintouched/\fBcurs_touch\fP(3X)
+isendwin/\fBcurs_initscr\fP(3X)
+key_defined/\fBkey_defined\fP(3X)*
+key_name/\fBcurs_util\fP(3X)
+keybound/\fBkeybound\fP(3X)*
+keyname/\fBcurs_util\fP(3X)
+keyok/\fBkeyok\fP(3X)*
+keypad/\fBcurs_inopts\fP(3X)
+killchar/\fBcurs_termattrs\fP(3X)
+killwchar/\fBcurs_termattrs\fP(3X)
+leaveok/\fBcurs_outopts\fP(3X)
+longname/\fBcurs_termattrs\fP(3X)
+mcprint/\fBcurs_print\fP(3X)*
+meta/\fBcurs_inopts\fP(3X)
+mouse_trafo/\fBcurs_mouse\fP(3X)*
+mouseinterval/\fBcurs_mouse\fP(3X)*
+mousemask/\fBcurs_mouse\fP(3X)*
+move/\fBcurs_move\fP(3X)
+mvadd_wch/\fBcurs_add_wch\fP(3X)
+mvadd_wchnstr/\fBcurs_add_wchstr\fP(3X)
+mvadd_wchstr/\fBcurs_add_wchstr\fP(3X)
+mvaddch/\fBcurs_addch\fP(3X)
+mvaddchnstr/\fBcurs_addchstr\fP(3X)
+mvaddchstr/\fBcurs_addchstr\fP(3X)
+mvaddnstr/\fBcurs_addstr\fP(3X)
+mvaddnwstr/\fBcurs_addwstr\fP(3X)
+mvaddstr/\fBcurs_addstr\fP(3X)
+mvaddwstr/\fBcurs_addwstr\fP(3X)
+mvchgat/\fBcurs_attr\fP(3X)
+mvcur/\fBcurs_terminfo\fP(3X)
+mvdelch/\fBcurs_delch\fP(3X)
+mvderwin/\fBcurs_window\fP(3X)
+mvget_wch/\fBcurs_get_wch\fP(3X)
+mvget_wstr/\fBcurs_get_wstr\fP(3X)
+mvgetch/\fBcurs_getch\fP(3X)
+mvgetn_wstr/\fBcurs_get_wstr\fP(3X)
+mvgetnstr/\fBcurs_getstr\fP(3X)
+mvgetstr/\fBcurs_getstr\fP(3X)
+mvhline/\fBcurs_border\fP(3X)
+mvhline_set/\fBcurs_border_set\fP(3X)
+mvin_wch/\fBcurs_in_wch\fP(3X)
+mvin_wchnstr/\fBcurs_in_wchstr\fP(3X)
+mvin_wchstr/\fBcurs_in_wchstr\fP(3X)
+mvinch/\fBcurs_inch\fP(3X)
+mvinchnstr/\fBcurs_inchstr\fP(3X)
+mvinchstr/\fBcurs_inchstr\fP(3X)
+mvinnstr/\fBcurs_instr\fP(3X)
+mvinnwstr/\fBcurs_inwstr\fP(3X)
+mvins_nwstr/\fBcurs_ins_wstr\fP(3X)
+mvins_wch/\fBcurs_ins_wch\fP(3X)
+mvins_wstr/\fBcurs_ins_wstr\fP(3X)
+mvinsch/\fBcurs_insch\fP(3X)
+mvinsnstr/\fBcurs_insstr\fP(3X)
+mvinsstr/\fBcurs_insstr\fP(3X)
+mvinstr/\fBcurs_instr\fP(3X)
+mvinwstr/\fBcurs_inwstr\fP(3X)
+mvprintw/\fBcurs_printw\fP(3X)
+mvscanw/\fBcurs_scanw\fP(3X)
+mvvline/\fBcurs_border\fP(3X)
+mvvline_set/\fBcurs_border_set\fP(3X)
+mvwadd_wch/\fBcurs_add_wch\fP(3X)
+mvwadd_wchnstr/\fBcurs_add_wchstr\fP(3X)
+mvwadd_wchstr/\fBcurs_add_wchstr\fP(3X)
+mvwaddch/\fBcurs_addch\fP(3X)
+mvwaddchnstr/\fBcurs_addchstr\fP(3X)
+mvwaddchstr/\fBcurs_addchstr\fP(3X)
+mvwaddnstr/\fBcurs_addstr\fP(3X)
+mvwaddnwstr/\fBcurs_addwstr\fP(3X)
+mvwaddstr/\fBcurs_addstr\fP(3X)
+mvwaddwstr/\fBcurs_addwstr\fP(3X)
+mvwchgat/\fBcurs_attr\fP(3X)
+mvwdelch/\fBcurs_delch\fP(3X)
+mvwget_wch/\fBcurs_get_wch\fP(3X)
+mvwget_wstr/\fBcurs_get_wstr\fP(3X)
+mvwgetch/\fBcurs_getch\fP(3X)
+mvwgetn_wstr/\fBcurs_get_wstr\fP(3X)
+mvwgetnstr/\fBcurs_getstr\fP(3X)
+mvwgetstr/\fBcurs_getstr\fP(3X)
+mvwhline/\fBcurs_border\fP(3X)
+mvwhline_set/\fBcurs_border_set\fP(3X)
+mvwin/\fBcurs_window\fP(3X)
+mvwin_wch/\fBcurs_in_wch\fP(3X)
+mvwin_wchnstr/\fBcurs_in_wchstr\fP(3X)
+mvwin_wchstr/\fBcurs_in_wchstr\fP(3X)
+mvwinch/\fBcurs_inch\fP(3X)
+mvwinchnstr/\fBcurs_inchstr\fP(3X)
+mvwinchstr/\fBcurs_inchstr\fP(3X)
+mvwinnstr/\fBcurs_instr\fP(3X)
+mvwinnwstr/\fBcurs_inwstr\fP(3X)
+mvwins_nwstr/\fBcurs_ins_wstr\fP(3X)
+mvwins_wch/\fBcurs_ins_wch\fP(3X)
+mvwins_wstr/\fBcurs_ins_wstr\fP(3X)
+mvwinsch/\fBcurs_insch\fP(3X)
+mvwinsnstr/\fBcurs_insstr\fP(3X)
+mvwinsstr/\fBcurs_insstr\fP(3X)
+mvwinstr/\fBcurs_instr\fP(3X)
+mvwinwstr/\fBcurs_inwstr\fP(3X)
+mvwprintw/\fBcurs_printw\fP(3X)
+mvwscanw/\fBcurs_scanw\fP(3X)
+mvwvline/\fBcurs_border\fP(3X)
+mvwvline_set/\fBcurs_border_set\fP(3X)
+napms/\fBcurs_kernel\fP(3X)
+newpad/\fBcurs_pad\fP(3X)
+newterm/\fBcurs_initscr\fP(3X)
+newwin/\fBcurs_window\fP(3X)
+nl/\fBcurs_inopts\fP(3X)
+nocbreak/\fBcurs_inopts\fP(3X)
+nodelay/\fBcurs_inopts\fP(3X)
+noecho/\fBcurs_inopts\fP(3X)
+nofilter/\fBcurs_util\fP(3X)*
+nonl/\fBcurs_inopts\fP(3X)
+noqiflush/\fBcurs_inopts\fP(3X)
+noraw/\fBcurs_inopts\fP(3X)
+notimeout/\fBcurs_inopts\fP(3X)
+overlay/\fBcurs_overlay\fP(3X)
+overwrite/\fBcurs_overlay\fP(3X)
+pair_content/\fBcurs_color\fP(3X)
+pecho_wchar/\fBcurs_pad\fP(3X)
+pechochar/\fBcurs_pad\fP(3X)
+pnoutrefresh/\fBcurs_pad\fP(3X)
+prefresh/\fBcurs_pad\fP(3X)
+printw/\fBcurs_printw\fP(3X)
+putp/\fBcurs_terminfo\fP(3X)
+putwin/\fBcurs_util\fP(3X)
+qiflush/\fBcurs_inopts\fP(3X)
+raw/\fBcurs_inopts\fP(3X)
+redrawwin/\fBcurs_refresh\fP(3X)
+refresh/\fBcurs_refresh\fP(3X)
+reset_color_pairs/\fBcurs_color\fP(3X)*
+reset_prog_mode/\fBcurs_kernel\fP(3X)
+reset_shell_mode/\fBcurs_kernel\fP(3X)
+resetty/\fBcurs_kernel\fP(3X)
+resize_term/\fBresizeterm\fP(3X)*
+resizeterm/\fBresizeterm\fP(3X)*
+restartterm/\fBcurs_terminfo\fP(3X)
+ripoffline/\fBcurs_kernel\fP(3X)
+savetty/\fBcurs_kernel\fP(3X)
+scanw/\fBcurs_scanw\fP(3X)
+scr_dump/\fBcurs_scr_dump\fP(3X)
+scr_init/\fBcurs_scr_dump\fP(3X)
+scr_restore/\fBcurs_scr_dump\fP(3X)
+scr_set/\fBcurs_scr_dump\fP(3X)
+scrl/\fBcurs_scroll\fP(3X)
+scroll/\fBcurs_scroll\fP(3X)
+scrollok/\fBcurs_outopts\fP(3X)
+set_curterm/\fBcurs_terminfo\fP(3X)
+set_escdelay/\fBcurs_threads\fP(3X)*
+set_tabsize/\fBcurs_threads\fP(3X)*
+set_term/\fBcurs_initscr\fP(3X)
+setcchar/\fBcurs_getcchar\fP(3X)
+setscrreg/\fBcurs_outopts\fP(3X)
+setsyx/\fBcurs_kernel\fP(3X)
+setupterm/\fBcurs_terminfo\fP(3X)
+slk_attr/\fBcurs_slk\fP(3X)*
+slk_attr_off/\fBcurs_slk\fP(3X)
+slk_attr_on/\fBcurs_slk\fP(3X)
+slk_attr_set/\fBcurs_slk\fP(3X)
+slk_attroff/\fBcurs_slk\fP(3X)
+slk_attron/\fBcurs_slk\fP(3X)
+slk_attrset/\fBcurs_slk\fP(3X)
+slk_clear/\fBcurs_slk\fP(3X)
+slk_color/\fBcurs_slk\fP(3X)
+slk_init/\fBcurs_slk\fP(3X)
+slk_label/\fBcurs_slk\fP(3X)
+slk_noutrefresh/\fBcurs_slk\fP(3X)
+slk_refresh/\fBcurs_slk\fP(3X)
+slk_restore/\fBcurs_slk\fP(3X)
+slk_set/\fBcurs_slk\fP(3X)
+slk_touch/\fBcurs_slk\fP(3X)
+slk_wset/\fBcurs_slk\fP(3X)
+standend/\fBcurs_attr\fP(3X)
+standout/\fBcurs_attr\fP(3X)
+start_color/\fBcurs_color\fP(3X)
+subpad/\fBcurs_pad\fP(3X)
+subwin/\fBcurs_window\fP(3X)
+syncok/\fBcurs_window\fP(3X)
+term_attrs/\fBcurs_termattrs\fP(3X)
+termattrs/\fBcurs_termattrs\fP(3X)
+termname/\fBcurs_termattrs\fP(3X)
+tgetent/\fBcurs_termcap\fP(3X)
+tgetflag/\fBcurs_termcap\fP(3X)
+tgetnum/\fBcurs_termcap\fP(3X)
+tgetstr/\fBcurs_termcap\fP(3X)
+tgoto/\fBcurs_termcap\fP(3X)
+tigetflag/\fBcurs_terminfo\fP(3X)
+tigetnum/\fBcurs_terminfo\fP(3X)
+tigetstr/\fBcurs_terminfo\fP(3X)
+timeout/\fBcurs_inopts\fP(3X)
+tiparm/\fBcurs_terminfo\fP(3X)
+tiparm_s/\fBcurs_terminfo\fP(3X)*
+tiscan_s/\fBcurs_terminfo\fP(3X)*
+touchline/\fBcurs_touch\fP(3X)
+touchwin/\fBcurs_touch\fP(3X)
+tparm/\fBcurs_terminfo\fP(3X)
+tputs/\fBcurs_termcap\fP(3X)
+tputs/\fBcurs_terminfo\fP(3X)
+trace/\fBcurs_trace\fP(3X)*
+typeahead/\fBcurs_inopts\fP(3X)
+unctrl/\fBcurs_util\fP(3X)
+unget_wch/\fBcurs_get_wch\fP(3X)
+ungetch/\fBcurs_getch\fP(3X)
+ungetmouse/\fBcurs_mouse\fP(3X)*
+untouchwin/\fBcurs_touch\fP(3X)
+use_default_colors/\fBdefault_colors\fP(3X)*
+use_env/\fBcurs_util\fP(3X)
+use_extended_names/\fBcurs_extend\fP(3X)*
+use_legacy_coding/\fBlegacy_coding\fP(3X)*
+use_screen/\fBcurs_threads\fP(3X)*
+use_tioctl/\fBcurs_util\fP(3X)*
+use_window/\fBcurs_threads\fP(3X)*
+vid_attr/\fBcurs_terminfo\fP(3X)
+vid_puts/\fBcurs_terminfo\fP(3X)
+vidattr/\fBcurs_terminfo\fP(3X)
+vidputs/\fBcurs_terminfo\fP(3X)
+vline/\fBcurs_border\fP(3X)
+vline_set/\fBcurs_border_set\fP(3X)
+vw_printw/\fBcurs_printw\fP(3X)
+vw_scanw/\fBcurs_scanw\fP(3X)
+vwprintw/\fBcurs_printw\fP(3X)
+vwscanw/\fBcurs_scanw\fP(3X)
+wadd_wch/\fBcurs_add_wch\fP(3X)
+wadd_wchnstr/\fBcurs_add_wchstr\fP(3X)
+wadd_wchstr/\fBcurs_add_wchstr\fP(3X)
+waddch/\fBcurs_addch\fP(3X)
+waddchnstr/\fBcurs_addchstr\fP(3X)
+waddchstr/\fBcurs_addchstr\fP(3X)
+waddnstr/\fBcurs_addstr\fP(3X)
+waddnwstr/\fBcurs_addwstr\fP(3X)
+waddstr/\fBcurs_addstr\fP(3X)
+waddwstr/\fBcurs_addwstr\fP(3X)
+wattr_get/\fBcurs_attr\fP(3X)
+wattr_off/\fBcurs_attr\fP(3X)
+wattr_on/\fBcurs_attr\fP(3X)
+wattr_set/\fBcurs_attr\fP(3X)
+wattroff/\fBcurs_attr\fP(3X)
+wattron/\fBcurs_attr\fP(3X)
+wattrset/\fBcurs_attr\fP(3X)
+wbkgd/\fBcurs_bkgd\fP(3X)
+wbkgdset/\fBcurs_bkgd\fP(3X)
+wbkgrnd/\fBcurs_bkgrnd\fP(3X)
+wbkgrndset/\fBcurs_bkgrnd\fP(3X)
+wborder/\fBcurs_border\fP(3X)
+wborder_set/\fBcurs_border_set\fP(3X)
+wchgat/\fBcurs_attr\fP(3X)
+wclear/\fBcurs_clear\fP(3X)
+wclrtobot/\fBcurs_clear\fP(3X)
+wclrtoeol/\fBcurs_clear\fP(3X)
+wcolor_set/\fBcurs_attr\fP(3X)
+wcursyncup/\fBcurs_window\fP(3X)
+wdelch/\fBcurs_delch\fP(3X)
+wdeleteln/\fBcurs_deleteln\fP(3X)
+wecho_wchar/\fBcurs_add_wch\fP(3X)
+wechochar/\fBcurs_addch\fP(3X)
+wenclose/\fBcurs_mouse\fP(3X)*
+werase/\fBcurs_clear\fP(3X)
+wget_wch/\fBcurs_get_wch\fP(3X)
+wget_wstr/\fBcurs_get_wstr\fP(3X)
+wgetbkgrnd/\fBcurs_bkgrnd\fP(3X)
+wgetch/\fBcurs_getch\fP(3X)
+wgetdelay/\fBcurs_opaque\fP(3X)*
+wgetn_wstr/\fBcurs_get_wstr\fP(3X)
+wgetnstr/\fBcurs_getstr\fP(3X)
+wgetparent/\fBcurs_opaque\fP(3X)*
+wgetscrreg/\fBcurs_opaque\fP(3X)*
+wgetstr/\fBcurs_getstr\fP(3X)
+whline/\fBcurs_border\fP(3X)
+whline_set/\fBcurs_border_set\fP(3X)
+win_wch/\fBcurs_in_wch\fP(3X)
+win_wchnstr/\fBcurs_in_wchstr\fP(3X)
+win_wchstr/\fBcurs_in_wchstr\fP(3X)
+winch/\fBcurs_inch\fP(3X)
+winchnstr/\fBcurs_inchstr\fP(3X)
+winchstr/\fBcurs_inchstr\fP(3X)
+winnstr/\fBcurs_instr\fP(3X)
+winnwstr/\fBcurs_inwstr\fP(3X)
+wins_nwstr/\fBcurs_ins_wstr\fP(3X)
+wins_wch/\fBcurs_ins_wch\fP(3X)
+wins_wstr/\fBcurs_ins_wstr\fP(3X)
+winsch/\fBcurs_insch\fP(3X)
+winsdelln/\fBcurs_deleteln\fP(3X)
+winsertln/\fBcurs_deleteln\fP(3X)
+winsnstr/\fBcurs_insstr\fP(3X)
+winsstr/\fBcurs_insstr\fP(3X)
+winstr/\fBcurs_instr\fP(3X)
+winwstr/\fBcurs_inwstr\fP(3X)
+wmouse_trafo/\fBcurs_mouse\fP(3X)*
+wmove/\fBcurs_move\fP(3X)
+wnoutrefresh/\fBcurs_refresh\fP(3X)
+wprintw/\fBcurs_printw\fP(3X)
+wredrawln/\fBcurs_refresh\fP(3X)
+wrefresh/\fBcurs_refresh\fP(3X)
+wresize/\fBwresize\fP(3X)*
+wscanw/\fBcurs_scanw\fP(3X)
+wscrl/\fBcurs_scroll\fP(3X)
+wsetscrreg/\fBcurs_outopts\fP(3X)
+wstandend/\fBcurs_attr\fP(3X)
+wstandout/\fBcurs_attr\fP(3X)
+wsyncdown/\fBcurs_window\fP(3X)
+wsyncup/\fBcurs_window\fP(3X)
+wtimeout/\fBcurs_inopts\fP(3X)
+wtouchln/\fBcurs_touch\fP(3X)
+wunctrl/\fBcurs_util\fP(3X)
+wvline/\fBcurs_border\fP(3X)
+wvline_set/\fBcurs_border_set\fP(3X)
 .TE
 .PP
-Depending on the configuration,
-additional sets of functions may be available:
-.RS 3
-.TP 5
-\fBcurs_memleaks\fP(3X) - curses memory-leak checking
-.TP 5
-\fBcurs_sp_funcs\fP(3X) - curses screen-pointer extension
-.TP 5
-\fBcurs_threads\fP(3X) - curses thread support
-.TP 5
-\fBcurs_trace\fP(3X) - curses debugging routines
-.RE
+.IR \%ncurses 's
+.I "screen-pointer extension"
+adds additional functions corresponding to many of the above,
+each with an \*(``_sp\*('' suffix;
+see \fBcurs_sp_funcs\fP(3X).
+.PP
+The availability of some extensions is configurable when
+.I \%ncurses
+is compiled;
+see sections \*(``ALTERNATE CONFIGURATIONS\*('' and \*(``EXTENSIONS\*(''
+below.
 .SH RETURN VALUE
-Routines that return an integer return \fBERR\fR upon failure and an
-integer value other than \fBERR\fR upon successful completion, unless
-otherwise noted in the routine descriptions.
-.PP
-As a general rule, routines check for null pointers passed as parameters,
-and handle this as an error.
-.PP
-All macros return the value of the \fBw\fR version, except \fBsetscrreg\fR,
-\fBwsetscrreg\fR, \fBgetyx\fR, \fBgetbegyx\fR, and \fBgetmaxyx\fR.
-The return values of
-\fBsetscrreg\fR,
-\fBwsetscrreg\fR,
-\fBgetyx\fR,
-\fBgetbegyx\fR, and
-\fBgetmaxyx\fR are undefined (i.e., these should not be used as the
-right-hand side of assignment statements).
-.PP
-Functions with a \*(``mv\*('' prefix first perform a cursor movement using
-\fBwmove\fP, and return an error if the position is outside the window,
-or if the window pointer is null.
-Most \*(``mv\*(''-prefixed functions
-(except variadic functions such as \fBmvprintw\fP)
-are provided both as macros and functions.
-.PP
-Routines that return pointers return \fBNULL\fR on error.
+Unless otherwise noted,
+functions that return an integer return
+.B OK
+on success and
+.B ERR
+on failure.
+Functions that return pointers return
+.B NULL
+on failure.
+Typically,
+.I \%ncurses
+treats a null pointer passed as a function parameter as a failure.
+Functions prefixed with \*(``mv\*('' first perform cursor movement and
+fail if the position
+.RI ( y ,
+.IR x )
+is outside the window boundaries.
 .SH ENVIRONMENT
-.PP
-The following environment symbols are useful for customizing the
-runtime behavior of the \fBncurses\fR library.
-The most important ones have been already discussed in detail.
-.SS CC command-character
-.PP
-When set, change occurrences of the command_character
-(i.e., the \fBcmdch\fP capability)
-of the loaded terminfo entries to the value of this variable.
-Very few terminfo entries provide this feature.
+The following symbols from the process environment customize the
+runtime behavior of
+.I \%ncurses
+applications.
+The library may be configured to disregard the variables
+.IR \%TERMINFO ,
+.IR \%TERMINFO_DIRS ,
+.IR \%TERMPATH ,
+and
+.IR HOME ,
+if the user is the superuser (root),
+or the application uses \fI\%setuid\fP(2) or \fI\%setgid\fP(2).
+.SS "\fIBAUDRATE\fP"
+The debugging library checks this variable when the application has
+redirected output to a file.
+Its integral value is used for the baud rate.
+If that value is absent or invalid,
+.I \%ncurses
+uses 9600.
+This feature allows testers to construct repeatable test cases
+that take into account optimization decisions that depend on baud rate.
+.SS "\fICC\fP (command character)"
+When set,
+the
+.B \%command_character
+.RB ( \%cmdch )
+capability value of loaded
+.I \%term\%info
+entries changes to the value of this variable.
+Very few
+.I \%term\%info
+entries provide this feature.
 .PP
 Because this name is also used in development environments to represent
-the C compiler's name, \fBncurses\fR ignores it if it does not happen to
-be a single character.
-.SS BAUDRATE
-.PP
-The debugging library checks this environment variable when the application
-has redirected output to a file.
-The variable's numeric value is used for the baudrate.
-If no value is found, \fBncurses\fR uses 9600.
-This allows testers to construct repeatable test-cases
-that take into account costs that depend on baudrate.
-.SS COLUMNS
-.PP
-Specify the width of the screen in characters.
+the C compiler's name,
+.I \%ncurses
+ignores its value if it is not one character in length.
+.SS "\fICOLUMNS\fP"
+This variable specifies the width of the screen in characters.
 Applications running in a windowing environment usually are able to
 obtain the width of the window in which they are executing.
-If neither the \fBCOLUMNS\fP value nor the terminal's screen size is available,
-\fBncurses\fR uses the size which may be specified in the terminfo database
-(i.e., the \fBcols\fR capability).
-.PP
-It is important that your application use a correct size for the screen.
-This is not always possible because your application may be
-running on a host which does not honor NAWS (Negotiations About Window
-Size), or because you are temporarily running as another user.
-However, setting \fBCOLUMNS\fP and/or \fBLINES\fP overrides the library's
-use of the screen size obtained from the operating system.
-.PP
-Either \fBCOLUMNS\fP or \fBLINES\fP symbols may be specified independently.
-This is mainly useful to circumvent legacy misfeatures of terminal descriptions,
-e.g., xterm which commonly specifies a 65 line screen.
-For best results, \fBlines\fR and \fBcols\fR should not be specified in
-a terminal description for terminals which are run as emulations.
-.PP
-Use the \fBuse_env\fR function to disable all use of external environment
-(but not including system calls) to determine the screen size.
-Use the \fBuse_tioctl\fR function to update \fBCOLUMNS\fP or \fBLINES\fP
-to match the screen size obtained from system calls or the terminal database.
-.SS ESCDELAY
-.PP
-Specifies the total time, in milliseconds, for which ncurses will
-await a character sequence, e.g., a function key.
-The default value, 1000 milliseconds, is enough for most uses.
-However, it is made a variable to accommodate unusual applications.
+If
+.I \%COLUMNS
+is not defined and the terminal's screen size is not available from the
+terminal driver,
+.I \%ncurses
+uses the size specified by the
+.B \%columns
+.RB ( \%cols )
+capability of the terminal type's entry in the
+.I \%term\%info
+database,
+if any.
+.PP
+It is important that your application use the correct screen size.
+Automatic detection thereof is not always possible because an
+application may be running on a host that does not honor NAWS
+(Negotiations About Window Size)
+or as a different user ID than the owner of the terminal device file.
+Setting
+.I \%COLUMNS
+and/or
+.I \%LINES
+overrides the library's use of the screen size obtained from the
+operating system.
+.PP
+The
+.I \%COLUMNS
+and
+.I \%LINES
+variables may be specified independently.
+This property is useful to circumvent misfeatures of legacy terminal
+type descriptions;
+\fI\%xterm\fP(1) descriptions specifying 65 lines were once notorious.
+For best results,
+avoid specifying
+.B cols
+and
+.B lines
+capability codes in
+.I \%term\%info
+descriptions of terminal emulators.
+.PP
+\fBuse_env\fP(3X) can disable use of the process environment
+in determining the screen size.
+\fBuse_tioctl\fP(3X) can update
+.I \%COLUMNS
+and
+.I \%LINES
+to match the screen size obtained from system calls or the terminal
+database.
+.SS "\fIESCDELAY\fP"
+For
+.I curses
+to distinguish the ESC character resulting from a user's press of the
+\*(``Escape\*('' key on the input device from one beginning an
+.I "escape sequence"
+(as commonly produced by function keys),
+it waits after receiving the escape character to see if further
+characters are available on the input stream within a short interval.
+A global variable
+.B \%ESCDELAY
+stores this interval in milliseconds.
+The default value of 1000
+(one second)
+is adequate for most uses.
+This environment variable overrides it.
 .PP
 The most common instance where you may wish to change this value
-is to work with slow hosts, e.g., running on a network.
-If the host cannot read characters rapidly enough, it will have the same
-effect as if the terminal did not send characters rapidly enough.
-The library will still see a timeout.
-.PP
-Note that xterm mouse events are built up from character sequences
-received from the xterm.
-If your application makes heavy use of multiple-clicking, you may
-wish to lengthen this default value because the timeout applies
-to the composed multi-click event as well as the individual clicks.
-.PP
-In addition to the environment variable,
-this implementation provides a global variable with the same name.
-Portable applications should not rely upon the presence of ESCDELAY
+is to work with a remote host over a slow communication channel.
+If the host running a
+.I curses
+application does not receive the characters of an escape sequence in a
+timely manner,
+the library can interpret them as multiple key stroke events.
+.PP
+\fI\%xterm\fP(1) mouse events are a form of escape sequence;
+therefore,
+if your application makes heavy use of multiple-clicking,
+you may wish to lengthen the default value because the delay applies
+to the composite multi-click event as well as the individual clicks.
+.PP
+Portable applications should not rely upon the presence of
+.B \%ESCDELAY
 in either form,
 but setting the environment variable rather than the global variable
 does not create problems when compiling an application.
-.SS HOME
-Tells \fBncurses\fR where your home directory is.
-That is where it may read and write auxiliary terminal descriptions:
-.NS
-$HOME/.termcap
-$HOME/.terminfo
-.NE
-.SS LINES
-.PP
-Like COLUMNS, specify the height of the screen in characters.
-See COLUMNS for a detailed description.
-.SS MOUSE_BUTTONS_123
-.PP
-This applies only to the OS/2 EMX port.
-It specifies the order of buttons on the mouse.
-OS/2 numbers a 3-button mouse inconsistently from other
-platforms:
-.NS
-1 = left
-.br
-2 = right
-.br
-3 = middle.
-.NE
-.PP
-This variable lets you customize the mouse.
-The variable must be three numeric digits 1\-3 in any order, e.g., 123 or 321.
-If it is not specified, \fBncurses\fR uses 132.
-.SS NCURSES_ASSUMED_COLORS
-.PP
-Override the compiled-in assumption that the
-terminal's default colors are white-on-black
-(see \fBdefault_colors\fR(3X)).
-You may set the foreground and background color values with this environment
-variable by proving a 2-element list: foreground,background.
-For example, to tell ncurses to not assume anything
-about the colors, set this to "\-1,\-1".
-To make it green-on-black, set it to "2,0".
-Any positive value from zero to the terminfo \fBmax_colors\fR value is allowed.
-.SS NCURSES_CONSOLE2
-This applies only to the MinGW port of ncurses.
-.PP
-The \fBConsole2\fP program's handling of the Microsoft Console API call
-\fBCreateConsoleScreenBuffer\fP is defective.
-Applications which use this will hang.
-However, it is possible to simulate the action of this call by
-mapping coordinates,
-explicitly saving and restoring the original screen contents.
-Setting the environment variable \fBNCGDB\fP has the same effect.
-.SS NCURSES_GPM_TERMS
-.PP
-This applies only to ncurses configured to use the GPM interface.
-.PP
-If present,
-the environment variable is a list of one or more terminal names
-against which the \fBTERM\fP environment variable is matched.
-Setting it to an empty value disables the GPM interface;
-using the built-in support for xterm, etc.
 .PP
-If the environment variable is absent,
-ncurses will attempt to open GPM if \fBTERM\fP contains \*(``linux\*(''.
-.SS NCURSES_NO_HARD_TABS
-.PP
-\fBNcurses\fP may use tabs as part of the cursor movement optimization.
+If \fB\%keypad\fP(3X) is disabled for the
+.I curses
+window receiving input,
+a program must disambiguate escape sequences itself.
+.SS "\fIHOME\fP"
+.I \%ncurses
+may read and write auxiliary terminal descriptions in
+.I \%.termcap
+and
+.I \%.terminfo
+files in the user's home directory.
+.SS "\fILINES\fP"
+This counterpart to
+.I \%COLUMNS
+specifies the height of the screen in characters.
+The corresponding
+.I \%term\%info
+capability and code is
+.BR \%lines .
+See the description of the
+.I \%COLUMNS
+variable above.
+.SS "\fIMOUSE_BUTTONS_123\fP"
+(OS/2 EMX port only)
+OS/2 numbers a three-button mouse inconsistently with other platforms,
+such that 1 is the left button,
+2 the right,
+and 3 the middle.
+This variable customizes the mouse button numbering.
+Its value must be three digits 1\-3 in any order.
+By default,
+.I \%ncurses
+assumes a numbering of \*(``132\*(''.
+.SS "\fINCURSES_ASSUMED_COLORS\fP"
+If set,
+this variable overrides the
+.I \%ncurses
+library's compiled-in assumption that the terminal's default colors are
+white on black;
+see \fB\%default_colors\fP(3X).
+Set the foreground and background color values with this environment
+variable by assigning it two integer values separated by a comma,
+indicating foregound and background color numbers,
+respectively.
+.PP
+For example,
+to tell
+.I \%ncurses
+not to assume anything about the colors,
+use a value of \*(``\-1,\-1\*(''.
+To make the default color scheme green on black,
+use \*(``2,0\*(''.
+.I \%ncurses
+accepts integral values from \-1 up to the value of the
+.I \%term\%info
+.B \%max_colors
+.RB ( colors )
+capability.
+.SS "\fINCURSES_CONSOLE2\fP"
+(MinGW port only)
+The
+.I \%Console2
+.\" https://www.hanselman.com/blog/console2-a-better-windows-command-prompt
+program defectively handles the Microsoft Console API call
+.IR \%Create\%Console\%Screen\%Buffer .
+Applications that use it will hang.
+However,
+it is possible to simulate the action of this call by mapping
+coordinates,
+explicitly saving and restoring the original screen contents.
+Setting the environment variable
+.I \%NCGDB
+has the same effect.
+.SS "\fINCURSES_GPM_TERMS\fP"
+(Linux only)
+When
+.I \%ncurses
+is configured to use the GPM interface,
+this variable may list one or more terminal names
+against which the
+.I TERM
+variable
+(see below)
+is matched.
+An empty value disables the GPM interface,
+using
+.IR \%ncurses 's
+built-in support for \fIxterm\fP(1) mouse protocols instead.
+If the variable is absent,
+.I \%ncurses
+attempts to open GPM if
+.I TERM
+contains \*(``linux\*(''.
+.SS "\fINCURSES_NO_HARD_TABS\fP"
+.I \%ncurses
+may use tab characters in cursor movement optimization.
 In some cases,
-your terminal driver may not handle these properly.
-Set this environment variable to disable the feature.
-You can also adjust your \fBstty\fP settings to avoid the problem.
-.SS NCURSES_NO_MAGIC_COOKIE
-.PP
-Some terminals use a magic-cookie feature which requires special handling
-to make highlighting and other video attributes display properly.
-You can suppress the highlighting entirely for these terminals by
-setting this environment variable.
-.SS NCURSES_NO_PADDING
-.PP
-Most of the terminal descriptions in the terminfo database are written
-for real \*(``hardware\*('' terminals.
-Many people use terminal emulators
-which run in a windowing environment and use curses-based applications.
-Terminal emulators can duplicate
-all of the important aspects of a hardware terminal, but they do not
-have the same limitations.
-The chief limitation of a hardware terminal from the standpoint
-of your application is the management of dataflow, i.e., timing.
+your terminal driver may not handle them properly.
+Set this environment variable to any value to disable the feature.
+You can also adjust your \fI\%stty\fP(1) settings to avoid the problem.
+.SS "\fINCURSES_NO_MAGIC_COOKIE\fP"
+Many terminals store video attributes as a property of a character cell,
+as
+.I curses
+does.
+Historically,
+some recorded changes in video attributes as data that logically
+.I occupies
+character cells on the display,
+switching attributes on or off,
+similarly to tags in a markup language;
+these are termed \*(``magic cookies\*('',
+and must be subsequently overprinted.
+If the
+.I \%term\%info
+entry for your terminal type does not adequately describe its handling
+of magic cookies,
+set this variable to any value to instruct
+.I \%ncurses
+to disable attributes entirely.
+.SS "\fINCURSES_NO_PADDING\fP"
+Most terminal type descriptions in the
+.I \%term\%info
+database detail hardware devices.
+Many people use
+.IR curses -based
+applications in terminal emulator programs that run in a windowing
+environment.
+These programs can duplicate all of the important features of a hardware
+terminal,
+but often lack their limitations.
+Chief among these absent drawbacks is the problem of data flow
+management;
+that is,
+limiting the speed of communication to what the hardware could handle.
 Unless a hardware terminal is interfaced into a terminal concentrator
 (which does flow control),
-it (or your application) must manage dataflow, preventing overruns.
-The cheapest solution (no hardware cost)
-is for your program to do this by pausing after
-operations that the terminal does slowly, such as clearing the display.
-.PP
-As a result, many terminal descriptions (including the vt100)
-have delay times embedded.
-You may wish to use these descriptions,
-but not want to pay the performance penalty.
-.PP
-Set the NCURSES_NO_PADDING environment variable to disable all but mandatory
-padding.
-Mandatory padding is used as a part of special control
-sequences such as \fIflash\fR.
-.SS NCURSES_NO_SETBUF
-This setting is obsolete.
-Before changes
-.RS 3
-.bP
-started with 5.9 patch 20120825
-and
-.bP
-continued
-though 5.9 patch 20130126
-.RE
-.PP
-\fBncurses\fR enabled buffered output during terminal initialization.
-This was done (as in SVr4 curses) for performance reasons.
-For testing purposes, both of \fBncurses\fR and certain applications,
+an application must manage flow control itself to prevent overruns and
+data loss.
+.PP
+A solution that comes at no hardware cost is for an application to pause
+after directing a terminal to execute an operation that it performs
+slowly,
+such as clearing the display.
+Many terminal type descriptions,
+including that for the VT100,
+embed delay specifications in capabilities.
+You may wish to use these terminal descriptions without paying the
+performance penalty.
+Set
+.I \%NCURSES_NO_PADDING
+to any value to disable all but mandatory padding.
+Mandatory padding is used by such terminal capabilities as
+.B \%flash_screen
+.RB ( flash ).
+.SS "\fINCURSES_NO_SETBUF\fP"
+(Obsolete)
+Prior to internal changes developed in
+.I \%ncurses
+5.9
+(patches 20120825 through 20130126),
+the library used \fI\%setbuf\fP(3) to enable fully buffered output when
+initializing the terminal.
+This was done,
+as in SVr4
+.IR curses ,
+to increase performance.
+For testing purposes,
+both of
+.I \%ncurses
+and of certain applications,
 this feature was made optional.
-Setting the NCURSES_NO_SETBUF variable
-disabled output buffering, leaving the output in the original (usually
-line buffered) mode.
-.PP
-In the current implementation,
-ncurses performs its own buffering and does not require this workaround.
-It does not modify the buffering of the standard output.
-.PP
-The reason for the change was to make the behavior for interrupts and
-other signals more robust.
-One drawback is that certain nonconventional programs would mix
-ordinary stdio calls with ncurses calls and (usually) work.
-This is no longer possible since ncurses is not using
-the buffered standard output but its own output (to the same file descriptor).
-As a special case, the low-level calls such as \fBputp\fP still use the
-standard output.
-But high-level curses calls do not.
-.SS NCURSES_NO_UTF8_ACS
-.PP
-During initialization, the \fBncurses\fR library
-checks for special cases where VT100 line-drawing (and the corresponding
-alternate character set capabilities) described in the terminfo are known
-to be missing.
-Specifically, when running in a UTF\-8 locale,
-the Linux console emulator and the GNU screen program ignore these.
-Ncurses checks the \fBTERM\fP environment variable for these.
-For other special cases, you should set this environment variable.
-Doing this tells ncurses to use Unicode values which correspond to
-the VT100 line-drawing glyphs.
-That works for the special cases cited,
-and is likely to work for terminal emulators.
-.PP
-When setting this variable, you should set it to a nonzero value.
-Setting it to zero (or to a nonnumber)
-disables the special check for \*(``linux\*('' and \*(``screen\*(''.
-.PP
-As an alternative to the environment variable,
-ncurses checks for an extended terminfo capability \fBU8\fP.
-This is a numeric capability which can be compiled using \fB@TIC@\ \-x\fP.
-For example
+Setting this variable disabled output buffering,
+leaving the output stream in the original
+(usually line-buffered)
+mode.
+.PP
+Nowadays,
+.I \%ncurses
+performs its own buffering and does not require this workaround;
+it does not modify the buffering of the standard output stream.
+This approach makes signal handling,
+as for interrupts,
+more robust.
+A drawback is that certain unconventional programs mixed
+\fI\%stdio\fP(3) calls with
+.I \%ncurses
+calls and (usually)
+got the behavior they expected.
+This is no longer the case;
+.I \%ncurses
+does not write to the standard output file descriptor through a
+.IR stdio -buffered
+stream.
+.PP
+As a special case,
+low-level API calls such as \fB\%putp\fP(3X) still use the
+standard output stream.
+High-level
+.I curses
+calls such as \fB\%printw\fP(3X) do not.
+.SS "\fINCURSES_NO_UTF8_ACS\fP"
+At initialization,
+.I \%ncurses
+inspects the
+.I TERM
+environment variable for special cases where VT100 forms-drawing
+characters
+(and the corresponding alternate character set
+.I \%term\%info
+capabilities)
+are known to be unsupported by terminal types that otherwise claim VT100
+compatibility.
+Specifically,
+when running in a UTF-8 locale,
+the Linux virtual console device and the GNU \fI\%screen\fP(1)
+program ignore them.
+Set this variable to a nonzero value to instruct
+.I \%ncurses
+that the terminal's ACS support is broken;
+the library then outputs Unicode code points that correspond to the
+forms-drawing
+characters.
+Set it to zero
+(or a non-integer)
+to disable the special check for terminal type names matching
+\*(``linux\*('' or \*(``screen\*('',
+directing
+.I \%ncurses
+to assume that the ACS feature works if the terminal type description
+advertises it.
+.PP
+As an alternative to use of this variable,
+.I \%ncurses
+checks for an extended
+.I \%term\%info
+numeric capability \fBU8\fP
+that can be compiled using
+.RB \*(`` "@TIC@ \-x" \*(''.
+Examples follow.
+.PP
 .RS 3
-.ft CW
-.sp
-.nf
+.EX
 # linux console, if patched to provide working
-# VT100 shift-in/shift-out, with corresponding font.
-linux-vt100|linux console with VT100 line-graphics,
+# VT100 shift\-in/shift\-out, with corresponding font.
+linux\-vt100|linux console with VT100 line\-graphics,
         U8#0, use=linux,
-.sp
+\&
 # uxterm with vt100Graphics resource set to false
-xterm-utf8|xterm relying on UTF-8 line-graphics,
+xterm\-utf8|xterm relying on UTF\-8 line\-graphics,
         U8#1, use=xterm,
-.fi
-.ft
+.EE
 .RE
 .PP
-The name \*(``U8\*('' is chosen to be two characters,
-to permit it to be used by applications that use ncurses'
-termcap interface.
-.SS NCURSES_TRACE
-.PP
-During initialization, the \fBncurses\fR debugging library
-checks the NCURSES_TRACE environment variable.
-If it is defined, to a numeric value, \fBncurses\fR calls the \fBtrace\fR
-function, using that value as the argument.
-.PP
-The argument values, which are defined in \fBcurses.h\fR, provide several
-types of information.
-When running with traces enabled, your application will write the
-file \fBtrace\fR to the current directory.
-.PP
-See \fBcurs_trace\fP(3X) for more information.
-.SS TERM
-.PP
-Denotes your terminal type.
-Each terminal type is distinct, though many are similar.
-.PP
-\fBTERM\fP is commonly set by terminal emulators to help
-applications find a workable terminal description.
-Some of those choose a popular approximation, e.g.,
-\*(``ansi\*('', \*(``vt100\*('', \*(``xterm\*('' rather than an exact fit.
-Not infrequently, your application will have problems with that approach,
-e.g., incorrect function-key definitions.
-.PP
-If you set \fBTERM\fP in your environment,
-it has no effect on the operation of the terminal emulator.
-It only affects the way applications work within the terminal.
-Likewise, as a general rule (\fBxterm\fP being a rare exception),
-terminal emulators which allow you to
-specify \fBTERM\fP as a parameter or configuration value do
-not change their behavior to match that setting.
-.SS TERMCAP
-If the \fBncurses\fR library has been configured with \fItermcap\fR
-support, \fBncurses\fR will check for a terminal's description in
-termcap form if it is not available in the terminfo database.
-.PP
-The \fBTERMCAP\fP environment variable contains
-either a terminal description (with newlines stripped out),
-or a file name telling where the information denoted by
-the \fBTERM\fP environment variable exists.
-In either case, setting it directs \fBncurses\fR to ignore
-the usual place for this information, e.g., /etc/termcap.
-.SS TERMINFO
-.PP
-\fBncurses\fP can be configured to read from multiple terminal databases.
-The \fBTERMINFO\fP variable overrides the location for
-the default terminal database.
-Terminal descriptions (in terminal format) are stored in terminal databases:
+The two-character name \*(``U8\*('' was chosen to permit its use via
+.IR \%ncurses 's
+.I termcap
+interface.
+.SS "\fINCURSES_TRACE\fP"
+At initialization,
+.I \%ncurses
+(in its debugging configuration)
+checks for this variable's presence.
+If defined with an integral value,
+the library calls \fB\%curses_trace\fP(3X) with that value as the
+argument.
+.SS "\fITERM\fP"
+The
+.I TERM
+variable denotes the terminal type.
+Each is distinct,
+though many are similar.
+It is commonly set by terminal emulators to help applications find a
+workable terminal description.
+Some choose a popular approximation such as \*(``ansi\*('',
+\*(``vt100\*('', or \*(``xterm\*('' rather than an exact fit to their
+capabilities.
+Not infrequently,
+an application will have problems with that approach;
+for example,
+a key stroke may not operate correctly,
+or produce no effect but seeming garbage characters on the screen.
+.PP
+Setting
+.I TERM
+has no effect on hardware operation;
+it affects the way applications communicate with the terminal.
+Likewise,
+as a general rule
+(\fIxterm\fP(1) being a rare exception),
+terminal emulators that allow you to specify
+.I TERM
+as a parameter or configuration value do not change their behavior to
+match that setting.
+.SS "\fITERMCAP\fP"
+If
+.I \%ncurses
+is configured with
+.I termcap
+support,
+it checks for a terminal type description in
+.I termcap
+format if one in
+.I \%term\%info
+format is not available.
+Setting this variable directs
+.I \%ncurses
+to ignore the usual
+.I termcap
+database location,
+.IR \%/etc/termcap ;
+see
+.I \%TERMPATH
+below.
+.I \%TERMCAP
+should contain either a terminal description
+(with newlines stripped out),
+or a file name indicating where the information required by the
+.I TERM
+environment variable is stored.
+.SS "\fITERMINFO\fP"
+.I \%ncurses
+can be configured to read terminal type description databases in various
+locations using different formats.
+This variable overrides the default location.
 .bP
-Normally these are stored in a directory tree,
-using subdirectories named by the first letter of the terminal names therein.
-.IP
-This is the scheme used in System V, which legacy Unix systems use,
-and the \fBTERMINFO\fP variable is used by \fIcurses\fP applications on those
-systems to override the default location of the terminal database.
+Descriptions in
+.I \%term\%info
+format are normally stored in a directory tree using subdirectories
+named by the common first letters of the terminal types named therein.
+This is the scheme used in System\ V.
 .bP
-If \fBncurses\fP is built to use hashed databases,
-then each entry in this list may be the path of a hashed database file, e.g.,
-.NS
-/usr/share/terminfo.db
-.NE
-.IP
+If
+.I \%ncurses
+is configured to use hashed databases,
+then
+.I \%TERM\%INFO
+may name its location,
+such as
+.IR \%/usr/share/terminfo.db ,
 rather than
-.NS
-/usr/share/terminfo/
-.NE
-.IP
-The hashed database uses less disk-space and is a little faster than the
+.IR \%/usr/share/terminfo/ .
+.PP
+The hashed database uses less disk space and is a little faster than the
 directory tree.
 However,
 some applications assume the existence of the directory tree,
-reading it directly
-rather than using the terminfo library calls.
+and read it directly
+rather than using the
+.I \%term\%info
+API.
 .bP
-If \fBncurses\fP is built with a support for reading termcap files
-directly, then an entry in this list may be the path of a termcap file.
+If
+.I \%ncurses
+is configured with
+.I termcap
+support,
+this variable may contain the location of a
+.I \%termcap
+file.
 .bP
-If the \fBTERMINFO\fP variable begins with
-\*(``hex:\*('' or \*(``b64:\*('',
-\fBncurses\fP uses the remainder of that variable as a compiled terminal
+If the value of
+.I \%TERM\%INFO
+begins with \*(``hex:\*('' or \*(``b64:\*('',
+.I \%ncurses
+uses the remainder of the value as a compiled
+.I \%term\%info
 description.
-You might produce the base64 format using \fBinfocmp\fP(1M):
-.NS
-TERMINFO="$(infocmp -0 -Q2 -q)"
+You might produce the base64 format using \fB\%infocmp\fP(1M).
+.RS 4
+.IP
+.EX
+TERMINFO=$(infocmp \-0 \-Q2 \-q)
 export TERMINFO
-.NE
+.EE
+.RE
 .IP
-The compiled description is used if it corresponds to the terminal identified
-by the \fBTERM\fP variable.
-.PP
-Setting \fBTERMINFO\fP is the simplest,
-but not the only way to set location of the default terminal database.
-The complete list of database locations in order follows:
-.RS 3
+The compiled description is used only if it corresponds to the terminal
+type identified by
+.IR TERM .
+.PP
+Setting
+.I \%TERM\%INFO
+is the simplest,
+but not the only,
+way to direct
+.I \%ncurses
+to a terminal database.
+The search path is as follows.
 .bP
-the last terminal database to which \fBncurses\fR wrote,
-if any, is searched first
+the last terminal database to which the running
+.I \%ncurses
+application wrote,
+if any
 .bP
-the location specified by the TERMINFO environment variable
+the location specified by the
+.I \%TERM\%INFO
+environment variable
 .bP
-$HOME/.terminfo
+.I $HOME/.terminfo
 .bP
-locations listed in the TERMINFO_DIRS environment variable
+locations listed in the
+.I \%TERMINFO_DIRS
+environment variable
+.ds td \" empty
+.if !'@TERMINFO_DIRS@'no default value' .as td @TERMINFO_DIRS@
+.if !'@TERMINFO@\*(td'' \{\
 .bP
-one or more locations whose names are configured and compiled into the
-ncurses library, i.e.,
+location(s) configured and compiled into
+.I \%ncurses
 .RS 3
+.if !'\*(td'' \{\
 .bP
-@TERMINFO_DIRS@ (corresponding to the TERMINFO_DIRS variable)
+.I \%@TERMINFO_DIRS@
+.\}
+.if !'@TERMINFO'' .if !'\*(td'@TERMINFO@' \{\
 .bP
-@TERMINFO@ (corresponding to the TERMINFO variable)
+.I \%@TERMINFO@
+.\}
+.\}
 .RE
-.RE
-.PP
-.SS TERMINFO_DIRS
-.PP
-Specifies a list of locations to search for terminal descriptions.
-Each location in the list is a terminal database as described in
-the section on the \fBTERMINFO\fP variable.
-The list is separated by colons (i.e., ":") on Unix, semicolons on OS/2 EMX.
-.PP
-There is no corresponding feature in System V terminfo;
-it is an extension developed for \fBncurses\fP.
-.SS TERMPATH
+.SS "\fITERMINFO_DIRS\fP"
+This variable specifies a list of locations,
+akin to
+.IR PATH ,
+in which
+.I \%ncurses
+searches for the terminal type descriptions described by
+.I \%TERMINFO
+above.
+The list items are separated by colons on Unix
+and semicolons on OS/2 EMX.
+System\ V
+.I \%term\%info
+lacks a corresponding feature;
+.I \%TERMINFO_DIRS
+is an
+.I \%ncurses
+extension.
+.SS "\fITERMPATH\fP"
+If
+.I \%TERMCAP
+does not hold a terminal type description or file name,
+then
+.I \%ncurses
+checks the contents of
+.IR \%TERMPATH ,
+a list of locations,
+akin to
+.IR PATH ,
+in which it searches for
+.I termcap
+terminal type descriptions.
+The list items are separated by colons on Unix
+and semicolons on OS/2 EMX.
+.PP
+If both
+.I \%TERMCAP
+and
+.I \%TERMPATH
+are unset or invalid,
+.I \%ncurses
+searches for the files
+.IR \%/etc/termcap ,
+.IR \%/usr/share/misc/termcap ,
+and
+.IR \%$HOME/.termcap ,
+in that order.
+.SH "ALTERNATE CONFIGURATIONS"
+Many different
+.I \%ncurses
+configurations are possible,
+determined by the options given to the
+.I \%configure
+script when building the library.
+Run the script with the
+.B \-\-help
+option to peruse them all.
+A few are of particular significance to the application developer
+employing
+.IR \%ncurses .
+.TP 5
+.B \-\-disable\-overwrite
+The standard include for \fI\%ncurses\fP is as noted in \fBSYNOPSIS\fP:
+.RS 5
 .PP
-If \fBTERMCAP\fP does not hold a file name then \fBncurses\fR checks
-the \fBTERMPATH\fP environment variable.
-This is a list of filenames separated by spaces or colons (i.e., ":") on Unix,
-semicolons on OS/2 EMX.
+.RS 4
+.EX
+\fB#include <curses.h>\fP
+.EE
+.RE
 .PP
-If the \fBTERMPATH\fP environment variable is not set,
-\fBncurses\fR looks in the files
-.NS
-/etc/termcap, /usr/share/misc/termcap and $HOME/.termcap,
-.NE
+This option is used to avoid filename conflicts when \fI\%ncurses\fP
+is not the main implementation of curses of the computer.
+If \fI\%ncurses\fP is installed disabling overwrite,
+it puts its headers in a subdirectory,
+e.g.,
 .PP
-in that order.
+.RS 4
+.EX
+\fB#include <ncurses/curses.h>\fP
+.EE
+.RE
 .PP
-The library may be configured to disregard the following variables when the
-current user is the superuser (root), or if the application uses setuid or
-setgid permissions:
-.NS
-$TERMINFO, $TERMINFO_DIRS, $TERMPATH, as well as $HOME.
-.NE
-.SH ALTERNATE CONFIGURATIONS
-.PP
-Several different configurations are possible,
-depending on the configure script options used when building \fBncurses\fP.
-There are a few main options whose effects are visible to the applications
-developer using \fBncurses\fP:
-.TP 5
-\-\-disable\-overwrite
-The standard include for \fBncurses\fP is as noted in \fBSYNOPSIS\fP:
-.NS
-\fB#include <curses.h>\fR
-.NE
-.IP
-This option is used to avoid filename conflicts when \fBncurses\fP
-is not the main implementation of curses of the computer.
-If \fBncurses\fP is installed disabling overwrite, it puts its headers in
-a subdirectory, e.g.,
-.NS
-\fB#include <ncurses/curses.h>\fR
-.NE
-.IP
 It also omits a symbolic link which would allow you to use \fB\-lcurses\fP
 to build executables.
+.RE
 .TP 5
-\-\-enable\-widec
+.B \-\-enable\-widec
 The configure script renames the library and
 (if the \fB\-\-disable\-overwrite\fP option is used)
 puts the header files in a different subdirectory.
 All of the library names have a \*(``w\*('' appended to them,
 i.e., instead of
-.NS
-\fB\-lncurses\fR
-.NE
-.IP
+.RS 5
+.PP
+.RS 4
+.EX
+\fB\-lncurses\fP
+.EE
+.RE
+.PP
 you link with
-.NS
-\fB\-lncursesw\fR
-.NE
-.IP
+.PP
+.RS 4
+.EX
+\fB\-lncursesw\fP
+.EE
+.RE
+.PP
 You must also enable the wide-character features in the header file
 when compiling for the wide-character library
 to use the extended (wide-character) functions.
-The symbol which enables these features has changed since XSI Curses, Issue 4:
-.RS
+The symbol which enables these features has changed
+since X/Open Curses, Issue 4:
 .bP
 Originally, the wide-character feature required the symbol
 \fB_XOPEN_SOURCE_EXTENDED\fP
@@ -1270,19 +1729,19 @@ Alternatively, you can enable the feature by defining \fBNCURSES_WIDECHAR\fP
 with the caveat that some other header file than \fBcurses.h\fP
 may require a specific value for \fB_XOPEN_SOURCE\fP
 (or a system-specific symbol).
-.RE
-.IP
-The \fBcurses.h\fP file which is installed for the wide-character
-library is designed to be compatible with the normal library's header.
-Only the size of the \fBWINDOW\fP structure differs, and very few
-applications require more than a pointer to \fBWINDOW\fPs.
-.IP
+.PP
+The \fI\%curses.h\fP header file installed for the wide-character
+library is designed to be compatible with the non-wide library's header.
+Only the size of the \fI\%WINDOW\fP structure differs;
+few applications require more than pointers to \fI\%WINDOW\fPs.
+.PP
 If the headers are installed allowing overwrite,
 the wide-character library's headers should be installed last,
 to allow applications to be built using either library
 from the same set of headers.
+.RE
 .TP 5
-\-\-with\-pthread
+.B \-\-with\-pthread
 The configure script renames the library.
 All of the library names have a \*(``t\*('' appended to them
 (before any \*(``w\*('' added by \fB\-\-enable\-widec\fP).
@@ -1292,20 +1751,20 @@ allow read-only access.
 At the same time, setter-functions are provided to set these values.
 Some applications (very few) may require changes to work with this convention.
 .TP 5
-\-\-with\-shared
-.TP
-\-\-with\-normal
-.TP
-\-\-with\-debug
-.TP
-\-\-with\-profile
+.B \-\-with\-shared
+.tQ
+.B \-\-with\-normal
+.tQ
+.B \-\-with\-debug
+.tQ
+.B \-\-with\-profile
 The shared and normal (static) library names differ by their suffixes,
 e.g., \fBlibncurses.so\fP and \fBlibncurses.a\fP.
 The debug and profiling libraries add a \*(``_g\*(''
 and a \*(``_p\*('' to the root names respectively,
 e.g., \fBlibncurses_g.a\fP and \fBlibncurses_p.a\fP.
 .TP 5
-\-\-with\-termlib
+.B \-\-with\-termlib
 Low-level functions which do not depend upon whether the library
 supports wide-characters, are provided in the tinfo library.
 .IP
@@ -1316,242 +1775,487 @@ when only low-level functions are needed.
 Those functions are described in these pages:
 .RS
 .bP
-\fBcurs_extend\fP(3X) \- miscellaneous curses extensions
+\fB\%curs_extend\fP(3X) \- miscellaneous \fIcurses\fP extensions
 .bP
-\fBcurs_inopts\fR(3X) \- \fBcurses\fR input options
+\fB\%curs_inopts\fP(3X) \- \fIcurses\fP input options
 .bP
-\fBcurs_kernel\fR(3X) \- low-level \fBcurses\fR routines
+\fB\%curs_kernel\fP(3X) \- low-level \fIcurses\fP routines
 .bP
-\fBcurs_termattrs\fR(3X) \- \fBcurses\fR environment query routines
+\fB\%curs_termattrs\fP(3X) \- \fIcurses\fP environment query routines
 .bP
-\fBcurs_termcap\fR(3X) \- \fBcurses\fR emulation of termcap
+\fB\%curs_termcap\fP(3X) \- \fIcurses\fP emulation of \fItermcap\fP
 .bP
-\fBcurs_terminfo\fR(3X) \- \fBcurses\fR interfaces to terminfo database
+\fB\%curs_terminfo\fP(3X) \- \fIcurses\fP interface to \fIterminfo\fP
+database
 .bP
-\fBcurs_util\fR(3X) \- miscellaneous \fBcurses\fR utility routines
+\fB\%curs_util\fP(3X) \- miscellaneous \fIcurses\fP utility routines
 .RE
 .TP 5
-\-\-with\-trace
+.B \-\-with\-trace
 The \fBtrace\fP function normally resides in the debug library,
 but it is sometimes useful to configure this in the shared library.
 Configure scripts should check for the function's existence rather
 than assuming it is always in the debug library.
 .SH FILES
-.TP 5
-@DATADIR@/tabset
-directory containing initialization files for the terminal capability database
-@TERMINFO@
-terminal capability database
-.SH SEE ALSO
-\fBterminfo\fR(\*n) and related pages whose names begin
-\*(``curs_\*('' for detailed routine descriptions.
-.br
-\fBcurs_variables\fR(3X)
-.br
-\fBuser_caps\fP(5) for user-defined capabilities
-.SH EXTENSIONS
-The \fBncurses\fR library can be compiled with an option (\fB\-DUSE_GETCAP\fR)
-that falls back to the old-style /etc/termcap file if the terminal setup code
-cannot find a terminfo entry corresponding to \fBTERM\fR.
-Use of this feature
-is not recommended, as it essentially includes an entire termcap compiler in
-the \fBncurses\fR startup code, at significant cost in core and startup cycles.
-.PP
-The \fBncurses\fR library includes facilities for capturing mouse events on
-certain terminals (including xterm).
-See the \fBcurs_mouse\fR(3X)
-manual page for details.
-.PP
-The \fBncurses\fR library includes facilities for responding to window
-resizing events, e.g., when running in an xterm.
-See the \fBresizeterm\fR(3X)
-and \fBwresize\fR(3X) manual pages for details.
-In addition, the library may be configured with a \fBSIGWINCH\fP handler.
-.PP
-The \fBncurses\fR library extends the fixed set of function key capabilities
-of terminals by allowing the application designer to define additional
-key sequences at runtime.
-See the \fBdefine_key\fR(3X)
-\fBkey_defined\fR(3X),
-and \fBkeyok\fR(3X) manual pages for details.
-.PP
-The \fBncurses\fR library can exploit the capabilities of terminals which
-implement the ISO\-6429 SGR 39 and SGR 49 controls, which allow an application
-to reset the terminal to its original foreground and background colors.
-From the users' perspective, the application is able to draw colored
-text on a background whose color is set independently, providing better
-control over color contrasts.
-See the \fBdefault_colors\fR(3X) manual page for details.
-.PP
-The \fBncurses\fR library includes a function for directing application output
-to a printer attached to the terminal device.
-See the \fBcurs_print\fR(3X) manual page for details.
-.SH PORTABILITY
-The \fBncurses\fR library is intended to be BASE-level conformant with XSI
-Curses.
-The EXTENDED XSI Curses functionality
-(including color support) is supported.
-.PP
-A small number of local differences (that is, individual differences between
-the XSI Curses and \fBncurses\fR calls) are described in \fBPORTABILITY\fR
-sections of the library man pages.
-.SS Error checking
-.PP
-In many cases, X/Open Curses is vague about error conditions,
-omitting some of the SVr4 documentation.
-.PP
-Unlike other implementations, this one checks parameters such as pointers
-to WINDOW structures to ensure they are not null.
-The main reason for providing this behavior is to guard against programmer
-error.
-The standard interface does not provide a way for the library
-to tell an application which of several possible errors were detected.
-Relying on this (or some other) extension will adversely affect the
-portability of curses applications.
-.SS Extensions versus portability
-.PP
-Most of the extensions provided by ncurses have not been standardized.
-Some have been incorporated into other implementations, such as
-PDCurses or NetBSD curses.
-Here are a few to consider:
+.TP
+.I @DATADIR@/tabset
+tab stop initialization database
+.TP
+.I \*d
+compiled terminal capability database
+.SH NOTES
+X/Open Curses permits most functions it specifies to be made available
+as macros as well.
+.\" See X/Open Curses Issue 4, Version 2, pp. 227-234.
+.\" See X/Open Curses Issue 7, pp. 311-318.
+\fI\%ncurses\fP does so
 .bP
-The routine \fBhas_key\fR is not part of XPG4, nor is it present in SVr4.
-See the \fBcurs_getch\fR(3X) manual page for details.
+for functions that return values via their parameters,
 .bP
-The routine \fBslk_attr\fR is not part of XPG4, nor is it present in SVr4.
-See the \fBcurs_slk\fR(3X) manual page for details.
+to support obsolete features,
+.bP
+to reuse functions
+(for example,
+those that move the cursor before another operation),
+and
 .bP
-The routines \fBgetmouse\fR, \fBmousemask\fR, \fBungetmouse\fR,
-\fBmouseinterval\fR, and \fBwenclose\fR relating to mouse interfacing are not
-part of XPG4, nor are they present in SVr4.
-See the \fBcurs_mouse\fR(3X) manual page for details.
+a few special cases.
+.PP
+If the standard output file descriptor of an
+.I \%ncurses
+program is redirected to something that is not a terminal device,
+the library writes screen updates to the standard error file descriptor.
+This was an undocumented feature of SVr3
+.IR curses .
+.PP
+See subsection \*(``Header Files\*('' below regarding symbols exposed by
+inclusion of \fI\%curses.h\fP.
+.SH EXTENSIONS
+.I \%ncurses
+enables an application to capture mouse events on certain terminals,
+including \fI\%xterm\fP(1);
+see \fB\%curs_mouse\fP(3X).
+.PP
+.I \%ncurses
+provides a means of responding to window resizing events,
+as when running in a GUI terminal emulator application such as
+.IR \%xterm ;
+see \fB\%resizeterm\fP(3X) and \fB\%wresize\fP(3X).
+.PP
+.I \%ncurses
+allows an application to query the terminal for the presence of a wide
+variety of special keys;
+see \fB\%has_key\fP(3X).
+.PP
+.I \%ncurses
+extends the fixed set of function key capabilities specified by X/Open
+Curses by allowing the application programmer to define additional key
+events at runtime;
+see
+\fB\%define_key\fP(3X),
+\fB\%key_defined\fP(3X),
+\fB\%keybound\fP(3X),
+and
+\fB\%keyok\fP(3X).
+.PP
+.I \%ncurses
+can exploit the capabilities of terminals implementing ISO\ 6429/ECMA-48
+SGR\ 39 and SGR\ 49 sequences,
+which allow an application to reset the terminal to its original
+foreground and background colors.
+From a user's perspective,
+the application is able to draw colored text on a background whose color
+is set independently,
+providing better control over color contrasts.
+See \fB\%default_colors\fP(3X).
+.PP
+An
+.I \%ncurses
+application can eschew knowledge of
+.I \%WINDOW
+structure internals,
+instead using accessor functions such as
+\fB\%is_scrollok\fP(3X).
+.PP
+.I \%ncurses
+enables an application to direct application output to a printer
+attached to the terminal device;
+see \fB\%curs_print\fP(3X).
+.PP
+.I \%ncurses
+offers \fB\%slk_attr\fP(3X) as a counterpart of \fB\%attr_get\fP(3X) for
+soft-label key lines,
+and \fB\%extended_slk_color\fP(3X) as a form of \fB\%slk_color\fP(3X)
+that can gather color information from them when many colors are
+supported.
+.PP
+Some extensions are available only if
+.I \%ncurses
+permits modification of \fB\%unctrl\fP(3X)'s behavior;
+see \fB\%use_legacy_coding\fP(3X).
+.I \%ncurses
+is compiled to support them;
+section \*(``ALTERNATE CONFIGURATIONS\*('' describes how.
 .bP
-The routine \fBmcprint\fR was not present in any previous curses implementation.
-See the \fBcurs_print\fR(3X) manual page for details.
+Rudimentary support for multi-threaded applications may be available;
+see \fBcurs_threads\fP(3X).
 .bP
-The routine \fBwresize\fR is not part of XPG4, nor is it present in SVr4.
-See the \fBwresize\fR(3X) manual page for details.
+Functions that ease the management of multiple screens can be exposed;
+see \fBcurs_sp_funcs\fP(3X).
 .bP
-The WINDOW structure's internal details can be hidden from application
-programs.
-See \fBcurs_opaque\fR(3X) for the discussion of \fBis_scrollok\fR, etc.
+To aid applications to debug their memory usage,
+.I ncurses
+optionally offers functions to more aggressively free memory it
+dynamically allocates itself;
+see \fBcurs_memleaks\fP(3X).
 .bP
-This implementation can be configured to provide rudimentary support
-for multi-threaded applications.
-See \fBcurs_threads\fR(3X) for details.
+The library facilitates auditing and troubleshooting of its behavior;
+see \fBcurs_trace\fP(3X).
 .bP
-This implementation can also be configured to provide a set of functions which
-improve the ability to manage multiple screens.
-See \fBcurs_sp_funcs\fR(3X) for details.
-.SS Padding differences
-.PP
-In historic curses versions, delays embedded in the capabilities \fBcr\fR,
-\fBind\fR, \fBcub1\fR, \fBff\fR and \fBtab\fR activated corresponding delay
-bits in the UNIX tty driver.
-In this implementation, all padding is done by sending NUL bytes.
-This method is slightly more expensive, but narrows the interface
-to the UNIX kernel significantly and increases the package's portability
-correspondingly.
-.SS Header files
-The header file \fB<curses.h>\fR automatically includes the header files
-\fB<stdio.h>\fR and \fB<unctrl.h>\fR.
+The compiler option
+.B \%\-DUSE_GETCAP
+causes the library to fall back to reading
+.I \%/etc/termcap
+if the terminal setup code cannot find a
+.I \%term\%info
+entry corresponding to
+.IR TERM .
+Use of this feature is not recommended,
+as it essentially includes an entire
+.I termcap
+compiler in the
+.I \%ncurses
+startup code,
+at a cost in memory usage and application launch latency.
+.PP
+.I \%PDCurses
+and NetBSD
+.I curses
+incorporate some
+.I \%ncurses
+extensions.
+Individual man pages indicate where this is the case.
+.SH PORTABILITY
+X/Open Curses defines two levels of conformance,
+\*(``base\*('' and \*(``enhanced\*(''.
+The latter includes several additional features,
+such as wide-character and color support.
+.I \%ncurses
+intends base-level conformance with X/Open Curses,
+and supports all features of its enhanced level
+except the \fB\%untic\fP utility.
+.PP
+Differences between X/Open Curses and
+.I \%ncurses
+are documented in the \*(``PORTABILITY\*('' sections of applicable man
+pages.
+.SS "Error Checking"
+In many cases, X/Open Curses is vague about error conditions,
+omitting some of the SVr4 documentation.
+.PP
+Unlike other implementations,
+.I \%ncurses
+checks pointer parameters,
+such as those to
+.I \%WINDOW
+structures,
+to ensure that they are not null.
+This is done primarily to guard against programmer error.
+The standard interface does not provide a way for the library
+to tell an application which of several possible errors occurred.
+Relying on this
+(or some other)
+extension adversely affects the portability of
+.I curses
+applications.
+.SS "Padding Differences"
+In historical
+.I curses
+implementations,
+delays embedded in the
+.I \%term\%info
+capabilities
+.B \%carriage_return
+.RB ( cr ),
+.B \%scroll_forward
+.RB ( ind ),
+.B \%cursor_left
+.RB ( cub1 ),
+.B \%form_feed
+.RB ( ff ),
+and
+.B \%tab
+.RB ( ht )
+activated corresponding delay bits in the Unix terminal driver.
+.I \%ncurses
+performs all padding by sending NUL bytes to the device.
+This method is slightly more expensive,
+but narrows the interface to the Unix kernel significantly and
+correspondingly increases the package's portability.
+.SS "Header Files"
+The header file
+.I \%curses.h
+itself includes the header files
+.I \%stdio.h
+and
+.IR \%unctrl.h .
 .PP
 X/Open Curses has more to say,
-but does not finish the story:
 .RS 4
 .PP
-The inclusion of <curses.h> may make visible all symbols
-from the headers <stdio.h>, <term.h>, <termios.h>, and <wchar.h>.
+The inclusion of
+.I \%curses.h
+may make visible all symbols from the headers
+.IR \%stdio.h ,
+.IR \%term.h ,
+.IR \%termios.h ,
+and
+.IR \%wchar.h .
 .RE
 .PP
-Here is a more complete story:
+but does not finish the story.
+A more complete account follows.
 .bP
-Starting with BSD curses, all implementations have included <stdio.h>.
+Starting with 4BSD
+.I curses
+(1980)
+all implementations have provided a
+.I \%curses.h
+file.
 .IP
-BSD curses included <curses.h> and <unctrl.h> from an internal header
-"curses.ext" ("ext" was a short name for \fIexterns\fP).
+BSD
+.I curses
+code included
+.I \%curses.h
+and
+.I \%unctrl.h
+from an internal header file
+.IR \%curses.ext ,
+where
+\*(``ext\*('' abbreviated \*(``externs\*(''.
 .IP
-BSD curses used <stdio.h> internally (for \fBprintw\fP and \fBscanw\fP),
-but nothing in <curses.h> itself relied upon <stdio.h>.
+The implementations of
+.I \%printw
+and
+.I \%scanw
+used undocumented internal functions of the standard I/O library
+.RI ( _doprnt
+and
+.IR _doscan ),
+but nothing in
+.I \%curses.h
+itself relied upon
+.IR \%stdio.h .
 .bP
-SVr2 curses added \fBnewterm\fP(3X), which relies upon <stdio.h>.
-That is, the function prototype uses \fBFILE\fP.
+SVr2
+.I curses
+added
+.IR \%newterm ,
+which relies upon
+.I \%stdio.h
+because its function prototype employs the
+.I FILE
+type.
 .IP
-SVr4 curses added \fBputwin\fP and \fBgetwin\fP, which also use <stdio.h>.
+SVr4
+.I curses
+added
+.I \%putwin
+and
+.IR \%getwin ,
+which also use
+.IR \%stdio.h .
 .IP
-X/Open Curses documents all three of these functions.
+X/Open Curses specifies all three of these functions.
 .IP
-SVr4 curses and X/Open Curses do not require the developer to
-include <stdio.h> before including <curses.h>.
-Both document curses showing <curses.h> as the only required header.
+SVr4
+.I curses
+and X/Open Curses do not require the developer to include
+.I \%stdio.h
+before
+.IR \%curses.h .
+Both document use of
+.I curses
+as requiring only
+.IR \%curses.h .
 .IP
-As a result, standard <curses.h> will always include <stdio.h>.
+As a result,
+standard
+.I \%curses.h
+always includes
+.IR \%stdio.h .
 .bP
-X/Open Curses is inconsistent with respect to SVr4 regarding <unctrl.h>.
+X/Open Curses and SVr4
+.I curses
+are inconsistent with respect to
+.IR \%unctrl.h .
 .IP
-As noted in \fBcurs_util\fP(3X), ncurses includes <unctrl.h> from
-<curses.h> (like SVr4).
+As noted in \fBcurs_util\fP(3X),
+.I \%ncurses
+includes
+.I \%unctrl.h
+from
+.I \%curses.h
+(as SVr4 does).
 .bP
-X/Open's comments about <term.h> and <termios.h> may refer to HP-UX and AIX:
+X/Open Curses's comments about
+.I \%term.h
+and
+.I \%termios.h
+may refer to HP-UX and AIX.
 .IP
-HP-UX curses includes <term.h> from <curses.h>
-to declare \fBsetupterm\fP in curses.h,
-but ncurses (and Solaris curses) do not.
+HP-UX
+.I curses
+includes
+.I \%term.h
+from
+.I \%curses.h
+to declare
+.I \%setupterm
+in
+.IR \%curses.h ,
+but
+.I \%ncurses
+and Solaris
+.I curses
+do not.
 .IP
-AIX curses includes <term.h> and <termios.h>.
-Again, ncurses (and Solaris curses) do not.
+AIX
+.I curses
+includes
+.I \%term.h
+and
+.IR \% termios.h .
+Again,
+.I \%ncurses
+and Solaris
+.I curses
+do not.
 .bP
-X/Open says that <curses.h> \fImay\fP include <term.h>,
-but there is no requirement that it do that.
+X/Open Curses says that
+.I \%curses.h
+.B may
+include
+.IR \%term.h ,
+but does not require it to do so.
 .IP
-Some programs use functions declared in both <curses.h> and <term.h>,
-and must include both headers in the same module.
-Very old versions of AIX curses required including <curses.h>
-before including <term.h>.
+Some programs use functions declared in both
+.I \%curses.h
+and
+.IR \%term.h ,
+and must include both header files in the same module.
+Very old versions of AIX
+.I curses
+required inclusion of
+.I \%curses.h
+before
+.IR \%term.h .
 .IP
-Because ncurses header files include the headers needed to
-define datatypes used in the headers,
-ncurses header files can be included in any order.
-But for portability, you should include <curses.h> before <term.h>.
+The header files supplied by
+.I \%ncurses
+include the standard library headers required for its declarations,
+so
+.IR \%ncurses 's
+own header files can be included in any order.
+But for portability,
+you should include
+.I \%curses.h
+before
+.IR \%term.h .
 .bP
-X/Open Curses says \fI"may make visible"\fP
-because including a header file does not necessarily make all symbols
-in it visible (there are ifdef's to consider).
+X/Open Curses says \*(``may make visible\*('' because including a header
+file does not necessarily make visible all of the symbols in it
+(consider
+.B \%#ifdef
+and similar).
 .IP
-For instance, in ncurses <wchar.h> \fImay\fP be included if
-the proper symbol is defined, and if ncurses is configured for
-wide-character support.
-If the header is included, its symbols may be made visible.
-That depends on the value used for \fB_XOPEN_SOURCE\fP
+For instance,
+.IR \%ncurses 's
+.I \%curses.h
+.B may \" bold to contrast with preceding italic
+include
+.I \%wchar.h
+if the proper symbol is defined,
+and if
+.I \%ncurses
+is configured for wide-character support.
+If
+.I \%wchar.h
+is included,
+its symbols
+.B may \" bold for consistency in this paragraph
+be made visible depending on the value of the
+.B _XOPEN_SOURCE
 feature test macro.
 .bP
-X/Open Curses documents one required header,
-in a special case: <stdarg.h> before <curses.h> to prototype
-the \fBvw_printw\fP and \fBvw_scanw\fP functions
+X/Open Curses mandates an application's inclusion of one standard C
+library header in a special case:
+.I \%stdarg.h
+before
+.I \%curses.h
+to prototype the functions
+.I \%vw_printw
+and
+.I \%vw_scanw
 (as well as the obsolete
-the \fBvwprintw\fP and \fBvwscanw\fP functions).
-Each of those uses a \fBva_list\fP parameter.
+.I \%vwprintw
+and
+.IR \%vwscanw ).
+Each of these takes a variadic argument list,
+a
+.I \%va_list
+parameter,
+like that of \fI\%printf\fP(3).
 .IP
-The two obsolete functions were introduced in SVr3.
-The other functions were introduced in X/Open Curses.
-In between, SVr4 curses provided for the possibility that
-an application might include either <varargs.h> or <stdarg.h>.
-Initially, that was done by using \fBvoid*\fP for the \fBva_list\fP
+SVr3
+.I curses
+introduced
+the two obsolete functions,
+and X/Open Curses the others.
+In between,
+SVr4
+.I curses
+provided for the possibility that an application might include either
+.I \%varargs.h
+or
+.IR \%stdarg.h .
+These represented contrasting approaches to handling variadic
+argument lists.
+The older interface,
+.IR \%varargs.h ,
+used a pointer to
+.I char \" V7, 32V, System III, 3BSD
+for variadic functions'
+.I \%va_list
 parameter.
-Later, a special type (defined in <stdio.h>) was introduced,
-to allow for compiler type-checking.
-That special type is always available,
-because <stdio.h> is always included by <curses.h>.
+Later,
+the list acquired its own standard data type,
+.IR \%va_list ,
+defined in
+.IR \%stdarg.h ,
+empowering the compiler to check the types of a function call's actual
+parameters against the formal ones declared in its prototype.
 .IP
-None of the X/Open Curses implementations require an application
-to include <stdarg.h> before <curses.h> because they either
-have allowed for a special type, or (like ncurses) include <stdarg.h>
-directly to provide a portable interface.
-.SH NOTES
-.PP
-If standard output from a \fBncurses\fR program is re-directed to something
-which is not a tty, screen updates will be directed to standard error.
-This was an undocumented feature of AT&T System V Release 3 curses.
+No conforming implementations of X/Open Curses require an application
+to include
+.I \%stdarg.h
+before
+.I \%curses.h
+because they either have allowed for a special type,
+or,
+like
+.IR \%ncurses ,
+they include
+.I \%stdarg.h
+themselves to provide a portable interface.
 .SH AUTHORS
-Zeyd M. Ben-Halim, Eric S. Raymond, Thomas E. Dickey.
-Based on pcurses by Pavel Curtis.
+Zeyd M. Ben-Halim,
+Eric S. Raymond,
+Thomas E. Dickey.
+Based on
+.I \%pcurses
+by Pavel Curtis.
+.SH SEE ALSO
+\fB\%curs_variables\fP(3X),
+\fB\%terminfo\fP(5),
+\fB\%user_caps\fP(5)
diff --git a/contrib/ncurses/man/new_pair.3x b/contrib/ncurses/man/new_pair.3x
index c22523887ac6..5e844bf8fc25 100644
--- a/contrib/ncurses/man/new_pair.3x
+++ b/contrib/ncurses/man/new_pair.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 2017 Free Software Foundation, Inc.                            *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -29,44 +29,38 @@
 .\"
 .\" Author: Thomas E. Dickey
 .\"
-.\" $Id: new_pair.3x,v 1.15 2020/10/17 23:54:50 tom Exp $
-.TH new_pair 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: new_pair.3x,v 1.46 2024/03/16 15:35:01 tom Exp $
+.TH new_pair 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.de NS
-.ie n  .sp
-.el    .sp .5
-.ie n  .in +4
-.el    .in +2
-.nf
-.ft C			\" Courier
-..
-.de NE
-.fi
-.ft R
-.ie n  .in -4
-.el    .in -2
-..
 .SH NAME
-\fBalloc_pair\fP,
-\fBfind_pair\fP,
-\fBfree_pair\fP \- new curses color-pair functions
+\fB\%alloc_pair\fP,
+\fB\%find_pair\fP,
+\fB\%free_pair\fP \-
+dynamically allocate \fIcurses\fR color pairs
 .SH SYNOPSIS
-\fB#include <curses.h>\fP
-.sp
-\fBint alloc_pair(int \fP\fIfg\fP\fB, int \fP\fIbg\fP\fB);\fP
-.br
-\fBint find_pair(int \fP\fIfg\fP\fB, int \fP\fIbg\fP\fB);\fP
-.br
-\fBint free_pair(int \fP\fIpair\fP\fB);\fP
+.nf
+\fB#include <curses.h>
+.PP
+\fBint alloc_pair(int \fIfg\fP, int \fIbg\fP);
+\fBint find_pair(int \fIfg\fP, int \fIbg\fP);
+\fBint free_pair(int \fIpair\fP);
+.fi
 .SH DESCRIPTION
-These functions are an extension to the curses library.
+These functions are an extension to the \fIcurses\fP library.
 They permit an application to dynamically allocate a color pair using
 the foreground/background colors rather than assign a fixed color pair number,
 and return an unused pair to the pool.
@@ -80,31 +74,37 @@ it is unlikely that your terminal allows you to modify the attributes
 of a given character cell without rewriting it.
 That is, the foreground and background colors are applied as a pair.
 .bP
-Color pairs are the curses library's way of managing a color palette
+Color pairs are the \fIcurses\fP library's way of managing a color palette
 on a terminal.
-If the library does not keep track of the \fIcombinations\fP of 
+If the library does not keep track of the \fIcombinations\fP of
 colors which are displayed, it will be inefficient.
-.bP
+.IP \(bu 4
 For simple terminal emulators
 with only a few dozen color combinations,
 it is convenient to use the maximum number of combinations
 as the limit on color pairs:
-.NS
-\fBCOLORS\fP\fI * \fP\fBCOLORS\fP
-.NE
-.bP
+.PP
+.RS 8
+.EX
+\fBCOLORS\fI * \fBCOLORS\fR
+.EE
+.RE
+.IP \(bu 4
 Terminals which support \fIdefault colors\fP distinct
-from \*(``ANSI colors\*('' 
+from \*(``ANSI colors\*(''
 add to the possible combinations, producing this total:
-.NS
-\fI( \fP\fBCOLORS\fP\fI + 1 ) * ( \fP\fBCOLORS\fP\fI + 1 )\fP
-.NE
+.PP
+.RS 8
+.EX
+\fI( \fBCOLORS\fI + 1 ) * ( \fBCOLORS\fI + 1 )\fR
+.EE
+.RE
 .bP
 An application might use up to a few dozen color pairs to
 implement a predefined color scheme.
 .IP
 Beyond that lies in the realm of programs using the foreground
-and background colors for \*(``ASCII art\*('' 
+and background colors for \*(``ASCII art\*(''
 (or some other non-textual application).
 .IP
 Also beyond those few dozen pairs, the required size for a table
@@ -127,10 +127,11 @@ If the table fills up, \fBalloc_pair\fP discards the least-recently
 allocated entry using \fBfree_pair\fP and allocates a new color pair.
 .PP
 All of the color pairs are allocated from a table of possible color pairs.
-The size of the table is determined by the terminfo \fIpairs\fP capability.
+The size of the table is determined by the terminfo \fBpairs\fP capability.
 The table is shared with \fBinit_pair\fP;
 in fact \fBalloc_pair\fP calls \fBinit_pair\fP after
-updating the ncurses library's fast index to the colors versus color pairs.
+updating the \fI\%ncurses\fP library's fast index
+to the colors versus color pairs.
 .SS find_pair
 The \fBfind_pair\fP function accepts parameters for
 foreground and background color, and
@@ -141,7 +142,6 @@ Otherwise it returns \-1.
 Marks the given color pair as unused,
 i.e., like color pair 0.
 .SH RETURN VALUE
-.PP
 The \fBalloc_pair\fP function returns a color pair number in the range
 1 through \fBCOLOR_PAIRS\fP\-1, unless it encounters an error updating
 its fast index to the color pair values, preventing it from allocating
@@ -155,12 +155,12 @@ or \-1 if not.
 Likewise, \fBfree_pair\fP returns \fBOK\fP unless it encounters an
 error updating the fast index or if no such color pair is in use.
 .SH PORTABILITY
-These routines are specific to ncurses.
+These routines are specific to \fI\%ncurses\fP.
 They were not supported on
 Version 7, BSD or System V implementations.
 It is recommended that
-any code depending on them be conditioned using NCURSES_VERSION.
+any code depending on them be conditioned using \fB\%NCURSES_VERSION\fP.
+.SH AUTHORS
+Thomas Dickey
 .SH SEE ALSO
-\fBcurs_color\fR(3X).
-.SH AUTHOR
-Thomas Dickey.
+\fB\%curs_color\fP(3X)
diff --git a/contrib/ncurses/man/panel.3x b/contrib/ncurses/man/panel.3x
index 932ef48eef7d..c63b4315699b 100644
--- a/contrib/ncurses/man/panel.3x
+++ b/contrib/ncurses/man/panel.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,253 +27,264 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: panel.3x,v 1.39 2020/02/15 21:06:40 tom Exp $
-.TH panel 3X ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: panel.3x,v 1.63 2024/03/16 15:35:01 tom Exp $
+.TH panel 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
 .SH NAME
-panel \- panel stack extension for curses
+panel \-
+panel stack extension for \fIcurses\fP
 .SH SYNOPSIS
-\fB#include <panel.h>\fR
-.P
-\fBcc [flags] sourcefiles \-lpanel \-lncurses\fR
-.P
-\fBPANEL *new_panel(WINDOW *\fIwin\fB);\fR
-.sp
-\fBint bottom_panel(PANEL *\fIpan\fB);\fR
-.br
-\fBint top_panel(PANEL *\fIpan\fB);\fR
-.br
-\fBint show_panel(PANEL *\fIpan\fB);\fR
-.br
-\fBvoid update_panels(void);\fR
-.br
-\fBint hide_panel(PANEL *\fIpan\fB);\fR
-.sp
-\fBWINDOW *panel_window(const PANEL *\fIpan\fB);\fR
-.br
-\fBint replace_panel(PANEL *\fIpan\fB, WINDOW *\fIwindow\fB);\fR
-.br
-\fBint move_panel(PANEL *\fIpan\fB, int \fIstarty\fB, int \fIstartx\fB);\fR
-.br
-\fBint panel_hidden(const PANEL *\fIpan\fB);\fR
-.sp
-\fBPANEL *panel_above(const PANEL *\fIpan\fB);\fR
-.br
-\fBPANEL *panel_below(const PANEL *\fIpan\fB);\fR
-.sp
-\fBint set_panel_userptr(PANEL *\fIpan\fB, const void *\fIptr\fB);\fR
-.br
-\fBconst void *panel_userptr(const PANEL *\fIpan\fB);\fR
-.sp
-\fBint del_panel(PANEL *\fIpan\fB);\fR
-.sp
-/* ncurses-extensions */
-.br
-\fBPANEL *ground_panel(SCREEN *\fIsp\fB);\fR
-.br
-\fBPANEL *ceiling_panel(SCREEN *\fIsp\fB);\fR
-.br
+.nf
+\fB#include <panel.h>
+.PP
+\fBPANEL *new_panel(WINDOW *\fIwin\fP);
+.PP
+\fBint bottom_panel(PANEL *\fIpan\fP);
+\fBint top_panel(PANEL *\fIpan\fP);
+\fBint show_panel(PANEL *\fIpan\fP);
+\fBvoid update_panels(void);
+\fBint hide_panel(PANEL *\fIpan\fP);
+.PP
+\fBWINDOW *panel_window(const PANEL *\fIpan\fP);
+\fBint replace_panel(PANEL *\fIpan\fP, WINDOW *\fIwindow\fP);
+\fBint move_panel(PANEL *\fIpan\fP, int \fIstarty\fP, int \fIstartx\fP);
+\fBint panel_hidden(const PANEL *\fIpan\fP);
+.PP
+\fBPANEL *panel_above(const PANEL *\fIpan\fP);
+\fBPANEL *panel_below(const PANEL *\fIpan\fP);
+.PP
+\fBint set_panel_userptr(PANEL *\fIpan\fP, const void *\fIptr\fP);
+\fBconst void *panel_userptr(const PANEL *\fIpan\fP);
+.PP
+\fBint del_panel(PANEL *\fIpan\fP);
+.PP
+\fI/* ncurses extensions */\fP
+\fBPANEL *ground_panel(SCREEN *\fIsp\fP);
+\fBPANEL *ceiling_panel(SCREEN *\fIsp\fP);
+.fi
 .SH DESCRIPTION
-Panels are \fBcurses\fR(3X) windows with the added feature of
+Panels are \fBcurses\fP(3X) windows with the added property of
 depth.
-Panel functions allow the use of stacked windows and ensure
-the proper portions of each window and the curses \fBstdscr\fR window are
-hidden or displayed when panels are added, moved, modified or removed.
+Panel functions allow the use of stacked windows and ensure that the
+proper portions of each window and the \fIcurses\fP \fB\%stdscr\fP
+window are hidden or displayed when panels are added,
+moved,
+modified,
+or removed.
 The set of currently visible panels is the stack of panels.
 The
-\fBstdscr\fR window is beneath all panels, and is not considered part
-of the stack.
-.P
-A window is associated with every panel.
-The panel routines enable
-you to create, move, hide, and show panels, as well as position a
-panel at any desired location in the stack.
-.P
-Panel routines are a functional layer added to \fBcurses\fR(3X), make only
-high-level curses calls, and work anywhere terminfo curses does.
+\fB\%stdscr\fP window is beneath all panels,
+and is not considered part of the stack.
+.PP
+A window is associated with each panel.
+The panel routines enable you to create,
+move,
+hide,
+and show panels.
+You can relocate a panel to any desired position in the stack.
+.PP
+Panel routines are a functional layer added to \fIcurses\fP,
+make only high-level \fIcurses\fP calls,
+and work anywhere \fIcurses\fP does.
 .SH FUNCTIONS
 .\" ---------
 .SS bottom_panel
-\fBbottom_panel(\fIpan\fB)\fR
+\fB\%bottom_panel(\fIpan\fB)\fR
 puts panel \fIpan\fP at the bottom of all panels.
 .\" ---------
 .SS ceiling_panel
-\fBceiling_panel(\fIsp\fB)\fR
-acts like \fBpanel_below(NULL)\fP, for the given \fBSCREEN\fP \fIsp\fP.
+\fB\%ceiling_panel(\fIsp\fB)\fR
+acts like \fB\%panel_below(NULL)\fP
+for the given \fISCREEN\fP \fIsp\fP.
 .\" ---------
 .SS del_panel
-\fBdel_panel(\fIpan\fB)\fR
-removes the given panel \fIpan\fP from the  stack and deallocates the
-\fBPANEL\fR structure (but not its associated window).
+\fB\%del_panel(\fIpan\fB)\fR
+removes the given panel \fIpan\fP from the stack and deallocates the
+\fI\%PANEL\fP structure (but not its associated window).
 .\" ---------
 .SS ground_panel
-\fBground_panel(\fIsp\fB)\fR
-acts like \fBpanel_above(NULL)\fP, for the given \fBSCREEN\fP \fIsp\fP.
+\fB\%ground_panel(\fIsp\fB)\fR
+acts like \fB\%panel_above(NULL)\fP
+for the given \fISCREEN\fP \fIsp\fP.
 .\" ---------
 .SS hide_panel
-\fBhide_panel(\fIpan\fB)\fR
+\fB\%hide_panel(\fIpan\fB)\fR
 removes the given panel \fIpan\fP from the panel stack
 and thus hides it from view.
-The \fBPANEL\fR structure is not lost, merely removed from the stack.
+The \fI\%PANEL\fP structure is not lost,
+merely removed from the stack.
 .\" ---------
 .SS move_panel
-\fBmove_panel(\fIpan\fB,\fIstarty\fB,\fIstartx\fB)\fR
-moves the given panel \fIpan\fP's window so that its upper-left corner is at
-\fIstarty\fR, \fIstartx\fR.
+\fB\%move_panel(\fIpan\fB, \fIstarty\fB, \fIstartx\fB)\fR
+moves the given panel \fIpan\fP's window so that its upper-left corner
+is at
+\fIstarty\fP,
+\fIstartx\fP.
 It does not change the position of the panel in the stack.
-Be sure to use this function, not \fBmvwin\fR(3X), to move a panel window.
+Be sure to use this function,
+not \fB\%mvwin\fP(3X),
+to move a panel window.
 .\" ---------
 .SS new_panel
-\fBnew_panel(\fIwin\fB)\fR allocates  a  \fBPANEL\fR structure,
-associates it with \fIwin\fR, places the panel on the top of the stack
-(causes  it to  be  displayed above any other panel) and returns a
-pointer to the new panel.
+\fB\%new_panel(\fIwin\fB)\fR allocates a \fI\%PANEL\fR structure,
+associates it with \fIwin\fP,
+places the panel on the top of the stack
+(causes it to be displayed above any other panel)
+and returns a pointer to the new panel.
 .\" ---------
 .SS panel_above
-\fBpanel_above(\fIpan\fB)\fR
+\fB\%panel_above(\fIpan\fB)\fR
 returns a pointer to the panel above \fIpan\fP.
 If the panel argument is
-\fB(PANEL *)0\fR, it returns a pointer to the bottom panel in the stack.
+\*(``\fB(PANEL *)0\fP\*('',
+it returns a pointer to the bottom panel in the stack.
 .\" ---------
 .SS panel_below
-\fBpanel_below(\fIpan\fB)\fR
+\fB\%panel_below(\fIpan\fB)\fR
 returns a pointer to the panel just below \fIpan\fP.
-If the panel argument
-is \fB(PANEL *)0\fR, it returns a pointer to the top panel in the stack.
+If the panel argument is
+\*(``\fB(PANEL *)0\fP\*('',
+it returns a pointer to the top panel in the stack.
 .\" ---------
 .SS panel_hidden
-\fBpanel_hidden(\fIpan\fB)\fR
-returns \fBTRUE\fP if the panel \fIpan\fP is in the panel stack,
-\fBFALSE\fP if it is not.
-If the panel is a null pointer, return \fBERR\fP.
+\fB\%panel_hidden(\fIpan\fB)\fR
+returns \fBFALSE\fP if the panel \fIpan\fP is in the panel stack,
+and \fBTRUE\fP if it is not.
+If the panel is a null pointer,
+it returns \fBERR\fP.
 .\" ---------
 .SS panel_userptr
-\fBpanel_userptr(\fIpan\fB)\fR
+\fB\%panel_userptr(\fIpan\fB)\fR
 returns the user pointer for a given panel \fIpan\fP.
 .\" ---------
 .SS panel_window
-\fBpanel_window(\fIpan\fB)\fR
+\fB\%panel_window(\fIpan\fB)\fR
 returns a pointer to the window of the given panel \fIpan\fP.
 .\" ---------
 .SS replace_panel
-\fBreplace_panel(\fIpan\fB,\fIwindow\fB)\fR
-replaces the current window of panel \fIpan\fP with \fIwindow\fR
-This is useful, for example if you want to resize a panel.
-In \fBncurses\fR, you can call \fBreplace_panel\fR
-to resize a panel using a window resized with \fBwresize\fR(3X).
+\fB\%replace_panel(\fIpan\fB, \fIwindow\fB)\fR
+replaces the current window of panel \fIpan\fP with \fIwindow\fP
+This is useful if,
+for example,
+you want to resize a panel.
+In \fI\%ncurses\fP,
+you can call \fB\%replace_panel\fP
+to resize a panel using a window resized with \fB\%wresize\fP(3X).
 It does not change the position of the panel in the stack.
 .\" ---------
 .SS set_panel_userptr
-\fBset_panel_userptr(\fIpan\fB,\fIptr\fB)\fR
+\fB\%set_panel_userptr(\fIpan\fB, \fIptr\fB)\fR
 sets the panel's user pointer.
 .\" ---------
 .SS show_panel
-\fBshow_panel(\fIpan\fB)\fR
+\fB\%show_panel(\fIpan\fB)\fR
 makes a hidden panel visible by placing it on top of the panels in the
 panel stack.
-See \fBCOMPATIBILITY\fP below.
+See \*(``PORTABILITY\*('' below.
 .\" ---------
 .SS top_panel
-\fBtop_panel(\fIpan\fB)\fR
-puts the given visible panel \fIpan\fP on top of all panels in the stack.
-See \fBCOMPATIBILITY\fP below.
+\fB\%top_panel(\fIpan\fB)\fR
+puts the given visible panel \fIpan\fP on top of all panels in the
+stack.
+See \*(``PORTABILITY\*('' below.
 .\" ---------
 .SS update_panels
-\fBupdate_panels()\fR
-refreshes the \fIvirtual screen\fP to reflect the relations between the
-panels in the stack, but does not call \fBdoupdate\fP(3X) to refresh the
-\fIphysical screen\fP.
-Use this function and not \fBwrefresh\fP(3X) or \fBwnoutrefresh\fP(3X).
+\fB\%update_panels()\fR
+refreshes the virtual screen to reflect the relations between the panels
+in the stack,
+but does not call \fB\%doupdate\fP(3X) to refresh the physical screen.
+Use this function and not \fB\%wrefresh\fP(3X) or
+\fB\%wnoutrefresh\fP(3X).
 .PP
-\fBupdate_panels\fP may be called more than once before a call to
-\fBdoupdate\fP, but \fBdoupdate\fP is the function responsible for updating
-the \fIphysical screen\fP.
-.SH DIAGNOSTICS
-Each routine that returns a pointer returns \fBNULL\fR if an error
+\fB\%update_panels\fP may be called more than once before a call to
+\fB\%doupdate\fP,
+but \fB\%doupdate\fP is the function responsible for updating
+the physical screen.
+.SH "RETURN VALUE"
+Each routine that returns a pointer returns \fBNULL\fP if an error
 occurs.
-Each routine that returns an int value returns \fBOK\fR if it
-executes successfully and \fBERR\fR if not.
+Each routine that returns an int value returns \fBOK\fP if it
+executes successfully and \fBERR\fP if not.
 .PP
-Except as noted, the \fIpan\fP and \fIwindow\fP parameters must be non-null.
-If those are null, an error is returned.
+Except as noted,
+the \fIpan\fP and \fIwindow\fP parameters must be non-null.
+If either is null,
+an error is returned.
 .PP
-The \fBmove_panel\fP function uses \fBmvwin\fP(3X),
-and will return an error if \fBmvwin\fP returns an error.
-.SH COMPATIBILITY
-Reasonable care has been taken to  ensure  compatibility
-with  the  native  panel facility introduced in System V (inspection of
-the SVr4 manual pages suggests the programming interface is unchanged).
-The \fBPANEL\fR data structures are merely  similar.
-The  programmer
-is cautioned not to directly use \fBPANEL\fR fields.
-.P
-The functions \fBshow_panel\fR and \fBtop_panel\fR are identical
-in this implementation, and work equally well with displayed or hidden
-panels.
-In the native System V implementation, \fBshow_panel\fR is
-intended for making a hidden panel visible (at the top of the stack)
-and \fBtop_panel\fR is intended for making an already-visible panel
-move to the top of the stack.
-You are cautioned to use the correct
-function to ensure compatibility with native panel libraries.
-.SH NOTE
-In your library list, libpanel.a should be before libncurses.a; that is,
-you should say \*(``\-lpanel \-lncurses\*('', not the other way around
-(which would give a link-error with static libraries).
+The \fB\%move_panel\fP function uses \fBmvwin\fP(3X),
+and returns an error if \fB\%mvwin\fP returns an error.
+.SH NOTES
+The header file \fI\%panel.h\fP itself includes the header file
+\fI\%curses.h\fP.
 .SH PORTABILITY
+Reasonable care has been taken to ensure compatibility
+with the native panel facility introduced in System\ V;
+inspection of the SVr4 manual pages suggests the programming interface
+never changed.
+The \fI\%PANEL\fP data structures are merely similar.
+The programmer is cautioned not to directly use \fI\%PANEL\fP fields.
 .PP
-The panel facility was documented in SVr4.2 in
-\fICharacter User Interface Programming (UNIX SVR4.2)\fP.
+The functions \fB\%show_panel\fP and \fB\%top_panel\fP are identical
+in this implementation,
+and work equally well with displayed or hidden panels.
+In the System\ V implementation,
+\fB\%show_panel\fP is intended for making a hidden panel visible
+(at the top of the stack)
+and \fB\%top_panel\fP is intended for making an already-visible panel
+move to the top of the stack.
+You are cautioned to use the correct
+function to ensure compatibility with System\ V panel libraries.
+.SH HISTORY
+A panel facility was documented in SVr4.2's
+\fICharacter User Interface Programming\fP document.
 .PP
 It is not part of X/Open Curses.
 .PP
 A few implementations exist:
 .bP
 Systems based on SVr4 source code,
-e.g., Solaris, provide this library.
+such as Solaris,
+provide this library.
 .bP
-\fBncurses\fP (since version 0.6 in 1993)
-and \fBPDCurses\fP (since version 2.2 in 1995)
+\fI\%ncurses\fP (since version 0.6 in 1993)
+and \fIPDCurses\fP (since version 2.2 in 1995)
 provide a panel library whose common ancestor
-was a public domain implementation by Warren Tucker
+is a public domain implementation by Warren Tucker
 published in \fIu386mon\fP 2.20 (1990).
 .IP
-According to Tucker, the SystemV panel library
-was first released in SVr3.2 (1988),
+According to Tucker,
+the System\ V panel library was first released in SVr3.2 (1988),
 and his implementation helped with a port to SVr3.1 (1987).
 .IP
 Several developers have improved each of these;
 they are no longer the same as Tucker's implementation.
 .bP
 NetBSD 8 (2018)
-has a panel library begun by Valery Ushakov in 2015.
-This is based on the AT&T documentation.
-.SH FILES
-.P
-panel.h
-interface for the panels library
-.P
-libpanel.a
-the panels library itself
-.SH SEE ALSO
-\fBcurses\fR(3X),
-\fBcurs_variables\fR(3X),
-.PP
-This describes \fBncurses\fR
-version @NCURSES_MAJOR@.@NCURSES_MINOR@ (patch @NCURSES_PATCH@).
-.SH AUTHOR
+has a panel library begun by Valery Ushakov in 2015,
+based on the System\ V documentation.
+.SH AUTHORS
+Warren Tucker <wht@n4hgf.mt\-park.ga.us> originally wrote this
+implementation,
+primarily to assist in porting \fI\%u386mon\fP to systems without a
+native panel library.
 .PP
-Originally written by Warren Tucker <wht@n4hgf.mt-park.ga.us>,
-primarily to assist in porting \fIu386mon\fP to systems without a native
-panels library.
+Zeyd ben-Halim repackaged it for \fI\%ncurses\fP.
 .PP
-Repackaged for ncurses by Zeyd ben-Halim.
-.PP
-Juergen Pfeifer and Thomas E. Dickey revised/improved the library.
+Juergen Pfeifer and Thomas E. Dickey revised and improved the library.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%curs_variables\fP(3X)
diff --git a/contrib/ncurses/man/resizeterm.3x b/contrib/ncurses/man/resizeterm.3x
index ae5106e1d0b0..5e23d9fb37bb 100644
--- a/contrib/ncurses/man/resizeterm.3x
+++ b/contrib/ncurses/man/resizeterm.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2015,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -29,115 +29,152 @@
 .\"
 .\" Author: Thomas E. Dickey 1996-on
 .\"
-.\" $Id: resizeterm.3x,v 1.28 2020/10/17 23:55:41 tom Exp $
-.TH resizeterm 3X ""
+.\" $Id: resizeterm.3x,v 1.56 2024/03/16 15:35:01 tom Exp $
+.TH resizeterm 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
 .SH NAME
-\fBis_term_resized\fR,
-\fBresize_term\fR,
-\fBresizeterm\fR \- change the curses terminal size
+\fB\%is_term_resized\fP,
+\fB\%resize_term\fP,
+\fB\%resizeterm\fP \-
+manage the terminal dimensions understood by \fIcurses\fR
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBbool is_term_resized(int \fP\fIlines\fP\fB, int \fP\fIcolumns\fP\fB);\fR
-.br
-\fBint resize_term(int \fP\fIlines\fP\fB, int \fP\fIcolumns\fP\fB);\fR
-.br
-\fBint resizeterm(int \fP\fIlines\fP\fB, int \fP\fIcolumns\fP\fB);\fR
+.nf
+\fB#include <curses.h>
+.PP
+\fBbool is_term_resized(int \fIlines\fP, int \fIcolumns\fP);
+\fBint resize_term(int \fIlines\fP, int \fIcolumns\fP);
+\fBint resizeterm(int \fIlines\fP, int \fIcolumns\fP);
+.fi
 .SH DESCRIPTION
+This is an extension to the \fIcurses\fP library.
+It provides callers with a hook into the \fI\%ncurses\fP data to resize
+windows,
+primarily for use by programs running in an X Window terminal (e.g., xterm)
+when the terminal's screen size is changed by the user:
+.bP
+\fIcurses\fP windows cannot extend outside the screen.
+If the terminal is shrunk, \fIcurses\fP windows must be shrunk to fit.
+.bP
+If the terminal is stretched,
+rows and/or columns can be added to existing windows.
+The added cells should match the current attributes of the windows.
 .PP
-This is an extension to the curses library.
-It provides callers with a hook into the \fBncurses\fR data to resize windows,
-primarily for use by programs running in an X Window terminal (e.g., xterm).
-.SS resizeterm
+If the calling program has not set up a handler for \fB\%SIGWINCH\fP
+when it initializes \fI\%ncurses\fP
+(e.g., using \fB\%initscr\fP(3X) or \fB\%newterm\fP(3X)),
+then \fI\%ncurses\fP sets a handler for \fB\%SIGWINCH\fP which notifies
+the library when a window-size event has occurred.
+The library checks for this notification
+.bP
+when reading input data,
+.bP
+when implicitly resuming program mode
+(e.g., between \fB\%endwin\fP(3X) and \fB\%wrefresh\fP(3X)),
+and
+.bP
+when explicitly resuming program mode in \fB\%restartterm\fP(3X).
+.PP
+When the library has found that the terminal's window-size has
+changed, it calls \fB\%resizeterm\fP to update its data structures.
 .PP
-The function \fBresizeterm\fR resizes the standard and current windows
+An application which establishes its own \fB\%SIGWINCH\fP handler
+can call \fB\%resizeterm\fP, but in that case, the library will not
+see \fB\%SIGWINCH\fP, and proper layout will rely upon the application.
+.SH FUNCTIONS
+.SS resizeterm
+The function \fB\%resizeterm\fP resizes the standard and current windows
+(i.e., \fB\%stdscr\fP and \fB\%curscr\fP)
 to the specified dimensions, and adjusts other bookkeeping data used by
-the \fBncurses\fR library that record the window dimensions
-such as the \fBLINES\fP and \fBCOLS\fP variables.
+the \fI\%ncurses\fP library that record the window dimensions
+such as the \fB\%LINES\fP and \fB\%COLS\fP variables.
 .SS resize_term
+Most of the work for \fB\%resizeterm\fP is
+done by the inner function \fB\%resize_term\fP.
+The outer function \fB\%resizeterm\fP adds bookkeeping
+for the \fB\%SIGWINCH\fP handler,
+as well as repainting the soft-key area (see \fB\%slk_touch\fP(3X)).
 .PP
-Most of the work is done by the inner function \fBresize_term\fR.
-The outer function \fBresizeterm\fR adds bookkeeping
-for the \fBSIGWINCH\fP handler,
-as well as repainting the soft-key area (see \fBslk_touch\fP(3X)).
-.PP
-When resizing the windows,
-\fBresize_term\fR blank-fills the areas that are extended.
-The calling application should fill in these areas with appropriate data.
-.PP
-The \fBresize_term\fR function attempts to resize all windows.
-However, due to the calling convention of pads,
-it is not possible to resize these
-without additional interaction with the application.
+The \fB\%resize_term\fP function attempts to resize all windows.
+This helps with simple applications.
+However:
+.bP
+It is not possible to automatically resize pads.
+.bP
+Applications which have complicated layouts should check for
+\fB\%KEY_RESIZE\fP returned from \fB\%wgetch\fP,
+and adjust their layout, e.g., using \fB\%wresize\fP and \fB\%mvwin\fP,
+or by recreating the windows.
 .PP
-When resizing windows, \fBresize_term\fR recursively adjusts subwindows,
+When resizing windows, \fB\%resize_term\fP recursively adjusts subwindows,
 keeping them within the updated parent window's limits.
 If a top-level window happens to extend to the screen's limits,
-then on resizing the window, \fBresize_term\fR will keep the window
+then on resizing the window, \fB\%resize_term\fP will keep the window
 extending to the corresponding limit, regardless of whether the
 screen has shrunk or grown.
 .SS is_term_resized
-.PP
-A support function \fBis_term_resized\fR is provided so that applications
-can check if the \fBresize_term\fR function would modify the window structures.
+A support function \fB\%is_term_resized\fP is provided so that applications
+can check if the \fB\%resize_term\fP function would modify
+the window structures.
 It returns \fBTRUE\fP if the windows would be modified,
 and \fBFALSE\fP otherwise.
 .SH RETURN VALUE
 Except as noted, these functions return
-the integer \fBERR\fR upon failure and \fBOK\fR on success.
+the integer \fBERR\fP upon failure and \fBOK\fP on success.
 They will fail if either of the dimensions are less than or equal to zero,
 or if an error occurs while (re)allocating memory for the windows.
 .SH NOTES
 While these functions are intended to be used to support a signal handler
-(i.e., for \fBSIGWINCH\fP), care should be taken to avoid invoking them in a
-context where \fBmalloc\fR or \fBrealloc\fR may have been interrupted,
+(i.e., for \fB\%SIGWINCH\fP), care should be taken to avoid invoking them in a
+context where \fB\%malloc\fP or \fB\%realloc\fP may have been interrupted,
 since it uses those functions.
 .PP
-If ncurses is configured to supply its own \fBSIGWINCH\fP handler,
+If \fI\%ncurses\fP is configured to supply its own \fB\%SIGWINCH\fP
+handler,
 .bP
-on receipt of a \fBSIGWINCH\fP, the handler sets a flag
+on receipt of a \fB\%SIGWINCH\fP, the handler sets a flag
 .bP
-which is tested in \fBwgetch\fP(3X) and \fBdoupdate\fP,
+which is tested in
+\fB\%wgetch\fP(3X),
+\fB\%doupdate\fP(3X) and
+\fB\%restartterm\fP(3X),
 .bP
-in turn, calling the \fBresizeterm\fR function,
+in turn, calling the \fB\%resizeterm\fP function,
 .bP
-which \fBungetch\fP's a \fBKEY_RESIZE\fR which
-will be read on the next call to \fBwgetch\fR.
+which \fB\%ungetch\fP's a \fB\%KEY_RESIZE\fP which
+will be read on the next call to \fB\%wgetch\fP.
 .IP
-The \fBKEY_RESIZE\fP alerts an application that the screen size has changed,
+The \fB\%KEY_RESIZE\fP alerts an application that the screen size has changed,
 and that it should repaint special features such as pads that cannot
 be done automatically.
 .IP
-Calling \fBresizeterm\fP or \fBresize_term\fP
+Calling \fB\%resizeterm\fP or \fB\%resize_term\fP
 directly from a signal handler is unsafe.
-This indirect method is used to provide a safe way to resize the ncurses
-data structures.
+This indirect method is used to provide a safe way to resize the
+\fI\%ncurses\fP data structures.
 .PP
-If the environment variables \fBLINES\fP or \fBCOLUMNS\fP are set,
+If the environment variables \fILINES\fP or \fI\%COLUMNS\fP are set,
 this overrides the library's use of the window size obtained from
 the operating system.
-Thus, even if a \fBSIGWINCH\fP is received,
+Thus, even if a \fB\%SIGWINCH\fP is received,
 no screen size change may be recorded.
 .SH PORTABILITY
-.PP
-It is possible to resize the screen with SVr4 curses,
+It is possible to resize the screen with SVr4 \fIcurses\fP,
 by
 .bP
-exiting curses with \fBendwin\fP(3X) and
+exiting \fIcurses\fP with \fB\%endwin\fP(3X) and
 .bP
-resuming using \fBrefresh\fP(3X).
+resuming using \fB\%refresh\fP(3X).
 .PP
 Doing that clears the screen and is visually distracting.
 .PP
-This extension of ncurses was introduced in mid-1995.
-It was adopted in NetBSD curses (2001) and PDCurses (2003).
+This extension of \fI\%ncurses\fP was introduced in mid-1995.
+It was adopted in NetBSD \fIcurses\fP (2001) and PDCurses (2003).
+.SH AUTHORS
+Thomas Dickey (from an equivalent function written in 1988 for BSD \fIcurses\fP)
 .SH SEE ALSO
-\fBcurs_getch\fR(3X),
-\fBcurs_variables\fR(3X),
-\fBwresize\fR(3X).
-.SH AUTHOR
-Thomas Dickey (from an equivalent function written in 1988 for BSD curses).
+\fB\%curs_getch\fP(3X),
+\fB\%curs_variables\fP(3X),
+\fB\%wresize\fP(3X)
diff --git a/contrib/ncurses/man/scr_dump.5 b/contrib/ncurses/man/scr_dump.5
index 7ef68cdeb083..95b2142ee6af 100644
--- a/contrib/ncurses/man/scr_dump.5
+++ b/contrib/ncurses/man/scr_dump.5
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 2017 Free Software Foundation, Inc.                            *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,36 +27,28 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: scr_dump.5,v 1.16 2020/02/02 23:34:34 tom Exp $
-.TH scr_dump 5
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
-.de NS
-.ie n  .sp
-.el    .sp .5
-.ie n  .in +4
-.el    .in +2
-.nf
-.ft C			\" Courier
-..
-.de NE
-.fi
-.ft R
-.ie n  .in -4
-.el    .in -2
-..
+.\" $Id: scr_dump.5,v 1.46 2024/03/23 20:42:29 tom Exp $
+.TH scr_dump 5 2024-03-23 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "File formats"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
 .SH NAME
-scr_dump \- format of curses screen-dumps.
-.SH SYNOPSIS
-.B scr_dump
+scr_dump \-
+\fIcurses\fR screen dump
+.\"SH SYNOPSIS
 .SH DESCRIPTION
-.PP
 The curses library provides applications with the ability to write the
 contents of a window to an external file using \fBscr_dump\fP or \fBputwin\fP,
 and read it back using \fBscr_restore\fP or \fBgetwin\fP.
@@ -65,10 +57,9 @@ The \fBputwin\fP and \fBgetwin\fP functions do the work;
 while \fBscr_dump\fP and \fBscr_restore\fP conveniently save and restore
 the whole screen, i.e., \fBstdscr\fP.
 .SS ncurses6
-.PP
 A longstanding implementation of screen-dump was
 revised with ncurses6 to remedy problems with the earlier approach:
-.bP
+.IP \(bu 4
 A \*(``magic number\*('' is written to the beginning of the dump file,
 allowing applications (such as \fBfile\fP(1)) to recognize curses dump files.
 .IP
@@ -76,25 +67,36 @@ Because ncurses6 uses a new format,
 that requires a new magic number
 was unused by other applications.
 This 16-bit number was unused:
-.NS
-0x8888 (octal \*(``\\210\\210\*('')
-.NE
-.IP
+.RS 4
+.PP
+.RS 4
+.EX
+0x8888 (octal \*(``\e210\e210\*('')
+.EE
+.RE
+.PP
 but to be more certain, this 32-bit number was chosen:
-.NS
-0x88888888 (octal \*(``\\210\\210\\210\\210\*('')
-.NE
-.IP
+.PP
+.RS 4
+.EX
+0x88888888 (octal \*(``\e210\e210\e210\e210\*('')
+.EE
+.RE
+.PP
 This is the pattern submitted to the maintainers of the \fBfile\fP program:
-.NS
+.PP
+.RS 4
+.EX
 #
 # ncurses5 (and before) did not use a magic number,
 # making screen dumps "data".
 #
 # ncurses6 (2015) uses this format, ignoring byte-order
-0    string    \\210\\210\\210\\210ncurses    ncurses6 screen image
+0    string    \e210\e210\e210\e210ncurses    ncurses6 screen image
 #
-.NE
+.EE
+.RE
+.RE
 .bP
 The screen dumps are written in textual form,
 so that internal data sizes are not directly related to the dump-format, and
@@ -111,171 +113,208 @@ screen-size,
 because the library truncates or fills the screen as necessary.
 .bP
 The ncurses6 \fBgetwin\fP reads the legacy screen dumps from ncurses5.
-.SS ncurses5 (legacy)
-.PP
-The screen-dump feature was added to ncurses in June 1995.
+.SS "ncurses5 (Legacy)"
+The screen-dump feature was added to \fI\%ncurses\fP in June 1995.
 While there were fixes and improvements in succeeding years,
 the basic scheme was unchanged:
 .bP
-The \fBWINDOW\fP structure was written in binary form.
+The \fI\%WINDOW\fP structure was written in binary form.
 .bP
-The \fBWINDOW\fP structure refers to lines of data,
-which were written as an array of binary data following the \fBWINDOW\fP.
+The \fI\%WINDOW\fP structure refers to lines of data,
+which were written as an array of binary data following the \fI\%WINDOW\fP.
 .bP
 When \fBgetwin\fP restored the window,
 it would keep track of offsets into the array of line-data
-and adjust the \fBWINDOW\fP structure which was read back into memory.
+and adjust the \fI\%WINDOW\fP structure which was read back into memory.
 .PP
-This is similar to Unix SystemV,
+This is similar to Unix System\ V,
 but does not write a \*(``magic number\*('' to identify the file format.
 .SH PORTABILITY
-.PP
-There is no standard format for \fBputwin\fP.
-This section gives a brief description of the existing formats.
-.SS X/Open Curses
-.PP
-Refer to \fIX/Open Curses, Issue 7\fP (2009).
-.PP
-X/Open's documentation for \fIenhanced curses\fP says only:
+There is no standard format for
+.I curses
+screen dumps.
+A brief survey of the existing implementations follows.
+.SS "X/Open Curses"
+X/Open Curses, Issue 7 specifies little.
+It says
+(boldface emphasis added)
 .RS 3
 .PP
-The \fIgetwin(\ ) \fPfunction reads window-related data
-stored in the file by \fIputwin(\ )\fP.
-The function
-then creates and initializes a new window using that data.
+\*(``[t]he \fI\%getwin()\fP function reads window-related data stored in
+the file by \fI\%putwin()\fP.
+The function then creates and initializes a new window using that data.
 .PP
-The \fIputwin(\ )\fP function writes all data associated
-with \fIwin\fP into the \fIstdio\fP stream to which \fIfilep\fP
-points, using an \fBunspecified format\fP.
-This information can be retrieved later using \fIgetwin(\ )\fP.
+The \fI\%putwin()\fP function writes all data associated with \fIwin\fP
+into the \fI\%stdio\fP stream to which \fIfilep\fP points,
+using an \fBunspecified format\fP.
+This information can be retrieved later using \fI\%getwin()\fP.\*(''
 .RE
 .PP
 In the mid-1990s when the X/Open Curses document was written,
-there were still systems using older, less capable curses libraries
-(aside from the BSD curses library which was not relevant to X/Open
-because it did not meet the criteria for \fIbase curses\fP).
-The document explained the term \*(``enhanced\*('' as follows:
-.RS 3
-.bP
-Shading is used to identify \fIX/Open Enhanced Curses\fP material,
-relating to interfaces included to provide enhanced capabilities
-for applications originally written to be compiled on systems
-based on the UNIX operating system.
-Therefore, the features described may not be present on systems
-that conform to \fBXPG4 or to earlier XPG releases\fP.
-The relevant reference pages may provide additional
-or more specific portability warnings about use of the material.
-.RE
-.PP
-In the foregoing, emphasis was added to \fBunspecified format\fP
-and to \fBXPG4 or to earlier XPG releases\fP,
-for clarity.
-.SS Unix SystemV
+there were still System\ V systems using older,
+less capable
+.I curses
+libraries.
+BSD
+.I curses
+was not relevant to X/Open because it did not meet the criteria
+for base-level conformance;
+see \fB\%ncurses\fP(3X).
+.SS "System V"
+System\ V
+.I curses
+identified the file format by writing a \*(``magic number\*('' at the
+beginning of the dump.
+The \fI\%WINDOW\fP data and the lines of text follow, all in binary form.
 .PP
-Unix SystemV curses identified the file format by writing a
-\*(``magic number\*('' at the beginning of the dump.
-The \fBWINDOW\fP data and the lines of text follow, all in binary form.
+Solaris
+.I curses
+has the following definitions.
 .PP
-The Solaris curses source has these definitions:
-.NS
+.RS 4
+.EX
 /* terminfo magic number */
 #define MAGNUM  0432
 
 /* curses screen dump magic number */
 #define SVR2_DUMP_MAGIC_NUMBER  0433
 #define SVR3_DUMP_MAGIC_NUMBER  0434
-.NE
+.EE
+.RE
 .PP
 That is, the feature was likely introduced in SVr2 (1984),
 and improved in SVr3 (1987).
-The Solaris curses source has no magic number for SVr4 (1989).
-Other operating systems (AIX and HPUX) use a magic number which would
-correspond to this definition:
-.NS
+Solaris
+.I curses
+has no magic number for SVr4 (1989).
+Other System\ V operating systems
+(AIX and HP-UX)
+use a magic number that would correspond to the following.
+.PP
+.RS 4
+.EX
 /* curses screen dump magic number */
 #define SVR4_DUMP_MAGIC_NUMBER  0435
-.NE
+.EE
+.RE
 .PP
 That octal number in bytes is 001, 035.
-Because most Unix vendors use big-endian hardware,
-the magic number is written with the high-order byte first, e.g.,
-.NS
-\001\035
-.NE
+Because most Unix vendors at the time used big-endian hardware,
+the magic number is written with the high-order byte first.
 .PP
-After the magic number, the \fBWINDOW\fP structure and line-data are
-written in binary format.
-While the magic number used by the Unix systems can be seen using \fBod\fP(1),
-none of the Unix systems documents the format used for screen-dumps.
+.RS 4
+.EX
+\e001\e035
+.EE
+.RE
+.PP
+After the magic number,
+the \fI\%WINDOW\fP structure and line data are written in binary format.
+While the magic number used by these systems can be observed with
+\fIod\fP(1),
+none of them documents the format used for screen dumps.
 .PP
-The Unix systems do not use identical formats.
-While collecting information for for this manual page,
-the \fIsavescreen\fP test-program
-produced dumps of different size
-(all on 64-bit hardware, on 40x80 screens):
+Nor do they use an identical format,
+even with the System\ V family.
+The
+.I \%ncurses
+.I \%savescreen
+test program was used to collect information for this manual page.
+It produced dumps of different size
+(all on 64-bit hardware,
+on 40x80 screens):
 .bP
 AIX (51817 bytes)
 .bP
-HPUX (90093 bytes)
+HP-UX (90093 bytes)
 .bP
 Solaris 10 (13273 bytes)
 .bP
-ncurses5 (12888 bytes)
+\fI\%ncurses\fP5 (12888 bytes)
 .SS Solaris
-.PP
-As noted above, Solaris curses has no magic number corresponding
-to SVr4 curses.
-This is odd since Solaris was the first operating system
-to pass the SVr4 guidelines.
-Solaris has two versions of curses:
+As noted above,
+Solaris
+.I curses
+has no magic number corresponding to SVr4
+.IR curses .
+This is odd,
+since Solaris was the first operating system to meet the SVr4
+guidelines.
+Solaris furthermore supplies two versions of
+.IR curses .
 .bP
-The default curses library uses the SVr3 magic number.
+The default
+.I curses
+library uses the SVr3 magic number.
 .bP
-There is an alternate curses library in \fB/usr/xpg4\fP.
-This uses a textual format with no magic number.
+An alternate
+.I curses
+library
+(which we term
+.I \%xcurses),
+available in
+.IR /usr/xpg4 ,
+uses a textual format with no magic number.
 .IP
-According to the copyright notice, the \fIxpg4\fP Solaris curses library was
-developed by MKS (Mortice Kern Systems) from 1990 to 1995.
+According to its copyright notice,
+this
+.I \%xcurses
+library was developed by MKS
+(Mortice Kern Systems) from 1990 to 1995.
 .IP
-Like ncurses6, there is a file-header with parameters.
-Unlike ncurses6, the contents of the window are written piecemeal,
-with coordinates and attributes for each chunk of text rather
-than writing the whole window from top to bottom.
+Like ncurses6,
+it includes a header with parameters.
+Unlike ncurses6,
+the contents of the window are written piecemeal,
+with coordinates and attributes for each chunk of text rather than
+writing the whole window from top to bottom.
 .SS PDCurses
-.PP
-PDCurses added support for screen dumps in version 2.7 (2005).
-Like Unix SystemV and ncurses5,
-it writes the \fBWINDOW\fP structure in binary,
+.I \%PDCurses
+added support for screen dumps in version 2.7 (2005).
+Like System\ V and ncurses5,
+it writes the \fI\%WINDOW\fP structure in binary,
 but begins the file with its three-byte identifier \*(``PDC\*('',
-followed by a one-byte version,
-e.g.,
-.NS
-	\*(``PDC\\001\*(''
-.NE
-.SS NetBSD
+followed by a single-byte version number.
 .PP
-As of April 2017, NetBSD curses does
-not support \fBscr_dump\fP and \fBscr_restore\fP
-(or \fBscr_init\fP, \fBscr_set\fP),
-although it has \fBputwin\fP and \fBgetwin\fP.
+.RS 4
+.EX
+	\*(``PDC\e001\*(''
+.EE
+.RE
+.SS NetBSD
+As of April 2017,
+NetBSD
+.I curses
+does not support \fB\%scr_dump\fP and \fB\%scr_restore\fP
+(or \fB\%scr_init\fP,
+\fB\%scr_set\fP),
+although it has \fB\%putwin\fP and \fB\%getwin\fP.
 .PP
-Like ncurses5, NetBSD \fBputwin\fP does not identify its dumps with a
-useful magic number.
+Like ncurses5,
+NetBSD \fB\%putwin\fP does not identify its dumps with a useful magic
+number.
 It writes
 .bP
-the curses shared library major and minor versions
-as the first two bytes (e.g., 7 and 1),
+the
+.I curses
+shared library major and minor versions as the first two bytes
+(for example,
+7 and 1),
 .bP
-followed by a binary dump of the \fBWINDOW\fP,
+followed by a binary dump of the \fI\%WINDOW\fP,
 .bP
-some data for wide-characters referenced by the \fBWINDOW\fP structure, and
+some data for wide characters referenced by the \fI\%WINDOW\fP
+structure,
+and
 .bP
-finally, lines as done by other implementations.
-.SH EXAMPLE
-.PP
+finally,
+lines as done by other implementations.
+.SH EXAMPLES
 Given a simple program which writes text to the screen
 (and for the sake of example, limiting the screen-size to 10x20):
-.NS
+.PP
+.RS 4
+.EX
 #include <curses.h>
 
 int
@@ -300,33 +339,37 @@ main(void)
     endwin();
     return 0;
 }
-.NE
+.EE
+.RE
 .PP
 When run using ncurses6, the output looks like this:
-.NS
-\\210\\210\\210\\210ncurses 6.0.20170415
+.PP
+.RS 4
+.EX
+\e210\e210\e210\e210ncurses 6.0.20170415
 _cury=5
 _curx=11
 _maxy=9
 _maxx=19
 _flags=14
-_attrs=\\{REVERSE|C2}
+_attrs=\e{REVERSE|C2}
 flag=_idcok
 _delay=-1
 _regbottom=9
-_bkgrnd=\\{NORMAL|C1}\\s
+_bkgrnd=\e{NORMAL|C1}\es
 rows:
-1:\\{NORMAL|C1}\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s
-2:\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s
-3:\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s
-4:\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s
-5:\\s\\s\\s\\s\\s\\{BOLD}Hello\\{NORMAL}\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s
-6:\\s\\s\\s\\s\\s\\{REVERSE|C2}World!\\{NORMAL|C1}\\s\\s\\s\\s\\s\\s\\s\\s\\s
-7:\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s
-8:\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s
-9:\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s
-10:\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s
-.NE
+1:\e{NORMAL|C1}\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es
+2:\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es
+3:\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es
+4:\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es
+5:\es\es\es\es\es\e{BOLD}Hello\e{NORMAL}\es\es\es\es\es\es\es\es\es\es
+6:\es\es\es\es\es\e{REVERSE|C2}World!\e{NORMAL|C1}\es\es\es\es\es\es\es\es\es
+7:\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es
+8:\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es
+9:\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es
+10:\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es
+.EE
+.RE
 .PP
 The first four octal escapes are actually nonprinting characters,
 while the remainder of the file is printable text.
@@ -334,18 +377,20 @@ You may notice:
 .bP
 The actual color pair values are not written to the file.
 .bP
-All characters are shown in printable form; spaces are \*(``\\s\*('' to
+All characters are shown in printable form; spaces are \*(``\es\*('' to
 ensure they are not overlooked.
 .bP
-Attributes are written in escaped curly braces, e.g., \*(``\\{BOLD}\*('',
-and may include a color-pair (C1 or C2 in this example).
+Attributes are written in escaped curly braces, e.g., \*(``\e{BOLD}\*('',
+and may include a color pair (C1 or C2 in this example).
 .bP
 The parameters in the header are written out only if they are nonzero.
 When reading back, order does not matter.
 .ne 10
 .PP
 Running the same program with Solaris \fIxpg4\fP curses gives this dump:
-.NS
+.PP
+.RS 4
+.EX
 MAX=10,20
 BEG=0,0
 SCROLL=0,10
@@ -353,33 +398,34 @@ VMIN=1
 VTIME=0
 FLAGS=0x1000
 FG=0,0
-BG=0,0, 
+BG=0,0,
 0,0,0,1,
-0,19,0,0, 
+0,19,0,0,
 1,0,0,1,
-1,19,0,0, 
+1,19,0,0,
 2,0,0,1,
-2,19,0,0, 
+2,19,0,0,
 3,0,0,1,
-3,19,0,0, 
+3,19,0,0,
 4,0,0,1,
 4,5,0x20,0,Hello
 4,10,0,1,
-4,19,0,0, 
+4,19,0,0,
 5,0,0,1,
 5,5,0x4,2,World!
 5,11,0,1,
-5,19,0,0, 
+5,19,0,0,
 6,0,0,1,
-6,19,0,0, 
+6,19,0,0,
 7,0,0,1,
-7,19,0,0, 
+7,19,0,0,
 8,0,0,1,
-8,19,0,0, 
+8,19,0,0,
 9,0,0,1,
-9,19,0,0, 
+9,19,0,0,
 CUR=11,5
-.NE
+.EE
+.RE
 .PP
 Solaris \fBgetwin\fP requires that all parameters are present, and
 in the same order.
@@ -389,8 +435,10 @@ The \fIxpg4\fP curses library does not know about the \fBbce\fP
 .PP
 On the other hand, the SVr4 curses library does know about the background color.
 However, its screen dumps are in binary.
-Here is the corresponding dump (using \*(``od -t x1\*(''):
-.NS
+Here is the corresponding dump (using \*(``od \-t x1\*(''):
+.PP
+.RS 4
+.EX
 0000000 1c 01 c3 d6 f3 58 05 00 0b 00 0a 00 14 00 00 00
 0000020 00 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00
 0000040 00 00 b8 1a 06 08 cc 1a 06 08 00 00 09 00 10 00
@@ -413,17 +461,16 @@ Here is the corresponding dump (using \*(``od -t x1\*(''):
 0001620 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 *
 0002371
-.NE
-.SH SEE ALSO
-.PP
-\fBcurs_scr_dump\fR(3X),
-\fBcurs_util\fR(3X).
+.EE
+.RE
 .SH AUTHORS
-.PP
 Thomas E. Dickey
 .br
-extended screen-dump format for ncurses 6.0 (2015)
+extended screen-dump format for \fI\%ncurses\fP 6.0 (2015)
 .sp
 Eric S. Raymond
 .br
-screen dump feature in ncurses 1.9.2d (1995)
+screen dump feature in \fI\%ncurses\fP 1.9.2d (1995)
+.SH SEE ALSO
+\fB\%curs_scr_dump\fP(3X),
+\fB\%curs_util\fP(3X)
diff --git a/contrib/ncurses/man/tabs.1 b/contrib/ncurses/man/tabs.1
index eb7e659746dd..059bc1ec66fc 100644
--- a/contrib/ncurses/man/tabs.1
+++ b/contrib/ncurses/man/tabs.1
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 2008-2016,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,48 +27,44 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: tabs.1,v 1.28 2020/12/19 21:50:22 tom Exp $
-.TH @TABS@ 1 ""
-.ds n 5
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: tabs.1,v 1.59 2024/04/20 19:08:15 tom Exp $
+.TH @TABS@ 1 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "User commands"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.de NS
-.ie n  .sp
-.el    .sp .5
-.ie n  .in +4
-.el    .in +2
-.nf
-.ft C			\" Courier
-..
-.de NE
-.fi
-.ft R
-.ie n  .in -4
-.el    .in -2
-..
+.
 .SH NAME
-\fB@TABS@\fR \- set tabs on a terminal
+\fB\%@TABS@\fP \-
+set terminal tab stops
 .SH SYNOPSIS
-\fB@TABS@\fR [\fIoptions\fR]] \fI[tabstop-list]\fR
+\fB@TABS@\fP [\fIoptions\fP] [\fItabstop-list\fP]
 .SH DESCRIPTION
-.PP
 The \fB@TABS@\fP program clears and sets tab-stops on the terminal.
-This uses the terminfo \fIclear_all_tabs\fP and \fIset_tab\fP capabilities.
+This uses the terminfo \fBclear_all_tabs\fP and \fBset_tab\fP capabilities.
 If either is absent, \fB@TABS@\fP is unable to clear/set tab-stops.
 The terminal should be configured to use hard tabs, e.g.,
-.NS
+.PP
+.RS 4
+.EX
 stty tab0
-.NE
+.EE
+.RE
 .PP
-Like \fB@CLEAR@\fR(1), \fB@TABS@\fR writes to the standard output.
+Like \fB@CLEAR@\fP(1), \fB@TABS@\fP writes to the standard output.
 You can redirect the standard output to a file (which prevents
-\fB@TABS@\fR from actually changing the tabstops),
+\fB@TABS@\fP from actually changing the tabstops),
 and later \fBcat\fP the file to the screen, setting tabstops at that point.
 .PP
 These are hardware tabs, which cannot be queried rapidly by applications
@@ -79,15 +75,18 @@ If the hardware tabstops differ from the information in the terminal
 database, the result is unpredictable.
 Before running curses programs,
 you should either reset tab-stops to the standard interval
-.NS
-tabs -8
-.NE
+.PP
+.RS 4
+.EX
+tabs \-8
+.EE
+.RE
 .PP
 or use the \fB@RESET@\fP program,
 since the normal initialization sequences do not ensure that tab-stops
 are reset.
 .SH OPTIONS
-.SS General Options
+.SS "General Options"
 .TP 5
 .BI \-T "name"
 Tell \fB@TABS@\fP which terminal type to use.
@@ -104,13 +103,14 @@ The second data line shows the actual tab-stops, marked with asterisks.
 This option tells \fB@TABS@\fP to check the options and run any debugging
 option, but not to modify the terminal settings.
 .TP
-\fB\-V\fR
-reports the version of ncurses which was used in this program, and exits.
+\fB\-V\fP
+reports the version of \fI\%ncurses\fP which was used in this program,
+and exits.
 .PP
 The \fB@TABS@\fP program processes a single list of tab stops.
 The last option to be processed which defines a list is the one that
 determines the list to be processed.
-.SS Implicit Lists
+.SS "Implicit Lists"
 Use a single number as an option,
 e.g., \*(``\fB\-5\fP\*('' to set tabs at the given
 interval (in this case 1, 6, 11, 16, 21, etc.).
@@ -119,120 +119,239 @@ Tabs are repeated up to the right margin of the screen.
 Use \*(``\fB\-0\fP\*('' to clear all tabs.
 .PP
 Use \*(``\fB\-8\fP\*('' to set tabs to the standard interval.
-.SS Explicit Lists
+.SS "Explicit Lists"
 An explicit list can be defined after the options
 (this does not use a \*(``\-\*('').
 The values in the list must be in increasing numeric order,
 and greater than zero.
 They are separated by a comma or a blank, for example,
-.NS
+.PP
+.RS 4
+.EX
 tabs 1,6,11,16,21
-.br
 tabs 1 6 11 16 21
-.NE
+.EE
+.RE
 .PP
 Use a \*(``+\*('' to treat a number
 as an increment relative to the previous value,
 e.g.,
-.NS
+.PP
+.RS 4
+.EX
 tabs 1,+5,+5,+5,+5
-.NE
+.EE
+.RE
 .PP
 which is equivalent to the 1,6,11,16,21 example.
-.SS Predefined Tab-Stops
-X/Open defines several predefined lists of tab stops.
+.SS "Predefined Tab Stops"
+POSIX defines several predefined lists of tab stops.
 .TP 5
 .B \-a
 Assembler, IBM S/370, first format
+.br
+1,10,16,36,72
 .TP 5
 .B \-a2
 Assembler, IBM S/370, second format
+.br
+1,10,16,40,72
 .TP 5
 .B \-c
 COBOL, normal format
+.br
+1,8,12,16,20,55
 .TP 5
 .B \-c2
 COBOL compact format
+.br
+1,6,10,14,49
 .TP 5
 .B \-c3
 COBOL compact format extended
+.br
+1,6,10,14,18,22,26,30,34,38,42,46,50,54,58,62,67
 .TP 5
 .B \-f
 FORTRAN
+.br
+1,7,11,15,19,23
 .TP 5
 .B \-p
 PL/I
+.br
+1,5,9,13,17,21,25,29,33,37,41,45,49,53,57,61
 .TP 5
 .B \-s
 SNOBOL
+.br
+1,10,55
 .TP 5
 .B \-u
 UNIVAC 1100 Assembler
-.SH PORTABILITY
+.br
+1,12,20,44
+.SS Margins
+A few terminals expose a means of changing their left and right margins.
+\fB@TABS@\fP supports this feature with an option.
+.TP 5
+.BI +m \ margin
+The effect depends on whether the terminal has the margin capabilities:
+.RS
+.bP
+If the terminal provides the capability for setting the left margin,
+\fB@TABS@\fP uses this,
+and adjusts the available tab stop widths.
+.bP
+If the terminal does not provide the margin capabilities,
+\fB@TABS@\fP imitates their effect,
+putting tab stops at appropriate places on each line.
+The terminal's left margin is not modified.
+.RE
+.IP
+If the
+.I margin
+parameter is omitted,
+the default is 10.
+Use
+.B +m0
+to reset the left margin,
+that is,
+to make it the left edge of the terminal's display.
+Before setting a left margin,
+\fB@TABS@\fP resets the margin to reduce problems that might arise
+from moving the cursor to the left of the current left margin.
 .PP
-\fIIEEE Std 1003.1/The Open Group Base Specifications Issue 7\fP (POSIX.1-2008)
-describes a \fBtabs\fP utility.
-However
+When setting or resetting the left margin,
+\fB@TABS@\fP may also reset the right margin.
+.SH FILES
+.TP
+.I @DATADIR@/tabset
+tab stop initialization database
+.SH PORTABILITY
+IEEE Std 1003.1/The Open Group Base Specifications Issue 7
+(POSIX.1-2008)
+describes a
+.B tabs
+utility.
+However,
 .bP
-This standard describes a \fB+m\fP option, to set a terminal's left-margin.
+this standard describes a
+.B +m
+option to set a terminal's left margin.
 Very few of the entries in the terminal database provide the
-\fBsmgl\fP (\fBset_left_margin\fP) or
-\fBsmglp\fP (\fBset_left_margin_parm\fP)
-capability needed to support the feature.
+.B \%set_left_margin
+.RB ( smgl )
+or
+.B \%set_left_margin_parm
+.RB \%( smglp )
+capabilities needed to support the feature.
 .bP
 There is no counterpart in X/Open Curses Issue 7 for this utility,
-unlike \fB@TPUT@(1)\fP.
-.PP
-The \fB\-d\fP (debug) and \fB\-n\fP (no-op) options are extensions not provided
-by other implementations.
-.PP
-A \fBtabs\fP utility appeared in PWB/Unix 1.0 (1977).
-There was a reduced version of the \fBtabs\fP utility
-in Unix 7th edition and in 3BSD (1979).
-The latter supported a single \*(``\-n\*('' option
-(to cause the first tab stop to be set on the left margin).
-That option is not documented by POSIX.
-.PP
-The PWB/Unix \fBtabs\fP utility, which was included in System III (1980),
-used built-in tables rather than the terminal database,
-to support a half-dozen terminal types.
-It also had built-in logic to support the left-margin,
+unlike \fB@TPUT@\fP(1).
+.PP
+The
+.B \-d
+(debug) and
+.B \-n
+(no-op) options are
+.I \%ncurses
+extensions not provided by other implementations.
+.SH HISTORY
+A
+.B tabs
+utility appeared in PWB/Unix 1.0 (1977).
+.\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=PWB1/sys/source/s2/\
+.\"   tabs.c
+A reduced version shipped in Seventh Edition Unix
+(early 1979)
+.\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/tabs.c
+and in 3BSD
+.\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=3BSD/usr/src/cmd/\
+.\"   tabs.c
+(later the same year);
+it supported a \*(``\-n\*('' option to set the first tab stop at the
+left margin.
+That option is not specified by POSIX.
+.PP
+The PWB/Unix
+.B tabs
+utility returned in System III (1980),
+and used built-in tables
+to support a half-dozen hardcopy terminal (printer) types.
+It also had logic to support setting the left margin,
 as well as a feature for copying the tab settings from a file.
 .PP
-Later versions of Unix, e.g., SVr4,
+Versions of the program in later releases of AT&T Unix,
+such as SVr4,
+.\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=SysVR4/cmd/tabs/tabs.c
 added support for the terminal database,
-but kept the tables, as a fallback.
-In an earlier development effort,
-the tab-stop initialization provided by \fBtset\fP (1982)
-and incorporated into \fBtput\fP uses the terminal database,
-.PP
-POSIX documents no limits on the number of tab stops.
-Documentation for other implementations states that there is a limit on the
-number of tab stops
-(e.g., 20 in PWB/Unix's \fBtabs\fP utility).
-While some terminals may not accept an arbitrary number
-of tab stops, this implementation will attempt to set tab stops up to the
-right margin of the screen, if the given list happens to be that long.
-.PP
-The \fIRationale\fP section of the POSIX documentation goes into some
-detail about the ways the committee considered redesigning the
-\fBtabs\fP and \fBtput\fP utilities,
-without proposing an improved solution.
-It comments that
-.RS 5
-.PP
-no known historical version of tabs supports the capability of setting
-arbitrary tab stops.
+but retained the tables to support the printers.
+By this time,
+System\ V
+.B tput
+had incorporated the tab stop initialization feature of BSD's
+.B tset
+from 1982,
+but employed the
+.I \%term\%info
+database to do so.
+.PP
+The
+.B +m
+option was documented in the POSIX Base Specifications Issue 5
+(Unix98, 1997),
+then omitted in Issue 6
+(Unix03, 2004)
+without express motivation,
+though an introductory comment
+\*(``and optionally adjusts the margin\*('' remains,
+overlooked in the removal.
+The
+.B tabs
+utility documented in Issues 6 and later has no mechanism for setting
+margins.
+The
+.B +m
+option in
+.I \%ncurses
+\fB\%@TABS@\fP differs from the SVr4 feature by using terminal
+capabilities rather than built-in tables.
+.PP
+POSIX documents no limit on the number of tab stops.
+Other implementations impose one;
+the limit is 20 in PWB/Unix's
+.B tabs
+utility.
+While some terminals may not accept an arbitrary number of tab stops,
+.I \%ncurses
+\fB\%@TABS@\fP attempts to set tab stops up to the right margin if the
+list thereof is sufficiently long.
+.PP
+The \*(``Rationale\*('' section of the Issue 6
+.B tabs
+reference page
+.\" https://pubs.opengroup.org/onlinepubs/009604499/utilities/tabs.html
+details how the committee considered redesigning the
+.B tabs
+and
+.B tput
+utilities,
+without settling on an improved solution.
+It claims that
+.PP
+.RS 4
+\*(``no known historical version of
+.I tabs
+supports the capability of setting arbitrary tab stops.\*(''
 .RE
 .PP
-However, the \fIExplicit Lists\fP described in this manual page
-were implemented in PWB/Unix.
-Those provide the capability of setting abitrary tab stops.
+The feature described in subsection \*(``Explicit Lists\*('' above was
+implemented in PWB/Unix,
+.\" see URL above
+and permitted the setting of abitrary tab stops nevertheless.
 .SH SEE ALSO
-\fB@INFOCMP@\fR(1M),
-\fB@TSET@\fR(1),
-\fBcurses\fR(3X),
-\fBterminfo\fR(\*n).
-.PP
-This describes \fBncurses\fR
-version @NCURSES_MAJOR@.@NCURSES_MINOR@ (patch @NCURSES_PATCH@).
+\fB\%@INFOCMP@\fP(1M),
+\fB\%@TSET@\fP(1),
+\fB\%curses\fP(3X),
+\fB\%terminfo\fP(5)
diff --git a/contrib/ncurses/man/term.5 b/contrib/ncurses/man/term.5
index e9ae5bd0b908..cec231f551a3 100644
--- a/contrib/ncurses/man/term.5
+++ b/contrib/ncurses/man/term.5
@@ -1,5 +1,6 @@
+'\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,44 +28,48 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: term.5,v 1.38 2020/07/25 21:56:02 tom Exp $
-.TH term 5
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
-.de NS
-.ie n  .sp
-.el    .sp .5
-.ie n  .in +4
-.el    .in +2
-.nf
-.ft C			\" Courier
-..
-.de NE
-.fi
-.ft R
-.ie n  .in -4
-.el    .in -2
-..
+.\" $Id: term.5,v 1.77 2024/04/20 21:24:19 tom Exp $
+.TH term 5 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "File formats"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.ds '  \(aq
+.ds ^  \(ha
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.ds       '  '
+.ds       ^  ^
+.\}
+.ie n .ds CW R
+.el   \{
+.ie \n(.g .ds CW CR
+.el       .ds CW CW
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.ds n 5
+.
 .ds d @TERMINFO@
 .SH NAME
-term \- format of compiled term file.
+term \-
+compiled \fIterminfo\fR terminal description
 .SH SYNOPSIS
 .B term
 .SH DESCRIPTION
-.SS STORAGE LOCATION
+.SS "Storage Location"
 Compiled terminfo descriptions are placed under the directory \fB\*d\fP.
-Two configurations are supported (when building the \fBncurses\fP libraries):
+Two configurations are supported
+(when building the \fI\%ncurses\fP libraries):
 .TP 5
 .B directory tree
 A two-level scheme is used to avoid a linear search
-of a huge \s-1UNIX\s+1 system directory: \fB\*d/c/name\fP where
+of a huge Unix system directory: \fB\*d/c/name\fP where
 .I name
 is the name of the terminal, and
 .I c
@@ -83,15 +88,16 @@ the terminfo's primary name as a key,
 and records containing only aliases pointing to the primary name.
 .IP
 If built to write hashed databases,
-\fBncurses\fP can still read terminfo databases organized as a directory tree,
+\fI\%ncurses\fP can still read terminfo databases organized as a
+directory tree,
 but cannot write entries into the directory tree.
 It can write (or rewrite) entries in the hashed database.
 .IP
-\fBncurses\fP distinguishes the two cases in the TERMINFO and TERMINFO_DIRS
-environment variable by assuming a directory tree for entries that
-correspond to an existing directory,
+\fI\%ncurses\fP distinguishes the two cases in the \fI\%TERMINFO\fP and
+\fI\%TERMINFO_DIRS\fP environment variable by assuming a directory tree
+for entries that correspond to an existing directory,
 and hashed database otherwise.
-.SS LEGACY STORAGE FORMAT
+.SS "Legacy Storage Format"
 The format has been chosen so that it will be the same on all hardware.
 An 8 or more bit byte is assumed, but no assumptions about byte ordering
 or sign extension are made.
@@ -105,7 +111,7 @@ a) \fIheader\fP,
 .TP 3
 b) \fIterminal names\fP,
 .TP 3
-c) \fIboolean flags\fP,
+c) \fIBoolean flags\fP,
 .TP 3
 d) \fInumbers\fP,
 .TP 3
@@ -124,7 +130,7 @@ These integers are
 .TP 5
 (2) the size, in bytes, of the \fIterminal names\fP section;
 .TP 5
-(3) the number of bytes in the \fIboolean flags\fP section;
+(3) the number of bytes in the \fIBoolean flags\fP section;
 .TP 5
 (4) the number of short integers in the \fInumbers\fP section;
 .TP 5
@@ -134,7 +140,7 @@ These integers are
 .RE
 .PP
 The capabilities in the
-\fIboolean flags\fP,
+\fIBoolean flags\fP,
 \fInumbers\fP, and
 \fIstrings\fP
 sections are in the same order as the file <term.h>.
@@ -162,14 +168,14 @@ If a capability is absent from this terminal,
 .IP
 The integer value \-1 is represented by two bytes 0377, 0377.
 .br
-Absent boolean values are represented by the byte 0 (false).
+Absent Boolean values are represented by the byte 0 (false).
 .bP
 If a capability has been canceled from this terminal,
 @TIC@ stores a \-2 in the corresponding table.
 .IP
 The integer value \-2 is represented by two bytes 0377, 0376.
 .br
-The boolean value \-2 is represented by the byte 0376.
+The Boolean value \-2 is represented by the byte 0376.
 .br
 .bP
 Other negative values are illegal.
@@ -181,11 +187,11 @@ separated by the \*(``|\*('' character.
 The \fIterminal names\fP section is terminated
 with an \s-1ASCII NUL\s+1 character.
 .PP
-The \fIboolean flags\fP section has one byte for each flag.
+The \fIBoolean flags\fP section has one byte for each flag.
 Boolean capabilities are either 1 or 0 (true or false)
 according to whether the terminal supports the given capability or not.
 .PP
-Between the \fIboolean flags\fP section and the \fInumber\fP section,
+Between the \fIBoolean flags\fP section and the \fInumber\fP section,
 a null byte will be inserted, if necessary,
 to ensure that the \fInumber\fP section begins on an even byte
 This is a relic of the PDP\-11's word-addressed architecture,
@@ -193,7 +199,7 @@ originally designed to avoid traps induced
 by addressing a word on an odd byte boundary.
 All short integers are aligned on a short word boundary.
 .PP
-The \fInumbers\fP section is similar to the \fIboolean flags\fP section.
+The \fInumbers\fP section is similar to the \fIBoolean flags\fP section.
 Each capability takes up two bytes,
 and is stored as a little-endian short integer.
 .PP
@@ -205,24 +211,24 @@ The \fIstring table\fP is the last section.
 It contains all of the values of string capabilities referenced in
 the \fIstrings\fP section.
 Each string is null-terminated.
-Special characters in ^X or \ec notation are stored in their
+Special characters in \*^X or \ec notation are stored in their
 interpreted form, not the printing representation.
 Padding information $<nn> and parameter information %x are
 stored intact in uninterpreted form.
-.SS EXTENDED STORAGE FORMAT
+.SS "Extended Storage Format"
 The previous section describes the conventional terminfo binary format.
 With some minor variations of the offsets (see PORTABILITY),
-the same binary format is used in all modern UNIX systems.
-Each system uses a predefined set of boolean, number or string capabilities.
+the same binary format is used in all modern Unix systems.
+Each system uses a predefined set of Boolean, number or string capabilities.
 .PP
-The \fBncurses\fP libraries and applications support
+The \fI\%ncurses\fP libraries and applications support
 extended terminfo binary format,
 allowing users to define capabilities which are loaded at runtime.
 This
 extension is made possible by using the fact that the other implementations
 stop reading the terminfo data when they have reached the end of the size given
 in the header.
-\fBncurses\fP checks the size,
+\fI\%ncurses\fP checks the size,
 and if it exceeds that due to the predefined data,
 continues to parse according to its own scheme.
 .PP
@@ -230,7 +236,7 @@ First, it reads the extended header (5 short integers):
 .RS 5
 .TP 5
 (1)
-count of extended boolean capabilities
+count of extended Boolean capabilities
 .TP 5
 (2)
 count of extended numeric capabilities
@@ -249,22 +255,31 @@ The count- and size-values for the extended string table
 include the extended capability \fInames\fP as well as
 extended capability \fIvalues\fP.
 .PP
-Using the counts and sizes, \fBncurses\fP allocates arrays and reads data
-for the extended capabilities in the same order as the header information.
+Using the counts and sizes,
+\fI\%ncurses\fP allocates arrays and reads data for the extended
+capabilities in the same order as the header information.
 .PP
 The extended string table contains values for string capabilities.
 After the end of these values, it contains the names for each of
-the extended capabilities in order, e.g., booleans, then numbers and
+the extended capabilities in order, e.g., Booleans, then numbers and
 finally strings.
 .PP
+By storing terminal descriptions in this way,
+\fI\%ncurses\fP is able to provide a database useful with legacy
+applications,
+as well as providing data for applications which need more than the
+predefined capabilities.
+See \fBuser_caps\fP(5) for an overview
+of the way \fI\%ncurses\fP uses this extended information.
+.PP
 Applications which manipulate terminal data can use the definitions
 described in \fBterm_variables\fP(3X) which associate the long capability
 names with members of a \fBTERMTYPE\fP structure.
 .
-.SS EXTENDED NUMBER FORMAT
-.PP
+.SS "Extended Number Format"
 On occasion, 16-bit signed integers are not large enough.
-With \fBncurses\fP 6.1, a new format was introduced by making a few changes
+With \fI\%ncurses\fP 6.1,
+a new format was introduced by making a few changes
 to the legacy format:
 .bP
 a different magic number (octal 01036)
@@ -277,16 +292,19 @@ to direct users of the \fBTERMTYPE\fP structure as in previous formats.
 However, that cannot provide callers with the extended numbers.
 The library uses a similar but hidden data structure \fBTERMTYPE2\fP
 to provide data for the terminfo functions.
+.SH FILES
+.TP
+.I \*d
+compiled terminal description database
 .SH PORTABILITY
 .SS setupterm
-.PP
 Note that it is possible for
 .B setupterm
 to expect a different set of capabilities
 than are actually present in the file.
 Either the database may have been updated since
 .B setupterm
-has been recompiled
+was recompiled
 (resulting in extra unrecognized entries in the file)
 or the program may have been recompiled more recently
 than the database was updated
@@ -296,22 +314,21 @@ The routine
 must be prepared for both possibilities \-
 this is why the numbers and sizes are included.
 Also, new capabilities must always be added at the end of the lists
-of boolean, number, and string capabilities.
-.SS Binary format
-.PP
+of Boolean, number, and string capabilities.
+.SS "Binary Format"
 X/Open Curses does not specify a format for the terminfo database.
-UNIX System V curses used a directory-tree of binary files,
+System V curses used a directory-tree of binary files,
 one per terminal description.
 .PP
 Despite the consistent use of little-endian for numbers and the otherwise
 self-describing format, it is not wise to count on portability of binary
-terminfo entries between commercial UNIX versions.
+terminfo entries between commercial Unix versions.
 The problem is that there
 are at least three versions of terminfo (under HP\-UX, AIX, and OSF/1) which
 diverged from System V terminfo after SVr1, and have added extension
 capabilities to the string table that (in the binary format) collide with
-System V and XSI Curses extensions.
-See \fBterminfo\fR(\*n) for detailed
+System V and X/Open Curses extensions.
+See \fBterminfo\fP(5) for detailed
 discussion of terminfo source compatibility issues.
 .PP
 This implementation is by default compatible with the binary
@@ -319,53 +336,83 @@ terminfo format used by Solaris curses,
 except in a few less-used details
 where it was found that the latter did not match X/Open Curses.
 The format used by the other Unix versions
-can be matched by building ncurses
+can be matched by building \fI\%ncurses\fP
 with different configuration options.
-.SS Magic codes
-.PP
+.SS "Magic Codes"
 The magic number in a binary terminfo file is the first 16-bits (two bytes).
 Besides making it more reliable for the library to check that a file
 is terminfo,
-utilities such as \fBfile\fP also use that to tell what the file-format is.
+utilities such as \fBfile\fP(1) also use that to tell what the file-format is.
 System V defined more than one magic number,
 with 0433, 0435 as screen-dumps (see \fBscr_dump\fP(5)).
 This implementation uses 01036 as a continuation of that sequence,
 but with a different high-order byte to avoid confusion.
-.SS The TERMTYPE structure
-.PP
+.SS "The \fITERMTYPE\fP Structure"
 Direct access to the \fBTERMTYPE\fP structure is provided for legacy
 applications.
 Portable applications should use the \fBtigetflag\fP and related functions
 described in \fBcurs_terminfo\fP(3X) for reading terminal capabilities.
-.SS Mixed-case terminal names
-.PP
+.SS "Mixed-case Terminal Names"
 A small number of terminal descriptions use uppercase characters in
 their names.
 If the underlying filesystem ignores the difference between
 uppercase and lowercase,
-\fBncurses\fP represents the \*(``first character\*(''
+\fI\%ncurses\fP represents the \*(``first character\*(''
 of the terminal name used as
 the intermediate level of a directory tree in (two-character) hexadecimal form.
-.SH EXAMPLE
+.SS Limits
+\fI\%ncurses\fP stores compiled terminal descriptions
+in three related formats,
+described in the sections
+.bP
+\fBLEGACY STORAGE FORMAT\fP, and
+.bP
+\fBEXTENDED STORAGE FORMAT\fP, and
+.bP
+\fBEXTENDED NUMBER FORMAT\fP.
+.PP
+The legacy storage format and the extended number format differ by
+the types of numeric capability which they can store
+(i.e., 16-bit versus 32-bit integers).
+The extended storage format introduced by \fI\%ncurses\fP 5.0 adds data
+to either of these formats.
+.PP
+Some limitations apply:
+.bP
+total compiled entries cannot exceed 4096 bytes in the legacy format.
+.bP
+total compiled entries cannot exceed 32768 bytes in the extended format.
+.bP
+the name field cannot exceed 128 bytes.
+.PP
+Compiled entries are limited to 32768 bytes because offsets into the
+\fIstrings table\fP use two-byte integers.
+The legacy format could have supported 32768-byte entries,
+but was limited to a virtual memory page's 4096 bytes.
+.SH EXAMPLES
 As an example, here is a description for the Lear-Siegler
 ADM\-3, a popular though rather stupid early terminal:
-.NS
+.PP
+.EX
 adm3a|lsi adm3a,
         am,
         cols#80, lines#24,
-        bel=^G, clear=\032$<1>, cr=^M, cub1=^H, cud1=^J,
-        cuf1=^L, cup=\\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K,
-        home=^^, ind=^J,
-.NS
+        bel=\*^G, clear=\e032$<1>, cr=\*^M, cub1=\*^H, cud1=\*^J,
+        cuf1=\*^L, cup=\eE=%p1%{32}%+%c%p2%{32}%+%c, cuu1=\*^K,
+        home=\*^\*^, ind=\*^J,
+.EE
 .PP
 and a hexadecimal dump of the compiled terminal description:
-.NS
-.ft CW
-\s-20000  1a 01 10 00 02 00 03 00  82 00 31 00 61 64 6d 33  ........ ..1.adm3
+.PP
+.if t .in +4n
+.ft \*(CW
+.TS
+Lp-1.
+0000  1a 01 10 00 02 00 03 00  82 00 31 00 61 64 6d 33  ........ ..1.adm3
 0010  61 7c 6c 73 69 20 61 64  6d 33 61 00 00 01 50 00  a|lsi ad m3a...P.
 0020  ff ff 18 00 ff ff 00 00  02 00 ff ff ff ff 04 00  ........ ........
-0030  ff ff ff ff ff ff ff ff  0a 00 25 00 27 00 ff ff  ........ ..%.'...
-0040  29 00 ff ff ff ff 2b 00  ff ff 2d 00 ff ff ff ff  ).....+. ..-.....
+0030  ff ff ff ff ff ff ff ff  0a 00 25 00 27 00 ff ff  ........ ..%.\*'...
+0040  29 00 ff ff ff ff 2b 00  ff ff 2d 00 ff ff ff ff  ).....+. ..\-.....
 0050  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
 0060  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
 0070  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
@@ -382,36 +429,24 @@ and a hexadecimal dump of the compiled terminal description:
 0120  ff ff ff ff ff ff 2f 00  07 00 0d 00 1a 24 3c 31  ....../. .....$<1
 0130  3e 00 1b 3d 25 70 31 25  7b 33 32 7d 25 2b 25 63  >..=%p1% {32}%+%c
 0140  25 70 32 25 7b 33 32 7d  25 2b 25 63 00 0a 00 1e  %p2%{32} %+%c....
-0150  00 08 00 0c 00 0b 00 0a  00                       ........ .\s+2
-.ft R
-.NE
-.sp
-.SH LIMITS
-Some limitations:
-.bP
-total compiled entries cannot exceed 4096 bytes in the legacy format.
-.bP
-total compiled entries cannot exceed 32768 bytes in the extended format.
-.bP
-the name field cannot exceed 128 bytes.
-.PP
-Compiled entries are limited to 32768 bytes because offsets into the
-\fIstrings table\fP use two-byte integers.
-The legacy format could have supported 32768-byte entries,
-but was limited a virtual memory page's 4096 bytes.
-.SH FILES
-\*d/*/*	compiled terminal capability data base
-.SH SEE ALSO
-\fBcurses\fR(3X), \fBterminfo\fR(\*n).
+0150  00 08 00 0c 00 0b 00 0a  00                       ........ .
+.TE
+.ft
+.in
 .SH AUTHORS
 Thomas E. Dickey
 .br
-extended terminfo format for ncurses 5.0
+extended terminfo format for \fI\%ncurses\fP 5.0
 .br
-hashed database support for ncurses 5.6
+hashed database support for \fI\%ncurses\fP 5.6
 .br
-extended number support for ncurses 6.1
+extended number support for \fI\%ncurses\fP 6.1
 .sp
 Eric S. Raymond
 .br
-documented legacy terminfo format, e.g., from pcurses.
+documented legacy terminfo format, e.g., from \fIpcurses\fP.
+.SH SEE ALSO
+\fB\%curses\fP(3X),
+\fB\%curs_terminfo\fP(3X),
+\fB\%terminfo\fP(5),
+\fB\%user_caps\fP(5)
diff --git a/contrib/ncurses/man/term.7 b/contrib/ncurses/man/term.7
index fc46b8a6f914..84d100d840ca 100644
--- a/contrib/ncurses/man/term.7
+++ b/contrib/ncurses/man/term.7
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2011,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,79 +27,91 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: term.7,v 1.28 2020/02/02 23:34:34 tom Exp $
-.TH term 7
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
-.ds n 5
+.\" $Id: term.7,v 1.48 2024/03/16 15:35:01 tom Exp $
+.TH term 7 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" Miscellaneous
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .ds d @TERMINFO@
 .SH NAME
-term \- conventions for naming terminal types
+term \-
+conventions for naming terminal types
+.\"SH SYNOPSIS
 .SH DESCRIPTION
-.PP
-The environment variable \fBTERM\fR should normally contain the type name of
-the terminal, console or display-device type you are using.
+The environment variable \fITERM\fP should normally contain the type
+name of the terminal,
+console or display-device type you are using.
 This information
 is critical for all screen-oriented programs, including your editor and mailer.
 .PP
-A default \fBTERM\fR value will be set on a per-line basis by either
-\fB/etc/inittab\fR (e.g., System\-V-like UNIXes)
-or \fB/etc/ttys\fR (BSD UNIXes).
+A default \fITERM\fP value will be set on a per-line basis by either
+\fB/etc/inittab\fP (e.g., System\-V-like Unices)
+or \fB/etc/ttys\fP (BSD Unices).
 This will nearly always suffice for workstation and microcomputer consoles.
 .PP
 If you use a dialup line, the type of device attached to it may vary.
-Older UNIX systems pre-set a very dumb terminal type
+Older Unix systems pre-set a very dumb terminal type
 like \*(``dumb\*('' or \*(``dialup\*('' on dialup lines.
 Newer ones may pre-set \*(``vt100\*('', reflecting the prevalence of DEC
 VT100-compatible terminals and personal-computer emulators.
 .PP
-Modern telnets pass your \fBTERM\fR environment variable from the local side to
-the remote one.
+Modern telnets pass your \fITERM\fP environment variable from the local
+side to the remote one.
 There can be problems if the remote terminfo or termcap entry
 for your type is not compatible with yours, but this situation is rare and
 can almost always be avoided by explicitly exporting \*(``vt100\*(''
 (assuming you are in fact using a VT100-superset console,
-terminal, or terminal emulator.)
+terminal, or terminal emulator).
 .PP
-In any case, you are free to override the system \fBTERM\fR setting to your
-taste in your shell profile.
+In any case, you are free to override the system \fITERM\fP setting to
+your taste in your shell profile.
 The \fB@TSET@\fP(1) utility may be of assistance;
 you can give it a set of rules for deducing or requesting a terminal type based
 on the tty device and baud rate.
 .PP
-Setting your own \fBTERM\fR value may also be useful if you have created a
-custom entry incorporating options (such as visual bell or reverse-video)
+Setting your own \fITERM\fP value may also be useful if you have created
+a custom entry incorporating options
+(such as visual bell or reverse-video)
 which you wish to override the system default type for your line.
 .PP
 Terminal type descriptions are stored as files of capability data underneath
 \*d.
 To browse a list of all terminal names recognized by the system, do
 .sp
-	@TOE@ | more
+        @TOE@ | more
 .sp
 from your shell.
 These capability files are in a binary format optimized for
-retrieval speed (unlike the old text-based \fBtermcap\fR format they replace);
-to examine an entry, you must use the \fB@INFOCMP@\fR(1M) command.
+retrieval speed (unlike the old text-based \fBtermcap\fP format they replace);
+to examine an entry, you must use the \fB@INFOCMP@\fP(1M) command.
 Invoke it as follows:
 .sp
-	@INFOCMP@ \fIentry_name\fR
+        @INFOCMP@ \fIentry_name\fP
 .sp
-where \fIentry_name\fR is the name of the type you wish to examine (and the
+where \fIentry_name\fP is the name of the type you wish to examine (and the
 name of its capability file the subdirectory of \*d named for its first
 letter).
 This command dumps a capability file in the text format described by
-\fBterminfo\fR(\*n).
+\fBterminfo\fP(5).
 .PP
-The first line of a \fBterminfo\fR(\*n) description gives the names by which
+The first line of a \fBterminfo\fP(5) description gives the names by which
 terminfo knows a terminal,
 separated by \*(``|\*('' (pipe-bar) characters with the last
 name field terminated by a comma.
 The first name field is the type's
-\fIprimary name\fR, and is the one to use when setting \fBTERM\fR.  The last
-name field (if distinct from the first) is actually a description of the
+\fIprimary name\fP,
+and is the one to use when setting \fITERM\fP.
+The last name field
+(if distinct from the first)
+is actually a description of the
 terminal type (it may contain blanks; the others must be single words).
 Name
 fields between the first and last (if present) are aliases for the terminal,
@@ -126,23 +138,23 @@ dot (.) character is relatively safe as long as there is at most one per root
 name; some historical terminfo names use it.
 .PP
 The root name for a terminal or workstation console type should almost always
-begin with a vendor prefix (such as \fBhp\fR for Hewlett-Packard, \fBwy\fR for
-Wyse, or \fBatt\fR for AT&T terminals), or a common name of the terminal line
-(\fBvt\fR for the VT series of terminals from DEC, or \fBsun\fR for Sun
-Microsystems workstation consoles, or \fBregent\fR for the ADDS Regent series.
+begin with a vendor prefix (such as \fBhp\fP for Hewlett-Packard, \fBwy\fP for
+Wyse, or \fBatt\fP for AT&T terminals), or a common name of the terminal line
+(\fBvt\fP for the VT series of terminals from DEC, or \fBsun\fP for Sun
+Microsystems workstation consoles, or \fBregent\fP for the ADDS Regent series.
 You can list the terminfo tree to see what prefixes are already in common use.
 The root name prefix should be followed when appropriate by a model number;
-thus \fBvt100\fR, \fBhp2621\fR, \fBwy50\fR.
+thus \fBvt100\fP, \fBhp2621\fP, \fBwy50\fP.
 .PP
 The root name for a PC-Unix console type should be the OS name,
-i.e., \fBlinux\fR, \fBbsdos\fR, \fBfreebsd\fR, \fBnetbsd\fR.  It should
-\fInot\fR be \fBconsole\fR or any other generic that might cause confusion in a
+i.e., \fBlinux\fP, \fBbsdos\fP, \fBfreebsd\fP, \fBnetbsd\fP.  It should
+\fInot\fP be \fBconsole\fP or any other generic that might cause confusion in a
 multi-platform environment!  If a model number follows, it should indicate
 either the OS release level or the console driver release level.
 .PP
 The root name for a terminal emulator (assuming it does not fit one of the
 standard ANSI or vt100 types) should be the program name or a readily
-recognizable abbreviation of it (i.e., \fBversaterm\fR, \fBctrm\fR).
+recognizable abbreviation of it (i.e., \fBversaterm\fP, \fBctrm\fP).
 .PP
 Following the root name, you may add any reasonable number of hyphen-separated
 feature suffixes.
@@ -197,7 +209,7 @@ Conventionally, if your terminal type is a variant intended to specify a
 line height, that suffix should go first.
 So, for a hypothetical FuBarCo
 model 2317 terminal in 30-line mode with reverse video, best form would be
-\fBfubar\-30\-rv\fR (rather than, say, \*(``fubar\-rv\-30\*('').
+\fBfubar\-30\-rv\fP (rather than, say, \*(``fubar\-rv\-30\*('').
 .PP
 Terminal types that are written not as standalone entries, but rather as
 components to be plugged into other entries via \fBuse\fP capabilities,
@@ -206,19 +218,21 @@ are distinguished by using embedded plus signs rather than dashes.
 Commands which use a terminal type to control display often accept a \-T
 option that accepts a terminal name argument.
 Such programs should fall back
-on the \fBTERM\fR environment variable when no \-T option is specified.
+on the \fITERM\fP environment variable when no \-T option is specified.
+.SH FILES
+.TP
+.I \*d
+compiled terminal description database
+.TP
+.I /etc/inittab
+tty line initialization (AT&T-like Unices)
+.TP
+.I /etc/ttys
+tty line initialization (BSD-like Unices)
 .SH PORTABILITY
-For maximum compatibility with older System V UNIXes, names and aliases
+For maximum compatibility with older System V Unices, names and aliases
 should be unique within the first 14 characters.
-.SH FILES
-.TP 5
-\*d/?/*
-compiled terminal capability data base
-.TP 5
-/etc/inittab
-tty line initialization (AT&T-like UNIXes)
-.TP 5
-/etc/ttys
-tty line initialization (BSD-like UNIXes)
 .SH SEE ALSO
-\fBcurses\fR(3X), \fBterminfo\fR(\*n), \fBterm\fR(\*n).
+\fB\%curses\fP(3X),
+\fB\%term\fP(5),
+\fB\%terminfo\fP(5)
diff --git a/contrib/ncurses/man/term_variables.3x b/contrib/ncurses/man/term_variables.3x
index 0abaf0968bde..6aee63f487ed 100644
--- a/contrib/ncurses/man/term_variables.3x
+++ b/contrib/ncurses/man/term_variables.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2019,2020 Thomas E. Dickey                                     *
+.\" Copyright 2019-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 2010-2015,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,64 +27,58 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: term_variables.3x,v 1.12 2020/02/02 23:34:34 tom Exp $
-.TH term_variables 3X ""
-.ds n 5
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
-.na
-.hy 0
+.\" $Id: term_variables.3x,v 1.36 2024/03/16 15:35:01 tom Exp $
+.TH term_variables 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .SH NAME
-\fBSP\fP,
-\fBacs_map\fP,
-\fBboolcodes\fP,
-\fBboolfnames\fP,
-\fBboolnames\fP,
-\fBcur_term\fP,
-\fBnumcodes\fP,
-\fBnumfnames\fP,
-\fBnumnames\fP,
-\fBstrcodes\fP,
-\fBstrfnames\fP,
-\fBstrnames\fP,
-\fBttytype\fP
-\- \fBcurses\fR terminfo global variables
-.ad
-.hy
+\fB\%SP\fP,
+\fB\%acs_map\fP,
+\fB\%boolcodes\fP,
+\fB\%boolfnames\fP,
+\fB\%boolnames\fP,
+\fB\%cur_term\fP,
+\fB\%numcodes\fP,
+\fB\%numfnames\fP,
+\fB\%numnames\fP,
+\fB\%strcodes\fP,
+\fB\%strfnames\fP,
+\fB\%strnames\fP,
+\fB\%ttytype\fP \-
+\fIterminfo\fR global variables
 .SH SYNOPSIS
 .nf
-\fB#include <curses.h>\fR
-.br
-\fB#include <term.h>\fR
-.PP
-\fBchtype acs_map[];\fR
-.sp
-\fBSCREEN * SP;\fR
-.sp
-\fBTERMINAL * cur_term;\fR
-.sp
-\fBchar ttytype[];\fR
-.sp
-\fBNCURSES_CONST char * const boolcodes[];\fR
-.br
-\fBNCURSES_CONST char * const boolfnames[];\fR
-.br
-\fBNCURSES_CONST char * const boolnames[];\fR
-.sp
-\fBNCURSES_CONST char * const numcodes[];\fR
-.br
-\fBNCURSES_CONST char * const numfnames[];\fR
-.br
-\fBNCURSES_CONST char * const numnames[];\fR
-.sp
-\fBNCURSES_CONST char * const strcodes[];\fR
-.br
-\fBNCURSES_CONST char * const strfnames[];\fR
-.br
-\fBNCURSES_CONST char * const strnames[];\fR
-.br
+\fB#include <curses.h>
+\fB#include <term.h>
+.PP
+\fBchtype acs_map[];
+.PP
+\fBSCREEN * SP;
+.PP
+\fBTERMINAL * cur_term;
+.PP
+\fBchar ttytype[];
+.PP
+\fBNCURSES_CONST char * const boolcodes[];
+\fBNCURSES_CONST char * const boolfnames[];
+\fBNCURSES_CONST char * const boolnames[];
+.PP
+\fBNCURSES_CONST char * const numcodes[];
+\fBNCURSES_CONST char * const numfnames[];
+\fBNCURSES_CONST char * const numnames[];
+.PP
+\fBNCURSES_CONST char * const strcodes[];
+\fBNCURSES_CONST char * const strfnames[];
+\fBNCURSES_CONST char * const strnames[];
 .fi
 .SH DESCRIPTION
 This page summarizes variables provided by the \fBcurses\fP library's
@@ -92,11 +86,11 @@ low-level terminfo interface.
 A more complete description is given in the \fBcurs_terminfo\fP(3X) manual page.
 .PP
 Depending on the configuration, these may be actual variables,
-or macros (see \fBcurs_threads\fR(3X))
+or macros (see \fBcurs_threads\fP(3X))
 which provide read-only access to \fIcurses\fP's state.
 In either case, applications should treat them as read-only to avoid
 confusing the library.
-.SS Alternate Character Set Mapping
+.SS "Alternate Character Set Mapping"
 After initializing the curses or terminfo interfaces,
 the \fBacs_map\fP array holds information used to translate cells
 with the \fBA_ALTCHARSET\fP video attribute into line-drawing characters.
@@ -106,7 +100,7 @@ Application developers need only know that it is used for the \*(``ACS_\*(''
 constants in <curses.h>.
 .PP
 The comparable data for the wide-character library is a private variable.
-.SS Current Terminal Data
+.SS "Current Terminal Data"
 After initializing the curses or terminfo interfaces,
 the \fBcur_term\fP contains data describing the current terminal.
 This variable is also set as a side-effect of \fBset_term\fP(3X)
@@ -116,7 +110,7 @@ It is possible to save a value of \fBcur_term\fP for subsequent
 use as a parameter to \fBset_term\fP, for switching between screens.
 Alternatively, one can save the return value from \fBnewterm\fP
 or \fBsetupterm\fP(3X) to reuse in \fBset_term\fP.
-.SS Terminfo Names
+.SS "\fIterminfo\fP Lookup Tables"
 The \fB@TIC@\fP(1) and \fB@INFOCMP@\fP(1) programs use lookup tables for
 the long and short names of terminfo capabilities,
 as well as the corresponding names for termcap capabilities.
@@ -124,7 +118,7 @@ These are available to other applications,
 although the hash-tables used by
 the terminfo and termcap functions are not available.
 .PP
-The long terminfo capability names use a \*(``l\*('' (ell) in their names:
+The long terminfo capability names use a \*(``f\*('' (eff) in their names:
 \fBboolfnames\fP,
 \fBnumfnames\fP, and
 \fBstrfnames\fP.
@@ -139,27 +133,24 @@ These are the corresponding names used for termcap descriptions:
 \fBnumcodes\fP, and
 \fBstrcodes\fP.
 .\"
-.SS Terminal Type
+.SS "Terminal Type"
 A terminal description begins with one or more terminal names
 separated by \*(``|\*('' (vertical bars).
 On initialization of the curses or terminfo interfaces,
 \fBsetupterm\fP(3X) copies the terminal names to the array \fBttytype\fP.
 .\"
-.SS Terminfo Names
-.PP
+.SS "\fIterminfo\fP Names"
 In addition to the variables, \fB<term.h>\fP also defines a symbol for each
 terminfo capability \fIlong name\fP.
 These are in terms of the symbol \fBCUR\fP,
 which is defined
 .PP
-.nf
-.ft CW
-#define CUR ((TERMTYPE *)(cur_term))->
-.fi
-.ft R
+.EX
+#define CUR ((TERMTYPE *)(cur_term))\->
+.EE
 .PP
 These symbols provide a faster method of accessing terminfo capabilities
-than using \fBtigetstr\fR(3X), etc.
+than using \fBtigetstr\fP(3X), etc.
 .PP
 The actual definition of \fBCUR\fP depends upon the implementation,
 but each terminfo library provides these long names defined to point
@@ -167,9 +158,7 @@ into the current terminal description loaded into memory.
 .\"
 .SH NOTES
 The low-level terminfo interface is initialized using
-.hy 0
-\fBsetupterm\fR(3X).
-.hy
+\fB\%setupterm\fP(3X).
 The upper-level curses interface uses the low-level terminfo interface,
 internally.
 .\"
@@ -186,9 +175,7 @@ All implementations which provide terminfo interfaces add definitions
 as described in the \fBTerminfo Names\fP section.
 Most, but not all, base the definition upon the \fBcur_term\fP variable.
 .SH SEE ALSO
-.hy 0
-\fBcurses\fR(3X),
-\fBcurs_terminfo\fR(3X),
-\fBcurs_threads\fR(3X),
-\fBterminfo\fR(\*n).
-.hy
+\fB\%curses\fP(3X),
+\fB\%curs_terminfo\fP(3X),
+\fB\%curs_threads\fP(3X),
+\fB\%terminfo\fP(5)
diff --git a/contrib/ncurses/man/terminfo.head b/contrib/ncurses/man/terminfo.head
index f6a31c8055dc..717f849e25fb 100644
--- a/contrib/ncurses/man/terminfo.head
+++ b/contrib/ncurses/man/terminfo.head
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,45 +27,45 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: terminfo.head,v 1.39 2020/02/02 23:34:34 tom Exp $
-.TH terminfo 5 "" "" "File Formats"
-.ds n 5
-.ds d @TERMINFO@
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: terminfo.head,v 1.65 2024/04/20 21:14:00 tom Exp $
+.TH terminfo 5 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "File formats"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.ds '  \(aq
+.ds ^  \(ha
+.ds ~  \(ti
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.ds       '  '
+.ds       ^  ^
+.ds       ~  ~
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.de NS
-.ie n  .sp
-.el    .sp .5
-.ie n  .in +4
-.el    .in +2
-.nf
-.ft C			\" Courier
-..
-.de NE
-.fi
-.ft R
-.ie n  .in -4
-.el    .in -2
-..
+.
+.ds d @TERMINFO@
 .SH NAME
-terminfo \- terminal capability data base
+\fB\%terminfo\fP \-
+terminal capability database
 .SH SYNOPSIS
 \*d/*/*
 .SH DESCRIPTION
 .I Terminfo
-is a data base describing terminals,
+is a database describing terminals,
 used by screen-oriented programs such as
-\fBnvi\fR(1),
-\fBlynx\fR(1),
-\fBmutt\fR(1),
+\fBnvi\fP(1),
+\fBlynx\fP(1),
+\fBmutt\fP(1),
 and other curses applications,
-using high-level calls to libraries such as \fBcurses\fR(3X).
+using high-level calls to libraries such as \fBcurses\fP(3X).
 It is also used via low-level calls by non-curses applications
 which may be screen-oriented (such as \fB@CLEAR@\fP(1))
 or non-screen (such as \fB@TABS@\fP(1)).
@@ -75,17 +75,18 @@ describes terminals by giving a set of capabilities which they
 have, by specifying how to perform screen operations, and by
 specifying padding requirements and initialization sequences.
 .PP
-This manual describes \fBncurses\fR
-version @NCURSES_MAJOR@.@NCURSES_MINOR@ (patch @NCURSES_PATCH@).
-.SS Terminfo Entry Syntax
-.PP
+This document describes
+.I \%ncurses
+version @NCURSES_MAJOR@.@NCURSES_MINOR@
+(patch @NCURSES_PATCH@).
+.SS "\fIterminfo\fP Entry Syntax"
 Entries in
 .I terminfo
 consist of a sequence of fields:
 .bP
-Each field ends with a comma \*(``,\*('' 
+Each field ends with a comma \*(``,\*(''
 (embedded commas may be
-escaped with a backslash or written as \*(``\\054\*('').
+escaped with a backslash or written as \*(``\e054\*('').
 .bP
 White space between fields is ignored.
 .bP
@@ -121,7 +122,7 @@ it allows that to be both an alias and a verbose name
 .bP
 Lines beginning with a \*(``#\*('' in the first column are treated as comments.
 .IP
-While comment lines are legal at any point, the output of \fB@CAPTOINFO@\fP
+While comment lines are valid at any point, the output of \fB@CAPTOINFO@\fP
 and \fB@INFOTOCAP@\fP (aliases for \fB@TIC@\fP)
 will move comments so they occur only between entries.
 .PP
@@ -136,38 +137,38 @@ Thus, a vt100 in 132-column mode would be vt100\-w.
 The following suffixes should be used where possible:
 .PP
 .TS
-center ;
-l c l
-l l l.
-\fBSuffix	Meaning	Example\fP
-\-\fInn\fP	Number of lines on the screen	aaa\-60
-\-\fIn\fPp	Number of pages of memory	c100\-4p
-\-am	With automargins (usually the default)	vt100\-am
-\-m	Mono mode; suppress color       	ansi\-m
-\-mc	Magic cookie; spaces when highlighting	wy30\-mc
-\-na	No arrow keys (leave them in local)	c100\-na
-\-nam	Without automatic margins       	vt100\-nam
-\-nl	No status line                  	att4415\-nl
-\-ns	No status line                  	hp2626\-ns
-\-rv	Reverse video                   	c100\-rv
-\-s	Enable status line              	vt100\-s
-\-vb	Use visible bell instead of beep	wy370\-vb
-\-w	Wide mode (> 80 columns, usually 132)	vt100\-w
+center;
+Lb Lb Lb
+L  L  Lx.
+Suffix	Example	Meaning
+_
+\-\fInn\fP	aaa\-60	Number of lines on the screen
+\-\fIn\fPp	c100\-4p	Number of pages of memory
+\-am	vt100\-am	With automargins (usually the default)
+\-m	ansi\-m	Mono mode; suppress color
+\-mc	wy30\-mc	Magic cookie; spaces when highlighting
+\-na	c100\-na	No arrow keys (leave them in local)
+\-nam	vt100\-nam	Without automatic margins
+\-nl	hp2621\-nl	No status line
+\-ns	hp2626\-ns	No status line
+\-rv	c100\-rv	Reverse video
+\-s	vt100\-s	Enable status line
+\-vb	wy370\-vb	Use visible bell instead of beep
+\-w	vt100\-w	Wide mode (> 80 columns, usually 132)
 .TE
 .PP
 For more on terminal naming conventions, see the \fBterm\fP(7) manual page.
-.SS Terminfo Capabilities Syntax
-.PP
+.SS "\fIterminfo\fP Capabilities Syntax"
 The terminfo entry consists of several \fIcapabilities\fP,
 i.e., features that the terminal has,
 or methods for exercising the terminal's features.
 .PP
 After the first field (giving the name(s) of the terminal entry),
 there should be one or more \fIcapability\fP fields.
-These are boolean, numeric or string names with corresponding values:
+These are Boolean, numeric or string names with corresponding values:
 .bP
 Boolean capabilities are true when present, false when absent.
-There is no explicit value for boolean capabilities.
+There is no explicit value for Boolean capabilities.
 .bP
 Numeric capabilities have a \*(``#\*('' following the name,
 then an unsigned decimal integer value.
@@ -186,12 +187,11 @@ Any capability can be \fIcanceled\fP,
 i.e., suppressed from the terminal entry,
 by following its name with \*(``@\*(''
 rather than a capability value.
-.SS Similar Terminals
-.PP
+.SS "Similar Terminals"
 If there are two very similar terminals, one (the variant) can be defined as
 being just like the other (the base) with certain exceptions.
 In the
-definition of the variant, the string capability \fBuse\fR can be given with
+definition of the variant, the string capability \fBuse\fP can be given with
 the name of the base terminal:
 .bP
 The capabilities given before
@@ -199,14 +199,14 @@ The capabilities given before
 override those in the base type named by
 .BR use .
 .bP
-If there are multiple \fBuse\fR capabilities, they are merged in reverse order.
-That is, the rightmost \fBuse\fR reference is processed first, then the one to
+If there are multiple \fBuse\fP capabilities, they are merged in reverse order.
+That is, the rightmost \fBuse\fP reference is processed first, then the one to
 its left, and so forth.
 .bP
 Capabilities given explicitly in the entry override
-those brought in by \fBuse\fR references.
+those brought in by \fBuse\fP references.
 .PP
-A capability can be canceled by placing \fBxx@\fR to the left of the
+A capability can be canceled by placing \fBxx@\fP to the left of the
 use reference that imports it, where \fIxx\fP is the capability.
 For example, the entry
 .RS
@@ -214,7 +214,7 @@ For example, the entry
 2621\-nl, smkx@, rmkx@, use=2621,
 .RE
 .PP
-defines a 2621\-nl that does not have the \fBsmkx\fR or \fBrmkx\fR capabilities,
+defines a 2621\-nl that does not have the \fBsmkx\fP or \fBrmkx\fP capabilities,
 and hence does not turn on the function key labels when in visual mode.
 This is useful for different modes for a terminal, or for different
 user preferences.
@@ -222,6 +222,6 @@ user preferences.
 An entry included via \fBuse\fP can contain canceled capabilities,
 which have the same effect as if those cancels were inline in the
 using terminal entry.
-.SS Predefined Capabilities
+.SS "Predefined Capabilities"
 .\" Head of terminfo man page ends here
 .ps -1
diff --git a/contrib/ncurses/man/terminfo.tail b/contrib/ncurses/man/terminfo.tail
index da154ecf96fc..4d6daa38b692 100644
--- a/contrib/ncurses/man/terminfo.tail
+++ b/contrib/ncurses/man/terminfo.tail
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,9 +27,9 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: terminfo.tail,v 1.100 2020/12/19 21:51:22 tom Exp $
+.\" $Id: terminfo.tail,v 1.148 2024/04/20 21:24:19 tom Exp $
 .ps +1
-.SS User-Defined Capabilities
+.SS "User-Defined Capabilities"
 .
 The preceding section listed the \fIpredefined\fP capabilities.
 They deal with some special features for terminals no longer
@@ -38,24 +38,25 @@ Occasionally there are special features of newer terminals which
 are awkward or impossible to represent by reusing the predefined
 capabilities.
 .PP
-\fBncurses\fP addresses this limitation by allowing user-defined capabilities.
+\fI\%ncurses\fP addresses this limitation by allowing user-defined
+capabilities.
 The \fB@TIC@\fP and \fB@INFOCMP@\fP programs provide
 the \fB\-x\fP option for this purpose.
 When \fB\-x\fP is set,
 \fB@TIC@\fP treats unknown capabilities as user-defined.
 That is, if \fB@TIC@\fP encounters a capability name
 which it does not recognize,
-it infers its type (boolean, number or string) from the syntax
+it infers its type (Boolean, number or string) from the syntax
 and makes an extended table entry for that capability.
 The \fBuse_extended_names\fP(3X) function makes this information
 conditionally available to applications.
-The ncurses library provides the data leaving most of the behavior
-to applications:
+The \fI\%ncurses\fP library provides the data leaving most of the
+behavior to applications:
 .bP
 User-defined capability strings whose name begins
 with \*(``k\*('' are treated as function keys.
 .bP
-The types (boolean, number, string) determined by \fB@TIC@\fP
+The types (Boolean, number, string) determined by \fB@TIC@\fP
 can be inferred by successful calls on \fBtigetflag\fP, etc.
 .bP
 If the capability name happens to be two characters,
@@ -67,51 +68,56 @@ in practice it has been limited to the capabilities defined by
 terminfo implementations.
 As a rule,
 user-defined capabilities intended for use by termcap applications should
-be limited to booleans and numbers to avoid running past the 1023 byte
+be limited to Booleans and numbers to avoid running past the 1023 byte
 limit assumed by termcap implementations and their applications.
 In particular, providing extended sets of function keys (past the 60
 numbered keys and the handful of special named keys) is best done using
 the longer names available using terminfo.
+.PP
+The \fI\%ncurses\fP library uses a few of these user-defined
+capabilities,
+as described in \fBuser_caps\fR(5).
+Other user-defined capabilities (including function keys) are
+described in the terminal database, in the section on
+.I "NCURSES USER-DEFINABLE CAPABILITIES"
 .
-.SS A Sample Entry
+.SS "A Sample Entry"
 .
 The following entry, describing an ANSI-standard terminal, is representative
-of what a \fBterminfo\fR entry for a modern terminal typically looks like.
+of what a \fBterminfo\fP entry for a modern terminal typically looks like.
 .PP
-.nf
-.ft CW
-\s-2ansi|ansi/pc-term compatible with color,
+.EX
+\s-2ansi|ansi/pc\-term compatible with color,
         am, mc5i, mir, msgr,
         colors#8, cols#80, it#8, lines#24, ncv#3, pairs#64,
-        acsc=+\\020\\,\\021-\\030.^Y0\\333`\\004a\\261f\\370g\\361h\\260
-             j\\331k\\277l\\332m\\300n\\305o~p\\304q\\304r\\304s_t\\303
-             u\\264v\\301w\\302x\\263y\\363z\\362{\\343|\\330}\\234~\\376,
-        bel=^G, blink=\\E[5m, bold=\\E[1m, cbt=\\E[Z, clear=\\E[H\\E[J,
-        cr=^M, cub=\\E[%p1%dD, cub1=\\E[D, cud=\\E[%p1%dB, cud1=\\E[B,
-        cuf=\\E[%p1%dC, cuf1=\\E[C, cup=\\E[%i%p1%d;%p2%dH,
-        cuu=\\E[%p1%dA, cuu1=\\E[A, dch=\\E[%p1%dP, dch1=\\E[P,
-        dl=\\E[%p1%dM, dl1=\\E[M, ech=\\E[%p1%dX, ed=\\E[J, el=\\E[K,
-        el1=\\E[1K, home=\\E[H, hpa=\\E[%i%p1%dG, ht=\\E[I, hts=\\EH,
-        ich=\\E[%p1%d@, il=\\E[%p1%dL, il1=\\E[L, ind=^J,
-        indn=\\E[%p1%dS, invis=\\E[8m, kbs=^H, kcbt=\\E[Z, kcub1=\\E[D,
-        kcud1=\\E[B, kcuf1=\\E[C, kcuu1=\\E[A, khome=\\E[H, kich1=\\E[L,
-        mc4=\\E[4i, mc5=\\E[5i, nel=\\r\\E[S, op=\\E[39;49m,
-        rep=%p1%c\\E[%p2%{1}%-%db, rev=\\E[7m, rin=\\E[%p1%dT,
-        rmacs=\\E[10m, rmpch=\\E[10m, rmso=\\E[m, rmul=\\E[m,
-        s0ds=\\E(B, s1ds=\\E)B, s2ds=\\E*B, s3ds=\\E+B,
-        setab=\\E[4%p1%dm, setaf=\\E[3%p1%dm,
-        sgr=\\E[0;10%?%p1%t;7%;
+        acsc=+\e020\e,\e021\-\e030.\*^Y0\e333\(ga\e004a\e261f\e370g\e361h\e260
+             j\e331k\e277l\e332m\e300n\e305o\*~p\e304q\e304r\e304s_t\e303
+             u\e264v\e301w\e302x\e263y\e363z\e362{\e343|\e330}\e234\*~\e376,
+        bel=\*^G, blink=\eE[5m, bold=\eE[1m, cbt=\eE[Z, clear=\eE[H\eE[J,
+        cr=\*^M, cub=\eE[%p1%dD, cub1=\eE[D, cud=\eE[%p1%dB, cud1=\eE[B,
+        cuf=\eE[%p1%dC, cuf1=\eE[C, cup=\eE[%i%p1%d;%p2%dH,
+        cuu=\eE[%p1%dA, cuu1=\eE[A, dch=\eE[%p1%dP, dch1=\eE[P,
+        dl=\eE[%p1%dM, dl1=\eE[M, ech=\eE[%p1%dX, ed=\eE[J, el=\eE[K,
+        el1=\eE[1K, home=\eE[H, hpa=\eE[%i%p1%dG, ht=\eE[I, hts=\eEH,
+        ich=\eE[%p1%d@, il=\eE[%p1%dL, il1=\eE[L, ind=\*^J,
+        indn=\eE[%p1%dS, invis=\eE[8m, kbs=\*^H, kcbt=\eE[Z, kcub1=\eE[D,
+        kcud1=\eE[B, kcuf1=\eE[C, kcuu1=\eE[A, khome=\eE[H, kich1=\eE[L,
+        mc4=\eE[4i, mc5=\eE[5i, nel=\er\eE[S, op=\eE[39;49m,
+        rep=%p1%c\eE[%p2%{1}%\-%db, rev=\eE[7m, rin=\eE[%p1%dT,
+        rmacs=\eE[10m, rmpch=\eE[10m, rmso=\eE[m, rmul=\eE[m,
+        s0ds=\eE(B, s1ds=\eE)B, s2ds=\eE*B, s3ds=\eE+B,
+        setab=\eE[4%p1%dm, setaf=\eE[3%p1%dm,
+        sgr=\eE[0;10%?%p1%t;7%;
                    %?%p2%t;4%;
                    %?%p3%t;7%;
                    %?%p4%t;5%;
                    %?%p6%t;1%;
                    %?%p7%t;8%;
                    %?%p9%t;11%;m,
-        sgr0=\\E[0;10m, smacs=\\E[11m, smpch=\\E[11m, smso=\\E[7m,
-        smul=\\E[4m, tbc=\\E[3g, u6=\\E[%i%d;%dR, u7=\\E[6n,
-        u8=\\E[?%[;0123456789]c, u9=\\E[c, vpa=\\E[%i%p1%dd,
-.fi
-.ft R
+        sgr0=\eE[0;10m, smacs=\eE[11m, smpch=\eE[11m, smso=\eE[7m,
+        smul=\eE[4m, tbc=\eE[3g, u6=\eE[%i%d;%dR, u7=\eE[6n,
+        u8=\eE[?%[;0123456789]c, u9=\eE[c, vpa=\eE[%i%p1%dd,
+.EE
 .PP
 Entries may continue onto multiple lines by placing white space at
 the beginning of each line except the first.
@@ -129,38 +135,44 @@ or the size of particular delays, and
 string
 capabilities, which give a sequence which can be used to perform particular
 terminal operations.
-.PP
-.SS Types of Capabilities
-.PP
+.SS "Types of Capabilities"
 All capabilities have names.
 For instance, the fact that
 ANSI-standard terminals have
 .I "automatic margins"
 (i.e., an automatic return and line-feed
-when the end of a line is reached) is indicated by the capability \fBam\fR.
-Hence the description of ansi includes \fBam\fR.
-Numeric capabilities are followed by the character \*(``#\*('' and then a positive value.
-Thus \fBcols\fR, which indicates the number of columns the terminal has,
+when the end of a line is reached) is indicated by the capability \fBam\fP.
+Hence the description of ansi includes \fBam\fP.
+Numeric capabilities are followed by the character \*(``#\*(''
+and then a positive value.
+Thus \fBcols\fP, which indicates the number of columns the terminal has,
 gives the value \*(``80\*('' for ansi.
-Values for numeric capabilities may be specified in decimal, octal or hexadecimal,
-using the C programming language conventions (e.g., 255, 0377 and 0xff or 0xFF).
-.PP
-Finally, string valued capabilities, such as \fBel\fR (clear to end of line
-sequence) are given by the two-character code, an \*(``=\*('', and then a string
-ending at the next following \*(``,\*(''.
+Values for numeric capabilities may be specified in
+decimal,
+octal, or
+hexadecimal,
+using the C programming language conventions
+(e.g., 255, 0377 and 0xff or 0xFF).
+.PP
+Finally, string valued capabilities,
+such as \fBel\fP (clear to end of line sequence)
+are given by the two-character code,
+an \*(``=\*('', and then
+a string ending at the next following \*(``,\*(''.
 .PP
 A number of escape sequences are provided in the string valued capabilities
 for easy encoding of characters there:
 .bP
-Both \fB\eE\fR and \fB\ee\fR
+Both \fB\eE\fP and \fB\ee\fP
 map to an \s-1ESCAPE\s0 character,
 .bP
-\fB^x\fR maps to a control-x for any appropriate \fIx\fP, and
+\fB\*^\f(BIx\fR maps to a control-\fIx\fP for any appropriate \fIx\fP,
+and
 .bP
 the sequences
 .RS 6
 .PP
-\fB\en\fP, \fB\el\fP, \fB\er\fP, \fB\et\fP, \fB\eb\fP, \fB\ef\fP, and \fB\es\fR
+\fB\en\fP, \fB\el\fP, \fB\er\fP, \fB\et\fP, \fB\eb\fP, \fB\ef\fP, and \fB\es\fP
 .RE
 .IP
 produce
@@ -173,23 +185,23 @@ respectively.
 .PP
 X/Open Curses does not say what \*(``appropriate \fIx\fP\*('' might be.
 In practice, that is a printable ASCII graphic character.
-The special case \*(``^?\*('' is interpreted as DEL (127).
+The special case \*(``\*^?\*('' is interpreted as DEL (127).
 In all other cases, the character value is AND'd with 0x1f,
 mapping to ASCII control codes in the range 0 through 31.
 .PP
 Other escapes include
 .bP
-\fB\e^\fR for \fB^\fR,
+\fB\e\*^\fP for \fB\*^\fP,
 .bP
-\fB\e\e\fR for \fB\e\fR,
+\fB\e\e\fP for \fB\e\fP,
 .bP
-\fB\e\fR, for comma,
+\fB\e\fP, for comma,
 .bP
-\fB\e:\fR for \fB:\fR,
+\fB\e:\fP for \fB:\fP,
 .bP
-and \fB\e0\fR for null.
+and \fB\e0\fP for null.
 .IP
-\fB\e0\fR will produce \e200, which does not terminate a string but behaves
+\fB\e0\fP will produce \e200, which does not terminate a string but behaves
 as a null character on most terminals, providing CS7 is specified.
 See \fBstty\fP(1).
 .IP
@@ -197,10 +209,10 @@ The reason for this quirk is to maintain binary compatibility of the
 compiled terminfo files with other implementations,
 e.g., the SVr4 systems, which document this.
 Compiled terminfo files use null-terminated strings, with no lengths.
-Modifying this would require a new binary format, 
+Modifying this would require a new binary format,
 which would not work with other implementations.
 .PP
-Finally, characters may be given as three octal digits after a \fB\e\fR.
+Finally, characters may be given as three octal digits after a \fB\e\fP.
 .PP
 A delay in milliseconds may appear anywhere in a string capability, enclosed in
 $<..> brackets, as in \fBel\fP=\eEK$<5>,
@@ -208,7 +220,8 @@ and padding characters are supplied by \fBtputs\fP(3X)
 to provide this delay.
 .bP
 The delay must be a number with at most one decimal
-place of precision; it may be followed by suffixes \*(``*\*('' or \*(``/\*('' or both.
+place of precision;
+it may be followed by suffixes \*(``*\*('' or \*(``/\*('' or both.
 .bP
 A \*(``*\*(''
 indicates that the padding required is proportional to the number of lines
@@ -217,12 +230,12 @@ padding required.
 (In the case of insert character, the factor is still the
 number of \fIlines\fP affected.)
 .IP
-Normally, padding is advisory if the device has the \fBxon\fR
+Normally, padding is advisory if the device has the \fBxon\fP
 capability; it is used for cost computation but does not trigger delays.
 .bP
 A \*(``/\*(''
 suffix indicates that the padding is mandatory and forces a delay of the given
-number of milliseconds even on devices for which \fBxon\fR is present to
+number of milliseconds even on devices for which \fBxon\fP is present to
 indicate flow control.
 .PP
 Sometimes individual capabilities must be commented out.
@@ -232,41 +245,68 @@ For example, see the second
 in the example above.
 .br
 .ne 5
-.PP
-.SS Fetching Compiled Descriptions
-.PP
-The \fBncurses\fP library searches for terminal descriptions in several places.
-It uses only the first description found.
-The library has a compiled-in list of places to search
+.SS "Fetching Compiled Descriptions"
+Terminal descriptions in \fI\%ncurses\fP are stored in terminal
+databases.
+These databases, which are found by their pathname,
+may be configured either as directory trees or hashed databases
+(see \fBterm\fR(5)),
+.PP
+The library uses a compiled-in list of pathnames,
 which can be overridden by environment variables.
 Before starting to search,
-\fBncurses\fP eliminates duplicates in its search list.
+\fI\%ncurses\fP checks the search list,
+eliminating duplicates and pathnames where no terminal database is found.
+The \fI\%ncurses\fP library reads the first description
+which passes its consistency checks.
 .bP
-If the environment variable TERMINFO is set, it is interpreted as the pathname
-of a directory containing the compiled description you are working on.
-Only that directory is searched.
+The environment variable \fBTERMINFO\fR is checked first, for
+a terminal database containing the terminal description.
 .bP
-If TERMINFO is not set,
-\fBncurses\fR will instead look in the directory \fB$HOME/.terminfo\fR
+Next,
+\fI\%ncurses\fP looks in \fI$HOME/.terminfo\fP
 for a compiled description.
+.IP
+This is an optional feature which may be omitted entirely from
+the library, or limited to prevent accidental use by privileged applications.
 .bP
-Next, if the environment variable TERMINFO_DIRS is set,
-\fBncurses\fR will interpret the contents of that variable
-as a list of colon-separated directories (or database files) to be searched.
+Next,
+if the environment variable \fI\%TERMINFO_DIRS\fP is set,
+\fI\%ncurses\fP interprets the contents of that variable
+as a list of colon-separated pathnames of terminal databases to be searched.
 .IP
-An empty directory name (i.e., if the variable begins or ends
+An empty pathname (i.e., if the variable begins or ends
 with a colon, or contains adjacent colons)
-is interpreted as the system location \fI\*d\fR.
+is interpreted as the system location \fI\*d\fP.
 .bP
-Finally, \fBncurses\fP searches these compiled-in locations:
+Finally, \fI\%ncurses\fP searches these compiled-in locations:
 .RS
 .bP
 a list of directories (@TERMINFO_DIRS@), and
 .bP
-the system terminfo directory, \fI\*d\fR (the compiled-in default).
+the system terminfo directory, \fI\*d\fP
 .RE
-.SS Preparing Descriptions
 .PP
+The \fBTERMINFO\fP variable can contain a terminal description instead
+of the pathname of a terminal database.
+If this variable begins with \*(``hex:\*('' or \*(``b64:\*(''
+then \fI\%ncurses\fP reads a terminal description from
+hexadecimal- or base64-encoded data,
+and if that description matches the name sought, will use that.
+This encoded data can be set using the \*(``\-Q\*('' option of
+\fB@TIC@\fR or \fB@INFOCMP@\fR.
+.PP
+The preceding addresses the usual configuration of \fI\%ncurses\fP,
+which uses terminal descriptions prepared in \fIterminfo\fP format.
+While \fItermcap\fP is less expressive,
+\fI\%ncurses\fP can also be configured to read \fItermcap\fP
+descriptions.
+In that configuration,
+it checks the \fI\%TERMCAP\fP and \fI\%TERMPATH\fP variables
+(for content and search path,
+respectively)
+after the system terminal database.
+.SS "Preparing Descriptions"
 We now outline how to prepare descriptions of terminals.
 The most effective way to prepare a terminal description is by imitating
 the description of a similar terminal in
@@ -287,20 +327,18 @@ delete 16 or so lines from the middle of the screen, then hit the \*(``u\*(''
 key several times quickly.
 If the terminal messes up, more padding is usually needed.
 A similar test can be used for insert character.
-.PP
-.SS Basic Capabilities
-.PP
+.SS "Basic Capabilities"
 The number of columns on each line for the terminal is given by the
-\fBcols\fR numeric capability.
+\fBcols\fP numeric capability.
 If the terminal is a \s-1CRT\s0, then the
-number of lines on the screen is given by the \fBlines\fR capability.
+number of lines on the screen is given by the \fBlines\fP capability.
 If the terminal wraps around to the beginning of the next line when
-it reaches the right margin, then it should have the \fBam\fR capability.
+it reaches the right margin, then it should have the \fBam\fP capability.
 If the terminal can clear its screen, leaving the cursor in the home
-position, then this is given by the \fBclear\fR string capability.
+position, then this is given by the \fBclear\fP string capability.
 If the terminal overstrikes
 (rather than clearing a position when a character is struck over)
-then it should have the \fBos\fR capability.
+then it should have the \fBos\fP capability.
 If the terminal is a printing terminal, with no soft copy unit,
 give it both
 .B hc
@@ -365,7 +403,7 @@ and
 except that they take one parameter, and scroll that many lines.
 They are also undefined except at the appropriate edge of the screen.
 .PP
-The \fBam\fR capability tells whether the cursor sticks at the right
+The \fBam\fP capability tells whether the cursor sticks at the right
 edge of the screen when text is output, but this does not necessarily
 apply to a
 .B cuf1
@@ -382,7 +420,7 @@ This is useful for drawing a box around the edge of the screen, for example.
 If the terminal has switch selectable automatic margins,
 the
 .I terminfo
-file usually assumes that this is on; i.e., \fBam\fR.
+file usually assumes that this is on; i.e., \fBam\fP.
 If the terminal has a command which moves to the first column of the next
 line, that command can be given as
 .B nel
@@ -396,38 +434,31 @@ it may still be possible to craft a working
 .B nel
 out of one or both of them.
 .PP
-These capabilities suffice to describe hard-copy and \*(``glass-tty\*('' terminals.
+These capabilities suffice to describe
+hard-copy and \*(``glass-tty\*('' terminals.
 Thus the model 33 teletype is described as
 .PP
-.DT
-.nf
-.ft CW
+.EX
 .\".in -2
 \s-133\||\|tty33\||\|tty\||\|model 33 teletype,
-        bel=^G, cols#72, cr=^M, cud1=^J, hc, ind=^J, os,\s+1
+        bel=\*^G, cols#72, cr=\*^M, cud1=\*^J, hc, ind=\*^J, os,\s+1
 .\".in +2
-.ft R
-.fi
+.EE
 .PP
 while the Lear Siegler \s-1ADM-3\s0 is described as
 .PP
-.DT
-.nf
-.ft CW
+.EX
 .\".in -2
 \s-1adm3\||\|3\||\|lsi adm3,
-        am, bel=^G, clear=^Z, cols#80, cr=^M, cub1=^H, cud1=^J,
-        ind=^J, lines#24,\s+1
+        am, bel=\*^G, clear=\*^Z, cols#80, cr=\*^M, cub1=\*^H, cud1=\*^J,
+        ind=\*^J, lines#24,\s+1
 .\".in +2
-.ft R
-.fi
-.PP
-.SS Parameterized Strings
-.PP
+.EE
+.SS "Parameterized Strings"
 Cursor addressing and other strings requiring parameters
 in the terminal are described by a
 parameterized string capability,
-with \fIprintf\fP-like escapes such as \fI%x\fR in it.
+with \fIprintf\fP-like escapes such as \fI%x\fP in it.
 For example, to address the cursor, the
 .B cup
 capability is given, using two parameters:
@@ -442,53 +473,93 @@ The parameter mechanism uses a stack and special \fB%\fP codes
 to manipulate it.
 Typically a sequence will push one of the
 parameters onto the stack and then print it in some format.
-Print (e.g., "%d") is a special case.
-Other operations, including "%t" pop their operand from the stack.
+Print (e.g., \*(``%d\*('') is a special case.
+Other operations, including \*(``%t\*('' pop their operand from the stack.
 It is noted that more complex operations are often necessary,
 e.g., in the \fBsgr\fP string.
 .PP
-The \fB%\fR encodings have the following meanings:
-.PP
+The \fB%\fP encodings have the following meanings:
 .TP 5
 \fB%%\fP
 outputs \*(``%\*(''
 .TP
-\fB%\fP\fI[[\fP:\fI]flags][width[.precision]][\fP\fBdoxXs\fP\fI]\fP
+\fB%\fI[[\fR:\fI]flags][width[.precision]][\fBdoxXs\fI]\fR
 as in \fBprintf\fP(3), flags are \fI[\-+#]\fP and \fIspace\fP.
 Use a \*(``:\*('' to allow the next character to be a \*(``\-\*('' flag,
 avoiding interpreting \*(``%\-\*('' as an operator.
 .TP
-\f(CW%c\fP
+\fB%c\fP
 print \fIpop()\fP like %c in \fBprintf\fP
 .TP
 \fB%s\fP
 print \fIpop()\fP like %s in \fBprintf\fP
 .TP
-\fB%p\fP\fI[1\-9]\fP
+\fB%p\fI[1\-9]\fR
 push \fIi\fP'th parameter
 .TP
-\fB%P\fP\fI[a\-z]\fP
+\fB%P\fI[a\-z]\fR
 set dynamic variable \fI[a\-z]\fP to \fIpop()\fP
 .TP
-\fB%g\fP\fI[a\-z]/\fP
+\fB%g\fI[a\-z]\fR
 get dynamic variable \fI[a\-z]\fP and push it
 .TP
-\fB%P\fP\fI[A\-Z]\fP
+\fB%P\fI[A\-Z]\fR
 set static variable \fI[a\-z]\fP to \fIpop()\fP
 .TP
-\fB%g\fP\fI[A\-Z]\fP
+\fB%g\fI[A\-Z]\fR
 get static variable \fI[a\-z]\fP and push it
 .IP
 The terms \*(``static\*('' and \*(``dynamic\*('' are misleading.
 Historically, these are simply two different sets of variables,
 whose values are not reset between calls to \fBtparm\fP(3X).
 However, that fact is not documented in other implementations.
-Relying on it will adversely impact portability to other implementations.
+Relying on it will adversely impact portability to other implementations:
+.RS
+.bP
+SVr2 curses supported \fIdynamic\fP variables.
+Those are set only by a \fB%P\fP operator.
+A \fB%g\fP for a given variable without first setting it with \fB%P\fP
+will give unpredictable results, because dynamic variables are
+an uninitialized local array on the stack in the \fBtparm\fP function.
+.bP
+SVr3.2 curses supported \fIstatic\fP variables.
+Those are an array in the \fI\%TERMINAL\fP
+structure (declared in \fBterm.h\fP),
+and are zeroed automatically when the \fBsetupterm\fP function
+allocates the data.
+.bP
+SVr4 curses made no further improvements
+to the \fIdynamic/static\fP variable feature.
+.bP
+Solaris XPG4 curses does not distinguish between \fIdynamic\fP and
+\fIstatic\fP variables.
+They are the same.
+Like SVr4 curses, XPG4 curses does not initialize these explicitly.
+.bP
+Before version 6.3,
+\fI\%ncurses\fP stores both \fIdynamic\fP and \fIstatic\fP
+variables in persistent storage, initialized to zeros.
+.bP
+Beginning with version 6.3,
+\fI\%ncurses\fP stores \fIstatic\fP and \fIdynamic\fP
+variables in the same manner as SVr4.
+.RS
+.bP
+Unlike other implementations, \fI\%ncurses\fP zeros dynamic variables
+before the first \fB%g\fP or \fB%P\fP operator.
+.bP
+Like SVr2,
+the scope of dynamic variables in \fI\%ncurses\fP
+is within the current call to
+\fBtparm\fP.
+Use static variables if persistent storage is needed.
+.RE
+.RE
 .TP
-\fB%'\fP\fIc\fP\fB'\fP
+\fB%\*'\fIc\fB\*'\fR
 char constant \fIc\fP
 .TP
-\fB%{\fP\fInn\fP\fB}\fP
+\fB%{\fInn\fB}\fR
 integer constant \fInn\fP
 .TP
 \fB%l\fP
@@ -497,7 +568,7 @@ push strlen(pop)
 \fB%+\fP, \fB%\-\fP, \fB%*\fP, \fB%/\fP, \fB%m\fP
 arithmetic (%m is \fImod\fP): \fIpush(pop() op pop())\fP
 .TP
-\fB%&\fP, \fB%|\fP, \fB%^\fP
+\fB%&\fP, \fB%|\fP, \fB%\*^\fP
 bit operations (AND, OR and exclusive-OR): \fIpush(pop() op pop())\fP
 .TP
 \fB%=\fP, \fB%>\fP, \fB%<\fP
@@ -506,7 +577,7 @@ logical operations: \fIpush(pop() op pop())\fP
 \fB%A\fP, \fB%O\fP
 logical AND and OR operations (for conditionals)
 .TP
-\fB%!\fP, \fB%~\fP
+\fB%!\fP, \fB%\*~\fP
 unary operations (logical and bit complement): \fIpush(op pop())\fP
 .TP
 \fB%i\fP
@@ -533,45 +604,52 @@ on one line.
 The \fB\-f\fP option splits the string into lines with the parts indented.
 .PP
 Binary operations are in postfix form with the operands in the usual order.
-That is, to get x\-5 one would use "%gx%{5}%-".
+That is, to get x\-5 one would use \*(``%gx%{5}%\-\*(''.
 \fB%P\fP and \fB%g\fP variables are
 persistent across escape-string evaluations.
 .PP
 Consider the HP2645, which, to get to row 3 and column 12, needs
 to be sent \eE&a12c03Y padded for 6 milliseconds.
-Note that the order
-of the rows and columns is inverted here, and that the row and column
-are printed as two digits.
-Thus its \fBcup\fR capability is \*(``cup=6\eE&%p2%2dc%p1%2dY\*(''.
+The order of the rows and columns is inverted here,
+and the row and column are printed as two digits.
+The corresponding terminal description is expressed thus:
+.RS
+cup=\eE&a%p2%dc%p1%dY$<6>,
+.RE
 .PP
 The Microterm \s-1ACT-IV\s0 needs the current row and column sent
-preceded by a \fB^T\fR, with the row and column simply encoded in binary,
-\*(``cup=^T%p1%c%p2%c\*(''.
+preceded by a \fB\*^T\fP, with the row and column simply encoded in binary,
+.RS
+cup=\*^T%p1%c%p2%c
+.RE
+.PP
 Terminals which use \*(``%c\*('' need to be able to
-backspace the cursor (\fBcub1\fR),
-and to move the cursor up one line on the screen (\fBcuu1\fR).
-This is necessary because it is not always safe to transmit \fB\en\fR
-\fB^D\fR and \fB\er\fR, as the system may change or discard them.
+backspace the cursor (\fBcub1\fP),
+and to move the cursor up one line on the screen (\fBcuu1\fP).
+This is necessary because it is not always safe to transmit \fB\en\fP
+\fB\*^D\fP and \fB\er\fP, as the system may change or discard them.
 (The library routines dealing with terminfo set tty modes so that
 tabs are never expanded, so \et is safe to send.
 This turns out to be essential for the Ann Arbor 4080.)
 .PP
 A final example is the \s-1LSI ADM\s0-3a, which uses row and column
-offset by a blank character, thus \*(``cup=\eE=%p1%' '%+%c%p2%' '%+%c\*(''.
+offset by a blank character, thus
+.RS
+cup=\eE=%p1%\*' \*'%+%c%p2%\*' \*'%+%c
+.RE
+.PP
 After sending \*(``\eE=\*('', this pushes the first parameter, pushes the
 ASCII value for a space (32), adds them (pushing the sum on the stack
 in place of the two previous values) and outputs that value as a character.
 Then the same is done for the second parameter.
 More complex arithmetic is possible using the stack.
-.PP
-.SS Cursor Motions
-.PP
+.SS "Cursor Motions"
 If the terminal has a fast way to home the cursor
 (to very upper left corner of screen) then this can be given as
-\fBhome\fR; similarly a fast way of getting to the lower left-hand corner
-can be given as \fBll\fR; this may involve going up with \fBcuu1\fR
+\fBhome\fP; similarly a fast way of getting to the lower left-hand corner
+can be given as \fBll\fP; this may involve going up with \fBcuu1\fP
 from the home position,
-but a program should never do this itself (unless \fBll\fR does) because it
+but a program should never do this itself (unless \fBll\fP does) because it
 can make no assumption about the effect of moving up from the home position.
 Note that the home position is the same as addressing to (0,0):
 to the top left corner of the screen, not of memory.
@@ -603,7 +681,8 @@ such as the \s-1TEKTRONIX\s+1 4025.
 .PP
 If the terminal needs to be in a special mode when running
 a program that uses these capabilities,
-the codes to enter and exit this mode can be given as \fBsmcup\fR and \fBrmcup\fR.
+the codes to enter and exit this mode can be given
+as \fBsmcup\fP and \fBrmcup\fP.
 This arises, for example, from terminals like the Concept with more than
 one page of memory.
 If the terminal has only memory relative cursor addressing and not screen
@@ -616,30 +695,152 @@ sets the command character to be the one used by terminfo.
 If the \fBsmcup\fP sequence will not restore the screen after an
 \fBrmcup\fP sequence is output (to the state prior to outputting
 \fBrmcup\fP), specify \fBnrrmc\fP.
+.SS Margins
+SVr4 (and X/Open Curses)
+list several string capabilities for setting margins.
+Two were intended for use with terminals,
+and another six were intended for use with printers.
+.bP
+The two terminal capabilities assume that the terminal may have
+the capability of setting the left and/or right margin at the current
+cursor column position.
+.bP
+The printer capabilities assume that the printer may have
+two types of capability:
+.RS
+.bP
+the ability to set a top and/or bottom margin using the current
+line position, and
+.bP
+parameterized capabilities for setting the top, bottom, left, right margins
+given the number of rows or columns.
+.RE
+.PP
+In practice, the categorization into \*(``terminal\*('' and \*(``printer\*(''
+is not suitable:
+.bP
+The AT&T SVr4 terminal database uses \fBsmgl\fP four times,
+for AT&T hardware.
+.IP
+Three of the four are printers.
+They lack the ability to set left/right margins by specifying the column.
+.bP
+Other (non-AT&T) terminals may support margins
+but using different assumptions from AT&T.
+.IP
+For instance, the DEC VT420 supports left/right margins,
+but only using a column parameter.
+As an added complication, the VT420 uses two settings to fully enable
+left/right margins (left/right margin mode, and origin mode).
+The former enables the margins, which causes printed text
+to wrap within margins, but the latter is needed to prevent
+cursor-addressing outside those margins.
+.bP
+Both DEC VT420 left/right margins are set with a single control sequence.
+If either is omitted, the corresponding margin is set to the left or
+right edge of the display (rather than leaving the margin unmodified).
 .PP
-.SS Area Clears
+These are the margin-related capabilities:
 .PP
+.TS
+center;
+lb lb
+lb l .
+Name	Description
+_
+smgl	Set left margin at current column
+smgr	Set right margin at current column
+smgb	Set bottom margin at current line
+smgt	Set top margin at current line
+smgbp	Set bottom margin at line \fIN\fP
+smglp	Set left margin at column \fIN\fP
+smgrp	Set right margin at column \fIN\fP
+smgtp	Set top margin at line \fIN\fP
+smglr	Set both left and right margins to \fIL\fP and \fIR\fP
+smgtb	Set both top and bottom margins to \fIT\fP and \fIB\fP
+.TE
+.PP
+When writing an application that
+uses these string capabilities,
+the pairs should be first checked to see
+if each capability in the pair is set or only one is set:
+.bP
+If both \fBsmglp\fP and \fBsmgrp\fP are set,
+each is used with a single argument, \fIN\fP,
+that gives the column number of the left and right margin, respectively.
+.bP
+If both \fBsmgtp\fP and \fBsmgbp\fP are set,
+each is used to set the top and bottom margin,
+respectively:
+.RS 4
+.bP
+\fBsmgtp\fP is used with a single argument, \fIN\fP,
+the line number of the top margin.
+.bP
+\fBsmgbp\fP is used with two arguments, \fIN\fP and \fIM\fP,
+that give the line number of the bottom margin,
+the first counting from the top of the
+page and the second counting from the bottom.
+This accommodates the two styles of specifying
+the bottom margin in different manufacturers' printers.
+.RE
+.IP
+When designing a terminfo entry for a
+printer that has a settable bottom margin,
+only the first or second argument should be used, depending on the printer.
+When developing an application that uses \fBsmgbp\fP to set the bottom margin,
+both arguments must be given.
+.PP
+Conversely, when only one capability in the pair is set:
+.bP
+If only one of \fBsmglp\fP and \fBsmgrp\fP is set,
+then it is used with two arguments,
+the column number of the left and right margins, in that order.
+.bP
+Likewise, if only one of \fBsmgtp\fP and \fBsmgbp\fP is set, then it
+is used with two arguments that give the top and bottom margins,
+in that order, counting from the top of the page.
+.IP
+When designing a terminfo entry for a printer that requires setting both
+left and right or top and bottom margins simultaneously,
+only one capability in the pairs
+\fBsmglp\fP and \fBsmgrp\fP or
+\fBsmgtp\fP and \fBsmgbp\fP should be defined,
+leaving the other unset.
+.PP
+Except for very old terminal descriptions, e.g., those developed for SVr4,
+the scheme just described should be considered obsolete.
+An improved set of capabilities was added late in the SVr4 releases
+(\fBsmglr\fP and \fBsmgtb\fP),
+which explicitly use two parameters for setting the left/right or top/bottom
+margins.
+.PP
+When setting margins, the line- and column-values are zero-based.
+.PP
+The \fBmgc\fP string capability should be defined.
+Applications such as \fBtabs\fP(1) rely upon this to reset all margins.
+.\"
+.SS "Area Clears"
 If the terminal can clear from the current position to the end of the
-line, leaving the cursor where it is, this should be given as \fBel\fR.
+line, leaving the cursor where it is, this should be given as \fBel\fP.
 If the terminal can clear from the beginning of the line to the current
 position inclusive, leaving
 the cursor where it is, this should be given as \fBel1\fP.
 If the terminal can clear from the current position to the end of the
-display, then this should be given as \fBed\fR.
-\fBEd\fR is only defined from the first column of a line.
+display, then this should be given as \fBed\fP.
+\fBEd\fP is only defined from the first column of a line.
 (Thus, it can be simulated by a request to delete a large number of lines,
 if a true
 .B ed
 is not available.)
-.PP
-.SS Insert/delete line and vertical motions
-.PP
+.\"
+.SS "Insert/Delete Line and Vertical Motions"
 If the terminal can open a new blank line before the line where the cursor
-is, this should be given as \fBil1\fR; this is done only from the first
+is, this should be given as \fBil1\fP; this is done only from the first
 position of a line.
 The cursor must then appear on the newly blank line.
 If the terminal can delete the line which the cursor is on, then this
-should be given as \fBdl1\fR; this is done only from the first position on
+should be given as \fBdl1\fP; this is done only from the first position on
 the line to be deleted.
 Versions of
 .B il1
@@ -666,12 +867,12 @@ and
 .B rc
 (save and restore cursor) commands may be useful for ensuring that
 your synthesized insert/delete string does not move the cursor.
-(Note that the \fBncurses\fR(3X) library does this synthesis
+(Note that the \fB\%ncurses\fP(3X) library does this synthesis
 automatically, so you need not compose insert/delete strings for
-an entry with \fBcsr\fR).
+an entry with \fBcsr\fP).
 .PP
 Yet another way to construct insert and delete might be to use a combination of
-index with the memory-lock feature found on some terminals (like the HP\-700/90
+index with the memory-lock feature found on some terminals (like the HP-700/90
 series, which however also has insert/delete).
 .PP
 Inserting lines at the top or bottom of the screen can also be
@@ -682,20 +883,20 @@ or
 on many terminals without a true insert/delete line,
 and is often faster even on terminals with those features.
 .PP
-The boolean \fBnon_dest_scroll_region\fR should be set if each scrolling
+The Boolean \fBnon_dest_scroll_region\fP should be set if each scrolling
 window is effectively a view port on a screen-sized canvas.
 To test for
 this capability, create a scrolling region in the middle of the screen,
 write something to the bottom line, move the cursor to the top of the region,
-and do \fBri\fR followed by \fBdl1\fR or \fBind\fR.
+and do \fBri\fP followed by \fBdl1\fP or \fBind\fP.
 If the data scrolled
-off the bottom of the region by the \fBri\fR re-appears, then scrolling
+off the bottom of the region by the \fBri\fP re-appears, then scrolling
 is non-destructive.
-System V and XSI Curses expect that \fBind\fR, \fBri\fR,
-\fBindn\fR, and \fBrin\fR will simulate destructive scrolling; their
-documentation cautions you not to define \fBcsr\fR unless this is true.
-This \fBcurses\fR implementation is more liberal and will do explicit erases
-after scrolling if \fBndsrc\fR is defined.
+System V and X/Open Curses expect that \fBind\fP, \fBri\fP,
+\fBindn\fP, and \fBrin\fP will simulate destructive scrolling; their
+documentation cautions you not to define \fBcsr\fP unless this is true.
+This \fBcurses\fP implementation is more liberal and will do explicit erases
+after scrolling if \fBndsrc\fP is defined.
 .PP
 If the terminal has the ability to define a window as part of
 memory, which all commands affect,
@@ -705,17 +906,15 @@ The four parameters are the starting and ending lines in memory
 and the starting and ending columns in memory, in that order.
 .PP
 If the terminal can retain display memory above, then the
-\fBda\fR capability should be given; if display memory can be retained
-below, then \fBdb\fR should be given.
+\fBda\fP capability should be given; if display memory can be retained
+below, then \fBdb\fP should be given.
 These indicate
 that deleting a line or scrolling may bring non-blank lines up from below
-or that scrolling back with \fBri\fR may bring down non-blank lines.
-.PP
-.SS Insert/Delete Character
-.PP
+or that scrolling back with \fBri\fP may bring down non-blank lines.
+.SS "Insert/Delete Character"
 There are two basic kinds of intelligent terminals with respect to
 insert/delete character which can be described using
-.I terminfo.
+.IR terminfo .
 The most common insert/delete character operations affect only the characters
 on the current line and shift characters off the end of the line rigidly.
 Other terminals, such as the Concept 100 and the Perkin Elmer Owl, make
@@ -736,7 +935,7 @@ not distinguish between blanks and untyped positions.
 If the \*(``abc\*(''
 shifts over to the \*(``def\*('' which then move together around the end of the
 current line and onto the next as you insert, you have the second type of
-terminal, and should give the capability \fBin\fR, which stands for
+terminal, and should give the capability \fBin\fP, which stands for
 \*(``insert null\*(''.
 .PP
 While these are two logically separate attributes (one line versus multi-line
@@ -745,34 +944,34 @@ terminals whose insert mode cannot be described with the single attribute.
 .PP
 Terminfo can describe both terminals which have an insert mode, and terminals
 which send a simple sequence to open a blank position on the current line.
-Give as \fBsmir\fR the sequence to get into insert mode.
-Give as \fBrmir\fR the sequence to leave insert mode.
-Now give as \fBich1\fR any sequence needed to be sent just before sending
+Give as \fBsmir\fP the sequence to get into insert mode.
+Give as \fBrmir\fP the sequence to leave insert mode.
+Now give as \fBich1\fP any sequence needed to be sent just before sending
 the character to be inserted.
 Most terminals with a true insert mode
-will not give \fBich1\fR; terminals which send a sequence to open a screen
+will not give \fBich1\fP; terminals which send a sequence to open a screen
 position should give it here.
 .PP
-If your terminal has both, insert mode is usually preferable to \fBich1\fR.
+If your terminal has both, insert mode is usually preferable to \fBich1\fP.
 Technically, you should not give both unless the terminal actually requires
 both to be used in combination.
 Accordingly, some non-curses applications get
 confused if both are present; the symptom is doubled characters in an update
 using insert.
-This requirement is now rare; most \fBich\fR sequences do not
-require previous smir, and most smir insert modes do not require \fBich1\fR
+This requirement is now rare; most \fBich\fP sequences do not
+require previous smir, and most smir insert modes do not require \fBich1\fP
 before each character.
-Therefore, the new \fBcurses\fR actually assumes this
-is the case and uses either \fBrmir\fR/\fBsmir\fR or \fBich\fR/\fBich1\fR as
+Therefore, the new \fBcurses\fP actually assumes this
+is the case and uses either \fBrmir\fP/\fBsmir\fP or \fBich\fP/\fBich1\fP as
 appropriate (but not both).
 If you have to write an entry to be used under
 new curses for a terminal old enough to need both, include the
-\fBrmir\fR/\fBsmir\fR sequences in \fBich1\fR.
+\fBrmir\fP/\fBsmir\fP sequences in \fBich1\fP.
 .PP
 If post insert padding is needed, give this as a number of milliseconds
-in \fBip\fR (a string option).
+in \fBip\fP (a string option).
 Any other sequence which may need to be
-sent after an insert of a single character may also be given in \fBip\fR.
+sent after an insert of a single character may also be given in \fBip\fP.
 If your terminal needs both to be placed into an \*(``insert mode\*('' and
 a special code to precede each inserted character, then both
 .BR smir / rmir
@@ -795,11 +994,11 @@ It is occasionally necessary to move around while in insert mode
 to delete characters on the same line (e.g., if there is a tab after
 the insertion position).
 If your terminal allows motion while in
-insert mode you can give the capability \fBmir\fR to speed up inserting
+insert mode you can give the capability \fBmir\fP to speed up inserting
 in this case.
-Omitting \fBmir\fR will affect only speed.
+Omitting \fBmir\fP will affect only speed.
 Some terminals
-(notably Datamedia's) must not have \fBmir\fR because of the way their
+(notably Datamedia's) must not have \fBmir\fP because of the way their
 insert mode works.
 .PP
 Finally, you can specify
@@ -809,8 +1008,8 @@ to delete a single character,
 with one parameter,
 .IR n ,
 to delete
-.I n characters,
-and delete mode by giving \fBsmdc\fR and \fBrmdc\fR
+.IR n "characters,"
+and delete mode by giving \fBsmdc\fP and \fBrmdc\fP
 to enter and exit delete mode (any mode the terminal needs to be placed
 in for
 .B dch1
@@ -824,30 +1023,28 @@ blanks without moving the cursor)
 can be given as
 .B ech
 with one parameter.
-.PP
 .SS "Highlighting, Underlining, and Visible Bells"
-.PP
 If your terminal has one or more kinds of display attributes,
 these can be represented in a number of different ways.
 You should choose one display form as
-\f2standout mode\fR,
+\f2standout mode\fP,
 representing a good, high contrast, easy-on-the-eyes,
 format for highlighting error messages and other attention getters.
 (If you have a choice, reverse video plus half-bright is good,
 or reverse video alone.)
 The sequences to enter and exit standout mode
-are given as \fBsmso\fR and \fBrmso\fR, respectively.
+are given as \fBsmso\fP and \fBrmso\fP, respectively.
 If the code to change into or out of standout
 mode leaves one or even two blank spaces on the screen,
 as the TVI 912 and Teleray 1061 do,
-then \fBxmc\fR should be given to tell how many spaces are left.
+then \fBxmc\fP should be given to tell how many spaces are left.
 .PP
-Codes to begin underlining and end underlining can be given as \fBsmul\fR
-and \fBrmul\fR respectively.
+Codes to begin underlining and end underlining can be given as \fBsmul\fP
+and \fBrmul\fP respectively.
 If the terminal has a code to underline the current character and move
 the cursor one space to the right,
 such as the Microterm Mime,
-this can be given as \fBuc\fR.
+this can be given as \fBuc\fP.
 .PP
 Other capabilities to enter various highlighting modes include
 .B blink
@@ -878,7 +1075,8 @@ this should be given as
 .B sgr
 (set attributes),
 taking 9 parameters.
-Each parameter is either 0 or nonzero, as the corresponding attribute is on or off.
+Each parameter is either zero (0) or nonzero,
+as the corresponding attribute is on or off.
 The 9 parameters are, in order:
 standout, underline, reverse, blink, dim, bold, blank, protect, alternate
 character set.
@@ -890,21 +1088,20 @@ For example, the DEC vt220 supports most of the modes:
 .PP
 .TS
 center;
-l l l
-l l l
-lw18 lw14 lw18.
-\fBtparm parameter	attribute	escape sequence\fP
-
-none	none	\\E[0m
-p1	standout	\\E[0;1;7m
-p2	underline	\\E[0;4m
-p3	reverse	\\E[0;7m
-p4	blink	\\E[0;5m
+lb lb lb
+l  l  l .
+tparm Parameter	Attribute	Escape Sequence
+_
+none	none	\eE[0m
+p1	standout	\eE[0;1;7m
+p2	underline	\eE[0;4m
+p3	reverse	\eE[0;7m
+p4	blink	\eE[0;5m
 p5	dim	not available
-p6	bold	\\E[0;1m
-p7	invis	\\E[0;8m
+p6	bold	\eE[0;1m
+p7	invis	\eE[0;8m
 p8	protect	not used
-p9	altcharset	^O (off) ^N (on)
+p9	altcharset	\*^O (off) \*^N (on)
 .TE
 .PP
 We begin each escape sequence by turning off any existing modes, since
@@ -913,9 +1110,9 @@ Standout is set up to be the combination of reverse and bold.
 The vt220 terminal has a protect mode,
 though it is not commonly used in sgr
 because it protects characters on the screen from the host's erasures.
-The altcharset mode also is different in that it is either ^O or ^N,
+The altcharset mode also is different in that it is either \*^O or \*^N,
 depending on whether it is off or on.
-If all modes are turned on, the resulting sequence is \\E[0;1;4;5;7;8m^N.
+If all modes are turned on, the resulting sequence is \eE[0;1;4;5;7;8m\*^N.
 .PP
 Some sequences are common to different modes.
 For example, ;7 is output when either p1 or p3 is true, that is, if
@@ -926,31 +1123,26 @@ Writing out the above sequences, along with their dependencies yields
 .ne 11
 .TS
 center;
-l l l
-l l l
-lw18 lw14 lw18.
-\fBsequence	when to output	terminfo translation\fP
-
-.ft CW
-\\E[0	always	\\E[0
+lb lb lb
+l  l  l .
+Sequence	When to Output	terminfo Translation
+_
+\eE[0	always	\eE[0
 ;1	if p1 or p6	%?%p1%p6%|%t;1%;
 ;4	if p2	%?%p2%|%t;4%;
 ;5	if p4	%?%p4%|%t;5%;
 ;7	if p1 or p3	%?%p1%p3%|%t;7%;
 ;8	if p7	%?%p7%|%t;8%;
 m	always	m
-^N or ^O	if p9 ^N, else ^O	%?%p9%t^N%e^O%;
-.ft R
+\*^N or \*^O	if p9 \*^N, else \*^O	%?%p9%t\*^N%e\*^O%;
 .TE
 .PP
 Putting this all together into the sgr sequence gives:
 .PP
-.ft CW
-.nf
-    sgr=\\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p4%t;5%;
-        %?%p1%p3%|%t;7%;%?%p7%t;8%;m%?%p9%t\\016%e\\017%;,
-.fi
-.ft R
+.EX
+    sgr=\eE[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p4%t;5%;
+        %?%p1%p3%|%t;7%;%?%p7%t;8%;m%?%p9%t\e016%e\e017%;,
+.EE
 .PP
 Remember that if you specify sgr, you must also specify sgr0.
 Also, some implementations rely on sgr being given if sgr0 is,
@@ -975,7 +1167,7 @@ capability, asserting that it is safe to move in standout mode, is present.
 .PP
 If the terminal has
 a way of flashing the screen to indicate an error quietly (a bell replacement)
-then this can be given as \fBflash\fR; it must not move the cursor.
+then this can be given as \fBflash\fP; it must not move the cursor.
 .PP
 If the cursor needs to be made more visible than normal when it is
 not on the bottom line (to make, for example, a non-blinking underline into an
@@ -991,30 +1183,28 @@ should be given which undoes the effects of both of these modes.
 If your terminal correctly generates underlined characters
 (with no special codes needed)
 even though it does not overstrike,
-then you should give the capability \fBul\fR.
+then you should give the capability \fBul\fP.
 If a character overstriking another leaves both characters on the screen,
 specify the capability \fBos\fP.
 If overstrikes are erasable with a blank,
-then this should be indicated by giving \fBeo\fR.
-.PP
-.SS Keypad and Function Keys
-.PP
+then this should be indicated by giving \fBeo\fP.
+.SS "Keypad and Function Keys"
 If the terminal has a keypad that transmits codes when the keys are pressed,
 this information can be given.
 Note that it is not possible to handle
 terminals where the keypad only works in local (this applies, for example,
 to the unshifted HP 2621 keys).
 If the keypad can be set to transmit or not transmit,
-give these codes as \fBsmkx\fR and \fBrmkx\fR.
+give these codes as \fBsmkx\fP and \fBrmkx\fP.
 Otherwise the keypad is assumed to always transmit.
 .PP
 The codes sent by the left arrow, right arrow, up arrow, down arrow,
 and home keys can be given as
-\fBkcub1, kcuf1, kcuu1, kcud1, \fRand\fB khome\fR respectively.
+\fBkcub1, kcuf1, kcuu1, kcud1, \fRand\fB khome\fP respectively.
 If there are function keys such as f0, f1, ..., f10, the codes they send
-can be given as \fBkf0, kf1, ..., kf10\fR.
+can be given as \fBkf0, kf1, ..., kf10\fP.
 If these keys have labels other than the default f0 through f10, the labels
-can be given as \fBlf0, lf1, ..., lf10\fR.
+can be given as \fBlf0, lf1, ..., lf10\fP.
 .PP
 The codes transmitted by certain other special keys can be given:
 .bP
@@ -1105,9 +1295,7 @@ If there are commands to turn the labels on and off,
 give them in \fBsmln\fP and \fBrmln\fP.
 \fBsmln\fP is normally output after one or more pln
 sequences to make sure that the change becomes visible.
-.PP
-.SS Tabs and Initialization
-.PP
+.SS "Tabs and Initialization"
 A few capabilities are used only for tabs:
 .bP
 If the terminal has hardware tabs, the command to advance to the next
@@ -1153,7 +1341,7 @@ initialization strings for the terminal,
 .BR iprog ,
 the path name of a program to be run to initialize the terminal,
 .bP
-and \fBif\fR, the name of a file containing long initialization strings.
+and \fBif\fP, the name of a file containing long initialization strings.
 .PP
 These strings are expected to set the terminal into modes consistent
 with the rest of the terminfo description.
@@ -1238,7 +1426,7 @@ The \fB@RESET@\fP program writes strings including
 .BR iprog ,
 etc., in the same order as the
 .I init
-program, using 
+program, using
 .BR rs1 ,
 etc., instead of
 .BR is1 ,
@@ -1291,8 +1479,7 @@ use the
 \fBhts\fP (\fBset_tab\fP) capabilities directly
 only when the \fBit\fP (\fBinit_tabs\fP) capability
 is set to a value other than \fIeight\fP.
-.SS Delays and Padding
-.PP
+.SS "Delays and Padding"
 Many older and slower terminals do not support either XON/XOFF or DTR
 handshaking, including hard copy terminals and some very archaic CRTs
 (including, for example, DEC VT100s).
@@ -1300,7 +1487,7 @@ These may require padding characters
 after certain cursor motions and screen changes.
 .PP
 If the terminal uses xon/xoff handshaking for flow control (that is,
-it automatically emits ^S back to the host when its input buffers are
+it automatically emits \*^S back to the host when its input buffers are
 close to full), set
 .BR xon .
 This capability suppresses the emission of padding.
@@ -1310,101 +1497,98 @@ Padding information should still be included so that routines can
 make better decisions about relative costs, but actual pad characters will
 not be transmitted.
 .PP
-If \fBpb\fR (padding baud rate) is given, padding is suppressed at baud rates
-below the value of \fBpb\fR.
+If \fBpb\fP (padding baud rate) is given, padding is suppressed at baud rates
+below the value of \fBpb\fP.
 If the entry has no padding baud rate, then
-whether padding is emitted or not is completely controlled by \fBxon\fR.
+whether padding is emitted or not is completely controlled by \fBxon\fP.
 .PP
 If the terminal requires other than a null (zero) character as a pad,
-then this can be given as \fBpad\fR.
+then this can be given as \fBpad\fP.
 Only the first character of the
 .B pad
 string is used.
-.PP
-.SS Status Lines
+.SS "Status Lines"
 Some terminals have an extra \*(``status line\*('' which is not normally used by
-software (and thus not counted in the terminal's \fBlines\fR capability).
+software (and thus not counted in the terminal's \fBlines\fP capability).
 .PP
 The simplest case is a status line which is cursor-addressable but not
 part of the main scrolling region on the screen; the Heathkit H19 has
 a status line of this kind, as would a 24-line VT100 with a 23-line
 scrolling region set up on initialization.
 This situation is indicated
-by the \fBhs\fR capability.
+by the \fBhs\fP capability.
 .PP
 Some terminals with status lines need special sequences to access the
 status line.
 These may be expressed as a string with single parameter
-\fBtsl\fR which takes the cursor to a given zero-origin column on the
+\fBtsl\fP which takes the cursor to a given zero-origin column on the
 status line.
-The capability \fBfsl\fR must return to the main-screen
-cursor positions before the last \fBtsl\fR.
+The capability \fBfsl\fP must return to the main-screen
+cursor positions before the last \fBtsl\fP.
 You may need to embed the
-string values of \fBsc\fR (save cursor) and \fBrc\fR (restore cursor)
-in \fBtsl\fR and \fBfsl\fR to accomplish this.
+string values of \fBsc\fP (save cursor) and \fBrc\fP (restore cursor)
+in \fBtsl\fP and \fBfsl\fP to accomplish this.
 .PP
 The status line is normally assumed to be the same width as the width
 of the terminal.
 If this is untrue, you can specify it with the numeric
-capability \fBwsl\fR.
+capability \fBwsl\fP.
 .PP
-A command to erase or blank the status line may be specified as \fBdsl\fR.
+A command to erase or blank the status line may be specified as \fBdsl\fP.
 .PP
-The boolean capability \fBeslok\fR specifies that escape sequences, tabs,
+The Boolean capability \fBeslok\fP specifies that escape sequences, tabs,
 etc., work ordinarily in the status line.
 .PP
-The \fBncurses\fR implementation does not yet use any of these capabilities.
+The \fI\%ncurses\fP implementation does not yet use any of these
+capabilities.
 They are documented here in case they ever become important.
-.PP
-.SS Line Graphics
-.PP
+.SS "Line Graphics"
 Many terminals have alternate character sets useful for forms-drawing.
-Terminfo and \fBcurses\fR have built-in support
+Terminfo and \fBcurses\fP have built-in support
 for most of the drawing characters
 supported by the VT100, with some characters from the AT&T 4410v1 added.
-This alternate character set may be specified by the \fBacsc\fR capability.
-.PP
-.TS H
-center expand;
-l l l l l
-l l l l l
-_ _ _ _ _
-lw25 lw10 lw6 lw6 lw6.
-.\".TH
-\fBGlyph	ACS	Ascii	acsc	acsc\fR
-\fBName	Name	Default	Char	Value\fR
-arrow pointing right	ACS_RARROW	>	+	0x2b
-arrow pointing left	ACS_LARROW	<	,	0x2c
-arrow pointing up	ACS_UARROW	^	\-	0x2d
-arrow pointing down	ACS_DARROW	v	.	0x2e
-solid square block	ACS_BLOCK	#	0	0x30
-diamond         	ACS_DIAMOND	+	`	0x60
-checker board (stipple)	ACS_CKBOARD	:	a	0x61
-degree symbol   	ACS_DEGREE	\e	f	0x66
-plus/minus      	ACS_PLMINUS	#	g	0x67
-board of squares	ACS_BOARD	#	h	0x68
-lantern symbol  	ACS_LANTERN	#	i	0x69
-lower right corner	ACS_LRCORNER	+	j	0x6a
-upper right corner	ACS_URCORNER	+	k	0x6b
-upper left corner	ACS_ULCORNER	+	l	0x6c
-lower left corner	ACS_LLCORNER	+	m	0x6d
-large plus or crossover	ACS_PLUS	+	n	0x6e
-scan line 1     	ACS_S1  	~	o	0x6f
-scan line 3     	ACS_S3  	\-	p	0x70
-horizontal line 	ACS_HLINE	\-	q	0x71
-scan line 7     	ACS_S7  	\-	r	0x72
-scan line 9     	ACS_S9  	\&_	s	0x73
-tee pointing right	ACS_LTEE	+	t	0x74
-tee pointing left	ACS_RTEE	+	u	0x75
-tee pointing up 	ACS_BTEE	+	v	0x76
-tee pointing down	ACS_TTEE	+	w	0x77
-vertical line   	ACS_VLINE	|	x	0x78
-less-than-or-equal-to	ACS_LEQUAL	<	y	0x79
-greater-than-or-equal-to	ACS_GEQUAL	>	z	0x7a
-greek pi        	ACS_PI	*	{	0x7b
-not-equal       	ACS_NEQUAL	!	|	0x7c
-UK pound sign        	ACS_STERLING	f	}	0x7d
-bullet          	ACS_BULLET	o	~	0x7e
+This alternate character set may be specified by the \fBacsc\fP capability.
+.PP
+.TS
+center;
+Lb  Cb  S  L   Lb
+Lb2 Lb2 Lb Lb1 S
+Lb  L   C  Lb  Lx.
+\&	acsc	\&	\&
+ACS Name	Value	Symbol	ASCII Fallback / Glyph Name
+_
+ACS_RARROW	0x2b	+	>	arrow pointing right
+ACS_LARROW	0x2c	,	<	arrow pointing left
+ACS_UARROW	0x2d	\-	\*^	arrow pointing up
+ACS_DARROW	0x2e	.	v	arrow pointing down
+ACS_BLOCK	0x30	0	#	solid square block
+ACS_DIAMOND	0x60	\(ga	+	diamond
+ACS_CKBOARD	0x61	a	:	checker board (stipple)
+ACS_DEGREE	0x66	f	\e	degree symbol
+ACS_PLMINUS	0x67	g	#	plus/minus
+ACS_BOARD	0x68	h	#	board of squares
+ACS_LANTERN	0x69	i	#	lantern symbol
+ACS_LRCORNER	0x6a	j	+	lower right corner
+ACS_URCORNER	0x6b	k	+	upper right corner
+ACS_ULCORNER	0x6c	l	+	upper left corner
+ACS_LLCORNER	0x6d	m	+	lower left corner
+ACS_PLUS	0x6e	n	+	large plus or crossover
+ACS_S1	0x6f	o	\*~	scan line 1
+ACS_S3	0x70	p	\-	scan line 3
+ACS_HLINE	0x71	q	\-	horizontal line
+ACS_S7	0x72	r	\-	scan line 7
+ACS_S9	0x73	s	\&_	scan line 9
+ACS_LTEE	0x74	t	+	tee pointing right
+ACS_RTEE	0x75	u	+	tee pointing left
+ACS_BTEE	0x76	v	+	tee pointing up
+ACS_TTEE	0x77	w	+	tee pointing down
+ACS_VLINE	0x78	x	|	vertical line
+ACS_LEQUAL	0x79	y	<	less-than-or-equal-to
+ACS_GEQUAL	0x7a	z	>	greater-than-or-equal-to
+ACS_PI	0x7b	{	*	greek pi
+ACS_NEQUAL	0x7c	|	!	not-equal
+ACS_STERLING	0x7d	}	f	UK pound sign
+ACS_BULLET	0x7e	\*~	o	bullet
 .TE
 .PP
 A few notes apply to the table itself:
@@ -1429,13 +1613,11 @@ The other VT100 symbols for control characters (\fIhorizontal tab\fP,
 .PP
 The best way to define a new device's graphics set is to add a column
 to a copy of this table for your terminal, giving the character which
-(when emitted between \fBsmacs\fR/\fBrmacs\fR switches) will be rendered
+(when emitted between \fBsmacs\fP/\fBrmacs\fP switches) will be rendered
 as the corresponding graphic.
 Then read off the VT100/your terminal
 character pairs right to left in sequence; these become the ACSC string.
-.PP
-.SS Color Handling
-.PP
+.SS "Color Handling"
 The curses library functions \fBinit_pair\fP and \fBinit_color\fP
 manipulate the \fIcolor pairs\fP and \fIcolor values\fP discussed in this
 section
@@ -1448,26 +1630,26 @@ terminals have a predefined set of \fIN\fP colors
 (where \fIN\fP is usually 8),
 and can set
 character-cell foreground and background characters independently, mixing them
-into \fIN\fP\ *\ \fIN\fP color-pairs.
+into \fIN\fP\ *\ \fIN\fP color pairs.
 .bP
 On HP-like terminals, the user must set each color
 pair up separately (foreground and background are not independently settable).
-Up to \fIM\fP color-pairs may be set up from 2*\fIM\fP different colors.
+Up to \fIM\fP color pairs may be set up from 2*\fIM\fP different colors.
 ANSI-compatible terminals are Tektronix-like.
 .PP
 Some basic color capabilities are independent of the color method.
 The numeric
-capabilities \fBcolors\fR and \fBpairs\fR specify the maximum numbers of colors
-and color-pairs that can be displayed simultaneously.
-The \fBop\fR (original
+capabilities \fBcolors\fP and \fBpairs\fP specify the maximum numbers of colors
+and color pairs that can be displayed simultaneously.
+The \fBop\fP (original
 pair) string resets foreground and background colors to their default values
 for the terminal.
-The \fBoc\fR string resets all colors or color-pairs to
+The \fBoc\fP string resets all colors or color pairs to
 their default values for the terminal.
 Some terminals (including many PC
 terminal emulators) erase screen areas with the current background color rather
-than the power-up default background; these should have the boolean capability
-\fBbce\fR.
+than the power-up default background; these should have the Boolean capability
+\fBbce\fP.
 .PP
 While the curses library works with \fIcolor pairs\fP
 (reflecting the inability of some devices to set foreground
@@ -1475,109 +1657,115 @@ and background colors independently),
 there are separate capabilities for setting these features:
 .bP
 To change the current foreground or background color on a Tektronix-type
-terminal, use \fBsetaf\fR (set ANSI foreground) and \fBsetab\fR (set ANSI
-background) or \fBsetf\fR (set foreground) and \fBsetb\fR (set background).
+terminal, use \fBsetaf\fP (set ANSI foreground) and \fBsetab\fP (set ANSI
+background) or \fBsetf\fP (set foreground) and \fBsetb\fP (set background).
 These take one parameter, the color number.
 The SVr4 documentation describes
-only \fBsetaf\fR/\fBsetab\fR; the XPG4 draft says that "If the terminal
+only \fBsetaf\fP/\fBsetab\fP; the XPG4 draft says that "If the terminal
 supports ANSI escape sequences to set background and foreground, they should
-be coded as \fBsetaf\fR and \fBsetab\fR, respectively.
+be coded as \fBsetaf\fP and \fBsetab\fP, respectively.
 .bP
 If the terminal
 supports other escape sequences to set background and foreground, they should
-be coded as \fBsetf\fR and \fBsetb\fR, respectively.
-The \fBvidputs\fR and the \fBrefresh\fP(3X) functions
-use the \fBsetaf\fR and \fBsetab\fR capabilities if they are defined.
+be coded as \fBsetf\fP and \fBsetb\fP, respectively.
+The \fBvidputs\fP and the \fBrefresh\fP(3X) functions
+use the \fBsetaf\fP and \fBsetab\fP capabilities if they are defined.
 .PP
-The \fBsetaf\fR/\fBsetab\fR and \fBsetf\fR/\fBsetb\fR capabilities take a
+The \fBsetaf\fP/\fBsetab\fP and \fBsetf\fP/\fBsetb\fP capabilities take a
 single numeric argument each.
-Argument values 0-7 of \fBsetaf\fR/\fBsetab\fR are portably defined as
+Argument values 0-7 of \fBsetaf\fP/\fBsetab\fP are portably defined as
 follows (the middle column is the symbolic #define available in the header for
-the \fBcurses\fR or \fBncurses\fR libraries).
+the \fBcurses\fP or \fI\%ncurses\fP libraries).
 The terminal hardware is free to
 map these as it likes, but the RGB values indicate normal locations in color
 space.
 .PP
-.TS H
+.TS
 center;
-l c c c
-l l n l.
-\fBColor	#define 	Value	RGB\fR
-black	\fBCOLOR_BLACK\fR	0	0, 0, 0
-red	\fBCOLOR_RED\ \fR	1	max,0,0
-green	\fBCOLOR_GREEN\fR	2	0,max,0
-yellow	\fBCOLOR_YELLOW\fR	3	max,max,0
-blue	\fBCOLOR_BLUE\fR	4	0,0,max
-magenta	\fBCOLOR_MAGENTA\fR	5	max,0,max
-cyan	\fBCOLOR_CYAN\fR	6	0,max,max
-white	\fBCOLOR_WHITE\fR	7	max,max,max
+cb cb cb cb s  s
+l  lb c  l1 l1 l .
+Color	#define 	Value	RGB
+_
+black	COLOR_BLACK	0	0,	0,	0
+red	COLOR_RED	1	max,	0,	0
+green	COLOR_GREEN	2	0,	max,	0
+yellow	COLOR_YELLOW	3	max,	max,	0
+blue	COLOR_BLUE	4	0,	0,	max
+magenta	COLOR_MAGENTA	5	max,	0,	max
+cyan	COLOR_CYAN	6	0,	max,	max
+white	COLOR_WHITE	7	max,	max,	max
 .TE
+.br
+.if t .ne 6v
 .PP
-The argument values of \fBsetf\fR/\fBsetb\fR historically correspond to
+The argument values of \fBsetf\fP/\fBsetb\fP historically correspond to
 a different mapping, i.e.,
-.TS H
+.PP
+.TS
 center;
-l c c c
-l l n l.
-\fBColor	#define 	Value	RGB\fR
-black	\fBCOLOR_BLACK\fR	0	0, 0, 0
-blue	\fBCOLOR_BLUE\fR	1	0,0,max
-green	\fBCOLOR_GREEN\fR	2	0,max,0
-cyan	\fBCOLOR_CYAN\fR	3	0,max,max
-red	\fBCOLOR_RED\ \fR	4	max,0,0
-magenta	\fBCOLOR_MAGENTA\fR	5	max,0,max
-yellow	\fBCOLOR_YELLOW\fR	6	max,max,0
-white	\fBCOLOR_WHITE\fR	7	max,max,max
+cb cb cb cb s  s
+l  lb c  l1 l1 l .
+Color	#define 	Value	RGB
+_
+black	COLOR_BLACK	0	0,	0,	0
+blue	COLOR_BLUE	1	0,	0,	max
+green	COLOR_GREEN	2	0,	max,	0
+cyan	COLOR_CYAN	3	0,	max,	max
+red	COLOR_RED	4	max,	0,	0
+magenta	COLOR_MAGENTA	5	max,	0,	max
+yellow	COLOR_YELLOW	6	max,	max,	0
+white	COLOR_WHITE	7	max,	max,	max
 .TE
 .PP
 It is important to not confuse the two sets of color capabilities;
 otherwise red/blue will be interchanged on the display.
 .PP
-On an HP-like terminal, use \fBscp\fR with a color-pair number parameter to set
+On an HP-like terminal, use \fBscp\fP with a color pair number parameter to set
 which color pair is current.
 .PP
 Some terminals allow the \fIcolor values\fP to be modified:
 .bP
-On a Tektronix-like terminal, the capability \fBccc\fR may be present to
+On a Tektronix-like terminal, the capability \fBccc\fP may be present to
 indicate that colors can be modified.
-If so, the \fBinitc\fR capability will
-take a color number (0 to \fBcolors\fR \- 1)and three more parameters which
+If so, the \fBinitc\fP capability will
+take a color number (0 to \fBcolors\fP \- 1)and three more parameters which
 describe the color.
 These three parameters default to being interpreted as RGB
 (Red, Green, Blue) values.
-If the boolean capability \fBhls\fR is present,
+If the Boolean capability \fBhls\fP is present,
 they are instead as HLS (Hue, Lightness, Saturation) indices.
 The ranges are
 terminal-dependent.
 .bP
-On an HP-like terminal, \fBinitp\fR may give a capability for changing a
-color-pair value.
-It will take seven parameters; a color-pair number (0 to
-\fBmax_pairs\fR \- 1), and two triples describing first background and then
+On an HP-like terminal, \fBinitp\fP may give a capability for changing a
+color pair value.
+It will take seven parameters; a color pair number (0 to
+\fBmax_pairs\fP \- 1), and two triples describing first background and then
 foreground colors.
 These parameters must be (Red, Green, Blue) or
-(Hue, Lightness, Saturation) depending on \fBhls\fR.
+(Hue, Lightness, Saturation) depending on \fBhls\fP.
 .PP
 On some color terminals, colors collide with highlights.
 You can register
-these collisions with the \fBncv\fR capability.
-This is a bit-mask of
+these collisions with the \fBncv\fP capability.
+This is a bit mask of
 attributes not to be used when colors are enabled.
 The correspondence with the
-attributes understood by \fBcurses\fR is as follows:
+attributes understood by \fBcurses\fP is as follows:
 .PP
 .TS
 center;
-l l l l
-lw20 lw2 lw10 lw10.
-\fBAttribute	Bit	Decimal	Set by\fR
+cb cb cb cb
+lb n  n  lb.
+Attribute	Bit	Decimal	Set by
+_
 A_STANDOUT	0	1	sgr
 A_UNDERLINE	1	2	sgr
 A_REVERSE	2	4	sgr
-A_BLINK   	3	8	sgr
-A_DIM      	4	16	sgr
-A_BOLD    	5	32	sgr
-A_INVIS   	6	64	sgr
+A_BLINK	3	8	sgr
+A_DIM	4	16	sgr
+A_BOLD	5	32	sgr
+A_INVIS	6	64	sgr
 A_PROTECT	7	128	sgr
 A_ALTCHARSET	8	256	sgr
 A_HORIZONTAL	9	512	sgr1
@@ -1592,19 +1780,21 @@ A_ITALIC	15	32768	sitm
 For example, on many IBM PC consoles, the underline attribute collides with the
 foreground color blue and is not available in color mode.
 These should have
-an \fBncv\fR capability of 2.
+an \fBncv\fP capability of 2.
 .PP
-SVr4 curses does nothing with \fBncv\fR, ncurses recognizes it and optimizes
+SVr4 curses does nothing with \fBncv\fP,
+\fI\%ncurses\fP recognizes it and optimizes
 the output in favor of colors.
-.PP
 .SS Miscellaneous
 If the terminal requires other than a null (zero) character as a pad, then this
 can be given as pad.
 Only the first character of the pad string is used.
 If the terminal does not have a pad character, specify npc.
-Note that ncurses implements the termcap-compatible \fBPC\fR variable;
+Note that \fI\%ncurses\fP implements the termcap-compatible \fBPC\fP
+variable;
 though the application may set this value to something other than
-a null, ncurses will test \fBnpc\fR first and use napms if the terminal
+a null,
+\fI\%ncurses\fP will test \fBnpc\fP first and use napms if the terminal
 has no pad character.
 .PP
 If the terminal can move up or down half a line,
@@ -1625,16 +1815,17 @@ this can be indicated with the parameterized string
 .BR rep .
 The first parameter is the character to be repeated and the second
 is the number of times to repeat it.
-Thus, tparm(repeat_char, 'x', 10) is the same as \*(``xxxxxxxxxx\*(''.
+Thus, tparm(repeat_char, \*'x\*', 10) is the same as \*(``xxxxxxxxxx\*(''.
 .PP
-If the terminal has a settable command character, such as the \s-1TEKTRONIX\s+1 4025,
+If the terminal has a settable command character,
+such as the \s-1TEKTRONIX\s+1 4025,
 this can be indicated with
 .BR cmdch .
 A prototype command character is chosen which is used in all capabilities.
 This character is given in the
 .B cmdch
 capability to identify it.
-The following convention is supported on some UNIX systems:
+The following convention is supported on some Unix systems:
 The environment is to be searched for a
 .B CC
 variable, and if found, all
@@ -1676,7 +1867,7 @@ A value of
 indicates that the number of lines is not fixed,
 but that there is still more memory than fits on the screen.
 .PP
-If the terminal is one of those supported by the \s-1UNIX\s+1 virtual
+If the terminal is one of those supported by the Unix virtual
 terminal protocol, the terminal number can be given as
 .BR vt .
 .PP
@@ -1703,15 +1894,14 @@ All text, including
 is transparently passed to the printer while an
 .B mc5p
 is in effect.
+.SS "Glitches and Brain Damage"
+Hazeltine terminals,
+which do not allow \*(``\*~\*('' characters to be displayed should
+indicate \fBhz\fP.
 .PP
-.SS Glitches and Braindamage
-.PP
-Hazeltine terminals, which do not allow \*(``~\*('' characters to be displayed should
-indicate \fBhz\fR.
-.PP
-Terminals which ignore a line-feed immediately after an \fBam\fR wrap,
+Terminals which ignore a line-feed immediately after an \fBam\fP wrap,
 such as the Concept and vt100,
-should indicate \fBxenl\fR.
+should indicate \fBxenl\fP.
 .PP
 If
 .B el
@@ -1720,14 +1910,14 @@ is required to get rid of standout
 \fBxhp\fP should be given.
 .PP
 Teleray terminals, where tabs turn all characters moved over to blanks,
-should indicate \fBxt\fR (destructive tabs).
+should indicate \fBxt\fP (destructive tabs).
 Note: the variable indicating this is now \*(``dest_tabs_magic_smso\*(''; in
 older versions, it was teleray_glitch.
 This glitch is also taken to mean that it is not possible to position
 the cursor on top of a \*(``magic cookie\*('',
 that to erase standout mode it is instead necessary to use
 delete and insert line.
-The ncurses implementation ignores this glitch.
+The \fI\%ncurses\fP implementation ignores this glitch.
 .PP
 The Beehive Superbee, which is unable to correctly transmit the escape
 or control/C characters, has
@@ -1738,28 +1928,32 @@ Note that in older terminfo versions, this capability was called
 \*(``beehive_glitch\*(''; it is now \*(``no_esc_ctl_c\*(''.
 .PP
 Other specific terminal problems may be corrected by adding more
-capabilities of the form \fBx\fR\fIx\fR.
-.PP
-.SS Pitfalls of Long Entries
-.PP
+capabilities of the form \fBx\fIx\fR.
+.SS "Pitfalls of Long Entries"
 Long terminfo entries are unlikely to be a problem; to date, no entry has even
 approached terminfo's 4096-byte string-table maximum.
 Unfortunately, the termcap
-translations are much more strictly limited (to 1023 bytes), thus termcap translations
-of long terminfo entries can cause problems.
+translations are much more strictly limited (to 1023 bytes),
+thus termcap translations of long terminfo entries can cause problems.
 .PP
-The man pages for 4.3BSD and older versions of \fBtgetent\fP instruct the user to
+The man pages for 4.3BSD
+and older versions of \fBtgetent\fP instruct the user to
 allocate a 1024-byte buffer for the termcap entry.
 The entry gets null-terminated by
 the termcap library, so that makes the maximum safe length for a termcap entry
 1k\-1 (1023) bytes.
-Depending on what the application and the termcap library
-being used does, and where in the termcap file the terminal type that \fBtgetent\fP
-is searching for is, several bad things can happen.
+Depending on what the application and the termcap library being used does,
+and where in the termcap file the terminal type that \fBtgetent\fP
+is searching for is, several bad things can happen:
+.bP
+some termcap libraries print a warning message,
+.bP
+some exit if they find an entry that's longer than 1023 bytes,
+.bP
+some neither exit nor warn, doing nothing useful, and
+.bP
+some simply truncate the entries to 1023 bytes.
 .PP
-Some termcap libraries print a warning message or exit if they find an
-entry that's longer than 1023 bytes; others do not; others truncate the
-entries to 1023 bytes.
 Some application programs allocate more than
 the recommended 1K for the termcap entry; others do not.
 .PP
@@ -1792,8 +1986,9 @@ long entry, appears in the termcap file after the long entry, or
 does not appear in the file at all (so that \fBtgetent\fP has to search
 the whole termcap file).
 .PP
-Then \fBtgetent\fP will overwrite memory, perhaps its stack, and probably core dump
-the program.
+Then \fBtgetent\fP will overwrite memory,
+perhaps its stack,
+and probably core dump the program.
 Programs like telnet are particularly vulnerable; modern telnets
 pass along values like the terminal type automatically.
 The results are almost
@@ -1804,7 +1999,7 @@ termcap library truncates long entries, like OSF/1 3.0, it is immune to dying
 here but will return incorrect data for the terminal.
 .PP
 The \*(``after tc expansion\*('' length will have a similar effect to the
-above, but only for people who actually set TERM to that terminal
+above, but only for people who actually set \fITERM\fP to that terminal
 type, since \fBtgetent\fP only does \*(``tc\*('' expansion once it is found the
 terminal type it was looking for, not while searching.
 .PP
@@ -1813,108 +2008,121 @@ on various combinations of termcap libraries and applications, a core
 dump, warnings, or incorrect operation.
 If it is too long even before
 \*(``tc\*('' expansion, it will have this effect even for users of some other
-terminal types and users whose TERM variable does not have a termcap
+terminal types and users whose \fITERM\fP variable does not have a termcap
 entry.
 .PP
-When in \-C (translate to termcap) mode, the \fBncurses\fR implementation of
-\fB@TIC@\fR(1M) issues warning messages when the pre-tc length of a termcap
+When in \-C (translate to termcap) mode,
+the \fI\%ncurses\fP implementation of
+\fB@TIC@\fP(1M) issues warning messages when the pre-tc length of a termcap
 translation is too long.
 The \-c (check) option also checks resolved (after tc
 expansion) lengths.
-.SS Binary Compatibility
-It is not wise to count on portability of binary terminfo entries between
-commercial UNIX versions.
-The problem is that there are at least two versions
-of terminfo (under HP\-UX and AIX) which diverged from System V terminfo after
-SVr1, and have added extension capabilities to the string table that (in the
-binary format) collide with System V and XSI Curses extensions.
+.SH FILES
+.TP
+.I \*d
+compiled terminal description database directory
 .SH EXTENSIONS
-.PP
 Searching for terminal descriptions in
-\fB$HOME/.terminfo\fR and TERMINFO_DIRS 
+\fI$HOME/.terminfo\fP and \fI\%TERMINFO_DIRS\fP
 is not supported by older implementations.
 .PP
-Some SVr4 \fBcurses\fR implementations, and all previous to SVr4, do not
+Some SVr4 \fBcurses\fP implementations, and all previous to SVr4, do not
 interpret the %A and %O operators in parameter strings.
 .PP
-SVr4/XPG4 do not specify whether \fBmsgr\fR licenses movement while in
+SVr4/XPG4 do not specify whether \fBmsgr\fP licenses movement while in
 an alternate-character-set mode (such modes may, among other things, map
 CR and NL to characters that do not trigger local motions).
-The \fBncurses\fR implementation ignores \fBmsgr\fR in \fBALTCHARSET\fR
-mode.
+The \fI\%ncurses\fP implementation ignores \fBmsgr\fP in
+\fBALTCHARSET\fP mode.
 This raises the possibility that an XPG4
 implementation making the opposite interpretation may need terminfo
-entries made for \fBncurses\fR to have \fBmsgr\fR turned off.
+entries made for \fI\%ncurses\fP to have \fBmsgr\fP turned off.
 .PP
-The \fBncurses\fR library handles insert-character and insert-character modes
-in a slightly non-standard way to get better update efficiency.
+The \fI\%ncurses\fP library handles insert-character and
+insert-character modes in a slightly non-standard way to get better
+update efficiency.
 See
-the \fBInsert/Delete Character\fR subsection above.
+the \fBInsert/Delete Character\fP subsection above.
 .PP
-The parameter substitutions for \fBset_clock\fR and \fBdisplay_clock\fR are
-not documented in SVr4 or the XSI Curses standard.
+The parameter substitutions for \fBset_clock\fP and \fBdisplay_clock\fP are
+not documented in SVr4 or X/Open Curses.
 They are deduced from the
 documentation for the AT&T 505 terminal.
 .PP
-Be careful assigning the \fBkmous\fR capability.
-The \fBncurses\fR library wants to interpret it as \fBKEY_MOUSE\fR,
+Be careful assigning the \fBkmous\fP capability.
+The \fI\%ncurses\fP library wants to interpret it as \fBKEY_MOUSE\fP,
 for use by terminals and emulators like xterm
 that can return mouse-tracking information in the keyboard-input stream.
 .PP
 X/Open Curses does not mention italics.
 Portable applications must assume that numeric capabilities are
 signed 16-bit values.
-This includes the \fIno_color_video\fP (ncv) capability.
-The 32768 mask value used for italics with ncv can be confused with
-an absent or cancelled ncv.
+This includes the \fIno_color_video\fP (\fBncv\fP) capability.
+The 32768 mask value used for italics with \fBncv\fP can be confused with
+an absent or cancelled \fBncv\fP.
 If italics should work with colors,
-then the ncv value must be specified, even if it is zero.
-.PP
-Different commercial ports of terminfo and curses support different subsets of
-the XSI Curses standard and (in some cases) different extension sets.
-Here
-is a summary, accurate as of October 1995:
-.bP
-\fBSVR4, Solaris, ncurses\fR \-\-
-These support all SVr4 capabilities.
-.bP
-\fBSGI\fR \-\-
-Supports the SVr4 set, adds one undocumented extended string
-capability (\fBset_pglen\fR).
-.bP
-\fBSVr1, Ultrix\fR \-\-
-These support a restricted subset of terminfo capabilities.
-The booleans end with \fBxon_xoff\fR;
-the numerics with \fBwidth_status_line\fR;
-and the strings with \fBprtr_non\fR.
-.bP
-\fBHP/UX\fR \-\-
-Supports the SVr1 subset, plus the SVr[234] numerics \fBnum_labels\fR,
-\fBlabel_height\fR, \fBlabel_width\fR, plus function keys 11 through 63, plus
-\fBplab_norm\fR, \fBlabel_on\fR, and \fBlabel_off\fR, plus some incompatible
-extensions in the string table.
-.bP
-\fBAIX\fR \-\-
-Supports the SVr1 subset, plus function keys 11 through 63, plus a number
-of incompatible string table extensions.
-.bP
-\fBOSF\fR \-\-
-Supports both the SVr4 set and the AIX extensions.
-.SH FILES
-.TP 25
-\*d/?/*
-files containing terminal descriptions
-.SH SEE ALSO
-\fB@INFOCMP@\fR(1M),
-\fB@TABS@\fR(1),
-\fB@TIC@\fR(1M),
-\fBcurses\fR(3X),
-\fBcurs_color\fR(3X),
-\fBcurs_variables\fR(3X),
-\fBprintf\fR(3),
-\fBterm_variables\fR(3X).
-\fBterm\fR(\*n).
-\fBuser_caps\fR(5).
+then the \fBncv\fP value must be specified, even if it is zero.
+.PP
+Different commercial ports of \fI\%terminfo\fP and \fIcurses\fP support
+different subsets of X/Open Curses and
+(in some cases)
+different extensions.
+Here is a summary,
+accurate as of October 1995,
+after which the commercial Unix market contracted and lost diversity.
+.bP
+SVr4,
+Solaris,
+and \fI\%ncurses\fP support all SVr4 capabilities.
+.bP
+IRIX supports the SVr4 set and adds one undocumented extended string
+capability (\fB\%set_pglen\fP).
+.bP
+SVr1 and Ultrix support a restricted subset of \fI\%terminfo\fP
+capabilities.
+The Booleans end with \fB\%xon_xoff\fP;
+the numerics with \fB\%width_status_line\fP;
+and the strings with \fB\%prtr_non\fP.
+.bP
+HP/UX supports the SVr1 subset,
+plus the SVr[234] numerics
+\fB\%num_labels\fP,
+\fB\%label_height\fP,
+\fB\%label_width\fP,
+plus function keys 11 through 63,
+plus
+\fB\%plab_norm\fP,
+\fB\%label_on\fP,
+and
+\fB\%label_off\fP,
+plus a number of incompatible string table extensions.
+.bP
+AIX supports the SVr1 subset,
+plus function keys 11 through 63,
+plus a number of incompatible string table extensions.
+.bP
+OSF/1 supports both the SVr4 set and the AIX extensions.
+.SH PORTABILITY
+Do not count on compiled (binary) \fI\%terminfo\fP entries being
+portable between commercial Unix systems.
+At least two implementations of \fI\%terminfo\fP
+(those of HP-UX and AIX)
+diverged from those of other System V Unices after SVr1,
+adding extension capabilities to the string table that
+(in the binary format)
+collide with subsequent System V and X/Open Curses extensions.
 .SH AUTHORS
 Zeyd M. Ben-Halim, Eric S. Raymond, Thomas E. Dickey.
-Based on pcurses by Pavel Curtis.
+Based on \fIpcurses\fP by Pavel Curtis.
+.SH SEE ALSO
+\fB\%@INFOCMP@\fP(1M),
+\fB\%@TABS@\fP(1),
+\fB\%@TIC@\fP(1M),
+\fB\%curses\fP(3X),
+\fB\%curs_color\fP(3X),
+\fB\%curs_terminfo\fP(3X),
+\fB\%curs_variables\fP(3X),
+\fB\%printf\fP(3),
+\fB\%term_variables\fP(3X),
+\fB\%term\fP(5),
+\fB\%user_caps\fP(5)
diff --git a/contrib/ncurses/man/tic.1m b/contrib/ncurses/man/tic.1m
index f0a627d96af8..9c3181ed5c7d 100644
--- a/contrib/ncurses/man/tic.1m
+++ b/contrib/ncurses/man/tic.1m
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,63 +27,70 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: tic.1m,v 1.78 2020/12/19 21:32:45 tom Exp $
-.TH @TIC@ 1M ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
-.ds n 5
-.ds d @TERMINFO@
+.\" $Id: tic.1m,v 1.110 2024/04/27 17:57:06 tom Exp $
+.TH @TIC@ 1M 2024-04-27 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "User commands"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
+.
+.ds d @TERMINFO@
 .SH NAME
-\fB@TIC@\fR \- the \fIterminfo\fR entry-description compiler
+\fB\%@TIC@\fP \-
+compile terminal descriptions for \fIterminfo\fR or \fItermcap\fR
 .SH SYNOPSIS
-\fB@TIC@\fR
+\fB@TIC@\fP
 [\fB\-\
 0\
 1\
+a\
+c\
 C\
 D\
+f\
+g\
 G\
 I\
 K\
 L\
 N\
-T\
-U\
-V\
-W\
-a\
-c\
-f\
-g\
 q\
 r\
 s\
 t\
+T\
+U\
+V\
+W\
 x\
-\fR]
-[\fB\-e\fR \fInames\fR]
-[\fB\-o\fR \fIdir\fR]
-[\fB\-Q\fR[\fIn\fR]]
-[\fB\-R\fR \fIsubset\fR]
-[\fB\-v\fR[\fIn\fR]]
-[\fB\-w\fR[\fIn\fR]]
-\fIfile\fR
-.br
+\fP]
+[\fB\-e\fP \fIterminal-type-list\fP]
+[\fB\-o\fP \fIdir\fP]
+[\fB\-Q\fP[\fIn\fP]]
+[\fB\-R\fP \fIsubset\fP]
+[\fB\-v\fP[\fIn\fP]]
+[\fB\-w\fP[\fIn\fP]]
+\fIfile\fP
 .SH DESCRIPTION
-The \fB@TIC@\fR command translates a \fBterminfo\fR file from source
+The \fB@TIC@\fP command translates a \fBterminfo\fP file from source
 format into compiled format.
 The compiled format is necessary for use with
-the library routines in \fBncurses\fR(3X).
+the library routines in \fB\%ncurses\fP(3X).
 .PP
-As described in \fBterm\fR(\*n), the database may be either a directory
+As described in \fBterm\fP(5), the database may be either a directory
 tree (one file per terminal entry) or a hashed database (one record per entry).
-The \fB@TIC@\fR command writes only one type of entry,
+The \fB@TIC@\fP command writes only one type of entry,
 depending on how it was built:
 .bP
 For directory trees, the top-level directory, e.g., /usr/share/terminfo,
@@ -102,71 +109,73 @@ In either case (directory or hashed database),
 For a directory, this would be the \*(``terminfo\*('' leaf,
 versus a "terminfo.db" file.
 .PP
-The results are normally placed in the system terminfo database \fB\*d\fR.
+The results are normally placed in the system terminfo database \fB\*d\fP.
 The compiled terminal description can be placed
 in a different terminfo database.
 There are two ways to achieve this:
 .bP
 First, you may override the system default either by
 using the \fB\-o\fP option,
-or by setting the variable \fBTERMINFO\fR
+or by setting the variable \fI\%TERMINFO\fP
 in your shell environment to a valid database location.
 .bP
-Secondly, if \fB@TIC@\fR cannot write in \fI\*d\fR
-or the location specified using your TERMINFO variable,
-it looks for the directory \fI$HOME/.terminfo\fR
-(or hashed database \fI$HOME/.terminfo.db)\fR;
+Secondly, if \fB@TIC@\fP cannot write in \fI\*d\fP
+or the location specified using your \fI\%TERMINFO\fP variable,
+it looks for the directory \fI$HOME/.terminfo\fP
+(or hashed database \fI$HOME/.terminfo.db)\fP;
 if that location exists, the entry is placed there.
 .PP
 Libraries that read terminfo entries are expected to check in succession
 .bP
-a location specified with the TERMINFO environment variable,
+a location specified with the \fI\%TERMINFO\fP environment variable,
 .bP
-\fI$HOME/.terminfo\fR,
+\fI$HOME/.terminfo\fP,
 .bP
-directories listed in the TERMINFO_DIRS environment variable,
+directories listed in the \fI\%TERMINFO_DIRS\fP environment variable,
 .bP
 a compiled-in list of directories (@TERMINFO_DIRS@), and
 .bP
-the system terminfo database (\fI\*d\fR).
-.SS ALIASES
+the system terminfo database (\fI\*d\fP).
 .PP
+The \fIFetching Compiled Descriptions\fP section in the \fBterminfo\fR(5)
+manual goes into further detail.
+.SS Aliases
 This is the same program as @INFOTOCAP@ and @CAPTOINFO@;
 usually those are linked to, or copied from this program:
 .bP
 When invoked as @INFOTOCAP@, @TIC@ sets the \fB\-I\fP option.
 .bP
 When invoked as @CAPTOINFO@, @TIC@ sets the \fB\-C\fP option.
-.SS OPTIONS
+.SH OPTIONS
 .TP
-\fB\-0\fR
+\fB\-0\fP
 restricts the output to a single line
 .TP
-\fB\-1\fR
+\fB\-1\fP
 restricts the output to a single column
 .TP
-\fB\-a\fR
+\fB\-a\fP
 tells \fB@TIC@\fP to retain commented-out capabilities rather than discarding
 them.
 Capabilities are commented by prefixing them with a period.
-This sets the \fB\-x\fR option, because it treats the commented-out
+This sets the \fB\-x\fP option, because it treats the commented-out
 entries as user-defined names.
 If the source is termcap, accept the 2-character names required by version 6.
 Otherwise these are ignored.
 .TP
-\fB\-C\fR
+\fB\-C\fP
 Force source translation to termcap format.
-Note: this differs from the \fB\-C\fR
-option of \fB@INFOCMP@\fR(1M) in that it does not merely translate capability
+Note: this differs from the \fB\-C\fP
+option of \fB@INFOCMP@\fP(1M) in that it does not merely translate capability
 names, but also translates terminfo strings to termcap format.
 Capabilities
 that are not translatable are left in the entry under their terminfo names
 but commented out with two preceding dots.
 The actual format used incorporates some improvements for escaped characters
 from terminfo format.
-For a stricter BSD-compatible translation, add the \fB\-K\fR option.
+For a stricter BSD-compatible translation, add the \fB\-K\fP option.
 .IP
-If this is combined with \fB\-c\fR, \fB@TIC@\fR makes additional checks
+If this is combined with \fB\-c\fP, \fB@TIC@\fP makes additional checks
 to report cases where the terminfo values do not have an exact equivalent
 in termcap form.
 For example:
@@ -180,10 +189,10 @@ capabilities with more than one delay or with delays before the end of
 the string will not convert completely.
 .RE
 .TP
-\fB\-c\fR
-tells \fB@TIC@\fP to only check \fIfile\fR for errors,
+\fB\-c\fP
+tells \fB@TIC@\fP to only check \fIfile\fP for errors,
 including syntax problems and bad use-links.
-If you specify \fB\-C\fR (\fB\-I\fR) with this option, the code
+If you specify \fB\-C\fP (\fB\-I\fP) with this option, the code
 will print warnings about entries which, after use resolution, are more than
 1023 (4096) bytes long.
 Due to a fixed buffer length in older termcap libraries,
@@ -197,7 +206,7 @@ will be valid expressions.
 It does this check only for the predefined string capabilities;
 those which are defined with the \fB\-x\fP option are ignored.
 .TP
-\fB\-D\fR
+\fB\-D\fP
 tells \fB@TIC@\fP to print the database locations that it knows about, and exit.
 The first location shown is the one to which it would write compiled
 terminal descriptions.
@@ -206,58 +215,58 @@ according to the rules summarized above,
 it will print a diagnostic and exit with an error rather than
 printing a list of database locations.
 .TP
-\fB\-e \fR\fInames\fR
-Limit writes and translations to the following comma-separated list of
-terminals.
+\fB\-e \fIlist\fR
+Limit writes and translations to the comma-separated \fIlist\fP of
+terminal types.
 If any name or alias of a terminal matches one of the names in
 the list, the entry will be written or translated as normal.
 Otherwise no output will be generated for it.
 The option value is interpreted as a file containing the list if it
 contains a '/'.
 (Note: depending on how @TIC@ was compiled,
-this option may require \fB\-I\fR or \fB\-C\fR.)
+this option may require \fB\-I\fP or \fB\-C\fP.)
 .TP
-\fB\-f\fR
+\fB\-f\fP
 Display complex terminfo strings which contain if/then/else/endif expressions
 indented for readability.
 .TP
-\fB\-G\fR
+\fB\-G\fP
 Display constant literals in decimal form
 rather than their character equivalents.
 .TP
-\fB\-g\fR
+\fB\-g\fP
 Display constant character literals in quoted form
 rather than their decimal equivalents.
 .TP
-\fB\-I\fR
+\fB\-I\fP
 Force source translation to terminfo format.
 .TP
-\fB\-K\fR
-Suppress some longstanding ncurses extensions to termcap format,
-e.g., "\\s" for space.
+\fB\-K\fP
+Suppress some longstanding \fI\%ncurses\fP extensions to termcap format,
+e.g., "\es" for space.
 .TP
-\fB\-L\fR
+\fB\-L\fP
 Force source translation to terminfo format
-using the long C variable names listed in <\fBterm.h\fR>
+using the long C variable names listed in <\fBterm.h\fP>
 .TP
-\fB\-N\fR
+\fB\-N\fP
 Disable smart defaults.
 Normally, when translating from termcap to terminfo, the compiler makes
 a number of assumptions about the defaults of string capabilities
-\fBreset1_string\fR, \fBcarriage_return\fR, \fBcursor_left\fR,
-\fBcursor_down\fR, \fBscroll_forward\fR, \fBtab\fR, \fBnewline\fR,
-\fBkey_backspace\fR, \fBkey_left\fR, and \fBkey_down\fR, then attempts
+\fBreset1_string\fP, \fBcarriage_return\fP, \fBcursor_left\fP,
+\fBcursor_down\fP, \fBscroll_forward\fP, \fBtab\fP, \fBnewline\fP,
+\fBkey_backspace\fP, \fBkey_left\fP, and \fBkey_down\fP, then attempts
 to use obsolete termcap capabilities to deduce correct values.
 It also
-normally suppresses output of obsolete termcap capabilities such as \fBbs\fR.
+normally suppresses output of obsolete termcap capabilities such as \fBbs\fP.
 This option forces a more literal translation that also preserves the
 obsolete capabilities.
 .TP
-\fB\-o\fR\fIdir\fR
+\fB\-o\fIdir\fR
 Write compiled entries to given database location.
-Overrides the TERMINFO environment variable.
+Overrides the \fI\%TERMINFO\fP environment variable.
 .TP
-\fB\-Q\fR\fIn\fR
+\fB\-Q\fIn\fR
 Rather than show source in terminfo (text) format,
 print the compiled (binary) format in hexadecimal or base64 form,
 depending on the option's value:
@@ -273,20 +282,28 @@ base64
 hexadecimal and base64
 .RE
 .TP
-\fB\-q\fR
+\fB\-q\fP
 Suppress comments and blank lines when showing translated source.
 .TP
-\fB\-R\fR\fIsubset\fR
+\fB\-R\fIsubset\fR
 Restrict output to a given subset.
 This option is for use with archaic
-versions of terminfo like those on SVr1, Ultrix, or HP/UX that do not support
+versions of terminfo like those on SVr1, Ultrix, or HP-UX that do not support
 the full set of SVR4/XSI Curses terminfo; and outright broken ports like AIX 3.x
 that have their own extensions incompatible with SVr4/XSI.
-Available subsets
-are \*(``SVr1\*('', \*(``Ultrix\*('', \*(``HP\*('', \*(``BSD\*('' and \*(``AIX\*('';
-see \fBterminfo\fR(\*n) for details.
+.IP
+Available subsets are
+.RS
+\*(``SVr1\*('',
+\*(``Ultrix\*('',
+\*(``HP\*('',
+\*(``BSD\*('', and
+\*(``AIX\*(''
+.RE
+.IP
+See \fBterminfo\fP(5) for details.
 .TP
-\fB\-r\fR
+\fB\-r\fP
 Force entry resolution (so there are no remaining tc capabilities) even
 when doing translation to termcap format.
 This may be needed if you are
@@ -294,42 +311,50 @@ preparing a termcap file for a termcap library (such as GNU termcap through
 version 1.3 or BSD termcap through 4.3BSD) that does not handle multiple
 tc capabilities per entry.
 .TP
-\fB\-s\fR
+\fB\-s\fP
 Summarize the compile by showing the database location into which entries
 are written, and the number of entries which are compiled.
 .TP
-\fB\-T\fR
+\fB\-T\fP
 eliminates size-restrictions on the generated text.
 This is mainly useful for testing and analysis, since the compiled
 descriptions are limited (e.g., 1023 for termcap, 4096 for terminfo).
 .TP
-\fB\-t\fR
+\fB\-t\fP
 tells \fB@TIC@\fP to discard commented-out capabilities.
 Normally when translating from terminfo to termcap,
 untranslatable capabilities are commented-out.
-.TP 5
-\fB\-U\fR
+.TP
+\fB\-U\fP
 tells \fB@TIC@\fP to not post-process the data after parsing the source file.
 Normally, it infers data which is commonly missing in older terminfo data,
 or in termcaps.
 .TP
-\fB\-V\fR
-reports the version of ncurses which was used in this program, and exits.
+\fB\-V\fP
+reports the version of \fI\%ncurses\fP which was used in this program,
+and exits.
 .TP
-\fB\-v\fR\fIn\fR
+\fB\-v\fIn\fR
 specifies that (verbose) output be written to standard error trace
-information showing \fB@TIC@\fR's progress.
+information showing \fB@TIC@\fP's progress.
 .IP
-The optional parameter \fIn\fR is a number from 1 to 10, inclusive,
+The optional parameter \fIn\fP is a number from 1 to 9, inclusive,
 indicating the desired level of detail of information.
-If ncurses is built without tracing support, the optional parameter is ignored.
-If \fIn\fR is omitted, the default level is 1.
-If \fIn\fR is specified and greater than 1, the level of
-detail is increased.
+.RS
+.bP
+If \fI\%ncurses\fP is built without tracing support,
+the optional parameter is ignored.
+.bP
+If \fIn\fP is omitted, the default level is 1.
+.bP
+If \fIn\fP is specified and greater than 1, the level of
+detail is increased, and the output is written (with tracing information)
+to the \*(``trace\*('' file.
+.RE
 .RS
 .PP
 The debug flag levels are as follows:
-.TP
+.TP 4
 1
 Names of files created and linked
 .TP
@@ -339,8 +364,14 @@ Information related to the \*(``use\*('' facility
 3
 Statistics from the hashing algorithm
 .TP
+4
+Details of extended capabilities
+.TP
 5
-String-table memory allocations
+(unused)
+.TP
+6
+(unused)
 .TP
 7
 Entries into the string-table
@@ -350,69 +381,168 @@ List of tokens encountered by scanner
 .TP
 9
 All values computed in construction of the hash table
-.LP
-If the debug level \fIn\fR is not given, it is taken to be one.
 .RE
 .TP
-\fB\-W\fR
+\fB\-W\fP
 By itself, the \fB\-w\fP option will not force long strings to be wrapped.
 Use the \fB\-W\fP option to do this.
 .IP
 If you specify both \fB\-f\fP and \fB\-W\fP options,
 the latter is ignored when \fB\-f\fP has already split the line.
 .TP
-\fB\-w\fR\fIn\fR
+\fB\-w\fIn\fR
 specifies the width of the output.
 The parameter is optional.
 If it is omitted, it defaults to 60.
 .TP
-\fB\-x\fR
-Treat unknown capabilities as user-defined (see \fBuser_caps(\*n)\fP).
+\fB\-x\fP
+Treat unknown capabilities as user-defined (see \fBuser_caps\fP(5)).
 That is, if you supply a capability name which \fB@TIC@\fP does not recognize,
-it will infer its type (boolean, number or string) from the syntax and
+it will infer its type (Boolean, number or string) from the syntax and
 make an extended table entry for that.
 User-defined capability strings
 whose name begins with \*(``k\*('' are treated as function keys.
-.SS PARAMETERS
+.SS Parameters
 .TP
-\fIfile\fR
-contains one or more \fBterminfo\fR terminal descriptions in source
-format [see \fBterminfo\fR(\*n)].
+\fIfile\fP
+contains one or more \fBterminfo\fP terminal descriptions in source
+format [see \fBterminfo\fP(5)].
 Each description in the file
 describes the capabilities of a particular terminal.
 .IP
-If \fIfile\fR is \*(``-\*('', then the data is read from the standard input.
-The \fIfile\fR parameter may also be the path of a character-device.
-.SS PROCESSING
-.PP
-All but one of the capabilities recognized by \fB@TIC@\fR are documented
-in \fBterminfo\fR(\*n).
-The exception is the \fBuse\fR capability.
+If \fIfile\fP is \*(``-\*('', then the data is read from the standard input.
+The \fIfile\fP parameter may also be the path of a character-device.
+.SS Processing
+All but one of the capabilities recognized by \fB@TIC@\fP are documented
+in \fBterminfo\fP(5).
+The exception is the \fBuse\fP capability.
 .PP
-When a \fBuse\fR=\fIentry\fR\-\fIname\fR field is discovered in a
-terminal entry currently being compiled, \fB@TIC@\fR reads in the binary
-from \fB\*d\fR to complete the entry.
+When a \fBuse\fP=\fIentry\fP\-\fIname\fP field is discovered in a
+terminal entry currently being compiled, \fB@TIC@\fP reads in the binary
+from \fB\*d\fP to complete the entry.
 (Entries created from
-\fIfile\fR will be used first.
-\fB@TIC@\fR duplicates the capabilities in
-\fIentry\fR\-\fIname\fR for the current entry, with the exception of
+\fIfile\fP will be used first.
+\fB@TIC@\fP duplicates the capabilities in
+\fIentry\fP\-\fIname\fP for the current entry, with the exception of
 those capabilities that explicitly are defined in the current entry.
 .PP
-When an entry, e.g., \fBentry_name_1\fR, contains a
-\fBuse=\fR\fIentry\fR_\fIname\fR_\fI2\fR field, any canceled
-capabilities in \fIentry\fR_\fIname\fR_\fI2\fR must also appear in
-\fBentry_name_1\fR before \fBuse=\fR for these capabilities to be
-canceled in \fBentry_name_1\fR.
+When an entry, e.g., \fBentry_name_1\fP, contains a
+\fBuse=\fIentry\fR_\fIname\fR_\fI2\fR field, any canceled
+capabilities in \fIentry\fR_\fIname\fR_\fI2\fP must also appear in
+\fBentry_name_1\fP before \fBuse=\fP for these capabilities to be
+canceled in \fBentry_name_1\fP.
 .PP
-Total compiled entries cannot exceed 4096 bytes.
+Total compiled entries cannot exceed
+4096 bytes in the legacy storage format, or
+32768 using the extended number format.
 The name field cannot
 exceed 512 bytes.
 Terminal names exceeding the maximum alias length
 (32 characters on systems with long filenames, 14 characters otherwise)
 will be truncated to the maximum alias length
 and a warning message will be printed.
-.SH HISTORY
+.SH FILES
+.TP
+.I \*d
+compiled terminal description database
+.SH NOTES
+There is some evidence that historic \fB@TIC@\fP implementations treated
+description fields with no whitespace in them as additional aliases or
+short names.
+This \fB@TIC@\fP does not do that, but it does warn when
+description fields may be treated that way and check them for dangerous
+characters.
+.SH EXTENSIONS
+Unlike the SVr4 \fB@TIC@\fP command, this implementation can actually
+compile termcap sources.
+In fact, entries in terminfo and termcap syntax can
+be mixed in a single source file.
+See \fBterminfo\fP(5) for the list of
+termcap names taken to be equivalent to terminfo names.
+.PP
+The SVr4 manual pages are not clear on the resolution rules for \fBuse\fP
+capabilities.
+This implementation of \fB@TIC@\fP will find \fBuse\fP targets anywhere
+in the source file,
+or anywhere in the file tree rooted at
+\fI\%TERMINFO\fP
+(if
+\fI\%TERMINFO\fP is defined),
+or in the user's \fI$HOME/.terminfo\fP database
+(if it exists),
+or (finally) anywhere in the system's file tree of
+compiled entries.
+.PP
+The error messages from this \fB@TIC@\fP have the same format as GNU C
+error messages, and can be parsed by GNU Emacs's compile facility.
+.PP
+Aside from \fB\-c\fP and \fB\-v\fP, options are not portable:
+.bP
+Most of @TIC@'s options
+are not supported by SVr4 \fBtic\fP:
+.sp
+.RS
+\fB\-0\fP
+\fB\-1\fP
+\fB\-C\fP
+\fB\-G\fP
+\fB\-I\fP
+\fB\-N\fP
+\fB\-R\fP
+\fB\-T\fP
+\fB\-V\fP
+\fB\-a\fP
+\fB\-e\fP
+\fB\-f\fP
+\fB\-g\fP
+\fB\-o\fP
+\fB\-r\fP
+\fB\-s\fP
+\fB\-t\fP
+\fB\-x\fP
+.RE
+.bP
+The NetBSD \fBtic\fP supports a few of the \fI\%ncurses\fP options
+.sp
+.RS
+\fB\-a\fP
+\fB\-o\fP
+\fB\-x\fP
+.RE
+.IP
+and adds \fB\-S\fP
+(a feature which does the same thing
+as @INFOCMP@'s \fB\-e\fP and \fB\-E\fP options).
+.PP
+The SVr4 \fB\-c\fP mode does not report bad \*(``use=\*('' links.
+.PP
+System V does not compile entries to or read entries from your
+\fI$HOME/.terminfo\fP database unless \fI\%TERMINFO\fP is explicitly set
+to it.
+.SH PORTABILITY
+X/Open Curses, Issue 7 (2009) provides a brief description of \fBtic\fP.
+It lists one option: \fB\-c\fP.
+The omission of \fB\-v\fP is unexpected.
+The change history states that the description is derived from Tru64.
+According to its manual pages, that system also supported the \fB\-v\fP option.
+.PP
+Shortly after Issue 7 was released, Tru64 was discontinued.
+As of 2019, the surviving implementations of \fBtic\fP
+are SVr4 (AIX, HP-UX and Solaris),
+\fI\%ncurses\fP
+and NetBSD curses.
+The SVr4 \fBtic\fP programs all support the \fB\-v\fP option.
+The NetBSD \fBtic\fP program follows X/Open's documentation,
+omitting the \fB\-v\fP option.
 .PP
+The X/Open rationale states that some implementations of \fBtic\fP
+read terminal descriptions from the standard input if the \fIfile\fP
+parameter is omitted.
+None of these implementations do that.
+Further, it comments that some may choose to read from \*(''./terminfo.src\*(''
+but that is obsolescent behavior from SVr2,
+and is not (for example) a documented feature of SVr3.
+.SH HISTORY
 System V Release 2 provided a \fBtic\fP utility.
 It accepted a single option: \fB\-v\fP (optionally followed by a number).
 According to Ross Ridge's comment in \fImytinfo\fP,
@@ -431,19 +561,19 @@ While the program itself was changed little as development
 continued with System V Release 4,
 the table of capabilities grew from 180 (\fIpcurses\fP) to 464 (Solaris).
 .PP
-In early development of ncurses (1993),
+In early development of \fI\%ncurses\fP (1993),
 Zeyd Ben-Halim used the table from \fImytinfo\fP to
 extend the \fIpcurses\fP table to 469 capabilities
 (456 matched SVr4, 8 were only in SVr4, 13 were not in SVr4).
 Of those 13, 11 were ultimately discarded
 (perhaps to match the draft of X/Open Curses).
 The exceptions were
-\fBmemory_lock_above\fP and
-\fBmemory_unlock\fP (see \fBuser_caps\fP(5)).
+\fB\%memory_lock_above\fP and
+\fB\%memory_unlock\fP (see \fB\%user_caps\fP(5)).
 .PP
-Eric Raymond incorporated parts of \fImytinfo\fP into ncurses
+Eric Raymond incorporated parts of \fImytinfo\fP into \fI\%ncurses\fP
 to implement the termcap-to-terminfo source conversion,
-and extended that to begin development of 
+and extended that to begin development of
 the corresponding terminfo-to-termcap source conversion,
 Thomas Dickey completed that development over the course of several years.
 .PP
@@ -452,7 +582,7 @@ to support user-defined capabilities.
 .PP
 In 2010, Roy Marples provided a \fBtic\fP program
 and terminfo library for NetBSD.
-That implementation adapts several features from ncurses,
+That implementation adapts several features from \fI\%ncurses\fP,
 including \fB@TIC@\fP's \fB\-x\fP option.
 .PP
 The \fB\-c\fP option tells \fB@TIC@\fP to check for problems in the
@@ -461,131 +591,32 @@ Continued development provides additional checks:
 .bP
 \fIpcurses\fP had 8 warnings
 .bP
-ncurses in 1996 had 16 warnings
+\fI\%ncurses\fP in 1996 had 16 warnings
 .bP
 Solaris (SVr4) curses has 28 warnings
 .bP
 NetBSD tic in 2019 has 19 warnings.
 .bP
-ncurses in 2019 has 96 warnings
+\fI\%ncurses\fP in 2019 has 96 warnings
 .PP
-The checking done in ncurses' \fB@TIC@\fP helps with the conversion to
-termcap, as well as pointing out errors and inconsistencies.
+The checking done in \fI\%ncurses\fP' \fB@TIC@\fP helps with the
+conversion to termcap,
+as well as pointing out errors and inconsistencies.
 It is also used to ensure consistency with the user-defined capabilities.
-There are 527 distinct capabilities in ncurses' terminal database;
+There are 527 distinct capabilities in \fI\%ncurses\fP' terminal
+database;
 128 of those are user-defined.
-.SH PORTABILITY
-.PP
-X/Open Curses, Issue 7 (2009) provides a brief description of \fBtic\fP.
-It lists one option: \fB\-c\fP.
-The omission of \fB\-v\fP is unexpected.
-The change history states that the description is derived from True64 UNIX.
-According to its manual pages, that system also supported the \fB\-v\fP option.
-.PP
-Shortly after Issue 7 was released, Tru64 was discontinued.
-As of 2019, the surviving implementations of \fBtic\fP
-are SVr4 (AIX, HP-UX and Solaris),
-ncurses
-and NetBSD curses.
-The SVr4 \fBtic\fP programs all support the \fB\-v\fP option.
-The NetBSD \fBtic\fP program follows X/Open's documentation,
-omitting the \fB\-v\fP option.
-.PP
-The X/Open rationale states that some implementations of \fBtic\fP
-read terminal descriptions from the standard input if the \fIfile\fP
-parameter is omitted.
-None of these implementations do that.
-Further, it comments that some may choose to read from \*(''./terminfo.src\*(''
-but that is obsolescent behavior from SVr2,
-and is not (for example) a documented feature of SVr3.
-.SS COMPATIBILITY
-There is some evidence that historic \fB@TIC@\fR implementations treated
-description fields with no whitespace in them as additional aliases or
-short names.
-This \fB@TIC@\fR does not do that, but it does warn when
-description fields may be treated that way and check them for dangerous
-characters.
-.SS EXTENSIONS
-Unlike the SVr4 \fB@TIC@\fR command, this implementation can actually
-compile termcap sources.
-In fact, entries in terminfo and termcap syntax can
-be mixed in a single source file.
-See \fBterminfo\fR(\*n) for the list of
-termcap names taken to be equivalent to terminfo names.
-.PP
-The SVr4 manual pages are not clear on the resolution rules for \fBuse\fR
-capabilities.
-This implementation of \fB@TIC@\fR will find \fBuse\fR targets anywhere
-in the source file, or anywhere in the file tree rooted at \fBTERMINFO\fR (if
-\fBTERMINFO\fR is defined),
-or in the user's \fI$HOME/.terminfo\fR database
-(if it exists),
-or (finally) anywhere in the system's file tree of
-compiled entries.
-.PP
-The error messages from this \fB@TIC@\fR have the same format as GNU C
-error messages, and can be parsed by GNU Emacs's compile facility.
-.PP
-Aside from \fB\-c\fP and \fB\-v\fP, options are not portable:
-.bP
-Most of @TIC@'s options 
-are not supported by SVr4 \fBtic\fP:
-.sp
-.RS
-\fB\-0\fR
-\fB\-1\fR
-\fB\-C\fR
-\fB\-G\fR
-\fB\-I\fR
-\fB\-N\fR
-\fB\-R\fR
-\fB\-T\fR
-\fB\-V\fR
-\fB\-a\fR
-\fB\-e\fR
-\fB\-f\fR
-\fB\-g\fR
-\fB\-o\fR
-\fB\-r\fR
-\fB\-s\fR
-\fB\-t\fR
-\fB\-x\fR
-.RE
-.bP
-The NetBSD \fBtic\fP  supports a few of the ncurses options
-.sp
-.RS
-\fB\-a\fP
-\fB\-o\fP
-\fB\-x\fP
-.RE
-.IP
-and adds \fB\-S\fP
-(a feature which does the same thing
-as @INFOCMP@'s \fB\-e\fP and \fB\-E\fP options).
-.PP
-The SVr4 \fB\-c\fR mode does not report bad \*(``use=\*('' links.
-.PP
-System V does not compile entries to or read entries from your
-\fI$HOME/.terminfo\fR database unless TERMINFO is explicitly set to it.
-.SH FILES
-.TP 5
-\fB\*d/?/*\fR
-Compiled terminal description database.
-.SH SEE ALSO
-\fB@CAPTOINFO@\fR(1M),
-\fB@INFOCMP@\fR(1M),
-\fB@INFOTOCAP@\fR(1M),
-\fB@TOE@\fR(1M),
-\fBcurses\fR(3X),
-\fBterm\fR(\*n).
-\fBterminfo\fR(\*n).
-\fBuser_caps\fR(\*n).
-.PP
-This describes \fBncurses\fR
-version @NCURSES_MAJOR@.@NCURSES_MINOR@ (patch @NCURSES_PATCH@).
-.SH AUTHOR
+.SH AUTHORS
 Eric S. Raymond <esr@snark.thyrsus.com>
 and
 .br
-Thomas E. Dickey <dickey@invisible-island.net>
+Thomas E. Dickey <dickey@invisible\-island.net>
+.SH SEE ALSO
+\fB\%@CAPTOINFO@\fP(1M),
+\fB\%@INFOCMP@\fP(1M),
+\fB\%@INFOTOCAP@\fP(1M),
+\fB\%@TOE@\fP(1M),
+\fB\%curses\fP(3X),
+\fB\%term\fP(5),
+\fB\%terminfo\fP(5),
+\fB\%user_caps\fP(5)
diff --git a/contrib/ncurses/man/toe.1m b/contrib/ncurses/man/toe.1m
index 9a83821babc5..c4eba848e06b 100644
--- a/contrib/ncurses/man/toe.1m
+++ b/contrib/ncurses/man/toe.1m
@@ -1,5 +1,6 @@
+'\" t
 .\"***************************************************************************
-.\" Copyright 2019,2020 Thomas E. Dickey                                     *
+.\" Copyright 2019-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2015,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,168 +28,215 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: toe.1m,v 1.33 2020/12/19 21:52:09 tom Exp $
-.TH @TOE@ 1M ""
+.\" $Id: toe.1m,v 1.68 2024/04/20 18:59:26 tom Exp $
+.TH @TOE@ 1M 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "User commands"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.ie n .ds CW R
+.el   \{
+.ie \n(.g .ds CW CR
+.el       .ds CW CW
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
-.de NS
-.ie n  .sp
-.el    .sp .5
-.ie n  .in +4
-.el    .in +2
-.nf
-.ft C			\" Courier
-..
-.de NE
-.fi
-.ft R
-.ie n  .in -4
-.el    .in -2
-..
-.ds n 5
 .ds d @TERMINFO@
 .SH NAME
-\fB@TOE@\fR \- table of (terminfo) entries
+\fB\%@TOE@\fP \-
+list table of entries of \fIterminfo\fR terminal types
 .SH SYNOPSIS
-\fB@TOE@\fR [\fB\-v\fR[\fIn\fR]] [\fB\-ahsuUV\fR] \fIfile...\fR
-.br
-.SH DESCRIPTION
+.B @TOE@
+.RB [ \-ahs ]
+.RB [ \-v\ \c
+.RI [ n ]]
+.RI [ directory
+\&.\|.\|.]
 .PP
-With no options,
-\fB@TOE@\fR lists all available terminal types by primary name
-with descriptions.
-File arguments specify the directories to be scanned; if no
-such arguments are given,
-your default terminfo directory is scanned.
-If you also specify the \fB\-h\fR option,
-a directory header will be issued as each
-directory is entered.
+.B @TOE@
+.RB [ \-u | \-U ]
+.I file
 .PP
-There are other options intended for use by terminfo file maintainers:
-.TP
-\fB\-a\fR
-report on all of the terminal databases which ncurses would search,
-rather than only the first one that it finds.
+.B "@TOE@ \-V"
+.SH DESCRIPTION
+\fB\%@TOE@\fP reports to the standard output stream the (primary) names
+and descriptions of the terminal types available to the \fIterminfo\fP
+library.
+Each \fIdirectory\fP is scanned;
+if none are given,
+\fB\%@TOE@\fP scans the default \fIterminfo\fP directory.
+.SH OPTIONS
+The \fB\-h\fP option can be helpful to observe where \fB\%@TOE@\fP is
+looking for terminal descriptions.
+Other options support maintainers of \fIterminfo\fP terminal
+descriptions.
+.TP 9 \" "-u file" + 2n
+.B \-a
+lists entries from all terminal database directories that \fIterminfo\fP
+would search,
+instead of only the first that it finds.
 .IP
-If the \fB\-s\fR is also given, \fB@TOE@\fR
-adds a column to the report,
-showing (like \fBconflict\fP(1)) which entries which 
-belong to a given terminal database.
-An "*" marks entries which differ, and "+" marks equivalent entries.
+If
+.B \-s
+is also given,
+\fB\%@TOE@\fP
+additionally reports,
+like \fI\%conflict\fP(1),
+which entries correspond to a given terminal database.
+An \*(``*\*('' marks entries that differ,
+and \*(``+\*('' marks equivalent entries.
 .IP
-Without the \fB\-s\fP option, \fB@TOE@\fR does not attempt to merge
-duplicates in its report
+Without the \fB\-s\fP option,
+\fB\%@TOE@\fP does not attempt to merge duplicates in its report.
+.TP
+.B \-h
+writes a heading naming each each directory as it is accessed.
 .TP
-\fB\-s\fR
-sort the output by the entry names.
+.B \-s
+sorts the output by the entry names.
 .TP
-\fB\-u\fR \fIfile\fR
-says to write a report to the standard output,
-listing dependencies in the given terminfo/termcap source file.
-The report condenses the \*(``use\*('' relation:
-each line consists of the primary name of a terminal that
-has use capabilities,
-followed by a colon,
-followed by the
-whitespace-separated primary names of all terminals which occur in those use
-capabilities,
-followed by a newline
+.BI \-u\  file
+lists terminal type dependencies in \fIfile\fP,
+a \fIterminfo\fP entry source or \fItermcap\fP database file.
+The report summarizes the \*(``\fBuse\fP\*('' (\fIterminfo\fP) and
+\fBtc\fP (\fItermcap\fP) relations:
+each line comprises the primary name of a terminal type employing
+\fBuse\fP/\fBtc\fP capabilities,
+a colon,
+a space- and tab-separated list of primary names of terminal types thus
+named,
+and a newline.
 .TP
-\fB\-U\fR \fIfile\fR
-says to write a report to the standard output,
-listing reverse dependencies in the given terminfo/termcap source file.
-The report reverses the \*(``use\*('' relation:
-each line consists of the primary name of a
-terminal that occurs in use capabilities,
-followed by a colon,
-followed by the
-whitespace-separated primary names of all terminals which depend on it,
-followed by a newline.
+.BI \-U\  file
+lists terminal type reverse dependencies in \fIfile\fP,
+a \fIterminfo\fP entry source or \fItermcap\fP database file.
+The report summarizes the \*(``\fBuse\fP\*('' (\fIterminfo\fP) and
+\fBtc\fP (\fItermcap\fP) reverse relations:
+each line comprises the primary name of a terminal type occurring in
+\fBuse\fP/\fBtc\fP capabilities,
+a colon,
+a space- and tab-separated list of primary names of terminal types
+naming them thus,
+and a newline.
 .TP
-\fB\-v\fR\fIn\fR
-specifies that (verbose) output be written to standard error,
-showing \fB@TOE@\fR's progress.
+.BR \-v\  [\c
+.IR n ]
+reports verbose status information to the standard error stream,
+showing \fB\%@TOE@\fP's progress.
 .IP
-The optional parameter \fIn\fR is a number from 1 to 10,
-interpreted as for \fB@TIC@\fR(1M).
-If ncurses is built without tracing support, the optional parameter is ignored.
+The optional parameter \fIn\fP is an integer between 1 and 10 inclusive,
+interpreted as for \fB\%@TIC@\fP(1M).
+If \fI\%ncurses\fP is built without tracing support,
+\fIn\fP is ignored.
 .TP
-\fB\-V\fR
-reports the version of ncurses which was used in this program,
-and exits.
-.SH EXAMPLES
-.PP
-Without sorting, the \fB\-a\fP option reports all of the names found
-in all of the terminal databases found by the \fBTERMINFO\fP and
-\fBTERMINFO_DIRS\fP environment variables:
-.NS
-MtxOrb162 	16x2 Matrix Orbital LCD display
-MtxOrb204 	20x4 Matrix Orbital LCD display
-MtxOrb    	Generic Matrix Orbital LCD display
-qvt101+   	qume qvt 101 PLUS product
-qvt119+-25	QVT 119 PLUS with 25 data lines
-qansi-g   	QNX ANSI
-qvt103    	qume qvt 103
-qnxw      	QNX4 windows
-qansi-w   	QNX ansi for windows
-qnxm      	QNX4 with mouse events
-qvt203-25-w	QVT 203 PLUS with 25 by 132 columns
-qansi-t   	QNX ansi without console writes
-\&.\ .\ .
-.NE
-.PP
-Use the \fB\-a\fP and \fB\-s\fP options together to show where each terminal
-description was found:
-.NS
---> /usr/local/ncurses/share/terminfo
-----> /usr/share/terminfo
-*-+-:	9term     	Plan9 terminal emulator for X
-*---:	Eterm     	Eterm with xterm-style color support (X Window System)
-*-*-:	Eterm-256color	Eterm with xterm 256-colors
-*-*-:	Eterm-88color	Eterm with 88 colors
-*-+-:	MtxOrb    	Generic Matrix Orbital LCD display
-*-+-:	MtxOrb162 	16x2 Matrix Orbital LCD display
-*-+-:	MtxOrb204 	20x4 Matrix Orbital LCD display
-*-*-:	NCR260VT300WPP	NCR 2900_260 vt300 wide mode pc+  kybd
-*-+-:	aaa       	ann arbor ambassador/30 lines
-*-+-:	aaa+dec   	ann arbor ambassador in dec vt100 mode
-*-+-:	aaa+rv    	ann arbor ambassador in reverse video
-\&.\ .\ .
-.NE
+\fB\-V\fP
+reports the version of \fI\%ncurses\fP associated
+with this program and exits with a successful status.
 .SH FILES
-.TP 5
-\fB\*d/?/*\fR
-Compiled terminal description database.
+.TP
+.I \*d
+compiled terminal description database
+.SH PORTABILITY
+\fB\%@TOE@\fP is not provided by other implementations.
+There is no applicable X/Open or POSIX standard for it.
 .SH HISTORY
-This utility is not provided by other implementations.
-There is no relevant X/Open or POSIX standard for \fB@TOE@\fP.
-.PP 
-The program name refers to a developer's pun:
+\fB\%@TOE@\fP replaces a \fB\-T\fP option that was briefly supported by
+the \fI\%ncurses\fP \fB\%infocmp\fP utility in 1995.
+.PP
+The \fB\-a\fP and \fB\-s\fP options were added in 2006 and 2011,
+respectively.
+.PP
+The program's name originates with a developer's pun:
 .bP
 \fBtic\fP,
 .bP
 \fBtac\fP (now \fBtack\fP),
 .bP
 \fBtoe\fP.
+.SH EXAMPLES
+When not sorting with the \fB\-s\fP option,
+the \fB\-a\fP option reports all of the names found in all of the
+terminal database directories named in the \fI\%TERMINFO\fP and
+\fI\%TERMINFO_DIRS\fP environment variables.
+.RS 4
 .PP
-It replaced a \fB\-T\fP option which was briefly supported by
-the ncurses \fBinfocmp\fP utility in 1995.
+.\" toe -a | grep -E '^(xterm|vt)'
+.ft \*(CW
+.TS
+L2 Lx.
+xterm\-color	generic color xterm
+xterm\-xfree86	xterm terminal emulator (XFree86)
+xterm\-vt220	xterm emulating vt220
+xterm\-256color	xterm with 256 colors
+xterm\-r6	xterm X11R6 version
+xterm\-r5	xterm R5 version
+xterm\-mono	monochrome xterm
+xterm	T{
+.ad l
+xterm terminal emulator (X Window System)
+T}
+vt220	dec vt220
+vt102	dec vt102
+vt100	dec vt100 (w/advanced video)
+vt52	dec vt52
+.T&
+L.
+\&.\|.\|.
+.TE
+.ft
+.RE
 .PP
-The \fB\-a\fP and \fB\-s\fP options were added to 
-\fB@TOE@\fR several years later (2006 and 2011, respectively).
-.SH SEE ALSO
-\fB@CAPTOINFO@\fR(1M),
-\fB@INFOCMP@\fR(1M),
-\fB@INFOTOCAP@\fR(1M),
-\fB@TIC@\fR(1M),
-\fBcurses\fR(3X),
-\fBterminfo\fR(\*n).
+Use the \fB\-a\fP and \fB\-s\fP options together to show where each
+terminal description was found.
+.RS 4
 .PP
-This describes \fBncurses\fR
-version @NCURSES_MAJOR@.@NCURSES_MINOR@ (patch @NCURSES_PATCH@).
+.\" toe -as | grep -E '(^-+>|:.(xterm|vt))'
+.ft \*(CW
+.TS
+Lx.
+\-\-> /etc/terminfo
+\-\-\-\-> /lib/terminfo
+\-\-\-\-\-\-> /usr/share/terminfo
+.TE
+.TS
+L1 L2 Lx.
+\-\-*\-\-\-:	vt100	dec vt100 (w/advanced video)
+\-\-*\-\-\-:	vt102	dec vt102
+\-\-*\-\-\-:	vt220	dec vt220
+\-\-*\-\-\-:	vt52	dec vt52
+\-\-*\-\-\-:	xterm	T{
+.ad l
+xterm terminal emulator (X Window System)
+T}
+\-\-*\-\-\-:	xterm\-256color	xterm with 256 colors
+\-\-*\-\-\-:	xterm\-color	generic color xterm
+\-\-*\-\-\-:	xterm\-mono	monochrome xterm
+\-\-*\-\-\-:	xterm\-r5	xterm R5 version
+\-\-*\-\-\-:	xterm\-r6	xterm X11R6 version
+\-\-*\-\-\-:	xterm\-vt220	xterm emulating vt220
+\-\-*\-\-\-:	xterm\-xfree86	T{
+.ad l
+xterm terminal emulator (XFree86)
+T}
+.T&
+L.
+\&.\|.\|.
+.TE
+.ft
+.RE
+.SH SEE ALSO
+\fB\%@CAPTOINFO@\fP(1M),
+\fB\%@INFOCMP@\fP(1M),
+\fB\%@INFOTOCAP@\fP(1M),
+\fB\%@TIC@\fP(1M),
+\fB\%curses\fP(3X),
+\fB\%terminfo\fP(5)
diff --git a/contrib/ncurses/man/tput.1 b/contrib/ncurses/man/tput.1
index 64fb453016eb..eba073390df5 100644
--- a/contrib/ncurses/man/tput.1
+++ b/contrib/ncurses/man/tput.1
@@ -1,6 +1,6 @@
 '\" t
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,570 +28,977 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: tput.1,v 1.65 2020/12/19 22:17:47 tom Exp $
-.TH @TPUT@ 1 ""
-.ds d @TERMINFO@
-.ds n 1
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: tput.1,v 1.113 2024/04/20 19:58:50 tom Exp $
+.TH @TPUT@ 1 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "User commands"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
+.ds d @TERMINFO@
 .SH NAME
-\fB@TPUT@\fR, \fBreset\fR \- initialize a terminal or query terminfo database
+\fB\%@TPUT@\fP \-
+initialize a terminal, exercise its capabilities, or query \fI\%term\%info\fP database
 .SH SYNOPSIS
-\fB@TPUT@\fR [\fB\-T\fR\fItype\fR] \fIcapname\fR [\fIparameters\fR]
-.br
-\fB@TPUT@\fR [\fB\-T\fR\fItype\fR] [\fB\-x\fP] \fBclear\fR
-.br
-\fB@TPUT@\fR [\fB\-T\fR\fItype\fR] \fBinit\fR
-.br
-\fB@TPUT@\fR [\fB\-T\fR\fItype\fR] \fBreset\fR
-.br
-\fB@TPUT@\fR [\fB\-T\fR\fItype\fR] \fBlongname\fR
-.br
-\fB@TPUT@ \-S\fR  \fB<<\fR
-.br
-\fB@TPUT@ \-V\fR
-.br
+\fB@TPUT@\fP [\fB\-T\fP \fIterminal-type\fP]
+{\fIcap-code\fP [\fIparameter\fP .\|.\|.\&]} .\|.\|.
+.PP
+\fB@TPUT@\fP [\fB\-T\fP \fIterminal-type\fP] [\fB\-x\fP] \fBclear\fP
+.PP
+\fB@TPUT@\fP [\fB\-T\fP \fIterminal-type\fP] \fBinit\fP
+.PP
+\fB@TPUT@\fP [\fB\-T\fP \fIterminal-type\fP] \fB\%reset\fP
+.PP
+\fB@TPUT@\fP [\fB\-T\fP \fIterminal-type\fP] \fB\%longname\fP
+.PP
+\fB@TPUT@ \-S\fP
+.PP
+\fB@TPUT@ \-V\fP
 .SH DESCRIPTION
-The \fB@TPUT@\fR utility uses the \fBterminfo\fR database to make the
-values of terminal-dependent capabilities and information available to
-the shell (see \fBsh\fR(1)), to initialize or reset the terminal, or
-return the long name of the requested terminal type.
-The result depends upon the capability's type:
-.RS 3
-.TP 5
-string
-\fB@TPUT@\fR writes the string to the standard output.
-No trailing newline is supplied.
+\fB\%@TPUT@\fP uses the
+.I \%term\%info
+library and database to make terminal-specific capabilities and
+information available to the shell,
+to initialize or reset the terminal,
+or
+to report a description of the current
+(or specified)
+terminal type.
+Terminal capabilities are accessed by
+.IR cap-code .
+.PP
+\fB\%terminfo\fP(5) discusses terminal capabilities at length
+and presents a complete list of
+.IR cap-codes .
+.PP
+When retrieving capability values,
+the result depends upon the capability's type.
+.TP 9 \" "Boolean" + 2n
+Boolean
+\fB\%@TPUT@\fP sets its exit status to
+.B 0
+if the terminal possesses
+.IR cap-code ,
+and
+.B 1
+if it does not.
 .TP
-integer
-\fB@TPUT@\fR writes the decimal value to the standard output,
-with a trailing newline.
+numeric
+\fB\%@TPUT@\fP writes
+.IR cap-code 's
+decimal value to the standard output stream if defined
+.RB ( \-1
+if it is not)
+followed by a newline.
 .TP
-boolean
-\fB@TPUT@\fR simply sets the exit code
-(\fB0\fR for TRUE if the terminal has the capability,
-\fB1\fR for FALSE if it does not),
-and writes nothing to the standard output.
-.RE
+string
+\fB\%@TPUT@\fP writes
+.IR cap-code 's
+value to the standard output stream if defined,
+without a trailing newline.
 .PP
 Before using a value returned on the standard output,
-the application should test the exit code
-(e.g., \fB$?\fR, see \fBsh\fR(1)) to be sure it is \fB0\fR.
-(See the \fBEXIT CODES\fR and \fBDIAGNOSTICS\fR sections.)
-For a complete list of capabilities
-and the \fIcapname\fR associated with each, see \fBterminfo\fR(5).
-.SS Options
-.TP
-\fB\-S\fR
-allows more than one capability per invocation of \fB@TPUT@\fR.  The
-capabilities must be passed to \fB@TPUT@\fR from the standard input
-instead of from the command line (see example).
-Only one \fIcapname\fR is allowed per line.
-The \fB\-S\fR option changes the
-meaning of the \fB0\fR and \fB1\fR boolean and string exit codes (see the
-EXIT CODES section).
+the application should test \fB\%@TPUT@\fP's exit status
+to be sure it is 0;
+see section \*(``EXIT STATUS\*('' below.
+.SS Operands
+Generally,
+an operand is a
+.IR cap-code ,
+a capability code from the terminal database,
+or a parameter thereto.
+Three others are specially recognized by \fB\%@TPUT@\fP:
+.BR init ,
+.BR \%reset ,
+and
+.BR \%longname .
+Although these resemble capability codes,
+they in fact receive special handling;
+we term them \*(``pseudo-capabilities\*(''.
+.TP 11n \" "longname" + 2n + adjustment for PDF
+.I cap-code
+indicates a capability from the terminal database.
 .IP
-Because some capabilities may use
-\fIstring\fP parameters rather than \fInumbers\fP,
-\fB@TPUT@\fR uses a table and the presence of parameters in its input
-to decide whether to use \fBtparm\fR(3X),
-and how to interpret the parameters.
-.TP
-\fB\-T\fR\fItype\fR
-indicates the \fItype\fR of terminal.
-Normally this option is
-unnecessary, because the default is taken from the environment
-variable \fBTERM\fR.
-If \fB\-T\fR is specified, then the shell
-variables \fBLINES\fR and \fBCOLUMNS\fR will also be ignored.
-.TP
-\fB\-V\fR
-reports the version of ncurses which was used in this program, and exits.
-.TP
-.B \-x
-do not attempt to clear the terminal's scrollback buffer
-using the extended \*(``E3\*('' capability.
-.SS Commands
-A few commands (\fBinit\fP, \fBreset\fP and \fBlongname\fP) are
-special; they are defined by the \fB@TPUT@\fP program.
-The others are the names of \fIcapabilities\fP from the terminal database
-(see \fBterminfo\fR(5) for a list).
-Although \fBinit\fP and \fBreset\fP resemble capability names,
-\fB@TPUT@\fP uses several capabilities to perform these special functions.
-.TP
-\fIcapname\fR
-indicates the capability from the terminal database.
-.IP
-If the capability is a string that takes parameters, the arguments
-following the capability will be used as parameters for the string.
+If
+.I cap-code
+is of string type and takes parameters,
+\fB\%@TPUT@\fP interprets arguments following
+.I cap-code
+as the parameters,
+up to the (fixed) quantity the capability requires.
 .IP
-Most parameters are numbers.
+Most parameters are numeric.
 Only a few terminal capabilities require string parameters;
-\fB@TPUT@\fR uses a table to decide which to pass as strings.
-Normally \fB@TPUT@\fR uses \fBtparm\fR(3X) to perform the substitution.
+\fB\%@TPUT@\fP uses a table to decide which to pass as strings.
+Normally \fB\%@TPUT@\fP uses \fB\%tparm\fP(3X) to perform the
+substitution.
 If no parameters are given for the capability,
-\fB@TPUT@\fR writes the string without performing the substitution.
+\fB\%@TPUT@\fP writes the string without performing the substitution.
 .TP
-\fBinit\fR
-If the terminal database is present and an entry for the user's
-terminal exists (see \fB\-T\fR\fItype\fR, above), the following will
-occur:
+.B init
+initializes the terminal.
+If the terminal database is present
+and an entry for the user's terminal type exists,
+the following occur.
 .RS
 .TP 5
 (1)
-first, \fB@TPUT@\fR retrieves the current terminal mode settings
-for your terminal.
-It does this by successively testing
+\fB\%@TPUT@\fP retrieves the terminal's mode settings.
+It successively tests the file descriptors corresponding to
 .RS
 .bP
-the standard error,
+the standard error stream,
 .bP
-standard output,
+the standard output stream,
 .bP
-standard input and
+the standard input stream,
+and
 .bP
-ultimately \*(``/dev/tty\*(''
+.I \%/dev/tty
 .RE
 .IP
 to obtain terminal settings.
-Having retrieved these settings, \fB@TPUT@\fP remembers which
-file descriptor to use when updating settings.
+Having retrieved them,
+\fB\%@TPUT@\fP remembers which descriptor to use for further updates.
 .TP
 (2)
-if the window size cannot be obtained from the operating system,
-but the terminal description (or environment, e.g., \fBLINES\fP
-and \fBCOLUMNS\fP variables specify this),
-update the operating system's notion of the window size.
+If the terminal dimensions cannot be obtained from the operating system,
+but the environment or terminal type database entry describes them,
+\fB\%@TPUT@\fP updates the operating system's notion of them.
 .TP
 (3)
-the terminal modes will be updated:
+\fB\%@TPUT@\fP updates the terminal modes.
 .RS
 .bP
-any delays (e.g., newline) specified in the entry will
-be set in the tty driver,
+Any delays specified in the entry
+(for example,
+when a newline is sent)
+are set in the terminal driver.
 .bP
-tabs expansion will be turned on or off according to
-the specification in the entry, and
+Tab expansion is turned on or off per the specification in the entry,
+and
 .bP
 if tabs are not expanded,
-standard tabs will be set (every 8 spaces).
+standard tabs
+(every 8 spaces)
+are set.
 .RE
 .TP
 (4)
-if present, the terminal's initialization strings will be
-output as detailed in the \fBterminfo\fR(5) section on
-.IR "Tabs and Initialization" ,
+If initialization capabilities,
+detailed in subsection \*(``Tabs and Initialization\*('' of
+\fB\%terminfo\fP(5),
+are present,
+\fB\%@TPUT@\fP writes them to the standard output stream.
 .TP
 (5)
-output is flushed.
+\fB\%@TPUT@\fP flushes the standard output stream.
 .RE
 .IP
-If an entry does not
-contain the information needed for any of these activities,
-that activity will silently be skipped.
+If an entry lacks the information needed for an activity above,
+that activity is silently skipped.
 .TP
-\fBreset\fR
-This is similar to \fBinit\fP, with two differences:
+.B reset
+re-initializes the terminal.
+A reset differs from initialization in two ways.
 .RS
 .TP 5
 (1)
-before any other initialization,
-the terminal modes will be reset to a \*(``sane\*('' state:
+\fB\%@TPUT@\fP sets the the terminal modes to a \*(``sane\*('' state,
 .RS
 .bP
-set cooked and echo modes,
+enabling cooked and echo modes,
 .bP
-turn off cbreak and raw modes,
+disabling cbreak and raw modes,
 .bP
-turn on newline translation and
+enabling newline translation,
+and
 .bP
-reset any unset special characters to their default values
+setting any unset special characters to their default values.
 .RE
 .TP 5
 (2)
-Instead of putting out \fIinitialization\fP strings, the terminal's
-\fIreset\fP strings will be output if present
-(\fBrs1\fR, \fBrs2\fR, \fBrs3\fR, \fBrf\fR).
-If the \fIreset\fP strings are not present, but \fIinitialization\fP
-strings are, the \fIinitialization\fP strings will be output.
+If any reset capabilities are defined for the terminal type,
+\fB\%@TPUT@\fP writes them to the output stream.
+Otherwise,
+\fB\%@TPUT@\fP uses any defined initialization capabilities.
+Reset capabilities are detailed in subsection
+\*(``Tabs and Initialization\*('' of \fB\%terminfo\fP(5).
 .RE
-.IP
-Otherwise, \fBreset\fR acts identically to \fBinit\fR.
 .TP
-\fBlongname\fR
-If the terminal database is present and an entry for the
-user's terminal exists (see \fB\-T\fR\fItype\fR above), then the long name
-of the terminal will be put out.
-The long name is the last
-name in the first line of the terminal's description in the
-\fBterminfo\fR database [see \fBterm\fR(5)].
-.SS Aliases
-\fB@TPUT@\fR handles the \fBclear\fP, \fBinit\fP and \fBreset\fP
-commands specially:
-it allows for the possibility that it is invoked by a link with those names.
-.PP
-If \fB@TPUT@\fR is invoked by a link named \fBreset\fR, this has the
-same effect as \fB@TPUT@ reset\fR.
-The \fB@TSET@\fR(\*n) utility also treats a link named \fBreset\fP specially.
-.PP
-Before ncurses 6.1, the two utilities were different from each other:
-.bP
-\fB@TSET@\fP utility reset the terminal modes and special characters
-(not done with \fB@TPUT@\fP).
-.bP
-On the other hand, \fB@TSET@\fP's repertoire of terminal capabilities for
-resetting the terminal was more limited,
-i.e., only \fBreset_1string\fP, \fBreset_2string\fP and \fBreset_file\fP
-in contrast to the tab-stops and margins which are set by this utility.
-.bP
-The \fBreset\fP program is usually an alias for \fB@TSET@\fP,
-because of this difference with resetting terminal modes and special characters.
-.PP
-With the changes made for ncurses 6.1, the \fIreset\fP feature of the
-two programs is (mostly) the same.
-A few differences remain:
-.bP
-The \fB@TSET@\fP program waits one second when resetting,
-in case it happens to be a hardware terminal.
-.bP
-The two programs write the terminal initialization strings
-to different streams (i.e., the standard error for \fB@TSET@\fP and the
-standard output for \fB@TPUT@\fP).
+.B longname
+A
+.I \%term\%info
+entry begins with one or more names by which an application
+can refer to the entry,
+before the list of terminal capabilities.
+The names are separated by \*(``|\*('' characters.
+X/Open Curses terms the last name the \*(``long name\*('',
+and indicates that it may include blanks.
+.IP
+\fB\%@TIC@\fP warns if the last name does not include blanks,
+to accommodate old
+.I \%term\%info
+entries that treated the long name as an optional feature.
+The long name is often referred to as the description field.
 .IP
-\fBNote:\fP although these programs write to different streams,
-redirecting their output to a file will capture only part of their actions.
-The changes to the terminal modes are not affected by redirecting the output.
+If the terminal database is present and an entry for the user's terminal
+type exists,
+\fB\%@TPUT@\fP reports its description to the standard output stream,
+without a trailing newline.
+See \fB\%terminfo\fP(5).
 .PP
-If \fB@TPUT@\fR is invoked by a link named \fBinit\fR, this has the
-same effect as \fB@TPUT@ init\fR.
-Again, you are less likely to use that link because another program
-named \fBinit\fP has a more well-established use.
-.SS Terminal Size
+.I Note:
+Redirecting the output of
+.RB \%\*(`` "@TPUT@ init" \*(''
+or
+.RB \%\*(`` "@TPUT@ reset" \*(''
+to a file will capture only part of their actions.
+Changes to the terminal modes are not affected by file descriptor
+redirection,
+since the terminal modes are altered via \fB\%ioctl\fP(2).
+.SS Aliases
+If \fB\%@TPUT@\fP is invoked via link with any of the names
+.BR clear ,
+.BR init ,
+or
+.BR \%reset ,
+it operates as if run with the corresponding (pseudo-)capability
+operand.
+For example,
+executing a link named
+.B \%reset
+that points to \fB\%@TPUT@\fP has the same effect as
+.RB \%\*(`` "@TPUT@ \%reset" \*(''.
 .PP
-Besides the special commands (e.g., \fBclear\fP),
-@TPUT@ treats certain terminfo capabilities specially:
-\fBlines\fP and \fBcols\fP.
-@TPUT@ calls \fBsetupterm\fP(3X) to obtain the terminal size:
+This feature was introduced by
+.I \%ncurses
+5.2 in 2000.
+It is rarely used:
+.TP
+.B \%clear
+is a separate program,
+which is both smaller and more frequently executed.
+.TP
+.B init
+has the same name as another program in widespread use.
+.TP
+.B \%reset
+is provided
+by the \fB\%@TSET@\fP(1) utility (also via a link named
+.BR \%reset ")."
+.SS "Terminal Size"
+Besides the pseudo-capabilities
+(such as
+.BR init ),
+\fB\%@TPUT@\fP treats the
+.B lines
+and
+.B cols
+.I cap-codes
+specially:
+it may call \fB\%setupterm\fP(3X) to obtain the terminal size.
 .bP
-first, it gets the size from the terminal database
-(which generally is not provided for terminal emulators
-which do not have a fixed window size)
+First,
+\fB\%@TPUT@\fP attempts to obtain these capabilities from the terminal
+database.
+This generally fails for terminal emulators,
+which lack a fixed window size and thus omit the capabilities.
 .bP
-then it asks the operating system for the terminal's size
-(which generally works, unless connecting via a serial line which
-does not support \fINAWS\fP: negotiations about window size).
+It then asks the operating system for the terminal's size,
+which generally works,
+unless the connection is via a serial line that
+does not support \*(``NAWS\*('': negotiations about window size.
 .bP
-finally, it inspects the environment variables \fBLINES\fP and \fBCOLUMNS\fP
+Finally,
+it inspects the environment variables
+.I LINES
+and
+.IR \%COLUMNS ,
 which may override the terminal size.
 .PP
-If the \fB\-T\fP option is given
-@TPUT@ ignores the environment variables by calling \fBuse_tioctl(TRUE)\fP,
-relying upon the operating system (or finally, the terminal database).
-.SH EXAMPLES
-.TP 5
-\fB@TPUT@ init\fR
-Initialize the terminal according to the type of
-terminal in the environmental variable \fBTERM\fR.  This
-command should be included in everyone's .profile after
-the environmental variable \fBTERM\fR has been exported, as
-illustrated on the \fBprofile\fR(5) manual page.
-.TP 5
-\fB@TPUT@ \-T5620 reset\fR
-Reset an AT&T 5620 terminal, overriding the type of
-terminal in the environmental variable \fBTERM\fR.
-.TP 5
-\fB@TPUT@ cup 0 0\fR
-Send the sequence to move the cursor to row \fB0\fR, column \fB0\fR
-(the upper left corner of the screen, usually known as the \*(``home\*(''
-cursor position).
-.TP 5
-\fB@TPUT@ clear\fR
-Echo the clear-screen sequence for the current terminal.
-.TP 5
-\fB@TPUT@ cols\fR
-Print the number of columns for the current terminal.
-.TP 5
-\fB@TPUT@ \-T450 cols\fR
-Print the number of columns for the 450 terminal.
-.TP 5
-\fBbold=`@TPUT@ smso` offbold=`@TPUT@ rmso`\fR
-Set the shell variables \fBbold\fR, to begin stand-out mode
-sequence, and \fBoffbold\fR, to end standout mode sequence,
-for the current terminal.
-This might be followed by a
-prompt: \fBecho "${bold}Please type in your name: ${offbold}\\c"\fR
-.TP 5
-\fB@TPUT@ hc\fR
-Set exit code to indicate if the current terminal is a hard copy terminal.
-.TP 5
-\fB@TPUT@ cup 23 4\fR
-Send the sequence to move the cursor to row 23, column 4.
-.TP 5
-\fB@TPUT@ cup\fR
-Send the terminfo string for cursor-movement, with no parameters substituted.
-.TP 5
-\fB@TPUT@ longname\fR
-Print the long name from the \fBterminfo\fR database for the
-type of terminal specified in the environmental
-variable \fBTERM\fR.
-.PP
-.RS 5
-\fB@TPUT@ \-S <<!\fR
-.br
-\fB> clear\fR
-.br
-\fB> cup 10 10\fR
-.br
-\fB> bold\fR
-.br
-\fB> !\fR
-.RE
-.TP 5
-\&
-This example shows \fB@TPUT@\fR processing several capabilities
-in one invocation.
-It clears the screen,
-moves the cursor to position 10, 10
-and turns on bold (extra bright) mode.
-The list is terminated by an exclamation mark (\fB!\fR) on a line by itself.
-.SH FILES
-.TP
-\fB\*d\fR
-compiled terminal description database
-.TP
-\fB@DATADIR@/tabset/*\fR
-tab settings for some terminals, in a format
-appropriate to be output to the terminal (escape
-sequences that set margins and tabs); for more
-information, see the
-.IR "Tabs and Initialization" ,
-section of \fBterminfo\fR(5)
-.SH EXIT CODES
-If the \fB\-S\fR option is used,
-\fB@TPUT@\fR checks for errors from each line,
-and if any errors are found, will set the exit code to 4 plus the
-number of lines with errors.
-If no errors are found, the exit code is \fB0\fR.
-No indication of which line failed can be given so
-exit code \fB1\fR will never appear.
-Exit codes \fB2\fR, \fB3\fR, and
-\fB4\fR retain their usual interpretation.
-If the \fB\-S\fR option is not used,
-the exit code depends on the type of \fIcapname\fR:
-.RS 3
-.TP
-.I boolean
-a value of \fB0\fR is set for TRUE and \fB1\fR for FALSE.
+If the
+.B \-T
+option is given,
+\fB\%@TPUT@\fP ignores the environment variables by calling
+.BR \%use_tioctl(TRUE) ,
+relying upon the operating system
+(or,
+ultimately,
+the terminal database).
+.SH OPTIONS
+.TP 9n \" "-T type" + 2n
+.B \-S
+retrieves more than one capability per invocation of \fB\%@TPUT@\fP.
+The capabilities must be passed to \fB\%@TPUT@\fP from the standard
+input stream instead of from the command line
+(see section \*(``EXAMPLES\*('' below).
+Only one
+.I cap-code
+is allowed per line.
+The
+.B \-S
+option changes the meanings of the
+.B 0
+and
+.B 1
+exit statuses
+(see section \*(``EXIT STATUS\*('' below).
+.IP
+Some capabilities use string parameters rather than numeric ones.
+\fB\%@TPUT@\fP employs a built-in table and the presence of parameters
+in its input to decide how to interpret them,
+and whether to use \fB\%tparm\fP(3X).
 .TP
-.I string
-a value of \fB0\fR is set if the
-\fIcapname\fR is defined for this terminal \fItype\fR (the value of
-\fIcapname\fR is returned on standard output);
-a value of \fB1\fR is set if \fIcapname\fR
-is not defined for this terminal \fItype\fR
-(nothing is written to standard output).
+.BI \-T\  type
+indicates the terminal's
+.IR type .
+Normally this option is unnecessary,
+because a default is taken from the
+.I TERM
+environment variable.
+If specified,
+the environment variables
+.I LINES
+and
+.I \%COLUMNS
+are also ignored.
 .TP
-.I integer
-a value of \fB0\fR is always set,
-whether or not \fIcapname\fR is defined for this terminal \fItype\fR.
-To determine if \fIcapname\fR is defined for this terminal \fItype\fR,
-the user must test the value written to standard output.
-A value of \fB\-1\fR
-means that \fIcapname\fR is not defined for this terminal \fItype\fR.
+.B \-V
+reports the version of
+.I \%ncurses
+associated with \fB\%@TPUT@\fP,
+and exits with a successful status.
 .TP
-.I other
-\fBreset\fR or \fBinit\fR may fail to find their respective files.
-In that case, the exit code is set to 4 + \fBerrno\fR.
-.RE
-.PP
-Any other exit code indicates an error; see the DIAGNOSTICS section.
-.SH DIAGNOSTICS
-\fB@TPUT@\fR prints the following error messages and sets the corresponding exit
-codes.
+.B \-x
+prevents
+.RB \%\*(`` "@TPUT@ clear" \*(''
+from attempting to clear the scrollback buffer.
+.SH EXIT STATUS
+Normally,
+one should interpret \fB\%@TPUT@\fP's exit statuses as follows.
 .PP
-.ne 15
+.if n .ne 3
+.if t .ne 2
 .TS
-l l.
-exit code	error message
-=
-\fB0\fR	T{
-(\fIcapname\fR is a numeric variable that is not specified in the
-\fBterminfo\fR(5) database for this terminal type, e.g.
-\fB@TPUT@ \-T450 lines\fR and \fB@TPUT@ \-T2621 xmc\fR)
-T}
-\fB1\fR	no error message is printed, see the \fBEXIT CODES\fR section.
-\fB2\fR	usage error
-\fB3\fR	unknown terminal \fItype\fR or no \fBterminfo\fR database
-\fB4\fR	unknown \fBterminfo\fR capability \fIcapname\fR
-\fB>4\fR	error occurred in \-S
-=
+Lb Lb
+Lb Lx.
+Status	Meaning When \-S Not Specified
+_
+0	Boolean or string capability present
+1	Boolean or numeric capability absent
+2	usage error or no terminal type specified
+3	unrecognized terminal type
+4	unrecognized capability code
+>4	system error (4 + \fBerrno\fP)
 .TE
-.SH HISTORY
-The \fBtput\fP command was begun by Bill Joy in 1980.
-The initial version only cleared the screen.
-.PP
-AT&T System V provided a different \fBtput\fP command,
-whose \fBinit\fP and \fBreset\fP  subcommands
-(more than half the program) were incorporated from
-the \fBreset\fP feature of BSD \fBtset\fP written by Eric Allman.
-.PP
-Keith Bostic replaced the BSD \fBtput\fP command in 1989
-with a new implementation
-based on the AT&T System V program \fBtput\fP.
-Like the AT&T program, Bostic's version
-accepted some parameters named for \fIterminfo capabilities\fP
-(\fBclear\fP, \fBinit\fP, \fBlongname\fP and \fBreset\fP).
-However (because he had only termcap available),
-it accepted \fItermcap names\fP for other capabilities.
-Also, Bostic's BSD \fBtput\fP did not modify the terminal I/O modes
-as the earlier BSD \fBtset\fP had done.
 .PP
-At the same time, Bostic added a shell script named \*(``clear\*('',
-which used \fBtput\fP to clear the screen.
+When the
+.B \-S
+option is used,
+some statuses change meanings.
 .PP
-Both of these appeared in 4.4BSD,
-becoming the \*(``modern\*('' BSD implementation of \fBtput\fP.
-.PP
-This implementation of \fBtput\fP began from a different source than
-AT&T or BSD: Ross Ridge's \fImytinfo\fP package, published on
-\fIcomp.sources.unix\fP in December 1992.
-Ridge's program made more sophisticated use of the terminal capabilities
-than the BSD program.
-Eric Raymond used that \fBtput\fP program
-(and other parts of \fImytinfo\fP) in ncurses in June 1995.
-Using the portions dealing with terminal capabilities
-almost without change,
-Raymond made improvements to the way the command-line parameters
-were handled.
+.if n .ne 4
+.if t .ne 3
+.TS
+Lb Lb
+Lb Lx.
+Status	Meaning When \-S Specified
+_
+0	all operands interpreted
+1	unused
+4	some operands not interpreted
+.TE
+.SH ENVIRONMENT
+\fB@TPUT@\fP reads one environment variable.
+.TP 8n \" "TERM" + 2n + adjustment for PDF
+.I TERM
+denotes the terminal type.
+Each terminal type is distinct,
+though many are similar.
+The
+.B \-T
+option overrides its value.
+.SH FILES
+.TP
+.I @DATADIR@/tabset
+tab stop initialization database
+.TP
+.I \*d
+compiled terminal description database
 .SH PORTABILITY
-.PP
-This implementation of \fBtput\fP differs from AT&T \fBtput\fP in
-two important areas:
+Over time
+.I \%ncurses
+\fB\%@TPUT@\fP
+has differed from that of System\ V in two important respects,
+one now mostly historical.
 .bP
-\fB@TPUT@\fP \fIcapname\fP writes to the standard output.
-That need not be a regular terminal.
-However, the subcommands which manipulate terminal modes
-may not use the standard output.
+\%\*(``\fB@TPUT@\fP
+.IR cap-code \*(''
+writes to the standard output,
+which need not be a terminal device.
+However,
+the operands that manipulate terminal modes might not use the standard
+output.
 .IP
-The AT&T implementation's \fBinit\fP and \fBreset\fP commands
-use the BSD (4.1c) \fBtset\fP source, which manipulates terminal modes.
-It successively tries standard output, standard error, standard input
-before falling back to \*(``/dev/tty\*('' and finally just assumes
-a 1200Bd terminal.
-When updating terminal modes, it ignores errors.
+System\ V
+.BR tput 's
+.B init
+and
+.B \%reset
+operands use logic from 4.1cBSD
+.BR tset ,
+manipulating terminal modes.
+It checks the same file descriptors
+(and
+.IR \%/dev/tty )
+for association with a terminal device as
+.I \%ncurses
+now does,
+and if none are,
+finally assumes a 1200 baud terminal.
+When updating terminal modes,
+it ignores errors.
 .IP
-Until changes made after ncurses 6.0,
-\fB@TPUT@\fP did not modify terminal modes.
-\fB@TPUT@\fP now uses a similar scheme,
-using functions shared with \fB@TSET@\fP
-(and ultimately based on the 4.4BSD \fBtset\fP).
-If it is not able to open a terminal, e.g., when running in \fBcron\fP,
-\fB@TPUT@\fP will return an error.
-.bP
-AT&T \fBtput\fP guesses the type of its \fIcapname\fP operands by seeing if
-all of the characters are numeric, or not.
+Until
+.I \%ncurses
+6.1
+(see section \*(``HISTORY\*('' below),
+\fB\%@TPUT@\fP did not modify terminal modes.
+It now employs a scheme similar to System\ V,
+using functions shared with \fB\%@TSET@\fP
+(and ultimately based on 4.4BSD
+.BR tset ).
+If it is not able to open a terminal
+(for instance,
+when run by \fIcron\fP(1)),
+\fB\%@TPUT@\fP exits with an error status.
+.bP
+System\ V
+.B tput
+assumes that the type of a
+.I cap-code
+operand is numeric if all the characters of its value are decimal
+numbers;
+if they are not,
+it treats
+.I cap-code
+as a string capability.
 .IP
-Most implementations which provide support for \fIcapname\fR operands
-use the \fItparm\fP function to expand parameters in it.
+Most implementations that provide support for
+.I cap-code
+operands use the \fB\%tparm\fP(3X) function to expand its parameters.
 That function expects a mixture of numeric and string parameters,
-requiring \fB@TPUT@\fP to know which type to use.
+requiring \fB\%@TPUT@\fP to know which type to use.
+.IP
+.I \%ncurses
+\fB\%@TPUT@\fP
+uses a table to determine the parameter types for
+the standard
+.I cap-code
+operands,
+and an internal function to analyze nonstandard
+.I cap-code
+operands.
 .IP
-This implementation uses a table to determine the parameter types for
-the standard \fIcapname\fR operands, and an internal library
-function to analyze nonstandard \fIcapname\fR operands.
+While more reliable than System\ V's utility,
+a portability problem is introduced by this analysis.
+An OpenBSD developer adapted the internal library function from
+.I \%ncurses
+to port NetBSD's
+.IR termcap -based
+.B tput
+to
+.IR \%term\%info ,
+and modified it to interpret multiple
+.I cap-codes
+(and parameters)
+on the command line.
+Portable applications should not rely upon this feature;
+.I \%ncurses
+offers it to support applications written specifically for OpenBSD.
 .PP
-This implementation (unlike others) can accept both \fItermcap\fP
-and \fIterminfo\fP names for the \fIcapname\fP feature,
+This implementation,
+unlike others,
+accepts both
+.I termcap
+and
+.I \%term\%info
+.I cap-codes
 if
-\fItermcap\fR support is compiled in.
-However, the predefined \fItermcap\fP and \fIterminfo\fP names have two
-ambiguities in this case (and the \fIterminfo\fP name is assumed):
-.bP
-The \fItermcap\fP name \fBdl\fP corresponds to
-the \fIterminfo\fP name \fBdl1\fP (delete one line).
-.br
-The \fIterminfo\fP name \fBdl\fP corresponds to
-the \fItermcap\fP name \fBDL\fP (delete a given number of lines).
-.bP
-The \fItermcap\fP name \fBed\fP corresponds to
-the \fIterminfo\fP name \fBrmdc\fP (end delete mode).
-.br
-The \fIterminfo\fP name \fBed\fP corresponds to
-the \fItermcap\fP name \fBcd\fP (clear to end of screen).
+.I termcap
+support is compiled in.
+In that case,
+however,
+the predefined
+.I termcap
+and
+.I \%term\%info
+codes have two
+ambiguities;
+.I \%ncurses
+assumes the
+.I \%term\%info
+code.
+.bP
+The
+.I cap-code
+.B dl
+means
+.B \%delete_line
+to
+.I termcap
+but
+.B \%parm_delete_line
+to
+.IR \%term\%info .
+.I termcap
+uses the code
+.B DL
+for
+.BR \%parm_delete_line .
+.I \%term\%info
+uses the code
+.B dl1
+for
+.BR \%delete_line .
+.bP
+The
+.I cap-code
+.B ed
+means
+.B \%exit_delete_mode
+to
+.I termcap
+but
+.B \%clr_eos
+to
+.IR \%term\%info .
+.I termcap
+uses the code
+.B cd
+for
+.BR \%clr_eos .
+.I \%term\%info
+uses the code
+.B rmdc
+for
+.BR \%exit_delete_mode .
 .PP
-The \fBlongname\fR and \fB\-S\fR options, and the parameter-substitution
-features used in the \fBcup\fR example,
-were not supported in BSD curses before 4.3reno (1989) or in
-AT&T/USL curses before SVr4 (1988).
+The
+.B \%longname
+operand,
+.B \-S
+option,
+and the parameter-substitution features used in the
+.B cup
+example below,
+were not supported in
+AT&T/USL
+.I curses
+before SVr4 (1989).
+Later,
+4.3BSD-Reno (1990) added support for
+.BR \%longname ,
+.\" longname was added in October 1989.
+and in 1994,
+NetBSD added support for the parameter-substitution features.
 .PP
-IEEE Std 1003.1/The Open Group  Base Specifications Issue 7 (POSIX.1-2008) 
-documents only the operands for \fBclear\fP, \fBinit\fP and \fBreset\fP.
-There are a few interesting observations to make regarding that:
-.bP
-In this implementation, \fBclear\fP is part of the \fIcapname\fR support.
-The others (\fBinit\fP and \fBlongname\fP) do not correspond to terminal
-capabilities.
-.bP
-Other implementations of \fBtput\fP on
-SVr4-based systems such as Solaris, IRIX64 and HPUX
-as well as others such as AIX and Tru64
-provide support for \fIcapname\fR operands.
-.bP
-A few platforms such as FreeBSD recognize termcap names rather
-than terminfo capability names in their respective \fBtput\fP commands.
-Since 2010, NetBSD's \fBtput\fP uses terminfo names.
-Before that, it (like FreeBSD) recognized termcap names.
+IEEE Std 1003.1/The Open Group Base Specifications Issue 7
+(POSIX.1-2008)
+documents only the
+.BR clear ,
+.BR init ,
+and
+.B \%reset
+operands.
+A few observations of interest arise from that selection.
+.bP
+.I \%ncurses
+supports
+.B clear
+as it does any other standard
+.IR cap-code .
+The others
+.RB ( init
+and
+.BR \%longname )
+do not correspond to terminal capabilities.
+.bP
+The
+.B tput
+on SVr4-based systems such as Solaris,
+IRIX64,
+and HP-UX,
+as well as others such as AIX and Tru64,
+also support standard
+.I cap-code
+operands.
+.bP
+A few platforms such as FreeBSD recognize
+.I termcap
+codes rather than
+.I \%term\%info
+capability codes in their respective
+.B tput
+commands.
+Since 2010,
+NetBSD's
+.B tput
+uses
+.I \%term\%info
+codes.
+Before that,
+it
+(like FreeBSD)
+recognized
+.I termcap
+codes.
+.IP
+Beginning in 2021,
+FreeBSD uses
+.I \%ncurses
+.BR tput ,
+configured for both
+.I \%term\%info
+(tested first)
+and
+.I termcap
+(as a fallback).
 .PP
-Because (apparently) \fIall\fP of the certified Unix systems
-support the full set of capability names, the reasoning for documenting
-only a few may not be apparent.
+Because (apparently) all
+.I certified
+Unix systems support the full set of capability codes,
+the reason for documenting only a few may not be apparent.
 .bP
-X/Open Curses Issue 7 documents \fBtput\fP differently, with \fIcapname\fP
+X/Open Curses Issue 7 documents
+.B tput
+differently,
+with
+.I cap-code
 and the other features used in this implementation.
 .bP
-That is, there are two standards for \fBtput\fP:
+That is,
+there are two standards for
+.BR tput :
 POSIX (a subset) and X/Open Curses (the full implementation).
-POSIX documents a subset to avoid the complication of including X/Open Curses
-and the terminal capabilities database.
+POSIX documents a subset to avoid the complication of including
+X/Open Curses and the terminal capability database.
 .bP
-While it is certainly possible to write a \fBtput\fP program
-without using curses,
-none of the systems which have a curses implementation provide
-a \fBtput\fP utility which does not provide the \fIcapname\fP feature.
+While it is certainly possible to write a
+.B tput
+program without using
+.IR curses ,
+no system with a
+.I curses
+implementation provides a
+.B tput
+utility that does not also support standard
+.IR cap-codes .
 .PP
 X/Open Curses Issue 7 (2009) is the first version to document utilities.
 However that part of X/Open Curses does not follow existing practice
-(i.e., Unix features documented in SVID 3):
+(that is,
+System\ V
+.I curses
+behavior).
 .bP
-It assigns exit code 4 to \*(``invalid operand\*('',
-which may be the same as \fIunknown capability\fP.
-For instance, the source code for Solaris' xcurses uses the term
-\*(``invalid\*('' in this case.
+It assigns exit status 4 to \*(``invalid operand\*('',
+which may have the same meaning as \*(``unknown capability\*(''.
+For instance,
+the source code for
+Solaris
+.I xcurses
+uses the term \*(``invalid\*('' in this case.
 .bP
-It assigns exit code 255 to a numeric variable that is not specified in
-the terminfo database.
+It assigns exit status 255 to a numeric variable that is not specified
+in the
+.I \%term\%info
+database.
 That likely is a documentation error,
-confusing the \fB\-1\fP written to the standard output for an absent
-or cancelled numeric value versus an (unsigned) exit code.
+mistaking the \*(``\-1\*('' written to the standard output to indicate
+an absent or cancelled numeric capability for an (unsigned) exit status.
 .PP
-The various Unix systems (AIX, HPUX, Solaris) use the same exit-codes
-as ncurses.
+The various System\ V implementations
+(AIX,
+HP-UX,
+Solaris)
+use the same exit statuses as
+.IR \%ncurses .
 .PP
-NetBSD curses documents different exit codes which do not correspond
-to either ncurses or X/Open.
-.SH SEE ALSO
-\fB@CLEAR@\fR(\*n),
-\fBstty\fR(1),
-\fB@TABS@\fR(\*n),
-\fB@TSET@\fR(\*n),
-\fBcurs_termcap\fR(3X),
-\fBterminfo\fR(5).
+NetBSD
+.I curses
+documents exit statuses that correspond to neither
+.I \%ncurses
+nor X/Open Curses.
+.SH HISTORY
+Bill Joy wrote a
+.B tput
+command during development of 4BSD in October 1980.
+This initial version only cleared the screen,
+and did not ship with official distributions.
+.\" It also exited with backwards exit status (1 on success, 0 on
+.\" failure), and was characterized by Bostic in 1988 as "pretty
+.\" unreasonable".
+.\" See Spinellis's "unix-history-repo" on GitHub.
 .PP
-This describes \fBncurses\fR
-version @NCURSES_MAJOR@.@NCURSES_MINOR@ (patch @NCURSES_PATCH@).
+System\ V developed a different
+.B tput
+command.
+.bP
+SVr2 (1984) provided a rudimentary
+.B tput
+that checked the parameter against each
+predefined capability and returned the corresponding value.
+This version of
+.B tput
+did not use \fB\%tparm\fP(3X) for parameterized capabilities.
+.bP
+SVr3 (1987) replaced that
+.\" SVr3 released in 1987, not 1985.
+.\" https://unix.org/what_is_unix/history_timeline.html
+with a more extensive program
+whose support for
+.B init
+and
+.B \%reset
+operands
+(more than half the program)
+incorporated the
+.B \%reset
+feature of BSD
+.B tset
+written by Eric Allman.
+.bP
+SVr4 (1989) added color initialization by using the
+.B \%orig_colors
+.RB ( oc )
+and
+.B \%orig_pair
+.RB ( op )
+capabilities in its
+.B init
+logic.
+.PP
+Keith Bostic refactored BSD
+.B tput
+for shipment in 4.3BSD-Tahoe (1988),
+then replaced it the next year with a new implementation based on
+System\ V
+.BR tput .
+Bostic's version similarly accepted some parameters named for
+.I \%term\%info
+(pseudo-)capabilities:
+.BR clear ,
+.BR init ,
+.BR \%longname ,
+and
+.BR \%reset .
+However,
+because he had only
+.I termcap
+available,
+it accepted
+.I termcap
+codes for other capabilities.
+Also,
+Bostic's BSD
+.B tput
+did not modify the terminal modes as the earlier BSD
+.B tset
+had done.
+.PP
+At the same time,
+Bostic added a shell script named \*(``clear\*('' that used
+.B tput
+to clear the screen.
+Both of these appeared in 4.4BSD,
+becoming the \*(``modern\*('' BSD implementation of
+.BR tput .
+.PP
+The origin of
+.I \%ncurses
+\fB\%@TPUT@\fP lies outside both System\ V and BSD,
+in Ross Ridge's
+.I \%mytinfo
+package,
+published on
+.I comp.sources.unix
+in December 1992.
+Ridge's program made more sophisticated use of the terminal capabilities
+than the BSD program.
+Eric Raymond used that
+.B tput
+program
+(and other parts of
+.IR \%mytinfo )
+in
+.I \%ncurses
+in June 1995.
+Incorporating the portions dealing with terminal capabilities
+almost without change,
+Raymond made improvements to the way command-line parameters
+were handled.
+.PP
+Before
+.I \%ncurses
+6.1 (2018),
+its \fB\%@TSET@\fP and \fB\%@TPUT@\fP utilities differed.
+.bP
+\fB\%@TSET@\fP was more effective,
+resetting the terminal modes and special characters.
+.bP
+On the other hand,
+\fB\%@TSET@\fP's repertoire of terminal capabilities for resetting the
+terminal was more limited;
+it had only equivalents of
+.B \%reset_1string
+.RB ( rs1 ),
+.B \%reset_2string
+.RB ( rs2 ),
+and
+.B \%reset_file
+.RB ( rf ),
+and not the tab stop and margin update features of \fB\%@TPUT@\fP.
+.PP
+The
+.B \%reset
+program is traditionally an alias for \fB\%@TSET@\fP due to its ability
+to reset terminal modes and special characters.
+.PP
+As of
+.I \%ncurses
+6.1,
+the \*(``reset\*('' features of the two programs are (mostly) the same.
+Two minor differences remain.
+.bP
+The \fB\%@TSET@\fP program waits one second when resetting,
+in case the terminal happens to be a hardware device.
+.bP
+The two programs write the terminal initialization strings
+to different streams;
+that is,
+standard error for \fB\%@TSET@\fP and
+standard output for \fB\%@TPUT@\fP.
+.SH EXAMPLES
+.TP
+.B "@TPUT@ init"
+Initialize the terminal according to the type of
+terminal in the
+.I TERM
+environment variable.
+If the system does not reliably initialize the terminal upon login,
+this command can be included in
+.I \%$HOME/.profile
+after exporting the
+.I TERM
+environment variable.
+.TP
+.B "@TPUT@ \-T5620 reset"
+Reset an AT&T 5620 terminal,
+overriding the terminal type in the
+.I TERM
+environment variable.
+.TP
+.B "@TPUT@ cnorm"
+Set cursor to normal visibility.
+.TP
+.B "@TPUT@ home"
+Move the cursor to row 0,
+column 0:
+the upper left corner of the screen,
+usually known as the \*(``home\*('' cursor position.
+.TP
+.B "@TPUT@ clear"
+Clear the screen:
+write the
+.B \%clear_screen
+capability's value to the standard output stream.
+.TP
+.B "@TPUT@ cols"
+Report the number of columns used by the current terminal type.
+.TP
+.B "@TPUT@ \-Tadm3a cols"
+Report the number of columns used by an ADM-3A terminal.
+.TP
+.B "strong=\(ga@TPUT@ smso\(ga normal=\(ga@TPUT@ rmso\(ga"
+Set shell variables to capability values:
+.B strong
+and
+.BR normal ,
+to begin and end,
+respectively,
+stand-out mode for the terminal.
+One might use these to present a prompt.
+.IP
+.EX
+.RS 14
+printf "${strong}Username:${normal} "
+.RE
+.EE
+.TP
+.B "@TPUT@ hc"
+Indicate via exit status whether the terminal is a hard copy device.
+.TP
+.B "@TPUT@ cup 23 4"
+Move the cursor to row 23,
+column 4.
+.TP
+.B "@TPUT@ cup"
+Report the value of the
+.B \%cursor_address
+.RB ( cup )
+capability
+(used for cursor movement),
+with no parameters substituted.
+.TP
+.B "@TPUT@ longname"
+Report the
+.I \%term\%info
+database's description of the terminal type specified in the
+.I TERM
+environment variable.
+.TP
+.B "@TPUT@ \-S"
+Process multiple capabilities.
+The
+.B \-S
+option can be profitably used with a shell \*(``here document\*(''.
+.IP
+.EX
+.RB $\  "@TPUT@ \-S <<!"
+.RB >\  clear
+.RB >\  "cup 10 10"
+.RB >\  bold
+.RB >\  !
+.EE
+.IP
+The foregoing
+clears the screen,
+moves the cursor to position
+(10, 10)
+and turns on bold
+(extra bright)
+mode.
+.TP
+.B "@TPUT@ clear cup 10 10 bold"
+Perform the same actions as the foregoing
+.RB \%\*(`` "@TPUT@ \-S" \*(''
+example.
+.SH SEE ALSO
+\fB\%@CLEAR@\fP(1),
+\fB\%stty\fP(1),
+\fB\%@TABS@\fP(1),
+\fB\%@TSET@\fP(1),
+\fB\%curs_termcap\fP(3X),
+\fB\%terminfo\fP(5)
diff --git a/contrib/ncurses/man/tset.1 b/contrib/ncurses/man/tset.1
index 65b1ef229967..185227dcdb03 100644
--- a/contrib/ncurses/man/tset.1
+++ b/contrib/ncurses/man/tset.1
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,27 +27,40 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: tset.1,v 1.55 2020/02/02 23:34:34 tom Exp $
-.TH @TSET@ 1 ""
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
+.\" $Id: tset.1,v 1.85 2024/04/27 17:57:47 tom Exp $
+.TH @TSET@ 1 2024-04-27 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "User commands"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.ds ^  \(ha
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.ds       ^  ^
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
+.
+.ds d @TERMINFO@
 .SH NAME
-\fB@TSET@\fR, \fB@RESET@\fR \- terminal initialization
+\fB\%@TSET@\fP,
+\fB\%@RESET@\fP \-
+initialize or reset terminal state
 .SH SYNOPSIS
-\fB@TSET@\fR [\fB\-IQVcqrsw\fR] [\fB\-\fR] [\fB\-e\fR \fIch\fR] [\fB\-i\fR \fIch\fR] [\fB\-k\fR \fIch\fR] [\fB\-m\fR \fImapping\fR] [\fIterminal\fR]
+\fB@TSET@\fP [\fB\-IQVcqrsw\fP] [\fB\-\fP] [\fB\-e\fP \fIch\fP] [\fB\-i\fP \fIch\fP] [\fB\-k\fP \fIch\fP] [\fB\-m\fP \fImapping\fP] [\fIterminal-type\fP]
 .br
-\fB@RESET@\fR [\fB\-IQVcqrsw\fR] [\fB\-\fR] [\fB\-e\fR \fIch\fR] [\fB\-i\fR \fIch\fR] [\fB\-k\fR \fIch\fR] [\fB\-m\fR \fImapping\fR] [\fIterminal\fR]
+\fB@RESET@\fP [\fB\-IQVcqrsw\fP] [\fB\-\fP] [\fB\-e\fP \fIch\fP] [\fB\-i\fP \fIch\fP] [\fB\-k\fP \fIch\fP] [\fB\-m\fP \fImapping\fP] [\fIterminal-type\fP]
 .SH DESCRIPTION
-.SS tset - initialization
+.SS "\fItset\fP \(em initialization"
 This program initializes terminals.
 .PP
-First, \fB@TSET@\fR retrieves the current terminal mode settings
+First, \fB@TSET@\fP retrieves the current terminal mode settings
 for your terminal.
 It does this by successively testing
 .bP
@@ -66,22 +79,22 @@ file descriptor to use when updating settings.
 Next, \fB@TSET@\fP determines the type of terminal that you are using.
 This determination is done as follows, using the first terminal type found.
 .PP
-1. The \fBterminal\fR argument specified on the command line.
+1. The \fBterminal\fP argument specified on the command line.
 .PP
-2. The value of the \fBTERM\fR environmental variable.
+2. The value of the \fITERM\fP environment variable.
 .PP
 3. (BSD systems only.) The terminal type associated with the standard
-error output device in the \fI/etc/ttys\fR file.
-(On System\-V-like UNIXes and systems using that convention,
-\fIgetty\fR does this job by setting
-\fBTERM\fR according to the type passed to it by \fI/etc/inittab\fR.)
+error output device in the \fI/etc/ttys\fP file.
+(On System\ V hosts and systems using that convention,
+\fI\%getty\fP(8) does this job by setting
+\fITERM\fP according to the type passed to it by \fI\%/etc/inittab\fP.)
 .PP
-4. The default terminal type, \*(``unknown\*(''.
+4. The default terminal type, \*(``unknown\*('',
+is not suitable for curses applications.
 .PP
-If the terminal type was not specified on the command-line, the \fB\-m\fR
-option mappings are then applied (see the section
-.B TERMINAL TYPE MAPPING
-for more information).
+If the terminal type was not specified on the command-line, the \fB\-m\fP
+option mappings are then applied;
+see subsection \*(``Terminal Type Mapping\*(''.
 Then, if the terminal type begins with a question mark (\*(``?\*(''), the
 user is prompted for confirmation of the terminal type.
 An empty
@@ -98,8 +111,10 @@ if the \*(``\fB\-w\fP\*('' option is enabled, \fB@TSET@\fP may update
 the terminal's window size.
 .IP
 If the window size cannot be obtained from the operating system,
-but the terminal description (or environment, e.g., \fBLINES\fP
-and \fBCOLUMNS\fP variables specify this),
+but the terminal description
+(or environment,
+e.g.,
+\fILINES\fP and \fI\%COLUMNS\fP variables specify this),
 use this to set the operating system's notion of the window size.
 .bP
 if the \*(``\fB\-c\fP\*('' option is enabled,
@@ -114,9 +129,8 @@ and \fB@TSET@\fP waits one second (in case a hardware reset was issued).
 Finally, if the erase, interrupt and line kill characters have changed,
 or are not set to their default values, their values are displayed to the
 standard error output.
-.SS reset - reinitialization
-.PP
-When invoked as \fB@RESET@\fR, \fB@TSET@\fR sets the terminal
+.SS "\fIreset\fP \(em reinitialization"
+When invoked as \fB@RESET@\fP, \fB@TSET@\fP sets the terminal
 modes to \*(``sane\*('' values:
 .bP
 sets cooked and echo modes,
@@ -137,104 +151,46 @@ after a program dies leaving a terminal in an abnormal state:
 .bP
 you may have to type
 .sp
-    \fI<LF>\fP\fB@RESET@\fP\fI<LF>\fP
+    \fI<LF>\fB@RESET@\fI<LF>\fR
 .sp
 (the line-feed character is normally control-J) to get the terminal
 to work, as carriage-return may no longer work in the abnormal state.
 .bP
 Also, the terminal will often not echo the command.
-.SH OPTIONS 
-.PP
-The options are as follows:
-.TP 5
-.B \-c
-Set control characters and modes.
-.TP 5
-.B \-e
-Set the erase character to \fIch\fR.
-.TP
-.B \-I
-Do not send the terminal or tab initialization strings to the terminal.
-.TP
-.B \-i
-Set the interrupt character to \fIch\fR.
-.TP
-.B \-k
-Set the line kill character to \fIch\fR.
-.TP
-.B \-m
-Specify a mapping from a port type to a terminal.
-See the section
-.B TERMINAL TYPE MAPPING
-for more information.
-.TP
-.B \-Q
-Do not display any values for the erase, interrupt and line kill characters.
-Normally \fB@TSET@\fR displays the values for control characters which
-differ from the system's default values.
-.TP
-.B \-q
-The terminal type is displayed to the standard output, and the terminal is
-not initialized in any way.
-The option \*(``\-\*('' by itself is equivalent but archaic.
-.TP
-.B \-r
-Print the terminal type to the standard error output.
-.TP
-.B \-s
-Print the sequence of shell commands to initialize the environment variable
-\fBTERM\fR to the standard output.
-See the section
-.B SETTING THE ENVIRONMENT
-for details.
-.TP
-.B \-V
-reports the version of ncurses which was used in this program, and exits.
-.TP
-.B \-w
-Resize the window to match the size deduced via \fBsetupterm\fP(3X).
-Normally this has no effect,
-unless \fBsetupterm\fP is not able to detect the window size.
-.PP
-The arguments for the \fB\-e\fR, \fB\-i\fR, and \fB\-k\fR
-options may either be entered as actual characters
-or by using the \*(``hat\*(''
-notation, i.e., control-h may be specified as \*(``^H\*('' or \*(``^h\*(''.
-.PP
-If neither \fB\-c\fP or \fB\-w\fP is given, both options are assumed.
-.
-.SH SETTING THE ENVIRONMENT
+.SS "Setting the Environment"
 It is often desirable to enter the terminal type and information about
 the terminal's capabilities into the shell's environment.
-This is done using the \fB\-s\fR option.
+This is done using the \fB\-s\fP option.
 .PP
-When the \fB\-s\fR option is specified, the commands to enter the information
+When the \fB\-s\fP option is specified, the commands to enter the information
 into the shell's environment are written to the standard output.
-If
-the \fBSHELL\fR environmental variable ends in \*(``csh\*('', the commands
-are for \fBcsh\fR, otherwise, they are for \fBsh\fR.
-Note, the \fBcsh\fR commands set and unset the shell variable
-\fBnoglob\fR, leaving it unset.
-The following line in the \fB.login\fR
-or \fB.profile\fR files will initialize the environment correctly:
+If the \fISHELL\fP environment variable ends in \*(``csh\*('',
+the commands
+are for \fIcsh\fP(1),
+otherwise,
+they are for \fIsh\fP(1).
+The \fIcsh\fP commands set and unset the shell variable \fBnoglob\fP,
+leaving it unset.
+The following line in the \fB.login\fP
+or \fB.profile\fP files will initialize the environment correctly:
 .sp
-    eval \`@TSET@ \-s options ... \`
+    eval \(ga@TSET@ \-s options ... \(ga
 .
-.SH TERMINAL TYPE MAPPING
+.SS "Terminal Type Mapping"
 When the terminal is not hardwired into the system (or the current
 system information is incorrect) the terminal type derived from the
-\fI/etc/ttys\fR file or the \fBTERM\fR environmental variable is often
-something generic like \fBnetwork\fR, \fBdialup\fR, or \fBunknown\fR.
-When \fB@TSET@\fR is used in a startup script it is often desirable to
+\fI/etc/ttys\fP file or the \fITERM\fP environment variable is often
+something generic like \fBnetwork\fP, \fBdialup\fP, or \fBunknown\fP.
+When \fB@TSET@\fP is used in a startup script it is often desirable to
 provide information about the type of terminal used on such ports.
 .PP
-The \fB\-m\fR options maps
+The \fB\-m\fP options maps
 from some set of conditions to a terminal type, that is, to
-tell \fB@TSET@\fR
+tell \fB@TSET@\fP
 \*(``If I'm on this port at a particular speed,
 guess that I'm on that kind of terminal\*(''.
 .PP
-The argument to the \fB\-m\fR option consists of an optional port type, an
+The argument to the \fB\-m\fP option consists of an optional port type, an
 optional operator, an optional baud rate specification, an optional
 colon (\*(``:\*('') character and a terminal type.
 The port type is a
@@ -252,7 +208,7 @@ The baud rate is specified as a number and is compared with the speed
 of the standard error output (which should be the control terminal).
 The terminal type is a string.
 .PP
-If the terminal type is not specified on the command line, the \fB\-m\fR
+If the terminal type is not specified on the command line, the \fB\-m\fP
 mappings are applied to the terminal type.
 If the port type and baud
 rate match the mapping, the terminal type specified in the mapping
@@ -260,72 +216,112 @@ replaces the current type.
 If more than one mapping is specified, the
 first applicable mapping is used.
 .PP
-For example, consider the following mapping: \fBdialup>9600:vt100\fR.
+For example, consider the following mapping: \fBdialup>9600:vt100\fP.
 The port type is dialup , the operator is >, the baud rate
 specification is 9600, and the terminal type is vt100.
 The result of
-this mapping is to specify that if the terminal type is \fBdialup\fR,
+this mapping is to specify that if the terminal type is \fBdialup\fP,
 and the baud rate is greater than 9600 baud, a terminal type of
-\fBvt100\fR will be used.
+\fBvt100\fP will be used.
 .PP
 If no baud rate is specified, the terminal type will match any baud rate.
 If no port type is specified, the terminal type will match any port type.
-For example, \fB\-m dialup:vt100 \-m :?xterm\fR
+For example, \fB\-m dialup:vt100 \-m :?xterm\fP
 will cause any dialup port, regardless of baud rate, to match the terminal
 type vt100, and any non-dialup port type to match the terminal type ?xterm.
 Note, because of the leading question mark, the user will be
 queried on a default port as to whether they are actually using an xterm
 terminal.
 .PP
-No whitespace characters are permitted in the \fB\-m\fR option argument.
+No whitespace characters are permitted in the \fB\-m\fP option argument.
 Also, to avoid problems with meta-characters, it is suggested that the
-entire \fB\-m\fR option argument be placed within single quote characters,
-and that \fBcsh\fR users insert a backslash character (\*(``\e\*('') before
-any exclamation marks (\*(``!\*('').
-.SH HISTORY
-.PP
-A \fBreset\fP command appeared in 2BSD (April 1979), written by Kurt Shoens.
-This program set the \fIerase\fP and \fIkill\fP characters
-to \fB^H\fP (backspace) and \fB@\fP respectively.
-Mark Horton improved that in 3BSD (October 1979), adding
-\fIintr\fP, \fIquit\fP, \fIstart\fP/\fIstop\fP and \fIeof\fP characters
-as well as changing the program to avoid modifying any user settings.
-.PP
-Later in 4.1BSD (December 1980),
-Mark Horton added a call to the \fBtset\fP program
-using the \fB\-I\fP and \fB\-Q\fP options, i.e.,
-using that to improve the terminal modes.
-With those options,
-that version of \fBreset\fP did not use the termcap database.
-.PP
-A separate \fBtset\fP command was provided in 2BSD by Eric Allman.
-While the oldest published source (from 1979)
-provides both \fBtset\fP and \fBreset\fP,
-Allman's comments in the 2BSD source code indicate
-that he began work in October 1977,
-continuing development over the next few years.
-.PP
-In September 1980, Eric Allman modified \fBtset\fP,
-adding the code from the existing \*(``reset\*(''
-feature when \fBtset\fP was invoked as \fBreset\fP.
-Rather than simply copying the existing program,
-in this merged version, \fBtset\fP used the termcap database
-to do additional (re)initialization of the terminal.
-This version appeared in 4.1cBSD, late in 1982.
-.PP
-Other developers (e.g., Keith Bostic and Jim Bloom)
-continued to modify \fBtset\fP until 4.4BSD was released in 1993.
+entire \fB\-m\fP option argument be placed within single quote characters,
+and that \fIcsh\fP users insert a backslash character (\*(``\e\*('')
+before any exclamation marks (\*(``!\*('').
+.SH OPTIONS
+The options are as follows:
+.TP 5
+.B \-c
+Set control characters and modes.
+.TP 5
+.BI \-e\  ch
+Set the erase character to \fIch\fP.
+.TP
+.B \-I
+Do not send the terminal or tab initialization strings to the terminal.
+.TP
+.BI \-i\  ch
+Set the interrupt character to \fIch\fP.
+.TP
+.BI \-k\  ch
+Set the line kill character to \fIch\fP.
+.TP
+.BI \-m\  mapping
+Specify a mapping from a port type to a terminal;
+see subsection \*(``Terminal Type Mapping\*(''.
+.TP
+.B \-Q
+Do not display any values for the erase, interrupt and line kill characters.
+Normally \fB@TSET@\fP displays the values for control characters which
+differ from the system's default values.
+.TP
+.B \-q
+The terminal type is displayed to the standard output, and the terminal is
+not initialized in any way.
+The option \*(``\-\*('' by itself is equivalent but archaic.
+.TP
+.B \-r
+Print the terminal type to the standard error output.
+.TP
+.B \-s
+Print the sequence of shell commands to initialize the environment variable
+\fITERM\fP to the standard output;
+see subsection \*(``Setting the Environment\*(''.
+.TP
+.B \-V
+reports the version of \fI\%ncurses\fP which was used in this program,
+and exits.
+.TP
+.B \-w
+Resize the window to match the size deduced via \fBsetupterm\fP(3X).
+Normally this has no effect,
+unless \fBsetupterm\fP is not able to detect the window size.
 .PP
-The \fBncurses\fR implementation
-was lightly adapted from the 4.4BSD sources for a terminfo environment by Eric
-S. Raymond <esr@snark.thyrsus.com>.
-.SH COMPATIBILITY
+The arguments for the \fB\-e\fP, \fB\-i\fP, and \fB\-k\fP
+options may either be entered as actual characters
+or by using the \*(``hat\*(''
+notation, i.e., control-h may be specified as \*(``\*^H\*('' or \*(``\*^h\*(''.
 .PP
+If neither \fB\-c\fP or \fB\-w\fP is given, both options are assumed.
+.SH ENVIRONMENT
+The \fB@TSET@\fP command uses these environment variables:
+.TP 5
+.I SHELL
+tells \fB@TSET@\fP whether to initialize \fITERM\fP using \fIsh\fP(1) or
+\fIcsh\fP(1) syntax.
+.TP 5
+.I TERM
+Denotes your terminal type.
+Each terminal type is distinct, though many are similar.
+.TP 5
+.I TERMCAP
+may denote the location of a termcap database.
+If it is not an absolute pathname, e.g., begins with a \*(``/\*('',
+\fB@TSET@\fP removes the variable from the environment before looking
+for the terminal description.
+.SH FILES
+.TP
+.I /etc/ttys
+system port name to terminal type mapping database (BSD versions only).
+.TP
+.I \*d
+compiled terminal description database directory
+.SH PORTABILITY
 Neither IEEE Std 1003.1/The Open Group Base Specifications Issue 7
 (POSIX.1-2008) nor
 X/Open Curses Issue 7 documents \fB@TSET@\fP or \fB@RESET@\fP.
 .PP
-The AT&T \fBtput\fP utility (AIX, HPUX, Solaris)
+The AT&T \fBtput\fP utility (AIX, HP-UX, Solaris)
 incorporated the terminal-mode manipulation as well as termcap-based features
 such as resetting tabstops from \fBtset\fP in BSD (4.1c),
 presumably with the intention of making \fBtset\fP obsolete.
@@ -333,21 +329,24 @@ However, each of those systems still provides \fBtset\fP.
 In fact, the commonly-used \fBreset\fP utility
 is always an alias for \fBtset\fP.
 .PP
-The \fB@TSET@\fR utility provides for backward-compatibility with BSD
-environments (under most modern UNIXes, \fB/etc/inittab\fR and \fBgetty\fR(1)
-can set \fBTERM\fR appropriately for each dial-up line; this obviates what was
-\fB@TSET@\fR's most important use).
-This implementation behaves like 4.4BSD
-\fBtset\fP, with a few exceptions specified here.
+The \fB\%@TSET@\fP utility provides backward compatibility with BSD
+environments;
+under most modern Unices,
+\fI\%/etc/inittab\fP and \fI\%getty\fP(8) can set \fITERM\fP
+appropriately for each dial-up line,
+obviating what was \fB\%@TSET@\fP's most important use.
+This implementation behaves like 4.4BSD \fBtset\fP,
+with a few exceptions we shall consider now.
 .PP
 A few options are different
-because the \fBTERMCAP\fR variable
-is no longer supported under terminfo-based \fBncurses\fR:
+because the \fI\%TERMCAP\fP variable
+is no longer supported under terminfo-based \fI\%ncurses\fP:
 .bP
-The \fB\-S\fR option of BSD \fBtset\fP no longer works;
+The \fB\-S\fP option of BSD \fBtset\fP no longer works;
 it prints an error message to the standard error and dies.
 .bP
-The \fB\-s\fR option only sets \fBTERM\fR, not \fBTERMCAP\fP.
+The \fB\-s\fP option only sets \fITERM\fP,
+not \fI\%TERMCAP\fP.
 .PP
 There was an undocumented 4.4BSD feature
 that invoking \fBtset\fP via a link named
@@ -355,17 +354,17 @@ that invoking \fBtset\fP via a link named
 set the terminal to use upper-case only.
 This feature has been omitted.
 .PP
-The \fB\-A\fR, \fB\-E\fR, \fB\-h\fR, \fB\-u\fR and \fB\-v\fR
-options were deleted from the \fB@TSET@\fR
+The \fB\-A\fP, \fB\-E\fP, \fB\-h\fP, \fB\-u\fP and \fB\-v\fP
+options were deleted from the \fB@TSET@\fP
 utility in 4.4BSD.
 None of them were documented in 4.3BSD and all are
 of limited utility at best.
-The \fB\-a\fR, \fB\-d\fR, and \fB\-p\fR options are similarly
+The \fB\-a\fP, \fB\-d\fP, and \fB\-p\fP options are similarly
 not documented or useful, but were retained as they appear to be in
 widespread use.
 It is strongly recommended that any usage of these
-three options be changed to use the \fB\-m\fR option instead.
-The \fB\-a\fP, \fB\-d\fP, and \fB\-p\fR options
+three options be changed to use the \fB\-m\fP option instead.
+The \fB\-a\fP, \fB\-d\fP, and \fB\-p\fP options
 are therefore omitted from the usage summary above.
 .PP
 Very old systems, e.g., 3BSD, used a different terminal driver which
@@ -374,15 +373,15 @@ To accommodate these older systems, the 4BSD \fB@TSET@\fP provided a
 \fB\-n\fP option to specify that the new terminal driver should be used.
 This implementation does not provide that choice.
 .PP
-It is still permissible to specify the \fB\-e\fR, \fB\-i\fR,
-and \fB\-k\fR options without arguments,
+It is still permissible to specify the \fB\-e\fP, \fB\-i\fP,
+and \fB\-k\fP options without arguments,
 although it is strongly recommended that such usage be fixed to
 explicitly specify the character.
 .PP
 As of 4.4BSD,
-executing \fB@TSET@\fR as \fB@RESET@\fR no longer implies the \fB\-Q\fR option.
-Also, the interaction between the \- option and the \fIterminal\fR
-argument in some historic implementations of \fB@TSET@\fR has been removed.
+executing \fB@TSET@\fP as \fB@RESET@\fP no longer implies the \fB\-Q\fP option.
+Also, the interaction between the \- option and the \fIterminal\fP
+argument in some historic implementations of \fB@TSET@\fP has been removed.
 .PP
 The \fB\-c\fP and \fB\-w\fP options are not found in earlier implementations.
 However, a different window size-change feature was provided in 4.4BSD.
@@ -391,57 +390,75 @@ In 4.4BSD, \fBtset\fP uses the window size from the termcap description
 to set the window size if \fBtset\fP is not able to obtain the window
 size from the operating system.
 .bP
-In ncurses, \fB@TSET@\fR obtains the window size using
-\fBsetupterm\fP, which may be from
+In \fI\%ncurses\fP, \fB@TSET@\fP obtains the window size using
+\fB\%setupterm\fP(3X), which may be from
 the operating system,
-the \fBLINES\fP and \fBCOLUMNS\fP environment variables or
+the \fILINES\fP and \fICOLUMNS\fP environment variables or
 the terminal description.
 .PP
-Obtaining the window size from the terminal description is common to
-both implementations, but considered obsolescent.
+Obtaining the window size from a terminal's type description is common
+to both implementations,
+but considered obsolescent.
 Its only practical use is for hardware terminals.
-Generally speaking, a window size would be unset only if there were
-some problem obtaining the value from the operating system
-(and \fBsetupterm\fP would still fail).
-For that reason, the \fBLINES\fP and \fBCOLUMNS\fP environment variables
-may be useful for working around window-size problems.
-Those have the drawback that if the window is resized,
-those variables must be recomputed and reassigned.
-To do this more easily, use the \fBresize\fP(1) program.
-.SH ENVIRONMENT
-The \fB@TSET@\fR command uses these environment variables:
-.TP 5
-SHELL
-tells \fB@TSET@\fP whether to initialize \fBTERM\fP using \fBsh\fP or
-\fBcsh\fP syntax.
-.TP 5
-TERM
-Denotes your terminal type.
-Each terminal type is distinct, though many are similar.
-.TP 5
-TERMCAP
-may denote the location of a termcap database.
-If it is not an absolute pathname, e.g., begins with a \*(``/\*('',
-\fB@TSET@\fP removes the variable from the environment before looking
-for the terminal description.
-.SH FILES
-.TP 5
-/etc/ttys
-system port name to terminal type mapping database (BSD versions only).
-.TP
-@TERMINFO@
-terminal capability database
+Generally,
+the window size will remain uninitialized only if there were a problem
+obtaining the value from the operating system
+(and \fB\%setupterm\fP would still fail).
+The \fILINES\fP and \fI\%COLUMNS\fP environment variables
+may thus be useful for working around window-size problems,
+but have the drawback that if the window is resized,
+their values must be recomputed and reassigned.
+The \fI\%resize\fP(1) program distributed with
+\fI\%xterm\fP(1) assists this activity.
+.SH HISTORY
+A \fB\%reset\fP command written by Kurt Shoens appeared in 1BSD
+(March 1978).
+.\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=1BSD/s6/reset.c
+It set the \fIerase\fP and \fIkill\fP characters
+to \fB\*^H\fP (backspace) and \fB@\fP respectively.
+Mark Horton improved this \fB\%reset\fP in 3BSD
+(October 1979),
+adding \fIintr\fP,
+\fIquit\fP,
+\fIstart\fP/\fIstop\fP,
+and \fIeof\fP
+characters as well as changing the program to avoid modifying any user
+settings.
+.\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=3BSD/usr/src/cmd/\
+.\"   reset.c
+That version of \fB\%reset\fP did not use \fI\%termcap\fP.
+.PP
+Eric Allman wrote a distinct \fBtset\fP command for 1BSD,
+using a forerunner of \fI\%termcap\fP called \fI\%ttycap\fP.
+.\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=1BSD/s6/tset.c
+.\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=1BSD/man7/ttycap.7
+Allman's comments in the source code indicate
+that he began work in October 1977,
+continuing development over the next few years.
+By late 1979,
+it had migrated to \fI\%termcap\fP and handled the \fI\%TERMCAP\fP
+variable.
+.\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=3BSD/usr/src/cmd/\
+.\"   tset/tset.c
+Later comments indicate that \fBtset\fP was modified in September 1980
+to use logic copied from the 3BSD \*(``reset\*('' program when it was
+invoked as \fB\%reset\fP.
+.\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=2.9BSD/usr/src/ucb/\
+.\"   tset/tset.c
+This version appeared in 4.1cBSD, \" and backported to 2.9BSD
+late in 1982.
+Other developers such as Keith Bostic and Jim Bloom continued to modify
+\fBtset\fP until 4.4BSD was released in 1993.
+.PP
+The \fI\%ncurses\fP implementation was lightly adapted from the 4.4BSD
+sources to use the \fI\%terminfo\fP API by Eric S.\& Raymond
+<esr@snark.thyrsus.com>.
 .SH SEE ALSO
-.hy 0
-\fBcsh\fP(1),
-\fBsh\fP(1),
-\fBstty\fP(1),
-\fBcurs_terminfo\fP(3X),
-\fBtty\fP(4),
-\fBterminfo\fP(5),
-\fBttys\fP(5),
-\fBenviron\fP(7)
-.hy
-.PP
-This describes \fBncurses\fR
-version @NCURSES_MAJOR@.@NCURSES_MINOR@ (patch @NCURSES_PATCH@).
+\fB\%csh\fP(1),
+\fB\%sh\fP(1),
+\fB\%stty\fP(1),
+\fB\%curs_terminfo\fP(3X),
+\fB\%tty\fP(4),
+\fB\%terminfo\fP(5),
+\fB\%ttys\fP(5),
+\fB\%environ\fP(7)
diff --git a/contrib/ncurses/man/user_caps.5 b/contrib/ncurses/man/user_caps.5
index 43dd000cdc08..219bbf5f9976 100644
--- a/contrib/ncurses/man/user_caps.5
+++ b/contrib/ncurses/man/user_caps.5
@@ -1,5 +1,6 @@
+'\" t
 .\"***************************************************************************
-.\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 2017 Free Software Foundation, Inc.                            *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,45 +28,40 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: user_caps.5,v 1.16 2020/12/19 21:26:11 tom Exp $
-.TH user_caps 5
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
-.de NS
-.ie n  .sp
-.el    .sp .5
-.ie n  .in +4
-.el    .in +2
-.nf
-.ft C			\" Courier
-..
-.de NE
-.fi
-.ft R
-.ie n  .in -4
-.el    .in -2
-..
+.\" $Id: user_caps.5,v 1.49 2024/03/16 15:35:01 tom Exp $
+.TH user_caps 5 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "File formats"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el   .ds `` ""
+.ie t .ds '' ''
+.el   .ds '' ""
+.\}
+.
 .de bP
 .ie n  .IP \(bu 4
 .el    .IP \(bu 2
 ..
 .SH NAME
-user_caps \- user-defined terminfo capabilities
+user_caps \-
+user-defined \fIterminfo\fR capability format
 .SH SYNOPSIS
-.B @TIC@ -x, @INFOCMP@ -x
+.B @INFOCMP@ \-x
+.PP
+.B @TIC@ \-x
 .SH DESCRIPTION
 .SS Background
-.PP
-Before ncurses 5.0,
+Before \fI\%ncurses\fP 5.0,
 terminfo databases used a \fIfixed repertoire\fP of terminal
 capabilities designed for the SVr2 terminal database in 1984,
 and extended in stages through SVr4 (1989),
 and standardized in the Single Unix Specification beginning in 1995.
 .PP
 Most of the \fIextensions\fP in this fixed repertoire were additions
-to the tables of boolean, numeric and string capabilities.
+to the tables of Boolean, numeric and string capabilities.
 Rather than change the meaning of an existing capability, a new name was added.
 The terminfo database uses a binary format; binary compatibility was
 ensured by using a header which gave the number of items in the
@@ -92,22 +88,24 @@ Although they \fImay\fP provide all of the standard capability names,
 the position in the tables differs because some features were added as needed,
 while others were added (out of order) to comply with X/Open Curses.
 .IP
-While ncurses' repertoire of predefined capabilities is closest to Solaris,
+While \fI\%ncurses\fP' repertoire of predefined capabilities is closest
+to Solaris,
 Solaris's terminfo database has a few differences from
 the list published by X/Open Curses.
-For example, ncurses can be configured with tables which match the
-terminal databases for AIX, HP-UX or OSF/1,
+For example,
+\fI\%ncurses\fP can be configured with tables which match the terminal
+databases for AIX, HP-UX or OSF/1,
 rather than the default Solaris-like configuration.
 .bP
-In SVr4 curses and ncurses,
+In SVr4 curses and \fI\%ncurses\fP,
 the terminal database is defined at compile-time using a text file
 which lists the different terminal capabilities.
 .IP
 In principle, the text-file can be extended,
 but doing this requires recompiling and reinstalling the library.
-The text-file used in ncurses for terminal capabilities includes
+The text-file used in \fI\%ncurses\fP for terminal capabilities includes
 details for various systems past the documented X/Open Curses features.
-For example, ncurses supports these capabilities in each configuration:
+For example, \fI\%ncurses\fP supports these capabilities in each configuration:
 .RS 8
 .TP 5
 memory_lock
@@ -124,9 +122,9 @@ box characters primary set
 .RE
 .IP
 The memory lock/unlock capabilities were included because they were used
-in the X11R6 terminal description for \fBxterm\fP.
+in the X11R6 terminal description for \fBxterm\fP(1).
 The \fIbox1\fP capability is used in @TIC@ to help with terminal descriptions
-written for AIX. 
+written for AIX.
 .PP
 During the 1990s, some users were reluctant to use terminfo
 in spite of its performance advantages over termcap:
@@ -142,16 +140,16 @@ it could represent larger numbers.
 Although termcap's extensibility was rarely used
 (it was never the \fIspeaker\fP who had actually used the feature),
 the criticism had a point.
-ncurses 5.0 provided a way to detect nonstandard capabilities,
+\fI\%ncurses\fP 5.0 provided a way to detect nonstandard capabilities,
 determine their
 type and optionally store and retrieve them in a way which did not interfere
 with other applications.
 These are referred to as \fIuser-defined capabilities\fP because no
 modifications to the toolset's predefined capability names are needed.
 .PP
-The ncurses utilities \fB@TIC@\fP and \fB@INFOCMP@\fP have a command-line
-option \*(``\-x\*('' to control whether the nonstandard capabilities
-are stored or retrieved.
+The \fI\%ncurses\fP utilities \fB@TIC@\fP and \fB@INFOCMP@\fP have a
+command-line option \*(``\-x\*('' to control whether the nonstandard
+capabilities are stored or retrieved.
 A library function \fBuse_extended_names\fP
 is provided for the same purpose.
 .PP
@@ -159,7 +157,7 @@ When compiling a terminal database, if \*(``\-x\*('' is set,
 \fB@TIC@\fP will store a user-defined capability if the capability name is not
 one of the predefined names.
 .PP
-Because ncurses provides a termcap library interface,
+Because \fI\%ncurses\fP provides a termcap library interface,
 these user-defined capabilities may be visible to termcap applications:
 .bP
 The termcap interface (like all implementations of termcap)
@@ -181,21 +179,20 @@ While terminfo and termcap have a set of 60 predefined function-key names,
 to which a series of keys can be assigned,
 that is insufficient for more than a dozen keys multiplied by more than
 a couple of modifier combinations.
-The ncurses database uses a convention based on \fBxterm\fP to
-provide extended special-key names.
+The \fI\%ncurses\fP database uses a convention based on \fBxterm\fP(1)
+to provide extended special-key names.
 .IP
 Fitting that into termcap's limitation of 2-character names
 would be pointless.
 These extended keys are available only with terminfo.
-.SS Recognized capabilities
-.PP
-The ncurses library uses the user-definable capabilities.
+.SS "Recognized Capabilities"
+The \fI\%ncurses\fP library uses the user-definable capabilities.
 While the terminfo database may have other extensions,
-ncurses makes explicit checks for these:
+\fI\%ncurses\fP makes explicit checks for these:
 .RS 3
 .TP 3
 AX
-\fIboolean\fP, asserts that the terminal interprets SGR 39 and SGR 49
+\fIBoolean\fP, asserts that the terminal interprets SGR 39 and SGR 49
 by resetting the foreground and background color, respectively, to the default.
 .IP
 This is a feature recognized by the \fBscreen\fP program as well.
@@ -207,9 +204,17 @@ the terminal.
 .IP
 The command \*(``\fBtput clear\fP\*('' does the same thing.
 .TP 3
+NQ
+\fIBoolean\fP,
+used to suppress a consistency check in @TIC@ for the \fI\%ncurses\fP
+capabilities
+in user6 through user9 (u6, u7, u8 and u9)
+which tell how to query the terminal's cursor position
+and its device attributes.
+.TP 3
 RGB
-\fIboolean\fP, \fInumber\fP \fBor\fP \fIstring\fP,
-to assert that the
+\fIBoolean\fP, \fInumber\fP \fBor\fP \fIstring\fP,
+used to assert that the
 \fBset_a_foreground\fP and
 \fBset_a_background\fP capabilities correspond to \fIdirect colors\fP,
 using an RGB (red/green/blue) convention.
@@ -217,22 +222,24 @@ This capability allows the \fBcolor_content\fP function to
 return appropriate values without requiring the application
 to initialize colors using \fBinit_color\fP.
 .IP
-The capability type determines the values which ncurses sees:
+The capability type determines the values which \fI\%ncurses\fP sees:
 .RS 3
 .TP 3
-\fIboolean\fP
+\fIBoolean\fP
 implies that the number of bits for red, green and blue are the same.
 Using the maximum number of colors,
-ncurses adds two, divides that sum by three, and assigns the result
-to red, green and blue in that order.
+\fI\%ncurses\fP adds two,
+divides that sum by three,
+and assigns the result to red,
+green and blue in that order.
 .IP
 If the number of bits needed for the number of colors is not a multiple
 of three, the blue (and green) components lose in comparison to red.
 .TP 3
 \fInumber\fP
-tells ncurses what result to add to red, green and blue.
-If ncurses runs out of bits,
-blue (and green) lose just as in the \fIboolean\fP case.
+tells \fI\%ncurses\fP what result to add to red, green and blue.
+If \fI\%ncurses\fP runs out of bits,
+blue (and green) lose just as in the \fIBoolean\fP case.
 .TP 3
 \fIstring\fP
 explicitly list the number of bits used for red, green and blue components
@@ -247,27 +254,29 @@ to represent the standard eight ANSI colors, i.e., one bit per color.
 .TP 3
 U8
 \fInumber\fP,
-asserts that ncurses must use Unicode values for line-drawing characters,
+asserts that \fI\%ncurses\fP must use Unicode values for line-drawing
+characters,
 and that it should ignore the alternate character set capabilities
 when the locale uses UTF-8 encoding.
 For more information, see the discussion of
-\fBNCURSES_NO_UTF8_ACS\fP in \fBncurses\fP(3X).
+\fBNCURSES_NO_UTF8_ACS\fP in \fB\%ncurses\fP(3X).
 .IP
 Set this capability to a nonzero value to enable it.
 .TP 3
 XM
 \fIstring\fP,
-override ncurses's built-in string which
-enables/disables \fBxterm\fP mouse mode.
+override \fI\%ncurses\fP's built-in string which
+enables/disables \fBxterm\fP(1) mouse mode.
 .IP
-ncurses sends a character sequence to the terminal to initialize mouse mode,
+\fI\%ncurses\fP sends a character sequence to the terminal to initialize mouse mode,
 and when the user clicks the mouse buttons or (in certain modes) moves the
 mouse, handles the characters sent back by the terminal to tell it what
 was done with the mouse.
 .IP
 The mouse protocol is enabled when
 the \fImask\fP passed in the \fBmousemask\fP function is nonzero.
-By default, ncurses handles the responses for the X11 xterm mouse protocol.
+By default,
+\fI\%ncurses\fP handles the responses for the X11 xterm mouse protocol.
 It also knows about the \fISGR 1006\fP xterm mouse protocol,
 but must to be told to look for this specifically.
 It will not be able to guess which mode is used,
@@ -276,7 +285,7 @@ because the responses are enough alike that only confusion would result.
 The \fBXM\fP capability has a single parameter.
 If nonzero, the mouse protocol should be enabled.
 If zero, the mouse protocol should be disabled.
-ncurses inspects this capability if it is present,
+\fI\%ncurses\fP inspects this capability if it is present,
 to see whether the 1006 protocol is used.
 If so, it expects the responses to use the \fISGR 1006\fP xterm mouse protocol.
 .IP
@@ -324,61 +333,79 @@ xterm mouse protocols:
 .IP
 .nf
   xterm+x11mouse|X11 xterm mouse protocol,
-          kmous=\\E[M, XM=\\E[?1000%?%p1%{1}%=%th%el%;,
-          xm=\\E[M
+          kmous=\eE[M, XM=\eE[?1000%?%p1%{1}%=%th%el%;,
+          xm=\eE[M
              %?%p4%t%p3%e%{3}%;%'\ '%+%c
              %p2%'!'%+%c
              %p1%'!'%+%c,
 
   xterm+sm+1006|xterm SGR-mouse,
-          kmous=\\E[<, XM=\\E[?1006;1000%?%p1%{1}%=%th%el%;,
-          xm=\\E[<%i%p3%d;
+          kmous=\eE[<, XM=\eE[?1006;1000%?%p1%{1}%=%th%el%;,
+          xm=\eE[<%i%p3%d;
              %p1%d;
              %p2%d;
              %?%p4%tM%em%;,
 .fi
 .
-.SS Extended key-definitions
-.PP
+.SS "Extended Key Definitions"
 Several terminals provide the ability to send distinct strings for
 combinations of modified special keys.
 There is no standard for what those keys can send.
 .PP
-Since 1999, \fBxterm\fP has supported
+Since 1999, \fBxterm\fP(1) has supported
 \fIshift\fP, \fIcontrol\fP, \fIalt\fP, and \fImeta\fP modifiers which produce
 distinct special-key strings.
-In a terminal description, ncurses has no special knowledge of the
-modifiers used.
+In a terminal description,
+\fI\%ncurses\fP has no special knowledge of the modifiers used.
 Applications can use the \fInaming convention\fP established for \fBxterm\fP
 to find these special keys in the terminal description.
 .PP
-Starting with the curses convention that \fIkey names\fP begin with \*(``k\*(''
-and that shifted special keys are an uppercase name,
-ncurses' terminal database defines these names to which a suffix is added:
+Starting with the
+.I curses
+convention that capability codes describing the input generated by a
+terminal's key caps begin with \*(``k\*('',
+and that shifted special keys use uppercase letters in their names,
+.IR \%ncurses 's
+terminal database defines the following names and codes to which a
+suffix is added.
+.PP
 .RS 5
 .TS
-tab(/) ;
-l l .
-\fIName\fR/\fIDescription\fR
+Lb Lb
+Lb Lx.
+Code	Description
 _
-kDC/special form of kdch1 (delete character)
-kDN/special form of kcud1 (cursor down)
-kEND/special form of kend (End)
-kHOM/special form of khome (Home)
-kLFT/special form of kcub1 (cursor-left or cursor-back)
-kNXT/special form of knext (Next, or Page-Down)
-kPRV/special form of kprev (Prev, or Page-Up)
-kRIT/special form of kcuf1 (cursor-right, or cursor-forward)
-kUP/special form of kcuu1 (cursor-up)
+kDC	shifted kdch1 (delete character)
+.\" kDC is a standard capability; see X/Open Curses Issue 7, p. 345.
+kDN	shifted kcud1 (cursor down)
+kEND	shifted kend (end)
+kHOM	shifted khome (home)
+kLFT	shifted kcub1 (cursor back)
+kNXT	shifted knext (next)
+kPRV	shifted kprev (previous)
+kRIT	shifted kcuf1 (cursor forward)
+kUP	shifted kcuu1 (cursor up)
 .TE
 .RE
 .PP
+Keycap nomenclature on the Unix systems for which
+.I curses
+was developed differs from today's ubiquitous descendants of the IBM
+PC/AT keyboard layout.
+In the foregoing,
+interpret \*(``backward\*('' as \*(``left\*('',
+\*(``forward\*('' as \*(``right\*('',
+\*(``next\*('' as \*(``page down\*('',
+and
+\*(``prev(ious)\*('' as \*(``page up\*(''.
+.PP
 These are the suffixes used to denote the modifiers:
+.PP
 .RS 5
 .TS
 tab(/) ;
 l l .
-\fIValue\fR/\fIDescription\fR
+\fBValue\fP/\fBDescription\fP
 _
 2/Shift
 3/Alt
@@ -399,8 +426,9 @@ _
 .RE
 .PP
 None of these are predefined; terminal descriptions can refer to \fInames\fP
-which ncurses will allocate at runtime to \fIkey-codes\fP.
-To use these keys in an ncurses program, an application could do this:
+which \fI\%ncurses\fP will allocate at runtime to \fIkey-codes\fP.
+To use these keys in an \fI\%ncurses\fP program,
+an application could do this:
 .bP
 using a list of extended key \fInames\fP,
 ask \fBtigetstr\fP(3X) for their values, and
@@ -408,32 +436,29 @@ ask \fBtigetstr\fP(3X) for their values, and
 given the list of values,
 ask \fBkey_defined\fP(3X) for the \fIkey-code\fP which
 would be returned for those keys by \fBwgetch\fP(3X).
-.PP
 .\"
 .SH PORTABILITY
-.PP
 The \*(``\-x\*('' extension feature of \fB@TIC@\fP and \fB@INFOCMP@\fP
 has been adopted in NetBSD curses.
 That implementation stores user-defined capabilities,
 but makes no use of these capabilities itself.
 .\"
+.SH AUTHORS
+Thomas E. Dickey
+.br
+beginning with \fI\%ncurses\fP 5.0 (1999)
+.\"
 .SH SEE ALSO
-.PP
-\fB@INFOCMP@\fR(1M),
-\fB@TIC@\fR(1M).
+\fB\%@INFOCMP@\fP(1M),
+\fB\%@TIC@\fP(1M)
 .PP
 The terminal database section
 .I "NCURSES USER-DEFINABLE CAPABILITIES"
 summarizes commonly-used user-defined capabilities
 which are used in the terminal descriptions.
-Some of those features are mentioned in \fBscreen\fR(1) or \fBtmux\fR(1).
+Some of those features are mentioned in \fB\%screen\fP(1) or
+\fBtmux\fP(1).
 .PP
 .I "XTerm Control Sequences"
-provides further information on the \fBxterm\fP features
-which are used in these extended capabilities.
-.\"
-.SH AUTHORS
-.PP
-Thomas E. Dickey
-.br
-beginning with ncurses 5.0 (1999)
+provides further information on the \fB\%xterm\fP(1) features
+that are used in these extended capabilities.
diff --git a/contrib/ncurses/man/wresize.3x b/contrib/ncurses/man/wresize.3x
index 54c1fc6bccc5..b67feada0dc0 100644
--- a/contrib/ncurses/man/wresize.3x
+++ b/contrib/ncurses/man/wresize.3x
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018,2020 Thomas E. Dickey                                     *
+.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
 .\" Copyright 1998-2010,2015 Free Software Foundation, Inc.                  *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -29,38 +29,44 @@
 .\"
 .\" Author: Thomas E. Dickey 1996
 .\"
-.\" $Id: wresize.3x,v 1.17 2020/10/17 23:56:38 tom Exp $
-.TH wresize 3X ""
+.\" $Id: wresize.3x,v 1.36 2024/03/16 15:35:01 tom Exp $
+.TH wresize 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
 .SH NAME
-\fBwresize\fR \- resize a curses window
+\fB\%wresize\fP \-
+resize a \fIcurses\fR window
 .SH SYNOPSIS
-\fB#include <curses.h>\fR
-.sp
-\fBint wresize(WINDOW *\fP\fIwin\fP\fB, int \fP\fIlines\fP\fB, int \fP\fIcolumns\fP\fB);\fR
+.nf
+\fB#include <curses.h>
+.PP
+\fBint wresize(WINDOW *\fIwin\fP, int \fIlines\fP, int \fIcolumns\fP);
+.fi
 .SH DESCRIPTION
-This is an extension to the curses library.
-It reallocates storage for an \fBncurses\fR
-window to adjust its dimensions to the specified values.
-If either dimension is larger than the current values, the
-window's data is filled with blanks that have the current background rendition
-(as set by \fBwbkgdset\fR) merged into them.
+This \fI\%ncurses\fP extension to standard \fIcurses\fP reallocates
+storage for a \fIcurses\fP window to adjust its dimensions to the
+specified values.
+If either dimension is larger than its current value,
+the expanded part of the window is filled with blanks merged with
+current background rendition
+(as set by \fB\%wbkgdset\fP(3X)).
 .SH RETURN VALUE
-The function returns the integer \fBERR\fR upon failure and \fBOK\fR on success.
-It will fail if either of the dimensions less than or equal to zero,
+\fB\%wresize\fP returns \fBERR\fP upon failure and \fBOK\fP on success.
+It will fail if either of the dimensions is less than or equal to zero,
 or if an error occurs while (re)allocating memory for the window.
 .SH NOTES
-The only restriction placed on the dimensions is that they be greater than zero.
-The dimensions are not compared to \fBcurses\fR screen dimensions to
-simplify the logic of \fBresizeterm\fR.
+The only restriction placed on the dimensions is that they be greater
+than zero.
+They are \fInot\fP compared to the \fIcurses\fP screen dimensions;
+this keeps the logic of \fB\%resizeterm\fP(3X) simple.
 The caller must ensure that the window's dimensions fit within the
 actual screen dimensions.
 .SH PORTABILITY
+It is not possible to resize windows with SVr4 \fIcurses\fP.
 .PP
-It is not possible to resize windows with SVr4 curses.
-.PP
-This extension of ncurses was introduced in mid-1995.
-It was adopted in NetBSD curses (2001) and PDCurses (2003).
+\fI\%ncurses\fP introduced this extension in mid-1995.
+NetBSD \fIcurses\fP adopted it in 2001,
+and \fI\%PDCurses\fP in 2003.
+.SH AUTHORS
+Thomas Dickey
+(from an equivalent function written in 1988 for BSD \fIcurses\fP).
 .SH SEE ALSO
-\fBresizeterm\fR(3X).
-.SH AUTHOR
-Thomas Dickey (from an equivalent function written in 1988 for BSD curses).
+\fB\%resizeterm\fP(3X)
diff --git a/contrib/ncurses/menu/Makefile.in b/contrib/ncurses/menu/Makefile.in
index fb13eb07c8ef..b623bf0eed82 100644
--- a/contrib/ncurses/menu/Makefile.in
+++ b/contrib/ncurses/menu/Makefile.in
@@ -1,6 +1,6 @@
-# $Id: Makefile.in,v 1.70 2020/08/29 14:50:45 tom Exp $
+# $Id: Makefile.in,v 1.71 2021/07/03 15:45:33 tom Exp $
 ##############################################################################
-# Copyright 2020 Thomas E. Dickey                                            #
+# Copyright 2020,2021 Thomas E. Dickey                                       #
 # Copyright 1998-2015,2018 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -136,6 +136,19 @@ AUTO_SRC	= \
 		../include/mf_common.h
 
 ################################################################################
+
+@MAKE_PHONY@.PHONY :	all
+@MAKE_PHONY@.PHONY :	clean
+@MAKE_PHONY@.PHONY :	distclean
+@MAKE_PHONY@.PHONY :	install
+@MAKE_PHONY@.PHONY :	install.libs
+@MAKE_PHONY@.PHONY :	libs
+@MAKE_PHONY@.PHONY :	mostlyclean
+@MAKE_PHONY@.PHONY :	realclean
+@MAKE_PHONY@.PHONY :	sources
+@MAKE_PHONY@.PHONY :	uninstall
+@MAKE_PHONY@.PHONY :	uninstall.libs
+
 all \
 libs \
 install ::	$(AUTO_SRC) $(LIBRARIES)
diff --git a/contrib/ncurses/menu/READ.ME b/contrib/ncurses/menu/READ.ME
index e790f4308624..8c78037764e0 100644
--- a/contrib/ncurses/menu/READ.ME
+++ b/contrib/ncurses/menu/READ.ME
@@ -1,5 +1,5 @@
 -------------------------------------------------------------------------------
--- Copyright 2020 Thomas E. Dickey                                           --
+-- Copyright 2020,2021 Thomas E. Dickey                                      --
 -- Copyright 1998-2003,2006 Free Software Foundation, Inc.                   --
 --                                                                           --
 -- Permission is hereby granted, free of charge, to any person obtaining a   --
@@ -26,7 +26,7 @@
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
--- $Id: READ.ME,v 1.10 2020/02/02 23:34:34 tom Exp $
+-- $Id: READ.ME,v 1.11 2021/06/17 21:20:30 tom Exp $
 -------------------------------------------------------------------------------
 
 This is a clone of the menu library that is available with typical
@@ -37,7 +37,7 @@ a 386 based SVR4 implementation (ESIX).
 
 The development environment was and is an ELF based Linux system.
 
-For things that still need doing, see the TO-DO file in the top-level 
+For things that still need doing, see the TO-DO file in the top-level
 directory.
 
 Juergen Pfeifer
diff --git a/contrib/ncurses/menu/llib-lmenu b/contrib/ncurses/menu/llib-lmenu
index 7a5a41b9a72c..67f6822376e6 100644
--- a/contrib/ncurses/menu/llib-lmenu
+++ b/contrib/ncurses/menu/llib-lmenu
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2010,2015 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -38,7 +38,7 @@
 
 #undef set_menu_fore
 int	set_menu_fore(
-		MENU	*menu, 
+		MENU	*menu,
 		chtype	attr)
 		{ return(*(int *)0); }
 
@@ -49,7 +49,7 @@ chtype	menu_fore(
 
 #undef set_menu_back
 int	set_menu_back(
-		MENU	*menu, 
+		MENU	*menu,
 		chtype	attr)
 		{ return(*(int *)0); }
 
@@ -60,7 +60,7 @@ chtype	menu_back(
 
 #undef set_menu_grey
 int	set_menu_grey(
-		MENU	*menu, 
+		MENU	*menu,
 		chtype	attr)
 		{ return(*(int *)0); }
 
@@ -73,9 +73,9 @@ chtype	menu_grey(
 
 #undef _nc_menu_cursor_pos
 int	_nc_menu_cursor_pos(
-		const MENU *menu, 
-		const ITEM *item, 
-		int	*pY, 
+		const MENU *menu,
+		const ITEM *item,
+		int	*pY,
 		int	*pX)
 		{ return(*(int *)0); }
 
@@ -88,14 +88,14 @@ int	pos_menu_cursor(
 
 #undef _nc_Match_Next_Character_In_Item_Name
 int	_nc_Match_Next_Character_In_Item_Name(
-		MENU	*menu, 
-		int	ch, 
+		MENU	*menu,
+		int	ch,
 		ITEM	**item)
 		{ return(*(int *)0); }
 
 #undef menu_driver
 int	menu_driver(
-		MENU	*menu, 
+		MENU	*menu,
 		int	c)
 		{ return(*(int *)0); }
 
@@ -103,15 +103,15 @@ int	menu_driver(
 
 #undef set_menu_format
 int	set_menu_format(
-		MENU	*menu, 
-		int	rows, 
+		MENU	*menu,
+		int	rows,
 		int	cols)
 		{ return(*(int *)0); }
 
 #undef menu_format
 void	menu_format(
-		const MENU *menu, 
-		int	*rows, 
+		const MENU *menu,
+		int	*rows,
 		int	*cols)
 		{ /* void */ }
 
@@ -124,7 +124,7 @@ ITEM	_nc_Default_Item;
 
 #undef _nc_Connect_Items
 NCURSES_BOOL _nc_Connect_Items(
-		MENU	*menu, 
+		MENU	*menu,
 		ITEM	**items)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -155,8 +155,8 @@ void	_nc_Show_Menu(
 
 #undef _nc_New_TopRow_and_CurrentItem
 void	_nc_New_TopRow_and_CurrentItem(
-		MENU	*menu, 
-		int	new_toprow, 
+		MENU	*menu,
+		int	new_toprow,
 		ITEM	*new_current_item)
 		{ /* void */ }
 
@@ -164,7 +164,7 @@ void	_nc_New_TopRow_and_CurrentItem(
 
 #undef set_menu_init
 int	set_menu_init(
-		MENU	*menu, 
+		MENU	*menu,
 		Menu_Hook func)
 		{ return(*(int *)0); }
 
@@ -175,7 +175,7 @@ Menu_Hook menu_init(
 
 #undef set_menu_term
 int	set_menu_term(
-		MENU	*menu, 
+		MENU	*menu,
 		Menu_Hook func)
 		{ return(*(int *)0); }
 
@@ -186,7 +186,7 @@ Menu_Hook menu_term(
 
 #undef set_item_init
 int	set_item_init(
-		MENU	*menu, 
+		MENU	*menu,
 		Menu_Hook func)
 		{ return(*(int *)0); }
 
@@ -197,7 +197,7 @@ Menu_Hook item_init(
 
 #undef set_item_term
 int	set_item_term(
-		MENU	*menu, 
+		MENU	*menu,
 		Menu_Hook func)
 		{ return(*(int *)0); }
 
@@ -210,7 +210,7 @@ Menu_Hook item_term(
 
 #undef set_current_item
 int	set_current_item(
-		MENU	*menu, 
+		MENU	*menu,
 		ITEM	*item)
 		{ return(*(int *)0); }
 
@@ -240,7 +240,7 @@ const char *item_description(
 
 #undef new_item
 ITEM	*new_item(
-		const char *name, 
+		const char *name,
 		const char *description)
 		{ return(*(ITEM **)0); }
 
@@ -251,7 +251,7 @@ int	free_item(
 
 #undef set_menu_mark
 int	set_menu_mark(
-		MENU	*menu, 
+		MENU	*menu,
 		const char *mark)
 		{ return(*(int *)0); }
 
@@ -264,19 +264,19 @@ const char *menu_mark(
 
 #undef set_item_opts
 int	set_item_opts(
-		ITEM	*item, 
+		ITEM	*item,
 		Item_Options opts)
 		{ return(*(int *)0); }
 
 #undef item_opts_off
 int	item_opts_off(
-		ITEM	*item, 
+		ITEM	*item,
 		Item_Options opts)
 		{ return(*(int *)0); }
 
 #undef item_opts_on
 int	item_opts_on(
-		ITEM	*item, 
+		ITEM	*item,
 		Item_Options opts)
 		{ return(*(int *)0); }
 
@@ -289,7 +289,7 @@ Item_Options item_opts(
 
 #undef set_top_row
 int	set_top_row(
-		MENU	*menu, 
+		MENU	*menu,
 		int	row)
 		{ return(*(int *)0); }
 
@@ -302,7 +302,7 @@ int	top_row(
 
 #undef set_item_userptr
 int	set_item_userptr(
-		ITEM	*item, 
+		ITEM	*item,
 		void	*userptr)
 		{ return(*(int *)0); }
 
@@ -315,7 +315,7 @@ void	*item_userptr(
 
 #undef set_item_value
 int	set_item_value(
-		ITEM	*item, 
+		ITEM	*item,
 		NCURSES_BOOL value)
 		{ return(*(int *)0); }
 
@@ -335,7 +335,7 @@ NCURSES_BOOL item_visible(
 
 #undef set_menu_items
 int	set_menu_items(
-		MENU	*menu, 
+		MENU	*menu,
 		ITEM	**items)
 		{ return(*(int *)0); }
 
@@ -353,7 +353,7 @@ int	item_count(
 
 #undef new_menu_sp
 MENU	*new_menu_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		ITEM	**items)
 		{ return(*(MENU **)0); }
 
@@ -371,19 +371,19 @@ int	free_menu(
 
 #undef set_menu_opts
 int	set_menu_opts(
-		MENU	*menu, 
+		MENU	*menu,
 		Menu_Options opts)
 		{ return(*(int *)0); }
 
 #undef menu_opts_off
 int	menu_opts_off(
-		MENU	*menu, 
+		MENU	*menu,
 		Menu_Options opts)
 		{ return(*(int *)0); }
 
 #undef menu_opts_on
 int	menu_opts_on(
-		MENU	*menu, 
+		MENU	*menu,
 		Menu_Options opts)
 		{ return(*(int *)0); }
 
@@ -396,7 +396,7 @@ Menu_Options menu_opts(
 
 #undef set_menu_pad
 int	set_menu_pad(
-		MENU	*menu, 
+		MENU	*menu,
 		int	pad)
 		{ return(*(int *)0); }
 
@@ -414,7 +414,7 @@ char	*menu_pattern(
 
 #undef set_menu_pattern
 int	set_menu_pattern(
-		MENU	*menu, 
+		MENU	*menu,
 		const char *p)
 		{ return(*(int *)0); }
 
@@ -422,7 +422,7 @@ int	set_menu_pattern(
 
 #undef _nc_Post_Item
 void	_nc_Post_Item(
-		const MENU *menu, 
+		const MENU *menu,
 		const ITEM *item)
 		{ /* void */ }
 
@@ -457,8 +457,8 @@ int	menu_request_by_name(
 
 #undef scale_menu
 int	scale_menu(
-		const MENU *menu, 
-		int	*rows, 
+		const MENU *menu,
+		int	*rows,
 		int	*cols)
 		{ return(*(int *)0); }
 
@@ -466,17 +466,17 @@ int	scale_menu(
 
 #undef set_menu_spacing
 int	set_menu_spacing(
-		MENU	*menu, 
-		int	s_desc, 
-		int	s_row, 
+		MENU	*menu,
+		int	s_desc,
+		int	s_row,
 		int	s_col)
 		{ return(*(int *)0); }
 
 #undef menu_spacing
 int	menu_spacing(
-		const MENU *menu, 
-		int	*s_desc, 
-		int	*s_row, 
+		const MENU *menu,
+		int	*s_desc,
+		int	*s_row,
 		int	*s_col)
 		{ return(*(int *)0); }
 
@@ -484,7 +484,7 @@ int	menu_spacing(
 
 #undef set_menu_sub
 int	set_menu_sub(
-		MENU	*menu, 
+		MENU	*menu,
 		WINDOW	*win)
 		{ return(*(int *)0); }
 
@@ -529,7 +529,7 @@ Menu_Options _nc_retrace_menu_opts(
 
 #undef set_menu_userptr
 int	set_menu_userptr(
-		MENU	*menu, 
+		MENU	*menu,
 		void	*userptr)
 		{ return(*(int *)0); }
 
@@ -542,7 +542,7 @@ void	*menu_userptr(
 
 #undef set_menu_win
 int	set_menu_win(
-		MENU	*menu, 
+		MENU	*menu,
 		WINDOW	*win)
 		{ return(*(int *)0); }
 
diff --git a/contrib/ncurses/menu/llib-lmenut b/contrib/ncurses/menu/llib-lmenut
index 1d348c09d2bb..0a0d05947222 100644
--- a/contrib/ncurses/menu/llib-lmenut
+++ b/contrib/ncurses/menu/llib-lmenut
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 2010,2015 Free Software Foundation, Inc.                       *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -38,7 +38,7 @@
 
 #undef set_menu_fore
 int	set_menu_fore(
-		MENU	*menu, 
+		MENU	*menu,
 		chtype	attr)
 		{ return(*(int *)0); }
 
@@ -49,7 +49,7 @@ chtype	menu_fore(
 
 #undef set_menu_back
 int	set_menu_back(
-		MENU	*menu, 
+		MENU	*menu,
 		chtype	attr)
 		{ return(*(int *)0); }
 
@@ -60,7 +60,7 @@ chtype	menu_back(
 
 #undef set_menu_grey
 int	set_menu_grey(
-		MENU	*menu, 
+		MENU	*menu,
 		chtype	attr)
 		{ return(*(int *)0); }
 
@@ -73,9 +73,9 @@ chtype	menu_grey(
 
 #undef _nc_menu_cursor_pos
 int	_nc_menu_cursor_pos(
-		const MENU *menu, 
-		const ITEM *item, 
-		int	*pY, 
+		const MENU *menu,
+		const ITEM *item,
+		int	*pY,
 		int	*pX)
 		{ return(*(int *)0); }
 
@@ -88,14 +88,14 @@ int	pos_menu_cursor(
 
 #undef _nc_Match_Next_Character_In_Item_Name
 int	_nc_Match_Next_Character_In_Item_Name(
-		MENU	*menu, 
-		int	ch, 
+		MENU	*menu,
+		int	ch,
 		ITEM	**item)
 		{ return(*(int *)0); }
 
 #undef menu_driver
 int	menu_driver(
-		MENU	*menu, 
+		MENU	*menu,
 		int	c)
 		{ return(*(int *)0); }
 
@@ -103,15 +103,15 @@ int	menu_driver(
 
 #undef set_menu_format
 int	set_menu_format(
-		MENU	*menu, 
-		int	rows, 
+		MENU	*menu,
+		int	rows,
 		int	cols)
 		{ return(*(int *)0); }
 
 #undef menu_format
 void	menu_format(
-		const MENU *menu, 
-		int	*rows, 
+		const MENU *menu,
+		int	*rows,
 		int	*cols)
 		{ /* void */ }
 
@@ -124,7 +124,7 @@ ITEM	_nc_Default_Item;
 
 #undef _nc_Connect_Items
 NCURSES_BOOL _nc_Connect_Items(
-		MENU	*menu, 
+		MENU	*menu,
 		ITEM	**items)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -155,8 +155,8 @@ void	_nc_Show_Menu(
 
 #undef _nc_New_TopRow_and_CurrentItem
 void	_nc_New_TopRow_and_CurrentItem(
-		MENU	*menu, 
-		int	new_toprow, 
+		MENU	*menu,
+		int	new_toprow,
 		ITEM	*new_current_item)
 		{ /* void */ }
 
@@ -164,7 +164,7 @@ void	_nc_New_TopRow_and_CurrentItem(
 
 #undef set_menu_init
 int	set_menu_init(
-		MENU	*menu, 
+		MENU	*menu,
 		Menu_Hook func)
 		{ return(*(int *)0); }
 
@@ -175,7 +175,7 @@ Menu_Hook menu_init(
 
 #undef set_menu_term
 int	set_menu_term(
-		MENU	*menu, 
+		MENU	*menu,
 		Menu_Hook func)
 		{ return(*(int *)0); }
 
@@ -186,7 +186,7 @@ Menu_Hook menu_term(
 
 #undef set_item_init
 int	set_item_init(
-		MENU	*menu, 
+		MENU	*menu,
 		Menu_Hook func)
 		{ return(*(int *)0); }
 
@@ -197,7 +197,7 @@ Menu_Hook item_init(
 
 #undef set_item_term
 int	set_item_term(
-		MENU	*menu, 
+		MENU	*menu,
 		Menu_Hook func)
 		{ return(*(int *)0); }
 
@@ -210,7 +210,7 @@ Menu_Hook item_term(
 
 #undef set_current_item
 int	set_current_item(
-		MENU	*menu, 
+		MENU	*menu,
 		ITEM	*item)
 		{ return(*(int *)0); }
 
@@ -240,7 +240,7 @@ const char *item_description(
 
 #undef new_item
 ITEM	*new_item(
-		const char *name, 
+		const char *name,
 		const char *description)
 		{ return(*(ITEM **)0); }
 
@@ -251,7 +251,7 @@ int	free_item(
 
 #undef set_menu_mark
 int	set_menu_mark(
-		MENU	*menu, 
+		MENU	*menu,
 		const char *mark)
 		{ return(*(int *)0); }
 
@@ -264,19 +264,19 @@ const char *menu_mark(
 
 #undef set_item_opts
 int	set_item_opts(
-		ITEM	*item, 
+		ITEM	*item,
 		Item_Options opts)
 		{ return(*(int *)0); }
 
 #undef item_opts_off
 int	item_opts_off(
-		ITEM	*item, 
+		ITEM	*item,
 		Item_Options opts)
 		{ return(*(int *)0); }
 
 #undef item_opts_on
 int	item_opts_on(
-		ITEM	*item, 
+		ITEM	*item,
 		Item_Options opts)
 		{ return(*(int *)0); }
 
@@ -289,7 +289,7 @@ Item_Options item_opts(
 
 #undef set_top_row
 int	set_top_row(
-		MENU	*menu, 
+		MENU	*menu,
 		int	row)
 		{ return(*(int *)0); }
 
@@ -302,7 +302,7 @@ int	top_row(
 
 #undef set_item_userptr
 int	set_item_userptr(
-		ITEM	*item, 
+		ITEM	*item,
 		void	*userptr)
 		{ return(*(int *)0); }
 
@@ -315,7 +315,7 @@ void	*item_userptr(
 
 #undef set_item_value
 int	set_item_value(
-		ITEM	*item, 
+		ITEM	*item,
 		NCURSES_BOOL value)
 		{ return(*(int *)0); }
 
@@ -335,7 +335,7 @@ NCURSES_BOOL item_visible(
 
 #undef set_menu_items
 int	set_menu_items(
-		MENU	*menu, 
+		MENU	*menu,
 		ITEM	**items)
 		{ return(*(int *)0); }
 
@@ -353,7 +353,7 @@ int	item_count(
 
 #undef new_menu_sp
 MENU	*new_menu_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		ITEM	**items)
 		{ return(*(MENU **)0); }
 
@@ -371,19 +371,19 @@ int	free_menu(
 
 #undef set_menu_opts
 int	set_menu_opts(
-		MENU	*menu, 
+		MENU	*menu,
 		Menu_Options opts)
 		{ return(*(int *)0); }
 
 #undef menu_opts_off
 int	menu_opts_off(
-		MENU	*menu, 
+		MENU	*menu,
 		Menu_Options opts)
 		{ return(*(int *)0); }
 
 #undef menu_opts_on
 int	menu_opts_on(
-		MENU	*menu, 
+		MENU	*menu,
 		Menu_Options opts)
 		{ return(*(int *)0); }
 
@@ -396,7 +396,7 @@ Menu_Options menu_opts(
 
 #undef set_menu_pad
 int	set_menu_pad(
-		MENU	*menu, 
+		MENU	*menu,
 		int	pad)
 		{ return(*(int *)0); }
 
@@ -414,7 +414,7 @@ char	*menu_pattern(
 
 #undef set_menu_pattern
 int	set_menu_pattern(
-		MENU	*menu, 
+		MENU	*menu,
 		const char *p)
 		{ return(*(int *)0); }
 
@@ -422,7 +422,7 @@ int	set_menu_pattern(
 
 #undef _nc_Post_Item
 void	_nc_Post_Item(
-		const MENU *menu, 
+		const MENU *menu,
 		const ITEM *item)
 		{ /* void */ }
 
@@ -457,8 +457,8 @@ int	menu_request_by_name(
 
 #undef scale_menu
 int	scale_menu(
-		const MENU *menu, 
-		int	*rows, 
+		const MENU *menu,
+		int	*rows,
 		int	*cols)
 		{ return(*(int *)0); }
 
@@ -466,17 +466,17 @@ int	scale_menu(
 
 #undef set_menu_spacing
 int	set_menu_spacing(
-		MENU	*menu, 
-		int	s_desc, 
-		int	s_row, 
+		MENU	*menu,
+		int	s_desc,
+		int	s_row,
 		int	s_col)
 		{ return(*(int *)0); }
 
 #undef menu_spacing
 int	menu_spacing(
-		const MENU *menu, 
-		int	*s_desc, 
-		int	*s_row, 
+		const MENU *menu,
+		int	*s_desc,
+		int	*s_row,
 		int	*s_col)
 		{ return(*(int *)0); }
 
@@ -484,7 +484,7 @@ int	menu_spacing(
 
 #undef set_menu_sub
 int	set_menu_sub(
-		MENU	*menu, 
+		MENU	*menu,
 		WINDOW	*win)
 		{ return(*(int *)0); }
 
@@ -529,7 +529,7 @@ Menu_Options _nc_retrace_menu_opts(
 
 #undef set_menu_userptr
 int	set_menu_userptr(
-		MENU	*menu, 
+		MENU	*menu,
 		void	*userptr)
 		{ return(*(int *)0); }
 
@@ -542,7 +542,7 @@ void	*menu_userptr(
 
 #undef set_menu_win
 int	set_menu_win(
-		MENU	*menu, 
+		MENU	*menu,
 		WINDOW	*win)
 		{ return(*(int *)0); }
 
diff --git a/contrib/ncurses/menu/llib-lmenutw b/contrib/ncurses/menu/llib-lmenutw
index 1d348c09d2bb..0a0d05947222 100644
--- a/contrib/ncurses/menu/llib-lmenutw
+++ b/contrib/ncurses/menu/llib-lmenutw
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 2010,2015 Free Software Foundation, Inc.                       *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -38,7 +38,7 @@
 
 #undef set_menu_fore
 int	set_menu_fore(
-		MENU	*menu, 
+		MENU	*menu,
 		chtype	attr)
 		{ return(*(int *)0); }
 
@@ -49,7 +49,7 @@ chtype	menu_fore(
 
 #undef set_menu_back
 int	set_menu_back(
-		MENU	*menu, 
+		MENU	*menu,
 		chtype	attr)
 		{ return(*(int *)0); }
 
@@ -60,7 +60,7 @@ chtype	menu_back(
 
 #undef set_menu_grey
 int	set_menu_grey(
-		MENU	*menu, 
+		MENU	*menu,
 		chtype	attr)
 		{ return(*(int *)0); }
 
@@ -73,9 +73,9 @@ chtype	menu_grey(
 
 #undef _nc_menu_cursor_pos
 int	_nc_menu_cursor_pos(
-		const MENU *menu, 
-		const ITEM *item, 
-		int	*pY, 
+		const MENU *menu,
+		const ITEM *item,
+		int	*pY,
 		int	*pX)
 		{ return(*(int *)0); }
 
@@ -88,14 +88,14 @@ int	pos_menu_cursor(
 
 #undef _nc_Match_Next_Character_In_Item_Name
 int	_nc_Match_Next_Character_In_Item_Name(
-		MENU	*menu, 
-		int	ch, 
+		MENU	*menu,
+		int	ch,
 		ITEM	**item)
 		{ return(*(int *)0); }
 
 #undef menu_driver
 int	menu_driver(
-		MENU	*menu, 
+		MENU	*menu,
 		int	c)
 		{ return(*(int *)0); }
 
@@ -103,15 +103,15 @@ int	menu_driver(
 
 #undef set_menu_format
 int	set_menu_format(
-		MENU	*menu, 
-		int	rows, 
+		MENU	*menu,
+		int	rows,
 		int	cols)
 		{ return(*(int *)0); }
 
 #undef menu_format
 void	menu_format(
-		const MENU *menu, 
-		int	*rows, 
+		const MENU *menu,
+		int	*rows,
 		int	*cols)
 		{ /* void */ }
 
@@ -124,7 +124,7 @@ ITEM	_nc_Default_Item;
 
 #undef _nc_Connect_Items
 NCURSES_BOOL _nc_Connect_Items(
-		MENU	*menu, 
+		MENU	*menu,
 		ITEM	**items)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -155,8 +155,8 @@ void	_nc_Show_Menu(
 
 #undef _nc_New_TopRow_and_CurrentItem
 void	_nc_New_TopRow_and_CurrentItem(
-		MENU	*menu, 
-		int	new_toprow, 
+		MENU	*menu,
+		int	new_toprow,
 		ITEM	*new_current_item)
 		{ /* void */ }
 
@@ -164,7 +164,7 @@ void	_nc_New_TopRow_and_CurrentItem(
 
 #undef set_menu_init
 int	set_menu_init(
-		MENU	*menu, 
+		MENU	*menu,
 		Menu_Hook func)
 		{ return(*(int *)0); }
 
@@ -175,7 +175,7 @@ Menu_Hook menu_init(
 
 #undef set_menu_term
 int	set_menu_term(
-		MENU	*menu, 
+		MENU	*menu,
 		Menu_Hook func)
 		{ return(*(int *)0); }
 
@@ -186,7 +186,7 @@ Menu_Hook menu_term(
 
 #undef set_item_init
 int	set_item_init(
-		MENU	*menu, 
+		MENU	*menu,
 		Menu_Hook func)
 		{ return(*(int *)0); }
 
@@ -197,7 +197,7 @@ Menu_Hook item_init(
 
 #undef set_item_term
 int	set_item_term(
-		MENU	*menu, 
+		MENU	*menu,
 		Menu_Hook func)
 		{ return(*(int *)0); }
 
@@ -210,7 +210,7 @@ Menu_Hook item_term(
 
 #undef set_current_item
 int	set_current_item(
-		MENU	*menu, 
+		MENU	*menu,
 		ITEM	*item)
 		{ return(*(int *)0); }
 
@@ -240,7 +240,7 @@ const char *item_description(
 
 #undef new_item
 ITEM	*new_item(
-		const char *name, 
+		const char *name,
 		const char *description)
 		{ return(*(ITEM **)0); }
 
@@ -251,7 +251,7 @@ int	free_item(
 
 #undef set_menu_mark
 int	set_menu_mark(
-		MENU	*menu, 
+		MENU	*menu,
 		const char *mark)
 		{ return(*(int *)0); }
 
@@ -264,19 +264,19 @@ const char *menu_mark(
 
 #undef set_item_opts
 int	set_item_opts(
-		ITEM	*item, 
+		ITEM	*item,
 		Item_Options opts)
 		{ return(*(int *)0); }
 
 #undef item_opts_off
 int	item_opts_off(
-		ITEM	*item, 
+		ITEM	*item,
 		Item_Options opts)
 		{ return(*(int *)0); }
 
 #undef item_opts_on
 int	item_opts_on(
-		ITEM	*item, 
+		ITEM	*item,
 		Item_Options opts)
 		{ return(*(int *)0); }
 
@@ -289,7 +289,7 @@ Item_Options item_opts(
 
 #undef set_top_row
 int	set_top_row(
-		MENU	*menu, 
+		MENU	*menu,
 		int	row)
 		{ return(*(int *)0); }
 
@@ -302,7 +302,7 @@ int	top_row(
 
 #undef set_item_userptr
 int	set_item_userptr(
-		ITEM	*item, 
+		ITEM	*item,
 		void	*userptr)
 		{ return(*(int *)0); }
 
@@ -315,7 +315,7 @@ void	*item_userptr(
 
 #undef set_item_value
 int	set_item_value(
-		ITEM	*item, 
+		ITEM	*item,
 		NCURSES_BOOL value)
 		{ return(*(int *)0); }
 
@@ -335,7 +335,7 @@ NCURSES_BOOL item_visible(
 
 #undef set_menu_items
 int	set_menu_items(
-		MENU	*menu, 
+		MENU	*menu,
 		ITEM	**items)
 		{ return(*(int *)0); }
 
@@ -353,7 +353,7 @@ int	item_count(
 
 #undef new_menu_sp
 MENU	*new_menu_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		ITEM	**items)
 		{ return(*(MENU **)0); }
 
@@ -371,19 +371,19 @@ int	free_menu(
 
 #undef set_menu_opts
 int	set_menu_opts(
-		MENU	*menu, 
+		MENU	*menu,
 		Menu_Options opts)
 		{ return(*(int *)0); }
 
 #undef menu_opts_off
 int	menu_opts_off(
-		MENU	*menu, 
+		MENU	*menu,
 		Menu_Options opts)
 		{ return(*(int *)0); }
 
 #undef menu_opts_on
 int	menu_opts_on(
-		MENU	*menu, 
+		MENU	*menu,
 		Menu_Options opts)
 		{ return(*(int *)0); }
 
@@ -396,7 +396,7 @@ Menu_Options menu_opts(
 
 #undef set_menu_pad
 int	set_menu_pad(
-		MENU	*menu, 
+		MENU	*menu,
 		int	pad)
 		{ return(*(int *)0); }
 
@@ -414,7 +414,7 @@ char	*menu_pattern(
 
 #undef set_menu_pattern
 int	set_menu_pattern(
-		MENU	*menu, 
+		MENU	*menu,
 		const char *p)
 		{ return(*(int *)0); }
 
@@ -422,7 +422,7 @@ int	set_menu_pattern(
 
 #undef _nc_Post_Item
 void	_nc_Post_Item(
-		const MENU *menu, 
+		const MENU *menu,
 		const ITEM *item)
 		{ /* void */ }
 
@@ -457,8 +457,8 @@ int	menu_request_by_name(
 
 #undef scale_menu
 int	scale_menu(
-		const MENU *menu, 
-		int	*rows, 
+		const MENU *menu,
+		int	*rows,
 		int	*cols)
 		{ return(*(int *)0); }
 
@@ -466,17 +466,17 @@ int	scale_menu(
 
 #undef set_menu_spacing
 int	set_menu_spacing(
-		MENU	*menu, 
-		int	s_desc, 
-		int	s_row, 
+		MENU	*menu,
+		int	s_desc,
+		int	s_row,
 		int	s_col)
 		{ return(*(int *)0); }
 
 #undef menu_spacing
 int	menu_spacing(
-		const MENU *menu, 
-		int	*s_desc, 
-		int	*s_row, 
+		const MENU *menu,
+		int	*s_desc,
+		int	*s_row,
 		int	*s_col)
 		{ return(*(int *)0); }
 
@@ -484,7 +484,7 @@ int	menu_spacing(
 
 #undef set_menu_sub
 int	set_menu_sub(
-		MENU	*menu, 
+		MENU	*menu,
 		WINDOW	*win)
 		{ return(*(int *)0); }
 
@@ -529,7 +529,7 @@ Menu_Options _nc_retrace_menu_opts(
 
 #undef set_menu_userptr
 int	set_menu_userptr(
-		MENU	*menu, 
+		MENU	*menu,
 		void	*userptr)
 		{ return(*(int *)0); }
 
@@ -542,7 +542,7 @@ void	*menu_userptr(
 
 #undef set_menu_win
 int	set_menu_win(
-		MENU	*menu, 
+		MENU	*menu,
 		WINDOW	*win)
 		{ return(*(int *)0); }
 
diff --git a/contrib/ncurses/menu/llib-lmenuw b/contrib/ncurses/menu/llib-lmenuw
index 6ad96140a5b0..d5566d489696 100644
--- a/contrib/ncurses/menu/llib-lmenuw
+++ b/contrib/ncurses/menu/llib-lmenuw
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 2002-2010,2015 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -38,7 +38,7 @@
 
 #undef set_menu_fore
 int	set_menu_fore(
-		MENU	*menu, 
+		MENU	*menu,
 		chtype	attr)
 		{ return(*(int *)0); }
 
@@ -49,7 +49,7 @@ chtype	menu_fore(
 
 #undef set_menu_back
 int	set_menu_back(
-		MENU	*menu, 
+		MENU	*menu,
 		chtype	attr)
 		{ return(*(int *)0); }
 
@@ -60,7 +60,7 @@ chtype	menu_back(
 
 #undef set_menu_grey
 int	set_menu_grey(
-		MENU	*menu, 
+		MENU	*menu,
 		chtype	attr)
 		{ return(*(int *)0); }
 
@@ -73,9 +73,9 @@ chtype	menu_grey(
 
 #undef _nc_menu_cursor_pos
 int	_nc_menu_cursor_pos(
-		const MENU *menu, 
-		const ITEM *item, 
-		int	*pY, 
+		const MENU *menu,
+		const ITEM *item,
+		int	*pY,
 		int	*pX)
 		{ return(*(int *)0); }
 
@@ -88,14 +88,14 @@ int	pos_menu_cursor(
 
 #undef _nc_Match_Next_Character_In_Item_Name
 int	_nc_Match_Next_Character_In_Item_Name(
-		MENU	*menu, 
-		int	ch, 
+		MENU	*menu,
+		int	ch,
 		ITEM	**item)
 		{ return(*(int *)0); }
 
 #undef menu_driver
 int	menu_driver(
-		MENU	*menu, 
+		MENU	*menu,
 		int	c)
 		{ return(*(int *)0); }
 
@@ -103,15 +103,15 @@ int	menu_driver(
 
 #undef set_menu_format
 int	set_menu_format(
-		MENU	*menu, 
-		int	rows, 
+		MENU	*menu,
+		int	rows,
 		int	cols)
 		{ return(*(int *)0); }
 
 #undef menu_format
 void	menu_format(
-		const MENU *menu, 
-		int	*rows, 
+		const MENU *menu,
+		int	*rows,
 		int	*cols)
 		{ /* void */ }
 
@@ -124,7 +124,7 @@ ITEM	_nc_Default_Item;
 
 #undef _nc_Connect_Items
 NCURSES_BOOL _nc_Connect_Items(
-		MENU	*menu, 
+		MENU	*menu,
 		ITEM	**items)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -155,8 +155,8 @@ void	_nc_Show_Menu(
 
 #undef _nc_New_TopRow_and_CurrentItem
 void	_nc_New_TopRow_and_CurrentItem(
-		MENU	*menu, 
-		int	new_toprow, 
+		MENU	*menu,
+		int	new_toprow,
 		ITEM	*new_current_item)
 		{ /* void */ }
 
@@ -164,7 +164,7 @@ void	_nc_New_TopRow_and_CurrentItem(
 
 #undef set_menu_init
 int	set_menu_init(
-		MENU	*menu, 
+		MENU	*menu,
 		Menu_Hook func)
 		{ return(*(int *)0); }
 
@@ -175,7 +175,7 @@ Menu_Hook menu_init(
 
 #undef set_menu_term
 int	set_menu_term(
-		MENU	*menu, 
+		MENU	*menu,
 		Menu_Hook func)
 		{ return(*(int *)0); }
 
@@ -186,7 +186,7 @@ Menu_Hook menu_term(
 
 #undef set_item_init
 int	set_item_init(
-		MENU	*menu, 
+		MENU	*menu,
 		Menu_Hook func)
 		{ return(*(int *)0); }
 
@@ -197,7 +197,7 @@ Menu_Hook item_init(
 
 #undef set_item_term
 int	set_item_term(
-		MENU	*menu, 
+		MENU	*menu,
 		Menu_Hook func)
 		{ return(*(int *)0); }
 
@@ -210,7 +210,7 @@ Menu_Hook item_term(
 
 #undef set_current_item
 int	set_current_item(
-		MENU	*menu, 
+		MENU	*menu,
 		ITEM	*item)
 		{ return(*(int *)0); }
 
@@ -240,7 +240,7 @@ const char *item_description(
 
 #undef new_item
 ITEM	*new_item(
-		const char *name, 
+		const char *name,
 		const char *description)
 		{ return(*(ITEM **)0); }
 
@@ -251,7 +251,7 @@ int	free_item(
 
 #undef set_menu_mark
 int	set_menu_mark(
-		MENU	*menu, 
+		MENU	*menu,
 		const char *mark)
 		{ return(*(int *)0); }
 
@@ -264,19 +264,19 @@ const char *menu_mark(
 
 #undef set_item_opts
 int	set_item_opts(
-		ITEM	*item, 
+		ITEM	*item,
 		Item_Options opts)
 		{ return(*(int *)0); }
 
 #undef item_opts_off
 int	item_opts_off(
-		ITEM	*item, 
+		ITEM	*item,
 		Item_Options opts)
 		{ return(*(int *)0); }
 
 #undef item_opts_on
 int	item_opts_on(
-		ITEM	*item, 
+		ITEM	*item,
 		Item_Options opts)
 		{ return(*(int *)0); }
 
@@ -289,7 +289,7 @@ Item_Options item_opts(
 
 #undef set_top_row
 int	set_top_row(
-		MENU	*menu, 
+		MENU	*menu,
 		int	row)
 		{ return(*(int *)0); }
 
@@ -302,7 +302,7 @@ int	top_row(
 
 #undef set_item_userptr
 int	set_item_userptr(
-		ITEM	*item, 
+		ITEM	*item,
 		void	*userptr)
 		{ return(*(int *)0); }
 
@@ -315,7 +315,7 @@ void	*item_userptr(
 
 #undef set_item_value
 int	set_item_value(
-		ITEM	*item, 
+		ITEM	*item,
 		NCURSES_BOOL value)
 		{ return(*(int *)0); }
 
@@ -335,7 +335,7 @@ NCURSES_BOOL item_visible(
 
 #undef set_menu_items
 int	set_menu_items(
-		MENU	*menu, 
+		MENU	*menu,
 		ITEM	**items)
 		{ return(*(int *)0); }
 
@@ -353,7 +353,7 @@ int	item_count(
 
 #undef new_menu_sp
 MENU	*new_menu_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		ITEM	**items)
 		{ return(*(MENU **)0); }
 
@@ -371,19 +371,19 @@ int	free_menu(
 
 #undef set_menu_opts
 int	set_menu_opts(
-		MENU	*menu, 
+		MENU	*menu,
 		Menu_Options opts)
 		{ return(*(int *)0); }
 
 #undef menu_opts_off
 int	menu_opts_off(
-		MENU	*menu, 
+		MENU	*menu,
 		Menu_Options opts)
 		{ return(*(int *)0); }
 
 #undef menu_opts_on
 int	menu_opts_on(
-		MENU	*menu, 
+		MENU	*menu,
 		Menu_Options opts)
 		{ return(*(int *)0); }
 
@@ -396,7 +396,7 @@ Menu_Options menu_opts(
 
 #undef set_menu_pad
 int	set_menu_pad(
-		MENU	*menu, 
+		MENU	*menu,
 		int	pad)
 		{ return(*(int *)0); }
 
@@ -414,7 +414,7 @@ char	*menu_pattern(
 
 #undef set_menu_pattern
 int	set_menu_pattern(
-		MENU	*menu, 
+		MENU	*menu,
 		const char *p)
 		{ return(*(int *)0); }
 
@@ -422,7 +422,7 @@ int	set_menu_pattern(
 
 #undef _nc_Post_Item
 void	_nc_Post_Item(
-		const MENU *menu, 
+		const MENU *menu,
 		const ITEM *item)
 		{ /* void */ }
 
@@ -457,8 +457,8 @@ int	menu_request_by_name(
 
 #undef scale_menu
 int	scale_menu(
-		const MENU *menu, 
-		int	*rows, 
+		const MENU *menu,
+		int	*rows,
 		int	*cols)
 		{ return(*(int *)0); }
 
@@ -466,17 +466,17 @@ int	scale_menu(
 
 #undef set_menu_spacing
 int	set_menu_spacing(
-		MENU	*menu, 
-		int	s_desc, 
-		int	s_row, 
+		MENU	*menu,
+		int	s_desc,
+		int	s_row,
 		int	s_col)
 		{ return(*(int *)0); }
 
 #undef menu_spacing
 int	menu_spacing(
-		const MENU *menu, 
-		int	*s_desc, 
-		int	*s_row, 
+		const MENU *menu,
+		int	*s_desc,
+		int	*s_row,
 		int	*s_col)
 		{ return(*(int *)0); }
 
@@ -484,7 +484,7 @@ int	menu_spacing(
 
 #undef set_menu_sub
 int	set_menu_sub(
-		MENU	*menu, 
+		MENU	*menu,
 		WINDOW	*win)
 		{ return(*(int *)0); }
 
@@ -529,7 +529,7 @@ Menu_Options _nc_retrace_menu_opts(
 
 #undef set_menu_userptr
 int	set_menu_userptr(
-		MENU	*menu, 
+		MENU	*menu,
 		void	*userptr)
 		{ return(*(int *)0); }
 
@@ -542,7 +542,7 @@ void	*menu_userptr(
 
 #undef set_menu_win
 int	set_menu_win(
-		MENU	*menu, 
+		MENU	*menu,
 		WINDOW	*win)
 		{ return(*(int *)0); }
 
diff --git a/contrib/ncurses/menu/m_attribs.c b/contrib/ncurses/menu/m_attribs.c
index 5cd94d342475..a9275d08049e 100644
--- a/contrib/ncurses/menu/m_attribs.c
+++ b/contrib/ncurses/menu/m_attribs.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2010,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -38,7 +38,7 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_attribs.c,v 1.19 2020/07/04 19:44:58 tom Exp $")
+MODULE_ID("$Id: m_attribs.c,v 1.20 2021/06/17 21:20:30 tom Exp $")
 
 /* Macro to redraw menu if it is posted and changed */
 #define Refresh_Menu(menu) \
@@ -73,69 +73,69 @@ MENU_EXPORT(chtype) NCURSES_API menu_ ## name (const MENU * menu)\
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  int set_menu_fore(MENU *menu, chtype attr)
-|   
+|
 |   Description   :  Set the attribute for selectable items. In single-
 |                    valued menus this is used to highlight the current
 |                    item ((i.e. where the cursor is), in multi-valued
 |                    menus this is used to highlight the selected items.
 |
 |   Return Values :  E_OK              - success
-|                    E_BAD_ARGUMENT    - an invalid value has been passed   
+|                    E_BAD_ARGUMENT    - an invalid value has been passed
 +--------------------------------------------------------------------------*/
 GEN_MENU_ATTR_SET_FCT(fore)
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  chtype menu_fore(const MENU* menu)
-|   
+|
 |   Description   :  Return the attribute used for selectable items that
 |                    are current (single-valued menu) or selected (multi-
-|                    valued menu).   
+|                    valued menu).
 |
 |   Return Values :  Attribute value
 +--------------------------------------------------------------------------*/
 GEN_MENU_ATTR_GET_FCT(fore)
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  int set_menu_back(MENU *menu, chtype attr)
-|   
+|
 |   Description   :  Set the attribute for selectable but not yet selected
 |                    items.
 |
-|   Return Values :  E_OK             - success  
+|   Return Values :  E_OK             - success
 |                    E_BAD_ARGUMENT   - an invalid value has been passed
 +--------------------------------------------------------------------------*/
 GEN_MENU_ATTR_SET_FCT(back)
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  chtype menu_back(const MENU *menu)
-|   
+|
 |   Description   :  Return the attribute used for selectable but not yet
-|                    selected items. 
+|                    selected items.
 |
 |   Return Values :  Attribute value
 +--------------------------------------------------------------------------*/
 GEN_MENU_ATTR_GET_FCT(back)
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  int set_menu_grey(MENU *menu, chtype attr)
-|   
+|
 |   Description   :  Set the attribute for unselectable items.
 |
 |   Return Values :  E_OK             - success
-|                    E_BAD_ARGUMENT   - an invalid value has been passed    
+|                    E_BAD_ARGUMENT   - an invalid value has been passed
 +--------------------------------------------------------------------------*/
 GEN_MENU_ATTR_SET_FCT(grey)
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  chtype menu_grey(const MENU *menu)
-|   
+|
 |   Description   :  Return the attribute used for non-selectable items
 |
 |   Return Values :  Attribute value
diff --git a/contrib/ncurses/menu/m_cursor.c b/contrib/ncurses/menu/m_cursor.c
index 8cf15ce51335..b9b301d3eb90 100644
--- a/contrib/ncurses/menu/m_cursor.c
+++ b/contrib/ncurses/menu/m_cursor.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2009,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -38,7 +38,7 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_cursor.c,v 1.25 2020/12/12 00:38:02 tom Exp $")
+MODULE_ID("$Id: m_cursor.c,v 1.26 2021/03/27 23:46:29 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu
@@ -83,7 +83,6 @@ _nc_menu_cursor_pos(const MENU *menu, const ITEM *item, int *pY, int *pX)
 MENU_EXPORT(int)
 pos_menu_cursor(const MENU *menu)
 {
-  WINDOW *win, *sub;
   int x = 0, y = 0;
   int err = _nc_menu_cursor_pos(menu, (ITEM *)0, &y, &x);
 
@@ -91,8 +90,9 @@ pos_menu_cursor(const MENU *menu)
 
   if (E_OK == err)
     {
-      win = Get_Menu_UserWin(menu);
-      sub = menu->usersub ? menu->usersub : win;
+      WINDOW *win = Get_Menu_UserWin(menu);
+      WINDOW *sub = menu->usersub ? menu->usersub : win;
+
       assert(win && sub);
 
       if ((menu->opt & O_SHOWMATCH) && (menu->pindex > 0))
diff --git a/contrib/ncurses/menu/m_driver.c b/contrib/ncurses/menu/m_driver.c
index b1d7c3541b53..cf2ef2fe05c6 100644
--- a/contrib/ncurses/menu/m_driver.c
+++ b/contrib/ncurses/menu/m_driver.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2012,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -38,7 +38,7 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_driver.c,v 1.36 2020/12/12 00:38:02 tom Exp $")
+MODULE_ID("$Id: m_driver.c,v 1.37 2021/03/27 23:46:29 tom Exp $")
 
 /* Macros */
 
@@ -220,7 +220,7 @@ menu_driver(MENU *menu, int c)
 
   int result = E_OK;
   ITEM *item;
-  int my_top_row, rdiff;
+  int my_top_row;
 
   T((T_CALLED("menu_driver(%p,%d)"), (void *)menu, c));
 
@@ -239,6 +239,8 @@ menu_driver(MENU *menu, int c)
 
   if ((c > KEY_MAX) && (c <= MAX_MENU_COMMAND))
     {
+      int rdiff;
+
       if (!((c == REQ_BACK_PATTERN)
 	    || (c == REQ_NEXT_MATCH) || (c == REQ_PREV_MATCH)))
 	{
@@ -489,16 +491,20 @@ menu_driver(MENU *menu, int c)
 		    }
 		  else if (wenclose(sub, event.y, event.x))
 		    {		/* Inside the area we try to find the hit item */
-		      int i, x, y, err;
+		      int x, y;
 
 		      ry = event.y;
 		      rx = event.x;
 		      if (wmouse_trafo(sub, &ry, &rx, FALSE))
 			{
+			  int i;
+
 			  for (i = 0; i < menu->nitems; i++)
 			    {
-			      err = _nc_menu_cursor_pos(menu, menu->items[i],
-							&y, &x);
+			      int err = _nc_menu_cursor_pos(menu,
+							    menu->items[i],
+							    &y, &x);
+
 			      if (E_OK == err)
 				{
 				  if ((ry == y) &&
diff --git a/contrib/ncurses/menu/m_format.c b/contrib/ncurses/menu/m_format.c
index 848de0b21118..65adfc6bfcb0 100644
--- a/contrib/ncurses/menu/m_format.c
+++ b/contrib/ncurses/menu/m_format.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2010,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -38,7 +38,7 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_format.c,v 1.21 2020/12/12 00:38:02 tom Exp $")
+MODULE_ID("$Id: m_format.c,v 1.22 2021/03/27 23:46:29 tom Exp $")
 
 #define minimum(a,b) ((a)<(b) ? (a): (b))
 
@@ -59,7 +59,6 @@ MODULE_ID("$Id: m_format.c,v 1.21 2020/12/12 00:38:02 tom Exp $")
 MENU_EXPORT(int)
 set_menu_format(MENU *menu, int rows, int cols)
 {
-  int total_rows, total_cols;
 
   T((T_CALLED("set_menu_format(%p,%d,%d)"), (void *)menu, rows, cols));
 
@@ -68,6 +67,8 @@ set_menu_format(MENU *menu, int rows, int cols)
 
   if (menu)
     {
+      int total_rows, total_cols;
+
       if (menu->status & _POSTED)
 	RETURN(E_POSTED);
 
diff --git a/contrib/ncurses/menu/m_global.c b/contrib/ncurses/menu/m_global.c
index 2e5211468a86..4bc8ef8fc8c1 100644
--- a/contrib/ncurses/menu/m_global.c
+++ b/contrib/ncurses/menu/m_global.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020-2021,2023 Thomas E. Dickey                                *
  * Copyright 1998-2012,2014 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -38,7 +38,7 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_global.c,v 1.32 2020/12/12 00:38:02 tom Exp $")
+MODULE_ID("$Id: m_global.c,v 1.34 2023/09/16 16:39:26 tom Exp $")
 
 static char mark[] = "-";
 /* *INDENT-OFF* */
@@ -113,12 +113,12 @@ ComputeMaximum_NameDesc_Lengths(MENU *menu)
   unsigned MaximumNameLength = 0;
   unsigned MaximumDescriptionLength = 0;
   ITEM **items;
-  unsigned check;
 
   assert(menu && menu->items);
   for (items = menu->items; *items; items++)
     {
-      check = (unsigned)_nc_Calculate_Text_Width(&((*items)->name));
+      unsigned check = (unsigned)_nc_Calculate_Text_Width(&((*items)->name));
+
       if (check > MaximumNameLength)
 	MaximumNameLength = check;
 
@@ -174,11 +174,12 @@ ResetConnectionInfo(MENU *menu, ITEM **items)
 MENU_EXPORT(bool)
 _nc_Connect_Items(MENU *menu, ITEM **items)
 {
-  ITEM **item;
   unsigned int ItemCount = 0;
 
   if (menu && items)
     {
+      ITEM **item;
+
       for (item = items; *item; item++)
 	{
 	  if ((*item)->imenu)
@@ -292,23 +293,19 @@ static int
 calculate_actual_width(MENU *menu, bool name)
 {
   int width = 0;
-  int check = 0;
-  ITEM **items;
 
   assert(menu && menu->items);
 
   if (menu->items != 0)
     {
+      ITEM **items;
+
       for (items = menu->items; *items; items++)
 	{
-	  if (name)
-	    {
-	      check = _nc_Calculate_Text_Width(&((*items)->name));
-	    }
-	  else
-	    {
-	      check = _nc_Calculate_Text_Width(&((*items)->description));
-	    }
+	  int check = (name
+		       ? _nc_Calculate_Text_Width(&((*items)->name))
+		       : _nc_Calculate_Text_Width(&((*items)->description)));
+
 	  if (check > width)
 	    width = check;
 	}
@@ -381,7 +378,7 @@ _nc_Link_Items(MENU *menu)
 {
   if (menu && menu->items && *(menu->items))
     {
-      int i, j;
+      int i;
       ITEM *item;
       int Number_Of_Items = menu->nitems;
       int col = 0, row = 0;
@@ -444,6 +441,7 @@ _nc_Link_Items(MENU *menu)
       else
 	{
 	  int Number_Of_Rows = menu->rows;
+	  int j;
 
 	  for (j = 0; j < Number_Of_Items; j++)
 	    {
@@ -506,12 +504,12 @@ _nc_Link_Items(MENU *menu)
 MENU_EXPORT(void)
 _nc_Show_Menu(const MENU *menu)
 {
-  WINDOW *win;
-  int maxy, maxx;
-
   assert(menu);
   if ((menu->status & _POSTED) && !(menu->status & _IN_DRIVER))
     {
+      WINDOW *win;
+      int maxy, maxx;
+
       /* adjust the internal subwindow to start on the current top */
       assert(menu->sub);
       mvderwin(menu->sub, menu->spc_rows * menu->toprow, 0);
@@ -549,13 +547,13 @@ _nc_New_TopRow_and_CurrentItem(
 				int new_toprow,
 				ITEM *new_current_item)
 {
-  ITEM *cur_item;
-  bool mterm_called = FALSE;
-  bool iterm_called = FALSE;
-
   assert(menu);
   if (menu->status & _POSTED)
     {
+      ITEM *cur_item;
+      bool mterm_called = FALSE;
+      bool iterm_called = FALSE;
+
       if (new_current_item != menu->curitem)
 	{
 	  Call_Hook(menu, itemterm);
@@ -570,7 +568,7 @@ _nc_New_TopRow_and_CurrentItem(
       cur_item = menu->curitem;
       assert(cur_item);
       menu->toprow = (short)(((menu->rows - menu->frows) >= 0)
-			     ? min(menu->rows - menu->frows, new_toprow)
+			     ? Min(menu->rows - menu->frows, new_toprow)
 			     : 0);
       menu->curitem = new_current_item;
 
@@ -594,7 +592,7 @@ _nc_New_TopRow_and_CurrentItem(
   else
     {				/* if we are not posted, this is quite simple */
       menu->toprow = (short)(((menu->rows - menu->frows) >= 0)
-			     ? min(menu->rows - menu->frows, new_toprow)
+			     ? Min(menu->rows - menu->frows, new_toprow)
 			     : 0);
       menu->curitem = new_current_item;
     }
diff --git a/contrib/ncurses/menu/m_hook.c b/contrib/ncurses/menu/m_hook.c
index 916b9fc7ce7d..c7d9fe91af7f 100644
--- a/contrib/ncurses/menu/m_hook.c
+++ b/contrib/ncurses/menu/m_hook.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2018-2020,2021 Thomas E. Dickey                                *
  * Copyright 1998-2012,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -38,7 +38,7 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_hook.c,v 1.20 2020/07/04 19:45:16 tom Exp $")
+MODULE_ID("$Id: m_hook.c,v 1.21 2021/06/17 21:26:02 tom Exp $")
 
 /* "Template" macro to generate function to set application specific hook */
 #define GEN_HOOK_SET_FUNCTION( typ, name ) \
@@ -59,9 +59,9 @@ MENU_EXPORT(Menu_Hook) NCURSES_API typ ## _ ## name ( const MENU *menu )\
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  int set_menu_init(MENU *menu, void (*f)(MENU *))
-|   
+|
 |   Description   :  Set user-exit which is called when menu is posted
 |                    or just after the top row changes.
 |
@@ -70,11 +70,11 @@ MENU_EXPORT(Menu_Hook) NCURSES_API typ ## _ ## name ( const MENU *menu )\
 GEN_HOOK_SET_FUNCTION(menu, init)
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  void (*)(MENU *) menu_init(const MENU *menu)
-|   
+|
 |   Description   :  Return address of user-exit function which is called
-|                    when a menu is posted or just after the top row 
+|                    when a menu is posted or just after the top row
 |                    changes.
 |
 |   Return Values :  Menu init function address or NULL
@@ -82,9 +82,9 @@ GEN_HOOK_SET_FUNCTION(menu, init)
 GEN_HOOK_GET_FUNCTION(menu, init)
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  int set_menu_term (MENU *menu, void (*f)(MENU *))
-|   
+|
 |   Description   :  Set user-exit which is called when menu is unposted
 |                    or just before the top row changes.
 |
@@ -93,11 +93,11 @@ GEN_HOOK_GET_FUNCTION(menu, init)
 GEN_HOOK_SET_FUNCTION(menu, term)
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  void (*)(MENU *) menu_term(const MENU *menu)
-|   
+|
 |   Description   :  Return address of user-exit function which is called
-|                    when a menu is unposted or just before the top row 
+|                    when a menu is unposted or just before the top row
 |                    changes.
 |
 |   Return Values :  Menu finalization function address or NULL
@@ -105,9 +105,9 @@ GEN_HOOK_SET_FUNCTION(menu, term)
 GEN_HOOK_GET_FUNCTION(menu, term)
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  int set_item_init (MENU *menu, void (*f)(MENU *))
-|   
+|
 |   Description   :  Set user-exit which is called when menu is posted
 |                    or just after the current item changes.
 |
@@ -116,11 +116,11 @@ GEN_HOOK_GET_FUNCTION(menu, term)
 GEN_HOOK_SET_FUNCTION(item, init)
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  void (*)(MENU *) item_init (const MENU *menu)
-|   
+|
 |   Description   :  Return address of user-exit function which is called
-|                    when a menu is posted or just after the current item 
+|                    when a menu is posted or just after the current item
 |                    changes.
 |
 |   Return Values :  Item init function address or NULL
@@ -128,9 +128,9 @@ GEN_HOOK_SET_FUNCTION(item, init)
 GEN_HOOK_GET_FUNCTION(item, init)
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  int set_item_term (MENU *menu, void (*f)(MENU *))
-|   
+|
 |   Description   :  Set user-exit which is called when menu is unposted
 |                    or just before the current item changes.
 |
@@ -139,11 +139,11 @@ GEN_HOOK_GET_FUNCTION(item, init)
 GEN_HOOK_SET_FUNCTION(item, term)
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  void (*)(MENU *) item_init (const MENU *menu)
-|   
+|
 |   Description   :  Return address of user-exit function which is called
-|                    when a menu is unposted or just before the current item 
+|                    when a menu is unposted or just before the current item
 |                    changes.
 |
 |   Return Values :  Item finalization function address or NULL
diff --git a/contrib/ncurses/menu/m_item_cur.c b/contrib/ncurses/menu/m_item_cur.c
index dcb0be156ac5..ed76518211d8 100644
--- a/contrib/ncurses/menu/m_item_cur.c
+++ b/contrib/ncurses/menu/m_item_cur.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2004,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -38,12 +38,12 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_item_cur.c,v 1.21 2020/12/12 00:38:02 tom Exp $")
+MODULE_ID("$Id: m_item_cur.c,v 1.22 2021/06/17 21:20:30 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  int set_current_item(MENU *menu, const ITEM *item)
-|   
+|
 |   Description   :  Make the item the current item
 |
 |   Return Values :  E_OK                - success
@@ -82,9 +82,9 @@ set_current_item(MENU *menu, ITEM *item)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  ITEM *current_item(const MENU *menu)
-|   
+|
 |   Description   :  Return the menus current item
 |
 |   Return Values :  Item pointer or NULL if failure
@@ -97,9 +97,9 @@ current_item(const MENU *menu)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  int item_index(const ITEM *)
-|   
+|
 |   Description   :  Return the logical index of this item.
 |
 |   Return Values :  The index or ERR if this is an invalid item pointer
diff --git a/contrib/ncurses/menu/m_item_nam.c b/contrib/ncurses/menu/m_item_nam.c
index 92966270454d..ce74531f0f4c 100644
--- a/contrib/ncurses/menu/m_item_nam.c
+++ b/contrib/ncurses/menu/m_item_nam.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2004,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -38,12 +38,12 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_item_nam.c,v 1.18 2020/12/12 00:38:08 tom Exp $")
+MODULE_ID("$Id: m_item_nam.c,v 1.19 2021/06/17 21:20:30 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  char *item_name(const ITEM *item)
-|   
+|
 |   Description   :  Return name of menu item
 |
 |   Return Values :  See above; returns NULL if item is invalid
@@ -56,9 +56,9 @@ item_name(const ITEM *item)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  char *item_description(const ITEM *item)
-|   
+|
 |   Description   :  Returns description of item
 |
 |   Return Values :  See above; Returns NULL if item is invalid
diff --git a/contrib/ncurses/menu/m_item_new.c b/contrib/ncurses/menu/m_item_new.c
index 4e3f67bacdd0..28b71caf5b07 100644
--- a/contrib/ncurses/menu/m_item_new.c
+++ b/contrib/ncurses/menu/m_item_new.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020,2021 Thomas E. Dickey                                     *
+ * Copyright 2020-2021 Thomas E. Dickey                                     *
  * Copyright 1998-2010,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -45,12 +45,12 @@
 #endif
 #endif
 
-MODULE_ID("$Id: m_item_new.c,v 1.37 2021/02/13 19:40:51 tom Exp $")
+MODULE_ID("$Id: m_item_new.c,v 1.38 2021/06/17 21:26:02 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  bool Is_Printable_String(const char *s)
-|   
+|
 |   Description   :  Checks whether or not the string contains only printable
 |                    characters.
 |
@@ -98,9 +98,9 @@ Is_Printable_String(const char *s)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  ITEM *new_item(char *name, char *description)
-|   
+|
 |   Description   :  Create a new item with name and description. Return
 |                    a pointer to this new item.
 |                    N.B.: an item must(!) have a name.
@@ -152,15 +152,15 @@ new_item(const char *name, const char *description)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  int free_item(ITEM *item)
-|   
-|   Description   :  Free the allocated storage for this item. 
+|
+|   Description   :  Free the allocated storage for this item.
 |                    N.B.: a connected item can't be freed.
 |
 |   Return Values :  E_OK              - success
 |                    E_BAD_ARGUMENT    - invalid value has been passed
-|                    E_CONNECTED       - item is still connected to a menu    
+|                    E_CONNECTED       - item is still connected to a menu
 +--------------------------------------------------------------------------*/
 MENU_EXPORT(int)
 free_item(ITEM *item)
@@ -179,16 +179,16 @@ free_item(ITEM *item)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  int set_menu_mark( MENU *menu, const char *mark )
-|   
+|
 |   Description   :  Set the mark string used to indicate the current
 |                    item (single-valued menu) or the selected items
 |                    (multi-valued menu).
-|                    The mark argument may be NULL, in which case no 
+|                    The mark argument may be NULL, in which case no
 |                    marker is used.
-|                    This might be a little bit tricky, because this may 
-|                    affect the geometry of the menu, which we don't allow 
+|                    This might be a little bit tricky, because this may
+|                    affect the geometry of the menu, which we don't allow
 |                    if it is already posted.
 |
 |   Return Values :  E_OK               - success
@@ -260,9 +260,9 @@ set_menu_mark(MENU *menu, const char *mark)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  char *menu_mark(const MENU *menu)
-|   
+|
 |   Description   :  Return a pointer to the marker string
 |
 |   Return Values :  The marker string pointer or NULL if no marker defined
diff --git a/contrib/ncurses/menu/m_item_opt.c b/contrib/ncurses/menu/m_item_opt.c
index 985fd2988c37..495e409b601b 100644
--- a/contrib/ncurses/menu/m_item_opt.c
+++ b/contrib/ncurses/menu/m_item_opt.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2004,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -38,12 +38,12 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_item_opt.c,v 1.21 2020/12/12 00:38:08 tom Exp $")
+MODULE_ID("$Id: m_item_opt.c,v 1.22 2021/06/17 21:20:30 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
-|   Function      :  int set_item_opts(ITEM *item, Item_Options opts)  
-|   
+|   Facility      :  libnmenu
+|   Function      :  int set_item_opts(ITEM *item, Item_Options opts)
+|
 |   Description   :  Set the options of the item. If there are relevant
 |                    changes, the item is connected and the menu is posted,
 |                    the menu will be redisplayed.
@@ -86,9 +86,9 @@ set_item_opts(ITEM *item, Item_Options opts)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
-|   Function      :  int item_opts_off(ITEM *item, Item_Options opts)   
-|   
+|   Facility      :  libnmenu
+|   Function      :  int item_opts_off(ITEM *item, Item_Options opts)
+|
 |   Description   :  Switch of the options for this item.
 |
 |   Return Values :  E_OK            - success
@@ -114,9 +114,9 @@ item_opts_off(ITEM *item, Item_Options opts)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
-|   Function      :  int item_opts_on(ITEM *item, Item_Options opts)   
-|   
+|   Facility      :  libnmenu
+|   Function      :  int item_opts_on(ITEM *item, Item_Options opts)
+|
 |   Description   :  Switch on the options for this item.
 |
 |   Return Values :  E_OK            - success
@@ -143,9 +143,9 @@ item_opts_on(ITEM *item, Item_Options opts)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
-|   Function      :  Item_Options item_opts(const ITEM *item)   
-|   
+|   Facility      :  libnmenu
+|   Function      :  Item_Options item_opts(const ITEM *item)
+|
 |   Description   :  Switch of the options for this item.
 |
 |   Return Values :  Items options
diff --git a/contrib/ncurses/menu/m_item_top.c b/contrib/ncurses/menu/m_item_top.c
index ee0d17b43dd5..68303c7676b5 100644
--- a/contrib/ncurses/menu/m_item_top.c
+++ b/contrib/ncurses/menu/m_item_top.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2004,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -38,12 +38,12 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_item_top.c,v 1.14 2020/12/12 00:38:08 tom Exp $")
+MODULE_ID("$Id: m_item_top.c,v 1.16 2021/06/17 21:11:08 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  int set_top_row(MENU *menu, int row)
-|   
+|
 |   Description   :  Makes the specified row the top row in the menu
 |
 |   Return Values :  E_OK             - success
@@ -53,8 +53,6 @@ MODULE_ID("$Id: m_item_top.c,v 1.14 2020/12/12 00:38:08 tom Exp $")
 MENU_EXPORT(int)
 set_top_row(MENU *menu, int row)
 {
-  ITEM *item;
-
   T((T_CALLED("set_top_row(%p,%d)"), (void *)menu, row));
 
   if (menu)
@@ -72,6 +70,8 @@ set_top_row(MENU *menu, int row)
 
   if (row != menu->toprow)
     {
+      ITEM *item;
+
       if (menu->status & _LINK_NEEDED)
 	_nc_Link_Items(menu);
 
@@ -85,9 +85,9 @@ set_top_row(MENU *menu, int row)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  int top_row(const MENU *)
-|   
+|
 |   Description   :  Return the top row of the menu
 |
 |   Return Values :  The row number or ERR if there is no row
diff --git a/contrib/ncurses/menu/m_item_val.c b/contrib/ncurses/menu/m_item_val.c
index a5c38e2716dc..3163f4b7216e 100644
--- a/contrib/ncurses/menu/m_item_val.c
+++ b/contrib/ncurses/menu/m_item_val.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2004,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -38,17 +38,17 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_item_val.c,v 1.18 2020/12/12 00:38:08 tom Exp $")
+MODULE_ID("$Id: m_item_val.c,v 1.20 2021/06/17 21:11:08 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  int set_item_value(ITEM *item, int value)
-|   
+|
 |   Description   :  Programmatically set the item's selection value. This is
 |                    only allowed if the item is selectable at all and if
 |                    it is not connected to a single-valued menu.
 |                    If the item is connected to a posted menu, the menu
-|                    will be redisplayed.  
+|                    will be redisplayed.
 |
 |   Return Values :  E_OK              - success
 |                    E_REQUEST_DENIED  - not selectable or single valued menu
@@ -56,12 +56,10 @@ MODULE_ID("$Id: m_item_val.c,v 1.18 2020/12/12 00:38:08 tom Exp $")
 MENU_EXPORT(int)
 set_item_value(ITEM *item, bool value)
 {
-  MENU *menu;
-
   T((T_CALLED("set_item_value(%p,%d)"), (void *)item, value));
   if (item)
     {
-      menu = item->imenu;
+      MENU *menu = item->imenu;
 
       if ((!(item->opt & O_SELECTABLE)) ||
 	  (menu && (menu->opt & O_ONEVALUE)))
@@ -87,9 +85,9 @@ set_item_value(ITEM *item, bool value)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  bool item_value(const ITEM *item)
-|   
+|
 |   Description   :  Return the selection value of the item
 |
 |   Return Values :  TRUE   - if item is selected
diff --git a/contrib/ncurses/menu/m_item_vis.c b/contrib/ncurses/menu/m_item_vis.c
index 8e409cb864ad..9ae4fdb0a689 100644
--- a/contrib/ncurses/menu/m_item_vis.c
+++ b/contrib/ncurses/menu/m_item_vis.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2004,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -38,12 +38,12 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_item_vis.c,v 1.19 2020/12/12 00:38:08 tom Exp $")
+MODULE_ID("$Id: m_item_vis.c,v 1.20 2021/06/17 21:20:30 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  bool item_visible(const ITEM *item)
-|   
+|
 |   Description   :  A item is visible if it currently appears in the
 |                    subwindow of a posted menu.
 |
diff --git a/contrib/ncurses/menu/m_items.c b/contrib/ncurses/menu/m_items.c
index 5b24cb76a01d..ecc5e2f05be0 100644
--- a/contrib/ncurses/menu/m_items.c
+++ b/contrib/ncurses/menu/m_items.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2005,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -38,12 +38,12 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_items.c,v 1.20 2020/12/12 00:38:08 tom Exp $")
+MODULE_ID("$Id: m_items.c,v 1.21 2021/06/17 21:20:30 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  int set_menu_items(MENU *menu, ITEM **items)
-|   
+|
 |   Description   :  Sets the item pointer array connected to menu.
 |
 |   Return Values :  E_OK           - success
@@ -78,9 +78,9 @@ set_menu_items(MENU *menu, ITEM **items)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  ITEM **menu_items(const MENU *menu)
-|   
+|
 |   Description   :  Returns a pointer to the item pointer array of the menu
 |
 |   Return Values :  NULL on error
@@ -93,11 +93,11 @@ menu_items(const MENU *menu)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  int item_count(const MENU *menu)
-|   
+|
 |   Description   :  Get the number of items connected to the menu. If the
-|                    menu pointer is NULL we return -1.         
+|                    menu pointer is NULL we return -1.
 |
 |   Return Values :  Number of items or -1 to indicate error.
 +--------------------------------------------------------------------------*/
diff --git a/contrib/ncurses/menu/m_new.c b/contrib/ncurses/menu/m_new.c
index 82c410c6a96a..be175581ba19 100644
--- a/contrib/ncurses/menu/m_new.c
+++ b/contrib/ncurses/menu/m_new.c
@@ -38,12 +38,12 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_new.c,v 1.26 2021/02/13 19:43:10 tom Exp $")
+MODULE_ID("$Id: m_new.c,v 1.27 2021/06/17 21:26:02 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  MENU* _nc_new_menu(SCREEN*, ITEM **items)
-|   
+|
 |   Description   :  Creates a new menu connected to the item pointer
 |                    array items and returns a pointer to the new menu.
 |                    The new menu is initialized with the values from the
@@ -92,9 +92,9 @@ NCURSES_SP_NAME(new_menu) (NCURSES_SP_DCLx ITEM **items)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  MENU *new_menu(ITEM **items)
-|   
+|
 |   Description   :  Creates a new menu connected to the item pointer
 |                    array items and returns a pointer to the new menu.
 |                    The new menu is initialized with the values from the
@@ -111,10 +111,10 @@ new_menu(ITEM **items)
 #endif
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
-|   Function      :  int free_menu(MENU *menu)  
-|   
-|   Description   :  Disconnects menu from its associated item pointer 
+|   Facility      :  libnmenu
+|   Function      :  int free_menu(MENU *menu)
+|
+|   Description   :  Disconnects menu from its associated item pointer
 |                    array and frees the storage allocated for the menu.
 |
 |   Return Values :  E_OK               - success
diff --git a/contrib/ncurses/menu/m_pad.c b/contrib/ncurses/menu/m_pad.c
index 88dad151d6ff..008e19a79cdd 100644
--- a/contrib/ncurses/menu/m_pad.c
+++ b/contrib/ncurses/menu/m_pad.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2010,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -38,7 +38,7 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_pad.c,v 1.16 2020/12/12 00:38:14 tom Exp $")
+MODULE_ID("$Id: m_pad.c,v 1.17 2021/06/17 21:20:30 tom Exp $")
 
 /* Macro to redraw menu if it is posted and changed */
 #define Refresh_Menu(menu) \
@@ -49,11 +49,11 @@ MODULE_ID("$Id: m_pad.c,v 1.16 2020/12/12 00:38:14 tom Exp $")
    }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  int set_menu_pad(MENU* menu, int pad)
-|   
+|
 |   Description   :  Set the character to be used to separate the item name
-|                    from its description. This must be a printable 
+|                    from its description. This must be a printable
 |                    character.
 |
 |   Return Values :  E_OK              - success
@@ -79,9 +79,9 @@ set_menu_pad(MENU *menu, int pad)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  int menu_pad(const MENU *menu)
-|   
+|
 |   Description   :  Return the value of the padding character
 |
 |   Return Values :  The pad character
diff --git a/contrib/ncurses/menu/m_pattern.c b/contrib/ncurses/menu/m_pattern.c
index 58047df218d4..6fbef236f2e6 100644
--- a/contrib/ncurses/menu/m_pattern.c
+++ b/contrib/ncurses/menu/m_pattern.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2006,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -38,12 +38,12 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_pattern.c,v 1.19 2020/12/12 00:38:14 tom Exp $")
+MODULE_ID("$Id: m_pattern.c,v 1.20 2021/06/17 21:20:30 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  char *menu_pattern(const MENU *menu)
-|   
+|
 |   Description   :  Return the value of the pattern buffer.
 |
 |   Return Values :  NULL          - if there is no pattern buffer allocated
@@ -61,9 +61,9 @@ menu_pattern(const MENU *menu)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  int set_menu_pattern(MENU *menu, const char *p)
-|   
+|
 |   Description   :  Set the match pattern for a menu and position to the
 |                    first item that matches.
 |
diff --git a/contrib/ncurses/menu/m_post.c b/contrib/ncurses/menu/m_post.c
index bfc633164b49..cb80230433d5 100644
--- a/contrib/ncurses/menu/m_post.c
+++ b/contrib/ncurses/menu/m_post.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020-2021,2022 Thomas E. Dickey                                *
  * Copyright 1998-2010,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -38,7 +38,7 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_post.c,v 1.34 2020/12/12 00:38:14 tom Exp $")
+MODULE_ID("$Id: m_post.c,v 1.38 2022/09/24 09:38:44 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu
@@ -58,7 +58,6 @@ _nc_Post_Item(const MENU *menu, const ITEM *item)
   int count = 0;
   bool isfore = FALSE, isback = FALSE, isgrey = FALSE;
   int name_len;
-  int desc_len;
 
   assert(menu->win);
 
@@ -132,6 +131,7 @@ _nc_Post_Item(const MENU *menu, const ITEM *item)
     {
       int m = menu->spc_desc / 2;
       int cy = -1, cx = -1;
+      int desc_len;
 
       for (ch = ' ', i = 0; i < menu->spc_desc; i++)
 	{
@@ -201,9 +201,8 @@ MENU_EXPORT(void)
 _nc_Draw_Menu(const MENU *menu)
 {
   ITEM *item = menu->items[0];
-  ITEM *lasthor, *lastvert;
+  ITEM *lastvert;
   ITEM *hitem;
-  int y = 0;
   chtype s_bkgd;
 
   assert(item && menu->win);
@@ -215,43 +214,50 @@ _nc_Draw_Menu(const MENU *menu)
 
   lastvert = (menu->opt & O_NONCYCLIC) ? (ITEM *)0 : item;
 
-  do
+  if (item != NULL)
     {
-      wmove(menu->win, y, 0);
-
-      hitem = item;
-      lasthor = (menu->opt & O_NONCYCLIC) ? (ITEM *)0 : hitem;
+      int y = 0;
 
       do
 	{
-	  _nc_Post_Item(menu, hitem);
+	  ITEM *lasthor;
 
-	  wattron(menu->win, (int)menu->back);
-	  if (((hitem = hitem->right) != lasthor) && hitem)
+	  wmove(menu->win, y, 0);
+
+	  hitem = item;
+	  lasthor = (menu->opt & O_NONCYCLIC) ? (ITEM *)0 : hitem;
+
+	  do
 	    {
-	      int i, j, cy, cx;
-	      chtype ch = ' ';
+	      _nc_Post_Item(menu, hitem);
 
-	      getyx(menu->win, cy, cx);
-	      for (j = 0; j < menu->spc_rows; j++)
+	      wattron(menu->win, (int)menu->back);
+	      if (((hitem = hitem->right) != lasthor) && hitem)
 		{
-		  wmove(menu->win, cy + j, cx);
-		  for (i = 0; i < menu->spc_cols; i++)
+		  int i, j, cy, cx;
+		  chtype ch = ' ';
+
+		  getyx(menu->win, cy, cx);
+		  for (j = 0; j < menu->spc_rows; j++)
 		    {
-		      waddch(menu->win, ch);
+		      wmove(menu->win, cy + j, cx);
+		      for (i = 0; i < menu->spc_cols; i++)
+			{
+			  waddch(menu->win, ch);
+			}
 		    }
+		  wmove(menu->win, cy, cx + menu->spc_cols);
 		}
-	      wmove(menu->win, cy, cx + menu->spc_cols);
 	    }
-	}
-      while (hitem && (hitem != lasthor));
-      wattroff(menu->win, (int)menu->back);
+	  while (hitem && (hitem != lasthor));
+	  wattroff(menu->win, (int)menu->back);
 
-      item = item->down;
-      y += menu->spc_rows;
+	  item = item->down;
+	  y += menu->spc_rows;
 
+	}
+      while (item && (item != lastvert));
     }
-  while (item && (item != lastvert));
 }
 
 /*---------------------------------------------------------------------------
@@ -283,7 +289,6 @@ post_menu(MENU *menu)
 
   if (menu->items && *(menu->items))
     {
-      int y;
       int h = 1 + menu->spc_rows * (menu->rows - 1);
 
       WINDOW *win = Get_Menu_Window(menu);
@@ -291,7 +296,8 @@ post_menu(MENU *menu)
 
       if ((menu->win = newpad(h, menu->width)))
 	{
-	  y = (maxy >= h) ? h : maxy;
+	  int y = (maxy >= h) ? h : maxy;
+
 	  if (y >= menu->height)
 	    y = menu->height;
 	  if (!(menu->sub = subpad(menu->win, y, menu->width, 0, 0)))
diff --git a/contrib/ncurses/menu/m_req_name.c b/contrib/ncurses/menu/m_req_name.c
index 7d1e7bf5d106..c72116fa4aff 100644
--- a/contrib/ncurses/menu/m_req_name.c
+++ b/contrib/ncurses/menu/m_req_name.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2012,2015 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -38,7 +38,7 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_req_name.c,v 1.25 2020/05/24 01:40:20 anonymous.maarten Exp $")
+MODULE_ID("$Id: m_req_name.c,v 1.27 2021/06/17 21:11:08 tom Exp $")
 
 #define DATA(s) { s }
 
@@ -66,9 +66,9 @@ static const char request_names[MAX_MENU_COMMAND - MIN_MENU_COMMAND + 1][14] =
 #define A_SIZE (sizeof(request_names)/sizeof(request_names[0]))
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  const char * menu_request_name (int request);
-|   
+|
 |   Description   :  Get the external name of a menu request.
 |
 |   Return Values :  Pointer to name      - on success
@@ -88,9 +88,9 @@ menu_request_name(int request)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  int menu_request_by_name (const char *str);
-|   
+|
 |   Description   :  Search for a request with this name.
 |
 |   Return Values :  Request Id       - on success
@@ -103,12 +103,13 @@ menu_request_by_name(const char *str)
      to run sequentially through it.
    */
   size_t i = 0;
-  char buf[16];
 
   T((T_CALLED("menu_request_by_name(%s)"), _nc_visbuf(str)));
 
   if (str != 0 && (i = strlen(str)) != 0)
     {
+      char buf[16];
+
       if (i > sizeof(buf) - 2)
 	i = sizeof(buf) - 2;
       memcpy(buf, str, i);
diff --git a/contrib/ncurses/menu/m_scale.c b/contrib/ncurses/menu/m_scale.c
index 0067ae76a1c9..9e7f81d515ee 100644
--- a/contrib/ncurses/menu/m_scale.c
+++ b/contrib/ncurses/menu/m_scale.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2004,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -38,14 +38,14 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_scale.c,v 1.13 2020/12/12 00:38:14 tom Exp $")
+MODULE_ID("$Id: m_scale.c,v 1.14 2021/06/17 21:20:30 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  int scale_menu(const MENU *menu)
-|   
+|
 |   Description   :  Returns the minimum window size necessary for the
-|                    subwindow of menu.  
+|                    subwindow of menu.
 |
 |   Return Values :  E_OK                  - success
 |                    E_BAD_ARGUMENT        - invalid menu pointer
diff --git a/contrib/ncurses/menu/m_sub.c b/contrib/ncurses/menu/m_sub.c
index 5f898b0f7766..a055245bf49c 100644
--- a/contrib/ncurses/menu/m_sub.c
+++ b/contrib/ncurses/menu/m_sub.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2009,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -38,12 +38,12 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_sub.c,v 1.15 2020/12/12 00:38:14 tom Exp $")
+MODULE_ID("$Id: m_sub.c,v 1.16 2021/06/17 21:20:30 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  int set_menu_sub(MENU *menu, WINDOW *win)
-|   
+|
 |   Description   :  Sets the subwindow of the menu.
 |
 |   Return Values :  E_OK           - success
@@ -82,9 +82,9 @@ set_menu_sub(MENU *menu, WINDOW *win)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  WINDOW* menu_sub(const MENU *menu)
-|   
+|
 |   Description   :  Returns a pointer to the subwindow of the menu
 |
 |   Return Values :  NULL on error, otherwise a pointer to the window
diff --git a/contrib/ncurses/menu/m_win.c b/contrib/ncurses/menu/m_win.c
index 72f72ad0cc90..4bb64e6a6daa 100644
--- a/contrib/ncurses/menu/m_win.c
+++ b/contrib/ncurses/menu/m_win.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2009,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -38,12 +38,12 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_win.c,v 1.20 2020/12/12 00:38:14 tom Exp $")
+MODULE_ID("$Id: m_win.c,v 1.21 2021/06/17 21:20:30 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  int set_menu_win(MENU *menu, WINDOW *win)
-|   
+|
 |   Description   :  Sets the window of the menu.
 |
 |   Return Values :  E_OK               - success
@@ -82,9 +82,9 @@ set_menu_win(MENU *menu, WINDOW *win)
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  WINDOW* menu_win(const MENU*)
-|   
+|
 |   Description   :  Returns pointer to the window of the menu
 |
 |   Return Values :  NULL on error, otherwise pointer to window
diff --git a/contrib/ncurses/misc/Makefile.in b/contrib/ncurses/misc/Makefile.in
index 3999a4e9bd1b..1539973fef07 100644
--- a/contrib/ncurses/misc/Makefile.in
+++ b/contrib/ncurses/misc/Makefile.in
@@ -1,4 +1,4 @@
-# $Id: Makefile.in,v 1.74 2021/01/23 20:42:08 tom Exp $
+# $Id: Makefile.in,v 1.79 2021/11/06 23:36:12 tom Exp $
 ##############################################################################
 # Copyright 2018-2020,2021 Thomas E. Dickey                                  #
 # Copyright 1998-2016,2017 Free Software Foundation, Inc.                    #
@@ -76,13 +76,29 @@ INSTALL_DATA	= @INSTALL_DATA@
 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
 
 ################################################################################
+
+@MAKE_PHONY@.PHONY :	all
+@MAKE_PHONY@.PHONY :	check
+@MAKE_PHONY@.PHONY :	clean
+@MAKE_PHONY@.PHONY :	depend
+@MAKE_PHONY@.PHONY :	distclean
+@MAKE_PHONY@.PHONY :	install
+@MAKE_PHONY@.PHONY :	install.data
+@MAKE_PHONY@.PHONY :	install.libs
+@MAKE_PHONY@.PHONY :	libs
+@MAKE_PHONY@.PHONY :	mostlyclean
+@MAKE_PHONY@.PHONY :	realclean
+@MAKE_PHONY@.PHONY :	sources
+@MAKE_PHONY@.PHONY :	uninstall
+@MAKE_PHONY@.PHONY :	uninstall.data
+@MAKE_PHONY@.PHONY :	uninstall.libs
+
 all \
+depend \
 sources ::
 
 @MAKE_DATABASE@all \
-@MAKE_DATABASE@sources :: terminfo.tmp 
-
-depend :
+@MAKE_DATABASE@sources :: terminfo.tmp
 
 @MAKE_DATABASE@install :: @MISC_INSTALL_DATA@
 
@@ -131,8 +147,8 @@ install.libs :: $(DESTDIR)$(bindir) ncurses-config
 # directory during this rule:
 @MAKE_PC_FILES@install \
 @MAKE_PC_FILES@install.libs :: pc-files
-@MAKE_PC_FILES@	@$(SHELL) -c 'case "x$(DESTDIR)$(PKG_CONFIG_LIBDIR)" in \
-@MAKE_PC_FILES@		(x/*) \
+@MAKE_PC_FILES@	@$(SHELL) -c 'case "x$(PKG_CONFIG_LIBDIR)" in \
+@MAKE_PC_FILES@		x/*) \
 @MAKE_PC_FILES@			mkdir -p $(DESTDIR)$(PKG_CONFIG_LIBDIR); \
 @MAKE_PC_FILES@			for name in $(PC_FILES); do \
 @MAKE_PC_FILES@				test -f $$name || continue; \
@@ -140,7 +156,7 @@ install.libs :: $(DESTDIR)$(bindir) ncurses-config
 @MAKE_PC_FILES@				$(INSTALL_DATA) $$name $(DESTDIR)$(PKG_CONFIG_LIBDIR)/$$name; \
 @MAKE_PC_FILES@			done \
 @MAKE_PC_FILES@			;; \
-@MAKE_PC_FILES@		(*) \
+@MAKE_PC_FILES@		*) \
 @MAKE_PC_FILES@			echo "...skip actual install: no destination was given" ; \
 @MAKE_PC_FILES@			;; \
 @MAKE_PC_FILES@		esac'
@@ -177,7 +193,7 @@ uninstall.data :
 uninstall.libs :
 	-rm -f $(DESTDIR)$(bindir)/$(NCURSES_CONFIG)
 @MAKE_PC_FILES@	@$(SHELL) -c 'case x$(DESTDIR)$(PKG_CONFIG_LIBDIR) in \
-@MAKE_PC_FILES@	(x/*) \
+@MAKE_PC_FILES@	x/*) \
 @MAKE_PC_FILES@		for name in $(PC_FILES); do \
 @MAKE_PC_FILES@			test -f $$name || continue; \
 @MAKE_PC_FILES@			echo uninstalling $$name; \
diff --git a/contrib/ncurses/misc/csort b/contrib/ncurses/misc/csort
index 24554196a04d..c39c2951e745 100755
--- a/contrib/ncurses/misc/csort
+++ b/contrib/ncurses/misc/csort
@@ -1,7 +1,7 @@
 #!/bin/sh
-# $Id: csort,v 1.3 2020/02/02 23:34:34 tom Exp $
+# $Id: csort,v 1.4 2021/09/04 15:55:29 tom Exp $
 ##############################################################################
-# Copyright 2020 Thomas E. Dickey                                            #
+# Copyright 2020,2021 Thomas E. Dickey                                       #
 # Copyright 2002 Free Software Foundation, Inc.                              #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -34,4 +34,4 @@ LANG=C;		export LANG
 LANGUAGE=C;	export LANGUAGE
 LC_ALL=C;	export LC_ALL
 LC_CTYPE=C;	export LC_CTYPE
-sort $*
+sort "$@"
diff --git a/contrib/ncurses/misc/gen-pkgconfig.in b/contrib/ncurses/misc/gen-pkgconfig.in
index 5a71ab0203c6..89a5cd4a3180 100644
--- a/contrib/ncurses/misc/gen-pkgconfig.in
+++ b/contrib/ncurses/misc/gen-pkgconfig.in
@@ -1,7 +1,7 @@
 #!@SHELL@
-# $Id: gen-pkgconfig.in,v 1.49 2021/01/24 00:35:28 tom Exp $
+# $Id: gen-pkgconfig.in,v 1.56 2022/10/08 16:45:20 tom Exp $
 ##############################################################################
-# Copyright 2018-2020,2021 Thomas E. Dickey                                  #
+# Copyright 2018-2021,2022 Thomas E. Dickey                                  #
 # Copyright 2009-2015,2018 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -83,7 +83,7 @@ if [ "$includedir" != "/usr/include" ]; then
 fi
 
 lib_flags=
-for opt in -L$libdir @LDFLAGS@ @EXTRA_PKG_LDFLAGS@ @LIBS@
+for opt in -L$libdir @EXTRA_PKG_LDFLAGS@ @LIBS@
 do
 	case $opt in
 	-l*) # LIBS is handled specially below
@@ -95,9 +95,19 @@ do
 	-Wl,-z,*) # ignore flags used to manipulate shared image
 		continue
 		;;
+	-Wl,--dynamic-linker*) # ignore ELF interpreter
+		continue
+		;;
+	-Wl,--as-needed|-Wl,--build-id=*|-Wl,-dT,*|-Wl,-T,*)
+		continue
+		;;
 	-L*)
-		lib_check=${opt##-L} 
-		[ -d "$lib_check" ] || continue
+		lib_check=`echo "x$opt" | sed -e 's/^.-L//'`
+		# on a new/nonstandard install, $libdir may not yet exist at this point
+		if [ "$libdir" != "$lib_check" ]
+		then
+			[ -d "$lib_check" ] || continue
+		fi
 		case "$lib_check" in
 		@LD_SEARCHPATH@) # skip standard libdir
 			if [ "$lib_check" = "$libdir" ]
@@ -164,7 +174,7 @@ fi
 
 # The "URL" feature came in pkg-config 0.17
 USEURL=""
-CFGVER=`pkg-config --version 2>/dev/null |head -n 1 | awk -F. '/0.[0-9][0-9]/{print $2;}'`
+CFGVER=`${PKG_CONFIG:-pkg-config} --version 2>/dev/null |head -n 1 | awk -F. '/0.[0-9][0-9]/{print $2;}'`
 # A missing version should simply fail, but some packagers insist on building
 # packages on machines which do not actually have the tools they depend on at
 # runtime.
@@ -216,7 +226,7 @@ do
 
 	echo "** creating ${name}${suffix}.pc"
 	cat >${name}${suffix}.pc <<EOF
-# pkg-config file generated by `basename $0`
+# pkg-config file generated by `basename "$0"`
 # vile:makemode
 
 prefix=$show_prefix
diff --git a/contrib/ncurses/misc/gen_edit.sh b/contrib/ncurses/misc/gen_edit.sh
index dadf00357114..0c41611d7c57 100755
--- a/contrib/ncurses/misc/gen_edit.sh
+++ b/contrib/ncurses/misc/gen_edit.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 ##############################################################################
-# Copyright 2020 Thomas E. Dickey                                            #
+# Copyright 2020,2021 Thomas E. Dickey                                       #
 # Copyright 2004-2011,2012 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -30,7 +30,7 @@
 #
 # Author: Thomas E. Dickey
 #
-# $Id: gen_edit.sh,v 1.6 2020/02/02 23:34:34 tom Exp $
+# $Id: gen_edit.sh,v 1.7 2021/09/04 15:55:29 tom Exp $
 # Generate a sed-script for converting the terminfo.src to the form which will
 # be installed.
 #
@@ -40,10 +40,10 @@
 
 linux_dft=linux2.2
 
-: ${datadir=/usr/share}
-: ${WHICH_LINUX=$linux_dft}
-: ${WHICH_XTERM=xterm-new}
-: ${XTERM_KBS=BS}
+: "${datadir=/usr/share}"
+: "${WHICH_LINUX=$linux_dft}"
+: "${WHICH_XTERM=xterm-new}"
+: "${XTERM_KBS=BS}"
 
 # If we're not installing into /usr/share/, we'll have to adjust the location
 # of the tabset files in terminfo.src (which are in a parallel directory).
diff --git a/contrib/ncurses/misc/magic b/contrib/ncurses/misc/magic
index 0fab0049a4f0..ee1a1c4d456c 100644
--- a/contrib/ncurses/misc/magic
+++ b/contrib/ncurses/misc/magic
@@ -1,6 +1,6 @@
-# $Id: magic,v 1.3 2020/02/02 23:34:34 tom Exp $
+# $Id: magic,v 1.5 2023/09/23 23:37:26 tom Exp $
 ##############################################################################
-# Copyright 2020 Thomas E. Dickey                                            #
+# Copyright 2020,2023 Thomas E. Dickey                                       #
 # Copyright 2015,2018 Free Software Foundation, Inc.                         #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -60,7 +60,7 @@
 !:mime	application/x-terminfo2
 #
 # While the compiled terminfo uses little-endian format irregardless of
-# platform, SystemV screen dumps do not.  They came later, and that detail was
+# platform, System V screen dumps do not.  They came later, and that detail was
 # overlooked.
 #
 # AIX and HPUX use the SVr4 big-endian format
diff --git a/contrib/ncurses/misc/makedef.cmd b/contrib/ncurses/misc/makedef.cmd
index 12baeca86861..129ca83b5e48 100644
--- a/contrib/ncurses/misc/makedef.cmd
+++ b/contrib/ncurses/misc/makedef.cmd
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998,2006 Free Software Foundation, Inc.                       *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -28,7 +28,7 @@
  ****************************************************************************/
 
 /*
- * $Id: makedef.cmd,v 1.6 2020/02/02 23:34:34 tom Exp $
+ * $Id: makedef.cmd,v 1.7 2021/09/04 10:52:55 tom Exp $
  *
  * Author:  Juan Jose Garcia Ripoll <worm@arrakis.es>.
  * Webpage: http://www.arrakis.es/~worm/
@@ -119,12 +119,12 @@ do while queued() > 0
     *		it has a valid code that we store
     *		we mark that code as used
     *   ELIF (it has no number) THEN
-    *		(it's a new symbol)
+    *		(it is a new symbol)
     *		we increase the counter of defined symbols
     *		we assign it the special number 0
     *		(later on it'll be assigned an unused export code)
     *   ELSE
-    *		this symbol was in the old DLL and it's no longer
+    *		this symbol was in the old DLL and it is no longer
     *		here, so we skip it.
     */
    select
diff --git a/contrib/ncurses/misc/makellib b/contrib/ncurses/misc/makellib
index 06e50f253d9f..fb3d3b7a92fd 100755
--- a/contrib/ncurses/misc/makellib
+++ b/contrib/ncurses/misc/makellib
@@ -1,6 +1,6 @@
 #!/bin/sh
 ##############################################################################
-# Copyright 2020 Thomas E. Dickey                                            #
+# Copyright 2020,2021 Thomas E. Dickey                                       #
 # Copyright 1998,2000 Free Software Foundation, Inc.                         #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -30,7 +30,7 @@
 #
 # Author: Thomas E. Dickey 1996,1997,2000
 #
-# $Id: makellib,v 1.9 2020/02/02 23:34:34 tom Exp $
+# $Id: makellib,v 1.11 2021/09/04 15:49:38 tom Exp $
 # System-dependent wrapper for 'lint' that creates a lint-library via the
 # following method (XXX is the name of the library):
 #	a.  If the file llib-lXXX doesn't exist, create it using the make-rule
@@ -45,7 +45,7 @@
 #	a.  On a few systems, you'll have to manually-edit the llib-lXXX file
 #	    to get a usable lint-library (not all C-preprocessors work well).
 #	b.  The system's lint utility won't recognize -lXXX as a lint-library
-#	    (Use tdlint as a wrapper; it's designed for this).
+#	    (Use tdlint as a wrapper; it is designed for this).
 #
 # Parameters:
 #	$1 = library name
@@ -68,7 +68,7 @@ while test $# != 0
 do
 	case $1 in
 	-L*)
-		DST="$DST `echo $1|sed -e 's/^-L//'`"
+		DST="$DST `echo "$1"|sed -e 's/^-L//'`"
 		;;
 	-*)
 		OPT="$OPT $1"
@@ -94,8 +94,8 @@ then
 	llib="llib-l$LLIB"
 fi
 
-if test ! -f $llib ; then
-	if ( make $llib )
+if test ! -f "$llib" ; then
+	if ( make "$llib" )
 	then
 		:
 	else
@@ -103,39 +103,39 @@ if test ! -f $llib ; then
 	fi
 fi
 
-rm -f $llib.ln $llib.c
+rm -f "$llib.ln" "$llib.c"
 TARGET=$LLIB
 
 case "$ARCH" in
 AIX)
 	CREATE="-uvxo$LLIB -Nn4000"
 	TARGET=$llib.c
-	ln $llib $TARGET
+	ln "$llib" "$TARGET"
 	;;
 Solaris)
 	CREATE="-C$llib"
 	TARGET=$llib.c
-	ln $llib $TARGET
+	ln "$llib" "$TARGET"
 	;;
 FreeBSD)
 	CREATE="-g -z -C$LLIB"
 	TARGET=$llib.c
-	ln $llib $TARGET
+	ln "$llib" "$TARGET"
 	;;
 CLIX)
 	CREATE="-DLINTLIBRARY -vxo$LLIB"
 	TARGET=$llib.c
-	ln $llib $TARGET
+	ln "$llib" "$TARGET"
 	;;
 IRIX*)
 	CREATE="-DLINTLIBRARY -vxyo$LLIB"
 	TARGET=$llib.c
-	ln $llib $TARGET
+	ln "$llib" "$TARGET"
 	;;
 UNIX_SV)
 	CREATE="-DLINTLIBRARY -vxyo$LLIB"
 	TARGET=$llib.c
-	ln $llib $TARGET
+	ln "$llib" "$TARGET"
 	;;
 *)
 	echo "Sorry.  I do not know how to build a lint-library for $ARCH"
@@ -145,24 +145,24 @@ esac
 echo OPT    "$OPT"
 echo TARGET "$TARGET"
 echo LIBNAME "$llib"
-if ( lint $CREATE $OPT $TARGET )
+if ( lint "$CREATE" "$OPT" "$TARGET" )
 then
-	if test -f $llib.ln
+	if test -f "$llib.ln"
 	then
 		for p in $HOME/lib $HOME/lib/$ARCH $HOME/lib/$ARCH/lint
 		do
-			if test ! -d $p
+			if test ! -d "$p"
 			then
-				mkdir $p
+				mkdir "$p"
 			fi
 		done
 		for p in $DST
 		do
-			cp $llib.ln $p/
+			cp "$llib.ln" "$p/"
 		done
-		rm -f $llib.ln
+		rm -f "$llib.ln"
 	fi
 fi
 if test "x$TARGET" = "x$llib.c" ; then
-	rm -f $TARGET
+	rm -f "$TARGET"
 fi
diff --git a/contrib/ncurses/misc/ncu2openbsd b/contrib/ncurses/misc/ncu2openbsd
new file mode 100755
index 000000000000..0c3365d76fdb
--- /dev/null
+++ b/contrib/ncurses/misc/ncu2openbsd
@@ -0,0 +1,1288 @@
+#!/usr/bin/env perl
+# $Id: ncu2openbsd,v 1.67 2023/09/09 15:59:17 tom Exp $
+# -----------------------------------------------------------------------------
+# Copyright 2021,2023 by Thomas E. Dickey
+#
+#                         All Rights Reserved
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+# -----------------------------------------------------------------------------
+# https://invisible-island.net/ncurses/ncurses-openbsd.html
+#
+# Update the OpenBSD source-tree given an ncurses tarball or build-tree.
+
+use strict;
+use warnings;
+
+use Getopt::Std;
+use Cwd;
+use Cwd 'abs_path';
+use File::Path qw/ remove_tree /;
+use File::Temp qw/ tempdir /;
+
+$| = 1;
+
+our ( $opt_d, $opt_n, $opt_r, $opt_t, $opt_v, $opt_x, $opt_6 );
+our $source_dir;
+our $target_dir;
+our $update_dir;
+our $backup_dir;
+
+our $tempdir = tempdir( CLEANUP => 1 );
+my $current = getcwd;
+my $working = $current;
+
+our $generated_by = "generated by: ncu2openbsd";
+
+our %setup_dir = qw(
+  lib/libcurses         ncurses
+  lib/libform           form
+  lib/libmenu           menu
+  lib/libpanel          panel
+  usr.bin/infocmp       progs
+  usr.bin/tabs          progs
+  usr.bin/tic           progs
+  usr.bin/toe           progs
+  usr.bin/tput          progs
+  usr.bin/tset          progs
+  share/termtypes       misc
+);
+
+our %generated = qw(
+  codes.c 1
+  comp_captab.c         1
+  comp_userdefs.c       1
+  expanded.c            1
+  fallback.c            1
+  init_keytry.h         1
+  keys.list             1
+  lib_gen.c             1
+  lib_keyname.c         1
+  make_hash             1
+  make_keys             1
+  names.c               1
+  termsort.c            1
+  unctrl.c              1
+);
+
+our %definitions = qw(
+  CAPTOINFO             captoinfo
+  DATADIR               /usr/share
+  INFOCMP               infocmp
+  INFOTOCAP             infotocap
+  NCURSES_MAJOR         5
+  NCURSES_MINOR         7
+  NCURSES_OSPEED        int
+  NCURSES_PATCH         20081102
+  TERMINFO              /usr/share/terminfo
+  TIC                   tic
+  TOE                   toe
+  TPUT                  tput
+  TSET                  tset
+);
+
+sub patchdate() {
+    return $definitions{"NCURSES_PATCH"};
+}
+
+sub failed($) {
+    chdir $current;
+    printf STDERR "? %s\n", $_[0];
+    exit;
+}
+
+sub verbose($) {
+    my $text = shift;
+    printf "%s\n", $text if ($opt_v);
+}
+
+sub read_file($) {
+    my $name = shift;
+    open( my $fp, $name ) || &failed("cannot open $name");
+    my (@input) = <$fp>;
+    chomp @input;
+    close($fp);
+    return @input;
+}
+
+sub read_dir($) {
+    my $path = shift;
+    my @result;
+    if ( opendir( my $dh, $path ) ) {
+        my @data = sort readdir($dh);
+        closedir $dh;
+        for my $d ( 0 .. $#data ) {
+            next if ( $data[$d] =~ /^\.(\.)?$/ );
+            next if ( -l $path . "/" . $data[$d] );
+            $result[ $#result + 1 ] = $data[$d];
+        }
+    }
+    return @result;
+}
+
+sub rename_dir($$) {
+    my $src = shift;
+    my $dst = shift;
+    printf "%% mv %s -> %s\n", $src, $dst if ($opt_v);
+    rename $src, $dst unless ($opt_n);
+}
+
+sub check_sourcedir($) {
+    my $path = shift;
+    &failed("not a directory: $path") unless ( -d $path );
+    my $full = abs_path($path);
+    chdir $full;
+    &failed("not an ncurses source-tree: $path")
+      unless ( -f "NEWS" and -f "dist.mk" );
+    $source_dir = $full;
+}
+
+sub unpack($) {
+    my $path    = shift;
+    my $full    = abs_path($path);
+    my $command = "";
+    if ( $path =~ /\.tgz$/ or $path =~ /\.tar\.gz$/ ) {
+        $command = "tar xzf %s";
+    }
+    elsif ( $path =~ /\.zip$/ ) {
+        $command = "unzip -q %s";
+    }
+    else {
+        &failed("not a gzip'd tarball or zip-file: $path");
+    }
+    chdir $tempdir;
+    system( sprintf( $command, $full ) );
+
+    # there should be exactly one subdirectory -- the source-tree
+    my @data = &read_dir(".");
+    &failed("found no subdirectories of $path") if ( $#data < 0 );
+    &failed( "too many subdirectories: " . $data[0] . " vs " . $data[1] )
+      if ( $#data > 0 );
+    &check_sourcedir( $data[0] );
+}
+
+sub remove_dir($) {
+    my $tree = shift;
+    if ( -d $tree ) {
+        printf "%% rm -rf %s\n", $tree if ($opt_v);
+        remove_tree( $tree, $opt_v ? 1 : 0, 1 ) unless ($opt_n);
+    }
+}
+
+sub copy_CVS($) {
+    my $leaf    = shift;
+    my $src     = $target_dir . $leaf . "/CVS";
+    my $dst     = $update_dir . $leaf . "/CVS";
+    my $verbose = $opt_v ? "v" : "";
+    if ( -d $src and !-d $dst ) {
+        my $mid = $update_dir . $leaf;
+        mkdir $mid unless ( -d $mid );
+        mkdir $dst unless ( -d $dst );
+        system("cp -a$verbose $src/* $dst/");
+    }
+}
+
+sub is_tic_code($) {
+    my $item   = shift;
+    my $result = 0;
+    $result = 1
+      if (
+        $item =~ /^(capconvert
+                   |tic
+                   |dump
+                   |progs
+                   |termsort
+                   |transform
+                   |MKtermsort)/x
+      );
+    return $result;
+}
+
+sub is_ident($$) {
+    my $name = shift;
+    my $text = shift;
+    my $code = 0;
+    $code = 1 if ( $text =~ /\$$name:.*\$/ );
+    return $code;
+}
+
+# We "could", filter out differences with ident's using the diff -I option,
+# but in practice, that is cumbersome.
+sub munge_ident($) {
+    my $target = shift;
+    my $source = $target;
+    $source =~ s/\.update\b//;
+    &failed("bug at $source") if ( $source eq $target );
+    return unless ( -f $source );
+    my @source = &read_file($source);
+    my @target = &read_file($target);
+    my $old_id = "";
+    my $gap_id = 0;
+    my $new_id = "";
+    my $skipit = -1;
+
+    for my $n ( 0 .. $#source ) {
+        if ( &is_ident( "OpenBSD", $source[$n] ) ) {
+            $old_id = $source[$n];
+            $skipit = $n + 1;
+        }
+        elsif ( &is_ident( "Id", $source[$n] ) ) {
+            $new_id = $source[$n];
+            last;
+        }
+        elsif ( $n == $skipit ) {
+            $source[$n] =~ s/\s+$//;
+            if ( $source[$n] eq "" ) {
+                $gap_id = $source[$n];
+            }
+            elsif ( $source[$n] eq '.\"' ) {
+                $gap_id = $source[$n];
+            }
+        }
+    }
+    if ( $old_id ne "" ) {
+        my @update;
+        my $tables = &uses_tables($target);
+        $update[ $#update + 1 ] = $target[0] if ($tables);
+        $update[ $#update + 1 ] = $old_id;
+        $update[ $#update + 1 ] = $gap_id unless ( $gap_id eq 0 );
+        for my $n ( $tables .. $#target ) {
+            if ( &is_ident( "Id", $target[$n] ) ) {
+                $update[ $#update + 1 ] = $new_id;
+            }
+            else {
+                $update[ $#update + 1 ] = $target[$n];
+            }
+        }
+        system("chmod u+w $target");
+        if ( open my $fp, ">", $target ) {
+            for my $n ( 0 .. $#update ) {
+                printf $fp "%s\n", $update[$n];
+            }
+            close $fp;
+            system("chmod u-w $target");
+        }
+    }
+}
+
+# ncurses manual pages provide for renaming the utilities, normally as part of
+# the scripts provided in its sources.  OpenBSD developers do not use those.
+sub munge_docs($) {
+    my $path = shift;
+    my @data = &read_file($path);
+    my $done = 0;
+    for my $n ( 0 .. $#data ) {
+        my $text = $data[$n];
+        $text =~ s/\b1M\b/1/g;
+        $text =~ s/\b3X\b/3/g;
+        $text =~ s/\bcurs_(term(info|cap)\s*3\b)/$1/g;
+        $text =~ s/(\\fB)curs_(term(info|cap)\\f[RP]\(3\))/$1$2/g;
+        my $left = "";
+        while ( $text =~ /@[[:alnum:]_]+@/ ) {
+            my $next = index( $text, "@" );
+            last if ( $next < 0 );
+            $left .= substr( $text, 0, $next++ );
+            $text = substr( $text, $next );
+            $next = index( $text, "@" );
+            last if ( $next < 0 );
+            my $word = substr( $text, 0, $next );
+            if ( $word =~ /^[[:alnum:]_]+/ ) {
+
+                if ( $definitions{$word} ) {
+                    $word = $definitions{$word};
+                }
+                else {
+                    $word = "?";
+                }
+                $left .= $word;
+                $text = substr( $text, $next + 1 );
+            }
+            else {
+                &failed("unexpected definition @$word@");
+            }
+        }
+        $text = $left . $text;
+        if ( $text ne $data[$n] ) {
+            $done++;
+            $data[$n] = $text;
+        }
+    }
+    if ($done) {
+        system("chmod u+w $path");
+        if ( open my $fp, ">", $path ) {
+            for my $n ( 0 .. $#data ) {
+                printf $fp "%s\n", $data[$n];
+            }
+            close $fp;
+            system("chmod u-w $path");
+        }
+    }
+}
+
+sub copy_file($$) {
+    my $src     = shift;
+    my $dst     = shift;
+    my $verbose = $opt_v ? "v" : "";
+    if ( -d $dst ) {
+        my $leaf = $src;
+        $leaf =~ s,^.*/,,;
+        $dst .= "/" . $leaf;
+    }
+    system("chmod u+w $dst") if ( -f $dst );
+    system("cp -a$verbose $src $dst");
+    &munge_ident($dst);
+}
+
+sub copy_code($) {
+    my $src = shift;
+    my $dst = shift;
+    &copy_CVS( substr( $dst, length($update_dir) ) );
+    printf ".. copying files for $dst\n";
+    my @data = &read_dir($src);
+    printf ".. %d entries\n", $#data + 1;
+    my $verbose = $opt_v ? "v" : "";
+    for my $d ( 0 .. $#data ) {
+        my $item     = $data[$d];
+        my $src_item = $src . "/" . $item;
+        next if ( -d $src_item );
+        next if ( -l $src_item );
+        next if ( $item =~ /^\.(\.)?$/ );
+        next if ( $item =~ /\.(bak|in|log|status)$/ );
+        next if ( $item =~ /^llib-/ );
+        next if ( $item =~ /^modules/ );
+        next if ( $item =~ /^[fm]_trace\.c/ and not $opt_t );
+        next
+          if ( $item =~ /^Makefile/ and index( $update_dir, "/share/" ) < 0 );
+        next if ( $item =~ /^README/ );
+        next if ( $item eq "headers" );
+        next if ( $generated{$item} );
+        next if ( $item eq "link_test.c" );
+
+        if ( index( $dst, "/usr.bin/" ) >= 0 ) {
+            next if ( $item =~ /^(clear)/ );    # OpenBSD uses "tput clear"
+            my $prog = $dst;
+            $prog =~ s%^.*/%%;
+            $prog =~ s/(update|backup)//;
+            $prog .= "c";
+            if ( $dst =~ /infocmp/ ) {
+                next if ( $item ne $prog );
+            }
+            elsif ( $dst =~ /tabs/ ) {
+                next if ( $item ne $prog );
+            }
+            elsif ( $dst =~ /tic/ ) {
+                next if ( &is_tic_code($item) == 0 );
+            }
+            elsif ( $dst =~ /toe/ ) {
+                next if ( $item ne $prog );
+            }
+            elsif ( $dst =~ /tput/ ) {
+                next if ( $item ne $prog );
+            }
+            elsif ( $dst =~ /tset/ ) {
+                next if ( $item ne $prog );
+            }
+            else {
+                next;
+            }
+        }
+        system( sprintf( "cp -a$verbose %s %s/%s", $src_item, $dst, $item ) );
+        &munge_ident("$dst/$item");
+    }
+}
+
+# Checking if nroff supports tables is a long-obsolete issue, and is not really
+# necessary, except to match OpenBSD's source-tree.
+sub uses_tables($) {
+    my $docs = shift;
+    my @docs = &read_file($docs);
+    my $code = 0;
+    for my $n ( 0 .. $#docs ) {
+        if ( $docs[$n] =~ /^[.']\\"\s+t\b.*/ ) {
+            $code = 1;
+            last;
+        }
+        elsif ( $docs[$n] =~ /^\./ ) {
+            last;
+        }
+    }
+    return $code;
+}
+
+sub copy_1doc($$) {
+    my $docs = shift;
+    my $src  = "$source_dir/man/$docs";
+    my $dst  = "$update_dir/$docs";
+    $src .= "m" if ( -f "${src}m" );
+    $dst =~ s/x$//;
+    if ( $dst =~ /\.3/ ) {
+        $dst =~ s/\bncurses/curses/ if ( $dst =~ /ncurses\./ );
+        $dst =~ s/\bcurs_//         if ( $dst =~ /_term(cap|info)\./ );
+    }
+    &copy_file( $src, $dst );
+    &munge_docs($dst);
+}
+
+sub copy_docs($) {
+    my $docs = shift;
+    if ( index( $update_dir, "/usr.bin/" ) >= 0 ) {
+        &copy_1doc( $docs . ".1" );
+        if ( $docs eq "tic" ) {
+            &copy_1doc("captoinfo.1");
+            &copy_1doc("infotocap.1");
+        }
+    }
+    else {
+        my @docs = &read_dir("$source_dir/man");
+        if ( $docs eq "curses" ) {
+            for my $n ( 0 .. $#docs ) {
+                next if ( $docs[$n] eq "Makefile" );
+                next if ( $docs[$n] eq "make_sed.sh" );
+                next if ( $docs[$n] eq "man_db.renames" );
+                next if ( $docs[$n] eq "manlinks.sed" );
+                next if ( $docs[$n] =~ /\.(1|head|tail|in)/ );
+                next if ( $docs[$n] =~ /^(form|menu|mitem|panel)/ );
+                &copy_1doc( $docs[$n] );
+            }
+        }
+        elsif ( $docs eq "form" ) {
+            for my $n ( 0 .. $#docs ) {
+                next unless ( $docs[$n] =~ /^form/ );
+                &copy_1doc( $docs[$n] );
+            }
+        }
+        elsif ( $docs eq "menu" ) {
+            for my $n ( 0 .. $#docs ) {
+                next unless ( $docs[$n] =~ /^(menu|mitem)/ );
+                &copy_1doc( $docs[$n] );
+            }
+        }
+        elsif ( $docs eq "panel" ) {
+            for my $n ( 0 .. $#docs ) {
+                next unless ( $docs[$n] =~ /^panel/ );
+                &copy_1doc( $docs[$n] );
+            }
+        }
+    }
+}
+
+sub setup_dir($) {
+    my $dst = shift;
+    &failed("no definition for $dst")
+      unless ( defined $setup_dir{$dst} or $opt_r );
+    $target_dir = sprintf( "%s/%s", $opt_d, $dst );
+    $update_dir = $target_dir . ".update";
+    $backup_dir = $target_dir . ".backup";
+    my $result = 0;
+    if ($opt_r) {
+        &remove_dir($update_dir);
+        if ( $target_dir =~ /\/(tabs|toe)$/ ) {
+            &remove_dir($target_dir);
+        }
+        elsif ( -d $backup_dir ) {
+            &remove_dir($target_dir);
+            &rename_dir( $backup_dir, $target_dir );
+        }
+    }
+    else {
+        &remove_dir($update_dir);
+        mkdir $update_dir;
+
+        # reuse the shared-library version, assuming ABI=5 would involve at
+        # most a minor-version bump.
+        &copy_file( "$target_dir/shlib_version", $update_dir )
+          if ( $dst =~ /^lib\// );
+        &copy_code( $source_dir . "/" . $setup_dir{$dst}, $update_dir )
+          unless ( $setup_dir{$dst} eq "misc" );
+        $result = 1;
+    }
+    return $result;
+}
+
+sub do_build($) {
+    my $command = shift;
+    printf "%% %s\n", $command if ($opt_v);
+    system($command);
+}
+
+sub finish_dir() {
+    printf "** $target_dir\n";
+    system("diff -Naurb $target_dir $update_dir | diffstat -n 30")
+      if ( -d $target_dir );
+    if ($opt_n) {
+        &do_build("cd $update_dir && make -n") if ($opt_x);
+    }
+    else {
+        if ( -d $backup_dir ) {
+            printf STDERR "? backup directory exists: %s\n", $backup_dir;
+        }
+        else {
+            &rename_dir( $target_dir, $backup_dir );
+            &rename_dir( $update_dir, $target_dir );
+        }
+        &do_build("cd $target_dir && make") if ($opt_x);
+    }
+}
+
+################################################################################
+
+sub only_c_files($) {
+    my @data = @{ $_[0] };
+    my %data;
+    for my $n ( 0 .. $#data ) {
+        my $text = $data[$n];
+        $data{$text}++ if ( $text =~ /\.c$/ );
+    }
+    return sort keys %data;
+}
+
+sub makefile_list($$$) {
+    my @data = @{ $_[0] };
+    my $name = $_[1];
+    my $skip = $_[2];
+    my %data;
+    my $state = 0;
+    for my $n ( 0 .. $#data ) {
+        my $text = $data[$n];
+        $text =~ s/^\s+//;
+        next if ( index( $text, $skip ) == 0 );
+        $text =~ s/\s+=/=/;
+        $text =~ s/=\s+/=/;
+        $text =~ s/\s*\\//;
+        $state = 1 if ( $text =~ /^${name}=/ );
+        next unless ( $state == 1 );
+
+        if ( index( $text, "(trace)" ) >= 0 and not $opt_t ) {
+            next unless ( $text =~ /\b(lib_trace|visbuf)\.c$/ );
+        }
+        if ( not $opt_t ) {
+            next if ( $text =~ /\b[fm]_trace\.c$/ );
+        }
+        $text =~ s/^.*=//;
+        $text =~ s/\$o/.o/g;
+        $text =~ s/^.*\///;
+        next           if ( $text eq "link_test.c" );
+        next           if ( $text eq "mf_common.h" );
+        next           if ( $text eq "transform.h" );
+        $data{$text}++ if ( $text ne "" );
+        last           if ( $data[$n] !~ /\\$/ );
+    }
+    return sort keys %data;
+}
+
+sub manpage_list($) {
+    my $path = shift;
+    my @data = &read_dir($path);
+    my %data;
+    for my $n ( 0 .. $#data ) {
+        my $text = $data[$n];
+        $data{$text}++ if ( $text =~ /\.\d$/ );
+    }
+    return sort keys %data;
+}
+
+sub columns_of($) {
+    my $string = shift;
+    my $result = 0;
+    for my $n ( 0 .. length($string) - 1 ) {
+        my $c = substr( $string, $n, 1 );
+        if ( $c eq "\t" ) {
+            $result |= 7;
+            $result++;
+        }
+        elsif ( $c eq "\n" ) {
+            $result = 0;
+        }
+        else {
+            ++$result;
+        }
+    }
+    return $result;
+}
+
+sub format_list($$) {
+    my $name = $_[0];
+    my @data = @{ $_[1] };
+    my $keep = ( defined $_[2] ) ? 1 : 0;
+    my $base;
+    my $fill;
+    if ( length($name) >= 9 ) {
+        $fill = " ";
+        $base = length($name) + 1;
+    }
+    else {
+        $base = 9;
+        $fill = "\t";
+    }
+    my $result = sprintf( "%s%s", $name, $fill );
+    if ( $keep == 0 ) {
+        my %data;
+        for my $n ( 0 .. $#data ) {
+            $data{ $data[$n] } = 1 if ( defined $data[$n] );
+        }
+        @data = sort keys %data;
+    }
+    for my $n ( 0 .. $#data ) {
+        my $data = $data[$n];
+        my $col  = &columns_of($result);
+        my $add  = 1 + length($data);
+        if ( ( $col + $add ) > 76 ) {
+            $result .= " " if ( $col > $base );
+            $base = 9;
+            $fill = "\t";
+            $result .= "\\\n" . $fill . $data;
+        }
+        else {
+            $result .= " " if ( $col > $base );
+            $result .= $data;
+        }
+    }
+    return $result;
+}
+
+################################################################################
+
+sub compare_makefiles($) {
+    if ($opt_v) {
+        my $newfile = shift;
+        my $bakfile =
+          ( -d $backup_dir ? $backup_dir : $target_dir ) . "/Makefile";
+        system("diff -u $bakfile $newfile") if ( -f $bakfile );
+    }
+}
+
+# The curses makefile has to build build-time utilities and generate source.
+sub gen_1st_makefile() {
+    my $libname = "curses";
+    my $oldfile = "$source_dir/n$libname/Makefile";
+    my @oldfile = &read_file($oldfile);
+
+    my $newfile = "$update_dir/Makefile";
+    open( my $fp, ">", $newfile ) || &failed("cannot open $newfile");
+    my @subdirs = (
+        '${.CURDIR}/base', '${.CURDIR}/tinfo',
+        '${.CURDIR}/tty',  '${.CURDIR}/widechar'
+    );
+    $subdirs[ $#subdirs + 1 ] = '${.CURDIR}/trace' if ($opt_t);
+    printf $fp <<EOF;
+# $generated_by
+
+LIB=	$libname
+
+# Uncomment this to enable tracing in libcurses
+#CURSESTRACE=-DTRACE
+
+# This is used to compile terminal info directly into the library
+FALLBACK_LIST=
+
+# XXX - should be defined elsewhere
+AWK?=	/usr/bin/awk
+
+# Search in subdirs
+EOF
+    printf $fp "%s\n", &format_list( ".PATH:", \@subdirs );
+
+    my @autosrc = &makefile_list( \@oldfile, "AUTO_SRC", "?" );
+    my @auto_cc = &only_c_files( \@autosrc );
+    printf $fp "%s\n", &format_list( "SRCS=", \@auto_cc );
+
+    my @sources = &makefile_list( \@oldfile, "C_SRC", "./" );
+    printf $fp "%s\n", &format_list( "SRCS+=", \@sources );
+
+    printf $fp <<EOF;
+
+HOSTCFLAGS?=	\${CFLAGS}
+HOSTLDFLAGS?=	\${LDFLAGS}
+HOSTCFLAGS+=	-I. -I\${.CURDIR} \${CURSESTRACE}
+CFLAGS+=	-I. -I\${.CURDIR} \${CURSESTRACE} -D_XOPEN_SOURCE_EXTENDED -DNDEBUG
+
+EOF
+    my @manpages = &manpage_list($update_dir);
+    printf $fp "%s\n", &format_list( "MAN=", \@manpages );
+
+    $autosrc[ $#autosrc++ ] = "make_hash";
+    $autosrc[ $#autosrc++ ] = "make_keys";
+    printf $fp "%s\n", &format_list( "GENERATED=", \@autosrc );
+    printf $fp <<EOF;
+
+CAPLIST	= \${.CURDIR}/Caps
+USE_BIG_STRINGS	= 1
+
+CLEANFILES+= \${GENERATED}
+
+BUILDFIRST = \${GENERATED}
+
+includes:
+	\@cmp -s \${DESTDIR}/usr/include/ncurses.h \${.CURDIR}/curses.h || \\
+	  \${INSTALL} \${INSTALL_COPY} -m 444 -o \$(BINOWN) -g \$(BINGRP) \\
+	  \${.CURDIR}/curses.h \${DESTDIR}/usr/include/ncurses.h
+	\@cd \${.CURDIR}; for i in ncurses_dll.h unctrl.h term.h termcap.h; do \\
+	  cmp -s \$\$i \${DESTDIR}/usr/include/\$\$i || \\
+	  \${INSTALL} \${INSTALL_COPY} -m 444 -o \$(BINOWN) -g \$(BINGRP) \$\$i \\
+	  \${DESTDIR}/usr/include; done
+
+keys.list: \${.CURDIR}/tinfo/MKkeys_list.sh
+	sh \${.CURDIR}/tinfo/MKkeys_list.sh \${.CURDIR}/Caps | sort > \${.TARGET}
+
+fallback.c: \${.CURDIR}/tinfo/MKfallback.sh
+	sh \${.CURDIR}/tinfo/MKfallback.sh /usr/share/terminfo \${.CURDIR}/../../share/termtypes/termtypes.master \$(FALLBACK_LIST) > \${.TARGET}
+
+lib_gen.c: \${.CURDIR}/base/MKlib_gen.sh
+	sh \${.CURDIR}/base/MKlib_gen.sh "\${CC} -E -P -I\${.CURDIR}" \\
+		"\${AWK}" generated < \${.CURDIR}/curses.h > lib_gen.c
+
+init_keytry.h: make_keys keys.list
+	./make_keys keys.list > \${.TARGET}
+
+make_keys: \${.CURDIR}/tinfo/make_keys.c \${.CURDIR}/curses.priv.h names.c
+	\${HOSTCC} \${LDSTATIC} \${HOSTCFLAGS} \${HOSTLDFLAGS} \\
+		-o \${.TARGET} \${.CURDIR}/tinfo/make_keys.c \${LDADD}
+EOF
+
+    if ( &patchdate >= 20090808 ) {
+        printf $fp <<EOF;
+make_hash:	\${.CURDIR}/tinfo/make_hash.c \\
+		\${.CURDIR}/curses.priv.h \\
+		\${.CURDIR}/hashsize.h
+	\${HOSTCC} \${LDSTATIC} \${HOSTCFLAGS} -DMAIN_PROGRAM \${HOSTLDFLAGS} \\
+		-o \${.TARGET} \${.CURDIR}/tinfo/make_hash.c \${LDADD}
+EOF
+    }
+    else {
+        printf $fp <<EOF;
+make_hash: \${.CURDIR}/tinfo/comp_hash.c \\
+		\${.CURDIR}/curses.priv.h \\
+		\${.CURDIR}/hashsize.h
+	\${HOSTCC} \${LDSTATIC} \${HOSTCFLAGS} -DMAIN_PROGRAM \${HOSTLDFLAGS} \\
+		-o \${.TARGET} \${.CURDIR}/tinfo/comp_hash.c \${LDADD}
+EOF
+    }
+
+    if ( &patchdate >= 20190309 ) {
+        printf $fp <<EOF;
+CAPLIST += \${.CURDIR}/Caps-ncurses
+
+comp_userdefs.c: make_hash \\
+		\${.CURDIR}/hashsize.h \\
+		\${.CURDIR}/tinfo/MKuserdefs.sh
+	sh \${.CURDIR}/tinfo/MKuserdefs.sh \${AWK} \${USE_BIG_STRINGS} \${CAPLIST} > \${.TARGET}
+EOF
+    }
+    printf $fp <<EOF;
+
+expanded.c: \${.CURDIR}/term.h \${.CURDIR}/curses.priv.h \\
+		\${.CURDIR}/ncurses_cfg.h \${.CURDIR}/tty/MKexpanded.sh
+	sh \${.CURDIR}/tty/MKexpanded.sh "\${CC} -E -P" \${CPPFLAGS} > \${.TARGET}
+
+comp_captab.c: make_hash
+	sh \${.CURDIR}/tinfo/MKcaptab.sh \${AWK} \${USE_BIG_STRINGS} \\
+		\${.CURDIR}/tinfo/MKcaptab.awk \${CAPLIST} > \${.TARGET}
+
+lib_keyname.c: keys.list \${.CURDIR}/base/MKkeyname.awk
+	\${AWK} -f \${.CURDIR}/base/MKkeyname.awk \\
+		bigstrings=\${USE_BIG_STRINGS} \\
+		keys.list > \${.TARGET}
+
+names.c: \${.CURDIR}/tinfo/MKnames.awk
+	\${AWK} -f \${.CURDIR}/tinfo/MKnames.awk \\
+		bigstrings=\${USE_BIG_STRINGS} \\
+		\${CAPLIST} > \${.TARGET}
+codes.c: \${.CURDIR}/tinfo/MKcodes.awk
+	\${AWK} -f \${.CURDIR}/tinfo/MKcodes.awk \\
+		bigstrings=\${USE_BIG_STRINGS} \\
+		\${CAPLIST} > \${.TARGET}
+
+unctrl.c: \${.CURDIR}/base/MKunctrl.awk
+	echo | \${AWK} -f \${.CURDIR}/base/MKunctrl.awk bigstrings=1 > \${.TARGET}
+
+.include <bsd.own.mk>
+
+# Link libtermlib, libtermcap to libcurses so we don't break people's Makefiles
+afterinstall:
+	-cd \${DESTDIR}\${LIBDIR}; \\
+	for i in \${_LIBS}; do \\
+	    ln -f \$\$i `echo \$\$i | sed 's/curses/termlib/'`; \\
+	    ln -f \$\$i `echo \$\$i | sed 's/curses/termcap/'`; \\
+	    ln -f \$\$i `echo \$\$i | sed 's/curses/ncurses/'`; \\
+	    ln -f \$\$i `echo \$\$i | sed 's/curses/ncursesw/'`; \\
+	done
+
+.include <bsd.lib.mk>
+EOF
+    close $fp;
+    &compare_makefiles($newfile);
+}
+
+sub gen_lib_makefile($) {
+    my $libname = shift;
+    my $oldfile = "$source_dir/$libname/Makefile";
+    my @oldfile = &read_file($oldfile);
+
+    # in ncurses, header-files are quasi-generated, because the original
+    # header file for form/menu/panel lives in the source-directory, but is
+    # copied to the include-directory with "make sources".
+    my @headers = &makefile_list( \@oldfile, "AUTO_SRC", "?" );
+
+    # The C source is more straightforward.
+    my @sources = &makefile_list( \@oldfile, "C_SRC", "?" );
+    my $newfile = "$update_dir/Makefile";
+    open( my $fp, ">", $newfile ) || &failed("cannot open $newfile");
+    printf $fp <<EOF;
+# $generated_by
+
+LIB=	$libname
+EOF
+
+    printf $fp "%s\n", &format_list( "SRCS=", \@sources );
+    printf $fp "%s\n", &format_list( "HDRS=", \@headers );
+    my $includes = '-I${.CURDIR}/../libcurses';
+    $includes .= ' -I${.CURDIR}/../libmenu' if ( $libname eq "form" );
+    printf $fp <<EOF;
+CFLAGS+=$includes -D_XOPEN_SOURCE_EXTENDED -DNDEBUG
+EOF
+    my @manpages = &manpage_list($update_dir);
+    printf $fp "%s\n", &format_list( "MAN=", \@manpages );
+    printf $fp <<EOF;
+
+includes:
+	\@cd \$\{.CURDIR}; for i in \$\{HDRS}; do \\
+	  cmp -s \$\$i \${DESTDIR}/usr/include/\$\$i || \\
+	  \${INSTALL} \${INSTALL_COPY} -m 444 -o \$(BINOWN) -g \$(BINGRP) \$\$i \\
+	  \${DESTDIR}/usr/include; done
+
+.include <bsd.own.mk>
+
+afterinstall:
+	-cd \${DESTDIR}\${LIBDIR}; \\
+	for i in \${_LIBS}; do \\
+	    ln -f \$\$i `echo \$\$i | sed 's/${libname}/${libname}w/'`; \\
+	done
+
+.include <bsd.lib.mk>
+EOF
+    close $fp;
+    &compare_makefiles($newfile);
+}
+
+sub gen_bin_makefile($) {
+    my $binname = shift;
+    my $oldfile = "$source_dir/progs/Makefile";
+    my @oldfile = &read_file($oldfile);
+    my $newfile = "$update_dir/Makefile";
+
+    open( my $fp, ">", $newfile ) || &failed("cannot open $newfile");
+    my @sources = ("$binname.c");
+    my @links   = ();
+    my @autosrc = &makefile_list( \@oldfile, "AUTO_SRC", "?" );
+
+    my $tput_ver       = 0;
+    my $use_dump_entry = 0;
+    my $use_termsort   = 0;
+    my $use_tparm_type = 0;
+    my $use_transform  = 0;
+
+    $use_dump_entry = 1 if ( $binname eq "infocmp" or $binname eq "tic" );
+    $use_termsort   = 1 if ( $use_dump_entry       or $binname eq "tput" );
+
+    if ( &patchdate >= 20090314 ) {
+        $use_transform = 1 if ( $binname =~ /^(tic|tput|tset)/ );
+    }
+    if ( &patchdate >= 20140521 ) {
+        $use_tparm_type = 1 if ( $binname =~ /^(tic|tput)$/ );
+    }
+    if ( &patchdate >= 20160806 ) {
+        $tput_ver = &patchdate;
+    }
+
+    $sources[ ++$#sources ] = "dump_entry.c" if ($use_dump_entry);
+    $sources[ ++$#sources ] = "tparm_type.c" if ($use_tparm_type);
+    $sources[ ++$#sources ] = "transform.c"  if ($use_transform);
+
+    $autosrc[ ++$#autosrc ] = "termsort.c" if ($use_termsort);
+
+    # transform.h also is generated, but OpenBSD checked-in a copy
+
+    if ( $binname eq "tic" ) {
+        $links[ ++$#links ] = "captoinfo";
+        $links[ ++$#links ] = "infotocap";
+    }
+    elsif ( $binname eq "tabs" ) {
+        $sources[ ++$#sources ] = "tty_settings.c" if ( $tput_ver >= 20161224 );
+    }
+    elsif ( $binname eq "tput" ) {
+        $sources[ ++$#sources ] = "clear_cmd.c"    if ( $tput_ver >= 20161022 );
+        $sources[ ++$#sources ] = "reset_cmd.c"    if ( $tput_ver >= 20160806 );
+        $sources[ ++$#sources ] = "tty_settings.c" if ( $tput_ver >= 20161224 );
+        $links[ ++$#links ]     = "clear";
+    }
+    elsif ( $binname eq "tset" ) {
+        $sources[ ++$#sources ] = "reset_cmd.c"    if ( $tput_ver >= 20160806 );
+        $sources[ ++$#sources ] = "tty_settings.c" if ( $tput_ver >= 20161224 );
+        $links[ ++$#links ]     = "reset";
+    }
+
+    printf $fp <<EOF;
+# $generated_by
+
+PROG=	$binname
+EOF
+    printf $fp "%s\n", &format_list( "SRCS=", \@sources );
+    printf $fp <<EOF;
+CURSES=	\${.CURDIR}/../../lib/libcurses
+DPADD=	\${LIBCURSES}
+LDADD=	-L\${CURSES} -lcurses\t# in-tree link to add _nc_strict_bsd, etc
+EOF
+    if ( $#links >= 0 ) {
+        my @bin_links;
+        for my $n ( 0 .. $#links ) {
+            $bin_links[ ++$#bin_links ] = '${BINDIR}/' . $binname;
+            $bin_links[ ++$#bin_links ] = '${BINDIR}/' . $links[$n];
+        }
+        printf $fp "%s\n", &format_list( "LINKS=", \@bin_links, 1 );
+    }
+    my $ticfix = '${.CURDIR}/';
+    if ( $binname eq "tic" ) {
+        printf $fp <<EOF;
+CFLAGS+= -I\${CURSES} -I\${.CURDIR} -I.
+EOF
+    }
+    else {
+        $ticfix = '${TIC}/';
+        printf $fp <<EOF;
+TIC= \${.CURDIR}/../tic
+CFLAGS+= -I\${CURSES} -I\${TIC} -I\${.CURDIR} -I.
+.PATH:  \${TIC}
+EOF
+    }
+    printf $fp "%s\n", &format_list( "CLEANFILES+=", \@autosrc );
+    if ($use_dump_entry) {
+        printf $fp <<EOF;
+
+dump_entry.o: termsort.c
+EOF
+    }
+    if ($use_termsort) {
+        printf $fp <<EOF;
+
+termsort.c: ${ticfix}MKtermsort.sh
+	sh ${ticfix}MKtermsort.sh awk \${CURSES}/Caps > \${.TARGET}
+EOF
+    }
+    printf $fp <<EOF;
+
+.include <bsd.prog.mk>
+EOF
+    close $fp;
+
+    &compare_makefiles($newfile);
+}
+
+################################################################################
+
+sub setup_lib_libcurses() {
+    if ( &setup_dir("lib/libcurses") ) {
+        &copy_code( "$source_dir/ncurses/base",     "$update_dir/base" );
+        &copy_code( "$source_dir/ncurses/tinfo",    "$update_dir/tinfo" );
+        &copy_code( "$source_dir/ncurses/tty",      "$update_dir/tty" );
+        &copy_code( "$source_dir/ncurses/widechar", "$update_dir/widechar" );
+        &copy_file( "$source_dir/include/Caps",           $update_dir );
+        &copy_file( "$source_dir/include/capdefaults.c",  $update_dir );
+        &copy_file( "$source_dir/include/curses.h",       $update_dir );
+        &copy_file( "$source_dir/include/hashed_db.h",    $update_dir );
+        &copy_file( "$source_dir/include/hashsize.h",     $update_dir );
+        &copy_file( "$source_dir/include/nc_alloc.h",     $update_dir );
+        &copy_file( "$source_dir/include/nc_panel.h",     $update_dir );
+        &copy_file( "$source_dir/include/nc_tparm.h",     $update_dir );
+        &copy_file( "$source_dir/include/ncurses_cfg.h",  $update_dir );
+        &copy_file( "$source_dir/include/ncurses_def.h",  $update_dir );
+        &copy_file( "$source_dir/include/ncurses_dll.h",  $update_dir );
+        &copy_file( "$source_dir/include/parametrized.h", $update_dir );
+        &copy_file( "$source_dir/include/term.h",         $update_dir );
+        &copy_file( "$source_dir/include/termcap.h",      $update_dir );
+        &copy_file( "$source_dir/include/term_entry.h",   $update_dir );
+        &copy_file( "$source_dir/include/tic.h",          $update_dir );
+        &copy_file( "$source_dir/include/unctrl.h",       $update_dir );
+        &copy_file( "$source_dir/man/terminfo.5",         $update_dir );
+        &copy_docs("curses");
+
+        &verbose(".. work around a bug in /bin/sh in OpenBSD");
+        system( "sed -i"
+              . " -e 's,^shift,test \$# != 0 \\&\\& shift,'"
+              . " $update_dir/tinfo/MKfallback.sh" );
+
+        # OpenBSD dropped support for sys/ttydev.h, without mentioning the
+        # system version.  Just trim it.
+        &verbose(".. work around mishandled sys/ttydef.h");
+        system( "sed -i"
+              . " -e '/__FreeBSD_version/s,|| defined(__OpenBSD__),,'"
+              . " $update_dir/tinfo/lib_baudrate.c" );
+
+        if ($opt_t) {
+            &copy_code( "$source_dir/ncurses/trace", "$update_dir/trace" );
+        }
+        else {
+            &copy_file( "$source_dir/ncurses/trace/lib_trace.c", $update_dir );
+            &copy_file( "$source_dir/ncurses/trace/visbuf.c",    $update_dir );
+        }
+        &copy_file( "$source_dir/include/nc_termios.h", $update_dir )
+          if ( &patchdate >= 20110625 );
+        &copy_file( "$source_dir/include/nc_string.h", $update_dir )
+          if ( &patchdate >= 20120222 );
+        &copy_file( "$source_dir/include/nc_access.h", $update_dir )
+          if ( &patchdate >= 20210626 );
+        &copy_file( "$source_dir/include/Caps-ncurses", $update_dir )
+          if ( &patchdate >= 20190302 );
+        &gen_1st_makefile;
+        &finish_dir;
+    }
+}
+
+sub setup_lib_libform() {
+    if ( &setup_dir("lib/libform") ) {
+        &copy_docs("form");
+        &gen_lib_makefile("form");
+        &finish_dir;
+    }
+}
+
+sub setup_lib_libmenu() {
+    if ( &setup_dir("lib/libmenu") ) {
+        &copy_docs("menu");
+        &gen_lib_makefile("menu");
+        &finish_dir;
+    }
+}
+
+sub setup_lib_libpanel() {
+    if ( &setup_dir("lib/libpanel") ) {
+        &copy_docs("panel");
+        &gen_lib_makefile("panel");
+        &finish_dir;
+    }
+}
+
+sub setup_bin_infocmp() {
+    if ( &setup_dir("usr.bin/infocmp") ) {
+        &copy_docs("infocmp");
+        &gen_bin_makefile("infocmp");
+        &finish_dir;
+    }
+}
+
+sub setup_bin_tabs() {
+    if ( &setup_dir("usr.bin/tabs") ) {
+        &copy_docs("tabs");
+        &gen_bin_makefile("tabs");
+        &finish_dir;
+    }
+}
+
+sub setup_bin_tic() {
+    if ( &setup_dir("usr.bin/tic") ) {
+        if ( &patchdate >= 20140521 ) {
+            &copy_file( "$source_dir/progs/tparm_type.c", $update_dir );
+            &copy_file( "$source_dir/progs/tparm_type.h", $update_dir );
+        }
+
+        # shared files for tput/tset
+        if ( &patchdate >= 20160806 ) {
+            &copy_file( "$source_dir/progs/reset_cmd.c", $update_dir );
+            &copy_file( "$source_dir/progs/reset_cmd.h", $update_dir );
+        }
+        if ( &patchdate >= 20161022 ) {
+            &copy_file( "$source_dir/progs/clear_cmd.c", $update_dir );
+            &copy_file( "$source_dir/progs/clear_cmd.h", $update_dir );
+        }
+        if ( &patchdate >= 20161224 ) {
+            &copy_file( "$source_dir/progs/tty_settings.c", $update_dir );
+            &copy_file( "$source_dir/progs/tty_settings.h", $update_dir );
+        }
+        &copy_docs("tic");
+        &gen_bin_makefile("tic");
+        &finish_dir;
+    }
+}
+
+sub setup_bin_toe() {
+    if ( &setup_dir("usr.bin/toe") ) {
+        &copy_docs("toe");
+        &gen_bin_makefile("toe");
+        &finish_dir;
+    }
+}
+
+sub setup_bin_tput() {
+    if ( &setup_dir("usr.bin/tput") ) {
+        &copy_docs("tput");
+        &gen_bin_makefile("tput");
+        &finish_dir;
+    }
+}
+
+sub setup_bin_tset() {
+    if ( &setup_dir("usr.bin/tset") ) {
+        &copy_docs("tset");
+        &gen_bin_makefile("tset");
+        &finish_dir;
+    }
+}
+
+sub setup_terminfo() {
+    if ( &setup_dir("share/termtypes") ) {
+        &copy_code( $target_dir, $update_dir );
+        &copy_file( "$source_dir/misc/terminfo.src",
+            "$update_dir/termtypes.master" );
+
+        # build the terminfo database using the in-tree tic.
+        # This is always best practice, but for ncurses 6.2 in particular is
+        # required.
+        my $prog = abs_path("$target_dir/../../usr.bin/tic");
+        my $libs = abs_path("$target_dir/../../lib/libcurses");
+        if ( defined $prog and defined $libs ) {
+            $prog .= "/tic";
+            &verbose(".. changing makefile to use in-tree tic");
+            system( "sed -i -E "
+                  . "-e 's,(TIC=).*,\\1\t$prog,' "
+                  . "-e 's,(\\\${TIC}),LD_LIBRARY_PATH=$libs \\1,' "
+                  . "$update_dir/Makefile" );
+        }
+        &finish_dir;
+    }
+}
+
+sub configure_tree() {
+    return if ( -f "ncurses/Makefile" );
+    my @search = ( "/usr/share/terminfo", "/usr/local/share/terminfo" );
+    my @prefix = ("./configure");
+    $prefix[ ++$#prefix ] = "--with-abi-version=5"
+      if ( &patchdate >= 20150502 && !$opt_6 );
+    my @options = (
+        "--with-ospeed=int",                               #
+        "--with-shared",                                   #
+        "--without-normal",                                #
+        "--without-debug",                                 #
+        "--with-terminfo-dirs=" . join( ':', @search ),    #
+        "--without-ada",                                   #
+        "--disable-hard-tabs",                             #
+        "--enable-const",                                  #
+        "--enable-getcap",                                 #
+        "--enable-bsdpad",                                 #
+        "--enable-signed-char",                            #
+        "--enable-termcap",                                #
+        "--enable-widec",                                  #
+        "--disable-setuid-environ"
+    );
+    $options[ ++$#options ] = "--with-trace" if ($opt_t);
+    $options[ ++$#options ] = "--enable-string-hacks"
+      if ( &patchdate >= 20120225 );
+    system( join( ' ', @prefix ) . ' ' . join( ' ', @options ) );
+    &failed("problem with configuring") unless ( -f "ncurses/Makefile" );
+
+    system("make sources");
+
+    # OpenBSD developers edit the generated file and do not regen it when
+    # doing upgrades.  This script reflects those edits.
+    system( "sed -i" . " -E"
+          . " -e '/TYPEOF_CHTYPE/s,int,long,'"
+          . " -e '/USE_TERMCAP/d'"
+          . " -e '/HAVE_LIB(FORM|MENU|PANEL)/s,^(.*)\$,/* \\1 */,'"
+          . " -e 's/TERMPATH.*/PURE_TERMINFO 0/'"
+          . " -e '/SYSTEM_NAME/s,\[0-9.\]+,,'"
+          . " include/ncurses_cfg.h" );
+}
+
+sub get_definitions() {
+    my @data = &read_file("dist.mk");
+    for my $n ( 0 .. $#data ) {
+        my $text = $data[$n];
+        $text =~ s/^\s*//;
+        next unless ( $text =~ /^NCURSES.*=/ );
+        $text =~ s/\s*=\s+/=/;
+        my $name = $text;
+        $name =~ s/=.*//;
+        my $value = $text;
+        $value =~ s/^[^=]*=//;
+        $value =~ s/\s.*//;
+        $definitions{$name} = $value;
+    }
+}
+
+sub setup_all_dirs() {
+    printf "** %s all build-directories\n", $opt_r ? "removing" : "setting up";
+    &get_definitions;
+    &configure_tree unless ($opt_r);
+    &setup_lib_libcurses;
+    &setup_lib_libmenu;
+    &setup_lib_libform;    # build after libmenu, for mf_common.h
+    &setup_lib_libpanel;
+    &setup_bin_tic;        # do this first, for shared headers
+    &setup_bin_infocmp;
+    &setup_bin_tabs if ( -f "$source_dir/progs/tabs.c" );
+    &setup_bin_toe;
+    &setup_bin_tput;
+    &setup_bin_tset;
+    &setup_terminfo;
+}
+
+sub usage() {
+    print <<EOF;
+Usage: ncu2openbsd [options] [sourcetree]
+
+Options:
+  -6       use ABI 6 rather than 5 if available
+  -d DST   specify destination (default: /usr/src)
+  -n       no-op, do not update destination
+  -r       remove update, restore sources from ".orig"
+  -t       enable ncurses trace
+  -v       verbose
+  -x       build each directory after setting up
+EOF
+    exit;
+}
+
+$Getopt::Std::STANDARD_HELP_VERSION = 1;
+&getopts('6d:nrtvx') || &usage();
+$opt_d = "/usr/src" unless ($opt_d);
+&usage() unless ( $#ARGV <= 0 );
+
+if ( $#ARGV == 0 ) {
+    if ( -f $ARGV[0] ) {
+        printf "** unpacking sources: %s\n", $ARGV[0];
+        &unpack( $ARGV[0] );
+    }
+    else {
+        &check_sourcedir( $ARGV[0] );
+    }
+}
+else {
+    &check_sourcedir(".");
+}
+
+&setup_all_dirs;
+
+# move out of temp-directory to allow cleanup.
+chdir $current;
+
+1;
diff --git a/contrib/ncurses/misc/ncurses-config.in b/contrib/ncurses/misc/ncurses-config.in
index eae39a516ff3..c9f1cf809843 100644
--- a/contrib/ncurses/misc/ncurses-config.in
+++ b/contrib/ncurses/misc/ncurses-config.in
@@ -1,7 +1,7 @@
 #!@SHELL@
-# $Id: ncurses-config.in,v 1.46 2021/01/23 23:47:46 tom Exp $
+# $Id: ncurses-config.in,v 1.52 2022/07/26 21:36:28 tom Exp $
 ##############################################################################
-# Copyright 2018-2020,2021 Thomas E. Dickey                                  #
+# Copyright 2018-2021,2022 Thomas E. Dickey                                  #
 # Copyright 2006-2015,2017 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -98,10 +98,10 @@ fi
 # are standard library directories (i.e., the linker is supposed to search
 # those directories).
 #
-# There is no portable way to find the list of standard library directories. 
+# There is no portable way to find the list of standard library directories.
 # Require a POSIX shell anyway, to keep this simple.
 lib_flags=
-for opt in -L$libdir @LDFLAGS@ @EXTRA_PKG_LDFLAGS@ $LIBS
+for opt in -L$libdir @EXTRA_PKG_LDFLAGS@ $LIBS
 do
 	case $opt in
 	-specs*) # ignore linker specs-files which were used to build library
@@ -110,8 +110,14 @@ do
 	-Wl,-z,*) # ignore flags used to manipulate shared image
 		continue
 		;;
+	-Wl,--dynamic-linker*) # ignore ELF interpreter
+		continue
+		;;
+	-Wl,--as-needed|-Wl,--build-id=*|-Wl,-dT,*|-Wl,-T,*)
+		continue
+		;;
 	-L*)
-		lib_check=${opt##-L} 
+		lib_check=`echo "x$opt" | sed -e 's/^.-L//'`
 		[ -d "$lib_check" ] || continue
 		case "$lib_check" in
 		@LD_SEARCHPATH@) # skip standard libdir
@@ -167,7 +173,7 @@ do
 	lib_flags="$lib_flags $opt"
 done
 
-[ $# = 0 ] && exec @SHELL@ $0 --error
+[ $# = 0 ] && exec @SHELL@ "$0" --error
 
 while [ $# -gt 0 ]; do
 	case "$1" in
@@ -198,7 +204,7 @@ ENDECHO
 			[ -n "$OPTS" ] && OPTS="$OPTS "
 			OPTS="${OPTS}${opt}"
 		done
-		printf "%s\n" "$OPTS"
+		printf '%s\n' "$OPTS"
 		;;
 	--libs-only-L)
 		OPTS=
@@ -211,7 +217,7 @@ ENDECHO
 				;;
 			esac
 		done
-		printf "%s\n" "$OPTS"
+		printf '%s\n' "$OPTS"
 		;;
 	--libs-only-l)
 		OPTS=
@@ -224,7 +230,7 @@ ENDECHO
 				;;
 			esac
 		done
-		printf "%s\n" "$OPTS"
+		printf '%s\n' "$OPTS"
 		;;
 	--libs-only-other)
 		OPTS=
@@ -239,7 +245,7 @@ ENDECHO
 				;;
 			esac
 		done
-		printf "%s\n" "$OPTS"
+		printf '%s\n' "$OPTS"
 		;;
 	# identification
 	--version)
@@ -265,7 +271,7 @@ ENDECHO
 		elif [ "${includedir}" != /usr/include ]; then
 			INCS="${includedir}"
 		fi
-		echo $INCS
+		echo "$INCS"
 		;;
 	--libdir)
 		echo "${libdir}"
@@ -285,7 +291,7 @@ ENDECHO
 	# general info
 	--help)
 		cat <<ENDHELP
-Usage: `basename $0` [options]
+Usage: `basename "$0"` [options]
 
 Options:
   --prefix           echos the package-prefix of ${THIS}
@@ -315,7 +321,7 @@ Options:
 ENDHELP
 		;;
 	--error|*)
-		@SHELL@ $0 --help 1>&2
+		@SHELL@ "$0" --help 1>&2
 		exit 1
 		;;
 	esac
diff --git a/contrib/ncurses/misc/run_tic.in b/contrib/ncurses/misc/run_tic.in
index b335b48e2a0d..bd11c4c80d4c 100644
--- a/contrib/ncurses/misc/run_tic.in
+++ b/contrib/ncurses/misc/run_tic.in
@@ -1,7 +1,7 @@
 #!@SHELL@
-# $Id: run_tic.in,v 1.38 2020/02/15 15:30:53 tom Exp $
+# $Id: run_tic.in,v 1.40 2022/07/16 19:37:03 tom Exp $
 ##############################################################################
-# Copyright 2019,2020 Thomas E. Dickey                                       #
+# Copyright 2019-2020,2022 Thomas E. Dickey                                  #
 # Copyright 2000-2012,2017 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -42,21 +42,20 @@ echo "** Building terminfo database, please wait..."
 # The script is designed to be run from the misc/Makefile as
 #	make install.data
 
-: ${suffix:=@EXEEXT@}
-: ${DESTDIR:=@DESTDIR@}
-: ${prefix:=@prefix@}
-: ${exec_prefix:=@exec_prefix@}
-: ${bindir:=@bindir@}
-: ${top_srcdir:=@top_srcdir@}
-: ${srcdir:=@srcdir@}
-: ${datarootdir:=@datarootdir@}
-: ${datadir:=@datadir@}
-: ${TIC_PATH:=@TIC@}
-: ${ticdir:=@TERMINFO@}
-: ${source:=@TERMINFO_SRC@}
-: ${LN_S:="@LN_S@"}
-: ${cross_compiling:=no}
-: ${ext_funcs:=@NCURSES_EXT_FUNCS@}
+: "${suffix:=@EXEEXT@}"
+: "${DESTDIR:=@DESTDIR@}"
+: "${prefix:=@prefix@}"
+: "${exec_prefix:=@exec_prefix@}"
+: "${bindir:=@bindir@}"
+: "${top_srcdir:=@top_srcdir@}"
+: "${srcdir:=@srcdir@}"
+: "${datarootdir:=@datarootdir@}"
+: "${datadir:=@datadir@}"
+: "${TIC_PATH:=@TIC@}"
+: "${ticdir:=@TERMINFO@}"
+: "${source:=@TERMINFO_SRC@}"
+: "${cross_compiling:=no}"
+: "${ext_funcs:=@NCURSES_EXT_FUNCS@}"
 
 test -z "${DESTDIR}" && DESTDIR=
 
@@ -118,7 +117,7 @@ TICDIR=`echo "$TERMINFO" | sed -e 's%/share/\([^/]*\)$%/lib/\1%'`
 PARENT=`echo "$TERMINFO" | sed -e 's%/[^/]*$%%'`
 if test -n "$PARENT"
 then
-	test -d $PARENT || mkdir -p $PARENT
+	mkdir -p "$PARENT"
 fi
 
 # Remove the old terminfo stuff; we don't care if it existed before, and it
@@ -127,7 +126,7 @@ fi
 # the directory is actually a symbolic link.
 if test -d "$TERMINFO"
 then
-	( cd "$TERMINFO" && rm -fr ? 2>/dev/null )
+	( cd "$TERMINFO" && rm -fr ./? 2>/dev/null )
 elif test -f "$TERMINFO.db"
 then
 	( rm -f "$TERMINFO.db" 2>/dev/null )
@@ -183,9 +182,9 @@ if test "$TICDIR" != "$TERMINFO" ; then
 	( rm -f "$TICDIR" 2>/dev/null )
 	if ( cd "$TICDIR" 2>/dev/null )
 	then
-		cd "$TICDIR"
+		cd "$TICDIR" || exit
 		TICDIR=`pwd`
-		if test "$TICDIR "!= "$TERMINFO "; then
+		if test "$TICDIR " != "$TERMINFO "; then
 			# Well, we tried.  Some systems lie to us, so the
 			# installer will have to double-check.
 			echo "Verify if $TICDIR and $TERMINFO are the same."
@@ -193,7 +192,7 @@ if test "$TICDIR" != "$TERMINFO" ; then
 			echo "Otherwise, remove $TICDIR and link it to $TERMINFO."
 		fi
 	else
-		cd ${DESTDIR}$prefix
+		cd ${DESTDIR}$prefix || exit
 		# Construct a symbolic link that only assumes $ticdir has the
 		# same $prefix as the other installed directories.
 		RELATIVE=`echo $ticdir|sed -e 's%^'$prefix'/%%'`
diff --git a/contrib/ncurses/misc/shlib b/contrib/ncurses/misc/shlib
index 8772d4f4a9e0..7b93d170e821 100755
--- a/contrib/ncurses/misc/shlib
+++ b/contrib/ncurses/misc/shlib
@@ -1,6 +1,6 @@
 #!/bin/sh
 ##############################################################################
-# Copyright 2020 Thomas E. Dickey                                            #
+# Copyright 2020,2021 Thomas E. Dickey                                       #
 # Copyright 1998-2005,2007 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -30,7 +30,7 @@
 #
 # Author: Thomas E. Dickey <dickey@clark.net> 1996
 #
-# $Id: shlib,v 1.13 2020/02/02 23:34:34 tom Exp $
+# $Id: shlib,v 1.14 2021/09/04 15:55:29 tom Exp $
 # Use this script as a wrapper when running executables linked to shared
 # libraries on systems that use the $LD_LIBRARY_PATH variable and don't embed
 # the soname's path within the linked executable (such as IRIX), e.g,
@@ -81,7 +81,7 @@ q=""
 for p in lib ../lib ../../lib ../../../lib
 do
 	if test -d $p; then
-		q=`cd $p; pwd`
+		q=`cd $p || exit; pwd`
 		break
 	elif test -f configure && test ! -d ../$p ; then
 		break
@@ -102,7 +102,7 @@ if test -n "$q" ; then
 	elif test -n "$LD_LIBRARY_PATH"; then
 		system=unix
 	else
-		for r in $q/*.*
+		for r in "$q"/*.*
 		do
 			if test -f "$r"
 			then
diff --git a/contrib/ncurses/misc/tdlint b/contrib/ncurses/misc/tdlint
index 71b0d89b6d4d..8ff5a40bffee 100755
--- a/contrib/ncurses/misc/tdlint
+++ b/contrib/ncurses/misc/tdlint
@@ -1,6 +1,6 @@
 #!/bin/sh
 ##############################################################################
-# Copyright 2020 Thomas E. Dickey                                            #
+# Copyright 2020,2021 Thomas E. Dickey                                       #
 # Copyright 1998,2000 Free Software Foundation, Inc.                         #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -30,7 +30,7 @@
 #
 # Author: Thomas E. Dickey <dickey@clark.net> 1996
 #
-# $Id: tdlint,v 1.7 2020/02/02 23:34:34 tom Exp $
+# $Id: tdlint,v 1.8 2021/09/04 15:55:29 tom Exp $
 #
 # Lint-script that allows user's own lint libraries, in addition to the ones
 # installed in the system.
@@ -45,16 +45,16 @@ if test -z "$ARCH" ; then
 	exit 1
 else
 	case $ARCH in
-	AIX)	set - $* -Nn4000
+	AIX)	set - "$@" -Nn4000
 		;;
-	IRIX)	set - $* -n -lc
+	IRIX)	set - "$@" -n -lc
 		;;
-	FreeBSD) set - $* -g -p -u -v -z
+	FreeBSD) set - "$@" -g -p -u -v -z
 		;;
 	SunOS)
 		case `uname -r` in
 		5.*)	ARCH=Solaris
-			set - $* -n -lc
+			set - "$@" -n -lc
 			;;
 		esac
 		;;
@@ -63,7 +63,7 @@ fi
 # LIBDIR=$HOME/lib/$ARCH/lint ;export LIBDIR
 for p in $HOME/lib/$ARCH/lint /usr/lib/lint /usr/lib
 do
-	if [ -d $p ]
+	if [ -d "$p" ]
 	then
 		DIRS="$DIRS $p"
 	fi
@@ -74,15 +74,15 @@ do
 	case $1 in
 	-D*\"*)	;;
 	-L*)
-		DIRS="`echo $1|sed -e 's/^-L//'` $DIRS"
+		DIRS="`echo "$1"|sed -e 's/^-L//'` $DIRS"
 		;;
 	-l*)
-		lib="llib-l`echo $1 | sed -e 's/^-l//'`.ln"
+		lib="llib-l`echo "$1" | sed -e 's/^-l//'`.ln"
 		found=no
 		for p in $DIRS
 		do
-			echo -n testing $p/$lib
-			if [ -f $p/$lib ]
+			printf "testing %s" "$p/$lib"
+			if [ -f "$p/$lib" ]
 			then
 				LIBS="$LIBS $p/$lib"
 				echo " (ok)"
@@ -111,4 +111,4 @@ do
 	shift
 done
 #
-eval lint $OPT $FILES $LIBS
+exec lint $OPT $FILES $LIBS
diff --git a/contrib/ncurses/misc/terminfo.src b/contrib/ncurses/misc/terminfo.src
index c1fdeb8a875d..5d575b8eb454 100644
--- a/contrib/ncurses/misc/terminfo.src
+++ b/contrib/ncurses/misc/terminfo.src
@@ -6,8 +6,8 @@
 # Report bugs and new terminal descriptions to
 #	bug-ncurses@gnu.org
 #
-#	$Revision: 1.866 $
-#	$Date: 2021/02/20 23:39:21 $
+#	$Revision: 1.1143 $
+#	$Date: 2024/03/09 20:01:40 $
 #
 # The original header is preserved below for reference.  It is noted that there
 # is a "newer" version which differs in some cosmetic details (but actually
@@ -349,8 +349,10 @@ ansi+inittabs|ANSI initial tab-stops,
 	it#8, use=ansi+tabs,
 ansi+erase|ANSI clear screen/line,
 	clear=\E[H\E[J, ed=\E[J, el=\E[K,
-ansi+rca|ANSI relative cursor-addressing,
+ansi+rca|ANSI relative cursor-addressing (1-based),
 	hpa=\E[%p1%{1}%+%dG, vpa=\E[%p1%{1}%+%dd,
+ansi+rca2|ANSI relative cursor-addressing,
+	hpa=\E[%i%p1%dG, vpa=\E[%i%p1%dd,
 ansi+cup|ANSI absolute cursor-addressing,
 	cup=\E[%i%p1%d;%p2%dH, home=\E[H,
 ansi+rep|ANSI repeat-character,
@@ -363,9 +365,12 @@ ansi+idc1|ANSI insert/delete one character,
 	dch1=\E[P, ich1=\E[@, rmir=\E[4l, smir=\E[4h,
 ansi+idc|ANSI insert/delete characters,
 	dch=\E[%p1%dP, ich=\E[%p1%d@, use=ansi+idc1,
-ansi+arrows|ANSI normal-mode cursor-keys,
+ansi+arrows|ANSI normal-mode home and cursor-keys,
 	kbs=^H, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
 	khome=\E[H,
+ansi+apparrows|ANSI application-mode home and cursor-keys,
+	kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, khome=\EOH,
+	use=ansi+arrows,
 ansi+sgr|ANSI graphic renditions,
 	blink=\E[5m, invis=\E[8m, rev=\E[7m,
 	sgr=\E[0%?%p3%t;7%;%?%p4%t;5%;%?%p7%t;8%;m,
@@ -425,7 +430,7 @@ klone+sgr|attribute control for ansi.sys displays,
 	use=klone+acs,
 
 # Most Intel boxes do not treat "invis" (invisible) text.
-klone+sgr8|attribute control for ansi.sys displays,
+klone+sgr8|attribute control for ansi.sys displays with invis,
 	invis=\E[8m,
 	sgr=\E[0;10%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p6
 	    %t;1%;%?%p7%t;8%;%?%p9%t;11%;m,
@@ -436,11 +441,9 @@ klone+sgr8|attribute control for ansi.sys displays,
 # work; uses \E[12m instead, which is pretty bulletproof but loses you the ACS
 # diamond and arrow characters under curses.
 klone+sgr-dumb|attribute control for ansi.sys displays (no ESC [ 11 m),
-	blink=\E[5m, bold=\E[1m, invis=\E[8m, rev=\E[7m, rmso=\E[m,
-	rmul=\E[m,
 	sgr=\E[0;10%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p6
 	    %t;1%;%?%p7%t;8%;%?%p9%t;12%;m,
-	sgr0=\E[0;10m, smacs=\E[12m, smso=\E[7m, smul=\E[4m,
+	sgr0=\E[0;10m, smacs=\E[12m, use=ansi+sgrbold,
 	use=klone+acs,
 
 # KOI8-R (RFC1489) acs (alternate character set)
@@ -467,8 +470,7 @@ klone+color|color control for ansi.sys and ISO6429-compatible displays,
 # default color pair,  but many `ANSI' terminals don't grok the <op> cap.
 ecma+color|color control for ECMA-48-compatible terminals,
 	AX,
-	colors#8, ncv#3, pairs#64,
-	op=\E[39;49m, setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
+	op=\E[39;49m, use=klone+color,
 
 ecma+italics|ECMA-48 italics,
 	ritm=\E[23m, sitm=\E[3m,
@@ -490,13 +492,12 @@ ecma+index|ECMA-48 scroll up/down,
 # For more detail on this rather pathetic standard, see the comments
 # near the end of this file.
 ibcs2|Intel Binary Compatibility Standard prescriptions,
-	cbt=\E[Z, clear=\Ec, cub=\E[%p1%dD, cub1=\E[1D,
-	cud=\E[%p1%dB, cud1=\E[1B, cuf=\E[%p1%dC, cuf1=\E[1C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[1A,
-	dch=\E[%p1%dP, dispc=\E=%p1%dg, ech=\E[%p1%dX,
-	hpa=\E[%i%p1%dG, hts=\EH, ich=\E[%p1%d@, ich1=\E[@,
-	il=\E[%p1%dL, rc=\E7, rmam=\E[?7l, sc=\E7, smam=\E[?7h,
-	tbc=\E[g, vpa=\E[%i%p1%dd, use=ecma+index,
+	cbt=\E[Z, clear=\Ec, cub1=\E[1D, cud1=\E[1B, cuf1=\E[1C,
+	cup=\E[%i%p1%d;%p2%dH, cuu1=\E[1A, dch=\E[%p1%dP,
+	dispc=\E=%p1%dg, ech=\E[%p1%dX, hpa=\E[%i%p1%dG, hts=\EH,
+	ich=\E[%p1%d@, ich1=\E[@, il=\E[%p1%dL, rc=\E7,
+	rmam=\E[?7l, sc=\E7, smam=\E[?7h, tbc=\E[g,
+	vpa=\E[%i%p1%dd, use=ansi+local, use=ecma+index,
 
 #### ANSI/ECMA-48 terminals and terminal emulators
 #
@@ -511,20 +512,20 @@ ibcs2|Intel Binary Compatibility Standard prescriptions,
 # and more than one page of memory.  It uses local motions instead of
 # direct cursor addressing, and makes almost no assumptions. It does
 # assume auto margins, no padding and/or xon/xoff, and a 24x80 screen.
-ansi-mr|mem rel cup ansi,
+ansi-mr|mem rel cup ANSI,
 	am, xon,
 	cols#80, lines#24, use=vanilla, use=ansi+erase,
 	use=ansi+local1,
 
 # ansi-mini is a bare minimum ANSI terminal. This should work on anything, but
 # beware of screen size problems and memory relative cursor addressing.
-ansi-mini|any ansi terminal with pessimistic assumptions,
+ansi-mini|any ANSI terminal with pessimistic assumptions,
 	am, xon,
 	cols#80, lines#24, use=vanilla, use=ansi+cup,
 	use=ansi+erase,
 
 # ansi-mtabs adds relative addressing and minimal tab support
-ansi-mtabs|any ansi terminal with pessimistic assumptions,
+ansi-mtabs|any ANSI terminal with pessimistic assumptions (relative addressing),
 	it#8,
 	ht=^I, use=ansi-mini, use=ansi+local1,
 
@@ -558,14 +559,12 @@ ansi-mtabs|any ansi terminal with pessimistic assumptions,
 ansi77|ANSI 3.64 standard 1977 version,
 	OTbs, am, mir,
 	cols#80, it#8, lines#24,
-	bel=^G, clear=\E[;H\E[2J, cr=\r, csr=\E[%i%p1%d;%p2%dr,
-	cub1=^H, cud1=\E[B, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
-	cuu1=\E[A, dch1=\E[P, dl1=\E[M$<5*/>, ed=\E[J, el=\E[K,
-	home=\E[H, ht=^I, il1=\E[L$<5*/>, ind=\ED, kbs=^H,
-	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kf1=\EOP,
-	kf2=\EOR, kf4=\EOS, khome=\E[H, nel=\r\ED, rc=\E8, ri=\EM,
-	rmir=\E[4l, rmso=\E[m, rmul=\E[m, sc=\E7, smir=\E[4h,
-	smso=\E[7m, smul=\E[4m,
+	bel=^G, clear=\E[;H\E[2J, cr=\r, cub1=^H,
+	cup=\E[%i%p1%d;%p2%dH, dch1=\E[P, dl1=\E[M$<5*/>,
+	ed=\E[J, el=\E[K, home=\E[H, ht=^I, il1=\E[L$<5*/>, ind=\ED,
+	kf1=\EOP, kf2=\EOR, kf4=\EOS, nel=\r\ED, ri=\EM, rmir=\E[4l,
+	rmso=\E[m, rmul=\E[m, smir=\E[4h, smso=\E[7m, smul=\E[4m,
+	use=ansi+arrows, use=ansi+csr, use=ansi+local1,
 
 # Procomm and some other ANSI emulations don't recognize all of the ANSI-
 # standard capabilities.  This entry deletes <cuu>, <cuf>, <cud>, <cub>, and
@@ -577,15 +576,14 @@ ansi77|ANSI 3.64 standard 1977 version,
 # <invis=\E[9m>, but <invis=\E[8m> now seems to be more common under
 # ANSI.SYS influence.
 # From: Eric S. Raymond <esr@snark.thyrsus.com> Oct 30 1995
-pcansi-m|pcansi-mono|ibm-pc terminal programs claiming to be ansi (mono mode),
+pcansi-m|pcansi-mono|ibm-pc terminal programs claiming to be ANSI (mono mode),
 	OTbs, am, mir, msgr,
-	cols#80, it#8, lines#24,
-	bel=^G, cbt=\E[Z, clear=\E[H\E[J, cr=\r, cub1=\E[D,
-	cud1=\E[B, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A,
-	dch1=\E[P, dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H, ht=^I,
-	hts=\EH, il1=\E[L, ind=\n, kbs=^H, kcub1=\E[D, kcud1=\E[B,
-	kcuf1=\E[C, kcuu1=\E[A, khome=\E[H, tbc=\E[3g,
+	cols#80, lines#24,
+	bel=^G, cr=\r, cup=\E[%i%p1%d;%p2%dH, dch1=\E[P, dl1=\E[M,
+	home=\E[H, ht=^I, il1=\E[L, ind=\n, use=ansi+arrows,
+	use=ansi+erase, use=ansi+inittabs, use=ansi+local1,
 	use=klone+sgr-dumb,
+
 pcansi-25-m|pcansi25m|ibm-pc terminal programs with 25 lines (mono mode),
 	lines#25, use=pcansi-m,
 pcansi-33-m|pcansi33m|ibm-pc terminal programs with 33 lines (mono mode),
@@ -593,7 +591,7 @@ pcansi-33-m|pcansi33m|ibm-pc terminal programs with 33 lines (mono mode),
 pcansi-43-m|ansi43m|ibm-pc terminal programs with 43 lines (mono mode),
 	lines#43, use=pcansi-m,
 # The color versions.  All PC emulators do color...
-pcansi|ibm-pc terminal programs claiming to be ansi,
+pcansi|ibm-pc terminal programs claiming to be ANSI,
 	use=klone+color, use=pcansi-m,
 pcansi-25|pcansi25|ibm-pc terminal programs with 25 lines,
 	lines#25, use=pcansi,
@@ -608,18 +606,52 @@ pcansi-43|pcansi43|ibm-pc terminal programs with 43 lines,
 # From: Eric S. Raymond <esr@snark.thyrsus.com> Nov 6 1995
 ansi-m|ansi-mono|ANSI X3.64-1979 terminal with ANSI.SYS compatible attributes,
 	mc5i,
-	cub=\E[%p1%dD, cud=\E[%p1%dB, cuf=\E[%p1%dC,
-	cuu=\E[%p1%dA, dch=\E[%p1%dP, dl=\E[%p1%dM,
-	ech=\E[%p1%dX, el1=\E[1K, hpa=\E[%i%p1%dG, ht=\E[I,
-	ich=\E[%p1%d@, il=\E[%p1%dL, kbs=^H, kcbt=\E[Z, kcub1=\E[D,
-	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kich1=\E[L, mc4=\E[4i,
-	mc5=\E[5i, nel=\r\E[S, rep=%p1%c\E[%p2%{1}%-%db,
-	s0ds=\E(B, s1ds=\E)B, s2ds=\E*B, s3ds=\E+B, tbc=\E[3g,
-	vpa=\E[%i%p1%dd, use=ecma+index, use=pcansi-m,
-
+	dch=\E[%p1%dP, dl=\E[%p1%dM, ech=\E[%p1%dX, el1=\E[1K,
+	hpa=\E[%i%p1%dG, ht=\E[I, ich=\E[%p1%d@, il=\E[%p1%dL,
+	kcbt=\E[Z, kich1=\E[L, mc4=\E[4i, mc5=\E[5i, nel=\r\E[S,
+	rep=%p1%c\E[%p2%{1}%-%db, s0ds=\E(B, s1ds=\E)B,
+	s2ds=\E*B, s3ds=\E+B, vpa=\E[%i%p1%dd, use=ansi+local,
+	use=ecma+index, use=pcansi-m,
+
+# ECMA-48 addresses three of the four capabilities here:
+#
+# u6 -
+#	8.3.14 CPR - ACTIVE POSITION REPORT
+#	Notation: (Pn1;Pn2) Representation: CSI Pn1;Pn2 05/02
+#	Parameter default values: Pn1 = 1; Pn2 = 1
+#
+# u7
+#	8.3.35 DSR - DEVICE ST A TUS REPORT
+#	Notation: (Ps) Representation: CSI Ps 06/14
+#	Parameter default value: Ps = 0
+#	DSR is used either to report the status of the sending device or to
+#	request a status report from the receiving device, depending on the
+#	parameter values:
+#	6 a report of the active presentation position or of the active data
+#	  position in the form of ACTIVE POSITION REPORT (CPR) is requested
+#
+# u9 -
+#	8.3.24 DA - DEVICE ATTRIBUTES
+#	Notation: (Ps) Representation: CSI Ps 06/03
+#	Parameter default value: Ps = 0
+#	With a parameter value not equal to 0, DA is used to identify the
+#	device which sends the DA.  The parameter value is a device type
+#	identification code according to a register which is to be established. 
+#	If the parameter value is 0, DA is used to request an identifying DA
+#	from a device.
+#
+# DEC (and most "ANSI") terminals reply with a private-mode ("?") sequence,
+# but that register "which is to be" in ECMA-48 was never established.
+# For terminals that support DA1, a more specific u8 capability is preferred,
+# except for those (such as xterm) which can be configured to return different
+# responses.
+ansi+cpr|ncurses extension for ANSI CPR,
+	u6=\E[%i%d;%dR, u7=\E[6n,
 ansi+enq|ncurses extension for ANSI ENQ,
-	u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?%[;0123456789]c,
-	u9=\E[c,
+	u8=\E[?%[;0123456789]c, u9=\E[c, use=ansi+cpr,
+# DEC terminals provided DECID, subsumed into DA1:
+decid+cpr|ncurses extension for DECID,
+	u8=\E[?%[;0123456789]c, u9=\EZ, use=ansi+cpr,
 
 # ansi -- this terminfo expresses the largest subset of X3.64 that will fit in
 # standard terminfo.  Assumes ANSI.SYS-compatible attributes and color.
@@ -630,11 +662,11 @@ ansi|ansi/pc-term compatible with color,
 # ansi-generic is a vanilla ANSI terminal. This is assumed to implement
 # all the normal ANSI stuff with no extensions. It assumes
 # insert/delete line/char is there, so it won't work with
-# vt100 clones. It assumes video attributes for bold, blink,
+# VT100 clones. It assumes video attributes for bold, blink,
 # underline, and reverse, which won't matter much if the terminal
 # can't do some of those. Padding is assumed to be zero, which
 # shouldn't hurt since xon/xoff is assumed.
-ansi-generic|ansiterm|generic ansi standard terminal,
+ansi-generic|ansiterm|generic ANSI standard terminal,
 	am, xon,
 	cols#80, lines#24, use=vanilla, use=ansi+csr, use=ansi+cup,
 	use=ansi+rca, use=ansi+erase, use=ansi+tabs,
@@ -649,15 +681,17 @@ ansi-generic|ansiterm|generic ansi standard terminal,
 # though undocumented.  The <pfkey> capability is untested but should work for
 # keys F1-F10 (%p1 values outside this range will yield unpredictable results).
 # From: Eric S. Raymond <esr@snark.thyrsus.com> Nov 7 1995
-ansi.sys-old|ANSI.SYS under PC-DOS 2.1,
+#
+# DOS 2.0 (January 1983) documented these features in
+# Chapter 13, "Using Extended Screen and Keyboard Control" -TD
+ansi.sys-old|ANSI.SYS under PC-DOS 2.0,
 	OTbs, am, mir, msgr, xon,
 	cols#80, lines#25,
-	clear=\E[2J, cub1=^H, cud1=\E[B, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, el=\E[k, home=\E[H,
-	is2=\E[m\E[?7h, kcub1=^H, kcud1=\n, kcuf1=^L, kcuu1=^K,
-	khome=^^, pfkey=\E[0;%p1%{58}%+%d;%p2"%s"p, rc=\E[u,
-	rmam=\E[?7l, sc=\E[s, smam=\E[?7h, u6=\E[%i%d;%dR,
-	u7=\E[6n, use=klone+color, use=klone+sgr8,
+	clear=\E[2J, cub1=^H, cup=\E[%i%p1%d;%p2%dH, el=\E[k,
+	home=\E[H, is2=\E[m\E[?7h, kcub1=^H, kcud1=\n, kcuf1=^L,
+	kcuu1=^K, khome=^^, pfkey=\E[0;%p1%{58}%+%d;%p2"%s"p,
+	rc=\E[u, rmam=\E[?7l, sc=\E[s, smam=\E[?7h, use=ansi+cpr,
+	use=ansi+local1, use=klone+color, use=klone+sgr8,
 
 # Keypad:	Home=\0G	Up=\0H	PrPag=\0I
 #		ka1,kh		kcuu1		kpp,ka3
@@ -680,7 +714,7 @@ ansi.sys-old|ANSI.SYS under PC-DOS 2.1,
 #
 # <pfkey> capability for F1-F48 -TD
 ansi.sys|ANSI.SYS 3.1 and later versions,
-	el=\E[K, ka1=\0G, ka3=\0I, kb2=\0L, kbs=^H, kc1=\0O, kc3=\0Q,
+	el=\E[K, ka1=\0G, ka3=\0I, kb2=\0L, kc1=\0O, kc3=\0Q,
 	kcbt=\0^O, kcub1=\0K, kcud1=\0P, kcuf1=\0M, kcuu1=\0H,
 	kdch1=\0S, kend=\0O, kf1=\0;, kf10=\0D, kf11=\0\205,
 	kf12=\0\206, kf13=\0T, kf14=\0U, kf15=\0V, kf16=\0W,
@@ -692,10 +726,10 @@ ansi.sys|ANSI.SYS 3.1 and later versions,
 	kf42=\0m, kf43=\0n, kf44=\0o, kf45=\0p, kf46=\0q,
 	kf47=\0\213, kf48=\0\214, kf5=\0?, kf6=\0@, kf7=\0A, kf8=\0B,
 	kf9=\0C, khome=\0G, kich1=\0R, knp=\0Q, kpp=\0I,
-	pfkey=\E[0;%?%p1%{11}%<%t%'\:'%e%p1%{13}%<%t%'z'%e%p1%{23}%<
+	pfkey=\E[0;%?%p1%{11}%<%t%':'%e%p1%{13}%<%t%'z'%e%p1%{23}%<
 	      %t%'G'%e%p1%{25}%<%t%'p'%e%p1%'#'%<%t%'E'%e%p1%'%'%<%t
 	      %'f'%e%p1%'/'%<%t%'C'%e%{92}%;%p1%+%d;%p2"%s"p,
-	use=ansi.sys-old,
+	use=ansi+arrows, use=ansi.sys-old,
 
 #
 # Define IBM PC keypad keys for vi as per MS-Kermit while using ANSI.SYS.
@@ -764,62 +798,54 @@ st52-color|at-color|atari-color|atari_st-color|Atari ST with color,
 	is2=\Ev\Eq\Ee\Eb1\Ec0, rs2=\Ev\Eq\Ee\Eb1\Ec0,
 	setab=\Ec%?%p1%{0}%=%t1%e%p1%{1}%=%t2%e%p1%{2}%=%t3%e%p1%{3}
 	      %=%t>%e%p1%{4}%=%t4%e%p1%{5}%=%t7%e%p1%{6}%=%t5%e%p1
-	      %{7}%=%t0%e%p1%{8}%=%t8%e%p1%{9}%=%t9%e%p1%{10}%=%t\:
-	      %e%p1%{11}%=%t;%e%p1%{12}%=%t<%e%p1%{13}%=%t=%e%p1
-	      %{14}%=%t6%e?,
+	      %{7}%=%t0%e%p1%{8}%=%t8%e%p1%{9}%=%t9%e%p1%{10}%=%t:%e
+	      %p1%{11}%=%t;%e%p1%{12}%=%t<%e%p1%{13}%=%t=%e%p1%{14}
+	      %=%t6%e?,
 	setaf=\Eb%?%p1%{0}%=%t1%e%p1%{1}%=%t2%e%p1%{2}%=%t3%e%p1%{3}
 	      %=%t>%e%p1%{4}%=%t4%e%p1%{5}%=%t7%e%p1%{6}%=%t5%e%p1
-	      %{7}%=%t0%e%p1%{8}%=%t8%e%p1%{9}%=%t9%e%p1%{10}%=%t\:
-	      %e%p1%{11}%=%t;%e%p1%{12}%=%t<%e%p1%{13}%=%t=%e%p1
-	      %{14}%=%t6%e?,
+	      %{7}%=%t0%e%p1%{8}%=%t8%e%p1%{9}%=%t9%e%p1%{10}%=%t:%e
+	      %p1%{11}%=%t;%e%p1%{12}%=%t<%e%p1%{13}%=%t=%e%p1%{14}
+	      %=%t6%e?,
 	setb=\Ec%?%p1%{0}%=%t1%e%p1%{1}%=%t2%e%p1%{2}%=%t3%e%p1%{3}
 	     %=%t>%e%p1%{4}%=%t4%e%p1%{5}%=%t7%e%p1%{6}%=%t5%e%p1
-	     %{7}%=%t0%e%p1%{8}%=%t8%e%p1%{9}%=%t9%e%p1%{10}%=%t\:%e
+	     %{7}%=%t0%e%p1%{8}%=%t8%e%p1%{9}%=%t9%e%p1%{10}%=%t:%e
 	     %p1%{11}%=%t;%e%p1%{12}%=%t<%e%p1%{13}%=%t=%e%p1%{14}%=
 	     %t6%e?,
 	setf=\Eb%?%p1%{0}%=%t1%e%p1%{1}%=%t2%e%p1%{2}%=%t3%e%p1%{3}
 	     %=%t>%e%p1%{4}%=%t4%e%p1%{5}%=%t7%e%p1%{6}%=%t5%e%p1
-	     %{7}%=%t0%e%p1%{8}%=%t8%e%p1%{9}%=%t9%e%p1%{10}%=%t\:%e
+	     %{7}%=%t0%e%p1%{8}%=%t8%e%p1%{9}%=%t9%e%p1%{10}%=%t:%e
 	     %p1%{11}%=%t;%e%p1%{12}%=%t<%e%p1%{13}%=%t=%e%p1%{14}%=
 	     %t6%e?,
 	use=st52,
 st52|st52-m|at|at-m|atari|atari-m|atari_st|atarist-m|Atari ST,
 	am, eo, mir, npc,
-	cols#80, it#8, lines#24,
-	bel=^G, civis=\Ef, clear=\EE, cnorm=\Ee, cr=\r, cub1=\ED,
-	cud1=\EB, cuf1=\EC, cup=\EY%p1%{32}%+%c%p2%{32}%+%c,
-	cuu1=\EA, dl1=\EM, ed=\EJ, el=\EK, el1=\Eo, home=\EH, ht=^I,
-	il1=\EL, ind=\n, is2=\Ev\Eq\Ee, kLFT=\Ed, kRIT=\Ec, kbs=^H,
-	kcub1=\ED, kcud1=\EB, kcuf1=\EC, kcuu1=\EA, kdch1=^?,
-	kf1=\EP, kf10=\EY, kf11=\Ep, kf12=\Eq, kf13=\Er, kf14=\Es,
-	kf15=\Et, kf16=\Eu, kf17=\Ev, kf18=\Ew, kf19=\Ex, kf2=\EQ,
-	kf20=\Ey, kf3=\ER, kf4=\ES, kf5=\ET, kf6=\EU, kf7=\EV, kf8=\EW,
-	kf9=\EX, khlp=\EH, khome=\EE, kich1=\EI, knp=\Eb, kpp=\Ea,
-	kund=\EK, nel=\r\n, rc=\Ek, rev=\Ep, ri=\EI, rmso=\Eq,
-	rs2=\Ev\Eq\Ee, sc=\Ej, sgr0=\Eq, smso=\Ep,
-tw100|toswin vt100 window mgr,
+	civis=\Ef, clear=\EE, cnorm=\Ee, dl1=\EM, el1=\Eo, il1=\EL,
+	is2=\Ev\Eq\Ee, kLFT=\Ed, kRIT=\Ec, kdch1=^?, kf1=\EP,
+	kf10=\EY, kf11=\Ep, kf12=\Eq, kf13=\Er, kf14=\Es, kf15=\Et,
+	kf16=\Eu, kf17=\Ev, kf18=\Ew, kf19=\Ex, kf2=\EQ, kf20=\Ey,
+	kf3=\ER, kf4=\ES, kf5=\ET, kf6=\EU, kf7=\EV, kf8=\EW, kf9=\EX,
+	khlp=\EH, khome=\EE, kich1=\EI, knp=\Eb, kpp=\Ea, kund=\EK,
+	rc=\Ek, rev=\Ep, rmso=\Eq, rs2=\Ev\Eq\Ee, sc=\Ej, sgr0=\Eq,
+	smso=\Ep, use=vt52-basic,
+tw100|Toswin VT100 window manager,
 	eo, mir, msgr, xon,
 	colors#8, cols#80, it#8, lines#24, pairs#64, vt#3,
 	acsc=++\,\,--..00II``aaffgghhjjkkllmmnnooppqqrrssttuuvvwwxxy
 	     yzz{{||}}~~,
 	bel=^G, blink=\E[5m, bold=\E[1m, civis=\Ef,
-	clear=\E[2J\E[H, cnorm=\Ee, cr=\r, csr=\E[%i%p1%d;%p2%dr,
-	cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\EB,
-	cuf=\E[%p1%dC, cuf1=\EC, cup=\E[%i%p1%d;%p2%dH,
-	cuu=\E[%p1%dA, cuu1=\EA, dch1=\Ea, dim=\E[2m, dl=\E[%p1%dM,
-	dl1=\E[M, ed=\E[J, el=\E[K, el1=\E[1K, home=\E[H, ht=^I,
-	hts=\EH, ich=\E[%p1%d@, il1=\EL, ind=\n, is2=\E<\E)0, kbs=^H,
-	kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kdch1=^?,
-	kf1=\EOP, kf10=\EOY, kf11=\Ep, kf12=\Eq, kf13=\Er, kf14=\Es,
-	kf15=\Et, kf16=\Eu, kf17=\Ev, kf18=\Ew, kf19=\Ex, kf2=\EOQ,
-	kf20=\Ey, kf3=\EOR, kf4=\EOS, kf5=\EOT, kf6=\EOU, kf7=\EOV,
-	kf8=\EOW, kf9=\EOX, khlp=\EH, khome=\E\EE, kich1=\EI,
-	knp=\Eb, kpp=\E\Ea, kund=\EK, ll=\E[24H, nel=\EE,
-	oc=\E[30;47m, op=\E[30;47m, rc=\E8, rev=\E[7m, ri=\EM,
-	rmacs=^O, rmcup=\E[?7h, rmir=\Ei, rmkx=\E[?1l\E>,
+	clear=\E[2J\E[H, cnorm=\Ee, cr=\r, cub1=^H, cud1=\EB,
+	cuf1=\EC, cup=\E[%i%p1%d;%p2%dH, cuu1=\EA, dch1=\Ea,
+	dim=\E[2m, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K,
+	el1=\E[1K, home=\E[H, ht=^I, hts=\EH, ich=\E[%p1%d@, il1=\EL,
+	ind=\n, is2=\E<\E)0, kdch1=^?, kf1=\EOP, kf10=\EOY, kf11=\Ep,
+	kf12=\Eq, kf13=\Er, kf14=\Es, kf15=\Et, kf16=\Eu, kf17=\Ev,
+	kf18=\Ew, kf19=\Ex, kf2=\EOQ, kf20=\Ey, kf3=\EOR, kf4=\EOS,
+	kf5=\EOT, kf6=\EOU, kf7=\EOV, kf8=\EOW, kf9=\EOX, khlp=\EH,
+	khome=\E\EE, kich1=\EI, knp=\Eb, kpp=\E\Ea, kund=\EK,
+	ll=\E[24H, nel=\EE, oc=\E[30;47m, op=\E[30;47m, rev=\E[7m,
+	ri=\EM, rmacs=^O, rmcup=\E[?7h, rmir=\Ei, rmkx=\E[?1l\E>,
 	rmso=\E[m, rmul=\E[m,
 	rs1=\E<\E[20l\E[?3;6;9l\E[r\Eq\E(B\017\E)0\E>,
-	sc=\E7,
 	setb=\E[4%p1%'0'%+%Pa%?%ga%'0'%=%t0%e%ga%'1'%=%t4%e%ga%'2'%=
 	     %t2%e%ga%'3'%=%t6%e%ga%'4'%=%t1%e%ga%'5'%=%t5%e%ga%'6'
 	     %=%t3%e7%;m,
@@ -828,51 +854,47 @@ tw100|toswin vt100 window mgr,
 	     %=%t3%e7%;m,
 	sgr0=\E[m, smacs=^N, smcup=\E[?7l, smir=\Eh,
 	smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g,
+	use=ansi+apparrows, use=ansi+csr, use=ansi+local,
+
 # The entries for stv52 and stv52pc probably need a revision.
 stv52|MiNT virtual console,
 	am, msgr,
-	cols#80, it#8, lines#30,
-	bel=^G, blink=\Er, bold=\EyA, civis=\Ef, clear=\EE,
-	cnorm=\E. \Ee, cr=\r, cub1=^H, cud1=\EB, cuf1=\EC,
-	cup=\EY%p1%{32}%+%c%p2%{32}%+%c, cuu1=\EA, cvvis=\E.",
-	dim=\Em, dl1=\EM, ed=\EJ, el=\EK, home=\EH, ht=^I, il1=\EL,
-	ind=\n$<2*/>, kbs=^H, kcub1=\ED, kcud1=\EB, kcuf1=\EC,
-	kcuu1=\EA, kdch1=^?, kf1=\EP, kf10=\EY, kf11=\Ep, kf12=\Eq,
-	kf13=\Er, kf14=\Es, kf15=\Et, kf16=\Eu, kf17=\Ev, kf18=\Ew,
-	kf19=\Ex, kf2=\EQ, kf20=\Ey, kf3=\ER, kf4=\ES, kf5=\ET,
-	kf6=\EU, kf7=\EV, kf8=\EW, kf9=\EX, khlp=\EH, khome=\EE,
-	kich1=\EI, knp=\Eb, kpp=\Ea, kund=\EK, nel=\r\n$<2*/>,
-	op=\Eb@\EcO, rev=\Ep, ri=\EI$<2*/>, rmcup=\Ev\E. \Ee\Ez_,
-	rmso=\Eq, rmul=\EzH, rs1=\Ez_\Eb@\EcA, sgr0=\Ez_,
-	smcup=\Ev\Ee\Ez_, smso=\Ep, smul=\EyH,
+	lines#30,
+	blink=\Er, bold=\EyA, civis=\Ef, clear=\EE, cnorm=\E. \Ee,
+	cub1=^H, cvvis=\E.", dim=\Em, dl1=\EM, il1=\EL, ind=\n$<2*/>,
+	kdch1=^?, kf1=\EP, kf10=\EY, kf11=\Ep, kf12=\Eq, kf13=\Er,
+	kf14=\Es, kf15=\Et, kf16=\Eu, kf17=\Ev, kf18=\Ew, kf19=\Ex,
+	kf2=\EQ, kf20=\Ey, kf3=\ER, kf4=\ES, kf5=\ET, kf6=\EU, kf7=\EV,
+	kf8=\EW, kf9=\EX, khlp=\EH, khome=\EE, kich1=\EI, knp=\Eb,
+	kpp=\Ea, kund=\EK, nel=\r\n$<2*/>, op=\Eb@\EcO, rev=\Ep,
+	ri=\EI$<2*/>, rmcup=\Ev\E. \Ee\Ez_, rmso=\Eq, rmul=\EzH,
+	rs1=\Ez_\Eb@\EcA, sgr0=\Ez_, smcup=\Ev\Ee\Ez_, smso=\Ep,
+	smul=\EyH, use=vt52-basic,
 stv52pc|MiNT virtual console with PC charset,
 	am, msgr,
-	cols#80, it#8, lines#30,
+	lines#30,
 	acsc=+\257\,\256-\^.v0\333I\374`\177a\260f\370g\361h\261j
 	     \331k\277l\332m\300n\305o\377p-q\304r-s_t+u+v+w+x\263y
 	     \363z\362{\343|\366}\234~\371,
-	bel=^G, blink=\Er, bold=\EyA, civis=\Ef, clear=\EE,
-	cnorm=\E. \Ee, cr=\r, cub1=^H, cud1=\EB, cuf1=\EC,
-	cup=\EY%p1%{32}%+%c%p2%{32}%+%c, cuu1=\EA, cvvis=\E.",
-	dim=\Em, dl1=\EM, ed=\EJ, el=\EK, home=\EH, ht=^I, il1=\EL,
-	ind=\n$<2*/>, kbs=^H, kcub1=\ED, kcud1=\EB, kcuf1=\EC,
-	kcuu1=\EA, kdch1=^?, kf1=\EP, kf10=\EY, kf11=\Ep, kf12=\Eq,
-	kf13=\Er, kf14=\Es, kf15=\Et, kf16=\Eu, kf17=\Ev, kf18=\Ew,
-	kf19=\Ex, kf2=\EQ, kf20=\Ey, kf3=\ER, kf4=\ES, kf5=\ET,
-	kf6=\EU, kf7=\EV, kf8=\EW, kf9=\EX, khlp=\EH, khome=\EE,
-	kich1=\EI, knp=\Eb, kpp=\Ea, kund=\EK, nel=\r\n$<2*/>,
-	rev=\Ep, ri=\EI$<2*/>, rmcup=\Ev\E. \Ee\Ez_, rmso=\Eq,
-	rmul=\EzH, rs1=\Ez_\Eb@\EcA, sgr0=\Ez_, smcup=\Ev\Ee\Ez_,
-	smso=\Ep, smul=\EyH,
+	blink=\Er, bold=\EyA, civis=\Ef, clear=\EE, cnorm=\E. \Ee,
+	cub1=^H, cvvis=\E.", dim=\Em, dl1=\EM, il1=\EL, ind=\n$<2*/>,
+	kdch1=^?, kf1=\EP, kf10=\EY, kf11=\Ep, kf12=\Eq, kf13=\Er,
+	kf14=\Es, kf15=\Et, kf16=\Eu, kf17=\Ev, kf18=\Ew, kf19=\Ex,
+	kf2=\EQ, kf20=\Ey, kf3=\ER, kf4=\ES, kf5=\ET, kf6=\EU, kf7=\EV,
+	kf8=\EW, kf9=\EX, khlp=\EH, khome=\EE, kich1=\EI, knp=\Eb,
+	kpp=\Ea, kund=\EK, nel=\r\n$<2*/>, rev=\Ep, ri=\EI$<2*/>,
+	rmcup=\Ev\E. \Ee\Ez_, rmso=\Eq, rmul=\EzH,
+	rs1=\Ez_\Eb@\EcA, sgr0=\Ez_, smcup=\Ev\Ee\Ez_, smso=\Ep,
+	smul=\EyH, use=vt52-basic,
 
 # From: Simson L. Garfinkel <simsong@media-lab.mit.edu>
-atari-old|atari st,
+atari-old|Atari st,
 	OTbs, am,
 	cols#80, it#8, lines#25,
 	clear=\EH\EJ, cub1=\ED, cud1=\EB, cuf1=\EC,
 	cup=\EY%p1%{32}%+%c%p2%{32}%+%c, cuu1=\EA, dl1=\EM,
-	ed=\EJ, el=\EK, ht=^I, il1=\EL, kcub1=\ED, kcud1=\EB,
-	kcuf1=\EC, kcuu1=\EA, ri=\EI, rmso=\Eq, sgr0=\Eq, smso=\Ep,
+	ed=\EJ, el=\EK, ht=^I, il1=\EL, ri=\EI, rmso=\Eq, sgr0=\Eq,
+	smso=\Ep, use=vt52+arrows,
 # UniTerm terminal program for the Atari ST:  49-line VT220 emulation mode
 # From: Paul M. Aoki <aoki@ucbvax.berkeley.edu>
 uniterm|uniterm49|UniTerm VT220 emulator with 49 lines,
@@ -902,30 +924,26 @@ st52-old|Atari ST with VT52 emulation,
 # BeOS entry for Terminal program Seems to be almost ANSI
 beterm|BeOS Terminal,
 	am, eo, mir, msgr, xenl, xon,
-	colors#8, cols#80, it#8, lines#25, ncv#5, pairs#64,
-	bel=^G, bold=\E[1m, clear=\E[H\E[J, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M,
-	ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K, home=\E[H,
-	hpa=\E[%i%p1%dG, ht=^I, hts=\EH, ich=\E[%p1%d@, ich1=\E[@,
-	il=\E[%p1%dL, il1=\E[L, ind=\n, kbs=^H, kcub1=\E[D,
-	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kf1=\E[11~,
-	kf10=\E[20~, kf11=\E[21~, kf12=\E[22~, kf2=\E[12~,
-	kf3=\E[13~, kf4=\E[14~, kf5=\E[15~, kf6=\E[16~, kf7=\E[17~,
-	kf8=\E[18~, kf9=\E[19~, kspd=^Z, nel=\r\n, op=\E[m, rc=\E8,
-	rev=\E[7m, ri=\EM, rmir=\E[4l, rmkx=\E[?4l, rmso=\E[m,
-	rmul=\E[24m, rs1=\Ec, sc=\E7, setab=\E[4%p1%dm,
-	setaf=\E[3%p1%dm, setb=\E[%p1%{40}%+%cm,
-	setf=\E[%p1%{30}%+%cm, sgr0=\E[0;10m, smir=\E[4h,
-	smkx=\E[?4h, smso=\E[7m, smul=\E[4m,
-	u6=\E[%i%p1%d;%p2%dR, u7=\E[6n, vpa=\E[%i%p1%dd,
-	use=vt220+pcedit,
+	cols#80, it#8, lines#25, ncv#5,
+	bel=^G, bold=\E[1m, cr=\r, cub1=^H, cud1=\n,
+	cup=\E[%i%p1%d;%p2%dH, ech=\E[%p1%dX, el1=\E[1K,
+	home=\E[H, hpa=\E[%i%p1%dG, ht=^I, hts=\EH, ind=\n,
+	kf1=\E[11~, kf10=\E[20~, kf11=\E[21~, kf12=\E[22~,
+	kf2=\E[12~, kf3=\E[13~, kf4=\E[14~, kf5=\E[15~, kf6=\E[16~,
+	kf7=\E[17~, kf8=\E[18~, kf9=\E[19~, khome=\E[1~, kspd=^Z,
+	nel=\r\n, op=\E[m, rev=\E[7m, ri=\EM, rmkx=\E[?4l, rmso=\E[m,
+	rmul=\E[24m, rs1=\Ec, setb=\E[%p1%{40}%+%cm,
+	setf=\E[%p1%{30}%+%cm, sgr0=\E[0;10m, smkx=\E[?4h,
+	smso=\E[7m, smul=\E[4m, u6=\E[%i%p1%d;%p2%dR, u7=\E[6n,
+	vpa=\E[%i%p1%dd, use=ansi+arrows, use=ansi+csr,
+	use=ansi+erase, use=ansi+idc, use=ansi+idl,
+	use=ansi+local, use=klone+color, use=vt220+pcedit,
 
 #### Linux consoles
 #
 
+# release 1.2.13: 1995/03
+#
 # This entry is good for the 1.2.13 or later version of the Linux console.
 #
 # ***************************************************************************
@@ -949,34 +967,30 @@ beterm|BeOS Terminal,
 # All linux kernels since 1.2.13 (at least) set the screen size
 # themselves; this entry assumes that capability.
 #
-linux-basic|linux console,
+linux-basic|Linux console (basic),
 	am, bce, eo, mir, msgr, xenl, xon,
 	it#8, ncv#18, U8#1,
 	acsc=+\020\,\021-\030.^Y0\333`\004a\261f\370g\361h\260i
 	     \316j\331k\277l\332m\300n\305o~p\304q\304r\304s_t\303u
 	     \264v\301w\302x\263y\363z\362{\343|\330}\234~\376,
-	bel=^G, clear=\E[H\E[J, cr=\r, csr=\E[%i%p1%d;%p2%dr,
-	cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\n,
-	cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
-	cuu=\E[%p1%dA, cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[P,
-	dim=\E[2m, dl=\E[%p1%dM, dl1=\E[M, ech=\E[%p1%dX, ed=\E[J,
-	el=\E[K, el1=\E[1K, flash=\E[?5h$<200/>\E[?5l, home=\E[H,
-	hpa=\E[%i%p1%dG, ht=^I, hts=\EH, ich=\E[%p1%d@, ich1=\E[@,
-	il=\E[%p1%dL, il1=\E[L, ind=\n, kb2=\E[G, kbs=^?, kcbt=\E[Z,
-	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kf1=\E[[A,
+	bel=^G, cr=\r, cub1=^H, cud1=\n, cup=\E[%i%p1%d;%p2%dH,
+	dim=\E[2m, ech=\E[%p1%dX, el1=\E[1K,
+	flash=\E[?5h$<200/>\E[?5l, home=\E[H, hpa=\E[%i%p1%dG,
+	ht=^I, hts=\EH, ind=\n, kb2=\E[G, kbs=^?, kcbt=\E[Z, kf1=\E[[A,
 	kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf2=\E[[B,
 	kf3=\E[[C, kf4=\E[[D, kf5=\E[[E, kf6=\E[17~, kf7=\E[18~,
-	kf8=\E[19~, kf9=\E[20~, kmous=\E[M, kspd=^Z, nel=\r\n,
-	rc=\E8, rev=\E[7m, ri=\EM, rmam=\E[?7l, rmir=\E[4l,
-	rmso=\E[27m, rmul=\E[24m, rs1=\Ec\E]R, sc=\E7,
+	kf8=\E[19~, kf9=\E[20~, khome=\E[1~, kmous=\E[M, kspd=^Z,
+	nel=\r\n, ri=\EM, rmam=\E[?7l, rmso=\E[27m, rmul=\E[24m,
+	rs1=\Ec\E]R,
 	sgr=\E[0;10%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p5
 	    %t;2%;%?%p6%t;1%;%?%p9%t;11%;m,
-	smam=\E[?7h, smir=\E[4h, smul=\E[4m, tbc=\E[3g,
-	vpa=\E[%i%p1%dd, use=vt220+pcedit, use=vt102+enq,
+	smam=\E[?7h, tbc=\E[3g, vpa=\E[%i%p1%dd, use=ansi+arrows,
+	use=ansi+csr, use=ansi+erase, use=ansi+idc, use=ansi+idl,
+	use=ansi+local, use=vt220+pcedit, use=vt102+enq,
 	use=klone+sgr, use=ecma+color, use=linux+sfkeys,
 
 linux+decid|ncurses extension for Linux console DECID,
-	u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?6c, u9=\EZ,
+	u8=\E[?6c, use=decid+cpr,
 
 linux+sfkeys|shifted function-keys for Linux console,
 	kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, kf16=\E[29~,
@@ -986,18 +1000,20 @@ linux-m|Linux console no color,
 	colors@, pairs@,
 	setab@, setaf@, setb@, setf@, use=linux,
 
+# release 1.3: 1995/06
+#
 # The 1.3.x kernels add color-change capabilities; if yours doesn't have this
 # and it matters, turn off <ccc>.  The %02x escape used to implement this is
 # not supposedly back-portable to older SV curses (although it has worked fine
 # on Solaris for several years) and not supported in ncurses versions before
 # 1.9.9.
-linux-c-nc|linux console with color-change,
+linux-c-nc|Linux console with color-change,
 	ccc,
 	initc=\E]P%p1%x%p2%{255}%*%{1000}%/%02x%p3%{255}%*%{1000}%/
 	      %02x%p4%{255}%*%{1000}%/%02x,
 	oc=\E]R, use=linux-basic,
 # From: Dennis Henriksen <opus@osrl.dk>, 9 July 1996
-linux-c|linux console 1.3.6+ for older ncurses,
+linux-c|Linux console 1.3.6+ for older ncurses,
 	ccc,
 	initc=\E]P%?%p1%{9}%>%t%p1%{10}%-%'a'%+%c%e%p1%d%;%p2%{255}
 	      %*%{1000}%/%Pr%gr%{16}%/%Px%?%gx%{9}%>%t%gx%{10}%-%'a'
@@ -1010,13 +1026,17 @@ linux-c|linux console 1.3.6+ for older ncurses,
 	      %d%;,
 	oc=\E]R, use=linux-basic,
 
+# release 2.2: 1999/01
+#
 # The 2.2.x kernels add a private mode that sets the cursor type; use that to
 # get a block cursor for cvvis.
 # reported by Frank Heckenbach <frank@g-n-u.de>.
-linux2.2|linux 2.2.x console,
+linux2.2|Linux 2.2.x console,
 	civis=\E[?25l\E[?1c, cnorm=\E[?25h\E[?0c,
 	cvvis=\E[?25h\E[?8c, use=linux-c-nc,
 
+# release 2.6: 2003/12 - 2004/12
+#
 # Linux 2.6.x has a fix for SI/SO to work with UTF-8 encoding added here:
 #	http://lkml.iu.edu/hypermail/linux/kernel/0602.2/0738.html
 # Although the kernel has mappings for these, they were not in the default
@@ -1044,7 +1064,7 @@ linux2.2|linux 2.2.x console,
 #
 #    https://lwn.net/Articles/284767/
 #	"An interview with the new embedded maintainers"
-linux2.6|linux 2.6.x console,
+linux2.6|Linux 2.6.x console,
 	acsc=++\,\,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxy
 	     yzz{{||}}~~,
 	enacs=\E)0, rmacs=^O,
@@ -1054,11 +1074,22 @@ linux2.6|linux 2.6.x console,
 
 # The 3.0 kernel adds support for clearing scrollback buffer (capability E3).
 # It is the same as xterm's erase-saved-lines feature.
-linux3.0|linux 3.0 kernels,
-	E3=\E[3J, use=linux2.6,
+#
+# Linux 3.0 was released in July 2011.  The keyboard utilities (kbd) are
+# used for configuring its keyboard mappings.
+#
+# kbd 1.14 was released before that (January 2008), but due to its placement
+# late in the Linux 2.6.x series had no immediate effect for most users.  That
+# provided a default mapping for shift-tab to the (misnamed) Meta_Tab, i.e.,
+# the same as Alt-Tab.
+#
+# The suggested mapping for the conventional \E[Z is provided in this entry as
+# an extended key to lessen user surprise -TD
+linux3.0|Linux 3.0 kernels,
+	kcbt=\E^I, E3=\E[3J, kcbt2=\E[Z, use=linux2.6,
 
 # This is Linux console for ncurses.
-linux|linux console,
+linux|Linux console,
 	use=linux3.0,
 
 # Subject: linux 2.6.26 vt back_color_erase
@@ -1067,16 +1098,16 @@ linux|linux console,
 # apparently from
 #	http://lkml.org/lkml/2008/4/26/305
 #	http://lkml.org/lkml/2008/10/3/66
-linux2.6.26|linux console w/o bce,
+linux2.6.26|Linux console w/o bce,
 	bce@, use=linux2.6,
 
 # See the note on ICH/ICH1 VERSUS RMIR/SMIR near the end of file
-linux-nic|linux with ich/ich1 suppressed for non-curses programs,
+linux-nic|Linux with ich/ich1 suppressed for non-curses programs,
 	ich@, ich1@, use=linux,
 
 # This assumes you have used setfont(8) to load one of the Linux koi8-r fonts.
 # acsc entry from Pavel Roskin" <pavel@absolute.spb.su>, 29 Sep 1997.
-linux-koi8|linux with koi8 alternate character set,
+linux-koi8|Linux with koi8 alternate character set,
 	acsc=+\020\,\021-\030.^Y0\215`\004a\221f\234g\237h\220i
 	     \276j\205k\203l\202m\204n\212o~p\0q\0r\0s_t\206u\207v
 	     \211w\210x\201y\230z\231{\267|\274~\224,
@@ -1084,11 +1115,11 @@ linux-koi8|linux with koi8 alternate character set,
 
 # Another entry for KOI8-r with Qing Long's acsc.
 # (which one better complies with the standard?)
-linux-koi8r|linux with koi8-r alternate character set,
+linux-koi8r|Linux with koi8-r alternate character set,
 	use=linux, use=klone+koi8acs,
 
 # Entry for the latin1 and latin2 fonts
-linux-lat|linux with latin1 or latin2 alternate character set,
+linux-lat|Linux with latin1 or latin2 alternate character set,
 	acsc=+\020\,\021-\030.^Y0\333`\004a\013f\370g\361h\260i
 	     \316j\211k\214l\206m\203n\305o~p\304q\212r\304s_t\207u
 	     \215v\301w\302x\205y\363z\362{\343|\330}\234~\376,
@@ -1097,12 +1128,14 @@ linux-lat|linux with latin1 or latin2 alternate character set,
 # This uses graphics from VT codeset instead of from cp437.
 # reason: cp437 (aka "straight to font") is not functional under luit.
 # from: Andrey V Lukyanov <land@long.yar.ru>.
-linux-vt|linux console using VT codes for graphics,
+linux-vt|Linux console using VT codes for graphics,
 	acsc=++\,\,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxy
 	     yzz~~,
 	rmacs=\E(K, rmpch@, sgr@, sgr0=\E[0m\E(K\017, smacs=\E(0,
 	smpch@, use=linux,
 
+# release: 0.3.9b 1997/01 to 2000/05
+#
 # This is based on the Linux console (relies on the console to perform some
 # of the functionality), but does not recognize as many control sequences.
 # The program comes bundled with an old (circa 1998) copy of the Linux
@@ -1113,11 +1146,35 @@ linux-vt|linux console using VT codes for graphics,
 #	\E[y,xf	same as \E[y,xH
 #
 # Note: The status-line support is buggy (dsl does not work).
-kon|kon2|jfbterm|Kanji ON Linux console,
-	ccc@, hs,
-	civis@, cnorm@, cvvis@, dsl=\E[?H, flash@, fsl=\E[?F, initc@,
-	initp@, kcbt@, oc@, op=\E[37;40m, rs1=\Ec, tsl=\E[?T,
-	use=linux,
+kon|kon2|Kanji ON Linux console,
+	am, bce, ccc, eo, eslok, hs, mir, msgr, xenl, xon,
+	it#8, ncv#18,
+	bel=^G, civis=\E[?25l, cnorm=\E[?25h, cr=\r, cub1=^H,
+	cud1=\n, cup=\E[%i%p1%d;%p2%dH, dim=\E[2m,
+	dsl=\E[?H\E[?E, el1=\E[1K, fsl=\E[?F, home=\E[H,
+	hpa=\E[%i%p1%dG, ht=^I, hts=\EH, ind=\n,
+	initc=\E]P%p1%x%p2%02x%p3%02x%p4%02x, kb2=\E[G, kbs=^?,
+	kf1=\E[[A, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~,
+	kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, kf16=\E[29~,
+	kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, kf2=\E[[B,
+	kf20=\E[34~, kf3=\E[[C, kf4=\E[[D, kf5=\E[[E, kf6=\E[17~,
+	kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, khome=\E[1~, kspd=^Z,
+	nel=\r\n, op=\E[37;40m, ri=\EM, rmso=\E[27m, rmul=\E[24m,
+	rs1=\Ec,
+	sgr=\E[0;10%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p5
+	    %t;2%;%?%p6%t;1%;%?%p7%t;8%;%?%p9%t;11%;m,
+	sgr0=\E[0;10m, tbc=\E[3g, tsl=\E[?T, u8=\E[?6c,
+	vpa=\E[%i%p1%dd, use=ansi+arrows, use=ansi+csr,
+	use=ansi+enq, use=ansi+erase, use=ansi+idc, use=ansi+idl,
+	use=ansi+local, use=ansi+sgrbold, use=ecma+sgr,
+	use=klone+color, use=vt220+pcedit,
+
+# release: 0.4.7 2005/05
+#
+jfbterm|japanese framebuffer terminal,
+	acsc=++\,\,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxy
+	     yzz{{||}}~~,
+	sgr0=\E[0m, use=kon,
 
 # FbTerm
 # Another variant.  There are two parts (src, src/lib) with the latter
@@ -1163,7 +1220,7 @@ fbterm|FbTerm for Linux with framebuffer,
 # For background, refer to the report on bug-ncurses:
 #
 # https://lists.gnu.org/archive/html/bug-ncurses/2019-10/msg00059.html
-linux-16color|linux console with 16 colors,
+linux-16color|Linux console with 16 colors,
 	colors#16, ncv#42, pairs#0x100,
 	setab=\E[4%p1%{8}%m%d%?%p1%{7}%>%t;5%e;25%;m,
 	setaf=\E[3%p1%{8}%m%d%?%p1%{7}%>%t;1%e;22%;m,
@@ -1182,38 +1239,36 @@ bterm|bogl virtual terminal,
 	acsc=aajjkkllmmqqttuuxx, bold=\E[1m, clear=\E[H\E[2J,
 	cr=\r, cub1=^H, cud1=\n, cup=\E[%i%p1%d;%p2%dH, ed=\E[J,
 	el=\E[K, home=\E[H, ind=\n, kb2=\E[G, kbs=^?, kcbt=\E[Z,
-	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kf1=\E[[A,
-	kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[25~,
-	kf14=\E[26~, kf15=\E[28~, kf16=\E[29~, kf17=\E[31~,
-	kf18=\E[32~, kf19=\E[33~, kf2=\E[[B, kf20=\E[34~,
-	kf3=\E[[C, kf4=\E[[D, kf5=\E[[E, kf6=\E[17~, kf7=\E[18~,
-	kf8=\E[19~, kf9=\E[20~, kmous=\E[M, kspd=^Z, nel=\r\n,
-	op=\E[49m\E[39m, rev=\E[7m, ri=\EM, rmacs=^O, rmso=\E[27m,
-	rmul=\E[24m, setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
-	sgr0=\E[0m, smacs=^N, smso=\E[7m, smul=\E[4m,
+	kf1=\E[[A, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~,
+	kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, kf16=\E[29~,
+	kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, kf2=\E[[B,
+	kf20=\E[34~, kf3=\E[[C, kf4=\E[[D, kf5=\E[[E, kf6=\E[17~,
+	kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, khome=\E[1~,
+	kmous=\E[M, kspd=^Z, nel=\r\n, op=\E[49m\E[39m, rev=\E[7m,
+	ri=\EM, rmacs=^O, rmso=\E[27m, rmul=\E[24m,
+	setab=\E[4%p1%dm, setaf=\E[3%p1%dm, sgr0=\E[0m, smacs=^N,
+	smso=\E[7m, smul=\E[4m, use=ansi+arrows,
 	use=vt220+pcedit, use=vt220+cvis,
 
 #### Mach
 #
 
 # From: Matthew Vernon <mcv21@pick.sel.cam.ac.uk>
-mach|Mach Console,
-	am, km,
+mach|Mach console,
+	am, km, NQ,
 	cols#80, it#8, lines#25,
-	bel=^G, blink=\E[5m, bold=\E[1m, clear=\Ec, cr=\r,
-	cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\n,
-	cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
-	cuu=\E[%p1%dA, cuu1=\E[A, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J,
-	el=\E[K, home=\E[H, ht=^I, il=\E[%p1%dL, il1=\E[L, ind=\n,
-	kbs=^?, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
-	kdch1=\E[9, kend=\E[Y, kf1=\EOP, kf10=\EOY, kf2=\EOQ,
-	kf3=\EOR, kf4=\EOS, kf5=\EOT, kf6=\EOU, kf7=\EOV, kf8=\EOW,
-	kf9=\EOX, khome=\E[H, kich1=\E[@, kll=\E[F, knp=\E[U,
-	kpp=\E[V, rev=\E[7m, rmso=\E[0m, rmul=\E[24m, sgr0=\E[0m,
-	smso=\E[7m, smul=\E[4m,
-mach-bold|Mach Console with bold instead of underline,
+	bel=^G, blink=\E[5m, bold=\E[1m, clear=\Ec, cr=\r, cub1=^H,
+	cud1=\n, cup=\E[%i%p1%d;%p2%dH, ed=\E[J, el=\E[K,
+	home=\E[H, ht=^I, ind=\n, kbs=^?, kdch1=\E[9, kend=\E[Y,
+	kf1=\EOP, kf10=\EOY, kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf5=\EOT,
+	kf6=\EOU, kf7=\EOV, kf8=\EOW, kf9=\EOX, kich1=\E[@, kll=\E[F,
+	knp=\E[U, kpp=\E[V, rev=\E[7m, rmso=\E[0m, rmul=\E[24m,
+	sgr0=\E[0m, smso=\E[7m, smul=\E[4m, use=ansi+arrows,
+	use=ansi+idl, use=ansi+local,
+
+mach-bold|Mach console with bold instead of underline,
 	rmul=\E[0m, smul=\E[1m, use=mach,
-mach-color|Mach Console with ANSI color,
+mach-color|Mach console with ANSI color,
 	colors#8, pairs#64,
 	dim=\E[2m, invis=\E[8m, op=\E[37;40m, rmso=\E[27m,
 	setab=\E[4%p1%dm, setaf=\E[3%p1%dm, use=mach,
@@ -1234,7 +1289,7 @@ mach-gnu|GNU Mach,
 	    2%;%?%p6%t;1%;%?%p7%t;8%;m,
 	use=ecma+index, use=mach,
 
-mach-gnu-color|Mach Console with ANSI color,
+mach-gnu-color|GNU Mach console with ANSI color,
 	colors#8, pairs#64,
 	op=\E[37;40m, rmso=\E[27m, setab=\E[4%p1%dm,
 	setaf=\E[3%p1%dm, use=mach-gnu,
@@ -1267,34 +1322,29 @@ mach-gnu-color|Mach Console with ANSI color,
 #
 # Reading the source, RIS resets cnorm, but not xmous.
 hurd|The GNU Hurd console server,
-	am, bce, bw, eo, km, mir, msgr, xenl, xon,
-	colors#8, it#8, ncv#18, pairs#64,
+	am, bce, bw, eo, km, mir, msgr, xenl, xon, NQ,
+	it#8, ncv#18,
 	acsc=++\,\,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxy
 	     yzz{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, clear=\Ec, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\E[B, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	cvvis=\E[34l, dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m,
-	dl=\E[%p1%dM, dl1=\E[M, ech=\E[%p1%dX, ed=\E[J, el=\E[K,
-	el1=\E[1K, flash=\Eg, home=\E[H, hpa=\E[%i%p1%dG, ht=^I,
-	ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L, ind=\E[S,
-	invis=\E[8m, kb2=\E[G, kbs=^?, kcbt=\E[Z, kcub1=\EOD,
-	kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kf1=\EOP, kf10=\E[21~,
+	bel=^G, cbt=\E[Z, clear=\Ec, cr=\r, cub1=^H, cvvis=\E[34l,
+	dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m, ech=\E[%p1%dX,
+	el1=\E[1K, flash=\Eg, ht=^I, ich=\E[%p1%d@, ind=\E[S,
+	kb2=\E[G, kbs=^?, kcbt=\E[Z, kf1=\EOP, kf10=\E[21~,
 	kf11=\E[23~, kf12=\E[24~, kf13=\E[25~, kf14=\E[26~,
 	kf15=\E[28~, kf16=\E[29~, kf17=\E[31~, kf18=\E[32~,
 	kf19=\E[33~, kf2=\EOQ, kf20=\E[34~, kf3=\EOR, kf4=\EOS,
 	kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~,
-	kich1=\E[2~, kmous=\E[M, kspd=^Z, nel=\r\n, op=\E[39;49m,
-	rc=\E8, rev=\E[7m, ri=\E[T, rmacs=\E[10m, rmir=\E[4l,
-	rmso=\E[27m, rmul=\E[24m, rs1=\EM\E[?1000l, sc=\E7,
-	setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
+	khome=\E[1~, kmous=\E[M, kspd=^Z, nel=\r\n, op=\E[39;49m,
+	ri=\E[T, rmir=\E[4l, rmso=\E[27m, rmul=\E[24m,
+	rs1=\EM\E[?1000l,
 	sgr=\E[0%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p5%t;
 	    2%;%?%p6%t;1%;%?%p7%t;8%;%?%p9%t;11%;m,
-	sgr0=\E[0m, smacs=\E[11m, smir=\E[4h, smso=\E[7m,
-	smul=\E[4m, vpa=\E[%i%p1%dd, grbom=\E[>1l, gsbom=\E[>1h,
-	use=vt220+pcedit, use=ecma+index, use=ecma+italics,
-	use=vt220+cvis,
+	smir=\E[4h, grbom=\E[>1l, gsbom=\E[>1h,
+	use=ansi+apparrows, use=ansi+csr, use=ansi+cup,
+	use=ansi+erase, use=ansi+idl, use=ansi+local,
+	use=ansi+rca2, use=ansi+sgrbold, use=vt220+pcedit,
+	use=ecma+index, use=ecma+italics, use=klone+acs,
+	use=klone+color, use=vt220+cvis,
 
 #### QNX
 #
@@ -1307,7 +1357,7 @@ hurd|The GNU Hurd console server,
 # optimization.  Bug: The <op> capability resets attributes.
 # From: Michael Hunter <mphunter@qnx.com> 30 Jul 1996
 # (removed: <sgr=%?%p1%t\E<%;%p2%t\E[%;%p3%t\E(%;%p4%t\E{%;%p6%t\E<%;,>)
-qnx|qnx4|qnx console,
+qnx|qnx4|QNX console,
 	daisy, km, mir, msgr, xhpa, xt,
 	colors#8, cols#80, it#4, lines#25, ncv#3, pairs#8,
 	acsc=O\333a\261j\331k\277l\332m\300n\305o\337q\304s\334t
@@ -1389,7 +1439,7 @@ qnxtmono|Monochrome QNX4 terminal or console,
 # From: Federico Bianchi <bianchi@pc-arte2.arte.unipi.it>, 1 Jul 1998
 # (esr: commented out <scp> and <rmcup> to avoid warnings.)
 # (TD: derive from original qnx4 entry)
-qnxt2|qnx 2.15 serial terminal,
+qnxt2|QNX 2.15 serial terminal,
 	am,
 	civis@, cnorm@, cvvis@, dch1@, ich1@, kRES@, kRPL@, kUND@, kspd@,
 	rep@, rmcup@, rmso=\E>, setb@, setf@, smcup@, smso=\E<, use=qnx4,
@@ -1397,25 +1447,21 @@ qnxt2|qnx 2.15 serial terminal,
 # QNX ANSI terminal definition
 qansi-g|QNX ANSI,
 	am, eslok, hs, xon,
-	colors#8, cols#80, it#8, lines#25, ncv#19, pairs#64, wsl#80,
+	colors#8, cols#80, lines#25, ncv#19, pairs#64, wsl#80,
 	acsc=Oa``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, clear=\E[2J\E[H,
-	cr=\r, csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=\E[D,
-	cud=\E[%p1%dB, cud1=\E[B, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH$<5>, cuu=\E[%p1%dA, cuu1=\E[A,
-	cvvis=\E[?12;25h, dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m,
-	dl=\E[%p1%dM, dl1=\E[1M, dsl=\E[r, ech=\E[%p1%dX, ed=\E[J,
-	el=\E[K, el1=\E[1K\E[X, flash=\E[?5h$<200>\E[?5l,
-	fsl=\E[?6h\E8, home=\E[H, hpa=\E[%i%p1%dG, ht=^I, hts=\EH,
-	ich=\E[%p1%d@, ich1=\E[1@, il=\E[%p1%dL, il1=\E[1L,
-	ind=\E[S, invis=\E[9m,
+	bel=^G, clear=\E[2J\E[H, cr=\r, csr=\E[%i%p1%d;%p2%dr,
+	cup=\E[%i%p1%d;%p2%dH$<5>, cvvis=\E[?12;25h,
+	dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m, dl=\E[%p1%dM,
+	dl1=\E[1M, dsl=\E[r, ech=\E[%p1%dX, ed=\E[J, el=\E[K,
+	el1=\E[1K\E[X, flash=\E[?5h$<200>\E[?5l, fsl=\E[?6h\E8,
+	home=\E[H, hpa=\E[%i%p1%dG, ich=\E[%p1%d@, ich1=\E[1@,
+	il=\E[%p1%dL, il1=\E[1L, ind=\E[S, invis=\E[9m,
 	is2=\E>\E[?1l\E[?7h\E[0;10;39;49m, is3=\E(B\E)0,
 	kBEG=\ENn, kCAN=\E[s, kCMD=\E[t, kCPY=\ENs, kCRT=\ENt,
 	kDL=\ENv, kEXT=\ENw, kFND=\ENx, kHLP=\ENy, kHOM=\E[h,
 	kLFT=\E[d, kNXT=\E[u, kOPT=\ENz, kPRV=\E[v, kRIT=\E[c,
-	kbs=^H, kcan=\E[S, kcbt=\E[Z, kclo=\ENc, kclr=\ENa,
-	kcmd=\E[G, kcpy=\E[g, kctab=\E[z, kcub1=\E[D, kcud1=\E[B,
-	kcuf1=\E[C, kcuu1=\E[A, kdch1=\E[P, kdl1=\E[p, kend=\E[Y,
+	kcan=\E[S, kcbt=\E[Z, kclo=\ENc, kclr=\ENa, kcmd=\E[G,
+	kcpy=\E[g, kctab=\E[z, kdch1=\E[P, kdl1=\E[p, kend=\E[Y,
 	kext=\E[y, kf1=\EOP, kf10=\EOY, kf11=\EOZ, kf12=\EOA,
 	kf13=\EOp, kf14=\EOq, kf15=\EOr, kf16=\EOs, kf17=\EOt,
 	kf18=\EOu, kf19=\EOv, kf2=\EOQ, kf20=\EOw, kf21=\EOx,
@@ -1427,13 +1473,13 @@ qansi-g|QNX ANSI,
 	kf42=\E[22~, kf43=\E[23~, kf44=\E[24~, kf45=\E[25~,
 	kf46=\E[26~, kf47=\E[27~, kf48=\E[28~, kf5=\EOT, kf6=\EOU,
 	kf7=\EOV, kf8=\EOW, kf9=\EOX, kfnd=\ENf, khlp=\ENh,
-	khome=\E[H, khts=\ENb, kich1=\E[@, kil1=\E[`, kind=\E[a,
-	kmov=\ENi, kmrk=\ENm, kmsg=\ENe, knp=\E[U, kopn=\ENo,
-	kopt=\ENk, kpp=\E[V, kref=\ENl, kres=\ENp, krfr=\ENg,
-	kri=\E[b, krpl=\ENr, krst=\ENj, ksav=\ENq, kslt=\E[T,
-	ktbc=\ENd, kund=\ENu, ll=\E[99H, nel=\EE, op=\E[39;49m,
-	rev=\E[7m, ri=\E[T, rmacs=^O, rmam=\E[?7l, rmso=\E[27m,
-	rmul=\E[24m, rs1=\017\E[?7h\E[0;39;49m$<2>\E>\E[?1l,
+	khts=\ENb, kich1=\E[@, kil1=\E[`, kind=\E[a, kmov=\ENi,
+	kmrk=\ENm, kmsg=\ENe, knp=\E[U, kopn=\ENo, kopt=\ENk,
+	kpp=\E[V, kref=\ENl, kres=\ENp, krfr=\ENg, kri=\E[b,
+	krpl=\ENr, krst=\ENj, ksav=\ENq, kslt=\E[T, ktbc=\ENd,
+	kund=\ENu, ll=\E[99H, nel=\EE, op=\E[39;49m, ri=\E[T,
+	rmacs=^O, rmam=\E[?7l, rmso=\E[27m, rmul=\E[24m,
+	rs1=\017\E[?7h\E[0;39;49m$<2>\E>\E[?1l,
 	rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h,
 	setb=\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}
 	     %=%t3%e%p1%d%;m,
@@ -1441,25 +1487,26 @@ qansi-g|QNX ANSI,
 	     %=%t3%e%p1%d%;m,
 	sgr=\E[0%?%p6%t;1%;%?%p5%t;2%;%?%p2%t;4%;%?%p4%t;5%;%?%p3%p1
 	    %|%t;7%;%?%p7%t;9%;m%?%p9%t\016%e\017%;,
-	sgr0=\E[m\017, smacs=^N, smam=\E[?7h, smso=\E[7m,
-	smul=\E[4m, tbc=\E[3g,
-	tsl=\E7\E1;24r\E[?6l\E[25;%i%p1%dH, use=ansi+rep,
-	use=att610+cvis0, use=ecma+index,
+	sgr0=\E[m\017, smacs=^N, smam=\E[?7h,
+	tsl=\E7\E1;24r\E[?6l\E[25;%i%p1%dH, use=ansi+arrows,
+	use=ansi+local, use=ansi+rep, use=ansi+inittabs,
+	use=ansi+sgrbold, use=att610+cvis0, use=decid+cpr,
+	use=ecma+index,
 #
-qansi|QNX ansi with console writes,
+qansi|QNX ANSI with console writes,
 	daisy, xhpa, use=qansi-g,
 #
-qansi-t|QNX ansi without console writes,
+qansi-t|QNX ANSI without console writes,
 	crxm, use=qansi,
 #
-qansi-m|QNX ansi with mouse,
+qansi-m|QNX ANSI with mouse,
 	maddr#1,
 	chr=\E[, cvr=\E], is1=\E[0t, mcub=\E[>1h, mcub1=\E[>7h,
 	mcud=\E[>1h, mcud1=\E[>1l\E[>9h, mcuf=\E[>1h\E[>9l,
 	mcuf1=\E[>7l, mcuu=\E[>6h, mcuu1=\E[>6l, rmicm=\E[>2l,
 	smicm=\E[>2h, use=qansi,
 #
-qansi-w|QNX ansi for windows,
+qansi-w|QNX ANSI for windows,
 	xvpa, use=qansi-m,
 
 #### SCO consoles
@@ -1493,36 +1540,34 @@ qansi-w|QNX ansi for windows,
 #
 # Console documents only 3 attributes can be set with SGR (so we don't use sgr).
 scoansi-old|SCO Extended ANSI standard crt (5.0.5),
-	OTbs, am, bce, eo, xon,
+	OTbs, am, bce, eo, xon, NQ,
 	colors#8, cols#80, it#8, lines#25, pairs#64,
-	acsc=+/\,.-\230.\2310[5566778899\:\:;;<<==>>FFGGHHIIJJKKLLMM
-	     NNOOPPQQRRSSTTUUVVWWXX`\204a0fxgqh2jYk?lZm@nEqDtCu4vAwB
-	     x3yszr{c}\034~\207,
+	acsc=+/\,.-\230.\2310[5566778899::;;<<==>>FFGGHHIIJJKKLLMMNN
+	     OOPPQQRRSSTTUUVVWWXX`\204a0fxgqh2jYk?lZm@nEqDtCu4vAwBx3
+	     yszr{c}\034~\207,
 	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z,
 	civis=\E[=14;12C, clear=\E[H\E[2J, cnorm=\E[=10;12C,
-	cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\E[B,
-	cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
-	cuu=\E[%p1%dA, cuu1=\E[A, cvvis=\E[=0;12C, dch=\E[%p1%dP,
-	dch1=\E[P, dispc=\E[=%p1%dg, dl=\E[%p1%dM, dl1=\E[M,
-	ed=\E[m\E[J, el=\E[m\E[K, el1=\E[1K, home=\E[H, ht=^I,
-	hts=\EH, ich=\E[%p1%d@, ich1=\E[@, il=\E[%p1%dL, il1=\E[L,
-	ind=\E[S, invis=\E[8m, kbeg=\E[E, kbs=^H, kcbt=\E[Z,
-	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kdch1=^?,
-	kend=\E[F, kf1=\E[M, kf10=\E[V, kf11=\E[W, kf12=\E[X,
-	kf13=\E[Y, kf15=\E[a, kf16=\E[b, kf17=\E[c, kf18=\E[d,
-	kf19=\E[e, kf2=\E[N, kf20=\E[f, kf21=\E[g, kf22=\E[h,
-	kf23=\E[i, kf24=\E[j, kf25=\E[k, kf26=\E[l, kf27=\E[m,
-	kf28=\E[n, kf29=\E[o, kf3=\E[O, kf30=\E[p, kf31=\E[q,
-	kf32=\E[r, kf33=\E[s, kf34=\E[t, kf35=\E[u, kf36=\E[v,
-	kf37=\E[w, kf38=\E[x, kf39=\E[y, kf4=\E[P, kf40=\E[z,
-	kf41=\E[@, kf42=\E[[, kf43=\E[\\, kf44=\E[], kf45=\E[\^,
-	kf46=\E[_, kf47=\E[`, kf48=\E[{, kf5=\E[Q, kf6=\E[R,
-	kf7=\E[S, kf8=\E[T, kf9=\E[U, khome=\E[H, kich1=\E[L,
+	cub1=^H, cup=\E[%i%p1%d;%p2%dH, cvvis=\E[=0;12C,
+	dch=\E[%p1%dP, dch1=\E[P, dispc=\E[=%p1%dg, ed=\E[m\E[J,
+	el=\E[m\E[K, el1=\E[1K, home=\E[H, ht=^I, hts=\EH,
+	ich=\E[%p1%d@, ich1=\E[@, ind=\E[S, invis=\E[8m, kbeg=\E[E,
+	kcbt=\E[Z, kdch1=^?, kend=\E[F, kf1=\E[M, kf10=\E[V,
+	kf11=\E[W, kf12=\E[X, kf13=\E[Y, kf15=\E[a, kf16=\E[b,
+	kf17=\E[c, kf18=\E[d, kf19=\E[e, kf2=\E[N, kf20=\E[f,
+	kf21=\E[g, kf22=\E[h, kf23=\E[i, kf24=\E[j, kf25=\E[k,
+	kf26=\E[l, kf27=\E[m, kf28=\E[n, kf29=\E[o, kf3=\E[O,
+	kf30=\E[p, kf31=\E[q, kf32=\E[r, kf33=\E[s, kf34=\E[t,
+	kf35=\E[u, kf36=\E[v, kf37=\E[w, kf38=\E[x, kf39=\E[y,
+	kf4=\E[P, kf40=\E[z, kf41=\E[@, kf42=\E[[, kf43=\E[\\,
+	kf44=\E[], kf45=\E[\^, kf46=\E[_, kf47=\E[`, kf48=\E[{,
+	kf5=\E[Q, kf6=\E[R, kf7=\E[S, kf8=\E[T, kf9=\E[U, kich1=\E[L,
 	knp=\E[G, kpp=\E[I, op=\E[0;37;40m, rc=\E8, rev=\E[7m,
 	ri=\E[T, rmacs=\E[10m, rmam=\E[?7l, rmso=\E[m, rmul=\E[m,
 	sc=\E7, setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
 	sgr0=\E[0;10m, smacs=\E[12m, smam=\E[?7h, smso=\E[7m,
-	smul=\E[4m, use=ecma+index,
+	smul=\E[4m, use=ansi+arrows, use=ansi+idl,
+	use=ansi+local, use=ecma+index,
+
 scoansi-new|SCO Extended ANSI standard crt (5.0.6),
 	km,
 	civis=\E[=0c, cnorm=\E[=1c, csr=\E[%i%p1%d;%p2%dr,
@@ -1579,36 +1624,33 @@ iris-ansi|iris-ansi-net|IRIS emulating 40 line ANSI terminal (almost VT100),
 	am,
 	cols#80, it#8, lines#40,
 	bel=^G, bold=\E[1m, clear=\E[H\E[2J,
-	cnorm=\E[9/y\E[12/y\E[=6l, cr=\r, cub=\E[%p1%dD,
-	cub1=\E[D, cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC,
-	cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA,
-	cuu1=\E[A, cvvis=\E[10/y\E[=1h\E[=2l\E[=6h,
-	dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K, el1=\E[1K,
-	home=\E[H, ht=^I, hts=\EH, il=\E[%p1%dL, il1=\E[L, ind=\ED,
+	cnorm=\E[9/y\E[12/y\E[=6l, cr=\r, cud1=\n,
+	cup=\E[%i%p1%d;%p2%dH,
+	cvvis=\E[10/y\E[=1h\E[=2l\E[=6h, ed=\E[J, el=\E[K,
+	el1=\E[1K, home=\E[H, ht=^I, hts=\EH, ind=\ED,
 	is2=\E[?1l\E>\E[?7h\E[100g\E[0m\E7\E[r\E8, kDC=\E[P,
 	kEND=\E[147q, kHOM=\E[143q, kLFT=\E[158q, kPRT=\E[210q,
-	kRIT=\E[167q, kSPD=\E[218q, kbs=^H, kcbt=\E[Z, kcub1=\E[D,
-	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kdch1=^?, kend=\E[146q,
-	kent=\r, kf1=\E[001q, kf10=\E[010q, kf11=\E[011q,
-	kf12=\E[012q, kf2=\E[002q, kf3=\E[003q, kf4=\E[004q,
-	kf5=\E[005q, kf6=\E[006q, kf7=\E[007q, kf8=\E[008q,
-	kf9=\E[009q, khome=\E[H, kich1=\E[139q, knp=\E[154q,
+	kRIT=\E[167q, kSPD=\E[218q, kcbt=\E[Z, kdch1=^?,
+	kend=\E[146q, kent=\r, kf1=\E[001q, kf10=\E[010q,
+	kf11=\E[011q, kf12=\E[012q, kf2=\E[002q, kf3=\E[003q,
+	kf4=\E[004q, kf5=\E[005q, kf6=\E[006q, kf7=\E[007q,
+	kf8=\E[008q, kf9=\E[009q, kich1=\E[139q, knp=\E[154q,
 	kpp=\E[150q, kprt=\E[209q, krmir=\E[146q, kspd=\E[217q,
 	nel=\EE, pfkey=\EP101;%p1%d.y%p2%s\E\\, rc=\E8,
 	rev=\E[7m, ri=\EM, rmam=\E[?7l, rmso=\E[m, rmul=\E[m, sc=\E7,
 	sgr0=\E[m, smam=\E[?7h, smso=\E[1;7m, smul=\E[4m,
-	tbc=\E[3g,
+	tbc=\E[3g, use=ansi+arrows, use=ansi+idl, use=ansi+local,
+
 iris-ansi-ap|IRIS ANSI in application-keypad mode,
-	is2=\E[?1l\E=\E[?7h, kent=\EOM, kf10=\E[010q,
-	kf11=\E[011q, kf12=\E[012q, kf9=\E[009q, use=iris-ansi,
+	is2=\E[?1l\E=\E[?7h, kent=\EOM, use=iris-ansi,
 
 # From the man-page, this is a quasi-vt100 emulator that runs on SGI's IRIX
 # (T.Dickey 98/1/24)
 iris-color|xwsh|IRIX ANSI with color,
 	ncv#33,
 	csr=\E[%i%p1%d;%p2%dr, dch=\E[%p1%dP, dim=\E[2m,
-	ech=\E[%p1%dX, ich=\E[%p1%d@, rc=\E8, rmul=\E[24m, rs1=\Ec,
-	rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, sc=\E7,
+	ech=\E[%p1%dX, ich=\E[%p1%d@, rmul=\E[24m, rs1=\Ec,
+	rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h,
 	use=ecma+italics, use=vt100+enq, use=klone+color,
 	use=iris-ansi-ap,
 
@@ -1634,49 +1676,52 @@ iris-color|xwsh|IRIX ANSI with color,
 #		CSI ? 5 h Reverse Video (DECSCNM).
 #
 pccon+keys|OpenBSD PC keyboard keys,
-	kbs=^?, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
-	kdch1=\E[3~, kend=\E[8~, kent=\r, kf1=\E[11~, kf10=\E[21~,
+	kbs=^?, kend=\E[8~, kent=\r, kf1=\E[11~, kf10=\E[21~,
 	kf11=\E[23~, kf12=\E[24~, kf13=\E[25~, kf14=\E[26~,
 	kf15=\E[28~, kf16=\E[29~, kf17=\E[31~, kf18=\E[32~,
 	kf19=\E[33~, kf2=\E[12~, kf20=\E[34~, kf21=\E[35~,
 	kf22=\E[36~, kf23=\E[37~, kf24=\E[38~, kf3=\E[13~,
 	kf4=\E[14~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~,
-	kf9=\E[20~, khome=\E[7~, kich1=\E[2~, knp=\E[6~, kpp=\E[5~,
-	krfr=^R,
+	kf9=\E[20~, khome=\E[7~, krfr=^R, use=ansi+arrows,
+	use=vt220+pcedit,
 pccon+sgr+acs0|sgr and simple ASCII pseudographics for OpenBSD PC console,
-	acsc=+>\,<-\^.v0#`+a\:f\\h#i#j+k+l+m+n+o~p-q-r-s_t+u+v+w+x|y
-	     #z#{*|!}#~o,
+	acsc=+>\,<-\^.v0#`+a:f\\h#i#j+k+l+m+n+o~p-q-r-s_t+u+v+w+x|y#
+	     z#{*|!}#~o,
+	bold=\E[1m, rev=\E[7m, rmso=\E[27m,
 	sgr=\E[0%?%p1%p3%|%t;7%;%?%p6%t;1%;%?%p2%t;4%;m,
-	sgr0=\E[m,
+	sgr0=\E[m, smso=\E[7m,
 pccon+sgr+acs|sgr and default ASCII pseudographics for OpenBSD PC console,
-	acsc=++\,\,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxy
-	     yzz{{||}}~~,
-	enacs=\E)0$<5>, rmacs=\E(B$<5>,
+	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
+	bold=\E[1m, enacs=\E)0, rev=\E[7m, rmacs=\E(B, rmso=\E[27m,
 	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;m%?%p9%t\E(0%e
-	    \E(B%;$<2>,
-	sgr0=\E[m\E(B$<5>, smacs=\E(0$<5>,
+	    \E(B%;,
+	sgr0=\E[m\E(B, smacs=\E(0, smso=\E[7m,
 # underline renders as color
 pccon+colors|ANSI colors for OpenBSD PC console,
 	bce,
-	colors#8, ncv#2, pairs#64,
-	op=\E[47;30m, setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
+	ncv#2,
+	op=\E[49;39m, use=klone+color,
+# OpenBSD uses wscons,
+# + which does not implement DECSCNM or anything comparable, so it does not
+#   support flash.
+# + it renders underline using color.
 pccon+base|base capabilities for OpenBSD PC console,
 	am, km, mc5i, msgr, npc, nxon, xenl, xon,
 	cols#80, it#8, lines#24,
-	bel=^G, bold=\E[1m, clear=\E[H\E[J, cr=\r, cub1=^H, cud1=\n,
-	cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[P, dl1=\E[M, ech=\E[%p1%dX, ed=\E[J,
-	el=\E[K, el1=\E[1K, home=\E[H, ht=^I, hts=\EH, ich=\E[%p1%d@,
-	il1=\E[L, ind=\ED, nel=\EE, rev=\E[7m, ri=\EM, rmam=\E[?7l,
-	rmso=\E[27m, rmul=\E[24m, rs2=\Ec$<50>, smam=\E[?7h,
-	smso=\E[7m, smul=\E[4m, tbc=\E[3g, u6=\E[%i%d;%dR,
-	u7=\E[6n,
+	bel=^G, cr=\r, cub1=^H, cud1=\n, cup=\E[%i%p1%d;%p2%dH,
+	dch=\E[%p1%dP, dch1=\E[P, ech=\E[%p1%dX, el1=\E[1K,
+	home=\E[H, ht=^I, hts=\EH, ich=\E[%p1%d@, ind=\ED, nel=\EE,
+	ri=\EM, rmam=\E[?7l, rmul=\E[24m, rs2=\Ec, smam=\E[?7h,
+	smul=\E[4m, tbc=\E[3g, use=ansi+cpr, use=ansi+csr,
+	use=ansi+erase, use=ansi+idl, use=ansi+local,
+
 pccon0-m|OpenBSD PC console without colors & with simple ASCII pseudographics,
 	use=pccon+sgr+acs0, use=pccon+base, use=pccon+keys,
 pccon0|OpenBSD PC console with simple ASCII pseudographics,
 	use=pccon0-m, use=pccon+colors,
 pccon-m|OpenBSD PC console without colors,
 	use=pccon+base, use=pccon+sgr+acs, use=pccon+keys,
+	use=ansi+enq, use=vt220+cvis,
 pccon|OpenBSD PC console,
 	use=pccon-m, use=pccon+colors,
 
@@ -1693,77 +1738,74 @@ pccon|OpenBSD PC console,
 # NOTE: <ich1> has been taken out of this entry. for reference, it should
 # be <ich1=\E[@>.  For discussion, see ICH/ICH1 VERSUS RMIR/SMIR below.
 # (esr: added <civis> and <cnorm> to resolve NetBSD Problem Report #4583)
-pcvtXX|pcvt vt200 emulator (DEC VT220),
+pcvtXX|pcvt VT200 emulator (DEC VT220),
 	am, km, mir, msgr, xenl,
 	it#8, vt#3,
 	acsc=++\,\,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxy
 	     yzz~~,
-	bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[J, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\E[B, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J,
-	el=\E[K, el1=\E[1K, home=\E[H, ht=^I, hts=\EH, ich=\E[%p1%d@,
-	il=\E[%p1%dL, il1=\E[L, ind=\ED,
+	bel=^G, blink=\E[5m, bold=\E[1m, cr=\r, cub1=^H,
+	cup=\E[%i%p1%d;%p2%dH, dch=\E[%p1%dP, dch1=\E[P,
+	el1=\E[1K, home=\E[H, ht=^I, hts=\EH, ich=\E[%p1%d@, ind=\ED,
 	is1=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, kbs=^?,
-	kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
 	kdch1=\E[3~, kf1=\E[17~, kf2=\E[18~, kf3=\E[19~,
 	kf4=\E[20~, kf5=\E[21~, kf6=\E[23~, kf7=\E[24~, kf8=\E[25~,
 	khome=\E[1~, kich1=\E[2~, kll=\E[4~, knp=\E[6~, kpp=\E[5~,
-	nel=\EE, rc=\E8, rev=\E[7m, rf=/usr/share/tabset/vt100,
-	ri=\EM, rmacs=\E(B, rmam=\E[?7l, rmir=\E[4l,
-	rmkx=\E[?1l\E>, rmso=\E[27m, rmul=\E[24m,
-	rs1=\Ec\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, sc=\E7,
-	sgr0=\E[m, smacs=\E(0, smam=\E[?7h, smir=\E[4h,
-	smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g,
-	use=ecma+index, use=vt220+cvis,
+	nel=\EE, rev=\E[7m, rf=/usr/share/tabset/vt100, ri=\EM,
+	rmacs=\E(B, rmam=\E[?7l, rmir=\E[4l, rmkx=\E[?1l\E>,
+	rmso=\E[27m, rmul=\E[24m,
+	rs1=\Ec\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, sgr0=\E[m,
+	smacs=\E(0, smam=\E[?7h, smir=\E[4h, smkx=\E[?1h\E=,
+	smso=\E[7m, smul=\E[4m, tbc=\E[3g, use=ansi+apparrows,
+	use=ansi+csr, use=ansi+erase, use=ansi+idl,
+	use=ansi+local, use=decid+cpr, use=ecma+index,
+	use=vt220+cvis,
 
-#	NetBSD/FreeBSD vt220 terminal emulator console (pc keyboard & monitor)
+#	NetBSD/FreeBSD VT220 terminal emulator console (pc keyboard & monitor)
 #	termcap entries for pure VT220-Emulation and 25, 28, 35, 40, 43 and
 #	50 lines entries; 80 columns
-pcvt25|dec vt220 emulation with 25 lines,
+pcvt25|DEC VT220 emulation with 25 lines,
 	cols#80, lines#25,
 	is2=\E[1;25r\E[25;1H, use=pcvtXX,
-pcvt28|dec vt220 emulation with 28 lines,
+pcvt28|DEC VT220 emulation with 28 lines,
 	cols#80, lines#28,
 	is2=\E[1;28r\E[28;1H, use=pcvtXX,
-pcvt35|dec vt220 emulation with 35 lines,
+pcvt35|DEC VT220 emulation with 35 lines,
 	cols#80, lines#35,
 	is2=\E[1;35r\E[35;1H, use=pcvtXX,
-pcvt40|dec vt220 emulation with 40 lines,
+pcvt40|DEC VT220 emulation with 40 lines,
 	cols#80, lines#40,
 	is2=\E[1;40r\E[40;1H, use=pcvtXX,
-pcvt43|dec vt220 emulation with 43 lines,
+pcvt43|DEC VT220 emulation with 43 lines,
 	cols#80, lines#43,
 	is2=\E[1;43r\E[43;1H, use=pcvtXX,
-pcvt50|dec vt220 emulation with 50 lines,
+pcvt50|DEC VT220 emulation with 50 lines,
 	cols#80, lines#50,
 	is2=\E[1;50r\E[50;1H, use=pcvtXX,
 
-#	NetBSD/FreeBSD vt220 terminal emulator console (pc keyboard & monitor)
+#	NetBSD/FreeBSD VT220 terminal emulator console (pc keyboard & monitor)
 #	termcap entries for pure VT220-Emulation and 25, 28, 35, 40, 43 and
 #	50 lines entries; 132 columns
-pcvt25w|dec vt220 emulation with 25 lines and 132 cols,
+pcvt25w|DEC VT220 emulation with 25 lines and 132 cols,
 	cols#132, lines#25,
 	is2=\E[1;25r\E[25;1H, use=pcvtXX,
-pcvt28w|dec vt220 emulation with 28 lines and 132 cols,
+pcvt28w|DEC VT220 emulation with 28 lines and 132 cols,
 	cols#132, lines#28,
 	is2=\E[1;28r\E[28;1H, use=pcvtXX,
-pcvt35w|dec vt220 emulation with 35 lines and 132 cols,
+pcvt35w|DEC VT220 emulation with 35 lines and 132 cols,
 	cols#132, lines#35,
 	is2=\E[1;35r\E[35;1H, use=pcvtXX,
-pcvt40w|dec vt220 emulation with 40 lines and 132 cols,
+pcvt40w|DEC VT220 emulation with 40 lines and 132 cols,
 	cols#132, lines#40,
 	is2=\E[1;40r\E[40;1H, use=pcvtXX,
-pcvt43w|dec vt220 emulation with 43 lines and 132 cols,
+pcvt43w|DEC VT220 emulation with 43 lines and 132 cols,
 	cols#132, lines#43,
 	is2=\E[1;43r\E[43;1H, use=pcvtXX,
-pcvt50w|dec vt220 emulation with 50 lines and 132 cols,
+pcvt50w|DEC VT220 emulation with 50 lines and 132 cols,
 	cols#132, lines#50,
 	is2=\E[1;50r\E[50;1H, use=pcvtXX,
 
 #	OpenBSD implements a color variation
-pcvt25-color|dec vt220 emulation with 25 lines and color,
+pcvt25-color|DEC VT220 emulation with 25 lines and color,
 	cols#80, lines#25,
 	is2=\E[1;25r\E[25;1H, kf1=\EOP, kf10=\E[29~, kf11=\E[23~,
 	kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, kf15=\E[28~,
@@ -1778,39 +1820,32 @@ pcvt25-color|dec vt220 emulation with 25 lines and color,
 # modified codes for setf/setb to setaf/setab, then to klone+color, corrected
 # typo in invis - TD
 arm100|arm100-am|Arm(RiscPC) ncurses compatible (for 640x480),
-	am, bce, msgr, xenl, xon,
-	cols#80, it#8, lines#30,
+	bce, xenl, xon,
+	lines#30,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, blink=\E[5m$<2>, bold=\E[1m$<2>,
-	clear=\E[H\E[J$<50>, cr=\r, csr=\E[%i%p1%d;%p2%dr,
-	cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\n,
-	cuf=\E[%p1%dC, cuf1=\E[C$<2>,
-	cup=\E[%i%p1%d;%p2%dH$<5>, cuu=\E[%p1%dA,
-	cuu1=\E[A$<2>, ed=\E[J$<50>, el=\E[K$<3>, el1=\E[1K$<3>,
-	enacs=\E(B\E)0, home=\E[H, ht=^I, hts=\EH, ind=\n,
-	invis=\E[8m$<2>, ka1=\E[q, ka3=\E[s, kb2=\E[r, kbs=^H,
-	kc1=\E[p, kc3=\E[n, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C,
-	kcuu1=\E[A, kent=\E[M, kf0=\E[y, kf1=\E[P, kf10=\E[x,
-	kf2=\E[Q, kf3=\E[R, kf4=\E[S, kf5=\E[t, kf6=\E[u, kf7=\E[v,
-	kf8=\E[l, kf9=\E[w, rc=\E8, rev=\E[7m$<2>, ri=\EM$<5>,
+	blink=\E[5m$<2>, bold=\E[1m$<2>, cub1=^H, cud1=\n,
+	cuf1=\E[C$<2>, cuu1=\E[A$<2>, invis=\E[8m$<2>, ka1=\E[q,
+	ka3=\E[s, kb2=\E[r, kc1=\E[p, kc3=\E[n, kent=\E[M, kf0=\E[y,
+	kf1=\E[P, kf10=\E[x, kf2=\E[Q, kf3=\E[R, kf4=\E[S, kf5=\E[t,
+	kf6=\E[u, kf7=\E[v, kf8=\E[l, kf9=\E[w, rev=\E[7m$<2>,
 	rmacs=^O, rmam=\E[?7l, rmkx=\E[?1l\E>, rmso=\E[m$<2>,
-	rmul=\E[m$<2>, rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h,
-	sc=\E7,
+	rmul=\E[m$<2>,
 	sgr=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5
 	    %;%?%p7%t;8%;m%?%p9%t\016%e\017%;$<2>,
 	sgr0=\E[m\017$<2>, smacs=^N, smam=\E[?7h, smkx=\E[?1h\E=,
-	smso=\E[7m$<2>, smul=\E[4m$<2>, tbc=\E[3g, use=ecma+sgr,
+	smso=\E[7m$<2>, smul=\E[4m$<2>, use=ansi+csr,
+	use=ansi+local, use=ecma+sgr, use=vt100+4bsd,
 	use=klone+color,
 
 arm100-w|arm100-wam|Arm(RiscPC) ncurses compatible (for 1024x768),
 	cols#132, lines#50, use=arm100,
 
-# NetBSD/x68k console vt200 emulator. This port runs on a 68K machine
+# NetBSD/x68k console VT200 emulator. This port runs on a 68K machine
 # manufactured by Sharp for the Japanese market.
 # From Minoura Makoto <minoura@netlaputa.or.jp>, 12 May 1996
 x68k|x68k-ite|NetBSD/x68k ITE,
 	cols#96, lines#32,
-	kclr=\E[9~, khlp=\E[28~, use=vt220-base,
+	kbs=^?, kclr=\E[9~, khlp=\E[28~, use=vt220-base,
 
 # <tv@pobox.com>:
 # Entry for the DNARD OpenFirmware console, close to ANSI but not quite.
@@ -1835,26 +1870,26 @@ ofcons|DNARD OpenFirmware console,
 	    %;%?%p1%p3%|%t;7%;m,
 	sgr0=\2330m, smso=\2337m, smul=\2334m,
 
-# NetBSD "wscons" emulator in vt220 mode.
-# This entry is based on the NetBSD termcap entry, correcting the ncv value.
-# The emulator renders underlined text in red.  Colors are otherwise usable.
+# NetBSD "wscons" emulator in VT220 mode.
+# This entry is based on the NetBSD termcap entry.  The emulator renders
+# underlined text in red.  Colors are otherwise usable.  NetBSD developers
+# prefer to not specify the corresponding ncv value.
 #
 # Testing the emulator and reading the source code (NetBSD 2.0), it appears
-# that "vt220" is inaccurate.  There are a few vt220-features, but most of the
-# vt220 screens in vttest do not work with this emulator.  For instance, it
-# identifies itself (primary DA response) as a vt220 with selective erase.  But
+# that "vt220" is inaccurate.  There are a few VT220-features, but most of the
+# VT220 screens in vttest do not work with this emulator.  For instance, it
+# identifies itself (primary DA response) as a VT220 with selective erase.  But
 # the selective erase feature does not work.  The secondary response is copied
-# from Kermit's emulation of vt220, does not correspond to actual vt220.  At
+# from Kermit's emulation of VT220, does not correspond to actual VT220.  At
 # the level of detail in a termcap, it is a passable emulator, since ECH does
 # work.  Don't use it on a VMS system -TD
 wsvt25|NetBSD wscons in 25 line DEC VT220 mode,
-	bce, msgr,
-	colors#8, cols#80, it#8, lines#25, ncv#2, pairs#64,
+	bce,
+	colors#8, lines#25, pairs#64,
 	is2=\E[r\E[25;1H, kdch1=\E[3~, kend=\E[8~, kf1=\E[11~,
-	kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf2=\E[12~,
-	kf3=\E[13~, kf4=\E[14~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~,
-	kf8=\E[19~, kf9=\E[20~, khome=\E[7~, op=\E[m, rs1=\Ec,
-	setab=\E[4%p1%dm, setaf=\E[3%p1%dm, use=vt220,
+	kf2=\E[12~, kf3=\E[13~, kf4=\E[14~, kf5=\E[15~,
+	khome=\E[7~, op=\E[m, rs1=\Ec, setab=\E[4%p1%dm,
+	setaf=\E[3%p1%dm, use=vt220,
 
 wsvt25m|NetBSD wscons in 25 line DEC VT220 mode with Meta,
 	km, use=wsvt25,
@@ -1879,9 +1914,9 @@ wsvt25m|NetBSD wscons in 25 line DEC VT220 mode with Meta,
 #
 # Testing with vttest:
 # -------------------
-# Identifies as vt220 with selective erase
+# Identifies as VT220 with selective erase
 #	(however, selective erase refers to DECSCA, SPA)
-# Does not implement vt52
+# Does not implement VT52
 # Uses spaces to simulate double-size characters
 # Does not support 8-bit controls
 # Does not support VT220 reports
@@ -1913,24 +1948,22 @@ rcons-color|BSD rasterconsole with ANSI color,
 mgterm|MGL/MGL2 MobileGear Graphic Library,
 	OTbs, OTpt, am, bce, bw, eo, km, msgr, npc,
 	colors#8, cols#80, it#8, lines#18, pairs#64,
-	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, clear=\E[H\E[J,
-	cr=\r, csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\E[B, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[P, dim=\E[30;1m, dl=\E[%p1%dM,
-	dl1=\E[M, ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K,
-	home=\E[H, hpa=\E[%i%p1%d`, ht=^I, ich=\E[%p1%d@,
-	ich1=\E[@, il=\E[%p1%dL, il1=\E[L, ind=\E[S, kb2=\E[E,
-	kbs=^H, kcbt=\E[Z, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C,
-	kcuu1=\E[A, kdch1=^?, kend=\E[F, kf1=\E[M, kf10=\E[V,
-	kf11=\E[W, kf12=\E[X, kf2=\E[N, kf3=\E[O, kf4=\E[P, kf5=\E[Q,
-	kf6=\E[R, kf7=\E[S, kf8=\E[T, kf9=\E[U, khome=\E[H,
-	kich1=\E[L, knp=\E[G, kpp=\E[I, nel=\E[E, op=\E[x, rc=\E8,
-	rev=\E[7m, ri=\E[T, rmso=\E[m, rs2=\E[x\E[m\Ec, sc=\E7,
-	setb=\E[4%p1%dm, setf=\E[3%p1%dm, sgr0=\E[m, smso=\E[7m,
-	vpa=\E[%i%p1%dd, use=ecma+index,
+	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, cr=\r, cub1=^H,
+	cup=\E[%i%p1%d;%p2%dH, dch=\E[%p1%dP, dch1=\E[P,
+	dim=\E[30;1m, ech=\E[%p1%dX, el1=\E[1K, home=\E[H,
+	hpa=\E[%i%p1%d`, ht=^I, ich=\E[%p1%d@, ich1=\E[@, ind=\E[S,
+	kb2=\E[E, kcbt=\E[Z, kdch1=^?, kend=\E[F, kf1=\E[M,
+	kf10=\E[V, kf11=\E[W, kf12=\E[X, kf2=\E[N, kf3=\E[O,
+	kf4=\E[P, kf5=\E[Q, kf6=\E[R, kf7=\E[S, kf8=\E[T, kf9=\E[U,
+	kich1=\E[L, knp=\E[G, kpp=\E[I, nel=\E[E, op=\E[x, rev=\E[7m,
+	ri=\E[T, rmso=\E[m, rs2=\E[x\E[m\Ec, setb=\E[4%p1%dm,
+	setf=\E[3%p1%dm, sgr0=\E[m, smso=\E[7m, vpa=\E[%i%p1%dd,
+	use=ansi+arrows, use=ansi+csr, use=ansi+erase,
+	use=ansi+idl, use=ansi+local, use=ecma+index,
 
 #### FreeBSD console entries
+
+# Originally from termcap:
 #
 # From: Andrey Chernov <ache@astral.msk.su> 29 Mar 1996
 # Andrey Chernov maintains the FreeBSD termcap distributions.
@@ -1942,8 +1975,9 @@ mgterm|MGL/MGL2 MobileGear Graphic Library,
 # I have seen FreeBSD-2.1.5R... The old el1 bug changed, but it is still there.
 # Now el1 clears not only to the line beginning, but also a large chunk
 # of previous line. But there is another bug - ech does not work at all.
-#
 
+# syscons, sc - the console driver
+#
 # for syscons
 # common entry without semigraphics
 # Bug: The <op> capability resets attributes.
@@ -1954,112 +1988,164 @@ mgterm|MGL/MGL2 MobileGear Graphic Library,
 # Setting colors turns off reverse; we cannot guarantee order, so use ncv.
 # Note that this disables standout with color.
 #
-# The emulator sends difference strings based on shift- and control-keys,
+# The emulator sends different strings based on shift- and control-keys,
 # like scoansi:
 #	F13-F24 are shifted F1-F12
 #	F25-F36 are control F1-F12
 #	F37-F48 are shift+control F1-F12
-cons25w|ansiw|ansi80x25-raw|freebsd console (25-line raw mode),
+cons25w|ansiw|ansi80x25-raw|FreeBSD console (25-line raw mode),
 	am, bce, bw, eo, msgr, npc,
-	colors#8, cols#80, it#8, lines#25, ncv#21, pairs#64,
-	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, clear=\E[H\E[J,
-	cnorm=\E[=0C, cr=\r, cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB,
-	cud1=\E[B, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	cvvis=\E[=1C, dch=\E[%p1%dP, dch1=\E[P, dim=\E[30;1m,
-	dl=\E[%p1%dM, dl1=\E[M, ech=\E[%p1%dX, ed=\E[J, el=\E[K,
+	cols#80, it#8, lines#25, ncv#21,
+	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, cnorm=\E[=0C,
+	cr=\r, cub1=^H, cup=\E[%i%p1%d;%p2%dH, cvvis=\E[=1C,
+	dch=\E[%p1%dP, dch1=\E[P, dim=\E[30;1m, ech=\E[%p1%dX,
 	home=\E[H, hpa=\E[%i%p1%d`, ht=^I, ich=\E[%p1%d@,
-	ich1=\E[@, il=\E[%p1%dL, il1=\E[L, ind=\E[S, kb2=\E[E,
-	kbs=^H, kcbt=\E[Z, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C,
-	kcuu1=\E[A, kdch1=^?, kend=\E[F, kf1=\E[M, kf10=\E[V,
-	kf11=\E[W, kf12=\E[X, kf13=\E[Y, kf14=\E[Z, kf15=\E[a,
-	kf16=\E[b, kf17=\E[c, kf18=\E[d, kf19=\E[e, kf2=\E[N,
-	kf20=\E[f, kf21=\E[g, kf22=\E[h, kf23=\E[i, kf24=\E[j,
-	kf25=\E[k, kf26=\E[l, kf27=\E[m, kf28=\E[n, kf29=\E[o,
-	kf3=\E[O, kf30=\E[p, kf31=\E[q, kf32=\E[r, kf33=\E[s,
-	kf34=\E[t, kf35=\E[u, kf36=\E[v, kf37=\E[w, kf38=\E[x,
-	kf39=\E[y, kf4=\E[P, kf40=\E[z, kf41=\E[@, kf42=\E[[,
-	kf43=\E[\\, kf44=\E[], kf45=\E[\^, kf46=\E[_, kf47=\E[`,
-	kf48=\E[{, kf5=\E[Q, kf6=\E[R, kf7=\E[S, kf8=\E[T, kf9=\E[U,
-	khome=\E[H, kich1=\E[L, knp=\E[G, kpp=\E[I, nel=\E[E,
-	op=\E[x, rc=\E8, rev=\E[7m, ri=\E[T, rmso=\E[m,
-	rs2=\E[x\E[m\Ec, sc=\E7, setab=\E[4%p1%dm,
-	setaf=\E[3%p1%dm,
+	ich1=\E[@, ind=\E[S, kb2=\E[E, kcbt=\E[Z, kdch1=^?,
+	kend=\E[F, kf1=\E[M, kf10=\E[V, kf11=\E[W, kf12=\E[X,
+	kf13=\E[Y, kf14=\E[Z, kf15=\E[a, kf16=\E[b, kf17=\E[c,
+	kf18=\E[d, kf19=\E[e, kf2=\E[N, kf20=\E[f, kf21=\E[g,
+	kf22=\E[h, kf23=\E[i, kf24=\E[j, kf25=\E[k, kf26=\E[l,
+	kf27=\E[m, kf28=\E[n, kf29=\E[o, kf3=\E[O, kf30=\E[p,
+	kf31=\E[q, kf32=\E[r, kf33=\E[s, kf34=\E[t, kf35=\E[u,
+	kf36=\E[v, kf37=\E[w, kf38=\E[x, kf39=\E[y, kf4=\E[P,
+	kf40=\E[z, kf41=\E[@, kf42=\E[[, kf43=\E[\\, kf44=\E[],
+	kf45=\E[\^, kf46=\E[_, kf47=\E[`, kf48=\E[{, kf5=\E[Q,
+	kf6=\E[R, kf7=\E[S, kf8=\E[T, kf9=\E[U, kich1=\E[L, knp=\E[G,
+	kpp=\E[I, nel=\E[E, op=\E[x, rc=\E8, rev=\E[7m, ri=\E[T,
+	rmso=\E[m, rs2=\E[x\E[m\Ec, sc=\E7,
 	sgr=\E[0%?%p1%t;2;7%;%?%p3%t;7%;%?%p4%t;5%;%?%p5%t;30;1%;%?
 	    %p6%t;1%;m,
-	sgr0=\E[m, smso=\E[7m, vpa=\E[%i%p1%dd, use=ecma+index,
-cons25|ansis|ansi80x25|freebsd console (25-line ansi mode),
+	sgr0=\E[m, smso=\E[7m, vpa=\E[%i%p1%dd, use=ansi+arrows,
+	use=ansi+erase, use=ansi+idl, use=ansi+local,
+	use=ecma+index, use=klone+color,
+
+cons25|ansis|ansi80x25|FreeBSD console (25-line ANSI mode),
 	acsc=-\030.^Y0\333`\004a\260f\370g\361h\261i\025j\331k\277l
 	     \332m\300n\305q\304t\303u\264v\301w\302x\263y\363z\362~
 	     \371,
 	use=cons25w,
-cons25-debian|freebsd console with debian backspace (25-line ansi mode),
+cons25-debian|FreeBSD console with debian backspace (25-line ANSI mode),
 	kbs=^?, kdch1=\E[3~, use=cons25,
-cons25-m|ansis-mono|ansi80x25-mono|freebsd console (25-line mono ansi mode),
+cons25-m|ansis-mono|ansi80x25-mono|FreeBSD console (25-line mono ANSI mode),
 	colors@, pairs@,
 	bold@, dim@, op@, rmul=\E[m, setab@, setaf@,
 	sgr=\E[0%?%p1%t;2;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;m,
 	smul=\E[4m, use=cons25,
-cons30|ansi80x30|freebsd console (30-line ansi mode),
+cons30|ansi80x30|FreeBSD console (30-line ANSI mode),
 	lines#30, use=cons25,
-cons30-m|ansi80x30-mono|freebsd console (30-line mono ansi mode),
+cons30-m|ansi80x30-mono|FreeBSD console (30-line mono ANSI mode),
 	lines#30, use=cons25-m,
-cons43|ansi80x43|freebsd console (43-line ansi mode),
+cons43|ansi80x43|FreeBSD console (43-line ANSI mode),
 	lines#43, use=cons25,
-cons43-m|ansi80x43-mono|freebsd console (43-line mono ansi mode),
+cons43-m|ansi80x43-mono|FreeBSD console (43-line mono ANSI mode),
 	lines#43, use=cons25-m,
-cons50|ansil|ansi80x50|freebsd console (50-line ansi mode),
+cons50|ansil|ansi80x50|FreeBSD console (50-line ANSI mode),
 	lines#50, use=cons25,
-cons50-m|ansil-mono|ansi80x50-mono|freebsd console (50-line mono ansi mode),
+cons50-m|ansil-mono|ansi80x50-mono|FreeBSD console (50-line mono ANSI mode),
 	lines#50, use=cons25-m,
-cons60|ansi80x60|freebsd console (60-line ansi mode),
+cons60|ansi80x60|FreeBSD console (60-line ANSI mode),
 	lines#60, use=cons25,
-cons60-m|ansi80x60-mono|freebsd console (60-line mono ansi mode),
+cons60-m|ansi80x60-mono|FreeBSD console (60-line mono ANSI mode),
 	lines#60, use=cons25-m,
-cons25r|pc3r|ibmpc3r|cons25-koi8-r|freebsd console w/koi8-r cyrillic,
+cons25r|pc3r|ibmpc3r|cons25-koi8-r|FreeBSD console w/koi8-r cyrillic,
 	acsc=-\030.^Y0\215`\004a\220f\234h\221i\025j\205k\203l\202m
 	     \204n\212q\0t\206u\207v\211w\210x\201y\230z\231~
 	     \225,
 	use=cons25w,
-cons25r-m|pc3r-m|ibmpc3r-mono|cons25-koi8r-m|freebsd console w/koi8-r cyrillic (mono),
+cons25r-m|pc3r-m|ibmpc3r-mono|cons25-koi8r-m|FreeBSD console w/koi8-r cyrillic (mono),
 	colors@, pairs@,
 	op@, rmul=\E[m, setab@, setaf@,
 	sgr=\E[0%?%p1%t;2;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p5
 	    %t;30;1%;%?%p6%t;1%;m,
 	smul=\E[4m, use=cons25r,
-cons50r|cons50-koi8r|freebsd console w/koi8-r cyrillic (50 lines),
+cons50r|cons50-koi8r|FreeBSD console w/koi8-r cyrillic (50 lines),
 	lines#50, use=cons25r,
-cons50r-m|cons50-koi8r-m|freebsd console w/koi8-r cyrillic (50-line mono),
+cons50r-m|cons50-koi8r-m|FreeBSD console w/koi8-r cyrillic (50-line mono),
 	lines#50, use=cons25r-m,
-cons60r|cons60-koi8r|freebsd console w/koi8-r cyrillic (60 lines),
+cons60r|cons60-koi8r|FreeBSD console w/koi8-r cyrillic (60 lines),
 	lines#60, use=cons25r,
-cons60r-m|cons60-koi8r-m|freebsd console w/koi8-r cyrillic (60-line mono),
+cons60r-m|cons60-koi8r-m|FreeBSD console w/koi8-r cyrillic (60-line mono),
 	lines#60, use=cons25r-m,
 # ISO 8859-1 FreeBSD console
-cons25l1|cons25-iso8859|freebsd console w/iso 8859-1 chars,
+cons25l1|cons25-iso8859|FreeBSD console w/iso 8859-1 chars,
 	acsc=+\253\,\273-\030.\031`\201a\202f\207g\210i\247j\213k
 	     \214l\215m\216n\217o\220p\221q\222r\223s\224t\225u
 	     \226v\227w\230x\231y\232z\233~\237,
 	use=cons25w,
-cons25l1-m|cons25-iso-m|freebsd console w/iso 8859-1 chars (mono),
+cons25l1-m|cons25-iso-m|FreeBSD console w/iso 8859-1 chars (mono),
 	colors@, pairs@,
 	bold@, dim@, op@, rmul=\E[m, setab@, setaf@,
 	sgr=\E[0%?%p1%t;2;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;m,
 	smul=\E[4m, use=cons25l1,
-cons50l1|cons50-iso8859|freebsd console w/iso 8859-1 chars (50 lines),
+cons50l1|cons50-iso8859|FreeBSD console w/iso 8859-1 chars (50 lines),
 	lines#50, use=cons25l1,
-cons50l1-m|cons50-iso-m|freebsd console w/iso 8859-1 chars (50-line mono),
+cons50l1-m|cons50-iso-m|FreeBSD console w/iso 8859-1 chars (50-line mono),
 	lines#50, use=cons25l1-m,
-cons60l1|cons60-iso|freebsd console w/iso 8859-1 chars (60 lines),
+cons60l1|cons60-iso|FreeBSD console w/iso 8859-1 chars (60 lines),
 	lines#60, use=cons25l1,
-cons60l1-m|cons60-iso-m|freebsd console w/iso 8859-1 chars (60-line mono),
+cons60l1-m|cons60-iso-m|FreeBSD console w/iso 8859-1 chars (60-line mono),
 	lines#60, use=cons25l1-m,
 
+# vt - virtual terminal console driver
+#
 # Starting with FreeBSD 8, an alternative configuration for syscons is provided,
 # which is intended to be xterm-compatible.  See for example
 #	http://svnweb.freebsd.org/base/stable/8/sys/dev/syscons/
 # in particular scterm-teken.c
 #
+# Some of the documentation refers to this as "vt"; its proper name is "teken".
+#
+# The sc(4) manual page states that it is possible to switch between the two
+# by editing /boot/loader.conf, adding
+#	kern.vty=sc
+# Doing that does not change the default TERM variable.  That is hard-coded in
+# /etc/ttys, rather than deriving it from the kernel state.
+#
+# For FreeBSD 12 and 13:
+# ---------------------
+# In newer releases, it is no longer possible to boot into a configuration that
+# works with syscons.  According to efi(4),
+# "The vt(4) system console is automatically selected when booting via UEFI."
+# See FreeBSD #264226.
+#
+# FreeBSD 13 supports 64-bit machines which boot with UEFI:
+#	https://www.freebsd.org/platforms/
+# The i386 platform does not use UEFI (and modifying the loader configuration
+# does load sysconf); however because no updates (fixes) are available, most
+# developers will regard that as unsupported.
+#
+# With FreeBSD 13, even when syscons is loaded (e.g., with the i386 platform),
+# its function-keys are not configured.  Using
+#	vidcontrol -T cons25
+# repairs this.
+#
+# When teken is loaded, vidcontrol can switch at runtime between the
+# teken/cons25 function keys:
+#	vidcontrol -T cons25
+#	vidcontrol -T xterm
+# However due to a limitation in the implementation, only the first 12 function
+# keys are available.  The real syscons supports 48 function keys (using the
+# shift and control modifiers), while xterm supports more than twice as many.
+#
+# vidcontrol does not change the emulation. As a result, the quarter (17/73) of
+# non-function key capabilities which differ between syscons and teken are
+# unsupported in the UEFI-based configurations.
+#
+# tack:
+#	VT100 line-drawing does not work (UTF-8 equivalents do).
+#	Shift/control modifiers have no effect on special keys.
+#	Meta does not work.
+# vttest:
+#	supports REP (repeat).
+#	still does not support left/right margins
+#	SU/SD work, but not SL/SR
+#	alternate screen does not work
+#	ENQ/DA1 is unimplemented (the terminal does not identify itself)
+#	CPR, XCPR are unimplemented (i.e., vttest and resize are broken)
+#	implements X11 (original) xterm-mouse.
+# ncurses:
+#	UTF-8 line-drawing works, including some double/thick lines
+#
 # For FreeBSD 9 and 10:
 # --------------------
 # The /etc/ttys entries for console and other ttys are all configured to set
@@ -2089,18 +2175,51 @@ cons60l1-m|cons60-iso-m|freebsd console w/iso 8859-1 chars (60-line mono),
 #
 # Those are removed from this entry's acsc string to avoid confusion.
 # The resulting description provides correct line-drawing and function-keys -TD
-teken|syscons with teken,
-	bw@, mir, xenl,
+teken-2018|teken as of 2018,
+	bw@, mir, xenl, NQ,
 	acsc=0\333a\260f\370g\361h\261j\331k\277l\332m\300n\305q
 	     \304t\303u\264v\301w\302x\263y\363z\362~\371,
-	cvvis@, hpa=\E[%i%p1%dG, hts=\EH, kcub1=\E[D, kcud1=\E[B,
-	kcuf1=\E[C, kcuu1=\E[A, kdch1=\E[3~, kend=\E[F, kent=\r,
+	cvvis@, hpa=\E[%i%p1%dG, hts=\EH, kdch1=\E[3~, kent=\r,
 	kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf2=\EOQ,
 	kf3=\EOR, kf4=\EOS, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~,
-	kf8=\E[19~, kf9=\E[20~, khome=\E[H, kich1=\E[2~, knp=\E[6~,
-	kpp=\E[5~, rmir=\E[4l, smir=\E[4h, tbc=\E[3g,
-	u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?1;2c, u9=\E[c,
-	vpa=\E[%i%p1%dd, use=vt220+cvis, use=cons25,
+	kf8=\E[19~, kf9=\E[20~, kich1=\E[2~, knp=\E[6~, kpp=\E[5~,
+	rmir=\E[4l, smir=\E[4h, tbc=\E[3g, use=vt220+cvis,
+	use=cons25,
+
+teken-2022|teken as of 2022,
+	am, bce, eo, mir, msgr, npc, NQ,
+	cols#80, it#8, lines#25, ncv#21, U8#1,
+	bold=\E[1m, cr=\r, cub1=^H, dim=\E[30;1m, ech=\E[%p1%dX,
+	ind=\E[S, kent=\r, nel=\E[E, op=\E[x, rev=\E[7m, ri=\E[T,
+	rmso=\E[27m, rs2=\E[x\E[m\Ec,
+	sgr=\E[0%?%p1%t;2;7%;%?%p3%t;7%;%?%p5%t;30;1%;%?%p6%t;1%;m,
+	sgr0=\E[m, use=vt220+cvis, use=ecma+index,
+	use=ansi+arrows, use=ansi+csr, use=ansi+cup,
+	use=ansi+erase, use=ansi+idc, use=ansi+idl,
+	use=ansi+local, use=ansi+rca2, use=ansi+sgrso,
+	use=ansi+tabs, use=klone+color,
+
+teken-vt+fkeys|teken's xterm special keys,
+	kend=\E[F, kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~,
+	kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf5=\E[15~, kf6=\E[17~,
+	kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, khome=\E[H,
+	use=vt220+pcedit,
+
+teken-sc+fkeys|teken's syscons special keys,
+	kdch1=^?, kend=\E[F, kf1=\E[M, kf10=\E[V, kf11=\E[W,
+	kf12=\E[X, kf2=\E[N, kf3=\E[O, kf4=\E[P, kf5=\E[Q, kf6=\E[R,
+	kf7=\E[S, kf8=\E[T, kf9=\E[U, khome=\E[H, kich1=\E[L,
+	knp=\E[G, kpp=\E[I,
+
+teken-sc|teken imitating syscons,
+	use=teken-sc+fkeys, use=teken-2022,
+
+teken|teken-vt|teken imitating xterm,
+	xenl, use=teken-vt+fkeys, use=xterm+x11mouse,
+	use=teken-2022,
+
+teken-16color|teken using 16 colors,
+	use=ibm+16color, use=teken,
 
 #### 386BSD and BSD/OS Consoles
 #
@@ -2108,26 +2227,25 @@ teken|syscons with teken,
 # This was the original 386BSD console entry (I think).
 # Some places it's named oldpc3|oldibmpc3.
 # From: Alex R.N. Wetmore <aw2t@andrew.cmu.edu>
-origpc3|origibmpc3|IBM PC 386BSD Console,
+origpc3|origibmpc3|IBM PC 386BSD console,
 	OTbs, am, bw, eo, xon,
 	cols#80, lines#25,
 	acsc=j\331k\277l\332m\300n\305q\304t\303u\264v\301w\302x
 	     \263,
-	bold=\E[7m, clear=\Ec, cub1=^H, cud1=\E[B, cuf1=\E[C,
-	cup=\E[%i%p1%2d;%p2%2dH, cuu1=\E[A, ed=\E[J, el=\E[K,
-	home=\E[H, ind=\E[S, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C,
-	kcuu1=\E[A, khome=\E[Y, ri=\E[T, rmso=\E[1;0x\E[2;7x,
-	rmul=\E[1;0x\E[2;7x, sgr0=\E[m\E[1;0x\E[2;7x,
-	smso=\E[1;7x\E[2;0x, smul=\E[1;7x\E[2;0x,
+	bold=\E[7m, clear=\Ec, cub1=^H, cup=\E[%i%p1%2d;%p2%2dH,
+	ed=\E[J, el=\E[K, home=\E[H, ind=\E[S, kcub1=\E[D,
+	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, khome=\E[Y, ri=\E[T,
+	rmso=\E[1;0x\E[2;7x, rmul=\E[1;0x\E[2;7x,
+	sgr0=\E[m\E[1;0x\E[2;7x, smso=\E[1;7x\E[2;0x,
+	smul=\E[1;7x\E[2;0x, use=ansi+local1,
 
 # description of BSD/386 console emulator in version 1.0 (supplied by BSDI)
-oldpc3|oldibmpc3|old IBM PC BSD/386 Console,
+oldpc3|oldibmpc3|old IBM PC BSD/386 console,
 	OTbs, km,
 	lines#25,
 	bel=^G, bold=\E[=15F, cr=\r, cud1=\n, dim=\E[=8F, dl1=\E[M,
-	ht=^I, il1=\E[L, ind=\n, kbs=^H, kcub1=\E[D, kcud1=\E[B,
-	kcuf1=\E[C, kcuu1=\E[A, khome=\E[H, kich1=\E[L, kll=\E[F,
-	knp=\E[G, kpp=\E[I, nel=\r\n, sgr0=\E[=R,
+	ht=^I, il1=\E[L, ind=\n, kich1=\E[L, kll=\E[F, knp=\E[G,
+	kpp=\E[I, nel=\r\n, sgr0=\E[=R, use=ansi+arrows,
 
 # Description of BSD/OS console emulator in version 1.1, 2.0, 2.1
 # Note, the emulator supports many of the additional console features
@@ -2137,7 +2255,7 @@ oldpc3|oldibmpc3|old IBM PC BSD/386 Console,
 # "stty rows NN", e.g. to use 24 lines.
 # (Color support from Kevin Rosenberg <kevin@cyberport.com>, 2 May 1996)
 # Bug: The <op> capability resets attributes.
-bsdos-pc|IBM PC BSD/OS Console,
+bsdos-pc|IBM PC BSD/OS console,
 	sgr=\E[0;10%?%p1%t;7%;%?%p2%t;1%;%?%p3%t;7%;%?%p4%t;5%;%?%p6
 	    %t;1%;%?%p7%t;8%;%?%p9%t;11%;m,
 	use=bsdos-pc-nobold,
@@ -2148,29 +2266,27 @@ bsdos-pc-nobold|BSD/OS PC console w/o bold,
 bsdos-pc-m|bsdos-pc-mono|BSD/OS PC console mono,
 	OTbs, am, eo, km, xon,
 	cols#80, it#8, lines#25,
-	bel=^G, clear=\Ec, cr=\r, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H, ht=^I,
-	il=\E[%p1%dL, il1=\E[L, ind=\n, kbs=^H, kcub1=\E[D,
-	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, khome=\E[H, kich1=\E[L,
-	kll=\E[F, knp=\E[G, kpp=\E[I, nel=\r\n, rc=\E8, sc=\E7,
+	bel=^G, clear=\Ec, cr=\r, cub1=^H, cud1=\n,
+	cup=\E[%i%p1%d;%p2%dH, ed=\E[J, el=\E[K, home=\E[H, ht=^I,
+	ind=\n, kich1=\E[L, kll=\E[F, knp=\E[G, kpp=\E[I, nel=\r\n,
+	rc=\E8, sc=\E7,
 	sgr=\E[0;10%?%p1%t;7%;%?%p3%t;7%;%?%p4%t;5%;%?%p6%t;1%;%?%p7
 	    %t;8%;%?%p9%t;11%;m%?%p5%t\E[=8F%;,
+	use=ansi+arrows, use=ansi+idl, use=ansi+local,
 	use=klone+sgr8,
 
 # Old names for BSD/OS PC console used in releases before 4.1.
-pc3|BSD/OS on the PC Console,
+pc3|BSD/OS on the PC console,
 	use=bsdos-pc-nobold,
-ibmpc3|pc3-bold|BSD/OS on the PC Console with bold instead of underline,
+ibmpc3|pc3-bold|BSD/OS on the PC console with bold instead of underline,
 	use=bsdos-pc,
 
 # BSD/OS on the SPARC
-bsdos-sparc|Sun SPARC BSD/OS Console,
+bsdos-sparc|Sun SPARC BSD/OS console,
 	use=sun,
 
 # BSD/OS on the PowerPC
-bsdos-ppc|PowerPC BSD/OS Console,
+bsdos-ppc|PowerPC BSD/OS console,
 	use=bsdos-pc,
 
 
@@ -2178,8 +2294,8 @@ bsdos-ppc|PowerPC BSD/OS Console,
 # (<acsc>/<rmacs>/<smacs> capabilities aren't in DEC's official entry -- esr)
 #
 # Actually (TD pointed this out at the time the acsc string was added):
-# vt52 shouldn't define full acsc since most of the cells don't match.
-# see vt100 manual page A-31.  This is the list that does match:
+# VT52 shouldn't define full acsc since most of the cells don't match.
+# see VT100 manual page A-31.  This is the list that does match:
 #	f degree
 #	g plus/minus
 #	h right-arrow
@@ -2189,28 +2305,29 @@ bsdos-ppc|PowerPC BSD/OS Console,
 #	q scan-5
 #	s scan-7
 # The line-drawing happens to work in several terminal emulators, but should
-# not be used as a guide to the capabilities of the vt52.  Note in particular
-# that vt52 does not support line-drawing characters (the scan-X values refer
+# not be used as a guide to the capabilities of the VT52.  Note in particular
+# that VT52 does not support line-drawing characters (the scan-X values refer
 # to a crude plotting feature) -TD
-vt52|dec vt52,
-	OTbs,
-	it#8, lines#24,
-	acsc=+h.k0affggolpnqprrss, home=\EH, kbs=^H, nel=\r\n,
-	ri=\EI, rmacs=\EG, rmkx=\E>, smacs=\EF, smkx=\E=, u8=\E/[KL],
-	use=vt50h,
+vt52|DEC VT52,
+	lines#24,
+	acsc=+h.k0affggolpnqprrss, rmacs=\EG, rmkx=\E>,
+	smacs=\EF, smkx=\E=, u8=\E/[KL], use=vt50h, use=vt52-basic,
 
 # This is more likely the "vt52" that you would see in emulation, i.e., no
 # keypad, no graphics.
-vt52-basic|vt52 for emulators,
+vt52-basic|VT52 for emulators,
 	cols#80, it#8, lines#24,
 	bel=^G, clear=\EH\EJ, cr=\r, cub1=\ED, cud1=\EB, cuf1=\EC,
 	cup=\EY%p1%' '%+%c%p2%' '%+%c, cuu1=\EA, ed=\EJ, el=\EK,
-	home=\EH, ht=^I, ind=\n, kbs=^H, kcub1=\ED, kcud1=\EB,
-	kcuf1=\EC, kcuu1=\EA, nel=\r\n, ri=\EI,
+	home=\EH, ht=^I, ind=\n, kbs=^H, nel=\r\n, ri=\EI,
+	use=vt52+arrows,
+
+vt52+arrows|cursor keys for VT52,
+	kcub1=\ED, kcud1=\EB, kcuf1=\EC, kcuu1=\EA,
 
 #### DEC VT100 and compatibles
 #
-# DEC terminals from the vt100 forward are collected here. Older DEC terminals
+# DEC terminals from the VT100 forward are collected here. Older DEC terminals
 # and micro consoles can be found in the `obsolete' section.  More details on
 # the relationship between the VT100 and ANSI X3.64/ISO 6429/ECMA-48 may be
 # found near the end of this file.
@@ -2319,12 +2436,12 @@ vt52-basic|vt52 for emulators,
 # terminfo guidelines.  That is a compromise used to assign the remaining
 # keys on the keypad to kf5-kf0, used on older systems with legacy termcap
 # support:
-vt100+keypad|dec vt100 numeric keypad no fkeys,
+vt100+keypad|DEC VT100 numeric keypad no fkeys,
 	ka1=\EOq, ka3=\EOs, kb2=\EOr, kc1=\EOp, kc3=\EOn,
-vt100+pfkeys|dec vt100 numeric keypad,
+vt100+pfkeys|DEC VT100 numeric keypad (kf1-kf4),
 	kent=\EOM, kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS,
 	use=vt100+keypad,
-vt100+fnkeys|dec vt100 numeric keypad,
+vt100+fnkeys|DEC VT100 numeric keypad (kf0-kf10),
 	kf0=\EOy, kf10=\EOx, kf5=\EOt, kf6=\EOu, kf7=\EOv, kf8=\EOl,
 	kf9=\EOw, use=vt100+pfkeys,
 #
@@ -2349,14 +2466,13 @@ vt100+fnkeys|dec vt100 numeric keypad,
 #  |        $Op        |  $On    |         |
 #  |___________________|_________|_kent_@8_|
 #
-vt220+keypad|dec vt220 numeric keypad,
-	ka1=\EOw, ka3=\EOy, kb2=\EOu, kc1=\EOq, kc3=\EOs, kent=\EOM,
-	kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, ka2=\EOx, kb1=\EOt,
-	kb3=\EOv, kc2=\EOr,
+vt220+keypad|DEC VT220 numeric keypad,
+	ka1=\EOw, ka3=\EOy, kb2=\EOu, kc1=\EOq, kc3=\EOs, ka2=\EOx,
+	kb1=\EOt, kb3=\EOv, kc2=\EOr, use=vt100+pfkeys,
 #
-vt100+enq|ncurses extension for vt100-style ENQ,
+vt100+enq|ncurses extension for VT100-style ENQ,
 	u8=\E[?1;2c, use=ansi+enq,
-vt102+enq|ncurses extension for vt102-style ENQ,
+vt102+enq|ncurses extension for VT102-style ENQ,
 	u8=\E[?6c, use=ansi+enq,
 #
 # And here, for those of you with orphaned VT100s lacking documentation, is
@@ -2393,26 +2509,25 @@ vt102+enq|ncurses extension for vt102-style ENQ,
 #	INTERLACE_OFF
 #
 # (vt100: I added <rmam>/<smam> based on the init string, also <OTbs>. -- esr)
-vt100|vt100-am|dec vt100 (w/advanced video),
-	OTbs, mc5i, xenl, xon,
+vt100|vt100-am|DEC VT100 (w/advanced video),
+	OTbs, xenl, xon,
 	vt#3,
-	csr=\E[%i%p1%d;%p2%dr, kcub1=\EOD, kcud1=\EOB,
-	kcuf1=\EOC, kcuu1=\EOA, lf1=pf1, lf2=pf2, lf3=pf3, lf4=pf4,
-	mc0=\E[0i, mc4=\E[4i, mc5=\E[5i, rc=\E8, rmam=\E[?7l,
+	kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, lf1=pf1,
+	lf2=pf2, lf3=pf3, lf4=pf4, mc0=\E[0i, rmam=\E[?7l,
 	rmkx=\E[?1l\E>, rs2=\E<\E>\E[?3;4;5l\E[?7;8h\E[r,
-	sc=\E7,
 	sgr=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5
 	    %;m%?%p9%t\016%e\017%;$<2>,
 	smam=\E[?7h, smkx=\E[?1h\E=, smso=\E[7m$<2>,
-	use=vt100+4bsd, use=vt100+fnkeys,
-vt100+4bsd|dec vt100 from 4.0BSD,
+	use=ansi+csr, use=ansi+pp, use=decid+cpr, use=vt100+4bsd,
+	use=vt100+fnkeys,
+
+vt100+4bsd|DEC VT100 from 4.0BSD,
 	am, msgr,
 	cols#80, it#8, lines#24,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
 	bel=^G, blink=\E[5m$<2>, bold=\E[1m$<2>,
-	clear=\E[H\E[J$<50>, cr=\r, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C$<2>,
-	cup=\E[%i%p1%d;%p2%dH$<5>, cuu=\E[%p1%dA,
+	clear=\E[H\E[J$<50>, cr=\r, cub1=^H, cud1=\n,
+	cuf1=\E[C$<2>, cup=\E[%i%p1%d;%p2%dH$<5>,
 	cuu1=\E[A$<2>, ed=\E[J$<50>, el=\E[K$<3>, el1=\E[1K$<3>,
 	enacs=\E(B\E)0, home=\E[H, ht=^I, hts=\EH, ind=\n, kbs=^H,
 	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
@@ -2421,32 +2536,33 @@ vt100+4bsd|dec vt100 from 4.0BSD,
 	sgr=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5
 	    %;m%?%p9%t\016%e\017%;$<2>,
 	sgr0=\E[m\017$<2>, smacs=^N, smso=\E[1;7m$<2>,
-	smul=\E[4m$<2>, tbc=\E[3g,
-vt100nam|vt100-nam|vt100 no automargins,
+	smul=\E[4m$<2>, tbc=\E[3g, use=ansi+local,
+
+vt100nam|vt100-nam|VT100 no automargins,
 	am@, xenl@,
 	rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7l\E[?8h, use=vt100-am,
-vt100-vb|dec vt100 (w/advanced video) & no beep,
+vt100-vb|DEC VT100 (w/advanced video) & no beep,
 	bel@, flash=\E[?5h$<100/>\E[?5l, use=vt100,
 
-# Ordinary vt100 in 132 column ("wide") mode.
-vt100-w|vt100-w-am|dec vt100 132 cols (w/advanced video),
+# Ordinary VT100 in 132 column ("wide") mode.
+vt100-w|vt100-w-am|DEC VT100 132 cols (w/advanced video),
 	cols#132, lines#24,
 	rs2=\E>\E[?3h\E[?4l\E[?5l\E[?8h, use=vt100-am,
-vt100-w-nam|vt100-nam-w|dec vt100 132 cols (w/advanced video no automargin),
+vt100-w-nam|vt100-nam-w|DEC VT100 132 cols (w/advanced video no automargin),
 	cols#132, lines#14, vt@,
 	rs2=\E>\E[?3h\E[?4l\E[?5l\E[?8h, use=vt100-nam,
 
-# vt100 with no advanced video.
-vt100-nav|vt100 without advanced video option,
+# VT100 with no advanced video.
+vt100-nav|VT100 without advanced video option,
 	xmc#1,
 	blink@, bold@, rev@, rmso=\E[m, rmul@, sgr@, sgr0@, smso=\E[7m,
 	smul@, use=vt100,
-vt100-nav-w|vt100-w-nav|dec vt100 132 cols 14 lines (no advanced video option),
+vt100-nav-w|vt100-w-nav|DEC VT100 132 cols 14 lines (no advanced video option),
 	cols#132, lines#14, use=vt100-nav,
 
-# vt100 with one of the 24 lines used as a status line.
+# VT100 with one of the 24 lines used as a status line.
 # We put the status line on the top.
-vt100-s|vt100-s-top|vt100-top-s|vt100 for use with top sysline,
+vt100-s|vt100-s-top|vt100-top-s|VT100 for use with top sysline,
 	eslok, hs,
 	lines#23,
 	clear=\E[2;1H\E[J$<50>, csr=\E[%i%i%p1%d;%p2%dr,
@@ -2456,19 +2572,19 @@ vt100-s|vt100-s-top|vt100-top-s|vt100 for use with top sysline,
 
 # Status line at bottom.
 # Clearing the screen will clobber status line.
-vt100-s-bot|vt100-bot-s|vt100 for use with bottom sysline,
+vt100-s-bot|vt100-bot-s|VT100 for use with bottom sysline,
 	eslok, hs,
 	lines#23,
 	dsl=\E7\E[1;24r\E8, fsl=\E8, is2=\E[1;23r\E[23;1H,
 	tsl=\E7\E[24;%p1%dH\E[1K, use=vt100-am,
 
-# Most of the `vt100' emulators out there actually emulate a vt102
+# Most of the `vt100' emulators out there actually emulate a VT102
 # This entry (or vt102-nsgr) is probably the right thing to use for
 # these.
-vt102|dec vt102,
+vt102|DEC VT102,
 	dch1=\E[P, dl1=\E[M, il1=\E[L, rmir=\E[4l, smir=\E[4h,
 	use=vt100,
-vt102-w|dec vt102 in wide mode,
+vt102-w|DEC VT102 in wide mode,
 	cols#132,
 	rs3=\E[?3h, use=vt102,
 
@@ -2480,33 +2596,32 @@ vt102-w|dec vt102 in wide mode,
 # ACS support working, at the cost of making multiple-highlight changes
 # slightly more expensive.
 # From: Eric S. Raymond <esr@snark.thyrsus.com> July 22 1995
-vt102-nsgr|vt102 no sgr (use if you see snowflakes after highlight changes),
+vt102-nsgr|VT102 no sgr (use if you see snowflakes after highlight changes),
 	sgr@, sgr0=\E[m, use=vt102,
 
 # VT125 Graphics CRT.  Clear screen also erases graphics
-# Some vt125's came configured with vt102 support.
-vt125|vt125 graphics terminal,
+# Some VT125's came configured with VT102 support.
+vt125|VT125 graphics terminal,
 	mir,
 	clear=\E[H\E[2J\EPpS(E)\E\\$<50>, use=vt100,
 
 # This isn't a DEC entry, it came from University of Wisconsin.
 # (vt131: I added <rmam>/<smam> based on the init string, also <OTbs> -- esr)
-vt131|dec vt131,
+vt131|DEC VT131,
 	OTbs, am, xenl,
 	cols#80, it#8, lines#24, vt#3,
 	bel=^G, blink=\E[5m$<2/>, bold=\E[1m$<2/>,
-	clear=\E[;H\E[2J$<50/>, cr=\r, csr=\E[%i%p1%d;%p2%dr,
-	cub1=^H, cud1=\n, cuf1=\E[C$<2/>,
-	cup=\E[%i%p1%d;%p2%dH$<5/>, cuu1=\E[A$<2/>,
-	ed=\E[J$<50/>, el=\E[K$<3/>, home=\E[H, ht=^I,
-	is2=\E[1;24r\E[24;1H, kbs=^H, kcub1=\EOD, kcud1=\EOB,
-	kcuf1=\EOC, kcuu1=\EOA, kf1=\EOP, kf2=\EOQ, kf3=\EOR,
-	kf4=\EOS, nel=\r\n, rc=\E8, rev=\E[7m$<2/>, ri=\EM$<5/>,
+	clear=\E[;H\E[2J$<50/>, cr=\r, cub1=^H, cud1=\n,
+	cuf1=\E[C$<2/>, cup=\E[%i%p1%d;%p2%dH$<5/>,
+	cuu1=\E[A$<2/>, ed=\E[J$<50/>, el=\E[K$<3/>, home=\E[H,
+	ht=^I, is2=\E[1;24r\E[24;1H, kbs=^H, kcub1=\EOD,
+	kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kf1=\EOP, kf2=\EOQ,
+	kf3=\EOR, kf4=\EOS, nel=\r\n, rev=\E[7m$<2/>, ri=\EM$<5/>,
 	rmam=\E[?7h, rmkx=\E[?1l\E>, rmso=\E[m$<2/>,
 	rmul=\E[m$<2/>,
-	rs1=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, sc=\E7,
+	rs1=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h,
 	sgr0=\E[m$<2/>, smam=\E[?7h, smkx=\E[?1h\E=,
-	smso=\E[7m$<2/>, smul=\E[4m$<2/>,
+	smso=\E[7m$<2/>, smul=\E[4m$<2/>, use=ansi+csr,
 
 # vt132 - like vt100 but slower and has ins/del line and such.
 # I'm told that <smir>/<rmir> are backwards in the terminal from the
@@ -2514,7 +2629,7 @@ vt131|dec vt131,
 # terminal. I've never actually used a vt132 myself, so this
 # is untested.
 #
-vt132|DEC vt132,
+vt132|DEC VT132,
 	xenl,
 	dch1=\E[P$<7>, dl1=\E[M$<99>, il1=\E[L$<99>, ind=\n$<30>,
 	ip=$<7>, rmir=\E[4h, smir=\E[4l, use=vt100,
@@ -2525,29 +2640,29 @@ vt132|DEC vt132,
 # PF1--PF4 are used as F1--F4.
 #
 # added msgr -TD
-vt220-old|vt200-old|DEC VT220 in vt100 emulation mode,
+vt220-old|vt200-old|DEC VT220 in VT100 emulation mode,
 	OTbs, OTpt, am, mir, msgr, xenl, xon,
 	cols#80, lines#24, vt#3,
 	OTnl=\n,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
 	bel=^G, blink=\E[5m$<2>, bold=\E[1m$<2>,
-	clear=\E[H\E[2J$<50>, cr=\r, csr=\E[%i%p1%d;%p2%dr,
-	cub1=^H, cud1=\E[B, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH$<10>, cuu1=\E[A, dch1=\E[P,
-	dl1=\E[M, ed=\E[J$<50>, el=\E[K$<3>, home=\E[H, ht=^I,
-	if=/usr/share/tabset/vt100, il1=\E[L, ind=\ED$<20/>,
-	is2=\E[1;24r\E[24;1H, kbs=^H, kcub1=\E[D, kcud1=\E[B,
-	kcuf1=\E[C, kcuu1=\E[A, kf1=\EOP, kf10=\E[29~, kf2=\EOQ,
+	clear=\E[H\E[2J$<50>, cr=\r, cub1=^H,
+	cup=\E[%i%p1%d;%p2%dH$<10>, dch1=\E[P, ed=\E[J$<50>,
+	el=\E[K$<3>, home=\E[H, ht=^I,
+	if=/usr/share/tabset/vt100, ind=\ED$<20/>,
+	is2=\E[1;24r\E[24;1H, kf1=\EOP, kf10=\E[29~, kf2=\EOQ,
 	kf3=\EOR, kf4=\EOS, kf5=\E[17~, kf6=\E[18~, kf7=\E[19~,
-	kf8=\E[20~, kf9=\E[21~, kich1=\E[2~, rc=\E8, rev=\E[7m$<2>,
-	rf=/usr/share/tabset/vt100, ri=\EM$<14/>,
-	rmacs=\E(B$<4>, rmam=\E[?7l, rmir=\E[4l, rmso=\E[27m,
-	rmul=\E[24m, rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h,
-	sc=\E7,
+	kf8=\E[20~, kf9=\E[21~, khome=\E[1~, kich1=\E[2~,
+	rev=\E[7m$<2>, rf=/usr/share/tabset/vt100,
+	ri=\EM$<14/>, rmacs=\E(B$<4>, rmam=\E[?7l, rmir=\E[4l,
+	rmso=\E[27m, rmul=\E[24m,
+	rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h,
 	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p4%t;5%;%?%p1%p3%|%t;7%;m%?
 	    %p9%t\E(0%e\E(B%;$<2>,
 	sgr0=\E[m$<2>, smacs=\E(0$<2>, smam=\E[?7h, smir=\E[4h,
-	smso=\E[7m, smul=\E[4m, use=vt220+pcedit, use=vt220+cvis,
+	smso=\E[7m, smul=\E[4m, use=ansi+arrows, use=ansi+csr,
+	use=ansi+idl1, use=ansi+local1, use=vt220+pcedit,
+	use=vt220+cvis,
 
 # Here's a picture of the Sun/PC editing keypad:
 #	+--------+--------+--------+
@@ -2566,10 +2681,10 @@ vt220-old|vt200-old|DEC VT220 in vt100 emulation mode,
 #	Remove		Delete
 #	Find		Home
 #	Select		End
-vt220+pcedit|editing-keypad for vt220 using PC keyboard,
+vt220+pcedit|editing-keypad for VT220 using PC keyboard,
 	kdch1=\E[3~, kend=\E[4~, khome=\E[1~, kich1=\E[2~,
 	knp=\E[6~, kpp=\E[5~,
-vt220+vtedit|editing-keypad for vt220 using DEC keyboard,
+vt220+vtedit|editing-keypad for VT220 using DEC keyboard,
 	kdch1=\E[3~, kfnd=\E[1~, kich1=\E[2~, knp=\E[6~, kpp=\E[5~,
 	kslt=\E[4~,
 
@@ -2590,35 +2705,32 @@ vt220-base|DEC VT220 as emulated,
 	OTbs, am, mir, msgr, xenl, xon,
 	cols#80, it#8, lines#24, vt#3,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[J, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M,
-	ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K, enacs=\E)0,
-	flash=\E[?5h$<200/>\E[?5l, home=\E[H, ht=^I, hts=\EH,
-	ich=\E[%p1%d@, if=/usr/share/tabset/vt100,
-	il=\E[%p1%dL, il1=\E[L, ind=\ED,
+	bel=^G, blink=\E[5m, bold=\E[1m, cr=\r, cub1=^H, cud1=\n,
+	dch=\E[%p1%dP, dch1=\E[P, ech=\E[%p1%dX, el1=\E[1K,
+	enacs=\E)0, flash=\E[?5h$<200/>\E[?5l, ht=^I, hts=\EH,
+	ich=\E[%p1%d@, if=/usr/share/tabset/vt100, ind=\ED,
 	is2=\E[?7h\E[>\E[?1l\E F\E[?4l, kbs=^H, kcub1=\E[D,
-	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kdch1=\E[3~, kf1=\EOP,
-	kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[25~,
-	kf14=\E[26~, kf17=\E[31~, kf18=\E[32~, kf19=\E[33~,
-	kf2=\EOQ, kf20=\E[34~, kf3=\EOR, kf4=\EOS, kf6=\E[17~,
-	kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, khlp=\E[28~,
-	krdo=\E[29~, lf1=pf1, lf2=pf2, lf3=pf3, lf4=pf4, nel=\EE,
-	rc=\E8, rev=\E[7m, ri=\EM, rmacs=\E(B$<4>, rmam=\E[?7l,
-	rmir=\E[4l, rmso=\E[27m, rmul=\E[24m, rs1=\E[?3l, sc=\E7,
+	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kf1=\EOP, kf10=\E[21~,
+	kf11=\E[23~, kf12=\E[24~, kf13=\E[25~, kf14=\E[26~,
+	kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, kf2=\EOQ,
+	kf20=\E[34~, kf3=\EOR, kf4=\EOS, kf6=\E[17~, kf7=\E[18~,
+	kf8=\E[19~, kf9=\E[20~, khlp=\E[28~, krdo=\E[29~, lf1=pf1,
+	lf2=pf2, lf3=pf3, lf4=pf4, nel=\EE, rev=\E[7m, ri=\EM,
+	rmacs=\E(B$<4>, rmam=\E[?7l, rmir=\E[4l, rmso=\E[27m,
+	rmul=\E[24m, rs1=\E[?3l,
 	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p4%t;5%;%?%p1%p3%|%t;7%;m%?
 	    %p9%t\E(0%e\E(B%;$<2>,
 	sgr0=\E[m\E(B, smacs=\E(0$<2>, smam=\E[?7h, smir=\E[4h,
-	smso=\E[7m, smul=\E[4m, tbc=\E[3g, use=vt220+vtedit,
-	use=ansi+pp, use=ansi+enq,
-vt220|vt200|dec vt220,
+	smso=\E[7m, smul=\E[4m, tbc=\E[3g, use=ansi+csr,
+	use=ansi+cup, use=ansi+pp, use=ansi+enq, use=ansi+erase,
+	use=ansi+idl, use=ansi+local, use=vt220+vtedit,
+
+vt220|vt200|DEC VT220,
 	use=vt220+cvis, use=vt220-base,
-vt220-w|vt200-w|DEC vt220 in wide mode,
+vt220-w|vt200-w|DEC VT220 in wide mode,
 	cols#132,
 	rs3=\E[?3h, use=vt220,
-vt220-8bit|vt220-8|vt200-8bit|vt200-8|dec vt220/200 in 8-bit mode,
+vt220-8bit|vt220-8|vt200-8bit|vt200-8|DEC VT220/200 in 8-bit mode,
 	OTbs, am, mc5i, mir, msgr, xenl, xon,
 	cols#80, it#8, lines#24, vt#3,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
@@ -2649,62 +2761,61 @@ vt220-8bit|vt220-8|vt200-8bit|vt200-8|dec vt220/200 in 8-bit mode,
 	smso=\2337m, smul=\2334m, tbc=\2333g, use=vt220+cvis8,
 
 # vt220d:
-# This vt220 description regards F6--F10 as the second block of function keys
+# This VT220 description regards F6--F10 as the second block of function keys
 # at the top of the keyboard.  This mapping follows the description given
 # in the VT220 Programmer Reference Manual and agrees with the labeling
-# on some terminals that emulate the vt220.  There is no support for an F5.
+# on some terminals that emulate the VT220.  There is no support for an F5.
 # See vt220 for an alternate mapping.
 #
-vt220d|DEC VT220 in vt100 mode with DEC function key labeling,
+vt220d|DEC VT220 in VT100 mode with DEC function key labeling,
 	kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[25~,
 	kf14=\E[26~, kf15=\E[28~, kf16=\E[29~, kf17=\E[31~,
 	kf18=\E[32~, kf19=\E[33~, kf20=\E[34~, kf5@, kf6=\E[17~,
 	kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, use=vt220-old,
 
-vt220-nam|v200-nam|VT220 in vt100 mode with no auto margins,
+vt220-nam|v200-nam|VT220 in VT100 mode with no auto margins,
 	am@,
 	rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7l\E[?8h, use=vt220,
 
 # vt220 termcap written Tue Oct 25 20:41:10 1988 by Alex Latzko
 # (not an official DEC entry!)
-# The problem with real vt220 terminals is they don't send escapes when in
-# in vt220 mode.  This can be gotten around two ways.  1> don't send
-# escapes or 2> put the vt220 into vt100 mode and use all the nifty
-# features of vt100 advanced video which it then has.
+# The problem with real VT220 terminals is they don't send escapes when in
+# in VT220 mode.  This can be gotten around two ways.  1> don't send
+# escapes or 2> put the VT220 into VT100 mode and use all the nifty
+# features of VT100 advanced video which it then has.
 #
-# This entry takes the view of putting a vt220 into vt100 mode so
+# This entry takes the view of putting a VT220 into VT100 mode so
 # you can use the escape key in emacs and everything else which needs it.
 #
 # You probably don't want to use this on a VMS machine since VMS will think
-# it has a vt220 and will get fouled up coming out of emacs
+# it has a VT220 and will get fouled up coming out of emacs
 #
 # From: Alexander Latzko <latzko@marsenius.rutgers.edu>, 30 Dec 1996
 # (Added vt100 <rc>,<sc> to quiet a tic warning -- esr)
 # added msgr -TD
-vt200-js|vt220-js|dec vt200 series with jump scroll,
+vt200-js|vt220-js|DEC VT200 series with jump scroll,
 	am, msgr,
 	cols#80,
-	bel=^G, clear=\E[H\E[J, cr=\r, csr=\E[%i%p1%d;%p2%dr,
-	cub1=^H, cud1=\n, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
-	cuu1=\E[A, dch1=\E[P, dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H,
-	ht=^I, il1=\E[L, ind=\ED,
+	bel=^G, cr=\r, cub1=^H, cud1=\n, cuf1=\E[C,
+	cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, dch1=\E[P, dl1=\E[M,
+	home=\E[H, ht=^I, il1=\E[L, ind=\ED,
 	is2=\E[61"p\E[H\E[?3l\E[?4l\E[?1h\E[?5l\E[?6l\E[?7h\E[?8h\E[
 	    ?25h\E>\E[m,
 	kbs=^H, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
-	kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, nel=\r\ED, rc=\E8,
+	kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, nel=\r\ED,
 	rf=/usr/share/tabset/vt100, ri=\EM, rmdc=, rmir=\E[4l,
 	rmkx=\E[?1l\E>, rmso=\E[27m$<5/>, rmul=\E[24m,
-	rs1=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, sc=\E7, smdc=,
+	rs1=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, smdc=,
 	smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m$<5/>, smul=\E[4m,
-	use=vt220+cvis,
+	use=ansi+csr, use=ansi+erase, use=vt220+cvis,
 
-# This was DEC's vt320.  Use the purpose-built one below instead
-#vt320|DEC VT320 in vt100 emulation mode,
+# This was DEC's VT320.  Use the purpose-built one below instead
+#vt320|DEC VT320 in VT100 emulation mode,
 #	use=vt220,
 
 # Use v320n for SCO's LYRIX.  Otherwise, use Adam Thompson's vt320-nam.
 #
-vt320nam|v320n|DEC VT320 in vt100 emul. mode with NO AUTO WRAP mode,
+vt320nam|v320n|DEC VT320 in VT100 emul. mode with NO AUTO WRAP mode,
 	am@,
 	rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7l\E[?8h,
 	use=vt220-base,
@@ -2722,46 +2833,43 @@ vt320nam|v320n|DEC VT320 in vt100 emul. mode with NO AUTO WRAP mode,
 # to SMASH the 1k-barrier...
 # From: Adam Thompson <athompso@pangea.ca> Sept 10 1995
 # (vt320: uncommented <fsl> --esr)
-vt320|vt300|dec vt320 7 bit terminal,
-	am, hs, mir, msgr, xenl,
+vt320|vt300|DEC VT320 7 bit terminal,
+	am, mir, msgr, xenl,
 	cols#80, lines#24, wsl#80,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
 	bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[2J, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M,
-	ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K, home=\E[H, ht=^I,
-	hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L, ind=\ED,
+	cub1=^H, cud1=\n, cup=\E[%i%p1%d;%p2%dH, dch=\E[%p1%dP,
+	dch1=\E[P, ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K,
+	home=\E[H, ht=^I, hts=\EH, ich=\E[%p1%d@, ind=\ED,
 	is2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h\E[1;24r\E[24;1H,
-	kbs=^?, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
-	kdch1=\E[3~, kel=\E[4~, kf10=\E[21~, kf11=\E[23~,
+	kbs=^?, kdch1=\E[3~, kel=\E[4~, kf10=\E[21~, kf11=\E[23~,
 	kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, kf15=\E[28~,
 	kf16=\E[29~, kf17=\E[31~, kf18=\E[32~, kf19=\E[33~,
 	kf20=\E[34~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~,
 	kf9=\E[20~, khome=\E[1~, kich1=\E[2~, knp=\E[6~, knxt=^I,
-	kpp=\E[5~, kprv=\E[Z, kslt=\E[4~, nel=\EE, rc=\E8, rev=\E[7m,
+	kpp=\E[5~, kprv=\E[Z, kslt=\E[4~, nel=\EE, rev=\E[7m,
 	rf=/usr/share/tabset/vt300, ri=\EM, rmacs=\E(B,
 	rmam=\E[?7l, rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[m,
 	rmul=\E[m,
 	rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h\E[1;24r\E[24;1H,
-	sc=\E7,
 	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p4%t;5%;%?%p1%p3%|%t;7%;m%?
 	    %p9%t\E(0%e\E(B%;$<2>,
 	sgr0=\E[m\E(B, smacs=\E(0, smam=\E[?7h, smir=\E[4h,
 	smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g,
-	use=dec+pp, use=vt220+cvis, use=vt220+keypad, use=dec+sl,
-	use=ansi+enq,
-vt320-nam|vt300-nam|dec vt320 7 bit terminal with no am to make SAS happy,
+	use=ansi+apparrows, use=ansi+csr, use=ansi+enq,
+	use=ansi+idl, use=ansi+local, use=dec+pp, use=vt220+cvis,
+	use=vt220+keypad, use=dec+sl,
+
+vt320-nam|vt300-nam|DEC VT320 7 bit terminal with no am to make SAS happy,
 	am@,
 	is2=\E>\E[?3l\E[?4l\E[?5l\E[?7l\E[?8h\E[1;24r\E[24;1H,
 	rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7l\E[?8h\E[1;24r\E[24;1H, use=vt320,
 # We have to init 132-col mode, not 80-col mode.
-vt320-w|vt300-w|dec vt320 wide 7 bit terminal,
+vt320-w|vt300-w|DEC VT320 wide 7 bit terminal,
 	cols#132, wsl#132,
 	is2=\E>\E[?3h\E[?4l\E[?5l\E[?7h\E[?8h\E[1;24r\E[24;1H,
 	rs2=\E>\E[?3h\E[?4l\E[?5l\E[?7h\E[?8h\E[1;24r\E[24;1H, use=vt320,
-vt320-w-nam|vt300-w-nam|dec vt320 wide 7 bit terminal with no am,
+vt320-w-nam|vt300-w-nam|DEC VT320 wide 7 bit terminal with no am,
 	am@,
 	is2=\E>\E[?3h\E[?4l\E[?5l\E[?7l\E[?8h\E[1;24r\E[24;1H,
 	rs2=\E>\E[?3h\E[?4l\E[?5l\E[?7l\E[?8h\E[1;24r\E[24;1H, use=vt320-w,
@@ -2771,7 +2879,7 @@ vt320-w-nam|vt300-w-nam|dec vt320 wide 7 bit terminal with no am,
 #   host writable status line, yet another different DRCS matrix size,
 #   and such, but they add the DEC Technical character set, Multiple text
 #   pages, selectable length pages, and the like.  The difference between
-#   the vt330 and vt340 is that the former has only 2 planes and a monochrome
+#   the VT330 and VT340 is that the former has only 2 planes and a monochrome
 #   monitor, the latter has 4 planes and a color monitor.  These terminals
 #   support VT131 and ANSI block mode, but as with much of these things,
 #   termcap/terminfo doesn't deal with these features.
@@ -2786,42 +2894,42 @@ vt320-w-nam|vt300-w-nam|dec vt320 wide 7 bit terminal with no am,
 # From: Daniel Glasser <dag@persoft.persoft.com>, 13 Oct 1993
 # (vt340: string capability "sb=\E[M" corrected to "sr";
 # also, added <rmam>/<smam> based on the init string -- esr)
-vt340|dec-vt340|vt330|dec-vt330|dec vt340 graphics terminal with 24 line page,
+vt340|dec-vt340|vt330|dec-vt330|DEC VT340 graphics terminal with 24 line page,
 	am, eslok, hs, mir, msgr, xenl, xon,
 	cols#80, it#8, lines#24, vt#3,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	blink=\E[5m, bold=\E[1m, clear=\E[H\E[J, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M,
-	dsl=\E[2$~\r\E[1$}\E[K\E[$}, ed=\E[J, el=\E[K,
+	blink=\E[5m, bold=\E[1m, cr=\r, cub1=^H, cud1=\n,
+	cup=\E[%i%p1%d;%p2%dH, dch=\E[%p1%dP, dch1=\E[P,
+	dsl=\E[2$~\r\E[1$}\E[K\E[$},
 	flash=\E[?5h$<200/>\E[?5l, fsl=\E[$}, home=\E[H, ht=^I,
-	hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L, ind=\ED,
+	hts=\EH, ich=\E[%p1%d@, ind=\ED,
 	is2=\E<\E\sF\E>\E[?1h\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h\E[1;24r
 	    \E[24;1H,
 	kbs=^H, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
 	kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf6=\E[17~,
 	kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, lf1=pf1, lf2=pf2,
-	lf3=pf3, lf4=pf4, nel=\r\ED, rc=\E8, rev=\E[7m,
+	lf3=pf3, lf4=pf4, nel=\r\ED, rev=\E[7m,
 	rf=/usr/share/tabset/vt300, ri=\EM, rmacs=\E(B,
 	rmam=\E[?7l, rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[27m,
-	rmul=\E[24m, rs1=\E[?3l, sc=\E7,
+	rmul=\E[24m, rs1=\E[?3l,
 	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p4%t;5%;%?%p1%p3%|%t;7%;m%?
 	    %p9%t\E(0%e\E(B%;$<2>,
 	sgr0=\E[m\E(B, smacs=\E(0, smam=\E[?7h, smir=\E[4h,
 	smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g,
-	tsl=\E[2$~\E[1$}\E[1;%dH, use=vt220+cvis,
+	tsl=\E[2$~\E[1$}\E[1;%dH, use=ansi+csr, use=ansi+erase,
+	use=ansi+idl, use=ansi+local, use=vt220+cvis,
 
 # Left/right margins are supported in xterm since patch #279 (2012/05/10)
 vt420+lrmm|VT420 left/right margins,
-	mgc=\E[?69l, smglr=\E[?69h\E[%i%p1%d;%p2%ds,
+	mgc=\E[?69l, smglp=\E[?69h\E[%i%p1%ds,
+	smglr=\E[?69h\E[%i%p1%d;%p2%ds,
+	smgrp=\E[?69h\E[%i;%p1%ds,
 
-# DEC doesn't supply a vt400 description, so we add Daniel Glasser's
-# (originally written with vt420 as its primary name, and usable for it).
+# DEC doesn't supply a VT400 description, so we add Daniel Glasser's
+# (originally written with VT420 as its primary name, and usable for it).
 #
-# VT400/420 -- This terminal is a superset of the vt320.  It adds the multiple
-#    text pages and long text pages with selectable length of the vt340, along
+# VT400/420 -- This terminal is a superset of the VT320.  It adds the multiple
+#    text pages and long text pages with selectable length of the VT340, along
 #    with left and right margins, rectangular area text copy, fill, and erase
 #    operations, selected region character attribute change operations,
 #    page memory and rectangle checksums, insert/delete column, reception
@@ -2838,33 +2946,30 @@ vt420+lrmm|VT420 left/right margins,
 # From: Daniel Glasser <dag@persoft.persoft.com>, 13 Oct 1993
 # (vt400: string capability ":sb=\E[M:" corrected to ":sr=\E[M:";
 # also, added <rmam>/<smam> based on the init string -- esr)
-vt400|vt400-24|dec-vt400|dec vt400 24x80 column autowrap,
-	am, eslok, hs, mir, msgr, xenl, xon,
+vt400|vt400-24|dec-vt400|DEC VT400 24x80 column autowrap,
+	am, eslok, mir, msgr, xenl, xon,
 	cols#80, it#8, lines#24, vt#3,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
 	blink=\E[5m, bold=\E[1m, clear=\E[H\E[J$<10/>, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M,
-	dsl=\E[2$~\r\E[1$}\E[K\E[$}, ed=\E[J$<10/>,
-	el=\E[K$<4/>, flash=\E[?5h$<200/>\E[?5l, fsl=\E[$},
-	home=\E[H, ht=^I, hts=\EH, ich=\E[%p1%d@, ich1=\E[@,
-	il=\E[%p1%dL, il1=\E[L, ind=\ED,
+	cub1=^H, cud1=\n, dsl=\E[2$~\r\E[1$}\E[K\E[$},
+	ed=\E[J$<10/>, el=\E[K$<4/>, flash=\E[?5h$<200/>\E[?5l,
+	fsl=\E[$}, ht=^I, hts=\EH, ind=\ED,
 	is2=\E<\E\sF\E>\E[?1h\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h\E[1;24r
 	    \E[24;1H,
 	kbs=^H, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
 	kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf6=\E[17~,
 	kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, lf1=pf1, lf2=pf2,
-	lf3=pf3, lf4=pf4, nel=\r\ED, rc=\E8, rev=\E[7m,
+	lf3=pf3, lf4=pf4, nel=\r\ED, rev=\E[7m,
 	rf=/usr/share/tabset/vt300, ri=\EM, rmacs=\E(B,
-	rmam=\E[?7l, rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[27m,
-	rmul=\E[24m, rs1=\E<\E[?3l\E[!p\E[?7h, sc=\E7,
+	rmam=\E[?7l, rmkx=\E[?1l\E>, rmso=\E[27m, rmul=\E[24m,
+	rs1=\E<\E[?3l\E[!p\E[?7h,
 	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p4%t;5%;%?%p1%p3%|%t;7%;m%?
 	    %p9%t\E(0%e\E(B%;$<2>,
-	sgr0=\E[m\E(B, smacs=\E(0, smam=\E[?7h, smir=\E[4h,
-	smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g,
-	tsl=\E[2$~\E[1$}\E[1;%dH, use=dec+sl, use=vt220+cvis,
+	sgr0=\E[m\E(B, smacs=\E(0, smam=\E[?7h, smkx=\E[?1h\E=,
+	smso=\E[7m, smul=\E[4m, tbc=\E[3g,
+	tsl=\E[2$~\E[1$}\E[1;%dH, use=ansi+csr, use=ansi+cup,
+	use=ansi+idc, use=ansi+idl, use=ansi+local, use=dec+sl,
+	use=vt220+cvis,
 
 # (vt420: I removed <kf0>, it collided with <kf10>.  I also restored
 # a missing <sc> -- esr)
@@ -2874,29 +2979,26 @@ vt420|DEC VT420,
 	cols#80, it#8, lines#24, vt#3,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
 	bel=^G, blink=\E[5m$<2>, bold=\E[1m$<2>,
-	clear=\E[H\E[2J$<50>, cr=\r, csr=\E[%i%p1%d;%p2%dr,
-	cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\n,
-	cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH$<10>,
-	cuu=\E[%p1%dA, cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[P,
-	dl=\E[%p1%dM, dl1=\E[M, ech=\E[%p1%dX, ed=\E[J$<50>,
-	el=\E[K$<3>, el1=\E[1K, enacs=\E)0,
-	flash=\E[?5h$<200/>\E[?5l, home=\E[H, ht=^I, hts=\EH,
-	ich=\E[%p1%d@, if=/usr/share/tabset/vt300,
-	il=\E[%p1%dL, il1=\E[L, ind=\ED, is2=\E[1;24r\E[24;1H,
-	is3=\E[?67h\E[64;1"p, kbs=^H, kcub1=\E[D, kcud1=\E[B,
-	kcuf1=\E[C, kcuu1=\E[A, kf1=\EOP, kf10=\E[29~, kf2=\EOQ,
-	kf3=\EOR, kf4=\EOS, kf5=\E[17~, kf6=\E[18~, kf7=\E[19~,
-	kf8=\E[20~, kf9=\E[21~, nel=\EE, rc=\E8, rev=\E[7m$<2>,
-	rf=/usr/share/tabset/vt300, ri=\EM, rmacs=\E(B$<4>,
-	rmam=\E[?7l, rmir=\E[4l, rmkx=\E>,
+	clear=\E[H\E[2J$<50>, cr=\r, cub1=^H, cud1=\n,
+	cup=\E[%i%p1%d;%p2%dH$<10>, dch=\E[%p1%dP, dch1=\E[P,
+	ech=\E[%p1%dX, ed=\E[J$<50>, el=\E[K$<3>, el1=\E[1K,
+	enacs=\E)0, flash=\E[?5h$<200/>\E[?5l, home=\E[H, ht=^I,
+	hts=\EH, ich=\E[%p1%d@, if=/usr/share/tabset/vt300,
+	ind=\ED, is2=\E[1;24r\E[24;1H, is3=\E[?67h\E[64;1"p,
+	kbs=^H, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
+	kf1=\EOP, kf10=\E[29~, kf2=\EOQ, kf3=\EOR, kf4=\EOS,
+	kf5=\E[17~, kf6=\E[18~, kf7=\E[19~, kf8=\E[20~, kf9=\E[21~,
+	nel=\EE, rev=\E[7m$<2>, rf=/usr/share/tabset/vt300,
+	ri=\EM, rmacs=\E(B$<4>, rmam=\E[?7l, rmir=\E[4l, rmkx=\E>,
 	rmsc=\E[?0;0r\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h,
-	rmso=\E[27m, rmul=\E[24m, rs3=\E[?67h\E[64;1"p, sc=\E7,
+	rmso=\E[27m, rmul=\E[24m, rs3=\E[?67h\E[64;1"p,
 	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p4%t;5%;%?%p1%p3%|%t;7%;m%?
 	    %p9%t\E(0%e\E(B%;$<2>,
 	sgr0=\E[m\E(B$<2>, smacs=\E(0$<2>, smam=\E[?7h,
 	smir=\E[4h, smkx=\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g,
-	use=vt220+vtedit, use=ansi+pp, use=dec+sl, use=ansi+enq,
-	use=vt220+cvis,
+	use=ansi+csr, use=ansi+enq, use=ansi+idl, use=ansi+pp,
+	use=ansi+local, use=dec+sl, use=vt220+cvis,
+	use=vt420+lrmm, use=vt220+vtedit,
 
 # DEC VT220 and up support DECUDK (user-defined keys).  DECUDK (i.e., pfx)
 # takes two parameters, the key and the string.  Translating the key is
@@ -2928,7 +3030,7 @@ vt420pc|DEC VT420 w/PC keyboard,
 	kf43=\E[31;2~, kf44=\E[32;2~, kf45=\E[33;2~,
 	kf46=\E[34;2~, kf47=\E[35;2~, kf48=\E[36;2~, kf5=\E[15~,
 	kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, khome=\E[H,
-	pctrm=USR_TERM\:vt420pcdos\:,
+	pctrm=USR_TERM:vt420pcdos:,
 	pfx=\EP1;1|%?%{16}%p1%>%t%{0}%e%{21}%p1%>%t%{1}%e%{25}%p1%>
 	    %t%{2}%e%{27}%p1%>%t%{3}%e%{30}%p1%>%t%{4}%e%{5}%;%p1%+
 	    %d/%p2%s\E\\,
@@ -3008,17 +3110,17 @@ dec-vt220|DOS tnvt200 terminal emulator,
 # I can send the address if requested.
 # (z340: changed garbled \E[5?l to \E[?5l, DEC smooth scroll off -- esr)
 # From: Adam Thompson <athompso@pangea.ca> Sept 10 1995
-z340|zstem vt340 terminal emulator 132col 42line,
+z340|ZSTEM VT340 terminal emulator 132col 42line,
 	lines#42,
 	is2=\E>\E[?3h\E[?4l\E[?5l\E[?7h\E[?8h\E[1;42r\E[42;1H,
 	rs2=\E>\E[?3h\E[?4l\E[?5l\E[?7h\E[?8h\E[1;42r\E[42;1H, use=vt320-w,
-z340-nam|zstem vt340 terminal emulator 132col 42line (no automatic margins),
+z340-nam|ZSTEM VT340 terminal emulator 132col 42line (no automatic margins),
 	am@,
 	is2=\E>\E[?3h\E[?4l\E[?5l\E[?7l\E[?8h\E[1;42r\E[42;1H,
 	rs2=\E>\E[?3h\E[?4l\E[?5l\E[?7l\E[?8h\E[1;42r\E[42;1H, use=z340,
 
 # expect-5.44.1.15/example/tkterm
-# a minimal subset of a vt100 (compare with "news-unk).
+# a minimal subset of a VT100 (compare with "news-unk).
 #
 # The missing "=" in smkx is not a typo (here), but an error in tkterm.
 tt|tkterm|Don Libes' tk text widget terminal emulator,
@@ -3241,36 +3343,29 @@ tt|tkterm|Don Libes' tk text widget terminal emulator,
 nsterm+7|AppKit Terminal.app v41+ basic capabilities w/ASCII charset,
 	am, bw, msgr, xenl, xon,
 	cols#80, it#8, lines#24,
-	bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[J, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dim=\E[2m, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K,
-	el1=\E[1K, home=\E[H, ht=^I, hts=\EH, il=\E[%p1%dL, il1=\E[L,
-	ind=\n, invis=\E[8m, kbs=^?, kcub1=\EOD, kcud1=\EOB,
-	kcuf1=\EOC, kcuu1=\EOA, kent=\EOM, rc=\E8, rev=\E[7m, ri=\EM,
-	rmam=\E[?7l, rmkx=\E[?1l\E>, rmso=\E[m, rmul=\E[m,
-	rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, sc=\E7,
+	bel=^G, cr=\r, cub1=^H, cud1=\n, dim=\E[2m, el1=\E[1K, ht=^I,
+	hts=\EH, ind=\n, kbs=^?, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC,
+	kcuu1=\EOA, kent=\EOM, ri=\EM, rmam=\E[?7l, rmkx=\E[?1l\E>,
+	rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h,
 	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?
 	    %p5%t;2%;%?%p7%t;8%;m,
-	sgr0=\E[m, smam=\E[?7h, smkx=\E[?1h\E=, smso=\E[7m,
-	smul=\E[4m, tbc=\E[3g, use=vt100+enq, use=vt100+pfkeys,
+	sgr0=\E[m, smam=\E[?7h, smkx=\E[?1h\E=, tbc=\E[3g,
+	use=ansi+csr, use=ansi+cup, use=ansi+erase, use=ansi+idl,
+	use=ansi+local, use=ansi+sgrbold, use=vt100+enq,
+	use=vt100+pfkeys,
 
 nsterm+acs|AppKit Terminal.app v41+ basic capabilities w/VT100 alternate-charset,
-	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	enacs=\E(B\E)0, rmacs=^O,
 	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?
 	    %p5%t;2%;%?%p7%t;8%;m%?%p9%t\016%e\017%;,
-	sgr0=\E[m\017, smacs=^N, use=nsterm+7,
+	sgr0=\E[m\017, use=nsterm+7, use=vt100+4bsd,
 
 nsterm+mac|AppKit Terminal.app v41+ basic capabilities w/MacRoman alternate-charset,
-	acsc=+\335\,\334-\366.\3770#`\327a\:f\241g\261h#i
+	acsc=+\335\,\334-\366.\3770#`\327a:f\241g\261h#i
 	     \360jjkkllmmnno\370p\370q\321rrssttuuvvwwxxy\262z\263{
 	     \271|\255}\243~\245,
-	enacs=\E(B\E)0, rmacs=^O,
 	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?
 	    %p5%t;2%;%?%p7%t;8%;m%?%p9%t\016%e\017%;,
-	sgr0=\E[m\017, smacs=^N, use=nsterm+7,
+	sgr0=\E[m\017, use=nsterm+7, use=vt100+4bsd,
 
 # compare with xterm+sl-twm
 nsterm+s|AppKit Terminal.app v41+ status-line (window titlebar) support,
@@ -3280,8 +3375,8 @@ nsterm+c|AppKit Terminal.app v51+ full color support (including 16 colors),
 	op=\E[0m, use=ibm+16color,
 
 nsterm+c41|AppKit Terminal.app v41 color support,
-	colors#8, ncv#37, pairs#64,
-	op=\E[0m, setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
+	ncv#37,
+	op=\E[0m, use=klone+color,
 
 # These are different combinations of the building blocks
 
@@ -3362,16 +3457,14 @@ nsterm-c-s|AppKit Terminal.app v51+ w/MacRoman charset (full color w/statusline)
 # vt52, vt100, vt102 and xterm.
 nsterm-16color|AppKit Terminal.app v240.2+ with Mac OS X version 10.5,
 	bw@, mir, npc,
-	dch=\E[%p1%dP, dch1=\E[P, flash=\E[?5h$<200/>\E[?5l,
-	hpa=\E[%i%p1%dG, ich=\E[%p1%d@, ich1=\E[@, kdch1=\E[3~,
-	kend=\E[F, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~,
-	kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, kf16=\E[29~,
-	kf17=\E[31~, kf18=\E[22~, kf19=\E[33~, kf20=\E[34~,
-	kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~,
-	khome=\E[H, knp=\E[6~, kpp=\E[5~, rmcup=\E[2J\E[?47l\E8,
-	rmir=\E[4l, smcup=\E7\E[?47h, smir=\E[4h,
-	vpa=\E[%i%p1%dd, kLFT5=\E[5D, kRIT5=\E[5C,
-	use=nsterm-c-s-acs, use=vt220+cvis,
+	flash=\E[?5h$<200/>\E[?5l, hpa=\E[%i%p1%dG,
+	kdch1=\E[3~, kend=\E[F, kf10=\E[21~, kf11=\E[23~,
+	kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, kf15=\E[28~,
+	kf16=\E[29~, kf17=\E[31~, kf18=\E[22~, kf19=\E[33~,
+	kf20=\E[34~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~,
+	kf8=\E[19~, kf9=\E[20~, khome=\E[H, knp=\E[6~, kpp=\E[5~,
+	vpa=\E[%i%p1%dd, kLFT5=\E[5D, kRIT5=\E[5C, use=ansi+idc,
+	use=xterm+alt47, use=nsterm-c-s-acs, use=vt220+cvis,
 
 # The versions of Terminal.app in Mac OS X version 10.3.x seem to have
 # the background color erase feature. The newer version 240.2 in Mac OS X
@@ -3418,7 +3511,7 @@ nsterm-16color|AppKit Terminal.app v240.2+ with Mac OS X version 10.5,
 #     ansi or dtterm).
 #   + the shift/control/meta key modifiers from rxvt and xterm variants are not
 #     recognised except for a few special cases, i.e., kRIT5 and kLFT5.
-#   + the vt52 emulation does not give a usable shell because screen-clearing
+#   + the VT52 emulation does not give a usable shell because screen-clearing
 #     does not work as expected.
 #   + selecting "xterm" or "xterm-16color" sets TERM to "xterm-256color".
 # + OSX 10.9 (Yosemite) added more extended keys in the default configuration
@@ -3446,10 +3539,10 @@ nsterm-build343|Terminal.app in OS X 10.10,
 
 # reviewed Terminal.app in El Capitan (version 2.6 build 361) -TD
 # Using vttest:
-# + no vt52 mode for cursor keys, though vt52 screen works in vttest
+# + no VT52 mode for cursor keys, though VT52 screen works in vttest
 # + f1-f4 map to pf1-pf4
-# + no vt220 support aside from DECTCEM and ECH
-# + there are no protected areas.  Forget about anything above vt220.
+# + no VT220 support aside from DECTCEM and ECH
+# + there are no protected areas.  Forget about anything above VT220.
 # + in ECMA-48 cursor movement, VPR and HPR fail.  Others work.
 # + vttest color 11.6.4 and 11.6.5 (bce for ED/EL and ECH/indexing) are bce
 # + but bce fails for 11.6.7.2 (test repeat).
@@ -3495,9 +3588,12 @@ nsterm-build400|Terminal.app in OS X 10.13,
 	rmso=\E[27m, rmul=\E[24m, use=xterm+sm+1006,
 	use=ecma+italics, use=nsterm-build361,
 
+nsterm-build440|Terminal.app in MacOS 11.6.8,
+	use=xterm+alt1049, use=nsterm-build400,
+
 # This is an alias which should always point to the "current" version
 nsterm|nsterm-256color|Apple_Terminal|AppKit Terminal.app,
-	use=nsterm-build400,
+	use=nsterm-build440,
 
 #### iTerm, iTerm2
 
@@ -3536,38 +3632,29 @@ nsterm|nsterm-256color|Apple_Terminal|AppKit Terminal.app,
 #	can display/alter xterm-256color cube
 #	can display/alter xterm-88color cube
 iTerm.app|iterm|iTerm.app terminal emulator for Mac OS X,
-	am, bce, hs, mir, msgr, npc, xenl, xon,
-	cols#80, it#8, lines#24, wsl#50,
-	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[J, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J,
-	el=\E[K, el1=\E[1K, enacs=\E(B\E)0,
-	flash=\E[?5h$<200/>\E[?5l, home=\E[H, hpa=\E[%i%p1%dG,
-	ht=^I, hts=\EH, ich=\E[%p1%d@, ich1=\E[@, il=\E[%p1%dL,
-	il1=\E[L, ind=\n, kLFT=\E[1;2D, kRIT=\E[1;2C, kbs=^?,
-	kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
-	kdch1=\E[3~, kend=\EOF, kent=\EOM, kf1=\EOP, kf10=\E[21~,
-	kf11=\E[23~, kf12=\E[24~, kf2=\EOQ, kf3=\EOR, kf4=\EOS,
+	bce, mir, npc, xenl, xon,
+	wsl#50,
+	blink=\E[5m, bold=\E[1m, cub1=^H, cud1=\n,
+	cup=\E[%i%p1%d;%p2%dH, el1=\E[1K,
+	flash=\E[?5h$<200/>\E[?5l, hpa=\E[%i%p1%dG,
+	kLFT=\E[1;2D, kRIT=\E[1;2C, kbs=^?, kcbt=\E[Z, kdch1=\E[3~,
+	kend=\EOF, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~,
 	kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~,
-	khome=\EOH, knp=\E[6~, kpp=\E[5~, op=\E[0m, rc=\E8,
-	rev=\E[7m, ri=\EM, rmacs=^O, rmam=\E[?7l,
-	rmcup=\E[2J\E[?47l\E8, rmir=\E[4l, rmkx=\E[?1l\E>,
-	rmso=\E[m, rmul=\E[m,
-	rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, sc=\E7,
+	knp=\E[6~, kpp=\E[5~, op=\E[0m, rev=\E[7m, ri=\EM,
+	rmam=\E[?7l, rmkx=\E[?1l\E>, rmso=\E[m, rmul=\E[m,
 	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m%?
 	    %p9%t\016%e\017%;,
-	sgr0=\E[m\017, smacs=^N, smam=\E[?7h, smcup=\E7\E[?47h,
-	smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m,
-	tbc=\E[3g, vpa=\E[%i%p1%dd, kEND5=\E[1;5F, kHOM5=\E[1;5H,
-	use=ansi+enq, use=xterm+sl-twm, use=vt100+keypad,
+	sgr0=\E[m\017, smam=\E[?7h, smkx=\E[?1h\E=, smso=\E[7m,
+	smul=\E[4m, vpa=\E[%i%p1%dd, kEND5=\E[1;5F,
+	kHOM5=\E[1;5H, use=ansi+apparrows, use=ansi+csr,
+	use=ansi+enq, use=ansi+erase, use=ansi+idc, use=ansi+idl,
+	use=ansi+local, use=vt100+4bsd, use=vt100+keypad,
+	use=vt100+pfkeys, use=xterm+alt47, use=xterm+sl-twm,
 	use=xterm+x11mouse, use=xterm+256setaf, use=vt220+cvis,
 
 # iTerm2 3.0.15
 #
-# https://www.iterm2.com/
+# https://iterm2.com/
 # https://github.com/gnachman/iTerm2
 # ~/Library/Preferences/com.googlecode.iterm2.plist
 # "iTerm" stalled in 2009.  A different set of developers began "iTerm2".
@@ -3599,13 +3686,13 @@ iTerm.app|iterm|iTerm.app terminal emulator for Mac OS X,
 # 2018/01/21: found xterm+sm+1006 did not work with version 3.1.5
 # 2018/05/19: xterm+sm+1006 seems to work with 3.1.6beta -TD
 iTerm2.app|iterm2|terminal emulator for Mac OS X,
-	blink=\E[5m, cbt=\E[Z, dim=\E[2m, kEND=\E[1;2F,
-	kHOM=\E[1;2H, ka1@, ka3@, kb2@, kc1@, kc3@, kent@, kf13=\E[1;2P,
-	kf14=\E[1;2Q, kf15=\E[1;2R, kf16=\E[1;2S, kf17=\E[15;2~,
-	kf18=\E[17;2~, kf19=\E[18;2~, kf2=\EOQ, kf20=\E[19;2~,
-	kf21=\E[20;2~, kf22=\E[21;2~, kf23=\E[23;2~,
-	kf24=\E[24;2~, kind=\E[1;2B, kri=\E[1;2A, nel=\EE,
-	op=\E[39;49m, rmso=\E[27m, rmul=\E[24m,
+	cbt=\E[Z, dim=\E[2m, kEND=\E[1;2F, kHOM=\E[1;2H, ka1@, ka3@,
+	kb2@, kc1@, kc3@, kent@, kf13=\E[1;2P, kf14=\E[1;2Q,
+	kf15=\E[1;2R, kf16=\E[1;2S, kf17=\E[15;2~, kf18=\E[17;2~,
+	kf19=\E[18;2~, kf20=\E[19;2~, kf21=\E[20;2~,
+	kf22=\E[21;2~, kf23=\E[23;2~, kf24=\E[24;2~,
+	kind=\E[1;2B, kri=\E[1;2A, nel=\EE, op=\E[39;49m,
+	rmso=\E[27m, rmul=\E[24m,
 	rs2=\E[!p\E[?3;4l\E[4l\E>\E[?1000l,
 	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?
 	    %p5%t;2%;m%?%p9%t\016%e\017%;,
@@ -3619,6 +3706,7 @@ iTerm2.app|iterm2|terminal emulator for Mac OS X,
 	kRIT5=\E[1;5C, kRIT6=\E[1;6C, kUP3=\E\E[A, kUP4=\E[1;10A,
 	kUP5=\E[1;5A, kUP6=\E[1;6A, use=ecma+index,
 	use=xterm+alt+title, use=ecma+italics, use=iterm,
+	use=bracketed+paste,
 
 # xnuppc - Darwin PowerPC Console (a.k.a. "darwin")
 #
@@ -3715,186 +3803,181 @@ iTerm2.app|iterm2|terminal emulator for Mac OS X,
 # color-bold entries do not include size information.
 
 # The '+' entries are building blocks
-xnuppc+basic|Darwin PowerPC Console basic capabilities,
-	am, bce, mir, xenl,
+xnuppc+basic|Darwin PowerPC console basic capabilities,
+	am, bce, mir, xenl, NQ,
 	it#8,
-	bold=\E[1m, clear=\E[H\E[J, cr=\r, csr=\E[%i%p1%d;%p2%dr,
-	cub=\E[%p1%dD, cub1=\E[D, cud=\E[%p1%dB, cud1=\E[B,
-	cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
-	cuu=\E[%p1%dA, cuu1=\E[A, dsl=\E]2;\007, ed=\E[J, el=\E[K,
-	el1=\E[1K, home=\E[H, ht=^I, hts=\EH, ind=\n, kbs=^?,
-	kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, rc=\E8,
-	rev=\E[7m, ri=\EM, rmam=\E[?7l, rmkx=\E[?1l\E>, rmso=\E[m,
-	rmul=\E[m, rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h,
-	sc=\E7,
+	bold=\E[1m, cr=\r, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
+	dsl=\E]2;\007, el1=\E[1K, home=\E[H, ht=^I, hts=\EH, ind=\n,
+	kbs=^?, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
+	rev=\E[7m, ri=\EM, rmam=\E[?7l, rmkx=\E[?1l\E>,
+	rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h,
 	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;m,
-	sgr0=\E[m, smam=\E[?7h, smkx=\E[?1h\E=, smso=\E[7m,
-	smul=\E[4m, tbc=\E[3g, use=vt100+keypad,
+	sgr0=\E[m, smam=\E[?7h, smkx=\E[?1h\E=, tbc=\E[3g,
+	use=ansi+csr, use=ansi+erase, use=ansi+local,
+	use=ansi+sgrso, use=ansi+sgrul, use=vt100+keypad,
 
-xnuppc+c|Darwin PowerPC Console ANSI color support,
-	colors#8, ncv#32, pairs#64,
-	op=\E[37;40m, setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
+xnuppc+c|Darwin PowerPC console ANSI color support,
+	ncv#32, use=klone+color,
 
-xnuppc+b|Darwin PowerPC Console color-bold support,
+xnuppc+b|Darwin PowerPC console color-bold support,
 	ncv#32,
 	bold=\E[35m,
 	sgr=\E[0%?%p6%t;35%;%?%p2%t;4%;%?%p1%p3%|%t;7%;m,
 	use=xnuppc+basic,
 
-xnuppc+f|Darwin PowerPC Console fancy color support,
+xnuppc+f|Darwin PowerPC console fancy color support,
 	ncv#35,
 	sgr=\E[0%?%p6%t;35%;%?%p2%t;36;4%;%?%p1%t;33;44%;%?%p3%t;7%;
 	    m,
 	smso=\E[33;44m, smul=\E[36;4m, use=xnuppc+b,
 
-xnuppc+f2|Darwin PowerPC Console alternate fancy color support,
+xnuppc+f2|Darwin PowerPC console alternate fancy color support,
 	ncv#35,
 	bold=\E[33m,
 	sgr=\E[0%?%p6%t;33%;%?%p2%t;34%;%?%p1%t;31;47%;%?%p3%t;7%;m,
 	smso=\E[31;47m, smul=\E[34m, use=xnuppc+basic,
 
 # Building blocks for specific screen sizes
-xnuppc+80x25|Darwin PowerPC Console 80x25 support (640x400 pixels),
+xnuppc+80x25|Darwin PowerPC console 80x25 support (640x400 pixels),
 	cols#80, lines#25,
 
-xnuppc+80x30|Darwin PowerPC Console 80x30 support (640x480 pixels),
+xnuppc+80x30|Darwin PowerPC console 80x30 support (640x480 pixels),
 	cols#80, lines#30,
 
-xnuppc+90x30|Darwin PowerPC Console 90x30 support (720x480 pixels),
+xnuppc+90x30|Darwin PowerPC console 90x30 support (720x480 pixels),
 	cols#90, lines#30,
 
-xnuppc+100x37|Darwin PowerPC Console 100x37 support (800x600 pixels),
+xnuppc+100x37|Darwin PowerPC console 100x37 support (800x600 pixels),
 	cols#100, lines#37,
 
-xnuppc+112x37|Darwin PowerPC Console 112x37 support (896x600 pixels),
+xnuppc+112x37|Darwin PowerPC console 112x37 support (896x600 pixels),
 	cols#112, lines#37,
 
-xnuppc+128x40|Darwin PowerPC Console 128x40 support (1024x640 pixels),
+xnuppc+128x40|Darwin PowerPC console 128x40 support (1024x640 pixels),
 	cols#128, lines#40,
 
-xnuppc+128x48|Darwin PowerPC Console 128x48 support (1024x768 pixels),
+xnuppc+128x48|Darwin PowerPC console 128x48 support (1024x768 pixels),
 	cols#128, lines#48,
 
-xnuppc+144x48|Darwin PowerPC Console 144x48 support (1152x768 pixels),
+xnuppc+144x48|Darwin PowerPC console 144x48 support (1152x768 pixels),
 	cols#144, lines#48,
 
-xnuppc+160x64|Darwin PowerPC Console 160x64 support (1280x1024 pixels),
+xnuppc+160x64|Darwin PowerPC console 160x64 support (1280x1024 pixels),
 	cols#160, lines#64,
 
-xnuppc+200x64|Darwin PowerPC Console 200x64 support (1600x1024 pixels),
+xnuppc+200x64|Darwin PowerPC console 200x64 support (1600x1024 pixels),
 	cols#200, lines#64,
 
-xnuppc+200x75|Darwin PowerPC Console 200x75 support (1600x1200 pixels),
+xnuppc+200x75|Darwin PowerPC console 200x75 support (1600x1200 pixels),
 	cols#200, lines#75,
 
-xnuppc+256x96|Darwin PowerPC Console 256x96 support (2048x1536 pixels),
+xnuppc+256x96|Darwin PowerPC console 256x96 support (2048x1536 pixels),
 	cols#0x100, lines#96,
 
 # These are different combinations of the building blocks
 
-xnuppc-m|darwin-m|Darwin PowerPC Console (monochrome),
+xnuppc-m|darwin-m|Darwin PowerPC console (monochrome),
 	use=xnuppc+basic,
 
-xnuppc|darwin|Darwin PowerPC Console (color),
+xnuppc|darwin|Darwin PowerPC console (color),
 	use=xnuppc+c, use=xnuppc+basic,
 
-xnuppc-m-b|darwin-m-b|Darwin PowerPC Console (monochrome w/color-bold),
+xnuppc-m-b|darwin-m-b|Darwin PowerPC console (monochrome w/color-bold),
 	use=xnuppc+b,
 
-xnuppc-b|darwin-b|Darwin PowerPC Console (color w/color-bold),
+xnuppc-b|darwin-b|Darwin PowerPC console (color w/color-bold),
 	use=xnuppc+b, use=xnuppc+c,
 
-xnuppc-m-f|darwin-m-f|Darwin PowerPC Console (fancy monochrome),
+xnuppc-m-f|darwin-m-f|Darwin PowerPC console (fancy monochrome),
 	use=xnuppc+f,
 
-xnuppc-f|darwin-f|Darwin PowerPC Console (fancy color),
+xnuppc-f|darwin-f|Darwin PowerPC console (fancy color),
 	use=xnuppc+f, use=xnuppc+c,
 
-xnuppc-m-f2|darwin-m-f2|Darwin PowerPC Console (alternate fancy monochrome),
+xnuppc-m-f2|darwin-m-f2|Darwin PowerPC console (alternate fancy monochrome),
 	use=xnuppc+f2,
 
-xnuppc-f2|darwin-f2|Darwin PowerPC Console (alternate fancy color),
+xnuppc-f2|darwin-f2|Darwin PowerPC console (alternate fancy color),
 	use=xnuppc+f2, use=xnuppc+c,
 
 # Combinations for specific screen sizes
-xnuppc-80x25-m|darwin-80x25-m|Darwin PowerPC Console (monochrome) 80x25,
+xnuppc-80x25-m|darwin-80x25-m|Darwin PowerPC console (monochrome) 80x25,
 	use=xnuppc+80x25, use=xnuppc+basic,
 
-xnuppc-80x25|darwin-80x25|Darwin PowerPC Console (color) 80x25,
+xnuppc-80x25|darwin-80x25|Darwin PowerPC console (color) 80x25,
 	use=xnuppc+c, use=xnuppc+80x25, use=xnuppc+basic,
 
-xnuppc-80x30-m|darwin-80x30-m|Darwin PowerPC Console (monochrome) 80x30,
+xnuppc-80x30-m|darwin-80x30-m|Darwin PowerPC console (monochrome) 80x30,
 	use=xnuppc+80x30, use=xnuppc+basic,
 
-xnuppc-80x30|darwin-80x30|Darwin PowerPC Console (color) 80x30,
+xnuppc-80x30|darwin-80x30|Darwin PowerPC console (color) 80x30,
 	use=xnuppc+c, use=xnuppc+80x30, use=xnuppc+basic,
 
-xnuppc-90x30-m|darwin-90x30-m|Darwin PowerPC Console (monochrome) 90x30,
+xnuppc-90x30-m|darwin-90x30-m|Darwin PowerPC console (monochrome) 90x30,
 	use=xnuppc+90x30, use=xnuppc+basic,
 
-xnuppc-90x30|darwin-90x30|Darwin PowerPC Console (color) 90x30,
+xnuppc-90x30|darwin-90x30|Darwin PowerPC console (color) 90x30,
 	use=xnuppc+c, use=xnuppc+90x30, use=xnuppc+basic,
 
-xnuppc-100x37-m|darwin-100x37-m|Darwin PowerPC Console (monochrome) 100x37,
+xnuppc-100x37-m|darwin-100x37-m|Darwin PowerPC console (monochrome) 100x37,
 	use=xnuppc+100x37, use=xnuppc+basic,
 
-xnuppc-100x37|darwin-100x37|Darwin PowerPC Console (color) 100x37,
+xnuppc-100x37|darwin-100x37|Darwin PowerPC console (color) 100x37,
 	use=xnuppc+c, use=xnuppc+100x37, use=xnuppc+basic,
 
-xnuppc-112x37-m|darwin-112x37-m|Darwin PowerPC Console (monochrome) 112x37,
+xnuppc-112x37-m|darwin-112x37-m|Darwin PowerPC console (monochrome) 112x37,
 	use=xnuppc+112x37, use=xnuppc+basic,
 
-xnuppc-112x37|darwin-112x37|Darwin PowerPC Console (color) 112x37,
+xnuppc-112x37|darwin-112x37|Darwin PowerPC console (color) 112x37,
 	use=xnuppc+c, use=xnuppc+112x37, use=xnuppc+basic,
 
-xnuppc-128x40-m|darwin-128x40-m|Darwin PowerPC Console (monochrome) 128x40,
+xnuppc-128x40-m|darwin-128x40-m|Darwin PowerPC console (monochrome) 128x40,
 	use=xnuppc+128x40, use=xnuppc+basic,
 
-xnuppc-128x40|darwin-128x40|Darwin PowerPC Console (color) 128x40,
+xnuppc-128x40|darwin-128x40|Darwin PowerPC console (color) 128x40,
 	use=xnuppc+c, use=xnuppc+128x40, use=xnuppc+basic,
 
-xnuppc-128x48-m|darwin-128x48-m|Darwin PowerPC Console (monochrome) 128x48,
+xnuppc-128x48-m|darwin-128x48-m|Darwin PowerPC console (monochrome) 128x48,
 	use=xnuppc+128x48, use=xnuppc+basic,
 
-xnuppc-128x48|darwin-128x48|Darwin PowerPC Console (color) 128x48,
+xnuppc-128x48|darwin-128x48|Darwin PowerPC console (color) 128x48,
 	use=xnuppc+c, use=xnuppc+128x48, use=xnuppc+basic,
 
-xnuppc-144x48-m|darwin-144x48-m|Darwin PowerPC Console (monochrome) 144x48,
+xnuppc-144x48-m|darwin-144x48-m|Darwin PowerPC console (monochrome) 144x48,
 	use=xnuppc+144x48, use=xnuppc+basic,
 
-xnuppc-144x48|darwin-144x48|Darwin PowerPC Console (color) 144x48,
+xnuppc-144x48|darwin-144x48|Darwin PowerPC console (color) 144x48,
 	use=xnuppc+c, use=xnuppc+144x48, use=xnuppc+basic,
 
-xnuppc-160x64-m|darwin-160x64-m|Darwin PowerPC Console (monochrome) 160x64,
+xnuppc-160x64-m|darwin-160x64-m|Darwin PowerPC console (monochrome) 160x64,
 	use=xnuppc+160x64, use=xnuppc+basic,
 
-xnuppc-160x64|darwin-160x64|Darwin PowerPC Console (color) 160x64,
+xnuppc-160x64|darwin-160x64|Darwin PowerPC console (color) 160x64,
 	use=xnuppc+c, use=xnuppc+160x64, use=xnuppc+basic,
 
-xnuppc-200x64-m|darwin-200x64-m|Darwin PowerPC Console (monochrome) 200x64,
+xnuppc-200x64-m|darwin-200x64-m|Darwin PowerPC console (monochrome) 200x64,
 	use=xnuppc+200x64, use=xnuppc+basic,
 
-xnuppc-200x64|darwin-200x64|Darwin PowerPC Console (color) 200x64,
+xnuppc-200x64|darwin-200x64|Darwin PowerPC console (color) 200x64,
 	use=xnuppc+c, use=xnuppc+200x64, use=xnuppc+basic,
 
-xnuppc-200x75-m|darwin-200x75-m|Darwin PowerPC Console (monochrome) 200x75,
+xnuppc-200x75-m|darwin-200x75-m|Darwin PowerPC console (monochrome) 200x75,
 	use=xnuppc+200x75, use=xnuppc+basic,
 
-xnuppc-200x75|darwin-200x75|Darwin PowerPC Console (color) 200x75,
+xnuppc-200x75|darwin-200x75|Darwin PowerPC console (color) 200x75,
 	use=xnuppc+c, use=xnuppc+200x75, use=xnuppc+basic,
 
-xnuppc-256x96-m|darwin-256x96-m|Darwin PowerPC Console (monochrome) 256x96,
+xnuppc-256x96-m|darwin-256x96-m|Darwin PowerPC console (monochrome) 256x96,
 	use=xnuppc+256x96, use=xnuppc+basic,
 
-xnuppc-256x96|darwin-256x96|Darwin PowerPC Console (color) 256x96,
+xnuppc-256x96|darwin-256x96|Darwin PowerPC console (color) 256x96,
 	use=xnuppc+c, use=xnuppc+256x96, use=xnuppc+basic,
 
 ######## DOS/WINDOWS
 # CRT is shareware.  It implements some xterm features, including mouse.
 crt|crt-vt220|CRT 2.3 emulating VT220,
-	bce, msgr,
-	ncv@,
-	hts=\EH, use=vt100+enq, use=vt220-base, use=ecma+color,
+	bce,
+	ncv@, use=vt100+enq, use=vt220-base, use=ecma+color,
 
 # SecureCRT 8.7.3.2279
 # 8.7.3 was released 2020/08/11
@@ -3955,7 +4038,7 @@ crt|crt-vt220|CRT 2.3 emulating VT220,
 #	resize.pl gets no reply, resize.sh needs fix for no reply.
 scrt|securecrt|SecureCRT emulating xterm-256color,
 	bce@, km@, npc,
-	bel@, cvvis@, kcbt=\E[Z, kent=\EOM, use=vt220+pcedit,
+	bel@, cvvis@, kcbt=\E[Z, use=vt220+pcedit,
 	use=xterm+256setaf, use=ecma+index, use=ansi+rep,
 	use=xterm+keypad, use=xterm+pcfkeys, use=xterm-basic,
 
@@ -3969,7 +4052,7 @@ scrt|securecrt|SecureCRT emulating xterm-256color,
 #	Double-size characters
 #	Xterm extensions for mouse support
 #	Emulates VT52, VT100, VT220, VT320, ansi, xterm, qnx, scoansi,
-#	ANSIBBS, WYSE60, Televideo 950.
+#	ANSIBBS, WYSE60, TeleVideo 950.
 #
 # Default:
 #	TERM=xterm
@@ -4005,15 +4088,23 @@ scrt|securecrt|SecureCRT emulating xterm-256color,
 #	supports 256-colors, including changing palette (ncurses menu d works)
 #	supports UTF-8, but honors VT100 line-drawing
 absolute|Absolute Telnet emulating xterm,
-	kcbt=\E[Z, use=ecma+index, use=ansi+rep,
+	kcbt=\E[Z, use=ecma+index, use=linux+kbs, use=ansi+rep,
 	use=vt220+pcedit, use=xterm+keypad, use=xterm+app,
 	use=xterm+pcf0, use=xterm+256color, use=xterm+x11mouse,
 	use=xterm-basic,
 
 #### PuTTY
-# PuTTY 0.74 (27 June 2020)
 # http://www.chiark.greenend.org.uk/~sgtatham/putty/
 #
+# PuTTY 0.78 (September 2020, tested 12 August 2023)
+# Testing with tack:
+#	implements cross-out text (shortly after 0.74)
+#	restore kLFT as kLFT5, etc. (mentioned in October 2021)
+#	does not support direct-colors (mentioned in July 2021)
+#
+# PuTTY 0.74 (27 June 2020)
+#	(unchanged)
+#
 # PuTTY 0.73 (September 2019)
 # Testing with tack:
 #	does not implement italics
@@ -4037,7 +4128,7 @@ absolute|Absolute Telnet emulating xterm,
 #
 # PuTTY 0.51 (14 December 2000)
 #
-# This emulates vt100 + vt52 (plus a few vt220 features:  ech, SRM, DECTCEM, as
+# This emulates VT100 + VT52 (plus a few VT220 features:  ech, SRM, DECTCEM, as
 # well as SCO and Atari, color palettes from Linux console).  Reading the code,
 # it is intended to be VT102 plus selected features.  By default, it sets $TERM
 # to xterm, which is incorrect, since several features are misimplemented:
@@ -4058,48 +4149,52 @@ absolute|Absolute Telnet emulating xterm,
 #	http://stackoverflow.com/questions/24613237/terminal-retains-bg-color-after-closing-vim-using-color-scheme-and-putty-256co/37869114#37869114
 putty|PuTTY terminal emulator,
 	am, bce, bw, ccc, mir, msgr, xenl, xon, XT,
-	colors#8, it#8, ncv#22, pairs#64, U8#1,
+	it#8, ncv#22, U8#1,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[J, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\ED, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\EM,
-	dch=\E[%p1%dP, dch1=\E[P,
+	bel=^G, cr=\r, cub1=^H, cud1=\ED, cup=\E[%i%p1%d;%p2%dH,
+	cuu1=\EM, dch=\E[%p1%dP, dch1=\E[P,
 	dispc=%?%p1%{8}%=%t\E%%G\342\227\230\E%%@%e%p1%{10}%=%t\E%%G
 	      \342\227\231\E%%@%e%p1%{12}%=%t\E%%G\342\231\0\E%%@%e
 	      %p1%{13}%=%t\E%%G\342\231\252\E%%@%e%p1%{14}%=%t\E%%G
 	      \342\231\253\E%%@%e%p1%{15}%=%t\E%%G\342\230\274\E%%@
 	      %e%p1%{27}%=%t\E%%G\342\206\220\E%%@%e%p1%{155}%=%t\E
 	      %%G\340\202\242\E%%@%e%p1%c%;,
-	dl=\E[%p1%dM, dl1=\E[M, ech=\E[%p1%dX, ed=\E[J, el=\E[K,
-	el1=\E[1K, enacs=\E(B\E)0, flash=\E[?5h$<100/>\E[?5l,
-	home=\E[H, hpa=\E[%i%p1%dG, il=\E[%p1%dL, il1=\E[L, ind=\n,
+	ech=\E[%p1%dX, el1=\E[1K, enacs=\E(B\E)0,
+	flash=\E[?5h$<100/>\E[?5l, home=\E[H, hpa=\E[%i%p1%dG,
+	ind=\n,
 	initc=\E]P%p1%x%p2%{255}%*%{1000}%/%02x%p3%{255}%*%{1000}%/
 	      %02x%p4%{255}%*%{1000}%/%02x,
 	is2=\E7\E[r\E[m\E[?7h\E[?1;4;6l\E[4l\E8\E>\E]R,
-	kbs=^?, kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC,
-	kcuu1=\EOA, kind=\E[B, kri=\E[A, kspd=^Z, nel=\r\n, oc=\E]R,
-	op=\E[39;49m, rc=\E8, rev=\E[7m, ri=\EM, rmacs=^O,
-	rmam=\E[?7l, rmcup=\E[2J\E[?47l, rmir=\E[4l,
-	rmkx=\E[?1l\E>, rmpch=\E[10m, rmso=\E[27m, rmul=\E[24m,
+	kbs=^?, kcbt=\E[Z, khome=\E[1~, kind=\E[B, kri=\E[A, kspd=^Z,
+	nel=\r\n, oc=\E]R, op=\E[39;49m, ri=\EM, rmacs=^O,
+	rmam=\E[?7l, rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[27m,
+	rmul=\E[24m,
 	rs2=\E<\E["p\E[50;6"p\Ec\E[?3l\E]R\E[?1000l,
-	s0ds=\E[10m, s1ds=\E[11m, s2ds=\E[12m, sc=\E7,
-	setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
+	s0ds=\E[10m, s1ds=\E[11m, s2ds=\E[12m,
 	sgr=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5
 	    %;m%?%p9%t\016%e\017%;,
-	sgr0=\E[m\017, smacs=^N, smam=\E[?7h, smcup=\E[?47h,
-	smir=\E[4h, smkx=\E[?1h\E=, smpch=\E[11m, smso=\E[7m,
-	smul=\E[4m, vpa=\E[%i%p1%dd, E3=\E[3J, use=vt220+pcedit,
-	use=ansi+tabs, use=ansi+rep, use=ecma+index,
-	use=xterm+sm+1006, use=putty+fnkeys, use=vt102+enq,
+	sgr0=\E[m\017, smacs=^N, smam=\E[?7h, smir=\E[4h,
+	smkx=\E[?1h\E=, vpa=\E[%i%p1%dd, E3=\E[3J,
+	use=ansi+apparrows, use=ansi+csr, use=ansi+erase,
+	use=ansi+idl, use=ansi+local, use=ansi+tabs,
+	use=ansi+rep, use=bracketed+paste, use=ecma+index,
+	use=ecma+strikeout, use=klone+color, use=klone+sgr,
+	use=putty+cursor, use=putty+fnkeys, use=vt220+pcedit,
+	use=xterm+alt1049, use=vt102+enq, use=xterm+sm+1006,
 	use=xterm+sl, use=vt100+fnkeys, use=putty+keypad,
 	use=vt220+cvis,
+
+# older versions (e.g., before 0.71) of PuTTY used a shift-modifier to toggle
+# between normal- and application-mode for the cursor-keys.  That was dropped,
+# and a few years later (after 0.74) restored as the control-modifier.
+putty+cursor|PuTTY modified cursor-keys,
+	kDN5=\E[B, kLFT5=\E[D, kRIT5=\E[C, kUP5=\E[A,
 putty+keypad|PuTTY numeric keypad,
 	kp1=\EOq, kp2=\EOr, kp3=\EOs, kp4=\EOt, kp5=\EOu, kp6=\EOv,
 	kp7=\EOw, kp8=\EOx, kp9=\EOy, kpADD=\EOl, kpDIV=\EOQ,
 	kpDOT=\EOn, kpMUL=\EOR, kpNUM=\EOP, kpSUB=\EOS, kpZRO=\EOp,
 
-vt100-putty|Reset PuTTY to pure vt100,
+vt100-putty|Reset PuTTY to pure VT100,
 	rs2=\E<\E["p\Ec\E[?3l\E]R\E[40"p\E[61"p\E[50;1;2"p,
 	use=vt100,
 putty-256color|PuTTY 0.58 with xterm 256-colors,
@@ -4209,20 +4304,19 @@ mintty|Cygwin Terminal,
 	setal=\E[5%p1%dm, use=xterm+256color,
 	use=mintty+common,
 mintty-direct|Cygwin Terminal direct-color,
-	setal=\E[%?%p1%{8}%<%t5%p1%d%e58\:2\:\:%p1%{65536}%/%d\:%p1
-	      %{256}%/%{255}%&%d\:%p1%{255}%&%d%;m,
-	use=xterm+direct, use=mintty+common,
+	use=kitty+setal, use=xterm+direct, use=mintty+common,
 mintty+common|shared capabilities for mintty,
 	km@, npc,
 	kcbt=\E[Z, kent=\EOM, rmm@, rmpch=\E[10m,
 	rs1=\Ec\E]104\007, rshm=\E[22m, rsubm=\E[75m,
-	rsupm=\E[75m, smm@, smpch=\E[11m, sshm=\E[1\:2m,
+	rsupm=\E[75m, smm@, smpch=\E[11m, sshm=\E[1:2m,
 	ssubm=\E[74m, ssupm=\E[73m, Rmol=\E[55m, Smol=\E[53m,
-	Smulx=\E[4\:%p1%dm, blink2=\E[6m, norm=\E[22m,
-	opaq=\E[28m, smul2=\E[21m, use=ansi+rep,
+	Smulx=\E[4:%p1%dm, blink2=\E[6m, norm=\E[22m,
+	opaq=\E[28m, smul2=\E[21m, use=linux+kbs, use=ansi+rep,
 	use=ecma+strikeout, use=ecma+index, use=vt420+lrmm,
-	use=xterm+sm+1006, use=xterm+pcfkeys, use=xterm+tmux,
-	use=ecma+italics, use=xterm-basic,
+	use=xterm+focus, use=xterm+sm+1006, use=xterm+pcfkeys,
+	use=xterm+tmux, use=ecma+italics, use=xterm-basic,
+	use=bracketed+paste, use=report+version,
 # 2019-06-09: These capabilities are commented-out for compatibility with
 # existing releases 5.9-6.1, and may be considered for inclusion after the
 # release of ncurses 6.2:
@@ -4257,14 +4351,14 @@ mintty+common|shared capabilities for mintty,
 #	- Japanese and Russian character sets.
 #
 # The program does not come with terminfo or termcap entries.  However, the
-# emulation (testing with vttest and ncurses) is reasonably close to vt100 (no
-# vt52 or doublesize character support; blinking is done with color).  Besides
+# emulation (testing with vttest and ncurses) is reasonably close to VT100 (no
+# VT52 or doublesize character support; blinking is done with color).  Besides
 # the HPA, VPA extensions it also implements CPL and CNL.
 #
 # All of the function keys can be remapped.  This description shows the default
-# mapping, as installed.  Both vt100 PF1-PF4 keys and quasi-vt220 F1-F4 keys
+# mapping, as installed.  Both VT100 PF1-PF4 keys and quasi-vt220 F1-F4 keys
 # are supported.  F13-F20 are obtained by shifting F3-F10.  The editing keypad
-# is laid out like vt220, rather than the face codes on the PC keyboard, i.e,
+# is laid out like VT220, rather than the face codes on the PC keyboard, i.e,
 #	kfnd	Insert
 #	kslt	Delete
 #	kich1	Home
@@ -4282,7 +4376,7 @@ mintty+common|shared capabilities for mintty,
 # retrieving the window title, and for setting the window size (i.e., using
 # "resize -s"), though it does not pass SIGWINCH to the application if the
 # user resizes the window with the mouse.
-teraterm2.3|Tera Term Pro,
+teraterm2.3|Tera Term Pro 2.3,
 	km,
 	ncv#43, vt@,
 	acsc=+\020\,\021-\030.^Y0\333`\004a\261f\370g\361h\260i
@@ -4290,33 +4384,32 @@ teraterm2.3|Tera Term Pro,
 	     \264v\301w\302x\263y\363z\362{\343|\330}\234~\376,
 	blink=\E[5m, bold=\E[1m, clear=\E[H\E[J, cuf1=\E[C,
 	cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, dch=\E[%p1%dP,
-	dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, ech=\E[%p1%dX, ed=\E[J,
-	el=\E[K, el1=\E[1K, flash=\E[?5h$<200/>\E[?5l,
-	hpa=\E[%i%p1%dG, il=\E[%p1%dL, il1=\E[L, kf1=\E[11~,
+	dch1=\E[P, ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K,
+	flash=\E[?5h$<200/>\E[?5l, hpa=\E[%i%p1%dG, kf1=\E[11~,
 	kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[25~,
 	kf14=\E[26~, kf15=\E[28~, kf16=\E[29~, kf17=\E[31~,
 	kf18=\E[32~, kf19=\E[33~, kf2=\E[12~, kf20=\E[34~,
 	kf3=\E[13~, kf4=\E[14~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~,
 	kf8=\E[19~, kf9=\E[20~, op=\E[100m, rev=\E[7m, ri=\EM,
 	rmso=\E[27m, rmul=\E[24m, sgr0=\E[0m\017, smso=\E[7m,
-	smul=\E[4m, vpa=\E[%i%p1%dd, use=vt220+vtedit,
-	use=vt100+enq, use=klone+color, use=vt100,
-	use=vt220+cvis,
+	smul=\E[4m, vpa=\E[%i%p1%dd, use=ansi+idl,
+	use=vt220+vtedit, use=vt100+enq, use=klone+color,
+	use=vt100, use=vt220+cvis,
 
-# Version 4.59 has regular vt100 line-drawing (so it is no longer necessary
+# Version 4.59 has regular VT100 line-drawing (so it is no longer necessary
 # to choose a Windows OEM font).
 #
 # Testing with tack:
 #	- it does not have xenl (suppress that)
 #	- underline seems to work with color (modify ncv).
 # Testing with vttest:
-#	- wrapping differs from vt100 (menu 1).
+#	- wrapping differs from VT100 (menu 1).
 #	- it recognizes xterm's X10 and normal mouse tracking, but none of the
 #	  other flavors.
 #	- it recognizes the dtterm window controls for reporting size in
 #	  characters and pixels.
 #	- it passes SIGWINCH.
-teraterm4.59|Tera Term Pro,
+teraterm4.59|Tera Term Pro 4.59,
 	bce, xenl@,
 	ncv#41,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
@@ -4346,7 +4439,7 @@ teraterm4.59|Tera Term Pro,
 #	+ recognizes xterm's original direct-colors sequences, but result is
 #	  poor.
 #	+ no UTF-8 apparent when UTF-8 is set, with font Lucida Control
-teraterm4.97|Tera Term Pro,
+teraterm4.97|Tera Term Pro 4.97,
 	XT, use=ecma+color, use=xterm+sm+1006, use=teraterm4.59,
 teraterm-256color|TeraTerm with xterm 256-colors,
 	use=xterm+256setaf, use=teraterm,
@@ -4362,10 +4455,10 @@ teraterm|Tera Term,
 # Other notes:
 # a) Fails tack's cup (cursor-addressing) test, though cup works well enough
 #    for casual (occasional) use.  Also fails several of the vttest screens,
-#    but that is not unusual for vt100 "emulators".
-# b) Does not implement vt100 keypad
-# c) Recognizes a subset of vt52 controls.
-ms-vt100|MS telnet imitating dec vt100,
+#    but that is not unusual for VT100 "emulators".
+# b) Does not implement VT100 keypad
+# c) Recognizes a subset of VT52 controls.
+ms-vt100|MS telnet imitating DEC VT100,
 	lines#25,
 	acsc=+\020\,\021-\030.^Y0\333`\004a\261f\370g\361h\260i
 	     \316j\331k\277l\332m\300n\305o~p\304q\304r\304s_t\303u
@@ -4380,7 +4473,7 @@ ms-vt100|MS telnet imitating dec vt100,
 # a) This version has no function keys or numeric keypad.  Unlike the older
 #    version, the numeric keypad is entirely ignored.
 # b) The program sets $TERM to "ansi", which of course is inaccurate.
-ms-vt100-color|vtnt|windows 2000 ansi (sic),
+ms-vt100-color|vtnt|windows 2000 ANSI (sic),
 	bce,
 	dch=\E[%p1%dP, ich=\E[%p1%d@, use=ecma+color,
 	use=ms-vt100,
@@ -4400,7 +4493,7 @@ ms-vt100-color|vtnt|windows 2000 ansi (sic),
 #	Shift	\E^S
 #	Alt	\E^A,
 #	Ctrl	\E^C,
-ms-vt100+|vt100+|windows XP vt100+ (sic),
+ms-vt100+|vt100+|windows XP VT100+ (sic),
 	kdch1=\E-, kend=\Ek, kf1=\E1, kf10=\E0, kf11=\E!, kf12=\E@,
 	kf13=\E\023\E1, kf14=\E\023\E2, kf15=\E\023\E3,
 	kf16=\E\023\E4, kf17=\E\023\E5, kf18=\E\023\E6,
@@ -4417,22 +4510,151 @@ ms-vt100+|vt100+|windows XP vt100+ (sic),
 	kf6=\E6, kf7=\E7, kf8=\E8, kf9=\E9, khome=\Eh, kich1=\E+,
 	knp=\E/, kpp=\E?, use=ms-vt100-color,
 
-ms-vt-utf8|vt-utf8|UTF-8 flavor of vt100+,
+ms-vt-utf8|vt-utf8|UTF-8 flavor of VT100+,
 	use=ms-vt100+,
 
+# VT-UTF-8 and VT100+ Protocols
+# https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-vuvp/969416c0-ccd6-4a75-a9b3-597d7713845b
+#
+# This Microsoft "protocol" adapted the aixterm 16-color feature from xterm's
+# documentation in 2015, as seen in successive revisions:
+#
+# 2013/07/22 has 8 colors
+# 2015/10/16 has 16 colors using SGR 90-97, 100-107 as well as SGR 24 and 27,
+#            adds "informative" reference to xterm's ctlseqs
+#
+# The cnorm/civis definitions added in 2015 are unrelated to any standard.
+ms-vt100-16color|VT-UTF-8 and VT100+,
+	civis=\E[?h, cnorm=\E[?l, rmso=\E[27m, rmul=\E[24m,
+	use=ibm+16color, use=ms-vt100+,
+
+# Based on
+# https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences
+# We use this scheme to map function keys
+#       terminfo        modifier        code    keys
+#       kf13-kf24       shift           2       F1 to F12
+#       kf25-kf36       alt             3       F1 to F12
+#       kf37-kf48       control         4       F1 to F12
+#       kf49-kf60       ctrl-alt        7       F1 to F12
+#
+# Unclear: smam and rmam implemented?
+# Unclear: rmkx, smkx, rmir, smir - irrelevant?
+#
+# TD:
+# +	According to tack, tbc and cbt fail.
+# +	The line-drawing (acsc) does not work in telnet or ssh.  I added the
+#	U8 extension to tell ncurses to use UTF-8 for line-drawing (when the
+#	locale uses UTF-8).  That won't work for telnet (which uses ASCII),
+#	but seems to work for OpenSSH's ssh.  I set the codepage to 65001,
+#	of course.
+# +	Function keys... do not work consistently in telnet and ssh.  With
+#	telnet, kf1-kf4 are \EOP to \EOS, and kf5-kf12 match the terminfo.
+#	But with ssh, it's entirely different (reminds me of rxvt).
+winconsole|Windows 10 new console,
+	am, km, mir, msgr, xenl,
+	ncv@, U8#1,
+	acsc=++\,\,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxy
+	     yzz~~,
+	bel=^G, blink@, cr=\r, ech=\E[%p1%dX, el1=\E[0K, ich1@, ind=\n,
+	invis@, is1=\E[!p, kf13=\E[11;2~, kf14=\E[12;2~,
+	kf15=\E[13;2~, kf16=\E[14;2~, kf17=\E[15;2~,
+	kf18=\E[17;2~, kf19=\E[18;2~, kf20=\E[19;2~,
+	kf21=\E[20;2~, kf22=\E[21;2~, kf23=\E[24;2~,
+	kf24=\E[25;2~, kf25=\E[11;3~, kf26=\E[12;3~,
+	kf27=\E[13;3~, kf28=\E[14;3~, kf29=\E[15;3~,
+	kf30=\E[17;3~, kf31=\E[18;3~, kf32=\E[19;3~,
+	kf33=\E[20;3~, kf34=\E[21;3~, kf35=\E[24;3~,
+	kf36=\E[25;3~, kf37=\E[11;4~, kf38=\E[12;4~,
+	kf39=\E[13;4~, kf40=\E[14;4~, kf41=\E[15;4~,
+	kf42=\E[17;4~, kf43=\E[18;4~, kf44=\E[19;4~,
+	kf45=\E[20;4~, kf46=\E[21;4~, kf47=\E[24;4~,
+	kf48=\E[25;4~, kf49=\E[11;7~, kf50=\E[12;7~,
+	kf51=\E[13;7~, kf52=\E[14;7~, kf53=\E[15;7~,
+	kf54=\E[17;7~, kf55=\E[18;7~, kf56=\E[19;7~,
+	kf57=\E[20;7~, kf58=\E[21;7~, kf59=\E[24;7~,
+	kf60=\E[25;7~, khome=\E[1~, nel=\r\n, ri=\E[T, rmacs=\E(B,
+	rmir@, rmpch@, rs1=\E[!p,
+	sgr=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;m%?%p9%t
+	    \E(0%e\E(B%;,
+	sgr0=\E[0m\E(B, smacs=\E(0, smir@, smpch@, use=ansi+arrows,
+	use=ansi+csr, use=ansi+cup, use=ansi+erase, use=ansi+idc,
+	use=ansi+idl, use=ecma+index, use=ansi+inittabs,
+	use=ansi+local, use=ecma+sgr, use=ecma+color,
+	use=vt220+cvis, use=vt220+pcedit, use=xterm+nopcfkeys,
+
 # Windows Terminal (Preview)
-# Windows 10 1903
-# Version 0.2.1831.0
 # https://github.com/microsoft/terminal
 #
-# The task manager shows this as "OpenConsole.exe", which differs
-# from the "Windows Command Processor" used for the command-prompt.
+# Windows 10 22H2 (also Windows 11)
+# Version 1.16.10261.0
 #
-# The settings dialog does not work (unless the end user expects to open
-# profiles.json in Visual Studio).  There is no documentation, of course.
+# - Windows Terminal #1553: "Feature Request:  Mouse/Touch/Pointer Bindings
+#   (like middle-click paste, right-click context menu, etc.)", compare to
+#   https://learn.microsoft.com/en-us/windows/console/mouse-event-record-str
+#   This appears to be related to a problem with its implementation of the
+#   Console API; the mouse does not work in a "Command Window" (e.g., as used
+#   in the ncurses MinGW driver), although escape sequences work.
 #
-# Testing via an ssh connection, using openssh:
-# - the program sets TERM to cygwin if the tab is set to PowerShell,
+# Windows 10 21H1
+# Version 1.9.1942.0
+#
+# This has longstanding issues with CR/LF mapping, e.g.,
+# - first reported by Juergen Pfeifer August 13, 2020, with workaround
+# - Windows Terminal #8303 "Updates to ms-terminal terminal type in terminfo to
+#   1.4 from 0.2"
+# - Windows Terminal #6733 "Midnight Commander (mc) output is screwed when
+#   using the 'ms-terminal' as $TERM"
+#
+# still seen in testing during May-July 2021.  As a workaround, this terminal
+# description sets cud1 to an escape sequence rather than just \r.
+#
+# Using TERM=xterm-256color shows a number of problems.
+# A few are seen only in the WSL2 environment.
+#
+# tack:
+# - flash does not work.
+# - video attribute blink does not work.
+# - video attribute invis does not work in WSL2.
+# - italics sitm/ritm do not work in WSL2.
+# - crossed-out smxx/rmxx do not work in WSL2.
+# - reloading colors via initp interchanges red/blue.
+# - does not implement OSC 104, which is used for resetting colors in xterm.
+# - does not support numeric keypad application mode.
+# - control-modifier (without alt/shift) does not work for special keys.
+# - meta-key sends escape character rather than acting as a meta key.
+#
+# vttest:
+# - identifies itself as a VT100.
+# - cursor movement (menu 1) does not work properly, e.g., for wrapping.
+# - does not support 8-bit controls.
+# - does not support VT420 rectangles.
+# - does not support VT420 left/right margins.
+# - ECMA-48 cursor-movement works.
+# - does not support X10 mouse, or mouse highlight tracking.
+# - SGR mouse mode 1006 works.
+# - any-event mouse mode shows no focus-in/focus-out events.
+# - alternate screen 47/48 modes do not work, nor do 1047/1048.
+# - alternate screen 1049 mode works.
+# - none of the window report/modify operations work.
+# - none of the DECRPM/DECRQM reporting operations work.
+#
+# xterm:
+# - 256colors2.pl -r, -i and -q options work.
+# - dynamic colors do not work.
+# - paste64.pl does not work, i.e., bracketed-paste.
+# - tcapquery.pl does not work.
+#
+# Windows 10 1903
+# Version 0.2.1831.0
+#
+# The task manager shows this as "OpenConsole.exe", which differs
+# from the "Windows Command Processor" used for the command-prompt.
+#
+# The settings dialog does not work (unless the end user expects to open
+# profiles.json in Visual Studio).  There is no documentation, of course.
+#
+# Testing via an ssh connection, using openssh:
+# - the program sets TERM to cygwin if the tab is set to PowerShell,
 #   and to xterm-256color if "Legacy".  However, in the latter, more tests
 #   fail in vttest, which does not pay attention to TERM.
 # vttest:
@@ -4462,9 +4684,11 @@ ms-vt-utf8|vt-utf8|UTF-8 flavor of vt100+,
 # - does not recognize either xterm+direct or xterm+indirect escapes.
 ms-terminal|Windows10 terminal,
 	npc,
-	rmkx=\E[?1l, rmm@, smkx=\E[?1h, smm@, use=xterm+256setaf,
-	use=xterm+pcfkeys, use=ansi+rep, use=ecma+index,
-	use=ecma+italics, use=xterm-basic,
+	cud1=\E[B, kcbt=\E[Z, rmkx=\E[?1l, rmm@, smkx=\E[?1h, smm@,
+	Cr@, Ms@, use=linux+kbs, use=xterm+256color,
+	use=xterm+pcfkeys, use=ansi+rep, use=xterm+sm+1006,
+	use=ecma+index, use=ecma+italics, use=ecma+strikeout,
+	use=xterm-basic, use=xterm+tmux,
 
 #### Visual Studio
 # Visual Studio Code 1.45.0 uses xterm.js 12.8.1 (see https://xtermjs.org/).
@@ -4513,9 +4737,10 @@ ms-terminal|Windows10 terminal,
 # - color-palette cannot be changed
 vscode|xterm.js|Visual Studio Code terminal using xterm.js,
 	npc,
-	kcbt=\E[Z, rmkx=\E[?1l, smkx=\E[?1h, use=xterm+256setaf,
-	use=ecma+index, use=xterm+sm+1006, use=xterm+pcfkeys,
-	use=ecma+italics, use=xterm-basic,
+	kcbt=\E[Z, rmkx=\E[?1l, smkx=\E[?1h, use=linux+kbs,
+	use=xterm+256setaf, use=ecma+index, use=xterm+focus,
+	use=xterm+sm+1006, use=xterm+pcfkeys, use=ecma+italics,
+	use=xterm-basic, use=bracketed+paste,
 vscode-direct|Visual Studio Code with direct-colors,
 	use=xterm+indirect, use=vscode,
 
@@ -4542,14 +4767,19 @@ x10term|vs100-x10|xterm terminal emulator (X10 window system),
 	cols#80, it#8, lines#65,
 	bold=\E[1m, clear=\E[H\E[2J, csr=\E[%i%p1%d;%p2%dr,
 	cub1=^H, cud1=\n, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
-	cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM,
-	dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H, ht=^I, il=\E[%p1%dL,
-	il1=\E[L, ind=\n, is2=\E\E[m\E[?7h\E[?1;4l, kbs=^H,
+	cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[P, ed=\E[J, el=\E[K,
+	home=\E[H, ht=^I, ind=\n, is2=\E\E[m\E[?7h\E[?1;4l, kbs=^H,
 	kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kf1=\EOP,
 	kf2=\EOQ, kf3=\EOR, kf4=\EOS, rev=\E[7m, ri=\EM, rmam=\E[?7l,
 	rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[m, rmul=\E[m,
 	sgr0=\E[m, smam=\E[?7h, smir=\E[4h, smkx=\E[?1h\E=,
-	smso=\E[7m, smul=\E[4m,
+	smso=\E[7m, smul=\E[4m, use=ansi+idl,
+
+# csl is extension which clears the status line
+x10term+sl|status-line for X10 xterm,
+	eslok, hs,
+	dsl=\E[?H, fsl=\E[?F, tsl=\E[?E\E[?%i%p1%dT, csl=\E[?E,
+
 # Compatible with the R5 xterm
 # (from the XFree86 3.2 distribution, <blink=@> removed)
 # added khome/kend, rmir/smir, rmul/smul, hts based on the R5 xterm code - TD
@@ -4558,26 +4788,22 @@ x10term|vs100-x10|xterm terminal emulator (X10 window system),
 xterm-r5|xterm R5 version,
 	OTbs, am, km, msgr, xenl,
 	cols#80, it#8, lines#24,
-	bel=^G, bold=\E[1m, clear=\E[H\E[2J, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J,
-	el=\E[K, home=\E[H, ht=^I, hts=\EH, ich=\E[%p1%d@, ich1=\E[@,
-	il=\E[%p1%dL, il1=\E[L, ind=\n, kcub1=\EOD, kcud1=\EOB,
-	kcuf1=\EOC, kcuu1=\EOA, kdl1=\E[31~, kel=\E[8~, kf0=\EOq,
+	bel=^G, bold=\E[1m, clear=\E[H\E[2J, cr=\r, cub1=^H, cud1=\n,
+	cup=\E[%i%p1%d;%p2%dH, ed=\E[J, el=\E[K, home=\E[H, ht=^I,
+	hts=\EH, ind=\n, kdl1=\E[31~, kel=\E[8~, kf0=\EOq,
 	kf1=\E[11~, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~,
 	kf2=\E[12~, kf3=\E[13~, kf4=\E[14~, kf5=\E[15~, kf6=\E[17~,
 	kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, khome=\E[1~,
-	kil1=\E[30~, kmous=\E[M, rc=\E8, rev=\E[7m, ri=\EM,
-	rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[m, rmul=\E[m,
+	kil1=\E[30~, kmous=\E[M, rev=\E[7m, ri=\EM, rmkx=\E[?1l\E>,
+	rmso=\E[m, rmul=\E[m,
 	rs2=\E>\E[?1;3;4;5;6l\E[4l\E[?7h\E[m\E[r\E[2J\E[H,
-	sc=\E7,
 	sgr=\E[%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p6%t;1
 	    %;m,
-	sgr0=\E[m, smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m,
-	smul=\E[4m, tbc=\E[3g, use=vt220+pcedit, use=vt100+enq,
-	use=xterm+kbs,
+	sgr0=\E[m, smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m,
+	tbc=\E[3g, use=xterm+kbs, use=ansi+apparrows,
+	use=ansi+csr, use=ansi+idc, use=ansi+idl, use=ansi+local,
+	use=vt220+pcedit, use=vt100+enq,
+
 # Compatible with the R6 xterm
 # (from XFree86 3.2 distribution, <acsc> and <it> added, <blink@> removed)
 # added khome/kend, hts based on the R6 xterm code - TD
@@ -4587,13 +4813,10 @@ xterm-r6|xterm X11R6 version,
 	OTbs, am, km, mir, msgr, xenl,
 	cols#80, it#8, lines#24,
 	acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, bold=\E[1m, clear=\E[H\E[2J, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J,
-	el=\E[K, enacs=\E)0, home=\E[H, ht=^I, hts=\EH, il=\E[%p1%dL,
-	il1=\E[L, ind=\n,
+	bel=^G, bold=\E[1m, clear=\E[H\E[2J, cr=\r, cub1=^H, cud1=\n,
+	cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, dch=\E[%p1%dP,
+	dch1=\E[P, ed=\E[J, el=\E[K, enacs=\E)0, home=\E[H, ht=^I,
+	hts=\EH, ind=\n,
 	is2=\E[m\E[?7h\E[4l\E>\E7\E[r\E[?1;3;4;6l\E8,
 	kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kf1=\E[11~,
 	kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[25~,
@@ -4601,12 +4824,13 @@ xterm-r6|xterm X11R6 version,
 	kf18=\E[32~, kf19=\E[33~, kf2=\E[12~, kf20=\E[34~,
 	kf3=\E[13~, kf4=\E[14~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~,
 	kf8=\E[19~, kf9=\E[20~, kmous=\E[M, meml=\El, memu=\Em,
-	rc=\E8, rev=\E[7m, ri=\EM, rmacs=^O, rmcup=\E[2J\E[?47l\E8,
-	rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[m, rmul=\E[m,
-	rs2=\E[m\E[?7h\E[4l\E>\E7\E[r\E[?1;3;4;6l\E8, sc=\E7,
-	sgr0=\E[m, smacs=^N, smcup=\E7\E[?47h, smir=\E[4h,
-	smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g,
+	rev=\E[7m, ri=\EM, rmacs=^O, rmir=\E[4l, rmkx=\E[?1l\E>,
+	rs2=\E[m\E[?7h\E[4l\E>\E7\E[r\E[?1;3;4;6l\E8,
+	sgr0=\E[m, smacs=^N, smir=\E[4h, smkx=\E[?1h\E=, tbc=\E[3g,
+	use=xterm+alt47, use=ansi+csr, use=ansi+idl,
+	use=ansi+local, use=ansi+sgrso, use=ansi+sgrul,
 	use=vt220+vtedit, use=xterm+kbs, use=vt100+enq,
+
 xterm-old|antique xterm version,
 	use=xterm-r6,
 # The monochrome version began as a copy of "xtermm" (from Solaris), and was
@@ -4622,40 +4846,35 @@ xterm-mono|monochrome xterm,
 # The name has been changed and some aliases have been removed.
 xterm-xf86-v32|xterm terminal emulator (XFree86 3.2 Window System),
 	OTbs, am, bce, km, mir, msgr, xenl, XT,
-	cols#80, it#8, lines#24, ncv@,
+	cols#80, lines#24, ncv@,
 	acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, bold=\E[1m, cbt=\E[Z, clear=\E[H\E[2J, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M,
-	ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K, enacs=\E(B\E)0,
-	flash=\E[?5h$<100/>\E[?5l, home=\E[H, hpa=\E[%i%p1%dG,
-	ht=^I, hts=\EH, ich=\E[%p1%d@, ich1=\E[@, il=\E[%p1%dL,
-	il1=\E[L, ind=\n,
+	bel=^G, bold=\E[1m, clear=\E[H\E[2J, cr=\r, cub1=^H, cud1=\n,
+	cup=\E[%i%p1%d;%p2%dH, ech=\E[%p1%dX, ed=\E[J, el=\E[K,
+	el1=\E[1K, enacs=\E(B\E)0, flash=\E[?5h$<100/>\E[?5l,
+	home=\E[H, hpa=\E[%i%p1%dG, ind=\n,
 	is2=\E7\E[r\E[m\E[?7h\E[?1;3;4;6l\E[4l\E8\E>,
-	kbeg=\EOE, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
-	kdch1=^?, kend=\EOF, kf1=\E[11~, kf10=\E[21~, kf11=\E[23~,
-	kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, kf15=\E[28~,
-	kf16=\E[29~, kf17=\E[31~, kf18=\E[32~, kf19=\E[33~,
-	kf2=\E[12~, kf20=\E[34~, kf3=\E[13~, kf4=\E[14~,
-	kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~,
-	kfnd=\E[1~, khome=\EOH, kich1=\E[2~, kmous=\E[M, knp=\E[6~,
-	kpp=\E[5~, kslt=\E[4~, meml=\El, memu=\Em, rc=\E8, rev=\E[7m,
-	ri=\EM, rmacs=^O, rmam=\E[?7l, rmcup=\E[2J\E[?47l\E8,
-	rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[27m, rmul=\E[24m,
-	rs1=^O, rs2=\E7\E[r\E8\E[m\E[?7h\E[?1;3;4;6l\E[4l\E>,
-	sc=\E7,
+	kbeg=\EOE, kbs=^?, kdch1=^?, kend=\EOF, kf1=\E[11~,
+	kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[25~,
+	kf14=\E[26~, kf15=\E[28~, kf16=\E[29~, kf17=\E[31~,
+	kf18=\E[32~, kf19=\E[33~, kf2=\E[12~, kf20=\E[34~,
+	kf3=\E[13~, kf4=\E[14~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~,
+	kf8=\E[19~, kf9=\E[20~, kfnd=\E[1~, kmous=\E[M, kslt=\E[4~,
+	meml=\El, memu=\Em, rev=\E[7m, ri=\EM, rmacs=^O, rmam=\E[?7l,
+	rmkx=\E[?1l\E>, rmso=\E[27m, rmul=\E[24m, rs1=^O,
+	rs2=\E7\E[r\E8\E[m\E[?7h\E[?1;3;4;6l\E[4l\E>,
 	setb=\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}
 	     %=%t3%e%p1%d%;m,
 	setf=\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}
 	     %=%t3%e%p1%d%;m,
 	sgr=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5
 	    %;m%?%p9%t\016%e\017%;,
-	sgr0=\E[m\017, smacs=^N, smam=\E[?7h, smcup=\E7\E[?47h,
-	smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m,
-	tbc=\E[3g, vpa=\E[%i%p1%dd, use=xterm+kbs, use=vt100+enq,
+	sgr0=\E[m\017, smacs=^N, smam=\E[?7h, smkx=\E[?1h\E=,
+	smso=\E[7m, smul=\E[4m, vpa=\E[%i%p1%dd,
+	use=ansi+apparrows, use=ansi+csr, use=ansi+idc,
+	use=ansi+idl, use=ansi+inittabs, use=ansi+local,
+	use=xterm+alt47, use=xterm+kbs, use=vt100+enq,
 	use=ecma+color, use=vt220+cvis, use=vt220+keypad,
+	use=vt220+pcedit,
 
 # This is the stock xterm entry supplied with XFree86 3.3, which uses VT100
 # codes for F1-F4 except while in VT220 mode.
@@ -4681,18 +4900,17 @@ xterm-xf86-v40|xterm terminal emulator (XFree86 4.0 Window System),
 	npc,
 	kDC=\E[3;5~, kEND=\EO5F, kHOM=\EO5H, kIC=\E[2;5~,
 	kLFT=\EO5D, kNXT=\E[6;5~, kPRV=\E[5;5~, kRIT=\EO5C, ka1@,
-	ka3@, kb2=\EOE, kc1@, kc3@, kcbt=\E[Z, kdch1=\E[3~, kend=\EOF,
-	kf13=\EO2P, kf14=\EO2Q, kf15=\EO2R, kf16=\EO2S,
-	kf17=\E[15;2~, kf18=\E[17;2~, kf19=\E[18;2~,
-	kf20=\E[19;2~, kf21=\E[20;2~, kf22=\E[21;2~,
-	kf23=\E[23;2~, kf24=\E[24;2~, kf25=\EO5P, kf26=\EO5Q,
-	kf27=\EO5R, kf28=\EO5S, kf29=\E[15;5~, kf30=\E[17;5~,
-	kf31=\E[18;5~, kf32=\E[19;5~, kf33=\E[20;5~,
-	kf34=\E[21;5~, kf35=\E[23;5~, kf36=\E[24;5~, kf37=\EO6P,
-	kf38=\EO6Q, kf39=\EO6R, kf40=\EO6S, kf41=\E[15;6~,
-	kf42=\E[17;6~, kf43=\E[18;6~, kf44=\E[19;6~,
-	kf45=\E[20;6~, kf46=\E[21;6~, kf47=\E[23;6~,
-	kf48=\E[24;6~, khome=\EOH,
+	ka3@, kb2=\EOE, kc1@, kc3@, kcbt=\E[Z, kf13=\EO2P, kf14=\EO2Q,
+	kf15=\EO2R, kf16=\EO2S, kf17=\E[15;2~, kf18=\E[17;2~,
+	kf19=\E[18;2~, kf20=\E[19;2~, kf21=\E[20;2~,
+	kf22=\E[21;2~, kf23=\E[23;2~, kf24=\E[24;2~, kf25=\EO5P,
+	kf26=\EO5Q, kf27=\EO5R, kf28=\EO5S, kf29=\E[15;5~,
+	kf30=\E[17;5~, kf31=\E[18;5~, kf32=\E[19;5~,
+	kf33=\E[20;5~, kf34=\E[21;5~, kf35=\E[23;5~,
+	kf36=\E[24;5~, kf37=\EO6P, kf38=\EO6Q, kf39=\EO6R,
+	kf40=\EO6S, kf41=\E[15;6~, kf42=\E[17;6~, kf43=\E[18;6~,
+	kf44=\E[19;6~, kf45=\E[20;6~, kf46=\E[21;6~,
+	kf47=\E[23;6~, kf48=\E[24;6~,
 	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m%?
 	    %p9%t\016%e\017%;,
 	use=xterm+alt1049, use=xterm-xf86-v333,
@@ -4711,15 +4929,12 @@ xterm-xf86-v43|xterm terminal emulator (XFree86 4.3 Window System),
 # the hardware terminals, or for more recent emulators, e.g., xterm.
 vt220+cvis|DECTCEM VT220 cursor-visibility,
 	civis=\E[?25l, cnorm=\E[?25h,
-vt220+cvis8|8-bit variant,
+vt220+cvis8|8-bit DECTCEM VT220 cursor-visibility,
 	civis=\233?25l, cnorm=\233?25h,
-# The cvvis capability was unused in the SVr4 terminal descriptions for the
-# AT&T terminals, and there are no available documents as of 2021 which can
-# provide that it would have worked.  The first block is used for those 1980s
-# terminals; the second is used for terminals whose behavior can be verified.
-att610+cvis0|ATT 610 cursor-visibility,
-	civis=\E[?25l, cnorm=\E[?25h\E[?12l,
-att610+cvis|xterm cursor-visibility in XFree86 4.4,
+# The first block is for terminals which did not support blinking cursor.
+att610+cvis0|AT&T 610 cursor-visibility,
+	civis=\E[?25l, cnorm=\E[?12l\E[?25h,
+att610+cvis|AT&T 610 cursor-visibility with blink,
 	civis=\E[?25l, cnorm=\E[?12l\E[?25h, cvvis=\E[?12;25h,
 
 # This version was released in XFree86 4.4.
@@ -4731,22 +4946,36 @@ xterm-xfree86|xterm terminal emulator (XFree86),
 
 xterm+nofkeys|building block for xterm fkey-variants,
 	npc,
-	kcbt=\E[Z, kent=\EOM, nel=\EE, use=ecma+index,
-	use=ansi+rep, use=ecma+strikeout, use=vt420+lrmm,
+	kcbt=\E[Z, nel=\EE, use=ecma+index, use=ansi+rep,
+	use=ecma+strikeout, use=vt420+lrmm, use=xterm+focus,
 	use=xterm+sm+1006, use=xterm+tmux, use=ecma+italics,
 	use=xterm+keypad, use=xterm-basic,
 
+xterm-p370|xterm patch #370,
+	rv=\E\\[41;[1-6][0-9][0-9];0c,
+	xr=\EP>\\|XTerm\\([1-9][0-9]+\\)\E\\\\,
+	use=ecma+index, use=ansi+rep, use=ecma+strikeout,
+	use=xterm+pcfkeys, use=xterm+nofkeys,
+	use=bracketed+paste, use=report+version,
+	use=xterm+focus,
+
+xterm-p371|xterm patch #371,
+	use=dec+sl, use=xterm-p370,
+
 # This version reflects the current xterm features.
 xterm-new|modern xterm terminal emulator,
-	npc,
-	kcbt=\E[Z, kent=\EOM, nel=\EE, use=ecma+index,
-	use=ansi+rep, use=ecma+strikeout, use=xterm+pcfkeys,
-	use=xterm+nofkeys,
+	use=xterm-p370,
 
 # This fragment is for people who cannot agree on what the backspace key
-# should send.
+# should send.  The ncurses configure script option "--with-xterm-kbs" can
+# set it to BS (standard) or DEL (Linux's notion of "vt220").  xterm provides
+# either, depending on how the pseudoterminals are configured.
 xterm+kbs|fragment for backspace key,
 	kbs=^H,
+
+# Use this fragment for terminals that always use DEL for "backspace".
+linux+kbs|fragment for "backspace" key,
+	kbs=^?,
 #
 # This fragment describes as much of XFree86 xterm's "pc-style" function
 # keys as will fit into terminfo's 60 function keys.
@@ -4763,17 +4992,48 @@ xterm+kbs|fragment for backspace key,
 #  ---------------------------------
 # The meta key may also be used as a modifier in this scheme, adding another
 # bit to the parameter.
-xterm+pcfkeys|fragment for PC-style fkeys,
+xterm+pcfkeys|xterm fragment for PC-style fkeys,
 	use=xterm+app, use=xterm+pcf2, use=xterm+pcc2,
 	use=xterm+pce2,
-#
+
+# The xterm ctrlFKeys resource defaults to 10, so without the "pc-style"
+# feature, e.g., setting the modifyCursorKeys and modifyFunctionKeys resources
+# to -1 to disable them, one gets 42 function-keys on a 12-function-key
+# keyboard, e.g.,
+# kf1                   = \E[11~
+# kf11 shift f1         = \E[23~
+# kf21 control f1       = \E[42~
+# kf31 shift control f1 = \E[52~
+xterm+nopcfkeys|fragment without PC-style fkeys,
+	kf1=\E[11~, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~,
+	kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, kf16=\E[29~,
+	kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, kf2=\E[12~,
+	kf20=\E[34~, kf21=\E[42~, kf22=\E[43~, kf23=\E[44~,
+	kf24=\E[45~, kf25=\E[46~, kf26=\E[47~, kf27=\E[48~,
+	kf28=\E[49~, kf29=\E[50~, kf3=\E[13~, kf30=\E[51~,
+	kf31=\E[52~, kf32=\E[53~, kf33=\E[54~, kf34=\E[55~,
+	kf35=\E[56~, kf36=\E[57~, kf37=\E[58~, kf38=\E[59~,
+	kf39=\E[60~, kf4=\E[14~, kf40=\E[61~, kf41=\E[62~,
+	kf42=\E[63~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~,
+	kf8=\E[19~, kf9=\E[20~,
+
+vt100+noapp|fragment with cursor keys in normal mode,
+	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
+	use=vt100+noapp+pc,
+
 xterm+noapp|fragment with cursor keys in normal mode,
 	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kend=\E[F,
 	khome=\E[H,
 
 xterm+app|fragment with cursor keys in application mode,
-	kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kend=\EOF,
-	khome=\EOH,
+	kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
+	use=xterm+app+pc,
+
+vt100+noapp+pc|fragment for noapp pc-style home/end,
+	kend=\E[F, khome=\E[H,
+
+xterm+app+pc|fragment for app pc-style home/end,
+	kend=\EOF, khome=\EOH,
 #
 # The "PC-style" modifier scheme was introduced in xterm patch #94 (1999/3/27)
 # and revised in xterm patch #167 (2002/8/24).  Some other terminal emulators
@@ -4846,8 +5106,7 @@ xterm+pcc0|fragment with modifyCursorKeys:0,
 # Here are corresponding fragments from xterm patch #216:
 #
 xterm+pcf0|fragment with modifyFunctionKeys:0,
-	kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~,
-	kf13=\EO2P, kf14=\EO2Q, kf15=\EO2R, kf16=\EO2S,
+	kf1=\EOP, kf13=\EO2P, kf14=\EO2Q, kf15=\EO2R, kf16=\EO2S,
 	kf17=\E[15;2~, kf18=\E[17;2~, kf19=\E[18;2~, kf2=\EOQ,
 	kf20=\E[19;2~, kf21=\E[20;2~, kf22=\E[21;2~,
 	kf23=\E[23;2~, kf24=\E[24;2~, kf25=\EO5P, kf26=\EO5Q,
@@ -4858,55 +5117,56 @@ xterm+pcf0|fragment with modifyFunctionKeys:0,
 	kf4=\EOS, kf40=\EO6S, kf41=\E[15;6~, kf42=\E[17;6~,
 	kf43=\E[18;6~, kf44=\E[19;6~, kf45=\E[20;6~,
 	kf46=\E[21;6~, kf47=\E[23;6~, kf48=\E[24;6~, kf49=\EO3P,
-	kf5=\E[15~, kf50=\EO3Q, kf51=\EO3R, kf52=\EO3S,
-	kf53=\E[15;3~, kf54=\E[17;3~, kf55=\E[18;3~,
-	kf56=\E[19;3~, kf57=\E[20;3~, kf58=\E[21;3~,
-	kf59=\E[23;3~, kf6=\E[17~, kf60=\E[24;3~, kf61=\EO4P,
-	kf62=\EO4Q, kf63=\EO4R, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~,
+	kf50=\EO3Q, kf51=\EO3R, kf52=\EO3S, kf53=\E[15;3~,
+	kf54=\E[17;3~, kf55=\E[18;3~, kf56=\E[19;3~,
+	kf57=\E[20;3~, kf58=\E[21;3~, kf59=\E[23;3~,
+	kf60=\E[24;3~, kf61=\EO4P, kf62=\EO4Q, kf63=\EO4R,
+	use=xterm+nopcfkeys,
 #
 xterm+pcf2|fragment with modifyFunctionKeys:2,
-	kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~,
-	kf13=\E[1;2P, kf14=\E[1;2Q, kf15=\E[1;2R, kf16=\E[1;2S,
-	kf17=\E[15;2~, kf18=\E[17;2~, kf19=\E[18;2~, kf2=\EOQ,
-	kf20=\E[19;2~, kf21=\E[20;2~, kf22=\E[21;2~,
-	kf23=\E[23;2~, kf24=\E[24;2~, kf25=\E[1;5P, kf26=\E[1;5Q,
-	kf27=\E[1;5R, kf28=\E[1;5S, kf29=\E[15;5~, kf3=\EOR,
-	kf30=\E[17;5~, kf31=\E[18;5~, kf32=\E[19;5~,
-	kf33=\E[20;5~, kf34=\E[21;5~, kf35=\E[23;5~,
-	kf36=\E[24;5~, kf37=\E[1;6P, kf38=\E[1;6Q, kf39=\E[1;6R,
-	kf4=\EOS, kf40=\E[1;6S, kf41=\E[15;6~, kf42=\E[17;6~,
-	kf43=\E[18;6~, kf44=\E[19;6~, kf45=\E[20;6~,
-	kf46=\E[21;6~, kf47=\E[23;6~, kf48=\E[24;6~,
-	kf49=\E[1;3P, kf5=\E[15~, kf50=\E[1;3Q, kf51=\E[1;3R,
+	kf1=\EOP, kf13=\E[1;2P, kf14=\E[1;2Q, kf15=\E[1;2R,
+	kf16=\E[1;2S, kf17=\E[15;2~, kf18=\E[17;2~,
+	kf19=\E[18;2~, kf2=\EOQ, kf20=\E[19;2~, kf21=\E[20;2~,
+	kf22=\E[21;2~, kf23=\E[23;2~, kf24=\E[24;2~,
+	kf25=\E[1;5P, kf26=\E[1;5Q, kf27=\E[1;5R, kf28=\E[1;5S,
+	kf29=\E[15;5~, kf3=\EOR, kf30=\E[17;5~, kf31=\E[18;5~,
+	kf32=\E[19;5~, kf33=\E[20;5~, kf34=\E[21;5~,
+	kf35=\E[23;5~, kf36=\E[24;5~, kf37=\E[1;6P, kf38=\E[1;6Q,
+	kf39=\E[1;6R, kf4=\EOS, kf40=\E[1;6S, kf41=\E[15;6~,
+	kf42=\E[17;6~, kf43=\E[18;6~, kf44=\E[19;6~,
+	kf45=\E[20;6~, kf46=\E[21;6~, kf47=\E[23;6~,
+	kf48=\E[24;6~, kf49=\E[1;3P, kf50=\E[1;3Q, kf51=\E[1;3R,
 	kf52=\E[1;3S, kf53=\E[15;3~, kf54=\E[17;3~,
 	kf55=\E[18;3~, kf56=\E[19;3~, kf57=\E[20;3~,
-	kf58=\E[21;3~, kf59=\E[23;3~, kf6=\E[17~, kf60=\E[24;3~,
-	kf61=\E[1;4P, kf62=\E[1;4Q, kf63=\E[1;4R, kf7=\E[18~,
-	kf8=\E[19~, kf9=\E[20~,
+	kf58=\E[21;3~, kf59=\E[23;3~, kf60=\E[24;3~,
+	kf61=\E[1;4P, kf62=\E[1;4Q, kf63=\E[1;4R,
+	use=xterm+nopcfkeys,
 #
 # Chunks from xterm #230:
-xterm+pce2|fragment with modifyCursorKeys:2,
+xterm+pce2|fragment with modifyCursorKeys:2 editing-keys,
 	kDC=\E[3;2~, kEND=\E[1;2F, kHOM=\E[1;2H, kIC=\E[2;2~,
-	kNXT=\E[6;2~, kPRV=\E[5;2~, kich1=\E[2~, knp=\E[6~,
-	kpp=\E[5~, kDC3=\E[3;3~, kDC4=\E[3;4~, kDC5=\E[3;5~,
-	kDC6=\E[3;6~, kDC7=\E[3;7~, kEND3=\E[1;3F, kEND4=\E[1;4F,
-	kEND5=\E[1;5F, kEND6=\E[1;6F, kEND7=\E[1;7F,
-	kHOM3=\E[1;3H, kHOM4=\E[1;4H, kHOM5=\E[1;5H,
-	kHOM6=\E[1;6H, kHOM7=\E[1;7H, kIC3=\E[2;3~, kIC4=\E[2;4~,
-	kIC5=\E[2;5~, kIC6=\E[2;6~, kIC7=\E[2;7~, kNXT3=\E[6;3~,
-	kNXT4=\E[6;4~, kNXT5=\E[6;5~, kNXT6=\E[6;6~,
-	kNXT7=\E[6;7~, kPRV3=\E[5;3~, kPRV4=\E[5;4~,
-	kPRV5=\E[5;5~, kPRV6=\E[5;6~, kPRV7=\E[5;7~,
-	use=xterm+edit,
+	kNXT=\E[6;2~, kPRV=\E[5;2~, kDC3=\E[3;3~, kDC4=\E[3;4~,
+	kDC5=\E[3;5~, kDC6=\E[3;6~, kDC7=\E[3;7~, kEND3=\E[1;3F,
+	kEND4=\E[1;4F, kEND5=\E[1;5F, kEND6=\E[1;6F,
+	kEND7=\E[1;7F, kHOM3=\E[1;3H, kHOM4=\E[1;4H,
+	kHOM5=\E[1;5H, kHOM6=\E[1;6H, kHOM7=\E[1;7H,
+	kIC3=\E[2;3~, kIC4=\E[2;4~, kIC5=\E[2;5~, kIC6=\E[2;6~,
+	kIC7=\E[2;7~, kNXT3=\E[6;3~, kNXT4=\E[6;4~,
+	kNXT5=\E[6;5~, kNXT6=\E[6;6~, kNXT7=\E[6;7~,
+	kPRV3=\E[5;3~, kPRV4=\E[5;4~, kPRV5=\E[5;5~,
+	kPRV6=\E[5;6~, kPRV7=\E[5;7~, use=xterm+edit,
 
 xterm+edit|fragment for 6-key editing-keypad,
+	use=xterm+pc+edit, use=vt220+pcedit,
+
+xterm+decedit|fragment for vt220 6-key editing-keypad,
 	kdch1=\E[3~, kich1=\E[2~, knp=\E[6~, kpp=\E[5~,
-	use=xterm+pc+edit,
+	use=xterm+vt+edit,
 
 xterm+pc+edit|fragment for pc-style editing keypad,
 	kend=\E[4~, khome=\E[1~,
 
-xterm+vt+edit|fragment for vt220-style editing keypad,
+xterm+vt+edit|fragment for VT220-style editing keypad,
 	kfnd=\E[1~, kslt=\E[4~,
 
 # These variations for alternate-screen and title-stacking were introduced by
@@ -4914,6 +5174,9 @@ xterm+vt+edit|fragment for vt220-style editing keypad,
 xterm+noalt|xterm without altscreen,
 	rmcup@, smcup@,
 
+xterm+alt47|X11R4 alternate-screen,
+	rmcup=\E[2J\E[?47l\E8, smcup=\E7\E[?47h,
+
 xterm+alt1049|xterm 90 feature,
 	rmcup=\E[?1049l, smcup=\E[?1049h,
 
@@ -4938,22 +5201,34 @@ xterm+alt+title|xterm 90 and 251 features combined,
 #  | NumLock |    /    |    *    |    -    |
 #  |         |   $Oo   |   $Oj   |   $OS   |
 #  |_________|__kpDIV__|__kpMUL__|__kpSUB__|
-#  |    7         8         9    |         |
-#  |   $Ow   |   $Ox   |   $Oy   |    +    |
-#  |_ka1__K1_|_________|_ka3__K3_|   $Ok   |
-#  |    4    |    5    |    6    |  kpADD  |
+#  |    7         8         9    |    +    |
+#  |   $Ow   |   $Ox   |   $Oy   |   $Ok   |
+#  |_ka1__K1_|_________|_ka3__K3_|  kpADD  |
+#  |    4    |    5    |    6    |         |
 #  |   $Ot   |   $Ou   |   $Ov   |         |
 #  |_________|_kb2__K2_|_________|_________|
 #  |    1    |    2    |    3    |         |
 #  |   $Oq   |   $Or   |   $Os   |         |
 #  |_kc1__K4_|_________|_kc3__K5_|  enter  |
-#  |         0         |   .     |   $OM   |
-#  |        $Op        |  $On    |         |
-#  |___________________|_________|_kent_@8_|
+#  |         0         |    .    |   $OM   |
+#  |        $Op        |   $On   |         |
+#  |_______kpZRO_______|__kpDOT__|_kent_@8_|
+#
+# ka2, kb1, kb3 and kc2 are extensions, as are the mixed-case names.
+# There are no termcap equivalents for these extensions.
+#
+# kpCMA (comma) is used here for the VT100 keypad, which xterm emulates with
+# shifted-keypad-plus, though normally that invokes a font-size change.
+#
+# Old versions of xterm, e.g., xterm-xfree86, documented \EOE as kb2, which
+# does not fit into this layout.  The extension kp5 fits, but is not visible
+# to termcap applications.  As an alternative, kbeg (which does have a termcap
+# equivalent) is provided.
 #
 xterm+keypad|xterm emulating VT100/VT220 numeric keypad,
-	kp5=\EOE, kpADD=\EOk, kpCMA=\EOl, kpDIV=\EOo, kpDOT=\EOn,
-	kpMUL=\EOj, kpSUB=\EOm, kpZRO=\EOp, use=vt220+keypad,
+	kbeg=\EOE, kp5=\EOE, kpADD=\EOk, kpCMA=\EOl, kpDIV=\EOo,
+	kpDOT=\EOn, kpMUL=\EOj, kpSUB=\EOm, kpZRO=\EOp,
+	use=vt220+keypad,
 #
 # Those chunks use the new-style (the xterm oldFunctionKeys resource is false).
 # Alternatively, the same scheme with old-style function keys as in xterm-r6
@@ -4967,35 +5242,34 @@ xterm+r6f2|xterm with oldFunctionKeys and modifyFunctionKeys:2,
 	kf52=\E[14;3~, kf61=\E[11;4~, kf62=\E[12;4~,
 	kf63=\E[13;4~, use=xterm+pcf2,
 #
+xterm+acs|ISO-2022 alternate character-switching for xterm,
+	acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
+	enacs@, rmacs=\E(B, smacs=\E(0,
+
 # This chunk is used for building the VT220/Sun/PC keyboard variants.
 xterm-basic|modern xterm terminal emulator - common,
 	OTbs, am, bce, mir, msgr, xenl, AX, XT,
-	colors#8, cols#80, it#8, lines#24, pairs#64,
-	acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, clear=\E[H\E[2J,
-	cr=\r, csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m, dl=\E[%p1%dM,
-	dl1=\E[M, ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K,
+	colors#8, cols#80, lines#24, pairs#64,
+	bel=^G, clear=\E[H\E[2J, cr=\r, cub1=^H, cud1=\n,
+	cup=\E[%i%p1%d;%p2%dH, dch=\E[%p1%dP, dch1=\E[P,
+	dim=\E[2m, ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K,
 	flash=\E[?5h$<100/>\E[?5l, home=\E[H, hpa=\E[%i%p1%dG,
-	ht=^I, hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L,
-	ind=\n, invis=\E[8m, is2=\E[!p\E[?3;4l\E[4l\E>,
-	kmous=\E[M, meml=\El, memu=\Em, op=\E[39;49m, rc=\E8,
-	rev=\E[7m, ri=\EM, rmacs=\E(B, rmam=\E[?7l, rmir=\E[4l,
-	rmkx=\E[?1l\E>, rmso=\E[27m, rmul=\E[24m, rs1=\Ec,
-	rs2=\E[!p\E[?3;4l\E[4l\E>, sc=\E7, setab=\E[4%p1%dm,
-	setaf=\E[3%p1%dm,
+	ich=\E[%p1%d@, ind=\n, is2=\E[!p\E[?3;4l\E[4l\E>,
+	kmous=\E[M, meml=\El, memu=\Em, op=\E[39;49m, ri=\EM,
+	rmam=\E[?7l, rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[27m,
+	rmul=\E[24m, rs1=\Ec, rs2=\E[!p\E[?3;4l\E[4l\E>,
+	setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
 	setb=\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}
 	     %=%t3%e%p1%d%;m,
 	setf=\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}
 	     %=%t3%e%p1%d%;m,
 	sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p5%t;2%;%?%p2%t;4%;
 	    %?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m,
-	sgr0=\E(B\E[m, smacs=\E(0, smam=\E[?7h, smir=\E[4h,
-	smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g,
-	vpa=\E[%i%p1%dd, E3=\E[3J, use=ansi+pp, use=xterm+kbs,
-	use=xterm+alt+title, use=ansi+enq, use=att610+cvis,
+	sgr0=\E(B\E[m, smam=\E[?7h, smir=\E[4h, smkx=\E[?1h\E=,
+	vpa=\E[%i%p1%dd, E3=\E[3J, use=ansi+csr, use=ansi+enq,
+	use=ansi+idl, use=ansi+inittabs, use=ansi+local,
+	use=ansi+pp, use=ansi+sgrbold, use=xterm+kbs,
+	use=xterm+alt+title, use=att610+cvis, use=xterm+acs,
 	use=xterm+meta,
 
 xterm+meta|meta mode for xterm,
@@ -5016,7 +5290,7 @@ xterm-xi|xterm on XI Graphics Accelerated X under BSD/OS 3.1,
 # xterm also recognizes the control sequences for initc -TD
 xterm-16color|xterm with 16 colors like aixterm,
 	ccc,
-	initc=\E]4;%p1%d;rgb\:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*
+	initc=\E]4;%p1%d;rgb:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*
 	      %{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E\\,
 	use=xterm+osc104, use=ibm+16color, use=xterm-new,
 
@@ -5025,7 +5299,7 @@ xterm-16color|xterm with 16 colors like aixterm,
 xterm+256color|original xterm 256-color feature,
 	ccc,
 	colors#0x100, pairs#0x10000,
-	initc=\E]4;%p1%d;rgb\:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*
+	initc=\E]4;%p1%d;rgb:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*
 	      %{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E\\,
 	oc=\E]104\007,
 	setab=\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;
@@ -5041,10 +5315,10 @@ xterm+256color|original xterm 256-color feature,
 # The xterm FAQ gives some of the history:
 #	https://invisible-island.net/xterm/xterm.faq.html#color_by_number
 xterm+256color2|xterm 256-color feature,
-	setab=\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48
-	      \:5\:%p1%d%;m,
-	setaf=\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38\:
-	      5\:%p1%d%;m,
+	setab=\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48:
+	      5:%p1%d%;m,
+	setaf=\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38:5
+	      :%p1%d%;m,
 	use=xterm+256color,
 
 # xterm OSC 104 resets the color palette.  Using it as part of xterm+256color
@@ -5101,14 +5375,14 @@ xterm-88color|xterm with 88 colors,
 # is of interest only to the numerically illiterate), is compatible with other
 # terminal descriptions written for curses.  It relies upon the extended range
 # for numeric capabilities provided in ncurses 6.1:
-xterm+direct2|xterm with direct-color indexing,
+xterm+direct2|xterm with direct-color indexing (old building-block),
 	RGB,
 	colors#0x1000000, pairs#0x10000, CO#8,
 	initc@, op=\E[39;49m,
-	setab=\E[%?%p1%{8}%<%t4%p1%d%e48\:2\:%p1%{65536}%/%d\:%p1
-	      %{256}%/%{255}%&%d\:%p1%{255}%&%d%;m,
-	setaf=\E[%?%p1%{8}%<%t3%p1%d%e38\:2\:%p1%{65536}%/%d\:%p1
-	      %{256}%/%{255}%&%d\:%p1%{255}%&%d%;m,
+	setab=\E[%?%p1%{8}%<%t4%p1%d%e48:2:%p1%{65536}%/%d:%p1%{256}
+	      %/%{255}%&%d:%p1%{255}%&%d%;m,
+	setaf=\E[%?%p1%{8}%<%t3%p1%d%e38:2:%p1%{65536}%/%d:%p1%{256}
+	      %/%{255}%&%d:%p1%{255}%&%d%;m,
 	setb@, setf@,
 xterm-direct2|xterm with direct-color indexing (old),
 	use=xterm+direct2, use=xterm+titlestack, use=xterm,
@@ -5116,14 +5390,14 @@ xterm-direct2|xterm with direct-color indexing (old),
 # That in turn had a problem: in the original patch submitted for KDE konsole
 # in 2006, the submitter and the developer alike overlooked a "color space
 # identifier" parameter.  This version provides for that parameter:
-xterm+direct|xterm with direct-color indexing,
+xterm+direct|xterm with direct-color indexing (building-block),
 	RGB,
 	colors#0x1000000, pairs#0x10000, CO#8,
 	initc@, op=\E[39;49m,
-	setab=\E[%?%p1%{8}%<%t4%p1%d%e48\:2\:\:%p1%{65536}%/%d\:%p1
-	      %{256}%/%{255}%&%d\:%p1%{255}%&%d%;m,
-	setaf=\E[%?%p1%{8}%<%t3%p1%d%e38\:2\:\:%p1%{65536}%/%d\:%p1
-	      %{256}%/%{255}%&%d\:%p1%{255}%&%d%;m,
+	setab=\E[%?%p1%{8}%<%t4%p1%d%e48:2::%p1%{65536}%/%d:%p1
+	      %{256}%/%{255}%&%d:%p1%{255}%&%d%;m,
+	setaf=\E[%?%p1%{8}%<%t3%p1%d%e38:2::%p1%{65536}%/%d:%p1
+	      %{256}%/%{255}%&%d:%p1%{255}%&%d%;m,
 	setb@, setf@,
 xterm-direct|xterm with direct-color indexing,
 	use=xterm+direct, use=xterm,
@@ -5138,7 +5412,7 @@ mlterm-direct|mlterm with direct-color indexing,
 # that xterm's original implementation should have used colons for the
 # subparameter separators, but chose not to correct this in konsole.  As of
 # late 2017, konsole still accepts only the nonstandard semicolon delimiters.
-xterm+indirect|xterm with direct-color indexing (old),
+xterm+indirect|xterm with direct-color indexing (old legacy building-block),
 	RGB,
 	colors#0x1000000, pairs#0x10000,
 	initc@, op=\E[39;49m,
@@ -5149,9 +5423,9 @@ xterm+indirect|xterm with direct-color indexing (old),
 	setb@, setf@,
 konsole-direct|konsole with direct-color indexing,
 	use=xterm+indirect, use=konsole,
-st-direct|st with direct-color indexing,
+st-direct|simpleterm with direct-color indexing,
 	use=xterm+indirect, use=st,
-vte-direct|vte with direct-color indexing,
+vte-direct|VTE with direct-color indexing,
 	use=xterm+indirect, use=vte,
 # reportedly in Apple's Mohave (fall 2018), but untested -TD
 nsterm-direct|nsterm with direct-color indexing,
@@ -5182,31 +5456,31 @@ nsterm-direct|nsterm with direct-color indexing,
 # palette, though the intrusion of indexed colors on the direct-color space
 # would be more noticeable.
 
-xterm+direct16|xterm with direct-color indexing,
+xterm+direct16|xterm with direct-color indexing (16-color building-block),
 	CO#16,
-	setab=\E[%?%p1%{8}%<%t4%p1%d%e%?%p1%{16}%<%t%p1%{92}%+%e48\:
-	      2\:\:%p1%{65536}%/%d\:%p1%{256}%/%{255}%&%d\:%p1%{255}
-	      %&%d%;%;m,
-	setaf=\E[%?%p1%{8}%<%t3%p1%d%e%?%p1%{16}%<%t%p1%'R'%+%e38\:2
-	      \:\:%p1%{65536}%/%d\:%p1%{256}%/%{255}%&%d\:%p1%{255}
-	      %&%d%;%;m,
+	setab=\E[%?%p1%{8}%<%t4%p1%d%e%?%p1%{16}%<%t%p1%{92}%+%d%e48
+	      :2::%p1%{65536}%/%d:%p1%{256}%/%{255}%&%d:%p1%{255}%&
+	      %d%;%;m,
+	setaf=\E[%?%p1%{8}%<%t3%p1%d%e%?%p1%{16}%<%t%p1%'R'%+%d%e38:
+	      2::%p1%{65536}%/%d:%p1%{256}%/%{255}%&%d:%p1%{255}%&%d
+	      %;%;m,
 	setb@, setf@, use=xterm+direct,
 
 xterm-direct16|xterm with direct-colors and 16 indexed colors,
-	use=xterm, use=xterm+direct16,
+	use=xterm+direct16, use=xterm,
 
-xterm+direct256|xterm with direct-color indexing,
+xterm+direct256|xterm with direct-color indexing (256-color building-block),
 	CO#0x100,
 	setab=\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e%?
-	      %p1%{256}%<%t48;5;%p1%d%e48\:2\:\:%p1%{65536}%/%d\:%p1
-	      %{256}%/%{255}%&%d\:%p1%{255}%&%d%;%;m,
+	      %p1%{256}%<%t48;5;%p1%d%e48:2::%p1%{65536}%/%d:%p1
+	      %{256}%/%{255}%&%d:%p1%{255}%&%d%;%;m,
 	setaf=\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e%?
-	      %p1%{256}%<%t38;5;%p1%d%e38\:2\:\:%p1%{65536}%/%d\:%p1
-	      %{256}%/%{255}%&%d\:%p1%{255}%&%d%;%;m,
+	      %p1%{256}%<%t38;5;%p1%d%e38:2::%p1%{65536}%/%d:%p1
+	      %{256}%/%{255}%&%d:%p1%{255}%&%d%;%;m,
 	setb@, setf@, use=xterm+direct,
 
 xterm-direct256|xterm with direct-colors and 256 indexed colors,
-	use=xterm, use=xterm+direct256,
+	use=xterm+direct256, use=xterm,
 
 #### XTERM Features
 
@@ -5228,12 +5502,15 @@ xterm-direct256|xterm with direct-colors and 256 indexed colors,
 # Se resets the cursor style to the terminal power-on default.
 #
 # Cs and Cr set and reset the cursor colour.
-xterm+tmux|advanced xterm features used in tmux,
+xterm+tmux|advanced xterm features used in tmux (cursor style 2),
 	Cr=\E]112\007, Cs=\E]12;%p1%s\007,
 	Ms=\E]52;%p1%s;%p2%s\007, Se=\E[2 q, Ss=\E[%p1%d q,
+xterm+tmux2|advanced xterm features used in tmux,
+	Cr=\E]112\E\\, Cs=\E]12;%p1%s\E\\,
+	Ms=\E]52;%p1%s;%p2%s\E\\, Se=\E[ q, Ss=\E[%p1%d q,
 
 # This is another variant, for XFree86 4.0 xterm (T.Dickey)
-# This is an 8-bit version of xterm, which emulates DEC vt220 with ANSI color.
+# This is an 8-bit version of xterm, which emulates DEC VT220 with ANSI color.
 # To use it, your decTerminalID resource must be set to 200 or above.
 #
 #	HTS	\E H	\210
@@ -5244,7 +5521,6 @@ xterm+tmux|advanced xterm features used in tmux,
 xterm-8bit|xterm terminal emulator 8-bit controls (X Window System),
 	OTbs, am, bce, km, mc5i, mir, msgr, npc, xenl, AX,
 	colors#8, cols#80, it#8, lines#24, pairs#64,
-	acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
 	bel=^G, blink=\2335m, bold=\2331m, cbt=\233Z,
 	civis=\233?25l, clear=\233H\2332J,
 	cnorm=\233?25l\233?25h, cr=\r, csr=\233%i%p1%d;%p2%dr,
@@ -5269,9 +5545,8 @@ xterm-8bit|xterm terminal emulator 8-bit controls (X Window System),
 	kf9=\23320~, khome=\2331~, kich1=\2332~, kmous=\233M,
 	knp=\2336~, kpp=\2335~, mc0=\233i, mc4=\2334i, mc5=\2335i,
 	meml=\El, memu=\Em, op=\23339;49m, rc=\E8, rev=\2337m,
-	ri=\215, rmacs=\E(B, rmam=\233?7l, rmcup=\233?1049l,
-	rmir=\2334l, rmkx=\233?1l\E>, rmso=\23327m, rmul=\23324m,
-	rs1=\Ec,
+	ri=\215, rmam=\233?7l, rmcup=\233?1049l, rmir=\2334l,
+	rmkx=\233?1l\E>, rmso=\23327m, rmul=\23324m, rs1=\Ec,
 	rs2=\E[62"p\E\sG\233m\233?7h\E>\E7\233?1;3;4;6l\2334l\233r
 	    \E8,
 	sc=\E7, setab=\2334%p1%dm, setaf=\2333%p1%dm,
@@ -5281,70 +5556,79 @@ xterm-8bit|xterm terminal emulator 8-bit controls (X Window System),
 	     %{6}%=%t3%e%p1%d%;m,
 	sgr=\2330%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?
 	    %p7%t;8%;m%?%p9%t\E(0%e\E(B%;,
-	sgr0=\2330m\E(B, smacs=\E(0, smam=\233?7h,
-	smcup=\233?1049h, smir=\2334h, smkx=\233?1h\E=,
-	smso=\2337m, smul=\2334m, tbc=\2333g, u6=\233[%i%d;%dR,
-	u7=\E[6n, u8=\233[?%[;0123456789]c, u9=\E[c,
-	vpa=\233%i%p1%dd, use=xterm+kbs,
+	sgr0=\2330m\E(B, smam=\233?7h, smcup=\233?1049h,
+	smir=\2334h, smkx=\233?1h\E=, smso=\2337m, smul=\2334m,
+	tbc=\2333g, u6=\233[%i%d;%dR, u8=\233[?%[;0123456789]c,
+	vpa=\233%i%p1%dd, use=ansi+enq, use=xterm+acs,
+	use=xterm+kbs,
 
+# Note: normally xterm supports modified function-keys as described in
+#	XTerm - "Other" modified keys
+#	https://invisible-island.net/xterm/modified-keys.html
+#
+# However, xterm-hp, xterm-sco and xterm-sun assume no modifiers.  Here is
+# a simple script which demonstrates these descriptions:
+#	#!/bin/sh
+#	export TERM=xterm-$1
+#	xterm \
+#		-kt $1 \
+#		-fs 16 -fa mono \
+#		-title $TERM \
+#		-tn $TERM \
+#		-xrm '*modifyCursorKeys:-1' \
+#		-xrm '*modifyFunctionKeys:-1' \
+#		-e tack
+# e.g., "foo sun" if the script is named "foo" -TD
 xterm-hp|xterm with hpterm function keys,
-	kclr=\EJ, kcub1=\ED, kcud1=\EB, kcuf1=\EC, kcuu1=\EA,
-	kdch1=\EP, kend=\EF, kf1=\Ep, kf2=\Eq, kf3=\Er, kf4=\Es,
-	kf5=\Et, kf6=\Eu, kf7=\Ev, kf8=\Ew, khome=\Eh, kich1=\EQ,
-	knp=\ES, kpp=\ET, use=xterm+nofkeys,
+	kclr=\EJ, kdch1=\EP, kend=\EF, khome=\Eh, kich1=\EQ, knp=\ES,
+	kpp=\ET, use=hp+pfk-cr, use=vt52+arrows,
+	use=xterm+nofkeys, use=xterm+nopcfkeys,
 
 xterm-sco|xterm with SCO function keys,
-	kbeg=\E[E, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
-	kdch1=^?, kend=\E[F, kf1=\E[M, kf10=\E[V, kf11=\E[W,
-	kf12=\E[X, kf13=\E[Y, kf14=\E[Z, kf15=\E[a, kf16=\E[b,
-	kf17=\E[c, kf18=\E[d, kf19=\E[e, kf2=\E[N, kf20=\E[f,
-	kf21=\E[g, kf22=\E[h, kf23=\E[i, kf24=\E[j, kf25=\E[k,
-	kf26=\E[l, kf27=\E[m, kf28=\E[n, kf29=\E[o, kf3=\E[O,
-	kf30=\E[p, kf31=\E[q, kf32=\E[r, kf33=\E[s, kf34=\E[t,
-	kf35=\E[u, kf36=\E[v, kf37=\E[w, kf38=\E[x, kf39=\E[y,
-	kf4=\E[P, kf40=\E[z, kf41=\E[@, kf42=\E[[, kf43=\E[\\,
-	kf44=\E[], kf45=\E[\^, kf46=\E[_, kf47=\E[`, kf48=\E[{,
-	kf5=\E[Q, kf6=\E[R, kf7=\E[S, kf8=\E[T, kf9=\E[U, khome=\E[H,
+	kbeg=\E[E, kbs=^?, kdch1=^?, kend=\E[F, kf1=\E[M, kf10=\E[V,
+	kf11=\E[W, kf12=\E[X, kf13=\E[Y, kf14=\E[Z, kf15=\E[a,
+	kf16=\E[b, kf17=\E[c, kf18=\E[d, kf19=\E[e, kf2=\E[N,
+	kf20=\E[f, kf21=\E[g, kf22=\E[h, kf23=\E[i, kf24=\E[j,
+	kf25=\E[k, kf26=\E[l, kf27=\E[m, kf28=\E[n, kf29=\E[o,
+	kf3=\E[O, kf30=\E[p, kf31=\E[q, kf32=\E[r, kf33=\E[s,
+	kf34=\E[t, kf35=\E[u, kf36=\E[v, kf37=\E[w, kf38=\E[x,
+	kf39=\E[y, kf4=\E[P, kf40=\E[z, kf41=\E[@, kf42=\E[[,
+	kf43=\E[\\, kf44=\E[], kf45=\E[\^, kf46=\E[_, kf47=\E[`,
+	kf48=\E[{, kf5=\E[Q, kf6=\E[R, kf7=\E[S, kf8=\E[T, kf9=\E[U,
 	kich1=\E[L, kmous=\E[>M, knp=\E[G, kpp=\E[I,
-	use=xterm+nofkeys,
+	use=ansi+arrows, use=xterm+nofkeys,
 
 # The xterm-new description has all of the features, but is not completely
-# compatible with vt220.  If you are using a Sun or PC keyboard, set the
+# compatible with VT220.  If you are using a Sun or PC keyboard, set the
 # sunKeyboard resource to true:
 #	+ maps the editing keypad
 #	+ interprets control-function-key as a second array of keys, so a
-#	  12-fkey keyboard can support vt220's 20-fkeys.
+#	  12-fkey keyboard can support VT220's 20-fkeys.
 #	+ maps numeric keypad "+" to ",".
 #	+ uses DEC-style control sequences for the application keypad.
 #
-xterm-vt220|xterm emulating vt220,
+xterm-vt220|xterm emulating VT220,
 	npc,
-	kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
-	kend=\E[4~, kent=\EOM, kf10=\E[21~, kf11=\E[23~,
+	kcbt=\E[Z, kend=\E[4~, kf10=\E[21~, kf11=\E[23~,
 	kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, kf15=\E[28~,
 	kf16=\E[29~, kf17=\E[31~, kf18=\E[32~, kf19=\E[33~,
 	kf20=\E[34~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~,
-	kf8=\E[19~, kf9=\E[20~, khome=\E[1~, kich1=\E[2~,
-	kmous=\E[M, knp=\E[6~, kpp=\E[5~, nel=\EE, use=xterm+app,
-	use=xterm+edit, use=vt220+keypad, use=ecma+italics,
-	use=ecma+index, use=ansi+rep, use=ecma+strikeout,
-	use=xterm+sm+1006, use=xterm+tmux, use=ecma+italics,
-	use=xterm+keypad, use=xterm-basic,
+	kf8=\E[19~, kf9=\E[20~, khome=\E[1~, kmous=\E[M, nel=\EE,
+	use=xterm+app, use=xterm+edit, use=vt220+keypad,
+	use=ecma+italics, use=ecma+index, use=ansi+rep,
+	use=ecma+strikeout, use=xterm+focus, use=xterm+sm+1006,
+	use=xterm+tmux, use=xterm+keypad, use=xterm-basic,
 
-xterm-vt52|xterm emulating dec vt52,
-	cols#80, it#8, lines#24,
+xterm-vt52|xterm emulating DEC VT52,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, clear=\EH\EJ, cr=\r, cub1=\ED, cud1=\EB, cuf1=\EC,
-	cup=\EY%p1%' '%+%c%p2%' '%+%c, cuu1=\EA, ed=\EJ, el=\EK,
-	home=\EH, ht=^I, ind=\n, kcub1=\ED, kcud1=\EB, kcuf1=\EC,
-	kcuu1=\EA, nel=\r\n, ri=\EI, rmacs=\EG, smacs=\EF,
-	use=xterm+kbs, use=vt52+keypad,
+	clear=\EH\EJ, rmacs=\EG, smacs=\EF, use=xterm+kbs,
+	use=vt52+keypad, use=vt52-basic,
 
 xterm-noapp|xterm with cursor keys in normal mode,
 	rmcup@, rmkx=\E>, smcup@, smkx=\E=, use=xterm+noapp,
 	use=xterm,
 
-xterm-24|vs100|xterms|xterm terminal emulator (X Window System),
+xterm-24|vs100|xterms|xterm terminal emulator 24-line (X Window System),
 	lines#24, use=xterm-old,
 
 # This is xterm for ncurses.
@@ -5365,6 +5649,24 @@ xterm-utf8|xterm with no VT100 line-drawing in UTF-8 mode,
 #    window managers such as twm (and possibly window managers descended from
 #    it such as tvtwm, ctwm, and vtwm) track windows by icon-name. Thus, you
 #    don't want to mess with icon-name when using those window managers.
+# c) fsl ends the escape sequence begun by tsl.  Printable characters between
+#    those (probably) will appear in the window title.  Nonprintable characters
+#    may cause the escape sequence to end with an error.
+# d) the BEL (^G or \007) used in the original title-as-statusline came from 
+#    David J. MacKenzie's "pseudo-color" entry in 20 Apr 1995.  At that time
+#    xterm used BEL as the string-terminator rather than ST (\E\\).  Either
+#    BEL or ST has worked since xterm patch #28 in 1996, but most uses of
+#    this feature have been embedded in shell scripts.
+#
+# But that issue regarding the parameter for tsl means that applications may
+# not rely on it.  The SVr4 documentation says tsl will "move to status line,
+# column #1".  At the point in time when ESR added DJM's "pseudo-color" entry
+# with the split-up escape sequence for tsl/fsl, there were 65 entries using
+# tsl:
+#    32 used a parameter, matching the documentation (including x10term).
+#    21 used a parameterless control, exiting from the status line on ^M.
+#     6 used parameterless controls for tsl and fsl
+#     6 used a split-up escape sequence, e.g., the same approach.
 #
 # The extension "TS" is preferable, because it does not accept a parameter.
 # However, if you are using a non-extended terminfo, "TS" is not visible.
@@ -5374,8 +5676,11 @@ xterm+sl|access X title line and icon name,
 xterm+sl-twm|access X title line (pacify twm-descended window managers),
 	hs,
 	dsl=\E]2;\007, fsl=^G, tsl=\E]2;, TS=\E]2;,
+xterm+sl-alt|alternate access X title line,
+	hs,
+	dsl=\E]2;\E\\, fsl=\E\\, tsl=\E]2;, TS=\E]2;,
 
-# In contrast, this block can be used for a DEC vt320 and up.  There are two
+# In contrast, this block can be used for a DEC VT320 and up.  There are two
 # controls used.
 #
 # DECSASD (select active status display)
@@ -5403,7 +5708,7 @@ xterm+sl-twm|access X title line (pacify twm-descended window managers),
 #
 dec+sl|DEC VTxx status line,
 	eslok, hs,
-	dsl=\E[1$~, fsl=\E[0$}, tsl=\E[2$~\E[1$}\E[%i%p1%d`,
+	dsl=\E[0$~, fsl=\E[0$}, tsl=\E[2$~\E[1$}\E[%i%p1%d`,
 
 #
 # The following xterm variants don't depend on your base version
@@ -5421,6 +5726,33 @@ xterm-nic|xterm with ich/ich1 suppressed for non-curses programs,
 xterm1|xterm terminal emulator ignoring the alternate screen buffer,
 	rmcup@, smcup@, use=xterm,
 
+# https://invisible-island.net/xterm/xterm-paste64.html
+#
+# Bracketed paste was introduced by xterm patch #203 in May 2005, as part of a
+# larger feature for manipulating the clipboard selection.  Few terminals aside
+# from xterm fully implement the clipboard feature, but several copy this
+# detail.  The names for the extended capabilities here were introduced by vim
+# in January 2017, but used internally.  In 2023, vim patch 9.0.1117 is needed
+# to work with this change.
+bracketed+paste|xterm bracketed paste,
+	BD=\E[?2004l, BE=\E[?2004h, PE=\E[201~, PS=\E[200~,
+
+# https://invisible-island.net/xterm/xterm.log.html#xterm_354
+#
+# The response is a DSR sequence identifying the version: DCS > | text ST
+# For example:
+#	^[P>|XTerm(354)^[\
+report+version|Report xterm name and version (XTVERSION),
+	XR=\E[>0q, xr=\EP>\\|[ -~]+\E\\\\, use=report+da2,
+
+# Vim uses RV to denote the secondary device attributes.  Xterm documents the
+# - first parameter as the terminal type (extending it to VT100),
+# - the second as the patch number for xterm, and
+# - the third parameter as zero.
+# Other terminals may provide useful responses, though few are documented.
+report+da2|report secondary device attributes (DA2),
+	RV=\E[>c, rv=\E\\[[0-9]+;[0-9]+;[0-9]+c,
+
 #### XTERM Mouse
 # The xterm mouse protocol is used by other terminal emulators.
 # In this section, two extended capabilities are used to illustrate the mouse
@@ -5469,7 +5801,7 @@ xterm-x10mouse|X10 xterm mouse,
 # X11R4 (December 1989) added the control sequences document, listing the
 # control sequences for the X10/X11 protocols without descriptions.  It also
 # mentioned the "emacs" ("T") response.  Comments in button.c referred to the
-# X11 protocol as "DEC vt200 compatible", although DEC offered no such terminal.
+# X11 protocol as "DEC VT200 compatible", although DEC offered no such terminal.
 #
 # X11R5 (November 1993) gave a description of the mouse protocol.
 #
@@ -5502,17 +5834,32 @@ xterm-x11hilite|X11 mouse with highlight,
 
 # xterm patch #83 (1998/10/7), added Jason Bacon's changes to provide an
 # "any-event" mouse mode.
-xterm+sm+1002|xterm any-event mouse,
-	kmous=\E[M, XM=\E[?1002%?%p1%{1}%=%th%el%;,
-xterm-1002|xterm any-event mouse,
-	use=xterm+sm+1002, use=xterm,
+#
+# These building blocks incorporate later features as well:
+# xterm patch #224 (2007/2/11) added private mode 1004, for enabling/disabling
+# focus in/out event reporting.
+# xterm patch #277 (2012/01/07) added private mode 1006
 
-xterm+sm+1003|testing xterm-mouse,
-	kmous=\E[M, XM=\E[?1003%?%p1%{1}%=%th%el%;,
+xterm+sm+1002|xterm any-button mouse,
+	kmous=\E[<, XM=\E[?1006;1004;1002%?%p1%{1}%=%th%el%;,
+	xm=\E[<%i%p3%d;%p1%d;%p2%d;%?%p4%tM%em%;,
+	use=xterm+focus,
+xterm-1002|example of xterm any-button mouse,
+	use=xterm+sm+1002, use=xterm,
 
-xterm-1003|testing xterm-mouse,
+xterm+sm+1003|xterm any-event mouse,
+	XM=\E[?1006;1004;1003%?%p1%{1}%=%th%el%;,
+	use=xterm+sm+1002,
+xterm-1003|example of xterm any-event mouse,
 	use=xterm+sm+1003, use=xterm,
 
+# Some terminal emulators implement xterm focus in/out, but do it incorrectly,
+# interfering with user applications.
+# https://lists.gnu.org/archive/html/bug-ncurses/2023-10/msg00087.html
+xterm+focus|xterm focus-in/out event "keys",
+	XF,
+	fd=\E[?1004l, fe=\E[?1004h, kxIN=\E[I, kxOUT=\E[O,
+
 # xterm patch #116 (1999/9/25) added Stephen P Wall's changes to support DEC
 # locator mode.
 
@@ -5526,7 +5873,7 @@ xterm-1003|testing xterm-mouse,
 # where the coordinates in the mouse response would be encoded in UTF-8,
 # thereby extending the range of coordinates past 222=(255-33).  This is the
 # "1005" mouse mode.
-xterm+sm+1005|xterm UTF-8 mouse,
+xterm+sm+1005|xterm UTF-8 mouse (building block),
 	kmous=\E[M, XM=\E[?1005;1000%?%p1%{1}%=%th%el%;,
 	xm=\E[M%?%p4%t3%e%p3%'\s'%+%c%;%p2%'!'%+%u%p1%'!'%+%u,
 xterm-1005|xterm UTF-8 mouse,
@@ -5543,12 +5890,19 @@ xterm-1005|xterm UTF-8 mouse,
 # As an alternative (and fixing the longstanding limitation of X11 mouse
 # protocol regarding button-releases), I provided the 1006 mode, referring
 # to it as "SGR 1006" since the replies resemble the SGR control string:
-xterm+sm+1006|xterm SGR-mouse,
+xterm+sm+1006|xterm SGR-mouse (building block),
 	kmous=\E[<, XM=\E[?1006;1000%?%p1%{1}%=%th%el%;,
 	xm=\E[<%i%p3%d;%p1%d;%p2%d;%?%p4%tM%em%;,
 xterm-1006|xterm SGR-mouse,
 	use=xterm+sm+1006, use=xterm,
 
+# Some terminal emulators implement xterm focus in/out, but do it incorrectly,
+# interfering with user applications.
+# https://lists.gnu.org/archive/html/bug-ncurses/2023-10/msg00087.html
+oldxterm+sm+1006|xterm SGR-mouse (building block),
+	kmous=\E[<, XM=\E[?1006;1000%?%p1%{1}%=%th%el%;,
+	xm=\E[<%i%p3%d;%p1%d;%p2%d;%?%p4%tM%em%;,
+
 #### KTERM
 # (kterm: this had extension capabilities ":KJ:TY=ascii:" -- esr)
 # (kterm should not invoke DEC Graphics as the alternate character set
@@ -5557,15 +5911,14 @@ xterm-1006|xterm SGR-mouse,
 #  -- MATSUMOTO Shoji)
 # kterm implements acsc via built-in table of X Drawable's
 kterm|kterm kanji terminal emulator (X window system),
-	eslok, hs, XT,
+	XT,
 	ncv@,
-	acsc=``aajjkkllmmnnooppqqrrssttuuvvwwxx~~,
-	csr=\E[%i%p1%d;%p2%dr, dsl=\E[?H, enacs=, fsl=\E[?F,
-	kmous=\E[M, rc=\E8, rmacs=\E(B, rmam=\E[?7l, sc=\E7,
+	acsc=``aajjkkllmmnnooppqqrrssttuuvvwwxx~~, enacs=,
+	rmacs=\E(B, rmam=\E[?7l,
 	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;m%?%p9%t\E(0%e
 	    \E(B%;,
-	sgr0=\E[m\E(B, smacs=\E(0, smam=\E[?7h,
-	tsl=\E[?E\E[?%i%p1%dT, use=xterm-r6, use=ecma+color,
+	sgr0=\E[m\E(B, smacs=\E(0, smam=\E[?7h, use=x10term+sl,
+	use=xterm-r6, use=ecma+color,
 kterm-color|kterm-co|kterm with ANSI colors,
 	ncv@, use=kterm, use=ecma+color,
 
@@ -5578,34 +5931,31 @@ xtermm|xterm terminal emulator (monochrome),
 	OTbs, am, km, mir, msgr, xenl,
 	btns#3, cols#80, it#8, lines#24,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, blink@, bold=\E[1m, clear=\E[H\E[2J, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=\E[D,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J,
-	el=\E[K, el1=\E[1K$<3>, enacs=\E(B\E)0, getm=\E[%p1%dY,
-	home=\E[H, ht=^I, hts=\EH, ich=\E[%p1%d@, ich1=\E[@,
-	il=\E[%p1%dL, il1=\E[L, ind=\n, kbs=^H, kcub1=\EOD,
-	kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kend=\E[Y, kf0=\EOy,
-	kf10=\EOY, kf11=\EOZ, kf12=\EOA, kf5=\EOT, kf6=\EOU,
-	kf7=\EOV, kf8=\EOW, kf9=\EOX, khome=\E[H, kmous=\E[^_,
-	knp=\E[U, kpp=\E[V, rc=\E8, reqmp=\E[492Z, rev=\E[7m, ri=\EM,
-	rmacs=^O, rmcup=\E@0\E[?4r, rmso=\E[m,
+	bel=^G, blink@, bold=\E[1m, clear=\E[H\E[2J, cr=\r, cud1=\n,
+	dch=\E[%p1%dP, dch1=\E[P, el1=\E[1K$<3>, enacs=\E(B\E)0,
+	getm=\E[%p1%dY, ht=^I, hts=\EH, ich=\E[%p1%d@, ich1=\E[@,
+	ind=\n, kend=\E[Y, kf0=\EOy, kf10=\EOY, kf11=\EOZ, kf12=\EOA,
+	kf5=\EOT, kf6=\EOU, kf7=\EOV, kf8=\EOW, kf9=\EOX, khome=\E[H,
+	kmous=\E[^_, knp=\E[U, kpp=\E[V, reqmp=\E[492Z, rev=\E[7m,
+	ri=\EM, rmacs=^O, rmcup=\E@0\E[?4r,
 	rs1=\E>\E[1;3;4;5;6l\E[?7h\E[m\E[r\E[2J\E[H,
-	rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, sc=\E7,
+	rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h,
 	sgr=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5
 	    %;m%?%p9%t\016%e\017%;,
 	sgr0=\E[m\017, smacs=^N, smcup=\E@0\E[?4s\E[?4h\E@1,
-	smso=\E[7m, tbc=\E[3g, use=vt100+fnkeys,
+	tbc=\E[3g, use=ansi+apparrows, use=ansi+csr,
+	use=ansi+cup, use=ansi+erase, use=ansi+idl,
+	use=ansi+local, use=ansi+sgrso, use=decid+cpr,
+	use=vt100+fnkeys,
 
 xtermc|xterm terminal emulator (color),
-	colors#8, ncv#7, pairs#64,
-	op=\E[100m, setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
+	ncv#7,
+	op=\E[100m,
 	setb=\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}
 	     %=%t3%e%p1%d%;m,
 	setf=\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}
 	     %=%t3%e%p1%d%;m,
-	use=xtermm,
+	use=xtermm, use=klone+color,
 
 # From: David J. MacKenzie <djm@va.pubnix.com> 20 Apr 1995
 # Here's a termcap entry I've been using for xterm_color, which comes
@@ -5619,8 +5969,25 @@ xterm-pcolor|xterm with color used for highlights and status line,
 	    %t;7;31%;%?%p3%t;7;34%;m,
 	smso=\E[7;31m, smul=\E[4;42m, use=xterm+sl, use=xterm-r6,
 
+# This was mentioned
+#	http://unix.stackexchange.com/questions/119/colors-in-man-pages
+# pointing to
+#	http://nion.modprobe.de/blog/archives/569-colored-manpages.html
+#	(blog posting by Nico Golde, June 24 2007)
+# archive:
+#	https://web-beta.archive.org/web/20070921042430/http://nion.modprobe.de/mostlike.txt
+# The comment hints where it started, but there are differences:
+#	Reconstructed via infocmp from file: /usr/share/terminfo/x/xterm-pcolor
+mostlike|manpages with color looking like most,
+	OTbs@,
+	bold=\E[1m\E[31m,
+	is2=\E7\E[r\E[m\E[?7h\E[?1;3;4;6l\E[4l\E8\E>, kbs=^H,
+	meml@, memu@, rev=\E[7m\E[34m,
+	rs2=\E7\E[r\E8\E[m\E[?7h\E[?1;3;4;6l\E[4l\E>, sgr@,
+	smso=\E[1;30m\E[47m, smul=\E[32m, TS@, use=xterm-pcolor,
+
 # This describes the capabilities of color_xterm, an xterm variant from
-# before ECMA-64 color support was folded into the main-line xterm release.
+# before ECMA-48 color support was folded into the main-line xterm release.
 # This entry is straight from color_xterm's maintainer.
 # From: Jacob Mandelson <jlm@ugcs.caltech.edu>, 09 Nov 1996
 # The README's with the distribution also say that it supports SGR 21, 24, 25
@@ -5629,28 +5996,52 @@ color_xterm|cx|cx100|color_xterm color terminal emulator for X,
 	OTbs, am, km, mir, msgr, xenl, XT,
 	cols#80, it#8, lines#65, ncv@,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, bold=\E[1m, clear=\E[H\E[2J, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J,
+	bel=^G, bold=\E[1m, clear=\E[H\E[2J, cr=\r, cub1=^H, cud1=\n,
+	cup=\E[%i%p1%d;%p2%dH, dch=\E[%p1%dP, dch1=\E[P, ed=\E[J,
 	el=\E[K, el1=\E[1K, enacs=\E(B\E)0, home=\E[H, ht=^I,
-	ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L, ind=\n,
-	is1=\E[r\E[m\E[?7h\E[?4;6l\E[4l, kbs=^H, kcub1=\EOD,
-	kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kend=\E[8~, kf1=\E[11~,
-	kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf2=\E[12~,
-	kf3=\E[13~, kf4=\E[14~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~,
-	kf8=\E[19~, kf9=\E[20~, khome=\E[7~, kich1=\E[2~,
-	kmous=\E[M, knp=\E[6~, kpp=\E[5~, rc=\E8, rev=\E[7m, ri=\EM,
-	rmacs=^O, rmam=\E[?7l, rmcup=\E>\E[?41;1r, rmir=\E[4l,
-	rmso=\E[27m, rmul=\E[24m,
+	ich=\E[%p1%d@, ind=\n, is1=\E[r\E[m\E[?7h\E[?4;6l\E[4l,
+	kend=\E[8~, kf1=\E[11~, kf10=\E[21~, kf11=\E[23~,
+	kf12=\E[24~, kf2=\E[12~, kf3=\E[13~, kf4=\E[14~,
+	kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~,
+	khome=\E[7~, kich1=\E[2~, kmous=\E[M, knp=\E[6~, kpp=\E[5~,
+	rev=\E[7m, ri=\EM, rmacs=^O, rmam=\E[?7l,
+	rmcup=\E>\E[?41;1r, rmir=\E[4l, rmso=\E[27m, rmul=\E[24m,
 	rs1=\E(B\017\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l\E<,
-	sc=\E7,
 	sgr=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5
 	    %;m%?%p9%t\016%e\017%;,
 	sgr0=\E[0m\017, smacs=^N, smam=\E[?7h,
 	smcup=\E[?1;41s\E[?1;41h\E=, smir=\E[4h, smso=\E[7m,
-	smul=\E[4m, use=ecma+color, use=vt220+keypad,
+	smul=\E[4m, use=ansi+apparrows, use=ansi+csr,
+	use=ansi+idl, use=ansi+local, use=decid+cpr,
+	use=ecma+color, use=vt220+keypad,
+
+# The IRAF source has a terminfo using "xterm-r5", but line-drawing does not
+# work in that case.  This entry uses xterm+acs, to work around that problem.
+#
+# Home/end keys do not work, due to a bug in the X Consortium xterm on which
+# this is based:
+#
+#	https://invisible-island.net/xterm/xterm.faq.html#bug_xterm_r6
+#
+# Comparing to the X11R5 source, xgterm has dynamic and ANSI colors (probably
+# not bce).  It interchanges mouse buttons 2/3 for menus.
+#
+# It also has a few features found in later versions of xterm:
+# - vi-button and dired-button,
+# - i18n stuff like X11R6.
+# - colorBD, colorUL
+# - scrollBarRight
+#
+# Debian provides a package for xgterm (and iraf).  Although the source for
+# xgterm implements the control-sequences for ANSI color, the packaged xgterm
+# does nothing with those, even after installing the app-defaults file which
+# was overlooked by the Debian packager.
+xgterm|graphic terminal for IRAF,
+	enacs=\E(B\E)0, rmacs=^O,
+	sgr=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;m%?%p9%t
+	    \016%e\017%;,
+	sgr0=\E[m\017, smacs=^N, use=xterm+acs, use=xterm-r5,
+	use=xterm+keypad,
 
 # The 'nxterm' distributed with Redhat Linux 5.2 is a slight rehack of
 # xterm-sb_right-ansi-3d, which implements ANSI colors, but does not support
@@ -5675,8 +6066,7 @@ xterm-color|nxterm|generic color xterm,
 # with their Sun keyboard labels instead.
 # From: Simon J. Gerraty <sjg@zen.void.oz.au> 10 Jan 1996
 xterm-sun|xterm with sunFunctionKeys true,
-	kb2=\E[218z, kcpy=\E[197z, kcub1=\EOD, kcud1=\EOB,
-	kcuf1=\EOC, kcuu1=\EOA, kdch1=\E[3z, kend=\E[220z,
+	kb2=\E[218z, kcpy=\E[197z, kdch1=\E[3z, kend=\E[220z,
 	kent=\EOM, kf1=\E[224z, kf10=\E[233z, kf11=\E[192z,
 	kf12=\E[193z, kf13=\E[194z, kf14=\E[195z, kf15=\E[196z,
 	kf17=\E[198z, kf18=\E[199z, kf19=\E[200z, kf2=\E[225z,
@@ -5687,25 +6077,27 @@ xterm-sun|xterm with sunFunctionKeys true,
 	kf5=\E[228z, kf6=\E[229z, kf7=\E[230z, kf8=\E[231z,
 	kf9=\E[232z, kfnd=\E[200z, khlp=\E[196z, khome=\E[214z,
 	kich1=\E[2z, knp=\E[222z, kpp=\E[216z, kund=\E[195z,
-	use=xterm+nofkeys,
+	use=xterm+kbs, use=ansi+apparrows, use=xterm+nofkeys,
+	use=xterm+nopcfkeys,
+
 xterms-sun|small (80x24) xterm with sunFunctionKeys true,
-	cols#80, lines#24, use=xterm-sun,
+	use=xterm-sun,
 
 #### GNOME (VTE)
-# this describes the alpha-version of Gnome terminal shipped with Redhat 6.0
-gnome-rh62|Gnome terminal,
+# this describes the alpha-version of GNOME terminal shipped with Redhat 6.0
+gnome-rh62|GNOME terminal,
 	bce,
 	kdch1=^?, kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS,
-	use=xterm-color,
+	use=linux+kbs, use=xterm-color,
 
 # GNOME Terminal 1.4.0.4 (Redhat 7.2)
 #
-# This implements a subset of vt102 with a random selection of features from
+# This implements a subset of VT102 with a random selection of features from
 # other terminals such as color and function-keys.
 #
 # shift-f1 to shift-f10 are f11 to f20
 #
-# NumLock changes the application keypad to approximate vt100 keypad, except
+# NumLock changes the application keypad to approximate VT100 keypad, except
 # that there is no escape sequence matching comma (,).
 #
 # Other defects observed:
@@ -5716,20 +6108,19 @@ gnome-rh62|Gnome terminal,
 #	vt100 TBC (tab reset) is not implemented.
 #	xterm alternate screen controls do not restore cursor position properly
 #	it hangs in tack after running function-keys test.
-gnome-rh72|GNOME Terminal,
+gnome-rh72|GNOME Terminal in RedHat 7,
 	bce, km@,
-	kdch1=\E[3~, kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS,
-	rmam=\E[?7l,
+	kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, rmam=\E[?7l,
 	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;m%?%p9%t\016%e
 	    \017%;,
 	sgr0=\E[0m\017, smam=\E[?7h, tbc@, use=vt220+cvis,
-	use=xterm-color,
+	use=linux+kbs, use=xterm-color,
 
 # GNOME Terminal 2.0.1 (Redhat 8.0)
 #
-# Documentation now claims it implements vt220 (which is demonstrably false).
-# However, it does implement ECH, which is a vt220 feature.  And there are
-# workable vt100 LNM, DECALN, DECSNM modes, making it possible to display
+# Documentation now claims it implements VT220 (which is demonstrably false).
+# However, it does implement ECH, which is a VT220 feature.  And there are
+# workable VT100 LNM, DECALN, DECSNM modes, making it possible to display
 # more of its bugs using vttest.
 #
 # However, note that bce and msgr are broken in this release.  Tabs (tbc and
@@ -5738,24 +6129,23 @@ gnome-rh72|GNOME Terminal,
 # kf1 and kf10 are not tested since they're assigned (hardcoded?) to menu
 # operations.  Shift-tab generates a distinct sequence so it can be argued
 # that it implements kcbt.
-gnome-rh80|GNOME Terminal,
+gnome-rh80|GNOME Terminal in RedHat 8,
 	bce@, msgr@,
-	ech=\E[%p1%dX, flash=\E[?5h$<100/>\E[?5l, kbs=^?,
-	kcbt=\E^I, op=\E[39;49m, use=gnome-rh72,
+	ech=\E[%p1%dX, flash=\E[?5h$<100/>\E[?5l, kcbt=\E^I,
+	op=\E[39;49m, use=gnome-rh72,
 
 # GNOME Terminal 2.2.1 (Redhat 9.0)
 #
 # bce and msgr are repaired.
-gnome-rh90|GNOME Terminal,
+gnome-rh90|GNOME Terminal in RedHat 9,
 	bce, msgr, XT,
-	hpa=\E[%i%p1%dG, kDC=\E[3;2~, kLFT=\EO2D, kRIT=\EO2C,
-	kb2=\E[E, kcbt=\E[Z, kend=\EOF, khome=\EOH, tbc=\E[3g,
-	vpa=\E[%i%p1%dd, use=xterm+pcf0, use=xterm+pcfkeys,
-	use=gnome-rh80,
+	hpa=\E[%i%p1%dG, kLFT=\EO2D, kRIT=\EO2C, kb2=\E[E,
+	kcbt=\E[Z, tbc=\E[3g, vpa=\E[%i%p1%dd, use=xterm+pcf0,
+	use=xterm+pcfkeys, use=gnome-rh80,
 
 # GNOME Terminal 2.14.2 (Fedora Core 5)
 # Ed Catmur notes that gnome-terminal has recognized soft-reset since May 2002.
-gnome-fc5|GNOME Terminal,
+gnome-fc5|GNOME Terminal in Fedora Core 5,
 	rs1=\Ec,
 	rs2=\E7\E[r\E8\E[m\E[?7h\E[!p\E[?1;3;4;6l\E[4l\E>\E[?1000l
 	    \E[?25h,
@@ -5776,9 +6166,9 @@ gnome-2007|GNOME Terminal snapshot 2.18.1,
 
 # GNOME Terminal 2.22.3 (2008 snapshot)
 #
-# In vttest, it claims to be a vt220 with national replacement character-sets,
+# In vttest, it claims to be a VT220 with national replacement character-sets,
 # but aside from the identifier string, implements only a small fraction of
-# vt220's behavior, which will make it less usable on a VMS system (unclear
+# VT220's behavior, which will make it less usable on a VMS system (unclear
 # what the intent of the developer is, since the NRC feature exposed in vttest
 # by this change does not work).
 vte-2008|VTE in GNOME Terminal snapshot 2.22.3,
@@ -5819,15 +6209,14 @@ gnome-2012|GNOME Terminal 3.6.0,
 #
 # The parameters with \EO (SS3) are technically an error, since SS3 should have
 # no parameters.  This appears to be rote copying based on xterm+pcc0.
-vte+pcfkeys|VTE's variation on xterm+pcfkeys,
-	kf1=\EOP, kf13=\EO1;2P, kf14=\EO1;2Q, kf15=\EO1;2R,
-	kf16=\EO1;2S, kf2=\EOQ, kf25=\EO1;5P, kf26=\EO1;5Q,
-	kf27=\EO1;5R, kf28=\EO1;5S, kf3=\EOR, kf37=\EO1;6P,
-	kf38=\EO1;6Q, kf39=\EO1;6R, kf4=\EOS, kf40=\EO1;6S,
+vte+pcfkeys|VTE's variation on xterm+pcfkeys (building block),
+	kf13=\EO1;2P, kf14=\EO1;2Q, kf15=\EO1;2R, kf16=\EO1;2S,
+	kf25=\EO1;5P, kf26=\EO1;5Q, kf27=\EO1;5R, kf28=\EO1;5S,
+	kf37=\EO1;6P, kf38=\EO1;6Q, kf39=\EO1;6R, kf40=\EO1;6S,
 	kf49=\EO1;3P, kf50=\EO1;3Q, kf51=\EO1;3R, kf52=\EO1;3S,
 	kf61=\EO1;4P, kf62=\EO1;4Q, kf63=\EO1;4R,
 	use=xterm+pcfkeys,
-gnome+pcfkeys|VTE's variation on xterm+pcfkeys,
+gnome+pcfkeys|GHOME Terminal's variation on xterm+pcfkeys (building block),
 	use=vte+pcfkeys,
 
 # deprecated - use "vte" for newer versions
@@ -5857,12 +6246,13 @@ vte-2014|VTE 0.35.1,
 	ncv@,
 	cbt=\E[Z, el1=\E[1K, flash=\E[?5h$<100/>\E[?5l,
 	ich=\E[%p1%d@, kent=\EOM, use=ecma+index,
-	use=xterm+sm+1006, use=xterm+pcfkeys, use=vte-2012,
+	use=oldxterm+sm+1006, use=xterm+pcfkeys, use=vte-2012,
+	use=bracketed+paste,
 
 # As of January 2018, this was the  most recent release,
 # e.g., with gnome-terminal 3.26.2
 vte-2017|VTE 0.50.2,
-	use=ecma+strikeout, use=vte-2014,
+	E3=\E[3J, use=ecma+strikeout, use=vte-2014,
 
 # VTE 0.51.2 and gnome-terminal 3.28.2 copied a feature from KovId's TTY
 # late in 2017 for changing the appearance of underlines, which was
@@ -5870,9 +6260,24 @@ vte-2017|VTE 0.50.2,
 # 2018, respectively. Overline (Smol/Rmol) has been supported since December
 # 2017.
 vte-2018|VTE 0.51.2,
-	Rmol=\E[55m, Smol=\E[53m, Smulx=\E[4\:%p1%dm,
+	AX,
+	blink=\E[5m, enacs=\E(B\E)0, nel=\EE,
+	rep=%p1%c\E[%p2%{1}%-%db,
+	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p4%t;5%;%?%p5%t;2%;%?%p7%t;
+	    8%;%?%p1%p3%|%t;7%;m%?%p9%t\016%e\017%;,
+	Rmol=\E[55m, Se=\E[1 q, Smol=\E[53m, Smulx=\E[4:%p1%dm,
+	use=xterm+alt+title, use=xterm+tmux, use=kitty+setal,
 	use=vte-2017,
 
+# Summarizing as of March 2022, these terminfo-capabilities of xterm are
+# absent from VTE:
+# - DEC application keypad mode
+# - DEC-compatible status-line
+# - DEC left/right margin support
+# - DEC printer controls
+# - AT&T cursor-blinking
+# - meta mode, as documented in terminfo(5)
+# - xterm's extension to clear scrollback
 vte|VTE aka GNOME Terminal,
 	use=vte-2018,
 
@@ -5888,6 +6293,29 @@ vte-256color|VTE with xterm 256-colors,
 xfce|Xfce Terminal,
 	use=vte-2008,
 
+# HTERM
+#
+# https://hterm.org
+#
+# A terminal written in JavaScript, which can provide xterm-like terminal
+# emulation in a browser such as Google Chrome, or in Chome OS.
+#
+# https://chromium.googlesource.com/apps/libapps/+/master/nassh/doc/FAQ.md
+#
+# Tested with Secure Shell App version 0.39 in Chrome 89.0.4389.90, found that
+# the numeric keypad escapes are missing -TD
+hterm|Chromium hterm,
+	npc,
+	U8#1,
+	kcbt=\E[Z, kent=\EOM, nel=\EE, use=linux+kbs,
+	use=xterm+osc104, use=ecma+index, use=ansi+rep,
+	use=ecma+strikeout, use=vt420+lrmm, use=xterm+focus,
+	use=xterm+sm+1006, use=xterm+tmux, use=ecma+italics,
+	use=xterm+pcfkeys, use=xterm-basic,
+	use=bracketed+paste,
+hterm-256color|Chromium hterm with xterm 256-colors,
+	use=xterm+256color2, use=hterm,
+
 # TERMITE
 #
 # https://github.com/thestinger/termite
@@ -5909,32 +6337,30 @@ xfce|Xfce Terminal,
 # trimmed to eliminate those.  Also, since it is a slightly older version of
 # VTE, it lacks a few more features (again, trimmed).
 termite|VTE-based terminal,
-	am, ccc, km, mir, msgr, npc, xenl,
-	cols#80, it#8, lines#24, ncv@,
+	am, km, mir, msgr, npc, xenl,
+	cols#80, lines#24, ncv@,
 	acsc=++\,\,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxy
 	     yzz{{||}}~~,
-	bel=^G, bold=\E[1m, cbt=\E[Z, clear=\E[H\E[2J, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP, ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K,
-	flash=\E[?5h$<100/>\E[?5l, home=\E[H, hpa=\E[%i%p1%dG,
-	ht=^I, hts=\EH, ind=\n, invis=\E[8m,
+	bel=^G, bold=\E[1m, clear=\E[H\E[2J, cr=\r, cub1=^H, cud1=\n,
+	cup=\E[%i%p1%d;%p2%dH, ech=\E[%p1%dX, ed=\E[J, el=\E[K,
+	el1=\E[1K, flash=\E[?5h$<100/>\E[?5l, home=\E[H,
+	hpa=\E[%i%p1%dG, ind=\n, invis=\E[8m,
 	is2=\E[!p\E[?3;4l\E[4l\E>, kb2=\EOE, kbs=^?, kcbt=\E[Z,
-	kent=\EOM, kmous=\E[M, rc=\E8, rev=\E[7m, ri=\EM, rmacs=\E(B,
+	kent=\EOM, kmous=\E[M, rev=\E[7m, ri=\EM, rmacs=\E(B,
 	rmam=\E[?7l, rmkx=\E[?1l\E>, rmso=\E[27m, rmul=\E[24m,
-	rs1=\Ec, rs2=\E[!p\E[?3;4l\E[4l\E>, sc=\E7,
+	rs1=\Ec, rs2=\E[!p\E[?3;4l\E[4l\E>,
 	sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|
 	    %t;7%;%?%p7%t;8%;m,
 	sgr0=\E(B\E[m, smacs=\E(0, smam=\E[?7h, smkx=\E[?1h\E=,
-	smso=\E[7m, smul=\E[4m, tbc=\E[3g, vpa=\E[%i%p1%dd,
-	use=xterm+alt1049, use=ecma+index, use=ansi+idc,
-	use=ansi+idl, use=ansi+enq, use=ecma+italics,
-	use=xterm+256color, use=ecma+color, use=vt220+cvis,
-	use=xterm+pcfkeys, use=xterm+sl-twm,
+	smso=\E[7m, smul=\E[4m, vpa=\E[%i%p1%dd, use=ansi+csr,
+	use=ansi+enq, use=ansi+idc, use=ansi+idl,
+	use=ansi+inittabs, use=ecma+index, use=ecma+italics,
+	use=ansi+local, use=xterm+alt1049, use=xterm+256color,
+	use=ecma+color, use=vt220+cvis, use=xterm+pcfkeys,
+	use=xterm+sl-twm,
 
 #### Other GNOME
-# Multi-Gnome-Terminal 1.6.2
+# Multi-GNOME-Terminal 1.6.2
 #
 # This does not use VTE, and does have different behavior (compare xfce and
 # gnome).
@@ -5946,7 +6372,8 @@ mgt|Multi GNOME Terminal,
 # or not is debatable).
 kvt|KDE terminal,
 	bce, km@,
-	kdch1=^?, kend=\E[F, khome=\E[H, use=xterm-color,
+	kdch1=^?, kend=\E[F, khome=\E[H, use=linux+kbs,
+	use=xterm-color,
 
 # Konsole 1.0.1 (2001/11/25)
 # (formerly known as kvt)
@@ -5963,18 +6390,18 @@ kvt|KDE terminal,
 #    konsole.  Some features such as the 1049 private mode are recognized but
 #    incorrectly implemented as a duplicate of the 47 private mode.
 # b) even with the "vt100 (historical)" keyboard setting, the numeric keypad
-#    sends PC-style escapes rather than vt100.
+#    sends PC-style escapes rather than VT100.
 # c) fails vttest menu 3 (Test of character sets) because it does not properly
 #    parse some control sequences.  Also fails vttest Primary Device Attributes
 #    by sending a bogus code (in the source it says it's supposed to be a
-#    vt220, which is doubly incorrect because it does not implement vt220
+#    VT220, which is doubly incorrect because it does not implement VT220
 #    control sequences except for a few special cases).  Treat it as a
-#    mildly-broken vt102.
+#    mildly-broken VT102.
 #
 # Update for konsole 1.3.2:
 #    The 1049 private mode works (but see the other xterm screens in vttest).
-#    Primary Device Attributes now returns the code for a vt100 with advanced
-#    video option.  Perhaps that's intended to be a "mildly-broken vt102".
+#    Primary Device Attributes now returns the code for a VT100 with advanced
+#    video option.  Perhaps that's intended to be a "mildly-broken Vt102".
 #
 # Updated for konsole 1.6.4:
 #    add konsole-solaris
@@ -5984,7 +6411,7 @@ kvt|KDE terminal,
 #
 # Updated for konsole 2.3 (October 2008):
 #    vttest menu 1 shows that both konsole and gnome terminal do wrapping
-#    different from xterm (and vt100's).  They have the same behavior in
+#    different from xterm (and VT100's).  They have the same behavior in
 #    this detail, but it is unclear which copies the other.
 #
 # Deferred update for konsole 2.10 (late 2012):
@@ -6001,22 +6428,23 @@ kvt|KDE terminal,
 #
 # Re-enable "bel", since it is latent in the source-code even though KDE config
 # often hides the feature (2020/5/30)
-konsole-base|KDE console window,
+konsole-base|KDE console window (common),
 	bce, km@, npc, XT,
 	ncv@,
-	blink=\E[5m, dim=\E[2m, ech=\E[%p1%dX,
-	flash=\E[?5h$<100/>\E[?5l, hpa=\E[%i%p1%dG,
-	invis=\E[8m, kbs=^?, kdch1=\E[3~, kend=\E[4~, kf1@, kf10@,
-	kf11@, kf12@, kf13@, kf14@, kf15@, kf16@, kf17@, kf18@, kf19@, kf2@,
-	kf20@, kf3@, kf4@, kf5@, kf6@, kf7@, kf8@, kf9@, kfnd@, khome=\E[1~,
-	kslt@, rmam=\E[?7l, rmso=\E[27m, rmul=\E[24m, rs1=\Ec,
+	ech=\E[%p1%dX, flash=\E[?5h$<100/>\E[?5l,
+	hpa=\E[%i%p1%dG, kend=\E[4~, kf1@, kf10@, kf11@, kf12@, kf13@,
+	kf14@, kf15@, kf16@, kf17@, kf18@, kf19@, kf2@, kf20@, kf3@, kf4@,
+	kf5@, kf6@, kf7@, kf8@, kf9@, kfnd@, khome=\E[1~, kslt@,
+	rmam=\E[?7l, rmso=\E[27m, rmul=\E[24m, rs1=\Ec,
 	rs2=\E7\E[r\E8\E[m\E[?7h\E[?1;3;4;6l\E[4l\E>\E[?1000l\E[?25h,
 	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?
 	    %p5%t;2%;%?%p7%t;8%;m%?%p9%t\016%e\017%;,
 	sgr0=\E[0m\017, smam=\E[?7h, vpa=\E[%i%p1%dd,
-	use=ecma+index, use=xterm+sm+1006, use=ecma+strikeout,
+	use=ansi+sgrdim, use=ecma+index, use=xterm+focus,
+	use=xterm+sm+1006, use=ecma+strikeout,
 	use=ecma+italics, use=ecma+color, use=xterm-r6,
-	use=vt220+cvis,
+	use=vt220+cvis, use=bracketed+paste,
+	use=report+version,
 
 # The keytab feature was introduced in 0.9.12 (February 2000) with "linux" and
 # "vt100" key-table files along with a compiled-in default key-table.
@@ -6073,7 +6501,7 @@ konsole-base|KDE console window,
 #
 # As of 2018, konsole still provides 3 keyboard profiles ("XFree 4", "linux",
 # "solaris").
-konsole-linux|KDE console window with linux keyboard,
+konsole-linux|KDE console window with Linux keyboard,
 	kf1=\E[[A, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13@,
 	kf14@, kf15@, kf16@, kf17@, kf18@, kf19@, kf2=\E[[B, kf20@,
 	kf3=\E[[C, kf4=\E[[D, kf5=\E[[E, kf6=\E[17~, kf7=\E[18~,
@@ -6101,17 +6529,17 @@ konsole+pcfkeys|konsole subset of xterm+pcfkeys,
 # KDE's "vt100" keyboard has no relationship to any terminal that DEC made, but
 # it is still useful for deriving the other entries, since the developer
 # provided function-keys based on xterm.
-konsole-vt100|KDE console window with vt100 (sic) keyboard,
-	kbs=^?, kdch1=\E[3~, kend=\E[F, kf1=\E[11~, kf10=\E[21~,
-	kf11=\E[23~, kf12=\E[24~, kf13@, kf14@, kf15@, kf16@, kf17@,
-	kf18@, kf19@, kf2=\E[12~, kf20@, kf3=\E[13~, kf4=\E[14~,
-	kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~,
-	khome=\E[H, use=konsole-base,
+konsole-vt100|KDE console window with VT100 (sic) keyboard,
+	kend=\E[F, kf1=\E[11~, kf10=\E[21~, kf11=\E[23~,
+	kf12=\E[24~, kf13@, kf14@, kf15@, kf16@, kf17@, kf18@, kf19@,
+	kf2=\E[12~, kf20@, kf3=\E[13~, kf4=\E[14~, kf5=\E[15~,
+	kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, khome=\E[H,
+	use=konsole-base,
 
 # Obsolete: vt420pc.keytab was added in June 2000, dropped from the install in
 # September 2008 and removed in June 2016.  The developer who removed it stated
 # that it was never installed.
-konsole-vt420pc|KDE console window with vt420 pc keyboard,
+konsole-vt420pc|KDE console window with VT420 PC keyboard,
 	kbs=^H, kdch1=^?, use=konsole-vt100,
 
 # make a default entry for konsole
@@ -6165,7 +6593,7 @@ mlterm|multi lingual terminal emulator,
 # mlterm 3.x made further changes, but they were not reflected in the included
 # mlterm.ti (which was dropped in 2015).  This entry has been based on testing
 # with ncurses, tack and vttest -TD
-mlterm3|multi lingual terminal emulator,
+mlterm3|multi lingual terminal emulator 3.x,
 	bce, AX,
 	blink=\E[5m, flash=\E[?5h$<100/>\E[?5l, invis=\E[8m,
 	is2=\E[!p\E[?3;4l\E>, rs2=\E[!p\E[?3;4l\E>,
@@ -6175,11 +6603,12 @@ mlterm3|multi lingual terminal emulator,
 	use=ecma+strikeout, use=xterm+app, use=xterm+pcf2,
 	use=xterm+pcc2, use=xterm+pce2, use=xterm+meta,
 	use=xterm+alt+title, use=xterm+sm+1006,
-	use=vt100+pfkeys, use=mlterm2,
+	use=vt100+pfkeys, use=bracketed+paste, use=mlterm2,
+	use=report+version,
 
 # This is mlterm 2.9.3's mlterm.ti, with some additions/corrections -TD
 #
-# It is nominally a vt102 emulator, with features borrowed from rxvt and
+# It is nominally a VT102 emulator, with features borrowed from rxvt and
 # xterm.
 #
 # The function keys are numbered based on shift/control/alt modifiers, except
@@ -6196,39 +6625,35 @@ mlterm3|multi lingual terminal emulator,
 #	control/alt		kf1 to kf12	\E[11;7~ to \E[24;7~
 #	control/shift/alt	kf1 to kf12	\E[11;8~ to \E[24;8~
 #
-mlterm2|multi lingual terminal emulator,
+mlterm2|multi lingual terminal emulator 2.x,
 	am, eslok, km, mc5i, mir, msgr, npc, xenl, XT,
-	colors#8, cols#80, it#8, lines#24, pairs#64,
+	colors#8, cols#80, lines#24, pairs#64,
 	acsc=00``aaffgghhjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, bold=\E[1m, cbt=\E[Z, clear=\E[H\E[2J, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M,
+	bel=^G, bold=\E[1m, clear=\E[H\E[2J, cr=\r, cub1=^H, cud1=\n,
+	cup=\E[%i%p1%d;%p2%dH, dch=\E[%p1%dP, dch1=\E[P,
 	ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K, enacs=,
-	home=\E[H, hpa=\E[%i%p1%dG, ht=^I, hts=\EH, ich=\E[%p1%d@,
-	il=\E[%p1%dL, il1=\E[L, ind=\n,
+	home=\E[H, hpa=\E[%i%p1%dG, ich=\E[%p1%d@, ind=\n,
 	is2=\E7\E[r\E[m\E[?7h\E[?1;3;4;6l\E[4l\E8\E>, kbs=^?,
-	kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
-	kend=\EOF, kent=\EOM, khome=\EOH, kind=\EO1;2B, kmous=\E[M,
-	kri=\EO1;2A, mc0=\E[i, nel=\EE, op=\E[39;49m, rc=\E8,
-	rev=\E[7m, ri=\EM, rmacs=\E(B, rmam=\E[?7l, rmir=\E[4l,
+	kcbt=\E[Z, kend=\EOF, kent=\EOM, kind=\EO1;2B, kmous=\E[M,
+	kri=\EO1;2A, mc0=\E[i, nel=\EE, op=\E[39;49m, rev=\E[7m,
+	ri=\EM, rmacs=\E(B, rmam=\E[?7l, rmir=\E[4l,
 	rmkx=\E[?1l\E>, rmso=\E[27m, rmul=\E[24m, rs1=\Ec,
 	rs2=\E7\E[r\E8\E[m\E[?7h\E[?1;3;4;6l\E[4l\E>\E[?1000l,
-	sc=\E7, setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
+	setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
 	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;m%?%p9%t\E(0%e
 	    \E(B%;,
 	sgr0=\E[m\E(B, smacs=\E(0, smam=\E[?7h, smir=\E[4h,
-	smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g,
-	u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?1;2c, u9=\E[c,
-	vpa=\E[%i%p1%dd, use=vt220+vtedit, use=xterm+alt1049,
+	smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, u8=\E[?1;2c,
+	vpa=\E[%i%p1%dd, use=ansi+apparrows, use=ansi+csr,
+	use=ansi+enq, use=ansi+idl, use=ansi+inittabs,
+	use=ansi+local, use=vt220+vtedit, use=xterm+alt1049,
 	use=ecma+index, use=mlterm+pcfkeys, use=vt220+cvis,
 	use=xterm+r6f2,
 
 # The insert/delete/home/end keys do not respond to modifiers because mlterm
 # looks in its termcap to decide which string to send.  If it used terminfo
 # (when available), it could use the extended names introduced for xterm.
-mlterm+pcfkeys|fragment for PC-style fkeys,
+mlterm+pcfkeys|mlterm fragment for PC-style fkeys,
 	kLFT=\EO1;2D, kNXT=\E[6;2~, kPRV=\E[5;2~, kRIT=\EO1;2C,
 	kDN=\EO1;2B, kDN3=\EO1;3B, kDN4=\EO1;4B, kDN5=\EO1;5B,
 	kDN6=\EO1;6B, kDN7=\EO1;7B, kIC5=\E[2;5~, kIC6=\E[2;6~,
@@ -6265,30 +6690,25 @@ mlterm-256color|mlterm 3.0 with xterm 256-colors,
 # removed dch/dch1 because they are inconsistent with bce/ech -TD
 # remove km as per tack test -TD
 rxvt-basic|rxvt terminal base (X Window System),
-	OTbs, am, bce, eo, mir, msgr, xenl, xon, XT,
-	cols#80, it#8, lines#24,
-	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[2J, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K, el1=\E[1K,
-	enacs=\E(B\E)0, flash=\E[?5h$<100/>\E[?5l, home=\E[H,
-	ht=^I, hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L,
-	ind=\n, is1=\E[?47l\E=\E[?1l,
-	is2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l, kbs=^H,
-	kcbt=\E[Z, kmous=\E[M, rc=\E8, rev=\E[7m, ri=\EM, rmacs=^O,
-	rmcup=\E[2J\E[?47l\E8, rmir=\E[4l, rmkx=\E>, rmso=\E[27m,
-	rmul=\E[24m,
+	OTbs, bce, eo, mir, xenl, xon, XT,
+	blink=\E[5m, bold=\E[1m, clear=\E[H\E[2J, cub1=^H, cud1=\n,
+	cup=\E[%i%p1%d;%p2%dH, ed=\E[J, el=\E[K, el1=\E[1K,
+	flash=\E[?5h$<100/>\E[?5l, ich=\E[%p1%d@,
+	is1=\E[?47l\E=\E[?1l,
+	is2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l,
+	kcbt=\E[Z, kmous=\E[M, rev=\E[7m, ri=\EM, rmir=\E[4l,
+	rmkx=\E>, rmso=\E[27m, rmul=\E[24m,
 	rs1=\E>\E[1;3;4;5;6l\E[?7h\E[m\E[r\E[2J\E[H,
 	rs2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l\E>\E[?1000l\E[?
 	    25h,
-	s0ds=\E(B, s1ds=\E(0, sc=\E7,
+	s0ds=\E(B, s1ds=\E(0,
 	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m%?
 	    %p9%t\016%e\017%;,
-	sgr0=\E[0m\017, smacs=^N, smcup=\E7\E[?47h, smir=\E[4h,
-	smkx=\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g, use=vt100+enq,
+	sgr0=\E[0m\017, smir=\E[4h, smkx=\E=, smso=\E[7m,
+	smul=\E[4m, use=ansi+csr, use=ansi+idl, use=ansi+local,
+	use=xterm+alt47, use=vt100+enq, use=vt100+4bsd,
 	use=rxvt+pcfkeys, use=vt220+cvis, use=vt220+keypad,
+
 # Key Codes from rxvt reference:
 #
 # Note: Shift + F1-F10 generates F11-F20
@@ -6369,26 +6789,22 @@ rxvt-basic|rxvt terminal base (X Window System),
 #
 # kDN, kDN5, kDN6, etc are extensions based on the names from xterm+pcfkeys -TD
 # Removed kDN6, etc (control+shift) since rxvt does not implement this -TD
-rxvt+pcfkeys|fragment for PC-style fkeys,
+rxvt+pcfkeys|rxvt fragment for PC-style fkeys,
 	kDC=\E[3$, kEND=\E[8$, kHOM=\E[7$, kIC=\E[2$, kLFT=\E[d,
 	kNXT=\E[6$, kPRV=\E[5$, kRIT=\E[c, kcub1=\E[D, kcud1=\E[B,
-	kcuf1=\E[C, kcuu1=\E[A, kel=\E[8\^, kend=\E[8~, kf1=\E[11~,
-	kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[25~,
-	kf14=\E[26~, kf15=\E[28~, kf16=\E[29~, kf17=\E[31~,
-	kf18=\E[32~, kf19=\E[33~, kf2=\E[12~, kf20=\E[34~,
+	kcuf1=\E[C, kcuu1=\E[A, kel=\E[8\^, kend=\E[8~,
 	kf21=\E[23$, kf22=\E[24$, kf23=\E[11\^, kf24=\E[12\^,
 	kf25=\E[13\^, kf26=\E[14\^, kf27=\E[15\^, kf28=\E[17\^,
-	kf29=\E[18\^, kf3=\E[13~, kf30=\E[19\^, kf31=\E[20\^,
-	kf32=\E[21\^, kf33=\E[23\^, kf34=\E[24\^, kf35=\E[25\^,
-	kf36=\E[26\^, kf37=\E[28\^, kf38=\E[29\^, kf39=\E[31\^,
-	kf4=\E[14~, kf40=\E[32\^, kf41=\E[33\^, kf42=\E[34\^,
-	kf43=\E[23@, kf44=\E[24@, kf5=\E[15~, kf6=\E[17~,
-	kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, khome=\E[7~, kind=\E[a,
-	kri=\E[b, kDC5=\E[3\^, kDC6=\E[3@, kDN=\E[b, kDN5=\EOb,
-	kEND5=\E[8\^, kEND6=\E[8@, kHOM5=\E[7\^, kHOM6=\E[7@,
-	kIC5=\E[2\^, kIC6=\E[2@, kLFT5=\EOd, kNXT5=\E[6\^,
-	kNXT6=\E[6@, kPRV5=\E[5\^, kPRV6=\E[5@, kRIT5=\EOc,
-	kUP=\E[a, kUP5=\EOa, use=vt220+vtedit,
+	kf29=\E[18\^, kf30=\E[19\^, kf31=\E[20\^, kf32=\E[21\^,
+	kf33=\E[23\^, kf34=\E[24\^, kf35=\E[25\^, kf36=\E[26\^,
+	kf37=\E[28\^, kf38=\E[29\^, kf39=\E[31\^, kf40=\E[32\^,
+	kf41=\E[33\^, kf42=\E[34\^, kf43=\E[23@, kf44=\E[24@,
+	khome=\E[7~, kind=\E[a, kri=\E[b, kDC5=\E[3\^, kDC6=\E[3@,
+	kDN=\E[b, kDN5=\EOb, kEND5=\E[8\^, kEND6=\E[8@,
+	kHOM5=\E[7\^, kHOM6=\E[7@, kIC5=\E[2\^, kIC6=\E[2@,
+	kLFT5=\EOd, kNXT5=\E[6\^, kNXT6=\E[6@, kPRV5=\E[5\^,
+	kPRV6=\E[5@, kRIT5=\EOc, kUP=\E[a, kUP5=\EOa,
+	use=vt220+vtedit, use=xterm+nopcfkeys,
 
 # rxvt was originally "xvt", first announced in April 1993:
 #	http://www.krsaborio.net/linux-desktops/research/1993/0416.html
@@ -6439,17 +6855,15 @@ rxvt+pcfkeys|fragment for PC-style fkeys,
 # Olesen (or possibly Davis) diverged in one respect from Linux's bce color
 # behavior: inserting/deleting characters does not fill the newly empty cell
 # with the default background color.
-rxvt|rxvt terminal emulator (X Window System),
+rxvt|rxvt-color|rxvt terminal emulator (X Window System),
 	ncv@,
 	hpa=\E[%i%p1%dG, kf0=\E[21~, sgr0=\E[m\017,
 	vpa=\E[%i%p1%dd, use=rxvt-basic, use=ecma+color,
-rxvt-color|rxvt terminal emulator (X Window System),
-	use=rxvt,
 rxvt-256color|rxvt 2.7.9 with xterm 256-colors,
 	use=xterm+256color, use=rxvt,
 rxvt-88color|rxvt 2.7.9 with xterm 88-colors,
 	use=xterm+88color, use=rxvt,
-rxvt-xpm|rxvt terminal emulator (X Window System),
+rxvt-xpm|rxvt terminal emulator (X Window System with xpm),
 	use=rxvt,
 rxvt-cygwin|rxvt terminal emulator (X Window System) on cygwin,
 	acsc=+\257\,\256-\^0\333`\004a\261f\370g\361h\260j\331k
@@ -6481,7 +6895,7 @@ rxvt-16color|rxvt with 16 colors like aixterm,
 #	window collapses to a single line when running several of the screens
 #	in vttest, e.g., the tests for cursor movement, screen features,
 #	double-sized characters.
-# +	The vt52 test works properly, but this is an exception.  Due to the
+# +	The VT52 test works properly, but this is an exception.  Due to the
 #	other bug(s) most of vttest is untestable.
 # +	the color test using ECH shows a gap in the bce model, like rxvt.
 #
@@ -6490,7 +6904,6 @@ rxvt-16color|rxvt with 16 colors like aixterm,
 #	(not in rxvt, but not documented by mrxvt) but not CSI 19 t.
 # +	none of the "dynamic colors" (OSC colors) scripts work.
 mrxvt|multitabbed rxvt,
-	XT,
 	kEND=\E[8;2~, kHOM=\E[7;2~, kcub1=\E[D, kcud1=\E[B,
 	kcuf1=\E[C, kcuu1=\E[A, kend=\E[8~, khome=\E[7~,
 	kEND3=\E[8;3~, kEND4=\E[8;4~, kEND5=\E[8;5~,
@@ -6514,33 +6927,27 @@ mrxvt-256color|multitabbed rxvt with 256 colors,
 # remove nonworking flash -TD
 # remove km as per tack test -TD
 Eterm|Eterm-color|Eterm with xterm-style color support (X Window System),
-	am, bce, bw, eo, mc5i, mir, msgr, xenl, xon, XT,
-	btns#5, cols#80, it#8, lines#24, lm#0, ncv@,
-	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[2J, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\E[B, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M,
+	bce, bw, eo, mc5i, mir, xenl, xon, XT,
+	btns#5, lm#0, ncv@,
+	blink=\E[5m, bold=\E[1m, clear=\E[H\E[2J, cub1=^H,
+	cup=\E[%i%p1%d;%p2%dH, dch=\E[%p1%dP, dch1=\E[P,
 	ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K, enacs=\E)0,
-	home=\E[H, hpa=\E[%i%p1%dG, ht=^I, hts=\EH, ich=\E[%p1%d@,
-	il=\E[%p1%dL, il1=\E[L, ind=\n, is1=\E[?47l\E>\E[?1l,
+	hpa=\E[%i%p1%dG, ich=\E[%p1%d@, is1=\E[?47l\E>\E[?1l,
 	is2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l, kNXT@,
-	kPRV@, ka1=\E[7~, ka3=\E[5~, kb2=\EOu, kbeg=\EOu, kbs=^H,
-	kc1=\E[8~, kc3=\E[6~, kent=\EOM, khlp=\E[28~, kmous=\E[M,
-	mc4=\E[4i, mc5=\E[5i, rc=\E8, rev=\E[7m, ri=\EM, rmacs=^O,
-	rmam=\E[?7l, rmcup=\E[2J\E[?47l\E8, rmir=\E[4l, rmkx=,
+	kPRV@, ka1=\E[7~, ka3=\E[5~, kb2=\EOu, kbeg=\EOu, kc1=\E[8~,
+	kc3=\E[6~, kent=\EOM, khlp=\E[28~, kmous=\E[M, mc4=\E[4i,
+	mc5=\E[5i, rev=\E[7m, ri=\EM, rmam=\E[?7l, rmir=\E[4l, rmkx=,
 	rmso=\E[27m, rmul=\E[24m,
 	rs1=\E>\E[1;3;4;5;6l\E[?7h\E[m\E[r\E[2J\E[H,
 	rs2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l\E>\E[?1000l\E[?
 	    25h,
-	sc=\E7,
 	sgr=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5
 	    %;m%?%p9%t\016%e\017%;,
-	sgr0=\E[m\017, smacs=^N, smam=\E[?7h, smcup=\E7\E[?47h,
-	smir=\E[4h, smkx=, smso=\E[7m, smul=\E[4m, tbc=\E[3g,
-	vpa=\E[%i%p1%dd, use=vt100+enq, use=rxvt+pcfkeys,
-	use=ecma+color, use=vt220+cvis,
+	sgr0=\E[m\017, smam=\E[?7h, smir=\E[4h, smkx=, smso=\E[7m,
+	smul=\E[4m, vpa=\E[%i%p1%dd, use=ansi+csr, use=ansi+idl,
+	use=ansi+local, use=xterm+alt47, use=vt100+enq,
+	use=rxvt+pcfkeys, use=ecma+color, use=vt100+4bsd,
+	use=vt220+cvis,
 
 Eterm-256color|Eterm with xterm 256-colors,
 	use=xterm+256color, use=Eterm,
@@ -6560,27 +6967,24 @@ aterm|AfterStep terminal,
 # vttest shows several problems with keyboard, cursor-movements.
 # see also https://invisible-island.net/xterm/xterm.faq.html#bug_xiterm
 xiterm|internationalized terminal emulator for X,
-	km@,
-	kbs=^?, kdch1=\E[3~, use=klone+color, use=xterm-r6,
+	km@, use=klone+color, use=xterm-r6,
 
 
 #### HPTERM
 # HP ships this (HPUX 9 and 10), except for the pb#9600 which was merged in
 # from BSD termcap.  (hpterm:  added empty <acsc>, we have no idea what ACS
 # chars look like --esr)
-hpterm|X-hpterm|hp X11 terminal emulator,
+hpterm|X-hpterm|HP X11 terminal emulator (old),
 	am, da, db, mir, xhp, xon,
 	cols#80, lh#2, lines#24, lm#0, lw#8, nlab#8, pb#9600, xmc#0,
 	acsc=, bel=^G, bold=\E&dB, cbt=\Ei, clear=\E&a0y0C\EJ, cr=\r,
 	cub1=^H, cud1=\EB, cuf1=\EC, cup=\E&a%p1%dy%p2%dC,
 	cuu1=\EA, dch1=\EP, dim=\E&dH, dl1=\EM, ed=\EJ$<1>, el=\EK,
 	hpa=\E&a%p1%dC, ht=^I, hts=\E1, il1=\EL, ind=\n, kbs=^H,
-	kclr=\EJ, kctab=\E2, kcub1=\ED, kcud1=\EB, kcuf1=\EC,
-	kcuu1=\EA, kdch1=\EP, kdl1=\EM, ked=\EJ, kel=\EK, kf1=\Ep,
-	kf2=\Eq, kf3=\Er, kf4=\Es, kf5=\Et, kf6=\Eu, kf7=\Ev, kf8=\Ew,
-	khome=\Eh, khts=\E1, kich1=\EQ, kil1=\EL, kind=\ES, kll=\EF,
-	knp=\EU, kpp=\EV, kri=\ET, krmir=\ER, ktbc=\E3, meml=\El,
-	memu=\Em, pfkey=\E&f%p1%dk%p2%l%dL%p2%s,
+	kclr=\EJ, kctab=\E2, kdch1=\EP, kdl1=\EM, ked=\EJ, kel=\EK,
+	khts=\E1, kich1=\EQ, kil1=\EL, knp=\EU, kpp=\EV, krmir=\ER,
+	ktbc=\E3, meml=\El, memu=\Em,
+	pfkey=\E&f%p1%dk%p2%l%dL%p2%s,
 	pfloc=\E&f1a%p1%dk%p2%l%dL%p2%s,
 	pfx=\E&f2a%p1%dk%p2%l%dL%p2%s,
 	pln=\E&f%p1%dk%p2%l%dd0L%p2%s, rev=\E&dB, ri=\ET,
@@ -6590,7 +6994,7 @@ hpterm|X-hpterm|hp X11 terminal emulator,
 	    %p5%{8}%*%+%{64}%+%c%?%p9%t%'\016'%c%e%'\017'%c%;,
 	sgr0=\E&d@\017, smacs=^N, smir=\EQ, smkx=\E&s1A,
 	smln=\E&jB, smso=\E&dJ, smul=\E&dD, tbc=\E3,
-	vpa=\E&a%p1%dY,
+	vpa=\E&a%p1%dY, use=hp+pfk-cr, use=hp+arrows,
 # HPUX 11 provides a color version.
 hpterm-color|HP X11 terminal emulator with color,
 	ccc,
@@ -6599,6 +7003,54 @@ hpterm-color|HP X11 terminal emulator with color,
 	initp=\E&v%p2%da%p3%db%p4%dc%p5%dx%p6%dy%p7%dz%p1%dI,
 	op=\E&v0S, scp=\E&v%p1%dS, use=hpterm,
 
+# http://bitsavers.trailing-edge.com/pdf/hp/9000_hpux/1986/97089-90081_198611_Facilities_for_Series_200_300_and_500.pdf
+# http://bitsavers.trailing-edge.com/pdf/hp/9000_hpux/1987/97089-90081_198709_Facilities_for_Series_200_300_and_500_HP-UX_Concepts_and_Tutorials.pdf
+#
+# This article does not cover the HP 46020A keyboard that is used by the Model
+# 217 and 237 computers.  For information on this keyboard read the article,
+# "The Series 300 ITE as System Console" found in the manual, HP-UX Concepts
+# and Tutorials, Vol.  7. 
+#
+# Possibly:
+# http://bitsavers.trailing-edge.com/pdf/hp/9000_hpux/1986/97089-90042_198608_HP-UX_Concepts_and_Tutorials.pdf
+#
+# HP300_Series_ITE.pdf
+#
+# This version, which came from Martin Trusler, was tested with lynx using
+# ncurses 5.4
+hpterm-color2|X-hpterm-color2|HP X11 terminal emulator with color (new),
+	OTbs, am, ccc, da, db, km, mir, xhp,
+	colors#8, cols#80, it#8, lh#2, lines#24, lm#0, lw#8, nlab#8,
+	pairs#8, xmc#0,
+	acsc=+>\,<-\^.v0\374``a\374f\372g\376h\374j+k+l+m+n+o-q-s-t+
+	     u+v+w+x|y<z>{*|!}\273~\362,
+	bel=^G, bold=\E&dD, cbt=\Ei, clear=\EH\EJ, cr=\r, cub1=^H,
+	cud1=\EB, cuf1=\EC, cup=\E&a%p1%dy%p2%dC, cuu1=\EA,
+	dch1=\EP, dim=\E&dH, dl1=\EM, ed=\EJ$<1>, el=\EK,
+	home=\E&a0y0C, hpa=\E&a%p1%dC, ht=^I, hts=\E1, il1=\EL,
+	ind=\ES,
+	initp=\E&v0m%?%p2%{1000}%=%t1%e.%p2%d%;a%?%p3%{1000}%=%t1%e.
+	      %p3%d%;b%?%p4%{1000}%=%t1%e.%p4%d%;c%?%p5%{1000}%=%t1
+	      %e.%p5%d%;x%?%p6%{1000}%=%t1%e.%p6%d%;y%?%p7%{1000}%=
+	      %t1%e.%p7%d%;z%p1%dI,
+	is1=\EH\EJ, kbs=^H, kctab=\E2, kdch1=\EP, kdl1=\EM, ked=\EJ,
+	kel=\EK, khts=\E1, kich1=\EQ, kil1=\EL, knp=\EU, kpp=\EV,
+	krmir=\ER, ktbc=\E3, meml=\El, memu=\Em,
+	oc=\E&v0m1a1b1c0I\E&v1a1I\E&v1b2I\E&v1a1b3I\E&v1c4I\E&v1a1c5
+	   I\E&v1b1c6I\E&v1x1y7I,
+	op=\E&v0S, pfkey=\E&f%p1%dk%p2%l%dL%p2%s,
+	pfloc=\E&f1a%p1%dk%p2%l%dL%p2%s,
+	pfx=\E&f2a%p1%dk%p2%l%dL%p2%s,
+	pln=\E&f%p1%dk%p2%l%dd0L%p2%s, rev=\E&dB, ri=\ET,
+	rmacs=^O, rmam=\E&s1C, rmcup=\E&s0A, rmir=\ER, rmkx=\E&s0A,
+	rmln=\E&j@, rmm=\E&k0I, rmso=\E&d@, rmul=\E&d@, rs1=\EE,
+	scp=\E&v%p1%dS,
+	sgr=\E&d%p1%p3%|%{2}%*%p2%p6%|%{4}%*%+%p5%{8}%*%+%{64}%+%c%?
+	    %p9%t%'\016'%c%e%'\017'%c%;,
+	sgr0=\E&d@\017, smacs=^N, smam=\E&s0C, smcup=\E&s1A,
+	smir=\EQ, smkx=\E&s1A, smln=\E&jB, smm=\E&k1I, smso=\E&dB,
+	smul=\E&dD, tbc=\E3, vpa=\E&a%p1%dY, use=hp+pfk-cr,
+	use=hp+arrows,
 #### EMU
 # This is for the extensible terminal emulator on the X11R6 contrib tape.
 # It corresponds to emu's internal emulation:
@@ -6632,7 +7084,7 @@ emu|emu native mode,
 	    %t\EU%;,
 	sgr0=\ES, smir=\EY, smso=\ET, smul=\EV, tbc=\Ej,
 
-# vt220 Terminfo entry for the Emu emulation, corresponds to
+# VT220 terminfo entry for the Emu emulation, corresponds to
 #	emu -term vt220
 # with NumLock set (to make the keypad transmit kf0-kf9).
 # fixes: add am, xenl, corrected sgr0 -TD
@@ -6641,28 +7093,27 @@ emu-220|Emu-220 (vt200-7bit mode),
 	cols#80, it#8, lines#24, vt#200,
 	acsc=aaffggjjkkllmmnnooqqssttuuvvwwxx~~, bel=^G,
 	blink=\E[0;5m, bold=\E[0;1m, clear=\E[2J\E[H, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=\E[1D,
-	cud=\E[%p1%dB, cud1=\E[1B, cuf=\E[%p1%dC, cuf1=\E[1C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[1A,
-	dch=\E[%p1%dP, dch1=\E[1P, dl=\E[%p1%dM, dl1=\E[1M,
-	ed=\E[0J, el=\E[0K, el1=\E[1K, enacs=\E)0, home=\E[H, ht=^I,
-	hts=\EH, if=/usr/share/tabset/vt300, il=\E[%p1%dL,
-	il1=\E[1L, ind=\ED, is2=\E>\E[?1l\E[?3l\E[4l\E[?7h,
-	kbs=^H, kcmd=\E[29~, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C,
+	cub1=\E[1D, cud1=\E[1B, cuf1=\E[1C,
+	cup=\E[%i%p1%d;%p2%dH, cuu1=\E[1A, dch=\E[%p1%dP,
+	dch1=\E[1P, dl=\E[%p1%dM, dl1=\E[1M, ed=\E[0J, el=\E[0K,
+	el1=\E[1K, enacs=\E)0, home=\E[H, ht=^I, hts=\EH,
+	if=/usr/share/tabset/vt300, il=\E[%p1%dL, il1=\E[1L,
+	ind=\ED, is2=\E>\E[?1l\E[?3l\E[4l\E[?7h, kbs=^H,
+	kcmd=\E[29~, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C,
 	kcuu1=\E[A, kent=\EOM, kf0=\EOp, kf1=\EOq, kf10=\EOl,
 	kf11=\EOm, kf12=\EOn, kf13=\EOP, kf14=\EOQ, kf15=\EOR,
 	kf16=\EOS, kf2=\EOr, kf26=\E[17~, kf27=\E[18~, kf28=\E[19~,
 	kf29=\E[20~, kf3=\EOs, kf30=\E[21~, kf34=\E[26~,
 	kf37=\E[31~, kf38=\E[32~, kf39=\E[33~, kf4=\EOt,
 	kf40=\E[34~, kf5=\EOu, kf6=\EOv, kf7=\EOw, kf8=\EOx,
-	kf9=\EOy, khlp=\E[28~, rc=\E8, rev=\E[0;7m, ri=\EM, rmacs=^O,
+	kf9=\EOy, khlp=\E[28~, rev=\E[0;7m, ri=\EM, rmacs=^O,
 	rmcup=\E>, rmkx=\E>, rmso=\E[m, rmul=\E[m,
-	rs2=\E[4l\E[34l\E[?1l\E[?3l\E[?5l\E[?7h, sc=\E7,
+	rs2=\E[4l\E[34l\E[?1l\E[?3l\E[?5l\E[?7h,
 	sgr=\E[0%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p5%t;
 	    2%;%?%p6%t;1%;%?%p7%t;8%;m%?%p9%t\016%e\017%;,
 	sgr0=\E[m\017, smacs=^N, smcup=\E[?1l\E=, smkx=\E=,
-	smso=\E[0;7m, smul=\E[0;4m, tbc=\E[3g, use=vt220+vtedit,
-	use=vt220+cvis,
+	smso=\E[0;7m, smul=\E[0;4m, tbc=\E[3g, use=ansi+csr,
+	use=ansi+local, use=vt220+vtedit, use=vt220+cvis,
 
 #### MVTERM
 # A commercial product, Reportedly a version of Xterm with an OPEN LOOK UI,
@@ -6676,29 +7127,21 @@ emu-220|Emu-220 (vt200-7bit mode),
 #	apparently implements alternate screen like xterm
 #	does not use padding, of course.
 mvterm|vv100|SwitchTerm aka mvTERM,
-	am, eslok, hs, km, mir, msgr, xenl, xon,
-	colors#8, cols#80, it#8, lines#24, pairs#64,
-	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[2J, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M,
-	dsl=\E[?E, ed=\E[J, el=\E[K, el1=\E[1K$<3>, enacs=\E(B\E)0,
-	fsl=\E[?F, home=\E[H, ht=^I, hts=\EH, ich=\E[%p1%d@,
-	ich1=\E[@, il=\E[%p1%dL, il1=\E[L, ind=\n, kbs=^H,
-	kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kf0=\EOy,
-	kf10=\EOx, kf5=\EOt, kf6=\EOu, kf7=\EOv, kf8=\EOl, kf9=\EOw,
-	op=\E[100m, rc=\E8, rev=\E[7m, ri=\EM, rmacs=^O,
-	rmcup=\E[2J\E[?47l\E8, rmkx=\E[?1l\E>, rmso=\E[m,
-	rmul=\E[m,
+	km, mir, xenl, xon,
+	colors#8, pairs#64,
+	blink=\E[5m, bold=\E[1m, clear=\E[H\E[2J, cub1=^H, cud1=\n,
+	cup=\E[%i%p1%d;%p2%dH, dch=\E[%p1%dP, dch1=\E[P, ed=\E[J,
+	el=\E[K, ich=\E[%p1%d@, ich1=\E[@, kcub1=\EOD, kcud1=\EOB,
+	kcuf1=\EOC, kcuu1=\EOA, op=\E[100m, rev=\E[7m, ri=\EM,
+	rmkx=\E[?1l\E>, rmso=\E[m, rmul=\E[m,
 	rs2=\E>\E[1;3;4;5;6l\E[?7h\E[100m\E[m\E[r\E[2J\E[H,
-	sc=\E7, setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
+	setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
 	sgr=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5
 	    %;m%?%p9%t\016%e\017%;,
-	sgr0=\E[m\017, smacs=^N, smcup=\E7\E[?47h,
-	smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g,
-	tsl=\E[?E\E[?%i%p1%dT, use=vt100+fnkeys,
+	sgr0=\E[m\017, smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m,
+	use=ansi+csr, use=ansi+idl, use=ansi+local,
+	use=xterm+alt47, use=vt100+fnkeys, use=vt100+4bsd,
+	use=x10term+sl,
 
 #### MTERM
 #
@@ -6709,19 +7152,16 @@ mterm-ansi|ANSI emulation,
 	am, bw, mir, msgr,
 	it#8,
 	acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[J, cr=\r,
-	cub=\E[%p1%dD, cub1=\E[D, cud=\E[%p1%dB, cud1=\E[B,
-	cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
-	cuu=\E[%p1%dA, cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[P,
-	dim=\E[2m, dl=\E[%p1%dM, dl1=\E[M, ech=\E[%p1%dX, ed=\E[J,
-	el=\E[K, home=\E[H, hpa=\E[%i%p1%d`, ht=^I, ich1=,
-	il=\E[%p1%dL, il1=\E[L, ind=\E[S, invis=\E[8m,
-	is2=\E)0\017, kbs=^H, nel=\EE, rev=\E[7m, ri=\E[T, rmacs=^O,
-	rmir=\E[4l, rmso=\E[27m, rmul=\E[24m,
+	bel=^G, cr=\r, cup=\E[%i%p1%d;%p2%dH, dch=\E[%p1%dP,
+	dim=\E[2m, ech=\E[%p1%dX, home=\E[H, hpa=\E[%i%p1%d`,
+	ht=^I, ich1=, ind=\E[S, is2=\E)0\017, kbs=^H, nel=\EE, ri=\E[T,
+	rmacs=^O, rmso=\E[27m, rmul=\E[24m,
 	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?
 	    %p5%t;2%;%?%p7%t;8%;m%?%p9%t\016%e\017%;,
-	sgr0=\E[m\017, smacs=^N, smir=\E[4h, smso=\E[7m,
-	smul=\E[4m, vpa=\E[%i%p1%dd, use=ecma+index,
+	sgr0=\E[m\017, smacs=^N, vpa=\E[%i%p1%dd, use=ansi+erase,
+	use=ansi+idc1, use=ansi+idl, use=ansi+local,
+	use=ansi+sgrbold, use=ecma+index,
+
 # mterm normally sets $TERM to "mterm"
 mterm|mouse-sun|Der Mouse term,
 	am, bw, mir,
@@ -6737,28 +7177,24 @@ decansi|ANSI emulation with DEC compatibility hacks,
 	am, mir, msgr, xenl,
 	colors#8, it#8, pairs#64,
 	acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[J, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=\E[D,
-	cud=\E[%p1%dB, cud1=\E[B, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m, dl=\E[%p1%dM,
-	dl1=\E[M, ech=\E[%p1%dX, ed=\E[J, el=\E[K, enacs=\E(B\E)0,
-	home=\E[H, hpa=\E[%i%p1%d`, ht=^I, ich1=, il=\E[%p1%dL,
-	il1=\E[L, ind=\E[S, invis=\E[8m, is2=\E)0\E[r\017, kbs=^H,
-	kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kf1=\E[11~,
-	kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[25~,
-	kf14=\E[26~, kf15=\E[28~, kf16=\E[29~, kf17=\E[31~,
-	kf18=\E[32~, kf19=\E[33~, kf2=\E[12~, kf20=\E[34~,
-	kf3=\E[13~, kf4=\E[14~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~,
-	kf8=\E[19~, kf9=\E[20~, nel=\EE, op=\E[0m, rc=\E8, rev=\E[7m,
-	ri=\E[T, rmacs=^O, rmam=\E[?7l, rmir=\E[4l, rmkx=\E[?1l\E>,
-	rmso=\E[27m, rmul=\E[24m, sc=\E7, setab=\E[4%p1%dm,
+	bel=^G, cr=\r, cup=\E[%i%p1%d;%p2%dH, dch=\E[%p1%dP,
+	dim=\E[2m, ech=\E[%p1%dX, enacs=\E(B\E)0, home=\E[H,
+	hpa=\E[%i%p1%d`, ht=^I, ich1=, ind=\E[S, is2=\E)0\E[r\017,
+	kbs=^H, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
+	kf1=\E[11~, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~,
+	kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, kf16=\E[29~,
+	kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, kf2=\E[12~,
+	kf20=\E[34~, kf3=\E[13~, kf4=\E[14~, kf5=\E[15~,
+	kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, nel=\EE,
+	op=\E[0m, ri=\E[T, rmacs=^O, rmam=\E[?7l, rmkx=\E[?1l\E>,
+	rmso=\E[27m, rmul=\E[24m, setab=\E[4%p1%dm,
 	setaf=\E[3%p1%dm,
 	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?
 	    %p5%t;2%;%?%p7%t;8%;m%?%p9%t\016%e\017%;,
-	sgr0=\E[m\017, smacs=^N, smam=\E[?7h, smir=\E[4h,
-	smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, u6=\E[%i%d;%dR,
-	u7=\E[6n, vpa=\E[%i%p1%dd, use=vt220+vtedit,
+	sgr0=\E[m\017, smacs=^N, smam=\E[?7h, smkx=\E[?1h\E=,
+	vpa=\E[%i%p1%dd, use=ansi+cpr, use=ansi+csr,
+	use=ansi+erase, use=ansi+idc1, use=ansi+idl,
+	use=ansi+local, use=ansi+sgrbold, use=vt220+vtedit,
 	use=ecma+index, use=vt220+cvis,
 
 #### VWM
@@ -6767,26 +7203,24 @@ decansi|ANSI emulation with DEC compatibility hacks,
 # VWM 2.0.2 (2009-05-01)
 # vwmterm is a terminal emulator written for the VWM console window manager.
 # This version is obsolete, replaced by libvterm in 2.1.0 (2009-10-23).
-vwmterm|(vwm term),
+vwmterm|VWM terminal,
 	am, bce, ccc, mir, msgr, npc, xenl, xon,
 	colors#8, pairs#64,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[J, cr=\r,
-	cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\E[B,
-	cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
-	cuu=\E[%p1%dA, cuu1=\E[A, cvvis=\E[?25h, dim=\E[2m,
-	ed=\E[J, el=\E[K, home=\E[H, il1=\E[L, ind=\n, invis=\E[8m,
+	bel=^G, bold=\E[1m, cr=\r, cub1=^H, cup=\E[%i%p1%d;%p2%dH,
+	cvvis=\E[?25h, dim=\E[2m, home=\E[H, il1=\E[L, ind=\n,
 	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
 	kdch1=\E[3~, kend=\E[4~, kf1=\E[[A, kf10=\E[21~,
 	kf11=\E[22~, kf12=\E[23~, kf2=\E[[B, kf3=\E[[C, kf4=\E[[D,
 	kf5=\E[[E, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~,
-	khome=\E[1~, knp=\E[6~, kpp=\E[5~, rev=\E[7m, rmacs=\E[10m,
+	khome=\E[1~, knp=\E[6~, kpp=\E[5~, rmacs=\E[10m,
 	rmam=\E[?7l, rs1=\E[H\E[J\E[m\Ec, setab=\E[4%p1%dm,
 	setaf=\E[3%p1%dm,
 	sgr=\E[0;10%?%p1%t;3%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p5
 	    %t;2%;%?%p6%t;1%;%?%p7%t;8%;%?%p9%t;11%;m,
 	sgr0=\E[0;10m, smacs=\E[11m, smam=\E[?7h, smso=\E[3m,
-	smul=\E[4m, use=vt220+cvis, use=xterm+alt1049,
+	smul=\E[4m, use=ansi+erase, use=ansi+local, use=ansi+sgr,
+	use=vt220+cvis, use=xterm+alt1049,
 
 #### MGR
 #
@@ -6825,7 +7259,7 @@ mgr-linux|Mgr window with Linux keyboard,
 #### SIMPLETERM
 # st.suckless.org
 
-st|stterm| simpleterm,
+st|stterm|aka simpleterm,
 	use=st-0.8,
 
 # Reviewed 0.8.2:
@@ -6840,15 +7274,13 @@ st|stterm| simpleterm,
 #
 # This entry discards the ccc/initc capabilities from st-0.7 because they
 # belong in st-256color.
-st-0.8|simpleterm 0.7,
-	dim=\E[2m, kcbt@, kent@, oc=\E]104\007,
-	sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|
-	    %t;7%;%?%p4%t;5%;%?%p5%t;2%;%?%p7%t;8%;m,
-	Ms=\E]52;%p1%s;%p2%s\007, kDN3=\E[1;3B, kDN5=\E[1;5B,
-	kLFT3=\E[1;3D, kLFT5=\E[1;5D, kNXT3=\E[6;3~,
-	kNXT5=\E[6;5~, kPRV3=\E[5;3~, kPRV5=\E[5;5~,
-	kRIT3=\E[1;3C, kRIT5=\E[1;5C, kUP3=\E[1;3A, kUP5=\E[1;5A,
-	use=ecma+strikeout, use=st-0.6,
+st-0.8|simpleterm 0.8,
+	kcbt@, kent@, oc=\E]104\007, Ms=\E]52;%p1%s;%p2%s\007,
+	kDN3=\E[1;3B, kDN5=\E[1;5B, kLFT3=\E[1;3D, kLFT5=\E[1;5D,
+	kNXT3=\E[6;3~, kNXT5=\E[6;5~, kPRV3=\E[5;3~,
+	kPRV5=\E[5;5~, kRIT3=\E[1;3C, kRIT5=\E[1;5C,
+	kUP3=\E[1;3A, kUP5=\E[1;5A, use=ecma+strikeout,
+	use=st-0.6,
 
 # Reviewed 0.7:
 #	dim is intermittent, sometimes works, sometimes does not
@@ -6860,18 +7292,12 @@ st-0.8|simpleterm 0.7,
 #	provided with the source is incorrect, since Se/Ss are mis-coded
 #	as booleans rather than strings.
 st-0.7|simpleterm 0.7,
-	ccc,
-	dim=\E[2m,
-	initc=\E]4;%p1%d;rgb\:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*
-	      %{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E\\,
-	kcbt@, kent@, oc=\E]104\007,
-	sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|
-	    %t;7%;%?%p4%t;5%;%?%p5%t;2%;%?%p7%t;8%;m,
-	Ms=\E]52;%p1%s;%p2%s\007, kDN3=\E[1;3B, kDN5=\E[1;5B,
-	kLFT3=\E[1;3D, kLFT5=\E[1;5D, kNXT3=\E[6;3~,
-	kNXT5=\E[6;5~, kPRV3=\E[5;3~, kPRV5=\E[5;5~,
-	kRIT3=\E[1;3C, kRIT5=\E[1;5C, kUP3=\E[1;3A, kUP5=\E[1;5A,
-	use=ecma+strikeout, use=st-0.6,
+	kcbt@, kent@, Ms=\E]52;%p1%s;%p2%s\007, kDN3=\E[1;3B,
+	kDN5=\E[1;5B, kLFT3=\E[1;3D, kLFT5=\E[1;5D,
+	kNXT3=\E[6;3~, kNXT5=\E[6;5~, kPRV3=\E[5;3~,
+	kPRV5=\E[5;5~, kRIT3=\E[1;3C, kRIT5=\E[1;5C,
+	kUP3=\E[1;3A, kUP5=\E[1;5A, use=ecma+strikeout,
+	use=st-0.6, use=xterm+256color,
 
 # st-0.4.1
 #
@@ -6902,60 +7328,40 @@ st-0.7|simpleterm 0.7,
 # still has no function keys past kf36 (no combinations of modifiers)
 # no application keypad mode, e.g, kent.
 st-0.6|simpleterm 0.6,
-	am, bce, hs, mir, msgr, npc, xenl, XT,
-	colors#8, cols#80, it#8, lines#24, pairs#64,
+	bce, mir, npc, xenl, XT,
+	colors#8, pairs#64,
 	acsc=+C\,D-A.B0E``aaffgghFiGjjkkllmmnnooppqqrrssttuuvvwwxxyy
 	     zz{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, clear=\E[H\E[2J,
-	cr=\r, csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M,
-	ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K, enacs=\E)0,
-	flash=\E[?5h$<100/>\E[?5l, fsl=^G, home=\E[H,
-	hpa=\E[%i%p1%dG, ht=^I, hts=\EH, ich=\E[%p1%d@,
-	il=\E[%p1%dL, il1=\E[L, ind=\n, invis=\E[8m,
-	is2=\E[4l\E>\E[?1034l, kDC=\E[3;2~, kEND=\E[1;2F,
-	kHOM=\E[1;2H, kIC=\E[2;2~, kLFT=\E[1;2D, kNXT=\E[6;2~,
-	kPRV=\E[5;2~, kRIT=\E[1;2C, ka1=\E[1~, ka3=\E[5~, kb2=\EOu,
-	kbs=^?, kc1=\E[4~, kc3=\E[6~, kcbt=\E[Z, kclr=\E[3;5~,
-	kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
-	kdl1=\E[3;2~, ked=\E[1;5F, kel=\E[1;2F, kent=\EOM,
-	kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~,
-	kf13=\E[1;2P, kf14=\E[1;2Q, kf15=\E[1;2R, kf16=\E[1;2S,
-	kf17=\E[15;2~, kf18=\E[17;2~, kf19=\E[18;2~, kf2=\EOQ,
-	kf20=\E[19;2~, kf21=\E[20;2~, kf22=\E[21;2~,
-	kf23=\E[23;2~, kf24=\E[24;2~, kf25=\E[1;5P, kf26=\E[1;5Q,
-	kf27=\E[1;5R, kf28=\E[1;5S, kf29=\E[15;5~, kf3=\EOR,
-	kf30=\E[17;5~, kf31=\E[18;5~, kf32=\E[19;5~,
-	kf33=\E[20;5~, kf34=\E[21;5~, kf35=\E[23;5~,
-	kf36=\E[24;5~, kf37=\E[1;6P, kf38=\E[1;6Q, kf39=\E[1;6R,
-	kf4=\EOS, kf40=\E[1;6S, kf41=\E[15;6~, kf42=\E[17;6~,
-	kf43=\E[18;6~, kf44=\E[19;6~, kf45=\E[20;6~,
-	kf46=\E[21;6~, kf47=\E[23;6~, kf48=\E[24;6~,
-	kf49=\E[1;3P, kf5=\E[15~, kf50=\E[1;3Q, kf51=\E[1;3R,
-	kf52=\E[1;3S, kf53=\E[15;3~, kf54=\E[17;3~,
-	kf55=\E[18;3~, kf56=\E[19;3~, kf57=\E[20;3~,
-	kf58=\E[21;3~, kf59=\E[23;3~, kf6=\E[17~, kf60=\E[24;3~,
-	kf61=\E[1;4P, kf62=\E[1;4Q, kf63=\E[1;4R, kf7=\E[18~,
-	kf8=\E[19~, kf9=\E[20~, khome=\E[1~, kil1=\E[2;5~,
-	kind=\E[1;2B, kmous=\E[M, kri=\E[1;2A, krmir=\E[2;2~,
-	mc0=\E[i, mc4=\E[4i, mc5=\E[5i, op=\E[39;49m, rc=\E8,
-	rev=\E[7m, ri=\EM, rmacs=\E(B, rmir=\E[4l, rmkx=\E[?1l\E>,
-	rmso=\E[27m, rmul=\E[24m, rs1=\Ec, rs2=\E[4l\E>\E[?1034l,
-	sc=\E7, setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
+	clear=\E[H\E[2J, cub1=^H, cud1=\n, cup=\E[%i%p1%d;%p2%dH,
+	dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m, ech=\E[%p1%dX,
+	ed=\E[J, el=\E[K, el1=\E[1K, enacs=\E)0,
+	flash=\E[?5h$<100/>\E[?5l, hpa=\E[%i%p1%dG,
+	ich=\E[%p1%d@, is2=\E[4l\E>\E[?1034l, kDC=\E[3;2~,
+	kEND=\E[1;2F, kHOM=\E[1;2H, kIC=\E[2;2~, kLFT=\E[1;2D,
+	kNXT=\E[6;2~, kPRV=\E[5;2~, kRIT=\E[1;2C, ka1=\E[1~,
+	ka3=\E[5~, kb2=\EOu, kbs=^?, kc1=\E[4~, kc3=\E[6~, kcbt=\E[Z,
+	kclr=\E[3;5~, kdl1=\E[3;2~, ked=\E[1;5F, kel=\E[1;2F,
+	khome=\E[1~, kil1=\E[2;5~, kind=\E[1;2B, kmous=\E[M,
+	kri=\E[1;2A, krmir=\E[2;2~, mc0=\E[i, mc4=\E[4i, mc5=\E[5i,
+	op=\E[39;49m, ri=\EM, rmacs=\E(B, rmir=\E[4l,
+	rmkx=\E[?1l\E>, rmso=\E[27m, rmul=\E[24m, rs1=\Ec,
+	rs2=\E[4l\E>\E[?1034l, setab=\E[4%p1%dm,
+	setaf=\E[3%p1%dm,
 	setb=\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}
 	     %=%t3%e%p1%d%;m,
 	setf=\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}
 	     %=%t3%e%p1%d%;m,
 	sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|
-	    %t;7%;%?%p4%t;5%;%?%p7%t;8%;m,
-	sgr0=\E[0m, smacs=\E(0, smir=\E[4h, smkx=\E[?1h\E=,
-	smso=\E[7m, smul=\E[4m, tbc=\E[3g, u6=\E[%i%d;%dR,
-	u7=\E[6n, u8=\E[?1;2c, u9=\E[c, vpa=\E[%i%p1%dd, Se=\E[2 q,
-	Ss=\E[%p1%d q, use=vt220+pcedit, use=ecma+index,
-	use=xterm+alt1049, use=vt220+cvis, use=xterm+sl,
-	use=ecma+italics,
+	    %t;7%;%?%p4%t;5%;%?%p5%t;2%;%?%p7%t;8%;m,
+	smacs=\E(0, smir=\E[4h, smkx=\E[?1h\E=, u8=\E[?1;2c,
+	vpa=\E[%i%p1%dd, Se=\E[2 q, Ss=\E[%p1%d q,
+	use=ansi+apparrows, use=ansi+csr, use=ansi+enq,
+	use=ansi+idl, use=ansi+inittabs, use=ansi+local,
+	use=ansi+sgrbold, use=vt100+4bsd, use=vt100+pfkeys,
+	use=vt220+pcedit, use=ecma+index, use=xterm+alt1049,
+	use=vt220+cvis, use=xterm+sl, use=ecma+italics,
+	use=ecma+strikeout, use=bracketed+paste,
+	use=xterm+pcf2,
 #
 # st-0.1.1
 #
@@ -6975,27 +7381,25 @@ st-0.6|simpleterm 0.6,
 # - shifted cursor-keys send sequences like rxvt
 # - sgr referred to unimplemented "invis" mode.
 # Fixes: add eo and xenl per tack, remove nonworking cbt, hts and tbc, invis
-simpleterm|old-st| simpleterm 0.1.1,
+simpleterm|old-st|simpleterm 0.1.1,
 	am, eo, mir, msgr, ul, xenl,
-	colors#8, cols#80, it#8, lines#24, ncv#3, pairs#64,
-	acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, bold=\E[1m, clear=\E[H\E[2J, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub1=^H, cud=\E[%p1%dB, cud1=\n,
-	cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
-	cuu=\E[%p1%dA, cuu1=\E[A, dch1=\E[P, dl=\E[%p1%dM,
-	dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H, hpa=\E[%i%p1%dG,
-	ht=^I, ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L, ind=\n, kbs=^?,
-	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
-	kdch1=\E[3~, kend=\E[4~, kf1=\EOP, kf10=\E[21~,
-	kf11=\E[23~, kf12=\E[24~, kf2=\EOQ, kf3=\EOR, kf4=\EOS,
-	kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~,
-	khome=\E[1~, knp=\E[6~, kpp=\E[5~, op=\E[37;40m, rc=\E8,
-	rev=\E[7m, rmacs=\E(B, rmso=\E[m, rmul=\E[m, sc=\E7,
-	setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
+	cols#80, it#8, lines#24,
+	bel=^G, bold=\E[1m, clear=\E[H\E[2J, cr=\r, cub1=^H,
+	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
+	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
+	dch1=\E[P, ed=\E[J, el=\E[K, home=\E[H, hpa=\E[%i%p1%dG,
+	ht=^I, ich=\E[%p1%d@, ind=\n, kbs=^?, kdch1=\E[3~,
+	kend=\E[4~, kf1=\EOP, kf10=\E[21~, kf11=\E[23~,
+	kf12=\E[24~, kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf5=\E[15~,
+	kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~,
+	khome=\E[1~, knp=\E[6~, kpp=\E[5~, rev=\E[7m, rmso=\E[m,
+	rmul=\E[m,
 	sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|
 	    %t;7%;m,
-	sgr0=\E[0m, smacs=\E(0, smso=\E[7m, smul=\E[4m,
-	use=vt220+cvis, use=ecma+index,
+	sgr0=\E[0m, smso=\E[7m, smul=\E[4m, use=ansi+arrows,
+	use=ansi+csr, use=ansi+idl, use=vt220+cvis,
+	use=ecma+index, use=klone+color, use=xterm+acs,
+
 st-16color|stterm-16color|simpleterm with 16-colors,
 	use=ibm+16color, use=st,
 # Tested with st 0.8.2
@@ -7071,7 +7475,7 @@ st-256color|stterm-256color|simpleterm with 256 colors,
 #	terminal does not respond to 80/132-column switching
 #	wrapping at the right margin is erratic
 #	there are several problems in the cursor-movements and screen-features
-#	no vt52, no double-sized characters
+#	no VT52, no double-sized characters
 #	Device attributes response says it is a vanilla VT100
 #	does not respond to xterm mouse controls
 #	alternate screen tests do not fill the screen, return wrong position
@@ -7085,36 +7489,33 @@ terminator|Terminator no line wrap,
 	bce, eo, mir, msgr, xenl, xon,
 	cols#80, it#8, lines#24, lm#0,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bold=\E[1m, clear=\E[H\E[2J, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m, dl=\E[%p1%dM,
-	dl1=\E[M, ed=\E[J, el=\E[K, el1=\E[1K, enacs=\E(B\E)0,
-	flash=^G, home=\E[H, hpa=\E[%i%p1%dG, ht=^I, hts=\EH,
-	il=\E[%p1%dL, il1=\E[L, ind=\n, is1=\E[?47l\E=\E[?1l,
+	bold=\E[1m, clear=\E[H\E[2J, cr=\r, cub1=^H, cud1=\n,
+	cup=\E[%i%p1%d;%p2%dH, dch=\E[%p1%dP, dch1=\E[P,
+	dim=\E[2m, ed=\E[J, el=\E[K, el1=\E[1K, enacs=\E(B\E)0,
+	flash=^G, home=\E[H, hpa=\E[%i%p1%dG, ht=^I, hts=\EH, ind=\n,
+	is1=\E[?47l\E=\E[?1l,
 	is2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l, kbs=^?,
-	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kf1=\EOP,
-	kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[25~,
-	kf14=\E[26~, kf15=\E[28~, kf16=\E[29~, kf2=\EOQ, kf3=\EOR,
-	kf4=\EOS, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~,
-	kf9=\E[20~, rc=\E8, rev=\E[7m, ri=\EM, rmacs=\E(B,
-	rmir=\E[4l, rmso=\E[27m, rmul=\E[24m, rs1=\Ec,
-	rs2=\E[!p\E[?3;4l\E[4l\E>, s0ds=\E(B, s1ds=\E(0, sc=\E7,
+	kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~,
+	kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, kf16=\E[29~,
+	kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf5=\E[15~, kf6=\E[17~,
+	kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, khome=\E[1~, rev=\E[7m,
+	ri=\EM, rmacs=\E(B, rmir=\E[4l, rmso=\E[27m, rmul=\E[24m,
+	rs1=\Ec, rs2=\E[!p\E[?3;4l\E[4l\E>, s0ds=\E(B, s1ds=\E(0,
 	sgr=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p5%t;2%;%?%p1%p3%|%t;7
 	    %;m%?%p9%t\E(0%e\E(B%;,
 	sgr0=\E[m\E(B, smacs=\E(0, smir=\E[4h, smso=\E[7m,
-	smul=\E[4m, tbc=\E[3g, tsl=\E]2;%p1, vpa=\E[%i%p1%dd,
+	smul=\E[4m, tbc=\E[3g, vpa=\E[%i%p1%dd, use=ansi+arrows,
+	use=ansi+csr, use=ansi+enq, use=ansi+idl, use=ansi+local,
 	use=vt220+pcedit, use=ecma+italics, use=ecma+index,
 	use=xterm+256setaf, use=xterm+sl-twm,
-	use=xterm+alt1049, use=vt220+cvis,
+	use=xterm+alt1049, use=vt220+cvis, use=bracketed+paste,
 
 #### TERMINOLOGY
 # https://www.enlightenment.org/about-terminology
 # https://github.com/borisfaure/terminology
 #
 # 2014/10/14:
-# Tested terminology-0.3.0, 0.6.1, using tack and vttest.  This is not a vt100
+# Tested terminology-0.3.0, 0.6.1, using tack and vttest.  This is not a VT100
 # emulator, nor is it compatible with xterm, but it uses a few features from
 # both -TD
 #
@@ -7123,7 +7524,7 @@ terminator|Terminator no line wrap,
 #	there are pervasive problems with clearing/erasing parts of the screen
 #	resizing the window causes it to stop listening to the keyboard
 # tack -
-#	doesn't understand vt100 CPR needed for resize
+#	doesn't understand VT100 CPR needed for resize
 #	no CBT
 #	no cvvis
 #	has invis
@@ -7143,9 +7544,9 @@ terminator|Terminator no line wrap,
 # vttest -
 #	spits lots of messages from termptyesc.c especially in vttest.
 #	no 132-column mode
-#	fails menu 1, 2 (definitely not vt100-compatible)
-#	primary (claims vt420 with several options, apparently none work) and
-#	secondary report says (perhaps... vt420): \E[>41;285;0c
+#	fails menu 1, 2 (definitely not VT100-compatible)
+#	primary (claims VT420 with several options, apparently none work) and
+#	secondary report says (perhaps... VT420): \E[>41;285;0c
 #	CHA, HPR, VPA, CNL, CPL work
 #	BCE with ED/EL - fail
 #	BCE with ECH/indexing - fail
@@ -7159,12 +7560,10 @@ terminator|Terminator no line wrap,
 # This description uses xterm+pcf0, which is misleading because the program
 # does not handle combinations of modifiers - but listing them all would
 # involve more effort than its developers spent -TD
-terminology-0.6.1|EFL-based terminal emulator,
+terminology-0.6.1|EFL-based terminal emulator (0.6.1),
 	mc5i@,
 	blink@, ed@, el@, el1@, invis=\E[8m, kLFT=\E[1;2D,
-	kRIT=\E[1;2C, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~,
-	kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~,
-	kind=\E[1;2B, kri=\E[1;2A,
+	kRIT=\E[1;2C, kind=\E[1;2B, kri=\E[1;2A,
 	sgr=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p7%t;8
 	    %;m%?%p9%t\016%e\017%;$<2>,
 	vpa=\E[%i%p1%dd, kDC3=\E[3;3~, kDC4=\E[3;4~,
@@ -7174,10 +7573,10 @@ terminology-0.6.1|EFL-based terminal emulator,
 	kLFT3=\E[1;3D, kLFT4=\E[1;4D, kLFT5=\E[1;5D,
 	kLFT6=\E[1;6D, kLFT7=\E[1;7D, kRIT3=\E[1;3C,
 	kRIT4=\E[1;4C, kRIT5=\E[1;5C, kRIT6=\E[1;6C,
-	kRIT7=\E[1;7C, kUP=\E[1;2A, use=xterm+pcf0, use=vt100,
-	use=xterm+256setaf,
+	kRIT7=\E[1;7C, kUP=\E[1;2A, use=ansi+enq, use=xterm+pcf0,
+	use=vt100, use=xterm+256setaf,
 
-# 2017-11-11
+# 2017-11-11:
 # Tested terminology 1.0.0
 #
 # tack -
@@ -7191,14 +7590,15 @@ terminology-0.6.1|EFL-based terminal emulator,
 #
 # Aside from the partial fixes for function/cursor/editing keys, no improvement
 # in other tests versus 0.6.1
-terminology-1.0.0|EFL-based terminal emulator,
+terminology-1.0.0|EFL-based terminal emulator (1.0.0),
 	dim=\E[2m, flash=\E[?5h$<100/>\E[?5l, kend=\E[OF,
 	khome=\E[OH, rmacs=\E(B,
 	sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p5%t;2%;%?%p2%t;4%;
 	    %?%p1%p3%|%t;7%;%?%p7%t;8%;m$<2>,
 	sgr0=\E(B\E[m, smacs=\E(0, use=ecma+italics,
 	use=vt220+cvis, use=xterm+x11mouse, use=xterm+pce2,
-	use=xterm+pcf2, use=xterm+pcc2, use=terminology-0.6.1,
+	use=xterm+pcf2, use=xterm+pcc2, use=bracketed+paste,
+	use=terminology-0.6.1,
 
 # 2020/12/26:
 # Tested terminology 1.8.1 using tack and vttest.
@@ -7214,13 +7614,14 @@ terminology-1.0.0|EFL-based terminal emulator,
 #	left/right margins do not work
 #	most of DECSCUSR works
 #	most problems with bce are fixed.
-terminology-1.8.1|EFL-based terminal emulator,
+terminology-1.8.1|EFL-based terminal emulator (1.8.1),
 	km@,
 	cvvis@, flash@, initc@, kcbt=\E[Z, rmm@, smm@, Ms@,
-	use=ecma+index, use=xterm+256setaf, use=ansi+rep,
-	use=ecma+strikeout, use=xterm+sm+1006,
-	use=xterm+pcfkeys, use=xterm+tmux, use=vt220+cvis,
-	use=ecma+italics, use=xterm-basic,
+	use=linux+kbs, use=ecma+index, use=xterm+256setaf,
+	use=ansi+rep, use=ecma+strikeout, use=xterm+focus,
+	use=xterm+sm+1006, use=xterm+pcfkeys, use=xterm+tmux,
+	use=vt220+cvis, use=ecma+italics, use=xterm-basic,
+	use=report+version,
 
 terminology|EFL-based terminal emulator,
 	use=terminology-1.8.1,
@@ -7242,7 +7643,7 @@ terminology|EFL-based terminal emulator,
 #	no DECCOLM (does not switch between 80/132 columns)
 #	otherwise, passes wrapping test
 #	no DECSCNM
-#	identifies as a vt102
+#	identifies as a VT102
 #	numeric keypad does not send expected codes (seen in 0.4.0)
 #	passes bce test
 #	vt220:
@@ -7288,12 +7689,19 @@ alacritty-direct|alacritty with direct color indexing,
 # added xterm+sl-twm in 0.3.3 -TD
 alacritty+common|base fragment for alacritty,
 	km@, npc,
-	kb2=\EOE, kbs=^?, kcbt=\E[Z, kent=\EOM, Se=\E[0 q,
-	Smulx=\E[4\:%p1%dm, use=ecma+index, use=xterm+sm+1006,
-	use=xterm-basic, use=xterm+app, use=ansi+rep,
-	use=xterm+tmux, use=ecma+strikeout, use=xterm+sl-twm,
-	use=ecma+italics, use=xterm+pce2, use=xterm+pcc2,
-	use=xterm+pcf2,
+	kb2=\EOE, kcbt=\E[Z, kent=\EOM, Se=\E[0 q,
+	Smulx=\E[4:%p1%dm, use=ecma+index, use=xterm+focus,
+	use=xterm+sm+1006, use=xterm-basic, use=xterm+app,
+	use=ansi+rep, use=xterm+tmux, use=ecma+strikeout,
+	use=xterm+sl-twm, use=ecma+italics, use=xterm+pce2,
+	use=xterm+pcc2, use=xterm+pcf2, use=bracketed+paste,
+
+# https://github.com/raphamorim/rio
+# derived from alacritty
+rio|fork of alacritty,
+	use=alacritty,
+rio-direct|fork of alacritty,
+	use=alacritty-direct,
 
 #### Kitty
 # https://github.com/kovidgoyal/kitty
@@ -7311,7 +7719,26 @@ alacritty+common|base fragment for alacritty,
 #	http://lists.gnu.org/archive/html/bug-ncurses/2018-09/msg00005.html
 #	https://github.com/kovidgoyal/kitty/issues/879
 #
-# Version 0.19.1
+# Version 0.21.2 (June 28, 2021)
+# changes since 0.19.1
+# Notes:
+#	Repeatable tests with tack and vttest assume a standard screensize --
+#	measured in characters.  However, kitty uses pixel-measurements and
+#	does not readily use characters.
+#	Resizing with twm shows only pixel-based hint rather than characters
+#	manual page states that it is possible to override initial window size,
+#	but configuration file has no effect on initial window size.
+#	The same problem with XFCE4, but editing the cached json file works
+#	for setting the window size (the "c" suffix for cells does not):
+#		{"window-size": [720, 440]}
+#	though the values depend upon the font in use.
+# vttest
+# tack
+#	flash works
+#	invisible text still does not work
+#	function/special key modifiers finally work
+#
+# Version 0.19.1 (October 6, 2020)
 # changes since 0.13.3:
 # vttest
 #	ISO-6429
@@ -7327,7 +7754,7 @@ alacritty+common|base fragment for alacritty,
 #	rs1 adds an empty string for resetting title- and other OSC-strings.
 #	italics work
 #
-# Version 0.13.3
+# Version 0.13.3 (January 19, 2019)
 # Notes:
 #	initial screensize 71x22
 #	does not respond to "resize -s"
@@ -7336,7 +7763,7 @@ alacritty+common|base fragment for alacritty,
 #	does not switch between 80/132 columns
 #	fails wrapping test, copying vte/rxvt
 #	no reverse-background, no blink
-#	claims to be vt200:
+#	claims to be VT200:
 #		primary \E[?62;c
 #		secondary \E[>1;4000;12c
 #	however -
@@ -7394,41 +7821,88 @@ kitty-direct|KovId's TTY using direct colors,
 	oc=\E]104\007, use=xterm+direct2, use=kitty+common,
 kitty+common|KovId's TTY common properties,
 	am, mc5i, mir, msgr, npc, xenl,
-	cols#80, it#8, lines#24,
+	cols#80, lines#24,
 	acsc=++\,\,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxy
 	     yzz{{||}}~~,
-	bel=^G, bold=\E[1m, cbt=\E[Z, clear=\E[H\E[2J, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m, dl=\E[%p1%dM,
-	dl1=\E[M, ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K,
+	bel=^G, bold=\E[1m, clear=\E[H\E[2J, cr=\r, cub1=^H, cud1=\n,
+	cup=\E[%i%p1%d;%p2%dH, dch=\E[%p1%dP, dch1=\E[P,
+	dim=\E[2m, ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K,
 	flash=\E[?5h$<100/>\E[?5l, home=\E[H, hpa=\E[%i%p1%dG,
-	ht=^I, hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L,
-	ind=\n, kbs=^?, kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB,
-	kcuf1=\EOC, kcuu1=\EOA, kdch1=\E[3~, kend=\EOF, kf1=\EOP,
-	kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[1;2P,
-	kf14=\E[1;2Q, kf15=\E[1;2R, kf16=\E[1;2S, kf17=\E[15;2~,
-	kf18=\E[17;2~, kf19=\E[18;2~, kf2=\EOQ, kf20=\E[19;2~,
-	kf21=\E[20;2~, kf22=\E[21;2~, kf23=\E[23;2~,
-	kf24=\E[24;2~, kf25=\E[1;5P, kf26=\E[1;5Q, kf27=\E[1;5R,
-	kf28=\E[1;5S, kf29=\E[15;5~, kf3=\EOR, kf30=\E[17;5~,
-	kf31=\E[18;5~, kf32=\E[19;5~, kf33=\E[20;5~,
-	kf34=\E[21;5~, kf35=\E[23;5~, kf36=\E[24;5~, kf4=\EOS,
-	kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~,
-	khome=\EOH, kich1=\E[2~, kind=\E[1;2B, knp=\E[6~,
-	kpp=\E[5~, kri=\E[1;2A, op=\E[39;49m, rc=\E8, rev=\E[7m,
-	ri=\EM, rmacs=\E(B, rmam=\E[?7l, rmir=\E[4l, rmkx=\E[?1l,
-	rmso=\E[27m, rmul=\E[24m, rs1=\E]\E\\\Ec, sc=\E7,
+	ich=\E[%p1%d@, ind=\n, kBEG=\E[1;2E, kbeg=\EOE, kbs=^?,
+	kcbt=\E[Z, op=\E[39;49m, rev=\E[7m, ri=\EM, rmacs=\E(B,
+	rmam=\E[?7l, rmir=\E[4l, rmkx=\E[?1l, rmso=\E[27m,
+	rmul=\E[24m, rs1=\E]\E\\\Ec,
 	sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p5%t;2%;%?%p2%t;4%;
 	    %?%p1%p3%|%t;7%;m,
 	sgr0=\E(B\E[m, smacs=\E(0, smam=\E[?7h, smir=\E[4h,
-	smkx=\E[?1h, smso=\E[7m, smul=\E[4m, tbc=\E[3g,
-	vpa=\E[%i%p1%dd, use=ansi+enq, use=ansi+rep,
-	use=xterm+sm+1006, use=ecma+index, use=xterm+sl-twm,
-	use=ecma+strikeout, use=xterm+pce2, use=xterm+pcc2,
-	use=ecma+italics, use=xterm+alt1049, use=att610+cvis,
-	use=xterm+tmux,
+	smkx=\E[?1h, smso=\E[7m, smul=\E[4m, vpa=\E[%i%p1%dd,
+	Smulx=\E[4:%p1%dm, use=ansi+csr, use=ansi+enq,
+	use=ansi+idl, use=ansi+inittabs, use=ansi+local,
+	use=ansi+rep, use=xterm+focus, use=xterm+sm+1006,
+	use=ecma+index, use=xterm+pcfkeys, use=xterm+sl-twm,
+	use=ecma+strikeout, use=ecma+italics,
+	use=xterm+alt1049, use=att610+cvis, use=xterm+tmux,
+	use=bracketed+paste, use=report+version,
+
+kitty+setal|set underline colors (nonstandard),
+	setal=\E[58:2::%p1%{65536}%/%d:%p1%{256}%/%{255}%&%d:%p1
+	      %{255}%&%dm,
+
+######## WAYLAND CLIENTS
+
+#### Foot
+# https://codeberg.org/dnkl/foot/
+# Version 1.8.2
+#
+# This identifies as a VT220 with 4=sixel and 22=color, however:
+# tack:
+#	bell does not work
+#	status-line does not work because foot does not set the window title
+#	sends escape when meta key is used, whether or not smm/rmm enabled
+# vttest:
+#	wrap-test fails
+#	no application-mode for numeric keypad (unless private mode 1035 is set)
+#	no NRCS
+#	no VT52
+#	no SRM
+#	protected areas do not work
+#	SU/SD work, SL/SR do not
+#	DECRPM responds, but not the corresponding ANSI reports.
+#	otherwise few reports, except cursor-position and mouse and some dtterm
+#	VT520 cursor-movement works, except for left/right margins
+#	supports xterm/DECSCUSR, though default case in vttest does not blink
+#		Send: <27> [ 0 <32> q 
+#		Text: The cursor should be a blinking rectangle
+#	partial support for xterm mouse any-event mode and button-event mode:
+#	+ does not report focus-in/focus-out
+#	+ does not report buttons 6/7
+#	alternate-screen works
+foot|foot terminal emulator,
+	oc=\E]104\E\\, use=xterm+256color2, use=foot+base,
+
+foot-direct|foot with direct color indexing,
+	use=xterm+direct, use=foot+base,
+
+foot+base|foot base fragment,
+	am, bce, bw, mir, msgr, npc, xenl, AX, XT,
+	cols#80, it#8, lines#24,
+	bel=^G, clear=\E[H\E[2J, cr=\r, cub1=^H, cud1=\n, dim=\E[2m,
+	ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K,
+	flash=\E]555\E\\, ind=\n, is2=\E[!p\E[4l\E>, kbs=^?,
+	kcbt=\E[Z, oc=\E]104\E\\, op=\E[39;49m, ri=\EM,
+	rmam=\E[?7l, rmkx=\E[?1l\E>, rmso=\E[27m, rmul=\E[24m,
+	rs1=\Ec, rs2=\E[!p\E[4l\E>,
+	sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p5%t;2%;%?%p2%t;4%;
+	    %?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m,
+	sgr0=\E(B\E[m, smam=\E[?7h, smkx=\E[?1h\E=, E3=\E[3J,
+	use=att610+cvis, use=ansi+csr, use=ansi+cup,
+	use=ansi+enq, use=ansi+local, use=ansi+idc, use=ansi+idl,
+	use=ansi+rca2, use=ansi+rep, use=ansi+tabs,
+	use=ansi+sgrbold, use=ecma+index, use=ecma+italics,
+	use=ecma+strikeout, use=xterm+acs, use=xterm+alt+title,
+	use=xterm+pcfkeys, use=xterm+sm+1006, use=xterm+tmux2,
+	use=xterm+sl-alt, use=bracketed+paste,
+	use=report+version, use=xterm+focus,
 
 ######## WEB CLIENTS
 
@@ -7461,7 +7935,7 @@ kitty+common|KovId's TTY common properties,
 #	sends utf-8 for meta, like xterm
 # vttest
 #	has problems with menu #1 (wrapping)
-#	DA = vt200 with 132 columns, color
+#	DA = VT200 with 132 columns, color
 #	DA2 = 990, 100300 ("\E[>990;100300;0c")
 #	no VT52, no double-size characters
 #	vt220 ECH test works, SRM, DECSCA do not
@@ -7482,8 +7956,150 @@ domterm|DomTerm web client,
 	bel@, blink@, dim@, invis@, kcbt=\E[Z, ritm@, rmkx=\E[?1l,
 	sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|
 	    %t;7%;m,
-	sitm@, smkx=\E[?1h, use=xterm+256setaf, use=ecma+index,
-	use=xterm+sm+1006, use=xterm+pcfkeys, use=xterm-basic,
+	sitm@, smkx=\E[?1h, use=linux+kbs, use=xterm+256setaf,
+	use=ecma+index, use=xterm+focus, use=xterm+sm+1006,
+	use=xterm+pcfkeys, use=xterm-basic,
+	use=bracketed+paste,
+
+######## Miscellaneous
+
+#### WezTerm
+# https://wezfurlong.org/wezterm/
+# https://github.com/wez/wezterm
+#
+# which says:
+# "wezterm is a terminal emulator with support for modern features
+#  such as fonts with ligatures, hyperlinks, tabs and multiple windows."
+#
+# wezterm-20230712_072601_f4abf8fd-1.fedora38.x86_64
+# tested with MacOS and Fedora 38/39.
+#
+# General:
+# + written in Rust.
+# + initial screensize is odd, i.e., 81x24
+#   provides no visual feedback on resize
+#   ignores "resize -s"
+#   manual resize and then running resize got off-by-one adjustment
+# + leaves debris (unerased cells) when switching between normal/alternate
+#   screens.
+# + sets TERM=xterm-256color
+# tack:
+# + misplaced message in "am" screen
+# + fails xenl (should be false)
+# + cvvis is same as cnorm, block
+# + has blink and dim
+# + in bce test, blue isn't really blue but some pale purple
+# + modified keys mostly work, but its tab control interferes with some
+# + rmm/smm don't work (always uses escape-prefix)
+# wraptest:
+# + poor (doesn't copy anyone, most of the results are wrong)
+# vttest:
+# + DA is VT5xx with sixel, selective erase, user windows, color
+# + DA2 is VT220 version 277
+# + only the VT100 character set works, contrary to DA/DA2.
+# + no NRCS, either
+# + double-sized character work, with some debris
+# + doesn't switch between 80/132 columns.
+# + numeric keypad ANSI application mode escapes don't work.
+# + numeric keypad ANSI mode misses "0", ".", ","
+# + uses PC-style editing keypad \E[H and \E[F for Find and Select
+# + no VT52
+# + DECSED selective erase doesn't work
+# + SRM doesn't work
+# + 8-bit controls don't work
+# + DECNCSM doesn't work
+# + most DECRQSS do not work (DECSCL, DECSTBM, DECSLRM respond)
+# + DECRQM/DECRPM don't work (most reply permanently reset)
+# + DECLRMM responds to DECRPM, but VT420 rectangle tests do not work.
+#   Some of the left/right margin tests work with the cursor-movement screen,
+#   but DECFI/DECBI do not work.  The other cursor-movement tests are buggy.
+# + implements ECMA-48 cursor movement, but not SL/SR or protected area
+# + implements xterm normal, any-event and button-event mouse, none of the rest
+# + reports window size, none of the other window reports
+wezterm|Wez's Terminal Emulator,
+	km@, xenl@,
+	cvvis@, rmkx=\E[?1l, rmm@, smkx=\E[?1h, smm@,
+	use=xterm-256color,
+
+#### Contour
+# https://github.com/contour-terminal/contour
+#
+# "Modern C++ Terminal Emulator"
+# Contour is a modern and actually fast, modal, virtual terminal emulator,
+# for everyday use. It is aiming for power users with a modern feature mindset.
+#
+# That is three occurrences of "modern" too many -TD
+#
+# MacOS
+# - cannot run, because the package is not signed.
+#
+# Fedora rawhide
+# contour-terminal-0.3.12.262-6.fc39.x86_64
+# - dumps core, cannot test
+#
+# Fedora 39
+# contour-terminal-0.4.0.6245-1.fc38.x86_64
+# - starts but doesn't display
+#
+# Fedora 38
+# contour-terminal-0.4.0.6245-1.fc38.x86_64
+# - starts but doesn't display
+# contour-terminal-0.3.12.262-1.fc38.x86_64
+# + testable (see below)
+# + initial screensize 62x23, no visual feedback on resize, no "resize -s"
+#
+# Sets TERM=contour (which is preferable to xterm).
+#
+# tack:
+# + cvvis is same as cnorm, "|"
+# + sitm/ritm don't work
+# + rmm/smm don't work (always uses escape, but terminfo defines km)
+# + initp interchanges red/blue (bug in tack?)
+# + modified F1-F4 are wrong, sending SS3 with modifier numbers
+# + shifted editing-keypad doesn't send anything
+# + meta key doesn't work
+# + status-line works (based on xterm, including window-resizing)
+# + dots don't line up for home test
+#
+# wraptest:
+# + poor 7/25 differences from xterm (perhaps copying iTerm2)
+#
+# vttest:
+# + hangs in menu 1, etc., when it tries to resize
+#
+# infocmp vs xterm-256color
+# + missing XM/xm
+# + rmcup/smcup doesn't use title-stack (but is implemented)
+# + doesn't use SGR mouse (but is implemented)
+# + sgr doesn't define dim, but dim capability is in terminfo (implemented)
+#
+# Developer's terminfo (compiled-in) uses some extensions.
+contour|contour-latest|Contour Terminal Emulator,
+	am, bce, eslok, hs, km, mc5i, mir, msgr, npc, xenl, xvpa,
+	cols#80, lines#24, pairs#0x7fff,
+	bel=^G, bold=\E[1m, clear=\E[H\E[2J, cr=\r, cub1=^H, cud1=\n,
+	dim=\E[2m, dsl=\E[$~, ech=\E[%p1%dX, el1=\E[1K,
+	flash=\E[?5h$<100/>\E[?5l, fsl=\E[$}, hpa=\E[%i%p1%dG,
+	ind=\n, indn=\E[%p1%dS, invis=\E[8m, ka1=, ka3=, kbs=^?, kc1=,
+	kc3=, kcbt=\E[Z, kend=\EOF, khlp=, kmous=\E[M, kund=,
+	oc=\E]104\E\\, op=\E[39;49m, rev=\E[7m, ri=\EM,
+	rin=\E[%p1%dT, rmam=\E[?7l, rmkx=\E[?1l, rmso=\E[27m,
+	rmul=\E[24m, rs1=\E]\E\\\Ec,
+	sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|
+	    %t;7%;%?%p4%t;5%;%?%p7%t;8%;m,
+	sgr0=\E(B\E[m, smam=\E[?7h, smkx=\E[?1h, smso=\E[7m,
+	smul=\E[4m, tsl=\E[2$~\E[1$}\E[H\E[2J, vpa=\E[%i%p1%dd,
+	Cs=\E]12;%p1%s\E\\, E3=\E[3J, Rmol=\E[55m, Se=\E[ q,
+	Smol=\E[53m, Smulx=\E[4:%p1%dm, Ss=\E[%p1%d q,
+	use=ansi+apparrows, use=ansi+cup, use=ansi+csr,
+	use=ansi+erase, use=ansi+idc, use=ansi+idl,
+	use=ansi+inittabs, use=ansi+local, use=ansi+rep,
+	use=att610+cvis, use=ecma+italics, use=ecma+strikeout,
+	use=xterm+256color, use=xterm+acs, use=xterm+alt1049,
+	use=xterm+pcc2, use=xterm+pce2, use=xterm+pcf2,
+
+contour-direct|Contour terminal with direct colors,
+	use=xterm+direct, use=contour,
 
 ######## UNIX VIRTUAL TERMINALS, VIRTUAL CONSOLES, AND TELNET CLIENTS
 #
@@ -7496,9 +8112,8 @@ cbunix|cb unix virtual terminal,
 	cols#80, lines#24, lm#0,
 	bel=^G, clear=\EL, cr=\r, cub1=^H, cud1=\n, cuf1=\EC,
 	cup=\EG%p2%c%p1%c, cuu1=\EA, dch1=\EM, dl1=\EN, ed=\EL,
-	el=\EK, ich1=\EO, il1=\EP, ind=\n, kcub1=\ED, kcud1=\EB,
-	kcuf1=\EC, kcuu1=\EA, khome=\EE, rmso=\Eb^D, rmul=\Eb^A,
-	smso=\Ea^D, smul=\Ea^A,
+	el=\EK, ich1=\EO, il1=\EP, ind=\n, khome=\EE, rmso=\Eb^D,
+	rmul=\Eb^A, smso=\Ea^D, smul=\Ea^A, use=vt52+arrows,
 # (vremote: removed obsolete ":nl@:" -- esr)
 vremote|virtual remote terminal,
 	am@,
@@ -7514,39 +8129,28 @@ pty|4bsd pseudo teletype,
 # https://github.com/emacs-mirror/emacs/blob/master/lisp/term.el
 #
 # The codes supported by the term.el terminal emulation in GNU Emacs 19.30
-eterm|gnu emacs term.el terminal emulation,
+eterm|GNU Emacs term.el terminal emulation,
 	am, mir, xenl,
 	cols#80, lines#24,
-	bel=^G, bold=\E[1m, clear=\E[H\E[J, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J,
-	el=\E[K, el1=\E[1K, home=\E[H, ht=^I, ich=\E[%p1%d@,
-	il=\E[%p1%dL, il1=\E[L, ind=\n, rev=\E[7m,
-	rmcup=\E[2J\E[?47l\E8, rmir=\E[4l, rmso=\E[m, rmul=\E[m,
-	sgr0=\E[m, smcup=\E7\E[?47h, smir=\E[4h, smso=\E[7m,
-	smul=\E[4m,
+	bel=^G, bold=\E[1m, cr=\r, csr=\E[%i%p1%d;%p2%dr, cub1=^H,
+	cud1=\n, cup=\E[%i%p1%d;%p2%dH, dch=\E[%p1%dP, dch1=\E[P,
+	el1=\E[1K, home=\E[H, ht=^I, ich=\E[%p1%d@, ind=\n,
+	rev=\E[7m, rmir=\E[4l, rmso=\E[m, rmul=\E[m, sgr0=\E[m,
+	smir=\E[4h, smso=\E[7m, smul=\E[4m, use=ansi+cpr,
+	use=ansi+erase, use=ansi+idl, use=ansi+local,
+	use=xterm+alt47,
 
 # The codes supported by the term.el terminal emulation in GNU Emacs 22.2
 eterm-color|Emacs term.el terminal emulator term-protocol-version 0.96,
-	am, mir, msgr, xenl,
-	colors#8, cols#80, lines#24, pairs#64,
-	bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[J, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J,
-	el=\E[K, el1=\E[1K, home=\E[H, ht=^I, ich=\E[%p1%d@,
-	il=\E[%p1%dL, il1=\E[L, ind=\n, invis=\E[8m, kbs=^?,
-	kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
-	op=\E[39;49m, rc=\E8, rev=\E[7m, ri=\EM, rmir=\E[4l,
-	rmso=\E[27m, rmul=\E[24m, rs1=\Ec, sc=\E7,
-	setab=\E[%p1%'('%+%dm, setaf=\E[%p1%{30}%+%dm,
+	msgr,
+	colors#8, pairs#64,
+	kbs=^?, khome=\E[1~, op=\E[39;49m, ri=\EM, rmso=\E[27m,
+	rmul=\E[24m, rs1=\Ec, setab=\E[%p1%'('%+%dm,
+	setaf=\E[%p1%{30}%+%dm,
 	sgr=\E[0%?%p1%p3%|%t;7%;%?%p2%t;4%;%?%p4%t;5%;%?%p6%t;1%;%?
 	    %p7%t;8%;m,
-	sgr0=\E[m, smir=\E[4h, smso=\E[7m, smul=\E[4m,
-	u6=\E[%i%d;%dR, u7=\E[6n, use=vt220+pcedit,
+	sgr0=\E[m, use=ansi+apparrows, use=ansi+csr,
+	use=ansi+sgr, use=vt220+pcedit, use=eterm,
 
 # shell.el can "do" color, though not nearly as well.
 #
@@ -7563,10 +8167,10 @@ eterm-color|Emacs term.el terminal emulator term-protocol-version 0.96,
 # italics but does not lose the color information -TD 2017/01/28.
 dumb-emacs-ansi|Emacs dumb terminal with ANSI color codes,
 	am, hc,
-	colors#8, it#8, ncv#13, pairs#64,
+	it#8, ncv#13,
 	bold=\E[1m, cud1=\n, ht=^I, ind=\n, op=\E[39;49m,
-	rmul=\E[24m, setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
-	sgr0=\E[m, smul=\E[4m, use=ecma+italics,
+	rmul=\E[24m, sgr0=\E[m, smul=\E[4m, use=ecma+italics,
+	use=klone+color,
 
 #### Screen
 
@@ -7640,40 +8244,44 @@ dumb-emacs-ansi|Emacs dumb terminal with ANSI color codes,
 # since 1994 (i.e., screen 3.0.5), stating that it was an obscure code used by
 # the (Siemens Nixdorf) 97801 terminal.  It was not shown in the termcap or
 # terminfo entries (which list about 60% of the control sequences).
-screen|VT 100/ANSI X3.64 virtual terminal,
-	OTbs, OTpt, am, km, mir, msgr, xenl, G0,
-	colors#8, cols#80, it#8, lines#24, ncv@, pairs#64, U8#1,
+screen-base|VT 100/ANSI X3.64 virtual terminal (base),
+	OTbs, OTpt, km, mir, xenl, G0,
+	ncv@, U8#1,
 	acsc=++\,\,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxy
 	     yzz{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[?25l,
-	clear=\E[H\E[J, cnorm=\E[34h\E[?25h, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\EM,
-	cvvis=\E[34l, dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m,
-	dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K, el1=\E[1K,
-	enacs=\E(B\E)0, flash=\Eg, home=\E[H, hpa=\E[%i%p1%dG,
-	ht=^I, hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L,
-	ind=\n, indn=\E[%p1%dS, is2=\E)0, kbs=^H, kcbt=\E[Z,
-	kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kf1=\EOP,
-	kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf2=\EOQ, kf3=\EOR,
-	kf4=\EOS, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~,
-	kf9=\E[20~, kmous=\E[M, nel=\EE, rc=\E8, rev=\E[7m, ri=\EM,
-	rmacs=^O, rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[23m,
-	rmul=\E[24m, rs2=\Ec\E[?1000l\E[?25h, sc=\E7,
+	blink=\E[5m, bold=\E[1m, civis=\E[?25l,
+	cnorm=\E[34h\E[?25h, cub1=^H, cud1=\n,
+	cup=\E[%i%p1%d;%p2%dH, cuu1=\EM, cvvis=\E[34l,
+	dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m, el1=\E[1K, flash=\Eg,
+	hpa=\E[%i%p1%dG, ich=\E[%p1%d@, indn=\E[%p1%dS, is2=\E)0,
+	kbs=^?, kcbt=\E[Z, kf1=\EOP, kf10=\E[21~, kf11=\E[23~,
+	kf12=\E[24~, kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf5=\E[15~,
+	kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~,
+	khome=\E[1~, kmous=\E[M, nel=\EE, rev=\E[7m, ri=\EM,
+	rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[23m, rmul=\E[24m,
+	rs2=\Ec\E[?1000l\E[?25h,
 	sgr=\E[0%?%p6%t;1%;%?%p1%t;3%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;
 	    5%;%?%p5%t;2%;m%?%p9%t\016%e\017%;,
-	sgr0=\E[m\017, smacs=^N, smir=\E[4h, smkx=\E[?1h\E=,
-	smso=\E[3m, smul=\E[4m, tbc=\E[3g, vpa=\E[%i%p1%dd,
-	E0=\E(B, S0=\E(%p1%c, use=vt220+pcedit,
-	use=xterm+alt1049, use=ecma+color, use=vt100+enq,
+	sgr0=\E[m\017, smir=\E[4h, smkx=\E[?1h\E=, smso=\E[3m,
+	smul=\E[4m, vpa=\E[%i%p1%dd, E0=\E(B, S0=\E(%p1%c,
+	use=ansi+apparrows, use=ansi+csr, use=ansi+erase,
+	use=ansi+idl, use=ansi+inittabs, use=ansi+local,
+	use=xterm+kbs, use=vt220+pcedit, use=xterm+alt1049,
+	use=ecma+color, use=vt100+enq, use=vt100+4bsd,
+
+screen|VT 100/ANSI X3.64 virtual terminal,
+	use=screen4,
+
+no+brackets|cancel bracketed paste,
+	BD@, BE@, PE@, PS@,
+
 # The bce and status-line entries are from screen 3.9.13 (and require some
 # changes to .screenrc).
 screen-bce|VT 100/ANSI X3.64 virtual terminal with bce,
 	bce,
-	ech@, use=screen4,
+	ech@, use=screen,
 screen-s|VT 100/ANSI X3.64 virtual terminal with hardstatus line,
-	dsl=\E_\E\\, fsl=\E\\, tsl=\E_, use=screen4,
+	dsl=\E_\E\\, fsl=\E\\, tsl=\E_, use=screen,
 
 # ======================================================================
 # Entries for GNU Screen with 16 colors.
@@ -7684,7 +8292,7 @@ screen-s|VT 100/ANSI X3.64 virtual terminal with hardstatus line,
 # do all support 16 color palette.
 
 screen-16color|GNU Screen with 16 colors,
-	use=ibm+16color, use=screen4,
+	use=ibm+16color, use=screen,
 
 screen-16color-s|GNU Screen with 16 colors and status line,
 	use=ibm+16color, use=screen-s,
@@ -7699,13 +8307,13 @@ screen-16color-bce-s|GNU Screen with 16 colors using BCE and status line,
 # Entries for GNU Screen 4.02 with --enable-colors256.
 
 screen-256color|GNU Screen with 256 colors,
-	use=xterm+256setaf, use=screen4,
+	use=xterm+256setaf, use=screen,
 
 screen-256color-s|GNU Screen with 256 colors and status line,
 	use=xterm+256setaf, use=screen-s,
 
 screen-256color-bce|GNU Screen with 256 colors and BCE,
-	bce, use=xterm+256setaf, use=screen-bce,
+	use=xterm+256setaf, use=screen-bce,
 
 screen-256color-bce-s|GNU Screen with 256 colors using BCE and status line,
 	bce, use=xterm+256setaf, use=screen-s,
@@ -7714,7 +8322,7 @@ screen.xterm-256color|GNU Screen with xterm using 256 colors,
 	use=xterm+256setaf, use=screen.xterm-new,
 
 screen.konsole-256color|GNU Screen with konsole using 256 colors,
-	use=xterm+256setaf, use=screen.konsole,
+	XR@, use=xterm+256setaf, use=screen.konsole,
 
 screen.vte-256color|GNU Screen with vte using 256 colors,
 	use=xterm+256setaf, use=screen.vte,
@@ -7723,7 +8331,7 @@ screen.putty-256color|GNU Screen with putty using 256 colors,
 	use=xterm+256setaf, use=screen.putty,
 
 screen.mlterm-256color|GNU Screen with mlterm using 256 colors,
-	use=xterm+256setaf, use=screen.mlterm,
+	XR@, use=xterm+256setaf, use=screen.mlterm,
 
 # ======================================================================
 
@@ -7761,6 +8369,7 @@ screen+italics|screen cannot support italics,
 #	match.  Hence, no "screen.xterm" entry is provided, since that would
 #	create heartburn for people running remote xterm's.
 # (f)   screen does not support rep.
+# (g)	the xterm-new compatibility does not include bracketed paste.
 #
 #	xterm (-xfree86 or -r6) does not normally support kIC, kNXT and kPRV
 #	since the default translations override the built-in keycode
@@ -7771,9 +8380,14 @@ screen.xterm-xfree86|screen.xterm-new|screen customized for modern xterm,
 	sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|
 	    %t;7%;%?%p4%t;5%;%?%p5%t;2%;m,
 	E3@, use=screen+italics, use=screen+fkeys,
-	use=xterm+x11mouse, use=xterm-new,
+	use=xterm+x11mouse, use=ecma+index, use=ansi+rep,
+	use=ecma+strikeout, use=xterm+pcfkeys,
+	use=xterm+nofkeys,
+
+# Don't use this, because not everyone has "screen.xterm-new":
 #:screen.xterm|screen for modern xterm,
 #:	use=screen.xterm-new,
+
 # xterm-r6 does not really support khome/kend unless it is propped up by
 # the translations resource.
 screen.xterm-r6|screen customized for X11R6 xterm,
@@ -7785,36 +8399,38 @@ screen.teraterm|disable ncv in teraterm,
 	acsc=+\020\,\021-\030.^Y0\333`\004a\261f\370g\361h\260i
 	     \316j\331k\277l\332m\300n\305o~p\304q\304r\304s_t\303u
 	     \264v\301w\302x\263y\363z\362{\343|\330}\234~\376,
-	use=screen+fkeys, use=xterm+x11mouse, use=screen4,
+	use=screen+fkeys, use=xterm+x11mouse, use=screen,
 # Other terminals
 screen.rxvt|screen in rxvt,
 	bw, XT,
 	cvvis@, flash@, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC,
 	kcuu1=\EOA, use=screen+fkeys, use=vt100+enq,
 	use=rxvt+pcfkeys, use=xterm+x11mouse, use=vt220+keypad,
-	use=screen4,
+	use=screen,
 screen.Eterm|screen in Eterm,
 	use=xterm+x11mouse, use=screen+fkeys, use=Eterm,
 screen.mrxvt|screen in mrxvt,
 	use=xterm+x11mouse, use=screen+fkeys, use=mrxvt,
 screen.vte|screen in any VTE-based terminal,
 	use=xterm+x11mouse, use=screen+italics,
-	use=screen+fkeys, use=vte,
+	use=screen+fkeys, use=no+brackets, use=vte,
 screen.gnome|screen in GNOME Terminal,
 	use=xterm+x11mouse, use=screen+italics,
-	use=screen+fkeys, use=gnome,
+	use=screen+fkeys, use=no+brackets, use=gnome,
 screen.konsole|screen in KDE console window,
-	use=xterm+x11mouse, use=screen+italics,
-	use=screen+fkeys, use=konsole,
+	XR@, use=xterm+x11mouse, use=screen+italics,
+	use=screen+fkeys, use=no+brackets, use=konsole,
 # fix the backspace key
-screen.linux|screen.linux-s|screen in linux console,
+screen.linux|screen.linux-s|screen in Linux console,
 	bw,
-	kbs=^?, kcbt@, use=linux+sfkeys, use=xterm+x11mouse,
-	use=screen+fkeys, use=screen4,
+	kcbt@, use=linux+sfkeys, use=xterm+x11mouse,
+	use=screen+fkeys, use=screen,
 screen.mlterm|screen in mlterm,
-	use=xterm+x11mouse, use=screen+fkeys, use=mlterm,
+	XR@, use=xterm+x11mouse, use=screen+fkeys,
+	use=no+brackets, use=mlterm,
 screen.putty|screen in putty,
-	use=xterm+x11mouse, use=screen+fkeys, use=putty,
+	use=xterm+x11mouse, use=screen+fkeys, use=no+brackets,
+	use=putty,
 
 # The default "screen" entry is reasonably portable, but not optimal for the
 # most widely-used terminal emulators.  The "bce" capability is supported in
@@ -7842,55 +8458,47 @@ screen-bce.mrxvt|screen optimized for mrxvt,
 	bce,
 	ech@, use=screen.mrxvt,
 screen-bce.gnome|screen optimized for GNOME-Terminal,
-	bce,
 	ech@, use=screen+italics, use=screen.gnome,
 screen-bce.konsole|screen optimized for KDE console window,
-	bce,
 	ech@, use=screen+italics, use=screen.konsole,
-screen-bce.linux|screen optimized for linux console,
+screen-bce.linux|screen optimized for Linux console,
 	bce,
 	ech@, use=screen.linux,
 
 screen-w|VT 100/ANSI X3.64 virtual terminal with 132 cols,
-	cols#132, use=screen4,
+	cols#132, use=screen,
+
+screen2|VT 100/ANSI X3.64 virtual terminal (old 2.x),
+	cols#80, lines#24,
+	clear=\E[2J\E[H, cr=\r, cub1=^H, cup=\E[%i%p1%d;%p2%dH,
+	ed=\E[J, el=\E[K, ich1=, ind=\n, kbs=^H, kf0=\E~, kf1=\ES,
+	kf2=\ET, kf3=\EU, kf4=\EV, kf5=\EW, kf6=\EP, kf7=\EQ, kf8=\ER,
+	kf9=\E0I, khome=\EH, nel=\r\n, rc=\E8, ri=\EM, rmso=\E[23m,
+	rmul=\E[24m, rs1=\Ec, sc=\E7, sgr0=\E[m, smso=\E[3m,
+	smul=\E[4m, use=ansi+idc, use=ansi+idl,
+	use=ansi+inittabs, use=ansi+local, use=vt52+arrows,
 
-screen2|old VT 100/ANSI X3.64 virtual terminal,
-	cols#80, it#8, lines#24,
-	cbt=\E[Z, clear=\E[2J\E[H, cr=\r, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\E[B, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J,
-	el=\E[K, ht=^I, hts=\EH, ich=\E[%p1%d@, ich1=, il=\E[%p1%dL,
-	il1=\E[L, ind=\n, kbs=^H, kcub1=\ED, kcud1=\EB, kcuf1=\EC,
-	kcuu1=\EA, kf0=\E~, kf1=\ES, kf2=\ET, kf3=\EU, kf4=\EV,
-	kf5=\EW, kf6=\EP, kf7=\EQ, kf8=\ER, kf9=\E0I, khome=\EH,
-	nel=\r\n, rc=\E8, ri=\EM, rmir=\E[4l, rmso=\E[23m,
-	rmul=\E[24m, rs1=\Ec, sc=\E7, sgr0=\E[m, smir=\E[4h,
-	smso=\E[3m, smul=\E[4m, tbc=\E[3g,
 # (screen3: removed unknown ":xv:LP:G0:" -- esr)
-screen3|older VT 100/ANSI X3.64 virtual terminal,
+screen3|VT 100/ANSI X3.64 virtual terminal (old 3.x),
 	km, mir, msgr,
-	cols#80, it#8, lines#24,
-	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, clear=\E[H\E[J,
-	cr=\r, csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\EM,
-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J,
-	el=\E[K, home=\E[H, ht=^I, hts=\EH, ich=\E[%p1%d@,
-	il=\E[%p1%dL, il1=\E[L, ind=\n, is2=\E)0, kbs=^H, kcub1=\EOD,
-	kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kf1=\EOP, kf2=\EOQ,
-	kf3=\EOR, kf4=\EOS, nel=\EE, rc=\E8, rev=\E[7m, ri=\EM,
-	rmir=\E[4l, rmkx=\E>, rmso=\E[23m, rmul=\E[24m, rs1=\Ec,
-	sc=\E7, sgr0=\E[m, smir=\E[4h, smkx=\E=, smso=\E[3m,
-	smul=\E[4m, tbc=\E[3g,
+	cols#80, lines#24,
+	bel=^G, blink=\E[5m, bold=\E[1m, cr=\r, cub1=^H, cud1=\n,
+	cup=\E[%i%p1%d;%p2%dH, cuu1=\EM, dch=\E[%p1%dP,
+	dch1=\E[P, home=\E[H, ich=\E[%p1%d@, ind=\n, is2=\E)0,
+	kbs=^H, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
+	kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, nel=\EE, rev=\E[7m,
+	ri=\EM, rmir=\E[4l, rmkx=\E>, rmso=\E[23m, rmul=\E[24m,
+	rs1=\Ec, sgr0=\E[m, smir=\E[4h, smkx=\E=, smso=\E[3m,
+	smul=\E[4m, use=ansi+csr, use=ansi+erase, use=ansi+idl,
+	use=ansi+inittabs, use=ansi+local,
 
 # screen 4.0 was released 2003-07-21, and as of March 2019, its terminfo file
 # was last updated in 2009 to include 256-color support.  The most recent
 # release is 4.6.2 (October 2017).
-screen4|VT 100/ANSI X3.64 virtual terminal,
-	use=ecma+index, use=screen,
+screen4|VT 100/ANSI X3.64 virtual terminal (4.x),
+	use=ecma+index, use=screen-base,
 
-# As of March 2019, screen 5.0 has not been released.
+# As of December 2022, screen 5.0 has not been released.
 #
 # However,
 #
@@ -7906,7 +8514,8 @@ screen5|VT 100/ANSI X3.64 virtual terminal (someday),
 	rmso=\E[27m,
 	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?
 	    %p5%t;2%;m%?%p9%t\016%e\017%;,
-	smso=\E[7m, use=ecma+italics, use=screen4,
+	smso=\E[7m, use=ecma+italics, use=ecma+index,
+	use=screen-base,
 
 #### Tmux
 
@@ -7919,21 +8528,67 @@ screen5|VT 100/ANSI X3.64 virtual terminal (someday),
 # various entries such as screen.xterm-new provide a way to more closely
 # match the terminal.
 tmux|tmux terminal multiplexer,
-	invis=\E[8m, kbs=^?, rmso=\E[27m,
+	invis=\E[8m, rmso=\E[27m,
 	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?
 	    %p5%t;2%;%?%p7%t;8%;m%?%p9%t\016%e\017%;,
-	smso=\E[7m, E3=\E[3J, Smulx=\E[4\:%p1%dm,
+	smso=\E[7m, E3=\E[3J, Smulx=\E[4:%p1%dm,
 	use=ecma+italics, use=ecma+strikeout, use=xterm+edit,
 	use=xterm+pcfkeys, use=xterm+sl, use=xterm+tmux,
-	use=screen,
+	use=screen, use=bracketed+paste, use=report+version,
+	use=xterm+focus,
 
 tmux-256color|tmux with 256 colors,
 	use=xterm+256setaf, use=tmux,
 
 tmux-direct|tmux with direct-color indexing,
-	setal=\E[%?%p1%{8}%<%t5%p1%d%e58\:2\:\:%p1%{65536}%/%d\:%p1
-	      %{256}%/%{255}%&%d\:%p1%{255}%&%d%;m,
-	use=xterm+direct, use=tmux,
+	use=kitty+setal, use=xterm+direct, use=tmux,
+
+#### Mosh
+# https://mosh.org/
+# mosh 1.3.2
+#
+# mosh's DA1 identifies it as a VT220, but sets $TERM to "xterm" or
+# "xterm-256color" (hard-coded), which in its pretense that it is xterm, is
+# several years out of date.
+#
+# There is little documentation; the existing manpages amount to a quarter of
+# the length of mosh.org's heavily promotional website.  This entry is based
+# on testing, and reading the source-code.  For the latter, analysis is aided
+# by the developer's extensive use of hard-coded strings.
+#
+# The website has an example "Tricky unicode", which shows a shell command
+# with a typo (i.e., assuming that a byte in octal uses 4 digits) and suggests
+# that mosh and OS X Terminal "gets it right".
+#
+# The example as shown would not work.  Correcting the typo, xterm gives the
+# result expected by the mosh developer.
+#
+# The other examples follow in a similar vein.
+#
+# It does not support these xterm features:
+#	use=ansi+rep (xterm patch #36, 1997)
+#	use=ecma+strikeout (xterm patch #305, 2014)
+#	use=vt420+lrmm (xterm patch #279, 2012)
+#	titlestack in smcup/rmcup has no effect (xterm patch #251, 2009)
+#	does not support "dim" (xterm patch #305, 2014)
+# In tack
+#	rmkx/smkx has no effect on numeric keypad
+#	acs stuff has no effect, is included here for ease of comparison
+#
+# Unlike screen and tmux, mosh has only limited awareness of a terminal
+# description.  It assumes that the underlying terminal is xterm, and would
+# not work well with terminals using other key-definitions, such as urxvt.
+mosh|mobile shell,
+	U8#1,
+	sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|
+	    %t;7%;%?%p4%t;5%;%?%p7%t;8%;m,
+	sgr0=\E(B\E[m, use=ansi+enq, use=xterm+meta,
+	use=ecma+italics, use=ecma+index, use=xterm+acs,
+	use=xterm+focus, use=xterm+sm+1006, use=xterm+pcfkeys,
+	use=xterm-xfree86, use=bracketed+paste,
+
+mosh-256color|mosh using 256-colors,
+	use=xterm+256color, use=mosh,
 
 #### Dvtm
 
@@ -7957,41 +8612,35 @@ tmux-direct|tmux with direct-color indexing,
 # + Most of the mode-settings in the initialization/reset strings are not
 #   implemented; dvtm copies its description from rxvt.
 dvtm|dynamic virtual terminal manager,
-	am, eo, mir, msgr, xenl, AX,
-	colors#8, cols#80, it#8, lines#24, ncv@, pairs#64,
-	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[2J, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K, el1=\E[1K,
-	enacs=\E(B\E)0, home=\E[H, hpa=\E[%i%p1%dG, ht=^I, hts=\EH,
-	ich=\E[%p1%d@, ich1=\E[@, il=\E[%p1%dL, il1=\E[L, ind=\n,
+	eo, mir, xenl,
+	ncv@,
+	blink=\E[5m, bold=\E[1m, clear=\E[H\E[2J, cub1=^H, cud1=\n,
+	cup=\E[%i%p1%d;%p2%dH, ed=\E[J, el=\E[K, el1=\E[1K,
+	hpa=\E[%i%p1%dG, ich=\E[%p1%d@, ich1=\E[@,
 	is1=\E[?47l\E=\E[?1l,
 	is2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l,
 	kDC=\E[3$, kEND=\E[8$, kHOM=\E[7$, kIC=\E[2$, kLFT=\E[d,
 	kNXT=\E[6$, kPRV=\E[5$, kRIT=\E[c, ka1=\EOw, ka3=\EOy,
-	kb2=\EOu, kbs=^?, kc1=\EOq, kc3=\EOs, kcbt=\E[Z, kcub1=\E[D,
-	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kel=\E[8\^, kend=\E[8~,
-	kent=\EOM, kf0=\E[21~, kf1=\E[11~, kf10=\E[21~,
+	kb2=\EOu, kbs=^?, kc1=\EOq, kc3=\EOs, kcbt=\E[Z, kel=\E[8\^,
+	kend=\E[8~, kent=\EOM, kf0=\E[21~, kf1=\E[11~, kf10=\E[21~,
 	kf11=\E[23~, kf12=\E[24~, kf13=\E[25~, kf14=\E[26~,
 	kf15=\E[28~, kf16=\E[29~, kf17=\E[31~, kf18=\E[32~,
 	kf19=\E[33~, kf2=\E[12~, kf20=\E[34~, kf21=\E[23$,
 	kf22=\E[24$, kf3=\E[13~, kf4=\E[14~, kf5=\E[15~,
 	kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~,
-	khome=\E[7~, kind=\E[a, kmous=\E[M, kri=\E[b, op=\E[39;49m,
-	rc=\E8, rev=\E[7m, ri=\EM, rmacs=^O, rmcup=\E[2J\E[?47l\E8,
-	rmir=\E[4l, rmso=\E[27m, rmul=\E[24m,
+	khome=\E[7~, kind=\E[a, kmous=\E[M, kri=\E[b, rev=\E[7m,
+	ri=\EM, rmir=\E[4l, rmso=\E[27m, rmul=\E[24m,
 	rs1=\E>\E[1;3;4;5;6l\E[?7h\E[m\E[r\E[2J\E[H,
 	rs2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l\E>\E[?1000l\E[?
 	    25h,
-	s0ds=\E(B, s1ds=\E(0, sc=\E7, setab=\E[4%p1%dm,
-	setaf=\E[3%p1%dm,
+	s0ds=\E(B, s1ds=\E(0,
 	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m%?
 	    %p9%t\016%e\017%;,
-	sgr0=\E[m\017, smacs=^N, smcup=\E7\E[?47h, smir=\E[4h,
-	smso=\E[7m, smul=\E[4m, tbc=\E[3g, vpa=\E[%i%p1%dd,
-	use=vt220+vtedit, use=vt220+cvis, use=ecma+italics,
+	sgr0=\E[m\017, smir=\E[4h, smso=\E[7m, smul=\E[4m,
+	vpa=\E[%i%p1%dd, use=ansi+arrows, use=ansi+csr,
+	use=ansi+idl, use=ansi+local, use=xterm+alt47,
+	use=vt220+vtedit, use=vt220+cvis, use=ecma+color,
+	use=ecma+italics, use=vt100+4bsd,
 
 dvtm-256color|dynamic virtual terminal manager with 256 colors,
 	colors#0x100, pairs#0x10000,
@@ -8010,7 +8659,7 @@ dvtm-256color|dynamic virtual terminal manager with 256 colors,
 # from www.ncsa.edu.  This terminfo description file is based on xterm-vt220,
 # xterm+sl, and the docs at NCSA.  It works well.
 #
-# NCSA Telnet 2.6 for Macintosh in vt220 8-bit emulation mode
+# NCSA Telnet 2.6 for Macintosh in VT220 8-bit emulation mode
 # The terminal options should be set as follows:
 #         Xterm sequences ON
 #         use VT wrap mode ON
@@ -8037,41 +8686,38 @@ dvtm-256color|dynamic virtual terminal manager with 256 colors,
 # The status-line manipulation is a mapping of the xterm-compatible control
 # sequences for setting the window-title.  So you must use tsl and fsl in
 # pairs, since the latter ends the string that is loaded to the window-title.
-ncsa-m|ncsa-vt220-8|NCSA Telnet 2.6 for Macintosh in vt220-8 mode,
+ncsa-m|ncsa-vt220-8|NCSA Telnet 2.6 for Macintosh in VT220-8 mode,
 	am, km, mir, msgr, xenl,
-	acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
 	bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[2J, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J,
-	el=\E[K, el1=\E[1K, enacs=\E)0,
+	cub1=^H, cud1=\n, cup=\E[%i%p1%d;%p2%dH, dch=\E[%p1%dP,
+	dch1=\E[P, ed=\E[J, el=\E[K, el1=\E[1K, enacs=\E)0,
 	flash=\E[?5h$<100/>\E[?5l, home=\E[H, ht=^I, hts=\EH,
 	ich=\E[%p1%d@, if=/usr/share/tabset/vt100,
-	il=\E[%p1%dL, il1=\E[L, ind=\n$<150*>,
-	is2=\E7\E[r\E[m\E[?7h\E[?1;4;6l\E[4l\E8\E>, kbs=^H,
-	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
+	ind=\n$<150*>,
+	is2=\E7\E[r\E[m\E[?7h\E[?1;4;6l\E[4l\E8\E>,
 	kdch1=\E[4~, kend=\E[5~, kf1=\E[17~, kf10=\E[28~,
 	kf11=\E[29~, kf12=\E[31~, kf13=\E[32~, kf14=\E[33~,
 	kf15=\E[34~, kf2=\E[18, kf3=\E[19~, kf4=\E[20~, kf5=\E[21~,
 	kf6=\E[23~, kf7=\E[24~, kf8=\E[25~, kf9=\E[26~, khlp=\E[1~,
 	khome=\E[2~, knp=\E[6~, kpp=\E[3~, mc4=\E[4i, mc5=\E[5i,
-	rc=\E8, rev=\E[7m, rf=/usr/share/tabset/vt100, ri=\EM,
-	rmacs=\E(B, rmam=\E[?7l, rmcup=\E[2J\E8, rmir=\E[4l,
-	rmso=\E[27m, rmul=\E[24m,
-	rs2=\E7\E[r\E8\E[m\E[?7h\E[?1;4;6l\E[4l\E>, sc=\E7,
+	rev=\E[7m, rf=/usr/share/tabset/vt100, ri=\EM,
+	rmam=\E[?7l, rmcup=\E[2J\E8, rmir=\E[4l, rmso=\E[27m,
+	rmul=\E[24m,
+	rs2=\E7\E[r\E8\E[m\E[?7h\E[?1;4;6l\E[4l\E>,
 	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p4%t;5%;%?%p1%p3%|%t;7%;m%?
 	    %p9%t\E(0%e\E(B%;,
-	sgr0=\E[m\E(B, smacs=\E(0, smam=\E[?7h, smcup=\E7,
-	smir=\E[4h, smso=\E[7m, smul=\E[4m, tbc=\E[3g,
-	u8=\E[?62;1;6c, use=vt220+cvis, use=xterm+sl,
-	use=ansi+enq,
-ncsa|NCSA Telnet 2.7 for Macintosh in vt220-8 mode,
+	sgr0=\E[m\E(B, smam=\E[?7h, smcup=\E7, smir=\E[4h,
+	smso=\E[7m, smul=\E[4m, tbc=\E[3g, u8=\E[?62;1;6c,
+	use=ansi+arrows, use=ansi+csr, use=ansi+idl,
+	use=ansi+local, use=vt220+cvis, use=xterm+acs,
+	use=xterm+sl, use=ansi+enq,
+
+ncsa|NCSA Telnet 2.7 for Macintosh in VT220-8 mode (color),
 	use=ncsa-m, use=klone+color,
-ncsa-ns|NCSA Telnet 2.7 for Macintosh in vt220-8 mode,
+ncsa-ns|NCSA Telnet 2.7 for Macintosh in VT220-8 mode (color w/o status line),
 	hs@,
 	dsl@, fsl@, tsl@, use=ncsa,
-ncsa-m-ns|NCSA Telnet 2.6 for Macintosh in vt220-8 mode,
+ncsa-m-ns|NCSA Telnet 2.6 for Macintosh in VT220-8 mode (no status line),
 	hs@,
 	dsl@, fsl@, tsl@, use=ncsa-m,
 # alternate -TD:
@@ -8080,7 +8726,7 @@ ncsa-m-ns|NCSA Telnet 2.6 for Macintosh in vt220-8 mode,
 # codes, however, since the numeric keypad (VT100) PF1-PF4 are available on
 # some keyboards and many applications require these as F1-F4.
 #
-ncsa-vt220|NCSA Telnet using vt220-compatible function keys,
+ncsa-vt220|NCSA Telnet using VT220-compatible function keys,
 	kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~,
 	kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, kf16=\E[29~,
 	kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, kf2=\EOQ,
@@ -8116,15 +8762,15 @@ elks-glasstty|ELKS glass-TTY capabilities,
 	bel=^G, cr=\r, ht=^I, ind=\n, kbs=^H, kcub1=^H, kcud1=\n,
 	nel=\r\n,
 
-elks-vt52|ELKS vt52 console,
+elks-vt52|ELKS VT52 console,
 	clear=\EH\EJ, cub1=\ED, cud1=\EB, cuf1=\EC,
 	cup=\EY%p1%{32}%+%c%p2%{32}%+%c, cuu1=\EA, el=\EK,
 	home=\EH, use=elks-glasstty,
 
 elks-ansi|ELKS ANSI console,
-	clear=\E[H\E[2J, cub1=\E[D, cud1=\E[B, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, el=\E[K, home=\E[H,
-	rmso=\E[m, smso=\E[7m, use=elks-glasstty,
+	clear=\E[H\E[2J, cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A,
+	el=\E[K, home=\E[H, use=ansi+local1, use=ansi+sgrso,
+	use=elks-glasstty,
 
 # As a matter of fact, ELKS 0.0.83 on PCs defaults to ANSI emulation
 # instead of VT52, but the "elks" entry still refers to the latter.
@@ -8150,24 +8796,24 @@ pccons|pcconsole|ANSI (mostly) Alpha PC console terminal emulation,
 	cols#80, lines#25,
 	bel=^G, clear=\E[H\E[2J, cr=\r, cub1=^H, cud1=\n, cuf1=\E[C,
 	cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, dch1=\E[P, dl1=\E[M,
-	el=\E[K, home=\E[H, ht=^I, ich1=\E[@, il1=\E[L, kbs=^H,
-	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, khome=\E[H,
-	nel=\r\n, rev=\E[7m, rmso=\E[m, sgr0=\E[m, smso=\E[7m,
+	el=\E[K, home=\E[H, ht=^I, ich1=\E[@, il1=\E[L, nel=\r\n,
+	rev=\E[7m, rmso=\E[m, sgr0=\E[m, smso=\E[7m,
+	use=ansi+arrows,
 
 #### Sun consoles
 #
 
-# :is1: resets scrolling region in case a previous user had used "tset vt100"
+# :is1: resets scrolling region in case a previous user had used "tset VT100"
 oldsun|Sun Microsystems Workstation console,
 	OTbs, am, km, mir, msgr,
 	cols#80, it#8, lines#34,
-	bel=^G, clear=^L, cr=\r, cub1=^H, cud1=\E[B, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, dch=\E[%p1%dP,
-	dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K, ht=^I,
-	ich=\E[%p1%d@, ich1=\E[@, il=\E[%p1%dL, il1=\E[L, ind=\n,
-	is1=\E[1r, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
-	kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, khome=\E[H,
-	rmso=\E[m, sgr0=\E[m, smso=\E[7m,
+	bel=^G, clear=^L, cr=\r, cub1=^H, cup=\E[%i%p1%d;%p2%dH,
+	dch=\E[%p1%dP, dch1=\E[P, ed=\E[J, el=\E[K, ht=^I,
+	ich=\E[%p1%d@, ich1=\E[@, ind=\n, is1=\E[1r, kcub1=\E[D,
+	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kf1=\EOP, kf2=\EOQ,
+	kf3=\EOR, kf4=\EOS, khome=\E[H, rmso=\E[m, sgr0=\E[m,
+	smso=\E[7m, use=ansi+idl, use=ansi+local1,
+
 # From: Alexander Lukyanov <lav@video.yars.free.net>, 14 Nov 1995
 # <lines> capability later corrected by J.T. Conklin <jtc@cygnus.com>
 # SGR 1, 4 aren't supported - removed bold/underline (T.Dickey 17 Jan 1998)
@@ -8176,22 +8822,42 @@ sun-il|Sun Microsystems console with working insert-line,
 	cols#80, lines#34,
 	bel=^G, clear=^L, cr=\r, cub1=^H, cud1=\n, cuf1=\E[C,
 	cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, dch=\E[%p1%dP,
-	dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K, ht=^I,
-	ich=\E[%p1%d@, ich1=\E[@, il=\E[%p1%dL, il1=\E[L, ind=\n,
-	kb2=\E[218z, kbs=^H, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C,
-	kcuu1=\E[A, kdch1=^?, kend=\E[220z, kf1=\E[224z,
+	dch1=\E[P, ed=\E[J, el=\E[K, ht=^I, ich=\E[%p1%d@, ich1=\E[@,
+	ind=\n, kb2=\E[218z, kdch1=^?, kend=\E[220z, kf1=\E[224z,
 	kf10=\E[233z, kf11=\E[234z, kf12=\E[235z, kf2=\E[225z,
 	kf3=\E[226z, kf4=\E[227z, kf5=\E[228z, kf6=\E[229z,
 	kf7=\E[230z, kf8=\E[231z, kf9=\E[232z, khome=\E[214z,
 	kich1=\E[247z, knp=\E[222z, kopt=\E[194z, kpp=\E[216z,
 	kres=\E[193z, kund=\E[195z, rev=\E[7m, rmso=\E[m, rmul@,
 	rs2=\E[s, sgr=\E[0%?%p1%p3%|%t;7%;m, sgr0=\E[m,
-	smso=\E[7m, u8=\E[1t, u9=\E[11t,
+	smso=\E[7m, u8=\E[1t, u9=\E[11t, use=ansi+arrows,
+	use=ansi+idl,
+
 # On some versions of CGSIX framebuffer firmware (SparcStation 5), <il1>/<il>
 # flake out on the last line.  Unfortunately, without them the terminal has no
 # way to scroll.
 sun-cgsix|sun-ss5|Sun SparcStation 5 console,
 	il@, il1@, use=sun-il,
+
+# The Sun console was documented in the wscons manual page (apparently
+# unrelated to the "wscons" used by some of the BSDs).
+#
+#    https://illumos.org/man/4D/wscons
+#    https://www.bitsavers.org/pdf/sun/sun1/800-0345_Sun-1_System_Reference_Manual_Jul82.pdf
+#
+# The early cmdtool and shelltool programs in Sun's NeWS were based on this.
+# After NeWS was discontinued, XView provided a similar shelltool, with an
+# incomplete manual page.  Presumably the intent was to document features of
+# shelltool not in wscons:
+#
+#    https://manpages.ubuntu.com/manpages/bionic/en/man1/shelltool.1.html
+#    https://manpages.ubuntu.com/manpages/bionic/en/man1/cmdtool.1.html
+#
+# The wscons manual page and the XView source show that it had no feature that
+# could be used in ncurses u6/u7/u8/u9 extensions.  Interesting, the XView
+# source shows that its shelltool could tell the host what a particular mode
+# was set to.  But neither that nor its CSI..t controls support u6/u7/u8/u9.
+#
 # If you are using an SS5, change the sun definition to use sun-ss5.
 sun|sun1|sun2|Sun Microsystems Inc. workstation console,
 	use=sun-il,
@@ -8202,15 +8868,13 @@ sun+sl|Sun Workstation window status line,
 
 # From: <john@ucbrenoir>  Tue Sep 24 13:14:44 1985
 sun-s|Sun Microsystems Workstation window with status line,
-	hs,
-	dsl=\E]l\E\\, fsl=\E\\, tsl=\E]l, use=sun,
+	use=sun+sl, use=sun,
 sun-e-s|sun-s-e|Sun Microsystems Workstation with status hacked for emacs,
-	hs,
-	dsl=\E]l\E\\, fsl=\E\\, tsl=\E]l, use=sun-e,
+	use=sun+sl, use=sun-e,
 sun-48|Sun 48-line window,
 	cols#80, lines#48, use=sun,
 sun-34|Sun 34-line window,
-	cols#80, lines#34, use=sun,
+	use=sun,
 sun-24|Sun 24-line window,
 	cols#80, lines#24, use=sun,
 sun-17|Sun 17-line window,
@@ -8252,16 +8916,13 @@ sun-type4|Sun Workstation console with type 4 keyboard,
 #	blink=\E[5m
 # It supports bold, but not underline -TD (2009-09-19)
 sun-color|Sun Microsystems Workstation console with color support (IA systems),
-	colors#8, ncv#3, pairs#64,
-	bold=\E[1m, cub=\E[%p1%dD, cud=\E[%p1%dB, cuf=\E[%p1%dC,
-	cuu=\E[%p1%dA, home=\E[H, op=\E[0m, rs2=\E[s,
-	setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
+	bold=\E[1m, cub1=^H, cud1=\n, home=\E[H, op=\E[0m,
 	setb=\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}
 	     %=%t3%e%p1%d%;m,
 	setf=\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}
 	     %=%t3%e%p1%d%;m,
-	sgr=\E[0%?%p6%t;1%;%?%p1%p3%|%t;7%;m, sgr0=\E[m,
-	smso=\E[7m, use=sun,
+	sgr=\E[0%?%p6%t;1%;%?%p1%p3%|%t;7%;m, use=ansi+local,
+	use=sun, use=klone+color,
 
 #### Iris consoles
 #
@@ -8272,18 +8933,17 @@ sun-color|Sun Microsystems Workstation console with color support (IA systems),
 # See the note on Iris extensions near the end of this file.
 # Finally, removed suboptimal <clear>=\EH\EJ and added <cud1> &
 # <flash> from BRL -- esr)
-wsiris|iris40|iris emulating a 40 line visual 50 (approximately),
+wsiris|iris40|IRIS emulating a 40 line Visual 50 (approximately),
 	OTbs, OTnc, OTpt, am,
 	OTkn#3, cols#80, it#8, lines#40,
 	OTnl=\EB, bel=^G, clear=\Ev, cnorm=\E>, cub1=^H, cud1=\EB,
 	cuf1=\EC, cup=\EY%p1%{32}%+%c%p2%{32}%+%c, cuu1=\EA,
 	cvvis=\E;, dim=\E7F2, dl1=\EM, ed=\EJ, el=\EK,
 	flash=\E7F4\E7B1\013\E7F7\E7B0, home=\EH, ht=^I, il1=\EL,
-	ind=\n, is2=\E7B0\E7F7\E7C2\E7R3, kcub1=\ED, kcud1=\EB,
-	kcuf1=\EC, kcuu1=\EA, kf0=\E0, kf1=\E1, kf2=\E2, kf3=\E3,
-	kf4=\E4, kf5=\E5, kf6=\E6, kf7=\E7, kf8=\E8, kf9=\E9, ri=\EI,
-	rmso=\E0@, rmul=\E7R3\E0@, sgr0=\E7F7, smso=\E9P,
-	smul=\E7R2\E9P,
+	ind=\n, is2=\E7B0\E7F7\E7C2\E7R3, kf0=\E0, kf1=\E1,
+	kf2=\E2, kf3=\E3, kf4=\E4, kf5=\E5, kf6=\E6, kf7=\E7, kf8=\E8,
+	kf9=\E9, ri=\EI, rmso=\E0@, rmul=\E7R3\E0@, sgr0=\E7F7,
+	smso=\E9P, smul=\E7R2\E9P, use=vt52+arrows,
 
 #### NeWS consoles
 #
@@ -8348,70 +9008,70 @@ nextshell|NeXT Shell application,
 #
 
 # (news-unk: this had :KB=news: -- esr)
-news-unk|SONY NEWS vt100 emulator common entry,
+news-unk|Sony NEWS VT100 emulator common entry,
 	OTbs, OTpt, am, xenl,
 	cols#80,
 	OTnl=\n, bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[2J,
-	cr=\r, csr=\E[%i%p1%d;%p2%dr, cub1=^H, cud1=\n, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, dl=\E[%p1%dM, dl1=\E[M,
-	ed=\E[J, el=\E[K, home=\E[H, ht=^I,
-	if=/usr/share/tabset/vt100, il=\E[%p1%dL, il1=\E[L,
+	cr=\r, cub1=^H, cud1=\n, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
+	cuu1=\E[A, ed=\E[J, el=\E[K, home=\E[H, ht=^I,
+	if=/usr/share/tabset/vt100,
 	is2=\E[?7h\E[?1h\E[?3l\E7\E8, kbs=^H, kcub1=\EOD,
 	kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kf0=\EOY, kf1=\EOP,
 	kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf5=\EOT, kf6=\EOU, kf7=\EOV,
-	kf8=\EOW, kf9=\EOX, rc=\E8, rev=\E[7m, ri=\EM,
-	rmkx=\E[?1l\E>, rmso=\E[m, rmul=\E[m,
-	rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h\E[r, sc=\E7,
-	sgr0=\E[m, smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m,
+	kf8=\EOW, kf9=\EOX, rev=\E[7m, ri=\EM, rmkx=\E[?1l\E>,
+	rmso=\E[m, rmul=\E[m,
+	rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h\E[r, sgr0=\E[m,
+	smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, use=ansi+csr,
+	use=ansi+idl,
 #
 # (news-29: this had :TY=ascii: --esr)
-news-29|SONY NEWS vt100 emulator with 29 lines,
+news-29|Sony NEWS VT100 emulator with 29 lines,
 	lines#29, use=news-unk,
 # (news-29-euc: this had :TY=euc: --esr)
-news-29-euc|SONY NEWS vt100 emulator with 29 lines and EUC,
+news-29-euc|Sony NEWS VT100 emulator with 29 lines and EUC,
 	use=news-29,
 # (news-29-sjis: this had :TY=sjis: --esr)
-news-29-sjis|SONY NEWS vt100 emulator with 29 lines and SJIS,
+news-29-sjis|Sony NEWS VT100 emulator with 29 lines and SJIS,
 	use=news-29,
 #
 # (news-33: this had :TY=ascii: --esr)
-news-33|SONY NEWS vt100 with 33 lines,
+news-33|Sony NEWS VT100 with 33 lines,
 	lines#33, use=news-unk,
 # (news-33-euc: this had :TY=euc: --esr)
-news-33-euc|SONY NEWS vt100 with 33 lines and EUC,
+news-33-euc|Sony NEWS VT100 with 33 lines and EUC,
 	use=news-33,
 # (news-33-sjis: this had :TY=sjis: --esr)
-news-33-sjis|SONY NEWS vt100 with 33 lines and SJIS,
+news-33-sjis|Sony NEWS VT100 with 33 lines and SJIS,
 	use=news-33,
 #
 # (news-42: this had :TY=ascii: --esr)
-news-42|SONY NEWS vt100 with 42 lines,
+news-42|Sony NEWS VT100 with 42 lines,
 	lines#42, use=news-unk,
 # (news-42-euc: this had :TY=euc: --esr)
-news-42-euc|SONY NEWS vt100 with 42 lines and EUC,
+news-42-euc|Sony NEWS VT100 with 42 lines and EUC,
 	use=news-42,
 # (news-42-sjis: this had :TY=sjis: --esr)
-news-42-sjis|SONY NEWS vt100 with 42 lines and SJIS,
+news-42-sjis|Sony NEWS VT100 with 42 lines and SJIS,
 	use=news-42,
 #
 #	NEWS-OS old termcap entry
 #
 # (news-old-unk: this had :KB=news:TY=sjis: --esr)
-news-old-unk|SONY NEWS vt100 emulator common entry,
+news-old-unk|old Sony NEWS VT100 emulator common entry,
 	OTbs, OTpt, am, xenl,
 	cols#80, vt#3,
 	OTnl=\n, bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[;H\E[2J,
-	cr=\r, csr=\E[%i%p1%d;%p2%dr, cub1=^H, cud1=\n, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, ed=\E[J, el=\E[K,
-	home=\E[H, ht=^I, if=/usr/share/tabset/vt100, kbs=^H,
-	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kf1=\EOP,
-	kf2=\EOQ, kf3=\EOR, kf4=\EOS, rc=\E8, rev=\E[7m, ri=\EM,
-	rmkx=\E[?1l\E>, rmso=\E[m, rmul=\E[m,
-	rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, sc=\E7,
-	sgr0=\E[m, smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m,
+	cr=\r, cub1=^H, cud1=\n, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
+	cuu1=\E[A, ed=\E[J, el=\E[K, home=\E[H, ht=^I,
+	if=/usr/share/tabset/vt100, kbs=^H, kcub1=\E[D,
+	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kf1=\EOP, kf2=\EOQ,
+	kf3=\EOR, kf4=\EOS, rev=\E[7m, ri=\EM, rmkx=\E[?1l\E>,
+	rmso=\E[m, rmul=\E[m,
+	rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, sgr0=\E[m,
+	smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, use=ansi+csr,
 #
 # (nwp512: this had :DE=^H:, which I think means <OTbs> --esr)
-nwp512|news|nwp514|news40|vt100-bm|old sony vt100 emulator 40 lines,
+nwp512|news|nwp514|news40|vt100-bm|nwp512-o|nwp514-o|news-o|news40-o|vt100-bm-o|old Sony VT100 emulator 40 lines,
 	OTbs,
 	lines#40,
 	is2=\E7\E[r\E8\EE\EE\EE\EM\EM\EM\E[?7h\E[?1l\E[?3l\E7\E[1;40
@@ -8419,21 +9079,13 @@ nwp512|news|nwp514|news40|vt100-bm|old sony vt100 emulator 40 lines,
 	use=news-old-unk,
 #
 # (nwp512-a: this had :TY=ascii: and the alias vt100-bm --esr)
-nwp512-a|nwp514-a|news-a|news42|news40-a|sony vt100 emulator 42 line,
+nwp512-a|nwp514-a|news-a|news42|news40-a|old Sony VT100 emulator 42 line,
 	lines#42,
 	is2=\E[?7h\E[?1l\E[?3l\E7\E[1;42r\E8,
 	use=news-old-unk,
 #
-# (nwp-512-o: this had :KB=nwp410:DE=^H:  I interpret the latter as <OTbs>. --esr)
-nwp512-o|nwp514-o|news-o|news40-o|vt100-bm-o|sony vt100 emulator 40 lines,
-	OTbs,
-	lines#40,
-	is2=\E7\E[r\E8\EE\EE\EE\EM\EM\EM\E[?7h\E[?1l\E[?3l\E7\E[1;40
-	    r\E8,
-	use=news-old-unk,
-#
 # (nwp513: this had :DE=^H: and the alias vt100-bm --esr)
-nwp513|nwp518|nwe501|newscbm|news31|sony vt100 emulator 33 lines,
+nwp513|nwp518|nwe501|newscbm|news31|nwp513-o|nwp518-o|nwe501-o|nwp251-o|newscbm-o|news31-o|old Sony VT100 emulator 31 lines,
 	OTbs,
 	lines#31,
 	is2=\E7\E[r\E8\EE\EE\EE\EM\EM\EM\E[?7h\E[?1l\E[?3l\E7\E[1;31
@@ -8442,23 +9094,15 @@ nwp513|nwp518|nwe501|newscbm|news31|sony vt100 emulator 33 lines,
 #
 # (nwp513-a: this had :TY=ascii: and :DE=^H:, which I interpret as <OTbs>; --esr)
 # also the alias vt100-bm.
-nwp513-a|nwp518-a|nwe501-a|nwp251-a|newscbm-a|news31-a|newscbm33|news33|old sony vt100 emulator 33 lines,
+nwp513-a|nwp518-a|nwe501-a|nwp251-a|newscbm-a|news31-a|newscbm33|news33|old Sony VT100 emulator 33 lines,
 	OTbs,
 	lines#33,
 	is2=\E7\E[r\E8\EE\EE\EE\EM\EM\EM\E[?7h\E[?1l\E[?3l\E7\E[1;33
 	    r\E8,
 	use=news-old-unk,
 #
-# (nwp513-o: had :DE=^H:, I think that's <OTbs>; also the alias vt100-bm --esr)
-nwp513-o|nwp518-o|nwe501-o|nwp251-o|newscbm-o|news31-o|old sony vt100 emulator 33 lines,
-	OTbs,
-	lines#31,
-	is2=\E7\E[r\E8\EE\EE\EE\EM\EM\EM\E[?7h\E[?1l\E[?3l\E7\E[1;31
-	    r\E8,
-	use=news-old-unk,
-#
 # (news28: this had :DE=^H:, I think that's <OTbs>, and :KB=nws1200: --esr)
-news28|sony vt100 emulator 28 lines,
+news28|old Sony VT100 emulator 28 lines,
 	OTbs,
 	lines#28,
 	is2=\E7\E[r\E8\EE\EE\EE\EM\EM\EM\E[?7h\E[?1l\E[?3l\E7\E[1;28
@@ -8466,35 +9110,33 @@ news28|sony vt100 emulator 28 lines,
 	use=news-old-unk,
 #
 # (news29: this had :TY=ascii:KB=nws1200:\ --esr)
-news29|news28-a|sony vt100 emulator 29 lines,
+news29|news28-a|old Sony VT100 emulator 29 lines,
 	lines#29,
 	is2=\E7\E[r\E8\EE\EE\EE\EM\EM\EM\E[?7h\E[?1l\E[?3l\E7\E[1;29
 	    r\E8,
 	use=news-old-unk,
 #
 # (news511: this had :TY=sjis: --esr)
-nwp511|nwp-511|nwp-511 vt100,
+nwp511|nwp-511|nwp-511 VT100,
 	OTbs, OTpt, am, xenl,
 	cols#80, lines#24,
-	clear=\E[;H\E[2J$<20/>, cub1=\E[D, cud1=\E[B, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A$<2/>, dl1=\E[M,
-	ed=\E[J$<30/>, el=\E[K$<3/>,
+	clear=\E[;H\E[2J$<20/>, cup=\E[%i%p1%d;%p2%dH,
+	cuu1=\E[A$<2/>, dl1=\E[M, ed=\E[J$<30/>, el=\E[K$<3/>,
 	flash=\E[?5h\0\0\0\0\0\0\0\0\0\0\0\0\0\E[?5l,
 	il1=\E[L, is2=\E[?5l\E[?1l\E>\E[?7h\E[?8h, kcub1=\E[D,
 	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kf1=\EOP, kf2=\EOQ,
 	kf3=\EOR, kf4=\EOS, kf5=\EOT, kf6=\E#W, khome=\E[H,
 	ri=\EM$<5/>, rmso=\E[m$<2/>, rmul=\E[m$<2/>,
 	rs2=\E7\E[r\E8\E[?5l\E[?1l\E>\E[?7h\E[?8h,
-	smso=\E[7m$<2/>, smul=\E[4m$<2/>,
+	smso=\E[7m$<2/>, smul=\E[4m$<2/>, use=ansi+local1,
 # (news517: this had :TY=sjis:. --esr)
-nwp517|nwp-517|nwp-517 vt200 80 cols 30 rows,
-	eslok, hs,
+nwp517|nwp-517|nwp-517 VT200 80 cols 30 rows,
 	cols#80, lines#30,
-	OTi2=\E[2$~\n, dsl=\E[1$~, fsl=\E[0$},
+	OTi2=\E[2$~\n, dsl=\E[1$~,
 	is2=\E7\E[r\E8\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h,
-	tsl=\E[1$}\E[;%df, use=vt220-base,
+	tsl=\E[1$}\E[;%df, use=dec+sl, use=vt220-base,
 # (news517-w: this had :TY=sjis:. --esr)
-nwp517-w|nwp-517-w|nwp-517 vt200 132 cols 50 rows,
+nwp517-w|nwp-517-w|nwp-517 VT200 132 cols 50 rows,
 	eslok, hs,
 	cols#132, lines#50,
 	OTi2=\E[2$~\n, dsl=\E[1$~, fsl=\E[0$},
@@ -8511,28 +9153,25 @@ dtterm|CDE desktop terminal,
 	am, mir, msgr, xenl, xon,
 	cols#80, it#8, lines#24, lm#0, ncv@,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[J, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m, dl=\E[%p1%dM,
-	dl1=\E[M, ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K,
-	enacs=\E(B\E)0, flash=\E[?5h$<200>\E[?5l, home=\E[H,
-	ht=^I, hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L,
-	ind=\ED, invis=\E[8m, is2=\E F\E>\E[?1l\E[?7h\E[?45l,
+	bel=^G, bold=\E[1m, cr=\r, cub1=^H, cud1=\n,
+	cup=\E[%i%p1%d;%p2%dH, dch=\E[%p1%dP, dch1=\E[P,
+	dim=\E[2m, ech=\E[%p1%dX, el1=\E[1K, enacs=\E(B\E)0,
+	flash=\E[?5h$<200>\E[?5l, home=\E[H, ht=^I, hts=\EH,
+	ich=\E[%p1%d@, ind=\ED, is2=\E F\E>\E[?1l\E[?7h\E[?45l,
 	kbs=^H, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
 	kf1=\E[11~, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~,
 	kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, kf16=\E[29~,
 	kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, kf2=\E[12~,
 	kf20=\E[34~, kf3=\E[13~, kf4=\E[14~, kf5=\E[15~,
 	kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~,
-	khlp=\E[28~, nel=\EE, rc=\E8, rev=\E[7m, ri=\EM, rmacs=^O,
-	rmam=\E[?7l, rmir=\E[4l, rmso=\E[22;27m, rmul=\E[24m,
-	sc=\E7,
+	khlp=\E[28~, nel=\EE, ri=\EM, rmacs=^O, rmam=\E[?7l,
+	rmir=\E[4l, rmso=\E[22;27m, rmul=\E[24m,
 	sgr=\E[0%?%p1%t;2;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p5
 	    %t;2%;%?%p6%t;1%;%?%p7%t;8%;m%?%p9%t\016%e\017%;,
 	sgr0=\E[m\017, smacs=^N, smam=\E[?7h, smir=\E[4h,
-	smso=\E[2;7m, smul=\E[4m, tbc=\E[3g, use=vt220+vtedit,
+	smso=\E[2;7m, smul=\E[4m, tbc=\E[3g, use=ansi+csr,
+	use=ansi+erase, use=ansi+idl, use=ansi+local,
+	use=ansi+sgr, use=decid+cpr, use=vt220+vtedit,
 	use=vt220+cvis, use=ecma+color,
 
 ######## Non-Unix Consoles
@@ -8554,43 +9193,34 @@ emx-base|DOS special keys,
 #
 # Removed: rmacs=\E[10m, smacs=\E[11m, because OS/2 does not implement acs.
 ansi-emx|ANSI.SYS color,
-	am, bce, eo, mir, msgr, xon,
-	colors#8, cols#80, it#8, lines#25, pairs#64,
-	bel=^G, blink=\E[5m, bold=\E[1m,
-	clear=\E[1;33;44m\E[H\E[J, cr=\r, cub1=^H, cud1=\n,
-	cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A,
-	dch=\E[%p1%dp, ed=\E[J, el=\E[K,
-	flash=\E[?5h$<100/>\E[?5l, home=\E[H, ht=^I, hts=\EH,
-	ich=\E[%p1%d@, ich1=\E[@, ind=\n, kb2=\E[G, kbs=^H, kf0=\0D,
-	kll=\0O, kspd=^Z, nel=\r\n, rev=\E[5;37;41m, rmir=\E[4l,
-	rmpch=\E[10m, rmso=\E[0;44m\E[1;33m,
-	rmul=\E[0;44m\E[1;33m, rs1=\Ec, setab=\E[4%p1%dm,
-	setaf=\E[3%p1%dm, sgr0=\E[0m\E[1;33;44m, smir=\E[4h,
-	smpch=\E[11m, smso=\E[0;31;47m, smul=\E[1;31;44m,
-	tbc=\E[3g, u8=\E[?6c, u9=\E[c, use=vt220+cvis,
-	use=emx-base,
+	eo,
+	clear=\E[1;33;44m\E[H\E[J, cr=\r, cud1=\n, dch=\E[%p1%dp,
+	ed=\E[J, flash=\E[?5h$<100/>\E[?5l, ht=^I, hts=\EH,
+	ich=\E[%p1%d@, ich1=\E[@, ind=\n, kb2=\E[G, kf0=\0D, kll=\0O,
+	kspd=^Z, nel=\r\n, rev=\E[5;37;41m, rmir=\E[4l,
+	rmso=\E[0;44m\E[1;33m, rmul=\E[0;44m\E[1;33m, rs1=\Ec,
+	sgr0=\E[0m\E[1;33;44m, smir=\E[4h, smso=\E[0;31;47m,
+	smul=\E[1;31;44m, tbc=\E[3g, u8=\E[?6c, u9=\E[c,
+	use=vt220+cvis, use=emx-base,
 # nice colors for Emacs (white on blue, mode line white on cyan)
 ansi-color-2-emx|ANSI.SYS color 2,
 	clear=\E[0;37;44m\E[H\E[J, rev=\E[1;37;46m,
-	rmso=\E[0;37;44m, rmul=\E[0;37;44m, rs1=\Ec,
-	setaf=\E[3%p1%dm, sgr0=\E[0;37;44m, smso=\E[1;37;46m,
-	smul=\E[1;36;44m, use=ansi-emx,
+	rmso=\E[0;37;44m, rmul=\E[0;37;44m, sgr0=\E[0;37;44m,
+	smso=\E[1;37;46m, smul=\E[1;36;44m, use=ansi-emx,
 # nice colors for Emacs (white on black, mode line black on cyan)
 ansi-color-3-emx|ANSI.SYS color 3,
 	clear=\E[0;37;40m\E[H\E[J, rev=\E[1;37;46m,
-	rmso=\E[0;37;40m, rmul=\E[0;37;40m, rs1=\Ec,
-	setaf=\E[3%p1%dm, sgr0=\E[0;10m, smso=\E[1;37;46m,
-	smul=\E[0;36;40m, use=ansi-emx,
-mono-emx|stupid monochrome ansi terminal with only one kind of emphasis,
+	rmso=\E[0;37;40m, rmul=\E[0;37;40m, sgr0=\E[0;10m,
+	smso=\E[1;37;46m, smul=\E[0;36;40m, use=ansi-emx,
+mono-emx|stupid monochrome ANSI terminal with only one kind of emphasis,
 	am,
 	cols#80, it#8, lines#24,
-	clear=\E[H\E[2J$<50>, cub1=\E[D, cud1=\E[B, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, el=\E[K, home=\E[H,
-	ht=^I, kb2=\E[G, kbs=^H, kcub1=\0K, kcud1=\0P, kcuf1=\0M,
-	kcuu1=\0H, kf0=\0D, kf1=\0;, kf2=\0<, kf3=\0=, kf4=\0>,
-	kf5=\0?, kf6=\0@, kf7=\0A, kf8=\0B, kf9=\0C, khome=\0G,
-	kich1=\0R, kll=\0O, knp=\0Q, kpp=\0I, nel=\r\n, rev=\E[7m,
-	sgr0=\E[0m,
+	clear=\E[H\E[2J$<50>, cup=\E[%i%p1%d;%p2%dH, el=\E[K,
+	home=\E[H, ht=^I, kb2=\E[G, kbs=^H, kcub1=\0K, kcud1=\0P,
+	kcuf1=\0M, kcuu1=\0H, kf0=\0D, kf1=\0;, kf2=\0<, kf3=\0=,
+	kf4=\0>, kf5=\0?, kf6=\0@, kf7=\0A, kf8=\0B, kf9=\0C,
+	khome=\0G, kich1=\0R, kll=\0O, knp=\0Q, kpp=\0I, nel=\r\n,
+	rev=\E[7m, sgr0=\E[0m, use=ansi+local1,
 
 #### Cygwin
 
@@ -8660,31 +9290,23 @@ cygwinB19|ANSI emulation for cygwin32,
 cygwin|ANSI emulation for Cygwin,
 	am, hs, mir, msgr, xon,
 	colors#8, it#8, pairs#64,
-	acsc=+\020\,\021-\030.^Y0\333`\004a\261f\370g\361h\260j
-	     \331k\277l\332m\300n\305o~p\304q\304r\304s_t\303u\264v
-	     \301w\302x\263y\363z\362{\343|\330}\234~\376,
-	bel=^G, bold=\E[1m, clear=\E[H\E[J, cr=\r, cub=\E[%p1%dD,
-	cub1=^H, cud=\E[%p1%dB, cud1=\E[B, cuf=\E[%p1%dC,
-	cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA,
-	cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM,
-	dl1=\E[M, ed=\E[J, el=\E[K, el1=\E[1K, fsl=^G, home=\E[H,
-	hpa=\E[%i%p1%dG, ht=^I, ich=\E[%p1%d@, ich1=\E[@,
-	il=\E[%p1%dL, il1=\E[L, ind=\n, invis=\E[8m, kb2=\E[G,
-	kbs=^H, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
-	kf1=\E[[A, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~,
-	kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, kf16=\E[29~,
-	kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, kf2=\E[[B,
-	kf20=\E[34~, kf3=\E[[C, kf4=\E[[D, kf5=\E[[E, kf6=\E[17~,
-	kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, kspd=^Z, nel=\r\n,
-	op=\E[39;49m, rc=\E8, rev=\E[7m, ri=\EM, rmacs=\E[10m,
-	rmcup=\E[2J\E[?47l\E8, rmir=\E[4l, rmpch=\E[10m,
-	rmso=\E[27m, rmul=\E[24m, rs1=\Ec\E]R, sc=\E7,
-	setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
+	bel=^G, bold=\E[1m, cr=\r, cub=\E[%p1%dD, cub1=^H,
+	cup=\E[%i%p1%d;%p2%dH, el1=\E[1K, fsl=^G, home=\E[H, ht=^I,
+	ind=\n, invis=\E[8m, kb2=\E[G, kf1=\E[[A, kf10=\E[21~,
+	kf11=\E[23~, kf12=\E[24~, kf13=\E[25~, kf14=\E[26~,
+	kf15=\E[28~, kf16=\E[29~, kf17=\E[31~, kf18=\E[32~,
+	kf19=\E[33~, kf2=\E[[B, kf20=\E[34~, kf3=\E[[C, kf4=\E[[D,
+	kf5=\E[[E, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~,
+	khome=\E[1~, kspd=^Z, nel=\r\n, op=\E[39;49m, rc=\E8,
+	rev=\E[7m, ri=\EM, rmpch=\E[10m, rmso=\E[27m, rmul=\E[24m,
+	rs1=\Ec\E]R, sc=\E7, setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
 	sgr=\E[0;10%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p6%t;1%;%?%p7
 	    %t;8%;%?%p9%t;11%;m,
-	sgr0=\E[0;10m, smacs=\E[11m, smcup=\E7\E[?47h,
-	smir=\E[4h, smpch=\E[11m, smso=\E[7m, smul=\E[4m, tsl=\E];,
-	vpa=\E[%i%p1%dd, use=vt220+pcedit, use=vt102+enq,
+	sgr0=\E[0;10m, smpch=\E[11m, smso=\E[7m, smul=\E[4m,
+	tsl=\E];, use=ansi+arrows, use=ansi+erase, use=ansi+idc,
+	use=ansi+idl, use=ansi+local, use=ansi+rca2,
+	use=vt220+pcedit, use=vt102+enq, use=klone+acs,
+	use=xterm+alt47,
 
 # I've supplied this so that you can help test new values and add other
 # features.  Cheers, earnie_boyd@yahoo.com.
@@ -8694,31 +9316,22 @@ cygwin|ANSI emulation for Cygwin,
 # this list, but DOES cause problems so it has been removed
 cygwinDBG|Debug Version for Cygwin,
 	am, eo, mir, msgr, xon,
-	colors#8, cols#80, it#8, lines#24, ncv#3, pairs#64,
-	acsc=+\020\,\021-\030.^Y0\333`\004a\261f\370g\361h\260j
-	     \331k\277l\332m\300n\305o~p\304q\304r\304s_t\303u\264v
-	     \301w\302x\263y\363z\362{\343|\330}\234~\376,
-	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, clear=\E[H\E[J,
-	cr=\r, cub=\E[%p1%dD, cub1=\E[D, cud=\E[%p1%dB, cud1=\E[B,
-	cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
-	cuu=\E[%p1%dA, cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[P,
-	dim=\E[2m, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K,
-	el1=\E[1K, flash=\E[?5h$<200/>\E[?5l, home=\E[H,
-	hpa=\E[%i%p1%dG, ht=^I, hts=\EH, ich=\E[%p1%d@, ich1=\E[@,
-	il=\E[%p1%dL, il1=\E[L, ind=\n, invis=\E[8m, kNXT=\E[6$,
-	kPRV=\E[5$, kb2=\E[G, kbs=^H, kcbt=\E[Z, kcub1=\E[D,
-	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kf1=\E[[A, kf10=\E[21~,
-	kf11=\E[23~, kf12=\E[24~, kf13=\E[25~, kf14=\E[26~,
-	kf15=\E[28~, kf16=\E[29~, kf17=\E[31~, kf18=\E[32~,
-	kf19=\E[33~, kf2=\E[[B, kf20=\E[34~, kf3=\E[[C, kf4=\E[[D,
-	kf5=\E[[E, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~,
-	kspd=^Z, nel=\r\n, op=\E[39;49m, rc=\E8, rev=\E[7m, ri=\EM,
-	rmacs=\E[10m, rmir=\E[4l, rmso=\E[m, rmul=\E[m,
-	rs1=\Ec\E]R, sc=\E7, setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
+	cols#80, lines#24, ncv#3,
+	bel=^G, cr=\r, cup=\E[%i%p1%d;%p2%dH, dim=\E[2m, el1=\E[1K,
+	flash=\E[?5h$<200/>\E[?5l, home=\E[H, hpa=\E[%i%p1%dG,
+	ind=\n, kNXT=\E[6$, kPRV=\E[5$, kb2=\E[G, kcbt=\E[Z,
+	kf1=\E[[A, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~,
+	kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, kf16=\E[29~,
+	kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, kf2=\E[[B,
+	kf20=\E[34~, kf3=\E[[C, kf4=\E[[D, kf5=\E[[E, kf6=\E[17~,
+	kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, khome=\E[1~, kspd=^Z,
+	nel=\r\n, op=\E[39;49m, rc=\E8, ri=\EM, rs1=\Ec\E]R, sc=\E7,
 	sgr=\E[0;10%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p5
 	    %t;2%;%?%p6%t;1%;%?%p7%t;8%;%?%p9%t;12%;m,
-	sgr0=\E[0;10m, smacs=\E[11m, smir=\E[4h, smso=\E[7m,
-	smul=\E[4m, tbc=\E[3g, vpa=\E[%i%p1%dd, use=vt220+pcedit,
+	sgr0=\E[0;10m, vpa=\E[%i%p1%dd, use=ansi+arrows,
+	use=ansi+erase, use=ansi+idc, use=ansi+idl,
+	use=ansi+inittabs, use=ansi+local, use=ansi+sgrbold,
+	use=klone+acs, use=klone+color, use=vt220+pcedit,
 	use=vt220+cvis, use=vt102+enq,
 
 #### DJGPP
@@ -8847,48 +9460,43 @@ djgpp|ANSI emulation for DJGPP alpha,
 	acsc=+\020\,\021-\030.^Y0\333`\004a\261f\370g\361h\260j
 	     \331k\277l\332m\300n\305o~p\304q\304r\304s_t\303u\264v
 	     \301w\302x\263y\363z\362{\343|\330}\234~\376,
-	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[1v,
-	clear=\E[H\E[J, cnorm=\E[v, cr=\r, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\E[B, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	cvvis=\E[2v, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM,
-	dl1=\E[M, ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K,
+	bel=^G, bold=\E[1m, cbt=\E[Z, civis=\E[1v, cnorm=\E[v, cr=\r,
+	cub1=^H, cup=\E[%i%p1%d;%p2%dH, cvvis=\E[2v,
+	dch=\E[%p1%dP, dch1=\E[P, ech=\E[%p1%dX, el1=\E[1K,
 	home=\E[H, hpa=\E[%i%p1%dG, ht=^I, ich=\E[%p1%d@,
-	ich1=\E[@, il=\E[%p1%dL, il1=\E[L, ind=\E[S, invis=\E[8m,
-	kbs=^H, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
-	kf1=\E[[A, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~,
-	kf2=\E[[B, kf3=\E[[C, kf4=\E[[D, kf5=\E[[E, kf6=\E[17~,
-	kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, nel=\r\n, op=\E[37;40m,
-	rev=\E[7m, ri=\E[T, rmso=\E[m, setab=\E[4%p1%dm,
-	setaf=\E[3%p1%dm,
+	ich1=\E[@, ind=\E[S, kf1=\E[[A, kf10=\E[21~, kf11=\E[23~,
+	kf12=\E[24~, kf2=\E[[B, kf3=\E[[C, kf4=\E[[D, kf5=\E[[E,
+	kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~,
+	khome=\E[1~, nel=\r\n, op=\E[37;40m, ri=\E[T, rmso=\E[m,
+	setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
 	sgr=\E[0%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%e;25%;%?
 	    %p6%t;1%;%?%p7%t;8%;m,
 	sgr0=\E[m, smso=\E[7m, smul=\E[4m, vpa=\E[%i%p1%dd,
-	use=vt220+pcedit, use=ecma+index,
+	use=ansi+arrows, use=ansi+erase, use=ansi+idl,
+	use=ansi+local, use=ansi+sgr, use=vt220+pcedit,
+	use=ecma+index,
 
-djgpp203|Entry for DJGPP 2.03,
+djgpp203|entry for DJGPP 2.03,
 	OTbs, am,
 	cols#80, it#8, lines#25,
 	bel=^G, cr=\r, cub1=^H, cud1=\n, ht=^I, ind=\n, kbs=^H, kcub1=^H,
 	kcud1=\n, nel=\r\n,
 
-djgpp204|Entry for DJGPP 2.04,
+djgpp204|entry for DJGPP 2.04,
 	OTbs, am, AX,
 	colors#8, cols#80, it#8, lines#25, ncv#3, pairs#64,
 	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[1v,
-	clear=\E[H\E[2J, cnorm=\E[v, cr=\r, cub=\E[%p1%dD,
-	cub1=\E[D, cud=\E[%p1%dB, cud1=\E[B, cuf=\E[%p1%dC,
-	cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA,
-	cuu1=\E[A, cvvis=\E[2v, dch=\E[%p1%dP, dch1=\E[P,
-	dl=\E[%p1%dM, dl1=\E[M, ech=\E[%p1%dX, ed=\E[J, el=\E[K,
-	home=\E[H, ht=^I, ich=\E[%p1%d@, ich1=\E[@, il=\E[%p1%dL,
-	il1=\E[L, ind=\E[S, invis=\E[8m, kbs=^H, kcub1=\E[D,
-	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kf0=\E[21~, kf1=\E[[A,
-	kf10=\E[21~, kf2=\E[[B, kf3=\E[[C, kf4=\E[[D, kf5=\E[[E,
-	kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, kll=\E[4~,
-	nel=\r\n, rev=\E[7m, ri=\E[T, rmso=\E[m, setab=\E[4%p1%dm,
-	setaf=\E[3%p1%dm, sgr0=\E[m, smso=\E[7m, smul=\E[4m,
-	use=vt220+pcedit, use=ecma+index,
+	clear=\E[H\E[2J, cnorm=\E[v, cr=\r,
+	cup=\E[%i%p1%d;%p2%dH, cvvis=\E[2v, dch=\E[%p1%dP,
+	dch1=\E[P, ech=\E[%p1%dX, ed=\E[J, el=\E[K, home=\E[H, ht=^I,
+	ich=\E[%p1%d@, ich1=\E[@, ind=\E[S, invis=\E[8m,
+	kf0=\E[21~, kf1=\E[[A, kf10=\E[21~, kf2=\E[[B, kf3=\E[[C,
+	kf4=\E[[D, kf5=\E[[E, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~,
+	kf9=\E[20~, khome=\E[1~, kll=\E[4~, nel=\r\n, rev=\E[7m,
+	ri=\E[T, rmso=\E[m, setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
+	sgr0=\E[m, smso=\E[7m, smul=\E[4m, use=ansi+arrows,
+	use=ansi+idl, use=ansi+local, use=vt220+pcedit,
+	use=ecma+index,
 
 #### U/Win
 
@@ -8897,24 +9505,21 @@ djgpp204|Entry for DJGPP 2.04,
 # set (the emulator spits out error messages).  Compare with att6386 -TD
 uwin|U/Win 3.2 console,
 	am, eo, in, msgr, xenl, xon,
-	colors#8, it#8, ncv#58, pairs#64,
+	it#8, ncv#58,
 	acsc=+\020\,\021-\030.^Y0\333`\004a\261f\370g\361h\260i
 	     \316j\331k\277l\332m\300n\305o~p\304q\304r\304s_t\303u
 	     \264v\301w\302x\263y\363z\362{\343|\330}\234~\376,
-	bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[J, cr=\r,
-	cub1=^H, cud1=\n, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
-	cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m,
-	ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K, home=\E[H, ht=^I,
-	hts=\EH, ich=\E[%p1%d@, ich1=\E[@, kbs=^H, kcub1=\E[D,
-	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kdch1=^?, kend=\E[Y,
-	kf1=\EOP, kf10=\EOY, kf11=\EOZ, kf12=\EOA, kf2=\EOQ,
-	kf3=\EOR, kf4=\EOS, kf5=\EOT, kf6=\EOU, kf7=\EOV, kf8=\EOW,
-	kf9=\EOX, khome=\E[H, kich1=\E[@, nel=\r\n, op=\E[39;49m,
-	rc=\E8, rev=\E[7m, rmacs=\E[10m, rmir=\E[4l, rmpch=\E[10m,
-	rmso=\E[27m, rmul=\E[m, rs1=\Ec\E]R, sc=\E7,
-	setab=\E[4%p1%dm, setaf=\E[3%p1%dm, sgr0=\E[0;10m,
-	smacs=\E[11m, smir=\E[4h, smpch=\E[11m, smso=\E[7m,
-	smul=\E[4m, tbc=\E[3g, u6=\E[%i%d;%dR, u7=\E[6n,
+	bel=^G, blink=\E[5m, bold=\E[1m, cr=\r, cub1=^H, cud1=\n,
+	cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, dim=\E[2m,
+	ech=\E[%p1%dX, el1=\E[1K, home=\E[H, ht=^I, hts=\EH,
+	kdch1=^?, kend=\E[Y, kf1=\EOP, kf10=\EOY, kf11=\EOZ,
+	kf12=\EOA, kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf5=\EOT, kf6=\EOU,
+	kf7=\EOV, kf8=\EOW, kf9=\EOX, kich1=\E[@, nel=\r\n,
+	op=\E[39;49m, rc=\E8, rev=\E[7m, rmacs=\E[10m,
+	rmpch=\E[10m, rmso=\E[27m, rmul=\E[m, rs1=\Ec\E]R, sc=\E7,
+	sgr0=\E[0;10m, smacs=\E[11m, smpch=\E[11m, smso=\E[7m,
+	smul=\E[4m, tbc=\E[3g, use=ansi+arrows, use=ansi+cpr,
+	use=ansi+erase, use=ansi+idc, use=klone+color,
 	use=vt220+cvis,
 
 #### Microsoft (miscellaneous)
@@ -9006,30 +9611,28 @@ interix|opennt|opennt-25|ntconsole|ntconsole-25|OpenNT-term compatible with colo
 	acsc=+\020\,\021-\030.^Y0\333`\004a\261f\370g\361h\260j
 	     \331k\277l\332m\300n\305o~p\304q\304r\304s_t\303u\264v
 	     \301w\302x\263y\363z\362{\343|\330}\234~\376,
-	bel=^G, bold=\E[1m, clear=\E[2J, cr=\r, cub=\E[%p1%dD,
-	cub1=\E[D, cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC,
-	cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA,
-	cuu1=\E[A, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K,
-	home=\E[H, ht=^I, il=\E[%p1%dL, il1=\E[L, ind=\E[S,
-	kLFT=\EF\^, kRIT=\EF$, kbs=^H, kcbt=\E[Z, kcub1=\E[D,
-	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kdch1=^?, kend=\E[U,
-	kf0=\EFA, kf1=\EF1, kf10=\EFA, kf11=\EFB, kf12=\EFC,
-	kf13=\EFD, kf14=\EFE, kf15=\EFF, kf16=\EFG, kf17=\EFH,
-	kf18=\EFI, kf19=\EFJ, kf2=\EF2, kf20=\EFK, kf21=\EFL,
-	kf22=\EFM, kf23=\EFN, kf24=\EFO, kf25=\EFP, kf26=\EFQ,
-	kf27=\EFR, kf28=\EFS, kf29=\EFT, kf3=\EF3, kf30=\EFU,
-	kf31=\EFV, kf32=\EFW, kf33=\EFX, kf34=\EFY, kf35=\EFZ,
-	kf36=\EFa, kf37=\EFb, kf38=\EFc, kf39=\EFd, kf4=\EF4,
-	kf40=\EFe, kf41=\EFf, kf42=\EFg, kf43=\EFh, kf44=\EFi,
-	kf45=\EFj, kf46=\EFk, kf47=\EFm, kf48=\EFn, kf49=\EFo,
-	kf5=\EF5, kf50=\EFp, kf51=\EFq, kf52=\EFr, kf53=\EFs,
-	kf54=\EFt, kf55=\EFu, kf56=\EFv, kf57=\EFw, kf58=\EFx,
-	kf59=\EFy, kf6=\EF6, kf60=\EFz, kf7=\EF7, kf8=\EF8, kf9=\EF9,
-	khome=\E[H, kich1=\E[L, kind=\EF+, kll=\E[U, knp=\E[T,
-	kpp=\E[S, kri=\EF-, ll=\E[U, nel=\r\n, op=\E[m, rc=\E[u,
-	rev=\E[7m, ri=\E[T, rmcup=\E[2b\E[u\r\E[K, rmso=\E[m,
-	rmul=\E[m, rs1=\Ec, sc=\E[s, sgr0=\E[0m, smcup=\E[s\E[1b,
-	smso=\E[7m, smul=\E[4m, use=ecma+index, use=klone+color,
+	bel=^G, bold=\E[1m, clear=\E[2J, cr=\r, cud1=\n,
+	cup=\E[%i%p1%d;%p2%dH, ed=\E[J, el=\E[K, home=\E[H, ht=^I,
+	ind=\E[S, kLFT=\EF\^, kRIT=\EF$, kcbt=\E[Z, kdch1=^?,
+	kend=\E[U, kf0=\EFA, kf1=\EF1, kf10=\EFA, kf11=\EFB,
+	kf12=\EFC, kf13=\EFD, kf14=\EFE, kf15=\EFF, kf16=\EFG,
+	kf17=\EFH, kf18=\EFI, kf19=\EFJ, kf2=\EF2, kf20=\EFK,
+	kf21=\EFL, kf22=\EFM, kf23=\EFN, kf24=\EFO, kf25=\EFP,
+	kf26=\EFQ, kf27=\EFR, kf28=\EFS, kf29=\EFT, kf3=\EF3,
+	kf30=\EFU, kf31=\EFV, kf32=\EFW, kf33=\EFX, kf34=\EFY,
+	kf35=\EFZ, kf36=\EFa, kf37=\EFb, kf38=\EFc, kf39=\EFd,
+	kf4=\EF4, kf40=\EFe, kf41=\EFf, kf42=\EFg, kf43=\EFh,
+	kf44=\EFi, kf45=\EFj, kf46=\EFk, kf47=\EFm, kf48=\EFn,
+	kf49=\EFo, kf5=\EF5, kf50=\EFp, kf51=\EFq, kf52=\EFr,
+	kf53=\EFs, kf54=\EFt, kf55=\EFu, kf56=\EFv, kf57=\EFw,
+	kf58=\EFx, kf59=\EFy, kf6=\EF6, kf60=\EFz, kf7=\EF7,
+	kf8=\EF8, kf9=\EF9, kich1=\E[L, kind=\EF+, kll=\E[U,
+	knp=\E[T, kpp=\E[S, kri=\EF-, ll=\E[U, nel=\r\n, op=\E[m,
+	rc=\E[u, rev=\E[7m, ri=\E[T, rmcup=\E[2b\E[u\r\E[K,
+	rmso=\E[m, rmul=\E[m, rs1=\Ec, sc=\E[s, sgr0=\E[0m,
+	smcup=\E[s\E[1b, smso=\E[7m, smul=\E[4m, use=ansi+arrows,
+	use=ansi+idl, use=ansi+local, use=ecma+index,
+	use=klone+color,
 
 opennt-35|ntconsole-35|OpenNT-term35 compatible with color,
 	lines#35, use=opennt,
@@ -9104,22 +9707,22 @@ opennt-100-nti|ntconsole-100-nti|OpenNT-term100-nti compatible with color,
 # Comparison with the k* capabilities makes it obvious that the c* things are
 # shift keys.  I have renamed them to keys 32 and up accordingly.  Also,
 # :sr: was given as a boolean-- esr)
-altos2|alt2|altos-2|altos II,
+altos2|alt2|altos-2|Altos II,
 	cols#80, it#8, lines#24, xmc#0,
 	clear=\E[H\E[2J, cr=\r, cub1=^H, cud1=\E[1B, cuf1=\E[1C,
 	cup=\E[%i%p1%d;%p2%dH, cuu1=\E[1A, dch1=\E[P, dl1=\E[M,
 	ed=\E[J, el=\E[K, home=\E[H, ht=^I, ich1=\E[@,
 	if=/usr/share/tabset/vt100, il1=\E[L, ind=\n,
 	is2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, kDL=^Am\r,
-	kEOL=^An\r, kbs=^H, kcbt=^AK\r, kclr=^AL\r, kcub1=\E[D,
-	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kdch1=^AM\r, kel=^AN\r,
+	kEOL=^An\r, kcbt=^AK\r, kclr=^AL\r, kdch1=^AM\r, kel=^AN\r,
 	kf0=^AI\r, kf1=^A@\r, kf2=^AA\r, kf3=^AB\r, kf32=^A`\r,
 	kf33=^Aa\r, kf34=^Ab\r, kf35=^Ac\r, kf36=^Ad\r, kf37=^Ae\r,
 	kf38=^Af\r, kf39=^Ag\r, kf4=^AC\r, kf40=^Ah\r, kf41=^Ai\r,
 	kf42=^Aj\r, kf43=^Ak\r, kf5=^AD\r, kf6=^AE\r, kf7=^AF\r,
 	kf8=^AG\r, kf9=^AH\r, khome=\E[f, kil1=^AJ\r, kind=^AO\r,
 	nel=\r\n, rmam=\E[?7l, rmso=\E[m, rmul=\E[m, sgr0=\E[m,
-	smam=\E[?7h, smso=\E[7m, smul=\E[4m,
+	smam=\E[?7h, smso=\E[7m, smul=\E[4m, use=ansi+arrows,
+
 # (altos3: had extension capabilities
 #	:c0=^A`\r:c1=^Aa\r:c2=^Ab\r:c3=^Ac\r:\
 #	:c4=^Ad\r:c5=^Ae\r:c6=^Af\r:c7=^Ag\r:\
@@ -9128,9 +9731,9 @@ altos2|alt2|altos-2|altos II,
 #	:XU=^Aq\r:XD=^Ar\r:XR=^As\r:XL=^At\r:\
 #	:HL=^AP\r:SP=\E[i:\
 #	:IS=\E[@:DE=\E[P:IL=\E[L:NS=\E[S:PS=\E[T:
-altos3|altos5|alt3|alt5|altos-3|altos-5|altos III or V,
+altos3|altos5|alt3|alt5|altos-3|altos-5|Altos III or V,
 	blink=\E[5p, ri=\EM, sgr0=\E[p, use=altos2,
-altos4|alt4|altos-4|altos IV,
+altos4|alt4|altos-4|Altos IV,
 	use=wy50,
 # (altos7: had extension capabilities:
 #	:GG#0:GI=\EH8:GF=\EH7:\
@@ -9142,15 +9745,15 @@ altos4|alt4|altos-4|altos IV,
 # shift keys.  I have renamed them to keys 32 and up accordingly.  I have
 # also made this entry relative to adm12 in order to give it an <sgr>. The
 # <invis> imported by use=adm+sgr may work, let me know. -- esr)
-altos7|alt7|altos VII,
+altos7|alt7|Altos VII,
 	am, mir,
 	cols#80, lines#24, xmc#0,
-	acsc=j5k3l2m1n8q\:t4u9v=w0x6, blink=\EG2, bold=\EGt,
+	acsc=j5k3l2m1n8q:t4u9v=w0x6, blink=\EG2, bold=\EGt,
 	clear=\E+^^, cr=\r, cub1=^H, cud1=\n, cuf1=^L,
 	cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K, dch1=\EW,
 	dim=\EGp, dl1=\ER, ed=\EY, el=\ET, home=^^, ht=^I, il1=\EE,
 	ind=\n, invis=\EG1,
-	is2=\E`\:\Ee(\EO\Ee6\Ec41\E~4\Ec21\Eu\E~2, kDL=^Am\r,
+	is2=\E`:\Ee(\EO\Ee6\Ec41\E~4\Ec21\Eu\E~2, kDL=^Am\r,
 	kEOL=^An\r, kbs=^H, kcbt=^AK\r, kclr=^AL\r, kcub1=^H,
 	kcud1=\n, kcuf1=^L, kcuu1=^K, kdch1=^AM\r, kel=^AN\r,
 	kf0=^AI\r, kf1=^A@\r, kf2=^AA\r, kf3=^AB\r, kf32=^A`\r,
@@ -9160,7 +9763,7 @@ altos7|alt7|altos VII,
 	kf8=^AG\r, kf9=^AH\r, khome=^^, kil1=^AJ\r, kind=^AO\r,
 	knp=\EK, kpp=\EJ, mc4=\EJ, mc5=\Ed#, nel=\r\n, ri=\Ej,
 	rmir=\Er, smir=\Eq, use=adm+sgr,
-altos7pc|alt7pc|altos PC VII,
+altos7pc|alt7pc|Altos PC VII,
 	kend=\ET, use=altos7,
 
 #### Hewlett-Packard (hp)
@@ -9179,7 +9782,7 @@ altos7pc|alt7pc|altos PC VII,
 #
 
 # Generic HP terminal - this should (hopefully) work on any HP terminal.
-hpgeneric|hp|hewlett-packard generic terminal,
+hpgeneric|hp|Hewlett-Packard generic terminal,
 	OTbs, OTpt, am, da, db, mir, xhp,
 	cols#80, lines#24, lm#0, vt#6,
 	bel=^G, clear=\EH\EJ, cr=\r, cub1=^H, cud1=\n, cuf1=\EC,
@@ -9189,14 +9792,14 @@ hpgeneric|hp|hewlett-packard generic terminal,
 	sgr0=\E&d@, smir=\EQ, smso=\E&dJ, smul=\E&dD, tbc=\E3,
 	vpa=\E&a%p1%dY,
 
-hp110|hewlett-packard model 110 portable,
+hp110|Hewlett-Packard model 110 portable,
 	lines#16, use=hpgeneric,
 
-hp+pfk+cr|hp function keys with CR,
+hp+pfk+cr|HP function keys with CR,
 	kf1=\Ep\r, kf2=\Eq\r, kf3=\Er\r, kf4=\Es\r, kf5=\Et\r,
 	kf6=\Eu\r, kf7=\Ev\r, kf8=\Ew\r,
 
-hp+pfk-cr|hp function keys w/o CR,
+hp+pfk-cr|HP function keys w/o CR,
 	kf1=\Ep, kf2=\Eq, kf3=\Er, kf4=\Es, kf5=\Et, kf6=\Eu, kf7=\Ev,
 	kf8=\Ew,
 
@@ -9204,27 +9807,27 @@ hp+pfk-cr|hp function keys w/o CR,
 # but not separate escape sequences. These definitions allow the
 # user to use those keys as arrow keys rather than as function
 # keys.
-hp+pfk+arrows|hp alternate arrow definitions,
+hp+pfk+arrows|HP alternate arrow definitions,
 	kcub1=\Eu\r, kcud1=\Ew\r, kcuf1=\Ev\r, kcuu1=\Et\r, kf1@,
 	kf2@, kf3@, kf4@, kf5@, kf6@, kf7@, kf8@, khome=\Ep\r, kind=\Er\r,
 	kll=\Eq\r, kri=\Es\r,
 
-hp+arrows|hp arrow definitions,
-	kcub1=\ED, kcud1=\EB, kcuf1=\EC, kcuu1=\EA, khome=\Eh,
-	kind=\ES, kll=\EF, kri=\ET,
+hp+arrows|HP arrow definitions,
+	khome=\Eh, kind=\ES, kll=\EF, kri=\ET, use=vt52+arrows,
 
 # Generic stuff from the HP 262x series
 #
 hp262x|HP 262x terminals,
 	xhp,
 	blink=\E&dA, dch1=\EP$<2>, ed=\EJ, ht=\011$<2>, ind=\ES,
-	invis=\E&dS, ip=$<2>, kcub1=\ED, kcud1=\EB, kcuf1=\EC,
-	kcuu1=\EA, kdch1=\EP, kdl1=\EM, ked=\EJ, kel=\EK, khome=\Eh,
-	kich1=\EQ, kil1=\EL, kind=\ES, knp=\EU, kpp=\EV, kri=\ET,
-	krmir=\ER, rev=\E&dB, rmkx=\E&s0A, rmso=\E&d@, rmul=\E&d@,
+	invis=\E&dS, ip=$<2>, kdch1=\EP, kdl1=\EM, ked=\EJ, kel=\EK,
+	khome=\Eh, kich1=\EQ, kil1=\EL, kind=\ES, knp=\EU, kpp=\EV,
+	kri=\ET, krmir=\ER, rev=\E&dB, rmkx=\E&s0A, rmso=\E&d@,
+	rmul=\E&d@,
 	sgr=\E&d%{64}%?%p1%t%{66}%|%;%?%p2%t%{68}%|%;%?%p3%t%{66}%|
 	    %;%?%p4%t%{65}%|%;%c,
 	sgr0=\E&d@, smkx=\E&s1A, smso=\E&dB, smul=\E&dD,
+	use=vt52+arrows,
 
 # Note: no <home> on HPs since that homes to top of memory, not screen.
 # Due to severe 2621 braindamage, the only way to get the arrow keys to
@@ -9242,49 +9845,48 @@ hp262x|HP 262x terminals,
 # Since there is no way to set/unset the strap with an escape
 # sequence, we don't use it in the default.
 # If you like, you can use 2621-ba (brain-damaged arrow keys).
-hp2621-ba|2621 w/new rom and strap A set,
+hp2621-ba|HP 2621 w/new rom and strap A set,
 	rmkx@, smkx@, use=hp+arrows, use=hp2621,
 
 # hp2621 with function labels. Most of the time they are off,
 # but inside vi, the function key labels appear. You have to
 # hold down shift to get them to xmit.
-hp2621|hp2621a|hp2621A|2621|2621a|2621A|hp2621-wl|2621-wl|hp 2621 w/labels,
+hp2621|hp2621a|hp2621A|2621|2621a|2621A|hp2621-wl|2621-wl|HP 2621 w/labels,
 	is2=\E&jA\r, rmkx=\E&jA, use=hp2621-fl,
-hp2621-fl|hp 2621,
+hp2621-fl|HP 2621,
 	xhp@, xon,
 	pb#19200,
 	cbt=\Ei, cup=\E&a%p2%dc%p1%dY, dch1=\EP$<2>, ht=\011$<2>,
-	ip=$<2>, is2=\E&j@\r, rmkx=\E&j@, rmso=\E&d@, rmul=\E&d@,
-	sgr0=\E&d@, smkx=\E&jB, smso=\E&dD, smul=\E&dD,
+	ip=$<2>, is2=\E&j@\r, rmkx=\E&j@, smkx=\E&jB, smso=\E&dD,
 	use=hp+pfk+cr, use=hpgeneric,
 
 # To use hp2621p printer, setenv TERM=2621p, PRINTER=2612p
-hp2621p|hp 2621 with printer,
+hp2621p|HP 2621 with printer,
 	mc4=\E&p13C, mc5=\E&p11C, use=hp2621,
 
-hp2621p-a|hp2621p with fn as arrows,
+hp2621p-a|HP 2621p with fn as arrows,
 	use=hp+pfk+arrows, use=hp2621p,
 
 # hp2621 with k45 keyboard
-hp2621-k45|hp2621k45|k45|hp 2621 with 45 keyboard,
-	kbs=^H, kcub1=\ED, kcud1=\EB, kcuf1=\EC, kcuu1=\EA,
-	khome=\Eh, rmkx=\E&s0A, smkx=\E&s1A, use=hp2621,
+hp2621-k45|hp2621k45|k45|HP 2621 with 45 keyboard,
+	kbs=^H, khome=\Eh, rmkx=\E&s0A, smkx=\E&s1A, use=hp2621,
+	use=vt52+arrows,
 
 # 2621 using all 48 lines of memory, only 24 visible at any time.
-hp2621-48|48 line 2621,
+hp2621-48|HP 48 line 2621,
 	lines#48,
 	cup=\E&a%p2%dc%p1%dR, home=\EH, vpa=\E&a%p1%dR,
 	use=hp2621,
 
 # 2621 with no labels ever. Also prevents vi delays on escape.
-hp2621-nl|hp 2621 with no labels,
+hp2621-nl|HP 2621 with no labels,
 	kcub1@, kcud1@, kcuf1@, kcuu1@, khome@, rmkx@, smkx@,
 	use=hp2621-fl,
 
 # Needed for UCB ARPAVAX console, since lsi-11 expands tabs
 # (wrong).
 #
-hp2621-nt|hp 2621 w/no tabs,
+hp2621-nt|HP 2621 w/no tabs,
 	ht@, use=hp2621,
 
 # Hp 2624 B with 4 or 10 pages of memory.
@@ -9338,7 +9940,7 @@ hp2624|hp2624a|hp2624b|hp2624b-4p|Hewlett Packard 2624 B,
 #
 # The padding probably should be changed.
 #
-hp2626|hp2626a|hp2626p|hp 2626,
+hp2626|hp2626a|hp2626p|HP 2626,
 	da, db,
 	lm#0, pb#19200,
 	ed=\ED\EJ$<500>\EC, indn=\E&r%p1%dD, ip=$<4>,
@@ -9356,7 +9958,7 @@ hp2626|hp2626a|hp2626p|hp 2626,
 # Note that this clears the tabs so it must be done by tset before
 # it sets the tabs.
 #
-hp2626-s|hp 2626 using only 23 lines,
+hp2626-s|HP 2626 using only 23 lines,
 	eslok, hs,
 	lines#23,
 	fsl=\E&d@\E&w7f2p1I\E&w4f1I,
@@ -9364,47 +9966,46 @@ hp2626-s|hp 2626 using only 23 lines,
 	    \s\E&w2f2i0d23u23l0S\s\E&w7f2p1I\s\r,
 	tsl=\E&w7f2p2I\E&w4f2I\r\EK\E&a%p1%dC, use=hp2626,
 # Force terminal back to 24 lines after being 23.
-hp2626-ns|hp 2626 using all 24 lines,
+hp2626-ns|HP 2626 using all 24 lines,
 	is1=\E&q3t0{0H\s\E&w0f118n1I\s\E&w0f1n2I\s\E&w2f1i0d0u23l0S
 	    \s\E&w3f2I\s\E&w7f2p1I\s\r,
 	use=hp2626,
 # Various entries useful for small windows on 2626.
-hp2626-12|hewlett-packard 2626 12 lines,
+hp2626-12|Hewlett-Packard 2626 12 lines,
 	lines#12, use=hp2626,
-hp2626-12x40|hewlett-packard 2626 12 lines 40 columns,
+hp2626-12x40|Hewlett-Packard 2626 12 lines 40 columns,
 	cols#40, lines#12, use=hp2626,
-hp2626-x40|hewlett-packard 2626 40 columns,
+hp2626-x40|Hewlett-Packard 2626 40 columns,
 	cols#40, use=hp2626,
-hp2626-12-s|hewlett-packard 2626 11 lines plus status,
+hp2626-12-s|Hewlett-Packard 2626 11 lines plus status,
 	lines#11, use=hp2626-s,
 
 #
 # hp2627 color tubes from University of Wisconsin
 #
-hp2627a-rev|hp 2627 with reverse video colors,
-	cr=\r, cud1=\n, ht=^I, ind=\n,
+hp2627a-rev|HP 2627 with reverse video colors,
+	ht=^I,
 	is2=\E&v0m1a0b0c1x1y1z1i0a0b1c1x1y1z0i0S\E&j@\r\E3
 	    \r,
-	kbs=^H, kcub1=^H, kcud1=\n, nel=\r\n, rmul=\E&v0S\E&d@,
+	kcub1=^H, kcud1=\n, nel=\r\n, rmul=\E&v0S\E&d@,
 	smul=\E&dD\E&v1S, use=hp2621-nl,
-hp2627a|hp 2627 color terminal with no labels,
-	cr=\r, cud1=\n, ht=^I, ind=\n,
+hp2627a|HP 2627 color terminal with no labels,
+	ht=^I,
 	is2=\E&v0m1a1b0c1i0a1b1c2i1a0b0c0i0S\E&j@\r\E3\r,
-	kbs=^H, kcub1=^H, kcud1=\n, nel=\r\n, rmso=\E&v0S,
+	kcub1=^H, kcud1=\n, nel=\r\n, rmso=\E&v0S,
 	rmul=\E&v0S\E&d@, smso=\E&v2S, smul=\E&dD\E&v1S,
 	use=hp2621-nl,
-hp2627c|hp 2627 color (cyan) terminal with no labels,
-	cr=\r, cud1=\n, ht=^I, ind=\n,
+hp2627c|HP 2627 color (cyan) terminal with no labels,
 	is2=\E&v0m1a0b0c2i1a1b0c1i0a1b1c0i0S\E&j@\r\E3\r,
-	kbs=^H, kcub1=^H, kcud1=\n, nel=\r\n, use=hp2627a,
+	use=hp2627a,
 
 # hp2640a doesn't have the Y cursor addressing feature, and C is
 # memory relative instead of screen relative, as we need.
 #
-hp2640a|hp 2640a,
+hp2640a|HP 2640a,
 	cup@, rmkx@, smkx@, use=hp2645,
 
-hp2640b|hp2644a|hp 264x series,
+hp2640b|hp2644a|HP 264x series,
 	rmkx@, smkx@, use=hp2645,
 
 # (hp2641a: removed unknown :gu: -- esr)
@@ -9425,14 +10026,13 @@ hp2641a|hp2645a|hp2647a|HP 264?A series BRL entry,
 # software to support it.
 hp2645|hp45|HP 2645 series,
 	pb#9600,
-	blink=\E&dA, cr=\r$<20>, dim=\E&dH, kctab=\E2, kcub1=\ED,
-	kcud1=\EB, kcuf1=\EC, kcuu1=\EA, kdch1=\EP, kdl1=\EM,
-	ked=\EJ, kel=\EK, khome=\Eh, khts=\E1, kich1=\EQ, kil1=\EL,
-	kind=\ES, knp=\EU, kpp=\EV, kri=\ET, krmir=\ER, rev=\E&dB,
-	rmkx=\E&s0A,
+	blink=\E&dA, cr=\r$<20>, dim=\E&dH, kctab=\E2, kdch1=\EP,
+	kdl1=\EM, ked=\EJ, kel=\EK, khome=\Eh, khts=\E1, kich1=\EQ,
+	kil1=\EL, kind=\ES, knp=\EU, kpp=\EV, kri=\ET, krmir=\ER,
+	rev=\E&dB, rmkx=\E&s0A,
 	sgr=\E&d%{64}%?%p1%t%{66}%|%;%?%p2%t%{68}%|%;%?%p3%t%{66}%|
 	    %;%?%p4%t%{65}%|%;%?%p5%t%{72}%|%;%?%p6%t%{66}%|%;%c,
-	sgr0=\E&d@, smkx=\E&s1A, smul=\E&dD, use=hpgeneric,
+	sgr0=\E&d@, smkx=\E&s1A, use=hpgeneric, use=vt52+arrows,
 # You should use this terminal at 4800 baud or less.
 hp2648|hp2648a|HP 2648a graphics terminal,
 	clear=\EH\EJ$<50>, cup=\E&a%p2%dc%p1%dY$<20>,
@@ -9441,13 +10041,13 @@ hp2648|hp2648a|HP 2648a graphics terminal,
 # The HP 150 terminal is a fairly vanilla HP terminal, with the
 # clreol standout problem. It also has graphics capabilities and
 # a touch screen, which we don't describe here.
-hp150|hewlett packard Model 150,
+hp150|Hewlett Packard Model 150,
 	OTbs, use=hp2622,
 
 # HP 2382a terminals, "the little ones." They don't have any
 # alternate character set support and sending out ^N/^O will
 # leave the screen blank.
-hp2382a|hp2382|hewlett packard 2382a,
+hp2382a|hp2382|Hewlett Packard 2382a,
 	da, db,
 	lh#1, lm#48,
 	acsc@,
@@ -9466,17 +10066,16 @@ hp2621-a|hp2621a-a|hp2621 with fn as arrows,
 # newer hewlett packard terminals
 
 newhpkeyboard|generic entry for HP extended keyboard,
-	kbs=^H, kcbt=\Ei, kclr=\EJ, kcub1=\ED, kcud1=\EB, kcuf1=\EC,
-	kcuu1=\EA, kdch1=\EP, kdl1=\EM, ked=\EJ, kel=\EK, khome=\Eh,
-	kich1=\EQ, kil1=\EL, kind=\ET, kll=\EF, knp=\EU, kpp=\EV,
-	kri=\ES, krmir=\ER, rmkx=\E&s0A, smkx=\E&s1A,
-	use=hp+pfk-cr,
+	kbs=^H, kcbt=\Ei, kclr=\EJ, kdch1=\EP, kdl1=\EM, ked=\EJ,
+	kel=\EK, khome=\Eh, kich1=\EQ, kil1=\EL, kind=\ET, kll=\EF,
+	knp=\EU, kpp=\EV, kri=\ES, krmir=\ER, rmkx=\E&s0A,
+	smkx=\E&s1A, use=hp+pfk-cr, use=vt52+arrows,
 
-newhp|generic entry for new hewlett packard terminals,
+newhp|generic entry for new Hewlett Packard terminals,
 	am, bw, mir, xhp, xon,
 	cols#80, lines#24, pb#4800,
-	acsc=2[3@4>5I9(\:'JSKWLQMAO#P$Q;R!S"T1U2V4W3X\:Y+Z*dHjGkTlRm
-	     Fn/q\,t5u6v8w7x.,
+	acsc=2[3@4>5I9(:'JSKWLQMAO#P$Q;R!S"T1U2V4W3X:Y+Z*dHjGkTlRmFn
+	     /q\,t5u6v8w7x.,
 	bel=^G, blink=\E&dA, bold=\E&dF, cbt=\Ei, cr=\r, cub1=^H,
 	cud1=\n, cuf1=\EC, cuu1=\EA, dch1=\EP$<2>, dim=\E&dH,
 	dl1=\EM, ed=\EJ, el=\EK, ht=\011$<2>, hts=\E1, il1=\EL, ind=\n,
@@ -9522,23 +10121,22 @@ hp+printer|"standard" printer info for HP ttys,
 # new 262x series of machines. It has dip-switched options.
 # The firmware has a bug in it such that if you give it a null
 # length label, the following character is eaten!
-hp2621b|hp 2621b with old style keyboard,
+hp2621b|HP 2621b with old style keyboard,
 	lh#1, lm#48, lw#8, nlab#8,
-	kcub1=\ED, kcud1=\EB, kcuf1=\EC, kcuu1=\EA, khome=\Eh,
-	kind=\ET, kll=\EF, kri=\ES,
+	khome=\Eh, kind=\ET, kll=\EF, kri=\ES,
 	pln=\E&f0a%p1%dk%p2%l%Pa%?%ga%t%ga%d%e1%;d3L%?%ga%!%t%{32}%c
 	    %;%p2%s\E%{111}%p1%+%c\r,
-	smln=\E&jB, use=hp2621,
+	smln=\E&jB, use=hp2621, use=vt52+arrows,
 
-hp2621b-p|hp 2621b with printer,
+hp2621b-p|HP 2621b with printer,
 	use=hp+printer, use=hp2621b,
 
 # hp2621b - new 2621b with new extended keyboard
 # these are closer to the new 26xx series than the other 2621b
-hp2621b-kx|hp 2621b with extended keyboard,
+hp2621b-kx|HP 2621b with extended keyboard,
 	use=newhpkeyboard, use=hp2621b,
 
-hp2621b-kx-p|hp 2621b with new keyboard & printer,
+hp2621b-kx-p|HP 2621b with new keyboard & printer,
 	use=hp+printer, use=hp2621b-kx,
 
 # Some assumptions are made in the following entries.
@@ -9554,27 +10152,27 @@ hp2621b-kx-p|hp 2621b with new keyboard & printer,
 #
 # Hp 2622a & hp2623a display and graphics terminals
 #
-hp2622|hp2622a|hp 2622,
+hp2622|hp2622a|HP 2622,
 	da, db,
 	lm#0, pb#19200,
 	is2=\E&dj@\r, use=hp+pfk-cr, use=hp+labels, use=scrhp,
 
 # The 2623 is a 2622 with extra graphics hardware.
-hp2623|hp2623a|hp 2623,
+hp2623|hp2623a|HP 2623,
 	use=hp2622,
 
-hp2624b-p|hp2624b-4p-p|hewlett packard 2624 B with printer,
+hp2624b-p|hp2624b-4p-p|Hewlett Packard 2624 B with printer,
 	use=hp+printer, use=hp2624,
 
 # The hewlett packard B can have an optional extra 6 pages of memory.
-hp2624-10p|hp2624a-10p|hp2624b-10p|hewlett packard 2624 B w/ 10 pages of memory,
+hp2624-10p|hp2624a-10p|hp2624b-10p|Hewlett Packard 2624 B w/ 10 pages of memory,
 	lm#240, use=hp2624,
 
-hp2624b-10p-p|hewlett packard 2624 B w/ extra memory & printer,
+hp2624b-10p-p|Hewlett Packard 2624 B w/ extra memory & printer,
 	lm#240, use=hp2624b-p,
 
 # Color manipulations for HP terminals
-hp+color|hp with colors,
+hp+color|HP with colors,
 	ccc,
 	colors#16, ncv#17, pairs#7,
 	initp=\E&v%?%p2%{1000}%=%t1%e.%p2%d%;a%?%p3%{1000}%=%t1%e.
@@ -9586,7 +10184,7 @@ hp+color|hp with colors,
 	op=\E&v0S, scp=\E&v%p1%dS,
 
 # <is2> sets the screen to be 80 columns wide
-hp2397a|hp2397|hewlett packard 2397A color terminal,
+hp2397a|hp2397|Hewlett Packard 2397A color terminal,
 	is2=\E&w6f80X, use=memhp, use=hp+labels, use=hp+color,
 
 #  HP 700/44 Setup parameters:
@@ -9602,44 +10200,40 @@ hp2397a|hp2397|hewlett packard 2397A color terminal,
 # <is2>		sets pcterm; autowrap; 25 lines; pc char set; prog DEL key;
 # \E\\? does not turn off keycode mode
 # <smsc>	sets alternate start/stop; keycode on
-hpansi|hp700|hewlett packard 700/44 in HP-PCterm mode,
+hpansi|hp700|Hewlett Packard 700/44 in HP-PCterm mode,
 	am, eo, xenl, xon,
 	cols#80, lines#25,
 	acsc=j\331k\277l\332m\300n\305q\304t\303u\264v\301w\302x
 	     \263,
-	bel=^G, cbt=\E[Z, clear=\E[2J\E[H, cr=\r, cub1=\E[D,
-	cud1=\E[B, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A,
-	dch1=\E[P, dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H, ht=^I,
-	ich1=\E[@, il1=\E[L, ind=\n,
+	bel=^G, cbt=\E[Z, clear=\E[2J\E[H, cr=\r,
+	cup=\E[%i%p1%d;%p2%dH, dch1=\E[P, dl1=\E[M, ed=\E[J,
+	el=\E[K, home=\E[H, ht=^I, ich1=\E[@, il1=\E[L, ind=\n,
 	is2=\E[44"p\E[?7h\E[>10h\E[>12h\EP1;1|3/7F\E\\,
-	kbs=^H, kcbt=\E[Z, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C,
-	kcuu1=\E[A, kend=\E[4~, kf1=\E[17~, kf10=\E[28~,
-	kf2=\E[18~, kf3=\E[19~, kf4=\E[20~, kf5=\E[21~, kf6=\E[23~,
-	kf7=\E[24~, kf8=\E[25~, kf9=\E[26~, khome=\E[1~, knp=\E[6~,
-	kpp=\E[5~, rmam=\E[?7l,
-	rmsc=\E[>11l\EP1**x0/11;1/13\E[m\E\\, rmso=\E[m,
-	rmul=\E[m, sgr0=\E[m, smam=\E[?7h,
+	kcbt=\E[Z, kend=\E[4~, kf1=\E[17~, kf10=\E[28~, kf2=\E[18~,
+	kf3=\E[19~, kf4=\E[20~, kf5=\E[21~, kf6=\E[23~, kf7=\E[24~,
+	kf8=\E[25~, kf9=\E[26~, khome=\E[1~, knp=\E[6~, kpp=\E[5~,
+	rmam=\E[?7l, rmsc=\E[>11l\EP1**x0/11;1/13\E[m\E\\,
+	rmso=\E[m, rmul=\E[m, sgr0=\E[m, smam=\E[?7h,
 	smsc=\E[>11h\EPO**x0/65;1/67\E\\$<250>, smso=\E[7m,
-	smul=\E[4m, xoffc=g, xonc=e, use=vt220+cvis,
+	smul=\E[4m, xoffc=g, xonc=e, use=ansi+arrows,
+	use=ansi+local1, use=vt220+cvis,
 #
 # (hp2392: copied <rmir> here from hpex -- esr)
 hp2392|239x series,
 	cols#80,
-	cbt=\Ei, cup=\E&a%p1%dy%p2%dC, kf1=\Ep\r, kf2=\Eq\r,
-	kf3=\Er\r, kf4=\Es\r, kf5=\Et\r, kf6=\Eu\r, kf7=\Ev\r,
-	kf8=\Ew\r, khome=\Eh, kind=\EU, knp=\Eu, kpp=\Ev, kri=\EV,
-	rmir=\ER, rmul=\E&d@, smir=\EQ, smul=\E&dD, vpa=\E&a%p1%dY,
-	use=hpsub,
+	cbt=\Ei, cup=\E&a%p1%dy%p2%dC, khome=\Eh, kind=\EU,
+	knp=\Eu, kpp=\Ev, kri=\EV, rmir=\ER, rmul=\E&d@, smir=\EQ,
+	smul=\E&dD, vpa=\E&a%p1%dY, use=hpsub, use=hp+pfk+cr,
 
-hpsub|hp terminals -- capability subset,
+hpsub|HP terminals -- capability subset,
 	am, da, db, mir, xhp, xon,
 	lines#24,
 	bel=^G, clear=\EH\EJ, cr=\r, cub1=^H, cud1=\EB, cuf1=\EC,
 	cuu1=\EA, dch1=\EP, dl1=\EM, ed=\EJ, el=\EK, hpa=\E&a%p1%dC,
 	ht=^I, if=/usr/share/tabset/stdcrt, il1=\EL, ind=\n,
-	is2=\E&s1A\E<\E&k0\\, kbs=^H, kcub1=\ED, kcud1=\EB,
-	kcuf1=\EC, kcuu1=\EA, khome=\Eh, rmkx=\E&s0A, rmso=\E&d@,
-	sgr0=\E&d@, smkx=\E&s1A, smso=\E&dB,
+	is2=\E&s1A\E<\E&k0\\, kbs=^H, khome=\Eh, rmkx=\E&s0A,
+	rmso=\E&d@, sgr0=\E&d@, smkx=\E&s1A, smso=\E&dB,
+	use=vt52+arrows,
 
 # hpex:
 #	May be used for most 24 x 80 hp terminals,
@@ -9651,24 +10245,21 @@ hpsub|hp terminals -- capability subset,
 #
 # (hpex: removed memory-lock capabilities ":ml=\El:mu=\Em:",
 # moved <rmir> here from hpsub -- esr)
-hpex|hp extended capabilities,
-	cr=\r, cud1=\n, cup=\E&a%p1%dy%p2%dC, ht=^I, ind=\n, kbs=^H,
-	kcub1=^H, kcud1=\n, nel=\r\n, rmir=\ER, rmul=\E&d@, smir=\EQ,
-	smul=\E&dD, vpa=\E&a%p1%dY, use=hpsub,
+hpex|HP extended capabilities,
+	cud1=\n, cup=\E&a%p1%dy%p2%dC, kcub1=^H, kcud1=\n,
+	nel=\r\n, rmir=\ER, rmul=\E&d@, smir=\EQ, smul=\E&dD,
+	vpa=\E&a%p1%dY, use=hpsub,
 
 # From: Ville Sulko <Ville.Sulko@bip.atk.tpo.fi>, 05 Aug 1996
-hp2|hpex2|hewlett-packard extended capabilities newer version,
+hp2|hpex2|Hewlett-Packard extended capabilities newer version,
 	am, da, db, mir, xhp,
 	cols#80, lh#2, lines#24, lm#0, lw#8, nlab#8, xmc#0,
 	bel=^G, clear=\E&a0y0C\EJ, cr=\r, cub1=^H, cud1=\EB,
 	cuf1=\EC, cup=\E&a%p1%dy%p2%dC, cuu1=\EA, dch1=\EP,
 	dl1=\EM, ed=\EJ, el=\EK, hpa=\E&a%p1%dC, ht=^I, hts=\E1,
-	il1=\EL, ind=\n, kbs=^H, kclr=\EJ, kctab=\E2, kcub1=\ED,
-	kcud1=\EB, kcuf1=\EC, kcuu1=\EA, kdch1=\EP, kdl1=\EM,
-	ked=\EJ, kel=\EK, kf1=\Ep, kf2=\Eq, kf3=\Er, kf4=\Es, kf5=\Et,
-	kf6=\Eu, kf7=\Ev, kf8=\Ew, khome=\Eh, khts=\E1, kich1=\EQ,
-	kil1=\EL, kind=\ES, kll=\EF, knp=\EU, kpp=\EV, kri=\ET,
-	krmir=\ER, ktbc=\E3, meml=\El, memu=\Em,
+	il1=\EL, ind=\n, kbs=^H, kclr=\EJ, kctab=\E2, kdch1=\EP,
+	kdl1=\EM, ked=\EJ, kel=\EK, khts=\E1, kich1=\EQ, kil1=\EL,
+	knp=\EU, kpp=\EV, krmir=\ER, ktbc=\E3, meml=\El, memu=\Em,
 	pfkey=\E&f%p1%dk%p2%l%dL%p2%s,
 	pfloc=\E&f1a%p1%dk%p2%l%dL%p2%s,
 	pfx=\E&f2a%p1%dk%p2%l%dL%p2%s,
@@ -9678,6 +10269,7 @@ hp2|hpex2|hewlett-packard extended capabilities newer version,
 	    %p5%{8}%*%+%{64}%+%c%?%p9%t%'\016'%c%e%'\017'%c%;,
 	sgr0=\E&d@\017, smir=\EQ, smkx=\E&s1A, smln=\E&jB,
 	smso=\E&dB, smul=\E&dD, tbc=\E3, vpa=\E&a%p1%dY,
+	use=hp+pfk-cr, use=hp+arrows,
 
 # HP 236 console
 # From: <ddavis@ic.berkeley.edu>
@@ -9698,10 +10290,9 @@ hp300h|HP Catseye console,
 	cuf1=\EC, cup=\E&a%p1%dy%p2%dC, cuu1=\EA, dch1=\EP,
 	dl1=\EM, ed=\EJ, el=\EK, hpa=\E&a%p1%dC, ht=^I,
 	if=/usr/share/tabset/stdcrt, il1=\EL, ind=\n, kbs=^H,
-	kcub1=\ED, kcud1=\EB, kcuf1=\EC, kcuu1=\EA, khome=\Eh,
-	rmir=\ER, rmkx=\E&s0A, rmso=\E&d@, rmul=\E&d@, sgr0=\E&d@,
-	smir=\EQ, smkx=\E&s1A, smso=\E&dB, smul=\E&dD, tbc=\E3,
-	vpa=\E&a%p1%dY,
+	khome=\Eh, rmir=\ER, rmkx=\E&s0A, rmso=\E&d@, rmul=\E&d@,
+	sgr0=\E&d@, smir=\EQ, smkx=\E&s1A, smso=\E&dB, smul=\E&dD,
+	tbc=\E3, vpa=\E&a%p1%dY, use=vt52+arrows,
 # From: Greg Couch <gregc@ernie.berkeley.edu>
 hp9837|hp98720|hp98721|HP 9000/300 workstations,
 	OTbs, am, da, db, mir, xhp,
@@ -9709,12 +10300,11 @@ hp9837|hp98720|hp98721|HP 9000/300 workstations,
 	bel=^G, cbt=\Ei, clear=\E&a0y0C\EJ, cub1=^H, cud1=\EB,
 	cuf1=\EC, cup=\E&a%p1%dy%p2%dC, cuu1=\EA, dch1=\EP,
 	dl1=\EM, ed=\EJ, el=\EK, hpa=\E&a%p1%dC, ht=^I, hts=\E1,
-	il1=\EL, ind=\n, is2=\E&v0m1b0i&j@, kbs=^H, kcub1=\ED,
-	kcud1=\EB, kcuf1=\EC, kcuu1=\EA, kdch1=\EP, kdl1=\EM,
-	ked=\EJ, kel=\EK, khome=\Eh, kich1=\EQ, kil1=\EL, knp=\EU,
-	kpp=\EV, rmir=\ER, rmkx=\E&s0A, rmso=\E&v0S, rmul=\E&d@,
-	sgr0=\E&d@, smir=\EQ, smkx=\E&s1A, smso=\E&v5S, smul=\E&dD,
-	tbc=\E3, vpa=\E&a%p1%dY,
+	il1=\EL, ind=\n, is2=\E&v0m1b0i&j@, kbs=^H, kdch1=\EP,
+	kdl1=\EM, ked=\EJ, kel=\EK, khome=\Eh, kich1=\EQ, kil1=\EL,
+	knp=\EU, kpp=\EV, rmir=\ER, rmkx=\E&s0A, rmso=\E&v0S,
+	rmul=\E&d@, sgr0=\E&d@, smir=\EQ, smkx=\E&s1A, smso=\E&v5S,
+	smul=\E&dD, tbc=\E3, vpa=\E&a%p1%dY, use=vt52+arrows,
 # HP 9845 desktop computer from BRL
 # (hp9845: removed unknown capability :gu: -- esr)
 hp9845|HP 9845,
@@ -9729,24 +10319,59 @@ hp9845|HP 9845,
 # added empty <acsc> to avoid warnings re <smacs>/<rmacs> --esr)
 hp98550|hp98550a|HP 9000 Series 300 color console,
 	OTbs, am, da, db, mir, xhp,
-	cols#128, it#8, lines#49, lm#0,
+	cols#128, lines#49, lm#0,
 	acsc=, bel=^G, blink=\E&dA, bold=\E&dJ, cbt=\Ei, civis=\E*dR,
 	clear=\EH\EJ, cnorm=\E*dQ, cr=\r, cub1=^H, cud1=\n, cuf1=\EC,
 	cup=\E&a%p1%dy%p2%dC, cuu1=\EA, dch1=\EP, dim=\E&dH,
-	dl1=\EM, ed=\EJ, el=\EK, hpa=\E&a%p1%dC, ht=^I, hts=\E1,
+	dl1=\EM, ed=\EJ, el=\EK, hpa=\E&a%p1%dC, hts=\E1,
 	if=/usr/share/tabset/std, il1=\EL, ind=\n, invis=\E&ds,
-	kbs=^H, kclr=\EJ, kctab=\E2, kcub1=\ED, kcud1=\EB, kcuf1=\EC,
-	kcuu1=\EA, kdch1=\EP, kdl1=\EM, ked=\EJ, kel=\EK, kf1=\Ep,
-	kf2=\Eq, kf3=\Er, kf4=\Es, kf5=\Et, kf6=\Eu, kf7=\Ev, kf8=\Ew,
-	khome=\Eh, khts=\E1, kich1=\EQ, kil1=\EL, kind=\ES, kll=\EF,
-	knp=\EU, kpp=\EV, kri=\ET, krmir=\ER, ktbc=\E3, rev=\E&dJ,
-	rmacs=^O, rmir=\ER, rmkx=\E&s0A, rmso=\E&d@, rmul=\E&d@,
-	sgr0=\E&d@, smacs=^N, smir=\EQ, smkx=\E&s1A, smso=\E&dJ,
-	smul=\E&dD, tbc=\E3, vpa=\E&a%p1%dY,
+	kbs=^H, kclr=\EJ, kctab=\E2, kdch1=\EP, kdl1=\EM, ked=\EJ,
+	kel=\EK, khts=\E1, kich1=\EQ, kil1=\EL, kll=\EF, knp=\EU,
+	kpp=\EV, krmir=\ER, ktbc=\E3, rev=\E&dJ, rmacs=^O, rmir=\ER,
+	rmkx=\E&s0A, rmso=\E&d@, rmul=\E&d@, sgr0=\E&d@, smacs=^N,
+	smir=\EQ, smkx=\E&s1A, smso=\E&dJ, smul=\E&dD, tbc=\E3,
+	vpa=\E&a%p1%dY, use=hp+pfk-cr, use=ansi+inittabs,
+	use=hp+arrows,
+
+# From: Martin Trusler
+hp98550-color|hp98550a-color|HP 9000 Series 300 color console (Trusler),
+	OTbs, am, ccc, da, db, km, mir, xhp,
+	colors#8, cols#128, lh#2, lines#49, lm#0, lw#8, nlab#8, pairs#8,
+	xmc#0,
+	acsc=+>\,<-\^.v0\374``a\374f\372g\376h\374j+k+l+m+n+o-q-s-t+
+	     u+v+w+x|y<z>{*|!}\273~\362,
+	bel=^G, bold=\E&dD, cbt=\Ei, clear=\EH\EJ, cr=\r, cub1=^H,
+	cud1=\EB, cuf1=\EC, cup=\E&a%p1%dy%p2%dC, cuu1=\EA,
+	dch1=\EP, dl1=\EM, ed=\EJ, el=\EK, home=\E&a0y0C,
+	hpa=\E&a%p1%dC, hts=\E1, il1=\EL, ind=\ES,
+	initp=\E&v0m%?%p2%{1000}%=%t1%e.%p2%d%;a%?%p3%{1000}%=%t1%e.
+	      %p3%d%;b%?%p4%{1000}%=%t1%e.%p4%d%;c%?%p5%{1000}%=%t1
+	      %e.%p5%d%;x%?%p6%{1000}%=%t1%e.%p6%d%;y%?%p7%{1000}%=
+	      %t1%e.%p7%d%;z%p1%dI,
+	is1=\EH\EJ, kbs=^H, kctab=\E2, kdch1=\EP, kdl1=\EM, ked=\EJ,
+	kel=\EK, khts=\E1, kich1=\EQ, kil1=\EL, kll=\EF, knp=\EU,
+	kpp=\EV, krmir=\ER, ktbc=\E3, meml=\El, memu=\Em,
+	oc=\E&v0m1a1b1c0I\E&v1a1I\E&v1b2I\E&v1a1b3I\E&v1c4I\E&v1a1c5
+	   I\E&v1b1c6I\E&v1x1y7I,
+	op=\E&v0S, pfkey=\E&f%p1%dk%p2%l%dL%p2%s,
+	pfloc=\E&f1a%p1%dk%p2%l%dL%p2%s,
+	pfx=\E&f2a%p1%dk%p2%l%dL%p2%s,
+	pln=\E&f%p1%dk%p2%l%dd0L%p2%s, rev=\E&dB, ri=\ET,
+	rmacs=^O, rmam=\E&s1C, rmcup=\E&s0A, rmir=\ER, rmkx=\E&s0A,
+	rmln=\E&j@, rmm=\E&k0I, rmso=\E&d@, rmul=\E&d@, rs1=\EE,
+	scp=\E&v%p1%dS,
+	sgr=\E&d%p1%p3%|%{2}%*%p2%p6%|%{4}%*%+%{64}%+%c%?%p9%t%'
+	    \016'%c%e%'\017'%c%;,
+	sgr0=\E&d@\017, smacs=^N, smam=\E&s0C, smcup=\E&s1A,
+	smir=\EQ, smkx=\E&s1A, smln=\E&jB, smm=\E&k1I, smso=\E&dB,
+	smul=\E&dD, tbc=\E3, u6=\Ea%dc%dR\r, u7=\Ea,
+	u8=\E%[0123456789/], u9=\E*s1\^, vpa=\E&a%p1%dY,
+	use=hp+pfk-cr, use=ansi+inittabs, use=hp+arrows,
+
 # From: Victor Duchovni <vic@fine.princeton.edu>
 # (hp700-wy: removed obsolete ":nl=^J:";
 # replaced /usr/share/tabset/hp700-wy with std because <it#8>,<hts=\E1> -- esr)
-hp700-wy|HP700/41 emulating wyse30,
+hp700-wy|HP 700/41 emulating Wyse30,
 	OTbs, am, bw, mir, msgr,
 	cols#80, it#8, lines#24, xmc#1,
 	cbt=\EI, clear=^Z, cr=\r, cub1=^H, cud1=^V, cuf1=^L,
@@ -9766,15 +10391,13 @@ hp70092|hp70092a|hp70092A|HP 700/92,
 	bold=\E&dB, cbt=\Ei, clear=\E&a0y0C\EJ, cr=\r, cub1=^H,
 	cud1=\EB, cuf1=\EC, cup=\E&a%p1%dy%p2%dC, cuu1=\EA,
 	dch1=\EP, dim=\E&dH, dl1=\EM, el=\EK, hpa=\E&a%p1%dC, ht=^I,
-	hts=\E1, il1=\EL, kbs=^H, kclr=\EJ, kctab=\E2, kcub1=\ED,
-	kcud1=\EB, kcuf1=\EC, kcuu1=\EA, kdch1=\EP, kdl1=\EM,
-	ked=\EJ, kel=\EK, kf1=\Ep, kf2=\Eq, kf3=\Er, kf4=\Es, kf5=\Et,
-	kf6=\Eu, kf7=\Ev, kf8=\Ew, khome=\Eh, khts=\E1, kich1=\EQ,
-	kil1=\EL, kind=\ES, kll=\EF, knp=\EU, kpp=\EV, kri=\ET,
-	krmir=\ER, ktbc=\E3, rev=\E&dB, ri=\ET, rmacs=^O, rmir=\ER,
-	rmkx=\E&s0A, rmln=\E&j@, rmso=\E&d@, rmul=\E&d@,
-	sgr0=\E&d@, smacs=^N, smir=\EQ, smkx=\E&s1A, smln=\E&jB,
-	smso=\E&dJ, smul=\E&dD, tbc=\E3, vpa=\E&a%p1%dY,
+	hts=\E1, il1=\EL, kbs=^H, kclr=\EJ, kctab=\E2, kdch1=\EP,
+	kdl1=\EM, ked=\EJ, kel=\EK, khts=\E1, kich1=\EQ, kil1=\EL,
+	kll=\EF, knp=\EU, kpp=\EV, krmir=\ER, ktbc=\E3, rev=\E&dB,
+	ri=\ET, rmacs=^O, rmir=\ER, rmkx=\E&s0A, rmln=\E&j@,
+	rmso=\E&d@, rmul=\E&d@, sgr0=\E&d@, smacs=^N, smir=\EQ,
+	smkx=\E&s1A, smln=\E&jB, smso=\E&dJ, smul=\E&dD, tbc=\E3,
+	vpa=\E&a%p1%dY, use=hp+pfk-cr, use=hp+arrows,
 
 bobcat|sbobcat|HP 9000 model 300 console,
 	am, da, db, mir, xhp,
@@ -9782,23 +10405,24 @@ bobcat|sbobcat|HP 9000 model 300 console,
 	cbt=\Ei, clear=\EH\EJ, cr=\r, cub1=^H, cud1=\EB, cuf1=\EC,
 	cup=\E&a%p1%dy%p2%dC$<6/>, cuu1=\EA, dch1=\EP,
 	dl1=\EM$<10*/>, ed=\EJ, el=\EK, hpa=\E&a%p1%dC$<6/>, ht=^I,
-	il1=\EL$<10*/>, ind=\n, kbs=^H, kcub1=\ED, kcud1=\EB,
-	kcuf1=\EC, kcuu1=\EA, khome=\Eh, nel=\r\n, rmir=\ER,
-	rmkx=\E&s0A, rmso=\E&d@, rmul=\E&d@, sgr0=\E&d@, smir=\EQ,
-	smkx=\E&s1A, smso=\E&dB, smul=\E&dD, vpa=\E&a%p1%dY$<6/>,
+	il1=\EL$<10*/>, ind=\n, kbs=^H, khome=\Eh, nel=\r\n,
+	rmir=\ER, rmkx=\E&s0A, rmso=\E&d@, rmul=\E&d@, sgr0=\E&d@,
+	smir=\EQ, smkx=\E&s1A, smso=\E&dB, smul=\E&dD,
+	vpa=\E&a%p1%dY$<6/>, use=vt52+arrows,
 gator-t|HP 9000 model 237 emulating extra-tall AAA,
 	lines#94, use=gator,
 gator|HP 9000 model 237 emulating AAA,
 	bw, km, mir, ul,
 	cols#128, it#8, lines#47,
-	bel=^G, cbt=\E[Z, clear=\E[H\E[J, cr=\r, cub1=^H, cud1=\n,
-	cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu1=\EM,
-	dch=\E[%p1%dP$<4/>, dch1=\E[P, dl=\E[%p1%dM$<1*/>,
-	dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H, hpa=\E[%i%p1%d`,
-	ht=^I, ich=\E[%p1%d@$<4/>, ich1=\E[@, il=\E[%p1%dL$<1*/>,
-	il1=\E[L, kbs=^H, kcub1=^H, kcud1=\n, nel=\r\n,
-	rep=%p1%c\E[%p2%db$<1*/>, rev=\E[7m, rmso=\E[m,
+	bel=^G, cbt=\E[Z, cr=\r, cub1=^H, cud1=\n, cuf1=\E[C,
+	cup=\E[%i%p1%d;%p2%dH, cuu1=\EM, dch=\E[%p1%dP$<4/>,
+	dch1=\E[P, dl=\E[%p1%dM$<1*/>, dl1=\E[M, home=\E[H,
+	hpa=\E[%i%p1%d`, ht=^I, ich=\E[%p1%d@$<4/>, ich1=\E[@,
+	il=\E[%p1%dL$<1*/>, il1=\E[L, kbs=^H, kcub1=^H, kcud1=\n,
+	nel=\r\n, rep=%p1%c\E[%p2%db$<1*/>, rev=\E[7m, rmso=\E[m,
 	rmul=\E[m, sgr0=\E[m, smso=\E[7m, smul=\E[4m,
+	use=ansi+erase,
+
 gator-52|HP 9000 model 237 emulating VT52,
 	cols#128, lines#47, use=vt52-basic,
 gator-52t|HP 9000 model 237 emulating extra-tall VT52,
@@ -9826,7 +10450,7 @@ dku7003|Honeywell Bull DKU 7003 all features described,
 	rmul=\E[m, sgr0=\E[m, smso=\E[7m, smul=\E[4m,
 	use=dku7003-dumb,
 
-#### Lear-Siegler (adm)
+#### Lear-Siegler (LSI adm)
 #
 # These guys are long since out of the terminals business, but
 # in 1995 many current terminals still have an adm type as one of their
@@ -9840,13 +10464,13 @@ dku7003|Honeywell Bull DKU 7003 all features described,
 # hanging in the air. (Thanks to Eric Fischer, <eric@fudge.uchicago.edu>,
 # for clearing up this point.)
 
-adm1a|adm1|lsi adm1a,
+adm1a|adm1|LSI adm1a,
 	am,
 	cols#80, lines#24,
 	bel=^G, clear=\E;$<1>, cr=\r, cub1=^H, cud1=\n, cuf1=^L,
 	cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K, home=^^,
 	ind=\n,
-adm2|lsi adm2,
+adm2|LSI adm2,
 	OTbs, am,
 	cols#80, lines#24,
 	bel=^G, clear=\E;, cr=\r, cub1=^H, cud1=\n, cuf1=^L,
@@ -9854,7 +10478,7 @@ adm2|lsi adm2,
 	dl1=\ER, ed=\EY, el=\ET, home=^^, ich1=\EQ, il1=\EE, ind=\n,
 	kcub1=^H, kcud1=\n, kcuf1=^L, kcuu1=^K, khome=^^,
 # (adm3: removed obsolete ":ma=^K^P:" -- esr)
-adm3|lsi adm3,
+adm3|LSI adm3,
 	OTbs, am,
 	cols#80, lines#24,
 	bel=^G, clear=^Z, cr=\r, cub1=^H, cud1=\n, ind=\n,
@@ -9870,7 +10494,7 @@ adm3|lsi adm3,
 # socket, you may be out of luck.
 #
 # (adm3a: some capabilities merged in from BRl entry -- esr)
-adm3a|lsi adm3a,
+adm3a|LSI adm3a,
 	OTbs, am,
 	cols#80, lines#24,
 	OTma=^K^P, OTnl=\n, bel=^G, clear=\032$<1/>, cr=\r, cub1=^H,
@@ -9880,10 +10504,9 @@ adm3a|lsi adm3a,
 adm3a+|adm3a plus,
 	kbs=^H, use=adm3a,
 # (adm5: removed obsolete ":ma=^Hh^Jj^Kk^Ll^^H:" & duplicate ":do=^J:" -- esr)
-adm5|lsi adm5,
+adm5|LSI adm5,
 	xmc#1,
-	bel=^G, cr=\r, cud1=\n, ed=\EY, el=\ET, kbs=^H, khome=^^,
-	rmso=\EG, smso=\EG, use=adm3a+,
+	ed=\EY, el=\ET, khome=^^, rmso=\EG, smso=\EG, use=adm3a+,
 # A lot of terminals other than adm11s use these.  Wherever you see
 # use=adm+sgr with some of its capabilities disabled, try the
 # disabled ones.  They may well work but not have been documented or
@@ -9953,7 +10576,7 @@ adm11|LSI ADM-11,
 #         7 - 7
 #        20 - 6,8
 #
-adm12|lsi adm12,
+adm12|LSI adm12,
 	OTbs, OTpt, am, mir,
 	OTug#1, cols#80, it#8, lines#24,
 	bel=^G, clear=^Z, cr=\r, cub1=^H, cud1=\n, cuf1=^L,
@@ -9967,7 +10590,7 @@ adm12|lsi adm12,
 	kf7=^A7\r, kf8=^A8\r, kf9=^A9\r, rmir=\Er, smir=\Eq, tbc=\E0,
 	use=adm+sgr,
 # (adm20: removed obsolete ":kn#7:" -- esr)
-adm20|lear siegler adm20,
+adm20|Lear Siegler adm20,
 	OTbs, am,
 	cols#80, it#8, lines#24,
 	bel=^G, cbt=\EI, clear=^Z, cr=\r, cub1=^H, cuf1=^L,
@@ -9975,16 +10598,15 @@ adm20|lear siegler adm20,
 	dl1=\ER, ed=\EY, el=\ET, home=^^, ht=^I, ich1=\EQ, il1=\EE,
 	kf1=^A, kf2=^B, kf3=^W, kf4=^D, kf5=^E, kf6=^X, kf7=^Z, rmso=\E(,
 	sgr0=\E(, smso=\E),
-adm21|lear siegler adm21,
+adm21|Lear Siegler adm21,
 	xmc#1,
-	bel=^G, cr=\r, cud1=\n, dch1=\EW, dl1=\ER$<30*>, ed=\EY,
-	el=\ET, ich1=\EQ, il1=\EE$<30*>, ind=\n, invis@, kbs=^H,
-	kcub1=^H, kcud1=\n, kcuf1=^L, kcuu1=^K, khome=^^,
-	use=adm+sgr, use=adm3a,
+	dch1=\EW, dl1=\ER$<30*>, ed=\EY, el=\ET, ich1=\EQ,
+	il1=\EE$<30*>, invis@, kbs=^H, khome=^^, use=adm+sgr,
+	use=adm3a,
 # (adm22: ":em=:" was an obvious typo for ":ei=:"; also,
 # removed obsolete ":kn#7:ma=j^Jk^P^K^Pl ^R^L^L :";
 # removed bogus-looking \200 from before <cup>. -- esr)
-adm22|lsi adm22,
+adm22|LSI adm22,
 	OTbs, am,
 	cols#80, lines#24,
 	bel=^G, cbt=\EI, clear=\E+, cr=\r, cub1=^H, cud1=\n, cuf1=^L,
@@ -10139,7 +10761,7 @@ adm22|lsi adm22,
 # position 6, bank @c11, 25% from back end of the circuit board.  Should be
 # OFF.  If there is no such switch, you have an old adm31 and must use oadm31.
 # (adm31: removed obsolete ":ma=j^Jk^P^K^Pl ^R^L^L :" -- esr)
-adm31|lsi adm31 with sw6 set for underline mode,
+adm31|LSI adm31 with sw6 set for underline mode,
 	OTbs, am, mir,
 	cols#80, lines#24,
 	bel=^G, clear=\E*, cr=\r, cub1=^H, cud1=\n, cuf1=^L,
@@ -10158,7 +10780,7 @@ adm36|LSI ADM36,
 	if=/usr/share/tabset/vt100,
 	is2=\E<\E>\E[6;?2;?7;?8h\E[4;20;?1;?3;?4;?5;?6;?18;?19l, use=vt100+4bsd,
 # (adm42: removed obsolete ":ma=^K^P:" -- esr)
-adm42|lsi adm42,
+adm42|LSI adm42,
 	OTbs, am,
 	cols#80, lines#24,
 	bel=^G, cbt=\EI, clear=\E;, cr=\r, cub1=^H, cud1=\n, cuf1=^L,
@@ -10170,7 +10792,7 @@ adm42|lsi adm42,
 # The following termcap for the Lear Siegler ADM-42 leaves the
 # "system line" at the bottom of the screen blank (for those who
 # find it distracting otherwise)
-adm42-ns|lsi adm-42 with no system line,
+adm42-ns|LSI adm-42 with no system line,
 	cbt=\EI\EF \011, clear=\E;\EF \011,
 	cup=\E=%p1%{32}%+%c%p2%{32}%+%c$<6>\EF \011,
 	dch1=\EW\EF \011, dl1=\ER\EF \011, ed=\EY\EF \011,
@@ -10181,7 +10803,7 @@ adm42-ns|lsi adm-42 with no system line,
 # purposes in that it will shift the position of every character on the page,
 # not just the cursor line!
 # From: Michael Driscoll <fenris@lightspeed.net> 10 July 1996
-adm1178|1178|lsi adm1178,
+adm1178|1178|LSI adm1178,
 	am,
 	cols#80, lines#24, xmc#1,
 	bel=^G, bold=\E(, cbt=\EI, clear=\E+, cr=\r, cub1=^H, cud1=\n,
@@ -10203,22 +10825,21 @@ adm1178|1178|lsi adm1178,
 #
 
 # Standout mode is dim reverse-video.
-pt100|pt200|wren|fenix|prime pt100/pt200,
+pt100|pt200|wren|fenix|Prime pt100/pt200,
 	am, bw, mir, msgr,
 	cols#80, it#8, lines#24,
-	cbt=\E[Z, clear=\E?, cr=\r, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\ED, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E0%p1%{33}%+%c%p2%{33}%+%c, cuu=\E[%p1%dA,
-	cuu1=\EM, dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m, dl1=\E[M,
-	ed=\E[J\E[r, el=\E[K\E[t, flash=\E$$<200/>\E$P,
-	home=\E$B, ht=^I, il1=\E[L\E[t, ind=\n, kbs=^H, kcub1=\E[D,
-	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, khome=\E$A, nel=\r\n,
-	rmcup=, rmir=\E[4l, rmkx=\E[>13l, rmso=\E[m, rmul=\E[m,
-	sgr0=\E[m,
+	cbt=\E[Z, clear=\E?, cr=\r, cub1=^H, cud1=\ED,
+	cup=\E0%p1%{33}%+%c%p2%{33}%+%c, cuu1=\EM,
+	dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m, dl1=\E[M, ed=\E[J\E[r,
+	el=\E[K\E[t, flash=\E$$<200/>\E$P, home=\E$B, ht=^I,
+	il1=\E[L\E[t, ind=\n, khome=\E$A, nel=\r\n, rmcup=,
+	rmir=\E[4l, rmkx=\E[>13l, rmso=\E[m, rmul=\E[m, sgr0=\E[m,
 	smcup=\E[>1l\E[>2l\E[>16l\E[4l\E[>9l\E[20l\E[>3l\E[>7h\E[>12
 	      l\E[1Q,
 	smir=\E[4h, smkx=\E[>13h, smso=\E[2;7m, smul=\E[4m,
-pt100w|pt200w|wrenw|fenixw|prime pt100/pt200 in 132-column mode,
+	use=ansi+arrows, use=ansi+local,
+
+pt100w|pt200w|wrenw|fenixw|Prime pt100/pt200 in 132-column mode,
 	cols#132,
 	cup=\E[%i%p1%d;%p2%dH, use=pt100,
 pt250|Prime PT250,
@@ -10242,7 +10863,7 @@ pt250w|Prime PT250 in 132-column mode,
 #
 # The qvt101 and qvt102 listed here are long obsolete; so is the qvt101+
 # built to replace them, and a qvt119+ which was a 101+ with available wide
-# mode (132 columns).  There was a qvt103 which added vt100/vt131 emulations
+# mode (132 columns).  There was a qvt103 which added VT100/VT131 emulations
 # and an ANSI-compatible qvt203 that replaced it.  Qume started producing
 # ANSI-compatible terminals with the qvt323 and qvt61.
 #
@@ -10253,14 +10874,14 @@ pt250w|Prime PT250 in 132-column mode,
 # popular lines such as ADDS, and dual-host capabilities.  The qvt82 is
 # designed for use as a SCO ANSI terminal.  The qvt70 is a color terminal
 # with many emulations including Wyse370, Wyse 325, etc.  Their newest
-# model is the qvt520, which is vt420-compatible.
+# model is the qvt520, which is VT420-compatible.
 #
 # There are some ancient printing Qume terminals under `Daisy Wheel Printers'
 #
 # If you inherit a Qume without docs, try Ctrl-Shift-Setup to enter its
 # setup mode.  Shift-s should be a configuration save to NVRAM.
 
-qvt101|qvt108|qume qvt 101 and QVT 108,
+qvt101|qvt108|Qume qvt 101 and QVT 108,
 	xmc#1, use=qvt101+,
 
 # This used to have <cvvis=\E.2> but no <cnorm> or <civis>.  The BSD termcap
@@ -10272,7 +10893,7 @@ qvt101|qvt108|qume qvt 101 and QVT 108,
 #
 # Added kdch1, kil1, kdl1 based on screenshot -TD:
 #	http://www.vintagecomputer.net/qume/qvt-108/qume_qvt-108_keyboard.jpg
-qvt101+|qvt101p|qume qvt 101 PLUS product,
+qvt101+|qvt101p|Qume qvt 101 PLUS product,
 	am, bw, hs, ul,
 	cols#80, lines#24, xmc#0,
 	bel=^G, cbt=\EI, clear=^Z, cnorm=\E.4, cr=\r, cub1=^H, cud1=\n,
@@ -10285,31 +10906,31 @@ qvt101+|qvt101p|qume qvt 101 PLUS product,
 	kf4=^AC\r, kf5=^AD\r, kf6=^AE\r, kf7=^AF\r, kf8=^AG\r,
 	kf9=^AH\r, khome=^^, kich1=\EQ, kil1=\EE, mc4=\EA, mc5=\E@,
 	rmso=\E(, smso=\E0P\E), tbc=\E3, tsl=\Eg\Ef, use=adm+sgr,
-qvt102|qume qvt 102,
+qvt102|Qume qvt 102,
 	cnorm=\E., use=qvt101,
 # (qvt103: added <rmam>/<smam> based on init string -- esr)
-qvt103|qume qvt 103,
+qvt103|Qume qvt 103,
 	am, xenl, xon,
 	cols#80, it#8, lines#24, vt#3,
 	bel=^G, blink=\E[5m$<2>, bold=\E[1m$<2>,
-	clear=\E[H\E[2J$<50>, cr=\r, csr=\E[%i%p1%d;%p2%dr,
-	cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\n,
-	cuf=\E[%p1%dC, cuf1=\E[C$<2>,
-	cup=\E[%i%p1%d;%p2%dH$<5>, cuu=\E[%p1%dA,
+	clear=\E[H\E[2J$<50>, cr=\r, cub1=^H, cud1=\n,
+	cuf1=\E[C$<2>, cup=\E[%i%p1%d;%p2%dH$<5>,
 	cuu1=\E[A$<2>, ed=\E[J$<50>, el=\E[K$<3>, home=\E[H, ht=^I,
 	hts=\EH, ind=\n, kbs=^H, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC,
-	kcuu1=\EOA, kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, rc=\E8,
+	kcuu1=\EOA, kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS,
 	rev=\E[7m$<2>, ri=\EM$<5>, rmam=\E[?7l, rmkx=\E[?1l\E>,
 	rmso=\E[m$<2>, rmul=\E[m$<2>,
-	rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, sc=\E7,
+	rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h,
 	sgr=\E[%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p6%t;1
 	    %;m$<2>,
 	sgr0=\E[m$<2>, smam=\E[?7h, smkx=\E[?1h\E=,
-	smso=\E[7m$<2>, smul=\E[4m$<2>, tbc=\E[3g,
-qvt103-w|qume qvt103 132 cols,
+	smso=\E[7m$<2>, smul=\E[4m$<2>, tbc=\E[3g, use=ansi+csr,
+	use=ansi+local,
+
+qvt103-w|Qume qvt103 132 cols,
 	cols#132, lines#24,
 	rs2=\E>\E[?3h\E[?4l\E[?5l\E[?8h, use=qvt103,
-qvt119+|qvt119p|qvt119|qume qvt 119 and 119PLUS terminals,
+qvt119+|qvt119p|qvt119|Qume qvt 119 and 119PLUS terminals,
 	am, hs, mir, msgr,
 	cols#80, lines#24, xmc#0,
 	bel=^G, cbt=\EI, clear=\E*1, cnorm=\E.4, cr=\r, cub1=^H,
@@ -10329,12 +10950,12 @@ qvt119+-w|qvt119p-w|qvt119-w|QVT 119 and 119 PLUS in 132 column mode,
 	is2=\EDF\EC\EG0\Er\E(\E%\EX\En4, use=qvt119+,
 qvt119+-25-w|qvt119p-25-w|qvt119-25-w|QVT 119 and 119 PLUS 132 by 25,
 	lines#25, use=qvt119+,
-qvt203|qvt203+|qume qvt 203 Plus,
+qvt203|qvt203+|Qume qvt 203 Plus,
 	dch1=\E[P$<7>, dl1=\E[M$<99>, il1=\E[L$<99>, ind=\n$<30>,
 	ip=$<7>, kf0=\E[29~, kf1=\E[17~, kf2=\E[18~, kf3=\E[19~,
 	kf4=\E[20~, kf5=\E[21~, kf6=\E[23~, kf7=\E[24~, kf8=\E[25~,
 	kf9=\E[28~, rmir=\E[4l, smir=\E[4h, use=qvt103,
-qvt203-w|qvt203-w-am|qume qvt 203 PLUS in 132 cols (w/advanced video),
+qvt203-w|qvt203-w-am|Qume qvt 203 PLUS in 132 cols (w/advanced video),
 	cols#132, lines#24,
 	rs2=\E>\E[?3h\E[?4l\E[?5l\E[?8h, use=qvt203,
 #
@@ -10350,7 +10971,7 @@ qvt203-25-w|QVT 203 PLUS with 25 by 132 columns,
 	cols#132, lines#25,
 	rs2=\E[?3h\E[=40h, use=qvt203,
 
-#### Televideo (tvi)
+#### TeleVideo (tvi)
 #
 #	TeleVideo
 #	550 East Brokaw Road
@@ -10363,9 +10984,9 @@ qvt203-25-w|QVT 203 PLUS with 25 by 132 columns,
 # These require incredible amounts of padding.
 #
 # All of these terminals (912 to 970 and the tvipt) are discontinued.  Newer
-# Televideo terminals are ANSI and PC-ANSI compatible.
+# TeleVideo terminals are ANSI and PC-ANSI compatible.
 
-tvi803|televideo 803,
+tvi803|TeleVideo 803,
 	clear=\E*$<10>, use=tvi950,
 
 # Vanilla tvi910 -- W. Gish <cswarren@violet> 10/29/86
@@ -10450,7 +11071,7 @@ tvi803|televideo 803,
 #     D  duplex
 # (tvi910: removed obsolete ":ma=^Kk^Ll^R^L:"; added <khome>, <cub1>, <cud1>,
 # <ind>, <hpa>, <vpa>, <am>, <msgr> from SCO entry -- esr)
-tvi910|televideo model 910,
+tvi910|TeleVideo model 910,
 	OTbs, am, msgr,
 	cols#80, it#8, lines#24, xmc#1,
 	bel=^G, cbt=\EI, clear=^Z, cr=\r, cub1=^H, cud1=\n, cuf1=^L,
@@ -10491,7 +11112,7 @@ tvi910|televideo model 910,
 # S2  9  DCD status (pin 8)  (U = disconnected, D = connected)
 # S2 10  DTR status (pin 20) (U = disconnected, D = connected)
 #
-tvi910+|televideo 910+,
+tvi910+|TeleVideo 910+,
 	dch1=\EW, dl1=\ER$<33*>, home=^^, ich1=\EQ, il1=\EE$<33*>,
 	kf0=^A@\r, kf1=^AA\r, kf2=^AB\r, kf3=^AC\r, kf4=^AD\r,
 	kf5=^AE\r, kf6=^AF\r, kf7=^AG\r, kf8=^AH\r, kf9=^AI\r,
@@ -10499,7 +11120,7 @@ tvi910+|televideo 910+,
 
 # (tvi912: removed obsolete ":ma=^K^P^L :", added  <flash> and
 # <khome> from BRL entry -- esr)
-tvi912|tvi914|tvi920|old televideo 912/914/920,
+tvi912|tvi914|tvi920|TeleVideo 912/914/920 (old),
 	OTbs, OTpt, am, msgr,
 	cols#80, it#8, lines#24, xmc#1,
 	bel=^G, clear=^Z, cr=\r, cub1=^H, cud1=\n, cuf1=^L,
@@ -10514,7 +11135,7 @@ tvi912|tvi914|tvi920|old televideo 912/914/920,
 # We got some new tvi912c terminals that act really weird on the regular
 # termcap, so one of our gurus worked this up. Seems that cursor
 # addressing is broken.
-tvi912cc|tvi912 at cowell college,
+tvi912cc|tvi912 at Cowell College,
 	cup@, use=tvi912c,
 
 # tvi{912,920}[bc] - TeleVideo TVI-912B/TVI-920B and TVI-912C/TVI-920C
@@ -10908,11 +11529,11 @@ tvi920b|tvi920c|TeleVideo TVI-920B or TVI-920C (half-intensity attribute),
 tvi920b-mc|tvi920c-mc|TeleVideo TVI-920B or TVI-920C (magic cookies),
 	use=tvi920b+fn, use=tvi912b+mc, use=tvi912b-unk,
 
-# Televideo 921 and variants
+# TeleVideo 921 and variants
 # From: Tim Theisen <tim@cs.wisc.edu> 22 Sept 1995
 # (tvi921: removed :ko=bt: before translation, I see no backtab cap;
 # also added empty <acsc> to suppress tic warning -- esr)
-tvi921|televideo model 921 with sysline same as page & real vi function,
+tvi921|TeleVideo model 921 with sysline same as page & real vi function,
 	OTbs, OTpt, am, hs, xenl, xhp,
 	cols#80, lines#24, xmc#0,
 	acsc=, clear=^Z, cnorm=\E.3, cr=\r, cub1=^H, cud1=^V, cuf1=^L,
@@ -10927,7 +11548,7 @@ tvi921|televideo model 921 with sysline same as page & real vi function,
 # without the beeper
 # (tvi92B: removed :ko=bt: before translation, I see no backtab cap;
 # also added empty <acsc> to suppress tic warning -- esr)
-tvi92B|televideo model 921 with sysline same as page & real vi function & no beeper,
+tvi92B|TeleVideo model 921 with sysline same as page & real vi function & no beeper,
 	am, hs, xenl, xhp,
 	cols#80, lines#24, xmc#0,
 	acsc=, clear=^Z, cnorm=\E.3, cr=\r, cub1=^H, cud1=^V, cuf1=^L,
@@ -10948,7 +11569,7 @@ tvi92D|tvi92B with DTR instead of XON/XOFF & better padding,
 # (tvi924: This used to have <dsl=\Es0>, <fsl=\031>.  I put the new strings
 # in from a BSD termcap file because it looks like they do something the
 # old ones skip -- esr)
-tvi924|televideo tvi924,
+tvi924|TeleVideo tvi924,
 	am, bw, hs, in, mir, msgr, xenl, xon,
 	cols#80, it#8, lines#24, wsl#80, xmc#0,
 	bel=^G, blink=\EG2, cbt=\EI, civis=\E.0, clear=\E*0,
@@ -11102,7 +11723,7 @@ tvi924|televideo tvi924,
 # --------------------------------------------
 #
 # (tvi925: BSD has <clear=\E*>.  I got <is2> and <ri> from there -- esr)
-tvi925|televideo 925,
+tvi925|TeleVideo 925,
 	OTbs, am, bw, hs, ul,
 	cols#80, lines#24, xmc#1,
 	bel=^G, cbt=\EI, clear=^Z, cnorm=\E.4, cr=\r, cub1=^H, cud1=^V,
@@ -11119,7 +11740,7 @@ tvi925|televideo 925,
 # to avoid "magic cookie" standout glitch:
 tvi925-hi|TeleVideo Model 925 with half intensity standout mode,
 	xmc@,
-	kbs=^H, kcub1=^H, kcud1=\n, rmso=\E(, smso=\E), use=tvi925,
+	kcud1=\n, rmso=\E(, smso=\E), use=tvi925,
 
 # From: Todd Litwin <litwin@litwin.jpl.nasa.gov> 28 May 1993
 # Originally Tim Curry, Univ. of Central Fla., <duke!ucf-cs!tim> 5/21/82
@@ -11220,7 +11841,7 @@ tvi925-hi|TeleVideo Model 925 with half intensity standout mode,
 # Finally, note that BSD has cud1=^V. -- esr)
 #
 # TVI 950 has 11 function-keys -TD
-tvi950|televideo 950,
+tvi950|TeleVideo 950,
 	OTbs, am, hs, mir, msgr, xenl, xon,
 	cols#80, it#8, lines#24, xmc#1,
 	acsc=jHkGlFmEnIqKtMuLvOwNxJ, bel=^G, cbt=\EI, clear=\E*,
@@ -11254,7 +11875,7 @@ tvi950|televideo 950,
 #	set duplex (send) edit keys (\El) when entering vi
 #	set local (no send) edit keys (\Ek) when exiting vi
 #
-tvi950-2p|televideo950 w/2 pages,
+tvi950-2p|TeleVideo 950 w/2 pages,
 	is2=\EDF\EC\Ed\EG0\Eg\Er\EO\E'\E(\E%\Ew\EX\Ee\s\017\011\Ek
 	    \E016\E004\Ex0\0\0\Ex1\0\0\Ex2\0\0\011\Ex3\0\0\Ex4\r\0
 	    \E\\2\E-07\s\011,
@@ -11270,7 +11891,7 @@ tvi950-2p|televideo950 w/2 pages,
 #	when exiting ex, reset 96 line page (\E\\3)
 #			 place cursor at 0,24,1 (\E-07 )
 #
-tvi950-4p|televideo950 w/4 pages,
+tvi950-4p|TeleVideo 950 w/4 pages,
 	is2=\EDF\EC\Ed\EG0\Eg\Er\EO\E'\E(\E%\Ew\EX\Ee\s\017\011\Ek
 	    \E016\E004\Ex0\0\0\Ex1\0\0\Ex2\0\0\011\Ex3\0\0\Ex4\r\0
 	    \E\\3\E-07\s\011,
@@ -11282,7 +11903,7 @@ tvi950-4p|televideo950 w/4 pages,
 #
 # set vb accordingly (\Ed ...delay... \Eb)
 #
-tvi950-rv|televideo950 rev video,
+tvi950-rv|TeleVideo 950 rev video,
 	flash=\Ed$<200/>\Eb,
 	is2=\EDF\EC\Eb\EG0\Eg\Er\EO\E'\E(\E%\Ew\EX\Ee\s\017\011\El
 	    \E016\E004\Ex0\0\0\Ex1\0\0\Ex2\0\0\011\Ex3\0\0\Ex4\r
@@ -11290,7 +11911,7 @@ tvi950-rv|televideo950 rev video,
 	use=tvi950,
 
 # tvi950-rv-2p uses the appropriate entries from 950-2p and 950-rv
-tvi950-rv-2p|televideo950 rev video w/2 pages,
+tvi950-rv-2p|TeleVideo 950 rev video w/2 pages,
 	flash=\Ed$<200/>\Eb,
 	is2=\EDF\EC\Eb\EG0\Eg\Er\EO\E'\E(\E%\Ew\EX\Ee\s\017\011\Ek
 	    \E016\E004\Ex0\0\0\Ex1\0\0\Ex2\0\0\011\Ex3\0\0\Ex4\r\0
@@ -11299,7 +11920,7 @@ tvi950-rv-2p|televideo950 rev video w/2 pages,
 	smkx=\El, use=tvi950,
 
 # tvi950-rv uses the appropriate entries from 950-4p and 950-rv
-tvi950-rv-4p|televideo950 rev video w/4 pages,
+tvi950-rv-4p|TeleVideo 950 rev video w/4 pages,
 	flash=\Ed$<200/>\Eb,
 	is2=\EDF\EC\Eb\EG0\Er\EO\E'\E(\E%\Ew\EX\Ee\s\017\011\Ek
 	    \E016\E004\Ex0\0\0\Ex1\0\0\Ex2\0\0\011\Ex3\0\0\Ex4\r\0
@@ -11316,9 +11937,9 @@ tvi950-rv-4p|televideo950 rev video w/4 pages,
 # ko implies -- esr)
 # If the BSD termcap file was right, <cup=\E=%p1%{32}%+%c%p2%{32}%+%c> would
 # also work.
-tvi955|televideo 955,
-	OTbs, mc5i, msgr@,
-	it#8, xmc@,
+tvi955|TeleVideo 955,
+	mc5i, msgr@,
+	xmc@,
 	acsc=0_`RjHkGlFmEnIoPqKsQtMuLvOwNxJ, blink=\EG2,
 	civis=\E.0, cnorm=\E.2, cud1=^V, cup=\E[%i%p1%d;%p2%dH,
 	cvvis=\E.1, dim=\E[=5h, ind@, invis=\EG1,
@@ -11327,13 +11948,12 @@ tvi955|televideo 955,
 	rmam=\E[=7l, rmxon=^N,
 	rs1=\EDF\EC\Eg\Er\EO\E'\E(\Ew\EX\Ee\s\017\E0P\E6\0\E0p\E4\0
 	    \Ef\r,
-	sgr0=\EG0\E[=5l, smacs=\E$, smam=\E[=7h, smxon=^O,
-	use=tvi950,
-tvi955-w|955-w|televideo955 w/132 cols,
+	sgr0=\EG0\E[=5l, smam=\E[=7h, smxon=^O, use=tvi950,
+tvi955-w|955-w|TeleVideo 955 w/132 cols,
 	cols#132,
 	is2=\E[=3h\EF1\Ed\EG0\E[=5l\E%\El, use=tvi955,
 # use half-intensity as normal mode, full intensity as <bold>
-tvi955-hb|955-hb|televideo955 half-bright,
+tvi955-hb|955-hb|TeleVideo 955 half-bright,
 	bold=\E[=5l, dim@, is2=\E[=3l\EF1\Ed\EG0\E[=5h\E%\El,
 	sgr0=\EG0\E[=5h, use=tvi955,
 # From: Humberto Appleton <beto@cs.utexas.edu>, 880521 UT Austin
@@ -11342,7 +11962,7 @@ tvi955-hb|955-hb|televideo955 half-bright,
 # According to BRL we could have <rmkx>=\E>, <smkx>=\E= but I'm not sure what
 # it does to the function keys.  I deduced <rmam>/<smam>.
 # also added empty <acsc> to suppress tic warning,  -- esr)
-tvi970|televideo 970,
+tvi970|TeleVideo 970,
 	OTbs, OTpt, am, da, db, mir, msgr,
 	cols#80, it#8, lines#24,
 	acsc=, cbt=\E[Z, clear=\E[H\E[2J, csr=\E[%i%p1%d;%p2%dr,
@@ -11351,17 +11971,17 @@ tvi970|televideo 970,
 	ed=\E[J, el=\E[K, flash=\E[5m$<200/>\E[m, home=\E[H,
 	hpa=\E[%i%p1%dG, ht=^I, il1=\E[L,
 	is2=\E<\E[?21l\E[19h\E[1Q\E[10l\E[7l\E[H\E[2J,
-	kbs=^H, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
 	kf1=\E?a, kf2=\E?b, kf3=\E?c, kf4=\E?d, kf5=\E?e, kf6=\E?f,
-	kf7=\E?g, kf8=\E?h, kf9=\E?i, khome=\E[H, ri=\EM, rmacs=\E(B,
+	kf7=\E?g, kf8=\E?h, kf9=\E?i, ri=\EM, rmacs=\E(B,
 	rmam=\E[?7h, rmcup=, rmir=\E[4l, rmso=\E[m, rmul=\E[m,
 	sgr0=\E[m, smacs=\E(B, smam=\E[?7l,
 	smcup=\E[?20l\E[?7h\E[1Q, smir=\E[4h, smso=\E[7m,
-	smul=\E[4m, vpa=\E[%i%p1%dd,
-tvi970-vb|televideo 970 with visual bell,
+	smul=\E[4m, vpa=\E[%i%p1%dd, use=ansi+arrows,
+
+tvi970-vb|TeleVideo 970 with visual bell,
 	flash=\E[?5h\0\0\0\0\0\0\0\0\0\0\0\0\0\E[?5l,
 	use=tvi970,
-tvi970-2p|televideo 970 with using 2 pages of memory,
+tvi970-2p|TeleVideo 970 with using 2 pages of memory,
 	rmcup=\E[H\E[J\E[V, smcup=\E[U\E[?20l\E[?7h\E[1Q,
 	use=tvi970,
 # Works with vi and rogue.  NOTE: Esc v sets autowrap on, Esc u sets 80 chars
@@ -11373,7 +11993,7 @@ tvi970-2p|televideo 970 with using 2 pages of memory,
 # From: Gene Rochlin <armsis@amber.berkeley.edu> 9/19/84.
 # The <ed>/<kf0>/<kf1>/<khome>/<mc4>, and <mc5> caps are from BRL, which says:
 # F1 and F2 should be programmed as ^A and ^B; required for UNIFY.
-tvipt|televideo personal terminal,
+tvipt|TeleVideo personal terminal,
 	OTbs, am,
 	cols#80, lines#24,
 	cbt=\EI, clear=^Z, cub1=^H, cuf1=^L,
@@ -11383,16 +12003,15 @@ tvipt|televideo personal terminal,
 	kcuf1=^L, kcuu1=^K, kf0=^A, kf1=^B, khome=^^, mc4=^T, mc5=^R,
 	rmso=\EF, rmul=\EF, smso=\EG1@A\EH, smul=\EG1B@\EH,
 # From: Nathan Peterson <nathan@sco.com>, 03 Sep 1996
-tvi9065|televideo 9065,
+tvi9065|TeleVideo 9065,
 	am, bw, chts, hs, mc5i, mir, msgr, xenl, xon,
 	cols#80, it#8, lh#1, lines#25, lm#0, lw#9, ma#4, nlab#8, vt#0,
 	wnum#0, wsl#30,
 	acsc='r0_jhkglfmeniopqksqtmulvownxj, bel=^G,
 	blink=\EG2, bold=\EG\,, cbt=\EI, civis=\E.0, clear=^Z,
-	cnorm=\E.3, cr=\r, csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD,
-	cub1=^H, cud=\E[%p1%dB, cud1=^V, cuf=\E[%p1%dC, cuf1=^L,
-	cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu=\E[%p1%dA,
-	cuu1=^K, cvvis=\E.2, dch=\E[%p1%dP, dch1=\EW, dim=\EGp,
+	cnorm=\E.3, cr=\r, csr=\E[%i%p1%d;%p2%dr, cub1=^H, cud1=^V,
+	cuf1=^L, cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K,
+	cvvis=\E.2, dch=\E[%p1%dP, dch1=\EW, dim=\EGp,
 	dl=\E[%p1%dM, dl1=\ER, dsl=\E_30\r, ech=\E[%p1%d@, ed=\EY,
 	el=\ET, flash=\Eb$<15>\Ed, fsl=\r, home=^^, ht=^I, hts=\E1,
 	ich=\E[%p1%d@, if=/usr/share/tabset/stdcrt,
@@ -11424,7 +12043,8 @@ tvi9065|televideo 9065,
 	    %p9%t\E$%e\E%%%;,
 	sgr0=\EG0\E%, smacs=\E$, smam=\E=7h, smcup=\E.2, smdc=\Er,
 	smir=\Eq, smln=\E[4;2v, smso=\EGt, smul=\EG8, smxon=^O,
-	tbc=\E3, tsl=\E[4;1v\E_30, uc=\EG8\EG0, use=ecma+index,
+	tbc=\E3, tsl=\E[4;1v\E_30, uc=\EG8\EG0, use=ansi+local,
+	use=ecma+index,
 
 #### Visual (vi)
 #
@@ -11438,36 +12058,31 @@ tvi9065|televideo 9065,
 # Visual 50 from Beau Shekita, BTL-Whippany <whuxlb!ejs>
 # Recently I hacked together the following termcap for Visual
 # Technology's Visual 50 terminal. It's a slight modification of
-# the vt52 termcap.
-# It's intended to run when the Visual 50 is in vt52 emulation mode
-# (I know what you're thinking; if it's emulating a vt52, then why
+# the VT52 termcap.
+# It's intended to run when the Visual 50 is in VT52 emulation mode
+# (I know what you're thinking; if it's emulating a VT52, then why
 # another termcap? Well, it turns out that the Visual 50 can handle
-# <dl1> and db(?) among other things, which the vt52 can't)
+# <dl1> and db(?) among other things, which the VT52 can't)
 # The termcap works OK for the most part. The only problem is on
 # character inserts. The whole line gets painfully redrawn for each
 # character typed. Any suggestions?
 # Beau's entry is combined with the vi50 entry from University of Wisconsin.
 # Note especially the <il1> function.  <kf4>-<kf6> are really l4-l6 in
 # disguise; <kf7>-<kf9> are really l1-l3.
-vi50|visual 50,
+vi50|Visual 50,
 	OTbs, OTpt, am, da, db, msgr,
-	cols#80, it#8, lines#24,
-	OTnl=\n, bel=^G, cbt=\Ez$<4/>, clear=\EH\EJ, cr=\r, cub1=^H,
-	cud1=\EB, cuf1=\EC, cup=\EY%p1%{32}%+%c%p2%{32}%+%c,
-	cuu1=\EA, dl1=\EM$<3*/>, ed=\EJ, el=\EK$<16/>, home=\EH,
-	ht=^I, il1=\EL, ind=\n, kbs=^H, kcub1=\ED, kcud1=\EB,
-	kcuf1=\EC, kcuu1=\EA, kf1=\EP, kf2=\EQ, kf3=\ER, kf4=\EV,
+	OTnl=\n, cbt=\Ez$<4/>, cub1=^H, dl1=\EM$<3*/>,
+	el=\EK$<16/>, il1=\EL, kf1=\EP, kf2=\EQ, kf3=\ER, kf4=\EV,
 	kf5=\EE, kf6=\E], kf7=\EL, kf8=\Ev, kf9=\EM, khome=\EH,
-	nel=\r\n, ri=\EI, rmso=\ET, rmul=\EW, smso=\EU, smul=\ES,
+	rmso=\ET, rmul=\EW, smso=\EU, smul=\ES, use=vt52-basic,
 # this one was BSD & SCO's vi50
-vi50adm|visual 50 in adm3a mode,
+vi50adm|Visual 50 in adm3a mode,
 	am, msgr,
 	cols#80, it#8, lines#24,
 	bel=^G, clear=^Z, cr=\r, cub1=^H, cud1=\n, cuf1=^L,
 	cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K, dl1=\EM,
 	ed=\Ek, el=\EK, home=\EH, ht=^I, il1=\EL, ind=\n, kbs=^H,
-	kcub1=\ED, kcud1=\EB, kcuf1=\EC, kcuu1=\EA, khome=\EH,
-	rmso=\ET, smso=\EU,
+	khome=\EH, rmso=\ET, smso=\EU, use=vt52+arrows,
 # From: Jeff Siegal <jbs@quiotix.com>
 vi55|Visual 55,
 	OTbs, am, mir, msgr,
@@ -11475,9 +12090,8 @@ vi55|Visual 55,
 	clear=\Ev, csr=\E_%p1%{65}%+%c%p2%{65}%+%c, cub1=^H,
 	cud1=\n, cuf1=\EC, cup=\EY%p1%{32}%+%c%p2%{32}%+%c,
 	cuu1=\EA, dch1=\Ew, dl1=\EM, ed=\EJ, el=\EK, home=\EH, ht=^I,
-	il1=\EL, is2=\Ev\E_AX\Eb\EW\E9P\ET, kbs=^H, kcub1=\ED,
-	kcud1=\EB, kcuf1=\EC, kcuu1=\EA, ri=\EI, rmir=\Eb, rmso=\ET,
-	smir=\Ea, smso=\EU,
+	il1=\EL, is2=\Ev\E_AX\Eb\EW\E9P\ET, kbs=^H, ri=\EI,
+	rmir=\Eb, rmso=\ET, smir=\Ea, smso=\EU, use=vt52+arrows,
 
 # Visual 200 from BRL
 # The following switch settings are assumed for normal operation:
@@ -11489,7 +12103,7 @@ vi55|Visual 55,
 # (This cap is commented out because <smir>/<rmir> is more efficient -- esr)
 # Supposedly "4*" delays should be used for <il1>, <ed>, <clear>, <dch1>,
 # and <dl1> strings, but we seem to get along fine without them.
-vi200|visual 200,
+vi200|Visual 200,
 	OTbs, OTpt, am, mir, msgr,
 	OTkn#10, cols#80, it#8, lines#24,
 	acsc=+h.kffggjmkllsmenbq`tnuovcwdxa}r, bel=^G, cbt=\Ez,
@@ -11497,47 +12111,44 @@ vi200|visual 200,
 	cup=\EY%p1%{32}%+%c%p2%{32}%+%c, cuu1=\EA, cvvis=\Ed,
 	dch1=\EO, dim=\E4, dl1=\EM, ed=\Ey, el=\Ex, home=\EH, ht=^I,
 	hts=\E1, il1=\EL, ind=\n, invis=\Ea, kbs=^H, kclr=\Ev,
-	kctab=\E2, kcub1=\ED, kcud1=\EB, kcuf1=\EC, kcuu1=\EA,
-	kdch1=\EO, kdl1=\EM, ked=\EJ, kel=\Et, kf0=\E?p, kf1=\E?q,
-	kf2=\E?r, kf3=\E?s, kf4=\E?t, kf5=\E?u, kf6=\E?v, kf7=\E?w,
-	kf8=\E?x, kf9=\E?y, khome=\EH, khts=\E1, kich1=\Ei, kil1=\EL,
-	krmir=\Ej, mc0=\EH\E], mc4=\EX, mc5=\EW, ri=\EI, rmacs=\EG,
-	rmkx=\E>, rmso=\E3, rs1=\E3\Eb\Ej\E\El\EG\Ec\Ek\EX,
-	sgr0=\E3\Eb, smacs=\EF, smkx=\E=, smso=\E4, tbc=\Eg,
+	kctab=\E2, kdch1=\EO, kdl1=\EM, ked=\EJ, kel=\Et, kf0=\E?p,
+	kf1=\E?q, kf2=\E?r, kf3=\E?s, kf4=\E?t, kf5=\E?u, kf6=\E?v,
+	kf7=\E?w, kf8=\E?x, kf9=\E?y, khome=\EH, khts=\E1, kich1=\Ei,
+	kil1=\EL, krmir=\Ej, mc0=\EH\E], mc4=\EX, mc5=\EW, ri=\EI,
+	rmacs=\EG, rmkx=\E>, rmso=\E3,
+	rs1=\E3\Eb\Ej\E\El\EG\Ec\Ek\EX, sgr0=\E3\Eb, smacs=\EF,
+	smkx=\E=, smso=\E4, tbc=\Eg, use=vt52+arrows,
 # The older Visuals didn't come with function keys. This entry uses
 # <smkx> and <rmkx> so that the keypad keys can be used as function keys.
 # If your version of vi doesn't support function keys you may want
 # to use vi200-f.
-vi200-f|visual 200 no function keys,
-	is2=\E3\Eb\Ej\E\\\El\EG\Ed\Ek, kf0=\E?p, kf1=\E?q,
-	kf2=\E?r, kf3=\E?s, kf4=\E?t, kf5=\E?u, kf6=\E?v, kf7=\E?w,
-	kf8=\E?x, kf9=\E?y, rmkx=\E>, rmso@, smkx=\E=, smso@,
-	use=vi200,
-vi200-rv|visual 200 reverse video,
-	cnorm@, cvvis@, ri@, rmso=\E3, smso=\E4, use=vi200,
+vi200-f|Visual 200 no function keys,
+	is2=\E3\Eb\Ej\E\\\El\EG\Ed\Ek, rmso@, smso@, use=vi200,
+vi200-rv|Visual 200 reverse video,
+	cnorm@, cvvis@, ri@, use=vi200,
 
 # the function keys are programmable but we don't reprogram them to their
 # default values with <is2> because programming them is very verbose. maybe
 # an initialization file should be made for the 300 and they could be stuck
 # in it.
 # (vi300: added <rmam>/<smam> based on init string -- esr)
-vi300|visual 300 ansi x3.64,
+vi300|Visual 300 ANSI x3.64,
 	am, bw, mir, xenl,
 	cols#80, lines#24,
-	bel=^G, cbt=\E[Z, clear=\E[H\E[2J, cr=\r, cub1=^H, cud1=\E[B,
-	cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A,
-	dch1=\E[P$<40>, dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H, ht=^I,
-	il1=\E[L, ind=\n,
+	bel=^G, cbt=\E[Z, clear=\E[H\E[2J, cr=\r, cub1=^H,
+	cup=\E[%i%p1%d;%p2%dH, dch1=\E[P$<40>, dl1=\E[M, ed=\E[J,
+	el=\E[K, home=\E[H, ht=^I, il1=\E[L, ind=\n,
 	is2=\E[7s\E[2;3;4;20;?5;?6l\E[12;?7h\E[1Q\E[0;1(D\E[8s,
 	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
 	kf1=\E_A\E\\, kf2=\E_B\E\\, kf3=\E_C\E\\, kf4=\E_D\E\\,
 	kf5=\E_E\E\\, kf6=\E_F\E\\, kf7=\E_G\E\\, kf8=\E_H\E\\,
 	kf9=\E_I\E\\, khome=\E[H, ri=\EM, rmam=\E[?7l, rmir=\E[4l,
 	rmso=\E[m, rmul=\E[m, sgr0=\E[m, smam=\E[?7h, smir=\E[4h,
-	smso=\E[1m, smul=\E[4m,
+	smso=\E[1m, smul=\E[4m, use=ansi+local1,
+
 # some of the vi300s have older firmware that has the command
 # sequence for setting editing extent reversed.
-vi300-old|visual 300 with old firmware (set edit extent reversed),
+vi300-old|Visual 300 with old firmware (set edit extent reversed),
 	is2=\E[7s\E[2;3;4;20;?5;?6l\E[12;?7h\E[2Q\E[0;1(D\E[8s, use=vi300,
 
 # Visual 500 prototype entry from University of Wisconsin.
@@ -11549,7 +12160,7 @@ vi300-old|visual 300 with old firmware (set edit extent reversed),
 # of this slow terminal.  :xp: is 10 time the padding factor.
 # (vi500: removed unknown :xp#4: termcap;
 # also added empty <acsc> to suppress tic warning -- esr)
-vi500|visual 500,
+vi500|Visual 500,
 	am, mir, msgr,
 	cols#80, it#8, lines#33,
 	acsc=, cbt=\Ez$<4/>, clear=\Ev$<6*/>, cr=\r,
@@ -11559,27 +12170,27 @@ vi500|visual 500,
 	el=\Ex$<16/>, home=\EH, ht=\011$<8/>, il1=\EL\Ex$<3*/>,
 	ind=\n,
 	is2=\E3\E\001\E\007\E\003\Ek\EG\Ed\EX\El\E>\Eb\E\\,
-	kbs=^H, kcub1=\ED, kcud1=\EB, kcuf1=\EC, kcuu1=\EA,
-	khome=\EH, nel=\r\n, rmacs=^O, rmir=\Ej, rmso=\E^G,
+	kbs=^H, khome=\EH, nel=\r\n, rmacs=^O, rmir=\Ej, rmso=\E^G,
 	rmul=\E^C, smacs=^N, smir=\Ei, smso=\E^H, smul=\E^D,
+	use=vt52+arrows,
 
-# The visual 550 is a visual 300 with tektronix graphics,
+# The visual 550 is a visual 300 with Tektronix graphics,
 # and with 33 lines. clear screen is modified here to
 # also clear the graphics.
-vi550|visual 550 ansi x3.64,
+vi550|Visual 550 ANSI x3.64,
 	lines#33,
 	clear=\030\E[H\E[2J, use=vi300,
 
-vi603|visual603|visual 603,
+vi603|visual603|Visual 603,
 	hs, mir,
-	bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[J,
+	blink=\E[5m, bold=\E[1m, clear=\E[H\E[J,
 	csr=\E[%i%p1%d;%p2%dr, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, dch1=\E[P, dl1=\E[M,
-	dsl=\EP2;1~\E\\, ed=\E[J, el=\E[K, fsl=\E\\, il1=\E[L,
-	ind=\ED, is1=\E>\E[?3l\E[?4l\E[?7h\E[?8h\E[1;24r,
-	rev=\E[7m, ri=\EM, rmir=\E[4l, rmso=\E[27m, rmul=\E[24m,
+	cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, dch1=\E[P,
+	dsl=\EP2;1~\E\\, ed=\E[J, el=\E[K, fsl=\E\\, ind=\ED,
+	is1=\E>\E[?3l\E[?4l\E[?7h\E[?8h\E[1;24r, rev=\E[7m,
+	ri=\EM, rmir=\E[4l, rmso=\E[27m, rmul=\E[24m,
 	sgr0=\E[m\017$<2>, smir=\E[4h, smso=\E[7m, smul=\E[4m,
-	tsl=\EP2~, use=vt100+4bsd,
+	tsl=\EP2~, use=ansi+idl1, use=decid+cpr, use=vt100+4bsd,
 
 #### Wyse (wy)
 #
@@ -11616,32 +12227,32 @@ vi603|visual603|visual 603,
 #	should be used.
 #
 wy30|wyse30|Wyse 30,
-	am, bw, hs, mc5i, mir, msgr, xon,
-	cols#80, lh#1, lines#24, lw#8, ma#1, nlab#8, wsl#45,
+	am, bw, mc5i, mir, msgr, xon,
+	cols#80, lh#1, lines#24, lw#8, ma#1, nlab#8,
 	acsc=0wa_h[jukslrmqnxqzttuyv]wpxv, bel=^G, cbt=\EI,
 	civis=\E`0, clear=\E+$<80>, cnorm=\E`1, cr=\r, cub1=^H,
 	cud1=\n, cuf1=^L, cup=\E=%p1%{32}%+%c%p2%{32}%+%c,
 	cuu1=^K, dch1=\EW$<10>, dim=\E`7\E), dl1=\ER$<1>,
-	dsl=\EF\r, ed=\EY$<80>, el=\ET, flash=\E`8$<100/>\E`9,
-	fsl=\r, home=^^, ht=\011$<1>, hts=\E1, il1=\EE$<2>,
-	ind=\n$<2>, ip=$<2>, is2=\E'\E(\E\^3\E`9\016\024,
-	kHOM=\E{, kbs=^H, kcbt=\EI, kcub1=^H, kcud1=\n, kcuf1=^L,
-	kcuu1=^K, kdch1=\EW, kdl1=\ER, ked=\EY, kel=\ET, kent=\E7,
-	kf1=^A@\r, kf2=^AA\r, kf3=^AB\r, kf4=^AC\r, kf5=^AD\r,
-	kf6=^AE\r, kf7=^AF\r, kf8=^AG\r, khome=^^, kich1=\EQ,
-	kil1=\EE, knp=\EK, kpp=\EJ, krpl=\Er, ll=^^^K, mc0=\EP, mc4=^T,
-	mc5=^X, nel=\r\n, pfx=\Ez%p1%{63}%+%c%p2%s\177,
+	ed=\EY$<80>, el=\ET, flash=\E`8$<100/>\E`9, home=^^,
+	ht=\011$<1>, hts=\E1, il1=\EE$<2>, ind=\n$<2>, ip=$<2>,
+	is2=\E'\E(\E\^3\E`9\016\024, kHOM=\E{, kbs=^H, kcbt=\EI,
+	kcub1=^H, kcud1=\n, kcuf1=^L, kcuu1=^K, kdch1=\EW, kdl1=\ER,
+	ked=\EY, kel=\ET, kent=\E7, kf1=^A@\r, kf2=^AA\r, kf3=^AB\r,
+	kf4=^AC\r, kf5=^AD\r, kf6=^AE\r, kf7=^AF\r, kf8=^AG\r,
+	khome=^^, kich1=\EQ, kil1=\EE, knp=\EK, kpp=\EJ, krpl=\Er,
+	ll=^^^K, mc0=\EP, mc4=^T, mc5=^X, nel=\r\n,
+	pfx=\Ez%p1%{63}%+%c%p2%s\177,
 	pln=\Ez%p1%{47}%+%c%p2%s\r, prot=\E`7\E), ri=\Ej$<3>,
 	rmacs=\EH^C, rmir=\Er, rmln=\EA11, rmso=\E(,
 	sgr=%?%p1%p5%p8%|%|%t\E`7\E)%e\E(%;%?%p9%t\EH\002%e\EH\003%;,
 	sgr0=\E(\EH\003, smacs=\EH^B, smir=\Eq, smln=\EA10,
-	smso=\E`7\E), tbc=\E0, tsl=\EF,
+	smso=\E`7\E), tbc=\E0, use=wyse+sl,
 #
 #	This terminal description uses the non-hidden attribute mode
 #	(with magic cookie).
 #
 # (wy30-mc: added <smcup> to suppress tic warning --esr)
-wy30-mc|wyse30-mc|wyse 30 with magic cookies,
+wy30-mc|wyse30-mc|Wyse 30 with magic cookies,
 	msgr@,
 	ma@, xmc#1,
 	blink=\EG2, dim=\EGp, prot=\EG0\E), rmacs=\EG0\EH\003,
@@ -11655,7 +12266,7 @@ wy30-mc|wyse30-mc|wyse 30 with magic cookies,
 #	older versions of terminfo.  If you see this effect then
 #	unset xon and delete the / from the delay.
 #	i.e. change $<100/> to $<100>
-wy30-vb|wyse30-vb|wyse 30 visible bell,
+wy30-vb|wyse30-vb|Wyse 30 visible bell,
 	bel@, use=wy30,
 #
 #	   The Wyse 50 can support one attribute (e.g. Dim, Inverse,
@@ -11668,32 +12279,36 @@ wy30-vb|wyse30-vb|wyse 30 visible bell,
 #	to correctly handle multiple attributes on a screen.
 #
 wy50|wyse50|Wyse 50,
-	am, bw, hs, mc5i, mir, msgr, xon,
-	cols#80, lh#1, lines#24, lw#8, ma#1, nlab#8, wsl#45,
-	acsc=a;j5k3l2m1n8q\:t4u9v=w0x6, bel=^G, cbt=\EI,
+	am, bw, mc5i, mir, msgr, xon,
+	cols#80, lh#1, lines#24, lw#8, ma#1, nlab#8,
+	acsc=a;j5k3l2m1n8q:t4u9v=w0x6, bel=^G, cbt=\EI,
 	civis=\E`0, clear=\E+$<20>, cnorm=\E`1, cr=\r, cub1=^H,
 	cud1=\n, cuf1=^L, cup=\E=%p1%{32}%+%c%p2%{32}%+%c,
-	cuu1=^K, dch1=\EW$<1>, dim=\E`7\E), dl1=\ER, dsl=\EF\r,
-	ed=\EY$<20>, el=\ET, flash=\E`8$<100/>\E`9, fsl=\r,
-	home=^^, ht=^I, hts=\E1, il1=\EE, ind=\n$<2>, ip=$<1>,
-	is1=\E`\:\E`9$<30>, is2=\016\024\E'\E(, kHOM=\E{, kbs=^H,
-	kcbt=\EI, kcub1=^H, kcud1=\n, kcuf1=^L, kcuu1=^K, kdch1=\EW,
-	kdl1=\ER, ked=\EY, kel=\ET, kent=\E7, kf1=^A@\r, kf10=^AI\r,
-	kf11=^AJ\r, kf12=^AK\r, kf13=^AL\r, kf14=^AM\r, kf15=^AN\r,
-	kf16=^AO\r, kf2=^AA\r, kf3=^AB\r, kf4=^AC\r, kf5=^AD\r,
-	kf6=^AE\r, kf7=^AF\r, kf8=^AG\r, kf9=^AH\r, khome=^^,
-	kich1=\EQ, kil1=\EE, knp=\EK, kpp=\EJ, kprt=\EP, krpl=\Er,
-	ll=^^^K, mc0=\EP, mc4=^T, mc5=^X, nel=\r\n,
+	cuu1=^K, dch1=\EW$<1>, dim=\E`7\E), dl1=\ER, ed=\EY$<20>,
+	el=\ET, flash=\E`8$<100/>\E`9, home=^^, ht=^I, hts=\E1,
+	il1=\EE, ind=\n$<2>, ip=$<1>, is1=\E`:\E`9$<30>,
+	is2=\016\024\E'\E(, kHOM=\E{, kbs=^H, kcbt=\EI, kcub1=^H,
+	kcud1=\n, kcuf1=^L, kcuu1=^K, kdch1=\EW, kdl1=\ER, ked=\EY,
+	kel=\ET, kent=\E7, kf1=^A@\r, kf10=^AI\r, kf11=^AJ\r,
+	kf12=^AK\r, kf13=^AL\r, kf14=^AM\r, kf15=^AN\r, kf16=^AO\r,
+	kf2=^AA\r, kf3=^AB\r, kf4=^AC\r, kf5=^AD\r, kf6=^AE\r,
+	kf7=^AF\r, kf8=^AG\r, kf9=^AH\r, khome=^^, kich1=\EQ,
+	kil1=\EE, knp=\EK, kpp=\EJ, kprt=\EP, krpl=\Er, ll=^^^K,
+	mc0=\EP, mc4=^T, mc5=^X, nel=\r\n,
 	pfx=\Ez%p1%{63}%+%c%p2%s\177,
 	pln=\Ez%p1%{47}%+%c%p2%s\r, prot=\E`7\E), rev=\E`6\E),
 	ri=\Ej, rmacs=\EH^C, rmir=\Er, rmln=\EA11, rmso=\E(,
 	sgr=%?%p1%p3%|%t\E`6\E)%e%p5%p8%|%t\E`7\E)%e\E(%;%?%p9%t\EH
 	    \002%e\EH\003%;,
 	sgr0=\E(\EH\003, smacs=\EH^B, smir=\Eq, smln=\EA10,
-	smso=\E`6\E), tbc=\E0, tsl=\EF, kF1=^A`\r, kF10=^Ai\r,
-	kF11=^Aj\r, kF12=^Ak\r, kF13=^Al\r, kF14=^Am\r, kF15=^An\r,
-	kF16=^Ao\r, kF2=^Aa\r, kF3=^Ab\r, kF4=^Ac\r, kF5=^Ad\r,
-	kF6=^Ae\r, kF7=^Af\r, kF8=^Ag\r, kF9=^Ah\r,
+	smso=\E`6\E), tbc=\E0, kF1=^A`\r, kF10=^Ai\r, kF11=^Aj\r,
+	kF12=^Ak\r, kF13=^Al\r, kF14=^Am\r, kF15=^An\r, kF16=^Ao\r,
+	kF2=^Aa\r, kF3=^Ab\r, kF4=^Ac\r, kF5=^Ad\r, kF6=^Ae\r,
+	kF7=^Af\r, kF8=^Ag\r, kF9=^Ah\r, use=wyse+sl,
+wyse+sl|status line for Wyse terminals,
+	hs,
+	wsl#45,
+	dsl=\EF\r, fsl=\r, tsl=\EF,
 #
 #	This terminal description uses the non-hidden attribute mode
 #	(with magic cookie).
@@ -11703,7 +12318,7 @@ wy50|wyse50|Wyse 50,
 #	unset <xon> and delete the / from the delay.
 #	i.e. change $<100/> to $<100>
 # (wy50-mc: added <smcup> to suppress tic warning --esr)
-wy50-mc|wyse50-mc|wyse 50 with magic cookies,
+wy50-mc|wyse50-mc|Wyse 50 with magic cookies,
 	msgr@,
 	ma@, xmc#1,
 	blink=\EG2, dim=\EGp, prot=\EG0\E), rev=\EG4,
@@ -11713,13 +12328,13 @@ wy50-mc|wyse50-mc|wyse 50 with magic cookies,
 	    %t\E)%e\E(%;%?%p9%t\EH\002%e\EH\003%;,
 	sgr0=\EG0\E(\EH\003, smacs=\EG0\EH\002, smcup=,
 	smso=\EGt, use=wy50, use=adm+sgr,
-wy50-vb|wyse50-vb|wyse 50 visible bell,
+wy50-vb|wyse50-vb|Wyse 50 visible bell,
 	bel@, use=wy50,
-wy50-w|wyse50-w|wyse 50 132-column,
+wy50-w|wyse50-w|Wyse 50 132-column,
 	cols#132, lw#7, nlab#16, wsl#97,
 	cup=\Ea%i%p1%dR%p2%dC, dch1=\EW$<2>, is1=\E`;\E`9$<30>,
 	use=wy50,
-wy50-wvb|wyse50-wvb|wyse 50 132-column visible bell,
+wy50-wvb|wyse50-wvb|Wyse 50 132-column visible bell,
 	bel@, use=wy50-w,
 
 #
@@ -11746,16 +12361,16 @@ wy50-wvb|wyse50-wvb|wyse 50 132-column visible bell,
 #
 # Bug: The <op> capability resets attributes.
 wy350|wyse350|Wyse 350,
-	am, bw, hs, mc5i, mir, xon,
+	am, bw, mc5i, mir, xon,
 	colors#8, cols#80, lh#1, lines#24, lw#8, ncv#55, nlab#8, pairs#8,
-	wsl#45, xmc#1,
+	xmc#1,
 	acsc=0wa_h[jukslrmqnxqzttuyv]wpxv, bel=^G, blink=\EG2,
 	cbt=\EI, civis=\E`0, clear=\E+$<20>, cnorm=\E`1, cr=\r,
 	cub1=^H, cud1=\n, cuf1=^L,
 	cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K, dch1=\EW$<1>,
-	dim=\EGp, dl1=\ER, dsl=\EF\r, ed=\EY$<20>, el=\ET,
-	flash=\E`8$<100/>\E`9, fsl=\r, home=^^, ht=^I, hts=\E1,
-	il1=\EE, ind=\n$<2>, ip=$<1>, is1=\E`\:\E`9$<30>,
+	dim=\EGp, dl1=\ER, ed=\EY$<20>, el=\ET,
+	flash=\E`8$<100/>\E`9, home=^^, ht=^I, hts=\E1, il1=\EE,
+	ind=\n$<2>, ip=$<1>, is1=\E`:\E`9$<30>,
 	is2=\016\024\E'\E(, is3=\E%?, kHOM=\E{, kbs=^H, kcbt=\EI,
 	kcub1=^H, kcud1=\n, kcuf1=^L, kcuu1=^K, kdch1=\EW, kdl1=\ER,
 	ked=\EY, kel=\ET, kent=\E7, kf1=^A@\r, kf10=^AI\r,
@@ -11776,20 +12391,20 @@ wy350|wyse350|Wyse 350,
 	    %{64}%|%;%;%gA%+%{48}%+%c%?%p8%t\E)%e\E(%;%?%p9%t\EH
 	    \002%e\EH\003%;,
 	sgr0=\EG0\E(\EH\003%{0}%PA%{0}%PC, smacs=\EG0\EH\002,
-	smir=\Eq, smln=\EA10, tbc=\E0, tsl=\EF, use=adm+sgr,
-wy350-vb|wyse350-vb|wyse 350 visible bell,
+	smir=\Eq, smln=\EA10, tbc=\E0, use=adm+sgr, use=wyse+sl,
+wy350-vb|wyse350-vb|Wyse 350 visible bell,
 	bel@, use=wy350,
-wy350-w|wyse350-w|wyse 350 132-column,
+wy350-w|wyse350-w|Wyse 350 132-column,
 	cols#132, lw#7, nlab#16, wsl#97,
 	cup=\Ea%i%p1%dR%p2%dC, dch1=\EW$<2>, is1=\E`;\E`9$<30>,
 	use=wy350,
-wy350-wvb|wyse350-wvb|wyse 350 132-column visible bell,
+wy350-wvb|wyse350-wvb|Wyse 350 132-column visible bell,
 	bel@, use=wy350-w,
 #
 #	This terminfo description is untested.
 #	The wyse100 emulates an adm31, so the adm31 entry should work.
 #
-wy100|wyse 100,
+wy100|Wyse 100,
 	hs, mir,
 	cols#80, lines#24, xmc#1,
 	bel=^G, clear=\E;, cr=\r, cub1=^H, cud1=\n, cuf1=^L,
@@ -11807,15 +12422,15 @@ wy100|wyse 100,
 #	then set <msgr>.
 #
 wy120|wyse120|wy150|wyse150|Wyse 120/150,
-	am, bw, hs, km, mc5i, mir, msgr, xon,
-	cols#80, it#8, lh#1, lines#24, lw#8, nlab#8, pb#9601, wsl#45,
+	am, bw, km, mc5i, mir, msgr, xon,
+	cols#80, it#8, lh#1, lines#24, lw#8, nlab#8, pb#9601,
 	acsc=+/\,.0[a2fxgqh1ihjYk?lZm@nEqDtCu4vAwBx3yszr{c~~,
 	bel=^G, blink=\EG2, cbt=\EI, civis=\E`0, clear=\E+$<50>,
 	cnorm=\E`1, cr=\r, cub1=^H, cud1=\n, cuf1=^L,
 	cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K, dch1=\EW$<7>,
-	dim=\EGp, dl1=\ER$<3>, dsl=\EF\r, ed=\EY$<50>, el=\ET$<4>,
-	flash=\E`8$<100/>\E`9, fsl=\r, home=^^, ht=\011$<1>,
-	hts=\E1, il1=\EE$<3>, ind=\n$<3>, ip=$<2>, is1=\EcB0\EcC1,
+	dim=\EGp, dl1=\ER$<3>, ed=\EY$<50>, el=\ET$<4>,
+	flash=\E`8$<100/>\E`9, home=^^, ht=\011$<1>, hts=\E1,
+	il1=\EE$<3>, ind=\n$<3>, ip=$<2>, is1=\EcB0\EcC1,
 	is2=\Ed$\EcD\E'\Er\EH\003\Ed/\EO\Ee1\Ed*\E`@\E`9\E`1\016
 	    \024\El,
 	is3=\EwJ\Ew1$<150>, kHOM=\E{, kbs=^H, kcbt=\EI, kcub1=^H,
@@ -11830,25 +12445,25 @@ wy120|wyse120|wy150|wyse150|Wyse 120/150,
 	pfx=\EZ1%p1%{63}%+%c%p2%s\177,
 	pln=\Ez%p1%{47}%+%c%p2%s\r, prot=\E), ri=\Ej$<2>,
 	rmacs=\EcD, rmam=\Ed., rmcup=\Ew1, rmir=\Er, rmln=\EA11,
-	rmxon=\Ec20, rs1=\E~!\E~4$<30>, rs2=\EeF\E`\:$<70>,
+	rmxon=\Ec20, rs1=\E~!\E~4$<30>, rs2=\EeF\E`:$<70>,
 	rs3=\EwG\Ee($<100>,
 	sgr=%?%p8%t\E)%e\E(%;%?%p9%t\EcE%e\EcD%;\EG%{48}%?%p2%t%{8}
 	    %|%;%?%p1%p3%|%p6%|%t%{4}%|%;%?%p4%t%{2}%|%;%?%p1%p5%|%t
 	    %{64}%|%;%?%p7%t%{1}%|%;%c,
 	sgr0=\E(\EH\003\EG0\EcD, smacs=\EcE, smam=\Ed/,
 	smcup=\Ew0, smir=\Eq, smln=\EA10, smso=\EGt, smxon=\Ec21,
-	tbc=\E0, tsl=\EF, use=adm+sgr,
+	tbc=\E0, use=adm+sgr, use=wyse+sl,
 #
-wy120-w|wyse120-w|wy150-w|wyse150-w|wyse 120/150 132-column,
+wy120-w|wyse120-w|wy150-w|wyse150-w|Wyse 120/150 132-column,
 	cols#132, lw#7, nlab#16, wsl#97,
 	cup=\Ea%i%p1%dR%p2%dC, dch1=\EW$<12>, ip=$<4>,
 	rs2=\E`;$<70>, use=wy120,
 #
-wy120-25|wyse120-25|wy150-25|wyse150-25|wyse 120/150 80-column 25-lines,
+wy120-25|wyse120-25|wy150-25|wyse150-25|Wyse 120/150 80-column 25-lines,
 	lh@, lines#25, lw@, nlab@,
 	pln@, rs3=\EwG\Ee)$<100>, use=wy120,
 #
-wy120-25-w|wyse120-25-w|wy150-25-w|wyse150-25-w|wyse 120/150 132-column 25-lines,
+wy120-25-w|wyse120-25-w|wy150-25-w|wyse150-25-w|Wyse 120/150 132-column 25-lines,
 	lh@, lines#25, lw@, nlab@,
 	pln@, rs3=\EwG\Ee)$<100>, use=wy120-w,
 #
@@ -11870,7 +12485,7 @@ wy120-w-vb|wy120-wvb|wyse120-wvb|wy150-w-vb|wyse150-w-vb|Wyse 120/150 132-column
 #		<is2> -> do the initialization
 #		<is3> -> set up display memory (2 pages)
 #
-#	The Wyse 60's that have vt100 emulation are slower than the
+#	The Wyse 60's that have VT100 emulation are slower than the
 #	older Wyse 60's.  This change happened mid-1987.
 #	The capabilities effected are <dch1> <dl1> <il1> <ind> <ri>
 #
@@ -11889,16 +12504,16 @@ wy120-w-vb|wy120-wvb|wyse120-wvb|wy150-w-vb|wyse150-w-vb|Wyse 120/150 132-column
 # (wy60: we use \E{ rather than ^^ for home (both are documented) to avoid
 # a bug reported by Robert Dunn, <rcdii@inlink.com> -- esr)
 wy60|wyse60|Wyse 60,
-	am, bw, hs, km, mc5i, mir, msgr,
-	cols#80, lh#1, lines#24, lw#8, nlab#8, wsl#45,
+	am, bw, km, mc5i, mir, msgr,
+	cols#80, lh#1, lines#24, lw#8, nlab#8,
 	acsc=+/\,.0[a2fxgqh1ihjYk?lZm@nEqDtCu4vAwBx3yszr{c~~,
 	bel=^G, blink=\EG2, cbt=\EI, civis=\E`0, clear=\E+$<100>,
 	cnorm=\E`1, cr=\r, cub1=^H, cud1=\n, cuf1=^L,
 	cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K,
-	dch1=\EW$<11>, dclk=\E`b, dim=\EGp, dl1=\ER$<5>, dsl=\EF\r,
-	ed=\EY$<100>, el=\ET, flash=\E`8$<100/>\E`9, fsl=\r,
-	home=\E{, ht=\011$<1>, hts=\E1, il1=\EE$<4>, ind=\n$<5>,
-	ip=$<3>, is1=\EcB0\EcC1,
+	dch1=\EW$<11>, dclk=\E`b, dim=\EGp, dl1=\ER$<5>,
+	ed=\EY$<100>, el=\ET, flash=\E`8$<100/>\E`9, home=\E{,
+	ht=\011$<1>, hts=\E1, il1=\EE$<4>, ind=\n$<5>, ip=$<3>,
+	is1=\EcB0\EcC1,
 	is2=\Ed$\EcD\E'\Er\EH\003\Ed/\EO\Ee1\Ed*\E`@\E`9\E`1\016
 	    \024\El,
 	is3=\EwJ\Ew1$<150>, kHOM=\E{, kbs=^H, kcbt=\EI, kcub1=^H,
@@ -11920,39 +12535,39 @@ wy60|wyse60|Wyse 60,
 	    %{64}%|%;%?%p7%t%{1}%|%;%c,
 	sgr0=\E(\EH\003\EG0\EcD, smacs=\EcE, smam=\Ed/,
 	smcup=\Ew0, smir=\Eq, smln=\EA10, smso=\EGt, smxon=\Ec21,
-	tbc=\E0, tsl=\EF, kF1=^A`\r, kF10=^Ai\r, kF11=^Aj\r,
-	kF12=^Ak\r, kF13=^Al\r, kF14=^Am\r, kF15=^An\r, kF16=^Ao\r,
-	kF2=^Aa\r, kF3=^Ab\r, kF4=^Ac\r, kF5=^Ad\r, kF6=^Ae\r,
-	kF7=^Af\r, kF8=^Ag\r, kF9=^Ah\r, use=adm+sgr,
+	tbc=\E0, kF1=^A`\r, kF10=^Ai\r, kF11=^Aj\r, kF12=^Ak\r,
+	kF13=^Al\r, kF14=^Am\r, kF15=^An\r, kF16=^Ao\r, kF2=^Aa\r,
+	kF3=^Ab\r, kF4=^Ac\r, kF5=^Ad\r, kF6=^Ae\r, kF7=^Af\r,
+	kF8=^Ag\r, kF9=^Ah\r, use=adm+sgr, use=wyse+sl,
 #
-wy60-w|wyse60-w|wyse 60 132-column,
+wy60-w|wyse60-w|Wyse 60 132-column,
 	cols#132, lw#7, nlab#16, wsl#97,
 	cup=\Ea%i%p1%dR%p2%dC, dch1=\EW$<16>, ip=$<5>,
 	rs2=\EeF$<150>\E`;$<150>, use=wy60,
 #
-wy60-25|wyse60-25|wyse 60 80-column 25-lines,
+wy60-25|wyse60-25|Wyse 60 80-column 25-lines,
 	lh@, lines#25, lw@, nlab@,
 	pln@, rs3=\EwG\Ee)$<200>, use=wy60,
-wy60-25-w|wyse60-25-w|wyse 60 132-column 25-lines,
+wy60-25-w|wyse60-25-w|Wyse 60 132-column 25-lines,
 	lh@, lines#25, lw@, nlab@,
 	pln@, rs3=\EwG\Ee)$<200>, use=wy60-w,
 #
-wy60-42|wyse60-42|wyse 60 80-column 42-lines,
+wy60-42|wyse60-42|Wyse 60 80-column 42-lines,
 	lines#42,
 	clear=\E+$<260>, cup=\E=%p1%{32}%+%c%p2%{32}%+%c$<2>,
 	dch1=\EW$<16>, dl1=\ER$<11>, ed=\Ey$<260>, il1=\EE$<11>,
 	ind=\n$<9>, ip=$<5>, is1=\EcB2\EcC3, nel=\r\n$<6>,
 	ri=\Ej$<10>, rs3=\Ee*$<150>, use=wy60,
-wy60-42-w|wyse60-42-w|wyse 60 132-column 42-lines,
+wy60-42-w|wyse60-42-w|Wyse 60 132-column 42-lines,
 	cols#132, lw#7, nlab#16, wsl#97,
-	clear=\E+$<260>, cup=\Ea%i%p1%dR%p2%dC$<2>,
-	dch1=\EW$<19>, ed=\Ey$<260>, home=\036$<2>, ip=$<6>,
-	nel=\r\n$<11>, rs2=\EeF$<150>\E`;$<150>, use=wy60-42,
+	cup=\Ea%i%p1%dR%p2%dC$<2>, dch1=\EW$<19>,
+	home=\036$<2>, ip=$<6>, nel=\r\n$<11>,
+	rs2=\EeF$<150>\E`;$<150>, use=wy60-42,
 #
-wy60-43|wyse60-43|wyse 60 80-column 43-lines,
+wy60-43|wyse60-43|Wyse 60 80-column 43-lines,
 	lh@, lines#43, lw@, nlab@,
 	pln@, rs3=\Ee+$<150>, use=wy60-42,
-wy60-43-w|wyse60-43-w|wyse 60 132-column 43-lines,
+wy60-43-w|wyse60-43-w|Wyse 60 132-column 43-lines,
 	lh@, lines#43, lw@, nlab@,
 	pln@, rs3=\Ee+$<150>, use=wy60-42-w,
 #
@@ -11979,22 +12594,21 @@ wy60-w-vb|wy60-wvb|wyse60-wvb|Wyse 60 132-column visible bell,
 wy99gt|wyse99gt|Wyse 99gt,
 	msgr@,
 	clear=\E+$<130>, dch1=\EW$<7>, dl1=\ER$<4>, ed=\Ey$<130>,
-	el=\Et$<5>, flash=\E`8$<100/>\E`9, ht=\011$<1>,
-	il1=\EE$<4>, ind=\n$<4>, ip=$<2>, is3=\Ew0$<20>, nel@,
-	ri=\Ej$<3>, rmcup=\Ew0, rs2=\E`\:$<150>, smcup=\Ew1,
+	el=\Et$<5>, ind=\n$<4>, ip=$<2>, is3=\Ew0$<20>, nel@,
+	ri=\Ej$<3>, rmcup=\Ew0, rs2=\E`:$<150>, smcup=\Ew1,
 	u0=\E~>\E8, u1=\E[42h, use=wy60,
 #
-wy99gt-w|wyse99gt-w|wyse 99gt 132-column,
+wy99gt-w|wyse99gt-w|Wyse 99gt 132-column,
 	cols#132, lw#7, nlab#16, wsl#97,
 	clear=\E+$<160>, cup=\Ea%i%p1%dR%p2%dC$<2>,
 	dch1=\EW$<9>, ed=\Ey$<160>, ip=$<4>, rs2=\E`;$<150>,
 	use=wy99gt,
 #
-wy99gt-25|wyse99gt-25|wyse 99gt 80-column 25-lines,
+wy99gt-25|wyse99gt-25|Wyse 99gt 80-column 25-lines,
 	lh@, lines#25, lw@, nlab@,
-	pln@, rs2=\E`\:$<150>, rs3=\EwG\Ee)$<200>, use=wy99gt,
+	pln@, rs3=\EwG\Ee)$<200>, use=wy99gt,
 #
-wy99gt-25-w|wyse99gt-25-w|wyse 99gt 132-column 25-lines,
+wy99gt-25-w|wyse99gt-25-w|Wyse 99gt 132-column 25-lines,
 	lh@, lines#25, lw@, nlab@,
 	pln@, rs2=\E`;$<150>, use=wy99gt-w,
 #
@@ -12008,7 +12622,7 @@ wy99gt-w-vb|wy99gt-wvb|wyse99gt-wvb|Wyse 99gt 132-column visible bell,
 # - can't redefine function keys (anyway, key redefinition in ANSI mode
 #   is too much complex to be described);
 # - meta key can't be described (the terminal forgets it when reset);
-# The xon-xoff handshaking can't be disabled while in ansi personality, so
+# The xon-xoff handshaking can't be disabled while in ANSI personality, so
 # emacs can't work at speed greater than 9600 baud.  No padding is needed at
 # this speed.
 #   dch1 has been commented out because it causes annoying glittering when
@@ -12018,21 +12632,19 @@ wy99gt-w-vb|wy99gt-wvb|wyse99gt-wvb|Wyse 99gt 132-column visible bell,
 # thing is that vi goes crazy if smir-rmir are present and both dch-dch1 are
 # not, so smir and rmir are commented out as well.
 # From: Francesco Potorti` <F.Potorti@cnuce.cnr.it>, 24 Aug 1998
-wy99-ansi|Wyse WY-99GT in ansi mode (int'l PC keyboard),
-	am, km, mc5i, mir, msgr, xenl,
+wy99-ansi|Wyse WY-99GT in ANSI mode (int'l PC keyboard),
+	am, km, mir, msgr, xenl,
 	cols#80, it#8, lines#25, vt#3,
 	acsc=``aaffggjjkkllmmnnooqqssttuuvvwwxx{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[?25l,
-	clear=\E[H\E[J$<200>, cnorm=\E[34h\E[?25h, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD$<1>,
+	bel=^G, cbt=\E[Z, civis=\E[?25l, clear=\E[H\E[J$<200>,
+	cnorm=\E[34h\E[?25h, cr=\r, cub=\E[%p1%dD$<1>,
 	cub1=\010$<1>, cud=\E[%p1%dB, cud1=\ED,
 	cuf=\E[%p1%dC$<1>, cuf1=\E[C$<1>,
 	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\EM,
-	cvvis=\E[34l\E[?25h, dim=\E[2m, dl=\E[%p1%dM, dl1=\E[M,
-	ech=\E[%p1%dX, ed=\E[J$<8*>, el=\E[K$<1>, el1=\E[1K$<1>,
-	enacs=\E)0, flash=\E[?5h$<30/>\E[?5l, home=\E[H,
-	hpa=\E[%i%p1%dG, ht=^I, ich=\E[%p1%d@, il=\E[%p1%dL,
-	il1=\E[L, ind=\n$<1>, invis=\E[8m,
+	cvvis=\E[34l\E[?25h, dim=\E[2m, ech=\E[%p1%dX,
+	ed=\E[J$<8*>, el=\E[K$<1>, el1=\E[1K$<1>, enacs=\E)0,
+	flash=\E[?5h$<30/>\E[?5l, home=\E[H, hpa=\E[%i%p1%dG,
+	ht=^I, ich=\E[%p1%d@, ind=\n$<1>,
 	is2=\E7\E[1r\E8\E[2;3;4;13;20;34;39;36l\E[12;16;34h\E[?1;3;4
 	    ;5;10;18l\E[?7;8;25h\E>\E[?5W\E(B\017\E[4i,
 	kbs=^H, kcbt=\E[z, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC,
@@ -12041,21 +12653,20 @@ wy99-ansi|Wyse WY-99GT in ansi mode (int'l PC keyboard),
 	kf20=\E[33~, kf21=\E[34~, kf22=\E[35~, kf23=\E[1~,
 	kf24=\E[2~, kf3=\EOR, kf4=\EOS, kf5=\E[M, kf6=\E[17~,
 	kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, ll=\E[24E, mc0=\E[?19h,
-	mc4=\E[4i, mc5=\E[5i, nel=\EE, prot=\E[1"q, rc=\E8,
-	rev=\E[7m, ri=\EM, rmacs=^O, rmam=\E[?7l, rmir=\E[4l,
-	rmkx=\E[?1l, rmso=\E[27m, rmul=\E[24m,
+	nel=\EE, prot=\E[1"q, ri=\EM, rmacs=^O, rmam=\E[?7l,
+	rmir=\E[4l, rmkx=\E[?1l, rmso=\E[27m, rmul=\E[24m,
 	rs2=\E[61"p\E[40h\E[?6l\E[1r\E[2;3;4;13;20;34;39;36l\E[12;16
 	    ;34h\E[?1;3;4;5;10;18l\E[?7;8;25h\E>\E[?5W\E(B\017\E[24E
 	    \E[4i,
-	sc=\E7,
 	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%O%t;7%;%?%p4%t;5%;%?
 	    %p5%t;2%;%?%p7%t;8%;m\E[%?%p8%t1%;"q%?%p9%t\016%e\017%;,
 	sgr0=\E[m\017\E["q, smacs=^N, smam=\E[?7h, smir=\E[4h,
-	smkx=\E[?1h, smso=\E[7m, smul=\E[4m, vpa=\E[%i%p1%dd,
+	smkx=\E[?1h, vpa=\E[%i%p1%dd, use=ansi+csr, use=ansi+idl,
+	use=ansi+pp, use=ansi+sgrbold,
 
 #   This is the american terminal. Here tabs work fine.
 # From: Francesco Potorti` <F.Potorti@cnuce.cnr.it>, 24 Aug 1998
-wy99a-ansi|Wyse WY-99GT in ansi mode (US PC keyboard),
+wy99a-ansi|Wyse WY-99GT in ANSI mode (US PC keyboard),
 	hts=\EH, is3=\E[?5l, rs3=\E[?5l, tbc=\E[3g, use=wy99-ansi,
 
 # This terminal (firmware version 02) has a lot of bugs:
@@ -12068,19 +12679,19 @@ wy99a-ansi|Wyse WY-99GT in ansi mode (US PC keyboard),
 # DTR handshaking, you can use even greater speeds.
 # From: Francesco Potorti` <F.Potorti@cnuce.cnr.it>, 24 Aug 1998
 wy99f|wy99fgt|wy-99fgt|Wyse WY-99GT (int'l PC keyboard),
-	am, bw, hs, km, mc5i, mir, msgr, xon,
-	cols#80, it#8, lines#25, wsl#46,
+	am, bw, km, mc5i, mir, msgr, xon,
+	cols#80, it#8, lines#25,
 	acsc='x+y.w_vi~j(k'l&m%n)o9q*s8t-u.v\,w+x=, bel=^G,
 	blink=\EG2, cbt=\EI, civis=\E`0, clear=\E'\E(\032,
 	cnorm=\E`4\E`1, cr=\r, cub1=^H, cud1=\Ej, cuf1=^L,
 	cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K,
-	cvvis=\E`2\E`1, dch1=\EW, dim=\EGp, dl1=\ER, dsl=\EF\r,
-	ed=\EY$<8*>, el=\ET$<8>, enacs=\Ec@1J$<2000>,
-	flash=\E\^1$<30/>\E\^0, fsl=\r, home=^^, ht=^I, il1=\EE,
-	ind=\n, invis=\EG3,
+	cvvis=\E`2\E`1, dch1=\EW, dim=\EGp, dl1=\ER, ed=\EY$<8*>,
+	el=\ET$<8>, enacs=\Ec@1J$<2000>,
+	flash=\E\^1$<30/>\E\^0, home=^^, ht=^I, il1=\EE, ind=\n,
+	invis=\EG3,
 	is2=\Eu\Ee6\EC\EDF\Ec21\Ec31\Ec62\Ec72\Ee;\016\E'\EeL\E`9\E
-	    \^0\E`1\E`4\Ee.\E`\:\Ee1\EG0\E(\Ed/\Ee4\Ed*\EO\E`I\Er
-	    \Ee"\EcD\024,
+	    \^0\E`1\E`4\Ee.\E`:\Ee1\EG0\E(\Ed/\Ee4\Ed*\EO\E`I\Er\Ee"
+	    \EcD\024,
 	ka1=^^, ka3=\EJ, kbs=^H, kc1=\ET, kc3=\EK, kcbt=\EI, kcub1=^H,
 	kcud1=\n, kcuf1=^L, kcuu1=^K, kf1=^A@\r, kf10=^AI\r,
 	kf11=^AJ\r, kf12=^AK\r, kf13=^A`\r, kf14=^Aa\r, kf15=^Ab\r,
@@ -12091,13 +12702,13 @@ wy99f|wy99fgt|wy-99fgt|Wyse WY-99GT (int'l PC keyboard),
 	nel=^_, prot=\E), rev=\EG4, ri=\Ej, rmacs=\EcD, rmam=\Ed.,
 	rmcup=\Ec21\Ec31, rmir=\Er, rmso=\EG0, rmxon=\Ec20\Ec30,
 	rs2=\Eu\E~4\Ee6\EC\EDF\Ec21\Ec31\Ec62\Ec72\Ee;\016\E'\EeL\E`
-	    9\E\^0\E`1\E`4\Ee.\E`\:\Ee)\Ew\EwG\Ew0\Ee1\EG0\E(\Ed/
+	    9\E\^0\E`1\E`4\Ee.\E`:\Ee)\Ew\EwG\Ew0\Ee1\EG0\E(\Ed/
 	    \Ee4\Ed*\EO\E`I\Er\Ee"\Ec@0B\EcD\024,
 	sgr=\E(\EG%{48}%?%p1%p3%O%t%{4}%+%;%?%p2%t%{8}%+%;%?%p4%t
 	    %{2}%+%;%?%p5%t%{64}%+%;%?%p7%t%{1}%+%;%c%?%p8%t\E)%;%?
 	    %p9%t\EcE%e\EcD%;,
 	sgr0=\E(\EG0, smacs=\EcE, smam=\Ed/, smcup=\Ec20\Ec30,
-	smir=\Eq, smso=\EG4, smxon=\Ec21\Ec31, tsl=\EF,
+	smir=\Eq, smso=\EG4, smxon=\Ec21\Ec31, use=wyse+sl,
 
 # This is the american terminal. Here tabs work.
 # From: Francesco Potorti` <F.Potorti@cnuce.cnr.it>, 24 Aug 1998
@@ -12126,15 +12737,15 @@ wy99fa|wy99fgta|wy-99fgta|Wyse WY-99GT (US PC keyboard),
 # (wy160: we use \E{ rather than ^^ for home (both are documented) to avoid
 # a bug reported by Robert Dunn, <rcdii@inlink.com> -- esr)
 wy160|wyse160|Wyse 160,
-	am, bw, hs, km, mc5i, mir, msgr,
+	am, bw, km, mc5i, mir, msgr,
 	cols#80, lh#1, lines#24, lw#8, nlab#8, wsl#38,
 	acsc=+/\,.0[a2fxgqh1ihjYk?lZm@nEqDtCu4vAwBx3yszr{c~~,
 	bel=^G, blink=\EG2, cbt=\EI, civis=\E`0, clear=\E+$<30>,
 	cnorm=\E`1, cr=\r, cub1=^H, cud1=\n, cuf1=^L,
 	cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K, dch1=\EW$<5>,
-	dclk=\E`b, dim=\EGp, dl1=\ER$<1>, dsl=\EF\r, ed=\EY$<30>,
-	el=\ET$<5>, flash=\E`8$<100/>\E`9, fsl=\r, home=\E{, ht=^I,
-	hts=\E1, il1=\EE$<1>, ind=\n$<1>, ip=$<2>, is1=\EcB0\EcC1,
+	dclk=\E`b, dim=\EGp, dl1=\ER$<1>, ed=\EY$<30>, el=\ET$<5>,
+	flash=\E`8$<100/>\E`9, home=\E{, ht=^I, hts=\E1,
+	il1=\EE$<1>, ind=\n$<1>, ip=$<2>, is1=\EcB0\EcC1,
 	is2=\Ed$\EcD\E'\Er\EH\003\Ed/\EO\Ee1\Ed*\E`@\E`9\E`1\016
 	    \024\El,
 	is3=\Ew0$<100>, kHOM=\E{, kbs=^H, kcbt=\EI, kcub1=^H,
@@ -12150,40 +12761,40 @@ wy160|wyse160|Wyse 160,
 	pln=\Ez%p1%{47}%+%c%p2%s\r, prot=\E), ri=\Ej$<1>,
 	rmacs=\EcD, rmam=\Ed., rmclk=\E`c, rmcup=\Ew0, rmir=\Er,
 	rmln=\EA11, rmxon=\Ec20, rs1=\E~!\E~4$<70>,
-	rs2=\E`\:$<100>, rs3=\EwG\Ee($<140>,
+	rs2=\E`:$<100>, rs3=\EwG\Ee($<140>,
 	sgr=%?%p8%t\E)%e\E(%;%?%p9%t\EcE%e\EcD%;\EG%{48}%?%p2%t%{8}
 	    %|%;%?%p1%p3%|%p6%|%t%{4}%|%;%?%p4%t%{2}%|%;%?%p1%p5%|%t
 	    %{64}%|%;%?%p7%t%{1}%|%;%c,
 	sgr0=\E(\EH\003\EG0\EcD, smacs=\EcE, smam=\Ed/,
 	smcup=\Ew1, smir=\Eq, smln=\EA10, smso=\EGt, smxon=\Ec21,
-	tbc=\E0, tsl=\EF, use=adm+sgr,
+	tbc=\E0, use=adm+sgr, use=wyse+sl,
 #
-wy160-w|wyse160-w|wyse 160 132-column,
+wy160-w|wyse160-w|Wyse 160 132-column,
 	cols#132, lw#7, nlab#16, wsl#90,
 	cup=\Ea%i%p1%dR%p2%dC, dch1=\EW$<9>,
 	rs2=\EeF$<150>\E`;$<150>, use=wy160,
 #
-wy160-25|wyse160-25|wyse 160 80-column 25-lines,
+wy160-25|wyse160-25|Wyse 160 80-column 25-lines,
 	lh@, lines#25, lw@, nlab@,
 	pln@, rs3=\EwG\Ee)$<200>, use=wy160,
-wy160-25-w|wyse160-25-w|wyse 160 132-column 25-lines,
+wy160-25-w|wyse160-25-w|Wyse 160 132-column 25-lines,
 	lh@, lines#25, lw@, nlab@,
 	pln@, rs3=\EwG\Ee)$<200>, use=wy160-w,
 #
-wy160-42|wyse160-42|wyse 160 80-column 42-lines,
+wy160-42|wyse160-42|Wyse 160 80-column 42-lines,
 	lines#42,
 	clear=\E+$<50>, dl1=\ER$<2>, ed=\Ey$<50>, il1=\EE$<2>,
 	ind=\n$<2>, is1=\EcB2\EcC3, nel=\r\n$<2>, ri=\Ej$<2>,
 	rs3=\Ee*$<150>, use=wy160,
-wy160-42-w|wyse160-42-w|wyse 160 132-column 42-lines,
+wy160-42-w|wyse160-42-w|Wyse 160 132-column 42-lines,
 	cols#132, lw#7, nlab#16, wsl#90,
 	cup=\Ea%i%p1%dR%p2%dC, dch1=\EW$<8>, ip=$<3>,
 	rs2=\EeF$<150>\E`;$<150>, use=wy160-42,
 #
-wy160-43|wyse160-43|wyse 160 80-column 43-lines,
+wy160-43|wyse160-43|Wyse 160 80-column 43-lines,
 	lh@, lines#43, lw@, nlab@,
 	pln@, rs3=\Ee+$<150>, use=wy160-42,
-wy160-43-w|wyse160-43-w|wyse 160 132-column 43-lines,
+wy160-43-w|wyse160-43-w|Wyse 160 132-column 43-lines,
 	lh@, lines#43, lw@, nlab@,
 	pln@, rs3=\Ee+$<150>, use=wy160-42-w,
 #
@@ -12192,7 +12803,7 @@ wy160-vb|wyse160-vb|Wyse 160 visible bell,
 wy160-w-vb|wy160-wvb|wyse160-wvb|Wyse 160 132-column visible bell,
 	bel@, use=wy160-w,
 #
-#	The Wyse 75 is a vt100 lookalike without advanced video.
+#	The Wyse 75 is a VT100 lookalike without advanced video.
 #
 #	   The Wyse 75 can support one attribute (e.g. Dim, Inverse,
 #	Underline) without magic cookies.  The following description
@@ -12203,47 +12814,44 @@ wy160-w-vb|wy160-wvb|wyse160-wvb|Wyse 160 132-column visible bell,
 #	cookies.  The wy75-mc terminal description uses magic cookies
 #	to correctly handle multiple attributes on a screen.
 #
-wy75|wyse75|wyse 75,
-	am, hs, mc5i, mir, msgr, xenl, xon,
+wy75|wyse75|Wyse 75,
+	am, hs, mir, msgr, xenl, xon,
 	cols#80, lines#24, ma#1, pb#1201, wsl#78,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, cbt=\E[Z, clear=\E[H\E[J$<30>, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr$<2>, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP$<3*>, dch1=\E[P$<3>, dim=\E[0t\E[2m,
-	dl=\E[%p1%dM$<1*>, dl1=\E[M,
-	dsl=\E[>\,\001\001\E[>-\001\001, ech=\E[%p1%dX,
-	ed=\E[J$<30>, el=\E[K$<3>, el1=\E[1K$<3>, enacs=\E)0,
-	flash=\E[30h\E\,$<250/>\E[30l, fsl=^A, home=\E[H,
-	hpa=\E[%i%p1%dG, ht=^I, hts=\EH, ich=\E[%p1%d@$<1*>,
+	bel=^G, clear=\E[H\E[J$<30>, cr=\r,
+	csr=\E[%i%p1%d;%p2%dr$<2>, cub1=^H, cud1=\n,
+	cup=\E[%i%p1%d;%p2%dH, dch=\E[%p1%dP$<3*>,
+	dch1=\E[P$<3>, dim=\E[0t\E[2m, dl=\E[%p1%dM$<1*>,
+	dl1=\E[M, dsl=\E[>\,\001\001\E[>-\001\001,
+	ech=\E[%p1%dX, ed=\E[J$<30>, el=\E[K$<3>, el1=\E[1K$<3>,
+	enacs=\E)0, flash=\E[30h\E\,$<250/>\E[30l, fsl=^A,
+	home=\E[H, hpa=\E[%i%p1%dG, ich=\E[%p1%d@$<1*>,
 	il=\E[%p1%dL$<2*>, il1=\E[L$<2>, ind=\n$<2>, ip=$<1>,
 	is1=\E[2;4;20;30l\E[?1;10l\E[12h\E[?7;8;25h,
-	is2=\E>\E(B\E)0\017, is3=\E[m, kbs=^H, kcub1=\E[D,
-	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kdl1=\E[M, kel=\E[K,
+	is2=\E>\E(B\E)0\017, is3=\E[m, kdl1=\E[M, kel=\E[K,
 	kf1=\E[?5i, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~,
 	kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, kf16=\E[29~,
 	kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, kf2=\E[?3i,
 	kf20=\E[34~, kf21=\E[35~, kf3=\E[2i, kf4=\E[@, kf5=\E[M,
 	kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, kfnd=\E[1~,
-	khlp=\E[28~, khome=\E[H, kich1=\E[@, kil1=\E[L, knp=\E[6~,
-	kpp=\E[5~, kprt=\E[?5i, kslt=\E[4~, mc0=\E[0i, mc4=\E[4i,
-	mc5=\E[5i, rc=\E8, rev=\E[1t\E[7m, ri=\EM$<2>, rmacs=^O,
-	rmam=\E[?7l, rmir=\E[4l, rmkx=\E>, rmso=\E[m, rmul=\E[m,
-	rs1=\E[13l\E[3l\E!p, rs2=\E[35h\E[?3l$<80>, rs3=\E[?5l,
-	sc=\E7,
+	khlp=\E[28~, kich1=\E[@, kil1=\E[L, knp=\E[6~, kpp=\E[5~,
+	kprt=\E[?5i, kslt=\E[4~, mc0=\E[0i, rc=\E8, rev=\E[1t\E[7m,
+	ri=\EM$<2>, rmacs=^O, rmam=\E[?7l, rmir=\E[4l, rmkx=\E>,
+	rmso=\E[m, rmul=\E[m, rs1=\E[13l\E[3l\E!p,
+	rs2=\E[35h\E[?3l$<80>, rs3=\E[?5l, sc=\E7,
 	sgr=%?%p5%t\E[0t%;%?%p3%p1%|%t\E[1t%;%?%p2%t\E[2t%;%?%p4%t
 	    \E[3t%;%?%p1%p2%p3%p4%p5%|%|%|%|%t\E[7m%e\E[m%;%?%p9%t
 	    \016%e\017%;,
 	sgr0=\E[m\017, smacs=^N, smam=\E[?7h, smir=\E[4h,
 	smkx=\E[?1l\E[?7h\E=, smso=\E[1t\E[7m, smul=\E[2t\E[4m,
-	tbc=\E[3g, tsl=\E[>\,\001, use=vt220+cvis,
-	use=vt220+keypad,
+	tsl=\E[>\,\001, use=ansi+arrows, use=ansi+local,
+	use=ansi+pp, use=ansi+tabs, use=decid+cpr,
+	use=vt220+cvis, use=vt220+keypad,
 #
 #	This terminal description uses the non-hidden attribute mode
 #	(with magic cookie).
 #
-wy75-mc|wyse75-mc|wyse 75 with magic cookies,
+wy75-mc|wyse75-mc|Wyse 75 with magic cookies,
 	msgr@,
 	ma@, xmc#1,
 	blink=\E[2p, dim=\E[1p, invis=\E[4p, is3=\E[m\E[p,
@@ -12253,20 +12861,20 @@ wy75-mc|wyse75-mc|wyse 75 with magic cookies,
 	    %t\016%e\017%;,
 	sgr0=\E[0p\017, smacs=\E[0p\016, smso=\E[17p, smul=\E[8p,
 	use=wy75,
-wy75-vb|wyse75-vb|wyse 75 with visible bell,
+wy75-vb|wyse75-vb|Wyse 75 with visible bell,
 	pb@,
 	bel@, use=wy75,
-wy75-w|wyse75-w|wyse 75 in 132 column mode,
+wy75-w|wyse75-w|Wyse 75 in 132 column mode,
 	cols#132, wsl#130,
 	rs2=\E[35h\E[?3h$<80>, use=wy75,
-wy75-wvb|wyse75-wvb|wyse 75 with visible bell 132 columns,
+wy75-wvb|wyse75-wvb|Wyse 75 with visible bell 132 columns,
 	pb@,
 	bel@, use=wy75-w,
 #
-#	Wyse 85 emulating a vt220 7 bit mode.
+#	Wyse 85 emulating a VT220 7 bit mode.
 #		24 line screen with status line.
 #
-#	The vt220 mode permits more function keys but it wipes out
+#	The VT220 mode permits more function keys but it wipes out
 #	the escape key.  I strongly recommend that <f11> be set to
 #	escape (esc).
 #	The terminal may have to be set for 8 data bits and 2 stop
@@ -12275,51 +12883,46 @@ wy75-wvb|wyse75-wvb|wyse 75 with visible bell 132 columns,
 #	<dch> and <ich> work best when XON/XOFF is set.  <ich> and
 #	<dch> leave trash on the screen when used without XON/XOFF.
 #
-wy85|wyse85|wyse 85,
-	am, hs, mc5i, mir, msgr, xenl, xon,
-	cols#80, it#8, lines#24, wsl#80,
-	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z,
-	clear=\E[H\E[J$<110>, cr=\r, csr=\E[%i%p1%d;%p2%dr,
-	cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\n,
-	cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH$<1>,
-	cuu=\E[%p1%dA, cuu1=\E[A, dch=\E[%p1%dP$<3*>,
+wy85|wyse85|Wyse 85,
+	hs, mir, xenl, xon,
+	wsl#80,
+	clear=\E[H\E[J$<110>, cub1=^H, cud1=\n,
+	cup=\E[%i%p1%d;%p2%dH$<1>, dch=\E[%p1%dP$<3*>,
 	dch1=\E[P$<3>, dim=\E[2m, dl=\E[%p1%dM$<3*>,
 	dl1=\E[M$<3>, dsl=\E[40l, ech=\E[%p1%dX, ed=\E[J$<110>,
 	el=\E[K$<1>, el1=\E[1K, enacs=\E)0,
 	flash=\E[30h\E\,$<300/>\E[30l, fsl=\E[1;24r\E8,
-	home=\E[H, ht=\011$<1>, hts=\EH, ich=\E[%p1%d@$<4*>,
-	il=\E[%p1%dL$<5*>, il1=\E[L$<5>, ind=\n$<3>, invis=\E[8m,
-	ip=$<3>, is1=\E[62;1"p\E[?5W,
+	ht=\011$<1>, ich=\E[%p1%d@$<4*>, il=\E[%p1%dL$<5*>,
+	il1=\E[L$<5>, ind=\n$<3>, ip=$<3>, is1=\E[62;1"p\E[?5W,
 	is2=\E[2;4;20;30l\E[?1;4;10;16l\E[12h\E[?7;8;25h$<16>,
-	is3=\E>\E(B\E)0\017\E[m, kbs=^H, kcub1=\E[D, kcud1=\E[B,
-	kcuf1=\E[C, kcuu1=\E[A, kf10=\E[21~, kf11=\E[23~,
+	is3=\E>\E(B\E)0\017\E[m, kf10=\E[21~, kf11=\E[23~,
 	kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, kf15=\E[28~,
 	kf16=\E[29~, kf17=\E[31~, kf18=\E[32~, kf19=\E[33~,
 	kf20=\E[34~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~,
 	kf9=\E[20~, khlp=\E[28~, khome=\E[26~, lf1=PF1, lf2=PF2,
-	lf3=PF3, lf4=PF4, mc0=\E[0i, mc4=\E[4i, mc5=\E[5i, rc=\E8,
-	rev=\E[7m, ri=\EM$<3>, rmacs=^O, rmam=\E[?7l, rmir=\E[4l,
-	rmkx=\E>, rmso=\E[m, rmul=\E[m, rs1=\E[13l\E[3l\E!p,
-	rs2=\E[35h\E[?3l$<70>, rs3=\E[?5l, sc=\E7,
+	lf3=PF3, lf4=PF4, mc0=\E[0i, ri=\EM$<3>, rmam=\E[?7l,
+	rmir=\E[4l, rmkx=\E>, rs1=\E[13l\E[3l\E!p,
+	rs2=\E[35h\E[?3l$<70>, rs3=\E[?5l,
 	sgr=\E[0%?%p2%t;4%;%?%p3%p1%|%t;7%;%?%p4%t;5%;%?%p5%t;2%;%?
 	    %p6%t;1%;%?%p7%t;8%;m%?%p9%t\016%e\017%;,
-	sgr0=\E[m\017, smacs=^N, smam=\E[?7h, smir=\E[4h,
-	smkx=\E[?1l\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g,
-	tsl=\E[40h\E7\E[25;%i%p1%dH, use=vt220+vtedit,
-	use=vt220+cvis, use=vt220+keypad,
+	sgr0=\E[m\017, smam=\E[?7h, smir=\E[4h, smkx=\E[?1l\E=,
+	tsl=\E[40h\E7\E[25;%i%p1%dH, use=ansi+arrows,
+	use=ansi+csr, use=ansi+inittabs, use=ansi+local,
+	use=ansi+pp, use=ansi+sgrbold, use=decid+cpr,
+	use=vt100+4bsd, use=vt220+vtedit, use=vt220+cvis,
+	use=vt220+keypad,
 #
 #	Wyse 85 with visual bell.
-wy85-vb|wyse85-vb|wyse 85 with visible bell,
+wy85-vb|wyse85-vb|Wyse 85 with visible bell,
 	bel@, flash=\E[30h\E\,$<300/>\E[30l, use=wy85,
 #
 #	Wyse 85 in 132-column mode.
-wy85-w|wyse85-w|wyse 85 in 132-column mode,
+wy85-w|wyse85-w|Wyse 85 in 132-column mode,
 	cols#132, wsl#132,
 	rs2=\E[35h$<70/>\E[?3h, use=wy85,
 #
 #	Wyse 85 in 132-column mode with visual bell.
-wy85-wvb|wyse85-wvb|wyse 85 with visible bell 132-columns,
+wy85-wvb|wyse85-wvb|Wyse 85 with visible bell 132-columns,
 	bel@, use=wy85-w,
 
 # From: Kevin Turner <kevint@aracnet.com>, 12 Jul 1998
@@ -12332,44 +12935,38 @@ wy85-wvb|wyse85-wvb|wyse 85 with visible bell 132-columns,
 # Technical" isn't responding.  So there's the question of whether the wy85
 # terminfo should reflect the manufacturer's intended behaviour of the terminal
 # or the actual."
-wy85-8bit|wyse85-8bit|wyse 85 in 8-bit mode,
-	am, hs, mc5i, mir, msgr, xenl, xon,
-	cols#80, it#8, lines#24, wsl#80,
-	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z,
-	clear=\E[H\E[J$<110>, cr=\r, csr=\E[%i%p1%d;%p2%dr,
-	cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\n,
-	cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH$<1>,
-	cuu=\E[%p1%dA, cuu1=\E[A, dch=\E[%p1%dP$<3*>,
+wy85-8bit|wyse85-8bit|Wyse 85 in 8-bit mode,
+	hs, mir, xenl, xon,
+	wsl#80,
+	clear=\E[H\E[J$<110>, cub1=^H, cud1=\n,
+	cup=\E[%i%p1%d;%p2%dH$<1>, dch=\E[%p1%dP$<3*>,
 	dch1=\E[P$<3>, dim=\E[2m, dl=\E[%p1%dM$<3*>,
 	dl1=\E[M$<3>, dsl=\E[40l, ech=\E[%p1%dX, ed=\E[J$<110>,
 	el=\E[K$<1>, el1=\E[1K, enacs=\E)0,
 	flash=\E[30h\E\,$<300/>\E[30l, fsl=\E[1;24r\E8,
-	home=\E[H, ht=\011$<1>, hts=\EH, ich=\E[%p1%d@$<4*>,
-	il=\E[%p1%dL$<5*>, il1=\E[L$<5>, ind=\n$<3>, invis=\E[8m,
-	ip=$<3>, is1=\E[62;1"p\E[?5W,
+	ht=\011$<1>, ich=\E[%p1%d@$<4*>, il=\E[%p1%dL$<5*>,
+	il1=\E[L$<5>, ind=\n$<3>, ip=$<3>, is1=\E[62;1"p\E[?5W,
 	is2=\E[2;4;20;30l\E[?1;4;10;16l\E[12h\E[?7;8;25h$<16>,
 	is3=\E>\E(B\E)0\017\E[m, ka1=\EOw, ka3=\EOy, kb2=\EOu,
-	kbs=^H, kc1=\EOq, kc3=\EOs, kcub1=\233D, kcud1=\233B,
-	kcuf1=\233C, kcuu1=\233A, kdch1=\2333~, kent=\EOM,
-	kf1=\EOP, kf10=\23321~, kf11=\23323~, kf12=\23324~,
-	kf13=\23325~, kf14=\23326~, kf15=\23328~, kf16=\23329~,
-	kf17=\23331~, kf18=\23332~, kf19=\23333~, kf2=\EOQ,
-	kf20=\23334~, kf3=\EOR, kf4=\EOS, kf6=\23317~, kf7=\23318~,
-	kf8=\23319~, kf9=\23320~, kfnd=\2331~, khlp=\23328~,
-	khome=\23326~, kich1=\2332~, knp=\2336~, kpp=\2335~,
-	kslt=\2334~, lf1=PF1, lf2=PF2, lf3=PF3, lf4=PF4, mc0=\E[0i,
-	mc4=\E[4i, mc5=\E[5i, rc=\E8, rev=\E[7m, ri=\EM$<3>,
-	rmacs=^O, rmam=\E[?7l, rmir=\E[4l, rmkx=\E>, rmso=\E[m,
-	rmul=\E[m, rs1=\E[13l\E[3l\E!p, rs2=\E[35h\E[?3l$<70>,
-	rs3=\E[?5l, sc=\E7,
+	kc1=\EOq, kc3=\EOs, kcub1=\233D, kcud1=\233B, kcuf1=\233C,
+	kcuu1=\233A, kdch1=\2333~, kf10=\23321~, kf11=\23323~,
+	kf12=\23324~, kf13=\23325~, kf14=\23326~, kf15=\23328~,
+	kf16=\23329~, kf17=\23331~, kf18=\23332~, kf19=\23333~,
+	kf20=\23334~, kf6=\23317~, kf7=\23318~, kf8=\23319~,
+	kf9=\23320~, kfnd=\2331~, khlp=\23328~, khome=\23326~,
+	kich1=\2332~, knp=\2336~, kpp=\2335~, kslt=\2334~, lf1=PF1,
+	lf2=PF2, lf3=PF3, lf4=PF4, mc0=\E[0i, ri=\EM$<3>,
+	rmam=\E[?7l, rmir=\E[4l, rmkx=\E>, rs1=\E[13l\E[3l\E!p,
+	rs2=\E[35h\E[?3l$<70>, rs3=\E[?5l,
 	sgr=\E[0%?%p2%t;4%;%?%p3%p1%|%t;7%;%?%p4%t;5%;%?%p5%t;2%;%?
 	    %p6%t;1%;%?%p7%t;8%;+m%?%p9%t\016%e\017%;,
-	sgr0=\E[m\017, smacs=^N, smam=\E[?7h, smir=\E[4h,
-	smkx=\E[?1l\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g,
-	tsl=\E[40h\E7\E[25;%i%p1%dH, use=vt220+cvis,
+	sgr0=\E[m\017, smam=\E[?7h, smir=\E[4h, smkx=\E[?1l\E=,
+	tsl=\E[40h\E7\E[25;%i%p1%dH, use=ansi+csr,
+	use=ansi+inittabs, use=ansi+local, use=ansi+pp,
+	use=ansi+sgrbold, use=decid+cpr, use=vt100+4bsd,
+	use=vt100+pfkeys, use=vt220+cvis,
 #
-#	Wyse 185 emulating a vt320 7 bit mode.
+#	Wyse 185 emulating a VT320 7 bit mode.
 #
 #	This terminal always displays 25 lines.  These lines may be used
 #	as 24 data lines and a terminal status line (top or bottom) or
@@ -12379,61 +12976,56 @@ wy85-8bit|wyse85-8bit|wyse 85 in 8-bit mode,
 #	The Compose Character key can be used as a meta key if changed
 #	by set-up.
 #
-wy185|wyse185|wyse 185,
-	am, hs, km, mc5i, mir, msgr, xenl, xon,
-	cols#80, it#8, lines#24, wsl#80,
-	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[?25l,
-	clear=\E[H\E[J$<40>, cnorm=\E[34h\E[?25h, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr$<20>, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
+wy185|wyse185|Wyse 185,
+	hs, km, mir, xenl, xon,
+	wsl#80,
+	civis=\E[?25l, clear=\E[H\E[J$<40>,
+	cnorm=\E[34h\E[?25h, csr=\E[%i%p1%d;%p2%dr$<20>,
+	cub1=^H, cud1=\n, cup=\E[%i%p1%d;%p2%dH,
 	cvvis=\E[?25h\E[34l, dch=\E[%p1%dP$<3>, dch1=\E[P$<3>,
 	dim=\E[2m, dl=\E[%p1%dM$<2*>, dl1=\E[M$<2>,
 	dsl=\E7\E[99;0H\E[K\E8, ech=\E[%p1%dX, ed=\E[J$<40>,
 	el=\E[K, el1=\E[1K, enacs=\E)0,
 	flash=\E[30h\E\,$<100/>\E[30l, fsl=\E[1;24r\E8,
-	home=\E[H, hpa=\E[%i%p1%d`, ht=^I, hts=\EH,
-	ich=\E[%p1%d@$<2>, il=\E[%p1%dL$<3*>, il1=\E[L$<3>,
-	ind=\n$<2>, invis=\E[8m, ip=$<4>, is1=\E[?5W,
-	is2=\E[2;4;20;30l\E[?1;4;10;16l\E[12h\E[?7;8;25h,
-	is3=\E>\E(B\E)0\017\E[m, kbs=^H, kcbt=\E[Z, kcub1=\E[D,
-	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kf1=\EOP, kf10=\E[21~,
-	kf11=\E[23~, kf12=\E[24~, kf13=\E[25~, kf14=\E[26~,
-	kf15=\E[28~, kf16=\E[29~, kf17=\E[31~, kf18=\E[32~,
-	kf19=\E[33~, kf2=\EOQ, kf20=\E[34~, kf3=\EOR, kf4=\EOS,
-	kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~,
-	khlp=\E[28~, khome=\E[26~, lf1=PF1, lf2=PF2, lf3=PF3,
-	lf4=PF4, mc0=\E[0i, mc4=\E[4i, mc5=\E[5i, rc=\E8, rev=\E[7m,
-	ri=\EM$<2>, rmacs=^O, rmam=\E[?7l, rmcup=\E[ R, rmir=\E[4l,
-	rmkx=\E>, rmso=\E[27m, rmul=\E[24m,
+	hpa=\E[%i%p1%d`, ich=\E[%p1%d@$<2>, il=\E[%p1%dL$<3*>,
+	il1=\E[L$<3>, ind=\n$<2>, ip=$<4>, is1=\E[?5W,
+	is2=\E[2;4;20;30l\E[?1;4;10;16l\E[12h\E[?7;8;25h,
+	is3=\E>\E(B\E)0\017\E[m, kcbt=\E[Z, kf10=\E[21~,
+	kf11=\E[23~, kf12=\E[24~, kf13=\E[25~, kf14=\E[26~,
+	kf15=\E[28~, kf16=\E[29~, kf17=\E[31~, kf18=\E[32~,
+	kf19=\E[33~, kf20=\E[34~, kf6=\E[17~, kf7=\E[18~,
+	kf8=\E[19~, kf9=\E[20~, khlp=\E[28~, khome=\E[26~, lf1=PF1,
+	lf2=PF2, lf3=PF3, lf4=PF4, mc0=\E[0i, rc=\E8, ri=\EM$<2>,
+	rmam=\E[?7l, rmcup=\E[ R, rmir=\E[4l, rmkx=\E>,
+	rmso=\E[27m, rmul=\E[24m,
 	rs1=\E[13l\E[3l\E\\\E[63;1"p\E[!p, rs2=\E[35h\E[?3l,
 	rs3=\E[?5l\E[47h\E[40l\E[r, sc=\E7,
 	sgr=\E[0%?%p2%t;4%;%?%p3%p1%|%t;7%;%?%p4%t;5%;%?%p5%t;2%;%?
 	    %p6%t;1%;%?%p7%t;8%;m%?%p9%t\016%e\017%;,
-	sgr0=\E[m\017, smacs=^N, smam=\E[?7h, smcup=\E[ Q,
-	smir=\E[4h, smkx=\E[?1l\E=, smso=\E[7m, smul=\E[4m,
-	tbc=\E[3g, tsl=\E7\E[99;%i%p1%dH, vpa=\E[%i%p1%dd,
-	use=vt220+vtedit, use=vt220+keypad,
+	sgr0=\E[m\017, smam=\E[?7h, smcup=\E[ Q, smir=\E[4h,
+	smkx=\E[?1l\E=, tsl=\E7\E[99;%i%p1%dH, vpa=\E[%i%p1%dd,
+	use=ansi+arrows, use=ansi+inittabs, use=ansi+local,
+	use=ansi+pp, use=ansi+sgrbold, use=decid+cpr,
+	use=vt100+4bsd, use=vt220+vtedit, use=vt220+keypad,
 #
 #	Wyse 185 with 24 data lines and top status (terminal status)
-wy185-24|wyse185-24|wyse 185 with 24 data lines,
+wy185-24|wyse185-24|Wyse 185 with 24 data lines,
 	hs@,
 	dsl@, fsl@, rs3=\E[?5l\E[47h\E[40l\E[1;24r, tsl@,
 	use=wy185,
 #
 #	Wyse 185 with visual bell.
-wy185-vb|wyse185-vb|wyse 185+flash,
+wy185-vb|wyse185-vb|Wyse 185+flash,
 	bel@, use=wy185,
 #
 #	Wyse 185 in 132-column mode.
-wy185-w|wyse185-w|wyse 185 in 132-column mode,
+wy185-w|wyse185-w|Wyse 185 in 132-column mode,
 	cols#132, wsl#132,
 	dch=\E[%p1%dP$<7>, dch1=\E[P$<7>, ich=\E[%p1%d@$<7>,
 	ip=$<7>, rs2=\E[35h\E[?3h, use=wy185,
 #
 #	Wyse 185 in 132-column mode with visual bell.
-wy185-wvb|wyse185-wvb|wyse 185+flash+132 cols,
+wy185-wvb|wyse185-wvb|Wyse 185+flash+132 cols,
 	bel@, use=wy185-w,
 
 # wy325 terminfo entries
@@ -12442,14 +13034,14 @@ wy185-wvb|wyse185-wvb|wyse 185+flash+132 cols,
 # lines 25  columns 80
 #
 wy325|wyse325|Wyse epc,
-	am, bw, hs, mc5i, mir,
-	cols#80, lh#1, lines#24, lw#8, nlab#8, pb#9601, wsl#45,
+	am, bw, mc5i, mir,
+	cols#80, lh#1, lines#24, lw#8, nlab#8, pb#9601,
 	acsc=+/\,.0[a2fxgqh1ihjYk?lZm@nEqDtCu4vAwBx3yszr{c~~,
 	bel=^G, blink=\EG2, cbt=\EI, civis=\E`0, clear=\E+$<50>,
 	cnorm=\E`1, cr=\r, cub1=^H, cud1=\n, cuf1=^L,
 	cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K, dch1=\EW$<7>,
-	dim=\EGp, dl1=\ER$<3>, dsl=\EF\r, ed=\EY$<50>, el=\ET$<4>,
-	flash=\E`8$<100/>\E`9, fsl=\r, home=^^, ht=^I, hts=\E1,
+	dim=\EGp, dl1=\ER$<3>, ed=\EY$<50>, el=\ET$<4>,
+	flash=\E`8$<100/>\E`9, home=^^, ht=^I, hts=\E1,
 	il1=\EE$<3>, ind=\n$<3>, ip=$<2>, is1=\EcB0\EcC1,
 	is2=\EcD\E'\Er\EH\003\Ed/\EO\Ee1\Ed*\E`@\E`9\E`1\016\024
 	    \El,
@@ -12465,79 +13057,79 @@ wy325|wyse325|Wyse epc,
 	pfx=\EZ1%p1%{63}%+%c%p2%s\177,
 	pln=\Ez%p1%{47}%+%c%p2%s\r, prot=\E), ri=\Ej$<2>,
 	rmacs=\EcD, rmam=\Ed., rmcup=\Ew0, rmir=\Er, rmln=\EA11,
-	rs1=\E~!\E~4$<30>, rs2=\EeF\E`\:$<70>,
+	rs1=\E~!\E~4$<30>, rs2=\EeF\E`:$<70>,
 	rs3=\EwG\Ee($<100>,
 	sgr=%?%p8%t\E)%e\E(%;%?%p9%t\EcE%e\EcD%;\EG%{48}%?%p2%t%{8}
 	    %|%;%?%p1%p3%|%p6%|%t%{4}%|%;%?%p4%t%{2}%|%;%?%p1%p5%|%t
 	    %{64}%|%;%?%p7%t%{1}%|%;%c,
 	sgr0=\E(\EH\003\EG0\EcD, smacs=\EcE, smam=\Ed/,
 	smcup=\Ew1, smir=\Eq, smln=\EA10, smso=\EGt, tbc=\E0,
-	tsl=\EF, use=adm+sgr,
+	use=adm+sgr, use=wyse+sl,
 
 #
 # lines 24  columns 80  vb
 #
-wy325-vb|wyse325-vb|wyse-325 with visual bell,
+wy325-vb|wyse325-vb|Wyse-325 with visual bell,
 	bel@, use=wy325,
 
 #
 # lines 24  columns 132
 #
-wy325-w|wyse325-w|wy325w-24|wyse-325 in wide mode,
+wy325-w|wyse325-w|wy325w-24|Wyse-325 in wide mode,
 	cols#132, lw#7, nlab#16, wsl#97,
 	cup=\Ea%i%p1%dR%p2%dC, dch1=\EW$<12>, ip=$<4>,
 	rs2=\E`;$<70>, use=wy325,
 #
 # lines 25  columns 80
 #
-wy325-25|wyse325-25|wy325-80|wyse-325|wyse-325 25 lines,
+wy325-25|wyse325-25|wy325-80|wyse-325|Wyse-325 25 lines,
 	lh@, lines#25, lw@, nlab@,
 	pln@, rs3=\EwG\Ee)$<100>, use=wy325,
 #
 # lines 25  columns 132
 #
-wy325-25w|wyse325-25w|wy325 132 columns,
+wy325-25w|wyse325-25w|Wyse-325 132 columns,
 	lh@, lines#25, lw@, nlab@,
 	pln@, rs3=\EwG\Ee)$<100>, use=wy325-w,
 #
 # lines 25  columns 132  vb
 #
-wy325-w-vb|wy325-wvb|wyse325-wvb|wyse-325 wide mode reverse video,
+wy325-w-vb|wy325-wvb|wyse325-wvb|Wyse-325 wide mode reverse video,
 	bel@, use=wy325-w,
 
 #
 # lines 42  columns 80
 #
-wy325-42|wyse325-42|wyse-325 42 lines,
+wy325-42|wyse325-42|Wyse-325 42 lines,
 	lh@, lines#42, lw@, nlab@,
 	pln@, rs3=\EwG\Ee)$<100>, use=wy325,
 #
 # lines 42  columns 132
 #
-wy325-42w|wyse325-42w|wyse-325 42 lines wide mode,
+wy325-42w|wyse325-42w|Wyse-325 42 lines wide mode,
 	lh@, lines#42, lw@, nlab@,
 	pln@, rs3=\EwG\Ee)$<100>, use=wy325-w,
 #
 # lines 42  columns 132  vb
 #
-wy325-42w-vb|wy325-42wvb|wyse-325 42 lines wide mode visual bell,
+wy325-42w-vb|wy325-42wvb|Wyse-325 42 lines wide mode visual bell,
 	bel@, use=wy325-w,
 #
 # lines 43  columns 80
 #
-wy325-43|wyse325-43|wyse-325 43 lines,
+wy325-43|wyse325-43|Wyse-325 43 lines,
 	lh@, lines#43, lw@, nlab@,
 	pln@, use=wy325,
 #
 # lines 43  columns 132
 #
-wy325-43w|wyse325-43w|wyse-325 43 lines wide mode,
+wy325-43w|wyse325-43w|Wyse-325 43 lines wide mode,
 	lh@, lines#43, lw@, nlab@,
 	pln@, rs3=\EwG\Ee)$<100>, use=wy325-w,
 #
 # lines 43  columns 132  vb
 #
-wy325-43w-vb|wy325-43wvb|wyse-325 43 lines wide mode visual bell,
+wy325-43w-vb|wy325-43wvb|Wyse-325 43 lines wide mode visual bell,
 	bel@, use=wy325-w,
 
 #	Wyse 370 -- 24 line screen with status line.
@@ -12558,21 +13150,19 @@ wy325-43w-vb|wy325-43wvb|wyse-325 43 lines wide mode visual bell,
 #	<u5> -> exit  Tek 4207 mode (goto native ANSI mode)
 #
 # Bug: The <op> capability resets attributes.
-wy370-nk|wyse 370 without function keys,
-	am, ccc, hs, mc5i, mir, msgr, xenl, xon,
-	colors#64, cols#80, it#8, lines#24, ncv#48, pairs#64, wsl#80,
+wy370-nk|Wyse 370 without function keys,
+	am, ccc, hs, mir, msgr, xenl, xon,
+	colors#64, cols#80, lines#24, ncv#48, pairs#64, wsl#80,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[?25l,
-	clear=\E[H\E[J$<40>, cnorm=\E[34h\E[?25h, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH$<1>, cuu=\E[%p1%dA, cuu1=\E[A,
-	cvvis=\E[?25h\E[34l, dch=\E[%p1%dP$<1*>, dch1=\E[P$<1>,
-	dclk=\E[31h, dim=\E[2m, dl=\E[%p1%dM$<2*>, dl1=\E[M$<2>,
-	dsl=\E[40l, ech=\E[%p1%dX$<.1*>, ed=\E[J$<40>,
-	el=\E[K$<10>, el1=\E[1K$<12>, enacs=\E)0,
+	bel=^G, civis=\E[?25l, clear=\E[H\E[J$<40>,
+	cnorm=\E[34h\E[?25h, cr=\r, cub1=^H, cud1=\n,
+	cup=\E[%i%p1%d;%p2%dH$<1>, cvvis=\E[?25h\E[34l,
+	dch=\E[%p1%dP$<1*>, dch1=\E[P$<1>, dclk=\E[31h,
+	dim=\E[2m, dl=\E[%p1%dM$<2*>, dl1=\E[M$<2>, dsl=\E[40l,
+	ech=\E[%p1%dX$<.1*>, ed=\E[J$<40>, el=\E[K$<10>,
+	el1=\E[1K$<12>, enacs=\E)0,
 	flash=\E[30h\E\,$<300/>\E[30l, fsl=\E[1;24r\E8,
-	home=\E[H, hpa=\E[%i%p1%d`, ht=\011$<1>, hts=\EH,
+	home=\E[H, hpa=\E[%i%p1%d`, ht=\011$<1>,
 	ich=\E[%p1%d@$<1*>, il=\E[%p1%dL$<2*>, il1=\E[L$<2>,
 	ind=\n$<2>,
 	initc=\E[66;%p1%d;%?%p2%{250}%<%t%{0}%e%p2%{500}%<%t%{16}%e
@@ -12580,57 +13170,56 @@ wy370-nk|wyse 370 without function keys,
 	      %{500}%<%t%{4}%e%p3%{750}%<%t%{8}%e%{12}%;%?%p4%{250}
 	      %<%t%{0}%e%p4%{500}%<%t%{1}%e%p4%{750}%<%t%{2}%e%{3}%;
 	      %{1}%+%+%+%dw,
-	invis=\E[8m, ip=$<1>, is1=\E[90;1"p\E[?5W$<6>,
+	ip=$<1>, is1=\E[90;1"p\E[?5W$<6>,
 	is2=\E[2;4;20;30;40l\E[?1;10;16l\E[12h\E[?7;8;25h,
-	is3=\E>\017\E)0\E(B\E[63;0w\E[m, mc0=\E[0i, mc4=\E[4i,
-	mc5=\E[5i,
+	is3=\E>\017\E)0\E(B\E[63;0w\E[m, mc0=\E[0i,
 	oc=\E[60w\E[63;0w\E[66;1;4w\E[66;2;13w\E[66;3;16w\E[66;4;49w
 	   \E[66;5;51w\E[66;6;61w\E[66;7;64w,
-	op=\E[m, rc=\E8, rev=\E[7m, ri=\EM$<2>, rmacs=^O,
-	rmam=\E[?7l, rmclk=\E[31l, rmcup=\E[ R, rmir=\E[4l,
-	rmkx=\E>, rmso=\E[27m, rmul=\E[24m,
-	rs1=\E[13l\E[3l\E!p\E[?4i, rs2=\E[35h\E[?3l$<8>,
-	rs3=\E[?5l, sc=\E7, setb=\E[62;%p1%dw, setf=\E[61;%p1%dw,
+	op=\E[m, ri=\EM$<2>, rmacs=^O, rmam=\E[?7l, rmclk=\E[31l,
+	rmcup=\E[ R, rmir=\E[4l, rmkx=\E>, rmso=\E[27m,
+	rmul=\E[24m, rs1=\E[13l\E[3l\E!p\E[?4i,
+	rs2=\E[35h\E[?3l$<8>, rs3=\E[?5l, setb=\E[62;%p1%dw,
+	setf=\E[61;%p1%dw,
 	sgr=\E[0%?%p2%t;4%;%?%p3%p1%|%t;7%;%?%p4%t;5%;%?%p5%t;2%;%?
 	    %p6%t;1%;%?%p7%t;8%;m%?%p9%t\016%e\017%;,
 	sgr0=\E[m\017, smacs=^N, smam=\E[?7h, smcup=\E[ Q,
-	smir=\E[4h, smkx=\E[?1l\E=, smso=\E[7m, smul=\E[4m,
-	tbc=\E[3g, tsl=\E[40l\E[40h\E7\E[99;%i%p1%dH,
-	u0=\E[?38h\E8, u1=\E[?38l\E)0, u2=\E[92;52"p, u3=\E~B,
-	u4=\E[92;76"p, u5=\E%!1\E[90;1"p, vpa=\E[%i%p1%dd,
+	smir=\E[4h, smkx=\E[?1l\E=,
+	tsl=\E[40l\E[40h\E7\E[99;%i%p1%dH, u0=\E[?38h\E8,
+	u1=\E[?38l\E)0, u2=\E[92;52"p, u3=\E~B, u4=\E[92;76"p,
+	u5=\E%!1\E[90;1"p, vpa=\E[%i%p1%dd, use=ansi+csr,
+	use=ansi+inittabs, use=ansi+local, use=ansi+pp,
+	use=ansi+sgrbold, use=decid+cpr,
 #
 #	Function key set for the ASCII (wy-50 compatible) keyboard
 #	This is the default 370.
 #
 wy370|wyse370|wy370-101k|Wyse 370 with 101 key keyboard,
-	kbs=^H, kcbt=\E[Z, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C,
-	kcuu1=\E[A, kdch1=\EOQ, kdl1=\EOQ, kent=\EOM, kf1=\E[?4i,
+	kcbt=\E[Z, kdch1=\EOQ, kdl1=\EOQ, kent=\EOM, kf1=\E[?4i,
 	kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[25~,
 	kf14=\E[26~, kf15=\E[28~, kf16=\E[29~, kf2=\E[?3i,
 	kf3=\E[2i, kf4=\E[@, kf5=\E[M, kf6=\E[17~, kf7=\E[18~,
-	kf8=\E[19~, kf9=\E[20~, khome=\E[H, kich1=\EOP, kil1=\EOP,
-	knp=\E[U, kpp=\E[V, use=wy370-nk,
+	kf8=\E[19~, kf9=\E[20~, kich1=\EOP, kil1=\EOP, knp=\E[U,
+	kpp=\E[V, use=ansi+arrows, use=wy370-nk,
 #
 #	Function key set for the VT-320 (and wy85) compatible keyboard
 #
 wy370-105k|Wyse 370 with 105 key keyboard,
-	kbs=^H, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
 	kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[25~,
 	kf14=\E[26~, kf15=\E[28~, kf16=\E[29~, kf17=\E[31~,
 	kf18=\E[32~, kf19=\E[33~, kf20=\E[34~, kf6=\E[17~,
 	kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, kfnd=\E[1~,
 	khlp=\E[28~, khome=\E[26~, lf1=PF1, lf2=PF2, lf3=PF3,
-	lf4=PF4, use=vt220+vtedit, use=wy370-nk,
+	lf4=PF4, use=ansi+arrows, use=vt220+vtedit, use=wy370-nk,
 	use=vt220+keypad,
 #
 #	Function key set for the PC compatible keyboard
 #
 wy370-EPC|Wyse 370 with 102 key keyboard,
-	kbs=^H, kcbt=\E[Z, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C,
-	kcuu1=\E[A, kend=\E[1~, kent=\EOM, kf1=\EOP, kf10=\E[21~,
+	kcbt=\E[Z, kend=\E[1~, kent=\EOM, kf1=\EOP, kf10=\E[21~,
 	kf11=\E[23~, kf12=\E[24~, kf2=\EOQ, kf3=\EOR, kf4=\EOS,
 	kf5=\E[M, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~,
-	khome=\E[H, kich1=\E[2~, knp=\E[U, kpp=\E[V, use=wy370-nk,
+	kich1=\E[2~, knp=\E[U, kpp=\E[V, use=ansi+arrows,
+	use=wy370-nk,
 #
 #	Wyse 370 with visual bell.
 wy370-vb|Wyse 370 with visible bell,
@@ -12707,7 +13296,7 @@ wy370-tek|Wyse 370 Tektronix 4010/4014 emulator,
 #               is2 -> do the initialization
 #               is3 -> If this string is empty then rs3 gets sent.
 #
-#       Wyse 520 emulating a vt420 7 bit mode with default ANSI keyboard
+#       Wyse 520 emulating a VT420 7 bit mode with default ANSI keyboard
 #       - The BS key is programmed to generate BS in smcup since
 #         is2 doesn't seem to work.
 #       - Remove and shift/Remove: delete a character
@@ -12721,63 +13310,60 @@ wy370-tek|Wyse 370 Tektronix 4010/4014 emulator,
 #         keypad in Dec application mode which doesn't seem to work
 #         with SCO applications.
 #
-wy520|wyse520|wyse 520,
-	am, hs, km, mc5i, mir, xenl, xon,
+wy520|wyse520|Wyse 520,
+	am, hs, km, mir, xenl, xon,
 	cols#80, it#8, lines#24, wsl#80,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[?25l,
-	clear=\E[H\E[J$<40>, cnorm=\E[34h\E[?25h, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr$<20>, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
+	bel=^G, civis=\E[?25l, clear=\E[H\E[J$<40>,
+	cnorm=\E[34h\E[?25h, cr=\r, csr=\E[%i%p1%d;%p2%dr$<20>,
+	cub1=^H, cud1=\n, cup=\E[%i%p1%d;%p2%dH,
 	cvvis=\E[?25h\E[34l, dch=\E[%p1%dP$<3>, dch1=\E[P$<30>,
 	dim=\E[2m, dl=\E[%p1%dM$<2*>, dl1=\E[M$<2>, dsl=\E[0$~,
 	ech=\E[%p1%dX, ed=\E[J$<40>, el=\E[K, el1=\E[1K,
-	enacs=\E)0, fsl=\E[0$}, home=\E[H, hpa=\E[%i%p1%d`, ht=^I,
-	hts=\EH, ich=\E[%p1%d@$<2>, il=\E[%p1%dL$<3*>,
-	il1=\E[L$<3>, ind=\n$<2>, invis=\E[8m, ip=$<4>, is1=\E[?5W,
+	enacs=\E)0, fsl=\E[0$}, home=\E[H, hpa=\E[%i%p1%d`,
+	ich=\E[%p1%d@$<2>, il=\E[%p1%dL$<3*>, il1=\E[L$<3>,
+	ind=\n$<2>, ip=$<4>, is1=\E[?5W,
 	is2=\E[2;4;20;30l\E[?1;4;10;16l\E[12h\E[?7;8;25;67h,
-	is3=\E>\E(B\E)0\017\E[m, kbs=^H, kcbt=\E[Z, kcub1=\E[D,
-	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, ked=\E[1~, kel=\E[4~,
-	kent=\EOM, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~,
-	kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, kf16=\E[29~,
-	kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, kf20=\E[34~,
-	kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~,
-	khlp=\E[28~, khome=\E[26~, lf1=PF1, lf2=PF2, lf3=PF3,
-	lf4=PF4, mc0=\E[0i, mc4=\E[4i, mc5=\E[5i, rc=\E8, rev=\E[7m,
+	is3=\E>\E(B\E)0\017\E[m, kcbt=\E[Z, ked=\E[1~, kel=\E[4~,
+	kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[25~,
+	kf14=\E[26~, kf15=\E[28~, kf16=\E[29~, kf17=\E[31~,
+	kf18=\E[32~, kf19=\E[33~, kf20=\E[34~, kf6=\E[17~,
+	kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, khlp=\E[28~,
+	khome=\E[26~, lf1=PF1, lf2=PF2, lf3=PF3, lf4=PF4, mc0=\E[0i,
 	ri=\EM$<2>, rmacs=^O, rmam=\E[?7l, rmcup=\E[ R, rmir=\E[4l,
-	rmso=\E[m, rmul=\E[24m,
-	rs1=\E[13l\E[3l\E\\\E[63;1"p\E[!p, rs2=\E[35h\E[?3l,
-	rs3=\E[?5l\E[47h\E[40l\E[r, sc=\E7,
+	rmul=\E[24m, rs1=\E[13l\E[3l\E\\\E[63;1"p\E[!p,
+	rs2=\E[35h\E[?3l, rs3=\E[?5l\E[47h\E[40l\E[r,
 	sgr=\E[0%?%p2%t;4%;%?%p3%p1%|%t;7%;%?%p4%t;5%;%?%p5%t;2%;%?
 	    %p6%t;1%;%?%p7%t;8%;m%?%p9%t\016%e\017%;,
 	sgr0=\E[m\017, smacs=^N, smam=\E[?7h,
-	smcup=\E[ Q\E[?67;8h, smir=\E[4h, smso=\E[7m, smul=\E[4m,
-	tbc=\E[3g, tsl=\E[2$~\E[1$}\E[%i%p1%d`,
-	vpa=\E[%i%p1%dd, use=vt220+vtedit, use=vt220+keypad,
+	smcup=\E[ Q\E[?67;8h, smir=\E[4h,
+	tsl=\E[2$~\E[1$}\E[%i%p1%d`, vpa=\E[%i%p1%dd,
+	use=ansi+arrows, use=ansi+csr, use=ansi+local,
+	use=ansi+pp, use=ansi+sgrbold, use=ansi+tabs,
+	use=decid+cpr, use=vt220+vtedit, use=vt220+keypad,
 #
 #       Wyse 520 with 24 data lines and status (terminal status)
-wy520-24|wyse520-24|wyse 520 with 24 data lines,
+wy520-24|wyse520-24|Wyse 520 with 24 data lines,
 	hs@,
 	dsl@, fsl@, rs3=\E[?5l\E[47h\E[40l\E[1;24r, tsl@,
 	use=wy520,
 #
 #       Wyse 520 with visual bell.
-wy520-vb|wyse520-vb|wyse 520 with visible bell,
+wy520-vb|wyse520-vb|Wyse 520 with visible bell,
 	flash=\E[30h\E\,$<100/>\E[30l, use=wy520,
 #
 #       Wyse 520 in 132-column mode.
-wy520-w|wyse520-w|wyse 520 in 132-column mode,
+wy520-w|wyse520-w|Wyse 520 in 132-column mode,
 	cols#132, wsl#132,
 	dch=\E[%p1%dP$<7>, dch1=\E[P$<7>, ich=\E[%p1%d@$<7>,
 	ip=$<7>, rs2=\E[35h\E[?3h, use=wy520,
 #
 #       Wyse 520 in 132-column mode with visual bell.
-wy520-wvb|wyse520-wvb|wyse 520 with visible bell 132-columns,
+wy520-wvb|wyse520-wvb|Wyse 520 with visible bell 132-columns,
 	flash=\E[30h\E\,$<100/>\E[30l, use=wy520-w,
 #
 #
-#       Wyse 520 emulating a vt420 7 bit mode.
+#       Wyse 520 emulating a VT420 7 bit mode.
 #       The DEL key is programmed to generate BS in is2.
 #       With EPC keyboard.
 #       - 'End' key will clear till end of line on EPC keyboard
@@ -12786,55 +13372,55 @@ wy520-wvb|wyse520-wvb|wyse 520 with visible bell 132-columns,
 #       - Delete : delete a character (have to change interrupt character
 #                  to CTRL-C: stty intr '^c') for it to work since the
 #                  Delete key sends 7FH.
-wy520-epc|wyse520-epc|wyse 520 with EPC keyboard,
+wy520-epc|wyse520-epc|Wyse 520 with EPC keyboard,
 	kdch1=^?, kel=\E[4~, kend=\E[4~, kf0=\E[21~, kf1=\E[11~,
 	kf2=\E[12~, kf3=\E[13~, kf4=\E[14~, kf5=\E[15~, khome=\E[H,
 	use=wy520,
 #
 #       Wyse 520 with 24 data lines and status (terminal status)
 #       with EPC keyboard.
-wy520-epc-24|wyse520-pc-24|wyse 520 with 24 data lines and EPC keyboard,
+wy520-epc-24|wyse520-pc-24|Wyse 520 with 24 data lines and EPC keyboard,
 	hs@,
 	dsl@, fsl@, rs3=\E[?5l\E[47h\E[40l\E[1;24r, tsl@,
 	use=wy520-epc,
 #
 #       Wyse 520 with visual bell.
-wy520-epc-vb|wyse520-pc-vb|wyse 520 with visible bell and EPC keyboard,
+wy520-epc-vb|wyse520-pc-vb|Wyse 520 with visible bell and EPC keyboard,
 	flash=\E[30h\E\,$<100/>\E[30l, use=wy520-epc,
 #
 #       Wyse 520 in 132-column mode.
-wy520-epc-w|wyse520-epc-w|wyse 520 in 132-column mode with EPC keyboard,
+wy520-epc-w|wyse520-epc-w|Wyse 520 in 132-column mode with EPC keyboard,
 	cols#132, wsl#132,
 	dch=\E[%p1%dP$<7>, dch1=\E[P$<7>, ich=\E[%p1%d@$<7>,
 	ip=$<7>, rs2=\E[35h\E[?3h, use=wy520-epc,
 #
 #       Wyse 520 in 132-column mode with visual bell.
-wy520-epc-wvb|wyse520-p-wvb|wyse 520 with visible bell 132-columns and EPC keyboard,
+wy520-epc-wvb|wyse520-p-wvb|Wyse 520 with visible bell 132-columns and EPC keyboard,
 	flash=\E[30h\E\,$<100/>\E[30l, use=wy520-epc-w,
 #
 #       Wyse 520 in 80-column, 36 lines
-wy520-36|wyse520-36|wyse 520 with 36 data lines,
+wy520-36|wyse520-36|Wyse 520 with 36 data lines,
 	hs@,
 	lines#36,
 	dsl@, fsl@, rs3=\E[?5l\E[36*|\E[36t\E[40l\E[1;36r, tsl@,
 	use=wy520,
 #
 #       Wyse 520 in 80-column, 48 lines
-wy520-48|wyse520-48|wyse 520 with 48 data lines,
+wy520-48|wyse520-48|Wyse 520 with 48 data lines,
 	hs@,
 	lines#48,
 	dsl@, fsl@, rs3=\E[?5l\E[48*|\E[48t\E[40l\E[1;48r, tsl@,
 	use=wy520,
 #
 #       Wyse 520 in 132-column, 36 lines
-wy520-36w|wyse520-36w|wyse 520 with 132 columns and 36 data lines,
+wy520-36w|wyse520-36w|Wyse 520 with 132 columns and 36 data lines,
 	cols#132, wsl#132,
 	rs2=\E[?3h,
 	rs3=\E[?5l\E[36*|\E[36t\E[40l\E[1;36r\E[132$|,
 	use=wy520-36,
 #
 #       Wyse 520 in 132-column, 48 lines
-wy520-48w|wyse520-48w|wyse 520 with 48 data lines,
+wy520-48w|wyse520-48w|Wyse 520 with 48 data lines (132 column),
 	cols#132, wsl#132,
 	rs2=\E[?3h,
 	rs3=\E[?5l\E[48*|\E[48t\E[40l\E[1;48r\E[132$|,
@@ -12842,28 +13428,28 @@ wy520-48w|wyse520-48w|wyse 520 with 48 data lines,
 #
 #
 #       Wyse 520 in 80-column, 36 lines with EPC keyboard
-wy520-36pc|wyse520-36pc|wyse 520 with 36 data lines and EPC keyboard,
+wy520-36pc|wyse520-36pc|Wyse 520 with 36 data lines and EPC keyboard,
 	hs@,
 	lines#36,
 	dsl@, fsl@, rs3=\E[?5l\E[36*|\E[36t\E[40l\E[1;36r, tsl@,
 	use=wy520-epc,
 #
 #       Wyse 520 in 80-column, 48 lines with EPC keyboard
-wy520-48pc|wyse520-48pc|wyse 520 with 48 data lines and EPC keyboard,
+wy520-48pc|wyse520-48pc|Wyse 520 with 48 data lines and EPC keyboard,
 	hs@,
 	lines#48,
 	dsl@, fsl@, rs3=\E[?5l\E[48*|\E[48t\E[40l\E[1;48r, tsl@,
 	use=wy520-epc,
 #
 #       Wyse 520 in 132-column, 36 lines with EPC keyboard
-wy520-36wpc|wyse520-36wpc|wyse 520 with 36 data lines and EPC keyboard,
+wy520-36wpc|wyse520-36wpc|Wyse 520 with 36 data lines and EPC keyboard (132 column),
 	cols#132, wsl#132,
 	rs2=\E[?3h,
 	rs3=\E[?5l\E[36*|\E[36t\E[40l\E[1;36r\E[132$|,
 	use=wy520-36pc,
 #
 #       Wyse 520 in 132-column, 48 lines with EPC keyboard
-wy520-48wpc|wyse520-48wpc|wyse 520 with 48 data lines and EPC keyboard,
+wy520-48wpc|wyse520-48wpc|Wyse 520 with 48 data lines and EPC keyboard (132 column),
 	cols#132, wsl#132,
 	rs2=\E[?3h,
 	rs3=\E[?5l\E[48*|\E[48t\E[40l\E[1;48r\E[132$|,
@@ -12878,9 +13464,9 @@ wyse-vp|Wyse 50 in ADDS Viewpoint emulation mode with "enhance" on,
 	bel=^G, clear=^L, cr=\r, cub1=^H, cud1=\n, cuf1=^F,
 	cup=\EY%p1%{32}%+%c%p2%{32}%+%c, cuu1=^Z, dch1=\EW,
 	dl1=\El, ed=\Ek, el=\EK, home=^A, ht=^I, il1=\EM, ind=\n,
-	is2=\E`\:\E`9\017\Er, kbs=^H, kcub1=^U, kcud1=\n, kcuf1=^F,
+	is2=\E`:\E`9\017\Er, kbs=^H, kcub1=^U, kcud1=\n, kcuf1=^F,
 	kcuu1=^Z, khome=^A, ll=^A^Z, nel=\r\n, rmir=\Er, rmso=^O,
-	rmul=^O, rs1=\E`\:\E`9\017\Er, sgr0=^O, smir=\Eq, smso=^N,
+	rmul=^O, rs1=\E`:\E`9\017\Er, sgr0=^O, smir=\Eq, smso=^N,
 	smul=^N,
 
 wy75ap|wyse75ap|wy-75ap|wyse-75ap|Wyse WY-75 Applications and Cursor keypad,
@@ -12896,7 +13482,7 @@ wy100q|Wyse 100 for Quotron,
 	cbt=\EI, clear=^Z, cub1=^H, cud1=\n, cuf1=^L,
 	cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K, dch1=\EW,
 	dl1=\ER, ed=\EY, el=\ET, home=^^, il1=\EE, invis@,
-	is2=\E`\:\0\EC\EDF\E0\E'\E(\EA21, kcub1=^H, kcud1=\n,
+	is2=\E`:\0\EC\EDF\E0\E'\E(\EA21, kcub1=^H, kcud1=\n,
 	kcuf1=^L, kcuu1=^K, ri=\Ej, rmir=\Er, smir=\Eq, use=adm+sgr,
 
 #### Kermit terminal emulations
@@ -12931,21 +13517,20 @@ pckermit|pckermit12|UCB IBMPC Kermit 1.2,
 	clear=\EH\EJ, ed@, el@,
 	is2=K2 UCB IBMPC Kermit 1.2  8-30-84\n, use=kermit,
 # IBMPC Kermit 1.20
-# Cannot use line 25, now acts funny like ansi special scrolling region.
+# Cannot use line 25, now acts funny like ANSI special scrolling region.
 # Initialization must escape from that region by cursor position to line 24.
 # Cannot use character insert because 1.20 goes crazy if insert at col 80.
 # Does not use :am: because autowrap is lost when kermit dropped and restarted.
 # From: greg small <gts@populi.berkeley.edu> 12-19-84
 pckermit120|UCB IBMPC Kermit 1.20,
-	it#8, lines#24,
-	cud1=\EB, cvvis=\EO\Eq\EEK3, dch1=\EN, dl1=\EM, ht=^I,
-	il1=\EL,
+	it#8,
+	cvvis=\EO\Eq\EEK3, dch1=\EN, dl1=\EM, ht=^I, il1=\EL,
 	is2=\EO\Eq\EJ\EY7\sK3\sUCB\sIBMPC\sKermit\s1.20\s\s12-19-84
 	    \n,
 	rmir@, rmso=\Eq, smir@, smso=\Ep, use=kermit,
 # MS-DOS Kermit 2.27 for the IBMPC
 # Straight ascii keyboard. :sr=\EI: not avail. many versions + bug prone in vi.
-# Cannot use line 25, now acts funny like ansi special scrolling region.
+# Cannot use line 25, now acts funny like ANSI special scrolling region.
 # Initialization must escape from that region by cursor position to line 24.
 # Does not use am: because autowrap is lost when kermit dropped and restarted.
 # Reverse video for standout like H19.
@@ -12987,60 +13572,55 @@ msk22714|mskermit22714|UCB MS-DOS Kermit 2.27 UCB 227.14 IBM PC,
 # at support for the VT320 itself.
 # Please send changes with explanations to bug-gnu-emacs@prep.ai.mit.edu.
 # (vt320-k3: I added <rmam>/<smam> based on the init string -- esr)
-vt320-k3|MS-Kermit 3.00's vt320 emulation,
-	am, eslok, hs, km, mir, msgr, xenl,
+vt320-k3|MS-Kermit 3.00's VT320 emulation,
+	am, km, mir, msgr, xenl,
 	cols#80, it#8, lines#49, pb#9600, vt#3,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[J, cmdch=\E,
-	cr=\r, csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M,
-	dsl=\E[0$~, ech=\E[%p1%dX, ed=\E[J, el=\E[K,
+	bel=^G, blink=\E[5m, bold=\E[1m, cmdch=\E, cr=\r, cub1=^H,
+	cud1=\n, cup=\E[%i%p1%d;%p2%dH, dch=\E[%p1%dP, dch1=\E[P,
+	ech=\E[%p1%dX,
 	flash=\E[?5h$<100/>\E[?5l\E[?5h$<100/>\E[?5l\E[?5h$<100/>\E[
 	      ?5l,
-	fsl=\E[0$}, home=\E[H, hpa=\E[%i%p1%dG, ht=^I, hts=\EH,
-	ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L, ind=\n,
-	is2=\E>\E F\E[?1h\E[?7h\E[r\E[2$~, kbs=^H, kcub1=\EOD,
-	kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kdl1=\E[3~, kf0=\E[21~,
-	kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf6=\E[17~,
-	kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, kich1=\E[2~, knp=\E[6~,
-	kpp=\E[5~, mc0=\E[0i, mc4=\E[4i, mc5=\E[5i, nel=\r\n, rc=\E8,
-	rev=\E[7m, ri=\EM, rin=\E[%p1%dL, rmacs=\E(B, rmam=\E[?7l,
-	rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[27m, rmul=\E[24m,
+	home=\E[H, hpa=\E[%i%p1%dG, ht=^I, hts=\EH, ich=\E[%p1%d@,
+	ind=\n, is2=\E>\E F\E[?1h\E[?7h\E[r\E[2$~, kbs=^H,
+	kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kdl1=\E[3~,
+	kf0=\E[21~, kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS,
+	kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~,
+	kich1=\E[2~, knp=\E[6~, kpp=\E[5~, mc0=\E[0i, mc4=\E[4i,
+	mc5=\E[5i, nel=\r\n, rev=\E[7m, ri=\EM, rin=\E[%p1%dL,
+	rmacs=\E(B, rmam=\E[?7l, rmir=\E[4l, rmkx=\E[?1l\E>,
+	rmso=\E[27m, rmul=\E[24m,
 	rs1=\E(B\E)B\E>\E\sF\E[4;20l\E[12h\E[?1;5;6;38;42l\E[?7;25h
 	    \E[4i\E[?4i\E[m\E[r\E[2$~,
-	sc=\E7, sgr0=\E[m, smacs=\E(0, smam=\E[?7h, smir=\E[4h,
+	sgr0=\E[m, smacs=\E(0, smam=\E[?7h, smir=\E[4h,
 	smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g,
-	tsl=\E[1$}\r\E[K, vpa=\E[%i%p1%dd, use=vt220+cvis,
+	tsl=\E[1$}\r\E[K, vpa=\E[%i%p1%dd, use=ansi+csr,
+	use=ansi+erase, use=ansi+idl, use=ansi+local, use=dec+sl,
+	use=vt220+cvis,
 
 # From: Joseph Gil <yogi@cs.ubc.ca> 13 Dec 1991
 # ACS capabilities from Philippe De Muyter  <phdm@info.ucl.ac.be> 30 May 1996
 # (I removed a bogus boolean :mo: and added <msgr>, <smam>, <rmam> -- esr)
-vt320-k311|dec vt320 series as defined by kermit 3.11,
+vt320-k311|DEC VT320 series as defined by kermit 3.11,
 	am, eslok, hs, mir, msgr, xenl, xon,
 	cols#80, it#8, lines#24, vt#3,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
 	bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[;H\E[2J, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M,
-	dsl=\E[2$~\r\E[1$}\E[K\E[$}, ed=\E[J, el=\E[K,
+	cub1=^H, cud1=\n, cup=\E[%i%p1%d;%p2%dH, dch=\E[%p1%dP,
+	dch1=\E[P, dsl=\E[2$~\r\E[1$}\E[K\E[$}, ed=\E[J, el=\E[K,
 	flash=\E[?5h$<100/>\E[?5l, fsl=\E[$}, home=\E[H, ht=^I,
-	hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L$<3/>,
-	ind=\ED,
+	hts=\EH, ich=\E[%p1%d@, il1=\E[L$<3/>, ind=\ED,
 	is2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h\E[1;24r\E[24;1H,
 	kbs=^H, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
 	kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf6=\E[17~,
 	kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, lf1=pf1, lf2=pf2,
-	lf3=pf3, lf4=pf4, nel=\r\ED, rc=\E8, rev=\E[7m,
+	lf3=pf3, lf4=pf4, nel=\r\ED, rev=\E[7m,
 	rf=/usr/share/tabset/vt100, ri=\EM, rmacs=^O,
 	rmam=\E[?7l, rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[27m,
-	rmul=\E[24m, rs1=\E[?3l, sc=\E7, sgr0=\E[m, smacs=^N,
-	smam=\E[?7h, smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m,
-	smul=\E[4m, tbc=\E[3g, tsl=\E[2$~\E[1$}\E[1;%dH,
-	use=vt220+cvis,
+	rmul=\E[24m, rs1=\E[?3l, sgr0=\E[m, smacs=^N, smam=\E[?7h,
+	smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m,
+	tbc=\E[3g, tsl=\E[2$~\E[1$}\E[1;%dH, use=ansi+csr,
+	use=ansi+idl, use=ansi+local, use=vt220+cvis,
 
 ######## NON-ANSI TERMINAL EMULATIONS
 #
@@ -13135,27 +13715,28 @@ rbcomm|IBM PC with RBcomm and EMACS keybindings,
 	am, bw, mir, msgr, xenl,
 	cols#80, it#8, lines#25,
 	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, clear=^L, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub1=^H, cud1=^C, cuf1=^B,
+	cub1=^H, cud1=^C, cuf1=^B,
 	cup=\037%p2%{32}%+%c%p1%{32}%+%c, cuu1=^^, dch1=^W,
 	dl=\E[%p1%dM, dl1=^Z, ech=\E[%p1%dX, ed=^F5, el=^P^P, ht=^I,
 	il=\E[%p1%dL, il1=^K, ind=\ED, invis=\E[8m,
 	is2=\017\035\E(B\E)0\E[?7h\E[?3l\E[>8g, kbs=^H,
 	kcub1=^B, kcud1=^N, kcuf1=^F, kcuu1=^P, khome=^A, nel=\r\ED,
-	rc=\E8, rep=\030%p1%c%p2%c, rev=^R, ri=\EM, rmcup=, rmdc=,
-	rmir=^], rmkx=\E>, rmso=^U, rmul=^U,
-	rs1=\017\E(B\E)0\025\E[?3l\E[>8g, sc=\E7, sgr0=\E[m,
-	smcup=, smdc=, smir=^\, smkx=\E=, smso=^R, smul=^T,
+	rep=\030%p1%c%p2%c, rev=^R, ri=\EM, rmcup=, rmdc=, rmir=^],
+	rmkx=\E>, rmso=^U, rmul=^U,
+	rs1=\017\E(B\E)0\025\E[?3l\E[>8g, sgr0=\E[m, smcup=,
+	smdc=, smir=^\, smkx=\E=, smso=^R, smul=^T, use=ansi+csr,
 	use=vt220+cvis,
+
 rbcomm-nam|IBM PC with RBcomm without autowrap,
 	am@,
-	bel=^G, cr=\r, cud1=\n, ht=^I, ind=\n,
-	is2=\017\035\E(B\E)0\E[?7l\E[?3l\E[>8g, kbs=^H,
-	kcub1=^H, kcud1=\n, nel=\r\n, use=rbcomm,
+	cud1=\n, ind=\n,
+	is2=\017\035\E(B\E)0\E[?7l\E[?3l\E[>8g, kcub1=^H,
+	kcud1=\n, nel=\r\n, use=rbcomm,
 rbcomm-w|IBM PC with RBcomm in 132 column mode,
 	cols#132,
-	bel=^G, cr=\r, cud1=\n, ht=^I, ind=\n,
-	is2=\017\035\E(B\E)0\E[?7h\E[?3h\E[>8g, kbs=^H,
-	kcub1=^H, kcud1=\n, nel=\r\n, use=rbcomm,
+	cud1=\n, ind=\n,
+	is2=\017\035\E(B\E)0\E[?7h\E[?3h\E[>8g, kcub1=^H,
+	kcud1=\n, nel=\r\n, use=rbcomm,
 
 ######## LCD DISPLAYS
 #
@@ -13184,7 +13765,7 @@ rbcomm-w|IBM PC with RBcomm in 132 column mode,
 # NOTE: calling 'beep' turns on the backlight (bell)
 # NOTE: calling 'flash' turns it on and back off (visual bell)
 #
-MtxOrb|Generic Matrix Orbital LCD display,
+MtxOrb|generic Matrix Orbital LCD display,
 	bel=\376B\001, clear=\376X\376C\376R\376K\376T,
 	cnorm=\376K\376T, cub1=\376L, cuf1=\376M,
 	flash=\376B\001$<200>\376F, home=\376H,
@@ -13214,25 +13795,23 @@ MtxOrb162|16x2 Matrix Orbital LCD display,
 att2300|sv80|AT&T 2300 Video Information Terminal 80 column mode,
 	am, eo, mir, msgr, xon,
 	cols#80, it#8, lines#24,
-	bel=^G, clear=\E[H\E[J, cr=\r, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J,
-	el=\E[K, el1=\E[1K, home=\E[H, ht=^I, ich=\E[%p1%d@,
-	il=\E[%p1%dL, il1=\E[L, ind=\n, kbs=^H, kcbt=\E[Z, kclr=\E[J,
-	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kdch1=\E[P,
+	bel=^G, cr=\r, cub1=^H, cud1=\n, cup=\E[%i%p1%d;%p2%dH,
+	dch=\E[%p1%dP, dch1=\E[P, el1=\E[1K, home=\E[H, ht=^I,
+	ich=\E[%p1%d@, ind=\n, kcbt=\E[Z, kclr=\E[J, kdch1=\E[P,
 	kdl1=\E[M, kf1=\E[1r, kf10=\E[10r, kf11=\E[11r,
 	kf12=\E[12r, kf13=\E[13r, kf14=\E[14r, kf15=\E[15r,
 	kf16=\E[16r, kf2=\E[2r, kf3=\E[3r, kf4=\E[4r, kf5=\E[5r,
-	kf6=\E[6r, kf7=\E[7r, kf8=\E[8r, kf9=\E[9r, khome=\E[H,
-	kich1=\E[@, kil1=\E[L, mc0=\E[0i, mc4=\E[4i, mc5=\E[5i,
-	rev=\E[7m, rmir=\E[4l, rmso=\E[m, sgr0=\E[m, smir=\E[4h,
-	smso=\E[7m,
+	kf6=\E[6r, kf7=\E[7r, kf8=\E[8r, kf9=\E[9r, kich1=\E[@,
+	kil1=\E[L, mc0=\E[0i, mc4=\E[4i, mc5=\E[5i, rev=\E[7m,
+	rmir=\E[4l, rmso=\E[m, sgr0=\E[m, smir=\E[4h, smso=\E[7m,
+	use=ansi+arrows, use=ansi+cpr, use=ansi+erase,
+	use=ansi+idl, use=ansi+local,
+
 att2350|AT&T 2350 Video Information Terminal 80 column mode,
 	mc0@, mc4@, mc5@, use=att2300,
 
 # Must setup RETURN KEY - CR, REC'VD LF - INDEX.
-# Seems upward compatible with vt100, plus ins/del line/char.
+# Seems upward compatible with VT100, plus ins/del line/char.
 # On sgr, the protection parameter is ignored.
 # No check is made to make sure that only 3 parameters are output.
 #	standout= reverse + half-intensity = 3 | 5.
@@ -13247,11 +13826,10 @@ att5410v1|att4410v1|tty5410v1|AT&T 4410/5410 80 columns - version 1,
 	cols#80, it#8, lh#2, lines#24, lw#8, nlab#8, wsl#80,
 	acsc=++\,\,--..00``aaffgghhjjkkllmmnnooppqqrrssttuuvvwwxxyyz
 	     z{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[2;7m, clear=\E[H\E[J, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub1=^H, cud1=\E[B, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, dch1=\E[P, dim=\E[2m,
-	dl1=\E[M, ed=\E[J, el=\E[K, fsl=\E8, home=\E[H, ht=^I,
-	ich1=\E[@, il1=\E[L, ind=\n, invis=\E[8m, is1=\E[?3l\E)0,
+	bel=^G, bold=\E[2;7m, cr=\r, cub1=^H, cuf1=\E[C,
+	cup=\E[%i%p1%d;%p2%dH, dch1=\E[P, dim=\E[2m, dl1=\E[M,
+	fsl=\E8, home=\E[H, ht=^I, ich1=\E[@, il1=\E[L, ind=\n,
+	is1=\E[?3l\E)0,
 	is3=\E[1;03q\s\s\sf1\s\s\s\s\s\s\s\s\s\s\s\EOP\E[2;03q\s\s
 	    \sf2\s\s\s\s\s\s\s\s\s\s\s\EOQ\E[3;03q\s\s\sf3\s\s\s\s
 	    \s\s\s\s\s\s\s\EOR\E[4;03q\s\s\sf4\s\s\s\s\s\s\s\s\s\s
@@ -13259,19 +13837,18 @@ att5410v1|att4410v1|tty5410v1|AT&T 4410/5410 80 columns - version 1,
 	    \s\s\sf6\s\s\s\s\s\s\s\s\s\s\s\EOU\E[7;03q\s\s\sf7\s\s
 	    \s\s\s\s\s\s\s\s\s\EOV\E[8;03q\s\s\sf8\s\s\s\s\s\s\s\s
 	    \s\s\s\EOW,
-	kbs=^H, kclr=\E[2J, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C,
-	kcuu1=\E[A, kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf5=\EOT,
-	kf6=\EOU, kf7=\EOV, kf8=\EOW, khome=\E[H, kll=\E[24;1H,
-	ll=\E[24H, nel=\r\n,
+	kclr=\E[2J, kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf5=\EOT,
+	kf6=\EOU, kf7=\EOV, kf8=\EOW, kll=\E[24;1H, ll=\E[24H,
+	nel=\r\n,
 	pfx=\E[%p1%1d;%p2%l%2.2dq\s\s\sf%p1%1d\s\s\s\s\s\s\s\s\s\s
 	    \s%p2%s,
-	pln=\E[%p1%d;00q%p2%:-16s, rc=\E8, rev=\E[7m, ri=\EM,
-	rmacs=^O, rmso=\E[m, rmul=\E[m, rs2=\Ec\E[?3l\E[2;0y,
-	sc=\E7,
+	pln=\E[%p1%d;00q%p2%:-16s, ri=\EM, rmacs=^O,
+	rs2=\Ec\E[?3l\E[2;0y,
 	sgr=\E[0%?%p1%p5%|%p6%|%t;2%;%?%p2%t;4%;%?%p4%t;5%;%?%p3%p1
 	    %|%p6%|%t;7%;%?%p7%t;8%;m%?%p9%t\016%e\017%;,
-	sgr0=\E[m\017, smacs=^N, smso=\E[7m, smul=\E[4m,
-	tsl=\E7\E[25;%p1%{1}%+%dH,
+	sgr0=\E[m\017, smacs=^N, tsl=\E7\E[25;%p1%{1}%+%dH,
+	use=ansi+arrows, use=ansi+csr, use=ansi+erase,
+	use=ansi+local1, use=ansi+sgrbold,
 
 att4410v1-w|att5410v1-w|tty5410v1-w|AT&T 4410/5410 132 columns - version 1,
 	cols#132, wsl#132,
@@ -13286,28 +13863,27 @@ att5410-w|att4410-w|4410-w|tty5410-w|5410-w|AT&T 4410/5410 in 132 column mode,
 	cols#132, wsl#132,
 	is1=\E[?3h\E)0, rs2=\Ec\E[?3h\E[2;0y, use=att4410,
 
-# 5410 in terms of a vt100
+# 5410 in terms of a VT100
 # (v5410: added <rmam>/<smam> based on init string -- esr)
-v5410|att5410 in terms of a vt100,
+v5410|att5410 in terms of a VT100,
 	am, mir, msgr, xon,
 	cols#80, it#8, lines#24, vt#3,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
 	bel=^G, blink=\E[5m$<2>, bold=\E[1m$<2>,
-	clear=\E[H\E[J$<50>, cr=\r, csr=\E[%i%p1%d;%p2%dr,
-	cub1=^H, cud1=\n, cuf1=\E[C$<2>,
-	cup=\E[%i%p1%d;%p2%dH$<5>, cuu1=\E[A$<2>, dch1=\E[P,
-	dl1=\E[M, ed=\E[J$<50>, el=\E[K$<3>, el1=\E[1K$<3>,
-	enacs=\E(B\E)0, home=\E[H, ht=^I, hts=\EH, ich1=\E[@,
-	il1=\E[L, ind=\n, kbs=^H, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC,
-	kcuu1=\EOA, rc=\E8, rev=\E[7m$<2>, ri=\EM$<5>, rmacs=^O,
-	rmam=\E[?7l, rmkx=\E[?1l\E>, rmso=\E[m$<2>,
-	rmul=\E[m$<2>, rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h,
-	sc=\E7,
+	clear=\E[H\E[J$<50>, cr=\r, cub1=^H, cud1=\n,
+	cuf1=\E[C$<2>, cup=\E[%i%p1%d;%p2%dH$<5>,
+	cuu1=\E[A$<2>, dch1=\E[P, dl1=\E[M, ed=\E[J$<50>,
+	el=\E[K$<3>, el1=\E[1K$<3>, enacs=\E(B\E)0, home=\E[H,
+	ht=^I, hts=\EH, ich1=\E[@, il1=\E[L, ind=\n, kbs=^H,
+	kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
+	rev=\E[7m$<2>, ri=\EM$<5>, rmacs=^O, rmam=\E[?7l,
+	rmkx=\E[?1l\E>, rmso=\E[m$<2>, rmul=\E[m$<2>,
+	rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h,
 	sgr=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5
 	    %;m%?%p9%t\016%e\017%;$<2>,
 	sgr0=\E[m\017$<2>, smacs=^N, smam=\E[?7h, smkx=\E[?1h\E=,
 	smso=\E[1;7m$<2>, smul=\E[4m$<2>, tbc=\E[3g,
-	use=vt100+fnkeys,
+	use=ansi+csr, use=decid+cpr, use=vt100+fnkeys,
 
 #
 # Teletype Model 5420 -- A souped up 5410, with multiple windows,
@@ -13347,15 +13923,12 @@ v5410|att5410 in terms of a vt100,
 # when pressed in SYS PF mode.
 # (att4415: I added <rmam>/<smam> based on the init string -- esr)
 att4415|tty5420|att5420|AT&T 4415/5420 80 cols,
-	OTbs, db, mir, xon,
-	lh#2, lm#78, lw#8, nlab#8, wsl#55,
-	cbt=\E[Z, clear=\E[x\E[J, cnorm=\E[11;0j, cub=\E[%p1%dD,
-	cud=\E[%p1%dB, cuf=\E[%p1%dC, cup=\E[%i%p1%d;%p2%dx,
-	cuu=\E[%p1%dA, cvvis=\E[11;1j, dch=\E[%p1%dP,
-	dl=\E[%p1%dM, ech=\E[%p1%ds\E[%p1%dD,
-	flash=\E[?5h$<200>\E[?5l, home=\E[x,
-	hpa=\E[%p1%{1}%+%dG, hts=\EH, ich=\E[%p1%d@, ich1@,
-	il=\E[%p1%dL, indn=\E[%p1%dE, is1=\E[?3l$<100>,
+	db,
+	lm#78, wsl#55,
+	clear=\E[x\E[J, cnorm=\E[11;0j, cub1=^H,
+	cup=\E[%i%p1%d;%p2%dx, cvvis=\E[11;1j,
+	ech=\E[%p1%ds\E[%p1%dD, flash=\E[?5h$<200>\E[?5l,
+	home=\E[x, ich1@, indn=\E[%p1%dE, is1=\E[?3l$<100>,
 	is2=\E[m\017\E[1;2;3;4;6l\E[12;13;14;20l\E[?6;97;99l\E[?7h
 	    \E[4i\Ex\E[21;1j\212,
 	is3=\E[?5l, kbeg=\Et, kcbt=\E[Z, kdch1=\E[P, kdl1=\E[M,
@@ -13367,14 +13940,14 @@ att4415|tty5420|att5420|AT&T 4415/5420 80 cols,
 	mc5=\E[?4i, mrcup=\E[%i%p1%d;%p2%dt,
 	pfx=\E[%p1%d;%p2%l%02dq   F%p1%d           %p2%s,
 	pln=\E[%p1%d;0;0;0q%p2%:-16.16s, prot=\EV,
-	rin=\E[%p1%dF, rmam=\E[?7l, rmir=\E[4l,
-	rmkx=\E[19;0j\E[21;1j\212, rmln=\E|,
+	rin=\E[%p1%dF, rmam=\E[?7l, rmkx=\E[19;0j\E[21;1j\212,
+	rmln=\E|,
 	sgr=\E[0%?%p1%p5%|%p6%|%t;2%;%?%p2%t;4%;%?%p4%t;5%;%?%p3%p1
 	    %|%p6%|%t;7%;%?%p7%t;8%;m%?%p8%t\EV%;%?%p9%t\016%e\017%;,
-	sgr0=\E[m\017, smam=\E[?7h, smir=\E[4h,
-	smkx=\E[19;1j\E[21;4j\Eent, smln=\E~, tbc=\E[3g,
-	tsl=\E7\E[25;%p1%{8}%+%dH, vpa=\E[%p1%{1}%+%dd,
-	use=att4410,
+	sgr0=\E[m\017, smam=\E[?7h, smkx=\E[19;1j\E[21;4j\Eent,
+	smln=\E~, tsl=\E7\E[25;%p1%{8}%+%dH, use=ansi+idc,
+	use=ansi+idl, use=ansi+inittabs, use=ansi+local,
+	use=ansi+rca, use=att4410,
 
 att4415-w|tty5420-w|att5420-w|AT&T 4415/5420 132 cols,
 	cols#132, lm#54, wsl#97,
@@ -13415,40 +13988,38 @@ att4415-w-rv-n|tty5420-w-rv-n|att5420-w-rv-n|AT&T 4415/5420 132 cols reverse wit
 
 att5420_2|AT&T 5420 model 2 80 cols,
 	am, db, hs, mir, msgr, xon,
-	cols#80, it#8, lh#2, lines#24, lm#78, lw#8, nlab#8, wsl#55,
+	cols#80, lh#2, lines#24, lm#78, lw#8, nlab#8, wsl#55,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	blink=\E[5m, cbt=\E[1Z, clear=\EH\EJ, cnorm=\E[11;0j,
-	cr=\EG, csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\E[1B, cuf=\E[%p1%dC, cuf1=\E[1C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[1A,
-	cvvis=\E[11;1j, dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m,
-	dl=\E[%p1%dM, dl1=\E[M, ech=\E[%p1%ds\E[%p1%dD, ed=\E[0J,
-	el=\E[0K, el1=\E[1K, flash=\E[?5h$<200>\E[?5l, fsl=\E8,
-	home=\E[H, hpa=\E[%p1%{1}%+%dG, ht=^I, hts=\EH,
-	ich=\E[%p1%d@, ich1=\E[@, il=\E[%p1%dL, il1=\E[L, ind=\n,
-	indn=\E[%p1%dE, invis=\E[8m,
+	cbt=\E[1Z, clear=\EH\EJ, cnorm=\E[11;0j, cr=\EG, cub1=^H,
+	cud1=\E[1B, cuf1=\E[1C, cup=\E[%i%p1%d;%p2%dH,
+	cuu1=\E[1A, cvvis=\E[11;1j, dch=\E[%p1%dP, dch1=\E[P,
+	ech=\E[%p1%ds\E[%p1%dD, ed=\E[0J, el=\E[0K, el1=\E[1K,
+	flash=\E[?5h$<200>\E[?5l, fsl=\E8, home=\E[H,
+	hpa=\E[%p1%{1}%+%dG, ich=\E[%p1%d@, ich1=\E[@, ind=\n,
+	indn=\E[%p1%dE,
 	is1=\E[0;23r\Ex\Ey\E[2;0j\E[3;3j\E[4;0j\E[5;0j\E[6;0j\E[7;0j
 	    \E[8;0j\E[9;1j\E[10;0j\E[15;0j\E[16;1j\E[19;0j\E[20;1j
 	    \E[29;0j\E[1;24r,
-	kbeg=\Et, kbs=^H, kcbt=\E[Z, kclr=\E[2J, kcub1=\E[D,
-	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kdch1=\E[P, kdl1=\E[M,
+	kbeg=\Et, kcbt=\E[Z, kclr=\E[2J, kdch1=\E[P, kdl1=\E[M,
 	kel=\E[2K, kend=\Ez, kent=\n, kf1=\EOc, kf2=\EOd, kf3=\EOe,
-	kf4=\EOf, kf5=\EOg, kf6=\EOh, kf7=\EOi, kf8=\EOj, khome=\E[H,
+	kf4=\EOf, kf5=\EOg, kf6=\EOh, kf7=\EOi, kf8=\EOj,
 	kich1=\E[4h, kil1=\E[L, kind=\E[T, kll=\Eu, knp=\E[U,
 	kpp=\E[V, kri=\E[S, lf1=F1, lf2=F2, lf3=F3, lf4=F4, lf5=F5,
 	lf6=F6, lf7=F7, lf8=F8, ll=\Ew, mc0=\E[?;2i, mc4=\E[4i,
 	mc5=\E[5i, mrcup=\E[%i%p1%d;%p2%dt, nel=\r\n,
 	pfx=\E[%p1%d;%p2%l%02dq\s\s\sF%p1%d\s\s\s\s\s\s\s\s\s\s\s%p2
 	    %s\E~,
-	pln=\E[%p1%d;0;0;0q%p2%:-16.16s\E~, prot=\EV, rc=\E8,
-	rev=\E[7m, ri=\EM, rin=\E[%p1%dF, rmacs=^O, rmkx=\E[19;0j,
-	rmln=\E|, rmso=\E[m, rmul=\E[m, rs2=\Ec\E[?3l\E[2;0y,
-	sc=\E7,
+	pln=\E[%p1%d;0;0;0q%p2%:-16.16s\E~, prot=\EV, ri=\EM,
+	rin=\E[%p1%dF, rmacs=^O, rmkx=\E[19;0j, rmln=\E|,
+	rs2=\Ec\E[?3l\E[2;0y,
 	sgr=\E[0%?%p1%p5%|%t;2%;%?%p2%p6%|%t;4%;%?%p4%t;5%;%?%p3%p1
 	    %|%p6%|%t;7%;%?%p7%t;8%;m%?%p9%t\016%e\017%;%?%p8%t\EV%;,
 	sgr0=\E[m\017, smacs=^N, smkx=\E[19;1j, smln=\E~,
-	smso=\E[7m, smul=\E[4m, tbc=\E[3g,
 	tsl=\E7\E[25;%p1%{8}%+%dH, vpa=\E[%p1%{1}%+%dd,
+	use=ansi+arrows, use=ansi+csr, use=ansi+idl,
+	use=ansi+inittabs, use=ansi+local, use=ansi+sgrdim,
+	use=decid+cpr,
+
 att5420_2-w|AT&T 5420 model 2 in 132 column mode,
 	cols#132,
 	is1=\E[0;23r\Ex\Ey\E[2;0j\E[3;3j\E[4;0j\E[5;1j\E[6;0j\E[7;0j
@@ -13460,35 +14031,34 @@ att4418|att5418|AT&T 5418 80 cols,
 	am, xon,
 	cols#80, lines#24,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, blink=\E[5m, clear=\E[H\E[2J, cr=\r, cub=\E[%p1%dD,
-	cub1=\E[D, cud=\E[%p1%dB, cud1=\E[B, cuf=\E[%p1%dC,
-	cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA,
-	cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[1P, dim=\E[2m,
-	dl=\E[%p1%dM, dl1=\E[M, ed=\E[0J, el=\E[0K, home=\E[H,
-	ich=\E[%p1%d@, ich1=\E[1@, il=\E[%p1%dL, il1=\E[1L, ind=\n,
-	is1=\E[?3l, is2=\E)0\E?6l\E?5l, kclr=\E[%%, kcub1=\E@,
-	kcud1=\EU, kcuf1=\EA, kcuu1=\ES, kent=\E[, kf1=\E[h,
-	kf10=\E[m, kf11=\E[n, kf12=\E[o, kf13=\E[H, kf14=\E[I,
-	kf15=\E[J, kf18=\E[K, kf19=\E[L, kf2=\E[i, kf20=\E[E,
-	kf21=\E[_, kf22=\E[M, kf23=\E[N, kf24=\E[O, kf3=\E[j,
-	kf6=\E[k, kf7=\E[l, kf8=\E[f, kf9=\E[w, khome=\Ec, rc=\E8,
-	rev=\E[7m, rmacs=^O, rmso=\E[m, rmul=\E[m, sc=\E7,
-	sgr0=\E[m\017, smacs=^N, smso=\E[7m, smul=\E[4m,
+	bel=^G, blink=\E[5m, clear=\E[H\E[2J, cr=\r,
+	cup=\E[%i%p1%d;%p2%dH, dch=\E[%p1%dP, dch1=\E[1P,
+	dim=\E[2m, ed=\E[0J, el=\E[0K, home=\E[H, ich=\E[%p1%d@,
+	ich1=\E[1@, il1=\E[1L, ind=\n, is1=\E[?3l,
+	is2=\E)0\E?6l\E?5l, kclr=\E[%%, kcub1=\E@, kcud1=\EU,
+	kcuf1=\EA, kcuu1=\ES, kent=\E[, kf1=\E[h, kf10=\E[m,
+	kf11=\E[n, kf12=\E[o, kf13=\E[H, kf14=\E[I, kf15=\E[J,
+	kf18=\E[K, kf19=\E[L, kf2=\E[i, kf20=\E[E, kf21=\E[_,
+	kf22=\E[M, kf23=\E[N, kf24=\E[O, kf3=\E[j, kf6=\E[k,
+	kf7=\E[l, kf8=\E[f, kf9=\E[w, khome=\Ec, rc=\E8, rev=\E[7m,
+	rmacs=^O, rmso=\E[m, rmul=\E[m, sc=\E7, sgr0=\E[m\017,
+	smacs=^N, smso=\E[7m, smul=\E[4m, use=ansi+idl,
+	use=ansi+local,
+
 att4418-w|att5418-w|AT&T 5418 132 cols,
 	cols#132,
 	is1=\E[?3h, use=att5418,
 
-att4420|tty4420|teletype 4420,
+att4420|tty4420|Teletype 4420,
 	OTbs, da, db, eo, msgr, ul, xon,
 	cols#80, lines#24, lm#72,
 	bel=^G, clear=\EH\EJ, cr=\EG, cub1=\ED, cud1=\EB, cuf1=\EC,
 	cup=\EY%p1%{32}%+%c%p2%{32}%+%c, cuu1=\EA, dch1=\EP,
 	dl1=\EM, ed=\EJ, el=\Ez, home=\EH, il1=\EL, ind=\EH\EM\EY7\s,
-	kcbt=\EO, kclr=\EJ, kcub1=^H, kcud1=\EB, kcuf1=\EC,
-	kcuu1=\EA, kdch1=\EP, kdl1=\EM, kf0=\EU, kf3=\E@, khome=\EH,
-	kich1=\E\^, kil1=\EL, kind=\ES, kri=\ET,
+	kcbt=\EO, kclr=\EJ, kcub1=^H, kdch1=\EP, kdl1=\EM, kf0=\EU,
+	kf3=\E@, khome=\EH, kich1=\E\^, kil1=\EL, kind=\ES, kri=\ET,
 	lf0=segment advance, lf3=cursor tab, rmdc@, rmso=\E~,
-	rmul=\EZ, smdc@, smso=\E}, smul=\E\\,
+	rmul=\EZ, smdc@, smso=\E}, smul=\E\\, use=vt52+arrows,
 
 #  The following is a terminfo entry for the Teletype 4424
 #  asynchronous keyboard-display terminal.  It supports
@@ -13505,27 +14075,24 @@ att4420|tty4420|teletype 4420,
 # The terminal has either bold or blink, depending on options
 #
 # (att4424: commented out <smcup>=\E[1m, we don't need bright locked on -- esr)
-att4424|tty4424|teletype 4424,
+att4424|tty4424|Teletype 4424,
 	OTbs, am, xon,
 	cols#80, lines#24,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
 	bel=^G, blink=\E3, bold=\E3, cbt=\EO, clear=\E[H\E[2J, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\EB, cuf=\E[%p1%dC, cuf1=\EC,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\EA,
-	dch=\E[%p1%dP, dch1=\EP, dim=\EW, dl=\E[%p1%dM, dl1=\EM,
-	ed=\EJ, el=\Ez, home=\E[H, ht=^I, hts=\EH, ich=\E[%p1%d@,
-	ich1=\E\^, il=\E[%p1%dL, il1=\EL, ind=\n, is2=\E[20l\E[?7h,
-	kbs=^H, kclr=\EJ, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C,
-	kcuu1=\E[A, kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS,
-	khome=\E[H, nel=\EE, rev=\E}, ri=\ET, rmacs=\E(B, rmso=\E~,
-	rmul=\EZ,
+	csr=\E[%i%p1%d;%p2%dr, cub1=^H, cud1=\EB, cuf1=\EC,
+	cup=\E[%i%p1%d;%p2%dH, cuu1=\EA, dch=\E[%p1%dP, dch1=\EP,
+	dim=\EW, dl=\E[%p1%dM, dl1=\EM, ed=\EJ, el=\Ez, home=\E[H,
+	ht=^I, hts=\EH, ich=\E[%p1%d@, ich1=\E\^, il=\E[%p1%dL,
+	il1=\EL, ind=\n, is2=\E[20l\E[?7h, kclr=\EJ, kf1=\EOP,
+	kf2=\EOQ, kf3=\EOR, kf4=\EOS, nel=\EE, rev=\E}, ri=\ET,
+	rmacs=\E(B, rmso=\E~, rmul=\EZ,
 	sgr=\EX\E~\EZ\E4\E(B%?%p1%p3%|%t\E}%;%?%p2%t\E\\%;%?%p4%p6%|
 	    %t\E3%;%?%p5%t\EW%;%?%p9%t\E(0%;,
 	sgr0=\EX\E~\EZ\E4\E(B, smacs=\E(0, smso=\E}, smul=\E\\,
-	tbc=\EF,
+	tbc=\EF, use=ansi+arrows, use=ansi+local,
 
-att4424-1|tty4424-1|teletype 4424 in display function group I,
+att4424-1|tty4424-1|Teletype 4424 in display function group I,
 	kclr@, kcub1=\ED, kcud1=\EB, kcuf1=\EC, kcuu1=\EA, khome@,
 	use=att4424,
 
@@ -13535,16 +14102,15 @@ att4424-1|tty4424-1|teletype 4424 in display function group I,
 # The following two lines are the comment originally attached to the entry:
 # This entry appears to avoid the top line - I have no idea why.
 # From: jwb Wed Mar 31 13:25:09 1982 remote from ihuxp
-att4424m|tty4424m|teletype 4424M,
+att4424m|tty4424m|Teletype 4424M,
 	am, da, db, mir,
 	cols#80, it#8, lines#23,
 	bel=^G, clear=\E[2;H\E[J, cr=\r, cub1=^H, cud1=\n, cuf1=\E[C,
 	cup=\E[%i%p1%2d;%p2%2dH\E[B, cuu1=\E[A, dch1=\EP,
 	dl1=\EM, el=\E[K, ht=^I, ich1=\E\^, il1=\EL, ind=\n, ip=$<2/>,
-	is2=\E[m\E[2;24r, kbs=^H, kcub1=\E[D, kcud1=\E[B,
-	kcuf1=\E[C, kcuu1=\E[A, kf1=\EOP, kf2=\EOQ, kf3=\EOR,
-	kf4=\EOS, khome=\E[H, nel=\r\n, ri=\ET, rmso=\E[m, rmul=\E[m,
-	sgr0=\E[m, smso=\E[7m, smul=\E[4m,
+	is2=\E[m\E[2;24r, kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS,
+	nel=\r\n, ri=\ET, rmso=\E[m, rmul=\E[m, sgr0=\E[m,
+	smso=\E[7m, smul=\E[4m, use=ansi+arrows,
 
 # The Teletype 5425 is really version 2 of the Teletype 5420. It
 # is quite similar, except for some minor differences. No page
@@ -13556,70 +14122,59 @@ att4424m|tty4424m|teletype 4424M,
 #
 # (att5425: added <rmam>/<smam> based on the init string -- esr)
 att5425|tty5425|att4425|AT&T 4425/5425,
-	am, da, db, hs, mir, msgr, xenl, xon,
-	cols#80, it#8, lh#2, lines#24, lm#78, lw#8, nlab#8, wsl#55,
-	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[2;7m, cbt=\E[Z,
-	clear=\E[H\E[J, cnorm=\E[12;0j, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	cvvis=\E[12;1j, dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m,
-	dl=\E[%p1%dM, dl1=\E[M, ech=\E[%p1%ds\E[%p1%dD, ed=\E[J,
-	el=\E[K, el1=\E[1K, enacs=\E(B\E)0,
-	flash=\E[?5h$<200>\E[?5l, fsl=\E8, home=\E[H,
-	hpa=\E[%p1%{1}%+%dG, ht=^I, hts=\EH, ich=\E[%p1%d@,
-	il=\E[%p1%dL, il1=\E[L, ind=\n, indn=\E[%p1%dE,
-	invis=\E[8m, is1=\E<\E[?3l$<100>,
+	da, db, hs, mir, xenl, xon,
+	lh#2, lm#78, lw#8, nlab#8, wsl#55,
+	bold=\E[2;7m, cnorm=\E[12;0j, cub1=^H, cud1=\n,
+	cup=\E[%i%p1%d;%p2%dH, cvvis=\E[12;1j, dch=\E[%p1%dP,
+	dch1=\E[P, dim=\E[2m, ech=\E[%p1%ds\E[%p1%dD, el1=\E[1K,
+	flash=\E[?5h$<200>\E[?5l, fsl=\E8, hpa=\E[%p1%{1}%+%dG,
+	ich=\E[%p1%d@, indn=\E[%p1%dE, is1=\E<\E[?3l$<100>,
 	is2=\E[m\017\E[1;2;3;4;6l\E[12;13;14;20l\E[?6;97;99l\E[?7h
 	    \E[4i\Ex\E[25;1j\212,
-	is3=\E[?5l, kbeg=\Et, kbs=^H, kcbt=\E[Z, kclr=\E[J,
-	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kdch1=\E[P,
+	is3=\E[?5l, kbeg=\Et, kcbt=\E[Z, kclr=\E[J, kdch1=\E[P,
 	kdl1=\E[M, kel=\E[2K, kend=\Ez, kent=\Eent, kf1=\EOc,
 	kf2=\EOd, kf3=\EOe, kf4=\EOf, kf5=\EOg, kf6=\EOh, kf7=\EOi,
-	kf8=\EOj, khome=\E[H, kich1=\E[4h, kil1=\E[L, kind=\E[T,
-	kri=\E[S, ll=\E[24H, mc0=\E[?2i, mc4=\E[?9i, mc5=\E[?4i,
-	nel=\r\n,
+	kf8=\EOj, kich1=\E[4h, kil1=\E[L, kind=\E[T, kri=\E[S,
+	ll=\E[24H, mc0=\E[?2i, mc4=\E[?9i, mc5=\E[?4i, nel=\r\n,
 	pfx=\E[%p1%d;%p2%l%02dq   F%p1%1d           %p2%s,
-	pln=\E[%p1%d;0;0;0q%p2%:-16.16s, prot=\EV, rc=\E8,
-	rev=\E[7m, ri=\EM, rin=\E[%p1%dF, rmacs=^O, rmam=\E[?7l,
-	rmir=\E[4l, rmkx=\E[21;0j\E[25;1j\212, rmln=\E|,
-	rmso=\E[m, rmul=\E[m, rs2=\Ec\E[?3l\E[2;0y, sc=\E7,
+	pln=\E[%p1%d;0;0;0q%p2%:-16.16s, prot=\EV, ri=\EM,
+	rin=\E[%p1%dF, rmam=\E[?7l, rmir=\E[4l,
+	rmkx=\E[21;0j\E[25;1j\212, rmln=\E|,
+	rs2=\Ec\E[?3l\E[2;0y,
 	sgr=\E[0%?%p5%p6%|%t;2%;%?%p2%t;4%;%?%p4%t;5%;%?%p3%p1%|%p6
 	    %|%t;7%;%?%p7%t;8%;m%?%p8%t\EV%;%?%p9%t\016%e\017%;,
-	sgr0=\E[m\017, smacs=^N, smam=\E[?7h, smir=\E[4h,
-	smkx=\E[21;1j\E[25;4j\Eent\E~, smln=\E~, smso=\E[7m,
-	smul=\E[4m, tbc=\E[3g, tsl=\E7\E[25;%p1%{8}%+%dH,
-	vpa=\E[%p1%{1}%+%dd,
+	sgr0=\E[m\017, smam=\E[?7h, smir=\E[4h,
+	smkx=\E[21;1j\E[25;4j\Eent\E~, smln=\E~,
+	tsl=\E7\E[25;%p1%{8}%+%dH, vpa=\E[%p1%{1}%+%dd,
+	use=ansi+arrows, use=ansi+csr, use=ansi+erase,
+	use=ansi+idl, use=ansi+inittabs, use=ansi+local,
+	use=ansi+sgrbold, use=decid+cpr, use=vt100+4bsd,
 
 att5425-nl|tty5425-nl|att4425-nl|AT&T 4425/5425 80 columns no labels,
 	smkx=\E[21;1j\E[25;4j\Eent, use=att4425,
 
-att5425-w|att4425-w|tty5425-w|teletype 4425/5425 in 132 column mode,
+att5425-w|att4425-w|tty5425-w|Teletype 4425/5425 in 132 column mode,
 	cols#132, lm#54, wsl#97,
 	is1=\E[?3h$<100>, use=tty5425,
 
 # (att4426: his had bogus capabilities: :ri=\EM:, :ri=\E[1U:.
 # I also added <rmam>/<smam> -- esr)
-att4426|tty4426|teletype 4426S,
+att4426|tty4426|Teletype 4426S,
 	am, da, db, xon,
 	cols#80, lines#24, lm#48,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
 	bel=^G, bold=\E[5m, clear=\E[H\E[2J\E[1U\E[H\E[2J\E[1V,
-	cr=\r, cub=\E[%p1%dD, cub1=\E[D, cud=\E[%p1%dB, cud1=\E[B,
-	cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
-	cuu=\E[%p1%dA, cuu1=\E[A, dch=\E[%p1%dP, dch1=\EP,
-	dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[0K, home=\E[H,
-	hpa=\E[%p1%dG, ht=^I, hts=\E1, ich=\E[%p1%d@, ich1=\E\^,
-	il=\E[%p1%dL, il1=\EL, ind=\n, is1=\Ec\E[?7h,
-	is2=\E[m\E[1;24r, kbs=^H, kcbt=\EO, kclr=\E[2J, kcub1=\ED,
-	kcud1=\EB, kcuf1=\EC, kcuu1=\EA, kf1=\EOP, kf2=\EOQ,
-	kf3=\EOR, kf4=\EOS, kf5=\EOT, kf6=\EOU, kf7=\EOV, kf8=\EOW,
-	khome=\E[H, kll=\E[24;1H, ll=\E[24H, nel=\r\n, rc=\E8,
-	rev=\E[7m, ri=\ET, rmacs=\E(B, rmam=\E[?7l, rmso=\E[m,
-	rmul=\E[m, rs2=\Ec\E[?3l\E[2;0y, sc=\E7, sgr0=\E[m\E(B,
-	smacs=\E(0, smam=\E[?7h, smso=\E[5m, smul=\E[4m, tbc=\E[3g,
-	vpa=\E[%p1%dd, use=ecma+index,
+	cr=\r, cup=\E[%i%p1%d;%p2%dH, dch=\E[%p1%dP, dch1=\EP,
+	ed=\E[J, el=\E[0K, home=\E[H, hpa=\E[%p1%dG, ht=^I, hts=\E1,
+	ich=\E[%p1%d@, ich1=\E\^, il1=\EL, ind=\n, is1=\Ec\E[?7h,
+	is2=\E[m\E[1;24r, kbs=^H, kcbt=\EO, kclr=\E[2J, kf1=\EOP,
+	kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf5=\EOT, kf6=\EOU, kf7=\EOV,
+	kf8=\EOW, khome=\E[H, kll=\E[24;1H, ll=\E[24H, nel=\r\n,
+	rc=\E8, rev=\E[7m, ri=\ET, rmacs=\E(B, rmam=\E[?7l,
+	rmso=\E[m, rmul=\E[m, rs2=\Ec\E[?3l\E[2;0y, sc=\E7,
+	sgr0=\E[m\E(B, smacs=\E(0, smam=\E[?7h, smso=\E[5m,
+	smul=\E[4m, tbc=\E[3g, vpa=\E[%p1%dd, use=ansi+idl,
+	use=ansi+local, use=ecma+index, use=vt52+arrows,
 
 # Terminfo entry for the AT&T 510 A Personal Terminal
 # Function keys 9 - 16 are available only after the
@@ -13633,26 +14188,25 @@ att510a|bct510a|AT&T 510A Personal Terminal,
 	am, mir, msgr, xenl, xon,
 	cols#80, lh#2, lines#24, lw#7, nlab#8,
 	acsc=+g\,h-f.e`bhrisjjkkllmmnnqqttuuvvwwxx{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[2;7m, cbt=\E[Z,
-	civis=\E[11;0|, clear=\E[H\E[J, cnorm=\E[11;3|, cr=\r,
-	cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\E[B,
-	cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
-	cuu=\E[%p1%dA, cuu1=\E[A, cvvis=\E[11;2|, dch=\E[%p1%dP,
-	dch1=\E[P, dim=\E[2m, dl=\E[%p1%dM, dl1=\E[M, ed=\E[0J,
-	el=\E[0K, el1=\E[1K, enacs=\E(B\E)1, ff=^L, home=\E[H, ht=^I,
-	hts=\EH, il=\E[%p1%dL, il1=\E[L, ind=\n, is1=\E(B\E)1\E[2l,
-	is3=\E[21;1|\212, kLFT=\E[u, kRIT=\E[v, kbs=^H, kcbt=\E[Z,
-	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kf1=\EOm,
-	kf10=\EOd, kf11=\EOe, kf12=\EOf, kf13=\EOg, kf14=\EOh,
-	kf15=\EOi, kf16=\EOj, kf2=\EOV, kf3=\EOu, kf4=\ENj, kf5=\ENe,
-	kf6=\ENf, kf7=\ENh, kf8=\E[H, kf9=\EOc, kind=\E[S, kri=\E[T,
-	mc0=\E[0i, mc4=\E[?8i, mc5=\E[?4i, nel=\EE,
-	pln=\E[%p1%dp%p2%:-16s, rc=\E8, rev=\E[7m, ri=\EM,
-	rmacs=^O, rmkx=\E[19;0|, rmso=\E[m, rmul=\E[m, sc=\E7,
+	bel=^G, blink=\E[5m, bold=\E[2;7m, civis=\E[11;0|,
+	clear=\E[H\E[J, cnorm=\E[11;3|, cr=\r, cub1=^H,
+	cup=\E[%i%p1%d;%p2%dH, cvvis=\E[11;2|, dch=\E[%p1%dP,
+	dch1=\E[P, dim=\E[2m, ed=\E[0J, el=\E[0K, el1=\E[1K,
+	enacs=\E(B\E)1, ff=^L, home=\E[H, ind=\n,
+	is1=\E(B\E)1\E[2l, is3=\E[21;1|\212, kLFT=\E[u,
+	kRIT=\E[v, kbs=^H, kcbt=\E[Z, kcub1=\E[D, kcud1=\E[B,
+	kcuf1=\E[C, kcuu1=\E[A, kf1=\EOm, kf10=\EOd, kf11=\EOe,
+	kf12=\EOf, kf13=\EOg, kf14=\EOh, kf15=\EOi, kf16=\EOj,
+	kf2=\EOV, kf3=\EOu, kf4=\ENj, kf5=\ENe, kf6=\ENf, kf7=\ENh,
+	kf8=\E[H, kf9=\EOc, kind=\E[S, kri=\E[T, mc0=\E[0i,
+	mc4=\E[?8i, mc5=\E[?4i, nel=\EE, pln=\E[%p1%dp%p2%:-16s,
+	rc=\E8, rev=\E[7m, ri=\EM, rmacs=^O, rmkx=\E[19;0|,
+	rmso=\E[m, rmul=\E[m, sc=\E7,
 	sgr=\E[0%?%p5%p6%|%t;2%;%?%p2%t;4%;%?%p4%t;5%;%?%p3%p1%|%p6
 	    %|%t;7%;m%?%p9%t\016%e\017%;,
 	sgr0=\E[m\017, smacs=^N, smkx=\E[19;1|, smso=\E[7m,
-	smul=\E[4m, tbc=\E[3g,
+	smul=\E[4m, use=ansi+cpr, use=ansi+idl, use=ansi+local,
+	use=ansi+tabs,
 
 # Terminfo entry for the AT&T 510 D Personal Terminal
 # Function keys 9 through 16 are accessed by bringing up the
@@ -13667,60 +14221,52 @@ att510d|bct510d|AT&T 510D Personal Terminal,
 	am, da, db, mir, msgr, xenl, xon,
 	cols#80, lh#2, lines#24, lm#48, lw#7, nlab#8,
 	acsc=+g\,h-f.e`bhrisjjkkllmmnnqqttuuvvwwxx{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[2;7m, cbt=\E[Z,
-	clear=\E[H\E[J, cnorm=\E[11;3|, cr=\r, cub=\E[%p1%dD,
-	cub1=^H, cud=\E[%p1%dB, cud1=\E[B, cuf=\E[%p1%dC,
-	cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA,
-	cuu1=\E[A, cvvis=\E[11;2|, dch=\E[%p1%dP, dch1=\E[P,
-	dim=\E[2m, dl=\E[%p1%dM, dl1=\E[M, ed=\E[0J, el=\E[0K,
+	bel=^G, bold=\E[2;7m, clear=\E[H\E[J, cnorm=\E[11;3|,
+	cr=\r, cub1=^H, cup=\E[%i%p1%d;%p2%dH, cvvis=\E[11;2|,
+	dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m, ed=\E[0J, el=\E[0K,
 	el1=\E[1K, enacs=\E(B\E)1, ff=^L, home=\E[H,
-	hpa=\E[%p1%{1}%+%dG, ht=^I, hts=\EH, ich=\E[%p1%d@,
-	il=\E[%p1%dL, il1=\E[L, ind=\n, invis=\E[8m,
+	hpa=\E[%p1%{1}%+%dG, ich=\E[%p1%d@, ind=\n,
 	is1=\E(B\E)1\E[5;0|, is3=\E[21;1|\212, kLFT=\E[u,
 	kRIT=\E[v, kbs=^H, kcbt=\E[Z, kcub1=\E[D, kcud1=\E[B,
 	kcuf1=\E[C, kcuu1=\E[A, kf1=\EOm, kf10=\EOd, kf11=\EOe,
 	kf12=\EOf, kf13=\EOg, kf14=\EOh, kf15=\EOi, kf16=\EOj,
 	kf2=\EOV, kf3=\EOu, kf4=\ENj, kf5=\ENe, kf6=\ENf, kf7=\ENh,
 	kf8=\E[H, kf9=\EOc, kind=\E[S, kri=\E[T, ll=\E#2, mc0=\E[0i,
-	mc4=\E[?8i, mc5=\E[?4i, mgc=\E\:, nel=\EE,
-	pln=\E[%p1%dp%p2%:-16s, rc=\E8, rev=\E[7m, ri=\EM,
-	rmacs=^O, rmir=\E[4l, rmkx=\E[19;0|, rmln=\E<, rmso=\E[m,
-	rmul=\E[m, rmxon=\E[29;1|, rs2=\E[5;0|, sc=\E7,
+	mc4=\E[?8i, mc5=\E[?4i, mgc=\E:, nel=\EE,
+	pln=\E[%p1%dp%p2%:-16s, rc=\E8, ri=\EM, rmacs=^O,
+	rmir=\E[4l, rmkx=\E[19;0|, rmln=\E<, rmxon=\E[29;1|,
+	rs2=\E[5;0|, sc=\E7,
 	sgr=\E[0%?%p5%p6%|%t;2%;%?%p2%t;4%;%?%p4%t;5%;%?%p3%p1%|%p6
 	    %|%t;7%;%?%p7%t;8%;m%?%p9%t\016%e\017%;,
 	sgr0=\E[m\017, smacs=^N, smgl=\E4, smgr=\E5, smir=\E[4h,
-	smkx=\E[19;1|, smln=\E?, smso=\E[7m, smul=\E[4m,
-	smxon=\E[29;0|, tbc=\E[3g, vpa=\E[%p1%{1}%+%dd,
-	use=ansi+rep, use=ecma+index,
+	smkx=\E[19;1|, smln=\E?, smxon=\E[29;0|,
+	vpa=\E[%p1%{1}%+%dd, use=ansi+cpr, use=ansi+idl,
+	use=ansi+local, use=ansi+rep, use=ansi+sgrbold,
+	use=ansi+tabs, use=ecma+index,
 
 # (att500: I merged this with the att513 entry, att500 just used att513 -- esr)
 att500|att513|AT&T 513 using page mode,
 	am, chts, mir, msgr, xenl, xon,
 	cols#80, lh#2, lines#24, lw#8, nlab#8,
 	acsc=+g\,h-f.e`bhrisjjkkllmmnnqqttuuvvwwxx{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[2;7m, cbt=\E[Z,
-	clear=\E[H\E[J, cnorm=\E[11;0|, cr=\r,
-	csr=%i\E[%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	cvvis=\E[11;1|, dch=\E[%p1%dP, dch1=\E[P$<1>, dim=\E[2m,
-	dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K, el1=\E[1K,
-	enacs=\E(B\E)1, home=\E[H, hpa=\E[%p1%{1}%+%dG, ht=^I,
-	hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L, ind=\n,
-	indn=\E[%p1%dE, invis=\E[8m,
+	bel=^G, bold=\E[2;7m, cnorm=\E[11;0|, cr=\r,
+	csr=%i\E[%p1%d;%p2%dr, cub1=^H, cud1=\n,
+	cup=\E[%i%p1%d;%p2%dH, cvvis=\E[11;1|, dch=\E[%p1%dP,
+	dch1=\E[P$<1>, dim=\E[2m, el1=\E[1K, enacs=\E(B\E)1,
+	home=\E[H, hpa=\E[%p1%{1}%+%dG, ich=\E[%p1%d@, ind=\n,
+	indn=\E[%p1%dE,
 	is1=\E?\E[3;3|\E[10;0|\E[21;1|\212\E[6;1|\E[1{\E[?99l,
 	kBEG=\ENB, kCAN=\EOW, kCMD=\EOU, kCPY=\END, kCRT=\EON,
 	kDC=\ENF, kDL=\ENE, kEND=\ENN, kEOL=\EOA, kEXT=\EOK,
 	kFND=\EOX, kHLP=\EOM, kHOM=\ENM, kIC=\ENJ, kLFT=\ENK,
 	kMOV=\ENC, kMSG=\EOL, kNXT=\ENH, kOPT=\EOR, kPRT=\EOZ,
 	kPRV=\ENG, kRDO=\EOT, kRES=\EOQ, kRIT=\ENL, kRPL=\EOY,
-	kSAV=\EOO, kSPD=\EOP, kUND=\EOS, kbeg=\E9, kbs=^H, kcan=\EOw,
+	kSAV=\EOO, kSPD=\EOP, kUND=\EOS, kbeg=\E9, kcan=\EOw,
 	kcbt=\E[Z, kclo=\EOV, kclr=\E[J, kcmd=\EOu, kcpy=\ENd,
-	kcrt=\EOn, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
-	kdch1=\ENf, kdl1=\ENe, kel=\EOa, kend=\E0, kent=\Eent,
-	kext=\EOk, kf1=\EOc, kf2=\EOd, kf3=\EOe, kf4=\EOf, kf5=\EOg,
-	kf6=\EOh, kf7=\EOi, kf8=\EOj, kfnd=\EOx, khlp=\EOm,
-	khome=\E[H, kich1=\ENj, kind=\E[S, kmov=\ENc, kmrk=\ENi,
+	kcrt=\EOn, kdch1=\ENf, kdl1=\ENe, kel=\EOa, kend=\E0,
+	kent=\Eent, kext=\EOk, kf1=\EOc, kf2=\EOd, kf3=\EOe,
+	kf4=\EOf, kf5=\EOg, kf6=\EOh, kf7=\EOi, kf8=\EOj, kfnd=\EOx,
+	khlp=\EOm, kich1=\ENj, kind=\E[S, kmov=\ENc, kmrk=\ENi,
 	kmsg=\EOl, knp=\E[U, knxt=\ENh, kopn=\EOv, kopt=\EOr,
 	kpp=\E[V, kprt=\EOz, kprv=\ENg, krdo=\EOt, kref=\EOb,
 	kres=\EOq, krfr=\ENa, kri=\E[T, krpl=\EOy, krst=\EOB,
@@ -13732,20 +14278,21 @@ att500|att513|AT&T 513 using page mode,
 	pfloc=\E[%p1%d;%p2%l%d;2;0p\s\s\sF%p1%d\s\s\s\s\s\s\s\s\s\s
 	      \s%p2%s,
 	pfx=\E[%p1%d;%p2%l%d;1;0p   F%p1%d           %p2%s,
-	pln=\E[%p1%dp%p2%:-16s, rc=\E8, rev=\E[7m, ri=\EM,
-	rin=\E[%p1%dF, rmacs=^O, rmir=\E[4l,
-	rmkx=\E[19;0|\E[21;1|\212, rmln=\E<, rmso=\E[m,
-	rmul=\E[m,
+	pln=\E[%p1%dp%p2%:-16s, rc=\E8, ri=\EM, rin=\E[%p1%dF,
+	rmacs=^O, rmir=\E[4l, rmkx=\E[19;0|\E[21;1|\212,
+	rmln=\E<,
 	rs1=\E?\E[3;3|\E[10;0|\E[21;1|\212\E[6;1|\E[1{\E[?99l\E[2;0|
 	    \E[6;1|\E[8;0|\E[19;0|\E[1{\E[?99l,
 	rs2=\E[5;0|, sc=\E7,
 	sgr=\E[0%?%p1%p5%|%p6%|%t;2%;%?%p2%t;4%;%?%p4%t;5%;%?%p3%p1
 	    %|%p6%|%t;7%;%?%p7%t;8%;m%?%p9%t\016%e\017%;,
 	sgr0=\E[m\017, smacs=^N, smir=\E[4h,
-	smkx=\E[19;1|\E[21;4|\Eent, smln=\E?, smso=\E[7m,
-	smul=\E[4m, tbc=\E[3g, vpa=\E[%p1%{1}%+%dd, use=ansi+rep,
+	smkx=\E[19;1|\E[21;4|\Eent, smln=\E?,
+	vpa=\E[%p1%{1}%+%dd, use=ansi+arrows, use=ansi+erase,
+	use=ansi+idl, use=ansi+local, use=ansi+rep,
+	use=ansi+sgrbold, use=ansi+tabs, use=decid+cpr,
 
-# 01-07-88
+# 01-07-88:
 # printer must be set to EMUL ANSI to accept ESC codes
 # <cuu1> stops at top margin
 # <is1> sets cpi 10,lpi 6,form 66,left 1,right 132,top 1,bottom 66,font
@@ -13793,13 +14340,12 @@ att5310|att5320|AT&T Model 53210 or 5320 matrix printer,
 att5620-1|tty5620-1|dmd1|Teletype 5620 with old ROMs,
 	am, xon,
 	cols#88, it#8, lines#70, vt#3,
-	bel=^G, clear=\E[H\E[J, cr=\r, cub1=^H, cud1=\n, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, dch=\E[%p1%dP,
-	dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K,
-	home=\E[H, ht=^I, ich=\E[%p1%d@, ich1=\E[@, il=\E[%p1%dL,
-	il1=\E[L, ind=\n, kbs=^H, kclr=\E[2J, kcub1=\E[D, kcud1=\E[B,
-	kcuf1=\E[C, kcuu1=\E[A, khome=\E[H, kll=\E[70;1H, nel=\r\n,
-	rc=\E8, ri=\E[T, rs1=\Ec, sc=\E7, use=ecma+index,
+	bel=^G, cr=\r, cub1=^H, cud1=\n, cup=\E[%i%p1%d;%p2%dH,
+	dch=\E[%p1%dP, dch1=\E[P, home=\E[H, ht=^I, ich=\E[%p1%d@,
+	ich1=\E[@, ind=\n, kclr=\E[2J, kll=\E[70;1H, nel=\r\n,
+	rc=\E8, ri=\E[T, rs1=\Ec, sc=\E7, use=ansi+arrows,
+	use=ansi+erase, use=ansi+idl, use=ansi+local1,
+	use=ecma+index,
 
 # 5620 terminfo  (2.0 or later ROMS with char attributes)
 # The following SET-UP modes are assumed for normal operation:
@@ -13813,32 +14359,30 @@ att5620-1|tty5620-1|dmd1|Teletype 5620 with old ROMs,
 # <msgr> is from an otherwise inferior BRL for this terminal.  That entry
 # also has <ll>=\E[70H commented out and marked unsafe.
 # For more, see the 5620 FAQ maintained by David Breneman <daveb@dgtl.com>.
-att5620|dmd|tty5620|ttydmd|5620|5620 terminal 88 columns,
+att5620|dmd|tty5620|ttydmd|5620|AT&T 5620 terminal 88 columns,
 	OTbs, am, msgr, npc, xon,
 	cols#88, it#8, lines#70,
-	bel=^G, bold=\E[2m, clear=\E[H\E[J, cr=\r, cub1=^H,
-	cud1=\E[B, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m, dl=\E[%p1%dM,
-	dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H, ht=^I, ich=\E[%p1%d@,
-	ich1=\E[@, il=\E[%p1%dL, il1=\E[L, ind=\E[S, kbs=^H,
-	kclr=\E[2J, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
-	khome=\E[H, kll=\E[70;1H, nel=\n,
-	pfx=\E[%p1%d;%p2%l%dq%p2%s, rc=\E8, rev=\E[7m, ri=\E[T,
-	rmso=\E[0m, rmul=\E[0m, rs1=\Ec, sc=\E7, sgr0=\E[0m,
-	smso=\E[7m, smul=\E[4m, use=ecma+index,
-att5620-24|tty5620-24|dmd-24|teletype dmd 5620 in a 24x80 layer,
+	bel=^G, bold=\E[2m, cr=\r, cub1=^H, cup=\E[%i%p1%d;%p2%dH,
+	dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m, home=\E[H, ht=^I,
+	ich=\E[%p1%d@, ich1=\E[@, ind=\E[S, kclr=\E[2J,
+	kll=\E[70;1H, nel=\n, pfx=\E[%p1%d;%p2%l%dq%p2%s, rc=\E8,
+	rev=\E[7m, ri=\E[T, rmso=\E[0m, rmul=\E[0m, rs1=\Ec, sc=\E7,
+	sgr0=\E[0m, smso=\E[7m, smul=\E[4m, use=ansi+arrows,
+	use=ansi+erase, use=ansi+idl, use=ansi+local1,
+	use=ecma+index,
+
+att5620-24|tty5620-24|dmd-24|Teletype dmd 5620 in a 24x80 layer,
 	lines#24, use=att5620,
-att5620-34|tty5620-34|dmd-34|teletype dmd 5620 in a 34x80 layer,
+att5620-34|tty5620-34|dmd-34|Teletype dmd 5620 in a 34x80 layer,
 	lines#34, use=att5620,
 # 5620 layer running the "S" system's downloaded graphics handler:
-att5620-s|tty5620-s|layer|vitty|5620 S layer,
+att5620-s|tty5620-s|layer|vitty|AT&T 5620 S layer,
 	OTbs, OTpt, am,
 	cols#80, it#8, lines#72,
 	bel=^G, clear=^L, cr=\r, cub1=^H, cud1=\n,
 	cup=\EY%p2%{32}%+%c%p1%{32}%+%c, cuu1=^K, dl1=\ED,
-	el=\EK, flash=\E^G, ht=^I, il1=\EI, ind=\n, kbs=^H, kclr=\E[2J,
-	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, khome=\E[H,
-	kll=\E[70;1H,
+	el=\EK, flash=\E^G, ht=^I, il1=\EI, ind=\n, kclr=\E[2J,
+	khome=\E[H, kll=\E[70;1H, use=ansi+arrows,
 
 # Entries for <kf15> thru <kf28> refer to the shifted system pf keys.
 #
@@ -13848,15 +14392,11 @@ att605|AT&T 605 80 column 102key keyboard,
 	am, eo, xon,
 	cols#80, lines#24, lw#8, nlab#8, wsl#80,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, clear=\E[H\E[J,
-	cr=\r, cub1=^H, cud1=\E[B, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, dch=\E[%p1%dP,
-	dch1=\E[P, dim=\E[2m, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J,
-	el=\E[K, el1=\E[1K, fsl=\E8, ht=^I, ich=\E[%p1%d@, ich1=\E[@,
-	il1=\E[L, ind=\n, invis=\E[8m,
+	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, cr=\r, cub1=^H,
+	cup=\E[%i%p1%d;%p2%dH, dim=\E[2m, dl=\E[%p1%dM, dl1=\E[M,
+	el1=\E[1K, fsl=\E8, ht=^I, il1=\E[L, ind=\n, invis=\E[8m,
 	is1=\E[8;0|\E[?\E[13;20l\E[?\E[12h, is2=\E[m\017,
-	kLFT=\E[ A, kRIT=\E[ @, kbs=^H, kcbt=\E[Z, kclr=\E[2J,
-	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kdch1=\E[P,
+	kLFT=\E[ A, kRIT=\E[ @, kcbt=\E[Z, kclr=\E[2J, kdch1=\E[P,
 	kdl1=\E[M, kend=\E[24;1H, kf1=\EOc, kf10=\ENp, kf11=\ENq,
 	kf12=\ENr, kf13=\ENs, kf14=\ENt, kf15=\EOC, kf16=\EOD,
 	kf17=\EOE, kf18=\EOF, kf19=\EOG, kf2=\EOd, kf20=\EOH,
@@ -13866,26 +14406,24 @@ att605|AT&T 605 80 column 102key keyboard,
 	kf35=\EOy, kf36=\EOm, kf37=\EOt, kf38=\EOu, kf39=\EOv,
 	kf4=\EOf, kf40=\EOl, kf41=\EOq, kf42=\EOr, kf43=\EOs,
 	kf44=\EOp, kf45=\EOn, kf46=\EOM, kf5=\EOg, kf6=\EOh,
-	kf7=\EOi, kf8=\EOj, kf9=\ENo, khome=\E[H, kich1=\E[@,
-	kil1=\E[L, kind=\E[S, knp=\E[U, kpp=\E[V, ll=\E[24H,
-	mc4=\E[?4i, mc5=\E[?5i, nel=\EE,
+	kf7=\EOi, kf8=\EOj, kf9=\ENo, kich1=\E[@, kil1=\E[L,
+	kind=\E[S, knp=\E[U, kpp=\E[V, ll=\E[24H, mc4=\E[?4i,
+	mc5=\E[?5i, nel=\EE,
 	pfx=\E[%p1%d;%p2%l%02dq   F%p1%1d           %p2%s,
 	pln=\E[%p1%d;0;0;0q%p2%:-16.16s, rc=\E8, rev=\E[7m,
-	rmacs=^O, rmir=\E[4l, rmln=\E[2p, rmso=\E[m, rmul=\E[m,
-	rs2=\Ec\E[?3l, sc=\E7, sgr0=\E[m\017, smacs=\E)0\016,
-	smir=\E[4h, smln=\E[p, smso=\E[7m, smul=\E[4m,
-	tsl=\E7\E[25;%i%p1%dx,
-att605-pc|ATT 605 in pc term mode,
+	rmacs=^O, rmln=\E[2p, rmso=\E[m, rmul=\E[m, rs2=\Ec\E[?3l,
+	sc=\E7, sgr0=\E[m\017, smacs=\E)0\016, smln=\E[p,
+	smso=\E[7m, smul=\E[4m, tsl=\E7\E[25;%i%p1%dx,
+	use=ansi+arrows, use=ansi+cpr, use=ansi+erase,
+	use=ansi+idc, use=ansi+local1,
+
+att605-pc|AT&T 605 in pc term mode,
 	acsc=j\331k\277l\332m\300n\305q\304t\303u\264v\301w\302x
 	     \263,
-	cbt=\E[Z, cub1=\E[D, cud1=\E[B, cuf1=\E[C, cuu1=\E[A,
-	dch1=\E[P, dl1=\E[M, ich1=\E[@, il1=\E[L, kcbt=\E[Z,
-	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kdch1=\E[P,
-	kdl1=\E[M, kend=\E[F, kf1=\E[M, kf10=\E[V, kf2=\E[N,
+	cub1=\E[D, kend=\E[F, kf1=\E[M, kf10=\E[V, kf2=\E[N,
 	kf3=\E[O, kf4=\E[P, kf5=\E[Q, kf6=\E[R, kf7=\E[S, kf8=\E[T,
-	kf9=\E[U, khome=\E[H, kich1=\E[@, knp=\E[G, kpp=\E[I,
-	rmsc=\E[50;0|$<400>, smsc=\E[?11l\E[50;1|$<250>,
-	xoffc=g, xonc=e, use=att605,
+	kf9=\E[U, knp=\E[G, kpp=\E[I, rmsc=\E[50;0|$<400>,
+	smsc=\E[?11l\E[50;1|$<250>, xoffc=g, xonc=e, use=att605,
 att605-w|AT&T 605-w 132 column 102 key keyboard,
 	cols#132, wsl#132,
 	is1=\E[8;0|\E[?4;5;13;15l\E[13;20l\E[?3;7h\E[12h\E(B\E)0, use=att605,
@@ -13897,32 +14435,28 @@ att610|AT&T 610; 80 column; 98key keyboard,
 	am, eslok, hs, mir, msgr, xenl, xon,
 	cols#80, it#8, lh#2, lines#24, lw#8, nlab#8, wsl#80,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, clear=\E[H\E[J,
-	cr=\r, csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\E[B, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	cvvis=\E[?12;25h, dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m,
-	dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K, el1=\E[1K,
-	flash=\E[?5h$<200>\E[?5l, fsl=\E8, home=\E[H, ht=^I,
-	ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L, ind=\ED,
-	invis=\E[8m,
+	bel=^G, cbt=\E[Z, cr=\r, cub1=^H, cvvis=\E[?12;25h,
+	dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m, el1=\E[1K,
+	flash=\E[?5h$<200>\E[?5l, fsl=\E8, ht=^I, ich=\E[%p1%d@,
+	ind=\ED,
 	is1=\E[8;0|\E[?3;4;5;13;15l\E[13;20l\E[?7h\E[12h\E(B\E)0,
-	is2=\E[m\017, is3=\E(B\E)0, kLFT=\E[ @, kRIT=\E[ A, kbs=^H,
-	kcbt=\E[Z, kclr=\E[2J, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C,
-	kcuu1=\E[A, kf1=\EOc, kf10=\ENp, kf11=\ENq, kf12=\ENr,
-	kf13=\ENs, kf14=\ENt, kf2=\EOd, kf3=\EOe, kf4=\EOf, kf5=\EOg,
-	kf6=\EOh, kf7=\EOi, kf8=\EOj, kf9=\ENo, khome=\E[H,
+	is2=\E[m\017, is3=\E(B\E)0, kLFT=\E[ @, kRIT=\E[ A,
+	kcbt=\E[Z, kclr=\E[2J, kf1=\EOc, kf10=\ENp, kf11=\ENq,
+	kf12=\ENr, kf13=\ENs, kf14=\ENt, kf2=\EOd, kf3=\EOe,
+	kf4=\EOf, kf5=\EOg, kf6=\EOh, kf7=\EOi, kf8=\EOj, kf9=\ENo,
 	kind=\E[S, kri=\E[T, ll=\E[24H, mc4=\E[?4i, mc5=\E[?5i,
 	nel=\EE,
 	pfx=\E[%p1%d;%p2%l%02dq   F%p1%1d           %p2%s,
-	pln=\E[%p1%d;0;0;0q%p2%:-16.16s, rc=\E8, rev=\E[7m,
-	ri=\EM, rmacs=^O, rmam=\E[?7l, rmir=\E[4l, rmln=\E[2p,
-	rmso=\E[m, rmul=\E[m, rs2=\Ec\E[?3l, sc=\E7,
+	pln=\E[%p1%d;0;0;0q%p2%:-16.16s, ri=\EM, rmacs=^O,
+	rmam=\E[?7l, rmir=\E[4l, rmln=\E[2p, rs2=\Ec\E[?3l,
 	sgr=\E[0%?%p6%t;1%;%?%p5%t;2%;%?%p2%t;4%;%?%p4%t;5%;%?%p3%p1
 	    %|%t;7%;%?%p7%t;8%;m%?%p9%t\016%e\017%;,
 	sgr0=\E[m\017, smacs=^N, smam=\E[?7h, smir=\E[4h,
-	smln=\E[p, smso=\E[7m, smul=\E[4m, tsl=\E7\E[25;%i%p1%dx,
-	use=ecma+index, use=att610+cvis0,
+	smln=\E[p, tsl=\E7\E[25;%i%p1%dx, use=ansi+arrows,
+	use=ansi+csr, use=ansi+cup, use=ansi+erase, use=ansi+idl,
+	use=ansi+local, use=ansi+sgrbold, use=decid+cpr,
+	use=ecma+index, use=att610+cvis,
+
 att610-w|AT&T 610; 132 column; 98key keyboard,
 	cols#132, wsl#132,
 	is1=\E[8;0|\E[?4;5;13;15l\E[13;20l\E[?3;7h\E[12h,
@@ -13972,39 +14506,36 @@ att620|AT&T 620; 80 column; 98key keyboard,
 	am, eslok, hs, mir, msgr, xenl, xon,
 	cols#80, it#8, lh#2, lines#24, lw#8, nlab#8, wsl#80,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, clear=\E[H\E[J,
-	cr=\r, csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\E[B, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	cvvis=\E[?12;25h, dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m,
-	dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K, el1=\E[1K,
-	flash=\E[?5h$<200>\E[?5l, fsl=\E8, home=\E[H, ht=^I,
-	ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L, ind=\ED,
-	invis=\E[8m,
+	bel=^G, cbt=\E[Z, cr=\r, cub1=^H, cvvis=\E[?12;25h,
+	dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m, el1=\E[1K,
+	flash=\E[?5h$<200>\E[?5l, fsl=\E8, ht=^I, ich=\E[%p1%d@,
+	ind=\ED,
 	is1=\E[8;0|\E[?3;4;5;13;15l\E[13;20l\E[?7h\E[12h,
-	is2=\E[m\017, is3=\E(B\E)0, kLFT=\E[ A, kRIT=\E[ @, kbs=^H,
-	kcbt=\E[Z, kclr=\E[2J, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C,
-	kcuu1=\E[A, kf1=\EOc, kf10=\ENp, kf11=\ENq, kf12=\ENr,
-	kf13=\ENs, kf14=\ENt, kf15=\EOC, kf16=\EOD, kf17=\EOE,
-	kf18=\EOF, kf19=\EOG, kf2=\EOd, kf20=\EOH, kf21=\EOI,
-	kf22=\EOJ, kf23=\ENO, kf24=\ENP, kf25=\ENQ, kf26=\ENR,
-	kf27=\ENS, kf28=\ENT, kf29=\EOP, kf3=\EOe, kf30=\EOQ,
-	kf31=\EOR, kf32=\EOS, kf33=\EOw, kf34=\EOx, kf35=\EOy,
-	kf36=\EOm, kf37=\EOt, kf38=\EOu, kf39=\EOv, kf4=\EOf,
-	kf40=\EOl, kf41=\EOq, kf42=\EOr, kf43=\EOs, kf44=\EOp,
-	kf45=\EOn, kf46=\EOM, kf5=\EOg, kf6=\EOh, kf7=\EOi, kf8=\EOj,
-	kf9=\ENo, khome=\E[H, kind=\E[S, kri=\E[T, ll=\E[24H,
+	is2=\E[m\017, is3=\E(B\E)0, kLFT=\E[ A, kRIT=\E[ @,
+	kcbt=\E[Z, kclr=\E[2J, kf1=\EOc, kf10=\ENp, kf11=\ENq,
+	kf12=\ENr, kf13=\ENs, kf14=\ENt, kf15=\EOC, kf16=\EOD,
+	kf17=\EOE, kf18=\EOF, kf19=\EOG, kf2=\EOd, kf20=\EOH,
+	kf21=\EOI, kf22=\EOJ, kf23=\ENO, kf24=\ENP, kf25=\ENQ,
+	kf26=\ENR, kf27=\ENS, kf28=\ENT, kf29=\EOP, kf3=\EOe,
+	kf30=\EOQ, kf31=\EOR, kf32=\EOS, kf33=\EOw, kf34=\EOx,
+	kf35=\EOy, kf36=\EOm, kf37=\EOt, kf38=\EOu, kf39=\EOv,
+	kf4=\EOf, kf40=\EOl, kf41=\EOq, kf42=\EOr, kf43=\EOs,
+	kf44=\EOp, kf45=\EOn, kf46=\EOM, kf5=\EOg, kf6=\EOh,
+	kf7=\EOi, kf8=\EOj, kf9=\ENo, kind=\E[S, kri=\E[T, ll=\E[24H,
 	mc4=\E[?4i, mc5=\E[?5i, nel=\EE,
 	pfx=\E[%p1%d;%p2%l%02dq   F%p1%1d           %p2%s,
-	pln=\E[%p1%d;0;0;0q%p2%:-16.16s, rc=\E8, rev=\E[7m,
-	ri=\EM, rmacs=\E(B\017, rmam=\E[?7l, rmir=\E[4l,
-	rmln=\E[2p, rmso=\E[m, rmul=\E[m, rs2=\Ec\E[?3l, sc=\E7,
+	pln=\E[%p1%d;0;0;0q%p2%:-16.16s, ri=\EM,
+	rmacs=\E(B\017, rmam=\E[?7l, rmir=\E[4l, rmln=\E[2p,
+	rs2=\Ec\E[?3l,
 	sgr=\E[0%?%p6%t;1%;%?%p5%t;2%;%?%p2%t;4%;%?%p4%t;5%;%?%p3%p1
 	    %|%t;7%;%?%p7%t;8%;m%?%p9%t\E)0\016%e\E(B\017%;,
 	sgr0=\E[m\E(B\017, smacs=\E)0\016, smam=\E[?7h,
-	smir=\E[4h, smln=\E[p, smso=\E[7m, smul=\E[4m,
-	tsl=\E7\E[25;%i%p1%dx, use=ecma+index,
-	use=att610+cvis0,
+	smir=\E[4h, smln=\E[p, tsl=\E7\E[25;%i%p1%dx,
+	use=ansi+arrows, use=ansi+csr, use=ansi+cup,
+	use=ansi+erase, use=ansi+idl, use=ansi+local,
+	use=ansi+sgrbold, use=decid+cpr, use=ecma+index,
+	use=att610+cvis,
+
 att620-w|AT&T 620; 132 column; 98key keyboard,
 	cols#132, wsl#132,
 	is1=\E[8;0|\E[?4;5;13;15l\E[13;20l\E[?3;7h\E[12h,
@@ -14045,25 +14576,22 @@ att620-103k-w|AT&T 620; 132 column; 103key keyboard,
 att630|AT&T 630 windowing terminal,
 	OTbs, am, da, db, mir, msgr, npc, xon,
 	cols#80, it#8, lines#60, lm#0,
-	bel=^G, blink=\E[5m, cbt=\E[Z, clear=\E[H\E[J, cr=\r,
-	cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\E[B,
-	cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
-	cuu=\E[%p1%dA, cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[P,
-	dim=\E[2m, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K,
-	el1=\E[1K, home=\E[H, ht=^I, ich=\E[%p1%d@, ich1=\E[@,
-	il=\E[%p1%dL, il1=\E[L, ind=\ED, is2=\E[m, kbs=^H, kcbt=\E[Z,
-	kclr=\E[2J, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
-	kdch1=\E[P, kdl1=\E[M, kent=\r, kf10=\ENp, kf11=\ENq,
-	kf12=\ENr, kf13=\ENs, kf14=\ENt, kf15=\ENu, kf16=\ENv,
-	kf17=\ENw, kf18=\ENx, kf19=\ENy, kf20=\ENz, kf21=\EN{,
-	kf22=\EN|, kf23=\EN}, kf24=\EN~, kf9=\ENo, khome=\E[H,
-	kich1=\E[@, kil1=\E[L, mc4=\E[?4i, mc5=\E[?5i, nel=\r\n,
+	bel=^G, blink=\E[5m, cbt=\E[Z, cr=\r, cub1=^H,
+	cup=\E[%i%p1%d;%p2%dH, dim=\E[2m, el1=\E[1K, home=\E[H,
+	ht=^I, ind=\ED, is2=\E[m, kcbt=\E[Z, kclr=\E[2J, kdch1=\E[P,
+	kdl1=\E[M, kent=\r, kf10=\ENp, kf11=\ENq, kf12=\ENr,
+	kf13=\ENs, kf14=\ENt, kf15=\ENu, kf16=\ENv, kf17=\ENw,
+	kf18=\ENx, kf19=\ENy, kf20=\ENz, kf21=\EN{, kf22=\EN|,
+	kf23=\EN}, kf24=\EN~, kf9=\ENo, kich1=\E[@, kil1=\E[L,
+	mc4=\E[?4i, mc5=\E[?5i, nel=\r\n,
 	pfx=\E[%p1%d;%p2%l%dq%p2%s, rc=\E8, rev=\E[7m, ri=\EM,
-	rmir=\E[4l, rmso=\E[m, rmul=\E[m, rs2=\Ec, sc=\E7,
+	rmso=\E[m, rmul=\E[m, rs2=\Ec, sc=\E7,
 	sgr=\E[0%?%p5%t;2%;%?%p2%t;4%;%?%p4%t;5%;%?%p1%p3%|%p4%|%t;7
 	    %;m,
-	sgr0=\E[m, smir=\E[4h, smso=\E[7m, smul=\E[4m,
-	use=ecma+index,
+	sgr0=\E[m, smso=\E[7m, smul=\E[4m, use=ansi+arrows,
+	use=ansi+cpr, use=ansi+erase, use=ansi+idc, use=ansi+idl,
+	use=ansi+local, use=ecma+index,
+
 att630-24|5630-24|5630DMD-24|630MTG-24|AT&T 630 windowing terminal 24 lines,
 	lines#24, use=att630,
 
@@ -14146,44 +14674,39 @@ att630-24|5630-24|5630DMD-24|630MTG-24|AT&T 630 windowing terminal 24 lines,
 #
 att700|AT&T 700 24x80 column display w/102key keyboard,
 	am, eslok, hs, mir, msgr, xenl, xon,
-	cols#80, it#8, lh#2, lines#24, lw#8, nlab#8, wsl#80,
+	cols#80, lh#2, lines#24, lw#8, nlab#8, wsl#80,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, clear=\E[H\E[J,
-	cr=\r, csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\E[B, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
+	bel=^G, cr=\r, cub1=^H, cup=\E[%i%p1%d;%p2%dH,
 	cvvis=\E[?12;25h, dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m,
-	dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K, el1=\E[1K,
-	enacs=\E(B\E)0, flash=\E[?5h$<200>\E[?5l, fln=4\,4,
-	fsl=\E8, home=\E[H, ht=^I, hts=\EH, ich=\E[%p1%d@,
-	il=\E[%p1%dL, il1=\E[L, ind=\ED, invis=\E[8m,
+	el1=\E[1K, enacs=\E(B\E)0, flash=\E[?5h$<200>\E[?5l,
+	fln=4\,4, fsl=\E8, home=\E[H, ich=\E[%p1%d@, ind=\ED,
 	is2=\E[50;4|\E[53;0|\E[8;0|\E[?4;13;15l\E[13;20l\E[?7h\E[12h
 	    \E(B\E)0\E[?31l\E[0m\017,
-	is3=\E(B\E)0, kLFT=\E[ A, kRIT=\E[ @, kbs=^H, kcbt=\E[Z,
-	kclr=\E[2J, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
-	kdch1=\E[P, kdl1=\E[M, kend=\E[24;1H, kf1=\EOc, kf10=\ENp,
-	kf11=\ENq, kf12=\ENr, kf13=\ENs, kf14=\ENt, kf15=\EOC,
-	kf16=\EOD, kf17=\EOE, kf18=\EOF, kf19=\EOG, kf2=\EOd,
-	kf20=\EOH, kf21=\EOI, kf22=\EOJ, kf23=\ENO, kf24=\ENP,
-	kf25=\ENQ, kf26=\ENR, kf27=\ENS, kf28=\ENT, kf29=\EOq,
-	kf3=\EOe, kf30=\EOr, kf31=\EOs, kf32=\EOt, kf33=\EOu,
-	kf34=\EOv, kf35=\EOw, kf36=\EOx, kf37=\EOy, kf38=\EOu,
-	kf39=\EOv, kf4=\EOf, kf40=\EOl, kf41=\EOq, kf42=\EOr,
-	kf43=\EOs, kf44=\EOp, kf45=\EOn, kf46=\EOM, kf5=\EOg,
-	kf6=\EOh, kf7=\EOi, kf8=\EOj, kf9=\ENo, khome=\E[H,
-	kich1=\E[@, kil1=\E[L, knp=\E[U, kpp=\E[V, ll=\E[24H,
-	mc0=\E[i, mc4=\E[?4i, mc5=\E[?5i, nel=\EE,
+	is3=\E(B\E)0, kLFT=\E[ A, kRIT=\E[ @, kcbt=\E[Z,
+	kclr=\E[2J, kdch1=\E[P, kdl1=\E[M, kend=\E[24;1H, kf1=\EOc,
+	kf10=\ENp, kf11=\ENq, kf12=\ENr, kf13=\ENs, kf14=\ENt,
+	kf15=\EOC, kf16=\EOD, kf17=\EOE, kf18=\EOF, kf19=\EOG,
+	kf2=\EOd, kf20=\EOH, kf21=\EOI, kf22=\EOJ, kf23=\ENO,
+	kf24=\ENP, kf25=\ENQ, kf26=\ENR, kf27=\ENS, kf28=\ENT,
+	kf29=\EOq, kf3=\EOe, kf30=\EOr, kf31=\EOs, kf32=\EOt,
+	kf33=\EOu, kf34=\EOv, kf35=\EOw, kf36=\EOx, kf37=\EOy,
+	kf38=\EOu, kf39=\EOv, kf4=\EOf, kf40=\EOl, kf41=\EOq,
+	kf42=\EOr, kf43=\EOs, kf44=\EOp, kf45=\EOn, kf46=\EOM,
+	kf5=\EOg, kf6=\EOh, kf7=\EOi, kf8=\EOj, kf9=\ENo, kich1=\E[@,
+	kil1=\E[L, knp=\E[U, kpp=\E[V, ll=\E[24H, nel=\EE,
 	pfx=\E[%p1%d;%p2%l%02dq%?%p1%{9}%<%t\s\s\sF%p1%1d\s\s\s\s\s
 	    \s\s\s\s\s\s%;%p2%s,
-	pln=\E[%p1%d;0;0;0q%p2%:-16.16s, rc=\E8, rev=\E[7m,
-	ri=\EM, rmacs=^O, rmir=\E[4l, rmln=\E[2p, rmso=\E[27m,
-	rmul=\E[24m, rmxon=\E[53;3|, rs1=\Ec\E[?3;5l\E[56;0|,
-	sc=\E7,
+	pln=\E[%p1%d;0;0;0q%p2%:-16.16s, ri=\EM, rmacs=^O,
+	rmir=\E[4l, rmln=\E[2p, rmso=\E[27m, rmul=\E[24m,
+	rmxon=\E[53;3|, rs1=\Ec\E[?3;5l\E[56;0|,
 	sgr=\E[0%?%p6%t;1%;%?%p5%t;2%;%?%p2%t;4%;%?%p4%t;5%;%?%p3%p1
 	    %|%t;7%;%?%p7%t;8%;m%?%p9%t\016%e\017%;,
-	sgr0=\E[m\017, smacs=^N, smir=\E[4h, smln=\E[p, smso=\E[7m,
-	smul=\E[4m, smxon=\E[53;0|, tbc=\E[3g,
-	tsl=\E7\E[99;%i%p1%dx, use=ansi+rep, use=att610+cvis0,
+	sgr0=\E[m\017, smacs=^N, smir=\E[4h, smln=\E[p,
+	smxon=\E[53;0|, tsl=\E7\E[99;%i%p1%dx, use=ansi+arrows,
+	use=ansi+csr, use=ansi+erase, use=ansi+idl,
+	use=ansi+inittabs, use=ansi+local, use=ansi+rep,
+	use=ansi+sgrbold, use=decid+cpr, use=dec+pp,
+	use=att610+cvis0,
 
 # This entry was modified 3/13/90 by JWE.
 # fixes include additions of <enacs>, correcting <rep>, and modification
@@ -14202,53 +14725,49 @@ att730|AT&T 730 windowing terminal,
 	am, da, db, eslok, hs, mir, msgr, npc, xenl, xon,
 	cols#80, it#8, lh#2, lines#60, lm#0, lw#8, nlab#24, wsl#80,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, clear=\E[H\E[J,
-	cr=\r, csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\E[B, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	cvvis=\E[?12;25h, dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m,
-	dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K, el1=\E[1K,
-	enacs=\E(B\E)0, flash=\E[?5h$<200>\E[?5l, fsl=\E8,
-	home=\E[H, ht=^I, ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L,
-	ind=\ED, invis=\E[8m,
+	bel=^G, cbt=\E[Z, cr=\r, cub1=^H, dch=\E[%p1%dP, dch1=\E[P,
+	dim=\E[2m, el1=\E[1K, enacs=\E(B\E)0,
+	flash=\E[?5h$<200>\E[?5l, fsl=\E8, ht=^I, ich=\E[%p1%d@,
+	ind=\ED,
 	is1=\E[8;0|\E[?3;4;5;13;15l\E[13;20l\E[?7h\E[12h\E(B\E)B,
-	is2=\E[m\017, is3=\E(B\E)0, kLFT=\E[ @, kRIT=\E[ A, kbs=^H,
-	kcbt=\E[Z, kclr=\E[2J, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C,
-	kcuu1=\E[A, kf1=\EOc, kf10=\ENp, kf11=\ENq, kf12=\ENr,
-	kf13=\ENs, kf14=\ENt, kf15=\ENu, kf16=\ENv, kf17=\ENw,
-	kf18=\ENx, kf19=\ENy, kf2=\EOd, kf20=\ENz, kf21=\EN{,
-	kf22=\EN|, kf23=\EN}, kf24=\EN~, kf25=\EOC, kf26=\EOD,
-	kf27=\EOE, kf28=\EOF, kf29=\EOG, kf3=\EOe, kf30=\EOH,
-	kf31=\EOI, kf32=\EOJ, kf33=\ENO, kf34=\ENP, kf35=\ENQ,
-	kf36=\ENR, kf37=\ENS, kf38=\ENT, kf39=\EOU, kf4=\EOf,
-	kf40=\EOV, kf41=\EOW, kf42=\EOX, kf43=\EOY, kf44=\EOZ,
-	kf45=\EO[, kf46=\EO\s, kf47=\EO], kf48=\EO\^, kf5=\EOg,
-	kf6=\EOh, kf7=\EOi, kf8=\EOj, kf9=\ENo, khome=\E[H,
-	kich1=\E[@, kil1=\E[L, kind=\E[S, kri=\E[T,
-	mc0=\E[?19h\E[0i, mc4=\E[?4i, mc5=\E[?5i, nel=\EE,
+	is2=\E[m\017, is3=\E(B\E)0, kLFT=\E[ @, kRIT=\E[ A,
+	kcbt=\E[Z, kclr=\E[2J, kf1=\EOc, kf10=\ENp, kf11=\ENq,
+	kf12=\ENr, kf13=\ENs, kf14=\ENt, kf15=\ENu, kf16=\ENv,
+	kf17=\ENw, kf18=\ENx, kf19=\ENy, kf2=\EOd, kf20=\ENz,
+	kf21=\EN{, kf22=\EN|, kf23=\EN}, kf24=\EN~, kf25=\EOC,
+	kf26=\EOD, kf27=\EOE, kf28=\EOF, kf29=\EOG, kf3=\EOe,
+	kf30=\EOH, kf31=\EOI, kf32=\EOJ, kf33=\ENO, kf34=\ENP,
+	kf35=\ENQ, kf36=\ENR, kf37=\ENS, kf38=\ENT, kf39=\EOU,
+	kf4=\EOf, kf40=\EOV, kf41=\EOW, kf42=\EOX, kf43=\EOY,
+	kf44=\EOZ, kf45=\EO[, kf46=\EO\s, kf47=\EO], kf48=\EO\^,
+	kf5=\EOg, kf6=\EOh, kf7=\EOi, kf8=\EOj, kf9=\ENo, kich1=\E[@,
+	kil1=\E[L, kind=\E[S, kri=\E[T, mc0=\E[?19h\E[0i, nel=\EE,
 	pfx=\E[%?%p1%{25}%<%t%p1%e%p1%{24}%-%;%d;%p2%l%02d%?%p1%{25}
 	    %<%tq\s\s\sSYS\s\s\s\s\sF%p1%:-2d\s\s%e;0;3q%;%p2%s,
 	pfxl=\E[%p1%d;%p2%l%02d;0;0q%p3%:-16.16s%p2%s,
-	pln=\E[%p1%d;0;0;0q%p2%:-16.16s, rc=\E8, rev=\E[7m,
-	ri=\EM, rmacs=^O, rmam=\E[?7l, rmir=\E[4l, rmln=\E[?13h,
-	rmso=\E[27m, rmul=\E[24m, rmxon=\E[?21l, rs2=\Ec\E[?3l,
-	sc=\E7,
+	pln=\E[%p1%d;0;0;0q%p2%:-16.16s, ri=\EM, rmacs=^O,
+	rmam=\E[?7l, rmir=\E[4l, rmln=\E[?13h, rmso=\E[27m,
+	rmul=\E[24m, rmxon=\E[?21l, rs2=\Ec\E[?3l,
 	sgr=\E[0%?%p6%t;1%;%?%p5%t;2%;%?%p2%t;4%;%?%p4%t;5%;%?%p3%p1
 	    %|%t;7%;%?%p7%t;8%;m%?%p9%t\016%e\017%;,
 	sgr0=\E[m\017, smacs=^N, smam=\E[?7h, smir=\E[4h,
-	smln=\E[?13l, smso=\E[7m, smul=\E[4m, smxon=\E[?21h,
-	swidm=\E#6, tsl=\E7\E[;%i%p1%dx, use=ansi+rep,
-	use=att610+cvis0,
-att730-41|730MTG-41|AT&T 730-41 windowing terminal Version,
+	smln=\E[?13l, smxon=\E[?21h, swidm=\E#6,
+	tsl=\E7\E[;%i%p1%dx, use=ansi+arrows, use=ansi+csr,
+	use=ansi+cup, use=ansi+erase, use=ansi+idl,
+	use=ansi+local, use=ansi+rep, use=ansi+sgrbold,
+	use=decid+cpr, use=dec+pp, use=att610+cvis,
+
+# "MGT" is "Multi-Tasking Graphics Terminal"
+att730-41|730MTG-41|AT&T 730-41 windowing terminal,
 	lines#41, use=att730,
-att730-24|730MTG-24|AT&T 730-24 windowing terminal Version,
+att730-24|730MTG-24|AT&T 730-24 windowing terminal,
 	lines#24, use=att730,
-att730r|730MTGr|AT&T 730 rev video windowing terminal Version,
+att730r|730MTGr|AT&T 730 rev video windowing terminal,
 	flash=\E[?5l$<200>\E[?5h,
 	is1=\E[8;0|\E[?3;4;13;15l\E[?5h\E[13;20l\E[?7h\E[12h\E(B\E)B, use=att730,
-att730r-41|730MTG-41r|AT&T 730r-41 rev video windowing terminal Version,
+att730r-41|730MTG-41r|AT&T 730r-41 rev video windowing terminal,
 	lines#41, use=att730r,
-att730r-24|730MTGr-24|AT&T 730r-24 rev video windowing terminal Version,
+att730r-24|730MTGr-24|AT&T 730r-24 rev video windowing terminal,
 	lines#24, use=att730r,
 
 # The following represents the screen layout along with the associated
@@ -14418,12 +14937,9 @@ att505|pt505|att5430|gs5430|AT&T Personal Terminal 505 or 5430 GETSET terminal,
 	cols#80, it#8, lines#24,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
 	bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[2J\E[H,
-	cnorm=\E[>l, cr=\r, cub=\E[%p1%dD, cub1=\E[D,
-	cud=\E[%p1%dB, cud1=\E[B, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	cvvis=\E[>h, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM,
-	dl1=\E[M, ed=\E[0J, el=\E[0K, el1=\E[2K, home=\E[H, ht=^I,
-	il=\E[%p1%dL, il1=\E[L, ind=\n,
+	cnorm=\E[>l, cr=\r, cup=\E[%p1%d;%p2%dH, cvvis=\E[>h,
+	dch=\E[%p1%dP, dch1=\E[P, ed=\E[0J, el=\E[0K, el1=\E[2K,
+	home=\E[H, ht=^I, ind=\n,
 	is1=\EPr\\E[0u\E[2J\E[0;0H\E[m\E[3l\E[<l\E[4l\E[>l\E[=l\E[?l,
 	kbs=^H, kcmd=\E!, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C,
 	kcuu1=\E[A, kf0=\E[00s, kf1=\E[01s, kf18=\E[18s,
@@ -14434,13 +14950,14 @@ att505|pt505|att5430|gs5430|AT&T Personal Terminal 505 or 5430 GETSET terminal,
 	rmacs=\E[10m, rmam=\E[11;1j, rmir=\E[4l, rmso=\E[m,
 	rmul=\E[m, rs1=\Ec, sc=\E7, sgr0=\E[m, smacs=\E[11m,
 	smam=\E[11;0j, smir=\E[4h, smso=\E[1m, smul=\E[4m,
+	use=ansi+cpr, use=ansi+idl, use=ansi+local,
 
 # The following Terminfo entry describes functions which are supported by
 # the AT&T 5430/pt505 terminal software version 1.
 att505-24|pt505-24|gs5430-24|AT&T PT505 or 5430 GETSET version 1 24 lines,
 	lines#24,
 	mc4@, mc5@, rc@, rmam@, sc@, smam@, use=att505,
-tt505-22|pt505-22|gs5430-22|AT&T PT505 or 5430 GETSET version 1 22 lines,
+att505-22|pt505-22|gs5430-22|AT&T PT505 or 5430 GETSET version 1 22 lines,
 	lines#22, use=att505,
 #
 #### ------------------ TERMINFO FILE CAN BE SPLIT HERE ---------------------
@@ -14458,7 +14975,7 @@ tt505-22|pt505-22|gs5430-22|AT&T PT505 or 5430 GETSET version 1 22 lines,
 
 # From: <cbosg!ucbvax!SRC:george> Fri Sep 11 22:38:32 1981
 # (ampex80: some capabilities merged in from SCO's entry -- esr)
-ampex80|a80|d80|dialogue|dialogue80|ampex dialogue 80,
+ampex80|a80|d80|dialogue|dialogue80|Ampex dialogue 80,
 	OTbs, am, bw, ul,
 	cols#80, it#8, lines#24,
 	bel=^G, cbt=\EI, clear=\E*$<75>, cr=\r, cub1=^H, cud1=\n,
@@ -14467,7 +14984,7 @@ ampex80|a80|d80|dialogue|dialogue80|ampex dialogue 80,
 	ich1=\EQ, il1=\EE$<5*>, ind=\n, is2=\EA, rmso=\Ek, rmul=\Em,
 	smso=\Ej, smul=\El, tbc=\E3,
 # This entry was from somebody anonymous, Tue Aug  9 20:11:37 1983, who wrote:
-ampex175|ampex d175,
+ampex175|Ampex d175,
 	am,
 	cols#80, lines#24,
 	bel=^G, clear=\E+, cr=\r, cub1=^H, cud1=\n, cuf1=^L,
@@ -14482,11 +14999,11 @@ ampex175|ampex d175,
 # mode), this key can be used as the erase key; I find I like this. Because
 # some people and some systems may not, there is another termcap ("ampex175")
 # that suppresses this little eccentricity by omitting the relevant capability.
-ampex175-b|ampex d175 using left arrow for erase,
+ampex175-b|Ampex d175 using left arrow for erase,
 	kbs=^_, use=ampex175,
 # From: Richard Bascove <atd!dsd!rcb@ucbvax.berkeley.edu>
 # (ampex210: removed obsolete ":kn#10:" -- esr)
-ampex210|a210|ampex a210,
+ampex210|a210|Ampex a210,
 	OTbs, am, hs, xenl,
 	cols#80, it#8, lines#24, xmc#1,
 	cbt=\EI, clear=\E*, cub1=^H, cuf1=^L,
@@ -14502,7 +15019,7 @@ ampex210|a210|ampex a210,
 # (ampex219: I added <rmam>/<smam> based on the init string, added <cvvis>
 # from ampex219w, added <cnorm>=\E[?3l, irresistibly suggested by <cvvis>,
 # and moved the padding to be *after* the caps -- esr)
-ampex219|ampex-219|amp219|Ampex with Automargins,
+ampex219|ampex-219|amp219|Ampex with automargins,
 	hs, xenl,
 	cols#80, it#8, lines#24,
 	bel=^G, blink=\E[5m$<2>, bold=\E[1m$<2>, cbt=\E[Z,
@@ -14519,9 +15036,9 @@ ampex219|ampex-219|amp219|Ampex with Automargins,
 	rmso=\E[m$<2>, rmul=\E[m$<2>, sgr0=\E[m$<2>, smam=\E[?7h,
 	smkx=\E=, smso=\E[7m$<2>, smul=\E[4m$<2>,
 ampex219w|ampex-219w|amp219w|Ampex 132 cols,
-	cols#132, lines#24,
-	bel=^G, cr=\r, cud1=\n, ind=\n,
-	is2=\E>\E[?3h\E[?4l\E[?5l\E[?7h\E[?8h, use=ampex219,
+	cols#132,
+	cud1=\n, is2=\E>\E[?3h\E[?4l\E[?5l\E[?7h\E[?8h,
+	use=ampex219,
 # (ampex232: removed <if=/usr/share/tabset/ampex>, no file and no <hts> --esr)
 ampex232|ampex-232|Ampex Model 232,
 	am,
@@ -14536,7 +15053,7 @@ ampex232|ampex-232|Ampex Model 232,
 	kf9=^AI\r, khome=^^, use=adm+sgr,
 # (ampex: removed <if=/usr/share/tabset/amp-132>, no file and no <hts> -- esr)
 ampex232w|Ampex Model 232 / 132 columns,
-	cols#132, lines#24,
+	cols#132,
 	is2=\E\034Eg\El, use=ampex232,
 
 #### Ann Arbor (aa)
@@ -14667,7 +15184,7 @@ ampex232w|Ampex Model 232 / 132 columns,
 #	unused
 #
 
-annarbor4080|aa4080|ann arbor 4080,
+annarbor4080|aa4080|Ann Arbor 4080,
 	OTbs, am,
 	cols#80, lines#40,
 	bel=^G, clear=\014$<2>, cr=\r, cub1=^H, cud1=\n, cuf1=^_,
@@ -14693,86 +15210,83 @@ aas1901|Ann Arbor K4080 w/S1901 mod,
 #   3. Number of lines below (outside of) desired scroll region.
 #   4. Total number of lines on the screen, the same as the first parameter.
 # The generic Ann Arbor entry is the only one that uses this.
-aaa+unk|aaa-unk|ann arbor ambassador (internal - don't use this directly),
+aaa+unk|aaa-unk|Ann Arbor Ambassador (internal - don't use this directly),
 	OTbs, am, km, mc5i, mir, xon,
-	cols#80, it#8,
-	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z,
-	clear=\E[H\E[J$<156>, cr=\r, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=^K, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J,
-	el=\E[K$<5>, home=\E[H, hpa=\E[%p1%{1}%+%dG, ht=^I,
-	hts=\EH, ich=\E[%p1%d@$<4*>, ich1=\E[@$<4>, il=\E[%p1%dL,
-	il1=\E[L$<3>, ind=^K, invis=\E[8m, is1=\E[m\E7\E[H\E9\E8,
-	is3=\E[1Q\E[>20;30l\EP`+x~M\E\\, kbs=^H, kcbt=\E[Z,
-	kclr=\E[J, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
+	cols#80,
+	bel=^G, clear=\E[H\E[J$<156>, cr=\r, cub1=^H, cud1=^K,
+	cup=\E[%i%p1%d;%p2%dH, dch=\E[%p1%dP, dch1=\E[P, ed=\E[J,
+	el=\E[K$<5>, home=\E[H, hpa=\E[%p1%{1}%+%dG,
+	ich=\E[%p1%d@$<4*>, ich1=\E[@$<4>, il1=\E[L$<3>, ind=^K,
+	is1=\E[m\E7\E[H\E9\E8,
+	is3=\E[1Q\E[>20;30l\EP`+x~M\E\\, kcbt=\E[Z, kclr=\E[J,
 	kdch1=\E[P, kdl1=\E[M, kf1=\EOA, kf10=\EOJ, kf11=\EOK,
 	kf12=\EOL, kf13=\EOM, kf14=\EON, kf15=\EOO, kf16=\EOP,
 	kf17=\EOQ, kf18=\EOR, kf19=\EOS, kf2=\EOB, kf20=\EOT,
 	kf21=\EOU, kf22=\EOV, kf23=\EOW, kf24=\EOX, kf3=\EOC,
 	kf4=\EOD, kf5=\EOE, kf6=\EOF, kf7=\EOG, kf8=\EOH, kf9=\EOI,
-	khome=\E[H, kich1=\E[@, kil1=\E[L, krmir=\E6, mc0=\E[0i,
-	mc4=^C, mc5=\E[v, mc5p=\E[%p1%dv, rc=\E8, rev=\E[7m,
+	kich1=\E[@, kil1=\E[L, krmir=\E6, mc0=\E[0i, mc4=^C,
+	mc5=\E[v, mc5p=\E[%p1%dv, rc=\E8,
 	rmkx=\EP`>y~[[J`8xy~[[A`4xy~[[D`6xy~[[C`2xy~[[B\E
 	     \\,
-	rmm=\E[>52l, rmso=\E[m, rmul=\E[m, sc=\E7,
+	rmm=\E[>52l, sc=\E7,
 	sgr=\E[%?%p1%t7;%;%?%p2%t4;%;%?%p3%t7;%;%?%p4%t5;%;%?%p6%t1;
 	    %;%?%p7%t8;%;m,
 	sgr0=\E[m,
 	smkx=\EP`>z~[[J`8xz~[[A`4xz~[[D`6xz~[[C`2xz~[[B\E
 	     \\,
-	smm=\E[>52h, smso=\E[7m, smul=\E[4m, tbc=\E[3g,
-	vpa=\E[%p1%{1}%+%dd, use=ansi+rep,
+	smm=\E[>52h, vpa=\E[%p1%{1}%+%dd, use=ansi+arrows,
+	use=ansi+idl, use=ansi+inittabs, use=ansi+local,
+	use=ansi+rep, use=ansi+sgrbold,
 
-aaa+rv|ann arbor ambassador in reverse video,
+aaa+rv|Ann Arbor Ambassador in reverse video,
 	blink=\E[5;7m, bold=\E[1;7m, invis=\E[7;8m,
 	is1=\E[7m\E7\E[H\E9\E8, rev=\E[m, rmso=\E[7m, rmul=\E[7m,
 	rs1=\E[H\E[7m\E[J$<156>,
 	sgr=\E[%?%p2%t4;%;%?%p4%t5;%;%?%p6%t1;%;%?%p1%p2%|%p3%!%|%t7
 	    ;%;%?%p7%t8;%;m\016,
 	sgr0=\E[7m\016, smso=\E[m, smul=\E[4;7m,
-# Ambassador with the DEC option, for partial vt100 compatibility.
-aaa+dec|ann arbor ambassador in dec vt100 mode,
+# Ambassador with the DEC option, for partial VT100 compatibility.
+aaa+dec|Ann Arbor Ambassador in DEC VT100 mode,
 	acsc=aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}},
-	csr=\E[%i%p1%d;%p2%dr, enacs=\E(0, rmacs=^N,
+	csr=\E[%i%p1%d;%p2%dr, enacs=\E(B\E)0, rmacs=^O,
 	sgr=\E[%?%p2%t4;%;%?%p4%t5;%;%?%p6%t1;%;%?%p1%p3%|%!%t7;%;%?
-	    %p7%t8;%;m%?%p9%t\017%e\016%;,
-	smacs=^O,
-aaa-18|ann arbor ambassador/18 lines,
+	    %p7%t8;%;m%?%p9%t\016%e\017%;,
+	smacs=^N,
+aaa-18|Ann Arbor Ambassador/18 lines,
 	lines#18,
 	is2=\E7\E[60;0;0;18p\E8,
 	rmcup=\E[60;0;0;18p\E[60;1H\E[K, smcup=\E[18;0;0;18p,
 	use=aaa+unk,
-aaa-18-rv|ann arbor ambassador/18 lines+reverse video,
+aaa-18-rv|Ann Arbor Ambassador/18 lines+reverse video,
 	use=aaa+rv, use=aaa-18,
-aaa-20|ann arbor ambassador/20 lines,
+aaa-20|Ann Arbor Ambassador/20 lines,
 	lines#20,
 	is2=\E7\E[60;0;0;20p\E8,
 	rmcup=\E[60;0;0;20p\E[60;1H\E[K, smcup=\E[20;0;0;20p,
 	use=aaa+unk,
-aaa-22|ann arbor ambassador/22 lines,
+aaa-22|Ann Arbor Ambassador/22 lines,
 	lines#22,
 	is2=\E7\E[60;0;0;22p\E8,
 	rmcup=\E[60;0;0;22p\E[60;1H\E[K, smcup=\E[22;0;0;22p,
 	use=aaa+unk,
-aaa-24|ann arbor ambassador/24 lines,
+aaa-24|Ann Arbor Ambassador/24 lines,
 	lines#24,
 	is2=\E7\E[60;0;0;24p\E8,
 	rmcup=\E[60;0;0;24p\E[60;1H\E[K, smcup=\E[24;0;0;24p,
 	use=aaa+unk,
-aaa-24-rv|ann arbor ambassador/24 lines+reverse video,
+aaa-24-rv|Ann Arbor Ambassador/24 lines+reverse video,
 	use=aaa+rv, use=aaa-24,
-aaa-26|ann arbor ambassador/26 lines,
+aaa-26|Ann Arbor Ambassador/26 lines,
 	lines#26,
 	is2=\E7\E[60;0;0;26p\E8,
 	rmcup=\E[60;0;0;26p\E[26;1H\E[K,
 	smcup=\E[H\E[J$<156>\E[26;0;0;26p, use=aaa+unk,
-aaa-28|ann arbor ambassador/28 lines,
+aaa-28|Ann Arbor Ambassador/28 lines,
 	lines#28,
 	is2=\E7\E[60;0;0;28p\E8,
 	rmcup=\E[60;0;0;28p\E[28;1H\E[K,
 	smcup=\E[H\E[J$<156>\E[28;0;0;28p, use=aaa+unk,
-aaa-30-s|aaa-s|ann arbor ambassador/30 lines w/status,
+aaa-30-s|aaa-s|Ann Arbor Ambassador/30 lines w/status,
 	eslok, hs,
 	lines#29,
 	dsl=\E7\E[60;0;0;30p\E[1;1H\E[K\E[H\E8\r\n\E[K,
@@ -14780,76 +15294,76 @@ aaa-30-s|aaa-s|ann arbor ambassador/30 lines w/status,
 	rmcup=\E[60;1;0;30p\E[29;1H\E[K,
 	smcup=\E[H\E[J$<156>\E[30;1;0;30p\E[30;1H\E[K,
 	tsl=\E[>51h\E[1;%p1%dH\E[2K, use=aaa+unk,
-aaa-30-s-rv|aaa-s-rv|ann arbor ambassador/30 lines+status+reverse video,
+aaa-30-s-rv|aaa-s-rv|Ann Arbor Ambassador/30 lines+status+reverse video,
 	use=aaa+rv, use=aaa-30-s,
-aaa-s-ctxt|aaa-30-s-ctxt|ann arbor ambassador/30 lines+status+save context,
+aaa-s-ctxt|aaa-30-s-ctxt|Ann Arbor Ambassador/30 lines+status+save context,
 	rmcup=\E[60;1;0;30p\E[59;1H\E[K,
 	smcup=\E[30;1H\E[K\E[30;1;0;30p, use=aaa-30-s,
-aaa-s-rv-ctxt|aaa-30-s-rv-ct|ann arbor ambassador/30 lines+status+save context+reverse video,
+aaa-s-rv-ctxt|aaa-30-s-rv-ct|Ann Arbor Ambassador/30 lines+status+save context+reverse video,
 	rmcup=\E[60;1;0;30p\E[59;1H\E[K,
 	smcup=\E[30;1H\E[K\E[30;1;0;30p, use=aaa-30-s-rv,
-aaa|aaa-30|ambas|ambassador|ann arbor ambassador/30 lines,
+aaa|aaa-30|ambas|ambassador|Ann Arbor Ambassador/30 lines,
 	lines#30,
 	is2=\E7\E[60;0;0;30p\E8,
 	rmcup=\E[60;0;0;30p\E[30;1H\E[K,
 	smcup=\E[H\E[J$<156>\E[30;0;0;30p, use=aaa+unk,
-aaa-30-rv|aaa-rv|ann arbor ambassador/30 lines in reverse video,
+aaa-30-rv|aaa-rv|Ann Arbor Ambassador/30 lines in reverse video,
 	use=aaa+rv, use=aaa-30,
-aaa-30-ctxt|aaa-ctxt|ann arbor ambassador/30 lines; saving context,
+aaa-30-ctxt|aaa-ctxt|Ann Arbor Ambassador/30 lines; saving context,
 	rmcup=\E[60;0;0;30p\E[60;1H\E[K, smcup=\E[30;0;0;30p,
 	use=aaa-30,
-aaa-30-rv-ctxt|aaa-rv-ctxt|ann arbor ambassador/30 lines reverse video; saving context,
+aaa-30-rv-ctxt|aaa-rv-ctxt|Ann Arbor Ambassador/30 lines reverse video; saving context,
 	rmcup=\E[60;0;0;30p\E[60;1H\E[K, smcup=\E[30;0;0;30p,
 	use=aaa+rv, use=aaa-30,
-aaa-36|ann arbor ambassador/36 lines,
+aaa-36|Ann Arbor Ambassador/36 lines,
 	lines#36,
 	is2=\E7\E[60;0;0;36p\E8,
 	rmcup=\E[60;0;0;36p\E[36;1H\E[K,
 	smcup=\E[H\E[J$<156>\E[36;0;0;36p, use=aaa+unk,
-aaa-36-rv|ann arbor ambassador/36 lines+reverse video,
+aaa-36-rv|Ann Arbor Ambassador/36 lines+reverse video,
 	use=aaa+rv, use=aaa-36,
-aaa-40|ann arbor ambassador/40 lines,
+aaa-40|Ann Arbor Ambassador/40 lines,
 	lines#40,
 	is2=\E7\E[60;0;0;40p\E8,
 	rmcup=\E[60;0;0;40p\E[40;1H\E[K,
 	smcup=\E[H\E[J$<156>\E[40;0;0;40p, use=aaa+unk,
-aaa-40-rv|ann arbor ambassador/40 lines+reverse video,
+aaa-40-rv|Ann Arbor Ambassador/40 lines+reverse video,
 	use=aaa+rv, use=aaa-40,
-aaa-48|ann arbor ambassador/48 lines,
+aaa-48|Ann Arbor Ambassador/48 lines,
 	lines#48,
 	is2=\E7\E[60;0;0;48p\E8,
 	rmcup=\E[60;0;0;48p\E[48;1H\E[K,
 	smcup=\E[H\E[J$<156>\E[48;0;0;48p, use=aaa+unk,
-aaa-48-rv|ann arbor ambassador/48 lines+reverse video,
+aaa-48-rv|Ann Arbor Ambassador/48 lines+reverse video,
 	use=aaa+rv, use=aaa-48,
-aaa-60-s|ann arbor ambassador/59 lines+status,
+aaa-60-s|Ann Arbor Ambassador/59 lines+status,
 	eslok, hs,
 	lines#59,
 	dsl=\E7\E[60;0;0;60p\E[1;1H\E[K\E[H\E8\r\n\E[K,
 	fsl=\E[>51l, is2=\r\n\E[A\E7\E[60;1;0;60p\E8,
 	tsl=\E[>51h\E[1;%p1%dH\E[2K, use=aaa+unk,
-aaa-60-s-rv|ann arbor ambassador/59 lines+status+reverse video,
+aaa-60-s-rv|Ann Arbor Ambassador/59 lines+status+reverse video,
 	use=aaa+rv, use=aaa-60-s,
-aaa-60-dec-rv|ann arbor ambassador/dec mode+59 lines+status+rev video,
+aaa-60-dec-rv|Ann Arbor Ambassador/DEC mode+59 lines+status+rev video,
 	use=aaa+dec, use=aaa+rv, use=aaa-60-s,
-aaa-60|ann arbor ambassador/60 lines,
+aaa-60|Ann Arbor Ambassador/60 lines,
 	lines#60,
 	is2=\E7\E[60;0;0;60p\E[1Q\E[m\E[>20;30l\E8,
 	use=aaa+unk,
-aaa-60-rv|ann arbor ambassador/60 lines+reverse video,
+aaa-60-rv|Ann Arbor Ambassador/60 lines+reverse video,
 	use=aaa+rv, use=aaa-60,
-aaa-db|ann arbor ambassador 30/destructive backspace,
+aaa-db|Ann Arbor Ambassador 30/destructive backspace,
 	OTbs@,
 	cub1=\E[D, is3=\E[1Q\E[m\E[>20l\E[>30h, use=aaa-30,
 
-guru|guru-33|guru+unk|ann arbor guru/33 lines 80 cols,
+guru|guru-33|guru+unk|Ann Arbor guru/33 lines 80 cols,
 	lines#33,
 	flash=\E[>59h$<100>\E[>59l,
 	is2=\E7\E[255;0;0;33;80;80p\E8\E[J, is3=\E[>59l,
 	rmcup=\E[255p\E[255;1H\E[K, smcup=\E[33p, use=aaa+unk,
 guru+rv|guru changes for reverse video,
 	flash=\E[>59l$<100>\E[>59h, is3=\E[>59h,
-guru-rv|guru-33-rv|ann arbor guru/33 lines+reverse video,
+guru-rv|guru-33-rv|Ann Arbor guru/33 lines+reverse video,
 	use=guru+rv, use=guru-33,
 guru+s|guru status line,
 	eslok, hs,
@@ -14858,19 +15372,19 @@ guru+s|guru status line,
 	tsl=\E[>51h\E[1;%p1%dH\E[2K,
 guru-nctxt|guru with no saved context,
 	smcup=\E[H\E[J$<156>\E[33p\E[255;1H\E[K, use=guru,
-guru-s|guru-33-s|ann arbor guru/33 lines+status,
+guru-s|guru-33-s|Ann Arbor guru/33 lines+status,
 	lines#32,
 	is2=\r\n\E[A\E7\E[255;1;0;33;80;80p\E8\E[J,
 	smcup=\E[33;1p\E[255;1H\E[K, use=guru+s, use=guru+unk,
-guru-24|ann arbor guru 24 lines,
+guru-24|Ann Arbor guru 24 lines,
 	cols#80, lines#24,
 	is2=\E7\E[255;0;0;24;80;80p\E8\E[J, smcup=\E[24p,
 	use=guru+unk,
-guru-44|ann arbor guru 44 lines,
+guru-44|Ann Arbor guru 44 lines,
 	cols#97, lines#44,
 	is2=\E7\E[255;0;0;44;97;100p\E8\E[J, smcup=\E[44p,
 	use=guru+unk,
-guru-44-s|ann arbor guru/44 lines+status,
+guru-44-s|Ann Arbor guru/44 lines+status,
 	lines#43,
 	is2=\r\n\E[A\E7\E[255;1;0;44;80;80p\E8\E[J,
 	smcup=\E[44;1p\E[255;1H\E[K, use=guru+s, use=guru+unk,
@@ -14878,7 +15392,7 @@ guru-76|guru with 76 lines by 89 cols,
 	cols#89, lines#76,
 	is2=\E7\E[255;0;0;76;89;100p\E8\E[J, smcup=\E[76p,
 	use=guru+unk,
-guru-76-s|ann arbor guru/76 lines+status,
+guru-76-s|Ann Arbor guru/76 lines+status,
 	cols#89, lines#75,
 	is2=\r\n\E[A\E7\E[255;1;0;76;89;100p\E8\E[J,
 	smcup=\E[76;1p\E[255;1H\E[K, use=guru+s, use=guru+unk,
@@ -14890,7 +15404,7 @@ guru-76-w|guru 76 lines by 178 cols,
 	cols#178, lines#76,
 	is2=\E7\E[255;0;0;76;178;178p\E8\E[J, smcup=\E[76p,
 	use=guru+unk,
-guru-76-w-s|ann arbor guru/76 lines+status+wide,
+guru-76-w-s|Ann Arbor guru/76 lines+status+wide,
 	cols#178, lines#75,
 	is2=\r\n\E[A\E7\E[255;1;0;76;178;178p\E8\E[J,
 	smcup=\E[76;1p\E[255;1H\E[K, use=guru+s, use=guru+unk,
@@ -14898,7 +15412,7 @@ guru-76-wm|guru 76 lines by 178 cols with 255 cols memory,
 	cols#178, lines#76,
 	is2=\E7\E[255;0;0;76;178;255p\E8\E[J, smcup=\E[76p,
 	use=guru+unk,
-aaa-rv-unk|ann arbor unknown type,
+aaa-rv-unk|Ann Arbor unknown type,
 	lh#0, lw#0, nlab#0,
 	blink=\E[5;7m, bold=\E[1;7m, home=\E[H, invis=\E[7;8m,
 	is1=\E[7m\E7\E[H\E9\E8, rev=\E[m, rmso=\E[7m, rmul=\E[7m,
@@ -14929,14 +15443,14 @@ aaa-rv-unk|ann arbor unknown type,
 
 # Regent: lowest common denominator, works on all regents.
 # (regent: renamed ":bc:" to ":le:" -- esr)
-regent|Adds Regent Series,
+regent|ADDS Regent Series,
 	OTbs, am,
 	cols#80, lines#24,
 	bel=^G, clear=^L, cr=\r, cub1=^U, cud1=\n, cuf1=^F, cuu1=^Z,
 	home=\EY\s\s, ind=\n, ll=^A,
 # Regent 100 has a bug where if computer sends escape when user is holding
 # down shift key it gets confused, so we avoid escape.
-regent100|Adds Regent 100,
+regent100|ADDS Regent 100,
 	xmc#1,
 	bel=^G,
 	cup=\013%p1%'\s'%+%c\020%p2%{10}%/%{16}%*%p2%{10}%m%+%c,
@@ -14944,23 +15458,23 @@ regent100|Adds Regent 100,
 	kf5=^B6\r, kf6=^B7\r, kf7=^B8\r, lf0=F1, lf1=F2, lf2=F3,
 	lf3=F4, lf4=F5, lf5=F6, lf6=F7, lf7=F8, rmso=\E0@, rmul=\E0@,
 	sgr0=\E0@, smso=\E0P, smul=\E0`, use=regent,
-regent20|Adds Regent 20,
+regent20|ADDS Regent 20,
 	bel=^G, cup=\EY%p1%{32}%+%c%p2%{32}%+%c, ed=\Ek, el=\EK,
 	use=regent,
-regent25|Adds Regent 25,
+regent25|ADDS Regent 25,
 	bel=^G, kcub1=^U, kcud1=\n, kcuf1=^F, kcuu1=^Z, khome=^A,
 	use=regent20,
-regent40|Adds Regent 40,
+regent40|ADDS Regent 40,
 	xmc#1,
 	bel=^G, dl1=\El$<2*>, il1=\EM$<2*>, kf1=^B1\r, kf2=^B2\r,
 	kf3=^B3\r, kf4=^B4\r, kf5=^B5\r, kf6=^B6\r, kf7=^B7\r,
 	kf8=^B8\r, lf0=F1, lf1=F2, lf2=F3, lf3=F4, lf4=F5, lf5=F6,
 	lf6=F7, lf7=F8, rmso=\E0@, rmul=\E0@, sgr0=\E0@, smso=\E0P,
 	smul=\E0`, use=regent25,
-regent40+|Adds Regent 40+,
+regent40+|ADDS Regent 40+,
 	is2=\EB, use=regent40,
 # It uses a different code for mapping acs vs dim/blink.
-regent60|regent200|adds200|Adds Regent 60,
+regent60|regent200|adds200|ADDS Regent 60,
 	acsc=jLkDl@mHnhq`tXuTv\\wPxd, dch1=\EE, ed=\Ek,
 	is2=\EV\EB, kbs=^H, kcbt=\EO, kdch1=\EE, kich1=\EF,
 	krmir=\EF, rmacs=\E2, rmir=\EF, rmso=\ER\E0@\EV, smacs=\E1,
@@ -14969,7 +15483,7 @@ regent60|regent200|adds200|Adds Regent 60,
 	use=regent40+,
 # From: <edward@onyx.berkeley.edu> Thu Jul  9 09:27:33 1981
 # (viewpoint: added <kcuf1>, function key, and <dl1> capabilities -- esr)
-viewpoint|addsviewpoint|adds viewpoint,
+viewpoint|addsviewpoint|ADDS Viewpoint,
 	OTbs, am,
 	cols#80, lines#24,
 	bel=^G, clear=^L, cnorm=\017\E0`, cr=\r, cub1=^H, cud1=\n,
@@ -14979,7 +15493,7 @@ viewpoint|addsviewpoint|adds viewpoint,
 	kf0=^B1, kf2=^B2, kf3=^B!, kf4=^B", kf5=^B#, khome=^A, ll=^A,
 	rmso=^O, rmul=^O, sgr0=^O, smso=^N, smul=^N,
 # Some viewpoints have bad ROMs that foo up on ^O
-screwpoint|adds viewpoint with ^O bug,
+screwpoint|ADDS Viewpoint with ^O bug,
 	cvvis@, rmso@, rmul@, smso@, smul@, use=viewpoint,
 
 # From: Jay S. Rouman <jsr@dexter.mi.org> 5 Jul 92
@@ -15037,7 +15551,7 @@ screwpoint|adds viewpoint with ^O bug,
 # Underlined Half Intensity
 #    Blinking                     c	0143
 # Video suppress                  D	0104
-vp3a+|viewpoint3a+|adds viewpoint 3a+,
+vp3a+|viewpoint3a+|ADDS Viewpoint 3a+,
 	am, bw,
 	cols#80, it#8, lines#24,
 	blink=\E0B\E), civis=^W, clear=\E*$<80>, cnorm=^X, cr=\r,
@@ -15050,7 +15564,7 @@ vp3a+|viewpoint3a+|adds viewpoint 3a+,
 	    %?%p2%t%{32}%|%;%?%p3%t%{16}%|%;%?%p4%t%{2}%|%;%?%p5%t
 	    %{1}%|%;%c%?%p7%tD%;\E)%e\E(%;,
 	sgr0=\E(, smso=\E0Q\E), smul=\E0`\E),
-vp60|viewpoint60|addsvp60|adds viewpoint60,
+vp60|viewpoint60|addsvp60|ADDS Viewpoint60,
 	use=regent40,
 #
 # adds viewpoint 90 - from cornell
@@ -15063,7 +15577,7 @@ vp60|viewpoint60|addsvp60|adds viewpoint60,
 #   -    <clear=\EG\Ek>: clears screen and visual attributes without affecting
 #               the status line
 # Function key and label capabilities merged in from SCO.
-vp90|viewpoint90|adds viewpoint 90,
+vp90|viewpoint90|ADDS Viewpoint 90,
 	OTbs, bw, msgr, xhp,
 	cols#80, lines#24,
 	clear=\EG\Ek, cub1=^H, cud1=\n, cuf1=^F,
@@ -15072,13 +15586,13 @@ vp90|viewpoint90|adds viewpoint 90,
 	ich1=\EF \EF\025, ind=\n, kbs=^H, kcub1=^U, kcud1=\n,
 	kcuf1=^F, kcuu1=^Z, kf0=^B1\r, kf1=^B2\r, kf10=^B;\r,
 	kf2=^B3\r, kf3=^B4\r, kf4=^B5\r, kf5=^B6\r, kf6=^B7\r,
-	kf7=^B8\r, kf8=^B9\r, kf9=\002\:\r, khome=^A, lf0=F1, lf1=F2,
+	kf7=^B8\r, kf8=^B9\r, kf9=^B:\r, khome=^A, lf0=F1, lf1=F2,
 	lf10=F11, lf2=F3, lf3=F4, lf4=F5, lf5=F6, lf6=F7, lf7=F8, lf8=F9,
 	lf9=F10, ll=^A, rmso=\ER\E0@\EV, rmul=\ER\E0@\EV,
 	sgr0=\ER\E0@\EV, smso=\ER\E0Q\EV, smul=\ER\E0`\EV,
 # Note: if return acts weird on a980, check internal switch #2
 # on the top chip on the CONTROL pc board.
-adds980|a980|adds consul 980,
+adds980|a980|ADDS Consul 980,
 	OTbs, am,
 	cols#80, lines#24,
 	bel=^G, clear=\014$<1>\013@, cr=\r, cub1=^H, cud1=\n,
@@ -15100,24 +15614,26 @@ adds980|a980|adds consul 980,
 cit80|cit-80|citoh 80,
 	OTbs, am,
 	cols#80, lines#24,
-	clear=\E[H\EJ, cr=\r, cub1=^H, cud1=\E[B, cuf1=\E[C,
-	cup=\E[%i%p1%2d;%p2%2dH, cuu1=\E[A, ed=\EJ, el=\EK, ff=^L,
-	ind=\n, is2=\E>, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC,
-	kcuu1=\EOA, rmkx=\E[?1l\E>, smkx=\E[?1h\E=,
+	clear=\E[H\EJ, cr=\r, cub1=^H, cup=\E[%i%p1%2d;%p2%2dH,
+	ed=\EJ, el=\EK, ff=^L, ind=\n, is2=\E>, kcub1=\EOD, kcud1=\EOB,
+	kcuf1=\EOC, kcuu1=\EOA, rmkx=\E[?1l\E>, smkx=\E[?1h\E=,
+	use=ansi+local1,
+
 # From: Tim Wood <mtxinu!sybase!tim> Fri Sep 27 09:39:12 PDT 1985
 # (cit101: added <rmam>/<smam> based on init string, merged this with c101 -- esr)
-cit101|citc|C.itoh fast vt100,
+cit101|citc|C. Itoh fast VT100,
 	OTbs, am, xenl,
 	cols#80, lines#24,
-	bel=^G, clear=\E[H\E[2J, cnorm=\E[V\E8, cub1=^H, cud1=\E[B,
-	cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A,
-	cvvis=\E7\E[U, dch1=\E[P, dl1=\E[M, ed=\E[J, el=\E[K,
-	flash=\E[?5h$<200/>\E[?5l, ich1=\E[@, il1=\E[L,
+	bel=^G, clear=\E[H\E[2J, cnorm=\E[V\E8, cub1=^H,
+	cup=\E[%i%p1%d;%p2%dH, cvvis=\E7\E[U, dch1=\E[P,
+	dl1=\E[M, ed=\E[J, el=\E[K, flash=\E[?5h$<200/>\E[?5l,
+	ich1=\E[@, il1=\E[L,
 	is2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h\E[3g\E[>5g,
 	kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
 	rmam=\E[?7l, rmkx=\E[?1l\E>, rmso=\E[m, rmul=\E[m,
 	sgr0=\E[m, smam=\E[?7h, smkx=\E[?1h\E=, smso=\E[7m,
-	smul=\E[4m,
+	smul=\E[4m, use=ansi+local1,
+
 # CIE Terminals CIT-101e from Geoff Kuenning <callan!geoff> via BRL
 # The following termcap entry was created from the Callan cd100 entry.  The
 # last two lines (with the capabilities in caps) are used by RM-cobol to allow
@@ -15128,15 +15644,16 @@ cit101|citc|C.itoh fast vt100,
 cit101e|C. Itoh CIT-101e,
 	OTbs, OTpt, am, mir, msgr,
 	cols#80, it#8, lines#24,
-	acsc=, clear=\E[H\E[J, cnorm=, csr=\E[%i%p1%2d;%p2%2dr,
-	cub1=\E[D, cud1=\E[B, cuf1=\E[C, cup=\E[%i%p1%2d;%p2%2dH,
-	cuu1=\E[A, cvvis=\E[?1l\E[?4l\E[?7h, dch1=\E[P, dl1=\E[M,
-	ed=\E[J, el=\E[K, if=/usr/share/tabset/vt100, il1=\E[L,
-	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kf0=\EOT,
-	kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf5=\EOm, kf6=\EOl,
-	kf7=\EOM, kf8=\EOn, rc=\E8, ri=\EM, rmacs=^O, rmir=\E[4l,
-	rmkx=\E>, rmso=\E[m, rmul=\E[m, sc=\E7, smacs=^N, smir=\E[4h,
-	smkx=\E=, smso=\E[7m, smul=\E[4m,
+	acsc=, cnorm=, csr=\E[%i%p1%2d;%p2%2dr,
+	cup=\E[%i%p1%2d;%p2%2dH, cvvis=\E[?1l\E[?4l\E[?7h,
+	dch1=\E[P, dl1=\E[M, if=/usr/share/tabset/vt100,
+	il1=\E[L, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
+	kf0=\EOT, kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf5=\EOm,
+	kf6=\EOl, kf7=\EOM, kf8=\EOn, rc=\E8, ri=\EM, rmacs=^O,
+	rmir=\E[4l, rmkx=\E>, rmso=\E[m, rmul=\E[m, sc=\E7, smacs=^N,
+	smir=\E[4h, smkx=\E=, smso=\E[7m, smul=\E[4m,
+	use=ansi+erase, use=ansi+local1,
+
 # From: David S. Lawyer, June 1997:
 # The CIT 101-e was made in Japan in 1983-4 and imported by CIE
 # Terminals in Irvine, CA.  It was part of CITOH Electronics.  In the
@@ -15154,27 +15671,24 @@ cit101e|C. Itoh CIT-101e,
 # on.  I also set up mine for parity (but you may not need it).  Then
 # save the setup with ^S.
 # (cit101e-rv: added empty <rmcup> to suppress a tic warning. --esr)
-cit101e-rv|Citoh CIT-101e (sets reverse video),
+cit101e-rv|C. Itoh CIT-101e (sets reverse video),
 	am, eo, mir, msgr, xenl, xon,
-	cols#80, it#8, lines#24,
-	OTnl=\EM, bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z,
-	civis=\E[1v, clear=\E[H\E[J, cnorm=\E[0;3;4v, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\E[B, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	cvvis=\E[3;5v, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM,
-	dl1=\E[M, ed=\E[J, el=\E[K, flash=\E[?5l$<200/>\E[?5h,
-	home=\E[H, hpa=\E[%i%p1%dG, ht=^I, hts=\EH, ich=\E[%p1%d@,
-	ich1=\E[@, il=\E[%p1%dL, il1=\E[L, ind=\n,
+	cols#80, lines#24,
+	OTnl=\EM, bel=^G, blink=\E[5m, bold=\E[1m, civis=\E[1v,
+	cnorm=\E[0;3;4v, cr=\r, cub1=^H, cup=\E[%i%p1%d;%p2%dH,
+	cvvis=\E[3;5v, flash=\E[?5l$<200/>\E[?5h, home=\E[H,
+	hpa=\E[%i%p1%dG, ind=\n,
 	is2=\E<\E>\E[?1l\E[?3l\E[?4l\E[?5h\E[?7h\E[?8h\E[3g\E[>5g\E(
 	    B\E[m\E[20l\E[1;24r\E[24;1H,
 	kbs=^?, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
-	kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, nel=\EE, rc=\E8,
-	rev=\E[7m, ri=\EM, rmcup=, rmir=\E[4l, rmso=\E[m, rmul=\E[m,
-	rs1=\Ec\E[?7h\E[>5g, sc=\E7, sgr0=\E[m,
-	smcup=\E[>5g\E[?7h\E[?5h, smir=\E[4h, smso=\E[7m,
-	smul=\E[4m, tbc=\E[3g, u6=\E[%i%p1%d;%p2%dR, u7=\E[6n,
-	u8=\E[?6c, u9=\E[c, use=ecma+index,
+	kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, nel=\EE, rev=\E[7m,
+	ri=\EM, rmcup=, rmso=\E[m, rmul=\E[m, rs1=\Ec\E[?7h\E[>5g,
+	sgr0=\E[m, smcup=\E[>5g\E[?7h\E[?5h, smso=\E[7m,
+	smul=\E[4m, u6=\E[%i%p1%d;%p2%dR, u8=\E[?6c,
+	use=ansi+enq, use=ansi+csr, use=ansi+erase, use=ansi+idc,
+	use=ansi+idl, use=ansi+inittabs, use=ansi+local,
+	use=ecma+index,
+
 cit101e-n|CIT-101e w/o am,
 	am@,
 	cvvis=\E[?1l\E[?4l\E[?7l, kbs=^H, kcub1=^H, kcud1=\n,
@@ -15200,28 +15714,25 @@ cit101e-n132|CIT-101e with 132 cols w/o am,
 # (cit500: I added <rmam>/<smam> based on the init string -- esr)
 cit500|CIE Terminals CIT-500,
 	OTbs, OTpt, mir, msgr, xon,
-	OTkn#10, cols#80, it#8, lines#64, vt#3,
-	acsc=, bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z,
-	clear=\E[H\E[J, cr=\r, csr=\E[%i%p1%d;%p2%dr,
-	cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\n,
-	cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
-	cuu=\E[%p1%dA, cuu1=\EM, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M,
-	ed=\EJ, el=\EK, home=\E[H, ht=^I, hts=\EH, il=\E[%p1%dL,
-	il1=\E[L, ind=\n, is2=\E<\E)0, kbs=^H, kcbt=\E[Z, kcub1=\EOD,
-	kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kdch1=\E[P, kdl1=\E[M,
-	ked=\EJ, kel=\EK, kf0=\EOP, kf1=\EOQ, kf2=\EOR, kf3=\EOS,
-	kf4=\EOU, kf5=\EOV, kf6=\EOW, kf7=\EOX, kf8=\EOY, kf9=\EOZ,
-	khome=\E[H, kich1=\E[4h, kil1=\E[L, krmir=\E[4l, lf0=PF1,
-	lf1=PF2, lf2=PF3, lf3=PF4, lf4=F15, lf5=F16, lf6=F17, lf7=F18,
-	lf8=F19, lf9=F20, ll=\E[64H, nel=\EE, rc=\E8, rev=\E[7m,
-	ri=\EM, rmacs=^O, rmam=\E[?7l, rmir=\E[4l, rmkx=\E[?1l\E>,
-	rmso=\E[m, rmul=\E[m,
+	OTkn#10, cols#80, lines#64, vt#3,
+	acsc=, bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[J,
+	cr=\r, cub1=^H, cud1=\n, cup=\E[%i%p1%d;%p2%dH, cuu1=\EM,
+	dch1=\E[P, ed=\EJ, el=\EK, home=\E[H, ind=\n, is2=\E<\E)0,
+	kcbt=\E[Z, kdch1=\E[P, kdl1=\E[M, ked=\EJ, kel=\EK, kf0=\EOP,
+	kf1=\EOQ, kf2=\EOR, kf3=\EOS, kf4=\EOU, kf5=\EOV, kf6=\EOW,
+	kf7=\EOX, kf8=\EOY, kf9=\EOZ, khome=\E[H, kich1=\E[4h,
+	kil1=\E[L, krmir=\E[4l, lf0=PF1, lf1=PF2, lf2=PF3, lf3=PF4,
+	lf4=F15, lf5=F16, lf6=F17, lf7=F18, lf8=F19, lf9=F20,
+	ll=\E[64H, nel=\EE, rev=\E[7m, ri=\EM, rmacs=^O, rmam=\E[?7l,
+	rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[m, rmul=\E[m,
 	rs1=\E<\E2\E[20l\E[?6l\E[r\E[m\E[q\E(B\017\E)0\E>,
-	sc=\E7, sgr0=\E[m, smacs=^N, smam=\E[?7h, smir=\E[4h,
-	smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g,
+	sgr0=\E[m, smacs=^N, smam=\E[?7h, smir=\E[4h,
+	smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m,
+	use=ansi+apparrows, use=ansi+csr, use=ansi+idl,
+	use=ansi+inittabs, use=ansi+local,
 
 # C. Itoh printers begin here
-citoh|ci8510|8510|c.itoh 8510a,
+citoh|ci8510|8510|C. Itoh 8510a,
 	cols#80, it#8,
 	bold=\E!, cub1@,
 	is2=\E(009\,017\,025\,033\,041\,049\,057\,065\,073.,
@@ -15254,7 +15765,7 @@ citoh-8lpi|citoh in 8 lines per inch mode,
 #### Control Data (cdc)
 #
 
-cdc456|cdc 456 terminal,
+cdc456|CDC 456 terminal,
 	OTbs, am,
 	cols#80, lines#24,
 	bel=^G, clear=^Y^X, cr=\r, cub1=^H, cud1=\n, cuf1=^L,
@@ -15339,43 +15850,40 @@ cdc721-esc|Control Data 721,
 # to have been at least two models, the 33 and the 50.
 #
 
-# The 50 seems to be a top end vt220 clone, with the addition of a higher
+# The 50 seems to be a top end VT220 clone, with the addition of a higher
 # screen resolution, a larger screen, at least 1 page of memory above and
 # below the screen, apparently pages of memory right and left of the screen
 # which can be panned, and about 75 function keys (15 function keys x normal,
 # shift, control, func A, func B). It also has more setup possibilities than
-# the vt220. The monitor case is dated November 1978 and the keyboard case is
+# the VT220. The monitor case is dated November 1978 and the keyboard case is
 # May 1982.
 #
-# The vt100 emulation works as is.  The entry below describes the rather
+# The VT100 emulation works as is.  The entry below describes the rather
 # non-conformant (but more featureful) ANSI mode.
 #
 # From: Stephen Peterson <stv@utrecht.ow.nl>, 27 May 1995
-visa50|geveke visa 50 terminal in ansi 80 character mode,
+visa50|Geveke VISA 50 terminal in ANSI 80 character mode,
 	bw, mir, msgr,
 	cols#80, lines#25,
 	acsc=0_aaffggh jjkkllmmnnooqqssttuuvvwwxx, bel=^G,
 	blink=\E[5m, bold=\E[1m, cbt=\E[Z, clear=\E[H\E[2J, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=\E[D,
-	cud=\E[%p1%dB, cud1=\E[B, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dX, dch1=\E[X, dim=\E[2m, dl=\E[%p1%dM,
-	dl1=\E[M, ed=\E[J, el=\E[K, flash=\E[?5h$<100/>\E[?5l,
-	home=\E[H, hpa=\E[%i%p1%dG, ht=^I, ich=\E[%p1%d@,
-	ich1=\E[@, il=\E[%p1%dL, il1=\E[L, ind=\n, invis=\E[8m,
+	csr=\E[%i%p1%d;%p2%dr, cup=\E[%i%p1%d;%p2%dH,
+	dch=\E[%p1%dX, dch1=\E[X, dim=\E[2m, ed=\E[J, el=\E[K,
+	flash=\E[?5h$<100/>\E[?5l, home=\E[H, hpa=\E[%i%p1%dG,
+	ht=^I, ind=\n, invis=\E[8m,
 	is2=\E0;2m\E[1;25r\E[25;1H\E[?3l\E[?7h\E[?8h,
-	ka1=\E[f, ka3=\EOQ, kb2=\EOP, kbs=^H, kc1=\EOR, kc3=\EOS,
-	kcub1=\E[D, kcud1=\E[A, kcuf1=\E[C, kcuu1=\E[A, kdch1=^?,
+	ka1=\E[f, ka3=\EOQ, kb2=\EOP, kc1=\EOR, kc3=\EOS, kdch1=^?,
 	kdl1=\EOS, kf0=\E010, kf1=\E001, kf10=\E011, kf2=\E002,
 	kf3=\E003, kf4=\E004, kf5=\E005, kf6=\E006, kf7=\E007,
 	kf8=\E008, kf9=\E009, khome=\E[f, lf2=A delete char,
 	lf3=A insert line, lf4=A delete line, lf5=A clear,
 	lf6=A ce of/cf gn, lf7=A print, lf8=A on-line,
 	lf9=A funcl0=A send, nel=\r\n, rev=\E[7m, rmacs=\E[3l,
-	rmam=\E[?7l, rmir=\E[4l, rmkx=\E>, rmso=\E[0;2m,
-	rmul=\E[0m, sgr0=\E[0;2m, smacs=\E3h, smam=\E?7h,
-	smir=\E[4h, smkx=\E=, smso=\E[2;7m, smul=\E[4m, tbc=\E[3g,
-	vpa=\E[%i%p1%dd,
+	rmam=\E[?7l, rmkx=\E>, rmso=\E[0;2m, rmul=\E[0m,
+	sgr0=\E[0;2m, smacs=\E3h, smam=\E?7h, smkx=\E=,
+	smso=\E[2;7m, smul=\E[4m, tbc=\E[3g, vpa=\E[%i%p1%dd,
+	use=ansi+arrows, use=ansi+idc, use=ansi+idl,
+	use=ansi+local,
 
 #### Human Designed Systems (Concept)
 #
@@ -15425,29 +15933,29 @@ visa50|geveke visa 50 terminal in ansi 80 character mode,
 #
 # No delays needed on c108 because of ^S/^Q handshaking
 #
-c108|concept108|c108-8p|concept108-8p|concept 108 w/8 pages,
+c108|concept108|c108-8p|concept108-8p|Concept 108 w/8 pages,
 	is3=\EU\E\sz"\Ev\001\177\s!p\E\s;"\E\sz\s\Ev\s\s\001\177p
 	    \Ep\n,
 	rmcup=\Ev  \001\177p\Ep\r\n, use=c108-4p,
-c108-4p|concept108-4p|concept 108 w/4 pages,
-	OTbs, eslok, hs, xon,
+c108-4p|concept108-4p|Concept 108 w/4 pages,
+	eslok, hs, xon,
 	pb@,
 	acsc=jEkTl\\mMqLxU, cnorm=\Ew, cr=\r,
 	cup=\Ea%p1%?%p1%{95}%>%t\001%{96}%-%;%{32}%+%c%p2%?%p2%{95}
 	    %>%t\001%{96}%-%;%{32}%+%c,
 	cvvis=\EW, dch1=\E 1$<16*>, dsl=\E ;\177, fsl=\Ee\E z\s,
-	ind=\n, is1=\EK\E!\E F,
+	is1=\EK\E!\E F,
 	is3=\EU\E z"\Ev\177 !p\E ;"\E z \Ev  \001 p\Ep\n,
 	rmacs=\Ej\s, rmcup=\Ev  \001 p\Ep\r\n, smacs=\Ej!,
 	smcup=\EU\Ev  8p\Ep\r\E\025,
 	tsl=\E z"\E?\E\005\EE\Ea %+\s, use=c100,
-c108-rv|c108-rv-8p|concept 108 w/8 pages in reverse video,
+c108-rv|c108-rv-8p|Concept 108 w/8 pages in reverse video,
 	rmcup=\Ev  \002 p\Ep\r\n, smcup=\EU\Ev  8p\Ep\r,
 	use=c108-rv-4p,
-c108-rv-4p|concept108rv4p|concept 108 w/4 pages in reverse video,
+c108-rv-4p|concept108rv4p|Concept 108 w/4 pages in reverse video,
 	flash=\EK$<200>\Ek, is1=\Ek, rmso=\Ee, smso=\EE,
 	use=c108-4p,
-c108-w|c108-w-8p|concept108-w-8|concept108-w8p|concept 108 w/8 pages in wide mode,
+c108-w|c108-w-8p|concept108-w-8|concept108-w8p|Concept 108 w/8 pages in wide mode,
 	cols#132,
 	is1=\E F\E", rmcup=\Ev  ^A0\001D\Ep\r\n,
 	smcup=\EU\Ev  8\001D\Ep\r, use=c108-8p,
@@ -15490,7 +15998,7 @@ c108-w|c108-w-8p|concept108-w-8|concept108-w8p|concept 108 w/8 pages in wide mod
 # \EQ"\EY(^W (send anything from printer to host, for xon/xoff)
 # cannot be # in is2 because it will hang a c100 with no printer
 # if sent twice.
-c100|concept100|concept|c104|c100-4p|hds concept 100,
+c100|concept100|concept|c104|c100-4p|HDS Concept 100,
 	OTbs, am, eo, mir, ul, xenl,
 	cols#80, lines#24, pb#9600, vt#8,
 	bel=^G, blink=\EC, clear=\E?\E\005$<2*>, cr=$<9>\r,
@@ -15501,11 +16009,11 @@ c100|concept100|concept|c104|c100-4p|hds concept 100,
 	ht=\011$<8>, il1=\E\022$<3*>, ind=\n, invis=\EH, ip=$<16*>,
 	is1=\EK,
 	is2=\EU\Ef\E7\E5\E8\El\ENH\E\0\Eo&\0\Eo'\E\Eo!\0\E\007!\E
-	    \010A@\s\E4#\:"\E\:a\E4#;"\E\:b\E4#<"\E\:c,
+	    \010A@\s\E4#:"\E:a\E4#;"\E:b\E4#<"\E:c,
 	is3=\Ev    $<6>\Ep\n, kbs=^H, kcbt=\E', kctab=\E_,
 	kcub1=\E>, kcud1=\E<, kcuf1=\E=, kcuu1=\E;, kdch1=\E^Q,
 	kdl1=\E^B, ked=\E^C, kel=\E^S, kf1=\E5, kf2=\E6, kf3=\E7,
-	kf4=\E8, kf5=\E9, kf6=\E\:a, kf7=\E\:b, kf8=\E\:c, khome=\E?,
+	kf4=\E8, kf5=\E9, kf6=\E:a, kf7=\E:b, kf8=\E:c, khome=\E?,
 	khts=\E], kich1=\E^P, kil1=\E^R, kind=\E[, knp=\E-, kpp=\E.,
 	kri=\E\\, krmir=\E\0, mc4=\036o \E\EQ!\EYP\027,
 	mc5=\EQ"\EY(\027\EYD\Eo \036, prot=\EI,
@@ -15514,10 +16022,10 @@ c100|concept100|concept|c104|c100-4p|hds concept 100,
 	rmso=\Ed, rmul=\Eg, sgr0=\EN@,
 	smcup=\EU\Ev  8p\Ep\r\E\025$<16>, smir=\E^P, smkx=\EX,
 	smso=\ED, smul=\EG,
-c100-rv|c100-rv-4p|concept100-rv|c100 rev video,
+c100-rv|c100-rv-4p|concept100-rv|Concept 100 reverse video,
 	cnorm@, cvvis@, flash=\EK$<200>\Ek, is1=\Ek, rmso=\Ee,
 	smso=\EE, use=c100,
-oc100|oconcept|c100-1p|old 1 page concept 100,
+oc100|oconcept|c100-1p|old 1-page Concept 100,
 	in,
 	is3@, use=c100,
 
@@ -15761,27 +16269,20 @@ oc100|oconcept|c100-1p|old 1 page concept 100,
 #	 and mc5= should use the \E[?4i and \E[?5i strings instead).
 
 hds200|Human Designed Systems HDS200,
-	am, bw, eslok, hs, km, mir, msgr, xenl, xon,
-	cols#80, it#8, lines#24, lm#0,
+	am, bw, eslok, hs, km, mir, msgr, xenl, xon, NQ,
+	cols#80, lines#24, lm#0,
 	acsc=``aaffggjjkkllmmnnooqqssttuuvvwwxx~~, bel=^G,
-	blink=\E[0;5m, bold=\E[0;1m, cbt=\E[Z, civis=\E[6+{,
-	clear=\E[H\E[J, cnorm=\E[+{, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=\E[D,
-	cud=\E[%p1%dB, cud1=\E[B, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M,
-	dsl=\E[2!w\r\n\E[!w, ed=\E[J, el=\E[K, el1=\E[1K,
-	fsl=\E[!w, home=\E[H, hpa=\E[%i%p1%dG, ht=^I, hts=\EH,
-	ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L, ind=\ED,
-	invis=\E[0;8m,
+	blink=\E[0;5m, bold=\E[0;1m, civis=\E[6+{, cnorm=\E[+{,
+	cr=\r, cup=\E[%i%p1%d;%p2%dH, dch=\E[%p1%dP, dch1=\E[P,
+	dsl=\E[2!w\r\n\E[!w, el1=\E[1K, fsl=\E[!w, home=\E[H,
+	hpa=\E[%i%p1%dG, ich=\E[%p1%d@, ind=\ED, invis=\E[0;8m,
 	is2=\E)0\017\E[m\E[=107;207h\E[90;3u\E[92;3u\E[43;1u\177\E$P
 	    \177\E[44;1u\177\E$Q\177\E[45;1u\177\E$R\177\E[46;1u
 	    \177\E$S\177\E[200;1u\177\E$A\177\E[201;1u\177\E$B\177
 	    \E[202;1u\177\E$C\177\E[203;1u\177\E$D\177\E[204;1u\177
 	    \E$H\177\E[212;1u\177\E$I\177\E[213;1u\177\E$\010\177\E[
 	    214;1u"\E$\177"\E[2!w\E[25;25w\E[!w\E[2*w\E[2+x\E[;3+},
-	kDC=\E$^?, kHOM=\E$H, kLFT=\E$D, kRIT=\E$C, kbs=^H,
-	kcbt=\E$I, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
+	kDC=\E$^?, kHOM=\E$H, kLFT=\E$D, kRIT=\E$C, kcbt=\E$I,
 	kdch1=^?, kent=\r, kf1=^\001\r, kf10=^\010\r, kf11=^\011\r,
 	kf12=^\012\r, kf13=\EOP, kf14=\EOQ, kf15=\EOR, kf16=\EOS,
 	kf17=^\017\r, kf18=^\018\r, kf19=^\019\r, kf2=^\002\r,
@@ -15793,56 +16294,55 @@ hds200|Human Designed Systems HDS200,
 	kf45=\E$R, kf46=\E$S, kf47=^\047\r, kf48=^\048\r,
 	kf49=^\049\r, kf5=^\005\r, kf50=^\050\r, kf51=^\051\r,
 	kf52=^\052\r, kf53=^\053\r, kf6=^\006\r, kf7=^\007\r,
-	kf8=^\008\r, kf9=^\009\r, khome=\E[H, kind=\E[T, knp=\E[U,
-	kpp=\E[V, kri=\E[S, ll=\E[H\E[A, nel=\E[E, rc=\E8,
-	rev=\E[0;7m, ri=\EM, rmacs=^O, rmir=\E[4l, rmso=\E[m\017,
-	rmul=\E[m\017, sc=\E7,
+	kf8=^\008\r, kf9=^\009\r, kind=\E[T, knp=\E[U, kpp=\E[V,
+	kri=\E[S, ll=\E[H\E[A, nel=\E[E, rev=\E[0;7m, ri=\EM,
+	rmacs=^O, rmir=\E[4l, rmso=\E[m\017, rmul=\E[m\017,
 	sgr=\E[0%?%p1%p6%O%t;1%;%?%p2%t;4%;%?%p4%t;5%;%?%p1%p3%O%t;7
 	    %;%?%p7%t;8%;m%?%p9%t\016%e\017%;,
 	sgr0=\E[m\017, smacs=^N, smir=\E[4h, smso=\E[0;1;7m,
-	smul=\E[0;4m, tbc=\E[3g, tsl=\E[2!w\E[%i%p1%dG,
-	vpa=\E[%i%p1%dd, use=ansi+pp,
+	smul=\E[0;4m, tsl=\E[2!w\E[%i%p1%dG, vpa=\E[%i%p1%dd,
+	use=ansi+arrows, use=ansi+csr, use=ansi+erase,
+	use=ansi+idl, use=ansi+inittabs, use=ansi+local,
+	use=ansi+pp,
 
 # <ht> through <el> included to specify padding needed in raw mode.
 # (avt-ns: added empty <acsc> to suppress a tic warning --esr)
-avt-ns|concept avt no status line,
+avt-ns|Concept AVT no status line,
 	OTbs, am, eo, mir, ul, xenl, xon,
-	cols#80, it#8, lines#24, lm#192,
-	acsc=, bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z,
-	clear=\E[H\E[J$<38>, cnorm=\E[=119l, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	cvvis=\E[=119h, dch1=\E[P, dim=\E[1!{, dl=\E[%p1%dM$<4*>,
-	dl1=\E[M$<4>, ed=\E[J$<96>, el=\E[K$<6>, home=\E[H,
-	hpa=\E[%p1%{1}%+%dG, ht=\011$<4>, hts=\EH, ich=\E[%p1%d@,
-	ich1=\E[@, il=\E[%p1%dL$<4*>, il1=\E[L$<4>, ind=\n$<8>,
-	invis=\E[8m, ip=$<4>, is1=\E[=103l\E[=205l,
+	cols#80, lines#24, lm#192,
+	acsc=, bel=^G, clear=\E[H\E[J$<38>, cnorm=\E[=119l, cr=\r,
+	cub1=^H, cud1=\n, cup=\E[%i%p1%d;%p2%dH, cvvis=\E[=119h,
+	dim=\E[1!{, dl=\E[%p1%dM$<4*>, dl1=\E[M$<4>,
+	ed=\E[J$<96>, el=\E[K$<6>, home=\E[H,
+	hpa=\E[%p1%{1}%+%dG, ht=\011$<4>, ich=\E[%p1%d@,
+	il=\E[%p1%dL$<4*>, il1=\E[L$<4>, ind=\n$<8>, ip=$<4>,
+	is1=\E[=103l\E[=205l,
 	is2=\E[1*q\E[2!t\E[7!t\E[=4;101;119;122l\E[=107;118;207h\E)1
-	    \E[1Q\EW\E[!y\E[!z\E>\E[0\:0\:32!r\E[0*w\E[w\E2\r\n\E[2;
-	    27!t,
-	kbs=^H, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
+	    \E[1Q\EW\E[!y\E[!z\E>\E[0:0:32!r\E[0*w\E[w\E2\r\n\E[2;27
+	    !t,
 	kdch1=\E\002\r, ked=\E\004\r, kf1=\EOP, kf2=\EOQ, kf3=\EOR,
-	kf4=\EOS, khome=\E[H, kich1=\E\001\r, kil1=\E\003\r,
-	ll=\E[24H, mc0=\E[0i, mc4=\E[4i, mc5=\E[5i,
+	kf4=\EOS, kich1=\E\001\r, kil1=\E\003\r, ll=\E[24H,
+	mc0=\E[0i, mc4=\E[4i, mc5=\E[5i,
 	pfloc=\E[%p1%d;0u#%p2%s#, pfx=\E[%p1%d;1u#%p2%s#,
-	prot=\E[99m, rc=\E8, rev=\E[7m, ri=\EM$<4>, rmacs=\016$<1>,
-	rmcup=\E[w\E2\r\n, rmir=\E[4l, rmkx=\E[!z\E[0;2u,
-	rmso=\E[7!{, rmul=\E[4!{, sc=\E7,
+	prot=\E[99m, ri=\EM$<4>, rmacs=\016$<1>,
+	rmcup=\E[w\E2\r\n, rmkx=\E[!z\E[0;2u, rmso=\E[7!{,
+	rmul=\E[4!{,
 	sgr=\E[%?%p1%t7;%;%?%p2%t4;%;%?%p3%t7;%;%?%p4%t5;%;%?%p6%t1;
 	    %;%?%p7%t8;%;%?%p8%t99;%;m%?%p5%t\E[1!{%;%?%p9%t\017%e
 	    \016%;$<1>,
 	sgr0=\E[m\016$<1>, smacs=\017$<1>,
-	smcup=\E[=4l\E[1;24w\E2\r, smir=\E[4h,
-	smkx=\E[1!z\E[0;3u, smso=\E[7m, smul=\E[4m, tbc=\E[3g,
-	vpa=\E[%p1%{1}%+%dd, use=ansi+rep,
-avt-rv-ns|concept avt in reverse video mode/no status line,
+	smcup=\E[=4l\E[1;24w\E2\r, smkx=\E[1!z\E[0;3u,
+	vpa=\E[%p1%{1}%+%dd, use=ansi+arrows, use=ansi+csr,
+	use=ansi+idc1, use=ansi+inittabs, use=ansi+local,
+	use=ansi+rep, use=ansi+sgrbold,
+
+avt-rv-ns|Concept AVT in reverse video mode/no status line,
 	flash=\E[=205l$<200>\E[=205h, is1=\E[=103l\E[=205h,
 	use=avt-ns,
-avt-w-ns|concept avt in 132 column mode/no status line,
+avt-w-ns|Concept AVT in 132 column mode/no status line,
 	is1=\E[=103h\E[=205l, smcup=\E[H\E[1;24;1;132w,
 	use=avt-ns,
-avt-w-rv-ns|concept avt in 132 column mode/no status line/reverse video,
+avt-w-rv-ns|Concept AVT in 132 column mode/no status line/reverse video,
 	flash=\E[=205l$<200>\E[=205h, is1=\E[=103h\E[=205h,
 	smcup=\E[H\E[1;24;1;132w, use=avt-ns,
 
@@ -15854,22 +16354,22 @@ avt-w-rv-ns|concept avt in 132 column mode/no status line/reverse video,
 # on both 4 and 8 page AVTs. (Note the lm#191 or 192 - this
 # assumes an 8 page AVT but lm isn't currently used anywhere.)
 #
-avt+s|concept avt status line changes,
+avt+s|Concept AVT status line changes,
 	eslok, hs,
 	lm#191,
 	dsl=\E[0*w, fsl=\E[1;1!w,
 	is3=\E[2w\E[2!w\E[1;1;1;80w\E[H\E[2*w\E[1!w\E2\r\n,
 	rmcup=\E[2w\E2\r\n, smcup=\E[2;25w\E2\r,
 	tsl=\E[2;1!w\E[;%p1%dH\E[2K,
-avt|avt-s|concept-avt|avt w/80 columns,
+avt|avt-s|concept-avt|Concept AVT w/80 columns,
 	use=avt+s, use=avt-ns,
-avt-rv|avt-rv-s|avt reverse video w/sl,
+avt-rv|avt-rv-s|Concept AVT reverse video w/sl,
 	flash=\E[=205l$<200>\E[=205h, is1=\E[=103l\E[=205h,
 	use=avt+s, use=avt-ns,
-avt-w|avt-w-s|concept avt 132 cols+status,
+avt-w|avt-w-s|Concept AVT 132 cols+status,
 	is1=\E[=103h\E[=205l, smcup=\E[H\E[1;24;1;132w,
 	use=avt+s, use=avt-ns,
-avt-w-rv|avt-w-rv-s|avt wide+status+rv,
+avt-w-rv|avt-w-rv-s|Concept AVT wide+status+rv,
 	flash=\E[=205l$<200>\E[=205h, is1=\E[=103h\E[=205h,
 	smcup=\E[H\E[1;24;1;132w, use=avt+s, use=avt-ns,
 
@@ -15968,7 +16468,7 @@ dgkeys+11|Private entry describing 11 minimal-subset DG mode special keys,
 	kf15=^^d, kf16=^^e, kf17=^^f, kf18=^^g, kf19=^^h, kf2=^^r,
 	kf20=^^i, kf21=^^j, kf22=^^k, kf23=^^1, kf24=^^2, kf25=^^3,
 	kf26=^^4, kf27=^^5, kf28=^^6, kf29=^^7, kf3=^^s, kf30=^^8,
-	kf31=^^9, kf32=^^\:, kf33=^^;, kf34=^^!, kf35=^^", kf36=^^#,
+	kf31=^^9, kf32=^^:, kf33=^^;, kf34=^^!, kf35=^^", kf36=^^#,
 	kf37=^^$, kf38=^^%%, kf39=^^&, kf4=^^t, kf40=^^', kf41=^^(,
 	kf42=^^), kf43=^^*, kf44=^^+, kf5=^^u, kf6=^^v, kf7=^^w,
 	kf8=^^x, kf9=^^y, khome=^H,
@@ -15980,7 +16480,7 @@ dgkeys+15|Private entry describing 15 DG mode special keys,
 	kf2=^^r, kf20=^^e, kf21=^^f, kf22=^^g, kf23=^^h, kf24=^^i,
 	kf25=^^j, kf26=^^k, kf27=^^l, kf28=^^m, kf29=^^n, kf3=^^s,
 	kf30=^^`, kf31=^^1, kf32=^^2, kf33=^^3, kf34=^^4, kf35=^^5,
-	kf36=^^6, kf37=^^7, kf38=^^8, kf39=^^9, kf4=^^t, kf40=^^\:,
+	kf36=^^6, kf37=^^7, kf38=^^8, kf39=^^9, kf4=^^t, kf40=^^:,
 	kf41=^^;, kf42=^^<, kf43=^^=, kf44=^^>, kf45=^^0, kf46=^^!,
 	kf47=^^", kf48=^^#, kf49=^^$, kf5=^^u, kf50=^^%%, kf51=^^&,
 	kf52=^^', kf53=^^(, kf54=^^), kf55=^^*, kf56=^^+, kf57=^^\,,
@@ -15998,14 +16498,7 @@ dgkeys+15|Private entry describing 15 DG mode special keys,
 #	u8=^^F}20^^Fi^^F}21,
 #
 dgunix+fixed|Fixed color info for DG D430C terminals in DG-UNIX mode,
-	bce,
-	colors#16, ncv#53, pairs#0x100,
-	op=\036Ad\036Bd,
-	setab=\036B%p1%?%p1%{8}%<%t%{2}%&%?%p1%{1}%&%t%{4}%|%;%?%p1
-	      %{4}%&%t%{1}%|%;%;%{48}%+%c,
-	setaf=\036A%p1%?%p1%{8}%<%t%{2}%&%?%p1%{1}%&%t%{4}%|%;%?%p1
-	      %{4}%&%t%{1}%|%;%;%{48}%+%c,
-	setb=\036B%p1%{48}%+%c, setf=\036A%p1%{48}%+%c,
+	ncv#53, use=dgmode+color,
 
 dg+fixed|Fixed color info for DG D430C terminals in DG mode,
 	use=dgunix+fixed,
@@ -16082,16 +16575,16 @@ dg+ccc|Configurable color info for DG D430C terminals in DG mode,
 	      %+%c%ga%{16}%m%{48}%+%c%p6%{255}%*%{1000}%/%Pa%ga%{16}
 	      %/%{48}%+%c%ga%{16}%m%{48}%+%c%p7%{255}%*%{1000}%/%Pa
 	      %ga%{16}%/%{48}%+%c%ga%{16}%m%{48}%+%c,
-	oc=\036RG01\:00??00000000\036RG01;00000000??00\036RG01<007?0
-	   0000000\036RG01=000000007?00,
-	op=\036RF4831\:\036RF2>31;\036RF1=31<\036RF3?31=,
+	oc=\036RG01:00??00000000\036RG01;00000000??00\036RG01<007?00
+	   000000\036RG01=000000007?00,
+	op=\036RF4831:\036RF2>31;\036RF1=31<\036RF3?31=,
 	scp=\036RG2%p1%{16}%/%{48}%+%c%p1%{16}%m%{48}%+%c,
 
 # The generic DG terminal type (an 8-bit-clean subset of the 6053)
 # Initialization string 1 sets:
 #	^R		- vertical scrolling enabled
 #	^C		- blinking enabled
-dg-generic|Generic Data General terminal in DG mode,
+dg-generic|generic Data General terminal in DG mode,
 	am, bw, msgr, xon,
 	cols#80, lines#24,
 	bel=^G, blink=^N, clear=^L, cr=\r, cub1=^Y, cud1=^Z, cuf1=^X,
@@ -16104,7 +16597,7 @@ dg-generic|Generic Data General terminal in DG mode,
 # notation that's "^P%r%+\200%+\200").  Those \200s are suspicious,
 # maybe they were originally nuls (which would fit).
 
-dg200|data general dasher 200,
+dg200|Data General DASHER 200,
 	OTbs, am, bw,
 	cols#80, lines#24,
 	bel=^G, clear=^L, cr=\r, cub1=^Y, cud1=^Z, cuf1=^X,
@@ -16118,11 +16611,11 @@ dg200|data general dasher 200,
 dg210|dg-ansi|Data General 210/211,
 	am,
 	cols#80, lines#24,
-	OTnl=\E[B, clear=\E[2J, cub1=\E[D, cud1=\E[B, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, ed=\E[J, el=\E[K,
-	home=\E[H, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
-	khome=\E[H, nel=\r\E[H\E[A\n, rmso=\E[0;m, rmul=\E[0;m,
-	smso=\E[7;m, smul=\E[4;m,
+	OTnl=\E[B, clear=\E[2J, cup=\E[%i%p1%d;%p2%dH, ed=\E[J,
+	el=\E[K, home=\E[H, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C,
+	kcuu1=\E[A, khome=\E[H, nel=\r\E[H\E[A\n, rmso=\E[0;m,
+	rmul=\E[0;m, smso=\E[7;m, smul=\E[4;m, use=ansi+local1,
+
 # From: Peter N. Wan <ihnp4!gatech!gacsr!wan>
 # courtesy of Carlos Rucalde of Vantage Software, Inc.
 # (dg211: this had <cup=\020%r%.%>., which was an ancient termcap hangover.
@@ -16133,7 +16626,7 @@ dg211|Data General d211,
 	rmso=\036E$<0/>, smcup=^L^R, smso=\036D$<5/>, use=dg200,
 
 # dg450 from Cornell (not official)
-dg450|dg6134|data general 6134,
+dg450|dg6134|Data General 6134,
 	cub1@, cuf1=^X, use=dg200,
 
 # Not official...
@@ -16148,20 +16641,19 @@ dg450|dg6134|data general 6134,
 dg460-ansi|Data General Dasher 460 in ANSI-mode,
 	OTbs, am, msgr, ul,
 	cols#80, it#8, lines#24,
-	OTnl=\ED, blink=\E[5m, clear=\E[2J, cub1=^H, cud1=\E[B,
-	cuf1=\E[C, cup=\E[%i%p1%2d;%p2%2dH, cuu1=\E[A, dch1=\E[P,
-	dim=\E[2m, dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H, ht=^I,
-	ich1=\E[@, il1=\E[L, ind=\E[S, is2=^^F@, kbs=\E[D,
-	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
-	kf0=\E[001z, kf1=\E[002z, kf2=\E[003z, kf3=\E[004z,
-	kf4=\E[005z, kf5=\E[006z, kf6=\E[007z, kf7=\E[008z,
-	kf8=\E[009z, kf9=\E[00\:z, khome=\E[H, lf0=f1, lf1=f2,
-	lf2=f3, lf3=f4, lf4=f5, lf5=f6, lf6=f7, lf7=f8, lf9=f10,
+	OTnl=\ED, blink=\E[5m, clear=\E[2J, cub1=^H,
+	cup=\E[%i%p1%2d;%p2%2dH, dch1=\E[P, dim=\E[2m, dl1=\E[M,
+	ed=\E[J, el=\E[K, home=\E[H, ht=^I, ich1=\E[@, il1=\E[L,
+	ind=\E[S, is2=^^F@, kbs=\E[D, kf0=\E[001z, kf1=\E[002z,
+	kf2=\E[003z, kf3=\E[004z, kf4=\E[005z, kf5=\E[006z,
+	kf6=\E[007z, kf7=\E[008z, kf8=\E[009z, kf9=\E[00:z, lf0=f1,
+	lf1=f2, lf2=f3, lf3=f4, lf4=f5, lf5=f6, lf6=f7, lf7=f8, lf9=f10,
 	mc0=\E[i, rev=\E[7m, ri=\E[T, rmso=\E[m, rmul=\E[05,
 	sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p5%t;2%;%?%p2%t;4%;%?%p4%t;5%;
 	    %?%p1%p3%|%t;7%;m,
-	sgr0=\E(B\E[m, smso=\E[7m, smul=\E[4m, u6=\E[%d;%dR,
-	u7=\E[6n, u8=\E[5n, u9=\E[0n,
+	sgr0=\E(B\E[m, smso=\E[7m, smul=\E[4m, u8=\E[5n, u9=\E[0n,
+	use=ansi+arrows, use=ansi+cpr, use=ansi+local1,
+
 # From: Wayne Throop <mcnc!rti-sel!rtp47!throopw> (not official)
 # Data General 605x
 # Ought to work for a Model 6242, Type D210 as well as a 605x.
@@ -16169,7 +16661,7 @@ dg460-ansi|Data General Dasher 460 in ANSI-mode,
 # This also matches a posted description of something called a `Dasher 100'
 # so there's a dg100 alias here.
 # (dg6053: the 4.4BSD file had <cub1=^H>, <cud1=^J>, <cuf1=^S>. -- esr)
-dg6053-old|dg100|data general 6053,
+dg6053-old|dg100|Data General 6053,
 	OTbs, am, bw, ul,
 	cols#80, lines#24,
 	OTbc=^Y, bel=^G, clear=^L, cnorm=^L, cr=\r, cub1=^Y, cud1=^Z,
@@ -16203,14 +16695,13 @@ d210|d214|Data General DASHER D210 series,
 	am, bw, msgr, xon,
 	cols#80, lines#24,
 	bel=^G, blink=\E[5m, bold=\E[4;7m, clear=\E[2J, cr=\r,
-	cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\E[B,
-	cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
-	cuu=\E[%p1%dA, cuu1=\E[A, dim=\E[2m, ed=\E[J, el=\E[K,
-	el1=\E[1K, home=\E[H, ind=\n, is1=\E[<0;<1;<4l,
+	cub1=^H, cup=\E[%i%p1%d;%p2%dH, dim=\E[2m, ed=\E[J,
+	el=\E[K, el1=\E[1K, home=\E[H, ind=\n, is1=\E[<0;<1;<4l,
 	ll=\E[H\E[A, nel=\n, rev=\E[7m, rmso=\E[m, rmul=\E[m,
 	sgr=\E[%?%p4%t5;%;%?%p2%p6%|%t4;%;%?%p1%p5%|%t2;%;%?%p1%p3%|
 	    %p6%|%t7;%;m,
-	sgr0=\E[m, smso=\E[2;7m, smul=\E[4m, use=dgkeys+7b,
+	sgr0=\E[m, smso=\E[2;7m, smul=\E[4m, use=ansi+local,
+	use=dgkeys+7b,
 
 # DASHER D210 series terminals in DG mode.
 # Like D200, but adds clear to end-of-screen and needs XON/XOFF.
@@ -16408,17 +16899,17 @@ d400|d400-dg|d450|d450-dg|Data General DASHER D400/D450 series,
 #	\E)4		- default secondary character set (international)
 #
 d410|d411|d460|d461|Data General DASHER D410/D460 series,
-	mc5i,
 	acsc=j$k"l!m#n)q+t'u&v(w%x*, civis=\E[3;0v,
-	cnorm=\E[3;2v, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM,
-	dl1=\E[M, ich=\E[%p1%d@, ich1=\E[@, il=\E[%p1%dL, il1=\E[L,
+	cnorm=\E[3;2v, dch=\E[%p1%dP, dch1=\E[P, ich=\E[%p1%d@,
+	ich1=\E[@,
 	is1=\E[<0;<1;<2;<4l\E[5;0v\E[1;1;80w\E[1;6;<2h,
-	is2=\E[3;2;2;1;1;1v\E(B\E)4\017, mc4=\E[4i, mc5=\E[5i,
-	ri=\EM, rmacs=\E)4\017, rs1=\Ec\E[<2h,
+	is2=\E[3;2;2;1;1;1v\E(B\E)4\017, ri=\EM,
+	rmacs=\E)4\017, rs1=\Ec\E[<2h,
 	rs2=\E[4;0;2;1;1;1v\E(B\E)4,
 	sgr=\E[%?%p1%t2;7%;%?%p3%t7;%;%?%p4%t5;%;%?%p2%t4;%;%?%p1%p5
 	    %|%t2;%;%?%p6%t4;7;%;m\E)%?%p9%t6\016%e4\017%;,
 	sgr0=\E[m\E)4\017, smacs=\E)6\016, use=d211,
+	use=ansi+idl, use=ansi+pp,
 
 # Initialization string 2 sets:
 #	\E[3;2;2;0;1;0v
@@ -16681,17 +17172,18 @@ d578-7b|Data General DASHER D578 in 7-bit mode,
 cs10|colorscan|Datamedia Color Scan 10,
 	msgr,
 	cols#80, lines#24,
-	bel=^G, clear=\E[H\E[J, cr=\r, cub1=^H, cud1=\n, cuf1=\E[C,
-	cup=\E[%i%p1%02d;%p2%02dH, cuu1=\E[A, ed=\E[J, el=\E[K,
-	ind=\n, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
-	kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, rmso=\E[m, rmul=\E[m,
-	sgr0=\E[m, smso=\E[7m, smul=\E[4m,
+	bel=^G, cr=\r, cub1=^H, cud1=\n, cuf1=\E[C,
+	cup=\E[%i%p1%02d;%p2%02dH, cuu1=\E[A, ind=\n, kcub1=\E[D,
+	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kf1=\EOP, kf2=\EOQ,
+	kf3=\EOR, kf4=\EOS, rmso=\E[m, rmul=\E[m, sgr0=\E[m,
+	smso=\E[7m, smul=\E[4m, use=ansi+erase,
+
 cs10-w|Datamedia Color Scan 10 with 132 columns,
 	cols#132,
 	cup=\E[%i%p1%02d;%p2%03dH, use=cs10,
 
 # (dm1520: removed obsolete ":ma=^\ ^_^P^YH:" -- esr)
-dm1520|dm1521|datamedia 1520,
+dm1520|dm1521|Datamedia 1520,
 	OTbs, am, xenl,
 	cols#80, it#8, lines#24,
 	bel=^G, clear=^L, cr=\r, cub1=^H, cud1=\n, cuf1=^\,
@@ -16700,7 +17192,7 @@ dm1520|dm1521|datamedia 1520,
 	khome=^Y,
 # dm2500: this terminal has both <ich> and <smir>. Applications using
 # termcap/terminfo directly (rather than through ncurses) might be confused.
-dm2500|datamedia2500|datamedia 2500,
+dm2500|datamedia2500|Datamedia 2500,
 	OTbs, OTnc,
 	cols#80, lines#24,
 	bel=^G, clear=^^^^^?, cub1=^H, cud1=\n, cuf1=^\,
@@ -16715,12 +17207,12 @@ dm2500|datamedia2500|datamedia 2500,
 # also, has a meta-key.
 # From: <goldberger@su-csli.arpa>
 # (dmchat: ":MT:" changed to ":km:" -- esr)
-dmchat|dmchat version of datamedia 2500,
+dmchat|dmchat version of Datamedia 2500,
 	km,
 	dl1=\020\032\030\035$<2/>,
 	il1=\020\n\030\035\030\035$<1*/>, use=dm2500,
 # (dm3025: ":MT:" changed to ":km:" -- esr)
-dm3025|datamedia 3025a,
+dm3025|Datamedia 3025a,
 	OTbs, km,
 	cols#80, it#8, lines#24,
 	bel=^G, clear=\EM$<2>, cr=\r, cub1=^H, cud1=\n, cuf1=\EC,
@@ -16729,13 +17221,11 @@ dm3025|datamedia 3025a,
 	home=\EH, ht=^I, il1=\EP\n\EQ$<130>, ind=\n, ip=$<6>,
 	is2=\EQ\EU\EV, rmdc=\EQ, rmir=\EQ, rmso=\EO0, smdc=\EP,
 	smir=\EP, smso=\EO1,
-dm3045|datamedia 3045a,
-	OTbs, am, eo, km@, ul, xenl,
+dm3045|Datamedia 3045a,
+	am, eo, km@, ul, xenl,
 	dch1=\EB$<6>, dl1@, il1@, is2=\EU\EV, kcuf1=\EC, kcuu1=\EA,
-	kf0=\Ey\r, kf1=\Ep\r, kf2=\Eq\r, kf3=\Er\r, kf4=\Es\r,
-	kf5=\Et\r, kf6=\Eu\r, kf7=\Ev\r, kf8=\Ew\r, kf9=\Ex\r,
-	khome=\EH, pad=^?, rmdc@, rmir=\EP, rmso@, smdc@, smso@,
-	use=dm3025,
+	kf0=\Ey\r, kf9=\Ex\r, khome=\EH, pad=^?, rmdc@, rmir=\EP,
+	rmso@, smdc@, smso@, use=dm3025, use=hp+pfk+cr,
 # Datamedia DT80 soft switches:
 # 1	0=Jump  1=Smooth
 #	Autorepeat	0=off  1=on
@@ -16766,18 +17256,17 @@ dm3045|datamedia 3045a,
 #	Aux Parity	0=Off  1=On
 #	Aux Bits/Char	0=7    1=8
 #	CRT Saver	0=Off  1=On
-# dm80/1 is a vt100 lookalike, but it doesn't seem to need any padding.
-dm80|dmdt80|dt80|datamedia dt80/1,
-	clear=\E[2J\E[H, cud1=\n, cuf1=\E[C,
-	cup=%i\E[%p1%d;%p2%dH, cuu1=\E[A, ed=\E[J, el=\E[K,
-	home=\E[H, mc0=\E[0i, mc4=\E[4i, mc5=\E[5i, ri=\EM,
-	rmso=\E[m, rmul=\E[m, sgr0=\E[m\017$<2>, smso=\E[7m,
-	smul=\E[4m, use=vt100+4bsd,
+# dm80/1 is a VT100 lookalike, but it doesn't seem to need any padding.
+dm80|dmdt80|dt80|Datamedia dt80/1,
+	clear=\E[2J\E[H, cuf1=\E[C, cup=%i\E[%p1%d;%p2%dH,
+	cuu1=\E[A, ed=\E[J, el=\E[K, mc0=\E[0i, mc4=\E[4i, mc5=\E[5i,
+	ri=\EM, rmso=\E[m, rmul=\E[m, sgr0=\E[m\017$<2>,
+	smso=\E[7m, smul=\E[4m, use=vt100+4bsd,
 # except in 132 column mode, where it needs a little padding.
-# This is still less padding than the vt100, and you can always turn on
-# the ^S/^Q handshaking, so you can use vt100 flavors for things like
+# This is still less padding than the VT100, and you can always turn on
+# the ^S/^Q handshaking, so you can use VT100 flavors for things like
 # reverse video.
-dm80w|dmdt80w|dt80w|datamedia dt80/1 in 132 char mode,
+dm80w|dmdt80w|dt80w|Datamedia dt80/1 in 132 char mode,
 	cols#132,
 	clear=\E[H\E[2J$<50/>, cud1=\n,
 	cup=\E[%i%p1%d;%p2%dH$<5/>, cuu1=\E[A$<5/>,
@@ -16805,15 +17294,15 @@ dt80-sas|Datamedia DT803/DTX for SAS usage,
 # from the other Datamedias in use here, and yet to associate a model of
 # the Excel terminals with the regular datamedia terminals that share
 # major characteristics.
-excel62|excel64|datamedia Excel 62,
+excel62|excel64|Datamedia Excel 62,
 	dch1=\E[P, kbs=^H, kcub1=^H, kcud1=\n, kf5=\EOu, kf6=\EOv,
 	kf7=\EOw, kf8=\EOx, kf9=\EOy, rmir=\E[4l, smir=\E[4h,
 	use=dt80,
-excel62-w|excel64-w|datamedia Excel 62 in 132 char mode,
+excel62-w|excel64-w|Datamedia Excel 62 in 132 char mode,
 	dch1=\E[P, kbs=^H, kcub1=^H, kcud1=\n, kf5=\EOu, kf6=\EOv,
 	kf7=\EOw, kf8=\EOx, kf9=\EOy, rmir=\E[4l, smir=\E[4h,
 	use=dt80w,
-excel62-rv|excel64-rv|datamedia Excel 62 in reverse video mode,
+excel62-rv|excel64-rv|Datamedia Excel 62 in reverse video mode,
 	dch1=\E[P, flash=\E[?5l\E[?5h, kbs=^H, kcub1=^H, kcud1=\n,
 	kf5=\EOu, kf6=\EOv, kf7=\EOw, kf8=\EOx, kf9=\EOy, rmir=\E[4l,
 	smir=\E[4h, use=dt80,
@@ -16828,13 +17317,13 @@ excel62-rv|excel64-rv|datamedia Excel 62 in reverse video mode,
 #	Net: techsup@charm.sys.falco.com
 #
 # Current Falco models as of 1995 are generally ANSI-compatible and support
-# emulations of DEC VT-series, Wyse, and Televideo types.
+# emulations of DEC VT-series, Wyse, and TeleVideo types.
 #
 
 # Test version for Falco ts-1. See <arpavax.hickman@ucb> for info
 # This terminal was released around 1983 and was discontinued long ago.
 # The standout and underline highlights are the same.
-falco|ts1|ts-1|falco ts-1,
+falco|ts1|ts-1|Falco ts-1,
 	OTbs, am,
 	cols#80, it#8, lines#24,
 	bel=^G, clear=\E*, cr=\r, cub1=^H, cud1=\n, cuf1=^L,
@@ -16843,39 +17332,30 @@ falco|ts1|ts-1|falco ts-1,
 	ind=\n, is2=\Eu\E3, kcub1=^H, kcud1=\n, kcuf1=^L, kcuu1=^K,
 	kf0=^A0\r, rmir=\Er, rmso=\Eg0, rmul=\Eg0, sgr0=\Eg0,
 	smir=\Eq, smso=\Eg1, smul=\Eg1,
-falco-p|ts1p|ts-1p|falco ts-1 with paging option,
+falco-p|ts1p|ts-1p|Falco ts-1 with paging option,
 	OTbs, am, da, db, mir, msgr, ul,
 	cols#80, it#8, lines#24,
-	bel=^G, cbt=\EI, clear=\E*, cr=\r, cub1=^H, cud1=\E[B,
-	cuf1=\E[C, cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=\E[A,
-	dch1=\EW, dl1=\ER, ed=\EY, el=\ET\EG0\010\Eg0, ht=^I,
-	il1=\EE, ind=\n, is2=\EZ\E3\E_c, kcub1=\E[D, kcud1=\E[B,
-	kcuf1=\E[C, kcuu1=\E[A, khome=\E[H, rmcup=\E_b, rmir=\Er,
-	rmso=\Eg0, rmul=\Eg0, sgr0=\Eg0, smcup=\E_d, smir=\Eq,
-	smso=\Eg4, smul=\Eg1,
+	bel=^G, cbt=\EI, clear=\E*, cr=\r, cub1=^H,
+	cup=\E=%p1%{32}%+%c%p2%{32}%+%c, dch1=\EW, dl1=\ER,
+	ed=\EY, el=\ET\EG0\010\Eg0, ht=^I, il1=\EE, ind=\n,
+	is2=\EZ\E3\E_c, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C,
+	kcuu1=\E[A, khome=\E[H, rmcup=\E_b, rmir=\Er, rmso=\Eg0,
+	rmul=\Eg0, sgr0=\Eg0, smcup=\E_d, smir=\Eq, smso=\Eg4,
+	smul=\Eg1, use=ansi+local1,
+
 # (ts100: I added <rmam>/<smam> based on the init string -- esr)
-ts100|ts100-sp|falco ts100-sp,
-	am, mir, msgr, xenl, xon,
-	cols#80, it#8, lines#24, vt#3,
-	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, blink=\E[5m$<2>, bold=\E[1m$<2>,
-	clear=\E[H\E[J$<50>, cr=\r, csr=\E[%i%p1%d;%p2%dr,
-	cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\n,
-	cuf=\E[%p1%dC, cuf1=\E[C$<2>,
-	cup=\E[%i%p1%d;%p2%dH$<5>, cuu=\E[%p1%dA,
-	cuu1=\E[A$<2>, dch1=\E~W, dl1=\E~R, ed=\E[J$<50>,
-	el=\E[K$<3>, el1=\E[1K$<3>, enacs=\E(B\E)0, home=\E[H,
-	ht=^I, hts=\EH, ich1=\E~Q, il1=\E~E, ind=\n, is1=\E~)\E~ea,
-	kbs=^H, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
-	rc=\E8, rev=\E[7m$<2>, ri=\EM$<5>, rmacs=^O, rmam=\E[?7l,
-	rmkx=\E[?1l\E>, rmso=\E[m$<2>, rmul=\E[m$<2>,
-	rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, sc=\E7,
-	sgr=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5
-	    %;m%?%p9%t\016%e\017%;$<2>,
-	sgr0=\E[m\017$<2>, smacs=^N, smam=\E[?7h, smkx=\E[?1h\E=,
-	smso=\E[1;7m$<2>, smul=\E[4m$<2>, tbc=\E[3g,
-	use=vt100+fnkeys,
-ts100-ctxt|falco ts-100 saving context,
+ts100|ts100-sp|Falco ts100-sp,
+	mir, xenl, xon,
+	vt#3,
+	cub1=^H, cud1=\n, cuf1=\E[C$<2>, cuu1=\E[A$<2>, dch1=\E~W,
+	dl1=\E~R, ich1=\E~Q, il1=\E~E, is1=\E~)\E~ea, kcub1=\EOD,
+	kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, rmam=\E[?7l,
+	rmkx=\E[?1l\E>,
+	rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, smam=\E[?7h,
+	smkx=\E[?1h\E=, use=ansi+csr, use=ansi+local,
+	use=decid+cpr, use=vt100+4bsd, use=vt100+fnkeys,
+
+ts100-ctxt|Falco ts-100 saving context,
 	rmcup=\E~_b, smcup=\E~_d\E[2J, use=ts100,
 
 #### Florida Computer Graphics
@@ -16911,11 +17391,11 @@ beacon|FCG Beacon System,
 f1720|f1720a|fluke 1720A,
 	xt,
 	cols#80, lines#16, xmc#1,
-	bel=^G, clear=\E[H\E[2J, cr=\r, cub1=^H, cud1=\E[B,
-	cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, ed=\E[J,
-	el=\E[K, ind=\ED, is2=\E[H\E[2J, kcub1=^_, kcud1=^],
-	kcuf1=^^, kcuu1=^\, ri=\EM, rmso=\E[m, rmul=\E[m, sgr0=\E[m,
-	smso=\E[7m, smul=\E[4m,
+	bel=^G, clear=\E[H\E[2J, cr=\r, cub1=^H,
+	cup=\E[%i%p1%d;%p2%dH, ed=\E[J, el=\E[K, ind=\ED,
+	is2=\E[H\E[2J, kcub1=^_, kcud1=^], kcuf1=^^, kcuu1=^\,
+	ri=\EM, rmso=\E[m, rmul=\E[m, sgr0=\E[m, smso=\E[7m,
+	smul=\E[4m, use=ansi+local1,
 
 #### Liberty Electronics (Freedom)
 #
@@ -16929,7 +17409,7 @@ f1720|f1720a|fluke 1720A,
 # (f100: added empty <acsc> to suppress a tic warning;
 # made this relative to adm+sgr -- note that <invis> isn't
 # known to work for f100 but does on the f110. --esr)
-f100|freedom|freedom100|freedom model 100,
+f100|freedom|freedom100|Liberty Freedom model 100,
 	OTbs, am, bw, hs, mir, msgr, xon,
 	cols#80, lines#24,
 	acsc=, bel=^G, cbt=\EI, clear=^Z, cr=\r, cub1=^H, cud1=\n,
@@ -16943,7 +17423,7 @@ f100|freedom|freedom100|freedom model 100,
 	kf8=^AG\r, kf9=^AH\r, khome=^^, ri=\Ej, rmacs=\E$, rmir=\Er,
 	smacs=\E%%, smir=\Eq, tbc=\E3, tsl=\Eg\Ef,
 	vpa=\E[%p1%{32}%+%c, use=adm+sgr,
-f100-rv|freedom-rv|freedom 100 in reverse video,
+f100-rv|freedom-rv|Liberty Freedom 100 in reverse video,
 	flash=\Ed$<200>\Eb, is2=\Eg\Ef\r\Eb, use=f100,
 # The f110 and f200 have problems with vi(1).  They use the ^V
 # code for the down cursor key. When kcud1 is defined in terminfo
@@ -17017,8 +17497,8 @@ f200vi-w|Liberty Freedom 200 - 132 cols for vi,
 go140|graphon go-140,
 	OTbs,
 	cols#80, it#8, lines#24,
-	clear=\E[H\E[2J$<10/>, cub1=^H, cud1=\E[B, cuf1=\E[C,
-	cup=\E[%i%p1%2d;%p2%2dH, cuu1=\E[A, dch1=\E[P, dl1=\E[M,
+	clear=\E[H\E[2J$<10/>, cub1=^H,
+	cup=\E[%i%p1%2d;%p2%2dH, dch1=\E[P, dl1=\E[M,
 	ed=\E[J$<10/>, el=\E[K, ht=^I,
 	if=/usr/share/tabset/vt100, il1=\E[L,
 	is2=\E<\E=\E[?3l\E[?7l\E(B\E[J\E7\E[;r\E8\E[m\E[q,
@@ -17026,7 +17506,8 @@ go140|graphon go-140,
 	kf2=\EOQ, kf3=\EOR, kf4=\EOS, khome=\E[H, ri=\EM,
 	rmam=\E[?7l, rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[m,
 	rmul=\E[m, sgr0=\E[m, smam=\E[?7h, smir=\E[4h,
-	smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m,
+	smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, use=ansi+local1,
+
 go140w|graphon go-140 in 132 column mode,
 	am,
 	cols#132,
@@ -17038,18 +17519,17 @@ go140w|graphon go-140 in 132 column mode,
 go225|go-225|Graphon 225,
 	OTbs, am, mir, xenl,
 	cols#80, it#8, lines#25, vt#3,
-	blink=\E[5m, bold=\E[1m, clear=\E[H\E[J,
-	csr=\E[%i%p1%d;%p2%dr, cub1=^H, cud1=\n, cuf1=\E[C,
+	blink=\E[5m, bold=\E[1m, cub1=^H, cud1=\n, cuf1=\E[C,
 	cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, dch1=\E[P, dl1=\E[M,
-	ed=\E[J, el=\E[K, home=\E[H, ht=^I, il1=\E[L, ind=\ED,
-	is2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, kbs=^H,
-	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kf1=\EOP,
-	kf2=\EOQ, kf3=\EOR, kf4=\EOS, khome=\E[H, rc=\E8, rev=\E[7m,
+	home=\E[H, ht=^I, il1=\E[L, ind=\ED,
+	is2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, kf1=\EOP,
+	kf2=\EOQ, kf3=\EOR, kf4=\EOS, rev=\E[7m,
 	rf=/usr/share/tabset/vt100, ri=\EM, rmam=\E[?7l,
 	rmcup=\E[!p\E[?7h\E[2;1;1#w, rmir=\E[4l, rmkx=\E>,
 	rmso=\E[27m, rmul=\E[24m, rs1=\E[!p\E[?7h\E[2;1;1#w,
-	sc=\E7, sgr0=\E[m, smam=\E[?7h, smcup=\E[2;0#w\E[1;25r,
+	sgr0=\E[m, smam=\E[?7h, smcup=\E[2;0#w\E[1;25r,
 	smir=\E[4h, smkx=\E=, smso=\E[7m, smul=\E[4m,
+	use=ansi+arrows, use=ansi+csr, use=ansi+erase,
 
 #### Harris (Beehive)
 #
@@ -17116,7 +17596,7 @@ go225|go-225|Graphon 225,
 # NOTE WELL that the rear panel switch should be set to CR/LF,
 # not AEP!
 #
-sb1|beehive superbee,
+sb1|Beehive SuperBee,
 	OTbs, am, bw, da, db, mir, ul, xsb,
 	cols#80, lines#25, xmc#1,
 	bel=^G, cbt=\E`$<650>, clear=\EH$<1>\EJ$<3>, cr=$<1>\r,
@@ -17127,14 +17607,13 @@ sb1|beehive superbee,
 	    \s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s
 	    \s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s
 	    \s\s\s\s\s\EP$<3>\s\EO\ER\EA$<3>,
-	ind=\n, is2=\EE$<3>\EX\EZ\EO\Eb\Eg\ER, kbs=^_, kcub1=\ED,
-	kcud1=\EB, kcuf1=\EC, kcuu1=\EA, kdl1=\EM, ked=\EJ, kel=\EK,
-	kf0=\E2, kf1=\Ep, kf2=\Eq, kf3=\Er, kf4=\Es, kf5=\Et, kf6=\Eu,
-	kf7=\Ev, kf8=\Ew, kf9=\E1, khome=\EH, kich1=\EQ\EO,
+	ind=\n, is2=\EE$<3>\EX\EZ\EO\Eb\Eg\ER, kbs=^_, kdl1=\EM,
+	ked=\EJ, kel=\EK, kf0=\E2, kf9=\E1, khome=\EH, kich1=\EQ\EO,
 	krmir=\ER, lf0=TAB CLEAR, lf9=TAB SET, rmcup=, rmir=\ER,
 	rmso=\E_3, rmul=\E_3, sgr0=\E_3, smcup=\EO, smir=\EQ\EO,
-	smso=\E_1, smul=\E_0, tbc=\E3,
-sbi|superbee|beehive superbee at Indiana U.,
+	smso=\E_1, smul=\E_0, tbc=\E3, use=hp+pfk-cr,
+	use=vt52+arrows,
+sbi|superbee|Beehive SuperBee at Indiana U.,
 	xsb,
 	cr=\r$<1>, il1=\EN$<1>\EL$<9>\EQ \EP$<9> \EO\ER\EA,
 	use=sb1,
@@ -17148,7 +17627,7 @@ sbi|superbee|beehive superbee at Indiana U.,
 # the other two if you want to try to hit that tiny escape key.
 # This description is tricky: being able to use cup depends on there being
 # 2048 bytes of memory and the hairy <nl> string.
-superbee-xsb|beehive super bee,
+superbee-xsb|Beehive SuperBee (improved),
 	am, da, db, xsb,
 	cols#80, it#8, lines#25,
 	clear=\EH\EJ$<3>, cnorm=\n, cr=\r$<1000>, cub1=^H, cud1=\n,
@@ -17156,13 +17635,12 @@ superbee-xsb|beehive super bee,
 	dch1=\EP$<3>, dl1=\EM$<100>, ed=\EJ$<3>, el=\EK$<3>,
 	home=\EH, ht=^I, hts=\E1,
 	ind=\n\0\0\0\n\0\0\0\EA\EK\0\0\0\ET\ET, is2=\EH\EJ,
-	kcub1=\ED, kcud1=\EB, kcuf1=\EC, kcuu1=\EA, kf1=\Ep, kf2=\Eq,
-	kf3=\Er, kf4=\Es, kf5=\Et, kf6=\Eu, kf7=\Ev, kf8=\Ew,
 	khome=\EH, rmso=\E_3, sgr0=\E_3, smso=\E_1, tbc=\E3,
+	use=hp+pfk-cr, use=vt52+arrows,
 # This loses on lines > 80 chars long, use at your own risk
-superbeeic|super bee with insert char,
+superbeeic|SuperBee with insert char,
 	ich1=, rmir=\ER, smir=\EQ, use=superbee-xsb,
-sb2|sb3|fixed superbee,
+sb2|sb3|fixed SuperBee,
 	xsb@, use=superbee,
 
 #### Beehive Medical Electronics
@@ -17172,35 +17650,34 @@ sb2|sb3|fixed superbee,
 # They were made by Beehive Medical Electronics in Utah. They went out of
 # business in the early '80s.
 #
-# (OK, then, I don't know why a couple of these say "harris beehive".)
+# (OK, then, I don't know why a couple of these say "Harris Beehive".)
 #
 
 # Reports are that most of these Beehive entries (except superbee) have not
 # been tested and do not work right.  <rmso> is a trouble spot.  Be warned.
 
 # (bee: <ich1> was empty, which is obviously bogus -- esr)
-beehive|bee|harris beehive,
+beehive|bee|Harris Beehive,
 	OTbs, am, mir,
 	cols#80, lines#24,
 	cbt=\E>, clear=\EE, cub1=^H, cud1=\EB, cuf1=\EC,
 	cup=\EF%p1%{32}%+%c%p2%{32}%+%c, cuu1=\EA, dch1=\EP,
 	dl1=\EM, ed=\EJ, el=\EK, home=\EH, il1=\EL, kbs=^H, kcbt=\E>,
-	kclr=\EE, kcub1=\ED, kcud1=\EB, kcuf1=\EC, kcuu1=\EA,
-	kdch1=\EP, kdl1=\EM, kel=\EK, khome=\EH, kich1=\EQ, kil1=\EL,
-	krmir=\E@, rmir=\E@, rmso=\Ed@, rmul=\Ed@, sgr0=\Ed@,
-	smir=\EQ, smso=\EdP, smul=\Ed`,
+	kclr=\EE, kdch1=\EP, kdl1=\EM, kel=\EK, khome=\EH, kich1=\EQ,
+	kil1=\EL, krmir=\E@, rmir=\E@, rmso=\Ed@, rmul=\Ed@,
+	sgr0=\Ed@, smir=\EQ, smso=\EdP, smul=\Ed`, use=vt52+arrows,
 # set tab is ^F, clear (one) tab is ^V, no way to clear all tabs.
 # good grief - does this entry make :sg:/:ug: when it doesn't have to?
 # look at those spaces in <rmso>/<smso>.  Seems strange to me...
 # (beehive: <if=/usr/share/tabset/beehive> removed, no such file.  If you
 # really care, cook up one using ^F -- esr)
-beehive3|bh3m|beehiveIIIm|harris beehive 3m,
+beehive3|bh3m|beehiveIIIm|Harris Beehive 3m,
 	OTbs, am,
 	cols#80, it#8, lines#20,
 	bel=^G, clear=^E^R, cr=\r, cub1=^H, cud1=\n, cuf1=^L, cuu1=^K,
 	dl1=\021$<350>, ed=^R, el=^P, home=^E, ht=^I, hts=^F,
 	il1=\023$<160>, ind=\n, ll=^E^K, rmso=\s^_, smso=^]\s,
-beehive4|bh4|beehive 4,
+beehive4|bh4|Beehive 4,
 	am,
 	cols#80, lines#24,
 	bel=^G, clear=\EE, cr=\r, cub1=\ED, cud1=\n, cuf1=\EC,
@@ -17208,26 +17685,25 @@ beehive4|bh4|beehive 4,
 # There was an early Australian kit-built computer called a "Microbee".
 # It's not clear whether this is for one of those or for a relative
 # of the Beehive.
-microb|microbee|micro bee series,
+microb|microbee|Micro Bee series,
 	OTbs, am,
 	cols#80, it#8, lines#24,
 	bel=^G, clear=\EE, cr=\r, cub1=^H, cud1=\n, cuf1=\EC,
 	cup=\EF%p1%{32}%+%c%p2%{32}%+%c, cuu1=\EA, ed=\EJ,
-	el=\EK, ht=^I, ind=\n, kcub1=\ED, kcud1=\EB, kcuf1=\EC,
-	kcuu1=\EA, kf1=\Ep, kf2=\Eq, kf3=\Er, kf4=\Es, kf5=\Et,
-	kf6=\Eu, kf7=\Ev, kf8=\Ew, kf9=\Ex, khome=\EH, rmso=\Ed@,
+	el=\EK, ht=^I, ind=\n, kf9=\Ex, khome=\EH, rmso=\Ed@,
 	rmul=\Ed@, sgr0=\Ed@, smso=\s\EdP, smul=\Ed`,
+	use=hp+pfk-cr, use=vt52+arrows,
 
 # 8675, 8686, and bee from Cyrus Rahman
 # (8675: changed k10, k11...k16 to k;, F1...F6 -- esr)
-ha8675|harris 8675,
+ha8675|Harris 8675,
 	is2=\ES\E#\E*\Eh\Em\E?\E1\E9\E@\EX\EU, kf1=^F,
 	kf10=\Ed, kf11=^W, kf12=\ER, kf13=\EE, kf14=\EI, kf15=\Ei,
 	kf16=\Eg, kf2=^P, kf3=^N, kf4=^V, kf5=\n, kf6=^T, kf7=^H, kf8=^?,
 	kf9=\Ee, use=bee,
 # (8686: changed k10, k11...k16 to k;, F1...F6; fixed broken continuation
 # in :is: -- esr)
-ha8686|harris 8686,
+ha8686|Harris 8686,
 	is2=\ES\E#\E*\Eh\Em\E?\E1\E9\E@\EX\EU\E"*Z01\E"8F35021B7C83#
 	    \E"8F45021B7D83#\E"8F55021B7E83#\E"8F65021B7F83#\E"8F750
 	    21B7383#\E"8F851BD7#\E"8F95021B7083#\E"8FA5021B7183#\E"8
@@ -17266,13 +17742,13 @@ ha8686|harris 8686,
 # redraw the screen.  h1000 is untested.  It doesn't work in
 # vi - this terminal is too dumb for even vi.  (The code is
 # there but it isn't debugged for this case.)
-hz1000|hazeltine 1000,
+hz1000|Hazeltine 1000,
 	OTbs,
 	cols#80, lines#12,
 	bel=^G, clear=^L, cr=\r, cub1=^H, cud1=\n, cuf1=\s, home=^K,
 	ind=\n,
 # From: <cbosg!ucbvax!pur-ee!cincy!chris> Thu Aug 20 09:09:18 1981
-hz1420|hazeltine 1420,
+hz1420|Hazeltine 1420,
 	OTbs, am,
 	cols#80, lines#24,
 	bel=^G, clear=\E^\, cr=\r, cub1=^H, cud1=\n, cuf1=^P,
@@ -17282,7 +17758,7 @@ hz1420|hazeltine 1420,
 # New "safe" cursor movement (11/87) from <cgs@umd5.umd.edu>.  Prevents
 # freakout with out-of-range args and tn3270.  No hz since it needs to
 # receive tildes.
-hz1500|hazeltine 1500,
+hz1500|Hazeltine 1500,
 	OTbs, am, hz,
 	cols#80, lines#24,
 	bel=^G, clear=~^\, cr=\r, cub1=^H, cud1=~^K, cuf1=^P,
@@ -17294,7 +17770,7 @@ hz1500|hazeltine 1500,
 # (h1510: early versions of this entry apparently had "<rmso=\E^_>,
 # <smso=\E^Y>, but these caps were commented out in 8.3; also,
 # removed incorrect and overridden ":do=^J:" -- esr)
-hz1510|hazeltine 1510,
+hz1510|Hazeltine 1510,
 	OTbs, am,
 	cols#80, lines#24,
 	bel=^G, clear=\E^\, cr=\r, cub1=^H, cud1=\E^K, cuf1=^P,
@@ -17317,7 +17793,7 @@ hz1520|Hazeltine 1520,
 	rmso=\E^Y, rs1=\E$\E\005\E?\E\031, sgr0=\E^Y, smso=\E^_,
 # This version works with the escape switch off
 # (h1520: removed incorrect and overridden ":do=^J:" -- esr)
-hz1520-noesc|hazeltine 1520,
+hz1520-noesc|Hazeltine 1520 (no escape),
 	am, hz,
 	cols#80, lines#24,
 	bel=^G, clear=~^\, cr=\r, cub1=^H, cud1=~^K, cuf1=^P,
@@ -17326,14 +17802,14 @@ hz1520-noesc|hazeltine 1520,
 # Note: the h1552 appears to be the first Hazeltine terminal which
 # is not braindamaged.  It has tildes and backprimes and everything!
 # Be sure the auto lf/cr switch is set to cr.
-hz1552|hazeltine 1552,
+hz1552|Hazeltine 1552,
 	OTbs,
 	cud1=\n, dl1=\EO, il1=\EE, lf1=blue, lf2=red, lf3=green,
 	use=vt52,
-hz1552-rv|hazeltine 1552 reverse video,
+hz1552-rv|Hazeltine 1552 reverse video,
 	cud1=\n, rmso=\ET, smso=\ES, use=hz1552,
 # Note: h2000 won't work well because of a clash between upper case and ~'s.
-hz2000|hazeltine 2000,
+hz2000|Hazeltine 2000,
 	OTbs, OTnc, am,
 	cols#74, lines#27,
 	bel=^G, clear=~\034$<6>, cub1=^H, cud1=\n,
@@ -17358,7 +17834,7 @@ esprit|Hazeltine Esprit I,
 	kf6=^B6\n, kf7=^B7\n, kf8=^B8\n, kf9=^B9\n, khome=\E^R,
 	lf0=0, lf1=1, lf2=2, lf3=3, lf4=4, lf5=5, lf6=6, lf7=7, lf8=8, lf9=9,
 	rmkx=\E>, rmso=\E^Y, smkx=\E<, smso=\E^_,
-esprit-am|hazeltine esprit auto-margin,
+esprit-am|Hazeltine esprit auto-margin,
 	am, use=esprit,
 # Hazeltine Modular-1 from Cliff Shackelton <ittvax!ittral!shackelt> via BRL
 # Vi it seems always wants to send a control J for "do" and it turned out
@@ -17379,18 +17855,17 @@ hazel|exec80|h80|he80|Hazeltine Executive 80,
 	OTbs, OTpt, am,
 	cols#80, it#8, lines#24, vt#3,
 	OTnl=\n, bel=^G, blink=\E[5m$<2/>, bold=\E[1m$<2/>,
-	clear=\E[;H\E[2J$<50/>, cr=\r, csr=\E[%i%p1%d;%p2%dr,
-	cub1=^H, cud1=\n, cuf1=\E[C$<2/>,
-	cup=\E[%i%p1%d;%p2%dH$<5/>, cuu1=\E[A$<2/>,
-	ed=\E[J$<50/>, el=\E[K$<3/>, home=\E[H, ht=^I,
-	is2=\E[1;24r\E[24;1H, kbs=^H, kcub1=\EOD, kcud1=\EOB,
-	kcuf1=\EOC, kcuu1=\EOA, kf1=\EOP, kf2=\EOQ, kf3=\EOR,
-	kf4=\EOS, rc=\E8, rev=\E[7m$<2/>,
+	clear=\E[;H\E[2J$<50/>, cr=\r, cub1=^H, cud1=\n,
+	cuf1=\E[C$<2/>, cup=\E[%i%p1%d;%p2%dH$<5/>,
+	cuu1=\E[A$<2/>, ed=\E[J$<50/>, el=\E[K$<3/>, home=\E[H,
+	ht=^I, is2=\E[1;24r\E[24;1H, kbs=^H, kcub1=\EOD,
+	kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kf1=\EOP, kf2=\EOQ,
+	kf3=\EOR, kf4=\EOS, rev=\E[7m$<2/>,
 	rf=/usr/share/tabset/vt100, ri=\EM$<5/>,
 	rmkx=\E[?1l\E>, rmso=\E[m$<2/>, rmul=\E[m$<2/>,
-	rs1=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, sc=\E7,
+	rs1=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h,
 	sgr0=\E[m$<2/>, smkx=\E[?1h\E=, smso=\E[7m$<2/>,
-	smul=\E[4m$<2/>,
+	smul=\E[4m$<2/>, use=ansi+csr,
 
 #### IBM
 #
@@ -17404,14 +17879,14 @@ ibm3101|i3101|IBM 3101-10,
 	cols#80, lines#24,
 	bel=^G, clear=\EK, cr=\r, cub1=^H, cud1=\n, cuf1=\EC,
 	cup=\EY%p1%{32}%+%c%p2%{32}%+%c, cuu1=\EA, ed=\EJ,
-	el=\EI, home=\EH, hts=\E0, ind=\n, kcub1=\ED, kcud1=\EB,
-	kcuf1=\EC, kcuu1=\EA, nel=\r\n, tbc=\EH,
+	el=\EI, home=\EH, hts=\E0, ind=\n, nel=\r\n, tbc=\EH,
+	use=vt52+arrows,
 ibm3151|IBM 3151 display,
-	is2=\E S, rmacs=\E>B, rmcup=\E>B, rs2=\E S, s0ds=\E>B,
+	is2=\E S, rmacs=\E>B, rs2=\E S,
 	sgr=\E4%{64}%?%p1%t%{65}%|%;%?%p2%t%{66}%|%;%?%p3%t%{65}%|%;
 	    %?%p4%t%{68}%|%;%?%p5%t%{64}%|%;%?%p6%t%{72}%|%;%?%p7%t
 	    %{80}%|%;%c%?%p9%t\E>A%e\E>B%;,
-	sgr0=\E4@\E>B, smacs=\E>A, smcup=\E>B, use=ibm3162,
+	sgr0=\E4@\E>B, smacs=\E>A, use=ibm3162,
 # From: Mark Easter <marke@fsi-ssd.csg.ssd.fsi.com> 29 Oct 1992
 # removed kend, knp, kpp -TD
 #
@@ -17429,9 +17904,8 @@ ibm3161|ibm3163|wy60-316X|wyse60-316X|IBM 3161/3163 display,
 	cud1=\EB, cuf1=\EC, cup=\EY%p1%{32}%+%c%p2%{32}%+%c,
 	cuu1=\EA, dch1=\EQ, dl1=\EO, ed=\EJ, el=\EI, home=\EH,
 	ich1=\EP \010, il1=\EN, ind=\n, invis=\E4P, kbs=^H, kcbt=\E2,
-	kclr=\EL\r, kctab=\E1, kcub1=\ED, kcud1=\EB, kcuf1=\EC,
-	kcuu1=\EA, kdch1=\EQ, kdl1=\EO, ked=\EJ, kel=\EI, kf1=\Ea\r,
-	kf10=\Ej\r, kf11=\Ek\r, kf12=\El\r, kf13=\E!a\r,
+	kclr=\EL\r, kctab=\E1, kdch1=\EQ, kdl1=\EO, ked=\EJ, kel=\EI,
+	kf1=\Ea\r, kf10=\Ej\r, kf11=\Ek\r, kf12=\El\r, kf13=\E!a\r,
 	kf14=\E!b\r, kf15=\E!c\r, kf16=\E!d\r, kf17=\E!e\r,
 	kf18=\E!f\r, kf19=\E!g\r, kf2=\Eb\r, kf20=\E!h\r,
 	kf21=\E!i\r, kf22=\E!j\r, kf23=\E!k\r, kf24=\E!l\r,
@@ -17443,6 +17917,7 @@ ibm3161|ibm3163|wy60-316X|wyse60-316X|IBM 3161/3163 display,
 	    %?%p4%t%{68}%|%;%?%p5%t%{64}%|%;%?%p6%t%{72}%|%;%?%p7%t
 	    %{80}%|%;%c%?%p9%t\E>A%e\E<@%;,
 	sgr0=\E4@\E<@, smcup=\E>A, smso=\E4A, smul=\E4B,
+	use=vt52+arrows,
 
 ibm3161-C|IBM 3161-C NLS terminal using cartridge,
 	rmcup=\E>B, s0ds=\E>B, s1ds=\E>A, smcup=\E>B, use=ibm3161,
@@ -17471,14 +17946,9 @@ ibm5151|wy60-AT|wyse60-AT|IBM 5151 Monochrome display,
 	cols#80, it#8, lines#25,
 	acsc=j\331k\277l\332m\300n\305q\304t\303u\264v\301w\302x
 	     \263,
-	bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[J, cr=\r,
-	cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\n,
-	cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
-	cuu=\E[%p1%dA, cuu1=\E[A, dch1=\E[P, dl=\E[%p1%dM,
-	dl1=\E[M, ech=\E[%p1%dX, ed=\E[J, el=\E[K, home=\E[H,
-	hpa=\E[%i%p1%dG, il=\E[%p1%dL, il1=\E[L, ind=\E[S,
-	invis=\E[8m, is2=\Ec, kbs=^H, kcbt=\E[Z, kclr=\E[144q,
-	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kdch1=\E[P,
+	bel=^G, cr=\r, cub1=^H, cud1=\n, cup=\E[%i%p1%d;%p2%dH,
+	dch1=\E[P, ech=\E[%p1%dX, home=\E[H, hpa=\E[%i%p1%dG,
+	ind=\E[S, is2=\Ec, kcbt=\E[Z, kclr=\E[144q, kdch1=\E[P,
 	ked=\E[148q, kel=\E[142q, kend=\E[146q, kf1=\E[001q,
 	kf10=\E[010q, kf11=\E[011q, kf12=\E[012q, kf13=\E[013q,
 	kf14=\E[014q, kf15=\E[015q, kf16=\E[016q, kf17=\E[017q,
@@ -17488,13 +17958,13 @@ ibm5151|wy60-AT|wyse60-AT|IBM 5151 Monochrome display,
 	kf29=\E[029q, kf3=\E[003q, kf30=\E[030q, kf31=\E[031q,
 	kf32=\E[032q, kf33=\E[033q, kf34=\E[034q, kf35=\E[035q,
 	kf36=\E[036q, kf4=\E[004q, kf5=\E[005q, kf6=\E[006q,
-	kf7=\E[007q, kf8=\E[008q, kf9=\E[009q, khome=\E[H,
-	kich1=\E[139q, kil1=\E[140q, kind=\E[151q, knp=\E[154q,
-	kpp=\E[150q, kri=\E[155q, krmir=\E[4l, rev=\E[7m, ri=\E[T,
-	rmir=\E[4l, rmso=\E[m, rmul=\E[m, rs2=\Ec,
+	kf7=\E[007q, kf8=\E[008q, kf9=\E[009q, kich1=\E[139q,
+	kil1=\E[140q, kind=\E[151q, knp=\E[154q, kpp=\E[150q,
+	kri=\E[155q, krmir=\E[4l, ri=\E[T, rmir=\E[4l, rs2=\Ec,
 	sgr=\E[%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p6%t;1
 	    %;%?%p7%t;8%;m,
-	sgr0=\E[0m, smir=\E[4h, smso=\E[7m, smul=\E[4m,
+	smir=\E[4h, use=ansi+arrows, use=ansi+erase,
+	use=ansi+idl, use=ansi+local, use=ansi+sgrbold,
 	use=ecma+index,
 
 ibmaed|IBM Experimental display,
@@ -17503,8 +17973,8 @@ ibmaed|IBM Experimental display,
 	clear=\EH\EK, cub1=^H, cud1=\EB, cuf1=\EC,
 	cup=\EY%p1%{32}%+%c%p2%{32}%+%c, cuu1=\EA, dch1=\EQ,
 	dl1=\EO, ed=\EJ, el=\EI, flash=\EG, home=\EH, ht=^I, ich1=\EP,
-	il1=\EN, kbs=^H, kcub1=\ED, kcud1=\EB, kcuf1=\EC, kcuu1=\EA,
-	rmso=\E0, sgr0=\E0, smso=\E0,
+	il1=\EN, kbs=^H, rmso=\E0, sgr0=\E0, smso=\E0,
+	use=vt52+arrows,
 ibm-apl|apl|IBM apl terminal simulator,
 	lines#25, use=dm1520,
 # (ibmmono: this had an unknown `sb' boolean, I changed it to `bs'.
@@ -17519,8 +17989,7 @@ ibmmono|IBM workstation monochrome,
 	sgr0=\Ew\Eq\Ez\EB, smso=\EZ, smul=\EW, tsl=\Ej\EY8%+ \Eo,
 	use=ibm3101,
 ibmega|IBM Enhanced Color Display,
-	cr=\r, cud1=\n, ht=^I, ind=\n, kbs=^H, kcub1=^H, kcud1=\n,
-	nel=\r\n, use=ibmmono,
+	ht=^I, kcub1=^H, kcud1=\n, use=ibmmono,
 # This color scheme is assumed in some recent IBM terminal descriptions
 # (green on black, emulated on a 16-color terminal).
 ibm+color|IBM color definitions,
@@ -17541,18 +18010,16 @@ ibm+16color|IBM aixterm color definitions,
 	setf=%p1%{8}%/%{6}%*%{3}%+\E[%d%p1%{8}%m%Pa%?%ga%{1}%=%t4%e
 	     %ga%{3}%=%t6%e%ga%{4}%=%t1%e%ga%{6}%=%t3%e%ga%d%;m,
 ibm5154|IBM 5154 Color display,
-	colors#8, ncv@, pairs#64,
+	ncv@,
 	bold@, setab=\E[4%p1%dm, setaf=\E[3%p1%dm, use=ibm5151,
 	use=ibm+color,
 ibmega-c|ibm5154-c|IBM Enhanced Color Display with standout and underline,
 	rmso=\EB, rmul=\EB, smso=\EF\Ef3;, smul=\EF\Ef2;,
 	use=ibmmono,
 ibmvga-c|IBM VGA display color termcap,
-	cr=\r, cud1=\n, ht=^I, ind=\n, kbs=^H, kcub1=^H, kcud1=\n,
-	nel=\r\n, use=ibmega-c,
+	ht=^I, kcub1=^H, kcud1=\n, use=ibmega-c,
 ibmvga|IBM VGA display,
-	cr=\r, cud1=\n, ht=^I, ind=\n, kbs=^H, kcub1=^H, kcud1=\n,
-	nel=\r\n, use=ibmega,
+	use=ibmega,
 # ibmapa* and ibmmono entries come from ACIS 4.3 distribution
 rtpc|ibmapa16|IBM 6155 Extended Monochrome Graphics Display,
 	lines#32,
@@ -17577,51 +18044,39 @@ ibm6153|IBM 6153 Black & White display,
 	sgr=\E[%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p7%t;8%;%?%p6%t;1
 	    2%;m,
 	sgr0=\E[0;10m, use=ibm5151,
-ibm6153-90|IBM 6153 Black & White display,
+ibm6153-90|IBM 6153 Black & White display (36-line),
 	cols#90, lines#36,
 	blink@, bold@, use=ibm5151,
-ibm6153-40|IBM 6153 Black & White display,
+ibm6153-40|IBM 6153 Black & White display (12-line),
 	cols#40, lines#12, use=ibm6153-90,
 ibm8512|ibm8513|IBM color VGA Terminal,
-	am, mir, msgr,
-	cols#80, it#8, lines#25,
-	acsc=jjkkllmmnnqqttuuvvwwxx, blink=\E[5m, bold=\E[1m,
-	clear=\E[H\E[J, cub1=\E[D, cud1=\n, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, dl=\E[%p1%dM, dl1=\E[M,
-	ech=\E[%p1%dX, ed=\E[J, el=\E[K, home=\E[H, il=\E[%p1%dL,
-	il1=\E[L, is2=\Eb\E[m\017\E[?7h, kcud1=\E[B, kcuu1=\E[A,
-	kf0=\E[010q, kf1=\E[001q, kf2=\E[002q, kf3=\E[003q,
-	kf4=\E[004q, kf5=\E[005q, kf6=\E[006q, kf7=\E[007q,
-	kf8=\E[008q, kf9=\E[009q, khome=\E[H, rc=\E[u, rev=\E[7m,
+	mir,
+	cub1=\E[D, is2=\Eb\E[m\017\E[?7h, kf0=\E[010q, rc=\E[u,
 	rmacs=^O, rmam=\E[?7l, rmcup=\E[20h, rmdc=\E[4l,
-	rmir=\E[4l, rmso=\E[m, rmul=\E[m,
 	rs1=\Eb\E[m\017\E[?7h\E[H\E[J, sc=\E[s, sgr0=\E[m,
 	smacs=^N, smam=\E[?7h, smcup=\E[20;4l\E[?7h\Eb,
-	smdc=\E[4h, smir=\E[4h, smso=\E[7m, smul=\E[4m,
-	use=ibm8503,
+	smdc=\E[4h, use=ibm8503,
 hft-c|HFT with Color,
-	colors#8, pairs#64,
 	acsc=jjkkllmmnnqqttuuvvwwxx, s0ds=\E(B, s1ds=\E(0,
 	setab=\E[4%p1%dm, setaf=\E[3%p1%dm, sgr0=\E[0m\E(B,
 	use=ibm5151, use=ibm+color,
 hft-c-old|HFT with Color PC850,
-	colors#8, pairs#64,
 	setab=\E[4%p1%dm, setaf=\E[3%p1%dm, use=ibm5151,
 	use=ibm+color,
 hft-old|AIWS High Function Terminal,
 	am, xon,
 	cols#80, lines#25,
-	bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[J, cr=\r,
-	cub1=^H, cud1=\n, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
-	cuu1=\E[A, dch1=\E[P, dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H,
-	ht=^I, ich1=\E[@, il1=\E[L, ind=\n, invis=\E[8m, kbs=^H,
-	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
-	kf1=\E[001q, kf2=\E[002q, kf3=\E[003q, kf4=\E[004q,
-	kf5=\E[005q, kf6=\E[006q, kf7=\E[007q, kf8=\E[008q,
-	kf9=\E[009q, khome=\E[H, knp=\E[153q, kpp=\E[159q,
+	bel=^G, blink=\E[5m, bold=\E[1m, cr=\r, cub1=^H, cud1=\n,
+	cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, dch1=\E[P,
+	dl1=\E[M, home=\E[H, ht=^I, ich1=\E[@, il1=\E[L, ind=\n,
+	invis=\E[8m, kf1=\E[001q, kf2=\E[002q, kf3=\E[003q,
+	kf4=\E[004q, kf5=\E[005q, kf6=\E[006q, kf7=\E[007q,
+	kf8=\E[008q, kf9=\E[009q, knp=\E[153q, kpp=\E[159q,
 	ktbc=\E[010q, rev=\E[7m, rmir=\E6, rmso=\E[m, rmul=\E[m,
-	sgr0=\E[m, smir=\E6, smso=\E[7m, smul=\E[4m, use=ibm+color,
-ibm-system1|system1|ibm system/1 computer,
+	sgr0=\E[m, smir=\E6, smso=\E[7m, smul=\E[4m,
+	use=ansi+arrows, use=ansi+erase, use=ibm+color,
+
+ibm-system1|system1|IBM system/1 computer,
 	am, xt,
 	cols#80, lines#24,
 	bel=^G, clear=^Z, cub1=^H, cuf1=^\,
@@ -17636,53 +18091,47 @@ lft|lft-pc850|LFT-PC850|IBM LFT PC850 Device,
 	cols#80, it#8, lines#25,
 	acsc=j\331k\277l\332m\300n\305q\304t\303u\264v\301w\302x
 	     \263,
-	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, clear=\E[H\E[J,
-	cr=\r, cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\n,
-	cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
-	cuu=\E[%p1%dA, cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[P,
-	dl=\E[%p1%dM, dl1=\E[M, ech=\E[%p1%dX, ed=\E[2J, el=\E[0K,
-	home=\E[H, hpa=\E[%i%p1%dG, ich=\E[%p1%d@, il=\E[%p1%dL,
-	il1=\E[L, ind=\ED, invis=\E[8m, is2=\Ec, kbs=^H, kcbt=\E[Z,
-	kclr=\E[144q, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C,
-	kcuu1=\E[A, kdch1=\E[P, ked=\E[148q, kel=\E[142q,
-	kend=\E[146q, kf1=\E[001q, kf10=\E[010q, kf11=\E[011q,
-	kf12=\E[012q, kf13=\E[013q, kf14=\E[014q, kf15=\E[015q,
-	kf16=\E[016q, kf17=\E[017q, kf18=\E[018q, kf19=\E[019q,
-	kf2=\E[002q, kf20=\E[020q, kf21=\E[021q, kf22=\E[022q,
-	kf23=\E[023q, kf24=\E[024q, kf25=\E[025q, kf26=\E[026q,
-	kf27=\E[027q, kf28=\E[028q, kf29=\E[029q, kf3=\E[003q,
-	kf30=\E[030q, kf31=\E[031q, kf32=\E[032q, kf33=\E[033q,
-	kf34=\E[034q, kf35=\E[035q, kf36=\E[036q, kf4=\E[004q,
-	kf5=\E[005q, kf6=\E[006q, kf7=\E[007q, kf8=\E[008q,
-	kf9=\E[009q, khome=\E[H, kich1=\E[139q, kil1=\E[140q,
+	bel=^G, cbt=\E[Z, clear=\E[H\E[J, cr=\r, cub1=^H, cud1=\n,
+	cup=\E[%i%p1%d;%p2%dH, dch=\E[%p1%dP, dch1=\E[P,
+	ech=\E[%p1%dX, ed=\E[2J, el=\E[0K, home=\E[H,
+	hpa=\E[%i%p1%dG, ich=\E[%p1%d@, ind=\ED, is2=\Ec,
+	kcbt=\E[Z, kclr=\E[144q, kdch1=\E[P, ked=\E[148q,
+	kel=\E[142q, kend=\E[146q, kf1=\E[001q, kf10=\E[010q,
+	kf11=\E[011q, kf12=\E[012q, kf13=\E[013q, kf14=\E[014q,
+	kf15=\E[015q, kf16=\E[016q, kf17=\E[017q, kf18=\E[018q,
+	kf19=\E[019q, kf2=\E[002q, kf20=\E[020q, kf21=\E[021q,
+	kf22=\E[022q, kf23=\E[023q, kf24=\E[024q, kf25=\E[025q,
+	kf26=\E[026q, kf27=\E[027q, kf28=\E[028q, kf29=\E[029q,
+	kf3=\E[003q, kf30=\E[030q, kf31=\E[031q, kf32=\E[032q,
+	kf33=\E[033q, kf34=\E[034q, kf35=\E[035q, kf36=\E[036q,
+	kf4=\E[004q, kf5=\E[005q, kf6=\E[006q, kf7=\E[007q,
+	kf8=\E[008q, kf9=\E[009q, kich1=\E[139q, kil1=\E[140q,
 	kind=\E[151q, knp=\E[154q, kpp=\E[150q, kri=\E[155q,
-	krmir=\E[4l, rev=\E[7m, ri=\EL, rmacs=\E(B, rmir=\E[4l,
-	rmso=\E[0m, rmul=\E[0m, rs2=\Ec,
+	krmir=\E[4l, ri=\EL, rmacs=\E(B, rmir=\E[4l, rmso=\E[0m,
+	rmul=\E[0m, rs2=\Ec,
 	sgr=\E[%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p6%t;1
 	    %;%?%p7%t;8%;m%?%p9%t\E(0%e\E(B%;,
-	sgr0=\E[0m, smacs=\E(0, smir=\E[4h, smso=\E[7m, smul=\E[4m,
-	tbc=\E[3g, use=ecma+index,
+	smacs=\E(0, smir=\E[4h, tbc=\E[3g, use=ansi+arrows,
+	use=ansi+idl, use=ansi+local, use=ansi+sgrbold,
+	use=ecma+index,
+
 # "Megapel" refers to the display adapter, which was used with the IBM RT
 # aka IBM 6150.
 ibm5081|hft|IBM Megapel Color display,
 	acsc=jjkkllmmnnqqttuuvvwwxx, blink@, bold@, s0ds=\E(B,
 	s1ds=\E(0, sgr0=\E[0m\E(B, use=ibm5154,
 ibm5081-c|ibmmpel-c|IBM 5081 1024x1024 256/4096 Megapel enhanced color display,
-	eslok, hs,
 	lines#33,
-	dsl=\Ej\EYA \EI\Ek, fsl=\Ek, tsl=\Ej\EYA%+ \Eo,
-	use=ibmega-c,
+	dsl=\Ej\EYA \EI\Ek, tsl=\Ej\EYA%+ \Eo, use=ibmega-c,
 ibm8503|ibm8507|ibm8604|IBM 8503 B & W VGA display,
 	use=hft-c,
 ibm8514|IBM 8514/a color VGA display,
 	eslok, hs,
 	dsl=\Ej\EYI \EI\Ek, fsl=\Ek, tsl=\Ej\EYI%+ \Eo, use=hft,
 ibm8514-c|IBM 8514 color display with standout and underline,
-	eslok, hs,
 	lines#41,
-	cr=\r, cud1=\n, dsl=\Ej\EYI \EI\Ek, fsl=\Ek, ht=^I, ind=\n,
-	kbs=^H, kcub1=^H, kcud1=\n, nel=\r\n, tsl=\Ej\EYI%+ \Eo,
-	use=ibmega-c,
+	dsl=\Ej\EYI \EI\Ek, ht=^I, kcub1=^H, kcud1=\n,
+	tsl=\Ej\EYI%+ \Eo, use=ibmega-c,
 
 #
 # AIX entries.  IBM ships these with AIX 3.2.5.
@@ -17690,27 +18139,27 @@ ibm8514-c|IBM 8514 color display with standout and underline,
 # -- added rmacs, smacs based on manpage -TD
 # Note that we could use ibm+16color, but that is not how IBM defines this one.
 aixterm|IBM Aixterm Terminal Emulator,
-	eslok, hs,
-	acsc=jjkkllmmnnqqttuuvvwwxx, bold=\E[1m, dsl=\E[?E,
-	fsl=\E[?F, rc=\E8, ri@, rmacs=\E(B, s0ds=\E(B, s1ds=\E(0,
-	sc=\E7,
+	acsc=jjkkllmmnnqqttuuvvwwxx, bold=\E[1m, rc=\E8, ri@,
+	rmacs=\E(B, s0ds=\E(B, s1ds=\E(0, sc=\E7,
 	sgr=\E[0;10%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p6%t;1%;%?%p7
 	    %t;8%;m%?%p9%t\E(0%e\E(B%;,
-	sgr0=\E[0;10m\E(B, smacs=\E(0, tsl=\E[?%p1%dT,
-	use=ibm6154,
-aixterm-m|IBM AIXterm Monochrome Terminal Emulator,
+	sgr0=\E[0;10m\E(B, smacs=\E(0, use=ibm6154,
+	use=aixterm+sl,
+aixterm+sl|status line for AIXterm,
 	eslok, hs,
-	acsc=jjkkllmmnnqqttuuvvwwxx, bold=\E[1m, dsl=\E[?E,
-	fsl=\E[?F, ri@, s0ds=\E(B, s1ds=\E(0,
+	dsl=\E[?E, fsl=\E[?F, tsl=\E[?%p1%dT,
+
+aixterm-m|IBM AIXterm Monochrome Terminal Emulator,
+	acsc=jjkkllmmnnqqttuuvvwwxx, bold=\E[1m, ri@, s0ds=\E(B,
+	s1ds=\E(0,
 	sgr=\E[0;10%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p6%t;1%;%?%p7
 	    %t;8%;m%?%p9%t\E(0%e\E(B%;,
-	sgr0=\E[0;10m\E(B, tsl=\E[?%p1%dT, use=ibm6153,
+	sgr0=\E[0;10m\E(B, use=ibm6153, use=aixterm+sl,
 aixterm-m-old|old IBM AIXterm Monochrome Terminal Emulator,
-	eslok, hs,
-	bold=\E[1m, dsl=\E[?E, fsl=\E[?F, ri@,
+	bold=\E[1m, ri@,
 	sgr=\E[0;10%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p6%t;1%;%?%p7
 	    %t;8%;m,
-	tsl=\E[?%p1%dT, use=ibm6153,
+	use=ibm6153, use=aixterm+sl,
 jaixterm|IBM Kanji Aixterm Terminal Eemulator,
 	acsc@, rmacs@,
 	sgr=\E[%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p6%t;1%;%?%p7%t;8
@@ -17737,21 +18186,28 @@ i100|gt100|gt100a|General Terminal 100A (formerly Infoton 100),
 	cup=\Ef%p2%{32}%+%c%p1%{32}%+%c, cuu1=\EA, dl1=\EM,
 	ed=\EJ, el=\EK, flash=\Eb$<200/>\Ea, home=\EH, il1=\EL,
 	ind=\n, rmso=\Ea, smso=\Eb,
-i400|infoton 400,
+
+i400|Infoton 400,
 	OTbs, am,
 	cols#80, lines#25,
 	bel=^G, clear=\E[2J, cr=\r, cub1=^H, cud1=\n, cuf1=\E[C,
 	cup=\E[%i%p1%3d;%p2%3dH, cuu1=\E[A,
 	dch1=\E[4h\E[2Q\E[P\E[4l\E[0Q, dl1=\E[M, el=\E[N,
 	il1=\E[L, ind=\n, rmir=\E[4l\E[0Q, smir=\E[4h\E[2Q,
+
 # (addrinfo: removed obsolete ":bc=^Z:" -- esr)
-addrinfo,
-	am,
-	cols#80, lines#24,
-	bel=^G, clear=^L, cr=\r, cub1=^Z, cud1=\n, cuf1=^Y,
-	cup=\037%p1%c%p2%c, cuu1=^\, ed=^K, home=^H, ind=\n, ll=^H^\,
+addrinfo|cursor-addressable Infoton,
+	cup=\037%p1%c%p2%c, home=^H, use=infoton,
+
+# "VISTAR II/HZ Technical Users Manual" (May 1975).
+#
+infoton2|cursor-addressable Infoton VISTAR II,
+	cup=~\021%p2%c%p1%c, home=^H, use=infoton,
+
+# "VISTAR Technical User's Manual" (October 1972).
+#
 # (infoton: used to have the no-ops <lh#0>, <lw#0>, <nlab#0> -- esr)
-infoton,
+infoton|Infoton VISTAR,
 	am,
 	cols#80, lines#24,
 	bel=^G, clear=^L, cr=\r, cub1=^Z, cud1=\n, cuf1=^Y, cuu1=^\,
@@ -18011,7 +18467,7 @@ infoton,
 # Codes and info from Peter Disdale <pete@pdlmail.demon.co.uk> 12 May 1997
 #
 # Entry is by esr going solely on above information and is UNTESTED.
-# This actually looks a lot like a Televideo 9xx.
+# This actually looks a lot like a TeleVideo 9xx.
 # This entry uses page 0 and is monochrome; I'm not brave enough to try
 # to make color work without a test terminal.  The <am> capability is a guess.
 # The initialization string sets conversation mode, blinking underline cursor,
@@ -18056,14 +18512,14 @@ intext|Interactive Systems Corporation modified owl 1200,
 	kcub1=^_, kcud1=\n, kcuf1=^^, kcuu1=^\, kf0=^VJ\r, kf1=^VA\r,
 	kf2=^VB\r, kf3=^VC\r, kf4=^VD\r, kf5=^VE\r, kf6=^VF\r,
 	kf7=^VG\r, kf8=^VH\r, kf9=^VI\r, khome=^Z, rmir=^V<,
-	rmkx=^V9, rmso=^V#\s, smir=^V;, smkx=\036\:\264\026%%,
+	rmkx=^V9, rmso=^V#\s, smir=^V;, smkx=\036:\264\026%%,
 	smso=^V$\,,
 intext2|intextii|INTERACTIVE modified owl 1251,
 	am, bw, ul,
 	cols#80, lines#24, xmc#0,
-	bel=^G, cbt=\E[Z, clear=\E[H\E[2J, cr=\r, cub1=\E[D,
-	cud1=\E[B, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A,
-	dch1=\E[P, dl1=\E[M, ed=\E[J, el=\E[K,
+	bel=^G, cbt=\E[Z, clear=\E[H\E[2J, cr=\r,
+	cup=\E[%i%p1%d;%p2%dH, dch1=\E[P, dl1=\E[M, ed=\E[J,
+	el=\E[K,
 	flash=\E[;;;;;;;;;2;;u$<200/>\E[;;;;;;;;;1;;u,
 	hpa=\E[%p1%{1}%+%dG, ht=^I, ich1=\E[@, il1=\E[L, ind=\E[S,
 	kbs=^H, kcub1=\ED\r, kcud1=\EB\r, kcuf1=\EC\r, kcuu1=\EA\r,
@@ -18072,7 +18528,7 @@ intext2|intextii|INTERACTIVE modified owl 1251,
 	khome=\ER\r, lf0=REFRSH, lf1=DEL CH, lf2=TABSET, lf3=GOTO,
 	lf4=+PAGE, lf5=+SRCH, lf6=-PAGE, lf7=-SRCH, lf8=LEFT,
 	lf9=RIGHT, ri=\E[T, rmso=\E[2 D, rmul=\E[2 D, smso=\E[6 D,
-	smul=\E[18 D,
+	smul=\E[18 D, use=ansi+local1,
 
 #### Kimtron (abm, kt)
 #
@@ -18174,13 +18630,13 @@ kt7ix|kimtron model kt-7 or 70 in IX mode,
 	cuf1=^L, cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K,
 	dch1=\EW, dim=\EG@, dl1=\ER, dsl=\Ef\r, ed=\EY, el=\ET, fsl=\r,
 	home=^^, ht=^I, ich1=\EQ, il1=\EE, ind=\n,
-	is2=\EG0\E s\017\E~, kbs=^H, kcbt=\EI, kclr=\E*,
-	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kdl1=\ER,
-	ked=\EY, kel=\ET, kend=\EY, kf0=^AI\r, kf1=^A@\r, kf2=^AA\r,
+	is2=\EG0\E s\017\E~, kcbt=\EI, kclr=\E*, kdl1=\ER, ked=\EY,
+	kel=\ET, kend=\EY, kf0=^AI\r, kf1=^A@\r, kf2=^AA\r,
 	kf3=^AB\r, kf4=^AC\r, kf5=^AD\r, kf6=^AE\r, kf7=^AF\r,
 	kf8=^AG\r, kf9=^AH\r, khome=^^, kich1=\EQ, kil1=\EE, knp=\EJ,
 	nel=\r\n, pulse=\EK, rmacs=\E%%, rmir=, rmso=\EG0, rmul=\EG0,
 	sgr0=\EG0, smacs=\E$, smir=, smso=\EG4, smul=\EG8, tsl=\Ef,
+	use=ansi+arrows,
 
 #### Microdata/MDIS
 #
@@ -18196,7 +18652,7 @@ kt7ix|kimtron model kt-7 or 70 in IX mode,
 # =========================================
 #
 # Prism-1, Prism-2 and P99:
-#       Ancient Microdata and CMC terminals, vaguely like Adds Regent 25.
+#       Ancient Microdata and CMC terminals, vaguely like ADDS Regent 25.
 #
 # Prism-4 and Prism-5:
 #       Slightly less ancient range of Microdata terminals. Follow-on from
@@ -18355,33 +18811,29 @@ prism8-w|p8-w|P8-W|MDC Prism-8 in 132 column mode,
 #  . Padding values (sets xon)
 # (esr: commented out <smacs>/<rmacs> because there's no <acsc>)
 #
-prism9|p9|P9|MDC Prism-9 in ANSII mode,
+prism9|p9|P9|MDC Prism-9 in ANSI mode,
 	am, bw, hs, msgr, xenl, xon,
-	cols#80, it#8, lines#24, vt#3, wsl#72,
-	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[<4l,
-	clear=^L, cnorm=\E[<4h, cr=\r, csr=\E[%i%p1%d;%p2%d%%v,
-	cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\n,
-	cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
-	cuu=\E[%p1%dA, cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[P,
-	dl=\E[%p1%dM, dl1=\E[M, dsl=\E[%}\024, ech=\E[%p1%dX,
-	ed=\E[J$<10>, el=\E[K, fsl=^T, home=\E[H, hpa=\E[%i%p1%d`,
-	ht=^I, hts=\EH, il=\E[%p1%dL, il1=\E[L, ind=\n,
-	is2=\E[&p\E[<12l\E F, kbs=^H, kclr=^L, kcub1=\E[D,
-	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kf1=\E[11~,
-	kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[25~,
-	kf14=\E[26~, kf15=\E[28~, kf16=\E[29~, kf17=\E[31~,
-	kf18=\E[32~, kf2=\E[12~, kf3=\E[13~, kf4=\E[14~,
-	kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~,
-	khome=\E[H, nel=\r\n, prot=\E[32%{, rc=\E[%z,
-	rep=\E[%p2%db%p1%c, rev=\E[7m, ri=\E[L, rmir=\E[4l,
-	rmso=\E[27m, rmul=\E[24m,
+	cols#80, lines#24, vt#3, wsl#72,
+	bel=^G, blink=\E[5m, bold=\E[1m, civis=\E[<4l, clear=^L,
+	cnorm=\E[<4h, cr=\r, csr=\E[%i%p1%d;%p2%d%%v, cub1=^H,
+	cud1=\n, cup=\E[%i%p1%d;%p2%dH, dch=\E[%p1%dP, dch1=\E[P,
+	dsl=\E[%}\024, ech=\E[%p1%dX, ed=\E[J$<10>, el=\E[K,
+	fsl=^T, home=\E[H, hpa=\E[%i%p1%d`, ind=\n,
+	is2=\E[&p\E[<12l\E F, kclr=^L, kf1=\E[11~, kf10=\E[21~,
+	kf11=\E[23~, kf12=\E[24~, kf13=\E[25~, kf14=\E[26~,
+	kf15=\E[28~, kf16=\E[29~, kf17=\E[31~, kf18=\E[32~,
+	kf2=\E[12~, kf3=\E[13~, kf4=\E[14~, kf5=\E[15~, kf6=\E[17~,
+	kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, nel=\r\n, prot=\E[32%{,
+	rc=\E[%z, rep=\E[%p2%db%p1%c, rev=\E[7m, ri=\E[L,
+	rmir=\E[4l, rmso=\E[27m, rmul=\E[24m,
 	rs2=\E[&p\E[<12l\E\sF\E[3g\E[9;17;25;33;41;49;57;65;73
 	    \sN,
 	sc=\E[%y,
 	sgr=\E[0%?%p1%p3%|%t;7%;%?%p2%t;4%;%?%p4%t;5%;%?%p6%t;1%;m%?
 	    %p8%t\E[32%%{%;%?%p9%t\016%e\017%;,
 	sgr0=\E[0m\017, smir=\E[4h, smso=\E[7m, smul=\E[4m,
-	tbc=\E[3g, tsl=\E[%i%p1%d%%}, vpa=\E[%i%p1%dd,
+	tsl=\E[%i%p1%d%%}, vpa=\E[%i%p1%dd, use=ansi+arrows,
+	use=ansi+idl, use=ansi+inittabs, use=ansi+local,
 	use=ansi+pp,
 
 # p9-w: Prism-9 in 132 column mode
@@ -18402,8 +18854,8 @@ prism9-w|p9-w|P9-W|MDC Prism-9 in 132 column mode,
 # Insertion and deletion operations possible.
 #
 prism9-8|p9-8|P9-8|MDC Prism-9 in P8 mode,
-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M,
-	ich=\E[%p1%d@, ich1=\E[@, il=\E[%p1%dL, il1=\E[L, use=p8,
+	dch=\E[%p1%dP, dch1=\E[P, ich=\E[%p1%d@, ich1=\E[@,
+	use=ansi+idl, use=p8,
 
 # p9-8-w: Prism-9 in P8 and 132 column modes
 # ------------------------------------------
@@ -18411,8 +18863,8 @@ prism9-8|p9-8|P9-8|MDC Prism-9 in P8 mode,
 # P9 terminal in P8 emulation mode and 132 column mode.
 #
 prism9-8-w|p9-8-w|P9-8-W|MDC Prism-9 in Prism 8 emulation and 132 column mode,
-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M,
-	ich=\E[%p1%d@, ich1=\E[@, il=\E[%p1%dL, il1=\E[L, use=p8-w,
+	dch=\E[%p1%dP, dch1=\E[P, ich=\E[%p1%d@, ich1=\E[@,
+	use=ansi+idl, use=p8-w,
 
 # p12: Prism-12 in ANSI mode
 # ---------------------------
@@ -18448,12 +18900,12 @@ prism12-m|p12-m|P12-M|MDC Prism-12 in MDC emulation mode,
 prism12-m-w|p12-m-w|P12-M-W|MDC Prism-12 in MDC emulation and 132 column mode,
 	use=p9-8-w,
 
-# p14: Prism-14 in ANSII mode
+# p14: Prism-14 in ANSI mode
 # ---------------------------
 #
 # See p9 definition.
 #
-prism14|p14|P14|MDC Prism-14 in ANSII mode,
+prism14|p14|P14|MDC Prism-14 in ANSI mode,
 	use=p9,
 
 # p14-w: Prism-14 in 132 column mode
@@ -18525,8 +18977,7 @@ act4|microterm|microterm act iv,
 # The act 5 has hardware tabs, but they are in columns 8, 16, 24, 32, 41 (!)...
 # (microterm5: removed obsolete ":ma==^Z^P^Xl^Kj:" -- esr)
 act5|microterm5|microterm act v,
-	kcub1=^H, kcud1=^K, kcuf1=^X, kcuu1=^Z, ri=\EH$<3>, uc=^H\EA,
-	use=act4,
+	ri=\EH$<3>, uc=^H\EA, use=act4,
 # Mimes using brightness for standout.  Half bright is really dim unless
 # you turn up the brightness so far that lines show up on the screen.
 mime-fb|full bright mime1,
@@ -18546,7 +18997,7 @@ mime|mime1|mime2|mimei|mimeii|microterm mime1,
 	kcuf1=^X, kcuu1=^Z, ri=\022$<3>, uc=^U,
 # These termcaps (for mime2a) put the terminal in low intensity mode
 # since high intensity mode is so obnoxious.
-mime2a-s|microterm mime2a (emulating an enhanced soroc iq120),
+mime2a-s|microterm mime2a (emulating an enhanced Soroc iq120),
 	OTbs, am,
 	cols#80, lines#24,
 	bel=^G, clear=\EL, cr=\r, cub1=^H, cud1=\n, cuf1=^L,
@@ -18554,21 +19005,21 @@ mime2a-s|microterm mime2a (emulating an enhanced soroc iq120),
 	dl1=\027$<20*>, ed=\EJ$<20*>, el=\EK, home=^^,
 	il1=\001$<20*>, ind=\n, ip=$<2>, is2=\E), kcub1=^H, kcud1=\n,
 	kcuf1=^L, kcuu1=^K, ri=\EI, rmir=^Z, rmso=\E;, rmul=\E7,
-	smir=\EE, smso=\E\:, smul=\E6,
+	smir=\EE, smso=\E:, smul=\E6,
 # This is the preferred mode (but ^X can't be used as a kill character)
-mime2a|mime2a-v|microterm mime2a (emulating an enhanced vt52),
+mime2a|mime2a-v|microterm mime2a (emulating an enhanced VT52),
 	OTbs,
 	cols#80, it#8, lines#24,
 	bel=^G, clear=\EL, cr=\r, cub1=^H, cud1=\n, cuf1=\EC,
 	cup=\EY%p1%{32}%+%c%p2%{32}%+%c, cuu1=\EA, dch1=^N,
 	dl1=\027$<20*>, ed=\EQ$<20*>, el=\EP, home=\EH, ht=^I,
-	il1=\001$<20*>, ind=\n, ip=$<2>, is2=^Y, kcub1=\ED,
-	kcud1=\EB, kcuf1=\EC, kcuu1=\EA, ri=\EA, rmir=^Z, rmso=\E9,
-	rmul=\E5, smir=^O, smso=\E8, smul=\E4,
+	il1=\001$<20*>, ind=\n, ip=$<2>, is2=^Y, ri=\EA, rmir=^Z,
+	rmso=\E9, rmul=\E5, smir=^O, smso=\E8, smul=\E4,
+	use=vt52+arrows,
 # (mime3a: removed obsolete ":ma=^X ^K^J^Z^P:" -- esr)
 mime3a|mime1 emulating 3a,
 	am@,
-	kcub1=^H, kcud1=^K, kcuf1=^X, kcuu1=^Z, use=adm3a,
+	kcud1=^K, kcuf1=^X, kcuu1=^Z, use=adm3a,
 mime3ax|mime-3ax|mime1 emulating enhanced 3a,
 	it#8,
 	dl1=\027$<80>, ed=^_, el=^X, ht=\011$<3>, il1=\001$<80>,
@@ -18601,23 +19052,19 @@ mm340|mime340|mime 340,
 mt4520-rv|micro-term 4520 reverse video,
 	am, hs, msgr, xenl, xon,
 	cols#80, it#8, lines#24, wsl#80,
-	bel=^G, clear=\E[H\E[J, cnorm=\E[0V\E8, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=\E[D,
-	cud=\E[%p1%dB, cud1=\E[B, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	cvvis=\E7\E[0U, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM,
-	dl1=\E[M, ed=\E[J, el=\E[K, flash=\E[?5l$<200/>\E[?5h,
-	fsl=\E[?5l\E[?5h, home=\E[H, ht=^I, hts=\EH, ich=\E[%p1%d@,
-	ich1=\E[@, il=\E[%p1%dL, il1=\E[L, ind=\ED,
+	bel=^G, cnorm=\E[0V\E8, cr=\r, cup=\E[%i%p1%d;%p2%dH,
+	cvvis=\E7\E[0U, dch=\E[%p1%dP, dch1=\E[P,
+	flash=\E[?5l$<200/>\E[?5h, fsl=\E[?5l\E[?5h, home=\E[H,
+	ht=^I, hts=\EH, ich=\E[%p1%d@, ich1=\E[@, ind=\ED,
 	is2=\E(B\E[2l\E>\E[20l\E[?3l\E[?5h\E[?7h\E[1;24r\E[24;1H\E[H
 	    \E[J,
-	kbs=^H, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
-	kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, khome=\E[H,
-	ll=\E[24;1H, nel=\EE, rc=\E8, rf=/usr/share/tabset/vt100,
-	ri=\EM, rmam=\E[?7l, rmso=\E[0m, rmul=\E[24m,
+	kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, ll=\E[24;1H, nel=\EE,
+	rf=/usr/share/tabset/vt100, ri=\EM, rmam=\E[?7l,
+	rmso=\E[0m, rmul=\E[24m,
 	rs1=\E(B\E[2l\E>\E[20l\E[?3l\E[?5h\E[?7h\E[H\E[J,
-	sc=\E7, sgr0=\E[m, smam=\E[?7h, smso=\E[7m, smul=\E[4m,
-	tbc=\E[g, tsl=\E[25;1H,
+	sgr0=\E[m, smam=\E[?7h, smso=\E[7m, smul=\E[4m, tbc=\E[g,
+	tsl=\E[25;1H, use=ansi+arrows, use=ansi+csr,
+	use=ansi+erase, use=ansi+idl, use=ansi+local,
 
 # Fri Aug  5 08:11:57 1983
 # This entry works for the ergo 4000 with the following setups:
@@ -18631,17 +19078,17 @@ mt4520-rv|micro-term 4520 reverse video,
 ergo4000|microterm ergo 4000,
 	da, db, msgr,
 	cols#80, lines#66,
-	bel=^G, clear=\E[H\E[2J$<80>, cr=\r, cub1=^H, cud1=\E[B,
-	cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A,
-	dch1=\E[1P$<80>, dl1=\E[1M$<5*>, ed=\E[0J$<15>,
-	el=\E[0K$<13>, ht=^I, il1=\E[1L$<5*>, ind=\ED$<20*>,
+	bel=^G, clear=\E[H\E[2J$<80>, cr=\r, cub1=^H,
+	cup=\E[%i%p1%d;%p2%dH, dch1=\E[1P$<80>, dl1=\E[1M$<5*>,
+	ed=\E[0J$<15>, el=\E[0K$<13>, ht=^I, il1=\E[1L$<5*>,
+	ind=\ED$<20*>,
 	is2=\E<\E=\E[?1l\E[?4l\E[?5l\E[?7h\E[?8h$<300>,
 	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kf1=\EOP,
 	kf2=\EOQ, kf3=\EOR, kf4=\EOS, lf1=pf1, lf2=pf2, lf3=pf3,
 	lf4=pf4, ri=\EM$<20*>, rmam=\E[?7l, rmir=\E[4l,
 	rmkx=\E=$<4>, rmso=\E[m$<20>, sgr0=\E[m$<20>,
 	smam=\E[?7m, smir=\E[4h$<6>, smkx=\E=$<4>,
-	smso=\E[7m$<20>,
+	smso=\E[7m$<20>, use=ansi+local1,
 
 #### NCR
 #
@@ -18657,26 +19104,26 @@ ergo4000|microterm ergo 4000,
 # capabilities.X
 #
 # The Intecolor emulation of the NCR 2900/260C color terminal is basically a
-# DEC vt200/300 with color capabilities added.
-ncr260intan|NCR Intecolor emulation of the 2900_260C with an ANSI keyboard,
+# DEC VT200/300 with color capabilities added.
+ncr260intan|NCR Intecolor emulation of the 2900/260C with an ANSI keyboard,
 	colors#8, pairs#64,
 	op=\E[0m, setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
-	use=ncr260vt300an,
+	use=decid+cpr, use=ncr260vt300an,
 # The Intecolor emulation of the NCR 2900/260C color terminal is basically a
-# DEC vt200/300 with color capabilities added.
-ncr260intwan|NCR Intecolor emulation of the 2900_260C with an ANSI keyboard,
+# DEC VT200/300 with color capabilities added.
+ncr260intwan|NCR Intecolor emulation of the 2900/260C with an ANSI keyboard (132 column),
 	colors#8, pairs#64,
 	op=\E[0m, setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
-	use=ncr260vt300wan,
+	use=decid+cpr, use=ncr260vt300wan,
 # The Intecolor emulation of the NCR 2900/260C color terminal is basically a
-# DEC vt200/300 with color capabilities added.
-ncr260intpp|NCR Intecolor emulation of the 2900_260C with a PC+ keyboard,
+# DEC VT200/300 with color capabilities added.
+ncr260intpp|NCR Intecolor emulation of the 2900/260C with a PC+ keyboard,
 	colors#8, pairs#64,
 	op=\E[0m, setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
 	use=ncr260vt300pp,
 # The Intecolor emulation of the NCR 2900/260C color terminal is basically a
-# DEC vt200/300 with color capabilities added.
-ncr260intwpp|NCR Intecolor emulation of the 2900_260C with a PC+ keyboard in 132 column mode,
+# DEC VT200/300 with color capabilities added.
+ncr260intwpp|NCR Intecolor emulation of the 2900/260C with a PC+ keyboard (132 column),
 	colors#8, pairs#64,
 	op=\E[0m, setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
 	use=ncr260vt300wpp,
@@ -18688,21 +19135,21 @@ ncr260intwpp|NCR Intecolor emulation of the 2900_260C with a PC+ keyboard in 132
 # attributes can be removed.
 # Mapping to ASCII character set ('acsc' capability) can also be
 # restored if needed.
-ncr260vppp|NCR 2900_260 viewpoint,
-	am, bw, hs, km, mc5i, mir, msgr, xon,
+ncr260vppp|NCR 2900/260 viewpoint,
+	am, bw, km, mc5i, mir, msgr, xon,
 	cols#80, lines#24, nlab#32, xmc#1,
-	acsc=07a?h;j5k3l2m1n8q\:t4u9v=w0x6, bel=^G, blink=\EG2,
+	acsc=07a?h;j5k3l2m1n8q:t4u9v=w0x6, bel=^G, blink=\EG2,
 	cbt=\EI, civis=\E`0, clear=\014$<40>, cnorm=\E`5,
 	cr=\r$<2>, cub1=\010$<2>, cud1=\n$<2>, cuf1=\006$<2>,
 	cup=\EY%p1%{32}%+%c%p2%{32}%+%c$<5>, cuu1=\032$<2>,
-	dch1=\EW$<2>, dim=\EGp, dl1=\El$<2>, dsl=\E`c, ed=\Ek$<2>,
-	el=\EK$<2>, fsl=\r, home=\036$<2>, ht=^I, hts=\E1,
-	il1=\EM$<2>, ind=\n$<2>, invis=\EG1,
-	is2=\Ee6\E~%$<100>\E+\E`\:\Ed/\E`1\EO\Ee4\Ec@0@\Ec@1A\EcB0
+	dch1=\EW$<2>, dim=\EGp, dl1=\El$<2>, ed=\Ek$<2>,
+	el=\EK$<2>, home=\036$<2>, ht=^I, hts=\E1, il1=\EM$<2>,
+	ind=\n$<2>, invis=\EG1,
+	is2=\Ee6\E~%$<100>\E+\E`:\Ed/\E`1\EO\Ee4\Ec@0@\Ec@1A\EcB0
 	    \EcC1\Ee7$<100>,
 	kDC=\El, kEND=\Ek, kHOM=^A, kPRT=\E7, kRIT=^F, ka1=^A, ka3=\EJ,
 	kbs=^H, kc1=\ET, kc3=\EJ, kcub1=^U, kcud1=\n, kcuf1=^F,
-	kcuu1=^Z, kdch1=\EW, kend=\EK, kf1=^B1\r, kf10=\002\:\r,
+	kcuu1=^Z, kdch1=\EW, kend=\EK, kf1=^B1\r, kf10=^B:\r,
 	kf11=^B;\r, kf12=^B<\r, kf13=^B=\r, kf14=^B>\r, kf15=^B?\r,
 	kf16=^B@\r, kf17=^B!\r, kf18=^B"\r, kf19=^B#\r, kf2=^B2\r,
 	kf20=^B$\r, kf21=^B%^M, kf22=^B&\r, kf23=^B'\r, kf24=^B(\r,
@@ -18714,11 +19161,16 @@ ncr260vppp|NCR 2900_260 viewpoint,
 	mrcup=\Ew@%p1%{48}%+%c%p2%{32}%+%c%p3%{32}%+%c$<5>,
 	nel=\037$<2>, rev=\EG4, ri=\Ej$<2>, rmacs=\EcB0\EH\003,
 	rmir=\Er, rmso=\EG0, rmul=\EG0, rmxon=\Ec20,
-	rs2=\Ee6\E~%$<100>\E+\E`\:\Ed/\E`1\EO\Ee4\Ec@0@\Ec@1A\EcB0
+	rs2=\Ee6\E~%$<100>\E+\E`:\Ed/\E`1\EO\Ee4\Ec@0@\Ec@1A\EcB0
 	    \EcC1\Ee7$<100>,
 	sgr0=\EG0\EH\003, smacs=\EcB1\EH\002, smir=\Eq,
-	smso=\EG4, smul=\EG8, smxon=\Ec21, tsl=\EF,
-ncr260vpwpp|NCR 2900_260 viewpoint wide mode,
+	smso=\EG4, smul=\EG8, smxon=\Ec21, use=ncr260vp+sl,
+
+ncr260vp+sl|NCR 2900/260 viewpoint with status-line,
+	hs,
+	dsl=\E`c, fsl=\r, tsl=\EF,
+
+ncr260vpwpp|NCR 2900/260 viewpoint wide mode,
 	cols#132,
 	cup=\Ea%i%p1%dR%p2%dC$<30>,
 	is2=\Ee6\E~%$<100>\E+\E`;\Ed/\E`1\EO\Ee4\Ec@0@\Ec@1A\EcB0
@@ -18726,38 +19178,41 @@ ncr260vpwpp|NCR 2900_260 viewpoint wide mode,
 	rs2=\Ee6\E~%$<100>\E+\E`;\Ed/\E`1\EO\Ee4\Ec@0@\Ec@1A\EcB0
 	    \EcC1\Ee7$<100>,
 	use=ncr260vppp,
-ncr260vt100an|NCR 2900_260 vt100 with ansi kybd,
-	am, hs, mir, msgr, xenl, xon,
+
+ncr260vt100an|NCR 2900/260 VT100 with ANSI keyboard,
+	am, mir, msgr, xenl, xon,
 	cols#80, lines#24, nlab#32,
 	acsc=``aaffggjjkkllmmnnooqqssttuuvvwwxx~~, bel=^G,
-	blink=\E[5m, bold=\E[1m, clear=\E[2J\E[1;1H$<20>,
-	cr=\r$<1>, csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD$<5>,
+	clear=\E[2J\E[1;1H$<20>, cr=\r$<1>, cub=\E[%p1%dD$<5>,
 	cub1=\E[D$<5>, cud=\E[%p1%dB$<5>, cud1=\E[B$<5>,
 	cuf=\E[%p1%dC$<5>, cuf1=\E[C$<5>,
 	cup=\E[%i%p1%d;%p2%dH$<10>, cuu=\E[%p1%dA$<5>,
 	cuu1=\E[A$<5>, dch=\E[%p1%dP$<5>, dch1=\E[1P$<5>,
-	dl=\E[%p1%dM$<5>, dl1=\E[M$<5>, dsl=\E[0$~\E[1$~,
-	ech=\E[%p1%dX, ed=\E[0J$<5>, el=\E[0K$<3>, el1=\E[1K$<3>,
-	fsl=\E[0$}, home=\E[H$<1>, hpa=\E[%p1%dG$<40>, ht=^I,
-	hts=\EH, ich=\E[%p1%d@$<5>, il=\E[%p1%dL$<5>,
-	il1=\E[L$<5>, ind=\ED$<5>, indn=\E[%p1%dE$<5>,
-	invis=\E[8m,
+	dl=\E[%p1%dM$<5>, dl1=\E[M$<5>, ech=\E[%p1%dX,
+	ed=\E[0J$<5>, el=\E[0K$<3>, el1=\E[1K$<3>, home=\E[H$<1>,
+	hpa=\E[%p1%dG$<40>, ht=^I, hts=\EH, ich=\E[%p1%d@$<5>,
+	il=\E[%p1%dL$<5>, il1=\E[L$<5>, ind=\ED$<5>,
+	indn=\E[%p1%dE$<5>,
 	is2=\E[!p\E[?7;19;67h\E[?1;3;4l\E(B\E)0\017\E[2J\E[1;1H\E>$<
 	    200>,
 	kbs=^H, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
-	khlp=\E[28~, kich1=\E[2~, krdo=\E[29~, nel=\EE$<5>, rc=\E8,
-	rev=\E[7m, ri=\EM$<5>, rmacs=^O, rmir=\E[4l,
-	rmkx=\E[?1l\E>, rmso=\E[0m, rmul=\E[0m,
+	khlp=\E[28~, kich1=\E[2~, krdo=\E[29~, nel=\EE$<5>,
+	ri=\EM$<5>, rmacs=^O, rmir=\E[4l, rmkx=\E[?1l\E>,
+	rmso=\E[0m, rmul=\E[0m,
 	rs2=\E[!p\E[?7;19;67h\E[?1;3;4l\E(B\E)0\017\E[2J\E[1;1H\E>$<
 	    200>,
-	sc=\E7,
 	sgr=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5
 	    %;%?%p7%t;8%;m%?%p9%t\016%e\017%;$<20>,
 	sgr0=\E[0m\017$<20>, smacs=^N, smir=\E[4h,
-	smkx=\E[?1h\E=, smso=\E[1;7m, smul=\E[4m, tbc=\E[3g,
-	tsl=\E[2$~\E[1$}, vpa=\E[%p1%dd$<40>, use=vt220+vtedit,
-	use=vt220+cvis, use=vt220+keypad,
-ncr260vt100wan|NCR 2900_260 vt100 wide mode ansi kybd,
+	smkx=\E[?1h\E=, smso=\E[1;7m, tbc=\E[3g,
+	vpa=\E[%p1%dd$<40>, use=ansi+csr, use=ansi+sgrbold,
+	use=decid+cpr, use=vt220+vtedit, use=vt220+cvis,
+	use=vt220+keypad, use=ncr260vt+sl,
+
+ncr260vt+sl|NCR 2900/260 VT100 status line,
+	hs,
+	dsl=\E[0$~\E[1$~, fsl=\E[0$}, tsl=\E[2$~\E[1$},
+ncr260vt100wan|NCR 2900/260 VT100 wide mode ANSI keyboard,
 	cols#132,
 	cup=\E[%i%p1%d;%p2%dH$<30>,
 	is2=\E[!p\E[?3;7;19;67h\E[?1;4l\E(B\E)0\017\E[2J\E[1;1H\E>$<
@@ -18765,17 +19220,13 @@ ncr260vt100wan|NCR 2900_260 vt100 wide mode ansi kybd,
 	rs2=\E[!p\E[?3;7;19;67h\E[?1;4l\E(B\E)0\017\E[2J\E[1;1H\E>$<
 	    200>,
 	use=ncr260vt100an,
-ncr260vt100pp|NCR 2900_260 vt100 with PC+ kybd,
-	is2=\E[!p\E[?7;19;67h\E[?1;3;4l\E(B\E)0\017\E[2J\E[1;1H\E>$<
-	    200>,
+ncr260vt100pp|NCR 2900/260 VT100 with PC+ keyboard,
 	ka1=\E[H, ka3=\EOu, kb2=\E[V, kc3=\E[U, kcub1=\E[D,
 	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kdch1=\E[4~,
-	kend=\E[5~, khome=\E[2~, kich1=\E[1~, knp=\E[6~, kpp=\E[3~,
-	lf1=pf1, lf2=pf2, lf3=pf3, lf4=pf4, rmkx=\E>,
-	rs2=\E[!p\E[?7;19;67h\E[?1;3;4l\E(B\E)0\017\E[2J\E[1;1H\E>$<
-	    200>,
-	smkx=\E=, use=ncr260vt100an,
-ncr260vt100wpp|NCR 2900_260 vt100 wide mode pc+  kybd,
+	kend=\E[5~, khome=\E[2~, kich1=\E[1~, kpp=\E[3~, lf1=pf1,
+	lf2=pf2, lf3=pf3, lf4=pf4, rmkx=\E>, smkx=\E=,
+	use=ncr260vt100an,
+ncr260vt100wpp|NCR 2900/260 VT100 wide mode PC+  keyboard,
 	cols#132,
 	cup=\E[%i%p1%d;%p2%dH$<30>,
 	is2=\E[!p\E[?3;7;19;67h\E[?1;4l\E(B\E)0\017\E[2J\E[1;1H\E>$<
@@ -18783,57 +19234,57 @@ ncr260vt100wpp|NCR 2900_260 vt100 wide mode pc+  kybd,
 	rs2=\E[!p\E[?3;7;19;67h\E[?1;4l\E(B\E)0\017\E[2J\E[1;1H\E>$<
 	    200>,
 	use=ncr260vt100pp,
-ncr260vt200an|NCR 2900_260 vt200 with ansi kybd,
-	am, hs, mir, msgr, xenl, xon,
+ncr260vt200an|NCR 2900/260 VT200 with ANSI keyboard,
+	am, mir, msgr, xenl, xon,
 	cols#80, lines#24, nlab#32,
 	acsc=``aaffggjjkkllmmnnooqqssttuuvvwwxx~~, bel=^G,
-	blink=\E[5m, bold=\E[1m, clear=\E[2J\E[1;1H$<20>,
-	cr=\r$<1>, csr=\E[%i%p1%d;%p2%dr$<5>,
-	cub=\E[%p1%dD$<5>, cub1=\E[D$<5>, cud=\E[%p1%dB$<5>,
-	cud1=\E[B$<5>, cuf=\E[%p1%dC$<5>, cuf1=\E[C$<5>,
+	clear=\E[2J\E[1;1H$<20>, cr=\r$<1>,
+	csr=\E[%i%p1%d;%p2%dr$<5>, cub=\E[%p1%dD$<5>,
+	cub1=\E[D$<5>, cud=\E[%p1%dB$<5>, cud1=\E[B$<5>,
+	cuf=\E[%p1%dC$<5>, cuf1=\E[C$<5>,
 	cup=\E[%i%p1%d;%p2%dH$<10>, cuu=\E[%p1%dA$<5>,
 	cuu1=\E[A$<5>, dch=\E[%p1%dP$<5>, dch1=\E[1P$<5>,
-	dl=\E[%p1%dM$<5>, dl1=\E[M$<5>, dsl=\E[0$~\E[1$~,
-	ech=\E[%p1%dX$<5>, ed=\E[0J, el=\E[0K$<5>, el1=\E[1K$<5>,
-	fsl=\E[0$}, home=\E[H, hpa=\E[%p1%dG$<40>, ht=^I, hts=\EH,
-	ich=\E[%p1%d@$<5>, il=\E[%p1%dL$<5>, il1=\E[L$<5>,
-	ind=\ED$<5>, indn=\E[%p1%dE$<5>, invis=\E[8m,
+	dl=\E[%p1%dM$<5>, dl1=\E[M$<5>, ech=\E[%p1%dX$<5>,
+	ed=\E[0J, el=\E[0K$<5>, el1=\E[1K$<5>, home=\E[H,
+	hpa=\E[%p1%dG$<40>, ht=^I, hts=\EH, ich=\E[%p1%d@$<5>,
+	il=\E[%p1%dL$<5>, il1=\E[L$<5>, ind=\ED$<5>,
+	indn=\E[%p1%dE$<5>,
 	is2=\E[!p\E[?7;19;67h\E[?1;3;4l\E(B\E)0\017\E[2J\E[1;1H\E>$<
 	    200>,
 	kbs=^H, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
 	kf0=\EOy, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~,
 	kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, kf16=\E[29~,
-	kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, kf2=\EOQ,
-	kf20=\E[34~, kf21=\E[31~, kf22=\E[32~, kf23=\E[33~,
-	kf24=\E[34~, kf25=\E[35~, kf26=\E[1~, kf27=\E[2~,
-	kf28=\E[3~, kf29=\E[4~, kf3=\EOR, kf30=\E[5~, kf31=\E[6~,
-	kf32=\E[7~, kf33=\E[8~, kf34=\E[9~, kf35=\E[10~, kf4=\EOS,
-	kf5=\E[M, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~,
-	khlp=\E[28~, krdo=\E[29~, mc0=\E[i, mc4=\E[4i, mc5=\E[5i,
-	nel=\EE, rc=\E8, rev=\E[7m, ri=\EM$<5>, rmacs=\017$<20>,
-	rmam=\E[?7l, rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[27m,
-	rmul=\E[24m,
+	kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, kf20=\E[34~,
+	kf21=\E[31~, kf22=\E[32~, kf23=\E[33~, kf24=\E[34~,
+	kf25=\E[35~, kf26=\E[1~, kf27=\E[2~, kf28=\E[3~,
+	kf29=\E[4~, kf30=\E[5~, kf31=\E[6~, kf32=\E[7~, kf33=\E[8~,
+	kf34=\E[9~, kf35=\E[10~, kf5=\E[M, kf6=\E[17~, kf7=\E[18~,
+	kf8=\E[19~, kf9=\E[20~, khlp=\E[28~, krdo=\E[29~, mc0=\E[i,
+	mc4=\E[4i, mc5=\E[5i, nel=\EE, rc=\E8, ri=\EM$<5>,
+	rmacs=\017$<20>, rmam=\E[?7l, rmir=\E[4l, rmkx=\E[?1l\E>,
+	rmso=\E[27m, rmul=\E[24m,
 	rs2=\E[!p\E[?7;19;67h\E[?1;3;4l\E(B\E)0\017\E[2J\E[1;1H\E>$<
 	    200>,
 	sc=\E7,
 	sgr=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5
 	    %;%?%p7%t;8%;m%?%p9%t\016%e\017%;$<20>,
 	sgr0=\E[0m\017$<20>, smacs=\016$<20>, smam=\E[?7h,
-	smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m,
-	tbc=\E[3g, tsl=\E[2$~\E[1$}, vpa=\E[%p1%dd$<40>,
+	smir=\E[4h, smkx=\E[?1h\E=, tbc=\E[3g,
+	vpa=\E[%p1%dd$<40>, use=ansi+sgrbold, use=decid+cpr,
 	use=vt220+vtedit, use=vt220+cvis, use=vt220+keypad,
-ncr260vt200wan|NCR 2900_260 vt200 wide mode ansi kybd,
+	use=ncr260vt+sl,
+
+ncr260vt200wan|NCR 2900/260 VT200 wide mode ANSI keyboard,
 	cols#132,
 	cup=\E[%i%p1%d;%p2%dH$<30>,
 	is2=\E[!p\E[?3;7;19;67h\E[?4l\E(B\E)0\017\E[2J\E[1;1H$<200>,
 	rs2=\E[!p\E[?3;7;19;67h\E[?4l\E(B\E)0\017\E[2J\E[1;1H$<200>, use=ncr260vt200an,
-ncr260vt200pp|NCR 2900_260 vt200 with pc+ kybd,
+ncr260vt200pp|NCR 2900/260 VT200 with PC+ keyboard,
 	ka1=\E[H, ka3=\EOu, kb2=\E[V, kc3=\E[U, kcub1=\E[D,
 	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kdch1=\E[4~,
-	kend=\E[1~, khome=\E[H, kich1=\E[2~, knp=\E[6~, kpp=\E[5~,
-	lf1=pf1, lf2=pf2, lf3=pf3, lf4=pf4, rmkx=\E>, smkx=\E=,
-	use=ncr260vt200an,
-ncr260vt200wpp|NCR 2900_260 vt200 wide mode pc+  kybd,
+	kend=\E[1~, khome=\E[H, lf1=pf1, lf2=pf2, lf3=pf3, lf4=pf4,
+	rmkx=\E>, smkx=\E=, use=ncr260vt200an,
+ncr260vt200wpp|NCR 2900/260 VT200 wide mode PC+  keyboard,
 	cols#132,
 	cup=\E[%i%p1%d;%p2%dH$<30>,
 	is2=\E[!p\E[?3;7;19;67h\E[?1;4l\E(B\E)0\017\E[2J\E[1;1H\E>$<
@@ -18841,21 +19292,21 @@ ncr260vt200wpp|NCR 2900_260 vt200 wide mode pc+  kybd,
 	rs2=\E[!p\E[?3;7;19;67h\E[?1;4l\E(B\E)0\017\E[2J\E[1;1H\E>$<
 	    200>,
 	use=ncr260vt200pp,
-ncr260vt300an|NCR 2900_260 vt300 with ansi kybd,
-	am, hs, mir, msgr, xenl, xon,
+ncr260vt300an|NCR 2900/260 VT300 with ANSI keyboard,
+	am, mir, msgr, xenl, xon,
 	cols#80, lines#24, nlab#32,
 	acsc=``aaffggjjkkllmmnnooqqssttuuvvwwxx~~, bel=^G,
-	blink=\E[5m, bold=\E[1m, clear=\E[2J\E[1;1H$<20>,
-	cr=\r$<1>, csr=\E[%i%p1%d;%p2%dr$<5>,
-	cub=\E[%p1%dD$<5>, cub1=\E[D$<5>, cud=\E[%p1%dB$<5>,
-	cud1=\E[B$<5>, cuf=\E[%p1%dC$<5>, cuf1=\E[C$<5>,
+	clear=\E[2J\E[1;1H$<20>, cr=\r$<1>,
+	csr=\E[%i%p1%d;%p2%dr$<5>, cub=\E[%p1%dD$<5>,
+	cub1=\E[D$<5>, cud=\E[%p1%dB$<5>, cud1=\E[B$<5>,
+	cuf=\E[%p1%dC$<5>, cuf1=\E[C$<5>,
 	cup=\E[%i%p1%d;%p2%dH$<10>, cuu=\E[%p1%dA$<5>,
 	cuu1=\E[A$<5>, dch=\E[%p1%dP$<5>, dch1=\E[1P$<5>,
-	dl=\E[%p1%dM$<5>, dl1=\E[M$<5>, dsl=\E[0$~\E[1$~,
-	ech=\E[%p1%dX$<5>, ed=\E[0J, el=\E[0K$<5>, el1=\E[1K$<5>,
-	fsl=\E[0$}, home=\E[H, hpa=\E[%p1%dG$<40>, ht=^I, hts=\EH,
-	ich=\E[%p1%d@$<5>, il=\E[%p1%dL$<5>, il1=\E[L$<5>,
-	ind=\ED$<5>, indn=\E[%p1%dE$<5>, invis=\E[8m,
+	dl=\E[%p1%dM$<5>, dl1=\E[M$<5>, ech=\E[%p1%dX$<5>,
+	ed=\E[0J, el=\E[0K$<5>, el1=\E[1K$<5>, home=\E[H,
+	hpa=\E[%p1%dG$<40>, ht=^I, hts=\EH, ich=\E[%p1%d@$<5>,
+	il=\E[%p1%dL$<5>, il1=\E[L$<5>, ind=\ED$<5>,
+	indn=\E[%p1%dE$<5>,
 	is2=\E[!p\E[?7;19;67h\E[?1;3;4l\E[1;0%w\E(B\E)0\017\E[2J\E[1
 	    ;1H\E>$<200>,
 	kbs=^H, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
@@ -18867,7 +19318,7 @@ ncr260vt300an|NCR 2900_260 vt300 with ansi kybd,
 	kf29=\E[4~, kf30=\E[5~, kf31=\E[6~, kf32=\E[7~, kf33=\E[8~,
 	kf34=\E[9~, kf35=\E[10~, kf5=\E[M, kf6=\E[17~, kf7=\E[18~,
 	kf8=\E[19~, kf9=\E[20~, khlp=\E[28~, krdo=\E[29~, mc0=\E[i,
-	mc4=\E[4i, mc5=\E[5i, nel=\EE, rc=\E8, rev=\E[7m, ri=\EM$<5>,
+	mc4=\E[4i, mc5=\E[5i, nel=\EE, rc=\E8, ri=\EM$<5>,
 	rmacs=\017$<20>, rmam=\E[?7l, rmir=\E[4l, rmkx=\E[?1l\E>,
 	rmso=\E[27m, rmul=\E[24m,
 	rs2=\E[!p\E[?7;19;67h\E[?1;3;4l\E[1;0%w\E(B\E)0\017\E[2J\E[1
@@ -18876,10 +19327,12 @@ ncr260vt300an|NCR 2900_260 vt300 with ansi kybd,
 	sgr=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5
 	    %;%?%p7%t;8%;m%?%p9%t\016%e\017%;$<20>,
 	sgr0=\E[0m\017$<20>, smacs=\016$<20>, smam=\E[?7h,
-	smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m,
-	tbc=\E[3g, tsl=\E[2$~\E[1$}, vpa=\E[%p1%dd$<40>,
+	smir=\E[4h, smkx=\E[?1h\E=, tbc=\E[3g,
+	vpa=\E[%p1%dd$<40>, use=ansi+sgrbold, use=decid+cpr,
 	use=vt220+vtedit, use=vt220+cvis, use=vt220+keypad,
-ncr260vt300wan|NCR 2900_260 vt300 wide mode ansi kybd,
+	use=ncr260vt+sl,
+
+ncr260vt300wan|NCR 2900/260 VT300 wide mode ANSI keyboard,
 	cols#132,
 	cup=\E[%i%p1%d;%p2%dH$<30>,
 	is2=\E[!p\E[?3;7;19;67h\E[?4l\E[1;0%w\E(B\E)0\017\E[2J\E[1;1
@@ -18887,13 +19340,12 @@ ncr260vt300wan|NCR 2900_260 vt300 wide mode ansi kybd,
 	rs2=\E[!p\E[?3;7;19;67h\E[?4l\E[1;0%w\E(B\E)0\017\E[2J\E[1;1
 	    H$<200>,
 	use=ncr260vt300an,
-ncr260vt300pp|NCR 2900_260 vt300 with pc+ kybd,
+ncr260vt300pp|NCR 2900/260 VT300 with PC+ keyboard,
 	ka1=\E[H, ka3=\EOu, kb2=\E[V, kc3=\E[U, kcub1=\E[D,
 	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kdch1=\E[4~,
-	kend=\E[1~, khome=\E[H, kich1=\E[2~, knp=\E[6~, kpp=\E[5~,
-	lf1=pf1, lf2=pf2, lf3=pf3, lf4=pf4, rmkx=\E>, smkx=\E=,
-	use=ncr260vt300an,
-NCR260VT300WPP|ncr260vt300wpp|NCR 2900_260 vt300 wide mode pc+  kybd,
+	kend=\E[1~, khome=\E[H, lf1=pf1, lf2=pf2, lf3=pf3, lf4=pf4,
+	rmkx=\E>, smkx=\E=, use=ncr260vt300an,
+ncr260vt300wpp|NCR260VT300WPP|NCR 2900/260 VT300 wide mode PC+  keyboard,
 	cols#132,
 	cup=\E[%i%p1%d;%p2%dH$<30>,
 	is2=\E[!p\E[?3;7;19;67h\E[?1;4l\E[1;0%w\E(B\E)0\017\E[2J\E[1
@@ -18915,17 +19367,17 @@ NCR260VT300WPP|ncr260vt300wpp|NCR 2900_260 vt300 wide mode pc+  kybd,
 #	    if the 'pairs' capability is defined. Un-Comment the 'pairs'
 #	    capability and recompile if you wish to have it included.
 #
-ncr260wy325pp|NCR 2900_260 wyse 325,
-	am, bw, hs, km, mc5i, mir, msgr, xon,
+ncr260wy325pp|NCR 2900/260 Wyse 325,
+	am, bw, km, mc5i, mir, msgr, xon,
 	colors#16, cols#80, lines#24, ncv#33, nlab#32,
-	acsc=07a?h;j5k3l2m1n8q\:t4u9v=w0x6, bel=^G, blink=\EG2,
+	acsc=07a?h;j5k3l2m1n8q:t4u9v=w0x6, bel=^G, blink=\EG2,
 	cbt=\EI, civis=\E`0, clear=\E*$<10>, cnorm=\E`1, cr=\r,
 	cub1=\010$<5>, cud1=\n$<5>, cuf1=\014$<5>,
 	cup=\E=%p1%{32}%+%c%p2%{32}%+%c$<10>, cuu1=\013$<5>,
-	cvvis=\E`5, dch1=\EW$<50>, dl1=\ER$<5>, dsl=\E`c,
-	ed=\Ey$<5>, el=\Et$<5>, fsl=\r, home=\036$<5>, ht=^I,
-	hts=\E1, il1=\EE$<5>, ind=\n$<5>, invis=\EG1,
-	is2=\Ee6\Ed/\Ee1\Ed*\Er\EO\E`1\E`\:\E`@\E~!\E"\Ee4\Ex@\E`9
+	cvvis=\E`5, dch1=\EW$<50>, dl1=\ER$<5>, ed=\Ey$<5>,
+	el=\Et$<5>, home=\036$<5>, ht=^I, hts=\E1, il1=\EE$<5>,
+	ind=\n$<5>, invis=\EG1,
+	is2=\Ee6\Ed/\Ee1\Ed*\Er\EO\E`1\E`:\E`@\E~!\E"\Ee4\Ex@\E`9
 	    \Ee7$<100>,
 	kDC=\ER, kEND=\EY, kHOM=\E{, kNXT=\EK, kPRT=\E7, kPRV=\EJ,
 	kRIT=^L, ka1=^^, kb2=\EJ, kbs=^H, kc1=\ET, kc3=\EK, kcbt=\EI,
@@ -18941,7 +19393,7 @@ ncr260wy325pp|NCR 2900_260 wyse 325,
 	mrcup=\Ew@%p1%{48}%+%c%p2%{32}%+%c%p3%{32}%+%c$<10>,
 	nel=\037$<5>, rev=\EG4, ri=\Ej$<5>, rmacs=\EH\003\EcB0,
 	rmam=\Ed., rmir=\Er, rmso=\EG0, rmul=\EG0, rmxon=\Ec20,
-	rs2=\Ee6\Ed/\Ee1\Ed*\Er\EO\E`1\E`\:\E`@\E~!\E"\Ee4\Ex@\E`9
+	rs2=\Ee6\Ed/\Ee1\Ed*\Er\EO\E`1\E`:\E`@\E~!\E"\Ee4\Ex@\E`9
 	    \Ee7$<100>,
 	setb=\s,
 	setf=%?%p1%{0}%=%t%{49}%e%p1%{1}%=%t%{50}%e%p1%{2}%=%t%{51}
@@ -18952,8 +19404,8 @@ ncr260wy325pp|NCR 2900_260 wyse 325,
 	     %t%{63}%e%p1%{15}%=%t%{56}%;\Edy%c11$<100>,
 	sgr0=\EG0\EcB0\EcD$<15>, smacs=\EH\002\EcB1, smam=\Ed/,
 	smir=\Eq, smso=\EGt, smul=\EG8, smxon=\Ec21, tbc=\E0,
-	tsl=\EF,
-ncr260wy325wpp|NCR 2900_260 wyse 325 wide mode,
+	use=ncr260vp+sl,
+ncr260wy325wpp|NCR 2900/260 Wyse 325 wide mode,
 	cols#132,
 	cup=\Ea%i%p1%dR%p2%dC$<30>,
 	is2=\Ee6\Ed/\Ee1\Ed*\Er\EO\E`1\E`;\E`@\E~!\E"\Ee4\Ex@\E`9
@@ -18977,33 +19429,16 @@ ncr260wy325wpp|NCR 2900_260 wyse 325 wide mode,
 #	    with the 'pairs' capability defined as below.  If you wish to
 #	    have it included, Un-comment it and recompile (using 'tic').
 #
-ncr260wy350pp|NCR 2900_260 wyse 350,
-	am, bw, hs, km, mc5i, mir, msgr, xon,
-	colors#16, cols#80, lines#24, ncv#33, nlab#32, pairs#16, xmc#1,
-	acsc=07a?h;j5k3l2m1n8q\:t4u9v=w0x6, bel=^G, blink=\EG2,
-	cbt=\EI, civis=\E`0, clear=\E+$<20>, cnorm=\E`1, cr=\r,
-	cub1=\010$<5>, cud1=\n$<5>, cuf1=\014$<5>,
-	cup=\E=%p1%{32}%+%c%p2%{32}%+%c$<40>, cuu1=\013$<5>,
-	cvvis=\E`5, dch1=\EW$<50>, dim=\EGp, dl1=\ER$<5>, dsl=\E`c,
-	ed=\Ey$<5>, el=\Et$<5>, fsl=\r, home=\036$<10>, ht=^I,
-	hts=\E1, il1=\EE$<5>, ind=\n$<5>, invis=\EG1,
-	is2=\Ee6\Ed/\Ee1\Ed*\Er\EO\E`1\E`\:\E`@\E~!\E"\Ee4\Ex@\E`9
+ncr260wy350pp|NCR 2900/260 Wyse 350,
+	colors#16, ncv#33, pairs#16,
+	acsc=07a?h;j5k3l2m1n8q:t4u9v=w0x6, cbt=\EI,
+	cup=\E=%p1%{32}%+%c%p2%{32}%+%c$<40>, ed=\Ey$<5>,
+	el=\Et$<5>, ht=^I, hts=\E1,
+	is2=\Ee6\Ed/\Ee1\Ed*\Er\EO\E`1\E`:\E`@\E~!\E"\Ee4\Ex@\E`9
 	    \Ee7$<100>,
-	kDC=\ER, kEND=\EY, kHOM=\E{, kPRT=\E7, kRIT=^L, ka1=^^, kbs=^H,
-	kc1=\ET, kc3=\EK, kcbt=\EI, kcub1=^H, kcud1=\n, kcuf1=^L,
-	kcuu1=^K, kdch1=\EW, kend=\ET, kf1=^A@\r, kf10=^AI\r,
-	kf11=^AJ\r, kf12=^AK\r, kf13=^AL\r, kf14=^AM\r, kf15=^AN\r,
-	kf16=^AO\r, kf17=^A`\r, kf18=^Aa\r, kf19=^Ab\r, kf2=^AA\r,
-	kf20=^Ac\r, kf21=^Ad\r, kf22=^Ae\r, kf23=^Af\r, kf24=^Ag\r,
-	kf25=^Ah\r, kf26=^Ai\r, kf27=^Aj\r, kf28=^Ak\r, kf29=^Al\r,
-	kf3=^AB\r, kf30=^Am\r, kf31=^An\r, kf32=^Ao\r, kf4=^AC\r,
-	kf5=^AD\r, kf6=^AE\r, kf7=^AF\r, kf8=^AG\r, kf9=^AH\r,
-	khome=^^, kich1=\Eq, knp=\EK, kpp=\EJ, kprt=\EP,
-	mc0=\EP$<10>, mc4=^T, mc5=^R,
 	mrcup=\Ew@%p1%{48}%+%c%p2%{32}%+%c%p3%{32}%+%c$<20>,
-	nel=\037$<5>, rev=\EG4, ri=\Ej$<5>, rmacs=\EH\003\EcB0,
-	rmam=\Ed., rmir=\Er, rmso=\EG0, rmul=\EG0, rmxon=\Ec20,
-	rs2=\Ee6\Ed/\Ee1\Ed*\Er\EO\E`1\E`\:\E`@\E~!\E"\Ee4\Ex@\E`9
+	rmacs=\EH\003\EcB0,
+	rs2=\Ee6\Ed/\Ee1\Ed*\Er\EO\E`1\E`:\E`@\E~!\E"\Ee4\Ex@\E`9
 	    \Ee7$<100>,
 	setb=\s,
 	setf=%?%p1%{0}%=%t%{49}%e%p1%{1}%=%t%{50}%e%p1%{2}%=%t%{51}
@@ -19012,10 +19447,9 @@ ncr260wy350pp|NCR 2900_260 wyse 350,
 	     %e%p1%{9}%=%t%{98}%e%p1%{10}%=%t%{99}%e%p1%{11}%=%t
 	     %{101}%e%p1%{12}%=%t%{106}%e%p1%{13}%=%t%{110}%e%p1
 	     %{14}%=%t%{111}%e%p1%{15}%=%t%{56}%;\Em0%c$<100>,
-	sgr0=\EG0\EH\003\EcD, smacs=\EH\002\EcB1, smam=\Ed/,
-	smir=\Eq, smso=\EGt, smul=\EG8, smxon=\Ec21, tbc=\E0,
-	tsl=\EF,
-ncr260wy350wpp|NCR 2900_260 wyse 350 wide mode,
+	sgr0=\EG0\EH\003\EcD, smacs=\EH\002\EcB1, tbc=\E0,
+	use=ncr260vp+sl, use=ncr160wy50+pp,
+ncr260wy350wpp|NCR 2900/260 Wyse 350 wide mode,
 	cols#132,
 	cup=\Ea%i%p1%dR%p2%dC$<30>,
 	is2=\Ee6\Ed/\Ee1\Ed*\Er\EO\E`1\E`;\E`@\E~!\E"\Ee4\Ex@\E`9
@@ -19033,18 +19467,17 @@ ncr260wy350wpp|NCR 2900_260 wyse 350 wide mode,
 # restored if needed.
 # (ncr260wy50+pp: originally contained commented-out
 # <acsc=j5k3l2m1n8q:t4u9v=w0x6>, as well as the commented-out one there -- esr)
-ncr260wy50+pp|NCR 2900_260 wyse 50+,
-	am, bw, hs, km, mc5i, mir, msgr, xon,
+ncr260wy50+pp|NCR 2900/260 Wyse 50+,
+	am, bw, km, mc5i, mir, msgr, xon,
 	cols#80, lines#24, nlab#32, xmc#1,
 	acsc=0wa_h[jukslrmqnxqzttuyv]wpxv, bel=^G, blink=\EG2,
 	cbt=\EI$<5>, civis=\E`0, clear=\E+$<20>, cnorm=\E`1, cr=\r,
 	cub1=\010$<5>, cud1=\n$<5>, cuf1=\014$<5>,
 	cup=\E=%p1%{32}%+%c%p2%{32}%+%c$<30>, cuu1=\013$<5>,
-	cvvis=\E`5, dch1=\EW$<50>, dim=\EGp, dl1=\ER$<5>, dsl=\E`c,
-	ed=\EY$<5>, el=\ET$<5>, fsl=\r, home=\036$<10>,
-	ht=\011$<5>, hts=\E1$<5>, il1=\EE$<5>, ind=\n$<5>,
-	invis=\EG1,
-	is2=\Ee6\E~"$<100>\E+\Ed/\Ee1\Ed*\Er\EO\E`1\E`\:\E`@\E~!\E"
+	cvvis=\E`5, dch1=\EW$<50>, dim=\EGp, dl1=\ER$<5>,
+	ed=\EY$<5>, el=\ET$<5>, home=\036$<10>, ht=\011$<5>,
+	hts=\E1$<5>, il1=\EE$<5>, ind=\n$<5>, invis=\EG1,
+	is2=\Ee6\E~"$<100>\E+\Ed/\Ee1\Ed*\Er\EO\E`1\E`:\E`@\E~!\E"
 	    \Ee4\Ex@\E`9\Ee7$<100>,
 	kDC=\ER, kEND=\EY, kHOM=\E{, kPRT=\E7, kRIT=^L, ka1=^^, kbs=^H,
 	kc1=\ET, kc3=\EK, kcbt=\EI, kcub1=^H, kcud1=\n, kcuf1=^L,
@@ -19060,11 +19493,12 @@ ncr260wy50+pp|NCR 2900_260 wyse 50+,
 	mrcup=\Ew@%p1%{48}%+%c%p2%{32}%+%c%p3%{32}%+%c$<10>,
 	nel=\037$<5>, rev=\EG4, ri=\Ej$<5>, rmacs=\EH^C, rmam=\Ed.,
 	rmir=\Er, rmso=\EG0, rmul=\EG0, rmxon=\Ec20,
-	rs2=\Ee6\E~"$<100>\E+\Ed/\Ee1\Ed*\Er\EO\E`1\E`\:\E`@\E~!\E"
+	rs2=\Ee6\E~"$<100>\E+\Ed/\Ee1\Ed*\Er\EO\E`1\E`:\E`@\E~!\E"
 	    \Ee4\Ex@\E`9\Ee7$<100>,
 	sgr0=\EG0\EH\003$<15>, smacs=\EH^B, smam=\Ed/, smir=\Eq,
-	smso=\EGt, smul=\EG8, smxon=\Ec21, tbc=\E0$<5>, tsl=\EF,
-ncr260wy50+wpp|NCR 2900_260 wyse 50+ wide mode,
+	smso=\EGt, smul=\EG8, smxon=\Ec21, tbc=\E0$<5>,
+	use=ncr260vp+sl,
+ncr260wy50+wpp|NCR 2900/260 Wyse 50+ wide mode,
 	cols#132,
 	cup=\Ea%i%p1%dR%p2%dC$<30>,
 	is2=\Ee6\E~"$<100>\E+\Ed/\Ee1\Ed*\Er\EO\E`1\E`;\E`@\E~!\E"
@@ -19072,18 +19506,17 @@ ncr260wy50+wpp|NCR 2900_260 wyse 50+ wide mode,
 	rs2=\Ee6\E~"$<100>\E+\Ed/\Ee1\Ed*\Er\EO\E`1\E`;\E`@\E~!\E"
 	    \Ee4\Ex@\E`9\Ee7$<200>,
 	use=ncr260wy50+pp,
-ncr260wy60pp|NCR 2900_260 wyse 60,
-	am, bw, hs, km, mc5i, mir, msgr, xon,
+ncr260wy60pp|NCR 2900/260 Wyse 60,
+	am, bw, km, mc5i, mir, msgr, xon,
 	cols#80, lines#24, nlab#32,
-	acsc=07a?h;j5k3l2m1n8q\:t4u9v=w0x6, bel=^G, blink=\EG2,
+	acsc=07a?h;j5k3l2m1n8q:t4u9v=w0x6, bel=^G, blink=\EG2,
 	cbt=\EI$<15>, civis=\E`0, clear=\E*$<100>, cnorm=\E`1,
 	cr=\r, cub1=\010$<5>, cud1=\n$<5>, cuf1=\014$<5>,
 	cup=\E=%p1%{32}%+%c%p2%{32}%+%c$<10>, cuu1=\013$<5>,
-	cvvis=\E`5, dch1=\EW$<50>, dl1=\ER$<5>, dsl=\E`c,
-	ed=\Ey$<5>, el=\Et$<5>, fsl=\r, home=\036$<25>,
-	ht=\011$<15>, hts=\E1$<15>, il1=\EE$<5>, ind=\n$<5>,
-	invis=\EG1,
-	is2=\Ee6\E~4$<100>\E+\Ed/\Ee1\Ed*\Er\EO\E`1\E`\:\E`@\E~!\E"
+	cvvis=\E`5, dch1=\EW$<50>, dl1=\ER$<5>, ed=\Ey$<5>,
+	el=\Et$<5>, home=\036$<25>, ht=\011$<15>, hts=\E1$<15>,
+	il1=\EE$<5>, ind=\n$<5>, invis=\EG1,
+	is2=\Ee6\E~4$<100>\E+\Ed/\Ee1\Ed*\Er\EO\E`1\E`:\E`@\E~!\E"
 	    \Ee4\Ex@\E`9\Ee7$<100>,
 	kDC=\ER, kEND=\EY, kHOM=\E{, kNXT=\EK, kPRT=\E7, kPRV=\EJ,
 	kRIT=^L, ka1=^^, kb2=\EJ, kbs=^H, kc1=\ET, kc3=\EK,
@@ -19099,12 +19532,12 @@ ncr260wy60pp|NCR 2900_260 wyse 60,
 	mrcup=\Ew@%p1%{48}%+%c%p2%{32}%+%c%p3%{32}%+%c$<30>,
 	nel=\037$<5>, rev=\EG4, ri=\Ej$<5>, rmacs=\EH^C, rmam=\Ed.,
 	rmir=\Er, rmso=\EG0, rmul=\EG0, rmxon=\Ec20,
-	rs2=\Ee6\E~4$<100>\E+\Ed/\Ee1\Ed*\Er\EO\E`1\E`\:\E`@\E~!\E"
+	rs2=\Ee6\E~4$<100>\E+\Ed/\Ee1\Ed*\Er\EO\E`1\E`:\E`@\E~!\E"
 	    \Ee4\Ex@\E`9\Ee7$<100>,
 	sgr0=\EG0\EcB0\EcD$<15>, smacs=\EH^B, smam=\Ed/,
 	smir=\Eq, smso=\EGt, smul=\EG8, smxon=\Ec21, tbc=\E0$<15>,
-	tsl=\EF,
-ncr260wy60wpp|NCR 2900_260 wyse 60 wide mode,
+	use=ncr260vp+sl,
+ncr260wy60wpp|NCR 2900/260 Wyse 60 wide mode,
 	cols#132,
 	cup=\Ea%i%p1%dR%p2%dC$<30>,
 	is2=\Ee6\E~4$<100>\E+\Ed/\Ee1\Ed*\Er\EO\E`1\E`;\E`@\E~!\E"
@@ -19112,63 +19545,61 @@ ncr260wy60wpp|NCR 2900_260 wyse 60 wide mode,
 	rs2=\Ee6\E~4$<100>\E+\Ed/\Ee1\Ed*\Er\EO\E`1\E`;\E`@\E~!\E"
 	    \Ee4\Ex@\E`9\Ee7$<100>,
 	use=ncr260wy60pp,
-ncr160vppp|NCR 2900_160 viewpoint,
+ncr160vppp|NCR 2900/160 viewpoint,
 	use=ncr260vppp,
-ncr160vpwpp|NCR 2900_160 viewpoint wide mode,
+ncr160vpwpp|NCR 2900/160 viewpoint wide mode,
 	use=ncr260vpwpp,
-ncr160vt100an|NCR 2900_160 vt100 with ansi kybd,
+ncr160vt100an|NCR 2900/160 VT100 with ANSI keyboard,
 	use=ncr260vt100an,
-ncr160vt100pp|NCR 2900_160 vt100 with PC+ kybd,
+ncr160vt100pp|NCR 2900/160 VT100 with PC+  keyboard,
 	use=ncr260vt100pp,
-ncr160vt100wan|NCR 2900_160 vt100 wide mode ansi kybd,
+ncr160vt100wan|NCR 2900/160 VT100 wide mode ANSI keyboard,
 	use=ncr260vt100wan,
-ncr160vt100wpp|NCR 2900_160 vt100 wide mode pc+  kybd,
+ncr160vt100wpp|NCR 2900/160 VT100 wide mode PC+  keyboard,
 	use=ncr260vt100wpp,
-ncr160vt200an|NCR 2900_160 vt200 with ansi kybd,
+ncr160vt200an|NCR 2900/160 VT200 with ANSI keyboard,
 	use=ncr260vt200an,
-ncr160vt200pp|NCR 2900_160 vt200 with pc+ kybd,
+ncr160vt200pp|NCR 2900/160 VT200 with PC+  keyboard,
 	use=ncr260vt200pp,
-ncr160vt200wan|NCR 2900_160 vt200 wide mode ansi kybd,
+ncr160vt200wan|NCR 2900/160 VT200 wide mode ANSI keyboard,
 	use=ncr260vt200wan,
-ncr160vt200wpp|NCR 2900_160 vt200 wide mode pc+  kybd,
+ncr160vt200wpp|NCR 2900/160 VT200 wide mode PC+  keyboard,
 	use=ncr260vt200wpp,
-ncr160vt300an|NCR 2900_160 vt300 with ansi kybd,
+ncr160vt300an|NCR 2900/160 VT300 with ANSI keyboard,
 	use=ncr260vt300an,
-ncr160vt300pp|NCR 2900_160 vt300 with pc+ kybd,
+ncr160vt300pp|NCR 2900/160 VT300 with PC+ keyboard,
 	use=ncr260vt300pp,
-ncr160vt300wan|NCR 2900_160 vt300 wide mode ansi kybd,
+ncr160vt300wan|NCR 2900/160 VT300 wide mode ANSI keyboard,
 	use=ncr260vt300wan,
-ncr160vt300wpp|NCR 2900_160 vt300 wide mode pc+  kybd,
+ncr160vt300wpp|NCR 2900/160 VT300 wide mode PC+  keyboard,
 	use=ncr260vt300wpp,
-ncr160wy50+pp|NCR 2900_160 wyse 50+,
+ncr160wy50+pp|NCR 2900/160 Wyse 50+,
 	use=ncr260wy50+pp,
-ncr160wy50+wpp|NCR 2900_160 wyse 50+ wide mode,
+ncr160wy50+wpp|NCR 2900/160 Wyse 50+ wide mode,
 	use=ncr260wy50+wpp,
-ncr160wy60pp|NCR 2900_160 wyse 60,
+ncr160wy60pp|NCR 2900/160 Wyse 60,
 	use=ncr260wy60pp,
-ncr160wy60wpp|NCR 2900_160 wyse 60 wide mode,
+ncr160wy60wpp|NCR 2900/160 Wyse 60 wide mode,
 	use=ncr260wy60wpp,
-ncrvt100an|ncrvt100pp|NCR vt100 for the 2900 terminal,
-	am, hs, mc5i, mir, msgr, xon,
-	cols#80, it#8, lines#24, nlab#32,
+ncrvt100an|ncrvt100pp|NCR VT100 for the 2900 terminal,
+	hs, mc5i, mir, xon,
+	nlab#32,
 	acsc=``aaffgghhiijjkkllmmnnqqttuuvvwwxxyyzz~~,
-	bel=^G, blink=\E[5m$<30>, bold=\E[1m$<30>,
-	clear=\E[2J\E[1;1H$<300>, cr=\r,
+	blink=\E[5m$<30>, bold=\E[1m$<30>,
+	clear=\E[2J\E[1;1H$<300>,
 	csr=\E[%i%p1%d;%p2%dr$<100>, cub=\E[%p1%dD$<30>,
 	cub1=\E[D$<2>, cud=\E[%p1%dB$<30>, cud1=\E[B$<2>,
-	cuf=\E[%p1%dC$<30>, cuf1=\E[C$<2>,
-	cup=\E[%i%p1%d;%p2%dH$<100>, cuu=\E[%p1%dA$<30>,
-	cuu1=\E[A$<2>, dch=\E[%p1%dP$<40>, dch1=\E[1P$<10>,
-	dl=\E[%p1%dM$<70>, dl1=\E[M$<40>, dsl=\E[31l$<25>,
-	ed=\E[0J$<300>, el=\E[0K$<30>, el1=\E[1K$<30>,
-	enacs=\E(B\E)0$<40>, fsl=1$<10>, home=\E[H$<2>$<80>,
-	ht=^I, hts=\EH, il=\E[%p1%dL$<80>, il1=\E[B\E[L$<80>,
-	ind=\ED,
+	cuf=\E[%p1%dC$<30>, cup=\E[%i%p1%d;%p2%dH$<100>,
+	cuu=\E[%p1%dA$<30>, dch=\E[%p1%dP$<40>,
+	dch1=\E[1P$<10>, dl=\E[%p1%dM$<70>, dl1=\E[M$<40>,
+	dsl=\E[31l$<25>, ed=\E[0J$<300>, el=\E[0K$<30>,
+	el1=\E[1K$<30>, enacs=\E(B\E)0$<40>, fsl=1$<10>,
+	home=\E[H$<2>$<80>, il=\E[%p1%dL$<80>,
+	il1=\E[B\E[L$<80>, ind=\ED,
 	is2=\E[12h\E[?10l\E%/0n\E[P\031\E[?3l\E(B\E)0$<200>,
-	kLFT=\E[D, kRIT=\E[C, ka1=\E[H, kbs=^H, kcub1=\E[D,
-	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kent=\r, kf1=\EOP,
-	kf2=\EOQ, kf3=\EOR, kf4=\EOS, mc0=\E[i$<100>, nel=\EE,
-	rc=\E8, rev=\E[7m$<30>, ri=\EM$<50>, rmacs=\017$<90>,
+	kLFT=\E[D, kRIT=\E[C, ka1=\E[H, kent=\r, kf1=\EOP, kf2=\EOQ,
+	kf3=\EOR, kf4=\EOS, mc0=\E[i$<100>, nel=\EE, rc=\E8,
+	rev=\E[7m$<30>, ri=\EM$<50>, rmacs=\017$<90>,
 	rmir=\E[4l$<80>, rmso=\E[0m$<30>, rmul=\E[0m$<30>,
 	rs2=\Ec\E[12;31h\E[?3;4;5;10l\E[?6;7;19;25h\E[33;34l\E[0m\E(
 	    B\E)0\E%/0n\E[P\031$<200>,
@@ -19177,7 +19608,7 @@ ncrvt100an|ncrvt100pp|NCR vt100 for the 2900 terminal,
 	    %p3%|%t;7%;%?%p4%t;5%;m$<120>,
 	sgr0=\017\E[0m$<120>, smacs=\016$<90>, smir=\E[4h$<80>,
 	smso=\E[7m$<30>, smul=\E[4m$<30>, tbc=\E[3g$<40>,
-	tsl=\E[>+1$<70>,
+	tsl=\E[>+1$<70>, use=decid+cpr, use=vt100+4bsd,
 ncrvt100wan|NCRVT100WPP|ncrvt100wpp|NCR VT100 emulation of the 2900 terminal,
 	cols#132,
 	is2=\E[12h\E[?10l\E%/0n\E[P\031\E[?3h\E(B\E)0$<200>,
@@ -19240,7 +19671,7 @@ ncrvt100wan|NCRVT100WPP|ncrvt100wpp|NCR VT100 emulation of the 2900 terminal,
 #		P4 <==> Blink attribute parameter
 #		P5 <==> Dim attribute parameter
 # From <root@goliath.un.atlantaga.NCR.COM>, init string hacked by SCO.
-ncr7900i|ncr7900|n7900|ncr 7900 model 1,
+ncr7900i|ncr7900|n7900|NCR 7900 model 1,
 	am, bw, ul,
 	cols#80, lines#24, xmc#1,
 	bel=^G, blink=\E0B, clear=^L, cr=\r, cub1=^H, cud1=\n, cuf1=^F,
@@ -19251,21 +19682,20 @@ ncr7900i|ncr7900|n7900|ncr 7900 model 1,
 	sgr=\E0%p5%{64}%+%p4%{2}%*%+%p3%{16}%*%+%p2%{32}%*%+%p1%{17}
 	    %*%+%c,
 	sgr0=\E0@, smso=\E0Q, smul=\E0`,
-ncr7900iv|ncr 7900 model 4,
+ncr7900iv|NCR 7900 model 4,
 	am, bw, eslok, hs,
 	cols#80, lines#24,
 	bel=^G, clear=^L, cr=\r, cub1=^H, cud1=\n,
 	cup=\013%p1%{64}%+%c\E\005%p2%02d, dl1=\E^O, dsl=\Ey1,
 	fsl=\Ek\Ey5, home=\013@\E^E00, il1=\E^N, ind=\n, kbs=^H,
-	kcub1=\ED, kcud1=\EB, kcuf1=\EC, kcuu1=\EA, kf1=\ES, kf2=\ET,
-	kf3=\EU, kf4=\EV, kf5=\EW, kf6=\EP, kf7=\EQ, kf8=\ER,
-	khome=\EH, lf6=blue, lf7=red, lf8=white, nel=\r\n,
-	tsl=\Ej\Ex5\Ex1\EY8%p1%{32}%+%c\Eo,
+	kf1=\ES, kf2=\ET, kf3=\EU, kf4=\EV, kf5=\EW, kf6=\EP, kf7=\EQ,
+	kf8=\ER, khome=\EH, lf6=blue, lf7=red, lf8=white, nel=\r\n,
+	tsl=\Ej\Ex5\Ex1\EY8%p1%{32}%+%c\Eo, use=vt52+arrows,
 # Warning: This terminal will lock out the keyboard when it receives a CTRL-D.
 #	   The user can enter a CTRL-B to get out of this locked state.
 # In <hpa>, we want to output the character given by the formula:
 #		((col / 10) * 16) + (col % 10)		where "col" is "p1"
-ncr7901|ncr 7901 model,
+ncr7901|NCR 7901 model,
 	am, bw, ul,
 	cols#80, lines#24,
 	bel=^G, blink=\E0B, civis=^W, clear=^L, cnorm=^X, cr=\r,
@@ -19297,7 +19727,7 @@ ncr7901|ncr 7901 model,
 
 # NDR 9500
 # Manufactured in the early/mid eighties, behaves almost the same as a
-# Televideo 950.  Take a 950, change its cabinet for a more 80s-ish one (but
+# TeleVideo 950.  Take a 950, change its cabinet for a more 80s-ish one (but
 # keep the same keyboard layout), add an optional 25-line mode, replace the DIP
 # switches with a menu and remove the "lock line" feature (ESC !  1 and ESC !
 # 2), here is the NDR 9500.  Even the line-lock, albeit disabled, is
@@ -19344,7 +19774,7 @@ ndr9500-mc|NDR 9500 with magic cookies (enables underline inverse video invisibl
 	blink=\EG2, invis=\EG1, rev=\EG4, rmso=\EG0, rmul=\EG0,
 	sgr=\E%%\E(%?%p5%p8%|%t\E)%;%?%p9%t\E$%;\EG%{48}%?%p7%t%{1}
 	    %+%;%?%p4%t%{2}%+%;%?%p3%p1%|%t%{4}%+%;%?%p2%t%{8}%+%;%c,
-	sgr0=\EG0\E%%\E(, smso=\EG4, smul=\EG8, use=ndr9500,
+	smso=\EG4, smul=\EG8, use=ndr9500,
 
 ndr9500-25-mc|NDR 500 with 25 lines and magic cookies,
 	lines#25, use=ndr9500-mc,
@@ -19362,20 +19792,20 @@ ndr9500-25-mc-nl|NDR 9500 with 25 lines and magic cookies and no status line,
 # These are official terminfo entries from within Perkin-Elmer.
 #
 
-bantam|pe550|pe6100|perkin elmer 550,
+bantam|pe550|pe6100|Perkin Elmer 550,
 	OTbs,
 	cols#80, lines#24,
 	bel=^G, clear=\EK$<20>, cr=\r, cub1=^H, cud1=\n, cuf1=\EC,
 	cup=\EX%p1%{32}%+%c\EY%p2%{32}%+%c, cuu1=\EA,
 	el=\EI$<20>, home=\EH, ind=\n, ll=\EH\EA,
-fox|pe1100|perkin elmer 1100,
+fox|pe1100|Perkin Elmer 1100,
 	OTbs, am,
 	cols#80, lines#24,
 	bel=^G, clear=\EH\EJ$<132>, cr=\r, cub1=^H, cud1=\n,
 	cuf1=\EC, cup=\EX%p1%{32}%+%c\EY%p2%{32}%+%c, cuu1=\EA,
 	ed=\EJ$<5.5*>, el=\EI, flash=\020\002$<200/>\020\003,
 	home=\EH, hts=\E1, ind=\n, ll=\EH\EA, tbc=\E3,
-owl|pe1200|perkin elmer 1200,
+owl|pe1200|Perkin Elmer 1200,
 	OTbs, am, in,
 	cols#80, lines#24,
 	bel=^G, clear=\EH\EJ$<132>, cr=\r, cub1=^H, cud1=\n,
@@ -19386,7 +19816,7 @@ owl|pe1200|perkin elmer 1200,
 	kbs=^H, kf0=\ERJ, kf1=\ERA, kf2=\ERB, kf3=\ERC, kf4=\ERD,
 	kf5=\ERE, kf6=\ERF, kf7=\ERG, kf8=\ERH, kf9=\ERI, ll=\EH\EA,
 	rmso=\E!\0, sgr0=\E!\0, smso=\E!^H, tbc=\E3,
-pe1251|pe6300|pe6312|perkin elmer 1251,
+pe1251|pe6300|pe6312|Perkin Elmer 1251,
 	am,
 	cols#80, it#8, lines#24, pb#300, vt#8, xmc#1,
 	bel=^G, clear=\EK$<332>, cr=\r, cub1=\ED, cud1=\EB, cuf1=\EC,
@@ -19397,7 +19827,7 @@ pe1251|pe6300|pe6312|perkin elmer 1251,
 # (pe7000m: this had
 #	rmul=\E!\0, smul=\E!\040,
 # which is probably wrong, it collides with kf0
-pe7000m|perkin elmer 7000 series monochrome monitor,
+pe7000m|Perkin Elmer 7000 series monochrome monitor,
 	am,
 	cols#80, lines#24,
 	bel=^G, cbt=\E!Y, clear=\EK, cr=\r, cub1=\ED, cud1=\EB,
@@ -19408,7 +19838,7 @@ pe7000m|perkin elmer 7000 series monochrome monitor,
 	kf10=\E!\n, kf2=\E!^B, kf3=\E!^C, kf4=\E!^D, kf5=\E!^E,
 	kf6=\E!^F, kf7=\E!^G, kf8=\E!^H, kf9=\E!^I, khome=\E!S,
 	ll=\ES7\s, ri=\ER,
-pe7000c|perkin elmer 7000 series colour monitor,
+pe7000c|Perkin Elmer 7000 series colour monitor,
 	is1=\E!\0\EW  7o\Egf\Eb0\Ec7\ES7\s, rmso=\Eb0,
 	rmul=\E!\0, smso=\Eb2, smul=\E!\s, use=pe7000m,
 
@@ -19419,26 +19849,25 @@ pe7000c|perkin elmer 7000 series colour monitor,
 
 # This entry is for the Sperry UTS30 terminal running the TTY
 # utility under control of CP/M Plus 1R1. The functionality
-# provided is comparable to the DEC vt100.
+# provided is comparable to the DEC VT100.
 # (uts30: I added <rmam>/<smam> based on the init string -- esr)
-uts30|sperry uts30 with cp/m@1R1,
+uts30|Sperry UTS30 with cp/m@1R1,
 	am, bw, hs,
 	cols#80, lines#24, wsl#40,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
 	bel=^G, blink=\E[5m, bold=\E[1m, civis=\ER, clear=^L,
 	cnorm=\ES, cr=\r, csr=\EU%p1%{32}%+%c%p2%{32}%+%c,
-	cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\E[B,
-	cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
-	cuu=\E[%p1%dA, cuu1=\E[A, dch=\E[%p1%dP, dch1=\EM,
-	dl=\E[%p1%dM, dl1=\EL, ed=\E[J, el=\E[K, fsl=\r, home=\E[H,
-	ht=^I, ich=\E[%p1%d@, ich1=\EO, il=\E[%p1%dL, il1=\EN,
-	ind=\n, indn=\E[%p1%dB, is2=\E[U 7\E[24;1H, kbs=^H,
-	kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, khome=\E[H,
-	rc=\EX, rev=\E[7m, rf=/usr/share/tabset/vt100, ri=\EI,
-	rin=\E[%p1%dA, rmacs=\Ed, rmam=\E[?7l, rmso=\E[m,
-	rmul=\E[m, rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h,
-	sc=\EW, sgr0=\E[m, smacs=\EF, smam=\E[?7m, smso=\E[7m,
-	smul=\E[4m, tsl=\E], uc=\EPB,
+	cub1=^H, cud1=\E[B, cup=\E[%i%p1%d;%p2%dH, dch=\E[%p1%dP,
+	dch1=\EM, dl=\E[%p1%dM, dl1=\EL, ed=\E[J, el=\E[K, fsl=\r,
+	home=\E[H, ht=^I, ich=\E[%p1%d@, ich1=\EO, il=\E[%p1%dL,
+	il1=\EN, ind=\n, indn=\E[%p1%dB, is2=\E[U 7\E[24;1H,
+	khome=\E[H, rc=\EX, rev=\E[7m,
+	rf=/usr/share/tabset/vt100, ri=\EI, rin=\E[%p1%dA,
+	rmacs=\Ed, rmam=\E[?7l,
+	rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, sc=\EW,
+	sgr0=\E[m, smacs=\EF, smam=\E[?7m, tsl=\E], uc=\EPB,
+	use=ansi+apparrows, use=ansi+local, use=ansi+sgrso,
+	use=ansi+sgrul,
 
 #### Tandem
 #
@@ -19475,44 +19904,42 @@ dmterm|deskmate terminal,
 	bel=^G, civis=\EG5, clear=\Ej, cnorm=\EG6, cr=\r, cub1=^H,
 	cud1=\EB, cuf1=\EC, cup=\EY%p1%{32}%+%c%p2%{32}%+%c,
 	cuu1=\EA, dch1=\ES, dl1=\ER, ed=\EJ, el=\EK, home=\EH, ht=^I,
-	ich1=\EQ, il1=\EP, ind=\EX, invis@, kcub1=\ED, kcud1=\EB,
-	kcuf1=\EC, kcuu1=\EA, kf0=\E1, kf1=\E2, kf2=\E3, kf3=\E4,
-	kf4=\E5, kf5=\E6, kf6=\E7, kf7=\E8, kf8=\E9, kf9=\E0,
+	ich1=\EQ, il1=\EP, ind=\EX, invis@, kf0=\E1, kf1=\E2, kf2=\E3,
+	kf3=\E4, kf4=\E5, kf5=\E6, kf6=\E7, kf7=\E8, kf8=\E9, kf9=\E0,
 	khome=\EH, lf0=f1, lf1=f2, lf2=f3, lf3=f4, lf4=f5, lf5=f6,
 	lf6=f7, lf7=f8, lf8=f9, lf9=f10, ll=\EE, rmul@, smul@,
-	use=adm+sgr,
+	use=adm+sgr, use=vt52+arrows,
 dt100|dt-100|Tandy DT-100 terminal,
 	xon,
 	cols#80, lines#24, xmc#1,
 	acsc=jjkkllmmnnqqttuuvvwwxx, bel=^G, clear=\E[H\E[2J,
-	cr=\r, csr=\E[%p1%2d;%p2%2dr, cub1=^H, cud1=\E[B,
-	cuf1=\E[C, cup=\010\E[%i%p1%d;%p2%dH, cuu1=\E[A,
-	dch1=\E[P, dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H, ht=^I,
-	ich1=\E[@, il1=\E[L, ind=\n, is2=\E[?3l\E)0\E(B,
-	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kf1=\E[?3i,
-	kf10=\E[?5i, kf2=\E[2i, kf3=\E[@, kf4=\E[M, kf5=\E[17~,
-	kf6=\E[18~, kf7=\E[19~, kf8=\E[20~, kf9=\E[21~, khome=\E[H,
-	knp=\E[29~, kpp=\E[28~, lf1=f1, lf2=f2, lf3=f3, lf4=f4, lf5=f5,
-	lf6=f6, lf7=f7, lf8=f8, ri=\EM, rmacs=^O, rmso=\E[m, rmul=\E[m,
-	sgr0=\E[m, smacs=^N, smso=\E[7m, smul=\E[4m,
-	use=vt220+cvis,
+	cr=\r, csr=\E[%p1%2d;%p2%2dr, cub1=^H,
+	cup=\010\E[%i%p1%d;%p2%dH, dch1=\E[P, dl1=\E[M, ed=\E[J,
+	el=\E[K, home=\E[H, ht=^I, ich1=\E[@, il1=\E[L, ind=\n,
+	is2=\E[?3l\E)0\E(B, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C,
+	kcuu1=\E[A, kf1=\E[?3i, kf10=\E[?5i, kf2=\E[2i, kf3=\E[@,
+	kf4=\E[M, kf5=\E[17~, kf6=\E[18~, kf7=\E[19~, kf8=\E[20~,
+	kf9=\E[21~, khome=\E[H, knp=\E[29~, kpp=\E[28~, lf1=f1,
+	lf2=f2, lf3=f3, lf4=f4, lf5=f5, lf6=f6, lf7=f7, lf8=f8, ri=\EM,
+	rmacs=^O, rmso=\E[m, rmul=\E[m, sgr0=\E[m, smacs=^N,
+	smso=\E[7m, smul=\E[4m, use=ansi+local1, use=vt220+cvis,
 dt100w|dt-100w|Tandy DT-100 terminal (wide mode),
 	cols#132, use=dt100,
-dt110|Tandy DT-110 emulating ansi,
+dt110|Tandy DT-110 emulating ANSI,
 	xon,
 	cols#80, lines#24,
 	acsc=jjkkllmmnnqqttuuvvwwxx, bel=^G, clear=\E[H\E[2J,
-	cr=\r, csr=\E[%i%p1%d;%p2%dr, cub1=^H, cud1=\E[B,
-	cuf1=\E[C, cup=\010\E[%i%p1%d;%p2%dH, cuu1=\E[A,
-	dch1=\E[0P, dl1=\E[0M, ed=\E[0J, el=\E[0K, enacs=\E(B\E)0,
-	home=\E[H, ht=^I, ich1=\E[0@, il1=\E[0L, ind=\n,
-	is2=\E[?3l\E)0\E(B, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C,
-	kcuu1=\E[A, kend=\E[K, kf1=\E[1~, kf10=\E[10~, kf2=\E[2~,
-	kf3=\E[3~, kf4=\E[4~, kf5=\E[5~, kf6=\E[6~, kf7=\E[7~,
-	kf8=\E[8~, kf9=\E[9~, khome=\E[G, kich1=\E[@, knp=\E[26~,
-	kpp=\E[25~, lf0=f1, lf1=f2, lf2=f3, lf3=f4, lf4=f5, lf5=f6,
-	lf6=f7, lf7=f8, lf8=f9, lf9=f10, ri=\EM, rmacs=^O, rmso=\E[m,
-	rmul=\E[m, sgr0=\E[m, smacs=^N, smso=\E[7m, smul=\E[4m,
+	cr=\r, csr=\E[%i%p1%d;%p2%dr, cub1=^H,
+	cup=\010\E[%i%p1%d;%p2%dH, dch1=\E[0P, dl1=\E[0M,
+	ed=\E[0J, el=\E[0K, enacs=\E(B\E)0, home=\E[H, ht=^I,
+	ich1=\E[0@, il1=\E[0L, ind=\n, is2=\E[?3l\E)0\E(B,
+	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kend=\E[K,
+	kf1=\E[1~, kf10=\E[10~, kf2=\E[2~, kf3=\E[3~, kf4=\E[4~,
+	kf5=\E[5~, kf6=\E[6~, kf7=\E[7~, kf8=\E[8~, kf9=\E[9~,
+	khome=\E[G, kich1=\E[@, knp=\E[26~, kpp=\E[25~, lf0=f1,
+	lf1=f2, lf2=f3, lf3=f4, lf4=f5, lf5=f6, lf6=f7, lf7=f8, lf8=f9,
+	lf9=f10, ri=\EM, rmacs=^O, rmso=\E[m, rmul=\E[m, sgr0=\E[m,
+	smacs=^N, smso=\E[7m, smul=\E[4m, use=ansi+local1,
 	use=vt220+cvis,
 pt210|TRS-80 PT-210 printing terminal,
 	hc, os,
@@ -19527,25 +19954,25 @@ pt210|TRS-80 PT-210 printing terminal,
 # area" for interactive text.
 #
 
-tek|tek4012|tektronix 4012,
+tek|tek4012|Tektronix 4012,
 	OTbs, os,
 	cols#75, lines#35,
 	bel=^G, clear=\E\014$<1000>, cr=\r, cub1=^H, cud1=\n,
 	ff=\014$<1000>, is2=\E^O,
 # (tek4013: added <acsc> to suppress tic warnings re <smacs>/<rmacs> --esr)
-tek4013|tektronix 4013,
+tek4013|Tektronix 4013,
 	acsc=, rmacs=\E^O, smacs=\E^N, use=tek4012,
-tek4014|tektronix 4014,
+tek4014|Tektronix 4014,
 	cols#81, lines#38,
 	is2=\E\017\E9, use=tek4012,
 # (tek4015: added <acsc> to suppress tic warnings re <smacs>/<rmacs> --esr)
-tek4015|tektronix 4015,
+tek4015|Tektronix 4015,
 	acsc=, rmacs=\E^O, smacs=\E^N, use=tek4014,
-tek4014-sm|tektronix 4014 in small font,
+tek4014-sm|Tektronix 4014 in small font,
 	cols#121, lines#58,
-	is2=\E\017\E\:, use=tek4014,
+	is2=\E\017\E:, use=tek4014,
 # (tek4015-sm: added <acsc> to suppress tic warnings re <smacs>/<rmacs> --esr)
-tek4015-sm|tektronix 4015 in small font,
+tek4015-sm|Tektronix 4015 in small font,
 	acsc=, rmacs=\E^O, smacs=\E^N, use=tek4014-sm,
 # Tektronix 4023 from Andrew Klossner <orca!andrew.tektronix@csnet-relay>
 #
@@ -19556,7 +19983,7 @@ tek4015-sm|tektronix 4015 in small font,
 # live with Magic Cookie, remove the :so: and :se: fields and do without
 # reverse video.  If you like reverse video stand-out mode but don't want
 # it to flash, change the letter 'H' to 'P' in the :so: field.
-tek4023|tektronix 4023,
+tek4023|Tektronix 4023,
 	OTbs, am,
 	OTdN#4, cols#80, lines#24, vt#4, xmc#1,
 	OTnl=\n, bel=^G, clear=\E\014$<4/>, cr=\r, cub1=^H, cud1=\n,
@@ -19577,7 +20004,7 @@ tek4023|tektronix 4023,
 # <il1> and <il> had 145ms of padding, but that slowed down vi's ^U
 # and didn't seem necessary.
 #
-tek4024|tek4025|tek4027|tektronix 4024/4025/4027,
+tek4024|tek4025|tek4027|Tektronix 4024/4025/4027,
 	OTbs, am, da, db,
 	cols#80, it#8, lines#34, lm#0,
 	bel=^G, clear=\037era\r\n\n, cmdch=^_, cr=\r,
@@ -19593,14 +20020,14 @@ tek4024|tek4025|tek4027|tektronix 4024/4025/4027,
 	     \037lea\sf5\r,
 	smkx=\037lea\sp4\s/h/\r\037lea\sp8\s/k/\r\037lea\sp6\s/\s/
 	     \r\037lea\sp2\s/j/\r\037lea\sf5\s/H/\r,
-tek4025-17|tek 4025 17 line window,
+tek4025-17|Tektronix 4025 17 line window,
 	lines#17, use=tek4025,
-tek4025-17-ws|tek 4025 17 line window in workspace,
+tek4025-17-ws|Tektronix 4025 17 line window in workspace,
 	is2=!com\s31\r\n\037sto\s9\s17\s25\s33\s41\s49\s57\s65\s73
 	    \r\037wor\s17\r\037mon\s17\r,
 	rmcup=\037mon h\r, rmso=\037att s\r, smcup=\037wor h\r,
 	smso=\037att e\r, use=tek4025-17,
-tek4025-ex|tek4027-ex|tek 4025/4027 w/!,
+tek4025-ex|tek4027-ex|Tektronix 4025/4027 w/!,
 	is2=\037com 33\r\n!sto 9 17 25 33 41 49 57 65 73\r,
 	rmcup=\037com 33\r, smcup=!com 31\r, use=tek4025,
 # Tektronix 4025a
@@ -19644,7 +20071,7 @@ tek4025a|Tektronix 4025A,
 # not try to scroll, or cursor addressing won't work.  Also, you can't
 # see the cursor.)
 # (This "learns" the arrow keys for rogue. I have adapted it for termcap - mrh)
-tek4025-cr|tek 4025 for curses and rogue,
+tek4025-cr|Tektronix 4025 for curses and rogue,
 	OTbs, am,
 	cols#80, it#8, lines#33,
 	clear=\037era;, cub1=^H, cud1=^F\n, cuf1=\037rig;,
@@ -19654,11 +20081,11 @@ tek4025-cr|tek 4025 for curses and rogue,
 # next two lines commented out since curses only allows 128 chars, sigh.
 #	:ti=\037lea p1/b/\037lea p2/j/\037lea p3/n/\037lea p4/h/\037lea p5/ /\037lea p6/l/\037lea p7/y/\037lea p8/k/\037lea p9/u/\037lea p./f/\037lea pt/`era w/13\037lea p0/s/\037wor 33h:\
 #	:te=\037lea p1\037lea p2\037lea p3\037lea p4\037lea pt\037lea p5\037lea p6\037lea p7\037lea p8\037lea p9/la/13\037lea p.\037lea p0\037wor 0:
-tek4025ex|4025ex|4027ex|tek 4025 w/!,
+tek4025ex|4025ex|4027ex|Tektronix 4025 w/!,
 	is2=\037com\s33\r\n!sto\s9\,17\,25\,33\,41\,49\,57\,65\,73
 	    \r,
 	rmcup=\037com 33\r, smcup=!com 31\r, use=tek4025,
-tek4105|tektronix 4105,
+tek4105|Tektronix 4105,
 	OTbs, am, mir, msgr, ul, xenl, xt,
 	cols#79, it#8, lines#29,
 	acsc=, bel=^G, blink=\E[=3;<7m, bold=\E[=7;<4m, cbt=\E[Z,
@@ -19674,26 +20101,14 @@ tek4105|tektronix 4105,
 	smul=\E[=5;<2m, tbc=\E[1g,
 
 # (tek4105-30: I added <rmam>/<smam> based on the init string -- esr)
-tek4105-30|4015 emulating 30 line vt100,
-	am, mir, msgr, xenl, xon,
-	cols#80, it#8, lines#30, vt#3,
-	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, blink=\E[5m$<2>, bold=\E[1m$<2>,
-	clear=\E[H\E[J$<50>, cr=\r, csr=\E[%i%p1%d;%p2%dr,
-	cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\n,
-	cuf=\E[%p1%dC, cuf1=\E[C$<2>,
-	cup=\E[%i%p1%d;%p2%dH$<5>, cuu=\E[%p1%dA,
-	cuu1=\E[A$<2>, ed=\E[J$<50>, el=\E[K$<3>, el1=\E[1K$<3>,
-	enacs=\E(B\E)0, home=\E[H, ht=^I, hts=\EH, ind=\n, kbs=^H,
-	kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, rc=\E8,
-	rev=\E[7m$<2>, ri=\EM$<5>, rmacs=^O, rmam=\E[?7l,
-	rmkx=\E[?1l\E>, rmso=\E[m$<2>, rmul=\E[m$<2>,
-	rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, sc=\E7,
-	sgr=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5
-	    %;m%?%p9%t\016%e\017%;$<2>,
-	sgr0=\E[m\017$<2>, smacs=^N, smam=\E[?7h, smkx=\E[?1h\E=,
-	smso=\E[1;7m$<2>, smul=\E[4m$<2>, tbc=\E[3g,
-	use=vt100+fnkeys,
+tek4105-30|Tektronix 4015 emulating 30 line VT100,
+	mir, xenl, xon,
+	lines#30, vt#3,
+	cub1=^H, cud1=\n, cuf1=\E[C$<2>, cuu1=\E[A$<2>, kcub1=\EOD,
+	kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, rmam=\E[?7l,
+	rmkx=\E[?1l\E>, rmso=\E[m$<2>, smam=\E[?7h,
+	smkx=\E[?1h\E=, use=ansi+csr, use=ansi+local,
+	use=vt100+4bsd, use=vt100+fnkeys,
 
 # Tektronix 4105 from BRL
 # The following setup modes are assumed for normal operation:
@@ -19716,32 +20131,28 @@ tek4105-30|4015 emulating 30 line vt100,
 # delays are specified; use "stty ixon -ixany" to enable DC3/DC1 flow control!
 # "IC" cannot be used in combination with "im" & "ei".
 # "tek4105a" is just a guess:
-tek4105a|Tektronix 4105,
+tek4105a|Tektronix 4105 (BRL),
 	OTbs, OTpt, msgr, xon,
-	OTkn#8, cols#80, it#8, lines#30, vt#3,
-	acsc=, bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z,
-	civis=\E%!0\ETD00\E%!1, clear=\E[H\E[J,
-	cnorm=\E%!0\ETD10\E%!1, cr=\r, csr=\E[%i%p1%d;%p2%dr,
-	cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\n,
-	cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
-	cuu=\E[%p1%dA, cuu1=\EM, cvvis=\E%!0\ETD70\E%!1,
-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M,
-	ech=\E[%p1%dX, ed=\E[J, el=\E[K, home=\E[H, ht=^I, hts=\EH,
-	il=\E[%p1%dL, il1=\E[L, ind=\n, is2=\E%!1, kbs=^H,
+	OTkn#8, cols#80, lines#30, vt#3,
+	acsc=, bel=^G, blink=\E[5m, bold=\E[1m,
+	civis=\E%!0\ETD00\E%!1, cnorm=\E%!0\ETD10\E%!1, cr=\r,
+	cub1=^H, cud1=\n, cup=\E[%i%p1%d;%p2%dH, cuu1=\EM,
+	cvvis=\E%!0\ETD70\E%!1, dch=\E[%p1%dP, dch1=\E[P,
+	ech=\E[%p1%dX, home=\E[H, ind=\n, is2=\E%!1, kbs=^H,
 	kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kf0=\EOA,
 	kf1=\EOB, kf2=\EOC, kf3=\EOD, kf4=\EOP, kf5=\EOQ, kf6=\EOR,
 	kf7=\EOS, lf0=F1, lf1=F2, lf2=F3, lf3=F4, lf4=F5, lf5=F6, lf6=F8,
-	ll=\E[30;H, nel=\EE, rc=\E8, rev=\E[7m, ri=\EM, rmacs=^O,
+	ll=\E[30;H, nel=\EE, rev=\E[7m, ri=\EM, rmacs=^O,
 	rmcup=\E%!0\ELBH=\E%!1, rmir=\E[4l, rmkx=\E[?1l\E>,
 	rmso=\E[m, rmul=\E[m,
 	rs2=\030\E%!0\EKC\E\014\EKR0\EKF0\ENM0\ELBH=\ETF8000010F40
 	    \ELI100\ELLA>\ELM0\EKE0\ENF1\EKS0\END0\E%!1\Ec\E[?3;5l
 	    \E[?7;8h\E[r\E[m\E>,
-	sc=\E7, sgr0=\E[m, smacs=^N, smcup=\E[?6l, smir=\E[4h,
-	smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g,
-	use=ecma+index,
+	sgr0=\E[m, smacs=^N, smcup=\E[?6l, smir=\E[4h,
+	smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, use=ansi+csr,
+	use=ansi+erase, use=ansi+idl, use=ansi+inittabs,
+	use=ansi+local, use=ecma+index,
 
-#
 # Tektronix 4106/4107/4109 from BRL
 # The following setup modes are assumed for normal operation:
 #	CODE ansi		COLUMNMODE 80		CRLF no
@@ -19765,28 +20176,25 @@ tek4105a|Tektronix 4105,
 # "IC" cannot be used in combination with "im" & "ei".
 tek4106brl|tek4107brl|tek4109brl|Tektronix 4106 4107 or 4109,
 	msgr, xon,
-	cols#80, it#8, lines#32, vt#3,
-	acsc=, bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z,
-	civis=\E%!0\ETD00\E%!1, clear=\E[H\E[J,
-	cnorm=\E%!0\ETD10\E%!1, cr=\r, csr=\E[%i%p1%d;%p2%dr,
-	cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\n,
-	cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
-	cuu=\E[%p1%dA, cuu1=\EM, cvvis=\E%!0\ETD70\E%!1,
-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M,
-	ech=\E[%p1%dX, ed=\E[J, el=\E[K, home=\E[H, ht=^I, hts=\EH,
-	il=\E[%p1%dL, il1=\E[L, ind=\n, is2=\E%!1, kbs=^H,
+	cols#80, lines#32, vt#3,
+	acsc=, bel=^G, blink=\E[5m, bold=\E[1m,
+	civis=\E%!0\ETD00\E%!1, cnorm=\E%!0\ETD10\E%!1, cr=\r,
+	cub1=^H, cud1=\n, cup=\E[%i%p1%d;%p2%dH, cuu1=\EM,
+	cvvis=\E%!0\ETD70\E%!1, dch=\E[%p1%dP, dch1=\E[P,
+	ech=\E[%p1%dX, home=\E[H, ind=\n, is2=\E%!1, kbs=^H,
 	kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kf0=\EOA,
 	kf1=\EOB, kf2=\EOC, kf3=\EOD, kf4=\EOP, kf5=\EOQ, kf6=\EOR,
 	kf7=\EOS, lf0=F1, lf1=F2, lf2=F3, lf3=F4, lf4=F5, lf5=F6, lf6=F8,
-	ll=\E[32;H, nel=\EE, rc=\E8, rev=\E[7m, ri=\EM, rmacs=^O,
+	ll=\E[32;H, nel=\EE, rev=\E[7m, ri=\EM, rmacs=^O,
 	rmcup=\E%!0\ELBH=\E%!1, rmir=\E[4l, rmkx=\E[?1l\E>,
 	rmso=\E[m, rmul=\E[m,
 	rs1=\030\E%!0\EKC\E\014\EKR0\EKF0\ENM0\ELBH=\ETF8000010F40
 	    \ELI100\ELLB0\ELM0\EKE0\ENF1\EKS0\END0\ERE0\E%!1\Ec\E[?3
 	    ;5l\E[?7;8h\E[r\E[m\E>,
-	sc=\E7, sgr0=\E[m, smacs=^N, smcup=\E[?6l, smir=\E[4h,
-	smkx=\E[?1h\E=, smso=\E[7;42m, smul=\E[4m, tbc=\E[3g,
-	use=ecma+index,
+	sgr0=\E[m, smacs=^N, smcup=\E[?6l, smir=\E[4h,
+	smkx=\E[?1h\E=, smso=\E[7;42m, smul=\E[4m, use=ansi+csr,
+	use=ansi+erase, use=ansi+idl, use=ansi+inittabs,
+	use=ansi+local, use=ecma+index,
 
 # Refer to:
 # TEK Programmer's Reference
@@ -19806,7 +20214,7 @@ tek4106brl|tek4107brl|tek4109brl|Tektronix 4106 4107 or 4109,
 # VT52's non-CSI versions of ANSI, e.g., \EJ.  A possible explanation is that
 # the developer used Emacs, which misuses cvvis (this description sets VT52
 # mode in that capability).
-tek4107|tek4109|tektronix terminals 4107 4109,
+tek4107|tek4109|Tektronix terminals 4107 4109,
 	OTbs, am, mir, msgr, ul, xenl, xt,
 	cols#79, it#8, lines#29,
 	bel=^G, blink=\E%!1\E[5m$<2>\E%!0,
@@ -19814,13 +20222,12 @@ tek4107|tek4109|tektronix terminals 4107 4109,
 	cub1=^H, cud1=\n, cuf1=\EC,
 	cup=\EY%p1%{32}%+%c%p2%{32}%+%c, cuu1=\EA, cvvis=\E%!3,
 	dim=\E%!1\E[<0m$<2>\E%!0, ed=\EJ, el=\EK, ht=^I, ind=\n,
-	kbs=^H, kcub1=\ED, kcud1=\EB, kcuf1=\EC, kcuu1=\EA,
-	rev=\E%!1\E[7m$<2>\E%!0, ri=\EI,
+	kbs=^H, rev=\E%!1\E[7m$<2>\E%!0, ri=\EI,
 	rmso=\E%!1\E[m$<2>\E%!0, rmul=\E%!1\E[m$<2>\E%!0,
 	sgr=\E%%!1\E[%?%p1%t;7;5%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;
 	    %?%p5%t<0%;%?%p6%t;1%;m$<2>\E%%!0,
 	sgr0=\E%!1\E[m$<2>\E%!0, smso=\E%!1\E[7;5m$<2>\E%!0,
-	smul=\E%!1\E[4m$<2>\E%!0,
+	smul=\E%!1\E[4m$<2>\E%!0, use=vt52+arrows,
 # Tektronix 4207 with sysline.  In the ancestral termcap file this was 4107-s;
 # see the note attached to tek4207.
 tek4207-s|Tektronix 4207 with sysline but no memory,
@@ -19837,7 +20244,7 @@ tek4207-s|Tektronix 4207 with sysline but no memory,
 # is no way to scroll.
 #
 # Note that there is a floppy for free from Tek that makes the
-# 4112 emulate the vt52 (use the vt52 termcap). There is also
+# 4112 emulate the VT52 (use the VT52 termcap). There is also
 # an expected enhancement that will use ANSI standard sequences.
 #
 # 4112 in non-dialog area pretending to scroll. It really wraps
@@ -19845,13 +20252,13 @@ tek4207-s|Tektronix 4207 with sysline but no memory,
 #
 # 'vi' works reasonably well with this entry.
 #
-otek4112|o4112-nd|otek4113|otek4114|old tektronix 4110 series,
+otek4112|o4112-nd|otek4113|otek4114|Tektronix 4110 series (old),
 	am,
 	cols#80, lines#34,
 	bel=^G, clear=\E^L, cr=\r, cub1=^H, cud1=\n, cuu1=^K, ind=\n,
 	rmcup=\EKA1\ELV1, smcup=\EKA0\ELV0\EMG0,
 # The 4112 with the ANSI compatibility enhancement
-tek4112|tek4114|tektronix 4110 series,
+tek4112|tek4114|Tektronix 4110 series,
 	OTbs, am, db,
 	cols#80, lines#34,
 	cbt=\E[Z, clear=\E[2J\E[0;0H, cub1=^H, cud1=\E[B,
@@ -19859,30 +20266,30 @@ tek4112|tek4114|tektronix 4110 series,
 	dl1=\E[M, ed=\E[0J, el=\E[0K, ich1=\E[@, il1=\E[L,
 	ind=\E7\E[0;0H\E[M\E8, is2=\E3!1, ri=\E7\E[0;0H\E[L\E8,
 	rmso=\E[m, rmul=\E[m, sgr0=\E[m, smso=\E[7m, smul=\E[4m,
-tek4112-nd|4112 not in dialog area,
+tek4112-nd|Tektronix 4112 not in dialog area,
 	OTns,
 	cuu1=^K, use=tek4112,
-tek4112-5|4112 in 5 line dialog area,
+tek4112-5|Tektronix 4112 in 5 line dialog area,
 	lines#5, use=tek4112,
 # (tek4113: this used to have "<cuf1=\LM1\s\LM0>", someone's mistake;
 # removed "<smacs=\E^N>, <rmacs=\E^O>", which had been commented out in 8.3.
 # Note, the !0 and !1 sequences in <rmcup>/<smcup>/<cnorm>/<civis> were
 # previously \0410 and \0411 sequences...I don't *think* they were supposed
 # to be 4-digit octal -- esr)
-tek4113|tektronix 4113 color graphics with 5 line dialog area,
+tek4113|Tektronix 4113 color graphics with 5 line dialog area,
 	OTbs, am, da, eo,
 	cols#80, lines#5,
 	clear=\ELZ, cub1=^H, cud1=\n, cuf1=\ELM1 \ELM0,
 	flash=\ERBA4\ERBA4\ERBA4\ERBA4\ERBA4\ERBA4\ERBA4\ERBA4
 	      \ERBA4\ERBA4\ERB0,
 	is2=\EKA1\ELL5\ELV0\ELV1, uc=\010\ELM1_\ELM0,
-tek4113-34|tektronix 4113 color graphics with 34 line dialog area,
+tek4113-34|Tektronix 4113 color graphics with 34 line dialog area,
 	lines#34,
 	is2=\EKA1\ELLB2\ELV0\ELV1, use=tek4113,
 # :ns: left off to allow vi visual mode. APL font (:as=\E^N:/:ae=\E^O:) not
 # supported here. :uc: is slow, but looks nice. Suggest setenv MORE -up .
 # :vb: needs enough delay to let you see the background color being toggled.
-tek4113-nd|tektronix 4113 color graphics with no dialog area,
+tek4113-nd|Tektronix 4113 color graphics with no dialog area,
 	OTbs, am, eo,
 	cols#80, it#8, lines#34,
 	clear=\E^L, cub1=^H, cud1=\n, cuf1=^I, cuu1=^K,
@@ -19893,47 +20300,40 @@ tek4113-nd|tektronix 4113 color graphics with no dialog area,
 	ll=\ELF hl @, rmso=\EMT1, smso=\EMT2, uc=\010\EMG1_\EMG0,
 # This entry is from Tek. Inc.  (Brian Biehl)
 # (tek4115: :bc: renamed to :le:, <rmam>/<smam> added based on init string -- esr)
-otek4115|Tektronix 4115,
+otek4115|Tektronix 4115 (old),
 	OTbs, am, da, db, eo,
 	cols#80, it#8, lines#34,
 	cbt=\E[Z, clear=\E[H\E[2J,
-	cnorm=\E%!0\ELBG8\E%!1\E[34;1H, cub1=\E[D, cud1=\E[B,
-	cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A,
-	cvvis=\E%!0\ELBB2\E%!1, dch1=\E[P, dl1=\E[M, ed=\E[J,
-	el=\E[K, home=\E[H, ht=^I, if=/usr/share/tabset/vt100,
-	il1=\E[L,
+	cnorm=\E%!0\ELBG8\E%!1\E[34;1H,
+	cup=\E[%i%p1%d;%p2%dH, cvvis=\E%!0\ELBB2\E%!1,
+	dch1=\E[P, dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H, ht=^I,
+	if=/usr/share/tabset/vt100, il1=\E[L,
 	is2=\E%!0\E%\014\ELV0\EKA1\ELBB2\ENU@=\ELLB2\ELM0\ELV1\EKYA?
 	    \E%!1\E[<1l\E[?7h\E[?8h\E[34;1H\E[34B\E[m,
 	kbs=^H, ri=\EM, rmam=\E[?7l,
 	rmcup=\E%!0\ELBG8\E%!1\E[34;1H\E[J, rmir=\E[4l,
 	rmkx=\E>, rmso=\E[m, rmul=\E[m, sgr0=\E[m, smam=\E[?7h,
 	smcup=\E%!0\ELBB2\E%!1, smir=\E[4h, smkx=\E=, smso=\E[7m,
-	smul=\E[4m,
-tek4115|newer tektronix 4115 entry with more ANSI capabilities,
+	smul=\E[4m, use=ansi+local1,
+tek4115|Tektronix 4115 entry with more ANSI capabilities (new),
 	am, xon,
 	cols#80, lines#34,
-	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, clear=\E[H\E[J,
-	cr=\r, cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\n,
-	cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
-	cuu=\E[%p1%dA, cuu1=\E[A, dch1=\E[P, dl=\E[%p1%dM,
-	dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H, hpa=\E[%p1%{1}%+%dG,
-	ht=^I, hts=\EH, ich=\E[%p1%d@, ich1=\E[@, il=\E[%p1%dL,
-	il1=\E[L, ind=\n, invis=\E[8m, kbs=^H, kcub1=\E[D,
-	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, khome=\E[H, rev=\E[7m,
-	rmam=\E[?7l, rmso=\E[m, rmul=\E[m,
-	sgr=\E[%?%p1%t7;%;%?%p2%t4;%;%?%p3%t7;%;%?%p4%t5;%;%?%p6%t1;
-	    %;%?%p7%t8;%;m,
-	sgr0=\E[m, smam=\E[?7h, smso=\E[7m, smul=\E[4m, tbc=\E[3g,
-	vpa=\E[%p1%{1}%+%dd, use=ansi+rep,
-# The tek4125 emulates a vt100 incorrectly - the scrolling region
+	bel=^G, cr=\r, cub1=^H, cud1=\n, dch1=\E[P, ich=\E[%p1%d@,
+	ich1=\E[@, ind=\n, kcuu1=\E[A, rmam=\E[?7l, sgr0=\E[m,
+	smam=\E[?7h, use=ansi+arrows, use=ansi+cup,
+	use=ansi+erase, use=ansi+idl, use=ansi+local,
+	use=ansi+rep, use=ansi+rca, use=ansi+sgrbold,
+	use=ansi+tabs,
+
+# The tek4125 emulates a VT100 incorrectly - the scrolling region
 # command is ignored.  The following entry replaces <csr> with the needed
 # <il>, <il>, and <smir>; removes some cursor pad commands that the tek4125
-# chokes on; and adds a lot of initialization for the tek dialog area.
+# chokes on; and adds a lot of initialization for the Tektronix dialog area.
 # Note that this entry uses all 34 lines and sets the cursor color to green.
 # Steve Jacobson 8/85
 # (tek4125: there were two "\!"s in the is that I replaced with "\E!";
 # commented out, <smir>=\E1 because there's no <rmir>  -- esr)
-tek4125|tektronix 4125,
+tek4125|Tektronix 4125,
 	lines#34,
 	csr@, dl1=\E[1M, il1=\E[1L,
 	is2=\E%\E!0\EQD1\EUX03\EKA\ELBB2\ELCE0\ELI100\ELJ2\ELLB2
@@ -19965,24 +20365,24 @@ tek4207|Tektronix 4207 graphics terminal with memory,
 # From: <carolyn@dali.berkeley.edu>  Thu Oct 31 12:54:27 1985
 # (tek4404: There was a "\!" in <smcup> that I replaced with "\E!".
 # Tab had been given as \E2I,that must be the tab-set capability -- esr)
-tek4404|tektronix 4404,
+tek4404|Tektronix 4404,
 	OTbs,
 	cols#80, it#8, lines#32,
-	blink=\E[5m, bold=\E[1m, clear=\E[H\E[2J,
-	csr=\E[%i%p1%d;%p2%dr, cub1=^H, cud1=\n, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, dch1=\E[P, dl1=\E[1M,
-	ed=\E[J, el=\E[K, home=\E[H, ht=^I, hts=\E[2I, il1=\E[1L,
-	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, rc=\E8,
+	blink=\E[5m, bold=\E[1m, clear=\E[H\E[2J, cub1=^H, cud1=\n,
+	cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, dch1=\E[P,
+	dl1=\E[1M, ed=\E[J, el=\E[K, home=\E[H, ht=^I, hts=\E[2I,
+	il1=\E[1L, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
 	rmcup=\E[1;1H\E[0J\E[?6h\E[?1l, rmir=\E[4l,
-	rmkx=\E[?1h, rmso=\E[27m, rmul=\E[m, sc=\E7, sgr0=\E[m,
+	rmkx=\E[?1h, rmso=\E[27m, rmul=\E[m, sgr0=\E[m,
 	smcup=\E%\E!1\E[1;32r\E[?6l\E>, smir=\E[4h,
-	smkx=\E[?1l, smso=\E[7m, smul=\E[4m,
+	smkx=\E[?1l, smso=\E[7m, smul=\E[4m, use=ansi+csr,
+
 # Some unknown person wrote:
 # I added the is string - straight Unix has ESC ; in the login
 # string which sets a ct8500 into monitor mode (aka 4025 snoopy
 # mode). The is string here cleans up a few things (but not
 # everything).
-ct8500|tektronix ct8500,
+ct8500|Tektronix ct8500,
 	am, bw, da, db,
 	cols#80, lines#25,
 	bel=^G, cbt=\E^I, clear=\E^E, cr=\r, cub1=^H, cud1=\n,
@@ -19995,23 +20395,21 @@ ct8500|tektronix ct8500,
 #
 # am is not defined because the wrap around occurs not when the char.
 # is placed in the 80'th column, but when we are attempting to type
-# the 81'st character on the line.  (esr: hmm, this is like the vt100
+# the 81'st character on the line.  (esr: hmm, this is like the VT100
 # version of xenl, perhaps am + xenl would work!)
 #
 # Bold, dim, and standout are simulated by colors and thus not allowed
-# with colors.  The tektronix color table is mapped into the RGB color
+# with colors.  The Tektronix color table is mapped into the RGB color
 # table by setf/setb. All colors are reset to factory specifications by oc.
 # The <initc> cap uses RGB notation to define colors.  for arguments 1-3 the
 # interval (0-1000) is broken into 8 smaller sub-intervals (125).  Each sub-
 # interval then maps into pre-defined value.
-tek4205|tektronix 4205,
+tek4205|Tektronix 4205,
 	ccc, mir, msgr,
 	colors#8, cols#80, it#8, lines#30, ncv#49, pairs#63,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
 	bel=^G, blink=\E[5m, bold=\E[=7;<4m, cbt=\E[Z,
-	clear=\E[2J\E[H, cr=\r, cub=\E[%p1%dD, cub1=\E[D,
-	cud=\E[%p1%dB, cud1=\E[B, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
+	clear=\E[2J\E[H, cr=\r, cup=\E[%i%p1%d;%p2%dH,
 	dch1=\E[1P, dim=\E[=1;<6m, dl=\E[%p1%dM, dl1=\E[1M,
 	ech=\E%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K, enacs=\E)0,
 	home=\E[H, ht=^I, ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[1L,
@@ -20020,12 +20418,12 @@ tek4205|tektronix 4205,
 	      %e%p1%{3}%=%t5%e%p1%{4}%=%t2%e%p1%{5}%=%t6%e%p1%{6}%=
 	      %t7%e1%;%?%p2%{125}%<%t0%e%p2%{250}%<%tA2%e%p2%{375}%<
 	      %tA?%e%p2%{500}%<%tC8%e%p2%{625}%<%tD4%e%p2%{750}%<%tE
-	      1%e%p2%{875}%<%tE\:%eF4%;%?%p3%{125}%<%t0%e%p3%{250}%<
+	      1%e%p2%{875}%<%tE:%eF4%;%?%p3%{125}%<%t0%e%p3%{250}%<
 	      %tA2%e%p3%{375}%<%tA?%e%p3%{500}%<%tC8%e%p3%{625}%<%tD
-	      4%e%p3%{750}%<%tE1%e%p3%{875}%<%tE\:%eF4%;%?%p4%{125}
-	      %<%t0%e%p4%{250}%<%tA2%e%p4%{375}%<%tA?%e%p4%{500}%<%t
-	      C8%e%p4%{625}%<%tD4%e%p4%{750}%<%tE1%e%p4%{875}%<%tE\:
-	      %eF4%;\E%%!1,
+	      4%e%p3%{750}%<%tE1%e%p3%{875}%<%tE:%eF4%;%?%p4%{125}%<
+	      %t0%e%p4%{250}%<%tA2%e%p4%{375}%<%tA?%e%p4%{500}%<%tC8
+	      %e%p4%{625}%<%tD4%e%p4%{750}%<%tE1%e%p4%{875}%<%tE:%eF
+	      4%;\E%%!1,
 	invis=\E[=6;<5, is1=\E%!0\ETM1\E%!1\E[m, kbs=^H,
 	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kf0=\EOA,
 	kf1=\EOB, kf2=\EOC, kf3=\EOD, kf4=\EP, kf5=\EQ, kf6=\ER,
@@ -20042,7 +20440,7 @@ tek4205|tektronix 4205,
 	     %e1m%;,
 	sgr0=\E[=0;<1m\E[24;25;27m\017, smacs=^N,
 	smcup=\E%%!1\E[?6l\E[2J, smir=\E[4h, smso=\E[=2;<3m,
-	smul=\E[4m, tbc=\E[1g,
+	smul=\E[4m, tbc=\E[1g, use=ansi+local,
 
 #### Teletype (tty)
 #
@@ -20075,7 +20473,7 @@ tty37|model 37 teletype,
 # a "newline" style terminal (-crmode) vi figures all it needs is nl
 # to get crlf, even if <cr> is not ^M.)
 # (tty40: removed obsolete ":nl=\EG\EB:", it's just do+cr -- esr)
-tty40|ds40|ds40-2|dataspeed40|teletype dataspeed 40/2,
+tty40|ds40|ds40-2|dataspeed40|Teletype dataspeed 40/2,
 	OTbs, xon,
 	cols#80, lines#24,
 	clear=\EH$<20>\EJ$<80>, cr=\EG, cub1=^H, cud1=\EB,
@@ -20099,9 +20497,9 @@ scanset|sc410|sc415|Tymshare Scan Set,
 	cols#80, lines#24,
 	acsc=j%k4l<m-q\,x5, bel=^G, clear=\EH\EJ, cr=\r, cub1=^H,
 	cud1=\n, cuf1=^I, cup=\EY%p1%{32}%+%c%p2%{32}%+%c,
-	cuu1=^K, ed=\EJ, el=\EK, home=\EH, ind=\n, kcub1=\ED,
-	kcud1=\EB, kcuf1=\EC, kcuu1=\EA, mc0=\E;3, mc4=\E;0,
+	cuu1=^K, ed=\EJ, el=\EK, home=\EH, ind=\n, mc0=\E;3, mc4=\E;0,
 	mc5=\E;0, rc=^C, rmacs=^O, rs1=\E>, sc=^B, smacs=^N,
+	use=vt52+arrows,
 
 #### Volker-Craig (vc)
 #
@@ -20113,24 +20511,24 @@ scanset|sc410|sc415|Tymshare Scan Set,
 
 # Missing in vc303a and vc303 descriptions:  they scroll 2 lines at a time
 # every other linefeed.
-vc303|vc103|vc203|volker-craig 303,
+vc303|vc103|vc203|Volker-Craig 303,
 	OTbs, OTns, am,
 	cols#80, lines#24,
 	bel=^G, clear=\014$<40>, cr=\r, cub1=^H, cud1=\n, cuf1=^I,
 	cuu1=^N, home=\013$<40>, kcub1=^H, kcud1=\n, kcuf1=^I,
 	kcuu1=^N, ll=\017$<1>W,
-vc303a|vc403a|volker-craig 303a,
+vc303a|vc403a|Volker-Craig 303a,
 	clear=\030$<40>, cuf1=^U, cuu1=^Z, el=\026$<20>,
 	home=\031$<40>, kcuf1=^U, kcuu1=^Z, ll=^P, use=vc303,
 # (vc404: removed obsolete ":ma=^Z^P^U :" -- esr)
-vc404|volker-craig 404,
+vc404|Volker-Craig 404,
 	OTbs, am,
 	cols#80, lines#24,
 	bel=^G, clear=\030$<40>, cr=\r, cub1=^H, cud1=\n, cuf1=^U,
 	cup=\020%p1%{32}%+%c%p2%{32}%+%c, cuu1=^Z,
 	ed=\027$<40>, el=\026$<20>, home=\031$<40>, ind=\n,
 	kcub1=^H, kcud1=\n, kcuf1=^U, kcuu1=^Z,
-vc404-s|volker-craig 404 w/standout mode,
+vc404-s|Volker-Craig 404 w/standout mode,
 	cud1=\n, rmso=^O, smso=^N, use=vc404,
 # From: <wolfgang@cs.sfu.ca>
 # (vc414: merged in cup/dl1/home from an old vc414h-noxon)
@@ -20140,12 +20538,12 @@ vc414|vc414h|Volker-Craig 414H in sane escape mode.,
 	clear=\E\034$<40>, cud1=\E^K, cuf1=^P,
 	cup=\E\021%p2%c%p1%c$<40>, cuu1=\E^L, dch1=\E3,
 	dl1=\E\023$<40>, ed=\E^X, el=\E\017$<10/>, home=\E^R,
-	ich1=\E\:, il1=\E\032$<40>, kcub1=^H, kcud1=\E^K, kcuf1=^P,
+	ich1=\E:, il1=\E\032$<40>, kcub1=^H, kcud1=\E^K, kcuf1=^P,
 	kcuu1=\E^L, kf0=\EA, kf1=\EB, kf2=\EC, kf3=\ED, kf4=\EE,
 	kf5=\EF, kf6=\EG, kf7=\EH, khome=\E^R, lf0=PF1, lf1=PF2,
 	lf2=PF3, lf3=PF4, lf4=PF5, lf5=PF6, lf6=PF7, lf7=PF8,
 	rmso=\E^_, smso=\E^Y,
-vc415|volker-craig 415,
+vc415|Volker-Craig 415,
 	clear=^L, use=vc404,
 
 ######## OBSOLETE PERSONAL-MICRO CONSOLES AND EMULATIONS
@@ -20189,21 +20587,18 @@ ibmpc|wy60-PC|wyse60-PC|IBM PC/XT running PC/IX,
 	cols#80, it#8, lines#24,
 	acsc=j\331k\277l\332m\300n\305q\304t\303u\264v\301w\302x
 	     \263,
-	bel=^G, blink=\E[5m, bold=\E[1m, clear=\Ec, cr=\r,
-	cub=\E[%p1%dD, cub1=\E[D, cud=\E[%p1%dB, cud1=\E[B,
-	cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
-	cuu=\E[%p1%dA, cuu1=\E[A, ech=\E[%p1%dX, ed=\E[J, el=\E[K,
-	home=\E[H, hpa=\E[%i%p1%dG, ind=\E[S\E[B,
-	indn=\E[%p1%dS\E[%p1%dB, invis=\E[30;40m, kbs=^H,
-	kcbt=^], kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
-	kdch1=^?, kend=\E[Y, kf1=\240, kf10=\251, kf2=\241, kf3=\242,
-	kf4=\243, kf5=\244, kf6=\245, kf7=\246, kf8=\247, kf9=\250,
-	khome=\E[H, kich1=\E[^H, knp=\E[U, kpp=\E[V, ll=\E[24;1H,
-	nel=\r, rev=\E[7m, ri=\E[T\E[A, rin=\E[%p1%dT\E[%p1%dA,
-	rmso=\E[m, rmul=\E[m,
+	bel=^G, clear=\Ec, cr=\r, cup=\E[%i%p1%d;%p2%dH,
+	ech=\E[%p1%dX, ed=\E[J, el=\E[K, home=\E[H,
+	hpa=\E[%i%p1%dG, ind=\E[S\E[B, indn=\E[%p1%dS\E[%p1%dB,
+	invis=\E[30;40m, kcbt=^], kdch1=^?, kend=\E[Y, kf1=\240,
+	kf10=\251, kf2=\241, kf3=\242, kf4=\243, kf5=\244, kf6=\245,
+	kf7=\246, kf8=\247, kf9=\250, kich1=\E[^H, knp=\E[U,
+	kpp=\E[V, ll=\E[24;1H, nel=\r, rev=\E[7m, ri=\E[T\E[A,
+	rin=\E[%p1%dT\E[%p1%dA,
 	sgr=\E[%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p6%t;1
 	    %;%?%p7%t30;40%;m,
-	sgr0=\E[m, smso=\E[7m, smul=\E[4m,
+	sgr0=\E[m, use=ansi+arrows, use=ansi+local,
+	use=ansi+sgrbold,
 
 #### Apple II
 #
@@ -20244,8 +20639,7 @@ apple2e|Apple //e,
 # mcvax!vu44!vu45!wilcke uses the "ap" entry together with Ascii Express Pro
 # 4.20, with incoming and outgoing terminals both on 0, emulation On.
 apple2e-p|Apple //e via Pascal,
-	cup=\036%p2%{32}%+%c%p1%{32}%+%c, kbs=^H, kcub1=^H,
-	kcud1=\n, use=apple2e,
+	cup=\036%p2%{32}%+%c%p1%{32}%+%c, use=apple2e,
 # (ASCII Express) MouseTalk "Standard Apple //" emulation from BRL
 # Enable DC3/DC1 flow control with "stty ixon -ixany".
 apple-ae|ASCII Express,
@@ -20256,7 +20650,7 @@ apple-ae|ASCII Express,
 	home=^Y, ind=^W, is2=^R^N, kclr=^X, kcub1=^H, kcud1=\n,
 	kcuf1=^U, kcuu1=^K, rev=^O, ri=^V, rmso=^N, rs1=^R^N, sgr0=^N,
 	smso=^O,
-appleII|apple ii plus,
+appleII|Apple II plus,
 	OTbs, am,
 	cols#80, it#8, lines#24,
 	clear=^L, cnorm=^TC2, cub1=^H, cud1=\n, cuf1=^\,
@@ -20265,13 +20659,13 @@ appleII|apple ii plus,
 	is2=^TT1^N, kcud1=\n, kcuf1=^U, rmso=^N, sgr0=^N, smso=^O,
 # Originally by Gary Ford 21NOV83
 # From: <ee178aci%sdcc7@SDCSVAX.ARPA>  Fri Oct 11 21:27:00 1985
-apple-80|apple II with smarterm 80 col,
+apple-80|Apple II with smarterm 80 col,
 	OTbs, am, bw,
 	cols#80, lines#24,
 	cbt=^R, clear=\014$<10*/>, cr=\r$<10*/>, cub1=^H, cud1=\n,
 	cuf1=^\, cup=\036%p2%{32}%+%c%p1%{32}%+%c, cuu1=^_,
 	ed=\013$<10*/>, el=\035$<10/>, home=^Y,
-apple-soroc|apple emulating soroc 120,
+apple-soroc|Apple emulating Soroc 120,
 	am,
 	cols#80, lines#24,
 	bel=^G, clear=\E*$<300>, cr=\r, cub1=^H, cud1=\n, cuf1=^L,
@@ -20321,9 +20715,8 @@ apple-uterm|Ultraterm for Apple micros,
 apple80p|80-column apple with Pascal card,
 	am, bw,
 	cols#80, lines#24,
-	clear=^Y^L, cuf1=^\\:,
-	cup=\036%p2%{32}%+%c%p1%{32}%+%c, cuu1=^_, ed=^K, el=^],
-	home=^Y, kcub1=^H,
+	clear=^Y^L, cuf1=^\:, cup=\036%p2%{32}%+%c%p1%{32}%+%c,
+	cuu1=^_, ed=^K, el=^], home=^Y, kcub1=^H,
 #
 # Apple II+ equipped with Videx 80 column card
 #
@@ -20351,9 +20744,9 @@ apple-videx3|vapple|Apple II with 80 col card,
 	cols#80, lines#24,
 	clear=\Ev, cub1=\ED, cud1=\EB, cuf1=\EC,
 	cup=\EY%p1%{32}%+%c%p2%{32}%+%c, cuu1=\EA, el=\Ex,
-	home=\EH, kcub1=\ED, kcud1=\EB, kcuf1=\EC, kcuu1=\EA,
-	kf0=\EP, kf1=\EQ, kf2=\ER, kf3=\E\s, kf4=\E!, kf5=\E", kf6=\E#,
-	kf7=\E$, kf8=\E%%, kf9=\E&, khome=\EH,
+	home=\EH, kf0=\EP, kf1=\EQ, kf2=\ER, kf3=\E\s, kf4=\E!,
+	kf5=\E", kf6=\E#, kf7=\E$, kf8=\E%%, kf9=\E&, khome=\EH,
+	use=vt52+arrows,
 #From: decvax!cbosgd!cbdkc1!mww Mike Warren via BRL
 aepro|Apple II+ running ASCII Express Pro--vt52,
 	OTbs,
@@ -20362,10 +20755,10 @@ aepro|Apple II+ running ASCII Express Pro--vt52,
 	cup=\EY%p1%{32}%+%c%p2%{32}%+%c, cuu1=\EA, ed=\EJ,
 	el=\EK, home=\EH,
 # UCSD addition: Yet another termcap from Brian Kantor's Micro Munger Factory
-apple-vm80|ap-vm80|apple with viewmax-80,
+apple-vm80|ap-vm80|Apple with viewmax-80,
 	OTbs,
 	cols#80, lines#24,
-	clear=\014$<300/>, cuf1=^\\:,
+	clear=\014$<300/>, cuf1=^\:,
 	cup=\036%p1%{32}%+%c%p2%{32}%+%c$<100/>, cuu1=^_,
 	ed=\013$<300/>, el=^], home=\031$<200/>,
 
@@ -20373,17 +20766,17 @@ apple-vm80|ap-vm80|apple with viewmax-80,
 #
 
 # (lisa: changed <cvvis> to <cnorm> -- esr)
-lisa|apple lisa console display (black on white),
+lisa|Apple Lisa console display (black on white),
 	OTbs, am, eo, msgr,
 	cols#88, it#8, lines#32,
 	acsc=jdkclfmenbqattuvvuwsx`, civis=\E[5h, clear=^L,
-	cnorm=\E[5l, cub1=^H, cud1=\E[B, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, dch1=\E[P, dl1=\E[M,
-	ed=\E[J, el=\E[K, home=\E[H, ht=^I, ich1=\E[@, il1=\E[L,
-	is2=\E>\E[m\014, kbs=^H, kcub1=\E[D, kcud1=\E[B,
+	cnorm=\E[5l, cub1=^H, cup=\E[%i%p1%d;%p2%dH, dch1=\E[P,
+	dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H, ht=^I, ich1=\E[@,
+	il1=\E[L, is2=\E>\E[m\014, kbs=^H, kcub1=\E[D, kcud1=\E[B,
 	kcuf1=\E[C, kcuu1=\E[A, rmacs=\E[10m, rmso=\E[m, rmul=\E[m,
 	sgr0=\E[m, smacs=\E[11m, smso=\E[7m, smul=\E[4m,
-liswb|apple lisa console display (white on black),
+	use=ansi+local1,
+liswb|Apple Lisa console display (white on black),
 	is2=\E>\E[0;7m\014, rmso=\E[0;7m, rmul=\E[0;7m,
 	smso=\E[m, smul=\E[4m, use=lisa,
 
@@ -20393,25 +20786,24 @@ liswb|apple lisa console display (white on black),
 # These entries assume that the 'Auto Wraparound' is enabled.
 # Xon-Xoff flow control should also be enabled.
 #
-# The vt100 uses :rs2: and :rf: rather than :is2:/:tbc:/:hts: because the tab
+# The VT100 uses :rs2: and :rf: rather than :is2:/:tbc:/:hts: because the tab
 # settings are in non-volatile memory and don't need to be reset upon login.
 # Also setting the number of columns glitches the screen annoyingly.
 # You can type "reset" to get them set.
 #
-lisaterm|Apple Lisa or Lisa/2 running LisaTerm vt100 emulation,
+lisaterm|Apple Lisa or Lisa/2 running LisaTerm VT100 emulation,
 	OTbs, OTpt, am, xenl, xon,
 	OTkn#4, cols#80, it#8, lines#24, vt#3,
 	bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[2J, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A, ed=\E[J,
-	el=\E[K, home=\E[H, ht=^I, hts=\EH, ind=\n, kbs=^H, kcub1=\EOD,
+	cub1=^H, cud1=\n, cup=\E[%i%p1%d;%p2%dH, ed=\E[J, el=\E[K,
+	home=\E[H, ht=^I, hts=\EH, ind=\n, kbs=^H, kcub1=\EOD,
 	kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kf0=\EOP, kf1=\EOQ,
-	kf2=\EOR, kf3=\EOS, lf0=F1, lf1=F2, lf2=F3, lf3=F4, rc=\E8,
-	rev=\E[7m, ri=\EM, rmkx=\E[?1l\E>, rmso=\E[m, rmul=\E[m,
+	kf2=\EOR, kf3=\EOS, lf0=F1, lf1=F2, lf2=F3, lf3=F4, rev=\E[7m,
+	ri=\EM, rmkx=\E[?1l\E>, rmso=\E[m, rmul=\E[m,
 	rs1=\E>\E[?1l\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h\E[1;24r,
-	sc=\E7, sgr0=\E[m, smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m,
-	tbc=\E[3g,
+	sgr0=\E[m, smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m,
+	tbc=\E[3g, use=ansi+csr, use=ansi+local,
+
 # Lisaterm in 132 column ("wide") mode.
 lisaterm-w|Apple Lisa with Lisaterm in 132 column mode,
 	cols#132,
@@ -20439,12 +20831,12 @@ mac-w|macterminal-w|Apple Macintosh with MacTerminal in 132 column mode,
 coco3|os9LII|Tandy CoCo3 24*80 OS9 Level II,
 	OTbs, am,
 	cols#80, it#8, lines#24,
-	bel=^G, blink=^_", bold=\E\:\001, civis=^E\s,
+	bel=^G, blink=^_", bold=\E:^A, civis=^E\s,
 	clear=\014$<5*/>, cnorm=^E!, cub1=^H, cud1=\n, cuf1=^F,
 	cup=\002%p2%{32}%+%c%p1%{32}%+%c$<2/>, cuu1=^I,
 	dl1=^_1, ed=^K, el=^D, home=^A, il1=^_0, kcub1=^H, kcud1=\n,
 	kcuf1=^I, kcuu1=^L, rev=^_\s, rmso=^_!, rmul=^_#,
-	sgr0=\037!\E\:\0, smso=^_\s, smul=^_",
+	sgr0=\037!\E:\0, smso=^_\s, smul=^_",
 # (trs2: removed obsolete ":nl=^_:" -- esr)
 trs2|trsII|trs80II|Radio Shack Model II using P&T CP/M,
 	OTbs, am, msgr,
@@ -20465,11 +20857,11 @@ trs16|trs-80 model 16 console,
 	cnorm=\ERC, cr=\r, cub1=^H, cud1=\EB, cuf1=\EC,
 	cup=\EY%p1%{32}%+%c%p2%{32}%+%c, cuu1=\EA, dch1=\EQ,
 	dl1=\EM, ed=\EJ, el=\EK, home=\EH, ht=^I, ich1=\EP, il1=\EL,
-	ind=\n, kbs=^H, kcub1=\ED, kcud1=\EB, kcuf1=\EC, kcuu1=\EA,
-	kf0=^A, kf1=^B, kf2=^D, kf3=^L, kf4=^U, kf5=^P, kf6=^N, kf7=^S,
-	khome=^W, lf0=f1, lf1=f2, lf2=f3, lf3=f4, lf4=f5, lf5=f6, lf6=f7,
-	lf7=f8, mc4=\E]+, mc5=\E]=, rmacs=\ERg, rmso=\ER@, sgr0=\ER@,
-	smacs=\ERG, smso=\ERD,
+	ind=\n, kbs=^H, kf0=^A, kf1=^B, kf2=^D, kf3=^L, kf4=^U, kf5=^P,
+	kf6=^N, kf7=^S, khome=^W, lf0=f1, lf1=f2, lf2=f3, lf3=f4, lf4=f5,
+	lf5=f6, lf6=f7, lf7=f8, mc4=\E]+, mc5=\E]=, rmacs=\ERg,
+	rmso=\ER@, sgr0=\ER@, smacs=\ERG, smso=\ERD,
+	use=vt52+arrows,
 
 #### Commodore Business Machines
 #
@@ -20502,18 +20894,16 @@ amiga|Amiga ANSI,
 	OTbs, am, bw, xenl,
 	cols#80, lines#24,
 	acsc=, bel=^G, blink=\E[7;2m, bold=\E[1m, cbt=\E[Z,
-	civis=\E[0 p, clear=\E[H\E[J, cnorm=\E[ p, cub=\E[%p1%dD,
-	cub1=\E[D, cud=\E[%p1%dB, cud1=\E[B, cuf=\E[%p1%dC,
-	cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA,
-	cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m,
-	dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H,
-	ich=\E[%p1%d@, ich1=\E[@, il=\E[%p1%dL, il1=\E[L, ind=\E[S,
-	invis=\E[8m, is2=\E[20l, kbs=^H, kcub1=\E[D, kcud1=\E[B,
-	kcuf1=\E[C, kcuu1=\E[A, kf0=\E[9~, kf1=\E[0~, kf2=\E[1~,
-	kf3=\E[2~, kf4=\E[3~, kf5=\E[4~, kf6=\E[5~, kf7=\E[6~,
-	kf8=\E[7~, kf9=\E[8~, rev=\E[7m, ri=\E[T, rmacs=^O,
-	rmso=\E[m, rmul=\E[m, rs1=\Ec, sgr0=\E[m, smacs=^N,
-	smso=\E[7m, smul=\E[4m, use=ecma+index,
+	civis=\E[0 p, cnorm=\E[ p, cup=\E[%i%p1%d;%p2%dH,
+	dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m, home=\E[H,
+	ich=\E[%p1%d@, ich1=\E[@, ind=\E[S, invis=\E[8m,
+	is2=\E[20l, kbs=^H, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C,
+	kcuu1=\E[A, kf0=\E[9~, kf1=\E[0~, kf2=\E[1~, kf3=\E[2~,
+	kf4=\E[3~, kf5=\E[4~, kf6=\E[5~, kf7=\E[6~, kf8=\E[7~,
+	kf9=\E[8~, rev=\E[7m, ri=\E[T, rmacs=^O, rmso=\E[m,
+	rmul=\E[m, rs1=\Ec, sgr0=\E[m, smacs=^N, smso=\E[7m,
+	smul=\E[4m, use=ansi+erase, use=ansi+idl, use=ansi+local,
+	use=ecma+index,
 
 # From: Hans Verkuil <hans@wyst.hobby.nl>, 4 Dec 1995
 # (amiga: added empty <acsc> to suppress a warning.
@@ -20556,17 +20946,13 @@ amiga-vnc|Amiga using VNC console (black on light gray),
 	am, da, db, msgr, ndscr,
 	btns#1, colors#16, cols#80, lines#24, lm#0, ncv#0, pairs#0x100,
 	bel=^G, blink=\E[7;2m, bold=\E[1m, civis=\E[0p,
-	clear=\E[H\E[J, cnorm=\E[p\E[>?6l, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=\E[D,
-	cud=\E[%p1%dB, cud1=\E[B, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	cvvis=\E[>?6h, dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m,
-	dl=\E[%p1%dM, dl1=\E[1M, ed=\E[J, el=\E[K, flash=^G,
+	cnorm=\E[p\E[>?6l, cr=\r, csr=\E[%i%p1%d;%p2%dr,
+	cup=\E[%i%p1%d;%p2%dH, cvvis=\E[>?6h, dch=\E[%p1%dP,
+	dch1=\E[P, dim=\E[2m, dl=\E[%p1%dM, dl1=\E[1M, flash=^G,
 	ich=\E[%p1%d@, ich1=\E[@, il=\E[%p1%dL, il1=\E[1L, ind=\ED,
 	invis=\E8m,
 	is2=\E[>?2;18l\E[>?26;?6;20;>?15;?7;>?22;>?8h,
-	kbs=^H, kcbt=\233Z, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C,
-	kcuu1=\E[A, kdch1=^?, kf0=\E[9~, kf1=\E[0~, kf2=\E[1~,
+	kcbt=\233Z, kdch1=^?, kf0=\E[9~, kf1=\E[0~, kf2=\E[1~,
 	kf3=\E[2~, kf4=\E[3~, kf5=\E[4~, kf6=\E[5~, kf7=\E[6~,
 	kf8=\E[7~, kf9=\E[8~, khlp=\E[?~, khome=\E[44~, kll=\E[45~,
 	kmous=\E[M, knp=\E[42~, kpp=\E[41~, nel=\EE, oc=\E[0m,
@@ -20576,7 +20962,8 @@ amiga-vnc|Amiga using VNC console (black on light gray),
 	setab=\E[%?%p1%{8}%>%t%'F'%p1%+%d%e4%p1%d%;m,
 	setaf=\E[%?%p1%{8}%>%t%'2'%p1%+%d%e3%p1%d%;m,
 	sgr0=\E[0m\017\E[30;85;>15m, smcup=\E[?7h, smkx=\E[?1h,
-	smso=\E[1m, smul=\E[4m, use=ecma+index,
+	smso=\E[1m, smul=\E[4m, use=ansi+arrows, use=ansi+erase,
+	use=ansi+local, use=ecma+index,
 
 # MorphOS on Genesi Pegasos
 # By Pavel Fedin <sonic_amiga@rambler.ru>
@@ -20632,7 +21019,7 @@ northstar|North Star Advantage,
 # with most systems.
 #
 # The tab is destructive on the Ozzie; make sure to 'stty -tabs'.
-osborne-w|osborne1-w|osborne I in 104-column mode,
+osborne-w|osborne1-w|Osborne I in 104-column mode,
 	msgr, ul, xt,
 	cols#104, lines#24,
 	bel=^G, clear=^Z, cr=\r, cub1=^H, cud1=\n, cuf1=^L,
@@ -20640,7 +21027,7 @@ osborne-w|osborne1-w|osborne I in 104-column mode,
 	dl1=\ER, el=\ET, ich1=\EQ, il1=\EE, ind=\n, kcub1=^H, kcud1=\n,
 	kcuf1=^L, kcuu1=^K, rmso=\E(, rmul=\Em, smso=\E), smul=\El,
 # Osborne I	from ptsfa!rhc (Robert Cohen) via BRL
-osborne|osborne1|osborne I in 80-column mode,
+osborne|osborne1|Osborne I in 80-column mode,
 	OTbs, am, mir, msgr, ul, xhp,
 	OTdB#4, cols#80, lines#24,
 	clear=^Z, cub1=\010$<4>, cud1=\n, cuf1=^L,
@@ -20681,6 +21068,7 @@ osexec|Osborne executive,
 # See
 #	https://web.archive.org/web/20120703021949/http://www.minix3.org/manpages/html4/console.html
 minix|minix console (v3),
+	NQ,
 	acsc=+\020\,\021-\030.^Y0\333`\004a\261f\370g\361h\260j
 	     \331k\277l\332m\300n\305o~p\304q\304r\304s_t\303u\264v
 	     \301w\302x\263y\363z\362{\343|\330}\234~\376,
@@ -20704,36 +21092,23 @@ minix-3.0|minix console (v3.0),
 
 # See
 #	https://web.archive.org/web/20030914201935/http://www.minix-vmd.org/pub/Minix-vmd/1.7.0/wwwman/man4/console.4.html
-# This is the entry provided with minix 1.7.4, with bogus :ri: removed.
+# This matches the entry provided with minix 1.7.4, with bogus :ri: removed.
 minix-1.7|minix console (v1.7),
-	am, xenl,
-	cols#80, it#8, lines#25,
-	bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[0J, cr=\r,
-	cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\E[B,
-	cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
-	cuu=\E[%p1%dA, cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[P,
-	dl=\E[%p1%dM, dl1=\E[M, ed=\E[0J, el=\E[K, el1=\E[2K,
-	home=\E[H, ht=^I, ich=\E[%p1%d@, ich1=\E[@, il=\E[%p1%dL,
-	il1=\E[L, ind=\n, is2=\E[0m, kbs=^H, kcub1=\E[D, kcud1=\E[B,
-	kcuf1=\E[C, kcuu1=\E[A, kf0=\E[Y, kf1=\E[V, kf2=\E[U,
-	kf3=\E[T, kf4=\E[S, kf5=\E[G, khome=\E[H, lf0=End, lf1=PgUp,
-	lf2=PgDn, lf3=Num +, lf4=Num -, lf5=Num 5, nel=\r\n,
-	rev=\E[7m, ri=\EM, rmso=\E[0m, rmul=\E[0m, sgr0=\E[0m,
-	smso=\E[7m, smul=\E[4m,
+	am, xenl, xon@,
+	el1=\E[2K, is2=\E[0m, lf0=End, lf1=PgUp, lf2=PgDn, lf3=Num +,
+	lf4=Num -, lf5=Num 5, use=minix-1.5,
 # Corrected Jan 14, 1997 by Vincent Broman <broman@nosc.mil>
 minix-old|minix-1.5|minix console (v1.5),
-	xon,
+	xon, NQ,
 	cols#80, it#8, lines#25,
 	bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[0J, cr=\r,
-	cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\E[B,
-	cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
-	cuu=\E[%p1%dA, cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[P,
-	dl=\E[%p1%dM, dl1=\E[M, ed=\E[0J, el=\E[K, home=\E[H, ht=^I,
-	ich=\E[%p1%d@, ich1=\E[@, il=\E[%p1%dL, il1=\E[L, ind=\n,
-	kbs=^H, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
-	kf0=\E[Y, kf1=\E[V, kf2=\E[U, kf3=\E[T, kf4=\E[S, kf5=\E[G,
-	khome=\E[H, nel=\r\n, rev=\E[7m, ri=\EM, rmso=\E[0m,
+	cub1=^H, cup=\E[%i%p1%d;%p2%dH, dch=\E[%p1%dP, dch1=\E[P,
+	ed=\E[0J, el=\E[K, home=\E[H, ht=^I, ich=\E[%p1%d@,
+	ich1=\E[@, ind=\n, kf0=\E[Y, kf1=\E[V, kf2=\E[U, kf3=\E[T,
+	kf4=\E[S, kf5=\E[G, nel=\r\n, rev=\E[7m, ri=\EM, rmso=\E[0m,
 	rmul=\E[0m, sgr0=\E[0m, smso=\E[7m, smul=\E[4m,
+	use=ansi+arrows, use=ansi+idl, use=ansi+local,
+
 # The linewrap option can be specified by editing /usr/include/minix/config.h
 # before recompiling the minix 1.5 kernel.
 minix-old-am|minix console with linewrap,
@@ -20751,12 +21126,12 @@ pc-coherent|pcz19|coherent|IBM PC console running Coherent,
 	cols#80, it#8, lines#25,
 	bel=^G, clear=\EE, cr=\r, cub1=^H, cud1=\EB, cuf1=\EC,
 	cup=\EY%p1%{32}%+%c%p2%{32}%+%c, cuu1=\EA, dch1=\EN,
-	ed=\EJ, el=\EK, home=\EH, ht=^I, ind=\n, kbs=^H, kcub1=\ED,
-	kcud1=\EB, kcuf1=\EC, kcuu1=\EA, khome=\EH, ri=\EI, rmir=\EO,
-	rmso=\Eq, sgr0=\Eq, smir=\E@, smso=\Ep,
+	ed=\EJ, el=\EK, home=\EH, ht=^I, ind=\n, kbs=^H, khome=\EH,
+	ri=\EI, rmir=\EO, rmso=\Eq, sgr0=\Eq, smir=\E@, smso=\Ep,
+	use=vt52+arrows,
 
 # According to the Venix 1.1 manual, the PC console is similar
-# to a DEC vt52.  Differences seem to be (1) arrow keys send
+# to a DEC VT52.  Differences seem to be (1) arrow keys send
 # different strings, (2) enhanced standout, (3) added insert/delete line.
 # Note in particular that it doesn't have automatic margins.
 # There are other keys (f1-f10, kpp, knp, kcbt, kich1, kdch1) but they
@@ -20781,20 +21156,21 @@ pc-venix|venix|IBM PC console running Venix,
 # wrap mode is reset by <cvvis>.  Using <ind>=\E[S caused errors so I
 # used \ED instead.
 # From: bf347@lafn.org (David Lawyer), 28 Jun 1997
-mai|basic4|MAI Basic Four in ansi mode,
+mai|basic4|MAI Basic Four in ANSI mode,
 	am, da, db, mir, msgr,
 	cols#82, it#8, lines#25,
 	bel=^G, blink=\E[5m, bold=\E[1m, clear=^]^_, cnorm=\E[?7h,
-	cr=\r, csr=\E[%i%p1%d;%p2%dr, cub1=^H, cud1=\n, cuf1=^X,
-	cup=\E[%i%p1%d;%p2%dH, cuu1=^Z, cvvis=\E[?7l, dch1=\E[1P,
-	dl1=\E[M, ed=^_, el=^^, home=^], ht=^I,
-	if=/usr/share/tabset/vt100, il1=\E[L, ind=\ED,
+	cr=\r, cub1=^H, cud1=\n, cuf1=^X, cup=\E[%i%p1%d;%p2%dH,
+	cuu1=^Z, cvvis=\E[?7l, dch1=\E[1P, dl1=\E[M, ed=^_, el=^^,
+	home=^], ht=^I, if=/usr/share/tabset/vt100, il1=\E[L,
+	ind=\ED,
 	is2=\E>\E[?1h\E[?7h\E[?5l\017\E(B\E[m\E[20l\E[1;24r\E[24;1H,
 	kbs=^H, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
 	kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf5=\EOT, kf6=\EOU,
-	kf7=\EOV, kf8=\EOW, nel=\r\ED, rc=\E8, rev=\E[7m, ri=\E[T,
-	rmir=\E[4l, rmso=\E[m, rmul=\E[m, sc=\E7, sgr0=\E[m,
-	smir=\E[4h, smso=\E[7m, smul=\E[4m,
+	kf7=\EOV, kf8=\EOW, nel=\r\ED, rev=\E[7m, ri=\E[T,
+	rmir=\E[4l, rmso=\E[m, rmul=\E[m, sgr0=\E[m, smir=\E[4h,
+	smso=\E[7m, smul=\E[4m, use=ansi+csr,
+
 # basis from Peter Harrison, Computer Graphics Lab, San Francisco
 #   ucbvax!ucsfmis!harrison ...uucp / ucbvax!ucsfmis!harrison@BERKELEY ...ARPA
 #
@@ -20813,8 +21189,7 @@ mai|basic4|MAI Basic Four in ansi mode,
 # (basis: removed obsolete ":ma=^K^P^R^L^L :nl=5000*^J:" -- esr)
 basis|BASIS108 computer with terminal translation table active,
 	clear=\E*$<300/>, cud1=\n$<5000/>, ed=\EY, el=\ET, kbs=^H,
-	kcub1=^H, kcud1=\n, kcuf1=^L, kcuu1=^K, rmso=\E), sgr0=\E),
-	smso=\E(, use=adm3a,
+	rmso=\E), sgr0=\E), smso=\E(, use=adm3a,
 # luna's BMC terminal emulator
 luna|luna68k|LUNA68K Bitmap console,
 	cols#88, lines#46, use=ansi-mini,
@@ -20845,24 +21220,20 @@ m2-nam|minitel|minitel-2|minitel-2-nam|France Telecom Minitel 2 mode te'le'infor
 	OTbs, eslok, hs, xenl,
 	cols#80, it#8, lines#24, wsl#72, xmc#0,
 	acsc=aaffggjjkkllmmnnooqqssttuuvvwwxx, bel=^G,
-	blink=\E[5m, bold=\E[1m, civis=\E[<1h, clear=\E[H\E[J,
-	cnorm=\E[<1l, cr=\r, csr=\E[%i%p1%d;%p2%dr,
-	cub=\E[%p1%dD, cub1=\E[D, cud=\E[%p1%dB, cud1=\E[B,
-	cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
-	cuu=\E[%p1%dA, cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[P,
-	dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K, flash=^G, fsl=\n,
-	home=\E[H, ht=^I, il=\E[%p1%dL, il1=\E[L, ind=\n, ip=$<7/>,
-	is1=\E\:1}\Ec\E[?4l\E[12h, is2=\Ec\E[12h\E)0,
-	is3=\E[?3l, kbs=^H, kclr=\E[2J, kcub1=\E[D, kcud1=\E[B,
-	kcuf1=\E[C, kcuu1=\E[A, kdch1=\E[P, kdl1=\E[M, kf0=\EOp,
+	blink=\E[5m, bold=\E[1m, civis=\E[<1h, cnorm=\E[<1l, cr=\r,
+	cup=\E[%i%p1%d;%p2%dH, dch=\E[%p1%dP, dch1=\E[P,
+	flash=^G, fsl=\n, home=\E[H, ht=^I, ind=\n, ip=$<7/>,
+	is1=\E:1}\Ec\E[?4l\E[12h, is2=\Ec\E[12h\E)0,
+	is3=\E[?3l, kclr=\E[2J, kdch1=\E[P, kdl1=\E[M, kf0=\EOp,
 	kf1=\EOq, kf10=\EOp, kf2=\EOr, kf3=\EOs, kf4=\EOt, kf5=\EOu,
-	kf6=\EOv, kf7=\EOw, kf8=\EOx, kf9=\EOy, khome=\E[H,
-	kich1=\E[4h, kil1=\E[4l, knp=\EOn, kpp=\EOR, ll=\E[24;80H,
-	mc0=\E[i, nel=\r\n, rc=\E8, rev=\E[7m, ri=\EM, rmacs=^O,
-	rmir=\E[4l, rmso=\E[27m, rmul=\E[24m,
-	rs1=\Ec\E[?4l\E[12h, rs2=\Ec\E)0, sc=\E7, sgr0=\E[m,
-	smacs=^N, smir=\E[4h, smso=\E[7m, smul=\E[4m, tsl=^_@A,
-	u6=\E[%i%d;%dR, u7=\E[6n,
+	kf6=\EOv, kf7=\EOw, kf8=\EOx, kf9=\EOy, kich1=\E[4h,
+	kil1=\E[4l, knp=\EOn, kpp=\EOR, ll=\E[24;80H, mc0=\E[i,
+	nel=\r\n, rev=\E[7m, ri=\EM, rmacs=^O, rmir=\E[4l,
+	rmso=\E[27m, rmul=\E[24m, rs1=\Ec\E[?4l\E[12h,
+	rs2=\Ec\E)0, sgr0=\E[m, smacs=^N, smir=\E[4h, smso=\E[7m,
+	smul=\E[4m, tsl=^_@A, use=ansi+arrows, use=ansi+cpr,
+	use=ansi+csr, use=ansi+erase, use=ansi+idl,
+	use=ansi+local,
 
 # From: Alexandre Montaron <canal@mygale.org>, 18 Jun 1998, updated 19 Sep 2016
 #
@@ -20874,7 +21245,7 @@ minitel1|minitel 1,
 	cup=\037%p1%'A'%+%c%p2%'A'%+%c, cuu1=^K,
 	dsl=\037@A\030\n, el=^X,
 	flash=\037@A\EW \177\022\177\022P\r\030\n, fsl=\n,
-	home=^^, ind=\n, is2=\E;`ZQ\E\:iC\E\:iE\021, kbs=^SG,
+	home=^^, ind=\n, is2=\E;`ZQ\E:iC\E:iE\021, kbs=^SG,
 	kcan=^SE, kend=^SI, kent=^SA, khlp=^SD, knp=^SH, kpp=^SB,
 	krfr=^SC, nel=\r\n, op=\EG, rep=%p1%c\022%p2%'?'%+%c,
 	rev=\E], ri=^K, rmso=\E\\,
@@ -20908,27 +21279,26 @@ minitel1|minitel 1,
 	   \177\,--,
 minitel1b|minitel 1-bistandard (in 40cols mode),
 	mir,
-	cub=\E[%p1%dD, cud=\E[%p1%dB, cuf=\E[%p1%dC,
-	cuu=\E[%p1%dA, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM,
-	dl1=\E[M, ed=\E[J, el1=\E[1K, il=\E[%p1%dL, il1=\E[L,
-	is1=\E;iYA\E;jYC, kbs@, kcan@, kclr=\E[2J, kctab=^I,
-	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kdch1=\E[P,
-	kdl1=\E[M, kent@, kf1=^SD, kf10=^Y0, kf11=^Y1, kf12=^Y/,
-	kf13=^Y{1, kf14=^Y{2, kf15=^Y{3, kf16=^Y{4, kf17=^Y{5,
-	kf18=^Y{6, kf19=^Y{7, kf2=^SC, kf20=^Y{8, kf21=^Y{9,
-	kf22=^Y{0, kf23=^Y{*, kf24=^Y{#, kf3=^SF, kf4=^SA, kf5=^SG,
-	kf6=^SE, kf7=^Y8, kf8=^Y\,, kf9=^Y., khlp@, khome=\E[H,
-	kich1=\E[4h, kil1=\E[L, krfr@, lf1=Guide, lf2=Repetition,
-	lf3=Sommaire, lf4=Envoi, lf5=Correction, lf6=Annulation,
-	rmir=\E[4l, smir=\E[4h,
-	u8=\001%[ABCPtuvwxyz0123456789\:;<=>?]\004,
+	cub1=^H, cud1=\n, cuf1=^I, cuu1=^K, dch=\E[%p1%dP, dch1=\E[P,
+	ed=\E[J, el1=\E[1K, is1=\E;iYA\E;jYC, kbs@, kcan@,
+	kclr=\E[2J, kctab=^I, kdch1=\E[P, kdl1=\E[M, kent@, kf1=^SD,
+	kf10=^Y0, kf11=^Y1, kf12=^Y/, kf13=^Y{1, kf14=^Y{2,
+	kf15=^Y{3, kf16=^Y{4, kf17=^Y{5, kf18=^Y{6, kf19=^Y{7,
+	kf2=^SC, kf20=^Y{8, kf21=^Y{9, kf22=^Y{0, kf23=^Y{*,
+	kf24=^Y{#, kf3=^SF, kf4=^SA, kf5=^SG, kf6=^SE, kf7=^Y8,
+	kf8=^Y\,, kf9=^Y., khlp@, kich1=\E[4h, kil1=\E[L, krfr@,
+	lf1=Guide, lf2=Repetition, lf3=Sommaire, lf4=Envoi,
+	lf5=Correction, lf6=Annulation, rmir=\E[4l, smir=\E[4h,
+	u8=\001%[ABCPtuvwxyz0123456789:;<=>?]\004,
 	.ich=\E[%p1%d@, .ich1=\E[@, .kLFT=\E[P, .kRIT=\E[4h,
-	.kb2=^Y{g, .kcbt=^Y{i, .kel=^X, .mc0=\E\:|k, .rmkx=\E;jYA,
+	.kb2=^Y{g, .kcbt=^Y{i, .kel=^X, .mc0=\E:|k, .rmkx=\E;jYA,
 	.rs1=\E[4l\E[2l, .smkx=\E;iYA\E;jYC, .u8=^ACu<^D,
+	use=ansi+arrows, use=ansi+idl, use=ansi+local,
 	use=minitel1,
+
 # rmkx posait des problemes (logout en sortant de vi).
 minitel1b-80|minitel 1-bistandard (standard teleinformatique),
-	am@, bw@, eslok@, hz@, msgr, G0,
+	am@, bw@, eslok@, hz@, msgr,
 	colors@, cols#80, it#8, pairs@,
 	acsc@, blink=\E[5m, bold=\E[1m, civis=\037@A\024\n,
 	clear=\E[H\E[J, cnorm=\037@A\021\n, cuf1=\E[C,
@@ -20959,7 +21329,6 @@ minitel1b-80|minitel 1-bistandard (standard teleinformatique),
 	.sgr=\E[%?%p1%t7;%;%?%p2%t4;%;%?%p3%t7;%;%?%p4%t5;%;%?%p6%t1
 	     ;%;m,
 	.smacs=^N, C0=}#f[j+k+l+m+n+o~q=s_t+u+v+w+x!0\032,
-	E0=^O, S0=^N,
 	XC=B\016%\017\,\243#\,\247]\,\260[\,\340@\,\347\\\\\,\351{\,
 	   \350}\,\371|\,\300A\,\301A\,\302A\,\303A\,\304A\,\305A\,
 	   \306E\,\307C\,\310E\,\311E\,\312E\,\313E\,\314I\,\315I\,
@@ -21010,11 +21379,10 @@ minitel1b-nb|minitel 1b (40cols) noir & blanc sans couleurs avec bold et dim ...
 #
 # Fonctionne par exemple avec Midnight Commander (mc).
 
-minitel2-80|minitel 2 (80cols) avec filets vt100 (DEC),
-	G0,
+minitel2-80|minitel 2 (80cols) avec filets VT100 (DEC),
 	acsc=ffggjjkkllmmnnooqqssttuuvvwwxxyyzz||}},
 	enacs=\E)0, rmacs=^O, smacs=^N, u6=\E[%i%d;%dR,
-	C0=ffggjjkkllmmnnooqqssttuuvvwwxxyyzz||}}, E0=^O,
+	C0=ffggjjkkllmmnnooqqssttuuvvwwxxyyzz||}},
 	S0=\E)0\016,
 	XC=B%\E(B\,\243\E(3}\,\247\E(R[\,\257\E(3v\,\260\E(3f\,\261
 	   \E(3g\,\265\E(3Y\,\267\E(3~\,\274\E(3O\,\275\E(3P\,\276
@@ -21032,7 +21400,6 @@ minitel2-80|minitel 2 (80cols) avec filets vt100 (DEC),
 	use=minitel12-80,
 
 minitel12-80|minitel 12 (80cols),
-	G0,
 	civis=\E[<1h, cnorm=\E[<1l, is2=\E[12h, u6=\E[%i%d;%dH,
 	u7=\E[6n,
 	.acsc=ffggj+k+l+m+n+ovq-swt+u+v+w+xx}}\,m+k.l-j0
@@ -21040,7 +21407,7 @@ minitel12-80|minitel 12 (80cols),
 	.enacs=\E)3, .rmacs=^O, .rs3=\E[?4l, .scs=\E(%p1%c,
 	.smacs=^N,
 	C0=ffggj+k+l+m+n+ovq-swt+u+v+w+xx}}\,m+k.l-j0\177,
-	E0=^O, S0=\E)3\016,
+	S0=\E)3\016,
 	XC=B%\E(B\,\243\E(3}\,\247\E(R[\,\257\E(3v\,\260\E(3f\,\261
 	   \E(3g\,\267\E(3~\,\274\E(3O\,\275\E(3P\,\276\E(3Q\,\300A
 	   \,\301A\,\302A\,\303A\,\304A\,\305A\,\306E\,\307C\,\310E
@@ -21076,8 +21443,8 @@ screen.minitel1|Screen specific for minitel1,
 	acsc=++\,\,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxy
 	     yzz||}}~~,
 	bel=\007\E\^ \E\\, bold@, csr@, flash=\Eg\E\^ \E\\, kmous@,
-	rmul@, smul@, u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?1;2c, u9=\EZ,
-	use=xterm+x11mouse, use=screen4,
+	rmul@, smul@, u8=\E[?1;2c, use=decid+cpr,
+	use=xterm+x11mouse, use=screen,
 
 screen.minitel1b|Screen specific for minitel1b,
 	kclr=\E[2J, kdl1=\E[M, kf13=^Y{1, kf14=^Y{2, kf15=^Y{3,
@@ -21094,7 +21461,7 @@ screen.minitel1b-80|screen.minitel2-80|screen.minitel12-80|Screen specific for m
 
 screen.minitel1-nb|Screen specific for minitel1-nb,
 	colors@, ncv@, pairs@,
-	bold=\E[1m, dim=\E[2m, op@, setab@, setaf@, setb@, setf@,
+	bold=\E[1m, op@, setab@, setaf@, setb@, setf@,
 	use=screen.minitel1,
 
 screen.minitel1b-nb|Screen specific for minitel1b-nb,
@@ -21106,30 +21473,26 @@ screen.minitel1b-nb|Screen specific for minitel1b-nb,
 
 linux-m1|Linux Minitel 1 "like" Couleurs,
 	am, bw@, ccc, mir, msgr, xenl,
-	colors#8, it#8, ncv#16, pairs#64,
+	it#8, ncv#16,
 	acsc=a\261f\370g\361h\260j\274k\273l\311m\310n\316q\315t
 	     \314u\271v\312w\313x\272y\363z\362{\343|\252~\372,
-	bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[J, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub1=^H, cud1=\n, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, dch=\E[%p1%dP,
-	dch1=\E[P, dim=\E[2m, dl=\E[%p1%dM, dl1=\E[M,
-	ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K, enacs=\E)U,
-	flash=\E[?5h$<100/>\E[?5l, home=\E[H, hpa=\E[%i%p1%d`,
-	ht=^I, hts=\EH, il=\E[%p1%dL, il1=\E[L, ind=\n,
+	bel=^G, blink=\E[5m, bold=\E[1m, cr=\r, cub1=^H, cud1=\n,
+	dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m, ech=\E[%p1%dX,
+	el1=\E[1K, enacs=\E)U, flash=\E[?5h$<100/>\E[?5l,
+	hpa=\E[%i%p1%d`, ht=^I, hts=\EH, ind=\n,
 	initc=\E]P%p1%{15}%&%X%p2%{255}%&%02X%p3%{255}%&%02X%p4
 	      %{255}%&%02X,
 	is2=\E]R\E]P3FFFF80\E[?8c, ka1=\EOw, ka3=\EOy, kb2=\E[G,
-	kbs=^?, kc1=\EOq, kc3=\EOs, kcbt=\E^I, kclr=\E\r, kcub1=\E[D,
-	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kdl1=\E\E[A, kent=\EOM,
-	kf1=\E[[A, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~,
-	kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, kf16=\E[29~,
-	kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, kf2=\E[[B,
-	kf20=\E[34~, kf3=\E[[C, kf4=\E[[D, kf5=\E[[E, kf6=\E[17~,
-	kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, kil1=\E\E[B,
-	kmous=\E[M, nel=\EE, oc=\E]R\E]P3FFFF80, op=\E[39;49m,
-	rc=\E8, rev=\E[7m, ri=\EM, rmacs=^O, rmam=\E[?7l, rmir=\E[4l,
-	rmpch=\E[10m, rmso=\E[27m, rs1=\Ec, rs3=\E[37;40m\E[8],
-	sc=\E7, setab=\E[4%p1%dm, setaf=\E[3%p1%dm, sgr0=\E[m,
+	kbs=^?, kc1=\EOq, kc3=\EOs, kcbt=\E^I, kclr=\E\r,
+	kdl1=\E\E[A, kent=\EOM, kf1=\E[[A, kf10=\E[21~,
+	kf11=\E[23~, kf12=\E[24~, kf13=\E[25~, kf14=\E[26~,
+	kf15=\E[28~, kf16=\E[29~, kf17=\E[31~, kf18=\E[32~,
+	kf19=\E[33~, kf2=\E[[B, kf20=\E[34~, kf3=\E[[C, kf4=\E[[D,
+	kf5=\E[[E, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~,
+	khome=\E[1~, kil1=\E\E[B, kmous=\E[M, nel=\EE,
+	oc=\E]R\E]P3FFFF80, op=\E[39;49m, rev=\E[7m, ri=\EM,
+	rmacs=^O, rmam=\E[?7l, rmir=\E[4l, rmpch=\E[10m,
+	rmso=\E[27m, rs1=\Ec, rs3=\E[37;40m\E[8], sgr0=\E[m,
 	smacs=^N, smam=\E[?7h, smir=\E[4h, smpch=\E[11m,
 	smso=\E[7m, tbc=\E[3g, vpa=\E[%i%p1%dd, .VN=\E[?5l,
 	.VR=\E[?5h, .am@, .ich=\E[%p1%d@, .ich1=\E[@, .ll=\E[99H,
@@ -21143,9 +21506,12 @@ linux-m1|Linux Minitel 1 "like" Couleurs,
 	   \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
 	   \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
 	   \n\n\n\n\n\n\n\n\n\n,
-	use=vt220+pcedit, use=vt220+cvis, use=linux+decid,
+	use=ansi+arrows, use=ansi+csr, use=ansi+cup,
+	use=ansi+erase, use=ansi+idl, use=ansi+local1,
+	use=klone+color, use=vt220+pcedit, use=vt220+cvis,
+	use=linux+decid,
 
-# 1. Using double-shapes for vt100 graphical chars (eg: mc).
+# 1. Using double-shapes for VT100 graphical chars (eg: mc).
 # 2. Native brown color corrected to good yellow color.
 # 3. Adding "Insert" and "Delete Line" keys as ESC Up and ESC Down arrow keys.
 # 4. Suppressed nonexistent underlined mode (normally as bright).
@@ -21178,8 +21544,7 @@ linux-m2|Linux Minitel 2 "like" Couleurs (Vert/Blanc/Noir+Bleu),
 	    900\E]P600A900\E]P700A900\E]P80000FF\E]P9FFFFFF\E]PAFFFF
 	    FF\E]PBFFFFFF\E]PCFFFFFF\E]PDFFFFFF\E]PEFFFFFF\E]PFFFFFF
 	    F\E[;37m,
-	oc@, op@, rmacs=^O, setab=^A, setaf=^A, sgr0=\E[;37m, smacs=^N,
-	.setab@, .setaf@,
+	oc@, op@, setab=^A, setaf=^A, sgr0=\E[;37m, .setab@, .setaf@,
 	.smcup=\E]R\E]P100A900\E]P200A900\E]P3FFFFFF\E]P400A900\E]P5
 	       00A900\E]P600A900\E]P700A900\E]P80000FF\E]P9FFFFFF\E]
 	       PAFFFFFF\E]PBFFFFFF\E]PCFFFFFF\E]PDFFFFFF\E]PEFFFFFF
@@ -21187,7 +21552,7 @@ linux-m2|Linux Minitel 2 "like" Couleurs (Vert/Blanc/Noir+Bleu),
 	use=linux-m1,
 
 # From: Alexandre Montaron, 27 May 2020
-linux-s|Linux Console with added status line at bottom,
+linux-s|Linux console with added status line at bottom,
 	hs,
 	clear=\E[255;255H\E[A\E[1J\E[H, csr@,
 	dsl=\E7\E[255H\E[K\E8, ed@, fsl=\E8,
@@ -21201,10 +21566,10 @@ linux-s|Linux Console with added status line at bottom,
 
 screen.linux-m1|Linux m1 specific for screen,
 	ncv@,
-	dim=\E[2m, kbs=^?, kclr=\E\r, kdl1=\E\E[A, kf13=\E[25~,
-	kf14=\E[26~, kf15=\E[28~, kf16=\E[29~, kf17=\E[31~,
-	kf18=\E[32~, kf19=\E[33~, kf20=\E[34~, kil1=\E\E[B, rmul@,
-	smul@, u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?1;2c, u9=\EZ,
+	kclr=\E\r, kdl1=\E\E[A, kf13=\E[25~, kf14=\E[26~,
+	kf15=\E[28~, kf16=\E[29~, kf17=\E[31~, kf18=\E[32~,
+	kf19=\E[33~, kf20=\E[34~, kil1=\E\E[B, rmul@, smul@,
+	u8=\E[?1;2c,
 	E3=\E[99H\E[2J\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
 	   \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
 	   \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
@@ -21213,7 +21578,7 @@ screen.linux-m1|Linux m1 specific for screen,
 	   \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
 	   \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
 	   \n\n\n\n\n\n\n\n\n\n,
-	use=xterm+x11mouse, use=screen4,
+	use=decid+cpr, use=xterm+x11mouse, use=screen,
 
 screen.linux-m1b|Linux m1b specific for screen,
 	colors@, pairs@,
@@ -21227,32 +21592,26 @@ screen.linux-m2|Linux m2 specific for screen,
 # Putty :
 
 putty-m1|Putty Minitel 1 "like" Couleurs,
-	hs,
 	dim@, kf1=\E[11~, kf2=\E[12~, kf3=\E[13~, kf4=\E[14~,
-	kf5=\E[15~, rmcup=\E[2J\E[?47l\E8, rmul=\E[24m,
-	smcup=\E7\E[?47h, smul=\E[4m, .E3=\E[300S,
-	use=putty+screen, use=xterm+sl-twm, use=ecma+index,
-	use=linux-m1,
+	kf5=\E[15~, rmul=\E[24m, smul=\E[4m, .E3=\E[300S,
+	use=xterm+alt47, use=putty+screen, use=xterm+sl-twm,
+	use=ecma+index, use=linux-m1,
 
 putty-m1b|Putty Minitel 1B "like" Monochrome (Gris/Blanc/Noir),
-	hs,
 	dim@, kf1=\E[11~, kf2=\E[12~, kf3=\E[13~, kf4=\E[14~,
-	kf5=\E[15~, rmcup=\E[2J\E[?47l\E8, rmul=\E[24m,
-	smcup=\E7\E[?47h, smul=\E[4m, .E3=\E[300S,
-	use=putty+screen, use=xterm+sl-twm, use=ecma+index,
-	use=linux-m1b,
+	kf5=\E[15~, rmul=\E[24m, smul=\E[4m, .E3=\E[300S,
+	use=xterm+alt47, use=putty+screen, use=xterm+sl-twm,
+	use=ecma+index, use=linux-m1b,
 
 putty-m2|Putty Minitel 2 "like" Couleurs (Vert/Blanc/Noir),
-	hs,
 	acsc=``aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{
 	     {||}}~~,
 	dim@, kf1=\E[11~, kf2=\E[12~, kf3=\E[13~, kf4=\E[14~,
-	kf5=\E[15~, rmcup=\E[2J\E[?47l\E8, rmul=\E[24m,
-	smcup=\E7\E[?47h, smul=\E[4m, .E3=\E[300S,
-	use=putty+screen, use=xterm+sl-twm, use=ecma+index,
-	use=linux-m2,
+	kf5=\E[15~, rmul=\E[24m, smul=\E[4m, .E3=\E[300S,
+	use=xterm+alt47, use=putty+screen, use=xterm+sl-twm,
+	use=ecma+index, use=linux-m2,
 
-putty+screen|PuTTY with screen resizing extensions,
+putty+screen|PuTTY with screen resizing extensions (building-block),
 	.WS=\E[8;%p1%d;%p2%dt, Z0=\E[?3h, Z1=\E[?3l,
 
 putty-screen|PuTTY with screen resizing extensions,
@@ -21274,7 +21633,7 @@ screen.putty-m2|Putty m2 specific for screen,
 # He comments:
 # viewdata lacks a true cup capability,
 # so I achieved it with home and cud1/cuf1 sequences only !
-viewdata|prestel/viewdata terminals,
+viewdata|Prestel/Viewdata terminals,
 	am, bw, eslok, hz,
 	cols#40, lines#24,
 	bel=^G, civis=^T, clear=^L, cnorm=^Q, cr=\r, cub1=^H, cud1=\n,
@@ -21290,7 +21649,7 @@ viewdata|prestel/viewdata terminals,
 	cuu1=^K, home=^^, nel=\r\n, rs2=^L, .el=^X, .ind=\n,
 	.rep=%p1%c\022%p2%'?'%+%c, .ri=^K,
 
-viewdata-o|optimized version of viewdata prestel/viewdata terminals,
+viewdata-o|optimized version of Viewdata Prestel/Viewdata terminals,
 	cup=\036%p1%?%p2%{20}%>%t%?%p1%{23}%=%t%Pa%{1}%e%{1}%+%;%;
 	    %Pa%?%ga%{13}%<%t%?%ga%{07}%>%t\n\n\n\n\n\n\n\n%;%?%ga
 	    %{4}%&%t\n\n\n\n%;%?%ga%{2}%&%t\n\n%;%?%ga%{1}%&%t\n%;%e
@@ -21308,7 +21667,7 @@ viewdata-o|optimized version of viewdata prestel/viewdata terminals,
 
 # Samples with TERM=viewdata and TERM=viewdata-rv: http://canal.chez.com/blog/
 
-viewdata-rv|prestel/viewdata terminals with reverse capabilitie (as green),
+viewdata-rv|Prestel/Viewdata terminals with reverse capabilitie (as green),
 	xmc#1,
 	rmso=\EG, smso=\EB, use=viewdata-o,
 
@@ -21360,8 +21719,8 @@ blit|jerq|blit running teletype rom,
 	cup=\EY%p2%{32}%+%c%p1%{32}%+%c, cuu1=\EA,
 	dch=\Ee%p1%{32}%+%c, dch1=\Ee!, dl=\EE%p1%{32}%+%c,
 	dl1=\EE!, el=\EK, ht=^I, ich=\Ef%p1%{32}%+%c, ich1=\Ef!,
-	il=\EF%p1%{32}%+%c, il1=\EF!, ind=\n, kbs=^H, kcub1=\ED,
-	kcud1=\EB, kcuf1=\EC, kcuu1=\EA, kf1=\Ex, kf2=\Ey, kf3=\Ez,
+	il=\EF%p1%{32}%+%c, il1=\EF!, ind=\n, kbs=^H, kf1=\Ex,
+	kf2=\Ey, kf3=\Ez, use=vt52+arrows,
 
 # (cbblit: here's a BSD termcap that says <cud1=\EG> -- esr)
 cbblit|fixterm|blit running columbus code,
@@ -21389,7 +21748,7 @@ oblit|ojerq|first version of blit rom,
 # The bitgraph was a large white box that contained a monochrome bitmap
 # display, and a 68000 to run it.  You could download code and run it on
 # the cpu, it had 128kb (I think) of memory.  I used one in the late
-# 70's, sure beat a vt100.  It had one strange feature tho -- it used
+# 70's, sure beat a VT100.  It had one strange feature tho -- it used
 # the cpu to bitblt pixels to scroll, it took longer than the refresh
 # rate, and looked like a rubber sheet stretching, then snapping
 # upwards.  It had everything the early mac had, except a floppy drive a
@@ -21409,41 +21768,39 @@ oblit|ojerq|first version of blit rom,
 # paints lines in on the bottom line of the screen, so you get
 # this big white gap.
 
-bitgraph|bg2.0nv|bg3.10nv|bbn bitgraph 2.0 or later (normal video),
+bitgraph|bg2.0nv|bg3.10nv|BBN BitGraph 2.0 or later (normal video),
 	flash=\E[?5h$<200/>\E[?5l, is2=\E>\E[?5l\E[?7h,
 	use=bg2.0,
-bg2.0rv|bg3.10rv|bbn bitgraph 2.0 (reverse video),
+bg2.0rv|bg3.10rv|BBn BitGraph 2.0 (reverse video),
 	flash=\E[?5l$<200/>\E[?5h, is2=\E>\E[?5h\E[?7h,
 	use=bg2.0,
-bg2.0|bg3.10|bbn bitgraph 2.0 or later (no init),
+bg2.0|bg3.10|BBN BitGraph 2.0 or later (no init),
 	OTbs, xenl,
 	cols#85, lines#64,
-	bel=^G, clear=\E[H\E[J$<150>, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub1=^H, cud1=\E[B, cuf1=\E[C,
-	cup=%i\E[%p1%d;%p2%dH, cuu1=\E[A, dl1=\E[M$<2*>,
-	ed=\E[J$<150>, el=\E[K$<2>, ht=^I, il1=\E[L$<2*>,
-	ind=\n$<280>, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C,
-	kcuu1=\E[A, kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, lf1=PF1,
-	lf2=PF2, lf3=PF3, lf4=PF4, rc=\E8, rmkx=\E>, rmso=\E[m, sc=\E7,
-	sgr0=\E[m, smkx=\E=, smso=\E[7m,
-
-bg1.25rv|bbn bitgraph 1.25 (reverse video),
+	bel=^G, clear=\E[H\E[J$<150>, cr=\r, cub1=^H,
+	cup=%i\E[%p1%d;%p2%dH, dl1=\E[M$<2*>, ed=\E[J$<150>,
+	el=\E[K$<2>, ht=^I, il1=\E[L$<2*>, ind=\n$<280>,
+	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kf1=\EOP,
+	kf2=\EOQ, kf3=\EOR, kf4=\EOS, lf1=PF1, lf2=PF2, lf3=PF3,
+	lf4=PF4, rmkx=\E>, rmso=\E[m, sgr0=\E[m, smkx=\E=,
+	smso=\E[7m, use=ansi+csr, use=ansi+local1,
+
+bg1.25rv|BBN BitGraph 1.25 (reverse video),
 	flash=\E[?5l$<200/>\E[?5h, is2=\E>\E[?5h\E[?7h,
 	use=bg1.25,
-bg1.25nv|bbn bitgraph 1.25 (normal video),
+bg1.25nv|BBN BitGraph 1.25 (normal video),
 	flash=\E[?5h$<200/>\E[?5l, is2=\E>\E[?5l\E[?7h,
 	use=bg1.25,
 # (bg1.25: I added <rmam>/<smam> based on the init string -- esr)
-bg1.25|bbn bitgraph 1.25,
+bg1.25|BBN BitGraph 1.25,
 	cols#85, lines#64,
-	bel=^G, clear=\E[H\E[J$<150>, cr=\r, cub1=^H, cud1=\E[B,
-	cuf1=\E[C, cup=%i\E[%p1%d;%p2%dH, cuu1=\E[A,
-	dl1=\E[M$<2*>, ed=\E[J$<150>, el=\E[K$<2>, ht=^I,
-	il1=\E[L$<2*>, ind=\n$<280>, kcub1=\ED, kcud1=\EB,
-	kcuf1=\EC, kcuu1=\EA, kf1=\EP, kf2=\EQ, kf3=\ER, kf4=\ES,
-	lf1=PF1, lf2=PF2, lf3=PF3, lf4=PF4, ll=\E[64;1H, rmam=\E[?7l,
-	rmkx=\E>, rmso=\E[m, sgr0=\E[m, smam=\E[?7h, smkx=\E=,
-	smso=\E[7m,
+	bel=^G, clear=\E[H\E[J$<150>, cr=\r, cub1=^H,
+	cup=%i\E[%p1%d;%p2%dH, dl1=\E[M$<2*>, ed=\E[J$<150>,
+	el=\E[K$<2>, ht=^I, il1=\E[L$<2*>, ind=\n$<280>, kf1=\EP,
+	kf2=\EQ, kf3=\ER, kf4=\ES, lf1=PF1, lf2=PF2, lf3=PF3, lf4=PF4,
+	ll=\E[64;1H, rmam=\E[?7l, rmkx=\E>, rmso=\E[m, sgr0=\E[m,
+	smam=\E[?7h, smkx=\E=, smso=\E[7m, use=ansi+local1,
+	use=vt52+arrows,
 
 #### Bull (bq, dku, vip)
 #
@@ -21514,45 +21871,44 @@ bg1.25|bbn bitgraph 1.25,
 # dku7102, tws2102, and tws models 2105 to 2112
 tws-generic|dku7102|Bull Questar tws terminals,
 	am, eslok, hs, mir, msgr, xenl, xhp@, xon,
-	cols#80, it#8, lines#24, wsl#80,
+	cols#80, lines#24, wsl#80,
 	acsc=``aaffggj)k\,l&m#n/ooppq*rrsst'u-v+w.x%yyzz{{||}}~~,
-	bel=^G, blink=\E[0;5m, cbt=\E[Z, civis=\E[1r, clear=\E[2J,
-	cnorm=\E[r, cr=\r, cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB,
-	cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%df,
-	cuu=\E[%p1%dA, cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[P,
-	dim=\E[0;2m, dl=\E[%p1%dM, dl1=\E[M,
-	dsl=\EPY99\:98\E\\\E[0;98v\E[2J\E[v, ed=\E[J, el=\E[K,
-	fsl=\E[v, home=\E[H, ht=\E[I, hts=\EH, il=\E[%p1%dL,
-	il1=\E[L, ind=\n, invis=\E[0;8m,
-	is1=\E[?=h\Ec\E`\E[?>h\EPY99\:98\E\\,
+	bel=^G, blink=\E[0;5m, civis=\E[1r, clear=\E[2J,
+	cnorm=\E[r, cr=\r, cub1=^H, cud1=\n, cup=\E[%i%p1%d;%p2%df,
+	dch=\E[%p1%dP, dch1=\E[P, dim=\E[0;2m,
+	dsl=\EPY99:98\E\\\E[0;98v\E[2J\E[v, fsl=\E[v,
+	home=\E[H, ht=\E[I, ind=\n, invis=\E[0;8m,
+	is1=\E[?=h\Ec\E`\E[?>h\EPY99:98\E\\,
 	is2=\E[5;>;12;18;?<l\E[=h\EP1s\E\\\E[\027p,
-	is3=\Eb\E[?<h, kbs=^H, kcbt=\E[Z, kctab=\E[g, kcub1=\E[D,
-	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kdch1=\E[P, kdl1=\E[M,
-	ked=\E[J, kel=\E[K, kf1=\E[1u\027, kf2=\E[2u\027,
-	kf3=\E[3u\027, kf4=\E[4u\027, kf5=\E[5u\027,
-	kf6=\E[6u\027, kf7=\E[7u\027, kf8=\E[8u\027, khome=\E[H,
-	khts=\EH, kil1=\E[L, krmir=\E[4l, ll=\E[H\E[A, mc0=\E[0i,
-	mc4=\r\E[4i, mc5=\E[5i, rev=\E[0;7m, rmacs=^O,
-	rmcup=\E[0;98v\E[2J\E[v, rmir=\E[4l, rmso=\E[m,
-	rmul=\E[m, rs2=\E[?=h\Ec, s0ds=^O, s1ds=^N,
+	is3=\Eb\E[?<h, kcbt=\E[Z, kctab=\E[g, kdch1=\E[P,
+	kdl1=\E[M, ked=\E[J, kel=\E[K, kf1=\E[1u\027,
+	kf2=\E[2u\027, kf3=\E[3u\027, kf4=\E[4u\027,
+	kf5=\E[5u\027, kf6=\E[6u\027, kf7=\E[7u\027,
+	kf8=\E[8u\027, khts=\EH, kil1=\E[L, krmir=\E[4l,
+	ll=\E[H\E[A, mc0=\E[0i, mc4=\r\E[4i, mc5=\E[5i,
+	rev=\E[0;7m, rmacs=^O, rmcup=\E[0;98v\E[2J\E[v,
+	rmir=\E[4l, rs2=\E[?=h\Ec, s0ds=^O, s1ds=^N,
 	sgr=\E[0%?%p1%p3%|%t;7%;%?%p2%t;4%;%?%p4%t;5%;%?%p5%t;2%;%?
 	    %p7%t;8%;m%?%p9%t\016%e\017%;,
-	sgr0=\E[m\017, smacs=^N, smcup=\E[?>h\EPY99\:98\E\\,
-	smir=\E[4h, smso=\E[0;7m, smul=\E[0;4m, tbc=\E[3g,
-	tsl=\EPY99\:98\E\\\E[0;98v\E[2;7m,
-tws2102-sna|dku7102-sna|BULL Questar tws2102 for SNA,
+	sgr0=\E[m\017, smacs=^N, smcup=\E[?>h\EPY99:98\E\\,
+	smir=\E[4h, smso=\E[0;7m, smul=\E[0;4m,
+	tsl=\EPY99:98\E\\\E[0;98v\E[2;7m, use=ansi+arrows,
+	use=ansi+erase, use=ansi+idl, use=ansi+inittabs,
+	use=ansi+local, use=ansi+sgrdim,
+
+tws2102-sna|dku7102-sna|Bull Questar tws2102 for SNA,
 	dsl=\E[0;98v\E[2J\E[v, fsl=\E[v, is3=\Eb, tsl=\E[0;98v,
 	use=tws-generic,
-tws2103|xdku|BULL Questar tws2103,
+tws2103|xdku|Bull Questar tws2103,
 	ht=^I, use=tws-generic,
-tws2103-sna|dku7103-sna|BULL Questar tws2103 for SNA,
+tws2103-sna|dku7103-sna|Bull Questar tws2103 for SNA,
 	ht=^I, use=tws2102-sna,
-dku7102-old|BULL Questar 200 DKU7102 (microcode version < 6),
+dku7102-old|Bull Questar 200 DKU7102 (microcode version < 6),
 	clear=\E[2J\E[H, cup@, dl@, dl1@,
-	dsl=\EPY99\:98\E\\\E[0;98v\E[2J\E[H\E[v, el=\E[K\E[m,
-	il@, il1@, tsl=\EPY99\:98\E\\\E[0;98v\E[H\E[2;7m,
+	dsl=\EPY99:98\E\\\E[0;98v\E[2J\E[H\E[v, el=\E[K\E[m,
+	il@, il1@, tsl=\EPY99:98\E\\\E[0;98v\E[H\E[2;7m,
 	use=tws-generic,
-dku7202|BULL Questar 200 DKU7202 (colour/character attributes),
+dku7202|Bull Questar 200 DKU7202 (colour/character attributes),
 	blink=\E[0;2;4m, dim=\E[0;5m, ht=^I, is3=\E[?3h\Eb,
 	sgr=\E[0%?%p1%t;2;4;5;7%;%?%p3%t;7%;%?%p2%t;2%;%?%p4%t;2;4%;
 	    %?%p5%t;5%;%?%p7%t;8%;m%?%p9%t\016%e\017%;,
@@ -21565,13 +21921,13 @@ dku7202|BULL Questar 200 DKU7202 (colour/character attributes),
 # Description written by J. Staerck (BULL SA)
 #       Copyright (c) 1989 BULL SA
 #---------------------------------------------------------------------------
-#  This entry is used for terminals with vt320 emulation mode
+#  This entry is used for terminals with VT320 emulation mode
 #  and following set-up :
 #    8 bit ISO Latin Character Set (ISO 8859-1),
 #    7 bit Control Characters,
 #    80 columns screen.
-#  Hereafter are some DEC vt terminals' commands. (valid on vt200 and 300)
-#  They are used in string capabilities with vt220-320 emulation mode.
+#  Hereafter are some DEC vt terminals' commands. (valid on VT200 and 300)
+#  They are used in string capabilities with VT220-320 emulation mode.
 #  In the following DEC definitions, two kinds of terminfo databases are
 #    provided :
 #    1. the first with Command Sequence Introducer starting with escape
@@ -21624,68 +21980,62 @@ dku7202|BULL Questar 200 DKU7202 (colour/character attributes),
 #	RM DECNKM numeric keypad appl.:	esc [ ? 6 6 l
 #	SM DECKBUM clavier informatique	esc [ ? 6 8 h
 #	RM DECKBUM clavier bureautique:	esc [ ? 6 8 l
-#	DECSCL vt300 mode 8-bit ctrl:	esc [ 6 3 " p
-# or	DECSCL vt300 mode 8-bit ctrl:	esc [ 6 3 ; 0 " p
-# or	DECSCL vt300 mode 8-bit ctrl:	esc [ 6 3 ; 2 " p
-#	DECSCL vt300 mode 7-bit ctrl:	esc [ 6 3 ; 1 " p
+#	DECSCL VT300 mode 8-bit ctrl:	esc [ 6 3 " p
+# or	DECSCL VT300 mode 8-bit ctrl:	esc [ 6 3 ; 0 " p
+# or	DECSCL VT300 mode 8-bit ctrl:	esc [ 6 3 ; 2 " p
+#	DECSCL VT300 mode 7-bit ctrl:	esc [ 6 3 ; 1 " p
 #	Char. and Line attributes:	esc [ Ps ... Ps m
 # with:  0 All off, 1 Bold, 4 Underline, 5 Blinking, 7 Reverse
 # and : 22 Bold off, 24 Underline off, 25 Blinking off, 27 Reverse off
 #
 
 # This entry covers BQ303, BQ306, BQ310, Q303, Q306, Q310
-bq300|Bull vt320 ISO Latin 1 80 columns terminal,
-	am, eo, eslok, hs, km, mir, msgr, xenl, xon,
-	cols#80, it#8, lines#24, vt#3, wsl#80,
-	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[J, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=\E[D,
-	cud=\E[%p1%dB, cud1=\E[B, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M,
-	dsl=\E[1$}\E[2$~\n\E[0$}, ech=\E[%p1%dX, ed=\E[J,
-	el=\E[K, el1=\E[1K, enacs=\E(B\E)0,
-	flash=\E[?5h$<50>\E[?5l, fsl=\E[0$}, home=\E[H, ht=^I,
-	hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L, ind=\ED,
-	is1=\E[63;1"p\E[2h,
+bq300|Bull VT320 ISO Latin 1 80 columns terminal,
+	eo, km, mir, xenl, xon,
+	vt#3, wsl#80,
+	blink=\E[5m, bold=\E[1m, cup=\E[%i%p1%d;%p2%dH,
+	dch=\E[%p1%dP, dch1=\E[P, dsl=\E[1$}\E[2$~\n\E[0$},
+	ech=\E[%p1%dX, el1=\E[1K, flash=\E[?5h$<50>\E[?5l,
+	ich=\E[%p1%d@, ind=\ED, is1=\E[63;1"p\E[2h,
 	is2=\E[?2h\E[?3l\E[?5l\E[?7h\E[?8h\E>\E[?1l\E\sF\E[?42l\E[?4
 	    l,
 	is3=\E[0$}\E[?25h\E[2l\E[H\E[J, ka1=\EOw, ka3=\EOy,
-	kb2=\EOu, kbs=^H, kc1=\EOq, kc3=\EOs, kcub1=\E[D, kcud1=\E[B,
-	kcuf1=\E[C, kcuu1=\E[A, kf1=\EOP, kf10=\E[21~, kf11=\E[23~,
-	kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, kf15=\E[28~,
-	kf16=\E[29~, kf17=\E[31~, kf18=\E[32~, kf19=\E[33~,
-	kf2=\EOQ, kf20=\E[34~, kf3=\EOR, kf4=\EOS, kf6=\E[17~,
-	kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, khlp=\E[28~,
-	krdo=\E[29~, lf1=pf1, lf2=pf2, lf3=pf3, lf4=pf4, nel=\EE,
-	rc=\E8, rev=\E[7m, ri=\EM, rmacs=\E(B, rmam=\E[?7l,
+	kb2=\EOu, kc1=\EOq, kc3=\EOs, kf1=\EOP, kf10=\E[21~,
+	kf11=\E[23~, kf12=\E[24~, kf13=\E[25~, kf14=\E[26~,
+	kf15=\E[28~, kf16=\E[29~, kf17=\E[31~, kf18=\E[32~,
+	kf19=\E[33~, kf2=\EOQ, kf20=\E[34~, kf3=\EOR, kf4=\EOS,
+	kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~,
+	khlp=\E[28~, krdo=\E[29~, lf1=pf1, lf2=pf2, lf3=pf3, lf4=pf4,
+	nel=\EE, rev=\E[7m, ri=\EM, rmacs=\E(B, rmam=\E[?7l,
 	rmcup=\E[?7h, rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[27m,
 	rmul=\E[24m, rs1=\E[!p, rs2=\E[?3l, s0ds=\E(B, s1ds=\E(0,
-	sc=\E7,
 	sgr=\E[%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p6%t;1
 	    %;m%?%p9%t\E(0%e\E(B%;,
 	sgr0=\E[0m\E(B, smacs=\E(0, smam=\E[?7h,
 	smcup=\E[?7l\E[?1l\E(B, smir=\E[4h, smso=\E[7m,
-	smul=\E[4m, tbc=\E[3g, tsl=\E[1$}\E[2$~,
-	use=vt220+vtedit, use=ansi+pp, use=vt220+cvis,
-bq300-rv|Bull vt320 reverse 80 columns,
+	smul=\E[4m, tsl=\E[1$}\E[2$~, use=ansi+enq, use=ansi+csr,
+	use=ansi+erase, use=ansi+idl, use=ansi+local,
+	use=ansi+pp, use=dec+sl, use=vt100+4bsd, use=vt220+cvis,
+	use=vt220+vtedit,
+
+bq300-rv|Bull VT320 reverse 80 columns,
 	flash=\E[?5l$<50>\E[?5h,
 	is2=\E[?2h\E[?3l\E[?5h\E[?7h\E[?8h\E>\E[?1l\E\sF\E[?42l\E[?4
 	    l,
 	use=bq300,
-bq300-w|Bull vt320 132 columns,
+bq300-w|Bull VT320 132 columns,
 	cols#132, wsl#132,
 	is2=\E[?2h\E[?3h\E[?5l\E[?7h\E[?8h\E>\E[?1l\E\sF\E[?42l\E[?4
 	    l,
 	rs2=\E[?3h, use=bq300,
-bq300-w-rv|Bull vt320 reverse mode 132 columns,
+bq300-w-rv|Bull VT320 reverse mode 132 columns,
 	cols#132, wsl#132,
 	flash=\E[?5l$<50>\E[?5h,
 	is2=\E[?2h\E[?3h\E[?5h\E[?7h\E[?8h\E>\E[?1l\E\sF\E[?42l\E[?4
 	    l,
 	rs2=\E[?3h, use=bq300,
 
-#  This entry is used for terminals with vt320 emulation mode
+#  This entry is used for terminals with VT320 emulation mode
 #  and following set-up :
 #    8 bit ISO Latin Character Set (ISO 8859-1),
 #    8 bit Control Characters, (CSI coded as x9B for ESC [)
@@ -21732,36 +22082,34 @@ bq300-w-rv|Bull vt320 reverse mode 132 columns,
 #	RM DECTCEM Invisible cursor:	csi ? 2 5 l
 #	SM DECNCRM 7 bits NCR set:	csi ? 4 2 h
 #	RM DECNCRM Multi or ISO latin:	csi ? 4 2 l
-#	DECSCL vt300 mode 8-bit ctrl:	csi 6 3 " p
-# or	DECSCL vt300 mode 8-bit ctrl:	csi 6 3 ; 0 " p
-#	DECSCL vt300 mode 7-bit ctrl:	csi 6 3 ; 1 " p
+#	DECSCL VT300 mode 8-bit ctrl:	csi 6 3 " p
+# or	DECSCL VT300 mode 8-bit ctrl:	csi 6 3 ; 0 " p
+#	DECSCL VT300 mode 7-bit ctrl:	csi 6 3 ; 1 " p
 #	Char. and Line attributes:	csi Ps ... Ps m
 # with:  0 All off, 1 Bold, 4 Underline, 5 Blinking, 7 Reverse
 # and : 22 Bold off, 24 Underline off, 25 Blinking off, 27 Reverse off
 # (bq300-8: <cub1>,<cuf1>,<cuu1>,<cud1>,<dl1>,<il1> to get under 1024 --esr)
-bq300-8|Bull vt320 full 8 bits 80 columns,
-	am, eo, eslok, hs, km, mc5i, mir, msgr, xenl, xon,
-	cols#80, it#8, lines#24, vt#3, wsl#80,
-	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, blink=\2335m, bold=\2331m, clear=\233H\233J, cr=\r,
+bq300-8|Bull VT320 full 8 bits 80 columns,
+	eo, eslok, hs, km, mc5i, mir, xenl, xon,
+	vt#3, wsl#80,
+	blink=\2335m, bold=\2331m, clear=\233H\233J,
 	csr=\233%i%p1%d;%p2%dr, cub=\233%p1%dD, cub1=\2331D,
 	cud=\233%p1%dB, cud1=\2331B, cuf=\233%p1%dC, cuf1=\2331C,
 	cup=\233%i%p1%d;%p2%dH, cuu=\233%p1%dA, cuu1=\2331A,
 	dch=\233%p1%dP, dch1=\233P, dl=\233%p1%dM, dl1=\233M,
 	dsl=\2331$}\2332$~\n\2330$}, ech=\233%p1%dX, ed=\233J,
-	el=\233K, el1=\2331K, enacs=\E(B\E)0,
-	flash=\233?5h$<50>\233?5l, fsl=\2330$}, home=\233H,
-	ht=^I, hts=\EH, ich=\233%p1%d@, il=\233%p1%dL, il1=\233L,
-	ind=\ED, is1=\E[63;2"p\E[2h,
+	el=\233K, el1=\2331K, flash=\233?5h$<50>\233?5l,
+	fsl=\2330$}, home=\233H, ich=\233%p1%d@, il=\233%p1%dL,
+	il1=\233L, ind=\ED, is1=\E[63;2"p\E[2h,
 	is2=\E[?2h\E[?3l\E[?5l\E[?7h\E[?8h\E>\E[?1l\E\sG\E[?42l\E[?4
 	    l,
 	is3=\2330$}\233?25h\2332l\233H\233J, ka1=\217w,
-	ka3=\217y, kb2=\217u, kbs=^H, kc1=\217q, kc3=\217s,
-	kcub1=\233D, kcud1=\233B, kcuf1=\233C, kcuu1=\233A,
-	kdch1=\2333~, kf1=\217P, kf10=\23321~, kf11=\23323~,
-	kf12=\23324~, kf13=\23325~, kf14=\23326~, kf15=\23328~,
-	kf16=\23329~, kf17=\23331~, kf18=\23332~, kf19=\23333~,
-	kf2=\217Q, kf20=\23334~, kf3=\217R, kf4=\217S, kf6=\23317~,
+	ka3=\217y, kb2=\217u, kc1=\217q, kc3=\217s, kcub1=\233D,
+	kcud1=\233B, kcuf1=\233C, kcuu1=\233A, kdch1=\2333~,
+	kf1=\217P, kf10=\23321~, kf11=\23323~, kf12=\23324~,
+	kf13=\23325~, kf14=\23326~, kf15=\23328~, kf16=\23329~,
+	kf17=\23331~, kf18=\23332~, kf19=\23333~, kf2=\217Q,
+	kf20=\23334~, kf3=\217R, kf4=\217S, kf6=\23317~,
 	kf7=\23318~, kf8=\23319~, kf9=\23320~, kfnd=\2331~,
 	khlp=\23328~, kich1=\2332~, knp=\2336~, kpp=\2335~,
 	krdo=\23329~, kslt=\2334~, lf1=pf1, lf2=pf2, lf3=pf3,
@@ -21775,25 +22123,25 @@ bq300-8|Bull vt320 full 8 bits 80 columns,
 	sgr0=\2330m\E(B, smacs=\E(0, smam=\233?7h,
 	smcup=\233?7l\233?1l\E(B, smir=\2334h, smso=\2337m,
 	smul=\2334m, tbc=\2333g, tsl=\2331$}\2332$~,
-	use=vt220+cvis8,
-bq300-8rv|Bull vt320 8-bit reverse mode 80 columns,
+	use=vt100+4bsd, use=vt220+cvis8,
+bq300-8rv|Bull VT320 8-bit reverse mode 80 columns,
 	flash=\233?5l$<50>\233?5h,
 	is2=\E[?2h\E[?3l\E[?5h\E[?7h\E[?8h\E>\E[?1l\E\sG\E[?42l\E[?4
 	    l,
 	use=bq300-8,
-bq300-8w|Bull vt320 8-bit 132 columns,
+bq300-8w|Bull VT320 8-bit 132 columns,
 	cols#132, wsl#132,
 	is2=\E[?2h\E[?3h\E[?5l\E[?7h\E[?8h\E>\E[?1l\E\sG\E[?42l\E[?4
 	    l,
 	rs2=\233?3h, use=bq300-8,
-bq300-w-8rv|Bull vt320 8-bit reverse mode 132 columns,
+bq300-w-8rv|Bull VT320 8-bit reverse mode 132 columns,
 	cols#132, wsl#132,
 	flash=\233?5l$<50>\233?5h,
 	is2=\E[?2h\E[?3h\E[?5h\E[?7h\E[?8h\E>\E[?1l\E\sG\E[?42l\E[?4
 	    l,
 	rs2=\233?3h, use=bq300-8,
 
-#  This entry is used for terminals with vt320 emulation mode
+#  This entry is used for terminals with VT320 emulation mode
 #  a 102 keys keyboard (PC scancode !) and following set-up :
 #    8 bit ISO Latin Character Set (ISO 8859-1),
 #    7 bit Control Characters,
@@ -21824,13 +22172,12 @@ bq300-pc-w-rv|Questar 303 with PC keyboard reverse mode 132 columns,
 #    8 bit Control Characters,
 #    80 columns screen.
 bq300-8-pc|Q306-8-pc|Questar 303 with PC keyboard in full 8 bits 80 columns,
-	kbs=^H, kdch1=\2333~, kend=\2334~, kf1=\23317~,
-	kf10=\23328~, kf11=\23329~, kf12=\23331~, kf13@, kf14@,
-	kf15@, kf16@, kf17@, kf18@, kf19@, kf2=\23318~, kf20@,
-	kf3=\23319~, kf4=\23320~, kf5=\23321~, kf6=\23323~,
-	kf7=\23324~, kf8=\23325~, kf9=\23326~, kfnd@, khlp@,
-	khome=\2331~, kich1=\2332~, knp=\2336~, kpp=\2335~, krdo@,
-	kslt@, lf1@, lf2@, lf3@, lf4@, use=bq300-8,
+	kend=\2334~, kf1=\23317~, kf10=\23328~, kf11=\23329~,
+	kf12=\23331~, kf13@, kf14@, kf15@, kf16@, kf17@, kf18@, kf19@,
+	kf2=\23318~, kf20@, kf3=\23319~, kf4=\23320~, kf5=\23321~,
+	kf6=\23323~, kf7=\23324~, kf8=\23325~, kf9=\23326~, kfnd@,
+	khlp@, khome=\2331~, krdo@, kslt@, lf1@, lf2@, lf3@, lf4@,
+	use=bq300-8,
 bq300-8-pc-rv|Questar 303 with PC keyboard full 8 bits reverse mode 80 columns,
 	flash=\E[?5l$<50>\E[?5h,
 	is2=\E[?2h\E[?3l\E[?5h\E[?7h\E[?8h\E>\E[?1l\E\sG\E[?42l\E[?4
@@ -21853,72 +22200,70 @@ bq300-8-pc-w-rv|Questar 303 with PC keyboard full 8 bits reverse 132 columns,
 #======================================================#
 
 # normal mode, 8 bits, 80 columns terminal.
-#	RES reset :			^[e
-#	RIS reset initial state:	^[c
-#	BLE bell enable			^[h
-#	BLD bell disable		^[g
-#	CAMS char. attr. mode set	^[[D
-#	CAMR char. attr. mode reset	^[[G
-#	CLR clear			^[`
-#	KBU keyboard unlock (set)	^[[W
-#	KBL keyboard lock (reset)	^[[X
-#	CM  character mode (async.)	^[k
-#	NEP non echoplex mode (by host)	^[l
-#	EP  echoplex mode (by host)	^[m
-#	IM  insert mode set		^[[I
-#	IM  insert mode reset		^[[J
-#	RMS roll mode set		^[r
-#	RMR roll mode reset		^[q
-#	SM78 set mode vip7800		^[[1q
-#	SD  scroll up	(72 lines)	^[[0s
-#	SD  scroll down (72 lines)	^[[1s
-#	RBM block mode reset		^[[E
-#	SLS status line set		^[w
-#	SLR status line reset		^[v
-#	SLL status line lock		^[O
-#	LGS Line-graphic mode set	^[G
-#	LGR Line-graphic mode reset	^[F
-#	TBC tab clear (at cursor pos.)	^[[g
-#	TBI tab initialize		^[[N
-#	TBS tab set (at cursor pos.)	^[p
-#	PDS  print data space		^[[0p
-#	PHD  print host data		^[[3p
-#	PDT  print data terminator	^[[<p
-#	PRES print adapter reset	^[[2p
-#	SSPR multi-part. reset		^[[<>u
-#	SSP0 partition 0 set		^[[00u
-#	SSP1 partition n format 1	^[[PnPnSTRINGu
-#	SSP2 partition n format 2	^[[PnPnSTRINGu
-#	SSP3 partition n format 3	^[[PnPnu
+#	BLD  bell disable			^[g
+#	BLE  bell enable			^[h
+#	CAMR char. attr. mode reset		^[[G
+#	CAMS char. attr. mode set		^[[D
+#	CLR  clear				^[`
+#	CM   character mode (async.)		^[k
+#	EP   echoplex mode (by host)		^[m
+#	IM   insert mode set			^[[I
+#	IMR  insert mode reset			^[[J
+#	KBL  keyboard lock (reset)		^[[X
+#	KBU  keyboard unlock (set)		^[[W
+#	LGR  Line-graphic mode reset		^[F
+#	LGS  Line-graphic mode set		^[G
+#	NEP  non echoplex mode (by host)	^[l
+#	PDS  print data space			^[[0p
+#	PDT  print data terminator		^[[<p
+#	PHD  print host data			^[[3p
+#	PRES print adapter reset		^[[2p
+#	RBM  block mode reset			^[[E
+#	RES  reset :				^[e
+#	RIS  reset initial state:		^[c
+#	RMR  roll mode reset			^[q
+#	RMS  roll mode set			^[r
+#	SCD  scroll down (72 lines)		^[[1s
+#	SCU  scroll up	(72 lines)		^[[0s
+#	SLL  status line lock			^[O
+#	SLR  status line reset			^[v
+#	SLS  status line set			^[w
+#	SM78 set mode vip7800			^[[1q
+#	SSP0 partition 0 set			^[[00u
+#	SSP1 partition n format 1		^[[PnPnSTRINGu
+#	SSP2 partition n format 2		^[[PnPnSTRINGu
+#	SSP3 partition n format 3		^[[PnPnu
+#	SSPR multi-part. reset			^[[<>u
+#	TBC  tab clear (at cursor pos.)		^[[g
+#	TBI  tab initialize			^[[N
+#	TBS  tab set (at cursor pos.)		^[p
+#
 #	ATR attribute (visual)
-#	    blink :			^[sB
-#	    dim :			^[sL
-#	    hide (blank) :		^[sH
-#	    restore :			^[sR
-#	    inverse video :		^[sI
-#	    prot. :			^[sP
-#	    underline :			^[s_
-#	    reset :			^{
+#	    blink :				^[sB
+#	    dim :				^[sL
+#	    hide (blank) :			^[sH
+#	    inverse video :			^[sI
+#	    protected :				^[sP
+#	    reset :				^[sR
+#	    underline :				^[s_
 #
 # This covers the vip7800 and BQ3155-vip7800
 vip|Bull Questar 3155-7800,
 	am, eslok, hs, km, mc5i, msgr, xenl, xon,
-	cols#80, it#8, lines#24, vt#3, wsl#80,
-	acsc=0pjdkblamcnkqitgufvhwexj, bel=^G, blink=\EsB,
-	cbt=\E[Z, clear=\E`, cr=\r, cub1=^H, cud1=\n, cuf1=\EC,
-	cup=\E[%i%p1%03d%p2%03df, cuu1=\EA, dch1=\E[P, dim=\EsL,
-	dl1=\E[M, dsl=\Ev, ed=\EJ, el=\EK,
-	flash=\007$<80>\007$<80>\007, fsl=\EO, home=\EH, ht=^I,
-	hts=\Ep, ich1=\E[I, ind=\n, invis=\EsH,
+	vt#3, wsl#80,
+	acsc=0pjdkblamcnkqitgufvhwexj, blink=\EsB, clear=\E`,
+	cub1=^H, cud1=\n, cup=\E[%i%p1%03d%p2%03df, dch1=\E[P,
+	dim=\EsL, dl1=\E[M, dsl=\Ev,
+	flash=\007$<80>\007$<80>\007, fsl=\EO, hts=\Ep,
+	ich1=\E[I, invis=\EsH,
 	is2=\E[00u\E[<>001001024080024080u\E[01u,
-	is3=\Er\E[W\E`, kHOM=\EH, kLFT=\Eo, kRIT=\Eu, kbs=^H,
-	kcbt=\E[Z, kclr=\E`, kctab=\E[g, kcub1=\ED, kcud1=\EB,
-	kcuf1=\EC, kcuu1=\EA, kdch1=\E[P, kdl1=\E[M, ked=\EJ,
+	is3=\Er\E[W\E`, kHOM=\EH, kLFT=\Eo, kRIT=\Eu, kcbt=\E[Z,
+	kclr=\E`, kctab=\E[g, kdch1=\E[P, kdl1=\E[M, ked=\EJ,
 	kel=\EK, kf1=\E0, kf10=\ET, kf11=\E\\, kf12=\E\^, kf13@, kf14@,
 	kf15@, kf16@, kf17@, kf18@, kf19@, kf2=\E2, kf20@, kf21=\E1,
 	kf22=\E5, kf23=\E7, kf24=\E9, kf25=\E;, kf26=\E=, kf27=\E?,
 	kf28=\EQ, kf29=\ES, kf3=\E6, kf30=\EV, kf31=\E], kf32=\E_,
-	kf4=\E8, kf5=\E\:, kf6=\E<, kf7=\E>, kf8=\EP, kf9=\ER,
+	kf4=\E8, kf5=\E:, kf6=\E<, kf7=\E>, kf8=\EP, kf9=\ER,
 	khome=\EH, khts=\Ep, kich1=\E[I, kil1=\E[L, kind=\E[0s,
 	kll=\EH\EA, kri=\E[1s, krmir=\E[J, ktbc=\E[N, lf1=pf1,
 	lf2=pf2, lf3=pf3, lf4=pf4, ll=\EH\EA, mc0=\E[0p, mc4=\E[<p,
@@ -21926,7 +22271,8 @@ vip|Bull Questar 3155-7800,
 	ri=\EA\EJ\EH\E[L$<10>, rmacs=\EF, rmir=\E[J, rmso=\EsR,
 	rmul=\EsR, rs1=\Ec, rs2=\E[G, s0ds=\EF, s1ds=\EG,
 	sgr0=\EsR\EsU\EF, smacs=\EG, smir=\E[I, smso=\EsI,
-	smul=\Es_, tbc=\E[N, tsl=\Ew,
+	smul=\Es_, tbc=\E[N, tsl=\Ew, use=ansi+inittabs,
+	use=vt52-basic,
 # normal screen, 8 bits, 132 columns terminal.
 vip-w|vip7800-w|Q310-vip-w|Q310-vip-w-am|Questar 3155-vip7800 wide,
 	cols#132, wsl#132,
@@ -21965,7 +22311,7 @@ cg7900|chromatics|chromatics 7900,
 #### Computer Automation
 #
 
-ca22851|computer automation 22851,
+ca22851|Computer Automation 22851,
 	am,
 	cols#80, lines#24,
 	bel=^G, clear=\014$<8>, cr=\r, cub1=^U, cud1=\n, cuf1=^I,
@@ -21976,7 +22322,7 @@ ca22851|computer automation 22851,
 #
 
 # This entry has correct padding and the undocumented "ri" capability
-cyb83|xl83|cybernex xl-83,
+cyb83|xl83|Cybernex xl-83,
 	OTbs, am,
 	cols#80, lines#24,
 	bel=^G, clear=\014$<62>, cr=\r, cub1=^H, cud1=\n, cuf1=^I,
@@ -21984,7 +22330,7 @@ cyb83|xl83|cybernex xl-83,
 	ed=\020$<62>, el=\017$<3>, home=^K, ind=\n, kcub1=^H,
 	kcud1=\n, kcuf1=^I, kcuu1=^N, ri=^N,
 # (mdl110: removed obsolete ":ma=^Z^P:" and overridden ":cd=145^NA^W:" -- esr)
-cyb110|mdl110|cybernex mdl-110,
+cyb110|mdl110|Cybernex mdl-110,
 	OTbs, am,
 	cols#80, lines#24,
 	bel=^G, clear=\030$<70>, cr=\r, cub1=^H, cud1=\n, cuf1=^U,
@@ -22002,7 +22348,7 @@ cyb110|mdl110|cybernex mdl-110,
 # side of Datapoint still lives (1995) in the form of Intelogic Trace.
 #
 
-dp3360|datapoint|datapoint 3360,
+dp3360|datapoint|Datapoint 3360,
 	OTbs, am,
 	cols#82, lines#25,
 	bel=^G, clear=^]^_, cr=\r, cub1=^H, cud1=\n, cuf1=^X, cuu1=^Z,
@@ -22035,7 +22381,7 @@ dp3360|datapoint|datapoint 3360,
 #         ctrl-O           vertical line
 # Unfortunately this cannot be fitted into the termcap/terminfo
 # description scheme.
-dp8242|datapoint 8242,
+dp8242|Datapoint 8242,
 	msgr,
 	cols#80, lines#25,
 	bel=^G, civis=^Y, clear=^U\E^D^W^X, cnorm=^X, cr=\r, cub1=^H,
@@ -22051,7 +22397,7 @@ dp8242|datapoint 8242,
 	wind=\E\014\E\016%p1%'\0'%+%c%p2%'\0'%+%c%p3%'\0'%+%c%p4%'
 	     \0'%+%c\025,
 
-#### DEC terminals (Obsolete types: DECwriter and vt40/42/50)
+#### DEC terminals (Obsolete types: DECwriter and VT40/42/50)
 #
 # These entries came from DEC's official terminfos for its older terminals
 # (which happen to be identical to the AT&T/SCO terminal descriptions),
@@ -22063,9 +22409,9 @@ dp8242|datapoint 8242,
 #
 # DECScope of course had no "function keys", but this building block assigns
 # the three blank keys at the top of the auxiliary (numeric) keypad, using
-# the same analogy as vt100 (also lacking function-keys).
+# the same analogy as VT100 (also lacking function-keys).
 #
-# These assignments use the same layout for 0-9 as vt100+keypad; the vt52
+# These assignments use the same layout for 0-9 as VT100+keypad; the VT52
 # keypad had its cursor-keys on the right-column as shown -TD
 #   _______________________________________
 #  |   PF1   |   PF2   |   PF3   | c-up    |
@@ -22089,71 +22435,67 @@ vt52+keypad|DECScope auxiliary keypad,
 	kf1=\EP, kf2=\EQ, kf3=\ER, kf5=\E?t, kf6=\E?u, kf7=\E?v,
 	kf8=\E?w, kf9=\E?x,
 
-gt40|dec gt40,
+gt40|DEC gt40,
 	OTbs, os,
 	cols#72, lines#30,
 	bel=^G, cr=\r, cub1=^H, cud1=\n,
-gt42|dec gt42,
+gt42|DEC gt42,
 	OTbs, os,
 	cols#72, lines#40,
 	bel=^G, cr=\r, cub1=^H, cud1=\n,
 
-vt50|dec vt50,
+vt50|DEC VT50,
 	OTbs,
 	cols#80, lines#12,
 	bel=^G, clear=\EH\EJ, cr=\r, cub1=^H, cud1=\n, cuf1=\EC,
 	cuu1=\EA, ed=\EJ, el=\EK, ht=^I, ind=\n, u8=\E/A, u9=\EZ,
-vt50h|dec vt50h,
+vt50h|DEC VT50h,
 	cub1=\ED, cud1=\EB, cup=\EY%p1%{32}%+%c%p2%{32}%+%c,
-	kcub1=\ED, kcud1=\EB, kcuf1=\EC, kcuu1=\EA, u8=\E/[HJ],
-	use=vt52+keypad, use=vt50,
+	u8=\E/[HJ], use=vt52+keypad, use=vt50, use=vt52+arrows,
 
 # (vt61: there's a BSD termcap that claims <dl1=\EPd>, <il1=\EPf.> <kbs=^H>)
-vt61|vt-61|vt61.5|dec vt61,
+vt61|vt-61|vt61.5|DEC VT61,
 	cols#80, lines#24,
 	bel=^G, clear=\EH\EJ$<120>, cr=\r$<20>, cub1=^H, cud1=\n,
 	cuf1=\EC$<20>, cup=\EY%p1%{32}%+%c%p2%{32}%+%c$<20>,
 	cuu1=\EA$<20>, ed=\EJ$<120>, el=\EK$<70>, ht=^I,
-	ind=\n$<20>, kcub1=\ED, kcud1=\EB, kcuf1=\EC, kcuu1=\EA,
-	ri=\E$<20>I,
+	ind=\n$<20>, ri=\E$<20>I, use=vt52+arrows,
 
 # The gigi does standout with red!
 # (gigi: I added <rmam>/<smam> based on the init string, corrected cub1 -- esr)
-gigi|vk100|dec gigi graphics terminal,
+gigi|vk100|DEC gigi graphics terminal,
 	OTbs, am, xenl,
 	cols#84, lines#24,
-	bel=^G, clear=\E[H\E[2J, cr=\r, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A, ed=\E[J,
-	el=\E[K, ht=^I, ind=\n,
+	bel=^G, clear=\E[H\E[2J, cr=\r, cub1=^H, cud1=\n,
+	cup=\E[%i%p1%d;%p2%dH, ed=\E[J, el=\E[K, ht=^I, ind=\n,
 	is2=\E>\E[?3l\E[?4l\E[?5l\E[?20l\E[?7h\E[?8h,
 	kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kf1=\EOP,
 	kf2=\EOQ, kf3=\EOR, kf4=\EOS, khome=\E[H, ri=\EM,
 	rmam=\E[?7l, rmkx=\E[?1l\E>, rmso=\E[m, rmul=\E[m,
 	sgr0=\E[m, smam=\E[?7h, smkx=\E[?1h\E=, smso=\E[7;31m,
-	smul=\E[4m,
+	smul=\E[4m, use=ansi+local,
 
 # DEC PRO-350 console (VT220-style).  The 350 was DEC's attempt to produce
 # a PC differentiated from the IBM clones.  It was a total, ludicrous,
 # grossly-overpriced failure (among other things, DEC's OS didn't include
 # a format program, so you had to buy pre-formatted floppies from DEC at
 # a hefty premium!).
-pro350|decpro|dec pro console,
+pro350|decpro|DEC pro console,
 	OTbs,
 	cols#80, it#8, lines#24,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
 	clear=\EH\EJ, cub1=^H, cud1=\EB, cuf1=\EC,
 	cup=\EY%p1%{32}%+%c%p2%{32}%+%c, cuu1=\EA, ed=\EJ,
-	el=\EK, home=\EH, ht=^I, kcub1=\ED, kcud1=\EB, kcuf1=\EC,
-	kcuu1=\EA, kf0=\EE, kf1=\EF, kf2=\EG, kf3=\EH, kf4=\EI,
-	kf5=\EJ, kf6=\Ei, kf7=\Ej, khome=\EH, ri=\EI, rmacs=\EG,
-	rmso=\E^N, rmul=\E^C, smacs=\EF, smso=\E^H, smul=\E^D,
+	el=\EK, home=\EH, ht=^I, kf0=\EE, kf1=\EF, kf2=\EG, kf3=\EH,
+	kf4=\EI, kf5=\EJ, kf6=\Ei, kf7=\Ej, khome=\EH, ri=\EI,
+	rmacs=\EG, rmso=\E^N, rmul=\E^C, smacs=\EF, smso=\E^H,
+	smul=\E^D, use=vt52+arrows,
 
-dw1|decwriter I,
+dw1|DECwriter I,
 	OTbs, hc, os,
 	cols#72,
 	bel=^G, cr=\r, cub1=^H, cud1=\n, ind=\n,
-dw2|decwriter|dw|decwriter II,
+dw2|decwriter|dw|DECwriter II,
 	OTbs, hc, os,
 	cols#132,
 	bel=^G, cr=\r, cub1=^H, cud1=\n, ind=\n, kbs=^H,
@@ -22173,7 +22515,7 @@ dw2|decwriter|dw|decwriter II,
 #
 #       The dw3 does standout with wide characters.
 #
-dw3|la120|decwriter III,
+dw3|la120|DECwriter III,
 	OTbs, hc, os,
 	cols#132,
 	bel=^G, cr=\r, cub1=^H, cud1=\n, ht=^I, ind=\n,
@@ -22181,23 +22523,22 @@ dw3|la120|decwriter III,
 	is2=\E[9;17;25;33;41;49;57;65;73;81;89;97;105;113;121;129u
 	    \r,
 	kbs=^H, rmso=\E[w, sgr0=\E[w, smso=\E[6w,
-dw4|decwriter IV,
+dw4|DECwriter IV,
 	OTbs, am, hc, os,
 	cols#132,
 	bel=^G, cr=\r, cub1=^H, cud1=\n, ht=^I, ind=\n, is2=\Ec, kbs=^H,
 	kf0=\EOP, kf1=\EOQ, kf2=\EOR, kf3=\EOS,
 
 # These aren't official
-ln03|dec ln03 laser printer,
+ln03|DEC ln03 laser printer,
 	hc,
 	cols#80, lines#66,
 	bel=^G, cr=\r, cud1=\n, hd=\EK, ht=^I, hu=\EL, ind=\n, nel=\r\n,
 	rmso=\E[22m, rmul=\E[24m, sgr0=\E[m, smso=\E[1m,
 	smul=\E[4m,
-ln03-w|dec ln03 laser printer 132 cols,
+ln03-w|DEC ln03 laser printer 132 cols,
 	cols#132,
-	bel=^G, cr=\r, cud1=\n, ht=^I, ind=\n, kbs=^H, kcub1=^H,
-	kcud1=\n, nel=\r\n, use=ln03,
+	kbs=^H, kcub1=^H, kcud1=\n, use=ln03,
 
 #### Delta Data (dd)
 #
@@ -22218,21 +22559,21 @@ delta|dd5000|delta data 5000,
 #
 
 # (ddr: I added <rmam>/<smam> based on the init string -- esr)
-ddr|rebus3180|ddr3180|Rebus/DDR 3180 vt100 emulator,
+ddr|rebus3180|ddr3180|Rebus/DDR 3180 VT100 emulator,
 	OTbs, am, xenl,
 	cols#80, it#8, lines#24, vt#3,
 	blink=\E[5m$<2/>, bold=\E[1m$<2/>,
-	clear=\E[H\E[2J$<50/>, csr=\E[%i%p1%d;%p2%dr, cub1=^H,
-	cud1=\n, cuf1=\E[C$<2/>, cup=\E[%i%p1%d;%p2%dH$<5/>,
-	cuu1=\E[A$<2/>, ed=\E[J$<50/>, el=\E[K$<3/>, home=\E[H,
-	ht=^I, ind=\ED$<5/>, is2=\E[1;24r\E[24;1H, kbs=^H,
-	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kf1=\EOP,
-	kf2=\EOQ, kf3=\EOR, kf4=\EOS, rc=\E8, rev=\E[7m$<2/>,
+	clear=\E[H\E[2J$<50/>, cub1=^H, cud1=\n, cuf1=\E[C$<2/>,
+	cup=\E[%i%p1%d;%p2%dH$<5/>, cuu1=\E[A$<2/>,
+	ed=\E[J$<50/>, el=\E[K$<3/>, home=\E[H, ht=^I,
+	ind=\ED$<5/>, is2=\E[1;24r\E[24;1H, kbs=^H, kcub1=\E[D,
+	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kf1=\EOP, kf2=\EOQ,
+	kf3=\EOR, kf4=\EOS, rev=\E[7m$<2/>,
 	rf=/usr/share/tabset/vt100, ri=\EM$<5/>, rmam=\E[7l,
 	rmkx=\E[?1l\E>, rmso=\E[m, rmul=\E[m$<2/>,
-	rs1=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, sc=\E7,
+	rs1=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h,
 	sgr0=\E[m$<2/>, smam=\E[7l, smkx=\E[?1h\E=, smso=\E[7m,
-	smul=\E[4m$<2/>,
+	smul=\E[4m$<2/>, use=ansi+csr,
 
 #### Evans & Sutherland
 #
@@ -22299,7 +22640,7 @@ terminet1200|terminet300|tn1200|tn300|terminet|GE terminet 1200,
 # S402     0 0 0 0 0 0 0 0
 # (h19: I added <rmam>/<smam> based on the init string;
 # also added empty <acsc> to suppress a tic warning -- esr)
-h19-a|h19a|heath-ansi|heathkit-a|heathkit h19 ansi mode,
+h19-a|h19a|heath-ansi|heathkit-a|Heathkit h19 ANSI mode,
 	OTbs, am, mir, msgr,
 	cols#80, it#8, lines#24,
 	acsc=, bel=^G, clear=\E[2J, cnorm=\E[>4l, cr=\r, cub1=^H,
@@ -22312,9 +22653,9 @@ h19-a|h19a|heath-ansi|heathkit-a|heathkit h19 ansi mode,
 	kf7=\EOQ, kf8=\EOR, khome=\E[H, lf6=blue, lf7=red, lf8=white,
 	ri=\EM, rmacs=\E[11m, rmam=\E[?7l, rmir=\E[4l, rmso=\E[m,
 	smacs=\E[10m, smam=\E[?7h, smir=\E[4h, smso=\E[7m,
-h19-bs|heathkit w/keypad shifted,
+h19-bs|Heathkit w/keypad shifted,
 	rmkx=\Eu, smkx=\Et, use=h19-b,
-h19-us|h19us|h19-smul|heathkit w/keypad shifted/underscore cursor,
+h19-us|h19us|h19-smul|Heathkit w/keypad shifted/underscore cursor,
 	rmkx=\Eu, smkx=\Et, use=h19-u,
 # (h19: merged in <ip> from BSDI hp19-e entry>;
 # also added empty <acsc> to suppress a tic warning --esr)
@@ -22331,23 +22672,23 @@ h19-us|h19us|h19-smul|heathkit w/keypad shifted/underscore cursor,
 # help (I have tried up to 20000).  Removing <il1=\EL$> and <dl1=\EM$>
 # makes Emacs a little slower, but it remains in the land of the living.
 # Big win.
-h19|heath|h19-b|heathkit|heath-19|z19|zenith|heathkit h19,
+h19|heath|h19-b|heathkit|heath-19|z19|zenith|Heathkit h19,
 	OTbs, am, eslok, hs, mir, msgr,
 	cols#80, it#8, lines#24,
 	acsc=+h.kaiggjdkclfmenbozqas{tvutvuwsx`~\^, bel=^G,
 	clear=\EE, cnorm=\Ey4, cr=\r, cub1=^H, cud1=\EB, cuf1=\EC,
 	cup=\EY%p1%{32}%+%c%p2%{32}%+%c, cuu1=\EA, cvvis=\Ex4,
 	dch1=\EN, ed=\EJ, el=\EK, fsl=\Ek\Ey5, home=\EH, ht=^I, ind=\n,
-	ip=$<1.5/>, kbs=^H, kcub1=\ED, kcud1=\EB, kcuf1=\EC,
-	kcuu1=\EA, kf1=\ES, kf2=\ET, kf3=\EU, kf4=\EV, kf5=\EW,
-	kf6=\EP, kf7=\EQ, kf8=\ER, khome=\EH, lf6=blue, lf7=red,
-	lf8=white, ri=\EI, rmacs=\EG, rmir=\EO, rmso=\Eq, smacs=\EF,
-	smir=\E@, smso=\Ep, tsl=\Ej\Ex5\EY8%p1%{32}%+%c\Eo\Eo,
-h19-u|heathkit with underscore cursor,
+	ip=$<1.5/>, kbs=^H, kf1=\ES, kf2=\ET, kf3=\EU, kf4=\EV,
+	kf5=\EW, kf6=\EP, kf7=\EQ, kf8=\ER, khome=\EH, lf6=blue,
+	lf7=red, lf8=white, ri=\EI, rmacs=\EG, rmir=\EO, rmso=\Eq,
+	smacs=\EF, smir=\E@, smso=\Ep,
+	tsl=\Ej\Ex5\EY8%p1%{32}%+%c\Eo\Eo, use=vt52+arrows,
+h19-u|Heathkit with underscore cursor,
 	cnorm@, cvvis@, use=h19-b,
-h19-g|h19g|heathkit w/block cursor,
+h19-g|h19g|Heathkit w/block cursor,
 	cnorm=\Ex4, cvvis@, use=h19-b,
-alto-h19|altoh19|altoheath|alto-heath|alto emulating heathkit h19,
+alto-h19|altoh19|altoheath|alto-heath|alto emulating Heathkit h19,
 	lines#60,
 	dl1=\EM, il1=\EL, use=h19,
 
@@ -22382,7 +22723,7 @@ alto-h19|altoh19|altoheath|alto-heath|alto emulating heathkit h19,
 # line will be really slow", you say. Well there is a sort of a
 # solution to that too. There is an insert character option on
 # the Z29 that will insert one character. Unfortunately, it
-# involves putting the terminal into ansi mode, inserting the
+# involves putting the terminal into ANSI mode, inserting the
 # character, and changing it back to H19 mode. All this takes 12
 # characters. Pretty expensive to insert one character, but it
 # works. Either Emacs doesn't try to use its inserting hack when
@@ -22391,7 +22732,7 @@ alto-h19|altoh19|altoheath|alto-heath|alto emulating heathkit h19,
 # but I haven't checked it out).
 # (z29: added empty <acsc> to suppress a tic warning, merged in
 # status line capabilities from BRL entry --esr)
-z29|zenith29|z29b|zenith z29b,
+z29|zenith29|z29b|Zenith z29b,
 	OTbs, OTpt, am, eslok, hs, mir, msgr,
 	OTkn#10, cols#80, lines#24,
 	OTbc=\ED, acsc=, bel=^G, cbt=\E-, clear=\EE$<14>, cnorm=\Ey4,
@@ -22400,106 +22741,98 @@ z29|zenith29|z29b|zenith z29b,
 	cvvis=\Ex4, dch1=\EN$<0.1*>, dl1=\EM$<1/>, dsl=\Ey1,
 	ed=\EJ$<14>, el=\EK$<1>, fsl=\Ek\Ey5, home=\EH, ht=^I,
 	ich1=\E<\E[1@\E[?2h$<1>, il1=\EL$<1/>, ind=\n$<2>,
-	is2=\E<\E[?2h\Ev, kbs=^H, kcub1=\ED, kcud1=\EB, kcuf1=\EC,
-	kcuu1=\EA, kf0=\E~, kf1=\ES, kf2=\ET, kf3=\EU, kf4=\EV,
-	kf5=\EW, kf6=\EP, kf7=\EQ, kf8=\ER, kf9=\E0I, khome=\EH,
-	lf0=home, ri=\EI$<2/>, rmacs=\EF, rmir=\EO, rmso=\Eq,
-	rmul=\Es0, smacs=\EG, smir=\E@, smso=\Ep, smul=\Es8,
-	tsl=\Ej\Ex5\Ex1\EY8%+ \Eo,
-# z29 in ansi mode. Assumes that the cursor is in the correct state, and that
+	is2=\E<\E[?2h\Ev, kbs=^H, kf0=\E~, kf1=\ES, kf2=\ET, kf3=\EU,
+	kf4=\EV, kf5=\EW, kf6=\EP, kf7=\EQ, kf8=\ER, kf9=\E0I,
+	khome=\EH, lf0=home, ri=\EI$<2/>, rmacs=\EF, rmir=\EO,
+	rmso=\Eq, rmul=\Es0, smacs=\EG, smir=\E@, smso=\Ep,
+	smul=\Es8, tsl=\Ej\Ex5\Ex1\EY8%+ \Eo, use=vt52+arrows,
+# z29 in ANSI mode. Assumes that the cursor is in the correct state, and that
 # the world is stable. <rs1> causes the terminal to be reset to the state
 # indicated by the name. kc -> key click, nkc -> no key click, uc -> underscore
 # cursor, bc -> block cursor.
 # From: Mike Meyers
 # (z29a: replaced nonexistent <if=/usr/share/tabset/zenith29> because <hts>
-# looks vt100-compatible -- esr)
-z29a|z29a-kc-bc|h29a-kc-bc|heath/zenith 29 in ansi mode,
+# looks VT100-compatible -- esr)
+z29a|z29a-kc-bc|h29a-kc-bc|Heath/Zenith 29 in ANSI mode,
 	OTbs, OTpt, am, eslok, hs, mir, msgr,
 	OTkn#10, cols#80, it#8, lines#24,
 	OTbc=\ED, bel=^G, blink=\E[5m, bold=\E[2m, clear=\E[2J,
-	cr=\r, csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
-	dch=\E[%p1%dP, dch1=\E[1P, dim=\E[2m, dl=\E[%p1%dM,
-	dl1=\E[M, dsl=\E[>1l, ed=\E[J, el=\E[K, fsl=\E[u\E[>5l,
+	cr=\r, csr=\E[%i%p1%d;%p2%dr, cub1=^H, cud1=\n,
+	cup=\E[%i%p1%d;%p2%dH, dch=\E[%p1%dP, dch1=\E[1P,
+	dim=\E[2m, dsl=\E[>1l, ed=\E[J, el=\E[K, fsl=\E[u\E[>5l,
 	home=\E[H, ht=^I, hts=\EH, if=/usr/share/tabset/vt100,
-	il=\E[%p1%dL, il1=\E[L, ind=\ED, kbs=^H, kclr=\E[J,
-	kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, ked=\E[J,
-	kf0=\E[~, kf1=\EOS, kf2=\EOT, kf3=\EOU, kf4=\EOV, kf5=\EOW,
-	kf6=\EOP, kf7=\EOQ, kf8=\EOR, kf9=\EOX, khome=\E[H, lf0=help,
-	mc0=\E#7, nel=\r\ED, rc=\E[r, rev=\E[7m, ri=\EM,
-	rmcup=\E[?7h, rmso=\E[m, rmul=\E[m,
+	ind=\ED, kclr=\E[J, ked=\E[J, kf0=\E[~, kf1=\EOS, kf2=\EOT,
+	kf3=\EOU, kf4=\EOV, kf5=\EOW, kf6=\EOP, kf7=\EOQ, kf8=\EOR,
+	kf9=\EOX, khome=\E[H, lf0=help, mc0=\E#7, nel=\r\ED, rc=\E[r,
+	rev=\E[7m, ri=\EM, rmcup=\E[?7h, rmso=\E[m, rmul=\E[m,
 	rs1=\E<\E[1;24r\E[24;1H\E[?7h\E[>4h\E[>1;2;3;5;6;7;8;9l\E[m
 	    \E[11m,
 	sc=\E[s, sgr0=\E[m, smcup=\E[?7l, smso=\E[7;2m, smul=\E[4m,
 	tbc=\E[3g, tsl=\E[s\E[>5;1h\E[25;%i%dH\E[1K,
-z29a-kc-uc|h29a-kc-uc|z29 ansi mode with keyclick and underscore cursor,
+	use=ansi+apparrows, use=ansi+idl, use=ansi+local,
+
+z29a-kc-uc|h29a-kc-uc|Zenith z29 ANSI mode with keyclick and underscore cursor,
 	rs1=\E<\E[1;24r\E[24;1H\E[?7h\E[>1;2;3;4;5;6;7;8;9l\E[m\E[11
 	    m,
 	use=z29a,
-z29a-nkc-bc|h29a-nkc-bc|z29 ansi mode with block cursor and no keyclick,
+z29a-nkc-bc|h29a-nkc-bc|Zenith z29 ANSI mode with block cursor and no keyclick,
 	rs1=\E<\E[1;24r\E[24;1H\E[?7h\E[>2;4h\E[>1;3;5;6;7;8;9l\E[m
 	    \E[11m,
 	use=z29a,
-z29a-nkc-uc|h29a-nkc-uc|z29 ansi mode with underscore cursor and no keyclick,
+z29a-nkc-uc|h29a-nkc-uc|Zenith z29 ANSI mode with underscore cursor and no keyclick,
 	rs1=\E<\E[1;24r\E[24;1H\E[?7h\E[>2h\E[>1;3;4;5;6;7;8;9l\E[m
 	    \E[11m,
 	use=z29a,
 # From: Jeff Bartig <jeffb@dont.doit.wisc.edu> 31 Mar 1995
 z39-a|z39a|zenith39-a|zenith39-ansi|Zenith 39 in ANSI mode,
-	am, eslok, hs, mc5i, mir, msgr, xon,
+	am, eslok, hs, mir, msgr, xon,
 	cols#80, lines#24,
 	acsc=0a``aaffggjjkkllmmnnooqqssttuuvvwwxx~~, bel=^G,
 	blink=\E[5m, bold=\E[1m, cbt=\E[1Z, civis=\E[>5h,
 	clear=\E[2J\E[H, cnorm=\E[>5l, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\E[B, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
+	csr=\E[%i%p1%d;%p2%dr, cub1=^H, cup=\E[%i%p1%d;%p2%dH,
 	dch=\E[%p1%dP, dch1=\E[1P, dim=\E[2m, dl=\E[%p1%dM,
 	dl1=\E[1M, dsl=\E[>1l, ed=\E[0J, el=\E[0K, el1=\E[1K,
-	fsl=\E[u, home=\E[H, ht=^I, hts=\EH, il=\E[%p1%dL, il1=\E[1L,
-	ind=\n, is2=\E<\E[>1;3;5;6;7l\E[0m\E[2J, ka1=\EOw,
-	ka3=\EOu, kb2=\EOy, kbs=^H, kc1=\EOq, kc3=\EOs, kcub1=\E[D,
-	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, ked=\E[J, kf1=\EOS,
-	kf2=\EOT, kf3=\EOU, kf4=\EOV, kf5=\EOW, kf6=\EOP, kf7=\EOQ,
-	kf8=\EOR, kf9=\EOX, khlp=\E[~, khome=\E[H, ll=\E[24;1H,
-	mc0=\E[?19h\E[i, mc4=\E[4i, mc5=\E[5i, rc=\E[u, rev=\E[7m,
-	rmacs=\E(B, rmir=\E[4l, rmkx=\E[>7l, rmso=\E[0m,
+	fsl=\E[u, home=\E[H, il=\E[%p1%dL, il1=\E[1L, ind=\n,
+	is2=\E<\E[>1;3;5;6;7l\E[0m\E[2J, ka1=\EOw, ka3=\EOu,
+	kb2=\EOy, kc1=\EOq, kc3=\EOs, ked=\E[J, kf1=\EOS, kf2=\EOT,
+	kf3=\EOU, kf4=\EOV, kf5=\EOW, kf6=\EOP, kf7=\EOQ, kf8=\EOR,
+	kf9=\EOX, khlp=\E[~, ll=\E[24;1H, mc0=\E[?19h\E[i, rc=\E[u,
+	rev=\E[7m, rmacs=\E(B, rmir=\E[4l, rmkx=\E[>7l, rmso=\E[0m,
 	rmul=\E[0m, rs2=\E<\Ec\0, sc=\E[s, sgr0=\E[0m, smacs=\E(0,
-	smir=\E[4h, smkx=\E[>7h, smso=\E[7m, smul=\E[4m, tbc=\E[3g,
-	tsl=\E[s\E[>1h\E[25;%i%p1%dH,
+	smir=\E[4h, smkx=\E[>7h, smso=\E[7m, smul=\E[4m,
+	tsl=\E[s\E[>1h\E[25;%i%p1%dH, use=ansi+arrows,
+	use=ansi+local, use=ansi+pp, use=ansi+tabs,
 
 # From: Brad Brahms <Brahms@USC-ECLC>
-z100|h100|z110|z-100|h-100|heath/zenith z-100 pc with color monitor,
+z100|h100|z110|z-100|h-100|Heath/Zenith z-100 pc with color monitor,
 	cnorm=\Ey4\Em70, cvvis=\Ex4\Em71, use=z100bw,
 # (z100bw: removed obsolete ":kn#10:", added empty <acsc> -- esr)
-z100bw|h100bw|z110bw|z-100bw|h-100bw|heath/zenith z-100 pc,
+z100bw|h100bw|z110bw|z-100bw|h-100bw|Heath/Zenith z-100 pc,
 	OTbs, OTpt, mir, msgr,
 	OTkn#10, cols#80, it#8, lines#24,
 	acsc=+h.kaiggjdkclfmenbozqas{tvutvuwsx`~\^,
 	clear=\EE$<5*/>, cnorm=\Ey4, cub1=^H, cud1=\EB, cuf1=\EC,
 	cup=\EY%p1%{32}%+%c%p2%{32}%+%c$<1*/>, cuu1=\EA,
 	cvvis=\Ex4, dch1=\EN$<1*/>, dl1=\EM$<5*/>, ed=\EJ, el=\EK,
-	home=\EH, ht=^I, il1=\EL$<5*/>, kbs=^H, kcub1=\ED, kcud1=\EB,
-	kcuf1=\EC, kcuu1=\EA, kf0=\EJ, kf1=\ES, kf2=\ET, kf3=\EU,
-	kf4=\EV, kf5=\EW, kf6=\EP, kf7=\EQ, kf8=\ER, kf9=\EOI,
-	khome=\EH, ri=\EI, rmacs=\EG, rmir=\EO, rmso=\Eq, smacs=\EF,
-	smir=\E@, smso=\Ep,
+	home=\EH, ht=^I, il1=\EL$<5*/>, kbs=^H, kf0=\EJ, kf1=\ES,
+	kf2=\ET, kf3=\EU, kf4=\EV, kf5=\EW, kf6=\EP, kf7=\EQ, kf8=\ER,
+	kf9=\EOI, khome=\EH, ri=\EI, rmacs=\EG, rmir=\EO, rmso=\Eq,
+	smacs=\EF, smir=\E@, smso=\Ep, use=vt52+arrows,
 p19|h19-b with il1/dl1,
 	dl1=\EM$<2*/>, il1=\EL$<2*/>, use=h19-b,
 # From: <ucscc!B.fiatlux@ucbvax.berkeley.edu>
 # (ztx: removed duplicate :sr: -- esr)
-ztx|ztx11|zt-1|htx11|ztx-1-a|ztx-10 or 11,
+ztx|ztx11|zt-1|htx11|ztx-1-a|Heath/Zenith ztx-10 or 11,
 	OTbs, am, eslok, hs,
 	cols#80, it#8, lines#24,
 	clear=\EE, cub1=^H, cud1=\n, cuf1=\EC,
 	cup=\EY%p1%{32}%+%c%p2%{32}%+%c, cuu1=\EA, dl1=\EM,
 	dsl=\Ey1, ed=\EJ, el=\EK, fsl=\Ek\Ey5, home=\EH, ht=^I,
 	il1=\EL, is2=\Ej\EH\Eq\Ek\Ev\Ey1\Ey5\EG\Ey8\Ey9\Ey>,
-	kbs=^H, kcub1=\ED, kcud1=\EB, kcuf1=\EC, kcuu1=\EA, kf0=\ES,
-	kf1=\EB, kf2=\EU, kf3=\EV, kf4=\EW, kf5=\EP, kf6=\EQ, kf7=\ER,
-	ri=\EI, rmso=\Eq, rmul=\Eq, smso=\Es5, smul=\Es2,
-	tsl=\Ej\Ex5\Ex1\EY8%+ \Eo,
+	kbs=^H, kf0=\ES, kf1=\EB, kf2=\EU, kf3=\EV, kf4=\EW, kf5=\EP,
+	kf6=\EQ, kf7=\ER, ri=\EI, rmso=\Eq, rmul=\Eq, smso=\Es5,
+	smul=\Es2, tsl=\Ej\Ex5\Ex1\EY8%+ \Eo, use=vt52+arrows,
 
 #### IMS International (ims)
 #
@@ -22512,12 +22845,12 @@ ztx|ztx11|zt-1|htx11|ztx-1-a|ztx-10 or 11,
 ims950-b|bare ims950 no init string,
 	is2@, use=ims950,
 # (ims950: removed obsolete ":ko@:" -- esr)
-ims950|ims televideo 950 emulation,
+ims950|IMS TeleVideo 950 emulation,
 	xenl@,
 	flash@, kbs@, kcub1@, kcud1@, kcuf1@, kcuu1@, kf0@, kf1@, kf2@, kf3@,
 	kf4@, kf5@, kf6@, kf7@, kf8@, kf9@, khome@, use=tvi950,
 # (ims950-rv: removed obsolete ":ko@:" -- esr)
-ims950-rv|ims tvi950 rev video,
+ims950-rv|IMS tvi950 rev video,
 	xenl@,
 	flash@, kbs@, kcub1@, kcud1@, kcuf1@, kcuu1@, kf0@, kf1@, kf2@, kf3@,
 	kf4@, kf5@, kf6@, kf7@, kf8@, kf9@, khome@, use=tvi950-rv,
@@ -22539,7 +22872,7 @@ ims-ansi|ultima2|ultimaII|IMS Ultima II,
 # then sank out of sight.
 #
 
-superbrain|intertec superbrain,
+superbrain|Intertec Superbrain,
 	OTbs, am, bw,
 	cols#80, lines#24,
 	OTbc=^U, bel=^G, clear=\014$<5*>, cr=\r, cub1=^H, cud1=\n,
@@ -22555,10 +22888,10 @@ intertube|intertec|Intertec InterTube,
 	bel=^G, clear=^L, cr=\r, cub1=^H, cud1=\n, cuf1=^F,
 	cup=\EY%p1%{32}%+%c%p2%{32}%+%c$<50>, cuu1=^Z, home=^A,
 	ind=\n, rmso=\E0@, smso=\E0P,
-# The intertube 2 has the "full duplex" problem like the tek 4025: if you
+# The intertube 2 has the "full duplex" problem like the Tektronix 4025: if you
 # are typing and a command comes in, the keystrokes you type get interspersed
 # with the command and it messes up
-intertube2|intertec data systems intertube 2,
+intertube2|Intertec data systems InterTube 2,
 	OTbs,
 	cup=\016%p1%c\020%p2%{10}%/%{16}%*%p2%{10}%m%+%c,
 	el=\EK, hpa=\020%p1%{10}%/%{16}%*%p1%{10}%m%+%c,
@@ -22588,16 +22921,14 @@ graphos|graphos III,
 	am, mir,
 	cols#80, it#8, lines#24,
 	clear=\E[H\E[2J, cnorm=\Ez56;2;0;0z\Ez73z\Ez4;1;1z,
-	cr=\r, cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\E[B,
-	cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
-	cuu=\E[%p1%dA, cuu1=\E[A,
-	cvvis=\Ez4;2;1z\Ez56;2;80;24z, dch1=\E[P, dl=\E[%p1%dM,
-	dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H, ht=^I, il=\E[%p1%dL,
-	il1=\E[L, ind=\ED, kbs=^H, kcub1=\E[D, kcud1=\E[B,
-	kcuf1=\E[C, kcuu1=\E[A, kf1=\EOP, kf2=\EOQ, kf3=\EOR,
-	kf4=\EOS, khome=\E[H, nel=\r\ED, rc=\E8, ri=\EM, rmdc=\E[4l,
-	rmir=\E[4l, rmso=\E[m, sc=\E7, sgr0=\E[m, smdc=\E[4h,
-	smir=\E[4h, smso=\E[7m,
+	cr=\r, cub1=^H, cud=\E[%p1%dB, cup=\E[%i%p1%d;%p2%dH,
+	cvvis=\Ez4;2;1z\Ez56;2;80;24z, dch1=\E[P, ed=\E[J,
+	el=\E[K, home=\E[H, ht=^I, ind=\ED, kf1=\EOP, kf2=\EOQ,
+	kf3=\EOR, kf4=\EOS, nel=\r\ED, rc=\E8, ri=\EM, rmdc=\E[4l,
+	rmir=\E[4l, sc=\E7, sgr0=\E[m, smdc=\E[4h, smir=\E[4h,
+	use=ansi+arrows, use=ansi+idl, use=ansi+local,
+	use=ansi+sgrso,
+
 graphos-30|graphos III with 30 lines,
 	lines#30,
 	cvvis=\Ez4;2;1z\Ez56;2;80;30z, use=graphos,
@@ -22625,9 +22956,8 @@ graphos-30|graphos III with 30 lines,
 # graphics and DEC VT100/VT52 + ADM-3A emulation with a VT220-style keyboard.
 #
 
-modgraph|mod24|modgraph terminal emulating vt100,
+modgraph|mod24|modgraph terminal emulating VT100,
 	xenl@,
-	cols#80, lines#24,
 	cvvis=\E\^9;0s\E\^7;1s,
 	is2=\E\^9;0s\E\^7;1s\E[3g\E\^11;9s\E\^11;17s\E\^11;25s\E\^11
 	    ;33s\E\^11;41s\E\^11;49s\E\^11;57s\E\^11;65s\E\^11;73s
@@ -22662,15 +22992,15 @@ modgraph48|mod|Modgraph w/48 lines,
 	OTbs, OTpt, am, xenl,
 	cols#80, it#8, lines#48, vt#3,
 	OTnl=\n, bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[;H\E[2J,
-	cr=\r, csr=\E[%i%p1%d;%p2%dr, cub1=^H, cud1=\n, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, ed=\E[J, el=\E[K,
+	cr=\r, cub1=^H, cud1=\n, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
+	cuu1=\E[A, ed=\E[J, el=\E[K,
 	flash=\E[?5h\E[0q\E[1;2q\E[?5l\E[0q\E[4;3q,
 	home=\E[H, ht=^I, is2=\E<\E[1;48r\E[0q\E[3;4q\E=\E[?1h,
 	kbs=^H, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
-	kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, rc=\E8, rev=\E[7m,
-	ri=\EM, rmkx=\E[?1l\E>, rmso=\E[m, rmul=\E[m,
-	rs1=\E=\E[0q\E>, sc=\E7, sgr0=\E[m, smkx=\E[?1h\E=,
-	smso=\E[7m, smul=\E[4m,
+	kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, rev=\E[7m, ri=\EM,
+	rmkx=\E[?1l\E>, rmso=\E[m, rmul=\E[m, rs1=\E=\E[0q\E>,
+	sgr0=\E[m, smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m,
+	use=ansi+csr,
 
 #### Morrow Designs
 #
@@ -22751,21 +23081,20 @@ rt6221|Ramtek 6221 80x24,
 	OTbs, OTpt, msgr, xon,
 	OTkn#4, cols#80, it#8, lines#24, vt#3,
 	acsc=, bel=^G, blink=\E[5m, bold=\E[1m, civis=\E[>5l,
-	clear=\E[1;1H\E[J, cnorm=\E[>5h\E[>9h, cr=\r,
-	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=^K, cuf=\E[%p1%dC, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\EM,
+	clear=\E[1;1H\E[J, cnorm=\E[>5h\E[>9h, cr=\r, cub1=^H,
+	cud1=^K, cup=\E[%i%p1%d;%p2%dH, cuu1=\EM,
 	cvvis=\E[>7h\E[>9l, ed=\E[J, el=\E[K, home=\E[1;1H, ht=^I,
 	hts=\EH, ind=\n, is2=\E)0, kbs=^H, kcub1=\E[D, kcud1=\E[B,
 	kcuf1=\E[C, kcuu1=\E[A, kf0=\EOP, kf1=\EOQ, kf2=\EOR,
 	kf3=\EOS, lf0=PF1, lf1=PF2, lf2=PF3, lf3=PF4, ll=\E[24;1H,
-	nel=\EE, rc=\E8, rev=\E[7m, ri=\EM, rmacs=^O, rmkx=\E>,
-	rmso=\E[m, rmul=\E[m,
+	nel=\EE, rev=\E[7m, ri=\EM, rmacs=^O, rmkx=\E>, rmso=\E[m,
+	rmul=\E[m,
 	rs1=\E[1w\E[>37m\E[>39m\E[1v\E[20l\E[?3l\E[?6l\E[>5h\E[>6h
 	    \E[>7h\E[>8l\E[>9h\E[>10l\E[1;24r\E[m\E[q\E(B\017\E)0\E#
 	    5\E>,
-	sc=\E7, sgr0=\E[m, smacs=^N, smkx=\E=, smso=\E[7m,
-	smul=\E[4m, tbc=\E[3g,
+	sgr0=\E[m, smacs=^N, smkx=\E=, smso=\E[7m, smul=\E[4m,
+	tbc=\E[3g, use=ansi+csr, use=ansi+local,
+
 # [TO DO: Check out: short forms of ho/cl and ll; reset (\Ec)].
 rt6221-w|Ramtek 6221 160x48,
 	cols#160, lines#48,
@@ -22775,7 +23104,7 @@ rt6221-w|Ramtek 6221 160x48,
 #
 
 # RCA VP3301 or VP3501
-rca|rca vp3301/vp3501,
+rca|RCA vp3301/vp3501,
 	OTbs,
 	cols#40, lines#24,
 	clear=^L, cuf1=^U, cup=\EY%p1%{32}%+%c%p2%{32}%+%c,
@@ -22800,21 +23129,20 @@ rca|rca vp3301/vp3501,
 hirez100|Selanar HiREZ-100,
 	OTbs, OTpt, mir, msgr, xon,
 	OTkn#4, cols#80, it#8, lines#48, vt#3,
-	acsc=, bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[J,
-	cr=\r, cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\n,
-	cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
-	cuu=\E[%p1%dA, cuu1=\EM, dch=\E[%p1%dP, dch1=\E[P,
-	dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H, ht=^I,
-	hts=\EH, il=\E[%p1%dL, il1=\E[L, is2=\E<\E)0, kbs=^H,
-	kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kf0=\EOP,
-	kf1=\EOQ, kf2=\EOR, kf3=\EOS, lf0=PF1, lf1=PF2, lf2=PF3,
-	lf3=PF4, ll=\E[48H, mc0=\E[i, mc4=\E[4i\E[?4i,
-	mc5=\E[?5i\E[5i, nel=\EE, rc=\E8, rev=\E[7m, rmacs=^O,
-	rmkx=\E[?1l\E>, rmso=\E[m, rmul=\E[m,
+	acsc=, bel=^G, blink=\E[5m, bold=\E[1m, cr=\r, cub=\E[%p1%dD,
+	cub1=^H, cud1=\n, cup=\E[%i%p1%d;%p2%dH, cuu1=\EM,
+	dch=\E[%p1%dP, dch1=\E[P, home=\E[H, ht=^I, hts=\EH,
+	is2=\E<\E)0, kbs=^H, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC,
+	kcuu1=\EOA, kf0=\EOP, kf1=\EOQ, kf2=\EOR, kf3=\EOS, lf0=PF1,
+	lf1=PF2, lf2=PF3, lf3=PF4, ll=\E[48H, mc0=\E[i,
+	mc4=\E[4i\E[?4i, mc5=\E[?5i\E[5i, nel=\EE, rc=\E8,
+	rev=\E[7m, rmacs=^O, rmkx=\E[?1l\E>,
 	rs1=\030\E2\E<\E[4i\E[?4i\E[12h\E[2;4;20l\E[?0;7h\E[?1;3;6;1
 	    9l\E[r\E[m\E(B\017\E)0\E>,
-	sc=\E7, sgr0=\E[m, smacs=^N, smkx=\E[?1h\E=, smso=\E[7m,
-	smul=\E[4m, tbc=\E[3g,
+	sc=\E7, sgr0=\E[m, smacs=^N, smkx=\E[?1h\E=, tbc=\E[3g,
+	use=ansi+erase, use=ansi+idl, use=ansi+local,
+	use=ansi+sgrso, use=ansi+sgrul,
+
 hirez100-w|Selanar HiREZ-100 in 132-column mode,
 	cols#132, use=hirez100,
 
@@ -22852,10 +23180,9 @@ vsc|Signetics Vsc Video driver by RMC,
 #
 
 # (soroc120: removed obsolete ":ma=^K^P^R^L^L :" -- esr)
-soroc120|iq120|soroc|soroc iq120,
-	clear=\E*$<2>, cud1=\n, ed=\EY, el=\ET, kcub1=^H, kcud1=\n,
-	kcuf1=^L, kcuu1=^K, use=adm3a,
-soroc140|iq140|soroc iq140,
+soroc120|iq120|soroc|Soroc iq120,
+	clear=\E*$<2>, ed=\EY, el=\ET, use=adm3a,
+soroc140|iq140|Soroc iq140,
 	OTbs, am, mir,
 	cols#80, lines#24,
 	bel=^G, cbt=\EI, clear=\E+, cr=\r, cub1=^H, cud1=\n, cuf1=^L,
@@ -22873,7 +23200,7 @@ soroc140|iq140|soroc iq140,
 #
 
 # (swtp: removed obsolete ":bc=^D:" -- esr)
-swtp|ct82|southwest technical products ct82,
+swtp|ct82|Southwest Technical Products ct82,
 	am,
 	cols#82, lines#20,
 	bel=^G, clear=^L, cr=\r, cub1=^D, cud1=\n, cuf1=^S,
@@ -22925,7 +23252,7 @@ swtp|ct82|southwest technical products ct82,
 #
 
 # Tested, seems to work fine with vi.
-synertek|ktm|synertek380|synertek ktm 3/80 tubeless terminal,
+synertek|ktm|synertek380|Synertek KTM 3/80 tubeless terminal,
 	am,
 	cols#80, lines#24,
 	clear=^Z, cub1=^H, cuf1=^L,
@@ -22945,14 +23272,20 @@ synertek|ktm|synertek380|synertek ktm 3/80 tubeless terminal,
 # <is2> sets 80 col mode, normal video, autowrap on (for <am>).
 # Seems to be no way to get rid of status line.
 # The manual for this puppy was dated June 1981.  It claims to be VT52-
-# compatible but looks more vt100-like.
+# compatible but looks more VT100-like -esr
+#
+# According to
+# https://ub.fnwi.uva.nl/computermuseum/tab13215g.html
+#	This monochrome graphics terminal of TAB Products, California, is a DEC
+#	VT52/VT100/VT132 compatible alphanumeric terminal (TAB 132/15),
+#	factory-fitted with additional hardware for Tektronix 4010 emulation. 
+#	Also the terminal understands a selection of Tektronix 4027 commands. 
 tab132|tab|tab132-15|tab 132/15,
 	da, db,
-	OTdN@, cols#80, lines#24, lm#96,
-	cud1=\n, cup=\E[%i%p1%d;%p2%dH, dch1=\E[P, dl1=\E[M,
-	il1=\E[L, is2=\E[?7h\E[?3l\E[?5l, kcub1=\E[D, kcud1=\E[B,
-	kcuu1=\E[A, rmir=\E[4l, rmkx@, smir=\E[4h, smkx@,
-	use=vt100+4bsd,
+	OTdN@, lm#96,
+	cup=\E[%i%p1%d;%p2%dH, dch1=\E[P, dl1=\E[M, il1=\E[L,
+	is2=\E[?7h\E[?3l\E[?5l, rmir=\E[4l, rmkx@, smir=\E[4h,
+	smkx@, use=decid+cpr, use=vt100+4bsd,
 tab132-w|tab132 in wide mode,
 	cols#132,
 	is2=\E[?7h\E[?3h\E[?5l, use=tab132,
@@ -22976,21 +23309,21 @@ tab132-w-rv|tab132 in reverse-video/wide mode,
 # Model 100) that were ANSI-compatible.
 #
 # Note two things called "teleray".  Reorder should move the common one
-# to the front if you have either.  A dumb teleray with the cursor stuck
+# to the front if you have either.  A dumb Teleray with the cursor stuck
 # on the bottom and no obvious model number is probably a 3700.
 #
 
-t3700|dumb teleray 3700,
+t3700|dumb Teleray 3700,
 	OTbs,
 	cols#80, lines#24,
 	bel=^G, clear=^L, cr=\r, cub1=^H, cud1=\n, ind=\n,
-t3800|teleray 3800 series,
+t3800|Teleray 3800 series,
 	OTbs,
 	cols#80, it#8, lines#24,
 	bel=^G, clear=^L, cr=\r, cub1=^H, cud1=\n, cuf1=\EC,
 	cup=\EY%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K, ed=\EJ, el=\EK,
 	home=\EH, ht=^I, ind=\n, ll=\EY7\s,
-t1061|teleray|teleray 1061,
+t1061|teleray|Teleray 1061,
 	OTbs, am, km, xhp, xt,
 	cols#80, it#8, lines#24, xmc#1,
 	bel=^G, clear=\014$<1>, cr=\r, cub1=^H, cud1=\n, cuf1=\EC,
@@ -23002,7 +23335,7 @@ t1061|teleray|teleray 1061,
 	kf1=^Z1, kf2=^Z2, kf3=^Z3, kf4=^Z4, kf5=^Z5, kf6=^Z6, kf7=^Z7,
 	kf8=^Z8, rmso=\ER@, rmul=\ER@, smso=\s\ERD, smul=\ERH,
 	tbc=\EG,
-t1061f|teleray 1061 with fast PROMs,
+t1061f|Teleray 1061 with fast PROMs,
 	dl1=\EM, il1=\EL, ip@, use=t1061,
 # "Teleray Arpa Special", officially designated as
 # "Teleray Arpa network model 10" with "Special feature 720".
@@ -23014,7 +23347,7 @@ t1061f|teleray 1061 with fast PROMs,
 # Note: this is NOT the old termcap's "t1061f with fast proms."
 # From: J. Lepreau <lepreau@utah-cs> Tue Feb  1 06:39:37 1983, Univ of Utah
 # (t10: removed overridden ":so@:se@:us@:ue@:" -- esr)
-t10|teleray 10 special,
+t10|Teleray 10 special,
 	OTbs, km, xhp, xt,
 	cols#80, it#8, lines#24, xmc#2,
 	clear=\Ej$<30/>, cub1=^H, cud1=\EB, cuf1=\EC,
@@ -23022,22 +23355,22 @@ t10|teleray 10 special,
 	dl1=\EM, ed=\EJ, el=\EK, home=\EH, ht=^I, ich1=\EP, il1=\EL,
 	ind=\Eq, pad=\0, ri=\Ep, rmso=\ER@, rmul=\ER@, smso=\ERD,
 	smul=\ERH,
-# teleray 16 - map the arrow keys for vi/rogue, shifted to up/down page, and
+# Teleray 16 - map the arrow keys for vi/rogue, shifted to up/down page, and
 # back/forth words. Put the function keys (f1-f10) where they can be
 # found, and turn off the other magic keys along the top row, except
 # for line/local. Do the magic appropriate to make the page shifts work.
 # Also toggle ^S/^Q for those of us who use Emacs.
-t16|teleray 16,
+t16|Teleray 16,
 	am, da, db, mir, xhp, xt,
 	cols#80, lines#24,
-	bel=^G, clear=\E[H\E[2J, cr=\r, cub1=^H, cud1=\E[B,
-	cuf1=\E[C, cup=%i\E[%p1%d;%p2%df, cuu1=\E[A, dch1=\E[P,
-	dl1=\E[M, ed=\E[0J, el=\E[0K, home=\E[H, ht=^I, il1=\E[L,
-	ind=\n, kf1=^Z1, kf10=^Z0, kf2=^Z2, kf3=^Z3, kf4=^Z4, kf5=^Z5,
-	kf6=^Z6, kf7=^Z7, kf8=^Z8, kf9=^Z9, ri=\E[T,
-	rmcup=\E[V\E[24;1f\E[?38h, rmir=\E[4l, rmso=\E[m,
-	rmul=\E[m, sgr0=\E[m, smcup=\E[U\E[?38l, smir=\E[4h,
-	smso=\E[7m, smul=\E[4m,
+	bel=^G, clear=\E[H\E[2J, cr=\r, cub1=^H,
+	cup=%i\E[%p1%d;%p2%df, dch1=\E[P, dl1=\E[M, ed=\E[0J,
+	el=\E[0K, home=\E[H, ht=^I, il1=\E[L, ind=\n, kf1=^Z1,
+	kf10=^Z0, kf2=^Z2, kf3=^Z3, kf4=^Z4, kf5=^Z5, kf6=^Z6, kf7=^Z7,
+	kf8=^Z8, kf9=^Z9, ri=\E[T, rmcup=\E[V\E[24;1f\E[?38h,
+	rmir=\E[4l, rmso=\E[m, rmul=\E[m, sgr0=\E[m,
+	smcup=\E[U\E[?38l, smir=\E[4h, smso=\E[7m, smul=\E[4m,
+	use=ansi+local1,
 
 #### Texas Instruments (ti)
 #
@@ -23045,7 +23378,7 @@ t16|teleray 16,
 # The Silent 700 was so called because it was built around a quiet thermal
 # printer.  It was portable, equipped with an acoustic coupler, and pretty
 # neat for its day.
-ti700|ti733|ti735|ti745|ti800|ti silent 700/733/735/745 or omni 800,
+ti700|ti733|ti735|ti745|ti800|Texas Instruments Silent 700/733/735/745 or OMNI 800,
 	OTbs, hc, os,
 	cols#80,
 	bel=^G, cr=\r$<162>, cub1=^H, cud1=\n, ind=\n,
@@ -23056,30 +23389,28 @@ ti700|ti733|ti735|ti745|ti800|ti silent 700/733/735/745 or omni 800,
 # http://www.bitsavers.org/pdf/ti/terminal/silent_700/
 # Refer to:
 #	Model 707 Data Terminal User's Manual
+#	http://www.bitsavers.org/pdf/ti/terminal/silent_700/2310451-0001_Silent_700_Model_707_Users_Manual_Nov1983.pdf
 #
 # pages 2-7 and 2-8 say that the model 707 prints 10.2 characters per inch
 # (cpi) (80 characters per line) by default, and can be switched to/from 17.0
 # cpi using an escape sequence.  There is no 80/132-column capability in
 # terminfo (only the more general cpi which allows any value).
 ti703|ti707|Texas Instruments Silent 703/707,
-	am, hc, os, xenl,
-	cols#80, it#8,
-	bel=^G, cr=\r$<162>, cub1=^H, cud1=\n, cuf1=\s, ind=\n,
-	is2=\EPC\\, nel=\r\n,
-ti703-w|ti707-w|Texas Instruments Silent 703/707,
+	am, xenl,
+	it#8,
+	cuf1=\s, is2=\EPC\\, nel=\r\n, use=ti700,
+ti703-w|ti707-w|Texas Instruments Silent 703/707 (132 column),
 	cols#132,
 	is2=\EPD\\, use=ti703,
 
 #
 # Texas Instruments 916 VDT 7 bit control mode
 #
-ti916|ti916-220-7|Texas Instruments 916 VDT 8859/1 vt220 mode 7 bit CTRL,
-	da, db, in, msgr,
-	cbt=\E[Z, clear=\E[H\E[2J$<6>, cub=\E[%p1%dD,
-	cud=\E[%p1%dB, cuf=\E[%p1%dC, cup=\E[%i%p1%d;%p2%dH,
-	cuu=\E[%p1%dA, dch=\E[%p1%dP$<250>, dch1=\E[P,
-	dl=\E[%p1%dM, ech=\E[%p1%dX$<20>, ed=\E[J$<6>, el=\E[0K,
-	el1=\E[1K, enacs=\E(B\E)0, ff=^L, flash=\E[?5h\E[?5l$<6>,
+ti916|ti916-220-7|Texas Instruments 916 VDT 8859/1 VT220 mode 7 bit CTRL,
+	da, db, in,
+	cbt=\E[Z, clear=\E[H\E[2J$<6>, dch=\E[%p1%dP$<250>,
+	ech=\E[%p1%dX$<20>, ed=\E[J$<6>, el=\E[0K,
+	enacs=\E(B\E)0, ff=^L, flash=\E[?5h\E[?5l$<6>,
 	hpa=\E[%p1%{1}%+%dG, hts=\E[0W, ich=\E[%p1%d@$<250>,
 	il=\E[%p1%dL$<36>, ip=$<10>, is2=\E[1;24r\E[24;1H,
 	kcmd=\E[29~, kdch1=\E[P, kent=\n, kf1=\E[17~, kf10=\E[28~,
@@ -23087,54 +23418,52 @@ ti916|ti916-220-7|Texas Instruments 916 VDT 8859/1 vt220 mode 7 bit CTRL,
 	kf4=\E[20~, kf5=\E[21~, kf6=\E[23~, kf7=\E[24~, kf8=\E[25~,
 	kf9=\E[26~, khome=\E[H, kich1=\E[@, knp=\E[S, kpp=\E[T,
 	kprt=^X, prot=\E&, rmacs=\017$<2>, rs2=\E[!p, sgr@,
-	smacs=\016$<2>, tbc=\E[3g, vpa=\E[%p1%{1}%+%dd,
-	use=vt220,
+	smacs=\016$<2>, vpa=\E[%p1%{1}%+%dd, use=vt220,
 #
 # Texas Instruments 916 VDT 8 bit control mode
 #
-ti916-8|ti916-220-8|Texas Instruments 916 VDT 8859/1 8 vt220 mode bit CTRL,
+ti916-8|ti916-220-8|Texas Instruments 916 VDT 8859/1 8 VT220 mode bit CTRL,
 	kcmd=\23329~, kcub1=\233D, kcud1=\233B, kcuf1=\233C,
-	kcuu1=\233A, kdch1=\233P, kent=\n, kf1=\23317~,
-	kf10=\23328~, kf11=\23329~, kf12=\23331~, kf2=\23318~,
-	kf3=\23319~, kf4=\23320~, kf5=\23321~, kf6=\23323~,
-	kf7=\23324~, kf8=\23325~, kf9=\23326~, khome=\233H,
-	kich1=\233@, knp=\233S, kpp=\233T, kprt=^X, use=ti916,
+	kcuu1=\233A, kdch1=\233P, kf1=\23317~, kf10=\23328~,
+	kf11=\23329~, kf12=\23331~, kf2=\23318~, kf3=\23319~,
+	kf4=\23320~, kf5=\23321~, kf6=\23323~, kf7=\23324~,
+	kf8=\23325~, kf9=\23326~, khome=\233H, kich1=\233@,
+	knp=\233S, kpp=\233T, use=ti916,
 #
 # Texas Instruments 916 VDT 8859/1 7 bit control 132 column mode
 #
-ti916-132|Texas Instruments 916 VDT vt220 132 column,
+ti916-132|Texas Instruments 916 VDT VT220 132 column,
 	cols#132, use=ti916,
 #
 # Texas Instruments 916 VDT 8859/1 8 bit control 132 column mode
 #
-ti916-8-132|Texas Instruments 916 VDT 8-bit vt220 132 column,
+ti916-8-132|Texas Instruments 916 VDT 8-bit VT220 132 column,
 	cols#132, use=ti916-8,
 ti924|Texas Instruments 924 VDT 8859/1 7 bit CTRL,
 	OTbs, am, xon,
 	cols#80, it#8, lines#24,
 	bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[2J\E[H, cr=\r,
-	csr=%i\E[%p1%d;%p2%dr, cub1=\E[D, cud1=\E[B, cuf1=\E[C,
-	cup=%i\E[%p1%d;%p2%dH, cuu1=\E[A, cvvis=\E[?31h,
-	dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H, ht=^I, hts=\EH,
-	il1=\E[L, ind=\ED, kbs=^H, kcub1=\E[D, kcud1=\E[B,
+	csr=%i\E[%p1%d;%p2%dr, cup=%i\E[%p1%d;%p2%dH,
+	cvvis=\E[?31h, dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H, ht=^I,
+	hts=\EH, il1=\E[L, ind=\ED, kbs=^H, kcub1=\E[D, kcud1=\E[B,
 	kcuf1=\E[C, kcuu1=\E[A, kdch1=\E[P, kf1=\EOP, kf2=\EOQ,
 	kf3=\EOR, kf4=\EOS, kf5=\E[16~, kf6=\E[17~, kf7=\E[18~,
 	kf8=\E[19~, kf9=\E[20~, kich1=\E[@, rc=\E8, rev=\E[7m,
 	ri=\EM, rmso=\E[m, rmul=\E[m, sc=\E7, sgr0=\E[m, smso=\E[7m,
-	smul=\E[4m, tbc=\E[3g, use=vt220+cvis,
+	smul=\E[4m, tbc=\E[3g, use=ansi+local1, use=vt220+cvis,
 ti924-8|Texas Instruments 924 VDT 8859/1 8 bit CTRL,
 	am, xon,
 	cols#80, it#8, lines#24,
 	bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[2J\E[H, cr=\r,
-	csr=%i\E[%p1%d;%p2%dr, cub1=\E[D, cud1=\E[B, cuf1=\E[C,
-	cup=%i\E[%p1%d;%p2%dH, cuu1=\E[A, cvvis=\E[?31h,
-	dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H, ht=^I, hts=\EH,
-	il1=\E[L, ind=\ED, kbs=^H, kcub1=\E[D, kcud1=\E[B,
+	csr=%i\E[%p1%d;%p2%dr, cup=%i\E[%p1%d;%p2%dH,
+	cvvis=\E[?31h, dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H, ht=^I,
+	hts=\EH, il1=\E[L, ind=\ED, kbs=^H, kcub1=\E[D, kcud1=\E[B,
 	kcuf1=\E[C, kcuu1=\E[A, kdch1=\233P, kf1=\217P, kf2=\217Q,
 	kf3=\217R, kf4=\217S, kf5=\23316~, kf6=\23317~,
 	kf7=\23318~, kf8=\23319~, kf9=\23320~, kich1=\233@, rc=\E8,
 	rev=\E[7m, ri=\EM, rmso=\E[m, rmul=\E[m, sc=\E7, sgr0=\E[m,
-	smso=\E[7m, smul=\E[4m, tbc=\E[3g, use=vt220+cvis,
+	smso=\E[7m, smul=\E[4m, tbc=\E[3g, use=ansi+local1,
+	use=vt220+cvis,
 ti924w|Texas Instruments 924 VDT 7 bit - 132 column mode,
 	cols#132, use=ti924,
 ti924-8w|Texas Instruments 924 VDT 8 bit - 132 column mode,
@@ -23146,11 +23475,11 @@ ti931|Texas Instruments 931 VDT,
 	cud1=\EB, cuf1=\EC, cup=\EY%p1%{32}%+%c%p2%{32}%+%c,
 	cuu1=\EA, dch1=\EQ, dl1=\EO, ed=\EJ, el=\EI, home=\EH,
 	ich1=\ER\EP\EM, il1=\EN, ind=\Ea, invis=\E4H,
-	is2=\EGB\E(@B@@\E), kcub1=\ED, kcud1=\EB, kcuf1=\EC,
-	kcuu1=\EA, kdch1=\EQ, kdl1=\EO, kf1=\Ei1, kf2=\Ei2, kf3=\Ei3,
-	kf4=\Ei4, kf5=\Ei5, kf6=\Ei6, kf7=\Ei7, kf8=\Ei8, kf9=\Ei9,
-	kich1=\EP, kil1=\EN, rev=\E4B, ri=\Eb, rmso=\E4@, rmul=\E4@,
-	sgr0=\E4@, smso=\E4A, smul=\E4D,
+	is2=\EGB\E(@B@@\E), kdch1=\EQ, kdl1=\EO, kf1=\Ei1,
+	kf2=\Ei2, kf3=\Ei3, kf4=\Ei4, kf5=\Ei5, kf6=\Ei6, kf7=\Ei7,
+	kf8=\Ei8, kf9=\Ei9, kich1=\EP, kil1=\EN, rev=\E4B, ri=\Eb,
+	rmso=\E4@, rmul=\E4@, sgr0=\E4@, smso=\E4A, smul=\E4D,
+	use=vt52+arrows,
 ti926|Texas Instruments 926 VDT 8859/1 7 bit CTRL,
 	csr@, ind=\E[1S, ri=\E[1T, use=ti924,
 # (ti926-8: I corrected this from the broken SCO entry -- esr)
@@ -23160,16 +23489,14 @@ ti_ansi|basic entry for ti928,
 	am, bce, eo, xenl, xon,
 	colors#8, cols#80, it#8, lines#25, pairs#64,
 	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, clear=\E[2J\E[H,
-	cr=\r, csr=\E[%i%p1%d;%p2%dr, cub1=^H, cud1=\E[B,
-	cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, dch1=\E[P,
-	dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H, ht=^I, ich1=\E[@,
-	il1=\E[L, ind=\E[S, kbs=^H, kcub1=\E[D, kcud1=\E[B,
-	kcuf1=\E[C, kcuu1=\E[A, kend=\E[F, kf0=\E[V, kf1=\E[M,
-	kf2=\E[N, kf3=\E[O, kf4=\E[P, kf5=\E[Q, kf6=\E[R, kf7=\E[S,
-	kf8=\E[T, kf9=\E[U, khome=\E[H, knp=\E[G, kpp=\E[I,
-	op=\E[37;40m, ri=\E[T, rmso=\E[m, rmul=\E[m,
+	cr=\r, csr=\E[%i%p1%d;%p2%dr, cub1=^H,
+	cup=\E[%i%p1%d;%p2%dH, dch1=\E[P, dl1=\E[M, ed=\E[J,
+	el=\E[K, home=\E[H, ht=^I, ich1=\E[@, il1=\E[L, ind=\E[S,
+	kend=\E[F, kf0=\E[V, kf1=\E[M, kf2=\E[N, kf3=\E[O, kf4=\E[P,
+	kf5=\E[Q, kf6=\E[R, kf7=\E[S, kf8=\E[T, kf9=\E[U, knp=\E[G,
+	kpp=\E[I, op=\E[37;40m, ri=\E[T, rmso=\E[m, rmul=\E[m,
 	setab=\E[4%p1%dm, setaf=\E[3%p1%dm, sgr0=\E[m,
-	smso=\E[7m, smul=\E[4m,
+	smso=\E[7m, smul=\E[4m, use=ansi+arrows, use=ansi+local1,
 #
 #       928 VDT 7 bit control mode
 #
@@ -23197,7 +23524,7 @@ ti928-8|Texas Instruments 928 VDT 8859/1 8 bit CTRL,
 # had just <smso>=\EG6 which I think means standout was supposed to be
 # dim-reverse using ADM12-style attributes. ADM12 <smul>/<rmul> and
 # <invis> might work-- esr)
-zen30|z30|zentec 30,
+zen30|z30|Zentec 30,
 	OTbs, am, mir, ul,
 	cols#80, lines#24,
 	bel=^G, clear=\E*, cr=\r, cub1=^H, cud1=\n, cuf1=^L,
@@ -23210,7 +23537,7 @@ zen30|z30|zentec 30,
 # UK/DK/RK/LK/HM were someone's aliases for ku/kd/kl/kr/kh,
 # which were also in the original entry -- esr)
 # (zen50: removed obsolete ":ma=^Hh^Ll^Jj^Kk:" -- esr)
-zen50|z50|zentec zephyr,
+zen50|z50|Zentec Zephyr,
 	OTbs, am,
 	cols#80, lines#24, xmc#1,
 	clear=\E+, cub1=^H, cup=\E=%p1%{32}%+%c%p2%{32}%+%c,
@@ -23226,10 +23553,9 @@ cci|cci1|z8001|zen8001|CCI Custom Zentec 8001,
 	csr=\ER%p1%{32}%+%c%p2%{32}%+%c, cub1=^H, cud1=\n,
 	cuf1=\EC, cup=\EY%p1%{32}%+%c%p2%{32}%+%c, cuu1=\EA,
 	cvvis=\EF\EQ\EM \ER 7, dim=\EM!, ed=\EJ, el=\EK, home=\EH,
-	invis=\EM(, is2=\EM \EF\ET\EP\ER 7, kbs=^H, kcub1=\ED,
-	kcud1=\EB, kcuf1=\EC, kcuu1=\EA, khome=\EH, mc4=^T, mc5=^R,
-	rev=\EM$, ri=\EI, rmso=\EM\s, rmul=\EM\s, sgr0=\EM\s,
-	smso=\EM$, smul=\EM0,
+	invis=\EM(, is2=\EM \EF\ET\EP\ER 7, kbs=^H, khome=\EH,
+	mc4=^T, mc5=^R, rev=\EM$, ri=\EI, rmso=\EM\s, rmul=\EM\s,
+	sgr0=\EM\s, smso=\EM$, smul=\EM0, use=vt52+arrows,
 
 ######## OBSOLETE UNIX CONSOLES
 #
@@ -23241,7 +23567,7 @@ cci|cci1|z8001|zen8001|CCI Custom Zentec 8001,
 #
 
 # From: Gary Darland <goodmanc@garnet.berkeley.edu>
-apollo|apollo console,
+apollo|Apollo console,
 	OTbs, am, mir,
 	cols#88, lines#53,
 	clear=^L, cub1=^H, cud1=\EB, cuf1=\EC,
@@ -23253,13 +23579,16 @@ apollo|apollo console,
 # We don't know whether or not the apollo guys replicated DEC's firmware bug
 # in the VT132 that reversed <rmir>/<smir>.  To be on the safe side, disable
 # both these capabilities.
-apollo_15P|apollo 15 inch display,
-	rmir@, smir@, use=vt132,
-apollo_19L|apollo 19 inch display,
-	rmir@, smir@, use=vt132,
-apollo_color|apollo color display,
+apollo+vt132|Apollo console emulating VT132,
 	rmir@, smir@, use=vt132,
 
+apollo_15P|Apollo 15 inch display,
+	use=apollo+vt132,
+apollo_19L|Apollo 19 inch display,
+	use=apollo+vt132,
+apollo_color|Apollo color display,
+	use=apollo+vt132,
+
 #### AT&T consoles
 
 # This actually describes the generic SVr4 display driver for Intel boxes.
@@ -23267,42 +23596,38 @@ apollo_color|apollo color display,
 # From: Eric Raymond <esr@snark.thyrsus.com> Mon Nov 27 19:00:53 EST 1995
 att6386|at386|386at|AT&T WGS 6386 console,
 	am, bw, eo, xon,
-	cols#80, it#8, lines#25,
+	cols#80, lines#25,
 	acsc=``a1fxgqh0jYk?lZm@nEooppqDrrsstCu4vAwBx3yyzz{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[=C,
-	clear=\E[2J\E[H, cnorm=\E[=1C, cr=\r, cub=\E[%p1%dD,
-	cub1=\E[D, cud=\E[%p1%dB, cud1=\E[B, cuf=\E[%p1%dC,
-	cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA,
-	cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m,
-	dl=\E[%p1%dM, dl1=\E[1M, ech=\E[%p1%dX, ed=\E[J, el=\E[K,
-	home=\E[H, hpa=\E[%i%p1%dG, ht=^I, hts=\EH, ich=\E[%p1%d@,
+	bel=^G, civis=\E[=C, clear=\E[2J\E[H, cnorm=\E[=1C, cr=\r,
+	cup=\E[%i%p1%d;%p2%dH, dch=\E[%p1%dP, dch1=\E[P,
+	dim=\E[2m, dl=\E[%p1%dM, dl1=\E[1M, ech=\E[%p1%dX, ed=\E[J,
+	el=\E[K, home=\E[H, hpa=\E[%i%p1%dG, ich=\E[%p1%d@,
 	ich1=\E[1@, il=\E[%p1%dL, il1=\E[1L, ind=\E[S, invis=\E[9m,
-	is2=\E[0;10;39m, kbs=^H, kcbt=^], kcub1=\E[D, kcud1=\E[B,
-	kcuf1=\E[C, kcuu1=\E[A, kdch1=\E[P, kend=\E[Y, kf1=\EOP,
+	is2=\E[0;10;39m, kcbt=^], kdch1=\E[P, kend=\E[Y, kf1=\EOP,
 	kf10=\EOY, kf11=\EOZ, kf12=\EOA, kf2=\EOQ, kf3=\EOR,
 	kf4=\EOS, kf5=\EOT, kf6=\EOU, kf7=\EOV, kf8=\EOW, kf9=\EOX,
-	khome=\E[H, kich1=\E[@, knp=\E[U, kpp=\E[V, krmir=\E0,
-	nel=\r\E[S, rc=\E8, rev=\E[7m, ri=\E[T, rmacs=\E[10m,
-	rmso=\E[m, rmul=\E[m, sc=\E7,
+	kich1=\E[@, knp=\E[U, kpp=\E[V, krmir=\E0, nel=\r\E[S,
+	rc=\E8, ri=\E[T, rmacs=\E[10m, sc=\E7,
 	sgr=\E[10m\E[0%?%p1%p3%|%t;7%;%?%p2%t;4%;%?%p4%t;5%;%?%p5%t;
 	    2%;%?%p6%t;1%;%?%p9%t;12%e;10%;%?%p7%t;9%;m,
-	sgr0=\E[0;10m, smacs=\E[12m, smso=\E[7m, smul=\E[4m,
-	tbc=\E[3g, vpa=\E[%i%p1%dd, use=ecma+index,
-	use=klone+color,
+	sgr0=\E[0;10m, smacs=\E[12m, vpa=\E[%i%p1%dd,
+	use=ansi+arrows, use=ansi+inittabs, use=ansi+local,
+	use=ansi+sgrbold, use=ecma+index, use=klone+color,
+
 # (pc6300plus: removed ":KM=/usr/lib/ua/kmap.s5:"; renamed BO/EE/CI/CV -- esr)
 pc6300plus|AT&T 6300 plus,
 	OTbs, am, xon,
 	cols#80, lines#24,
 	bel=^G, blink=\E[5m, bold=\E[1m, civis=\E[=C,
-	clear=\E[2J\E[H, cnorm=\E[=1C, cr=\r, cub1=^H, cud1=\E[B,
-	cuf1=\E[C, cup=\E[%i%p1%2d;%p2%2dH, cuu1=\E[A,
-	dch1=\E[1P, dim=\E[2m, dl1=\E[1M, ed=\E[0J, el=\E[0K,
-	home=\E[H, hts=\EH, ich1=\E[1@, il1=\E[1L, ind=\n,
-	invis=\E[9m, kbs=^H, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C,
-	kcuu1=\E[A, kf1=\EOc, kf10=\EOu, kf2=\EOd, kf3=\EOe,
-	kf4=\EOf, kf5=\EOg, kf6=\EOh, kf7=\EOi, kf8=\EOj, kf9=\EOk,
-	nel=\r\n, rev=\E[7m, rmso=\E[m, rmul=\E[m, sgr0=\E[m,
-	smso=\E[7m, smul=\E[4m, tbc=\E[3g,
+	clear=\E[2J\E[H, cnorm=\E[=1C, cr=\r, cub1=^H,
+	cup=\E[%i%p1%2d;%p2%2dH, dch1=\E[1P, dim=\E[2m,
+	dl1=\E[1M, ed=\E[0J, el=\E[0K, home=\E[H, hts=\EH,
+	ich1=\E[1@, il1=\E[1L, ind=\n, invis=\E[9m, kbs=^H,
+	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kf1=\EOc,
+	kf10=\EOu, kf2=\EOd, kf3=\EOe, kf4=\EOf, kf5=\EOg, kf6=\EOh,
+	kf7=\EOi, kf8=\EOj, kf9=\EOk, nel=\r\n, rev=\E[7m, rmso=\E[m,
+	rmul=\E[m, sgr0=\E[m, smso=\E[7m, smul=\E[4m, tbc=\E[3g,
+	use=ansi+local1,
 
 # From: Benjamin C. W. Sittler <bsittler@nmt.edu>
 #
@@ -23425,28 +23750,25 @@ att7300|unixpc|pc7300|3b1|s4|AT&T UNIX PC Model 7300,
 	am, xon,
 	cols#80, it#8, lines#24,
 	bel=^G, blink=\E[9m, bold=\E[1m, cbt=\E^I, civis=\E[=1C,
-	clear=\E[2J\E[H, cnorm=\E[=0C, cr=\r, cub=\E[%p1%dD,
-	cub1=^H, cud=\E[%p1%dB, cud1=\E[B, cuf=\E[%p1%dC,
-	cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA,
-	cuu1=\E[A, dch1=\E[P, dim=\E[2m, dl=\E[%p1%dM, dl1=\E[M,
-	ed=\E[0J, el=\E[0K, home=\E[H, ich1=\E[@, il=\E[%p1%dL,
-	il1=\E[L, ind=\n, invis=\E[9m, is1=\017\E[=1w, kBEG=\ENB,
-	kCAN=\EOW, kCPY=\END, kCRT=\EON, kDC=\ENF, kDL=\ENE,
-	kEND=\ENN, kEOL=\EOA, kFND=\EOX, kHLP=\EOM, kHOM=\ENM,
-	kIC=\ENJ, kLFT=\ENK, kMOV=\ENC, kNXT=\ENH, kOPT=\EOR,
-	kPRV=\ENG, kRDO=\EOT, kRIT=\ENL, kRPL=\EOY, kSAV=\EOO,
-	kUND=\EOS, kbeg=\ENb, kbs=^H, kcan=\EOw, kcbt=\E[Z,
-	kclo=\EOV, kclr=\E[J, kcmd=\EOu, kcpy=\ENd, kcrt=\EOn,
-	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kdch1=\ENf,
-	ked=\E[J, kel=\EOa, kend=\E0, kext=\EOk, kf1=\EOc, kf2=\EOd,
-	kf3=\EOe, kf4=\EOf, kf5=\EOg, kf6=\EOh, kf7=\EOi, kf8=\EOj,
-	kfnd=\EOx, khlp=\EOm, khome=\E[H, kich1=\ENj, kind=\E[B,
-	kmov=\ENc, kmrk=\ENi, knp=\E[U, knxt=\ENh, kopn=\EOv,
-	kopt=\EOr, kpp=\E[V, kprt=\EOz, kprv=\ENg, krdo=\EOt,
-	kref=\EOb, krfr=\ENa, kri=\E[A, krpl=\EOy, krst=\EOB,
-	ksav=\EOo, kslt=\ENI, kund=\EOs, nel=\EE, rev=\E[7m, ri=\EM,
-	rmso=\E[m, rmul=\E[m, sgr0=\E[0;10m, smso=\E[7m,
-	smul=\E[4m,
+	clear=\E[2J\E[H, cnorm=\E[=0C, cr=\r, cub1=^H,
+	cup=\E[%i%p1%d;%p2%dH, dch1=\E[P, dim=\E[2m, ed=\E[0J,
+	el=\E[0K, home=\E[H, ich1=\E[@, ind=\n, invis=\E[9m,
+	is1=\017\E[=1w, kBEG=\ENB, kCAN=\EOW, kCPY=\END, kCRT=\EON,
+	kDC=\ENF, kDL=\ENE, kEND=\ENN, kEOL=\EOA, kFND=\EOX,
+	kHLP=\EOM, kHOM=\ENM, kIC=\ENJ, kLFT=\ENK, kMOV=\ENC,
+	kNXT=\ENH, kOPT=\EOR, kPRV=\ENG, kRDO=\EOT, kRIT=\ENL,
+	kRPL=\EOY, kSAV=\EOO, kUND=\EOS, kbeg=\ENb, kcan=\EOw,
+	kcbt=\E[Z, kclo=\EOV, kclr=\E[J, kcmd=\EOu, kcpy=\ENd,
+	kcrt=\EOn, kdch1=\ENf, ked=\E[J, kel=\EOa, kend=\E0,
+	kext=\EOk, kf1=\EOc, kf2=\EOd, kf3=\EOe, kf4=\EOf, kf5=\EOg,
+	kf6=\EOh, kf7=\EOi, kf8=\EOj, kfnd=\EOx, khlp=\EOm,
+	kich1=\ENj, kind=\E[B, kmov=\ENc, kmrk=\ENi, knp=\E[U,
+	knxt=\ENh, kopn=\EOv, kopt=\EOr, kpp=\E[V, kprt=\EOz,
+	kprv=\ENg, krdo=\EOt, kref=\EOb, krfr=\ENa, kri=\E[A,
+	krpl=\EOy, krst=\EOB, ksav=\EOo, kslt=\ENI, kund=\EOs,
+	nel=\EE, rev=\E[7m, ri=\EM, rmso=\E[m, rmul=\E[m,
+	sgr0=\E[0;10m, smso=\E[7m, smul=\E[4m, use=ansi+arrows,
+	use=ansi+idl, use=ansi+local,
 
 #### Convergent Technology
 #
@@ -23522,15 +23844,14 @@ fos|fortune|Fortune system,
 	acsc=j*k(l m"q&v%w#x-, bel=^G, blink=\EN, civis=\E],
 	clear=\014$<20>, cnorm=\E\\, cr=\r, cub1=^H, cud1=\n$<3>,
 	cup=\034C%p1%{32}%+%c%p2%{32}%+%c, cuu1=\013$<3>,
-	cvvis=\E\:, dch1=\034W$<5>, dl1=\034R$<15>,
-	ed=\034Y$<3*>, el=^\Z, home=\036$<10>, ht=^Z,
-	ich1=\034Q$<5>, il1=\034E$<15>, ind=\n, is2=^_.., kbs=^H,
-	kcub1=^Aw\r, kcud1=^Ay\r, kcuf1=^Az\r, kcuu1=^Ax\r,
-	kend=^Ak\r, kent=^Aq, kf1=^Aa\r, kf2=^Ab\r, kf3=^Ac\r,
-	kf4=^Ad\r, kf5=^Ae\r, kf6=^Af\r, kf7=^Ag\r, kf8=^Ah\r,
-	khome=^A?\r, knp=^Ao\r, kpp=^An\r, nel=\r\n, rev=\EH,
-	rmacs=^O, rmso=^\I`, rmul=^\IP, sgr0=\EI, smacs=\Eo,
-	smso=^\H`, smul=^\HP,
+	cvvis=\E:, dch1=\034W$<5>, dl1=\034R$<15>, ed=\034Y$<3*>,
+	el=^\Z, home=\036$<10>, ht=^Z, ich1=\034Q$<5>,
+	il1=\034E$<15>, ind=\n, is2=^_.., kbs=^H, kcub1=^Aw\r,
+	kcud1=^Ay\r, kcuf1=^Az\r, kcuu1=^Ax\r, kend=^Ak\r,
+	kent=^Aq, kf1=^Aa\r, kf2=^Ab\r, kf3=^Ac\r, kf4=^Ad\r,
+	kf5=^Ae\r, kf6=^Af\r, kf7=^Ag\r, kf8=^Ah\r, khome=^A?\r,
+	knp=^Ao\r, kpp=^An\r, nel=\r\n, rev=\EH, rmacs=^O, rmso=^\I`,
+	rmul=^\IP, sgr0=\EI, smacs=\Eo, smso=^\H`, smul=^\HP,
 
 #### Masscomp consoles
 #
@@ -23543,11 +23864,11 @@ fos|fortune|Fortune system,
 masscomp|masscomp workstation console,
 	OTbs, km, mir,
 	cols#80, it#8, lines#24,
-	clear=\E[2J, cub1=^H, cud1=\E[B, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, dch1=\E[P, dl1=\E[M,
-	ed=\E[J, el=\E[K, ht=^I, il1=\E[L, is2=\EGc\EGb\EGw, kbs=^H,
-	kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, rmir=\E[4l,
-	rmso=\E[m, rmul=\EGau, smir=\E[4h, smso=\E[7m, smul=\EGu,
+	clear=\E[2J, cub1=^H, cup=\E[%i%p1%d;%p2%dH, dch1=\E[P,
+	dl1=\E[M, ed=\E[J, el=\E[K, ht=^I, il1=\E[L,
+	is2=\EGc\EGb\EGw, kbs=^H, kcub1=\EOD, kcud1=\EOB,
+	kcuf1=\EOC, kcuu1=\EOA, rmir=\E[4l, rmso=\E[m, rmul=\EGau,
+	smir=\E[4h, smso=\E[7m, smul=\EGu, use=ansi+local1,
 masscomp1|masscomp large screen version 1,
 	cols#104, lines#36, use=masscomp,
 masscomp2|masscomp large screen version 2,
@@ -23575,10 +23896,9 @@ pmcons|pmconsole|PMAX console,
 pcix|PC/IX console,
 	am, bw, eo,
 	cols#80, lines#24,
-	clear=\Ec, cub1=^H, cud1=\E[B, cuf1=\E[C,
-	cup=\E[%i%p1%2d;%p2%2dH, cuu1=\E[A, ed=\E[J, el=\E[K,
-	home=\E[H, rmso=\E[m, rmul=\E[m, sgr0=\E[m, smso=\E[7m,
-	smul=\E[4m,
+	clear=\Ec, cub1=^H, cup=\E[%i%p1%2d;%p2%2dH, ed=\E[J,
+	el=\E[K, home=\E[H, rmso=\E[m, rmul=\E[m, sgr0=\E[m,
+	smso=\E[7m, smul=\E[4m, use=ansi+local1,
 
 # (ibmpcx: this entry used to be known as ibmx.
 # It formerly included the following extension capabilities:
@@ -23594,12 +23914,11 @@ pcix|PC/IX console,
 ibmpcx|xenix|ibmx|IBM PC xenix console display,
 	OTbs, am, msgr,
 	cols#80, lines#25,
-	clear=^L, cub1=^H, cud1=\E[B, cuf1=\E[C,
-	cup=\E[%p1%d;%p2%dH, cuu1=\E[A, dch1=\E[P, dl1=\E[M,
-	ed=\E[J, el=\E[K, home=\E[H, ich1=\E[@, il1=\E[L, kbs=^H,
-	kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kend=\E[d,
-	kf1=\E[K, kf2=\E[L, kf3=\E[M, kf4=\E[N, khome=\E[Y, knp=\E[e,
-	kpp=\E[Z, use=klone+acs, use=klone+sgr8,
+	clear=^L, cub1=^H, cup=\E[%p1%d;%p2%dH, dch1=\E[P,
+	dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H, ich1=\E[@, il1=\E[L,
+	kend=\E[d, kf1=\E[K, kf2=\E[L, kf3=\E[M, kf4=\E[N,
+	khome=\E[Y, knp=\E[e, kpp=\E[Z, use=ansi+arrows,
+	use=ansi+local1, use=klone+acs, use=klone+sgr8,
 
 ######## OTHER OBSOLETE TYPES
 #
@@ -23647,9 +23966,7 @@ ctrm|C terminal emulator,
 	cup=\E&a%p2%dc%p1%dY, cuu1=\EA, dch1=\EP$<2>, dl1=\EM,
 	ed=\EJ, el=\EK, hpa=\E&a%p1%dC, ht=\011$<2>, hts=\E1,
 	il1=\EL, ind=\n, ip=$<2>, is2=\E&jA\r, kbs=^H, kcub1=\Eu\r,
-	kcud1=\Ew\r, kcuf1=\Ev\r, kcuu1=\Et\r, kf1=\Ep\r,
-	kf2=\Eq\r, kf3=\Er\r, kf4=\Es\r, kf5=\Et\r, kf6=\Eu\r,
-	kf7=\Ev\r, kf8=\Ew\r, khome=\Ep\r,
+	kcud1=\Ew\r, kcuf1=\Ev\r, kcuu1=\Et\r, khome=\Ep\r,
 	op=\E&bn\E&bB\E&bG\E&bR%{0}%PX%{0}%PY%{0}%PZ%{1}%PW%{1}%PV
 	   %{1}%PU,
 	rev=%?%gB%{0}%=%t\E&dB%{1}%PB%;, rmir=\ER, rmkx=\E&jA,
@@ -23666,6 +23983,7 @@ ctrm|C terminal emulator,
 	    %t\E&dD%;,
 	sgr0=\E&d@%{0}%PA%{0}%PB%{0}%PH, smir=\EQ, smkx=\E&jB,
 	smso=\E&dD, smul=\E&dD, tbc=\E3, vpa=\E&a%p1%dY,
+	use=hp+pfk+cr,
 
 # gs6300 - can't use blue foreground, it clashes with underline;
 # it's simulated with cyan
@@ -23676,48 +23994,45 @@ gs6300|emots|AT&T PC6300 with EMOTS terminal emulator,
 	colors#8, cols#80, it#8, lines#24, pairs#63,
 	acsc=++\,\,--..``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyz
 	     z{{||}}~~,
-	bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[J, cr=\r,
-	cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\n,
-	cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
-	cuu=\E[%p1%dA, cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[P,
-	dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H, ht=^I,
-	ich=\E[%p1%d@, ich1=\E[@, il=\E[%p1%dL, il1=\E[L, ind=\n,
-	is2=\E[m, kbs=^H, kcbt=^R^I, kcub1=\E[D, kcud1=\E[B,
-	kcuf1=\E[C, kcuu1=\E[A, kf1=\E[0s, kf2=\E[24s, kf3=\E[1s,
-	kf4=\E[23s, kf5=\E[2s, kf6=\E[22s, kf7=\E[3s, kf8=\E[21s,
-	khome=\E[H, mc4=\E[4i, mc5=\E[5i, op=\E[?;m, rev=\E[7m,
-	ri=\E[L, rmacs=\E[10m, rs1=\Ec, setb=\E[?;%p1%dm,
+	bel=^G, blink=\E[5m, bold=\E[1m, cr=\r, cub1=^H, cud1=\n,
+	cup=\E[%i%p1%d;%p2%dH, dch=\E[%p1%dP, dch1=\E[P,
+	home=\E[H, ht=^I, ich=\E[%p1%d@, ich1=\E[@, ind=\n, is2=\E[m,
+	kcbt=^R^I, kf1=\E[0s, kf2=\E[24s, kf3=\E[1s, kf4=\E[23s,
+	kf5=\E[2s, kf6=\E[22s, kf7=\E[3s, kf8=\E[21s, mc4=\E[4i,
+	mc5=\E[5i, op=\E[?;m, rev=\E[7m, ri=\E[L, rmacs=\E[10m,
+	rs1=\Ec, setb=\E[?;%p1%dm,
 	setf=\E[?%?%p1%{0}%=%t0%e%p1%{1}%=%t2%e%p1%{1}%-%d%;m,
 	sgr0=\E[m\E[10m, smacs=\E[11m, smso=\E[1m, smul=\E[4m,
+	use=ansi+arrows, use=ansi+erase, use=ansi+idl,
+	use=ansi+local,
 
 # From: <earle@smeagol.UUCP> 29 Oct 85 05:40:18 GMT
 # MS-Kermit with Heath-19 emulation mode enabled
 # (h19k: changed ":pt@:" to ":it@"
-h19k|h19kermit|heathkit emulation provided by Kermit (no auto margin),
+h19k|h19kermit|Heathkit emulation provided by Kermit (no auto margin),
 	am@, da, db, xt,
 	it@,
 	ht@, use=h19-u,
 
-# Apple Macintosh with Versaterm, a terminal emulator distributed by Synergy
+# Apple Macintosh with VersaTerm, a terminal emulator distributed by Synergy
 # Software (formerly Peripherals Computers & Supplies, Inc) of
 # 2457 Perkiomen Ave., Reading, PA 19606, 1-800-876-8376.  They can
 # also be reached at support@synergy.com.
-versaterm|versaterm vt100 emulator for the Macintosh,
+versaterm|VersaTerm VT100 emulator for the Macintosh,
 	am, xenl,
 	cols#80, it#8, lines#24,
 	bel=^G, blink=\E[5m$<2/>, bold=\E[1m$<2/>,
-	clear=\E[;H\E[2J$<50/>, cr=\r, csr=\E[%i%p1%d;%p2%dr,
-	cub1=^H, cud1=\n, cuf1=\E[C$<2/>,
-	cup=\E[%i%p1%d;%p2%dH$<5/>, cuu1=\E[A$<2/>,
-	dch1=\E[1P$<7/>, dl1=\E[1M$<9/>, ed=\E[J$<50/>,
-	el=\E[K$<3/>, home=\E[H, ht=^I, ich1=\E[1@$<7/>,
-	il1=\E[1L$<9/>, is2=\E[1;24r\E[24;1H, kbs=^H, kcub1=\EOD,
-	kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kf1=\EOP, kf2=\EOQ,
-	kf3=\EOR, kf4=\EOS, nel=\r\n, rc=\E8, rev=\E[7m$<2/>,
-	rf=/usr/share/tabset/vt100, ri=\EM$<5/>,
-	rmkx=\E>\E[?1l, rmso=\E[m$<2/>, rmul=\E[m$<2/>, rs1=\E>,
-	sc=\E7, sgr0=\E[m$<2/>, smkx=\E=\E[?1h, smso=\E[7m$<2/>,
-	smul=\E[4m$<2/>,
+	clear=\E[;H\E[2J$<50/>, cr=\r, cub1=^H, cud1=\n,
+	cuf1=\E[C$<2/>, cup=\E[%i%p1%d;%p2%dH$<5/>,
+	cuu1=\E[A$<2/>, dch1=\E[1P$<7/>, dl1=\E[1M$<9/>,
+	ed=\E[J$<50/>, el=\E[K$<3/>, home=\E[H, ht=^I,
+	ich1=\E[1@$<7/>, il1=\E[1L$<9/>, is2=\E[1;24r\E[24;1H,
+	kbs=^H, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
+	kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, nel=\r\n,
+	rev=\E[7m$<2/>, rf=/usr/share/tabset/vt100,
+	ri=\EM$<5/>, rmkx=\E>\E[?1l, rmso=\E[m$<2/>,
+	rmul=\E[m$<2/>, rs1=\E>, sgr0=\E[m$<2/>, smkx=\E=\E[?1h,
+	smso=\E[7m$<2/>, smul=\E[4m$<2/>, use=ansi+csr,
 
 # From: Rick Thomas <ihnp4!btlunix!rbt>
 # (xtalk: I added <rmam>/<smam> based on the init string.
@@ -23725,9 +24040,8 @@ xtalk|IBM PC with xtalk communication program (versions up to 3.4),
 	am, mir, msgr, xon,
 	cols#80, it#8, lines#24, vt#3, xmc#1,
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
-	bel=^G, clear=\E[H\E[J$<50>, cr=\r, cub=\E[%p1%dD, cub1=^H,
-	cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C$<2>,
-	cup=\E[%i%p1%d;%p2%dH$<5>, cuu=\E[%p1%dA,
+	bel=^G, clear=\E[H\E[J$<50>, cr=\r, cub1=^H, cud1=\n,
+	cuf1=\E[C$<2>, cup=\E[%i%p1%d;%p2%dH$<5>,
 	cuu1=\E[A$<2>, dl1=\E[M$<99>, ed=\E[J$<50>, el=\E[K$<3>,
 	el1=\E[1K$<3>, enacs=\E(B\E)0, home=\E[H, ht=^I, hts=\EH,
 	il1=\E[L$<99>, ind=\n, kbs=^H, kcub1=\EOD, kcud1=\EOB,
@@ -23735,7 +24049,7 @@ xtalk|IBM PC with xtalk communication program (versions up to 3.4),
 	rmkx=\E[?1l\E>, rmso=\E[m\s,
 	rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, sgr0=\E[m,
 	smacs=^N, smam=\E[?7h, smkx=\E[?1h\E=, smso=\E[7m\s,
-	tbc=\E[3g, use=vt100+fnkeys,
+	tbc=\E[3g, use=ansi+local, use=vt100+fnkeys,
 
 # The official PC terminal emulator program of the AT&T Product Centers.
 # Note - insert mode commented out - doesn't seem to work on AT&T PC.
@@ -23754,24 +24068,24 @@ simterm|attpc running simterm,
 #
 
 # (diablo1620: removed <if=/usr/share/tabset/xerox1720>, no such file -- esr)
-diablo1620|diablo1720|diablo450|ipsi|diablo 1620,
+diablo1620|diablo1720|diablo450|ipsi|Diablo 1620,
 	hc, os,
 	cols#132, it#8,
 	cub1=^H, cud1=\n, cuu1=\E\n, hd=\ED, hpa=\E\011%i%p1%c,
 	ht=^I, hts=\E1, hu=\EU, kbs=^H, tbc=\E2,
-diablo1620-m8|diablo1640-m8|diablo 1620 w/8 column left margin,
+diablo1620-m8|diablo1640-m8|Diablo 1620 w/8 column left margin,
 	cols#124,
 	is2=\r        \E9, use=diablo1620,
 # (diablo1640: removed <if=/usr/share/tabset/xerox1730>, no such file -- esr)
-diablo1640|diablo1730|diablo1740|diablo630|x1700|diablo|xerox|diablo 1640,
+diablo1640|diablo1730|diablo1740|diablo630|x1700|diablo|xerox|Diablo 1640,
 	bel=^G, rmso=\E&, rmul=\ER, smso=\EW, smul=\EE,
 	use=diablo1620,
 # (diablo1640-lm: removed <if=/usr/share/tabset/xerox1730-lm>, no such
 # file -- esr)
-diablo1640-lm|diablo-lm|xerox-lm|diablo 1640 with indented left margin,
+diablo1640-lm|diablo-lm|xerox-lm|Diablo 1640 with indented left margin,
 	cols#124,
 	rmso=\E&, rmul=\ER, smso=\EW, smul=\EE, use=diablo1620,
-diablo1740-lm|630-lm|1730-lm|x1700-lm|diablo 1740 printer,
+diablo1740-lm|630-lm|1730-lm|x1700-lm|Diablo 1740 printer,
 	use=diablo1640-lm,
 # DTC 382 with VDU.  Has no <ed> so we fake it with <el>.  Standout
 # <smso=^P\s\002^PF> works but won't go away without dynamite <rmso=^P\s\0>.
@@ -23804,7 +24118,7 @@ gsi|mystery gsi terminal,
 	cols#132,
 	bel=^G, cr=\r, cub1=^H, cud1=\n, cuu1=^Z, hd=\Eh, ht=^I, hu=\EH,
 	ind=\n,
-aj830|aj832|aj|anderson jacobson,
+aj830|aj832|aj|Anderson Jacobson,
 	hc, os,
 	bel=^G, cr=\r, cub1=^H, cud1=\n, cuu1=\E7, hd=\E9, hu=\E8,
 	ind=\n,
@@ -23821,7 +24135,7 @@ aj510|Anderson-Jacobson model 510,
 	smul=\E"U,
 # From: <cbosg!ucbvax!pur-ee!cincy!chris> Thu Aug 20 09:09:18 1981
 # This is incomplete, but it's a start.
-nec5520|nec|spinwriter|nec 5520,
+nec5520|nec|spinwriter|NEC 5520,
 	hc, os,
 	cols#132, it#8,
 	bel=^G, cr=\r, cub1=^H, cud1=\n, cuu1=\E9, ff=^L,
@@ -23832,8 +24146,8 @@ qume5|qume|Qume Sprint 5,
 	cols#80, it#8,
 	bel=^G, cr=\r, cub1=^H, cud1=\n, cuu1=^Z, ff=^L, hd=\Eh, ht=^I,
 	hts=\E1, hu=\EH, ind=\n, kbs=^H, tbc=\E3,
-# I suspect the xerox 1720 is the same as the diablo 1620.
-xerox1720|x1720|x1750|xerox 1720,
+# I suspect the Xerox 1720 is the same as the Diablo 1620.
+xerox1720|x1720|x1750|Xerox 1720,
 	hc, os,
 	cols#132, it#8,
 	bel=^G, cr=\r, cub1=^H, cud1=\n, ff=^L, ht=^I, hts=\E1, ind=\n,
@@ -23861,9 +24175,16 @@ cops10|cops|cops-10|cops 10,
 	cup=\020%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K, ed=^W, el=^V,
 	ind=\n, kbs=^H, kcub1=^H, kcud1=\n, kcuf1=^L, kcuu1=^K,
 	khome=^Y,
+
+# http://www.bitsavers.org/pdf/datapro/alphanumeric_terminals/Datapro_C25_Datagraphix.pdf
+#
+# DatagraphiX, Inc.
+# (a subsidiary of General Dynamics),
+# P.O. Box 82449, San Diego, California 92138.
+#
 # (d132: removed duplicate :ic=\E5:,
 # merged in capabilities from a BRL entry -- esr)
-d132|datagraphix|datagraphix 132a,
+d132|datagraphix|DatagraphiX 132a,
 	da, db, in,
 	cols#80, lines#30,
 	bel=^G, clear=^L, cnorm=\Em\En, cr=\r, cub1=^H, cud1=\n,
@@ -23871,7 +24192,7 @@ d132|datagraphix|datagraphix 132a,
 	dch1=\E6, home=\ET, ht=^I, ich1=\E5, il1=\E3, ind=\n, kbs=^H,
 	kcub1=^H, kcud1=\n, nel=\r\n, ri=\Ew,
 # The d800 was an early portable terminal from c.1984-85 that looked a lot
-# like the original Compaq `lunchbox' portable (but no handle).  It had a vt220
+# like the original Compaq `lunchbox' portable (but no handle).  It had a VT220
 # mode (which is what this entry looks like) and several other lesser-known
 # emulations.
 d800|Direct 800/A,
@@ -23893,17 +24214,13 @@ digilog|digilog 333,
 # The DWK was a terminal manufactured in the Soviet Union c.1986
 dwk|dwk-vt|dwk terminal,
 	am,
-	cols#80, it#8, lines#24,
-	acsc=+\^\,Q-S.M0\177`+a\:f'g#h#i#jXkClJmFnNo~qUs_tEuPv
-	     \\wKxW~_,
-	bel=^G, clear=\EH\EJ, cr=\r, cub1=^H, cud1=\n, cuf1=\EC,
-	cup=\EY%p1%{32}%+%c%p2%{32}%+%c, cuu1=\EA, dch1=\EP,
-	ed=\EJ, el=\EK, home=\EH, ht=^I, ich1=\EQ, ind=\n, kbs=^?,
-	kcub1=\ED, kcud1=\EB, kcuf1=\EC, kcuu1=\EA, kdch1=\Ee,
-	kf1=\Ef1, kf10=\Ef0, kf2=\Ef2, kf3=\Ef3, kf4=\Ef4, kf5=\Ef5,
-	kf6=\Ef6, kf7=\Ef7, kf8=\Ef8, kf9=\Ef9, kich1=\Ed, knp=\Eh,
-	kpp=\Eg, nel=\r\n, rev=\ET, ri=\ES, rmacs=\EG, rmso=\EX,
-	sgr0=\EX, smacs=\EF, smso=\ET,
+	acsc=+\^\,Q-S.M0\177`+a:f'g#h#i#jXkClJmFnNo~qUs_tEuPv\\wKxW~
+	     _,
+	clear=\EH\EJ, cub1=^H, cud1=\n, dch1=\EP, ich1=\EQ, kbs=^?,
+	kdch1=\Ee, kf1=\Ef1, kf10=\Ef0, kf2=\Ef2, kf3=\Ef3, kf4=\Ef4,
+	kf5=\Ef5, kf6=\Ef6, kf7=\Ef7, kf8=\Ef8, kf9=\Ef9, kich1=\Ed,
+	knp=\Eh, kpp=\Eg, rev=\ET, ri=\ES, rmacs=\EG, rmso=\EX,
+	sgr0=\EX, smacs=\EF, smso=\ET, use=vt52-basic,
 env230|envision230|envision 230 graphics terminal,
 	xenl@,
 	enacs@, mc0=\E[0i, mc4=\E[4i, mc5=\E[5i, rmacs@,
@@ -23949,17 +24266,16 @@ opus3n1+|Esprit Opus3n1+ in wy60 mode with ANSI arrow keys,
 	ed=\EY$<100>, el=\ET, fsl=\r, home=\036$<2>, ht=\011$<5>,
 	hts=\E1, if=/usr/share/tabset/std, il1=\EE$<4>, ind=\n,
 	ip=$<3>,
-	is2=\E`\:\Ee(\EO\Ee6\Ec41\E~4\Ec21\Ed/\Ezz&\E[A\177\Ezz'\E[B
+	is2=\E`:\Ee(\EO\Ee6\Ec41\E~4\Ec21\Ed/\Ezz&\E[A\177\Ezz'\E[B
 	    \177\Ezz(\E[D\177\Ezz)\E[C\177\Ezz<\E[Q\177\Ezz`\E[F
 	    \177\EA1*\EZH12,
-	kHOM=\E{, kbs=^H, kcbt=\EI, kcub1=\E[D, kcud1=\E[B,
-	kcuf1=\E[C, kcuu1=\E[A, kdch1=\EW, kdl1=\ER, ked=\EY,
-	kel=\ET, kend=\E[F, kent=\E7, kf1=^A@\r, kf10=^AI\r,
-	kf11=^AJ\r, kf12=^AK\r, kf13=^AL\r, kf14=^AM\r, kf15=^AN\r,
-	kf16=^AO\r, kf2=^AA\r, kf3=^AB\r, kf4=^AC\r, kf5=^AD\r,
-	kf6=^AE\r, kf7=^AF\r, kf8=^AG\r, kf9=^AH\r, khome=^^,
-	kich1=\EQ, kil1=\EE, knp=\EK, kpp=\EJ, kprt=\EP, krpl=\Er,
-	mc0=\EP, mc4=^T, mc5=^R, nel=\r\n$<3>,
+	kHOM=\E{, kcbt=\EI, kdch1=\EW, kdl1=\ER, ked=\EY, kel=\ET,
+	kend=\E[F, kent=\E7, kf1=^A@\r, kf10=^AI\r, kf11=^AJ\r,
+	kf12=^AK\r, kf13=^AL\r, kf14=^AM\r, kf15=^AN\r, kf16=^AO\r,
+	kf2=^AA\r, kf3=^AB\r, kf4=^AC\r, kf5=^AD\r, kf6=^AE\r,
+	kf7=^AF\r, kf8=^AG\r, kf9=^AH\r, khome=^^, kich1=\EQ,
+	kil1=\EE, knp=\EK, kpp=\EJ, kprt=\EP, krpl=\Er, mc0=\EP,
+	mc4=^T, mc5=^R, nel=\r\n$<3>,
 	pfloc=\EZ2%p1%{63}%+%c%p2%s\177,
 	pfx=\EZ1%p1%{63}%+%c%p2%s\177,
 	pln=\Ez%p1%{47}%+%c%p2%s\r, prot=\E), ri=\Ej$<7>,
@@ -23973,7 +24289,8 @@ opus3n1+|Esprit Opus3n1+ in wy60 mode with ANSI arrow keys,
 	smcup=\Ezz&\E[A\177\Ezz'\E[B\177\Ezz(\E[D\177\Ezz)\E[C\177
 	      \Ezz<\E[Q\177,
 	smir=\Eq, smln=\EA10, smxon=\Ec21, tbc=\E0, tsl=\Ez(,
-	uc=\EG8\EG0, use=adm+sgr,
+	uc=\EG8\EG0, use=ansi+arrows, use=adm+sgr,
+
 teletec|Teletec Datascreen,
 	OTbs, am,
 	cols#80, lines#24,
@@ -24008,15 +24325,14 @@ teletec|Teletec Datascreen,
 v3220|LANPAR Vision II model 3220/3221/3222,
 	OTbs, am, mir, xenl,
 	cols#80, it#8, lines#24,
-	clear=\E[H\E[J, cub1=^H, cud1=\E[B, cuf1=\E[C,
-	cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, dch1=\E[P, dl1=\E[M,
-	ed=\E[J, el=\E[K, ht=^I, il1=\E[L,
-	is2=\E>\E[?3l\E[?7h\E[?8h\E[p, kcub1=\E[D, kcud1=\E[B,
-	kcuf1=\E[C, kcuu1=\E[A, kf0=\E[1~, kf1=\E[2~, kf2=\E[3~,
-	kf3=\E[4~, kf4=\E[5~, kf5=\E[6~, kf6=\E[OP, kf7=\E[OQ,
-	kf8=\E[OR, kf9=\E[OS, khome=\E[H, ri=\EM, rmam=\E[?7l,
-	rmir=\E[4l, rmkx=\E>, rmso=\E[m, rmul=\E[m, sgr0=\E[m,
-	smam=\E[?7h, smir=\E[4h, smkx=\E=, smso=\E[7m, smul=\E[4m,
+	cub1=^H, cup=\E[%i%p1%d;%p2%dH, dch1=\E[P, dl1=\E[M, ht=^I,
+	il1=\E[L, is2=\E>\E[?3l\E[?7h\E[?8h\E[p, kcub1=\E[D,
+	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kf0=\E[1~, kf1=\E[2~,
+	kf2=\E[3~, kf3=\E[4~, kf4=\E[5~, kf5=\E[6~, kf6=\E[OP,
+	kf7=\E[OQ, kf8=\E[OR, kf9=\E[OS, khome=\E[H, ri=\EM,
+	rmam=\E[?7l, rmir=\E[4l, rmkx=\E>, rmso=\E[m, rmul=\E[m,
+	sgr0=\E[m, smam=\E[?7h, smir=\E[4h, smkx=\E=, smso=\E[7m,
+	smul=\E[4m, use=ansi+erase, use=ansi+local1,
 ######## ICH/ICH1 VERSUS RMIR/SMIR
 #
 # Some non-curses applications get confused if both ich/ich1 and rmir/smir
@@ -24785,7 +25101,7 @@ v3220|LANPAR Vision II model 3220/3221/3222,
 # differences, noted in
 #	https://invisible-island.net/ncurses/ncurses-netbsd.html
 #
-# ncurses makes explicit checks for a few user-definable capabilities:  AX,
+# ncurses makes explicit checks for a few user-definable capabilities:  AX, E3,
 # RGB, U8, XM, which are documented in the user_caps(5) manual page.
 #
 #### SCREEN Extensions:
@@ -24838,6 +25154,19 @@ v3220|LANPAR Vision II model 3220/3221/3222,
 #
 #### XTERM Extensions:
 #
+# For a discussion of "xterm", "xterm-256color" as values for TERM, see
+#	https://invisible-island.net/ncurses/ncurses.faq.html#xterm_generic
+#	https://invisible-island.net/ncurses/ncurses.faq.html#xterm_256color
+#
+# For xterm control sequences, see
+#	https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
+#
+# For function-keys with modifiers, see
+#	https://invisible-island.net/ncurses/ncurses.faq.html#modified_keys
+#
+# For a discussion of "bracketed paste", see
+#	https://invisible-island.net/xterm/xterm-paste64.html
+#
 # Most of the xterm extensions are for function-keys.  Since xterm patch #94 (in
 # 1999), xterm has supported shift/control/alt/meta modifiers which produce
 # additional function-key strings.  Some other developers copied the feature,
@@ -24852,7 +25181,20 @@ v3220|LANPAR Vision II model 3220/3221/3222,
 # kDC3 kDC4 kDC5 kDC6 kDC7 kDN kDN3 kDN4 kDN5 kDN6 kDN7 kEND3 kEND4 kEND5 kEND6
 # kEND7 kHOM3 kHOM4 kHOM5 kHOM6 kHOM7 kIC3 kIC4 kIC5 kIC6 kIC7 kLFT3 kLFT4
 # kLFT5 kLFT6 kLFT7 kNXT3 kNXT4 kNXT5 kNXT6 kNXT7 kPRV3 kPRV4 kPRV5 kPRV6 kPRV7
-# kRIT3 kRIT4 kRIT5 kRIT6 kRIT7 kUP kUP3 kUP4 kUP5 kUP6 kUP7 ka2 kb1 kb3 kc2
+# kRIT3 kRIT4 kRIT5 kRIT6 kRIT7 kUP kUP3 kUP4 kUP5 kUP6 kUP7 kxIN kxOUT ka2 kb1
+# kb3 kc2
+#
+# Bracketed paste is described with these capabilities in vim:
+#
+# BE enables bracketed paste
+# BD disables bracketed paste
+# PS is sent before the pasted text
+# PE is sent after the pasted text
+#
+# vim also uses these names for xterm focus:
+#
+# fe enables focus events
+# fd disables focus events
 #
 # Here are the other xterm-related extensions which are used in this file:
 #
@@ -24863,12 +25205,21 @@ v3220|LANPAR Vision II model 3220/3221/3222,
 # Ms modifies the selection/clipboard.  Its parameters are
 #	p1 = the storage unit (clipboard, selection or cut buffer)
 #	p2 = the base64-encoded clipboard content.
+# RV requests the terminal to report secondary device attributes (i.e, version).
+# rv shows the format of the terminal responses, as a regular expression.
 # Se resets the cursor style to the terminal power-on default.
 # Ss is a string capability with one numeric parameter.  It is used to set the
 #    cursor style as described by the DECSCUSR function to a block or
 #    underline.
 # TS is a string capability which acts like "tsl", but uses no parameter and
 #    goes to the first column of the "status line".
+# XF is set/true for terminals which support the xterm focus-in/focus-out
+#    escape sequences sent from the terminal to the host when private mode
+#    1004 is set.  Those are defined as kxIN and kxOUT, to take advantage of
+#    ncurses keypad mode to interpret them like a function key.  Because the
+#    1004 mode is usually combined with other flags to set the mouse protocol,
+#    this flag provides an application with the information that the focus
+#    mode is assumed to be set, e.g., in XM.
 # XM is a string capability which overrides ncurses's built-in string which
 #    enables/disables xterm mouse mode.
 # xm shows the format of the mouse responses.  Parameters:
@@ -24882,9 +25233,12 @@ v3220|LANPAR Vision II model 3220/3221/3222,
 #	p8 = x-ordinate ending region
 # Other extensions, used in xm:
 #	%u = UTF-8
+# XR requests the terminal to report its version as a free-format string.
+# xr shows the format of the terminal responses, as a regular expression.
 #
 #### Miscellaneous extensions:
 #
+# csr clears the status line
 # gsbom/grbom are used to enable/disable real bold (not intensity bright) mode.
 #    This was implemented for the Hurd.
 # rmxx/smxx describes the ECMA-48 strikeout/crossed-out attributes, as an
@@ -24894,6 +25248,8 @@ v3220|LANPAR Vision II model 3220/3221/3222,
 # E3 clears the terminal's scrollback buffer.  This was implemented in the
 #    Linux 3.0 kernel as a security feature.  It matches a feature which was
 #    added in xterm patch #107.
+# NQ denotes a terminal which does not support the standard query/response used
+#    in u6/u7 (cursor position) and u8/u9 (device attributes).
 # U8 is a numeric capability which denotes a terminal emulator which does not
 #    support VT100 SI/SO when processing UTF-8 encoding.  Set this to a nonzero
 #    value to enable it.
@@ -24974,7 +25330,7 @@ v3220|LANPAR Vision II model 3220/3221/3222,
 #	* Replaced the translated BBN BitGraph entries with purpose-built
 #	  ones from AT&T's SVr3.
 #	* Replaced the AT&T entries with AT&T's official terminfos.
-#	* Added teleray 16, vc415, cops10.
+#	* Added Teleray 16, vc415, cops10.
 #	* Merged in many individual capabilities from SCO terminfo files.
 # 9.4.3 (Mon Mar 13 02:37:53 EST 1995):
 #	* Typo fixes.
@@ -24987,7 +25343,7 @@ v3220|LANPAR Vision II model 3220/3221/3222,
 #	* Replaced Qume QVT and Freedom-series entries with purpose-built
 #	  terminfo entries.
 #	* Enhanced vt220, tvi910, tvi924, hpterm, hp2645, adm42, tek
-#	  and dg200 entries using caps from from SCO.
+#	  and dg200 entries using caps from SCO.
 #	* Added the usual set of function-key mappings to ANSI entry.
 #	* Corrected xterm's function-key capabilities.
 # 9.4.5 (Tue Mar 28 14:27:49 EST 1995):
@@ -25010,7 +25366,7 @@ v3220|LANPAR Vision II model 3220/3221/3222,
 #	* Added synertek, apple-soroc, ibmpc, pc-venix, pc-coherent, xtalk,
 #	  adm42-nl, pc52, gs6300, xerox820, uts30.
 #	* Pull SCO's padding into vi200 entry.
-#	* Improved capabilities for tvi4107 and other Televideo and Viewpoint
+#	* Improved capabilities for tvi4107 and other TeleVideo and Viewpoint
 #	  entries merged in from SCO's descriptions.
 #	* Fixed old-style prefix padding on zen50, h1500.
 #	* Moved old superbee entry to superbee-xsb, pulled in new superbee
@@ -26738,7 +27094,7 @@ v3220|LANPAR Vision II model 3220/3221/3222,
 # 2018-09-29
 #	+ corrected acsc for tvi950 -TD
 #	+ remove bogus kf0 from tvi950 -TD
-#	+ added function-key definitions to agree with Televideo 950 manual -TD
+#	+ added function-key definitions to agree with TeleVideo 950 manual -TD
 #	+ add bel to tvi950 -TD
 #	+ add shifted function-keys to regent60 -TD
 #	+ renumber regent40 function-keys to match manual -TD
@@ -26772,7 +27128,7 @@ v3220|LANPAR Vision II model 3220/3221/3222,
 #	+ add/use xterm+keypad in xterm-new (report by Alain D D Williams) -TD
 #	+ update terminator entry -TD
 #	+ remove hard-tabs from ti703 (report by Robert Clausecker)
-#	+ add Smol/Rmol for tmux, vte-2018 -Nicholas Marriott
+#	+ add Smol/Rmol for mintty, vte-2018 -Nicholas Marriott
 #
 # 2019-06-01
 #	+ add rs1 to konsole, mlterm -TD
@@ -26920,4 +27276,238 @@ v3220|LANPAR Vision II model 3220/3221/3222,
 #	+ add/use xterm+nofkeys -TD
 #	+ move use of ecma+italics from xterm-basic to xterm+nofkeys -TD
 #
+# 2021-02-27
+#	+ remove a duplicate "use" in xterm-vt220 -TD
+#
+# 2021-03-14
+#	+ correct use-ordering in some xterm-direct flavors -TD
+#
+# 2021-03-20
+#	+ add hterm, hterm-256color (Mike Frysinger)
+#
+# 2021-06-26
+#	+ use default colors in pccon "op" -TD
+#	+ correct rmacs/smacs in aaa+dec, aaa+rv -TD
+#	+ add hpterm-color2 and hp98550-color (Martin Trusler)
+#
+# 2021-07-17
+#	+ correct typo in "vip" comments (report by Nick Black), reviewed this
+#	  against Glink manual -TD
+#	+ fill in some missing pieces for pccon, to make it comparable to the
+#	  vt220 entry -TD
+#
+# 2021-07-24
+#	+ trim "flash" from pccon+base -TD
+#	+ revert change for aaa+rv -TD
+#	+ add workaround for Windows Terminal's problems with CR/LF mapping to
+#	  ms-terminal (patch by Juergen Pfeifer).
+#	+ review/update current Windows Terminal vs ms-terminal -TD
+#
+# 2021-07-31
+#	+ add extensions in xterm+tmux and ecma+strikeout to ms-terminal,
+#	  but cancel the non-working Cr and Ms capabilities -TD
+#	+ add foot and foot-direct -TD
+#
+# 2021-08-15
+#	+ fix missing "%d" for setaf/setab code 8-15 in xterm+direct16 (report
+#	  by Florian Weimer) -TD
+#
+# 2021-08-16
+#	+ corrected tsl capability for terminator -TD
+#
+# 2021-09-04
+#	+ modify linux3.0 entry to reflect default mapping of shift-tab by
+#	  kbd 1.14 (report by Jan Engelhardt) -TD
+#
+# 2021-09-11
+#	+ add testing note for xterm-{hp|sco|sun} -TD
+#	+ corrected description for ansi.sys-old -TD
+#	+ add xterm+nopcfkeys, to fill in keys for xterm-hp, xterm-sun -TD
+#	+ use hp+arrows in a few places -TD
+#	+ use hp+pfk-cr in a few places -TD
+#
+# 2021-09-21
+#	+ add kbeg to xterm+keypad to accommodate termcap applications -TD
+#	+ add smglp and smgrp to vt420+lrmm, to provide useful data for the
+#	  "tabs" +m option -TD
+#
+# 2021-10-09
+#	+ fill in some details for infoton -TD
+#	+ fix spelling/consistency in several descriptions -TD
+#	+ use vt420+lrmm in vt420 -TD
+#
+# 2021-10-13
+#	+ trim some redundant definitions -TD
+#
+# 2021-11-13
+#	+ add xterm+sl-alt, use that in foot+base (report by Jonas Grosse
+#	  Sundrup) -TD
+#
+# 2021-11-20
+#	+ add dim, ecma+strikeout to st-0.6 -TD
+#
+# 2021-11-27
+#	+ fix errata in description fields (report by Eric Lindblad) -TD
+#	+ add x10term+sl, aixterm+sl, ncr260vp+sl, ncr260vp+vt, wyse+sl -TD
+#
+# 2022-01-23
+#	+ update kitty -TD
+#
+# 2022-03-12
+#	+ add xterm+acs building-block -TD
+#	+ add xterm-p370, for use in older terminals -TD
+#	+ add dec+sl to xterm-new, per patch #371 -TD
+#	+ add mosh and mosh-256color -TD
+#
+# 2022-03-19
+#	+ add xgterm -TD
+#	+ correct setal in mintty/tmux entries, add to vte-2018 (report by
+#	  Robert Lange)
+#	+ add blink to vte-2018 (report by Robert Lange)
+#
+# 2022-03-26
+#	+ update teken -TD
+#	+ add teken-16color, teken-vt and teken-sc -TD
+#	+ add a few missing details for vte-2018 (report by Robert Lange) -TD
+#
+# 2022-03-27
+#	+ make description-fields distinct -TD
+#
+# 2022-04-30
+#	+ modify samples for xterm mouse 1002/1003 modes to use 1006 mode, and
+#	  also provide for focus in/out responses -TD
+#
+# 2022-05-28
+#	+ expanded notes for teken/syscons -TD
+#
+# 2022-06-04
+#	+ remove u6-u9 from teken-2018 -TD
+#	+ set "xterm-new" to "xterm-p370", add "xterm-p371" -TD
+#
+# 2022-06-18
+#	+ revise kon/kon2/jfbterm to undo "linux2.6" change to
+#	  smacs/rmacs/enacs (Debian #1012800) -TD
+#	+ amended note for att610+cvis0, as per documentation for att610,
+#	  att620, att730 -TD
+#
+# 2022-06-25
+#	+ correct dsl in dec+sl (report by Rajeev Pillai) -TD
+#	+ add/use ansi+cpr, decid+cpr -TD
+#
+# 2022-07-03
+#	+ use NQ to flag entries where the terminal does not support query and
+#	  response -TD
+#	+ use ansi+enq and decid+cpr in cases where the terminal probably
+#	  supported the u6-u9 extension -TD
+#	+ add/use apollo+vt132, xterm+alt47 -TD
+#
+# 2022-08-27
+#	+ modify nsterm to use xterm+alt1049 (report by Paul Handly) -TD
+#	+ modify putty to use xterm+alt1049 -TD
+#
+# 2022-12-24
+#	+ add/use bracketed+paste to help identify terminals supporting this
+#	  xterm feature (prompted by discussion with Bram Moolenaar) -TD
+#
+# 2022-12-29
+#	+ correct PS vs PE names in bracketed+paste (report by Bram Moolenaar)
+#	  -TD
+#
+# 2023-01-07
+#	+ add comment to bracketed+paste explaining that vim patch 9.0.1117 is
+#	  needed for use with the updated xterm descriptions (suggested by Bram
+#	  Moolenaar).
+#	+ add RV report+version (suggested by Bram Moolenaar).
+#
+# 2023-01-14
+#	+ change RV to XR/xr, to avoid conflict with pre-existing usage in vim,
+#	  to use RV/rv to denote DA2 and its response (discussion with Bram
+#	  Moolenaar) -TD
+#	+ add XF flag to xterm+focus so that termcap applications can be aware
+#	  of terminals which may support focus in/out -TD
+#	+ use xterm+focus in xterm-p370 and tmux -TD
+#
+# 2023-01-28
+#	+ document XF, kxIN and kxOUT -TD
+#	+ add note on sun/wscons/cmdtool/shelltool -TD
+#
+# 2023-04-01
+#	+ remove DECCOLM+DECSCLM from foot (patch by Daniel Ekloef).
+#
+# 2023-04-08
+#	+ add xterm+focus to alacritty+common (patch by Christian Duerr).
+#
+# 2023-05-08
+#	+ add mode 1004 to xterm+sm+1006 from xterm #380 -TD
+#
+# 2023-06-05
+#	+ add xterm+focus to foot+base (patch by Daniel Ekloef).
+#
+# 2023-07-08
+#	+ add linux+kbs for terminals which imitate xterm's behavior with
+#	  Linux -TD
+#
+# 2023-07-15
+#	+ mention E3 in regard to user_caps(5) -TD
+#
+# 2023-08-12
+#	+ add/use putty+cursor to reflect amending of modified cursor-keys in
+#	  2021 -TD
+#	+ add ecma+strikeout to putty -TD
+#
+# 2023-10-21
+#	+ use oldxterm+sm+1006 in vte-2014 (report by Benno Schulenberg) -TD
+#	+ add ansi+apparrows -TD
+#
+# 2023-10-28
+#	+ move xterm focus mode 1004 from xterm+sm+1006 into xterm+focus as
+#	  fe/fd capabilities, like vim (vim-pr #13440).
+#
+# 2023-11-11
+#	+ used "infocmp -u" to help trim redundant capabilities -TD
+#
+# 2023-12-09
+#	+ remove xterm+sm+1006 from tmux (Debian #1057688).
+#	+ used "infocmp -u" to help trim redundant capabilities -TD
+#
+# 2023-12-16
+#	+ used "infocmp -u" to help trim redundant capabilities -TD
+#
+# 2023-12-30
+#	+ add ms-vt100-16color, winconsole -TD
+#	+ add rio, rio-direct -TD
+#	+ add mostlike -TD
+#	+ add wezterm, contour -TD
+#
+# 2024-01-06
+#	+ use ansi+arrows, ansi+apparrows, ansi+csr, ansi+erase, ansi+idc,
+#	  ansi+idc1, ansi+idl, ansi+idl1, ansi+inittabs to trim -TD
+#
+# 2024-01-07
+#	+ restore padding for wy520* and vt320-k311 (report by Sven Joachim).
+#
+# 2024-01-13
+#	+ use ansi+local, ansi+local1, ansi+pp, ansi+rca, ansi+rca2, ansi+sgr
+#	  to trim -TD
+#
+# 2024-01-14
+#	+ use ansi+sgrbold, ansi+sgrdim, ansi+sgrso, ansi+sgrul, ansi+tabs
+#	  ecma+color, ecma+sgr, vt100+4bsd, vt100+pfkeys, vt220+pcedit
+#	  xterm+256color, xterm+acs, xterm+nopcfkeys, xterm+pcf2 to trim -TD
+#
+# 2024-01-27
+#	+ amend change to z39-a (report by Sven Joachim).
+#	+ use xterm+nopcfkeys, vt52-basic, dec+pp, dec+sl, vt52+arrows,
+#	  hp+pfk+cr, klone+acs, klone+color, klone+sgr, ncr160wy50+pp
+#	  to trim -TD
+#	+ NetBSD-related fixes for x68k and wsvt52 (patch by Thomas Klausner)
+#
+# 2024-02-11
+#	+ add vt100+noapp, vt100+noapp+pc, xterm+app+pc, xterm+decedit from
+#	  xterm #389 -TD
+#
+# 2024-03-09
+#	+ modify xgterm to work around line-drawing bug -TD
+#	+ use CSI 3J in vte-2017 (report by Sven Joachim)
+#
 ######## SHANTIH!  SHANTIH!  SHANTIH!
diff --git a/contrib/ncurses/mk-0th.awk b/contrib/ncurses/mk-0th.awk
index f97549e48845..366224309112 100644
--- a/contrib/ncurses/mk-0th.awk
+++ b/contrib/ncurses/mk-0th.awk
@@ -1,6 +1,6 @@
-# $Id: mk-0th.awk,v 1.23 2020/02/02 23:34:34 tom Exp $
+# $Id: mk-0th.awk,v 1.24 2021/03/20 11:44:48 tom Exp $
 ##############################################################################
-# Copyright 2020 Thomas E. Dickey                                            #
+# Copyright 2020,2021 Thomas E. Dickey                                       #
 # Copyright 1998-2010,2012 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -129,8 +129,10 @@ BEGIN	{
 				printf "C_SRC ="
 				if ( $2 == "lib" )
 					found = 1
-				else
+				else if ( $2 == "c++" )
 					found = 2
+				else
+					found = 3
 			}
 			if ( libname == "c++" || libname == "c++w" ) {
 				srcname = sprintf("%s/%s.cc", $3, $1);
@@ -159,6 +161,10 @@ END	{
 			show_list(ticlib, count_ticlib, list_ticlib);
 			show_list(termlib, count_termlib, list_termlib);
 		}
+		else if ( found == 2 )
+		{
+			make_lintlib(libname, "$(C_SRC)");
+		}
 		else
 		{
 			print  ""
diff --git a/contrib/ncurses/mk-1st.awk b/contrib/ncurses/mk-1st.awk
index 74bc2ebe8384..6a5eafab26cf 100644
--- a/contrib/ncurses/mk-1st.awk
+++ b/contrib/ncurses/mk-1st.awk
@@ -1,6 +1,6 @@
-# $Id: mk-1st.awk,v 1.109 2020/08/31 23:49:24 tom Exp $
+# $Id: mk-1st.awk,v 1.125 2023/04/22 15:49:59 tom Exp $
 ##############################################################################
-# Copyright 2018,2020 Thomas E. Dickey                                       #
+# Copyright 2018-2021,2023 Thomas E. Dickey                                  #
 # Copyright 1998-2016,2017 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -36,6 +36,8 @@
 #	traces		  ("all" or "DEBUG", to control whether tracing is compiled in)
 #	MODEL		  (e.g., "DEBUG", uppercase; toupper is not portable)
 #	CXX_MODEL	  (e.g., "DEBUG", uppercase)
+#	LIB_SUFFIX	  (e.g., "", "w", "t", "tw")
+#	USE_LIB_SUFFIX (e.g., "", "w", "t", "tw")
 #	model		  (directory into which we compile, e.g., "obj")
 #	prefix		  (e.g., "lib", for Unix-style libraries)
 #	suffix		  (e.g., "_g.a", for debug libraries)
@@ -51,6 +53,7 @@
 #	DoLinks		  ("yes", "reverse" or "no", flag to add symbolic links)
 #	rmSoLocs	  ("yes" or "no", flag to add extra clean target)
 #	ldconfig	  (path for this tool, if used)
+#	make_phony    ("yes" if the make-program accepts ".PHONY" directive.
 #	overwrite	  ("yes" or "no", flag to add link to libcurses.a
 #	depend		  (optional dependencies for all objects, e.g, ncurses_cfg.h)
 #	host		  (cross-compile host, if any)
@@ -59,7 +62,7 @@
 # Notes:
 #	CLIXs nawk does not like underscores in command-line variable names.
 #	Mixed-case variable names are ok.
-#	HP/UX requires shared libraries to have executable permissions.
+#	HP-UX requires shared libraries to have executable permissions.
 #
 function is_ticlib() {
 		return ( subset ~ /^ticlib$/ );
@@ -266,6 +269,15 @@ function in_subset(value) {
 		check = " " check " ";
 		return index(check,value);
 	}
+function trim_suffix(value) {
+	if (USE_LIB_SUFFIX != "" && length(value) > length(USE_LIB_SUFFIX)) {
+		check = substr(value, 1 + length(value) - length(USE_LIB_SUFFIX));
+		if (check == USE_LIB_SUFFIX) {
+			value = substr(value, 1, length(value) - length(USE_LIB_SUFFIX));
+		}
+	}
+	return value;
+}
 BEGIN	{
 		TOOL_PREFIX = "";
 		found = 0;
@@ -275,6 +287,8 @@ BEGIN	{
 		using = 0
 		if (subset == "none") {
 			using = 1
+			print  ""
+			print "# generated by mk-1st.awk"
 		} else if (in_subset($2) > 0) {
 			if (using == 0) {
 				if (found == 0) {
@@ -289,28 +303,32 @@ BEGIN	{
 					}
 					print  ""
 					printf "# generated by mk-1st.awk (subset=%s)\n", subset
-					printf "#  name:          %s\n", name 
-					printf "#  traces:        %s\n", traces 
-					printf "#  MODEL:         %s\n", MODEL 
-					printf "#  CXX_MODEL:     %s\n", CXX_MODEL 
-					printf "#  model:         %s\n", model 
-					printf "#  prefix:        %s\n", prefix 
-					printf "#  suffix:        %s\n", suffix 
-					printf "#  subset:        %s\n", subset 
-					printf "#  driver:        %s\n", driver 
-					printf "#  ShlibVer:      %s\n", ShlibVer 
-					printf "#  ShlibVerInfix: %s\n", ShlibVerInfix 
-					printf "#  SymLink:       %s\n", SymLink 
-					printf "#  TermlibRoot:   %s\n", TermlibRoot 
-					printf "#  TermlibSuffix: %s\n", TermlibSuffix 
-					printf "#  ReLink:        %s\n", ReLink 
-					printf "#  ReRanlib:      %s\n", ReRanlib 
-					printf "#  DoLinks:       %s\n", DoLinks 
-					printf "#  rmSoLocs:      %s\n", rmSoLocs 
-					printf "#  ldconfig:      %s\n", ldconfig 
-					printf "#  overwrite:     %s\n", overwrite 
-					printf "#  depend:        %s\n", depend 
-					printf "#  host:          %s\n", host 
+					printf "#  name:            %s\n", name
+					printf "#  traces:          %s\n", traces
+					printf "#  MODEL:           %s\n", MODEL
+					printf "#  CXX_MODEL:       %s\n", CXX_MODEL
+					printf "#  LIB_SUFFIX:      %s\n", LIB_SUFFIX
+					printf "#  USE_LIB_SUFFIX:  %s\n", USE_LIB_SUFFIX
+					printf "#  model:           %s\n", model
+					printf "#  prefix:          %s\n", prefix
+					printf "#  suffix:          %s\n", suffix
+					printf "#  subset:          %s\n", subset
+					printf "#  driver:          %s\n", driver
+					printf "#  ShlibVer:        %s\n", ShlibVer
+					printf "#  ShlibVerInfix:   %s\n", ShlibVerInfix
+					printf "#  SymLink:         %s\n", SymLink
+					printf "#  TermlibRoot:     %s\n", TermlibRoot
+					printf "#  TermlibSuffix:   %s\n", TermlibSuffix
+					printf "#  ReLink:          %s\n", ReLink
+					printf "#  ReRanlib:        %s\n", ReRanlib
+					printf "#  DoLinks:         %s\n", DoLinks
+					printf "#  rmSoLocs:        %s\n", rmSoLocs
+					printf "#  ldconfig:        %s\n", ldconfig
+					printf "#  make_phony:      %s\n", make_phony
+					printf "#  overwrite:       %s\n", overwrite
+					printf "#  depend:          %s\n", depend
+					printf "#  host:            %s\n", host
+					printf "#  libtool_version: %s\n", libtool_version
 					print  ""
 				}
 				using = 1
@@ -336,8 +354,7 @@ BEGIN	{
 		 && ( $1 != "link_test" ) \
 		 && ( $2 == "lib" \
 		   || $2 == "progs" \
-		   || $2 == "c++" \
-		   || $2 == "tack" ))
+		   || $2 == "c++" ))
 		{
 			if ( found == 0 )
 			{
@@ -458,7 +475,15 @@ END	{
 			else if ( MODEL == "LIBTOOL" )
 			{
 				end_name = lib_name;
-				printf "../lib/%s : $(%s_OBJS)\n", lib_name, OBJS
+				use_name = trim_suffix(TermlibRoot) USE_LIB_SUFFIX
+				printf "../lib/%s : \\\n", lib_name
+				if ( (name != use_name ) && ( index(name, "++") == 0 ) && ( index(name, "tic") == 1 || index(name, "ncurses") == 1 ) ) {
+					printf "\t\t../lib/lib%s.la \\\n", use_name;
+					if ( index(name, "tic") == 1 && index(TermlibRoot, "ncurses") != 1 ) {
+						printf "\t\t../lib/lib%s%s.la \\\n", "ncurses", USE_LIB_SUFFIX;
+					}
+				}
+				printf "\t\t$(%s_OBJS)\n", OBJS
 				if ( is_ticlib() ) {
 					which_list = "TICS_LIST";
 				} else if ( is_termlib() ) {
@@ -470,16 +495,31 @@ END	{
 				printf "\t\t-o %s $(%s_OBJS:$o=.lo) \\\n", lib_name, OBJS;
 				printf "\t\t-rpath $(libdir) \\\n";
 				printf "\t\t%s $(NCURSES_MAJOR):$(NCURSES_MINOR) $(LT_UNDEF) $(%s) $(LDFLAGS)\n", libtool_version, which_list;
+				if ( make_phony == "yes" ) {
+					print  ""
+					printf ".PHONY :\tinstall.%s\n", trim_suffix(name);
+				}
 				print  ""
 				print  "install \\"
 				print  "install.libs \\"
-				printf "install.%s :: $(DESTDIR)$(libdir) ../lib/%s\n", name, lib_name
+				printf "install.%s :: \\\n", trim_suffix(name);
+				printf "\t\t$(DESTDIR)$(libdir) \\\n";
+				use_name = TermlibRoot USE_LIB_SUFFIX
+				if ( (name != use_name ) && ( index(name, "++") == 0 ) && ( index(name, "tic") == 1 || index(name, "ncurses") == 1 ) ) {
+					if ( trim_suffix(TermlibRoot) != trim_suffix(name) ) {
+						printf "\t\tinstall.%s \\\n", trim_suffix(TermlibRoot);
+					}
+					if ( index(name, "tic") == 1 && index(TermlibRoot, "ncurses") != 1 && trim_suffix(name) != "ncurses" ) {
+						printf "\t\tinstall.%s \\\n", "ncurses";
+					}
+				}
+				printf "\t\t../lib/%s\n", lib_name
 				printf "\t@echo installing ../lib/%s as $(DESTDIR)$(libdir)/%s\n", lib_name, lib_name
 				printf "\tcd ../lib; $(LIBTOOL_INSTALL) $(INSTALL) %s $(DESTDIR)$(libdir)\n", lib_name
 				print  ""
 				print  "uninstall \\"
 				print  "uninstall.libs \\"
-				printf "uninstall.%s ::\n", name
+				printf "uninstall.%s ::\n", trim_suffix(name)
 				printf "\t@echo uninstalling $(DESTDIR)$(libdir)/%s\n", lib_name
 				printf "\t-@$(LIBTOOL_UNINSTALL) rm -f $(DESTDIR)$(libdir)/%s\n", lib_name
 			}
diff --git a/contrib/ncurses/mk-2nd.awk b/contrib/ncurses/mk-2nd.awk
index 3fe7ed3d22a0..4493bcf5ed23 100644
--- a/contrib/ncurses/mk-2nd.awk
+++ b/contrib/ncurses/mk-2nd.awk
@@ -1,6 +1,6 @@
-# $Id: mk-2nd.awk,v 1.22 2020/08/31 23:49:17 tom Exp $
+# $Id: mk-2nd.awk,v 1.23 2021/06/17 21:20:30 tom Exp $
 ##############################################################################
-# Copyright 2020 Thomas E. Dickey                                            #
+# Copyright 2020,2021 Thomas E. Dickey                                       #
 # Copyright 1998-2004,2005 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -75,7 +75,7 @@ BEGIN	{
 					print  "# generated by mk-2nd.awk"
 					printf "#   model:      %s\n", model
 					printf "#   MODEL:      %s\n", MODEL
-					printf "#   echo:       %s\n", echo 
+					printf "#   echo:       %s\n", echo
 					printf "#   subset:     %s\n", subset
 					printf "#   crenames:   %s\n", crenames
 					printf "#   cxxrenames: %s\n", cxxrenames
diff --git a/contrib/ncurses/mk-hdr.awk b/contrib/ncurses/mk-hdr.awk
index 2fa5941ea6ed..7608afedb01e 100644
--- a/contrib/ncurses/mk-hdr.awk
+++ b/contrib/ncurses/mk-hdr.awk
@@ -1,6 +1,6 @@
-# $Id: mk-hdr.awk,v 1.7 2020/08/31 23:48:44 tom Exp $
+# $Id: mk-hdr.awk,v 1.8 2021/06/17 21:20:30 tom Exp $
 ##############################################################################
-# Copyright 2020 Thomas E. Dickey                                            #
+# Copyright 2020,2021 Thomas E. Dickey                                       #
 # Copyright 2007-2010,2013 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -69,8 +69,8 @@ BEGIN	{
 			if (found == 0) {
 				print  ""
 				print  "# generated by mk-hdr.awk"
-				printf "#  subset:     %s\n", subset 
-				printf "#  compat:     %s\n", compat 
+				printf "#  subset:     %s\n", subset
+				printf "#  compat:     %s\n", compat
 				print  ""
 				found = 1
 			}
diff --git a/contrib/ncurses/ncurses/Makefile.in b/contrib/ncurses/ncurses/Makefile.in
index 8f2254d3a0d4..ae198df675a4 100644
--- a/contrib/ncurses/ncurses/Makefile.in
+++ b/contrib/ncurses/ncurses/Makefile.in
@@ -1,6 +1,6 @@
-# $Id: Makefile.in,v 1.178 2021/01/23 20:34:00 tom Exp $
+# $Id: Makefile.in,v 1.184 2024/01/19 12:00:00 tom Exp $
 ##############################################################################
-# Copyright 2018-2020,2021 Thomas E. Dickey                                  #
+# Copyright 2018-2022,2024 Thomas E. Dickey                                  #
 # Copyright 1998-2017,2018 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -193,10 +193,11 @@ HEADER_DEPS	= @INTERNALS_HDR@ \
 	$(INCDIR)/nc_win32.h \
 	$(INCDIR)/term_entry.h \
 	$(srcdir)/curses.priv.h \
-	$(srcdir)/new_pair.h
+	$(srcdir)/new_pair.h \
+	$(srcdir)/term.priv.h
 
 TEST_DEPS	= ../lib/@LIB_PREFIX@ncurses@DFT_DEP_SUFFIX@
-TEST_ARGS	= @LDFLAGS_STATIC@ @TEST_ARGS@ @LDFLAGS_SHARED@ 
+TEST_ARGS	= @LDFLAGS_STATIC@ @TEST_ARGS@ @LDFLAGS_SHARED@
 TEST_LDFLAGS	= @LD_MODEL@ $(TEST_ARGS) @LIBS@ @LOCAL_LDFLAGS@ @LDFLAGS@
 
 TEST_PROGS = \
@@ -217,9 +218,20 @@ wide	 = $(srcdir)/widechar
 win32con = $(srcdir)/win32con
 
 ################################################################################
+
+@MAKE_PHONY@.PHONY :	all
+@MAKE_PHONY@.PHONY :	check
+@MAKE_PHONY@.PHONY :	clean
+@MAKE_PHONY@.PHONY :	distclean
+@MAKE_PHONY@.PHONY :	libs
+@MAKE_PHONY@.PHONY :	mostlyclean
+@MAKE_PHONY@.PHONY :	realclean
+@MAKE_PHONY@.PHONY :	sources
+@MAKE_PHONY@.PHONY :	test_progs
+
 all libs ::	$(AUTO_SRC) ../lib $(LIBRARIES)
 
-@CHECK_BUILD@all libs ::	report_offsets$(BUILD_EXEEXT) 
+@CHECK_BUILD@all libs ::	report_offsets$(BUILD_EXEEXT)
 
 sources:	$(AUTO_SRC)
 
@@ -233,13 +245,13 @@ $(DESTDIR)$(libdir) :
 	$(SHELL) -e $(tinfo)/MKfallback.sh $(TERMINFO) $(TERMINFO_SRC) "$(TIC_PATH)" "$(INFOCMP_PATH)" $(FALLBACK_LIST) >$@
 
 ./lib_gen.c : $(base)/MKlib_gen.sh ../include/curses.h
-	$(SHELL) -e $(base)/MKlib_gen.sh "$(CPP) $(CPPFLAGS)" "$(AWK)" generated <../include/curses.h >$@
+	FGREP="@FGREP@" $(SHELL) -e $(base)/MKlib_gen.sh "$(CPP) $(CPPFLAGS)" "$(AWK)" generated <../include/curses.h >$@
 
-init_keytry.h: make_keys$(BUILD_EXEEXT) keys.list
+init_keytry.h : make_keys$(BUILD_EXEEXT) keys.list
 	./make_keys$(BUILD_EXEEXT) keys.list > $@
 
 keys.list :	$(tinfo)/MKkeys_list.sh
-	AWK=$(AWK) $(SHELL) $(tinfo)/MKkeys_list.sh $(CAPLIST) | LC_ALL=C sort >$@
+	AWK=$(AWK) USE_SIGWINCH=@cf_cv_enable_sigwinch@ $(SHELL) $(tinfo)/MKkeys_list.sh $(CAPLIST) | LC_ALL=C sort >$@
 
 make_keys$(BUILD_EXEEXT) : \
 		build.priv.h \
@@ -276,7 +288,7 @@ report_offsets$(BUILD_EXEEXT) : \
 	$(SHELL) -e $(tinfo)/MKuserdefs.sh $(AWK) $(USE_BIG_STRINGS) $(CAPLIST) > $@
 
 ./lib_keyname.c: keys.list $(base)/MKkeyname.awk
-	$(AWK) -f $(base)/MKkeyname.awk bigstrings=$(USE_BIG_STRINGS) keys.list > $@
+	$(AWK) -f $(base)/MKkeyname.awk use_sigwinch=@cf_cv_enable_sigwinch@ bigstrings=$(USE_BIG_STRINGS) keys.list > $@
 
 ./codes.c: $(tinfo)/MKcodes.awk
 	$(AWK) -f $(tinfo)/MKcodes.awk bigstrings=$(USE_BIG_STRINGS) $(CAPLIST) >$@
@@ -317,10 +329,11 @@ realclean :: distclean
 	( cd ../include && $(MAKE) $(TOP_MFLAGS) )
 
 # These rules build test-programs for the modules that have test-drivers
+@MAKE_PHONY@.PHONY :	test_progs
 test_progs : $(TEST_PROGS)
 
 ./link_test.c : $(base)/MKlib_gen.sh ../include/curses.h
-	$(SHELL) -e $(base)/MKlib_gen.sh "$(CPP) $(CPPFLAGS)" "$(AWK)" implemented <../include/curses.h >$@
+	FGREP="@FGREP@" $(SHELL) -e $(base)/MKlib_gen.sh "$(CPP) $(CPPFLAGS)" "$(AWK)" implemented <../include/curses.h >$@
 
 captoinfo$x : $(tinfo)/captoinfo.c $(TEST_DEPS)
 	@ECHO_LD@ $(LIBTOOL_LINK) -o $@ $(CFLAGS_DEFAULT) -DMAIN $(tinfo)/captoinfo.c $(TEST_LDFLAGS)
@@ -347,6 +360,23 @@ report_hashing$x : \
 		$(srcdir)/report_hashing.c $(TEST_DEPS)
 	@ECHO_LD@ $(CC) -o $@ $(CFLAGS_DEFAULT) report_hashing.c $(TEST_LDFLAGS)
 
+# Verify that each header-file can be compiled without including another.
+@MAKE_PHONY@.PHONY :	check_headers
+check_headers:
+	@$(SHELL) -c "for header in *.h;\
+		do \
+			echo \"** testing \$${header}\" ; \
+			echo \"#include <\$${header}>\" >headers.c; \
+			echo \"int main(void) { return 0; }\" >>headers.c; \
+			$(CC) -c $(CFLAGS) $(CPPFLAGS) headers.c; \
+		done"
+	-@rm -f headers.*
+
+@MAKE_PHONY@.PHONY :	check_objects
+check_objects: test_progs
+
+check :: check_headers check_objects
+
 ###############################################################################
 # The remainder of this file is automatically generated during configuration
 ###############################################################################
diff --git a/contrib/ncurses/ncurses/README.IZ b/contrib/ncurses/ncurses/README.IZ
index 25058a98ac89..a9e52ea5baff 100644
--- a/contrib/ncurses/ncurses/README.IZ
+++ b/contrib/ncurses/ncurses/README.IZ
@@ -1,5 +1,5 @@
 -------------------------------------------------------------------------------
--- Copyright 2020 Thomas E. Dickey                                           --
+-- Copyright 2020,2021 Thomas E. Dickey                                      --
 -- Copyright 2002,2006 Free Software Foundation, Inc.                        --
 --                                                                           --
 -- Permission is hereby granted, free of charge, to any person obtaining a   --
@@ -26,7 +26,7 @@
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
--- $Id: README.IZ,v 1.4 2020/02/02 23:34:34 tom Exp $
+-- $Id: README.IZ,v 1.5 2021/06/17 21:20:30 tom Exp $
 ---------------------------------------------------------------------
 
 Here is the patch.  I did no testing whatsoever with event watching
@@ -35,7 +35,7 @@ this, probably lynx ;-), but the code looks working "the normal way".
 
 I had no way to test that the poll() branch compiles/works...
 
-Here is the API: 
+Here is the API:
 
 *) two new functions wgetch_events() wgetstrn_event() are introduced,
    which allow an event-watch specification given as the last argument;
diff --git a/contrib/ncurses/ncurses/base/MKlib_gen.sh b/contrib/ncurses/ncurses/base/MKlib_gen.sh
index 3829eff8eecb..f0ac0452e8ef 100755
--- a/contrib/ncurses/ncurses/base/MKlib_gen.sh
+++ b/contrib/ncurses/ncurses/base/MKlib_gen.sh
@@ -2,10 +2,10 @@
 #
 # MKlib_gen.sh -- generate sources from curses.h macro definitions
 #
-# ($Id: MKlib_gen.sh,v 1.68 2020/08/23 00:02:29 tom Exp $)
+# ($Id: MKlib_gen.sh,v 1.73 2022/10/01 13:14:20 tom Exp $)
 #
 ##############################################################################
-# Copyright 2018,2020 Thomas E. Dickey                                       #
+# Copyright 2018-2021,2022 Thomas E. Dickey                                  #
 # Copyright 1998-2016,2017 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -69,12 +69,21 @@ USE="$3"
 
 # A patch discussed here:
 #	https://gcc.gnu.org/ml/gcc-patches/2014-06/msg02185.html
+#
 # introduces spurious #line markers into the preprocessor output.  The result
 # appears in gcc 5.0 and (with modification) in 5.1, making it necessary to
 # determine if we are using gcc, and if so, what version because the proposed
 # solution uses a nonstandard option.
+#
+# As illustrated in
+#	https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60723
+#
+# gcc developers chose to ignore the problems with this, and summarized those
+# as "intriguing problems" in
+#	https://gcc.gnu.org/gcc-5/porting_to.html
+
 PRG=`echo "$1" | "$AWK" '{ sub(/^[ 	]*/,""); sub(/[ 	].*$/, ""); print; }' || exit 0`
-FSF=`("$PRG" --version 2>/dev/null || exit 0) | fgrep "Free Software Foundation" | head -n 1`
+FSF=`("$PRG" --version 2>/dev/null || exit 0) | ${FGREP-grep -F} "Free Software Foundation" | head -n 1`
 ALL=`"$PRG" -dumpversion 2>/dev/null || exit 0`
 ONE=`echo "$ALL" | sed -e 's/[^0-9].*$//'`
 if test -n "$FSF" && test -n "$ALL" && test -n "$ONE" ; then
@@ -92,7 +101,8 @@ ED4=sed4_${PID}.sed
 AW1=awk1_${PID}.awk
 AW2=awk2_${PID}.awk
 TMP=gen__${PID}.c
-trap "rm -f $ED1 $ED2 $ED3 $ED4 $AW1 $AW2 $TMP" 0 1 2 3 15
+trap "rm -f $ED1 $ED2 $ED3 $ED4 $AW1 $AW2 $TMP; exit 1" 1 2 3 15
+trap "rm -f $ED1 $ED2 $ED3 $ED4 $AW1 $AW2 $TMP" 0
 
 ALL=$USE
 if test "$USE" = implemented ; then
@@ -461,8 +471,9 @@ END		{
 				if ( value !~ /P_POUNDC/ ) {
 					gsub(/[ \t]+/," ",value);
 					sub(/^[0-9a-zA-Z_]+ /,"",value);
-					sub(/^\* /,"",value);
-					gsub(/[0-9a-zA-Z_]+ \* /,"",value);
+					sub(/^[*][ \t]*/,"",value);
+					gsub("struct[ \t]*[0-9a-zA-Z_]+[ \t]*[*]","",value);
+					gsub(/[0-9a-zA-Z_]+[ \t]*[*][ \t]*/,"",value);
 					gsub(/ (const) /," ",value);
 					gsub(/ (int|short|attr_t|chtype|wchar_t|NCURSES_BOOL|NCURSES_OUTC|NCURSES_OUTC_sp|va_list) /," ",value);
 					gsub(/ void /,"",value);
diff --git a/contrib/ncurses/ncurses/base/MKunctrl.awk b/contrib/ncurses/ncurses/base/MKunctrl.awk
index 9a2a6db63876..e5362bd60d15 100644
--- a/contrib/ncurses/ncurses/base/MKunctrl.awk
+++ b/contrib/ncurses/ncurses/base/MKunctrl.awk
@@ -1,6 +1,6 @@
-# $Id: MKunctrl.awk,v 1.29 2020/02/02 23:34:34 tom Exp $
+# $Id: MKunctrl.awk,v 1.30 2024/02/03 21:09:14 tom Exp $
 ##############################################################################
-# Copyright 2020 Thomas E. Dickey                                            #
+# Copyright 2020,2024 Thomas E. Dickey                                       #
 # Copyright 1998-2012,2017 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -144,7 +144,7 @@ END	{
 		print  "\tint check = (int) ChCharOf(ch);"
 		print  "\tconst char *result;"
 		print  ""
-		print  "(void) sp;"
+		print  "\t(void) sp;"
 		print  "\tif (check >= 0 && check < (int)SIZEOF(unctrl_table)) {"
 		print  "#if NCURSES_EXT_FUNCS"
 		print  "\t\tif ((sp != 0)"
@@ -155,6 +155,7 @@ END	{
 		print  "\t\telse"
 		print  "\t\tif ((check >= 160)"
 		print  "\t\t && (check < 256)"
+		print  "\t\t && !_nc_unicode_locale()"
 		print  "\t\t && ((sp != 0)"
 		print  "\t\t  && ((sp->_legacy_coding > 0)"
 		print  "\t\t   || (sp->_legacy_coding == 0"
diff --git a/contrib/ncurses/ncurses/base/key_defined.c b/contrib/ncurses/ncurses/base/key_defined.c
index 25d5a674e1b8..147e5fe2db93 100644
--- a/contrib/ncurses/ncurses/base/key_defined.c
+++ b/contrib/ncurses/ncurses/base/key_defined.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
  * Copyright 2003-2006,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -32,8 +32,9 @@
  ****************************************************************************/
 
 #include <curses.priv.h>
+#include <tic.h>
 
-MODULE_ID("$Id: key_defined.c,v 1.10 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: key_defined.c,v 1.11 2023/06/24 15:36:32 tom Exp $")
 
 static int
 find_definition(TRIES * tree, const char *str)
@@ -41,7 +42,7 @@ find_definition(TRIES * tree, const char *str)
     TRIES *ptr;
     int result = OK;
 
-    if (str != 0 && *str != '\0') {
+    if (VALID_STRING(str) && *str != '\0') {
 	for (ptr = tree; ptr != 0; ptr = ptr->sibling) {
 	    if (UChar(*str) == UChar(ptr->ch)) {
 		if (str[1] == '\0' && ptr->child != 0) {
diff --git a/contrib/ncurses/ncurses/base/keyok.c b/contrib/ncurses/ncurses/base/keyok.c
index 8e0b9629db20..945228aa8035 100644
--- a/contrib/ncurses/ncurses/base/keyok.c
+++ b/contrib/ncurses/ncurses/base/keyok.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 2019-2020,2021 Thomas E. Dickey                                *
  * Copyright 1998-2012,2014 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -34,13 +34,13 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: keyok.c,v 1.16 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: keyok.c,v 1.17 2021/06/17 21:26:02 tom Exp $")
 
 /*
  * Enable (or disable) ncurses' interpretation of a keycode by adding (or
  * removing) the corresponding 'tries' entry.
  *
- * Do this by storing a second tree of tries, which records the disabled keys. 
+ * Do this by storing a second tree of tries, which records the disabled keys.
  * The simplest way to copy is to make a function that returns the string (with
  * nulls set to 0200), then use that to reinsert the string into the
  * corresponding tree.
diff --git a/contrib/ncurses/ncurses/base/lib_addch.c b/contrib/ncurses/ncurses/base/lib_addch.c
index 378c2881faac..a14bfd3b0e05 100644
--- a/contrib/ncurses/ncurses/base/lib_addch.c
+++ b/contrib/ncurses/ncurses/base/lib_addch.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2019-2020,2021 Thomas E. Dickey                                *
+ * Copyright 2019-2021,2022 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -37,7 +37,7 @@
 #include <curses.priv.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_addch.c,v 1.137 2021/02/20 22:24:34 tom Exp $")
+MODULE_ID("$Id: lib_addch.c,v 1.141 2022/06/12 15:16:41 tom Exp $")
 
 static const NCURSES_CH_T blankchar = NewChar(BLANK_TEXT);
 
@@ -140,7 +140,7 @@ newline_forces_scroll(WINDOW *win, NCURSES_SIZE_T *ypos)
  * wrapped the cursor.  We don't do anything with this flag except set it when
  * wrapping, and clear it whenever we move the cursor.  If we try to wrap at
  * the lower-right corner of a window, we cannot move the cursor (since that
- * wouldn't be legal).  So we return an error (which is what SVr4 does). 
+ * wouldn't be legal).  So we return an error (which is what SVr4 does).
  * Unlike SVr4, we can successfully add a character to the lower-right corner
  * (Solaris 2.6 does this also, however).
  */
@@ -321,20 +321,29 @@ waddch_literal(WINDOW *win, NCURSES_CH_T ch)
 	int len = _nc_wacs_width(CharOf(ch));
 	int i;
 	int j;
-	wchar_t *chars;
 
 	if (len == 0) {		/* non-spacing */
 	    if ((x > 0 && y >= 0)
 		|| (win->_maxx >= 0 && win->_cury >= 1)) {
-		if (x > 0 && y >= 0)
-		    chars = (win->_line[y].text[x - 1].chars);
-		else
-		    chars = (win->_line[y - 1].text[win->_maxx].chars);
+		NCURSES_CH_T *dst;
+		wchar_t *chars;
+		if (x > 0 && y >= 0) {
+		    for (j = x - 1; j >= 0; --j) {
+			if (!isWidecExt(win->_line[y].text[j])) {
+			    win->_curx = (NCURSES_SIZE_T) j;
+			    break;
+			}
+		    }
+		    dst = &(win->_line[y].text[j]);
+		} else {
+		    dst = &(win->_line[y - 1].text[win->_maxx]);
+		}
+		chars = dst->chars;
 		for (i = 0; i < CCHARW_MAX; ++i) {
 		    if (chars[i] == 0) {
 			TR(TRACE_VIRTPUT,
-			   ("added non-spacing %d: %x",
-			    x, (int) CharOf(ch)));
+			   ("adding non-spacing %s (level %d)",
+			    _tracech_t(CHREF(ch)), i));
 			chars[i] = CharOf(ch);
 			break;
 		    }
@@ -410,9 +419,9 @@ waddch_literal(WINDOW *win, NCURSES_CH_T ch)
   testwrapping:
     );
 
-    TR(TRACE_VIRTPUT, ("cell (%ld, %ld..%d) = %s",
-		       (long) win->_cury, (long) win->_curx, x - 1,
-		       _tracech_t(CHREF(ch))));
+    TR(TRACE_VIRTPUT, ("cell (%d, %d..%d) = %s",
+		       win->_cury, win->_curx, x - 1,
+		       _tracech_t(CHREF(line->text[win->_curx]))));
 
     if (x > win->_maxx) {
 	return wrap_to_next_line(win);
diff --git a/contrib/ncurses/ncurses/base/lib_addstr.c b/contrib/ncurses/ncurses/base/lib_addstr.c
index a1e8829dd7f5..a3753af0d53e 100644
--- a/contrib/ncurses/ncurses/base/lib_addstr.c
+++ b/contrib/ncurses/ncurses/base/lib_addstr.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 2019-2022,2023 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -45,7 +45,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_addstr.c,v 1.57 2020/12/05 20:06:19 tom Exp $")
+MODULE_ID("$Id: lib_addstr.c,v 1.62 2023/11/21 21:47:23 tom Exp $")
 
 NCURSES_EXPORT(int)
 waddnstr(WINDOW *win, const char *astr, int n)
@@ -55,15 +55,18 @@ waddnstr(WINDOW *win, const char *astr, int n)
 
     T((T_CALLED("waddnstr(%p,%s,%d)"), (void *) win, _nc_visbufn(astr, n), n));
 
-    if (win && (str != 0)) {
+    if (win && (str != 0) && (n != 0)) {
+	bool explicit = (n > 0);
+
 	TR(TRACE_VIRTPUT | TRACE_ATTRS,
 	   ("... current %s", _traceattr(WINDOW_ATTRS(win))));
 	code = OK;
-	if (n < 0)
-	    n = INT_MAX;
 
-	TR(TRACE_VIRTPUT, ("str is not null, length = %d", n));
-	while ((*str != '\0') && (n-- > 0)) {
+	TR(TRACE_VIRTPUT, ("str is not null, length = %d",
+			   (explicit ? n : (int) strlen(str))));
+	if (!explicit)
+	    n = INT_MAX;
+	while ((n-- > 0) && (*str != '\0')) {
 	    NCURSES_CH_T ch;
 	    TR(TRACE_VIRTPUT, ("*str = %#o", UChar(*str)));
 	    SetChar(ch, UChar(*str++), A_NORMAL);
@@ -143,7 +146,7 @@ wadd_wchnstr(WINDOW *win, const cchar_t *astr, int n)
        _nc_viscbuf(astr, n),
        n));
 
-    if (!win)
+    if (!win || !astr)
 	returnCode(ERR);
 
     y = win->_cury;
@@ -227,15 +230,18 @@ waddnwstr(WINDOW *win, const wchar_t *str, int n)
 
     T((T_CALLED("waddnwstr(%p,%s,%d)"), (void *) win, _nc_viswbufn(str, n), n));
 
-    if (win && (str != 0)) {
+    if (win && (str != 0) && (n != 0)) {
+	bool explicit = (n > 0);
+
 	TR(TRACE_VIRTPUT | TRACE_ATTRS,
 	   ("... current %s", _traceattr(WINDOW_ATTRS(win))));
 	code = OK;
-	if (n < 0)
-	    n = INT_MAX;
 
-	TR(TRACE_VIRTPUT, ("str is not null, length = %d", n));
-	while ((*str != L('\0')) && (n-- > 0)) {
+	TR(TRACE_VIRTPUT, ("str is not null, length = %d",
+			   (explicit ? n : (int) wcslen(str))));
+	if (!explicit)
+	    n = INT_MAX;
+	while ((n-- > 0) && (*str != L('\0'))) {
 	    NCURSES_CH_T ch;
 	    TR(TRACE_VIRTPUT, ("*str[0] = %#lx", (unsigned long) *str));
 	    SetChar(ch, *str++, A_NORMAL);
diff --git a/contrib/ncurses/ncurses/base/lib_bkgd.c b/contrib/ncurses/ncurses/base/lib_bkgd.c
index 23effc7cd141..4f99080835e8 100644
--- a/contrib/ncurses/ncurses/base/lib_bkgd.c
+++ b/contrib/ncurses/ncurses/base/lib_bkgd.c
@@ -37,7 +37,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_bkgd.c,v 1.62 2021/02/13 20:06:54 tom Exp $")
+MODULE_ID("$Id: lib_bkgd.c,v 1.63 2021/05/08 14:58:12 tom Exp $")
 
 static const NCURSES_CH_T blank = NewChar(BLANK_TEXT);
 
@@ -64,7 +64,7 @@ wbkgrndset(WINDOW *win, const ARG_CH_T ch)
 	{
 	    int pair;
 
-	    if ((pair = GetPair(win->_nc_bkgd)) != 0)
+	    if (GetPair(win->_nc_bkgd) != 0)
 		SET_WINDOW_PAIR(win, 0);
 	    if ((pair = GetPair(CHDEREF(ch))) != 0)
 		SET_WINDOW_PAIR(win, pair);
diff --git a/contrib/ncurses/ncurses/base/lib_clreol.c b/contrib/ncurses/ncurses/base/lib_clreol.c
index d6cb9b261283..0b6b0ff8f7de 100644
--- a/contrib/ncurses/ncurses/base/lib_clreol.c
+++ b/contrib/ncurses/ncurses/base/lib_clreol.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2001,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -41,7 +41,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_clreol.c,v 1.23 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_clreol.c,v 1.24 2021/10/23 19:06:01 tom Exp $")
 
 NCURSES_EXPORT(int)
 wclrtoeol(WINDOW *win)
@@ -61,7 +61,7 @@ wclrtoeol(WINDOW *win)
 	 * If we have just wrapped the cursor, the clear applies to the
 	 * new line, unless we are at the lower right corner.
 	 */
-	if ((win->_flags & _WRAPPED) != 0
+	if (IS_WRAPPED(win) != 0
 	    && y < win->_maxy) {
 	    win->_flags &= ~_WRAPPED;
 	}
@@ -70,7 +70,7 @@ wclrtoeol(WINDOW *win)
 	 * There's no point in clearing if we're not on a legal
 	 * position, either.
 	 */
-	if ((win->_flags & _WRAPPED) != 0
+	if (IS_WRAPPED(win)
 	    || y > win->_maxy
 	    || x > win->_maxx)
 	    returnCode(ERR);
diff --git a/contrib/ncurses/ncurses/base/lib_color.c b/contrib/ncurses/ncurses/base/lib_color.c
index 907e9743fcda..f001b22413fe 100644
--- a/contrib/ncurses/ncurses/base/lib_color.c
+++ b/contrib/ncurses/ncurses/base/lib_color.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2020,2021 Thomas E. Dickey                                *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -49,7 +49,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_color.c,v 1.146 2021/02/14 00:17:09 tom Exp $")
+MODULE_ID("$Id: lib_color.c,v 1.150 2023/09/16 16:39:15 tom Exp $")
 
 #ifdef USE_TERM_DRIVER
 #define CanChange      InfoOf(SP_PARM).canchange
@@ -94,8 +94,6 @@ NCURSES_EXPORT_VAR(int) COLORS = 0;
 
 #define DATA(r,g,b) {r,g,b, 0,0,0, 0}
 
-#define TYPE_CALLOC(type,elts) typeCalloc(type, (unsigned)(elts))
-
 #define MAX_PALETTE	8
 
 #define OkColorHi(n)	(((n) < COLORS) && ((n) < maxcolors))
@@ -266,7 +264,7 @@ init_direct_colors(NCURSES_SP_DCL0)
 	    ;
 	}
 
-	if ((n = tigetflag(name)) > 0) {
+	if (tigetflag(name) > 0) {
 	    n = (width + 2) / 3;
 	    result->bits.red = UChar(n);
 	    result->bits.green = UChar(n);
@@ -412,7 +410,7 @@ NCURSES_SP_NAME(start_color) (NCURSES_SP_DCL0)
 		if (init_direct_colors(NCURSES_SP_ARG)) {
 		    result = OK;
 		} else {
-		    SP_PARM->_color_table = TYPE_CALLOC(color_t, maxcolors);
+		    TYPE_CALLOC(color_t, maxcolors, SP_PARM->_color_table);
 		    if (SP_PARM->_color_table != 0) {
 			MakeColorPair(SP_PARM->_color_pairs[0],
 				      default_fg(NCURSES_SP_ARG),
@@ -529,7 +527,7 @@ _nc_reserve_pairs(SCREEN *sp, int want)
 	have = sp->_pair_limit;
 
     if (sp->_color_pairs == 0) {
-	sp->_color_pairs = TYPE_CALLOC(colorpair_t, have);
+	TYPE_CALLOC(colorpair_t, have, sp->_color_pairs);
     } else if (have > sp->_pair_alloc) {
 #if NCURSES_EXT_COLORS
 	colorpair_t *next;
@@ -747,7 +745,7 @@ _nc_init_color(SCREEN *sp, int color, int r, int g, int b)
 	NCURSES_PUTP2("initialize_color",
 		      TIPARM_4(initialize_color, color, r, g, b));
 #endif
-	sp->_color_defs = max(color + 1, sp->_color_defs);
+	sp->_color_defs = Max(color + 1, sp->_color_defs);
 
 	result = OK;
     }
@@ -831,7 +829,6 @@ static int
 _nc_color_content(SCREEN *sp, int color, int *r, int *g, int *b)
 {
     int result = ERR;
-    int maxcolors;
 
     T((T_CALLED("color_content(%p,%d,%p,%p,%p)"),
        (void *) sp,
@@ -840,52 +837,57 @@ _nc_color_content(SCREEN *sp, int color, int *r, int *g, int *b)
        (void *) g,
        (void *) b));
 
-    if (sp == 0)
-	returnCode(result);
-
-    maxcolors = MaxColors;
+    if (sp != 0) {
+	int maxcolors = MaxColors;
 
-    if (color < 0 || !OkColorHi(color) || !sp->_coloron) {
-	result = ERR;
-    } else {
-	int c_r, c_g, c_b;
+	if (color >= 0 && OkColorHi(color) && sp->_coloron) {
+	    int c_r, c_g, c_b;
 
-	if (sp->_direct_color.value) {
-	    rgb_bits_t *work = &(sp->_direct_color);
+	    if (sp->_direct_color.value) {
+		rgb_bits_t *work = &(sp->_direct_color);
 
 #define max_direct_color(name)	((1 << work->bits.name) - 1)
 #define value_direct_color(max) (1000 * ((color >> bitoff) & max)) / max
 
-	    int max_r = max_direct_color(red);
-	    int max_g = max_direct_color(green);
-	    int max_b = max_direct_color(blue);
+		int max_r = max_direct_color(red);
+		int max_g = max_direct_color(green);
+		int max_b = max_direct_color(blue);
 
-	    int bitoff = 0;
+		int bitoff = 0;
 
-	    c_b = value_direct_color(max_b);
-	    bitoff += work->bits.blue;
+		c_b = value_direct_color(max_b);
+		bitoff += work->bits.blue;
 
-	    c_g = value_direct_color(max_g);
-	    bitoff += work->bits.green;
+		c_g = value_direct_color(max_g);
+		bitoff += work->bits.green;
 
-	    c_r = value_direct_color(max_r);
+		c_r = value_direct_color(max_r);
 
-	} else {
-	    c_r = sp->_color_table[color].red;
-	    c_g = sp->_color_table[color].green;
-	    c_b = sp->_color_table[color].blue;
-	}
+	    } else {
+		c_r = sp->_color_table[color].red;
+		c_g = sp->_color_table[color].green;
+		c_b = sp->_color_table[color].blue;
+	    }
 
+	    if (r)
+		*r = c_r;
+	    if (g)
+		*g = c_g;
+	    if (b)
+		*b = c_b;
+
+	    TR(TRACE_ATTRS, ("...color_content(%d,%d,%d,%d)",
+			     color, c_r, c_g, c_b));
+	    result = OK;
+	}
+    }
+    if (result != OK) {
 	if (r)
-	    *r = c_r;
+	    *r = 0;
 	if (g)
-	    *g = c_g;
+	    *g = 0;
 	if (b)
-	    *b = c_b;
-
-	TR(TRACE_ATTRS, ("...color_content(%d,%d,%d,%d)",
-			 color, c_r, c_g, c_b));
-	result = OK;
+	    *b = 0;
     }
     returnCode(result);
 }
diff --git a/contrib/ncurses/ncurses/base/lib_delwin.c b/contrib/ncurses/ncurses/base/lib_delwin.c
index 2f0621cf856c..c96e417a9a48 100644
--- a/contrib/ncurses/ncurses/base/lib_delwin.c
+++ b/contrib/ncurses/ncurses/base/lib_delwin.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020-2021,2023 Thomas E. Dickey                                *
  * Copyright 1998-2008,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -43,24 +43,29 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_delwin.c,v 1.21 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_delwin.c,v 1.25 2023/10/21 11:12:44 tom Exp $")
 
 static bool
 cannot_delete(WINDOW *win)
 {
-    WINDOWLIST *p;
     bool result = TRUE;
-#ifdef USE_SP_WINDOWLIST
-    SCREEN *sp = _nc_screen_of(win);
+
+    if (IS_PAD(win)) {
+	result = FALSE;
+    } else {
+	WINDOWLIST *p;
+#if NCURSES_SP_FUNCS && defined(USE_SP_WINDOWLIST)
+	SCREEN *sp = _nc_screen_of(win);
 #endif
 
-    for (each_window(SP_PARM, p)) {
-	if (&(p->win) == win) {
-	    result = FALSE;
-	} else if ((p->win._flags & _SUBWIN) != 0
-		   && p->win._parent == win) {
-	    result = TRUE;
-	    break;
+	for (each_window(SP_PARM, p)) {
+	    if (&(p->win) == win) {
+		result = FALSE;
+	    } else if (IS_SUBWIN(&(p->win))
+		       && p->win._parent == win) {
+		result = TRUE;
+		break;
+	    }
 	}
     }
     return result;
@@ -77,15 +82,18 @@ delwin(WINDOW *win)
 	if (win == 0
 	    || cannot_delete(win)) {
 	    result = ERR;
+	} else if (IS_PAD(win)) {
+	    win->_parent = NULL;
+	    result = _nc_freewin(win);
 	} else {
 #if NCURSES_SP_FUNCS
 	    SCREEN *sp = _nc_screen_of(win);
 #endif
-	    if (win->_flags & _SUBWIN)
+	    if (IS_SUBWIN(win)) {
 		touchwin(win->_parent);
-	    else if (CurScreen(SP_PARM) != 0)
+	    } else if (CurScreen(SP_PARM) != 0) {
 		touchwin(CurScreen(SP_PARM));
-
+	    }
 	    result = _nc_freewin(win);
 	}
 	_nc_unlock_global(curses);
diff --git a/contrib/ncurses/ncurses/base/lib_dft_fgbg.c b/contrib/ncurses/ncurses/base/lib_dft_fgbg.c
index 95dc0c224035..4dd43bb1bbd0 100644
--- a/contrib/ncurses/ncurses/base/lib_dft_fgbg.c
+++ b/contrib/ncurses/ncurses/base/lib_dft_fgbg.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2014,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -38,7 +38,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_dft_fgbg.c,v 1.30 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_dft_fgbg.c,v 1.31 2021/04/03 22:27:18 tom Exp $")
 
 /*
  * Modify the behavior of color-pair 0 so that the library doesn't assume that
@@ -83,7 +83,9 @@ NCURSES_SP_NAME(assume_default_colors) (NCURSES_SP_DCLx int fg, int bg)
 		bool save = SP_PARM->_default_color;
 		SP_PARM->_assumed_color = TRUE;
 		SP_PARM->_default_color = TRUE;
-		init_pair(0, (short) fg, (short) bg);
+		NCURSES_SP_NAME(init_pair) (NCURSES_SP_ARGx 0,
+					    (short)fg,
+					    (short)bg);
 		SP_PARM->_default_color = save;
 	    }
 	    code = OK;
diff --git a/contrib/ncurses/ncurses/base/lib_echo.c b/contrib/ncurses/ncurses/base/lib_echo.c
index d8f57f292d60..de7832f4afc1 100644
--- a/contrib/ncurses/ncurses/base/lib_echo.c
+++ b/contrib/ncurses/ncurses/base/lib_echo.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
  * Copyright 1998-2000,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -45,7 +45,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_echo.c,v 1.9 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_echo.c,v 1.10 2023/04/29 18:57:12 tom Exp $")
 
 NCURSES_EXPORT(int)
 NCURSES_SP_NAME(echo) (NCURSES_SP_DCL0)
@@ -53,7 +53,7 @@ NCURSES_SP_NAME(echo) (NCURSES_SP_DCL0)
     T((T_CALLED("echo(%p)"), (void *) SP_PARM));
     if (0 == SP_PARM)
 	returnCode(ERR);
-    SP_PARM->_echo = TRUE;
+    IsEcho(SP_PARM) = TRUE;
     returnCode(OK);
 }
 
@@ -71,7 +71,7 @@ NCURSES_SP_NAME(noecho) (NCURSES_SP_DCL0)
     T((T_CALLED("noecho(%p)"), (void *) SP_PARM));
     if (0 == SP_PARM)
 	returnCode(ERR);
-    SP_PARM->_echo = FALSE;
+    IsEcho(SP_PARM) = FALSE;
     returnCode(OK);
 }
 
diff --git a/contrib/ncurses/ncurses/base/lib_endwin.c b/contrib/ncurses/ncurses/base/lib_endwin.c
index b8a9e4e66a4d..85d2bdbaac05 100644
--- a/contrib/ncurses/ncurses/base/lib_endwin.c
+++ b/contrib/ncurses/ncurses/base/lib_endwin.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
  * Copyright 1998-2014,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -43,7 +43,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_endwin.c,v 1.25 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_endwin.c,v 1.28 2023/11/11 21:27:32 tom Exp $")
 
 NCURSES_EXPORT(int)
 NCURSES_SP_NAME(endwin) (NCURSES_SP_DCL0)
@@ -52,20 +52,24 @@ NCURSES_SP_NAME(endwin) (NCURSES_SP_DCL0)
 
     T((T_CALLED("endwin(%p)"), (void *) SP_PARM));
 
-    if (SP_PARM) {
+    if (SP_PARM != NULL) {
+	if (SP_PARM->_endwin != ewSuspend) {
 #ifdef USE_TERM_DRIVER
-	TERMINAL_CONTROL_BLOCK *TCB = TCBOf(SP_PARM);
+	    TERMINAL_CONTROL_BLOCK *TCB = TCBOf(SP_PARM);
 
-	SP_PARM->_endwin = ewSuspend;
-	if (TCB && TCB->drv && TCB->drv->td_scexit)
-	    TCB->drv->td_scexit(SP_PARM);
+	    SP_PARM->_endwin = ewSuspend;
+	    if (TCB && TCB->drv && TCB->drv->td_scexit)
+		TCB->drv->td_scexit(SP_PARM);
 #else
-	SP_PARM->_endwin = ewSuspend;
-	SP_PARM->_mouse_wrap(SP_PARM);
-	_nc_screen_wrap();
-	_nc_mvcur_wrap();	/* wrap up cursor addressing */
+	    SP_PARM->_endwin = ewSuspend;
+	    SP_PARM->_mouse_wrap(SP_PARM);
+	    _nc_screen_wrap();
+	    _nc_mvcur_wrap();	/* wrap up cursor addressing */
 #endif
-	code = NCURSES_SP_NAME(reset_shell_mode) (NCURSES_SP_ARG);
+	    code = OK;
+	}
+	if (NCURSES_SP_NAME(reset_shell_mode) (NCURSES_SP_ARG) == ERR)
+	    code = ERR;
     }
 
     returnCode(code);
diff --git a/contrib/ncurses/ncurses/base/lib_erase.c b/contrib/ncurses/ncurses/base/lib_erase.c
index e190ebd549ac..aa9437a19ef1 100644
--- a/contrib/ncurses/ncurses/base/lib_erase.c
+++ b/contrib/ncurses/ncurses/base/lib_erase.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2022 Thomas E. Dickey                                     *
  * Copyright 1998-2009,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -42,18 +42,18 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_erase.c,v 1.19 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_erase.c,v 1.20 2022/09/03 21:40:27 tom Exp $")
 
 NCURSES_EXPORT(int)
 werase(WINDOW *win)
 {
     int code = ERR;
-    NCURSES_CH_T blank;
     NCURSES_CH_T *start;
 
     T((T_CALLED("werase(%p)"), (void *) win));
 
     if (win) {
+	NCURSES_CH_T blank;
 	NCURSES_CH_T *sp;
 	int y;
 
diff --git a/contrib/ncurses/ncurses/base/lib_freeall.c b/contrib/ncurses/ncurses/base/lib_freeall.c
index 9133d08a7328..75bbe77e3409 100644
--- a/contrib/ncurses/ncurses/base/lib_freeall.c
+++ b/contrib/ncurses/ncurses/base/lib_freeall.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2020,2021 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -40,7 +40,7 @@
 extern int malloc_errfd;	/* FIXME */
 #endif
 
-MODULE_ID("$Id: lib_freeall.c,v 1.72 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_freeall.c,v 1.76 2021/11/06 21:52:49 tom Exp $")
 
 /*
  * Free all ncurses data.  This is used for testing only (there's no practical
@@ -78,6 +78,9 @@ NCURSES_SP_NAME(_nc_freeall) (NCURSES_SP_DCL0)
 		WINDOW *p_win = &(p->win);
 		bool found = FALSE;
 
+		if (IS_PAD(p_win))
+		    continue;
+
 #ifndef USE_SP_WINDOWLIST
 		if (p->screen != SP_PARM)
 		    continue;
@@ -92,7 +95,7 @@ NCURSES_SP_NAME(_nc_freeall) (NCURSES_SP_DCL0)
 #endif
 
 		    if ((p != q)
-			&& (q_win->_flags & _SUBWIN)
+			&& IS_SUBWIN(q_win)
 			&& (p_win == q_win->_parent)) {
 			found = TRUE;
 			break;
@@ -171,8 +174,6 @@ NCURSES_SP_NAME(_nc_free_and_exit) (NCURSES_SP_DCLx int code)
 {
     if (SP_PARM) {
 	delscreen(SP_PARM);
-	if (SP_PARM->_term)
-	    NCURSES_SP_NAME(del_curterm) (NCURSES_SP_ARGx SP_PARM->_term);
     }
     exit(code);
 }
diff --git a/contrib/ncurses/ncurses/base/lib_getch.c b/contrib/ncurses/ncurses/base/lib_getch.c
index 38537591afc0..8e4767918bdd 100644
--- a/contrib/ncurses/ncurses/base/lib_getch.c
+++ b/contrib/ncurses/ncurses/base/lib_getch.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
  * Copyright 1998-2015,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -44,7 +44,7 @@
 #define NEED_KEY_EVENT
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_getch.c,v 1.141 2020/09/05 22:50:47 tom Exp $")
+MODULE_ID("$Id: lib_getch.c,v 1.146 2023/04/29 18:57:12 tom Exp $")
 
 #include <fifo_defs.h>
 
@@ -298,8 +298,8 @@ fifo_push(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl))
     } else
 #endif
 #if USE_KLIBC_KBD
-    if (NC_ISATTY(sp->_ifd) && sp->_cbreak) {
-	ch = _read_kbd(0, 1, !sp->_raw);
+    if (NC_ISATTY(sp->_ifd) && IsCbreak(sp)) {
+	ch = _read_kbd(0, 1, !IsRaw(sp));
 	n = (ch == -1) ? -1 : 1;
 	sp->_extended_key = (ch == 0);
     } else
@@ -308,20 +308,15 @@ fifo_push(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl))
 #if defined(USE_TERM_DRIVER)
 	int buf;
 # if defined(EXP_WIN32_DRIVER)
-	if (NC_ISATTY(sp->_ifd) && IsTermInfoOnConsole(sp) && sp->_cbreak) {
-#  if USE_PTHREADS_EINTR
-	    if ((pthread_self) && (pthread_kill) && (pthread_equal))
-		_nc_globals.read_thread = pthread_self();
-#  endif
+	if (NC_ISATTY(sp->_ifd) && IsTermInfoOnConsole(sp) && IsCbreak(sp)) {
+	    _nc_set_read_thread(TRUE);
 	    n = _nc_console_read(sp,
 				 _nc_console_handle(sp->_ifd),
 				 &buf);
-#  if USE_PTHREADS_EINTR
-	    _nc_globals.read_thread = 0;
-#  endif
+	    _nc_set_read_thread(FALSE);
 	} else
 # elif defined(_NC_WINDOWS)
-	if (NC_ISATTY(sp->_ifd) && IsTermInfoOnConsole(sp) && sp->_cbreak)
+	if (NC_ISATTY(sp->_ifd) && IsTermInfoOnConsole(sp) && IsCbreak(sp))
 	    n = _nc_mingw_console_read(sp,
 				       _nc_get_handle(sp->_ifd),
 				       &buf);
@@ -334,12 +329,8 @@ fifo_push(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl))
 	int buf;
 #endif
 	unsigned char c2 = 0;
-#if USE_PTHREADS_EINTR
-#if USE_WEAK_SYMBOLS
-	if ((pthread_self) && (pthread_kill) && (pthread_equal))
-#endif
-	    _nc_globals.read_thread = pthread_self();
-#endif
+
+	_nc_set_read_thread(TRUE);
 #if defined(EXP_WIN32_DRIVER)
 	n = _nc_console_read(sp,
 			     _nc_console_handle(sp->_ifd),
@@ -348,9 +339,7 @@ fifo_push(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl))
 #else
 	n = (int) read(sp->_ifd, &c2, (size_t) 1);
 #endif
-#if USE_PTHREADS_EINTR
-	_nc_globals.read_thread = 0;
-#endif
+	_nc_set_read_thread(FALSE);
 	ch = c2;
 #endif /* USE_TERM_DRIVER */
     }
@@ -391,7 +380,17 @@ recur_wrefresh(WINDOW *win)
 {
 #ifdef USE_PTHREADS
     SCREEN *sp = _nc_screen_of(win);
-    if (_nc_use_pthreads && sp != CURRENT_SCREEN) {
+    bool same_sp;
+
+    if (_nc_use_pthreads) {
+	_nc_lock_global(curses);
+	same_sp = (sp == CURRENT_SCREEN);
+	_nc_unlock_global(curses);
+    } else {
+	same_sp = (sp == CURRENT_SCREEN);
+    }
+
+    if (_nc_use_pthreads && !same_sp) {
 	SCREEN *save_SP;
 
 	/* temporarily switch to the window's screen to check/refresh */
@@ -404,7 +403,7 @@ recur_wrefresh(WINDOW *win)
     } else
 #endif
 	if ((is_wintouched(win) || (win->_flags & _HASMOVED))
-	    && !(win->_flags & _ISPAD)) {
+	    && !IS_PAD(win)) {
 	wrefresh(win);
     }
 }
@@ -480,8 +479,8 @@ _nc_wgetch(WINDOW *win,
      */
     if (head == -1 &&
 	!sp->_notty &&
-	!sp->_raw &&
-	!sp->_cbreak &&
+	!IsRaw(sp) &&
+	!IsCbreak(sp) &&
 	!sp->_called_wgetch) {
 	char buf[MAXCOLUMNS], *bufp;
 
@@ -514,13 +513,13 @@ _nc_wgetch(WINDOW *win,
 
     recur_wrefresh(win);
 
-    if (win->_notimeout || (win->_delay >= 0) || (sp->_cbreak > 1)) {
+    if (win->_notimeout || (win->_delay >= 0) || (IsCbreak(sp) > 1)) {
 	if (head == -1) {	/* fifo is empty */
 	    int delay;
 
 	    TR(TRACE_IEVENT, ("timed delay in wgetch()"));
-	    if (sp->_cbreak > 1)
-		delay = (sp->_cbreak - 1) * 100;
+	    if (IsCbreak(sp) > 1)
+		delay = (IsCbreak(sp) - 1) * 100;
 	    else
 		delay = win->_delay;
 
@@ -551,7 +550,7 @@ _nc_wgetch(WINDOW *win,
 	 * This is tricky.  We only want to get special-key
 	 * events one at a time.  But we want to accumulate
 	 * mouse events until either (a) the mouse logic tells
-	 * us it's picked up a complete gesture, or (b)
+	 * us it has picked up a complete gesture, or (b)
 	 * there's a detectable time lapse after one.
 	 *
 	 * Note: if the mouse code starts failing to compose
@@ -639,7 +638,7 @@ _nc_wgetch(WINDOW *win,
      * However, we provide the same visual result as Solaris, moving the
      * cursor to the left.
      */
-    if (sp->_echo && !(win->_flags & _ISPAD)) {
+    if (IsEcho(sp) && !IS_PAD(win)) {
 	chtype backup = (chtype) ((ch == KEY_BACKSPACE) ? '\b' : ch);
 	if (backup < KEY_MIN)
 	    wechochar(win, backup);
@@ -648,7 +647,7 @@ _nc_wgetch(WINDOW *win,
     /*
      * Simulate ICRNL mode
      */
-    if ((ch == '\r') && sp->_nl)
+    if ((ch == '\r') && IsNl(sp))
 	ch = '\n';
 
     /* Strip 8th-bit if so desired.  We do this only for characters that
diff --git a/contrib/ncurses/ncurses/base/lib_getstr.c b/contrib/ncurses/ncurses/base/lib_getstr.c
index 7871fb357a62..cac21fc85bd9 100644
--- a/contrib/ncurses/ncurses/base/lib_getstr.c
+++ b/contrib/ncurses/ncurses/base/lib_getstr.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2018-2021,2023 Thomas E. Dickey                                *
  * Copyright 1998-2011,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -42,7 +42,7 @@
 #define NEED_KEY_EVENT
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_getstr.c,v 1.35 2020/07/18 20:02:24 tom Exp $")
+MODULE_ID("$Id: lib_getstr.c,v 1.39 2023/04/29 19:00:17 tom Exp $")
 
 /*
  * This wipes out the last character, no matter whether it was a tab, control
@@ -78,7 +78,7 @@ wgetnstr_events(WINDOW *win,
 {
     SCREEN *sp = _nc_screen_of(win);
     TTY buf;
-    bool oldnl, oldecho, oldraw, oldcbreak;
+    TTY_FLAGS save_flags;
     char erasec;
     char killc;
     char *oldstr;
@@ -94,14 +94,11 @@ wgetnstr_events(WINDOW *win,
 
     NCURSES_SP_NAME(_nc_get_tty_mode) (NCURSES_SP_ARGx &buf);
 
-    oldnl = sp->_nl;
-    oldecho = sp->_echo;
-    oldraw = sp->_raw;
-    oldcbreak = sp->_cbreak;
+    save_flags = sp->_tty_flags;
     NCURSES_SP_NAME(nl) (NCURSES_SP_ARG);
     NCURSES_SP_NAME(noecho) (NCURSES_SP_ARG);
-    NCURSES_SP_NAME(noraw) (NCURSES_SP_ARG);
-    NCURSES_SP_NAME(cbreak) (NCURSES_SP_ARG);
+    if (!save_flags._raw)
+	NCURSES_SP_NAME(cbreak) (NCURSES_SP_ARG);
 
     erasec = NCURSES_SP_NAME(erasechar) (NCURSES_SP_ARG);
     killc = NCURSES_SP_NAME(killchar) (NCURSES_SP_ARG);
@@ -115,7 +112,7 @@ wgetnstr_events(WINDOW *win,
     while ((ch = wgetch_events(win, evl)) != ERR) {
 	/*
 	 * Some terminals (the Wyse-50 is the most common) generate
-	 * a \n from the down-arrow key.  With this logic, it's the
+	 * a \n from the down-arrow key.  With this logic, it is the
 	 * user's choice whether to set kcud=\n for wgetch();
 	 * terminating *getstr() with \n should work either way.
 	 */
@@ -123,7 +120,7 @@ wgetnstr_events(WINDOW *win,
 	    || ch == '\r'
 	    || ch == KEY_DOWN
 	    || ch == KEY_ENTER) {
-	    if (oldecho == TRUE
+	    if (save_flags._echo == TRUE
 		&& win->_cury == win->_maxy
 		&& win->_scroll)
 		wechochar(win, (chtype) '\n');
@@ -139,18 +136,18 @@ wgetnstr_events(WINDOW *win,
 #endif
 	if (ch == erasec || ch == KEY_LEFT || ch == KEY_BACKSPACE) {
 	    if (str > oldstr) {
-		str = WipeOut(win, y, x, oldstr, str, oldecho);
+		str = WipeOut(win, y, x, oldstr, str, save_flags._echo);
 	    }
 	} else if (ch == killc) {
 	    while (str > oldstr) {
-		str = WipeOut(win, y, x, oldstr, str, oldecho);
+		str = WipeOut(win, y, x, oldstr, str, save_flags._echo);
 	    }
 	} else if (ch >= KEY_MIN
 		   || (str - oldstr >= maxlen)) {
 	    NCURSES_SP_NAME(beep) (NCURSES_SP_ARG);
 	} else {
 	    *str++ = (char) ch;
-	    if (oldecho == TRUE) {
+	    if (save_flags._echo == TRUE) {
 		int oldy = win->_cury;
 		if (waddch(win, (chtype) ch) == ERR) {
 		    /*
@@ -160,9 +157,9 @@ wgetnstr_events(WINDOW *win,
 		     */
 		    win->_flags &= ~_WRAPPED;
 		    waddch(win, (chtype) ' ');
-		    str = WipeOut(win, y, x, oldstr, str, oldecho);
+		    str = WipeOut(win, y, x, oldstr, str, save_flags._echo);
 		    continue;
-		} else if (win->_flags & _WRAPPED) {
+		} else if (IS_WRAPPED(win)) {
 		    /*
 		     * If the last waddch forced a wrap &
 		     * scroll, adjust our reference point
@@ -191,11 +188,7 @@ wgetnstr_events(WINDOW *win,
     /* Restore with a single I/O call, to fix minor asymmetry between
      * raw/noraw, etc.
      */
-    sp->_nl = oldnl;
-    sp->_echo = oldecho;
-    sp->_raw = oldraw;
-    sp->_cbreak = oldcbreak;
-
+    sp->_tty_flags = save_flags;
     NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf);
 
     *str = '\0';
diff --git a/contrib/ncurses/ncurses/base/lib_insnstr.c b/contrib/ncurses/ncurses/base/lib_insnstr.c
index ff1ae573a576..caec48e8eb70 100644
--- a/contrib/ncurses/ncurses/base/lib_insnstr.c
+++ b/contrib/ncurses/ncurses/base/lib_insnstr.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
  * Copyright 2004-2009,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -41,7 +41,7 @@
 #include <curses.priv.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_insnstr.c,v 1.7 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_insnstr.c,v 1.10 2023/11/21 21:58:03 tom Exp $")
 
 NCURSES_EXPORT(int)
 winsnstr(WINDOW *win, const char *s, int n)
@@ -51,7 +51,7 @@ winsnstr(WINDOW *win, const char *s, int n)
 
     T((T_CALLED("winsnstr(%p,%s,%d)"), (void *) win, _nc_visbufn(s, n), n));
 
-    if (win != 0 && str != 0) {
+    if (win != 0 && str != 0 && n != 0) {
 	SCREEN *sp = _nc_screen_of(win);
 #if USE_WIDEC_SUPPORT
 	/*
@@ -70,6 +70,7 @@ winsnstr(WINDOW *win, const char *s, int n)
 		init_mb(state);
 		n3 = mbstowcs(buffer, s, nn);
 		if (n3 != (size_t) (-1)) {
+		    buffer[n3] = '\0';
 		    code = wins_nwstr(win, buffer, (int) n3);
 		}
 		free(buffer);
@@ -82,7 +83,7 @@ winsnstr(WINDOW *win, const char *s, int n)
 	    NCURSES_SIZE_T ox = win->_curx;
 	    const unsigned char *cp;
 
-	    for (cp = str; (n <= 0 || (cp - str) < n) && *cp; cp++) {
+	    for (cp = str; (n < 0 || (cp - str) < n) && *cp; cp++) {
 		_nc_insert_ch(sp, win, (chtype) UChar(*cp));
 	    }
 	    win->_curx = ox;
diff --git a/contrib/ncurses/ncurses/base/lib_instr.c b/contrib/ncurses/ncurses/base/lib_instr.c
index 2aa0fc32e9f3..221ebd290400 100644
--- a/contrib/ncurses/ncurses/base/lib_instr.c
+++ b/contrib/ncurses/ncurses/base/lib_instr.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020-2021,2023 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -42,7 +42,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_instr.c,v 1.24 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_instr.c,v 1.26 2023/06/03 12:37:04 tom Exp $")
 
 NCURSES_EXPORT(int)
 winnstr(WINDOW *win, char *str, int n)
@@ -66,7 +66,6 @@ winnstr(WINDOW *win, char *str, int n)
 	    cchar_t *cell = &(text[col]);
 	    attr_t attrs;
 	    NCURSES_PAIRS_T pair;
-	    mbstate_t state;
 	    char *tmp;
 
 	    if (!isWidecExt(*cell)) {
@@ -79,11 +78,12 @@ winnstr(WINDOW *win, char *str, int n)
 		    bool done = FALSE;
 
 		    if (getcchar(cell, wch, &attrs, &pair, 0) == OK) {
+			mbstate_t state;
 			size_t n3;
 
 			init_mb(state);
 			n3 = wcstombs(0, wch, (size_t) 0);
-			if (!isEILSEQ(n3) && (n3 != 0)) {
+			if (!isEILSEQ(n3) && (n3 != 0) && (n3 <= MB_LEN_MAX)) {
 			    size_t need = n3 + 10 + (size_t) i;
 			    int have = (int) n3 + i;
 
diff --git a/contrib/ncurses/ncurses/base/lib_mouse.c b/contrib/ncurses/ncurses/base/lib_mouse.c
index 6caef327a3c0..a03d8b8e1ab0 100644
--- a/contrib/ncurses/ncurses/base/lib_mouse.c
+++ b/contrib/ncurses/ncurses/base/lib_mouse.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2020,2021 Thomas E. Dickey                                *
+ * Copyright 2018-2023,2024 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -85,7 +85,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_mouse.c,v 1.192 2021/02/14 00:17:09 tom Exp $")
+MODULE_ID("$Id: lib_mouse.c,v 1.200 2024/02/17 21:13:01 tom Exp $")
 
 #include <tic.h>
 
@@ -380,7 +380,7 @@ handle_sysmouse(int sig GCC_UNUSED)
 }
 #endif /* USE_SYSMOUSE */
 
-#ifndef USE_TERM_DRIVER
+#if !defined(USE_TERM_DRIVER) || defined(EXP_WIN32_DRIVER)
 #define xterm_kmous "\033[M"
 
 static void
@@ -419,13 +419,22 @@ init_xterm_mouse(SCREEN *sp)
     } else {
 	int code = tigetnum("XM");
 	switch (code) {
+#ifdef EXP_XTERM_1005
+	case 1005:
+	    /* see "xterm+sm+1005" */
+	    sp->_mouse_xtermcap = "\033[?1005;1000%?%p1%{1}%=%th%el%;";
+	    sp->_mouse_format = MF_XTERM_1005;
+	    break;
+#endif
 	case 1006:
+	    /* see "xterm+sm+1006" */
+	    sp->_mouse_xtermcap = "\033[?1006;1000%?%p1%{1}%=%th%el%;";
+	    sp->_mouse_format = MF_SGR1006;
 	    break;
 	default:
-	    code = 1000;
+	    sp->_mouse_xtermcap = "\033[?1000%?%p1%{1}%=%th%el%;";
 	    break;
 	}
-	sp->_mouse_xtermcap = "\033[?1000%?%p1%{1}%=%th%el%;";
     }
 }
 #endif
@@ -433,6 +442,9 @@ init_xterm_mouse(SCREEN *sp)
 static void
 enable_xterm_mouse(SCREEN *sp, int enable)
 {
+    TPUTS_TRACE(enable
+		? "xterm mouse initialization"
+		: "xterm mouse deinitialization");
 #if USE_EMX_MOUSE
     sp->_emxmouse_activated = enable;
 #else
@@ -441,6 +453,18 @@ enable_xterm_mouse(SCREEN *sp, int enable)
     sp->_mouse_active = enable;
 }
 
+#if defined(USE_TERM_DRIVER)
+static void
+enable_win32_mouse(SCREEN *sp, int enable)
+{
+#if defined(EXP_WIN32_DRIVER)
+    enable_xterm_mouse(sp, enable);
+#else
+    sp->_mouse_active = enable;
+#endif
+}
+#endif
+
 #if USE_GPM_SUPPORT
 static bool
 allow_gpm_mouse(SCREEN *sp GCC_UNUSED)
@@ -732,7 +756,8 @@ initialize_mousetype(SCREEN *sp)
 
 #ifdef USE_TERM_DRIVER
     CallDriver(sp, td_initmouse);
-#else
+#endif
+#if !defined(USE_TERM_DRIVER) || defined(EXP_WIN32_DRIVER)
     /* we know how to recognize mouse events under "xterm" */
     if (NonEmpty(key_mouse)) {
 	init_xterm_mouse(sp);
@@ -751,13 +776,15 @@ _nc_mouse_init(SCREEN *sp)
 {
     bool result = FALSE;
 
+    T((T_CALLED("_nc_mouse_init(%p)"), (void *) sp));
+
     if (sp != 0) {
 	if (!sp->_mouse_initialized) {
 	    int i;
 
 	    sp->_mouse_initialized = TRUE;
 
-	    TR(MY_TRACE, ("_nc_mouse_init() called"));
+	    TR(MY_TRACE, ("set _mouse_initialized"));
 
 	    sp->_mouse_eventp = FirstEV(sp);
 	    for (i = 0; i < EV_MAX; i++)
@@ -765,11 +792,11 @@ _nc_mouse_init(SCREEN *sp)
 
 	    initialize_mousetype(sp);
 
-	    T(("_nc_mouse_init() set mousetype to %d", sp->_mouse_type));
+	    T(("set _mouse_type to %d", sp->_mouse_type));
 	}
 	result = sp->_mouse_initialized;
     }
-    return result;
+    returnCode(result);
 }
 
 /*
@@ -960,6 +987,17 @@ handle_wheel(SCREEN *sp, MEVENT * eventp, int button, int wheel)
 	PRESS_POSITION(3);
 	break;
     default:
+	/*
+	 * case 3 is sent when the mouse buttons are released.
+	 *
+	 * If the terminal uses xterm mode 1003, a continuous series of
+	 * button-release events is sent as the mouse moves around the screen,
+	 * or as the wheel mouse is rotated.
+	 *
+	 * Return false in this case, so that when running in X10 mode, we will
+	 * recalculate bstate.
+	 */
+	eventp->bstate = REPORT_MOUSE_POSITION;
 	result = FALSE;
 	break;
     }
@@ -1065,12 +1103,7 @@ decode_xterm_X10(SCREEN *sp, MEVENT * eventp)
     int res;
     bool result;
 
-# if USE_PTHREADS_EINTR
-#  if USE_WEAK_SYMBOLS
-    if ((pthread_self) && (pthread_kill) && (pthread_equal))
-#  endif
-	_nc_globals.read_thread = pthread_self();
-# endif
+    _nc_set_read_thread(TRUE);
     for (grabbed = 0; grabbed < MAX_KBUF; grabbed += (size_t) res) {
 
 	/* For VIO mouse we add extra bit 64 to disambiguate button-up. */
@@ -1084,9 +1117,7 @@ decode_xterm_X10(SCREEN *sp, MEVENT * eventp)
 	if (res == -1)
 	    break;
     }
-#if USE_PTHREADS_EINTR
-    _nc_globals.read_thread = 0;
-#endif
+    _nc_set_read_thread(FALSE);
     kbuf[MAX_KBUF] = '\0';
 
     TR(TRACE_IEVENT,
@@ -1120,12 +1151,7 @@ decode_xterm_1005(SCREEN *sp, MEVENT * eventp)
     coords[0] = 0;
     coords[1] = 0;
 
-# if USE_PTHREADS_EINTR
-#  if USE_WEAK_SYMBOLS
-    if ((pthread_self) && (pthread_kill) && (pthread_equal))
-#  endif
-	_nc_globals.read_thread = pthread_self();
-# endif
+    _nc_set_read_thread(TRUE);
     for (grabbed = 0; grabbed < limit;) {
 	int res;
 
@@ -1158,9 +1184,7 @@ decode_xterm_1005(SCREEN *sp, MEVENT * eventp)
 		break;
 	}
     }
-#if USE_PTHREADS_EINTR
-    _nc_globals.read_thread = 0;
-#endif
+    _nc_set_read_thread(FALSE);
 
     TR(TRACE_IEVENT,
        ("_nc_mouse_inline sees the following xterm data: %s",
@@ -1204,12 +1228,7 @@ read_SGR(SCREEN *sp, SGR_DATA * result)
     int marker = 1;
 
     memset(result, 0, sizeof(*result));
-# if USE_PTHREADS_EINTR
-#  if USE_WEAK_SYMBOLS
-    if ((pthread_self) && (pthread_kill) && (pthread_equal))
-#  endif
-	_nc_globals.read_thread = pthread_self();
-# endif
+    _nc_set_read_thread(TRUE);
 
     do {
 	int res;
@@ -1274,9 +1293,7 @@ read_SGR(SCREEN *sp, SGR_DATA * result)
 	}
 	++grabbed;
     } while (!isFinal(ch));
-#if USE_PTHREADS_EINTR
-    _nc_globals.read_thread = 0;
-#endif
+    _nc_set_read_thread(FALSE);
 
     kbuf[++grabbed] = 0;
     TR(TRACE_IEVENT,
@@ -1389,11 +1406,14 @@ _nc_mouse_inline(SCREEN *sp)
 static void
 mouse_activate(SCREEN *sp, int on)
 {
+    T((T_CALLED("mouse_activate(%p,%s)"),
+       (void *) SP_PARM, on ? "on" : "off"));
+
     if (!on && !sp->_mouse_initialized)
-	return;
+	returnVoid;
 
     if (!_nc_mouse_init(sp))
-	return;
+	returnVoid;
 
     if (on) {
 	sp->_mouse_bstate = 0;
@@ -1402,7 +1422,6 @@ mouse_activate(SCREEN *sp, int on)
 #if NCURSES_EXT_FUNCS
 	    NCURSES_SP_NAME(keyok) (NCURSES_SP_ARGx KEY_MOUSE, on);
 #endif
-	    TPUTS_TRACE("xterm mouse initialization");
 	    enable_xterm_mouse(sp, 1);
 	    break;
 #if USE_GPM_SUPPORT
@@ -1421,25 +1440,28 @@ mouse_activate(SCREEN *sp, int on)
 #endif
 #ifdef USE_TERM_DRIVER
 	case M_TERM_DRIVER:
-	    sp->_mouse_active = TRUE;
+	    enable_win32_mouse(sp, TRUE);
 	    break;
 #endif
 	case M_NONE:
-	    return;
+	    returnVoid;
+	default:
+	    T(("unexpected mouse mode"));
+	    break;
 	}
 	/* Make runtime binding to cut down on object size of applications that
 	 * do not use the mouse (e.g., 'clear').
 	 */
-	sp->_mouse_event = _nc_mouse_event;
+	/* *INDENT-EQLS* */
+	sp->_mouse_event  = _nc_mouse_event;
 	sp->_mouse_inline = _nc_mouse_inline;
-	sp->_mouse_parse = _nc_mouse_parse;
+	sp->_mouse_parse  = _nc_mouse_parse;
 	sp->_mouse_resume = _nc_mouse_resume;
-	sp->_mouse_wrap = _nc_mouse_wrap;
+	sp->_mouse_wrap   = _nc_mouse_wrap;
     } else {
 
 	switch (sp->_mouse_type) {
 	case M_XTERM:
-	    TPUTS_TRACE("xterm mouse deinitialization");
 	    enable_xterm_mouse(sp, 0);
 	    break;
 #if USE_GPM_SUPPORT
@@ -1455,14 +1477,18 @@ mouse_activate(SCREEN *sp, int on)
 #endif
 #ifdef USE_TERM_DRIVER
 	case M_TERM_DRIVER:
-	    sp->_mouse_active = FALSE;
+	    enable_win32_mouse(sp, FALSE);
 	    break;
 #endif
 	case M_NONE:
-	    return;
+	    returnVoid;
+	default:
+	    T(("unexpected mouse mode"));
+	    break;
 	}
     }
     NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
+    returnVoid;
 }
 
 /**************************************************************************
@@ -1560,7 +1586,7 @@ _nc_mouse_parse(SCREEN *sp, int runcount)
 		if (changed) {
 		    merge = FALSE;
 		    for (b = 1; b <= MAX_BUTTONS; ++b) {
-			if ((sp->_mouse_mask & MASK_CLICK(b))
+			if ((sp->_mouse_mask2 & MASK_CLICK(b))
 			    && (ep->bstate & MASK_PRESS(b))) {
 			    next->bstate &= ~MASK_RELEASE(b);
 			    next->bstate |= MASK_CLICK(b);
@@ -1641,7 +1667,7 @@ _nc_mouse_parse(SCREEN *sp, int runcount)
 		&& (next->bstate & BUTTON_CLICKED)) {
 		merge = FALSE;
 		for (b = 1; b <= MAX_BUTTONS; ++b) {
-		    if ((sp->_mouse_mask & MASK_DOUBLE_CLICK(b))
+		    if ((sp->_mouse_mask2 & MASK_DOUBLE_CLICK(b))
 			&& (ep->bstate & MASK_CLICK(b))
 			&& (next->bstate & MASK_CLICK(b))) {
 			next->bstate &= ~MASK_CLICK(b);
@@ -1659,7 +1685,7 @@ _nc_mouse_parse(SCREEN *sp, int runcount)
 		&& (next->bstate & BUTTON_CLICKED)) {
 		merge = FALSE;
 		for (b = 1; b <= MAX_BUTTONS; ++b) {
-		    if ((sp->_mouse_mask & MASK_TRIPLE_CLICK(b))
+		    if ((sp->_mouse_mask2 & MASK_TRIPLE_CLICK(b))
 			&& (ep->bstate & MASK_DOUBLE_CLICK(b))
 			&& (next->bstate & MASK_CLICK(b))) {
 			next->bstate &= ~MASK_CLICK(b);
@@ -1719,7 +1745,8 @@ _nc_mouse_parse(SCREEN *sp, int runcount)
 #endif /* TRACE */
 
     /* after all this, do we have a valid event? */
-    return ValidEvent(PREV(first_invalid));
+    ep = PREV(first_invalid);
+    return ValidEvent(ep) && ((ep->bstate & sp->_mouse_mask) != 0);
 }
 
 static void
@@ -1963,10 +1990,24 @@ wenclose(const WINDOW *win, int y, int x)
 
     if (win != 0) {
 	y -= win->_yoffset;
-	result = ((win->_begy <= y &&
-		   win->_begx <= x &&
-		   (win->_begx + win->_maxx) >= x &&
-		   (win->_begy + win->_maxy) >= y) ? TRUE : FALSE);
+	if (IS_PAD(win)) {
+	    if (win->_pad._pad_y >= 0 &&
+		win->_pad._pad_x >= 0 &&
+		win->_pad._pad_top >= 0 &&
+		win->_pad._pad_left >= 0 &&
+		win->_pad._pad_right >= 0 &&
+		win->_pad._pad_bottom >= 0) {
+		result = ((win->_pad._pad_top <= y &&
+			   win->_pad._pad_left <= x &&
+			   win->_pad._pad_right >= x &&
+			   win->_pad._pad_bottom >= y) ? TRUE : FALSE);
+	    }
+	} else {
+	    result = ((win->_begy <= y &&
+		       win->_begx <= x &&
+		       (win->_begx + win->_maxx) >= x &&
+		       (win->_begy + win->_maxy) >= y) ? TRUE : FALSE);
+	}
     }
     returnBool(result);
 }
@@ -2035,6 +2076,7 @@ wmouse_trafo(const WINDOW *win, int *pY, int *pX, bool to_screen)
 	int y = *pY;
 	int x = *pX;
 
+	T(("transform input %d,%d", y, x));
 	if (to_screen) {
 	    y += win->_begy + win->_yoffset;
 	    x += win->_begx;
@@ -2050,6 +2092,7 @@ wmouse_trafo(const WINDOW *win, int *pY, int *pX, bool to_screen)
 	if (result) {
 	    *pX = x;
 	    *pY = y;
+	    T(("output transform %d,%d", y, x));
 	}
     }
     returnBool(result);
diff --git a/contrib/ncurses/ncurses/base/lib_mvwin.c b/contrib/ncurses/ncurses/base/lib_mvwin.c
index 58bdb199f274..fca014efeb9a 100644
--- a/contrib/ncurses/ncurses/base/lib_mvwin.c
+++ b/contrib/ncurses/ncurses/base/lib_mvwin.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2009,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -43,7 +43,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_mvwin.c,v 1.19 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_mvwin.c,v 1.20 2021/10/23 18:57:41 tom Exp $")
 
 NCURSES_EXPORT(int)
 mvwin(WINDOW *win, int by, int bx)
@@ -54,7 +54,7 @@ mvwin(WINDOW *win, int by, int bx)
 
     T((T_CALLED("mvwin(%p,%d,%d)"), (void *) win, by, bx));
 
-    if (!win || (win->_flags & _ISPAD))
+    if (!win || IS_PAD(win))
 	returnCode(ERR);
 
     /*
@@ -63,7 +63,7 @@ mvwin(WINDOW *win, int by, int bx)
      */
 #if 0
     /* Copying subwindows is allowed, but it is expensive... */
-    if (win->_flags & _SUBWIN) {
+    if (IS_SUBWIN(win)) {
 	int err = ERR;
 	WINDOW *parent = win->_parent;
 	if (parent) {		/* Now comes the complicated and costly part, you should really
diff --git a/contrib/ncurses/ncurses/base/lib_newterm.c b/contrib/ncurses/ncurses/base/lib_newterm.c
index bba97ba1fae8..15d05a31b583 100644
--- a/contrib/ncurses/ncurses/base/lib_newterm.c
+++ b/contrib/ncurses/ncurses/base/lib_newterm.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2018-2020,2022 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -49,7 +49,7 @@
 
 #include <tic.h>
 
-MODULE_ID("$Id: lib_newterm.c,v 1.103 2020/09/05 21:34:04 tom Exp $")
+MODULE_ID("$Id: lib_newterm.c,v 1.104 2022/07/09 18:58:58 tom Exp $")
 
 #ifdef USE_TERM_DRIVER
 #define NumLabels      InfoOf(SP_PARM).numlabels
@@ -362,11 +362,14 @@ NCURSES_EXPORT(SCREEN *)
 newterm(const char *name, FILE *ofp, FILE *ifp)
 {
     SCREEN *rc;
+
+    _nc_init_pthreads();
     _nc_lock_global(prescreen);
     START_TRACE();
     rc = NCURSES_SP_NAME(newterm) (CURRENT_SCREEN_PRE, name, ofp, ifp);
     _nc_forget_prescr();
     _nc_unlock_global(prescreen);
+
     return rc;
 }
 #endif
diff --git a/contrib/ncurses/ncurses/base/lib_newwin.c b/contrib/ncurses/ncurses/base/lib_newwin.c
index 580d033b7d44..a6723197c093 100644
--- a/contrib/ncurses/ncurses/base/lib_newwin.c
+++ b/contrib/ncurses/ncurses/base/lib_newwin.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -44,7 +44,7 @@
 #include <curses.priv.h>
 #include <stddef.h>
 
-MODULE_ID("$Id: lib_newwin.c,v 1.75 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_newwin.c,v 1.76 2021/10/23 18:53:38 tom Exp $")
 
 #define window_is(name) ((sp)->_##name == win)
 
@@ -114,7 +114,7 @@ _nc_freewin(WINDOW *win)
 		    else
 			q->next = p->next;
 
-		    if (!(win->_flags & _SUBWIN)) {
+		    if (!IS_SUBWIN(win)) {
 			int i;
 
 			for (i = 0; i <= win->_maxy; i++)
@@ -219,7 +219,7 @@ derwin(WINDOW *orig, int num_lines, int num_columns, int begy, int begx)
     if (num_columns == 0)
 	num_columns = orig->_maxx + 1 - begx;
 
-    if (orig->_flags & _ISPAD)
+    if (IS_PAD(orig))
 	flags |= _ISPAD;
 
     win = NCURSES_SP_NAME(_nc_makenew) (NCURSES_SP_ARGx num_lines, num_columns,
diff --git a/contrib/ncurses/ncurses/base/lib_nl.c b/contrib/ncurses/ncurses/base/lib_nl.c
index df07349fc83c..417b257d0399 100644
--- a/contrib/ncurses/ncurses/base/lib_nl.c
+++ b/contrib/ncurses/ncurses/base/lib_nl.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
  * Copyright 1998-2000,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -45,7 +45,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_nl.c,v 1.13 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_nl.c,v 1.14 2023/04/29 18:51:49 tom Exp $")
 
 #ifdef __EMX__
 #include <io.h>
@@ -57,7 +57,7 @@ NCURSES_SP_NAME(nl) (NCURSES_SP_DCL0)
     T((T_CALLED("nl(%p)"), (void *) SP_PARM));
     if (0 == SP_PARM)
 	returnCode(ERR);
-    SP_PARM->_nl = TRUE;
+    IsNl(SP_PARM) = TRUE;
 #ifdef __EMX__
     _nc_flush();
     _fsetmode(NC_OUTPUT(SP_PARM), "t");
@@ -79,7 +79,7 @@ NCURSES_SP_NAME(nonl) (NCURSES_SP_DCL0)
     T((T_CALLED("nonl(%p)"), (void *) SP_PARM));
     if (0 == SP_PARM)
 	returnCode(ERR);
-    SP_PARM->_nl = FALSE;
+    IsNl(SP_PARM) = FALSE;
 #ifdef __EMX__
     _nc_flush();
     _fsetmode(NC_OUTPUT(SP_PARM), "b");
diff --git a/contrib/ncurses/ncurses/base/lib_overlay.c b/contrib/ncurses/ncurses/base/lib_overlay.c
index 6d451d046a85..6d21c7617047 100644
--- a/contrib/ncurses/ncurses/base/lib_overlay.c
+++ b/contrib/ncurses/ncurses/base/lib_overlay.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
  * Copyright 1998-2013,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -41,7 +41,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_overlay.c,v 1.33 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_overlay.c,v 1.34 2023/09/16 16:39:07 tom Exp $")
 
 static int
 overlap(const WINDOW *const src, WINDOW *const dst, int const flag)
@@ -78,12 +78,12 @@ overlap(const WINDOW *const src, WINDOW *const dst, int const flag)
 	dy2 = dy1 + dst->_maxy;
 
 	if (dx2 >= sx1 && dx1 <= sx2 && dy2 >= sy1 && dy1 <= sy2) {
-	    int sminrow = max(sy1, dy1) - sy1;
-	    int smincol = max(sx1, dx1) - sx1;
-	    int dminrow = max(sy1, dy1) - dy1;
-	    int dmincol = max(sx1, dx1) - dx1;
-	    int dmaxrow = min(sy2, dy2) - dy1;
-	    int dmaxcol = min(sx2, dx2) - dx1;
+	    int sminrow = Max(sy1, dy1) - sy1;
+	    int smincol = Max(sx1, dx1) - sx1;
+	    int dminrow = Max(sy1, dy1) - dy1;
+	    int dmincol = Max(sx1, dx1) - dx1;
+	    int dmaxrow = Min(sy2, dy2) - dy1;
+	    int dmaxcol = Min(sx2, dx2) - dx1;
 
 	    rc = copywin(src, dst,
 			 sminrow, smincol,
diff --git a/contrib/ncurses/ncurses/base/lib_pad.c b/contrib/ncurses/ncurses/base/lib_pad.c
index 73978fbb8ad2..d4bd7f111bef 100644
--- a/contrib/ncurses/ncurses/base/lib_pad.c
+++ b/contrib/ncurses/ncurses/base/lib_pad.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2010,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -43,7 +43,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_pad.c,v 1.48 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_pad.c,v 1.50 2021/10/23 22:57:27 tom Exp $")
 
 NCURSES_EXPORT(WINDOW *)
 NCURSES_SP_NAME(newpad) (NCURSES_SP_DCLx int l, int c)
@@ -90,7 +90,7 @@ subpad(WINDOW *orig, int l, int c, int begy, int begx)
     T((T_CALLED("subpad(%d, %d)"), l, c));
 
     if (orig) {
-	if (!(orig->_flags & _ISPAD)
+	if (!IS_PAD(orig)
 	    || ((win = derwin(orig, l, c, begy, begx)) == NULL))
 	    returnWin(0);
     }
@@ -146,7 +146,7 @@ pnoutrefresh(WINDOW *win,
     if (win == 0)
 	returnCode(ERR);
 
-    if (!(win->_flags & _ISPAD))
+    if (!IS_PAD(win))
 	returnCode(ERR);
 
     sp = _nc_screen_of(win);
@@ -296,7 +296,7 @@ pnoutrefresh(WINDOW *win,
 
     /*
      * Use the pad's current position, if it will be visible.
-     * If not, don't do anything; it's not an error.
+     * If not, don't do anything; it is not an error.
      */
     if (win->_leaveok == FALSE
 	&& win->_cury >= pminrow
@@ -334,7 +334,7 @@ pechochar(WINDOW *pad, const chtype ch)
     if (pad == 0)
 	returnCode(ERR);
 
-    if (!(pad->_flags & _ISPAD))
+    if (!IS_PAD(pad))
 	returnCode(wechochar(pad, ch));
 
     waddch(pad, ch);
diff --git a/contrib/ncurses/ncurses/base/lib_refresh.c b/contrib/ncurses/ncurses/base/lib_refresh.c
index d8444289c152..bcaa4624b8a9 100644
--- a/contrib/ncurses/ncurses/base/lib_refresh.c
+++ b/contrib/ncurses/ncurses/base/lib_refresh.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020-2021,2023 Thomas E. Dickey                                *
  * Copyright 1998-2010,2011 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -43,7 +43,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_refresh.c,v 1.46 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_refresh.c,v 1.48 2023/05/27 20:13:10 tom Exp $")
 
 NCURSES_EXPORT(int)
 wrefresh(WINDOW *win)
@@ -92,13 +92,21 @@ wnoutrefresh(WINDOW *win)
 
     T((T_CALLED("wnoutrefresh(%p)"), (void *) win));
 
-    /*
-     * This function will break badly if we try to refresh a pad.
-     */
-    if ((win == 0)
-	|| (win->_flags & _ISPAD))
+    if (win == NULL)
 	returnCode(ERR);
 
+    /*
+     * Handle pads as a special case.
+     */
+    if (IS_PAD(win)) {
+	returnCode(pnoutrefresh(win,
+				win->_pad._pad_y,
+				win->_pad._pad_x,
+				win->_pad._pad_top,
+				win->_pad._pad_left,
+				win->_pad._pad_bottom,
+				win->_pad._pad_right));
+    }
 #ifdef TRACE
     if (USE_TRACEF(TRACE_UPDATE)) {
 	_tracedump("...win", win);
@@ -200,7 +208,6 @@ wnoutrefresh(WINDOW *win)
 	    });
 
 	    if_WIDEC({
-		static cchar_t blank = BLANK;
 		int last_dst = begx + ((last_src < win->_maxx)
 				       ? last_src
 				       : win->_maxx);
@@ -246,6 +253,7 @@ wnoutrefresh(WINDOW *win)
 		 */
 		if (fix_left < dst_col || fix_right > last_dst) {
 		    for (j = fix_left; j <= fix_right; ++j) {
+			static cchar_t blank = BLANK;
 			nline->text[j] = blank;
 			CHANGED_CELL(nline, j);
 		    }
diff --git a/contrib/ncurses/ncurses/base/lib_restart.c b/contrib/ncurses/ncurses/base/lib_restart.c
index 81eb368843b8..0c61cb7ea667 100644
--- a/contrib/ncurses/ncurses/base/lib_restart.c
+++ b/contrib/ncurses/ncurses/base/lib_restart.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
  * Copyright 1998-2012,2015 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -42,7 +42,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_restart.c,v 1.17 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_restart.c,v 1.18 2023/04/29 19:01:25 tom Exp $")
 
 NCURSES_EXPORT(int)
 NCURSES_SP_NAME(restartterm) (NCURSES_SP_DCLx
@@ -65,31 +65,28 @@ NCURSES_SP_NAME(restartterm) (NCURSES_SP_DCLx
     if (TINFO_SETUP_TERM(&new_term, termp, filenum, errret, FALSE) != OK) {
 	result = ERR;
     } else if (SP_PARM != 0) {
-	int saveecho = SP_PARM->_echo;
-	int savecbreak = SP_PARM->_cbreak;
-	int saveraw = SP_PARM->_raw;
-	int savenl = SP_PARM->_nl;
+	TTY_FLAGS save_flags = SP_PARM->_tty_flags;
 
 #ifdef USE_TERM_DRIVER
 	SP_PARM->_term = new_term;
 #endif
-	if (saveecho) {
+	if (save_flags._echo) {
 	    NCURSES_SP_NAME(echo) (NCURSES_SP_ARG);
 	} else {
 	    NCURSES_SP_NAME(noecho) (NCURSES_SP_ARG);
 	}
 
-	if (savecbreak) {
+	if (save_flags._cbreak) {
 	    NCURSES_SP_NAME(cbreak) (NCURSES_SP_ARG);
 	    NCURSES_SP_NAME(noraw) (NCURSES_SP_ARG);
-	} else if (saveraw) {
+	} else if (save_flags._raw) {
 	    NCURSES_SP_NAME(nocbreak) (NCURSES_SP_ARG);
 	    NCURSES_SP_NAME(raw) (NCURSES_SP_ARG);
 	} else {
 	    NCURSES_SP_NAME(nocbreak) (NCURSES_SP_ARG);
 	    NCURSES_SP_NAME(noraw) (NCURSES_SP_ARG);
 	}
-	if (savenl) {
+	if (save_flags._nl) {
 	    NCURSES_SP_NAME(nl) (NCURSES_SP_ARG);
 	} else {
 	    NCURSES_SP_NAME(nonl) (NCURSES_SP_ARG);
diff --git a/contrib/ncurses/ncurses/base/lib_screen.c b/contrib/ncurses/ncurses/base/lib_screen.c
index 6afba6611c61..e2647b54e2eb 100644
--- a/contrib/ncurses/ncurses/base/lib_screen.c
+++ b/contrib/ncurses/ncurses/base/lib_screen.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 2019-2021,2023 Thomas E. Dickey                                *
  * Copyright 1998-2017,2018 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -42,7 +42,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_screen.c,v 1.100 2020/05/25 22:48:41 tom Exp $")
+MODULE_ID("$Id: lib_screen.c,v 1.105 2023/04/28 20:58:54 tom Exp $")
 
 #define MAX_SIZE 0x3fff		/* 16k is big enough for a window or pad */
 
@@ -90,7 +90,6 @@ typedef struct {
 typedef struct {
     const char name[17];
     PARAM_TYPE type;
-    size_t size;
     size_t offset;
 } SCR_PARAMS;
 
@@ -120,8 +119,7 @@ static const SCR_ATTRS scr_attrs[] =
 };
 #undef DATA
 
-#define sizeof2(type,name) sizeof(((type *)0)->name)
-#define DATA(name, type) { { #name }, type, sizeof2(WINDOW, name), offsetof(WINDOW, name) }
+#define DATA(name, type) { { #name }, type, offsetof(WINDOW, name) }
 
 static const SCR_PARAMS scr_params[] =
 {
@@ -200,7 +198,7 @@ read_txt(FILE *fp)
 
 	if (ch == '\n') {
 	    result[--used] = '\0';
-	    T(("READ:%s", result));
+	    TR(TRACE_IEVENT, ("READ:%s", result));
 	} else if (used == 0) {
 	    free(result);
 	    result = 0;
@@ -214,7 +212,7 @@ decode_attr(char *source, attr_t *target, int *color)
 {
     bool found = FALSE;
 
-    T(("decode_attr   '%s'", source));
+    TR(TRACE_IEVENT, ("decode_attr   '%s'", source));
 
     while (*source) {
 	if (source[0] == MARKER && source[1] == L_CURL) {
@@ -272,7 +270,7 @@ decode_char(char *source, int *target)
     int base = 16;
     const char digits[] = "0123456789abcdef";
 
-    T(("decode_char   '%s'", source));
+    TR(TRACE_IEVENT, ("decode_char   '%s'", source));
     *target = ' ';
     switch (*source) {
     case MARKER:
@@ -329,7 +327,7 @@ decode_chtype(char *source, chtype fillin, chtype *target)
     int color = PAIR_NUMBER((int) attr);
     int value;
 
-    T(("decode_chtype '%s'", source));
+    TR(TRACE_IEVENT, ("decode_chtype '%s'", source));
     source = decode_attr(source, &attr, &color);
     source = decode_char(source, &value);
     *target = (ChCharOf(value) | attr | (chtype) COLOR_PAIR(color));
@@ -347,7 +345,7 @@ decode_cchar(char *source, cchar_t *fillin, cchar_t *target)
     int append = 0;
     int value = 0;
 
-    T(("decode_cchar  '%s'", source));
+    TR(TRACE_IEVENT, ("decode_cchar  '%s'", source));
     *target = blank;
 #if NCURSES_EXT_COLORS
     color = fillin->ext_color;
@@ -542,7 +540,7 @@ NCURSES_SP_NAME(getwin) (NCURSES_SP_DCLx FILE *filep)
 	returnWin(0);
     }
 
-    if (tmp._flags & _ISPAD) {
+    if (IS_PAD(&tmp)) {
 	nwin = NCURSES_SP_NAME(newpad) (NCURSES_SP_ARGx
 					tmp._maxy + 1,
 					tmp._maxx + 1);
@@ -587,7 +585,7 @@ NCURSES_SP_NAME(getwin) (NCURSES_SP_DCLx FILE *filep)
 	nwin->_regtop = tmp._regtop;
 	nwin->_regbottom = tmp._regbottom;
 
-	if (tmp._flags & _ISPAD)
+	if (IS_PAD(&tmp))
 	    nwin->_pad = tmp._pad;
 
 	if (old_format) {
@@ -824,7 +822,7 @@ putwin(WINDOW *win, FILE *filep)
 	    attr_t attr;
 
 	    *buffer = '\0';
-	    if (!strncmp(name, "_pad.", (size_t) 5) && !(win->_flags & _ISPAD)) {
+	    if (!strncmp(name, "_pad.", (size_t) 5) && !IS_PAD(win)) {
 		continue;
 	    }
 	    switch (scr_params[y].type) {
@@ -940,6 +938,31 @@ putwin(WINDOW *win, FILE *filep)
     returnCode(code);
 }
 
+/*
+ * Replace a window covering the whole screen, i.e., newscr or curscr.
+ */
+static WINDOW *
+replace_window(WINDOW *target, FILE *source)
+{
+    WINDOW *result = getwin(source);
+#if NCURSES_EXT_FUNCS
+    if (result != NULL) {
+	if (getmaxx(result) != getmaxx(target)
+	    || getmaxy(result) != getmaxy(target)) {
+	    int code = wresize(result,
+			       1 + getmaxy(target),
+			       1 + getmaxx(target));
+	    if (code != OK) {
+		delwin(result);
+		result = NULL;
+	    }
+	}
+    }
+#endif
+    delwin(target);
+    return result;
+}
+
 NCURSES_EXPORT(int)
 NCURSES_SP_NAME(scr_restore) (NCURSES_SP_DCLx const char *file)
 {
@@ -949,9 +972,8 @@ NCURSES_SP_NAME(scr_restore) (NCURSES_SP_DCLx const char *file)
     T((T_CALLED("scr_restore(%p,%s)"), (void *) SP_PARM, _nc_visbuf(file)));
 
     if (_nc_access(file, R_OK) >= 0
-	&& (fp = fopen(file, BIN_R)) != 0) {
-	delwin(NewScreen(SP_PARM));
-	NewScreen(SP_PARM) = getwin(fp);
+	&& (fp = safe_fopen(file, BIN_R)) != 0) {
+	NewScreen(SP_PARM) = replace_window(NewScreen(SP_PARM), fp);
 #if !USE_REENTRANT
 	newscr = NewScreen(SP_PARM);
 #endif
@@ -980,7 +1002,7 @@ scr_dump(const char *file)
     T((T_CALLED("scr_dump(%s)"), _nc_visbuf(file)));
 
     if (_nc_access(file, W_OK) < 0
-	|| (fp = fopen(file, BIN_W)) == 0) {
+	|| (fp = safe_fopen(file, BIN_W)) == 0) {
 	result = ERR;
     } else {
 	(void) putwin(newscr, fp);
@@ -1007,9 +1029,8 @@ NCURSES_SP_NAME(scr_init) (NCURSES_SP_DCLx const char *file)
 	FILE *fp = 0;
 
 	if (_nc_access(file, R_OK) >= 0
-	    && (fp = fopen(file, BIN_R)) != 0) {
-	    delwin(CurScreen(SP_PARM));
-	    CurScreen(SP_PARM) = getwin(fp);
+	    && (fp = safe_fopen(file, BIN_R)) != 0) {
+	    CurScreen(SP_PARM) = replace_window(CurScreen(SP_PARM), fp);
 #if !USE_REENTRANT
 	    curscr = CurScreen(SP_PARM);
 #endif
diff --git a/contrib/ncurses/ncurses/base/lib_set_term.c b/contrib/ncurses/ncurses/base/lib_set_term.c
index 8573fbe7d522..78de859208b6 100644
--- a/contrib/ncurses/ncurses/base/lib_set_term.c
+++ b/contrib/ncurses/ncurses/base/lib_set_term.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2018-2021,2022 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -41,8 +41,11 @@
 **
 */
 
+#define NEW_PAIR_INTERNAL 1
+
 #include <curses.priv.h>
 #include <tic.h>
+#include <new_pair.h>
 
 #if USE_GPM_SUPPORT
 #ifdef HAVE_LIBDL
@@ -54,7 +57,7 @@
 #undef CUR
 #define CUR SP_TERMTYPE
 
-MODULE_ID("$Id: lib_set_term.c,v 1.175 2020/10/10 19:09:03 juergen Exp $")
+MODULE_ID("$Id: lib_set_term.c,v 1.184 2022/12/10 21:34:12 tom Exp $")
 
 #ifdef USE_TERM_DRIVER
 #define MaxColors      InfoOf(sp).maxcolors
@@ -146,9 +149,12 @@ delscreen(SCREEN *sp)
 
     _nc_lock_global(curses);
     if (delink_screen(sp)) {
+	WINDOWLIST *wl;
+	bool is_current = (sp == CURRENT_SCREEN);
+
 #ifdef USE_SP_RIPOFF
-	ripoff_t *rop;
 	if (safe_ripoff_sp && safe_ripoff_sp != safe_ripoff_stack) {
+	    ripoff_t *rop;
 	    for (rop = safe_ripoff_stack;
 		 rop != safe_ripoff_sp && (rop - safe_ripoff_stack) < N_RIPS;
 		 rop++) {
@@ -160,9 +166,13 @@ delscreen(SCREEN *sp)
 	}
 #endif
 
-	(void) _nc_freewin(CurScreen(sp));
-	(void) _nc_freewin(NewScreen(sp));
-	(void) _nc_freewin(StdScreen(sp));
+	/* delete all of the windows in this screen */
+      rescan:
+	for (each_window(sp, wl)) {
+	    if (_nc_freewin(&(wl->win)) == OK) {
+		goto rescan;
+	    }
+	}
 
 	if (sp->_slk != 0) {
 
@@ -187,6 +197,7 @@ delscreen(SCREEN *sp)
 
 	FreeIfNeeded(sp->_current_attr);
 
+	_nc_free_ordered_pairs(sp);
 	FreeIfNeeded(sp->_color_table);
 	FreeIfNeeded(sp->_color_pairs);
 
@@ -219,7 +230,7 @@ delscreen(SCREEN *sp)
 	 * application might try to use (except cur_term, which may have
 	 * multiple references in different screens).
 	 */
-	if (sp == CURRENT_SCREEN) {
+	if (is_current) {
 #if !USE_REENTRANT
 	    curscr = 0;
 	    newscr = 0;
@@ -234,6 +245,8 @@ delscreen(SCREEN *sp)
 		_nc_wacs = 0;
 	    }
 #endif
+	} else {
+	    set_term(CURRENT_SCREEN);
 	}
     }
     _nc_unlock_global(curses);
@@ -329,9 +342,14 @@ NCURSES_SP_NAME(_nc_setupscreen) (
 	T(("_nc_alloc_screen_sp %p", (void *) sp));
 	*spp = sp;
     }
-    if (!sp
-	|| ((sp->_acs_map = typeCalloc(chtype, ACS_LEN)) == 0)
-	|| ((sp->_screen_acs_map = typeCalloc(bool, ACS_LEN)) == 0)) {
+    if (sp == NULL) {
+	ReturnScreenError();
+    }
+    if ((sp->_acs_map = typeCalloc(chtype, ACS_LEN)) == NULL) {
+	ReturnScreenError();
+    }
+    if ((sp->_screen_acs_map = typeCalloc(bool, ACS_LEN)) == NULL) {
+	free(sp->_acs_map);
 	ReturnScreenError();
     }
 
@@ -412,7 +430,6 @@ NCURSES_SP_NAME(_nc_setupscreen) (
     fflush(output);
     _setmode(fileno(output), _O_BINARY);
 #endif
-    NCURSES_SP_NAME(_nc_set_buffer) (NCURSES_SP_ARGx output, TRUE);
     sp->_lines = (NCURSES_SIZE_T) slines;
     sp->_lines_avail = (NCURSES_SIZE_T) slines;
     sp->_columns = (NCURSES_SIZE_T) scolumns;
@@ -495,7 +512,7 @@ NCURSES_SP_NAME(_nc_setupscreen) (
 	p = extract_fgbg(p, &(sp->_default_fg));
 	p = extract_fgbg(p, &(sp->_default_bg));
 	if (*p)			/* assume rxvt was compiled with xpm support */
-	    p = extract_fgbg(p, &(sp->_default_bg));
+	    extract_fgbg(p, &(sp->_default_bg));
 	TR(TRACE_CHARPUT | TRACE_MOVE, ("decoded fg=%d, bg=%d",
 					sp->_default_fg, sp->_default_bg));
 	if (sp->_default_fg >= MaxColors) {
@@ -692,6 +709,9 @@ NCURSES_SP_NAME(_nc_setupscreen) (
 	       formats (4-4 or 3-2-3) for which there may be some hardware
 	       support. */
 	    if (rop->hook == _nc_slk_initialize) {
+		if (!TerminalOf(sp)) {
+		    continue;
+		}
 		if (!(NumLabels <= 0 || !SLK_STDFMT(slk_format))) {
 		    continue;
 		}
@@ -731,6 +751,7 @@ NCURSES_SP_NAME(_nc_setupscreen) (
     }
 
     T(("creating stdscr"));
+    (void) bottom_stolen;
     assert((sp->_lines_avail + sp->_topstolen + bottom_stolen) == slines);
     if ((StdScreen(sp) = NCURSES_SP_NAME(newwin) (NCURSES_SP_ARGx
 						  sp->_lines_avail,
@@ -812,10 +833,13 @@ NCURSES_EXPORT(int)
 _nc_ripoffline(int line, int (*init) (WINDOW *, int))
 {
     int rc;
+
+    _nc_init_pthreads();
     _nc_lock_global(prescreen);
     START_TRACE();
     rc = NCURSES_SP_NAME(_nc_ripoffline) (CURRENT_SCREEN_PRE, line, init);
     _nc_unlock_global(prescreen);
+
     return rc;
 }
 #endif
@@ -836,10 +860,13 @@ NCURSES_EXPORT(int)
 ripoffline(int line, int (*init) (WINDOW *, int))
 {
     int rc;
+
+    _nc_init_pthreads();
     _nc_lock_global(prescreen);
     START_TRACE();
     rc = NCURSES_SP_NAME(ripoffline) (CURRENT_SCREEN_PRE, line, init);
     _nc_unlock_global(prescreen);
+
     return rc;
 }
 #endif
diff --git a/contrib/ncurses/ncurses/base/lib_slk.c b/contrib/ncurses/ncurses/base/lib_slk.c
index f4b3ce6dbf0a..47e57e0bc5bd 100644
--- a/contrib/ncurses/ncurses/base/lib_slk.c
+++ b/contrib/ncurses/ncurses/base/lib_slk.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2022 Thomas E. Dickey                                     *
  * Copyright 1998-2010,2011 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -48,7 +48,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_slk.c,v 1.49 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_slk.c,v 1.50 2022/08/20 18:29:22 tom Exp $")
 
 #ifdef USE_TERM_DRIVER
 #define NumLabels    InfoOf(SP_PARM).numlabels
@@ -187,8 +187,10 @@ _nc_slk_initialize(WINDOW *stwin, int cols)
 	|| SP_PARM->_slk->labcnt <= 0
 	|| (SP_PARM->_slk->ent = typeCalloc(slk_ent,
 					    (size_t) SP_PARM->_slk->labcnt))
-	== NULL)
+	== NULL) {
+	free(SP_PARM->_slk->ent);
 	returnCode(slk_failed(NCURSES_SP_ARG));
+    }
 
     max_length = (size_t) SP_PARM->_slk->maxlen;
     for (i = 0; i < SP_PARM->_slk->labcnt; i++) {
diff --git a/contrib/ncurses/ncurses/base/lib_slkinit.c b/contrib/ncurses/ncurses/base/lib_slkinit.c
index e1602abc9f18..318077fc96c1 100644
--- a/contrib/ncurses/ncurses/base/lib_slkinit.c
+++ b/contrib/ncurses/ncurses/base/lib_slkinit.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2022 Thomas E. Dickey                                     *
  * Copyright 1998-2009,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -41,7 +41,7 @@
  */
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_slkinit.c,v 1.15 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_slkinit.c,v 1.16 2022/07/09 18:58:58 tom Exp $")
 
 #ifdef USE_SP_RIPOFF
 #define SoftkeyFormat SP_PARM->slk_format
@@ -77,10 +77,13 @@ NCURSES_EXPORT(int)
 slk_init(int format)
 {
     int rc;
+
+    _nc_init_pthreads();
     _nc_lock_global(prescreen);
     START_TRACE();
     rc = NCURSES_SP_NAME(slk_init) (CURRENT_SCREEN_PRE, format);
     _nc_unlock_global(prescreen);
+
     return rc;
 }
 #endif
diff --git a/contrib/ncurses/ncurses/base/lib_slkrefr.c b/contrib/ncurses/ncurses/base/lib_slkrefr.c
index c6bf9d2e06f6..7a40624b1276 100644
--- a/contrib/ncurses/ncurses/base/lib_slkrefr.c
+++ b/contrib/ncurses/ncurses/base/lib_slkrefr.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2013,2014 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -44,7 +44,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_slkrefr.c,v 1.31 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_slkrefr.c,v 1.32 2021/09/04 10:54:35 tom Exp $")
 
 #ifdef USE_TERM_DRIVER
 #define NumLabels    InfoOf(SP_PARM).numlabels
@@ -113,7 +113,7 @@ slk_intern_refresh(SCREEN *sp)
 		    wmove(slk->win, SLK_LINES(fmt) - 1, slk->ent[i].ent_x);
 		    (void) wattrset(slk->win, (int) AttrOf(slk->attr));
 		    waddstr(slk->win, slk->ent[i].form_text);
-		    /* if we simulate SLK's, it's looking much more
+		    /* if we simulate SLK's, it is looking much more
 		       natural to use the current ATTRIBUTE also
 		       for the label window */
 		    (void) wattrset(slk->win, (int) WINDOW_ATTRS(StdScreen(sp)));
diff --git a/contrib/ncurses/ncurses/base/lib_wattron.c b/contrib/ncurses/ncurses/base/lib_wattron.c
index c589f10473cb..906021d3b4cf 100644
--- a/contrib/ncurses/ncurses/base/lib_wattron.c
+++ b/contrib/ncurses/ncurses/base/lib_wattron.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2022 Thomas E. Dickey                                     *
  * Copyright 1998-2009,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -43,7 +43,7 @@
 #include <curses.priv.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_wattron.c,v 1.12 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_wattron.c,v 1.13 2022/04/15 22:34:38 tom Exp $")
 
 NCURSES_EXPORT(int)
 wattr_on(WINDOW *win, attr_t at, void *opts GCC_UNUSED)
@@ -55,8 +55,10 @@ wattr_on(WINDOW *win, attr_t at, void *opts GCC_UNUSED)
 	   GET_WINDOW_PAIR(win)));
 
 	if_EXT_COLORS({
-	    if (at & A_COLOR)
+	    if (at & A_COLOR) {
 		win->_color = PairNumber(at);
+		set_extended_pair(opts, win->_color);
+	    }
 	});
 	toggle_attr_on(WINDOW_ATTRS(win), at);
 	returnCode(OK);
diff --git a/contrib/ncurses/ncurses/base/lib_window.c b/contrib/ncurses/ncurses/base/lib_window.c
index 7222bfe5c656..5323fbf0348e 100644
--- a/contrib/ncurses/ncurses/base/lib_window.c
+++ b/contrib/ncurses/ncurses/base/lib_window.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2010,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -40,7 +40,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_window.c,v 1.31 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_window.c,v 1.32 2021/10/23 23:06:24 tom Exp $")
 
 NCURSES_EXPORT(void)
 _nc_synchook(WINDOW *win)
@@ -130,7 +130,7 @@ wsyncdown(WINDOW *win)
 {
     T((T_CALLED("wsyncdown(%p)"), (void *) win));
 
-    if (win && win->_parent) {
+    if (win != NULL && win->_parent != NULL) {
 	WINDOW *pp = win->_parent;
 	int y;
 
@@ -187,7 +187,7 @@ dupwin(WINDOW *win)
 	SCREEN *sp = _nc_screen_of(win);
 #endif
 	_nc_lock_global(curses);
-	if (win->_flags & _ISPAD) {
+	if (IS_PAD(win)) {
 	    nwin = NCURSES_SP_NAME(newpad) (NCURSES_SP_ARGx
 					    win->_maxy + 1,
 					    win->_maxx + 1);
@@ -238,7 +238,7 @@ dupwin(WINDOW *win)
 	    nwin->_regtop = win->_regtop;
 	    nwin->_regbottom = win->_regbottom;
 
-	    if (win->_flags & _ISPAD)
+	    if (IS_PAD(win))
 		nwin->_pad = win->_pad;
 
 	    linesize = (unsigned) (win->_maxx + 1) * sizeof(NCURSES_CH_T);
diff --git a/contrib/ncurses/ncurses/base/new_pair.c b/contrib/ncurses/ncurses/base/new_pair.c
index c04f4acbb95d..70866c636812 100644
--- a/contrib/ncurses/ncurses/base/new_pair.c
+++ b/contrib/ncurses/ncurses/base/new_pair.c
@@ -61,7 +61,7 @@
 
 #endif
 
-MODULE_ID("$Id: new_pair.c,v 1.21 2021/02/14 00:17:09 tom Exp $")
+MODULE_ID("$Id: new_pair.c,v 1.23 2021/08/16 22:11:26 tom Exp $")
 
 #if NCURSES_EXT_COLORS
 
@@ -106,7 +106,7 @@ dumpit(SCREEN *sp, int pair, const char *tag)
     size_t have = sizeof(bigbuf);
 
     _nc_STRCPY(p, tag, have);
-    for (n = 0; n < sp->_pair_limit; ++n) {
+    for (n = 0; n < sp->_pair_alloc; ++n) {
 	if (list[n].mode != cpFREE) {
 	    p += strlen(p);
 	    if ((size_t) (p - bigbuf) + 50 > have)
@@ -297,7 +297,7 @@ NCURSES_SP_NAME(alloc_pair) (NCURSES_SP_DCLx int fg, int bg)
 		    found = TRUE;
 		}
 	    }
-	    if (!found) {
+	    if (!found && SP_PARM->_color_pairs != NULL) {
 		for (pair = 1; pair <= hint; pair++) {
 		    if (SP_PARM->_color_pairs[pair].mode == cpFREE) {
 			T(("found gap %d", pair));
diff --git a/contrib/ncurses/ncurses/base/resizeterm.c b/contrib/ncurses/ncurses/base/resizeterm.c
index 9b04287cb56f..1a2ddb365a58 100644
--- a/contrib/ncurses/ncurses/base/resizeterm.c
+++ b/contrib/ncurses/ncurses/base/resizeterm.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020-2021,2024 Thomas E. Dickey                                *
  * Copyright 1998-2015,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -46,7 +46,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: resizeterm.c,v 1.50 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: resizeterm.c,v 1.53 2024/04/20 21:54:14 tom Exp $")
 
 /*
  * If we're trying to be reentrant, do not want any local statics.
@@ -210,7 +210,7 @@ parent_depth(WINDOW *cmp)
 }
 
 /*
- * FIXME: must adjust position so it's within the parent!
+ * FIXME: must adjust position so it is within the parent!
  */
 static int
 adjust_window(WINDOW *win, int ToLines, int ToCols, int stolen EXTRA_DCLS)
@@ -293,7 +293,7 @@ decrease_size(NCURSES_SP_DCLx int ToLines, int ToCols, int stolen EXTRA_DCLS)
 	for (each_window(SP_PARM, wp)) {
 	    WINDOW *win = &(wp->win);
 
-	    if (!(win->_flags & _ISPAD)) {
+	    if (!IS_PAD(win)) {
 		if (child_depth(win) == depth) {
 		    found = TRUE;
 		    if (adjust_window(win, ToLines, ToCols,
@@ -328,7 +328,7 @@ increase_size(NCURSES_SP_DCLx int ToLines, int ToCols, int stolen EXTRA_DCLS)
 	for (each_window(SP_PARM, wp)) {
 	    WINDOW *win = &(wp->win);
 
-	    if (!(win->_flags & _ISPAD)) {
+	    if (!IS_PAD(win)) {
 		if (parent_depth(win) == depth) {
 		    found = TRUE;
 		    if (adjust_window(win, ToLines, ToCols,
@@ -409,8 +409,8 @@ NCURSES_SP_NAME(resize_term) (NCURSES_SP_DCLx int ToLines, int ToCols)
 #ifdef USE_TERM_DRIVER
 	    CallDriver_2(SP_PARM, td_setsize, ToLines, ToCols);
 #else
-	    lines = (NCURSES_SIZE_T) ToLines;
-	    columns = (NCURSES_SIZE_T) ToCols;
+	    lines = (NCURSES_INT2) ToLines;
+	    columns = (NCURSES_INT2) ToCols;
 #endif
 
 	    SP_PARM->_lines_avail = (NCURSES_SIZE_T) (ToLines - was_stolen);
diff --git a/contrib/ncurses/ncurses/base/safe_sprintf.c b/contrib/ncurses/ncurses/base/safe_sprintf.c
index 1868c009660c..8816e58c2ca8 100644
--- a/contrib/ncurses/ncurses/base/safe_sprintf.c
+++ b/contrib/ncurses/ncurses/base/safe_sprintf.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2018-2021,2023 Thomas E. Dickey                                *
  * Copyright 1998-2012,2013 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -34,7 +34,7 @@
 #include <curses.priv.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: safe_sprintf.c,v 1.33 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: safe_sprintf.c,v 1.37 2023/09/30 10:42:42 tom Exp $")
 
 #if USE_SAFE_SPRINTF
 
@@ -223,9 +223,9 @@ NCURSES_SP_NAME(_nc_printf_string) (NCURSES_SP_DCLx
 				    const char *fmt,
 				    va_list ap)
 {
-    char *result = 0;
+    char *result = NULL;
 
-    if (SP_PARM != 0 && fmt != 0) {
+    if (SP_PARM != NULL && fmt != NULL) {
 #if USE_SAFE_SPRINTF
 	va_list ap2;
 	int len;
@@ -238,7 +238,7 @@ NCURSES_SP_NAME(_nc_printf_string) (NCURSES_SP_DCLx
 	    my_length = (size_t) (2 * (len + 1));
 	    my_buffer = typeRealloc(char, my_length, my_buffer);
 	}
-	if (my_buffer != 0) {
+	if (my_buffer != NULL) {
 	    *my_buffer = '\0';
 	    if (len >= 0) {
 		vsprintf(my_buffer, fmt, ap);
@@ -255,21 +255,37 @@ NCURSES_SP_NAME(_nc_printf_string) (NCURSES_SP_DCLx
 	    if (screen_columns(SP_PARM) > MyCols)
 		MyCols = screen_columns(SP_PARM);
 	    my_length = (size_t) (MyRows * (MyCols + 1)) + 1;
+	    if (my_length < 80)
+		my_length = 80;
 	    my_buffer = typeRealloc(char, my_length, my_buffer);
 	}
 
-	if (my_buffer != 0) {
+	if (my_buffer != NULL) {
 # if HAVE_VSNPRINTF
-	    vsnprintf(my_buffer, my_length, fmt, ap);	/* SUSv2, 1997 */
+	    /* SUSv2, 1997 */
+	    int used;
+
+	    do {
+		va_list ap2;
+
+		begin_va_copy(ap2, ap);
+		used = vsnprintf(my_buffer, my_length, fmt, ap2);
+		end_va_copy(ap2);
+		if (used < (int) my_length)
+		    break;
+		my_length = (size_t) ((3 * used) / 2);
+		my_buffer = typeRealloc(char, my_length, my_buffer);
+	    } while (my_buffer != NULL);
 # else
-	    vsprintf(my_buffer, fmt, ap);	/* ISO/ANSI C, 1989 */
+	    /* ISO/ANSI C, 1989 */
+	    vsprintf(my_buffer, fmt, ap);
 # endif
 	    result = my_buffer;
 	}
 #endif
-    } else if (my_buffer != 0) {	/* see _nc_freeall() */
+    } else if (my_buffer != NULL) {	/* see _nc_freeall() */
 	free(my_buffer);
-	my_buffer = 0;
+	my_buffer = NULL;
 	my_length = 0;
     }
     return result;
diff --git a/contrib/ncurses/ncurses/base/tries.c b/contrib/ncurses/ncurses/base/tries.c
index 0f309c213c45..0f8c0516e88f 100644
--- a/contrib/ncurses/ncurses/base/tries.c
+++ b/contrib/ncurses/ncurses/base/tries.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
  * Copyright 1998-2009,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -39,8 +39,9 @@
 */
 
 #include <curses.priv.h>
+#include <tic.h>
 
-MODULE_ID("$Id: tries.c,v 1.31 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: tries.c,v 1.32 2023/06/24 15:36:23 tom Exp $")
 
 /*
  * Expand a keycode into the string that it corresponds to, returning null if
@@ -124,7 +125,7 @@ _nc_remove_string(TRIES ** tree, const char *string)
 {
     T((T_CALLED("_nc_remove_string(%p,%s)"), (void *) tree, _nc_visbuf(string)));
 
-    if (string == 0 || *string == 0)
+    if (!VALID_STRING(string) || *string == 0)
 	returnCode(FALSE);
 
     while (*tree != 0) {
diff --git a/contrib/ncurses/ncurses/base/vsscanf.c b/contrib/ncurses/ncurses/base/vsscanf.c
index ef524250c36f..40ee8bb1d876 100644
--- a/contrib/ncurses/ncurses/base/vsscanf.c
+++ b/contrib/ncurses/ncurses/base/vsscanf.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
  * Copyright 1998-2004,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -39,15 +39,12 @@
 
 #if !HAVE_VSSCANF
 
-MODULE_ID("$Id: vsscanf.c,v 1.21 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: vsscanf.c,v 1.22 2023/09/23 18:48:57 tom Exp $")
 
 #if !(HAVE_VFSCANF || HAVE__DOSCAN)
 
 #include <ctype.h>
 
-#define L_SQUARE '['
-#define R_SQUARE ']'
-
 typedef enum {
     cUnknown
     ,cError			/* anything that isn't ANSI */
@@ -243,7 +240,7 @@ vsscanf(const char *str, const char *format, va_list ap)
 		    case sPercent:
 			if (format[n] == '%') {
 			    state = sUnknown;
-			} else if (format[n] == L_SQUARE) {
+			} else if (format[n] == L_BLOCK) {
 			    state = sLeft;
 			} else {
 			    state = sNormal;
@@ -258,7 +255,7 @@ vsscanf(const char *str, const char *format, va_list ap)
 			}
 			break;
 		    case sRange:
-			if (format[n] == R_SQUARE) {
+			if (format[n] == R_BLOCK) {
 			    state = sFinal;
 			    chunk = cRange;
 			}
diff --git a/contrib/ncurses/ncurses/base/wresize.c b/contrib/ncurses/ncurses/base/wresize.c
index 30718b8878fd..6d5589e2794e 100644
--- a/contrib/ncurses/ncurses/base/wresize.c
+++ b/contrib/ncurses/ncurses/base/wresize.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 2019-2021,2023 Thomas E. Dickey                                *
  * Copyright 1998-2010,2011 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -34,7 +34,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: wresize.c,v 1.41 2020/04/18 21:01:00 tom Exp $")
+MODULE_ID("$Id: wresize.c,v 1.43 2023/10/21 11:13:03 tom Exp $")
 
 static int
 cleanup_lines(struct ldat *data, int length)
@@ -55,7 +55,7 @@ repair_subwindows(WINDOW *cmp)
     WINDOWLIST *wp;
     struct ldat *pline = cmp->_line;
     int row;
-#ifdef USE_SP_WINDOWLIST
+#if NCURSES_SP_FUNCS && defined(USE_SP_WINDOWLIST)
     SCREEN *sp = _nc_screen_of(cmp);
 #endif
 
@@ -135,7 +135,7 @@ wresize(WINDOW *win, int ToLines, int ToCols)
 	&& ToCols == size_x)
 	returnCode(OK);
 
-    if ((win->_flags & _SUBWIN)) {
+    if (IS_SUBWIN(win)) {
 	/*
 	 * Check if the new limits will fit into the parent window's size.  If
 	 * not, do not resize.  We could adjust the location of the subwindow,
@@ -169,7 +169,7 @@ wresize(WINDOW *win, int ToLines, int ToCols)
 	int end = ToCols;
 	NCURSES_CH_T *s;
 
-	if (!(win->_flags & _SUBWIN)) {
+	if (!IS_SUBWIN(win)) {
 	    if (row <= size_y) {
 		if (ToCols != size_x) {
 		    s = typeMalloc(NCURSES_CH_T, (unsigned) ToCols + 1);
diff --git a/contrib/ncurses/ncurses/curses.priv.h b/contrib/ncurses/ncurses/curses.priv.h
index 4243373f9a7a..68cda17e71a3 100644
--- a/contrib/ncurses/ncurses/curses.priv.h
+++ b/contrib/ncurses/ncurses/curses.priv.h
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2023,2024 Thomas E. Dickey                                *
  * Copyright 1998-2017,2018 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -35,7 +35,7 @@
  ****************************************************************************/
 
 /*
- * $Id: curses.priv.h,v 1.639 2020/11/14 23:37:54 tom Exp $
+ * $Id: curses.priv.h,v 1.687 2024/04/23 22:28:25 tom Exp $
  *
  *	curses.priv.h
  *
@@ -72,12 +72,6 @@ extern "C" {
 #include <unistd.h>
 #endif
 
-#if HAVE_LIMITS_H
-# include <limits.h>
-#elif HAVE_SYS_PARAM_H
-# include <sys/param.h>
-#endif
-
 #include <assert.h>
 #include <stdio.h>
 
@@ -89,16 +83,6 @@ extern "C" {
 #  endif
 #endif
 
-#ifndef PATH_MAX
-# if defined(_POSIX_PATH_MAX)
-#  define PATH_MAX _POSIX_PATH_MAX
-# elif defined(MAXPATHLEN)
-#  define PATH_MAX MAXPATHLEN
-# else
-#  define PATH_MAX 255	/* the Posix minimum path-size */
-# endif
-#endif
-
 #if DECL_ERRNO
 extern int errno;
 #endif
@@ -141,6 +125,20 @@ extern int errno;
 # endif
 #endif
 
+#if (defined(__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO != 0) && (defined(__GNUC__) && (__GNUC__ < 12))
+# undef PRIxPTR		/* gcc bug fixed in 12.x */
+# define PRIxPTR	"lX"
+# define CASTxPTR(n)    (unsigned long)(intptr_t)(void*)(n)
+#else
+# define CASTxPTR(n)    (intptr_t)(n)
+#endif
+
+#ifndef PRIxPTR
+# define PRIxPTR	"lx"
+# undef CASTxPTR
+# define CASTxPTR(n)    (long)(void*)(n)
+#endif
+
 /* include signal.h before curses.h to work-around defect in glibc 2.1.3 */
 #include <signal.h>
 
@@ -207,14 +205,21 @@ extern int errno;
 #endif
 
 /*
- * If desired, one can configure this, disabling environment variables that
- * point to custom terminfo/termcap locations.
+ * When the standard handles have been redirected (such as inside a text editor
+ * or the less utility), keystrokes must be read from the console rather than
+ * the redirected handle.  The standard output handle suffers from a similar
+ * problem.  Both handles are not closed once opened.  The console shall be
+ * considered reachable throughout the process.
  */
-#ifdef USE_ROOT_ENVIRON
-#define use_terminfo_vars() 1
-#else
-#define use_terminfo_vars() _nc_env_access()
-extern NCURSES_EXPORT(int) _nc_env_access (void);
+#if defined(_NC_WINDOWS)
+#define GetDirectHandle(fileName, shareMode) \
+	CreateFile(TEXT(fileName), \
+		   GENERIC_READ | GENERIC_WRITE, \
+		   shareMode, \
+		   0, \
+		   OPEN_EXISTING, \
+		   0, \
+		   0)
 #endif
 
 /*
@@ -292,7 +297,6 @@ extern NCURSES_EXPORT(void *) _nc_memmove (void *, const void *, size_t);
 #define NO_TERMINAL "unknown"
 #define USE_SP_RIPOFF     1
 #define USE_SP_TERMTYPE   1
-#define USE_SP_WINDOWLIST 1
 #else
 #define NO_TERMINAL 0
 #endif
@@ -303,6 +307,12 @@ extern NCURSES_EXPORT(void *) _nc_memmove (void *, const void *, size_t);
 		     : no_terminal), \
 	 NonEmpty(term_env))
 
+/*
+ * Originally a terminal-driver option, the window-list is per-screen to allow
+ * freeing memory used for windows when a screen is deleted.
+ */
+#define USE_SP_WINDOWLIST 1
+
 /*
  * Note:  ht/cbt expansion flakes out randomly under Linux 1.1.47, but only
  * when we're throwing control codes at the screen at high volume.  To see
@@ -325,6 +335,11 @@ typedef TRIES {
  */
 #define StringOf(ch) {ch, 0}
 
+#define CSI_CHR 0x9b
+#define ESC_CHR 0x1b
+
+#define L_BLOCK '['
+#define R_BLOCK ']'
 #define L_BRACE '{'
 #define R_BRACE '}'
 #define S_QUOTE '\''
@@ -407,7 +422,7 @@ typedef union {
 
 #include <nc_panel.h>
 
-#include <term.h>
+#include <term.priv.h>
 #include <nc_termios.h>
 
 #define IsPreScreen(sp)      (((sp) != 0) && sp->_prescreen)
@@ -554,10 +569,10 @@ extern NCURSES_EXPORT(void)     _nc_set_no_padding(SCREEN *);
 #define SET_SCREEN_PAIR(s,p)	SetPair(SCREEN_ATTRS(s), p)
 
 #if USE_REENTRANT || NCURSES_SP_FUNCS
-NCURSES_EXPORT(int *)        _nc_ptr_Lines (SCREEN *);
-NCURSES_EXPORT(int *)        _nc_ptr_Cols (SCREEN *);
-NCURSES_EXPORT(int *)        _nc_ptr_Tabsize (SCREEN *);
-NCURSES_EXPORT(int *)        _nc_ptr_Escdelay (SCREEN *);
+extern NCURSES_EXPORT(int *)    _nc_ptr_Lines (SCREEN *);
+extern NCURSES_EXPORT(int *)    _nc_ptr_Cols (SCREEN *);
+extern NCURSES_EXPORT(int *)    _nc_ptr_Tabsize (SCREEN *);
+extern NCURSES_EXPORT(int *)    _nc_ptr_Escdelay (SCREEN *);
 #endif
 
 #if USE_REENTRANT
@@ -586,6 +601,10 @@ NCURSES_EXPORT(int *)        _nc_ptr_Escdelay (SCREEN *);
 
 #endif
 
+#define IS_SUBWIN(w)         ((w)->_flags & _SUBWIN)
+#define IS_PAD(w)            ((w)->_flags & _ISPAD)
+#define IS_WRAPPED(w)        ((w)->_flags & _WRAPPED)
+
 #define HasHardTabs()	(NonEmpty(clear_all_tabs) && NonEmpty(set_tab))
 
 #define TR_MUTEX(data) _tracef("%s@%d: me:%08lX COUNT:%2u/%2d/%6d/%2d/%s%9u: " #data, \
@@ -679,9 +698,14 @@ extern NCURSES_EXPORT(int) _nc_sigprocmask(int, const sigset_t *, sigset_t *);
 #define _nc_lock_global(name)	/* nothing */
 #define _nc_try_global(name)    0
 #define _nc_unlock_global(name)	/* nothing */
-
 #endif /* USE_PTHREADS */
 
+#if USE_PTHREADS_EINTR
+extern NCURSES_EXPORT(void) _nc_set_read_thread(bool);
+#else
+#define _nc_set_read_thread(enable)	/* nothing */
+#endif
+
 /*
  * When using sp-funcs, locks are targeted to SCREEN-level granularity.
  * So the locking is done in the non-sp-func (which calls the sp-func) rather
@@ -712,9 +736,18 @@ extern NCURSES_EXPORT(int) _nc_sigprocmask(int, const sigset_t *, sigset_t *);
 
 #endif
 
-#if HAVE_GETTIMEOFDAY
+#if HAVE_CLOCK_GETTIME
 # define PRECISE_GETTIME 1
+# define GetClockTime(t) clock_gettime(CLOCK_REALTIME, t)
+# define TimeType struct timespec
+# define TimeScale 1000000000L		/* 1e9 */
+# define sub_secs tv_nsec
+#elif HAVE_GETTIMEOFDAY
+# define PRECISE_GETTIME 1
+# define GetClockTime(t) gettimeofday(t, 0)
 # define TimeType struct timeval
+# define TimeScale 1000000L		/* 1e6 */
+# define sub_secs tv_usec
 #else
 # define PRECISE_GETTIME 0
 # define TimeType time_t
@@ -810,12 +843,6 @@ typedef struct _SLK {
 
 #endif	/* USE_TERMLIB */
 
-typedef	struct {
-	WINDOW *win;		/* the window used in the hook      */
-	int	line;		/* lines to take, < 0 => from bottom*/
-	int	(*hook)(WINDOW *, int); /* callback for user	    */
-} ripoff_t;
-
 #if USE_GPM_SUPPORT
 #undef buttons			/* term.h defines this, and gpm uses it! */
 #include <gpm.h>
@@ -843,15 +870,11 @@ typedef int (*TYPE_Gpm_GetEvent) (Gpm_Event *);
 #endif /* HAVE_LIBDL */
 #endif /* USE_GPM_SUPPORT */
 
-typedef struct {
-    long sequence;
-    bool last_used;
-    char *fix_sgr0;		/* this holds the filtered sgr0 string */
-    char *last_bufp;		/* help with fix_sgr0 leak */
-    TERMINAL *last_term;
-} TGETENT_CACHE;
-
-#define TGETENT_MAX 4
+/*
+ * Limit delay-times to 30 seconds, which is consistent with signed 16-bit
+ * numbers in legacy terminfo.
+ */
+#define MAX_DELAY_MSECS 30000
 
 /*
  * When converting from terminfo to termcap, check for cases where we can trim
@@ -863,46 +886,6 @@ typedef struct {
 
 #define isoctal(c) ((c) >= '0' && (c) <= '7')
 
-/*
- * State of tparm().
- */
-#define STACKSIZE 20
-
-typedef struct {
-	union {
-		int	num;
-		char	*str;
-	} data;
-	bool num_type;
-} STACK_FRAME;
-
-#define NUM_VARS 26
-
-typedef struct {
-	const char	*tparam_base;
-
-	STACK_FRAME	stack[STACKSIZE];
-	int		stack_ptr;
-
-	char		*out_buff;
-	size_t		out_size;
-	size_t		out_used;
-
-	char		*fmt_buff;
-	size_t		fmt_size;
-
-	int		dynamic_var[NUM_VARS];
-	int		static_vars[NUM_VARS];
-#ifdef TRACE
-	const char	*tname;
-#endif
-} TPARM_STATE;
-
-typedef struct {
-    char *text;
-    size_t size;
-} TRACEBUF;
-
 /*
  * The filesystem database normally uses a single-letter for the lower level
  * of directories.  Use a hexadecimal code for filesystems which do not
@@ -923,6 +906,7 @@ typedef struct {
  * string is less than 80 columns, but this buffer size is an absolute
  * limit.
  */
+#define TRACECHR_BUF	40
 #define TRACEMSE_MAX	(80 + (5 * 10) + (32 * 15))
 #define TRACEMSE_FMT	"id %2d  at (%2d, %2d, %2d) state %4lx = {" /* } */
 
@@ -933,132 +917,8 @@ struct DriverTCB; /* Terminal Control Block forward declaration */
 #define INIT_TERM_DRIVER()	/* nothing */
 #endif
 
-typedef struct {
-    const char *name;
-    char *value;
-} ITERATOR_VARS;
-
-/*
- * Global data which is not specific to a screen.
- */
-typedef struct {
-	SIG_ATOMIC_T	have_sigtstp;
-	SIG_ATOMIC_T	have_sigwinch;
-	SIG_ATOMIC_T	cleanup_nested;
-
-	bool		init_signals;
-	bool		init_screen;
-
-	char		*comp_sourcename;
-	char		*comp_termtype;
-
-	bool		have_tic_directory;
-	bool		keep_tic_directory;
-	const char	*tic_directory;
-
-	char		*dbi_list;
-	int		dbi_size;
-
-	char		*first_name;
-	char		**keyname_table;
-	int		init_keyname;
-
-	int		slk_format;
-
-	int		getstr_limit;	/* getstr_limit based on POSIX LINE_MAX */
-
-	char		*safeprint_buf;
-	size_t		safeprint_used;
-
-	TGETENT_CACHE	tgetent_cache[TGETENT_MAX];
-	int		tgetent_index;
-	long		tgetent_sequence;
-
-	char		*dbd_blob;	/* string-heap for dbd_list[] */
-	char		**dbd_list;	/* distinct places to look for data */
-	int		dbd_size;	/* length of dbd_list[] */
-	time_t		dbd_time;	/* cache last updated */
-	ITERATOR_VARS	dbd_vars[dbdLAST];
-
-#if HAVE_TSEARCH
-	void		*cached_tparm;
-	int		count_tparm;
-#endif /* HAVE_TSEARCH */
-
-#ifdef USE_TERM_DRIVER
-	int		(*term_driver)(struct DriverTCB*, const char*, int*);
-#endif
-
-#ifndef USE_SP_WINDOWLIST
-	WINDOWLIST	*_nc_windowlist;
-#define WindowList(sp)	_nc_globals._nc_windowlist
-#endif
-
-#if USE_HOME_TERMINFO
-	char		*home_terminfo;
-#endif
-
-#if !USE_SAFE_SPRINTF
-	int		safeprint_cols;
-	int		safeprint_rows;
-#endif
-
-#ifdef USE_PTHREADS
-	pthread_mutex_t	mutex_curses;
-	pthread_mutex_t	mutex_prescreen;
-	pthread_mutex_t	mutex_screen;
-	pthread_mutex_t	mutex_update;
-	pthread_mutex_t	mutex_tst_tracef;
-	pthread_mutex_t	mutex_tracef;
-	int		nested_tracef;
-	int		use_pthreads;
-#define _nc_use_pthreads	_nc_globals.use_pthreads
-#if USE_PTHREADS_EINTR
-	pthread_t	read_thread;		/* The reading thread */
-#endif
-#endif
-#if USE_WIDEC_SUPPORT
-	char		key_name[MB_LEN_MAX + 1];
-#endif
-
-#ifdef TRACE
-	bool		trace_opened;
-	char		trace_fname[PATH_MAX];
-	int		trace_level;
-	FILE		*trace_fp;
-	int		trace_fd;
-
-	char		*tracearg_buf;
-	size_t		tracearg_used;
-
-	TRACEBUF	*tracebuf_ptr;
-	size_t		tracebuf_used;
-
-	char		tracechr_buf[40];
-
-	char		*tracedmp_buf;
-	size_t		tracedmp_used;
-
-	unsigned char	*tracetry_buf;
-	size_t		tracetry_used;
-
-	char		traceatr_color_buf[2][80];
-	int		traceatr_color_sel;
-	int		traceatr_color_last;
-#if !defined(USE_PTHREADS) && USE_REENTRANT
-	int		nested_tracef;
-#endif
-#endif	/* TRACE */
-
-#if NO_LEAKS
-	bool		leak_checking;
-#endif
-} NCURSES_GLOBALS;
-
 extern NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals;
 
-#define N_RIPS 5
-
 /* The limit reserves one byte for a terminating NUL */
 #define my_getstr_limit	(_nc_globals.getstr_limit - 1)
 #define _nc_getstr_limit(n) \
@@ -1068,54 +928,6 @@ extern NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals;
 	    ? my_getstr_limit \
 	    : (n)))
 
-#ifdef USE_PTHREADS
-typedef struct _prescreen_list {
-	struct _prescreen_list *next;
-	pthread_t id;
-	struct screen *sp;
-} PRESCREEN_LIST;
-#endif
-
-/*
- * Global data which can be swept up into a SCREEN when one is created.
- * It may be modified before the next SCREEN is created.
- */
-typedef struct {
-#ifdef USE_PTHREADS
-	PRESCREEN_LIST *allocated;
-#else
-	struct screen * allocated;
-#endif
-	bool		use_env;
-	bool		filter_mode;
-	attr_t		previous_attr;
-	TPARM_STATE	tparm_state;
-	TTY		*saved_tty;	/* savetty/resetty information	    */
-	bool		use_tioctl;
-	NCURSES_SP_OUTC	_outch;		/* output handler if not putc */
-#ifndef USE_SP_RIPOFF
-	ripoff_t	rippedoff[N_RIPS];
-	ripoff_t	*rsp;
-#endif
-#if NCURSES_NO_PADDING
-	bool		_no_padding;	/* flag to set if padding disabled  */
-#endif
-#if BROKEN_LINKER || USE_REENTRANT
-	chtype		*real_acs_map;
-	int		_LINES;
-	int		_COLS;
-	int		_TABSIZE;
-	int		_ESCDELAY;
-	TERMINAL	*_cur_term;
-#endif
-#ifdef TRACE
-#if BROKEN_LINKER || USE_REENTRANT
-	long		_outchars;
-	const char	*_tputs_trace;
-#endif
-#endif
-} NCURSES_PRESCREEN;
-
 /*
  * Use screen-specific ripoff data (for softkeys) rather than global.
  */
@@ -1130,16 +942,29 @@ typedef struct {
 extern NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen;
 
 typedef enum {
-    ewInitial = 0,
+    ewUnknown = 0,
+    ewInitial,
     ewRunning,
     ewSuspend
 } ENDWIN;
 
+typedef struct {
+	int		_nl;		/* True if NL -> CR/NL is on	    */
+	int		_raw;		/* True if in raw mode		    */
+	int		_cbreak;	/* 1 if in cbreak mode		    */
+					/* > 1 if in halfdelay mode	    */
+	int		_echo;		/* True if echo on		    */
+} TTY_FLAGS;
+
+#define IsNl(sp)        (sp)->_tty_flags._nl
+#define IsRaw(sp)       (sp)->_tty_flags._raw
+#define IsCbreak(sp)    (sp)->_tty_flags._cbreak
+#define IsEcho(sp)      (sp)->_tty_flags._echo
+
 /*
  * The SCREEN structure.
  */
-
-struct screen {
+typedef struct screen {
 	int		_ifd;		/* input file descriptor for screen */
 	int		_ofd;		/* output file descriptor for screen */
 	FILE		*_ofp;		/* output file ptr for screen	    */
@@ -1186,11 +1011,7 @@ struct screen {
 	int		_cursrow;	/* physical cursor row		    */
 	int		_curscol;	/* physical cursor column	    */
 	bool		_notty;		/* true if we cannot switch non-tty */
-	int		_nl;		/* True if NL -> CR/NL is on	    */
-	int		_raw;		/* True if in raw mode		    */
-	int		_cbreak;	/* 1 if in cbreak mode		    */
-					/* > 1 if in halfdelay mode	    */
-	int		_echo;		/* True if echo on		    */
+	TTY_FLAGS	_tty_flags;
 	int		_use_meta;	/* use the meta key?		    */
 	struct _SLK	*_slk;		/* ptr to soft key struct / NULL    */
 	int		slk_format;	/* selected format for this screen  */
@@ -1416,14 +1237,15 @@ struct screen {
 #endif
 
 #ifdef TRACE
-	char		tracechr_buf[40];
+	char		tracechr_buf[TRACECHR_BUF];
 	char		tracemse_buf[TRACEMSE_MAX];
 #if USE_REENTRANT
 	long		_outchars;
 	const char	*_tputs_trace;
 #endif
 #endif
-};
+#undef SCREEN
+} SCREEN;
 
 extern NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain;
 extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
@@ -1449,18 +1271,18 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
 #endif
 
 #define SP_PRE_INIT(sp)                         \
-    sp->_cursrow = -1;                          \
-    sp->_curscol = -1;                          \
-    sp->_nl = TRUE;                             \
-    sp->_raw = FALSE;                           \
-    sp->_cbreak = 0;                            \
-    sp->_echo = TRUE;                           \
-    sp->_fifohead = -1;                         \
-    sp->_endwin = ewSuspend;                    \
-    sp->_cursor = -1;                           \
+    sp->_cursrow           = -1;                \
+    sp->_curscol           = -1;                \
+    IsNl(sp)               = TRUE;              \
+    IsRaw(sp)              = FALSE;             \
+    IsCbreak(sp)           = 0;                 \
+    IsEcho(sp)             = TRUE;              \
+    sp->_fifohead          = -1;                \
+    sp->_endwin            = ewSuspend;         \
+    sp->_cursor            = -1;                \
     SP_INIT_WINDOWLIST(sp);                     \
-    sp->_outch = NCURSES_OUTC_FUNC;             \
-    sp->jump = 0                                \
+    sp->_outch             = NCURSES_OUTC_FUNC; \
+    sp->jump               = 0                  \
 
 /* usually in <limits.h> */
 #ifndef UCHAR_MAX
@@ -1473,12 +1295,12 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
 /* Checks for isprint() should be done on 8-bit characters (non-wide) */
 #define is8bits(c)	((unsigned)(c) <= UCHAR_MAX)
 
-#ifndef min
-#define min(a,b)	((a) > (b)  ?  (b)  :  (a))
+#ifndef Min
+#define Min(a,b)	((a) > (b)  ?  (b)  :  (a))
 #endif
 
-#ifndef max
-#define max(a,b)	((a) < (b)  ?  (b)  :  (a))
+#ifndef Max
+#define Max(a,b)	((a) < (b)  ?  (b)  :  (a))
 #endif
 
 /* usually in <unistd.h> */
@@ -1542,14 +1364,11 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
 
 #define TR_PUTC(c)	TR(TRACE_CHARPUT, ("PUTC %#x", UChar(c)))
 
-#ifndef MB_LEN_MAX
-#define MB_LEN_MAX 8 /* should be >= MB_CUR_MAX, but that may be a function */
-#endif
-
 #if USE_WIDEC_SUPPORT /* { */
+/* true if the status/errno indicate an illegal multibyte sequence */
 #define isEILSEQ(status) (((size_t)status == (size_t)-1) && (errno == EILSEQ))
 
-#define init_mb(state)	memset(&state, 0, sizeof(state))
+#define init_mb(state)	memset(&(state), 0, sizeof(state))
 
 #if NCURSES_EXT_COLORS
 #define NulColor	, 0
@@ -1557,7 +1376,20 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
 #define NulColor	/* nothing */
 #endif
 
-#define NulChar		0,0,0,0	/* FIXME: see CCHARW_MAX */
+#if CCHARW_MAX > 6
+#define NulChar		0,0,0,0,0
+#elif CCHARW_MAX > 5
+#define NulChar		0,0,0,0		/* ncurses7 */
+#elif CCHARW_MAX > 4
+#define NulChar		0,0,0		/* ncurses6 */
+#elif CCHARW_MAX > 3
+#define NulChar		0,0
+#elif CCHARW_MAX > 2
+#define NulChar		0
+#else
+#define NulChar		/* nothing */
+#endif
+
 #define CharOf(c)	((c).chars[0])
 #define AttrOf(c)	((c).attr)
 
@@ -1568,29 +1400,25 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
 #define NewChar2(c,a)	{ a, { c, NulChar } NulColor }
 #define NewChar(ch)	NewChar2(ChCharOf(ch), ChAttrOf(ch))
 
-#if CCHARW_MAX == 5
+#if CCHARW_MAX > 1
 #define CharEq(a,b)	(((a).attr == (b).attr) \
-		       && (a).chars[0] == (b).chars[0] \
-		       && (a).chars[1] == (b).chars[1] \
-		       && (a).chars[2] == (b).chars[2] \
-		       && (a).chars[3] == (b).chars[3] \
-		       && (a).chars[4] == (b).chars[4] \
+			 && !memcmp((a).chars, \
+				    (b).chars, \
+				    CCHARW_MAX * sizeof((b).chars[0])) \
 			if_EXT_COLORS(&& (a).ext_color == (b).ext_color))
-#elif CCHARW_MAX > 0
-#error Inconsistent values for CCHARW_MAX
 #else
 #define CharEq(a,b)	(!memcmp(&(a), &(b), sizeof(a)))
 #endif
 
 #define SetChar(ch,c,a) do {							    \
-			    NCURSES_CH_T *_cp = &ch;				    \
+			    NCURSES_CH_T *_cp = &(ch);				    \
 			    memset(_cp, 0, sizeof(ch));				    \
 			    _cp->chars[0] = (wchar_t) (c);			    \
 			    _cp->attr = (a);					    \
 			    if_EXT_COLORS(SetPair(ch, PairNumber(a)));		    \
 			} while (0)
-#define CHREF(wch)	(&wch)
-#define CHDEREF(wch)	(*wch)
+#define CHREF(wch)	(&(wch))
+#define CHDEREF(wch)	(*(wch))
 #define ARG_CH_T	NCURSES_CH_T *
 #define CARG_CH_T	const NCURSES_CH_T *
 #define PUTC_DATA	char PUTC_buf[MB_LEN_MAX]; int PUTC_i, PUTC_n; \
@@ -1678,7 +1506,7 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
 #define isWidecExt(ch)	(0)
 #define if_WIDEC(code) /* nothing */
 
-#define Charable(ch)	((ch) >= ' ' && (ch) <= '~')
+#define Charable(ch)	(CharOf(ch) >= ' ' && CharOf(ch) <= '~')
 #define L(ch)		ch
 #endif /* } */
 
@@ -1720,6 +1548,9 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
 
 #define SIZEOF(v) (sizeof(v)/sizeof(v[0]))
 
+#include <nc_alloc.h>
+#include <nc_access.h>
+
 #define FreeIfNeeded(p)  if ((p) != 0) free(p)
 
 /* FreeAndNull() is not a comma-separated expression because some compilers
@@ -1727,7 +1558,18 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
  */
 #define FreeAndNull(p)   do { free(p); p = 0; } while (0)
 
-#include <nc_alloc.h>
+#ifdef EXP_OOM_TESTING
+extern NCURSES_EXPORT(void *)	_nc_oom_malloc(size_t size);
+extern NCURSES_EXPORT(void *)	_nc_oom_calloc(size_t nmemb, size_t size);
+extern NCURSES_EXPORT(void *)	_nc_oom_realloc(void *ptr, size_t size);
+extern NCURSES_EXPORT(void)	_nc_oom_free(void *ptr);
+extern NCURSES_EXPORT(char *)	_nc_oom_strdup(const char *ptr);
+#define malloc(size)		_nc_oom_malloc(size)
+#define calloc(nmemb, size)	_nc_oom_calloc(nmemb, size)
+#define realloc(ptr, size)	_nc_oom_realloc(ptr, size)
+#define free(ptr)		_nc_oom_free(ptr)
+#define strdup(ptr)		_nc_oom_strdup(ptr)
+#endif
 
 /*
  * Use these for tic/infocmp malloc failures.  Generally the ncurses library
@@ -1740,6 +1582,13 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
 		_nc_err_abort(MSG_NO_MEMORY); \
 	} while (0)
 
+#define TYPE_CALLOC(type, size, name) \
+	do { \
+	    name = typeCalloc(type, size); \
+	    if (name == 0) \
+		_nc_err_abort(MSG_NO_MEMORY); \
+	} while (0)
+
 #define TYPE_REALLOC(type, size, name) \
 	do { \
 	    name = typeRealloc(type, size, name); \
@@ -1848,11 +1697,13 @@ typedef void VoidFunc(void);
 #define returnMMask(code)	TRACE_RETURN_SP(code,mmask_t)
 #define returnPtr(code)		TRACE_RETURN1(code,ptr)
 #define returnSP(code)		TRACE_RETURN1(code,sp)
-#define returnVoid		T((T_RETURN(""))); return
+#define returnVoid		{ T((T_RETURN(""))); return; }
 #define returnVoidPtr(code)	TRACE_RETURN1(code,void_ptr)
 #define returnWin(code)		TRACE_RETURN1(code,win)
 
 #define returnDB(rc)		do { TR(TRACE_DATABASE,(T_RETURN("code %d"), (rc))); return (rc); } while (0)
+#define returnPtrDB(rc)		do { TR(TRACE_DATABASE,(T_RETURN("%p"), (rc))); return (rc); } while (0)
+#define returnVoidDB		do { TR(TRACE_DATABASE,(T_RETURN(""))); return; } while (0)
 
 extern NCURSES_EXPORT(NCURSES_BOOL)     _nc_retrace_bool (int);
 extern NCURSES_EXPORT(NCURSES_CONST void *) _nc_retrace_cvoid_ptr (NCURSES_CONST void *);
@@ -1927,6 +1778,8 @@ extern NCURSES_EXPORT(const char *) _nc_viscbuf (const NCURSES_CH_T *, int);
 #define returnWin(code)		return code
 
 #define returnDB(code)		return code
+#define returnPtrDB(rc)		return rc
+#define returnVoidDB		return
 
 #endif /* TRACE/!TRACE */
 
@@ -2132,11 +1985,11 @@ extern NCURSES_EXPORT(void) _nc_linedump (void);
 
 /* lib_acs.c */
 extern NCURSES_EXPORT(void) _nc_init_acs (void); /* corresponds to traditional 'init_acs()' */
-extern NCURSES_EXPORT(int)  _nc_msec_cost (const char *const, int);  /* used by 'tack' program */
+extern NCURSES_EXPORT(int)  _nc_msec_cost (const char *const, int);
 
 /* lib_addch.c */
 #if USE_WIDEC_SUPPORT
-NCURSES_EXPORT(int) _nc_build_wch(WINDOW *win, ARG_CH_T ch);
+extern NCURSES_EXPORT(int) _nc_build_wch(WINDOW *win, ARG_CH_T ch);
 #endif
 
 /* lib_addstr.c */
@@ -2249,7 +2102,7 @@ typedef struct {
 /* strings.c */
 extern NCURSES_EXPORT(string_desc *) _nc_str_init (string_desc *, char *, size_t);
 extern NCURSES_EXPORT(string_desc *) _nc_str_null (string_desc *, size_t);
-extern NCURSES_EXPORT(string_desc *) _nc_str_copy (string_desc *, string_desc *);
+extern NCURSES_EXPORT(string_desc *) _nc_str_copy (string_desc *, const string_desc *);
 extern NCURSES_EXPORT(bool) _nc_safe_strcat (string_desc *, const char *);
 extern NCURSES_EXPORT(bool) _nc_safe_strcpy (string_desc *, const char *);
 
@@ -2278,7 +2131,6 @@ extern NCURSES_EXPORT(char *) _nc_tracemouse (SCREEN *, MEVENT const *);
 extern NCURSES_EXPORT(char *) _nc_trace_mmask_t (SCREEN *, mmask_t);
 extern NCURSES_EXPORT(int) _nc_access (const char *, int);
 extern NCURSES_EXPORT(int) _nc_baudrate (int);
-extern NCURSES_EXPORT(ENTRY *) _nc_delink_entry (ENTRY *, TERMTYPE2 *);
 extern NCURSES_EXPORT(int) _nc_freewin (WINDOW *);
 extern NCURSES_EXPORT(int) _nc_getenv_num (const char *);
 extern NCURSES_EXPORT(int) _nc_keypad (SCREEN *, int);
@@ -2291,6 +2143,7 @@ extern NCURSES_EXPORT(int) _nc_read_termcap_entry (const char *const, TERMTYPE2
 extern NCURSES_EXPORT(int) _nc_setup_tinfo(const char *, TERMTYPE2 *);
 extern NCURSES_EXPORT(int) _nc_setupscreen (int, int, FILE *, int, int);
 extern NCURSES_EXPORT(int) _nc_timed_wait (SCREEN *, int, int, int * EVENTLIST_2nd(_nc_eventlist *));
+extern NCURSES_EXPORT(int) _nc_trans_string (char *, const char *);
 extern NCURSES_EXPORT(void) _nc_init_termtype (TERMTYPE2 *const);
 extern NCURSES_EXPORT(void) _nc_do_color (int, int, int, NCURSES_OUTC);
 extern NCURSES_EXPORT(void) _nc_flush (void);
@@ -2300,6 +2153,7 @@ extern NCURSES_EXPORT(void) _nc_hash_map (void);
 extern NCURSES_EXPORT(void) _nc_init_keytry (SCREEN *);
 extern NCURSES_EXPORT(void) _nc_keep_tic_dir (const char *);
 extern NCURSES_EXPORT(void) _nc_make_oldhash (int i);
+extern NCURSES_EXPORT(void) _nc_reset_input (FILE *, char *);
 extern NCURSES_EXPORT(void) _nc_scroll_oldhash (int n, int top, int bot);
 extern NCURSES_EXPORT(void) _nc_scroll_optimize (void);
 extern NCURSES_EXPORT(void) _nc_set_buffer (FILE *, int);
@@ -2314,6 +2168,8 @@ extern NCURSES_EXPORT(const TERMTYPE2 *) _nc_fallback2 (const char *);
 #define _nc_fallback2(tp) _nc_fallback(tp)
 #endif
 
+extern NCURSES_EXPORT(void) _nc_copy_termtype(TERMTYPE *, const TERMTYPE *);
+
 #if NCURSES_EXT_NUMBERS
 extern NCURSES_EXPORT(void) _nc_copy_termtype2 (TERMTYPE2 *, const TERMTYPE2 *);
 extern NCURSES_EXPORT(void) _nc_export_termtype2(TERMTYPE *, const TERMTYPE2 *);
@@ -2336,7 +2192,7 @@ extern NCURSES_EXPORT(void) _nc_comp_userdefs_leaks(void);
 extern NCURSES_EXPORT(void) _nc_db_iterator_leaks(void);
 extern NCURSES_EXPORT(void) _nc_keyname_leaks(void);
 extern NCURSES_EXPORT(void) _nc_names_leaks(void);
-extern NCURSES_EXPORT(void) _nc_tgetent_leak(TERMINAL *);
+extern NCURSES_EXPORT(void) _nc_tgetent_leak(const TERMINAL *);
 extern NCURSES_EXPORT(void) _nc_tgetent_leaks(void);
 #endif
 
@@ -2392,17 +2248,23 @@ extern int __MINGW_NOTHROW _nc_mblen(const char *, size_t);
 
 #endif /* _NC_WINDOWS && !_NC_MSC */
 
+#if defined(_NC_WINDOWS) || defined(_NC_MINGW)
+/* see wcwidth.c */
+extern NCURSES_EXPORT(int) mk_wcwidth(wchar_t);
+#define wcwidth(ucs) _nc_wcwidth(ucs)
+#endif
+
 #if HAVE_MBTOWC && HAVE_MBLEN
 #define reset_mbytes(state) IGNORE_RC(mblen(NULL, (size_t) 0)), IGNORE_RC(mbtowc(NULL, NULL, (size_t) 0))
 #define count_mbytes(buffer,length,state) mblen(buffer,length)
 #define check_mbytes(wch,buffer,length,state) \
-	(int) mbtowc(&wch, buffer, length)
+	(int) mbtowc(&(wch), buffer, length)
 #define state_unused
 #elif HAVE_MBRTOWC && HAVE_MBRLEN
 #define reset_mbytes(state) init_mb(state)
-#define count_mbytes(buffer,length,state) mbrlen(buffer,length,&state)
+#define count_mbytes(buffer,length,state) mbrlen(buffer,length,&(state))
 #define check_mbytes(wch,buffer,length,state) \
-	(int) mbrtowc(&wch, buffer, length, &state)
+	(int) mbrtowc(&(wch), buffer, length, &(state))
 #else
 make an error
 #endif
@@ -2451,7 +2313,7 @@ extern NCURSES_EXPORT_VAR(SCREEN *) SP;
 
 /*
  * We don't want to use the lines or columns capabilities internally, because
- * if the application is running multiple screens under X, it's quite possible
+ * if the application is running multiple screens under X, it is quite possible
  * they could all have type xterm but have different sizes!  So...
  */
 #define screen_lines(sp)        (sp)->_lines
@@ -2669,13 +2531,21 @@ extern NCURSES_EXPORT_VAR(TERM_DRIVER) _nc_TINFO_DRIVER;
 #define NC_ISATTY(fd) isatty(fd)
 #endif
 
+/*
+ * Perhaps not "real" but possibly not "fake".
+ */
+#define IsRealTty(fd,value) \
+	(NC_ISATTY(fd) \
+	 && (value = ttyname(fd)) != NULL \
+	 && strncmp(value, "/dev/pts/", 9))
+
 #ifdef USE_TERM_DRIVER
 #  define IsTermInfo(sp)       ((TCBOf(sp) != 0) && ((TCBOf(sp)->drv->isTerminfo)))
 #  define HasTInfoTerminal(sp) ((0 != TerminalOf(sp)) && IsTermInfo(sp))
 #  if defined(EXP_WIN32_DRIVER)
-#    define IsTermInfoOnConsole(sp) (IsTermInfo(sp)&&_nc_console_test(TerminalOf(sp)->Filedes))
+#    define IsTermInfoOnConsole(sp) (IsTermInfo(sp) && _nc_console_test(TerminalOf(sp)->Filedes))
 #  elif defined(USE_WIN32CON_DRIVER)
-#    define IsTermInfoOnConsole(sp) (IsTermInfo(sp)&&_nc_mingw_isconsole(TerminalOf(sp)->Filedes))
+#    define IsTermInfoOnConsole(sp) (IsTermInfo(sp) && _nc_mingw_isconsole(TerminalOf(sp)->Filedes))
 #  else
 #    define IsTermInfoOnConsole(sp) FALSE
 #  endif
@@ -2734,7 +2604,7 @@ extern NCURSES_EXPORT(int)      NCURSES_SP_NAME(_nc_tgetent)(SCREEN*,char*,const
 extern NCURSES_EXPORT(void)     NCURSES_SP_NAME(_nc_do_color)(SCREEN*, int, int, int, NCURSES_SP_OUTC);
 extern NCURSES_EXPORT(void)     NCURSES_SP_NAME(_nc_do_xmc_glitch)(SCREEN*, attr_t);
 extern NCURSES_EXPORT(void)     NCURSES_SP_NAME(_nc_flush)(SCREEN*);
-extern NCURSES_EXPORT(void)     NCURSES_SP_NAME(_nc_free_and_exit)(SCREEN*, int) GCC_NORETURN;
+extern GCC_NORETURN NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_free_and_exit)(SCREEN*, int);
 extern NCURSES_EXPORT(void)     NCURSES_SP_NAME(_nc_freeall)(SCREEN*);
 extern NCURSES_EXPORT(void)     NCURSES_SP_NAME(_nc_hash_map)(SCREEN*);
 extern NCURSES_EXPORT(void)     NCURSES_SP_NAME(_nc_init_acs)(SCREEN*);
@@ -2780,8 +2650,8 @@ extern NCURSES_EXPORT(NCURSES_CONST char *) _nc_unctrl (SCREEN *, chtype);
 #endif
 
 #ifdef EXP_XTERM_1005
-NCURSES_EXPORT(int) _nc_conv_to_utf8(unsigned char *, unsigned, unsigned);
-NCURSES_EXPORT(int) _nc_conv_to_utf32(unsigned *, const char *, unsigned);
+extern NCURSES_EXPORT(int) _nc_conv_to_utf8(unsigned char *, unsigned, unsigned);
+extern NCURSES_EXPORT(int) _nc_conv_to_utf32(unsigned *, const char *, unsigned);
 #endif
 
 #ifdef __cplusplus
diff --git a/contrib/ncurses/ncurses/llib-lncurses b/contrib/ncurses/ncurses/llib-lncurses
index 3033100792bf..5069c22221a1 100644
--- a/contrib/ncurses/ncurses/llib-lncurses
+++ b/contrib/ncurses/ncurses/llib-lncurses
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 2019-2022,2023 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -70,7 +70,7 @@ void	_nc_hash_map(void)
 
 #undef _nc_make_oldhash_sp
 void	_nc_make_oldhash_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	i)
 		{ /* void */ }
 
@@ -81,16 +81,16 @@ void	_nc_make_oldhash(
 
 #undef _nc_scroll_oldhash_sp
 void	_nc_scroll_oldhash_sp(
-		SCREEN	*sp, 
-		int	n, 
-		int	top, 
+		SCREEN	*sp,
+		int	n,
+		int	top,
 		int	bot)
 		{ /* void */ }
 
 #undef _nc_scroll_oldhash
 void	_nc_scroll_oldhash(
-		int	n, 
-		int	top, 
+		int	n,
+		int	top,
 		int	bot)
 		{ /* void */ }
 
@@ -98,25 +98,25 @@ void	_nc_scroll_oldhash(
 
 #undef _nc_render
 chtype	_nc_render(
-		WINDOW	*win, 
+		WINDOW	*win,
 		chtype	ch)
 		{ return(*(chtype *)0); }
 
 #undef _nc_waddch_nosync
 int	_nc_waddch_nosync(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const chtype c)
 		{ return(*(int *)0); }
 
 #undef waddch
 int	waddch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const chtype ch)
 		{ return(*(int *)0); }
 
 #undef wechochar
 int	wechochar(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const chtype ch)
 		{ return(*(int *)0); }
 
@@ -124,15 +124,15 @@ int	wechochar(
 
 #undef waddnstr
 int	waddnstr(
-		WINDOW	*win, 
-		const char *astr, 
+		WINDOW	*win,
+		const char *astr,
 		int	n)
 		{ return(*(int *)0); }
 
 #undef waddchnstr
 int	waddchnstr(
-		WINDOW	*win, 
-		const chtype *astr, 
+		WINDOW	*win,
+		const chtype *astr,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -151,13 +151,13 @@ int	beep(void)
 
 #undef wbkgdset
 void	wbkgdset(
-		WINDOW	*win, 
+		WINDOW	*win,
 		chtype	ch)
 		{ /* void */ }
 
 #undef wbkgd
 int	wbkgd(
-		WINDOW	*win, 
+		WINDOW	*win,
 		chtype	ch)
 		{ return(*(int *)0); }
 
@@ -165,14 +165,14 @@ int	wbkgd(
 
 #undef wborder
 int	wborder(
-		WINDOW	*win, 
-		chtype	ls, 
-		chtype	rs, 
-		chtype	ts, 
-		chtype	bs, 
-		chtype	tl, 
-		chtype	tr, 
-		chtype	bl, 
+		WINDOW	*win,
+		chtype	ls,
+		chtype	rs,
+		chtype	ts,
+		chtype	bs,
+		chtype	tl,
+		chtype	tr,
+		chtype	bl,
 		chtype	br)
 		{ return(*(int *)0); }
 
@@ -180,10 +180,10 @@ int	wborder(
 
 #undef wchgat
 int	wchgat(
-		WINDOW	*win, 
-		int	n, 
-		attr_t	attr, 
-		short	pair_arg, 
+		WINDOW	*win,
+		int	n,
+		attr_t	attr,
+		short	pair_arg,
 		const void *opts)
 		{ return(*(int *)0); }
 
@@ -198,7 +198,7 @@ int	wclear(
 
 #undef clearok
 int	clearok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
@@ -243,62 +243,62 @@ int	start_color(void)
 
 #undef _nc_change_pair
 void	_nc_change_pair(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	pair)
 		{ /* void */ }
 
 #undef _nc_reserve_pairs
 void	_nc_reserve_pairs(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	want)
 		{ /* void */ }
 
 #undef _nc_init_pair
 int	_nc_init_pair(
-		SCREEN	*sp, 
-		int	pair, 
-		int	f, 
+		SCREEN	*sp,
+		int	pair,
+		int	f,
 		int	b)
 		{ return(*(int *)0); }
 
 #undef init_pair_sp
 int	init_pair_sp(
-		SCREEN	*sp, 
-		short	pair, 
-		short	f, 
+		SCREEN	*sp,
+		short	pair,
+		short	f,
 		short	b)
 		{ return(*(int *)0); }
 
 #undef init_pair
 int	init_pair(
-		short	pair, 
-		short	f, 
+		short	pair,
+		short	f,
 		short	b)
 		{ return(*(int *)0); }
 
 #undef _nc_init_color
 int	_nc_init_color(
-		SCREEN	*sp, 
-		int	color, 
-		int	r, 
-		int	g, 
+		SCREEN	*sp,
+		int	color,
+		int	r,
+		int	g,
 		int	b)
 		{ return(*(int *)0); }
 
 #undef init_color_sp
 int	init_color_sp(
-		SCREEN	*sp, 
-		short	color, 
-		short	r, 
-		short	g, 
+		SCREEN	*sp,
+		short	color,
+		short	r,
+		short	g,
 		short	b)
 		{ return(*(int *)0); }
 
 #undef init_color
 int	init_color(
-		short	color, 
-		short	r, 
-		short	g, 
+		short	color,
+		short	r,
+		short	g,
 		short	b)
 		{ return(*(int *)0); }
 
@@ -322,58 +322,58 @@ NCURSES_BOOL has_colors(void)
 
 #undef color_content_sp
 int	color_content_sp(
-		SCREEN	*sp, 
-		short	color, 
-		short	*r, 
-		short	*g, 
+		SCREEN	*sp,
+		short	color,
+		short	*r,
+		short	*g,
 		short	*b)
 		{ return(*(int *)0); }
 
 #undef color_content
 int	color_content(
-		short	color, 
-		short	*r, 
-		short	*g, 
+		short	color,
+		short	*r,
+		short	*g,
 		short	*b)
 		{ return(*(int *)0); }
 
 #undef _nc_pair_content
 int	_nc_pair_content(
-		SCREEN	*sp, 
-		int	pair, 
-		int	*f, 
+		SCREEN	*sp,
+		int	pair,
+		int	*f,
 		int	*b)
 		{ return(*(int *)0); }
 
 #undef pair_content_sp
 int	pair_content_sp(
-		SCREEN	*sp, 
-		short	pair, 
-		short	*f, 
+		SCREEN	*sp,
+		short	pair,
+		short	*f,
 		short	*b)
 		{ return(*(int *)0); }
 
 #undef pair_content
 int	pair_content(
-		short	pair, 
-		short	*f, 
+		short	pair,
+		short	*f,
 		short	*b)
 		{ return(*(int *)0); }
 
 #undef _nc_do_color_sp
 void	_nc_do_color_sp(
-		SCREEN	*sp, 
-		int	old_pair, 
-		int	pair, 
-		int	reverse, 
+		SCREEN	*sp,
+		int	old_pair,
+		int	pair,
+		int	reverse,
 		NCURSES_OUTC_sp outc)
 		{ /* void */ }
 
 #undef _nc_do_color
 void	_nc_do_color(
-		int	old_pair, 
-		int	pair, 
-		int	reverse, 
+		int	old_pair,
+		int	pair,
+		int	reverse,
 		NCURSES_OUTC outc)
 		{ /* void */ }
 
@@ -381,8 +381,8 @@ void	_nc_do_color(
 
 #undef wcolor_set
 int	wcolor_set(
-		WINDOW	*win, 
-		short	pair_arg, 
+		WINDOW	*win,
+		short	pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -458,7 +458,7 @@ int	addch(
 
 #undef addchnstr
 int	addchnstr(
-		const chtype *a1, 
+		const chtype *a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -469,7 +469,7 @@ int	addchstr(
 
 #undef addnstr
 int	addnstr(
-		const char *a1, 
+		const char *a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -480,42 +480,42 @@ int	addstr(
 
 #undef attroff
 int	attroff(
-		int	z)
+		NCURSES_ATTR_T	z)
 		{ return(*(int *)0); }
 
 #undef attron
 int	attron(
-		int	z)
+		NCURSES_ATTR_T	z)
 		{ return(*(int *)0); }
 
 #undef attrset
 int	attrset(
-		int	z)
+		NCURSES_ATTR_T	z)
 		{ return(*(int *)0); }
 
 #undef attr_get
 int	attr_get(
-		attr_t	*a1, 
-		short	*a2, 
+		attr_t	*a1,
+		short	*a2,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef attr_off
 int	attr_off(
-		attr_t	a1, 
+		attr_t	a1,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef attr_on
 int	attr_on(
-		attr_t	a1, 
+		attr_t	a1,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef attr_set
 int	attr_set(
-		attr_t	a1, 
-		short	a2, 
+		attr_t	a1,
+		short	a2,
 		void	*z)
 		{ return(*(int *)0); }
 
@@ -531,28 +531,28 @@ void	bkgdset(
 
 #undef border
 int	border(
-		chtype	a1, 
-		chtype	a2, 
-		chtype	a3, 
-		chtype	a4, 
-		chtype	a5, 
-		chtype	a6, 
-		chtype	a7, 
+		chtype	a1,
+		chtype	a2,
+		chtype	a3,
+		chtype	a4,
+		chtype	a5,
+		chtype	a6,
+		chtype	a7,
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef box
 int	box(
-		WINDOW	*a1, 
-		chtype	a2, 
+		WINDOW	*a1,
+		chtype	a2,
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef chgat
 int	chgat(
-		int	a1, 
-		attr_t	a2, 
-		short	a3, 
+		int	a1,
+		attr_t	a2,
+		short	a3,
 		const void *z)
 		{ return(*(int *)0); }
 
@@ -570,7 +570,7 @@ int	clrtoeol(void)
 
 #undef color_set
 int	color_set(
-		short	a1, 
+		short	a1,
 		void	*z)
 		{ return(*(int *)0); }
 
@@ -607,7 +607,7 @@ int	getch(void)
 
 #undef getnstr
 int	getnstr(
-		char	*a1, 
+		char	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -618,7 +618,7 @@ int	getstr(
 
 #undef hline
 int	hline(
-		chtype	a1, 
+		chtype	a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -628,7 +628,7 @@ chtype	inch(void)
 
 #undef inchnstr
 int	inchnstr(
-		chtype	*a1, 
+		chtype	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -639,7 +639,7 @@ int	inchstr(
 
 #undef innstr
 int	innstr(
-		char	*a1, 
+		char	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -659,7 +659,7 @@ int	insertln(void)
 
 #undef insnstr
 int	insnstr(
-		const char *a1, 
+		const char *a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -675,323 +675,323 @@ int	instr(
 
 #undef move
 int	move(
-		int	a1, 
+		int	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddch
 int	mvaddch(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		const chtype z)
 		{ return(*(int *)0); }
 
 #undef mvaddchnstr
 int	mvaddchnstr(
-		int	a1, 
-		int	a2, 
-		const chtype *a3, 
+		int	a1,
+		int	a2,
+		const chtype *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddchstr
 int	mvaddchstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		const chtype *z)
 		{ return(*(int *)0); }
 
 #undef mvaddnstr
 int	mvaddnstr(
-		int	a1, 
-		int	a2, 
-		const char *a3, 
+		int	a1,
+		int	a2,
+		const char *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddstr
 int	mvaddstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvchgat
 int	mvchgat(
-		int	a1, 
-		int	a2, 
-		int	a3, 
-		attr_t	a4, 
-		short	a5, 
+		int	a1,
+		int	a2,
+		int	a3,
+		attr_t	a4,
+		short	a5,
 		const void *z)
 		{ return(*(int *)0); }
 
 #undef mvdelch
 int	mvdelch(
-		int	a1, 
+		int	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvgetch
 int	mvgetch(
-		int	a1, 
+		int	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvgetnstr
 int	mvgetnstr(
-		int	a1, 
-		int	a2, 
-		char	*a3, 
+		int	a1,
+		int	a2,
+		char	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvgetstr
 int	mvgetstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvhline
 int	mvhline(
-		int	a1, 
-		int	a2, 
-		chtype	a3, 
+		int	a1,
+		int	a2,
+		chtype	a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinch
 chtype	mvinch(
-		int	a1, 
+		int	a1,
 		int	z)
 		{ return(*(chtype *)0); }
 
 #undef mvinchnstr
 int	mvinchnstr(
-		int	a1, 
-		int	a2, 
-		chtype	*a3, 
+		int	a1,
+		int	a2,
+		chtype	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinchstr
 int	mvinchstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		chtype	*z)
 		{ return(*(int *)0); }
 
 #undef mvinnstr
 int	mvinnstr(
-		int	a1, 
-		int	a2, 
-		char	*a3, 
+		int	a1,
+		int	a2,
+		char	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinsch
 int	mvinsch(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef mvinsnstr
 int	mvinsnstr(
-		int	a1, 
-		int	a2, 
-		const char *a3, 
+		int	a1,
+		int	a2,
+		const char *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinsstr
 int	mvinsstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvinstr
 int	mvinstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvvline
 int	mvvline(
-		int	a1, 
-		int	a2, 
-		chtype	a3, 
+		int	a1,
+		int	a2,
+		chtype	a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddch
 int	mvwaddch(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const chtype z)
 		{ return(*(int *)0); }
 
 #undef mvwaddchnstr
 int	mvwaddchnstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const chtype *a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const chtype *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddchstr
 int	mvwaddchstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const chtype *z)
 		{ return(*(int *)0); }
 
 #undef mvwaddnstr
 int	mvwaddnstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const char *a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const char *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddstr
 int	mvwaddstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvwchgat
 int	mvwchgat(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		int	a4, 
-		attr_t	a5, 
-		short	a6, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		int	a4,
+		attr_t	a5,
+		short	a6,
 		const void *z)
 		{ return(*(int *)0); }
 
 #undef mvwdelch
 int	mvwdelch(
-		WINDOW	*a1, 
-		int	a2, 
+		WINDOW	*a1,
+		int	a2,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwgetch
 int	mvwgetch(
-		WINDOW	*a1, 
-		int	a2, 
+		WINDOW	*a1,
+		int	a2,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwgetnstr
 int	mvwgetnstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		char	*a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		char	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwgetstr
 int	mvwgetstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvwhline
 int	mvwhline(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		chtype	a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		chtype	a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinch
 chtype	mvwinch(
-		WINDOW	*a1, 
-		int	a2, 
+		WINDOW	*a1,
+		int	a2,
 		int	z)
 		{ return(*(chtype *)0); }
 
 #undef mvwinchnstr
 int	mvwinchnstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		chtype	*a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		chtype	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinchstr
 int	mvwinchstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		chtype	*z)
 		{ return(*(int *)0); }
 
 #undef mvwinnstr
 int	mvwinnstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		char	*a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		char	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinsch
 int	mvwinsch(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef mvwinsnstr
 int	mvwinsnstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const char *a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const char *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinsstr
 int	mvwinsstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvwinstr
 int	mvwinstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvwvline
 int	mvwvline(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		chtype	a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		chtype	a4,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -1021,7 +1021,7 @@ int	scroll(
 
 #undef setscrreg
 int	setscrreg(
-		int	a1, 
+		int	a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -1040,8 +1040,8 @@ void	timeout(
 
 #undef touchline
 int	touchline(
-		WINDOW	*a1, 
-		int	a2, 
+		WINDOW	*a1,
+		int	a2,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -1057,53 +1057,53 @@ int	untouchwin(
 
 #undef vline
 int	vline(
-		chtype	a1, 
+		chtype	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef waddchstr
 int	waddchstr(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		const chtype *z)
 		{ return(*(int *)0); }
 
 #undef waddstr
 int	waddstr(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef wattron
 int	wattron(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wattroff
 int	wattroff(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wattrset
 int	wattrset(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wattr_get
 int	wattr_get(
-		WINDOW	*a1, 
-		attr_t	*a2, 
-		short	*a3, 
+		WINDOW	*a1,
+		attr_t	*a2,
+		short	*a3,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef wattr_set
 int	wattr_set(
-		WINDOW	*a1, 
-		attr_t	a2, 
-		short	a3, 
+		WINDOW	*a1,
+		attr_t	a2,
+		short	a3,
 		void	*z)
 		{ return(*(int *)0); }
 
@@ -1114,13 +1114,13 @@ int	wdeleteln(
 
 #undef wgetstr
 int	wgetstr(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef winchstr
 int	winchstr(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		chtype	*z)
 		{ return(*(int *)0); }
 
@@ -1131,13 +1131,13 @@ int	winsertln(
 
 #undef winsstr
 int	winsstr(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef winstr
 int	winstr(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		char	*z)
 		{ return(*(int *)0); }
 
@@ -1268,15 +1268,15 @@ int	wgetdelay(
 
 #undef wgetscrreg
 int	wgetscrreg(
-		const WINDOW *a1, 
-		int	*a2, 
+		const WINDOW *a1,
+		int	*a2,
 		int	*z)
 		{ return(*(int *)0); }
 
 #undef mouse_trafo
 NCURSES_BOOL mouse_trafo(
-		int	*a1, 
-		int	*a2, 
+		int	*a1,
+		int	*a2,
 		NCURSES_BOOL z)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -1287,7 +1287,7 @@ int	ESCDELAY;
 
 #undef set_escdelay_sp
 int	set_escdelay_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	value)
 		{ return(*(int *)0); }
 
@@ -1307,8 +1307,8 @@ int	get_escdelay(void)
 
 #undef _nc_wgetch
 int	_nc_wgetch(
-		WINDOW	*win, 
-		int	*result, 
+		WINDOW	*win,
+		int	*result,
 		int	use_meta)
 		{ return(*(int *)0); }
 
@@ -1321,8 +1321,8 @@ int	wgetch(
 
 #undef wgetnstr
 int	wgetnstr(
-		WINDOW	*win, 
-		char	*str, 
+		WINDOW	*win,
+		char	*str,
 		int	maxlen)
 		{ return(*(int *)0); }
 
@@ -1330,8 +1330,8 @@ int	wgetnstr(
 
 #undef whline
 int	whline(
-		WINDOW	*win, 
-		chtype	ch, 
+		WINDOW	*win,
+		chtype	ch,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1339,7 +1339,7 @@ int	whline(
 
 #undef immedok
 void	immedok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ /* void */ }
 
@@ -1347,8 +1347,8 @@ void	immedok(
 
 #undef winchnstr
 int	winchnstr(
-		WINDOW	*win, 
-		chtype	*str, 
+		WINDOW	*win,
+		chtype	*str,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1362,14 +1362,14 @@ WINDOW	*initscr(void)
 
 #undef _nc_insert_ch
 int	_nc_insert_ch(
-		SCREEN	*sp, 
-		WINDOW	*win, 
+		SCREEN	*sp,
+		WINDOW	*win,
 		chtype	ch)
 		{ return(*(int *)0); }
 
 #undef winsch
 int	winsch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		chtype	c)
 		{ return(*(int *)0); }
 
@@ -1377,7 +1377,7 @@ int	winsch(
 
 #undef winsdelln
 int	winsdelln(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1385,8 +1385,8 @@ int	winsdelln(
 
 #undef winsnstr
 int	winsnstr(
-		WINDOW	*win, 
-		const char *s, 
+		WINDOW	*win,
+		const char *s,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1394,8 +1394,8 @@ int	winsnstr(
 
 #undef winnstr
 int	winnstr(
-		WINDOW	*win, 
-		char	*str, 
+		WINDOW	*win,
+		char	*str,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1414,7 +1414,7 @@ NCURSES_BOOL isendwin(void)
 
 #undef leaveok
 int	leaveok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
@@ -1422,7 +1422,7 @@ int	leaveok(
 
 #undef getmouse_sp
 int	getmouse_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		MEVENT	*aevent)
 		{ return(*(int *)0); }
 
@@ -1433,7 +1433,7 @@ int	getmouse(
 
 #undef ungetmouse_sp
 int	ungetmouse_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		MEVENT	*aevent)
 		{ return(*(int *)0); }
 
@@ -1444,27 +1444,27 @@ int	ungetmouse(
 
 #undef mousemask_sp
 mmask_t	mousemask_sp(
-		SCREEN	*sp, 
-		mmask_t	newmask, 
+		SCREEN	*sp,
+		mmask_t	newmask,
 		mmask_t	*oldmask)
 		{ return(*(mmask_t *)0); }
 
 #undef mousemask
 mmask_t	mousemask(
-		mmask_t	newmask, 
+		mmask_t	newmask,
 		mmask_t	*oldmask)
 		{ return(*(mmask_t *)0); }
 
 #undef wenclose
 NCURSES_BOOL wenclose(
-		const WINDOW *win, 
-		int	y, 
+		const WINDOW *win,
+		int	y,
 		int	x)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef mouseinterval_sp
 int	mouseinterval_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	maxclick)
 		{ return(*(int *)0); }
 
@@ -1489,9 +1489,9 @@ NCURSES_BOOL has_mouse(void)
 
 #undef wmouse_trafo
 NCURSES_BOOL wmouse_trafo(
-		const WINDOW *win, 
-		int	*pY, 
-		int	*pX, 
+		const WINDOW *win,
+		int	*pY,
+		int	*pX,
 		NCURSES_BOOL to_screen)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -1499,8 +1499,8 @@ NCURSES_BOOL wmouse_trafo(
 
 #undef wmove
 int	wmove(
-		WINDOW	*win, 
-		int	y, 
+		WINDOW	*win,
+		int	y,
 		int	x)
 		{ return(*(int *)0); }
 
@@ -1508,14 +1508,14 @@ int	wmove(
 
 #undef _nc_msec_cost_sp
 int	_nc_msec_cost_sp(
-		SCREEN	*sp, 
-		const char *const cap, 
+		SCREEN	*sp,
+		const char *const cap,
 		int	affcnt)
 		{ return(*(int *)0); }
 
 #undef _nc_msec_cost
 int	_nc_msec_cost(
-		const char *const cap, 
+		const char *const cap,
 		int	affcnt)
 		{ return(*(int *)0); }
 
@@ -1548,35 +1548,35 @@ void	_nc_mvcur_wrap(void)
 
 #undef _nc_mvcur_sp
 int	_nc_mvcur_sp(
-		SCREEN	*sp, 
-		int	yold, 
-		int	xold, 
-		int	ynew, 
+		SCREEN	*sp,
+		int	yold,
+		int	xold,
+		int	ynew,
 		int	xnew)
 		{ return(*(int *)0); }
 
 #undef _nc_mvcur
 int	_nc_mvcur(
-		int	yold, 
-		int	xold, 
-		int	ynew, 
+		int	yold,
+		int	xold,
+		int	ynew,
 		int	xnew)
 		{ return(*(int *)0); }
 
 #undef mvcur_sp
 int	mvcur_sp(
-		SCREEN	*sp, 
-		int	yold, 
-		int	xold, 
-		int	ynew, 
+		SCREEN	*sp,
+		int	yold,
+		int	xold,
+		int	ynew,
 		int	xnew)
 		{ return(*(int *)0); }
 
 #undef mvcur
 int	mvcur(
-		int	yold, 
-		int	xold, 
-		int	ynew, 
+		int	yold,
+		int	xold,
+		int	ynew,
 		int	xnew)
 		{ return(*(int *)0); }
 
@@ -1587,8 +1587,8 @@ int	_nc_optimize_enable;
 
 #undef mvwin
 int	mvwin(
-		WINDOW	*win, 
-		int	by, 
+		WINDOW	*win,
+		int	by,
 		int	bx)
 		{ return(*(int *)0); }
 
@@ -1614,16 +1614,16 @@ void	nofilter(void)
 
 #undef newterm_sp
 SCREEN	*newterm_sp(
-		SCREEN	*sp, 
-		const char *name, 
-		FILE	*ofp, 
+		SCREEN	*sp,
+		const char *name,
+		FILE	*ofp,
 		FILE	*ifp)
 		{ return(*(SCREEN **)0); }
 
 #undef newterm
 SCREEN	*newterm(
-		const char *name, 
-		FILE	*ofp, 
+		const char *name,
+		FILE	*ofp,
 		FILE	*ifp)
 		{ return(*(SCREEN **)0); }
 
@@ -1636,46 +1636,46 @@ int	_nc_freewin(
 
 #undef newwin_sp
 WINDOW	*newwin_sp(
-		SCREEN	*sp, 
-		int	num_lines, 
-		int	num_columns, 
-		int	begy, 
+		SCREEN	*sp,
+		int	num_lines,
+		int	num_columns,
+		int	begy,
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef newwin
 WINDOW	*newwin(
-		int	num_lines, 
-		int	num_columns, 
-		int	begy, 
+		int	num_lines,
+		int	num_columns,
+		int	begy,
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef derwin
 WINDOW	*derwin(
-		WINDOW	*orig, 
-		int	num_lines, 
-		int	num_columns, 
-		int	begy, 
+		WINDOW	*orig,
+		int	num_lines,
+		int	num_columns,
+		int	begy,
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef subwin
 WINDOW	*subwin(
-		WINDOW	*w, 
-		int	l, 
-		int	c, 
-		int	y, 
+		WINDOW	*w,
+		int	l,
+		int	c,
+		int	y,
 		int	x)
 		{ return(*(WINDOW **)0); }
 
 #undef _nc_makenew_sp
 WINDOW	*_nc_makenew_sp(
-		SCREEN	*sp, 
-		int	num_lines, 
-		int	num_columns, 
-		int	begy, 
-		int	begx, 
+		SCREEN	*sp,
+		int	num_lines,
+		int	num_columns,
+		int	begy,
+		int	begx,
 		int	flags)
 		{ return(*(WINDOW **)0); }
 
@@ -1718,26 +1718,26 @@ int	nonl(void)
 
 #undef overlay
 int	overlay(
-		const WINDOW *win1, 
+		const WINDOW *win1,
 		WINDOW	*win2)
 		{ return(*(int *)0); }
 
 #undef overwrite
 int	overwrite(
-		const WINDOW *win1, 
+		const WINDOW *win1,
 		WINDOW	*win2)
 		{ return(*(int *)0); }
 
 #undef copywin
 int	copywin(
-		const WINDOW *src, 
-		WINDOW	*dst, 
-		int	sminrow, 
-		int	smincol, 
-		int	dminrow, 
-		int	dmincol, 
-		int	dmaxrow, 
-		int	dmaxcol, 
+		const WINDOW *src,
+		WINDOW	*dst,
+		int	sminrow,
+		int	smincol,
+		int	dminrow,
+		int	dmincol,
+		int	dmaxrow,
+		int	dmaxcol,
 		int	over)
 		{ return(*(int *)0); }
 
@@ -1745,51 +1745,51 @@ int	copywin(
 
 #undef newpad_sp
 WINDOW	*newpad_sp(
-		SCREEN	*sp, 
-		int	l, 
+		SCREEN	*sp,
+		int	l,
 		int	c)
 		{ return(*(WINDOW **)0); }
 
 #undef newpad
 WINDOW	*newpad(
-		int	l, 
+		int	l,
 		int	c)
 		{ return(*(WINDOW **)0); }
 
 #undef subpad
 WINDOW	*subpad(
-		WINDOW	*orig, 
-		int	l, 
-		int	c, 
-		int	begy, 
+		WINDOW	*orig,
+		int	l,
+		int	c,
+		int	begy,
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef prefresh
 int	prefresh(
-		WINDOW	*win, 
-		int	pminrow, 
-		int	pmincol, 
-		int	sminrow, 
-		int	smincol, 
-		int	smaxrow, 
+		WINDOW	*win,
+		int	pminrow,
+		int	pmincol,
+		int	sminrow,
+		int	smincol,
+		int	smaxrow,
 		int	smaxcol)
 		{ return(*(int *)0); }
 
 #undef pnoutrefresh
 int	pnoutrefresh(
-		WINDOW	*win, 
-		int	pminrow, 
-		int	pmincol, 
-		int	sminrow, 
-		int	smincol, 
-		int	smaxrow, 
+		WINDOW	*win,
+		int	pminrow,
+		int	pmincol,
+		int	sminrow,
+		int	smincol,
+		int	smaxrow,
 		int	smaxcol)
 		{ return(*(int *)0); }
 
 #undef pechochar
 int	pechochar(
-		WINDOW	*pad, 
+		WINDOW	*pad,
 		const chtype ch)
 		{ return(*(int *)0); }
 
@@ -1797,45 +1797,45 @@ int	pechochar(
 
 #undef printw
 int	printw(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef wprintw
 int	wprintw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef mvprintw
 int	mvprintw(
-		int	y, 
-		int	x, 
-		const char *fmt, 
+		int	y,
+		int	x,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef mvwprintw
 int	mvwprintw(
-		WINDOW	*win, 
-		int	y, 
-		int	x, 
-		const char *fmt, 
+		WINDOW	*win,
+		int	y,
+		int	x,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef vwprintw
 int	vwprintw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
 		va_list	argp)
 		{ return(*(int *)0); }
 
 #undef vw_printw
 int	vw_printw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
 		va_list	argp)
 		{ return(*(int *)0); }
 
@@ -1843,8 +1843,8 @@ int	vw_printw(
 
 #undef wredrawln
 int	wredrawln(
-		WINDOW	*win, 
-		int	beg, 
+		WINDOW	*win,
+		int	beg,
 		int	num)
 		{ return(*(int *)0); }
 
@@ -1864,16 +1864,16 @@ int	wnoutrefresh(
 
 #undef restartterm_sp
 int	restartterm_sp(
-		SCREEN	*sp, 
-		const char *termp, 
-		int	filenum, 
+		SCREEN	*sp,
+		const char *termp,
+		int	filenum,
 		int	*errret)
 		{ return(*(int *)0); }
 
 #undef restartterm
 int	restartterm(
-		const char *termp, 
-		int	filenum, 
+		const char *termp,
+		int	filenum,
 		int	*errret)
 		{ return(*(int *)0); }
 
@@ -1881,45 +1881,45 @@ int	restartterm(
 
 #undef vwscanw
 int	vwscanw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
 		va_list	argp)
 		{ return(*(int *)0); }
 
 #undef vw_scanw
 int	vw_scanw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
 		va_list	argp)
 		{ return(*(int *)0); }
 
 #undef scanw
 int	scanw(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef wscanw
 int	wscanw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef mvscanw
 int	mvscanw(
-		int	y, 
-		int	x, 
-		const char *fmt, 
+		int	y,
+		int	x,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef mvwscanw
 int	mvwscanw(
-		WINDOW	*win, 
-		int	y, 
-		int	x, 
-		const char *fmt, 
+		WINDOW	*win,
+		int	y,
+		int	x,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
@@ -1927,7 +1927,7 @@ int	mvwscanw(
 
 #undef getwin_sp
 WINDOW	*getwin_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		FILE	*filep)
 		{ return(*(WINDOW **)0); }
 
@@ -1938,13 +1938,13 @@ WINDOW	*getwin(
 
 #undef putwin
 int	putwin(
-		WINDOW	*win, 
+		WINDOW	*win,
 		FILE	*filep)
 		{ return(*(int *)0); }
 
 #undef scr_restore_sp
 int	scr_restore_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *file)
 		{ return(*(int *)0); }
 
@@ -1960,7 +1960,7 @@ int	scr_dump(
 
 #undef scr_init_sp
 int	scr_init_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *file)
 		{ return(*(int *)0); }
 
@@ -1971,7 +1971,7 @@ int	scr_init(
 
 #undef scr_set_sp
 int	scr_set_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *file)
 		{ return(*(int *)0); }
 
@@ -1984,16 +1984,16 @@ int	scr_set(
 
 #undef _nc_scroll_window
 void	_nc_scroll_window(
-		WINDOW	*win, 
-		int const n, 
-		int const top, 
-		int const bottom, 
+		WINDOW	*win,
+		int const n,
+		int const top,
+		int const bottom,
 		chtype	blank)
 		{ /* void */ }
 
 #undef wscrl
 int	wscrl(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -2001,7 +2001,7 @@ int	wscrl(
 
 #undef scrollok
 int	scrollok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
@@ -2009,8 +2009,8 @@ int	scrollok(
 
 #undef wsetscrreg
 int	wsetscrreg(
-		WINDOW	*win, 
-		int	top, 
+		WINDOW	*win,
+		int	top,
 		int	bottom)
 		{ return(*(int *)0); }
 
@@ -2028,54 +2028,54 @@ void	delscreen(
 
 #undef _nc_setupscreen_sp
 int	_nc_setupscreen_sp(
-		SCREEN	**spp, 
-		int	slines, 
-		int	scolumns, 
-		FILE	*output, 
-		int	filtered, 
+		SCREEN	**spp,
+		int	slines,
+		int	scolumns,
+		FILE	*output,
+		int	filtered,
 		int	slk_format)
 		{ return(*(int *)0); }
 
 #undef _nc_setupscreen
 int	_nc_setupscreen(
-		int	slines, 
-		int	scolumns, 
-		FILE	*output, 
-		int	filtered, 
+		int	slines,
+		int	scolumns,
+		FILE	*output,
+		int	filtered,
 		int	slk_format)
 		{ return(*(int *)0); }
 
 #undef _nc_ripoffline_sp
 int	_nc_ripoffline_sp(
-		SCREEN	*sp, 
-		int	line, 
+		SCREEN	*sp,
+		int	line,
 		int	(*init)(
-		WINDOW	*p1, 
+		WINDOW	*p1,
 		int	p2))
 		{ return(*(int *)0); }
 
 #undef _nc_ripoffline
 int	_nc_ripoffline(
-		int	line, 
+		int	line,
 		int	(*init)(
-		WINDOW	*p1, 
+		WINDOW	*p1,
 		int	p2))
 		{ return(*(int *)0); }
 
 #undef ripoffline_sp
 int	ripoffline_sp(
-		SCREEN	*sp, 
-		int	line, 
+		SCREEN	*sp,
+		int	line,
 		int	(*init)(
-		WINDOW	*p1, 
+		WINDOW	*p1,
 		int	p2))
 		{ return(*(int *)0); }
 
 #undef ripoffline
 int	ripoffline(
-		int	line, 
+		int	line,
 		int	(*init)(
-		WINDOW	*p1, 
+		WINDOW	*p1,
 		int	p2))
 		{ return(*(int *)0); }
 
@@ -2083,13 +2083,13 @@ int	ripoffline(
 
 #undef _nc_format_slks
 int	_nc_format_slks(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	cols)
 		{ return(*(int *)0); }
 
 #undef _nc_slk_initialize
 int	_nc_slk_initialize(
-		WINDOW	*stwin, 
+		WINDOW	*stwin,
 		int	cols)
 		{ return(*(int *)0); }
 
@@ -2106,16 +2106,16 @@ int	slk_restore(void)
 
 #undef slk_attr_set_sp
 int	slk_attr_set_sp(
-		SCREEN	*sp, 
-		const attr_t attr, 
-		short	pair_arg, 
+		SCREEN	*sp,
+		const attr_t attr,
+		short	pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
 #undef slk_attr_set
 int	slk_attr_set(
-		const attr_t attr, 
-		short	pair_arg, 
+		const attr_t attr,
+		short	pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -2123,7 +2123,7 @@ int	slk_attr_set(
 
 #undef slk_attroff_sp
 int	slk_attroff_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const chtype attr)
 		{ return(*(int *)0); }
 
@@ -2136,7 +2136,7 @@ int	slk_attroff(
 
 #undef slk_attron_sp
 int	slk_attron_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const chtype attr)
 		{ return(*(int *)0); }
 
@@ -2149,7 +2149,7 @@ int	slk_attron(
 
 #undef slk_attrset_sp
 int	slk_attrset_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const chtype attr)
 		{ return(*(int *)0); }
 
@@ -2184,7 +2184,7 @@ int	slk_clear(void)
 
 #undef slk_color_sp
 int	slk_color_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		short	pair_arg)
 		{ return(*(int *)0); }
 
@@ -2197,7 +2197,7 @@ int	slk_color(
 
 #undef slk_init_sp
 int	slk_init_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	format)
 		{ return(*(int *)0); }
 
@@ -2210,7 +2210,7 @@ int	slk_init(
 
 #undef slk_label_sp
 char	*slk_label_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	n)
 		{ return(*(char **)0); }
 
@@ -2243,16 +2243,16 @@ int	slk_refresh(void)
 
 #undef slk_set_sp
 int	slk_set_sp(
-		SCREEN	*sp, 
-		int	i, 
-		const char *astr, 
+		SCREEN	*sp,
+		int	i,
+		const char *astr,
 		int	format)
 		{ return(*(int *)0); }
 
 #undef slk_set
 int	slk_set(
-		int	i, 
-		const char *astr, 
+		int	i,
+		const char *astr,
 		int	format)
 		{ return(*(int *)0); }
 
@@ -2271,7 +2271,7 @@ int	slk_touch(void)
 
 #undef is_linetouched
 NCURSES_BOOL is_linetouched(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	line)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -2282,9 +2282,9 @@ NCURSES_BOOL is_wintouched(
 
 #undef wtouchln
 int	wtouchln(
-		WINDOW	*win, 
-		int	y, 
-		int	n, 
+		WINDOW	*win,
+		int	y,
+		int	n,
 		int	changed)
 		{ return(*(int *)0); }
 
@@ -2292,7 +2292,7 @@ int	wtouchln(
 
 #undef _tracedump
 void	_tracedump(
-		const char *name, 
+		const char *name,
 		WINDOW	*win)
 		{ /* void */ }
 
@@ -2300,19 +2300,19 @@ void	_tracedump(
 
 #undef _nc_trace_mmask_t
 char	*_nc_trace_mmask_t(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		mmask_t	code)
 		{ return(*(char **)0); }
 
 #undef _nc_tracemouse
 char	*_nc_tracemouse(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		MEVENT const *ep)
 		{ return(*(char **)0); }
 
 #undef _nc_retrace_mmask_t
 mmask_t	_nc_retrace_mmask_t(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		mmask_t	code)
 		{ return(*(mmask_t *)0); }
 
@@ -2337,7 +2337,7 @@ void	_nc_fifo_dump(
 
 #undef ungetch_sp
 int	ungetch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -2350,20 +2350,20 @@ int	ungetch(
 
 #undef vidputs_sp
 int	vidputs_sp(
-		SCREEN	*sp, 
-		chtype	newmode, 
+		SCREEN	*sp,
+		chtype	newmode,
 		NCURSES_OUTC_sp outc)
 		{ return(*(int *)0); }
 
 #undef vidputs
 int	vidputs(
-		chtype	newmode, 
+		chtype	newmode,
 		NCURSES_OUTC outc)
 		{ return(*(int *)0); }
 
 #undef vidattr_sp
 int	vidattr_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		chtype	newmode)
 		{ return(*(int *)0); }
 
@@ -2385,8 +2385,8 @@ chtype	termattrs(void)
 
 #undef wvline
 int	wvline(
-		WINDOW	*win, 
-		chtype	ch, 
+		WINDOW	*win,
+		chtype	ch,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -2394,8 +2394,8 @@ int	wvline(
 
 #undef wattr_off
 int	wattr_off(
-		WINDOW	*win, 
-		attr_t	at, 
+		WINDOW	*win,
+		attr_t	at,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -2403,8 +2403,8 @@ int	wattr_off(
 
 #undef wattr_on
 int	wattr_on(
-		WINDOW	*win, 
-		attr_t	at, 
+		WINDOW	*win,
+		attr_t	at,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -2424,14 +2424,14 @@ void	_nc_synchook(
 
 #undef mvderwin
 int	mvderwin(
-		WINDOW	*win, 
-		int	y, 
+		WINDOW	*win,
+		int	y,
 		int	x)
 		{ return(*(int *)0); }
 
 #undef syncok
 int	syncok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL bf)
 		{ return(*(int *)0); }
 
@@ -2470,14 +2470,14 @@ struct panelhook *_nc_panelhook(void)
 
 #undef _nc_printf_string_sp
 char	*_nc_printf_string_sp(
-		SCREEN	*sp, 
-		const char *fmt, 
+		SCREEN	*sp,
+		const char *fmt,
 		va_list	ap)
 		{ return(*(char **)0); }
 
 #undef _nc_printf_string
 char	*_nc_printf_string(
-		const char *fmt, 
+		const char *fmt,
 		va_list	ap)
 		{ return(*(char **)0); }
 
@@ -2494,18 +2494,18 @@ int	doupdate(void)
 
 #undef _nc_scrolln_sp
 int	_nc_scrolln_sp(
-		SCREEN	*sp, 
-		int	n, 
-		int	top, 
-		int	bot, 
+		SCREEN	*sp,
+		int	n,
+		int	top,
+		int	bot,
 		int	maxy)
 		{ return(*(int *)0); }
 
 #undef _nc_scrolln
 int	_nc_scrolln(
-		int	n, 
-		int	top, 
-		int	bot, 
+		int	n,
+		int	top,
+		int	bot,
 		int	maxy)
 		{ return(*(int *)0); }
 
@@ -2538,7 +2538,7 @@ void	_nc_screen_wrap(void)
 
 #undef _nc_do_xmc_glitch_sp
 void	_nc_do_xmc_glitch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		attr_t	previous)
 		{ /* void */ }
 
@@ -2551,7 +2551,7 @@ void	_nc_do_xmc_glitch(
 
 #undef _nc_varargs
 char	*_nc_varargs(
-		const char *fmt, 
+		const char *fmt,
 		va_list	ap)
 		{ return(*(char **)0); }
 
@@ -2569,7 +2569,7 @@ void	_nc_freeall(void)
 
 #undef _nc_free_and_exit_sp
 void	_nc_free_and_exit_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	code)
 		{ /* void */ }
 
@@ -2587,31 +2587,31 @@ void	exit_curses(
 
 #undef _nc_toggle_attr_on
 void	_nc_toggle_attr_on(
-		attr_t	*S, 
+		attr_t	*S,
 		attr_t	at)
 		{ /* void */ }
 
 #undef _nc_toggle_attr_off
 void	_nc_toggle_attr_off(
-		attr_t	*S, 
+		attr_t	*S,
 		attr_t	at)
 		{ /* void */ }
 
 #undef _nc_DelCharCost_sp
 int	_nc_DelCharCost_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	count)
 		{ return(*(int *)0); }
 
 #undef _nc_InsCharCost_sp
 int	_nc_InsCharCost_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	count)
 		{ return(*(int *)0); }
 
 #undef _nc_UpdateAttrs_sp
 void	_nc_UpdateAttrs_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		chtype	c)
 		{ /* void */ }
 
@@ -2634,7 +2634,7 @@ void	_nc_UpdateAttrs(
 
 #undef use_legacy_coding_sp
 int	use_legacy_coding_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	level)
 		{ return(*(int *)0); }
 
@@ -2656,14 +2656,14 @@ int	use_default_colors(void)
 
 #undef assume_default_colors_sp
 int	assume_default_colors_sp(
-		SCREEN	*sp, 
-		int	fg, 
+		SCREEN	*sp,
+		int	fg,
 		int	bg)
 		{ return(*(int *)0); }
 
 #undef assume_default_colors
 int	assume_default_colors(
-		int	fg, 
+		int	fg,
 		int	bg)
 		{ return(*(int *)0); }
 
@@ -2671,14 +2671,14 @@ int	assume_default_colors(
 
 #undef mcprint_sp
 int	mcprint_sp(
-		SCREEN	*sp, 
-		char	*data, 
+		SCREEN	*sp,
+		char	*data,
 		int	len)
 		{ return(*(int *)0); }
 
 #undef mcprint
 int	mcprint(
-		char	*data, 
+		char	*data,
 		int	len)
 		{ return(*(int *)0); }
 
@@ -2692,40 +2692,40 @@ void	_nc_new_pair(void)
 
 #undef is_term_resized_sp
 NCURSES_BOOL is_term_resized_sp(
-		SCREEN	*sp, 
-		int	ToLines, 
+		SCREEN	*sp,
+		int	ToLines,
 		int	ToCols)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_term_resized
 NCURSES_BOOL is_term_resized(
-		int	ToLines, 
+		int	ToLines,
 		int	ToCols)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef resize_term_sp
 int	resize_term_sp(
-		SCREEN	*sp, 
-		int	ToLines, 
+		SCREEN	*sp,
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
 #undef resize_term
 int	resize_term(
-		int	ToLines, 
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
 #undef resizeterm_sp
 int	resizeterm_sp(
-		SCREEN	*sp, 
-		int	ToLines, 
+		SCREEN	*sp,
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
 #undef resizeterm
 int	resizeterm(
-		int	ToLines, 
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
@@ -2740,8 +2740,8 @@ void	_nc_trace_xnames(
 
 #undef use_screen
 int	use_screen(
-		SCREEN	*screen, 
-		NCURSES_SCREEN_CB func, 
+		SCREEN	*screen,
+		NCURSES_SCREEN_CB func,
 		void	*data)
 		{ return(*(int *)0); }
 
@@ -2749,8 +2749,8 @@ int	use_screen(
 
 #undef use_window
 int	use_window(
-		WINDOW	*win, 
-		NCURSES_WINDOW_CB func, 
+		WINDOW	*win,
+		NCURSES_WINDOW_CB func,
 		void	*data)
 		{ return(*(int *)0); }
 
@@ -2758,8 +2758,8 @@ int	use_window(
 
 #undef wresize
 int	wresize(
-		WINDOW	*win, 
-		int	ToLines, 
+		WINDOW	*win,
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
@@ -2787,7 +2787,7 @@ char	*_nc_basename(
 
 #undef _nc_access
 int	_nc_access(
-		const char *path, 
+		const char *path,
 		int	mode)
 		{ return(*(int *)0); }
 
@@ -2805,12 +2805,25 @@ NCURSES_BOOL _nc_is_file_path(
 int	_nc_env_access(void)
 		{ return(*(int *)0); }
 
+#undef _nc_safe_fopen
+FILE	*_nc_safe_fopen(
+		const char *path,
+		const char *mode)
+		{ return(*(FILE **)0); }
+
+#undef _nc_safe_open3
+int	_nc_safe_open3(
+		const char *path,
+		int	flags,
+		mode_t	mode)
+		{ return(*(int *)0); }
+
 /* ./tinfo/add_tries.c */
 
 #undef _nc_add_to_try
 int	_nc_add_to_try(
-		TRIES	**tree, 
-		const char *str, 
+		TRIES	**tree,
+		const char *str,
 		unsigned code)
 		{ return(*(int *)0); }
 
@@ -2818,13 +2831,13 @@ int	_nc_add_to_try(
 
 #undef _nc_align_termtype
 void	_nc_align_termtype(
-		TERMTYPE2 *to, 
-		TERMTYPE2 *from)
+		TERMTYPE *to,
+		TERMTYPE *from)
 		{ /* void */ }
 
 #undef _nc_copy_termtype
 void	_nc_copy_termtype(
-		TERMTYPE *dst, 
+		TERMTYPE *dst,
 		const TERMTYPE *src)
 		{ /* void */ }
 
@@ -2889,19 +2902,19 @@ void	_nc_get_type(
 
 #undef _nc_warning
 void	_nc_warning(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
 #undef _nc_err_abort
 void	_nc_err_abort(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
 #undef _nc_syserr_abort
 void	_nc_syserr_abort(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
@@ -2909,14 +2922,14 @@ void	_nc_syserr_abort(
 
 #undef _nc_find_entry
 struct name_table_entry const *_nc_find_entry(
-		const char *string, 
+		const char *string,
 		const HashValue *hash_table)
 		{ return(*(struct name_table_entry const **)0); }
 
 #undef _nc_find_type_entry
 struct name_table_entry const *_nc_find_type_entry(
-		const char *string, 
-		int	type, 
+		const char *string,
+		int	type,
 		NCURSES_BOOL termcap)
 		{ return(*(struct name_table_entry const **)0); }
 
@@ -2953,13 +2966,13 @@ void	_nc_last_db(void)
 
 #undef _nc_next_db
 const char *_nc_next_db(
-		DBDIRS	*state, 
+		DBDIRS	*state,
 		int	*offset)
 		{ return(*(const char **)0); }
 
 #undef _nc_first_db
 void	_nc_first_db(
-		DBDIRS	*state, 
+		DBDIRS	*state,
 		int	*offset)
 		{ /* void */ }
 
@@ -2967,7 +2980,7 @@ void	_nc_first_db(
 
 #undef _nc_doalloc
 void	*_nc_doalloc(
-		void	*oldp, 
+		void	*oldp,
 		size_t	amount)
 		{ return(*(void **)0); }
 
@@ -2980,8 +2993,8 @@ ENTRY	*_nc_tail;
 
 #undef _nc_free_entry
 void	_nc_free_entry(
-		ENTRY	*headp, 
-		TERMTYPE2 *tterm)
+		ENTRY	*headp,
+		TERMTYPE *tterm)
 		{ /* void */ }
 
 #undef _nc_free_entries
@@ -3001,9 +3014,9 @@ void	exit_terminfo(
 /* ./fallback.c */
 
 #undef _nc_fallback
-const TERMTYPE2 *_nc_fallback(
+const TERMTYPE *_nc_fallback(
 		const char *name)
-		{ return(*(const TERMTYPE2 **)0); }
+		{ return(*(const TERMTYPE **)0); }
 
 /* ./tinfo/free_ttype.c */
 
@@ -3012,6 +3025,11 @@ void	_nc_free_termtype(
 		TERMTYPE *ptr)
 		{ /* void */ }
 
+#undef _nc_free_termtype1
+void	_nc_free_termtype1(
+		TERMTYPE *ptr)
+		{ /* void */ }
+
 #undef _nc_user_definable
 NCURSES_BOOL _nc_user_definable;
 
@@ -3029,7 +3047,7 @@ int	_nc_getenv_num(
 
 #undef _nc_setenv_num
 void	_nc_setenv_num(
-		const char *name, 
+		const char *name,
 		int	value)
 		{ /* void */ }
 
@@ -3063,8 +3081,8 @@ void	_nc_init_acs(void)
 /* ./tinfo/lib_baudrate.c */
 
 struct speed {
-    int given_speed; 
-    int actual_speed; 
+    int given_speed;
+    int actual_speed;
 };
 
 #undef _nc_baudrate
@@ -3093,7 +3111,7 @@ TERMINAL *cur_term;
 
 #undef set_curterm_sp
 TERMINAL *set_curterm_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		TERMINAL *termp)
 		{ return(*(TERMINAL **)0); }
 
@@ -3104,7 +3122,7 @@ TERMINAL *set_curterm(
 
 #undef del_curterm_sp
 int	del_curterm_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		TERMINAL *termp)
 		{ return(*(int *)0); }
 
@@ -3190,7 +3208,7 @@ struct kn { short offset; int code; };
 
 #undef keyname_sp
 const char *keyname_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	c)
 		{ return(*(const char **)0); }
 
@@ -3214,7 +3232,7 @@ char	*longname(void)
 
 #undef napms_sp
 int	napms_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ms)
 		{ return(*(int *)0); }
 
@@ -3227,19 +3245,19 @@ int	napms(
 
 #undef idlok
 int	idlok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef idcok
 void	idcok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ /* void */ }
 
 #undef halfdelay_sp
 int	halfdelay_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	t)
 		{ return(*(int *)0); }
 
@@ -3250,37 +3268,37 @@ int	halfdelay(
 
 #undef nodelay
 int	nodelay(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef notimeout
 int	notimeout(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL f)
 		{ return(*(int *)0); }
 
 #undef wtimeout
 void	wtimeout(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	delay)
 		{ /* void */ }
 
 #undef keypad
 int	keypad(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef meta
 int	meta(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef curs_set_sp
 int	curs_set_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	vis)
 		{ return(*(int *)0); }
 
@@ -3291,7 +3309,7 @@ int	curs_set(
 
 #undef typeahead_sp
 int	typeahead_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	fd)
 		{ return(*(int *)0); }
 
@@ -3302,7 +3320,7 @@ int	typeahead(
 
 #undef has_key_sp
 int	has_key_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	keycode)
 		{ return(*(int *)0); }
 
@@ -3313,14 +3331,14 @@ int	has_key(
 
 #undef _nc_putp_flush_sp
 int	_nc_putp_flush_sp(
-		SCREEN	*sp, 
-		const char *name, 
+		SCREEN	*sp,
+		const char *name,
 		const char *value)
 		{ return(*(int *)0); }
 
 #undef _nc_keypad
 int	_nc_keypad(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	flag)
 		{ return(*(int *)0); }
 
@@ -3382,17 +3400,53 @@ void	noqiflush(void)
 
 #undef intrflush_sp
 int	intrflush_sp(
-		SCREEN	*sp, 
-		WINDOW	*win, 
+		SCREEN	*sp,
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef intrflush
 int	intrflush(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
+#undef is_nl_sp
+int	is_nl_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_raw_sp
+int	is_raw_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_cbreak_sp
+int	is_cbreak_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_echo_sp
+int	is_echo_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_nl
+int	is_nl(void)
+		{ return(*(int *)0); }
+
+#undef is_raw
+int	is_raw(void)
+		{ return(*(int *)0); }
+
+#undef is_cbreak
+int	is_cbreak(void)
+		{ return(*(int *)0); }
+
+#undef is_echo
+int	is_echo(void)
+		{ return(*(int *)0); }
+
 /* ./tinfo/lib_setup.c */
 
 #undef ttytype
@@ -3406,7 +3460,7 @@ int	TABSIZE;
 
 #undef set_tabsize_sp
 int	set_tabsize_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	value)
 		{ return(*(int *)0); }
 
@@ -3422,13 +3476,13 @@ int	_nc_handle_sigwinch(
 
 #undef use_env_sp
 void	use_env_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		NCURSES_BOOL f)
 		{ /* void */ }
 
 #undef use_tioctl_sp
 void	use_tioctl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		NCURSES_BOOL f)
 		{ /* void */ }
 
@@ -3444,8 +3498,8 @@ void	use_tioctl(
 
 #undef _nc_get_screensize
 void	_nc_get_screensize(
-		SCREEN	*sp, 
-		int	*linep, 
+		SCREEN	*sp,
+		int	*linep,
 		int	*colp)
 		{ /* void */ }
 
@@ -3456,13 +3510,13 @@ void	_nc_update_screensize(
 
 #undef _nc_setup_tinfo
 int	_nc_setup_tinfo(
-		const char *const tn, 
-		TERMTYPE2 *const tp)
+		const char *const tn,
+		TERMTYPE *const tp)
 		{ return(*(int *)0); }
 
 #undef _nc_tinfo_cmdch
 void	_nc_tinfo_cmdch(
-		TERMINAL *termp, 
+		TERMINAL *termp,
 		int	proto)
 		{ /* void */ }
 
@@ -3481,9 +3535,9 @@ int	_nc_locale_breaks_acs(
 
 #undef _nc_setupterm
 int	_nc_setupterm(
-		const char *tname, 
-		int	Filedes, 
-		int	*errret, 
+		const char *tname,
+		int	Filedes,
+		int	*errret,
 		int	reuse)
 		{ return(*(int *)0); }
 
@@ -3493,8 +3547,8 @@ SCREEN	*new_prescr(void)
 
 #undef setupterm
 int	setupterm(
-		const char *tname, 
-		int	Filedes, 
+		const char *tname,
+		int	Filedes,
 		int	*errret)
 		{ return(*(int *)0); }
 
@@ -3507,20 +3561,20 @@ char	*BC;
 
 #undef tgetent_sp
 int	tgetent_sp(
-		SCREEN	*sp, 
-		char	*bufp, 
+		SCREEN	*sp,
+		char	*bufp,
 		const char *name)
 		{ return(*(int *)0); }
 
 #undef tgetent
 int	tgetent(
-		char	*bufp, 
+		char	*bufp,
 		const char *name)
 		{ return(*(int *)0); }
 
 #undef tgetflag_sp
 int	tgetflag_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *id)
 		{ return(*(int *)0); }
 
@@ -3531,7 +3585,7 @@ int	tgetflag(
 
 #undef tgetnum_sp
 int	tgetnum_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *id)
 		{ return(*(int *)0); }
 
@@ -3542,14 +3596,14 @@ int	tgetnum(
 
 #undef tgetstr_sp
 char	*tgetstr_sp(
-		SCREEN	*sp, 
-		const char *id, 
+		SCREEN	*sp,
+		const char *id,
 		char	**area)
 		{ return(*(char **)0); }
 
 #undef tgetstr
 char	*tgetstr(
-		const char *id, 
+		const char *id,
 		char	**area)
 		{ return(*(char **)0); }
 
@@ -3568,8 +3622,8 @@ char	*termname(void)
 
 #undef tgoto
 char	*tgoto(
-		const char *string, 
-		int	x, 
+		const char *string,
+		int	x,
 		int	y)
 		{ return(*(char **)0); }
 
@@ -3577,7 +3631,7 @@ char	*tgoto(
 
 #undef tigetflag_sp
 int	tigetflag_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -3588,7 +3642,7 @@ int	tigetflag(
 
 #undef tigetnum_sp
 int	tigetnum_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -3599,7 +3653,7 @@ int	tigetnum(
 
 #undef tigetstr_sp
 char	*tigetstr_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(char **)0); }
 
@@ -3613,32 +3667,58 @@ char	*tigetstr(
 #undef _nc_tparm_err
 int	_nc_tparm_err;
 
+#undef _nc_free_tparm
+void	_nc_free_tparm(
+		TERMINAL *termp)
+		{ /* void */ }
+
 #undef _nc_tparm_analyze
 int	_nc_tparm_analyze(
-		const char *string, 
-		char	*p_is_s[9], 
+		TERMINAL *term,
+		const char *string,
+		char	**p_is_s,
 		int	*_nc_popcount)
 		{ return(*(int *)0); }
 
 #undef tparm
 char	*tparm(
-		const char *string, 
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
 #undef tiparm
 char	*tiparm(
-		const char *string, 
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
+#undef tiparm_s
+char	*tiparm_s(
+		int	num_expected,
+		int	tparm_type,
+		const char *string,
+		...)
+		{ return(*(char **)0); }
+
+#undef tiscan_s
+int	tiscan_s(
+		int	*num_expected,
+		int	*tparm_type,
+		const char *string)
+		{ return(*(int *)0); }
+
 #undef _nc_tiparm
 char	*_nc_tiparm(
-		int	expected, 
-		const char *string, 
+		int	expected,
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
+#undef _nc_reset_tparm
+void	_nc_reset_tparm(
+		TERMINAL *term)
+		{ /* void */ }
+
 /* ./tinfo/lib_tputs.c */
 
 #undef PC
@@ -3655,7 +3735,7 @@ void	_nc_set_no_padding(
 
 #undef delay_output_sp
 int	delay_output_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ms)
 		{ return(*(int *)0); }
 
@@ -3675,7 +3755,7 @@ void	_nc_flush(void)
 
 #undef _nc_outch_sp
 int	_nc_outch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -3686,7 +3766,7 @@ int	_nc_outch(
 
 #undef _nc_putchar_sp
 int	_nc_putchar_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -3697,7 +3777,7 @@ int	_nc_putchar(
 
 #undef putp_sp
 int	putp_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *string)
 		{ return(*(int *)0); }
 
@@ -3708,35 +3788,35 @@ int	putp(
 
 #undef _nc_putp_sp
 int	_nc_putp_sp(
-		SCREEN	*sp, 
-		const char *name, 
+		SCREEN	*sp,
+		const char *name,
 		const char *string)
 		{ return(*(int *)0); }
 
 #undef _nc_putp
 int	_nc_putp(
-		const char *name, 
+		const char *name,
 		const char *string)
 		{ return(*(int *)0); }
 
 #undef tputs_sp
 int	tputs_sp(
-		SCREEN	*sp, 
-		const char *string, 
-		int	affcnt, 
+		SCREEN	*sp,
+		const char *string,
+		int	affcnt,
 		NCURSES_OUTC_sp outc)
 		{ return(*(int *)0); }
 
 #undef _nc_outc_wrapper
 int	_nc_outc_wrapper(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	c)
 		{ return(*(int *)0); }
 
 #undef tputs
 int	tputs(
-		const char *string, 
-		int	affcnt, 
+		const char *string,
+		int	affcnt,
 		int	(*outc)(
 		int	p1))
 		{ return(*(int *)0); }
@@ -3762,7 +3842,7 @@ void	trace(
 
 #undef _tracef
 void	_tracef(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ /* void */ }
 
@@ -3818,8 +3898,8 @@ WINDOW	*_nc_retrace_win(
 
 #undef _nc_fmt_funcptr
 char	*_nc_fmt_funcptr(
-		char	*target, 
-		const char *source, 
+		char	*target,
+		const char *source,
 		size_t	size)
 		{ return(*(char **)0); }
 
@@ -3827,7 +3907,7 @@ char	*_nc_fmt_funcptr(
 
 #undef _traceattr2
 char	*_traceattr2(
-		int	bufnum, 
+		int	bufnum,
 		chtype	newmode)
 		{ return(*(char **)0); }
 
@@ -3848,13 +3928,13 @@ attr_t	_nc_retrace_attr_t(
 
 #undef _nc_altcharset_name
 const char *_nc_altcharset_name(
-		attr_t	attr, 
+		attr_t	attr,
 		chtype	ch)
 		{ return(*(const char **)0); }
 
 #undef _tracechtype2
 char	*_tracechtype2(
-		int	bufnum, 
+		int	bufnum,
 		chtype	ch)
 		{ return(*(char **)0); }
 
@@ -3872,7 +3952,7 @@ chtype	_nc_retrace_chtype(
 
 #undef _nc_trace_ttymode
 char	*_nc_trace_ttymode(
-		struct termios *tty)
+		const struct termios *tty)
 		{ return(*(char **)0); }
 
 #undef _nc_tracebits
@@ -3883,7 +3963,7 @@ char	*_nc_tracebits(void)
 
 #undef _nc_tracechar
 char	*_nc_tracechar(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(char **)0); }
 
@@ -3896,7 +3976,7 @@ char	*_tracechar(
 
 #undef _nc_get_tty_mode_sp
 int	_nc_get_tty_mode_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		struct termios *buf)
 		{ return(*(int *)0); }
 
@@ -3907,7 +3987,7 @@ int	_nc_get_tty_mode(
 
 #undef _nc_set_tty_mode_sp
 int	_nc_set_tty_mode_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		struct termios *buf)
 		{ return(*(int *)0); }
 
@@ -3974,9 +4054,9 @@ int	resetty(void)
 
 #undef _nc_timed_wait
 int	_nc_timed_wait(
-		SCREEN	*sp, 
-		int	mode, 
-		int	milliseconds, 
+		SCREEN	*sp,
+		int	mode,
+		int	milliseconds,
 		int	*timeleft)
 		{ return(*(int *)0); }
 
@@ -3989,8 +4069,8 @@ char	*_nc_first_name(
 
 #undef _nc_name_match
 int	_nc_name_match(
-		const char *const namelst, 
-		const char *const name, 
+		const char *const namelst,
+		const char *const name,
 		const char *const delim)
 		{ return(*(int *)0); }
 
@@ -4013,14 +4093,14 @@ const char *const strfnames[] = {0};
 
 #undef _nc_set_buffer_sp
 void	_nc_set_buffer_sp(
-		SCREEN	*sp, 
-		FILE	*ofp, 
+		SCREEN	*sp,
+		FILE	*ofp,
 		int	buffered)
 		{ /* void */ }
 
 #undef _nc_set_buffer
 void	_nc_set_buffer(
-		FILE	*ofp, 
+		FILE	*ofp,
 		int	buffered)
 		{ /* void */ }
 
@@ -4028,67 +4108,67 @@ void	_nc_set_buffer(
 
 #undef _nc_init_termtype
 void	_nc_init_termtype(
-		TERMTYPE2 *const tp)
+		TERMTYPE *const tp)
 		{ /* void */ }
 
 #undef _nc_read_termtype
 int	_nc_read_termtype(
-		TERMTYPE2 *ptr, 
-		char	*buffer, 
+		TERMTYPE *ptr,
+		char	*buffer,
 		int	limit)
 		{ return(*(int *)0); }
 
 #undef _nc_read_file_entry
 int	_nc_read_file_entry(
-		const char *const filename, 
-		TERMTYPE2 *ptr)
+		const char *const filename,
+		TERMTYPE *ptr)
 		{ return(*(int *)0); }
 
 #undef _nc_read_entry
 int	_nc_read_entry(
-		const char *const name, 
-		char	*const filename, 
-		TERMTYPE2 *const tp)
+		const char *const name,
+		char	*const filename,
+		TERMTYPE *const tp)
 		{ return(*(int *)0); }
 
 /* ./tinfo/read_termcap.c */
 
 #undef _nc_read_termcap_entry
 int	_nc_read_termcap_entry(
-		const char *const tn, 
-		TERMTYPE2 *const tp)
+		const char *const tn,
+		TERMTYPE *const tp)
 		{ return(*(int *)0); }
 
 /* ./tinfo/strings.c */
 
 #undef _nc_str_init
 string_desc *_nc_str_init(
-		string_desc *dst, 
-		char	*src, 
+		string_desc *dst,
+		char	*src,
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_null
 string_desc *_nc_str_null(
-		string_desc *dst, 
+		string_desc *dst,
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_copy
 string_desc *_nc_str_copy(
-		string_desc *dst, 
-		string_desc *src)
+		string_desc *dst,
+		const string_desc *const src)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_safe_strcat
 NCURSES_BOOL _nc_safe_strcat(
-		string_desc *dst, 
+		string_desc *dst,
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_safe_strcpy
 NCURSES_BOOL _nc_safe_strcpy(
-		string_desc *dst, 
+		string_desc *dst,
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -4096,13 +4176,13 @@ NCURSES_BOOL _nc_safe_strcpy(
 
 #undef _nc_trace_buf
 char	*_nc_trace_buf(
-		int	bufnum, 
+		int	bufnum,
 		size_t	want)
 		{ return(*(char **)0); }
 
 #undef _nc_trace_bufcat
 char	*_nc_trace_bufcat(
-		int	bufnum, 
+		int	bufnum,
 		const char *value)
 		{ return(*(char **)0); }
 
@@ -4117,21 +4197,21 @@ void	_nc_trace_tries(
 
 #undef _nc_expand_try
 char	*_nc_expand_try(
-		TRIES	*tree, 
-		unsigned code, 
-		int	*count, 
+		TRIES	*tree,
+		unsigned code,
+		int	*count,
 		size_t	len)
 		{ return(*(char **)0); }
 
 #undef _nc_remove_key
 int	_nc_remove_key(
-		TRIES	**tree, 
+		TRIES	**tree,
 		unsigned code)
 		{ return(*(int *)0); }
 
 #undef _nc_remove_string
 int	_nc_remove_string(
-		TRIES	**tree, 
+		TRIES	**tree,
 		const char *string)
 		{ return(*(int *)0); }
 
@@ -4139,14 +4219,14 @@ int	_nc_remove_string(
 
 #undef _nc_trim_sgr0
 char	*_nc_trim_sgr0(
-		TERMTYPE2 *tp)
+		TERMTYPE *tp)
 		{ return(*(char **)0); }
 
 /* ./unctrl.c */
 
 #undef unctrl_sp
 const char *unctrl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		chtype	ch)
 		{ return(*(const char **)0); }
 
@@ -4159,7 +4239,7 @@ const char *unctrl(
 
 #undef _nc_visbuf2
 const char *_nc_visbuf2(
-		int	bufnum, 
+		int	bufnum,
 		const char *buf)
 		{ return(*(const char **)0); }
 
@@ -4170,20 +4250,20 @@ const char *_nc_visbuf(
 
 #undef _nc_visbufn
 const char *_nc_visbufn(
-		const char *buf, 
+		const char *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
 #undef _nc_viscbuf2
 const char *_nc_viscbuf2(
-		int	bufnum, 
-		const chtype *buf, 
+		int	bufnum,
+		const chtype *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
 #undef _nc_viscbuf
 const char *_nc_viscbuf(
-		const chtype *buf, 
+		const chtype *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
@@ -4201,18 +4281,18 @@ ENTRY	*_nc_copy_entry(
 
 #undef _nc_save_str
 char	*_nc_save_str(
-		const char *const string)
+		const char *string)
 		{ return(*(char **)0); }
 
 #undef _nc_wrap_entry
 void	_nc_wrap_entry(
-		ENTRY	*const ep, 
+		ENTRY	*const ep,
 		NCURSES_BOOL copy_strings)
 		{ /* void */ }
 
 #undef _nc_merge_entry
 void	_nc_merge_entry(
-		ENTRY	*const target, 
+		ENTRY	*const target,
 		ENTRY	*const source)
 		{ /* void */ }
 
@@ -4220,15 +4300,15 @@ void	_nc_merge_entry(
 
 #undef _nc_captoinfo
 char	*_nc_captoinfo(
-		const char *cap, 
-		const char *s, 
+		const char *cap,
+		const char *s,
 		int const parameterized)
 		{ return(*(char **)0); }
 
 #undef _nc_infotocap
 char	*_nc_infotocap(
-		const char *cap, 
-		const char *str, 
+		const char *cap,
+		const char *str,
 		int const parameterized)
 		{ return(*(char **)0); }
 
@@ -4236,8 +4316,8 @@ char	*_nc_infotocap(
 
 #undef _nc_tic_expand
 char	*_nc_tic_expand(
-		const char *srcp, 
-		NCURSES_BOOL tic_format, 
+		const char *srcp,
+		NCURSES_BOOL tic_format,
 		int	numbers)
 		{ return(*(char **)0); }
 
@@ -4245,28 +4325,28 @@ char	*_nc_tic_expand(
 
 #undef _nc_check_termtype2
 void	(*_nc_check_termtype2)(
-		TERMTYPE2 *p1, 
+		TERMTYPE *p1,
 		NCURSES_BOOL p2);
 
 #undef _nc_entry_match
 NCURSES_BOOL _nc_entry_match(
-		char	*n1, 
+		char	*n1,
 		char	*n2)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_read_entry_source
 void	_nc_read_entry_source(
-		FILE	*fp, 
-		char	*buf, 
-		int	literal, 
-		NCURSES_BOOL silent, 
+		FILE	*fp,
+		char	*buf,
+		int	literal,
+		NCURSES_BOOL silent,
 		NCURSES_BOOL (*hook)(
 		ENTRY	*p1))
 		{ /* void */ }
 
 #undef _nc_resolve_uses2
 int	_nc_resolve_uses2(
-		NCURSES_BOOL fullresolve, 
+		NCURSES_BOOL fullresolve,
 		NCURSES_BOOL literal)
 		{ return(*(int *)0); }
 
@@ -4291,7 +4371,7 @@ NCURSES_BOOL _nc_disable_period;
 
 #undef _nc_reset_input
 void	_nc_reset_input(
-		FILE	*fp, 
+		FILE	*fp,
 		char	*buf)
 		{ /* void */ }
 
@@ -4302,8 +4382,8 @@ int	_nc_get_token(
 
 #undef _nc_trans_string
 int	_nc_trans_string(
-		char	*ptr, 
-		char	*last)
+		char	*ptr,
+		const char *const last)
 		{ return(*(int *)0); }
 
 #undef _nc_push_token
@@ -4320,14 +4400,14 @@ void	_nc_panic_mode(
 
 #undef _nc_parse_entry
 int	_nc_parse_entry(
-		ENTRY	*entryp, 
-		int	literal, 
+		ENTRY	*entryp,
+		int	literal,
 		NCURSES_BOOL silent)
 		{ return(*(int *)0); }
 
 #undef _nc_capcmp
 int	_nc_capcmp(
-		const char *s, 
+		const char *s,
 		const char *t)
 		{ return(*(int *)0); }
 
@@ -4340,14 +4420,14 @@ void	_nc_set_writedir(
 
 #undef _nc_write_entry
 void	_nc_write_entry(
-		TERMTYPE2 *const tp)
+		TERMTYPE *const tp)
 		{ /* void */ }
 
 #undef _nc_write_object
 int	_nc_write_object(
-		TERMTYPE2 *tp, 
-		char	*buffer, 
-		unsigned *offset, 
+		TERMTYPE *tp,
+		char	*buffer,
+		unsigned *offset,
 		unsigned limit)
 		{ return(*(int *)0); }
 
@@ -4359,14 +4439,14 @@ int	_nc_tic_written(void)
 
 #undef define_key_sp
 int	define_key_sp(
-		SCREEN	*sp, 
-		const char *str, 
+		SCREEN	*sp,
+		const char *str,
 		int	keycode)
 		{ return(*(int *)0); }
 
 #undef define_key
 int	define_key(
-		const char *str, 
+		const char *str,
 		int	keycode)
 		{ return(*(int *)0); }
 
@@ -4380,7 +4460,7 @@ void	_nc_hashed_db(void)
 
 #undef key_defined_sp
 int	key_defined_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -4393,14 +4473,14 @@ int	key_defined(
 
 #undef keybound_sp
 char	*keybound_sp(
-		SCREEN	*sp, 
-		int	code, 
+		SCREEN	*sp,
+		int	code,
 		int	count)
 		{ return(*(char **)0); }
 
 #undef keybound
 char	*keybound(
-		int	code, 
+		int	code,
 		int	count)
 		{ return(*(char **)0); }
 
@@ -4408,14 +4488,14 @@ char	*keybound(
 
 #undef keyok_sp
 int	keyok_sp(
-		SCREEN	*sp, 
-		int	c, 
+		SCREEN	*sp,
+		int	c,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef keyok
 int	keyok(
-		int	c, 
+		int	c,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
diff --git a/contrib/ncurses/ncurses/llib-lncursest b/contrib/ncurses/ncurses/llib-lncursest
index 36a94b57297e..7c8bac9c4076 100644
--- a/contrib/ncurses/ncurses/llib-lncursest
+++ b/contrib/ncurses/ncurses/llib-lncursest
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 2019-2022,2023 Thomas E. Dickey                                *
  * Copyright 2008-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -70,7 +70,7 @@ void	_nc_hash_map(void)
 
 #undef _nc_make_oldhash_sp
 void	_nc_make_oldhash_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	i)
 		{ /* void */ }
 
@@ -81,16 +81,16 @@ void	_nc_make_oldhash(
 
 #undef _nc_scroll_oldhash_sp
 void	_nc_scroll_oldhash_sp(
-		SCREEN	*sp, 
-		int	n, 
-		int	top, 
+		SCREEN	*sp,
+		int	n,
+		int	top,
 		int	bot)
 		{ /* void */ }
 
 #undef _nc_scroll_oldhash
 void	_nc_scroll_oldhash(
-		int	n, 
-		int	top, 
+		int	n,
+		int	top,
 		int	bot)
 		{ /* void */ }
 
@@ -98,25 +98,25 @@ void	_nc_scroll_oldhash(
 
 #undef _nc_render
 chtype	_nc_render(
-		WINDOW	*win, 
+		WINDOW	*win,
 		chtype	ch)
 		{ return(*(chtype *)0); }
 
 #undef _nc_waddch_nosync
 int	_nc_waddch_nosync(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const chtype c)
 		{ return(*(int *)0); }
 
 #undef waddch
 int	waddch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const chtype ch)
 		{ return(*(int *)0); }
 
 #undef wechochar
 int	wechochar(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const chtype ch)
 		{ return(*(int *)0); }
 
@@ -124,15 +124,15 @@ int	wechochar(
 
 #undef waddnstr
 int	waddnstr(
-		WINDOW	*win, 
-		const char *astr, 
+		WINDOW	*win,
+		const char *astr,
 		int	n)
 		{ return(*(int *)0); }
 
 #undef waddchnstr
 int	waddchnstr(
-		WINDOW	*win, 
-		const chtype *astr, 
+		WINDOW	*win,
+		const chtype *astr,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -151,13 +151,13 @@ int	beep(void)
 
 #undef wbkgdset
 void	wbkgdset(
-		WINDOW	*win, 
+		WINDOW	*win,
 		chtype	ch)
 		{ /* void */ }
 
 #undef wbkgd
 int	wbkgd(
-		WINDOW	*win, 
+		WINDOW	*win,
 		chtype	ch)
 		{ return(*(int *)0); }
 
@@ -165,14 +165,14 @@ int	wbkgd(
 
 #undef wborder
 int	wborder(
-		WINDOW	*win, 
-		chtype	ls, 
-		chtype	rs, 
-		chtype	ts, 
-		chtype	bs, 
-		chtype	tl, 
-		chtype	tr, 
-		chtype	bl, 
+		WINDOW	*win,
+		chtype	ls,
+		chtype	rs,
+		chtype	ts,
+		chtype	bs,
+		chtype	tl,
+		chtype	tr,
+		chtype	bl,
 		chtype	br)
 		{ return(*(int *)0); }
 
@@ -180,10 +180,10 @@ int	wborder(
 
 #undef wchgat
 int	wchgat(
-		WINDOW	*win, 
-		int	n, 
-		attr_t	attr, 
-		short	pair_arg, 
+		WINDOW	*win,
+		int	n,
+		attr_t	attr,
+		short	pair_arg,
 		const void *opts)
 		{ return(*(int *)0); }
 
@@ -198,7 +198,7 @@ int	wclear(
 
 #undef clearok
 int	clearok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
@@ -246,62 +246,62 @@ int	start_color(void)
 
 #undef _nc_change_pair
 void	_nc_change_pair(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	pair)
 		{ /* void */ }
 
 #undef _nc_reserve_pairs
 void	_nc_reserve_pairs(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	want)
 		{ /* void */ }
 
 #undef _nc_init_pair
 int	_nc_init_pair(
-		SCREEN	*sp, 
-		int	pair, 
-		int	f, 
+		SCREEN	*sp,
+		int	pair,
+		int	f,
 		int	b)
 		{ return(*(int *)0); }
 
 #undef init_pair_sp
 int	init_pair_sp(
-		SCREEN	*sp, 
-		short	pair, 
-		short	f, 
+		SCREEN	*sp,
+		short	pair,
+		short	f,
 		short	b)
 		{ return(*(int *)0); }
 
 #undef init_pair
 int	init_pair(
-		short	pair, 
-		short	f, 
+		short	pair,
+		short	f,
 		short	b)
 		{ return(*(int *)0); }
 
 #undef _nc_init_color
 int	_nc_init_color(
-		SCREEN	*sp, 
-		int	color, 
-		int	r, 
-		int	g, 
+		SCREEN	*sp,
+		int	color,
+		int	r,
+		int	g,
 		int	b)
 		{ return(*(int *)0); }
 
 #undef init_color_sp
 int	init_color_sp(
-		SCREEN	*sp, 
-		short	color, 
-		short	r, 
-		short	g, 
+		SCREEN	*sp,
+		short	color,
+		short	r,
+		short	g,
 		short	b)
 		{ return(*(int *)0); }
 
 #undef init_color
 int	init_color(
-		short	color, 
-		short	r, 
-		short	g, 
+		short	color,
+		short	r,
+		short	g,
 		short	b)
 		{ return(*(int *)0); }
 
@@ -325,58 +325,58 @@ NCURSES_BOOL has_colors(void)
 
 #undef color_content_sp
 int	color_content_sp(
-		SCREEN	*sp, 
-		short	color, 
-		short	*r, 
-		short	*g, 
+		SCREEN	*sp,
+		short	color,
+		short	*r,
+		short	*g,
 		short	*b)
 		{ return(*(int *)0); }
 
 #undef color_content
 int	color_content(
-		short	color, 
-		short	*r, 
-		short	*g, 
+		short	color,
+		short	*r,
+		short	*g,
 		short	*b)
 		{ return(*(int *)0); }
 
 #undef _nc_pair_content
 int	_nc_pair_content(
-		SCREEN	*sp, 
-		int	pair, 
-		int	*f, 
+		SCREEN	*sp,
+		int	pair,
+		int	*f,
 		int	*b)
 		{ return(*(int *)0); }
 
 #undef pair_content_sp
 int	pair_content_sp(
-		SCREEN	*sp, 
-		short	pair, 
-		short	*f, 
+		SCREEN	*sp,
+		short	pair,
+		short	*f,
 		short	*b)
 		{ return(*(int *)0); }
 
 #undef pair_content
 int	pair_content(
-		short	pair, 
-		short	*f, 
+		short	pair,
+		short	*f,
 		short	*b)
 		{ return(*(int *)0); }
 
 #undef _nc_do_color_sp
 void	_nc_do_color_sp(
-		SCREEN	*sp, 
-		int	old_pair, 
-		int	pair, 
-		int	reverse, 
+		SCREEN	*sp,
+		int	old_pair,
+		int	pair,
+		int	reverse,
 		NCURSES_OUTC_sp outc)
 		{ /* void */ }
 
 #undef _nc_do_color
 void	_nc_do_color(
-		int	old_pair, 
-		int	pair, 
-		int	reverse, 
+		int	old_pair,
+		int	pair,
+		int	reverse,
 		NCURSES_OUTC outc)
 		{ /* void */ }
 
@@ -384,8 +384,8 @@ void	_nc_do_color(
 
 #undef wcolor_set
 int	wcolor_set(
-		WINDOW	*win, 
-		short	pair_arg, 
+		WINDOW	*win,
+		short	pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -461,7 +461,7 @@ int	addch(
 
 #undef addchnstr
 int	addchnstr(
-		const chtype *a1, 
+		const chtype *a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -472,7 +472,7 @@ int	addchstr(
 
 #undef addnstr
 int	addnstr(
-		const char *a1, 
+		const char *a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -483,42 +483,42 @@ int	addstr(
 
 #undef attroff
 int	attroff(
-		int	z)
+		NCURSES_ATTR_T	z)
 		{ return(*(int *)0); }
 
 #undef attron
 int	attron(
-		int	z)
+		NCURSES_ATTR_T	z)
 		{ return(*(int *)0); }
 
 #undef attrset
 int	attrset(
-		int	z)
+		NCURSES_ATTR_T	z)
 		{ return(*(int *)0); }
 
 #undef attr_get
 int	attr_get(
-		attr_t	*a1, 
-		short	*a2, 
+		attr_t	*a1,
+		short	*a2,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef attr_off
 int	attr_off(
-		attr_t	a1, 
+		attr_t	a1,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef attr_on
 int	attr_on(
-		attr_t	a1, 
+		attr_t	a1,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef attr_set
 int	attr_set(
-		attr_t	a1, 
-		short	a2, 
+		attr_t	a1,
+		short	a2,
 		void	*z)
 		{ return(*(int *)0); }
 
@@ -534,28 +534,28 @@ void	bkgdset(
 
 #undef border
 int	border(
-		chtype	a1, 
-		chtype	a2, 
-		chtype	a3, 
-		chtype	a4, 
-		chtype	a5, 
-		chtype	a6, 
-		chtype	a7, 
+		chtype	a1,
+		chtype	a2,
+		chtype	a3,
+		chtype	a4,
+		chtype	a5,
+		chtype	a6,
+		chtype	a7,
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef box
 int	box(
-		WINDOW	*a1, 
-		chtype	a2, 
+		WINDOW	*a1,
+		chtype	a2,
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef chgat
 int	chgat(
-		int	a1, 
-		attr_t	a2, 
-		short	a3, 
+		int	a1,
+		attr_t	a2,
+		short	a3,
 		const void *z)
 		{ return(*(int *)0); }
 
@@ -573,7 +573,7 @@ int	clrtoeol(void)
 
 #undef color_set
 int	color_set(
-		short	a1, 
+		short	a1,
 		void	*z)
 		{ return(*(int *)0); }
 
@@ -610,7 +610,7 @@ int	getch(void)
 
 #undef getnstr
 int	getnstr(
-		char	*a1, 
+		char	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -621,7 +621,7 @@ int	getstr(
 
 #undef hline
 int	hline(
-		chtype	a1, 
+		chtype	a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -631,7 +631,7 @@ chtype	inch(void)
 
 #undef inchnstr
 int	inchnstr(
-		chtype	*a1, 
+		chtype	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -642,7 +642,7 @@ int	inchstr(
 
 #undef innstr
 int	innstr(
-		char	*a1, 
+		char	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -662,7 +662,7 @@ int	insertln(void)
 
 #undef insnstr
 int	insnstr(
-		const char *a1, 
+		const char *a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -678,323 +678,323 @@ int	instr(
 
 #undef move
 int	move(
-		int	a1, 
+		int	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddch
 int	mvaddch(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		const chtype z)
 		{ return(*(int *)0); }
 
 #undef mvaddchnstr
 int	mvaddchnstr(
-		int	a1, 
-		int	a2, 
-		const chtype *a3, 
+		int	a1,
+		int	a2,
+		const chtype *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddchstr
 int	mvaddchstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		const chtype *z)
 		{ return(*(int *)0); }
 
 #undef mvaddnstr
 int	mvaddnstr(
-		int	a1, 
-		int	a2, 
-		const char *a3, 
+		int	a1,
+		int	a2,
+		const char *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddstr
 int	mvaddstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvchgat
 int	mvchgat(
-		int	a1, 
-		int	a2, 
-		int	a3, 
-		attr_t	a4, 
-		short	a5, 
+		int	a1,
+		int	a2,
+		int	a3,
+		attr_t	a4,
+		short	a5,
 		const void *z)
 		{ return(*(int *)0); }
 
 #undef mvdelch
 int	mvdelch(
-		int	a1, 
+		int	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvgetch
 int	mvgetch(
-		int	a1, 
+		int	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvgetnstr
 int	mvgetnstr(
-		int	a1, 
-		int	a2, 
-		char	*a3, 
+		int	a1,
+		int	a2,
+		char	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvgetstr
 int	mvgetstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvhline
 int	mvhline(
-		int	a1, 
-		int	a2, 
-		chtype	a3, 
+		int	a1,
+		int	a2,
+		chtype	a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinch
 chtype	mvinch(
-		int	a1, 
+		int	a1,
 		int	z)
 		{ return(*(chtype *)0); }
 
 #undef mvinchnstr
 int	mvinchnstr(
-		int	a1, 
-		int	a2, 
-		chtype	*a3, 
+		int	a1,
+		int	a2,
+		chtype	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinchstr
 int	mvinchstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		chtype	*z)
 		{ return(*(int *)0); }
 
 #undef mvinnstr
 int	mvinnstr(
-		int	a1, 
-		int	a2, 
-		char	*a3, 
+		int	a1,
+		int	a2,
+		char	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinsch
 int	mvinsch(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef mvinsnstr
 int	mvinsnstr(
-		int	a1, 
-		int	a2, 
-		const char *a3, 
+		int	a1,
+		int	a2,
+		const char *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinsstr
 int	mvinsstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvinstr
 int	mvinstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvvline
 int	mvvline(
-		int	a1, 
-		int	a2, 
-		chtype	a3, 
+		int	a1,
+		int	a2,
+		chtype	a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddch
 int	mvwaddch(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const chtype z)
 		{ return(*(int *)0); }
 
 #undef mvwaddchnstr
 int	mvwaddchnstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const chtype *a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const chtype *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddchstr
 int	mvwaddchstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const chtype *z)
 		{ return(*(int *)0); }
 
 #undef mvwaddnstr
 int	mvwaddnstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const char *a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const char *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddstr
 int	mvwaddstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvwchgat
 int	mvwchgat(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		int	a4, 
-		attr_t	a5, 
-		short	a6, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		int	a4,
+		attr_t	a5,
+		short	a6,
 		const void *z)
 		{ return(*(int *)0); }
 
 #undef mvwdelch
 int	mvwdelch(
-		WINDOW	*a1, 
-		int	a2, 
+		WINDOW	*a1,
+		int	a2,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwgetch
 int	mvwgetch(
-		WINDOW	*a1, 
-		int	a2, 
+		WINDOW	*a1,
+		int	a2,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwgetnstr
 int	mvwgetnstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		char	*a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		char	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwgetstr
 int	mvwgetstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvwhline
 int	mvwhline(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		chtype	a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		chtype	a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinch
 chtype	mvwinch(
-		WINDOW	*a1, 
-		int	a2, 
+		WINDOW	*a1,
+		int	a2,
 		int	z)
 		{ return(*(chtype *)0); }
 
 #undef mvwinchnstr
 int	mvwinchnstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		chtype	*a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		chtype	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinchstr
 int	mvwinchstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		chtype	*z)
 		{ return(*(int *)0); }
 
 #undef mvwinnstr
 int	mvwinnstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		char	*a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		char	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinsch
 int	mvwinsch(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef mvwinsnstr
 int	mvwinsnstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const char *a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const char *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinsstr
 int	mvwinsstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvwinstr
 int	mvwinstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvwvline
 int	mvwvline(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		chtype	a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		chtype	a4,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -1024,7 +1024,7 @@ int	scroll(
 
 #undef setscrreg
 int	setscrreg(
-		int	a1, 
+		int	a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -1043,8 +1043,8 @@ void	timeout(
 
 #undef touchline
 int	touchline(
-		WINDOW	*a1, 
-		int	a2, 
+		WINDOW	*a1,
+		int	a2,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -1060,53 +1060,53 @@ int	untouchwin(
 
 #undef vline
 int	vline(
-		chtype	a1, 
+		chtype	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef waddchstr
 int	waddchstr(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		const chtype *z)
 		{ return(*(int *)0); }
 
 #undef waddstr
 int	waddstr(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef wattron
 int	wattron(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wattroff
 int	wattroff(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wattrset
 int	wattrset(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wattr_get
 int	wattr_get(
-		WINDOW	*a1, 
-		attr_t	*a2, 
-		short	*a3, 
+		WINDOW	*a1,
+		attr_t	*a2,
+		short	*a3,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef wattr_set
 int	wattr_set(
-		WINDOW	*a1, 
-		attr_t	a2, 
-		short	a3, 
+		WINDOW	*a1,
+		attr_t	a2,
+		short	a3,
 		void	*z)
 		{ return(*(int *)0); }
 
@@ -1117,13 +1117,13 @@ int	wdeleteln(
 
 #undef wgetstr
 int	wgetstr(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef winchstr
 int	winchstr(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		chtype	*z)
 		{ return(*(int *)0); }
 
@@ -1134,13 +1134,13 @@ int	winsertln(
 
 #undef winsstr
 int	winsstr(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef winstr
 int	winstr(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		char	*z)
 		{ return(*(int *)0); }
 
@@ -1271,15 +1271,15 @@ int	wgetdelay(
 
 #undef wgetscrreg
 int	wgetscrreg(
-		const WINDOW *a1, 
-		int	*a2, 
+		const WINDOW *a1,
+		int	*a2,
 		int	*z)
 		{ return(*(int *)0); }
 
 #undef mouse_trafo
 NCURSES_BOOL mouse_trafo(
-		int	*a1, 
-		int	*a2, 
+		int	*a1,
+		int	*a2,
 		NCURSES_BOOL z)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -1296,7 +1296,7 @@ int	*_nc_ptr_Escdelay(
 
 #undef set_escdelay_sp
 int	set_escdelay_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	value)
 		{ return(*(int *)0); }
 
@@ -1316,8 +1316,8 @@ int	get_escdelay(void)
 
 #undef _nc_wgetch
 int	_nc_wgetch(
-		WINDOW	*win, 
-		int	*result, 
+		WINDOW	*win,
+		int	*result,
 		int	use_meta)
 		{ return(*(int *)0); }
 
@@ -1330,8 +1330,8 @@ int	wgetch(
 
 #undef wgetnstr
 int	wgetnstr(
-		WINDOW	*win, 
-		char	*str, 
+		WINDOW	*win,
+		char	*str,
 		int	maxlen)
 		{ return(*(int *)0); }
 
@@ -1339,8 +1339,8 @@ int	wgetnstr(
 
 #undef whline
 int	whline(
-		WINDOW	*win, 
-		chtype	ch, 
+		WINDOW	*win,
+		chtype	ch,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1348,7 +1348,7 @@ int	whline(
 
 #undef immedok
 void	immedok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ /* void */ }
 
@@ -1356,8 +1356,8 @@ void	immedok(
 
 #undef winchnstr
 int	winchnstr(
-		WINDOW	*win, 
-		chtype	*str, 
+		WINDOW	*win,
+		chtype	*str,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1371,14 +1371,14 @@ WINDOW	*initscr(void)
 
 #undef _nc_insert_ch
 int	_nc_insert_ch(
-		SCREEN	*sp, 
-		WINDOW	*win, 
+		SCREEN	*sp,
+		WINDOW	*win,
 		chtype	ch)
 		{ return(*(int *)0); }
 
 #undef winsch
 int	winsch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		chtype	c)
 		{ return(*(int *)0); }
 
@@ -1386,7 +1386,7 @@ int	winsch(
 
 #undef winsdelln
 int	winsdelln(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1394,8 +1394,8 @@ int	winsdelln(
 
 #undef winsnstr
 int	winsnstr(
-		WINDOW	*win, 
-		const char *s, 
+		WINDOW	*win,
+		const char *s,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1403,8 +1403,8 @@ int	winsnstr(
 
 #undef winnstr
 int	winnstr(
-		WINDOW	*win, 
-		char	*str, 
+		WINDOW	*win,
+		char	*str,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1423,7 +1423,7 @@ NCURSES_BOOL isendwin(void)
 
 #undef leaveok
 int	leaveok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
@@ -1431,7 +1431,7 @@ int	leaveok(
 
 #undef getmouse_sp
 int	getmouse_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		MEVENT	*aevent)
 		{ return(*(int *)0); }
 
@@ -1442,7 +1442,7 @@ int	getmouse(
 
 #undef ungetmouse_sp
 int	ungetmouse_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		MEVENT	*aevent)
 		{ return(*(int *)0); }
 
@@ -1453,27 +1453,27 @@ int	ungetmouse(
 
 #undef mousemask_sp
 mmask_t	mousemask_sp(
-		SCREEN	*sp, 
-		mmask_t	newmask, 
+		SCREEN	*sp,
+		mmask_t	newmask,
 		mmask_t	*oldmask)
 		{ return(*(mmask_t *)0); }
 
 #undef mousemask
 mmask_t	mousemask(
-		mmask_t	newmask, 
+		mmask_t	newmask,
 		mmask_t	*oldmask)
 		{ return(*(mmask_t *)0); }
 
 #undef wenclose
 NCURSES_BOOL wenclose(
-		const WINDOW *win, 
-		int	y, 
+		const WINDOW *win,
+		int	y,
 		int	x)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef mouseinterval_sp
 int	mouseinterval_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	maxclick)
 		{ return(*(int *)0); }
 
@@ -1498,9 +1498,9 @@ NCURSES_BOOL has_mouse(void)
 
 #undef wmouse_trafo
 NCURSES_BOOL wmouse_trafo(
-		const WINDOW *win, 
-		int	*pY, 
-		int	*pX, 
+		const WINDOW *win,
+		int	*pY,
+		int	*pX,
 		NCURSES_BOOL to_screen)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -1508,8 +1508,8 @@ NCURSES_BOOL wmouse_trafo(
 
 #undef wmove
 int	wmove(
-		WINDOW	*win, 
-		int	y, 
+		WINDOW	*win,
+		int	y,
 		int	x)
 		{ return(*(int *)0); }
 
@@ -1517,14 +1517,14 @@ int	wmove(
 
 #undef _nc_msec_cost_sp
 int	_nc_msec_cost_sp(
-		SCREEN	*sp, 
-		const char *const cap, 
+		SCREEN	*sp,
+		const char *const cap,
 		int	affcnt)
 		{ return(*(int *)0); }
 
 #undef _nc_msec_cost
 int	_nc_msec_cost(
-		const char *const cap, 
+		const char *const cap,
 		int	affcnt)
 		{ return(*(int *)0); }
 
@@ -1557,35 +1557,35 @@ void	_nc_mvcur_wrap(void)
 
 #undef _nc_mvcur_sp
 int	_nc_mvcur_sp(
-		SCREEN	*sp, 
-		int	yold, 
-		int	xold, 
-		int	ynew, 
+		SCREEN	*sp,
+		int	yold,
+		int	xold,
+		int	ynew,
 		int	xnew)
 		{ return(*(int *)0); }
 
 #undef _nc_mvcur
 int	_nc_mvcur(
-		int	yold, 
-		int	xold, 
-		int	ynew, 
+		int	yold,
+		int	xold,
+		int	ynew,
 		int	xnew)
 		{ return(*(int *)0); }
 
 #undef mvcur_sp
 int	mvcur_sp(
-		SCREEN	*sp, 
-		int	yold, 
-		int	xold, 
-		int	ynew, 
+		SCREEN	*sp,
+		int	yold,
+		int	xold,
+		int	ynew,
 		int	xnew)
 		{ return(*(int *)0); }
 
 #undef mvcur
 int	mvcur(
-		int	yold, 
-		int	xold, 
-		int	ynew, 
+		int	yold,
+		int	xold,
+		int	ynew,
 		int	xnew)
 		{ return(*(int *)0); }
 
@@ -1596,8 +1596,8 @@ int	_nc_optimize_enable;
 
 #undef mvwin
 int	mvwin(
-		WINDOW	*win, 
-		int	by, 
+		WINDOW	*win,
+		int	by,
 		int	bx)
 		{ return(*(int *)0); }
 
@@ -1623,16 +1623,16 @@ void	nofilter(void)
 
 #undef newterm_sp
 SCREEN	*newterm_sp(
-		SCREEN	*sp, 
-		const char *name, 
-		FILE	*ofp, 
+		SCREEN	*sp,
+		const char *name,
+		FILE	*ofp,
 		FILE	*ifp)
 		{ return(*(SCREEN **)0); }
 
 #undef newterm
 SCREEN	*newterm(
-		const char *name, 
-		FILE	*ofp, 
+		const char *name,
+		FILE	*ofp,
 		FILE	*ifp)
 		{ return(*(SCREEN **)0); }
 
@@ -1645,46 +1645,46 @@ int	_nc_freewin(
 
 #undef newwin_sp
 WINDOW	*newwin_sp(
-		SCREEN	*sp, 
-		int	num_lines, 
-		int	num_columns, 
-		int	begy, 
+		SCREEN	*sp,
+		int	num_lines,
+		int	num_columns,
+		int	begy,
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef newwin
 WINDOW	*newwin(
-		int	num_lines, 
-		int	num_columns, 
-		int	begy, 
+		int	num_lines,
+		int	num_columns,
+		int	begy,
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef derwin
 WINDOW	*derwin(
-		WINDOW	*orig, 
-		int	num_lines, 
-		int	num_columns, 
-		int	begy, 
+		WINDOW	*orig,
+		int	num_lines,
+		int	num_columns,
+		int	begy,
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef subwin
 WINDOW	*subwin(
-		WINDOW	*w, 
-		int	l, 
-		int	c, 
-		int	y, 
+		WINDOW	*w,
+		int	l,
+		int	c,
+		int	y,
 		int	x)
 		{ return(*(WINDOW **)0); }
 
 #undef _nc_makenew_sp
 WINDOW	*_nc_makenew_sp(
-		SCREEN	*sp, 
-		int	num_lines, 
-		int	num_columns, 
-		int	begy, 
-		int	begx, 
+		SCREEN	*sp,
+		int	num_lines,
+		int	num_columns,
+		int	begy,
+		int	begx,
 		int	flags)
 		{ return(*(WINDOW **)0); }
 
@@ -1727,26 +1727,26 @@ int	nonl(void)
 
 #undef overlay
 int	overlay(
-		const WINDOW *win1, 
+		const WINDOW *win1,
 		WINDOW	*win2)
 		{ return(*(int *)0); }
 
 #undef overwrite
 int	overwrite(
-		const WINDOW *win1, 
+		const WINDOW *win1,
 		WINDOW	*win2)
 		{ return(*(int *)0); }
 
 #undef copywin
 int	copywin(
-		const WINDOW *src, 
-		WINDOW	*dst, 
-		int	sminrow, 
-		int	smincol, 
-		int	dminrow, 
-		int	dmincol, 
-		int	dmaxrow, 
-		int	dmaxcol, 
+		const WINDOW *src,
+		WINDOW	*dst,
+		int	sminrow,
+		int	smincol,
+		int	dminrow,
+		int	dmincol,
+		int	dmaxrow,
+		int	dmaxcol,
 		int	over)
 		{ return(*(int *)0); }
 
@@ -1754,51 +1754,51 @@ int	copywin(
 
 #undef newpad_sp
 WINDOW	*newpad_sp(
-		SCREEN	*sp, 
-		int	l, 
+		SCREEN	*sp,
+		int	l,
 		int	c)
 		{ return(*(WINDOW **)0); }
 
 #undef newpad
 WINDOW	*newpad(
-		int	l, 
+		int	l,
 		int	c)
 		{ return(*(WINDOW **)0); }
 
 #undef subpad
 WINDOW	*subpad(
-		WINDOW	*orig, 
-		int	l, 
-		int	c, 
-		int	begy, 
+		WINDOW	*orig,
+		int	l,
+		int	c,
+		int	begy,
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef prefresh
 int	prefresh(
-		WINDOW	*win, 
-		int	pminrow, 
-		int	pmincol, 
-		int	sminrow, 
-		int	smincol, 
-		int	smaxrow, 
+		WINDOW	*win,
+		int	pminrow,
+		int	pmincol,
+		int	sminrow,
+		int	smincol,
+		int	smaxrow,
 		int	smaxcol)
 		{ return(*(int *)0); }
 
 #undef pnoutrefresh
 int	pnoutrefresh(
-		WINDOW	*win, 
-		int	pminrow, 
-		int	pmincol, 
-		int	sminrow, 
-		int	smincol, 
-		int	smaxrow, 
+		WINDOW	*win,
+		int	pminrow,
+		int	pmincol,
+		int	sminrow,
+		int	smincol,
+		int	smaxrow,
 		int	smaxcol)
 		{ return(*(int *)0); }
 
 #undef pechochar
 int	pechochar(
-		WINDOW	*pad, 
+		WINDOW	*pad,
 		const chtype ch)
 		{ return(*(int *)0); }
 
@@ -1806,45 +1806,45 @@ int	pechochar(
 
 #undef printw
 int	printw(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef wprintw
 int	wprintw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef mvprintw
 int	mvprintw(
-		int	y, 
-		int	x, 
-		const char *fmt, 
+		int	y,
+		int	x,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef mvwprintw
 int	mvwprintw(
-		WINDOW	*win, 
-		int	y, 
-		int	x, 
-		const char *fmt, 
+		WINDOW	*win,
+		int	y,
+		int	x,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef vwprintw
 int	vwprintw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
 		va_list	argp)
 		{ return(*(int *)0); }
 
 #undef vw_printw
 int	vw_printw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
 		va_list	argp)
 		{ return(*(int *)0); }
 
@@ -1852,8 +1852,8 @@ int	vw_printw(
 
 #undef wredrawln
 int	wredrawln(
-		WINDOW	*win, 
-		int	beg, 
+		WINDOW	*win,
+		int	beg,
 		int	num)
 		{ return(*(int *)0); }
 
@@ -1873,16 +1873,16 @@ int	wnoutrefresh(
 
 #undef restartterm_sp
 int	restartterm_sp(
-		SCREEN	*sp, 
-		const char *termp, 
-		int	filenum, 
+		SCREEN	*sp,
+		const char *termp,
+		int	filenum,
 		int	*errret)
 		{ return(*(int *)0); }
 
 #undef restartterm
 int	restartterm(
-		const char *termp, 
-		int	filenum, 
+		const char *termp,
+		int	filenum,
 		int	*errret)
 		{ return(*(int *)0); }
 
@@ -1890,45 +1890,45 @@ int	restartterm(
 
 #undef vwscanw
 int	vwscanw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
 		va_list	argp)
 		{ return(*(int *)0); }
 
 #undef vw_scanw
 int	vw_scanw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
 		va_list	argp)
 		{ return(*(int *)0); }
 
 #undef scanw
 int	scanw(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef wscanw
 int	wscanw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef mvscanw
 int	mvscanw(
-		int	y, 
-		int	x, 
-		const char *fmt, 
+		int	y,
+		int	x,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef mvwscanw
 int	mvwscanw(
-		WINDOW	*win, 
-		int	y, 
-		int	x, 
-		const char *fmt, 
+		WINDOW	*win,
+		int	y,
+		int	x,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
@@ -1936,7 +1936,7 @@ int	mvwscanw(
 
 #undef getwin_sp
 WINDOW	*getwin_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		FILE	*filep)
 		{ return(*(WINDOW **)0); }
 
@@ -1947,13 +1947,13 @@ WINDOW	*getwin(
 
 #undef putwin
 int	putwin(
-		WINDOW	*win, 
+		WINDOW	*win,
 		FILE	*filep)
 		{ return(*(int *)0); }
 
 #undef scr_restore_sp
 int	scr_restore_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *file)
 		{ return(*(int *)0); }
 
@@ -1969,7 +1969,7 @@ int	scr_dump(
 
 #undef scr_init_sp
 int	scr_init_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *file)
 		{ return(*(int *)0); }
 
@@ -1980,7 +1980,7 @@ int	scr_init(
 
 #undef scr_set_sp
 int	scr_set_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *file)
 		{ return(*(int *)0); }
 
@@ -1993,16 +1993,16 @@ int	scr_set(
 
 #undef _nc_scroll_window
 void	_nc_scroll_window(
-		WINDOW	*win, 
-		int const n, 
-		int const top, 
-		int const bottom, 
+		WINDOW	*win,
+		int const n,
+		int const top,
+		int const bottom,
 		chtype	blank)
 		{ /* void */ }
 
 #undef wscrl
 int	wscrl(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -2010,7 +2010,7 @@ int	wscrl(
 
 #undef scrollok
 int	scrollok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
@@ -2018,8 +2018,8 @@ int	scrollok(
 
 #undef wsetscrreg
 int	wsetscrreg(
-		WINDOW	*win, 
-		int	top, 
+		WINDOW	*win,
+		int	top,
 		int	bottom)
 		{ return(*(int *)0); }
 
@@ -2037,54 +2037,54 @@ void	delscreen(
 
 #undef _nc_setupscreen_sp
 int	_nc_setupscreen_sp(
-		SCREEN	**spp, 
-		int	slines, 
-		int	scolumns, 
-		FILE	*output, 
-		int	filtered, 
+		SCREEN	**spp,
+		int	slines,
+		int	scolumns,
+		FILE	*output,
+		int	filtered,
 		int	slk_format)
 		{ return(*(int *)0); }
 
 #undef _nc_setupscreen
 int	_nc_setupscreen(
-		int	slines, 
-		int	scolumns, 
-		FILE	*output, 
-		int	filtered, 
+		int	slines,
+		int	scolumns,
+		FILE	*output,
+		int	filtered,
 		int	slk_format)
 		{ return(*(int *)0); }
 
 #undef _nc_ripoffline_sp
 int	_nc_ripoffline_sp(
-		SCREEN	*sp, 
-		int	line, 
+		SCREEN	*sp,
+		int	line,
 		int	(*init)(
-		WINDOW	*p1, 
+		WINDOW	*p1,
 		int	p2))
 		{ return(*(int *)0); }
 
 #undef _nc_ripoffline
 int	_nc_ripoffline(
-		int	line, 
+		int	line,
 		int	(*init)(
-		WINDOW	*p1, 
+		WINDOW	*p1,
 		int	p2))
 		{ return(*(int *)0); }
 
 #undef ripoffline_sp
 int	ripoffline_sp(
-		SCREEN	*sp, 
-		int	line, 
+		SCREEN	*sp,
+		int	line,
 		int	(*init)(
-		WINDOW	*p1, 
+		WINDOW	*p1,
 		int	p2))
 		{ return(*(int *)0); }
 
 #undef ripoffline
 int	ripoffline(
-		int	line, 
+		int	line,
 		int	(*init)(
-		WINDOW	*p1, 
+		WINDOW	*p1,
 		int	p2))
 		{ return(*(int *)0); }
 
@@ -2092,13 +2092,13 @@ int	ripoffline(
 
 #undef _nc_format_slks
 int	_nc_format_slks(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	cols)
 		{ return(*(int *)0); }
 
 #undef _nc_slk_initialize
 int	_nc_slk_initialize(
-		WINDOW	*stwin, 
+		WINDOW	*stwin,
 		int	cols)
 		{ return(*(int *)0); }
 
@@ -2115,16 +2115,16 @@ int	slk_restore(void)
 
 #undef slk_attr_set_sp
 int	slk_attr_set_sp(
-		SCREEN	*sp, 
-		const attr_t attr, 
-		short	pair_arg, 
+		SCREEN	*sp,
+		const attr_t attr,
+		short	pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
 #undef slk_attr_set
 int	slk_attr_set(
-		const attr_t attr, 
-		short	pair_arg, 
+		const attr_t attr,
+		short	pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -2132,7 +2132,7 @@ int	slk_attr_set(
 
 #undef slk_attroff_sp
 int	slk_attroff_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const chtype attr)
 		{ return(*(int *)0); }
 
@@ -2145,7 +2145,7 @@ int	slk_attroff(
 
 #undef slk_attron_sp
 int	slk_attron_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const chtype attr)
 		{ return(*(int *)0); }
 
@@ -2158,7 +2158,7 @@ int	slk_attron(
 
 #undef slk_attrset_sp
 int	slk_attrset_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const chtype attr)
 		{ return(*(int *)0); }
 
@@ -2193,7 +2193,7 @@ int	slk_clear(void)
 
 #undef slk_color_sp
 int	slk_color_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		short	pair_arg)
 		{ return(*(int *)0); }
 
@@ -2206,7 +2206,7 @@ int	slk_color(
 
 #undef slk_init_sp
 int	slk_init_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	format)
 		{ return(*(int *)0); }
 
@@ -2219,7 +2219,7 @@ int	slk_init(
 
 #undef slk_label_sp
 char	*slk_label_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	n)
 		{ return(*(char **)0); }
 
@@ -2252,16 +2252,16 @@ int	slk_refresh(void)
 
 #undef slk_set_sp
 int	slk_set_sp(
-		SCREEN	*sp, 
-		int	i, 
-		const char *astr, 
+		SCREEN	*sp,
+		int	i,
+		const char *astr,
 		int	format)
 		{ return(*(int *)0); }
 
 #undef slk_set
 int	slk_set(
-		int	i, 
-		const char *astr, 
+		int	i,
+		const char *astr,
 		int	format)
 		{ return(*(int *)0); }
 
@@ -2280,7 +2280,7 @@ int	slk_touch(void)
 
 #undef is_linetouched
 NCURSES_BOOL is_linetouched(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	line)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -2291,9 +2291,9 @@ NCURSES_BOOL is_wintouched(
 
 #undef wtouchln
 int	wtouchln(
-		WINDOW	*win, 
-		int	y, 
-		int	n, 
+		WINDOW	*win,
+		int	y,
+		int	n,
 		int	changed)
 		{ return(*(int *)0); }
 
@@ -2301,7 +2301,7 @@ int	wtouchln(
 
 #undef _tracedump
 void	_tracedump(
-		const char *name, 
+		const char *name,
 		WINDOW	*win)
 		{ /* void */ }
 
@@ -2309,19 +2309,19 @@ void	_tracedump(
 
 #undef _nc_trace_mmask_t
 char	*_nc_trace_mmask_t(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		mmask_t	code)
 		{ return(*(char **)0); }
 
 #undef _nc_tracemouse
 char	*_nc_tracemouse(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		MEVENT const *ep)
 		{ return(*(char **)0); }
 
 #undef _nc_retrace_mmask_t
 mmask_t	_nc_retrace_mmask_t(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		mmask_t	code)
 		{ return(*(mmask_t *)0); }
 
@@ -2346,7 +2346,7 @@ void	_nc_fifo_dump(
 
 #undef ungetch_sp
 int	ungetch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -2359,20 +2359,20 @@ int	ungetch(
 
 #undef vidputs_sp
 int	vidputs_sp(
-		SCREEN	*sp, 
-		chtype	newmode, 
+		SCREEN	*sp,
+		chtype	newmode,
 		NCURSES_OUTC_sp outc)
 		{ return(*(int *)0); }
 
 #undef vidputs
 int	vidputs(
-		chtype	newmode, 
+		chtype	newmode,
 		NCURSES_OUTC outc)
 		{ return(*(int *)0); }
 
 #undef vidattr_sp
 int	vidattr_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		chtype	newmode)
 		{ return(*(int *)0); }
 
@@ -2394,8 +2394,8 @@ chtype	termattrs(void)
 
 #undef wvline
 int	wvline(
-		WINDOW	*win, 
-		chtype	ch, 
+		WINDOW	*win,
+		chtype	ch,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -2403,8 +2403,8 @@ int	wvline(
 
 #undef wattr_off
 int	wattr_off(
-		WINDOW	*win, 
-		attr_t	at, 
+		WINDOW	*win,
+		attr_t	at,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -2412,8 +2412,8 @@ int	wattr_off(
 
 #undef wattr_on
 int	wattr_on(
-		WINDOW	*win, 
-		attr_t	at, 
+		WINDOW	*win,
+		attr_t	at,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -2433,14 +2433,14 @@ void	_nc_synchook(
 
 #undef mvderwin
 int	mvderwin(
-		WINDOW	*win, 
-		int	y, 
+		WINDOW	*win,
+		int	y,
 		int	x)
 		{ return(*(int *)0); }
 
 #undef syncok
 int	syncok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL bf)
 		{ return(*(int *)0); }
 
@@ -2479,14 +2479,14 @@ struct panelhook *_nc_panelhook(void)
 
 #undef _nc_printf_string_sp
 char	*_nc_printf_string_sp(
-		SCREEN	*sp, 
-		const char *fmt, 
+		SCREEN	*sp,
+		const char *fmt,
 		va_list	ap)
 		{ return(*(char **)0); }
 
 #undef _nc_printf_string
 char	*_nc_printf_string(
-		const char *fmt, 
+		const char *fmt,
 		va_list	ap)
 		{ return(*(char **)0); }
 
@@ -2503,18 +2503,18 @@ int	doupdate(void)
 
 #undef _nc_scrolln_sp
 int	_nc_scrolln_sp(
-		SCREEN	*sp, 
-		int	n, 
-		int	top, 
-		int	bot, 
+		SCREEN	*sp,
+		int	n,
+		int	top,
+		int	bot,
 		int	maxy)
 		{ return(*(int *)0); }
 
 #undef _nc_scrolln
 int	_nc_scrolln(
-		int	n, 
-		int	top, 
-		int	bot, 
+		int	n,
+		int	top,
+		int	bot,
 		int	maxy)
 		{ return(*(int *)0); }
 
@@ -2547,7 +2547,7 @@ void	_nc_screen_wrap(void)
 
 #undef _nc_do_xmc_glitch_sp
 void	_nc_do_xmc_glitch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		attr_t	previous)
 		{ /* void */ }
 
@@ -2560,7 +2560,7 @@ void	_nc_do_xmc_glitch(
 
 #undef _nc_varargs
 char	*_nc_varargs(
-		const char *fmt, 
+		const char *fmt,
 		va_list	ap)
 		{ return(*(char **)0); }
 
@@ -2578,7 +2578,7 @@ void	_nc_freeall(void)
 
 #undef _nc_free_and_exit_sp
 void	_nc_free_and_exit_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	code)
 		{ /* void */ }
 
@@ -2596,31 +2596,31 @@ void	exit_curses(
 
 #undef _nc_toggle_attr_on
 void	_nc_toggle_attr_on(
-		attr_t	*S, 
+		attr_t	*S,
 		attr_t	at)
 		{ /* void */ }
 
 #undef _nc_toggle_attr_off
 void	_nc_toggle_attr_off(
-		attr_t	*S, 
+		attr_t	*S,
 		attr_t	at)
 		{ /* void */ }
 
 #undef _nc_DelCharCost_sp
 int	_nc_DelCharCost_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	count)
 		{ return(*(int *)0); }
 
 #undef _nc_InsCharCost_sp
 int	_nc_InsCharCost_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	count)
 		{ return(*(int *)0); }
 
 #undef _nc_UpdateAttrs_sp
 void	_nc_UpdateAttrs_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		chtype	c)
 		{ /* void */ }
 
@@ -2643,7 +2643,7 @@ void	_nc_UpdateAttrs(
 
 #undef use_legacy_coding_sp
 int	use_legacy_coding_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	level)
 		{ return(*(int *)0); }
 
@@ -2665,14 +2665,14 @@ int	use_default_colors(void)
 
 #undef assume_default_colors_sp
 int	assume_default_colors_sp(
-		SCREEN	*sp, 
-		int	fg, 
+		SCREEN	*sp,
+		int	fg,
 		int	bg)
 		{ return(*(int *)0); }
 
 #undef assume_default_colors
 int	assume_default_colors(
-		int	fg, 
+		int	fg,
 		int	bg)
 		{ return(*(int *)0); }
 
@@ -2680,14 +2680,14 @@ int	assume_default_colors(
 
 #undef mcprint_sp
 int	mcprint_sp(
-		SCREEN	*sp, 
-		char	*data, 
+		SCREEN	*sp,
+		char	*data,
 		int	len)
 		{ return(*(int *)0); }
 
 #undef mcprint
 int	mcprint(
-		char	*data, 
+		char	*data,
 		int	len)
 		{ return(*(int *)0); }
 
@@ -2701,40 +2701,40 @@ void	_nc_new_pair(void)
 
 #undef is_term_resized_sp
 NCURSES_BOOL is_term_resized_sp(
-		SCREEN	*sp, 
-		int	ToLines, 
+		SCREEN	*sp,
+		int	ToLines,
 		int	ToCols)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_term_resized
 NCURSES_BOOL is_term_resized(
-		int	ToLines, 
+		int	ToLines,
 		int	ToCols)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef resize_term_sp
 int	resize_term_sp(
-		SCREEN	*sp, 
-		int	ToLines, 
+		SCREEN	*sp,
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
 #undef resize_term
 int	resize_term(
-		int	ToLines, 
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
 #undef resizeterm_sp
 int	resizeterm_sp(
-		SCREEN	*sp, 
-		int	ToLines, 
+		SCREEN	*sp,
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
 #undef resizeterm
 int	resizeterm(
-		int	ToLines, 
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
@@ -2749,8 +2749,8 @@ void	_nc_trace_xnames(
 
 #undef use_screen
 int	use_screen(
-		SCREEN	*screen, 
-		NCURSES_SCREEN_CB func, 
+		SCREEN	*screen,
+		NCURSES_SCREEN_CB func,
 		void	*data)
 		{ return(*(int *)0); }
 
@@ -2758,8 +2758,8 @@ int	use_screen(
 
 #undef use_window
 int	use_window(
-		WINDOW	*win, 
-		NCURSES_WINDOW_CB func, 
+		WINDOW	*win,
+		NCURSES_WINDOW_CB func,
 		void	*data)
 		{ return(*(int *)0); }
 
@@ -2767,8 +2767,8 @@ int	use_window(
 
 #undef wresize
 int	wresize(
-		WINDOW	*win, 
-		int	ToLines, 
+		WINDOW	*win,
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
@@ -2796,7 +2796,7 @@ char	*_nc_basename(
 
 #undef _nc_access
 int	_nc_access(
-		const char *path, 
+		const char *path,
 		int	mode)
 		{ return(*(int *)0); }
 
@@ -2814,12 +2814,25 @@ NCURSES_BOOL _nc_is_file_path(
 int	_nc_env_access(void)
 		{ return(*(int *)0); }
 
+#undef _nc_safe_fopen
+FILE	*_nc_safe_fopen(
+		const char *path,
+		const char *mode)
+		{ return(*(FILE **)0); }
+
+#undef _nc_safe_open3
+int	_nc_safe_open3(
+		const char *path,
+		int	flags,
+		mode_t	mode)
+		{ return(*(int *)0); }
+
 /* ./tinfo/add_tries.c */
 
 #undef _nc_add_to_try
 int	_nc_add_to_try(
-		TRIES	**tree, 
-		const char *str, 
+		TRIES	**tree,
+		const char *str,
 		unsigned code)
 		{ return(*(int *)0); }
 
@@ -2827,13 +2840,13 @@ int	_nc_add_to_try(
 
 #undef _nc_align_termtype
 void	_nc_align_termtype(
-		TERMTYPE2 *to, 
-		TERMTYPE2 *from)
+		TERMTYPE *to,
+		TERMTYPE *from)
 		{ /* void */ }
 
 #undef _nc_copy_termtype
 void	_nc_copy_termtype(
-		TERMTYPE *dst, 
+		TERMTYPE *dst,
 		const TERMTYPE *src)
 		{ /* void */ }
 
@@ -2903,19 +2916,19 @@ void	_nc_get_type(
 
 #undef _nc_warning
 void	_nc_warning(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
 #undef _nc_err_abort
 void	_nc_err_abort(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
 #undef _nc_syserr_abort
 void	_nc_syserr_abort(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
@@ -2923,14 +2936,14 @@ void	_nc_syserr_abort(
 
 #undef _nc_find_entry
 struct name_table_entry const *_nc_find_entry(
-		const char *string, 
+		const char *string,
 		const HashValue *hash_table)
 		{ return(*(struct name_table_entry const **)0); }
 
 #undef _nc_find_type_entry
 struct name_table_entry const *_nc_find_type_entry(
-		const char *string, 
-		int	type, 
+		const char *string,
+		int	type,
 		NCURSES_BOOL termcap)
 		{ return(*(struct name_table_entry const **)0); }
 
@@ -2967,13 +2980,13 @@ void	_nc_last_db(void)
 
 #undef _nc_next_db
 const char *_nc_next_db(
-		DBDIRS	*state, 
+		DBDIRS	*state,
 		int	*offset)
 		{ return(*(const char **)0); }
 
 #undef _nc_first_db
 void	_nc_first_db(
-		DBDIRS	*state, 
+		DBDIRS	*state,
 		int	*offset)
 		{ /* void */ }
 
@@ -2981,7 +2994,7 @@ void	_nc_first_db(
 
 #undef _nc_doalloc
 void	*_nc_doalloc(
-		void	*oldp, 
+		void	*oldp,
 		size_t	amount)
 		{ return(*(void **)0); }
 
@@ -2994,8 +3007,8 @@ ENTRY	*_nc_tail;
 
 #undef _nc_free_entry
 void	_nc_free_entry(
-		ENTRY	*headp, 
-		TERMTYPE2 *tterm)
+		ENTRY	*headp,
+		TERMTYPE *tterm)
 		{ /* void */ }
 
 #undef _nc_free_entries
@@ -3015,9 +3028,9 @@ void	exit_terminfo(
 /* ./fallback.c */
 
 #undef _nc_fallback
-const TERMTYPE2 *_nc_fallback(
+const TERMTYPE *_nc_fallback(
 		const char *name)
-		{ return(*(const TERMTYPE2 **)0); }
+		{ return(*(const TERMTYPE **)0); }
 
 /* ./tinfo/free_ttype.c */
 
@@ -3026,6 +3039,11 @@ void	_nc_free_termtype(
 		TERMTYPE *ptr)
 		{ /* void */ }
 
+#undef _nc_free_termtype1
+void	_nc_free_termtype1(
+		TERMTYPE *ptr)
+		{ /* void */ }
+
 #undef _nc_user_definable
 NCURSES_BOOL _nc_user_definable;
 
@@ -3043,7 +3061,7 @@ int	_nc_getenv_num(
 
 #undef _nc_setenv_num
 void	_nc_setenv_num(
-		const char *name, 
+		const char *name,
 		int	value)
 		{ /* void */ }
 
@@ -3078,8 +3096,8 @@ void	_nc_init_acs(void)
 /* ./tinfo/lib_baudrate.c */
 
 struct speed {
-    int given_speed; 
-    int actual_speed; 
+    int given_speed;
+    int actual_speed;
 };
 
 #undef _nc_baudrate
@@ -3118,7 +3136,7 @@ TERMINAL *_nc_cur_term(void)
 
 #undef set_curterm_sp
 TERMINAL *set_curterm_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		TERMINAL *termp)
 		{ return(*(TERMINAL **)0); }
 
@@ -3129,7 +3147,7 @@ TERMINAL *set_curterm(
 
 #undef del_curterm_sp
 int	del_curterm_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		TERMINAL *termp)
 		{ return(*(int *)0); }
 
@@ -3245,7 +3263,7 @@ struct kn { short offset; int code; };
 
 #undef keyname_sp
 const char *keyname_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	c)
 		{ return(*(const char **)0); }
 
@@ -3269,7 +3287,7 @@ char	*longname(void)
 
 #undef napms_sp
 int	napms_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ms)
 		{ return(*(int *)0); }
 
@@ -3282,19 +3300,19 @@ int	napms(
 
 #undef idlok
 int	idlok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef idcok
 void	idcok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ /* void */ }
 
 #undef halfdelay_sp
 int	halfdelay_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	t)
 		{ return(*(int *)0); }
 
@@ -3305,37 +3323,37 @@ int	halfdelay(
 
 #undef nodelay
 int	nodelay(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef notimeout
 int	notimeout(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL f)
 		{ return(*(int *)0); }
 
 #undef wtimeout
 void	wtimeout(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	delay)
 		{ /* void */ }
 
 #undef keypad
 int	keypad(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef meta
 int	meta(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef curs_set_sp
 int	curs_set_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	vis)
 		{ return(*(int *)0); }
 
@@ -3346,7 +3364,7 @@ int	curs_set(
 
 #undef typeahead_sp
 int	typeahead_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	fd)
 		{ return(*(int *)0); }
 
@@ -3357,7 +3375,7 @@ int	typeahead(
 
 #undef has_key_sp
 int	has_key_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	keycode)
 		{ return(*(int *)0); }
 
@@ -3368,14 +3386,14 @@ int	has_key(
 
 #undef _nc_putp_flush_sp
 int	_nc_putp_flush_sp(
-		SCREEN	*sp, 
-		const char *name, 
+		SCREEN	*sp,
+		const char *name,
 		const char *value)
 		{ return(*(int *)0); }
 
 #undef _nc_keypad
 int	_nc_keypad(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	flag)
 		{ return(*(int *)0); }
 
@@ -3437,17 +3455,53 @@ void	noqiflush(void)
 
 #undef intrflush_sp
 int	intrflush_sp(
-		SCREEN	*sp, 
-		WINDOW	*win, 
+		SCREEN	*sp,
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef intrflush
 int	intrflush(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
+#undef is_nl_sp
+int	is_nl_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_raw_sp
+int	is_raw_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_cbreak_sp
+int	is_cbreak_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_echo_sp
+int	is_echo_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_nl
+int	is_nl(void)
+		{ return(*(int *)0); }
+
+#undef is_raw
+int	is_raw(void)
+		{ return(*(int *)0); }
+
+#undef is_cbreak
+int	is_cbreak(void)
+		{ return(*(int *)0); }
+
+#undef is_echo
+int	is_echo(void)
+		{ return(*(int *)0); }
+
 /* ./tinfo/lib_setup.c */
 
 #undef _nc_ttytype
@@ -3483,7 +3537,7 @@ int	_nc_TABSIZE(void)
 
 #undef set_tabsize_sp
 int	set_tabsize_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	value)
 		{ return(*(int *)0); }
 
@@ -3499,13 +3553,13 @@ int	_nc_handle_sigwinch(
 
 #undef use_env_sp
 void	use_env_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		NCURSES_BOOL f)
 		{ /* void */ }
 
 #undef use_tioctl_sp
 void	use_tioctl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		NCURSES_BOOL f)
 		{ /* void */ }
 
@@ -3521,8 +3575,8 @@ void	use_tioctl(
 
 #undef _nc_get_screensize
 void	_nc_get_screensize(
-		SCREEN	*sp, 
-		int	*linep, 
+		SCREEN	*sp,
+		int	*linep,
 		int	*colp)
 		{ /* void */ }
 
@@ -3533,13 +3587,13 @@ void	_nc_update_screensize(
 
 #undef _nc_setup_tinfo
 int	_nc_setup_tinfo(
-		const char *const tn, 
-		TERMTYPE2 *const tp)
+		const char *const tn,
+		TERMTYPE *const tp)
 		{ return(*(int *)0); }
 
 #undef _nc_tinfo_cmdch
 void	_nc_tinfo_cmdch(
-		TERMINAL *termp, 
+		TERMINAL *termp,
 		int	proto)
 		{ /* void */ }
 
@@ -3558,9 +3612,9 @@ int	_nc_locale_breaks_acs(
 
 #undef _nc_setupterm
 int	_nc_setupterm(
-		const char *tname, 
-		int	Filedes, 
-		int	*errret, 
+		const char *tname,
+		int	Filedes,
+		int	*errret,
 		int	reuse)
 		{ return(*(int *)0); }
 
@@ -3578,8 +3632,8 @@ SCREEN	*new_prescr(void)
 
 #undef setupterm
 int	setupterm(
-		const char *tname, 
-		int	Filedes, 
+		const char *tname,
+		int	Filedes,
 		int	*errret)
 		{ return(*(int *)0); }
 
@@ -3592,20 +3646,20 @@ char	*BC;
 
 #undef tgetent_sp
 int	tgetent_sp(
-		SCREEN	*sp, 
-		char	*bufp, 
+		SCREEN	*sp,
+		char	*bufp,
 		const char *name)
 		{ return(*(int *)0); }
 
 #undef tgetent
 int	tgetent(
-		char	*bufp, 
+		char	*bufp,
 		const char *name)
 		{ return(*(int *)0); }
 
 #undef tgetflag_sp
 int	tgetflag_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *id)
 		{ return(*(int *)0); }
 
@@ -3616,7 +3670,7 @@ int	tgetflag(
 
 #undef tgetnum_sp
 int	tgetnum_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *id)
 		{ return(*(int *)0); }
 
@@ -3627,14 +3681,14 @@ int	tgetnum(
 
 #undef tgetstr_sp
 char	*tgetstr_sp(
-		SCREEN	*sp, 
-		const char *id, 
+		SCREEN	*sp,
+		const char *id,
 		char	**area)
 		{ return(*(char **)0); }
 
 #undef tgetstr
 char	*tgetstr(
-		const char *id, 
+		const char *id,
 		char	**area)
 		{ return(*(char **)0); }
 
@@ -3653,8 +3707,8 @@ char	*termname(void)
 
 #undef tgoto
 char	*tgoto(
-		const char *string, 
-		int	x, 
+		const char *string,
+		int	x,
 		int	y)
 		{ return(*(char **)0); }
 
@@ -3662,7 +3716,7 @@ char	*tgoto(
 
 #undef tigetflag_sp
 int	tigetflag_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -3673,7 +3727,7 @@ int	tigetflag(
 
 #undef tigetnum_sp
 int	tigetnum_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -3684,7 +3738,7 @@ int	tigetnum(
 
 #undef tigetstr_sp
 char	*tigetstr_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(char **)0); }
 
@@ -3698,32 +3752,58 @@ char	*tigetstr(
 #undef _nc_tparm_err
 int	_nc_tparm_err;
 
+#undef _nc_free_tparm
+void	_nc_free_tparm(
+		TERMINAL *termp)
+		{ /* void */ }
+
 #undef _nc_tparm_analyze
 int	_nc_tparm_analyze(
-		const char *string, 
-		char	*p_is_s[9], 
+		TERMINAL *term,
+		const char *string,
+		char	**p_is_s,
 		int	*_nc_popcount)
 		{ return(*(int *)0); }
 
 #undef tparm
 char	*tparm(
-		const char *string, 
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
 #undef tiparm
 char	*tiparm(
-		const char *string, 
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
+#undef tiparm_s
+char	*tiparm_s(
+		int	num_expected,
+		int	tparm_type,
+		const char *string,
+		...)
+		{ return(*(char **)0); }
+
+#undef tiscan_s
+int	tiscan_s(
+		int	*num_expected,
+		int	*tparm_type,
+		const char *string)
+		{ return(*(int *)0); }
+
 #undef _nc_tiparm
 char	*_nc_tiparm(
-		int	expected, 
-		const char *string, 
+		int	expected,
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
+#undef _nc_reset_tparm
+void	_nc_reset_tparm(
+		TERMINAL *term)
+		{ /* void */ }
+
 /* ./tinfo/lib_tputs.c */
 
 #undef PC
@@ -3740,7 +3820,7 @@ void	_nc_set_no_padding(
 
 #undef delay_output_sp
 int	delay_output_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ms)
 		{ return(*(int *)0); }
 
@@ -3760,7 +3840,7 @@ void	_nc_flush(void)
 
 #undef _nc_outch_sp
 int	_nc_outch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -3771,7 +3851,7 @@ int	_nc_outch(
 
 #undef _nc_putchar_sp
 int	_nc_putchar_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -3782,7 +3862,7 @@ int	_nc_putchar(
 
 #undef putp_sp
 int	putp_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *string)
 		{ return(*(int *)0); }
 
@@ -3793,35 +3873,35 @@ int	putp(
 
 #undef _nc_putp_sp
 int	_nc_putp_sp(
-		SCREEN	*sp, 
-		const char *name, 
+		SCREEN	*sp,
+		const char *name,
 		const char *string)
 		{ return(*(int *)0); }
 
 #undef _nc_putp
 int	_nc_putp(
-		const char *name, 
+		const char *name,
 		const char *string)
 		{ return(*(int *)0); }
 
 #undef tputs_sp
 int	tputs_sp(
-		SCREEN	*sp, 
-		const char *string, 
-		int	affcnt, 
+		SCREEN	*sp,
+		const char *string,
+		int	affcnt,
 		NCURSES_OUTC_sp outc)
 		{ return(*(int *)0); }
 
 #undef _nc_outc_wrapper
 int	_nc_outc_wrapper(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	c)
 		{ return(*(int *)0); }
 
 #undef tputs
 int	tputs(
-		const char *string, 
-		int	affcnt, 
+		const char *string,
+		int	affcnt,
 		int	(*outc)(
 		int	p1))
 		{ return(*(int *)0); }
@@ -3861,7 +3941,7 @@ void	trace(
 
 #undef _tracef
 void	_tracef(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ /* void */ }
 
@@ -3917,8 +3997,8 @@ WINDOW	*_nc_retrace_win(
 
 #undef _nc_fmt_funcptr
 char	*_nc_fmt_funcptr(
-		char	*target, 
-		const char *source, 
+		char	*target,
+		const char *source,
 		size_t	size)
 		{ return(*(char **)0); }
 
@@ -3929,7 +4009,7 @@ int	_nc_use_tracef(
 
 #undef _nc_locked_tracef
 void	_nc_locked_tracef(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ /* void */ }
 
@@ -3937,7 +4017,7 @@ void	_nc_locked_tracef(
 
 #undef _traceattr2
 char	*_traceattr2(
-		int	bufnum, 
+		int	bufnum,
 		chtype	newmode)
 		{ return(*(char **)0); }
 
@@ -3958,13 +4038,13 @@ attr_t	_nc_retrace_attr_t(
 
 #undef _nc_altcharset_name
 const char *_nc_altcharset_name(
-		attr_t	attr, 
+		attr_t	attr,
 		chtype	ch)
 		{ return(*(const char **)0); }
 
 #undef _tracechtype2
 char	*_tracechtype2(
-		int	bufnum, 
+		int	bufnum,
 		chtype	ch)
 		{ return(*(char **)0); }
 
@@ -3982,7 +4062,7 @@ chtype	_nc_retrace_chtype(
 
 #undef _nc_trace_ttymode
 char	*_nc_trace_ttymode(
-		struct termios *tty)
+		const struct termios *tty)
 		{ return(*(char **)0); }
 
 #undef _nc_tracebits
@@ -3993,7 +4073,7 @@ char	*_nc_tracebits(void)
 
 #undef _nc_tracechar
 char	*_nc_tracechar(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(char **)0); }
 
@@ -4006,7 +4086,7 @@ char	*_tracechar(
 
 #undef _nc_get_tty_mode_sp
 int	_nc_get_tty_mode_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		struct termios *buf)
 		{ return(*(int *)0); }
 
@@ -4017,7 +4097,7 @@ int	_nc_get_tty_mode(
 
 #undef _nc_set_tty_mode_sp
 int	_nc_set_tty_mode_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		struct termios *buf)
 		{ return(*(int *)0); }
 
@@ -4084,9 +4164,9 @@ int	resetty(void)
 
 #undef _nc_timed_wait
 int	_nc_timed_wait(
-		SCREEN	*sp, 
-		int	mode, 
-		int	milliseconds, 
+		SCREEN	*sp,
+		int	mode,
+		int	milliseconds,
 		int	*timeleft)
 		{ return(*(int *)0); }
 
@@ -4099,8 +4179,8 @@ char	*_nc_first_name(
 
 #undef _nc_name_match
 int	_nc_name_match(
-		const char *const namelst, 
-		const char *const name, 
+		const char *const namelst,
+		const char *const name,
 		const char *const delim)
 		{ return(*(int *)0); }
 
@@ -4134,14 +4214,14 @@ const char *const *_nc_strfnames(void)
 
 #undef _nc_set_buffer_sp
 void	_nc_set_buffer_sp(
-		SCREEN	*sp, 
-		FILE	*ofp, 
+		SCREEN	*sp,
+		FILE	*ofp,
 		int	buffered)
 		{ /* void */ }
 
 #undef _nc_set_buffer
 void	_nc_set_buffer(
-		FILE	*ofp, 
+		FILE	*ofp,
 		int	buffered)
 		{ /* void */ }
 
@@ -4149,67 +4229,67 @@ void	_nc_set_buffer(
 
 #undef _nc_init_termtype
 void	_nc_init_termtype(
-		TERMTYPE2 *const tp)
+		TERMTYPE *const tp)
 		{ /* void */ }
 
 #undef _nc_read_termtype
 int	_nc_read_termtype(
-		TERMTYPE2 *ptr, 
-		char	*buffer, 
+		TERMTYPE *ptr,
+		char	*buffer,
 		int	limit)
 		{ return(*(int *)0); }
 
 #undef _nc_read_file_entry
 int	_nc_read_file_entry(
-		const char *const filename, 
-		TERMTYPE2 *ptr)
+		const char *const filename,
+		TERMTYPE *ptr)
 		{ return(*(int *)0); }
 
 #undef _nc_read_entry
 int	_nc_read_entry(
-		const char *const name, 
-		char	*const filename, 
-		TERMTYPE2 *const tp)
+		const char *const name,
+		char	*const filename,
+		TERMTYPE *const tp)
 		{ return(*(int *)0); }
 
 /* ./tinfo/read_termcap.c */
 
 #undef _nc_read_termcap_entry
 int	_nc_read_termcap_entry(
-		const char *const tn, 
-		TERMTYPE2 *const tp)
+		const char *const tn,
+		TERMTYPE *const tp)
 		{ return(*(int *)0); }
 
 /* ./tinfo/strings.c */
 
 #undef _nc_str_init
 string_desc *_nc_str_init(
-		string_desc *dst, 
-		char	*src, 
+		string_desc *dst,
+		char	*src,
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_null
 string_desc *_nc_str_null(
-		string_desc *dst, 
+		string_desc *dst,
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_copy
 string_desc *_nc_str_copy(
-		string_desc *dst, 
-		string_desc *src)
+		string_desc *dst,
+		const string_desc *const src)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_safe_strcat
 NCURSES_BOOL _nc_safe_strcat(
-		string_desc *dst, 
+		string_desc *dst,
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_safe_strcpy
 NCURSES_BOOL _nc_safe_strcpy(
-		string_desc *dst, 
+		string_desc *dst,
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -4217,13 +4297,13 @@ NCURSES_BOOL _nc_safe_strcpy(
 
 #undef _nc_trace_buf
 char	*_nc_trace_buf(
-		int	bufnum, 
+		int	bufnum,
 		size_t	want)
 		{ return(*(char **)0); }
 
 #undef _nc_trace_bufcat
 char	*_nc_trace_bufcat(
-		int	bufnum, 
+		int	bufnum,
 		const char *value)
 		{ return(*(char **)0); }
 
@@ -4238,21 +4318,21 @@ void	_nc_trace_tries(
 
 #undef _nc_expand_try
 char	*_nc_expand_try(
-		TRIES	*tree, 
-		unsigned code, 
-		int	*count, 
+		TRIES	*tree,
+		unsigned code,
+		int	*count,
 		size_t	len)
 		{ return(*(char **)0); }
 
 #undef _nc_remove_key
 int	_nc_remove_key(
-		TRIES	**tree, 
+		TRIES	**tree,
 		unsigned code)
 		{ return(*(int *)0); }
 
 #undef _nc_remove_string
 int	_nc_remove_string(
-		TRIES	**tree, 
+		TRIES	**tree,
 		const char *string)
 		{ return(*(int *)0); }
 
@@ -4260,14 +4340,14 @@ int	_nc_remove_string(
 
 #undef _nc_trim_sgr0
 char	*_nc_trim_sgr0(
-		TERMTYPE2 *tp)
+		TERMTYPE *tp)
 		{ return(*(char **)0); }
 
 /* ./unctrl.c */
 
 #undef unctrl_sp
 const char *unctrl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		chtype	ch)
 		{ return(*(const char **)0); }
 
@@ -4280,7 +4360,7 @@ const char *unctrl(
 
 #undef _nc_visbuf2
 const char *_nc_visbuf2(
-		int	bufnum, 
+		int	bufnum,
 		const char *buf)
 		{ return(*(const char **)0); }
 
@@ -4291,20 +4371,20 @@ const char *_nc_visbuf(
 
 #undef _nc_visbufn
 const char *_nc_visbufn(
-		const char *buf, 
+		const char *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
 #undef _nc_viscbuf2
 const char *_nc_viscbuf2(
-		int	bufnum, 
-		const chtype *buf, 
+		int	bufnum,
+		const chtype *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
 #undef _nc_viscbuf
 const char *_nc_viscbuf(
-		const chtype *buf, 
+		const chtype *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
@@ -4322,18 +4402,18 @@ ENTRY	*_nc_copy_entry(
 
 #undef _nc_save_str
 char	*_nc_save_str(
-		const char *const string)
+		const char *string)
 		{ return(*(char **)0); }
 
 #undef _nc_wrap_entry
 void	_nc_wrap_entry(
-		ENTRY	*const ep, 
+		ENTRY	*const ep,
 		NCURSES_BOOL copy_strings)
 		{ /* void */ }
 
 #undef _nc_merge_entry
 void	_nc_merge_entry(
-		ENTRY	*const target, 
+		ENTRY	*const target,
 		ENTRY	*const source)
 		{ /* void */ }
 
@@ -4341,15 +4421,15 @@ void	_nc_merge_entry(
 
 #undef _nc_captoinfo
 char	*_nc_captoinfo(
-		const char *cap, 
-		const char *s, 
+		const char *cap,
+		const char *s,
 		int const parameterized)
 		{ return(*(char **)0); }
 
 #undef _nc_infotocap
 char	*_nc_infotocap(
-		const char *cap, 
-		const char *str, 
+		const char *cap,
+		const char *str,
 		int const parameterized)
 		{ return(*(char **)0); }
 
@@ -4357,8 +4437,8 @@ char	*_nc_infotocap(
 
 #undef _nc_tic_expand
 char	*_nc_tic_expand(
-		const char *srcp, 
-		NCURSES_BOOL tic_format, 
+		const char *srcp,
+		NCURSES_BOOL tic_format,
 		int	numbers)
 		{ return(*(char **)0); }
 
@@ -4366,28 +4446,28 @@ char	*_nc_tic_expand(
 
 #undef _nc_check_termtype2
 void	(*_nc_check_termtype2)(
-		TERMTYPE2 *p1, 
+		TERMTYPE *p1,
 		NCURSES_BOOL p2);
 
 #undef _nc_entry_match
 NCURSES_BOOL _nc_entry_match(
-		char	*n1, 
+		char	*n1,
 		char	*n2)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_read_entry_source
 void	_nc_read_entry_source(
-		FILE	*fp, 
-		char	*buf, 
-		int	literal, 
-		NCURSES_BOOL silent, 
+		FILE	*fp,
+		char	*buf,
+		int	literal,
+		NCURSES_BOOL silent,
 		NCURSES_BOOL (*hook)(
 		ENTRY	*p1))
 		{ /* void */ }
 
 #undef _nc_resolve_uses2
 int	_nc_resolve_uses2(
-		NCURSES_BOOL fullresolve, 
+		NCURSES_BOOL fullresolve,
 		NCURSES_BOOL literal)
 		{ return(*(int *)0); }
 
@@ -4412,7 +4492,7 @@ NCURSES_BOOL _nc_disable_period;
 
 #undef _nc_reset_input
 void	_nc_reset_input(
-		FILE	*fp, 
+		FILE	*fp,
 		char	*buf)
 		{ /* void */ }
 
@@ -4423,8 +4503,8 @@ int	_nc_get_token(
 
 #undef _nc_trans_string
 int	_nc_trans_string(
-		char	*ptr, 
-		char	*last)
+		char	*ptr,
+		const char *const last)
 		{ return(*(int *)0); }
 
 #undef _nc_push_token
@@ -4441,14 +4521,14 @@ void	_nc_panic_mode(
 
 #undef _nc_parse_entry
 int	_nc_parse_entry(
-		ENTRY	*entryp, 
-		int	literal, 
+		ENTRY	*entryp,
+		int	literal,
 		NCURSES_BOOL silent)
 		{ return(*(int *)0); }
 
 #undef _nc_capcmp
 int	_nc_capcmp(
-		const char *s, 
+		const char *s,
 		const char *t)
 		{ return(*(int *)0); }
 
@@ -4461,14 +4541,14 @@ void	_nc_set_writedir(
 
 #undef _nc_write_entry
 void	_nc_write_entry(
-		TERMTYPE2 *const tp)
+		TERMTYPE *const tp)
 		{ /* void */ }
 
 #undef _nc_write_object
 int	_nc_write_object(
-		TERMTYPE2 *tp, 
-		char	*buffer, 
-		unsigned *offset, 
+		TERMTYPE *tp,
+		char	*buffer,
+		unsigned *offset,
 		unsigned limit)
 		{ return(*(int *)0); }
 
@@ -4480,14 +4560,14 @@ int	_nc_tic_written(void)
 
 #undef define_key_sp
 int	define_key_sp(
-		SCREEN	*sp, 
-		const char *str, 
+		SCREEN	*sp,
+		const char *str,
 		int	keycode)
 		{ return(*(int *)0); }
 
 #undef define_key
 int	define_key(
-		const char *str, 
+		const char *str,
 		int	keycode)
 		{ return(*(int *)0); }
 
@@ -4501,7 +4581,7 @@ void	_nc_hashed_db(void)
 
 #undef key_defined_sp
 int	key_defined_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -4514,14 +4594,14 @@ int	key_defined(
 
 #undef keybound_sp
 char	*keybound_sp(
-		SCREEN	*sp, 
-		int	code, 
+		SCREEN	*sp,
+		int	code,
 		int	count)
 		{ return(*(char **)0); }
 
 #undef keybound
 char	*keybound(
-		int	code, 
+		int	code,
 		int	count)
 		{ return(*(char **)0); }
 
@@ -4529,14 +4609,14 @@ char	*keybound(
 
 #undef keyok_sp
 int	keyok_sp(
-		SCREEN	*sp, 
-		int	c, 
+		SCREEN	*sp,
+		int	c,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef keyok
 int	keyok(
-		int	c, 
+		int	c,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
diff --git a/contrib/ncurses/ncurses/llib-lncursestw b/contrib/ncurses/ncurses/llib-lncursestw
index 3c1aab97bc65..3aa57eee919a 100644
--- a/contrib/ncurses/ncurses/llib-lncursestw
+++ b/contrib/ncurses/ncurses/llib-lncursestw
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
  * Copyright 2009-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -70,7 +70,7 @@ void	_nc_hash_map(void)
 
 #undef _nc_make_oldhash_sp
 void	_nc_make_oldhash_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	i)
 		{ /* void */ }
 
@@ -81,16 +81,16 @@ void	_nc_make_oldhash(
 
 #undef _nc_scroll_oldhash_sp
 void	_nc_scroll_oldhash_sp(
-		SCREEN	*sp, 
-		int	n, 
-		int	top, 
+		SCREEN	*sp,
+		int	n,
+		int	top,
 		int	bot)
 		{ /* void */ }
 
 #undef _nc_scroll_oldhash
 void	_nc_scroll_oldhash(
-		int	n, 
-		int	top, 
+		int	n,
+		int	top,
 		int	bot)
 		{ /* void */ }
 
@@ -98,31 +98,31 @@ void	_nc_scroll_oldhash(
 
 #undef _nc_render
 cchar_t	_nc_render(
-		WINDOW	*win, 
+		WINDOW	*win,
 		cchar_t	ch)
 		{ return(*(cchar_t *)0); }
 
 #undef _nc_build_wch
 int	_nc_build_wch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		cchar_t	*ch)
 		{ return(*(int *)0); }
 
 #undef _nc_waddch_nosync
 int	_nc_waddch_nosync(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const cchar_t c)
 		{ return(*(int *)0); }
 
 #undef waddch
 int	waddch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const chtype ch)
 		{ return(*(int *)0); }
 
 #undef wechochar
 int	wechochar(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const chtype ch)
 		{ return(*(int *)0); }
 
@@ -130,15 +130,15 @@ int	wechochar(
 
 #undef waddnstr
 int	waddnstr(
-		WINDOW	*win, 
-		const char *astr, 
+		WINDOW	*win,
+		const char *astr,
 		int	n)
 		{ return(*(int *)0); }
 
 #undef waddchnstr
 int	waddchnstr(
-		WINDOW	*win, 
-		const chtype *astr, 
+		WINDOW	*win,
+		const chtype *astr,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -149,15 +149,15 @@ int	_nc_wchstrlen(
 
 #undef wadd_wchnstr
 int	wadd_wchnstr(
-		WINDOW	*win, 
-		const cchar_t *astr, 
+		WINDOW	*win,
+		const cchar_t *astr,
 		int	n)
 		{ return(*(int *)0); }
 
 #undef waddnwstr
 int	waddnwstr(
-		WINDOW	*win, 
-		const wchar_t *str, 
+		WINDOW	*win,
+		const wchar_t *str,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -176,25 +176,25 @@ int	beep(void)
 
 #undef wbkgrndset
 void	wbkgrndset(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const cchar_t *ch)
 		{ /* void */ }
 
 #undef wbkgdset
 void	wbkgdset(
-		WINDOW	*win, 
+		WINDOW	*win,
 		chtype	ch)
 		{ /* void */ }
 
 #undef wbkgrnd
 int	wbkgrnd(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const cchar_t *ch)
 		{ return(*(int *)0); }
 
 #undef wbkgd
 int	wbkgd(
-		WINDOW	*win, 
+		WINDOW	*win,
 		chtype	ch)
 		{ return(*(int *)0); }
 
@@ -202,14 +202,14 @@ int	wbkgd(
 
 #undef wborder
 int	wborder(
-		WINDOW	*win, 
-		chtype	ls, 
-		chtype	rs, 
-		chtype	ts, 
-		chtype	bs, 
-		chtype	tl, 
-		chtype	tr, 
-		chtype	bl, 
+		WINDOW	*win,
+		chtype	ls,
+		chtype	rs,
+		chtype	ts,
+		chtype	bs,
+		chtype	tl,
+		chtype	tr,
+		chtype	bl,
 		chtype	br)
 		{ return(*(int *)0); }
 
@@ -217,10 +217,10 @@ int	wborder(
 
 #undef wchgat
 int	wchgat(
-		WINDOW	*win, 
-		int	n, 
-		attr_t	attr, 
-		short	pair_arg, 
+		WINDOW	*win,
+		int	n,
+		attr_t	attr,
+		short	pair_arg,
 		const void *opts)
 		{ return(*(int *)0); }
 
@@ -235,7 +235,7 @@ int	wclear(
 
 #undef clearok
 int	clearok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
@@ -283,62 +283,62 @@ int	start_color(void)
 
 #undef _nc_change_pair
 void	_nc_change_pair(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	pair)
 		{ /* void */ }
 
 #undef _nc_reserve_pairs
 void	_nc_reserve_pairs(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	want)
 		{ /* void */ }
 
 #undef _nc_init_pair
 int	_nc_init_pair(
-		SCREEN	*sp, 
-		int	pair, 
-		int	f, 
+		SCREEN	*sp,
+		int	pair,
+		int	f,
 		int	b)
 		{ return(*(int *)0); }
 
 #undef init_pair_sp
 int	init_pair_sp(
-		SCREEN	*sp, 
-		short	pair, 
-		short	f, 
+		SCREEN	*sp,
+		short	pair,
+		short	f,
 		short	b)
 		{ return(*(int *)0); }
 
 #undef init_pair
 int	init_pair(
-		short	pair, 
-		short	f, 
+		short	pair,
+		short	f,
 		short	b)
 		{ return(*(int *)0); }
 
 #undef _nc_init_color
 int	_nc_init_color(
-		SCREEN	*sp, 
-		int	color, 
-		int	r, 
-		int	g, 
+		SCREEN	*sp,
+		int	color,
+		int	r,
+		int	g,
 		int	b)
 		{ return(*(int *)0); }
 
 #undef init_color_sp
 int	init_color_sp(
-		SCREEN	*sp, 
-		short	color, 
-		short	r, 
-		short	g, 
+		SCREEN	*sp,
+		short	color,
+		short	r,
+		short	g,
 		short	b)
 		{ return(*(int *)0); }
 
 #undef init_color
 int	init_color(
-		short	color, 
-		short	r, 
-		short	g, 
+		short	color,
+		short	r,
+		short	g,
 		short	b)
 		{ return(*(int *)0); }
 
@@ -362,92 +362,92 @@ NCURSES_BOOL has_colors(void)
 
 #undef color_content_sp
 int	color_content_sp(
-		SCREEN	*sp, 
-		short	color, 
-		short	*r, 
-		short	*g, 
+		SCREEN	*sp,
+		short	color,
+		short	*r,
+		short	*g,
 		short	*b)
 		{ return(*(int *)0); }
 
 #undef color_content
 int	color_content(
-		short	color, 
-		short	*r, 
-		short	*g, 
+		short	color,
+		short	*r,
+		short	*g,
 		short	*b)
 		{ return(*(int *)0); }
 
 #undef _nc_pair_content
 int	_nc_pair_content(
-		SCREEN	*sp, 
-		int	pair, 
-		int	*f, 
+		SCREEN	*sp,
+		int	pair,
+		int	*f,
 		int	*b)
 		{ return(*(int *)0); }
 
 #undef pair_content_sp
 int	pair_content_sp(
-		SCREEN	*sp, 
-		short	pair, 
-		short	*f, 
+		SCREEN	*sp,
+		short	pair,
+		short	*f,
 		short	*b)
 		{ return(*(int *)0); }
 
 #undef pair_content
 int	pair_content(
-		short	pair, 
-		short	*f, 
+		short	pair,
+		short	*f,
 		short	*b)
 		{ return(*(int *)0); }
 
 #undef _nc_do_color_sp
 void	_nc_do_color_sp(
-		SCREEN	*sp, 
-		int	old_pair, 
-		int	pair, 
-		int	reverse, 
+		SCREEN	*sp,
+		int	old_pair,
+		int	pair,
+		int	reverse,
 		NCURSES_OUTC_sp outc)
 		{ /* void */ }
 
 #undef _nc_do_color
 void	_nc_do_color(
-		int	old_pair, 
-		int	pair, 
-		int	reverse, 
+		int	old_pair,
+		int	pair,
+		int	reverse,
 		NCURSES_OUTC outc)
 		{ /* void */ }
 
 #undef init_extended_pair_sp
 int	init_extended_pair_sp(
-		SCREEN	*sp, 
-		int	pair, 
-		int	f, 
+		SCREEN	*sp,
+		int	pair,
+		int	f,
 		int	b)
 		{ return(*(int *)0); }
 
 #undef init_extended_color_sp
 int	init_extended_color_sp(
-		SCREEN	*sp, 
-		int	color, 
-		int	r, 
-		int	g, 
+		SCREEN	*sp,
+		int	color,
+		int	r,
+		int	g,
 		int	b)
 		{ return(*(int *)0); }
 
 #undef extended_color_content_sp
 int	extended_color_content_sp(
-		SCREEN	*sp, 
-		int	color, 
-		int	*r, 
-		int	*g, 
+		SCREEN	*sp,
+		int	color,
+		int	*r,
+		int	*g,
 		int	*b)
 		{ return(*(int *)0); }
 
 #undef extended_pair_content_sp
 int	extended_pair_content_sp(
-		SCREEN	*sp, 
-		int	pair, 
-		int	*f, 
+		SCREEN	*sp,
+		int	pair,
+		int	*f,
 		int	*b)
 		{ return(*(int *)0); }
 
@@ -458,31 +458,31 @@ void	reset_color_pairs_sp(
 
 #undef init_extended_pair
 int	init_extended_pair(
-		int	pair, 
-		int	f, 
+		int	pair,
+		int	f,
 		int	b)
 		{ return(*(int *)0); }
 
 #undef init_extended_color
 int	init_extended_color(
-		int	color, 
-		int	r, 
-		int	g, 
+		int	color,
+		int	r,
+		int	g,
 		int	b)
 		{ return(*(int *)0); }
 
 #undef extended_color_content
 int	extended_color_content(
-		int	color, 
-		int	*r, 
-		int	*g, 
+		int	color,
+		int	*r,
+		int	*g,
 		int	*b)
 		{ return(*(int *)0); }
 
 #undef extended_pair_content
 int	extended_pair_content(
-		int	pair, 
-		int	*f, 
+		int	pair,
+		int	*f,
 		int	*b)
 		{ return(*(int *)0); }
 
@@ -494,8 +494,8 @@ void	reset_color_pairs(void)
 
 #undef wcolor_set
 int	wcolor_set(
-		WINDOW	*win, 
-		short	pair_arg, 
+		WINDOW	*win,
+		short	pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -571,7 +571,7 @@ int	addch(
 
 #undef addchnstr
 int	addchnstr(
-		const chtype *a1, 
+		const chtype *a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -582,7 +582,7 @@ int	addchstr(
 
 #undef addnstr
 int	addnstr(
-		const char *a1, 
+		const char *a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -593,42 +593,42 @@ int	addstr(
 
 #undef attroff
 int	attroff(
-		int	z)
+		NCURSES_ATTR_T	z)
 		{ return(*(int *)0); }
 
 #undef attron
 int	attron(
-		int	z)
+		NCURSES_ATTR_T	z)
 		{ return(*(int *)0); }
 
 #undef attrset
 int	attrset(
-		int	z)
+		NCURSES_ATTR_T	z)
 		{ return(*(int *)0); }
 
 #undef attr_get
 int	attr_get(
-		attr_t	*a1, 
-		short	*a2, 
+		attr_t	*a1,
+		short	*a2,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef attr_off
 int	attr_off(
-		attr_t	a1, 
+		attr_t	a1,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef attr_on
 int	attr_on(
-		attr_t	a1, 
+		attr_t	a1,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef attr_set
 int	attr_set(
-		attr_t	a1, 
-		short	a2, 
+		attr_t	a1,
+		short	a2,
 		void	*z)
 		{ return(*(int *)0); }
 
@@ -644,28 +644,28 @@ void	bkgdset(
 
 #undef border
 int	border(
-		chtype	a1, 
-		chtype	a2, 
-		chtype	a3, 
-		chtype	a4, 
-		chtype	a5, 
-		chtype	a6, 
-		chtype	a7, 
+		chtype	a1,
+		chtype	a2,
+		chtype	a3,
+		chtype	a4,
+		chtype	a5,
+		chtype	a6,
+		chtype	a7,
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef box
 int	box(
-		WINDOW	*a1, 
-		chtype	a2, 
+		WINDOW	*a1,
+		chtype	a2,
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef chgat
 int	chgat(
-		int	a1, 
-		attr_t	a2, 
-		short	a3, 
+		int	a1,
+		attr_t	a2,
+		short	a3,
 		const void *z)
 		{ return(*(int *)0); }
 
@@ -683,7 +683,7 @@ int	clrtoeol(void)
 
 #undef color_set
 int	color_set(
-		short	a1, 
+		short	a1,
 		void	*z)
 		{ return(*(int *)0); }
 
@@ -720,7 +720,7 @@ int	getch(void)
 
 #undef getnstr
 int	getnstr(
-		char	*a1, 
+		char	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -731,7 +731,7 @@ int	getstr(
 
 #undef hline
 int	hline(
-		chtype	a1, 
+		chtype	a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -741,7 +741,7 @@ chtype	inch(void)
 
 #undef inchnstr
 int	inchnstr(
-		chtype	*a1, 
+		chtype	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -752,7 +752,7 @@ int	inchstr(
 
 #undef innstr
 int	innstr(
-		char	*a1, 
+		char	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -772,7 +772,7 @@ int	insertln(void)
 
 #undef insnstr
 int	insnstr(
-		const char *a1, 
+		const char *a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -788,323 +788,323 @@ int	instr(
 
 #undef move
 int	move(
-		int	a1, 
+		int	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddch
 int	mvaddch(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		const chtype z)
 		{ return(*(int *)0); }
 
 #undef mvaddchnstr
 int	mvaddchnstr(
-		int	a1, 
-		int	a2, 
-		const chtype *a3, 
+		int	a1,
+		int	a2,
+		const chtype *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddchstr
 int	mvaddchstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		const chtype *z)
 		{ return(*(int *)0); }
 
 #undef mvaddnstr
 int	mvaddnstr(
-		int	a1, 
-		int	a2, 
-		const char *a3, 
+		int	a1,
+		int	a2,
+		const char *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddstr
 int	mvaddstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvchgat
 int	mvchgat(
-		int	a1, 
-		int	a2, 
-		int	a3, 
-		attr_t	a4, 
-		short	a5, 
+		int	a1,
+		int	a2,
+		int	a3,
+		attr_t	a4,
+		short	a5,
 		const void *z)
 		{ return(*(int *)0); }
 
 #undef mvdelch
 int	mvdelch(
-		int	a1, 
+		int	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvgetch
 int	mvgetch(
-		int	a1, 
+		int	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvgetnstr
 int	mvgetnstr(
-		int	a1, 
-		int	a2, 
-		char	*a3, 
+		int	a1,
+		int	a2,
+		char	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvgetstr
 int	mvgetstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvhline
 int	mvhline(
-		int	a1, 
-		int	a2, 
-		chtype	a3, 
+		int	a1,
+		int	a2,
+		chtype	a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinch
 chtype	mvinch(
-		int	a1, 
+		int	a1,
 		int	z)
 		{ return(*(chtype *)0); }
 
 #undef mvinchnstr
 int	mvinchnstr(
-		int	a1, 
-		int	a2, 
-		chtype	*a3, 
+		int	a1,
+		int	a2,
+		chtype	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinchstr
 int	mvinchstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		chtype	*z)
 		{ return(*(int *)0); }
 
 #undef mvinnstr
 int	mvinnstr(
-		int	a1, 
-		int	a2, 
-		char	*a3, 
+		int	a1,
+		int	a2,
+		char	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinsch
 int	mvinsch(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef mvinsnstr
 int	mvinsnstr(
-		int	a1, 
-		int	a2, 
-		const char *a3, 
+		int	a1,
+		int	a2,
+		const char *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinsstr
 int	mvinsstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvinstr
 int	mvinstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvvline
 int	mvvline(
-		int	a1, 
-		int	a2, 
-		chtype	a3, 
+		int	a1,
+		int	a2,
+		chtype	a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddch
 int	mvwaddch(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const chtype z)
 		{ return(*(int *)0); }
 
 #undef mvwaddchnstr
 int	mvwaddchnstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const chtype *a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const chtype *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddchstr
 int	mvwaddchstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const chtype *z)
 		{ return(*(int *)0); }
 
 #undef mvwaddnstr
 int	mvwaddnstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const char *a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const char *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddstr
 int	mvwaddstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvwchgat
 int	mvwchgat(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		int	a4, 
-		attr_t	a5, 
-		short	a6, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		int	a4,
+		attr_t	a5,
+		short	a6,
 		const void *z)
 		{ return(*(int *)0); }
 
 #undef mvwdelch
 int	mvwdelch(
-		WINDOW	*a1, 
-		int	a2, 
+		WINDOW	*a1,
+		int	a2,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwgetch
 int	mvwgetch(
-		WINDOW	*a1, 
-		int	a2, 
+		WINDOW	*a1,
+		int	a2,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwgetnstr
 int	mvwgetnstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		char	*a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		char	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwgetstr
 int	mvwgetstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvwhline
 int	mvwhline(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		chtype	a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		chtype	a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinch
 chtype	mvwinch(
-		WINDOW	*a1, 
-		int	a2, 
+		WINDOW	*a1,
+		int	a2,
 		int	z)
 		{ return(*(chtype *)0); }
 
 #undef mvwinchnstr
 int	mvwinchnstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		chtype	*a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		chtype	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinchstr
 int	mvwinchstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		chtype	*z)
 		{ return(*(int *)0); }
 
 #undef mvwinnstr
 int	mvwinnstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		char	*a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		char	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinsch
 int	mvwinsch(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef mvwinsnstr
 int	mvwinsnstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const char *a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const char *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinsstr
 int	mvwinsstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvwinstr
 int	mvwinstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvwvline
 int	mvwvline(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		chtype	a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		chtype	a4,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -1134,19 +1134,19 @@ int	scroll(
 
 #undef setscrreg
 int	setscrreg(
-		int	a1, 
+		int	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef slk_attr_off
 int	slk_attr_off(
-		const attr_t a1, 
+		const attr_t a1,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef slk_attr_on
 int	slk_attr_on(
-		attr_t	a1, 
+		attr_t	a1,
 		void	*z)
 		{ return(*(int *)0); }
 
@@ -1165,8 +1165,8 @@ void	timeout(
 
 #undef touchline
 int	touchline(
-		WINDOW	*a1, 
-		int	a2, 
+		WINDOW	*a1,
+		int	a2,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -1182,53 +1182,53 @@ int	untouchwin(
 
 #undef vline
 int	vline(
-		chtype	a1, 
+		chtype	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef waddchstr
 int	waddchstr(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		const chtype *z)
 		{ return(*(int *)0); }
 
 #undef waddstr
 int	waddstr(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef wattron
 int	wattron(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wattroff
 int	wattroff(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wattrset
 int	wattrset(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wattr_get
 int	wattr_get(
-		WINDOW	*a1, 
-		attr_t	*a2, 
-		short	*a3, 
+		WINDOW	*a1,
+		attr_t	*a2,
+		short	*a3,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef wattr_set
 int	wattr_set(
-		WINDOW	*a1, 
-		attr_t	a2, 
-		short	a3, 
+		WINDOW	*a1,
+		attr_t	a2,
+		short	a3,
 		void	*z)
 		{ return(*(int *)0); }
 
@@ -1239,13 +1239,13 @@ int	wdeleteln(
 
 #undef wgetstr
 int	wgetstr(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef winchstr
 int	winchstr(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		chtype	*z)
 		{ return(*(int *)0); }
 
@@ -1256,13 +1256,13 @@ int	winsertln(
 
 #undef winsstr
 int	winsstr(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef winstr
 int	winstr(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		char	*z)
 		{ return(*(int *)0); }
 
@@ -1393,8 +1393,8 @@ int	wgetdelay(
 
 #undef wgetscrreg
 int	wgetscrreg(
-		const WINDOW *a1, 
-		int	*a2, 
+		const WINDOW *a1,
+		int	*a2,
 		int	*z)
 		{ return(*(int *)0); }
 
@@ -1405,7 +1405,7 @@ int	add_wch(
 
 #undef add_wchnstr
 int	add_wchnstr(
-		const cchar_t *a1, 
+		const cchar_t *a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -1416,7 +1416,7 @@ int	add_wchstr(
 
 #undef addnwstr
 int	addnwstr(
-		const wchar_t *a1, 
+		const wchar_t *a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -1437,20 +1437,20 @@ void	bkgrndset(
 
 #undef border_set
 int	border_set(
-		const cchar_t *a1, 
-		const cchar_t *a2, 
-		const cchar_t *a3, 
-		const cchar_t *a4, 
-		const cchar_t *a5, 
-		const cchar_t *a6, 
-		const cchar_t *a7, 
+		const cchar_t *a1,
+		const cchar_t *a2,
+		const cchar_t *a3,
+		const cchar_t *a4,
+		const cchar_t *a5,
+		const cchar_t *a6,
+		const cchar_t *a7,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef box_set
 int	box_set(
-		WINDOW	*a1, 
-		const cchar_t *a2, 
+		WINDOW	*a1,
+		const cchar_t *a2,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
@@ -1476,13 +1476,13 @@ int	getbkgrnd(
 
 #undef getn_wstr
 int	getn_wstr(
-		wint_t	*a1, 
+		wint_t	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef hline_set
 int	hline_set(
-		const cchar_t *a1, 
+		const cchar_t *a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -1493,7 +1493,7 @@ int	in_wch(
 
 #undef in_wchnstr
 int	in_wchnstr(
-		cchar_t	*a1, 
+		cchar_t	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -1504,13 +1504,13 @@ int	in_wchstr(
 
 #undef innwstr
 int	innwstr(
-		wchar_t	*a1, 
+		wchar_t	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef ins_nwstr
 int	ins_nwstr(
-		const wchar_t *a1, 
+		const wchar_t *a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -1531,336 +1531,336 @@ int	inwstr(
 
 #undef mvadd_wch
 int	mvadd_wch(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvadd_wchnstr
 int	mvadd_wchnstr(
-		int	a1, 
-		int	a2, 
-		const cchar_t *a3, 
+		int	a1,
+		int	a2,
+		const cchar_t *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvadd_wchstr
 int	mvadd_wchstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvaddnwstr
 int	mvaddnwstr(
-		int	a1, 
-		int	a2, 
-		const wchar_t *a3, 
+		int	a1,
+		int	a2,
+		const wchar_t *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddwstr
 int	mvaddwstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		const wchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvget_wch
 int	mvget_wch(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		wint_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvget_wstr
 int	mvget_wstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		wint_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvgetn_wstr
 int	mvgetn_wstr(
-		int	a1, 
-		int	a2, 
-		wint_t	*a3, 
+		int	a1,
+		int	a2,
+		wint_t	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvhline_set
 int	mvhline_set(
-		int	a1, 
-		int	a2, 
-		const cchar_t *a3, 
+		int	a1,
+		int	a2,
+		const cchar_t *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvin_wch
 int	mvin_wch(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvin_wchnstr
 int	mvin_wchnstr(
-		int	a1, 
-		int	a2, 
-		cchar_t	*a3, 
+		int	a1,
+		int	a2,
+		cchar_t	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvin_wchstr
 int	mvin_wchstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvinnwstr
 int	mvinnwstr(
-		int	a1, 
-		int	a2, 
-		wchar_t	*a3, 
+		int	a1,
+		int	a2,
+		wchar_t	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvins_nwstr
 int	mvins_nwstr(
-		int	a1, 
-		int	a2, 
-		const wchar_t *a3, 
+		int	a1,
+		int	a2,
+		const wchar_t *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvins_wch
 int	mvins_wch(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvins_wstr
 int	mvins_wstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		const wchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvinwstr
 int	mvinwstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		wchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvvline_set
 int	mvvline_set(
-		int	a1, 
-		int	a2, 
-		const cchar_t *a3, 
+		int	a1,
+		int	a2,
+		const cchar_t *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwadd_wch
 int	mvwadd_wch(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvwadd_wchnstr
 int	mvwadd_wchnstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const cchar_t *a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const cchar_t *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwadd_wchstr
 int	mvwadd_wchstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvwaddnwstr
 int	mvwaddnwstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const wchar_t *a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const wchar_t *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddwstr
 int	mvwaddwstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const wchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvwget_wch
 int	mvwget_wch(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		wint_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvwget_wstr
 int	mvwget_wstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		wint_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvwgetn_wstr
 int	mvwgetn_wstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		wint_t	*a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		wint_t	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwhline_set
 int	mvwhline_set(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const cchar_t *a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const cchar_t *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwin_wch
 int	mvwin_wch(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvwin_wchnstr
 int	mvwin_wchnstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		cchar_t	*a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		cchar_t	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwin_wchstr
 int	mvwin_wchstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvwinnwstr
 int	mvwinnwstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		wchar_t	*a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		wchar_t	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwins_nwstr
 int	mvwins_nwstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const wchar_t *a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const wchar_t *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwins_wch
 int	mvwins_wch(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvwins_wstr
 int	mvwins_wstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const wchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvwinwstr
 int	mvwinwstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		wchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvwvline_set
 int	mvwvline_set(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const cchar_t *a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const cchar_t *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef vline_set
 int	vline_set(
-		const cchar_t *a1, 
+		const cchar_t *a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wadd_wchstr
 int	wadd_wchstr(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef waddwstr
 int	waddwstr(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		const wchar_t *z)
 		{ return(*(int *)0); }
 
 #undef wget_wstr
 int	wget_wstr(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		wint_t	*z)
 		{ return(*(int *)0); }
 
 #undef wgetbkgrnd
 int	wgetbkgrnd(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef win_wchstr
 int	win_wchstr(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef wins_wstr
 int	wins_wstr(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		const wchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mouse_trafo
 NCURSES_BOOL mouse_trafo(
-		int	*a1, 
-		int	*a2, 
+		int	*a1,
+		int	*a2,
 		NCURSES_BOOL z)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -1877,7 +1877,7 @@ int	*_nc_ptr_Escdelay(
 
 #undef set_escdelay_sp
 int	set_escdelay_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	value)
 		{ return(*(int *)0); }
 
@@ -1897,8 +1897,8 @@ int	get_escdelay(void)
 
 #undef _nc_wgetch
 int	_nc_wgetch(
-		WINDOW	*win, 
-		int	*result, 
+		WINDOW	*win,
+		int	*result,
 		int	use_meta)
 		{ return(*(int *)0); }
 
@@ -1911,8 +1911,8 @@ int	wgetch(
 
 #undef wgetnstr
 int	wgetnstr(
-		WINDOW	*win, 
-		char	*str, 
+		WINDOW	*win,
+		char	*str,
 		int	maxlen)
 		{ return(*(int *)0); }
 
@@ -1920,8 +1920,8 @@ int	wgetnstr(
 
 #undef whline
 int	whline(
-		WINDOW	*win, 
-		chtype	ch, 
+		WINDOW	*win,
+		chtype	ch,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1929,7 +1929,7 @@ int	whline(
 
 #undef immedok
 void	immedok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ /* void */ }
 
@@ -1937,8 +1937,8 @@ void	immedok(
 
 #undef winchnstr
 int	winchnstr(
-		WINDOW	*win, 
-		chtype	*str, 
+		WINDOW	*win,
+		chtype	*str,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1952,14 +1952,14 @@ WINDOW	*initscr(void)
 
 #undef _nc_insert_ch
 int	_nc_insert_ch(
-		SCREEN	*sp, 
-		WINDOW	*win, 
+		SCREEN	*sp,
+		WINDOW	*win,
 		chtype	ch)
 		{ return(*(int *)0); }
 
 #undef winsch
 int	winsch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		chtype	c)
 		{ return(*(int *)0); }
 
@@ -1967,7 +1967,7 @@ int	winsch(
 
 #undef winsdelln
 int	winsdelln(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1975,8 +1975,8 @@ int	winsdelln(
 
 #undef winsnstr
 int	winsnstr(
-		WINDOW	*win, 
-		const char *s, 
+		WINDOW	*win,
+		const char *s,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1984,8 +1984,8 @@ int	winsnstr(
 
 #undef winnstr
 int	winnstr(
-		WINDOW	*win, 
-		char	*str, 
+		WINDOW	*win,
+		char	*str,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -2004,7 +2004,7 @@ NCURSES_BOOL isendwin(void)
 
 #undef leaveok
 int	leaveok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
@@ -2012,7 +2012,7 @@ int	leaveok(
 
 #undef getmouse_sp
 int	getmouse_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		MEVENT	*aevent)
 		{ return(*(int *)0); }
 
@@ -2023,7 +2023,7 @@ int	getmouse(
 
 #undef ungetmouse_sp
 int	ungetmouse_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		MEVENT	*aevent)
 		{ return(*(int *)0); }
 
@@ -2034,27 +2034,27 @@ int	ungetmouse(
 
 #undef mousemask_sp
 mmask_t	mousemask_sp(
-		SCREEN	*sp, 
-		mmask_t	newmask, 
+		SCREEN	*sp,
+		mmask_t	newmask,
 		mmask_t	*oldmask)
 		{ return(*(mmask_t *)0); }
 
 #undef mousemask
 mmask_t	mousemask(
-		mmask_t	newmask, 
+		mmask_t	newmask,
 		mmask_t	*oldmask)
 		{ return(*(mmask_t *)0); }
 
 #undef wenclose
 NCURSES_BOOL wenclose(
-		const WINDOW *win, 
-		int	y, 
+		const WINDOW *win,
+		int	y,
 		int	x)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef mouseinterval_sp
 int	mouseinterval_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	maxclick)
 		{ return(*(int *)0); }
 
@@ -2079,9 +2079,9 @@ NCURSES_BOOL has_mouse(void)
 
 #undef wmouse_trafo
 NCURSES_BOOL wmouse_trafo(
-		const WINDOW *win, 
-		int	*pY, 
-		int	*pX, 
+		const WINDOW *win,
+		int	*pY,
+		int	*pX,
 		NCURSES_BOOL to_screen)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -2089,8 +2089,8 @@ NCURSES_BOOL wmouse_trafo(
 
 #undef wmove
 int	wmove(
-		WINDOW	*win, 
-		int	y, 
+		WINDOW	*win,
+		int	y,
 		int	x)
 		{ return(*(int *)0); }
 
@@ -2098,14 +2098,14 @@ int	wmove(
 
 #undef _nc_msec_cost_sp
 int	_nc_msec_cost_sp(
-		SCREEN	*sp, 
-		const char *const cap, 
+		SCREEN	*sp,
+		const char *const cap,
 		int	affcnt)
 		{ return(*(int *)0); }
 
 #undef _nc_msec_cost
 int	_nc_msec_cost(
-		const char *const cap, 
+		const char *const cap,
 		int	affcnt)
 		{ return(*(int *)0); }
 
@@ -2138,35 +2138,35 @@ void	_nc_mvcur_wrap(void)
 
 #undef _nc_mvcur_sp
 int	_nc_mvcur_sp(
-		SCREEN	*sp, 
-		int	yold, 
-		int	xold, 
-		int	ynew, 
+		SCREEN	*sp,
+		int	yold,
+		int	xold,
+		int	ynew,
 		int	xnew)
 		{ return(*(int *)0); }
 
 #undef _nc_mvcur
 int	_nc_mvcur(
-		int	yold, 
-		int	xold, 
-		int	ynew, 
+		int	yold,
+		int	xold,
+		int	ynew,
 		int	xnew)
 		{ return(*(int *)0); }
 
 #undef mvcur_sp
 int	mvcur_sp(
-		SCREEN	*sp, 
-		int	yold, 
-		int	xold, 
-		int	ynew, 
+		SCREEN	*sp,
+		int	yold,
+		int	xold,
+		int	ynew,
 		int	xnew)
 		{ return(*(int *)0); }
 
 #undef mvcur
 int	mvcur(
-		int	yold, 
-		int	xold, 
-		int	ynew, 
+		int	yold,
+		int	xold,
+		int	ynew,
 		int	xnew)
 		{ return(*(int *)0); }
 
@@ -2177,8 +2177,8 @@ int	_nc_optimize_enable;
 
 #undef mvwin
 int	mvwin(
-		WINDOW	*win, 
-		int	by, 
+		WINDOW	*win,
+		int	by,
 		int	bx)
 		{ return(*(int *)0); }
 
@@ -2204,16 +2204,16 @@ void	nofilter(void)
 
 #undef newterm_sp
 SCREEN	*newterm_sp(
-		SCREEN	*sp, 
-		const char *name, 
-		FILE	*ofp, 
+		SCREEN	*sp,
+		const char *name,
+		FILE	*ofp,
 		FILE	*ifp)
 		{ return(*(SCREEN **)0); }
 
 #undef newterm
 SCREEN	*newterm(
-		const char *name, 
-		FILE	*ofp, 
+		const char *name,
+		FILE	*ofp,
 		FILE	*ifp)
 		{ return(*(SCREEN **)0); }
 
@@ -2226,46 +2226,46 @@ int	_nc_freewin(
 
 #undef newwin_sp
 WINDOW	*newwin_sp(
-		SCREEN	*sp, 
-		int	num_lines, 
-		int	num_columns, 
-		int	begy, 
+		SCREEN	*sp,
+		int	num_lines,
+		int	num_columns,
+		int	begy,
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef newwin
 WINDOW	*newwin(
-		int	num_lines, 
-		int	num_columns, 
-		int	begy, 
+		int	num_lines,
+		int	num_columns,
+		int	begy,
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef derwin
 WINDOW	*derwin(
-		WINDOW	*orig, 
-		int	num_lines, 
-		int	num_columns, 
-		int	begy, 
+		WINDOW	*orig,
+		int	num_lines,
+		int	num_columns,
+		int	begy,
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef subwin
 WINDOW	*subwin(
-		WINDOW	*w, 
-		int	l, 
-		int	c, 
-		int	y, 
+		WINDOW	*w,
+		int	l,
+		int	c,
+		int	y,
 		int	x)
 		{ return(*(WINDOW **)0); }
 
 #undef _nc_makenew_sp
 WINDOW	*_nc_makenew_sp(
-		SCREEN	*sp, 
-		int	num_lines, 
-		int	num_columns, 
-		int	begy, 
-		int	begx, 
+		SCREEN	*sp,
+		int	num_lines,
+		int	num_columns,
+		int	begy,
+		int	begx,
 		int	flags)
 		{ return(*(WINDOW **)0); }
 
@@ -2308,26 +2308,26 @@ int	nonl(void)
 
 #undef overlay
 int	overlay(
-		const WINDOW *win1, 
+		const WINDOW *win1,
 		WINDOW	*win2)
 		{ return(*(int *)0); }
 
 #undef overwrite
 int	overwrite(
-		const WINDOW *win1, 
+		const WINDOW *win1,
 		WINDOW	*win2)
 		{ return(*(int *)0); }
 
 #undef copywin
 int	copywin(
-		const WINDOW *src, 
-		WINDOW	*dst, 
-		int	sminrow, 
-		int	smincol, 
-		int	dminrow, 
-		int	dmincol, 
-		int	dmaxrow, 
-		int	dmaxcol, 
+		const WINDOW *src,
+		WINDOW	*dst,
+		int	sminrow,
+		int	smincol,
+		int	dminrow,
+		int	dmincol,
+		int	dmaxrow,
+		int	dmaxcol,
 		int	over)
 		{ return(*(int *)0); }
 
@@ -2335,51 +2335,51 @@ int	copywin(
 
 #undef newpad_sp
 WINDOW	*newpad_sp(
-		SCREEN	*sp, 
-		int	l, 
+		SCREEN	*sp,
+		int	l,
 		int	c)
 		{ return(*(WINDOW **)0); }
 
 #undef newpad
 WINDOW	*newpad(
-		int	l, 
+		int	l,
 		int	c)
 		{ return(*(WINDOW **)0); }
 
 #undef subpad
 WINDOW	*subpad(
-		WINDOW	*orig, 
-		int	l, 
-		int	c, 
-		int	begy, 
+		WINDOW	*orig,
+		int	l,
+		int	c,
+		int	begy,
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef prefresh
 int	prefresh(
-		WINDOW	*win, 
-		int	pminrow, 
-		int	pmincol, 
-		int	sminrow, 
-		int	smincol, 
-		int	smaxrow, 
+		WINDOW	*win,
+		int	pminrow,
+		int	pmincol,
+		int	sminrow,
+		int	smincol,
+		int	smaxrow,
 		int	smaxcol)
 		{ return(*(int *)0); }
 
 #undef pnoutrefresh
 int	pnoutrefresh(
-		WINDOW	*win, 
-		int	pminrow, 
-		int	pmincol, 
-		int	sminrow, 
-		int	smincol, 
-		int	smaxrow, 
+		WINDOW	*win,
+		int	pminrow,
+		int	pmincol,
+		int	sminrow,
+		int	smincol,
+		int	smaxrow,
 		int	smaxcol)
 		{ return(*(int *)0); }
 
 #undef pechochar
 int	pechochar(
-		WINDOW	*pad, 
+		WINDOW	*pad,
 		const chtype ch)
 		{ return(*(int *)0); }
 
@@ -2387,45 +2387,45 @@ int	pechochar(
 
 #undef printw
 int	printw(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef wprintw
 int	wprintw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef mvprintw
 int	mvprintw(
-		int	y, 
-		int	x, 
-		const char *fmt, 
+		int	y,
+		int	x,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef mvwprintw
 int	mvwprintw(
-		WINDOW	*win, 
-		int	y, 
-		int	x, 
-		const char *fmt, 
+		WINDOW	*win,
+		int	y,
+		int	x,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef vwprintw
 int	vwprintw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
 		va_list	argp)
 		{ return(*(int *)0); }
 
 #undef vw_printw
 int	vw_printw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
 		va_list	argp)
 		{ return(*(int *)0); }
 
@@ -2433,8 +2433,8 @@ int	vw_printw(
 
 #undef wredrawln
 int	wredrawln(
-		WINDOW	*win, 
-		int	beg, 
+		WINDOW	*win,
+		int	beg,
 		int	num)
 		{ return(*(int *)0); }
 
@@ -2454,16 +2454,16 @@ int	wnoutrefresh(
 
 #undef restartterm_sp
 int	restartterm_sp(
-		SCREEN	*sp, 
-		const char *termp, 
-		int	filenum, 
+		SCREEN	*sp,
+		const char *termp,
+		int	filenum,
 		int	*errret)
 		{ return(*(int *)0); }
 
 #undef restartterm
 int	restartterm(
-		const char *termp, 
-		int	filenum, 
+		const char *termp,
+		int	filenum,
 		int	*errret)
 		{ return(*(int *)0); }
 
@@ -2471,45 +2471,45 @@ int	restartterm(
 
 #undef vwscanw
 int	vwscanw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
 		va_list	argp)
 		{ return(*(int *)0); }
 
 #undef vw_scanw
 int	vw_scanw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
 		va_list	argp)
 		{ return(*(int *)0); }
 
 #undef scanw
 int	scanw(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef wscanw
 int	wscanw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef mvscanw
 int	mvscanw(
-		int	y, 
-		int	x, 
-		const char *fmt, 
+		int	y,
+		int	x,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef mvwscanw
 int	mvwscanw(
-		WINDOW	*win, 
-		int	y, 
-		int	x, 
-		const char *fmt, 
+		WINDOW	*win,
+		int	y,
+		int	x,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
@@ -2517,7 +2517,7 @@ int	mvwscanw(
 
 #undef getwin_sp
 WINDOW	*getwin_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		FILE	*filep)
 		{ return(*(WINDOW **)0); }
 
@@ -2528,13 +2528,13 @@ WINDOW	*getwin(
 
 #undef putwin
 int	putwin(
-		WINDOW	*win, 
+		WINDOW	*win,
 		FILE	*filep)
 		{ return(*(int *)0); }
 
 #undef scr_restore_sp
 int	scr_restore_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *file)
 		{ return(*(int *)0); }
 
@@ -2550,7 +2550,7 @@ int	scr_dump(
 
 #undef scr_init_sp
 int	scr_init_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *file)
 		{ return(*(int *)0); }
 
@@ -2561,7 +2561,7 @@ int	scr_init(
 
 #undef scr_set_sp
 int	scr_set_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *file)
 		{ return(*(int *)0); }
 
@@ -2574,16 +2574,16 @@ int	scr_set(
 
 #undef _nc_scroll_window
 void	_nc_scroll_window(
-		WINDOW	*win, 
-		int const n, 
-		int const top, 
-		int const bottom, 
+		WINDOW	*win,
+		int const n,
+		int const top,
+		int const bottom,
 		cchar_t	blank)
 		{ /* void */ }
 
 #undef wscrl
 int	wscrl(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -2591,7 +2591,7 @@ int	wscrl(
 
 #undef scrollok
 int	scrollok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
@@ -2599,8 +2599,8 @@ int	scrollok(
 
 #undef wsetscrreg
 int	wsetscrreg(
-		WINDOW	*win, 
-		int	top, 
+		WINDOW	*win,
+		int	top,
 		int	bottom)
 		{ return(*(int *)0); }
 
@@ -2618,54 +2618,54 @@ void	delscreen(
 
 #undef _nc_setupscreen_sp
 int	_nc_setupscreen_sp(
-		SCREEN	**spp, 
-		int	slines, 
-		int	scolumns, 
-		FILE	*output, 
-		int	filtered, 
+		SCREEN	**spp,
+		int	slines,
+		int	scolumns,
+		FILE	*output,
+		int	filtered,
 		int	slk_format)
 		{ return(*(int *)0); }
 
 #undef _nc_setupscreen
 int	_nc_setupscreen(
-		int	slines, 
-		int	scolumns, 
-		FILE	*output, 
-		int	filtered, 
+		int	slines,
+		int	scolumns,
+		FILE	*output,
+		int	filtered,
 		int	slk_format)
 		{ return(*(int *)0); }
 
 #undef _nc_ripoffline_sp
 int	_nc_ripoffline_sp(
-		SCREEN	*sp, 
-		int	line, 
+		SCREEN	*sp,
+		int	line,
 		int	(*init)(
-		WINDOW	*p1, 
+		WINDOW	*p1,
 		int	p2))
 		{ return(*(int *)0); }
 
 #undef _nc_ripoffline
 int	_nc_ripoffline(
-		int	line, 
+		int	line,
 		int	(*init)(
-		WINDOW	*p1, 
+		WINDOW	*p1,
 		int	p2))
 		{ return(*(int *)0); }
 
 #undef ripoffline_sp
 int	ripoffline_sp(
-		SCREEN	*sp, 
-		int	line, 
+		SCREEN	*sp,
+		int	line,
 		int	(*init)(
-		WINDOW	*p1, 
+		WINDOW	*p1,
 		int	p2))
 		{ return(*(int *)0); }
 
 #undef ripoffline
 int	ripoffline(
-		int	line, 
+		int	line,
 		int	(*init)(
-		WINDOW	*p1, 
+		WINDOW	*p1,
 		int	p2))
 		{ return(*(int *)0); }
 
@@ -2673,13 +2673,13 @@ int	ripoffline(
 
 #undef _nc_format_slks
 int	_nc_format_slks(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	cols)
 		{ return(*(int *)0); }
 
 #undef _nc_slk_initialize
 int	_nc_slk_initialize(
-		WINDOW	*stwin, 
+		WINDOW	*stwin,
 		int	cols)
 		{ return(*(int *)0); }
 
@@ -2696,16 +2696,16 @@ int	slk_restore(void)
 
 #undef slk_attr_set_sp
 int	slk_attr_set_sp(
-		SCREEN	*sp, 
-		const attr_t attr, 
-		short	pair_arg, 
+		SCREEN	*sp,
+		const attr_t attr,
+		short	pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
 #undef slk_attr_set
 int	slk_attr_set(
-		const attr_t attr, 
-		short	pair_arg, 
+		const attr_t attr,
+		short	pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -2713,7 +2713,7 @@ int	slk_attr_set(
 
 #undef slk_attroff_sp
 int	slk_attroff_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const chtype attr)
 		{ return(*(int *)0); }
 
@@ -2726,7 +2726,7 @@ int	slk_attroff(
 
 #undef slk_attron_sp
 int	slk_attron_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const chtype attr)
 		{ return(*(int *)0); }
 
@@ -2739,7 +2739,7 @@ int	slk_attron(
 
 #undef slk_attrset_sp
 int	slk_attrset_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const chtype attr)
 		{ return(*(int *)0); }
 
@@ -2774,7 +2774,7 @@ int	slk_clear(void)
 
 #undef slk_color_sp
 int	slk_color_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		short	pair_arg)
 		{ return(*(int *)0); }
 
@@ -2785,7 +2785,7 @@ int	slk_color(
 
 #undef extended_slk_color_sp
 int	extended_slk_color_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	pair_arg)
 		{ return(*(int *)0); }
 
@@ -2798,7 +2798,7 @@ int	extended_slk_color(
 
 #undef slk_init_sp
 int	slk_init_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	format)
 		{ return(*(int *)0); }
 
@@ -2811,7 +2811,7 @@ int	slk_init(
 
 #undef slk_label_sp
 char	*slk_label_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	n)
 		{ return(*(char **)0); }
 
@@ -2844,16 +2844,16 @@ int	slk_refresh(void)
 
 #undef slk_set_sp
 int	slk_set_sp(
-		SCREEN	*sp, 
-		int	i, 
-		const char *astr, 
+		SCREEN	*sp,
+		int	i,
+		const char *astr,
 		int	format)
 		{ return(*(int *)0); }
 
 #undef slk_set
 int	slk_set(
-		int	i, 
-		const char *astr, 
+		int	i,
+		const char *astr,
 		int	format)
 		{ return(*(int *)0); }
 
@@ -2872,7 +2872,7 @@ int	slk_touch(void)
 
 #undef is_linetouched
 NCURSES_BOOL is_linetouched(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	line)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -2883,9 +2883,9 @@ NCURSES_BOOL is_wintouched(
 
 #undef wtouchln
 int	wtouchln(
-		WINDOW	*win, 
-		int	y, 
-		int	n, 
+		WINDOW	*win,
+		int	y,
+		int	n,
 		int	changed)
 		{ return(*(int *)0); }
 
@@ -2893,7 +2893,7 @@ int	wtouchln(
 
 #undef _tracedump
 void	_tracedump(
-		const char *name, 
+		const char *name,
 		WINDOW	*win)
 		{ /* void */ }
 
@@ -2901,19 +2901,19 @@ void	_tracedump(
 
 #undef _nc_trace_mmask_t
 char	*_nc_trace_mmask_t(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		mmask_t	code)
 		{ return(*(char **)0); }
 
 #undef _nc_tracemouse
 char	*_nc_tracemouse(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		MEVENT const *ep)
 		{ return(*(char **)0); }
 
 #undef _nc_retrace_mmask_t
 mmask_t	_nc_retrace_mmask_t(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		mmask_t	code)
 		{ return(*(mmask_t *)0); }
 
@@ -2938,7 +2938,7 @@ void	_nc_fifo_dump(
 
 #undef ungetch_sp
 int	ungetch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -2951,20 +2951,20 @@ int	ungetch(
 
 #undef vidputs_sp
 int	vidputs_sp(
-		SCREEN	*sp, 
-		chtype	newmode, 
+		SCREEN	*sp,
+		chtype	newmode,
 		NCURSES_OUTC_sp outc)
 		{ return(*(int *)0); }
 
 #undef vidputs
 int	vidputs(
-		chtype	newmode, 
+		chtype	newmode,
 		NCURSES_OUTC outc)
 		{ return(*(int *)0); }
 
 #undef vidattr_sp
 int	vidattr_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		chtype	newmode)
 		{ return(*(int *)0); }
 
@@ -2986,8 +2986,8 @@ chtype	termattrs(void)
 
 #undef wvline
 int	wvline(
-		WINDOW	*win, 
-		chtype	ch, 
+		WINDOW	*win,
+		chtype	ch,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -2995,8 +2995,8 @@ int	wvline(
 
 #undef wattr_off
 int	wattr_off(
-		WINDOW	*win, 
-		attr_t	at, 
+		WINDOW	*win,
+		attr_t	at,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -3004,8 +3004,8 @@ int	wattr_off(
 
 #undef wattr_on
 int	wattr_on(
-		WINDOW	*win, 
-		attr_t	at, 
+		WINDOW	*win,
+		attr_t	at,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -3025,14 +3025,14 @@ void	_nc_synchook(
 
 #undef mvderwin
 int	mvderwin(
-		WINDOW	*win, 
-		int	y, 
+		WINDOW	*win,
+		int	y,
 		int	x)
 		{ return(*(int *)0); }
 
 #undef syncok
 int	syncok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL bf)
 		{ return(*(int *)0); }
 
@@ -3071,14 +3071,14 @@ struct panelhook *_nc_panelhook(void)
 
 #undef _nc_printf_string_sp
 char	*_nc_printf_string_sp(
-		SCREEN	*sp, 
-		const char *fmt, 
+		SCREEN	*sp,
+		const char *fmt,
 		va_list	ap)
 		{ return(*(char **)0); }
 
 #undef _nc_printf_string
 char	*_nc_printf_string(
-		const char *fmt, 
+		const char *fmt,
 		va_list	ap)
 		{ return(*(char **)0); }
 
@@ -3095,18 +3095,18 @@ int	doupdate(void)
 
 #undef _nc_scrolln_sp
 int	_nc_scrolln_sp(
-		SCREEN	*sp, 
-		int	n, 
-		int	top, 
-		int	bot, 
+		SCREEN	*sp,
+		int	n,
+		int	top,
+		int	bot,
 		int	maxy)
 		{ return(*(int *)0); }
 
 #undef _nc_scrolln
 int	_nc_scrolln(
-		int	n, 
-		int	top, 
-		int	bot, 
+		int	n,
+		int	top,
+		int	bot,
 		int	maxy)
 		{ return(*(int *)0); }
 
@@ -3139,7 +3139,7 @@ void	_nc_screen_wrap(void)
 
 #undef _nc_do_xmc_glitch_sp
 void	_nc_do_xmc_glitch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		attr_t	previous)
 		{ /* void */ }
 
@@ -3152,7 +3152,7 @@ void	_nc_do_xmc_glitch(
 
 #undef _nc_varargs
 char	*_nc_varargs(
-		const char *fmt, 
+		const char *fmt,
 		va_list	ap)
 		{ return(*(char **)0); }
 
@@ -3170,7 +3170,7 @@ void	_nc_freeall(void)
 
 #undef _nc_free_and_exit_sp
 void	_nc_free_and_exit_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	code)
 		{ /* void */ }
 
@@ -3205,13 +3205,13 @@ wint_t	_nc_to_widechar(
 
 #undef wadd_wch
 int	wadd_wch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const cchar_t *wch)
 		{ return(*(int *)0); }
 
 #undef wecho_wchar
 int	wecho_wchar(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const cchar_t *wch)
 		{ return(*(int *)0); }
 
@@ -3219,14 +3219,14 @@ int	wecho_wchar(
 
 #undef wborder_set
 int	wborder_set(
-		WINDOW	*win, 
-		const cchar_t *ls, 
-		const cchar_t *rs, 
-		const cchar_t *ts, 
-		const cchar_t *bs, 
-		const cchar_t *tl, 
-		const cchar_t *tr, 
-		const cchar_t *bl, 
+		WINDOW	*win,
+		const cchar_t *ls,
+		const cchar_t *rs,
+		const cchar_t *ts,
+		const cchar_t *bs,
+		const cchar_t *tl,
+		const cchar_t *tr,
+		const cchar_t *bl,
 		const cchar_t *br)
 		{ return(*(int *)0); }
 
@@ -3234,29 +3234,41 @@ int	wborder_set(
 
 #undef setcchar
 int	setcchar(
-		cchar_t	*wcval, 
-		const wchar_t *wch, 
-		const attr_t attrs, 
-		short	pair_arg, 
+		cchar_t	*wcval,
+		const wchar_t *wch,
+		const attr_t attrs,
+		short	pair_arg,
 		const void *opts)
 		{ return(*(int *)0); }
 
 #undef getcchar
 int	getcchar(
-		const cchar_t *wcval, 
-		wchar_t	*wch, 
-		attr_t	*attrs, 
-		short	*pair_arg, 
+		const cchar_t *wcval,
+		wchar_t	*wch,
+		attr_t	*attrs,
+		short	*pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
 /* ./widechar/lib_erasewchar.c */
 
+#undef erasewchar_sp
+int	erasewchar_sp(
+		SCREEN	*sp,
+		wchar_t	*wch)
+		{ return(*(int *)0); }
+
 #undef erasewchar
 int	erasewchar(
 		wchar_t	*wch)
 		{ return(*(int *)0); }
 
+#undef killwchar_sp
+int	killwchar_sp(
+		SCREEN	*sp,
+		wchar_t	*wch)
+		{ return(*(int *)0); }
+
 #undef killwchar
 int	killwchar(
 		wchar_t	*wch)
@@ -3266,7 +3278,7 @@ int	killwchar(
 
 #undef wget_wch
 int	wget_wch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		wint_t	*result)
 		{ return(*(int *)0); }
 
@@ -3274,8 +3286,8 @@ int	wget_wch(
 
 #undef wgetn_wstr
 int	wgetn_wstr(
-		WINDOW	*win, 
-		wint_t	*str, 
+		WINDOW	*win,
+		wint_t	*str,
 		int	maxlen)
 		{ return(*(int *)0); }
 
@@ -3283,8 +3295,8 @@ int	wgetn_wstr(
 
 #undef whline_set
 int	whline_set(
-		WINDOW	*win, 
-		const cchar_t *ch, 
+		WINDOW	*win,
+		const cchar_t *ch,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -3292,7 +3304,7 @@ int	whline_set(
 
 #undef win_wch
 int	win_wch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		cchar_t	*wcval)
 		{ return(*(int *)0); }
 
@@ -3300,8 +3312,8 @@ int	win_wch(
 
 #undef win_wchnstr
 int	win_wchnstr(
-		WINDOW	*win, 
-		cchar_t	*wchstr, 
+		WINDOW	*win,
+		cchar_t	*wchstr,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -3309,20 +3321,20 @@ int	win_wchnstr(
 
 #undef _nc_insert_wch
 int	_nc_insert_wch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const cchar_t *wch)
 		{ return(*(int *)0); }
 
 #undef wins_wch
 int	wins_wch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const cchar_t *wch)
 		{ return(*(int *)0); }
 
 #undef wins_nwstr
 int	wins_nwstr(
-		WINDOW	*win, 
-		const wchar_t *wstr, 
+		WINDOW	*win,
+		const wchar_t *wstr,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -3330,14 +3342,14 @@ int	wins_nwstr(
 
 #undef winnwstr
 int	winnwstr(
-		WINDOW	*win, 
-		wchar_t	*wstr, 
+		WINDOW	*win,
+		wchar_t	*wstr,
 		int	n)
 		{ return(*(int *)0); }
 
 #undef winwstr
 int	winwstr(
-		WINDOW	*win, 
+		WINDOW	*win,
 		wchar_t	*wstr)
 		{ return(*(int *)0); }
 
@@ -3352,7 +3364,7 @@ const char *key_name(
 
 #undef pecho_wchar
 int	pecho_wchar(
-		WINDOW	*pad, 
+		WINDOW	*pad,
 		const cchar_t *wch)
 		{ return(*(int *)0); }
 
@@ -3360,8 +3372,8 @@ int	pecho_wchar(
 
 #undef slk_wset
 int	slk_wset(
-		int	i, 
-		const wchar_t *astr, 
+		int	i,
+		const wchar_t *astr,
 		int	format)
 		{ return(*(int *)0); }
 
@@ -3369,14 +3381,14 @@ int	slk_wset(
 
 #undef _nc_wcrtomb
 size_t	_nc_wcrtomb(
-		char	*target, 
-		wchar_t	source, 
+		char	*target,
+		wchar_t	source,
 		mbstate_t *state)
 		{ return(*(size_t *)0); }
 
 #undef unget_wch_sp
 int	unget_wch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const wchar_t wch)
 		{ return(*(int *)0); }
 
@@ -3389,33 +3401,33 @@ int	unget_wch(
 
 #undef vid_puts_sp
 int	vid_puts_sp(
-		SCREEN	*sp, 
-		attr_t	newmode, 
-		short	pair_arg, 
-		void	*opts, 
+		SCREEN	*sp,
+		attr_t	newmode,
+		short	pair_arg,
+		void	*opts,
 		NCURSES_OUTC_sp outc)
 		{ return(*(int *)0); }
 
 #undef vid_puts
 int	vid_puts(
-		attr_t	newmode, 
-		short	pair_arg, 
-		void	*opts, 
+		attr_t	newmode,
+		short	pair_arg,
+		void	*opts,
 		NCURSES_OUTC outc)
 		{ return(*(int *)0); }
 
 #undef vid_attr_sp
 int	vid_attr_sp(
-		SCREEN	*sp, 
-		attr_t	newmode, 
-		short	pair_arg, 
+		SCREEN	*sp,
+		attr_t	newmode,
+		short	pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
 #undef vid_attr
 int	vid_attr(
-		attr_t	newmode, 
-		short	pair_arg, 
+		attr_t	newmode,
+		short	pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -3432,8 +3444,8 @@ attr_t	term_attrs(void)
 
 #undef wvline_set
 int	wvline_set(
-		WINDOW	*win, 
-		const cchar_t *ch, 
+		WINDOW	*win,
+		const cchar_t *ch,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -3450,7 +3462,7 @@ void	_nc_init_wacs(void)
 
 #undef wunctrl_sp
 wchar_t	*wunctrl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		cchar_t	*wc)
 		{ return(*(wchar_t **)0); }
 
@@ -3463,31 +3475,31 @@ wchar_t	*wunctrl(
 
 #undef _nc_toggle_attr_on
 void	_nc_toggle_attr_on(
-		attr_t	*S, 
+		attr_t	*S,
 		attr_t	at)
 		{ /* void */ }
 
 #undef _nc_toggle_attr_off
 void	_nc_toggle_attr_off(
-		attr_t	*S, 
+		attr_t	*S,
 		attr_t	at)
 		{ /* void */ }
 
 #undef _nc_DelCharCost_sp
 int	_nc_DelCharCost_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	count)
 		{ return(*(int *)0); }
 
 #undef _nc_InsCharCost_sp
 int	_nc_InsCharCost_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	count)
 		{ return(*(int *)0); }
 
 #undef _nc_UpdateAttrs_sp
 void	_nc_UpdateAttrs_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const cchar_t *c)
 		{ /* void */ }
 
@@ -3510,7 +3522,7 @@ void	_nc_UpdateAttrs(
 
 #undef use_legacy_coding_sp
 int	use_legacy_coding_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	level)
 		{ return(*(int *)0); }
 
@@ -3532,14 +3544,14 @@ int	use_default_colors(void)
 
 #undef assume_default_colors_sp
 int	assume_default_colors_sp(
-		SCREEN	*sp, 
-		int	fg, 
+		SCREEN	*sp,
+		int	fg,
 		int	bg)
 		{ return(*(int *)0); }
 
 #undef assume_default_colors
 int	assume_default_colors(
-		int	fg, 
+		int	fg,
 		int	bg)
 		{ return(*(int *)0); }
 
@@ -3547,14 +3559,14 @@ int	assume_default_colors(
 
 #undef mcprint_sp
 int	mcprint_sp(
-		SCREEN	*sp, 
-		char	*data, 
+		SCREEN	*sp,
+		char	*data,
 		int	len)
 		{ return(*(int *)0); }
 
 #undef mcprint
 int	mcprint(
-		char	*data, 
+		char	*data,
 		int	len)
 		{ return(*(int *)0); }
 
@@ -3567,55 +3579,55 @@ void	_nc_free_ordered_pairs(
 
 #undef _nc_reset_color_pair
 void	_nc_reset_color_pair(
-		SCREEN	*sp, 
-		int	pair, 
+		SCREEN	*sp,
+		int	pair,
 		colorpair_t *next)
 		{ /* void */ }
 
 #undef _nc_set_color_pair
 void	_nc_set_color_pair(
-		SCREEN	*sp, 
-		int	pair, 
+		SCREEN	*sp,
+		int	pair,
 		int	mode)
 		{ /* void */ }
 
 #undef _nc_copy_pairs
 void	_nc_copy_pairs(
-		SCREEN	*sp, 
-		colorpair_t *target, 
-		colorpair_t *source, 
+		SCREEN	*sp,
+		colorpair_t *target,
+		colorpair_t *source,
 		int	length)
 		{ /* void */ }
 
 #undef alloc_pair_sp
 int	alloc_pair_sp(
-		SCREEN	*sp, 
-		int	fg, 
+		SCREEN	*sp,
+		int	fg,
 		int	bg)
 		{ return(*(int *)0); }
 
 #undef find_pair_sp
 int	find_pair_sp(
-		SCREEN	*sp, 
-		int	fg, 
+		SCREEN	*sp,
+		int	fg,
 		int	bg)
 		{ return(*(int *)0); }
 
 #undef free_pair_sp
 int	free_pair_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	pair)
 		{ return(*(int *)0); }
 
 #undef alloc_pair
 int	alloc_pair(
-		int	f, 
+		int	f,
 		int	b)
 		{ return(*(int *)0); }
 
 #undef find_pair
 int	find_pair(
-		int	f, 
+		int	f,
 		int	b)
 		{ return(*(int *)0); }
 
@@ -3628,40 +3640,40 @@ int	free_pair(
 
 #undef is_term_resized_sp
 NCURSES_BOOL is_term_resized_sp(
-		SCREEN	*sp, 
-		int	ToLines, 
+		SCREEN	*sp,
+		int	ToLines,
 		int	ToCols)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_term_resized
 NCURSES_BOOL is_term_resized(
-		int	ToLines, 
+		int	ToLines,
 		int	ToCols)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef resize_term_sp
 int	resize_term_sp(
-		SCREEN	*sp, 
-		int	ToLines, 
+		SCREEN	*sp,
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
 #undef resize_term
 int	resize_term(
-		int	ToLines, 
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
 #undef resizeterm_sp
 int	resizeterm_sp(
-		SCREEN	*sp, 
-		int	ToLines, 
+		SCREEN	*sp,
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
 #undef resizeterm
 int	resizeterm(
-		int	ToLines, 
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
@@ -3676,8 +3688,8 @@ void	_nc_trace_xnames(
 
 #undef use_screen
 int	use_screen(
-		SCREEN	*screen, 
-		NCURSES_SCREEN_CB func, 
+		SCREEN	*screen,
+		NCURSES_SCREEN_CB func,
 		void	*data)
 		{ return(*(int *)0); }
 
@@ -3685,8 +3697,8 @@ int	use_screen(
 
 #undef use_window
 int	use_window(
-		WINDOW	*win, 
-		NCURSES_WINDOW_CB func, 
+		WINDOW	*win,
+		NCURSES_WINDOW_CB func,
 		void	*data)
 		{ return(*(int *)0); }
 
@@ -3694,8 +3706,8 @@ int	use_window(
 
 #undef wresize
 int	wresize(
-		WINDOW	*win, 
-		int	ToLines, 
+		WINDOW	*win,
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
@@ -3723,7 +3735,7 @@ char	*_nc_basename(
 
 #undef _nc_access
 int	_nc_access(
-		const char *path, 
+		const char *path,
 		int	mode)
 		{ return(*(int *)0); }
 
@@ -3741,12 +3753,25 @@ NCURSES_BOOL _nc_is_file_path(
 int	_nc_env_access(void)
 		{ return(*(int *)0); }
 
+#undef _nc_safe_fopen
+FILE	*_nc_safe_fopen(
+		const char *path,
+		const char *mode)
+		{ return(*(FILE **)0); }
+
+#undef _nc_safe_open3
+int	_nc_safe_open3(
+		const char *path,
+		int	flags,
+		mode_t	mode)
+		{ return(*(int *)0); }
+
 /* ./tinfo/add_tries.c */
 
 #undef _nc_add_to_try
 int	_nc_add_to_try(
-		TRIES	**tree, 
-		const char *str, 
+		TRIES	**tree,
+		const char *str,
 		unsigned code)
 		{ return(*(int *)0); }
 
@@ -3754,25 +3779,25 @@ int	_nc_add_to_try(
 
 #undef _nc_align_termtype
 void	_nc_align_termtype(
-		TERMTYPE2 *to, 
+		TERMTYPE2 *to,
 		TERMTYPE2 *from)
 		{ /* void */ }
 
 #undef _nc_copy_termtype
 void	_nc_copy_termtype(
-		TERMTYPE *dst, 
+		TERMTYPE *dst,
 		const TERMTYPE *src)
 		{ /* void */ }
 
 #undef _nc_copy_termtype2
 void	_nc_copy_termtype2(
-		TERMTYPE2 *dst, 
+		TERMTYPE2 *dst,
 		const TERMTYPE2 *src)
 		{ /* void */ }
 
 #undef _nc_export_termtype2
 void	_nc_export_termtype2(
-		TERMTYPE *dst, 
+		TERMTYPE *dst,
 		const TERMTYPE2 *src)
 		{ /* void */ }
 
@@ -3842,19 +3867,19 @@ void	_nc_get_type(
 
 #undef _nc_warning
 void	_nc_warning(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
 #undef _nc_err_abort
 void	_nc_err_abort(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
 #undef _nc_syserr_abort
 void	_nc_syserr_abort(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
@@ -3862,14 +3887,14 @@ void	_nc_syserr_abort(
 
 #undef _nc_find_entry
 struct name_table_entry const *_nc_find_entry(
-		const char *string, 
+		const char *string,
 		const HashValue *hash_table)
 		{ return(*(struct name_table_entry const **)0); }
 
 #undef _nc_find_type_entry
 struct name_table_entry const *_nc_find_type_entry(
-		const char *string, 
-		int	type, 
+		const char *string,
+		int	type,
 		NCURSES_BOOL termcap)
 		{ return(*(struct name_table_entry const **)0); }
 
@@ -3906,13 +3931,13 @@ void	_nc_last_db(void)
 
 #undef _nc_next_db
 const char *_nc_next_db(
-		DBDIRS	*state, 
+		DBDIRS	*state,
 		int	*offset)
 		{ return(*(const char **)0); }
 
 #undef _nc_first_db
 void	_nc_first_db(
-		DBDIRS	*state, 
+		DBDIRS	*state,
 		int	*offset)
 		{ /* void */ }
 
@@ -3920,7 +3945,7 @@ void	_nc_first_db(
 
 #undef _nc_doalloc
 void	*_nc_doalloc(
-		void	*oldp, 
+		void	*oldp,
 		size_t	amount)
 		{ return(*(void **)0); }
 
@@ -3933,7 +3958,7 @@ ENTRY	*_nc_tail;
 
 #undef _nc_free_entry
 void	_nc_free_entry(
-		ENTRY	*headp, 
+		ENTRY	*headp,
 		TERMTYPE2 *tterm)
 		{ /* void */ }
 
@@ -3970,6 +3995,11 @@ void	_nc_free_termtype(
 		TERMTYPE *ptr)
 		{ /* void */ }
 
+#undef _nc_free_termtype1
+void	_nc_free_termtype1(
+		TERMTYPE *ptr)
+		{ /* void */ }
+
 #undef _nc_free_termtype2
 void	_nc_free_termtype2(
 		TERMTYPE2 *ptr)
@@ -3992,7 +4022,7 @@ int	_nc_getenv_num(
 
 #undef _nc_setenv_num
 void	_nc_setenv_num(
-		const char *name, 
+		const char *name,
 		int	value)
 		{ /* void */ }
 
@@ -4027,8 +4057,8 @@ void	_nc_init_acs(void)
 /* ./tinfo/lib_baudrate.c */
 
 struct speed {
-    int given_speed; 
-    int actual_speed; 
+    int given_speed;
+    int actual_speed;
 };
 
 #undef _nc_baudrate
@@ -4067,7 +4097,7 @@ TERMINAL *_nc_cur_term(void)
 
 #undef set_curterm_sp
 TERMINAL *set_curterm_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		TERMINAL *termp)
 		{ return(*(TERMINAL **)0); }
 
@@ -4078,7 +4108,7 @@ TERMINAL *set_curterm(
 
 #undef del_curterm_sp
 int	del_curterm_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		TERMINAL *termp)
 		{ return(*(int *)0); }
 
@@ -4194,7 +4224,7 @@ struct kn { short offset; int code; };
 
 #undef keyname_sp
 const char *keyname_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	c)
 		{ return(*(const char **)0); }
 
@@ -4218,7 +4248,7 @@ char	*longname(void)
 
 #undef napms_sp
 int	napms_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ms)
 		{ return(*(int *)0); }
 
@@ -4231,19 +4261,19 @@ int	napms(
 
 #undef idlok
 int	idlok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef idcok
 void	idcok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ /* void */ }
 
 #undef halfdelay_sp
 int	halfdelay_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	t)
 		{ return(*(int *)0); }
 
@@ -4254,37 +4284,37 @@ int	halfdelay(
 
 #undef nodelay
 int	nodelay(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef notimeout
 int	notimeout(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL f)
 		{ return(*(int *)0); }
 
 #undef wtimeout
 void	wtimeout(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	delay)
 		{ /* void */ }
 
 #undef keypad
 int	keypad(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef meta
 int	meta(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef curs_set_sp
 int	curs_set_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	vis)
 		{ return(*(int *)0); }
 
@@ -4295,7 +4325,7 @@ int	curs_set(
 
 #undef typeahead_sp
 int	typeahead_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	fd)
 		{ return(*(int *)0); }
 
@@ -4306,7 +4336,7 @@ int	typeahead(
 
 #undef has_key_sp
 int	has_key_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	keycode)
 		{ return(*(int *)0); }
 
@@ -4317,14 +4347,14 @@ int	has_key(
 
 #undef _nc_putp_flush_sp
 int	_nc_putp_flush_sp(
-		SCREEN	*sp, 
-		const char *name, 
+		SCREEN	*sp,
+		const char *name,
 		const char *value)
 		{ return(*(int *)0); }
 
 #undef _nc_keypad
 int	_nc_keypad(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	flag)
 		{ return(*(int *)0); }
 
@@ -4386,17 +4416,53 @@ void	noqiflush(void)
 
 #undef intrflush_sp
 int	intrflush_sp(
-		SCREEN	*sp, 
-		WINDOW	*win, 
+		SCREEN	*sp,
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef intrflush
 int	intrflush(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
+#undef is_nl_sp
+int	is_nl_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_raw_sp
+int	is_raw_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_cbreak_sp
+int	is_cbreak_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_echo_sp
+int	is_echo_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_nl
+int	is_nl(void)
+		{ return(*(int *)0); }
+
+#undef is_raw
+int	is_raw(void)
+		{ return(*(int *)0); }
+
+#undef is_cbreak
+int	is_cbreak(void)
+		{ return(*(int *)0); }
+
+#undef is_echo
+int	is_echo(void)
+		{ return(*(int *)0); }
+
 /* ./tinfo/lib_setup.c */
 
 #undef _nc_ttytype
@@ -4432,7 +4498,7 @@ int	_nc_TABSIZE(void)
 
 #undef set_tabsize_sp
 int	set_tabsize_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	value)
 		{ return(*(int *)0); }
 
@@ -4448,13 +4514,13 @@ int	_nc_handle_sigwinch(
 
 #undef use_env_sp
 void	use_env_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		NCURSES_BOOL f)
 		{ /* void */ }
 
 #undef use_tioctl_sp
 void	use_tioctl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		NCURSES_BOOL f)
 		{ /* void */ }
 
@@ -4470,8 +4536,8 @@ void	use_tioctl(
 
 #undef _nc_get_screensize
 void	_nc_get_screensize(
-		SCREEN	*sp, 
-		int	*linep, 
+		SCREEN	*sp,
+		int	*linep,
 		int	*colp)
 		{ /* void */ }
 
@@ -4482,13 +4548,13 @@ void	_nc_update_screensize(
 
 #undef _nc_setup_tinfo
 int	_nc_setup_tinfo(
-		const char *const tn, 
+		const char *const tn,
 		TERMTYPE2 *const tp)
 		{ return(*(int *)0); }
 
 #undef _nc_tinfo_cmdch
 void	_nc_tinfo_cmdch(
-		TERMINAL *termp, 
+		TERMINAL *termp,
 		int	proto)
 		{ /* void */ }
 
@@ -4507,9 +4573,9 @@ int	_nc_locale_breaks_acs(
 
 #undef _nc_setupterm
 int	_nc_setupterm(
-		const char *tname, 
-		int	Filedes, 
-		int	*errret, 
+		const char *tname,
+		int	Filedes,
+		int	*errret,
 		int	reuse)
 		{ return(*(int *)0); }
 
@@ -4527,8 +4593,8 @@ SCREEN	*new_prescr(void)
 
 #undef setupterm
 int	setupterm(
-		const char *tname, 
-		int	Filedes, 
+		const char *tname,
+		int	Filedes,
 		int	*errret)
 		{ return(*(int *)0); }
 
@@ -4541,20 +4607,20 @@ char	*BC;
 
 #undef tgetent_sp
 int	tgetent_sp(
-		SCREEN	*sp, 
-		char	*bufp, 
+		SCREEN	*sp,
+		char	*bufp,
 		const char *name)
 		{ return(*(int *)0); }
 
 #undef tgetent
 int	tgetent(
-		char	*bufp, 
+		char	*bufp,
 		const char *name)
 		{ return(*(int *)0); }
 
 #undef tgetflag_sp
 int	tgetflag_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *id)
 		{ return(*(int *)0); }
 
@@ -4565,7 +4631,7 @@ int	tgetflag(
 
 #undef tgetnum_sp
 int	tgetnum_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *id)
 		{ return(*(int *)0); }
 
@@ -4576,14 +4642,14 @@ int	tgetnum(
 
 #undef tgetstr_sp
 char	*tgetstr_sp(
-		SCREEN	*sp, 
-		const char *id, 
+		SCREEN	*sp,
+		const char *id,
 		char	**area)
 		{ return(*(char **)0); }
 
 #undef tgetstr
 char	*tgetstr(
-		const char *id, 
+		const char *id,
 		char	**area)
 		{ return(*(char **)0); }
 
@@ -4602,8 +4668,8 @@ char	*termname(void)
 
 #undef tgoto
 char	*tgoto(
-		const char *string, 
-		int	x, 
+		const char *string,
+		int	x,
 		int	y)
 		{ return(*(char **)0); }
 
@@ -4611,7 +4677,7 @@ char	*tgoto(
 
 #undef tigetflag_sp
 int	tigetflag_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -4622,7 +4688,7 @@ int	tigetflag(
 
 #undef tigetnum_sp
 int	tigetnum_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -4633,7 +4699,7 @@ int	tigetnum(
 
 #undef tigetstr_sp
 char	*tigetstr_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(char **)0); }
 
@@ -4647,32 +4713,58 @@ char	*tigetstr(
 #undef _nc_tparm_err
 int	_nc_tparm_err;
 
+#undef _nc_free_tparm
+void	_nc_free_tparm(
+		TERMINAL *termp)
+		{ /* void */ }
+
 #undef _nc_tparm_analyze
 int	_nc_tparm_analyze(
-		const char *string, 
-		char	*p_is_s[9], 
+		TERMINAL *term,
+		const char *string,
+		char	**p_is_s,
 		int	*_nc_popcount)
 		{ return(*(int *)0); }
 
 #undef tparm
 char	*tparm(
-		const char *string, 
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
 #undef tiparm
 char	*tiparm(
-		const char *string, 
+		const char *string,
+		...)
+		{ return(*(char **)0); }
+
+#undef tiparm_s
+char	*tiparm_s(
+		int	num_expected,
+		int	tparm_type,
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
+#undef tiscan_s
+int	tiscan_s(
+		int	*num_expected,
+		int	*tparm_type,
+		const char *string)
+		{ return(*(int *)0); }
+
 #undef _nc_tiparm
 char	*_nc_tiparm(
-		int	expected, 
-		const char *string, 
+		int	expected,
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
+#undef _nc_reset_tparm
+void	_nc_reset_tparm(
+		TERMINAL *term)
+		{ /* void */ }
+
 /* ./tinfo/lib_tputs.c */
 
 #undef PC
@@ -4689,7 +4781,7 @@ void	_nc_set_no_padding(
 
 #undef delay_output_sp
 int	delay_output_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ms)
 		{ return(*(int *)0); }
 
@@ -4709,7 +4801,7 @@ void	_nc_flush(void)
 
 #undef _nc_outch_sp
 int	_nc_outch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -4720,7 +4812,7 @@ int	_nc_outch(
 
 #undef _nc_putchar_sp
 int	_nc_putchar_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -4731,7 +4823,7 @@ int	_nc_putchar(
 
 #undef putp_sp
 int	putp_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *string)
 		{ return(*(int *)0); }
 
@@ -4742,35 +4834,35 @@ int	putp(
 
 #undef _nc_putp_sp
 int	_nc_putp_sp(
-		SCREEN	*sp, 
-		const char *name, 
+		SCREEN	*sp,
+		const char *name,
 		const char *string)
 		{ return(*(int *)0); }
 
 #undef _nc_putp
 int	_nc_putp(
-		const char *name, 
+		const char *name,
 		const char *string)
 		{ return(*(int *)0); }
 
 #undef tputs_sp
 int	tputs_sp(
-		SCREEN	*sp, 
-		const char *string, 
-		int	affcnt, 
+		SCREEN	*sp,
+		const char *string,
+		int	affcnt,
 		NCURSES_OUTC_sp outc)
 		{ return(*(int *)0); }
 
 #undef _nc_outc_wrapper
 int	_nc_outc_wrapper(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	c)
 		{ return(*(int *)0); }
 
 #undef tputs
 int	tputs(
-		const char *string, 
-		int	affcnt, 
+		const char *string,
+		int	affcnt,
 		int	(*outc)(
 		int	p1))
 		{ return(*(int *)0); }
@@ -4810,7 +4902,7 @@ void	trace(
 
 #undef _tracef
 void	_tracef(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ /* void */ }
 
@@ -4866,8 +4958,8 @@ WINDOW	*_nc_retrace_win(
 
 #undef _nc_fmt_funcptr
 char	*_nc_fmt_funcptr(
-		char	*target, 
-		const char *source, 
+		char	*target,
+		const char *source,
 		size_t	size)
 		{ return(*(char **)0); }
 
@@ -4878,7 +4970,7 @@ int	_nc_use_tracef(
 
 #undef _nc_locked_tracef
 void	_nc_locked_tracef(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ /* void */ }
 
@@ -4886,7 +4978,7 @@ void	_nc_locked_tracef(
 
 #undef _traceattr2
 char	*_traceattr2(
-		int	bufnum, 
+		int	bufnum,
 		chtype	newmode)
 		{ return(*(char **)0); }
 
@@ -4907,13 +4999,13 @@ attr_t	_nc_retrace_attr_t(
 
 #undef _nc_altcharset_name
 const char *_nc_altcharset_name(
-		attr_t	attr, 
+		attr_t	attr,
 		chtype	ch)
 		{ return(*(const char **)0); }
 
 #undef _tracechtype2
 char	*_tracechtype2(
-		int	bufnum, 
+		int	bufnum,
 		chtype	ch)
 		{ return(*(char **)0); }
 
@@ -4929,7 +5021,7 @@ chtype	_nc_retrace_chtype(
 
 #undef _tracecchar_t2
 char	*_tracecchar_t2(
-		int	bufnum, 
+		int	bufnum,
 		const cchar_t *ch)
 		{ return(*(char **)0); }
 
@@ -4942,7 +5034,7 @@ char	*_tracecchar_t(
 
 #undef _nc_trace_ttymode
 char	*_nc_trace_ttymode(
-		struct termios *tty)
+		const struct termios *tty)
 		{ return(*(char **)0); }
 
 #undef _nc_tracebits
@@ -4953,7 +5045,7 @@ char	*_nc_tracebits(void)
 
 #undef _nc_tracechar
 char	*_nc_tracechar(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(char **)0); }
 
@@ -4966,7 +5058,7 @@ char	*_tracechar(
 
 #undef _nc_get_tty_mode_sp
 int	_nc_get_tty_mode_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		struct termios *buf)
 		{ return(*(int *)0); }
 
@@ -4977,7 +5069,7 @@ int	_nc_get_tty_mode(
 
 #undef _nc_set_tty_mode_sp
 int	_nc_set_tty_mode_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		struct termios *buf)
 		{ return(*(int *)0); }
 
@@ -5044,9 +5136,9 @@ int	resetty(void)
 
 #undef _nc_timed_wait
 int	_nc_timed_wait(
-		SCREEN	*sp, 
-		int	mode, 
-		int	milliseconds, 
+		SCREEN	*sp,
+		int	mode,
+		int	milliseconds,
 		int	*timeleft)
 		{ return(*(int *)0); }
 
@@ -5059,8 +5151,8 @@ char	*_nc_first_name(
 
 #undef _nc_name_match
 int	_nc_name_match(
-		const char *const namelst, 
-		const char *const name, 
+		const char *const namelst,
+		const char *const name,
 		const char *const delim)
 		{ return(*(int *)0); }
 
@@ -5094,14 +5186,14 @@ const char *const *_nc_strfnames(void)
 
 #undef _nc_set_buffer_sp
 void	_nc_set_buffer_sp(
-		SCREEN	*sp, 
-		FILE	*ofp, 
+		SCREEN	*sp,
+		FILE	*ofp,
 		int	buffered)
 		{ /* void */ }
 
 #undef _nc_set_buffer
 void	_nc_set_buffer(
-		FILE	*ofp, 
+		FILE	*ofp,
 		int	buffered)
 		{ /* void */ }
 
@@ -5114,28 +5206,28 @@ void	_nc_init_termtype(
 
 #undef _nc_read_termtype
 int	_nc_read_termtype(
-		TERMTYPE2 *ptr, 
-		char	*buffer, 
+		TERMTYPE2 *ptr,
+		char	*buffer,
 		int	limit)
 		{ return(*(int *)0); }
 
 #undef _nc_read_file_entry
 int	_nc_read_file_entry(
-		const char *const filename, 
+		const char *const filename,
 		TERMTYPE2 *ptr)
 		{ return(*(int *)0); }
 
 #undef _nc_read_entry2
 int	_nc_read_entry2(
-		const char *const name, 
-		char	*const filename, 
+		const char *const name,
+		char	*const filename,
 		TERMTYPE2 *const tp)
 		{ return(*(int *)0); }
 
 #undef _nc_read_entry
 int	_nc_read_entry(
-		const char *const name, 
-		char	*const filename, 
+		const char *const name,
+		char	*const filename,
 		TERMTYPE *const tp)
 		{ return(*(int *)0); }
 
@@ -5143,7 +5235,7 @@ int	_nc_read_entry(
 
 #undef _nc_read_termcap_entry
 int	_nc_read_termcap_entry(
-		const char *const tn, 
+		const char *const tn,
 		TERMTYPE2 *const tp)
 		{ return(*(int *)0); }
 
@@ -5151,32 +5243,32 @@ int	_nc_read_termcap_entry(
 
 #undef _nc_str_init
 string_desc *_nc_str_init(
-		string_desc *dst, 
-		char	*src, 
+		string_desc *dst,
+		char	*src,
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_null
 string_desc *_nc_str_null(
-		string_desc *dst, 
+		string_desc *dst,
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_copy
 string_desc *_nc_str_copy(
-		string_desc *dst, 
-		string_desc *src)
+		string_desc *dst,
+		const string_desc *const src)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_safe_strcat
 NCURSES_BOOL _nc_safe_strcat(
-		string_desc *dst, 
+		string_desc *dst,
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_safe_strcpy
 NCURSES_BOOL _nc_safe_strcpy(
-		string_desc *dst, 
+		string_desc *dst,
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -5184,13 +5276,13 @@ NCURSES_BOOL _nc_safe_strcpy(
 
 #undef _nc_trace_buf
 char	*_nc_trace_buf(
-		int	bufnum, 
+		int	bufnum,
 		size_t	want)
 		{ return(*(char **)0); }
 
 #undef _nc_trace_bufcat
 char	*_nc_trace_bufcat(
-		int	bufnum, 
+		int	bufnum,
 		const char *value)
 		{ return(*(char **)0); }
 
@@ -5205,21 +5297,21 @@ void	_nc_trace_tries(
 
 #undef _nc_expand_try
 char	*_nc_expand_try(
-		TRIES	*tree, 
-		unsigned code, 
-		int	*count, 
+		TRIES	*tree,
+		unsigned code,
+		int	*count,
 		size_t	len)
 		{ return(*(char **)0); }
 
 #undef _nc_remove_key
 int	_nc_remove_key(
-		TRIES	**tree, 
+		TRIES	**tree,
 		unsigned code)
 		{ return(*(int *)0); }
 
 #undef _nc_remove_string
 int	_nc_remove_string(
-		TRIES	**tree, 
+		TRIES	**tree,
 		const char *string)
 		{ return(*(int *)0); }
 
@@ -5234,7 +5326,7 @@ char	*_nc_trim_sgr0(
 
 #undef unctrl_sp
 const char *unctrl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		chtype	ch)
 		{ return(*(const char **)0); }
 
@@ -5247,7 +5339,7 @@ const char *unctrl(
 
 #undef _nc_visbuf2
 const char *_nc_visbuf2(
-		int	bufnum, 
+		int	bufnum,
 		const char *buf)
 		{ return(*(const char **)0); }
 
@@ -5258,13 +5350,13 @@ const char *_nc_visbuf(
 
 #undef _nc_visbufn
 const char *_nc_visbufn(
-		const char *buf, 
+		const char *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
 #undef _nc_viswbuf2
 const char *_nc_viswbuf2(
-		int	bufnum, 
+		int	bufnum,
 		const wchar_t *buf)
 		{ return(*(const char **)0); }
 
@@ -5275,7 +5367,7 @@ const char *_nc_viswbuf(
 
 #undef _nc_viswbufn
 const char *_nc_viswbufn(
-		const wchar_t *buf, 
+		const wchar_t *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
@@ -5286,14 +5378,14 @@ const char *_nc_viswibuf(
 
 #undef _nc_viscbuf2
 const char *_nc_viscbuf2(
-		int	bufnum, 
-		const cchar_t *buf, 
+		int	bufnum,
+		const cchar_t *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
 #undef _nc_viscbuf
 const char *_nc_viscbuf(
-		const cchar_t *buf, 
+		const cchar_t *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
@@ -5311,18 +5403,18 @@ ENTRY	*_nc_copy_entry(
 
 #undef _nc_save_str
 char	*_nc_save_str(
-		const char *const string)
+		const char *string)
 		{ return(*(char **)0); }
 
 #undef _nc_wrap_entry
 void	_nc_wrap_entry(
-		ENTRY	*const ep, 
+		ENTRY	*const ep,
 		NCURSES_BOOL copy_strings)
 		{ /* void */ }
 
 #undef _nc_merge_entry
 void	_nc_merge_entry(
-		ENTRY	*const target, 
+		ENTRY	*const target,
 		ENTRY	*const source)
 		{ /* void */ }
 
@@ -5330,15 +5422,15 @@ void	_nc_merge_entry(
 
 #undef _nc_captoinfo
 char	*_nc_captoinfo(
-		const char *cap, 
-		const char *s, 
+		const char *cap,
+		const char *s,
 		int const parameterized)
 		{ return(*(char **)0); }
 
 #undef _nc_infotocap
 char	*_nc_infotocap(
-		const char *cap, 
-		const char *str, 
+		const char *cap,
+		const char *str,
 		int const parameterized)
 		{ return(*(char **)0); }
 
@@ -5346,8 +5438,8 @@ char	*_nc_infotocap(
 
 #undef _nc_tic_expand
 char	*_nc_tic_expand(
-		const char *srcp, 
-		NCURSES_BOOL tic_format, 
+		const char *srcp,
+		NCURSES_BOOL tic_format,
 		int	numbers)
 		{ return(*(char **)0); }
 
@@ -5355,28 +5447,28 @@ char	*_nc_tic_expand(
 
 #undef _nc_check_termtype2
 void	(*_nc_check_termtype2)(
-		TERMTYPE2 *p1, 
+		TERMTYPE2 *p1,
 		NCURSES_BOOL p2);
 
 #undef _nc_entry_match
 NCURSES_BOOL _nc_entry_match(
-		char	*n1, 
+		char	*n1,
 		char	*n2)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_read_entry_source
 void	_nc_read_entry_source(
-		FILE	*fp, 
-		char	*buf, 
-		int	literal, 
-		NCURSES_BOOL silent, 
+		FILE	*fp,
+		char	*buf,
+		int	literal,
+		NCURSES_BOOL silent,
 		NCURSES_BOOL (*hook)(
 		ENTRY	*p1))
 		{ /* void */ }
 
 #undef _nc_resolve_uses2
 int	_nc_resolve_uses2(
-		NCURSES_BOOL fullresolve, 
+		NCURSES_BOOL fullresolve,
 		NCURSES_BOOL literal)
 		{ return(*(int *)0); }
 
@@ -5401,7 +5493,7 @@ NCURSES_BOOL _nc_disable_period;
 
 #undef _nc_reset_input
 void	_nc_reset_input(
-		FILE	*fp, 
+		FILE	*fp,
 		char	*buf)
 		{ /* void */ }
 
@@ -5412,8 +5504,8 @@ int	_nc_get_token(
 
 #undef _nc_trans_string
 int	_nc_trans_string(
-		char	*ptr, 
-		char	*last)
+		char	*ptr,
+		const char *const last)
 		{ return(*(int *)0); }
 
 #undef _nc_push_token
@@ -5430,14 +5522,14 @@ void	_nc_panic_mode(
 
 #undef _nc_parse_entry
 int	_nc_parse_entry(
-		ENTRY	*entryp, 
-		int	literal, 
+		ENTRY	*entryp,
+		int	literal,
 		NCURSES_BOOL silent)
 		{ return(*(int *)0); }
 
 #undef _nc_capcmp
 int	_nc_capcmp(
-		const char *s, 
+		const char *s,
 		const char *t)
 		{ return(*(int *)0); }
 
@@ -5455,9 +5547,9 @@ void	_nc_write_entry(
 
 #undef _nc_write_object
 int	_nc_write_object(
-		TERMTYPE2 *tp, 
-		char	*buffer, 
-		unsigned *offset, 
+		TERMTYPE2 *tp,
+		char	*buffer,
+		unsigned *offset,
 		unsigned limit)
 		{ return(*(int *)0); }
 
@@ -5469,14 +5561,14 @@ int	_nc_tic_written(void)
 
 #undef define_key_sp
 int	define_key_sp(
-		SCREEN	*sp, 
-		const char *str, 
+		SCREEN	*sp,
+		const char *str,
 		int	keycode)
 		{ return(*(int *)0); }
 
 #undef define_key
 int	define_key(
-		const char *str, 
+		const char *str,
 		int	keycode)
 		{ return(*(int *)0); }
 
@@ -5490,7 +5582,7 @@ void	_nc_hashed_db(void)
 
 #undef key_defined_sp
 int	key_defined_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -5503,14 +5595,14 @@ int	key_defined(
 
 #undef keybound_sp
 char	*keybound_sp(
-		SCREEN	*sp, 
-		int	code, 
+		SCREEN	*sp,
+		int	code,
 		int	count)
 		{ return(*(char **)0); }
 
 #undef keybound
 char	*keybound(
-		int	code, 
+		int	code,
 		int	count)
 		{ return(*(char **)0); }
 
@@ -5518,14 +5610,14 @@ char	*keybound(
 
 #undef keyok_sp
 int	keyok_sp(
-		SCREEN	*sp, 
-		int	c, 
+		SCREEN	*sp,
+		int	c,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef keyok
 int	keyok(
-		int	c, 
+		int	c,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
diff --git a/contrib/ncurses/ncurses/llib-lncursesw b/contrib/ncurses/ncurses/llib-lncursesw
index 794d4929254a..dbf535db4b3f 100644
--- a/contrib/ncurses/ncurses/llib-lncursesw
+++ b/contrib/ncurses/ncurses/llib-lncursesw
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
  * Copyright 2001-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -70,7 +70,7 @@ void	_nc_hash_map(void)
 
 #undef _nc_make_oldhash_sp
 void	_nc_make_oldhash_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	i)
 		{ /* void */ }
 
@@ -81,16 +81,16 @@ void	_nc_make_oldhash(
 
 #undef _nc_scroll_oldhash_sp
 void	_nc_scroll_oldhash_sp(
-		SCREEN	*sp, 
-		int	n, 
-		int	top, 
+		SCREEN	*sp,
+		int	n,
+		int	top,
 		int	bot)
 		{ /* void */ }
 
 #undef _nc_scroll_oldhash
 void	_nc_scroll_oldhash(
-		int	n, 
-		int	top, 
+		int	n,
+		int	top,
 		int	bot)
 		{ /* void */ }
 
@@ -98,31 +98,31 @@ void	_nc_scroll_oldhash(
 
 #undef _nc_render
 cchar_t	_nc_render(
-		WINDOW	*win, 
+		WINDOW	*win,
 		cchar_t	ch)
 		{ return(*(cchar_t *)0); }
 
 #undef _nc_build_wch
 int	_nc_build_wch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		cchar_t	*ch)
 		{ return(*(int *)0); }
 
 #undef _nc_waddch_nosync
 int	_nc_waddch_nosync(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const cchar_t c)
 		{ return(*(int *)0); }
 
 #undef waddch
 int	waddch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const chtype ch)
 		{ return(*(int *)0); }
 
 #undef wechochar
 int	wechochar(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const chtype ch)
 		{ return(*(int *)0); }
 
@@ -130,15 +130,15 @@ int	wechochar(
 
 #undef waddnstr
 int	waddnstr(
-		WINDOW	*win, 
-		const char *astr, 
+		WINDOW	*win,
+		const char *astr,
 		int	n)
 		{ return(*(int *)0); }
 
 #undef waddchnstr
 int	waddchnstr(
-		WINDOW	*win, 
-		const chtype *astr, 
+		WINDOW	*win,
+		const chtype *astr,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -149,15 +149,15 @@ int	_nc_wchstrlen(
 
 #undef wadd_wchnstr
 int	wadd_wchnstr(
-		WINDOW	*win, 
-		const cchar_t *astr, 
+		WINDOW	*win,
+		const cchar_t *astr,
 		int	n)
 		{ return(*(int *)0); }
 
 #undef waddnwstr
 int	waddnwstr(
-		WINDOW	*win, 
-		const wchar_t *str, 
+		WINDOW	*win,
+		const wchar_t *str,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -176,25 +176,25 @@ int	beep(void)
 
 #undef wbkgrndset
 void	wbkgrndset(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const cchar_t *ch)
 		{ /* void */ }
 
 #undef wbkgdset
 void	wbkgdset(
-		WINDOW	*win, 
+		WINDOW	*win,
 		chtype	ch)
 		{ /* void */ }
 
 #undef wbkgrnd
 int	wbkgrnd(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const cchar_t *ch)
 		{ return(*(int *)0); }
 
 #undef wbkgd
 int	wbkgd(
-		WINDOW	*win, 
+		WINDOW	*win,
 		chtype	ch)
 		{ return(*(int *)0); }
 
@@ -202,14 +202,14 @@ int	wbkgd(
 
 #undef wborder
 int	wborder(
-		WINDOW	*win, 
-		chtype	ls, 
-		chtype	rs, 
-		chtype	ts, 
-		chtype	bs, 
-		chtype	tl, 
-		chtype	tr, 
-		chtype	bl, 
+		WINDOW	*win,
+		chtype	ls,
+		chtype	rs,
+		chtype	ts,
+		chtype	bs,
+		chtype	tl,
+		chtype	tr,
+		chtype	bl,
 		chtype	br)
 		{ return(*(int *)0); }
 
@@ -217,10 +217,10 @@ int	wborder(
 
 #undef wchgat
 int	wchgat(
-		WINDOW	*win, 
-		int	n, 
-		attr_t	attr, 
-		short	pair_arg, 
+		WINDOW	*win,
+		int	n,
+		attr_t	attr,
+		short	pair_arg,
 		const void *opts)
 		{ return(*(int *)0); }
 
@@ -235,7 +235,7 @@ int	wclear(
 
 #undef clearok
 int	clearok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
@@ -280,62 +280,62 @@ int	start_color(void)
 
 #undef _nc_change_pair
 void	_nc_change_pair(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	pair)
 		{ /* void */ }
 
 #undef _nc_reserve_pairs
 void	_nc_reserve_pairs(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	want)
 		{ /* void */ }
 
 #undef _nc_init_pair
 int	_nc_init_pair(
-		SCREEN	*sp, 
-		int	pair, 
-		int	f, 
+		SCREEN	*sp,
+		int	pair,
+		int	f,
 		int	b)
 		{ return(*(int *)0); }
 
 #undef init_pair_sp
 int	init_pair_sp(
-		SCREEN	*sp, 
-		short	pair, 
-		short	f, 
+		SCREEN	*sp,
+		short	pair,
+		short	f,
 		short	b)
 		{ return(*(int *)0); }
 
 #undef init_pair
 int	init_pair(
-		short	pair, 
-		short	f, 
+		short	pair,
+		short	f,
 		short	b)
 		{ return(*(int *)0); }
 
 #undef _nc_init_color
 int	_nc_init_color(
-		SCREEN	*sp, 
-		int	color, 
-		int	r, 
-		int	g, 
+		SCREEN	*sp,
+		int	color,
+		int	r,
+		int	g,
 		int	b)
 		{ return(*(int *)0); }
 
 #undef init_color_sp
 int	init_color_sp(
-		SCREEN	*sp, 
-		short	color, 
-		short	r, 
-		short	g, 
+		SCREEN	*sp,
+		short	color,
+		short	r,
+		short	g,
 		short	b)
 		{ return(*(int *)0); }
 
 #undef init_color
 int	init_color(
-		short	color, 
-		short	r, 
-		short	g, 
+		short	color,
+		short	r,
+		short	g,
 		short	b)
 		{ return(*(int *)0); }
 
@@ -359,92 +359,92 @@ NCURSES_BOOL has_colors(void)
 
 #undef color_content_sp
 int	color_content_sp(
-		SCREEN	*sp, 
-		short	color, 
-		short	*r, 
-		short	*g, 
+		SCREEN	*sp,
+		short	color,
+		short	*r,
+		short	*g,
 		short	*b)
 		{ return(*(int *)0); }
 
 #undef color_content
 int	color_content(
-		short	color, 
-		short	*r, 
-		short	*g, 
+		short	color,
+		short	*r,
+		short	*g,
 		short	*b)
 		{ return(*(int *)0); }
 
 #undef _nc_pair_content
 int	_nc_pair_content(
-		SCREEN	*sp, 
-		int	pair, 
-		int	*f, 
+		SCREEN	*sp,
+		int	pair,
+		int	*f,
 		int	*b)
 		{ return(*(int *)0); }
 
 #undef pair_content_sp
 int	pair_content_sp(
-		SCREEN	*sp, 
-		short	pair, 
-		short	*f, 
+		SCREEN	*sp,
+		short	pair,
+		short	*f,
 		short	*b)
 		{ return(*(int *)0); }
 
 #undef pair_content
 int	pair_content(
-		short	pair, 
-		short	*f, 
+		short	pair,
+		short	*f,
 		short	*b)
 		{ return(*(int *)0); }
 
 #undef _nc_do_color_sp
 void	_nc_do_color_sp(
-		SCREEN	*sp, 
-		int	old_pair, 
-		int	pair, 
-		int	reverse, 
+		SCREEN	*sp,
+		int	old_pair,
+		int	pair,
+		int	reverse,
 		NCURSES_OUTC_sp outc)
 		{ /* void */ }
 
 #undef _nc_do_color
 void	_nc_do_color(
-		int	old_pair, 
-		int	pair, 
-		int	reverse, 
+		int	old_pair,
+		int	pair,
+		int	reverse,
 		NCURSES_OUTC outc)
 		{ /* void */ }
 
 #undef init_extended_pair_sp
 int	init_extended_pair_sp(
-		SCREEN	*sp, 
-		int	pair, 
-		int	f, 
+		SCREEN	*sp,
+		int	pair,
+		int	f,
 		int	b)
 		{ return(*(int *)0); }
 
 #undef init_extended_color_sp
 int	init_extended_color_sp(
-		SCREEN	*sp, 
-		int	color, 
-		int	r, 
-		int	g, 
+		SCREEN	*sp,
+		int	color,
+		int	r,
+		int	g,
 		int	b)
 		{ return(*(int *)0); }
 
 #undef extended_color_content_sp
 int	extended_color_content_sp(
-		SCREEN	*sp, 
-		int	color, 
-		int	*r, 
-		int	*g, 
+		SCREEN	*sp,
+		int	color,
+		int	*r,
+		int	*g,
 		int	*b)
 		{ return(*(int *)0); }
 
 #undef extended_pair_content_sp
 int	extended_pair_content_sp(
-		SCREEN	*sp, 
-		int	pair, 
-		int	*f, 
+		SCREEN	*sp,
+		int	pair,
+		int	*f,
 		int	*b)
 		{ return(*(int *)0); }
 
@@ -455,31 +455,31 @@ void	reset_color_pairs_sp(
 
 #undef init_extended_pair
 int	init_extended_pair(
-		int	pair, 
-		int	f, 
+		int	pair,
+		int	f,
 		int	b)
 		{ return(*(int *)0); }
 
 #undef init_extended_color
 int	init_extended_color(
-		int	color, 
-		int	r, 
-		int	g, 
+		int	color,
+		int	r,
+		int	g,
 		int	b)
 		{ return(*(int *)0); }
 
 #undef extended_color_content
 int	extended_color_content(
-		int	color, 
-		int	*r, 
-		int	*g, 
+		int	color,
+		int	*r,
+		int	*g,
 		int	*b)
 		{ return(*(int *)0); }
 
 #undef extended_pair_content
 int	extended_pair_content(
-		int	pair, 
-		int	*f, 
+		int	pair,
+		int	*f,
 		int	*b)
 		{ return(*(int *)0); }
 
@@ -491,8 +491,8 @@ void	reset_color_pairs(void)
 
 #undef wcolor_set
 int	wcolor_set(
-		WINDOW	*win, 
-		short	pair_arg, 
+		WINDOW	*win,
+		short	pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -568,7 +568,7 @@ int	addch(
 
 #undef addchnstr
 int	addchnstr(
-		const chtype *a1, 
+		const chtype *a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -579,7 +579,7 @@ int	addchstr(
 
 #undef addnstr
 int	addnstr(
-		const char *a1, 
+		const char *a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -590,42 +590,42 @@ int	addstr(
 
 #undef attroff
 int	attroff(
-		int	z)
+		NCURSES_ATTR_T	z)
 		{ return(*(int *)0); }
 
 #undef attron
 int	attron(
-		int	z)
+		NCURSES_ATTR_T	z)
 		{ return(*(int *)0); }
 
 #undef attrset
 int	attrset(
-		int	z)
+		NCURSES_ATTR_T	z)
 		{ return(*(int *)0); }
 
 #undef attr_get
 int	attr_get(
-		attr_t	*a1, 
-		short	*a2, 
+		attr_t	*a1,
+		short	*a2,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef attr_off
 int	attr_off(
-		attr_t	a1, 
+		attr_t	a1,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef attr_on
 int	attr_on(
-		attr_t	a1, 
+		attr_t	a1,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef attr_set
 int	attr_set(
-		attr_t	a1, 
-		short	a2, 
+		attr_t	a1,
+		short	a2,
 		void	*z)
 		{ return(*(int *)0); }
 
@@ -641,28 +641,28 @@ void	bkgdset(
 
 #undef border
 int	border(
-		chtype	a1, 
-		chtype	a2, 
-		chtype	a3, 
-		chtype	a4, 
-		chtype	a5, 
-		chtype	a6, 
-		chtype	a7, 
+		chtype	a1,
+		chtype	a2,
+		chtype	a3,
+		chtype	a4,
+		chtype	a5,
+		chtype	a6,
+		chtype	a7,
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef box
 int	box(
-		WINDOW	*a1, 
-		chtype	a2, 
+		WINDOW	*a1,
+		chtype	a2,
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef chgat
 int	chgat(
-		int	a1, 
-		attr_t	a2, 
-		short	a3, 
+		int	a1,
+		attr_t	a2,
+		short	a3,
 		const void *z)
 		{ return(*(int *)0); }
 
@@ -680,7 +680,7 @@ int	clrtoeol(void)
 
 #undef color_set
 int	color_set(
-		short	a1, 
+		short	a1,
 		void	*z)
 		{ return(*(int *)0); }
 
@@ -717,7 +717,7 @@ int	getch(void)
 
 #undef getnstr
 int	getnstr(
-		char	*a1, 
+		char	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -728,7 +728,7 @@ int	getstr(
 
 #undef hline
 int	hline(
-		chtype	a1, 
+		chtype	a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -738,7 +738,7 @@ chtype	inch(void)
 
 #undef inchnstr
 int	inchnstr(
-		chtype	*a1, 
+		chtype	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -749,7 +749,7 @@ int	inchstr(
 
 #undef innstr
 int	innstr(
-		char	*a1, 
+		char	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -769,7 +769,7 @@ int	insertln(void)
 
 #undef insnstr
 int	insnstr(
-		const char *a1, 
+		const char *a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -785,323 +785,323 @@ int	instr(
 
 #undef move
 int	move(
-		int	a1, 
+		int	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddch
 int	mvaddch(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		const chtype z)
 		{ return(*(int *)0); }
 
 #undef mvaddchnstr
 int	mvaddchnstr(
-		int	a1, 
-		int	a2, 
-		const chtype *a3, 
+		int	a1,
+		int	a2,
+		const chtype *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddchstr
 int	mvaddchstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		const chtype *z)
 		{ return(*(int *)0); }
 
 #undef mvaddnstr
 int	mvaddnstr(
-		int	a1, 
-		int	a2, 
-		const char *a3, 
+		int	a1,
+		int	a2,
+		const char *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddstr
 int	mvaddstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvchgat
 int	mvchgat(
-		int	a1, 
-		int	a2, 
-		int	a3, 
-		attr_t	a4, 
-		short	a5, 
+		int	a1,
+		int	a2,
+		int	a3,
+		attr_t	a4,
+		short	a5,
 		const void *z)
 		{ return(*(int *)0); }
 
 #undef mvdelch
 int	mvdelch(
-		int	a1, 
+		int	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvgetch
 int	mvgetch(
-		int	a1, 
+		int	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvgetnstr
 int	mvgetnstr(
-		int	a1, 
-		int	a2, 
-		char	*a3, 
+		int	a1,
+		int	a2,
+		char	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvgetstr
 int	mvgetstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvhline
 int	mvhline(
-		int	a1, 
-		int	a2, 
-		chtype	a3, 
+		int	a1,
+		int	a2,
+		chtype	a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinch
 chtype	mvinch(
-		int	a1, 
+		int	a1,
 		int	z)
 		{ return(*(chtype *)0); }
 
 #undef mvinchnstr
 int	mvinchnstr(
-		int	a1, 
-		int	a2, 
-		chtype	*a3, 
+		int	a1,
+		int	a2,
+		chtype	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinchstr
 int	mvinchstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		chtype	*z)
 		{ return(*(int *)0); }
 
 #undef mvinnstr
 int	mvinnstr(
-		int	a1, 
-		int	a2, 
-		char	*a3, 
+		int	a1,
+		int	a2,
+		char	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinsch
 int	mvinsch(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef mvinsnstr
 int	mvinsnstr(
-		int	a1, 
-		int	a2, 
-		const char *a3, 
+		int	a1,
+		int	a2,
+		const char *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinsstr
 int	mvinsstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvinstr
 int	mvinstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvvline
 int	mvvline(
-		int	a1, 
-		int	a2, 
-		chtype	a3, 
+		int	a1,
+		int	a2,
+		chtype	a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddch
 int	mvwaddch(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const chtype z)
 		{ return(*(int *)0); }
 
 #undef mvwaddchnstr
 int	mvwaddchnstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const chtype *a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const chtype *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddchstr
 int	mvwaddchstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const chtype *z)
 		{ return(*(int *)0); }
 
 #undef mvwaddnstr
 int	mvwaddnstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const char *a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const char *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddstr
 int	mvwaddstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvwchgat
 int	mvwchgat(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		int	a4, 
-		attr_t	a5, 
-		short	a6, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		int	a4,
+		attr_t	a5,
+		short	a6,
 		const void *z)
 		{ return(*(int *)0); }
 
 #undef mvwdelch
 int	mvwdelch(
-		WINDOW	*a1, 
-		int	a2, 
+		WINDOW	*a1,
+		int	a2,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwgetch
 int	mvwgetch(
-		WINDOW	*a1, 
-		int	a2, 
+		WINDOW	*a1,
+		int	a2,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwgetnstr
 int	mvwgetnstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		char	*a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		char	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwgetstr
 int	mvwgetstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvwhline
 int	mvwhline(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		chtype	a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		chtype	a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinch
 chtype	mvwinch(
-		WINDOW	*a1, 
-		int	a2, 
+		WINDOW	*a1,
+		int	a2,
 		int	z)
 		{ return(*(chtype *)0); }
 
 #undef mvwinchnstr
 int	mvwinchnstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		chtype	*a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		chtype	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinchstr
 int	mvwinchstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		chtype	*z)
 		{ return(*(int *)0); }
 
 #undef mvwinnstr
 int	mvwinnstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		char	*a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		char	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinsch
 int	mvwinsch(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef mvwinsnstr
 int	mvwinsnstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const char *a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const char *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinsstr
 int	mvwinsstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvwinstr
 int	mvwinstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvwvline
 int	mvwvline(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		chtype	a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		chtype	a4,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -1131,19 +1131,19 @@ int	scroll(
 
 #undef setscrreg
 int	setscrreg(
-		int	a1, 
+		int	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef slk_attr_off
 int	slk_attr_off(
-		const attr_t a1, 
+		const attr_t a1,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef slk_attr_on
 int	slk_attr_on(
-		attr_t	a1, 
+		attr_t	a1,
 		void	*z)
 		{ return(*(int *)0); }
 
@@ -1162,8 +1162,8 @@ void	timeout(
 
 #undef touchline
 int	touchline(
-		WINDOW	*a1, 
-		int	a2, 
+		WINDOW	*a1,
+		int	a2,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -1179,53 +1179,53 @@ int	untouchwin(
 
 #undef vline
 int	vline(
-		chtype	a1, 
+		chtype	a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef waddchstr
 int	waddchstr(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		const chtype *z)
 		{ return(*(int *)0); }
 
 #undef waddstr
 int	waddstr(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef wattron
 int	wattron(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wattroff
 int	wattroff(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wattrset
 int	wattrset(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wattr_get
 int	wattr_get(
-		WINDOW	*a1, 
-		attr_t	*a2, 
-		short	*a3, 
+		WINDOW	*a1,
+		attr_t	*a2,
+		short	*a3,
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef wattr_set
 int	wattr_set(
-		WINDOW	*a1, 
-		attr_t	a2, 
-		short	a3, 
+		WINDOW	*a1,
+		attr_t	a2,
+		short	a3,
 		void	*z)
 		{ return(*(int *)0); }
 
@@ -1236,13 +1236,13 @@ int	wdeleteln(
 
 #undef wgetstr
 int	wgetstr(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef winchstr
 int	winchstr(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		chtype	*z)
 		{ return(*(int *)0); }
 
@@ -1253,13 +1253,13 @@ int	winsertln(
 
 #undef winsstr
 int	winsstr(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef winstr
 int	winstr(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		char	*z)
 		{ return(*(int *)0); }
 
@@ -1390,8 +1390,8 @@ int	wgetdelay(
 
 #undef wgetscrreg
 int	wgetscrreg(
-		const WINDOW *a1, 
-		int	*a2, 
+		const WINDOW *a1,
+		int	*a2,
 		int	*z)
 		{ return(*(int *)0); }
 
@@ -1402,7 +1402,7 @@ int	add_wch(
 
 #undef add_wchnstr
 int	add_wchnstr(
-		const cchar_t *a1, 
+		const cchar_t *a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -1413,7 +1413,7 @@ int	add_wchstr(
 
 #undef addnwstr
 int	addnwstr(
-		const wchar_t *a1, 
+		const wchar_t *a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -1434,20 +1434,20 @@ void	bkgrndset(
 
 #undef border_set
 int	border_set(
-		const cchar_t *a1, 
-		const cchar_t *a2, 
-		const cchar_t *a3, 
-		const cchar_t *a4, 
-		const cchar_t *a5, 
-		const cchar_t *a6, 
-		const cchar_t *a7, 
+		const cchar_t *a1,
+		const cchar_t *a2,
+		const cchar_t *a3,
+		const cchar_t *a4,
+		const cchar_t *a5,
+		const cchar_t *a6,
+		const cchar_t *a7,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef box_set
 int	box_set(
-		WINDOW	*a1, 
-		const cchar_t *a2, 
+		WINDOW	*a1,
+		const cchar_t *a2,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
@@ -1473,13 +1473,13 @@ int	getbkgrnd(
 
 #undef getn_wstr
 int	getn_wstr(
-		wint_t	*a1, 
+		wint_t	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef hline_set
 int	hline_set(
-		const cchar_t *a1, 
+		const cchar_t *a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -1490,7 +1490,7 @@ int	in_wch(
 
 #undef in_wchnstr
 int	in_wchnstr(
-		cchar_t	*a1, 
+		cchar_t	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -1501,13 +1501,13 @@ int	in_wchstr(
 
 #undef innwstr
 int	innwstr(
-		wchar_t	*a1, 
+		wchar_t	*a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef ins_nwstr
 int	ins_nwstr(
-		const wchar_t *a1, 
+		const wchar_t *a1,
 		int	z)
 		{ return(*(int *)0); }
 
@@ -1528,336 +1528,336 @@ int	inwstr(
 
 #undef mvadd_wch
 int	mvadd_wch(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvadd_wchnstr
 int	mvadd_wchnstr(
-		int	a1, 
-		int	a2, 
-		const cchar_t *a3, 
+		int	a1,
+		int	a2,
+		const cchar_t *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvadd_wchstr
 int	mvadd_wchstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvaddnwstr
 int	mvaddnwstr(
-		int	a1, 
-		int	a2, 
-		const wchar_t *a3, 
+		int	a1,
+		int	a2,
+		const wchar_t *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddwstr
 int	mvaddwstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		const wchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvget_wch
 int	mvget_wch(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		wint_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvget_wstr
 int	mvget_wstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		wint_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvgetn_wstr
 int	mvgetn_wstr(
-		int	a1, 
-		int	a2, 
-		wint_t	*a3, 
+		int	a1,
+		int	a2,
+		wint_t	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvhline_set
 int	mvhline_set(
-		int	a1, 
-		int	a2, 
-		const cchar_t *a3, 
+		int	a1,
+		int	a2,
+		const cchar_t *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvin_wch
 int	mvin_wch(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvin_wchnstr
 int	mvin_wchnstr(
-		int	a1, 
-		int	a2, 
-		cchar_t	*a3, 
+		int	a1,
+		int	a2,
+		cchar_t	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvin_wchstr
 int	mvin_wchstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvinnwstr
 int	mvinnwstr(
-		int	a1, 
-		int	a2, 
-		wchar_t	*a3, 
+		int	a1,
+		int	a2,
+		wchar_t	*a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvins_nwstr
 int	mvins_nwstr(
-		int	a1, 
-		int	a2, 
-		const wchar_t *a3, 
+		int	a1,
+		int	a2,
+		const wchar_t *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvins_wch
 int	mvins_wch(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvins_wstr
 int	mvins_wstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		const wchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvinwstr
 int	mvinwstr(
-		int	a1, 
-		int	a2, 
+		int	a1,
+		int	a2,
 		wchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvvline_set
 int	mvvline_set(
-		int	a1, 
-		int	a2, 
-		const cchar_t *a3, 
+		int	a1,
+		int	a2,
+		const cchar_t *a3,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwadd_wch
 int	mvwadd_wch(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvwadd_wchnstr
 int	mvwadd_wchnstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const cchar_t *a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const cchar_t *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwadd_wchstr
 int	mvwadd_wchstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvwaddnwstr
 int	mvwaddnwstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const wchar_t *a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const wchar_t *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddwstr
 int	mvwaddwstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const wchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvwget_wch
 int	mvwget_wch(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		wint_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvwget_wstr
 int	mvwget_wstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		wint_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvwgetn_wstr
 int	mvwgetn_wstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		wint_t	*a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		wint_t	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwhline_set
 int	mvwhline_set(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const cchar_t *a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const cchar_t *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwin_wch
 int	mvwin_wch(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvwin_wchnstr
 int	mvwin_wchnstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		cchar_t	*a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		cchar_t	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwin_wchstr
 int	mvwin_wchstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvwinnwstr
 int	mvwinnwstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		wchar_t	*a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		wchar_t	*a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwins_nwstr
 int	mvwins_nwstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const wchar_t *a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const wchar_t *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwins_wch
 int	mvwins_wch(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvwins_wstr
 int	mvwins_wstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		const wchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvwinwstr
 int	mvwinwstr(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
 		wchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvwvline_set
 int	mvwvline_set(
-		WINDOW	*a1, 
-		int	a2, 
-		int	a3, 
-		const cchar_t *a4, 
+		WINDOW	*a1,
+		int	a2,
+		int	a3,
+		const cchar_t *a4,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef vline_set
 int	vline_set(
-		const cchar_t *a1, 
+		const cchar_t *a1,
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wadd_wchstr
 int	wadd_wchstr(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef waddwstr
 int	waddwstr(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		const wchar_t *z)
 		{ return(*(int *)0); }
 
 #undef wget_wstr
 int	wget_wstr(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		wint_t	*z)
 		{ return(*(int *)0); }
 
 #undef wgetbkgrnd
 int	wgetbkgrnd(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef win_wchstr
 int	win_wchstr(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef wins_wstr
 int	wins_wstr(
-		WINDOW	*a1, 
+		WINDOW	*a1,
 		const wchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mouse_trafo
 NCURSES_BOOL mouse_trafo(
-		int	*a1, 
-		int	*a2, 
+		int	*a1,
+		int	*a2,
 		NCURSES_BOOL z)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -1868,7 +1868,7 @@ int	ESCDELAY;
 
 #undef set_escdelay_sp
 int	set_escdelay_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	value)
 		{ return(*(int *)0); }
 
@@ -1888,8 +1888,8 @@ int	get_escdelay(void)
 
 #undef _nc_wgetch
 int	_nc_wgetch(
-		WINDOW	*win, 
-		int	*result, 
+		WINDOW	*win,
+		int	*result,
 		int	use_meta)
 		{ return(*(int *)0); }
 
@@ -1902,8 +1902,8 @@ int	wgetch(
 
 #undef wgetnstr
 int	wgetnstr(
-		WINDOW	*win, 
-		char	*str, 
+		WINDOW	*win,
+		char	*str,
 		int	maxlen)
 		{ return(*(int *)0); }
 
@@ -1911,8 +1911,8 @@ int	wgetnstr(
 
 #undef whline
 int	whline(
-		WINDOW	*win, 
-		chtype	ch, 
+		WINDOW	*win,
+		chtype	ch,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1920,7 +1920,7 @@ int	whline(
 
 #undef immedok
 void	immedok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ /* void */ }
 
@@ -1928,8 +1928,8 @@ void	immedok(
 
 #undef winchnstr
 int	winchnstr(
-		WINDOW	*win, 
-		chtype	*str, 
+		WINDOW	*win,
+		chtype	*str,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1943,14 +1943,14 @@ WINDOW	*initscr(void)
 
 #undef _nc_insert_ch
 int	_nc_insert_ch(
-		SCREEN	*sp, 
-		WINDOW	*win, 
+		SCREEN	*sp,
+		WINDOW	*win,
 		chtype	ch)
 		{ return(*(int *)0); }
 
 #undef winsch
 int	winsch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		chtype	c)
 		{ return(*(int *)0); }
 
@@ -1958,7 +1958,7 @@ int	winsch(
 
 #undef winsdelln
 int	winsdelln(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1966,8 +1966,8 @@ int	winsdelln(
 
 #undef winsnstr
 int	winsnstr(
-		WINDOW	*win, 
-		const char *s, 
+		WINDOW	*win,
+		const char *s,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1975,8 +1975,8 @@ int	winsnstr(
 
 #undef winnstr
 int	winnstr(
-		WINDOW	*win, 
-		char	*str, 
+		WINDOW	*win,
+		char	*str,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1995,7 +1995,7 @@ NCURSES_BOOL isendwin(void)
 
 #undef leaveok
 int	leaveok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
@@ -2003,7 +2003,7 @@ int	leaveok(
 
 #undef getmouse_sp
 int	getmouse_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		MEVENT	*aevent)
 		{ return(*(int *)0); }
 
@@ -2014,7 +2014,7 @@ int	getmouse(
 
 #undef ungetmouse_sp
 int	ungetmouse_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		MEVENT	*aevent)
 		{ return(*(int *)0); }
 
@@ -2025,27 +2025,27 @@ int	ungetmouse(
 
 #undef mousemask_sp
 mmask_t	mousemask_sp(
-		SCREEN	*sp, 
-		mmask_t	newmask, 
+		SCREEN	*sp,
+		mmask_t	newmask,
 		mmask_t	*oldmask)
 		{ return(*(mmask_t *)0); }
 
 #undef mousemask
 mmask_t	mousemask(
-		mmask_t	newmask, 
+		mmask_t	newmask,
 		mmask_t	*oldmask)
 		{ return(*(mmask_t *)0); }
 
 #undef wenclose
 NCURSES_BOOL wenclose(
-		const WINDOW *win, 
-		int	y, 
+		const WINDOW *win,
+		int	y,
 		int	x)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef mouseinterval_sp
 int	mouseinterval_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	maxclick)
 		{ return(*(int *)0); }
 
@@ -2070,9 +2070,9 @@ NCURSES_BOOL has_mouse(void)
 
 #undef wmouse_trafo
 NCURSES_BOOL wmouse_trafo(
-		const WINDOW *win, 
-		int	*pY, 
-		int	*pX, 
+		const WINDOW *win,
+		int	*pY,
+		int	*pX,
 		NCURSES_BOOL to_screen)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -2080,8 +2080,8 @@ NCURSES_BOOL wmouse_trafo(
 
 #undef wmove
 int	wmove(
-		WINDOW	*win, 
-		int	y, 
+		WINDOW	*win,
+		int	y,
 		int	x)
 		{ return(*(int *)0); }
 
@@ -2089,14 +2089,14 @@ int	wmove(
 
 #undef _nc_msec_cost_sp
 int	_nc_msec_cost_sp(
-		SCREEN	*sp, 
-		const char *const cap, 
+		SCREEN	*sp,
+		const char *const cap,
 		int	affcnt)
 		{ return(*(int *)0); }
 
 #undef _nc_msec_cost
 int	_nc_msec_cost(
-		const char *const cap, 
+		const char *const cap,
 		int	affcnt)
 		{ return(*(int *)0); }
 
@@ -2129,35 +2129,35 @@ void	_nc_mvcur_wrap(void)
 
 #undef _nc_mvcur_sp
 int	_nc_mvcur_sp(
-		SCREEN	*sp, 
-		int	yold, 
-		int	xold, 
-		int	ynew, 
+		SCREEN	*sp,
+		int	yold,
+		int	xold,
+		int	ynew,
 		int	xnew)
 		{ return(*(int *)0); }
 
 #undef _nc_mvcur
 int	_nc_mvcur(
-		int	yold, 
-		int	xold, 
-		int	ynew, 
+		int	yold,
+		int	xold,
+		int	ynew,
 		int	xnew)
 		{ return(*(int *)0); }
 
 #undef mvcur_sp
 int	mvcur_sp(
-		SCREEN	*sp, 
-		int	yold, 
-		int	xold, 
-		int	ynew, 
+		SCREEN	*sp,
+		int	yold,
+		int	xold,
+		int	ynew,
 		int	xnew)
 		{ return(*(int *)0); }
 
 #undef mvcur
 int	mvcur(
-		int	yold, 
-		int	xold, 
-		int	ynew, 
+		int	yold,
+		int	xold,
+		int	ynew,
 		int	xnew)
 		{ return(*(int *)0); }
 
@@ -2168,8 +2168,8 @@ int	_nc_optimize_enable;
 
 #undef mvwin
 int	mvwin(
-		WINDOW	*win, 
-		int	by, 
+		WINDOW	*win,
+		int	by,
 		int	bx)
 		{ return(*(int *)0); }
 
@@ -2195,16 +2195,16 @@ void	nofilter(void)
 
 #undef newterm_sp
 SCREEN	*newterm_sp(
-		SCREEN	*sp, 
-		const char *name, 
-		FILE	*ofp, 
+		SCREEN	*sp,
+		const char *name,
+		FILE	*ofp,
 		FILE	*ifp)
 		{ return(*(SCREEN **)0); }
 
 #undef newterm
 SCREEN	*newterm(
-		const char *name, 
-		FILE	*ofp, 
+		const char *name,
+		FILE	*ofp,
 		FILE	*ifp)
 		{ return(*(SCREEN **)0); }
 
@@ -2217,46 +2217,46 @@ int	_nc_freewin(
 
 #undef newwin_sp
 WINDOW	*newwin_sp(
-		SCREEN	*sp, 
-		int	num_lines, 
-		int	num_columns, 
-		int	begy, 
+		SCREEN	*sp,
+		int	num_lines,
+		int	num_columns,
+		int	begy,
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef newwin
 WINDOW	*newwin(
-		int	num_lines, 
-		int	num_columns, 
-		int	begy, 
+		int	num_lines,
+		int	num_columns,
+		int	begy,
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef derwin
 WINDOW	*derwin(
-		WINDOW	*orig, 
-		int	num_lines, 
-		int	num_columns, 
-		int	begy, 
+		WINDOW	*orig,
+		int	num_lines,
+		int	num_columns,
+		int	begy,
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef subwin
 WINDOW	*subwin(
-		WINDOW	*w, 
-		int	l, 
-		int	c, 
-		int	y, 
+		WINDOW	*w,
+		int	l,
+		int	c,
+		int	y,
 		int	x)
 		{ return(*(WINDOW **)0); }
 
 #undef _nc_makenew_sp
 WINDOW	*_nc_makenew_sp(
-		SCREEN	*sp, 
-		int	num_lines, 
-		int	num_columns, 
-		int	begy, 
-		int	begx, 
+		SCREEN	*sp,
+		int	num_lines,
+		int	num_columns,
+		int	begy,
+		int	begx,
 		int	flags)
 		{ return(*(WINDOW **)0); }
 
@@ -2299,26 +2299,26 @@ int	nonl(void)
 
 #undef overlay
 int	overlay(
-		const WINDOW *win1, 
+		const WINDOW *win1,
 		WINDOW	*win2)
 		{ return(*(int *)0); }
 
 #undef overwrite
 int	overwrite(
-		const WINDOW *win1, 
+		const WINDOW *win1,
 		WINDOW	*win2)
 		{ return(*(int *)0); }
 
 #undef copywin
 int	copywin(
-		const WINDOW *src, 
-		WINDOW	*dst, 
-		int	sminrow, 
-		int	smincol, 
-		int	dminrow, 
-		int	dmincol, 
-		int	dmaxrow, 
-		int	dmaxcol, 
+		const WINDOW *src,
+		WINDOW	*dst,
+		int	sminrow,
+		int	smincol,
+		int	dminrow,
+		int	dmincol,
+		int	dmaxrow,
+		int	dmaxcol,
 		int	over)
 		{ return(*(int *)0); }
 
@@ -2326,51 +2326,51 @@ int	copywin(
 
 #undef newpad_sp
 WINDOW	*newpad_sp(
-		SCREEN	*sp, 
-		int	l, 
+		SCREEN	*sp,
+		int	l,
 		int	c)
 		{ return(*(WINDOW **)0); }
 
 #undef newpad
 WINDOW	*newpad(
-		int	l, 
+		int	l,
 		int	c)
 		{ return(*(WINDOW **)0); }
 
 #undef subpad
 WINDOW	*subpad(
-		WINDOW	*orig, 
-		int	l, 
-		int	c, 
-		int	begy, 
+		WINDOW	*orig,
+		int	l,
+		int	c,
+		int	begy,
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef prefresh
 int	prefresh(
-		WINDOW	*win, 
-		int	pminrow, 
-		int	pmincol, 
-		int	sminrow, 
-		int	smincol, 
-		int	smaxrow, 
+		WINDOW	*win,
+		int	pminrow,
+		int	pmincol,
+		int	sminrow,
+		int	smincol,
+		int	smaxrow,
 		int	smaxcol)
 		{ return(*(int *)0); }
 
 #undef pnoutrefresh
 int	pnoutrefresh(
-		WINDOW	*win, 
-		int	pminrow, 
-		int	pmincol, 
-		int	sminrow, 
-		int	smincol, 
-		int	smaxrow, 
+		WINDOW	*win,
+		int	pminrow,
+		int	pmincol,
+		int	sminrow,
+		int	smincol,
+		int	smaxrow,
 		int	smaxcol)
 		{ return(*(int *)0); }
 
 #undef pechochar
 int	pechochar(
-		WINDOW	*pad, 
+		WINDOW	*pad,
 		const chtype ch)
 		{ return(*(int *)0); }
 
@@ -2378,45 +2378,45 @@ int	pechochar(
 
 #undef printw
 int	printw(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef wprintw
 int	wprintw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef mvprintw
 int	mvprintw(
-		int	y, 
-		int	x, 
-		const char *fmt, 
+		int	y,
+		int	x,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef mvwprintw
 int	mvwprintw(
-		WINDOW	*win, 
-		int	y, 
-		int	x, 
-		const char *fmt, 
+		WINDOW	*win,
+		int	y,
+		int	x,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef vwprintw
 int	vwprintw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
 		va_list	argp)
 		{ return(*(int *)0); }
 
 #undef vw_printw
 int	vw_printw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
 		va_list	argp)
 		{ return(*(int *)0); }
 
@@ -2424,8 +2424,8 @@ int	vw_printw(
 
 #undef wredrawln
 int	wredrawln(
-		WINDOW	*win, 
-		int	beg, 
+		WINDOW	*win,
+		int	beg,
 		int	num)
 		{ return(*(int *)0); }
 
@@ -2445,16 +2445,16 @@ int	wnoutrefresh(
 
 #undef restartterm_sp
 int	restartterm_sp(
-		SCREEN	*sp, 
-		const char *termp, 
-		int	filenum, 
+		SCREEN	*sp,
+		const char *termp,
+		int	filenum,
 		int	*errret)
 		{ return(*(int *)0); }
 
 #undef restartterm
 int	restartterm(
-		const char *termp, 
-		int	filenum, 
+		const char *termp,
+		int	filenum,
 		int	*errret)
 		{ return(*(int *)0); }
 
@@ -2462,45 +2462,45 @@ int	restartterm(
 
 #undef vwscanw
 int	vwscanw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
 		va_list	argp)
 		{ return(*(int *)0); }
 
 #undef vw_scanw
 int	vw_scanw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
 		va_list	argp)
 		{ return(*(int *)0); }
 
 #undef scanw
 int	scanw(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef wscanw
 int	wscanw(
-		WINDOW	*win, 
-		const char *fmt, 
+		WINDOW	*win,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef mvscanw
 int	mvscanw(
-		int	y, 
-		int	x, 
-		const char *fmt, 
+		int	y,
+		int	x,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
 #undef mvwscanw
 int	mvwscanw(
-		WINDOW	*win, 
-		int	y, 
-		int	x, 
-		const char *fmt, 
+		WINDOW	*win,
+		int	y,
+		int	x,
+		const char *fmt,
 		...)
 		{ return(*(int *)0); }
 
@@ -2508,7 +2508,7 @@ int	mvwscanw(
 
 #undef getwin_sp
 WINDOW	*getwin_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		FILE	*filep)
 		{ return(*(WINDOW **)0); }
 
@@ -2519,13 +2519,13 @@ WINDOW	*getwin(
 
 #undef putwin
 int	putwin(
-		WINDOW	*win, 
+		WINDOW	*win,
 		FILE	*filep)
 		{ return(*(int *)0); }
 
 #undef scr_restore_sp
 int	scr_restore_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *file)
 		{ return(*(int *)0); }
 
@@ -2541,7 +2541,7 @@ int	scr_dump(
 
 #undef scr_init_sp
 int	scr_init_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *file)
 		{ return(*(int *)0); }
 
@@ -2552,7 +2552,7 @@ int	scr_init(
 
 #undef scr_set_sp
 int	scr_set_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *file)
 		{ return(*(int *)0); }
 
@@ -2565,16 +2565,16 @@ int	scr_set(
 
 #undef _nc_scroll_window
 void	_nc_scroll_window(
-		WINDOW	*win, 
-		int const n, 
-		int const top, 
-		int const bottom, 
+		WINDOW	*win,
+		int const n,
+		int const top,
+		int const bottom,
 		cchar_t	blank)
 		{ /* void */ }
 
 #undef wscrl
 int	wscrl(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -2582,7 +2582,7 @@ int	wscrl(
 
 #undef scrollok
 int	scrollok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
@@ -2590,8 +2590,8 @@ int	scrollok(
 
 #undef wsetscrreg
 int	wsetscrreg(
-		WINDOW	*win, 
-		int	top, 
+		WINDOW	*win,
+		int	top,
 		int	bottom)
 		{ return(*(int *)0); }
 
@@ -2609,54 +2609,54 @@ void	delscreen(
 
 #undef _nc_setupscreen_sp
 int	_nc_setupscreen_sp(
-		SCREEN	**spp, 
-		int	slines, 
-		int	scolumns, 
-		FILE	*output, 
-		int	filtered, 
+		SCREEN	**spp,
+		int	slines,
+		int	scolumns,
+		FILE	*output,
+		int	filtered,
 		int	slk_format)
 		{ return(*(int *)0); }
 
 #undef _nc_setupscreen
 int	_nc_setupscreen(
-		int	slines, 
-		int	scolumns, 
-		FILE	*output, 
-		int	filtered, 
+		int	slines,
+		int	scolumns,
+		FILE	*output,
+		int	filtered,
 		int	slk_format)
 		{ return(*(int *)0); }
 
 #undef _nc_ripoffline_sp
 int	_nc_ripoffline_sp(
-		SCREEN	*sp, 
-		int	line, 
+		SCREEN	*sp,
+		int	line,
 		int	(*init)(
-		WINDOW	*p1, 
+		WINDOW	*p1,
 		int	p2))
 		{ return(*(int *)0); }
 
 #undef _nc_ripoffline
 int	_nc_ripoffline(
-		int	line, 
+		int	line,
 		int	(*init)(
-		WINDOW	*p1, 
+		WINDOW	*p1,
 		int	p2))
 		{ return(*(int *)0); }
 
 #undef ripoffline_sp
 int	ripoffline_sp(
-		SCREEN	*sp, 
-		int	line, 
+		SCREEN	*sp,
+		int	line,
 		int	(*init)(
-		WINDOW	*p1, 
+		WINDOW	*p1,
 		int	p2))
 		{ return(*(int *)0); }
 
 #undef ripoffline
 int	ripoffline(
-		int	line, 
+		int	line,
 		int	(*init)(
-		WINDOW	*p1, 
+		WINDOW	*p1,
 		int	p2))
 		{ return(*(int *)0); }
 
@@ -2664,13 +2664,13 @@ int	ripoffline(
 
 #undef _nc_format_slks
 int	_nc_format_slks(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	cols)
 		{ return(*(int *)0); }
 
 #undef _nc_slk_initialize
 int	_nc_slk_initialize(
-		WINDOW	*stwin, 
+		WINDOW	*stwin,
 		int	cols)
 		{ return(*(int *)0); }
 
@@ -2687,16 +2687,16 @@ int	slk_restore(void)
 
 #undef slk_attr_set_sp
 int	slk_attr_set_sp(
-		SCREEN	*sp, 
-		const attr_t attr, 
-		short	pair_arg, 
+		SCREEN	*sp,
+		const attr_t attr,
+		short	pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
 #undef slk_attr_set
 int	slk_attr_set(
-		const attr_t attr, 
-		short	pair_arg, 
+		const attr_t attr,
+		short	pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -2704,7 +2704,7 @@ int	slk_attr_set(
 
 #undef slk_attroff_sp
 int	slk_attroff_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const chtype attr)
 		{ return(*(int *)0); }
 
@@ -2717,7 +2717,7 @@ int	slk_attroff(
 
 #undef slk_attron_sp
 int	slk_attron_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const chtype attr)
 		{ return(*(int *)0); }
 
@@ -2730,7 +2730,7 @@ int	slk_attron(
 
 #undef slk_attrset_sp
 int	slk_attrset_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const chtype attr)
 		{ return(*(int *)0); }
 
@@ -2765,7 +2765,7 @@ int	slk_clear(void)
 
 #undef slk_color_sp
 int	slk_color_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		short	pair_arg)
 		{ return(*(int *)0); }
 
@@ -2776,7 +2776,7 @@ int	slk_color(
 
 #undef extended_slk_color_sp
 int	extended_slk_color_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	pair_arg)
 		{ return(*(int *)0); }
 
@@ -2789,7 +2789,7 @@ int	extended_slk_color(
 
 #undef slk_init_sp
 int	slk_init_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	format)
 		{ return(*(int *)0); }
 
@@ -2802,7 +2802,7 @@ int	slk_init(
 
 #undef slk_label_sp
 char	*slk_label_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	n)
 		{ return(*(char **)0); }
 
@@ -2835,16 +2835,16 @@ int	slk_refresh(void)
 
 #undef slk_set_sp
 int	slk_set_sp(
-		SCREEN	*sp, 
-		int	i, 
-		const char *astr, 
+		SCREEN	*sp,
+		int	i,
+		const char *astr,
 		int	format)
 		{ return(*(int *)0); }
 
 #undef slk_set
 int	slk_set(
-		int	i, 
-		const char *astr, 
+		int	i,
+		const char *astr,
 		int	format)
 		{ return(*(int *)0); }
 
@@ -2863,7 +2863,7 @@ int	slk_touch(void)
 
 #undef is_linetouched
 NCURSES_BOOL is_linetouched(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	line)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -2874,9 +2874,9 @@ NCURSES_BOOL is_wintouched(
 
 #undef wtouchln
 int	wtouchln(
-		WINDOW	*win, 
-		int	y, 
-		int	n, 
+		WINDOW	*win,
+		int	y,
+		int	n,
 		int	changed)
 		{ return(*(int *)0); }
 
@@ -2884,7 +2884,7 @@ int	wtouchln(
 
 #undef _tracedump
 void	_tracedump(
-		const char *name, 
+		const char *name,
 		WINDOW	*win)
 		{ /* void */ }
 
@@ -2892,19 +2892,19 @@ void	_tracedump(
 
 #undef _nc_trace_mmask_t
 char	*_nc_trace_mmask_t(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		mmask_t	code)
 		{ return(*(char **)0); }
 
 #undef _nc_tracemouse
 char	*_nc_tracemouse(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		MEVENT const *ep)
 		{ return(*(char **)0); }
 
 #undef _nc_retrace_mmask_t
 mmask_t	_nc_retrace_mmask_t(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		mmask_t	code)
 		{ return(*(mmask_t *)0); }
 
@@ -2929,7 +2929,7 @@ void	_nc_fifo_dump(
 
 #undef ungetch_sp
 int	ungetch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -2942,20 +2942,20 @@ int	ungetch(
 
 #undef vidputs_sp
 int	vidputs_sp(
-		SCREEN	*sp, 
-		chtype	newmode, 
+		SCREEN	*sp,
+		chtype	newmode,
 		NCURSES_OUTC_sp outc)
 		{ return(*(int *)0); }
 
 #undef vidputs
 int	vidputs(
-		chtype	newmode, 
+		chtype	newmode,
 		NCURSES_OUTC outc)
 		{ return(*(int *)0); }
 
 #undef vidattr_sp
 int	vidattr_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		chtype	newmode)
 		{ return(*(int *)0); }
 
@@ -2977,8 +2977,8 @@ chtype	termattrs(void)
 
 #undef wvline
 int	wvline(
-		WINDOW	*win, 
-		chtype	ch, 
+		WINDOW	*win,
+		chtype	ch,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -2986,8 +2986,8 @@ int	wvline(
 
 #undef wattr_off
 int	wattr_off(
-		WINDOW	*win, 
-		attr_t	at, 
+		WINDOW	*win,
+		attr_t	at,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -2995,8 +2995,8 @@ int	wattr_off(
 
 #undef wattr_on
 int	wattr_on(
-		WINDOW	*win, 
-		attr_t	at, 
+		WINDOW	*win,
+		attr_t	at,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -3016,14 +3016,14 @@ void	_nc_synchook(
 
 #undef mvderwin
 int	mvderwin(
-		WINDOW	*win, 
-		int	y, 
+		WINDOW	*win,
+		int	y,
 		int	x)
 		{ return(*(int *)0); }
 
 #undef syncok
 int	syncok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL bf)
 		{ return(*(int *)0); }
 
@@ -3062,14 +3062,14 @@ struct panelhook *_nc_panelhook(void)
 
 #undef _nc_printf_string_sp
 char	*_nc_printf_string_sp(
-		SCREEN	*sp, 
-		const char *fmt, 
+		SCREEN	*sp,
+		const char *fmt,
 		va_list	ap)
 		{ return(*(char **)0); }
 
 #undef _nc_printf_string
 char	*_nc_printf_string(
-		const char *fmt, 
+		const char *fmt,
 		va_list	ap)
 		{ return(*(char **)0); }
 
@@ -3086,18 +3086,18 @@ int	doupdate(void)
 
 #undef _nc_scrolln_sp
 int	_nc_scrolln_sp(
-		SCREEN	*sp, 
-		int	n, 
-		int	top, 
-		int	bot, 
+		SCREEN	*sp,
+		int	n,
+		int	top,
+		int	bot,
 		int	maxy)
 		{ return(*(int *)0); }
 
 #undef _nc_scrolln
 int	_nc_scrolln(
-		int	n, 
-		int	top, 
-		int	bot, 
+		int	n,
+		int	top,
+		int	bot,
 		int	maxy)
 		{ return(*(int *)0); }
 
@@ -3130,7 +3130,7 @@ void	_nc_screen_wrap(void)
 
 #undef _nc_do_xmc_glitch_sp
 void	_nc_do_xmc_glitch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		attr_t	previous)
 		{ /* void */ }
 
@@ -3143,7 +3143,7 @@ void	_nc_do_xmc_glitch(
 
 #undef _nc_varargs
 char	*_nc_varargs(
-		const char *fmt, 
+		const char *fmt,
 		va_list	ap)
 		{ return(*(char **)0); }
 
@@ -3161,7 +3161,7 @@ void	_nc_freeall(void)
 
 #undef _nc_free_and_exit_sp
 void	_nc_free_and_exit_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	code)
 		{ /* void */ }
 
@@ -3196,13 +3196,13 @@ wint_t	_nc_to_widechar(
 
 #undef wadd_wch
 int	wadd_wch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const cchar_t *wch)
 		{ return(*(int *)0); }
 
 #undef wecho_wchar
 int	wecho_wchar(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const cchar_t *wch)
 		{ return(*(int *)0); }
 
@@ -3210,14 +3210,14 @@ int	wecho_wchar(
 
 #undef wborder_set
 int	wborder_set(
-		WINDOW	*win, 
-		const cchar_t *ls, 
-		const cchar_t *rs, 
-		const cchar_t *ts, 
-		const cchar_t *bs, 
-		const cchar_t *tl, 
-		const cchar_t *tr, 
-		const cchar_t *bl, 
+		WINDOW	*win,
+		const cchar_t *ls,
+		const cchar_t *rs,
+		const cchar_t *ts,
+		const cchar_t *bs,
+		const cchar_t *tl,
+		const cchar_t *tr,
+		const cchar_t *bl,
 		const cchar_t *br)
 		{ return(*(int *)0); }
 
@@ -3225,29 +3225,41 @@ int	wborder_set(
 
 #undef setcchar
 int	setcchar(
-		cchar_t	*wcval, 
-		const wchar_t *wch, 
-		const attr_t attrs, 
-		short	pair_arg, 
+		cchar_t	*wcval,
+		const wchar_t *wch,
+		const attr_t attrs,
+		short	pair_arg,
 		const void *opts)
 		{ return(*(int *)0); }
 
 #undef getcchar
 int	getcchar(
-		const cchar_t *wcval, 
-		wchar_t	*wch, 
-		attr_t	*attrs, 
-		short	*pair_arg, 
+		const cchar_t *wcval,
+		wchar_t	*wch,
+		attr_t	*attrs,
+		short	*pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
 /* ./widechar/lib_erasewchar.c */
 
+#undef erasewchar_sp
+int	erasewchar_sp(
+		SCREEN	*sp,
+		wchar_t	*wch)
+		{ return(*(int *)0); }
+
 #undef erasewchar
 int	erasewchar(
 		wchar_t	*wch)
 		{ return(*(int *)0); }
 
+#undef killwchar_sp
+int	killwchar_sp(
+		SCREEN	*sp,
+		wchar_t	*wch)
+		{ return(*(int *)0); }
+
 #undef killwchar
 int	killwchar(
 		wchar_t	*wch)
@@ -3257,7 +3269,7 @@ int	killwchar(
 
 #undef wget_wch
 int	wget_wch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		wint_t	*result)
 		{ return(*(int *)0); }
 
@@ -3265,8 +3277,8 @@ int	wget_wch(
 
 #undef wgetn_wstr
 int	wgetn_wstr(
-		WINDOW	*win, 
-		wint_t	*str, 
+		WINDOW	*win,
+		wint_t	*str,
 		int	maxlen)
 		{ return(*(int *)0); }
 
@@ -3274,8 +3286,8 @@ int	wgetn_wstr(
 
 #undef whline_set
 int	whline_set(
-		WINDOW	*win, 
-		const cchar_t *ch, 
+		WINDOW	*win,
+		const cchar_t *ch,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -3283,7 +3295,7 @@ int	whline_set(
 
 #undef win_wch
 int	win_wch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		cchar_t	*wcval)
 		{ return(*(int *)0); }
 
@@ -3291,8 +3303,8 @@ int	win_wch(
 
 #undef win_wchnstr
 int	win_wchnstr(
-		WINDOW	*win, 
-		cchar_t	*wchstr, 
+		WINDOW	*win,
+		cchar_t	*wchstr,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -3300,20 +3312,20 @@ int	win_wchnstr(
 
 #undef _nc_insert_wch
 int	_nc_insert_wch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const cchar_t *wch)
 		{ return(*(int *)0); }
 
 #undef wins_wch
 int	wins_wch(
-		WINDOW	*win, 
+		WINDOW	*win,
 		const cchar_t *wch)
 		{ return(*(int *)0); }
 
 #undef wins_nwstr
 int	wins_nwstr(
-		WINDOW	*win, 
-		const wchar_t *wstr, 
+		WINDOW	*win,
+		const wchar_t *wstr,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -3321,14 +3333,14 @@ int	wins_nwstr(
 
 #undef winnwstr
 int	winnwstr(
-		WINDOW	*win, 
-		wchar_t	*wstr, 
+		WINDOW	*win,
+		wchar_t	*wstr,
 		int	n)
 		{ return(*(int *)0); }
 
 #undef winwstr
 int	winwstr(
-		WINDOW	*win, 
+		WINDOW	*win,
 		wchar_t	*wstr)
 		{ return(*(int *)0); }
 
@@ -3343,7 +3355,7 @@ const char *key_name(
 
 #undef pecho_wchar
 int	pecho_wchar(
-		WINDOW	*pad, 
+		WINDOW	*pad,
 		const cchar_t *wch)
 		{ return(*(int *)0); }
 
@@ -3351,8 +3363,8 @@ int	pecho_wchar(
 
 #undef slk_wset
 int	slk_wset(
-		int	i, 
-		const wchar_t *astr, 
+		int	i,
+		const wchar_t *astr,
 		int	format)
 		{ return(*(int *)0); }
 
@@ -3360,14 +3372,14 @@ int	slk_wset(
 
 #undef _nc_wcrtomb
 size_t	_nc_wcrtomb(
-		char	*target, 
-		wchar_t	source, 
+		char	*target,
+		wchar_t	source,
 		mbstate_t *state)
 		{ return(*(size_t *)0); }
 
 #undef unget_wch_sp
 int	unget_wch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const wchar_t wch)
 		{ return(*(int *)0); }
 
@@ -3380,33 +3392,33 @@ int	unget_wch(
 
 #undef vid_puts_sp
 int	vid_puts_sp(
-		SCREEN	*sp, 
-		attr_t	newmode, 
-		short	pair_arg, 
-		void	*opts, 
+		SCREEN	*sp,
+		attr_t	newmode,
+		short	pair_arg,
+		void	*opts,
 		NCURSES_OUTC_sp outc)
 		{ return(*(int *)0); }
 
 #undef vid_puts
 int	vid_puts(
-		attr_t	newmode, 
-		short	pair_arg, 
-		void	*opts, 
+		attr_t	newmode,
+		short	pair_arg,
+		void	*opts,
 		NCURSES_OUTC outc)
 		{ return(*(int *)0); }
 
 #undef vid_attr_sp
 int	vid_attr_sp(
-		SCREEN	*sp, 
-		attr_t	newmode, 
-		short	pair_arg, 
+		SCREEN	*sp,
+		attr_t	newmode,
+		short	pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
 #undef vid_attr
 int	vid_attr(
-		attr_t	newmode, 
-		short	pair_arg, 
+		attr_t	newmode,
+		short	pair_arg,
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -3423,8 +3435,8 @@ attr_t	term_attrs(void)
 
 #undef wvline_set
 int	wvline_set(
-		WINDOW	*win, 
-		const cchar_t *ch, 
+		WINDOW	*win,
+		const cchar_t *ch,
 		int	n)
 		{ return(*(int *)0); }
 
@@ -3441,7 +3453,7 @@ void	_nc_init_wacs(void)
 
 #undef wunctrl_sp
 wchar_t	*wunctrl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		cchar_t	*wc)
 		{ return(*(wchar_t **)0); }
 
@@ -3454,31 +3466,31 @@ wchar_t	*wunctrl(
 
 #undef _nc_toggle_attr_on
 void	_nc_toggle_attr_on(
-		attr_t	*S, 
+		attr_t	*S,
 		attr_t	at)
 		{ /* void */ }
 
 #undef _nc_toggle_attr_off
 void	_nc_toggle_attr_off(
-		attr_t	*S, 
+		attr_t	*S,
 		attr_t	at)
 		{ /* void */ }
 
 #undef _nc_DelCharCost_sp
 int	_nc_DelCharCost_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	count)
 		{ return(*(int *)0); }
 
 #undef _nc_InsCharCost_sp
 int	_nc_InsCharCost_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	count)
 		{ return(*(int *)0); }
 
 #undef _nc_UpdateAttrs_sp
 void	_nc_UpdateAttrs_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const cchar_t *c)
 		{ /* void */ }
 
@@ -3501,7 +3513,7 @@ void	_nc_UpdateAttrs(
 
 #undef use_legacy_coding_sp
 int	use_legacy_coding_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	level)
 		{ return(*(int *)0); }
 
@@ -3523,14 +3535,14 @@ int	use_default_colors(void)
 
 #undef assume_default_colors_sp
 int	assume_default_colors_sp(
-		SCREEN	*sp, 
-		int	fg, 
+		SCREEN	*sp,
+		int	fg,
 		int	bg)
 		{ return(*(int *)0); }
 
 #undef assume_default_colors
 int	assume_default_colors(
-		int	fg, 
+		int	fg,
 		int	bg)
 		{ return(*(int *)0); }
 
@@ -3538,14 +3550,14 @@ int	assume_default_colors(
 
 #undef mcprint_sp
 int	mcprint_sp(
-		SCREEN	*sp, 
-		char	*data, 
+		SCREEN	*sp,
+		char	*data,
 		int	len)
 		{ return(*(int *)0); }
 
 #undef mcprint
 int	mcprint(
-		char	*data, 
+		char	*data,
 		int	len)
 		{ return(*(int *)0); }
 
@@ -3558,55 +3570,55 @@ void	_nc_free_ordered_pairs(
 
 #undef _nc_reset_color_pair
 void	_nc_reset_color_pair(
-		SCREEN	*sp, 
-		int	pair, 
+		SCREEN	*sp,
+		int	pair,
 		colorpair_t *next)
 		{ /* void */ }
 
 #undef _nc_set_color_pair
 void	_nc_set_color_pair(
-		SCREEN	*sp, 
-		int	pair, 
+		SCREEN	*sp,
+		int	pair,
 		int	mode)
 		{ /* void */ }
 
 #undef _nc_copy_pairs
 void	_nc_copy_pairs(
-		SCREEN	*sp, 
-		colorpair_t *target, 
-		colorpair_t *source, 
+		SCREEN	*sp,
+		colorpair_t *target,
+		colorpair_t *source,
 		int	length)
 		{ /* void */ }
 
 #undef alloc_pair_sp
 int	alloc_pair_sp(
-		SCREEN	*sp, 
-		int	fg, 
+		SCREEN	*sp,
+		int	fg,
 		int	bg)
 		{ return(*(int *)0); }
 
 #undef find_pair_sp
 int	find_pair_sp(
-		SCREEN	*sp, 
-		int	fg, 
+		SCREEN	*sp,
+		int	fg,
 		int	bg)
 		{ return(*(int *)0); }
 
 #undef free_pair_sp
 int	free_pair_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	pair)
 		{ return(*(int *)0); }
 
 #undef alloc_pair
 int	alloc_pair(
-		int	f, 
+		int	f,
 		int	b)
 		{ return(*(int *)0); }
 
 #undef find_pair
 int	find_pair(
-		int	f, 
+		int	f,
 		int	b)
 		{ return(*(int *)0); }
 
@@ -3619,40 +3631,40 @@ int	free_pair(
 
 #undef is_term_resized_sp
 NCURSES_BOOL is_term_resized_sp(
-		SCREEN	*sp, 
-		int	ToLines, 
+		SCREEN	*sp,
+		int	ToLines,
 		int	ToCols)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef is_term_resized
 NCURSES_BOOL is_term_resized(
-		int	ToLines, 
+		int	ToLines,
 		int	ToCols)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef resize_term_sp
 int	resize_term_sp(
-		SCREEN	*sp, 
-		int	ToLines, 
+		SCREEN	*sp,
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
 #undef resize_term
 int	resize_term(
-		int	ToLines, 
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
 #undef resizeterm_sp
 int	resizeterm_sp(
-		SCREEN	*sp, 
-		int	ToLines, 
+		SCREEN	*sp,
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
 #undef resizeterm
 int	resizeterm(
-		int	ToLines, 
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
@@ -3667,8 +3679,8 @@ void	_nc_trace_xnames(
 
 #undef use_screen
 int	use_screen(
-		SCREEN	*screen, 
-		NCURSES_SCREEN_CB func, 
+		SCREEN	*screen,
+		NCURSES_SCREEN_CB func,
 		void	*data)
 		{ return(*(int *)0); }
 
@@ -3676,8 +3688,8 @@ int	use_screen(
 
 #undef use_window
 int	use_window(
-		WINDOW	*win, 
-		NCURSES_WINDOW_CB func, 
+		WINDOW	*win,
+		NCURSES_WINDOW_CB func,
 		void	*data)
 		{ return(*(int *)0); }
 
@@ -3685,8 +3697,8 @@ int	use_window(
 
 #undef wresize
 int	wresize(
-		WINDOW	*win, 
-		int	ToLines, 
+		WINDOW	*win,
+		int	ToLines,
 		int	ToCols)
 		{ return(*(int *)0); }
 
@@ -3714,7 +3726,7 @@ char	*_nc_basename(
 
 #undef _nc_access
 int	_nc_access(
-		const char *path, 
+		const char *path,
 		int	mode)
 		{ return(*(int *)0); }
 
@@ -3732,12 +3744,25 @@ NCURSES_BOOL _nc_is_file_path(
 int	_nc_env_access(void)
 		{ return(*(int *)0); }
 
+#undef _nc_safe_fopen
+FILE	*_nc_safe_fopen(
+		const char *path,
+		const char *mode)
+		{ return(*(FILE **)0); }
+
+#undef _nc_safe_open3
+int	_nc_safe_open3(
+		const char *path,
+		int	flags,
+		mode_t	mode)
+		{ return(*(int *)0); }
+
 /* ./tinfo/add_tries.c */
 
 #undef _nc_add_to_try
 int	_nc_add_to_try(
-		TRIES	**tree, 
-		const char *str, 
+		TRIES	**tree,
+		const char *str,
 		unsigned code)
 		{ return(*(int *)0); }
 
@@ -3745,25 +3770,25 @@ int	_nc_add_to_try(
 
 #undef _nc_align_termtype
 void	_nc_align_termtype(
-		TERMTYPE2 *to, 
+		TERMTYPE2 *to,
 		TERMTYPE2 *from)
 		{ /* void */ }
 
 #undef _nc_copy_termtype
 void	_nc_copy_termtype(
-		TERMTYPE *dst, 
+		TERMTYPE *dst,
 		const TERMTYPE *src)
 		{ /* void */ }
 
 #undef _nc_copy_termtype2
 void	_nc_copy_termtype2(
-		TERMTYPE2 *dst, 
+		TERMTYPE2 *dst,
 		const TERMTYPE2 *src)
 		{ /* void */ }
 
 #undef _nc_export_termtype2
 void	_nc_export_termtype2(
-		TERMTYPE *dst, 
+		TERMTYPE *dst,
 		const TERMTYPE2 *src)
 		{ /* void */ }
 
@@ -3828,19 +3853,19 @@ void	_nc_get_type(
 
 #undef _nc_warning
 void	_nc_warning(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
 #undef _nc_err_abort
 void	_nc_err_abort(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
 #undef _nc_syserr_abort
 void	_nc_syserr_abort(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
@@ -3848,14 +3873,14 @@ void	_nc_syserr_abort(
 
 #undef _nc_find_entry
 struct name_table_entry const *_nc_find_entry(
-		const char *string, 
+		const char *string,
 		const HashValue *hash_table)
 		{ return(*(struct name_table_entry const **)0); }
 
 #undef _nc_find_type_entry
 struct name_table_entry const *_nc_find_type_entry(
-		const char *string, 
-		int	type, 
+		const char *string,
+		int	type,
 		NCURSES_BOOL termcap)
 		{ return(*(struct name_table_entry const **)0); }
 
@@ -3892,13 +3917,13 @@ void	_nc_last_db(void)
 
 #undef _nc_next_db
 const char *_nc_next_db(
-		DBDIRS	*state, 
+		DBDIRS	*state,
 		int	*offset)
 		{ return(*(const char **)0); }
 
 #undef _nc_first_db
 void	_nc_first_db(
-		DBDIRS	*state, 
+		DBDIRS	*state,
 		int	*offset)
 		{ /* void */ }
 
@@ -3906,7 +3931,7 @@ void	_nc_first_db(
 
 #undef _nc_doalloc
 void	*_nc_doalloc(
-		void	*oldp, 
+		void	*oldp,
 		size_t	amount)
 		{ return(*(void **)0); }
 
@@ -3919,7 +3944,7 @@ ENTRY	*_nc_tail;
 
 #undef _nc_free_entry
 void	_nc_free_entry(
-		ENTRY	*headp, 
+		ENTRY	*headp,
 		TERMTYPE2 *tterm)
 		{ /* void */ }
 
@@ -3956,6 +3981,11 @@ void	_nc_free_termtype(
 		TERMTYPE *ptr)
 		{ /* void */ }
 
+#undef _nc_free_termtype1
+void	_nc_free_termtype1(
+		TERMTYPE *ptr)
+		{ /* void */ }
+
 #undef _nc_free_termtype2
 void	_nc_free_termtype2(
 		TERMTYPE2 *ptr)
@@ -3978,7 +4008,7 @@ int	_nc_getenv_num(
 
 #undef _nc_setenv_num
 void	_nc_setenv_num(
-		const char *name, 
+		const char *name,
 		int	value)
 		{ /* void */ }
 
@@ -4012,8 +4042,8 @@ void	_nc_init_acs(void)
 /* ./tinfo/lib_baudrate.c */
 
 struct speed {
-    int given_speed; 
-    int actual_speed; 
+    int given_speed;
+    int actual_speed;
 };
 
 #undef _nc_baudrate
@@ -4042,7 +4072,7 @@ TERMINAL *cur_term;
 
 #undef set_curterm_sp
 TERMINAL *set_curterm_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		TERMINAL *termp)
 		{ return(*(TERMINAL **)0); }
 
@@ -4053,7 +4083,7 @@ TERMINAL *set_curterm(
 
 #undef del_curterm_sp
 int	del_curterm_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		TERMINAL *termp)
 		{ return(*(int *)0); }
 
@@ -4139,7 +4169,7 @@ struct kn { short offset; int code; };
 
 #undef keyname_sp
 const char *keyname_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	c)
 		{ return(*(const char **)0); }
 
@@ -4163,7 +4193,7 @@ char	*longname(void)
 
 #undef napms_sp
 int	napms_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ms)
 		{ return(*(int *)0); }
 
@@ -4176,19 +4206,19 @@ int	napms(
 
 #undef idlok
 int	idlok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef idcok
 void	idcok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ /* void */ }
 
 #undef halfdelay_sp
 int	halfdelay_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	t)
 		{ return(*(int *)0); }
 
@@ -4199,37 +4229,37 @@ int	halfdelay(
 
 #undef nodelay
 int	nodelay(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef notimeout
 int	notimeout(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL f)
 		{ return(*(int *)0); }
 
 #undef wtimeout
 void	wtimeout(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	delay)
 		{ /* void */ }
 
 #undef keypad
 int	keypad(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef meta
 int	meta(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef curs_set_sp
 int	curs_set_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	vis)
 		{ return(*(int *)0); }
 
@@ -4240,7 +4270,7 @@ int	curs_set(
 
 #undef typeahead_sp
 int	typeahead_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	fd)
 		{ return(*(int *)0); }
 
@@ -4251,7 +4281,7 @@ int	typeahead(
 
 #undef has_key_sp
 int	has_key_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	keycode)
 		{ return(*(int *)0); }
 
@@ -4262,14 +4292,14 @@ int	has_key(
 
 #undef _nc_putp_flush_sp
 int	_nc_putp_flush_sp(
-		SCREEN	*sp, 
-		const char *name, 
+		SCREEN	*sp,
+		const char *name,
 		const char *value)
 		{ return(*(int *)0); }
 
 #undef _nc_keypad
 int	_nc_keypad(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	flag)
 		{ return(*(int *)0); }
 
@@ -4331,17 +4361,53 @@ void	noqiflush(void)
 
 #undef intrflush_sp
 int	intrflush_sp(
-		SCREEN	*sp, 
-		WINDOW	*win, 
+		SCREEN	*sp,
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef intrflush
 int	intrflush(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
+#undef is_nl_sp
+int	is_nl_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_raw_sp
+int	is_raw_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_cbreak_sp
+int	is_cbreak_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_echo_sp
+int	is_echo_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_nl
+int	is_nl(void)
+		{ return(*(int *)0); }
+
+#undef is_raw
+int	is_raw(void)
+		{ return(*(int *)0); }
+
+#undef is_cbreak
+int	is_cbreak(void)
+		{ return(*(int *)0); }
+
+#undef is_echo
+int	is_echo(void)
+		{ return(*(int *)0); }
+
 /* ./tinfo/lib_setup.c */
 
 #undef ttytype
@@ -4355,7 +4421,7 @@ int	TABSIZE;
 
 #undef set_tabsize_sp
 int	set_tabsize_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	value)
 		{ return(*(int *)0); }
 
@@ -4371,13 +4437,13 @@ int	_nc_handle_sigwinch(
 
 #undef use_env_sp
 void	use_env_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		NCURSES_BOOL f)
 		{ /* void */ }
 
 #undef use_tioctl_sp
 void	use_tioctl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		NCURSES_BOOL f)
 		{ /* void */ }
 
@@ -4393,8 +4459,8 @@ void	use_tioctl(
 
 #undef _nc_get_screensize
 void	_nc_get_screensize(
-		SCREEN	*sp, 
-		int	*linep, 
+		SCREEN	*sp,
+		int	*linep,
 		int	*colp)
 		{ /* void */ }
 
@@ -4405,13 +4471,13 @@ void	_nc_update_screensize(
 
 #undef _nc_setup_tinfo
 int	_nc_setup_tinfo(
-		const char *const tn, 
+		const char *const tn,
 		TERMTYPE2 *const tp)
 		{ return(*(int *)0); }
 
 #undef _nc_tinfo_cmdch
 void	_nc_tinfo_cmdch(
-		TERMINAL *termp, 
+		TERMINAL *termp,
 		int	proto)
 		{ /* void */ }
 
@@ -4430,9 +4496,9 @@ int	_nc_locale_breaks_acs(
 
 #undef _nc_setupterm
 int	_nc_setupterm(
-		const char *tname, 
-		int	Filedes, 
-		int	*errret, 
+		const char *tname,
+		int	Filedes,
+		int	*errret,
 		int	reuse)
 		{ return(*(int *)0); }
 
@@ -4442,8 +4508,8 @@ SCREEN	*new_prescr(void)
 
 #undef setupterm
 int	setupterm(
-		const char *tname, 
-		int	Filedes, 
+		const char *tname,
+		int	Filedes,
 		int	*errret)
 		{ return(*(int *)0); }
 
@@ -4456,20 +4522,20 @@ char	*BC;
 
 #undef tgetent_sp
 int	tgetent_sp(
-		SCREEN	*sp, 
-		char	*bufp, 
+		SCREEN	*sp,
+		char	*bufp,
 		const char *name)
 		{ return(*(int *)0); }
 
 #undef tgetent
 int	tgetent(
-		char	*bufp, 
+		char	*bufp,
 		const char *name)
 		{ return(*(int *)0); }
 
 #undef tgetflag_sp
 int	tgetflag_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *id)
 		{ return(*(int *)0); }
 
@@ -4480,7 +4546,7 @@ int	tgetflag(
 
 #undef tgetnum_sp
 int	tgetnum_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *id)
 		{ return(*(int *)0); }
 
@@ -4491,14 +4557,14 @@ int	tgetnum(
 
 #undef tgetstr_sp
 char	*tgetstr_sp(
-		SCREEN	*sp, 
-		const char *id, 
+		SCREEN	*sp,
+		const char *id,
 		char	**area)
 		{ return(*(char **)0); }
 
 #undef tgetstr
 char	*tgetstr(
-		const char *id, 
+		const char *id,
 		char	**area)
 		{ return(*(char **)0); }
 
@@ -4517,8 +4583,8 @@ char	*termname(void)
 
 #undef tgoto
 char	*tgoto(
-		const char *string, 
-		int	x, 
+		const char *string,
+		int	x,
 		int	y)
 		{ return(*(char **)0); }
 
@@ -4526,7 +4592,7 @@ char	*tgoto(
 
 #undef tigetflag_sp
 int	tigetflag_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -4537,7 +4603,7 @@ int	tigetflag(
 
 #undef tigetnum_sp
 int	tigetnum_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -4548,7 +4614,7 @@ int	tigetnum(
 
 #undef tigetstr_sp
 char	*tigetstr_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(char **)0); }
 
@@ -4562,32 +4628,58 @@ char	*tigetstr(
 #undef _nc_tparm_err
 int	_nc_tparm_err;
 
+#undef _nc_free_tparm
+void	_nc_free_tparm(
+		TERMINAL *termp)
+		{ /* void */ }
+
 #undef _nc_tparm_analyze
 int	_nc_tparm_analyze(
-		const char *string, 
-		char	*p_is_s[9], 
+		TERMINAL *term,
+		const char *string,
+		char	**p_is_s,
 		int	*_nc_popcount)
 		{ return(*(int *)0); }
 
 #undef tparm
 char	*tparm(
-		const char *string, 
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
 #undef tiparm
 char	*tiparm(
-		const char *string, 
+		const char *string,
+		...)
+		{ return(*(char **)0); }
+
+#undef tiparm_s
+char	*tiparm_s(
+		int	num_expected,
+		int	tparm_type,
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
+#undef tiscan_s
+int	tiscan_s(
+		int	*num_expected,
+		int	*tparm_type,
+		const char *string)
+		{ return(*(int *)0); }
+
 #undef _nc_tiparm
 char	*_nc_tiparm(
-		int	expected, 
-		const char *string, 
+		int	expected,
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
+#undef _nc_reset_tparm
+void	_nc_reset_tparm(
+		TERMINAL *term)
+		{ /* void */ }
+
 /* ./tinfo/lib_tputs.c */
 
 #undef PC
@@ -4604,7 +4696,7 @@ void	_nc_set_no_padding(
 
 #undef delay_output_sp
 int	delay_output_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ms)
 		{ return(*(int *)0); }
 
@@ -4624,7 +4716,7 @@ void	_nc_flush(void)
 
 #undef _nc_outch_sp
 int	_nc_outch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -4635,7 +4727,7 @@ int	_nc_outch(
 
 #undef _nc_putchar_sp
 int	_nc_putchar_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -4646,7 +4738,7 @@ int	_nc_putchar(
 
 #undef putp_sp
 int	putp_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *string)
 		{ return(*(int *)0); }
 
@@ -4657,35 +4749,35 @@ int	putp(
 
 #undef _nc_putp_sp
 int	_nc_putp_sp(
-		SCREEN	*sp, 
-		const char *name, 
+		SCREEN	*sp,
+		const char *name,
 		const char *string)
 		{ return(*(int *)0); }
 
 #undef _nc_putp
 int	_nc_putp(
-		const char *name, 
+		const char *name,
 		const char *string)
 		{ return(*(int *)0); }
 
 #undef tputs_sp
 int	tputs_sp(
-		SCREEN	*sp, 
-		const char *string, 
-		int	affcnt, 
+		SCREEN	*sp,
+		const char *string,
+		int	affcnt,
 		NCURSES_OUTC_sp outc)
 		{ return(*(int *)0); }
 
 #undef _nc_outc_wrapper
 int	_nc_outc_wrapper(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	c)
 		{ return(*(int *)0); }
 
 #undef tputs
 int	tputs(
-		const char *string, 
-		int	affcnt, 
+		const char *string,
+		int	affcnt,
 		int	(*outc)(
 		int	p1))
 		{ return(*(int *)0); }
@@ -4711,7 +4803,7 @@ void	trace(
 
 #undef _tracef
 void	_tracef(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ /* void */ }
 
@@ -4767,8 +4859,8 @@ WINDOW	*_nc_retrace_win(
 
 #undef _nc_fmt_funcptr
 char	*_nc_fmt_funcptr(
-		char	*target, 
-		const char *source, 
+		char	*target,
+		const char *source,
 		size_t	size)
 		{ return(*(char **)0); }
 
@@ -4776,7 +4868,7 @@ char	*_nc_fmt_funcptr(
 
 #undef _traceattr2
 char	*_traceattr2(
-		int	bufnum, 
+		int	bufnum,
 		chtype	newmode)
 		{ return(*(char **)0); }
 
@@ -4797,13 +4889,13 @@ attr_t	_nc_retrace_attr_t(
 
 #undef _nc_altcharset_name
 const char *_nc_altcharset_name(
-		attr_t	attr, 
+		attr_t	attr,
 		chtype	ch)
 		{ return(*(const char **)0); }
 
 #undef _tracechtype2
 char	*_tracechtype2(
-		int	bufnum, 
+		int	bufnum,
 		chtype	ch)
 		{ return(*(char **)0); }
 
@@ -4819,7 +4911,7 @@ chtype	_nc_retrace_chtype(
 
 #undef _tracecchar_t2
 char	*_tracecchar_t2(
-		int	bufnum, 
+		int	bufnum,
 		const cchar_t *ch)
 		{ return(*(char **)0); }
 
@@ -4832,7 +4924,7 @@ char	*_tracecchar_t(
 
 #undef _nc_trace_ttymode
 char	*_nc_trace_ttymode(
-		struct termios *tty)
+		const struct termios *tty)
 		{ return(*(char **)0); }
 
 #undef _nc_tracebits
@@ -4843,7 +4935,7 @@ char	*_nc_tracebits(void)
 
 #undef _nc_tracechar
 char	*_nc_tracechar(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(char **)0); }
 
@@ -4856,7 +4948,7 @@ char	*_tracechar(
 
 #undef _nc_get_tty_mode_sp
 int	_nc_get_tty_mode_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		struct termios *buf)
 		{ return(*(int *)0); }
 
@@ -4867,7 +4959,7 @@ int	_nc_get_tty_mode(
 
 #undef _nc_set_tty_mode_sp
 int	_nc_set_tty_mode_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		struct termios *buf)
 		{ return(*(int *)0); }
 
@@ -4934,9 +5026,9 @@ int	resetty(void)
 
 #undef _nc_timed_wait
 int	_nc_timed_wait(
-		SCREEN	*sp, 
-		int	mode, 
-		int	milliseconds, 
+		SCREEN	*sp,
+		int	mode,
+		int	milliseconds,
 		int	*timeleft)
 		{ return(*(int *)0); }
 
@@ -4949,8 +5041,8 @@ char	*_nc_first_name(
 
 #undef _nc_name_match
 int	_nc_name_match(
-		const char *const namelst, 
-		const char *const name, 
+		const char *const namelst,
+		const char *const name,
 		const char *const delim)
 		{ return(*(int *)0); }
 
@@ -4973,14 +5065,14 @@ const char *const strfnames[] = {0};
 
 #undef _nc_set_buffer_sp
 void	_nc_set_buffer_sp(
-		SCREEN	*sp, 
-		FILE	*ofp, 
+		SCREEN	*sp,
+		FILE	*ofp,
 		int	buffered)
 		{ /* void */ }
 
 #undef _nc_set_buffer
 void	_nc_set_buffer(
-		FILE	*ofp, 
+		FILE	*ofp,
 		int	buffered)
 		{ /* void */ }
 
@@ -4993,28 +5085,28 @@ void	_nc_init_termtype(
 
 #undef _nc_read_termtype
 int	_nc_read_termtype(
-		TERMTYPE2 *ptr, 
-		char	*buffer, 
+		TERMTYPE2 *ptr,
+		char	*buffer,
 		int	limit)
 		{ return(*(int *)0); }
 
 #undef _nc_read_file_entry
 int	_nc_read_file_entry(
-		const char *const filename, 
+		const char *const filename,
 		TERMTYPE2 *ptr)
 		{ return(*(int *)0); }
 
 #undef _nc_read_entry2
 int	_nc_read_entry2(
-		const char *const name, 
-		char	*const filename, 
+		const char *const name,
+		char	*const filename,
 		TERMTYPE2 *const tp)
 		{ return(*(int *)0); }
 
 #undef _nc_read_entry
 int	_nc_read_entry(
-		const char *const name, 
-		char	*const filename, 
+		const char *const name,
+		char	*const filename,
 		TERMTYPE *const tp)
 		{ return(*(int *)0); }
 
@@ -5022,7 +5114,7 @@ int	_nc_read_entry(
 
 #undef _nc_read_termcap_entry
 int	_nc_read_termcap_entry(
-		const char *const tn, 
+		const char *const tn,
 		TERMTYPE2 *const tp)
 		{ return(*(int *)0); }
 
@@ -5030,32 +5122,32 @@ int	_nc_read_termcap_entry(
 
 #undef _nc_str_init
 string_desc *_nc_str_init(
-		string_desc *dst, 
-		char	*src, 
+		string_desc *dst,
+		char	*src,
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_null
 string_desc *_nc_str_null(
-		string_desc *dst, 
+		string_desc *dst,
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_copy
 string_desc *_nc_str_copy(
-		string_desc *dst, 
-		string_desc *src)
+		string_desc *dst,
+		const string_desc *const src)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_safe_strcat
 NCURSES_BOOL _nc_safe_strcat(
-		string_desc *dst, 
+		string_desc *dst,
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_safe_strcpy
 NCURSES_BOOL _nc_safe_strcpy(
-		string_desc *dst, 
+		string_desc *dst,
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -5063,13 +5155,13 @@ NCURSES_BOOL _nc_safe_strcpy(
 
 #undef _nc_trace_buf
 char	*_nc_trace_buf(
-		int	bufnum, 
+		int	bufnum,
 		size_t	want)
 		{ return(*(char **)0); }
 
 #undef _nc_trace_bufcat
 char	*_nc_trace_bufcat(
-		int	bufnum, 
+		int	bufnum,
 		const char *value)
 		{ return(*(char **)0); }
 
@@ -5084,21 +5176,21 @@ void	_nc_trace_tries(
 
 #undef _nc_expand_try
 char	*_nc_expand_try(
-		TRIES	*tree, 
-		unsigned code, 
-		int	*count, 
+		TRIES	*tree,
+		unsigned code,
+		int	*count,
 		size_t	len)
 		{ return(*(char **)0); }
 
 #undef _nc_remove_key
 int	_nc_remove_key(
-		TRIES	**tree, 
+		TRIES	**tree,
 		unsigned code)
 		{ return(*(int *)0); }
 
 #undef _nc_remove_string
 int	_nc_remove_string(
-		TRIES	**tree, 
+		TRIES	**tree,
 		const char *string)
 		{ return(*(int *)0); }
 
@@ -5113,7 +5205,7 @@ char	*_nc_trim_sgr0(
 
 #undef unctrl_sp
 const char *unctrl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		chtype	ch)
 		{ return(*(const char **)0); }
 
@@ -5126,7 +5218,7 @@ const char *unctrl(
 
 #undef _nc_visbuf2
 const char *_nc_visbuf2(
-		int	bufnum, 
+		int	bufnum,
 		const char *buf)
 		{ return(*(const char **)0); }
 
@@ -5137,13 +5229,13 @@ const char *_nc_visbuf(
 
 #undef _nc_visbufn
 const char *_nc_visbufn(
-		const char *buf, 
+		const char *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
 #undef _nc_viswbuf2
 const char *_nc_viswbuf2(
-		int	bufnum, 
+		int	bufnum,
 		const wchar_t *buf)
 		{ return(*(const char **)0); }
 
@@ -5154,7 +5246,7 @@ const char *_nc_viswbuf(
 
 #undef _nc_viswbufn
 const char *_nc_viswbufn(
-		const wchar_t *buf, 
+		const wchar_t *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
@@ -5165,14 +5257,14 @@ const char *_nc_viswibuf(
 
 #undef _nc_viscbuf2
 const char *_nc_viscbuf2(
-		int	bufnum, 
-		const cchar_t *buf, 
+		int	bufnum,
+		const cchar_t *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
 #undef _nc_viscbuf
 const char *_nc_viscbuf(
-		const cchar_t *buf, 
+		const cchar_t *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
@@ -5190,18 +5282,18 @@ ENTRY	*_nc_copy_entry(
 
 #undef _nc_save_str
 char	*_nc_save_str(
-		const char *const string)
+		const char *string)
 		{ return(*(char **)0); }
 
 #undef _nc_wrap_entry
 void	_nc_wrap_entry(
-		ENTRY	*const ep, 
+		ENTRY	*const ep,
 		NCURSES_BOOL copy_strings)
 		{ /* void */ }
 
 #undef _nc_merge_entry
 void	_nc_merge_entry(
-		ENTRY	*const target, 
+		ENTRY	*const target,
 		ENTRY	*const source)
 		{ /* void */ }
 
@@ -5209,15 +5301,15 @@ void	_nc_merge_entry(
 
 #undef _nc_captoinfo
 char	*_nc_captoinfo(
-		const char *cap, 
-		const char *s, 
+		const char *cap,
+		const char *s,
 		int const parameterized)
 		{ return(*(char **)0); }
 
 #undef _nc_infotocap
 char	*_nc_infotocap(
-		const char *cap, 
-		const char *str, 
+		const char *cap,
+		const char *str,
 		int const parameterized)
 		{ return(*(char **)0); }
 
@@ -5225,8 +5317,8 @@ char	*_nc_infotocap(
 
 #undef _nc_tic_expand
 char	*_nc_tic_expand(
-		const char *srcp, 
-		NCURSES_BOOL tic_format, 
+		const char *srcp,
+		NCURSES_BOOL tic_format,
 		int	numbers)
 		{ return(*(char **)0); }
 
@@ -5234,28 +5326,28 @@ char	*_nc_tic_expand(
 
 #undef _nc_check_termtype2
 void	(*_nc_check_termtype2)(
-		TERMTYPE2 *p1, 
+		TERMTYPE2 *p1,
 		NCURSES_BOOL p2);
 
 #undef _nc_entry_match
 NCURSES_BOOL _nc_entry_match(
-		char	*n1, 
+		char	*n1,
 		char	*n2)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_read_entry_source
 void	_nc_read_entry_source(
-		FILE	*fp, 
-		char	*buf, 
-		int	literal, 
-		NCURSES_BOOL silent, 
+		FILE	*fp,
+		char	*buf,
+		int	literal,
+		NCURSES_BOOL silent,
 		NCURSES_BOOL (*hook)(
 		ENTRY	*p1))
 		{ /* void */ }
 
 #undef _nc_resolve_uses2
 int	_nc_resolve_uses2(
-		NCURSES_BOOL fullresolve, 
+		NCURSES_BOOL fullresolve,
 		NCURSES_BOOL literal)
 		{ return(*(int *)0); }
 
@@ -5280,7 +5372,7 @@ NCURSES_BOOL _nc_disable_period;
 
 #undef _nc_reset_input
 void	_nc_reset_input(
-		FILE	*fp, 
+		FILE	*fp,
 		char	*buf)
 		{ /* void */ }
 
@@ -5291,8 +5383,8 @@ int	_nc_get_token(
 
 #undef _nc_trans_string
 int	_nc_trans_string(
-		char	*ptr, 
-		char	*last)
+		char	*ptr,
+		const char *const last)
 		{ return(*(int *)0); }
 
 #undef _nc_push_token
@@ -5309,14 +5401,14 @@ void	_nc_panic_mode(
 
 #undef _nc_parse_entry
 int	_nc_parse_entry(
-		ENTRY	*entryp, 
-		int	literal, 
+		ENTRY	*entryp,
+		int	literal,
 		NCURSES_BOOL silent)
 		{ return(*(int *)0); }
 
 #undef _nc_capcmp
 int	_nc_capcmp(
-		const char *s, 
+		const char *s,
 		const char *t)
 		{ return(*(int *)0); }
 
@@ -5334,9 +5426,9 @@ void	_nc_write_entry(
 
 #undef _nc_write_object
 int	_nc_write_object(
-		TERMTYPE2 *tp, 
-		char	*buffer, 
-		unsigned *offset, 
+		TERMTYPE2 *tp,
+		char	*buffer,
+		unsigned *offset,
 		unsigned limit)
 		{ return(*(int *)0); }
 
@@ -5348,14 +5440,14 @@ int	_nc_tic_written(void)
 
 #undef define_key_sp
 int	define_key_sp(
-		SCREEN	*sp, 
-		const char *str, 
+		SCREEN	*sp,
+		const char *str,
 		int	keycode)
 		{ return(*(int *)0); }
 
 #undef define_key
 int	define_key(
-		const char *str, 
+		const char *str,
 		int	keycode)
 		{ return(*(int *)0); }
 
@@ -5369,7 +5461,7 @@ void	_nc_hashed_db(void)
 
 #undef key_defined_sp
 int	key_defined_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -5382,14 +5474,14 @@ int	key_defined(
 
 #undef keybound_sp
 char	*keybound_sp(
-		SCREEN	*sp, 
-		int	code, 
+		SCREEN	*sp,
+		int	code,
 		int	count)
 		{ return(*(char **)0); }
 
 #undef keybound
 char	*keybound(
-		int	code, 
+		int	code,
 		int	count)
 		{ return(*(char **)0); }
 
@@ -5397,14 +5489,14 @@ char	*keybound(
 
 #undef keyok_sp
 int	keyok_sp(
-		SCREEN	*sp, 
-		int	c, 
+		SCREEN	*sp,
+		int	c,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef keyok
 int	keyok(
-		int	c, 
+		int	c,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
diff --git a/contrib/ncurses/ncurses/llib-ltic b/contrib/ncurses/ncurses/llib-ltic
index 6ea27146dd09..9e87aaeae4a6 100644
--- a/contrib/ncurses/ncurses/llib-ltic
+++ b/contrib/ncurses/ncurses/llib-ltic
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020-2021,2023 Thomas E. Dickey                                *
  * Copyright 2012-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -48,18 +48,18 @@ ENTRY	*_nc_copy_entry(
 
 #undef _nc_save_str
 char	*_nc_save_str(
-		const char *const string)
+		const char *string)
 		{ return(*(char **)0); }
 
 #undef _nc_wrap_entry
 void	_nc_wrap_entry(
-		ENTRY	*const ep, 
+		ENTRY	*const ep,
 		NCURSES_BOOL copy_strings)
 		{ /* void */ }
 
 #undef _nc_merge_entry
 void	_nc_merge_entry(
-		ENTRY	*const target, 
+		ENTRY	*const target,
 		ENTRY	*const source)
 		{ /* void */ }
 
@@ -67,15 +67,15 @@ void	_nc_merge_entry(
 
 #undef _nc_captoinfo
 char	*_nc_captoinfo(
-		const char *cap, 
-		const char *s, 
+		const char *cap,
+		const char *s,
 		int const parameterized)
 		{ return(*(char **)0); }
 
 #undef _nc_infotocap
 char	*_nc_infotocap(
-		const char *cap, 
-		const char *str, 
+		const char *cap,
+		const char *str,
 		int const parameterized)
 		{ return(*(char **)0); }
 
@@ -83,8 +83,8 @@ char	*_nc_infotocap(
 
 #undef _nc_tic_expand
 char	*_nc_tic_expand(
-		const char *srcp, 
-		NCURSES_BOOL tic_format, 
+		const char *srcp,
+		NCURSES_BOOL tic_format,
 		int	numbers)
 		{ return(*(char **)0); }
 
@@ -92,28 +92,28 @@ char	*_nc_tic_expand(
 
 #undef _nc_check_termtype2
 void	(*_nc_check_termtype2)(
-		TERMTYPE2 *p1, 
+		TERMTYPE *p1,
 		NCURSES_BOOL p2);
 
 #undef _nc_entry_match
 NCURSES_BOOL _nc_entry_match(
-		char	*n1, 
+		char	*n1,
 		char	*n2)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_read_entry_source
 void	_nc_read_entry_source(
-		FILE	*fp, 
-		char	*buf, 
-		int	literal, 
-		NCURSES_BOOL silent, 
+		FILE	*fp,
+		char	*buf,
+		int	literal,
+		NCURSES_BOOL silent,
 		NCURSES_BOOL (*hook)(
 		ENTRY	*p1))
 		{ /* void */ }
 
 #undef _nc_resolve_uses2
 int	_nc_resolve_uses2(
-		NCURSES_BOOL fullresolve, 
+		NCURSES_BOOL fullresolve,
 		NCURSES_BOOL literal)
 		{ return(*(int *)0); }
 
@@ -138,7 +138,7 @@ NCURSES_BOOL _nc_disable_period;
 
 #undef _nc_reset_input
 void	_nc_reset_input(
-		FILE	*fp, 
+		FILE	*fp,
 		char	*buf)
 		{ /* void */ }
 
@@ -149,8 +149,8 @@ int	_nc_get_token(
 
 #undef _nc_trans_string
 int	_nc_trans_string(
-		char	*ptr, 
-		char	*last)
+		char	*ptr,
+		const char *const last)
 		{ return(*(int *)0); }
 
 #undef _nc_push_token
@@ -167,14 +167,14 @@ void	_nc_panic_mode(
 
 #undef _nc_parse_entry
 int	_nc_parse_entry(
-		ENTRY	*entryp, 
-		int	literal, 
+		ENTRY	*entryp,
+		int	literal,
 		NCURSES_BOOL silent)
 		{ return(*(int *)0); }
 
 #undef _nc_capcmp
 int	_nc_capcmp(
-		const char *s, 
+		const char *s,
 		const char *t)
 		{ return(*(int *)0); }
 
@@ -187,14 +187,14 @@ void	_nc_set_writedir(
 
 #undef _nc_write_entry
 void	_nc_write_entry(
-		TERMTYPE2 *const tp)
+		TERMTYPE *const tp)
 		{ /* void */ }
 
 #undef _nc_write_object
 int	_nc_write_object(
-		TERMTYPE2 *tp, 
-		char	*buffer, 
-		unsigned *offset, 
+		TERMTYPE *tp,
+		char	*buffer,
+		unsigned *offset,
 		unsigned limit)
 		{ return(*(int *)0); }
 
diff --git a/contrib/ncurses/ncurses/llib-ltict b/contrib/ncurses/ncurses/llib-ltict
index e1625df943e3..db9090b9125b 100644
--- a/contrib/ncurses/ncurses/llib-ltict
+++ b/contrib/ncurses/ncurses/llib-ltict
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020-2021,2023 Thomas E. Dickey                                *
  * Copyright 2013-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -48,18 +48,18 @@ ENTRY	*_nc_copy_entry(
 
 #undef _nc_save_str
 char	*_nc_save_str(
-		const char *const string)
+		const char *string)
 		{ return(*(char **)0); }
 
 #undef _nc_wrap_entry
 void	_nc_wrap_entry(
-		ENTRY	*const ep, 
+		ENTRY	*const ep,
 		NCURSES_BOOL copy_strings)
 		{ /* void */ }
 
 #undef _nc_merge_entry
 void	_nc_merge_entry(
-		ENTRY	*const target, 
+		ENTRY	*const target,
 		ENTRY	*const source)
 		{ /* void */ }
 
@@ -67,15 +67,15 @@ void	_nc_merge_entry(
 
 #undef _nc_captoinfo
 char	*_nc_captoinfo(
-		const char *cap, 
-		const char *s, 
+		const char *cap,
+		const char *s,
 		int const parameterized)
 		{ return(*(char **)0); }
 
 #undef _nc_infotocap
 char	*_nc_infotocap(
-		const char *cap, 
-		const char *str, 
+		const char *cap,
+		const char *str,
 		int const parameterized)
 		{ return(*(char **)0); }
 
@@ -83,8 +83,8 @@ char	*_nc_infotocap(
 
 #undef _nc_tic_expand
 char	*_nc_tic_expand(
-		const char *srcp, 
-		NCURSES_BOOL tic_format, 
+		const char *srcp,
+		NCURSES_BOOL tic_format,
 		int	numbers)
 		{ return(*(char **)0); }
 
@@ -92,28 +92,28 @@ char	*_nc_tic_expand(
 
 #undef _nc_check_termtype2
 void	(*_nc_check_termtype2)(
-		TERMTYPE2 *p1, 
+		TERMTYPE *p1,
 		NCURSES_BOOL p2);
 
 #undef _nc_entry_match
 NCURSES_BOOL _nc_entry_match(
-		char	*n1, 
+		char	*n1,
 		char	*n2)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_read_entry_source
 void	_nc_read_entry_source(
-		FILE	*fp, 
-		char	*buf, 
-		int	literal, 
-		NCURSES_BOOL silent, 
+		FILE	*fp,
+		char	*buf,
+		int	literal,
+		NCURSES_BOOL silent,
 		NCURSES_BOOL (*hook)(
 		ENTRY	*p1))
 		{ /* void */ }
 
 #undef _nc_resolve_uses2
 int	_nc_resolve_uses2(
-		NCURSES_BOOL fullresolve, 
+		NCURSES_BOOL fullresolve,
 		NCURSES_BOOL literal)
 		{ return(*(int *)0); }
 
@@ -138,7 +138,7 @@ NCURSES_BOOL _nc_disable_period;
 
 #undef _nc_reset_input
 void	_nc_reset_input(
-		FILE	*fp, 
+		FILE	*fp,
 		char	*buf)
 		{ /* void */ }
 
@@ -149,8 +149,8 @@ int	_nc_get_token(
 
 #undef _nc_trans_string
 int	_nc_trans_string(
-		char	*ptr, 
-		char	*last)
+		char	*ptr,
+		const char *const last)
 		{ return(*(int *)0); }
 
 #undef _nc_push_token
@@ -167,14 +167,14 @@ void	_nc_panic_mode(
 
 #undef _nc_parse_entry
 int	_nc_parse_entry(
-		ENTRY	*entryp, 
-		int	literal, 
+		ENTRY	*entryp,
+		int	literal,
 		NCURSES_BOOL silent)
 		{ return(*(int *)0); }
 
 #undef _nc_capcmp
 int	_nc_capcmp(
-		const char *s, 
+		const char *s,
 		const char *t)
 		{ return(*(int *)0); }
 
@@ -187,14 +187,14 @@ void	_nc_set_writedir(
 
 #undef _nc_write_entry
 void	_nc_write_entry(
-		TERMTYPE2 *const tp)
+		TERMTYPE *const tp)
 		{ /* void */ }
 
 #undef _nc_write_object
 int	_nc_write_object(
-		TERMTYPE2 *tp, 
-		char	*buffer, 
-		unsigned *offset, 
+		TERMTYPE *tp,
+		char	*buffer,
+		unsigned *offset,
 		unsigned limit)
 		{ return(*(int *)0); }
 
diff --git a/contrib/ncurses/ncurses/llib-ltictw b/contrib/ncurses/ncurses/llib-ltictw
index 6ea27146dd09..85db89bce08b 100644
--- a/contrib/ncurses/ncurses/llib-ltictw
+++ b/contrib/ncurses/ncurses/llib-ltictw
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020-2021,2023 Thomas E. Dickey                                *
  * Copyright 2012-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -48,18 +48,18 @@ ENTRY	*_nc_copy_entry(
 
 #undef _nc_save_str
 char	*_nc_save_str(
-		const char *const string)
+		const char *string)
 		{ return(*(char **)0); }
 
 #undef _nc_wrap_entry
 void	_nc_wrap_entry(
-		ENTRY	*const ep, 
+		ENTRY	*const ep,
 		NCURSES_BOOL copy_strings)
 		{ /* void */ }
 
 #undef _nc_merge_entry
 void	_nc_merge_entry(
-		ENTRY	*const target, 
+		ENTRY	*const target,
 		ENTRY	*const source)
 		{ /* void */ }
 
@@ -67,15 +67,15 @@ void	_nc_merge_entry(
 
 #undef _nc_captoinfo
 char	*_nc_captoinfo(
-		const char *cap, 
-		const char *s, 
+		const char *cap,
+		const char *s,
 		int const parameterized)
 		{ return(*(char **)0); }
 
 #undef _nc_infotocap
 char	*_nc_infotocap(
-		const char *cap, 
-		const char *str, 
+		const char *cap,
+		const char *str,
 		int const parameterized)
 		{ return(*(char **)0); }
 
@@ -83,8 +83,8 @@ char	*_nc_infotocap(
 
 #undef _nc_tic_expand
 char	*_nc_tic_expand(
-		const char *srcp, 
-		NCURSES_BOOL tic_format, 
+		const char *srcp,
+		NCURSES_BOOL tic_format,
 		int	numbers)
 		{ return(*(char **)0); }
 
@@ -92,28 +92,28 @@ char	*_nc_tic_expand(
 
 #undef _nc_check_termtype2
 void	(*_nc_check_termtype2)(
-		TERMTYPE2 *p1, 
+		TERMTYPE2 *p1,
 		NCURSES_BOOL p2);
 
 #undef _nc_entry_match
 NCURSES_BOOL _nc_entry_match(
-		char	*n1, 
+		char	*n1,
 		char	*n2)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_read_entry_source
 void	_nc_read_entry_source(
-		FILE	*fp, 
-		char	*buf, 
-		int	literal, 
-		NCURSES_BOOL silent, 
+		FILE	*fp,
+		char	*buf,
+		int	literal,
+		NCURSES_BOOL silent,
 		NCURSES_BOOL (*hook)(
 		ENTRY	*p1))
 		{ /* void */ }
 
 #undef _nc_resolve_uses2
 int	_nc_resolve_uses2(
-		NCURSES_BOOL fullresolve, 
+		NCURSES_BOOL fullresolve,
 		NCURSES_BOOL literal)
 		{ return(*(int *)0); }
 
@@ -138,7 +138,7 @@ NCURSES_BOOL _nc_disable_period;
 
 #undef _nc_reset_input
 void	_nc_reset_input(
-		FILE	*fp, 
+		FILE	*fp,
 		char	*buf)
 		{ /* void */ }
 
@@ -149,8 +149,8 @@ int	_nc_get_token(
 
 #undef _nc_trans_string
 int	_nc_trans_string(
-		char	*ptr, 
-		char	*last)
+		char	*ptr,
+		const char *const last)
 		{ return(*(int *)0); }
 
 #undef _nc_push_token
@@ -167,14 +167,14 @@ void	_nc_panic_mode(
 
 #undef _nc_parse_entry
 int	_nc_parse_entry(
-		ENTRY	*entryp, 
-		int	literal, 
+		ENTRY	*entryp,
+		int	literal,
 		NCURSES_BOOL silent)
 		{ return(*(int *)0); }
 
 #undef _nc_capcmp
 int	_nc_capcmp(
-		const char *s, 
+		const char *s,
 		const char *t)
 		{ return(*(int *)0); }
 
@@ -192,9 +192,9 @@ void	_nc_write_entry(
 
 #undef _nc_write_object
 int	_nc_write_object(
-		TERMTYPE2 *tp, 
-		char	*buffer, 
-		unsigned *offset, 
+		TERMTYPE2 *tp,
+		char	*buffer,
+		unsigned *offset,
 		unsigned limit)
 		{ return(*(int *)0); }
 
diff --git a/contrib/ncurses/ncurses/llib-lticw b/contrib/ncurses/ncurses/llib-lticw
index 6ea27146dd09..85db89bce08b 100644
--- a/contrib/ncurses/ncurses/llib-lticw
+++ b/contrib/ncurses/ncurses/llib-lticw
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020-2021,2023 Thomas E. Dickey                                *
  * Copyright 2012-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -48,18 +48,18 @@ ENTRY	*_nc_copy_entry(
 
 #undef _nc_save_str
 char	*_nc_save_str(
-		const char *const string)
+		const char *string)
 		{ return(*(char **)0); }
 
 #undef _nc_wrap_entry
 void	_nc_wrap_entry(
-		ENTRY	*const ep, 
+		ENTRY	*const ep,
 		NCURSES_BOOL copy_strings)
 		{ /* void */ }
 
 #undef _nc_merge_entry
 void	_nc_merge_entry(
-		ENTRY	*const target, 
+		ENTRY	*const target,
 		ENTRY	*const source)
 		{ /* void */ }
 
@@ -67,15 +67,15 @@ void	_nc_merge_entry(
 
 #undef _nc_captoinfo
 char	*_nc_captoinfo(
-		const char *cap, 
-		const char *s, 
+		const char *cap,
+		const char *s,
 		int const parameterized)
 		{ return(*(char **)0); }
 
 #undef _nc_infotocap
 char	*_nc_infotocap(
-		const char *cap, 
-		const char *str, 
+		const char *cap,
+		const char *str,
 		int const parameterized)
 		{ return(*(char **)0); }
 
@@ -83,8 +83,8 @@ char	*_nc_infotocap(
 
 #undef _nc_tic_expand
 char	*_nc_tic_expand(
-		const char *srcp, 
-		NCURSES_BOOL tic_format, 
+		const char *srcp,
+		NCURSES_BOOL tic_format,
 		int	numbers)
 		{ return(*(char **)0); }
 
@@ -92,28 +92,28 @@ char	*_nc_tic_expand(
 
 #undef _nc_check_termtype2
 void	(*_nc_check_termtype2)(
-		TERMTYPE2 *p1, 
+		TERMTYPE2 *p1,
 		NCURSES_BOOL p2);
 
 #undef _nc_entry_match
 NCURSES_BOOL _nc_entry_match(
-		char	*n1, 
+		char	*n1,
 		char	*n2)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_read_entry_source
 void	_nc_read_entry_source(
-		FILE	*fp, 
-		char	*buf, 
-		int	literal, 
-		NCURSES_BOOL silent, 
+		FILE	*fp,
+		char	*buf,
+		int	literal,
+		NCURSES_BOOL silent,
 		NCURSES_BOOL (*hook)(
 		ENTRY	*p1))
 		{ /* void */ }
 
 #undef _nc_resolve_uses2
 int	_nc_resolve_uses2(
-		NCURSES_BOOL fullresolve, 
+		NCURSES_BOOL fullresolve,
 		NCURSES_BOOL literal)
 		{ return(*(int *)0); }
 
@@ -138,7 +138,7 @@ NCURSES_BOOL _nc_disable_period;
 
 #undef _nc_reset_input
 void	_nc_reset_input(
-		FILE	*fp, 
+		FILE	*fp,
 		char	*buf)
 		{ /* void */ }
 
@@ -149,8 +149,8 @@ int	_nc_get_token(
 
 #undef _nc_trans_string
 int	_nc_trans_string(
-		char	*ptr, 
-		char	*last)
+		char	*ptr,
+		const char *const last)
 		{ return(*(int *)0); }
 
 #undef _nc_push_token
@@ -167,14 +167,14 @@ void	_nc_panic_mode(
 
 #undef _nc_parse_entry
 int	_nc_parse_entry(
-		ENTRY	*entryp, 
-		int	literal, 
+		ENTRY	*entryp,
+		int	literal,
 		NCURSES_BOOL silent)
 		{ return(*(int *)0); }
 
 #undef _nc_capcmp
 int	_nc_capcmp(
-		const char *s, 
+		const char *s,
 		const char *t)
 		{ return(*(int *)0); }
 
@@ -192,9 +192,9 @@ void	_nc_write_entry(
 
 #undef _nc_write_object
 int	_nc_write_object(
-		TERMTYPE2 *tp, 
-		char	*buffer, 
-		unsigned *offset, 
+		TERMTYPE2 *tp,
+		char	*buffer,
+		unsigned *offset,
 		unsigned limit)
 		{ return(*(int *)0); }
 
diff --git a/contrib/ncurses/ncurses/llib-ltinfo b/contrib/ncurses/ncurses/llib-ltinfo
index b2160d4f66b7..5cfa111a236d 100644
--- a/contrib/ncurses/ncurses/llib-ltinfo
+++ b/contrib/ncurses/ncurses/llib-ltinfo
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 2019-2022,2023 Thomas E. Dickey                                *
  * Copyright 2012-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -58,7 +58,7 @@ char	*_nc_basename(
 
 #undef _nc_access
 int	_nc_access(
-		const char *path, 
+		const char *path,
 		int	mode)
 		{ return(*(int *)0); }
 
@@ -76,12 +76,25 @@ NCURSES_BOOL _nc_is_file_path(
 int	_nc_env_access(void)
 		{ return(*(int *)0); }
 
+#undef _nc_safe_fopen
+FILE	*_nc_safe_fopen(
+		const char *path,
+		const char *mode)
+		{ return(*(FILE **)0); }
+
+#undef _nc_safe_open3
+int	_nc_safe_open3(
+		const char *path,
+		int	flags,
+		mode_t	mode)
+		{ return(*(int *)0); }
+
 /* ./tinfo/add_tries.c */
 
 #undef _nc_add_to_try
 int	_nc_add_to_try(
-		TRIES	**tree, 
-		const char *str, 
+		TRIES	**tree,
+		const char *str,
 		unsigned code)
 		{ return(*(int *)0); }
 
@@ -89,13 +102,13 @@ int	_nc_add_to_try(
 
 #undef _nc_align_termtype
 void	_nc_align_termtype(
-		TERMTYPE2 *to, 
-		TERMTYPE2 *from)
+		TERMTYPE *to,
+		TERMTYPE *from)
 		{ /* void */ }
 
 #undef _nc_copy_termtype
 void	_nc_copy_termtype(
-		TERMTYPE *dst, 
+		TERMTYPE *dst,
 		const TERMTYPE *src)
 		{ /* void */ }
 
@@ -160,19 +173,19 @@ void	_nc_get_type(
 
 #undef _nc_warning
 void	_nc_warning(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
 #undef _nc_err_abort
 void	_nc_err_abort(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
 #undef _nc_syserr_abort
 void	_nc_syserr_abort(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
@@ -180,14 +193,14 @@ void	_nc_syserr_abort(
 
 #undef _nc_find_entry
 struct name_table_entry const *_nc_find_entry(
-		const char *string, 
+		const char *string,
 		const HashValue *hash_table)
 		{ return(*(struct name_table_entry const **)0); }
 
 #undef _nc_find_type_entry
 struct name_table_entry const *_nc_find_type_entry(
-		const char *string, 
-		int	type, 
+		const char *string,
+		int	type,
 		NCURSES_BOOL termcap)
 		{ return(*(struct name_table_entry const **)0); }
 
@@ -224,13 +237,13 @@ void	_nc_last_db(void)
 
 #undef _nc_next_db
 const char *_nc_next_db(
-		DBDIRS	*state, 
+		DBDIRS	*state,
 		int	*offset)
 		{ return(*(const char **)0); }
 
 #undef _nc_first_db
 void	_nc_first_db(
-		DBDIRS	*state, 
+		DBDIRS	*state,
 		int	*offset)
 		{ /* void */ }
 
@@ -238,7 +251,7 @@ void	_nc_first_db(
 
 #undef _nc_doalloc
 void	*_nc_doalloc(
-		void	*oldp, 
+		void	*oldp,
 		size_t	amount)
 		{ return(*(void **)0); }
 
@@ -251,8 +264,8 @@ ENTRY	*_nc_tail;
 
 #undef _nc_free_entry
 void	_nc_free_entry(
-		ENTRY	*headp, 
-		TERMTYPE2 *tterm)
+		ENTRY	*headp,
+		TERMTYPE *tterm)
 		{ /* void */ }
 
 #undef _nc_free_entries
@@ -272,9 +285,9 @@ void	exit_terminfo(
 /* ./fallback.c */
 
 #undef _nc_fallback
-const TERMTYPE2 *_nc_fallback(
+const TERMTYPE *_nc_fallback(
 		const char *name)
-		{ return(*(const TERMTYPE2 **)0); }
+		{ return(*(const TERMTYPE **)0); }
 
 /* ./tinfo/free_ttype.c */
 
@@ -283,6 +296,11 @@ void	_nc_free_termtype(
 		TERMTYPE *ptr)
 		{ /* void */ }
 
+#undef _nc_free_termtype1
+void	_nc_free_termtype1(
+		TERMTYPE *ptr)
+		{ /* void */ }
+
 #undef _nc_user_definable
 NCURSES_BOOL _nc_user_definable;
 
@@ -300,7 +318,7 @@ int	_nc_getenv_num(
 
 #undef _nc_setenv_num
 void	_nc_setenv_num(
-		const char *name, 
+		const char *name,
 		int	value)
 		{ /* void */ }
 
@@ -334,8 +352,8 @@ void	_nc_init_acs(void)
 /* ./tinfo/lib_baudrate.c */
 
 struct speed {
-    int given_speed; 
-    int actual_speed; 
+    int given_speed;
+    int actual_speed;
 };
 
 #undef _nc_baudrate
@@ -364,7 +382,7 @@ TERMINAL *cur_term;
 
 #undef set_curterm_sp
 TERMINAL *set_curterm_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		TERMINAL *termp)
 		{ return(*(TERMINAL **)0); }
 
@@ -375,7 +393,7 @@ TERMINAL *set_curterm(
 
 #undef del_curterm_sp
 int	del_curterm_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		TERMINAL *termp)
 		{ return(*(int *)0); }
 
@@ -461,7 +479,7 @@ struct kn { short offset; int code; };
 
 #undef keyname_sp
 const char *keyname_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	c)
 		{ return(*(const char **)0); }
 
@@ -485,7 +503,7 @@ char	*longname(void)
 
 #undef napms_sp
 int	napms_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ms)
 		{ return(*(int *)0); }
 
@@ -498,19 +516,19 @@ int	napms(
 
 #undef idlok
 int	idlok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef idcok
 void	idcok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ /* void */ }
 
 #undef halfdelay_sp
 int	halfdelay_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	t)
 		{ return(*(int *)0); }
 
@@ -521,37 +539,37 @@ int	halfdelay(
 
 #undef nodelay
 int	nodelay(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef notimeout
 int	notimeout(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL f)
 		{ return(*(int *)0); }
 
 #undef wtimeout
 void	wtimeout(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	delay)
 		{ /* void */ }
 
 #undef keypad
 int	keypad(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef meta
 int	meta(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef curs_set_sp
 int	curs_set_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	vis)
 		{ return(*(int *)0); }
 
@@ -562,7 +580,7 @@ int	curs_set(
 
 #undef typeahead_sp
 int	typeahead_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	fd)
 		{ return(*(int *)0); }
 
@@ -573,7 +591,7 @@ int	typeahead(
 
 #undef has_key_sp
 int	has_key_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	keycode)
 		{ return(*(int *)0); }
 
@@ -584,14 +602,14 @@ int	has_key(
 
 #undef _nc_putp_flush_sp
 int	_nc_putp_flush_sp(
-		SCREEN	*sp, 
-		const char *name, 
+		SCREEN	*sp,
+		const char *name,
 		const char *value)
 		{ return(*(int *)0); }
 
 #undef _nc_keypad
 int	_nc_keypad(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	flag)
 		{ return(*(int *)0); }
 
@@ -653,17 +671,53 @@ void	noqiflush(void)
 
 #undef intrflush_sp
 int	intrflush_sp(
-		SCREEN	*sp, 
-		WINDOW	*win, 
+		SCREEN	*sp,
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef intrflush
 int	intrflush(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
+#undef is_nl_sp
+int	is_nl_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_raw_sp
+int	is_raw_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_cbreak_sp
+int	is_cbreak_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_echo_sp
+int	is_echo_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_nl
+int	is_nl(void)
+		{ return(*(int *)0); }
+
+#undef is_raw
+int	is_raw(void)
+		{ return(*(int *)0); }
+
+#undef is_cbreak
+int	is_cbreak(void)
+		{ return(*(int *)0); }
+
+#undef is_echo
+int	is_echo(void)
+		{ return(*(int *)0); }
+
 /* ./tinfo/lib_setup.c */
 
 #undef ttytype
@@ -677,7 +731,7 @@ int	TABSIZE;
 
 #undef set_tabsize_sp
 int	set_tabsize_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	value)
 		{ return(*(int *)0); }
 
@@ -693,13 +747,13 @@ int	_nc_handle_sigwinch(
 
 #undef use_env_sp
 void	use_env_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		NCURSES_BOOL f)
 		{ /* void */ }
 
 #undef use_tioctl_sp
 void	use_tioctl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		NCURSES_BOOL f)
 		{ /* void */ }
 
@@ -715,8 +769,8 @@ void	use_tioctl(
 
 #undef _nc_get_screensize
 void	_nc_get_screensize(
-		SCREEN	*sp, 
-		int	*linep, 
+		SCREEN	*sp,
+		int	*linep,
 		int	*colp)
 		{ /* void */ }
 
@@ -727,13 +781,13 @@ void	_nc_update_screensize(
 
 #undef _nc_setup_tinfo
 int	_nc_setup_tinfo(
-		const char *const tn, 
-		TERMTYPE2 *const tp)
+		const char *const tn,
+		TERMTYPE *const tp)
 		{ return(*(int *)0); }
 
 #undef _nc_tinfo_cmdch
 void	_nc_tinfo_cmdch(
-		TERMINAL *termp, 
+		TERMINAL *termp,
 		int	proto)
 		{ /* void */ }
 
@@ -752,9 +806,9 @@ int	_nc_locale_breaks_acs(
 
 #undef _nc_setupterm
 int	_nc_setupterm(
-		const char *tname, 
-		int	Filedes, 
-		int	*errret, 
+		const char *tname,
+		int	Filedes,
+		int	*errret,
 		int	reuse)
 		{ return(*(int *)0); }
 
@@ -764,8 +818,8 @@ SCREEN	*new_prescr(void)
 
 #undef setupterm
 int	setupterm(
-		const char *tname, 
-		int	Filedes, 
+		const char *tname,
+		int	Filedes,
 		int	*errret)
 		{ return(*(int *)0); }
 
@@ -778,20 +832,20 @@ char	*BC;
 
 #undef tgetent_sp
 int	tgetent_sp(
-		SCREEN	*sp, 
-		char	*bufp, 
+		SCREEN	*sp,
+		char	*bufp,
 		const char *name)
 		{ return(*(int *)0); }
 
 #undef tgetent
 int	tgetent(
-		char	*bufp, 
+		char	*bufp,
 		const char *name)
 		{ return(*(int *)0); }
 
 #undef tgetflag_sp
 int	tgetflag_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *id)
 		{ return(*(int *)0); }
 
@@ -802,7 +856,7 @@ int	tgetflag(
 
 #undef tgetnum_sp
 int	tgetnum_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *id)
 		{ return(*(int *)0); }
 
@@ -813,14 +867,14 @@ int	tgetnum(
 
 #undef tgetstr_sp
 char	*tgetstr_sp(
-		SCREEN	*sp, 
-		const char *id, 
+		SCREEN	*sp,
+		const char *id,
 		char	**area)
 		{ return(*(char **)0); }
 
 #undef tgetstr
 char	*tgetstr(
-		const char *id, 
+		const char *id,
 		char	**area)
 		{ return(*(char **)0); }
 
@@ -839,8 +893,8 @@ char	*termname(void)
 
 #undef tgoto
 char	*tgoto(
-		const char *string, 
-		int	x, 
+		const char *string,
+		int	x,
 		int	y)
 		{ return(*(char **)0); }
 
@@ -848,7 +902,7 @@ char	*tgoto(
 
 #undef tigetflag_sp
 int	tigetflag_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -859,7 +913,7 @@ int	tigetflag(
 
 #undef tigetnum_sp
 int	tigetnum_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -870,7 +924,7 @@ int	tigetnum(
 
 #undef tigetstr_sp
 char	*tigetstr_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(char **)0); }
 
@@ -884,32 +938,58 @@ char	*tigetstr(
 #undef _nc_tparm_err
 int	_nc_tparm_err;
 
+#undef _nc_free_tparm
+void	_nc_free_tparm(
+		TERMINAL *termp)
+		{ /* void */ }
+
 #undef _nc_tparm_analyze
 int	_nc_tparm_analyze(
-		const char *string, 
-		char	*p_is_s[9], 
+		TERMINAL *term,
+		const char *string,
+		char	**p_is_s,
 		int	*_nc_popcount)
 		{ return(*(int *)0); }
 
 #undef tparm
 char	*tparm(
-		const char *string, 
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
 #undef tiparm
 char	*tiparm(
-		const char *string, 
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
+#undef tiparm_s
+char	*tiparm_s(
+		int	num_expected,
+		int	tparm_type,
+		const char *string,
+		...)
+		{ return(*(char **)0); }
+
+#undef tiscan_s
+int	tiscan_s(
+		int	*num_expected,
+		int	*tparm_type,
+		const char *string)
+		{ return(*(int *)0); }
+
 #undef _nc_tiparm
 char	*_nc_tiparm(
-		int	expected, 
-		const char *string, 
+		int	expected,
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
+#undef _nc_reset_tparm
+void	_nc_reset_tparm(
+		TERMINAL *term)
+		{ /* void */ }
+
 /* ./tinfo/lib_tputs.c */
 
 #undef PC
@@ -926,7 +1006,7 @@ void	_nc_set_no_padding(
 
 #undef delay_output_sp
 int	delay_output_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ms)
 		{ return(*(int *)0); }
 
@@ -946,7 +1026,7 @@ void	_nc_flush(void)
 
 #undef _nc_outch_sp
 int	_nc_outch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -957,7 +1037,7 @@ int	_nc_outch(
 
 #undef _nc_putchar_sp
 int	_nc_putchar_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -968,7 +1048,7 @@ int	_nc_putchar(
 
 #undef putp_sp
 int	putp_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *string)
 		{ return(*(int *)0); }
 
@@ -979,35 +1059,35 @@ int	putp(
 
 #undef _nc_putp_sp
 int	_nc_putp_sp(
-		SCREEN	*sp, 
-		const char *name, 
+		SCREEN	*sp,
+		const char *name,
 		const char *string)
 		{ return(*(int *)0); }
 
 #undef _nc_putp
 int	_nc_putp(
-		const char *name, 
+		const char *name,
 		const char *string)
 		{ return(*(int *)0); }
 
 #undef tputs_sp
 int	tputs_sp(
-		SCREEN	*sp, 
-		const char *string, 
-		int	affcnt, 
+		SCREEN	*sp,
+		const char *string,
+		int	affcnt,
 		NCURSES_OUTC_sp outc)
 		{ return(*(int *)0); }
 
 #undef _nc_outc_wrapper
 int	_nc_outc_wrapper(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	c)
 		{ return(*(int *)0); }
 
 #undef tputs
 int	tputs(
-		const char *string, 
-		int	affcnt, 
+		const char *string,
+		int	affcnt,
 		int	(*outc)(
 		int	p1))
 		{ return(*(int *)0); }
@@ -1033,7 +1113,7 @@ void	trace(
 
 #undef _tracef
 void	_tracef(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ /* void */ }
 
@@ -1089,8 +1169,8 @@ WINDOW	*_nc_retrace_win(
 
 #undef _nc_fmt_funcptr
 char	*_nc_fmt_funcptr(
-		char	*target, 
-		const char *source, 
+		char	*target,
+		const char *source,
 		size_t	size)
 		{ return(*(char **)0); }
 
@@ -1098,7 +1178,7 @@ char	*_nc_fmt_funcptr(
 
 #undef _traceattr2
 char	*_traceattr2(
-		int	bufnum, 
+		int	bufnum,
 		chtype	newmode)
 		{ return(*(char **)0); }
 
@@ -1119,13 +1199,13 @@ attr_t	_nc_retrace_attr_t(
 
 #undef _nc_altcharset_name
 const char *_nc_altcharset_name(
-		attr_t	attr, 
+		attr_t	attr,
 		chtype	ch)
 		{ return(*(const char **)0); }
 
 #undef _tracechtype2
 char	*_tracechtype2(
-		int	bufnum, 
+		int	bufnum,
 		chtype	ch)
 		{ return(*(char **)0); }
 
@@ -1143,7 +1223,7 @@ chtype	_nc_retrace_chtype(
 
 #undef _nc_trace_ttymode
 char	*_nc_trace_ttymode(
-		struct termios *tty)
+		const struct termios *tty)
 		{ return(*(char **)0); }
 
 #undef _nc_tracebits
@@ -1154,7 +1234,7 @@ char	*_nc_tracebits(void)
 
 #undef _nc_tracechar
 char	*_nc_tracechar(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(char **)0); }
 
@@ -1167,7 +1247,7 @@ char	*_tracechar(
 
 #undef _nc_get_tty_mode_sp
 int	_nc_get_tty_mode_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		struct termios *buf)
 		{ return(*(int *)0); }
 
@@ -1178,7 +1258,7 @@ int	_nc_get_tty_mode(
 
 #undef _nc_set_tty_mode_sp
 int	_nc_set_tty_mode_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		struct termios *buf)
 		{ return(*(int *)0); }
 
@@ -1245,9 +1325,9 @@ int	resetty(void)
 
 #undef _nc_timed_wait
 int	_nc_timed_wait(
-		SCREEN	*sp, 
-		int	mode, 
-		int	milliseconds, 
+		SCREEN	*sp,
+		int	mode,
+		int	milliseconds,
 		int	*timeleft)
 		{ return(*(int *)0); }
 
@@ -1260,8 +1340,8 @@ char	*_nc_first_name(
 
 #undef _nc_name_match
 int	_nc_name_match(
-		const char *const namelst, 
-		const char *const name, 
+		const char *const namelst,
+		const char *const name,
 		const char *const delim)
 		{ return(*(int *)0); }
 
@@ -1284,14 +1364,14 @@ const char *const strfnames[] = {0};
 
 #undef _nc_set_buffer_sp
 void	_nc_set_buffer_sp(
-		SCREEN	*sp, 
-		FILE	*ofp, 
+		SCREEN	*sp,
+		FILE	*ofp,
 		int	buffered)
 		{ /* void */ }
 
 #undef _nc_set_buffer
 void	_nc_set_buffer(
-		FILE	*ofp, 
+		FILE	*ofp,
 		int	buffered)
 		{ /* void */ }
 
@@ -1299,27 +1379,27 @@ void	_nc_set_buffer(
 
 #undef _nc_init_termtype
 void	_nc_init_termtype(
-		TERMTYPE2 *const tp)
+		TERMTYPE *const tp)
 		{ /* void */ }
 
 #undef _nc_read_termtype
 int	_nc_read_termtype(
-		TERMTYPE2 *ptr, 
-		char	*buffer, 
+		TERMTYPE *ptr,
+		char	*buffer,
 		int	limit)
 		{ return(*(int *)0); }
 
 #undef _nc_read_file_entry
 int	_nc_read_file_entry(
-		const char *const filename, 
-		TERMTYPE2 *ptr)
+		const char *const filename,
+		TERMTYPE *ptr)
 		{ return(*(int *)0); }
 
 #undef _nc_read_entry
 int	_nc_read_entry(
-		const char *const name, 
-		char	*const filename, 
-		TERMTYPE2 *const tp)
+		const char *const name,
+		char	*const filename,
+		TERMTYPE *const tp)
 		{ return(*(int *)0); }
 
 /* ./tinfo/read_termcap.c */
@@ -1332,32 +1412,32 @@ void	_nc_read_termcap(void)
 
 #undef _nc_str_init
 string_desc *_nc_str_init(
-		string_desc *dst, 
-		char	*src, 
+		string_desc *dst,
+		char	*src,
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_null
 string_desc *_nc_str_null(
-		string_desc *dst, 
+		string_desc *dst,
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_copy
 string_desc *_nc_str_copy(
-		string_desc *dst, 
-		string_desc *src)
+		string_desc *dst,
+		const string_desc *const src)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_safe_strcat
 NCURSES_BOOL _nc_safe_strcat(
-		string_desc *dst, 
+		string_desc *dst,
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_safe_strcpy
 NCURSES_BOOL _nc_safe_strcpy(
-		string_desc *dst, 
+		string_desc *dst,
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -1365,13 +1445,13 @@ NCURSES_BOOL _nc_safe_strcpy(
 
 #undef _nc_trace_buf
 char	*_nc_trace_buf(
-		int	bufnum, 
+		int	bufnum,
 		size_t	want)
 		{ return(*(char **)0); }
 
 #undef _nc_trace_bufcat
 char	*_nc_trace_bufcat(
-		int	bufnum, 
+		int	bufnum,
 		const char *value)
 		{ return(*(char **)0); }
 
@@ -1386,21 +1466,21 @@ void	_nc_trace_tries(
 
 #undef _nc_expand_try
 char	*_nc_expand_try(
-		TRIES	*tree, 
-		unsigned code, 
-		int	*count, 
+		TRIES	*tree,
+		unsigned code,
+		int	*count,
 		size_t	len)
 		{ return(*(char **)0); }
 
 #undef _nc_remove_key
 int	_nc_remove_key(
-		TRIES	**tree, 
+		TRIES	**tree,
 		unsigned code)
 		{ return(*(int *)0); }
 
 #undef _nc_remove_string
 int	_nc_remove_string(
-		TRIES	**tree, 
+		TRIES	**tree,
 		const char *string)
 		{ return(*(int *)0); }
 
@@ -1408,14 +1488,14 @@ int	_nc_remove_string(
 
 #undef _nc_trim_sgr0
 char	*_nc_trim_sgr0(
-		TERMTYPE2 *tp)
+		TERMTYPE *tp)
 		{ return(*(char **)0); }
 
 /* ./unctrl.c */
 
 #undef unctrl_sp
 const char *unctrl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		chtype	ch)
 		{ return(*(const char **)0); }
 
@@ -1428,7 +1508,7 @@ const char *unctrl(
 
 #undef _nc_visbuf2
 const char *_nc_visbuf2(
-		int	bufnum, 
+		int	bufnum,
 		const char *buf)
 		{ return(*(const char **)0); }
 
@@ -1439,20 +1519,20 @@ const char *_nc_visbuf(
 
 #undef _nc_visbufn
 const char *_nc_visbufn(
-		const char *buf, 
+		const char *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
 #undef _nc_viscbuf2
 const char *_nc_viscbuf2(
-		int	bufnum, 
-		const chtype *buf, 
+		int	bufnum,
+		const chtype *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
 #undef _nc_viscbuf
 const char *_nc_viscbuf(
-		const chtype *buf, 
+		const chtype *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
@@ -1460,14 +1540,14 @@ const char *_nc_viscbuf(
 
 #undef define_key_sp
 int	define_key_sp(
-		SCREEN	*sp, 
-		const char *str, 
+		SCREEN	*sp,
+		const char *str,
 		int	keycode)
 		{ return(*(int *)0); }
 
 #undef define_key
 int	define_key(
-		const char *str, 
+		const char *str,
 		int	keycode)
 		{ return(*(int *)0); }
 
@@ -1481,7 +1561,7 @@ void	_nc_hashed_db(void)
 
 #undef key_defined_sp
 int	key_defined_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -1494,14 +1574,14 @@ int	key_defined(
 
 #undef keybound_sp
 char	*keybound_sp(
-		SCREEN	*sp, 
-		int	code, 
+		SCREEN	*sp,
+		int	code,
 		int	count)
 		{ return(*(char **)0); }
 
 #undef keybound
 char	*keybound(
-		int	code, 
+		int	code,
 		int	count)
 		{ return(*(char **)0); }
 
@@ -1509,14 +1589,14 @@ char	*keybound(
 
 #undef keyok_sp
 int	keyok_sp(
-		SCREEN	*sp, 
-		int	c, 
+		SCREEN	*sp,
+		int	c,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef keyok
 int	keyok(
-		int	c, 
+		int	c,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
diff --git a/contrib/ncurses/ncurses/llib-ltinfot b/contrib/ncurses/ncurses/llib-ltinfot
index 18780beb96b1..94ca9a7f0272 100644
--- a/contrib/ncurses/ncurses/llib-ltinfot
+++ b/contrib/ncurses/ncurses/llib-ltinfot
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 2019-2022,2023 Thomas E. Dickey                                *
  * Copyright 2013-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -58,7 +58,7 @@ char	*_nc_basename(
 
 #undef _nc_access
 int	_nc_access(
-		const char *path, 
+		const char *path,
 		int	mode)
 		{ return(*(int *)0); }
 
@@ -76,12 +76,25 @@ NCURSES_BOOL _nc_is_file_path(
 int	_nc_env_access(void)
 		{ return(*(int *)0); }
 
+#undef _nc_safe_fopen
+FILE	*_nc_safe_fopen(
+		const char *path,
+		const char *mode)
+		{ return(*(FILE **)0); }
+
+#undef _nc_safe_open3
+int	_nc_safe_open3(
+		const char *path,
+		int	flags,
+		mode_t	mode)
+		{ return(*(int *)0); }
+
 /* ./tinfo/add_tries.c */
 
 #undef _nc_add_to_try
 int	_nc_add_to_try(
-		TRIES	**tree, 
-		const char *str, 
+		TRIES	**tree,
+		const char *str,
 		unsigned code)
 		{ return(*(int *)0); }
 
@@ -89,13 +102,13 @@ int	_nc_add_to_try(
 
 #undef _nc_align_termtype
 void	_nc_align_termtype(
-		TERMTYPE2 *to, 
-		TERMTYPE2 *from)
+		TERMTYPE *to,
+		TERMTYPE *from)
 		{ /* void */ }
 
 #undef _nc_copy_termtype
 void	_nc_copy_termtype(
-		TERMTYPE *dst, 
+		TERMTYPE *dst,
 		const TERMTYPE *src)
 		{ /* void */ }
 
@@ -165,19 +178,19 @@ void	_nc_get_type(
 
 #undef _nc_warning
 void	_nc_warning(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
 #undef _nc_err_abort
 void	_nc_err_abort(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
 #undef _nc_syserr_abort
 void	_nc_syserr_abort(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
@@ -185,14 +198,14 @@ void	_nc_syserr_abort(
 
 #undef _nc_find_entry
 struct name_table_entry const *_nc_find_entry(
-		const char *string, 
+		const char *string,
 		const HashValue *hash_table)
 		{ return(*(struct name_table_entry const **)0); }
 
 #undef _nc_find_type_entry
 struct name_table_entry const *_nc_find_type_entry(
-		const char *string, 
-		int	type, 
+		const char *string,
+		int	type,
 		NCURSES_BOOL termcap)
 		{ return(*(struct name_table_entry const **)0); }
 
@@ -229,13 +242,13 @@ void	_nc_last_db(void)
 
 #undef _nc_next_db
 const char *_nc_next_db(
-		DBDIRS	*state, 
+		DBDIRS	*state,
 		int	*offset)
 		{ return(*(const char **)0); }
 
 #undef _nc_first_db
 void	_nc_first_db(
-		DBDIRS	*state, 
+		DBDIRS	*state,
 		int	*offset)
 		{ /* void */ }
 
@@ -243,7 +256,7 @@ void	_nc_first_db(
 
 #undef _nc_doalloc
 void	*_nc_doalloc(
-		void	*oldp, 
+		void	*oldp,
 		size_t	amount)
 		{ return(*(void **)0); }
 
@@ -256,8 +269,8 @@ ENTRY	*_nc_tail;
 
 #undef _nc_free_entry
 void	_nc_free_entry(
-		ENTRY	*headp, 
-		TERMTYPE2 *tterm)
+		ENTRY	*headp,
+		TERMTYPE *tterm)
 		{ /* void */ }
 
 #undef _nc_free_entries
@@ -277,9 +290,9 @@ void	exit_terminfo(
 /* ./fallback.c */
 
 #undef _nc_fallback
-const TERMTYPE2 *_nc_fallback(
+const TERMTYPE *_nc_fallback(
 		const char *name)
-		{ return(*(const TERMTYPE2 **)0); }
+		{ return(*(const TERMTYPE **)0); }
 
 /* ./tinfo/free_ttype.c */
 
@@ -288,6 +301,11 @@ void	_nc_free_termtype(
 		TERMTYPE *ptr)
 		{ /* void */ }
 
+#undef _nc_free_termtype1
+void	_nc_free_termtype1(
+		TERMTYPE *ptr)
+		{ /* void */ }
+
 #undef _nc_user_definable
 NCURSES_BOOL _nc_user_definable;
 
@@ -305,7 +323,7 @@ int	_nc_getenv_num(
 
 #undef _nc_setenv_num
 void	_nc_setenv_num(
-		const char *name, 
+		const char *name,
 		int	value)
 		{ /* void */ }
 
@@ -340,8 +358,8 @@ void	_nc_init_acs(void)
 /* ./tinfo/lib_baudrate.c */
 
 struct speed {
-    int given_speed; 
-    int actual_speed; 
+    int given_speed;
+    int actual_speed;
 };
 
 #undef _nc_baudrate
@@ -380,7 +398,7 @@ TERMINAL *_nc_cur_term(void)
 
 #undef set_curterm_sp
 TERMINAL *set_curterm_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		TERMINAL *termp)
 		{ return(*(TERMINAL **)0); }
 
@@ -391,7 +409,7 @@ TERMINAL *set_curterm(
 
 #undef del_curterm_sp
 int	del_curterm_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		TERMINAL *termp)
 		{ return(*(int *)0); }
 
@@ -507,7 +525,7 @@ struct kn { short offset; int code; };
 
 #undef keyname_sp
 const char *keyname_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	c)
 		{ return(*(const char **)0); }
 
@@ -531,7 +549,7 @@ char	*longname(void)
 
 #undef napms_sp
 int	napms_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ms)
 		{ return(*(int *)0); }
 
@@ -544,19 +562,19 @@ int	napms(
 
 #undef idlok
 int	idlok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef idcok
 void	idcok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ /* void */ }
 
 #undef halfdelay_sp
 int	halfdelay_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	t)
 		{ return(*(int *)0); }
 
@@ -567,37 +585,37 @@ int	halfdelay(
 
 #undef nodelay
 int	nodelay(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef notimeout
 int	notimeout(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL f)
 		{ return(*(int *)0); }
 
 #undef wtimeout
 void	wtimeout(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	delay)
 		{ /* void */ }
 
 #undef keypad
 int	keypad(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef meta
 int	meta(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef curs_set_sp
 int	curs_set_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	vis)
 		{ return(*(int *)0); }
 
@@ -608,7 +626,7 @@ int	curs_set(
 
 #undef typeahead_sp
 int	typeahead_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	fd)
 		{ return(*(int *)0); }
 
@@ -619,7 +637,7 @@ int	typeahead(
 
 #undef has_key_sp
 int	has_key_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	keycode)
 		{ return(*(int *)0); }
 
@@ -630,14 +648,14 @@ int	has_key(
 
 #undef _nc_putp_flush_sp
 int	_nc_putp_flush_sp(
-		SCREEN	*sp, 
-		const char *name, 
+		SCREEN	*sp,
+		const char *name,
 		const char *value)
 		{ return(*(int *)0); }
 
 #undef _nc_keypad
 int	_nc_keypad(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	flag)
 		{ return(*(int *)0); }
 
@@ -699,17 +717,53 @@ void	noqiflush(void)
 
 #undef intrflush_sp
 int	intrflush_sp(
-		SCREEN	*sp, 
-		WINDOW	*win, 
+		SCREEN	*sp,
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef intrflush
 int	intrflush(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
+#undef is_nl_sp
+int	is_nl_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_raw_sp
+int	is_raw_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_cbreak_sp
+int	is_cbreak_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_echo_sp
+int	is_echo_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_nl
+int	is_nl(void)
+		{ return(*(int *)0); }
+
+#undef is_raw
+int	is_raw(void)
+		{ return(*(int *)0); }
+
+#undef is_cbreak
+int	is_cbreak(void)
+		{ return(*(int *)0); }
+
+#undef is_echo
+int	is_echo(void)
+		{ return(*(int *)0); }
+
 /* ./tinfo/lib_setup.c */
 
 #undef _nc_ttytype
@@ -745,7 +799,7 @@ int	_nc_TABSIZE(void)
 
 #undef set_tabsize_sp
 int	set_tabsize_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	value)
 		{ return(*(int *)0); }
 
@@ -761,13 +815,13 @@ int	_nc_handle_sigwinch(
 
 #undef use_env_sp
 void	use_env_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		NCURSES_BOOL f)
 		{ /* void */ }
 
 #undef use_tioctl_sp
 void	use_tioctl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		NCURSES_BOOL f)
 		{ /* void */ }
 
@@ -783,8 +837,8 @@ void	use_tioctl(
 
 #undef _nc_get_screensize
 void	_nc_get_screensize(
-		SCREEN	*sp, 
-		int	*linep, 
+		SCREEN	*sp,
+		int	*linep,
 		int	*colp)
 		{ /* void */ }
 
@@ -795,13 +849,13 @@ void	_nc_update_screensize(
 
 #undef _nc_setup_tinfo
 int	_nc_setup_tinfo(
-		const char *const tn, 
-		TERMTYPE2 *const tp)
+		const char *const tn,
+		TERMTYPE *const tp)
 		{ return(*(int *)0); }
 
 #undef _nc_tinfo_cmdch
 void	_nc_tinfo_cmdch(
-		TERMINAL *termp, 
+		TERMINAL *termp,
 		int	proto)
 		{ /* void */ }
 
@@ -820,9 +874,9 @@ int	_nc_locale_breaks_acs(
 
 #undef _nc_setupterm
 int	_nc_setupterm(
-		const char *tname, 
-		int	Filedes, 
-		int	*errret, 
+		const char *tname,
+		int	Filedes,
+		int	*errret,
 		int	reuse)
 		{ return(*(int *)0); }
 
@@ -840,8 +894,8 @@ SCREEN	*new_prescr(void)
 
 #undef setupterm
 int	setupterm(
-		const char *tname, 
-		int	Filedes, 
+		const char *tname,
+		int	Filedes,
 		int	*errret)
 		{ return(*(int *)0); }
 
@@ -854,20 +908,20 @@ char	*BC;
 
 #undef tgetent_sp
 int	tgetent_sp(
-		SCREEN	*sp, 
-		char	*bufp, 
+		SCREEN	*sp,
+		char	*bufp,
 		const char *name)
 		{ return(*(int *)0); }
 
 #undef tgetent
 int	tgetent(
-		char	*bufp, 
+		char	*bufp,
 		const char *name)
 		{ return(*(int *)0); }
 
 #undef tgetflag_sp
 int	tgetflag_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *id)
 		{ return(*(int *)0); }
 
@@ -878,7 +932,7 @@ int	tgetflag(
 
 #undef tgetnum_sp
 int	tgetnum_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *id)
 		{ return(*(int *)0); }
 
@@ -889,14 +943,14 @@ int	tgetnum(
 
 #undef tgetstr_sp
 char	*tgetstr_sp(
-		SCREEN	*sp, 
-		const char *id, 
+		SCREEN	*sp,
+		const char *id,
 		char	**area)
 		{ return(*(char **)0); }
 
 #undef tgetstr
 char	*tgetstr(
-		const char *id, 
+		const char *id,
 		char	**area)
 		{ return(*(char **)0); }
 
@@ -915,8 +969,8 @@ char	*termname(void)
 
 #undef tgoto
 char	*tgoto(
-		const char *string, 
-		int	x, 
+		const char *string,
+		int	x,
 		int	y)
 		{ return(*(char **)0); }
 
@@ -924,7 +978,7 @@ char	*tgoto(
 
 #undef tigetflag_sp
 int	tigetflag_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -935,7 +989,7 @@ int	tigetflag(
 
 #undef tigetnum_sp
 int	tigetnum_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -946,7 +1000,7 @@ int	tigetnum(
 
 #undef tigetstr_sp
 char	*tigetstr_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(char **)0); }
 
@@ -960,32 +1014,58 @@ char	*tigetstr(
 #undef _nc_tparm_err
 int	_nc_tparm_err;
 
+#undef _nc_free_tparm
+void	_nc_free_tparm(
+		TERMINAL *termp)
+		{ /* void */ }
+
 #undef _nc_tparm_analyze
 int	_nc_tparm_analyze(
-		const char *string, 
-		char	*p_is_s[9], 
+		TERMINAL *term,
+		const char *string,
+		char	**p_is_s,
 		int	*_nc_popcount)
 		{ return(*(int *)0); }
 
 #undef tparm
 char	*tparm(
-		const char *string, 
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
 #undef tiparm
 char	*tiparm(
-		const char *string, 
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
+#undef tiparm_s
+char	*tiparm_s(
+		int	num_expected,
+		int	tparm_type,
+		const char *string,
+		...)
+		{ return(*(char **)0); }
+
+#undef tiscan_s
+int	tiscan_s(
+		int	*num_expected,
+		int	*tparm_type,
+		const char *string)
+		{ return(*(int *)0); }
+
 #undef _nc_tiparm
 char	*_nc_tiparm(
-		int	expected, 
-		const char *string, 
+		int	expected,
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
+#undef _nc_reset_tparm
+void	_nc_reset_tparm(
+		TERMINAL *term)
+		{ /* void */ }
+
 /* ./tinfo/lib_tputs.c */
 
 #undef PC
@@ -1002,7 +1082,7 @@ void	_nc_set_no_padding(
 
 #undef delay_output_sp
 int	delay_output_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ms)
 		{ return(*(int *)0); }
 
@@ -1022,7 +1102,7 @@ void	_nc_flush(void)
 
 #undef _nc_outch_sp
 int	_nc_outch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -1033,7 +1113,7 @@ int	_nc_outch(
 
 #undef _nc_putchar_sp
 int	_nc_putchar_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -1044,7 +1124,7 @@ int	_nc_putchar(
 
 #undef putp_sp
 int	putp_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *string)
 		{ return(*(int *)0); }
 
@@ -1055,35 +1135,35 @@ int	putp(
 
 #undef _nc_putp_sp
 int	_nc_putp_sp(
-		SCREEN	*sp, 
-		const char *name, 
+		SCREEN	*sp,
+		const char *name,
 		const char *string)
 		{ return(*(int *)0); }
 
 #undef _nc_putp
 int	_nc_putp(
-		const char *name, 
+		const char *name,
 		const char *string)
 		{ return(*(int *)0); }
 
 #undef tputs_sp
 int	tputs_sp(
-		SCREEN	*sp, 
-		const char *string, 
-		int	affcnt, 
+		SCREEN	*sp,
+		const char *string,
+		int	affcnt,
 		NCURSES_OUTC_sp outc)
 		{ return(*(int *)0); }
 
 #undef _nc_outc_wrapper
 int	_nc_outc_wrapper(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	c)
 		{ return(*(int *)0); }
 
 #undef tputs
 int	tputs(
-		const char *string, 
-		int	affcnt, 
+		const char *string,
+		int	affcnt,
 		int	(*outc)(
 		int	p1))
 		{ return(*(int *)0); }
@@ -1123,7 +1203,7 @@ void	trace(
 
 #undef _tracef
 void	_tracef(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ /* void */ }
 
@@ -1179,8 +1259,8 @@ WINDOW	*_nc_retrace_win(
 
 #undef _nc_fmt_funcptr
 char	*_nc_fmt_funcptr(
-		char	*target, 
-		const char *source, 
+		char	*target,
+		const char *source,
 		size_t	size)
 		{ return(*(char **)0); }
 
@@ -1191,7 +1271,7 @@ int	_nc_use_tracef(
 
 #undef _nc_locked_tracef
 void	_nc_locked_tracef(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ /* void */ }
 
@@ -1199,7 +1279,7 @@ void	_nc_locked_tracef(
 
 #undef _traceattr2
 char	*_traceattr2(
-		int	bufnum, 
+		int	bufnum,
 		chtype	newmode)
 		{ return(*(char **)0); }
 
@@ -1220,13 +1300,13 @@ attr_t	_nc_retrace_attr_t(
 
 #undef _nc_altcharset_name
 const char *_nc_altcharset_name(
-		attr_t	attr, 
+		attr_t	attr,
 		chtype	ch)
 		{ return(*(const char **)0); }
 
 #undef _tracechtype2
 char	*_tracechtype2(
-		int	bufnum, 
+		int	bufnum,
 		chtype	ch)
 		{ return(*(char **)0); }
 
@@ -1244,7 +1324,7 @@ chtype	_nc_retrace_chtype(
 
 #undef _nc_trace_ttymode
 char	*_nc_trace_ttymode(
-		struct termios *tty)
+		const struct termios *tty)
 		{ return(*(char **)0); }
 
 #undef _nc_tracebits
@@ -1255,7 +1335,7 @@ char	*_nc_tracebits(void)
 
 #undef _nc_tracechar
 char	*_nc_tracechar(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(char **)0); }
 
@@ -1268,7 +1348,7 @@ char	*_tracechar(
 
 #undef _nc_get_tty_mode_sp
 int	_nc_get_tty_mode_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		struct termios *buf)
 		{ return(*(int *)0); }
 
@@ -1279,7 +1359,7 @@ int	_nc_get_tty_mode(
 
 #undef _nc_set_tty_mode_sp
 int	_nc_set_tty_mode_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		struct termios *buf)
 		{ return(*(int *)0); }
 
@@ -1346,9 +1426,9 @@ int	resetty(void)
 
 #undef _nc_timed_wait
 int	_nc_timed_wait(
-		SCREEN	*sp, 
-		int	mode, 
-		int	milliseconds, 
+		SCREEN	*sp,
+		int	mode,
+		int	milliseconds,
 		int	*timeleft)
 		{ return(*(int *)0); }
 
@@ -1361,8 +1441,8 @@ char	*_nc_first_name(
 
 #undef _nc_name_match
 int	_nc_name_match(
-		const char *const namelst, 
-		const char *const name, 
+		const char *const namelst,
+		const char *const name,
 		const char *const delim)
 		{ return(*(int *)0); }
 
@@ -1396,14 +1476,14 @@ const char *const *_nc_strfnames(void)
 
 #undef _nc_set_buffer_sp
 void	_nc_set_buffer_sp(
-		SCREEN	*sp, 
-		FILE	*ofp, 
+		SCREEN	*sp,
+		FILE	*ofp,
 		int	buffered)
 		{ /* void */ }
 
 #undef _nc_set_buffer
 void	_nc_set_buffer(
-		FILE	*ofp, 
+		FILE	*ofp,
 		int	buffered)
 		{ /* void */ }
 
@@ -1411,27 +1491,27 @@ void	_nc_set_buffer(
 
 #undef _nc_init_termtype
 void	_nc_init_termtype(
-		TERMTYPE2 *const tp)
+		TERMTYPE *const tp)
 		{ /* void */ }
 
 #undef _nc_read_termtype
 int	_nc_read_termtype(
-		TERMTYPE2 *ptr, 
-		char	*buffer, 
+		TERMTYPE *ptr,
+		char	*buffer,
 		int	limit)
 		{ return(*(int *)0); }
 
 #undef _nc_read_file_entry
 int	_nc_read_file_entry(
-		const char *const filename, 
-		TERMTYPE2 *ptr)
+		const char *const filename,
+		TERMTYPE *ptr)
 		{ return(*(int *)0); }
 
 #undef _nc_read_entry
 int	_nc_read_entry(
-		const char *const name, 
-		char	*const filename, 
-		TERMTYPE2 *const tp)
+		const char *const name,
+		char	*const filename,
+		TERMTYPE *const tp)
 		{ return(*(int *)0); }
 
 /* ./tinfo/read_termcap.c */
@@ -1444,32 +1524,32 @@ void	_nc_read_termcap(void)
 
 #undef _nc_str_init
 string_desc *_nc_str_init(
-		string_desc *dst, 
-		char	*src, 
+		string_desc *dst,
+		char	*src,
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_null
 string_desc *_nc_str_null(
-		string_desc *dst, 
+		string_desc *dst,
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_copy
 string_desc *_nc_str_copy(
-		string_desc *dst, 
-		string_desc *src)
+		string_desc *dst,
+		const string_desc *const src)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_safe_strcat
 NCURSES_BOOL _nc_safe_strcat(
-		string_desc *dst, 
+		string_desc *dst,
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_safe_strcpy
 NCURSES_BOOL _nc_safe_strcpy(
-		string_desc *dst, 
+		string_desc *dst,
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -1477,13 +1557,13 @@ NCURSES_BOOL _nc_safe_strcpy(
 
 #undef _nc_trace_buf
 char	*_nc_trace_buf(
-		int	bufnum, 
+		int	bufnum,
 		size_t	want)
 		{ return(*(char **)0); }
 
 #undef _nc_trace_bufcat
 char	*_nc_trace_bufcat(
-		int	bufnum, 
+		int	bufnum,
 		const char *value)
 		{ return(*(char **)0); }
 
@@ -1498,21 +1578,21 @@ void	_nc_trace_tries(
 
 #undef _nc_expand_try
 char	*_nc_expand_try(
-		TRIES	*tree, 
-		unsigned code, 
-		int	*count, 
+		TRIES	*tree,
+		unsigned code,
+		int	*count,
 		size_t	len)
 		{ return(*(char **)0); }
 
 #undef _nc_remove_key
 int	_nc_remove_key(
-		TRIES	**tree, 
+		TRIES	**tree,
 		unsigned code)
 		{ return(*(int *)0); }
 
 #undef _nc_remove_string
 int	_nc_remove_string(
-		TRIES	**tree, 
+		TRIES	**tree,
 		const char *string)
 		{ return(*(int *)0); }
 
@@ -1520,14 +1600,14 @@ int	_nc_remove_string(
 
 #undef _nc_trim_sgr0
 char	*_nc_trim_sgr0(
-		TERMTYPE2 *tp)
+		TERMTYPE *tp)
 		{ return(*(char **)0); }
 
 /* ./unctrl.c */
 
 #undef unctrl_sp
 const char *unctrl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		chtype	ch)
 		{ return(*(const char **)0); }
 
@@ -1540,7 +1620,7 @@ const char *unctrl(
 
 #undef _nc_visbuf2
 const char *_nc_visbuf2(
-		int	bufnum, 
+		int	bufnum,
 		const char *buf)
 		{ return(*(const char **)0); }
 
@@ -1551,20 +1631,20 @@ const char *_nc_visbuf(
 
 #undef _nc_visbufn
 const char *_nc_visbufn(
-		const char *buf, 
+		const char *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
 #undef _nc_viscbuf2
 const char *_nc_viscbuf2(
-		int	bufnum, 
-		const chtype *buf, 
+		int	bufnum,
+		const chtype *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
 #undef _nc_viscbuf
 const char *_nc_viscbuf(
-		const chtype *buf, 
+		const chtype *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
@@ -1572,14 +1652,14 @@ const char *_nc_viscbuf(
 
 #undef define_key_sp
 int	define_key_sp(
-		SCREEN	*sp, 
-		const char *str, 
+		SCREEN	*sp,
+		const char *str,
 		int	keycode)
 		{ return(*(int *)0); }
 
 #undef define_key
 int	define_key(
-		const char *str, 
+		const char *str,
 		int	keycode)
 		{ return(*(int *)0); }
 
@@ -1593,7 +1673,7 @@ void	_nc_hashed_db(void)
 
 #undef key_defined_sp
 int	key_defined_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -1606,14 +1686,14 @@ int	key_defined(
 
 #undef keybound_sp
 char	*keybound_sp(
-		SCREEN	*sp, 
-		int	code, 
+		SCREEN	*sp,
+		int	code,
 		int	count)
 		{ return(*(char **)0); }
 
 #undef keybound
 char	*keybound(
-		int	code, 
+		int	code,
 		int	count)
 		{ return(*(char **)0); }
 
@@ -1621,14 +1701,14 @@ char	*keybound(
 
 #undef keyok_sp
 int	keyok_sp(
-		SCREEN	*sp, 
-		int	c, 
+		SCREEN	*sp,
+		int	c,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef keyok
 int	keyok(
-		int	c, 
+		int	c,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
diff --git a/contrib/ncurses/ncurses/llib-ltinfotw b/contrib/ncurses/ncurses/llib-ltinfotw
index 0e7e76275885..3b21b8765761 100644
--- a/contrib/ncurses/ncurses/llib-ltinfotw
+++ b/contrib/ncurses/ncurses/llib-ltinfotw
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
  * Copyright 2012-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -58,7 +58,7 @@ char	*_nc_basename(
 
 #undef _nc_access
 int	_nc_access(
-		const char *path, 
+		const char *path,
 		int	mode)
 		{ return(*(int *)0); }
 
@@ -76,12 +76,25 @@ NCURSES_BOOL _nc_is_file_path(
 int	_nc_env_access(void)
 		{ return(*(int *)0); }
 
+#undef _nc_safe_fopen
+FILE	*_nc_safe_fopen(
+		const char *path,
+		const char *mode)
+		{ return(*(FILE **)0); }
+
+#undef _nc_safe_open3
+int	_nc_safe_open3(
+		const char *path,
+		int	flags,
+		mode_t	mode)
+		{ return(*(int *)0); }
+
 /* ./tinfo/add_tries.c */
 
 #undef _nc_add_to_try
 int	_nc_add_to_try(
-		TRIES	**tree, 
-		const char *str, 
+		TRIES	**tree,
+		const char *str,
 		unsigned code)
 		{ return(*(int *)0); }
 
@@ -89,25 +102,25 @@ int	_nc_add_to_try(
 
 #undef _nc_align_termtype
 void	_nc_align_termtype(
-		TERMTYPE2 *to, 
+		TERMTYPE2 *to,
 		TERMTYPE2 *from)
 		{ /* void */ }
 
 #undef _nc_copy_termtype
 void	_nc_copy_termtype(
-		TERMTYPE *dst, 
+		TERMTYPE *dst,
 		const TERMTYPE *src)
 		{ /* void */ }
 
 #undef _nc_copy_termtype2
 void	_nc_copy_termtype2(
-		TERMTYPE2 *dst, 
+		TERMTYPE2 *dst,
 		const TERMTYPE2 *src)
 		{ /* void */ }
 
 #undef _nc_export_termtype2
 void	_nc_export_termtype2(
-		TERMTYPE *dst, 
+		TERMTYPE *dst,
 		const TERMTYPE2 *src)
 		{ /* void */ }
 
@@ -177,19 +190,19 @@ void	_nc_get_type(
 
 #undef _nc_warning
 void	_nc_warning(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
 #undef _nc_err_abort
 void	_nc_err_abort(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
 #undef _nc_syserr_abort
 void	_nc_syserr_abort(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
@@ -197,14 +210,14 @@ void	_nc_syserr_abort(
 
 #undef _nc_find_entry
 struct name_table_entry const *_nc_find_entry(
-		const char *string, 
+		const char *string,
 		const HashValue *hash_table)
 		{ return(*(struct name_table_entry const **)0); }
 
 #undef _nc_find_type_entry
 struct name_table_entry const *_nc_find_type_entry(
-		const char *string, 
-		int	type, 
+		const char *string,
+		int	type,
 		NCURSES_BOOL termcap)
 		{ return(*(struct name_table_entry const **)0); }
 
@@ -241,13 +254,13 @@ void	_nc_last_db(void)
 
 #undef _nc_next_db
 const char *_nc_next_db(
-		DBDIRS	*state, 
+		DBDIRS	*state,
 		int	*offset)
 		{ return(*(const char **)0); }
 
 #undef _nc_first_db
 void	_nc_first_db(
-		DBDIRS	*state, 
+		DBDIRS	*state,
 		int	*offset)
 		{ /* void */ }
 
@@ -255,7 +268,7 @@ void	_nc_first_db(
 
 #undef _nc_doalloc
 void	*_nc_doalloc(
-		void	*oldp, 
+		void	*oldp,
 		size_t	amount)
 		{ return(*(void **)0); }
 
@@ -268,7 +281,7 @@ ENTRY	*_nc_tail;
 
 #undef _nc_free_entry
 void	_nc_free_entry(
-		ENTRY	*headp, 
+		ENTRY	*headp,
 		TERMTYPE2 *tterm)
 		{ /* void */ }
 
@@ -305,6 +318,11 @@ void	_nc_free_termtype(
 		TERMTYPE *ptr)
 		{ /* void */ }
 
+#undef _nc_free_termtype1
+void	_nc_free_termtype1(
+		TERMTYPE *ptr)
+		{ /* void */ }
+
 #undef _nc_free_termtype2
 void	_nc_free_termtype2(
 		TERMTYPE2 *ptr)
@@ -327,7 +345,7 @@ int	_nc_getenv_num(
 
 #undef _nc_setenv_num
 void	_nc_setenv_num(
-		const char *name, 
+		const char *name,
 		int	value)
 		{ /* void */ }
 
@@ -362,8 +380,8 @@ void	_nc_init_acs(void)
 /* ./tinfo/lib_baudrate.c */
 
 struct speed {
-    int given_speed; 
-    int actual_speed; 
+    int given_speed;
+    int actual_speed;
 };
 
 #undef _nc_baudrate
@@ -402,7 +420,7 @@ TERMINAL *_nc_cur_term(void)
 
 #undef set_curterm_sp
 TERMINAL *set_curterm_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		TERMINAL *termp)
 		{ return(*(TERMINAL **)0); }
 
@@ -413,7 +431,7 @@ TERMINAL *set_curterm(
 
 #undef del_curterm_sp
 int	del_curterm_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		TERMINAL *termp)
 		{ return(*(int *)0); }
 
@@ -529,7 +547,7 @@ struct kn { short offset; int code; };
 
 #undef keyname_sp
 const char *keyname_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	c)
 		{ return(*(const char **)0); }
 
@@ -553,7 +571,7 @@ char	*longname(void)
 
 #undef napms_sp
 int	napms_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ms)
 		{ return(*(int *)0); }
 
@@ -566,19 +584,19 @@ int	napms(
 
 #undef idlok
 int	idlok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef idcok
 void	idcok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ /* void */ }
 
 #undef halfdelay_sp
 int	halfdelay_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	t)
 		{ return(*(int *)0); }
 
@@ -589,37 +607,37 @@ int	halfdelay(
 
 #undef nodelay
 int	nodelay(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef notimeout
 int	notimeout(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL f)
 		{ return(*(int *)0); }
 
 #undef wtimeout
 void	wtimeout(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	delay)
 		{ /* void */ }
 
 #undef keypad
 int	keypad(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef meta
 int	meta(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef curs_set_sp
 int	curs_set_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	vis)
 		{ return(*(int *)0); }
 
@@ -630,7 +648,7 @@ int	curs_set(
 
 #undef typeahead_sp
 int	typeahead_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	fd)
 		{ return(*(int *)0); }
 
@@ -641,7 +659,7 @@ int	typeahead(
 
 #undef has_key_sp
 int	has_key_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	keycode)
 		{ return(*(int *)0); }
 
@@ -652,14 +670,14 @@ int	has_key(
 
 #undef _nc_putp_flush_sp
 int	_nc_putp_flush_sp(
-		SCREEN	*sp, 
-		const char *name, 
+		SCREEN	*sp,
+		const char *name,
 		const char *value)
 		{ return(*(int *)0); }
 
 #undef _nc_keypad
 int	_nc_keypad(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	flag)
 		{ return(*(int *)0); }
 
@@ -721,17 +739,53 @@ void	noqiflush(void)
 
 #undef intrflush_sp
 int	intrflush_sp(
-		SCREEN	*sp, 
-		WINDOW	*win, 
+		SCREEN	*sp,
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef intrflush
 int	intrflush(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
+#undef is_nl_sp
+int	is_nl_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_raw_sp
+int	is_raw_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_cbreak_sp
+int	is_cbreak_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_echo_sp
+int	is_echo_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_nl
+int	is_nl(void)
+		{ return(*(int *)0); }
+
+#undef is_raw
+int	is_raw(void)
+		{ return(*(int *)0); }
+
+#undef is_cbreak
+int	is_cbreak(void)
+		{ return(*(int *)0); }
+
+#undef is_echo
+int	is_echo(void)
+		{ return(*(int *)0); }
+
 /* ./tinfo/lib_setup.c */
 
 #undef _nc_ttytype
@@ -767,7 +821,7 @@ int	_nc_TABSIZE(void)
 
 #undef set_tabsize_sp
 int	set_tabsize_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	value)
 		{ return(*(int *)0); }
 
@@ -783,13 +837,13 @@ int	_nc_handle_sigwinch(
 
 #undef use_env_sp
 void	use_env_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		NCURSES_BOOL f)
 		{ /* void */ }
 
 #undef use_tioctl_sp
 void	use_tioctl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		NCURSES_BOOL f)
 		{ /* void */ }
 
@@ -805,8 +859,8 @@ void	use_tioctl(
 
 #undef _nc_get_screensize
 void	_nc_get_screensize(
-		SCREEN	*sp, 
-		int	*linep, 
+		SCREEN	*sp,
+		int	*linep,
 		int	*colp)
 		{ /* void */ }
 
@@ -817,13 +871,13 @@ void	_nc_update_screensize(
 
 #undef _nc_setup_tinfo
 int	_nc_setup_tinfo(
-		const char *const tn, 
+		const char *const tn,
 		TERMTYPE2 *const tp)
 		{ return(*(int *)0); }
 
 #undef _nc_tinfo_cmdch
 void	_nc_tinfo_cmdch(
-		TERMINAL *termp, 
+		TERMINAL *termp,
 		int	proto)
 		{ /* void */ }
 
@@ -842,9 +896,9 @@ int	_nc_locale_breaks_acs(
 
 #undef _nc_setupterm
 int	_nc_setupterm(
-		const char *tname, 
-		int	Filedes, 
-		int	*errret, 
+		const char *tname,
+		int	Filedes,
+		int	*errret,
 		int	reuse)
 		{ return(*(int *)0); }
 
@@ -862,8 +916,8 @@ SCREEN	*new_prescr(void)
 
 #undef setupterm
 int	setupterm(
-		const char *tname, 
-		int	Filedes, 
+		const char *tname,
+		int	Filedes,
 		int	*errret)
 		{ return(*(int *)0); }
 
@@ -876,20 +930,20 @@ char	*BC;
 
 #undef tgetent_sp
 int	tgetent_sp(
-		SCREEN	*sp, 
-		char	*bufp, 
+		SCREEN	*sp,
+		char	*bufp,
 		const char *name)
 		{ return(*(int *)0); }
 
 #undef tgetent
 int	tgetent(
-		char	*bufp, 
+		char	*bufp,
 		const char *name)
 		{ return(*(int *)0); }
 
 #undef tgetflag_sp
 int	tgetflag_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *id)
 		{ return(*(int *)0); }
 
@@ -900,7 +954,7 @@ int	tgetflag(
 
 #undef tgetnum_sp
 int	tgetnum_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *id)
 		{ return(*(int *)0); }
 
@@ -911,14 +965,14 @@ int	tgetnum(
 
 #undef tgetstr_sp
 char	*tgetstr_sp(
-		SCREEN	*sp, 
-		const char *id, 
+		SCREEN	*sp,
+		const char *id,
 		char	**area)
 		{ return(*(char **)0); }
 
 #undef tgetstr
 char	*tgetstr(
-		const char *id, 
+		const char *id,
 		char	**area)
 		{ return(*(char **)0); }
 
@@ -937,8 +991,8 @@ char	*termname(void)
 
 #undef tgoto
 char	*tgoto(
-		const char *string, 
-		int	x, 
+		const char *string,
+		int	x,
 		int	y)
 		{ return(*(char **)0); }
 
@@ -946,7 +1000,7 @@ char	*tgoto(
 
 #undef tigetflag_sp
 int	tigetflag_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -957,7 +1011,7 @@ int	tigetflag(
 
 #undef tigetnum_sp
 int	tigetnum_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -968,7 +1022,7 @@ int	tigetnum(
 
 #undef tigetstr_sp
 char	*tigetstr_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(char **)0); }
 
@@ -982,32 +1036,58 @@ char	*tigetstr(
 #undef _nc_tparm_err
 int	_nc_tparm_err;
 
+#undef _nc_free_tparm
+void	_nc_free_tparm(
+		TERMINAL *termp)
+		{ /* void */ }
+
 #undef _nc_tparm_analyze
 int	_nc_tparm_analyze(
-		const char *string, 
-		char	*p_is_s[9], 
+		TERMINAL *term,
+		const char *string,
+		char	**p_is_s,
 		int	*_nc_popcount)
 		{ return(*(int *)0); }
 
 #undef tparm
 char	*tparm(
-		const char *string, 
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
 #undef tiparm
 char	*tiparm(
-		const char *string, 
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
+#undef tiparm_s
+char	*tiparm_s(
+		int	num_expected,
+		int	tparm_type,
+		const char *string,
+		...)
+		{ return(*(char **)0); }
+
+#undef tiscan_s
+int	tiscan_s(
+		int	*num_expected,
+		int	*tparm_type,
+		const char *string)
+		{ return(*(int *)0); }
+
 #undef _nc_tiparm
 char	*_nc_tiparm(
-		int	expected, 
-		const char *string, 
+		int	expected,
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
+#undef _nc_reset_tparm
+void	_nc_reset_tparm(
+		TERMINAL *term)
+		{ /* void */ }
+
 /* ./tinfo/lib_tputs.c */
 
 #undef PC
@@ -1024,7 +1104,7 @@ void	_nc_set_no_padding(
 
 #undef delay_output_sp
 int	delay_output_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ms)
 		{ return(*(int *)0); }
 
@@ -1044,7 +1124,7 @@ void	_nc_flush(void)
 
 #undef _nc_outch_sp
 int	_nc_outch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -1055,7 +1135,7 @@ int	_nc_outch(
 
 #undef _nc_putchar_sp
 int	_nc_putchar_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -1066,7 +1146,7 @@ int	_nc_putchar(
 
 #undef putp_sp
 int	putp_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *string)
 		{ return(*(int *)0); }
 
@@ -1077,35 +1157,35 @@ int	putp(
 
 #undef _nc_putp_sp
 int	_nc_putp_sp(
-		SCREEN	*sp, 
-		const char *name, 
+		SCREEN	*sp,
+		const char *name,
 		const char *string)
 		{ return(*(int *)0); }
 
 #undef _nc_putp
 int	_nc_putp(
-		const char *name, 
+		const char *name,
 		const char *string)
 		{ return(*(int *)0); }
 
 #undef tputs_sp
 int	tputs_sp(
-		SCREEN	*sp, 
-		const char *string, 
-		int	affcnt, 
+		SCREEN	*sp,
+		const char *string,
+		int	affcnt,
 		NCURSES_OUTC_sp outc)
 		{ return(*(int *)0); }
 
 #undef _nc_outc_wrapper
 int	_nc_outc_wrapper(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	c)
 		{ return(*(int *)0); }
 
 #undef tputs
 int	tputs(
-		const char *string, 
-		int	affcnt, 
+		const char *string,
+		int	affcnt,
 		int	(*outc)(
 		int	p1))
 		{ return(*(int *)0); }
@@ -1145,7 +1225,7 @@ void	trace(
 
 #undef _tracef
 void	_tracef(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ /* void */ }
 
@@ -1201,8 +1281,8 @@ WINDOW	*_nc_retrace_win(
 
 #undef _nc_fmt_funcptr
 char	*_nc_fmt_funcptr(
-		char	*target, 
-		const char *source, 
+		char	*target,
+		const char *source,
 		size_t	size)
 		{ return(*(char **)0); }
 
@@ -1213,7 +1293,7 @@ int	_nc_use_tracef(
 
 #undef _nc_locked_tracef
 void	_nc_locked_tracef(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ /* void */ }
 
@@ -1221,7 +1301,7 @@ void	_nc_locked_tracef(
 
 #undef _traceattr2
 char	*_traceattr2(
-		int	bufnum, 
+		int	bufnum,
 		chtype	newmode)
 		{ return(*(char **)0); }
 
@@ -1242,13 +1322,13 @@ attr_t	_nc_retrace_attr_t(
 
 #undef _nc_altcharset_name
 const char *_nc_altcharset_name(
-		attr_t	attr, 
+		attr_t	attr,
 		chtype	ch)
 		{ return(*(const char **)0); }
 
 #undef _tracechtype2
 char	*_tracechtype2(
-		int	bufnum, 
+		int	bufnum,
 		chtype	ch)
 		{ return(*(char **)0); }
 
@@ -1264,7 +1344,7 @@ chtype	_nc_retrace_chtype(
 
 #undef _tracecchar_t2
 char	*_tracecchar_t2(
-		int	bufnum, 
+		int	bufnum,
 		const cchar_t *ch)
 		{ return(*(char **)0); }
 
@@ -1277,7 +1357,7 @@ char	*_tracecchar_t(
 
 #undef _nc_trace_ttymode
 char	*_nc_trace_ttymode(
-		struct termios *tty)
+		const struct termios *tty)
 		{ return(*(char **)0); }
 
 #undef _nc_tracebits
@@ -1288,7 +1368,7 @@ char	*_nc_tracebits(void)
 
 #undef _nc_tracechar
 char	*_nc_tracechar(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(char **)0); }
 
@@ -1301,7 +1381,7 @@ char	*_tracechar(
 
 #undef _nc_get_tty_mode_sp
 int	_nc_get_tty_mode_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		struct termios *buf)
 		{ return(*(int *)0); }
 
@@ -1312,7 +1392,7 @@ int	_nc_get_tty_mode(
 
 #undef _nc_set_tty_mode_sp
 int	_nc_set_tty_mode_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		struct termios *buf)
 		{ return(*(int *)0); }
 
@@ -1379,9 +1459,9 @@ int	resetty(void)
 
 #undef _nc_timed_wait
 int	_nc_timed_wait(
-		SCREEN	*sp, 
-		int	mode, 
-		int	milliseconds, 
+		SCREEN	*sp,
+		int	mode,
+		int	milliseconds,
 		int	*timeleft)
 		{ return(*(int *)0); }
 
@@ -1394,8 +1474,8 @@ char	*_nc_first_name(
 
 #undef _nc_name_match
 int	_nc_name_match(
-		const char *const namelst, 
-		const char *const name, 
+		const char *const namelst,
+		const char *const name,
 		const char *const delim)
 		{ return(*(int *)0); }
 
@@ -1429,14 +1509,14 @@ const char *const *_nc_strfnames(void)
 
 #undef _nc_set_buffer_sp
 void	_nc_set_buffer_sp(
-		SCREEN	*sp, 
-		FILE	*ofp, 
+		SCREEN	*sp,
+		FILE	*ofp,
 		int	buffered)
 		{ /* void */ }
 
 #undef _nc_set_buffer
 void	_nc_set_buffer(
-		FILE	*ofp, 
+		FILE	*ofp,
 		int	buffered)
 		{ /* void */ }
 
@@ -1449,28 +1529,28 @@ void	_nc_init_termtype(
 
 #undef _nc_read_termtype
 int	_nc_read_termtype(
-		TERMTYPE2 *ptr, 
-		char	*buffer, 
+		TERMTYPE2 *ptr,
+		char	*buffer,
 		int	limit)
 		{ return(*(int *)0); }
 
 #undef _nc_read_file_entry
 int	_nc_read_file_entry(
-		const char *const filename, 
+		const char *const filename,
 		TERMTYPE2 *ptr)
 		{ return(*(int *)0); }
 
 #undef _nc_read_entry2
 int	_nc_read_entry2(
-		const char *const name, 
-		char	*const filename, 
+		const char *const name,
+		char	*const filename,
 		TERMTYPE2 *const tp)
 		{ return(*(int *)0); }
 
 #undef _nc_read_entry
 int	_nc_read_entry(
-		const char *const name, 
-		char	*const filename, 
+		const char *const name,
+		char	*const filename,
 		TERMTYPE *const tp)
 		{ return(*(int *)0); }
 
@@ -1484,32 +1564,32 @@ void	_nc_read_termcap(void)
 
 #undef _nc_str_init
 string_desc *_nc_str_init(
-		string_desc *dst, 
-		char	*src, 
+		string_desc *dst,
+		char	*src,
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_null
 string_desc *_nc_str_null(
-		string_desc *dst, 
+		string_desc *dst,
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_copy
 string_desc *_nc_str_copy(
-		string_desc *dst, 
-		string_desc *src)
+		string_desc *dst,
+		const string_desc *const src)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_safe_strcat
 NCURSES_BOOL _nc_safe_strcat(
-		string_desc *dst, 
+		string_desc *dst,
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_safe_strcpy
 NCURSES_BOOL _nc_safe_strcpy(
-		string_desc *dst, 
+		string_desc *dst,
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -1517,13 +1597,13 @@ NCURSES_BOOL _nc_safe_strcpy(
 
 #undef _nc_trace_buf
 char	*_nc_trace_buf(
-		int	bufnum, 
+		int	bufnum,
 		size_t	want)
 		{ return(*(char **)0); }
 
 #undef _nc_trace_bufcat
 char	*_nc_trace_bufcat(
-		int	bufnum, 
+		int	bufnum,
 		const char *value)
 		{ return(*(char **)0); }
 
@@ -1538,21 +1618,21 @@ void	_nc_trace_tries(
 
 #undef _nc_expand_try
 char	*_nc_expand_try(
-		TRIES	*tree, 
-		unsigned code, 
-		int	*count, 
+		TRIES	*tree,
+		unsigned code,
+		int	*count,
 		size_t	len)
 		{ return(*(char **)0); }
 
 #undef _nc_remove_key
 int	_nc_remove_key(
-		TRIES	**tree, 
+		TRIES	**tree,
 		unsigned code)
 		{ return(*(int *)0); }
 
 #undef _nc_remove_string
 int	_nc_remove_string(
-		TRIES	**tree, 
+		TRIES	**tree,
 		const char *string)
 		{ return(*(int *)0); }
 
@@ -1567,7 +1647,7 @@ char	*_nc_trim_sgr0(
 
 #undef unctrl_sp
 const char *unctrl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		chtype	ch)
 		{ return(*(const char **)0); }
 
@@ -1580,7 +1660,7 @@ const char *unctrl(
 
 #undef _nc_visbuf2
 const char *_nc_visbuf2(
-		int	bufnum, 
+		int	bufnum,
 		const char *buf)
 		{ return(*(const char **)0); }
 
@@ -1591,13 +1671,13 @@ const char *_nc_visbuf(
 
 #undef _nc_visbufn
 const char *_nc_visbufn(
-		const char *buf, 
+		const char *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
 #undef _nc_viswbuf2
 const char *_nc_viswbuf2(
-		int	bufnum, 
+		int	bufnum,
 		const wchar_t *buf)
 		{ return(*(const char **)0); }
 
@@ -1608,7 +1688,7 @@ const char *_nc_viswbuf(
 
 #undef _nc_viswbufn
 const char *_nc_viswbufn(
-		const wchar_t *buf, 
+		const wchar_t *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
@@ -1619,14 +1699,14 @@ const char *_nc_viswibuf(
 
 #undef _nc_viscbuf2
 const char *_nc_viscbuf2(
-		int	bufnum, 
-		const cchar_t *buf, 
+		int	bufnum,
+		const cchar_t *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
 #undef _nc_viscbuf
 const char *_nc_viscbuf(
-		const cchar_t *buf, 
+		const cchar_t *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
@@ -1634,14 +1714,14 @@ const char *_nc_viscbuf(
 
 #undef define_key_sp
 int	define_key_sp(
-		SCREEN	*sp, 
-		const char *str, 
+		SCREEN	*sp,
+		const char *str,
 		int	keycode)
 		{ return(*(int *)0); }
 
 #undef define_key
 int	define_key(
-		const char *str, 
+		const char *str,
 		int	keycode)
 		{ return(*(int *)0); }
 
@@ -1655,7 +1735,7 @@ void	_nc_hashed_db(void)
 
 #undef key_defined_sp
 int	key_defined_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -1668,14 +1748,14 @@ int	key_defined(
 
 #undef keybound_sp
 char	*keybound_sp(
-		SCREEN	*sp, 
-		int	code, 
+		SCREEN	*sp,
+		int	code,
 		int	count)
 		{ return(*(char **)0); }
 
 #undef keybound
 char	*keybound(
-		int	code, 
+		int	code,
 		int	count)
 		{ return(*(char **)0); }
 
@@ -1683,14 +1763,14 @@ char	*keybound(
 
 #undef keyok_sp
 int	keyok_sp(
-		SCREEN	*sp, 
-		int	c, 
+		SCREEN	*sp,
+		int	c,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef keyok
 int	keyok(
-		int	c, 
+		int	c,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
diff --git a/contrib/ncurses/ncurses/llib-ltinfow b/contrib/ncurses/ncurses/llib-ltinfow
index 815e6b3e3c3e..fd308180722a 100644
--- a/contrib/ncurses/ncurses/llib-ltinfow
+++ b/contrib/ncurses/ncurses/llib-ltinfow
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
  * Copyright 2012-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -58,7 +58,7 @@ char	*_nc_basename(
 
 #undef _nc_access
 int	_nc_access(
-		const char *path, 
+		const char *path,
 		int	mode)
 		{ return(*(int *)0); }
 
@@ -76,12 +76,25 @@ NCURSES_BOOL _nc_is_file_path(
 int	_nc_env_access(void)
 		{ return(*(int *)0); }
 
+#undef _nc_safe_fopen
+FILE	*_nc_safe_fopen(
+		const char *path,
+		const char *mode)
+		{ return(*(FILE **)0); }
+
+#undef _nc_safe_open3
+int	_nc_safe_open3(
+		const char *path,
+		int	flags,
+		mode_t	mode)
+		{ return(*(int *)0); }
+
 /* ./tinfo/add_tries.c */
 
 #undef _nc_add_to_try
 int	_nc_add_to_try(
-		TRIES	**tree, 
-		const char *str, 
+		TRIES	**tree,
+		const char *str,
 		unsigned code)
 		{ return(*(int *)0); }
 
@@ -89,25 +102,25 @@ int	_nc_add_to_try(
 
 #undef _nc_align_termtype
 void	_nc_align_termtype(
-		TERMTYPE2 *to, 
+		TERMTYPE2 *to,
 		TERMTYPE2 *from)
 		{ /* void */ }
 
 #undef _nc_copy_termtype
 void	_nc_copy_termtype(
-		TERMTYPE *dst, 
+		TERMTYPE *dst,
 		const TERMTYPE *src)
 		{ /* void */ }
 
 #undef _nc_copy_termtype2
 void	_nc_copy_termtype2(
-		TERMTYPE2 *dst, 
+		TERMTYPE2 *dst,
 		const TERMTYPE2 *src)
 		{ /* void */ }
 
 #undef _nc_export_termtype2
 void	_nc_export_termtype2(
-		TERMTYPE *dst, 
+		TERMTYPE *dst,
 		const TERMTYPE2 *src)
 		{ /* void */ }
 
@@ -172,19 +185,19 @@ void	_nc_get_type(
 
 #undef _nc_warning
 void	_nc_warning(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
 #undef _nc_err_abort
 void	_nc_err_abort(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
 #undef _nc_syserr_abort
 void	_nc_syserr_abort(
-		const char *const fmt, 
+		const char *const fmt,
 		...)
 		{ /* void */ }
 
@@ -192,14 +205,14 @@ void	_nc_syserr_abort(
 
 #undef _nc_find_entry
 struct name_table_entry const *_nc_find_entry(
-		const char *string, 
+		const char *string,
 		const HashValue *hash_table)
 		{ return(*(struct name_table_entry const **)0); }
 
 #undef _nc_find_type_entry
 struct name_table_entry const *_nc_find_type_entry(
-		const char *string, 
-		int	type, 
+		const char *string,
+		int	type,
 		NCURSES_BOOL termcap)
 		{ return(*(struct name_table_entry const **)0); }
 
@@ -236,13 +249,13 @@ void	_nc_last_db(void)
 
 #undef _nc_next_db
 const char *_nc_next_db(
-		DBDIRS	*state, 
+		DBDIRS	*state,
 		int	*offset)
 		{ return(*(const char **)0); }
 
 #undef _nc_first_db
 void	_nc_first_db(
-		DBDIRS	*state, 
+		DBDIRS	*state,
 		int	*offset)
 		{ /* void */ }
 
@@ -250,7 +263,7 @@ void	_nc_first_db(
 
 #undef _nc_doalloc
 void	*_nc_doalloc(
-		void	*oldp, 
+		void	*oldp,
 		size_t	amount)
 		{ return(*(void **)0); }
 
@@ -263,7 +276,7 @@ ENTRY	*_nc_tail;
 
 #undef _nc_free_entry
 void	_nc_free_entry(
-		ENTRY	*headp, 
+		ENTRY	*headp,
 		TERMTYPE2 *tterm)
 		{ /* void */ }
 
@@ -300,6 +313,11 @@ void	_nc_free_termtype(
 		TERMTYPE *ptr)
 		{ /* void */ }
 
+#undef _nc_free_termtype1
+void	_nc_free_termtype1(
+		TERMTYPE *ptr)
+		{ /* void */ }
+
 #undef _nc_free_termtype2
 void	_nc_free_termtype2(
 		TERMTYPE2 *ptr)
@@ -322,7 +340,7 @@ int	_nc_getenv_num(
 
 #undef _nc_setenv_num
 void	_nc_setenv_num(
-		const char *name, 
+		const char *name,
 		int	value)
 		{ /* void */ }
 
@@ -356,8 +374,8 @@ void	_nc_init_acs(void)
 /* ./tinfo/lib_baudrate.c */
 
 struct speed {
-    int given_speed; 
-    int actual_speed; 
+    int given_speed;
+    int actual_speed;
 };
 
 #undef _nc_baudrate
@@ -386,7 +404,7 @@ TERMINAL *cur_term;
 
 #undef set_curterm_sp
 TERMINAL *set_curterm_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		TERMINAL *termp)
 		{ return(*(TERMINAL **)0); }
 
@@ -397,7 +415,7 @@ TERMINAL *set_curterm(
 
 #undef del_curterm_sp
 int	del_curterm_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		TERMINAL *termp)
 		{ return(*(int *)0); }
 
@@ -483,7 +501,7 @@ struct kn { short offset; int code; };
 
 #undef keyname_sp
 const char *keyname_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	c)
 		{ return(*(const char **)0); }
 
@@ -507,7 +525,7 @@ char	*longname(void)
 
 #undef napms_sp
 int	napms_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ms)
 		{ return(*(int *)0); }
 
@@ -520,19 +538,19 @@ int	napms(
 
 #undef idlok
 int	idlok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef idcok
 void	idcok(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ /* void */ }
 
 #undef halfdelay_sp
 int	halfdelay_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	t)
 		{ return(*(int *)0); }
 
@@ -543,37 +561,37 @@ int	halfdelay(
 
 #undef nodelay
 int	nodelay(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef notimeout
 int	notimeout(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL f)
 		{ return(*(int *)0); }
 
 #undef wtimeout
 void	wtimeout(
-		WINDOW	*win, 
+		WINDOW	*win,
 		int	delay)
 		{ /* void */ }
 
 #undef keypad
 int	keypad(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef meta
 int	meta(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef curs_set_sp
 int	curs_set_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	vis)
 		{ return(*(int *)0); }
 
@@ -584,7 +602,7 @@ int	curs_set(
 
 #undef typeahead_sp
 int	typeahead_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	fd)
 		{ return(*(int *)0); }
 
@@ -595,7 +613,7 @@ int	typeahead(
 
 #undef has_key_sp
 int	has_key_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	keycode)
 		{ return(*(int *)0); }
 
@@ -606,14 +624,14 @@ int	has_key(
 
 #undef _nc_putp_flush_sp
 int	_nc_putp_flush_sp(
-		SCREEN	*sp, 
-		const char *name, 
+		SCREEN	*sp,
+		const char *name,
 		const char *value)
 		{ return(*(int *)0); }
 
 #undef _nc_keypad
 int	_nc_keypad(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	flag)
 		{ return(*(int *)0); }
 
@@ -675,17 +693,53 @@ void	noqiflush(void)
 
 #undef intrflush_sp
 int	intrflush_sp(
-		SCREEN	*sp, 
-		WINDOW	*win, 
+		SCREEN	*sp,
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef intrflush
 int	intrflush(
-		WINDOW	*win, 
+		WINDOW	*win,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
+#undef is_nl_sp
+int	is_nl_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_raw_sp
+int	is_raw_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_cbreak_sp
+int	is_cbreak_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_echo_sp
+int	is_echo_sp(
+		SCREEN	*sp)
+		{ return(*(int *)0); }
+
+#undef is_nl
+int	is_nl(void)
+		{ return(*(int *)0); }
+
+#undef is_raw
+int	is_raw(void)
+		{ return(*(int *)0); }
+
+#undef is_cbreak
+int	is_cbreak(void)
+		{ return(*(int *)0); }
+
+#undef is_echo
+int	is_echo(void)
+		{ return(*(int *)0); }
+
 /* ./tinfo/lib_setup.c */
 
 #undef ttytype
@@ -699,7 +753,7 @@ int	TABSIZE;
 
 #undef set_tabsize_sp
 int	set_tabsize_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	value)
 		{ return(*(int *)0); }
 
@@ -715,13 +769,13 @@ int	_nc_handle_sigwinch(
 
 #undef use_env_sp
 void	use_env_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		NCURSES_BOOL f)
 		{ /* void */ }
 
 #undef use_tioctl_sp
 void	use_tioctl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		NCURSES_BOOL f)
 		{ /* void */ }
 
@@ -737,8 +791,8 @@ void	use_tioctl(
 
 #undef _nc_get_screensize
 void	_nc_get_screensize(
-		SCREEN	*sp, 
-		int	*linep, 
+		SCREEN	*sp,
+		int	*linep,
 		int	*colp)
 		{ /* void */ }
 
@@ -749,13 +803,13 @@ void	_nc_update_screensize(
 
 #undef _nc_setup_tinfo
 int	_nc_setup_tinfo(
-		const char *const tn, 
+		const char *const tn,
 		TERMTYPE2 *const tp)
 		{ return(*(int *)0); }
 
 #undef _nc_tinfo_cmdch
 void	_nc_tinfo_cmdch(
-		TERMINAL *termp, 
+		TERMINAL *termp,
 		int	proto)
 		{ /* void */ }
 
@@ -774,9 +828,9 @@ int	_nc_locale_breaks_acs(
 
 #undef _nc_setupterm
 int	_nc_setupterm(
-		const char *tname, 
-		int	Filedes, 
-		int	*errret, 
+		const char *tname,
+		int	Filedes,
+		int	*errret,
 		int	reuse)
 		{ return(*(int *)0); }
 
@@ -786,8 +840,8 @@ SCREEN	*new_prescr(void)
 
 #undef setupterm
 int	setupterm(
-		const char *tname, 
-		int	Filedes, 
+		const char *tname,
+		int	Filedes,
 		int	*errret)
 		{ return(*(int *)0); }
 
@@ -800,20 +854,20 @@ char	*BC;
 
 #undef tgetent_sp
 int	tgetent_sp(
-		SCREEN	*sp, 
-		char	*bufp, 
+		SCREEN	*sp,
+		char	*bufp,
 		const char *name)
 		{ return(*(int *)0); }
 
 #undef tgetent
 int	tgetent(
-		char	*bufp, 
+		char	*bufp,
 		const char *name)
 		{ return(*(int *)0); }
 
 #undef tgetflag_sp
 int	tgetflag_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *id)
 		{ return(*(int *)0); }
 
@@ -824,7 +878,7 @@ int	tgetflag(
 
 #undef tgetnum_sp
 int	tgetnum_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *id)
 		{ return(*(int *)0); }
 
@@ -835,14 +889,14 @@ int	tgetnum(
 
 #undef tgetstr_sp
 char	*tgetstr_sp(
-		SCREEN	*sp, 
-		const char *id, 
+		SCREEN	*sp,
+		const char *id,
 		char	**area)
 		{ return(*(char **)0); }
 
 #undef tgetstr
 char	*tgetstr(
-		const char *id, 
+		const char *id,
 		char	**area)
 		{ return(*(char **)0); }
 
@@ -861,8 +915,8 @@ char	*termname(void)
 
 #undef tgoto
 char	*tgoto(
-		const char *string, 
-		int	x, 
+		const char *string,
+		int	x,
 		int	y)
 		{ return(*(char **)0); }
 
@@ -870,7 +924,7 @@ char	*tgoto(
 
 #undef tigetflag_sp
 int	tigetflag_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -881,7 +935,7 @@ int	tigetflag(
 
 #undef tigetnum_sp
 int	tigetnum_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -892,7 +946,7 @@ int	tigetnum(
 
 #undef tigetstr_sp
 char	*tigetstr_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(char **)0); }
 
@@ -906,32 +960,58 @@ char	*tigetstr(
 #undef _nc_tparm_err
 int	_nc_tparm_err;
 
+#undef _nc_free_tparm
+void	_nc_free_tparm(
+		TERMINAL *termp)
+		{ /* void */ }
+
 #undef _nc_tparm_analyze
 int	_nc_tparm_analyze(
-		const char *string, 
-		char	*p_is_s[9], 
+		TERMINAL *term,
+		const char *string,
+		char	**p_is_s,
 		int	*_nc_popcount)
 		{ return(*(int *)0); }
 
 #undef tparm
 char	*tparm(
-		const char *string, 
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
 #undef tiparm
 char	*tiparm(
-		const char *string, 
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
+#undef tiparm_s
+char	*tiparm_s(
+		int	num_expected,
+		int	tparm_type,
+		const char *string,
+		...)
+		{ return(*(char **)0); }
+
+#undef tiscan_s
+int	tiscan_s(
+		int	*num_expected,
+		int	*tparm_type,
+		const char *string)
+		{ return(*(int *)0); }
+
 #undef _nc_tiparm
 char	*_nc_tiparm(
-		int	expected, 
-		const char *string, 
+		int	expected,
+		const char *string,
 		...)
 		{ return(*(char **)0); }
 
+#undef _nc_reset_tparm
+void	_nc_reset_tparm(
+		TERMINAL *term)
+		{ /* void */ }
+
 /* ./tinfo/lib_tputs.c */
 
 #undef PC
@@ -948,7 +1028,7 @@ void	_nc_set_no_padding(
 
 #undef delay_output_sp
 int	delay_output_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ms)
 		{ return(*(int *)0); }
 
@@ -968,7 +1048,7 @@ void	_nc_flush(void)
 
 #undef _nc_outch_sp
 int	_nc_outch_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -979,7 +1059,7 @@ int	_nc_outch(
 
 #undef _nc_putchar_sp
 int	_nc_putchar_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(int *)0); }
 
@@ -990,7 +1070,7 @@ int	_nc_putchar(
 
 #undef putp_sp
 int	putp_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *string)
 		{ return(*(int *)0); }
 
@@ -1001,35 +1081,35 @@ int	putp(
 
 #undef _nc_putp_sp
 int	_nc_putp_sp(
-		SCREEN	*sp, 
-		const char *name, 
+		SCREEN	*sp,
+		const char *name,
 		const char *string)
 		{ return(*(int *)0); }
 
 #undef _nc_putp
 int	_nc_putp(
-		const char *name, 
+		const char *name,
 		const char *string)
 		{ return(*(int *)0); }
 
 #undef tputs_sp
 int	tputs_sp(
-		SCREEN	*sp, 
-		const char *string, 
-		int	affcnt, 
+		SCREEN	*sp,
+		const char *string,
+		int	affcnt,
 		NCURSES_OUTC_sp outc)
 		{ return(*(int *)0); }
 
 #undef _nc_outc_wrapper
 int	_nc_outc_wrapper(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	c)
 		{ return(*(int *)0); }
 
 #undef tputs
 int	tputs(
-		const char *string, 
-		int	affcnt, 
+		const char *string,
+		int	affcnt,
 		int	(*outc)(
 		int	p1))
 		{ return(*(int *)0); }
@@ -1055,7 +1135,7 @@ void	trace(
 
 #undef _tracef
 void	_tracef(
-		const char *fmt, 
+		const char *fmt,
 		...)
 		{ /* void */ }
 
@@ -1111,8 +1191,8 @@ WINDOW	*_nc_retrace_win(
 
 #undef _nc_fmt_funcptr
 char	*_nc_fmt_funcptr(
-		char	*target, 
-		const char *source, 
+		char	*target,
+		const char *source,
 		size_t	size)
 		{ return(*(char **)0); }
 
@@ -1120,7 +1200,7 @@ char	*_nc_fmt_funcptr(
 
 #undef _traceattr2
 char	*_traceattr2(
-		int	bufnum, 
+		int	bufnum,
 		chtype	newmode)
 		{ return(*(char **)0); }
 
@@ -1141,13 +1221,13 @@ attr_t	_nc_retrace_attr_t(
 
 #undef _nc_altcharset_name
 const char *_nc_altcharset_name(
-		attr_t	attr, 
+		attr_t	attr,
 		chtype	ch)
 		{ return(*(const char **)0); }
 
 #undef _tracechtype2
 char	*_tracechtype2(
-		int	bufnum, 
+		int	bufnum,
 		chtype	ch)
 		{ return(*(char **)0); }
 
@@ -1163,7 +1243,7 @@ chtype	_nc_retrace_chtype(
 
 #undef _tracecchar_t2
 char	*_tracecchar_t2(
-		int	bufnum, 
+		int	bufnum,
 		const cchar_t *ch)
 		{ return(*(char **)0); }
 
@@ -1176,7 +1256,7 @@ char	*_tracecchar_t(
 
 #undef _nc_trace_ttymode
 char	*_nc_trace_ttymode(
-		struct termios *tty)
+		const struct termios *tty)
 		{ return(*(char **)0); }
 
 #undef _nc_tracebits
@@ -1187,7 +1267,7 @@ char	*_nc_tracebits(void)
 
 #undef _nc_tracechar
 char	*_nc_tracechar(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		int	ch)
 		{ return(*(char **)0); }
 
@@ -1200,7 +1280,7 @@ char	*_tracechar(
 
 #undef _nc_get_tty_mode_sp
 int	_nc_get_tty_mode_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		struct termios *buf)
 		{ return(*(int *)0); }
 
@@ -1211,7 +1291,7 @@ int	_nc_get_tty_mode(
 
 #undef _nc_set_tty_mode_sp
 int	_nc_set_tty_mode_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		struct termios *buf)
 		{ return(*(int *)0); }
 
@@ -1278,9 +1358,9 @@ int	resetty(void)
 
 #undef _nc_timed_wait
 int	_nc_timed_wait(
-		SCREEN	*sp, 
-		int	mode, 
-		int	milliseconds, 
+		SCREEN	*sp,
+		int	mode,
+		int	milliseconds,
 		int	*timeleft)
 		{ return(*(int *)0); }
 
@@ -1293,8 +1373,8 @@ char	*_nc_first_name(
 
 #undef _nc_name_match
 int	_nc_name_match(
-		const char *const namelst, 
-		const char *const name, 
+		const char *const namelst,
+		const char *const name,
 		const char *const delim)
 		{ return(*(int *)0); }
 
@@ -1317,14 +1397,14 @@ const char *const strfnames[] = {0};
 
 #undef _nc_set_buffer_sp
 void	_nc_set_buffer_sp(
-		SCREEN	*sp, 
-		FILE	*ofp, 
+		SCREEN	*sp,
+		FILE	*ofp,
 		int	buffered)
 		{ /* void */ }
 
 #undef _nc_set_buffer
 void	_nc_set_buffer(
-		FILE	*ofp, 
+		FILE	*ofp,
 		int	buffered)
 		{ /* void */ }
 
@@ -1337,28 +1417,28 @@ void	_nc_init_termtype(
 
 #undef _nc_read_termtype
 int	_nc_read_termtype(
-		TERMTYPE2 *ptr, 
-		char	*buffer, 
+		TERMTYPE2 *ptr,
+		char	*buffer,
 		int	limit)
 		{ return(*(int *)0); }
 
 #undef _nc_read_file_entry
 int	_nc_read_file_entry(
-		const char *const filename, 
+		const char *const filename,
 		TERMTYPE2 *ptr)
 		{ return(*(int *)0); }
 
 #undef _nc_read_entry2
 int	_nc_read_entry2(
-		const char *const name, 
-		char	*const filename, 
+		const char *const name,
+		char	*const filename,
 		TERMTYPE2 *const tp)
 		{ return(*(int *)0); }
 
 #undef _nc_read_entry
 int	_nc_read_entry(
-		const char *const name, 
-		char	*const filename, 
+		const char *const name,
+		char	*const filename,
 		TERMTYPE *const tp)
 		{ return(*(int *)0); }
 
@@ -1372,32 +1452,32 @@ void	_nc_read_termcap(void)
 
 #undef _nc_str_init
 string_desc *_nc_str_init(
-		string_desc *dst, 
-		char	*src, 
+		string_desc *dst,
+		char	*src,
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_null
 string_desc *_nc_str_null(
-		string_desc *dst, 
+		string_desc *dst,
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_copy
 string_desc *_nc_str_copy(
-		string_desc *dst, 
-		string_desc *src)
+		string_desc *dst,
+		const string_desc *const src)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_safe_strcat
 NCURSES_BOOL _nc_safe_strcat(
-		string_desc *dst, 
+		string_desc *dst,
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_safe_strcpy
 NCURSES_BOOL _nc_safe_strcpy(
-		string_desc *dst, 
+		string_desc *dst,
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -1405,13 +1485,13 @@ NCURSES_BOOL _nc_safe_strcpy(
 
 #undef _nc_trace_buf
 char	*_nc_trace_buf(
-		int	bufnum, 
+		int	bufnum,
 		size_t	want)
 		{ return(*(char **)0); }
 
 #undef _nc_trace_bufcat
 char	*_nc_trace_bufcat(
-		int	bufnum, 
+		int	bufnum,
 		const char *value)
 		{ return(*(char **)0); }
 
@@ -1426,21 +1506,21 @@ void	_nc_trace_tries(
 
 #undef _nc_expand_try
 char	*_nc_expand_try(
-		TRIES	*tree, 
-		unsigned code, 
-		int	*count, 
+		TRIES	*tree,
+		unsigned code,
+		int	*count,
 		size_t	len)
 		{ return(*(char **)0); }
 
 #undef _nc_remove_key
 int	_nc_remove_key(
-		TRIES	**tree, 
+		TRIES	**tree,
 		unsigned code)
 		{ return(*(int *)0); }
 
 #undef _nc_remove_string
 int	_nc_remove_string(
-		TRIES	**tree, 
+		TRIES	**tree,
 		const char *string)
 		{ return(*(int *)0); }
 
@@ -1455,7 +1535,7 @@ char	*_nc_trim_sgr0(
 
 #undef unctrl_sp
 const char *unctrl_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		chtype	ch)
 		{ return(*(const char **)0); }
 
@@ -1468,7 +1548,7 @@ const char *unctrl(
 
 #undef _nc_visbuf2
 const char *_nc_visbuf2(
-		int	bufnum, 
+		int	bufnum,
 		const char *buf)
 		{ return(*(const char **)0); }
 
@@ -1479,13 +1559,13 @@ const char *_nc_visbuf(
 
 #undef _nc_visbufn
 const char *_nc_visbufn(
-		const char *buf, 
+		const char *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
 #undef _nc_viswbuf2
 const char *_nc_viswbuf2(
-		int	bufnum, 
+		int	bufnum,
 		const wchar_t *buf)
 		{ return(*(const char **)0); }
 
@@ -1496,7 +1576,7 @@ const char *_nc_viswbuf(
 
 #undef _nc_viswbufn
 const char *_nc_viswbufn(
-		const wchar_t *buf, 
+		const wchar_t *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
@@ -1507,14 +1587,14 @@ const char *_nc_viswibuf(
 
 #undef _nc_viscbuf2
 const char *_nc_viscbuf2(
-		int	bufnum, 
-		const cchar_t *buf, 
+		int	bufnum,
+		const cchar_t *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
 #undef _nc_viscbuf
 const char *_nc_viscbuf(
-		const cchar_t *buf, 
+		const cchar_t *buf,
 		int	len)
 		{ return(*(const char **)0); }
 
@@ -1522,14 +1602,14 @@ const char *_nc_viscbuf(
 
 #undef define_key_sp
 int	define_key_sp(
-		SCREEN	*sp, 
-		const char *str, 
+		SCREEN	*sp,
+		const char *str,
 		int	keycode)
 		{ return(*(int *)0); }
 
 #undef define_key
 int	define_key(
-		const char *str, 
+		const char *str,
 		int	keycode)
 		{ return(*(int *)0); }
 
@@ -1543,7 +1623,7 @@ void	_nc_hashed_db(void)
 
 #undef key_defined_sp
 int	key_defined_sp(
-		SCREEN	*sp, 
+		SCREEN	*sp,
 		const char *str)
 		{ return(*(int *)0); }
 
@@ -1556,14 +1636,14 @@ int	key_defined(
 
 #undef keybound_sp
 char	*keybound_sp(
-		SCREEN	*sp, 
-		int	code, 
+		SCREEN	*sp,
+		int	code,
 		int	count)
 		{ return(*(char **)0); }
 
 #undef keybound
 char	*keybound(
-		int	code, 
+		int	code,
 		int	count)
 		{ return(*(char **)0); }
 
@@ -1571,14 +1651,14 @@ char	*keybound(
 
 #undef keyok_sp
 int	keyok_sp(
-		SCREEN	*sp, 
-		int	c, 
+		SCREEN	*sp,
+		int	c,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef keyok
 int	keyok(
-		int	c, 
+		int	c,
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
diff --git a/contrib/ncurses/ncurses/new_pair.h b/contrib/ncurses/ncurses/new_pair.h
index dfda89077207..49d7e8b8dbdd 100644
--- a/contrib/ncurses/ncurses/new_pair.h
+++ b/contrib/ncurses/ncurses/new_pair.h
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2018-2020,2021 Thomas E. Dickey                                *
  * Copyright 2017 Free Software Foundation, Inc.                            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -34,13 +34,22 @@
 /*
  * Common type definitions and macros for new_pair.c, lib_color.c
  *
- * $Id: new_pair.h,v 1.11 2020/04/11 16:43:47 tom Exp $
+ * $Id: new_pair.h,v 1.13 2021/09/24 17:52:01 tom Exp $
  */
 
 #ifndef NEW_PAIR_H
 #define NEW_PAIR_H 1
 /* *INDENT-OFF* */
 
+#include <ncurses_cfg.h>
+#include <ncurses_dll.h>
+
+#include <sys/types.h>
+
+#undef SCREEN
+#define SCREEN struct screen
+SCREEN;
+
 #define LIMIT_TYPED(n,t) \
 	(t)(((n) > MAX_OF_TYPE(t)) \
 	    ? MAX_OF_TYPE(t) \
diff --git a/contrib/ncurses/ncurses/report_offsets.c b/contrib/ncurses/ncurses/report_offsets.c
index 2e7083a1e43d..0f82dcf35db7 100644
--- a/contrib/ncurses/ncurses/report_offsets.c
+++ b/contrib/ncurses/ncurses/report_offsets.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2018-2023,2024 Thomas E. Dickey                                *
  * Copyright 2017 Free Software Foundation, Inc.                            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -31,14 +31,17 @@
  *  Author: Thomas E. Dickey                                                *
  ****************************************************************************/
 
+#define NEW_PAIR_INTERNAL 1
 #include <curses.priv.h>
 
-MODULE_ID("$Id: report_offsets.c,v 1.21 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: report_offsets.c,v 1.28 2024/02/24 15:59:09 tom Exp $")
 
 #define show_size(type) \
 	flag = 0; \
 	last = 0; \
 	printf("%5lu   " #type "\n", (unsigned long)sizeof(type))
+#define show_name(name) \
+	printf("%5lu   " #name "\n", (unsigned long)(name))
 #define show_offset(type,member) \
 	next = (unsigned long)offsetof(type,member); \
 	if (last > next) \
@@ -65,12 +68,7 @@ MODULE_ID("$Id: report_offsets.c,v 1.21 2020/02/02 23:34:34 tom Exp $")
 #define show_MLEAKS(type,member)	/* nothing */
 #endif
 
-#ifdef USE_TERM_DRIVER
-#define show_NORMAL(type,member)	/* nothing */
-#else
 #define show_NORMAL(type,member) { flag = "n"; show_offset(type,member); }
-#endif
-
 #define show_OPTION(type,member) { flag = "+"; show_offset(type,member); }
 
 #if USE_REENTRANT
@@ -116,9 +114,28 @@ main(void)
 #if USE_WIDEC_SUPPORT
     show_size(cchar_t);
 #endif
+    show_size(color_t);
+    show_size(colorpair_t);
     show_size(mmask_t);
+    show_size(rgb_bits_t);
     show_size(MEVENT);
     show_size(NCURSES_BOOL);
+    show_size(TRIES);
+
+    printf("\n");
+    printf("Sizes of buffers/arrays:\n");
+#if USE_WIDEC_SUPPORT
+    show_name(CCHARW_MAX);
+#endif
+    show_name(EV_MAX);
+    show_name(FIFO_SIZE);
+    show_name(NAMESIZE);
+    show_name(MB_LEN_MAX);
+    show_name(PATH_MAX);
+#ifdef TRACE
+    show_name(TRACECHR_BUF);
+    show_name(TRACEMSE_MAX);
+#endif
 
     printf("\n");
     show_size(SCREEN);
@@ -160,7 +177,9 @@ main(void)
 #if USE_SIZECHANGE
     show_OPTION(SCREEN, _resize);
 #endif
-    show_DRIVER(SCREEN, _windowlist);
+#ifdef USE_SP_WINDOWLIST
+    show_NORMAL(SCREEN, _windowlist);
+#endif
     show_REENTR(SCREEN, _ttytype);
     show_SPFUNC(SCREEN, use_tioctl);
     show_WIDECH(SCREEN, _screen_acs_fix);
@@ -175,6 +194,7 @@ main(void)
     show_offset(TERMINAL, Nttyb);
     show_offset(TERMINAL, _baudrate);
     show_offset(TERMINAL, _termname);
+    show_offset(TERMINAL, tparm_state);
 #if HAVE_INIT_EXTENDED_COLOR
     show_COLORS(TERMINAL, type2);
 #endif
@@ -186,6 +206,15 @@ main(void)
     show_OPTION(TERMTYPE, ext_Strings);
 #endif
 
+    printf("\n");
+    show_size(TPARM_STATE);
+    show_offset(TPARM_STATE, stack);
+    show_offset(TPARM_STATE, stack_ptr);
+    show_offset(TPARM_STATE, out_buff);
+    show_offset(TPARM_STATE, fmt_buff);
+    show_offset(TPARM_STATE, static_vars);
+    show_TRACES(TPARM_STATE, tname);
+
     printf("\n");
     show_size(WINDOW);
     show_WIDECH(WINDOW, _bkgrnd);
@@ -194,8 +223,15 @@ main(void)
     printf("\n");
     show_size(NCURSES_GLOBALS);
     show_offset(NCURSES_GLOBALS, init_signals);
+    show_offset(NCURSES_GLOBALS, tgetent_cache);
+    show_offset(NCURSES_GLOBALS, dbd_vars);
+#if HAVE_TSEARCH
+    show_offset(NCURSES_GLOBALS, cached_tparm);
+#endif
     show_DRIVER(NCURSES_GLOBALS, term_driver);
+#ifndef USE_SP_WINDOWLIST
     show_NORMAL(NCURSES_GLOBALS, _nc_windowlist);
+#endif
 #if USE_HOME_TERMINFO
     show_OPTION(NCURSES_GLOBALS, home_terminfo);
 #endif
@@ -208,14 +244,18 @@ main(void)
 #endif
     show_WIDECH(NCURSES_GLOBALS, key_name);
     show_TRACES(NCURSES_GLOBALS, trace_opened);
+    show_TRACES(NCURSES_GLOBALS, trace_level);
     show_MLEAKS(NCURSES_GLOBALS, leak_checking);
 
     printf("\n");
     show_size(NCURSES_PRESCREEN);
+    show_offset(NCURSES_PRESCREEN, tparm_state);
     show_offset(NCURSES_PRESCREEN, saved_tty);
     show_offset(NCURSES_PRESCREEN, use_tioctl);
     show_offset(NCURSES_PRESCREEN, _outch);
+#ifndef USE_SP_RIPOFF
     show_NORMAL(NCURSES_PRESCREEN, rippedoff);
+#endif
 #if NCURSES_NO_PADDING
     show_OPTION(NCURSES_PRESCREEN, _no_padding);
 #endif
@@ -224,6 +264,9 @@ main(void)
 #else
     show_REENTR(NCURSES_PRESCREEN, real_acs_map);
 #endif
+#if BROKEN_LINKER || USE_REENTRANT
+    show_TRACES(NCURSES_PRESCREEN, _outchars);
+#endif
 
     return EXIT_SUCCESS;
 }
diff --git a/contrib/ncurses/ncurses/term.priv.h b/contrib/ncurses/ncurses/term.priv.h
new file mode 100644
index 000000000000..1f436b5f8254
--- /dev/null
+++ b/contrib/ncurses/ncurses/term.priv.h
@@ -0,0 +1,364 @@
+/****************************************************************************
+ * Copyright 2021-2023,2024 Thomas E. Dickey                                *
+ *                                                                          *
+ * Permission is hereby granted, free of charge, to any person obtaining a  *
+ * copy of this software and associated documentation files (the            *
+ * "Software"), to deal in the Software without restriction, including      *
+ * without limitation the rights to use, copy, modify, merge, publish,      *
+ * distribute, distribute with modifications, sublicense, and/or sell       *
+ * copies of the Software, and to permit persons to whom the Software is    *
+ * furnished to do so, subject to the following conditions:                 *
+ *                                                                          *
+ * The above copyright notice and this permission notice shall be included  *
+ * in all copies or substantial portions of the Software.                   *
+ *                                                                          *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
+ *                                                                          *
+ * Except as contained in this notice, the name(s) of the above copyright   *
+ * holders shall not be used in advertising or otherwise to promote the     *
+ * sale, use or other dealings in this Software without prior written       *
+ * authorization.                                                           *
+ ****************************************************************************/
+
+/*
+ * $Id: term.priv.h,v 1.13 2024/03/02 20:43:06 tom Exp $
+ *
+ *	term.priv.h
+ *
+ *	Header file for terminfo library objects which are private to
+ *	the library.
+ */
+
+#ifndef _TERM_PRIV_H
+#define _TERM_PRIV_H 1
+/* *INDENT-OFF* */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <ncurses_cfg.h>
+
+#ifndef __NCURSES_H
+#include <curses.h>
+#endif
+
+#undef NCURSES_OPAQUE
+#define NCURSES_INTERNALS 1
+#define NCURSES_OPAQUE 0
+
+#if HAVE_LIMITS_H
+# include <limits.h>		/* PATH_MAX, MB_LEN_MAX, etc */
+#elif HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif
+
+#include <signal.h>		/* sig_atomic_t */
+#include <time.h>		/* time_t */
+#include <term.h>		/* time_t */
+
+#ifdef USE_PTHREADS
+#if USE_REENTRANT
+#include <pthread.h>
+#endif
+#endif
+
+/*
+ * If not properly configured to use the system's limits.h, we get gcc's
+ * fallback for limits.h which sets MB_LEN_MAX to 1, which is never correct.
+ */
+#if !HAVE_CONSISTENT_MB_LEN_MAX
+#undef MB_LEN_MAX
+#endif
+
+#ifndef MB_LEN_MAX
+#define MB_LEN_MAX 16	/* should be >= MB_CUR_MAX, but that may be a function */
+#endif
+
+#ifndef PATH_MAX
+# if defined(_POSIX_PATH_MAX)
+#  define PATH_MAX _POSIX_PATH_MAX
+# elif defined(MAXPATHLEN)
+#  define PATH_MAX MAXPATHLEN
+# else
+#  define PATH_MAX 255	/* the Posix minimum path-size */
+# endif
+#endif
+
+/*
+ * State of tparm().
+ */
+#define STACKSIZE 20
+
+typedef struct {
+	union {
+		int	num;
+		char *	str;
+	} data;
+	bool num_type;
+} STACK_FRAME;
+
+#define NUM_VARS 26
+
+typedef struct {
+	const char *	tparam_base;
+
+	STACK_FRAME	stack[STACKSIZE];
+	int		stack_ptr;
+
+	char *		out_buff;
+	size_t		out_size;
+	size_t		out_used;
+
+	char *		fmt_buff;
+	size_t		fmt_size;
+
+	int		static_vars[NUM_VARS];
+#ifdef TRACE
+	const char *	tname;
+#endif
+} TPARM_STATE;
+
+typedef struct {
+	char *		text;
+	size_t		size;
+} TRACEBUF;
+
+typedef struct {
+	const char *	name;
+	char *		value;
+} ITERATOR_VARS;
+
+/*
+ * Internals for term.h
+ */
+typedef struct term {			/* describe an actual terminal */
+	TERMTYPE	type;		/* terminal type description */
+	short		Filedes;	/* file description being written to */
+	TTY		Ottyb;		/* original state of the terminal */
+	TTY		Nttyb;		/* current state of the terminal */
+	int		_baudrate;	/* used to compute padding */
+	char *		_termname;	/* used for termname() */
+	TPARM_STATE	tparm_state;
+#if NCURSES_EXT_COLORS
+	TERMTYPE2	type2;		/* extended terminal type description */
+#endif
+#undef TERMINAL
+} TERMINAL;
+
+/*
+ * Internals for soft-keys
+ */
+typedef	struct {
+	WINDOW *	win;		/* the window used in the hook      */
+	int		line;		/* lines to take, < 0 => from bottom*/
+	int		(*hook)(WINDOW *, int); /* callback for user	    */
+} ripoff_t;
+
+/*
+ * Internals for tgetent
+ */
+typedef struct {
+	long		sequence;
+	bool		last_used;
+	char *		fix_sgr0;	/* this holds the filtered sgr0 string */
+	char *		last_bufp;	/* help with fix_sgr0 leak */
+	TERMINAL *	last_term;
+} TGETENT_CACHE;
+
+#define TGETENT_MAX 4
+
+#include <term_entry.h>		/* dbdLAST */
+
+#ifdef USE_TERM_DRIVER
+struct DriverTCB; /* Terminal Control Block forward declaration */
+#endif
+
+/*
+ * Global data which is not specific to a screen.
+ */
+typedef struct {
+	SIG_ATOMIC_T	have_sigtstp;
+	SIG_ATOMIC_T	have_sigwinch;
+	SIG_ATOMIC_T	cleanup_nested;
+
+	bool		init_signals;
+	bool		init_screen;
+
+	char *		comp_sourcename;
+	char *		comp_termtype;
+
+	bool		have_tic_directory;
+	bool		keep_tic_directory;
+	const char *	tic_directory;
+
+	char *		dbi_list;
+	int		dbi_size;
+
+	char *		first_name;
+	char **		keyname_table;
+	int		init_keyname;
+
+	int		slk_format;
+
+	int		getstr_limit;	/* getstr_limit based on POSIX LINE_MAX */
+
+	char *		safeprint_buf;
+	size_t		safeprint_used;
+
+	TGETENT_CACHE	tgetent_cache[TGETENT_MAX];
+	int		tgetent_index;
+	long		tgetent_sequence;
+	int		terminal_count;
+
+	char *		dbd_blob;	/* string-heap for dbd_list[] */
+	char **		dbd_list;	/* distinct places to look for data */
+	int		dbd_size;	/* length of dbd_list[] */
+	time_t		dbd_time;	/* cache last updated */
+	ITERATOR_VARS	dbd_vars[dbdLAST];
+
+#if HAVE_TSEARCH
+	void *		cached_tparm;
+	int		count_tparm;
+#endif /* HAVE_TSEARCH */
+
+#ifdef USE_TERM_DRIVER
+	int		(*term_driver)(struct DriverTCB*, const char*, int*);
+#endif
+
+#define WINDOWLIST struct _win_list
+
+#ifndef USE_SP_WINDOWLIST
+	WINDOWLIST *	_nc_windowlist;
+#define WindowList(sp)	_nc_globals._nc_windowlist
+#endif
+
+#if USE_HOME_TERMINFO
+	char *		home_terminfo;
+#endif
+
+#if !USE_SAFE_SPRINTF
+	int		safeprint_cols;
+	int		safeprint_rows;
+#endif
+
+#ifdef USE_PTHREADS
+	pthread_mutex_t	mutex_curses;
+	pthread_mutex_t	mutex_prescreen;
+	pthread_mutex_t	mutex_screen;
+	pthread_mutex_t	mutex_update;
+	pthread_mutex_t	mutex_tst_tracef;
+	pthread_mutex_t	mutex_tracef;
+	int		nested_tracef;
+	int		use_pthreads;
+#define _nc_use_pthreads	_nc_globals.use_pthreads
+#if USE_PTHREADS_EINTR
+	pthread_t	read_thread;	/* The reading thread */
+#endif
+#endif
+#if USE_WIDEC_SUPPORT
+	char		key_name[MB_LEN_MAX + 1];
+#endif
+
+#ifdef TRACE
+	bool		trace_opened;
+	int		trace_level;
+	FILE *		trace_fp;
+	int		trace_fd;
+
+	char *		tracearg_buf;
+	size_t		tracearg_used;
+
+	TRACEBUF *	tracebuf_ptr;
+	size_t		tracebuf_used;
+
+	char		tracechr_buf[40];
+
+	char *		tracedmp_buf;
+	size_t		tracedmp_used;
+
+	unsigned char *	tracetry_buf;
+	size_t		tracetry_used;
+
+	char		traceatr_color_buf[2][80];
+	int		traceatr_color_sel;
+	int		traceatr_color_last;
+#if !defined(USE_PTHREADS) && USE_REENTRANT
+	int		nested_tracef;
+#endif
+#endif	/* TRACE */
+
+#if NO_LEAKS
+	bool		leak_checking;
+#endif
+} NCURSES_GLOBALS;
+
+extern NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals;
+
+#define N_RIPS 5
+
+#ifdef USE_PTHREADS
+typedef struct _prescreen_list {
+	struct _prescreen_list *next;
+	pthread_t	id;
+	struct screen *	sp;
+} PRESCREEN_LIST;
+#endif
+
+/*
+ * Global data which can be swept up into a SCREEN when one is created.
+ * It may be modified before the next SCREEN is created.
+ */
+typedef struct {
+#ifdef USE_PTHREADS
+	PRESCREEN_LIST *allocated;
+#else
+	struct screen * allocated;
+#endif
+	bool		use_env;
+	bool		filter_mode;
+	attr_t		previous_attr;
+	TPARM_STATE	tparm_state;
+	TTY *		saved_tty;	/* savetty/resetty information	  */
+	bool		use_tioctl;
+	NCURSES_SP_OUTC	_outch;		/* output handler if not putc */
+#ifndef USE_SP_RIPOFF
+	ripoff_t	rippedoff[N_RIPS];
+	ripoff_t *	rsp;
+#endif
+#if NCURSES_NO_PADDING
+	bool		_no_padding;	/* flag to set if padding disabled */
+#endif
+#if BROKEN_LINKER || USE_REENTRANT
+	chtype *	real_acs_map;
+	int		_LINES;
+	int		_COLS;
+	int		_TABSIZE;
+	int		_ESCDELAY;
+	TERMINAL *	_cur_term;
+#endif
+#ifdef TRACE
+#if BROKEN_LINKER || USE_REENTRANT
+	long		_outchars;
+	const char *	_tputs_trace;
+#endif
+#endif
+} NCURSES_PRESCREEN;
+
+extern NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen;
+
+extern NCURSES_EXPORT(void) _nc_free_tparm(TERMINAL*);
+
+#ifdef __cplusplus
+}
+#endif
+
+/* *INDENT-ON* */
+
+#endif /* _TERM_PRIV_H */
diff --git a/contrib/ncurses/ncurses/tinfo/MKcaptab.sh b/contrib/ncurses/ncurses/tinfo/MKcaptab.sh
index c800023d105a..5f4135028f98 100755
--- a/contrib/ncurses/ncurses/tinfo/MKcaptab.sh
+++ b/contrib/ncurses/ncurses/tinfo/MKcaptab.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 ##############################################################################
-# Copyright 2019,2020 Thomas E. Dickey                                       #
+# Copyright 2019-2020,2023 Thomas E. Dickey                                  #
 # Copyright 2007-2010,2011 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -27,7 +27,7 @@
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
-# $Id: MKcaptab.sh,v 1.19 2020/02/02 23:34:34 tom Exp $
+# $Id: MKcaptab.sh,v 1.20 2023/04/22 15:12:57 tom Exp $
 
 if test $# != 0
 then
@@ -153,7 +153,6 @@ _nc_get_table(bool termcap)
     return termcap ? build_names(cap) : build_names(info);
 }
 
-/* entrypoint used by tack 1.07 */
 NCURSES_EXPORT(const HashValue *)
 _nc_get_hash_table(bool termcap)
 {
diff --git a/contrib/ncurses/ncurses/tinfo/MKfallback.sh b/contrib/ncurses/ncurses/tinfo/MKfallback.sh
index 64c65f197e0d..02b36ed739b2 100755
--- a/contrib/ncurses/ncurses/tinfo/MKfallback.sh
+++ b/contrib/ncurses/ncurses/tinfo/MKfallback.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 ##############################################################################
-# Copyright 2020 Thomas E. Dickey                                            #
+# Copyright 2020,2023 Thomas E. Dickey                                       #
 # Copyright 1998-2019,2020 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -27,7 +27,7 @@
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
-# $Id: MKfallback.sh,v 1.25 2020/08/16 15:58:44 tom Exp $
+# $Id: MKfallback.sh,v 1.26 2023/04/22 15:12:57 tom Exp $
 #
 # MKfallback.sh -- create fallback table for entry reads
 #
@@ -146,9 +146,6 @@ cat <<EOF
 #if NCURSES_EXT_NUMBERS
 #undef _nc_fallback
 
-/*
- * This entrypoint is used by tack 1.07
- */
 NCURSES_EXPORT(const TERMTYPE *)
 _nc_fallback (const char *name)
 {
diff --git a/contrib/ncurses/ncurses/tinfo/MKkeys_list.sh b/contrib/ncurses/ncurses/tinfo/MKkeys_list.sh
index 3b8beaee56f3..05ac8cf62578 100755
--- a/contrib/ncurses/ncurses/tinfo/MKkeys_list.sh
+++ b/contrib/ncurses/ncurses/tinfo/MKkeys_list.sh
@@ -1,7 +1,7 @@
 #! /bin/sh
-# $Id: MKkeys_list.sh,v 1.7 2020/02/02 23:34:34 tom Exp $
+# $Id: MKkeys_list.sh,v 1.9 2024/01/19 12:26:30 tom Exp $
 ##############################################################################
-# Copyright 2019,2020 Thomas E. Dickey                                       #
+# Copyright 2019-2022,2024 Thomas E. Dickey                                  #
 # Copyright 2001-2003,2017 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -36,6 +36,7 @@
 # Extract function-key names from the Caps file
 #
 : ${AWK-awk}
+: ${USE_SIGWINCH-0}
 if test $# != 0
 then
 	DATA="$*"
@@ -44,7 +45,8 @@ else
 fi
 
 data=data$$
-trap 'rm -f $data' EXIT INT QUIT TERM HUP
+trap 'rm -f $data; exit 1' 1 2 3 15
+trap 'rm -f $data' 0
 cat $DATA | sed -e 's/[	][	]*/	/g' >$data
 
 cat <<EOF
@@ -52,8 +54,8 @@ cat <<EOF
 KEY_BREAK
 KEY_SRESET
 KEY_RESET
-KEY_RESIZE
 EOF
+test "$USE_SIGWINCH" = 1 && echo KEY_RESIZE
 
 ${AWK-awk} <$data '
 /^#/		{next;}
diff --git a/contrib/ncurses/ncurses/tinfo/access.c b/contrib/ncurses/ncurses/tinfo/access.c
index 15593688266e..50a5769c3d63 100644
--- a/contrib/ncurses/ncurses/tinfo/access.c
+++ b/contrib/ncurses/ncurses/tinfo/access.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 2019-2021,2023 Thomas E. Dickey                                *
  * Copyright 1998-2011,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -35,9 +35,24 @@
 
 #include <ctype.h>
 
+#ifndef USE_ROOT_ACCESS
+#if HAVE_SETFSUID
+#include <sys/fsuid.h>
+#else
+#include <sys/stat.h>
+#endif
+#endif
+
+#if HAVE_GETAUXVAL && HAVE_SYS_AUXV_H && defined(__GLIBC__) && (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 19)
+#include <sys/auxv.h>
+#define USE_GETAUXVAL 1
+#else
+#define USE_GETAUXVAL 0
+#endif
+
 #include <tic.h>
 
-MODULE_ID("$Id: access.c,v 1.27 2020/08/29 16:22:03 juergen Exp $")
+MODULE_ID("$Id: access.c,v 1.37 2023/06/24 21:55:09 tom Exp $")
 
 #define LOWERCASE(c) ((isalpha(UChar(c)) && isupper(UChar(c))) ? tolower(UChar(c)) : (c))
 
@@ -55,8 +70,8 @@ _nc_rootname(char *path)
     static char *temp;
     char *s;
 
-    temp = strdup(result);
-    result = temp;
+    if ((temp = strdup(result)) != 0)
+	result = temp;
 #if !MIXEDCASE_FILENAMES
     for (s = result; *s != '\0'; ++s) {
 	*s = (char) LOWERCASE(*s);
@@ -169,23 +184,101 @@ _nc_is_file_path(const char *path)
     return result;
 }
 
-#ifndef USE_ROOT_ENVIRON
+#if HAVE_GETEUID && HAVE_GETEGID
+#define is_posix_elevated() \
+	(getuid() != geteuid() \
+	 || getgid() != getegid())
+#else
+#define is_posix_elevated() FALSE
+#endif
+
+#if HAVE_ISSETUGID
+#define is_elevated() issetugid()
+#elif USE_GETAUXVAL && defined(AT_SECURE)
+#define is_elevated() \
+	(getauxval(AT_SECURE) \
+	 ? TRUE \
+	 : (errno != ENOENT \
+	    ? FALSE \
+	    : is_posix_elevated()))
+#else
+#define is_elevated() is_posix_elevated()
+#endif
+
+#if HAVE_SETFSUID
+#define lower_privileges() \
+	    int save_err = errno; \
+	    setfsuid(getuid()); \
+	    setfsgid(getgid()); \
+	    errno = save_err
+#define resume_elevation() \
+	    save_err = errno; \
+	    setfsuid(geteuid()); \
+	    setfsgid(getegid()); \
+	    errno = save_err
+#else
+#define lower_privileges()	/* nothing */
+#define resume_elevation()	/* nothing */
+#endif
+
 /*
- * Returns true if we allow application to use environment variables that are
- * used for searching lists of directories, etc.
+ * Returns true if not running as root or setuid.  We use this check to allow
+ * applications to use environment variables that are used for searching lists
+ * of directories, etc.
  */
 NCURSES_EXPORT(int)
 _nc_env_access(void)
 {
-#if HAVE_ISSETUGID
-    if (issetugid())
-	return FALSE;
-#elif HAVE_GETEUID && HAVE_GETEGID
-    if (getuid() != geteuid()
-	|| getgid() != getegid())
-	return FALSE;
-#endif
-    /* ...finally, disallow root */
-    return (getuid() != ROOT_UID) && (geteuid() != ROOT_UID);
+    int result = TRUE;
+
+#if HAVE_GETUID && HAVE_GETEUID
+#if !defined(USE_SETUID_ENVIRON)
+    if (is_elevated()) {
+	result = FALSE;
+    }
+#endif
+#if !defined(USE_ROOT_ENVIRON)
+    if ((getuid() == ROOT_UID) || (geteuid() == ROOT_UID)) {
+	result = FALSE;
+    }
+#endif
+#endif /* HAVE_GETUID && HAVE_GETEUID */
+    return result;
+}
+
+#ifndef USE_ROOT_ACCESS
+/*
+ * Limit privileges if possible; otherwise disallow access for updating files.
+ */
+NCURSES_EXPORT(FILE *)
+_nc_safe_fopen(const char *path, const char *mode)
+{
+    FILE *result = NULL;
+#if HAVE_SETFSUID
+    lower_privileges();
+    result = fopen(path, mode);
+    resume_elevation();
+#else
+    if (!is_elevated() || *mode == 'r') {
+	result = fopen(path, mode);
+    }
+#endif
+    return result;
 }
+
+NCURSES_EXPORT(int)
+_nc_safe_open3(const char *path, int flags, mode_t mode)
+{
+    int result = -1;
+#if HAVE_SETFSUID
+    lower_privileges();
+    result = open(path, flags, mode);
+    resume_elevation();
+#else
+    if (!is_elevated() || (flags & O_RDONLY)) {
+	result = open(path, flags, mode);
+    }
 #endif
+    return result;
+}
+#endif /* USE_ROOT_ACCESS */
diff --git a/contrib/ncurses/ncurses/tinfo/add_tries.c b/contrib/ncurses/ncurses/tinfo/add_tries.c
index d41f488300ae..9d215575fec0 100644
--- a/contrib/ncurses/ncurses/tinfo/add_tries.c
+++ b/contrib/ncurses/ncurses/tinfo/add_tries.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 2019-2020,2023 Thomas E. Dickey                                *
  * Copyright 1998-2009,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -39,8 +39,9 @@
 */
 
 #include <curses.priv.h>
+#include <tic.h>
 
-MODULE_ID("$Id: add_tries.c,v 1.12 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: add_tries.c,v 1.13 2023/06/24 15:36:13 tom Exp $")
 
 #define SET_TRY(dst,src) if ((dst->ch = *src++) == 128) dst->ch = '\0'
 #define CMP_TRY(a,b) ((a)? (a == b) : (b == 128))
@@ -53,7 +54,7 @@ _nc_add_to_try(TRIES ** tree, const char *str, unsigned code)
 
     T((T_CALLED("_nc_add_to_try(%p, %s, %u)"),
        (void *) *tree, _nc_visbuf(str), code));
-    if (txt == 0 || *txt == '\0' || code == 0)
+    if (!VALID_STRING(str) || *txt == '\0' || code == 0)
 	returnCode(ERR);
 
     if ((*tree) != 0) {
diff --git a/contrib/ncurses/ncurses/tinfo/alloc_entry.c b/contrib/ncurses/ncurses/tinfo/alloc_entry.c
index 4bf7d6c8a082..6280ad4a2b2f 100644
--- a/contrib/ncurses/ncurses/tinfo/alloc_entry.c
+++ b/contrib/ncurses/ncurses/tinfo/alloc_entry.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
  * Copyright 1998-2013,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -48,13 +48,11 @@
 
 #include <tic.h>
 
-MODULE_ID("$Id: alloc_entry.c,v 1.64 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: alloc_entry.c,v 1.79 2023/09/15 08:16:12 tom Exp $")
 
 #define ABSENT_OFFSET    -1
 #define CANCELLED_OFFSET -2
 
-#define MAX_STRTAB	4096	/* documented maximum entry size */
-
 static char *stringbuf;		/* buffer for string capabilities */
 static size_t next_free;	/* next free character in stringbuf */
 
@@ -62,63 +60,77 @@ NCURSES_EXPORT(void)
 _nc_init_entry(ENTRY * const tp)
 /* initialize a terminal type data block */
 {
+    DEBUG(2, (T_CALLED("_nc_init_entry(tp=%p)"), (void *) tp));
+
+    if (tp == NULL) {
 #if NO_LEAKS
-    if (tp == 0) {
-	if (stringbuf != 0) {
+	if (stringbuf != NULL) {
 	    FreeAndNull(stringbuf);
 	}
 	return;
-    }
+#else
+	_nc_err_abort("_nc_init_entry called without initialization");
 #endif
+    }
 
-    if (stringbuf == 0)
-	TYPE_MALLOC(char, (size_t) MAX_STRTAB, stringbuf);
+    if (stringbuf == NULL)
+	TYPE_CALLOC(char, (size_t) MAX_ENTRY_SIZE, stringbuf);
 
     next_free = 0;
 
     _nc_init_termtype(&(tp->tterm));
+
+    DEBUG(2, (T_RETURN("")));
 }
 
 NCURSES_EXPORT(ENTRY *)
 _nc_copy_entry(ENTRY * oldp)
 {
-    ENTRY *newp = typeCalloc(ENTRY, 1);
+    ENTRY *newp;
 
-    if (newp != 0) {
+    DEBUG(2, (T_CALLED("_nc_copy_entry(oldp=%p)"), (void *) oldp));
+
+    newp = typeCalloc(ENTRY, 1);
+    if (newp != NULL) {
 	*newp = *oldp;
 	_nc_copy_termtype2(&(newp->tterm), &(oldp->tterm));
     }
-    return newp;
+
+    DEBUG(2, (T_RETURN("%p"), (void *) newp));
+    return (newp);
 }
 
 /* save a copy of string in the string buffer */
 NCURSES_EXPORT(char *)
-_nc_save_str(const char *const string)
+_nc_save_str(const char *string)
 {
     char *result = 0;
     size_t old_next_free = next_free;
-    size_t len;
-
-    if (!VALID_STRING(string))
-	return _nc_save_str("");
-    len = strlen(string) + 1;
-
-    if (len == 1 && next_free != 0) {
-	/*
-	 * Cheat a little by making an empty string point to the end of the
-	 * previous string.
-	 */
-	if (next_free < MAX_STRTAB) {
-	    result = (stringbuf + next_free - 1);
+
+    if (stringbuf != NULL) {
+	size_t len;
+
+	if (!VALID_STRING(string))
+	    string = "";
+	len = strlen(string) + 1;
+
+	if (len == 1 && next_free != 0) {
+	    /*
+	     * Cheat a little by making an empty string point to the end of the
+	     * previous string.
+	     */
+	    if (next_free < MAX_ENTRY_SIZE) {
+		result = (stringbuf + next_free - 1);
+	    }
+	} else if (next_free + len < MAX_ENTRY_SIZE) {
+	    _nc_STRCPY(&stringbuf[next_free], string, MAX_ENTRY_SIZE);
+	    DEBUG(7, ("Saved string %s", _nc_visbuf(string)));
+	    DEBUG(7, ("at location %d", (int) next_free));
+	    next_free += len;
+	    result = (stringbuf + old_next_free);
+	} else {
+	    _nc_warning("Too much data, some is lost: %s", string);
 	}
-    } else if (next_free + len < MAX_STRTAB) {
-	_nc_STRCPY(&stringbuf[next_free], string, MAX_STRTAB);
-	DEBUG(7, ("Saved string %s", _nc_visbuf(string)));
-	DEBUG(7, ("at location %d", (int) next_free));
-	next_free += len;
-	result = (stringbuf + old_next_free);
-    } else {
-	_nc_warning("Too much data, some is lost: %s", string);
     }
     return result;
 }
@@ -130,17 +142,23 @@ _nc_wrap_entry(ENTRY * const ep, bool copy_strings)
     int offsets[MAX_ENTRY_SIZE / sizeof(short)];
     int useoffsets[MAX_USES];
     unsigned i, n;
-    unsigned nuses = ep->nuses;
-    TERMTYPE2 *tp = &(ep->tterm);
+    unsigned nuses;
+    TERMTYPE2 *tp;
+
+    DEBUG(2, (T_CALLED("_nc_wrap_entry(ep=%p, copy_strings=%d)"), (void *)
+	      ep, copy_strings));
+    if (ep == NULL || stringbuf == NULL)
+	_nc_err_abort("_nc_wrap_entry called without initialization");
 
+    nuses = ep->nuses;
+    tp = &(ep->tterm);
     if (copy_strings) {
 	next_free = 0;		/* clear static storage */
 
 	/* copy term_names, Strings, uses */
 	tp->term_names = _nc_save_str(tp->term_names);
 	for_each_string(i, tp) {
-	    if (tp->Strings[i] != ABSENT_STRING &&
-		tp->Strings[i] != CANCELLED_STRING) {
+	    if (VALID_STRING(tp->Strings[i])) {
 		tp->Strings[i] = _nc_save_str(tp->Strings[i]);
 	    }
 	}
@@ -215,11 +233,13 @@ _nc_wrap_entry(ENTRY * const ep, bool copy_strings)
 #endif
 
     for (i = 0; i < nuses; i++) {
-	if (useoffsets[i] == ABSENT_OFFSET)
+	if (useoffsets[i] == ABSENT_OFFSET) {
 	    ep->uses[i].name = 0;
-	else
-	    ep->uses[i].name = (tp->str_table + useoffsets[i]);
+	} else {
+	    ep->uses[i].name = strdup(tp->str_table + useoffsets[i]);
+	}
     }
+    DEBUG(2, (T_RETURN("")));
 }
 
 NCURSES_EXPORT(void)
@@ -230,6 +250,8 @@ _nc_merge_entry(ENTRY * const target, ENTRY * const source)
     TERMTYPE2 *from = &(source->tterm);
 #if NCURSES_XNAMES
     TERMTYPE2 copy;
+    size_t str_size, copy_size;
+    char *str_table;
 #endif
     unsigned i;
 
@@ -240,9 +262,102 @@ _nc_merge_entry(ENTRY * const target, ENTRY * const source)
     _nc_copy_termtype2(&copy, from);
     from = &copy;
     _nc_align_termtype(to, from);
+    /*
+     * compute the maximum size of the string-table.
+     */
+    str_size = strlen(to->term_names) + 1;
+    for_each_string(i, from) {
+	if (VALID_STRING(from->Strings[i]))
+	    str_size += strlen(from->Strings[i]) + 1;
+    }
+    for_each_string(i, to) {
+	if (VALID_STRING(to->Strings[i]))
+	    str_size += strlen(to->Strings[i]) + 1;
+    }
+    /* allocate a string-table large enough for both source/target, and
+     * copy all of the strings into that table.  In the merge, we will
+     * select from the original source/target lists to construct a new
+     * target list.
+     */
+    if (str_size != 0) {
+	char *str_copied;
+	if ((str_table = malloc(str_size)) == NULL)
+	    _nc_err_abort(MSG_NO_MEMORY);
+	str_copied = str_table;
+	_nc_STRCPY(str_copied, to->term_names, str_size);
+	to->term_names = str_copied;
+	copy_size = strlen(str_copied) + 1;
+	str_copied += copy_size;
+	str_size -= copy_size;
+	for_each_string(i, from) {
+	    if (VALID_STRING(from->Strings[i])) {
+		_nc_STRCPY(str_copied, from->Strings[i], str_size);
+		from->Strings[i] = str_copied;
+		copy_size = strlen(str_copied) + 1;
+		str_copied += copy_size;
+		str_size -= copy_size;
+	    }
+	}
+	for_each_string(i, to) {
+	    if (VALID_STRING(to->Strings[i])) {
+		_nc_STRCPY(str_copied, to->Strings[i], str_size);
+		to->Strings[i] = str_copied;
+		copy_size = strlen(str_copied) + 1;
+		str_copied += copy_size;
+		str_size -= copy_size;
+	    }
+	}
+	free(to->str_table);
+	to->str_table = str_table;
+	free(from->str_table);
+    }
+    /*
+     * Do the same for the extended-strings (i.e., lists of capabilities).
+     */
+    str_size = 0;
+    for (i = 0; i < NUM_EXT_NAMES(from); ++i) {
+	if (VALID_STRING(from->ext_Names[i]))
+	    str_size += strlen(from->ext_Names[i]) + 1;
+    }
+    for (i = 0; i < NUM_EXT_NAMES(to); ++i) {
+	if (VALID_STRING(to->ext_Names[i]))
+	    str_size += strlen(to->ext_Names[i]) + 1;
+    }
+    /* allocate a string-table large enough for both source/target, and
+     * copy all of the strings into that table.  In the merge, we will
+     * select from the original source/target lists to construct a new
+     * target list.
+     */
+    if (str_size != 0) {
+	char *str_copied;
+	if ((str_table = malloc(str_size)) == NULL)
+	    _nc_err_abort(MSG_NO_MEMORY);
+	str_copied = str_table;
+	for (i = 0; i < NUM_EXT_NAMES(from); ++i) {
+	    if (VALID_STRING(from->ext_Names[i])) {
+		_nc_STRCPY(str_copied, from->ext_Names[i], str_size);
+		from->ext_Names[i] = str_copied;
+		copy_size = strlen(str_copied) + 1;
+		str_copied += copy_size;
+		str_size -= copy_size;
+	    }
+	}
+	for (i = 0; i < NUM_EXT_NAMES(to); ++i) {
+	    if (VALID_STRING(to->ext_Names[i])) {
+		_nc_STRCPY(str_copied, to->ext_Names[i], str_size);
+		to->ext_Names[i] = str_copied;
+		copy_size = strlen(str_copied) + 1;
+		str_copied += copy_size;
+		str_size -= copy_size;
+	    }
+	}
+	free(to->ext_str_table);
+	to->ext_str_table = str_table;
+	free(from->ext_str_table);
+    }
 #endif
     for_each_boolean(i, from) {
-	if (to->Booleans[i] != (char) CANCELLED_BOOLEAN) {
+	if (to->Booleans[i] != (NCURSES_SBOOL) CANCELLED_BOOLEAN) {
 	    int mergebool = from->Booleans[i];
 
 	    if (mergebool == CANCELLED_BOOLEAN)
@@ -279,10 +394,7 @@ _nc_merge_entry(ENTRY * const target, ENTRY * const source)
 	}
     }
 #if NCURSES_XNAMES
-    /* Discard the data allocated in _nc_copy_termtype2, but do not use
-     * _nc_free_termtype2 because that frees the string-table (which is
-     * not allocated by _nc_copy_termtype2).
-     */
+    /* cleanup */
     free(copy.Booleans);
     free(copy.Numbers);
     free(copy.Strings);
@@ -294,7 +406,7 @@ _nc_merge_entry(ENTRY * const target, ENTRY * const source)
 NCURSES_EXPORT(void)
 _nc_alloc_entry_leaks(void)
 {
-    if (stringbuf != 0) {
+    if (stringbuf != NULL) {
 	FreeAndNull(stringbuf);
     }
     next_free = 0;
diff --git a/contrib/ncurses/ncurses/tinfo/alloc_ttype.c b/contrib/ncurses/ncurses/tinfo/alloc_ttype.c
index 222868ecefcd..304c1b62f4e6 100644
--- a/contrib/ncurses/ncurses/tinfo/alloc_ttype.c
+++ b/contrib/ncurses/ncurses/tinfo/alloc_ttype.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
  * Copyright 1999-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -43,7 +43,7 @@
 
 #include <tic.h>
 
-MODULE_ID("$Id: alloc_ttype.c,v 1.33 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: alloc_ttype.c,v 1.51 2023/09/09 23:15:53 tom Exp $")
 
 #if NCURSES_XNAMES
 /*
@@ -377,6 +377,9 @@ adjust_cancels(TERMTYPE2 *to, TERMTYPE2 *from)
     int last = first + to->ext_Strings;
     int j, k;
 
+    DEBUG(3, (T_CALLED("adjust_cancels(%s), from(%s)"),
+	      NonNull(to->term_names),
+	      NonNull(from->term_names)));
     for (j = first; j < last;) {
 	char *name = to->ext_Names[j];
 	int j_str = to->num_Strings - first - to->ext_Strings;
@@ -413,6 +416,7 @@ adjust_cancels(TERMTYPE2 *to, TERMTYPE2 *from)
 	    j++;
 	}
     }
+    DEBUG(3, (T_RETURN("")));
 }
 
 NCURSES_EXPORT(void)
@@ -425,11 +429,11 @@ _nc_align_termtype(TERMTYPE2 *to, TERMTYPE2 *from)
     na = to ? ((int) NUM_EXT_NAMES(to)) : 0;
     nb = from ? ((int) NUM_EXT_NAMES(from)) : 0;
 
-    DEBUG(2, ("align_termtype to(%d:%s), from(%d:%s)",
+    DEBUG(2, (T_CALLED("_nc_align_termtype to(%d:%s), from(%d:%s)"),
 	      na, to ? NonNull(to->term_names) : "?",
 	      nb, from ? NonNull(from->term_names) : "?"));
 
-    if (na != 0 || nb != 0) {
+    if (to != NULL && from != NULL && (na != 0 || nb != 0)) {
 	int ext_Booleans, ext_Numbers, ext_Strings;
 	bool used_ext_Names = FALSE;
 
@@ -446,11 +450,13 @@ _nc_align_termtype(TERMTYPE2 *to, TERMTYPE2 *from)
 		    break;
 		}
 	    }
-	    if (same)
+	    if (same) {
+		DEBUG(2, (T_RETURN("")));
 		return;
+	    }
 	}
 	/*
-	 * This is where we pay for having a simple extension representation. 
+	 * This is where we pay for having a simple extension representation.
 	 * Allocate a new ext_Names array and merge the two ext_Names arrays
 	 * into it, updating to's counts for booleans, etc.  Fortunately we do
 	 * this only for the terminfo compiler (tic) and comparer (infocmp).
@@ -507,6 +513,7 @@ _nc_align_termtype(TERMTYPE2 *to, TERMTYPE2 *from)
 	if (!used_ext_Names)
 	    free(ext_Names);
     }
+    DEBUG(2, (T_RETURN("")));
 }
 #endif
 
@@ -520,15 +527,17 @@ _nc_align_termtype(TERMTYPE2 *to, TERMTYPE2 *from)
 static void
 copy_termtype(TERMTYPE2 *dst, const TERMTYPE2 *src, int mode)
 {
-#if NCURSES_XNAMES || NCURSES_EXT_NUMBERS
     unsigned i;
-#endif
+    int pass;
+    char *new_table;
+    size_t new_table_size;
 #if NCURSES_EXT_NUMBERS
     short *oldptr = 0;
     int *newptr = 0;
 #endif
 
-    DEBUG(2, ("copy_termtype"));
+    DEBUG(2, (T_CALLED("copy_termtype(dst=%p, src=%p, mode=%d)"), (void *)
+	      dst, (const void *) src, mode));
     *dst = *src;		/* ...to copy the sizes and string-tables */
 
     TYPE_MALLOC(NCURSES_SBOOL, NUM_BOOLEANS(dst), dst->Booleans);
@@ -541,6 +550,40 @@ copy_termtype(TERMTYPE2 *dst, const TERMTYPE2 *src, int mode)
 	   src->Strings,
 	   NUM_STRINGS(dst) * sizeof(dst->Strings[0]));
 
+    new_table = NULL;
+    new_table_size = 0;
+    for (pass = 0; pass < 2; ++pass) {
+	size_t str_size = 0;
+	if (src->term_names != NULL) {
+	    if (pass) {
+		dst->term_names = new_table + str_size;
+		_nc_STRCPY(dst->term_names + str_size,
+			   src->term_names,
+			   new_table_size - str_size);
+	    }
+	    str_size += strlen(src->term_names) + 1;
+	}
+	for_each_string(i, src) {
+	    if (VALID_STRING(src->Strings[i])) {
+		if (pass) {
+		    _nc_STRCPY(new_table + str_size,
+			       src->Strings[i],
+			       new_table_size - str_size);
+		    dst->Strings[i] = new_table + str_size;
+		}
+		str_size += strlen(src->Strings[i]) + 1;
+	    }
+	}
+	if (pass) {
+	    dst->str_table = new_table;
+	} else {
+	    ++str_size;
+	    if ((new_table = malloc(str_size)) == NULL)
+		_nc_err_abort(MSG_NO_MEMORY);
+	    new_table_size = str_size;
+	}
+    }
+
 #if NCURSES_EXT_NUMBERS
     if ((mode & dstINT) == 0) {
 	DEBUG(2, ("...convert int ->short"));
@@ -584,36 +627,75 @@ copy_termtype(TERMTYPE2 *dst, const TERMTYPE2 *src, int mode)
 	   NUM_NUMBERS(dst) * sizeof(dst->Numbers[0]));
 #endif
 
-    /* FIXME: we probably should also copy str_table and ext_str_table,
-     * but tic and infocmp are not written to exploit that (yet).
-     */
-
 #if NCURSES_XNAMES
     if ((i = NUM_EXT_NAMES(src)) != 0) {
 	TYPE_MALLOC(char *, i, dst->ext_Names);
 	memcpy(dst->ext_Names, src->ext_Names, i * sizeof(char *));
+
+	new_table = NULL;
+	new_table_size = 0;
+	for (pass = 0; pass < 2; ++pass) {
+	    size_t str_size = 0;
+	    char *raw_data = src->ext_str_table;
+	    if (raw_data != NULL) {
+		for (i = 0; i < src->ext_Strings; ++i) {
+		    size_t skip = strlen(raw_data) + 1;
+		    if (skip != 1) {
+			if (pass) {
+			    _nc_STRCPY(new_table + str_size,
+				       raw_data,
+				       new_table_size - str_size);
+			}
+			str_size += skip;
+			raw_data += skip;
+		    }
+		}
+	    }
+	    for (i = 0; i < NUM_EXT_NAMES(dst); ++i) {
+		if (VALID_STRING(src->ext_Names[i])) {
+		    if (pass) {
+			_nc_STRCPY(new_table + str_size,
+				   src->ext_Names[i],
+				   new_table_size - str_size);
+			dst->ext_Names[i] = new_table + str_size;
+		    }
+		    str_size += strlen(src->ext_Names[i]) + 1;
+		}
+	    }
+	    if (pass) {
+		dst->ext_str_table = new_table;
+	    } else {
+		++str_size;
+		if ((new_table = calloc(str_size, 1)) == NULL)
+		    _nc_err_abort(MSG_NO_MEMORY);
+		new_table_size = str_size;
+	    }
+	}
     } else {
 	dst->ext_Names = 0;
     }
 #endif
+    (void) new_table_size;
+    DEBUG(2, (T_RETURN("")));
 }
 
-/*
- * This entrypoint is used by tack 1.07
- */
 NCURSES_EXPORT(void)
 _nc_copy_termtype(TERMTYPE *dst, const TERMTYPE *src)
 {
-    DEBUG(2, ("_nc_copy_termtype..."));
+    DEBUG(2, (T_CALLED("_nc_copy_termtype(dst=%p, src=%p)"), (void *) dst,
+	      (const void *) src));
     copy_termtype((TERMTYPE2 *) dst, (const TERMTYPE2 *) src, 0);
+    DEBUG(2, (T_RETURN("")));
 }
 
 #if NCURSES_EXT_NUMBERS
 NCURSES_EXPORT(void)
 _nc_copy_termtype2(TERMTYPE2 *dst, const TERMTYPE2 *src)
 {
-    DEBUG(2, ("_nc_copy_termtype2..."));
+    DEBUG(2, (T_CALLED("_nc_copy_termtype2(dst=%p, src=%p)"), (void *) dst,
+	      (const void *) src));
     copy_termtype(dst, src, srcINT | dstINT);
+    DEBUG(2, (T_RETURN("")));
 }
 
 /*
@@ -623,7 +705,9 @@ _nc_copy_termtype2(TERMTYPE2 *dst, const TERMTYPE2 *src)
 NCURSES_EXPORT(void)
 _nc_export_termtype2(TERMTYPE *dst, const TERMTYPE2 *src)
 {
-    DEBUG(2, ("_nc_export_termtype2..."));
+    DEBUG(2, (T_CALLED("_nc_export_termtype2(dst=%p, src=%p)"), (void *)
+	      dst, (const void *) src));
     copy_termtype((TERMTYPE2 *) dst, src, srcINT);
+    DEBUG(2, (T_RETURN("")));
 }
 #endif /* NCURSES_EXT_NUMBERS */
diff --git a/contrib/ncurses/ncurses/tinfo/captoinfo.c b/contrib/ncurses/ncurses/tinfo/captoinfo.c
index de0133b386c6..7e14731df368 100644
--- a/contrib/ncurses/ncurses/tinfo/captoinfo.c
+++ b/contrib/ncurses/ncurses/tinfo/captoinfo.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2020,2021 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -98,7 +98,7 @@
 #include <ctype.h>
 #include <tic.h>
 
-MODULE_ID("$Id: captoinfo.c,v 1.100 2020/07/08 21:39:54 tom Exp $")
+MODULE_ID("$Id: captoinfo.c,v 1.102 2021/09/04 10:29:15 tom Exp $")
 
 #if 0
 #define DEBUG_THIS(p) DEBUG(9, p)
@@ -634,7 +634,10 @@ _nc_infotocap(const char *cap GCC_UNUSED, const char *str, int const parameteriz
 	int offset;
     } fixups[MAX_TC_FIXUPS];
 
-    DEBUG_THIS(("_nc_infotocap params %d, %s", parameterized, str));
+    DEBUG_THIS(("_nc_infotocap %s params %d, %s",
+		_nc_strict_bsd ? "strict" : "loose",
+		parameterized,
+		_nc_visbuf(str)));
 
     /* we may have to move some trailing mandatory padding up front */
     padding = str + strlen(str) - 1;
@@ -673,6 +676,11 @@ _nc_infotocap(const char *cap GCC_UNUSED, const char *str, int const parameteriz
 		bufptr = save_char(bufptr, *str++);
 		bufptr = save_char(bufptr, *str);
 	    }
+	} else if (str[0] == ':') {
+	    bufptr = save_char(bufptr, '\\');
+	    bufptr = save_char(bufptr, '0');
+	    bufptr = save_char(bufptr, '7');
+	    bufptr = save_char(bufptr, '2');
 	} else if (str[0] == '\\') {
 	    if (str[1] == '\0' || (str + 1) == trimmed) {
 		bufptr = save_string(bufptr, "\\134");
@@ -932,7 +940,7 @@ _nc_infotocap(const char *cap GCC_UNUSED, const char *str, int const parameteriz
 		break;
 
 		/*
-		 * %s isn't in termcap, but it's convenient to pass it through
+		 * %s isn't in termcap, but it is convenient to pass it through
 		 * so we can represent things like terminfo pfkey strings in
 		 * termcap notation.
 		 */
diff --git a/contrib/ncurses/ncurses/tinfo/comp_error.c b/contrib/ncurses/ncurses/tinfo/comp_error.c
index 48f48784d8db..3e6b4022a74b 100644
--- a/contrib/ncurses/ncurses/tinfo/comp_error.c
+++ b/contrib/ncurses/ncurses/tinfo/comp_error.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 2019-2020,2023 Thomas E. Dickey                                *
  * Copyright 1998-2012,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -42,7 +42,7 @@
 
 #include <tic.h>
 
-MODULE_ID("$Id: comp_error.c,v 1.40 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: comp_error.c,v 1.44 2023/06/15 20:27:02 tom Exp $")
 
 NCURSES_EXPORT_VAR(bool) _nc_suppress_warnings = FALSE;
 NCURSES_EXPORT_VAR(int) _nc_curr_line = 0; /* current line # in input */
@@ -60,8 +60,15 @@ _nc_get_source(void)
 NCURSES_EXPORT(void)
 _nc_set_source(const char *const name)
 {
-    FreeIfNeeded(SourceName);
-    SourceName = strdup(name);
+    if (name == NULL) {
+	free(SourceName);
+	SourceName = NULL;
+    } else if (SourceName == NULL) {
+	SourceName = strdup(name);
+    } else if (strcmp(name, SourceName)) {
+	free(SourceName);
+	SourceName = strdup(name);
+    }
 }
 
 NCURSES_EXPORT(void)
@@ -95,9 +102,9 @@ static NCURSES_INLINE void
 where_is_problem(void)
 {
     fprintf(stderr, "\"%s\"", SourceName ? SourceName : "?");
-    if (_nc_curr_line >= 0)
+    if (_nc_curr_line > 0)
 	fprintf(stderr, ", line %d", _nc_curr_line);
-    if (_nc_curr_col >= 0)
+    if (_nc_curr_col > 0)
 	fprintf(stderr, ", col %d", _nc_curr_col);
     if (TermType != 0 && TermType[0] != '\0')
 	fprintf(stderr, ", terminal '%s'", TermType);
@@ -148,9 +155,7 @@ _nc_syserr_abort(const char *const fmt, ...)
     /* If we're debugging, try to show where the problem occurred - this
      * will dump core.
      */
-#ifndef USE_ROOT_ENVIRON
-    if (getuid() != ROOT_UID)
-#endif
+    if (_nc_env_access())
 	abort();
 #endif
     /* Dumping core in production code is not a good idea.
diff --git a/contrib/ncurses/ncurses/tinfo/comp_expand.c b/contrib/ncurses/ncurses/tinfo/comp_expand.c
index 02e38e6e3c7a..e971384f52f2 100644
--- a/contrib/ncurses/ncurses/tinfo/comp_expand.c
+++ b/contrib/ncurses/ncurses/tinfo/comp_expand.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020-2021,2023 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -36,7 +36,7 @@
 #include <ctype.h>
 #include <tic.h>
 
-MODULE_ID("$Id: comp_expand.c,v 1.32 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: comp_expand.c,v 1.35 2023/04/28 20:59:06 tom Exp $")
 
 #if 0
 #define DEBUG_THIS(p) DEBUG(9, p)
@@ -87,7 +87,10 @@ _nc_tic_expand(const char *srcp, bool tic_format, int numbers)
 	      return 0;
     }
 
-    DEBUG_THIS(("_nc_tic_expand %s", _nc_visbuf(srcp)));
+    DEBUG_THIS(("_nc_tic_expand %s:%s:%s",
+		tic_format ? "ti" : "tc",
+		numbers ? "#" : "",
+		_nc_visbuf(srcp)));
     bufp = 0;
     while ((ch = UChar(*str)) != 0) {
 	if (ch == '%' && REALPRINT(str + 1)) {
@@ -126,7 +129,6 @@ _nc_tic_expand(const char *srcp, bool tic_format, int numbers)
 		    if (dst != 0
 			&& *dst == R_BRACE
 			&& value < 127
-			&& value != '\\'	/* FIXME */
 			&& isprint((int) value)) {
 			ch = (int) value;
 			buffer[bufp++] = S_QUOTE;
@@ -162,12 +164,12 @@ _nc_tic_expand(const char *srcp, bool tic_format, int numbers)
 					       trailing_spaces(str))) {
 	    buffer[bufp++] = '\\';
 	    buffer[bufp++] = 's';
-	} else if ((ch == ',' || ch == ':' || ch == '^') && tic_format) {
+	} else if ((ch == ',' || ch == '^') && tic_format) {
 	    buffer[bufp++] = '\\';
 	    buffer[bufp++] = (char) ch;
 	} else if (REALPRINT(str)
 		   && (ch != ','
-		       && ch != ':'
+		       && !(ch == ':' && !tic_format)
 		       && !(ch == '!' && !tic_format)
 		       && ch != '^'))
 	    buffer[bufp++] = (char) ch;
@@ -203,7 +205,7 @@ _nc_tic_expand(const char *srcp, bool tic_format, int numbers)
 
     /*
      * If most of a short string is ASCII control characters, reformat the
-     * string to show those in up-arrow format.  For longer strings, it's
+     * string to show those in up-arrow format.  For longer strings, it is
      * more likely that the characters are just binary coding.
      *
      * If we're formatting termcap, just use the shorter format (up-arrows).
diff --git a/contrib/ncurses/ncurses/tinfo/comp_hash.c b/contrib/ncurses/ncurses/tinfo/comp_hash.c
index 80755f22052c..4b081afa2c28 100644
--- a/contrib/ncurses/ncurses/tinfo/comp_hash.c
+++ b/contrib/ncurses/ncurses/tinfo/comp_hash.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 2019-2020,2023 Thomas E. Dickey                                *
  * Copyright 1998-2008,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -45,13 +45,12 @@
 #include <tic.h>
 #include <hashsize.h>
 
-MODULE_ID("$Id: comp_hash.c,v 1.53 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: comp_hash.c,v 1.55 2023/06/24 13:29:43 tom Exp $")
 
 /*
  * Finds the entry for the given string in the hash table if present.
  * Returns a pointer to the entry in the table or 0 if not found.
  */
-/* entrypoint used by tack 1.07 */
 NCURSES_EXPORT(struct name_table_entry const *)
 _nc_find_entry(const char *string,
 	       const HashValue * hash_table)
@@ -104,14 +103,16 @@ _nc_find_type_entry(const char *string,
 	&& data->table_data[hashvalue] >= 0) {
 	const struct name_table_entry *const table = _nc_get_table(termcap);
 
-	ptr = table + data->table_data[hashvalue];
-	while (ptr->nte_type != type
-	       || !data->compare_names(ptr->nte_name, string)) {
-	    if (ptr->nte_link < 0) {
-		ptr = 0;
-		break;
+	if (table != NULL) {
+	    ptr = table + data->table_data[hashvalue];
+	    while (ptr->nte_type != type
+		   || !data->compare_names(ptr->nte_name, string)) {
+		if (ptr->nte_link < 0) {
+		    ptr = 0;
+		    break;
+		}
+		ptr = table + (ptr->nte_link + data->table_data[data->table_size]);
 	    }
-	    ptr = table + (ptr->nte_link + data->table_data[data->table_size]);
 	}
     }
 
diff --git a/contrib/ncurses/ncurses/tinfo/comp_parse.c b/contrib/ncurses/ncurses/tinfo/comp_parse.c
index 2a89a866c374..dec4b925625e 100644
--- a/contrib/ncurses/ncurses/tinfo/comp_parse.c
+++ b/contrib/ncurses/ncurses/tinfo/comp_parse.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2023,2024 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -48,7 +48,7 @@
 
 #include <tic.h>
 
-MODULE_ID("$Id: comp_parse.c,v 1.110 2020/02/29 15:46:00 anonymous.maarten Exp $")
+MODULE_ID("$Id: comp_parse.c,v 1.134 2024/02/10 15:52:11 tom Exp $")
 
 static void sanity_check2(TERMTYPE2 *, bool);
 NCURSES_IMPEXP void (NCURSES_API *_nc_check_termtype2) (TERMTYPE2 *, bool) = sanity_check2;
@@ -59,8 +59,11 @@ static void
 enqueue(ENTRY * ep)
 /* add an entry to the in-core list */
 {
-    ENTRY *newp = _nc_copy_entry(ep);
+    ENTRY *newp;
 
+    DEBUG(2, (T_CALLED("enqueue(ep=%p)"), (void *) ep));
+
+    newp = _nc_copy_entry(ep);
     if (newp == 0)
 	_nc_err_abort(MSG_NO_MEMORY);
 
@@ -70,6 +73,7 @@ enqueue(ENTRY * ep)
     newp->next = 0;
     if (newp->last)
 	newp->last->next = newp;
+    DEBUG(2, (T_RETURN("")));
 }
 
 #define NAMEBUFFER_SIZE (MAX_NAME_SIZE + 2)
@@ -217,6 +221,12 @@ _nc_read_entry_source(FILE *fp, char *buf,
     bool oldsuppress = _nc_suppress_warnings;
     int immediate = 0;
 
+    DEBUG(2,
+	  (T_CALLED("_nc_read_entry_source("
+		    "file=%p, buf=%p, literal=%d, silent=%d, hook=%#"
+		    PRIxPTR ")"),
+	   (void *) fp, buf, literal, silent, CASTxPTR(hook)));
+
     if (silent)
 	_nc_suppress_warnings = TRUE;	/* shut the lexer up, too */
 
@@ -244,29 +254,33 @@ _nc_read_entry_source(FILE *fp, char *buf,
 	    FreeIfNeeded(thisentry.tterm.Booleans);
 	    FreeIfNeeded(thisentry.tterm.Numbers);
 	    FreeIfNeeded(thisentry.tterm.Strings);
+	    FreeIfNeeded(thisentry.tterm.str_table);
 #if NCURSES_XNAMES
 	    FreeIfNeeded(thisentry.tterm.ext_Names);
+	    FreeIfNeeded(thisentry.tterm.ext_str_table);
 #endif
 	}
     }
 
     if (_nc_tail) {
 	/* set up the head pointer */
-	for (_nc_head = _nc_tail; _nc_head->last; _nc_head = _nc_head->last)
-	    continue;
+	for (_nc_head = _nc_tail; _nc_head->last; _nc_head = _nc_head->last) {
+	    /* EMPTY */ ;
+	}
 
-	DEBUG(1, ("head = %s", _nc_head->tterm.term_names));
-	DEBUG(1, ("tail = %s", _nc_tail->tterm.term_names));
+	DEBUG(2, ("head = %s", _nc_head->tterm.term_names));
+	DEBUG(2, ("tail = %s", _nc_tail->tterm.term_names));
     }
 #ifdef TRACE
     else if (!immediate)
-	DEBUG(1, ("no entries parsed"));
+	DEBUG(2, ("no entries parsed"));
 #endif
 
     _nc_suppress_warnings = oldsuppress;
+    DEBUG(2, (T_RETURN("")));
 }
 
-#if NCURSES_XNAMES
+#if 0 && NCURSES_XNAMES
 static unsigned
 find_capname(TERMTYPE2 *p, const char *name)
 {
@@ -298,7 +312,9 @@ extended_captype(TERMTYPE2 *p, unsigned which)
 	} else {
 	    limit += p->ext_Strings;
 	    if (limit != 0 && which < limit) {
-		result = STRING;
+		result = ((p->Strings[STRCOUNT + which] != CANCELLED_STRING)
+			  ? STRING
+			  : CANCEL);
 	    } else if (which >= limit) {
 		result = CANCEL;
 	    }
@@ -354,24 +370,19 @@ invalid_merge(TERMTYPE2 *to, TERMTYPE2 *from)
 		&& tf <= STRING
 		&& (tt == STRING) != (tf == STRING)) {
 		if (from_name != 0 && strcmp(to_name, from_name)) {
-		    DEBUG(2,
-			  ("merge of %s to %s changes type of %s from %s to %s",
-			   from_name,
-			   to_name,
-			   from->ext_Names[n],
-			   name_of_captype(tf),
-			   name_of_captype(tt)));
+		    _nc_warning("merge of %s to %s changes type of %s from %s to %s",
+				from_name,
+				to_name,
+				from->ext_Names[n],
+				name_of_captype(tf),
+				name_of_captype(tt));
 		} else {
-		    DEBUG(2, ("merge of %s changes type of %s from %s to %s",
-			      to_name,
-			      from->ext_Names[n],
-			      name_of_captype(tf),
-			      name_of_captype(tt)));
+		    _nc_warning("merge of %s changes type of %s from %s to %s",
+				to_name,
+				from->ext_Names[n],
+				name_of_captype(tf),
+				name_of_captype(tt));
 		}
-		_nc_warning("merge changes type of %s from %s to %s",
-			    from->ext_Names[n],
-			    name_of_captype(tf),
-			    name_of_captype(tt));
 		rc = TRUE;
 	    }
 	}
@@ -392,10 +403,10 @@ _nc_resolve_uses2(bool fullresolve, bool literal)
 {
     ENTRY *qp, *rp, *lastread = 0;
     bool keepgoing;
-    unsigned i;
-    int unresolved, total_unresolved, multiples;
+    unsigned i, j;
+    int total_unresolved, multiples;
 
-    DEBUG(2, ("RESOLUTION BEGINNING"));
+    DEBUG(2, (T_CALLED("_nc_resolve_uses2")));
 
     /*
      * Check for multiple occurrences of the same name.
@@ -404,7 +415,7 @@ _nc_resolve_uses2(bool fullresolve, bool literal)
     for_entry_list(qp) {
 	int matchcount = 0;
 
-	for_entry_list(rp) {
+	for_entry_list2(rp, qp->next) {
 	    if (qp > rp
 		&& check_collisions(qp->tterm.term_names,
 				    rp->tterm.term_names,
@@ -420,8 +431,10 @@ _nc_resolve_uses2(bool fullresolve, bool literal)
 	    }
 	}
     }
-    if (multiples > 0)
+    if (multiples > 0) {
+	DEBUG(2, (T_RETURN("false")));
 	return (FALSE);
+    }
 
     DEBUG(2, ("NO MULTIPLE NAME OCCURRENCES"));
 
@@ -431,7 +444,6 @@ _nc_resolve_uses2(bool fullresolve, bool literal)
     total_unresolved = 0;
     _nc_curr_col = -1;
     for_entry_list(qp) {
-	unresolved = 0;
 	for (i = 0; i < qp->nuses; i++) {
 	    bool foundit;
 	    char *child = _nc_first_name(qp->tterm.term_names);
@@ -449,11 +461,21 @@ _nc_resolve_uses2(bool fullresolve, bool literal)
 	    for_entry_list(rp) {
 		if (rp != qp
 		    && _nc_name_match(rp->tterm.term_names, lookfor, "|")) {
-		    DEBUG(2, ("%s: resolving use=%s (in core)",
-			      child, lookfor));
+		    DEBUG(2, ("%s: resolving use=%s %p (in core)",
+			      child, lookfor, lookfor));
 
 		    qp->uses[i].link = rp;
 		    foundit = TRUE;
+
+		    /* verify that there are no earlier uses */
+		    for (j = 0; j < i; ++j) {
+			if (qp->uses[j].link != NULL
+			    && !strcmp(qp->uses[j].link->tterm.term_names,
+				       rp->tterm.term_names)) {
+			    _nc_warning("duplicate use=%s", lookfor);
+			    break;
+			}
+		    }
 		}
 	    }
 
@@ -475,12 +497,21 @@ _nc_resolve_uses2(bool fullresolve, bool literal)
 
 		    qp->uses[i].link = rp;
 		    foundit = TRUE;
+
+		    /* verify that there are no earlier uses */
+		    for (j = 0; j < i; ++j) {
+			if (qp->uses[j].link != NULL
+			    && !strcmp(qp->uses[j].link->tterm.term_names,
+				       rp->tterm.term_names)) {
+			    _nc_warning("duplicate use=%s", lookfor);
+			    break;
+			}
+		    }
 		}
 	    }
 
 	    /* no good, mark this one unresolvable and complain */
 	    if (!foundit) {
-		unresolved++;
 		total_unresolved++;
 
 		_nc_curr_line = (int) lookline;
@@ -492,6 +523,7 @@ _nc_resolve_uses2(bool fullresolve, bool literal)
     if (total_unresolved) {
 	/* free entries read in off disk */
 	_nc_free_entries(lastread);
+	DEBUG(2, (T_RETURN("false")));
 	return (FALSE);
     }
 
@@ -510,20 +542,22 @@ _nc_resolve_uses2(bool fullresolve, bool literal)
 
 	    for_entry_list(qp) {
 		if (qp->nuses > 0) {
-		    DEBUG(2, ("%s: attempting merge",
-			      _nc_first_name(qp->tterm.term_names)));
+		    DEBUG(2, ("%s: attempting merge of %d entries",
+			      _nc_first_name(qp->tterm.term_names),
+			      qp->nuses));
 		    /*
 		     * If any of the use entries we're looking for is
 		     * incomplete, punt.  We'll catch this entry on a
 		     * subsequent pass.
 		     */
-		    for (i = 0; i < qp->nuses; i++)
+		    for (i = 0; i < qp->nuses; i++) {
 			if (qp->uses[i].link
 			    && qp->uses[i].link->nuses) {
 			    DEBUG(2, ("%s: use entry %d unresolved",
 				      _nc_first_name(qp->tterm.term_names), i));
 			    goto incomplete;
 			}
+		    }
 
 		    /*
 		     * First, make sure there is no garbage in the
@@ -538,10 +572,10 @@ _nc_resolve_uses2(bool fullresolve, bool literal)
 		     * (reverse) order.
 		     */
 		    for (; qp->nuses; qp->nuses--) {
-			validate_merge(&merged,
-				       qp->uses[qp->nuses - 1].link);
-			_nc_merge_entry(&merged,
-					qp->uses[qp->nuses - 1].link);
+			int n = (int) (qp->nuses - 1);
+			validate_merge(&merged, qp->uses[n].link);
+			_nc_merge_entry(&merged, qp->uses[n].link);
+			free(qp->uses[n].name);
 		    }
 
 		    /*
@@ -556,8 +590,10 @@ _nc_resolve_uses2(bool fullresolve, bool literal)
 		    FreeIfNeeded(qp->tterm.Booleans);
 		    FreeIfNeeded(qp->tterm.Numbers);
 		    FreeIfNeeded(qp->tterm.Strings);
+		    FreeIfNeeded(qp->tterm.str_table);
 #if NCURSES_XNAMES
 		    FreeIfNeeded(qp->tterm.ext_Names);
+		    FreeIfNeeded(qp->tterm.ext_str_table);
 #endif
 		    qp->tterm = merged.tterm;
 		    _nc_wrap_entry(qp, TRUE);
@@ -577,13 +613,6 @@ _nc_resolve_uses2(bool fullresolve, bool literal)
 	DEBUG(2, ("MERGES COMPLETED OK"));
     }
 
-    /*
-     * We'd like to free entries read in off disk at this point, but can't.
-     * The merge_entry() code doesn't copy the strings in the use entries,
-     * it just aliases them.  If this ever changes, do a
-     * free_entries(lastread) here.
-     */
-
     DEBUG(2, ("RESOLUTION FINISHED"));
 
     if (fullresolve) {
@@ -614,6 +643,14 @@ _nc_resolve_uses2(bool fullresolve, bool literal)
 
 		_nc_check_termtype2(&qp->tterm, literal);
 
+		/*
+		 * Checking calls tparm, which can allocate memory.  Fix leaks.
+		 */
+#define TPS(name) fake_tm.tparm_state.name
+		FreeAndNull(TPS(out_buff));
+		FreeAndNull(TPS(fmt_buff));
+#undef TPS
+
 		_nc_set_screen(save_SP);
 		set_curterm(save_tm);
 	    } else {
@@ -623,6 +660,7 @@ _nc_resolve_uses2(bool fullresolve, bool literal)
 	DEBUG(2, ("SANITY CHECK FINISHED"));
     }
 
+    DEBUG(2, (T_RETURN("true")));
     return (TRUE);
 }
 
@@ -709,7 +747,7 @@ sanity_check2(TERMTYPE2 *tp, bool literal)
 NCURSES_EXPORT(void)
 _nc_leaks_tic(void)
 {
-    T((T_CALLED("_nc_free_tic()")));
+    T((T_CALLED("_nc_leaks_tic()")));
     _nc_globals.leak_checking = TRUE;
     _nc_alloc_entry_leaks();
     _nc_captoinfo_leaks();
@@ -719,11 +757,13 @@ _nc_leaks_tic(void)
     _nc_codes_leaks();
 #endif
     _nc_tic_expand(0, FALSE, 0);
+    T((T_RETURN("")));
 }
 
 NCURSES_EXPORT(void)
 _nc_free_tic(int code)
 {
+    T((T_CALLED("_nc_free_tic(%d)"), code));
     _nc_leaks_tic();
     exit_terminfo(code);
 }
diff --git a/contrib/ncurses/ncurses/tinfo/comp_scan.c b/contrib/ncurses/ncurses/tinfo/comp_scan.c
index 350f9b54e45b..8864638530a2 100644
--- a/contrib/ncurses/ncurses/tinfo/comp_scan.c
+++ b/contrib/ncurses/ncurses/tinfo/comp_scan.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+,* Copyright 2020-2022,2023 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -53,7 +53,7 @@
 #include <ctype.h>
 #include <tic.h>
 
-MODULE_ID("$Id: comp_scan.c,v 1.109 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: comp_scan.c,v 1.122 2023/05/27 20:13:10 tom Exp $")
 
 /*
  * Maximum length of string capability we'll accept before raising an error.
@@ -114,6 +114,9 @@ static FILE *yyin;		/* scanner's input file descriptor */
 NCURSES_EXPORT(void)
 _nc_reset_input(FILE *fp, char *buf)
 {
+    TR(TRACE_DATABASE,
+       (T_CALLED("_nc_reset_input(fp=%p, buf=%p)"), (void *) fp, buf));
+
     pushtype = NO_PUSHBACK;
     if (pushname != 0)
 	pushname[0] = '\0';
@@ -123,6 +126,8 @@ _nc_reset_input(FILE *fp, char *buf)
     if (fp != 0)
 	_nc_curr_line = 0;
     _nc_curr_col = 0;
+
+    returnVoidDB;
 }
 
 /*
@@ -138,7 +143,7 @@ last_char(int from_end)
 
     while (len--) {
 	if (!isspace(UChar(bufptr[len]))) {
-	    if (from_end < (int) len)
+	    if (from_end <= (int) len)
 		result = bufptr[(int) len - from_end];
 	    break;
 	}
@@ -146,6 +151,32 @@ last_char(int from_end)
     return result;
 }
 
+/*
+ * Read, like fgets(), but error-out if the input contains nulls.
+ */
+static int
+get_text(char *buffer, int length)
+{
+    int count = 0;
+    int limit = length - 1;
+
+    while (limit-- > 0) {
+	int ch = fgetc(yyin);
+
+	if (ch == '\0') {
+	    _nc_err_abort("This is not a text-file");
+	} else if (ch == EOF) {
+	    break;
+	}
+	++count;
+	*buffer++ = (char) ch;
+	if (ch == '\n')
+	    break;
+    }
+    *buffer = '\0';
+    return count;
+}
+
 /*
  *	int next_char()
  *
@@ -211,7 +242,7 @@ next_char(void)
 		if (used == 0)
 		    _nc_curr_file_pos = ftell(yyin);
 
-		if (fgets(result + used, (int) (allocated - used), yyin) != 0) {
+		if (get_text(result + used, (int) (allocated - used))) {
 		    bufstart = result;
 		    if (used == 0) {
 			if (_nc_curr_line == 0
@@ -273,7 +304,7 @@ push_back(int c)
 /* push a character back onto the input stream */
 {
     if (bufptr == bufstart)
-	_nc_syserr_abort("Can't backspace off beginning of line");
+	_nc_syserr_abort("cannot backspace off beginning of line");
     *--bufptr = (char) c;
     _nc_curr_col--;
 }
@@ -282,14 +313,16 @@ static long
 stream_pos(void)
 /* return our current character position in the input stream */
 {
-    return (yyin ? ftell(yyin) : (bufptr ? bufptr - bufstart : 0));
+    return (yyin ? ftell(yyin) : (bufptr ? (long) (bufptr - bufstart) : 0));
 }
 
 static bool
 end_of_stream(void)
 /* are we at end of input? */
 {
-    return ((yyin ? feof(yyin) : (bufptr && *bufptr == '\0'))
+    return ((yyin
+	     ? (feof(yyin) && (bufptr == NULL || *bufptr == '\0'))
+	     : (bufptr && *bufptr == '\0'))
 	    ? TRUE : FALSE);
 }
 
@@ -297,9 +330,11 @@ end_of_stream(void)
 static NCURSES_INLINE int
 eat_escaped_newline(int ch)
 {
-    if (ch == '\\')
-	while ((ch = next_char()) == '\n' || iswhite(ch))
-	    continue;
+    if (ch == '\\') {
+	while ((ch = next_char()) == '\n' || iswhite(ch)) {
+	    /* EMPTY */ ;
+	}
+    }
     return ch;
 }
 
@@ -369,6 +404,8 @@ _nc_get_token(bool silent)
     int old_col;
 #endif
 
+    DEBUG(3, (T_CALLED("_nc_get_token(silent=%d)"), silent));
+
     if (pushtype != NO_PUSHBACK) {
 	int retval = pushtype;
 
@@ -381,6 +418,7 @@ _nc_get_token(bool silent)
 	    pushname[0] = '\0';
 
 	/* currtok wasn't altered by _nc_push_token() */
+	DEBUG(3, (T_RETURN("%d"), retval));
 	return (retval);
     }
 
@@ -391,6 +429,7 @@ _nc_get_token(bool silent)
 	    if (_nc_curr_token.tk_name == tok_buf)
 		_nc_curr_token.tk_name = 0;
 	}
+	DEBUG(3, (T_RETURN("%d"), EOF));
 	return (EOF);
     }
 
@@ -399,7 +438,6 @@ _nc_get_token(bool silent)
     while ((ch = next_char()) == '\n' || iswhite(ch)) {
 	if (ch == '\n')
 	    had_newline = TRUE;
-	continue;
     }
 
     ch = eat_escaped_newline(ch);
@@ -424,8 +462,9 @@ _nc_get_token(bool silent)
 	    dot_flag = TRUE;
 	    DEBUG(8, ("dot-flag set"));
 
-	    while ((ch = next_char()) == '.' || iswhite(ch))
-		continue;
+	    while ((ch = next_char()) == '.' || iswhite(ch)) {
+		/* EMPTY */ ;
+	    }
 	}
 
 	if (ch == EOF) {
@@ -558,7 +597,7 @@ _nc_get_token(bool silent)
 		 * Grrr...what we ought to do here is barf, complaining that
 		 * the entry is malformed.  But because a couple of name fields
 		 * in the 8.2 termcap file end with |\, we just have to assume
-		 * it's termcap syntax.
+		 * it is termcap syntax.
 		 */
 		_nc_syntax = SYN_TERMCAP;
 		separator = ':';
@@ -566,8 +605,9 @@ _nc_get_token(bool silent)
 		/* throw away trailing /, *$/ */
 		for (--tok_ptr;
 		     iswhite(*tok_ptr) || *tok_ptr == ',';
-		     tok_ptr--)
-		    continue;
+		     tok_ptr--) {
+		    /* EMPTY */ ;
+		}
 		tok_ptr[1] = '\0';
 	    }
 
@@ -589,16 +629,15 @@ _nc_get_token(bool silent)
 	     */
 	    if (after_list != 0) {
 		if (!silent) {
-		    if (*after_list == '\0')
+		    if (*after_list == '\0' || strchr("|", after_list[1]) != NULL) {
 			_nc_warning("empty longname field");
-#ifndef FREEBSD_NATIVE
-		    else if (strchr(after_list, ' ') == 0)
+		    } else if (strchr(after_list, ' ') == 0) {
 			_nc_warning("older tic versions may treat the description field as an alias");
-#endif
+		    }
 		}
 	    } else {
 		after_list = tok_buf + strlen(tok_buf);
-		DEBUG(1, ("missing description"));
+		DEBUG(2, ("missing description"));
 	    }
 
 	    /*
@@ -773,6 +812,7 @@ _nc_get_token(bool silent)
 	       : "<null>"),
 	      type));
 
+    DEBUG(3, (T_RETURN("%d"), type));
     return (type);
 }
 
@@ -796,7 +836,7 @@ _nc_get_token(bool silent)
  */
 
 NCURSES_EXPORT(int)
-_nc_trans_string(char *ptr, char *last)
+_nc_trans_string(char *ptr, const char *const last)
 {
     int count = 0;
     int number = 0;
diff --git a/contrib/ncurses/ncurses/tinfo/db_iterator.c b/contrib/ncurses/ncurses/tinfo/db_iterator.c
index f0726682c403..db3872e3f90d 100644
--- a/contrib/ncurses/ncurses/tinfo/db_iterator.c
+++ b/contrib/ncurses/ncurses/tinfo/db_iterator.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
  * Copyright 2006-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -44,7 +44,7 @@
 #include <hashed_db.h>
 #endif
 
-MODULE_ID("$Id: db_iterator.c,v 1.48 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: db_iterator.c,v 1.50 2023/06/24 21:52:32 tom Exp $")
 
 #define HaveTicDirectory _nc_globals.have_tic_directory
 #define KeepTicDirectory _nc_globals.keep_tic_directory
@@ -202,6 +202,13 @@ free_cache(void)
     FreeAndNull(my_list);
 }
 
+static void
+update_tic_dir(const char *update)
+{
+    free((char *) TicDirectory);
+    TicDirectory = update;
+}
+
 /*
  * Record the "official" location of the terminfo directory, according to
  * the place where we're writing to, or the normal default, if not.
@@ -211,8 +218,9 @@ _nc_tic_dir(const char *path)
 {
     T(("_nc_tic_dir %s", NonNull(path)));
     if (!KeepTicDirectory) {
-	if (path != 0) {
-	    TicDirectory = path;
+	if (path != NULL) {
+	    if (path != TicDirectory)
+		update_tic_dir(strdup(path));
 	    HaveTicDirectory = TRUE;
 	} else if (HaveTicDirectory == 0) {
 	    if (use_terminfo_vars()) {
@@ -375,8 +383,11 @@ _nc_first_db(DBDIRS * state, int *offset)
 		 */
 		for (j = 0; my_list[j] != 0; ++j) {
 #ifdef TERMINFO
-		    if (*my_list[j] == '\0')
-			my_list[j] = strdup(TERMINFO);
+		    if (*my_list[j] == '\0') {
+			char *my_copy = strdup(TERMINFO);
+			if (my_copy != 0)
+			    my_list[j] = my_copy;
+		    }
 #endif
 		    trim_formatting(my_list[j]);
 		    for (k = 0; k < j; ++k) {
@@ -444,5 +455,6 @@ _nc_db_iterator_leaks(void)
 	FreeIfNeeded(my_vars[which].value);
 	my_vars[which].value = 0;
     }
+    update_tic_dir(NULL);
 }
 #endif
diff --git a/contrib/ncurses/ncurses/tinfo/doalloc.c b/contrib/ncurses/ncurses/tinfo/doalloc.c
index 0bda12cae8be..e3b1a2e96c1b 100644
--- a/contrib/ncurses/ncurses/tinfo/doalloc.c
+++ b/contrib/ncurses/ncurses/tinfo/doalloc.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2002,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -40,15 +40,18 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: doalloc.c,v 1.13 2020/08/30 00:27:15 tom Exp $")
+MODULE_ID("$Id: doalloc.c,v 1.14 2021/04/24 23:43:39 tom Exp $")
 
 void *
 _nc_doalloc(void *oldp, size_t amount)
 {
     void *newp;
 
-    if (oldp != 0) {
-	if ((newp = realloc(oldp, amount)) == 0) {
+    if (oldp != NULL) {
+	if (amount == 0) {
+	    free(oldp);
+	    newp = NULL;
+	} else if ((newp = realloc(oldp, amount)) == 0) {
 	    free(oldp);
 	    errno = ENOMEM;	/* just in case 'free' reset */
 	}
diff --git a/contrib/ncurses/ncurses/tinfo/entries.c b/contrib/ncurses/ncurses/tinfo/entries.c
index b261bedf312e..f47fd3fe9eff 100644
--- a/contrib/ncurses/ncurses/tinfo/entries.c
+++ b/contrib/ncurses/ncurses/tinfo/entries.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 2019-2022,2023 Thomas E. Dickey                                *
  * Copyright 2006-2012,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -38,7 +38,7 @@
 
 #include <tic.h>
 
-MODULE_ID("$Id: entries.c,v 1.30 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: entries.c,v 1.35 2023/05/27 20:13:10 tom Exp $")
 
 /****************************************************************************
  *
@@ -64,8 +64,8 @@ MODULE_ID("$Id: entries.c,v 1.30 2020/02/02 23:34:34 tom Exp $")
 NCURSES_EXPORT_VAR(ENTRY *) _nc_head = 0;
 NCURSES_EXPORT_VAR(ENTRY *) _nc_tail = 0;
 
-ENTRY *
-_nc_delink_entry(ENTRY * headp, TERMTYPE2 *tterm)
+static ENTRY *
+_nc_delink_entry(ENTRY * headp, const TERMTYPE2 *const tterm)
 /* delink the allocated storage for the given list entry */
 {
     ENTRY *ep, *last;
@@ -119,12 +119,28 @@ _nc_leaks_tinfo(void)
     char *s;
 #endif
 
-    T((T_CALLED("_nc_free_tinfo()")));
+    T((T_CALLED("_nc_leaks_tinfo()")));
 #if NO_LEAKS
     _nc_globals.leak_checking = TRUE;
-    _nc_free_tparm();
+    _nc_free_tparm(cur_term);
     _nc_tgetent_leaks();
 
+#ifdef USE_PTHREADS
+    /*
+     * Discard any prescreen data which is not used for the current screen.
+     */
+    _nc_lock_global(screen);
+    {
+	PRESCREEN_LIST *p;
+	pthread_t id = GetThreadID();
+	for (p = _nc_prescreen.allocated; p != 0; p = p->next) {
+	    if (p->id == id && p->sp != CURRENT_SCREEN) {
+		FreeAndNull(p->sp);
+	    }
+	}
+    }
+    _nc_unlock_global(screen);
+#endif
     if (TerminalOf(CURRENT_SCREEN) != 0) {
 	del_curterm(TerminalOf(CURRENT_SCREEN));
     }
@@ -161,6 +177,7 @@ _nc_leaks_tinfo(void)
 NCURSES_EXPORT(void)
 _nc_free_tinfo(int code)
 {
+    T((T_CALLED("_nc_free_tinfo(%d)"), code));
     _nc_leaks_tinfo();
     exit(code);
 }
@@ -169,6 +186,7 @@ _nc_free_tinfo(int code)
 NCURSES_EXPORT(void)
 exit_terminfo(int code)
 {
+    T((T_CALLED("exit_terminfo(%d)"), code));
 #if NO_LEAKS
     _nc_leaks_tinfo();
 #endif
diff --git a/contrib/ncurses/ncurses/tinfo/free_ttype.c b/contrib/ncurses/ncurses/tinfo/free_ttype.c
index 7f0fbcc35f29..7935152a7920 100644
--- a/contrib/ncurses/ncurses/tinfo/free_ttype.c
+++ b/contrib/ncurses/ncurses/tinfo/free_ttype.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020-2022,2023 Thomas E. Dickey                                *
  * Copyright 1999-2011,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -43,12 +43,12 @@
 
 #include <tic.h>
 
-MODULE_ID("$Id: free_ttype.c,v 1.19 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: free_ttype.c,v 1.22 2023/04/22 15:12:57 tom Exp $")
 
 static void
 really_free_termtype(TERMTYPE2 *ptr, bool freeStrings)
 {
-    T(("_nc_free_termtype(%s)", ptr->term_names));
+    T(("really_free_termtype(%s) %d", ptr->term_names, freeStrings));
 
     if (freeStrings) {
 	FreeIfNeeded(ptr->str_table);
@@ -66,15 +66,21 @@ really_free_termtype(TERMTYPE2 *ptr, bool freeStrings)
     _nc_free_entry(_nc_head, ptr);
 }
 
-/*
- * This entrypoint is used by tack 1.07
- */
 NCURSES_EXPORT(void)
 _nc_free_termtype(TERMTYPE *ptr)
 {
     really_free_termtype((TERMTYPE2 *) ptr, !NCURSES_EXT_NUMBERS);
 }
 
+/*
+ * These similar entrypoints are not used outside of ncurses.
+ */
+NCURSES_EXPORT(void)
+_nc_free_termtype1(TERMTYPE *ptr)
+{
+    really_free_termtype((TERMTYPE2 *) ptr, TRUE);
+}
+
 #if NCURSES_EXT_NUMBERS
 NCURSES_EXPORT(void)
 _nc_free_termtype2(TERMTYPE2 *ptr)
diff --git a/contrib/ncurses/ncurses/tinfo/init_keytry.c b/contrib/ncurses/ncurses/tinfo/init_keytry.c
index 1669c6414c18..ef20dfb1da08 100644
--- a/contrib/ncurses/ncurses/tinfo/init_keytry.c
+++ b/contrib/ncurses/ncurses/tinfo/init_keytry.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
  * Copyright 1999-2010,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -30,7 +30,7 @@
 #include <curses.priv.h>
 #include <tic.h>		/* struct tinfo_fkeys */
 
-MODULE_ID("$Id: init_keytry.c,v 1.19 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: init_keytry.c,v 1.20 2023/09/16 12:55:01 tom Exp $")
 
 /*
 **      _nc_init_keytry()
@@ -67,6 +67,8 @@ _nc_tinfo_fkeysf(void)
 NCURSES_EXPORT(void)
 _nc_init_keytry(SCREEN *sp)
 {
+    T(("_nc_init_keytry(%p)", (void *) sp));
+
     /* The sp->_keytry value is initialized in newterm(), where the sp
      * structure is created, because we can not tell where keypad() or
      * mouse_activate() (which will call keyok()) are first called.
@@ -95,7 +97,7 @@ _nc_init_keytry(SCREEN *sp)
 		char *value = tp->Strings[n];
 		if (name != 0
 		    && *name == 'k'
-		    && value != 0
+		    && VALID_STRING(value)
 		    && NCURSES_SP_NAME(key_defined) (NCURSES_SP_ARGx
 						     value) == 0) {
 		    (void) _nc_add_to_try(&(sp->_keytry),
diff --git a/contrib/ncurses/ncurses/tinfo/lib_cur_term.c b/contrib/ncurses/ncurses/tinfo/lib_cur_term.c
index 0373aebb11b9..1f8db2c1e0c8 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_cur_term.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_cur_term.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+,* Copyright 2020-2021,2022 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -41,7 +41,7 @@
 #include <termcap.h>		/* ospeed */
 #include <tic.h>		/* VALID_STRING */
 
-MODULE_ID("$Id: lib_cur_term.c,v 1.43 2020/10/24 18:54:32 tom Exp $")
+MODULE_ID("$Id: lib_cur_term.c,v 1.49 2022/05/28 17:56:55 tom Exp $")
 
 #undef CUR
 #define CUR TerminalType(termp).
@@ -147,7 +147,11 @@ NCURSES_SP_NAME(del_curterm) (NCURSES_SP_DCLx TERMINAL *termp)
 	);
 
 #if NCURSES_EXT_NUMBERS
-	_nc_free_termtype(&termp->type);
+#if NCURSES_EXT_COLORS
+	_nc_free_termtype1(&termp->type);
+#else
+	_nc_free_termtype2(&termp->type);
+#endif
 #endif
 	_nc_free_termtype2(&TerminalType(termp));
 	if (termp == cur)
@@ -167,10 +171,17 @@ NCURSES_SP_NAME(del_curterm) (NCURSES_SP_DCLx TERMINAL *termp)
 	/* discard memory used in tgetent's cache for this terminal */
 	_nc_tgetent_leak(termp);
 #endif
+	if (--_nc_globals.terminal_count == 0) {
+	    _nc_free_tparm(termp);
+	}
+
+	free(termp->tparm_state.fmt_buff);
+	free(termp->tparm_state.out_buff);
 	free(termp);
 
 	rc = OK;
     }
+
     returnCode(rc);
 }
 
diff --git a/contrib/ncurses/ncurses/tinfo/lib_data.c b/contrib/ncurses/ncurses/tinfo/lib_data.c
index 39274f4e7c39..b817f49bd78a 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_data.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_data.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2018-2022,2024 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -43,7 +43,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_data.c,v 1.81 2020/06/13 22:01:14 tom Exp $")
+MODULE_ID("$Id: lib_data.c,v 1.89 2024/02/24 18:11:38 tom Exp $")
 
 /*
  * OS/2's native linker complains if we don't initialize public data when
@@ -148,6 +148,7 @@ NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals = {
     TGETENT_0s,			/* tgetent_cache */
     0,				/* tgetent_index */
     0,				/* tgetent_sequence */
+    0,				/* terminal_count */
 
     0,				/* dbd_blob */
     0,				/* dbd_list */
@@ -195,7 +196,6 @@ NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals = {
 #endif
 #ifdef TRACE
     FALSE,			/* trace_opened */
-    CHARS_0s,			/* trace_fname */
     0,				/* trace_level */
     NULL,			/* trace_fp */
     -1,				/* trace_fd */
@@ -251,7 +251,6 @@ NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen = {
 	NULL,			/* fmt_buff */
 	0,			/* fmt_size */
 
-	NUM_VARS_0s,		/* dynamic_var */
 	NUM_VARS_0s,		/* static_vars */
 #ifdef TRACE
 	NULL,			/* tname */
@@ -363,25 +362,28 @@ _nc_mutex_init(pthread_mutex_t * obj)
 NCURSES_EXPORT(int)
 _nc_mutex_lock(pthread_mutex_t * obj)
 {
-    if (_nc_use_pthreads == 0)
-	return 0;
-    return pthread_mutex_lock(obj);
+    int rc = 0;
+    if (_nc_use_pthreads != 0)
+	rc = pthread_mutex_lock(obj);
+    return rc;
 }
 
 NCURSES_EXPORT(int)
 _nc_mutex_trylock(pthread_mutex_t * obj)
 {
-    if (_nc_use_pthreads == 0)
-	return 0;
-    return pthread_mutex_trylock(obj);
+    int rc = 0;
+    if (_nc_use_pthreads != 0)
+	rc = pthread_mutex_trylock(obj);
+    return rc;
 }
 
 NCURSES_EXPORT(int)
 _nc_mutex_unlock(pthread_mutex_t * obj)
 {
-    if (_nc_use_pthreads == 0)
-	return 0;
-    return pthread_mutex_unlock(obj);
+    int rc = 0;
+    if (_nc_use_pthreads != 0)
+	rc = pthread_mutex_unlock(obj);
+    return rc;
 }
 #endif /* USE_PTHREADS */
 
diff --git a/contrib/ncurses/ncurses/tinfo/lib_kernel.c b/contrib/ncurses/ncurses/tinfo/lib_kernel.c
index d5b021b80728..46f652b0a30a 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_kernel.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_kernel.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020-2022,2023 Thomas E. Dickey                                *
  * Copyright 1998-2009,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -49,7 +49,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_kernel.c,v 1.34 2020/11/21 22:05:58 tom Exp $")
+MODULE_ID("$Id: lib_kernel.c,v 1.36 2023/06/10 13:29:06 tom Exp $")
 
 #ifdef TERMIOS
 static int
@@ -59,7 +59,7 @@ _nc_vdisable(void)
 #if defined(_POSIX_VDISABLE) && HAVE_UNISTD_H
     value = _POSIX_VDISABLE;
 #endif
-#if defined(_PC_VDISABLE)
+#if defined(_PC_VDISABLE) && HAVE_FPATHCONF
     if (value == -1) {
 	value = (int) fpathconf(0, _PC_VDISABLE);
 	if (value == -1) {
@@ -148,34 +148,40 @@ killchar(void)
 }
 #endif
 
+static void
+flush_input(int fd)
+{
+#ifdef TERMIOS
+    tcflush(fd, TCIFLUSH);
+#else /* !TERMIOS */
+    errno = 0;
+    do {
+#if defined(EXP_WIN32_DRIVER)
+	_nc_console_flush(_nc_console_fd2handle(fd));
+#else
+	ioctl(fd, TIOCFLUSH, 0);
+#endif
+    } while
+	(errno == EINTR);
+#endif
+}
+
 /*
  *	flushinp()
  *
- *	Flush any input on cur_term->Filedes
- *
+ *	Flush any input on tty
  */
 
 NCURSES_EXPORT(int)
 NCURSES_SP_NAME(flushinp) (NCURSES_SP_DCL0)
 {
-    TERMINAL *termp = TerminalOf(SP_PARM);
-
     T((T_CALLED("flushinp(%p)"), (void *) SP_PARM));
 
-    if (termp != 0) {
-#ifdef TERMIOS
-	tcflush(termp->Filedes, TCIFLUSH);
-#else
-	errno = 0;
-	do {
-#if defined(EXP_WIN32_DRIVER)
-	    _nc_console_flush(_nc_console_fd2handle(termp->Filedes));
-#else
-	    ioctl(termp->Filedes, TIOCFLUSH, 0);
-#endif
-	} while
-	    (errno == EINTR);
-#endif
+    if (SP_PARM != 0) {
+	if (NC_ISATTY(SP_PARM->_ifd))
+	    flush_input(SP_PARM->_ifd);
+	else if (NC_ISATTY(SP_PARM->_ofd))
+	    flush_input(SP_PARM->_ofd);
 	if (SP_PARM) {
 	    SP_PARM->_fifohead = -1;
 	    SP_PARM->_fifotail = 0;
diff --git a/contrib/ncurses/ncurses/tinfo/lib_longname.c b/contrib/ncurses/ncurses/tinfo/lib_longname.c
index 835d15ccafc1..9dc6d71e2ad4 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_longname.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_longname.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2010,2015 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -43,7 +43,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_longname.c,v 1.14 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_longname.c,v 1.15 2021/04/03 22:36:21 tom Exp $")
 
 #if USE_REENTRANT
 NCURSES_EXPORT(char *)
@@ -51,11 +51,12 @@ NCURSES_SP_NAME(longname) (NCURSES_SP_DCL0)
 {
     static char empty[] =
     {'\0'};
-    char *ptr;
 
     T((T_CALLED("longname(%p)"), (void *) SP_PARM));
 
     if (SP_PARM) {
+	char *ptr;
+
 	for (ptr = SP_PARM->_ttytype + strlen(SP_PARM->_ttytype);
 	     ptr > SP_PARM->_ttytype;
 	     ptr--)
diff --git a/contrib/ncurses/ncurses/tinfo/lib_napms.c b/contrib/ncurses/ncurses/tinfo/lib_napms.c
index 3a9fc3168784..1b89a54c799b 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_napms.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_napms.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
  * Copyright 1998-2014,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -52,13 +52,16 @@
 #endif
 #endif
 
-MODULE_ID("$Id: lib_napms.c,v 1.27 2020/08/15 19:45:23 tom Exp $")
+MODULE_ID("$Id: lib_napms.c,v 1.28 2023/09/16 16:09:33 tom Exp $")
 
 NCURSES_EXPORT(int)
 NCURSES_SP_NAME(napms) (NCURSES_SP_DCLx int ms)
 {
     T((T_CALLED("napms(%d)"), ms));
 
+    if (ms > MAX_DELAY_MSECS)
+	ms = MAX_DELAY_MSECS;
+
 #ifdef USE_TERM_DRIVER
     CallDriver_1(SP_PARM, td_nap, ms);
 #else /* !USE_TERM_DRIVER */
diff --git a/contrib/ncurses/ncurses/tinfo/lib_options.c b/contrib/ncurses/ncurses/tinfo/lib_options.c
index 017a34aac6e7..6a8bb39489ce 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_options.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_options.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020,2021 Thomas E. Dickey                                     *
+ * Copyright 2020-2021,2023 Thomas E. Dickey                                *
  * Copyright 1998-2014,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -47,7 +47,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_options.c,v 1.82 2021/02/14 00:17:35 tom Exp $")
+MODULE_ID("$Id: lib_options.c,v 1.83 2023/04/29 18:56:12 tom Exp $")
 
 NCURSES_EXPORT(int)
 idlok(WINDOW *win, bool flag)
@@ -92,7 +92,7 @@ NCURSES_SP_NAME(halfdelay) (NCURSES_SP_DCLx int t)
 	returnCode(ERR);
 
     NCURSES_SP_NAME(cbreak) (NCURSES_SP_ARG);
-    SP_PARM->_cbreak = t + 1;
+    IsCbreak(SP_PARM) = t + 1;
     returnCode(OK);
 }
 
diff --git a/contrib/ncurses/ncurses/tinfo/lib_print.c b/contrib/ncurses/ncurses/tinfo/lib_print.c
index 4accdf6786ea..e7d8535ef603 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_print.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_print.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2018-2021,2023 Thomas E. Dickey                                *
  * Copyright 1998-2011,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -40,14 +40,14 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_print.c,v 1.28 2020/08/29 16:22:03 juergen Exp $")
+MODULE_ID("$Id: lib_print.c,v 1.31 2023/06/10 12:44:41 tom Exp $")
 
 NCURSES_EXPORT(int)
 NCURSES_SP_NAME(mcprint) (NCURSES_SP_DCLx char *data, int len)
 /* ship binary character data to the printer via mc4/mc5/mc5p */
 {
     int result;
-    char *mybuf, *switchon;
+    char *mybuf = NULL, *switchon;
     size_t onsize, offsize;
     size_t need;
 
@@ -73,6 +73,7 @@ NCURSES_SP_NAME(mcprint) (NCURSES_SP_DCLx char *data, int len)
 
     if (switchon == 0
 	|| (mybuf = typeMalloc(char, need + 1)) == 0) {
+	free(mybuf);
 	errno = ENOMEM;
 	return (ERR);
     }
@@ -89,7 +90,7 @@ NCURSES_SP_NAME(mcprint) (NCURSES_SP_DCLx char *data, int len)
      * data has actually been shipped to the terminal.  If the write(2)
      * operation is truly atomic we're protected from this.
      */
-    result = (int) write(TerminalOf(SP_PARM)->Filedes, mybuf, need);
+    result = (int) write(SP_PARM->_ofd, mybuf, need);
 
     /*
      * By giving up our scheduler slot here we increase the odds that the
diff --git a/contrib/ncurses/ncurses/tinfo/lib_raw.c b/contrib/ncurses/ncurses/tinfo/lib_raw.c
index 1e47f3b6fbfb..fda6deada2a7 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_raw.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_raw.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020-2023,2024 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -50,7 +50,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_raw.c,v 1.26 2020/11/21 22:07:48 tom Exp $")
+MODULE_ID("$Id: lib_raw.c,v 1.30 2024/03/30 15:54:17 tom Exp $")
 
 #if HAVE_SYS_TERMIO_H
 #include <sys/termio.h>		/* needed for ISC */
@@ -116,8 +116,8 @@ NCURSES_SP_NAME(raw) (NCURSES_SP_DCL0)
 	    KbdSetStatus(&kbdinfo, 0);
 #endif
 	    if (SP_PARM) {
-		SP_PARM->_raw = TRUE;
-		SP_PARM->_cbreak = 1;
+		IsRaw(SP_PARM) = TRUE;
+		IsCbreak(SP_PARM) = 1;
 	    }
 	    termp->Nttyb = buf;
 	}
@@ -151,7 +151,6 @@ NCURSES_SP_NAME(cbreak) (NCURSES_SP_DCL0)
 #ifdef TERMIOS
 	buf.c_lflag &= (unsigned) ~ICANON;
 	buf.c_iflag &= (unsigned) ~ICRNL;
-	buf.c_lflag |= ISIG;
 	buf.c_cc[VMIN] = 1;
 	buf.c_cc[VTIME] = 0;
 #elif defined(EXP_WIN32_DRIVER)
@@ -163,7 +162,7 @@ NCURSES_SP_NAME(cbreak) (NCURSES_SP_DCL0)
 	result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf);
 	if (result == OK) {
 	    if (SP_PARM) {
-		SP_PARM->_cbreak = 1;
+		IsCbreak(SP_PARM) = 1;
 	    }
 	    termp->Nttyb = buf;
 	}
@@ -255,8 +254,8 @@ NCURSES_SP_NAME(noraw) (NCURSES_SP_DCL0)
 	    KbdSetStatus(&kbdinfo, 0);
 #endif
 	    if (SP_PARM) {
-		SP_PARM->_raw = FALSE;
-		SP_PARM->_cbreak = 0;
+		IsRaw(SP_PARM) = FALSE;
+		IsCbreak(SP_PARM) = 0;
 	    }
 	    termp->Nttyb = buf;
 	}
@@ -298,7 +297,7 @@ NCURSES_SP_NAME(nocbreak) (NCURSES_SP_DCL0)
 	result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf);
 	if (result == OK) {
 	    if (SP_PARM) {
-		SP_PARM->_cbreak = 0;
+		IsCbreak(SP_PARM) = 0;
 	    }
 	    termp->Nttyb = buf;
 	}
@@ -395,3 +394,46 @@ intrflush(WINDOW *win GCC_UNUSED, bool flag)
     return NCURSES_SP_NAME(intrflush) (CURRENT_SCREEN, win, flag);
 }
 #endif
+
+#if NCURSES_EXT_FUNCS
+/* *INDENT-OFF* */
+
+/*
+ * SCREEN is always opaque, but nl/raw/cbreak/echo set properties in it.
+ * As an extension, provide a way to query the properties.
+ *
+ * There are other properties which could be queried, e.g., filter, keypad,
+ * use_env, use_meta, but these particular properties are saved/restored within
+ * the wgetnstr() and wgetn_wstr() functions, which requires that the higher
+ * level curses library knows about the internal state of the lower level
+ * terminfo library.
+ */
+
+#define is_TEST(show,what) \
+    NCURSES_EXPORT(int) \
+    NCURSES_SP_NAME(show) (NCURSES_SP_DCL0) \
+    { \
+	return ((SP_PARM != NULL) ? (what(SP_PARM) ? 1 : 0) : -1); \
+    }
+
+is_TEST(is_nl, IsNl)
+is_TEST(is_raw, IsRaw)
+is_TEST(is_cbreak, IsCbreak)
+is_TEST(is_echo, IsEcho)
+
+#if NCURSES_SP_FUNCS
+#undef is_TEST
+#define is_TEST(show) \
+    NCURSES_EXPORT(int) \
+    show(void) \
+    { \
+	return NCURSES_SP_NAME(show) (CURRENT_SCREEN); \
+    }
+is_TEST(is_nl)
+is_TEST(is_raw)
+is_TEST(is_cbreak)
+is_TEST(is_echo)
+#endif
+
+/* *INDENT-ON* */
+#endif /* extensions */
diff --git a/contrib/ncurses/ncurses/tinfo/lib_setup.c b/contrib/ncurses/ncurses/tinfo/lib_setup.c
index 976227effade..99097f00fc1d 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_setup.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_setup.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2023,2024 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -49,7 +49,7 @@
 #include <locale.h>
 #endif
 
-MODULE_ID("$Id: lib_setup.c,v 1.212 2020/09/09 19:43:00 juergen Exp $")
+MODULE_ID("$Id: lib_setup.c,v 1.240 2024/04/20 17:04:05 tom Exp $")
 
 /****************************************************************************
  *
@@ -66,7 +66,7 @@ MODULE_ID("$Id: lib_setup.c,v 1.212 2020/09/09 19:43:00 juergen Exp $")
 #endif
 
 #if NEED_PTEM_H
- /* On SCO, they neglected to define struct winsize in termios.h -- it's only
+ /* On SCO, they neglected to define struct winsize in termios.h -- it is only
   * in termio.h and ptem.h (the former conflicts with other definitions).
   */
 # include <sys/stream.h>
@@ -272,6 +272,191 @@ use_tioctl(bool f)
 }
 #endif
 
+#if !(defined(USE_TERM_DRIVER) || defined(EXP_WIN32_DRIVER))
+static void
+_nc_default_screensize(TERMINAL *termp, int *linep, int *colp)
+{
+    /* if we can't get dynamic info about the size, use static */
+    if (*linep <= 0) {
+	*linep = (int) lines;
+    }
+    if (*colp <= 0) {
+	*colp = (int) columns;
+    }
+
+    /* the ultimate fallback, assume fixed 24x80 size */
+    if (*linep <= 0) {
+	*linep = 24;
+    }
+    if (*colp <= 0) {
+	*colp = 80;
+    }
+}
+
+#if defined(USE_CHECK_SIZE) && defined(user6) && defined(user7)
+static const char *
+skip_csi(const char *value)
+{
+    if (UChar(*value) == CSI_CHR) {
+	++value;
+    } else if (*value == ESC_CHR && value[1] == L_BLOCK) {
+	value += 2;
+    }
+    return value;
+}
+
+static bool
+is_expected(const char *value, const char *expected)
+{
+    bool result = FALSE;
+    if (VALID_STRING(value)) {
+	const char *skipped = skip_csi(value);
+	if (skipped != value) {
+	    if (!strcmp(skipped, expected))
+		result = TRUE;
+	}
+    }
+    return result;
+}
+
+static bool
+get_position(TERMINAL *termp, int fd, int *row, int *col)
+{
+    bool result = FALSE;
+    size_t need = strlen(user7);
+    int have;
+
+    have = (int) write(fd, user7, need);
+
+    if (have == (int) need) {
+	int y, x;
+	char buf[20];
+	char *s;
+	char cc;
+	const char *skipped;
+	int scanned;
+
+	s = memset(buf, '\0', sizeof(buf));
+	do {
+	    size_t ask = (sizeof(buf) - 1 - (size_t) (s - buf));
+	    int got = (int) read(fd, s, ask);
+	    if (got == 0)
+		break;
+	    s += got;
+	    *s = '\0';
+	} while (strchr(buf, 'R') == NULL && (size_t) (s + 1 - buf) < sizeof(buf));
+	T(("CPR response %s", _nc_visbuf(buf)));
+	skipped = skip_csi(buf);
+	cc = '\0';
+	if (skipped != buf
+	    && *skipped != '\0'
+	    && (scanned = sscanf(skip_csi(buf), "%d;%d%c", &y, &x, &cc)) == 3
+	    && (cc == 'R')) {
+	    *row = y;
+	    *col = x;
+	    result = TRUE;
+	}
+    }
+    T(("get_position %s %d,%d", result ? "OK" : "ERR", *row, *col));
+    return result;
+}
+
+static bool
+set_position(NCURSES_SP_DCLx TERMINAL *termp, int row, int col)
+{
+    bool result;
+    char *actual = TIPARM_2(cursor_address, row, col);
+    T((T_CALLED("set_position %d,%d)"), row, col));
+#if NCURSES_SP_FUNCS
+    result = (NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx "set_position",
+					 actual) == OK);
+    NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
+#else
+    /* This does not support padding because without sp-funcs, we have only
+     * the interface using stdio, but we are not guaranteed that Filedes
+     * is the same as fileno(stdout).
+     */
+    result = FALSE;
+    if (actual != NULL) {
+	size_t want = strlen(actual);
+	int have = (int) write(termp->Filedes, actual, want);
+	result = ((int) want == have);
+    }
+#endif
+    returnBool(result);
+}
+
+/*
+ * This is a little more complicated than one might expect, because we do this
+ * before setting up the terminal modes, etc., and cannot use the timeout or
+ * buffering functions.
+ *
+ * We check if the terminal description has the ECMA-48 CPR (cursor position
+ * report) in u7 and the response in u6.  The two variations of is_expected()
+ * cover the termcap style and terminfo style, and are equivalent as far as we
+ * are concerned.  For analyzing the response, we wait (a short time) for 'R'
+ * to be echoed, and then check if we received two integers in the response.
+ *
+ * In principle, this could run on "any" ECMA-48 terminal, but in practice,
+ * there is a scenario using GNU screen where it uses ncurses with a partially
+ * configured pseudo-terminal, and the CPR response goes to the wrong place.
+ * So we do a simple check to exclude pseudo-terminals.
+ */
+static void
+_nc_check_screensize(SCREEN *sp, TERMINAL *termp, int *linep, int *colp)
+{
+    int fd = termp->Filedes;
+    TTY saved;
+    const char *name = NULL;
+
+    if (IsRealTty(fd, name)
+	&& VALID_STRING(cursor_address)
+	&& is_expected(user7, "6n")
+	&& (is_expected(user6, "%i%d;%dR") ||
+	    is_expected(user6, "%i%p1%d;%p2%dR"))
+	&& GET_TTY(fd, &saved) == OK) {
+	int current_y = -1, current_x = -1;
+	int updated_y = -1, updated_x = -1;
+	TTY alter = saved;
+
+#if NCURSES_SP_FUNCS
+	if (sp == NULL) {
+	    sp = new_prescr();
+	    sp->_term = termp;
+	    NCURSES_SP_NAME(baudrate) (NCURSES_SP_ARG);
+	}
+#else
+	(void) sp;
+#endif
+
+	T(("trying CPR (u7/u6) with %s", name));
+	alter.c_lflag &= (unsigned) ~(ECHO | ICANON | ISIG | IEXTEN);
+	alter.c_iflag &= (unsigned) ~(IXON | BRKINT | PARMRK);
+	alter.c_cc[VMIN] = 0;
+	alter.c_cc[VTIME] = 1;
+	SET_TTY(fd, &alter);
+
+	if (get_position(termp, fd, &current_y, &current_x)
+	    && set_position(NCURSES_SP_ARGx termp, 9999, 9999)
+	    && get_position(termp, fd, &updated_y, &updated_x)) {
+	    *linep = updated_y;
+	    *colp = updated_x;
+	    set_position(NCURSES_SP_ARGx termp, current_y, current_x);
+	}
+	/* restore tty modes */
+	SET_TTY(fd, &saved);
+    } else {
+	T(("NOT trying CPR with fd %d (%s): %s",
+	   fd, NonNull(name), NC_ISATTY(fd) ? "tty" : "not a tty"));
+    }
+
+    _nc_default_screensize(termp, linep, colp);
+}
+#else /* !USE_CHECK_SIZE */
+#define _nc_check_screensize(sp, termp, linep, colp)	/* nothing */
+#endif
+#endif /* !(defined(USE_TERM_DRIVER) || defined(EXP_WIN32_DRIVER)) */
+
 NCURSES_EXPORT(void)
 _nc_get_screensize(SCREEN *sp,
 #ifdef USE_TERM_DRIVER
@@ -305,6 +490,7 @@ _nc_get_screensize(SCREEN *sp,
     bool useEnv = _nc_prescreen.use_env;
     bool useTioctl = _nc_prescreen.use_tioctl;
 
+    T((T_CALLED("_nc_get_screensize (%p)"), (void *) sp));
 #ifdef EXP_WIN32_DRIVER
     /* If we are here, then Windows console is used in terminfo mode.
        We need to figure out the size using the console API
@@ -326,6 +512,7 @@ _nc_get_screensize(SCREEN *sp,
     }
 #endif
 
+    T(("useEnv:%d useTioctl:%d", useEnv, useTioctl));
     if (useEnv || useTioctl) {
 #ifdef __EMX__
 	{
@@ -389,22 +576,10 @@ _nc_get_screensize(SCREEN *sp,
 		*colp = value;
 		T(("screen size: environment COLUMNS = %d", *colp));
 	    }
-	}
 
-	/* if we can't get dynamic info about the size, use static */
-	if (*linep <= 0) {
-	    *linep = (int) lines;
-	}
-	if (*colp <= 0) {
-	    *colp = (int) columns;
-	}
-
-	/* the ultimate fallback, assume fixed 24x80 size */
-	if (*linep <= 0) {
-	    *linep = 24;
-	}
-	if (*colp <= 0) {
-	    *colp = 80;
+	    _nc_default_screensize(termp, linep, colp);
+	} else {
+	    _nc_check_screensize(sp, termp, linep, colp);
 	}
 
 	/*
@@ -419,6 +594,8 @@ _nc_get_screensize(SCREEN *sp,
 	OldNumber(termp, lines) = (short) (*linep);
 	OldNumber(termp, columns) = (short) (*colp);
 #endif
+    } else {
+	_nc_check_screensize(sp, termp, linep, colp);
     }
 
     T(("screen size is %dx%d", *linep, *colp));
@@ -435,6 +612,7 @@ _nc_get_screensize(SCREEN *sp,
     TABSIZE = my_tabsize;
 #endif
     T(("TABSIZE = %d", TABSIZE));
+    returnVoid;
 #endif /* USE_TERM_DRIVER */
 }
 
@@ -503,6 +681,7 @@ _nc_setup_tinfo(const char *const tn, TERMTYPE2 *const tp)
      */
     if (status == TGETENT_YES) {
 	unsigned n;
+	T(("_nc_setup_tinfo - resetting invalid booleans/strings"));
 	for_each_boolean(n, tp) {
 	    if (!VALID_BOOLEAN(tp->Booleans[n]))
 		tp->Booleans[n] = FALSE;
@@ -517,9 +696,9 @@ _nc_setup_tinfo(const char *const tn, TERMTYPE2 *const tp)
 #endif
 
 /*
-**	Take the real command character out of the CC environment variable
-**	and substitute it in for the prototype given in 'command_character'.
-*/
+ * Take the real command character out of the CC environment variable
+ * and substitute it in for the prototype given in 'command_character'.
+ */
 void
 _nc_tinfo_cmdch(TERMINAL *termp, int proto)
 {
@@ -535,9 +714,12 @@ _nc_tinfo_cmdch(TERMINAL *termp, int proto)
 	char CC = *tmp;
 
 	for_each_string(i, &(termp->type)) {
-	    for (tmp = termp->type.Strings[i]; tmp && *tmp; tmp++) {
-		if (UChar(*tmp) == proto)
-		    *tmp = CC;
+	    tmp = termp->type.Strings[i];
+	    if (VALID_STRING(tmp)) {
+		for (; *tmp; ++tmp) {
+		    if (UChar(*tmp) == proto)
+			*tmp = CC;
+		}
 	    }
 	}
     }
@@ -573,22 +755,27 @@ _nc_get_locale(void)
 NCURSES_EXPORT(int)
 _nc_unicode_locale(void)
 {
-    int result = 0;
+    static bool initialized = FALSE;
+    static int result = 0;
+
+    if (!initialized) {
 #if defined(_NC_WINDOWS) && USE_WIDEC_SUPPORT
-    result = 1;
+	result = 1;
 #elif HAVE_LANGINFO_CODESET
-    char *env = nl_langinfo(CODESET);
-    result = !strcmp(env, "UTF-8");
-    T(("_nc_unicode_locale(%s) ->%d", env, result));
+	char *env = nl_langinfo(CODESET);
+	result = !strcmp(env, "UTF-8");
+	T(("_nc_unicode_locale(%s) ->%d", env, result));
 #else
-    char *env = _nc_get_locale();
-    if (env != 0) {
-	if (strstr(env, ".UTF-8") != 0) {
-	    result = 1;
-	    T(("_nc_unicode_locale(%s) ->%d", env, result));
+	char *env = _nc_get_locale();
+	if (env != 0) {
+	    if (strstr(env, ".UTF-8") != 0) {
+		result = 1;
+		T(("_nc_unicode_locale(%s) ->%d", env, result));
+	    }
 	}
-    }
 #endif
+	initialized = TRUE;
+    }
     return result;
 }
 
@@ -679,10 +866,9 @@ TINFO_SETUP_TERM(TERMINAL **tp,
 #endif
     }
     myname = strdup(tname);
-
-    if (strlen(myname) > MAX_NAME_SIZE) {
+    if (myname == NULL || strlen(myname) > MAX_NAME_SIZE) {
 	ret_error(TGETENT_ERR,
-		  "TERM environment must be <= %d characters.\n",
+		  "TERM environment must be 1..%d characters.\n",
 		  MAX_NAME_SIZE,
 		  free(myname));
     }
@@ -743,6 +929,7 @@ TINFO_SETUP_TERM(TERMINAL **tp,
 		       "Not enough memory to create terminal structure.\n",
 		       myname, free(myname));
 	}
+	++_nc_globals.terminal_count;
 #if HAVE_SYSCONF
 	{
 	    long limit;
@@ -763,10 +950,14 @@ TINFO_SETUP_TERM(TERMINAL **tp,
 
 #ifdef USE_TERM_DRIVER
 	INIT_TERM_DRIVER();
+	/*
+	 * _nc_get_driver() will call td_CanHandle() for each driver, and win_driver
+	 * needs file descriptor to do the test, so set it before calling.
+	 */
+	termp->Filedes = (short) Filedes;
 	TCB = (TERMINAL_CONTROL_BLOCK *) termp;
 	code = _nc_globals.term_driver(TCB, myname, errret);
 	if (code == OK) {
-	    termp->Filedes = (short) Filedes;
 	    termp->_termname = strdup(myname);
 	} else {
 	    ret_error1(errret ? *errret : TGETENT_ERR,
@@ -802,6 +993,7 @@ TINFO_SETUP_TERM(TERMINAL **tp,
 		ret_error1(status, "unknown terminal type.\n",
 			   myname, free(myname));
 	    } else {
+		free(myname);
 		ret_error0(status, "unexpected return-code\n");
 	    }
 	}
@@ -817,7 +1009,7 @@ TINFO_SETUP_TERM(TERMINAL **tp,
 
 	set_curterm(termp);
 
-	if (command_character)
+	if (VALID_STRING(command_character))
 	    _nc_tinfo_cmdch(termp, UChar(*command_character));
 
 	/*
@@ -829,7 +1021,7 @@ TINFO_SETUP_TERM(TERMINAL **tp,
 	if (NC_ISATTY(Filedes)) {
 	    NCURSES_SP_NAME(def_shell_mode) (NCURSES_SP_ARG);
 	    NCURSES_SP_NAME(def_prog_mode) (NCURSES_SP_ARG);
-	    baudrate();
+	    NCURSES_SP_NAME(baudrate) (NCURSES_SP_ARG);
 	}
 	code = OK;
 #endif
@@ -906,6 +1098,7 @@ _nc_forget_prescr(void)
 {
     PRESCREEN_LIST *p, *q;
     pthread_t id = GetThreadID();
+    _nc_lock_global(screen);
     for (p = _nc_prescreen.allocated, q = 0; p != 0; q = p, p = p->next) {
 	if (p->id == id) {
 	    if (q) {
@@ -917,6 +1110,7 @@ _nc_forget_prescr(void)
 	    break;
 	}
     }
+    _nc_unlock_global(screen);
 }
 #endif /* USE_PTHREADS */
 
@@ -988,6 +1182,7 @@ _nc_setupterm(const char *tname,
     int rc = ERR;
     TERMINAL *termp = 0;
 
+    _nc_init_pthreads();
     _nc_lock_global(prescreen);
     START_TRACE();
     if (TINFO_SETUP_TERM(&termp, tname, Filedes, errret, reuse) == OK) {
@@ -997,6 +1192,7 @@ _nc_setupterm(const char *tname,
 	}
     }
     _nc_unlock_global(prescreen);
+
     return rc;
 }
 #endif
diff --git a/contrib/ncurses/ncurses/tinfo/lib_termcap.c b/contrib/ncurses/ncurses/tinfo/lib_termcap.c
index e5016197f4a5..4632bdce7a5d 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_termcap.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_termcap.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2018-2020,2023 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -51,7 +51,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_termcap.c,v 1.88 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_termcap.c,v 1.89 2023/05/27 20:13:10 tom Exp $")
 
 NCURSES_EXPORT_VAR(char *) UP = 0;
 NCURSES_EXPORT_VAR(char *) BC = 0;
@@ -415,7 +415,7 @@ tgetstr(const char *id, char **area)
 #undef CacheInx
 #define CacheInx num
 NCURSES_EXPORT(void)
-_nc_tgetent_leak(TERMINAL *termp)
+_nc_tgetent_leak(const TERMINAL *const termp)
 {
     if (termp != 0) {
 	int num;
diff --git a/contrib/ncurses/ncurses/tinfo/lib_tgoto.c b/contrib/ncurses/ncurses/tinfo/lib_tgoto.c
index 9cf5e100ce87..58b561fa7c78 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_tgoto.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_tgoto.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2020,2023 Thomas E. Dickey                                *
  * Copyright 2000-2008,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -36,7 +36,7 @@
 #include <ctype.h>
 #include <termcap.h>
 
-MODULE_ID("$Id: lib_tgoto.c,v 1.21 2020/05/27 23:55:56 tom Exp $")
+MODULE_ID("$Id: lib_tgoto.c,v 1.23 2023/04/16 17:19:40 tom Exp $")
 
 #if !PURE_TERMINFO
 static bool
@@ -207,6 +207,16 @@ tgoto(const char *string, int x, int y)
 	result = tgoto_internal(string, x, y);
     else
 #endif
-	result = TIPARM_2(string, y, x);
+    if ((result = TIPARM_2(string, y, x)) == NULL) {
+	/*
+	 * Because termcap did not provide a more general solution such as
+	 * tparm(), it was necessary to handle single-parameter capabilities
+	 * using tgoto().  The internal _nc_tiparm() function returns a NULL
+	 * for that case; retry for the single-parameter case.
+	 */
+	if ((result = TIPARM_1(string, y)) == NULL) {
+	    result = TIPARM_0(string);
+	}
+    }
     returnPtr(result);
 }
diff --git a/contrib/ncurses/ncurses/tinfo/lib_tparm.c b/contrib/ncurses/ncurses/tinfo/lib_tparm.c
index b8104eabcd5e..5666b27b7e09 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_tparm.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_tparm.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2020,2021 Thomas E. Dickey                                *
+ * Copyright 2018-2021,2023 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -53,7 +53,7 @@
 #include <ctype.h>
 #include <tic.h>
 
-MODULE_ID("$Id: lib_tparm.c,v 1.129 2021/02/14 00:09:49 tom Exp $")
+MODULE_ID("$Id: lib_tparm.c,v 1.153 2023/11/04 19:28:41 tom Exp $")
 
 /*
  *	char *
@@ -117,9 +117,14 @@ MODULE_ID("$Id: lib_tparm.c,v 1.129 2021/02/14 00:09:49 tom Exp $")
 
 NCURSES_EXPORT_VAR(int) _nc_tparm_err = 0;
 
-#define TPS(var) _nc_prescreen.tparm_state.var
+#define TPS(var) tps->var
 #define popcount _nc_popcount	/* workaround for NetBSD 6.0 defect */
 
+#define get_tparm_state(term) \
+	    (term != NULL \
+	      ? &(term->tparm_state) \
+	      : &(_nc_prescreen.tparm_state))
+
 #define isUPPER(c) ((c) >= 'A' && (c) <= 'Z')
 #define isLOWER(c) ((c) >= 'a' && (c) <= 'z')
 #define tc_BUMP()  if (level < 0 && number < 2) number++
@@ -137,10 +142,8 @@ typedef struct {
 #if HAVE_TSEARCH
 #define MyCache _nc_globals.cached_tparm
 #define MyCount _nc_globals.count_tparm
-#if NO_LEAKS
 static int which_tparm;
 static TPARM_DATA **delete_tparm;
-#endif
 #endif /* HAVE_TSEARCH */
 
 static char dummy[] = "";	/* avoid const-cast */
@@ -155,10 +158,9 @@ cmp_format(const void *p, const void *q)
 }
 #endif
 
-#if NO_LEAKS
 #if HAVE_TSEARCH
 static void
-visit_nodes(const void *nodep, const VISIT which, const int depth)
+visit_nodes(const void *nodep, VISIT which, int depth)
 {
     (void) depth;
     if (which == preorder || which == leaf) {
@@ -169,22 +171,27 @@ visit_nodes(const void *nodep, const VISIT which, const int depth)
 #endif
 
 NCURSES_EXPORT(void)
-_nc_free_tparm(void)
+_nc_free_tparm(TERMINAL *termp)
 {
+    TPARM_STATE *tps = get_tparm_state(termp);
 #if HAVE_TSEARCH
     if (MyCount != 0) {
-	delete_tparm = typeMalloc(TPARM_DATA *, MyCount);
-	which_tparm = 0;
-	twalk(MyCache, visit_nodes);
-	for (which_tparm = 0; which_tparm < MyCount; ++which_tparm) {
-	    TPARM_DATA *ptr = delete_tparm[which_tparm];
-	    tdelete(ptr, &MyCache, cmp_format);
-	    free((char *) ptr->format);
-	    free(ptr);
+	delete_tparm = typeCalloc(TPARM_DATA *, MyCount);
+	if (delete_tparm != NULL) {
+	    which_tparm = 0;
+	    twalk(MyCache, visit_nodes);
+	    for (which_tparm = 0; which_tparm < MyCount; ++which_tparm) {
+		TPARM_DATA *ptr = delete_tparm[which_tparm];
+		if (ptr != NULL) {
+		    tdelete(ptr, &MyCache, cmp_format);
+		    free((char *) ptr->format);
+		    free(ptr);
+		}
+	    }
+	    which_tparm = 0;
+	    twalk(MyCache, visit_nodes);
+	    FreeAndNull(delete_tparm);
 	}
-	which_tparm = 0;
-	twalk(MyCache, visit_nodes);
-	FreeAndNull(delete_tparm);
 	MyCount = 0;
 	which_tparm = 0;
     }
@@ -196,107 +203,159 @@ _nc_free_tparm(void)
     FreeAndNull(TPS(fmt_buff));
     TPS(fmt_size) = 0;
 }
-#endif
 
-static NCURSES_INLINE void
-get_space(size_t need)
+static int
+tparm_error(TPARM_STATE *tps, const char *message)
 {
-    need += TPS(out_used);
-    if (need > TPS(out_size)) {
-	TPS(out_size) = need * 2;
-	TYPE_REALLOC(char, TPS(out_size), TPS(out_buff));
-    }
+    (void) tps;
+    (void) message;
+    DEBUG(2, ("%s: %s", message, _nc_visbuf(TPS(tparam_base))));
+    return ++_nc_tparm_err;
+}
+
+#define get_space(tps, need) \
+{ \
+    size_t need2get = need + TPS(out_used); \
+    if (need2get > TPS(out_size)) { \
+	TPS(out_size) = need2get * 2; \
+	TYPE_REALLOC(char, TPS(out_size), TPS(out_buff)); \
+    } \
 }
 
+#if NCURSES_EXPANDED
 static NCURSES_INLINE void
-save_text(const char *fmt, const char *s, int len)
-{
-    size_t s_len = (size_t) len + strlen(s) + strlen(fmt);
-    get_space(s_len + 1);
+  (get_space) (TPARM_STATE *tps, size_t need) {
+    get_space(tps, need);
+}
 
-    _nc_SPRINTF(TPS(out_buff) + TPS(out_used),
-		_nc_SLIMIT(TPS(out_size) - TPS(out_used))
-		fmt, s);
-    TPS(out_used) += strlen(TPS(out_buff) + TPS(out_used));
+#undef get_space
+#endif
+
+#define save_text(tps, fmt, s, len) \
+{ \
+    size_t s_len = (size_t) len + strlen(s) + strlen(fmt); \
+    get_space(tps, s_len + 1); \
+    _nc_SPRINTF(TPS(out_buff) + TPS(out_used), \
+		_nc_SLIMIT(TPS(out_size) - TPS(out_used)) \
+		fmt, s); \
+    TPS(out_used) += strlen(TPS(out_buff) + TPS(out_used)); \
 }
 
+#if NCURSES_EXPANDED
 static NCURSES_INLINE void
-save_number(const char *fmt, int number, int len)
-{
-    size_t s_len = (size_t) len + 30 + strlen(fmt);
-    get_space(s_len + 1);
+  (save_text) (TPARM_STATE *tps, const char *fmt, const char *s, int len) {
+    save_text(tps, fmt, s, len);
+}
 
-    _nc_SPRINTF(TPS(out_buff) + TPS(out_used),
-		_nc_SLIMIT(TPS(out_size) - TPS(out_used))
-		fmt, number);
-    TPS(out_used) += strlen(TPS(out_buff) + TPS(out_used));
+#undef save_text
+#endif
+
+#define save_number(tps, fmt, number, len) \
+{ \
+    size_t s_len = (size_t) len + 30 + strlen(fmt); \
+    get_space(tps, s_len + 1); \
+    _nc_SPRINTF(TPS(out_buff) + TPS(out_used), \
+		_nc_SLIMIT(TPS(out_size) - TPS(out_used)) \
+		fmt, number); \
+    TPS(out_used) += strlen(TPS(out_buff) + TPS(out_used)); \
 }
 
+#if NCURSES_EXPANDED
 static NCURSES_INLINE void
-save_char(int c)
-{
-    if (c == 0)
-	c = 0200;
-    get_space((size_t) 1);
-    TPS(out_buff)[TPS(out_used)++] = (char) c;
+  (save_number) (TPARM_STATE *tps, const char *fmt, int number, int len) {
+    save_number(tps, fmt, number, len);
 }
 
+#undef save_number
+#endif
+
+#define save_char(tps, c) \
+{ \
+    get_space(tps, (size_t) 1); \
+    TPS(out_buff)[TPS(out_used)++] = (char) ((c == 0) ? 0200 : c); \
+}
+
+#if NCURSES_EXPANDED
 static NCURSES_INLINE void
-npush(int x)
-{
-    if (TPS(stack_ptr) < STACKSIZE) {
-	TPS(stack)[TPS(stack_ptr)].num_type = TRUE;
-	TPS(stack)[TPS(stack_ptr)].data.num = x;
-	TPS(stack_ptr)++;
-    } else {
-	DEBUG(2, ("npush: stack overflow: %s", _nc_visbuf(TPS(tparam_base))));
-	_nc_tparm_err++;
-    }
+  (save_char) (TPARM_STATE *tps, int c) {
+    save_char(tps, c);
 }
 
-static NCURSES_INLINE int
-npop(void)
-{
-    int result = 0;
-    if (TPS(stack_ptr) > 0) {
-	TPS(stack_ptr)--;
-	if (TPS(stack)[TPS(stack_ptr)].num_type)
-	    result = TPS(stack)[TPS(stack_ptr)].data.num;
-    } else {
-	DEBUG(2, ("npop: stack underflow: %s", _nc_visbuf(TPS(tparam_base))));
-	_nc_tparm_err++;
-    }
-    return result;
+#undef save_char
+#endif
+
+#define npush(tps, x) \
+{ \
+    if (TPS(stack_ptr) < STACKSIZE) { \
+	TPS(stack)[TPS(stack_ptr)].num_type = TRUE; \
+	TPS(stack)[TPS(stack_ptr)].data.num = x; \
+	TPS(stack_ptr)++; \
+    } else { \
+	(void) tparm_error(tps, "npush: stack overflow"); \
+    } \
 }
 
+#if NCURSES_EXPANDED
 static NCURSES_INLINE void
-spush(char *x)
-{
-    if (TPS(stack_ptr) < STACKSIZE) {
-	TPS(stack)[TPS(stack_ptr)].num_type = FALSE;
-	TPS(stack)[TPS(stack_ptr)].data.str = x;
-	TPS(stack_ptr)++;
-    } else {
-	DEBUG(2, ("spush: stack overflow: %s", _nc_visbuf(TPS(tparam_base))));
-	_nc_tparm_err++;
-    }
+  (npush) (TPARM_STATE *tps, int x) {
+    npush(tps, x);
+}
+
+#undef npush
+#endif
+
+#define spush(tps, x) \
+{ \
+    if (TPS(stack_ptr) < STACKSIZE) { \
+	TPS(stack)[TPS(stack_ptr)].num_type = FALSE; \
+	TPS(stack)[TPS(stack_ptr)].data.str = x; \
+	TPS(stack_ptr)++; \
+    } else { \
+	(void) tparm_error(tps, "spush: stack overflow"); \
+    } \
 }
 
+#if NCURSES_EXPANDED
+static NCURSES_INLINE void
+  (spush) (TPARM_STATE *tps, char *x) {
+    spush(tps, x);
+}
+
+#undef spush
+#endif
+
+#define npop(tps) \
+    ((TPS(stack_ptr)-- > 0) \
+     ? ((TPS(stack)[TPS(stack_ptr)].num_type) \
+	 ? TPS(stack)[TPS(stack_ptr)].data.num \
+	 : 0) \
+     : (tparm_error(tps, "npop: stack underflow"), \
+        TPS(stack_ptr) = 0))
+
+#if NCURSES_EXPANDED
+static NCURSES_INLINE int
+  (npop) (TPARM_STATE *tps) {
+    return npop(tps);
+}
+#undef npop
+#endif
+
+#define spop(tps) \
+    ((TPS(stack_ptr)-- > 0) \
+     ? ((!TPS(stack)[TPS(stack_ptr)].num_type \
+        && TPS(stack)[TPS(stack_ptr)].data.str != 0) \
+         ? TPS(stack)[TPS(stack_ptr)].data.str \
+         : dummy) \
+     : (tparm_error(tps, "spop: stack underflow"), \
+        dummy))
+
+#if NCURSES_EXPANDED
 static NCURSES_INLINE char *
-spop(void)
-{
-    char *result = dummy;
-    if (TPS(stack_ptr) > 0) {
-	TPS(stack_ptr)--;
-	if (!TPS(stack)[TPS(stack_ptr)].num_type
-	    && TPS(stack)[TPS(stack_ptr)].data.str != 0)
-	    result = TPS(stack)[TPS(stack_ptr)].data.str;
-    } else {
-	DEBUG(2, ("spop: stack underflow: %s", _nc_visbuf(TPS(tparam_base))));
-	_nc_tparm_err++;
-    }
-    return result;
+  (spop) (TPARM_STATE *tps) {
+    return spop(tps);
 }
+#undef spop
+#endif
 
 static NCURSES_INLINE const char *
 parse_format(const char *s, char *format, int *len)
@@ -405,8 +464,9 @@ parse_format(const char *s, char *format, int *len)
  * may be cases that we cannot see the explicit parameter numbers.
  */
 NCURSES_EXPORT(int)
-_nc_tparm_analyze(const char *string, char **p_is_s, int *popcount)
+_nc_tparm_analyze(TERMINAL *term, const char *string, char **p_is_s, int *popcount)
 {
+    TPARM_STATE *tps = get_tparm_state(term);
     size_t len2;
     int i;
     int lastpop = -1;
@@ -539,15 +599,16 @@ _nc_tparm_analyze(const char *string, char **p_is_s, int *popcount)
  * TODO: cache the result so that this is done once per capability per term.
  */
 static int
-tparm_setup(const char *string, TPARM_DATA * result)
+tparm_setup(TERMINAL *term, const char *string, TPARM_DATA *result)
 {
+    TPARM_STATE *tps = get_tparm_state(term);
     int rc = OK;
 
     TPS(out_used) = 0;
     memset(result, 0, sizeof(*result));
 
-    if (string == NULL) {
-	TR(TRACE_CALLS, ("%s: format is null", TPS(tname)));
+    if (!VALID_STRING(string)) {
+	TR(TRACE_CALLS, ("%s: format is invalid", TPS(tname)));
 	rc = ERR;
     } else {
 #if HAVE_TSEARCH
@@ -556,8 +617,15 @@ tparm_setup(const char *string, TPARM_DATA * result)
 
 	result->format = string;
 	if ((ft = tfind(result, &MyCache, cmp_format)) != 0) {
+	    size_t len2;
 	    fs = *(TPARM_DATA **) ft;
 	    *result = *fs;
+	    if ((len2 = strlen(string)) + 2 > TPS(fmt_size)) {
+		TPS(fmt_size) += len2 + 2;
+		TPS(fmt_buff) = typeRealloc(char, TPS(fmt_size), TPS(fmt_buff));
+		if (TPS(fmt_buff) == 0)
+		    return ERR;
+	    }
 	} else
 #endif
 	{
@@ -566,7 +634,7 @@ tparm_setup(const char *string, TPARM_DATA * result)
 	     * string.  Use this value to limit the number of arguments copied
 	     * from the variable-length argument list.
 	     */
-	    result->num_parsed = _nc_tparm_analyze(string,
+	    result->num_parsed = _nc_tparm_analyze(term, string,
 						   result->p_is_s,
 						   &(result->num_popped));
 	    if (TPS(fmt_buff) == 0) {
@@ -579,7 +647,7 @@ tparm_setup(const char *string, TPARM_DATA * result)
 		    result->num_parsed = NUM_PARM;
 		if (result->num_popped > NUM_PARM)
 		    result->num_popped = NUM_PARM;
-		result->num_actual = max(result->num_popped, result->num_parsed);
+		result->num_actual = Max(result->num_popped, result->num_parsed);
 
 		for (n = 0; n < result->num_actual; ++n) {
 		    if (result->p_is_s[n])
@@ -592,9 +660,11 @@ tparm_setup(const char *string, TPARM_DATA * result)
 			if (tsearch(fs, &MyCache, cmp_format) != 0) {
 			    ++MyCount;
 			} else {
+			    free(fs);
 			    rc = ERR;
 			}
 		    } else {
+			free(fs);
 			rc = ERR;
 		    }
 		} else {
@@ -615,7 +685,7 @@ tparm_setup(const char *string, TPARM_DATA * result)
  * long's, which is consistent with our va_arg() usage.
  */
 static void
-tparm_copy_valist(TPARM_DATA * data, int use_TPARM_ARG, va_list ap)
+tparm_copy_valist(TPARM_DATA *data, int use_TPARM_ARG, va_list ap)
 {
     int i;
 
@@ -642,7 +712,7 @@ tparm_copy_valist(TPARM_DATA * data, int use_TPARM_ARG, va_list ap)
  * will expand termcap strings OK.
  */
 static bool
-tparm_tc_compat(TPARM_DATA * data)
+tparm_tc_compat(TPARM_STATE *tps, TPARM_DATA *data)
 {
     bool termcap_hack = FALSE;
 
@@ -653,10 +723,11 @@ tparm_tc_compat(TPARM_DATA * data)
 
 	termcap_hack = TRUE;
 	for (i = data->num_parsed - 1; i >= 0; i--) {
-	    if (data->p_is_s[i])
-		spush(data->p_is_s[i]);
-	    else
-		npush((int) data->param[i]);
+	    if (data->p_is_s[i]) {
+		spush(tps, data->p_is_s[i]);
+	    } else {
+		npush(tps, (int) data->param[i]);
+	    }
 	}
     }
     return termcap_hack;
@@ -664,20 +735,20 @@ tparm_tc_compat(TPARM_DATA * data)
 
 #ifdef TRACE
 static void
-tparm_trace_call(const char *string, TPARM_DATA * data)
+tparm_trace_call(TPARM_STATE *tps, const char *string, TPARM_DATA *data)
 {
     if (USE_TRACEF(TRACE_CALLS)) {
 	int i;
 	for (i = 0; i < data->num_actual; i++) {
 	    if (data->p_is_s[i] != 0) {
-		save_text(", %s", _nc_visbuf(data->p_is_s[i]), 0);
+		save_text(tps, ", %s", _nc_visbuf(data->p_is_s[i]), 0);
 	    } else if ((long) data->param[i] > MAX_OF_TYPE(NCURSES_INT2) ||
 		       (long) data->param[i] < 0) {
 		_tracef("BUG: problem with tparm parameter #%d of %d",
 			i + 1, data->num_actual);
 		break;
 	    } else {
-		save_number(", %d", (int) data->param[i], 0);
+		save_number(tps, ", %d", (int) data->param[i], 0);
 	    }
 	}
 	_tracef(T_CALLED("%s(%s%s)"), TPS(tname), _nc_visbuf(string), TPS(out_buff));
@@ -687,27 +758,54 @@ tparm_trace_call(const char *string, TPARM_DATA * data)
 }
 
 #else
-#define tparm_trace_call(string, data)	/* nothing */
+#define tparm_trace_call(tps, string, data)	/* nothing */
 #endif /* TRACE */
 
+#define init_vars(name) \
+	if (!name##_used) { \
+	    name##_used = TRUE; \
+	    memset(name##_vars, 0, sizeof(name##_vars)); \
+	}
+
 static NCURSES_INLINE char *
-tparam_internal(const char *string, TPARM_DATA * data)
+tparam_internal(TPARM_STATE *tps, const char *string, TPARM_DATA *data)
 {
     int number;
     int len;
     int level;
     int x, y;
     int i;
+    const char *s;
     const char *cp = string;
     size_t len2 = strlen(cp);
     bool incremented_two = FALSE;
-    bool termcap_hack = tparm_tc_compat(data);
-
-    tparm_trace_call(string, data);
+    bool termcap_hack = tparm_tc_compat(tps, data);
+    /*
+     * SVr4 curses stores variables 'A' to 'Z' in the TERMINAL structure (so
+     * they are initialized once to zero), and variables 'a' to 'z' on the
+     * stack in tparm, referring to the former as "static" and the latter as
+     * "dynamic".  However, it makes no check to ensure that the "dynamic"
+     * variables are initialized.
+     *
+     * Solaris xpg4 curses makes no distinction between the upper/lower, and
+     * stores the common set of 26 variables on the stack, without initializing
+     * them.
+     *
+     * In ncurses, both sets of variables are initialized on the first use.
+     */
+    bool dynamic_used = FALSE;
+    int dynamic_vars[NUM_VARS];
+
+    tparm_trace_call(tps, string, data);
+
+    if (TPS(fmt_buff) == NULL) {
+	T((T_RETURN("<null>")));
+	return NULL;
+    }
 
     while ((cp - string) < (int) len2) {
 	if (*cp != '%') {
-	    save_char(UChar(*cp));
+	    save_char(tps, UChar(*cp));
 	} else {
 	    TPS(tparam_base) = cp++;
 	    cp = parse_format(cp, TPS(fmt_buff), &len);
@@ -715,40 +813,44 @@ tparam_internal(const char *string, TPARM_DATA * data)
 	    default:
 		break;
 	    case '%':
-		save_char('%');
+		save_char(tps, '%');
 		break;
 
 	    case 'd':		/* FALLTHRU */
 	    case 'o':		/* FALLTHRU */
 	    case 'x':		/* FALLTHRU */
 	    case 'X':		/* FALLTHRU */
-		save_number(TPS(fmt_buff), npop(), len);
+		x = npop(tps);
+		save_number(tps, TPS(fmt_buff), x, len);
 		break;
 
 	    case 'c':		/* FALLTHRU */
-		save_char(npop());
+		x = npop(tps);
+		save_char(tps, x);
 		break;
 
 #ifdef EXP_XTERM_1005
 	    case 'u':
 		{
 		    unsigned char target[10];
-		    unsigned source = (unsigned) npop();
+		    unsigned source = (unsigned) npop(tps);
 		    int rc = _nc_conv_to_utf8(target, source, (unsigned)
 					      sizeof(target));
 		    int n;
 		    for (n = 0; n < rc; ++n) {
-			save_char(target[n]);
+			save_char(tps, target[n]);
 		    }
 		}
 		break;
 #endif
 	    case 'l':
-		npush((int) strlen(spop()));
+		s = spop(tps);
+		npush(tps, (int) strlen(s));
 		break;
 
 	    case 's':
-		save_text(TPS(fmt_buff), spop(), len);
+		s = spop(tps);
+		save_text(tps, TPS(fmt_buff), s, len);
 		break;
 
 	    case 'p':
@@ -756,9 +858,9 @@ tparam_internal(const char *string, TPARM_DATA * data)
 		i = (UChar(*cp) - '1');
 		if (i >= 0 && i < NUM_PARM) {
 		    if (data->p_is_s[i]) {
-			spush(data->p_is_s[i]);
+			spush(tps, data->p_is_s[i]);
 		    } else {
-			npush((int) data->param[i]);
+			npush(tps, (int) data->param[i]);
 		    }
 		}
 		break;
@@ -767,10 +869,11 @@ tparam_internal(const char *string, TPARM_DATA * data)
 		cp++;
 		if (isUPPER(*cp)) {
 		    i = (UChar(*cp) - 'A');
-		    TPS(static_vars)[i] = npop();
+		    TPS(static_vars)[i] = npop(tps);
 		} else if (isLOWER(*cp)) {
 		    i = (UChar(*cp) - 'a');
-		    TPS(dynamic_var)[i] = npop();
+		    init_vars(dynamic);
+		    dynamic_vars[i] = npop(tps);
 		}
 		break;
 
@@ -778,16 +881,17 @@ tparam_internal(const char *string, TPARM_DATA * data)
 		cp++;
 		if (isUPPER(*cp)) {
 		    i = (UChar(*cp) - 'A');
-		    npush(TPS(static_vars)[i]);
+		    npush(tps, TPS(static_vars)[i]);
 		} else if (isLOWER(*cp)) {
 		    i = (UChar(*cp) - 'a');
-		    npush(TPS(dynamic_var)[i]);
+		    init_vars(dynamic);
+		    npush(tps, dynamic_vars[i]);
 		}
 		break;
 
 	    case S_QUOTE:
 		cp++;
-		npush(UChar(*cp));
+		npush(tps, UChar(*cp));
 		cp++;
 		break;
 
@@ -798,83 +902,95 @@ tparam_internal(const char *string, TPARM_DATA * data)
 		    number = (number * 10) + (UChar(*cp) - '0');
 		    cp++;
 		}
-		npush(number);
+		npush(tps, number);
 		break;
 
 	    case '+':
-		npush(npop() + npop());
+		y = npop(tps);
+		x = npop(tps);
+		npush(tps, x + y);
 		break;
 
 	    case '-':
-		y = npop();
-		x = npop();
-		npush(x - y);
+		y = npop(tps);
+		x = npop(tps);
+		npush(tps, x - y);
 		break;
 
 	    case '*':
-		npush(npop() * npop());
+		y = npop(tps);
+		x = npop(tps);
+		npush(tps, x * y);
 		break;
 
 	    case '/':
-		y = npop();
-		x = npop();
-		npush(y ? (x / y) : 0);
+		y = npop(tps);
+		x = npop(tps);
+		npush(tps, y ? (x / y) : 0);
 		break;
 
 	    case 'm':
-		y = npop();
-		x = npop();
-		npush(y ? (x % y) : 0);
+		y = npop(tps);
+		x = npop(tps);
+		npush(tps, y ? (x % y) : 0);
 		break;
 
 	    case 'A':
-		y = npop();
-		x = npop();
-		npush(y && x);
+		y = npop(tps);
+		x = npop(tps);
+		npush(tps, y && x);
 		break;
 
 	    case 'O':
-		y = npop();
-		x = npop();
-		npush(y || x);
+		y = npop(tps);
+		x = npop(tps);
+		npush(tps, y || x);
 		break;
 
 	    case '&':
-		npush(npop() & npop());
+		y = npop(tps);
+		x = npop(tps);
+		npush(tps, x & y);
 		break;
 
 	    case '|':
-		npush(npop() | npop());
+		y = npop(tps);
+		x = npop(tps);
+		npush(tps, x | y);
 		break;
 
 	    case '^':
-		npush(npop() ^ npop());
+		y = npop(tps);
+		x = npop(tps);
+		npush(tps, x ^ y);
 		break;
 
 	    case '=':
-		y = npop();
-		x = npop();
-		npush(x == y);
+		y = npop(tps);
+		x = npop(tps);
+		npush(tps, x == y);
 		break;
 
 	    case '<':
-		y = npop();
-		x = npop();
-		npush(x < y);
+		y = npop(tps);
+		x = npop(tps);
+		npush(tps, x < y);
 		break;
 
 	    case '>':
-		y = npop();
-		x = npop();
-		npush(x > y);
+		y = npop(tps);
+		x = npop(tps);
+		npush(tps, x > y);
 		break;
 
 	    case '!':
-		npush(!npop());
+		x = npop(tps);
+		npush(tps, !x);
 		break;
 
 	    case '~':
-		npush(~npop());
+		x = npop(tps);
+		npush(tps, ~x);
 		break;
 
 	    case 'i':
@@ -904,7 +1020,7 @@ tparam_internal(const char *string, TPARM_DATA * data)
 		break;
 
 	    case 't':
-		x = npop();
+		x = npop(tps);
 		if (!x) {
 		    /* scan forward for %e or %; at level zero */
 		    cp++;
@@ -963,7 +1079,7 @@ tparam_internal(const char *string, TPARM_DATA * data)
 	cp++;
     }				/* endwhile (*cp) */
 
-    get_space((size_t) 1);
+    get_space(tps, (size_t) 1);
     TPS(out_buff)[TPS(out_used)] = '\0';
 
     if (TPS(stack_ptr) && !_nc_tparm_err) {
@@ -977,27 +1093,89 @@ tparam_internal(const char *string, TPARM_DATA * data)
     return (TPS(out_buff));
 }
 
+#ifdef CUR
+/*
+ * Only a few standard capabilities accept string parameters.  The others that
+ * are parameterized accept only numeric parameters.
+ */
+static bool
+check_string_caps(TPARM_DATA *data, const char *string)
+{
+    bool result = FALSE;
+
+#define CHECK_CAP(name) (VALID_STRING(name) && !strcmp(name, string))
+
+    /*
+     * Disallow string parameters unless we can check them against a terminal
+     * description.
+     */
+    if (cur_term != NULL) {
+	int want_type = 0;
+
+	if (CHECK_CAP(pkey_key))
+	    want_type = 2;	/* function key #1, type string #2 */
+	else if (CHECK_CAP(pkey_local))
+	    want_type = 2;	/* function key #1, execute string #2 */
+	else if (CHECK_CAP(pkey_xmit))
+	    want_type = 2;	/* function key #1, transmit string #2 */
+	else if (CHECK_CAP(plab_norm))
+	    want_type = 2;	/* label #1, show string #2 */
+#ifdef pkey_plab
+	else if (CHECK_CAP(pkey_plab))
+	    want_type = 6;	/* function key #1, type string #2, show string #3 */
+#endif
+#if NCURSES_XNAMES
+	else {
+	    char *check;
+
+	    check = tigetstr("Cs");
+	    if (CHECK_CAP(check))
+		want_type = 1;	/* style #1 */
+
+	    check = tigetstr("Ms");
+	    if (CHECK_CAP(check))
+		want_type = 3;	/* storage unit #1, content #2 */
+	}
+#endif
+
+	if (want_type == data->tparm_type) {
+	    result = TRUE;
+	} else {
+	    T(("unexpected string-parameter"));
+	}
+    }
+    return result;
+}
+
+#define ValidCap(allow_strings) (myData.tparm_type == 0 || \
+				 (allow_strings && \
+				  check_string_caps(&myData, string)))
+#else
+#define ValidCap(allow_strings) 1
+#endif
+
 #if NCURSES_TPARM_VARARGS
 
 NCURSES_EXPORT(char *)
 tparm(const char *string, ...)
 {
+    TPARM_STATE *tps = get_tparm_state(cur_term);
     TPARM_DATA myData;
-    va_list ap;
     char *result = NULL;
 
     _nc_tparm_err = 0;
 #ifdef TRACE
-    TPS(tname) = "tparm";
+    tps->tname = "tparm";
 #endif /* TRACE */
 
-    if (tparm_setup(string, &myData) == OK) {
+    if (tparm_setup(cur_term, string, &myData) == OK && ValidCap(TRUE)) {
+	va_list ap;
 
 	va_start(ap, string);
 	tparm_copy_valist(&myData, TRUE, ap);
 	va_end(ap);
 
-	result = tparam_internal(string, &myData);
+	result = tparam_internal(tps, string, &myData);
     }
     return result;
 }
@@ -1016,15 +1194,18 @@ tparm(const char *string,
       TPARM_ARG a8,
       TPARM_ARG a9)
 {
+    TPARM_STATE *tps = get_tparm_state(cur_term);
     TPARM_DATA myData;
     char *result = NULL;
 
     _nc_tparm_err = 0;
 #ifdef TRACE
-    TPS(tname) = "tparm";
+    tps->tname = "tparm";
 #endif /* TRACE */
 
-    if (tparm_setup(string, &myData) == OK) {
+#define string_ok (sizeof(char*) <= sizeof(TPARM_ARG))
+
+    if (tparm_setup(cur_term, string, &myData) == OK && ValidCap(string_ok)) {
 
 	myData.param[0] = a1;
 	myData.param[1] = a2;
@@ -1036,7 +1217,7 @@ tparm(const char *string,
 	myData.param[7] = a8;
 	myData.param[8] = a9;
 
-	result = tparam_internal(string, &myData);
+	result = tparam_internal(tps, string, &myData);
     }
     return result;
 }
@@ -1046,50 +1227,182 @@ tparm(const char *string,
 NCURSES_EXPORT(char *)
 tiparm(const char *string, ...)
 {
+    TPARM_STATE *tps = get_tparm_state(cur_term);
     TPARM_DATA myData;
-    va_list ap;
     char *result = NULL;
 
     _nc_tparm_err = 0;
 #ifdef TRACE
-    TPS(tname) = "tiparm";
+    tps->tname = "tiparm";
 #endif /* TRACE */
 
-    if (tparm_setup(string, &myData) == OK) {
+    if (tparm_setup(cur_term, string, &myData) == OK && ValidCap(TRUE)) {
+	va_list ap;
 
 	va_start(ap, string);
 	tparm_copy_valist(&myData, FALSE, ap);
 	va_end(ap);
 
-	result = tparam_internal(string, &myData);
+	result = tparam_internal(tps, string, &myData);
     }
     return result;
 }
 
 /*
- * The internal-use flavor ensures that the parameters are numbers, not strings
+ * Use tparm if the formatting string matches the expected number of parameters
+ * counting string-parameters.
  */
 NCURSES_EXPORT(char *)
-_nc_tiparm(int expected, const char *string, ...)
+tiparm_s(int num_expected, int tparm_type, const char *string, ...)
 {
+    TPARM_STATE *tps = get_tparm_state(cur_term);
     TPARM_DATA myData;
-    va_list ap;
     char *result = NULL;
 
     _nc_tparm_err = 0;
 #ifdef TRACE
-    TPS(tname) = "_nc_tiparm";
+    tps->tname = "tiparm_s";
 #endif /* TRACE */
-
-    if (tparm_setup(string, &myData) == OK
-	&& myData.num_actual <= expected
-	&& myData.tparm_type == 0) {
+    if (num_expected >= 0 &&
+	num_expected <= 9 &&
+	tparm_type >= 0 &&
+	tparm_type < 7 &&	/* limit to 2 string parameters */
+	tparm_setup(cur_term, string, &myData) == OK &&
+	myData.tparm_type == tparm_type &&
+	myData.num_actual == num_expected) {
+	va_list ap;
 
 	va_start(ap, string);
 	tparm_copy_valist(&myData, FALSE, ap);
 	va_end(ap);
 
-	result = tparam_internal(string, &myData);
+	result = tparam_internal(tps, string, &myData);
     }
     return result;
 }
+
+/*
+ * Analyze the formatting string, return the analysis.
+ */
+NCURSES_EXPORT(int)
+tiscan_s(int *num_expected, int *tparm_type, const char *string)
+{
+    TPARM_DATA myData;
+    int result = ERR;
+
+#ifdef TRACE
+    TPARM_STATE *tps = get_tparm_state(cur_term);
+    tps->tname = "tiscan_s";
+#endif /* TRACE */
+
+    if (tparm_setup(cur_term, string, &myData) == OK) {
+	*num_expected = myData.num_actual;
+	*tparm_type = myData.tparm_type;
+	result = OK;
+    }
+    return result;
+}
+
+/*
+ * The internal-use flavor ensures that parameters are numbers, not strings.
+ * In addition to ensuring that they are numbers, it ensures that the parameter
+ * count is consistent with intended usage.
+ *
+ * Unlike the general-purpose tparm/tiparm, these internal calls are fairly
+ * well defined:
+ *
+ * expected == 0 - not applicable
+ * expected == 1 - set color, or vertical/horizontal addressing
+ * expected == 2 - cursor addressing
+ * expected == 4 - initialize color or color pair
+ * expected == 9 - set attributes
+ *
+ * Only for the last case (set attributes) should a parameter be optional.
+ * Also, a capability which calls for more parameters than expected should be
+ * ignored.
+ *
+ * Return a null if the parameter-checks fail.  Otherwise, return a pointer to
+ * the formatted capability string.
+ */
+NCURSES_EXPORT(char *)
+_nc_tiparm(int expected, const char *string, ...)
+{
+    TPARM_STATE *tps = get_tparm_state(cur_term);
+    TPARM_DATA myData;
+    char *result = NULL;
+
+    _nc_tparm_err = 0;
+    T((T_CALLED("_nc_tiparm(%d, %s, ...)"), expected, _nc_visbuf(string)));
+#ifdef TRACE
+    tps->tname = "_nc_tiparm";
+#endif /* TRACE */
+
+    if (tparm_setup(cur_term, string, &myData) == OK && ValidCap(FALSE)) {
+#ifdef CUR
+	if (myData.num_actual != expected && cur_term != NULL) {
+	    int needed = expected;
+	    if (CHECK_CAP(to_status_line)) {
+		needed = 0;	/* allow for xterm's status line */
+	    } else if (CHECK_CAP(set_a_background)) {
+		needed = 0;	/* allow for monochrome fakers */
+	    } else if (CHECK_CAP(set_a_foreground)) {
+		needed = 0;
+	    } else if (CHECK_CAP(set_background)) {
+		needed = 0;
+	    } else if (CHECK_CAP(set_foreground)) {
+		needed = 0;
+	    }
+#if NCURSES_XNAMES
+	    else {
+		char *check;
+
+		check = tigetstr("xm");
+		if (CHECK_CAP(check)) {
+		    needed = 3;
+		}
+		check = tigetstr("S0");
+		if (CHECK_CAP(check)) {
+		    needed = 0;	/* used in screen-base */
+		}
+	    }
+#endif
+	    if (myData.num_actual >= needed && myData.num_actual <= expected)
+		expected = myData.num_actual;
+	}
+#endif
+	if (myData.num_actual == 0 && expected) {
+	    T(("missing parameter%s, expected %s%d",
+	       expected > 1 ? "s" : "",
+	       expected == 9 ? "up to " : "",
+	       expected));
+	} else if (myData.num_actual > expected) {
+	    T(("too many parameters, have %d, expected %d",
+	       myData.num_actual,
+	       expected));
+	} else if (expected != 9 && myData.num_actual != expected) {
+	    T(("expected %d parameters, have %d",
+	       myData.num_actual,
+	       expected));
+	} else {
+	    va_list ap;
+
+	    va_start(ap, string);
+	    tparm_copy_valist(&myData, FALSE, ap);
+	    va_end(ap);
+
+	    result = tparam_internal(tps, string, &myData);
+	}
+    }
+    returnPtr(result);
+}
+
+/*
+ * Improve tic's checks by resetting the terminfo "static variables" before
+ * calling functions which may update them.
+ */
+NCURSES_EXPORT(void)
+_nc_reset_tparm(TERMINAL *term)
+{
+    TPARM_STATE *tps = get_tparm_state(term);
+    memset(TPS(static_vars), 0, sizeof(TPS(static_vars)));
+}
diff --git a/contrib/ncurses/ncurses/tinfo/lib_tputs.c b/contrib/ncurses/ncurses/tinfo/lib_tputs.c
index 4b89a19ed9dd..f834532c9193 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_tputs.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_tputs.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2020,2021 Thomas E. Dickey                                *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -52,12 +52,12 @@
 #include <termcap.h>		/* ospeed */
 #include <tic.h>
 
-MODULE_ID("$Id: lib_tputs.c,v 1.107 2021/04/03 18:45:53 tom Exp $")
+MODULE_ID("$Id: lib_tputs.c,v 1.111 2023/09/16 16:05:15 tom Exp $")
 
 NCURSES_EXPORT_VAR(char) PC = 0;              /* used by termcap library */
 NCURSES_EXPORT_VAR(NCURSES_OSPEED) ospeed = 0;        /* used by termcap library */
 
-NCURSES_EXPORT_VAR(int) _nc_nulls_sent = 0;   /* used by 'tack' program */
+NCURSES_EXPORT_VAR(int) _nc_nulls_sent = 0;
 
 #if NCURSES_NO_PADDING
 NCURSES_EXPORT(void)
@@ -89,6 +89,9 @@ NCURSES_SP_NAME(delay_output) (NCURSES_SP_DCLx int ms)
 {
     T((T_CALLED("delay_output(%p,%d)"), (void *) SP_PARM, ms));
 
+    if (ms > MAX_DELAY_MSECS)
+	ms = MAX_DELAY_MSECS;
+
     if (!HasTInfoTerminal(SP_PARM))
 	returnCode(ERR);
 
@@ -128,9 +131,8 @@ NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_DCL0)
 			   SP_PARM->out_buffer));
 	if (SP_PARM->out_inuse) {
 	    char *buf = SP_PARM->out_buffer;
-	    size_t amount = SP->out_inuse;
+	    size_t amount = SP_PARM->out_inuse;
 
-	    SP->out_inuse = 0;
 	    TR(TRACE_CHARPUT, ("flushing %ld/%ld bytes",
 			       (unsigned long) amount, _nc_outchars));
 	    while (amount) {
@@ -155,6 +157,8 @@ NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_DCL0)
 	TR(TRACE_CHARPUT, ("flushing stdout"));
 	fflush(stdout);
     }
+    if (SP_PARM != 0)
+	SP_PARM->out_inuse = 0;
     returnVoid;
 }
 
@@ -276,8 +280,8 @@ NCURSES_SP_NAME(tputs) (NCURSES_SP_DCLx
 			NCURSES_SP_OUTC outc)
 {
     NCURSES_SP_OUTC my_outch = GetOutCh();
-    bool always_delay;
-    bool normal_delay;
+    bool always_delay = FALSE;
+    bool normal_delay = FALSE;
     int number;
 #if BSD_TPUTS
     int trailpad;
@@ -305,32 +309,30 @@ NCURSES_SP_NAME(tputs) (NCURSES_SP_DCLx
     }
 #endif /* TRACE */
 
-    if (SP_PARM != 0 && !HasTInfoTerminal(SP_PARM))
-	return ERR;
-
     if (!VALID_STRING(string))
 	return ERR;
 
-    if (
+    if (SP_PARM != 0 && HasTInfoTerminal(SP_PARM)) {
+	if (
 #if NCURSES_SP_FUNCS
-	   (SP_PARM != 0 && SP_PARM->_term == 0)
+	       (SP_PARM != 0 && SP_PARM->_term == 0)
 #else
-	   cur_term == 0
+	       cur_term == 0
 #endif
-	) {
-	always_delay = FALSE;
-	normal_delay = TRUE;
-    } else {
-	always_delay = (string == bell) || (string == flash_screen);
-	normal_delay =
-	    !xon_xoff
-	    && padding_baud_rate
+	    ) {
+	    always_delay = FALSE;
+	    normal_delay = TRUE;
+	} else {
+	    always_delay = (string == bell) || (string == flash_screen);
+	    normal_delay =
+		!xon_xoff
+		&& padding_baud_rate
 #if NCURSES_NO_PADDING
-	    && !GetNoPadding(SP_PARM)
+		&& !GetNoPadding(SP_PARM)
 #endif
-	    && (_nc_baudrate(ospeed) >= padding_baud_rate);
+		&& (_nc_baudrate(ospeed) >= padding_baud_rate);
+	}
     }
-
 #if BSD_TPUTS
     /*
      * This ugly kluge deals with the fact that some ancient BSD programs
diff --git a/contrib/ncurses/ncurses/tinfo/lib_win32con.c b/contrib/ncurses/ncurses/tinfo/lib_win32con.c
index 3c0fe8160734..2d6857aeb4a8 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_win32con.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_win32con.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020-2021,2023 Thomas E. Dickey                                *
  * Copyright 1998-2009,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -38,7 +38,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_win32con.c,v 1.6 2020/11/21 23:44:58 tom Exp $")
+MODULE_ID("$Id: lib_win32con.c,v 1.14 2023/08/05 20:44:38 tom Exp $")
 
 #ifdef _NC_WINDOWS
 
@@ -58,19 +58,7 @@ MODULE_ID("$Id: lib_win32con.c,v 1.6 2020/11/21 23:44:58 tom Exp $")
 #define read_screen  ReadConsoleOutput
 #endif
 
-static BOOL IsConsoleHandle(HANDLE hdl);
-static bool save_original_screen(void);
-static bool restore_original_screen(void) GCC_UNUSED;
 static bool read_screen_data(void);
-static int  Adjust(int milliseconds, int diff);
-static int  decode_mouse(SCREEN *sp, int mask);
-static bool handle_mouse(SCREEN *sp, MOUSE_EVENT_RECORD mer);
-static int  rkeycompare(const void *el1, const void *el2);
-static int  keycompare(const void *el1, const void *el2);
-static int  MapKey(WORD vKey);
-static int  AnsiKey(WORD vKey);
-
-static ULONGLONG tdiff(FILETIME fstart, FILETIME fend);
 
 #define GenMap(vKey,key) MAKELONG(key, vKey)
 static const LONG keylist[] =
@@ -104,7 +92,7 @@ static const LONG ansi_keys[] =
 #define FKEYS 24
 #define MAPSIZE (FKEYS + N_INI)
 
-/*   A process can only have a single console, so it's safe
+/*   A process can only have a single console, so it is safe
      to maintain all the information about it in a single
      static structure.
  */
@@ -136,32 +124,32 @@ _nc_console_vt_supported(void)
        osvi.dwMinorVersion,
        osvi.dwBuildNumber));
     if (osvi.dwMajorVersion >= REQUIRED_MAX_V) {
-      if (osvi.dwMajorVersion == REQUIRED_MAX_V) {
-          if (((osvi.dwMinorVersion == REQUIRED_MIN_V) &&
-               (osvi.dwBuildNumber >= REQUIRED_BUILD)) ||
-              ((osvi.dwMinorVersion > REQUIRED_MIN_V)))
-              res = 1;
-      } else
-          res = 1;
+	if (osvi.dwMajorVersion == REQUIRED_MAX_V) {
+	    if (((osvi.dwMinorVersion == REQUIRED_MIN_V) &&
+		 (osvi.dwBuildNumber >= REQUIRED_BUILD)) ||
+		((osvi.dwMinorVersion > REQUIRED_MIN_V)))
+		res = 1;
+	} else
+	    res = 1;
     }
     returnCode(res);
 }
 
 NCURSES_EXPORT(void)
-_nc_console_size(int* Lines, int* Cols)
+_nc_console_size(int *Lines, int *Cols)
 {
-  EnsureInit();
-  if (Lines != NULL && Cols != NULL) {
-      if (WINCONSOLE.buffered) {
-          *Lines = (int) (WINCONSOLE.SBI.dwSize.Y);
-          *Cols = (int) (WINCONSOLE.SBI.dwSize.X);
-      } else {
-          *Lines = (int) (WINCONSOLE.SBI.srWindow.Bottom + 1 -
-                          WINCONSOLE.SBI.srWindow.Top);
-          *Cols = (int) (WINCONSOLE.SBI.srWindow.Right + 1 -
-                         WINCONSOLE.SBI.srWindow.Left);
-      }
-  }
+    EnsureInit();
+    if (Lines != NULL && Cols != NULL) {
+	if (WINCONSOLE.buffered) {
+	    *Lines = (int) (WINCONSOLE.SBI.dwSize.Y);
+	    *Cols = (int) (WINCONSOLE.SBI.dwSize.X);
+	} else {
+	    *Lines = (int) (WINCONSOLE.SBI.srWindow.Bottom + 1 -
+			    WINCONSOLE.SBI.srWindow.Top);
+	    *Cols = (int) (WINCONSOLE.SBI.srWindow.Right + 1 -
+			   WINCONSOLE.SBI.srWindow.Left);
+	}
+    }
 }
 
 /* Convert a file descriptor into a HANDLE
@@ -188,9 +176,9 @@ IsConsoleHandle(HANDLE hdl)
     EnsureInit();
 
     if (!GetConsoleMode(hdl, &dwFlag)) {
-        T(("GetConsoleMode failed"));
+	T(("GetConsoleMode failed"));
     } else {
-        result = TRUE;
+	result = TRUE;
     }
 
     returnBool(result);
@@ -198,7 +186,7 @@ IsConsoleHandle(HANDLE hdl)
 
 /*   This is used when running in terminfo mode to discover,
      whether or not the "terminal" is actually a Windows
-     Console. It's the responsibility of the console to deal
+     Console. It is the responsibility of the console to deal
      with the terminal escape sequences that are sent by
      terminfo.
  */
@@ -219,8 +207,8 @@ NCURSES_EXPORT(void)
 _nc_console_selectActiveHandle(void)
 {
     if (WINCONSOLE.lastOut != WINCONSOLE.hdl) {
-        WINCONSOLE.lastOut = WINCONSOLE.hdl;
-        SetConsoleActiveScreenBuffer(WINCONSOLE.lastOut);
+	WINCONSOLE.lastOut = WINCONSOLE.hdl;
+	SetConsoleActiveScreenBuffer(WINCONSOLE.lastOut);
     }
 }
 
@@ -228,32 +216,32 @@ NCURSES_EXPORT(HANDLE)
 _nc_console_fd2handle(int fd)
 {
     HANDLE hdl = _nc_console_handle(fd);
-    if (hdl==WINCONSOLE.inp) {
-        T(("lib_win32con:validateHandle %d -> WINCONSOLE.inp", fd));
-    } else if (hdl==WINCONSOLE.hdl) {
-        T(("lib_win32con:validateHandle %d -> WINCONSOLE.hdl", fd));
-    } else if (hdl==WINCONSOLE.out) {
-        T(("lib_win32con:validateHandle %d -> WINCONSOLE.out", fd));
+    if (hdl == WINCONSOLE.inp) {
+	T(("lib_win32con:validateHandle %d -> WINCONSOLE.inp", fd));
+    } else if (hdl == WINCONSOLE.hdl) {
+	T(("lib_win32con:validateHandle %d -> WINCONSOLE.hdl", fd));
+    } else if (hdl == WINCONSOLE.out) {
+	T(("lib_win32con:validateHandle %d -> WINCONSOLE.out", fd));
     } else {
-        T(("lib_win32con:validateHandle %d maps to unknown HANDLE", fd));
-        hdl = INVALID_HANDLE_VALUE;
+	T(("lib_win32con:validateHandle %d maps to unknown HANDLE", fd));
+	hdl = INVALID_HANDLE_VALUE;
     }
 #if 1
     assert(hdl != INVALID_HANDLE_VALUE);
 #endif
     if (hdl != INVALID_HANDLE_VALUE) {
-        if (hdl != WINCONSOLE.inp && (!WINCONSOLE.isTermInfoConsole && WINCONSOLE.progMode)) {
-            if (hdl==WINCONSOLE.out && hdl!=WINCONSOLE.hdl) {
-                T(("lib_win32con:validateHandle forcing WINCONSOLE.out -> WINCONSOLE.hdl"));
-                hdl = WINCONSOLE.hdl;
-            }
-        }
+	if (hdl != WINCONSOLE.inp && (!WINCONSOLE.isTermInfoConsole && WINCONSOLE.progMode)) {
+	    if (hdl == WINCONSOLE.out && hdl != WINCONSOLE.hdl) {
+		T(("lib_win32con:validateHandle forcing WINCONSOLE.out -> WINCONSOLE.hdl"));
+		hdl = WINCONSOLE.hdl;
+	    }
+	}
     }
     return hdl;
 }
 
 NCURSES_EXPORT(int)
-_nc_console_setmode(HANDLE hdl, const TTY *arg)
+_nc_console_setmode(HANDLE hdl, const TTY * arg)
 {
     DWORD dwFlag = 0;
     int code = ERR;
@@ -261,86 +249,86 @@ _nc_console_setmode(HANDLE hdl, const TTY *arg)
 
     if (arg) {
 #ifdef TRACE
-        TTY TRCTTY;
+	TTY TRCTTY;
 #define TRCTTYOUT(flag) TRCTTY.dwFlagOut = flag
 #define TRCTTYIN(flag)  TRCTTY.dwFlagIn = flag
 #else
 #define TRCTTYOUT(flag)
 #define TRCTTYIN(flag)
 #endif
-        T(("lib_win32con:_nc_console_setmode %s", _nc_trace_ttymode(arg)));
-        if (hdl==WINCONSOLE.inp) {
-            dwFlag = arg->dwFlagIn | ENABLE_MOUSE_INPUT | VT_FLAG_IN;
-            if (WINCONSOLE.isTermInfoConsole)
-                dwFlag |= (VT_FLAG_IN);
-            else
-                dwFlag &= (DWORD) ~(VT_FLAG_IN);
-            TRCTTYIN(dwFlag);
-            SetConsoleMode(hdl, dwFlag);
-
-            alt = OutHandle();
-            dwFlag = arg->dwFlagOut;
-            if (WINCONSOLE.isTermInfoConsole)
-                dwFlag |= (VT_FLAG_OUT);
-            else
-                dwFlag |= (VT_FLAG_OUT);
-            TRCTTYOUT(dwFlag);
-            SetConsoleMode(alt, dwFlag);
-        } else {
-            dwFlag = arg->dwFlagOut;
-            if (WINCONSOLE.isTermInfoConsole)
-                dwFlag |= (VT_FLAG_OUT);
-            else
-                dwFlag |= (VT_FLAG_OUT);
-            TRCTTYOUT(dwFlag);
-            SetConsoleMode(hdl, dwFlag);
-
-            alt = WINCONSOLE.inp;
-            dwFlag = arg->dwFlagIn | ENABLE_MOUSE_INPUT;
-            if (WINCONSOLE.isTermInfoConsole)
-                dwFlag |= (VT_FLAG_IN);
-            else
-                dwFlag &= (DWORD) ~(VT_FLAG_IN);
-            TRCTTYIN(dwFlag);
-            SetConsoleMode(alt, dwFlag);
-            T(("effective mode set %s", _nc_trace_ttymode(&TRCTTY)));
-        }
-        code = OK;
+	T(("lib_win32con:_nc_console_setmode %s", _nc_trace_ttymode(arg)));
+	if (hdl == WINCONSOLE.inp) {
+	    dwFlag = arg->dwFlagIn | ENABLE_MOUSE_INPUT | VT_FLAG_IN;
+	    if (WINCONSOLE.isTermInfoConsole)
+		dwFlag |= (VT_FLAG_IN);
+	    else
+		dwFlag &= (DWORD) ~ (VT_FLAG_IN);
+	    TRCTTYIN(dwFlag);
+	    SetConsoleMode(hdl, dwFlag);
+
+	    alt = OutHandle();
+	    dwFlag = arg->dwFlagOut;
+	    if (WINCONSOLE.isTermInfoConsole)
+		dwFlag |= (VT_FLAG_OUT);
+	    else
+		dwFlag |= (VT_FLAG_OUT);
+	    TRCTTYOUT(dwFlag);
+	    SetConsoleMode(alt, dwFlag);
+	} else {
+	    dwFlag = arg->dwFlagOut;
+	    if (WINCONSOLE.isTermInfoConsole)
+		dwFlag |= (VT_FLAG_OUT);
+	    else
+		dwFlag |= (VT_FLAG_OUT);
+	    TRCTTYOUT(dwFlag);
+	    SetConsoleMode(hdl, dwFlag);
+
+	    alt = WINCONSOLE.inp;
+	    dwFlag = arg->dwFlagIn | ENABLE_MOUSE_INPUT;
+	    if (WINCONSOLE.isTermInfoConsole)
+		dwFlag |= (VT_FLAG_IN);
+	    else
+		dwFlag &= (DWORD) ~ (VT_FLAG_IN);
+	    TRCTTYIN(dwFlag);
+	    SetConsoleMode(alt, dwFlag);
+	    T(("effective mode set %s", _nc_trace_ttymode(&TRCTTY)));
+	}
+	code = OK;
     }
-    return(code);
+    return (code);
 }
 
 NCURSES_EXPORT(int)
-_nc_console_getmode(HANDLE hdl, TTY *arg)
+_nc_console_getmode(HANDLE hdl, TTY * arg)
 {
     int code = ERR;
 
     if (arg) {
-        DWORD dwFlag = 0;
-        HANDLE alt;
-
-        if (hdl==WINCONSOLE.inp) {
-            if(GetConsoleMode(hdl, &dwFlag)) {
-                arg->dwFlagIn = dwFlag;
-                alt = OutHandle();
-                if (GetConsoleMode(alt, &dwFlag)) {
-                    arg->dwFlagOut = dwFlag;
-                    code = OK;
-                }
-            }
-        } else {
-            if (GetConsoleMode(hdl, &dwFlag)) {
-                arg->dwFlagOut = dwFlag;
-                alt = WINCONSOLE.inp;
-                if (GetConsoleMode(alt, &dwFlag)) {
-                    arg->dwFlagIn = dwFlag;
-                    code = OK;
-                }
-            }
-        }
+	DWORD dwFlag = 0;
+	HANDLE alt;
+
+	if (hdl == WINCONSOLE.inp) {
+	    if (GetConsoleMode(hdl, &dwFlag)) {
+		arg->dwFlagIn = dwFlag;
+		alt = OutHandle();
+		if (GetConsoleMode(alt, &dwFlag)) {
+		    arg->dwFlagOut = dwFlag;
+		    code = OK;
+		}
+	    }
+	} else {
+	    if (GetConsoleMode(hdl, &dwFlag)) {
+		arg->dwFlagOut = dwFlag;
+		alt = WINCONSOLE.inp;
+		if (GetConsoleMode(alt, &dwFlag)) {
+		    arg->dwFlagIn = dwFlag;
+		    code = OK;
+		}
+	    }
+	}
     }
     T(("lib_win32con:_nc_console_getmode %s", _nc_trace_ttymode(arg)));
-    return(code);
+    return (code);
 }
 
 NCURSES_EXPORT(int)
@@ -351,15 +339,15 @@ _nc_console_flush(HANDLE hdl)
     T((T_CALLED("lib_win32con::_nc_console_flush(hdl=%p"), hdl));
 
     if (hdl != INVALID_HANDLE_VALUE) {
-        if (hdl == WINCONSOLE.hdl ||
-            hdl == WINCONSOLE.inp ||
-            hdl == WINCONSOLE.out) {
-            if (!FlushConsoleInputBuffer(WINCONSOLE.inp))
-                code = ERR;
-        } else {
-            code = ERR;
-            T(("_nc_console_flush not requesting a handle owned by console."));
-        }
+	if (hdl == WINCONSOLE.hdl ||
+	    hdl == WINCONSOLE.inp ||
+	    hdl == WINCONSOLE.out) {
+	    if (!FlushConsoleInputBuffer(WINCONSOLE.inp))
+		code = ERR;
+	} else {
+	    code = ERR;
+	    T(("_nc_console_flush not requesting a handle owned by console."));
+	}
     }
     returnCode(code);
 }
@@ -368,18 +356,17 @@ NCURSES_EXPORT(WORD)
 _nc_console_MapColor(bool fore, int color)
 {
     static const int _cmap[] =
-        {0, 4, 2, 6, 1, 5, 3, 7};
+    {0, 4, 2, 6, 1, 5, 3, 7};
     int a;
     if (color < 0 || color > 7)
-        a = fore ? 7 : 0;
+	a = fore ? 7 : 0;
     else
-        a = _cmap[color];
+	a = _cmap[color];
     if (!fore)
-        a = a << 4;
+	a = a << 4;
     return (WORD) a;
 }
 
-
 /*
  * Attempt to save the screen contents.  PDCurses does this if
  * PDC_RESTORE_SCREEN is set, giving the same visual appearance on
@@ -398,25 +385,26 @@ save_original_screen(void)
     WINCONSOLE.save_region.Right = (SHORT) (WINCONSOLE.SBI.dwSize.X - 1);
 
     if (read_screen_data()) {
-        result = TRUE;
+	result = TRUE;
     } else {
 
-        WINCONSOLE.save_region.Top = WINCONSOLE.SBI.srWindow.Top;
-        WINCONSOLE.save_region.Left = WINCONSOLE.SBI.srWindow.Left;
-        WINCONSOLE.save_region.Bottom = WINCONSOLE.SBI.srWindow.Bottom;
-        WINCONSOLE.save_region.Right = WINCONSOLE.SBI.srWindow.Right;
+	WINCONSOLE.save_region.Top = WINCONSOLE.SBI.srWindow.Top;
+	WINCONSOLE.save_region.Left = WINCONSOLE.SBI.srWindow.Left;
+	WINCONSOLE.save_region.Bottom = WINCONSOLE.SBI.srWindow.Bottom;
+	WINCONSOLE.save_region.Right = WINCONSOLE.SBI.srWindow.Right;
 
-        WINCONSOLE.window_only = TRUE;
+	WINCONSOLE.window_only = TRUE;
 
-        if (read_screen_data()) {
-            result = TRUE;
-        }
+	if (read_screen_data()) {
+	    result = TRUE;
+	}
     }
 
     T(("... save original screen contents %s", result ? "ok" : "err"));
     return result;
 }
 
+#if 0
 static bool
 restore_original_screen(void)
 {
@@ -428,29 +416,30 @@ restore_original_screen(void)
        WINCONSOLE.window_only ? "window" : "entire buffer"));
 
     bufferCoord.X = (SHORT) (WINCONSOLE.window_only ?
-                             WINCONSOLE.SBI.srWindow.Left : 0);
+			     WINCONSOLE.SBI.srWindow.Left : 0);
     bufferCoord.Y = (SHORT) (WINCONSOLE.window_only ?
-                             WINCONSOLE.SBI.srWindow.Top : 0);
+			     WINCONSOLE.SBI.srWindow.Top : 0);
 
     if (write_screen(WINCONSOLE.hdl,
-                     WINCONSOLE.save_screen,
-                     WINCONSOLE.save_size,
-                     bufferCoord,
-                     &save_region)) {
-        result = TRUE;
-        mvcur(-1, -1, LINES - 2, 0);
-        T(("... restore original screen contents ok %dx%d (%d,%d - %d,%d)",
-           WINCONSOLE.save_size.Y,
-           WINCONSOLE.save_size.X,
-           save_region.Top,
-           save_region.Left,
-           save_region.Bottom,
-           save_region.Right));
+		     WINCONSOLE.save_screen,
+		     WINCONSOLE.save_size,
+		     bufferCoord,
+		     &save_region)) {
+	result = TRUE;
+	mvcur(-1, -1, LINES - 2, 0);
+	T(("... restore original screen contents ok %dx%d (%d,%d - %d,%d)",
+	   WINCONSOLE.save_size.Y,
+	   WINCONSOLE.save_size.X,
+	   save_region.Top,
+	   save_region.Left,
+	   save_region.Bottom,
+	   save_region.Right));
     } else {
-        T(("... restore original screen contents err"));
+	T(("... restore original screen contents err"));
     }
     return result;
 }
+#endif
 
 static bool
 read_screen_data(void)
@@ -460,38 +449,38 @@ read_screen_data(void)
     size_t want;
 
     WINCONSOLE.save_size.X = (SHORT) (WINCONSOLE.save_region.Right
-                                      - WINCONSOLE.save_region.Left + 1);
+				      - WINCONSOLE.save_region.Left + 1);
     WINCONSOLE.save_size.Y = (SHORT) (WINCONSOLE.save_region.Bottom
-                                      - WINCONSOLE.save_region.Top + 1);
+				      - WINCONSOLE.save_region.Top + 1);
 
     want = (size_t) (WINCONSOLE.save_size.X * WINCONSOLE.save_size.Y);
 
     if ((WINCONSOLE.save_screen = malloc(want * sizeof(CHAR_INFO))) != 0) {
-        bufferCoord.X = (SHORT) (WINCONSOLE.window_only ?
-                                 WINCONSOLE.SBI.srWindow.Left : 0);
-        bufferCoord.Y = (SHORT) (WINCONSOLE.window_only ?
-                                 WINCONSOLE.SBI.srWindow.Top : 0);
-
-        T(("... reading console %s %dx%d into %d,%d - %d,%d at %d,%d",
-           WINCONSOLE.window_only ? "window" : "buffer",
-           WINCONSOLE.save_size.Y, WINCONSOLE.save_size.X,
-           WINCONSOLE.save_region.Top,
-           WINCONSOLE.save_region.Left,
-           WINCONSOLE.save_region.Bottom,
-           WINCONSOLE.save_region.Right,
-           bufferCoord.Y,
-           bufferCoord.X));
-
-        if (read_screen(WINCONSOLE.hdl,
-                        WINCONSOLE.save_screen,
-                        WINCONSOLE.save_size,
-                        bufferCoord,
-                        &WINCONSOLE.save_region)) {
-            result = TRUE;
-        } else {
-            T((" error %#lx", (unsigned long) GetLastError()));
-            FreeAndNull(WINCONSOLE.save_screen);
-        }
+	bufferCoord.X = (SHORT) (WINCONSOLE.window_only ?
+				 WINCONSOLE.SBI.srWindow.Left : 0);
+	bufferCoord.Y = (SHORT) (WINCONSOLE.window_only ?
+				 WINCONSOLE.SBI.srWindow.Top : 0);
+
+	T(("... reading console %s %dx%d into %d,%d - %d,%d at %d,%d",
+	   WINCONSOLE.window_only ? "window" : "buffer",
+	   WINCONSOLE.save_size.Y, WINCONSOLE.save_size.X,
+	   WINCONSOLE.save_region.Top,
+	   WINCONSOLE.save_region.Left,
+	   WINCONSOLE.save_region.Bottom,
+	   WINCONSOLE.save_region.Right,
+	   bufferCoord.Y,
+	   bufferCoord.X));
+
+	if (read_screen(WINCONSOLE.hdl,
+			WINCONSOLE.save_screen,
+			WINCONSOLE.save_size,
+			bufferCoord,
+			&WINCONSOLE.save_region)) {
+	    result = TRUE;
+	} else {
+	    T((" error %#lx", (unsigned long) GetLastError()));
+	    FreeAndNull(WINCONSOLE.save_screen);
+	}
     }
 
     return result;
@@ -502,31 +491,31 @@ _nc_console_get_SBI(void)
 {
     bool rc = FALSE;
     if (GetConsoleScreenBufferInfo(WINCONSOLE.hdl, &(WINCONSOLE.SBI))) {
-        T(("GetConsoleScreenBufferInfo"));
-        T(("... buffer(X:%d Y:%d)",
-           WINCONSOLE.SBI.dwSize.X,
-           WINCONSOLE.SBI.dwSize.Y));
-        T(("... window(X:%d Y:%d)",
-           WINCONSOLE.SBI.dwMaximumWindowSize.X,
-           WINCONSOLE.SBI.dwMaximumWindowSize.Y));
-        T(("... cursor(X:%d Y:%d)",
-           WINCONSOLE.SBI.dwCursorPosition.X,
-           WINCONSOLE.SBI.dwCursorPosition.Y));
-        T(("... display(Top:%d Bottom:%d Left:%d Right:%d)",
-           WINCONSOLE.SBI.srWindow.Top,
-           WINCONSOLE.SBI.srWindow.Bottom,
-           WINCONSOLE.SBI.srWindow.Left,
-           WINCONSOLE.SBI.srWindow.Right));
-        if (WINCONSOLE.buffered) {
-            WINCONSOLE.origin.X = 0;
-            WINCONSOLE.origin.Y = 0;
-        } else {
-            WINCONSOLE.origin.X = WINCONSOLE.SBI.srWindow.Left;
-            WINCONSOLE.origin.Y = WINCONSOLE.SBI.srWindow.Top;
-        }
-        rc = TRUE;
+	T(("GetConsoleScreenBufferInfo"));
+	T(("... buffer(X:%d Y:%d)",
+	   WINCONSOLE.SBI.dwSize.X,
+	   WINCONSOLE.SBI.dwSize.Y));
+	T(("... window(X:%d Y:%d)",
+	   WINCONSOLE.SBI.dwMaximumWindowSize.X,
+	   WINCONSOLE.SBI.dwMaximumWindowSize.Y));
+	T(("... cursor(X:%d Y:%d)",
+	   WINCONSOLE.SBI.dwCursorPosition.X,
+	   WINCONSOLE.SBI.dwCursorPosition.Y));
+	T(("... display(Top:%d Bottom:%d Left:%d Right:%d)",
+	   WINCONSOLE.SBI.srWindow.Top,
+	   WINCONSOLE.SBI.srWindow.Bottom,
+	   WINCONSOLE.SBI.srWindow.Left,
+	   WINCONSOLE.SBI.srWindow.Right));
+	if (WINCONSOLE.buffered) {
+	    WINCONSOLE.origin.X = 0;
+	    WINCONSOLE.origin.Y = 0;
+	} else {
+	    WINCONSOLE.origin.X = WINCONSOLE.SBI.srWindow.Left;
+	    WINCONSOLE.origin.Y = WINCONSOLE.SBI.srWindow.Top;
+	}
+	rc = TRUE;
     } else {
-        T(("GetConsoleScreenBufferInfo ERR"));
+	T(("GetConsoleScreenBufferInfo ERR"));
     }
     return rc;
 }
@@ -546,8 +535,8 @@ _nc_console_set_scrollback(bool normal, CONSOLE_SCREEN_BUFFER_INFO * info)
 
     T((T_CALLED("lib_win32con::_nc_console_set_scrollback(%s)"),
        (normal
-        ? "normal"
-        : "application")));
+	? "normal"
+	: "application")));
 
     T(("... SBI.srWindow %d,%d .. %d,%d",
        info->srWindow.Top,
@@ -559,52 +548,52 @@ _nc_console_set_scrollback(bool normal, CONSOLE_SCREEN_BUFFER_INFO * info)
        info->dwSize.X));
 
     if (normal) {
-        rect = info->srWindow;
-        coord = info->dwSize;
-        if (memcmp(info, &WINCONSOLE.SBI, sizeof(*info)) != 0) {
-            changed = TRUE;
-            WINCONSOLE.SBI = *info;
-        }
+	rect = info->srWindow;
+	coord = info->dwSize;
+	if (memcmp(info, &WINCONSOLE.SBI, sizeof(*info)) != 0) {
+	    changed = TRUE;
+	    WINCONSOLE.SBI = *info;
+	}
     } else {
-        int high = info->srWindow.Bottom - info->srWindow.Top + 1;
-        int wide = info->srWindow.Right - info->srWindow.Left + 1;
-
-        if (high < MIN_HIGH) {
-            T(("... height %d < %d", high, MIN_HIGH));
-            high = MIN_HIGH;
-            changed = TRUE;
-        }
-        if (wide < MIN_WIDE) {
-            T(("... width %d < %d", wide, MIN_WIDE));
-            wide = MIN_WIDE;
-            changed = TRUE;
-        }
-
-        rect.Left =
-            rect.Top = 0;
-        rect.Right = (SHORT) (wide - 1);
-        rect.Bottom = (SHORT) (high - 1);
-
-        coord.X = (SHORT) wide;
-        coord.Y = (SHORT) high;
-
-        if (info->dwSize.Y != high ||
-            info->dwSize.X != wide ||
-            info->srWindow.Top != 0 ||
-            info->srWindow.Left != 0) {
-            changed = TRUE;
-        }
+	int high = info->srWindow.Bottom - info->srWindow.Top + 1;
+	int wide = info->srWindow.Right - info->srWindow.Left + 1;
+
+	if (high < MIN_HIGH) {
+	    T(("... height %d < %d", high, MIN_HIGH));
+	    high = MIN_HIGH;
+	    changed = TRUE;
+	}
+	if (wide < MIN_WIDE) {
+	    T(("... width %d < %d", wide, MIN_WIDE));
+	    wide = MIN_WIDE;
+	    changed = TRUE;
+	}
+
+	rect.Left =
+	    rect.Top = 0;
+	rect.Right = (SHORT) (wide - 1);
+	rect.Bottom = (SHORT) (high - 1);
+
+	coord.X = (SHORT) wide;
+	coord.Y = (SHORT) high;
+
+	if (info->dwSize.Y != high ||
+	    info->dwSize.X != wide ||
+	    info->srWindow.Top != 0 ||
+	    info->srWindow.Left != 0) {
+	    changed = TRUE;
+	}
 
     }
 
     if (changed) {
-        T(("... coord %d,%d", coord.Y, coord.X));
-        T(("... rect %d,%d - %d,%d",
-           rect.Top, rect.Left,
-           rect.Bottom, rect.Right));
-        SetConsoleScreenBufferSize(WINCONSOLE.hdl, coord);      /* dwSize */
-        SetConsoleWindowInfo(WINCONSOLE.hdl, TRUE, &rect);      /* srWindow */
-        _nc_console_get_SBI();
+	T(("... coord %d,%d", coord.Y, coord.X));
+	T(("... rect %d,%d - %d,%d",
+	   rect.Top, rect.Left,
+	   rect.Bottom, rect.Right));
+	SetConsoleScreenBufferSize(WINCONSOLE.hdl, coord);	/* dwSize */
+	SetConsoleWindowInfo(WINCONSOLE.hdl, TRUE, &rect);	/* srWindow */
+	_nc_console_get_SBI();
     }
     returnVoid;
 }
@@ -629,9 +618,9 @@ static int
 Adjust(int milliseconds, int diff)
 {
     if (milliseconds != INFINITY) {
-        milliseconds -= diff;
-        if (milliseconds < 0)
-            milliseconds = 0;
+	milliseconds -= diff;
+	if (milliseconds < 0)
+	    milliseconds = 0;
     }
     return milliseconds;
 }
@@ -642,38 +631,38 @@ Adjust(int milliseconds, int diff)
                      FROM_LEFT_4TH_BUTTON_PRESSED | \
                      RIGHTMOST_BUTTON_PRESSED)
 
-static int
+static mmask_t
 decode_mouse(SCREEN *sp, int mask)
 {
-    int result = 0;
+    mmask_t result = 0;
 
     (void) sp;
     assert(sp && console_initialized);
 
     if (mask & FROM_LEFT_1ST_BUTTON_PRESSED)
-        result |= BUTTON1_PRESSED;
+	result |= BUTTON1_PRESSED;
     if (mask & FROM_LEFT_2ND_BUTTON_PRESSED)
-        result |= BUTTON2_PRESSED;
+	result |= BUTTON2_PRESSED;
     if (mask & FROM_LEFT_3RD_BUTTON_PRESSED)
-        result |= BUTTON3_PRESSED;
+	result |= BUTTON3_PRESSED;
     if (mask & FROM_LEFT_4TH_BUTTON_PRESSED)
-        result |= BUTTON4_PRESSED;
+	result |= BUTTON4_PRESSED;
 
     if (mask & RIGHTMOST_BUTTON_PRESSED) {
-        switch (WINCONSOLE.numButtons) {
-        case 1:
-            result |= BUTTON1_PRESSED;
-            break;
-        case 2:
-            result |= BUTTON2_PRESSED;
-            break;
-        case 3:
-            result |= BUTTON3_PRESSED;
-            break;
-        case 4:
-            result |= BUTTON4_PRESSED;
-            break;
-        }
+	switch (WINCONSOLE.numButtons) {
+	case 1:
+	    result |= BUTTON1_PRESSED;
+	    break;
+	case 2:
+	    result |= BUTTON2_PRESSED;
+	    break;
+	case 3:
+	    result |= BUTTON3_PRESSED;
+	    break;
+	case 4:
+	    result |= BUTTON4_PRESSED;
+	    break;
+	}
     }
 
     return result;
@@ -697,26 +686,22 @@ handle_mouse(SCREEN *sp, MOUSE_EVENT_RECORD mer)
      * FIXME: implement continuous event-tracking.
      */
     if (sp->_drv_mouse_new_buttons != sp->_drv_mouse_old_buttons) {
-        memset(&work, 0, sizeof(work));
-
-        if (sp->_drv_mouse_new_buttons) {
-            work.bstate |=
-                (mmask_t) decode_mouse(sp,
-                                       sp->_drv_mouse_new_buttons);
-        } else {
-            /* cf: BUTTON_PRESSED, BUTTON_RELEASED */
-            work.bstate |=
-                (mmask_t) (decode_mouse(sp,
-                                        sp->_drv_mouse_old_buttons)
-                           >> 1);
-            result = TRUE;
-        }
-
-        work.x = mer.dwMousePosition.X;
-        work.y = mer.dwMousePosition.Y - AdjustY();
-
-        sp->_drv_mouse_fifo[sp->_drv_mouse_tail] = work;
-        sp->_drv_mouse_tail += 1;
+	memset(&work, 0, sizeof(work));
+
+	if (sp->_drv_mouse_new_buttons) {
+	    work.bstate |= decode_mouse(sp, sp->_drv_mouse_new_buttons);
+	} else {
+	    /* cf: BUTTON_PRESSED, BUTTON_RELEASED */
+	    work.bstate |= (decode_mouse(sp, sp->_drv_mouse_old_buttons)
+			    >> 1);
+	    result = TRUE;
+	}
+
+	work.x = mer.dwMousePosition.X;
+	work.y = mer.dwMousePosition.Y - AdjustY();
+
+	sp->_drv_mouse_fifo[sp->_drv_mouse_tail] = work;
+	sp->_drv_mouse_tail += 1;
     }
     return result;
 }
@@ -730,7 +715,6 @@ rkeycompare(const void *el1, const void *el2)
     return ((key1 < key2) ? -1 : ((key1 == key2) ? 0 : 1));
 }
 
-
 static int
 keycompare(const void *el1, const void *el2)
 {
@@ -746,22 +730,22 @@ MapKey(WORD vKey)
     int code = -1;
 
     if (!WINCONSOLE.isTermInfoConsole) {
-        WORD nKey = 0;
-        void *res;
-        LONG key = GenMap(vKey, 0);
-
-        res = bsearch(&key,
-                      WINCONSOLE.map,
-                      (size_t) (N_INI + FKEYS),
-                      sizeof(keylist[0]),
-                      keycompare);
-        if (res) {
-            key = *((LONG *) res);
-            nKey = LOWORD(key);
-            code = (int) (nKey & 0x7fff);
-            if (nKey & 0x8000)
-                code = -code;
-        }
+	WORD nKey = 0;
+	void *res;
+	LONG key = GenMap(vKey, 0);
+
+	res = bsearch(&key,
+		      WINCONSOLE.map,
+		      (size_t) (N_INI + FKEYS),
+		      sizeof(keylist[0]),
+		      keycompare);
+	if (res) {
+	    key = *((LONG *) res);
+	    nKey = LOWORD(key);
+	    code = (int) (nKey & 0x7fff);
+	    if (nKey & 0x8000)
+		code = -code;
+	}
     }
     return code;
 }
@@ -772,22 +756,22 @@ AnsiKey(WORD vKey)
     int code = -1;
 
     if (!WINCONSOLE.isTermInfoConsole) {
-        WORD nKey = 0;
-        void *res;
-        LONG key = GenMap(vKey, 0);
-
-        res = bsearch(&key,
-                      WINCONSOLE.ansi_map,
-                      (size_t) (N_INI + FKEYS),
-                      sizeof(keylist[0]),
-                      keycompare);
-        if (res) {
-            key = *((LONG *) res);
-            nKey = LOWORD(key);
-            code = (int) (nKey & 0x7fff);
-            if (nKey & 0x8000)
-                code = -code;
-        }
+	WORD nKey = 0;
+	void *res;
+	LONG key = GenMap(vKey, 0);
+
+	res = bsearch(&key,
+		      WINCONSOLE.ansi_map,
+		      (size_t) (N_INI + FKEYS),
+		      sizeof(keylist[0]),
+		      keycompare);
+	if (res) {
+	    key = *((LONG *) res);
+	    nKey = LOWORD(key);
+	    code = (int) (nKey & 0x7fff);
+	    if (nKey & 0x8000)
+		code = -code;
+	}
     }
     return code;
 }
@@ -804,17 +788,17 @@ _nc_console_keyok(int keycode, int flag)
     T((T_CALLED("lib_win32con::_nc_console_keyok(%d, %d)"), keycode, flag));
 
     res = bsearch(&key,
-                  WINCONSOLE.rmap,
-                  (size_t) (N_INI + FKEYS),
-                  sizeof(keylist[0]),
-                  rkeycompare);
+		  WINCONSOLE.rmap,
+		  (size_t) (N_INI + FKEYS),
+		  sizeof(keylist[0]),
+		  rkeycompare);
     if (res) {
-        key = *((LONG *) res);
-        vKey = HIWORD(key);
-        nKey = (LOWORD(key)) & 0x7fff;
-        if (!flag)
-            nKey |= 0x8000;
-        *(LONG *) res = GenMap(vKey, nKey);
+	key = *((LONG *) res);
+	vKey = HIWORD(key);
+	nKey = (LOWORD(key)) & 0x7fff;
+	if (!flag)
+	    nKey |= 0x8000;
+	*(LONG *) res = GenMap(vKey, nKey);
     }
     returnCode(code);
 }
@@ -829,27 +813,27 @@ _nc_console_keyExist(int keycode)
 
     T((T_CALLED("lib_win32con::_nc_console_keyExist(%d)"), keycode));
     res = bsearch(&key,
-                  WINCONSOLE.rmap,
-                  (size_t) (N_INI + FKEYS),
-                  sizeof(keylist[0]),
-                  rkeycompare);
+		  WINCONSOLE.rmap,
+		  (size_t) (N_INI + FKEYS),
+		  sizeof(keylist[0]),
+		  rkeycompare);
     if (res) {
-        key = *((LONG *) res);
-        nKey = LOWORD(key);
-        if (!(nKey & 0x8000))
-            found = TRUE;
+	key = *((LONG *) res);
+	nKey = LOWORD(key);
+	if (!(nKey & 0x8000))
+	    found = TRUE;
     }
     returnCode(found);
 }
 
 NCURSES_EXPORT(int)
 _nc_console_twait(
-    SCREEN *sp,
-    HANDLE hdl,
-    int mode,
-    int milliseconds,
-    int *timeleft
-    EVENTLIST_2nd(_nc_eventlist * evl))
+		     SCREEN *sp,
+		     HANDLE hdl,
+		     int mode,
+		     int milliseconds,
+		     int *timeleft
+		     EVENTLIST_2nd(_nc_eventlist * evl))
 {
     INPUT_RECORD inp_rec;
     BOOL b;
@@ -861,7 +845,7 @@ _nc_console_twait(
     bool isNoDelay = (milliseconds == 0);
 
 #ifdef NCURSES_WGETCH_EVENTS
-    (void) evl;                 /* TODO: implement wgetch-events */
+    (void) evl;			/* TODO: implement wgetch-events */
 #endif
 
 #define IGNORE_CTRL_KEYS (SHIFT_PRESSED|LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED| \
@@ -871,174 +855,174 @@ _nc_console_twait(
     assert(sp);
 
     TR(TRACE_IEVENT, ("start twait: hdl=%p, %d milliseconds, mode: %d",
-                      hdl, milliseconds, mode));
+		      hdl, milliseconds, mode));
 
     if (milliseconds < 0)
-        milliseconds = INFINITY;
+	milliseconds = INFINITY;
 
     memset(&inp_rec, 0, sizeof(inp_rec));
 
     while (true) {
-        if (!isNoDelay) {
-            GetSystemTimeAsFileTime(&fstart);
-            rc = WaitForSingleObject(hdl, (DWORD) milliseconds);
-            GetSystemTimeAsFileTime(&fend);
-            diff = (int) tdiff(fstart, fend);
-            milliseconds = Adjust(milliseconds, diff);
-            if (milliseconds< 0)
-                break;
-        }
-
-        if (isNoDelay || (rc == WAIT_OBJECT_0)) {
-            if (mode) {
-                nRead = 0;
-                b = GetNumberOfConsoleInputEvents(hdl, &nRead);
-                if (!b) {
-                    T(("twait:err GetNumberOfConsoleInputEvents"));
-                }
-                if (isNoDelay && b) {
-                    T(("twait: Events Available: %ld", nRead));
-                    if (nRead==0) {
-                        code = 0;
-                        goto end;
-                    } else {
-                        DWORD n = 0;
-                        INPUT_RECORD* pInpRec =
-                            TypeAlloca(INPUT_RECORD, nRead);
-                        if (pInpRec != NULL) {
-                            DWORD i;
-                            BOOL f;
-                            memset(pInpRec, 0, sizeof(INPUT_RECORD)*nRead);
-                            f = PeekConsoleInput(hdl, pInpRec, nRead, &n);
-                            if (f) {
-                                for(i = 0; i < n; i++) {
-                                    if (pInpRec[i].EventType==KEY_EVENT) {
-                                        if(pInpRec[i].Event.KeyEvent.bKeyDown) {
-                                          DWORD ctrlMask =
-                                              (pInpRec[i].Event.KeyEvent.dwControlKeyState &
-                                               IGNORE_CTRL_KEYS);
-                                          if (!ctrlMask) {
-                                              code = TW_INPUT;
-                                              goto end;
-                                          }
-                                        }
-                                    }
-                                }
-                            } else {
-                                T(("twait:err PeekConsoleInput"));
-                            }
-                            code = 0;
-                            goto end;
-                        } else {
-                            T(("twait:err could not alloca input records"));
-                        }
-                    }
-                }
-                if (b && nRead > 0) {
-                    b = PeekConsoleInput(hdl, &inp_rec, 1, &nRead);
-                    if (!b) {
-                        T(("twait:err PeekConsoleInput"));
-                    }
-                    if (b && nRead > 0) {
-                        switch (inp_rec.EventType) {
-                        case KEY_EVENT:
-                            if (mode & TW_INPUT) {
-                                WORD vk =
-                                    inp_rec.Event.KeyEvent.wVirtualKeyCode;
-                                char ch =
-                                    inp_rec.Event.KeyEvent.uChar.AsciiChar;
-                                T(("twait:event KEY_EVENT"));
-                                T(("twait vk=%d, ch=%d, keydown=%d",
-                                   vk, ch, inp_rec.Event.KeyEvent.bKeyDown));
-                                if (inp_rec.Event.KeyEvent.bKeyDown) {
-                                    T(("twait:event KeyDown"));
-                                    if (!WINCONSOLE.isTermInfoConsole &&
-                                        (0 == ch)) {
-                                        int nKey = MapKey(vk);
-                                        if (nKey < 0) {
-                                            CONSUME();
-                                            continue;
-                                        }
-                                    }
-                                    code = TW_INPUT;
-                                    goto end;
-                                } else {
-                                    CONSUME();
-                                }
-                            }
-                            continue;
-                        case MOUSE_EVENT:
-                            T(("twait:event MOUSE_EVENT"));
-                            if (decode_mouse(sp,
-                                             (inp_rec.Event.MouseEvent.dwButtonState
-                                              & BUTTON_MASK)) == 0) {
-                                CONSUME();
-                            } else if (mode & TW_MOUSE) {
-                                code = TW_MOUSE;
-                                goto end;
-                            }
-                            continue;
-                            /* e.g., FOCUS_EVENT */
-                        default:
-                            T(("twait:event Tyoe %d", inp_rec.EventType));
-                            CONSUME();
-                            _nc_console_selectActiveHandle();
-                            continue;
-                        }
-                    }
-                }
-            }
-            continue;
-        } else {
-            if (rc != WAIT_TIMEOUT) {
-                code = -1;
-                break;
-            } else {
-                code = 0;
-                break;
-            }
-        }
+	if (!isNoDelay) {
+	    GetSystemTimeAsFileTime(&fstart);
+	    rc = WaitForSingleObject(hdl, (DWORD) milliseconds);
+	    GetSystemTimeAsFileTime(&fend);
+	    diff = (int) tdiff(fstart, fend);
+	    milliseconds = Adjust(milliseconds, diff);
+	    if (milliseconds < 0)
+		break;
+	}
+
+	if (isNoDelay || (rc == WAIT_OBJECT_0)) {
+	    if (mode) {
+		nRead = 0;
+		b = GetNumberOfConsoleInputEvents(hdl, &nRead);
+		if (!b) {
+		    T(("twait:err GetNumberOfConsoleInputEvents"));
+		}
+		if (isNoDelay && b) {
+		    T(("twait: Events Available: %ld", nRead));
+		    if (nRead == 0) {
+			code = 0;
+			goto end;
+		    } else {
+			DWORD n = 0;
+			INPUT_RECORD *pInpRec =
+			TypeAlloca(INPUT_RECORD, nRead);
+			if (pInpRec != NULL) {
+			    DWORD i;
+			    BOOL f;
+			    memset(pInpRec, 0, sizeof(INPUT_RECORD) * nRead);
+			    f = PeekConsoleInput(hdl, pInpRec, nRead, &n);
+			    if (f) {
+				for (i = 0; i < n; i++) {
+				    if (pInpRec[i].EventType == KEY_EVENT) {
+					if (pInpRec[i].Event.KeyEvent.bKeyDown) {
+					    DWORD ctrlMask =
+					    (pInpRec[i].Event.KeyEvent.dwControlKeyState &
+					     IGNORE_CTRL_KEYS);
+					    if (!ctrlMask) {
+						code = TW_INPUT;
+						goto end;
+					    }
+					}
+				    }
+				}
+			    } else {
+				T(("twait:err PeekConsoleInput"));
+			    }
+			    code = 0;
+			    goto end;
+			} else {
+			    T(("twait:err could not alloca input records"));
+			}
+		    }
+		}
+		if (b && nRead > 0) {
+		    b = PeekConsoleInput(hdl, &inp_rec, 1, &nRead);
+		    if (!b) {
+			T(("twait:err PeekConsoleInput"));
+		    }
+		    if (b && nRead > 0) {
+			switch (inp_rec.EventType) {
+			case KEY_EVENT:
+			    if (mode & TW_INPUT) {
+				WORD vk =
+				inp_rec.Event.KeyEvent.wVirtualKeyCode;
+				char ch =
+				inp_rec.Event.KeyEvent.uChar.AsciiChar;
+				T(("twait:event KEY_EVENT"));
+				T(("twait vk=%d, ch=%d, keydown=%d",
+				   vk, ch, inp_rec.Event.KeyEvent.bKeyDown));
+				if (inp_rec.Event.KeyEvent.bKeyDown) {
+				    T(("twait:event KeyDown"));
+				    if (!WINCONSOLE.isTermInfoConsole &&
+					(0 == ch)) {
+					int nKey = MapKey(vk);
+					if (nKey < 0) {
+					    CONSUME();
+					    continue;
+					}
+				    }
+				    code = TW_INPUT;
+				    goto end;
+				} else {
+				    CONSUME();
+				}
+			    }
+			    continue;
+			case MOUSE_EVENT:
+			    T(("twait:event MOUSE_EVENT"));
+			    if (decode_mouse(sp,
+					     (inp_rec.Event.MouseEvent.dwButtonState
+					      & BUTTON_MASK)) == 0) {
+				CONSUME();
+			    } else if (mode & TW_MOUSE) {
+				code = TW_MOUSE;
+				goto end;
+			    }
+			    continue;
+			    /* e.g., FOCUS_EVENT */
+			default:
+			    T(("twait:event Tyoe %d", inp_rec.EventType));
+			    CONSUME();
+			    _nc_console_selectActiveHandle();
+			    continue;
+			}
+		    }
+		}
+	    }
+	    continue;
+	} else {
+	    if (rc != WAIT_TIMEOUT) {
+		code = -1;
+		break;
+	    } else {
+		code = 0;
+		break;
+	    }
+	}
     }
-end:
+  end:
 
     TR(TRACE_IEVENT, ("end twait: returned %d (%lu), remaining time %d msec",
-                      code, GetLastError(), milliseconds));
+		      code, GetLastError(), milliseconds));
 
     if (timeleft)
-        *timeleft = milliseconds;
+	*timeleft = milliseconds;
 
     return code;
 }
 
 NCURSES_EXPORT(int)
 _nc_console_testmouse(
-                      SCREEN *sp,
-                      HANDLE hdl,
-                      int delay
-                      EVENTLIST_2nd(_nc_eventlist * evl))
+			 SCREEN *sp,
+			 HANDLE hdl,
+			 int delay
+			 EVENTLIST_2nd(_nc_eventlist * evl))
 {
     int rc = 0;
 
     assert(sp);
 
     if (sp->_drv_mouse_head < sp->_drv_mouse_tail) {
-        rc = TW_MOUSE;
+	rc = TW_MOUSE;
     } else {
-        rc = _nc_console_twait(sp,
-                               hdl,
-                               TWAIT_MASK,
-                               delay,
-                               (int *) 0
-                               EVENTLIST_2nd(evl));
+	rc = _nc_console_twait(sp,
+			       hdl,
+			       TWAIT_MASK,
+			       delay,
+			       (int *) 0
+			       EVENTLIST_2nd(evl));
     }
     return rc;
 }
 
 NCURSES_EXPORT(int)
 _nc_console_read(
-                 SCREEN *sp,
-                 HANDLE hdl,
-                 int *buf)
+		    SCREEN *sp,
+		    HANDLE hdl,
+		    int *buf)
 {
     int rc = -1;
     INPUT_RECORD inp_rec;
@@ -1054,47 +1038,47 @@ _nc_console_read(
     T((T_CALLED("lib_win32con::_nc_console_read(%p)"), sp));
 
     while ((b = ReadConsoleInput(hdl, &inp_rec, 1, &nRead))) {
-        if (b && nRead > 0) {
-            if (rc < 0)
-                rc = 0;
-            rc = rc + (int) nRead;
-            if (inp_rec.EventType == KEY_EVENT) {
-                if (!inp_rec.Event.KeyEvent.bKeyDown)
-                    continue;
-                *buf = (int) inp_rec.Event.KeyEvent.uChar.AsciiChar;
-                vk = inp_rec.Event.KeyEvent.wVirtualKeyCode;
-                /*
-                 * There are 24 virtual function-keys, and typically
-                 * 12 function-keys on a keyboard.  Use the shift-modifier
-                 * to provide the remaining 12 keys.
-                 */
-                if (vk >= VK_F1 && vk <= VK_F12) {
-                    if (inp_rec.Event.KeyEvent.dwControlKeyState &
-                        SHIFT_PRESSED) {
-                        vk = (WORD) (vk + 12);
-                    }
-                }
-                if (*buf == 0) {
-                    int key = MapKey(vk);
-                    if (key < 0)
-                        continue;
-                    if (sp->_keypad_on) {
-                        *buf = key;
-                    } else {
-                        ungetch('\0');
-                        *buf = AnsiKey(vk);
-                    }
-                }
-                break;
-            } else if (inp_rec.EventType == MOUSE_EVENT) {
-                if (handle_mouse(sp,
-                                 inp_rec.Event.MouseEvent)) {
-                    *buf = KEY_MOUSE;
-                    break;
-                }
-            }
-            continue;
-        }
+	if (b && nRead > 0) {
+	    if (rc < 0)
+		rc = 0;
+	    rc = rc + (int) nRead;
+	    if (inp_rec.EventType == KEY_EVENT) {
+		if (!inp_rec.Event.KeyEvent.bKeyDown)
+		    continue;
+		*buf = (int) inp_rec.Event.KeyEvent.uChar.AsciiChar;
+		vk = inp_rec.Event.KeyEvent.wVirtualKeyCode;
+		/*
+		 * There are 24 virtual function-keys, and typically
+		 * 12 function-keys on a keyboard.  Use the shift-modifier
+		 * to provide the remaining 12 keys.
+		 */
+		if (vk >= VK_F1 && vk <= VK_F12) {
+		    if (inp_rec.Event.KeyEvent.dwControlKeyState &
+			SHIFT_PRESSED) {
+			vk = (WORD) (vk + 12);
+		    }
+		}
+		if (*buf == 0) {
+		    int key = MapKey(vk);
+		    if (key < 0)
+			continue;
+		    if (sp->_keypad_on) {
+			*buf = key;
+		    } else {
+			ungetch('\0');
+			*buf = AnsiKey(vk);
+		    }
+		}
+		break;
+	    } else if (inp_rec.EventType == MOUSE_EVENT) {
+		if (handle_mouse(sp,
+				 inp_rec.Event.MouseEvent)) {
+		    *buf = KEY_MOUSE;
+		    break;
+		}
+	    }
+	    continue;
+	}
     }
     returnCode(rc);
 }
@@ -1115,16 +1099,17 @@ _nc_console_isatty(int fd)
     T((T_CALLED("lib_win32con::_nc_console_isatty(%d"), fd));
 
     if (_isatty(fd))
-        result = 1;
+	result = 1;
 #ifdef _NC_CHECK_MINTTY
     else {
-        if (_nc_console_checkmintty(fd, NULL)) {
-            result = 2;
-            fprintf(stderr, "ncurses on Windows must run in a Windows console.\n");
-            fprintf(stderr, "On newer versions of Windows, the calling program should create a PTY-like.\n");
-            fprintf(stderr, "device using the CreatePseudoConsole Windows API call.\n");
-            exit(EXIT_FAILURE);
-        }
+	if (_nc_console_checkmintty(fd, NULL)) {
+	    result = 2;
+	    fprintf(stderr,
+		    "ncurses on Windows must run in a Windows console.\n"
+		    "On newer versions of Windows, the calling program should create a PTY-like.\n"
+		    "device using the CreatePseudoConsole Windows API call.\n");
+	    exit(EXIT_FAILURE);
+	}
     }
 #endif
     returnCode(result);
@@ -1139,116 +1124,127 @@ _nc_console_checkinit(bool initFlag, bool assumeTermInfo)
        initFlag, assumeTermInfo));
 
     if (!initFlag) {
-        res = console_initialized;
+	res = console_initialized;
     } else {
-        /* initialize once, or not at all */
-        if (!console_initialized) {
-            int i;
-            DWORD num_buttons;
-            WORD a;
-            BOOL buffered = FALSE;
-            BOOL b;
-
-            START_TRACE();
-            WINCONSOLE.isTermInfoConsole = assumeTermInfo;
-
-            WINCONSOLE.map = (LPDWORD)malloc(sizeof(DWORD)*MAPSIZE);
-            WINCONSOLE.rmap = (LPDWORD)malloc(sizeof(DWORD)*MAPSIZE);
-            WINCONSOLE.ansi_map = (LPDWORD)malloc(sizeof(DWORD)*MAPSIZE);
-
-            for (i = 0; i < (N_INI + FKEYS); i++) {
-                if (i < N_INI) {
-                    WINCONSOLE.rmap[i] = WINCONSOLE.map[i] =
-                        (DWORD) keylist[i];
-                    WINCONSOLE.ansi_map[i] = (DWORD) ansi_keys[i];
-                } else {
-                    WINCONSOLE.rmap[i] = WINCONSOLE.map[i] =
-                        (DWORD) GenMap((VK_F1 + (i - N_INI)),
-                                       (KEY_F(1) + (i - N_INI)));
-                    WINCONSOLE.ansi_map[i] =
-                        (DWORD) GenMap((VK_F1 + (i - N_INI)),
-                                       (';' + (i - N_INI)));
-                }
-            }
-            qsort(WINCONSOLE.ansi_map,
-                  (size_t) (MAPSIZE),
-                  sizeof(keylist[0]),
-                  keycompare);
-            qsort(WINCONSOLE.map,
-                  (size_t) (MAPSIZE),
-                  sizeof(keylist[0]),
-                  keycompare);
-            qsort(WINCONSOLE.rmap,
-                  (size_t) (MAPSIZE),
-                  sizeof(keylist[0]),
-                  rkeycompare);
-
-            if (GetNumberOfConsoleMouseButtons(&num_buttons)) {
-                WINCONSOLE.numButtons = (int) num_buttons;
-            } else {
-                WINCONSOLE.numButtons = 1;
-            }
-
-            a = _nc_console_MapColor(true, COLOR_WHITE) |
-                _nc_console_MapColor(false, COLOR_BLACK);
-            for (i = 0; i < CON_NUMPAIRS; i++)
-                WINCONSOLE.pairs[i] = a;
-
-            WINCONSOLE.inp = GetStdHandle(STD_INPUT_HANDLE);
-            WINCONSOLE.out = GetStdHandle(STD_OUTPUT_HANDLE);
-            WINCONSOLE.hdl = WINCONSOLE.out;
-
-            GetConsoleMode(WINCONSOLE.inp, &WINCONSOLE.originalMode.dwFlagIn);
-            GetConsoleMode(WINCONSOLE.out, &WINCONSOLE.originalMode.dwFlagOut);
-
-            if (!WINCONSOLE.isTermInfoConsole) {
-                b = AllocConsole();
-
-                if (!b)
-                    b = AttachConsole(ATTACH_PARENT_PROCESS);
-
-                if (getenv("NCGDB") || getenv("NCURSES_CONSOLE2")) {
-                    T(("... will not buffer console"));
-                } else {
-                    T(("... creating console buffer"));
-                    WINCONSOLE.hdl =
-                        CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE,
-                                                  0,
-                                                  NULL,
-                                                  CONSOLE_TEXTMODE_BUFFER,
-                                                  NULL);
-                    buffered = TRUE;
-                }
-            }
-
-            /* We set binary I/O even when using the console
-               driver to cover the situation, that the
-               TERM variable is set to #win32con, but actually
-               Windows supports virtual terminal processing.
-               So if terminfo functions are used in this setup,
-               they actually may work.
-            */
-            _setmode(fileno(stdin), _O_BINARY);
-            _setmode(fileno(stdout), _O_BINARY);
-
-            if (WINCONSOLE.hdl != INVALID_HANDLE_VALUE) {
-                WINCONSOLE.buffered = buffered;
-                _nc_console_get_SBI();
-                WINCONSOLE.save_SBI = WINCONSOLE.SBI;
-                if (!buffered) {
-                    save_original_screen();
-                    _nc_console_set_scrollback(FALSE, &WINCONSOLE.SBI);
-                }
-                GetConsoleCursorInfo(WINCONSOLE.hdl, &WINCONSOLE.save_CI);
-                T(("... initial cursor is %svisible, %d%%",
-                   (WINCONSOLE.save_CI.bVisible ? "" : "not-"),
-                   (int) WINCONSOLE.save_CI.dwSize));
-            }
-
-            WINCONSOLE.initialized = TRUE;
-            console_initialized = TRUE;
-        }
-        res = (WINCONSOLE.hdl != INVALID_HANDLE_VALUE);
+	/* initialize once, or not at all */
+	if (!console_initialized) {
+	    int i;
+	    DWORD num_buttons;
+	    WORD a;
+	    BOOL buffered = FALSE;
+	    BOOL b;
+
+	    START_TRACE();
+	    WINCONSOLE.isTermInfoConsole = assumeTermInfo;
+
+	    WINCONSOLE.map = (LPDWORD) malloc(sizeof(DWORD) * MAPSIZE);
+	    WINCONSOLE.rmap = (LPDWORD) malloc(sizeof(DWORD) * MAPSIZE);
+	    WINCONSOLE.ansi_map = (LPDWORD) malloc(sizeof(DWORD) * MAPSIZE);
+
+	    for (i = 0; i < (N_INI + FKEYS); i++) {
+		if (i < N_INI) {
+		    WINCONSOLE.rmap[i] = WINCONSOLE.map[i] =
+			(DWORD) keylist[i];
+		    WINCONSOLE.ansi_map[i] = (DWORD) ansi_keys[i];
+		} else {
+		    WINCONSOLE.rmap[i] = WINCONSOLE.map[i] =
+			(DWORD) GenMap((VK_F1 + (i - N_INI)),
+				       (KEY_F(1) + (i - N_INI)));
+		    WINCONSOLE.ansi_map[i] =
+			(DWORD) GenMap((VK_F1 + (i - N_INI)),
+				       (';' + (i - N_INI)));
+		}
+	    }
+	    qsort(WINCONSOLE.ansi_map,
+		  (size_t) (MAPSIZE),
+		  sizeof(keylist[0]),
+		  keycompare);
+	    qsort(WINCONSOLE.map,
+		  (size_t) (MAPSIZE),
+		  sizeof(keylist[0]),
+		  keycompare);
+	    qsort(WINCONSOLE.rmap,
+		  (size_t) (MAPSIZE),
+		  sizeof(keylist[0]),
+		  rkeycompare);
+
+	    if (GetNumberOfConsoleMouseButtons(&num_buttons)) {
+		WINCONSOLE.numButtons = (int) num_buttons;
+	    } else {
+		WINCONSOLE.numButtons = 1;
+	    }
+
+	    a = _nc_console_MapColor(true, COLOR_WHITE) |
+		_nc_console_MapColor(false, COLOR_BLACK);
+	    for (i = 0; i < CON_NUMPAIRS; i++)
+		WINCONSOLE.pairs[i] = a;
+
+#define SaveConsoleMode(handle, value) \
+            GetConsoleMode(WINCONSOLE.handle, &WINCONSOLE.originalMode.value)
+
+	    if (WINCONSOLE.isTermInfoConsole) {
+		WINCONSOLE.inp = GetStdHandle(STD_INPUT_HANDLE);
+		WINCONSOLE.out = GetStdHandle(STD_OUTPUT_HANDLE);
+		WINCONSOLE.hdl = WINCONSOLE.out;
+
+		SaveConsoleMode(inp, dwFlagIn);
+		SaveConsoleMode(out, dwFlagOut);
+
+	    } else {
+		b = AllocConsole();
+
+		if (!b)
+		    b = AttachConsole(ATTACH_PARENT_PROCESS);
+
+		WINCONSOLE.inp = GetDirectHandle("CONIN$", FILE_SHARE_READ);
+		WINCONSOLE.out = GetDirectHandle("CONOUT$", FILE_SHARE_WRITE);
+
+		SaveConsoleMode(inp, dwFlagIn);
+		SaveConsoleMode(out, dwFlagOut);
+
+		if (getenv("NCGDB") || getenv("NCURSES_CONSOLE2")) {
+		    WINCONSOLE.hdl = WINCONSOLE.out;
+		    T(("... will not buffer console"));
+		} else {
+		    T(("... creating console buffer"));
+		    WINCONSOLE.hdl =
+			CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE,
+						  FILE_SHARE_READ | FILE_SHARE_WRITE,
+						  NULL,
+						  CONSOLE_TEXTMODE_BUFFER,
+						  NULL);
+		    buffered = TRUE;
+		}
+	    }
+
+	    /* We set binary I/O even when using the console
+	       driver to cover the situation, that the
+	       TERM variable is set to #win32con, but actually
+	       Windows supports virtual terminal processing.
+	       So if terminfo functions are used in this setup,
+	       they actually may work.
+	     */
+	    _setmode(fileno(stdin), _O_BINARY);
+	    _setmode(fileno(stdout), _O_BINARY);
+
+	    if (WINCONSOLE.hdl != INVALID_HANDLE_VALUE) {
+		WINCONSOLE.buffered = buffered;
+		_nc_console_get_SBI();
+		WINCONSOLE.save_SBI = WINCONSOLE.SBI;
+		if (!buffered) {
+		    save_original_screen();
+		    _nc_console_set_scrollback(FALSE, &WINCONSOLE.SBI);
+		}
+		GetConsoleCursorInfo(WINCONSOLE.hdl, &WINCONSOLE.save_CI);
+		T(("... initial cursor is %svisible, %d%%",
+		   (WINCONSOLE.save_CI.bVisible ? "" : "not-"),
+		   (int) WINCONSOLE.save_CI.dwSize));
+	    }
+
+	    WINCONSOLE.initialized = TRUE;
+	    console_initialized = TRUE;
+	}
+	res = (WINCONSOLE.hdl != INVALID_HANDLE_VALUE);
     }
     returnBool(res);
 }
diff --git a/contrib/ncurses/ncurses/tinfo/lib_win32util.c b/contrib/ncurses/ncurses/tinfo/lib_win32util.c
index d5bcd70199ed..c67c8ceb9862 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_win32util.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_win32util.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020-2021,2023 Thomas E. Dickey                                *
  * Copyright 1998-2009,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -34,7 +34,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_win32util.c,v 1.1 2020/08/14 21:57:01 juergen Exp $")
+MODULE_ID("$Id: lib_win32util.c,v 1.4 2023/06/17 17:19:06 tom Exp $")
 
 #ifdef _NC_WINDOWS
 #include <io.h>
@@ -48,13 +48,13 @@ MODULE_ID("$Id: lib_win32util.c,v 1.1 2020/08/14 21:57:01 juergen Exp $")
 
 /*   This function tests, whether or not the ncurses application
      is running as a descendant of MSYS2/cygwin mintty terminal
-     application. mintty doesn't use Windows Console for it's screen
+     application. mintty doesn't use Windows Console for its screen
      I/O, so the native Windows _isatty doesn't recognize it as
      character device. But we can discover we are at the end of an
      Pipe and can query the server side of the pipe, looking whether
      or not this is mintty.
      For now we terminate the program if we discover that situation.
-     Althogh in theory it would be possible, to remotely manipulate
+     Although in theory it would be possible, to remotely manipulate
      the terminal state of mintty, this is out of scope for now and
      not worth the significant effort.
  */
@@ -68,10 +68,10 @@ _nc_console_checkmintty(int fd, LPHANDLE pMinTTY)
     T((T_CALLED("lib_winhelper::_nc_console_checkmintty(%d, %p)"), fd, pMinTTY));
 
     if (handle != INVALID_HANDLE_VALUE) {
-        dw = GetFileType(handle);
+	dw = GetFileType(handle);
 	if (dw == FILE_TYPE_PIPE) {
 	    if (GetNamedPipeInfo(handle, 0, 0, 0, 0)) {
-	        ULONG pPid;
+		ULONG pPid;
 		/* Requires NT6 */
 		if (GetNamedPipeServerProcessId(handle, &pPid)) {
 		    TCHAR buf[MAX_PATH];
@@ -79,8 +79,7 @@ _nc_console_checkmintty(int fd, LPHANDLE pMinTTY)
 		    /* These security attributes may allow us to
 		       create a remote thread in mintty to manipulate
 		       the terminal state remotely */
-		    HANDLE pHandle = OpenProcess(
-						 PROCESS_CREATE_THREAD
+		    HANDLE pHandle = OpenProcess(PROCESS_CREATE_THREAD
 						 | PROCESS_QUERY_INFORMATION
 						 | PROCESS_VM_OPERATION
 						 | PROCESS_VM_WRITE
@@ -88,20 +87,19 @@ _nc_console_checkmintty(int fd, LPHANDLE pMinTTY)
 						 FALSE,
 						 pPid);
 		    if (pMinTTY)
-		        *pMinTTY = INVALID_HANDLE_VALUE;
+			*pMinTTY = INVALID_HANDLE_VALUE;
 		    if (pHandle != INVALID_HANDLE_VALUE) {
-		        if ((len = GetProcessImageFileName(
-							   pHandle,
+			if ((len = GetProcessImageFileName(pHandle,
 							   buf,
 							   (DWORD)
 							   array_length(buf)))) {
 			    TCHAR *pos = _tcsrchr(buf, _T('\\'));
 			    if (pos) {
-			        pos++;
+				pos++;
 				if (_tcsnicmp(pos, _TEXT("mintty.exe"), 10)
 				    == 0) {
 				    if (pMinTTY)
-				        *pMinTTY = pHandle;
+					*pMinTTY = pHandle;
 				    code = 1;
 				}
 			    }
@@ -114,7 +112,8 @@ _nc_console_checkmintty(int fd, LPHANDLE pMinTTY)
     returnCode(code);
 }
 #endif /* _NC_CHECK_MINTTY */
-
+
+#if HAVE_GETTIMEOFDAY == 2
 #define JAN1970 116444736000000000LL	/* the value for 01/01/1970 00:00 */
 
 NCURSES_EXPORT(int)
@@ -130,5 +129,6 @@ _nc_gettimeofday(struct timeval *tv, void *tz GCC_UNUSED)
     tv->tv_sec = (long) ((data.since1601 - JAN1970) / 10000000LL);
     return (0);
 }
+#endif // HAVE_GETTIMEOFDAY == 2
 
 #endif // _NC_WINDOWS
diff --git a/contrib/ncurses/ncurses/tinfo/make_hash.c b/contrib/ncurses/ncurses/tinfo/make_hash.c
index 9980279b2d21..78a684cc8bcb 100644
--- a/contrib/ncurses/ncurses/tinfo/make_hash.c
+++ b/contrib/ncurses/ncurses/tinfo/make_hash.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2020,2024 Thomas E. Dickey                                *
  * Copyright 2009-2013,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -44,7 +44,7 @@
 
 #include <ctype.h>
 
-MODULE_ID("$Id: make_hash.c,v 1.33 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: make_hash.c,v 1.34 2024/03/02 19:35:40 tom Exp $")
 
 /*
  *	_nc_make_hash_table()
@@ -250,7 +250,7 @@ main(int argc, char **argv)
     struct user_table_entry *name_table = typeCalloc(struct
 						     user_table_entry, tablesize);
     HashValue *hash_table = typeCalloc(HashValue, HASHTABSIZE);
-    const char *root_name = "";
+    const char *root_name;
     int column = 0;
     int bigstring = 0;
     unsigned n;
diff --git a/contrib/ncurses/ncurses/tinfo/make_keys.c b/contrib/ncurses/ncurses/tinfo/make_keys.c
index 80bbf63198a5..b8eb934357a3 100644
--- a/contrib/ncurses/ncurses/tinfo/make_keys.c
+++ b/contrib/ncurses/ncurses/tinfo/make_keys.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2011,2015 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -40,7 +40,7 @@
 #define USE_TERMLIB 1
 #include <build.priv.h>
 
-MODULE_ID("$Id: make_keys.c,v 1.22 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: make_keys.c,v 1.23 2021/08/18 20:55:25 tom Exp $")
 
 #include <names.c>
 
@@ -128,11 +128,13 @@ main(int argc, char *argv[])
 {
     static const char *prefix[] =
     {
-	"#ifndef NCU_KEYS_H",
-	"#define NCU_KEYS_H 1",
+	"#ifndef _INIT_KEYTRY_H",
+	"#define _INIT_KEYTRY_H 1",
 	"",
 	"/* This file was generated by MAKE_KEYS */",
 	"",
+	"#include <tic.h>",
+	"",
 	"#if BROKEN_LINKER",
 	"static",
 	"#endif",
@@ -143,7 +145,7 @@ main(int argc, char *argv[])
     {
 	"\t{ 0, 0} };",
 	"",
-	"#endif /* NCU_KEYS_H */",
+	"#endif /* _INIT_KEYTRY_H */",
 	0
     };
 
diff --git a/contrib/ncurses/ncurses/tinfo/obsolete.c b/contrib/ncurses/ncurses/tinfo/obsolete.c
index 972a9a180e78..cc62f18cb3f4 100644
--- a/contrib/ncurses/ncurses/tinfo/obsolete.c
+++ b/contrib/ncurses/ncurses/tinfo/obsolete.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
  * Copyright 2013-2014,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -37,7 +37,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: obsolete.c,v 1.6 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: obsolete.c,v 1.11 2023/10/21 15:38:47 tom Exp $")
 
 /*
  * Obsolete entrypoint retained for binary compatibility.
@@ -238,3 +238,98 @@ _nc_conv_to_utf32(unsigned *target, const char *source, unsigned limit)
 #undef CH
 }
 #endif /* EXP_XTERM_1005 */
+
+#ifdef EXP_OOM_TESTING
+/*
+ * Out-of-memory testing, suitable for checking if initialization (and limited
+ * running) recovers from errors due to insufficient memory.  In practice, this
+ * is unlikely except with artificially constructed tests (or poorly behaved
+ * applications).
+ */
+#undef malloc
+#undef calloc
+#undef realloc
+#undef free
+#undef strdup
+
+#define TR_OOM(stmt) T(stmt)
+
+static long oom_limit = -1;
+static long oom_count = 0;
+
+static bool
+oom_check(void)
+{
+    static bool initialized = FALSE;
+    static bool triggered = FALSE;
+    bool result = FALSE;
+
+    if (!initialized) {
+	char *env = getenv("NCURSES_OOM_TESTING");
+	initialized = TRUE;
+	if (env != NULL) {
+	    char *check;
+	    oom_limit = strtol(env, &check, 0);
+	    if (check != NULL && *check != '\0')
+		oom_limit = 0;
+	}
+    }
+    ++oom_count;
+    if (oom_limit >= 0) {
+	result = (oom_count > oom_limit);
+	if (result && !triggered) {
+	    triggered = TRUE;
+	    TR_OOM(("out-of-memory"));
+	}
+    }
+    return result;
+}
+
+NCURSES_EXPORT(void *)
+_nc_oom_malloc(size_t size)
+{
+    char *result = (oom_check()
+		    ? NULL
+		    : malloc(size));
+    TR_OOM(("oom #%ld malloc(%ld) %p", oom_count, size, result));
+    return result;
+}
+
+NCURSES_EXPORT(void *)
+_nc_oom_calloc(size_t nmemb, size_t size)
+{
+    char *result = (oom_check()
+		    ? NULL
+		    : calloc(nmemb, size));
+    TR_OOM(("oom #%ld calloc(%ld, %ld) %p", oom_count, nmemb, size, result));
+    return result;
+}
+
+NCURSES_EXPORT(void *)
+_nc_oom_realloc(void *ptr, size_t size)
+{
+    char *result = (oom_check()
+		    ? NULL
+		    : realloc(ptr, size));
+    TR_OOM(("oom #%ld realloc(%p, %ld) %p", oom_count, ptr, size, result));
+    return result;
+}
+
+NCURSES_EXPORT(void)
+_nc_oom_free(void *ptr)
+{
+    ++oom_count;
+    TR_OOM(("oom #%ld free(%p)", oom_count, ptr));
+    free(ptr);
+}
+
+NCURSES_EXPORT(char *)
+_nc_oom_strdup(const char *ptr)
+{
+    char *result = (oom_check()
+		    ? NULL
+		    : strdup(ptr));
+    TR_OOM(("oom #%ld strdup(%p) %p", oom_count, ptr, result));
+    return result;
+}
+#endif /* EXP_OOM_TESTING */
diff --git a/contrib/ncurses/ncurses/tinfo/parse_entry.c b/contrib/ncurses/ncurses/tinfo/parse_entry.c
index ec2d3364234e..13fef495aec9 100644
--- a/contrib/ncurses/ncurses/tinfo/parse_entry.c
+++ b/contrib/ncurses/ncurses/tinfo/parse_entry.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -48,7 +48,7 @@
 #include <ctype.h>
 #include <tic.h>
 
-MODULE_ID("$Id: parse_entry.c,v 1.101 2020/10/24 21:37:13 tom Exp $")
+MODULE_ID("$Id: parse_entry.c,v 1.108 2023/04/24 22:32:33 tom Exp $")
 
 #ifdef LINT
 static short const parametrized[] =
@@ -110,7 +110,7 @@ _nc_extend_names(ENTRY * entryp, const char *name, int token_type)
 	/* Well, we are given a cancel for a name that we don't recognize */
 	return _nc_extend_names(entryp, name, STRING);
     default:
-	return 0;
+	return NULL;
     }
 
     /* Adjust the 'offset' (insertion-point) to keep the lists of extended
@@ -142,6 +142,11 @@ _nc_extend_names(ENTRY * entryp, const char *name, int token_type)
 	for (last = (unsigned) (max - 1); last > tindex; last--)
 
     if (!found) {
+	char *saved;
+
+	if ((saved = _nc_save_str(name)) == NULL)
+	    return NULL;
+
 	switch (token_type) {
 	case BOOLEAN:
 	    tp->ext_Booleans++;
@@ -169,7 +174,7 @@ _nc_extend_names(ENTRY * entryp, const char *name, int token_type)
 	TYPE_REALLOC(char *, actual, tp->ext_Names);
 	while (--actual > offset)
 	    tp->ext_Names[actual] = tp->ext_Names[actual - 1];
-	tp->ext_Names[offset] = _nc_save_str(name);
+	tp->ext_Names[offset] = saved;
     }
 
     temp.nte_name = tp->ext_Names[offset];
@@ -214,16 +219,39 @@ expected_type(const char *name, int token_type, bool silent)
 }
 #endif /* NCURSES_XNAMES */
 
+/*
+ * A valid entry name uses characters from the "portable character set"
+ * (more commonly referred to as US-ASCII), and disallows some of the
+ * punctuation characters:
+ *
+ * '/' is a pathname separator
+ * '\' may be a pathname separator, but more important, is an escape
+ * '|' delimits names and description
+ * '#' denotes a numeric value
+ * '=' denotes a string value
+ * '@' denotes a cancelled symbol
+ * ',' separates terminfo capabilities
+ * ':' separates termcap capabilities
+ *
+ * Termcap capability names may begin with a '#' or '@' (since they have
+ * exactly two characters).
+ */
 static bool
 valid_entryname(const char *name)
 {
     bool result = TRUE;
+    bool first = TRUE;
     int ch;
     while ((ch = UChar(*name++)) != '\0') {
-	if (ch <= ' ' || ch > '~' || ch == '/') {
+	if (ch <= ' ' || ch > '~' || strchr("/\\|=,:", ch) != NULL) {
+	    result = FALSE;
+	    break;
+	}
+	if (!first && strchr("#@", ch) != NULL) {
 	    result = FALSE;
 	    break;
 	}
+	first = FALSE;
     }
     return result;
 }
@@ -262,10 +290,14 @@ _nc_parse_entry(ENTRY * entryp, int literal, bool silent)
     const char *name;
     bool bad_tc_usage = FALSE;
 
+    TR(TRACE_DATABASE,
+       (T_CALLED("_nc_parse_entry(entry=%p, literal=%d, silent=%d)"),
+	(void *) entryp, literal, silent));
+
     token_type = _nc_get_token(silent);
 
     if (token_type == EOF)
-	return (EOF);
+	returnDB(EOF);
     if (token_type != NAMES)
 	_nc_err_abort("Entry does not start with terminal names in column one");
 
@@ -301,9 +333,9 @@ _nc_parse_entry(ENTRY * entryp, int literal, bool silent)
     entryp->tterm.str_table = entryp->tterm.term_names = _nc_save_str(ptr);
 
     if (entryp->tterm.str_table == 0)
-	return (ERR);
+	returnDB(ERR);
 
-    DEBUG(1, ("Starting '%s'", ptr));
+    DEBUG(2, ("Starting '%s'", ptr));
 
     /*
      * We do this because the one-token lookahead in the parse loop
@@ -337,6 +369,8 @@ _nc_parse_entry(ENTRY * entryp, int literal, bool silent)
 	bool is_use = (strcmp(_nc_curr_token.tk_name, "use") == 0);
 	bool is_tc = !is_use && (strcmp(_nc_curr_token.tk_name, "tc") == 0);
 	if (is_use || is_tc) {
+	    char *saved;
+
 	    if (!VALID_STRING(_nc_curr_token.tk_valstring)
 		|| _nc_curr_token.tk_valstring[0] == '\0') {
 		_nc_warning("missing name for use-clause");
@@ -350,11 +384,13 @@ _nc_parse_entry(ENTRY * entryp, int literal, bool silent)
 			    _nc_curr_token.tk_valstring);
 		continue;
 	    }
-	    entryp->uses[entryp->nuses].name = _nc_save_str(_nc_curr_token.tk_valstring);
-	    entryp->uses[entryp->nuses].line = _nc_curr_line;
-	    entryp->nuses++;
-	    if (entryp->nuses > 1 && is_tc) {
-		BAD_TC_USAGE
+	    if ((saved = _nc_save_str(_nc_curr_token.tk_valstring)) != NULL) {
+		entryp->uses[entryp->nuses].name = saved;
+		entryp->uses[entryp->nuses].line = _nc_curr_line;
+		entryp->nuses++;
+		if (entryp->nuses > 1 && is_tc) {
+		    BAD_TC_USAGE
+		}
 	    }
 	} else {
 	    /* normal token lookup */
@@ -362,7 +398,7 @@ _nc_parse_entry(ENTRY * entryp, int literal, bool silent)
 				       _nc_get_hash_table(_nc_syntax));
 
 	    /*
-	     * Our kluge to handle aliasing.  The reason it's done
+	     * Our kluge to handle aliasing.  The reason it is done
 	     * this ugly way, with a linear search, is so the hashing
 	     * machinery doesn't have to be made really complicated
 	     * (also we get better warnings this way).  No point in
@@ -605,7 +641,7 @@ _nc_parse_entry(ENTRY * entryp, int literal, bool silent)
     }
     _nc_wrap_entry(entryp, FALSE);
 
-    return (OK);
+    returnDB(OK);
 }
 
 NCURSES_EXPORT(int)
@@ -737,6 +773,10 @@ postprocess_termcap(TERMTYPE2 *tp, bool has_base)
     char buf[MAX_LINE * 2 + 2];
     string_desc result;
 
+    TR(TRACE_DATABASE,
+       (T_CALLED("postprocess_termcap(tp=%p, has_base=%d)"),
+	(void *) tp, has_base));
+
     /*
      * TERMCAP DEFAULTS AND OBSOLETE-CAPABILITY TRANSLATIONS
      *
@@ -929,7 +969,7 @@ postprocess_termcap(TERMTYPE2 *tp, bool has_base)
 	    if (tp->Strings[to_ptr->nte_index]) {
 		const char *s = tp->Strings[from_ptr->nte_index];
 		const char *t = tp->Strings[to_ptr->nte_index];
-		/* There's no point in warning about it if it's the same
+		/* There's no point in warning about it if it is the same
 		 * string; that's just an inefficiency.
 		 */
 		if (VALID_STRING(s) && VALID_STRING(t) && strcmp(s, t) != 0)
@@ -1023,11 +1063,16 @@ postprocess_termcap(TERMTYPE2 *tp, bool has_base)
 	       && PRESENT(exit_alt_charset_mode)) {
 	acs_chars = _nc_save_str(VT_ACSC);
     }
+    returnVoidDB;
 }
 
 static void
 postprocess_terminfo(TERMTYPE2 *tp)
 {
+    TR(TRACE_DATABASE,
+       (T_CALLED("postprocess_terminfo(tp=%p)"),
+	(void *) tp));
+
     /*
      * TERMINFO-TO-TERMINFO MAPPINGS FOR SOURCE TRANSLATION
      * ----------------------------------------------------------------------
@@ -1064,6 +1109,7 @@ postprocess_terminfo(TERMTYPE2 *tp)
     /*
      * ----------------------------------------------------------------------
      */
+    returnVoidDB;
 }
 
 /*
diff --git a/contrib/ncurses/ncurses/tinfo/read_entry.c b/contrib/ncurses/ncurses/tinfo/read_entry.c
index 9741e103b7a9..b0f360eca800 100644
--- a/contrib/ncurses/ncurses/tinfo/read_entry.c
+++ b/contrib/ncurses/ncurses/tinfo/read_entry.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2020,2021 Thomas E. Dickey                                *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -42,9 +42,7 @@
 
 #include <tic.h>
 
-MODULE_ID("$Id: read_entry.c,v 1.159 2021/02/14 00:17:09 tom Exp $")
-
-#define TYPE_CALLOC(type,elts) typeCalloc(type, (unsigned)(elts))
+MODULE_ID("$Id: read_entry.c,v 1.171 2023/09/16 16:30:34 tom Exp $")
 
 #define MyNumber(n) (short) LOW_MSB(n)
 
@@ -140,11 +138,13 @@ convert_16bits(char *buf, NCURSES_INT2 *Numbers, int count)
 }
 #endif
 
-static void
-convert_strings(char *buf, char **Strings, int count, int size, char *table)
+static bool
+convert_strings(char *buf, char **Strings, int count, int size,
+		char *table, bool always)
 {
     int i;
     char *p;
+    bool success = TRUE;
 
     for (i = 0; i < count; i++) {
 	if (IS_NEG1(buf + 2 * i)) {
@@ -154,8 +154,17 @@ convert_strings(char *buf, char **Strings, int count, int size, char *table)
 	} else if (MyNumber(buf + 2 * i) > size) {
 	    Strings[i] = ABSENT_STRING;
 	} else {
-	    Strings[i] = (MyNumber(buf + 2 * i) + table);
-	    TR(TRACE_DATABASE, ("Strings[%d] = %s", i, _nc_visbuf(Strings[i])));
+	    int nn = MyNumber(buf + 2 * i);
+	    if (nn >= 0 && nn < size) {
+		Strings[i] = (nn + table);
+		TR(TRACE_DATABASE, ("Strings[%d] = %s", i,
+				    _nc_visbuf(Strings[i])));
+	    } else {
+		TR(TRACE_DATABASE,
+		   ("found out-of-range index %d to Strings[%d]", nn, i));
+		success = FALSE;
+		break;
+	    }
 	}
 
 	/* make sure all strings are NUL terminated */
@@ -164,10 +173,25 @@ convert_strings(char *buf, char **Strings, int count, int size, char *table)
 		if (*p == '\0')
 		    break;
 	    /* if there is no NUL, ignore the string */
-	    if (p >= table + size)
+	    if (p >= table + size) {
 		Strings[i] = ABSENT_STRING;
+	    } else if (p == Strings[i] && always) {
+		TR(TRACE_DATABASE,
+		   ("found empty but required Strings[%d]", i));
+		success = FALSE;
+		break;
+	    }
+	} else if (always) {	/* names are always needed */
+	    TR(TRACE_DATABASE,
+	       ("found invalid but required Strings[%d]", i));
+	    success = FALSE;
+	    break;
 	}
     }
+    if (!success) {
+	_nc_warning("corrupt data found in convert_strings");
+    }
+    return success;
 }
 
 static int
@@ -203,6 +227,8 @@ _nc_init_termtype(TERMTYPE2 *const tp)
 {
     unsigned i;
 
+    DEBUG(2, (T_CALLED("_nc_init_termtype(tp=%p)"), (void *) tp));
+
 #if NCURSES_XNAMES
     tp->num_Booleans = BOOLCOUNT;
     tp->num_Numbers = NUMCOUNT;
@@ -226,6 +252,8 @@ _nc_init_termtype(TERMTYPE2 *const tp)
 
     for_each_string(i, tp)
 	tp->Strings[i] = ABSENT_STRING;
+
+    DEBUG(2, (T_RETURN("")));
 }
 
 #if NCURSES_USE_DATABASE
@@ -308,6 +336,9 @@ _nc_read_termtype(TERMTYPE2 *ptr, char *buffer, int limit)
 	|| bool_count < 0
 	|| num_count < 0
 	|| str_count < 0
+	|| bool_count > BOOLCOUNT
+	|| num_count > NUMCOUNT
+	|| str_count > STRCOUNT
 	|| str_size < 0) {
 	returnDB(TGETENT_NO);
     }
@@ -320,7 +351,7 @@ _nc_read_termtype(TERMTYPE2 *ptr, char *buffer, int limit)
     }
 
     /* grab the name (a null-terminated string) */
-    want = min(MAX_NAME_SIZE, (unsigned) name_size);
+    want = Min(MAX_NAME_SIZE, (unsigned) name_size);
     ptr->str_table = string_table;
     ptr->term_names = string_table;
     if ((have = (unsigned) Read(ptr->term_names, want)) != want) {
@@ -333,9 +364,8 @@ _nc_read_termtype(TERMTYPE2 *ptr, char *buffer, int limit)
 	offset = (int) (have - MAX_NAME_SIZE);
 
     /* grab the booleans */
-    if ((ptr->Booleans = TYPE_CALLOC(NCURSES_SBOOL,
-				     max(BOOLCOUNT, bool_count))) == 0
-	|| Read(ptr->Booleans, (unsigned) bool_count) < bool_count) {
+    TYPE_CALLOC(NCURSES_SBOOL, Max(BOOLCOUNT, bool_count), ptr->Booleans);
+    if (Read(ptr->Booleans, (unsigned) bool_count) < bool_count) {
 	returnDB(TGETENT_NO);
     }
 
@@ -348,15 +378,13 @@ _nc_read_termtype(TERMTYPE2 *ptr, char *buffer, int limit)
     even_boundary(name_size + bool_count);
 
     /* grab the numbers */
-    if (!(ptr->Numbers = TYPE_CALLOC(NCURSES_INT2, max(NUMCOUNT, num_count)))
-	|| !read_numbers(buf, num_count)) {
+    TYPE_CALLOC(NCURSES_INT2, Max(NUMCOUNT, num_count), ptr->Numbers);
+    if (!read_numbers(buf, num_count)) {
 	returnDB(TGETENT_NO);
     }
     convert_numbers(buf, ptr->Numbers, num_count);
 
-    if ((ptr->Strings = TYPE_CALLOC(char *, max(STRCOUNT, str_count))) == 0) {
-	returnDB(TGETENT_NO);
-    }
+    TYPE_CALLOC(char *, Max(STRCOUNT, str_count), ptr->Strings);
 
     if (str_count) {
 	/* grab the string offsets */
@@ -367,7 +395,10 @@ _nc_read_termtype(TERMTYPE2 *ptr, char *buffer, int limit)
 	if (Read(string_table, (unsigned) str_size) != str_size) {
 	    returnDB(TGETENT_NO);
 	}
-	convert_strings(buf, ptr->Strings, str_count, str_size, string_table);
+	if (!convert_strings(buf, ptr->Strings, str_count, str_size,
+			     string_table, FALSE)) {
+	    returnDB(TGETENT_NO);
+	}
     }
 #if NCURSES_XNAMES
 
@@ -468,8 +499,10 @@ _nc_read_termtype(TERMTYPE2 *ptr, char *buffer, int limit)
 	       ("Before computing extended-string capabilities "
 		"str_count=%d, ext_str_count=%d",
 		str_count, ext_str_count));
-	    convert_strings(buf, ptr->Strings + str_count, ext_str_count,
-			    ext_str_limit, ptr->ext_str_table);
+	    if (!convert_strings(buf, ptr->Strings + str_count, ext_str_count,
+				 ext_str_limit, ptr->ext_str_table, FALSE)) {
+		returnDB(TGETENT_NO);
+	    }
 	    for (i = ext_str_count - 1; i >= 0; i--) {
 		TR(TRACE_DATABASE, ("MOVE from [%d:%d] %s",
 				    i, i + str_count,
@@ -497,16 +530,17 @@ _nc_read_termtype(TERMTYPE2 *ptr, char *buffer, int limit)
 	    if (ext_str_count >= (max_entry_size / 2)) {
 		returnDB(TGETENT_NO);
 	    }
-	    if ((ptr->ext_Names = TYPE_CALLOC(char *, need)) == 0) {
-		returnDB(TGETENT_NO);
-	    }
+	    TYPE_CALLOC(char *, need, ptr->ext_Names);
 	    TR(TRACE_DATABASE,
 	       ("ext_NAMES starting @%d in extended_strings, first = %s",
 		base, _nc_visbuf(ptr->ext_str_table + base)));
-	    convert_strings(buf + (2 * ext_str_count),
-			    ptr->ext_Names,
-			    (int) need,
-			    ext_str_limit, ptr->ext_str_table + base);
+	    if (!convert_strings(buf + (2 * ext_str_count),
+				 ptr->ext_Names,
+				 (int) need,
+				 ext_str_limit, ptr->ext_str_table + base,
+				 TRUE)) {
+		returnDB(TGETENT_NO);
+	    }
 	}
 
 	TR(TRACE_DATABASE,
@@ -552,20 +586,24 @@ _nc_read_file_entry(const char *const filename, TERMTYPE2 *ptr)
     int code;
 
     if (_nc_access(filename, R_OK) < 0
-	|| (fp = fopen(filename, BIN_R)) == 0) {
+	|| (fp = safe_fopen(filename, BIN_R)) == 0) {
 	TR(TRACE_DATABASE, ("cannot open terminfo %s (errno=%d)", filename, errno));
 	code = TGETENT_NO;
     } else {
 	int limit;
 	char buffer[MAX_ENTRY_SIZE + 1];
 
-	if ((limit = (int) fread(buffer, sizeof(char), sizeof(buffer), fp))
-	    > 0) {
+	limit = (int) fread(buffer, sizeof(char), sizeof(buffer), fp);
+	if (limit > 0) {
+	    const char *old_source = _nc_get_source();
 
 	    TR(TRACE_DATABASE, ("read terminfo %s", filename));
+	    if (old_source == NULL)
+		_nc_set_source(filename);
 	    if ((code = _nc_read_termtype(ptr, buffer, limit)) == TGETENT_NO) {
 		_nc_free_termtype2(ptr);
 	    }
+	    _nc_set_source(old_source);
 	} else {
 	    code = TGETENT_NO;
 	}
@@ -765,6 +803,9 @@ _nc_read_tic_entry(char *filename,
 	int reccnt = 0;
 	char *save = strdup(name);
 
+	if (save == 0)
+	    returnDB(code);
+
 	memset(&key, 0, sizeof(key));
 	key.data = save;
 	key.size = strlen(save);
@@ -774,7 +815,7 @@ _nc_read_tic_entry(char *filename,
 	 * looking for compiled (binary) terminfo data.
 	 *
 	 * cgetent uses a two-level lookup.  On the first it uses the given
-	 * name to return a record containing only the aliases for an entry. 
+	 * name to return a record containing only the aliases for an entry.
 	 * On the second (using that list of aliases as a key), it returns the
 	 * content of the terminal description.  We expect second lookup to
 	 * return data beginning with the same set of aliases.
@@ -831,7 +872,7 @@ _nc_read_tic_entry(char *filename,
 #endif /* NCURSES_USE_DATABASE */
 
 /*
- * Find and read the compiled entry for a given terminal type, if it exists. 
+ * Find and read the compiled entry for a given terminal type, if it exists.
  * We take pains here to make sure no combination of environment variables and
  * terminal type name can be used to overrun the file buffer.
  */
@@ -879,9 +920,6 @@ _nc_read_entry2(const char *const name, char *const filename, TERMTYPE2 *const t
 }
 
 #if NCURSES_EXT_NUMBERS
-/*
- * This entrypoint is used by tack 1.07
- */
 NCURSES_EXPORT(int)
 _nc_read_entry(const char *const name, char *const filename, TERMTYPE *const tp)
 {
diff --git a/contrib/ncurses/ncurses/tinfo/read_termcap.c b/contrib/ncurses/ncurses/tinfo/read_termcap.c
index fcb43a442b7a..1a294848b827 100644
--- a/contrib/ncurses/ncurses/tinfo/read_termcap.c
+++ b/contrib/ncurses/ncurses/tinfo/read_termcap.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2021,2023 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -57,7 +57,7 @@
 #include <sys/types.h>
 #include <tic.h>
 
-MODULE_ID("$Id: read_termcap.c,v 1.98 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: read_termcap.c,v 1.104 2023/06/24 21:53:16 tom Exp $")
 
 #if !PURE_TERMINFO
 
@@ -187,7 +187,7 @@ _nc_cgetcap(char *buf, const char *cap, int type)
     bp = buf;
     for (;;) {
 	/*
-	 * Skip past the current capability field - it's either the
+	 * Skip past the current capability field - it is either the
 	 * name field if this is the first time through the loop, or
 	 * the remainder of a field whose name failed to match cap.
 	 */
@@ -324,7 +324,7 @@ _nc_getent(
 	    if (fd >= 0) {
 		(void) lseek(fd, (off_t) 0, SEEK_SET);
 	    } else if ((_nc_access(db_array[current], R_OK) < 0)
-		       || (fd = open(db_array[current], O_RDONLY, 0)) < 0) {
+		       || (fd = safe_open2(db_array[current], O_RDONLY)) < 0) {
 		/* No error on unfound file. */
 		if (errno == ENOENT)
 		    continue;
@@ -803,7 +803,7 @@ _nc_tgetent(char *bp, char **sourcename, int *lineno, const char *name)
     /*
      * TERMCAP can have one of two things in it.  It can be the name of a file
      * to use instead of /etc/termcap.  In this case it better start with a
-     * "/".  Or it can be an entry to use so we don't have to read the file. 
+     * "/".  Or it can be an entry to use so we don't have to read the file.
      * In this case it has to already have the newlines crunched out.  If
      * TERMCAP does not hold a file name then a path of names is searched
      * instead.  The path is found in the TERMPATH variable, or becomes
@@ -1055,23 +1055,25 @@ _nc_read_termcap_entry(const char *const tn, TERMTYPE2 *const tp)
     if (normal) {		/* normal case */
 	char envhome[PATH_MAX], *h;
 
-	copied = strdup(get_termpath());
-	for (cp = copied; *cp; cp++) {
-	    if (*cp == NCURSES_PATHSEP)
-		*cp = '\0';
-	    else if (cp == copied || cp[-1] == '\0') {
-		ADD_TC(cp, filecount);
+	if ((copied = strdup(get_termpath())) != 0) {
+	    for (cp = copied; *cp; cp++) {
+		if (*cp == NCURSES_PATHSEP)
+		    *cp = '\0';
+		else if (cp == copied || cp[-1] == '\0') {
+		    ADD_TC(cp, filecount);
+		}
 	    }
 	}
-
-#define PRIVATE_CAP "%s/.termcap"
+#define PRIVATE_CAP "%.*s/.termcap"
 
 	if (use_terminfo_vars() && (h = getenv("HOME")) != NULL && *h != '\0'
 	    && (strlen(h) + sizeof(PRIVATE_CAP)) < PATH_MAX) {
 	    /* user's .termcap, if any, should override it */
 	    _nc_STRCPY(envhome, h, sizeof(envhome));
 	    _nc_SPRINTF(pathbuf, _nc_SLIMIT(sizeof(pathbuf))
-			PRIVATE_CAP, envhome);
+			PRIVATE_CAP,
+			(int) (sizeof(pathbuf) - sizeof(PRIVATE_CAP)),
+			envhome);
 	    ADD_TC(pathbuf, filecount);
 	}
     }
@@ -1113,7 +1115,7 @@ _nc_read_termcap_entry(const char *const tn, TERMTYPE2 *const tp)
 
 	/*
 	 * We don't suppress warning messages here.  The presumption is
-	 * that since it's just a single entry, they won't be a pain.
+	 * that since it is just a single entry, they won't be a pain.
 	 */
 	_nc_read_entry_source((FILE *) 0, tc_buf, FALSE, FALSE, NULLHOOK);
 	free(tc_buf);
@@ -1124,7 +1126,7 @@ _nc_read_termcap_entry(const char *const tn, TERMTYPE2 *const tp)
 
 	    TR(TRACE_DATABASE, ("Looking for %s in %s", tn, termpaths[i]));
 	    if (_nc_access(termpaths[i], R_OK) == 0
-		&& (fp = fopen(termpaths[i], "r")) != (FILE *) 0) {
+		&& (fp = safe_fopen(termpaths[i], "r")) != (FILE *) 0) {
 		_nc_set_source(termpaths[i]);
 
 		/*
@@ -1164,7 +1166,7 @@ _nc_read_termcap_entry(const char *const tn, TERMTYPE2 *const tp)
 		_nc_free_entry(_nc_head, &(ep->tterm));
 
 		/*
-		 * OK, now try to write the type to user's terminfo directory. 
+		 * OK, now try to write the type to user's terminfo directory.
 		 * Next time he loads this, it will come through terminfo.
 		 *
 		 * Advantage:  Second and subsequent fetches of this entry will
diff --git a/contrib/ncurses/ncurses/tinfo/strings.c b/contrib/ncurses/ncurses/tinfo/strings.c
index a1d8beb63f31..03f59c24e9ad 100644
--- a/contrib/ncurses/ncurses/tinfo/strings.c
+++ b/contrib/ncurses/ncurses/tinfo/strings.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
  * Copyright 2000-2012,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -38,7 +38,7 @@
 #include <curses.priv.h>
 #include <tic.h>
 
-MODULE_ID("$Id: strings.c,v 1.10 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: strings.c,v 1.11 2023/05/27 20:13:10 tom Exp $")
 
 /****************************************************************************
  * Useful string functions (especially for mvcur)
@@ -95,7 +95,7 @@ _nc_str_null(string_desc * dst, size_t len)
  * Copy a descriptor
  */
 NCURSES_EXPORT(string_desc *)
-_nc_str_copy(string_desc * dst, string_desc * src)
+_nc_str_copy(string_desc * dst, const string_desc * const src)
 {
     *dst = *src;
     return dst;
diff --git a/contrib/ncurses/ncurses/tinfo/tinfo_driver.c b/contrib/ncurses/ncurses/tinfo/tinfo_driver.c
index c28d76415549..fd993b820381 100644
--- a/contrib/ncurses/ncurses/tinfo/tinfo_driver.c
+++ b/contrib/ncurses/ncurses/tinfo/tinfo_driver.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
  * Copyright 2008-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -52,7 +52,7 @@
 # endif
 #endif
 
-MODULE_ID("$Id: tinfo_driver.c,v 1.71 2020/12/12 01:06:40 tom Exp $")
+MODULE_ID("$Id: tinfo_driver.c,v 1.74 2023/09/16 10:44:33 tom Exp $")
 
 /*
  * SCO defines TIOCGSIZE and the corresponding struct.  Other systems (SunOS,
@@ -206,8 +206,8 @@ drv_CanHandle(TERMINAL_CONTROL_BLOCK * TCB, const char *tname, int *errret)
     save_ttytype(termp);
 #endif
 
-    if (command_character)
-	_nc_tinfo_cmdch(termp, *command_character);
+    if (VALID_STRING(command_character))
+	_nc_tinfo_cmdch(termp, UChar(*command_character));
 
     /*
      * If an application calls setupterm() rather than initscr() or
@@ -1282,10 +1282,7 @@ drv_read(TERMINAL_CONTROL_BLOCK * TCB, int *buf)
     assert(buf);
     SetSP();
 
-# if USE_PTHREADS_EINTR
-    if ((pthread_self) && (pthread_kill) && (pthread_equal))
-	_nc_globals.read_thread = pthread_self();
-# endif
+    _nc_set_read_thread(TRUE);
 #ifdef EXP_WIN32_DRIVER
     n = _nc_console_read(sp,
 			 _nc_console_handle(sp->_ifd),
@@ -1293,9 +1290,7 @@ drv_read(TERMINAL_CONTROL_BLOCK * TCB, int *buf)
 #else
     n = (int) read(sp->_ifd, &c2, (size_t) 1);
 #endif
-#if USE_PTHREADS_EINTR
-    _nc_globals.read_thread = 0;
-#endif
+    _nc_set_read_thread(FALSE);
 #ifndef EXP_WIN32_DRIVER
     *buf = (int) c2;
 #endif
@@ -1532,7 +1527,7 @@ _nc_get_driver(TERMINAL_CONTROL_BLOCK * TCB, const char *name, int *errret)
 	res = DriverTable[i].driver;
 #ifdef _NC_WINDOWS
 	if ((i + 1) == SIZEOF(DriverTable)) {
-	    /* For Windows >= 10.0.17763 Windows Console interface implements 
+	    /* For Windows >= 10.0.17763 Windows Console interface implements
 	       virtual Terminal functionality.
 	       If on Windows td_CanHandle returned FALSE although the terminal
 	       name is empty, we default to ms-terminal as tinfo TERM type.
diff --git a/contrib/ncurses/ncurses/tinfo/trim_sgr0.c b/contrib/ncurses/ncurses/tinfo/trim_sgr0.c
index 30c8f75c1e8a..177dcd87225e 100644
--- a/contrib/ncurses/ncurses/tinfo/trim_sgr0.c
+++ b/contrib/ncurses/ncurses/tinfo/trim_sgr0.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020-2021,2023 Thomas E. Dickey                                *
  * Copyright 2005-2012,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -37,15 +37,11 @@
 
 #include <tic.h>
 
-MODULE_ID("$Id: trim_sgr0.c,v 1.20 2020/05/27 23:54:31 tom Exp $")
+MODULE_ID("$Id: trim_sgr0.c,v 1.22 2023/09/23 18:47:56 tom Exp $")
 
 #undef CUR
 #define CUR tp->
 
-#define CSI       233
-#define ESC       033		/* ^[ */
-#define L_BRACK   '['
-
 static char *
 set_attribute_9(TERMTYPE2 *tp, int flag)
 {
@@ -65,9 +61,9 @@ is_csi(const char *s)
 {
     int result = 0;
     if (s != 0) {
-	if (UChar(s[0]) == CSI)
+	if (UChar(s[0]) == CSI_CHR)
 	    result = 1;
-	else if (s[0] == ESC && s[1] == L_BRACK)
+	else if (s[0] == ESC_CHR && s[1] == L_BLOCK)
 	    result = 2;
     }
     return result;
@@ -222,7 +218,7 @@ compare_part(const char *part, const char *full)
 }
 
 /*
- * While 'sgr0' is the "same" as termcap 'me', there is a compatibility issue. 
+ * While 'sgr0' is the "same" as termcap 'me', there is a compatibility issue.
  * The sgr/sgr0 capabilities include setting/clearing alternate character set
  * mode.  A termcap application cannot use sgr, so sgr0 strings that reset
  * alternate character set mode will be misinterpreted.  Here, we remove those
diff --git a/contrib/ncurses/ncurses/tinfo/write_entry.c b/contrib/ncurses/ncurses/tinfo/write_entry.c
index 5bb7aee7f360..8ccca9eca6fc 100644
--- a/contrib/ncurses/ncurses/tinfo/write_entry.c
+++ b/contrib/ncurses/ncurses/tinfo/write_entry.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2023,2024 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -42,6 +42,8 @@
 
 #include <tic.h>
 
+MODULE_ID("$Id: write_entry.c,v 1.132 2024/04/20 17:58:51 tom Exp $")
+
 #if 1
 #define TRACE_OUT(p) DEBUG(2, p)
 #define TRACE_NUM(n) if (VALID_NUMERIC(Numbers[n])) { \
@@ -51,7 +53,15 @@
 #define TRACE_NUM(n)		/* nothing */
 #endif
 
-MODULE_ID("$Id: write_entry.c,v 1.116 2020/08/29 16:22:03 juergen Exp $")
+/*
+ * FIXME: special case to work around Cygwin bug in link(), which updates
+ * the target file's timestamp.
+ */
+#if HAVE_LINK && !USE_SYMLINKS && !MIXEDCASE_FILENAMES && defined(__CYGWIN__)
+#define LINK_TOUCHES 1
+#else
+#define LINK_TOUCHES 0
+#endif
 
 static int total_written;
 static int total_parts;
@@ -71,13 +81,13 @@ write_file(char *filename, TERMTYPE2 *tp)
 	_nc_warning("entry is larger than %u bytes", limit);
     } else {
 	FILE *fp = ((_nc_access(filename, W_OK) == 0)
-		    ? fopen(filename, BIN_W)
+		    ? safe_fopen(filename, BIN_W)
 		    : 0);
 	size_t actual;
 
 	if (fp == 0) {
 	    perror(filename);
-	    _nc_syserr_abort("can't open %s/%s", _nc_tic_dir(0), filename);
+	    _nc_syserr_abort("cannot open %s/%s", _nc_tic_dir(0), filename);
 	}
 
 	actual = fwrite(buffer, sizeof(char), (size_t) offset, fp);
@@ -85,12 +95,12 @@ write_file(char *filename, TERMTYPE2 *tp)
 	    int myerr = ferror(fp) ? errno : 0;
 	    if (myerr) {
 		_nc_syserr_abort("error writing %s/%s: %s",
-				 _nc_tic_dir(0),
+				 _nc_tic_dir(NULL),
 				 filename,
 				 strerror(myerr));
 	    } else {
 		_nc_syserr_abort("error writing %s/%s: %u bytes vs actual %lu",
-				 _nc_tic_dir(0),
+				 _nc_tic_dir(NULL),
 				 filename,
 				 offset,
 				 (unsigned long) actual);
@@ -118,18 +128,16 @@ check_writeable(int code)
     char dir[sizeof(LEAF_FMT)];
     char *s = 0;
 
-    if (code == 0 || (s = (strchr) (dirnames, code)) == 0)
+    if (code == 0 || (s = (strchr) (dirnames, code)) == 0) {
 	_nc_err_abort("Illegal terminfo subdirectory \"" LEAF_FMT "\"", code);
-
-    if (verified[s - dirnames])
-	return;
-
-    _nc_SPRINTF(dir, _nc_SLIMIT(sizeof(dir)) LEAF_FMT, code);
-    if (make_db_root(dir) < 0) {
-	_nc_err_abort("%s/%s: permission denied", _nc_tic_dir(0), dir);
+    } else if (!verified[s - dirnames]) {
+	_nc_SPRINTF(dir, _nc_SLIMIT(sizeof(dir)) LEAF_FMT, code);
+	if (make_db_root(dir) < 0) {
+	    _nc_err_abort("%s/%s: permission denied", _nc_tic_dir(NULL), dir);
+	} else {
+	    verified[s - dirnames] = TRUE;
+	}
     }
-
-    verified[s - dirnames] = TRUE;
 }
 #endif /* !USE_HASHED_DB */
 
@@ -137,7 +145,7 @@ static int
 make_db_path(char *dst, const char *src, size_t limit)
 {
     int rc = -1;
-    const char *top = _nc_tic_dir(0);
+    const char *top = _nc_tic_dir(NULL);
 
     if (src == top || _nc_is_abs_path(src)) {
 	if (strlen(src) + 1 <= limit) {
@@ -145,7 +153,7 @@ make_db_path(char *dst, const char *src, size_t limit)
 	    rc = 0;
 	}
     } else {
-	if (strlen(top) + strlen(src) + 2 <= limit) {
+	if ((strlen(top) + strlen(src) + 6) <= limit) {
 	    _nc_SPRINTF(dst, _nc_SLIMIT(limit) "%s/%s", top, src);
 	    rc = 0;
 	}
@@ -190,7 +198,7 @@ make_db_root(const char *path)
 #else
 	struct stat statbuf;
 
-	if ((rc = stat(path, &statbuf)) < 0) {
+	if ((rc = stat(path, &statbuf)) == -1) {
 	    rc = mkdir(path
 #ifndef _NC_WINDOWS
 		       ,0777
@@ -214,26 +222,30 @@ _nc_set_writedir(const char *dir)
 {
     const char *destination;
     char actual[PATH_MAX];
+    bool specific = (dir != NULL);
 
-    if (dir == 0
-#ifndef USE_ROOT_ENVIRON
-	&& use_terminfo_vars()
-#endif
-	)
+    if (!specific && use_terminfo_vars())
 	dir = getenv("TERMINFO");
 
-    if (dir != 0)
+    if (dir != NULL)
 	(void) _nc_tic_dir(dir);
 
-    destination = _nc_tic_dir(0);
+    destination = _nc_tic_dir(NULL);
     if (make_db_root(destination) < 0) {
-	char *home = _nc_home_terminfo();
+	bool success = FALSE;
+
+	if (!specific) {
+	    char *home = _nc_home_terminfo();
 
-	if (home != 0) {
-	    destination = home;
-	    if (make_db_root(destination) < 0)
-		_nc_err_abort("%s: permission denied (errno %d)",
-			      destination, errno);
+	    if (home != NULL) {
+		destination = home;
+		if (make_db_root(destination) == 0)
+		    success = TRUE;
+	    }
+	}
+	if (!success) {
+	    _nc_err_abort("%s: permission denied (errno %d)",
+			  destination, errno);
 	}
     }
 
@@ -245,10 +257,10 @@ _nc_set_writedir(const char *dir)
     make_db_path(actual, destination, sizeof(actual));
 #else
     if (chdir(_nc_tic_dir(destination)) < 0
-	|| getcwd(actual, sizeof(actual)) == 0)
+	|| getcwd(actual, sizeof(actual)) == NULL)
 	_nc_err_abort("%s: not a directory", destination);
 #endif
-    _nc_keep_tic_dir(strdup(actual));
+    _nc_keep_tic_dir(actual);
 }
 
 /*
@@ -327,8 +339,9 @@ _nc_write_entry(TERMTYPE2 *const tp)
     if (ptr != name_list) {
 	*ptr = '\0';
 
-	for (ptr = name_list; *ptr != '\0' && *ptr != '|'; ptr++)
-	    continue;
+	for (ptr = name_list; *ptr != '\0' && *ptr != '|'; ptr++) {
+	    /* EMPTY */ ;
+	}
 
 	if (*ptr == '\0')
 	    other_names = ptr;
@@ -345,10 +358,10 @@ _nc_write_entry(TERMTYPE2 *const tp)
 
 #if USE_HASHED_DB
     if (_nc_write_object(tp, buffer + 1, &offset, limit - 1) != ERR) {
-	DB *capdb = _nc_db_open(_nc_tic_dir(0), TRUE);
+	DB *capdb = _nc_db_open(_nc_tic_dir(NULL), TRUE);
 	DBT key, data;
 
-	if (capdb != 0) {
+	if (capdb != NULL) {
 	    buffer[0] = 0;
 
 	    memset(&key, 0, sizeof(key));
@@ -371,7 +384,7 @@ _nc_write_entry(TERMTYPE2 *const tp)
 		       sizeof(buffer) - 1);
 	    data.size = name_size + 1;
 
-	    total_size += data.size;
+	    total_size += (int) data.size;
 	    total_parts++;
 	    _nc_db_put(capdb, &key, &data);
 
@@ -387,7 +400,7 @@ _nc_write_entry(TERMTYPE2 *const tp)
 		key.data = ptr;
 		key.size = strlen(ptr);
 
-		total_size += data.size;
+		total_size += (int) data.size;
 		total_parts++;
 		_nc_db_put(capdb, &key, &data);
 	    }
@@ -442,10 +455,10 @@ _nc_write_entry(TERMTYPE2 *const tp)
     write_file(filename, tp);
 
     if (start_time == 0) {
-	if (stat(filename, &statbuf) < 0
+	if (stat(filename, &statbuf) == -1
 	    || (start_time = statbuf.st_mtime) == 0) {
 	    _nc_syserr_abort("error obtaining time from %s/%s",
-			     _nc_tic_dir(0), filename);
+			     _nc_tic_dir(NULL), filename);
 	}
     }
     while (*other_names != '\0') {
@@ -460,7 +473,7 @@ _nc_write_entry(TERMTYPE2 *const tp)
 	    _nc_warning("terminal alias %s too long.", ptr);
 	    continue;
 	}
-	if (strchr(ptr, '/') != 0) {
+	if (strchr(ptr, '/') != NULL) {
 	    _nc_warning("cannot link alias %s.", ptr);
 	    continue;
 	}
@@ -472,10 +485,14 @@ _nc_write_entry(TERMTYPE2 *const tp)
 
 	if (strcmp(filename, linkname) == 0) {
 	    _nc_warning("self-synonym ignored");
-	} else if (stat(linkname, &statbuf) >= 0 &&
-		   statbuf.st_mtime < start_time) {
+	}
+#if !LINK_TOUCHES
+	else if (stat(linkname, &statbuf) >= 0 &&
+		 statbuf.st_mtime < start_time) {
 	    _nc_warning("alias %s multiply defined.", ptr);
-	} else if (_nc_access(linkname, W_OK) == 0)
+	}
+#endif
+	else if (_nc_access(linkname, W_OK) == 0)
 #if HAVE_LINK
 	{
 	    int code;
@@ -514,9 +531,9 @@ _nc_write_entry(TERMTYPE2 *const tp)
 		    write_file(linkname, tp);
 		else {
 #if MIXEDCASE_FILENAMES
-		    _nc_syserr_abort("can't link %s to %s", filename, linkname);
+		    _nc_syserr_abort("cannot link %s to %s", filename, linkname);
 #else
-		    _nc_warning("can't link %s to %s (errno=%d)", filename,
+		    _nc_warning("cannot link %s to %s (errno=%d)", filename,
 				linkname, errno);
 #endif
 		}
@@ -712,7 +729,7 @@ _nc_write_object(TERMTYPE2 *tp, char *buffer, unsigned *offset, unsigned limit)
     unsigned last_str = STRWRITE;
 #if NCURSES_EXT_NUMBERS
     bool need_ints = FALSE;
-    size_t (*convert_numbers) (unsigned char *, NCURSES_INT2 *, size_t) = convert_32bit;
+    size_t (*convert_numbers) (unsigned char *, NCURSES_INT2 *, size_t);
 #else
 #define convert_numbers convert_shorts
 #endif
@@ -773,7 +790,8 @@ _nc_write_object(TERMTYPE2 *tp, char *buffer, unsigned *offset, unsigned limit)
 #else
     LITTLE_ENDIAN(buf, MAGIC);
 #endif
-    LITTLE_ENDIAN(buf + 2, min(namelen, MAX_NAME_SIZE + 1));
+    namelen = Min(namelen, MAX_NAME_SIZE + 1);
+    LITTLE_ENDIAN(buf + 2, namelen);
     LITTLE_ENDIAN(buf + 4, boolmax);
     LITTLE_ENDIAN(buf + 6, nummax);
     LITTLE_ENDIAN(buf + 8, strmax);
diff --git a/contrib/ncurses/ncurses/trace/lib_trace.c b/contrib/ncurses/ncurses/trace/lib_trace.c
index 5eb87fe0c176..0904c132fee1 100644
--- a/contrib/ncurses/ncurses/trace/lib_trace.c
+++ b/contrib/ncurses/ncurses/trace/lib_trace.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2023,2024 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -37,7 +37,7 @@
 /*
  *	lib_trace.c - Tracing/Debugging routines
  *
- * The _tracef() function is originally from pcurses (by Pavel Curtis) in 1982. 
+ * The _tracef() function is originally from pcurses (by Pavel Curtis) in 1982.
  * pcurses allowed one to enable/disable tracing using traceon() and traceoff()
  * functions.  ncurses provides a trace() function which allows one to
  * selectively enable or disable several tracing features.
@@ -48,7 +48,7 @@
 
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_trace.c,v 1.97 2020/08/29 16:22:03 juergen Exp $")
+MODULE_ID("$Id: lib_trace.c,v 1.106 2024/02/24 18:28:19 tom Exp $")
 
 NCURSES_EXPORT_VAR(unsigned) _nc_tracing = 0; /* always define this */
 
@@ -89,45 +89,74 @@ NCURSES_EXPORT_VAR(long) _nc_outchars = 0;
 #define MyFP		_nc_globals.trace_fp
 #define MyFD		_nc_globals.trace_fd
 #define MyInit		_nc_globals.trace_opened
-#define MyPath		_nc_globals.trace_fname
 #define MyLevel		_nc_globals.trace_level
 #define MyNested	_nc_globals.nested_tracef
 #endif /* TRACE */
 
+#if USE_REENTRANT
+#define Locked(statement) \
+    do { \
+	_nc_lock_global(tst_tracef); \
+	statement; \
+	_nc_unlock_global(tst_tracef); \
+    } while (0)
+#else
+#define Locked(statement) statement
+#endif
+
 NCURSES_EXPORT(unsigned)
 curses_trace(unsigned tracelevel)
 {
     unsigned result;
+
 #if defined(TRACE)
-    result = _nc_tracing;
+    int bit;
+
+#define DATA(name) { name, #name }
+    static struct {
+	unsigned mask;
+	const char *name;
+    } trace_names[] = {
+	DATA(TRACE_TIMES),
+	    DATA(TRACE_TPUTS),
+	    DATA(TRACE_UPDATE),
+	    DATA(TRACE_MOVE),
+	    DATA(TRACE_CHARPUT),
+	    DATA(TRACE_CALLS),
+	    DATA(TRACE_VIRTPUT),
+	    DATA(TRACE_IEVENT),
+	    DATA(TRACE_BITS),
+	    DATA(TRACE_ICALLS),
+	    DATA(TRACE_CCALLS),
+	    DATA(TRACE_DATABASE),
+	    DATA(TRACE_ATTRS)
+    };
+#undef DATA
+
+    Locked(result = _nc_tracing);
+
     if ((MyFP == 0) && tracelevel) {
 	MyInit = TRUE;
 	if (MyFD >= 0) {
 	    MyFP = fdopen(MyFD, BIN_W);
 	} else {
-	    if (MyPath[0] == '\0') {
-		size_t size = sizeof(MyPath) - 12;
-		if (getcwd(MyPath, size) == 0) {
-		    perror("curses: Can't get working directory");
-		    exit(EXIT_FAILURE);
-		}
-		MyPath[size] = '\0';
-		assert(strlen(MyPath) <= size);
-		_nc_STRCAT(MyPath, "/trace", sizeof(MyPath));
-		if (_nc_is_dir_path(MyPath)) {
-		    _nc_STRCAT(MyPath, ".log", sizeof(MyPath));
-		}
+	    char myFile[80];
+
+	    _nc_STRCPY(myFile, "trace", sizeof(myFile));
+	    if (_nc_is_dir_path(myFile)) {
+		_nc_STRCAT(myFile, ".log", sizeof(myFile));
 	    }
-	    if (_nc_access(MyPath, W_OK) < 0
-		|| (MyFD = open(MyPath, O_CREAT | O_EXCL | O_RDWR, 0600)) < 0
+#define SAFE_MODE (O_CREAT | O_EXCL | O_RDWR)
+	    if (_nc_access(myFile, W_OK) < 0
+		|| (MyFD = safe_open3(myFile, SAFE_MODE, 0600)) < 0
 		|| (MyFP = fdopen(MyFD, BIN_W)) == 0) {
 		;		/* EMPTY */
 	    }
 	}
-	_nc_tracing = tracelevel;
+	Locked(_nc_tracing = tracelevel);
 	/* Try to set line-buffered mode, or (failing that) unbuffered,
 	 * so that the trace-output gets flushed automatically at the
-	 * end of each line.  This is useful in case the program dies. 
+	 * end of each line.  This is useful in case the program dies.
 	 */
 	if (MyFP != 0) {
 #if HAVE_SETVBUF		/* ANSI */
@@ -140,15 +169,33 @@ curses_trace(unsigned tracelevel)
 		NCURSES_VERSION,
 		NCURSES_VERSION_PATCH,
 		tracelevel);
+
+#define SPECIAL_MASK(mask) \
+	    if ((tracelevel & mask) == mask) \
+		_tracef("- %s (%u)", #mask, mask)
+
+	for (bit = 0; bit < TRACE_SHIFT; ++bit) {
+	    unsigned mask = (1U << bit) & tracelevel;
+	    if ((mask & trace_names[bit].mask) != 0) {
+		_tracef("- %s (%u)", trace_names[bit].name, mask);
+	    }
+	}
+	SPECIAL_MASK(TRACE_MAXIMUM);
+	else
+	SPECIAL_MASK(TRACE_ORDINARY);
+
+	if (tracelevel > TRACE_MAXIMUM) {
+	    _tracef("- DEBUG_LEVEL(%u)", tracelevel >> TRACE_SHIFT);
+	}
     } else if (tracelevel == 0) {
 	if (MyFP != 0) {
 	    MyFD = dup(MyFD);	/* allow reopen of same file */
 	    fclose(MyFP);
 	    MyFP = 0;
 	}
-	_nc_tracing = tracelevel;
+	Locked(_nc_tracing = tracelevel);
     } else if (_nc_tracing != tracelevel) {
-	_nc_tracing = tracelevel;
+	Locked(_nc_tracing = tracelevel);
 	_tracef("tracelevel=%#x", tracelevel);
     }
 #else
@@ -213,11 +260,13 @@ _nc_va_tracef(const char *fmt, va_list ap)
 # if USE_WEAK_SYMBOLS
 	if ((pthread_self))
 # endif
+	    fprintf(fp, "%#" PRIxPTR ":",
 #ifdef _NC_WINDOWS
-	    fprintf(fp, "%#lx:", (long) (intptr_t) pthread_self().p);
+		    CASTxPTR(pthread_self().p)
 #else
-	    fprintf(fp, "%#lx:", (long) (intptr_t) pthread_self());
+		    CASTxPTR(pthread_self())
 #endif
+		);
 #endif
 	if (before || after) {
 	    int n;
diff --git a/contrib/ncurses/ncurses/trace/lib_traceatr.c b/contrib/ncurses/ncurses/trace/lib_traceatr.c
index 940262750508..b36286253d6d 100644
--- a/contrib/ncurses/ncurses/trace/lib_traceatr.c
+++ b/contrib/ncurses/ncurses/trace/lib_traceatr.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2022,2024 Thomas E. Dickey                                *
  * Copyright 1998-2017,2018 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -44,7 +44,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_traceatr.c,v 1.94 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_traceatr.c,v 1.96 2024/02/04 00:11:35 tom Exp $")
 
 #define COLOR_OF(c) ((c < 0) ? "default" : (c > 7 ? color_of(c) : colors[c].name))
 
@@ -343,6 +343,7 @@ _tracecchar_t2(int bufnum, const cchar_t *ch)
 	    } else {
 		PUTC_DATA;
 		int n;
+		int assume_unicode = _nc_unicode_locale()? 128 : 255;
 
 		(void) _nc_trace_bufcat(bufnum, "{ ");
 		for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) {
@@ -362,21 +363,22 @@ _tracecchar_t2(int bufnum, const cchar_t *ch)
 								  UChar(ch->chars[PUTC_i])));
 			}
 			break;
-		    } else if (ch->chars[PUTC_i] > 255) {
+		    } else if (ch->chars[PUTC_i] > assume_unicode) {
 			char temp[80];
 			_nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
-				    "{%d:\\u%lx}",
+				    "{%d:\\u%04lx}",
 				    _nc_wacs_width(ch->chars[PUTC_i]),
 				    (unsigned long) ch->chars[PUTC_i]);
 			(void) _nc_trace_bufcat(bufnum, temp);
-			break;
-		    }
-		    for (n = 0; n < PUTC_n; n++) {
-			if (n)
-			    (void) _nc_trace_bufcat(bufnum, ", ");
-			(void) _nc_trace_bufcat(bufnum,
-						_nc_tracechar(CURRENT_SCREEN,
-							      UChar(PUTC_buf[n])));
+			attr &= ~A_CHARTEXT;	/* ignore WidecExt(ch) */
+		    } else {
+			for (n = 0; n < PUTC_n; n++) {
+			    if (n)
+				(void) _nc_trace_bufcat(bufnum, ", ");
+			    (void) _nc_trace_bufcat(bufnum,
+						    _nc_tracechar(CURRENT_SCREEN,
+								  UChar(PUTC_buf[n])));
+			}
 		    }
 		}
 		(void) _nc_trace_bufcat(bufnum, " }");
diff --git a/contrib/ncurses/ncurses/trace/lib_tracechr.c b/contrib/ncurses/ncurses/trace/lib_tracechr.c
index 36158d6f45a6..9c879dc67397 100644
--- a/contrib/ncurses/ncurses/trace/lib_tracechr.c
+++ b/contrib/ncurses/ncurses/trace/lib_tracechr.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2024 Thomas E. Dickey                                     *
  * Copyright 1998-2009,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -40,7 +40,7 @@
 
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_tracechr.c,v 1.23 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_tracechr.c,v 1.24 2024/02/04 00:11:35 tom Exp $")
 
 #ifdef TRACE
 
@@ -54,26 +54,28 @@ _nc_tracechar(SCREEN *sp, int ch)
 		      ? sp->tracechr_buf
 		      : _nc_globals.tracechr_buf);
 
-    if (ch > KEY_MIN || ch < 0) {
+    if ((ch > KEY_MIN && !_nc_unicode_locale()) || ch < 0) {
 	name = safe_keyname(SP_PARM, ch);
 	if (name == 0 || *name == '\0')
 	    name = "NULL";
 	_nc_SPRINTF(MyBuffer, _nc_SLIMIT(MyBufSize)
-		    "'%.30s' = %#03o", name, ch);
-    } else if (!is8bits(ch) || !isprint(UChar(ch))) {
+		    "'%.30s' = \\x%02x", name, ch);
+    } else if (!is8bits(ch)
+	       || (_nc_unicode_locale() && !is7bits(ch))
+	       || !isprint(UChar(ch))) {
 	/*
 	 * workaround for glibc bug:
 	 * sprintf changes the result from unctrl() to an empty string if it
 	 * does not correspond to a valid multibyte sequence.
 	 */
 	_nc_SPRINTF(MyBuffer, _nc_SLIMIT(MyBufSize)
-		    "%#03o", ch);
+		    "\\x%02x", ch);
     } else {
 	name = safe_unctrl(SP_PARM, (chtype) ch);
 	if (name == 0 || *name == 0)
 	    name = "null";	/* shouldn't happen */
 	_nc_SPRINTF(MyBuffer, _nc_SLIMIT(MyBufSize)
-		    "'%.30s' = %#03o", name, ch);
+		    "'%.30s' = \\x%02x", name, ch);
     }
     return (MyBuffer);
 }
diff --git a/contrib/ncurses/ncurses/trace/lib_tracedmp.c b/contrib/ncurses/ncurses/trace/lib_tracedmp.c
index 3b7ea0749986..529148bb785a 100644
--- a/contrib/ncurses/ncurses/trace/lib_tracedmp.c
+++ b/contrib/ncurses/ncurses/trace/lib_tracedmp.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
  * Copyright 1998-2012,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -40,7 +40,7 @@
 #include <curses.priv.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_tracedmp.c,v 1.36 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_tracedmp.c,v 1.37 2023/06/24 15:49:45 tom Exp $")
 
 #ifdef TRACE
 
@@ -71,9 +71,9 @@ _tracedump(const char *name, WINDOW *win)
     if (++width + 1 > (int) my_length) {
 	my_length = (unsigned) (2 * (width + 1));
 	my_buffer = typeRealloc(char, my_length, my_buffer);
-	if (my_buffer == 0)
-	    return;
     }
+    if (my_buffer == 0)
+	return;
 
     for (n = 0; n <= win->_maxy; ++n) {
 	char *ep = my_buffer;
diff --git a/contrib/ncurses/ncurses/trace/trace_buf.c b/contrib/ncurses/ncurses/trace/trace_buf.c
index 7e6384b54153..91b12e45c248 100644
--- a/contrib/ncurses/ncurses/trace/trace_buf.c
+++ b/contrib/ncurses/ncurses/trace/trace_buf.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
  * Copyright 1998-2011,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -36,7 +36,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: trace_buf.c,v 1.21 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: trace_buf.c,v 1.22 2023/06/24 13:37:25 tom Exp $")
 
 #ifdef TRACE
 
@@ -104,7 +104,11 @@ _nc_trace_buf(int bufnum, size_t want)
 NCURSES_EXPORT(char *)
 _nc_trace_bufcat(int bufnum, const char *value)
 {
-    char *buffer = _nc_trace_alloc(bufnum, (size_t) 0);
+    char *buffer;
+
+    if (value == NULL)
+	value = "";
+    buffer = _nc_trace_alloc(bufnum, (size_t) 0);
     if (buffer != 0) {
 	size_t have = strlen(buffer);
 	size_t need = strlen(value) + have;
diff --git a/contrib/ncurses/ncurses/trace/varargs.c b/contrib/ncurses/ncurses/trace/varargs.c
index 9be5fc254fb0..7b9533bd62f4 100644
--- a/contrib/ncurses/ncurses/trace/varargs.c
+++ b/contrib/ncurses/ncurses/trace/varargs.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
  * Copyright 2001-2008,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -35,7 +35,7 @@
 
 #include <ctype.h>
 
-MODULE_ID("$Id: varargs.c,v 1.12 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: varargs.c,v 1.13 2023/06/24 13:41:46 tom Exp $")
 
 #ifdef TRACE
 
@@ -59,18 +59,16 @@ typedef enum {
 NCURSES_EXPORT(char *)
 _nc_varargs(const char *fmt, va_list ap)
 {
-    static char dummy[] = "";
-
     char buffer[BUFSIZ];
     const char *param;
     int n;
 
     if (fmt == 0 || *fmt == '\0')
-	return dummy;
+	return NULL;
     if (MyLength == 0)
 	MyBuffer = typeMalloc(char, MyLength = BUFSIZ);
     if (MyBuffer == 0)
-	return dummy;
+	return NULL;
     *MyBuffer = '\0';
 
     while (*fmt != '\0') {
@@ -185,7 +183,7 @@ _nc_varargs(const char *fmt, va_list ap)
 	}
     }
 
-    return (MyBuffer ? MyBuffer : dummy);
+    return (MyBuffer ? MyBuffer : NULL);
 }
 #else
 EMPTY_MODULE(_nc_varargs)
diff --git a/contrib/ncurses/ncurses/trace/visbuf.c b/contrib/ncurses/ncurses/trace/visbuf.c
index 5f95a6bc50c0..590e42306f51 100644
--- a/contrib/ncurses/ncurses/trace/visbuf.c
+++ b/contrib/ncurses/ncurses/trace/visbuf.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 2019-2021,2023 Thomas E. Dickey                                *
  * Copyright 2001-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -43,7 +43,7 @@
 #include <tic.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: visbuf.c,v 1.52 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: visbuf.c,v 1.54 2023/05/27 20:13:10 tom Exp $")
 
 #define NUM_VISBUFS 4
 
@@ -67,7 +67,9 @@ static const char r_brace[] = StringOf(R_BRACE);
 static char *
 _nc_vischar(char *tp, unsigned c LIMIT_ARG)
 {
-    if (c == '"' || c == '\\') {
+    if (tp == NULL) {
+	return NULL;
+    } else if (c == '"' || c == '\\') {
 	*tp++ = '\\';
 	*tp++ = (char) c;
     } else if (is7bits((int) c) && (isgraph((int) c) || c == ' ')) {
@@ -283,7 +285,7 @@ _nc_viswibuf(const wint_t *buf)
 
 /* use these functions for displaying parts of a line within a window */
 NCURSES_EXPORT(const char *)
-_nc_viscbuf2(int bufnum, const NCURSES_CH_T * buf, int len)
+_nc_viscbuf2(int bufnum, const NCURSES_CH_T *buf, int len)
 {
     char *result = _nc_trace_buf(bufnum, (size_t) BUFSIZ);
 
@@ -371,7 +373,7 @@ _nc_viscbuf2(int bufnum, const NCURSES_CH_T * buf, int len)
 }
 
 NCURSES_EXPORT(const char *)
-_nc_viscbuf(const NCURSES_CH_T * buf, int len)
+_nc_viscbuf(const NCURSES_CH_T *buf, int len)
 {
     return _nc_viscbuf2(0, buf, len);
 }
diff --git a/contrib/ncurses/ncurses/tty/MKexpanded.sh b/contrib/ncurses/ncurses/tty/MKexpanded.sh
index 65c6b93e4627..0072be2cd35d 100755
--- a/contrib/ncurses/ncurses/tty/MKexpanded.sh
+++ b/contrib/ncurses/ncurses/tty/MKexpanded.sh
@@ -1,6 +1,6 @@
 #! /bin/sh
 ##############################################################################
-# Copyright 2019,2020 Thomas E. Dickey                                       #
+# Copyright 2019-2020,2021 Thomas E. Dickey                                  #
 # Copyright 1998-2015,2017 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -30,7 +30,7 @@
 #
 # Author: Thomas E. Dickey, 1997-on
 #
-# $Id: MKexpanded.sh,v 1.22 2020/02/02 23:34:34 tom Exp $
+# $Id: MKexpanded.sh,v 1.24 2022/02/05 17:27:18 tom Exp $
 #
 # Script to generate 'expanded.c', a dummy source that contains functions
 # corresponding to complex macros used in this library.  By making functions,
@@ -49,7 +49,8 @@ else
 fi
 
 TMP=gen$$.c
-trap "rm -f $TMP" EXIT INT QUIT TERM HUP
+trap "rm -f $TMP; exit 1" 1 2 3 15
+trap "rm -f $TMP" 0
 
 cat <<EOF
 /* generated by MKexpanded.sh */
@@ -81,7 +82,7 @@ _nc_toggle_attr_on (attr_t *S, attr_t at)
 }
 
 NCURSES_EXPORT(void)
-_nc_toggle_attr_off (attr_t *S, attr_t at) 
+_nc_toggle_attr_off (attr_t *S, attr_t at)
 {
 	toggle_attr_off(*S,at);
 }
diff --git a/contrib/ncurses/ncurses/tty/hardscroll.c b/contrib/ncurses/ncurses/tty/hardscroll.c
index abb21cfddfe3..2b1f079e4b9e 100644
--- a/contrib/ncurses/ncurses/tty/hardscroll.c
+++ b/contrib/ncurses/ncurses/tty/hardscroll.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
  * Copyright 1998-2015,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -148,7 +148,7 @@ AUTHOR
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: hardscroll.c,v 1.54 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: hardscroll.c,v 1.58 2023/09/09 16:04:08 Nicholas.Marriott Exp $")
 
 #if defined(SCROLLDEBUG) || defined(HASHDEBUG)
 
@@ -204,13 +204,19 @@ NCURSES_SP_NAME(_nc_scroll_optimize) (NCURSES_SP_DCL0)
 	int *new_oldnums = typeRealloc(int,
 				       (size_t) need_lines,
 				       oldnums(SP_PARM));
-	if (!new_oldnums)
+	if (!new_oldnums) {
+	    TR(TRACE_ICALLS, (T_RETURN("")));
 	    return;
+	}
 	oldnums(SP_PARM) = new_oldnums;
 	OLDNUM_SIZE(SP_PARM) = need_lines;
     }
     /* calculate the indices */
     NCURSES_SP_NAME(_nc_hash_map) (NCURSES_SP_ARG);
+    if (SP_PARM->hashtab_len < screen_lines(SP_PARM)) {
+	TR(TRACE_ICALLS, (T_RETURN("")));
+	return;
+    }
 #endif
 #endif /* !defined(SCROLLDEBUG) && !defined(HASHDEBUG) */
 
@@ -301,20 +307,27 @@ NCURSES_EXPORT(void)
 NCURSES_SP_NAME(_nc_linedump) (NCURSES_SP_DCL0)
 /* dump the state of the real and virtual oldnum fields */
 {
-    char *buf = 0;
-    size_t want = ((size_t) screen_lines(SP_PARM) + 1) * 4;
-    (void) SP_PARM;
-
-    if ((buf = typeMalloc(char, want)) != 0) {
-	int n;
-
-	*buf = '\0';
-	for (n = 0; n < screen_lines(SP_PARM); n++)
-	    _nc_SPRINTF(buf + strlen(buf),
-			_nc_SLIMIT(want - strlen(buf))
-			" %02d", OLDNUM(SP_PARM, n));
-	TR(TRACE_UPDATE | TRACE_MOVE, ("virt %s", buf));
-	free(buf);
+    if (USE_TRACEF(TRACE_UPDATE | TRACE_MOVE)) {
+	char *buf = 0;
+	size_t want = ((size_t) screen_lines(SP_PARM) + 1) * 4;
+	(void) SP_PARM;
+
+	if ((buf = typeMalloc(char, want)) != 0) {
+	    int n;
+
+	    *buf = '\0';
+	    for (n = 0; n < screen_lines(SP_PARM); n++) {
+		int number = OLDNUM(SP_PARM, n);
+		if (number >= -99 && number < 999) {
+		    _nc_SPRINTF(buf + strlen(buf),
+				_nc_SLIMIT(want - strlen(buf))
+				" %02d", number);
+		} else {
+		    _nc_STRCAT(buf, " ??", want - strlen(buf));
+		}
+	    }
+	    free(buf);
+	}
     }
 }
 
diff --git a/contrib/ncurses/ncurses/tty/hashmap.c b/contrib/ncurses/ncurses/tty/hashmap.c
index 3f124c96c896..e50b63847b99 100644
--- a/contrib/ncurses/ncurses/tty/hashmap.c
+++ b/contrib/ncurses/ncurses/tty/hashmap.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 2019-2020,2023 Thomas E. Dickey                                *
  * Copyright 1998-2015,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -74,7 +74,7 @@ AUTHOR
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: hashmap.c,v 1.69 2020/05/31 17:50:48 tom Exp $")
+MODULE_ID("$Id: hashmap.c,v 1.71 2023/09/16 16:28:53 tom Exp $")
 
 #ifdef HASHDEBUG
 
@@ -318,8 +318,11 @@ NCURSES_SP_NAME(_nc_hash_map) (NCURSES_SP_DCL0)
 	if (newhash(SP_PARM) == 0)
 	    newhash(SP_PARM) = typeCalloc(unsigned long,
 					    (size_t) screen_lines(SP_PARM));
-	if (!oldhash(SP_PARM) || !newhash(SP_PARM))
+	if (!oldhash(SP_PARM) || !newhash(SP_PARM)) {
+	    FreeAndNull(oldhash(SP_PARM));
+	    FreeAndNull(newhash(SP_PARM));
 	    return;		/* malloc failure */
+	}
 	for (i = 0; i < screen_lines(SP_PARM); i++) {
 	    newhash(SP_PARM)[i] = hash(SP_PARM, NEWTEXT(SP_PARM, i));
 	    oldhash(SP_PARM)[i] = hash(SP_PARM, OLDTEXT(SP_PARM, i));
@@ -403,7 +406,7 @@ NCURSES_SP_NAME(_nc_hash_map) (NCURSES_SP_DCL0)
 	       && OLDNUM(SP_PARM, i) - i == shift)
 	    i++;
 	size = i - start;
-	if (size < 3 || size + min(size / 8, 2) < abs(shift)) {
+	if (size < 3 || size + Min(size / 8, 2) < abs(shift)) {
 	    while (start < i) {
 		OLDNUM(SP_PARM, start) = _NEWINDEX;
 		start++;
diff --git a/contrib/ncurses/ncurses/tty/lib_mvcur.c b/contrib/ncurses/ncurses/tty/lib_mvcur.c
index dd0dc3d9b712..8fad93c727ae 100644
--- a/contrib/ncurses/ncurses/tty/lib_mvcur.c
+++ b/contrib/ncurses/ncurses/tty/lib_mvcur.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2020,2021 Thomas E. Dickey                                *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -83,8 +83,8 @@
 
 /*
  * The average overhead of a full optimization computation in character
- * transmission times.  If it's too high, the algorithm will be a bit
- * over-biased toward using cup rather than local motions; if it's too
+ * transmission times.  If it is too high, the algorithm will be a bit
+ * over-biased toward using cup rather than local motions; if it is too
  * low, the algorithm may spend more time than is strictly optimal
  * looking for non-cup motions.  Profile the optimizer using the `t'
  * command of the exerciser (see below), and round to the nearest integer.
@@ -98,7 +98,7 @@
 
 /*
  * LONG_DIST is the distance we consider to be just as costly to move over as a
- * cup sequence is to emit.  In other words, it's the length of a cup sequence
+ * cup sequence is to emit.  In other words, it is the length of a cup sequence
  * adjusted for average computation overhead.  The magic number is the length
  * of "\033[yy;xxH", the typical cup sequence these days.
  */
@@ -148,7 +148,7 @@
  *	int		_rep_cost;	// cost of (repeat_char)
  *
  * The USE_HARD_TABS switch controls whether it is reliable to use tab/backtabs
- * for local motions.  On many systems, it's not, due to uncertainties about
+ * for local motions.  On many systems, it is not, due to uncertainties about
  * tab delays and whether or not tabs will be expanded in raw mode.  If you
  * have parm_right_cursor, tab motions don't win you a lot anyhow.
  */
@@ -160,7 +160,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_mvcur.c,v 1.155 2021/02/06 13:53:41 tom Exp $")
+MODULE_ID("$Id: lib_mvcur.c,v 1.161 2023/09/16 16:29:02 tom Exp $")
 
 #define WANT_CHAR(sp, y, x) NewScreen(sp)->_line[y].text[x]	/* desired state */
 
@@ -232,14 +232,33 @@ NCURSES_SP_NAME(_nc_msec_cost) (NCURSES_SP_DCLx const char *const cap, int affcn
 	    /* extract padding, either mandatory or required */
 	    if (cp[0] == '$' && cp[1] == '<' && strchr(cp, '>')) {
 		float number = 0.0;
+		int state = 0;
 
 		for (cp += 2; *cp != '>'; cp++) {
-		    if (isdigit(UChar(*cp)))
-			number = number * 10 + (float) (*cp - '0');
-		    else if (*cp == '*')
-			number *= (float) affcnt;
-		    else if (*cp == '.' && (*++cp != '>') && isdigit(UChar(*cp)))
-			number += (float) ((*cp - '0') / 10.0);
+		    if (isdigit(UChar(*cp))) {
+			switch (state) {
+			case 0:
+			    number = number * 10 + (float) (*cp - '0');
+			    break;
+			case 2:
+			    number += (float) ((*cp - '0') / 10.0);
+			    ++state;
+			    break;
+			}
+		    } else if (*cp == '*') {
+			/* padding is always a suffix */
+			if (state < 4) {
+			    number *= (float) affcnt;
+			    state = 4;
+			}
+		    } else if (*cp == '.') {
+			/* a single decimal point is allowed */
+			state = (state == 0) ? 2 : 3;
+		    }
+		    if (number > MAX_DELAY_MSECS) {
+			number = MAX_DELAY_MSECS;
+			break;
+		    }
 		}
 
 #if NCURSES_NO_PADDING
@@ -432,8 +451,8 @@ NCURSES_SP_NAME(_nc_mvcur_init) (NCURSES_SP_DCL0)
 					   1);
     SP_PARM->_hpa_ch_cost = NormalizedCost(TIPARM_1(column_address, 23), 1);
     SP_PARM->_cuf_ch_cost = NormalizedCost(TIPARM_1(parm_right_cursor, 23), 1);
-    SP_PARM->_inline_cost = min(SP_PARM->_cup_ch_cost,
-				min(SP_PARM->_hpa_ch_cost,
+    SP_PARM->_inline_cost = Min(SP_PARM->_cup_ch_cost,
+				Min(SP_PARM->_hpa_ch_cost,
 				    SP_PARM->_cuf_ch_cost));
 
     /*
@@ -470,12 +489,12 @@ NCURSES_EXPORT(void)
 NCURSES_SP_NAME(_nc_mvcur_wrap) (NCURSES_SP_DCL0)
 /* wrap up cursor-addressing mode */
 {
-    /* leave cursor at screen bottom */
-    TINFO_MVCUR(NCURSES_SP_ARGx -1, -1, screen_lines(SP_PARM) - 1, 0);
-
     if (!SP_PARM || !IsTermInfo(SP_PARM))
 	return;
 
+    /* leave cursor at screen bottom */
+    TINFO_MVCUR(NCURSES_SP_ARGx -1, -1, screen_lines(SP_PARM) - 1, 0);
+
     /* set cursor to normal mode */
     if (SP_PARM->_cursor != -1) {
 	int cursor = SP_PARM->_cursor;
@@ -675,7 +694,7 @@ relative_move(NCURSES_SP_DCLx
 		 * and the time the structure WANT_CHAR would access has been
 		 * updated.
 		 */
-		if (ovw) {
+		if (ovw && to_y >= 0) {
 		    int i;
 
 		    for (i = 0; i < n; i++) {
@@ -690,7 +709,7 @@ relative_move(NCURSES_SP_DCLx
 			}
 		    }
 		}
-		if (ovw) {
+		if (ovw && to_y >= 0) {
 		    int i;
 
 		    for (i = 0; i < n; i++)
@@ -760,7 +779,7 @@ relative_move(NCURSES_SP_DCLx
 #endif /* !NO_OPTIMIZE */
 
 /*
- * With the machinery set up above, it's conceivable that
+ * With the machinery set up above, it is conceivable that
  * onscreen_mvcur could be modified into a recursive function that does
  * an alpha-beta search of motion space, as though it were a chess
  * move tree, with the weight function being boolean and the search
diff --git a/contrib/ncurses/ncurses/tty/lib_tstp.c b/contrib/ncurses/ncurses/tty/lib_tstp.c
index 43a58e660a16..dd925c7efd12 100644
--- a/contrib/ncurses/ncurses/tty/lib_tstp.c
+++ b/contrib/ncurses/ncurses/tty/lib_tstp.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020-2021,2022 Thomas E. Dickey                                *
  * Copyright 1998-2014,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -43,7 +43,7 @@
 
 #include <SigAction.h>
 
-MODULE_ID("$Id: lib_tstp.c,v 1.50 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_tstp.c,v 1.54 2022/12/24 22:22:10 tom Exp $")
 
 #if defined(SIGTSTP) && (HAVE_SIGACTION || HAVE_SIGVEC)
 #define USE_SIGTSTP 1
@@ -130,7 +130,7 @@ signal_name(int sig)
  * (this may include XENIX).
  *
  * This implementation will probably be changed to use signal(3) in
- * the future.  If nothing else, it's simpler...
+ * the future.  If nothing else, it is simpler...
  */
 
 #if USE_SIGTSTP
@@ -283,7 +283,25 @@ handle_SIGINT(int sig)
     _exit(EXIT_FAILURE);
 }
 
+# ifndef _nc_set_read_thread
+NCURSES_EXPORT(void)
+_nc_set_read_thread(bool enable)
+{
+    _nc_lock_global(curses);
+    if (enable) {
+#  if USE_WEAK_SYMBOLS
+	if ((pthread_self) && (pthread_kill) && (pthread_equal))
+#  endif
+	    _nc_globals.read_thread = pthread_self();
+    } else {
+	_nc_globals.read_thread = 0;
+    }
+    _nc_unlock_global(curses);
+}
+# endif
+
 #if USE_SIGWINCH
+
 static void
 handle_SIGWINCH(int sig GCC_UNUSED)
 {
diff --git a/contrib/ncurses/ncurses/tty/lib_twait.c b/contrib/ncurses/ncurses/tty/lib_twait.c
index a7604b3e293b..6fa73eedb4ce 100644
--- a/contrib/ncurses/ncurses/tty/lib_twait.c
+++ b/contrib/ncurses/ncurses/tty/lib_twait.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2018-2020,2023 Thomas E. Dickey                                *
  * Copyright 1998-2015,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -76,8 +76,11 @@
 #endif
 #undef CUR
 
-MODULE_ID("$Id: lib_twait.c,v 1.75 2020/02/29 15:46:00 anonymous.maarten Exp $")
+MODULE_ID("$Id: lib_twait.c,v 1.81 2023/09/16 16:30:40 tom Exp $")
 
+/*
+ * Returns an elapsed time, in milliseconds (if possible).
+ */
 static long
 _nc_gettime(TimeType * t0, int first)
 {
@@ -85,18 +88,20 @@ _nc_gettime(TimeType * t0, int first)
 
 #if PRECISE_GETTIME
     TimeType t1;
-    gettimeofday(&t1, (struct timezone *) 0);
-    if (first) {
+    if (GetClockTime(&t1) == -1) {
+	*t0 = t1;
+	res = first ? 0 : 1;
+    } else if (first) {
 	*t0 = t1;
 	res = 0;
     } else {
 	/* .tv_sec and .tv_usec are unsigned, be careful when subtracting */
-	if (t0->tv_usec > t1.tv_usec) {
-	    t1.tv_usec += 1000000;	/* Convert 1s in 1e6 microsecs */
+	if (t0->sub_secs > t1.sub_secs) {
+	    t1.sub_secs += TimeScale;
 	    t1.tv_sec--;
 	}
-	res = (t1.tv_sec - t0->tv_sec) * 1000
-	    + (t1.tv_usec - t0->tv_usec) / 1000;
+	res = (long) ((t1.tv_sec - t0->tv_sec) * 1000L
+		      + (t1.sub_secs - t0->sub_secs) / (TimeScale / 1000L));
     }
 #else
     time_t t1 = time((time_t *) 0);
@@ -355,7 +360,7 @@ _nc_timed_wait(SCREEN *sp MAYBE_UNUSED,
     if ((mode & TW_MOUSE)
 	&& (fd = sp->_mouse_fd) >= 0) {
 	FD_SET(fd, &set);
-	count = max(fd, count) + 1;
+	count = Max(fd, count) + 1;
     }
 #ifdef NCURSES_WGETCH_EVENTS
     if ((mode & TW_EVENT) && evl) {
@@ -365,7 +370,7 @@ _nc_timed_wait(SCREEN *sp MAYBE_UNUSED,
 	    if (ev->type == _NC_EVENT_FILE
 		&& (ev->data.fev.flags & _NC_EVENT_FILE_READABLE)) {
 		FD_SET(ev->data.fev.fd, &set);
-		count = max(ev->data.fev.fd + 1, count);
+		count = Max(ev->data.fev.fd + 1, count);
 	    }
 	}
     }
diff --git a/contrib/ncurses/ncurses/tty/lib_vidattr.c b/contrib/ncurses/ncurses/tty/lib_vidattr.c
index 15e7397d5dbb..2c7a0b27bd6d 100644
--- a/contrib/ncurses/ncurses/tty/lib_vidattr.c
+++ b/contrib/ncurses/ncurses/tty/lib_vidattr.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2020,2023 Thomas E. Dickey                                *
  * Copyright 1998-2014,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -70,7 +70,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_vidattr.c,v 1.78 2020/05/27 23:56:32 tom Exp $")
+MODULE_ID("$Id: lib_vidattr.c,v 1.79 2023/04/28 20:59:26 tom Exp $")
 
 #define doPut(mode) \
 	TPUTS_TRACE(#mode); \
@@ -249,6 +249,7 @@ NCURSES_SP_NAME(vidputs) (NCURSES_SP_DCLx
 		    TurnOff(A_ITALIC, exit_italics_mode);
 		}
 #endif
+		(void) turn_off;
 	    }
 	    PreviousAttr &= ALL_BUT_COLOR;
 	}
@@ -278,6 +279,7 @@ NCURSES_SP_NAME(vidputs) (NCURSES_SP_DCLx
 	    } else if (turn_off & A_ITALIC) {
 		TurnOff(A_ITALIC, exit_italics_mode);
 	    }
+	    (void) turn_off;
 	}
 #endif
 	SetColorsIf((pair != 0) || fix_pair0, PreviousAttr);
diff --git a/contrib/ncurses/ncurses/tty/tty_update.c b/contrib/ncurses/ncurses/tty/tty_update.c
index 20f9349bd688..0427024cb084 100644
--- a/contrib/ncurses/ncurses/tty/tty_update.c
+++ b/contrib/ncurses/ncurses/tty/tty_update.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2020,2021 Thomas E. Dickey                                *
+ * Copyright 2018-2023,2024 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -85,7 +85,7 @@
 
 #include <ctype.h>
 
-MODULE_ID("$Id: tty_update.c,v 1.310 2021/02/06 14:24:38 tom Exp $")
+MODULE_ID("$Id: tty_update.c,v 1.316 2024/02/04 00:09:34 tom Exp $")
 
 /*
  * This define controls the line-breakout optimization.  Every once in a
@@ -256,6 +256,7 @@ PutAttrChar(NCURSES_SP_DCLx CARG_CH_T ch)
 	 *    not checked.
 	 */
 	if (is8bits(CharOf(CHDEREF(ch)))
+	    && (!is7bits(CharOf(CHDEREF(ch))) && _nc_unicode_locale())
 	    && (isprint(CharOf(CHDEREF(ch)))
 		|| (SP_PARM->_legacy_coding > 0 && CharOf(CHDEREF(ch)) >= 160)
 		|| (SP_PARM->_legacy_coding > 1 && CharOf(CHDEREF(ch)) >= 128)
@@ -473,7 +474,7 @@ wrap_cursor(NCURSES_SP_DCL0)
 	 * An aggressive way to handle this would be to emit CR/LF after the
 	 * char and then assume the wrap is done, you're on the first position
 	 * of the next line, and the terminal out of its weird state.  Here
-	 * it's safe to just tell the code that the cursor is in hyperspace and
+	 * it is safe to just tell the code that the cursor is in hyperspace and
 	 * let the next mvcur() call straighten things out.
 	 */
 	SP_PARM->_curscol = -1;
@@ -757,14 +758,20 @@ TINFO_DOUPDATE(NCURSES_SP_DCL0)
      * We do not allow applications to assign new values in the reentrant
      * model.
      */
+#if NCURSES_SP_FUNCS
+    if (SP_PARM == CURRENT_SCREEN) {
+#endif
 #define SyncScreens(internal,exported) \
 	if (internal == 0) internal = exported; \
 	if (internal != exported) exported = internal
 
-    SyncScreens(CurScreen(SP_PARM), curscr);
-    SyncScreens(NewScreen(SP_PARM), newscr);
-    SyncScreens(StdScreen(SP_PARM), stdscr);
+	SyncScreens(CurScreen(SP_PARM), curscr);
+	SyncScreens(NewScreen(SP_PARM), newscr);
+	SyncScreens(StdScreen(SP_PARM), stdscr);
+#if NCURSES_SP_FUNCS
+    }
 #endif
+#endif /* !USE_REENTRANT */
 
     if (CurScreen(SP_PARM) == 0
 	|| NewScreen(SP_PARM) == 0
@@ -823,7 +830,7 @@ TINFO_DOUPDATE(NCURSES_SP_DCL0)
     /*
      * This is the support for magic-cookie terminals.  The theory:  we scan
      * the virtual screen looking for attribute turnons.  Where we find one,
-     * check to make sure it's realizable by seeing if the required number of
+     * check to make sure it is realizable by seeing if the required number of
      * un-attributed blanks are present before and after the attributed range;
      * try to shift the range boundaries over blanks (not changing the screen
      * display) so this becomes true.  If it is, shift the beginning attribute
@@ -885,7 +892,7 @@ TINFO_DOUPDATE(NCURSES_SP_DCL0)
 		    bool end_onscreen = FALSE;
 		    int m, n = j;
 
-		    /* find end of span, if it's onscreen */
+		    /* find end of span, if it is onscreen */
 		    for (m = i; m < screen_lines(SP_PARM); m++) {
 			for (; n < screen_columns(SP_PARM); n++) {
 			    attr_t testattr =
@@ -998,7 +1005,7 @@ TINFO_DOUPDATE(NCURSES_SP_DCL0)
 	if (check_pending(NCURSES_SP_ARG))
 	    goto cleanup;
 
-	nonempty = min(screen_lines(SP_PARM), NewScreen(SP_PARM)->_maxy + 1);
+	nonempty = Min(screen_lines(SP_PARM), NewScreen(SP_PARM)->_maxy + 1);
 
 	if (SP_PARM->_scrolling) {
 	    NCURSES_SP_NAME(_nc_scroll_optimize) (NCURSES_SP_ARG);
@@ -1128,7 +1135,7 @@ ClrUpdate(NCURSES_SP_DCL0)
     if (0 != SP_PARM) {
 	int i;
 	NCURSES_CH_T blank = ClrBlank(NCURSES_SP_ARGx StdScreen(SP_PARM));
-	int nonempty = min(screen_lines(SP_PARM),
+	int nonempty = Min(screen_lines(SP_PARM),
 			   NewScreen(SP_PARM)->_maxy + 1);
 
 	ClearScreen(NCURSES_SP_ARGx blank);
@@ -1227,7 +1234,7 @@ static int
 ClrBottom(NCURSES_SP_DCLx int total)
 {
     int top = total;
-    int last = min(screen_columns(SP_PARM), NewScreen(SP_PARM)->_maxx + 1);
+    int last = Min(screen_columns(SP_PARM), NewScreen(SP_PARM)->_maxx + 1);
     NCURSES_CH_T blank = NewScreen(SP_PARM)->_line[total - 1].text[last - 1];
 
     if (clr_eos && can_clear_with(NCURSES_SP_ARGx CHREF(blank))) {
@@ -1287,7 +1294,7 @@ ClrBottom(NCURSES_SP_DCLx int total)
 **		nLastChar = position of last different character in new line
 **
 **		move to firstChar
-**		overwrite chars up to min(oLastChar, nLastChar)
+**		overwrite chars up to Min(oLastChar, nLastChar)
 **		if oLastChar < nLastChar
 **			insert newLine[oLastChar+1..nLastChar]
 **		else
@@ -1325,8 +1332,8 @@ TransformLine(NCURSES_SP_DCLx int const lineno)
 		newPair = GetPair(newLine[n]);
 		if (oldPair != newPair
 		    && unColor(oldLine[n]) == unColor(newLine[n])) {
-		    if (oldPair < SP_PARM->_pair_limit
-			&& newPair < SP_PARM->_pair_limit
+		    if (oldPair < SP_PARM->_pair_alloc
+			&& newPair < SP_PARM->_pair_alloc
 			&& (isSamePair(SP_PARM->_color_pairs[oldPair],
 				       SP_PARM->_color_pairs[newPair]))) {
 			SetPair(oldLine[n], GetPair(newLine[n]));
@@ -1525,7 +1532,7 @@ TransformLine(NCURSES_SP_DCLx int const lineno)
 		}
 		ClrToEOL(NCURSES_SP_ARGx blank, FALSE);
 	    } else {
-		n = max(nLastChar, oLastChar);
+		n = Max(nLastChar, oLastChar);
 		PutRange(NCURSES_SP_ARGx
 			 oldLine,
 			 newLine,
@@ -1550,7 +1557,7 @@ TransformLine(NCURSES_SP_DCLx int const lineno)
 		    break;
 	    }
 
-	    n = min(oLastChar, nLastChar);
+	    n = Min(oLastChar, nLastChar);
 	    if (n >= firstChar) {
 		GoTo(NCURSES_SP_ARGx lineno, firstChar);
 		PutRange(NCURSES_SP_ARGx
@@ -1562,7 +1569,7 @@ TransformLine(NCURSES_SP_DCLx int const lineno)
 	    }
 
 	    if (oLastChar < nLastChar) {
-		int m = max(nLastNonblank, oLastNonblank);
+		int m = Max(nLastNonblank, oLastNonblank);
 #if USE_WIDEC_SUPPORT
 		if (n) {
 		    while (isWidecExt(newLine[n + 1]) && n) {
diff --git a/contrib/ncurses/ncurses/wcwidth.h b/contrib/ncurses/ncurses/wcwidth.h
index ccae41a9b994..76673da65845 100644
--- a/contrib/ncurses/ncurses/wcwidth.h
+++ b/contrib/ncurses/ncurses/wcwidth.h
@@ -59,6 +59,16 @@
  * Latest version: http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
  */
 
+#ifndef _WCWIDTH_H_incl
+#define _WCWIDTH_H_incl 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <ncurses_cfg.h>
+#include <ncurses_dll.h>
+
 #include <wchar.h>
 
 struct interval {
@@ -187,7 +197,7 @@ NCURSES_EXPORT(int) mk_wcwidth(wchar_t ucs)
 
   /* if we arrive here, ucs is not a combining or C0/C1 control character */
 
-  return 1 + 
+  return 1 +
     (ucs >= 0x1100 &&
      (ucs <= 0x115f ||                    /* Hangul Jamo init. consonants */
       ucs == 0x2329 || ucs == 0x232a ||
@@ -310,3 +320,9 @@ NCURSES_EXPORT(int) mk_wcswidth_cjk(const wchar_t *pwcs, size_t n)
 
   return width;
 }
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _WCWIDTH_H_incl 1 */
diff --git a/contrib/ncurses/ncurses/widechar/lib_add_wch.c b/contrib/ncurses/ncurses/widechar/lib_add_wch.c
index 5d6d5547f2f4..be1bbb051ad3 100644
--- a/contrib/ncurses/ncurses/widechar/lib_add_wch.c
+++ b/contrib/ncurses/ncurses/widechar/lib_add_wch.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 2019-2021,2023 Thomas E. Dickey                                *
  * Copyright 2004-2011,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -40,7 +40,7 @@
 #include <wctype.h>
 #endif
 
-MODULE_ID("$Id: lib_add_wch.c,v 1.16 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_add_wch.c,v 1.18 2023/07/15 17:34:12 tom Exp $")
 
 /* clone/adapt lib_addch.c */
 static const cchar_t blankchar = NewChar(BLANK_TEXT);
@@ -133,7 +133,7 @@ newline_forces_scroll(WINDOW *win, NCURSES_SIZE_T *ypos)
  * wrapped the cursor.  We don't do anything with this flag except set it when
  * wrapping, and clear it whenever we move the cursor.  If we try to wrap at
  * the lower-right corner of a window, we cannot move the cursor (since that
- * wouldn't be legal).  So we return an error (which is what SVr4 does). 
+ * wouldn't be legal).  So we return an error (which is what SVr4 does).
  * Unlike SVr4, we can successfully add a character to the lower-right corner
  * (Solaris 2.6 does this also, however).
  */
@@ -204,10 +204,16 @@ wadd_wch_literal(WINDOW *win, cchar_t ch)
 	if (len == 0) {		/* non-spacing */
 	    if ((x > 0 && y >= 0)
 		|| (win->_maxx >= 0 && win->_cury >= 1)) {
-		if (x > 0 && y >= 0)
-		    chars = (win->_line[y].text[x - 1].chars);
-		else
+		if (x > 0 && y >= 0) {
+		    for (j = x - 1; j > 0; --j) {
+			if (!isWidecExt(win->_line[y].text[j])) {
+			    break;
+			}
+		    }
+		    chars = (win->_line[y].text[j].chars);
+		} else {
 		    chars = (win->_line[y - 1].text[win->_maxx].chars);
+		}
 		for (i = 0; i < CCHARW_MAX; ++i) {
 		    if (chars[i] == 0) {
 			TR(TRACE_VIRTPUT,
diff --git a/contrib/ncurses/ncurses/widechar/lib_cchar.c b/contrib/ncurses/ncurses/widechar/lib_cchar.c
index 62a1113ecaa6..451c5dcb518b 100644
--- a/contrib/ncurses/ncurses/widechar/lib_cchar.c
+++ b/contrib/ncurses/ncurses/widechar/lib_cchar.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2019-2020,2021 Thomas E. Dickey                                *
+ * Copyright 2019-2021,2022 Thomas E. Dickey                                *
  * Copyright 2001-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -37,9 +37,9 @@
 #include <curses.priv.h>
 #include <wchar.h>
 
-MODULE_ID("$Id: lib_cchar.c,v 1.35 2021/01/17 00:04:08 tom Exp $")
+MODULE_ID("$Id: lib_cchar.c,v 1.38 2022/07/27 08:03:16 tom Exp $")
 
-/* 
+/*
  * The SuSv2 description leaves some room for interpretation.  We'll assume wch
  * points to a string which is L'\0' terminated, contains at least one
  * character with strictly positive width, which must be the first, and
@@ -105,7 +105,6 @@ getcchar(const cchar_t *wcval,
 	 void *opts)
 {
     int code = ERR;
-    int color_pair;
 
     TR(TRACE_CCALLS, (T_CALLED("getcchar(%p,%p,%p,%p,%p)"),
 		      (const void *) wcval,
@@ -123,10 +122,13 @@ getcchar(const cchar_t *wcval,
 	wchar_t *wp;
 	int len;
 
+#if HAVE_WMEMCHR
 	len = ((wp = wmemchr(wcval->chars, L'\0', (size_t) CCHARW_MAX))
 	       ? (int) (wp - wcval->chars)
 	       : CCHARW_MAX);
-
+#else
+	len = wcsnlen(wcval->chars, CCHARW_MAX);
+#endif
 	if (wch == NULL) {
 	    /*
 	     * If the value is a null, set the length to 1.
@@ -136,6 +138,8 @@ getcchar(const cchar_t *wcval,
 	} else if (attrs == 0 || pair_arg == 0) {
 	    code = ERR;
 	} else if (len >= 0) {
+	    int color_pair;
+
 	    TR(TRACE_CCALLS, ("copy %d wchars, first is %s", len,
 			      _tracecchar_t(wcval)));
 	    *attrs = AttrOf(*wcval) & A_ATTRIBUTES;
diff --git a/contrib/ncurses/ncurses/widechar/lib_erasewchar.c b/contrib/ncurses/ncurses/widechar/lib_erasewchar.c
index f49d6413bd02..197f80b59b79 100644
--- a/contrib/ncurses/ncurses/widechar/lib_erasewchar.c
+++ b/contrib/ncurses/ncurses/widechar/lib_erasewchar.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 2002-2010,2014 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -33,46 +33,64 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_erasewchar.c,v 1.4 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_erasewchar.c,v 1.5 2021/05/22 23:51:14 tom Exp $")
 
 /*
  *	erasewchar()
  *
  *	Return erase character as given in cur_term->Ottyb.
- *
  */
 
 NCURSES_EXPORT(int)
-erasewchar(wchar_t *wch)
+NCURSES_SP_NAME(erasewchar) (NCURSES_SP_DCLx wchar_t *wch);
+NCURSES_EXPORT(int)
+NCURSES_SP_NAME(erasewchar) (NCURSES_SP_DCLx wchar_t *wch)
 {
     int value;
     int result = ERR;
 
     T((T_CALLED("erasewchar()")));
-    if ((value = erasechar()) != ERR) {
+    if ((value = NCURSES_SP_NAME(erasechar) (NCURSES_SP_ARG)) != ERR) {
 	*wch = (wchar_t) value;
 	result = OK;
     }
     returnCode(result);
 }
 
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(int)
+erasewchar(wchar_t *wch)
+{
+    return NCURSES_SP_NAME(erasewchar) (CURRENT_SCREEN, wch);
+}
+#endif
+
 /*
  *	killwchar()
  *
  *	Return kill character as given in cur_term->Ottyb.
- *
  */
 
 NCURSES_EXPORT(int)
-killwchar(wchar_t *wch)
+NCURSES_SP_NAME(killwchar) (NCURSES_SP_DCLx wchar_t *wch);
+NCURSES_EXPORT(int)
+NCURSES_SP_NAME(killwchar) (NCURSES_SP_DCLx wchar_t *wch)
 {
     int value;
     int result = ERR;
 
     T((T_CALLED("killwchar()")));
-    if ((value = killchar()) != ERR) {
+    if ((value = NCURSES_SP_NAME(killchar) (NCURSES_SP_ARG)) != ERR) {
 	*wch = (wchar_t) value;
 	result = OK;
     }
     returnCode(result);
 }
+
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(int)
+killwchar(wchar_t *wch)
+{
+    return NCURSES_SP_NAME(killwchar) (CURRENT_SCREEN, wch);
+}
+#endif
diff --git a/contrib/ncurses/ncurses/widechar/lib_get_wch.c b/contrib/ncurses/ncurses/widechar/lib_get_wch.c
index 2bd49187aa12..9f10d3bcf121 100644
--- a/contrib/ncurses/ncurses/widechar/lib_get_wch.c
+++ b/contrib/ncurses/ncurses/widechar/lib_get_wch.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 2002-2011,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -41,7 +41,7 @@
 #include <curses.priv.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_get_wch.c,v 1.25 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_get_wch.c,v 1.26 2021/04/17 16:12:54 tom Exp $")
 
 NCURSES_EXPORT(int)
 wget_wch(WINDOW *win, wint_t *result)
@@ -49,7 +49,6 @@ wget_wch(WINDOW *win, wint_t *result)
     SCREEN *sp;
     int code;
     int value = 0;
-    wchar_t wch;
 #ifndef state_unused
     mbstate_t state;
 #endif
@@ -98,6 +97,7 @@ wget_wch(WINDOW *win, wint_t *result)
 		reset_mbytes(state);
 		status = count_mbytes(buffer, count, state);
 		if (status >= 0) {
+		    wchar_t wch;
 		    reset_mbytes(state);
 		    if (check_mbytes(wch, buffer, count, state) != status) {
 			code = ERR;	/* the two calls should match */
diff --git a/contrib/ncurses/ncurses/widechar/lib_get_wstr.c b/contrib/ncurses/ncurses/widechar/lib_get_wstr.c
index 695b5263946a..3b3bd522c2d8 100644
--- a/contrib/ncurses/ncurses/widechar/lib_get_wstr.c
+++ b/contrib/ncurses/ncurses/widechar/lib_get_wstr.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2018-2021,2023 Thomas E. Dickey                                *
  * Copyright 2002-2009,2011 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -40,7 +40,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_get_wstr.c,v 1.16 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_get_wstr.c,v 1.21 2023/04/29 19:02:03 tom Exp $")
 
 static int
 wadd_wint(WINDOW *win, wint_t *src)
@@ -88,9 +88,9 @@ wgetn_wstr(WINDOW *win, wint_t *str, int maxlen)
 {
     SCREEN *sp = _nc_screen_of(win);
     TTY buf;
-    bool oldnl, oldecho, oldraw, oldcbreak;
-    wint_t erasec;
-    wint_t killc;
+    TTY_FLAGS save_flags;
+    wchar_t erasec = 0;
+    wchar_t killc = 0;
     wint_t *oldstr = str;
     wint_t *tmpstr = str;
     wint_t ch;
@@ -105,17 +105,14 @@ wgetn_wstr(WINDOW *win, wint_t *str, int maxlen)
 
     _nc_get_tty_mode(&buf);
 
-    oldnl = sp->_nl;
-    oldecho = sp->_echo;
-    oldraw = sp->_raw;
-    oldcbreak = sp->_cbreak;
-    nl();
-    noecho();
-    noraw();
-    cbreak();
+    save_flags = sp->_tty_flags;
+    NCURSES_SP_NAME(nl) (NCURSES_SP_ARG);
+    NCURSES_SP_NAME(noecho) (NCURSES_SP_ARG);
+    if (!save_flags._raw)
+	NCURSES_SP_NAME(cbreak) (NCURSES_SP_ARG);
 
-    erasec = (wint_t) erasechar();
-    killc = (wint_t) killchar();
+    NCURSES_SP_NAME(erasewchar) (NCURSES_SP_ARGx &erasec);
+    NCURSES_SP_NAME(killwchar) (NCURSES_SP_ARGx &killc);
 
     getyx(win, y, x);
 
@@ -132,12 +129,12 @@ wgetn_wstr(WINDOW *win, wint_t *str, int maxlen)
 	    code = KEY_CODE_YES;
 	    ch = KEY_ENTER;
 	}
-	if (ch < KEY_MIN) {
-	    if (ch == erasec) {
+	if (ch != 0 && ch < KEY_MIN) {
+	    if (ch == (wint_t) erasec) {
 		ch = KEY_BACKSPACE;
 		code = KEY_CODE_YES;
 	    }
-	    if (ch == killc) {
+	    if (ch == (wint_t) killc) {
 		ch = KEY_EOL;
 		code = KEY_CODE_YES;
 	    }
@@ -145,12 +142,12 @@ wgetn_wstr(WINDOW *win, wint_t *str, int maxlen)
 	if (code == KEY_CODE_YES) {
 	    /*
 	     * Some terminals (the Wyse-50 is the most common) generate a \n
-	     * from the down-arrow key.  With this logic, it's the user's
+	     * from the down-arrow key.  With this logic, it is the user's
 	     * choice whether to set kcud=\n for wget_wch(); terminating
 	     * *getn_wstr() with \n should work either way.
 	     */
 	    if (ch == KEY_DOWN || ch == KEY_ENTER) {
-		if (oldecho == TRUE
+		if (save_flags._echo == TRUE
 		    && win->_cury == win->_maxy
 		    && win->_scroll)
 		    wechochar(win, (chtype) '\n');
@@ -158,11 +155,11 @@ wgetn_wstr(WINDOW *win, wint_t *str, int maxlen)
 	    }
 	    if (ch == KEY_LEFT || ch == KEY_BACKSPACE) {
 		if (tmpstr > oldstr) {
-		    tmpstr = WipeOut(win, y, x, oldstr, tmpstr, oldecho);
+		    tmpstr = WipeOut(win, y, x, oldstr, tmpstr, save_flags._echo);
 		}
 	    } else if (ch == KEY_EOL) {
 		while (tmpstr > oldstr) {
-		    tmpstr = WipeOut(win, y, x, oldstr, tmpstr, oldecho);
+		    tmpstr = WipeOut(win, y, x, oldstr, tmpstr, save_flags._echo);
 		}
 	    } else {
 		beep();
@@ -172,7 +169,7 @@ wgetn_wstr(WINDOW *win, wint_t *str, int maxlen)
 	} else {
 	    *tmpstr++ = ch;
 	    *tmpstr = 0;
-	    if (oldecho == TRUE) {
+	    if (save_flags._echo == TRUE) {
 		int oldy = win->_cury;
 
 		if (wadd_wint(win, tmpstr - 1) == ERR) {
@@ -182,9 +179,9 @@ wgetn_wstr(WINDOW *win, wint_t *str, int maxlen)
 		     */
 		    win->_flags &= ~_WRAPPED;
 		    waddch(win, (chtype) ' ');
-		    tmpstr = WipeOut(win, y, x, oldstr, tmpstr, oldecho);
+		    tmpstr = WipeOut(win, y, x, oldstr, tmpstr, save_flags._echo);
 		    continue;
-		} else if (win->_flags & _WRAPPED) {
+		} else if (IS_WRAPPED(win)) {
 		    /*
 		     * If the last waddch forced a wrap & scroll, adjust our
 		     * reference point for erasures.
@@ -212,11 +209,7 @@ wgetn_wstr(WINDOW *win, wint_t *str, int maxlen)
     /* Restore with a single I/O call, to fix minor asymmetry between
      * raw/noraw, etc.
      */
-    sp->_nl = oldnl;
-    sp->_echo = oldecho;
-    sp->_raw = oldraw;
-    sp->_cbreak = oldcbreak;
-
+    sp->_tty_flags = save_flags;
     (void) _nc_set_tty_mode(&buf);
 
     *tmpstr = 0;
diff --git a/contrib/ncurses/ncurses/widechar/lib_ins_wch.c b/contrib/ncurses/ncurses/widechar/lib_ins_wch.c
index f75361081b62..ecaabcc9b73e 100644
--- a/contrib/ncurses/ncurses/widechar/lib_ins_wch.c
+++ b/contrib/ncurses/ncurses/widechar/lib_ins_wch.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 2019-2020,2023 Thomas E. Dickey                                *
  * Copyright 2002-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -40,7 +40,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_ins_wch.c,v 1.25 2020/12/05 20:04:59 tom Exp $")
+MODULE_ID("$Id: lib_ins_wch.c,v 1.29 2023/11/21 21:53:28 tom Exp $")
 
 /*
  * Insert the given character, updating the current location to simplify
@@ -109,9 +109,12 @@ wins_nwstr(WINDOW *win, const wchar_t *wstr, int n)
        (void *) win, _nc_viswbufn(wstr, n), n));
 
     if (win != 0
-	&& wstr != 0) {
-	if (n < 1)
+	&& wstr != 0
+	&& n != 0) {
+
+	if (n < 0) {
 	    n = INT_MAX;
+	}
 	code = OK;
 
 	if (n > 0) {
@@ -120,7 +123,7 @@ wins_nwstr(WINDOW *win, const wchar_t *wstr, int n)
 	    NCURSES_SIZE_T oy = win->_cury;
 	    NCURSES_SIZE_T ox = win->_curx;
 
-	    for (cp = wstr; (*cp != L'\0') && ((cp - wstr) < n); cp++) {
+	    for (cp = wstr; ((cp - wstr) < n) && (*cp != L'\0'); cp++) {
 		int len = _nc_wacs_width(*cp);
 
 		if ((len >= 0 && len != 1) || !is7bits(*cp)) {
diff --git a/contrib/ncurses/ncurses/widechar/lib_key_name.c b/contrib/ncurses/ncurses/widechar/lib_key_name.c
index 8acfe7a2f498..379bdc2d48dd 100644
--- a/contrib/ncurses/ncurses/widechar/lib_key_name.c
+++ b/contrib/ncurses/ncurses/widechar/lib_key_name.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
  * Copyright 2007-2008,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -36,7 +36,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_key_name.c,v 1.5 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_key_name.c,v 1.6 2023/06/03 12:15:34 tom Exp $")
 
 #define MyData _nc_globals.key_name
 
@@ -46,17 +46,22 @@ key_name(wchar_t c)
     cchar_t my_cchar;
     wchar_t *my_wchars;
     size_t len;
+    NCURSES_CONST char *result = NULL;
 
     memset(&my_cchar, 0, sizeof(my_cchar));
     my_cchar.chars[0] = c;
     my_cchar.chars[1] = L'\0';
 
     my_wchars = wunctrl(&my_cchar);
+    /*
+     * wunctrl() could return a wide character rather than just a "printable"
+     * representation.  Check for that and return a corresponding multibyte
+     * character string.
+     */
     len = wcstombs(MyData, my_wchars, sizeof(MyData) - 1);
-    if (isEILSEQ(len) || (len == 0)) {
-	return 0;
+    if (!isEILSEQ(len) && (len != 0) && (len <= MB_LEN_MAX)) {
+	MyData[len] = '\0';
+	result = MyData;
     }
-
-    MyData[len] = '\0';
-    return MyData;
+    return result;
 }
diff --git a/contrib/ncurses/ncurses/widechar/lib_pecho_wchar.c b/contrib/ncurses/ncurses/widechar/lib_pecho_wchar.c
index 82b49b686b07..502967fd4e4d 100644
--- a/contrib/ncurses/ncurses/widechar/lib_pecho_wchar.c
+++ b/contrib/ncurses/ncurses/widechar/lib_pecho_wchar.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 2004,2009 Free Software Foundation, Inc.                       *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -33,7 +33,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_pecho_wchar.c,v 1.3 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_pecho_wchar.c,v 1.4 2021/10/23 17:07:56 tom Exp $")
 
 NCURSES_EXPORT(int)
 pecho_wchar(WINDOW *pad, const cchar_t *wch)
@@ -43,7 +43,7 @@ pecho_wchar(WINDOW *pad, const cchar_t *wch)
     if (pad == 0)
 	returnCode(ERR);
 
-    if (!(pad->_flags & _ISPAD))
+    if (!IS_PAD(pad))
 	returnCode(wecho_wchar(pad, wch));
 
     wadd_wch(pad, wch);
diff --git a/contrib/ncurses/ncurses/widechar/lib_unget_wch.c b/contrib/ncurses/ncurses/widechar/lib_unget_wch.c
index 4ea26b6034b5..1a81fecc8705 100644
--- a/contrib/ncurses/ncurses/widechar/lib_unget_wch.c
+++ b/contrib/ncurses/ncurses/widechar/lib_unget_wch.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
  * Copyright 2002-2011,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -40,7 +40,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_unget_wch.c,v 1.17 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_unget_wch.c,v 1.18 2023/06/03 12:50:52 tom Exp $")
 
 /*
  * Wrapper for wcrtomb() which obtains the length needed for the given
@@ -60,7 +60,7 @@ _nc_wcrtomb(char *target, wchar_t source, mbstate_t * state)
     } else {
 	result = (int) wcrtomb(target, source, state);
     }
-    if (!isEILSEQ(result) && (result == 0))
+    if (!isEILSEQ(result) && ((result == 0) || (result > MB_LEN_MAX)))
 	result = 1;
     return (size_t) result;
 }
diff --git a/contrib/ncurses/ncurses/widechar/lib_vid_attr.c b/contrib/ncurses/ncurses/widechar/lib_vid_attr.c
index 2d9531f1b864..f108b307d9a7 100644
--- a/contrib/ncurses/ncurses/widechar/lib_vid_attr.c
+++ b/contrib/ncurses/ncurses/widechar/lib_vid_attr.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2020,2023 Thomas E. Dickey                                *
  * Copyright 2002-2014,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -37,7 +37,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_vid_attr.c,v 1.30 2020/05/27 23:54:31 tom Exp $")
+MODULE_ID("$Id: lib_vid_attr.c,v 1.31 2023/04/28 20:59:34 tom Exp $")
 
 #define doPut(mode) \
 	TPUTS_TRACE(#mode); \
@@ -181,6 +181,7 @@ NCURSES_SP_NAME(vid_puts) (NCURSES_SP_DCLx
 		    TurnOff(A_ITALIC, exit_italics_mode);
 		}
 #endif
+		(void) turn_off;
 	    }
 	    previous_attr &= ALL_BUT_COLOR;
 	    previous_pair = 0;
@@ -212,6 +213,7 @@ NCURSES_SP_NAME(vid_puts) (NCURSES_SP_DCLx
 	    } else if (turn_off & A_ITALIC) {
 		TurnOff(A_ITALIC, exit_italics_mode);
 	    }
+	    (void) turn_off;
 	}
 #endif
 	SetColorsIf((color_pair != 0) || fix_pair0, previous_attr, previous_pair);
diff --git a/contrib/ncurses/ncurses/win32con/gettimeofday.c b/contrib/ncurses/ncurses/win32con/gettimeofday.c
index 94be7b563b95..603a6f462b78 100644
--- a/contrib/ncurses/ncurses/win32con/gettimeofday.c
+++ b/contrib/ncurses/ncurses/win32con/gettimeofday.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
  * Copyright 2008-2010,2014 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -36,8 +36,9 @@
 
 #include <windows.h>
 
-MODULE_ID("$Id: gettimeofday.c,v 1.6 2020/07/11 21:03:53 tom Exp $")
+MODULE_ID("$Id: gettimeofday.c,v 1.7 2023/02/25 20:05:36 tom Exp $")
 
+#if HAVE_GETTIMEOFDAY == 2
 #define JAN1970 116444736000000000LL	/* the value for 01/01/1970 00:00 */
 
 NCURSES_EXPORT(int)
@@ -53,3 +54,4 @@ gettimeofday(struct timeval *tv, void *tz GCC_UNUSED)
     tv->tv_sec = (long) ((data.since1601 - JAN1970) / 10000000LL);
     return (0);
 }
+#endif // HAVE_GETTIMEOFDAY == 2
diff --git a/contrib/ncurses/ncurses/win32con/win32_driver.c b/contrib/ncurses/ncurses/win32con/win32_driver.c
index 45aadf2f596a..0a43588b1714 100644
--- a/contrib/ncurses/ncurses/win32con/win32_driver.c
+++ b/contrib/ncurses/ncurses/win32con/win32_driver.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2018-2020,2023 Thomas E. Dickey                                *
  * Copyright 2008-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -48,7 +48,7 @@
 
 #define CUR TerminalType(my_term).
 
-MODULE_ID("$Id: win32_driver.c,v 1.2 2020/11/21 23:35:56 tom Exp $")
+MODULE_ID("$Id: win32_driver.c,v 1.4 2023/09/16 16:29:24 tom Exp $")
 
 #define WINMAGIC NCDRV_MAGIC(NCDRV_WINCONSOLE)
 #define EXP_OPTIMIZE 0
@@ -393,7 +393,7 @@ wcon_doupdate(TERMINAL_CONTROL_BLOCK * TCB)
 
 	Width = screen_columns(sp);
 	Height = screen_lines(sp);
-	nonempty = min(Height, NewScreen(sp)->_maxy + 1);
+	nonempty = Min(Height, NewScreen(sp)->_maxy + 1);
 
 	T(("... %dx%d clear cur:%d new:%d",
 	   Height, Width,
@@ -924,11 +924,14 @@ wcon_initmouse(TERMINAL_CONTROL_BLOCK * TCB)
 {
     SCREEN *sp;
 
+    T((T_CALLED("win32con::wcon_initmouse(%p)"), TCB));
+
     if (validateConsoleHandle()) {
 	SetSP();
 
 	sp->_mouse_type = M_TERM_DRIVER;
     }
+    returnVoid;
 }
 
 static int
@@ -939,6 +942,7 @@ wcon_testmouse(TERMINAL_CONTROL_BLOCK * TCB,
     int rc = 0;
     SCREEN *sp;
 
+    T((T_CALLED("win32con::wcon_testmouse(%p)"), TCB));
     if (validateConsoleHandle()) {
 	SetSP();
 
@@ -953,7 +957,7 @@ wcon_testmouse(TERMINAL_CONTROL_BLOCK * TCB,
 	}
     }
 
-    return rc;
+    returnCode(rc);
 }
 
 static int
diff --git a/contrib/ncurses/ncurses/win32con/win_driver.c b/contrib/ncurses/ncurses/win32con/win_driver.c
index 72a9cf53525f..2425b3a44ce6 100644
--- a/contrib/ncurses/ncurses/win32con/win_driver.c
+++ b/contrib/ncurses/ncurses/win32con/win_driver.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2018-2021,2023 Thomas E. Dickey                                *
  * Copyright 2008-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -55,7 +55,9 @@
 
 #define CUR TerminalType(my_term).
 
-MODULE_ID("$Id: win_driver.c,v 1.66 2020/03/01 00:18:49 tom Exp $")
+#define CONTROL_PRESSED (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)
+
+MODULE_ID("$Id: win_driver.c,v 1.74 2023/09/16 16:27:44 tom Exp $")
 
 #define TypeAlloca(type,count) (type*) _alloca(sizeof(type) * (size_t) (count))
 
@@ -82,39 +84,40 @@ static bool okConsoleHandle(TERMINAL_CONTROL_BLOCK *);
 #define write_screen WriteConsoleOutput
 #define read_screen  ReadConsoleOutput
 #endif
-
+/* *INDENT-OFF* */
 static const LONG keylist[] =
 {
-    GenMap(VK_PRIOR, KEY_PPAGE),
-    GenMap(VK_NEXT, KEY_NPAGE),
-    GenMap(VK_END, KEY_END),
-    GenMap(VK_HOME, KEY_HOME),
-    GenMap(VK_LEFT, KEY_LEFT),
-    GenMap(VK_UP, KEY_UP),
-    GenMap(VK_RIGHT, KEY_RIGHT),
-    GenMap(VK_DOWN, KEY_DOWN),
+    GenMap(VK_PRIOR,  KEY_PPAGE),
+    GenMap(VK_NEXT,   KEY_NPAGE),
+    GenMap(VK_END,    KEY_END),
+    GenMap(VK_HOME,   KEY_HOME),
+    GenMap(VK_LEFT,   KEY_LEFT),
+    GenMap(VK_UP,     KEY_UP),
+    GenMap(VK_RIGHT,  KEY_RIGHT),
+    GenMap(VK_DOWN,   KEY_DOWN),
     GenMap(VK_DELETE, KEY_DC),
     GenMap(VK_INSERT, KEY_IC)
 };
 static const LONG ansi_keys[] =
 {
-    GenMap(VK_PRIOR, 'I'),
-    GenMap(VK_NEXT, 'Q'),
-    GenMap(VK_END, 'O'),
-    GenMap(VK_HOME, 'H'),
-    GenMap(VK_LEFT, 'K'),
-    GenMap(VK_UP, 'H'),
-    GenMap(VK_RIGHT, 'M'),
-    GenMap(VK_DOWN, 'P'),
+    GenMap(VK_PRIOR,  'I'),
+    GenMap(VK_NEXT,   'Q'),
+    GenMap(VK_END,    'O'),
+    GenMap(VK_HOME,   'H'),
+    GenMap(VK_LEFT,   'K'),
+    GenMap(VK_UP,     'H'),
+    GenMap(VK_RIGHT,  'M'),
+    GenMap(VK_DOWN,   'P'),
     GenMap(VK_DELETE, 'S'),
     GenMap(VK_INSERT, 'R')
 };
+/* *INDENT-ON* */
 #define N_INI ((int)array_length(keylist))
 #define FKEYS 24
 #define MAPSIZE (FKEYS + N_INI)
 #define NUMPAIRS 64
 
-/*   A process can only have a single console, so it's safe
+/*   A process can only have a single console, so it is safe
      to maintain all the information about it in a single
      static structure.
  */
@@ -123,7 +126,6 @@ static struct {
     BOOL buffered;
     BOOL window_only;
     BOOL progMode;
-    BOOL isMinTTY;
     BOOL isTermInfoConsole;
     HANDLE out;
     HANDLE inp;
@@ -486,7 +488,7 @@ wcon_doupdate(TERMINAL_CONTROL_BLOCK * TCB)
 
 	Width = screen_columns(sp);
 	Height = screen_lines(sp);
-	nonempty = min(Height, NewScreen(sp)->_maxy + 1);
+	nonempty = Min(Height, NewScreen(sp)->_maxy + 1);
 
 	T(("... %dx%d clear cur:%d new:%d",
 	   Height, Width,
@@ -610,6 +612,12 @@ wcon_doupdate(TERMINAL_CONTROL_BLOCK * TCB)
     returnCode(result);
 }
 
+#ifdef __MING32__
+#define SysISATTY(fd) _isatty(fd)
+#else
+#define SysISATTY(fd) isatty(fd)
+#endif
+
 static bool
 wcon_CanHandle(TERMINAL_CONTROL_BLOCK * TCB,
 	       const char *tname,
@@ -641,6 +649,8 @@ wcon_CanHandle(TERMINAL_CONTROL_BLOCK * TCB,
 	}
     } else if (tname != 0 && stricmp(tname, "unknown") == 0) {
 	code = TRUE;
+    } else if (SysISATTY(TCB->term.Filedes)) {
+	code = TRUE;
     }
 
     /*
@@ -1476,10 +1486,10 @@ Adjust(int milliseconds, int diff)
 		     FROM_LEFT_4TH_BUTTON_PRESSED | \
 		     RIGHTMOST_BUTTON_PRESSED)
 
-static int
+static mmask_t
 decode_mouse(SCREEN *sp, int mask)
 {
-    int result = 0;
+    mmask_t result = 0;
 
     (void) sp;
     assert(sp && console_initialized);
@@ -1668,14 +1678,14 @@ handle_mouse(SCREEN *sp, MOUSE_EVENT_RECORD mer)
 
 	if (sp->_drv_mouse_new_buttons) {
 
-	    work.bstate |= (mmask_t) decode_mouse(sp, sp->_drv_mouse_new_buttons);
+	    work.bstate |= decode_mouse(sp, sp->_drv_mouse_new_buttons);
 
 	} else {
 
 	    /* cf: BUTTON_PRESSED, BUTTON_RELEASED */
-	    work.bstate |= (mmask_t) (decode_mouse(sp,
-						   sp->_drv_mouse_old_buttons)
-				      >> 1);
+	    work.bstate |= (decode_mouse(sp,
+					 sp->_drv_mouse_old_buttons)
+			    >> 1);
 
 	    result = TRUE;
 	}
@@ -1867,7 +1877,7 @@ get_handle(int fd)
 #if WINVER >= 0x0600
 /*   This function tests, whether or not the ncurses application
      is running as a descendant of MSYS2/cygwin mintty terminal
-     application. mintty doesn't use Windows Console for it's screen
+     application. mintty doesn't use Windows Console for its screen
      I/O, so the native Windows _isatty doesn't recognize it as
      character device. But we can discover we are at the end of an
      Pipe and can query to server side of the pipe, looking whether
@@ -1957,11 +1967,6 @@ _nc_mingw_isatty(int fd)
 {
     int result = 0;
 
-#ifdef __MING32__
-#define SysISATTY(fd) _isatty(fd)
-#else
-#define SysISATTY(fd) isatty(fd)
-#endif
     if (SysISATTY(fd)) {
 	result = 1;
     } else {
@@ -1974,7 +1979,7 @@ _nc_mingw_isatty(int fd)
 
 /*   This is used when running in terminfo mode to discover,
      whether or not the "terminal" is actually a Windows
-     Console. It's the responsibility of the console to deal
+     Console. It is the responsibility of the console to deal
      with the terminal escape sequences that are sent by
      terminfo.
  */
@@ -2126,9 +2131,9 @@ _nc_mingw_console_read(
 		*buf = (int) inp_rec.Event.KeyEvent.uChar.AsciiChar;
 		vk = inp_rec.Event.KeyEvent.wVirtualKeyCode;
 		/*
-		 * There are 24 virtual function-keys, and typically
-		 * 12 function-keys on a keyboard.  Use the shift-modifier
-		 * to provide the remaining 12 keys.
+		 * There are 24 virtual function-keys (defined in winuser.h),
+		 * and typically 12 function-keys on a keyboard.  Use the
+		 * shift-modifier to provide the remaining keys.
 		 */
 		if (vk >= VK_F1 && vk <= VK_F12) {
 		    if (inp_rec.Event.KeyEvent.dwControlKeyState & SHIFT_PRESSED) {
@@ -2145,6 +2150,11 @@ _nc_mingw_console_read(
 			ungetch('\0');
 			*buf = AnsiKey(vk);
 		    }
+		} else if (vk == VK_BACK) {
+		    if (!(inp_rec.Event.KeyEvent.dwControlKeyState
+			  & (SHIFT_PRESSED | CONTROL_PRESSED))) {
+			*buf = KEY_BACKSPACE;
+		    }
 		}
 		break;
 	    } else if (inp_rec.EventType == MOUSE_EVENT) {
@@ -2172,9 +2182,6 @@ InitConsole(void)
 	BOOL b;
 
 	START_TRACE();
-	if (_nc_mingw_isatty(0)) {
-	    CON.isMinTTY = TRUE;
-	}
 
 	for (i = 0; i < (N_INI + FKEYS); i++) {
 	    if (i < N_INI) {
@@ -2213,14 +2220,14 @@ InitConsole(void)
 	for (i = 0; i < NUMPAIRS; i++)
 	    CON.pairs[i] = a;
 
-	CON.inp = GetStdHandle(STD_INPUT_HANDLE);
-	CON.out = GetStdHandle(STD_OUTPUT_HANDLE);
-
 	b = AllocConsole();
 
 	if (!b)
 	    b = AttachConsole(ATTACH_PARENT_PROCESS);
 
+	CON.inp = GetDirectHandle("CONIN$", FILE_SHARE_READ);
+	CON.out = GetDirectHandle("CONOUT$", FILE_SHARE_WRITE);
+
 	if (getenv("NCGDB") || getenv("NCURSES_CONSOLE2")) {
 	    T(("... will not buffer console"));
 	    buffered = FALSE;
@@ -2228,7 +2235,7 @@ InitConsole(void)
 	} else {
 	    T(("... creating console buffer"));
 	    CON.hdl = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE,
-						0,
+						FILE_SHARE_READ | FILE_SHARE_WRITE,
 						NULL,
 						CONSOLE_TEXTMODE_BUFFER,
 						NULL);
diff --git a/contrib/ncurses/panel/Makefile.in b/contrib/ncurses/panel/Makefile.in
index cbd978809dcb..380f80cf2d59 100644
--- a/contrib/ncurses/panel/Makefile.in
+++ b/contrib/ncurses/panel/Makefile.in
@@ -1,6 +1,6 @@
-# $Id: Makefile.in,v 1.75 2020/08/29 14:50:45 tom Exp $
+# $Id: Makefile.in,v 1.76 2021/07/03 15:45:33 tom Exp $
 ##############################################################################
-# Copyright 2020 Thomas E. Dickey                                            #
+# Copyright 2020,2021 Thomas E. Dickey                                       #
 # Copyright 1998-2015,2018 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -136,6 +136,19 @@ AUTO_SRC	= \
 		../include/panel.h
 
 ################################################################################
+
+@MAKE_PHONY@.PHONY :	all
+@MAKE_PHONY@.PHONY :	clean
+@MAKE_PHONY@.PHONY :	distclean
+@MAKE_PHONY@.PHONY :	install
+@MAKE_PHONY@.PHONY :	install.libs
+@MAKE_PHONY@.PHONY :	libs
+@MAKE_PHONY@.PHONY :	mostlyclean
+@MAKE_PHONY@.PHONY :	realclean
+@MAKE_PHONY@.PHONY :	sources
+@MAKE_PHONY@.PHONY :	uninstall
+@MAKE_PHONY@.PHONY :	uninstall.libs
+
 all \
 libs \
 install ::	$(AUTO_SRC) $(LIBRARIES)
diff --git a/contrib/ncurses/panel/llib-lpanel b/contrib/ncurses/panel/llib-lpanel
index 6f797f5d970f..afdea20c3db2 100644
--- a/contrib/ncurses/panel/llib-lpanel
+++ b/contrib/ncurses/panel/llib-lpanel
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2010,2015 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -43,20 +43,20 @@ PANEL	*_nc_retrace_panel(
 
 #undef _nc_my_visbuf
 const char *_nc_my_visbuf(
-		const void *ptr, 
+		const void *ptr,
 		int	n)
 		{ return(*(const char **)0); }
 
 #undef _nc_dPanel
 void	_nc_dPanel(
-		const char *text, 
+		const char *text,
 		const PANEL *pan)
 		{ /* void */ }
 
 #undef _nc_dStack
 void	_nc_dStack(
-		const char *fmt, 
-		int	num, 
+		const char *fmt,
+		int	num,
 		const PANEL *pan)
 		{ /* void */ }
 
@@ -72,8 +72,8 @@ void	_nc_Touchpan(
 
 #undef _nc_Touchline
 void	_nc_Touchline(
-		const PANEL *pan, 
-		int	start, 
+		const PANEL *pan,
+		int	start,
 		int	count)
 		{ /* void */ }
 
@@ -133,8 +133,8 @@ int	panel_hidden(
 
 #undef move_panel
 int	move_panel(
-		PANEL	*pan, 
-		int	starty, 
+		PANEL	*pan,
+		int	starty,
 		int	startx)
 		{ return(*(int *)0); }
 
@@ -149,7 +149,7 @@ PANEL	*new_panel(
 
 #undef replace_panel
 int	replace_panel(
-		PANEL	*pan, 
+		PANEL	*pan,
 		WINDOW	*win)
 		{ return(*(int *)0); }
 
@@ -182,7 +182,7 @@ void	update_panels(void)
 
 #undef set_panel_userptr
 int	set_panel_userptr(
-		PANEL	*pan, 
+		PANEL	*pan,
 		const void *uptr)
 		{ return(*(int *)0); }
 
diff --git a/contrib/ncurses/panel/llib-lpanelt b/contrib/ncurses/panel/llib-lpanelt
index 713a0753aa3c..0b996832e58d 100644
--- a/contrib/ncurses/panel/llib-lpanelt
+++ b/contrib/ncurses/panel/llib-lpanelt
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 2010,2015 Free Software Foundation, Inc.                       *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -43,20 +43,20 @@ PANEL	*_nc_retrace_panel(
 
 #undef _nc_my_visbuf
 const char *_nc_my_visbuf(
-		const void *ptr, 
+		const void *ptr,
 		int	n)
 		{ return(*(const char **)0); }
 
 #undef _nc_dPanel
 void	_nc_dPanel(
-		const char *text, 
+		const char *text,
 		const PANEL *pan)
 		{ /* void */ }
 
 #undef _nc_dStack
 void	_nc_dStack(
-		const char *fmt, 
-		int	num, 
+		const char *fmt,
+		int	num,
 		const PANEL *pan)
 		{ /* void */ }
 
@@ -72,8 +72,8 @@ void	_nc_Touchpan(
 
 #undef _nc_Touchline
 void	_nc_Touchline(
-		const PANEL *pan, 
-		int	start, 
+		const PANEL *pan,
+		int	start,
 		int	count)
 		{ /* void */ }
 
@@ -133,8 +133,8 @@ int	panel_hidden(
 
 #undef move_panel
 int	move_panel(
-		PANEL	*pan, 
-		int	starty, 
+		PANEL	*pan,
+		int	starty,
 		int	startx)
 		{ return(*(int *)0); }
 
@@ -149,7 +149,7 @@ PANEL	*new_panel(
 
 #undef replace_panel
 int	replace_panel(
-		PANEL	*pan, 
+		PANEL	*pan,
 		WINDOW	*win)
 		{ return(*(int *)0); }
 
@@ -182,7 +182,7 @@ void	update_panels(void)
 
 #undef set_panel_userptr
 int	set_panel_userptr(
-		PANEL	*pan, 
+		PANEL	*pan,
 		const void *uptr)
 		{ return(*(int *)0); }
 
diff --git a/contrib/ncurses/panel/llib-lpaneltw b/contrib/ncurses/panel/llib-lpaneltw
index 713a0753aa3c..0b996832e58d 100644
--- a/contrib/ncurses/panel/llib-lpaneltw
+++ b/contrib/ncurses/panel/llib-lpaneltw
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 2010,2015 Free Software Foundation, Inc.                       *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -43,20 +43,20 @@ PANEL	*_nc_retrace_panel(
 
 #undef _nc_my_visbuf
 const char *_nc_my_visbuf(
-		const void *ptr, 
+		const void *ptr,
 		int	n)
 		{ return(*(const char **)0); }
 
 #undef _nc_dPanel
 void	_nc_dPanel(
-		const char *text, 
+		const char *text,
 		const PANEL *pan)
 		{ /* void */ }
 
 #undef _nc_dStack
 void	_nc_dStack(
-		const char *fmt, 
-		int	num, 
+		const char *fmt,
+		int	num,
 		const PANEL *pan)
 		{ /* void */ }
 
@@ -72,8 +72,8 @@ void	_nc_Touchpan(
 
 #undef _nc_Touchline
 void	_nc_Touchline(
-		const PANEL *pan, 
-		int	start, 
+		const PANEL *pan,
+		int	start,
 		int	count)
 		{ /* void */ }
 
@@ -133,8 +133,8 @@ int	panel_hidden(
 
 #undef move_panel
 int	move_panel(
-		PANEL	*pan, 
-		int	starty, 
+		PANEL	*pan,
+		int	starty,
 		int	startx)
 		{ return(*(int *)0); }
 
@@ -149,7 +149,7 @@ PANEL	*new_panel(
 
 #undef replace_panel
 int	replace_panel(
-		PANEL	*pan, 
+		PANEL	*pan,
 		WINDOW	*win)
 		{ return(*(int *)0); }
 
@@ -182,7 +182,7 @@ void	update_panels(void)
 
 #undef set_panel_userptr
 int	set_panel_userptr(
-		PANEL	*pan, 
+		PANEL	*pan,
 		const void *uptr)
 		{ return(*(int *)0); }
 
diff --git a/contrib/ncurses/panel/llib-lpanelw b/contrib/ncurses/panel/llib-lpanelw
index bd6e90d2a2c2..7ed8b3c3bf3f 100644
--- a/contrib/ncurses/panel/llib-lpanelw
+++ b/contrib/ncurses/panel/llib-lpanelw
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 2002-2010,2015 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -43,20 +43,20 @@ PANEL	*_nc_retrace_panel(
 
 #undef _nc_my_visbuf
 const char *_nc_my_visbuf(
-		const void *ptr, 
+		const void *ptr,
 		int	n)
 		{ return(*(const char **)0); }
 
 #undef _nc_dPanel
 void	_nc_dPanel(
-		const char *text, 
+		const char *text,
 		const PANEL *pan)
 		{ /* void */ }
 
 #undef _nc_dStack
 void	_nc_dStack(
-		const char *fmt, 
-		int	num, 
+		const char *fmt,
+		int	num,
 		const PANEL *pan)
 		{ /* void */ }
 
@@ -72,8 +72,8 @@ void	_nc_Touchpan(
 
 #undef _nc_Touchline
 void	_nc_Touchline(
-		const PANEL *pan, 
-		int	start, 
+		const PANEL *pan,
+		int	start,
 		int	count)
 		{ /* void */ }
 
@@ -133,8 +133,8 @@ int	panel_hidden(
 
 #undef move_panel
 int	move_panel(
-		PANEL	*pan, 
-		int	starty, 
+		PANEL	*pan,
+		int	starty,
 		int	startx)
 		{ return(*(int *)0); }
 
@@ -149,7 +149,7 @@ PANEL	*new_panel(
 
 #undef replace_panel
 int	replace_panel(
-		PANEL	*pan, 
+		PANEL	*pan,
 		WINDOW	*win)
 		{ return(*(int *)0); }
 
@@ -182,7 +182,7 @@ void	update_panels(void)
 
 #undef set_panel_userptr
 int	set_panel_userptr(
-		PANEL	*pan, 
+		PANEL	*pan,
 		const void *uptr)
 		{ return(*(int *)0); }
 
diff --git a/contrib/ncurses/panel/p_bottom.c b/contrib/ncurses/panel/p_bottom.c
index 0e5b090aa694..3ca9c77eedab 100644
--- a/contrib/ncurses/panel/p_bottom.c
+++ b/contrib/ncurses/panel/p_bottom.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2008,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -34,11 +34,11 @@
  ****************************************************************************/
 
 /* p_bottom.c
- * Place a panel on bottom of the stack; may already be in the stack 
+ * Place a panel on bottom of the stack; may already be in the stack
  */
 #include "panel.priv.h"
 
-MODULE_ID("$Id: p_bottom.c,v 1.16 2020/09/26 18:02:35 tom Exp $")
+MODULE_ID("$Id: p_bottom.c,v 1.17 2021/06/17 21:20:30 tom Exp $")
 
 PANEL_EXPORT(int)
 bottom_panel(PANEL * pan)
diff --git a/contrib/ncurses/panel/p_new.c b/contrib/ncurses/panel/p_new.c
index a7c5a4e2db21..cf1164034f36 100644
--- a/contrib/ncurses/panel/p_new.c
+++ b/contrib/ncurses/panel/p_new.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2009,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -35,11 +35,11 @@
  ****************************************************************************/
 
 /* p_new.c
- * Creation of a new panel 
+ * Creation of a new panel
  */
 #include "panel.priv.h"
 
-MODULE_ID("$Id: p_new.c,v 1.22 2020/12/26 18:25:48 tom Exp $")
+MODULE_ID("$Id: p_new.c,v 1.24 2021/10/23 15:12:06 tom Exp $")
 
 #ifdef TRACE
 static char *stdscr_id;
@@ -117,7 +117,7 @@ new_panel(WINDOW *win)
     (void)root_panel(NCURSES_SP_ARG);
   assert(_nc_stdscr_pseudo_panel);
 
-  if (!(win->_flags & _ISPAD) && (pan = AllocPanel("new_panel")))
+  if ((pan = AllocPanel("new_panel")) != NULL)
     {
       pan->win = win;
       pan->above = (PANEL *)0;
diff --git a/contrib/ncurses/panel/p_show.c b/contrib/ncurses/panel/p_show.c
index 0c973dbeaf66..3503bec1909e 100644
--- a/contrib/ncurses/panel/p_show.c
+++ b/contrib/ncurses/panel/p_show.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2009,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -33,11 +33,11 @@
  ****************************************************************************/
 
 /* p_show.c
- * Place a panel on top of the stack; may already be in the stack 
+ * Place a panel on top of the stack; may already be in the stack
  */
 #include "panel.priv.h"
 
-MODULE_ID("$Id: p_show.c,v 1.16 2020/09/26 18:02:35 tom Exp $")
+MODULE_ID("$Id: p_show.c,v 1.17 2021/06/17 21:20:30 tom Exp $")
 
 PANEL_EXPORT(int)
 show_panel(PANEL * pan)
diff --git a/contrib/ncurses/panel/p_user.c b/contrib/ncurses/panel/p_user.c
index 9eec8ba11672..8d650979f845 100644
--- a/contrib/ncurses/panel/p_user.c
+++ b/contrib/ncurses/panel/p_user.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2005,2010 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -33,11 +33,11 @@
  ****************************************************************************/
 
 /* p_user.c
- * Set/Get panels user pointer 
+ * Set/Get panels user pointer
  */
 #include "panel.priv.h"
 
-MODULE_ID("$Id: p_user.c,v 1.10 2020/05/24 01:40:20 anonymous.maarten Exp $")
+MODULE_ID("$Id: p_user.c,v 1.11 2021/06/17 21:20:30 tom Exp $")
 
 PANEL_EXPORT(int)
 set_panel_userptr(PANEL * pan, NCURSES_CONST void *uptr)
diff --git a/contrib/ncurses/progs/MKtermsort.sh b/contrib/ncurses/progs/MKtermsort.sh
index 7206bc1a9288..4e58c50a03a2 100755
--- a/contrib/ncurses/progs/MKtermsort.sh
+++ b/contrib/ncurses/progs/MKtermsort.sh
@@ -1,10 +1,10 @@
 #!/bin/sh
-# $Id: MKtermsort.sh,v 1.13 2020/02/02 23:34:34 tom Exp $
+# $Id: MKtermsort.sh,v 1.17 2022/02/05 20:39:41 tom Exp $
 #
 # MKtermsort.sh -- generate indirection vectors for the various sort methods
 #
 ##############################################################################
-# Copyright 2020 Thomas E. Dickey                                            #
+# Copyright 2020-2021,2022 Thomas E. Dickey                                  #
 # Copyright 1998-2015,2017 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -47,15 +47,26 @@ AWK=${1-awk}
 DATA=${2-../include/Caps}
 
 data=data$$
-trap 'rm -f $data' 1 2 3 15
-sed -e 's/[	][	]*/	/g' < $DATA >$data
+trap 'rm -f $data; exit 1' 1 2 3 15
+sed -e 's/[	][	]*/	/g' < "$DATA" >$data
 DATA=$data
 
-echo "/*";
-echo " * termsort.c --- sort order arrays for use by infocmp.";
-echo " *";
-echo " * Note: this file is generated using MKtermsort.sh, do not edit by hand.";
-echo " */";
+cat <<EOF
+/*
+ * termsort.h --- sort order arrays for use by infocmp.
+ *
+ * Note: this file is generated using MKtermsort.sh, do not edit by hand.
+ */
+#ifndef _TERMSORT_H
+#define _TERMSORT_H 1
+#include <curses.h>
+
+#ifndef DUMP_ENTRY_H
+typedef unsigned PredType;
+typedef unsigned PredIdx;
+#endif
+
+EOF
 
 echo "static const PredIdx bool_terminfo_sort[] = {";
 $AWK <$DATA '
@@ -165,7 +176,11 @@ $3 == "str" && substr($7, 1, 1) == "-"        {print "\tFALSE,\t/* ", $2, " */";
 $3 == "str" && substr($7, 1, 1) == "Y"        {print "\tTRUE,\t/* ", $2, " */"; valid = count++; }
 END { printf "#define OK_str_from_termcap %d\n", valid; }
 '
-echo "};";
-echo "";
+
+cat <<EOF
+};
+
+#endif /* _TERMSORT_H */
+EOF
 
 rm -f $data
diff --git a/contrib/ncurses/progs/Makefile.in b/contrib/ncurses/progs/Makefile.in
index 1511ec271210..218e64e0c426 100644
--- a/contrib/ncurses/progs/Makefile.in
+++ b/contrib/ncurses/progs/Makefile.in
@@ -1,6 +1,6 @@
-# $Id: Makefile.in,v 1.108 2021/01/23 20:42:08 tom Exp $
+# $Id: Makefile.in,v 1.115 2024/04/08 18:33:54 tom Exp $
 ##############################################################################
-# Copyright 2020,2021 Thomas E. Dickey                                       #
+# Copyright 2020-2021,2024 Thomas E. Dickey                                  #
 # Copyright 1998-2016,2018 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -93,7 +93,8 @@ CPP		= @CPP@
 CFLAGS		= @CFLAGS@ @EXTRA_CFLAGS@
 
 INCDIR		= $(top_srcdir)/include
-CPPFLAGS	= -DHAVE_CONFIG_H -I../progs @CPPFLAGS@
+NCUDIR		= $(top_srcdir)/ncurses
+CPPFLAGS	= -DHAVE_CONFIG_H -I../progs -I../ncurses -I$(top_srcdir)/ncurses @CPPFLAGS@
 
 CCFLAGS		= $(CPPFLAGS) $(CFLAGS)
 
@@ -133,7 +134,7 @@ LINT_OPTS	= @LINT_OPTS@
 LINT_LIBS	= -lncurses @LIBS@
 
 AUTO_SRC = \
-	termsort.c \
+	termsort.h \
 	transform.h
 
 # tic relies on direct access to the terminfo database
@@ -145,12 +146,43 @@ PROGS = $(PUT_PROGS) $(GET_PROGS)
 DEPS_CURSES = ../lib/@LIB_PREFIX@ncurses@DFT_DEP_SUFFIX@
 
 HEADER_DEPS	= \
-	../include/curses.h \
+	$(INCDIR)/nc_access.h \
+	$(INCDIR)/nc_alloc.h \
+	$(INCDIR)/nc_panel.h \
+	$(INCDIR)/nc_string.h \
+	$(INCDIR)/nc_termios.h \
+	$(INCDIR)/nc_tparm.h \
 	$(INCDIR)/term_entry.h \
 	$(INCDIR)/tic.h \
-	$(INCDIR)/nc_alloc.h
+	$(NCUDIR)/curses.priv.h \
+	$(NCUDIR)/new_pair.h \
+	$(NCUDIR)/term.priv.h \
+	$(srcdir)/progs.priv.h \
+	../include/curses.h \
+	../include/ncurses_cfg.h \
+	../include/ncurses_def.h \
+	../include/ncurses_dll.h \
+	../include/term.h \
+	../include/unctrl.h
 
 ################################################################################
+
+@MAKE_PHONY@.PHONY :	all
+@MAKE_PHONY@.PHONY :	check
+@MAKE_PHONY@.PHONY :	clean
+@MAKE_PHONY@.PHONY :	distclean
+@MAKE_PHONY@.PHONY :	install
+@MAKE_PHONY@.PHONY :	install.libs
+@MAKE_PHONY@.PHONY :	install.progs
+@MAKE_PHONY@.PHONY :	libs
+@MAKE_PHONY@.PHONY :	lint
+@MAKE_PHONY@.PHONY :	mostlyclean
+@MAKE_PHONY@.PHONY :	realclean
+@MAKE_PHONY@.PHONY :	sources
+@MAKE_PHONY@.PHONY :	uninstall
+@MAKE_PHONY@.PHONY :	uninstall.libs
+@MAKE_PHONY@.PHONY :	uninstall.progs
+
 all:		$(AUTO_SRC) $(PROGS)
 
 sources:	$(AUTO_SRC)
@@ -292,7 +324,7 @@ DEPS_TSET = \
 tset$x: $(DEPS_TSET) $(DEPS_CURSES) transform.h
 	@ECHO_LD@ $(LINK) $(DEPS_TSET) $(LDFLAGS_TINFO) -o $@
 
-termsort.c: $(srcdir)/MKtermsort.sh
+termsort.h: $(srcdir)/MKtermsort.sh
 	$(SHELL) $(srcdir)/MKtermsort.sh $(AWK) $(srcdir)/../include/@TERMINFO_CAPS@ >$@
 
 #
@@ -329,12 +361,23 @@ $(DEPS_CURSES) :
 
 lint:
 @MAKE_TERMINFO@	$(LINT) $(LINT_OPTS) $(CPPFLAGS) $(srcdir)/tic.c     $(srcdir)/dump_entry.c $(LINT_LIBS)
-@MAKE_TERMINFO@	$(LINT) $(LINT_OPTS) $(CPPFLAGS) $(srcdir)/toe.c     $(srcdir)/dump_entry.c $(LINT_LIBS)
+@MAKE_TERMINFO@	$(LINT) $(LINT_OPTS) $(CPPFLAGS) $(srcdir)/toe.c                    $(LINT_LIBS)
 	$(LINT) $(LINT_OPTS) $(CPPFLAGS) $(srcdir)/clear.c                          $(LINT_LIBS)
 	$(LINT) $(LINT_OPTS) $(CPPFLAGS) $(srcdir)/infocmp.c $(srcdir)/dump_entry.c $(LINT_LIBS)
 	$(LINT) $(LINT_OPTS) $(CPPFLAGS) $(srcdir)/tabs.c                           $(LINT_LIBS)
 	$(LINT) $(LINT_OPTS) $(CPPFLAGS) $(srcdir)/tput.c                           $(LINT_LIBS)
-	$(LINT) $(LINT_OPTS) $(CPPFLAGS) $(srcdir)/tset.c    $(srcdir)/dump_entry.c $(LINT_LIBS)
+	$(LINT) $(LINT_OPTS) $(CPPFLAGS) $(srcdir)/tset.c                           $(LINT_LIBS)
+
+# Verify that each header-file can be compiled without including another.
+check:
+	@$(SHELL) -c "for header in *.h;\
+		do \
+			echo \"** testing \$${header}\" ; \
+			echo \"#include <\$${header}>\" >headers.c; \
+			echo \"int main(void) { return 0; }\" >>headers.c; \
+			$(CC) -c $(CFLAGS) $(CPPFLAGS) headers.c; \
+		done"
+	-@rm -f headers.*
 
 ###############################################################################
 # The remainder of this file is automatically generated during configuration
diff --git a/contrib/ncurses/progs/capconvert b/contrib/ncurses/progs/capconvert
index bcd56d3dc42a..4b5b321a58ce 100755
--- a/contrib/ncurses/progs/capconvert
+++ b/contrib/ncurses/progs/capconvert
@@ -1,6 +1,6 @@
 #!/bin/sh
 ##############################################################################
-# Copyright 2019,2020 Thomas E. Dickey                                       #
+# Copyright 2019-2021,2022 Thomas E. Dickey                                  #
 # Copyright 1998-2011,2017 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -27,7 +27,7 @@
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
-# $Id: capconvert,v 1.9 2020/02/02 23:34:34 tom Exp $
+# $Id: capconvert,v 1.12 2022/07/16 21:00:27 tom Exp $
 #
 # capconvert -- automated conversion from termcap to terminfo
 #
@@ -47,7 +47,7 @@ then
 	echo "TERMINFO is already defined in your environment.  This means"
 	echo "you already have a local terminfo tree, so you do not need any"
 	echo "conversion."
-	if test ! -d $TERMINFO ; then
+	if test ! -d "$TERMINFO" ; then
 		echo "Caution: TERMINFO does not point to a directory!"
 	fi
 	exit;
@@ -62,7 +62,7 @@ for p in $TERMINFO \
 	/usr/local/lib/terminfo \
 	/usr/local/share/terminfo
 do
-	if test -d $p ; then
+	if test -d "$p" ; then
 		terminfo=yes
 		break
 	fi
@@ -95,7 +95,7 @@ else
 fi
 echo "";
 
-# Check if test -x works (it's not portable, but useful)
+# Check if test -x works (it is not portable, but useful)
 OPT="-x"
 TMP=test$$; touch $TMP && chmod 755 $TMP
 if test $OPT $TMP ; then
@@ -111,13 +111,13 @@ TIC=
 IFS="${IFS= 	}"; save_ifs="$IFS"; IFS="${IFS}:"
 for x in $PATH .
 do
-	if test $OPT $x/tic
+	if test "$OPT" "$x"/tic
 	then
 		TIC=$x/tic
 		break
 	fi
 done
-IFS="$ac_save_ifs"
+IFS="$save_ifs"
 
 if test -n "$TIC"
 then
@@ -140,7 +140,7 @@ echo "";
 #
 
 # Make the user a terminfo directory
-if test -d $HOME/.terminfo
+if test -d "$HOME"/.terminfo
 then
 	echo "It appears you already have a private terminfo directory"
 	echo "at $HOME/.terminfo; this seems odd, because TERMINFO"
@@ -150,7 +150,7 @@ then
 	exit;
 else
 	echo "I am creating your private terminfo directory at $HOME/.terminfo"
-	mkdir $HOME/.terminfo
+	mkdir "$HOME"/.terminfo
 	# Ensure that that's where tic's compilation results.
 	# This isn't strictly necessary with a 1.9.7 or later tic.
 	TERMINFO="$HOME/.terminfo"; export TERMINFO
@@ -165,8 +165,8 @@ then
 else
 	# Ooops...looks like we're running from somewhere other than the
 	# progs directory of an ncurses source tree.
-	master=`find $HOME -name "*terminfo.src" -print`
-	mcount=`echo $master | wc -l`
+	master=`find "$HOME" -name "*terminfo.src" -print`
+	mcount=`find "$HOME" -name "*terminfo.src" | wc -l`
 	case $mcount in
 	0)
 		echo "I can not find a terminfo source file anywhere under your home directory."
@@ -184,12 +184,12 @@ else
 	;;
 	2)
 		echo "I see more than one possible terminfo source.  Here they are:"
-		echo $master | sed "/^/s//	/";
+		echo "$master" | sed "/^/s//	/";
 		while :
 		do
 			echo "Please tell me which one to use:"
 			read master;
-			if test -f $master
+			if test -f "$master"
 			then
 				break
 			else
@@ -206,12 +206,13 @@ echo "OK, now I will make your private terminfo tree.  This may take a bit..."
 #
 # Kluge alert: we compile terminfo.src in two pieces because a lot of machines
 # with < 16MB RAM choke on tic's core-hog habits.
-trap "rm -f tsplit$$.*" EXIT INT QUIT TERM HUP
-sed -n $master \
+trap 'rm -f tsplit$$.*; exit 1' 1 2 3 15
+trap 'rm -f tsplit$$.*' 0
+sed -n "$master" \
 	-e '1,/SPLIT HERE/w 'tsplit$$.01 \
 	-e '/SPLIT HERE/,$w 'tsplit$$.02 \
 	2>/dev/null
-for x in tsplit$$.*; do eval $TIC $x; done
+for x in tsplit$$.*; do eval $TIC "$x"; done
 rm tsplit$$.*
 trap EXIT INT QUIT TERM HUP
 #
@@ -227,26 +228,26 @@ fi
 
 # OK, here comes the nasty case...user has a TERMCAP.  Instead of
 # trying to follow all the convolutions of the relationship between
-# TERM and TERMCAP (partly because it's too painful, and partly because
+# TERM and TERMCAP (partly because it is too painful, and partly because
 # we don't actually know what TERM will be nor even if it always has
 # the same value for this user) we do the following three steps...
 
-if test -f $HOME/.termcap
+if test -f "$HOME"/.termcap
 then
-	echo 'I see you have a $HOME/.termcap file.  I will compile that.'
-	eval $TIC $HOME/.termcap
+	echo "I see you have a \$HOME/.termcap file.  I will compile that."
+	eval $TIC "$HOME"/.termcap
 	echo "Done."
 	echo "Note that editing $HOME/.termcap will no longer change the data curses sees."
 elif test -f "$TERMCAP"
 then
 	echo "Your TERMCAP names the file $TERMCAP.  I will compile that."
-	eval $TIC $TERMCAP
+	eval $TIC "$TERMCAP"
 	echo "Done."
 	echo "Note that editing $TERMCAP will no longer change the data curses sees."
 else
 	echo "Your TERMCAP value appears to be an entry in termcap format."
 	echo "I will compile it."
-	echo $TERMCAP >myterm$$
+	echo "$TERMCAP" >myterm$$
 	eval $TIC myterm$$
 	rm myterm$$
 	echo "Done."
diff --git a/contrib/ncurses/progs/clear.c b/contrib/ncurses/progs/clear.c
index 85a5ea541b68..97cb0f3651de 100644
--- a/contrib/ncurses/progs/clear.c
+++ b/contrib/ncurses/progs/clear.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -41,11 +41,11 @@
 #include <clear_cmd.h>
 #include <tty_settings.h>
 
-MODULE_ID("$Id: clear.c,v 1.23 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: clear.c,v 1.24 2021/03/20 18:23:14 tom Exp $")
 
 const char *_nc_progname = "clear";
 
-static void
+static GCC_NORETURN void
 usage(void)
 {
 #define KEEP(s) s "\n"
diff --git a/contrib/ncurses/progs/dump_entry.c b/contrib/ncurses/progs/dump_entry.c
index 75bbe059cd0b..be332d2e7765 100644
--- a/contrib/ncurses/progs/dump_entry.c
+++ b/contrib/ncurses/progs/dump_entry.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -36,11 +36,11 @@
 #define __INTERNAL_CAPS_VISIBLE
 #include <progs.priv.h>
 
-#include "dump_entry.h"
-#include "termsort.c"		/* this C file is generated */
+#include <dump_entry.h>
+#include <termsort.h>		/* this C file is generated */
 #include <parametrized.h>	/* so is this */
 
-MODULE_ID("$Id: dump_entry.c,v 1.181 2020/12/26 18:25:18 tom Exp $")
+MODULE_ID("$Id: dump_entry.c,v 1.196 2023/05/27 20:13:10 tom Exp $")
 
 #define DISCARD(string) string = ABSENT_STRING
 #define PRINTF (void) printf
@@ -85,7 +85,7 @@ static int indent = 8;
 /* cover various ports and variants of terminfo */
 #define V_ALLCAPS	0	/* all capabilities (SVr4, XSI, ncurses) */
 #define V_SVR1		1	/* SVR1, Ultrix */
-#define V_HPUX		2	/* HP/UX */
+#define V_HPUX		2	/* HP-UX */
 #define V_AIX		3	/* AIX */
 #define V_BSD		4	/* BSD */
 
@@ -107,9 +107,7 @@ static int indent = 8;
 #define StrIndirect(j)  ((sortmode == S_NOSORT) ? (j) : str_indirect[j])
 #endif
 
-static void failed(const char *) GCC_NORETURN;
-
-static void
+static GCC_NORETURN void
 failed(const char *s)
 {
     perror(s);
@@ -433,10 +431,12 @@ static int
 op_length(const char *src, int offset)
 {
     int result = 0;
-    int ch;
+
     if (offset > 0 && src[offset - 1] == '\\') {
 	result = 0;
     } else {
+	int ch;
+
 	result++;		/* for '%' mark */
 	ch = src[offset + result];
 	if (TcOutput()) {
@@ -477,10 +477,12 @@ static int
 find_split(const char *src, int step, int size)
 {
     int result = size;
-    int n;
+
     if (size > 0) {
 	/* check if that would split a backslash-sequence */
 	int mark = size;
+	int n;
+
 	for (n = size - 1; n > 0; --n) {
 	    int ch = UChar(src[step + n]);
 	    if (ch == '\\') {
@@ -526,13 +528,13 @@ fill_spaces(const char *src)
     size_t size = strlen(fill);
     char *result = 0;
     int pass;
-    int s, d;
+    size_t s, d;
     for (pass = 0; pass < 2; ++pass) {
 	for (s = d = 0; src[s] != '\0'; ++s) {
 	    if (src[s] == ' ') {
 		if (pass) {
 		    _nc_STRCPY(&result[d], fill, need + 1 - d);
-		    d += (int) size;
+		    d += size;
 		} else {
 		    need += size;
 		}
@@ -547,7 +549,7 @@ fill_spaces(const char *src)
 	if (pass) {
 	    result[d] = '\0';
 	} else {
-	    result = malloc(need + 1);
+	    result = calloc(need + 1, sizeof(char));
 	    if (result == 0)
 		failed("fill_spaces");
 	}
@@ -585,7 +587,6 @@ wrap_concat(const char *src, int need, unsigned mode)
 	(column + want) > width) {
 	int step = 0;
 	int used = width > WRAPPED ? width : WRAPPED;
-	int size;
 	int base = 0;
 	char *p, align[9];
 	const char *my_t = trailer;
@@ -619,7 +620,7 @@ wrap_concat(const char *src, int need, unsigned mode)
 	    }
 
 	    while ((column + (need + gaps)) > used) {
-		size = used - tag;
+		int size = used - tag;
 		if (step) {
 		    strcpy_DYN(&outbuf, align);
 		    size -= base;
@@ -858,7 +859,6 @@ fmt_complex(TERMTYPE2 *tterm, const char *capability, char *src, int level)
 		indent_DYN(&tmpbuf, level + 1);
 		strncpy_DYN(&tmpbuf, "%", (size_t) 1);
 	    }
-	    params = FALSE;
 	    percent = FALSE;
 	    break;
 	case ' ':
@@ -882,12 +882,15 @@ static const char *
 number_format(int value)
 {
     const char *result = "%d";
+
     if ((outform != F_TERMCAP) && (value > 255)) {
 	unsigned long lv = (unsigned long) value;
-	unsigned long mm;
 	int bits = sizeof(unsigned long) * 8;
 	int nn;
+
 	for (nn = 8; nn < bits; ++nn) {
+	    unsigned long mm;
+
 	    mm = 1UL << nn;
 	    if ((mm - 16) <= lv && (mm + 16) > lv) {
 		result = "%#x";
@@ -911,7 +914,6 @@ fmt_entry(TERMTYPE2 *tterm,
 {
     PredIdx i, j;
     char buffer[MAX_TERMINFO_LENGTH + EXTRA_CAP];
-    char *capability;
     NCURSES_CONST char *name;
     int predval, len;
     PredIdx num_bools = 0;
@@ -931,7 +933,7 @@ fmt_entry(TERMTYPE2 *tterm,
 
     strcpy_DYN(&outbuf, 0);
     if (content_only) {
-	column = indent;	/* FIXME: workaround to prevent empty lines */
+	column = indent;	/* workaround to prevent empty lines */
     } else {
 	strcpy_DYN(&outbuf, tterm->term_names);
 
@@ -1031,6 +1033,7 @@ fmt_entry(TERMTYPE2 *tterm,
     }
 
     for_each_string(j, tterm) {
+	char *capability;
 	i = StrIndirect(j);
 	name = ExtStrname(tterm, (int) i, str_names);
 	assert(strlen(name) < sizeof(buffer) - EXTRA_CAP);
@@ -1308,7 +1311,7 @@ fmt_entry(TERMTYPE2 *tterm,
 }
 
 static bool
-kill_string(TERMTYPE2 *tterm, char *cap)
+kill_string(TERMTYPE2 *tterm, const char *const cap)
 {
     unsigned n;
     for (n = 0; n < NUM_STRINGS(tterm); ++n) {
@@ -1346,10 +1349,11 @@ kill_labels(TERMTYPE2 *tterm, int target)
 {
     int n;
     int result = 0;
-    char *cap;
     char name[20];
 
     for (n = 0; n <= 10; ++n) {
+	char *cap;
+
 	_nc_SPRINTF(name, _nc_SLIMIT(sizeof(name)) "lf%d", n);
 	cap = find_string(tterm, name);
 	if (VALID_STRING(cap)
@@ -1372,10 +1376,11 @@ kill_fkeys(TERMTYPE2 *tterm, int target)
 {
     int n;
     int result = 0;
-    char *cap;
     char name[20];
 
     for (n = 60; n >= 0; --n) {
+	char *cap;
+
 	_nc_SPRINTF(name, _nc_SLIMIT(sizeof(name)) "kf%d", n);
 	cap = find_string(tterm, name);
 	if (VALID_STRING(cap)
@@ -1477,19 +1482,22 @@ dump_entry(TERMTYPE2 *tterm,
 	   PredFunc pred)
 {
     TERMTYPE2 save_tterm;
-    int len, critlen;
+    int critlen;
     const char *legend;
     bool infodump;
 
     if (quickdump) {
 	char bigbuf[65536];
-	unsigned n;
 	unsigned offset = 0;
+
 	separator = "";
 	trailer = "\n";
 	indent = 0;
+
 	if (_nc_write_object(tterm, bigbuf, &offset, sizeof(bigbuf)) == OK) {
 	    char numbuf[80];
+	    unsigned n;
+
 	    if (quickdump & 1) {
 		if (outbuf.used)
 		    wrap_concat1("\n");
@@ -1504,6 +1512,7 @@ dump_entry(TERMTYPE2 *tterm,
 		static char padding[] =
 		{0, 0};
 		int value = 0;
+
 		if (outbuf.used)
 		    wrap_concat1("\n");
 		wrap_concat1("b64:");
@@ -1544,6 +1553,7 @@ dump_entry(TERMTYPE2 *tterm,
     save_sgr = set_attributes;
 
     if ((FMT_ENTRY() > critlen)
+	&& TcOutput()
 	&& limited) {
 
 	save_tterm = *tterm;
@@ -1554,7 +1564,7 @@ dump_entry(TERMTYPE2 *tterm,
 	}
 	if (FMT_ENTRY() > critlen) {
 	    /*
-	     * We pick on sgr because it's a nice long string capability that
+	     * We pick on sgr because it is a nice long string capability that
 	     * is really just an optimization hack.  Another good candidate is
 	     * acsc since it is both long and unused by BSD termcap.
 	     */
@@ -1599,6 +1609,7 @@ dump_entry(TERMTYPE2 *tterm,
 	    }
 	    if (!changed || (FMT_ENTRY() > critlen)) {
 		int oldversion = tversion;
+		int len;
 
 		tversion = V_BSD;
 		SHOW_WHY("# (terminfo-only capabilities suppressed to fit entry within %d bytes)\n",
@@ -1641,15 +1652,25 @@ dump_entry(TERMTYPE2 *tterm,
 }
 
 void
-dump_uses(const char *name, bool infodump)
+dump_uses(const char *value, bool infodump)
 /* dump "use=" clauses in the appropriate format */
 {
-    char buffer[MAX_TERMINFO_LENGTH];
+    char buffer[MAX_TERMINFO_LENGTH + EXTRA_CAP];
+    int limit = (VALID_STRING(value) ? (int) strlen(value) : 0);
+    const char *cap = infodump ? "use" : "tc";
 
     if (TcOutput())
 	trim_trailing();
+    if (limit == 0) {
+	_nc_warning("empty \"%s\" field", cap);
+	value = "";
+    } else if (limit > MAX_ALIAS) {
+	_nc_warning("\"%s\" field too long (%d), limit to %d",
+		    cap, limit, MAX_ALIAS);
+	limit = MAX_ALIAS;
+    }
     _nc_SPRINTF(buffer, _nc_SLIMIT(sizeof(buffer))
-		"%s%s", infodump ? "use=" : "tc=", name);
+		"%s=%.*s", cap, limit, value);
     wrap_concat1(buffer);
 }
 
@@ -1672,7 +1693,7 @@ show_entry(void)
 		outbuf.used = (size_t) j;
 	    } else if (!infodump && ch == '\\') {
 		outbuf.used = (size_t) j;
-	    } else if (ch == delim && (j == 0 || outbuf.text[j - 1] != '\\')) {
+	    } else if (ch == delim && (outbuf.text[j - 1] != '\\')) {
 		outbuf.used = (size_t) (j + 1);
 	    } else {
 		break;
@@ -1761,9 +1782,8 @@ void
 repair_acsc(TERMTYPE2 *tp)
 {
     if (VALID_STRING(acs_chars)) {
-	size_t n, m;
+	size_t n;
 	char mapped[256];
-	char extra = 0;
 	unsigned source;
 	unsigned target;
 	bool fix_needed = FALSE;
@@ -1778,7 +1798,11 @@ repair_acsc(TERMTYPE2 *tp)
 	    if (acs_chars[n + 1])
 		n++;
 	}
+
 	if (fix_needed) {
+	    size_t m;
+	    char extra = 0;
+
 	    memset(mapped, 0, sizeof(mapped));
 	    for (n = 0; acs_chars[n] != 0; n++) {
 		source = UChar(acs_chars[n]);
diff --git a/contrib/ncurses/progs/dump_entry.h b/contrib/ncurses/progs/dump_entry.h
index 98551914cd63..39e856fb6171 100644
--- a/contrib/ncurses/progs/dump_entry.h
+++ b/contrib/ncurses/progs/dump_entry.h
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2018-2020,2021 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -34,7 +34,7 @@
  ****************************************************************************/
 
 /*
- * $Id: dump_entry.h,v 1.43 2020/11/14 18:16:57 tom Exp $
+ * $Id: dump_entry.h,v 1.44 2021/04/18 19:56:09 tom Exp $
  *
  * Dump control definitions and variables
  */
@@ -67,8 +67,11 @@
 #define CMP_STRING	2	/* comparison on strings */
 #define CMP_USE		3	/* comparison on use capabilities */
 
+#ifndef _TERMSORT_H
 typedef unsigned PredType;
 typedef unsigned PredIdx;
+#endif
+
 typedef int (*PredFunc) (PredType, PredIdx);
 typedef void (*PredHook) (PredType, PredIdx, const char *);
 
diff --git a/contrib/ncurses/progs/infocmp.c b/contrib/ncurses/progs/infocmp.c
index dbdbdc2dfe35..7932203ac2b1 100644
--- a/contrib/ncurses/progs/infocmp.c
+++ b/contrib/ncurses/progs/infocmp.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020-2022,2023 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -43,7 +43,7 @@
 
 #include <dump_entry.h>
 
-MODULE_ID("$Id: infocmp.c,v 1.145 2020/07/07 20:28:47 tom Exp $")
+MODULE_ID("$Id: infocmp.c,v 1.163 2023/12/16 17:27:47 tom Exp $")
 
 #define MAX_STRING	1024	/* maximum formatted string */
 
@@ -94,7 +94,7 @@ typedef struct {
 static ENTERED *entered;
 
 #undef ExitProgram
-static void ExitProgram(int code) GCC_NORETURN;
+static GCC_NORETURN void ExitProgram(int code);
 /* prototype is to get gcc to accept the noreturn attribute */
 static void
 ExitProgram(int code)
@@ -124,17 +124,19 @@ failed(const char *s)
     ExitProgram(EXIT_FAILURE);
 }
 
-static char *
-canonical_name(char *ptr, char *buf)
+static void
+canonical_name(char *source, char *target)
 /* extract the terminal type's primary name */
 {
-    char *bp;
-
-    _nc_STRCPY(buf, ptr, NAMESIZE);
-    if ((bp = strchr(buf, '|')) != 0)
-	*bp = '\0';
+    int limit = NAMESIZE;
 
-    return (buf);
+    while (--limit > 0) {
+	char ch = *source++;
+	if (ch == '|')
+	    break;
+	*target++ = ch;
+    }
+    *target = '\0';
 }
 
 static bool
@@ -156,7 +158,7 @@ no_numeric(int value)
 }
 
 static bool
-no_string(char *value)
+no_string(const char *const value)
 {
     bool result = (value == ABSENT_STRING);
     if (!strcmp(s_absent, s_cancel))
@@ -185,10 +187,21 @@ capcmp(PredIdx idx, const char *s, const char *t)
 	return (_nc_capcmp(s, t));
 }
 
+/*
+ * Predicate function to use for "use=" decompilation.
+ *
+ * Return value is used in fmt_entry:
+ *   FAIL  show nothing for this capability.
+ *   FALSE show cancel for booleans (a compromise)
+ *   TRUE  show capability
+ *
+ * The only difference between FALSE/TRUE returns is in the treatment of
+ * booleans.
+ */
 static int
 use_predicate(unsigned type, PredIdx idx)
-/* predicate function to use for use decompilation */
 {
+    int result = FAIL;
     ENTRY *ep;
 
     switch (type) {
@@ -207,16 +220,18 @@ use_predicate(unsigned type, PredIdx idx)
 	     * unlike numbers and strings, whose cancelled/absent state is
 	     * recorded in the terminfo database.
 	     */
-	    for (ep = &entries[1]; ep < entries + termcount; ep++)
-		if (ep->tterm.Booleans[idx] == TRUE) {
-		    is_set = entries[0].tterm.Booleans[idx];
-		    break;
+	    if (idx < NUM_BOOLEANS(&(entries[0].tterm))) {
+		for (ep = &entries[1]; ep < entries + termcount; ep++) {
+		    if (idx < NUM_BOOLEANS(&(ep->tterm))
+			&& (is_set = ep->tterm.Booleans[idx])) {
+			break;
+		    }
 		}
-	    if (is_set != entries[0].tterm.Booleans[idx])
-		return (!is_set);
-	    else
-		return (FAIL);
+		if (is_set != entries[0].tterm.Booleans[idx])
+		    result = (!is_set);
+	    }
 	}
+	break;
 
     case NUMBER:
 	{
@@ -227,45 +242,56 @@ use_predicate(unsigned type, PredIdx idx)
 	     * capability gets the first non-default value found
 	     * in the sequence of use entries'.
 	     */
-	    for (ep = &entries[1]; ep < entries + termcount; ep++)
-		if (VALID_NUMERIC(ep->tterm.Numbers[idx])) {
-		    value = ep->tterm.Numbers[idx];
-		    break;
-		}
+	    if (idx < NUM_NUMBERS(&(entries[0].tterm))) {
+		for (ep = &entries[1]; ep < entries + termcount; ep++)
+		    if (idx < NUM_NUMBERS(&(ep->tterm))
+			&& VALID_NUMERIC(ep->tterm.Numbers[idx])) {
+			value = ep->tterm.Numbers[idx];
+			break;
+		    }
 
-	    if (value != entries[0].tterm.Numbers[idx])
-		return (value != ABSENT_NUMERIC);
-	    else
-		return (FAIL);
+		if (value != entries[0].tterm.Numbers[idx])
+		    result = (value != ABSENT_NUMERIC);
+	    }
 	}
+	break;
 
     case STRING:
 	{
-	    char *termstr, *usestr = ABSENT_STRING;
-
-	    termstr = entries[0].tterm.Strings[idx];
+	    char *termstr = entries[0].tterm.Strings[idx];
+	    char *usestr = ABSENT_STRING;
 
 	    /*
 	     * We take the semantics of multiple uses to be 'each
 	     * capability gets the first non-default value found
 	     * in the sequence of use entries'.
 	     */
-	    for (ep = &entries[1]; ep < entries + termcount; ep++)
-		if (ep->tterm.Strings[idx]) {
-		    usestr = ep->tterm.Strings[idx];
-		    break;
-		}
+	    if (idx < NUM_STRINGS(&(entries[0].tterm))) {
+		for (ep = &entries[1]; ep < entries + termcount; ep++)
+		    if (idx < NUM_STRINGS(&(ep->tterm))
+			&& ep->tterm.Strings[idx]) {
+			usestr = ep->tterm.Strings[idx];
+			break;
+		    }
 
-	    if (usestr == ABSENT_STRING && termstr == ABSENT_STRING)
-		return (FAIL);
-	    else if (!usestr || !termstr || capcmp(idx, usestr, termstr))
-		return (TRUE);
-	    else
-		return (FAIL);
+		if (usestr == CANCELLED_STRING && termstr == ABSENT_STRING)
+		    result = (FAIL);
+		else if (usestr == CANCELLED_STRING && termstr == CANCELLED_STRING)
+		    result = (TRUE);
+		else if (usestr == ABSENT_STRING && termstr == ABSENT_STRING)
+		    result = (FAIL);
+		else if (!usestr || !termstr || capcmp(idx, usestr, termstr))
+		    result = (TRUE);
+	    }
 	}
+	break;
+
+    default:
+	result = FALSE;
+	break;
     }
 
-    return (FALSE);		/* pacify compiler */
+    return (result);
 }
 
 static bool
@@ -322,16 +348,17 @@ static void
 print_uses(ENTRY * ep, FILE *fp)
 /* print an entry's use references */
 {
-    unsigned i;
-
-    if (!ep->nuses)
+    if (!ep->nuses) {
 	fputs("NULL", fp);
-    else
+    } else {
+	unsigned i;
+
 	for (i = 0; i < ep->nuses; i++) {
 	    fputs(ep->uses[i].name, fp);
 	    if (i < ep->nuses - 1)
 		fputs(" ", fp);
 	}
+    }
 }
 
 static const char *
@@ -418,7 +445,7 @@ show_comparing(char **names)
 
 /*
  * ncurses stores two types of non-standard capabilities:
- * a) capabilities listed past the "STOP-HERE" comment in the Caps file. 
+ * a) capabilities listed past the "STOP-HERE" comment in the Caps file.
  *    These are used in the terminfo source file to provide data for termcaps,
  *    e.g., when there is no equivalent capability in terminfo, as well as for
  *    widely-used non-standard capabilities.
@@ -835,6 +862,8 @@ analyze_string(const char *name, const char *cap, TERMTYPE2 *tp)
 	    char *cp = tp->Strings[i];
 
 	    /* don't use function-key capabilities */
+	    if (strnames[i] == NULL)
+		continue;
 	    if (strnames[i][0] == 'k' && strnames[i][1] == 'f')
 		continue;
 
@@ -900,7 +929,6 @@ analyze_string(const char *name, const char *cap, TERMTYPE2 *tp)
 		       sizeof(buf2));
 	    _nc_STRNCPY(buf3, sp + csi, len);
 	    buf3[len] = '\0';
-	    len += (size_t) csi + 1;
 
 	    expansion = lookup_params(std_modes, buf2, buf3);
 	}
@@ -921,7 +949,6 @@ analyze_string(const char *name, const char *cap, TERMTYPE2 *tp)
 		       sizeof(buf2));
 	    _nc_STRNCPY(buf3, sp + csi + 1, len);
 	    buf3[len] = '\0';
-	    len += (size_t) csi + 2;
 
 	    expansion = lookup_params(private_modes, buf2, buf3);
 	}
@@ -1129,8 +1156,8 @@ file_comparison(int argc, char *argv[])
 	    if (entryeq(&qp->tterm, &rp->tterm) && useeq(qp, rp)) {
 		char name1[NAMESIZE], name2[NAMESIZE];
 
-		(void) canonical_name(qp->tterm.term_names, name1);
-		(void) canonical_name(rp->tterm.term_names, name2);
+		canonical_name(qp->tterm.term_names, name1);
+		canonical_name(rp->tterm.term_names, name2);
 
 		(void) printf("%s = %s\n", name1, name2);
 	    }
@@ -1158,8 +1185,8 @@ file_comparison(int argc, char *argv[])
 		entries[0] = *qp;
 		entries[1] = *rp;
 
-		(void) canonical_name(qp->tterm.term_names, name1);
-		(void) canonical_name(rp->tterm.term_names, name2);
+		canonical_name(qp->tterm.term_names, name1);
+		canonical_name(rp->tterm.term_names, name2);
 
 		switch (compare) {
 		case C_DIFFERENCE:
@@ -1305,9 +1332,9 @@ dump_initializers(TERMTYPE2 *term)
 	   name_initializer("alias"), entries->tterm.term_names);
 
     for_each_string(n, term) {
-	char buf[MAX_STRING], *sp, *tp;
-
 	if (VALID_STRING(term->Strings[n])) {
+	    char buf[MAX_STRING], *sp, *tp;
+
 	    tp = buf;
 #define TP_LIMIT	((MAX_STRING - 5) - (size_t)(tp - buf))
 	    *tp++ = '"';
@@ -1510,6 +1537,8 @@ show_databases(void)
 
 #if NO_LEAKS
 #define MAIN_LEAKS() \
+    _nc_free_termtype2(&entries[0].tterm); \
+    _nc_free_termtype2(&entries[1].tterm); \
     free(myargv); \
     free(tfile); \
     free(tname)
@@ -1529,7 +1558,7 @@ main(int argc, char *argv[])
     char **myargv;
 
     char *firstdir, *restdir;
-    int c, i, len;
+    int c;
     bool formatted = FALSE;
     bool filecompare = FALSE;
     int initdump = 0;
@@ -1720,7 +1749,7 @@ main(int argc, char *argv[])
 
 	case 'v':
 	    itrace = (unsigned) optarg_to_number();
-	    set_trace_level(itrace);
+	    use_verbosity(itrace);
 	    break;
 
 	case 'W':
@@ -1853,8 +1882,16 @@ main(int argc, char *argv[])
 	}
 
 #if NCURSES_XNAMES
-	if (termcount > 1)
-	    _nc_align_termtype(&entries[0].tterm, &entries[1].tterm);
+	if (termcount > 1) {
+	    /*
+	     * User-defined capabilities in different terminal descriptions
+	     * may have the same name/type but different indices.  Line up
+	     * the names to use comparable indices.  We may have more than two
+	     * entries to compare when processing the "-u" option.
+	     */
+	    for (c = 1; c < termcount; ++c)
+		_nc_align_termtype(&entries[c].tterm, &entries[0].tterm);
+	}
 #endif
 
 	/* dump as C initializer for the terminal type */
@@ -1881,6 +1918,8 @@ main(int argc, char *argv[])
 	    analyze_string("rmkx", keypad_local, &entries[0].tterm);
 #undef CUR
 	} else {
+	    int i;
+	    int len;
 
 	    /*
 	     * Here's where the real work gets done
diff --git a/contrib/ncurses/progs/modules b/contrib/ncurses/progs/modules
index f2bba15c1eb8..349061ff5542 100644
--- a/contrib/ncurses/progs/modules
+++ b/contrib/ncurses/progs/modules
@@ -1,7 +1,7 @@
-# $Id: modules,v 1.22 2020/02/02 23:34:34 tom Exp $
+# $Id: modules,v 1.25 2021/04/18 17:21:03 tom Exp $
 # Program modules (some are in ncurses lib!)
 ##############################################################################
-# Copyright 2020 Thomas E. Dickey                                            #
+# Copyright 2020,2021 Thomas E. Dickey                                       #
 # Copyright 1998-2014,2016 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
@@ -37,13 +37,13 @@ clear		progs		$(srcdir)	$(HEADER_DEPS) tty_settings.h
 tic		progs		$(srcdir)	$(HEADER_DEPS) transform.h $(srcdir)/dump_entry.h $(srcdir)/tparm_type.h
 toe		progs		$(srcdir)	$(HEADER_DEPS)             $(INCDIR)/hashed_db.h
 clear_cmd	progs		$(srcdir)	$(HEADER_DEPS) clear_cmd.h
-dump_entry	progs		$(srcdir)	$(HEADER_DEPS)             $(srcdir)/dump_entry.h ../include/parametrized.h $(INCDIR)/capdefaults.c termsort.c
+dump_entry	progs		$(srcdir)	$(HEADER_DEPS)             $(srcdir)/dump_entry.h ../include/parametrized.h $(INCDIR)/capdefaults.c termsort.h
 infocmp		progs		$(srcdir)	$(HEADER_DEPS)             $(srcdir)/dump_entry.h
 reset_cmd	progs		$(srcdir)	$(HEADER_DEPS) reset_cmd.h tty_settings.h
 tabs		progs		$(srcdir)	$(HEADER_DEPS)
 tparm_type	progs		$(srcdir)	$(HEADER_DEPS)             $(srcdir)/tparm_type.h
-tput		progs		$(srcdir)	$(HEADER_DEPS) transform.h $(srcdir)/dump_entry.h $(srcdir)/tparm_type.h termsort.c reset_cmd.h tty_settings.h
-tset		progs		$(srcdir)	$(HEADER_DEPS) transform.h $(srcdir)/dump_entry.h ../include/termcap.h reset_cmd.h  tty_settings.h
+tput		progs		$(srcdir)	$(HEADER_DEPS) transform.h $(srcdir)/tparm_type.h reset_cmd.h tty_settings.h
+tset		progs		$(srcdir)	$(HEADER_DEPS) transform.h ../include/termcap.h reset_cmd.h  tty_settings.h
 transform	progs		$(srcdir)	$(HEADER_DEPS) transform.h
 tty_settings	progs		$(srcdir)	$(HEADER_DEPS) tty_settings.h
 
diff --git a/contrib/ncurses/progs/progs.priv.h b/contrib/ncurses/progs/progs.priv.h
index 3dc177d0a866..fea18b8d72c3 100644
--- a/contrib/ncurses/progs/progs.priv.h
+++ b/contrib/ncurses/progs/progs.priv.h
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 2019-2022,2024 Thomas E. Dickey                                *
  * Copyright 1998-2015,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -31,7 +31,7 @@
  *  Author: Thomas E. Dickey                    1997-on                     *
  ****************************************************************************/
 /*
- * $Id: progs.priv.h,v 1.52 2020/09/05 19:35:06 tom Exp $
+ * $Id: progs.priv.h,v 1.62 2024/04/08 17:28:28 tom Exp $
  *
  *	progs.priv.h
  *
@@ -41,28 +41,9 @@
 #ifndef PROGS_PRIV_H
 #define PROGS_PRIV_H 1
 
-#include <ncurses_cfg.h>
+#include <curses.priv.h>
 
-#if USE_RCS_IDS
-#define MODULE_ID(id) static const char Ident[] = id;
-#else
-#define MODULE_ID(id)		/*nothing */
-#endif
-
-#include <stdlib.h>
 #include <ctype.h>
-#include <string.h>
-#include <sys/types.h>
-
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#if HAVE_LIMITS_H
-# include <limits.h>
-#elif HAVE_SYS_PARAM_H
-# include <sys/param.h>
-#endif
 
 #if HAVE_DIRENT_H
 # include <dirent.h>
@@ -90,21 +71,6 @@
 # endif
 #endif
 
-#if HAVE_INTTYPES_H
-# include <inttypes.h>
-#else
-# if HAVE_STDINT_H
-#  include <stdint.h>
-# endif
-#endif
-
-#include <assert.h>
-#include <errno.h>
-
-#if DECL_ERRNO
-extern int errno;
-#endif
-
 #if HAVE_GETOPT_H
 #include <getopt.h>
 #elif !defined(HAVE_GETOPT_HEADER)
@@ -115,27 +81,7 @@ extern char *optarg;
 extern int optind;
 #endif /* HAVE_GETOPT_H */
 
-#undef _NC_WINDOWS
-#if (defined(_WIN32) || defined(_WIN64))
-#define _NC_WINDOWS 1
-#endif
-
-#define NCURSES_INTERNALS 1
-#define NCURSES_OPAQUE    0
-
-#include <curses.h>
-
-#if !(defined(NCURSES_WGETCH_EVENTS) && defined(NEED_KEY_EVENT))
-#undef KEY_EVENT		/* reduce compiler-warnings with Visual C++ */
-#endif
-
-#include <term_entry.h>
-#include <nc_termios.h>
 #include <tic.h>
-#include <nc_tparm.h>
-
-#include <nc_string.h>
-#include <nc_alloc.h>
 
 #if HAVE_NC_FREEALL
 #undef ExitProgram
@@ -146,77 +92,12 @@ extern int optind;
 #endif
 #endif
 
-#define VtoTrace(opt) (unsigned) ((opt > 0) ? opt : (opt == 0))
-
 /* error-returns for tput */
 #define ErrUsage	2
 #define ErrTermType	3
 #define ErrCapName	4
 #define ErrSystem(n)	(4 + (n))
 
-#if defined(__GNUC__) && defined(_FORTIFY_SOURCE)
-#define IGNORE_RC(func) errno = (int) func
-#else
-#define IGNORE_RC(func) (void) func
-#endif /* gcc workarounds */
-
-/* usually in <unistd.h> */
-#ifndef STDIN_FILENO
-#define STDIN_FILENO 0
-#endif
-
-#ifndef STDOUT_FILENO
-#define STDOUT_FILENO 1
-#endif
-
-#ifndef STDERR_FILENO
-#define STDERR_FILENO 2
-#endif
-
-#ifndef EXIT_SUCCESS
-#define EXIT_SUCCESS 0
-#endif
-
-#ifndef EXIT_FAILURE
-#define EXIT_FAILURE 1
-#endif
-
-#ifndef R_OK
-#define	R_OK	4		/* Test for readable.  */
-#endif
-
-#ifndef W_OK
-#define	W_OK	2		/* Test for writable.  */
-#endif
-
-#ifndef X_OK
-#define	X_OK	1		/* Test for executable.  */
-#endif
-
-#ifndef F_OK
-#define	F_OK	0		/* Test for existence.  */
-#endif
-
-/* usually in <unistd.h> */
-#ifndef STDOUT_FILENO
-#define STDOUT_FILENO 1
-#endif
-
-#ifndef STDERR_FILENO
-#define STDERR_FILENO 2
-#endif
-
-/* may be in limits.h, included from various places */
-#ifndef PATH_MAX
-# if defined(_POSIX_PATH_MAX)
-#  define PATH_MAX _POSIX_PATH_MAX
-# elif defined(MAXPATHLEN)
-#  define PATH_MAX MAXPATHLEN
-# else
-#  define PATH_MAX 255		/* the Posix minimum pathsize */
-# endif
-#endif
-
 /* We use isascii only to guard against use of 7-bit ctype tables in the
  * isprint test in infocmp.
  */
@@ -229,16 +110,28 @@ extern int optind;
 # endif
 #endif
 
-#define UChar(c)    ((unsigned char)(c))
-
-#define SIZEOF(v) (sizeof(v)/sizeof(v[0]))
-
-#define NCURSES_EXT_NUMBERS (NCURSES_EXT_COLORS && HAVE_INIT_EXTENDED_COLOR)
+#define VtoTrace(opt) (unsigned) ((opt > 0) ? opt : (opt == 0))
 
-#if NCURSES_EXT_NUMBERS
+/*
+ * If configured for tracing, the debug- and trace-output are merged together
+ * in the trace file for "upper" levels of the verbose option.
+ */
+#ifdef TRACE
+#define use_verbosity(level) do { \
+ 		set_trace_level(level); \
+		if (_nc_tracing > DEBUG_LEVEL(2)) \
+		    _nc_tracing |= TRACE_MAXIMUM; \
+		else if (_nc_tracing == DEBUG_LEVEL(2)) \
+		    _nc_tracing |= TRACE_ORDINARY; \
+		if (level >= 2) \
+		    curses_trace(_nc_tracing); \
+	} while (0)
 #else
-#define _nc_free_termtype2(t) _nc_free_termtype(t)
-#define _nc_read_entry2(n,f,t) _nc_read_entry(n,f,t)
+#define use_verbosity(level) do { set_trace_level(level); } while (0)
+#endif
+
+#ifndef CUR
+#define CUR ((TERMTYPE *)(cur_term))->
 #endif
 
 #endif /* PROGS_PRIV_H */
diff --git a/contrib/ncurses/progs/reset_cmd.c b/contrib/ncurses/progs/reset_cmd.c
index 5e517cc74e9e..6ae3b673e340 100644
--- a/contrib/ncurses/progs/reset_cmd.c
+++ b/contrib/ncurses/progs/reset_cmd.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 2019-2023,2024 Thomas E. Dickey                                *
  * Copyright 2016,2017 Free Software Foundation, Inc.                       *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -47,13 +47,13 @@
 #endif
 
 #if NEED_PTEM_H
-/* they neglected to define struct winsize in termios.h -- it's only
+/* they neglected to define struct winsize in termios.h -- it is only
    in termio.h	*/
 #include <sys/stream.h>
 #include <sys/ptem.h>
 #endif
 
-MODULE_ID("$Id: reset_cmd.c,v 1.24 2020/11/21 22:11:10 tom Exp $")
+MODULE_ID("$Id: reset_cmd.c,v 1.37 2024/04/08 17:29:34 tom Exp $")
 
 /*
  * SCO defines TIOCGSIZE and the corresponding struct.  Other systems (SunOS,
@@ -75,12 +75,15 @@ MODULE_ID("$Id: reset_cmd.c,v 1.24 2020/11/21 22:11:10 tom Exp $")
 # endif
 #endif
 
+#define set_flags(target, mask)    target |= mask
+#define clear_flags(target, mask)  target &= ~((unsigned)(mask))
+
 static FILE *my_file;
 
 static bool use_reset = FALSE;	/* invoked as reset */
 static bool use_init = FALSE;	/* invoked as init */
 
-static void
+static GCC_NORETURN void
 failed(const char *msg)
 {
     int code = errno;
@@ -102,7 +105,7 @@ cat_file(char *file)
     bool sent = FALSE;
 
     if (file != 0) {
-	if ((fp = fopen(file, "r")) == 0)
+	if ((fp = safe_fopen(file, "r")) == 0)
 	    failed(file);
 
 	while ((nr = fread(buf, sizeof(char), sizeof(buf), fp)) != 0) {
@@ -188,13 +191,91 @@ out_char(int c)
 #define reset_char(item, value) \
     tty_settings->c_cc[item] = CHK(tty_settings->c_cc[item], value)
 
+/*
+ * Simplify ifdefs
+ */
+#ifndef BSDLY
+#define BSDLY 0
+#endif
+#ifndef CRDLY
+#define CRDLY 0
+#endif
+#ifndef ECHOCTL
+#define ECHOCTL 0
+#endif
+#ifndef ECHOKE
+#define ECHOKE 0
+#endif
+#ifndef ECHOPRT
+#define ECHOPRT 0
+#endif
+#ifndef FFDLY
+#define FFDLY 0
+#endif
+#ifndef IMAXBEL
+#define IMAXBEL 0
+#endif
+#ifndef IUCLC
+#define IUCLC 0
+#endif
+#ifndef IXANY
+#define IXANY 0
+#endif
+#ifndef NLDLY
+#define NLDLY 0
+#endif
+#ifndef OCRNL
+#define OCRNL 0
+#endif
+#ifndef OFDEL
+#define OFDEL 0
+#endif
+#ifndef OFILL
+#define OFILL 0
+#endif
+#ifndef OLCUC
+#define OLCUC 0
+#endif
+#ifndef ONLCR
+#define ONLCR 0
+#endif
+#ifndef ONLRET
+#define ONLRET 0
+#endif
+#ifndef ONOCR
+#define ONOCR 0
+#endif
+#ifndef OXTABS
+#define OXTABS 0
+#endif
+#ifndef TAB3
+#define TAB3 0
+#endif
+#ifndef TABDLY
+#define TABDLY 0
+#endif
+#ifndef TOSTOP
+#define TOSTOP 0
+#endif
+#ifndef VTDLY
+#define VTDLY 0
+#endif
+#ifndef XCASE
+#define XCASE 0
+#endif
+
 /*
  * Reset the terminal mode bits to a sensible state.  Very useful after
  * a child program dies in raw mode.
  */
 void
-reset_tty_settings(int fd, TTY * tty_settings)
+reset_tty_settings(int fd, TTY * tty_settings, int noset)
 {
+    unsigned mask;
+#ifdef TIOCMGET
+    int modem_bits;
+#endif
+
     GET_TTY(fd, tty_settings);
 
 #ifdef TERMIOS
@@ -203,6 +284,9 @@ reset_tty_settings(int fd, TTY * tty_settings)
 #endif
     reset_char(VEOF, CEOF);
     reset_char(VERASE, CERASE);
+#if defined(VERASE2) && defined(CERASE2)
+    reset_char(VERASE2, CERASE2);
+#endif
 #if defined(VFLUSH) && defined(CFLUSH)
     reset_char(VFLUSH, CFLUSH);
 #endif
@@ -228,108 +312,69 @@ reset_tty_settings(int fd, TTY * tty_settings)
     reset_char(VWERASE, CWERASE);
 #endif
 
-    tty_settings->c_iflag &= ~((unsigned) (IGNBRK
-					   | PARMRK
-					   | INPCK
-					   | ISTRIP
-					   | INLCR
-					   | IGNCR
-#ifdef IUCLC
-					   | IUCLC
-#endif
-#ifdef IXANY
-					   | IXANY
-#endif
-					   | IXOFF));
-
-    tty_settings->c_iflag |= (BRKINT
-			      | IGNPAR
-			      | ICRNL
-			      | IXON
-#ifdef IMAXBEL
-			      | IMAXBEL
-#endif
-	);
-
-    tty_settings->c_oflag &= ~((unsigned) (0
-#ifdef OLCUC
-					   | OLCUC
-#endif
-#ifdef OCRNL
-					   | OCRNL
-#endif
-#ifdef ONOCR
-					   | ONOCR
-#endif
-#ifdef ONLRET
-					   | ONLRET
-#endif
-#ifdef OFILL
-					   | OFILL
-#endif
-#ifdef OFDEL
-					   | OFDEL
-#endif
-#ifdef NLDLY
-					   | NLDLY
-#endif
-#ifdef CRDLY
-					   | CRDLY
-#endif
-#ifdef TABDLY
-					   | TABDLY
-#endif
-#ifdef BSDLY
-					   | BSDLY
-#endif
-#ifdef VTDLY
-					   | VTDLY
-#endif
-#ifdef FFDLY
-					   | FFDLY
-#endif
-			       ));
-
-    tty_settings->c_oflag |= (OPOST
-#ifdef ONLCR
-			      | ONLCR
-#endif
-	);
-
-    tty_settings->c_cflag &= ~((unsigned) (CSIZE
-					   | CSTOPB
-					   | PARENB
-					   | PARODD
-					   | CLOCAL));
-    tty_settings->c_cflag |= (CS8 | CREAD);
-    tty_settings->c_lflag &= ~((unsigned) (ECHONL
-					   | NOFLSH
-#ifdef TOSTOP
-					   | TOSTOP
-#endif
-#ifdef ECHOPTR
-					   | ECHOPRT
-#endif
-#ifdef XCASE
-					   | XCASE
-#endif
-			       ));
-
-    tty_settings->c_lflag |= (ISIG
-			      | ICANON
-			      | ECHO
-			      | ECHOE
-			      | ECHOK
-#ifdef ECHOCTL
-			      | ECHOCTL
-#endif
-#ifdef ECHOKE
-			      | ECHOKE
-#endif
-	);
-#endif
-
-    SET_TTY(fd, tty_settings);
+    clear_flags(tty_settings->c_iflag, (IGNBRK
+					| PARMRK
+					| INPCK
+					| ISTRIP
+					| INLCR
+					| IGNCR
+					| IUCLC
+					| IXANY
+					| IXOFF));
+
+    set_flags(tty_settings->c_iflag, (BRKINT
+				      | IGNPAR
+				      | ICRNL
+				      | IXON
+				      | IMAXBEL));
+
+    clear_flags(tty_settings->c_oflag, (0
+					| OLCUC
+					| OCRNL
+					| ONOCR
+					| ONLRET
+					| OFILL
+					| OFDEL
+					| NLDLY
+					| CRDLY
+					| TABDLY
+					| BSDLY
+					| VTDLY
+					| FFDLY));
+
+    set_flags(tty_settings->c_oflag, (OPOST
+				      | ONLCR));
+
+    mask = (CSIZE | CSTOPB | PARENB | PARODD);
+#ifdef TIOCMGET
+    /* leave clocal alone if this appears to use a modem */
+    if (ioctl(fd, TIOCMGET, &modem_bits) == -1)
+	mask |= CLOCAL;
+#else
+    /* cannot check - use the behavior from tset */
+    mask |= CLOCAL;
+#endif
+    clear_flags(tty_settings->c_cflag, mask);
+
+    set_flags(tty_settings->c_cflag, (CS8 | CREAD));
+    clear_flags(tty_settings->c_lflag, (ECHONL
+					| NOFLSH
+					| TOSTOP
+					| ECHOPRT
+					| XCASE));
+
+    set_flags(tty_settings->c_lflag, (ISIG
+				      | ICANON
+				      | ECHO
+				      | ECHOE
+				      | ECHOK
+				      | ECHOCTL
+				      | ECHOKE));
+#endif /* TERMIOS */
+
+    if (!noset) {
+	SET_TTY(fd, tty_settings);
+    }
 }
 
 /*
@@ -400,29 +445,23 @@ set_conversions(TTY * tty_settings)
 #if defined(EXP_WIN32_DRIVER)
     /* FIXME */
 #else
-#ifdef ONLCR
-    tty_settings->c_oflag |= ONLCR;
-#endif
-    tty_settings->c_iflag |= ICRNL;
-    tty_settings->c_lflag |= ECHO;
-#ifdef OXTABS
-    tty_settings->c_oflag |= OXTABS;
-#endif /* OXTABS */
+    set_flags(tty_settings->c_oflag, ONLCR);
+    set_flags(tty_settings->c_iflag, ICRNL);
+    set_flags(tty_settings->c_lflag, ECHO);
+    set_flags(tty_settings->c_oflag, OXTABS);
 
     /* test used to be tgetflag("NL") */
     if (VALID_STRING(newline) && newline[0] == '\n' && !newline[1]) {
 	/* Newline, not linefeed. */
-#ifdef ONLCR
-	tty_settings->c_oflag &= ~((unsigned) ONLCR);
-#endif
-	tty_settings->c_iflag &= ~((unsigned) ICRNL);
+	clear_flags(tty_settings->c_oflag, ONLCR);
+	clear_flags(tty_settings->c_iflag, ICRNL);
     }
-#ifdef OXTABS
+#if OXTABS
     /* test used to be tgetflag("pt") */
     if (VALID_STRING(set_tab) && VALID_STRING(clear_all_tabs))
-	tty_settings->c_oflag &= ~OXTABS;
+	clear_flags(tty_settings->c_oflag, OXTABS);
 #endif /* OXTABS */
-    tty_settings->c_lflag |= (ECHOE | ECHOK);
+    set_flags(tty_settings->c_lflag, (ECHOE | ECHOK));
 #endif
 }
 
@@ -488,7 +527,7 @@ send_init_strings(int fd GCC_UNUSED, TTY * old_settings)
     bool need_flush = FALSE;
 
     (void) old_settings;
-#ifdef TAB3
+#if TAB3
     if (old_settings != 0 &&
 	old_settings->c_oflag & (TAB3 | ONLCR | OCRNL | ONLRET)) {
 	old_settings->c_oflag &= (TAB3 | ONLCR | OCRNL | ONLRET);
@@ -510,22 +549,22 @@ send_init_strings(int fd GCC_UNUSED, TTY * old_settings)
 
 	if (VALID_STRING(clear_margins)) {
 	    need_flush |= sent_string(clear_margins);
-	} else
+	}
 #if defined(set_lr_margin)
-	if (VALID_STRING(set_lr_margin)) {
+	else if (VALID_STRING(set_lr_margin)) {
 	    need_flush |= sent_string(TIPARM_2(set_lr_margin, 0, columns - 1));
-	} else
+	}
 #endif
 #if defined(set_left_margin_parm) && defined(set_right_margin_parm)
-	    if (VALID_STRING(set_left_margin_parm)
-		&& VALID_STRING(set_right_margin_parm)) {
+	else if (VALID_STRING(set_left_margin_parm)
+		 && VALID_STRING(set_right_margin_parm)) {
 	    need_flush |= sent_string(TIPARM_1(set_left_margin_parm, 0));
 	    need_flush |= sent_string(TIPARM_1(set_right_margin_parm,
 					       columns - 1));
-	} else
+	}
 #endif
-	    if (VALID_STRING(set_left_margin)
-		&& VALID_STRING(set_right_margin)) {
+	else if (VALID_STRING(set_left_margin)
+		 && VALID_STRING(set_right_margin)) {
 	    need_flush |= to_left_margin();
 	    need_flush |= sent_string(set_left_margin);
 	    if (VALID_STRING(parm_right_cursor)) {
@@ -638,7 +677,7 @@ print_tty_chars(TTY * old_settings, TTY * new_settings)
  * size was set.
  */
 void
-set_window_size(int fd, short *high, short *wide)
+set_window_size(int fd, NCURSES_INT2 *high, NCURSES_INT2 *wide)
 {
     STRUCT_WINSIZE win;
     (void) ioctl(fd, IOCTL_GET_WINSIZE, &win);
diff --git a/contrib/ncurses/progs/reset_cmd.h b/contrib/ncurses/progs/reset_cmd.h
index 7d457154996f..43aee28f7e8c 100644
--- a/contrib/ncurses/progs/reset_cmd.h
+++ b/contrib/ncurses/progs/reset_cmd.h
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020-2021,2024 Thomas E. Dickey                                *
  * Copyright 2016 Free Software Foundation, Inc.                            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -32,7 +32,7 @@
  ****************************************************************************/
 
 /*
- * $Id: reset_cmd.h,v 1.8 2020/02/02 23:34:34 tom Exp $
+ * $Id: reset_cmd.h,v 1.11 2024/04/08 17:29:34 tom Exp $
  *
  * Utility functions for resetting terminal.
  */
@@ -51,12 +51,12 @@ extern bool send_init_strings(int /* fd */, TTY * /* old_settings */);
 extern void print_tty_chars(TTY * /* old_settings */, TTY * /* new_settings */);
 extern void reset_flush(void);
 extern void reset_start(FILE * /* fp */, bool /* is_reset */, bool /* is_init */ );
-extern void reset_tty_settings(int /* fd */, TTY * /* tty_settings */);
+extern void reset_tty_settings(int /* fd */, TTY * /* tty_settings */, int /* noset */);
 extern void set_control_chars(TTY * /* tty_settings */, int /* erase */, int /* intr */, int /* kill */);
 extern void set_conversions(TTY * /* tty_settings */);
 
 #if HAVE_SIZECHANGE
-extern void set_window_size(int /* fd */, short * /* high */, short * /* wide */);
+extern void set_window_size(int /* fd */, NCURSES_INT2 * /* high */, NCURSES_INT2 * /* wide */);
 #endif
 
 extern const char *_nc_progname;
diff --git a/contrib/ncurses/progs/tabs.c b/contrib/ncurses/progs/tabs.c
index 0539e85653ea..a630b044e0cc 100644
--- a/contrib/ncurses/progs/tabs.c
+++ b/contrib/ncurses/progs/tabs.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020-2022,2023 Thomas E. Dickey                                *
  * Copyright 2008-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -39,9 +39,9 @@
 #include <progs.priv.h>
 #include <tty_settings.h>
 
-MODULE_ID("$Id: tabs.c,v 1.45 2020/05/27 23:47:22 tom Exp $")
+MODULE_ID("$Id: tabs.c,v 1.53 2023/11/04 20:46:09 tom Exp $")
 
-static void usage(void) GCC_NORETURN;
+static GCC_NORETURN void usage(void);
 
 const char *_nc_progname;
 static int max_cols;
@@ -59,14 +59,44 @@ putch(int c)
     return putchar(c);
 }
 
+static char *
+skip_csi(char *value)
+{
+    if (UChar(*value) == 0x9b)
+	++value;
+    else if (!strncmp(value, "\033[", 2))
+	value += 2;
+    return value;
+}
+
+/*
+ * If the terminal uses ANSI clear_all_tabs, then it is not necessary to first
+ * move to the left margin before clearing tabs.
+ */
+static bool
+ansi_clear_tabs(void)
+{
+    bool result = FALSE;
+    if (VALID_STRING(clear_all_tabs)) {
+	char *param = skip_csi(clear_all_tabs);
+	if (!strcmp(param, "3g"))
+	    result = TRUE;
+    }
+    return result;
+}
+
 static void
 do_tabs(int *tab_list)
 {
     int last = 1;
     int stop;
+    bool first = TRUE;
 
-    putchar('\r');
     while ((stop = *tab_list++) > 0) {
+	if (first) {
+	    first = FALSE;
+	    putchar('\r');
+	}
 	if (last < stop) {
 	    while (last++ < stop) {
 		if (last > max_cols)
@@ -75,7 +105,7 @@ do_tabs(int *tab_list)
 	    }
 	}
 	if (stop <= max_cols) {
-	    tputs(TIPARM_1(set_tab, stop), 1, putch);
+	    tputs(set_tab, 1, putch);
 	    last = stop;
 	} else {
 	    break;
@@ -84,8 +114,13 @@ do_tabs(int *tab_list)
     putchar('\r');
 }
 
+/*
+ * Decode a list of tab-stops from a string, returning an array of integers.
+ * If the margin is positive (because the terminal does not support margins),
+ * work around this by adding the margin to the decoded values.
+ */
 static int *
-decode_tabs(const char *tab_list)
+decode_tabs(const char *tab_list, int margin)
 {
     int *result = typeCalloc(int, strlen(tab_list) + (unsigned) max_cols);
     int n = 0;
@@ -93,15 +128,20 @@ decode_tabs(const char *tab_list)
     int prior = 0;
     int ch;
 
-    if (result == 0)
+    if (result == NULL)
 	failed("decode_tabs");
 
+    if (margin < 0)
+	margin = 0;
+
     while ((ch = *tab_list++) != '\0') {
 	if (isdigit(UChar(ch))) {
 	    value *= 10;
 	    value += (ch - '0');
+	    if (value > max_cols)
+		value = max_cols;
 	} else if (ch == ',') {
-	    result[n] = value + prior;
+	    result[n] = value + prior + margin;
 	    if (n > 0 && result[n] <= result[n - 1]) {
 		fprintf(stderr,
 			"%s: tab-stops are not in increasing order: %d %d\n",
@@ -127,7 +167,7 @@ decode_tabs(const char *tab_list)
 	    int step = value;
 	    value = 1;
 	    while (n < max_cols - 1) {
-		result[n++] = value;
+		result[n++] = value + margin;
 		value += step;
 	    }
 	}
@@ -135,7 +175,7 @@ decode_tabs(const char *tab_list)
 	/*
 	 * Add the last value, if any.
 	 */
-	result[n++] = value + prior;
+	result[n++] = value + prior + margin;
 	result[n] = 0;
     }
 
@@ -143,10 +183,9 @@ decode_tabs(const char *tab_list)
 }
 
 static void
-print_ruler(int *tab_list)
+print_ruler(const int *const tab_list, const char *new_line)
 {
     int last = 0;
-    int stop;
     int n;
 
     /* first print a readable ruler */
@@ -160,11 +199,12 @@ print_ruler(int *tab_list)
 		     : (ch + 'A' - 10)));
 	printf("%.*s", ((max_cols - n) > 10) ? 10 : (max_cols - n), buffer);
     }
-    putchar('\n');
+    printf("%s", new_line);
 
     /* now, print '*' for each stop */
     for (n = 0, last = 0; (tab_list[n] > 0) && (last < max_cols); ++n) {
-	stop = tab_list[n];
+	int stop = tab_list[n];
+
 	while (++last < stop) {
 	    if (last <= max_cols) {
 		putchar('-');
@@ -181,7 +221,7 @@ print_ruler(int *tab_list)
     }
     while (++last <= max_cols)
 	putchar('-');
-    putchar('\n');
+    printf("%s", new_line);
 }
 
 /*
@@ -189,7 +229,7 @@ print_ruler(int *tab_list)
  * ruler.
  */
 static void
-write_tabs(int *tab_list)
+write_tabs(int *tab_list, const char *new_line)
 {
     int stop;
 
@@ -199,7 +239,7 @@ write_tabs(int *tab_list)
     /* also show a tab _past_ the stops */
     if (stop < max_cols)
 	fputs("\t+", stdout);
-    putchar('\n');
+    fputs(new_line, stdout);
 }
 
 /*
@@ -210,11 +250,11 @@ static char *
 trimmed_tab_list(const char *source)
 {
     char *result = strdup(source);
-    int ch, j, k, last;
-
     if (result != 0) {
+	int j, k, last;
+
 	for (j = k = last = 0; result[j] != 0; ++j) {
-	    ch = UChar(result[j]);
+	    int ch = UChar(result[j]);
 	    if (isspace(ch)) {
 		if (last == '\0') {
 		    continue;
@@ -294,6 +334,66 @@ add_to_tab_list(char **append, const char *value)
     return result;
 }
 
+/*
+ * If the terminal supports it, (re)set the left margin and return true.
+ * Otherwise, return false.
+ */
+static bool
+do_set_margin(int margin, bool no_op)
+{
+    bool result = FALSE;
+
+    if (margin == 0) {		/* 0 is special case for resetting */
+	if (VALID_STRING(clear_margins)) {
+	    result = TRUE;
+	    if (!no_op)
+		tputs(clear_margins, 1, putch);
+	}
+    } else if (margin-- < 0) {	/* margin will be 0-based from here on */
+	result = TRUE;
+    } else if (VALID_STRING(set_left_margin)) {
+	result = TRUE;
+	if (!no_op) {
+	    /*
+	     * assuming we're on the first column of the line, move the cursor
+	     * to the column at which we will set a margin.
+	     */
+	    if (VALID_STRING(column_address)) {
+		tputs(TIPARM_1(column_address, margin), 1, putch);
+	    } else if (margin >= 1) {
+		if (VALID_STRING(parm_right_cursor)) {
+		    tputs(TIPARM_1(parm_right_cursor, margin), 1, putch);
+		} else {
+		    while (margin-- > 0)
+			putch(' ');
+		}
+	    }
+	    tputs(set_left_margin, 1, putch);
+	}
+    }
+#if defined(set_left_margin_parm) && defined(set_right_margin_parm)
+    else if (VALID_STRING(set_left_margin_parm)) {
+	result = TRUE;
+	if (!no_op) {
+	    if (VALID_STRING(set_right_margin_parm)) {
+		tputs(TIPARM_1(set_left_margin_parm, margin), 1, putch);
+	    } else {
+		tputs(TIPARM_2(set_left_margin_parm, margin, max_cols), 1, putch);
+	    }
+	}
+    }
+#endif
+#if defined(set_lr_margin)
+    else if (VALID_STRING(set_lr_margin)) {
+	result = TRUE;
+	if (!no_op) {
+	    tputs(TIPARM_2(set_lr_margin, margin, max_cols), 1, putch);
+	}
+    }
+#endif
+    return result;
+}
+
 /*
  * Check for illegal characters in the tab-list.
  */
@@ -304,9 +404,11 @@ legal_tab_list(const char *tab_list)
 
     if (tab_list != 0 && *tab_list != '\0') {
 	if (comma_is_needed(tab_list)) {
-	    int n, ch;
+	    int n;
+
 	    for (n = 0; tab_list[n] != '\0'; ++n) {
-		ch = UChar(tab_list[n]);
+		int ch = UChar(tab_list[n]);
+
 		if (!(isdigit(ch) || ch == ',' || ch == '+')) {
 		    fprintf(stderr,
 			    "%s: unexpected character found '%c'\n",
@@ -320,8 +422,7 @@ legal_tab_list(const char *tab_list)
 	    result = FALSE;
 	}
     } else {
-	fprintf(stderr, "%s: no tab-list given\n", _nc_progname);
-	result = FALSE;
+	/* if no list given, default to "tabs -8" */
     }
     return result;
 }
@@ -379,17 +480,18 @@ main(int argc, char *argv[])
     int rc = EXIT_FAILURE;
     bool debug = FALSE;
     bool no_op = FALSE;
+    bool change_tty = FALSE;
     int n, ch;
     NCURSES_CONST char *term_name = 0;
     char *append = 0;
     const char *tab_list = 0;
+    const char *new_line = "\n";
+    int margin = -1;
     TTY tty_settings;
     int fd;
 
     _nc_progname = _nc_rootname(argv[0]);
 
-    fd = save_tty_settings(&tty_settings, FALSE);
-
     if ((term_name = getenv("TERM")) == 0)
 	term_name = "ansi+tabs";
 
@@ -481,7 +583,10 @@ main(int argc, char *argv[])
 	    }
 	    break;
 	case '+':
-	    while ((ch = *++option) != '\0') {
+	    if ((ch = *++option) != '\0') {
+		int digits = 0;
+		int number = 0;
+
 		switch (ch) {
 		case 'm':
 		    /*
@@ -489,6 +594,17 @@ main(int argc, char *argv[])
 		     * att510d implements smgl, which is needed to support
 		     * this option.
 		     */
+		    while ((ch = *++option) != '\0') {
+			if (isdigit(UChar(ch))) {
+			    ++digits;
+			    number = number * 10 + (ch - '0');
+			} else {
+			    usage();
+			}
+		    }
+		    if (digits == 0)
+			number = 10;
+		    margin = number;
 		    break;
 		default:
 		    /* special case of relative stops separated by spaces? */
@@ -512,9 +628,13 @@ main(int argc, char *argv[])
 	}
     }
 
+    fd = save_tty_settings(&tty_settings, FALSE);
+
     setupterm(term_name, fd, (int *) 0);
 
     max_cols = (columns > 0) ? columns : 80;
+    if (margin > 0)
+	max_cols -= margin;
 
     if (!VALID_STRING(clear_all_tabs)) {
 	fprintf(stderr,
@@ -525,24 +645,61 @@ main(int argc, char *argv[])
 		"%s: terminal type '%s' cannot set tabs\n",
 		_nc_progname, term_name);
     } else if (legal_tab_list(tab_list)) {
-	int *list = decode_tabs(tab_list);
+	int *list;
+
+	if (tab_list == NULL)
+	    tab_list = add_to_tab_list(&append, "8");
+
+	if (!no_op) {
+#if defined(TERMIOS) && defined(OCRNL)
+	    /* set tty modes to -ocrnl to allow \r */
+	    if (isatty(STDOUT_FILENO)) {
+		TTY new_settings = tty_settings;
+		new_settings.c_oflag &= (unsigned) ~OCRNL;
+		update_tty_settings(&tty_settings, &new_settings);
+		change_tty = TRUE;
+		new_line = "\r\n";
+	    }
+#endif
 
-	if (!no_op)
+	    if (!ansi_clear_tabs())
+		putch('\r');
 	    tputs(clear_all_tabs, 1, putch);
+	}
+
+	if (margin >= 0) {
+	    putch('\r');
+	    if (margin > 0) {
+		/* reset existing margin before setting margin, to reduce
+		 * problems moving left of the current margin.
+		 */
+		if (do_set_margin(0, no_op))
+		    putch('\r');
+	    }
+	    if (do_set_margin(margin, no_op))
+		margin = -1;
+	}
+
+	list = decode_tabs(tab_list, margin);
 
 	if (list != 0) {
 	    if (!no_op)
 		do_tabs(list);
 	    if (debug) {
 		fflush(stderr);
-		printf("tabs %s\n", tab_list);
-		print_ruler(list);
-		write_tabs(list);
+		printf("tabs %s%s", tab_list, new_line);
+		print_ruler(list, new_line);
+		write_tabs(list, new_line);
 	    }
 	    free(list);
 	} else if (debug) {
 	    fflush(stderr);
-	    printf("tabs %s\n", tab_list);
+	    printf("tabs %s%s", tab_list, new_line);
+	}
+	if (!no_op) {
+	    if (change_tty) {
+		restore_tty_settings();
+	    }
 	}
 	rc = EXIT_SUCCESS;
     }
diff --git a/contrib/ncurses/progs/tic.c b/contrib/ncurses/progs/tic.c
index 9b02a23216fa..fc77b34445ff 100644
--- a/contrib/ncurses/progs/tic.c
+++ b/contrib/ncurses/progs/tic.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2023,2024 Thomas E. Dickey                                *
  * Copyright 1998-2017,2018 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -49,7 +49,7 @@
 #include <parametrized.h>
 #include <transform.h>
 
-MODULE_ID("$Id: tic.c,v 1.291 2021/02/20 23:57:24 tom Exp $")
+MODULE_ID("$Id: tic.c,v 1.325 2024/03/02 19:33:22 tom Exp $")
 
 #define STDIN_NAME "<stdin>"
 
@@ -116,8 +116,6 @@ free_namelist(char **src)
 static void
 cleanup(void)
 {
-    int rc;
-
 #if NO_LEAKS
     free_namelist(namelst);
     _nc_leaks_dump_entry();
@@ -125,6 +123,8 @@ cleanup(void)
     if (tmp_fp != 0)
 	fclose(tmp_fp);
     if (to_remove != 0) {
+	int rc;
+
 #if HAVE_REMOVE
 	rc = remove(to_remove);
 #else
@@ -304,15 +304,17 @@ put_translate(int c)
 /* emit a comment char, translating terminfo names to termcap names */
 {
     static bool in_name = FALSE;
-    static size_t have, used;
-    static char *namebuf, *suffix;
+    static size_t used;
 
     if (in_name) {
+	static size_t have;
+	static char *namebuf, *suffix;
+
 	if (used + 1 >= have) {
 	    have += 132;
-	    if ((namebuf = typeRealloc(char, have, namebuf)) == 0)
+	    if ((namebuf = typeRealloc(char, have, namebuf)) == NULL)
 		  failed("put_translate namebuf");
-	    if ((suffix = typeRealloc(char, have, suffix)) == 0)
+	    if ((suffix = typeRealloc(char, have, suffix)) == NULL)
 		  failed("put_translate suffix");
 	}
 	if (c == '\n' || c == '@') {
@@ -371,12 +373,10 @@ stripped(char *src)
 	src++;
 
     if (*src != '\0') {
-	size_t len;
-
 	if ((dst = strdup(src)) == NULL) {
 	    failed("strdup");
 	} else {
-	    len = strlen(dst);
+	    size_t len = strlen(dst);
 	    while (--len != 0 && isspace(UChar(dst[len])))
 		dst[len] = '\0';
 	}
@@ -400,7 +400,7 @@ open_tempfile(char *filename)
     }
 #else
     if (tmpnam(filename) != 0)
-	result = fopen(filename, "w");
+	result = safe_fopen(filename, "w");
 #endif
     return result;
 }
@@ -410,15 +410,15 @@ copy_input(FILE *source, const char *filename, char *alt_file)
 {
     char my_altfile[PATH_MAX];
     FILE *result = 0;
-    FILE *target = 0;
+    FILE *target;
     int ch;
 
-    if (alt_file == 0)
+    if (alt_file == NULL)
 	alt_file = my_altfile;
 
-    if (source == 0) {
+    if (source == NULL) {
 	failed("copy_input (source)");
-    } else if ((target = open_tempfile(alt_file)) == 0) {
+    } else if ((target = open_tempfile(alt_file)) == NULL) {
 	failed("copy_input (target)");
     } else {
 	clearerr(source);
@@ -442,7 +442,7 @@ copy_input(FILE *source, const char *filename, char *alt_file)
 	 * the one that we were writing on before starting to read from the
 	 * second stream.
 	 */
-	result = fopen(alt_file, "r+");
+	result = safe_fopen(alt_file, "r+");
 	fclose(target);
 	to_remove = strdup(alt_file);
     }
@@ -458,18 +458,21 @@ open_input(const char *filename, char *alt_file)
 
     if (!strcmp(filename, "-")) {
 	fp = copy_input(stdin, STDIN_NAME, alt_file);
-    } else if (stat(filename, &sb) < 0) {
-	fprintf(stderr, "%s: %s %s\n", _nc_progname, filename, strerror(errno));
+    } else if (stat(filename, &sb) == -1) {
+	fprintf(stderr, "%s: cannot open '%s': %s\n", _nc_progname,
+		filename, strerror(errno));
 	ExitProgram(EXIT_FAILURE);
     } else if ((mode = (sb.st_mode & S_IFMT)) == S_IFDIR
 	       || (mode != S_IFREG && mode != S_IFCHR && mode != S_IFIFO)) {
-	fprintf(stderr, "%s: %s is not a file\n", _nc_progname, filename);
+	fprintf(stderr, "%s: cannot open '%s'; it is not a file\n",
+		_nc_progname, filename);
 	ExitProgram(EXIT_FAILURE);
     } else {
-	fp = fopen(filename, "r");
+	fp = safe_fopen(filename, "r");
 
-	if (fp == 0) {
-	    fprintf(stderr, "%s: Can't open %s\n", _nc_progname, filename);
+	if (fp == NULL) {
+	    fprintf(stderr, "%s: cannot open '%s': %s\n", _nc_progname,
+		    filename, strerror(errno));
 	    ExitProgram(EXIT_FAILURE);
 	}
 	if (mode != S_IFREG) {
@@ -477,7 +480,8 @@ open_input(const char *filename, char *alt_file)
 		FILE *fp2 = copy_input(fp, filename, alt_file);
 		fp = fp2;
 	    } else {
-		fprintf(stderr, "%s: %s is not a file\n", _nc_progname, filename);
+		fprintf(stderr, "%s: cannot open '%s'; it is not a"
+			" file\n", _nc_progname, filename);
 		ExitProgram(EXIT_FAILURE);
 	    }
 	}
@@ -495,7 +499,7 @@ make_namelist(char *src)
     unsigned pass, n, nn;
     char buffer[BUFSIZ];
 
-    if (src == 0) {
+    if (src == NULL) {
 	/* EMPTY */ ;
     } else if (strchr(src, '/') != 0) {		/* a filename */
 	FILE *fp = open_input(src, (char *) 0);
@@ -512,7 +516,7 @@ make_namelist(char *src)
 		}
 	    }
 	    if (pass == 1) {
-		if ((dst = typeCalloc(char *, nn + 1)) == 0)
+		if ((dst = typeCalloc(char *, nn + 1)) == NULL)
 		      failed("make_namelist");
 		rewind(fp);
 	    }
@@ -536,7 +540,7 @@ make_namelist(char *src)
 		    break;
 	    }
 	    if (pass == 1) {
-		if ((dst = typeCalloc(char *, nn + 1)) == 0)
+		if ((dst = typeCalloc(char *, nn + 1)) == NULL)
 		      failed("make_namelist");
 	    }
 	}
@@ -554,9 +558,10 @@ matches(char **needle, const char *haystack)
 /* does entry in needle list match |-separated field in haystack? */
 {
     bool code = FALSE;
-    size_t n;
 
     if (needle != 0) {
+	size_t n;
+
 	for (n = 0; needle[n] != 0; n++) {
 	    if (_nc_name_match(haystack, needle[n], "|")) {
 		code = TRUE;
@@ -577,7 +582,7 @@ valid_db_path(const char *nominal)
     size_t need = strlen(nominal) + sizeof(suffix);
     char *result = malloc(need);
 
-    if (result == 0)
+    if (result == NULL)
 	failed("valid_db_path");
     _nc_STRCPY(result, nominal, need);
     if (strcmp(result + need - sizeof(suffix), suffix)) {
@@ -642,8 +647,8 @@ show_databases(const char *outdir)
     char *result;
     const char *tried = 0;
 
-    if (outdir == 0) {
-	outdir = _nc_tic_dir(0);
+    if (outdir == NULL) {
+	outdir = _nc_tic_dir(NULL);
     }
     if ((result = valid_db_path(outdir)) != 0) {
 	printf("%s\n", result);
@@ -681,7 +686,6 @@ int
 main(int argc, char *argv[])
 {
     char my_tmpname[PATH_MAX];
-    char my_altfile[PATH_MAX];
     int v_opt = -1;
     int smart_defaults = TRUE;
     char *termcap;
@@ -700,7 +704,7 @@ main(int argc, char *argv[])
     bool forceresolve = FALSE;	/* force resolution */
     bool limited = TRUE;
     char *tversion = (char *) NULL;
-    const char *source_file = "terminfo";
+    const char *source_file;
     char *outdir = (char *) NULL;
     bool check_only = FALSE;
     bool suppress_untranslatable = FALSE;
@@ -722,7 +726,8 @@ main(int argc, char *argv[])
 	sortmode = S_TERMCAP;
     }
 #if NCURSES_XNAMES
-    use_extended_names(FALSE);
+    /* set this directly to avoid interaction with -v and -D options */
+    _nc_user_definable = FALSE;
 #endif
     _nc_strict_bsd = 0;
 
@@ -775,7 +780,7 @@ main(int argc, char *argv[])
 	    break;
 	case 'D':
 	    debug_level = VtoTrace(v_opt);
-	    set_trace_level(debug_level);
+	    use_verbosity(debug_level);
 	    show_databases(outdir);
 	    ExitProgram(EXIT_SUCCESS);
 	    break;
@@ -853,7 +858,6 @@ main(int argc, char *argv[])
 	    _nc_disable_period = TRUE;
 	    /* FALLTHRU */
 	case 'x':
-	    use_extended_names(TRUE);
 	    using_extensions = TRUE;
 	    break;
 #endif
@@ -863,8 +867,23 @@ main(int argc, char *argv[])
 	last_opt = this_opt;
     }
 
+    /*
+     * If the -v option is set, it may override the $NCURSES_TRACE environment
+     * variable, e.g., for -v3 and up.
+     */
     debug_level = VtoTrace(v_opt);
-    set_trace_level(debug_level);
+    use_verbosity(debug_level);
+
+    /*
+     * Do this after setting debug_level, since the function calls START_TRACE,
+     * which uses the $NCURSES_TRACE environment variable if _nc_tracing bits
+     * for tracing are zero.
+     */
+#if NCURSES_XNAMES
+    if (using_extensions) {
+	use_extended_names(TRUE);
+    }
+#endif
 
     if (_nc_tracing) {
 	save_check_termtype = _nc_check_termtype2;
@@ -877,7 +896,7 @@ main(int argc, char *argv[])
      * One problem with immedhook is it means we can't do -e.  Problem
      * is that we can't guarantee that for each terminal listed, all the
      * terminals it depends on will have been kept in core for reference
-     * resolution -- in fact it's certain the primitive types at the end
+     * resolution -- in fact it is certain the primitive types at the end
      * of reference chains *won't* be in core unless they were explicitly
      * in the select list themselves.
      */
@@ -931,7 +950,8 @@ main(int argc, char *argv[])
 	}
     }
 
-    if (tmp_fp == 0) {
+    if (tmp_fp == NULL) {
+	char my_altfile[PATH_MAX];
 	tmp_fp = open_input(source_file, my_altfile);
 	if (!strcmp(source_file, "-")) {
 	    source_file = STDIN_NAME;
@@ -1080,7 +1100,7 @@ main(int argc, char *argv[])
 	if (total != 0)
 	    fprintf(log_fp, "%d entries written to %s\n",
 		    total,
-		    _nc_tic_dir((char *) 0));
+		    _nc_tic_dir(NULL));
 	else
 	    fprintf(log_fp, "No entries written\n");
     }
@@ -1153,6 +1173,7 @@ check_acs(TERMTYPE2 *tp)
 	char *q;
 
 	memset(mapped, 0, sizeof(mapped));
+	memset(missing, 0, sizeof(missing));
 	for (p = acs_chars; *p != '\0'; p += 2) {
 	    if (p[1] == '\0') {
 		_nc_warning("acsc has odd number of characters");
@@ -1217,7 +1238,7 @@ check_colors(TERMTYPE2 *tp)
     char *value;
 
     if ((max_colors > 0) != (max_pairs > 0)
-	|| ((max_colors > max_pairs) && (initialize_pair == 0)))
+	|| ((max_colors > max_pairs) && !VALID_STRING(initialize_pair)))
 	_nc_warning("inconsistent values for max_colors (%d) and max_pairs (%d)",
 		    max_colors, max_pairs);
 
@@ -1306,13 +1327,12 @@ keypad_final(const char *string)
 static long
 keypad_index(const char *string)
 {
-    char *test;
-    const char *list = "PQRSwxymtuvlqrsPpn";	/* app-keypad except "Enter" */
     int ch;
     long result = -1;
 
     if ((ch = keypad_final(string)) != '\0') {
-	test = (strchr) (list, ch);
+	const char *list = "PQRSwxymtuvlqrsPpn";	/* app-keypad except "Enter" */
+	char *test = (strchr) (list, ch);
 	if (test != 0)
 	    result = (long) (test - list);
     }
@@ -1329,18 +1349,15 @@ static void
 check_ansi_cursor(char *list[4])
 {
     int j, k;
-    int want;
-    size_t suffix;
     bool skip[4];
     bool repeated = FALSE;
 
     for (j = 0; j < 4; ++j) {
 	skip[j] = FALSE;
 	for (k = 0; k < j; ++k) {
-	    if (j != k
-		&& !strcmp(list[j], list[k])) {
+	    if (!strcmp(list[j], list[k])) {
 		char *value = _nc_tic_expand(list[k], TRUE, 0);
-		_nc_warning("repeated cursor control %s\n", value);
+		_nc_warning("repeated cursor control %s", value);
 		repeated = TRUE;
 	    }
 	}
@@ -1348,6 +1365,7 @@ check_ansi_cursor(char *list[4])
     if (!repeated) {
 	char *up = list[1];
 	size_t prefix = (size_t) csi_length(up);
+	size_t suffix;
 
 	if (prefix) {
 	    suffix = prefix;
@@ -1362,23 +1380,25 @@ check_ansi_cursor(char *list[4])
 		skip[2] = TRUE;
 
 	    for (j = 0; j < 4; ++j) {
+		int want;
+
 		if (skip[j] || strlen(list[j]) == 1)
 		    continue;
 		if (memcmp(list[j], up, prefix)) {
 		    char *value = _nc_tic_expand(list[j], TRUE, 0);
-		    _nc_warning("inconsistent prefix for %s\n", value);
+		    _nc_warning("inconsistent prefix for %s", value);
 		    continue;
 		}
 		if (strlen(list[j]) < suffix) {
 		    char *value = _nc_tic_expand(list[j], TRUE, 0);
-		    _nc_warning("inconsistent length for %s, expected %d\n",
+		    _nc_warning("inconsistent length for %s, expected %d",
 				value, (int) suffix + 1);
 		    continue;
 		}
 		want = "BADC"[j];
 		if (list[j][suffix] != want) {
 		    char *value = _nc_tic_expand(list[j], TRUE, 0);
-		    _nc_warning("inconsistent suffix for %s, expected %c, have %c\n",
+		    _nc_warning("inconsistent suffix for %s, expected %c, have %c",
 				value, want, list[j][suffix]);
 		}
 	    }
@@ -1411,7 +1431,7 @@ check_cursor(TERMTYPE2 *tp)
 	check_noaddress(tp, "hard_copy");
     } else if (generic_type) {
 	check_noaddress(tp, "generic_type");
-    } else if (strchr(tp->term_names, '+') == 0) {
+    } else if (strchr(tp->term_names, '+') == NULL) {
 	int y = 0;
 	int x = 0;
 	if (PRESENT(column_address))
@@ -1533,9 +1553,7 @@ check_keypad(TERMTYPE2 *tp)
 	char final[MAX_KP + 1];
 	long list[MAX_KP];
 	int increase = 0;
-	int j, k, kk;
-	long last;
-	long test;
+	int j;
 
 	final[0] = keypad_final(key_a1);
 	final[1] = keypad_final(key_a3);
@@ -1568,10 +1586,17 @@ check_keypad(TERMTYPE2 *tp)
 		++increase;
 	    }
 	}
+
 	if (increase != (MAX_KP - 1)) {
+	    long last;
+
 	    show[0] = '\0';
 
 	    for (j = 0, last = -1; j < MAX_KP; ++j) {
+		int k;
+		int kk;
+		long test;
+
 		for (k = 0, kk = -1, test = 100; k < 5; ++k) {
 		    if (list[k] > last &&
 			list[k] < test) {
@@ -1663,20 +1688,10 @@ check_printer(TERMTYPE2 *tp)
     ANDMISSING(start_char_set_def, stop_char_set_def);
 #endif
 
-    /* if we have a parameterized form, then the non-parameterized is easy */
-#if defined(set_bottom_margin_parm) && defined(set_bottom_margin)
-    ANDMISSING(set_bottom_margin_parm, set_bottom_margin);
-#endif
-#if defined(set_left_margin_parm) && defined(set_left_margin)
-    ANDMISSING(set_left_margin_parm, set_left_margin);
-#endif
-#if defined(set_right_margin_parm) && defined(set_right_margin)
-    ANDMISSING(set_right_margin_parm, set_right_margin);
-#endif
-#if defined(set_top_margin_parm) && defined(set_top_margin)
-    ANDMISSING(set_top_margin_parm, set_top_margin);
-#endif
-
+    /*
+     * If we have a parameterized form, then the non-parameterized is easy.
+     * note: parameterized/non-parameterized margin settings are unrelated.
+     */
 #if defined(parm_down_micro) && defined(micro_down)
     ANDMISSING(parm_down_micro, micro_down);
 #endif
@@ -1715,7 +1730,7 @@ check_screen(TERMTYPE2 *tp)
 	char *name = _nc_first_name(tp->term_names);
 	bool is_screen = !strncmp(name, "screen", 6);
 	bool screen_base = (is_screen
-			    && strchr(name, '.') == 0);
+			    && strchr(name, '.') == NULL);
 
 	if (!VALID_BOOLEAN(have_bce)) {
 	    have_bce = FALSE;
@@ -1745,6 +1760,8 @@ check_screen(TERMTYPE2 *tp)
 	} else if (have_XT && screen_base) {
 	    _nc_warning("screen's \"screen\" entries should not have XT set");
 	} else if (have_XT) {
+	    char *s;
+
 	    if (!have_kmouse && is_screen) {
 		if (VALID_STRING(key_mouse)) {
 		    _nc_warning("value of kmous inconsistent with screen's usage");
@@ -1760,12 +1777,14 @@ check_screen(TERMTYPE2 *tp)
 				"to have 39/49 parameters", name_39_49);
 		}
 	    }
-	    if (VALID_STRING(to_status_line))
+	    if (VALID_STRING(to_status_line)
+		&& (s = strchr(to_status_line, ';')) != NULL
+		&& *++s == '\0')
 		_nc_warning("\"tsl\" capability is redundant, given XT");
 	} else {
 	    if (have_kmouse
 		&& !have_XM
-		&& !screen_base && strchr(name, '+') == 0) {
+		&& !screen_base && strchr(name, '+') == NULL) {
 		_nc_warning("expected XT to be set, given kmous");
 	    }
 	}
@@ -1916,23 +1935,82 @@ is_user_capability(const char *name)
     return result;
 }
 
+static bool
+line_capability(const char *name)
+{
+    bool result = FALSE;
+    static const char *table[] =
+    {
+	"csr",			/* change_scroll_region          */
+	"clear",		/* clear_screen                  */
+	"ed",			/* clr_eos                       */
+	"cwin",			/* create_window                 */
+	"cup",			/* cursor_address                */
+	"cud1",			/* cursor_down                   */
+	"home",			/* cursor_home                   */
+	"mrcup",		/* cursor_mem_address            */
+	"ll",			/* cursor_to_ll                  */
+	"cuu1",			/* cursor_up                     */
+	"dl1",			/* delete_line                   */
+	"hd",			/* down_half_line                */
+	"flash",		/* flash_screen                  */
+	"ff",			/* form_feed                     */
+	"il1",			/* insert_line                   */
+	"nel",			/* newline                       */
+	"dl",			/* parm_delete_line              */
+	"cud",			/* parm_down_cursor              */
+	"indn",			/* parm_index                    */
+	"il",			/* parm_insert_line              */
+	"rin",			/* parm_rindex                   */
+	"cuu",			/* parm_up_cursor                */
+	"mc0",			/* print_screen                  */
+	"vpa",			/* row_address                   */
+	"ind",			/* scroll_forward                */
+	"ri",			/* scroll_reverse                */
+	"hu",			/* up_half_line                  */
+    };
+    size_t n;
+    for (n = 0; n < SIZEOF(table); ++n) {
+	if (!strcmp(name, table[n])) {
+	    result = TRUE;
+	    break;
+	}
+    }
+    return result;
+}
+
 /*
  * Make a quick sanity check for the parameters which are used in the given
  * strings.  If there are no "%p" tokens, then there should be no other "%"
  * markers.
  */
 static void
-check_params(TERMTYPE2 *tp, const char *name, char *value, int extended)
+check_params(TERMTYPE2 *tp, const char *name, const char *value, int extended)
 {
     int expected = expected_params(name);
     int actual = 0;
     int n;
     bool params[1 + NUM_PARM];
-    char *s = value;
+    const char *s = value;
 
+#ifdef set_left_margin_parm
+    if (!strcmp(name, "smgrp")
+	&& !VALID_STRING(set_left_margin_parm))
+	expected = 2;
+#endif
+#ifdef set_right_margin_parm
+    if (!strcmp(name, "smglp")
+	&& !VALID_STRING(set_right_margin_parm))
+	expected = 2;
+#endif
 #ifdef set_top_margin_parm
     if (!strcmp(name, "smgbp")
-	&& set_top_margin_parm == 0)
+	&& !VALID_STRING(set_top_margin_parm))
+	expected = 2;
+#endif
+#ifdef set_bottom_margin_parm
+    if (!strcmp(name, "smgtp")
+	&& !VALID_STRING(set_bottom_margin_parm))
 	expected = 2;
 #endif
 
@@ -1994,10 +2072,11 @@ check_params(TERMTYPE2 *tp, const char *name, char *value, int extended)
      * may not have been fully translated.  Also, tparm does its own analysis.
      * Report differences here.
      */
+    _nc_reset_tparm(NULL);
     if (actual >= 0) {
 	char *p_is_s[NUM_PARM];
 	int popcount;
-	int analyzed = _nc_tparm_analyze(value, p_is_s, &popcount);
+	int analyzed = _nc_tparm_analyze(NULL, value, p_is_s, &popcount);
 	if (analyzed < popcount) {
 	    analyzed = popcount;
 	}
@@ -2015,54 +2094,37 @@ check_params(TERMTYPE2 *tp, const char *name, char *value, int extended)
 		_nc_warning("tparm analyzed %d parameters for %s, expected %d",
 			    analyzed, name, actual);
 	    }
+	} else if (expected > 0
+		   && actual == expected
+		   && guess_tparm_type(expected, p_is_s) == Numbers) {
+	    int limit = 1;
+
+	    if (!strcmp(name, "setf")
+		|| !strcmp(name, "setb")
+		|| !strcmp(name, "setaf")
+		|| !strcmp(name, "setab")) {
+		if ((limit = max_colors) > 256)
+		    limit = 256;
+	    } else if (line_capability(name)) {
+		limit = 24;
+	    } else if (is_user_capability(name) < 0) {
+		limit = 80;
+	    }
+	    for (n = 0; n < limit; ++n) {
+		_nc_reset_tparm(NULL);
+		(void) TPARM_9(value, n, n, n, n, n, n, n, n, n);
+		if (_nc_tparm_err) {
+		    _nc_warning("problem%s in tparm(%s, %d, ...)",
+				(_nc_tparm_err == 1) ? "" : "s",
+				name, n);
+		    if (debug_level < 2)
+			break;
+		}
+	    }
 	}
     }
 }
 
-static bool
-line_capability(const char *name)
-{
-    bool result = FALSE;
-    static const char *table[] =
-    {
-	"csr",			/* change_scroll_region          */
-	"clear",		/* clear_screen                  */
-	"ed",			/* clr_eos                       */
-	"cwin",			/* create_window                 */
-	"cup",			/* cursor_address                */
-	"cud1",			/* cursor_down                   */
-	"home",			/* cursor_home                   */
-	"mrcup",		/* cursor_mem_address            */
-	"ll",			/* cursor_to_ll                  */
-	"cuu1",			/* cursor_up                     */
-	"dl1",			/* delete_line                   */
-	"hd",			/* down_half_line                */
-	"flash",		/* flash_screen                  */
-	"ff",			/* form_feed                     */
-	"il1",			/* insert_line                   */
-	"nel",			/* newline                       */
-	"dl",			/* parm_delete_line              */
-	"cud",			/* parm_down_cursor              */
-	"indn",			/* parm_index                    */
-	"il",			/* parm_insert_line              */
-	"rin",			/* parm_rindex                   */
-	"cuu",			/* parm_up_cursor                */
-	"mc0",			/* print_screen                  */
-	"vpa",			/* row_address                   */
-	"ind",			/* scroll_forward                */
-	"ri",			/* scroll_reverse                */
-	"hu",			/* up_half_line                  */
-    };
-    size_t n;
-    for (n = 0; n < SIZEOF(table); ++n) {
-	if (!strcmp(name, table[n])) {
-	    result = TRUE;
-	    break;
-	}
-    }
-    return result;
-}
-
 /*
  * Check for DEC VT100 private mode for reverse video.
  */
@@ -2097,7 +2159,6 @@ check_delays(TERMTYPE2 *tp, const char *name, const char *value)
 	if (p[0] == '$' && p[1] == '<') {
 	    const char *base = p + 2;
 	    const char *mark = 0;
-	    bool maybe = TRUE;
 	    bool mixed = FALSE;
 	    int proportional = 0;
 	    int mandatory = 0;
@@ -2106,7 +2167,7 @@ check_delays(TERMTYPE2 *tp, const char *name, const char *value)
 
 	    for (q = base; *q != '\0'; ++q) {
 		if (*q == '>') {
-		    if (mark == 0)
+		    if (mark == NULL)
 			mark = q;
 		    break;
 		} else if (*q == '*' || *q == '/') {
@@ -2114,23 +2175,20 @@ check_delays(TERMTYPE2 *tp, const char *name, const char *value)
 			++proportional;
 		    if (*q == '/')
 			++mandatory;
-		    if (mark == 0)
+		    if (mark == NULL)
 			mark = q;
 		} else if (!(isalnum(UChar(*q)) || strchr("+-.", *q) != 0)) {
-		    maybe = FALSE;
 		    break;
 		} else if (proportional || mandatory) {
 		    mixed = TRUE;
 		}
 	    }
 	    last = *q ? (q + 1) : q;
-	    if (*q == '\0') {
-		maybe = FALSE;	/* just an isolated "$<" */
-	    } else if (maybe) {
+	    if (*q != '\0') {
 		float check_f;
 		char check_c;
 		int rc = sscanf(base, "%f%c", &check_f, &check_c);
-		if ((rc != 2) || (check_c != *mark) || mixed) {
+		if ((rc != 2) || (mark != NULL && (check_c != *mark)) || mixed) {
 		    _nc_warning("syntax error in %s delay '%.*s'", name,
 				(int) (q - base), base);
 		} else if (*name == 'k') {
@@ -2139,7 +2197,7 @@ check_delays(TERMTYPE2 *tp, const char *name, const char *value)
 		    _nc_warning("non-line capability using proportional delay: %s", name);
 		} else if (!xon_xoff &&
 			   !mandatory &&
-			   strchr(_nc_first_name(tp->term_names), '+') == 0) {
+			   strchr(_nc_first_name(tp->term_names), '+') == NULL) {
 		    _nc_warning("%s in %s is used since no xon/xoff",
 				(proportional
 				 ? "proportional delay"
@@ -2171,7 +2229,7 @@ check_delays(TERMTYPE2 *tp, const char *name, const char *value)
 	     */
 	    if ((p = skip_DECSCNM(value, &flag)) != 0 &&
 		flag > 0 &&
-		(q = skip_DECSCNM(p, &flag)) != 0 &&
+		skip_DECSCNM(p, &flag) != 0 &&
 		flag == 0) {
 		_nc_warning("expected a delay in %s", name);
 	    }
@@ -2204,8 +2262,9 @@ check_1_infotocap(const char *name, NCURSES_CONST char *value, int count)
 	next += strlen(next) + 1;
     }
 
+    _nc_reset_tparm(NULL);
     expect = tparm_type(name);
-    nparam = _nc_tparm_analyze(value, p_is_s, &ignored);
+    nparam = _nc_tparm_analyze(NULL, value, p_is_s, &ignored);
     actual = guess_tparm_type(nparam, p_is_s);
 
     if (expect != actual) {
@@ -2213,10 +2272,17 @@ check_1_infotocap(const char *name, NCURSES_CONST char *value, int count)
 	actual = Other;
     }
 
+    _nc_reset_tparm(NULL);
     switch (actual) {
+    case Str:
+	result = TPARM_1(value, strings[1]);
+	break;
     case Num_Str:
 	result = TPARM_2(value, numbers[1], strings[2]);
 	break;
+    case Str_Str:
+	result = TPARM_2(value, strings[1], strings[2]);
+	break;
     case Num_Str_Str:
 	result = TPARM_3(value, numbers[1], strings[2], strings[3]);
 	break;
@@ -2277,7 +2343,7 @@ parse_delay_value(const char *src, double *delays, int *always)
 	}
     }
     while (*src == '*' || *src == '/') {
-	if (always == 0 && *src == '/')
+	if (always == NULL && *src == '/')
 	    break;
 	if (*src++ == '*') {
 	    star = 1;
@@ -2378,58 +2444,62 @@ static void
 check_infotocap(TERMTYPE2 *tp, int i, const char *value)
 {
     const char *name = ExtStrname(tp, i, strnames);
-    int params = ((i < (int) SIZEOF(parametrized))
-		  ? parametrized[i]
-		  : ((*value == 'k')
-		     ? 0
-		     : has_params(value, FALSE)));
-    char *ti_value;
-    char *tc_value;
-    bool embedded;
+    char *ti_value = NULL;
 
     assert(SIZEOF(parametrized) == STRCOUNT);
     if (!VALID_STRING(value) || (ti_value = strdup(value)) == NULL) {
 	_nc_warning("tic-expansion of %s failed", name);
-    } else if ((tc_value = _nc_infotocap(name, ti_value, params)) == ABSENT_STRING) {
-	_nc_warning("tic-conversion of %s failed", name);
-    } else if (params > 0) {
-	int limit = 5;
-	int count;
-	bool first = TRUE;
-
-	if (!strcmp(name, "setf")
-	    || !strcmp(name, "setb")
-	    || !strcmp(name, "setaf")
-	    || !strcmp(name, "setab")) {
-	    if ((limit = max_colors) > 16)
-		limit = 16;
-	}
-	for (count = 0; count < limit; ++count) {
-	    char *ti_check = check_1_infotocap(name, ti_value, count);
-	    char *tc_check = check_1_infotocap(name, tc_value, count);
-
-	    if (strcmp(ti_check, tc_check)) {
-		if (first) {
-		    fprintf(stderr, "check_infotocap(%s)\n", name);
-		    fprintf(stderr, "...ti '%s'\n", _nc_visbuf2(0, ti_value));
-		    fprintf(stderr, "...tc '%s'\n", _nc_visbuf2(0, tc_value));
-		    first = FALSE;
+    } else {
+	char *tc_value;
+	bool embedded;
+	int params = ((i < (int) SIZEOF(parametrized))
+		      ? parametrized[i]
+		      : ((*value == 'k')
+			 ? 0
+			 : has_params(value, FALSE)));
+
+	if ((tc_value = _nc_infotocap(name, ti_value, params)) == ABSENT_STRING) {
+	    _nc_warning("tic-conversion of %s failed", name);
+	} else if (params > 0) {
+	    int limit = 5;
+	    int count;
+	    bool first = TRUE;
+
+	    if (!strcmp(name, "setf")
+		|| !strcmp(name, "setb")
+		|| !strcmp(name, "setaf")
+		|| !strcmp(name, "setab")) {
+		if ((limit = max_colors) > 256)
+		    limit = 256;
+	    }
+	    for (count = 0; count < limit; ++count) {
+		char *ti_check = check_1_infotocap(name, ti_value, count);
+		char *tc_check = check_1_infotocap(name, tc_value, count);
+
+		if (strcmp(ti_check, tc_check)) {
+		    if (first) {
+			fprintf(stderr, "check_infotocap(%s)\n", name);
+			fprintf(stderr, "...ti '%s'\n", _nc_visbuf2(0, ti_value));
+			fprintf(stderr, "...tc '%s'\n", _nc_visbuf2(0, tc_value));
+			first = FALSE;
+		    }
+		    _nc_warning("tparm-conversion of %s(%d) differs between\n\tterminfo %s\n\ttermcap  %s",
+				name, count,
+				_nc_visbuf2(0, ti_check),
+				_nc_visbuf2(1, tc_check));
 		}
-		_nc_warning("tparm-conversion of %s(%d) differs between\n\tterminfo %s\n\ttermcap  %s",
-			    name, count,
-			    _nc_visbuf2(0, ti_check),
-			    _nc_visbuf2(1, tc_check));
+		free(ti_check);
+		free(tc_check);
+	    }
+	} else if (params == 0 && !same_ti_tc(ti_value, tc_value, &embedded)) {
+	    if (embedded) {
+		_nc_warning("termcap equivalent of %s cannot use embedded delay", name);
+	    } else {
+		_nc_warning("tic-conversion of %s changed value\n\tfrom %s\n\tto   %s",
+			    name, ti_value, tc_value);
 	    }
-	    free(ti_check);
-	    free(tc_check);
-	}
-    } else if (params == 0 && !same_ti_tc(ti_value, tc_value, &embedded)) {
-	if (embedded) {
-	    _nc_warning("termcap equivalent of %s cannot use embedded delay", name);
-	} else {
-	    _nc_warning("tic-conversion of %s changed value\n\tfrom %s\n\tto   %s",
-			name, ti_value, tc_value);
 	}
+	free(ti_value);
     }
 }
 
@@ -2633,7 +2703,7 @@ get_fkey_list(TERMTYPE2 *tp)
     int used = 0;
     unsigned j;
 
-    if (result == 0)
+    if (result == NULL)
 	failed("get_fkey_list");
 
     for (j = 0; all_fkeys[j].code; j++) {
@@ -2679,14 +2749,13 @@ show_fkey_name(NAME_VALUE * data)
 static void
 check_conflict(TERMTYPE2 *tp)
 {
-    bool conflict = FALSE;
-    unsigned j, k;
-
     if (!(_nc_syntax == SYN_TERMCAP && capdump)) {
 	char *check = calloc((size_t) (NUM_STRINGS(tp) + 1), sizeof(char));
 	NAME_VALUE *given = get_fkey_list(tp);
+	unsigned j, k;
+	bool conflict = FALSE;
 
-	if (check == 0)
+	if (check == NULL)
 	    failed("check_conflict");
 
 	for (j = 0; given[j].keycode; ++j) {
@@ -2936,6 +3005,190 @@ check_user_capability_type(const char *name, int actual)
 }
 #endif
 
+#define IN_DELAY "0123456789*/."
+
+static bool
+check_ANSI_cap(const char *value, int nparams, char final)
+{
+    bool result = FALSE;
+    if (VALID_STRING(value) && csi_length(value) > 0) {
+	char *p_is_s[NUM_PARM];
+	int popcount;
+	int analyzed = _nc_tparm_analyze(NULL, value, p_is_s, &popcount);
+	if (analyzed < popcount) {
+	    analyzed = popcount;
+	}
+	if (analyzed == nparams) {
+	    bool numbers = TRUE;
+	    int p;
+	    for (p = 0; p < nparams; ++p) {
+		if (p_is_s[p]) {
+		    numbers = FALSE;
+		    break;
+		}
+	    }
+	    if (numbers) {
+		int in_delay = 0;
+		p = (int) strlen(value);
+		while (p-- > 0) {
+		    char ch = value[p];
+		    if (ch == final) {
+			result = TRUE;
+			break;
+		    }
+		    switch (in_delay) {
+		    case 0:
+			if (ch == '>')
+			    in_delay = 1;
+			break;
+		    case 1:
+			if (strchr(IN_DELAY, value[p]) != NULL)
+			    break;
+			if (ch != '<')
+			    p = 0;
+			in_delay = 2;
+			break;
+		    case 2:
+			if (ch != '$')
+			    p = 0;
+			in_delay = 0;
+			break;
+		    }
+		}
+	    }
+	}
+    }
+    return result;
+}
+
+static const char *
+skip_Delay(const char *value)
+{
+    const char *result = value;
+
+    if (*value == '$') {
+	++result;
+	if (*result++ == '<') {
+	    while (strchr(IN_DELAY, *result) != NULL)
+		++result;
+	    if (*result++ != '>') {
+		result = value;
+	    }
+	} else {
+	    result = value;
+	}
+    }
+    return result;
+}
+
+static bool
+isValidString(const char *value, const char *expect)
+{
+    bool result = FALSE;
+    if (VALID_STRING(value)) {
+	if (!strcmp(value, expect))
+	    result = TRUE;
+    }
+    return result;
+}
+
+static bool
+isValidEscape(const char *value, const char *expect)
+{
+    bool result = FALSE;
+    if (VALID_STRING(value)) {
+	if (*value == '\033') {
+	    size_t need = strlen(expect);
+	    size_t have = strlen(value) - 1;
+	    if (have >= need && !strncmp(value + 1, expect, need)) {
+		if (*skip_Delay(value + need + 1) == '\0') {
+		    result = TRUE;
+		}
+	    }
+	}
+    }
+    return result;
+}
+
+static int
+guess_ANSI_VTxx(TERMTYPE2 *tp)
+{
+    int result = -1;
+    int checks = 0;
+
+    /* VT100s have scrolling region, but ANSI (ECMA-48) does not specify */
+    if (check_ANSI_cap(change_scroll_region, 2, 'r') &&
+	(isValidEscape(scroll_forward, "D") ||
+	 isValidString(scroll_forward, "\n") ||
+	 isValidEscape(scroll_forward, "6")) &&
+	(isValidEscape(scroll_reverse, "M") ||
+	 isValidEscape(scroll_reverse, "9"))) {
+	checks |= 2;
+    }
+    if (check_ANSI_cap(cursor_address, 2, 'H') &&
+	check_ANSI_cap(cursor_up, 0, 'A') &&
+	(check_ANSI_cap(cursor_down, 0, 'B') ||
+	 isValidString(cursor_down, "\n")) &&
+	check_ANSI_cap(cursor_right, 0, 'C') &&
+	(check_ANSI_cap(cursor_left, 0, 'D') ||
+	 isValidString(cursor_left, "\b")) &&
+	check_ANSI_cap(clr_eos, 0, 'J') &&
+	check_ANSI_cap(clr_bol, 0, 'K') &&
+	check_ANSI_cap(clr_eol, 0, 'K')) {
+	checks |= 1;
+    }
+    if (checks == 3)
+	result = 1;
+    if (checks == 1)
+	result = 0;
+    return result;
+}
+
+/*
+ * u6/u7 and u8/u9 are query/response extensions which most terminals support.
+ * In particular, any ECMA-48 terminal should support these, though the details
+ * for u9 are implementation dependent.
+ */
+#if defined(user6) && defined(user7) && defined(user8) && defined(user9)
+static void
+check_user_6789(TERMTYPE2 *tp)
+{
+    /*
+     * Check if the terminal is known to not 
+     */
+#define NO_QUERY(longname,shortname) \
+	if (PRESENT(longname)) _nc_warning(#shortname " is not supported")
+    if (tigetflag("NQ") > 0) {
+	NO_QUERY(user6, u6);
+	NO_QUERY(user7, u7);
+	NO_QUERY(user8, u8);
+	NO_QUERY(user9, u9);
+	return;
+    }
+
+    PAIRED(user6, user7);
+    PAIRED(user8, user9);
+
+    if (strchr(tp->term_names, '+') != NULL)
+	return;
+
+    switch (guess_ANSI_VTxx(tp)) {
+    case 1:
+	if (!PRESENT(user8)) {
+	    _nc_warning("expected u8/u9 for device-attributes");
+	}
+	/* FALLTHRU */
+    case 0:
+	if (!PRESENT(user6)) {
+	    _nc_warning("expected u6/u7 for cursor-position");
+	}
+	break;
+    }
+}
+#else
+#define check_user_6789(tp)	/* nothing */
+#endif
+
 /* other sanity-checks (things that we don't want in the normal
  * logic that reads a terminfo entry)
  */
@@ -2984,6 +3237,7 @@ check_termtype(TERMTYPE2 *tp, bool literal)
     check_keypad(tp);
     check_printer(tp);
     check_screen(tp);
+    check_user_6789(tp);
 
     /*
      * These are probably both or none.
@@ -3049,7 +3303,7 @@ check_termtype(TERMTYPE2 *tp, bool literal)
     if (PRESENT(exit_attribute_mode)) {
 	char *check_sgr0 = _nc_trim_sgr0(tp);
 
-	if (check_sgr0 == 0 || *check_sgr0 == '\0') {
+	if (check_sgr0 == NULL || *check_sgr0 == '\0') {
 	    _nc_warning("trimmed sgr0 is empty");
 	} else {
 	    show_where(2);
diff --git a/contrib/ncurses/progs/toe.c b/contrib/ncurses/progs/toe.c
index f3856f049c11..ecbfd53b5a08 100644
--- a/contrib/ncurses/progs/toe.c
+++ b/contrib/ncurses/progs/toe.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
  * Copyright 1998-2013,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -45,7 +45,7 @@
 #include <hashed_db.h>
 #endif
 
-MODULE_ID("$Id: toe.c,v 1.79 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: toe.c,v 1.89 2023/07/01 17:04:46 tom Exp $")
 
 #define isDotname(name) (!strcmp(name, ".") || !strcmp(name, ".."))
 
@@ -64,7 +64,7 @@ static size_t len_termdata;	/* allocated size of ptr_termdata[] */
 
 #if NO_LEAKS
 #undef ExitProgram
-static void ExitProgram(int code) GCC_NORETURN;
+static GCC_NORETURN void ExitProgram(int code);
 static void
 ExitProgram(int code)
 {
@@ -73,7 +73,7 @@ ExitProgram(int code)
 }
 #endif
 
-static void failed(const char *) GCC_NORETURN;
+static GCC_NORETURN void failed(const char *);
 
 static void
 failed(const char *msg)
@@ -127,12 +127,15 @@ compare_termdata(const void *a, const void *b)
 static void
 show_termdata(int eargc, char **eargv)
 {
-    int j, k;
-    size_t n;
-
     if (use_termdata) {
+	size_t n;
+
 	if (eargc > 1) {
+	    int j;
+
 	    for (j = 0; j < eargc; ++j) {
+		int k;
+
 		for (k = 0; k <= j; ++k) {
 		    printf("--");
 		}
@@ -143,14 +146,20 @@ show_termdata(int eargc, char **eargv)
 	if (use_termdata > 1)
 	    qsort(ptr_termdata, use_termdata, sizeof(TERMDATA), compare_termdata);
 	for (n = 0; n < use_termdata; ++n) {
+	    int nk = -1;
 
 	    /*
 	     * If there is more than one database, show how they differ.
 	     */
 	    if (eargc > 1) {
 		unsigned long check = 0;
-		k = 0;
+		int k = 0;
 		for (;;) {
+		    char mark = ((check == 0
+				  || (check != ptr_termdata[n].checksum))
+				 ? '*'
+				 : '+');
+
 		    for (; k < ptr_termdata[n].db_index; ++k) {
 			printf("--");
 		    }
@@ -160,11 +169,10 @@ show_termdata(int eargc, char **eargv)
 		     * from the first entry's checksum, print "*". Otherwise
 		     * it looks enough like a duplicate to print "+".
 		     */
-		    printf("%c-", ((check == 0
-				    || (check != ptr_termdata[n].checksum))
-				   ? '*'
-				   : '+'));
+		    printf("%c-", mark);
 		    check = ptr_termdata[n].checksum;
+		    if (mark == '*' && nk < 0)
+			nk = (int) n;
 
 		    ++k;
 		    if ((n + 1) >= use_termdata
@@ -179,10 +187,12 @@ show_termdata(int eargc, char **eargv)
 		}
 		printf(":\t");
 	    }
+	    if (nk < 0)
+		nk = (int) n;
 
 	    (void) printf("%-10s\t%s\n",
 			  ptr_termdata[n].term_name,
-			  ptr_termdata[n].description);
+			  ptr_termdata[nk].description);
 	}
     }
 }
@@ -242,7 +252,9 @@ make_db_name(char *dst, const char *src, unsigned limit)
 	    && !strcmp(src + size - lens, suffix)) {
 	    _nc_STRCPY(dst, src, PATH_MAX);
 	} else {
-	    _nc_SPRINTF(dst, _nc_SLIMIT(PATH_MAX) "%s%s", src, suffix);
+	    _nc_SPRINTF(dst, _nc_SLIMIT(PATH_MAX) "%.*s%s",
+			(int) (PATH_MAX - sizeof(suffix)),
+			src, suffix);
 	}
 	result = TRUE;
     }
@@ -325,6 +337,26 @@ sorthook(int db_index, int db_limit, const char *term_name, TERMTYPE2 *tp)
 }
 
 #if NCURSES_USE_TERMCAP
+/*
+ * Check if the buffer contents are printable ASCII, ensuring that we do not
+ * accidentally pick up incompatible binary content from a hashed database.
+ */
+static bool
+is_termcap(char *buffer)
+{
+    bool result = TRUE;
+    while (*buffer != '\0') {
+	int ch = UChar(*buffer++);
+	if (ch == '\t')
+	    continue;
+	if (ch < ' ' || ch > '~') {
+	    result = FALSE;
+	    break;
+	}
+    }
+    return result;
+}
+
 static void
 show_termcap(int db_index, int db_limit, char *buffer, DescHook hook)
 {
@@ -513,11 +545,13 @@ typelist(int eargc, char *eargv[],
 	    db_array[1] = 0;
 
 	    if (cgetfirst(&buffer, db_array) > 0) {
-		show_termcap(i, eargc, buffer, hook);
-		free(buffer);
-		while (cgetnext(&buffer, db_array) > 0) {
+		if (is_termcap(buffer)) {
 		    show_termcap(i, eargc, buffer, hook);
 		    free(buffer);
+		    while (cgetnext(&buffer, db_array) > 0) {
+			show_termcap(i, eargc, buffer, hook);
+			free(buffer);
+		    }
 		}
 		cgetclose();
 		continue;
@@ -532,11 +566,13 @@ typelist(int eargc, char *eargv[],
 	    if (verbosity)
 		(void) printf("#\n#%s:\n#\n", eargv[i]);
 
-	    if ((fp = fopen(eargv[i], "r")) != 0) {
+	    if ((fp = safe_fopen(eargv[i], "r")) != 0) {
 		while (fgets(buffer, sizeof(buffer), fp) != 0) {
+		    if (!is_termcap(buffer))
+			break;
 		    if (*buffer == '#')
 			continue;
-		    if (isspace(*buffer))
+		    if (isspace(UChar(*buffer)))
 			continue;
 		    show_termcap(i, eargc, buffer, hook);
 		}
@@ -570,7 +606,6 @@ main(int argc, char *argv[])
     bool invert_dependencies = FALSE;
     bool header = FALSE;
     char *report_file = 0;
-    unsigned i;
     int code;
     int this_opt, last_opt = '?';
     unsigned v_opt = 0;
@@ -623,7 +658,7 @@ main(int argc, char *argv[])
 	    usage();
 	}
     }
-    set_trace_level(v_opt);
+    use_verbosity(v_opt);
 
     if (report_file != 0) {
 	if (freopen(report_file, "r", stdin) == 0) {
@@ -658,11 +693,13 @@ main(int argc, char *argv[])
     /* maybe we want a reverse-dependency listing? */
     if (invert_dependencies) {
 	ENTRY *qp, *rp;
-	int matchcount;
 
 	for_entry_list(qp) {
-	    matchcount = 0;
+	    int matchcount = 0;
+
 	    for_entry_list(rp) {
+		unsigned i;
+
 		if (rp->nuses == 0)
 		    continue;
 
@@ -692,12 +729,12 @@ main(int argc, char *argv[])
 	DBDIRS state;
 	int offset;
 	int pass;
-	const char *path;
 	char **eargv = 0;
 
 	code = EXIT_FAILURE;
 	for (pass = 0; pass < 2; ++pass) {
 	    size_t count = 0;
+	    const char *path;
 
 	    _nc_first_db(&state, &offset);
 	    while ((path = _nc_next_db(&state, &offset)) != 0) {
diff --git a/contrib/ncurses/progs/tparm_type.c b/contrib/ncurses/progs/tparm_type.c
index 3da4a0774af5..4fed96a53440 100644
--- a/contrib/ncurses/progs/tparm_type.c
+++ b/contrib/ncurses/progs/tparm_type.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
  * Copyright 2014,2015 Free Software Foundation, Inc.                       *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -33,7 +33,7 @@
 
 #include <tparm_type.h>
 
-MODULE_ID("$Id: tparm_type.c,v 1.4 2020/10/24 17:30:32 tom Exp $")
+MODULE_ID("$Id: tparm_type.c,v 1.5 2023/04/08 15:57:01 tom Exp $")
 
 /*
  * Lookup the type of call we should make to tparm().  This ignores the actual
@@ -47,6 +47,7 @@ tparm_type(const char *name)
     	{code, {longname} }, \
 	{code, {ti} }, \
 	{code, {tc} }
+#define XD(code, onlyname) TD(code, onlyname, onlyname, onlyname)
     TParams result = Numbers;
     /* *INDENT-OFF* */
     static const struct {
@@ -58,6 +59,10 @@ tparm_type(const char *name)
 	TD(Num_Str,	"pkey_xmit",	"pfx",		"px"),
 	TD(Num_Str,	"plab_norm",	"pln",		"pn"),
 	TD(Num_Str_Str, "pkey_plab",	"pfxl",		"xl"),
+#if NCURSES_XNAMES
+	XD(Str,		"Cs"),
+	XD(Str_Str,	"Ms"),
+#endif
     };
     /* *INDENT-ON* */
 
@@ -80,12 +85,16 @@ guess_tparm_type(int nparam, char **p_is_s)
     case 1:
 	if (!p_is_s[0])
 	    result = Numbers;
+	if (p_is_s[0])
+	    result = Str;
 	break;
     case 2:
 	if (!p_is_s[0] && !p_is_s[1])
 	    result = Numbers;
 	if (!p_is_s[0] && p_is_s[1])
 	    result = Num_Str;
+	if (p_is_s[0] && p_is_s[1])
+	    result = Str_Str;
 	break;
     case 3:
 	if (!p_is_s[0] && !p_is_s[1] && !p_is_s[2])
diff --git a/contrib/ncurses/progs/tparm_type.h b/contrib/ncurses/progs/tparm_type.h
index 7c102a309c1a..2f7bd0771d53 100644
--- a/contrib/ncurses/progs/tparm_type.h
+++ b/contrib/ncurses/progs/tparm_type.h
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2023 Thomas E. Dickey                                     *
  * Copyright 2014 Free Software Foundation, Inc.                            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -32,7 +32,7 @@
  ****************************************************************************/
 
 /*
- * $Id: tparm_type.h,v 1.3 2020/10/24 17:11:33 tom Exp $
+ * $Id: tparm_type.h,v 1.4 2023/04/08 15:41:20 tom Exp $
  *
  * determine expected/actual number of parameters to setup for tparm
  */
@@ -45,8 +45,10 @@
 typedef enum {
     Other = -1
     ,Numbers = 0
+    ,Str
     ,Num_Str
     ,Num_Str_Str
+    ,Str_Str
 } TParams;
 
 extern TParams tparm_type(const char *name);
diff --git a/contrib/ncurses/progs/tput.c b/contrib/ncurses/progs/tput.c
index cac8d292a94b..f9321b60a8d3 100644
--- a/contrib/ncurses/progs/tput.c
+++ b/contrib/ncurses/progs/tput.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2018-2023,2024 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -44,39 +44,37 @@
 #include <clear_cmd.h>
 #include <reset_cmd.h>
 
-#if !PURE_TERMINFO
-#include <dump_entry.h>
-#include <termsort.c>
-#endif
 #include <transform.h>
 #include <tty_settings.h>
 
-MODULE_ID("$Id: tput.c,v 1.84 2020/10/24 18:29:38 tom Exp $")
+MODULE_ID("$Id: tput.c,v 1.104 2024/04/20 22:20:51 tom Exp $")
 
 #define PUTS(s)		fputs(s, stdout)
 
 const char *_nc_progname = "tput";
 
-static char *prg_name;
+static bool opt_v = FALSE;	/* quiet, do not show warnings */
+static bool opt_x = FALSE;	/* clear scrollback if possible */
+
 static bool is_init = FALSE;
 static bool is_reset = FALSE;
 static bool is_clear = FALSE;
 
-static void
+static GCC_NORETURN void
 quit(int status, const char *fmt, ...)
 {
     va_list argp;
 
     va_start(argp, fmt);
-    fprintf(stderr, "%s: ", prg_name);
+    fprintf(stderr, "%s: ", _nc_progname);
     vfprintf(stderr, fmt, argp);
     fprintf(stderr, "\n");
     va_end(argp);
     ExitProgram(status);
 }
 
-static void
-usage(void)
+static GCC_NORETURN void
+usage(const char *optstring)
 {
 #define KEEP(s) s "\n"
     static const char msg[] =
@@ -86,6 +84,7 @@ usage(void)
 	KEEP("  -S <<       read commands from standard input")
 	KEEP("  -T TERM     use this instead of $TERM")
 	KEEP("  -V          print curses-version")
+	KEEP("  -v          verbose, show warnings")
 	KEEP("  -x          do not try to clear scrollback")
 	KEEP("")
 	KEEP("Commands:")
@@ -95,8 +94,21 @@ usage(void)
 	KEEP("  capname     unlike clear/init/reset, print value for capability \"capname\"")
     };
 #undef KEEP
-    (void) fprintf(stderr, "Usage: %s [options] [command]\n", prg_name);
-    fputs(msg, stderr);
+    (void) fprintf(stderr, "Usage: %s [options] [command]\n", _nc_progname);
+    if (optstring != NULL) {
+	const char *s = msg;
+	while (*s != '\0') {
+	    fputc(UChar(*s), stderr);
+	    if (!strncmp(s, "  -", 3)) {
+		if (strchr(optstring, s[3]) == NULL)
+		    s = strchr(s, '\n') + 1;
+	    } else if (!strncmp(s, "\n\nC", 3))
+		break;
+	    ++s;
+	}
+    } else {
+	fputs(msg, stderr);
+    }
     ExitProgram(ErrUsage);
 }
 
@@ -140,7 +152,7 @@ exit_code(int token, int value)
  * Returns nonzero on error.
  */
 static int
-tput_cmd(int fd, TTY * saved_settings, bool opt_x, int argc, char *argv[])
+tput_cmd(int fd, TTY * settings, int argc, char **argv, int *used)
 {
     NCURSES_CONST char *name;
     char *s;
@@ -150,8 +162,9 @@ tput_cmd(int fd, TTY * saved_settings, bool opt_x, int argc, char *argv[])
 #endif
 
     name = check_aliases(argv[0], FALSE);
+    *used = 1;
     if (is_reset || is_init) {
-	TTY oldmode;
+	TTY oldmode = *settings;
 
 	int terasechar = -1;	/* new erase character */
 	int intrchar = -1;	/* new interrupt character */
@@ -159,23 +172,30 @@ tput_cmd(int fd, TTY * saved_settings, bool opt_x, int argc, char *argv[])
 
 	if (is_reset) {
 	    reset_start(stdout, TRUE, FALSE);
-	    reset_tty_settings(fd, saved_settings);
+	    reset_tty_settings(fd, settings, FALSE);
 	} else {
 	    reset_start(stdout, FALSE, TRUE);
 	}
 
 #if HAVE_SIZECHANGE
-	set_window_size(fd, &lines, &columns);
+	{
+	    NCURSES_INT2 my_rows = lines;
+	    NCURSES_INT2 my_cols = columns;
+	    set_window_size(fd, &my_rows, &my_cols);
+	    lines = my_rows;
+	    columns = my_cols;
+	}
 #else
 	(void) fd;
 #endif
-	set_control_chars(saved_settings, terasechar, intrchar, tkillchar);
-	set_conversions(saved_settings);
+	set_control_chars(settings, terasechar, intrchar, tkillchar);
+	set_conversions(settings);
+
 	if (send_init_strings(fd, &oldmode)) {
 	    reset_flush();
 	}
 
-	update_tty_settings(&oldmode, saved_settings);
+	update_tty_settings(&oldmode, settings);
 	return 0;
     }
 
@@ -221,17 +241,21 @@ tput_cmd(int fd, TTY * saved_settings, bool opt_x, int argc, char *argv[])
     } else if (VALID_STRING(s)) {
 	if (argc > 1) {
 	    int k;
-	    int ignored;
+	    int narg;
+	    int analyzed;
+	    int provided;
+	    int popcount;
 	    long numbers[1 + NUM_PARM];
 	    char *strings[1 + NUM_PARM];
 	    char *p_is_s[NUM_PARM];
+	    TParams paramType;
 
 	    /* Nasty hack time. The tparm function needs to see numeric
 	     * parameters as numbers, not as pointers to their string
 	     * representations
 	     */
 
-	    for (k = 1; (k < argc) && (k < NUM_PARM); k++) {
+	    for (k = 1; (k < argc) && (k <= NUM_PARM); k++) {
 		char *tmp = 0;
 		strings[k] = argv[k];
 		numbers[k] = strtol(argv[k], &tmp, 0);
@@ -243,14 +267,64 @@ tput_cmd(int fd, TTY * saved_settings, bool opt_x, int argc, char *argv[])
 		strings[k] = 0;
 	    }
 
-	    switch (tparm_type(name)) {
+	    paramType = tparm_type(name);
+#if NCURSES_XNAMES
+	    /*
+	     * If the capability is an extended one, analyze the string.
+	     */
+	    if (paramType == Numbers) {
+		struct name_table_entry const *entry_ptr;
+		entry_ptr = _nc_find_type_entry(name, STRING, FALSE);
+		if (entry_ptr == NULL) {
+		    paramType = Other;
+		}
+	    }
+#endif
+
+	    popcount = 0;
+	    _nc_reset_tparm(NULL);
+	    /*
+	     * Count the number of numeric parameters which are provided.
+	     */
+	    provided = 0;
+	    for (narg = 1; narg < argc; ++narg) {
+		char *ending = NULL;
+		long check = strtol(argv[narg], &ending, 0);
+		if (check < 0 || ending == argv[narg] || *ending != '\0')
+		    break;
+		provided = narg;
+	    }
+	    switch (paramType) {
+	    case Str:
+		s = TPARM_1(s, strings[1]);
+		analyzed = 1;
+		if (provided == 0 && argc >= 1)
+		    provided++;
+		break;
+	    case Str_Str:
+		s = TPARM_2(s, strings[1], strings[2]);
+		analyzed = 2;
+		if (provided == 0 && argc >= 1)
+		    provided++;
+		if (provided == 1 && argc >= 2)
+		    provided++;
+		break;
 	    case Num_Str:
 		s = TPARM_2(s, numbers[1], strings[2]);
+		analyzed = 2;
+		if (provided == 1 && argc >= 2)
+		    provided++;
 		break;
 	    case Num_Str_Str:
 		s = TPARM_3(s, numbers[1], strings[2], strings[3]);
+		analyzed = 3;
+		if (provided == 1 && argc >= 2)
+		    provided++;
+		if (provided == 2 && argc >= 3)
+		    provided++;
 		break;
 	    case Numbers:
+		analyzed = _nc_tparm_analyze(NULL, s, p_is_s, &popcount);
 #define myParam(n) numbers[n]
 		s = TIPARM_9(s,
 			     myParam(1),
@@ -267,7 +341,7 @@ tput_cmd(int fd, TTY * saved_settings, bool opt_x, int argc, char *argv[])
 	    case Other:
 		/* FALLTHRU */
 	    default:
-		(void) _nc_tparm_analyze(s, p_is_s, &ignored);
+		analyzed = _nc_tparm_analyze(NULL, s, p_is_s, &popcount);
 #define myParam(n) (p_is_s[n - 1] != 0 ? ((TPARM_ARG) strings[n]) : numbers[n])
 		s = TPARM_9(s,
 			    myParam(1),
@@ -282,6 +356,16 @@ tput_cmd(int fd, TTY * saved_settings, bool opt_x, int argc, char *argv[])
 #undef myParam
 		break;
 	    }
+	    if (analyzed < popcount) {
+		analyzed = popcount;
+	    }
+	    if (opt_v && (analyzed != provided)) {
+		fprintf(stderr, "%s: %s parameters for \"%s\"\n",
+			_nc_progname,
+			(analyzed < provided ? "extra" : "missing"),
+			argv[0]);
+	    }
+	    *used += provided;
 	}
 
 	/* use putp() in order to perform padding */
@@ -301,16 +385,18 @@ main(int argc, char **argv)
     char buf[BUFSIZ];
     int result = 0;
     int fd;
+    int used;
+    TTY old_settings;
     TTY tty_settings;
-    bool opt_x = FALSE;		/* clear scrollback if possible */
     bool is_alias;
     bool need_tty;
 
-    prg_name = check_aliases(_nc_rootname(argv[0]), TRUE);
+    _nc_progname = check_aliases(_nc_rootname(argv[0]), TRUE);
+    is_alias = (is_clear || is_reset || is_init);
 
     term = getenv("TERM");
 
-    while ((c = getopt(argc, argv, "ST:Vx")) != -1) {
+    while ((c = getopt(argc, argv, is_alias ? "T:Vvx" : "ST:Vvx")) != -1) {
 	switch (c) {
 	case 'S':
 	    cmdline = FALSE;
@@ -323,16 +409,18 @@ main(int argc, char **argv)
 	case 'V':
 	    puts(curses_version());
 	    ExitProgram(EXIT_SUCCESS);
+	case 'v':		/* verbose */
+	    opt_v = TRUE;
+	    break;
 	case 'x':		/* do not try to clear scrollback */
 	    opt_x = TRUE;
 	    break;
 	default:
-	    usage();
+	    usage(is_alias ? "TVx" : NULL);
 	    /* NOTREACHED */
 	}
     }
 
-    is_alias = (is_clear || is_reset || is_init);
     need_tty = ((is_reset || is_init) ||
 		(optind < argc &&
 		 (!strcmp(argv[optind], "reset") ||
@@ -346,7 +434,7 @@ main(int argc, char **argv)
 	    argc -= optind;
 	    argv += optind;
 	}
-	argv[0] = prg_name;
+	argv[0] = strdup(_nc_progname);
     } else {
 	argc -= optind;
 	argv += optind;
@@ -356,39 +444,62 @@ main(int argc, char **argv)
 	quit(ErrUsage, "No value for $TERM and no -T specified");
 
     fd = save_tty_settings(&tty_settings, need_tty);
+    old_settings = tty_settings;
 
     if (setupterm(term, fd, &errret) != OK && errret <= 0)
 	quit(ErrTermType, "unknown terminal \"%s\"", term);
 
     if (cmdline) {
+	int code = 0;
 	if ((argc <= 0) && !is_alias)
-	    usage();
-	ExitProgram(tput_cmd(fd, &tty_settings, opt_x, argc, argv));
+	    usage(NULL);
+	while (argc > 0) {
+	    tty_settings = old_settings;
+	    code = tput_cmd(fd, &tty_settings, argc, argv, &used);
+	    if (code != 0)
+		break;
+	    argc -= used;
+	    argv += used;
+	}
+	ExitProgram(code);
     }
 
     while (fgets(buf, sizeof(buf), stdin) != 0) {
-	char *argvec[16];	/* command, 9 parms, null, & slop */
+	size_t need = strlen(buf);
+	char **argvec = typeCalloc(char *, need + 1);
+	char **argnow;
 	int argnum = 0;
 	char *cp;
 
-	/* crack the argument list into a dope vector */
+	if (argvec == NULL) {
+	    quit(ErrSystem(1), strerror(errno));
+	}
+
+	/* split the buffer into tokens */
 	for (cp = buf; *cp; cp++) {
 	    if (isspace(UChar(*cp))) {
 		*cp = '\0';
-	    } else if (cp == buf || cp[-1] == 0) {
+	    } else if (cp == buf || cp[-1] == '\0') {
 		argvec[argnum++] = cp;
-		if (argnum >= (int) SIZEOF(argvec) - 1)
+		if (argnum >= (int) need)
 		    break;
 	    }
 	}
-	argvec[argnum] = 0;
 
-	if (argnum != 0
-	    && tput_cmd(fd, &tty_settings, opt_x, argnum, argvec) != 0) {
-	    if (result == 0)
-		result = ErrSystem(0);	/* will return value >4 */
-	    ++result;
+	argnow = argvec;
+	while (argnum > 0) {
+	    int code;
+	    tty_settings = old_settings;
+	    code = tput_cmd(fd, &tty_settings, argnum, argnow, &used);
+	    if (code != 0) {
+		if (result == 0)
+		    result = ErrSystem(0);	/* will return value >4 */
+		++result;
+	    }
+	    argnum -= used;
+	    argnow += used;
 	}
+	free(argvec);
     }
 
     ExitProgram(result);
diff --git a/contrib/ncurses/progs/tset.c b/contrib/ncurses/progs/tset.c
index 4d33ca8789c2..69f4aba87974 100644
--- a/contrib/ncurses/progs/tset.c
+++ b/contrib/ncurses/progs/tset.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020-2021,2024 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -91,14 +91,14 @@
 #include <transform.h>
 #include <tty_settings.h>
 
-#if HAVE_GETTTYNAM && HAVE_TTYENT_H
+#if HAVE_GETTTYNAM
 #include <ttyent.h>
 #endif
 #ifdef NeXT
 char *ttyname(int fd);
 #endif
 
-MODULE_ID("$Id: tset.c,v 1.125 2020/09/05 22:54:47 tom Exp $")
+MODULE_ID("$Id: tset.c,v 1.135 2024/04/20 22:20:41 tom Exp $")
 
 #ifndef environ
 extern char **environ;
@@ -108,7 +108,7 @@ const char *_nc_progname = "tset";
 
 #define LOWERCASE(c) ((isalpha(UChar(c)) && isupper(UChar(c))) ? tolower(UChar(c)) : (c))
 
-static void exit_error(void) GCC_NORETURN;
+static GCC_NORETURN void exit_error(void);
 
 static int
 CaselessCmp(const char *a, const char *b)
@@ -122,7 +122,7 @@ CaselessCmp(const char *a, const char *b)
     return LOWERCASE(*a) - LOWERCASE(*b);
 }
 
-static void
+static GCC_NORETURN void
 exit_error(void)
 {
     restore_tty_settings();
@@ -132,7 +132,7 @@ exit_error(void)
     /* NOTREACHED */
 }
 
-static void
+static GCC_NORETURN void
 err(const char *fmt, ...)
 {
     va_list ap;
@@ -144,7 +144,7 @@ err(const char *fmt, ...)
     /* NOTREACHED */
 }
 
-static void
+static GCC_NORETURN void
 failed(const char *msg)
 {
     char temp[BUFSIZ];
@@ -167,7 +167,6 @@ static const char *
 askuser(const char *dflt)
 {
     static char answer[256];
-    char *p;
 
     /* We can get recalled; if so, don't continue uselessly. */
     clearerr(stdin);
@@ -176,7 +175,10 @@ askuser(const char *dflt)
 	exit_error();
 	/* NOTREACHED */
     }
+
     for (;;) {
+	char *p;
+
 	if (dflt)
 	    (void) fprintf(stderr, "Terminal type? [%s] ", dflt);
 	else
@@ -543,12 +545,14 @@ get_termcap_entry(int fd, char *userarg)
     int errret;
     char *p;
     const char *ttype;
+#if HAVE_PATH_TTYS
 #if HAVE_GETTTYNAM
     struct ttyent *t;
 #else
     FILE *fp;
 #endif
     char *ttypath;
+#endif /* HAVE_PATH_TTYS */
 
     (void) fd;
 
@@ -561,6 +565,7 @@ get_termcap_entry(int fd, char *userarg)
     if ((ttype = getenv("TERM")) != 0)
 	goto map;
 
+#if HAVE_PATH_TTYS
     if ((ttypath = ttyname(fd)) != 0) {
 	p = _nc_basename(ttypath);
 #if HAVE_GETTTYNAM
@@ -598,6 +603,7 @@ get_termcap_entry(int fd, char *userarg)
 	}
 #endif /* HAVE_GETTTYNAM */
     }
+#endif /* HAVE_PATH_TTYS */
 
     /* If still undefined, use "unknown". */
     ttype = "unknown";
@@ -773,7 +779,7 @@ main(int argc, char **argv)
     bool opt_w = FALSE;		/* set window-size */
     TTY mode, oldmode;
 
-    my_fd = STDERR_FILENO;
+    _nc_progname = _nc_rootname(*argv);
     obsolete(argv);
     noinit = noset = quiet = Sflag = sflag = showterm = 0;
     while ((ch = getopt(argc, argv, "a:cd:e:Ii:k:m:p:qQrSsVw")) != -1) {
@@ -832,7 +838,6 @@ main(int argc, char **argv)
 	}
     }
 
-    _nc_progname = _nc_rootname(*argv);
     argc -= optind;
     argv += optind;
 
@@ -854,7 +859,7 @@ main(int argc, char **argv)
 
     if (same_program(_nc_progname, PROG_RESET)) {
 	reset_start(stderr, TRUE, FALSE);
-	reset_tty_settings(my_fd, &mode);
+	reset_tty_settings(my_fd, &mode, noset);
     } else {
 	reset_start(stderr, FALSE, TRUE);
     }
@@ -864,7 +869,11 @@ main(int argc, char **argv)
     if (!noset) {
 #if HAVE_SIZECHANGE
 	if (opt_w) {
-	    set_window_size(my_fd, &lines, &columns);
+	    NCURSES_INT2 my_rows = lines;
+	    NCURSES_INT2 my_cols = columns;
+	    set_window_size(my_fd, &my_rows, &my_cols);
+	    lines = my_rows;
+	    columns = my_cols;
 	}
 #endif
 	if (opt_c) {
@@ -873,9 +882,13 @@ main(int argc, char **argv)
 
 	    if (!noinit) {
 		if (send_init_strings(my_fd, &oldmode)) {
+		    const char *name;
+
 		    (void) putc('\r', stderr);
 		    (void) fflush(stderr);
-		    (void) napms(1000);		/* Settle the terminal. */
+		    if (IsRealTty(my_fd, name)) {
+			(void) napms(1000);	/* Settle the terminal. */
+		    }
 		}
 	    }
 
diff --git a/contrib/ncurses/progs/tty_settings.c b/contrib/ncurses/progs/tty_settings.c
index 274de9fecf6f..a9eb8cd8ba74 100644
--- a/contrib/ncurses/progs/tty_settings.c
+++ b/contrib/ncurses/progs/tty_settings.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  * Copyright 2016,2017 Free Software Foundation, Inc.                       *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -36,7 +36,7 @@
 
 #include <fcntl.h>
 
-MODULE_ID("$Id: tty_settings.c,v 1.6 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: tty_settings.c,v 1.7 2021/10/08 23:53:32 tom Exp $")
 
 static int my_fd;
 static TTY original_settings;
@@ -74,10 +74,12 @@ save_tty_settings(TTY * tty_settings, bool need_tty)
 {
     if (!get_tty_settings(STDERR_FILENO, tty_settings) &&
 	!get_tty_settings(STDOUT_FILENO, tty_settings) &&
-	!get_tty_settings(STDIN_FILENO, tty_settings) &&
-	!get_tty_settings(open("/dev/tty", O_RDWR), tty_settings)) {
+	!get_tty_settings(STDIN_FILENO, tty_settings)) {
 	if (need_tty) {
-	    failed("terminal attributes");
+	    int fd = open("/dev/tty", O_RDWR);
+	    if (!get_tty_settings(fd, tty_settings)) {
+		failed("terminal attributes");
+	    }
 	} else {
 	    my_fd = fileno(stdout);
 	}
diff --git a/contrib/ncurses/test/back_ground.c b/contrib/ncurses/test/back_ground.c
deleted file mode 100644
index 100282464ac8..000000000000
--- a/contrib/ncurses/test/back_ground.c
+++ /dev/null
@@ -1,300 +0,0 @@
-/****************************************************************************
- * Copyright 2021 Thomas E. Dickey                                          *
- *                                                                          *
- * Permission is hereby granted, free of charge, to any person obtaining a  *
- * copy of this software and associated documentation files (the            *
- * "Software"), to deal in the Software without restriction, including      *
- * without limitation the rights to use, copy, modify, merge, publish,      *
- * distribute, distribute with modifications, sublicense, and/or sell       *
- * copies of the Software, and to permit persons to whom the Software is    *
- * furnished to do so, subject to the following conditions:                 *
- *                                                                          *
- * The above copyright notice and this permission notice shall be included  *
- * in all copies or substantial portions of the Software.                   *
- *                                                                          *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
- * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
- * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
- *                                                                          *
- * Except as contained in this notice, the name(s) of the above copyright   *
- * holders shall not be used in advertising or otherwise to promote the     *
- * sale, use or other dealings in this Software without prior written       *
- * authorization.                                                           *
- ****************************************************************************/
-/*
- * $Id: back_ground.c,v 1.5 2021/02/20 12:23:21 tom Exp $
- */
-
-#include <test.priv.h>
-
-#if USE_WIDEC_SUPPORT
-
-#define NEED_COLOR_CODE 1
-#define NEED_COLOR_NAME 1
-#include <color_name.h>
-#include <dump_window.h>
-
-static int default_bg = COLOR_BLACK;
-static int default_fg = COLOR_WHITE;
-static wchar_t wide_fill = L' ';
-
-static wchar_t
-decode_wchar(const char *value)
-{
-    long result;
-    char *next = NULL;
-    int radix = 0;
-
-    if (!strncmp(value, "U+", 2)) {
-	value += 2;
-	radix = 16;
-    }
-    result = strtol(value, &next, radix);
-    if (next == value || (next == NULL || *next != '\0')) {
-	fprintf(stderr, "decoding wchar_t: %s\n", value);
-	exit(EXIT_FAILURE);
-    }
-    return (wchar_t) result;
-}
-
-static void
-test_background(void)
-{
-    NCURSES_COLOR_T f, b;
-    int row;
-    int chr;
-    wchar_t blank[2];
-    wchar_t graphics[2];
-    cchar_t data;
-
-    if (pair_content(0, &f, &b) == ERR) {
-	printw("pair 0 contains no data\n");
-    } else {
-	printw("pair 0 contains (%d,%d)\n", (int) f, (int) b);
-    }
-    dump_window(stdscr);
-
-    blank[0] = wide_fill;
-    blank[1] = L'\0';
-
-    printw("Initializing pair 1 to red/%s\n", color_name(default_bg));
-    init_pair(1, COLOR_RED, (NCURSES_COLOR_T) default_bg);
-    setcchar(&data, blank, A_NORMAL, 1, NULL);
-    bkgrndset(&data);
-    printw("RED/BLACK\n");
-    dump_window(stdscr);
-
-    printw("Initializing pair 2 to %s/blue\n", color_name(default_fg));
-    init_pair(2, (NCURSES_COLOR_T) default_fg, COLOR_BLUE);
-    setcchar(&data, blank, A_NORMAL, 2, NULL);
-    bkgrndset(&data);
-    printw("This line should be %s/blue\n", color_name(default_fg));
-    dump_window(stdscr);
-
-    printw("Initializing pair 3 to %s/cyan (ACS_HLINE)\n", color_name(default_fg));
-    init_pair(3, (NCURSES_COLOR_T) default_fg, COLOR_CYAN);
-    printw("...and drawing a box which should be followed by lines\n");
-    graphics[0] = ACS_HLINE & A_CHARTEXT;
-    graphics[1] = L'\0';
-    setcchar(&data, graphics, A_ALTCHARSET, 3, NULL);
-    bkgrndset(&data);
-    /*
-     * Characters from vt100 line-drawing should be mapped to line-drawing,
-     * since A_ALTCHARSET is set in the background, and the character part
-     * of the background is replaced by the nonblank characters written.
-     *
-     * Characters not in the line-drawing range are usually sent as-is.
-     *
-     * With SVr4 curses it is possible to rely on this to mix uppercase text
-     * with the (lowercase) line-drawing characters.  ncurses uses some of
-     * the uppercase characters for encoding thick- and double-lines.
-     */
-    row = 7;
-    mvprintw(row++, 10, "l");
-    for (chr = 0; chr < 32; ++chr)
-	AddCh(' ');
-    printw("x\n");
-    chr = 32;
-    while (chr < 128) {
-	if ((chr % 32) == 0)
-	    mvprintw(row++, 10, "x");
-	AddCh((chr == 127) ? ' ' : chr);
-	if ((++chr % 32) == 0)
-	    printw("x\n");
-    }
-    mvprintw(row++, 10, "m");
-    for (chr = 0; chr < 32; ++chr)
-	AddCh(' ');
-    printw("j\n");
-    dump_window(stdscr);
-
-    setcchar(&data, blank, A_NORMAL, 0, NULL);
-    bkgrndset(&data);
-    printw("Default Colors\n");
-    dump_window(stdscr);
-
-    printw("Resetting colors to pair 1\n");
-    setcchar(&data, blank, A_NORMAL, 1, NULL);
-    bkgrndset(&data);
-    printw("This line should be red/%s\n", color_name(default_bg));
-    dump_window(stdscr);
-
-    printw("Setting screen to pair 0\n");
-    setcchar(&data, blank, A_NORMAL, 0, NULL);
-    bkgrndset(&data);
-    dump_window(stdscr);
-
-    printw("Setting screen to pair 1\n");
-    setcchar(&data, blank, A_NORMAL, 1, NULL);
-    bkgrndset(&data);
-    dump_window(stdscr);
-
-    printw("Setting screen to pair 2\n");
-    setcchar(&data, blank, A_NORMAL, 2, NULL);
-    bkgrndset(&data);
-    dump_window(stdscr);
-
-    printw("Setting screen to pair 3\n");
-    setcchar(&data, blank, A_NORMAL, 3, NULL);
-    bkgrndset(&data);
-    dump_window(stdscr);
-
-    printw("Setting screen to pair 0\n");
-    setcchar(&data, blank, A_NORMAL, 0, NULL);
-    bkgrndset(&data);
-    dump_window(stdscr);
-}
-
-static void
-usage(void)
-{
-    static const char *msg[] =
-    {
-	"Usage: background [options]"
-	,""
-	,"Options:"
-#if HAVE_ASSUME_DEFAULT_COLORS
-	," -a       invoke assume_default_colors, repeat to use in init_pair"
-#endif
-	," -b XXX   specify background color"
-#if HAVE_USE_DEFAULT_COLORS
-	," -d       invoke use_default_colors, repeat to use in init_pair"
-#endif
-	," -f XXX   specify foreground color"
-	," -l FILE  log window-dumps to this file"
-	," -w       fill background with stipple pattern"
-	," -W CODE  fill background with this Unicode value"
-    };
-    size_t n;
-
-    for (n = 0; n < SIZEOF(msg); n++)
-	fprintf(stderr, "%s\n", msg[n]);
-
-    ExitProgram(EXIT_FAILURE);
-}
-
-int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
-{
-#if HAVE_ASSUME_DEFAULT_COLORS
-    int a_option = 0;
-#endif
-#if HAVE_USE_DEFAULT_COLORS
-    int d_option = 0;
-#endif
-    int n;
-
-    setlocale(LC_ALL, "");
-
-    while ((n = getopt(argc, argv, "ab:df:l:wW:")) != -1) {
-	switch (n) {
-#if HAVE_ASSUME_DEFAULT_COLORS
-	case 'a':
-	    ++a_option;
-	    break;
-#endif
-	case 'b':
-	    default_bg = color_code(optarg);
-	    break;
-#if HAVE_USE_DEFAULT_COLORS
-	case 'd':
-	    ++d_option;
-	    break;
-#endif
-	case 'f':
-	    default_fg = color_code(optarg);
-	    break;
-	case 'l':
-	    if (!open_dump(optarg))
-		usage();
-	    break;
-	case 'w':
-	    wide_fill = L'\u2591';
-	    break;
-	case 'W':
-	    wide_fill = decode_wchar(optarg);
-	    break;
-	default:
-	    usage();
-	}
-    }
-#if HAVE_USE_DEFAULT_COLORS && HAVE_ASSUME_DEFAULT_COLORS
-    if (a_option && d_option) {
-	fprintf(stderr, "Use either -a or -d option, but not both\n");
-	ExitProgram(EXIT_FAILURE);
-    }
-#endif
-
-    initscr();
-    cbreak();
-    noecho();
-
-    if (has_colors()) {
-	start_color();
-
-#if HAVE_USE_DEFAULT_COLORS
-	if (d_option) {
-	    printw("Using default colors...\n");
-	    use_default_colors();
-	    if (d_option > 1) {
-		default_fg = -1;
-		default_bg = -1;
-	    }
-	}
-#endif
-#if HAVE_ASSUME_DEFAULT_COLORS
-	if (a_option) {
-	    printw("Using assumed colors %s/%s...\n",
-		   color_name(default_fg),
-		   color_name(default_bg));
-	    assume_default_colors(default_fg, default_bg);
-	    if (a_option > 1) {
-		default_fg = -1;
-		default_bg = -1;
-	    }
-	}
-#endif
-
-	test_background();
-
-    } else {
-	printw("This demo requires a color terminal");
-	getch();
-    }
-    endwin();
-    close_dump();
-    ExitProgram(EXIT_SUCCESS);
-}
-
-#else
-int
-main(void)
-{
-    printf("This program requires the wide-curses library\n");
-    ExitProgram(EXIT_FAILURE);
-}
-#endif /* USE_WIDEC_SUPPORT */
diff --git a/contrib/ncurses/test/dup_field.c b/contrib/ncurses/test/dup_field.c
deleted file mode 100644
index 5ca67f0b0f5a..000000000000
--- a/contrib/ncurses/test/dup_field.c
+++ /dev/null
@@ -1,394 +0,0 @@
-/****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
- *                                                                          *
- * Permission is hereby granted, free of charge, to any person obtaining a  *
- * copy of this software and associated documentation files (the            *
- * "Software"), to deal in the Software without restriction, including      *
- * without limitation the rights to use, copy, modify, merge, publish,      *
- * distribute, distribute with modifications, sublicense, and/or sell       *
- * copies of the Software, and to permit persons to whom the Software is    *
- * furnished to do so, subject to the following conditions:                 *
- *                                                                          *
- * The above copyright notice and this permission notice shall be included  *
- * in all copies or substantial portions of the Software.                   *
- *                                                                          *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
- * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
- * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
- *                                                                          *
- * Except as contained in this notice, the name(s) of the above copyright   *
- * holders shall not be used in advertising or otherwise to promote the     *
- * sale, use or other dealings in this Software without prior written       *
- * authorization.                                                           *
- ****************************************************************************/
-/*
- * $Id: dup_field.c,v 1.1 2020/03/21 19:28:36 tom Exp $
- *
- * Demonstrate move_field().
- */
-
-#include <test.priv.h>
-
-#if USE_LIBFORM
-
-#include <edit_field.h>
-#include <popup_msg.h>
-
-#define MY_DEMO		EDIT_FIELD('f')
-
-static char empty[] = "";
-static FIELD *all_fields[100];
-
-/* *INDENT-OFF* */
-static struct {
-    int code;
-    int result;
-    const char *help;
-} commands[] = {
-    { CTRL('A'),     REQ_BEG_FIELD,   "go to beginning of field" },
-    { CTRL('D'),     REQ_DOWN_FIELD,  "move downward to field" },
-    { CTRL('E'),     REQ_END_FIELD,   "go to end of field" },
-    { CTRL('G'),     MY_DEMO,         "move current field with cursor keys" },
-    { CTRL('H'),     REQ_DEL_PREV,    "delete previous character" },
-    { CTRL('I'),     REQ_NEXT_FIELD,  "go to next field" },
-    { CTRL('K'),     REQ_CLR_EOF,     "clear to end of field" },
-    { CTRL('N'),     REQ_NEXT_FIELD,  "go to next field" },
-    { CTRL('P'),     REQ_PREV_FIELD,  "go to previous field" },
-    { CTRL('Q'),     MY_QUIT,         "exit form" },
-    { CTRL('U'),     REQ_UP_FIELD,    "move upward to field" },
-    { CTRL('W'),     REQ_NEXT_WORD,   "go to next word" },
-    { CTRL('X'),     REQ_CLR_FIELD,   "clear field" },
-    { CTRL('['),     MY_QUIT,         "exit form" },
-    { KEY_F(1),      MY_HELP,         "show this screen", },
-    { KEY_BACKSPACE, REQ_DEL_PREV,    "delete previous character" },
-    { KEY_BTAB,      REQ_PREV_FIELD,  "go to previous field" },
-    { KEY_DOWN,      REQ_DOWN_CHAR,   "move down 1 character" },
-    { KEY_END,       REQ_LAST_FIELD,  "go to last field" },
-    { KEY_HOME,      REQ_FIRST_FIELD, "go to first field" },
-    { KEY_LEFT,      REQ_LEFT_CHAR,   "move left 1 character" },
-    { KEY_NEXT,      REQ_NEXT_FIELD,  "go to next field" },
-    { KEY_PREVIOUS,  REQ_PREV_FIELD,  "go to previous field" },
-    { KEY_RIGHT,     REQ_RIGHT_CHAR,  "move right 1 character" },
-    { KEY_UP,        REQ_UP_CHAR,     "move up 1 character" }
-};
-/* *INDENT-ON* */
-
-static void
-my_help_edit_field(void)
-{
-    int used = 0;
-    unsigned n;
-    char **msgs = typeCalloc(char *, 3 + SIZEOF(commands));
-
-    msgs[used++] = strdup("Defined form edit/traversal keys:");
-    for (n = 0; n < SIZEOF(commands); ++n) {
-	char *msg;
-	const char *name;
-	const char *code = keyname(commands[n].code);
-	size_t need = 5;
-#ifdef NCURSES_VERSION
-	if ((name = form_request_name(commands[n].result)) == 0)
-#endif
-	    name = commands[n].help;
-	need = 5 + strlen(code) + strlen(name);
-	msg = typeMalloc(char, need);
-	_nc_SPRINTF(msg, _nc_SLIMIT(need) "%s -- %s", code, name);
-	msgs[used++] = msg;
-    }
-    msgs[used++] =
-	strdup("Arrow keys move within a field as you would expect.");
-    msgs[used] = 0;
-    popup_msg2(stdscr, msgs);
-    for (n = 0; msgs[n] != 0; ++n) {
-	free(msgs[n]);
-    }
-    free(msgs);
-}
-
-static void
-do_demo(FORM *form)
-{
-}
-
-static FIELD *
-make_label(const char *label, int frow, int fcol)
-{
-    FIELD *f = new_field(1, (int) strlen(label), frow, fcol, 0, 0);
-
-    if (f) {
-	set_field_buffer(f, 0, label);
-	set_field_opts(f, (int) ((unsigned) field_opts(f) & ~O_ACTIVE));
-    }
-    return (f);
-}
-
-static FIELD *
-make_field(int frow, int fcol, int rows, int cols)
-{
-    FIELD *f = new_field(rows, cols, frow, fcol, 0, 1);
-
-    if (f) {
-	set_field_back(f, A_UNDERLINE);
-	init_edit_field(f, empty);
-    }
-    return (f);
-}
-
-static void
-erase_form(FORM *f)
-{
-    WINDOW *w = form_win(f);
-    WINDOW *s = form_sub(f);
-
-    unpost_form(f);
-    werase(w);
-    wrefresh(w);
-    delwin(s);
-    delwin(w);
-}
-
-static int
-my_form_driver(FORM *form, int c)
-{
-    switch (c) {
-    case MY_QUIT:
-	if (form_driver(form, REQ_VALIDATION) == E_OK)
-	    return (TRUE);
-	break;
-    case MY_HELP:
-	my_help_edit_field();
-	break;
-    case MY_DEMO:
-	do_demo(form);
-	break;
-    default:
-	beep();
-	break;
-    }
-    return (FALSE);
-}
-
-static FieldAttrs *
-my_field_attrs(FIELD *f)
-{
-    return (FieldAttrs *) field_userptr(f);
-}
-
-static int
-buffer_length(FIELD *f)
-{
-    return my_field_attrs(f)->row_lengths[0];
-}
-
-static void
-set_buffer_length(FIELD *f, int length)
-{
-    my_field_attrs(f)->row_lengths[0] = length;
-}
-
-static int
-offset_in_field(FORM *form)
-{
-    FIELD *field = current_field(form);
-    int currow, curcol;
-
-    form_getyx(form, currow, curcol);
-    return curcol + currow * (int) field->dcols;
-}
-
-static void
-inactive_field(FIELD *f)
-{
-    set_field_back(f, my_field_attrs(f)->background);
-}
-
-static int
-my_edit_field(FORM *form, int *result)
-{
-    int ch = wgetch(form_win(form));
-    int status;
-    FIELD *before;
-    unsigned n;
-    int length;
-    int before_row;
-    int before_col;
-    int before_off = offset_in_field(form);
-
-    form_getyx(form, before_row, before_col);
-    before = current_field(form);
-    set_field_back(before, A_NORMAL);
-    if (ch <= KEY_MAX) {
-	set_field_back(before, A_REVERSE);
-    } else if (ch <= MAX_FORM_COMMAND) {
-	inactive_field(before);
-    }
-
-    *result = ch;
-    for (n = 0; n < SIZEOF(commands); ++n) {
-	if (commands[n].code == ch) {
-	    *result = commands[n].result;
-	    break;
-	}
-    }
-
-    status = form_driver(form, *result);
-
-    if (status == E_OK) {
-	bool modified = TRUE;
-
-	length = buffer_length(before);
-	if (length < before_off)
-	    length = before_off;
-	switch (*result) {
-	case REQ_CLR_EOF:
-	    length = before_off;
-	    break;
-	case REQ_CLR_EOL:
-	    if ((int) (before_row + 1) == (int) (before->rows))
-		length = before_off;
-	    break;
-	case REQ_CLR_FIELD:
-	    length = 0;
-	    break;
-	case REQ_DEL_CHAR:
-	    if (length > before_off)
-		--length;
-	    break;
-	case REQ_DEL_PREV:
-	    if (length > 0) {
-		if (before_col > 0) {
-		    --length;
-		} else if (before_row > 0) {
-		    length -= (int) before->cols + before_col;
-		}
-	    }
-	    break;
-	case REQ_NEW_LINE:
-	    length += (int) before->cols;
-	    break;
-
-	default:
-	    modified = (ch < MIN_FORM_COMMAND
-			&& isprint(ch));
-	    break;
-	}
-
-	/*
-	 * If we do not force a re-validation, then field_buffer 0 will
-	 * be lagging by one character.
-	 */
-	if (modified && form_driver(form, REQ_VALIDATION) == E_OK && *result
-	    < MIN_FORM_COMMAND)
-	    ++length;
-
-	set_buffer_length(before, length);
-    }
-
-    if (current_field(form) != before)
-	inactive_field(before);
-    return status;
-}
-
-static void
-demo_forms(void)
-{
-    FORM *form;
-    int c;
-    unsigned n = 0;
-    const char *fname;
-
-    /* describe the form */
-    all_fields[n++] = make_label("Sample Form", 0, 15);
-
-    fname = "Last Name";
-    all_fields[n++] = make_label(fname, 2, 0);
-    all_fields[n++] = make_field(3, 0, 1, 18);
-    set_field_type(all_fields[n - 1], TYPE_ALPHA, 1);
-
-    fname = "First Name";
-    all_fields[n++] = make_label(fname, 2, 20);
-    all_fields[n++] = make_field(3, 20, 1, 12);
-    set_field_type(all_fields[n - 1], TYPE_ALPHA, 1);
-
-    fname = "Middle Name";
-    all_fields[n++] = make_label(fname, 2, 34);
-    all_fields[n++] = make_field(3, 34, 1, 12);
-    set_field_type(all_fields[n - 1], TYPE_ALPHA, 1);
-
-    fname = "Comments";
-    all_fields[n++] = make_label(fname, 5, 0);
-    all_fields[n++] = make_field(6, 0, 4, 46);
-    init_edit_field(all_fields[n - 1], empty);
-
-    all_fields[n] = (FIELD *) 0;
-
-    if ((form = new_form(all_fields)) != 0) {
-	int finished = 0;
-
-	post_form(form);
-
-	while (!finished) {
-	    switch (my_edit_field(form, &c)) {
-	    case E_OK:
-		break;
-	    case E_UNKNOWN_COMMAND:
-		finished = my_form_driver(form, c);
-		break;
-	    default:
-		beep();
-		break;
-	    }
-	}
-
-	erase_form(form);
-
-	free_form(form);
-    }
-    for (c = 0; all_fields[c] != 0; c++) {
-	free_edit_field(all_fields[c]);
-	free_field(all_fields[c]);
-    }
-    noraw();
-    nl();
-}
-
-int
-main(void)
-{
-    setlocale(LC_ALL, "");
-
-    initscr();
-    cbreak();
-    noecho();
-    raw();
-    nonl();			/* lets us read ^M's */
-    intrflush(stdscr, FALSE);
-    keypad(stdscr, TRUE);
-
-    if (has_colors()) {
-	start_color();
-	init_pair(1, COLOR_WHITE, COLOR_BLUE);
-	init_pair(2, COLOR_GREEN, COLOR_BLACK);
-	init_pair(3, COLOR_CYAN, COLOR_BLACK);
-	bkgd((chtype) COLOR_PAIR(1));
-	refresh();
-    }
-
-    demo_forms();
-
-    endwin();
-    ExitProgram(EXIT_SUCCESS);
-}
-
-#else
-int
-main(void)
-{
-    printf("This program requires the curses form library\n");
-    ExitProgram(EXIT_FAILURE);
-}
-#endif
diff --git a/contrib/ncurses/test/move_field.c b/contrib/ncurses/test/move_field.c
deleted file mode 100644
index 8344c56f8c14..000000000000
--- a/contrib/ncurses/test/move_field.c
+++ /dev/null
@@ -1,524 +0,0 @@
-/****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
- *                                                                          *
- * Permission is hereby granted, free of charge, to any person obtaining a  *
- * copy of this software and associated documentation files (the            *
- * "Software"), to deal in the Software without restriction, including      *
- * without limitation the rights to use, copy, modify, merge, publish,      *
- * distribute, distribute with modifications, sublicense, and/or sell       *
- * copies of the Software, and to permit persons to whom the Software is    *
- * furnished to do so, subject to the following conditions:                 *
- *                                                                          *
- * The above copyright notice and this permission notice shall be included  *
- * in all copies or substantial portions of the Software.                   *
- *                                                                          *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
- * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
- * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
- *                                                                          *
- * Except as contained in this notice, the name(s) of the above copyright   *
- * holders shall not be used in advertising or otherwise to promote the     *
- * sale, use or other dealings in this Software without prior written       *
- * authorization.                                                           *
- ****************************************************************************/
-/*
- * $Id: move_field.c,v 1.7 2020/05/09 12:52:00 tom Exp $
- *
- * Demonstrate move_field().
- */
-
-#include <test.priv.h>
-
-#if USE_LIBFORM
-
-#include <edit_field.h>
-#include <popup_msg.h>
-
-#ifdef HAVE_NETBSD_FORM_H
-#define form_field_row(field) (field)->form_row
-#define form_field_col(field) (field)->form_col
-#else	/* e.g., SVr4, ncurses */
-#define form_field_row(field) (field)->frow
-#define form_field_col(field) (field)->fcol
-#endif
-
-#define DO_DEMO	CTRL('F')	/* actual key for toggling demo-mode */
-#define MY_DEMO	EDIT_FIELD('f')	/* internal request-code */
-
-static char empty[] = "";
-static FIELD *all_fields[100];
-
-/* *INDENT-OFF* */
-static struct {
-    int code;
-    int result;
-    const char *help;
-} commands[] = {
-    { CTRL('A'),     REQ_BEG_FIELD,   "go to beginning of field" },
-    { CTRL('D'),     REQ_DOWN_FIELD,  "move downward to field" },
-    { CTRL('E'),     REQ_END_FIELD,   "go to end of field" },
-    { CTRL('H'),     REQ_DEL_PREV,    "delete previous character" },
-    { CTRL('I'),     REQ_NEXT_FIELD,  "go to next field" },
-    { CTRL('K'),     REQ_CLR_EOF,     "clear to end of field" },
-    { CTRL('N'),     REQ_NEXT_FIELD,  "go to next field" },
-    { CTRL('P'),     REQ_PREV_FIELD,  "go to previous field" },
-    { CTRL('Q'),     MY_QUIT,         "exit form" },
-    { CTRL('U'),     REQ_UP_FIELD,    "move upward to field" },
-    { CTRL('W'),     REQ_NEXT_WORD,   "go to next word" },
-    { CTRL('X'),     REQ_CLR_FIELD,   "clear field" },
-    { CTRL('['),     MY_QUIT,         "exit form" },
-    { KEY_F(1),      MY_HELP,         "show this screen", },
-    { KEY_BACKSPACE, REQ_DEL_PREV,    "delete previous character" },
-    { KEY_BTAB,      REQ_PREV_FIELD,  "go to previous field" },
-    { KEY_DOWN,      REQ_DOWN_CHAR,   "move down 1 character" },
-    { KEY_END,       REQ_LAST_FIELD,  "go to last field" },
-    { KEY_HOME,      REQ_FIRST_FIELD, "go to first field" },
-    { KEY_LEFT,      REQ_LEFT_CHAR,   "move left 1 character" },
-    { KEY_NEXT,      REQ_NEXT_FIELD,  "go to next field" },
-    { KEY_PREVIOUS,  REQ_PREV_FIELD,  "go to previous field" },
-    { KEY_RIGHT,     REQ_RIGHT_CHAR,  "move right 1 character" },
-    { KEY_UP,        REQ_UP_CHAR,     "move up 1 character" },
-    { DO_DEMO,       MY_DEMO,         "move current field with cursor keys" }
-};
-/* *INDENT-ON* */
-
-static void
-my_help_edit_field(void)
-{
-    int used = 0;
-    unsigned n;
-    char **msgs = typeCalloc(char *, 3 + SIZEOF(commands));
-
-    msgs[used++] = strdup("Defined form edit/traversal keys:");
-    for (n = 0; n < SIZEOF(commands); ++n) {
-	char *msg;
-	const char *name;
-	const char *code = keyname(commands[n].code);
-	size_t need = 5;
-#ifdef NCURSES_VERSION
-	if ((name = form_request_name(commands[n].result)) == 0)
-#endif
-	    name = commands[n].help;
-	need = 5 + strlen(code) + strlen(name);
-	msg = typeMalloc(char, need);
-	_nc_SPRINTF(msg, _nc_SLIMIT(need) "%s -- %s", code, name);
-	msgs[used++] = msg;
-    }
-    msgs[used++] =
-	strdup("Arrow keys move within a field as you would expect.");
-    msgs[used] = 0;
-    popup_msg2(stdscr, msgs);
-    for (n = 0; msgs[n] != 0; ++n) {
-	free(msgs[n]);
-    }
-    free(msgs);
-}
-
-static FIELD *
-make_label(const char *label, int frow, int fcol)
-{
-    FIELD *f = new_field(1, (int) strlen(label), frow, fcol, 0, 0);
-
-    if (f) {
-	set_field_buffer(f, 0, label);
-	set_field_opts(f, (int) ((unsigned) field_opts(f) & ~O_ACTIVE));
-    }
-    return (f);
-}
-
-static FIELD *
-make_field(int frow, int fcol, int rows, int cols)
-{
-    FIELD *f = new_field(rows, cols, frow, fcol, 0, 1);
-
-    if (f) {
-	set_field_back(f, A_UNDERLINE);
-	init_edit_field(f, empty);
-    }
-    return (f);
-}
-
-static void
-erase_form(FORM *f)
-{
-    WINDOW *w = form_win(f);
-    WINDOW *s = form_sub(f);
-
-    unpost_form(f);
-    werase(w);
-    wrefresh(w);
-    delwin(s);
-    delwin(w);
-}
-
-static FieldAttrs *
-my_field_attrs(FIELD *f)
-{
-    return (FieldAttrs *) field_userptr(f);
-}
-
-static int
-buffer_length(FIELD *f)
-{
-    return my_field_attrs(f)->row_lengths[0];
-}
-
-static void
-set_buffer_length(FIELD *f, int length)
-{
-    my_field_attrs(f)->row_lengths[0] = length;
-}
-
-static int
-offset_in_field(FORM *form)
-{
-    FIELD *field = current_field(form);
-    int currow, curcol;
-
-    form_getyx(form, currow, curcol);
-    return curcol + currow * (int) field->dcols;
-}
-
-static void
-inactive_field(FIELD *f)
-{
-    set_field_back(f, my_field_attrs(f)->background);
-}
-
-static int
-my_edit_field(FORM *form, int *result)
-{
-    int ch = wgetch(form_win(form));
-    int status;
-    FIELD *before;
-    unsigned n;
-    int length;
-    int before_row;
-    int before_col;
-    int before_off = offset_in_field(form);
-
-    form_getyx(form, before_row, before_col);
-    before = current_field(form);
-    set_field_back(before, A_NORMAL);
-    if (ch <= KEY_MAX) {
-	set_field_back(before, A_REVERSE);
-    } else if (ch <= MAX_FORM_COMMAND) {
-	inactive_field(before);
-    }
-
-    *result = ch;
-    for (n = 0; n < SIZEOF(commands); ++n) {
-	if (commands[n].code == ch) {
-	    *result = commands[n].result;
-	    break;
-	}
-    }
-
-    status = form_driver(form, *result);
-
-    if (status == E_OK) {
-	bool modified = TRUE;
-
-	length = buffer_length(before);
-	if (length < before_off)
-	    length = before_off;
-	switch (*result) {
-	case REQ_CLR_EOF:
-	    length = before_off;
-	    break;
-	case REQ_CLR_EOL:
-	    if ((int) (before_row + 1) == (int) (before->rows))
-		length = before_off;
-	    break;
-	case REQ_CLR_FIELD:
-	    length = 0;
-	    break;
-	case REQ_DEL_CHAR:
-	    if (length > before_off)
-		--length;
-	    break;
-	case REQ_DEL_PREV:
-	    if (length > 0) {
-		if (before_col > 0) {
-		    --length;
-		} else if (before_row > 0) {
-		    length -= (int) before->cols + before_col;
-		}
-	    }
-	    break;
-	case REQ_NEW_LINE:
-	    length += (int) before->cols;
-	    break;
-
-	default:
-	    modified = (ch < MIN_FORM_COMMAND
-			&& isprint(ch));
-	    break;
-	}
-
-	/*
-	 * If we do not force a re-validation, then field_buffer 0 will
-	 * be lagging by one character.
-	 */
-	if (modified && form_driver(form, REQ_VALIDATION) == E_OK && *result
-	    < MIN_FORM_COMMAND)
-	    ++length;
-
-	set_buffer_length(before, length);
-    }
-
-    if (current_field(form) != before)
-	inactive_field(before);
-    return status;
-}
-
-static FIELD **
-copy_fields(FIELD **source, size_t length)
-{
-    FIELD **target = calloc(length + 1, sizeof(FIELD *));
-    memcpy(target, source, length * sizeof(FIELD *));
-    return target;
-}
-
-/* display a status message to show what's happening */
-static void
-show_status(FORM *form, FIELD *field)
-{
-    WINDOW *sub = form_sub(form);
-    int currow, curcol;
-
-    getyx(stdscr, currow, curcol);
-    mvprintw(LINES - 1, 0,
-	     "Field at [%d,%d].  Press %s to quit moving.",
-	     getbegy(sub) + form_field_row(field),
-	     getbegx(sub) + form_field_col(field),
-	     keyname(DO_DEMO));
-    clrtobot();
-    move(currow, curcol);
-    refresh();
-}
-
-/*
- * Move the current label+field in response to cursor-keys (or h,j,k,l) until
- * a control/F is read.
- */
-static void
-do_demo(FORM *form)
-{
-    int count = field_count(form);
-    FIELD *my_field = current_field(form);
-
-    if (count > 0 && my_field != NULL) {
-	size_t needed = (size_t) count;
-	FIELD **old_fields = copy_fields(form_fields(form), needed);
-	FIELD **new_fields = copy_fields(form_fields(form), needed);
-	int ch;
-
-	if (old_fields != NULL && new_fields != NULL) {
-	    bool found = FALSE;
-
-	    /* TODO: move the label too, in parallel with the editing field */
-
-	    /* remove the current field from the newer list */
-	    for (ch = 0; ch <= count; ++ch) {
-		if (found) {
-		    new_fields[ch - 1] = new_fields[ch];
-		} else if (new_fields[ch] == my_field) {
-		    found = TRUE;
-		}
-	    }
-
-	    if (found) {
-		int currow, curcol;
-
-		getyx(stdscr, currow, curcol);
-
-		show_status(form, my_field);
-		ch = '?';
-		while ((ch = wgetch(form_win(form))) != DO_DEMO) {
-		    int field_y = form_field_row(my_field);
-		    int field_x = form_field_col(my_field);
-
-		    switch (ch) {
-		    case 'h':
-		    case KEY_LEFT:
-			if (field_x > 0)
-			    field_x--;
-			break;
-		    case 'j':
-		    case KEY_DOWN:
-			field_y++;
-			break;
-		    case 'k':
-		    case KEY_UP:
-			if (field_y > 0)
-			    field_y--;
-			break;
-		    case 'l':
-		    case KEY_RIGHT:
-			field_x++;
-			break;
-		    case CTRL('Q'):
-		    case CTRL('['):
-			ch = DO_DEMO;
-			/* FALLTHRU */
-		    case DO_DEMO:
-			break;
-		    default:
-			continue;
-		    }
-
-		    if (ch == DO_DEMO)
-			break;
-
-		    /* alter connected fields temporarily to move the field */
-		    unpost_form(form);
-		    set_form_fields(form, new_fields);
-		    post_form(form);
-
-		    /* TODO: update screen position on success */
-		    move_field(my_field, field_y, field_x);
-
-		    /* restore the form's list of fields */
-		    unpost_form(form);
-		    set_form_fields(form, old_fields);
-		    post_form(form);
-
-		    show_status(form, my_field);
-		}
-
-		/* cleanup */
-		move(LINES - 1, 0);
-		clrtobot();
-		move(currow, curcol);
-		refresh();
-	    }
-	}
-	free(new_fields);
-    }
-}
-
-static int
-my_form_driver(FORM *form, int c)
-{
-    switch (c) {
-    case MY_QUIT:
-	if (form_driver(form, REQ_VALIDATION) == E_OK)
-	    return (TRUE);
-	break;
-    case MY_HELP:
-	my_help_edit_field();
-	break;
-    case MY_DEMO:
-	do_demo(form);
-	break;
-    default:
-	beep();
-	break;
-    }
-    return (FALSE);
-}
-
-static void
-demo_forms(void)
-{
-    FORM *form;
-    int c;
-    unsigned n = 0;
-    const char *fname;
-
-    /* describe the form */
-    all_fields[n++] = make_label("Sample Form", 0, 15);
-
-    fname = "Last Name";
-    all_fields[n++] = make_label(fname, 2, 0);
-    all_fields[n++] = make_field(3, 0, 1, 18);
-    set_field_type(all_fields[n - 1], TYPE_ALPHA, 1);
-
-    fname = "First Name";
-    all_fields[n++] = make_label(fname, 2, 20);
-    all_fields[n++] = make_field(3, 20, 1, 12);
-    set_field_type(all_fields[n - 1], TYPE_ALPHA, 1);
-
-    fname = "Middle Name";
-    all_fields[n++] = make_label(fname, 2, 34);
-    all_fields[n++] = make_field(3, 34, 1, 12);
-    set_field_type(all_fields[n - 1], TYPE_ALPHA, 1);
-
-    fname = "Comments";
-    all_fields[n++] = make_label(fname, 5, 0);
-    all_fields[n++] = make_field(6, 0, 4, 46);
-    init_edit_field(all_fields[n - 1], empty);
-
-    all_fields[n] = (FIELD *) 0;
-
-    if ((form = new_form(all_fields)) != 0) {
-	int finished = 0;
-
-	post_form(form);
-
-	while (!finished) {
-	    switch (my_edit_field(form, &c)) {
-	    case E_OK:
-		break;
-	    case E_UNKNOWN_COMMAND:
-		finished = my_form_driver(form, c);
-		break;
-	    default:
-		beep();
-		break;
-	    }
-	}
-
-	erase_form(form);
-
-	free_form(form);
-    }
-    for (c = 0; all_fields[c] != 0; c++) {
-	free_edit_field(all_fields[c]);
-	free_field(all_fields[c]);
-    }
-    noraw();
-    nl();
-}
-
-int
-main(void)
-{
-    setlocale(LC_ALL, "");
-
-    initscr();
-    cbreak();
-    noecho();
-    raw();
-    nonl();			/* lets us read ^M's */
-    intrflush(stdscr, FALSE);
-    keypad(stdscr, TRUE);
-
-    if (has_colors()) {
-	start_color();
-	init_pair(1, COLOR_WHITE, COLOR_BLUE);
-	init_pair(2, COLOR_GREEN, COLOR_BLACK);
-	init_pair(3, COLOR_CYAN, COLOR_BLACK);
-	bkgd((chtype) COLOR_PAIR(1));
-	refresh();
-    }
-
-    demo_forms();
-
-    endwin();
-    ExitProgram(EXIT_SUCCESS);
-}
-
-#else
-int
-main(void)
-{
-    printf("This program requires the curses form library\n");
-    ExitProgram(EXIT_FAILURE);
-}
-#endif
diff --git a/contrib/ncurses/test/test_tparm.c b/contrib/ncurses/test/test_tparm.c
deleted file mode 100644
index 40ffc4fb1d07..000000000000
--- a/contrib/ncurses/test/test_tparm.c
+++ /dev/null
@@ -1,388 +0,0 @@
-/****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
- *                                                                          *
- * Permission is hereby granted, free of charge, to any person obtaining a  *
- * copy of this software and associated documentation files (the            *
- * "Software"), to deal in the Software without restriction, including      *
- * without limitation the rights to use, copy, modify, merge, publish,      *
- * distribute, distribute with modifications, sublicense, and/or sell       *
- * copies of the Software, and to permit persons to whom the Software is    *
- * furnished to do so, subject to the following conditions:                 *
- *                                                                          *
- * The above copyright notice and this permission notice shall be included  *
- * in all copies or substantial portions of the Software.                   *
- *                                                                          *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
- * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
- * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
- *                                                                          *
- * Except as contained in this notice, the name(s) of the above copyright   *
- * holders shall not be used in advertising or otherwise to promote the     *
- * sale, use or other dealings in this Software without prior written       *
- * authorization.                                                           *
- ****************************************************************************/
-
-/*
- * Author: Thomas E. Dickey
- *
- * $Id: test_tparm.c,v 1.4 2020/05/31 00:51:32 tom Exp $
- *
- * Exercise tparm, either for all possible capabilities with fixed parameters,
- * or one capability with all possible parameters.
- *
- * TODO: incorporate tic.h and _nc_tparm_analyze
- * TODO: optionally test tiparm
- * TODO: add checks/logic to handle "%s" in tparm
- */
-#define USE_TINFO
-#include <test.priv.h>
-
-static void failed(const char *) GCC_NORETURN;
-
-static void
-failed(const char *msg)
-{
-    fprintf(stderr, "%s\n", msg);
-    ExitProgram(EXIT_FAILURE);
-}
-
-#if HAVE_TIGETSTR
-
-static int a_opt;
-static int v_opt;
-
-static int
-isNumeric(char *source)
-{
-    char *next = 0;
-    long value = strtol(source, &next, 0);
-    int result = (next == 0 || next == source || *next != '\0') ? 0 : 1;
-    (void) value;
-    return result;
-}
-
-static char *
-validate(const char *name)
-{
-    char *value = tigetstr(name);
-    if (!VALID_STRING(value)) {
-	if (v_opt > 1) {
-	    printf("? %s %s\n",
-		   (value == ABSENT_STRING)
-		   ? "absent"
-		   : "cancel",
-		   name);
-	}
-	value = 0;
-    }
-    return value;
-}
-
-static int
-increment(int *all_parms, int *num_parms, int len_parms, int end_parms)
-{
-    int rc = 0;
-    int n;
-
-    if (len_parms > 9)
-	len_parms = 9;
-
-    if (end_parms < len_parms) {
-	if (all_parms[end_parms]++ >= num_parms[end_parms]) {
-	    all_parms[end_parms] = 0;
-	    increment(all_parms, num_parms, len_parms, end_parms + 1);
-	}
-    }
-    for (n = 0; n < len_parms; ++n) {
-	if (all_parms[n] != 0) {
-	    rc = 1;
-	    break;
-	}
-    }
-    /* return 1 until the vector resets to all 0's */
-    return rc;
-}
-
-static void
-test_tparm(const char *name, int *number)
-{
-    char *format = tigetstr(name);
-    if ((format = validate(name)) != 0) {
-	char *result = tparm(format,
-			     number[0],
-			     number[1],
-			     number[2],
-			     number[3],
-			     number[4],
-			     number[5],
-			     number[6],
-			     number[7],
-			     number[8]);
-	if (v_opt > 1)
-	    printf(".. %2d = %2d %2d %2d %2d %2d %2d %2d %2d %2d %s\n",
-		   result != 0 ? (int) strlen(result) : -1,
-		   number[0],
-		   number[1],
-		   number[2],
-		   number[3],
-		   number[4],
-		   number[5],
-		   number[6],
-		   number[7],
-		   number[8],
-		   name);
-    }
-}
-
-static void
-usage(void)
-{
-    static const char *msg[] =
-    {
-	"Usage: test_tparm [options] [capability] [value1 [value2 [...]]]",
-	"",
-	"Print all distinct combinations of given capability.",
-	"",
-	"Options:",
-	" -T TERM  override $TERM; this may be a comma-separated list or \"-\"",
-	"          to read a list from standard-input",
-	" -a       if capability is given, test all combinations of values",
-	" -r NUM   repeat tests NUM times",
-	" -v       show values and results",
-    };
-    unsigned n;
-    for (n = 0; n < SIZEOF(msg); ++n) {
-	fprintf(stderr, "%s\n", msg[n]);
-    }
-    ExitProgram(EXIT_FAILURE);
-}
-
-#define PLURAL(n) n, (n != 1) ? "s" : ""
-#define COLONS(n) (n >= 1) ? ":" : ""
-
-int
-main(int argc, char *argv[])
-{
-    int n;
-    int r_run, t_run, n_run;
-    char *old_term = getenv("TERM");
-    int r_opt = 1;
-    char *t_opt = 0;
-    int len_names = 0;		/* cur # of items in all_names[] */
-    int use_names = 10;		/* max # of items in all_names[] */
-    char **all_names = typeCalloc(char *, use_names);
-    int all_parms[10];		/* workspace for "-a" option */
-    int len_terms = 0;		/* cur # of items in all_terms[] */
-    int use_terms = 10;		/* max # of items in all_terms[] */
-    char **all_terms = typeCalloc(char *, use_terms);
-    int len_parms = 0;		/* cur # of items in num_parms[], str_parms[] */
-    int use_parms = argc + 10;	/* max # of items in num_parms[], str_parms[] */
-    int *num_parms = typeCalloc(int, use_parms);
-    char **str_parms = typeCalloc(char *, use_parms);
-
-    if (all_names == 0 || all_terms == 0 || num_parms == 0 || str_parms == 0)
-	failed("no memory");
-
-    while ((n = getopt(argc, argv, "T:ar:v")) != -1) {
-	switch (n) {
-	case 'T':
-	    t_opt = optarg;
-	    break;
-	case 'a':
-	    ++a_opt;
-	    break;
-	case 'r':
-	    r_opt = atoi(optarg);
-	    break;
-	case 'v':
-	    ++v_opt;
-	    break;
-	default:
-	    usage();
-	    break;
-	}
-    }
-
-    /*
-     * If there is a nonnumeric parameter after the options, use that as the
-     * capability name.
-     */
-    if (optind < argc) {
-	if (!isNumeric(argv[optind])) {
-	    all_names[len_names++] = strdup(argv[optind++]);
-	}
-    }
-
-    /*
-     * Any remaining arguments must be possible parameter values.  If numeric,
-     * and "-a" is not set, use those as the maximum values within which the
-     * test parameters should vary.
-     */
-    while (optind < argc) {
-	if (isNumeric(argv[optind])) {
-	    char *dummy = 0;
-	    long value = strtol(argv[optind], &dummy, 0);
-	    num_parms[len_parms] = (int) value;
-	}
-	str_parms[len_parms] = argv[optind];
-	++optind;
-	++len_parms;
-    }
-    for (n = len_parms; n < use_parms; ++n) {
-	static char dummy[1];
-	str_parms[n] = dummy;
-    }
-    if (v_opt) {
-	printf("%d parameter%s%s\n", PLURAL(len_parms), COLONS(len_parms));
-	for (n = 0; n < len_parms; ++n) {
-	    printf(" %d: %d (%s)\n", n + 1, num_parms[n], str_parms[n]);
-	}
-    }
-
-    /*
-     * Make a list of values for $TERM.  Accept "-" for standard input to
-     * simplify scripting a check of the whole database.
-     */
-    old_term = strdup((old_term == 0) ? "unknown" : old_term);
-    if (t_opt != 0) {
-	if (!strcmp(t_opt, "-")) {
-	    char buffer[BUFSIZ];
-	    while (fgets(buffer, sizeof(buffer) - 1, stdin) != 0) {
-		char *s = buffer;
-		char *t;
-		while (isspace(UChar(s[0])))
-		    ++s;
-		t = s + strlen(s);
-		while (t != s && isspace(UChar(t[-1])))
-		    *--t = '\0';
-		s = strdup(s);
-		if (len_terms + 2 >= use_terms) {
-		    use_terms *= 2;
-		    all_terms = typeRealloc(char *, use_terms, all_terms);
-		    if (all_terms == 0)
-			failed("no memory: all_terms");
-		}
-		all_terms[len_terms++] = s;
-	    }
-	} else {
-	    char *s = t_opt;
-	    char *t;
-	    while ((t = strtok(s, ",")) != 0) {
-		s = 0;
-		if (len_terms + 2 >= use_terms) {
-		    use_terms *= 2;
-		    all_terms = typeRealloc(char *, use_terms, all_terms);
-		    if (all_terms == 0)
-			failed("no memory: all_terms");
-		}
-		all_terms[len_terms++] = strdup(t);
-	    }
-	}
-    } else {
-	all_terms[len_terms++] = strdup(old_term);
-    }
-    all_terms[len_terms] = 0;
-    if (v_opt) {
-	printf("%d term%s:\n", PLURAL(len_terms));
-	for (n = 0; n < len_terms; ++n) {
-	    printf(" %d: %s\n", n + 1, all_terms[n]);
-	}
-    }
-
-    /*
-     * If no capability name was selected, use the predefined list of string
-     * capabilities.
-     *
-     * TODO: To address the "other" systems which do not follow SVr4,
-     * just use the output from infocmp on $TERM.
-     */
-    if (len_names == 0) {
-#if defined(HAVE_CURSES_DATA_BOOLNAMES) || defined(DECL_CURSES_DATA_BOOLNAMES)
-	for (n = 0; strnames[n] != 0; ++n) {
-	    if (len_names + 2 >= use_names) {
-		use_names *= 2;
-		all_names = typeRealloc(char *, use_names, all_names);
-		if (all_names == 0) {
-		    failed("no memory: all_names");
-		}
-	    }
-	    all_names[len_names++] = strdup(strnames[n]);
-	}
-#else
-	all_names[len_names++] = strdup("cup");
-	all_names[len_names++] = strdup("sgr");
-#endif
-    }
-    all_names[len_names] = 0;
-    if (v_opt) {
-	printf("%d name%s%s\n", PLURAL(len_names), COLONS(len_names));
-	for (n = 0; n < len_names; ++n) {
-	    printf(" %d: %s\n", n + 1, all_names[n]);
-	}
-    }
-
-    if (r_opt <= 0)
-	r_opt = 1;
-
-    for (r_run = 0; r_run < r_opt; ++r_run) {
-	for (t_run = 0; t_run < len_terms; ++t_run) {
-	    int errs;
-
-	    if (setupterm(all_terms[t_run], fileno(stdout), &errs) != OK) {
-		printf("** skipping %s (errs:%d)\n", all_terms[t_run], errs);
-	    }
-
-	    if (v_opt)
-		printf("** testing %s\n", all_terms[t_run]);
-	    if (len_names == 1) {
-		if (a_opt) {
-		    /* for each combination of values */
-		    memset(all_parms, 0, sizeof(all_parms));
-		    do {
-			test_tparm(all_names[0], all_parms);
-		    }
-		    while (increment(all_parms, num_parms, len_parms, 0));
-		} else {
-		    /* for the given values */
-		    test_tparm(all_names[0], num_parms);
-		}
-	    } else {
-		for (n_run = 0; n_run < len_names; ++n_run) {
-		    test_tparm(all_names[n_run], num_parms);
-		}
-	    }
-	    if (cur_term != 0) {
-		del_curterm(cur_term);
-	    } else {
-		printf("? no cur_term\n");
-	    }
-	}
-    }
-#if NO_LEAKS
-    for (n = 0; n < len_names; ++n) {
-	free(all_names[n]);
-    }
-    free(all_names);
-    free(old_term);
-    for (n = 0; n < len_terms; ++n) {
-	free(all_terms[n]);
-    }
-    free(all_terms);
-    free(num_parms);
-    free(str_parms);
-#endif
-
-    ExitProgram(EXIT_SUCCESS);
-}
-
-#else /* !HAVE_TIGETSTR */
-int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
-{
-    failed("This program requires the terminfo functions such as tigetstr");
-}
-#endif /* HAVE_TIGETSTR */
diff --git a/contrib/ntp/COPYRIGHT b/contrib/ntp/COPYRIGHT
index 013202c0fb09..0cb57168ebfc 100644
--- a/contrib/ntp/COPYRIGHT
+++ b/contrib/ntp/COPYRIGHT
@@ -3,7 +3,7 @@ This file is automatically generated from html/copyright.html
 
    jpg "Clone me," says Dolly sheepishly.
 
-   Last update: 2-Mar-2023 05:21 UTC
+   Last update: 7-Jan-2024 00:29 UTC
      __________________________________________________________________
 
    The following copyright notice applies to all files collectively called
@@ -32,7 +32,7 @@ This file is automatically generated from html/copyright.html
    Hart, Danny Mayer, Martin Burnicki, and possibly others is:
 ***********************************************************************
 *                                                                     *
-* Copyright (c) Network Time Foundation 2011-2023                     *
+* Copyright (c) Network Time Foundation 2011-2024                     *
 *                                                                     *
 * All Rights Reserved                                                 *
 *                                                                     *
diff --git a/contrib/ntp/ChangeLog b/contrib/ntp/ChangeLog
index 93cdab8b94eb..f4a196aa57cd 100644
--- a/contrib/ntp/ChangeLog
+++ b/contrib/ntp/ChangeLog
@@ -1,3 +1,121 @@
+---
+(4.2.8p18) 2024/05/25 Released by Harlan Stenn <stenn@ntp.org>
+
+* [Bug 3918] Tweak openssl header/library handling. <stenn@ntp.org>
+* [Bug 3914] Spurious "Unexpected origin timestamp" logged after time
+             stepped. <hart@ntp.org>
+* [Bug 3913] Avoid duplicate IPv6 link-local manycast associations.
+             <hart@ntp.org>
+* [Bug 3912] Avoid rare math errors in ntptrace.  <brian.utterback@oracle.com>
+* [Bug 3910] Memory leak using openssl-3 <hart@ntp.org>
+* [Bug 3909] Do not select multicast local address for unicast peer.
+             <hart@ntp.org>
+* [Bug 3903] lib/isc/win32/strerror.c NTstrerror() is not thread-safe.
+             <hart@ntp.org>
+* [Bug 3901] LIB_GETBUF isn't thread-safe. <hart@ntp.org>
+* [Bug 3900] fast_xmit() selects wrong local addr responding to mcast on
+             Windows. <hart@ntp.org>
+* [Bug 3888] ntpd with multiple same-subnet IPs using manycastclient creates
+             duplicate associations. <hart@ntp.org>
+* [Bug 3872] Ignore restrict mask for hostname. <hart@ntp.org>
+* [Bug 3871] 4.2.8p17 build without hopf6021 refclock enabled fails.
+             Reported by Hans Mayer.  Moved NONEMPTY_TRANSLATION_UNIT
+             declaration from ntp_types.h to config.h.  <hart@ntp.org>
+* [Bug 3870] Server drops client packets with ppoll < 4.  <stenn@ntp.org>
+* [Bug 3869] Remove long-gone "calldelay" & "crypto sign" from docs.
+             Reported by PoolMUC@web.de. <hart@ntp.org>
+* [Bug 3868] Cannot restrict a pool peer. <hart@ntp.org>  Thanks to
+             Edward McGuire for tracking down the deficiency.
+* [Bug 3864] ntpd IPv6 refid different for big-endian and little-endian.
+             <hart@ntp.org>
+* [Bug 3859] Use NotifyIpInterfaceChange on Windows ntpd. <hart@ntp.org>
+* [Bug 3856] Enable Edit & Continue debugging with Visual Studio.
+             <hart@ntp.org>
+* [Bug 3855] ntpq lacks an equivalent to ntpdc's delrestrict. <hart@ntp.org>
+* [Bug 3854] ntpd 4.2.8p17 corrupts rawstats file with space in refid.
+             <hart@ntp.org>
+* [Bug 3853] Clean up warnings with modern compilers. <hart@ntp.org>
+* [Bug 3852] check-libntp.mf and friends are not triggering rebuilds as
+             intended. <hart@ntp.org>
+* [Bug 3851] Drop pool server when no local address can reach it.
+             <hart@ntp.org>
+* [Bug 3850] ntpq -c apeers breaks column formatting s2 w/refclock refid.
+             <hart@ntp.org>
+* [Bug 3849] ntpd --wait-sync times out. <hart@ntp.org>
+* [Bug 3847] SSL detection in configure should run-test if runpath is needed.
+             <hart@ntp.org>
+* [Bug 3846] Use -Wno-format-truncation by default. <hart@ntp.org>
+* [Bug 3845] accelerate pool clock_sync when IPv6 has only link-local access.
+             <hart@ntp.org>
+* [Bug 3842] Windows ntpd PPSAPI DLL load failure crashes. <hart@ntp.org>
+* [Bug 3841] 4.2.8p17 build break w/ gcc 12 -Wformat-security without -Wformat
+             Need to remove --Wformat-security when removing -Wformat to
+             silence numerous libopts warnings.  <hart@ntp.org>
+* [Bug 3837] NULL pointer deref crash when ntpd deletes last interface.
+             Reported by renmingshuai.  Correct UNLINK_EXPR_SLIST() when the
+             list is empty. <hart@ntp.org>
+* [Bug 3835] NTP_HARD_*FLAGS not used by libevent tearoff. <hart@ntp.org>
+* [Bug 3831] pollskewlist zeroed on runtime configuration. <hart@ntp.org>
+* [Bug 3830] configure libevent check intersperses output with answer. <stenn@>
+* [Bug 3828] BK should ignore a git repo in the same directory.
+             <burnicki@ntp.org>
+* [Bug 3827] Fix build in case CLOCK_HOPF6021 or CLOCK_WHARTON_400A
+             is disabled.  <burnicki@ntp.org>
+* [Bug 3825] Don't touch HTML files unless building inside a BK repo.
+             Fix the script checkHtmlFileDates.  <burnicki@ntp.org>
+* [Bug 3756] Improve OpenSSL library/header detection.
+* [Bug 3753] ntpd fails to start with FIPS-enabled OpenSSL 3. <hart@ntp.org>
+* [Bug 2734] TEST3 prevents initial interleave sync.  Fix from <PoolMUC@web.de>
+* Log failures to allocate receive buffers.  <hart@ntp.org>
+* Remove extraneous */ from libparse/ieee754io.c
+* Fix .datecheck target line in Makefile.am.  <stenn@ntp.org>
+* Update the copyright year.  <stenn@ntp.org>
+* Update ntp.conf documentation to add "delrestrict" and correct information
+  about KoD rate limiting.  <hart@ntp.org>
+* html/clockopt.html cleanup.  <stenn@ntp.org>
+* util/lsf-times - added.  <stenn@ntp.org>
+* Add DSA, DSA-SHA, and SHA to tests/libntp/digests.c. <hart@ntp.org>
+* Provide ntpd thread names to debugger on Windows. <hart@ntp.org>
+* Remove dead code libntp/numtohost.c and its unit tests. <hart@ntp.org>
+* Remove class A, B, C IPv4 distinctions in netof(). <hart@ntp.org>
+* Use @configure_input@ in various *.in files to include a comment that
+  the file is generated from another pointing to the *.in. <hart@ntp.org>
+* Correct underquoting, indents in ntp_facilitynames.m4. <hart@ntp.org>
+* Clean up a few warnings seen building with older gcc. <hart@ntp.org>
+* Fix build on older FreeBSD lacking sys/procctl.h. <hart@ntp.org>
+* Disable [Bug 3627] workaround on newer FreeBSD which has the kernel fix
+  that makes it unnecessary, re-enabling ASLR stack gap. <hart@ntp.org>
+* Use NONEMPTY_COMPILATION_UNIT in more conditionally-compiled files.
+* Remove useless pointer to Windows Help from system error messages.
+* Avoid newlines within Windows error messages. <hart@ntp.org>
+* Ensure unique association IDs if wrapped. <hart@ntp.org>
+* Simplify calc_addr_distance(). <hart@ntp.org>
+* Clamp min/maxpoll in edge cases in newpeer(). <hart@ntp.org>
+* Quiet local addr change logging when unpeering. <hart@ntp.org>
+* Correct missing arg for %s printf specifier in 
+  send_blocking_resp_internal(). <hart@ntp.org>
+* Suppress OpenSSL 3 deprecation warning clutter. <hart@ntp.org>
+* Correct OpenSSL usage in Autokey code to avoid warnings about
+  discarding const qualifiers with OpenSSL 3. <hart@ntp.org>
+* Display KoD refid as text in recently added message. <hart@ntp.org>
+* Avoid running checkHtmlFileDates script repeatedly when no html/*.html
+    files have changed. <hart@ntp.org>
+* Abort configure if --enable-crypto-rand given & unavailable. <hart@ntp.org>
+* Add configure --enable-verbose-ssl to trace SSL detection. <hart@ntp.org>
+* Add build test coverage for --disable-saveconfig to flock-build script.
+  <hart@ntp.org>
+* Remove deprecated configure --with-arlib option. <hart@ntp.org>
+* Remove configure support for ISC UNIX ca. 1998. <hart@ntp.org>
+* Move NTP_OPENSSL and NTP_CRYPTO_RAND invocations from configure.ac files
+  to NTP_LIBNTP. <hart@ntp.org>
+* Remove dead code: HAVE_U_INT32_ONLY_WITH_DNS. <hart@ntp.org>
+* Eliminate [v]snprintf redefinition warnings on macOS. <hart@ntp.org>
+* Fix clang 14 cast increases alignment warning on Linux. <hart@ntp.org>
+* Move ENABLE_CMAC to ntp_openssl.m4, reviving sntp/tests CMAC unit tests.
+  <hart@ntp.org>
+* Use NTP_HARD_CPPFLAGS in libopts tearoff. <hart@ntp.org>
+* wire in --enable-build-framework-help
+
 ---
 (4.2.8p17) 2023/06/06 Released by Harlan Stenn <stenn@ntp.org>
 
@@ -10,7 +128,7 @@
 	     Miroslav Lichvar and Matt for rapid testing and identifying the
 	     problem. <hart@ntp.org>
 * Add tests/libntp/digests.c to catch regressions reading keys file or with
-  symmetric authentication digest output.
+  symmetric authentication digest output. <hart@ntp.org>
 
 ---
 (4.2.8p16) 2023/05/31 Released by Harlan Stenn <stenn@ntp.org>
diff --git a/contrib/ntp/CommitLog b/contrib/ntp/CommitLog
index adeda2c60402..49952cfaef0d 100644
--- a/contrib/ntp/CommitLog
+++ b/contrib/ntp/CommitLog
@@ -1,3 +1,3224 @@
+ChangeSet@1.4062, 2024-05-25 00:06:49-07:00, ntpreleng@ntp-build.tal1.ntfo.org
+  NTP_4_2_8P18
+  TAG: NTP_4_2_8P18
+
+  ChangeLog@1.2103 +1 -0
+    NTP_4_2_8P18
+
+  ntpd/invoke-ntp.conf.texi@1.231 +1 -1
+    NTP_4_2_8P18
+
+  ntpd/invoke-ntp.keys.texi@1.214 +1 -1
+    NTP_4_2_8P18
+
+  ntpd/invoke-ntpd.texi@1.528 +2 -2
+    NTP_4_2_8P18
+
+  ntpd/ntp.conf.5man@1.265 +2 -2
+    NTP_4_2_8P18
+
+  ntpd/ntp.conf.5mdoc@1.265 +2 -2
+    NTP_4_2_8P18
+
+  ntpd/ntp.conf.html@1.213 +1 -1
+    NTP_4_2_8P18
+
+  ntpd/ntp.conf.man.in@1.265 +2 -2
+    NTP_4_2_8P18
+
+  ntpd/ntp.conf.mdoc.in@1.265 +2 -2
+    NTP_4_2_8P18
+
+  ntpd/ntp.keys.5man@1.248 +2 -2
+    NTP_4_2_8P18
+
+  ntpd/ntp.keys.5mdoc@1.248 +2 -2
+    NTP_4_2_8P18
+
+  ntpd/ntp.keys.html@1.208 +1 -1
+    NTP_4_2_8P18
+
+  ntpd/ntp.keys.man.in@1.248 +2 -2
+    NTP_4_2_8P18
+
+  ntpd/ntp.keys.mdoc.in@1.248 +2 -2
+    NTP_4_2_8P18
+
+  ntpd/ntpd-opts.c@1.553 +245 -245
+    NTP_4_2_8P18
+
+  ntpd/ntpd-opts.h@1.552 +3 -3
+    NTP_4_2_8P18
+
+  ntpd/ntpd.1ntpdman@1.357 +2 -2
+    NTP_4_2_8P18
+
+  ntpd/ntpd.1ntpdmdoc@1.357 +2 -2
+    NTP_4_2_8P18
+
+  ntpd/ntpd.html@1.202 +2 -2
+    NTP_4_2_8P18
+
+  ntpd/ntpd.man.in@1.357 +2 -2
+    NTP_4_2_8P18
+
+  ntpd/ntpd.mdoc.in@1.357 +2 -2
+    NTP_4_2_8P18
+
+  ntpdc/invoke-ntpdc.texi@1.527 +2 -2
+    NTP_4_2_8P18
+
+  ntpdc/ntpdc-opts.c@1.548 +113 -113
+    NTP_4_2_8P18
+
+  ntpdc/ntpdc-opts.h@1.547 +3 -3
+    NTP_4_2_8P18
+
+  ntpdc/ntpdc.1ntpdcman@1.358 +2 -2
+    NTP_4_2_8P18
+
+  ntpdc/ntpdc.1ntpdcmdoc@1.358 +2 -2
+    NTP_4_2_8P18
+
+  ntpdc/ntpdc.html@1.372 +2 -2
+    NTP_4_2_8P18
+
+  ntpdc/ntpdc.man.in@1.358 +2 -2
+    NTP_4_2_8P18
+
+  ntpdc/ntpdc.mdoc.in@1.358 +2 -2
+    NTP_4_2_8P18
+
+  ntpq/invoke-ntpq.texi@1.537 +2 -2
+    NTP_4_2_8P18
+
+  ntpq/ntpq-opts.c@1.557 +120 -120
+    NTP_4_2_8P18
+
+  ntpq/ntpq-opts.h@1.555 +3 -3
+    NTP_4_2_8P18
+
+  ntpq/ntpq.1ntpqman@1.365 +2 -2
+    NTP_4_2_8P18
+
+  ntpq/ntpq.1ntpqmdoc@1.365 +2 -2
+    NTP_4_2_8P18
+
+  ntpq/ntpq.html@1.202 +2 -2
+    NTP_4_2_8P18
+
+  ntpq/ntpq.man.in@1.365 +2 -2
+    NTP_4_2_8P18
+
+  ntpq/ntpq.mdoc.in@1.365 +2 -2
+    NTP_4_2_8P18
+
+  ntpsnmpd/invoke-ntpsnmpd.texi@1.527 +2 -2
+    NTP_4_2_8P18
+
+  ntpsnmpd/ntpsnmpd-opts.c@1.548 +68 -68
+    NTP_4_2_8P18
+
+  ntpsnmpd/ntpsnmpd-opts.h@1.547 +3 -3
+    NTP_4_2_8P18
+
+  ntpsnmpd/ntpsnmpd.1ntpsnmpdman@1.356 +2 -2
+    NTP_4_2_8P18
+
+  ntpsnmpd/ntpsnmpd.1ntpsnmpdmdoc@1.356 +2 -2
+    NTP_4_2_8P18
+
+  ntpsnmpd/ntpsnmpd.html@1.194 +1 -1
+    NTP_4_2_8P18
+
+  ntpsnmpd/ntpsnmpd.man.in@1.356 +2 -2
+    NTP_4_2_8P18
+
+  ntpsnmpd/ntpsnmpd.mdoc.in@1.356 +2 -2
+    NTP_4_2_8P18
+
+  packageinfo.sh@1.553 +2 -2
+    NTP_4_2_8P18
+
+  scripts/calc_tickadj/calc_tickadj.1calc_tickadjman@1.117 +2 -2
+    NTP_4_2_8P18
+
+  scripts/calc_tickadj/calc_tickadj.1calc_tickadjmdoc@1.119 +2 -2
+    NTP_4_2_8P18
+
+  scripts/calc_tickadj/calc_tickadj.html@1.118 +1 -1
+    NTP_4_2_8P18
+
+  scripts/calc_tickadj/calc_tickadj.man.in@1.116 +2 -2
+    NTP_4_2_8P18
+
+  scripts/calc_tickadj/calc_tickadj.mdoc.in@1.119 +2 -2
+    NTP_4_2_8P18
+
+  scripts/calc_tickadj/invoke-calc_tickadj.texi@1.121 +1 -1
+    NTP_4_2_8P18
+
+  scripts/invoke-plot_summary.texi@1.139 +2 -2
+    NTP_4_2_8P18
+
+  scripts/invoke-summary.texi@1.138 +2 -2
+    NTP_4_2_8P18
+
+  scripts/ntp-wait/invoke-ntp-wait.texi@1.350 +2 -2
+    NTP_4_2_8P18
+
+  scripts/ntp-wait/ntp-wait-opts@1.86 +2 -2
+    NTP_4_2_8P18
+
+  scripts/ntp-wait/ntp-wait.1ntp-waitman@1.345 +2 -2
+    NTP_4_2_8P18
+
+  scripts/ntp-wait/ntp-wait.1ntp-waitmdoc@1.347 +2 -2
+    NTP_4_2_8P18
+
+  scripts/ntp-wait/ntp-wait.html@1.366 +2 -2
+    NTP_4_2_8P18
+
+  scripts/ntp-wait/ntp-wait.man.in@1.345 +2 -2
+    NTP_4_2_8P18
+
+  scripts/ntp-wait/ntp-wait.mdoc.in@1.347 +2 -2
+    NTP_4_2_8P18
+
+  scripts/ntpsweep/invoke-ntpsweep.texi@1.136 +2 -2
+    NTP_4_2_8P18
+
+  scripts/ntpsweep/ntpsweep-opts@1.89 +2 -2
+    NTP_4_2_8P18
+
+  scripts/ntpsweep/ntpsweep.1ntpsweepman@1.124 +2 -2
+    NTP_4_2_8P18
+
+  scripts/ntpsweep/ntpsweep.1ntpsweepmdoc@1.124 +2 -2
+    NTP_4_2_8P18
+
+  scripts/ntpsweep/ntpsweep.html@1.138 +2 -2
+    NTP_4_2_8P18
+
+  scripts/ntpsweep/ntpsweep.man.in@1.124 +2 -2
+    NTP_4_2_8P18
+
+  scripts/ntpsweep/ntpsweep.mdoc.in@1.125 +2 -2
+    NTP_4_2_8P18
+
+  scripts/ntptrace/invoke-ntptrace.texi@1.139 +2 -2
+    NTP_4_2_8P18
+
+  scripts/ntptrace/ntptrace-opts@1.89 +2 -2
+    NTP_4_2_8P18
+
+  scripts/ntptrace/ntptrace.1ntptraceman@1.124 +2 -2
+    NTP_4_2_8P18
+
+  scripts/ntptrace/ntptrace.1ntptracemdoc@1.126 +2 -2
+    NTP_4_2_8P18
+
+  scripts/ntptrace/ntptrace.html@1.139 +2 -2
+    NTP_4_2_8P18
+
+  scripts/ntptrace/ntptrace.man.in@1.124 +2 -2
+    NTP_4_2_8P18
+
+  scripts/ntptrace/ntptrace.mdoc.in@1.127 +2 -2
+    NTP_4_2_8P18
+
+  scripts/plot_summary-opts@1.90 +2 -2
+    NTP_4_2_8P18
+
+  scripts/plot_summary.1plot_summaryman@1.137 +2 -2
+    NTP_4_2_8P18
+
+  scripts/plot_summary.1plot_summarymdoc@1.137 +2 -2
+    NTP_4_2_8P18
+
+  scripts/plot_summary.html@1.141 +2 -2
+    NTP_4_2_8P18
+
+  scripts/plot_summary.man.in@1.137 +2 -2
+    NTP_4_2_8P18
+
+  scripts/plot_summary.mdoc.in@1.137 +2 -2
+    NTP_4_2_8P18
+
+  scripts/summary-opts@1.89 +2 -2
+    NTP_4_2_8P18
+
+  scripts/summary.1summaryman@1.136 +2 -2
+    NTP_4_2_8P18
+
+  scripts/summary.1summarymdoc@1.136 +2 -2
+    NTP_4_2_8P18
+
+  scripts/summary.html@1.140 +2 -2
+    NTP_4_2_8P18
+
+  scripts/summary.man.in@1.136 +2 -2
+    NTP_4_2_8P18
+
+  scripts/summary.mdoc.in@1.136 +2 -2
+    NTP_4_2_8P18
+
+  scripts/update-leap/invoke-update-leap.texi@1.37 +1 -1
+    NTP_4_2_8P18
+
+  scripts/update-leap/update-leap-opts@1.39 +2 -2
+    NTP_4_2_8P18
+
+  scripts/update-leap/update-leap.1update-leapman@1.37 +2 -2
+    NTP_4_2_8P18
+
+  scripts/update-leap/update-leap.1update-leapmdoc@1.38 +2 -2
+    NTP_4_2_8P18
+
+  scripts/update-leap/update-leap.html@1.37 +1 -1
+    NTP_4_2_8P18
+
+  scripts/update-leap/update-leap.man.in@1.37 +2 -2
+    NTP_4_2_8P18
+
+  scripts/update-leap/update-leap.mdoc.in@1.38 +2 -2
+    NTP_4_2_8P18
+
+  sntp/invoke-sntp.texi@1.527 +2 -2
+    NTP_4_2_8P18
+
+  sntp/sntp-opts.c@1.549 +161 -161
+    NTP_4_2_8P18
+
+  sntp/sntp-opts.h@1.547 +3 -3
+    NTP_4_2_8P18
+
+  sntp/sntp.1sntpman@1.362 +2 -2
+    NTP_4_2_8P18
+
+  sntp/sntp.1sntpmdoc@1.362 +2 -2
+    NTP_4_2_8P18
+
+  sntp/sntp.html@1.543 +2 -2
+    NTP_4_2_8P18
+
+  sntp/sntp.man.in@1.362 +2 -2
+    NTP_4_2_8P18
+
+  sntp/sntp.mdoc.in@1.362 +2 -2
+    NTP_4_2_8P18
+
+  util/invoke-ntp-keygen.texi@1.530 +2 -2
+    NTP_4_2_8P18
+
+  util/ntp-keygen-opts.c@1.551 +174 -174
+    NTP_4_2_8P18
+
+  util/ntp-keygen-opts.h@1.549 +3 -3
+    NTP_4_2_8P18
+
+  util/ntp-keygen.1ntp-keygenman@1.358 +2 -2
+    NTP_4_2_8P18
+
+  util/ntp-keygen.1ntp-keygenmdoc@1.358 +2 -2
+    NTP_4_2_8P18
+
+  util/ntp-keygen.html@1.203 +2 -2
+    NTP_4_2_8P18
+
+  util/ntp-keygen.man.in@1.358 +2 -2
+    NTP_4_2_8P18
+
+  util/ntp-keygen.mdoc.in@1.358 +2 -2
+    NTP_4_2_8P18
+
+ChangeSet@1.4061, 2024-05-24 23:46:58-07:00, ntpreleng@ntp-build.tal1.ntfo.org
+  ntp-4.2.8p18
+
+  ChangeLog@1.2102 +0 -2
+    ntp-4.2.8p18
+
+ChangeSet@1.4060, 2024-05-24 22:53:53-07:00, ntpreleng@ntp-build.tal1.ntfo.org
+  NTP_4_2_8P18_RCGO
+  TAG: NTP_4_2_8P18_RCGO
+
+  ChangeLog@1.2101 +1 -0
+    NTP_4_2_8P18_RCGO
+
+  ntpd/invoke-ntp.conf.texi@1.230 +1 -1
+    NTP_4_2_8P18_RCGO
+
+  ntpd/invoke-ntp.keys.texi@1.213 +1 -1
+    NTP_4_2_8P18_RCGO
+
+  ntpd/invoke-ntpd.texi@1.527 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  ntpd/ntp.conf.5man@1.264 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  ntpd/ntp.conf.5mdoc@1.264 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  ntpd/ntp.conf.html@1.212 +1 -1
+    NTP_4_2_8P18_RCGO
+
+  ntpd/ntp.conf.man.in@1.264 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  ntpd/ntp.conf.mdoc.in@1.264 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  ntpd/ntp.keys.5man@1.247 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  ntpd/ntp.keys.5mdoc@1.247 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  ntpd/ntp.keys.html@1.207 +1 -1
+    NTP_4_2_8P18_RCGO
+
+  ntpd/ntp.keys.man.in@1.247 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  ntpd/ntp.keys.mdoc.in@1.247 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  ntpd/ntpd-opts.c@1.552 +7 -7
+    NTP_4_2_8P18_RCGO
+
+  ntpd/ntpd-opts.h@1.551 +3 -3
+    NTP_4_2_8P18_RCGO
+
+  ntpd/ntpd.1ntpdman@1.356 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  ntpd/ntpd.1ntpdmdoc@1.356 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  ntpd/ntpd.html@1.201 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  ntpd/ntpd.man.in@1.356 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  ntpd/ntpd.mdoc.in@1.356 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  ntpdc/invoke-ntpdc.texi@1.526 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  ntpdc/ntpdc-opts.c@1.547 +7 -7
+    NTP_4_2_8P18_RCGO
+
+  ntpdc/ntpdc-opts.h@1.546 +3 -3
+    NTP_4_2_8P18_RCGO
+
+  ntpdc/ntpdc.1ntpdcman@1.357 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  ntpdc/ntpdc.1ntpdcmdoc@1.357 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  ntpdc/ntpdc.html@1.371 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  ntpdc/ntpdc.man.in@1.357 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  ntpdc/ntpdc.mdoc.in@1.357 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  ntpq/invoke-ntpq.texi@1.536 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  ntpq/ntpq-opts.c@1.556 +7 -7
+    NTP_4_2_8P18_RCGO
+
+  ntpq/ntpq-opts.h@1.554 +3 -3
+    NTP_4_2_8P18_RCGO
+
+  ntpq/ntpq.1ntpqman@1.364 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  ntpq/ntpq.1ntpqmdoc@1.364 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  ntpq/ntpq.html@1.201 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  ntpq/ntpq.man.in@1.364 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  ntpq/ntpq.mdoc.in@1.364 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  ntpsnmpd/invoke-ntpsnmpd.texi@1.526 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  ntpsnmpd/ntpsnmpd-opts.c@1.547 +7 -7
+    NTP_4_2_8P18_RCGO
+
+  ntpsnmpd/ntpsnmpd-opts.h@1.546 +3 -3
+    NTP_4_2_8P18_RCGO
+
+  ntpsnmpd/ntpsnmpd.1ntpsnmpdman@1.355 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  ntpsnmpd/ntpsnmpd.1ntpsnmpdmdoc@1.355 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  ntpsnmpd/ntpsnmpd.html@1.193 +1 -1
+    NTP_4_2_8P18_RCGO
+
+  ntpsnmpd/ntpsnmpd.man.in@1.355 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  ntpsnmpd/ntpsnmpd.mdoc.in@1.355 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  packageinfo.sh@1.552 +3 -1
+    NTP_4_2_8P18_RCGO
+
+  scripts/calc_tickadj/calc_tickadj.1calc_tickadjman@1.116 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/calc_tickadj/calc_tickadj.1calc_tickadjmdoc@1.118 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/calc_tickadj/calc_tickadj.html@1.117 +1 -1
+    NTP_4_2_8P18_RCGO
+
+  scripts/calc_tickadj/calc_tickadj.man.in@1.115 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/calc_tickadj/calc_tickadj.mdoc.in@1.118 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/calc_tickadj/invoke-calc_tickadj.texi@1.120 +1 -1
+    NTP_4_2_8P18_RCGO
+
+  scripts/invoke-plot_summary.texi@1.138 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/invoke-summary.texi@1.137 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/ntp-wait/invoke-ntp-wait.texi@1.349 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/ntp-wait/ntp-wait-opts@1.85 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/ntp-wait/ntp-wait.1ntp-waitman@1.344 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/ntp-wait/ntp-wait.1ntp-waitmdoc@1.346 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/ntp-wait/ntp-wait.html@1.365 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/ntp-wait/ntp-wait.man.in@1.344 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/ntp-wait/ntp-wait.mdoc.in@1.346 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/ntpsweep/invoke-ntpsweep.texi@1.135 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/ntpsweep/ntpsweep-opts@1.88 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/ntpsweep/ntpsweep.1ntpsweepman@1.123 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/ntpsweep/ntpsweep.1ntpsweepmdoc@1.123 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/ntpsweep/ntpsweep.html@1.137 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/ntpsweep/ntpsweep.man.in@1.123 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/ntpsweep/ntpsweep.mdoc.in@1.124 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/ntptrace/invoke-ntptrace.texi@1.138 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/ntptrace/ntptrace-opts@1.88 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/ntptrace/ntptrace.1ntptraceman@1.123 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/ntptrace/ntptrace.1ntptracemdoc@1.125 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/ntptrace/ntptrace.html@1.138 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/ntptrace/ntptrace.man.in@1.123 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/ntptrace/ntptrace.mdoc.in@1.126 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/plot_summary-opts@1.89 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/plot_summary.1plot_summaryman@1.136 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/plot_summary.1plot_summarymdoc@1.136 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/plot_summary.html@1.140 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/plot_summary.man.in@1.136 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/plot_summary.mdoc.in@1.136 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/summary-opts@1.88 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/summary.1summaryman@1.135 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/summary.1summarymdoc@1.135 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/summary.html@1.139 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/summary.man.in@1.135 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/summary.mdoc.in@1.135 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/update-leap/invoke-update-leap.texi@1.36 +1 -1
+    NTP_4_2_8P18_RCGO
+
+  scripts/update-leap/update-leap-opts@1.38 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/update-leap/update-leap.1update-leapman@1.36 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/update-leap/update-leap.1update-leapmdoc@1.37 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/update-leap/update-leap.html@1.36 +1 -1
+    NTP_4_2_8P18_RCGO
+
+  scripts/update-leap/update-leap.man.in@1.36 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  scripts/update-leap/update-leap.mdoc.in@1.37 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  sntp/invoke-sntp.texi@1.526 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  sntp/sntp-opts.c@1.548 +7 -7
+    NTP_4_2_8P18_RCGO
+
+  sntp/sntp-opts.h@1.546 +3 -3
+    NTP_4_2_8P18_RCGO
+
+  sntp/sntp.1sntpman@1.361 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  sntp/sntp.1sntpmdoc@1.361 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  sntp/sntp.html@1.542 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  sntp/sntp.man.in@1.361 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  sntp/sntp.mdoc.in@1.361 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  util/invoke-ntp-keygen.texi@1.529 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  util/ntp-keygen-opts.c@1.550 +7 -7
+    NTP_4_2_8P18_RCGO
+
+  util/ntp-keygen-opts.h@1.548 +3 -3
+    NTP_4_2_8P18_RCGO
+
+  util/ntp-keygen.1ntp-keygenman@1.357 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  util/ntp-keygen.1ntp-keygenmdoc@1.357 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  util/ntp-keygen.html@1.202 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  util/ntp-keygen.man.in@1.357 +2 -2
+    NTP_4_2_8P18_RCGO
+
+  util/ntp-keygen.mdoc.in@1.357 +2 -2
+    NTP_4_2_8P18_RCGO
+
+ChangeSet@1.4059, 2024-05-24 00:40:40-07:00, ntpreleng@ntp-build.tal1.ntfo.org
+  Remove duplicate ChangeLog entries
+
+  ChangeLog@1.2100 +1 -1
+    Remove duplicate ChangeLog entries
+
+  NEWS@1.221 +3898 -7
+    Remove duplicate ChangeLog entries
+
+ChangeSet@1.4058, 2024-05-24 00:30:46-07:00, ntpreleng@ntp-build.tal1.ntfo.org
+  Remove duplicate ChangeLog entries
+
+  ChangeLog@1.2099 +0 -4
+    Remove duplicate ChangeLog entries
+
+ChangeSet@1.4057, 2024-05-07 16:50:59-07:00, ntpreleng@ntp-build.tal1.ntfo.org
+  NTP_4_2_8P18_RC1
+  TAG: NTP_4_2_8P18_RC1
+
+  ChangeLog@1.2098 +1 -0
+    NTP_4_2_8P18_RC1
+
+  ntpd/invoke-ntp.conf.texi@1.229 +1 -1
+    NTP_4_2_8P18_RC1
+
+  ntpd/invoke-ntp.keys.texi@1.212 +1 -1
+    NTP_4_2_8P18_RC1
+
+  ntpd/invoke-ntpd.texi@1.526 +2 -2
+    NTP_4_2_8P18_RC1
+
+  ntpd/ntp.conf.5man@1.263 +2 -2
+    NTP_4_2_8P18_RC1
+
+  ntpd/ntp.conf.5mdoc@1.263 +2 -2
+    NTP_4_2_8P18_RC1
+
+  ntpd/ntp.conf.html@1.211 +765 -817
+    NTP_4_2_8P18_RC1
+
+  ntpd/ntp.conf.man.in@1.263 +2 -2
+    NTP_4_2_8P18_RC1
+
+  ntpd/ntp.conf.mdoc.in@1.263 +2 -2
+    NTP_4_2_8P18_RC1
+
+  ntpd/ntp.keys.5man@1.246 +2 -2
+    NTP_4_2_8P18_RC1
+
+  ntpd/ntp.keys.5mdoc@1.246 +3 -3
+    NTP_4_2_8P18_RC1
+
+  ntpd/ntp.keys.html@1.206 +105 -97
+    NTP_4_2_8P18_RC1
+
+  ntpd/ntp.keys.man.in@1.246 +2 -2
+    NTP_4_2_8P18_RC1
+
+  ntpd/ntp.keys.mdoc.in@1.246 +3 -3
+    NTP_4_2_8P18_RC1
+
+  ntpd/ntpd-opts.c@1.551 +245 -245
+    NTP_4_2_8P18_RC1
+
+  ntpd/ntpd-opts.h@1.550 +3 -3
+    NTP_4_2_8P18_RC1
+
+  ntpd/ntpd.1ntpdman@1.355 +2 -2
+    NTP_4_2_8P18_RC1
+
+  ntpd/ntpd.1ntpdmdoc@1.355 +2 -2
+    NTP_4_2_8P18_RC1
+
+  ntpd/ntpd.html@1.200 +398 -427
+    NTP_4_2_8P18_RC1
+
+  ntpd/ntpd.man.in@1.355 +2 -2
+    NTP_4_2_8P18_RC1
+
+  ntpd/ntpd.mdoc.in@1.355 +2 -2
+    NTP_4_2_8P18_RC1
+
+  ntpdc/invoke-ntpdc.texi@1.525 +2 -2
+    NTP_4_2_8P18_RC1
+
+  ntpdc/ntpdc-opts.c@1.546 +113 -113
+    NTP_4_2_8P18_RC1
+
+  ntpdc/ntpdc-opts.h@1.545 +3 -3
+    NTP_4_2_8P18_RC1
+
+  ntpdc/ntpdc.1ntpdcman@1.356 +2 -2
+    NTP_4_2_8P18_RC1
+
+  ntpdc/ntpdc.1ntpdcmdoc@1.356 +2 -2
+    NTP_4_2_8P18_RC1
+
+  ntpdc/ntpdc.html@1.370 +209 -215
+    NTP_4_2_8P18_RC1
+
+  ntpdc/ntpdc.man.in@1.356 +2 -2
+    NTP_4_2_8P18_RC1
+
+  ntpdc/ntpdc.mdoc.in@1.356 +2 -2
+    NTP_4_2_8P18_RC1
+
+  ntpq/invoke-ntpq.texi@1.535 +2 -2
+    NTP_4_2_8P18_RC1
+
+  ntpq/ntpq-opts.c@1.555 +120 -120
+    NTP_4_2_8P18_RC1
+
+  ntpq/ntpq-opts.h@1.553 +3 -3
+    NTP_4_2_8P18_RC1
+
+  ntpq/ntpq.1ntpqman@1.363 +2 -2
+    NTP_4_2_8P18_RC1
+
+  ntpq/ntpq.1ntpqmdoc@1.363 +2 -2
+    NTP_4_2_8P18_RC1
+
+  ntpq/ntpq.html@1.200 +815 -813
+    NTP_4_2_8P18_RC1
+
+  ntpq/ntpq.man.in@1.363 +2 -2
+    NTP_4_2_8P18_RC1
+
+  ntpq/ntpq.mdoc.in@1.363 +2 -2
+    NTP_4_2_8P18_RC1
+
+  ntpsnmpd/invoke-ntpsnmpd.texi@1.525 +2 -2
+    NTP_4_2_8P18_RC1
+
+  ntpsnmpd/ntpsnmpd-opts.c@1.546 +68 -68
+    NTP_4_2_8P18_RC1
+
+  ntpsnmpd/ntpsnmpd-opts.h@1.545 +3 -3
+    NTP_4_2_8P18_RC1
+
+  ntpsnmpd/ntpsnmpd.1ntpsnmpdman@1.354 +2 -2
+    NTP_4_2_8P18_RC1
+
+  ntpsnmpd/ntpsnmpd.1ntpsnmpdmdoc@1.354 +2 -2
+    NTP_4_2_8P18_RC1
+
+  ntpsnmpd/ntpsnmpd.html@1.192 +52 -39
+    NTP_4_2_8P18_RC1
+
+  ntpsnmpd/ntpsnmpd.man.in@1.354 +2 -2
+    NTP_4_2_8P18_RC1
+
+  ntpsnmpd/ntpsnmpd.mdoc.in@1.354 +2 -2
+    NTP_4_2_8P18_RC1
+
+  packageinfo.sh@1.551 +3 -3
+    NTP_4_2_8P18_RC1
+
+  scripts/calc_tickadj/calc_tickadj.1calc_tickadjman@1.115 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/calc_tickadj/calc_tickadj.1calc_tickadjmdoc@1.117 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/calc_tickadj/calc_tickadj.html@1.116 +30 -51
+    NTP_4_2_8P18_RC1
+
+  scripts/calc_tickadj/calc_tickadj.man.in@1.114 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/calc_tickadj/calc_tickadj.mdoc.in@1.117 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/calc_tickadj/invoke-calc_tickadj.texi@1.119 +1 -1
+    NTP_4_2_8P18_RC1
+
+  scripts/invoke-plot_summary.texi@1.137 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/invoke-summary.texi@1.136 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/ntp-wait/invoke-ntp-wait.texi@1.348 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/ntp-wait/ntp-wait-opts@1.84 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/ntp-wait/ntp-wait.1ntp-waitman@1.343 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/ntp-wait/ntp-wait.1ntp-waitmdoc@1.345 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/ntp-wait/ntp-wait.html@1.364 +109 -93
+    NTP_4_2_8P18_RC1
+
+  scripts/ntp-wait/ntp-wait.man.in@1.343 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/ntp-wait/ntp-wait.mdoc.in@1.345 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/ntpsweep/invoke-ntpsweep.texi@1.134 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/ntpsweep/ntpsweep-opts@1.87 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/ntpsweep/ntpsweep.1ntpsweepman@1.122 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/ntpsweep/ntpsweep.1ntpsweepmdoc@1.122 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/ntpsweep/ntpsweep.html@1.136 +39 -65
+    NTP_4_2_8P18_RC1
+
+  scripts/ntpsweep/ntpsweep.man.in@1.122 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/ntpsweep/ntpsweep.mdoc.in@1.123 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/ntptrace/invoke-ntptrace.texi@1.137 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/ntptrace/ntptrace-opts@1.87 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/ntptrace/ntptrace.1ntptraceman@1.122 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/ntptrace/ntptrace.1ntptracemdoc@1.124 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/ntptrace/ntptrace.html@1.137 +96 -81
+    NTP_4_2_8P18_RC1
+
+  scripts/ntptrace/ntptrace.man.in@1.122 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/ntptrace/ntptrace.mdoc.in@1.125 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/plot_summary-opts@1.88 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/plot_summary.1plot_summaryman@1.135 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/plot_summary.1plot_summarymdoc@1.135 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/plot_summary.html@1.139 +46 -73
+    NTP_4_2_8P18_RC1
+
+  scripts/plot_summary.man.in@1.135 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/plot_summary.mdoc.in@1.135 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/summary-opts@1.87 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/summary.1summaryman@1.134 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/summary.1summarymdoc@1.134 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/summary.html@1.138 +41 -66
+    NTP_4_2_8P18_RC1
+
+  scripts/summary.man.in@1.134 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/summary.mdoc.in@1.134 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/update-leap/invoke-update-leap.texi@1.35 +1 -1
+    NTP_4_2_8P18_RC1
+
+  scripts/update-leap/update-leap-opts@1.37 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/update-leap/update-leap.1update-leapman@1.35 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/update-leap/update-leap.1update-leapmdoc@1.36 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/update-leap/update-leap.html@1.35 +48 -80
+    NTP_4_2_8P18_RC1
+
+  scripts/update-leap/update-leap.man.in@1.35 +2 -2
+    NTP_4_2_8P18_RC1
+
+  scripts/update-leap/update-leap.mdoc.in@1.36 +2 -2
+    NTP_4_2_8P18_RC1
+
+  sntp/invoke-sntp.texi@1.525 +2 -2
+    NTP_4_2_8P18_RC1
+
+  sntp/sntp-opts.c@1.547 +161 -161
+    NTP_4_2_8P18_RC1
+
+  sntp/sntp-opts.h@1.545 +3 -3
+    NTP_4_2_8P18_RC1
+
+  sntp/sntp.1sntpman@1.360 +2 -2
+    NTP_4_2_8P18_RC1
+
+  sntp/sntp.1sntpmdoc@1.360 +2 -2
+    NTP_4_2_8P18_RC1
+
+  sntp/sntp.html@1.541 +258 -267
+    NTP_4_2_8P18_RC1
+
+  sntp/sntp.man.in@1.360 +2 -2
+    NTP_4_2_8P18_RC1
+
+  sntp/sntp.mdoc.in@1.360 +2 -2
+    NTP_4_2_8P18_RC1
+
+  util/invoke-ntp-keygen.texi@1.528 +2 -2
+    NTP_4_2_8P18_RC1
+
+  util/ntp-keygen-opts.c@1.549 +174 -174
+    NTP_4_2_8P18_RC1
+
+  util/ntp-keygen-opts.h@1.547 +3 -3
+    NTP_4_2_8P18_RC1
+
+  util/ntp-keygen.1ntp-keygenman@1.356 +2 -2
+    NTP_4_2_8P18_RC1
+
+  util/ntp-keygen.1ntp-keygenmdoc@1.356 +2 -2
+    NTP_4_2_8P18_RC1
+
+  util/ntp-keygen.html@1.201 +676 -652
+    NTP_4_2_8P18_RC1
+
+  util/ntp-keygen.man.in@1.356 +2 -2
+    NTP_4_2_8P18_RC1
+
+  util/ntp-keygen.mdoc.in@1.356 +2 -2
+    NTP_4_2_8P18_RC1
+
+ChangeSet@1.4056, 2024-04-28 22:49:42-05:00, stenn@stenn.chi1.ntfo.org
+  [Bug 2734] TEST3 prevents initial interleave sync
+
+  ChangeLog@1.2097 +1 -0
+    [Bug 2734] TEST3 prevents initial interleave sync
+
+  ntpd/ntp_proto.c@1.459 +3 -1
+    [Bug 2734] TEST3 prevents initial interleave sync
+
+ChangeSet@1.4055, 2024-04-21 03:19:48-05:00, harlan@stenn.chi1.ntfo.org
+  [Bug 3910] Memory leak using openssl-3 <hart@ntp.org>
+
+  ChangeLog@1.2096 +1 -0
+    [Bug 3910] Memory leak using openssl-3 <hart@ntp.org>
+
+ChangeSet@1.4054, 2024-04-21 03:11:17-05:00, harlan@stenn.chi1.ntfo.org
+  [Bug 3918] Tweak openssl header/library handling. <stenn@ntp.org>
+
+  ChangeLog@1.2095 +3 -3
+    [Bug 3918] Tweak openssl header/library handling. <stenn@ntp.org>
+
+ChangeSet@1.4053, 2024-04-17 04:23:11-05:00, harlan@stenn.chi1.ntfo.org
+  [Bug 3870] Server drops client packets with ppoll < 4.  <stenn@ntp.org>
+
+  ChangeLog@1.2094 +1 -0
+    [Bug 3870] Server drops client packets with ppoll < 4.  <stenn@ntp.org>
+
+  ntpd/ntp_proto.c@1.458 +5 -0
+    [Bug 3870] Server drops client packets with ppoll < 4.  <stenn@ntp.org>
+
+ChangeSet@1.4052, 2024-04-17 01:06:36-05:00, harlan@stenn.chi1.ntfo.org
+  [Bug 3912] Avoid rare math errors in ntptrace.  <brian.utterback@oracle.com>
+
+  ChangeLog@1.2093 +1 -0
+    [Bug 3912] Avoid rare math errors in ntptrace.  <brian.utterback@oracle.com>
+
+  scripts/ntptrace/ntptrace.in@1.14 +10 -0
+    [Bug 3912] Avoid rare math errors in ntptrace.  <brian.utterback@oracle.com>
+
+ChangeSet@1.4051, 2024-04-16 21:21:02-05:00, harlan@stenn.chi1.ntfo.org
+  [Bug 3756] Improve OpenSSL-3 detection and usage.
+
+  ChangeLog@1.2092 +1 -0
+    [Bug 3756] Improve OpenSSL-3 detection and usage.
+
+ChangeSet@1.4050, 2024-04-16 18:54:42-05:00, harlan@stenn.chi1.ntfo.org
+  [Bug 3874] ntp_openssl.m4: openssl detection cleanup.  <stenn@ntp.org>
+
+  ChangeLog@1.2091 +1 -1
+    [Bug 3874] ntp_openssl.m4: openssl detection cleanup.  <stenn@ntp.org>
+
+ChangeSet@1.4040.3.2, 2024-04-15 18:23:02-07:00, harlan@ntp-testbuild.tal1.ntfo.org
+  openssl detection cleanup
+
+  ChangeLog@1.2085.3.2 +1 -0
+    openssl detection cleanup
+
+  sntp/m4/ntp_openssl.m4@1.36.1.1 +115 -0
+    openssl detection cleanup
+
+ChangeSet@1.4040.2.3, 2024-04-15 23:27:13+00:00, davehart@tl.ntp.md
+  revert unintended change to "case BLAH:" label indent level in ntp_proto.c
+
+  ntpd/ntp_proto.c@1.454.2.2 +10 -11
+    revert unintended change to "case BLAH:" label indent level.
+
+ChangeSet@1.4040.2.2, 2024-04-15 22:28:07+00:00, davehart@tl.ntp.md
+  Log failures to allocate receive buffers.
+
+  ChangeLog@1.2085.2.2 +1 -0
+    Log failures to allocate receive buffers.
+
+  libntp/recvbuff.c@1.46 +26 -13
+    Log failures to allocate receive buffers.
+
+ChangeSet@1.4040.3.1, 2024-04-14 23:49:56-07:00, harlan@ntp-testbuild.tal1.ntfo.org
+  Wire in --enable-build-framework
+
+  ChangeLog@1.2085.3.1 +1 -0
+    Wire in --enable-build-framework
+
+  configure.ac@1.634.2.1 +17 -0
+    Wire in --enable-build-framework
+
+ChangeSet@1.4040.2.1, 2024-04-13 18:47:27+00:00, davehart@tl.ntp.md
+  [Bug 3914] Spurious "Unexpected origin timestamp" logged after time stepped.
+
+  ChangeLog@1.2085.2.1 +2 -0
+    [Bug 3914] Spurious "Unexpected origin timestamp" logged after time stepped.
+
+  ntpd/ntp_proto.c@1.454.2.1 +34 -20
+    [Bug 3914] Spurious "Unexpected origin timestamp" logged after time stepped.
+    Log suggested poll value with KoD.
+
+ChangeSet@1.4040.1.5, 2024-04-12 12:23:49+00:00, davehart@tl.ntp.md
+  Update libtool initialization macros to recommended.
+  Quiet some more Autoconf deprecation warnings.
+
+  configure.ac@1.634.1.1 +2 -3
+    Update libtool initialization macros to recommended.
+
+  ntpsnmpd/netsnmp_daemonize.c@1.8 +4 -12
+    https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.72/autoconf.html#AC_005fHEADER_005fTIME
+
+  sntp/configure.ac@1.92.1.1 +2 -3
+    Update libtool initialization macros to recommended.
+
+  sntp/libevent/configure.ac@1.21 +1 -1
+    Quiet Autoconf warning by using equivalent non-obsolete macro.
+
+  sntp/libevent/m4/acx_pthread.m4@1.2 +1 -1
+    Quiet Autoconf warning by using equivalent non-obsolete macro.
+
+  sntp/m4/ntp_compiler.m4@1.11 +1 -6
+    Quiet Autoconf warning by using equivalent non-obsolete macro.
+
+  sntp/m4/ntp_libntp.m4@1.41.1.1 +1 -1
+    https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.72/autoconf.html#AC_005fHEADER_005fTIME
+
+ChangeSet@1.4040.1.4, 2024-04-11 02:51:34+00:00, davehart@tl.ntp.md
+  [Bug 3913] Avoid duplicate IPv6 link-local manycast associations.
+  Complete the switch from struct interface to endpt.
+
+  ChangeLog@1.2085.1.2 +2 -0
+    [Bug 3913] Avoid duplicate IPv6 link-local manycast associations.
+
+  include/ntp.h@1.239.1.1 +6 -5
+    Complete the switch from struct interface to endpt.
+
+  include/ntp_control.h@1.61 +1 -1
+    Complete the switch from struct interface to endpt.
+
+  include/ntp_net.h@1.15 +1 -1
+    Complete the switch from struct interface to endpt.
+
+  include/ntpd.h@1.214 +3 -3
+    Complete the switch from struct interface to endpt.
+
+  libntp/socket.c@1.11 +8 -8
+    Complete the switch from struct interface to endpt.
+
+  ntpd/ntp_config.c@1.389 +2 -2
+    Complete the switch from struct interface to endpt.
+
+  ntpd/ntp_control.c@1.242.1.1 +8 -8
+    Complete the switch from struct interface to endpt.
+
+  ntpd/ntp_crypto.c@1.193.1.3 +1 -1
+    Complete the switch from struct interface to endpt.
+
+  ntpd/ntp_io.c@1.443.1.2 +200 -262
+    [Bug 3913] Avoid duplicate IPv6 link-local manycast associations.
+
+  ntpd/ntp_proto.c@1.454.1.1 +33 -10
+    [Bug 3913] Avoid duplicate IPv6 link-local manycast associations.
+
+  ports/winnt/include/ntp_iocpltypes.h@1.7 +0 -1
+    omplete the switch from struct interface to endpt.
+
+ChangeSet@1.4040.1.3, 2024-04-11 01:49:09+00:00, davehart@tl.ntp.md
+  [Bug 3909] Do not select multicast local address for unicast peer.
+
+  ChangeLog@1.2085.1.1 +2 -0
+    [Bug 3909] Do not select multicast local address for unicast peer.
+
+  ntpd/ntp_io.c@1.443.1.1 +26 -20
+    [Bug 3909] Do not select multicast local address for unicast peer.
+
+ChangeSet@1.4047, 2024-04-08 04:35:34+00:00, davehart@tl.ntp.md
+  Fix mismatched braces breaking --enable-leap-smear builds (my mistake).
+  Test --enable-leap-smear in one of the flock-build variants.
+
+  flock-build@1.54 +3 -15
+    Build with leap smearing code active in the -noopenssl variant.
+    Remove references to Dr. Mills' backroom hosts, update udel hosts.
+
+  ntpd/ntp_timer.c@1.102 +3 -2
+    Fix mismatched braces breaking --enable-leap-smear builds (my mistake).
+
+ChangeSet@1.4045, 2024-04-04 21:49:45+00:00, davehart@fips-22-04.davehart.net
+  [Bug 3753] ntpd fails to start with FIPS-enabled OpenSSL 3.
+
+  ChangeLog@1.2088 +1 -0
+    [Bug 3753] ntpd fails to start with FIPS-enabled OpenSSL 3.
+
+  include/Makefile.am@1.59 +1 -0
+    add c99_snprintf.h to quiet [v]snprintf.h redefinition warnings.
+
+  include/ntp.h@1.240 +8 -2
+    Provide more digest size macros for unit tests.
+
+  libntp/a_md5encrypt.c@1.59 +12 -15
+    Do not terminate program on EVP_DigestInit() failure.
+
+  libntp/authkeys.c@1.48 +3 -0
+    Comment only
+
+  libntp/ssl_init.c@1.34 +0 -3
+    Move MD5_LENGTH macro to ntp.h
+
+  ntpd/ntp_io.c@1.446 +1 -1
+    Don't assume AF_UNSPEC is 0.
+
+  sntp/crypto.c@1.43 +33 -39
+    Use size_t rath4er than int/u_int.
+    Add digest buffer size arg to sntp's compute_mac().
+
+  sntp/crypto.h@1.16 +8 -7
+    Use size_t and keyid_t rather than int/u_int.
+
+  sntp/main.c@1.109 +10 -10
+    Close broadcast sockets in sntp's kill_asyncio().
+
+  sntp/tests/crypto.c@1.20 +124 -63
+    Switch unit test digest algorithm from MD5 to SHAKE128 so it works on FIPS OpenSSL.
+
+  sntp/tests/packetHandling.c@1.8 +35 -15
+    Switch unit test digest algorithm from MD5 to SHAKE128 so it works on FIPS OpenSSL.
+
+  sntp/tests/packetProcessing.c@1.21 +112 -54
+    Add SHAKE128 test, make MD5 test XFAIL to handle FIPS OpenSSL.
+
+  sntp/tests/run-crypto.c@1.10 +10 -10
+    generated
+
+  sntp/tests/run-packetProcessing.c@1.16 +19 -17
+    generated
+
+  sntp/unity/unity_internals.h@1.8 +6 -4
+    Make TEST_EXPECT_FAIL_MESSAGE() work.  (Not in upstream)
+
+  tests/libntp/a_md5encrypt.c@1.20 +76 -32
+    Convert MAC unit tests to use SHA1 instead of MD5 for FIPS.
+
+  tests/libntp/digests.c@1.3 +1 -1
+    FIPS OpenSSL is expected to fail to initialize some digests.
+
+  tests/libntp/run-a_md5encrypt.c@1.19 +5 -5
+    generated
+
+  tests/libntp/run-digests.c@1.4 +2 -2
+    generated
+
+  tests/libntp/run-ssl_init.c@1.12 +7 -7
+    generated
+
+  tests/libntp/ssl_init.c@1.12 +3 -7
+    Remove redundant digest length identifiers
+
+  util/lsf-times.c@1.1 +1 -0
+    Stub needed by prior cset util/Makefile.am
+
+  util/lsf-times.c@1.0 +0 -0
+
+ChangeSet@1.4004.7.1, 2024-03-27 02:27:21-07:00, ntpreleng@ntp-bk2git.tal1.ntfo.org
+  authors.txt:
+    Add another email for Pearly
+
+  BitKeeper/etc/authors.txt@1.4 +1 -0
+    Add another email for Pearly
+
+ChangeSet@1.4044, 2024-03-04 13:16:37+00:00, davehart@tl.ntp.md
+  Build MD5 support even with OpenSSL to accomodate FIPS OpenSSL which lacks it.
+  Cache EVP_MD_CTX to avoid many alloc/frees around digest ops.
+
+  include/ntp_md5.h@1.17 +13 -11
+    Build MD5 support even with OpenSSL to accomodate FIPS OpenSSL which lacks it.
+
+  include/ntp_stdlib.h@1.95 +4 -3
+    Cache EVP_MD_CTX to avoid many alloc/frees around digest ops.
+
+  libntp/a_md5encrypt.c@1.58 +33 -64
+    Cache EVP_MD_CTX to avoid many alloc/frees around digest ops.
+
+  libntp/ssl_init.c@1.33 +13 -9
+    Cache EVP_MD_CTX to avoid many alloc/frees around digest ops.
+
+  ntpd/ntp_control.c@1.243 +20 -31
+    Use non-OpenSSL MD5 for mode 6 nonce generation.
+
+  ntpd/ntp_crypto.c@1.196 +16 -41
+    Cache EVP_MD_CTX to avoid many alloc/frees around digest ops.
+
+  ntpd/ntp_proto.c@1.455 +3 -3
+    Clean up debug output of timestamps.
+
+  ports/winnt/include/msvc_ssl_autolib.h@1.4 +1 -1
+    spelling
+
+ChangeSet@1.4043, 2024-02-23 09:09:57+00:00, hart@hart.chi1.ntfo.org
+  ntp_io.c:
+    clean up warnings about math with void *
+
+  ntpd/ntp_io.c@1.445 +3 -2
+    clean up warnings about math with void *
+
+ChangeSet@1.4042, 2024-02-23 08:49:49+00:00, davehart@fips-22-04.davehart.net
+  Remove deprecated configure --with-arlib option.
+  Remove configure support for ISC UNIX ca. 1998.
+  Move NTP_OPENSSL and NTP_CRYPTO_RAND invocations from configure.ac files
+    to NTP_LIBNTP.
+  Move ENABLE_CMAC to ntp_openssl.m4, enabling sntp/tests CMAC unit tests.
+  Remove dead code: HAVE_U_INT32_ONLY_WITH_DNS.
+  Eliminate [v]snprintf redefinition warnings on macOS.
+  Fix clang 14 cast increases alignment warning on Linux.
+  Move ENABLE_CMAC to ntp_openssl.m4, reviving sntp/tests CMAC unit tests.
+  Use NTP_HARD_CPPFLAGS in libopts tearoff.
+
+  BitKeeper/etc/ignore@1.99 +2 -0
+    added sntp/libevent/build-aux/test-driver
+
+  BitKeeper/etc/ignore@1.98 +1 -0
+    added html/.datecheck
+
+  ChangeLog@1.2087 +12 -1
+    Remove deprecated configure --with-arlib option.
+    Remove configure support for ISC UNIX ca. 1998.
+    Move NTP_OPENSSL and NTP_CRYPTO_RAND invocations from configure.ac files
+      to NTP_LIBNTP.
+    Move ENABLE_CMAC to ntp_openssl.m4, enabling sntp/tests CMAC unit tests.
+    Remove dead code: HAVE_U_INT32_ONLY_WITH_DNS.
+    Eliminate [v]snprintf redefinition warnings on macOS.
+    Fix clang 14 cast increases alignment warning on Linux.
+    Move ENABLE_CMAC to ntp_openssl.m4, reviving sntp/tests CMAC unit tests.
+    Use NTP_HARD_CPPFLAGS in libopts tearoff.
+
+  configure.ac@1.635 +2 -30
+    Remove deprecated configure --with-arlib option.
+    Remove support for ISC UNIX ca. 1998.
+    Move NTP_OPENSSL and NTP_CRYPTO_RAND invocations from configure.ac files
+      to NTP_LIBNTP.
+    Move ENABLE_CMAC to ntp_openssl.m4, reviving sntp/tests CMAC unit tests.
+
+  include/c99_snprintf.h@1.1 +28 -0
+    Eliminate [v]snprintf redefinition warnings on macOS.
+
+  include/c99_snprintf.h@1.0 +0 -0
+
+  libntp/ntp_intres.c@1.103 +0 -6
+    Remove dead code: HAVE_U_INT32_ONLY_WITH_DNS.
+
+  ntpd/ntp_io.c@1.444 +3 -5
+    Eliminate clang 14 cast increases alignment warning re: nlmsghdr.
+
+  sntp/configure.ac@1.93 +1 -2
+    Move NTP_OPENSSL and NTP_CRYPTO_RAND invocations from configure.ac files
+      to NTP_LIBNTP.
+
+  sntp/libopts/Makefile.am@1.32 +1 -3
+    Remove unneeded libopts_la_CPPFLAGS which prevented NTP_HARD_CPPFLAGS from being used.
+    Eliminate [v]snprintf redefinition warnings on macOS.
+
+  sntp/m4/ntp_libntp.m4@1.42 +6 -66
+    Move NTP_OPENSSL and NTP_CRYPTO_RAND invocations from configure.ac files
+     to NTP_LIBNTP.
+    Remove dead code: HAVE_U_INT32_ONLY_WITH_DNS.
+    Eliminate [v]snprintf redefinition warnings on macOS.
+
+  sntp/m4/ntp_openssl.m4@1.37 +12 -1
+    Move ENABLE_CMAC to ntp_openssl.m4, enabling sntp/tests CMAC unit tests.
+    Fix ntp_openssl.m4 manual libcrypto search by clearing _cv_ var.
+
+  sntp/tests/crypto.c@1.19 +20 -20
+    Improve test ignore messages.
+
+  sntp/tests/packetProcessing.c@1.20 +1 -1
+    Improve test ignore messages.
+
+  sntp/tests/run-packetProcessing.c@1.15 +19 -19
+    Should have been regenerated last March, oops.
+
+ChangeSet@1.4040.1.1, 2024-02-18 01:31:23-08:00, harlan@ntp-testbuild.tal1.ntfo.org
+  Makefile.am:
+    distribute lsf-times.c in util/Makefile.am
+  lsf-times.c:
+    new file
+  run-refnumtoa.c, run-bug-2803.c:
+    Check in regenerated files
+
+  tests/bug-2803/run-bug-2803.c@1.12 +1 -1
+    Check in regenerated files
+
+  tests/libntp/run-refnumtoa.c@1.12 +2 -2
+    Check in regenerated files
+
+  util/Makefile.am@1.85 +1 -0
+    distribute lsf-times.c in util/Makefile.am
+
+  util/lsf-times.c@1.1 +220 -0
+    BitKeeper file util/lsf-times.c
+
+  util/lsf-times.c@1.0 +0 -0
+
+ChangeSet@1.4040, 2024-02-01 02:22:21-06:00, stenn@stenn.chi1.ntfo.org
+  Fix another extra */
+
+  libparse/ieee754io.c@1.15 +1 -1
+    Fix another extra */
+
+ChangeSet@1.4039, 2024-01-31 21:43:41-08:00, harlan@ntp-testbuild.tal1.ntfo.org
+  Remove an extra */ from libparse/ieee754io.c
+
+  ChangeLog@1.2085 +1 -0
+    Remove an extra */ from libparse/ieee754io.c
+
+  libparse/ieee754io.c@1.14 +1 -1
+    Remove an extra */ from libparse/ieee754io.c
+
+ChangeSet@1.4038, 2024-01-31 21:00:01-08:00, harlan@ntp-testbuild.tal1.ntfo.org
+  Fix .datecheck location in Makefile.am
+
+  ChangeLog@1.2084 +1 -0
+    Fix .datecheck location in Makefile.am
+
+  Makefile.am@1.140 +1 -1
+    Fix .datecheck location in Makefile.am
+
+ChangeSet@1.4036, 2024-01-31 20:47:13+00:00, davehart@tl.ntp.md
+  #ifdef out unused put_ieee754() which triggers a warning and appears buggy.
+  Insert newlines in long error messages in ntp_openssl.m4, ntp_crypto_rand.m4.
+
+  libparse/ieee754io.c@1.13 +21 -2
+    #ifdef out unused put_ieee754() which triggers a warning and appears buggy.
+
+  sntp/m4/ntp_crypto_rand.m4@1.5 +10 -9
+    Insert newlines in long error message.
+
+  sntp/m4/ntp_openssl.m4@1.36 +20 -13
+    Insert newlines in long error messages.
+
+ChangeSet@1.4035, 2024-01-30 09:00:44+00:00, davehart@tl.ntp.md
+  Avoid running checkHtmlFileDates script repeatedly when no html/*.html
+      files have changed.
+  Correct comment, clarify configure --help text re: --with-autokey.
+  Display KoD refid as text in recently added message.
+  Correct OpenSSL usage in Autokey code to avoid warnings about
+      discarding const qualifiers with OpenSSL 3.
+  Avoid clang warning "a function declaration without a prototype is
+      deprecated in all versions of C".
+  Abort configure if --enable-crypto-rand given & unavailable.
+  improve --help output for --enable-c99-snprintf.
+  Add configure --enable-verbose-ssl to trace SSL detection.
+  Silence warnings about dropping const qualifier by making a copy
+      of OpenSSL key data before modifying it in ntp-keygen.
+  Display KoD refid as text in recently added message.
+  Add build test coverage for --disable-saveconfig to flock-build script.
+
+  ChangeLog@1.2082 +11 -2
+    Display KoD refid as text in recently added message.
+    Correct OpenSSL usage in Autokey code to avoid warnings about
+        discarding const qualifiers with OpenSSL 3.
+    Avoid running checkHtmlFileDates script repeatedly when no html/*.html
+    +    files have changed.
+    Add configure --enable-verbose-ssl to trace SSL detection.
+    Add build test coverage for --disable-saveconfig to flock-build script.
+
+  Makefile.am@1.139 +1 -1
+    Avoid running checkHtmlFileDates script repeatedly when no html/*.html
+        files have changed.
+
+  configure.ac@1.634 +2 -2
+    Correct comment, clarify configure --help text re: --with-autokey.
+
+  flock-build@1.53 +2 -2
+    Add build test coverage for --disable-saveconfig to flock-build script.
+
+  libntp/numtoa.c@1.11 +37 -30
+    Display KoD refid as text in recently added message.
+
+  ntpd/ntp_crypto.c@1.193.1.2 +44 -28
+    Correct OpenSSL usage in Autokey code to avoid warnings about
+        discarding const qualifiers with OpenSSL 3.
+
+  ntpd/ntp_io.c@1.443 +1 -1
+    Avoid clang warning "a function declaration without a prototype is
+        deprecated in all versions of C"
+
+  ntpd/ntp_proto.c@1.454 +1 -1
+    Display KoD refid as text in recently added message.
+
+  ntpd/ntp_scanner.c@1.54 +3 -3
+    Avoid clang warning "a function declaration without a prototype is
+        deprecated in all versions of C"
+
+  ntpd/refclock_arc.c@1.35 +8 -5
+    Quiet unused-but-set warning when building non-debug.
+
+  scripts/build/checkHtmlFileDates@1.3 +18 -2
+    Avoid running checkHtmlFileDates script repeatedly when no html/*.html
+        files have changed.
+
+  sntp/m4/ntp_crypto_rand.m4@1.4 +29 -7
+    Abort configure if --enable-crypto-rand given & unavailable.
+
+  sntp/m4/ntp_libntp.m4@1.41 +4 -1
+    improve --help output for --enable-c99-snprintf.
+
+  sntp/m4/ntp_openssl.m4@1.35 +24 -11
+    Add configure --enable-verbose-ssl to trace SSL detection.
+
+  tests/libntp/calendar.c@1.19 +3 -3
+    Avoid clang warning "a function declaration without a prototype is
+        deprecated in all versions of C"
+
+  tests/libntp/clocktime.c@1.10 +2 -2
+    Avoid clang warning "a function declaration without a prototype is
+        deprecated in all versions of C"
+
+  tests/libntp/refnumtoa.c@1.8 +24 -26
+    Display KoD refid as text in recently added message.
+
+  util/ntp-keygen.c@1.113 +35 -20
+    Silence warnings about dropping const qualifier by making a copy
+        of OpenSSL key data before modifying it.
+
+ChangeSet@1.4034, 2024-01-27 00:22:53+00:00, davehart@tl.ntp.md
+  [Bug 3903] lib/isc/win32/strerror.c NTstrerror() is not thread-safe.
+  Suppress OpenSSL 3 deprecation warning clutter.
+  Fix problem with statisics files not being generated (broken after 4.2.8p17)
+  Remove unneeded 200ms wait during NT service shutdown.
+  Do not compile unneded bsd_strerror.c on Windows.
+  Reduce HAVE_IO_COMPLETION_PORT #ifdef clutter by moving calls
+    to io_completion_port_remove_socket into
+    close_and_delete_fd_from_list().
+  Silence warnings building on macOS about incompatible types
+      for timeval.tv_usec.
+  Move massive config parser debug output from debug level 5 to 9.
+  Move yylex() debug output from level 4 to level 10.
+  Change overallocated 1k static lexeme buffer to 128 bytes.
+
+  ChangeLog@1.2081 +3 -0
+    [Bug 3903] lib/isc/win32/strerror.c NTstrerror() is not thread-safe.
+    Suppress OpenSSL 3 deprecation warning clutter.
+
+  include/ntpd.h@1.213 +2 -1
+    Add eptoa() (endpoint to ascii) alternative name for latoa()
+        (local address to ascii).
+
+  libntp/lib/isc/win32/strerror.c@1.18 +21 -14
+    [Bug 3903] lib/isc/win32/strerror.c NTstrerror() is not thread-safe.
+
+  libntp/work_thread.c@1.29 +1 -1
+    correct the correction
+
+  ntpd/ntp_config.c@1.388 +9 -10
+    Fix problem with statisics files not being generated (broken since 4.2.8p17)
+    Move massive config parser debug output from debug level 5 to 9.
+    Avoid "may be used uninitialized" warning re: match_type & action.
+
+  ntpd/ntp_io.c@1.442 +30 -33
+    Reduce HAVE_IO_COMPLETION_PORT #ifdef clutter by moving calls
+      to io_completion_port_remove_socket into
+      close_and_delete_fd_from_list().
+
+  ntpd/ntp_peer.c@1.170 +36 -14
+    Use eptoa() iinstead of equivalent latoa() with endpt *
+
+  ntpd/ntp_scanner.c@1.53 +10 -6
+    Move yylex() debug output from level 4 to level 10.
+    Change overallocated 1k static lexeme buffer to 128 bytes.
+
+  ports/winnt/include/ntp_iocpltypes.h@1.6 +1 -1
+    comment only
+
+  ports/winnt/ntpd/ntservice.c@1.35 +1 -3
+    Do not shut down IO thread until after peers are removed to prevent
+      assertion unpeering a serial refclock.
+    Remove unneeded 200ms wait during service shutdown.
+
+  ports/winnt/vs2015/libntp/libntp.vcxproj@1.12 +0 -1
+    Do not compile unneded bsd_strerror.c on Windows
+
+  ports/winnt/vs2015/libntp/libntp.vcxproj.filters@1.12 +0 -3
+    Do not compile unneded bsd_strerror.c on Windows
+
+  sntp/m4/ntp_openssl.m4@1.34 +9 -1
+    Suppress OpenSSL 3 deprecation warning clutter.
+    Add missing -I in search for evp.h.
+
+  tests/bug-2803/bug-2803.c@1.11 +4 -5
+    Silence warnings building on macOS about incompatible types
+        for timeval.tv_usec.
+
+  tests/libntp/timevalops.c@1.16 +3 -3
+    Suppress OpenSSL 3 deprecation warning clutter.
+
+ChangeSet@1.4028.2.1, 2024-01-22 06:54:06+00:00, davehart@tl.ntp.md
+  [Bug 3901] LIB_GETBUF isn't thread-safe.
+  [Bug 3900] fast_xmit() selects wrong local addr responding to mcast on
+             Windows.
+  [Bug 3888] ntpd with multiple same-subnet IPs using manycastclient creates
+             duplicate associations.
+  Remove useless pointer to Windows Help from system error messages.
+  Avoid newlines within Windows error messages.
+  Ensure unique association IDs if wrapped.
+  Write frequency file to 6 digits after decimal.
+  Unpeer on shutdown as long done on POSIX systems.
+  
+  Simplify calc_addr_distance().
+  Clamp min/maxpoll in edge cases in newpeer().
+  Quiet local addr change logginig when unpeering.
+  Correct missing arg for %s printf specifier in
+    send_blocking_resp_internal().
+
+  ChangeLog@1.2077.2.1 +13 -0
+    [Bug 3901] LIB_GETBUF isn't thread-safe.
+    [Bug 3900] fast_xmit() selects wrong local addr responding to mcast on
+               Windows.
+    [Bug 3888] ntpd with multiple same-subnet IPs using manycastclient creates
+               duplicate associations.
+    Remove useless pointer to Windows Help from system error messages.
+    Avoid newlines within Windows error messages.
+    Ensure unique association IDs if wrapped.
+    Simplify calc_addr_distance().
+    Clamp min/maxpoll in edge cases in newpeer().
+    Quiet local addr change logginig when unpeering.
+    Correct missing arg for %s printf specifier in
+      send_blocking_resp_internal().
+
+  include/lib_strbuf.h@1.13 +10 -15
+    Minimize chances of LIB_STRBUF threading problems (more to come).
+    ---
+    [Bug 3901] LIB_GETBUF isn't thread-safe.
+
+  include/ntp.h@1.236.1.3 +5 -0
+    Quiet local addr change logginig when unpeering.
+
+  libntp/lib/isc/win32/strerror.c@1.17 +30 -3
+    Remove useless pointer to Windows Help from system error messages.
+    Avoid newlines within Windows error messages.
+
+  libntp/lib_strbuf.c@1.13 +39 -15
+    [Bug 3901] LIB_GETBUF isn't thread-safe.
+
+  libntp/work_thread.c@1.28 +6 -2
+    Correct missing arg for %s printf specifier in send_blocking_resp_internal.
+
+  ntpd/ntp_io.c@1.438.1.3 +47 -50
+    Simplify calc_addr_distance().
+
+  ntpd/ntp_peer.c@1.169 +97 -71
+    [Bug 3888] ntpd with multiple same-subnet IPs using manycastclient 
+               creates duplicate associations.
+    Ensure unique association IDs even if we wrap 16 bits.
+    Never change interface for a link-local remote addreess.
+    Clamp min/maxpoll in edge cases in newpeer().
+    Quiet local addr change logginig when unpeering.
+
+  ntpd/ntp_proto.c@1.450.1.3 +20 -7
+    [Bug 3900] fast_xmit() selects wrong local addr responding
+      to mcast on Windows.
+    ---
+    whoops
+
+  ntpd/ntp_util.c@1.125.1.1 +5 -7
+    Write frequency file to 6 digits after decimal.
+
+  ntpq/ntpq-subs.c@1.135.1.1 +1 -1
+    Remove no-op cast.
+
+  ports/winnt/ntpd/ntservice.c@1.34 +1 -0
+    Unpeer on shutdown as long done on POSIX systems.
+
+ChangeSet@1.4028.1.1, 2024-01-07 00:46:19-08:00, harlan@ntp-testbuild.tal1.ntfo.org
+  Makefile.am:
+    Added util/lsf-times
+  Many files:
+    Update copyright year to 2024
+
+  ChangeLog@1.2077.1.1 +2 -0
+    Update copyright year to 2024
+
+  html/copyright.html@1.74 +2 -2
+    Update copyright year to 2024
+
+  ntpd/invoke-ntp.conf.texi@1.228 +1 -1
+    Update copyright year to 2024
+
+  ntpd/invoke-ntp.keys.texi@1.211 +1 -1
+    Update copyright year to 2024
+
+  ntpd/invoke-ntpd.texi@1.525 +1 -1
+    Update copyright year to 2024
+
+  ntpd/ntp.conf.5man@1.262 +3 -3
+    Update copyright year to 2024
+
+  ntpd/ntp.conf.5mdoc@1.262 +3 -3
+    Update copyright year to 2024
+
+  ntpd/ntp.conf.html@1.210 +817 -765
+    Update copyright year to 2024
+
+  ntpd/ntp.conf.man.in@1.262 +3 -3
+    Update copyright year to 2024
+
+  ntpd/ntp.conf.mdoc.in@1.262 +3 -3
+    Update copyright year to 2024
+
+  ntpd/ntp.keys.5man@1.245 +3 -3
+    Update copyright year to 2024
+
+  ntpd/ntp.keys.5mdoc@1.245 +4 -4
+    Update copyright year to 2024
+
+  ntpd/ntp.keys.html@1.205 +97 -105
+    Update copyright year to 2024
+
+  ntpd/ntp.keys.man.in@1.245 +3 -3
+    Update copyright year to 2024
+
+  ntpd/ntp.keys.mdoc.in@1.245 +4 -4
+    Update copyright year to 2024
+
+  ntpd/ntpd-opts.c@1.550 +4 -4
+    Update copyright year to 2024
+
+  ntpd/ntpd-opts.h@1.549 +2 -2
+    Update copyright year to 2024
+
+  ntpd/ntpd.1ntpdman@1.354 +3 -3
+    Update copyright year to 2024
+
+  ntpd/ntpd.1ntpdmdoc@1.354 +3 -3
+    Update copyright year to 2024
+
+  ntpd/ntpd.html@1.199 +427 -398
+    Update copyright year to 2024
+
+  ntpd/ntpd.man.in@1.354 +3 -3
+    Update copyright year to 2024
+
+  ntpd/ntpd.mdoc.in@1.354 +3 -3
+    Update copyright year to 2024
+
+  ntpdc/invoke-ntpdc.texi@1.524 +1 -1
+    Update copyright year to 2024
+
+  ntpdc/ntpdc-opts.c@1.545 +4 -4
+    Update copyright year to 2024
+
+  ntpdc/ntpdc-opts.h@1.544 +2 -2
+    Update copyright year to 2024
+
+  ntpdc/ntpdc.1ntpdcman@1.355 +3 -3
+    Update copyright year to 2024
+
+  ntpdc/ntpdc.1ntpdcmdoc@1.355 +3 -3
+    Update copyright year to 2024
+
+  ntpdc/ntpdc.html@1.369 +215 -209
+    Update copyright year to 2024
+
+  ntpdc/ntpdc.man.in@1.355 +3 -3
+    Update copyright year to 2024
+
+  ntpdc/ntpdc.mdoc.in@1.355 +3 -3
+    Update copyright year to 2024
+
+  ntpq/invoke-ntpq.texi@1.534 +1 -1
+    Update copyright year to 2024
+
+  ntpq/ntpq-opts.c@1.554 +4 -4
+    Update copyright year to 2024
+
+  ntpq/ntpq-opts.h@1.552 +2 -2
+    Update copyright year to 2024
+
+  ntpq/ntpq.1ntpqman@1.362 +3 -3
+    Update copyright year to 2024
+
+  ntpq/ntpq.1ntpqmdoc@1.362 +3 -3
+    Update copyright year to 2024
+
+  ntpq/ntpq.html@1.199 +813 -815
+    Update copyright year to 2024
+
+  ntpq/ntpq.man.in@1.362 +3 -3
+    Update copyright year to 2024
+
+  ntpq/ntpq.mdoc.in@1.362 +3 -3
+    Update copyright year to 2024
+
+  ntpsnmpd/invoke-ntpsnmpd.texi@1.524 +2 -2
+    Update copyright year to 2024
+
+  ntpsnmpd/ntpsnmpd-opts.c@1.545 +4 -4
+    Update copyright year to 2024
+
+  ntpsnmpd/ntpsnmpd-opts.h@1.544 +2 -2
+    Update copyright year to 2024
+
+  ntpsnmpd/ntpsnmpd.1ntpsnmpdman@1.353 +3 -3
+    Update copyright year to 2024
+
+  ntpsnmpd/ntpsnmpd.1ntpsnmpdmdoc@1.353 +3 -3
+    Update copyright year to 2024
+
+  ntpsnmpd/ntpsnmpd.html@1.191 +39 -52
+    Update copyright year to 2024
+
+  ntpsnmpd/ntpsnmpd.man.in@1.353 +3 -3
+    Update copyright year to 2024
+
+  ntpsnmpd/ntpsnmpd.mdoc.in@1.353 +3 -3
+    Update copyright year to 2024
+
+  scripts/calc_tickadj/calc_tickadj.1calc_tickadjman@1.114 +2 -2
+    Update copyright year to 2024
+
+  scripts/calc_tickadj/calc_tickadj.1calc_tickadjmdoc@1.116 +2 -2
+    Update copyright year to 2024
+
+  scripts/calc_tickadj/calc_tickadj.html@1.115 +50 -29
+    Update copyright year to 2024
+
+  scripts/calc_tickadj/calc_tickadj.man.in@1.113 +2 -2
+    Update copyright year to 2024
+
+  scripts/calc_tickadj/calc_tickadj.mdoc.in@1.116 +2 -2
+    Update copyright year to 2024
+
+  scripts/calc_tickadj/invoke-calc_tickadj.texi@1.118 +1 -1
+    Update copyright year to 2024
+
+  scripts/invoke-plot_summary.texi@1.136 +1 -1
+    Update copyright year to 2024
+
+  scripts/invoke-summary.texi@1.135 +1 -1
+    Update copyright year to 2024
+
+  scripts/ntp-wait/invoke-ntp-wait.texi@1.347 +1 -1
+    Update copyright year to 2024
+
+  scripts/ntp-wait/ntp-wait-opts@1.83 +1 -1
+    Update copyright year to 2024
+
+  scripts/ntp-wait/ntp-wait.1ntp-waitman@1.342 +2 -2
+    Update copyright year to 2024
+
+  scripts/ntp-wait/ntp-wait.1ntp-waitmdoc@1.344 +2 -2
+    Update copyright year to 2024
+
+  scripts/ntp-wait/ntp-wait.html@1.363 +93 -109
+    Update copyright year to 2024
+
+  scripts/ntp-wait/ntp-wait.man.in@1.342 +2 -2
+    Update copyright year to 2024
+
+  scripts/ntp-wait/ntp-wait.mdoc.in@1.344 +2 -2
+    Update copyright year to 2024
+
+  scripts/ntpsweep/invoke-ntpsweep.texi@1.133 +1 -1
+    Update copyright year to 2024
+
+  scripts/ntpsweep/ntpsweep-opts@1.86 +1 -1
+    Update copyright year to 2024
+
+  scripts/ntpsweep/ntpsweep.1ntpsweepman@1.121 +2 -2
+    Update copyright year to 2024
+
+  scripts/ntpsweep/ntpsweep.1ntpsweepmdoc@1.121 +2 -2
+    Update copyright year to 2024
+
+  scripts/ntpsweep/ntpsweep.html@1.135 +63 -37
+    Update copyright year to 2024
+
+  scripts/ntpsweep/ntpsweep.man.in@1.121 +2 -2
+    Update copyright year to 2024
+
+  scripts/ntpsweep/ntpsweep.mdoc.in@1.122 +2 -2
+    Update copyright year to 2024
+
+  scripts/ntptrace/invoke-ntptrace.texi@1.136 +1 -1
+    Update copyright year to 2024
+
+  scripts/ntptrace/ntptrace-opts@1.86 +1 -1
+    Update copyright year to 2024
+
+  scripts/ntptrace/ntptrace.1ntptraceman@1.121 +2 -2
+    Update copyright year to 2024
+
+  scripts/ntptrace/ntptrace.1ntptracemdoc@1.123 +2 -2
+    Update copyright year to 2024
+
+  scripts/ntptrace/ntptrace.html@1.136 +81 -96
+    Update copyright year to 2024
+
+  scripts/ntptrace/ntptrace.man.in@1.121 +2 -2
+    Update copyright year to 2024
+
+  scripts/ntptrace/ntptrace.mdoc.in@1.124 +2 -2
+    Update copyright year to 2024
+
+  scripts/plot_summary-opts@1.87 +1 -1
+    Update copyright year to 2024
+
+  scripts/plot_summary.1plot_summaryman@1.134 +2 -2
+    Update copyright year to 2024
+
+  scripts/plot_summary.1plot_summarymdoc@1.134 +2 -2
+    Update copyright year to 2024
+
+  scripts/plot_summary.html@1.138 +71 -44
+    Update copyright year to 2024
+
+  scripts/plot_summary.man.in@1.134 +2 -2
+    Update copyright year to 2024
+
+  scripts/plot_summary.mdoc.in@1.134 +2 -2
+    Update copyright year to 2024
+
+  scripts/summary-opts@1.86 +1 -1
+    Update copyright year to 2024
+
+  scripts/summary.1summaryman@1.133 +2 -2
+    Update copyright year to 2024
+
+  scripts/summary.1summarymdoc@1.133 +2 -2
+    Update copyright year to 2024
+
+  scripts/summary.html@1.137 +64 -39
+    Update copyright year to 2024
+
+  scripts/summary.man.in@1.133 +2 -2
+    Update copyright year to 2024
+
+  scripts/summary.mdoc.in@1.133 +2 -2
+    Update copyright year to 2024
+
+  scripts/update-leap/invoke-update-leap.texi@1.34 +1 -1
+    Update copyright year to 2024
+
+  scripts/update-leap/update-leap-opts@1.36 +1 -1
+    Update copyright year to 2024
+
+  scripts/update-leap/update-leap.1update-leapman@1.34 +2 -2
+    Update copyright year to 2024
+
+  scripts/update-leap/update-leap.1update-leapmdoc@1.35 +2 -2
+    Update copyright year to 2024
+
+  scripts/update-leap/update-leap.html@1.34 +79 -47
+    Update copyright year to 2024
+
+  scripts/update-leap/update-leap.man.in@1.34 +2 -2
+    Update copyright year to 2024
+
+  scripts/update-leap/update-leap.mdoc.in@1.35 +2 -2
+    Update copyright year to 2024
+
+  sntp/include/copyright.def@1.32 +1 -1
+    Update copyright year to 2024
+
+  sntp/invoke-sntp.texi@1.524 +1 -1
+    Update copyright year to 2024
+
+  sntp/sntp-opts.c@1.546 +4 -4
+    Update copyright year to 2024
+
+  sntp/sntp-opts.h@1.544 +2 -2
+    Update copyright year to 2024
+
+  sntp/sntp.1sntpman@1.359 +3 -3
+    Update copyright year to 2024
+
+  sntp/sntp.1sntpmdoc@1.359 +3 -3
+    Update copyright year to 2024
+
+  sntp/sntp.html@1.540 +267 -258
+    Update copyright year to 2024
+
+  sntp/sntp.man.in@1.359 +3 -3
+    Update copyright year to 2024
+
+  sntp/sntp.mdoc.in@1.359 +3 -3
+    Update copyright year to 2024
+
+  util/Makefile.am@1.84 +2 -1
+    Added util/lsf-times
+
+  util/invoke-ntp-keygen.texi@1.527 +1 -1
+    Update copyright year to 2024
+
+  util/ntp-keygen-opts.c@1.548 +4 -4
+    Update copyright year to 2024
+
+  util/ntp-keygen-opts.h@1.546 +2 -2
+    Update copyright year to 2024
+
+  util/ntp-keygen.1ntp-keygenman@1.355 +3 -3
+    Update copyright year to 2024
+
+  util/ntp-keygen.1ntp-keygenmdoc@1.355 +3 -3
+    Update copyright year to 2024
+
+  util/ntp-keygen.html@1.200 +652 -676
+    Update copyright year to 2024
+
+  util/ntp-keygen.man.in@1.355 +3 -3
+    Update copyright year to 2024
+
+  util/ntp-keygen.mdoc.in@1.355 +3 -3
+    Update copyright year to 2024
+
+ChangeSet@1.4032, 2024-01-05 08:09:43+00:00, davehart@tl.ntp.md
+  Fix build failure with forking worker.
+
+  ntpd/ntpd.c@1.190.1.4 +1 -1
+    Fix simulator build.
+
+ChangeSet@1.4029.1.1, 2024-01-04 10:33:34+00:00, davehart@tl.ntp.md
+  Further changes to ensure ntp_openssl.m4 does the right thing on systems
+    where no extra flags are needed to use OpenSSL.
+  Do not disable periodic network interface scans if we are abot
+    to get notifications from Windows, as some systems are observed
+    to get those notifications very late.
+  Update NEWS to note change to require --without-crypto or error out of configure.
+
+  NEWS@1.220 +11 -0
+    Note change to require --without-crypto or error out of configure.
+
+  configure.ac@1.633 +1 -1
+    Force config.cache flush
+
+  ports/winnt/ntpd/ntp_iocompletionport.c@1.87 +2 -1
+    Do not disable periodic network interface scans if we are able
+      to get notifications from Windows, as some systems are observed
+      to get those notifications very late.
+
+  sntp/configure.ac@1.92 +1 -1
+    Force config.cache flush
+
+  sntp/m4/ntp_openssl.m4@1.33 +215 -137
+    Further changes to ensure ntp_openssl.m4 does the right thing on systems
+      where no extra flags are needed to use OpenSSL.
+    Avoid silent downgrade to crypto-free build, error unless --without-crypto.
+
+ChangeSet@1.4026.2.1, 2023-10-30 04:31:05+00:00, davehart@tl.ntp.md
+  [Bug 3847] SSL detection in configure should run-test if runpath is needed.
+  Use @configure_input@ in various *.in files to include a comment that
+    the file is generated from another pointing to the *.in.
+  Correct underquoting, indents in ntp_facilitynames.m4.
+  Clean up a few warnings seen building with older gcc.
+  Fix build on older FreeBSD lacking sys/procctl.h.
+  Disable [Bug 3627] workaround on newer FreeBSD which has the kernel fix
+    that makes it unnecessary, re-enabling ASLR stack gap.
+
+  ChangeLog@1.2075.2.1 +9 -0
+    [Bug 3847] SSL detection in configure should run-test if runpath is needed.
+    Use @configure_input@ in various *.in files to include a comment that
+      the file is generated from another pointing to the *.in.
+    Correct underquoting, indents in ntp_facilitynames.m4.
+    Clean up a few warnings seen building with older gcc.
+    Fix build on older FreeBSD lacking sys/procctl.h.
+    Disable [Bug 3627] workaround on newer FreeBSD which has the kernel fix
+      that makes it unnecessary, re-enabling ASLR stack gap.
+
+  check-libntp.mf@1.4 +4 -1
+    Skip libntp submakes with --disable-dependency-tracking to save time
+      for one-off builds.
+
+  configure.ac@1.630.1.1 +7 -10
+    Use AC_MSG_FAILURE for internal error, which refers user to config.log.
+    Bump configure cache version with ntp_openssl.m4 changes, s/b unneeded.
+    Remove unneded AC_SUBST of CFLAGS & LDFLAGS.
+    Fix build on older FreeBSD lacking sys/procctl.h.
+
+  libntp/ntp_realpath.c@1.3 +22 -21
+    Remove warning for shadowing 'symlink'.
+    Enforce NTP_MAXSYMLINKS correctly.
+
+  libntp/timexsup.c@1.4 +18 -4
+    Fix build on FreeBSD 7 and other ancient systems by following the
+      pattern used elsewhere in our source for including time.h and timex.h.
+
+  libparse/Makefile.am@1.36 +5 -10
+    Use silent rules, $(SED) from Autoconf.
+
+  ntpd/complete.conf.in@1.38.1.1 +11 -11
+    Use RFC 5737 IPv4 documentation prefixes, more exemplary pool hostnames,
+      remove reference to long-gone freenet6.net.
+
+  ntpd/ntp_config.c@1.385.1.1 +20 -16
+    Clean up warning for shadowing 'poll' by renaming attrtopsl() arg
+      from poll to log2_poll.
+
+  ntpd/ntp_util.c@1.124.1.1 +2 -2
+    Uninit FILE *fp, missing %s arg.
+    Add missing arg to statsdir too long msyslog().
+
+  ntpd/ntpd.c@1.190.2.1 +28 -26
+    Remove warning about shadowing "pipe" in detach_from_terminal().
+    Fix build on older FreeBSD lacking sys/procctl.h.
+    Disable [Bug 3627] workaround on newer FreeBSD which has the kernel fix
+      that makes it unnecessary, re-enabling ASLR stack gap.
+
+  ntpdc/nl.pl.in@1.10 +1 -0
+    Add @configure_input@ comment
+
+  ntpq/ntpq-subs.c@1.136 +2 -2
+    Correct comment, indent.
+
+  ntpsnmpd/Makefile.am@1.46 +1 -1
+    Be sure the OpenSSL includes we're using come before any we get
+      from SNMP configuration.
+
+  scripts/build/genAuthors.in@1.3 +1 -0
+    Add @configure_input@ comment
+
+  scripts/build/mkver.in@1.17 +2 -0
+    Add @configure_input@ comment
+
+  scripts/calc_tickadj/calc_tickadj.in@1.5 +1 -0
+    Add @configure_input@ comment
+
+  scripts/ntp-wait/ntp-wait.in@1.13 +1 -0
+    Add @configure_input@ comment
+
+  scripts/ntpsweep/ntpsweep.in@1.10 +1 -0
+    Add @configure_input@ comment
+
+  scripts/ntptrace/ntptrace.in@1.13 +1 -0
+    Add @configure_input@ comment
+
+  scripts/ntpver.in@1.4 +2 -1
+    Add @configure_input@ comment.
+    Use equivalent "version" system variable instead of "daemon_version"
+
+  scripts/plot_summary.in@1.4 +1 -0
+    Add @configure_input@ comment
+
+  scripts/summary.in@1.4 +1 -0
+    Add @configure_input@ comment
+
+  scripts/update-leap/update-leap.in@1.7 +1 -0
+    Add @configure_input@ comment
+
+  sntp/Makefile.am@1.95 +1 -2
+    Fix syntax error "; unexpected" when --enable-local-libevent 
+      is needed for "make dist"
+
+  sntp/check-libntp.mf@1.7 +5 -1
+    Skip libntp submakes with --disable-dependency-tracking to save time
+      for one-off builds.
+
+  sntp/configure.ac@1.91 +1 -1
+    Bump configure cache version, s/b unneeded
+
+  sntp/libevent/kqueue.c@1.9 +1 -1
+    Fix libevent build on older FreeBSD lacking ENOTCAPABLE.
+
+  sntp/m4/ntp_facilitynames.m4@1.2 +20 -13
+    Correct underquoting, indents.
+    No need to check for cross-compiling when we're not running the result.
+
+  sntp/m4/ntp_libntp.m4@1.40 +9 -3
+    Skip libntp submakes with --disable-dependency-tracking to save time
+      for one-off builds.
+    Require AC_PROG_SED, we get it already but document use for $SED/$(SED)
+
+  sntp/m4/ntp_openssl.m4@1.32 +323 -228
+    [Bug 3847] SSL detection in configure should run-test if runpath is needed.
+
+  sntp/tests/fileHandlingTest.h.in@1.16 +7 -1
+    Add @configure_input@ comment
+
+ChangeSet@1.4026.1.1, 2023-09-30 05:35:01+00:00, davehart@tl.ntp.md
+  [Bug 3871] 4.2.8p17 build without hopf6021 refclock enabled fails.
+             Reported by Hans Mayer.  Moved NONEMPTY_TRANSLATION_UNIT
+             declaration from ntp_types.h to config.h.
+  Use NONEMPTY_COMPILATION_UNIT in more conditionally-compiled files.
+
+  ChangeLog@1.2075.1.1 +4 -0
+    [Bug 3871] 4.2.8p17 build without hopf6021 refclock enabled fails.
+               Reported by Hans Mayer.  Moved NONEMPTY_TRANSLATION_UNIT
+               declaration from ntp_types.h to config.h.
+
+  configure.ac@1.631 +12 -0
+    Move NONEMPTY_TRANSLATION_UNIT declaration from ntp_types.h to config.h.
+
+  include/ntp_types.h@1.40 +0 -10
+    Move NONEMPTY_TRANSLATION_UNIT declaration from ntp_types.h to config.h.
+
+  libntp/adjtime.c@1.9 +1 -1
+    Lose unused global
+
+  libntp/audio.c@1.39 +1 -1
+    Lose unused global
+
+  libntp/bsd_strerror.c@1.7 +1 -1
+    Lose unused global
+
+  libntp/snprintf.c@1.14 +1 -1
+    Lose unused global
+
+  libparse/clk_computime.c@1.14 +1 -1
+    Lose unused global
+
+  libparse/clk_dcf7000.c@1.14 +1 -1
+    Lose unused global
+
+  libparse/clk_meinberg.c@1.17 +1 -1
+    Lose unused global
+
+  libparse/clk_rawdcf.c@1.25 +1 -1
+    Lose unused global
+
+  libparse/clk_rcc8000.c@1.13 +1 -1
+    Lose unused global
+
+  libparse/clk_schmid.c@1.16 +1 -1
+    Lose unused global
+
+  libparse/clk_sel240x.c@1.5 +1 -1
+    Lose unused global
+
+  libparse/clk_trimtaip.c@1.14 +1 -1
+    Lose unused global
+
+  libparse/clk_trimtsip.c@1.16 +1 -1
+    Lose unused global
+
+  libparse/clk_varitext.c@1.13 +1 -1
+    Lose unused global
+
+  libparse/parse.c@1.22 +1 -1
+    Lose unused global
+
+  libparse/parse_conf.c@1.12 +1 -1
+    Lose unused global
+
+  ntpd/ntp_crypto.c@1.193.1.1 +1 -1
+    Lose unused global
+
+  ntpd/refclock_acts.c@1.57 +1 -1
+    Lose unused global
+
+  ntpd/refclock_arbiter.c@1.23 +1 -1
+    Lose unused global
+
+  ntpd/refclock_as2201.c@1.19 +1 -1
+    Lose unused global
+
+  ntpd/refclock_atom.c@1.63 +1 -1
+    Lose unused global
+
+  ntpd/refclock_bancomm.c@1.18 +1 -1
+    Lose unused global
+
+  ntpd/refclock_chronolog.c@1.14 +1 -1
+    Lose unused global
+
+  ntpd/refclock_conf.c@1.36 +1 -1
+    Lose unused global
+
+  ntpd/refclock_dumbclock.c@1.21 +1 -1
+    Lose unused global
+
+  ntpd/refclock_fg.c@1.18 +1 -1
+    Lose unused global
+
+  ntpd/refclock_gpsvme.c@1.11 +1 -1
+    Lose unused global
+
+  ntpd/refclock_heath.c@1.22 +1 -1
+    Lose unused global
+
+  ntpd/refclock_hopfpci.c@1.15 +1 -1
+    Lose unused global
+
+  ntpd/refclock_hopfser.c@1.20 +1 -1
+    Lose unused global
+
+  ntpd/refclock_hpgps.c@1.19 +1 -1
+    Lose unused global
+
+  ntpd/refclock_irig.c@1.38 +1 -1
+    Lose unused global
+
+  ntpd/refclock_jjy.c@1.39 +1 -1
+    Lose unused global
+
+  ntpd/refclock_jupiter.c@1.36 +1 -1
+    Lose unused global
+
+  ntpd/refclock_local.c@1.23 +1 -1
+    Lose unused global
+
+  ntpd/refclock_mx4200.c@1.33 +1 -1
+    Lose unused global
+
+  ntpd/refclock_neoclock4x.c@1.25 +1 -1
+    Lose unused global
+
+  ntpd/refclock_oncore.c@1.109 +1 -1
+    Lose unused global
+
+  ntpd/refclock_palisade.c@1.52 +1 -1
+    Lose unused global
+
+  ntpd/refclock_pcf.c@1.14 +1 -1
+    Lose unused global
+
+  ntpd/refclock_pst.c@1.15 +1 -1
+    Lose unused global
+
+  ntpd/refclock_ripencc.c@1.20 +1 -1
+    Lose unused global
+
+  ntpd/refclock_tpro.c@1.15 +1 -1
+    Lose unused global
+
+  ntpd/refclock_true.c@1.29 +1 -1
+    Lose unused global
+
+  ntpd/refclock_tsyncpci.c@1.11 +1 -1
+    Lose unused global
+
+  ntpd/refclock_tt560.c@1.5 +1 -1
+    Lose unused global
+
+  ntpd/refclock_ulink.c@1.21 +1 -1
+    Lose unused global
+
+  ntpd/refclock_wwv.c@1.81 +1 -1
+    Lose unused global
+
+  ntpd/refclock_wwvb.c@1.37 +1 -1
+    Lose unused global
+
+  ntpd/refclock_zyfer.c@1.13 +1 -1
+    Lose unused global
+
+  ntpsnmpd/netsnmp_daemonize.c@1.7 +1 -1
+    Lose unused global
+
+  ports/winnt/include/config.h@1.121 +10 -0
+    Move NONEMPTY_TRANSLATION_UNIT declaration from ntp_types.h to config.h.
+
+  ports/winnt/vs2015/libntp/libntp.vcxproj@1.11 +1 -0
+    Add bsd_strerror.c ref
+
+  ports/winnt/vs2015/libntp/libntp.vcxproj.filters@1.11 +3 -0
+    Add bsd_strerror.c ref
+
+  ports/winnt/vs2015/ntpd/ntpd.vcxproj@1.12 +2 -1
+    Add clk_sel240x.c under Parse Lib
+
+  ports/winnt/vs2015/ntpd/ntpd.vcxproj.filters@1.9 +5 -7
+    Add clk_sel240x.c under Parse Lib
+
+ChangeSet@1.4027, 2023-09-30 03:53:06+00:00, davehart@tl.ntp.md
+  [Bug 3872] Ignore restrict mask for hostname.
+  [Bug 3868] Cannot restrict a pool peer.
+  [Bug 3855] ntpq lacks an equivalent to ntpdc's delrestrict.
+  Correct handling of not-found or unreadable or corrupt driftfile
+    to match comments by starting protocol engine in FREQ mode.
+  Add missing printf-style arg in ntp_util.c.
+  Update ntp.conf documentation to add "delrestrict" and correct
+    information about KoD rate limiting.
+
+  ChangeLog@1.2076 +6 -0
+    [Bug 3872] Ignore restrict mask for hostname.
+    [Bug 3868] Cannot restrict a pool peer.
+    [Bug 3855] ntpq lacks an equivalent to ntpdc's delrestrict.
+    Update ntp.conf documentation to add "delrestrict" and correct
+      information about KoD rate limiting.
+
+  include/ntp.h@1.236.1.2 +6 -7
+    Rearrange restrict_u members for better packing.
+    Change restrict_u.expire from u_long to u_int32.  136 years is plenty of range.
+    Lose RES_FLAGS as the single place it was used has gone away.
+
+  include/ntp_config.h@1.92 +9 -4
+    [Bug 3855] ntpq lacks an equivalent to ntpdc's delrestrict.
+    Expand restrict_node in syntax tree to allow delrestrict in ntp.conf
+      and preserve column along with line for error reporting.
+
+  include/ntpd.h@1.212 +6 -5
+    Indicate success with hack_restrict() return value.
+
+  include/vint64ops.h@1.4 +1 -1
+    Eliminate strtouv64() const warning mess by following strtol() model.
+
+  libntp/vint64ops.c@1.4 +11 -10
+    Eliminate strtouv64() const warning mess by following strtol() model.
+
+  ntpd/complete.conf.in@1.39 +16 -11
+    Add delrestrict lines interspersed with restrict lines.
+    Remove "ippeerlimit -1" entries as that is the default and saveconfig now omits it.
+    Remove all-ones masks as saveconfig now omits them.
+    Live up to the complete.conf name by referencing all the restrict bits.
+    Use doc-reserved IP prefixes.
+
+  ntpd/invoke-ntp.conf.texi@1.227 +40 -25
+    Autogen
+
+  ntpd/keyword-gen-utd@1.37 +1 -1
+    keyword-gen.c output
+
+  ntpd/keyword-gen.c@1.45 +1 -0
+    Add "delrestrict"
+
+  ntpd/ntp.conf.5man@1.261 +42 -26
+    Autogen
+
+  ntpd/ntp.conf.5mdoc@1.261 +45 -26
+    Autogen
+
+  ntpd/ntp.conf.def@1.38 +43 -24
+    Update ntp.conf doocumentation to reflect the addition of "delrestrict",
+      change references to "dotted-quad" addresses to "numeric" to generalize
+      for IPv6 as well, and correct the information about KoD rate limiting.
+
+  ntpd/ntp.conf.html@1.209 +40 -24
+    Autogen
+
+  ntpd/ntp.conf.man.in@1.261 +42 -26
+    Autogen
+
+  ntpd/ntp.conf.mdoc.in@1.261 +45 -26
+    Autogen
+
+  ntpd/ntp_config.c@1.386 +151 -77
+    omit "ipperlimit -1" which is default from restrict saveconfig.
+    Provide column in restrict error messages.
+    Report hack_restrict() failures.
+    Ignore restriction mask when address comes from hostname.
+    normal_dtoa(): don't use strlcpy() for overlapping buffers, undefined behavior.
+
+  ntpd/ntp_io.c@1.438.1.2 +20 -5
+    Make local address deletion message match addition message.
+    Report hack_restrict() failures.
+
+  ntpd/ntp_keyword.h@1.41 +1044 -1034
+    keyword-gen.c output
+
+  ntpd/ntp_leapsec.c@1.27 +1 -1
+    Correct misleading indent
+
+  ntpd/ntp_monitor.c@1.47 +11 -10
+    Use braces consistently, correct KoD rate-limiting comment.
+
+  ntpd/ntp_parser.c@1.121 +1593 -1546
+    bison ntp_parser.y
+
+  ntpd/ntp_parser.h@1.82 +371 -369
+    bison ntp_parser.y
+
+  ntpd/ntp_parser.y@1.109 +50 -21
+    Add "delrestrict" support.
+    Reduce code duplication by factoring out restrict mask parsing.
+    Correct out of bounds ippeerlimit line/col reporting.
+
+  ntpd/ntp_peer.c@1.168 +2 -2
+    Use TRUE/FALSE for restrict_source() remove argument.
+
+  ntpd/ntp_proto.c@1.450.1.2 +6 -12
+    Always add restrict source entry before soliciting pool server.
+
+  ntpd/ntp_request.c@1.134 +12 -3
+    report hack_restrict() failures.
+
+  ntpd/ntp_restrict.c@1.50 +185 -143
+    Sort RESM_SOURCE entries after others so static entries have precedence,
+      allowing runtime-added pool IP restrictions to be effective (Bug 3868].
+    Check for failure of hack_restrict() operations.
+    #ifdef DEBUG dump_restricts() code which was dead code in release builds.
+    Do not assume the first member of struct in_addr is s_addr.
+
+  ntpd/ntp_util.c@1.125 +9 -8
+    Correct handling of not-found or unreadable or corrupt driftfile
+      to match comments by starting protocol engine in FREQ mode.
+    Add missing printf-style arg.
+
+  ntpd/ntpd.c@1.190.1.2 +2 -2
+    Typo broke Linux build.
+
+  tests/libntp/vi64ops.c@1.8 +6 -6
+    Eliminate strtouv64() const warning mess by following strtol() model.
+
+ChangeSet@1.4026, 2023-09-05 20:40:34+00:00, davehart@tl.ntp.md
+  [Bug 3869] Remove long-gone "calldelay" & "crypto sign" from docs.
+  Correct ntp.conf docs burst packet count from 8 to 6.
+
+  ChangeLog@1.2075 +2 -0
+    [Bug 3869] Remove long-gone "calldelay" & "crypto sign" from docs.
+
+  html/release.html@1.44 +1 -1
+    typo
+
+  ntpd/invoke-ntp.conf.texi@1.226 +6 -30
+    Autogen
+
+  ntpd/ntp.conf.5man@1.260 +7 -33
+    Autogen
+
+  ntpd/ntp.conf.5mdoc@1.260 +6 -31
+    Autogen
+
+  ntpd/ntp.conf.def@1.37 +4 -29
+    Remove long-gone "calldelay" & "crypto sign" from docs.
+    Correct burst packet count from 8 to 6.
+
+  ntpd/ntp.conf.html@1.208 +5 -31
+    Autogen
+
+  ntpd/ntp.conf.man.in@1.260 +7 -33
+    Autogen
+
+  ntpd/ntp.conf.mdoc.in@1.260 +6 -31
+    Autogen
+
+ChangeSet@1.4020.3.1, 2023-08-28 19:23:24+00:00, davehart@tl.davehart.net
+  [Bug 3859] Use NotifyIpInterfaceChange on Windows ntpd.
+  Update CommitLog build rule for bk 7.x repo format.
+  Provide ntpd thread names to debugger on Windows.
+  Remove dead code libntp/numtohost.c and its unit tests.
+  Remove class A, B, C IPv4 distinctions in netof().
+
+  BitKeeper/deleted/88/run-test-numtohost.c~5477248c1ca0a276@1.14 +0 -0
+    Rename: tests/libntp/run-numtohost.c -> BitKeeper/deleted/88/run-test-numtohost.c~5477248c1ca0a276
+
+  BitKeeper/deleted/9d/numtohost.c~3e480692@1.7 +0 -0
+    Rename: libntp/numtohost.c -> BitKeeper/deleted/9d/numtohost.c~3e480692
+
+  BitKeeper/deleted/d4/numtohost.c~11c5a6cbd0341da7@1.8 +0 -0
+    Rename: tests/libntp/numtohost.c -> BitKeeper/deleted/d4/numtohost.c~11c5a6cbd0341da7
+
+  ChangeLog@1.2069.3.1 +4 -0
+    [Bug 3859] Use NotifyIpInterfaceChange on Windows ntpd.
+    Provide ntpd thread names to debugger on Windows.
+    Remove dead code libntp/numtohost.c and its unit tests.
+    Remove class A, B, C IPv4 distinctions in netof().
+
+  Makefile.am@1.138 +1 -1
+    Update CommitLog build rule for bk 7.x repo format.
+
+  include/ntp.h@1.236.1.1 +12 -9
+    Remove unused restrict_u member.
+    Move/rename bitflag dumpers for interface and restriction flags,
+      build_iflags() -> iflags_str()
+      build_mflags() -> mflags_str()
+      build_rflags() -> rflags_str()
+
+  include/ntp_net.h@1.12.1.1 +5 -0
+    Add IS_LOOPBACK_ADDR() macro.
+
+  include/ntp_psl.h@1.2 +7 -4
+    Use u_int32 for psl entries to save a few bytes on 64-bit systems.
+
+  include/ntp_stdlib.h@1.91.1.1 +2 -2
+    Include lib_strbuf.h from ntp_stdlib.h, remove many #includes.
+
+  include/ntpd.h@1.211 +51 -12
+    Rename globals for network addr rescans while changing use a bit.
+      interface_interval      -> endpt_scan_period
+      interface_timer         -> endpt_scan_timer
+      disable_dynamic_updates -> scan_addrs_once & no_periodic_scan
+    Move/rename bitflag dumpers for interface and restriction flags,
+      build_iflags() -> iflags_str()
+      build_mflags() -> mflags_str()
+      build_rflags() -> rflags_str()
+    Make the bigflag dumpers #ifdef DEBUG
+
+  libntp/Makefile.am@1.87 +0 -1
+    Remove dead code libntp/numtohost.c
+
+  libntp/clocktypes.c@1.22 +0 -1
+    Remove #include now in ntp_stdlib.h
+
+  libntp/dofptoa.c@1.11 +0 -2
+    Remove #include now in ntp_stdlib.h
+
+  libntp/dolfptoa.c@1.14 +0 -2
+    Remove #include now in ntp_stdlib.h
+
+  libntp/humandate.c@1.13 +0 -1
+    Remove #include now in ntp_stdlib.h
+
+  libntp/lib_strbuf.c@1.10.1.1 +0 -1
+    Remove #include now in ntp_stdlib.h
+
+  libntp/machines.c@1.26.1.1 +0 -1
+    Remove #include now in ntp_stdlib.h
+
+  libntp/modetoa.c@1.7 +0 -1
+    Remove #include now in ntp_stdlib.h
+
+  libntp/netof.c@1.10 +11 -13
+    IPv4 class A, B, C distinctions are now meaningless.
+
+  libntp/ntp_calendar.c@1.27 +0 -1
+    Remove #include now in ntp_stdlib.h
+
+  libntp/numtoa.c@1.8.1.1 +0 -1
+    Remove #include now in ntp_stdlib.h
+
+  libntp/prettydate.c@1.22 +0 -1
+    Remove #include now in ntp_stdlib.h
+
+  libntp/refnumtoa.c@1.13 +0 -1
+    Remove #include now in ntp_stdlib.h
+
+  libntp/socktoa.c@1.20 +0 -1
+    Remove #include now in ntp_stdlib.h
+
+  libntp/socktohost.c@1.17 +0 -1
+    Remove #include now in ntp_stdlib.h
+
+  libntp/statestr.c@1.32 +0 -1
+    Remove #include now in ntp_stdlib.h
+
+  libntp/systime.c@1.79 +0 -1
+    Remove #include now in ntp_stdlib.h
+
+  libntp/uglydate.c@1.6 +0 -1
+    Remove #include now in ntp_stdlib.h
+
+  libntp/work_thread.c@1.27 +6 -3
+    Provide thread name to debugger.
+    Correct comment.
+
+  libparse/ieee754io.c@1.12 +0 -2
+    Remove #include now in ntp_stdlib.h
+
+  ntpd/cmd_args.c@1.65 +7 -9
+    interface_interval -> endpt_scan_period
+
+  ntpd/keyword-gen.c@1.44 +0 -1
+    Remove #include now in ntp_stdlib.h
+
+  ntpd/ntp_config.c@1.385 +69 -339
+    Don't trigger addr rescan from config_nic_rules() during
+      initialization or if we've dropped privileges.
+    Make some internal error checks DEBUG-only.
+    Rename bitflag to string functions:
+      build_iflags() -> iflags_str()
+      build_mflags() -> mflags_str()
+      build_rflags() -> rflags_str()
+    Move iflags_str() to ntp_io.c, the other two to ntp_restrict.c
+    Rename appendstr() -> append_flagstr() and move to ntp_util.c
+    Check for not enough space in append_flagstr().
+    Remove 3k of static string buffers in favor of LIB_GETBUF().
+
+  ntpd/ntp_control.c@1.242 +0 -1
+    Remove #include now in ntp_stdlib.h
+
+  ntpd/ntp_io.c@1.438.1.1 +117 -82
+    Rescan net addrs when notified by Windows of a change.
+    Remove redundant comment
+    Remove #ifdef around init_io_completion_port() call
+    Change default net addr scan interval 300->301 to shift the scans from minute synchrony.
+    Reduce code duplication re: link/site local address classification.
+    Move/rename bitflag dumpers for interface flags:
+      build_iflags() -> iflags_str()
+
+  ntpd/ntp_leapsec.c@1.26 +31 -49
+    Remove #includes in ntp_stdlib.h
+
+  ntpd/ntp_parser.c@1.120 +396 -420
+    generated from ntp_parser.y
+
+  ntpd/ntp_parser.h@1.81 +8 -6
+    generated from ntp_parser.y
+
+  ntpd/ntp_parser.y@1.108 +6 -1
+    Use NTP_MINPOLL/NTP_MAXPOLL instead of hard-coding.
+
+  ntpd/ntp_peer.c@1.167 +6 -4
+    Do not log endpt changes for multicast addresses, they're
+      meaningless as we send from a list of endpoints (addresses).
+
+  ntpd/ntp_proto.c@1.449.1.1 +57 -61
+    Debug output improvements.
+    Display offset, delay, jitter to 9 decimal places in debug output.
+    Use mprintf_event() in a few places rather than snprintf + report_event.
+    Move/rename bitflag dumpers for interface and restriction flags,
+      build_iflags() -> iflags_str()
+      build_mflags() -> mflags_str()
+      build_rflags() -> rflags_str()
+    Use "0x%x" instead of "%#010x" displaying l_fp seconds as the
+      latter doesnn't work with Microsoft C.
+
+  ntpd/ntp_restrict.c@1.49 +264 -157
+    inline inc_/dec_res_limited()
+    Make some unlikely assertions DEBUG-only.
+    Remove voluminous debug output from match_restrict4_addr().
+    Rename roptoa() -> resoop_str().
+    Display flag bit names in hack_restrict() debug output.
+    Move/rename bitflag dumpers for restriction rflags, mflags.
+      build_mflags() -> mflags_str()
+      build_rflags() -> rflags_str()
+    The two above were moved from ntp_config.c and modified to use LIB_STRBUF().
+
+  ntpd/ntp_timer.c@1.99.1.1 +35 -36
+    Rescan interfaces when notified by Windows of a change.
+    Remove interface_timer and interface_interval variables implementing
+      network interface periodic scans.
+    Replace those variables with endpt_scan_timer and endpt_scan_period
+      which are implemented slightly differently to enable on-change scans
+      on Windows with periodic re-scans suppressed.
+    Split disable_dynamic_updates into two variables:
+      no_periodic_scans
+      scan_addrs_once
+
+  ntpd/ntp_util.c@1.124 +127 -107
+    Remove #include now in ntp_stdlib.h
+
+  ntpd/ntpd.c@1.190.1.1 +10 -18
+    Split disable_dynamic_updates into two variables:
+      no_periodic_scans
+      scan_addrs_once
+    Remove interface_timer and interface_interval variables implementing
+      network interface periodic scans.
+    Replace those variables with endpt_scan_timer and endpt_scan_period
+      which are implemented slightly differently to enable on-change scans
+      on Windows with periodic re-scans suppressed.
+
+  ntpd/refclock_nmea.c@1.85 +2 -0
+    Eliminate unused func field_length() warning.
+
+  ntpq/ntpq.c@1.199 +0 -4
+    Remove #includes in ntpq.h
+
+  ntpq/ntpq.h@1.34 +0 -1
+    Remove #include now in ntp_stdlib.h
+
+  ports/winnt/include/clockstuff.h@1.14 +6 -0
+    Provide thread names to debugger.
+
+  ports/winnt/include/config.h@1.120 +17 -13
+    Update list of known _MSC_VER values
+
+  ports/winnt/include/ntp_iocompletionport.h@1.24 +30 -5
+    Use NotifyIpInterfaceChange on Windows Vista and newer.
+
+  ports/winnt/include/ntservice.h@1.7 +0 -1
+    Remove dead function declaration.
+
+  ports/winnt/include/win32_io.h@1.3 +2 -2
+    whitespace
+
+  ports/winnt/instsrv/instsrv.c@1.13 +1 -1
+    Correct app name
+
+  ports/winnt/libntp/getclock.c@1.6 +7 -0
+    Provide thread names to debugger.
+
+  ports/winnt/libntp/syslog.c@1.12 +0 -56
+    Remove long-dead code.
+
+  ports/winnt/libntp/win32_io.c@1.4 +13 -9
+    Bail out of InitSockets() when called more than once.
+
+  ports/winnt/ntpd/hopf_PCI_io.c@1.10 +11 -28
+    ntpd has never been able to run on Win32s (Win 3.1), remove check.
+
+  ports/winnt/ntpd/nt_clockstuff.c@1.68 +18 -44
+    Provide thread names to debugger.
+    Update my email address.
+    Remove code for unsupported pre-VS 2008 compiler.
+    Use Windows version number already discovered by libisc.
+
+  ports/winnt/ntpd/nt_ppsimpl.c@1.7 +0 -1
+    Remove #include now in ntp_stdlib.h
+
+  ports/winnt/ntpd/ntp_iocompletionport.c@1.86 +125 -68
+    Rescan net addrs when notified by Windows of a change.
+    Provide thread names to debugger.
+    Use Windows version number already discovered by libisc.
+
+  ports/winnt/ntpd/ntservice.c@1.33 +10 -13
+    Return immediately from service control handler when asked
+      to stop rather than sleeping for 100ms after signaling
+      the main thread to exit().
+
+  ports/winnt/vs2005/libntp.vcproj@1.31 +0 -4
+    Remove dead code libntp/numtohost.c
+
+  ports/winnt/vs2008/libntp/libntp.vcproj@1.62 +0 -4
+    Remove dead code libntp/numtohost.c
+
+  ports/winnt/vs2013/libntp/libntp.vcxproj@1.18 +0 -1
+    Remove dead code libntp/numtohost.c
+
+  ports/winnt/vs2013/libntp/libntp.vcxproj.filters@1.16 +0 -3
+    Remove dead code libntp/numtohost.c
+
+  ports/winnt/vs2015/libntp/libntp.vcxproj@1.10 +0 -1
+    Remove dead code libntp/numtohost.c
+
+  ports/winnt/vs2015/libntp/libntp.vcxproj.filters@1.10 +0 -3
+    Remove dead code libntp/numtohost.c
+
+  sntp/tests/crypto.c@1.16.1.1 +0 -6
+    Remove unused locals in test_VerifyCMAC()
+
+  sntp/utilities.h@1.12 +0 -1
+    Remove #include now in ntp_stdlib.h
+
+  tests/libntp/Makefile.am@1.105 +0 -12
+    Remove tests for dead code libntp/numtohost.c
+
+  tests/libntp/caljulian.c@1.16 +0 -1
+    Remove #include now in ntp_stdlib.h
+
+  tests/libntp/netof.c@1.11 +0 -33
+    IPv4 class A, B, C distinctions are now meaningless.
+
+  tests/libntp/run-caljulian.c@1.17 +4 -5
+    generated
+
+  tests/libntp/run-netof.c@1.11 +2 -6
+    generated
+
+  tests/ntpd/leapsec.c@1.6 +0 -1
+    Remove #include now in ntp_stdlib.h
+
+  tests/ntpd/run-leapsec.c@1.10 +33 -34
+    generated
+
+ChangeSet@1.4023.2.1, 2023-08-24 14:06:05+00:00, davehart@tl.davehart.net
+  [Bug 3753] ntpd won't start with FIPS-enabled OpenSSL 3.x.
+
+  ChangeLog@1.2072.2.1 +1 -0
+    [Bug 3753] ntpd won't start with FIPS-enabled OpenSSL 3.x.
+
+  include/ntp_md5.h@1.16 +3 -2
+    Reduce use of magic numbers
+
+  include/ntp_stdlib.h@1.93 +5 -3
+    add arg names to func declarations
+
+  libntp/a_md5encrypt.c@1.55.1.1 +79 -60
+    [Bug 3753] ntpd won't start with FIPS-enabled OpenSSL 3.x.
+
+  libntp/ssl_init.c@1.32 +21 -29
+    Reduce code duplication.
+
+  ntpd/ntp_crypto.c@1.194 +0 -1
+    move ssl_check_version from autokey-specific code to ntpdmain()
+
+  ntpd/ntpd.c@1.191 +5 -2
+    Move ssl_check_version from autokey-specific code to ntpdmain().
+    Put debug behavior msyslog on a single log line.
+
+ChangeSet@1.4023.1.1, 2023-08-23 10:58:43+00:00, davehart@tl.davehart.net
+  [Bug 3864] ntpd IPv6 refid different for big-endian and little-endian.
+
+  ChangeLog@1.2072.1.1 +2 -0
+    [Bug 3864] ntpd IPv6 refid different for big-endian and little-endian.
+
+  include/ntp.h@1.237 +9 -0
+    Track old-style IPv6 refid on big-endian systems
+
+  libntp/a_md5encrypt.c@1.56 +14 -2
+    [Bug 3864] Ensure refid calculation is endian-independent.
+
+  ntpd/ntp_io.c@1.439 +5 -0
+    Track old-style IPv6 refid on big-endian systems
+
+  ntpd/ntp_proto.c@1.451 +26 -4
+    Check both old- and new-style IPv6 refids on big-endian systems.
+
+  tests/libntp/a_md5encrypt.c@1.19 +9 -18
+    Enable IPv6 refid unit test that failed due to bug 3864.
+
+ChangeSet@1.4020.2.1, 2023-08-23 03:34:00+00:00, davehart@tl.davehart.net
+  [Bug 3854] ntpd 4.2.8p17 corrupts rawstats file with space in refid.
+
+  ChangeLog@1.2069.2.1 +2 -0
+    [Bug 3854] ntpd 4.2.8p17 corrupts rawstats file with space in refid.
+
+  include/ntp_net.h@1.13 +6 -0
+    LOOPBACKADR_N in network order
+
+  libntp/numtoa.c@1.9 +15 -7
+    Replace unprintable characters with ? instead of space.
+    Do not treat orphan refid 127.0.0.1 as text.
+
+  ntpd/ntp_timer.c@1.100 +133 -127
+    Change orphan mode s1 refid from LOOP to ORPH.
+    Clean up indents in leap second handling code.
+
+ChangeSet@1.4020.1.1, 2023-08-02 19:07:28+00:00, davehart@tl.davehart.net
+  [Bug 3856] Enable Edit & Continue debugging with Visual Studio.
+
+  ChangeLog@1.2069.1.1 +2 -0
+    [Bug 3856] Enable Edit & Continue debugging with Visual Studio.
+
+  ports/winnt/vs2015/debug-x64.props@1.6 +10 -0
+    Enable Edit & Continue debugging
+
+  ports/winnt/vs2015/debug.props@1.6 +11 -0
+    Enable Edit & Continue debugging
+
+ChangeSet@1.4022, 2023-07-31 12:41:01+00:00, davehart@tl.davehart.net
+  [Bug 3853] Clean up warnings with modern compilers.
+             partial, more to come.
+
+  ChangeLog@1.2071 +1 -0
+    [Bug 3853] Clean up warnings with modern compilers.
+               partial, more to come.
+
+  include/lib_strbuf.h@1.12 +16 -11
+    Keep a pointer to each LIB_GETBUF buffer to avoid -Wrestrict warnings.
+
+  include/ntp_stdlib.h@1.92 +1 -0
+    Keep a pointer to each LIB_GETBUF buffer to avoid -Wrestrict warnings.
+
+  include/ntp_tty.h@1.7 +5 -0
+    Silence unused function warning.
+    Prepare for reuse of symBaud2numBaud() in Win32 code which has similar.
+
+  libntp/lib_strbuf.c@1.11 +13 -7
+    Keep a pointer to each LIB_GETBUF buffer to avoid -Wrestrict warnings.
+
+  libntp/machines.c@1.27 +57 -3
+    Prepare for reuse of symBaud2numBaud() in Win32 code which has similar.
+
+  ntpd/ntp_proto.c@1.450 +1 -1
+    Whitespace
+
+  ntpd/ntp_refclock.c@1.131 +7 -51
+    Silence unused function warning.
+    Prepare for reuse of symBaud2numBaud() in Win32 code which has similar.
+
+  sntp/tests/crypto.c@1.17 +0 -6
+    Unused locals.
+
+  tests/libntp/a_md5encrypt.c@1.18 +3 -2
+    Initialized but unused warning.
+
+ChangeSet@1.4021, 2023-07-31 09:31:00+00:00, davehart@tl.davehart.net
+  [Bug 3852] check-libntp.mf and friends are not triggering rebuilds as
+             intended.
+
+  ChangeLog@1.2070 +2 -0
+    [Bug 3852] check-libntp.mf and friends are not triggering rebuilds as
+               intended.
+
+  check-libntp.mf@1.3 +2 -5
+    Check libntp for updated sources every make invocation.
+
+  check-libntpd.mf@1.3 +2 -11
+    Check libntpd.a for updated sources every make invocation.
+
+  check-libunity.mf@1.3 +2 -2
+    Ensure libunity is built before dependents, but don't check for updated sources.
+
+  check-scm-rev.mf@1.2 +2 -4
+    Use .PHONY so things work even if someone makes a FRC.scm-rev file.
+
+  sntp/check-libntp.mf@1.6 +2 -6
+    Check libntp for updated sources every make invocation.
+
+  sntp/check-libsntp.mf@1.3 +2 -6
+    Check libsntp for updated sources every make invocation.
+
+  sntp/check-libunity.mf@1.3 +1 -2
+    Ensure libunity is built before dependents, but don't check for updated sources.
+
+ChangeSet@1.4016.2.2, 2023-07-30 22:14:18+00:00, davehart@tl.davehart.net
+  [Bug 3842] Windows ntpd ppsapi DLL load failure crashes.
+
+  ChangeLog@1.2065.2.2 +1 -0
+    [Bug 3842] Windows ntpd ppsapi DLL load failure crashes.
+
+  ports/winnt/ntpd/nt_ppsimpl.c@1.6 +1 -1
+    Avoid freeing garbage pointer during PPSAPI load failure cleanup.
+
+ChangeSet@1.4016.2.1, 2023-07-30 19:49:30+00:00, davehart@tl.davehart.net
+  [Bug 3850] ntpq -c apeers breaks column formatting s2 w/refclock refid.
+
+  ChangeLog@1.2065.2.1 +2 -0
+    [Bug 3850] ntpq -c apeers breaks column formatting s2 w/refclock refid.
+
+  ntpq/ntpq-subs.c@1.135 +22 -13
+    Limit apeers refid column to 8 characters, fix small leak.
+
+ChangeSet@1.4016.1.2, 2023-07-29 21:54:29+00:00, davehart@tl.davehart.net
+  [Bug 3851] Drop pool server when no local address can reach it.
+
+  ChangeLog@1.2065.1.2 +3 -1
+    [Bug 3851] Drop pool server when no local address can reach it.
+
+  include/ntp.h@1.236 +3 -3
+    Get rid of unused MDF_UCLNT, introduce MDF_PCLNT
+
+  include/ntpd.h@1.210 +2 -1
+    nit
+
+  ntpd/ntp_io.c@1.438 +34 -22
+    move linklocal test to is_linklocal() helper
+
+  ntpd/ntp_proto.c@1.446.1.2 +18 -4
+    [Bug 3851] Drop pool server when no local address can reach it.
+
+ChangeSet@1.4016.1.1, 2023-07-20 16:52:18+00:00, davehart@tl.davehart.net
+  [Bug 3845] accelerate pool clock_sync when IPv6 has only link-local access.
+
+  ChangeLog@1.2065.1.1 +2 -0
+    [Bug 3845] accelerate pool clock_sync when IPv6 has only link-local access.
+
+  include/ntpd.h@1.209 +3 -1
+    Track if any non-linklocal addreses are available.
+
+  ntpd/ntp_io.c@1.437 +35 -4
+    Track if any non-linklocal addreses are available for v4 and v6.
+
+  ntpd/ntp_proto.c@1.446.1.1 +17 -1
+    [Bug 3845] accelerate pool clock_sync when IPv6 has only link-local access.
+
+ChangeSet@1.4017, 2023-07-18 19:17:19+00:00, davehart@tl.davehart.net
+  [Bug 3849] ntpd --wait-sync times out.
+
+  ChangeLog@1.2066 +3 -2
+    [Bug 3849] ntpd --wait-sync times out.
+
+  libntp/msyslog.c@1.58 +3 -3
+    Reduce code duplication
+
+  ntpd/ntp_loopfilter.c@1.198 +16 -0
+    Signal first sync from rstclock()
+
+  ntpd/ntp_proto.c@1.447 +2 -16
+    Signal first sync from rstclock().
+    Remove redundant fabs() call.
+
+  ntpd/ntpd.c@1.190 +12 -15
+    [Bug 3849] ntpd --wait-sync times out.
+    Remove some useless DPRINTF() calls as -d/-D disables forking and
+      these calls are in the forking codepath.
+
+  ntpsnmpd/Makefile.am@1.45 +3 -3
+    Rearrange library order to put $(SNMP_LIBS) last, avoiding problems
+      when they reference older OpenSSL libraries.
+    Use ntpsnmpd_LDADD rather than LDADD to leave the latter to the
+      choices of the end-user.
+
+ChangeSet@1.4016, 2023-07-15 00:45:44-07:00, harlan@ntp-testbuild.tal1.ntfo.org
+  configure libevent check intersperses output with answer.
+
+  ChangeLog@1.2065 +1 -0
+    configure libevent check intersperses output with answer.
+
+  sntp/m4/ntp_libevent.m4@1.22 +2 -1
+    configure libevent check intersperses output with answer.
+
+ChangeSet@1.4014, 2023-07-14 22:43:54-07:00, harlan@ntp-testbuild.tal1.ntfo.org
+  clean up ChangeLog listing order
+
+  ChangeLog@1.2063 +12 -11
+    clean up ChangeLog listing order
+
+ChangeSet@1.4013, 2023-07-14 22:23:53-07:00, harlan@ntp-testbuild.tal1.ntfo.org
+  html/clockopt.html cleanup
+
+  ChangeLog@1.2062 +1 -0
+    html/clockopt.html cleanup
+
+  html/clockopt.html@1.30 +6 -3
+    html/clockopt.html cleanup
+
+ChangeSet@1.4004.6.1, 2023-07-14 21:33:19+00:00, davehart@tl.davehart.net
+  [Bug 3846] Use -Wno-format-truncation by default.
+
+  ChangeLog@1.2053.6.1 +3 -0
+    [Bug 3846] Use -Wno-format-truncation by default.
+
+  sntp/m4/ntp_compiler.m4@1.8.1.1 +38 -22
+    [Bug 3846] Use -Wno-format-truncation by default.
+
+ChangeSet@1.4004.1.2, 2023-06-28 00:04:04+00:00, davehart@tl.davehart.net
+  fix release build
+
+  libntp/authreadkeys.c@1.38 +1 -1
+    fix non-DEBUG build
+
+ChangeSet@1.4004.5.1, 2023-06-25 23:18:48+00:00, davehart@tl.davehart.net
+  Remove -Wformat-security when removing -Wformat to avoid gcc 12 error.
+
+  ChangeLog@1.2053.5.1 +5 -0
+    [Bug 3841] 4.2.8p17 build break w/ gcc 12 -Wformat-security without -Wformat
+
+  configure.ac@1.630 +1 -1
+    bump cache version for ntp_compiler.m4 change
+
+  sntp/configure.ac@1.90 +1 -1
+    bump cache version for ntp_compiler.m4 change
+
+  sntp/m4/ntp_compiler.m4@1.9 +3 -8
+    Remove -Wformat-security when removing -Wformat to avoid gcc 12 error.
+
+ChangeSet@1.4004.4.1, 2023-06-20 18:41:45+00:00, davehart@tl.davehart.net
+  [Bug 3837] NULL pointer deref crash when ntpd deletes last interface.
+             Correct UNLINK_EXPR_SLIST() when the list is empty.
+
+  ChangeLog@1.2053.4.1 +5 -0
+    [Bug 3837] NULL pointer deref crash when ntpd deletes last interface.
+
+  include/ntp_lists.h@1.17 +3 -1
+    Correct UNLINK_EXPR_SLIST() when the list is empty. 
+
+ChangeSet@1.4004.3.1, 2023-06-16 05:13:03+00:00, davehart@tl.davehart.net
+  Bug 3835 - NTP_HARD_*FLAGS not used by libevent tearoff.
+  
+  cvo.sh:
+    Fix on newer Linux with /etc/os-release
+  ntp_libevent.m4:
+    Newer libevent supports LIBEVENT_*FLAGS.
+    Disable building samples for the bundled libevent.
+  configure.ac:
+    One piece missing in LIBEVENT_*FLAGS support
+
+  ChangeLog@1.2053.3.1 +3 -0
+    Bug 3835 - NTP_HARD_*FLAGS not used by libevent tearoff.
+
+  sntp/libevent/configure.ac@1.20 +5 -0
+    One piece missing in LIBEVENT_*FLAGS support
+
+  sntp/m4/ntp_libevent.m4@1.21 +4 -3
+    Newer libevent supports LIBEVENT_*FLAGS.
+    Disable building samples for the bundled libevent.
+
+  sntp/scripts/cvo.sh@1.9 +7 -1
+    Fix on newer Linux with /etc/os-release
+
+ChangeSet@1.4004.2.1, 2023-06-11 14:09:22+00:00, davehart@tl.davehart.net
+  [Bug 3831] pollskewlist zeroed on runtime configuration.
+
+  ChangeLog@1.2053.2.1 +3 -0
+    [Bug 3831] pollskewlist zeroed on runtime configuration.
+
+  ntpd/ntp_config.c@1.384 +22 -29
+    [Bug 3831] pollskewlist zeroed on runtime configuration.
+    Replace magic numbers 3 & 17 with NTP_MINPOLL and NTP_MAXPOLL.
+
+ChangeSet@1.4004.1.1, 2023-06-09 19:11:34+00:00, davehart@tl.davehart.net
+  Add DSA, DSA-SHA, and SHA to tests/libntp/digests.c regression test.
+
+  ChangeLog@1.2053.1.1 +3 -0
+    Add DSA, DSA-SHA, and SHA to tests/libntp/digests.c
+
+  libntp/authkeys.c@1.47 +1 -0
+    Whitespace
+
+  libntp/authreadkeys.c@1.37 +7 -5
+    Provide the keytype when unable to use one loading ntp.keys
+    #ifdef DEBUG a "never happen" bit of code checking an internal errno.
+
+  libntp/ssl_init.c@1.31 +1 -6
+    Use MAX_MDG_LEN, remove leftover debugging code.
+
+  ntpq/ntpq.c@1.198 +8 -13
+    Remove unneeded code.  keytype_from_text upcases its input.
+
+  tests/libntp/data/ntp.keys@1.3 +12 -11
+    Add DSA, DSA-SHA, and SHA keys.
+
+  tests/libntp/digests.c@1.2 +120 -3
+    Add DSA, DSA-SHA, and SHA digest algorithms.
+
+  tests/libntp/run-digests.c@1.3 +6 -0
+    Add DSA, DSA-SHA, and SHA digest algorithms.
+
+ChangeSet@1.4007, 2023-06-07 18:36:14+02:00, burnicki@burnicki.chi1.ntfo.org
+  [Bug 3828] BK should ignore a git repo in the same directory.
+
+  BitKeeper/etc/ignore@1.97 +1 -0
+    [Bug 3828] BK should ignore a git repo in the same directory.
+
+  ChangeLog@1.2056 +2 -0
+    [Bug 3828] BK should ignore a git repo in the same directory.
+
+ChangeSet@1.4006, 2023-06-07 18:25:37+02:00, burnicki@burnicki.chi1.ntfo.org
+  [Bug 3827] Fix build in case CLOCK_HOPF6021 or CLOCK_WHARTON_400A is disabled.
+
+  ChangeLog@1.2055 +2 -0
+    [Bug 3827] Fix build in case CLOCK_HOPF6021 or CLOCK_WHARTON_400A is disabled.
+
+  libparse/clk_hopf6021.c@1.15 +2 -0
+    [Bug 3827] Fix build in case CLOCK_HOPF6021 is disabled.
+
+  libparse/clk_wharton.c@1.14 +2 -0
+    [Bug 3827] Fix build in case CLOCK_WHARTON_400A is disabled.
+
+ChangeSet@1.4005, 2023-06-07 18:21:52+02:00, burnicki@burnicki.chi1.ntfo.org
+  [Bug 3825] Don't touch HTML files unless building inside a BK repo.
+
+  ChangeLog@1.2054 +3 -0
+    [Bug 3825] Don't touch HTML files unless building inside a BK repo.
+
+  scripts/build/checkHtmlFileDates@1.2 +3 -1
+    [Bug 3825] Don't touch HTML files unless building inside a BK repo.
+
 ChangeSet@1.4004, 2023-06-06 04:40:27-07:00, ntpreleng@ntp-build.tal1.ntfo.org
   NTP_4_2_8P17
   TAG: NTP_4_2_8P17
diff --git a/contrib/ntp/Makefile.am b/contrib/ntp/Makefile.am
index 72c35cb0e45d..2d5e6183261f 100644
--- a/contrib/ntp/Makefile.am
+++ b/contrib/ntp/Makefile.am
@@ -66,7 +66,7 @@ DISTCLEANFILES = .gcc-warning
 BUILT_SOURCES =				\
 	.gcc-warning			\
 	libtool				\
-	html/.datecheck			\
+	$(srcdir)/html/.datecheck	\
 	$(srcdir)/COPYRIGHT		\
 	$(srcdir)/.checkChangeLog	\
 	$(NULL)
@@ -83,7 +83,7 @@ BUILT_SOURCES =				\
 	@sleep 1
 	@touch $@
 
-html/.datecheck: FRC.html
+$(srcdir)/html/.datecheck: $(srcdir)/html/*.html
 	cd $(srcdir)/html && \
 	../scripts/build/checkHtmlFileDates
 
@@ -128,7 +128,7 @@ uninstall-local:
 CommitLog: FRC.CommitLog
 	cd $(srcdir)					\
 	&& $(PATH_TEST) -e CommitLog			\
-		-a SCCS/s.ChangeSet -ot CommitLog	\
+		-a .bk/SCCS/ChangeSet,s -ot CommitLog	\
 	|| scripts/build/genCommitLog
 
 # HMS: The following seems to be a work-in-progress...
diff --git a/contrib/ntp/Makefile.in b/contrib/ntp/Makefile.in
index 4307d8bebee9..fe562884111e 100644
--- a/contrib/ntp/Makefile.in
+++ b/contrib/ntp/Makefile.in
@@ -420,6 +420,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_NET_SNMP_CONFIG = @PATH_NET_SNMP_CONFIG@
+PATH_OPENSSL = @PATH_OPENSSL@
 PATH_PERL = @PATH_PERL@
 PATH_RUBY = @PATH_RUBY@
 PATH_SEPARATOR = @PATH_SEPARATOR@
@@ -583,7 +584,7 @@ DISTCLEANFILES = .gcc-warning
 BUILT_SOURCES = \
 	.gcc-warning			\
 	libtool				\
-	html/.datecheck			\
+	$(srcdir)/html/.datecheck	\
 	$(srcdir)/COPYRIGHT		\
 	$(srcdir)/.checkChangeLog	\
 	$(NULL)
@@ -1105,7 +1106,7 @@ uninstall-am: uninstall-local
 	@sleep 1
 	@touch $@
 
-html/.datecheck: FRC.html
+$(srcdir)/html/.datecheck: $(srcdir)/html/*.html
 	cd $(srcdir)/html && \
 	../scripts/build/checkHtmlFileDates
 
@@ -1150,7 +1151,7 @@ uninstall-local:
 CommitLog: FRC.CommitLog
 	cd $(srcdir)					\
 	&& $(PATH_TEST) -e CommitLog			\
-		-a SCCS/s.ChangeSet -ot CommitLog	\
+		-a .bk/SCCS/ChangeSet,s -ot CommitLog	\
 	|| scripts/build/genCommitLog
 
 .buildcvo:
diff --git a/contrib/ntp/NEWS b/contrib/ntp/NEWS
index 432c3d324575..da174c84e0d7 100644
--- a/contrib/ntp/NEWS
+++ b/contrib/ntp/NEWS
@@ -1,4 +1,3906 @@
 ---
+NTP 4.2.8p18 (Harlan Stenn <stenn@ntp.org>, 2024 May 24)
+
+Focus: Bug fixes
+
+Severity: Recommended
+
+This release:
+
+- changes crypto (OpenSSL or compatible) detection and default build behavior.
+  Previously, crypto was supported if available unless the --without-crypto
+  option was given to configure.  With this release, the prior behavior of
+  falling back to a crypto-free build if usable libcrypto was not found has
+  changed to instead cause configure to fail with an error.
+  The --without-crypto option must be explicitly provided if you want a build
+  that does not use libcrypto functionality.
+- Fixes 40 bugs
+- Includes 40 other improvements
+
+Details below:
+
+* [Bug 3918] Tweak openssl header/library handling. <stenn@ntp.org>
+* [Bug 3914] Spurious "Unexpected origin timestamp" logged after time
+             stepped. <hart@ntp.org>
+* [Bug 3913] Avoid duplicate IPv6 link-local manycast associations.
+             <hart@ntp.org>
+* [Bug 3912] Avoid rare math errors in ntptrace.  <brian.utterback@oracle.com>
+* [Bug 3910] Memory leak using openssl-3 <hart@ntp.org>
+* [Bug 3909] Do not select multicast local address for unicast peer.
+             <hart@ntp.org>
+* [Bug 3903] lib/isc/win32/strerror.c NTstrerror() is not thread-safe.
+             <hart@ntp.org>
+* [Bug 3901] LIB_GETBUF isn't thread-safe. <hart@ntp.org>
+* [Bug 3900] fast_xmit() selects wrong local addr responding to mcast on
+             Windows. <hart@ntp.org>
+* [Bug 3888] ntpd with multiple same-subnet IPs using manycastclient creates
+             duplicate associations. <hart@ntp.org>
+* [Bug 3872] Ignore restrict mask for hostname. <hart@ntp.org>
+* [Bug 3871] 4.2.8p17 build without hopf6021 refclock enabled fails.
+             Reported by Hans Mayer.  Moved NONEMPTY_TRANSLATION_UNIT
+             declaration from ntp_types.h to config.h.  <hart@ntp.org>
+* [Bug 3870] Server drops client packets with ppoll < 4.  <stenn@ntp.org>
+* [Bug 3869] Remove long-gone "calldelay" & "crypto sign" from docs.
+             Reported by PoolMUC@web.de. <hart@ntp.org>
+* [Bug 3868] Cannot restrict a pool peer. <hart@ntp.org>  Thanks to
+             Edward McGuire for tracking down the deficiency.
+* [Bug 3864] ntpd IPv6 refid different for big-endian and little-endian.
+             <hart@ntp.org>
+* [Bug 3859] Use NotifyIpInterfaceChange on Windows ntpd. <hart@ntp.org>
+* [Bug 3856] Enable Edit & Continue debugging with Visual Studio.
+             <hart@ntp.org>
+* [Bug 3855] ntpq lacks an equivalent to ntpdc's delrestrict. <hart@ntp.org>
+* [Bug 3854] ntpd 4.2.8p17 corrupts rawstats file with space in refid.
+             <hart@ntp.org>
+* [Bug 3853] Clean up warnings with modern compilers. <hart@ntp.org>
+* [Bug 3852] check-libntp.mf and friends are not triggering rebuilds as
+             intended. <hart@ntp.org>
+* [Bug 3851] Drop pool server when no local address can reach it.
+             <hart@ntp.org>
+* [Bug 3850] ntpq -c apeers breaks column formatting s2 w/refclock refid.
+             <hart@ntp.org>
+* [Bug 3849] ntpd --wait-sync times out. <hart@ntp.org>
+* [Bug 3847] SSL detection in configure should run-test if runpath is needed.
+             <hart@ntp.org>
+* [Bug 3846] Use -Wno-format-truncation by default. <hart@ntp.org>
+* [Bug 3845] accelerate pool clock_sync when IPv6 has only link-local access.
+             <hart@ntp.org>
+* [Bug 3842] Windows ntpd PPSAPI DLL load failure crashes. <hart@ntp.org>
+* [Bug 3841] 4.2.8p17 build break w/ gcc 12 -Wformat-security without -Wformat
+             Need to remove --Wformat-security when removing -Wformat to
+             silence numerous libopts warnings.  <hart@ntp.org>
+* [Bug 3837] NULL pointer deref crash when ntpd deletes last interface.
+             Reported by renmingshuai.  Correct UNLINK_EXPR_SLIST() when the
+             list is empty. <hart@ntp.org>
+* [Bug 3835] NTP_HARD_*FLAGS not used by libevent tearoff. <hart@ntp.org>
+* [Bug 3831] pollskewlist zeroed on runtime configuration. <hart@ntp.org>
+* [Bug 3830] configure libevent check intersperses output with answer. <stenn@>
+* [Bug 3828] BK should ignore a git repo in the same directory.
+             <burnicki@ntp.org>
+* [Bug 3827] Fix build in case CLOCK_HOPF6021 or CLOCK_WHARTON_400A
+             is disabled.  <burnicki@ntp.org>
+* [Bug 3825] Don't touch HTML files unless building inside a BK repo.
+             Fix the script checkHtmlFileDates.  <burnicki@ntp.org>
+* [Bug 3756] Improve OpenSSL library/header detection.
+* [Bug 3753] ntpd fails to start with FIPS-enabled OpenSSL 3. <hart@ntp.org>
+* [Bug 2734] TEST3 prevents initial interleave sync.  Fix from <PoolMUC@web.de>
+* Log failures to allocate receive buffers.  <hart@ntp.org>
+* Remove extraneous */ from libparse/ieee754io.c
+* Fix .datecheck target line in Makefile.am.  <stenn@ntp.org>
+* Update the copyright year.  <stenn@ntp.org>
+* Update ntp.conf documentation to add "delrestrict" and correct information
+  about KoD rate limiting.  <hart@ntp.org>
+* html/clockopt.html cleanup.  <stenn@ntp.org>
+* util/lsf-times - added.  <stenn@ntp.org>
+* Add DSA, DSA-SHA, and SHA to tests/libntp/digests.c. <hart@ntp.org>
+* Provide ntpd thread names to debugger on Windows. <hart@ntp.org>
+* Remove dead code libntp/numtohost.c and its unit tests. <hart@ntp.org>
+* Remove class A, B, C IPv4 distinctions in netof(). <hart@ntp.org>
+* Use @configure_input@ in various *.in files to include a comment that
+  the file is generated from another pointing to the *.in. <hart@ntp.org>
+* Correct underquoting, indents in ntp_facilitynames.m4. <hart@ntp.org>
+* Clean up a few warnings seen building with older gcc. <hart@ntp.org>
+* Fix build on older FreeBSD lacking sys/procctl.h. <hart@ntp.org>
+* Disable [Bug 3627] workaround on newer FreeBSD which has the kernel fix
+  that makes it unnecessary, re-enabling ASLR stack gap. <hart@ntp.org>
+* Use NONEMPTY_COMPILATION_UNIT in more conditionally-compiled files.
+* Remove useless pointer to Windows Help from system error messages.
+* Avoid newlines within Windows error messages. <hart@ntp.org>
+* Ensure unique association IDs if wrapped. <hart@ntp.org>
+* Simplify calc_addr_distance(). <hart@ntp.org>
+* Clamp min/maxpoll in edge cases in newpeer(). <hart@ntp.org>
+* Quiet local addr change logging when unpeering. <hart@ntp.org>
+* Correct missing arg for %s printf specifier in 
+  send_blocking_resp_internal(). <hart@ntp.org>
+* Suppress OpenSSL 3 deprecation warning clutter. <hart@ntp.org>
+* Correct OpenSSL usage in Autokey code to avoid warnings about
+  discarding const qualifiers with OpenSSL 3. <hart@ntp.org>
+* Display KoD refid as text in recently added message. <hart@ntp.org>
+* Avoid running checkHtmlFileDates script repeatedly when no html/*.html
+    files have changed. <hart@ntp.org>
+* Abort configure if --enable-crypto-rand given & unavailable. <hart@ntp.org>
+* Add configure --enable-verbose-ssl to trace SSL detection. <hart@ntp.org>
+* Add build test coverage for --disable-saveconfig to flock-build script.
+  <hart@ntp.org>
+* Remove deprecated configure --with-arlib option. <hart@ntp.org>
+* Remove configure support for ISC UNIX ca. 1998. <hart@ntp.org>
+* Move NTP_OPENSSL and NTP_CRYPTO_RAND invocations from configure.ac files
+  to NTP_LIBNTP. <hart@ntp.org>
+* Remove dead code: HAVE_U_INT32_ONLY_WITH_DNS. <hart@ntp.org>
+* Eliminate [v]snprintf redefinition warnings on macOS. <hart@ntp.org>
+* Fix clang 14 cast increases alignment warning on Linux. <hart@ntp.org>
+* Move ENABLE_CMAC to ntp_openssl.m4, reviving sntp/tests CMAC unit tests.
+  <hart@ntp.org>
+* Use NTP_HARD_CPPFLAGS in libopts tearoff. <hart@ntp.org>
+* wire in --enable-build-framework-help
+
+---
+NTP 4.2.8p17 (Harlan Stenn <stenn@ntp.org>, 2023 Jun 06)
+
+Focus: Bug fixes
+
+Severity: HIGH (for people running 4.2.8p16)
+
+This release:
+
+- fixes 3 bugs, including a regression
+- adds new unit tests
+
+Details below:
+
+* [Bug 3824] Spurious "ntpd: daemon failed to notify parent!" logged at
+             event_sync.  Reported by Edward McGuire.  <hart@ntp.org>
+* [Bug 3822] ntpd significantly delays first poll of servers specified by name.
+             <hart@ntp.org>  Miroslav Lichvar identified regression in 4.2.8p16.
+* [Bug 3821] 4.2.8p16 misreads hex authentication keys, won't interop with
+             4.2.8p15 or earlier.  Reported by Matt Nordhoff, thanks to
+	     Miroslav Lichvar and Matt for rapid testing and identifying the
+	     problem. <hart@ntp.org>
+* Add tests/libntp/digests.c to catch regressions reading keys file or with
+  symmetric authentication digest output.
+
+---
+NTP 4.2.8p16 (Harlan Stenn <stenn@ntp.org>, 2023 May 30)
+
+Focus: Security, Bug fixes
+
+Severity: LOW
+
+This release:
+
+- fixes 4 vulnerabilities (3 LOW and 1 None severity), 
+- fixes 46 bugs
+- includes 15 general improvements
+- adds support for OpenSSL-3.0
+
+Details below:
+
+* [Sec 3808] Assertion failure in ntpq on malformed RT-11 date <perlinger@ntp.org>
+* [Sec 3807] praecis_parse() in the Palisade refclock driver has a
+             hypothetical input buffer overflow. Reported by ... stenn@
+* [Sec 3806] libntp/mstolfp.c needs bounds checking <perlinger@ntp.org>
+  - solved numerically instead of using string manipulation
+* [Sec 3767] An OOB KoD RATE value triggers an assertion when debug is enabled.
+             <stenn@ntp.org>
+* [Bug 3819] Updated libopts/Makefile.am was missing NTP_HARD_* values. <stenn@>
+* [Bug 3817] Bounds-check "tos floor" configuration. <hart@ntp.org>
+* [Bug 3814] First poll delay of new or cleared associations miscalculated.
+             <hart@ntp.org>
+* [Bug 3802] ntp-keygen -I default identity modulus bits too small for
+             OpenSSL 3.  Reported by rmsh1216@163.com <hart@ntp.org>
+* [Bug 3801] gpsdjson refclock gps_open() device name mishandled. <hart@ntp.org>
+* [Bug 3800] libopts-42.1.17 does not compile with Microsoft C. <hart@ntp.org>
+* [Bug 3799] Enable libopts noreturn compiler advice for MSC. <hart@ntp.org>
+* [Bug 3797] Windows getaddrinfo w/AI_ADDRCONFIG fails for localhost when 
+             disconnected, breaking ntpq and ntpdc. <hart@ntp.org>
+* [Bug 3795] pollskewlist documentation uses | when it shouldn't.
+  - ntp.conf manual page and miscopt.html corrections. <hart@ntp.org>
+* [Bug 3793] Wrong variable type passed to record_raw_stats(). <hart@ntp.org>
+  - Report and patch by Yuezhen LUAN <wei6410@sina.com>.
+* [Bug 3786] Timer starvation on high-load Windows ntpd. <hart@ntp.org>
+* [Bug 3784] high-load ntpd on Windows deaf after enough ICMP TTL exceeded.
+             <hart@ntp.org>
+* [Bug 3781] log "Unable to listen for broadcasts" for IPv4 <hart@ntp.org>
+* [Bug 3774] mode 6 packets corrupted in rawstats file <hart@ntp.org>
+  - Reported by Edward McGuire, fix identified by <wei6410@sina.com>.
+* [Bug 3758] Provide a 'device' config statement for refclocks <perlinger@ntp.org> 
+* [Bug 3757] Improve handling of Linux-PPS in NTPD <perlinger@ntp.org>
+* [Bug 3741] 4.2.8p15 can't build with glibc 2.34 <perlinger@ntp.org>
+* [Bug 3725] Make copyright of clk_wharton.c compatible with Debian.
+             Philippe De Muyter <phdm@macqel.be>
+* [Bug 3724] ntp-keygen with openSSL 1.1.1 fails on Windows <perlinger@ntp.org>
+  - openssl applink needed again for openSSL-1.1.1
+* [Bug 3719] configure.ac checks for closefrom() and getdtablesize() missing.
+             Reported by Brian Utterback, broken in 2010 by <hart@ntp.org>
+* [Bug 3699] Problems handling drift file and restoring previous drifts <perlinger@ntp.org>
+  - command line options override config statements where applicable
+  - make initial frequency settings idempotent and reversible
+  - make sure kernel PLL gets a recovered drift componsation
+* [Bug 3695] Fix memory leak with ntpq on Windows Server 2019 <perlinger@ntp.org>
+* [Bug 3694] NMEA refclock seems to unnecessarily require location in messages
+  - misleading title; essentially a request to ignore the receiver status.
+    Added a mode bit for this. <perlinger@ntp.org>
+* [Bug 3693] Improvement of error handling key lengths <perlinger@ntp.org>
+  - original patch by Richard Schmidt, with mods & unit test fixes
+* [Bug 3692] /dev/gpsN requirement prevents KPPS <perlinger@ntp.org>
+  - implement/wrap 'realpath()' to resolve symlinks in device names
+* [Bug 3691] Buffer Overflow reading GPSD output
+  - original patch by matt<ntpbr@mattcorallo.com>
+  - increased max PDU size to 4k to avoid truncation
+* [Bug 3690] newline in ntp clock variable (parse) <perlinger@ntp.org>
+  - patch by Frank Kardel
+* [Bug 3689] Extension for MD5, SHA-1 and other keys <perlinger@ntp.org>
+  - ntp{q,dc} now use the same password processing as ntpd does in the key
+    file, so having a binary secret >= 11 bytes is possible for all keys.
+    (This is a different approach to the problem than suggested)
+* [Bug 3688] GCC 10 build errors in testsuite <perlinger@ntp.org>
+* [Bug 3687] ntp_crypto_rand RNG status not known <perlinger@ntp.org>
+  - patch by Gerry Garvey
+* [Bug 3682] Fixes for warnings when compiled without OpenSSL <perlinger@ntp.org>
+  - original patch by Gerry Garvey
+* [Bug 3677] additional peer events not decoded in associations listing <perlinger@ntp.org>
+  - original patch by Gerry Garvey
+* [Bug 3676] compiler warnings (CMAC, interrupt_buf, typo, fallthrough)
+  - applied patches by Gerry Garvey
+* [Bug 3675] ntpq ccmds[] stores pointer to non-persistent storage
+* [Bug 3674] ntpq command 'execute only' using '~' prefix <perlinger@ntp.org>
+  - idea+patch by Gerry Garvey
+* [Bug 3672] fix biased selection in median cut <perlinger@ntp.org>
+* [Bug 3666] avoid unlimited receive buffer allocation <perlinger@ntp.org>
+  - follow-up: fix inverted sense in check, reset shortfall counter
+* [Bug 3660] Revert 4.2.8p15 change to manycast. <hart@ntp.org>
+* [Bug 3640] document "discard monitor" and fix the code. <hart@ntp.org>
+  - fixed bug identified by Edward McGuire <perlinger@ntp.org>
+* [Bug 3626] (SNTP) UTC offset calculation needs dst flag <perlinger@ntp.org>
+  - applied patch by Gerry Garvey
+* [Bug 3432] refclocks that 'write()' should check the result <perlinger@ntp.org>
+  - backport from -dev, plus some more work on warnings for unchecked results
+* [Bug 3428] ntpd spinning consuming CPU on Linux router with full table.
+             Reported by Israel G. Lugo. <hart@ntp.org>
+* [Bug 3103] libopts zsave_warn format string too few arguments <bkorb@gnu.org>
+* [Bug 2990] multicastclient incorrectly causes bind to broadcast address.
+             Integrated patch from Brian Utterback. <hart@ntp.org>
+* [Bug 2525] Turn on automake subdir-objects across the project. <hart@ntp.org>
+* [Bug 2410] syslog an error message on panic exceeded. <brian.utterback@oracle.com>
+* Use correct rounding in mstolfp(). perlinger/hart
+* M_ADDF should use u_int32.  <hart@ntp.org>
+* Only define tv_fmt_libbuf() if we will use it. <stenn@ntp.org>
+* Use recv_buffer instead of the longer recv_space.X_recv_buffer. hart/stenn
+* Make sure the value returned by refid_str() prints cleanly. <stenn@ntp.org>
+* If DEBUG is enabled, the startup banner now says that debug assertions
+  are in force and that ntpd will abort if any are violated. <stenn@ntp.org>
+* syslog valid incoming KoDs.  <stenn@ntp.org>
+* Rename a poorly-named variable.  <stenn@ntp.org>
+* Disable "embedded NUL in string" messages in libopts, when we can. <stenn@>
+* Use https in the AC_INIT URLs in configure.ac.  <stenn@ntp.org>
+* Implement NTP_FUNC_REALPATH.  <stenn@ntp.org>
+* Lose a gmake construct in ntpd/Makefile.am.  <stenn@ntp.org>
+* upgrade to: autogen-5.18.16
+* upgrade to: libopts-42.1.17
+* upgrade to: autoconf-2.71
+* upgrade to: automake-1.16.15
+* Upgrade to libevent-2.1.12-stable <stenn@ntp.org>
+* Support OpenSSL-3.0
+
+---
+NTP 4.2.8p15 (Harlan Stenn <stenn@ntp.org>, 2020 Jun 23)
+
+Focus: Security, Bug fixes
+
+Severity: MEDIUM
+
+This release fixes one vulnerability: Associations that use CMAC
+authentication between ntpd from versions 4.2.8p11/4.3.97 and
+4.2.8p14/4.3.100 will leak a small amount of memory for each packet.
+Eventually, ntpd will run out of memory and abort.
+
+It also fixes 13 other bugs.
+
+* [Sec 3661] memory leak with AES128CMAC keys <perlinger@ntp.org>
+* [Bug 3670] Regression from bad merger between 3592 and 3596 <perlinger@>
+  - Thanks to Sylar Tao
+* [Bug 3667] decodenetnum fails with numeric port <perlinger@ntp.org>
+  - rewrite 'decodenetnum()' in terms of inet_pton
+* [Bug 3666] avoid unlimited receive buffer allocation <perlinger@ntp.org>
+  - limit number of receive buffers, with an iron reserve for refclocks
+* [Bug 3664] Enable openSSL CMAC support on Windows <burnicki@ntp.org>
+* [Bug 3662] Fix build errors on Windows with VS2008 <burnicki@ntp.org>
+* [Bug 3660] Manycast orphan mode startup discovery problem. <stenn@ntp.org>
+  - integrated patch from Charles Claggett
+* [Bug 3659] Move definition of psl[] from ntp_config.h to
+  ntp_config.h <perlinger@ntp.org>
+* [Bug 3657] Wrong "Autokey group mismatch" debug message <perlinger@ntp.org>
+* [Bug 3655] ntpdc memstats hash counts <perlinger@ntp.org>
+  - fix by Gerry garvey
+* [Bug 3653] Refclock jitter RMS calculation <perlinger@ntp.org>
+  - thanks to Gerry Garvey
+* [Bug 3646] Avoid sync with unsync orphan <perlinger@ntp.org>
+  - patch by Gerry Garvey
+* [Bug 3644] Unsynchronized server [...] selected as candidate <perlinger@ntp.org>
+* [Bug 3639] refclock_jjy: TS-JJY0x can skip time sync depending on the STUS reply. <abe@ntp.org>
+  - applied patch by Takao Abe
+
+---
+NTP 4.2.8p14 (Harlan Stenn <stenn@ntp.org>, 2020 Mar 03)
+
+Focus: Security, Bug fixes, enhancements.
+
+Severity: MEDIUM
+
+This release fixes three vulnerabilities: a bug that causes causes an ntpd
+instance that is explicitly configured to override the default and allow
+ntpdc (mode 7) connections to be made to a server to read some uninitialized
+memory; fixes the case where an unmonitored ntpd using an unauthenticated
+association to its servers may be susceptible to a forged packet DoS attack;
+and fixes an attack against a client instance that uses a single
+unauthenticated time source.  It also fixes 46 other bugs and addresses
+4 other issues.
+
+* [Sec 3610] process_control() should bail earlier on short packets. stenn@
+  - Reported by Philippe Antoine
+* [Sec 3596] Highly predictable timestamp attack. <stenn@ntp.org>
+  - Reported by Miroslav Lichvar
+* [Sec 3592] DoS attack on client ntpd <perlinger@ntp.org>
+  - Reported by Miroslav Lichvar
+* [Bug 3637] Emit the version of ntpd in saveconfig.  stenn@
+* [Bug 3636] NMEA: combine time/date from multiple sentences <perlinger@ntp.org>
+* [Bug 3635] Make leapsecond file hash check optional <perlinger@ntp.org>
+* [Bug 3634] Typo in discipline.html, reported by Jason Harrison.  stenn@
+* [Bug 3628] raw DCF decoding - improve robustness with Zeller's congruence
+  - implement Zeller's congruence in libparse and libntp <perlinger@ntp.org>
+* [Bug 3627] SIGSEGV on FreeBSD-12 with stack limit and stack gap <perlinger@ntp.org>
+  - integrated patch by Cy Schubert
+* [Bug 3620] memory leak in ntpq sysinfo <perlinger@ntp.org>
+  - applied patch by Gerry Garvey
+* [Bug 3619] Honour drefid setting in cooked mode and sysinfo <perlinger@ntp.org>
+  - applied patch by Gerry Garvey
+* [Bug 3617] Add support for ACE III and Copernicus II receivers <perlinger@ntp.org>
+  - integrated patch by Richard Steedman
+* [Bug 3615] accelerate refclock startup <perlinger@ntp.org>
+* [Bug 3613] Propagate noselect to mobilized pool servers <stenn@ntp.org>
+  - Reported by Martin Burnicki
+* [Bug 3612] Use-of-uninitialized-value in receive function <perlinger@ntp.org>
+  - Reported by Philippe Antoine
+* [Bug 3611] NMEA time interpreted incorrectly <perlinger@ntp.org>
+  - officially document new "trust date" mode bit for NMEA driver
+  - restore the (previously undocumented) "trust date" feature lost with [bug 3577] 
+* [Bug 3609] Fixing wrong falseticker in case of non-statistic jitter <perlinger@ntp.org>
+  - mostly based on a patch by Michael Haardt, implementing 'fudge minjitter'
+* [Bug 3608] libparse fails to compile on S11.4SRU13 and later <perlinger@ntp.org>
+  - removed ffs() and fls() prototypes as per Brian Utterback
+* [Bug 3604] Wrong param byte order passing into record_raw_stats() in
+	ntp_io.c <perlinger@ntp.org>
+  - fixed byte and paramter order as suggested by wei6410@sina.com 
+* [Bug 3601] Tests fail to link on platforms with ntp_cv_gc_sections_runs=no <perlinger@ntp.org>
+* [Bug 3599] Build fails on linux-m68k due to alignment issues <perlinger@ntp.org>
+  - added padding as suggested by John Paul Adrian Glaubitz 
+* [Bug 3594] ntpd discards messages coming through nmead <perlinger@ntp.org>
+* [Bug 3593] ntpd discards silently nmea messages after the 5th string <perlinger@ntp.org>
+* [Bug 3590] Update refclock_oncore.c to the new GPS date API <perlinger@ntp.org>
+* [Bug 3585] Unity tests mix buffered and unbuffered output <perlinger@ntp.org>
+  - stdout+stderr are set to line buffered during test setup now
+* [Bug 3583] synchronization error <perlinger@ntp.org>
+  - set clock to base date if system time is before that limit
+* [Bug 3582] gpsdjson refclock fudgetime1 adjustment is doubled <perlinger@ntp.org>
+* [Bug 3580] Possible bug ntpq-subs (NULL dereference in dogetassoc) <perlinger@ntp.org>
+  - Reported by Paulo Neves
+* [Bug 3577] Update refclock_zyfer.c to the new GPS date API <perlinger@ntp.org>
+  - also updates for refclock_nmea.c and refclock_jupiter.c
+* [Bug 3576] New GPS date function API <perlinger@ntp.org>
+* [Bug 3573] nptdate: missleading error message <perlinger@ntp.org>
+* [Bug 3570] NMEA driver docs: talker ID not mentioned, typo <perlinger@ntp.org>
+* [Bug 3569] cleanup MOD_NANO/STA_NANO handling for 'ntpadjtimex()' <perlinger@ntp.org>
+  - sidekick: service port resolution in 'ntpdate'
+* [Bug 3550] Reproducible build: Respect SOURCE_DATE_EPOCH <perlinger@ntp.org>
+  - applied patch by Douglas Royds
+* [Bug 3542] ntpdc monlist parameters cannot be set <perlinger@ntp.org>
+* [Bug 3533] ntpdc peer_info ipv6 issues <perlinger@ntp.org>
+  - applied patch by Gerry Garvey
+* [Bug 3531] make check: test-decodenetnum fails <perlinger@ntp.org>
+  - try to harden 'decodenetnum()' against 'getaddrinfo()' errors
+  - fix wrong cond-compile tests in unit tests
+* [Bug 3517] Reducing build noise <perlinger@ntp.org>
+* [Bug 3516] Require tooling from this decade <perlinger@ntp.org>
+  - patch by Philipp Prindeville
+* [Bug 3515] Refactor ntpdmain() dispatcher loop and group common code <perlinger@ntp.org>
+  - patch by Philipp Prindeville
+* [Bug 3511] Get rid of AC_LANG_SOURCE() warnings <perlinger@ntp.org>
+  - patch by Philipp Prindeville
+* [Bug 3510] Flatten out the #ifdef nesting in ntpdmain() <perlinger@ntp.org>
+  - partial application of patch by Philipp Prindeville
+* [Bug 3491] Signed values of LFP datatypes should always display a sign
+  - applied patch by Gerry Garvey & fixed unit tests <perlinger@ntp.org>
+* [Bug 3490] Patch to support Trimble Resolution Receivers <perlinger@ntp.org>
+  - applied (modified) patch by Richard Steedman
+* [Bug 3473] RefID of refclocks should always be text format <perlinger@ntp.org>
+  - applied patch by Gerry Garvey (with minor formatting changes)
+* [Bug 3132] Building 4.2.8p8 with disabled local libopts fails <perlinger@ntp.org>
+  - applied patch by Miroslav Lichvar
+* [Bug 3094] ntpd trying to listen for broadcasts on a completely ipv6 network
+  <perlinger@ntp.org>
+* [Bug 2420] ntpd doesn't run and exits with retval 0 when invalid user
+             is specified with -u <perlinger@ntp.org>
+  - monitor daemon child startup & propagate exit codes
+* [Bug 1433] runtime check whether the kernel really supports capabilities
+  - (modified) patch by Kurt Roeckx <perlinger@ntp.org>
+* Clean up sntp/networking.c:sendpkt() error message.  <stenn@ntp.org>
+* Provide more detail on unrecognized config file parser tokens. <stenn@ntp.org>
+* Startup log improvements. <stenn@ntp.org>
+* Update the copyright year.
+
+---
+NTP 4.2.8p13 (Harlan Stenn <stenn@ntp.org>, 2019 Mar 07)
+
+Focus: Security, Bug fixes, enhancements.
+
+Severity: MEDIUM
+
+This release fixes a bug that allows an attacker with access to an
+explicitly trusted source to send a crafted malicious mode 6 (ntpq)
+packet that can trigger a NULL pointer dereference, crashing ntpd.
+It also provides 17 other bugfixes and 1 other improvement:
+
+* [Sec 3565] Crafted null dereference attack in authenticated
+	     mode 6 packet <perlinger@ntp.org>
+  - reported by Magnus Stubman
+* [Bug 3560] Fix build when HAVE_DROPROOT is not defined <perlinger@ntp.org>
+  - applied patch by Ian Lepore
+* [Bug 3558] Crash and integer size bug <perlinger@ntp.org>
+  - isolate and fix linux/windows specific code issue
+* [Bug 3556] ntp_loopfilter.c snprintf compilation warnings <perlinger@ntp.org>
+  - provide better function for incremental string formatting
+* [Bug 3555] Tidy up print alignment of debug output from ntpdate <perlinger@ntp.org>
+  - applied patch by Gerry Garvey
+* [Bug 3554] config revoke stores incorrect value <perlinger@ntp.org>
+  - original finding by Gerry Garvey, additional cleanup needed
+* [Bug 3549] Spurious initgroups() error message <perlinger@ntp.org>
+  - patch by Christous Zoulas
+* [Bug 3548] Signature not verified on windows system <perlinger@ntp.org>
+  - finding by Chen Jiabin, plus another one by me
+* [Bug 3541] patch to fix STA_NANO struct timex units <perlinger@ntp.org>
+  - applied patch by Maciej Szmigiero
+* [Bug 3540] Cannot set minsane to 0 anymore <perlinger@ntp.org>
+  - applied patch by Andre Charbonneau
+* [Bug 3539] work_fork build fails when droproot is not supported <perlinger@ntp.org>
+  - applied patch by Baruch Siach
+* [Bug 3538] Build fails for no-MMU targets <perlinger@ntp.org>
+  - applied patch by Baruch Siach
+* [Bug 3535] libparse won't handle GPS week rollover <perlinger@ntp.org>
+  - refactored handling of GPS era based on 'tos basedate' for
+    parse (TSIP) and JUPITER clocks
+* [Bug 3529] Build failures on Mac OS X 10.13 (High Sierra) <perlinger@ntp.org>
+  - patch by Daniel J. Luke; this does not fix a potential linker
+    regression issue on MacOS.
+* [Bug 3527 - Backward Incompatible] mode7 clockinfo fudgeval2 packet
+  anomaly <perlinger@ntp.org>, reported by GGarvey.
+  - --enable-bug3527-fix support by HStenn
+* [Bug 3526] Incorrect poll interval in packet <perlinger@ntp.org>
+  - applied patch by Gerry Garvey
+* [Bug 3471] Check for openssl/[ch]mac.h.  <perlinger@ntp.org>
+  - added missing check, reported by Reinhard Max <perlinger@ntp.org>
+* [Bug 1674] runtime crashes and sync problems affecting both x86 and x86_64
+  - this is a variant of [bug 3558] and should be fixed with it
+* Implement 'configure --disable-signalled-io'
+
+--
+NTP 4.2.8p12 (Harlan Stenn <stenn@ntp.org>, 2018/14/09)
+
+Focus: Security, Bug fixes, enhancements.
+
+Severity: MEDIUM
+
+This release fixes a "hole" in the noepeer capability introduced to ntpd
+in ntp-4.2.8p11, and a buffer overflow in the openhost() function used by
+ntpq and ntpdc.  It also provides 26 other bugfixes, and 4 other improvements:
+
+* [Sec 3505] Buffer overflow in the openhost() call of ntpq and ntpdc.
+
+* [Sec 3012] Fix a hole in the new "noepeer" processing.
+
+* Bug Fixes:
+ [Bug 3521] Fix a logic bug in the INVALIDNAK checks.  <stenn@ntp.org>
+ [Bug 3509] Add support for running as non-root on FreeBSD, Darwin,
+            other TrustedBSD platforms
+ - applied patch by Ian Lepore <perlinger@ntp.org>
+ [Bug 3506] Service Control Manager interacts poorly with NTPD <perlinger@ntp.org>
+ - changed interaction with SCM to signal pending startup
+ [Bug 3486] Buffer overflow in ntpq/ntpq.c:tstflags() <perlinger@ntp.org>
+ - applied patch by Gerry Garvey
+ [Bug 3485] Undefined sockaddr used in error messages in ntp_config.c <perlinger@ntp.org>
+ - applied patch by Gerry Garvey
+ [Bug 3484] ntpq response from ntpd is incorrect when REFID is null <perlinger@ntp.org>
+ - rework of ntpq 'nextvar()' key/value parsing
+ [Bug 3482] Fixes for compilation warnings (ntp_io.c & ntpq-subs.c) <perlinger@ntp.org>
+ - applied patch by Gerry Garvey (with mods)
+ [Bug 3480] Refclock sample filter not cleared on clock STEP <perlinger@ntp.org>
+ - applied patch by Gerry Garvey
+ [Bug 3479] ctl_putrefid() allows unsafe characters through to ntpq <perlinger@ntp.org>
+ - applied patch by Gerry Garvey (with mods)
+ [Bug 3476]ctl_putstr() sends empty unquoted string [...] <perlinger@ntp.org>
+ - applied patch by Gerry Garvey (with mods); not sure if that's bug or feature, though
+ [Bug 3475] modify prettydate() to suppress output of zero time <perlinger@ntp.org>
+ - applied patch by Gerry Garvey
+ [Bug 3474] Missing pmode in mode7 peer info response <perlinger@ntp.org>
+ - applied patch by Gerry Garvey
+ [Bug 3471] Check for openssl/[ch]mac.h.  HStenn.
+ - add #define ENABLE_CMAC support in configure.  HStenn.
+ [Bug 3470] ntpd4.2.8p11 fails to compile without OpenSSL <perlinger@ntp.org>
+ [Bug 3469] Incomplete string compare [...] in is_refclk_addr <perlinger@ntp.org>
+ - patch by Stephen Friedl
+ [Bug 3467] Potential memory fault in ntpq [...] <perlinger@ntp.org>
+ - fixed IO redirection and CTRL-C handling in ntq and ntpdc
+ [Bug 3465] Default TTL values cannot be used <perlinger@ntp.org>
+ [Bug 3461] refclock_shm.c: clear error status on clock recovery <perlinger@ntp.org>
+ - initial patch by Hal Murray; also fixed refclock_report() trouble
+ [Bug 3460] Fix typo in ntpq.texi, reported by Kenyon Ralph.  <stenn@ntp.org>
+ [Bug 3456] Use uintptr_t rather than size_t to store an integer in a pointer
+ - According to Brooks Davis, there was only one location <perlinger@ntp.org>
+ [Bug 3449] ntpq - display "loop" instead of refid [...] <perlinger@ntp.org>
+ - applied patch by Gerry Garvey
+ [Bug 3445] Symmetric peer won't sync on startup <perlinger@ntp.org>
+ - applied patch by Gerry Garvey
+ [Bug 3442] Fixes for ntpdate as suggested by Gerry Garvey,
+ with modifications
+ New macro REFID_ISTEXT() which is also used in ntpd/ntp_control.c.
+ [Bug 3434] ntpd clears STA_UNSYNC on start <perlinger@ntp.org>
+ - applied patch by Miroslav Lichvar
+ [Bug 3426] ntpdate.html -t default is 2 seconds.  Leonid Evdokimov.
+ [Bug 3121] Drop root privileges for the forked DNS worker <perlinger@ntp.org>
+ - integrated patch by  Reinhard Max
+ [Bug 2821] minor build issues <perlinger@ntp.org>
+ - applied patches by Christos Zoulas, including real bug fixes
+ html/authopt.html: cleanup, from <stenn@ntp.org>
+ ntpd/ntpd.c: DROPROOT cleanup.  <stenn@ntp.org>
+ Symmetric key range is 1-65535.  Update docs.   <stenn@ntp.org>
+
+--
+NTP 4.2.8p11 (Harlan Stenn <stenn@ntp.org>, 2018/02/27)
+
+Focus: Security, Bug fixes, enhancements.
+
+Severity: MEDIUM
+
+This release fixes 2 low-/medium-, 1 informational/medum-, and 2 low-severity
+vulnerabilities in ntpd, one medium-severity vulernability in ntpq, and
+provides 65 other non-security fixes and improvements:
+
+* NTP Bug 3454: Unauthenticated packet can reset authenticated interleaved
+	association (LOW/MED)
+   Date Resolved: Stable (4.2.8p11) 27 Feb 2018
+   References: Sec 3454 / CVE-2018-7185 / VU#961909
+   Affects: ntp-4.2.6, up to but not including ntp-4.2.8p11.
+   CVSS2: MED 4.3 (AV:N/AC:M/Au:N/C:N/I:N/A:P) This could score between
+	2.9 and 6.8.
+   CVSS3: LOW 3.1 CVSS:3.0/AV:N/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:L This could
+	score between 2.6 and 3.1
+   Summary:
+	The NTP Protocol allows for both non-authenticated and
+	authenticated associations, in client/server, symmetric (peer),
+	and several broadcast modes. In addition to the basic NTP
+	operational modes, symmetric mode and broadcast servers can
+	support an interleaved mode of operation. In ntp-4.2.8p4 a bug
+	was inadvertently introduced into the protocol engine that
+	allows a non-authenticated zero-origin (reset) packet to reset
+	an authenticated interleaved peer association. If an attacker
+	can send a packet with a zero-origin timestamp and the source
+	IP address of the "other side" of an interleaved association,
+	the 'victim' ntpd will reset its association. The attacker must
+	continue sending these packets in order to maintain the
+	disruption of the association. In ntp-4.0.0 thru ntp-4.2.8p6,
+	interleave mode could be entered dynamically. As of ntp-4.2.8p7,
+	interleaved mode must be explicitly configured/enabled.
+   Mitigation:
+	Implement BCP-38.
+	Upgrade to 4.2.8p11, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page.
+	If you are unable to upgrade to 4.2.8p11 or later and have
+	    'peer HOST xleave' lines in your ntp.conf file, remove the
+	    'xleave' option.
+	Have enough sources of time.
+	Properly monitor your ntpd instances.
+	If ntpd stops running, auto-restart it without -g .
+   Credit:
+   	This weakness was discovered by Miroslav Lichvar of Red Hat.
+
+* NTP Bug 3453: Interleaved symmetric mode cannot recover from bad
+	state (LOW/MED)
+   Date Resolved: Stable (4.2.8p11) 27 Feb 2018
+   References: Sec 3453 / CVE-2018-7184 / VU#961909
+   Affects: ntpd in ntp-4.2.8p4, up to but not including ntp-4.2.8p11.
+   CVSS2: MED 4.3 (AV:N/AC:M/Au:N/C:P/I:N/A:N)
+	Could score between 2.9 and 6.8.
+   CVSS3: LOW 3.1 - CVSS:3.0/AV:N/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:L
+	Could score between 2.6 and 6.0.
+   Summary:
+   	The fix for NtpBug2952 was incomplete, and while it fixed one
+	problem it created another.  Specifically, it drops bad packets
+	before updating the "received" timestamp.  This means a
+	third-party can inject a packet with a zero-origin timestamp,
+	meaning the sender wants to reset the association, and the
+	transmit timestamp in this bogus packet will be saved as the
+	most recent "received" timestamp.  The real remote peer does
+	not know this value and this will disrupt the association until
+	the association resets.
+   Mitigation:
+	Implement BCP-38.
+	Upgrade to ntp-4.2.8p11 or later from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page.
+	Use authentication with 'peer' mode.
+	Have enough sources of time.
+	Properly monitor your ntpd instances.
+	If ntpd stops running, auto-restart it without -g .
+   Credit:
+   	This weakness was discovered by Miroslav Lichvar of Red Hat.
+
+* NTP Bug 3415: Provide a way to prevent authenticated symmetric passive
+	peering (LOW)
+   Date Resolved: Stable (4.2.8p11) 27 Feb 2018
+   References: Sec 3415 / CVE-2018-7170 / VU#961909
+   	       Sec 3012 / CVE-2016-1549 / VU#718152
+   Affects: All ntp-4 releases up to, but not including 4.2.8p7, and
+   	4.3.0 up to, but not including 4.3.92.  Resolved in 4.2.8p11.
+   CVSS2: LOW 3.5 - (AV:N/AC:M/Au:S/C:N/I:P/A:N)
+   CVSS3: LOW 3.1 - CVSS:3.0/AV:N/AC:H/PR:L/UI:N/S:U/C:N/I:L/A:N
+   Summary:
+	ntpd can be vulnerable to Sybil attacks.  If a system is set up to
+	use a trustedkey and if one is not using the feature introduced in
+	ntp-4.2.8p6 allowing an optional 4th field in the ntp.keys file to
+	specify which IPs can serve time, a malicious authenticated peer
+	-- i.e. one where the attacker knows the private symmetric key --
+	can create arbitrarily-many ephemeral associations in order to win
+	the clock selection of ntpd and modify a victim's clock.  Three
+	additional protections are offered in ntp-4.2.8p11.  One is the
+	new 'noepeer' directive, which disables symmetric passive
+	ephemeral peering. Another is the new 'ippeerlimit' directive,
+	which limits the number of peers that can be created from an IP.
+	The third extends the functionality of the 4th field in the
+	ntp.keys file to include specifying a subnet range.
+   Mitigation:
+	Implement BCP-38.
+	Upgrade to ntp-4.2.8p11 or later from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page.
+	Use the 'noepeer' directive to prohibit symmetric passive
+	    ephemeral associations.
+	Use the 'ippeerlimit' directive to limit the number of peers
+	    that can be created from an IP.
+	Use the 4th argument in the ntp.keys file to limit the IPs and
+	    subnets that can be time servers.
+	Have enough sources of time.
+	Properly monitor your ntpd instances.
+	If ntpd stops running, auto-restart it without -g .
+   Credit:
+	This weakness was reported as Bug 3012 by Matthew Van Gundy of
+	Cisco ASIG, and separately by Stefan Moser as Bug 3415.
+
+* ntpq Bug 3414: decodearr() can write beyond its 'buf' limits (Medium)
+   Date Resolved: 27 Feb 2018
+   References: Sec 3414 / CVE-2018-7183 / VU#961909
+   Affects: ntpq in ntp-4.2.8p6, up to but not including ntp-4.2.8p11.
+   CVSS2: MED 6.8 (AV:N/AC:M/Au:N/C:P/I:P/A:P)
+   CVSS3: MED 5.0 CVSS:3.0/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:L/A:L
+   Summary:
+   	ntpq is a monitoring and control program for ntpd.  decodearr()
+	is an internal function of ntpq that is used to -- wait for it --
+	decode an array in a response string when formatted data is being
+	displayed.  This is a problem in affected versions of ntpq if a
+	maliciously-altered ntpd returns an array result that will trip this
+	bug, or if a bad actor is able to read an ntpq request on its way to
+	a remote ntpd server and forge and send a response before the remote
+	ntpd sends its response.  It's potentially possible that the
+	malicious data could become injectable/executable code.
+   Mitigation:
+	Implement BCP-38.
+	Upgrade to ntp-4.2.8p11 or later from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page.
+   Credit:
+	This weakness was discovered by Michael Macnair of Thales e-Security.
+
+* NTP Bug 3412: ctl_getitem(): buffer read overrun leads to undefined
+	behavior and information leak (Info/Medium)
+   Date Resolved: 27 Feb 2018
+   References: Sec 3412 / CVE-2018-7182 / VU#961909
+   Affects: ntp-4.2.8p6, up to but not including ntp-4.2.8p11.
+   CVSS2: INFO 0.0 - MED 5.0 (AV:N/AC:L/Au:N/C:P/I:N/A:N) 0.0 if C:N
+   CVSS3: NONE 0.0 - MED 5.3 CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N
+	0.0 if C:N
+   Summary:
+	ctl_getitem()  is used by ntpd to process incoming mode 6 packets.
+	A malicious mode 6 packet can be sent to an ntpd instance, and
+	if the ntpd instance is from 4.2.8p6 thru 4.2.8p10, that will
+	cause ctl_getitem() to read past the end of its buffer.
+   Mitigation:
+	Implement BCP-38.
+	Upgrade to ntp-4.2.8p11 or later from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page.
+	Have enough sources of time.
+	Properly monitor your ntpd instances.
+	If ntpd stops running, auto-restart it without -g .
+   Credit:
+   	This weakness was discovered by Yihan Lian of Qihoo 360.
+
+* NTP Bug 3012: Sybil vulnerability: ephemeral association attack
+   Also see Bug 3415, above.
+   Date Mitigated: Stable (4.2.8p7) 26 Apr 2016; Dev (4.3.92) 26 Apr 2016
+   Date Resolved: Stable (4.2.8p11) 27 Feb 2018
+   References: Sec 3012 / CVE-2016-1549 / VU#718152
+   Affects: All ntp-4 releases up to, but not including 4.2.8p7, and
+	4.3.0 up to, but not including 4.3.92.  Resolved in 4.2.8p11.
+   CVSS2: LOW 3.5 - (AV:N/AC:M/Au:S/C:N/I:P/A:N)
+   CVSS3: MED 5.3 - CVSS:3.0/AV:N/AC:H/PR:L/UI:N/S:U/C:N/I:H/A:N
+   Summary:
+	ntpd can be vulnerable to Sybil attacks.  If a system is set up
+	to use a trustedkey and if one is not using the feature
+	introduced in ntp-4.2.8p6 allowing an optional 4th field in the
+	ntp.keys file to specify which IPs can serve time, a malicious
+	authenticated peer -- i.e. one where the attacker knows the
+	private symmetric key -- can create arbitrarily-many ephemeral
+	associations in order to win the clock selection of ntpd and
+	modify a victim's clock.  Two additional protections are
+	offered in ntp-4.2.8p11.  One is the 'noepeer' directive, which
+	disables symmetric passive ephemeral peering. The other extends
+	the functionality of the 4th field in the ntp.keys file to
+	include specifying a subnet range.
+   Mitigation:
+	Implement BCP-38.
+	Upgrade to 4.2.8p11, or later, from the NTP Project Download Page or
+	    the NTP Public Services Project Download Page.
+	Use the 'noepeer' directive to prohibit symmetric passive
+	    ephemeral associations.
+	Use the 'ippeerlimit' directive to limit the number of peer
+	    associations from an IP.
+	Use the 4th argument in the ntp.keys file to limit the IPs
+	    and subnets that can be time servers.
+	Properly monitor your ntpd instances.
+   Credit:
+   	This weakness was discovered by Matthew Van Gundy of Cisco ASIG.
+
+* Bug fixes:
+ [Bug 3457] OpenSSL FIPS mode regression <perlinger@ntp.org>
+ [Bug 3455] ntpd doesn't use scope id when binding multicast <perlinger@ntp.org>
+ - applied patch by Sean Haugh 
+ [Bug 3452] PARSE driver prints uninitialized memory. <perlinger@ntp.org>
+ [Bug 3450] Dubious error messages from plausibility checks in get_systime()
+ - removed error log caused by rounding/slew, ensured postcondition <perlinger@ntp.org>
+ [Bug 3447] AES-128-CMAC (fixes) <perlinger@ntp.org>
+ - refactoring the MAC code, too
+ [Bug 3441] Validate the assumption that AF_UNSPEC is 0.  stenn@ntp.org
+ [Bug 3439] When running multiple commands / hosts in ntpq... <perlinger@ntp.org>
+ - applied patch by ggarvey
+ [Bug 3438] Negative values and values > 999 days in... <perlinger@ntp.org>
+ - applied patch by ggarvey (with minor mods)
+ [Bug 3437] ntpd tries to open socket with AF_UNSPEC domain
+ - applied patch (with mods) by Miroslav Lichvar <perlinger@ntp.org>
+ [Bug 3435] anchor NTP era alignment <perlinger@ntp.org>
+ [Bug 3433] sntp crashes when run with -a.  <stenn@ntp.org>
+ [Bug 3430] ntpq dumps core (SIGSEGV) for "keytype md2"
+ - fixed several issues with hash algos in ntpd, sntp, ntpq,
+   ntpdc and the test suites <perlinger@ntp.org>
+ [Bug 3424] Trimble Thunderbolt 1024 week millenium bug <perlinger@ntp.org>
+ - initial patch by Daniel Pouzzner
+ [Bug 3423] QNX adjtime() implementation error checking is
+ wrong <perlinger@ntp.org>
+ [Bug 3417] ntpq ifstats packet counters can be negative
+ made IFSTATS counter quantities unsigned <perlinger@ntp.org>
+ [Bug 3411] problem about SIGN(6) packet handling for ntp-4.2.8p10
+ - raised receive buffer size to 1200 <perlinger@ntp.org>
+ [Bug 3408] refclock_jjy.c: Avoid a wrong report of the coverity static
+ analysis tool. <abe@ntp.org>
+ [Bug 3405] update-leap.in: general cleanup, HTTPS support.  Paul McMath.
+ [Bug 3404] Fix openSSL DLL usage under Windows <perlinger@ntp.org>
+ - fix/drop assumptions on OpenSSL libs directory layout
+ [Bug 3399] NTP: linker error in 4.2.8p10 during Linux cross-compilation
+ - initial patch by timeflies@mail2tor.com  <perlinger@ntp.org>
+ [Bug 3398] tests fail with core dump <perlinger@ntp.org>
+ - patch contributed by Alexander Bluhm
+ [Bug 3397] ctl_putstr() asserts that data fits in its buffer
+ rework of formatting & data transfer stuff in 'ntp_control.c'
+ avoids unecessary buffers and size limitations. <perlinger@ntp.org>
+ [Bug 3394] Leap second deletion does not work on ntpd clients
+ - fixed handling of dynamic deletion w/o leap file <perlinger@ntp.org>
+ [Bug 3391] ntpd segfaults on startup due to small warmup thread stack size
+ - increased mimimum stack size to 32kB <perlinger@ntp.org>
+ [Bug 3367] Faulty LinuxPPS NMEA clock support in 4.2.8 <perlinger@ntp.org>
+ - reverted handling of PPS kernel consumer to 4.2.6 behavior
+ [Bug 3365] Updates driver40(-ja).html and miscopt.html <abe@ntp.org>
+ [Bug 3358] Spurious KoD log messages in .INIT. phase.  HStenn.
+ [Bug 3016] wrong error position reported for bad ":config pool"
+ - fixed location counter & ntpq output <perlinger@ntp.org>
+ [Bug 2900] libntp build order problem.  HStenn.
+ [Bug 2878] Tests are cluttering up syslog <perlinger@ntp.org>
+ [Bug 2737] Wrong phone number listed for USNO. ntp-bugs@bodosom.net,
+ perlinger@ntp.org
+ [Bug 2557] Fix Thunderbolt init. ntp-bugs@bodosom.net, perlinger@ntp.
+ [Bug 948] Trustedkey config directive leaks memory. <perlinger@ntp.org>
+ Use strlcpy() to copy strings, not memcpy().  HStenn.
+ Typos.  HStenn.
+ test_ntp_scanner_LDADD needs ntpd/ntp_io.o.  HStenn.
+ refclock_jjy.c: Add missing "%s" to an msyslog() call.  HStenn.
+ Build ntpq and libntpq.a with NTP_HARD_*FLAGS.  perlinger@ntp.org
+ Fix trivial warnings from 'make check'. perlinger@ntp.org
+ Fix bug in the override portion of the compiler hardening macro. HStenn.
+ record_raw_stats(): Log entire packet.  Log writes.  HStenn.
+ AES-128-CMAC support.  BInglis, HStenn, JPerlinger.
+ sntp: tweak key file logging.  HStenn.
+ sntp: pkt_output(): Improve debug output.  HStenn.
+ update-leap: updates from Paul McMath.
+ When using pkg-config, report --modversion.  HStenn.
+ Clean up libevent configure checks.  HStenn.
+ sntp: show the IP of who sent us a crypto-NAK.  HStenn.
+ Allow .../N to specify subnet bits for IPs in ntp.keys.  HStenn, JPerlinger.
+ authistrustedip() - use it in more places.  HStenn, JPerlinger.
+ New sysstats: sys_lamport, sys_tsrounding.  HStenn.
+ Update ntp.keys .../N documentation.  HStenn.
+ Distribute testconf.yml.  HStenn.
+ Add DPRINTF(2,...) lines to receive() for packet drops.  HStenn.
+ Rename the configuration flag fifo variables.  HStenn.
+ Improve saveconfig output.  HStenn.
+ Decode restrict flags on receive() debug output.  HStenn.
+ Decode interface flags on receive() debug output.  HStenn.
+ Warn the user if deprecated "driftfile name WanderThreshold" is used.  HStenn.
+ Update the documentation in ntp.conf.def .  HStenn.
+ restrictions() must return restrict flags and ippeerlimit.  HStenn.
+ Update ntpq peer documentation to describe the 'p' type.  HStenn.
+ Rename restrict 'flags' to 'rflags.  Use an enum for the values.  HStenn.
+ Provide dump_restricts() for debugging.  HStenn.
+ Use consistent 4th arg type for [gs]etsockopt.  JPerlinger.
+
+* Other items:
+
+* update-leap needs the following perl modules:
+	Net::SSLeay
+	IO::Socket::SSL
+
+* New sysstats variables: sys_lamport, sys_tsrounding
+See them with: ntpq -c "rv 0 ss_lamport,ss_tsrounding"
+sys_lamport counts the number of observed Lamport violations, while
+sys_tsrounding counts observed timestamp rounding events.
+
+* New ntp.conf items:
+
+- restrict ... noepeer
+- restrict ... ippeerlimit N
+
+The 'noepeer' directive will disallow all ephemeral/passive peer
+requests.
+
+The 'ippeerlimit' directive limits the number of time associations
+for each IP in the designated set of addresses.  This limit does not
+apply to explicitly-configured associations.  A value of -1, the current
+default, means an unlimited number of associations may connect from a
+single IP.  0 means "none", etc.  Ordinarily the only way multiple
+associations would come from the same IP would be if the remote side
+was using a proxy.  But a trusted machine might become compromised,
+in which case an attacker might spin up multiple authenticated sessions
+from different ports.  This directive should be helpful in this case.
+
+* New ntp.keys feature: Each IP in the optional list of IPs in the 4th
+field may contain a /subnetbits specification, which identifies  the
+scope of IPs that may use this key.  This IP/subnet restriction can be
+used to limit the IPs that may use the key in most all situations where
+a key is used.
+--
+NTP 4.2.8p10 (Harlan Stenn <stenn@ntp.org>, 2017/03/21) 
+
+Focus: Security, Bug fixes, enhancements.
+
+Severity: MEDIUM
+
+This release fixes 5 medium-, 6 low-, and 4 informational-severity
+vulnerabilities, and provides 15 other non-security fixes and improvements:
+
+* NTP-01-016 NTP: Denial of Service via Malformed Config (Medium)
+   Date Resolved: 21 Mar 2017
+   References: Sec 3389 / CVE-2017-6464 / VU#325339
+   Affects: All versions of NTP-4, up to but not including ntp-4.2.8p10, and
+	ntp-4.3.0 up to, but not including ntp-4.3.94.
+   CVSS2: MED 4.6 (AV:N/AC:H/Au:M/C:N/I:N/A:C)
+   CVSS3: MED 4.2 CVSS:3.0/AV:N/AC:H/PR:H/UI:R/S:U/C:N/I:N/A:H
+   Summary:
+	A vulnerability found in the NTP server makes it possible for an
+	authenticated remote user to crash ntpd via a malformed mode
+	configuration directive.
+   Mitigation:
+	Implement BCP-38.
+	Upgrade to 4.2.8p10, or later, from the NTP Project Download Page or
+	    the NTP Public Services Project Download Page
+	Properly monitor your ntpd instances, and auto-restart
+	    ntpd (without -g) if it stops running. 
+   Credit:
+	This weakness was discovered by Cure53. 
+
+* NTP-01-014 NTP: Buffer Overflow in DPTS Clock (Low)
+    Date Resolved: 21 Mar 2017
+    References: Sec 3388 / CVE-2017-6462 / VU#325339
+    Affects: All versions of NTP, up to but not including ntp-4.2.8p10, and ntp-4.3.0 up to, but not including ntp-4.3.94.
+    CVSS2: Low 1.0 (AV:L/AC:H/Au:S/C:N/I:N/A:P)
+    CVSS3: Low 1.6 CVSS:3.0/AV:P/AC:H/PR:H/UI:R/S:U/C:N/I:N/A:L
+    Summary:
+	There is a potential for a buffer overflow in the legacy Datum
+	Programmable Time Server refclock driver.  Here the packets are
+	processed from the /dev/datum device and handled in
+	datum_pts_receive().  Since an attacker would be required to
+	somehow control a malicious /dev/datum device, this does not
+	appear to be a practical attack and renders this issue "Low" in
+	terms of severity.
+   Mitigation:
+	If you have a Datum reference clock installed and think somebody
+	    may maliciously change the device, upgrade to 4.2.8p10, or
+	    later, from the NTP Project Download Page or the NTP Public
+	    Services Project Download Page
+	Properly monitor your ntpd instances, and auto-restart
+	    ntpd (without -g) if it stops running. 
+   Credit:
+	This weakness was discovered by Cure53. 
+
+* NTP-01-012 NTP: Authenticated DoS via Malicious Config Option (Medium)
+   Date Resolved: 21 Mar 2017
+   References: Sec 3387 / CVE-2017-6463 / VU#325339
+   Affects: All versions of ntp, up to but not including ntp-4.2.8p10, and
+	ntp-4.3.0 up to, but not including ntp-4.3.94.
+   CVSS2: MED 4.6 (AV:N/AC:H/Au:M/C:N/I:N/A:C)
+   CVSS3: MED 4.2 CVSS:3.0/AV:N/AC:H/PR:H/UI:R/S:U/C:N/I:N/A:H
+   Summary:
+	A vulnerability found in the NTP server allows an authenticated
+	remote attacker to crash the daemon by sending an invalid setting
+	via the :config directive.  The unpeer option expects a number or
+	an address as an argument.  In case the value is "0", a
+	segmentation fault occurs.
+   Mitigation:
+	Implement BCP-38.
+	Upgrade to 4.2.8p10, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page 
+	Properly monitor your ntpd instances, and auto-restart
+	    ntpd (without -g) if it stops running. 
+   Credit:
+	This weakness was discovered by Cure53. 
+
+* NTP-01-011 NTP: ntpq_stripquotes() returns incorrect value (Informational)
+   Date Resolved: 21 Mar 2017
+   References: Sec 3386
+   Affects: All versions of NTP, up to but not including ntp-4.2.8p10, and
+	ntp-4.3.0 up to, but not including ntp-4.3.94.
+   CVSS2: None 0.0 (AV:N/AC:H/Au:N/C:N/I:N/A:N)
+   CVSS3: None 0.0 CVSS:3.0/AV:N/AC:H/PR:H/UI:R/S:U/C:N/I:N/A:N
+   Summary:
+	The NTP Mode 6 monitoring and control client, ntpq, uses the
+	function ntpq_stripquotes() to remove quotes and escape characters
+	from a given string.  According to the documentation, the function
+	is supposed to return the number of copied bytes but due to
+	incorrect pointer usage this value is always zero.  Although the
+	return value of this function is never used in the code, this
+	flaw could lead to a vulnerability in the future.  Since relying
+	on wrong return values when performing memory operations is a
+	dangerous practice, it is recommended to return the correct value
+	in accordance with the documentation pertinent to the code.
+   Mitigation:
+	Implement BCP-38.
+	Upgrade to 4.2.8p10, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page
+	Properly monitor your ntpd instances, and auto-restart
+	    ntpd (without -g) if it stops running. 
+   Credit:
+	This weakness was discovered by Cure53. 
+
+* NTP-01-010 NTP: ereallocarray()/eallocarray() underused (Info)
+   Date Resolved: 21 Mar 2017
+   References: Sec 3385
+   Affects: All versions of NTP, up to but not including ntp-4.2.8p10, and
+	ntp-4.3.0 up to, but not including ntp-4.3.94.
+   Summary:
+	NTP makes use of several wrappers around the standard heap memory
+	allocation functions that are provided by libc.  This is mainly
+	done to introduce additional safety checks concentrated on
+	several goals.  First, they seek to ensure that memory is not
+	accidentally freed, secondly they verify that a correct amount
+	is always allocated and, thirdly, that allocation failures are
+	correctly handled.  There is an additional implementation for
+	scenarios where memory for a specific amount of items of the
+	same size needs to be allocated.  The handling can be found in
+	the oreallocarray() function for which a further number-of-elements
+	parameter needs to be provided.  Although no considerable threat
+	was identified as tied to a lack of use of this function, it is
+	recommended to correctly apply oreallocarray() as a preferred
+	option across all of the locations where it is possible.
+   Mitigation:
+	Upgrade to 4.2.8p10, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page 
+   Credit:
+	This weakness was discovered by Cure53. 
+
+* NTP-01-009 NTP: Privileged execution of User Library code (WINDOWS
+	PPSAPI ONLY) (Low)
+   Date Resolved: 21 Mar 2017
+   References: Sec 3384 / CVE-2017-6455 / VU#325339
+   Affects: All Windows versions of ntp-4 that use the PPSAPI, up to but
+	not including ntp-4.2.8p10, and ntp-4.3.0 up to, but not
+	including ntp-4.3.94.
+   CVSS2: MED 3.8 (AV:L/AC:H/Au:S/C:N/I:N/A:C)
+   CVSS3: MED 4.0 CVSS:3.0/AV:L/AC:H/PR:H/UI:R/S:U/C:N/I:N/A:H
+   Summary:
+	The Windows NT port has the added capability to preload DLLs
+	defined in the inherited global local environment variable
+	PPSAPI_DLLS.  The code contained within those libraries is then
+	called from the NTPD service, usually running with elevated
+	privileges. Depending on how securely the machine is setup and
+	configured, if ntpd is configured to use the PPSAPI under Windows
+	this can easily lead to a code injection.
+   Mitigation:
+	Implement BCP-38.
+	Upgrade to 4.2.8p10, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page 
+   Credit:
+   This weakness was discovered by Cure53. 
+
+* NTP-01-008 NTP: Stack Buffer Overflow from Command Line (WINDOWS
+	installer ONLY) (Low)
+   Date Resolved: 21 Mar 2017
+   References: Sec 3383 / CVE-2017-6452 / VU#325339
+   Affects: WINDOWS installer ONLY: All versions of the ntp-4 Windows
+	installer, up to but not including ntp-4.2.8p10, and ntp-4.3.0 up
+	to, but not including ntp-4.3.94.
+   CVSS2: Low 1.0 (AV:L/AC:H/Au:S/C:N/I:N/A:P)
+   CVSS3: Low 1.8 CVSS:3.0/AV:L/AC:H/PR:H/UI:R/S:U/C:N/I:N/A:L
+   Summary:
+	The Windows installer for NTP calls strcat(), blindly appending
+	the string passed to the stack buffer in the addSourceToRegistry()
+	function.  The stack buffer is 70 bytes smaller than the buffer
+	in the calling main() function.  Together with the initially
+	copied Registry path, the combination causes a stack buffer
+	overflow and effectively overwrites the stack frame.  The
+	passed application path is actually limited to 256 bytes by the
+	operating system, but this is not sufficient to assure that the
+	affected stack buffer is consistently protected against
+	overflowing at all times.
+   Mitigation:
+	Upgrade to 4.2.8p10, or later, from the NTP Project Download Page
+	or the NTP Public Services Project Download Page 
+   Credit:
+	This weakness was discovered by Cure53. 
+
+* NTP-01-007 NTP: Data Structure terminated insufficiently (WINDOWS
+	installer ONLY) (Low)
+   Date Resolved: 21 Mar 2017
+   References: Sec 3382 / CVE-2017-6459 / VU#325339
+   Affects: WINDOWS installer ONLY: All ntp-4 versions of the Windows
+	installer, up to but not including ntp-4.2.8p10, and ntp-4.3.0
+	up to, but not including ntp-4.3.94.
+   CVSS2: Low 1.0 (AV:L/AC:H/Au:S/C:N/I:N/A:P)
+   CVSS3: Low 1.8 CVSS:3.0/AV:L/AC:H/PR:H/UI:R/S:U/C:N/I:N/A:L
+   Summary:
+	The Windows installer for NTP calls strcpy() with an argument
+	that specifically contains multiple null bytes.  strcpy() only
+	copies a single terminating null character into the target
+	buffer instead of copying the required double null bytes in the
+	addKeysToRegistry() function.  As a consequence, a garbage
+	registry entry can be created.  The additional arsize parameter
+	is erroneously set to contain two null bytes and the following
+	call to RegSetValueEx() claims to be passing in a multi-string
+	value, though this may not be true.
+   Mitigation:
+	Upgrade to 4.2.8p10, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page 
+   Credit:
+	This weakness was discovered by Cure53. 
+
+* NTP-01-006 NTP: Copious amounts of Unused Code (Informational)
+   References: Sec 3381
+   Summary:
+	The report says: Statically included external projects
+	potentially introduce several problems and the issue of having
+	extensive amounts of code that is "dead" in the resulting binary
+	must clearly be pointed out.  The unnecessary unused code may or
+	may not contain bugs and, quite possibly, might be leveraged for
+	code-gadget-based branch-flow redirection exploits.  Analogically,
+	having source trees statically included as well means a failure
+	in taking advantage of the free feature for periodical updates.
+	This solution is offered by the system's Package Manager. The
+	three libraries identified are libisc, libevent, and libopts.
+   Resolution:
+	For libisc, we already only use a portion of the original library.
+	We've found and fixed bugs in the original implementation (and
+	offered the patches to ISC), and plan to see what has changed
+	since we last upgraded the code.  libisc is generally not
+	installed, and when it it we usually only see the static libisc.a
+	file installed.  Until we know for sure that the bugs we've found
+	and fixed are fixed upstream, we're better off with the copy we
+	are using.
+
+        Version 1 of libevent was the only production version available
+	until recently, and we've been requiring version 2 for a long time.
+	But if the build system has at least version 2 of libevent
+	installed, we'll use the version that is installed on the system.
+	Otherwise, we provide a copy of libevent that we know works.
+
+        libopts is provided by GNU AutoGen, and that library and package
+	undergoes frequent API version updates.  The version of autogen
+	used to generate the tables for the code must match the API
+	version in libopts.  AutoGen can be ... difficult to build and
+	install, and very few developers really need it.  So we have it
+	on our build and development machines, and we provide the
+	specific version of the libopts code in the distribution to make
+	sure that the proper API version of libopts is available.
+
+        As for the point about there being code in these libraries that
+	NTP doesn't use, OK.  But other packages used these libraries as
+	well, and it is reasonable to assume that other people are paying
+	attention to security and code quality issues for the overall
+	libraries.  It takes significant resources to analyze and
+	customize these libraries to only include what we need, and to
+	date we believe the cost of this effort does not justify the benefit. 
+   Credit:
+	This issue was discovered by Cure53. 
+
+* NTP-01-005 NTP: Off-by-one in Oncore GPS Receiver (Low)
+   Date Resolved: 21 Mar 2017
+   References: Sec 3380
+   Affects: All versions of NTP, up to but not including ntp-4.2.8p10, and
+   	ntp-4.3.0 up to, but not including ntp-4.3.94.
+   CVSS2: None 0.0 (AV:L/AC:H/Au:N/C:N/I:N/A:N)
+   CVSS3: None 0.0 CVSS:3.0/AV:L/AC:H/PR:H/UI:N/S:U/C:N/I:N/A:N
+   Summary:
+	There is a fencepost error in a "recovery branch" of the code for
+	the Oncore GPS receiver if the communication link to the ONCORE
+	is weak / distorted and the decoding doesn't work.
+   Mitigation:
+        Upgrade to 4.2.8p10, or later, from the NTP Project Download Page or
+	    the NTP Public Services Project Download Page
+        Properly monitor your ntpd instances, and auto-restart
+	    ntpd (without -g) if it stops running. 
+   Credit:
+	This weakness was discovered by Cure53. 
+
+* NTP-01-004 NTP: Potential Overflows in ctl_put() functions (Medium)
+   Date Resolved: 21 Mar 2017
+   References: Sec 3379 / CVE-2017-6458 / VU#325339
+   Affects: All versions of NTP, up to but not including ntp-4.2.8p10, and
+	ntp-4.3.0 up to, but not including ntp-4.3.94.
+   CVSS2: MED 4.6 (AV:N/AC:H/Au:M/C:N/I:N/A:C)
+   CVSS3: MED 4.2 CVSS:3.0/AV:N/AC:H/PR:H/UI:R/S:U/C:N/I:N/A:H
+   Summary:
+	ntpd makes use of different wrappers around ctl_putdata() to
+	create name/value ntpq (mode 6) response strings.  For example,
+	ctl_putstr() is usually used to send string data (variable names
+	or string data).  The formatting code was missing a length check
+	for variable names.  If somebody explicitly created any unusually
+	long variable names in ntpd (longer than 200-512 bytes, depending
+	on the type of variable), then if any of these variables are
+	added to the response list it would overflow a buffer.
+   Mitigation:
+	Implement BCP-38.
+	Upgrade to 4.2.8p10, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page
+	If you don't want to upgrade, then don't setvar variable names
+	    longer than 200-512 bytes in your ntp.conf file.
+	Properly monitor your ntpd instances, and auto-restart
+	    ntpd (without -g) if it stops running. 
+   Credit:
+	This weakness was discovered by Cure53. 
+
+* NTP-01-003 NTP: Improper use of snprintf() in mx4200_send() (Low)
+   Date Resolved: 21 Mar 2017
+   References: Sec 3378 / CVE-2017-6451 / VU#325339
+   Affects: All versions of NTP, up to but not including ntp-4.2.8p10, and
+	ntp-4.3.0 up to, but not including ntp-4.3.94.
+   CVSS2: LOW 0.8 (AV:L/AC:H/Au:M/C:N/I:N/A:P)
+   CVSS3: LOW 1.8 CVSS:3.0/AV:L/AC:H/PR:H/UI:R/S:U/C:N/I:L/A:N
+   Summary:
+	The legacy MX4200 refclock is only built if is specifically
+	enabled, and furthermore additional code changes are required to
+	compile and use it.  But it uses the libc functions snprintf()
+	and vsnprintf() incorrectly, which can lead to an out-of-bounds
+	memory write due to an improper handling of the return value of
+	snprintf()/vsnprintf().  Since the return value is used as an
+	iterator and it can be larger than the buffer's size, it is
+	possible for the iterator to point somewhere outside of the
+	allocated buffer space.  This results in an out-of-bound memory
+	write.  This behavior can be leveraged to overwrite a saved
+	instruction pointer on the stack and gain control over the
+	execution flow.  During testing it was not possible to identify
+	any malicious usage for this vulnerability.  Specifically, no
+	way for an attacker to exploit this vulnerability was ultimately
+	unveiled.  However, it has the potential to be exploited, so the
+	code should be fixed.
+   Mitigation, if you have a Magnavox MX4200 refclock:
+	Upgrade to 4.2.8p10, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page.
+	Properly monitor your ntpd instances, and auto-restart
+	    ntpd (without -g) if it stops running. 
+   Credit:
+	This weakness was discovered by Cure53. 
+
+* NTP-01-002 NTP: Buffer Overflow in ntpq when fetching reslist from a
+	malicious ntpd (Medium)
+   Date Resolved: 21 Mar 2017
+   References: Sec 3377 / CVE-2017-6460 / VU#325339
+   Affects: All versions of ntpq, up to but not including ntp-4.2.8p10, and
+	ntp-4.3.0 up to, but not including ntp-4.3.94.
+   CVSS2: MED 4.9 (AV:N/AC:H/Au:S/C:N/I:N/A:C)
+   CVSS3: MED 4.2 CVSS:3.0/AV:N/AC:H/PR:H/UI:R/S:U/C:N/I:N/A:H
+   Summary:
+	A stack buffer overflow in ntpq can be triggered by a malicious
+	ntpd server when ntpq requests the restriction list from the server.
+	This is due to a missing length check in the reslist() function.
+	It occurs whenever the function parses the server's response and
+	encounters a flagstr variable of an excessive length.  The string
+	will be copied into a fixed-size buffer, leading to an overflow on
+	the function's stack-frame.  Note well that this problem requires
+	a malicious server, and affects ntpq, not ntpd.
+   Mitigation:
+	Upgrade to 4.2.8p10, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page
+	If you can't upgrade your version of ntpq then if you want to know
+	    the reslist of an instance of ntpd that you do not control,
+	    know that if the target ntpd is malicious that it can send back
+	    a response that intends to crash your ntpq process. 
+   Credit:
+	This weakness was discovered by Cure53. 
+
+* NTP-01-001 NTP: Makefile does not enforce Security Flags (Informational)
+   Date Resolved: 21 Mar 2017
+   References: Sec 3376
+   Affects: All versions of NTP, up to but not including ntp-4.2.8p10, and
+	ntp-4.3.0 up to, but not including ntp-4.3.94.
+   CVSS2: N/A
+   CVSS3: N/A
+   Summary:
+	The build process for NTP has not, by default, provided compile
+	or link flags to offer "hardened" security options.  Package
+	maintainers have always been able to provide hardening security
+	flags for their builds.  As of ntp-4.2.8p10, the NTP build
+	system has a way to provide OS-specific hardening flags.  Please
+	note that this is still not a really great solution because it
+	is specific to NTP builds.  It's inefficient to have every
+	package supply, track and maintain this information for every
+	target build.  It would be much better if there was a common way
+	for OSes to provide this information in a way that arbitrary
+	packages could benefit from it.
+   Mitigation:
+	Implement BCP-38.
+	Upgrade to 4.2.8p10, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page
+	Properly monitor your ntpd instances, and auto-restart
+	    ntpd (without -g) if it stops running. 
+   Credit:
+	This weakness was reported by Cure53. 
+
+* 0rigin DoS (Medium)
+   Date Resolved: 21 Mar 2017
+   References: Sec 3361 / CVE-2016-9042 / VU#325339
+   Affects: ntp-4.2.8p9 (21 Nov 2016), up to but not including ntp-4.2.8p10
+   CVSS2: MED 4.9 (AV:N/AC:H/Au:N/C:N/I:N/A:C) (worst case)
+   CVSS3: MED 4.4 CVSS:3.0/AV:N/AC:H/PR:H/UI:N/S:U/C:N/I:N/A:H (worst case)
+   Summary:
+	An exploitable denial of service vulnerability exists in the
+	origin timestamp check functionality of ntpd 4.2.8p9.  A specially
+	crafted unauthenticated network packet can be used to reset the
+	expected origin timestamp for target peers.  Legitimate replies
+	from targeted peers will fail the origin timestamp check (TEST2)
+	causing the reply to be dropped and creating a denial of service
+	condition.  This vulnerability can only be exploited if the
+	attacker can spoof all of the servers.
+   Mitigation:
+	Implement BCP-38.
+	Configure enough servers/peers that an attacker cannot target
+	    all of your time sources.
+	Upgrade to 4.2.8p10, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page
+	Properly monitor your ntpd instances, and auto-restart
+	    ntpd (without -g) if it stops running. 
+   Credit:
+	This weakness was discovered by Matthew Van Gundy of Cisco. 
+
+Other fixes:
+
+* [Bug 3393] clang scan-build findings <perlinger@ntp.org>
+* [Bug 3363] Support for openssl-1.1.0 without compatibility modes
+  - rework of patch set from <ntp.org@eroen.eu>. <perlinger@ntp.org>
+* [Bug 3356] Bugfix 3072 breaks multicastclient <perlinger@ntp.org>
+* [Bug 3216] libntp audio ioctl() args incorrectly cast to int
+  on 4.4BSD-Lite derived platforms <perlinger@ntp.org>
+  - original patch by Majdi S. Abbas
+* [Bug 3215] 'make distcheck' fails with new BK repo format <perlinger@ntp.org>
+* [Bug 3173] forking async worker: interrupted pipe I/O <perlinger@ntp.org>
+  - initial patch by Christos Zoulas
+* [Bug 3139] (...) time_pps_create: Exec format error <perlinger@ntp.org>
+  - move loader API from 'inline' to proper source
+  - augment pathless dlls with absolute path to NTPD
+  - use 'msyslog()' instead of 'printf() 'for reporting trouble
+* [Bug 3107] Incorrect Logic for Peer Event Limiting <perlinger@ntp.org>
+  - applied patch by Matthew Van Gundy
+* [Bug 3065] Quiet warnings on NetBSD <perlinger@ntp.org>
+  - applied some of the patches provided by Havard. Not all of them
+    still match the current code base, and I did not touch libopt.
+* [Bug 3062] Change the process name of forked DNS worker <perlinger@ntp.org>
+  - applied patch by Reinhard Max. See bugzilla for limitations.
+* [Bug 2923] Trap Configuration Fail <perlinger@ntp.org>
+  - fixed dependency inversion from [Bug 2837]
+* [Bug 2896] Nothing happens if minsane < maxclock < minclock
+  - produce ERROR log message about dysfunctional daemon. <perlinger@ntp.org>
+* [Bug 2851] allow -4/-6 on restrict line with mask <perlinger@ntp.org>
+  - applied patch by Miroslav Lichvar for ntp4.2.6 compat
+* [Bug 2645] out-of-bound pointers in ctl_putsys and decode_bitflags
+  - Fixed these and some more locations of this pattern.
+    Probably din't get them all, though. <perlinger@ntp.org>
+* Update copyright year.
+
+--
+(4.2.8p9-win) 2017/02/01 Released by Harlan Stenn <stenn@ntp.org>
+
+* [Bug 3144] NTP does not build without openSSL. <perlinger@ntp.org>
+  - added missed changeset for automatic openssl lib detection
+  - fixed some minor warning issues
+* [Bug 3095]  More compatibility with openssl 1.1. <perlinger@ntp.org>
+* configure.ac cleanup.  stenn@ntp.org
+* openssl configure cleanup.  stenn@ntp.org
+
+--
+NTP 4.2.8p9 (Harlan Stenn <stenn@ntp.org>, 2016/11/21) 
+
+Focus: Security, Bug fixes, enhancements.
+
+Severity: HIGH
+
+In addition to bug fixes and enhancements, this release fixes the
+following 1 high- (Windows only), 2 medium-, 2 medium-/low, and
+5 low-severity vulnerabilities, and provides 28 other non-security
+fixes and improvements:
+
+* Trap crash
+   Date Resolved: 21 November 2016; Dev (4.3.94) 21 November 2016
+   References: Sec 3119 / CVE-2016-9311 / VU#633847
+   Affects: ntp-4.0.90 (21 July 1999), possibly earlier, up to but not
+   	including 4.2.8p9, and ntp-4.3.0 up to but not including ntp-4.3.94.
+   CVSS2: MED 4.9 (AV:N/AC:H/Au:N/C:N/I:N/A:C)
+   CVSS3: MED 4.4 CVSS:3.0/AV:N/AC:H/PR:H/UI:N/S:U/C:N/I:N/A:H
+   Summary: 
+	ntpd does not enable trap service by default. If trap service
+	has been explicitly enabled, an attacker can send a specially
+	crafted packet to cause a null pointer dereference that will
+	crash ntpd, resulting in a denial of service. 
+   Mitigation:
+        Implement BCP-38.
+	Use "restrict default noquery ..." in your ntp.conf file. Only
+	    allow mode 6 queries from trusted networks and hosts. 
+        Upgrade to 4.2.8p9, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page
+        Properly monitor your ntpd instances, and auto-restart ntpd
+	    (without -g) if it stops running. 
+   Credit: This weakness was discovered by Matthew Van Gundy of Cisco.
+
+* Mode 6 information disclosure and DDoS vector
+   Date Resolved: 21 November 2016; Dev (4.3.94) 21 November 2016
+   References: Sec 3118 / CVE-2016-9310 / VU#633847
+   Affects: ntp-4.0.90 (21 July 1999), possibly earlier, up to but not
+	including 4.2.8p9, and ntp-4.3.0 up to but not including ntp-4.3.94.
+   CVSS2: MED 6.4 (AV:A/AC:L/Au:N/C:N/I:N/A:P)
+   CVSS3: MED 6.5 CVSS:3.0/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
+   Summary: 
+	An exploitable configuration modification vulnerability exists
+	in the control mode (mode 6) functionality of ntpd. If, against
+	long-standing BCP recommendations, "restrict default noquery ..."
+	is not specified, a specially crafted control mode packet can set
+	ntpd traps, providing information disclosure and DDoS
+	amplification, and unset ntpd traps, disabling legitimate
+	monitoring. A remote, unauthenticated, network attacker can
+	trigger this vulnerability. 
+   Mitigation:
+        Implement BCP-38.
+	Use "restrict default noquery ..." in your ntp.conf file.
+        Upgrade to 4.2.8p9, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page
+        Properly monitor your ntpd instances, and auto-restart ntpd
+	    (without -g) if it stops running. 
+   Credit: This weakness was discovered by Matthew Van Gundy of Cisco.
+
+* Broadcast Mode Replay Prevention DoS
+   Date Resolved: 21 November 2016; Dev (4.3.94) 21 November 2016
+   References: Sec 3114 / CVE-2016-7427 / VU#633847
+   Affects: ntp-4.2.8p6, up to but not including ntp-4.2.8p9, and 
+	ntp-4.3.90 up to, but not including ntp-4.3.94.
+   CVSS2: LOW 3.3 (AV:A/AC:L/Au:N/C:N/I:N/A:P)
+   CVSS3: MED 4.3 CVSS:3.0/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
+   Summary: 
+	The broadcast mode of NTP is expected to only be used in a
+	trusted network. If the broadcast network is accessible to an
+	attacker, a potentially exploitable denial of service
+	vulnerability in ntpd's broadcast mode replay prevention
+	functionality can be abused. An attacker with access to the NTP
+	broadcast domain can periodically inject specially crafted
+	broadcast mode NTP packets into the broadcast domain which,
+	while being logged by ntpd, can cause ntpd to reject broadcast
+	mode packets from legitimate NTP broadcast servers. 
+   Mitigation:
+        Implement BCP-38.
+        Upgrade to 4.2.8p9, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page
+        Properly monitor your ntpd instances, and auto-restart ntpd
+	    (without -g) if it stops running. 
+   Credit: This weakness was discovered by Matthew Van Gundy of Cisco.
+
+* Broadcast Mode Poll Interval Enforcement DoS
+   Date Resolved: 21 November 2016; Dev (4.3.94) 21 November 2016
+   References: Sec 3113 / CVE-2016-7428 / VU#633847
+   Affects: ntp-4.2.8p6, up to but not including ntp-4.2.8p9, and
+	ntp-4.3.90 up to, but not including ntp-4.3.94
+   CVSS2: LOW 3.3 (AV:A/AC:L/Au:N/C:N/I:N/A:P)
+   CVSS3: MED 4.3 CVSS:3.0/AV:A/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
+   Summary: 
+	The broadcast mode of NTP is expected to only be used in a
+	trusted network. If the broadcast network is accessible to an
+	attacker, a potentially exploitable denial of service
+	vulnerability in ntpd's broadcast mode poll interval enforcement
+	functionality can be abused. To limit abuse, ntpd restricts the
+	rate at which each broadcast association will process incoming
+	packets. ntpd will reject broadcast mode packets that arrive
+	before the poll interval specified in the preceding broadcast
+	packet expires. An attacker with access to the NTP broadcast
+	domain can send specially crafted broadcast mode NTP packets to
+	the broadcast domain which, while being logged by ntpd, will
+	cause ntpd to reject broadcast mode packets from legitimate NTP
+	broadcast servers. 
+   Mitigation:
+        Implement BCP-38.
+        Upgrade to 4.2.8p9, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page
+        Properly monitor your ntpd instances, and auto-restart ntpd
+	    (without -g) if it stops running. 
+   Credit: This weakness was discovered by Matthew Van Gundy of Cisco.
+
+* Windows: ntpd DoS by oversized UDP packet
+   Date Resolved: 21 November 2016; Dev (4.3.94) 21 November 2016
+   References: Sec 3110 / CVE-2016-9312 / VU#633847
+   Affects Windows only: ntp-4.?.?, up to but not including ntp-4.2.8p9,
+	and ntp-4.3.0 up to, but not including ntp-4.3.94. 
+   CVSS2: HIGH 7.8 (AV:N/AC:L/Au:N/C:N/I:N/A:C)
+   CVSS3: HIGH 7.5 CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
+   Summary: 
+	If a vulnerable instance of ntpd on Windows receives a crafted
+	malicious packet that is "too big", ntpd will stop working. 
+   Mitigation:
+        Implement BCP-38.
+        Upgrade to 4.2.8p9, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page
+        Properly monitor your ntpd instances, and auto-restart ntpd
+	    (without -g) if it stops running. 
+   Credit: This weakness was discovered by Robert Pajak of ABB.
+
+* 0rigin (zero origin) issues
+   Date Resolved: 21 November 2016; Dev (4.3.94) 21 November 2016
+   References: Sec 3102 / CVE-2016-7431 / VU#633847
+   Affects: ntp-4.2.8p8, and ntp-4.3.93.
+   CVSS2: MED 5.0 (AV:N/AC:L/Au:N/C:N/I:P/A:N)
+   CVSS3: MED 5.3 CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N
+   Summary: 
+	Zero Origin timestamp problems were fixed by Bug 2945 in
+	ntp-4.2.8p6. However, subsequent timestamp validation checks
+	introduced a regression in the handling of some Zero origin
+	timestamp checks.
+   Mitigation:
+        Implement BCP-38.
+        Upgrade to 4.2.8p9, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page
+        Properly monitor your ntpd instances, and auto-restart ntpd
+	    (without -g) if it stops running. 
+   Credit: This weakness was discovered by Sharon Goldberg and Aanchal
+	Malhotra of Boston University.
+
+* read_mru_list() does inadequate incoming packet checks
+   Date Resolved: 21 November 2016; Dev (4.3.94) 21 November 2016
+   References: Sec 3082 / CVE-2016-7434 / VU#633847
+   Affects: ntp-4.2.7p22, up to but not including ntp-4.2.8p9, and
+	ntp-4.3.0 up to, but not including ntp-4.3.94.
+   CVSS2: LOW 3.8 (AV:L/AC:H/Au:S/C:N/I:N/A:C)
+   CVSS3: LOW 3.8 CVSS:3.0/AV:P/AC:H/PR:H/UI:R/S:U/C:N/I:N/A:H
+   Summary: 
+	If ntpd is configured to allow mrulist query requests from a
+	server that sends a crafted malicious packet, ntpd will crash
+	on receipt of that crafted malicious mrulist query packet.
+   Mitigation:
+	Only allow mrulist query packets from trusted hosts.
+        Implement BCP-38.
+        Upgrade to 4.2.8p9, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page
+        Properly monitor your ntpd instances, and auto-restart ntpd
+	    (without -g) if it stops running. 
+   Credit: This weakness was discovered by Magnus Stubman.
+
+* Attack on interface selection
+   Date Resolved: 21 November 2016; Dev (4.3.94) 21 November 2016
+   References: Sec 3072 / CVE-2016-7429 / VU#633847
+   Affects: ntp-4.2.7p385, up to but not including ntp-4.2.8p9, and
+	ntp-4.3.0 up to, but not including ntp-4.3.94
+   CVSS2: LOW 1.0 (AV:L/AC:H/Au:S/C:N/I:N/A:P)
+   CVSS3: LOW 1.6 CVSS:3.0/AV:P/AC:H/PR:H/UI:R/S:U/C:N/I:N/A:L
+   Summary: 
+	When ntpd receives a server response on a socket that corresponds
+	to a different interface than was used for the request, the peer
+	structure is updated to use the interface for new requests. If
+	ntpd is running on a host with multiple interfaces in separate
+	networks and the operating system doesn't check source address in
+	received packets (e.g. rp_filter on Linux is set to 0), an
+	attacker that knows the address of the source can send a packet
+	with spoofed source address which will cause ntpd to select wrong
+	interface for the source and prevent it from sending new requests
+	until the list of interfaces is refreshed, which happens on
+	routing changes or every 5 minutes by default. If the attack is
+	repeated often enough (once per second), ntpd will not be able to
+	synchronize with the source.
+   Mitigation:
+        Implement BCP-38.
+        Upgrade to 4.2.8p9, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page
+	If you are going to configure your OS to disable source address
+	    checks, also configure your firewall configuration to control
+	    what interfaces can receive packets from what networks.
+        Properly monitor your ntpd instances, and auto-restart ntpd
+	    (without -g) if it stops running. 
+   Credit: This weakness was discovered by Miroslav Lichvar of Red Hat.
+
+* Client rate limiting and server responses
+   Date Resolved: 21 November 2016; Dev (4.3.94) 21 November 2016
+   References: Sec 3071 / CVE-2016-7426 / VU#633847
+   Affects: ntp-4.2.5p203, up to but not including ntp-4.2.8p9, and
+	ntp-4.3.0 up to, but not including ntp-4.3.94
+   CVSS2: LOW 1.0 (AV:L/AC:H/Au:S/C:N/I:N/A:P)
+   CVSS3: LOW 1.6 CVSS:3.0/AV:P/AC:H/PR:H/UI:R/S:U/C:N/I:N/A:L
+   Summary: 
+	When ntpd is configured with rate limiting for all associations
+	(restrict default limited in ntp.conf), the limits are applied
+	also to responses received from its configured sources. An
+	attacker who knows the sources (e.g., from an IPv4 refid in
+	server response) and knows the system is (mis)configured in this
+	way can periodically send packets with spoofed source address to
+	keep the rate limiting activated and prevent ntpd from accepting
+	valid responses from its sources. 
+
+	While this blanket rate limiting can be useful to prevent
+	brute-force attacks on the origin timestamp, it allows this DoS
+	attack. Similarly, it allows the attacker to prevent mobilization
+	of ephemeral associations.  
+   Mitigation:
+        Implement BCP-38.
+        Upgrade to 4.2.8p9, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page
+        Properly monitor your ntpd instances, and auto-restart ntpd
+	    (without -g) if it stops running. 
+   Credit: This weakness was discovered by Miroslav Lichvar of Red Hat.
+
+* Fix for bug 2085 broke initial sync calculations 
+   Date Resolved: 21 November 2016; Dev (4.3.94) 21 November 2016
+   References: Sec 3067 / CVE-2016-7433 / VU#633847
+   Affects: ntp-4.2.7p385, up to but not including ntp-4.2.8p9, and
+	ntp-4.3.0 up to, but not including ntp-4.3.94. But the
+	root-distance calculation in general is incorrect in all versions
+	of ntp-4 until this release. 
+   CVSS2: LOW 1.2 (AV:L/AC:H/Au:N/C:N/I:N/A:P)
+   CVSS3: LOW 1.6 CVSS:3.0/AV:P/AC:H/PR:H/UI:N/S:U/C:N/I:N/A:L
+   Summary: 
+	Bug 2085 described a condition where the root delay was included
+	twice, causing the jitter value to be higher than expected. Due
+	to a misinterpretation of a small-print variable in The Book, the
+	fix for this problem was incorrect, resulting in a root distance
+	that did not include the peer dispersion. The calculations and
+	formulae have been reviewed and reconciled, and the code has been
+	updated accordingly. 
+   Mitigation:
+        Upgrade to 4.2.8p9, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page
+        Properly monitor your ntpd instances, and auto-restart ntpd
+	    (without -g) if it stops running. 
+   Credit: This weakness was discovered independently by Brian Utterback of
+	Oracle, and Sharon Goldberg and Aanchal Malhotra of Boston University. 
+
+Other fixes:
+
+* [Bug 3142] bug in netmask prefix length detection <perlinger@ntp.org>
+* [Bug 3138] gpsdjson refclock should honor fudgetime1. stenn@ntp.org
+* [Bug 3129] Unknown hosts can put resolver thread into a hard loop
+  - moved retry decision where it belongs. <perlinger@ntp.org>
+* [Bug 3125] NTPD doesn't fully start when ntp.conf entries are out of order
+  using the loopback-ppsapi-provider.dll <perlinger@ntp.org>
+* [Bug 3116] unit tests for NTP time stamp expansion. <perlinger@ntp.org>
+* [Bug 3100] ntpq can't retrieve daemon_version <perlinger@ntp.org>
+  - fixed extended sysvar lookup (bug introduced with bug 3008 fix)
+* [Bug 3095] Compatibility with openssl 1.1 <perlinger@ntp.org>
+  - applied patches by Kurt Roeckx <kurt@roeckx.be> to source
+  - added shim layer for SSL API calls with issues (both directions)
+* [Bug 3089] Serial Parser does not work anymore for hopfser like device
+  - simplified / refactored hex-decoding in driver. <perlinger@ntp.org>
+* [Bug 3084] update-leap mis-parses the leapfile name.  HStenn.
+* [Bug 3068] Linker warnings when building on Solaris. perlinger@ntp.org
+  - applied patch thanks to Andrew Stormont <andyjstormont@gmail.com>
+* [Bug 3067] Root distance calculation needs improvement.  HStenn
+* [Bug 3066] NMEA clock ignores pps. perlinger@ntp.org
+  - PPS-HACK works again.
+* [Bug 3059] Potential buffer overrun from oversized hash <perlinger@ntp.org>
+  - applied patch by Brian Utterback <brian.utterback@oracle.com>
+* [Bug 3053] ntp_loopfilter.c frequency calc precedence error.  Sarah White.
+* [Bug 3050] Fix for bug #2960 causes [...] spurious error message.
+  <perlinger@ntp.org>
+  - patches by Reinhard Max <max@suse.com> and Havard Eidnes <he@uninett.no>
+* [Bug 3047] Fix refclock_jjy C-DEX JST2000. abe@ntp.org
+  - Patch provided by Kuramatsu.
+* [Bug 3021] unity_fixture.c needs pragma weak <perlinger@ntp.org>
+  - removed unnecessary & harmful decls of 'setUp()' & 'tearDown()'
+* [Bug 3019] Windows: ERROR_HOST_UNREACHABLE block packet processing. DMayer
+* [Bug 2998] sntp/tests/packetProcessing.c broken without openssl. JPerlinger
+* [Bug 2961] sntp/tests/packetProcessing.c assumes AUTOKEY.  HStenn.
+* [Bug 2959] refclock_jupiter: gps week correction <perlinger@ntp.org>
+  - fixed GPS week expansion to work based on build date. Special thanks
+    to Craig Leres for initial patch and testing.
+* [Bug 2951] ntpd tests fail: multiple definition of `send_via_ntp_signd'
+  - fixed Makefile.am <perlinger@ntp.org>
+* [Bug 2689] ATOM driver processes last PPS pulse at startup,
+             even if it is very old <perlinger@ntp.org>
+  - make sure PPS source is alive before processing samples
+  - improve stability close to the 500ms phase jump (phase gate)
+* Fix typos in include/ntp.h.
+* Shim X509_get_signature_nid() if needed
+* git author attribution cleanup
+* bk ignore file cleanup
+* remove locks in Windows IO, use rpc-like thread synchronisation instead
+
+---
+NTP 4.2.8p8 (Harlan Stenn <stenn@ntp.org>, 2016/06/02) 
+
+Focus: Security, Bug fixes, enhancements.
+
+Severity: HIGH
+
+In addition to bug fixes and enhancements, this release fixes the
+following 1 high- and 4 low-severity vulnerabilities:
+
+* CRYPTO_NAK crash
+   Date Resolved: 02 June 2016; Dev (4.3.93) 02 June 2016
+   References: Sec 3046 / CVE-2016-4957 / VU#321640
+   Affects: ntp-4.2.8p7, and ntp-4.3.92.
+   CVSS2: HIGH 7.8 (AV:N/AC:L/Au:N/C:N/I:N/A:C)
+   CVSS3: HIGH 7.5 CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
+   Summary: The fix for Sec 3007 in ntp-4.2.8p7 contained a bug that
+	could cause ntpd to crash.
+   Mitigation:
+        Implement BCP-38.
+        Upgrade to 4.2.8p8, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page
+        If you cannot upgrade from 4.2.8p7, the only other alternatives
+	    are to patch your code or filter CRYPTO_NAK packets.
+        Properly monitor your ntpd instances, and auto-restart ntpd
+	    (without -g) if it stops running. 
+   Credit: This weakness was discovered by Nicolas Edet of Cisco. 
+
+* Bad authentication demobilizes ephemeral associations
+   Date Resolved: 02 June 2016; Dev (4.3.93) 02 June 2016
+   References: Sec 3045 / CVE-2016-4953 / VU#321640
+   Affects: ntp-4, up to but not including ntp-4.2.8p8, and
+	ntp-4.3.0 up to, but not including ntp-4.3.93.
+   CVSS2: LOW 2.6 (AV:N/AC:H/Au:N/C:N/I:N/A:P)
+   CVSS3: LOW 3.7 CVSS:3.0/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:L
+   Summary: An attacker who knows the origin timestamp and can send a
+	spoofed packet containing a CRYPTO-NAK to an ephemeral peer
+	target before any other response is sent can demobilize that
+	association.
+   Mitigation:
+	Implement BCP-38.
+	Upgrade to 4.2.8p8, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page
+	Properly monitor your ntpd instances. 
+	Credit: This weakness was discovered by Miroslav Lichvar of Red Hat. 
+
+* Processing spoofed server packets
+   Date Resolved: 02 June 2016; Dev (4.3.93) 02 June 2016
+   References: Sec 3044 / CVE-2016-4954 / VU#321640
+   Affects: ntp-4, up to but not including ntp-4.2.8p8, and
+	ntp-4.3.0 up to, but not including ntp-4.3.93.
+   CVSS2: LOW 2.6 (AV:N/AC:H/Au:N/C:N/I:N/A:P)
+   CVSS3: LOW 3.7 CVSS:3.0/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:L
+   Summary: An attacker who is able to spoof packets with correct origin
+	timestamps from enough servers before the expected response
+	packets arrive at the target machine can affect some peer
+	variables and, for example, cause a false leap indication to be set.
+   Mitigation:
+	Implement BCP-38.
+	Upgrade to 4.2.8p8, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page
+	Properly monitor your ntpd instances. 
+   Credit: This weakness was discovered by Jakub Prokes of Red Hat. 
+
+* Autokey association reset
+   Date Resolved: 02 June 2016; Dev (4.3.93) 02 June 2016
+   References: Sec 3043 / CVE-2016-4955 / VU#321640
+   Affects: ntp-4, up to but not including ntp-4.2.8p8, and
+	ntp-4.3.0 up to, but not including ntp-4.3.93.
+   CVSS2: LOW 2.6 (AV:N/AC:H/Au:N/C:N/I:N/A:P)
+   CVSS3: LOW 3.7 CVSS:3.0/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:L
+   Summary: An attacker who is able to spoof a packet with a correct
+	origin timestamp before the expected response packet arrives at
+	the target machine can send a CRYPTO_NAK or a bad MAC and cause
+	the association's peer variables to be cleared. If this can be
+	done often enough, it will prevent that association from working.
+   Mitigation:
+	Implement BCP-38.
+	Upgrade to 4.2.8p8, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page
+	Properly monitor your ntpd instances. 
+   Credit: This weakness was discovered by Miroslav Lichvar of Red Hat. 
+ 
+* Broadcast interleave
+   Date Resolved: 02 June 2016; Dev (4.3.93) 02 June 2016
+   References: Sec 3042 / CVE-2016-4956 / VU#321640
+   Affects: ntp-4, up to but not including ntp-4.2.8p8, and
+   	ntp-4.3.0 up to, but not including ntp-4.3.93.
+   CVSS2: LOW 2.6 (AV:N/AC:H/Au:N/C:N/I:N/A:P)
+   CVSS3: LOW 3.7 CVSS:3.0/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:L
+   Summary: The fix for NtpBug2978 does not cover broadcast associations,
+   	so broadcast clients can be triggered to flip into interleave mode.
+   Mitigation:
+	Implement BCP-38.
+	Upgrade to 4.2.8p8, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page
+	Properly monitor your ntpd instances. 
+   Credit: This weakness was discovered by Miroslav Lichvar of Red Hat. 
+
+Other fixes:
+* [Bug 3038] NTP fails to build in VS2015. perlinger@ntp.org
+  - provide build environment
+  - 'wint_t' and 'struct timespec' defined by VS2015
+  - fixed print()/scanf() format issues
+* [Bug 3052] Add a .gitignore file.  Edmund Wong.
+* [Bug 3054] miscopt.html documents the allan intercept in seconds. SWhite.
+* [Bug 3058] fetch_timestamp() mishandles 64-bit alignment. Brian Utterback,
+  JPerlinger, HStenn.
+* Fix typo in ntp-wait and plot_summary.  HStenn.
+* Make sure we have an "author" file for git imports.  HStenn.
+* Update the sntp problem tests for MacOS.  HStenn.
+
+---
+NTP 4.2.8p7 (Harlan Stenn <stenn@ntp.org>, 2016/04/26) 
+
+Focus: Security, Bug fixes, enhancements.
+
+Severity: MEDIUM
+
+When building NTP from source, there is a new configure option
+available, --enable-dynamic-interleave.  More information on this below.
+
+Also note that ntp-4.2.8p7 logs more "unexpected events" than previous
+versions of ntp.  These events have almost certainly happened in the
+past, it's just that they were silently counted and not logged.  With
+the increasing awareness around security, we feel it's better to clearly
+log these events to help detect abusive behavior.  This increased
+logging can also help detect other problems, too.
+
+In addition to bug fixes and enhancements, this release fixes the
+following 9 low- and medium-severity vulnerabilities:
+
+* Improve NTP security against buffer comparison timing attacks,
+  AKA: authdecrypt-timing
+   Date Resolved: Stable (4.2.8p7) 26 Apr 2016; Dev (4.3.92) 26 Apr 2016
+   References: Sec 2879 / CVE-2016-1550
+   Affects: All ntp-4 releases up to, but not including 4.2.8p7, and
+	4.3.0 up to, but not including 4.3.92
+   CVSSv2: LOW 2.6 - (AV:L/AC:H/Au:N/C:P/I:P/A:N)
+   CVSSv3: MED 4.0 - CVSS:3.0/AV:L/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:N
+   Summary: Packet authentication tests have been performed using
+	memcmp() or possibly bcmp(), and it is potentially possible
+	for a local or perhaps LAN-based attacker to send a packet with
+	an authentication payload and indirectly observe how much of
+	the digest has matched.
+   Mitigation:
+	Upgrade to 4.2.8p7, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page.
+	Properly monitor your ntpd instances.
+   Credit: This weakness was discovered independently by Loganaden
+   	Velvindron, and Matthew Van Gundy and Stephen Gray of Cisco ASIG.
+
+* Zero origin timestamp bypass: Additional KoD checks.
+   References: Sec 2945 / Sec 2901 / CVE-2015-8138
+   Affects: All ntp-4 releases up to, but not including 4.2.8p7,
+   Summary: Improvements to the fixes incorporated in t 4.2.8p6 and 4.3.92.
+
+* peer associations were broken by the fix for NtpBug2899
+   Date Resolved: Stable (4.2.8p7) 26 Apr 2016; Dev (4.3.92) 26 Apr 2016
+   References: Sec 2952 / CVE-2015-7704
+   Affects: All ntp-4 releases up to, but not including 4.2.8p7, and
+   	4.3.0 up to, but not including 4.3.92
+   CVSSv2: MED 4.3 - (AV:N/AC:M/Au:N/C:N/I:N/A:P)
+   Summary: The fix for NtpBug2952 in ntp-4.2.8p5 to address broken peer
+   	associations did not address all of the issues.
+   Mitigation:
+        Implement BCP-38.
+        Upgrade to 4.2.8p7, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page
+        If you can't upgrade, use "server" associations instead of
+	    "peer" associations.
+        Monitor your ntpd instances. 
+   Credit: This problem was discovered by Michael Tatarinov.
+
+* Validate crypto-NAKs, AKA: CRYPTO-NAK DoS
+   Date Resolved: Stable (4.2.8p7) 26 Apr 2016; Dev (4.3.92) 26 Apr 2016
+   References: Sec 3007 / CVE-2016-1547 / VU#718152
+   Affects: All ntp-4 releases up to, but not including 4.2.8p7, and
+	4.3.0 up to, but not including 4.3.92
+   CVSS2: MED 4.3 - (AV:N/AC:M/Au:N/C:N/I:N/A:P)
+   CVSS3: MED 3.7 - CVSS:3.0/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:L
+   Summary: For ntp-4 versions up to but not including ntp-4.2.8p7, an
+	off-path attacker can cause a preemptable client association to
+	be demobilized by sending a crypto NAK packet to a victim client
+	with a spoofed source address of an existing associated peer.
+	This is true even if authentication is enabled.
+
+	Furthermore, if the attacker keeps sending crypto NAK packets,
+	for example one every second, the victim never has a chance to
+	reestablish the association and synchronize time with that
+	legitimate server.
+
+	For ntp-4.2.8 thru ntp-4.2.8p6 there is less risk because more
+	stringent checks are performed on incoming packets, but there
+	are still ways to exploit this vulnerability in versions before
+	ntp-4.2.8p7.
+   Mitigation:
+	Implement BCP-38.
+	Upgrade to 4.2.8p7, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page
+	Properly monitor your ntpd instances
+   Credit: This weakness was discovered by Stephen Gray and
+   	Matthew Van Gundy of Cisco ASIG.
+
+* ctl_getitem() return value not always checked
+   Date Resolved: Stable (4.2.8p7) 26 Apr 2016; Dev (4.3.92) 26 Apr 2016
+   References: Sec 3008 / CVE-2016-2519
+   Affects: All ntp-4 releases up to, but not including 4.2.8p7, and
+	4.3.0 up to, but not including 4.3.92
+   CVSSv2: MED 4.9 - (AV:N/AC:H/Au:S/C:N/I:N/A:C)
+   CVSSv3: MED 4.2 - CVSS:3.0/AV:N/AC:H/PR:H/UI:R/S:U/C:N/I:N/A:H
+   Summary: ntpq and ntpdc can be used to store and retrieve information
+   	in ntpd. It is possible to store a data value that is larger
+	than the size of the buffer that the ctl_getitem() function of
+	ntpd uses to report the return value. If the length of the
+	requested data value returned by ctl_getitem() is too large,
+	the value NULL is returned instead. There are 2 cases where the
+	return value from ctl_getitem() was not directly checked to make
+	sure it's not NULL, but there are subsequent INSIST() checks
+	that make sure the return value is not NULL. There are no data
+	values ordinarily stored in ntpd that would exceed this buffer
+	length. But if one has permission to store values and one stores
+	a value that is "too large", then ntpd will abort if an attempt
+	is made to read that oversized value.
+    Mitigation:
+        Implement BCP-38.
+        Upgrade to 4.2.8p7, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page
+        Properly monitor your ntpd instances.
+    Credit: This weakness was discovered by Yihan Lian of the Cloud
+    	Security Team, Qihoo 360. 
+
+* Crafted addpeer with hmode > 7 causes array wraparound with MATCH_ASSOC 
+   Date Resolved: Stable (4.2.8p7) 26 Apr 2016; Dev (4.3.92) 26 Apr 2016
+   References: Sec 3009 / CVE-2016-2518 / VU#718152
+   Affects: All ntp-4 releases up to, but not including 4.2.8p7, and
+	4.3.0 up to, but not including 4.3.92
+   CVSS2: LOW 2.1 - (AV:N/AC:H/Au:S/C:N/I:N/A:P)
+   CVSS3: LOW 2.0 - CVSS:3.0/AV:N/AC:H/PR:H/UI:R/S:U/C:N/I:N/A:L
+   Summary: Using a crafted packet to create a peer association with
+   	hmode > 7 causes the MATCH_ASSOC() lookup to make an
+	out-of-bounds reference.
+   Mitigation:
+	Implement BCP-38.
+	Upgrade to 4.2.8p7, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page
+	Properly monitor your ntpd instances
+   Credit: This weakness was discovered by Yihan Lian of the Cloud
+   	Security Team, Qihoo 360.
+
+* remote configuration trustedkey/requestkey/controlkey values are not
+	properly validated
+   Date Resolved: Stable (4.2.8p7) 26 Apr 2016; Dev (4.3.92) 26 Apr 2016
+   References: Sec 3010 / CVE-2016-2517 / VU#718152
+   Affects: All ntp-4 releases up to, but not including 4.2.8p7, and
+	4.3.0 up to, but not including 4.3.92
+   CVSS2: MED 4.9 - (AV:N/AC:H/Au:S/C:N/I:N/A:C)
+   CVSS3: MED 4.2 - CVSS:3.0/AV:N/AC:H/PR:H/UI:R/S:U/C:N/I:N/A:H
+   Summary: If ntpd was expressly configured to allow for remote
+   	configuration, a malicious user who knows the controlkey for
+	ntpq or the requestkey for ntpdc (if mode7 is expressly enabled)
+	can create a session with ntpd and then send a crafted packet to
+	ntpd that will change the value of the trustedkey, controlkey,
+	or requestkey to a value that will prevent any subsequent
+	authentication with ntpd until ntpd is restarted.
+   Mitigation:
+	Implement BCP-38.
+	Upgrade to 4.2.8p7, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page
+	Properly monitor your ntpd instances
+   Credit: This weakness was discovered by Yihan Lian of the Cloud
+   	Security Team, Qihoo 360.
+
+* Duplicate IPs on unconfig directives will cause an assertion botch in ntpd
+   Date Resolved: Stable (4.2.8p7) 26 Apr 2016; Dev (4.3.92) 26 Apr 2016
+   References: Sec 3011 / CVE-2016-2516 / VU#718152
+   Affects: All ntp-4 releases up to, but not including 4.2.8p7, and
+   	4.3.0 up to, but not including 4.3.92
+   CVSS2: MED 6.3 - (AV:N/AC:M/Au:S/C:N/I:N/A:C)
+   CVSS3: MED 4.2 - CVSS:3.0/AV:N/AC:H/PR:H/UI:R/S:U/C:N/I:N/A:H
+   Summary: If ntpd was expressly configured to allow for remote
+   	configuration, a malicious user who knows the controlkey for
+	ntpq or the requestkey for ntpdc (if mode7 is expressly enabled)
+	can create a session with ntpd and if an existing association is
+	unconfigured using the same IP twice on the unconfig directive
+	line, ntpd will abort.
+   Mitigation:
+	Implement BCP-38.
+	Upgrade to 4.2.8p7, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page
+	Properly monitor your ntpd instances
+   Credit: This weakness was discovered by Yihan Lian of the Cloud
+   	Security Team, Qihoo 360.
+
+* Refclock impersonation vulnerability
+   Date Resolved: Stable (4.2.8p7) 26 Apr 2016; Dev (4.3.92) 26 Apr 2016
+   References: Sec 3020 / CVE-2016-1551
+   Affects: On a very limited number of OSes, all NTP releases up to but
+	not including 4.2.8p7, and 4.3.0 up to but not including 4.3.92.
+	By "very limited number of OSes" we mean no general-purpose OSes
+	have yet been identified that have this vulnerability.
+   CVSSv2: LOW 2.6 - (AV:N/AC:H/Au:N/C:N/I:P/A:N)
+   CVSSv3: LOW 3.7 - CVSS:3.0/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:N
+   Summary: While most OSes implement martian packet filtering in their
+   	network stack, at least regarding 127.0.0.0/8, some will allow
+	packets claiming to be from 127.0.0.0/8 that arrive over a
+	physical network. On these OSes, if ntpd is configured to use a
+	reference clock an attacker can inject packets over the network
+	that look like they are coming from that reference clock.
+   Mitigation:
+        Implement martian packet filtering and BCP-38.
+        Configure ntpd to use an adequate number of time sources.
+        Upgrade to 4.2.8p7, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page
+        If you are unable to upgrade and if you are running an OS that
+	    has this vulnerability, implement martian packet filters and
+	    lobby your OS vendor to fix this problem, or run your
+	    refclocks on computers that use OSes that are not vulnerable
+	    to these attacks and have your vulnerable machines get their
+	    time from protected resources.
+        Properly monitor your ntpd instances.
+   Credit: This weakness was discovered by Matt Street and others of
+   	Cisco ASIG. 
+
+The following issues were fixed in earlier releases and contain
+improvements in 4.2.8p7:
+
+* Clients that receive a KoD should validate the origin timestamp field.
+   References: Sec 2901 / CVE-2015-7704, CVE-2015-7705
+   Affects: All ntp-4 releases up to, but not including 4.2.8p7,
+   Summary: Improvements to the fixes incorporated into 4.2.8p4 and 4.3.77.
+
+* Skeleton key: passive server with trusted key can serve time.
+   References: Sec 2936 / CVE-2015-7974
+   Affects: All ntp-4 releases up to, but not including 4.2.8p7,
+   Summary: Improvements to the fixes incorporated in t 4.2.8p6 and 4.3.90.
+
+Two other vulnerabilities have been reported, and the mitigations
+for these are as follows:
+
+* Interleave-pivot
+   Date Resolved: Stable (4.2.8p7) 26 Apr 2016; Dev (4.3.92) 26 Apr 2016
+   References: Sec 2978 / CVE-2016-1548
+   Affects: All ntp-4 releases.
+   CVSSv2: MED 6.4 - (AV:N/AC:L/Au:N/C:N/I:P/A:P)
+   CVSSv3: MED 7.2 - CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:C/C:N/I:L/A:L
+   Summary: It is possible to change the time of an ntpd client or deny
+   	service to an ntpd client by forcing it to change from basic
+	client/server mode to interleaved symmetric mode. An attacker
+	can spoof a packet from a legitimate ntpd server with an origin
+	timestamp that matches the peer->dst timestamp recorded for that
+	server. After making this switch, the client will reject all
+	future legitimate server responses. It is possible to force the
+	victim client to move time after the mode has been changed.
+	ntpq gives no indication that the mode has been switched.
+   Mitigation:
+        Implement BCP-38.
+        Upgrade to 4.2.8p7, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page.  These
+	    versions will not dynamically "flip" into interleave mode
+	    unless configured to do so.
+        Properly monitor your ntpd instances.
+   Credit: This weakness was discovered by Miroslav Lichvar of RedHat
+   	and separately by Jonathan Gardner of Cisco ASIG.
+
+* Sybil vulnerability: ephemeral association attack
+   Date Resolved: Stable (4.2.8p7) 26 Apr 2016; Dev (4.3.92) 26 Apr 2016
+   References: Sec 3012 / CVE-2016-1549
+   Affects: All ntp-4 releases up to, but not including 4.2.8p7, and
+   	4.3.0 up to, but not including 4.3.92
+   CVSSv2: LOW 3.5 - (AV:N/AC:M/Au:S/C:N/I:P/A:N)
+   CVSS3v: MED 5.3 - CVSS:3.0/AV:N/AC:H/PR:L/UI:N/S:U/C:N/I:H/A:N
+   Summary: ntpd can be vulnerable to Sybil attacks. If one is not using
+   	the feature introduced in ntp-4.2.8p6 allowing an optional 4th
+	field in the ntp.keys file to specify which IPs can serve time,
+	a malicious authenticated peer can create arbitrarily-many
+	ephemeral associations in order to win the clock selection of
+	ntpd and modify a victim's clock.
+   Mitigation:
+        Implement BCP-38.
+        Use the 4th field in the ntp.keys file to specify which IPs
+	    can be time servers.
+        Properly monitor your ntpd instances.
+   Credit: This weakness was discovered by Matthew Van Gundy of Cisco ASIG. 
+
+Other fixes:
+
+* [Bug 2831]  Segmentation Fault in DNS lookup during startup. perlinger@ntp.org
+  - fixed yet another race condition in the threaded resolver code.
+* [Bug 2858] bool support.  Use stdbool.h when available.  HStenn.
+* [Bug 2879] Improve NTP security against timing attacks. perlinger@ntp.org
+  - integrated patches by Loganaden Velvidron <logan@ntp.org>
+    with some modifications & unit tests
+* [Bug 2960] async name resolution fixes for chroot() environments.
+  Reinhard Max.
+* [Bug 2994] Systems with HAVE_SIGNALED_IO fail to compile. perlinger@ntp.org
+* [Bug 2995] Fixes to compile on Windows
+* [Bug 2999] out-of-bounds access in 'is_safe_filename()'. perlinger@ntp.org
+* [Bug 3013] Fix for ssl_init.c SHA1 test. perlinger@ntp.org
+  - Patch provided by Ch. Weisgerber
+* [Bug 3015] ntpq: config-from-file: "request contains an unprintable character"
+  - A change related to [Bug 2853] forbids trailing white space in
+    remote config commands. perlinger@ntp.org
+* [Bug 3019] NTPD stops processing packets after ERROR_HOST_UNREACHABLE
+  - report and patch from Aleksandr Kostikov.
+  - Overhaul of Windows IO completion port handling. perlinger@ntp.org
+* [Bug 3022] authkeys.c should be refactored. perlinger@ntp.org
+  - fixed memory leak in access list (auth[read]keys.c)
+  - refactored handling of key access lists (auth[read]keys.c)
+  - reduced number of error branches (authreadkeys.c)
+* [Bug 3023] ntpdate cannot correct dates in the future. perlinger@ntp.org
+* [Bug 3030] ntpq needs a general way to specify refid output format.  HStenn.
+* [Bug 3031] ntp broadcastclient unable to synchronize to an server
+             when the time of server changed. perlinger@ntp.org
+  - Check the initial delay calculation and reject/unpeer the broadcast
+    server if the delay exceeds 50ms. Retry again after the next
+    broadcast packet.
+* [Bug 3036] autokey trips an INSIST in authistrustedip().  Harlan Stenn.
+* Document ntp.key's optional IP list in authenetic.html.  Harlan Stenn.
+* Update html/xleave.html documentation.  Harlan Stenn.
+* Update ntp.conf documentation.  Harlan Stenn.
+* Fix some Credit: attributions in the NEWS file.  Harlan Stenn.
+* Fix typo in html/monopt.html.  Harlan Stenn.
+* Add README.pullrequests.  Harlan Stenn.
+* Cleanup to include/ntp.h.  Harlan Stenn.
+
+New option to 'configure':
+
+While looking in to the issues around Bug 2978, the "interleave pivot"
+issue, it became clear that there are some intricate and unresolved
+issues with interleave operations.  We also realized that the interleave
+protocol was never added to the NTPv4 Standard, and it should have been.
+
+Interleave mode was first released in July of 2008, and can be engaged
+in two ways.  Any 'peer' and 'broadcast' lines in the ntp.conf file may
+contain the 'xleave' option, which will expressly enable interlave mode
+for that association.  Additionally, if a time packet arrives and is
+found inconsistent with normal protocol behavior but has certain
+characteristics that are compatible with interleave mode, NTP will
+dynamically switch to interleave mode.  With sufficient knowledge, an
+attacker can send a crafted forged packet to an NTP instance that
+triggers only one side to enter interleaved mode.
+
+To prevent this attack until we can thoroughly document, describe,
+fix, and test the dynamic interleave mode, we've added a new
+'configure' option to the build process:
+
+ --enable-dynamic-interleave
+
+This option controls whether or not NTP will, if conditions are right,
+engage dynamic interleave mode.  Dynamic interleave mode is disabled by
+default in ntp-4.2.8p7.
+
+---
+NTP 4.2.8p6 (Harlan Stenn <stenn@ntp.org>, 2016/01/20) 
+
+Focus: Security, Bug fixes, enhancements.
+
+Severity: MEDIUM
+
+In addition to bug fixes and enhancements, this release fixes the
+following 1 low- and 8 medium-severity vulnerabilities:
+
+* Potential Infinite Loop in 'ntpq'
+   Date Resolved: Stable (4.2.8p6) 19 Jan 2016; Dev (4.3.90) 19 Jan 2016
+   References: Sec 2548 / CVE-2015-8158
+   Affects: All ntp-4 releases up to, but not including 4.2.8p6, and
+	4.3.0 up to, but not including 4.3.90
+   CVSS2: (AV:N/AC:M/Au:N/C:N/I:N/A:P) Base Score: 4.3 - MEDIUM
+   CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N Base Score: 5.3 - MEDIUM
+   Summary: 'ntpq' processes incoming packets in a loop in 'getresponse()'.
+	The loop's only stopping conditions are receiving a complete and
+	correct response or hitting a small number of error conditions.
+	If the packet contains incorrect values that don't trigger one of
+	the error conditions, the loop continues to receive new packets.
+	Note well, this is an attack against an instance of 'ntpq', not
+	'ntpd', and this attack requires the attacker to do one of the
+	following:
+	* Own a malicious NTP server that the client trusts
+	* Prevent a legitimate NTP server from sending packets to
+	    the 'ntpq' client
+	* MITM the 'ntpq' communications between the 'ntpq' client
+	    and the NTP server
+   Mitigation:
+	Upgrade to 4.2.8p6, or later, from the NTP Project Download Page
+	or the NTP Public Services Project Download Page
+   Credit: This weakness was discovered by Jonathan Gardner of Cisco ASIG.
+
+* 0rigin: Zero Origin Timestamp Bypass
+   Date Resolved: Stable (4.2.8p6) 19 Jan 2016; Dev (4.3.90) 19 Jan 2016
+   References: Sec 2945 / CVE-2015-8138
+   Affects: All ntp-4 releases up to, but not including 4.2.8p6, and
+	4.3.0 up to, but not including 4.3.90
+   CVSS2: (AV:N/AC:L/Au:N/C:N/I:P/A:N) Base Score: 5.0 - MEDIUM
+   CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N Base Score: 5.3 - MEDIUM
+	(3.7 - LOW if you score AC:L)
+   Summary: To distinguish legitimate peer responses from forgeries, a
+	client attempts to verify a response packet by ensuring that the
+	origin timestamp in the packet matches the origin timestamp it
+	transmitted in its last request.  A logic error exists that
+	allows packets with an origin timestamp of zero to bypass this
+	check whenever there is not an outstanding request to the server.
+   Mitigation:
+	Configure 'ntpd' to get time from multiple sources.
+	Upgrade to 4.2.8p6, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page.
+	Monitor your 'ntpd' instances.
+   Credit: This weakness was discovered by Matthey Van Gundy and
+	Jonathan Gardner of Cisco ASIG.
+
+* Stack exhaustion in recursive traversal of restriction list
+   Date Resolved: Stable (4.2.8p6) 19 Jan 2016
+   References: Sec 2940 / CVE-2015-7978
+   Affects: All ntp-4 releases up to, but not including 4.2.8p6, and
+	4.3.0 up to, but not including 4.3.90
+   CVSS: (AV:N/AC:M/Au:N/C:N/I:N/A:P) Base Score: 4.3 - MEDIUM
+   Summary: An unauthenticated 'ntpdc reslist' command can cause a
+   	segmentation fault in ntpd by exhausting the call stack.
+   Mitigation:
+	Implement BCP-38.
+	Upgrade to 4.2.8p6, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page.
+	If you are unable to upgrade:
+            In ntp-4.2.8, mode 7 is disabled by default. Don't enable it.
+	    If you must enable mode 7:
+		configure the use of a 'requestkey' to control who can
+		    issue mode 7 requests.
+		configure 'restrict noquery' to further limit mode 7
+		    requests to trusted sources.
+		Monitor your ntpd instances.
+   Credit: This weakness was discovered by Stephen Gray at Cisco ASIG.
+
+* Off-path Denial of Service (!DoS) attack on authenticated broadcast mode
+   Date Resolved: Stable (4.2.8p6) 19 Jan 2016; Dev (4.3.90) 19 Jan 2016
+   References: Sec 2942 / CVE-2015-7979
+   Affects: All ntp-4 releases up to, but not including 4.2.8p6, and
+	4.3.0 up to, but not including 4.3.90
+   CVSS: (AV:N/AC:M/Au:N/C:N/I:P/A:P) Base Score: 5.8
+   Summary: An off-path attacker can send broadcast packets with bad
+	authentication (wrong key, mismatched key, incorrect MAC, etc)
+	to broadcast clients. It is observed that the broadcast client
+	tears down the association with the broadcast server upon
+	receiving just one bad packet.
+   Mitigation:
+	Implement BCP-38.
+	Upgrade to 4.2.8p6, or later, from the NTP Project Download Page
+	or the NTP Public Services Project Download Page.
+	Monitor your 'ntpd' instances.
+	If this sort of attack is an active problem for you, you have
+	    deeper problems to investigate.  In this case also consider
+	    having smaller NTP broadcast domains.
+   Credit: This weakness was discovered by Aanchal Malhotra of Boston
+   	University.
+
+* reslist NULL pointer dereference
+   Date Resolved: Stable (4.2.8p6) 19 Jan 2016; Dev (4.3.90) 19 Jan 2016
+   References: Sec 2939 / CVE-2015-7977
+   Affects: All ntp-4 releases up to, but not including 4.2.8p6, and
+	4.3.0 up to, but not including 4.3.90
+   CVSS: (AV:N/AC:M/Au:N/C:N/I:N/A:P) Base Score: 4.3 - MEDIUM
+   Summary: An unauthenticated 'ntpdc reslist' command can cause a
+	segmentation fault in ntpd by causing a NULL pointer dereference.
+   Mitigation:
+	Implement BCP-38.
+	Upgrade to 4.2.8p6, or later, from NTP Project Download Page or
+	the NTP Public Services Project Download Page.
+	If you are unable to upgrade:
+	    mode 7 is disabled by default.  Don't enable it.
+	    If you must enable mode 7:
+		configure the use of a 'requestkey' to control who can
+		    issue mode 7 requests.
+		configure 'restrict noquery' to further limit mode 7
+		    requests to trusted sources. 
+	Monitor your ntpd instances.
+   Credit: This weakness was discovered by Stephen Gray of Cisco ASIG.
+
+* 'ntpq saveconfig' command allows dangerous characters in filenames.
+   Date Resolved: Stable (4.2.8p6) 19 Jan 2016; Dev (4.3.90) 19 Jan 2016
+   References: Sec 2938 / CVE-2015-7976
+   Affects: All ntp-4 releases up to, but not including 4.2.8p6, and
+	4.3.0 up to, but not including 4.3.90
+   CVSS: (AV:N/AC:L/Au:S/C:N/I:P/A:N) Base Score: 4.0 - MEDIUM
+   Summary: The ntpq saveconfig command does not do adequate filtering
+   	of special characters from the supplied filename.
+	Note well: The ability to use the saveconfig command is controlled
+	by the 'restrict nomodify' directive, and the recommended default
+	configuration is to disable this capability.  If the ability to
+	execute a 'saveconfig' is required, it can easily (and should) be
+	limited and restricted to a known small number of IP addresses.
+   Mitigation:
+	Implement BCP-38.
+	use 'restrict default nomodify' in your 'ntp.conf' file.
+	Upgrade to 4.2.8p6, or later, from the NTP Project Download Page.
+	If you are unable to upgrade:
+	    build NTP with 'configure --disable-saveconfig' if you will
+	    	never need this capability, or
+	    use 'restrict default nomodify' in your 'ntp.conf' file.  Be
+		careful about what IPs have the ability to send 'modify'
+		requests to 'ntpd'.
+	Monitor your ntpd instances.
+	'saveconfig' requests are logged to syslog - monitor your syslog files.
+   Credit: This weakness was discovered by Jonathan Gardner of Cisco ASIG.
+
+* nextvar() missing length check in ntpq
+   Date Resolved: Stable (4.2.8p6) 19 Jan 2016; Dev (4.3.90) 19 Jan 2016
+   References: Sec 2937 / CVE-2015-7975
+   Affects: All ntp-4 releases up to, but not including 4.2.8p6, and
+	4.3.0 up to, but not including 4.3.90
+   CVSS: (AV:L/AC:H/Au:N/C:N/I:N/A:P) Base Score: 1.2 - LOW
+	If you score A:C, this becomes 4.0.
+   CVSSv3: (CVSS:3.0/AV:L/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:L) Base Score 2.9, LOW
+   Summary: ntpq may call nextvar() which executes a memcpy() into the
+	name buffer without a proper length check against its maximum
+	length of 256 bytes. Note well that we're taking about ntpq here.
+	The usual worst-case effect of this vulnerability is that the
+	specific instance of ntpq will crash and the person or process
+	that did this will have stopped themselves.
+   Mitigation:
+	Upgrade to 4.2.8p6, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page.
+	If you are unable to upgrade:
+	    If you have scripts that feed input to ntpq make sure there are
+		some sanity checks on the input received from the "outside".
+	    This is potentially more dangerous if ntpq is run as root. 
+   Credit: This weakness was discovered by Jonathan Gardner at Cisco ASIG.
+
+* Skeleton Key: Any trusted key system can serve time
+   Date Resolved: Stable (4.2.8p6) 19 Jan 2016; Dev (4.3.90) 19 Jan 2016
+   References: Sec 2936 / CVE-2015-7974
+   Affects: All ntp-4 releases up to, but not including 4.2.8p6, and
+	4.3.0 up to, but not including 4.3.90
+   CVSS: (AV:N/AC:H/Au:S/C:N/I:C/A:N) Base Score: 4.9
+   Summary: Symmetric key encryption uses a shared trusted key. The
+	reported title for this issue was "Missing key check allows
+	impersonation between authenticated peers" and the report claimed
+	"A key specified only for one server should only work to
+	authenticate that server, other trusted keys should be refused."
+	Except there has never been any correlation between this trusted
+	key and server v. clients machines and there has never been any
+	way to specify a key only for one server. We have treated this as
+	an enhancement request, and ntp-4.2.8p6 includes other checks and
+	tests to strengthen clients against attacks coming from broadcast
+	servers.
+   Mitigation:
+	Implement BCP-38.
+	If this scenario represents a real or a potential issue for you,
+	    upgrade to 4.2.8p6, or later, from the NTP Project Download
+	    Page or the NTP Public Services Project Download Page, and
+	    use the new field in the ntp.keys file that specifies the list
+	    of IPs that are allowed to serve time. Note that this alone
+	    will not protect against time packets with forged source IP
+	    addresses, however other changes in ntp-4.2.8p6 provide
+	    significant mitigation against broadcast attacks. MITM attacks
+	    are a different story.
+	If you are unable to upgrade:
+	    Don't use broadcast mode if you cannot monitor your client
+	    	servers.
+	    If you choose to use symmetric keys to authenticate time
+	    	packets in a hostile environment where ephemeral time
+		servers can be created, or if it is expected that malicious
+		time servers will participate in an NTP broadcast domain,
+		limit the number of participating systems that participate
+		in the shared-key group. 
+	Monitor your ntpd instances. 
+   Credit: This weakness was discovered by Matt Street of Cisco ASIG. 
+
+* Deja Vu: Replay attack on authenticated broadcast mode
+   Date Resolved: Stable (4.2.8p6) 19 Jan 2016; Dev (4.3.90) 19 Jan 2016
+   References: Sec 2935 / CVE-2015-7973
+   Affects: All ntp-4 releases up to, but not including 4.2.8p6, and
+   	4.3.0 up to, but not including 4.3.90
+   CVSS: (AV:A/AC:M/Au:N/C:N/I:P/A:P) Base Score: 4.3 - MEDIUM
+   Summary: If an NTP network is configured for broadcast operations then
+   	either a man-in-the-middle attacker or a malicious participant
+	that has the same trusted keys as the victim can replay time packets.
+   Mitigation:
+	Implement BCP-38.
+	Upgrade to 4.2.8p6, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page.
+	If you are unable to upgrade:
+	    Don't use broadcast mode if you cannot monitor your client servers.
+	Monitor your ntpd instances.
+   Credit: This weakness was discovered by Aanchal Malhotra of Boston
+	University.
+
+Other fixes:
+
+* [Bug 2772] adj_systime overflows tv_usec. perlinger@ntp.org
+* [Bug 2814] msyslog deadlock when signaled. perlinger@ntp.org
+  - applied patch by shenpeng11@huawei.com with minor adjustments
+* [Bug 2882] Look at ntp_request.c:list_peers_sum(). perlinger@ntp.org
+* [Bug 2891] Deadlock in deferred DNS lookup framework. perlinger@ntp.org
+* [Bug 2892] Several test cases assume IPv6 capabilities even when
+             IPv6 is disabled in the build. perlinger@ntp.org
+  - Found this already fixed, but validation led to cleanup actions.
+* [Bug 2905] DNS lookups broken. perlinger@ntp.org
+  - added limits to stack consumption, fixed some return code handling
+* [Bug 2971] ntpq bails on ^C: select fails: Interrupted system call
+  - changed stacked/nested handling of CTRL-C. perlinger@ntp.org
+  - make CTRL-C work for retrieval and printing od MRU list. perlinger@ntp.org
+* [Bug 2980] reduce number of warnings. perlinger@ntp.org
+  - integrated several patches from Havard Eidnes (he@uninett.no)
+* [Bug 2985] bogus calculation in authkeys.c perlinger@ntp.org
+  - implement 'auth_log2()' using integer bithack instead of float calculation
+* Make leapsec_query debug messages less verbose.  Harlan Stenn.
+
+---
+NTP 4.2.8p5 (Harlan Stenn <stenn@ntp.org>, 2016/01/07) 
+
+Focus: Security, Bug fixes, enhancements.
+
+Severity: MEDIUM
+
+In addition to bug fixes and enhancements, this release fixes the
+following medium-severity vulnerability:
+
+* Small-step/big-step.  Close the panic gate earlier.
+    References: Sec 2956, CVE-2015-5300
+    Affects: All ntp-4 releases up to, but not including 4.2.8p5, and
+	4.3.0 up to, but not including 4.3.78
+    CVSS3: (AV:N/AC:H/PR:H/UI:R/S:C/C:L/I:N/A:L) Base Score: 4.0, MEDIUM
+    Summary: If ntpd is always started with the -g option, which is
+	common and against long-standing recommendation, and if at the
+	moment ntpd is restarted an attacker can immediately respond to
+	enough requests from enough sources trusted by the target, which
+	is difficult and not common, there is a window of opportunity
+	where the attacker can cause ntpd to set the time to an
+	arbitrary value. Similarly, if an attacker is able to respond
+	to enough requests from enough sources trusted by the target,
+	the attacker can cause ntpd to abort and restart, at which
+	point it can tell the target to set the time to an arbitrary
+	value if and only if ntpd was re-started against long-standing
+	recommendation with the -g flag, or if ntpd was not given the
+	-g flag, the attacker can move the target system's time by at
+	most 900 seconds' time per attack.
+    Mitigation:
+	Configure ntpd to get time from multiple sources.
+	Upgrade to 4.2.8p5, or later, from the NTP Project Download
+	    Page or the NTP Public Services Project Download Page
+	As we've long documented, only use the -g option to ntpd in
+	    cold-start situations.
+	Monitor your ntpd instances. 
+    Credit: This weakness was discovered by Aanchal Malhotra,
+	Isaac E. Cohen, and Sharon Goldberg at Boston University. 
+
+    NOTE WELL: The -g flag disables the limit check on the panic_gate
+	in ntpd, which is 900 seconds by default. The bug identified by
+	the researchers at Boston University is that the panic_gate
+	check was only re-enabled after the first change to the system
+	clock that was greater than 128 milliseconds, by default. The
+	correct behavior is that the panic_gate check should be
+	re-enabled after any initial time correction.
+
+	If an attacker is able to inject consistent but erroneous time
+	responses to your systems via the network or "over the air",
+	perhaps by spoofing radio, cellphone, or navigation satellite
+	transmissions, they are in a great position to affect your
+	system's clock. There comes a point where your very best
+	defenses include:
+
+	    Configure ntpd to get time from multiple sources.
+	    Monitor your ntpd instances. 
+
+Other fixes:
+
+* Coverity submission process updated from Coverity 5 to Coverity 7.
+  The NTP codebase has been undergoing regular Coverity scans on an
+  ongoing basis since 2006.  As part of our recent upgrade from
+  Coverity 5 to Coverity 7, Coverity identified 16 nits in some of
+  the newly-written Unity test programs.  These were fixed.
+* [Bug 2829] Clean up pipe_fds in ntpd.c  perlinger@ntp.org
+* [Bug 2887] stratum -1 config results as showing value 99
+  - fudge stratum should only accept values [0..16]. perlinger@ntp.org
+* [Bug 2932] Update leapsecond file info in miscopt.html.  CWoodbury, HStenn.
+* [Bug 2934] tests/ntpd/t-ntp_scanner.c has a magic constant wired in.  HMurray
+* [Bug 2944] errno is not preserved properly in ntpdate after sendto call.
+  - applied patch by Christos Zoulas.  perlinger@ntp.org
+* [Bug 2952] Peer associations broken by fix for Bug 2901/CVE-2015-7704.
+* [Bug 2954] Version 4.2.8p4 crashes on startup on some OSes.
+  - fixed data race conditions in threaded DNS worker. perlinger@ntp.org
+  - limit threading warm-up to linux; FreeBSD bombs on it. perlinger@ntp.org
+* [Bug 2957] 'unsigned int' vs 'size_t' format clash. perlinger@ntp.org
+  - accept key file only if there are no parsing errors
+  - fixed size_t/u_int format clash
+  - fixed wrong use of 'strlcpy'
+* [Bug 2958] ntpq: fatal error messages need a final newline. Craig Leres.
+* [Bug 2962] truncation of size_t/ptrdiff_t on 64bit targets. perlinger@ntp.org
+  - fixed several other warnings (cast-alignment, missing const, missing prototypes)
+  - promote use of 'size_t' for values that express a size
+  - use ptr-to-const for read-only arguments
+  - make sure SOCKET values are not truncated (win32-specific)
+  - format string fixes
+* [Bug 2965] Local clock didn't work since 4.2.8p4.  Martin Burnicki.
+* [Bug 2967] ntpdate command suffers an assertion failure
+  - fixed ntp_rfc2553.c to return proper address length. perlinger@ntp.org
+* [Bug 2969]  Seg fault from ntpq/mrulist when looking at server with
+              lots of clients. perlinger@ntp.org
+* [Bug 2971] ntpq bails on ^C: select fails: Interrupted system call
+  - changed stacked/nested handling of CTRL-C. perlinger@ntp.org
+* Unity cleanup for FreeBSD-6.4.  Harlan Stenn.
+* Unity test cleanup.  Harlan Stenn.
+* Libevent autoconf pthread fixes for FreeBSD-10.  Harlan Stenn.
+* Header cleanup in tests/sandbox/uglydate.c.  Harlan Stenn.
+* Header cleanup in tests/libntp/sfptostr.c.  Harlan Stenn.
+* Quiet a warning from clang.  Harlan Stenn.
+
+---
+NTP 4.2.8p4 (Harlan Stenn <stenn@ntp.org>, 2015/10/21) 
+
+Focus: Security, Bug fixes, enhancements.
+
+Severity: MEDIUM
+
+In addition to bug fixes and enhancements, this release fixes the
+following 13 low- and medium-severity vulnerabilities:
+
+* Incomplete vallen (value length) checks in ntp_crypto.c, leading
+  to potential crashes or potential code injection/information leakage.
+
+    References: Sec 2899, Sec 2671, CVE-2015-7691, CVE-2015-7692, CVE-2015-7702
+    Affects: All ntp-4 releases up to, but not including 4.2.8p4,
+    	and 4.3.0 up to, but not including 4.3.77
+    CVSS: (AV:N/AC:H/Au:M/C:N/I:N/A:C) Base Score: 4.6
+    Summary: The fix for CVE-2014-9750 was incomplete in that there were
+    	certain code paths where a packet with particular autokey operations
+	that contained malicious data was not always being completely
+	validated. Receipt of these packets can cause ntpd to crash.
+    Mitigation:
+        Don't use autokey.
+	Upgrade to 4.2.8p4, or later, from the NTP Project Download
+	    Page or the NTP Public Services Project Download Page
+	Monitor your ntpd instances. 
+	Credit: This weakness was discovered by Tenable Network Security. 
+
+* Clients that receive a KoD should validate the origin timestamp field.
+
+    References: Sec 2901 / CVE-2015-7704, CVE-2015-7705
+    Affects: All ntp-4 releases up to, but not including 4.2.8p4,
+	and 4.3.0 up to, but not including 4.3.77
+    CVSS: (AV:N/AC:M/Au:N/C:N/I:N/A:P) Base Score: 4.3-5.0 at worst
+    Summary: An ntpd client that honors Kiss-of-Death responses will honor
+    	KoD messages that have been forged by an attacker, causing it to
+	delay or stop querying its servers for time updates. Also, an
+	attacker can forge packets that claim to be from the target and
+	send them to servers often enough that a server that implements
+	KoD rate limiting will send the target machine a KoD response to
+	attempt to reduce the rate of incoming packets, or it may also
+	trigger a firewall block at the server for packets from the target
+	machine. For either of these attacks to succeed, the attacker must
+	know what servers the target is communicating with. An attacker
+	can be anywhere on the Internet and can frequently learn the
+	identity of the target's time source by sending the target a
+	time query.
+    Mitigation:
+        Implement BCP-38.
+	Upgrade to 4.2.8p4, or later, from the NTP Project Download Page
+	    or the NTP Public Services Project Download Page
+	If you can't upgrade, restrict who can query ntpd to learn who
+	    its servers are, and what IPs are allowed to ask your system
+	    for the time. This mitigation is heavy-handed.
+	Monitor your ntpd instances. 
+    Note:
+    	4.2.8p4 protects against the first attack. For the second attack,
+    	all we can do is warn when it is happening, which we do in 4.2.8p4.
+    Credit: This weakness was discovered by Aanchal Malhotra,
+    	Issac E. Cohen, and Sharon Goldberg of Boston University. 
+
+* configuration directives to change "pidfile" and "driftfile" should
+  only be allowed locally. 
+
+  References: Sec 2902 / CVE-2015-5196
+  Affects: All ntp-4 releases up to, but not including 4.2.8p4,
+	and 4.3.0 up to, but not including 4.3.77
+   CVSS: (AV:N/AC:H/Au:M/C:N/I:C/A:C) Base Score: 6.2 worst case
+   Summary: If ntpd is configured to allow for remote configuration,
+	and if the (possibly spoofed) source IP address is allowed to
+	send remote configuration requests, and if the attacker knows
+	the remote configuration password, it's possible for an attacker
+	to use the "pidfile" or "driftfile" directives to potentially
+	overwrite other files.
+   Mitigation:
+	Implement BCP-38.
+	Upgrade to 4.2.8p4, or later, from the NTP Project Download
+	    Page or the NTP Public Services Project Download Page
+	If you cannot upgrade, don't enable remote configuration.
+	If you must enable remote configuration and cannot upgrade,
+	    remote configuration of NTF's ntpd requires:
+	    - an explicitly configured trustedkey, and you should also
+	    	configure a controlkey.
+	    - access from a permitted IP. You choose the IPs.
+	    - authentication. Don't disable it. Practice secure key safety. 
+	Monitor your ntpd instances. 
+   Credit: This weakness was discovered by Miroslav Lichvar of Red Hat. 
+
+* Slow memory leak in CRYPTO_ASSOC 
+
+  References: Sec 2909 / CVE-2015-7701
+  Affects: All ntp-4 releases that use autokey up to, but not
+    including 4.2.8p4, and 4.3.0 up to, but not including 4.3.77
+  CVSS: (AV:N/AC:H/Au:M/C:N/I:N/A:C) Base Score: 0.0 best/usual case,
+  	4.6 otherwise
+  Summary: If ntpd is configured to use autokey, then an attacker can
+	send packets to ntpd that will, after several days of ongoing
+	attack, cause it to run out of memory.
+  Mitigation:
+	Don't use autokey.
+	Upgrade to 4.2.8p4, or later, from the NTP Project Download
+	    Page or the NTP Public Services Project Download Page
+	Monitor your ntpd instances. 
+  Credit: This weakness was discovered by Tenable Network Security. 
+
+* mode 7 loop counter underrun
+
+  References:  Sec 2913 / CVE-2015-7848 / TALOS-CAN-0052
+  Affects: All ntp-4 releases up to, but not including 4.2.8p4,
+  	and 4.3.0 up to, but not including 4.3.77
+  CVSS: (AV:N/AC:H/Au:M/C:N/I:N/A:C) Base Score: 4.6
+  Summary: If ntpd is configured to enable mode 7 packets, and if the
+	use of mode 7 packets is not properly protected thru the use of
+	the available mode 7 authentication and restriction mechanisms,
+	and if the (possibly spoofed) source IP address is allowed to
+	send mode 7 queries, then an attacker can send a crafted packet
+	to ntpd that will cause it to crash.
+  Mitigation:
+	Implement BCP-38.
+	Upgrade to 4.2.8p4, or later, from the NTP Project Download
+	    Page or the NTP Public Services Project Download Page.
+	      If you are unable to upgrade:
+	In ntp-4.2.8, mode 7 is disabled by default. Don't enable it.
+	If you must enable mode 7:
+	    configure the use of a requestkey to control who can issue
+		mode 7 requests.
+	    configure restrict noquery to further limit mode 7 requests
+		to trusted sources. 
+	Monitor your ntpd instances. 
+Credit: This weakness was discovered by Aleksandar Nikolic of Cisco Talos. 
+
+* memory corruption in password store
+
+  References: Sec 2916 / CVE-2015-7849 / TALOS-CAN-0054
+  Affects: All ntp-4 releases up to, but not including 4.2.8p4, and 4.3.0 up to, but not including 4.3.77
+  CVSS: (AV:N/AC:H/Au:M/C:N/I:C/A:C) Base Score: 6.8, worst case
+  Summary: If ntpd is configured to allow remote configuration, and if
+	the (possibly spoofed) source IP address is allowed to send
+	remote configuration requests, and if the attacker knows the
+	remote configuration password or if ntpd was configured to
+	disable authentication, then an attacker can send a set of
+	packets to ntpd that may cause a crash or theoretically
+	perform a code injection attack.
+  Mitigation:
+	Implement BCP-38.
+	Upgrade to 4.2.8p4, or later, from the NTP Project Download
+	    Page or the NTP Public Services Project Download Page.
+	If you are unable to upgrade, remote configuration of NTF's
+	    ntpd requires:
+		an explicitly configured "trusted" key. Only configure
+			this if you need it.
+		access from a permitted IP address. You choose the IPs.
+		authentication. Don't disable it. Practice secure key safety. 
+	Monitor your ntpd instances. 
+  Credit: This weakness was discovered by Yves Younan of Cisco Talos. 
+
+* Infinite loop if extended logging enabled and the logfile and
+  keyfile are the same.
+
+    References: Sec 2917 / CVE-2015-7850 / TALOS-CAN-0055
+    Affects: All ntp-4 releases up to, but not including 4.2.8p4,
+	and 4.3.0 up to, but not including 4.3.77
+    CVSS: (AV:N/AC:H/Au:M/C:N/I:N/A:C) Base Score: 4.6, worst case
+    Summary: If ntpd is configured to allow remote configuration, and if
+	the (possibly spoofed) source IP address is allowed to send
+	remote configuration requests, and if the attacker knows the
+	remote configuration password or if ntpd was configured to
+	disable authentication, then an attacker can send a set of
+	packets to ntpd that will cause it to crash and/or create a
+	potentially huge log file. Specifically, the attacker could
+	enable extended logging, point the key file at the log file,
+	and cause what amounts to an infinite loop.
+    Mitigation:
+	Implement BCP-38.
+	Upgrade to 4.2.8p4, or later, from the NTP Project Download
+	    Page or the NTP Public Services Project Download Page.
+	If you are unable to upgrade, remote configuration of NTF's ntpd
+	  requires:
+            an explicitly configured "trusted" key. Only configure this
+	    	if you need it.
+            access from a permitted IP address. You choose the IPs.
+            authentication. Don't disable it. Practice secure key safety. 
+        Monitor your ntpd instances. 
+    Credit: This weakness was discovered by Yves Younan of Cisco Talos. 
+
+* Potential path traversal vulnerability in the config file saving of
+  ntpd on VMS.
+
+  References: Sec 2918 / CVE-2015-7851 / TALOS-CAN-0062
+  Affects: All ntp-4 releases running under VMS up to, but not
+	including 4.2.8p4, and 4.3.0 up to, but not including 4.3.77
+  CVSS: (AV:N/AC:H/Au:M/C:N/I:P/A:C) Base Score: 5.2, worst case
+  Summary: If ntpd is configured to allow remote configuration, and if
+	the (possibly spoofed) IP address is allowed to send remote
+	configuration requests, and if the attacker knows the remote
+	configuration password or if ntpd was configured to disable
+	authentication, then an attacker can send a set of packets to
+	ntpd that may cause ntpd to overwrite files.
+  Mitigation:
+	Implement BCP-38.
+	Upgrade to 4.2.8p4, or later, from the NTP Project Download
+	    Page or the NTP Public Services Project Download Page.
+	If you are unable to upgrade, remote configuration of NTF's ntpd
+	    requires:
+		an explicitly configured "trusted" key. Only configure
+			this if you need it.
+		access from permitted IP addresses. You choose the IPs.
+		authentication. Don't disable it. Practice key security safety. 
+        Monitor your ntpd instances. 
+    Credit: This weakness was discovered by Yves Younan of Cisco Talos. 
+
+* ntpq atoascii() potential memory corruption
+
+  References: Sec 2919 / CVE-2015-7852 / TALOS-CAN-0063
+  Affects: All ntp-4 releases running up to, but not including 4.2.8p4,
+	and 4.3.0 up to, but not including 4.3.77
+  CVSS: (AV:N/AC:H/Au:N/C:N/I:P/A:P) Base Score: 4.0, worst case
+  Summary: If an attacker can figure out the precise moment that ntpq
+	is listening for data and the port number it is listening on or
+	if the attacker can provide a malicious instance ntpd that
+	victims will connect to then an attacker can send a set of
+	crafted mode 6 response packets that, if received by ntpq,
+	can cause ntpq to crash.
+  Mitigation:
+	Implement BCP-38.
+	Upgrade to 4.2.8p4, or later, from the NTP Project Download
+	    Page or the NTP Public Services Project Download Page.
+	If you are unable to upgrade and you run ntpq against a server
+	    and ntpq crashes, try again using raw mode. Build or get a
+	    patched ntpq and see if that fixes the problem. Report new
+	    bugs in ntpq or abusive servers appropriately.
+	If you use ntpq in scripts, make sure ntpq does what you expect
+	    in your scripts. 
+  Credit: This weakness was discovered by Yves Younan and
+  	Aleksander Nikolich of Cisco Talos. 
+
+* Invalid length data provided by a custom refclock driver could cause
+  a buffer overflow. 
+
+  References: Sec 2920 / CVE-2015-7853 / TALOS-CAN-0064
+  Affects: Potentially all ntp-4 releases running up to, but not
+	including 4.2.8p4, and 4.3.0 up to, but not including 4.3.77
+	that have custom refclocks
+  CVSS: (AV:L/AC:H/Au:M/C:C/I:C/A:C) Base Score: 0.0 usual case,
+	5.9 unusual worst case
+  Summary: A negative value for the datalen parameter will overflow a
+	data buffer. NTF's ntpd driver implementations always set this
+	value to 0 and are therefore not vulnerable to this weakness.
+	If you are running a custom refclock driver in ntpd and that
+	driver supplies a negative value for datalen (no custom driver
+	of even minimal competence would do this) then ntpd would
+	overflow a data buffer. It is even hypothetically possible
+	in this case that instead of simply crashing ntpd the attacker
+	could effect a code injection attack.
+  Mitigation:
+	Upgrade to 4.2.8p4, or later, from the NTP Project Download
+	    Page or the NTP Public Services Project Download Page.
+	If you are unable to upgrade:
+		If you are running custom refclock drivers, make sure
+			the signed datalen value is either zero or positive. 
+	Monitor your ntpd instances. 
+  Credit: This weakness was discovered by Yves Younan of Cisco Talos. 
+
+* Password Length Memory Corruption Vulnerability
+
+  References: Sec 2921 / CVE-2015-7854 / TALOS-CAN-0065
+  Affects: All ntp-4 releases up to, but not including 4.2.8p4, and
+  	4.3.0 up to, but not including 4.3.77
+  CVSS: (AV:N/AC:H/Au:M/C:C/I:C/A:C) Base Score: 0.0 best case,
+  	1.7 usual case, 6.8, worst case
+  Summary: If ntpd is configured to allow remote configuration, and if
+	the (possibly spoofed) source IP address is allowed to send
+	remote configuration requests, and if the attacker knows the
+	remote configuration password or if ntpd was (foolishly)
+	configured to disable authentication, then an attacker can
+	send a set of packets to ntpd that may cause it to crash,
+	with the hypothetical possibility of a small code injection.
+  Mitigation:
+	Implement BCP-38.
+	Upgrade to 4.2.8p4, or later, from the NTP Project Download
+	    Page or the NTP Public Services Project Download Page.
+	If you are unable to upgrade, remote configuration of NTF's
+	    ntpd requires:
+		an explicitly configured "trusted" key. Only configure
+			this if you need it.
+		access from a permitted IP address. You choose the IPs.
+		authentication. Don't disable it. Practice secure key safety. 
+	Monitor your ntpd instances. 
+  Credit: This weakness was discovered by Yves Younan and
+  	Aleksander Nikolich of Cisco Talos. 
+
+* decodenetnum() will ASSERT botch instead of returning FAIL on some
+  bogus values.
+
+  References: Sec 2922 / CVE-2015-7855
+  Affects: All ntp-4 releases up to, but not including 4.2.8p4, and
+	4.3.0 up to, but not including 4.3.77
+  CVSS: (AV:N/AC:H/Au:M/C:N/I:N/A:C) Base Score: 4.6, worst case
+  Summary: If ntpd is fed a crafted mode 6 or mode 7 packet containing
+	an unusually long data value where a network address is expected,
+	the decodenetnum() function will abort with an assertion failure
+	instead of simply returning a failure condition.
+  Mitigation:
+	Implement BCP-38.
+	Upgrade to 4.2.8p4, or later, from the NTP Project Download
+	    Page or the NTP Public Services Project Download Page.
+	If you are unable to upgrade:
+		mode 7 is disabled by default. Don't enable it.
+		Use restrict noquery to limit who can send mode 6
+			and mode 7 requests.
+		Configure and use the controlkey and requestkey
+			authentication directives to limit who can
+			send mode 6 and mode 7 requests. 
+	Monitor your ntpd instances. 
+  Credit: This weakness was discovered by John D "Doug" Birdwell of IDA.org. 
+
+* NAK to the Future: Symmetric association authentication bypass via
+  crypto-NAK.
+
+  References: Sec 2941 / CVE-2015-7871
+  Affects: All ntp-4 releases between 4.2.5p186 up to but not including
+  	4.2.8p4, and 4.3.0 up to but not including 4.3.77
+  CVSS: (AV:N/AC:L/Au:N/C:N/I:P/A:P) Base Score: 6.4
+  Summary: Crypto-NAK packets can be used to cause ntpd to accept time
+	from unauthenticated ephemeral symmetric peers by bypassing the
+	authentication required to mobilize peer associations. This
+	vulnerability appears to have been introduced in ntp-4.2.5p186
+	when the code handling mobilization of new passive symmetric
+	associations (lines 1103-1165) was refactored.
+  Mitigation:
+	Implement BCP-38.
+	Upgrade to 4.2.8p4, or later, from the NTP Project Download
+	    Page or the NTP Public Services Project Download Page.
+	If you are unable to upgrade:
+		Apply the patch to the bottom of the "authentic" check
+			block around line 1136 of ntp_proto.c. 
+	Monitor your ntpd instances. 
+  Credit: This weakness was discovered by Matthew Van Gundy of Cisco ASIG. 
+
+Backward-Incompatible changes:
+* [Bug 2817] Default on Linux is now "rlimit memlock -1".
+  While the general default of 32M is still the case, under Linux
+  the default value has been changed to -1 (do not lock ntpd into
+  memory).  A value of 0 means "lock ntpd into memory with whatever
+  memory it needs." If your ntp.conf file has an explicit "rlimit memlock"
+  value in it, that value will continue to be used.
+
+* [Bug 2886] Misspelling: "outlyer" should be "outlier".
+  If you've written a script that looks for this case in, say, the
+  output of ntpq, you probably want to change your regex matches
+  from 'outlyer' to 'outl[iy]er'.
+
+New features in this release:
+* 'rlimit memlock' now has finer-grained control.  A value of -1 means
+  "don't lock ntpd into memore".  This is the default for Linux boxes.
+  A value of 0 means "lock ntpd into memory" with no limits.  Otherwise
+  the value is the number of megabytes of memory to lock.  The default
+  is 32 megabytes.
+
+* The old Google Test framework has been replaced with a new framework,
+  based on http://www.throwtheswitch.org/unity/ .
+
+Bug Fixes and Improvements:
+* [Bug 2332] (reopened) Exercise thread cancellation once before dropping
+  privileges and limiting resources in NTPD removes the need to link
+  forcefully against 'libgcc_s' which does not always work. J.Perlinger
+* [Bug 2595] ntpdate man page quirks.  Hal Murray, Harlan Stenn.
+* [Bug 2625] Deprecate flag1 in local refclock.  Hal Murray, Harlan Stenn.
+* [Bug 2817] Stop locking ntpd into memory by default under Linux.  H.Stenn.
+* [Bug 2821] minor build issues: fixed refclock_gpsdjson.c.  perlinger@ntp.org
+* [Bug 2823] ntpsweep with recursive peers option doesn't work.  H.Stenn.
+* [Bug 2849] Systems with more than one default route may never
+  synchronize.  Brian Utterback.  Note that this patch might need to
+  be reverted once Bug 2043 has been fixed.
+* [Bug 2864] 4.2.8p3 fails to compile on Windows. Juergen Perlinger
+* [Bug 2866] segmentation fault at initgroups().  Harlan Stenn.
+* [Bug 2867] ntpd with autokey active crashed by 'ntpq -crv'. J.Perlinger
+* [Bug 2873] libevent should not include .deps/ in the tarball.  H.Stenn
+* [Bug 2874] Don't distribute generated sntp/tests/fileHandlingTest.h. H.Stenn
+* [Bug 2875] sntp/Makefile.am: Get rid of DIST_SUBDIRS.  libevent must
+  be configured for the distribution targets.  Harlan Stenn.
+* [Bug 2883] ntpd crashes on exit with empty driftfile.  Miroslav Lichvar.
+* [Bug 2886] Mis-spelling: "outlyer" should be "outlier".  dave@horsfall.org
+* [Bug 2888] streamline calendar functions.  perlinger@ntp.org
+* [Bug 2889] ntp-dev-4.3.67 does not build on Windows.  perlinger@ntp.org
+* [Bug 2890] Ignore ENOBUFS on routing netlink socket.  Konstantin Khlebnikov.
+* [Bug 2906] make check needs better support for pthreads.  Harlan Stenn.
+* [Bug 2907] dist* build targets require our libevent/ to be enabled.  HStenn.
+* [Bug 2912] no munlockall() under Windows.  David Taylor, Harlan Stenn.
+* libntp/emalloc.c: Remove explicit include of stdint.h.  Harlan Stenn.
+* Put Unity CPPFLAGS items in unity_config.h.  Harlan Stenn.
+* tests/ntpd/g_leapsec.cpp typo fix.  Harlan Stenn.
+* Phase 1 deprecation of google test in sntp/tests/.  Harlan Stenn.
+* On some versions of HP-UX, inttypes.h does not include stdint.h.  H.Stenn.
+* top_srcdir can change based on ntp v. sntp.  Harlan Stenn.
+* sntp/tests/ function parameter list cleanup.  Damir Tomić.
+* tests/libntp/ function parameter list cleanup.  Damir Tomić.
+* tests/ntpd/ function parameter list cleanup.  Damir Tomić.
+* sntp/unity/unity_config.h: handle stdint.h.  Harlan Stenn.
+* sntp/unity/unity_internals.h: handle *INTPTR_MAX on old Solaris.  H.Stenn.
+* tests/libntp/timevalops.c and timespecops.c fixed error printing.  D.Tomić.
+* tests/libntp/ improvements in code and fixed error printing.  Damir Tomić.
+* tests/libntp: a_md5encrypt.c, authkeys.c, buftvtots.c, calendar.c, caljulian.c,
+  caltontp.c, clocktime.c, humandate.c, hextolfp.c, decodenetnum.c - fixed
+  formatting; first declaration, then code (C90); deleted unnecessary comments;
+  changed from sprintf to snprintf; fixed order of includes. Tomasz Flendrich
+* tests/libntp/lfpfunc.c remove unnecessary include, remove old comments,
+  fix formatting, cleanup. Tomasz Flendrich
+* tests/libntp/lfptostr.c remove unnecessary include, add consts, fix formatting.
+  Tomasz Flendrich
+* tests/libntp/statestr.c remove empty functions, remove unnecessary include,
+  fix formatting. Tomasz Flendrich
+* tests/libntp/modetoa.c fixed formatting. Tomasz Flendrich
+* tests/libntp/msyslog.c fixed formatting. Tomasz Flendrich
+* tests/libntp/numtoa.c deleted unnecessary empty functions, fixed formatting.
+  Tomasz Flendrich
+* tests/libntp/numtohost.c added const, fixed formatting. Tomasz Flendrich
+* tests/libntp/refnumtoa.c fixed formatting. Tomasz Flendrich
+* tests/libntp/ssl_init.c fixed formatting. Tomasz Flendrich
+* tests/libntp/tvtots.c fixed a bug, fixed formatting. Tomasz Flendrich
+* tests/libntp/uglydate.c removed an unnecessary include. Tomasz Flendrich
+* tests/libntp/vi64ops.c removed an unnecessary comment, fixed formatting.
+* tests/libntp/ymd3yd.c removed an empty function and an unnecessary include,
+fixed formatting. Tomasz Flendrich
+* tests/libntp/timespecops.c fixed formatting, fixed the order of includes,
+  removed unnecessary comments, cleanup. Tomasz Flendrich
+* tests/libntp/timevalops.c fixed the order of includes, deleted unnecessary
+  comments, cleanup. Tomasz Flendrich
+* tests/libntp/sockaddrtest.h making it agree to NTP's conventions of formatting.
+  Tomasz Flendrich
+* tests/libntp/lfptest.h cleanup. Tomasz Flendrich
+* tests/libntp/test-libntp.c fix formatting. Tomasz Flendrich
+* sntp/tests/crypto.c is now using proper Unity's assertions, fixed formatting.
+  Tomasz Flendrich
+* sntp/tests/kodDatabase.c added consts, deleted empty function,
+  fixed formatting. Tomasz Flendrich
+* sntp/tests/kodFile.c cleanup, fixed formatting. Tomasz Flendrich
+* sntp/tests/packetHandling.c is now using proper Unity's assertions,
+  fixed formatting, deleted unused variable. Tomasz Flendrich
+* sntp/tests/keyFile.c is now using proper Unity's assertions, fixed formatting.
+  Tomasz Flendrich
+* sntp/tests/packetProcessing.c changed from sprintf to snprintf,
+  fixed formatting. Tomasz Flendrich
+* sntp/tests/utilities.c is now using proper Unity's assertions, changed
+  the order of includes, fixed formatting, removed unnecessary comments.
+  Tomasz Flendrich
+* sntp/tests/sntptest.h fixed formatting. Tomasz Flendrich
+* sntp/tests/fileHandlingTest.h.in fixed a possible buffer overflow problem,
+  made one function do its job, deleted unnecessary prints, fixed formatting.
+  Tomasz Flendrich
+* sntp/unity/Makefile.am added a missing header. Tomasz Flendrich
+* sntp/unity/unity_config.h: Distribute it.  Harlan Stenn.
+* sntp/libevent/evconfig-private.h: remove generated filefrom SCM.  H.Stenn.
+* sntp/unity/Makefile.am: fix some broken paths.  Harlan Stenn.
+* sntp/unity/unity.c: Clean up a printf().  Harlan Stenn.
+* Phase 1 deprecation of google test in tests/libntp/.  Harlan Stenn.
+* Don't build sntp/libevent/sample/.  Harlan Stenn.
+* tests/libntp/test_caltontp needs -lpthread.  Harlan Stenn.
+* br-flock: --enable-local-libevent.  Harlan Stenn.
+* Wrote tests for ntpd/ntp_prio_q.c. Tomasz Flendrich
+* scripts/lib/NTP/Util.pm: stratum output is version-dependent.  Harlan Stenn.
+* Get rid of the NTP_ prefix on our assertion macros.  Harlan Stenn.
+* Code cleanup.  Harlan Stenn.
+* libntp/icom.c: Typo fix.  Harlan Stenn.
+* util/ntptime.c: initialization nit.  Harlan Stenn.
+* ntpd/ntp_peer.c:newpeer(): added a DEBUG_REQUIRE(srcadr).  Harlan Stenn.
+* Add std_unity_tests to various Makefile.am files.  Harlan Stenn.
+* ntpd/ntp_restrict.c: added a few assertions, created tests for this file.
+  Tomasz Flendrich
+* Changed progname to be const in many files - now it's consistent. Tomasz
+  Flendrich
+* Typo fix for GCC warning suppression.  Harlan Stenn.
+* Added tests/ntpd/ntp_scanner.c test. Damir Tomić.
+* Added declarations to all Unity tests, and did minor fixes to them.
+  Reduced the number of warnings by half. Damir Tomić.
+* Updated generate_test_runner.rb and updated the sntp/unity/auto directory
+  with the latest Unity updates from Mark. Damir Tomić.
+* Retire google test - phase I.  Harlan Stenn.
+* Unity test cleanup: move declaration of 'initializing'.  Harlan Stenn.
+* Update the NEWS file.  Harlan Stenn.
+* Autoconf cleanup.  Harlan Stenn.
+* Unit test dist cleanup. Harlan Stenn.
+* Cleanup various test Makefile.am files.  Harlan Stenn.
+* Pthread autoconf macro cleanup.  Harlan Stenn.
+* Fix progname definition in unity runner scripts.  Harlan Stenn.
+* Clean trailing whitespace in tests/ntpd/Makefile.am.  Harlan Stenn.
+* Update the patch for bug 2817.  Harlan Stenn.
+* More updates for bug 2817.  Harlan Stenn.
+* Fix bugs in tests/ntpd/ntp_prio_q.c.  Harlan Stenn.
+* gcc on older HPUX may need +allowdups.  Harlan Stenn.
+* Adding missing MCAST protection.  Harlan Stenn.
+* Disable certain test programs on certain platforms.  Harlan Stenn.
+* Implement --enable-problem-tests (on by default).  Harlan Stenn.
+* build system tweaks.  Harlan Stenn.
+
+---
+NTP 4.2.8p3 (Harlan Stenn <stenn@ntp.org>, 2015/06/29) 
+
+Focus: 1 Security fix.  Bug fixes and enhancements.  Leap-second improvements.
+
+Severity: MEDIUM
+
+Security Fix:
+
+* [Sec 2853] Crafted remote config packet can crash some versions of
+  ntpd.  Aleksis Kauppinen, Juergen Perlinger, Harlan Stenn.
+
+Under specific circumstances an attacker can send a crafted packet to
+cause a vulnerable ntpd instance to crash. This requires each of the
+following to be true:
+
+1) ntpd set up to allow remote configuration (not allowed by default), and
+2) knowledge of the configuration password, and
+3) access to a computer entrusted to perform remote configuration. 
+
+This vulnerability is considered low-risk.
+
+New features in this release:
+
+Optional (disabled by default) support to have ntpd provide smeared
+leap second time.  A specially built and configured ntpd will only
+offer smeared time in response to client packets.  These response
+packets will also contain a "refid" of 254.a.b.c, where the 24 bits
+of a, b, and c encode the amount of smear in a 2:22 integer:fraction 
+format.  See README.leapsmear and http://bugs.ntp.org/2855 for more
+information.
+
+   *IF YOU CHOOSE TO CONFIGURE NTPD TO PROVIDE LEAP SMEAR TIME*
+   *BE SURE YOU DO NOT OFFER THAT TIME ON PUBLIC TIMESERVERS.*
+
+We've imported the Unity test framework, and have begun converting
+the existing google-test items to this new framework.  If you want
+to write new tests or change old ones, you'll need to have ruby
+installed.  You don't need ruby to run the test suite.
+
+Bug Fixes and Improvements:
+
+* CID 739725: Fix a rare resource leak in libevent/listener.c.
+* CID 1295478: Quiet a pedantic potential error from the fix for Bug 2776.
+* CID 1296235: Fix refclock_jjy.c and correcting type of the driver40-ja.html
+* CID 1269537: Clean up a line of dead code in getShmTime().
+* [Bug 1060] Buffer overruns in libparse/clk_rawdcf.c.  Helge Oldach.
+* [Bug 2590] autogen-5.18.5.
+* [Bug 2612] restrict: Warn when 'monitor' can't be disabled because
+  of 'limited'.
+* [Bug 2650] fix includefile processing.
+* [Bug 2745] ntpd -x steps clock on leap second
+   Fixed an initial-value problem that caused misbehaviour in absence of
+   any leapsecond information.
+   Do leap second stepping only of the step adjustment is beyond the
+   proper jump distance limit and step correction is allowed at all.
+* [Bug 2750] build for Win64
+  Building for 32bit of loopback ppsapi needs def file
+* [Bug 2776] Improve ntpq's 'help keytype'.
+* [Bug 2778] Implement "apeers"  ntpq command to include associd.
+* [Bug 2782] Refactor refclock_shm.c, add memory barrier protection.
+* [Bug 2792] If the IFF_RUNNING interface flag is supported then an
+  interface is ignored as long as this flag is not set since the
+  interface is not usable (e.g., no link).
+* [Bug 2794] Clean up kernel clock status reports.
+* [Bug 2800] refclock_true.c true_debug() can't open debug log because
+  of incompatible open/fdopen parameters.
+* [Bug 2804] install-local-data assumes GNU 'find' semantics.
+* [Bug 2805] ntpd fails to join multicast group.
+* [Bug 2806] refclock_jjy.c supports the Telephone JJY.
+* [Bug 2808] GPSD_JSON driver enhancements, step 1.
+  Fix crash during cleanup if GPS device not present and char device.
+  Increase internal token buffer to parse all JSON data, even SKY.
+  Defer logging of errors during driver init until the first unit is
+  started, so the syslog is not cluttered when the driver is not used.
+  Various improvements, see http://bugs.ntp.org/2808 for details.
+  Changed libjsmn to a more recent version.
+* [Bug 2810] refclock_shm.c memory barrier code needs tweaks for QNX.
+* [Bug 2813] HP-UX needs -D__STDC_VERSION__=199901L and limits.h.
+* [Bug 2815] net-snmp before v5.4 has circular library dependencies.
+* [Bug 2821] Add a missing NTP_PRINTF and a missing const.
+* [Bug 2822] New leap column in sntp broke NTP::Util.pm.
+* [Bug 2824] Convert update-leap to perl. (also see 2769)
+* [Bug 2825] Quiet file installation in html/ .
+* [Bug 2830] ntpd doesn't always transfer the correct TAI offset via autokey
+   NTPD transfers the current TAI (instead of an announcement) now.
+   This might still needed improvement.
+   Update autokey data ASAP when 'sys_tai' changes.
+   Fix unit test that was broken by changes for autokey update.
+   Avoid potential signature length issue and use DPRINTF where possible
+     in ntp_crypto.c.
+* [Bug 2832] refclock_jjy.c supports the TDC-300.
+* [Bug 2834] Correct a broken html tag in html/refclock.html
+* [Bug 2836] DFC77 patches from Frank Kardel to make decoding more
+  robust, and require 2 consecutive timestamps to be consistent.
+* [Bug 2837] Allow a configurable DSCP value.
+* [Bug 2837] add test for DSCP to ntpd/complete.conf.in
+* [Bug 2842] Glitch in ntp.conf.def documentation stanza.
+* [Bug 2842] Bug in mdoc2man.
+* [Bug 2843] make check fails on 4.3.36
+   Fixed compiler warnings about numeric range overflow
+   (The original topic was fixed in a byplay to bug#2830)
+* [Bug 2845] Harden memory allocation in ntpd.
+* [Bug 2852] 'make check' can't find unity.h.  Hal Murray.
+* [Bug 2854] Missing brace in libntp/strdup.c.  Masanari Iida.
+* [Bug 2855] Parser fix for conditional leap smear code.  Harlan Stenn.
+* [Bug 2855] Report leap smear in the REFID.  Harlan Stenn.
+* [Bug 2855] Implement conditional leap smear code.  Martin Burnicki.
+* [Bug 2856] ntpd should wait() on terminated child processes.  Paul Green.
+* [Bug 2857] Stratus VOS does not support SIGIO.  Paul Green.
+* [Bug 2859] Improve raw DCF77 robustness deconding.  Frank Kardel.
+* [Bug 2860] ntpq ifstats sanity check is too stringent.  Frank Kardel.
+* html/drivers/driver22.html: typo fix.  Harlan Stenn.
+* refidsmear test cleanup.  Tomasz Flendrich.
+* refidsmear function support and tests.  Harlan Stenn.
+* sntp/tests/Makefile.am: remove g_nameresolution.cpp as it tested
+  something that was only in the 4.2.6 sntp.  Harlan Stenn.
+* Modified tests/bug-2803/Makefile.am so it builds Unity framework tests.
+  Damir Tomić
+* Modified tests/libtnp/Makefile.am so it builds Unity framework tests.
+  Damir Tomić
+* Modified sntp/tests/Makefile.am so it builds Unity framework tests.
+  Damir Tomić
+* tests/sandbox/smeartest.c: Harlan Stenn, Damir Tomic, Juergen Perlinger.
+* Converted from gtest to Unity: tests/bug-2803/. Damir Tomić
+* Converted from gtest to Unity: tests/libntp/ a_md5encrypt, atoint.c,
+  atouint.c, authkeys.c, buftvtots.c, calendar.c, caljulian.c,
+  calyearstart.c, clocktime.c, hextoint.c, lfpfunc.c, modetoa.c,
+  numtoa.c, numtohost.c, refnumtoa.c, ssl_init.c, statestr.c,
+  timespecops.c, timevalops.c, uglydate.c, vi64ops.c, ymd2yd.c.
+  Damir Tomić
+* Converted from gtest to Unity: sntp/tests/ kodDatabase.c, kodFile.c,
+  networking.c, keyFile.c, utilities.cpp, sntptest.h,
+  fileHandlingTest.h. Damir Tomić
+* Initial support for experimental leap smear code.  Harlan Stenn.
+* Fixes to sntp/tests/fileHandlingTest.h.in.  Harlan Stenn.
+* Report select() debug messages at debug level 3 now.
+* sntp/scripts/genLocInfo: treat raspbian as debian.
+* Unity test framework fixes.
+  ** Requires ruby for changes to tests.
+* Initial support for PACKAGE_VERSION tests.
+* sntp/libpkgver belongs in EXTRA_DIST, not DIST_SUBDIRS.
+* tests/bug-2803/Makefile.am must distribute bug-2803.h.
+* Add an assert to the ntpq ifstats code.
+* Clean up the RLIMIT_STACK code.
+* Improve the ntpq documentation around the controlkey keyid.
+* ntpq.c cleanup.
+* Windows port build cleanup.
+
+---
+NTP 4.2.8p2 (Harlan Stenn <stenn@ntp.org>, 2015/04/07) 
+
+Focus: Security and Bug fixes, enhancements.
+
+Severity: MEDIUM
+ 
+In addition to bug fixes and enhancements, this release fixes the
+following medium-severity vulnerabilities involving private key
+authentication:
+
+* [Sec 2779] ntpd accepts unauthenticated packets with symmetric key crypto.
+
+    References: Sec 2779 / CVE-2015-1798 / VU#374268
+    Affects: All NTP4 releases starting with ntp-4.2.5p99 up to but not
+	including ntp-4.2.8p2 where the installation uses symmetric keys
+	to authenticate remote associations.
+    CVSS: (AV:A/AC:M/Au:N/C:P/I:P/A:P) Base Score: 5.4
+    Date Resolved: Stable (4.2.8p2) 07 Apr 2015
+    Summary: When ntpd is configured to use a symmetric key to authenticate
+	a remote NTP server/peer, it checks if the NTP message
+	authentication code (MAC) in received packets is valid, but not if
+	there actually is any MAC included. Packets without a MAC are
+	accepted as if they had a valid MAC. This allows a MITM attacker to
+	send false packets that are accepted by the client/peer without
+	having to know the symmetric key. The attacker needs to know the
+	transmit timestamp of the client to match it in the forged reply
+	and the false reply needs to reach the client before the genuine
+	reply from the server. The attacker doesn't necessarily need to be
+	relaying the packets between the client and the server.
+
+	Authentication using autokey doesn't have this problem as there is
+	a check that requires the key ID to be larger than NTP_MAXKEY,
+	which fails for packets without a MAC.
+    Mitigation:
+        Upgrade to 4.2.8p2, or later, from the NTP Project Download Page
+	or the NTP Public Services Project Download Page
+        Configure ntpd with enough time sources and monitor it properly. 
+    Credit: This issue was discovered by Miroslav Lichvar, of Red Hat. 
+
+* [Sec 2781] Authentication doesn't protect symmetric associations against
+  DoS attacks.
+
+    References: Sec 2781 / CVE-2015-1799 / VU#374268
+    Affects: All NTP releases starting with at least xntp3.3wy up to but
+	not including ntp-4.2.8p2 where the installation uses symmetric
+	key authentication.
+    CVSS: (AV:A/AC:M/Au:N/C:P/I:P/A:P) Base Score: 5.4
+    Note: the CVSS base Score for this issue could be 4.3 or lower, and
+	it could be higher than 5.4.
+    Date Resolved: Stable (4.2.8p2) 07 Apr 2015
+    Summary: An attacker knowing that NTP hosts A and B are peering with
+	each other (symmetric association) can send a packet to host A
+	with source address of B which will set the NTP state variables
+	on A to the values sent by the attacker. Host A will then send
+	on its next poll to B a packet with originate timestamp that
+	doesn't match the transmit timestamp of B and the packet will
+	be dropped. If the attacker does this periodically for both
+	hosts, they won't be able to synchronize to each other. This is
+	a known denial-of-service attack, described at
+	https://www.eecis.udel.edu/~mills/onwire.html .
+
+	According to the document the NTP authentication is supposed to
+	protect symmetric associations against this attack, but that
+	doesn't seem to be the case. The state variables are updated even
+	when authentication fails and the peers are sending packets with
+	originate timestamps that don't match the transmit timestamps on
+	the receiving side.
+
+	This seems to be a very old problem, dating back to at least
+	xntp3.3wy. It's also in the NTPv3 (RFC 1305) and NTPv4 (RFC 5905)
+	specifications, so other NTP implementations with support for
+	symmetric associations and authentication may be vulnerable too.
+	An update to the NTP RFC to correct this error is in-process.
+    Mitigation:
+        Upgrade to 4.2.8p2, or later, from the NTP Project Download Page
+	or the NTP Public Services Project Download Page
+        Note that for users of autokey, this specific style of MITM attack
+	is simply a long-known potential problem.
+        Configure ntpd with appropriate time sources and monitor ntpd.
+	Alert your staff if problems are detected. 
+    Credit: This issue was discovered by Miroslav Lichvar, of Red Hat. 
+
+* New script: update-leap
+The update-leap script will verify and if necessary, update the
+leap-second definition file.
+It requires the following commands in order to work:
+
+	wget logger tr sed shasum
+
+Some may choose to run this from cron.  It needs more portability testing.
+
+Bug Fixes and Improvements:
+
+* [Bug 1787] DCF77's formerly "antenna" bit is "call bit" since 2003.
+* [Bug 1960] setsockopt IPV6_MULTICAST_IF: Invalid argument.
+* [Bug 2346] "graceful termination" signals do not do peer cleanup.
+* [Bug 2728] See if C99-style structure initialization works.
+* [Bug 2747] Upgrade libevent to 2.1.5-beta.
+* [Bug 2749] ntp/lib/NTP/Util.pm needs update for ntpq -w, IPv6, .POOL. .
+* [Bug 2751] jitter.h has stale copies of l_fp macros.
+* [Bug 2756] ntpd hangs in startup with gcc 3.3.5 on ARM.
+* [Bug 2757] Quiet compiler warnings.
+* [Bug 2759] Expose nonvolatile/clk_wander_threshold to ntpq.
+* [Bug 2763] Allow different thresholds for forward and backward steps.
+* [Bug 2766] ntp-keygen output files should not be world-readable.
+* [Bug 2767] ntp-keygen -M should symlink to ntp.keys.
+* [Bug 2771] nonvolatile value is documented in wrong units.
+* [Bug 2773] Early leap announcement from Palisade/Thunderbolt
+* [Bug 2774] Unreasonably verbose printout - leap pending/warning
+* [Bug 2775] ntp-keygen.c fails to compile under Windows.
+* [Bug 2777] Fixed loops and decoding of Meinberg GPS satellite info.
+  Removed non-ASCII characters from some copyright comments.
+  Removed trailing whitespace.
+  Updated definitions for Meinberg clocks from current Meinberg header files.
+  Now use C99 fixed-width types and avoid non-ASCII characters in comments.
+  Account for updated definitions pulled from Meinberg header files.
+  Updated comments on Meinberg GPS receivers which are not only called GPS16x.
+  Replaced some constant numbers by defines from ntp_calendar.h
+  Modified creation of parse-specific variables for Meinberg devices
+  in gps16x_message().
+  Reworked mk_utcinfo() to avoid printing of ambiguous leap second dates.
+  Modified mbg_tm_str() which now expexts an additional parameter controlling
+  if the time status shall be printed.
+* [Sec 2779] ntpd accepts unauthenticated packets with symmetric key crypto.
+* [Sec 2781] Authentication doesn't protect symmetric associations against
+  DoS attacks.
+* [Bug 2783] Quiet autoconf warnings about missing AC_LANG_SOURCE.
+* [Bug 2789] Quiet compiler warnings from libevent.
+* [Bug 2790] If ntpd sets the Windows MM timer highest resolution
+  pause briefly before measuring system clock precision to yield
+  correct results.
+* Comment from Juergen Perlinger in ntp_calendar.c to make the code clearer.
+* Use predefined function types for parse driver functions
+  used to set up function pointers.
+  Account for changed prototype of parse_inp_fnc_t functions.
+  Cast parse conversion results to appropriate types to avoid
+  compiler warnings.
+  Let ioctl() for Windows accept a (void *) to avoid compiler warnings
+  when called with pointers to different types.
+
+---
+NTP 4.2.8p1 (Harlan Stenn <stenn@ntp.org>, 2015/02/04) 
+
+Focus: Security and Bug fixes, enhancements.
+
+Severity: HIGH
+ 
+In addition to bug fixes and enhancements, this release fixes the
+following high-severity vulnerabilities:
+
+* vallen is not validated in several places in ntp_crypto.c, leading
+  to a potential information leak or possibly a crash
+
+    References: Sec 2671 / CVE-2014-9297 / VU#852879
+    Affects: All NTP4 releases before 4.2.8p1 that are running autokey.
+    CVSS: (AV:N/AC:L/Au:N/C:P/I:P/A:P) Base Score: 7.5
+    Date Resolved: Stable (4.2.8p1) 04 Feb 2015
+    Summary: The vallen packet value is not validated in several code
+             paths in ntp_crypto.c which can lead to information leakage
+	     or perhaps a crash of the ntpd process.
+    Mitigation - any of:
+	Upgrade to 4.2.8p1, or later, from the NTP Project Download Page
+		or the NTP Public Services Project Download Page.
+	Disable Autokey Authentication by removing, or commenting out,
+		all configuration directives beginning with the "crypto"
+		keyword in your ntp.conf file. 
+    Credit: This vulnerability was discovered by Stephen Roettger of the
+    	Google Security Team, with additional cases found by Sebastian
+	Krahmer of the SUSE Security Team and Harlan Stenn of Network
+	Time Foundation. 
+
+* ::1 can be spoofed on some OSes, so ACLs based on IPv6 ::1 addresses
+  can be bypassed.
+
+    References: Sec 2672 / CVE-2014-9298 / VU#852879
+    Affects: All NTP4 releases before 4.2.8p1, under at least some
+	versions of MacOS and Linux. *BSD has not been seen to be vulnerable.
+    CVSS: (AV:N/AC:L/Au:N/C:P/I:P/A:C) Base Score: 9
+    Date Resolved: Stable (4.2.8p1) 04 Feb 2014
+    Summary: While available kernels will prevent 127.0.0.1 addresses
+	from "appearing" on non-localhost IPv4 interfaces, some kernels
+	do not offer the same protection for ::1 source addresses on
+	IPv6 interfaces. Since NTP's access control is based on source
+	address and localhost addresses generally have no restrictions,
+	an attacker can send malicious control and configuration packets
+	by spoofing ::1 addresses from the outside. Note Well: This is
+	not really a bug in NTP, it's a problem with some OSes. If you
+	have one of these OSes where ::1 can be spoofed, ALL ::1 -based
+	ACL restrictions on any application can be bypassed!
+    Mitigation:
+        Upgrade to 4.2.8p1, or later, from the NTP Project Download Page
+	or the NTP Public Services Project Download Page
+        Install firewall rules to block packets claiming to come from
+	::1 from inappropriate network interfaces. 
+    Credit: This vulnerability was discovered by Stephen Roettger of
+	the Google Security Team. 
+
+Additionally, over 30 bugfixes and improvements were made to the codebase.
+See the ChangeLog for more information.
+
+---
+NTP 4.2.8 (Harlan Stenn <stenn@ntp.org>, 2014/12/18) 
+ 
+Focus: Security and Bug fixes, enhancements.
+ 
+Severity: HIGH
+ 
+In addition to bug fixes and enhancements, this release fixes the
+following high-severity vulnerabilities:
+
+************************** vv NOTE WELL vv *****************************
+
+The vulnerabilities listed below can be significantly mitigated by
+following the BCP of putting
+
+ restrict default ... noquery
+
+in the ntp.conf file.  With the exception of:
+
+   receive(): missing return on error
+   References: Sec 2670 / CVE-2014-9296 / VU#852879
+
+below (which is a limited-risk vulnerability), none of the recent
+vulnerabilities listed below can be exploited if the source IP is
+restricted from sending a 'query'-class packet by your ntp.conf file.
+
+************************** ^^ NOTE WELL ^^ *****************************
+
+* Weak default key in config_auth().
+
+  References: [Sec 2665] / CVE-2014-9293 / VU#852879
+  CVSS: (AV:N/AC:L/Au:M/C:P/I:P/A:C) Base Score: 7.3
+  Vulnerable Versions: all releases prior to 4.2.7p11
+  Date Resolved: 28 Jan 2010
+
+  Summary: If no 'auth' key is set in the configuration file, ntpd
+	would generate a random key on the fly.  There were two
+	problems with this: 1) the generated key was 31 bits in size,
+	and 2) it used the (now weak) ntp_random() function, which was
+	seeded with a 32-bit value and could only provide 32 bits of
+	entropy.  This was sufficient back in the late 1990s when the
+	code was written.  Not today.
+
+  Mitigation - any of:
+	- Upgrade to 4.2.7p11 or later.
+	- Follow BCP and put 'restrict ... noquery' in your ntp.conf file.
+
+  Credit: This vulnerability was noticed in ntp-4.2.6 by Neel Mehta
+  	of the Google Security Team.
+
+* Non-cryptographic random number generator with weak seed used by
+  ntp-keygen to generate symmetric keys.
+
+  References: [Sec 2666] / CVE-2014-9294 / VU#852879
+  CVSS: (AV:N/AC:L/Au:M/C:P/I:P/A:C) Base Score: 7.3
+  Vulnerable Versions: All NTP4 releases before 4.2.7p230
+  Date Resolved: Dev (4.2.7p230) 01 Nov 2011
+
+  Summary: Prior to ntp-4.2.7p230 ntp-keygen used a weak seed to
+  	prepare a random number generator that was of good quality back
+	in the late 1990s. The random numbers produced was then used to
+	generate symmetric keys. In ntp-4.2.8 we use a current-technology
+	cryptographic random number generator, either RAND_bytes from
+	OpenSSL, or arc4random(). 
+
+  Mitigation - any of:
+  	- Upgrade to 4.2.7p230 or later.
+	- Follow BCP and put 'restrict ... noquery' in your ntp.conf file.
+
+  Credit:  This vulnerability was discovered in ntp-4.2.6 by
+  	Stephen Roettger of the Google Security Team.
+
+* Buffer overflow in crypto_recv()
+
+  References: Sec 2667 / CVE-2014-9295 / VU#852879
+  CVSS: (AV:N/AC:L/Au:N/C:P/I:P/A:P) Base Score: 7.5
+  Versions: All releases before 4.2.8
+  Date Resolved: Stable (4.2.8) 18 Dec 2014
+
+  Summary: When Autokey Authentication is enabled (i.e. the ntp.conf
+  	file contains a 'crypto pw ...' directive) a remote attacker
+	can send a carefully crafted packet that can overflow a stack
+	buffer and potentially allow malicious code to be executed
+	with the privilege level of the ntpd process.
+
+  Mitigation - any of:
+  	- Upgrade to 4.2.8, or later, or
+	- Disable Autokey Authentication by removing, or commenting out,
+	  all configuration directives beginning with the crypto keyword
+	  in your ntp.conf file. 
+
+  Credit: This vulnerability was discovered by Stephen Roettger of the
+  	Google Security Team. 
+
+* Buffer overflow in ctl_putdata()
+
+  References: Sec 2668 / CVE-2014-9295 / VU#852879
+  CVSS: (AV:N/AC:L/Au:N/C:P/I:P/A:P) Base Score: 7.5
+  Versions: All NTP4 releases before 4.2.8
+  Date Resolved: Stable (4.2.8) 18 Dec 2014
+
+  Summary: A remote attacker can send a carefully crafted packet that
+  	can overflow a stack buffer and potentially allow malicious
+	code to be executed with the privilege level of the ntpd process.
+
+  Mitigation - any of:
+  	- Upgrade to 4.2.8, or later.
+	- Follow BCP and put 'restrict ... noquery' in your ntp.conf file.
+
+  Credit: This vulnerability was discovered by Stephen Roettger of the
+  	Google Security Team. 
+
+* Buffer overflow in configure()
+
+  References: Sec 2669 / CVE-2014-9295 / VU#852879
+  CVSS: (AV:N/AC:L/Au:N/C:P/I:P/A:P) Base Score: 7.5
+  Versions: All NTP4 releases before 4.2.8
+  Date Resolved: Stable (4.2.8) 18 Dec 2014
+
+  Summary: A remote attacker can send a carefully crafted packet that
+	can overflow a stack buffer and potentially allow malicious
+	code to be executed with the privilege level of the ntpd process.
+
+  Mitigation - any of:
+  	- Upgrade to 4.2.8, or later.
+	- Follow BCP and put 'restrict ... noquery' in your ntp.conf file.
+
+  Credit: This vulnerability was discovered by Stephen Roettger of the
+	Google Security Team. 
+
+* receive(): missing return on error
+
+  References: Sec 2670 / CVE-2014-9296 / VU#852879
+  CVSS: (AV:N/AC:L/Au:N/C:N/I:N/A:P) Base Score: 5.0
+  Versions: All NTP4 releases before 4.2.8
+  Date Resolved: Stable (4.2.8) 18 Dec 2014
+
+  Summary: Code in ntp_proto.c:receive() was missing a 'return;' in
+  	the code path where an error was detected, which meant
+	processing did not stop when a specific rare error occurred.
+	We haven't found a way for this bug to affect system integrity.
+	If there is no way to affect system integrity the base CVSS
+	score for this bug is 0. If there is one avenue through which
+	system integrity can be partially affected, the base score
+	becomes a 5. If system integrity can be partially affected
+	via all three integrity metrics, the CVSS base score become 7.5.
+
+  Mitigation - any of:
+        - Upgrade to 4.2.8, or later,
+        - Remove or comment out all configuration directives
+	  beginning with the crypto keyword in your ntp.conf file. 
+
+  Credit: This vulnerability was discovered by Stephen Roettger of the
+  	Google Security Team. 
+
+See http://support.ntp.org/security for more information.
+
+New features / changes in this release:
+
+Important Changes
+
+* Internal NTP Era counters
+
+The internal counters that track the "era" (range of years) we are in
+rolls over every 136 years'.  The current "era" started at the stroke of
+midnight on 1 Jan 1900, and ends just before the stroke of midnight on
+1 Jan 2036.
+In the past, we have used the "midpoint" of the  range to decide which
+era we were in.  Given the longevity of some products, it became clear
+that it would be more functional to "look back" less, and "look forward"
+more.  We now compile a timestamp into the ntpd executable and when we
+get a timestamp we us the "built-on" to tell us what era we are in.
+This check "looks back" 10 years, and "looks forward" 126 years.
+
+* ntpdc responses disabled by default
+
+Dave Hart writes:
+
+For a long time, ntpq and its mostly text-based mode 6 (control) 
+protocol have been preferred over ntpdc and its mode 7 (private 
+request) protocol for runtime queries and configuration.  There has 
+been a goal of deprecating ntpdc, previously held back by numerous 
+capabilities exposed by ntpdc with no ntpq equivalent.  I have been 
+adding commands to ntpq to cover these cases, and I believe I've 
+covered them all, though I've not compared command-by-command 
+recently. 
+
+As I've said previously, the binary mode 7 protocol involves a lot of 
+hand-rolled structure layout and byte-swapping code in both ntpd and 
+ntpdc which is hard to get right.  As ntpd grows and changes, the 
+changes are difficult to expose via ntpdc while maintaining forward 
+and backward compatibility between ntpdc and ntpd.  In contrast, 
+ntpq's text-based, label=value approach involves more code reuse and 
+allows compatible changes without extra work in most cases. 
+
+Mode 7 has always been defined as vendor/implementation-specific while 
+mode 6 is described in RFC 1305 and intended to be open to interoperate 
+with other implementations.  There is an early draft of an updated 
+mode 6 description that likely will join the other NTPv4 RFCs 
+eventually. (http://tools.ietf.org/html/draft-odonoghue-ntpv4-control-01)
+
+For these reasons, ntpd 4.2.7p230 by default disables processing of 
+ntpdc queries, reducing ntpd's attack surface and functionally 
+deprecating ntpdc.  If you are in the habit of using ntpdc for certain 
+operations, please try the ntpq equivalent.  If there's no equivalent, 
+please open a bug report at http://bugs.ntp.org./
+
+In addition to the above, over 1100 issues have been resolved between
+the 4.2.6 branch and 4.2.8.  The ChangeLog file in the distribution
+lists these.
+
+--- 
+NTP 4.2.6p5 (Harlan Stenn <stenn@ntp.org>, 2011/12/24) 
+ 
+Focus: Bug fixes
+ 
+Severity: Medium 
+ 
+This is a recommended upgrade. 
+
+This release updates sys_rootdisp and sys_jitter calculations to match the
+RFC specification, fixes a potential IPv6 address matching error for the
+"nic" and "interface" configuration directives, suppresses the creation of
+extraneous ephemeral associations for certain broadcastclient and
+multicastclient configurations, cleans up some ntpq display issues, and
+includes improvements to orphan mode, minor bugs fixes and code clean-ups.
+
+New features / changes in this release:
+
+ntpd
+
+ * Updated "nic" and "interface" IPv6 address handling to prevent 
+   mismatches with localhost [::1] and wildcard [::] which resulted from
+   using the address/prefix format (e.g. fe80::/64)
+ * Fix orphan mode stratum incorrectly counting to infinity
+ * Orphan parent selection metric updated to includes missing ntohl()
+ * Non-printable stratum 16 refid no longer sent to ntp
+ * Duplicate ephemeral associations suppressed for broadcastclient and
+   multicastclient without broadcastdelay
+ * Exclude undetermined sys_refid from use in loopback TEST12
+ * Exclude MODE_SERVER responses from KoD rate limiting
+ * Include root delay in clock_update() sys_rootdisp calculations
+ * get_systime() updated to exclude sys_residual offset (which only
+   affected bits "below" sys_tick, the precision threshold)
+ * sys.peer jitter weighting corrected in sys_jitter calculation
+
+ntpq
+
+ * -n option extended to include the billboard "server" column
+ * IPv6 addresses in the local column truncated to prevent overruns
+
+--- 
+NTP 4.2.6p4 (Harlan Stenn <stenn@ntp.org>, 2011/09/22) 
+ 
+Focus: Bug fixes and portability improvements 
+ 
+Severity: Medium 
+ 
+This is a recommended upgrade. 
+ 
+This release includes build infrastructure updates, code 
+clean-ups, minor bug fixes, fixes for a number of minor 
+ref-clock issues, and documentation revisions. 
+ 
+Portability improvements affect AIX, HP-UX, Linux, OS X and 64-bit time_t. 
+ 
+New features / changes in this release: 
+ 
+Build system 
+ 
+* Fix checking for struct rtattr 
+* Update config.guess and config.sub for AIX 
+* Upgrade required version of autogen and libopts for building 
+  from our source code repository 
+ 
+ntpd 
+ 
+* Back-ported several fixes for Coverity warnings from ntp-dev 
+* Fix a rare boundary condition in UNLINK_EXPR_SLIST() 
+* Allow "logconfig =allall" configuration directive 
+* Bind tentative IPv6 addresses on Linux 
+* Correct WWVB/Spectracom driver to timestamp CR instead of LF 
+* Improved tally bit handling to prevent incorrect ntpq peer status reports 
+* Exclude the Undisciplined Local Clock and ACTS drivers from the initial 
+  candidate list unless they are designated a "prefer peer" 
+* Prevent the consideration of Undisciplined Local Clock or ACTS drivers for 
+  selection during the 'tos orphanwait' period 
+* Prefer an Orphan Mode Parent over the Undisciplined Local Clock or ACTS 
+  drivers 
+* Improved support of the Parse Refclock trusttime flag in Meinberg mode 
+* Back-port utility routines from ntp-dev: mprintf(), emalloc_zero() 
+* Added the NTPD_TICKADJ_PPM environment variable for specifying baseline 
+  clock slew on Microsoft Windows 
+* Code cleanup in libntpq 
+ 
+ntpdc 
+ 
+* Fix timerstats reporting 
+ 
+ntpdate 
+ 
+* Reduce time required to set clock 
+* Allow a timeout greater than 2 seconds 
+ 
+sntp 
+ 
+* Backward incompatible command-line option change: 
+  -l/--filelog changed -l/--logfile (to be consistent with ntpd) 
+ 
+Documentation 
+ 
+* Update html2man. Fix some tags in the .html files 
+* Distribute ntp-wait.html 
+
+---
+NTP 4.2.6p3 (Harlan Stenn <stenn@ntp.org>, 2011/01/03)
+
+Focus: Bug fixes and portability improvements
+
+Severity: Medium
+
+This is a recommended upgrade.
+
+This release includes build infrastructure updates, code
+clean-ups, minor bug fixes, fixes for a number of minor
+ref-clock issues, and documentation revisions.
+
+Portability improvements in this release affect AIX, Atari FreeMiNT,
+FreeBSD4, Linux and Microsoft Windows.
+
+New features / changes in this release:
+
+Build system
+* Use lsb_release to get information about Linux distributions.
+* 'test' is in /usr/bin (instead of /bin) on some systems.
+* Basic sanity checks for the ChangeLog file.
+* Source certain build files with ./filename for systems without . in PATH.
+* IRIX portability fix.
+* Use a single copy of the "libopts" code.
+* autogen/libopts upgrade.
+* configure.ac m4 quoting cleanup.
+
+ntpd
+* Do not bind to IN6_IFF_ANYCAST addresses.
+* Log the reason for exiting under Windows.
+* Multicast fixes for Windows.
+* Interpolation fixes for Windows.
+* IPv4 and IPv6 Multicast fixes.
+* Manycast solicitation fixes and general repairs.
+* JJY refclock cleanup.
+* NMEA refclock improvements.
+* Oncore debug message cleanup.
+* Palisade refclock now builds under Linux.
+* Give RAWDCF more baud rates.
+* Support Truetime Satellite clocks under Windows.
+* Support Arbiter 1093C Satellite clocks under Windows.
+* Make sure that the "filegen" configuration command defaults to "enable".
+* Range-check the status codes (plus other cleanup) in the RIPE-NCC driver.
+* Prohibit 'includefile' directive in remote configuration command.
+* Fix 'nic' interface bindings.
+* Fix the way we link with openssl if openssl is installed in the base
+  system.
+
+ntp-keygen
+* Fix -V coredump.
+* OpenSSL version display cleanup.
+
+ntpdc
+* Many counters should be treated as unsigned.
+
+ntpdate
+* Do not ignore replies with equal receive and transmit timestamps.
+
+ntpq
+* libntpq warning cleanup.
+
+ntpsnmpd
+* Correct SNMP type for "precision" and "resolution".
+* Update the MIB from the draft version to RFC-5907.
+
+sntp
+* Display timezone offset when showing time for sntp in the local
+  timezone.
+* Pay proper attention to RATE KoD packets.
+* Fix a miscalculation of the offset.
+* Properly parse empty lines in the key file.
+* Logging cleanup.
+* Use tv_usec correctly in set_time().
+* Documentation cleanup.
+
+---
+NTP 4.2.6p2 (Harlan Stenn <stenn@ntp.org>, 2010/07/08)
+
+Focus: Bug fixes and portability improvements
+
+Severity: Medium
+
+This is a recommended upgrade.
+
+This release includes build infrastructure updates, code
+clean-ups, minor bug fixes, fixes for a number of minor
+ref-clock issues, improved KOD handling, OpenSSL related
+updates and documentation revisions.
+
+Portability improvements in this release affect Irix, Linux,
+Mac OS, Microsoft Windows, OpenBSD and QNX6
+
+New features / changes in this release:
+
+ntpd
+* Range syntax for the trustedkey configuration directive
+* Unified IPv4 and IPv6 restrict lists
+
+ntpdate
+* Rate limiting and KOD handling
+
+ntpsnmpd
+* default connection to net-snmpd via a unix-domain socket
+* command-line 'socket name' option
+
+ntpq / ntpdc
+* support for the "passwd ..." syntax
+* key-type specific password prompts
+
+sntp
+* MD5 authentication of an ntpd
+* Broadcast and crypto
+* OpenSSL support
+
+---
+NTP 4.2.6p1 (Harlan Stenn <stenn@ntp.org>, 2010/04/09)
+
+Focus: Bug fixes, portability fixes, and documentation improvements
+
+Severity: Medium
+
+This is a recommended upgrade.
+
+---
+NTP 4.2.6 (Harlan Stenn <stenn@ntp.org>, 2009/12/08)
+
+Focus: enhancements and bug fixes.
+
+---
+NTP 4.2.4p8 (Harlan Stenn <stenn@ntp.org>, 2009/12/08)
+
+Focus: Security Fixes
+
+Severity: HIGH
+
+This release fixes the following high-severity vulnerability:
+
+* [Sec 1331] DoS with mode 7 packets - CVE-2009-3563.
+
+  See http://support.ntp.org/security for more information.
+
+  NTP mode 7 (MODE_PRIVATE) is used by the ntpdc query and control utility.
+  In contrast, ntpq uses NTP mode 6 (MODE_CONTROL), while routine NTP time
+  transfers use modes 1 through 5.  Upon receipt of an incorrect mode 7
+  request or a mode 7 error response from an address which is not listed
+  in a "restrict ... noquery" or "restrict ... ignore" statement, ntpd will
+  reply with a mode 7 error response (and log a message).  In this case:
+
+	* If an attacker spoofs the source address of ntpd host A in a
+	  mode 7 response packet sent to ntpd host B, both A and B will
+	  continuously send each other error responses, for as long as
+	  those packets get through.
+
+	* If an attacker spoofs an address of ntpd host A in a mode 7
+	  response packet sent to ntpd host A, A will respond to itself
+	  endlessly, consuming CPU and logging excessively.
+
+  Credit for finding this vulnerability goes to Robin Park and Dmitri
+  Vinokurov of Alcatel-Lucent.
+
+THIS IS A STRONGLY RECOMMENDED UPGRADE.
+
+---
+ntpd now syncs to refclocks right away.
+
+Backward-Incompatible changes:
+
+ntpd no longer accepts '-v name' or '-V name' to define internal variables.
+Use '--var name' or '--dvar name' instead. (Bug 817)
+
+---
+NTP 4.2.4p7 (Harlan Stenn <stenn@ntp.org>, 2009/05/04)
+
+Focus: Security and Bug Fixes
+
+Severity: HIGH
+
+This release fixes the following high-severity vulnerability:
+
+* [Sec 1151] Remote exploit if autokey is enabled.  CVE-2009-1252
+
+  See http://support.ntp.org/security for more information.
+
+  If autokey is enabled (if ntp.conf contains a "crypto pw whatever"
+  line) then a carefully crafted packet sent to the machine will cause
+  a buffer overflow and possible execution of injected code, running
+  with the privileges of the ntpd process (often root).
+
+  Credit for finding this vulnerability goes to Chris Ries of CMU.
+
+This release fixes the following low-severity vulnerabilities:
+
+* [Sec 1144] limited (two byte) buffer overflow in ntpq.  CVE-2009-0159
+  Credit for finding this vulnerability goes to Geoff Keating of Apple.
+  
+* [Sec 1149] use SO_EXCLUSIVEADDRUSE on Windows
+  Credit for finding this issue goes to Dave Hart.
+
+This release fixes a number of bugs and adds some improvements:
+
+* Improved logging
+* Fix many compiler warnings
+* Many fixes and improvements for Windows
+* Adds support for AIX 6.1
+* Resolves some issues under MacOS X and Solaris
+
+THIS IS A STRONGLY RECOMMENDED UPGRADE.
+
+---
+NTP 4.2.4p6 (Harlan Stenn <stenn@ntp.org>, 2009/01/07)
+
+Focus: Security Fix
+
+Severity: Low
+
+This release fixes oCERT.org's CVE-2009-0021, a vulnerability affecting
+the OpenSSL library relating to the incorrect checking of the return
+value of EVP_VerifyFinal function.
+
+Credit for finding this issue goes to the Google Security Team for
+finding the original issue with OpenSSL, and to ocert.org for finding
+the problem in NTP and telling us about it.
+
+This is a recommended upgrade.
+---
+NTP 4.2.4p5 (Harlan Stenn <stenn@ntp.org>, 2008/08/17)
+
+Focus: Minor Bugfixes 
+
+This release fixes a number of Windows-specific ntpd bugs and 
+platform-independent ntpdate bugs. A logging bugfix has been applied
+to the ONCORE driver.
+
+The "dynamic" keyword and is now obsolete and deferred binding to local 
+interfaces is the new default. The minimum time restriction for the 
+interface update interval has been dropped. 
+
+A number of minor build system and documentation fixes are included. 
+
+This is a recommended upgrade for Windows. 
+
+---
+NTP 4.2.4p4 (Harlan Stenn <stenn@ntp.org>, 2007/09/10)
+
+Focus: Minor Bugfixes
+
+This release updates certain copyright information, fixes several display
+bugs in ntpdc, avoids SIGIO interrupting malloc(), cleans up file descriptor
+shutdown in the parse refclock driver, removes some lint from the code,
+stops accessing certain buffers immediately after they were freed, fixes
+a problem with non-command-line specification of -6, and allows the loopback
+interface to share addresses with other interfaces.
+
+---
+NTP 4.2.4p3 (Harlan Stenn <stenn@ntp.org>, 2007/06/29)
+
+Focus: Minor Bugfixes
+
+This release fixes a bug in Windows that made it difficult to
+terminate ntpd under windows.
+This is a recommended upgrade for Windows.
+
+---
+NTP 4.2.4p2 (Harlan Stenn <stenn@ntp.org>, 2007/06/19)
+
+Focus: Minor Bugfixes
+
+This release fixes a multicast mode authentication problem, 
+an error in NTP packet handling on Windows that could lead to 
+ntpd crashing, and several other minor bugs. Handling of 
+multicast interfaces and logging configuration were improved. 
+The required versions of autogen and libopts were incremented.
+This is a recommended upgrade for Windows and multicast users.
+
+---
+NTP 4.2.4 (Harlan Stenn <stenn@ntp.org>, 2006/12/31)
+
+Focus: enhancements and bug fixes.
+
+Dynamic interface rescanning was added to simplify the use of ntpd in 
+conjunction with DHCP. GNU AutoGen is used for its command-line options 
+processing. Separate PPS devices are supported for PARSE refclocks, MD5 
+signatures are now provided for the release files. Drivers have been 
+added for some new ref-clocks and have been removed for some older 
+ref-clocks. This release also includes other improvements, documentation 
+and bug fixes. 
+
+K&R C is no longer supported as of NTP-4.2.4. We are now aiming for ANSI 
+C support.
+
+---
+NTP 4.2.0 (Harlan Stenn <stenn@ntp.org>, 2003/10/15)
+
+Focus: enhancements and bug fixes.
+---
 NTP 4.2.8p17 (Harlan Stenn <stenn@ntp.org>, 2023 Jun 06)
 
 Focus: Bug fixes
diff --git a/contrib/ntp/adjtimed/Makefile.in b/contrib/ntp/adjtimed/Makefile.in
index 7e7469c4f1b6..b97ef133137b 100644
--- a/contrib/ntp/adjtimed/Makefile.in
+++ b/contrib/ntp/adjtimed/Makefile.in
@@ -96,6 +96,7 @@ bin_PROGRAMS =
 libexec_PROGRAMS =
 sbin_PROGRAMS =
 EXTRA_PROGRAMS = adjtimed$(EXEEXT)
+@LIBNTP_SUBMAKES_TRUE@am__append_1 = check-libntp
 subdir = adjtimed
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
@@ -389,6 +390,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_NET_SNMP_CONFIG = @PATH_NET_SNMP_CONFIG@
+PATH_OPENSSL = @PATH_OPENSSL@
 PATH_PERL = @PATH_PERL@
 PATH_RUBY = @PATH_RUBY@
 PATH_SEPARATOR = @PATH_SEPARATOR@
@@ -487,8 +489,8 @@ target_alias = @target_alias@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-BUILT_SOURCES = check-libntp .deps-ver
-CLEANFILES = check-libntp .deps-ver
+BUILT_SOURCES = $(am__append_1) .deps-ver
+CLEANFILES = .deps-ver
 DISTCLEANFILES = $(DEPDIR)/deps-ver
 AM_CFLAGS = $(CFLAGS_NTP) $(NTP_HARD_CFLAGS)
 AM_CPPFLAGS = $(NTP_INCS) $(CPPFLAGS_NTP) $(NTP_HARD_CPPFLAGS)
@@ -967,11 +969,10 @@ install-exec-hook:
 
 #
 
-check-libntp: $(top_builddir)/libntp/libntp.a
-	@: avoid default SCCS get by some make implementations
+.PHONY: check-libntp
 
-$(top_builddir)/libntp/libntp.a:
-	cd $(top_builddir)/libntp && $(MAKE) $(AM_MAKEFLAGS) libntp.a
+@LIBNTP_SUBMAKES_TRUE@check-libntp:
+@LIBNTP_SUBMAKES_TRUE@	cd $(top_builddir)/libntp && $(MAKE) $(AM_MAKEFLAGS) libntp.a
 $(DEPDIR)/deps-ver: $(top_srcdir)/deps-ver
 	@[ -f $@ ] ||							\
 		cp $(top_srcdir)/deps-ver $@
diff --git a/contrib/ntp/check-libntp.mf b/contrib/ntp/check-libntp.mf
index 07c855b4be78..86fcca45b0e3 100644
--- a/contrib/ntp/check-libntp.mf
+++ b/contrib/ntp/check-libntp.mf
@@ -3,12 +3,12 @@
 ## sntp/check-libntp.mf
 ## The above file has a version of this for the sntp tree.
 
-BUILT_SOURCES	+= check-libntp
-CLEANFILES	+= check-libntp
+.PHONY: check-libntp
 
-check-libntp: $(top_builddir)/libntp/libntp.a
-	@: avoid default SCCS get by some make implementations
+if LIBNTP_SUBMAKES
+BUILT_SOURCES	+= check-libntp
 
-$(top_builddir)/libntp/libntp.a:
+check-libntp:
 	cd $(top_builddir)/libntp && $(MAKE) $(AM_MAKEFLAGS) libntp.a
 
+endif
diff --git a/contrib/ntp/check-libntpd.mf b/contrib/ntp/check-libntpd.mf
index 46304dd5f236..45133ad52c1c 100644
--- a/contrib/ntp/check-libntpd.mf
+++ b/contrib/ntp/check-libntpd.mf
@@ -4,16 +4,7 @@
 
 BUILT_SOURCES	+= check-libntpd
 
-# CLEANFILES addition below won't be needed after a while.
-# Leave it in for now for folks tracking the source repo
-# who have the file from a former version of the rule.
-# DLH Jan 2023
-
-CLEANFILES	+= check-libntpd
-
-check-libntpd: $(top_builddir)/ntpd/libntpd.a
-	 @: avoid default SCCS get by some make implementations
-
-$(top_builddir)/ntpd/libntpd.a:
+.PHONY: check-libntpd
+check-libntpd:
 	cd $(top_builddir)/ntpd && $(MAKE) $(AM_MAKEFLAGS) libntpd.a
 
diff --git a/contrib/ntp/check-libunity.mf b/contrib/ntp/check-libunity.mf
index 4e052058c0c3..830c72c1a421 100644
--- a/contrib/ntp/check-libunity.mf
+++ b/contrib/ntp/check-libunity.mf
@@ -4,10 +4,10 @@
 ## The above file has a version of this for the sntp tree.
 
 BUILT_SOURCES	+= check-libunity
+CLEANFILES	+= check-libunity
 
 check-libunity: $(top_builddir)/sntp/unity/libunity.a
-	 @: avoid default SCCS get by some make implementations
+	@echo stamp > $@
 
 $(top_builddir)/sntp/unity/libunity.a:
 	cd $(top_builddir)/sntp/unity && $(MAKE) $(AM_MAKEFLAGS) libunity.a
-
diff --git a/contrib/ntp/check-scm-rev.mf b/contrib/ntp/check-scm-rev.mf
index e2abbf0e452c..7c0d1be2892f 100644
--- a/contrib/ntp/check-scm-rev.mf
+++ b/contrib/ntp/check-scm-rev.mf
@@ -1,8 +1,6 @@
 $(top_srcdir)/sntp/scm-rev: FRC.scm-rev
 	$(AM_V_GEN)cd $(top_builddir)/sntp && $(MAKE) $(AM_MAKEFLAGS) check-scm-rev
 
+.PHONY: FRC.scm-rev
 FRC.scm-rev:
-	@: FRC.scm-rev "force" depends on nothing and is not a file, so is	\
-	   always out-of-date causing targets which depend on it to also		\
-	   be outdated so their rules to fire each time they are built.
-
+	@: FRC.scm-rev is always out of date, triggering the check every make invocation.
diff --git a/contrib/ntp/clockstuff/Makefile.in b/contrib/ntp/clockstuff/Makefile.in
index f33483eb59c8..b24cb48d113b 100644
--- a/contrib/ntp/clockstuff/Makefile.in
+++ b/contrib/ntp/clockstuff/Makefile.in
@@ -89,6 +89,7 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 EXTRA_PROGRAMS = propdelay$(EXEEXT) chutest$(EXEEXT)
+@LIBNTP_SUBMAKES_TRUE@am__append_1 = check-libntp
 subdir = clockstuff
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
@@ -384,6 +385,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_NET_SNMP_CONFIG = @PATH_NET_SNMP_CONFIG@
+PATH_OPENSSL = @PATH_OPENSSL@
 PATH_PERL = @PATH_PERL@
 PATH_RUBY = @PATH_RUBY@
 PATH_SEPARATOR = @PATH_SEPARATOR@
@@ -488,8 +490,8 @@ AM_CPPFLAGS = $(NTP_INCS) $(CPPFLAGS_NTP) $(NTP_HARD_CPPFLAGS)
 LDADD = ../libntp/libntp.a $(LDADD_LIBNTP) $(LIBM) $(PTHREAD_LIBS)
 AM_LDFLAGS = $(NTP_HARD_LDFLAGS)
 propdelay_LDADD = $(LDADD)
-BUILT_SOURCES = check-libntp .deps-ver
-CLEANFILES = check-libntp .deps-ver
+BUILT_SOURCES = $(am__append_1) .deps-ver
+CLEANFILES = .deps-ver
 DISTCLEANFILES = $(DEPDIR)/deps-ver
 NTP_INCS = -I$(top_srcdir)/include \
 	-I$(top_srcdir)/libntp/lib/isc/include \
@@ -809,11 +811,10 @@ uninstall-am:
 .PRECIOUS: Makefile
 
 
-check-libntp: $(top_builddir)/libntp/libntp.a
-	@: avoid default SCCS get by some make implementations
+.PHONY: check-libntp
 
-$(top_builddir)/libntp/libntp.a:
-	cd $(top_builddir)/libntp && $(MAKE) $(AM_MAKEFLAGS) libntp.a
+@LIBNTP_SUBMAKES_TRUE@check-libntp:
+@LIBNTP_SUBMAKES_TRUE@	cd $(top_builddir)/libntp && $(MAKE) $(AM_MAKEFLAGS) libntp.a
 $(DEPDIR)/deps-ver: $(top_srcdir)/deps-ver
 	@[ -f $@ ] ||							\
 		cp $(top_srcdir)/deps-ver $@
diff --git a/contrib/ntp/config.h.in b/contrib/ntp/config.h.in
index c00eba442298..bfaabf02e183 100644
--- a/contrib/ntp/config.h.in
+++ b/contrib/ntp/config.h.in
@@ -496,9 +496,6 @@
 /* Define to 1 if the system has the type `int32'. */
 #undef HAVE_INT32
 
-/* int32 type in DNS headers, not others. */
-#undef HAVE_INT32_ONLY_WITH_DNS
-
 /* Define to 1 if the system has the type `int32_t'. */
 #undef HAVE_INT32_T
 
@@ -691,9 +688,6 @@
 /* Define to 1 if you have the <openssl/cmac.h> header file. */
 #undef HAVE_OPENSSL_CMAC_H
 
-/* Define to 1 if you have the <openssl/hmac.h> header file. */
-#undef HAVE_OPENSSL_HMAC_H
-
 /* Define to 1 if the system has the type `pid_t'. */
 #undef HAVE_PID_T
 
@@ -970,7 +964,7 @@
 /* Define to 1 if you have the <sysexits.h> header file. */
 #undef HAVE_SYSEXITS_H
 
-/* */
+/* syslog.h provides facilitynames */
 #undef HAVE_SYSLOG_FACILITYNAMES
 
 /* Define to 1 if you have the <sys/audioio.h> header file. */
@@ -1035,6 +1029,9 @@
 /* Define to 1 if you have the <sys/prctl.h> header file. */
 #undef HAVE_SYS_PRCTL_H
 
+/* Define to 1 if you have the <sys/procctl.h> header file. */
+#undef HAVE_SYS_PROCCTL_H
+
 /* Define to 1 if you have the <sys/procset.h> header file. */
 #undef HAVE_SYS_PROCSET_H
 
@@ -1221,9 +1218,6 @@
 /* Define to 1 if the system has the type `u_int32'. */
 #undef HAVE_U_INT32
 
-/* u_int32 type in DNS headers, not others. */
-#undef HAVE_U_INT32_ONLY_WITH_DNS
-
 /* Define to 1 if you have the <values.h> header file. */
 #undef HAVE_VALUES_H
 
@@ -1477,6 +1471,9 @@
 /* Use OpenSSL? */
 #undef OPENSSL
 
+/* Suppress OpenSSL 3 deprecation warnings */
+#undef OPENSSL_SUPPRESS_DEPRECATED
+
 /* Should we open the broadcast socket? */
 #undef OPEN_BCAST_SOCKET
 
@@ -1619,10 +1616,6 @@
 /* Is K_TICK_NAME in nanoseconds? */
 #undef TICK_NANO
 
-/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. This
-   macro is obsolete. */
-#undef TIME_WITH_SYS_TIME
-
 /* Define to 1 if your <sys/time.h> declares `struct tm'. */
 #undef TM_IN_SYS_TIME
 
@@ -1820,15 +1813,8 @@ typedef unsigned int	uintptr_t;
 /* Define to `unsigned int' if <sys/types.h> does not define. */
 #undef size_t
 
-	
-	    #if !defined(_KERNEL) && !defined(PARSESTREAM)
-	    /*
-	     * stdio.h must be included after _GNU_SOURCE is defined
-	     * but before #define snprintf rpl_snprintf
-	     */
-	    # include <stdio.h>	
-	    #endif
-	
+	#include "c99_snprintf.h"
+    
 
 /* Define to rpl_snprintf if the replacement function should be used. */
 #undef snprintf
@@ -1887,3 +1873,15 @@ typedef union mpinfou {
 	# endif
 	#endif	/* !defined(_KERNEL) && !defined(PARSESTREAM) */
 	
+
+
+	/*
+	 * Macro to use in otherwise-empty source files to comply with ANSI C
+	 * requirement that each translation unit (source file) contain some
+	 * declaration.  This has commonly been done by declaring an unused
+	 * global variable of type int or char.  An extern reference to abs()
+	 * serves the same purpose without bloat.  We once used exit() but
+	 * that can produce warnings on systems that declare exit() noreturn.
+	 */
+	#define	NONEMPTY_TRANSLATION_UNIT	extern int abs(int);
+
diff --git a/contrib/ntp/configure b/contrib/ntp/configure
index 5d09904bea03..5172c2d5521f 100755
--- a/contrib/ntp/configure
+++ b/contrib/ntp/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.71 for ntp 4.2.8p17.
+# Generated by GNU Autoconf 2.71 for ntp 4.2.8p18.
 #
 # Report bugs to <https://bugs.ntp.org/>.
 #
@@ -183,7 +183,6 @@ test -x / || exit 1"
   as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
   eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
   test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
-test \$(( 1 + 1 )) = 2 || exit 1
 
   test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || (
     ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
@@ -191,7 +190,8 @@ test \$(( 1 + 1 )) = 2 || exit 1
     ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO
     PATH=/empty FPATH=/empty; export PATH FPATH
     test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\
-      || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1"
+      || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1
+test \$(( 1 + 1 )) = 2 || exit 1"
   if (eval "$as_required") 2>/dev/null
 then :
   as_have_required=yes
@@ -621,8 +621,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='ntp'
 PACKAGE_TARNAME='ntp'
-PACKAGE_VERSION='4.2.8p17'
-PACKAGE_STRING='ntp 4.2.8p17'
+PACKAGE_VERSION='4.2.8p18'
+PACKAGE_STRING='ntp 4.2.8p18'
 PACKAGE_BUGREPORT='https://bugs.ntp.org/'
 PACKAGE_URL='https://www.ntp.org/'
 
@@ -698,7 +698,6 @@ MAKE_PARSEKMODULE
 DCFD
 TESTDCF
 MAKE_CHECK_LAYOUT
-VER_SUFFIX
 MAKE_CHECK_Y2K
 MAKE_LIBPARSE_KERNEL
 MAKE_LIBPARSE
@@ -710,6 +709,10 @@ PATH_NET_SNMP_CONFIG
 CONFIG_SHELL
 PATH_TEST
 PATH_PERL
+PATH_OPENSSL
+VER_SUFFIX
+LIBNTP_SUBMAKES_FALSE
+LIBNTP_SUBMAKES_TRUE
 LIBOBJS
 PTHREADS_FALSE
 PTHREADS_TRUE
@@ -759,6 +762,8 @@ ac_ct_DUMPBIN
 DUMPBIN
 LD
 FGREP
+EGREP
+GREP
 SED
 LIBTOOL
 ac_ct_AR
@@ -857,14 +862,12 @@ NTP_HARD_CPPFLAGS
 NTP_HARD_CFLAGS
 YFLAGS
 YACC
+CPP
 LDFLAGS_NTP
 LDADD_NTP
 CPPFLAGS_NTP
 CFLAGS_NTP
 CC_NOFORMAT
-EGREP
-GREP
-CPP
 am__fastdepCC_FALSE
 am__fastdepCC_TRUE
 CCDEPMODE
@@ -968,6 +971,7 @@ plot_summary_opts'
 ac_user_opts='
 enable_option_checking
 enable_silent_rules
+enable_build_framework_help
 enable_dependency_tracking
 with_hardenfile
 with_locfile
@@ -995,7 +999,11 @@ enable_linuxcaps
 enable_solarisprivs
 enable_trustedbsd_mac
 enable_signalled_io
-with_arlib
+with_crypto
+with_openssl_libdir
+with_openssl_incdir
+enable_verbose_ssl
+enable_openssl_random
 with_net_snmp_config
 enable_libseccomp
 with_stack_limit
@@ -1057,11 +1065,6 @@ enable_TRIMTSIP
 enable_WHARTON
 enable_VARITEXT
 enable_SEL240X
-with_crypto
-with_openssl_libdir
-with_openssl_incdir
-with_rpath
-enable_openssl_random
 enable_autokey
 enable_kmem
 enable_accurate_adjtime
@@ -1651,7 +1654,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures ntp 4.2.8p17 to adapt to many kinds of systems.
+\`configure' configures ntp 4.2.8p18 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1722,7 +1725,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of ntp 4.2.8p17:";;
+     short | recursive ) echo "Configuration of ntp 4.2.8p18:";;
    esac
   cat <<\_ACEOF
 
@@ -1734,6 +1737,8 @@ Optional Features and Packages:
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
   --enable-silent-rules   less verbose build output (undo: "make V=1")
   --disable-silent-rules  verbose build output (undo: "make V=0")
+  --enable-build-framework-help
+                          + enable build framework help
   --enable-dependency-tracking
                           do not reject slow dependency extractors
   --disable-dependency-tracking
@@ -1765,14 +1770,20 @@ Optional Features and Packages:
   --enable-thread-support s use threads (+ if available)
   --with-threads	  with threads [auto]
   --with-yielding-select  with yielding select [auto]
-  --enable-c99-snprintf   s force replacement
+  --enable-c99-snprintf   s use replacement printf family
   --enable-clockctl       s Use /dev/clockctl for non-root clock control
   --enable-linuxcaps      + Use Linux capabilities for non-root clock control
   --enable-solarisprivs   + Use Solaris privileges for non-root clock control
   --enable-trustedbsd-mac s Use TrustedBSD MAC policy for non-root clock
                           control
   --enable-signalled-io   s Use signalled IO if we can
-  --with-arlib            - deprecated, arlib not distributed
+  --with-crypto           + =openssl,libcrypto
+  --with-openssl-libdir   + =/something/reasonable
+
+  --with-openssl-incdir   + =search likely dirs
+
+  --enable-verbose-ssl    - show crypto lib detection details
+  --enable-openssl-random + Use SSL lib's secure random numbers
   --with-net-snmp-config  + =net-snmp-config
   --enable-libseccomp     EXPERIMENTAL: enable support for libseccomp
                           sandboxing (default is no)
@@ -1837,16 +1848,6 @@ Optional Features and Packages:
   --enable-WHARTON        s WHARTON 400A Series clock
   --enable-VARITEXT       s VARITEXT clock
   --enable-SEL240X        s SEL240X clock
-  --with-crypto           + =openssl,libcrypto
-
-  --with-openssl-libdir   + =/something/reasonable
-
-  --with-openssl-incdir   + =/something/reasonable
-
-  --without-rpath         s Disable auto-added -R linker paths
-
-  --enable-openssl-random Use OpenSSL's crypto random number functions, if
-                          available (default is yes)
   --enable-autokey        + support NTP Autokey protocol
   --enable-kmem           s read /dev/kmem for tick and/or tickadj
   --enable-accurate-adjtime
@@ -1967,7 +1968,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-ntp configure 4.2.8p17
+ntp configure 4.2.8p18
 generated by GNU Autoconf 2.71
 
 Copyright (C) 2021 Free Software Foundation, Inc.
@@ -2053,44 +2054,6 @@ printf "%s\n" "$ac_res" >&6; }
 
 } # ac_fn_c_check_header_compile
 
-# ac_fn_c_try_cpp LINENO
-# ----------------------
-# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
-ac_fn_c_try_cpp ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  if { { ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-printf "%s\n" "$ac_try_echo"; } >&5
-  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    grep -v '^ *+' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-    mv -f conftest.er1 conftest.err
-  fi
-  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } > conftest.i && {
-	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       }
-then :
-  ac_retval=0
-else $as_nop
-  printf "%s\n" "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-    ac_retval=1
-fi
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-  as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_cpp
-
 # ac_fn_c_try_link LINENO
 # -----------------------
 # Try to link conftest.$ac_ext, and return whether this succeeded.
@@ -2181,6 +2144,44 @@ fi
 
 } # ac_fn_c_try_run
 
+# ac_fn_c_try_cpp LINENO
+# ----------------------
+# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_cpp ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { { ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+printf "%s\n" "$ac_try_echo"; } >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } > conftest.i && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }
+then :
+  ac_retval=0
+else $as_nop
+  printf "%s\n" "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+    ac_retval=1
+fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_cpp
+
 # ac_fn_c_check_func LINENO FUNC VAR
 # ----------------------------------
 # Tests whether FUNC exists, setting the cache variable VAR accordingly
@@ -2624,7 +2625,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by ntp $as_me 4.2.8p17, which was
+It was created by ntp $as_me 4.2.8p18, which was
 generated by GNU Autoconf 2.71.  Invocation command line was
 
   $ $0$ac_configure_args_raw
@@ -3218,7 +3219,6 @@ as_fn_append ac_func_c_list " vprintf HAVE_VPRINTF"
 as_fn_append ac_header_c_list " vfork.h vfork_h HAVE_VFORK_H"
 as_fn_append ac_func_c_list " fork HAVE_FORK"
 as_fn_append ac_func_c_list " vfork HAVE_VFORK"
-as_fn_append ac_header_c_list " sys/time.h sys_time_h HAVE_SYS_TIME_H"
 as_fn_append ac_header_c_list " stdarg.h stdarg_h HAVE_STDARG_H"
 
 # Auxiliary files required by this configure script.
@@ -3420,7 +3420,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 # the date YYYYMMDD optionally with -HHMM if there is more than one
 # bump in a day.
 
-ntp_configure_cache_version=20230326
+ntp_configure_cache_version=20240218
 
 # When the cache version of config.cache and configure do not
 # match, NTP_CACHEVERSION will flush the cache.
@@ -4039,7 +4039,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='ntp'
- VERSION='4.2.8p17'
+ VERSION='4.2.8p18'
 
 
 printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h
@@ -4266,6 +4266,25 @@ printf "%s\n" "#define STR_SYSTEM \"$host\"" >>confdefs.h
 ac_config_headers="$ac_config_headers config.h"
 
 
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if we should enable build framework help" >&5
+printf %s "checking if we should enable build framework help... " >&6; }
+# Check whether --enable-build-framework-help was given.
+if test ${enable_build_framework_help+y}
+then :
+  enableval=$enable_build_framework_help; ntp_ok=$enableval
+else $as_nop
+  ntp_ok=yes
+
+fi
+
+case "$ntp_ok" in
+ yes)
+    ntp_cv_build_framework_help=yes ;;
+ *) ntp_cv_build_framework_help=no ;;
+esac
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+printf "%s\n" "$ntp_ok" >&6; }
+
 ntp_atom_ok=${ntp_atom_ok=no}
 ntp_oncore_ok=${ntp_oncore_ok=no}
 ntp_parse_ok=${ntp_parse_ok=no}
@@ -5221,6 +5240,7 @@ fi
 
 
 
+
 ac_header= ac_cache=
 for ac_item in $ac_header_c_list
 do
@@ -5392,333 +5412,7 @@ then :
 fi
 
 
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
-printf %s "checking how to run the C preprocessor... " >&6; }
-# On Suns, sometimes $CPP names a directory.
-if test -n "$CPP" && test -d "$CPP"; then
-  CPP=
-fi
-if test -z "$CPP"; then
-  if test ${ac_cv_prog_CPP+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-      # Double quotes because $CC needs to be expanded
-    for CPP in "$CC -E" "$CC -E -traditional-cpp" cpp /lib/cpp
-    do
-      ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
-  # Use a header file that comes with gcc, so configuring glibc
-  # with a fresh cross-compiler works.
-  # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp. "Syntax error" is here to catch this case.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <limits.h>
-		     Syntax error
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"
-then :
-
-else $as_nop
-  # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-
-  # OK, works on sane cases.  Now check whether nonexistent headers
-  # can be detected and how.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <ac_nonexistent.h>
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"
-then :
-  # Broken: success on invalid input.
-continue
-else $as_nop
-  # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.i conftest.err conftest.$ac_ext
-if $ac_preproc_ok
-then :
-  break
-fi
-
-    done
-    ac_cv_prog_CPP=$CPP
-
-fi
-  CPP=$ac_cv_prog_CPP
-else
-  ac_cv_prog_CPP=$CPP
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
-printf "%s\n" "$CPP" >&6; }
-ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
-  # Use a header file that comes with gcc, so configuring glibc
-  # with a fresh cross-compiler works.
-  # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp. "Syntax error" is here to catch this case.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <limits.h>
-		     Syntax error
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"
-then :
-
-else $as_nop
-  # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-
-  # OK, works on sane cases.  Now check whether nonexistent headers
-  # can be detected and how.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <ac_nonexistent.h>
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"
-then :
-  # Broken: success on invalid input.
-continue
-else $as_nop
-  # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.i conftest.err conftest.$ac_ext
-if $ac_preproc_ok
-then :
-
-else $as_nop
-  { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details" "$LINENO" 5; }
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
-printf %s "checking for grep that handles long lines and -e... " >&6; }
-if test ${ac_cv_path_GREP+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  if test -z "$GREP"; then
-  ac_path_GREP_found=false
-  # Loop through the user's path and test for each of PROGNAME-LIST
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
-do
-  IFS=$as_save_IFS
-  case $as_dir in #(((
-    '') as_dir=./ ;;
-    */) ;;
-    *) as_dir=$as_dir/ ;;
-  esac
-    for ac_prog in grep ggrep
-   do
-    for ac_exec_ext in '' $ac_executable_extensions; do
-      ac_path_GREP="$as_dir$ac_prog$ac_exec_ext"
-      as_fn_executable_p "$ac_path_GREP" || continue
-# Check for GNU ac_path_GREP and select it if it is found.
-  # Check for GNU $ac_path_GREP
-case `"$ac_path_GREP" --version 2>&1` in
-*GNU*)
-  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
-*)
-  ac_count=0
-  printf %s 0123456789 >"conftest.in"
-  while :
-  do
-    cat "conftest.in" "conftest.in" >"conftest.tmp"
-    mv "conftest.tmp" "conftest.in"
-    cp "conftest.in" "conftest.nl"
-    printf "%s\n" 'GREP' >> "conftest.nl"
-    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
-    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
-    as_fn_arith $ac_count + 1 && ac_count=$as_val
-    if test $ac_count -gt ${ac_path_GREP_max-0}; then
-      # Best one so far, save it but keep looking for a better one
-      ac_cv_path_GREP="$ac_path_GREP"
-      ac_path_GREP_max=$ac_count
-    fi
-    # 10*(2^10) chars as input seems more than enough
-    test $ac_count -gt 10 && break
-  done
-  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
-esac
-
-      $ac_path_GREP_found && break 3
-    done
-  done
-  done
-IFS=$as_save_IFS
-  if test -z "$ac_cv_path_GREP"; then
-    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
-  fi
-else
-  ac_cv_path_GREP=$GREP
-fi
-
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
-printf "%s\n" "$ac_cv_path_GREP" >&6; }
- GREP="$ac_cv_path_GREP"
-
-
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
-printf %s "checking for egrep... " >&6; }
-if test ${ac_cv_path_EGREP+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
-   then ac_cv_path_EGREP="$GREP -E"
-   else
-     if test -z "$EGREP"; then
-  ac_path_EGREP_found=false
-  # Loop through the user's path and test for each of PROGNAME-LIST
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
-do
-  IFS=$as_save_IFS
-  case $as_dir in #(((
-    '') as_dir=./ ;;
-    */) ;;
-    *) as_dir=$as_dir/ ;;
-  esac
-    for ac_prog in egrep
-   do
-    for ac_exec_ext in '' $ac_executable_extensions; do
-      ac_path_EGREP="$as_dir$ac_prog$ac_exec_ext"
-      as_fn_executable_p "$ac_path_EGREP" || continue
-# Check for GNU ac_path_EGREP and select it if it is found.
-  # Check for GNU $ac_path_EGREP
-case `"$ac_path_EGREP" --version 2>&1` in
-*GNU*)
-  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
-*)
-  ac_count=0
-  printf %s 0123456789 >"conftest.in"
-  while :
-  do
-    cat "conftest.in" "conftest.in" >"conftest.tmp"
-    mv "conftest.tmp" "conftest.in"
-    cp "conftest.in" "conftest.nl"
-    printf "%s\n" 'EGREP' >> "conftest.nl"
-    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
-    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
-    as_fn_arith $ac_count + 1 && ac_count=$as_val
-    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
-      # Best one so far, save it but keep looking for a better one
-      ac_cv_path_EGREP="$ac_path_EGREP"
-      ac_path_EGREP_max=$ac_count
-    fi
-    # 10*(2^10) chars as input seems more than enough
-    test $ac_count -gt 10 && break
-  done
-  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
-esac
-
-      $ac_path_EGREP_found && break 3
-    done
-  done
-  done
-IFS=$as_save_IFS
-  if test -z "$ac_cv_path_EGREP"; then
-    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
-  fi
-else
-  ac_cv_path_EGREP=$EGREP
-fi
-
-   fi
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
-printf "%s\n" "$ac_cv_path_EGREP" >&6; }
- EGREP="$ac_cv_path_EGREP"
-
-
-
-
-
-
-
-# Ralf Wildenhues: With per-target flags we need CC_C_O
-# AM_PROG_CC_C_O supersets AC_PROG_CC_C_O
-
-if test $ac_cv_c_compiler_gnu = yes; then
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC needs -traditional" >&5
-printf %s "checking whether $CC needs -traditional... " >&6; }
-if test ${ac_cv_prog_gcc_traditional+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-    ac_pattern="Autoconf.*'x'"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sgtty.h>
-Autoconf TIOCGETP
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "$ac_pattern" >/dev/null 2>&1
-then :
-  ac_cv_prog_gcc_traditional=yes
-else $as_nop
-  ac_cv_prog_gcc_traditional=no
-fi
-rm -rf conftest*
-
-
-  if test $ac_cv_prog_gcc_traditional = no; then
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <termio.h>
-Autoconf TCGETA
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "$ac_pattern" >/dev/null 2>&1
-then :
-  ac_cv_prog_gcc_traditional=yes
-fi
-rm -rf conftest*
 
-  fi
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_gcc_traditional" >&5
-printf "%s\n" "$ac_cv_prog_gcc_traditional" >&6; }
-  if test $ac_cv_prog_gcc_traditional = yes; then
-    CC="$CC -traditional"
-  fi
-fi
 
 
 
@@ -5885,14 +5579,16 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_gcc_Winit_self" >&5
 printf "%s\n" "$ntp_cv_gcc_Winit_self" >&6; }
+    #
+    # $ntp_cv_gcc_Winit_self is tested later to add the
+    # flag to CFLAGS_NTP.
     #
     # libopts specifically builds a string with embedded NULs.
     # This causes a bunch of distracting warnings due to -Wformat.
-    # Let's see if we can figure out how to disable these.
     #
-    CFLAGS="$SAVED_CFLAGS -Wno-format"
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC can handle -Wno-format" >&5
-printf %s "checking if $CC can handle -Wno-format... " >&6; }
+    CFLAGS="$SAVED_CFLAGS -Wno-format -Wno-format-security"
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC can handle -Wno-format -Wno-format-security" >&5
+printf %s "checking if $CC can handle -Wno-format -Wno-format-security... " >&6; }
 if test ${ntp_cv_gcc_Wno_format+y}
 then :
   printf %s "(cached) " >&6
@@ -5922,21 +5618,50 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_gcc_Wno_format" >&5
 printf "%s\n" "$ntp_cv_gcc_Wno_format" >&6; }
-
     case "$ntp_cv_gcc_Wno_format" in
+      no) ntp_cv_gcc_Wno_format_truncation=no
+	  ;;
      yes)
-	CC_NOFORMAT="$CC_NOFORMAT -Wno-format"
-	;;
-     no)
-	;;
+	CC_NOFORMAT="-Wno-format -Wno-format-security"
+	CFLAGS="$SAVED_CFLAGS -Wformat -Wno-format-truncation -Werror"
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC can handle -Wformat -Wno-format-truncation" >&5
+printf %s "checking if $CC can handle -Wformat -Wno-format-truncation... " >&6; }
+if test ${ntp_cv_gcc_Wno_format_truncation+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main (void)
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+  ntp_cv_gcc_Wno_format_truncation=yes
+else $as_nop
+  ntp_cv_gcc_Wno_format_truncation=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_gcc_Wno_format_truncation" >&5
+printf "%s\n" "$ntp_cv_gcc_Wno_format_truncation" >&6; }
+	#
+	# $ntp_cv_gcc_Wno_format_truncation is tested later to add the
+	# flag to CFLAGS.
+	#
     esac
 
     CFLAGS="$SAVED_CFLAGS"
     { SAVED_CFLAGS=; unset SAVED_CFLAGS;}
-    #
-    # $ntp_cv_gcc_Winit_self is tested later to add the
-    # flag to CFLAGS_NTP.
-    #
+
     { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if linker supports omitting unused code and data" >&5
 printf %s "checking if linker supports omitting unused code and data... " >&6; }
 if test ${ntp_cv_gc_sections_runs+y}
@@ -5944,7 +5669,17 @@ then :
   printf %s "(cached) " >&6
 else $as_nop
 
-	    	    	    	    	    	    	    	    	    	    	    origCFLAGS="$CFLAGS"
+	    #  NetBSD will link but likely not run with --gc-sections
+	    #  http://bugs.ntp.org/1844
+	    #  http://gnats.netbsd.org/40401
+	    #  --gc-sections causes attempt to load as linux elf, with
+	    #  wrong syscalls in place.  Test a little gauntlet of
+	    #  simple stdio read code checking for errors, expecting
+	    #  enough syscall differences that the NetBSD code will
+	    #  fail even with Linux emulation working as designed.
+	    #  A shorter test could be refined by someone with access
+	    #  to a NetBSD host with Linux emulation working.
+	    origCFLAGS="$CFLAGS"
 	    CFLAGS="$CFLAGS -Wl,--gc-sections"
 	    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
@@ -6034,6 +5769,10 @@ printf "%s\n" "$ntp_cv_gc_sections_runs" >&6; }
      yes)
 	CFLAGS_NTP="$CFLAGS_NTP -Wstrict-overflow"
     esac
+    case "$ntp_cv_gcc_Wno_format_truncation" in
+     yes)
+	CFLAGS_NTP="$CFLAGS_NTP -Wno-format-truncation"
+    esac
     # -W[no-]strict-prototypes might be added by NTP_OPENSSL
 esac
 
@@ -7080,38 +6819,6 @@ esac
 
 # So far, the only shared library we might use is libopts.
 # It's a small library - we might as well use a static version of it.
-# Check whether --enable-shared was given.
-if test ${enable_shared+y}
-then :
-  enableval=$enable_shared; p=${PACKAGE-default}
-    case $enableval in
-    yes) enable_shared=yes ;;
-    no) enable_shared=no ;;
-    *)
-      enable_shared=no
-      # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
-      for pkg in $enableval; do
-	IFS=$lt_save_ifs
-	if test "X$pkg" = "X$p"; then
-	  enable_shared=yes
-	fi
-      done
-      IFS=$lt_save_ifs
-      ;;
-    esac
-else $as_nop
-  enable_shared=no
-fi
-
-
-
-
-
-
-
-
-
 case `pwd` in
   *\ * | *\	*)
     { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
@@ -7295,6 +7002,148 @@ Xsed="$SED -e 1s/^X//"
 
 
 
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
+printf %s "checking for grep that handles long lines and -e... " >&6; }
+if test ${ac_cv_path_GREP+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  if test -z "$GREP"; then
+  ac_path_GREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_prog in grep ggrep
+   do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_GREP="$as_dir$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_GREP" || continue
+# Check for GNU ac_path_GREP and select it if it is found.
+  # Check for GNU $ac_path_GREP
+case `"$ac_path_GREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
+*)
+  ac_count=0
+  printf %s 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    printf "%s\n" 'GREP' >> "conftest.nl"
+    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_GREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_GREP="$ac_path_GREP"
+      ac_path_GREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_GREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_GREP"; then
+    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_GREP=$GREP
+fi
+
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
+printf "%s\n" "$ac_cv_path_GREP" >&6; }
+ GREP="$ac_cv_path_GREP"
+
+
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
+printf %s "checking for egrep... " >&6; }
+if test ${ac_cv_path_EGREP+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+   then ac_cv_path_EGREP="$GREP -E"
+   else
+     if test -z "$EGREP"; then
+  ac_path_EGREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_prog in egrep
+   do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_EGREP="$as_dir$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_EGREP" || continue
+# Check for GNU ac_path_EGREP and select it if it is found.
+  # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+  ac_count=0
+  printf %s 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    printf "%s\n" 'EGREP' >> "conftest.nl"
+    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_EGREP="$ac_path_EGREP"
+      ac_path_EGREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_EGREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_EGREP"; then
+    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_EGREP=$EGREP
+fi
+
+   fi
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
+printf "%s\n" "$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
+
+
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5
 printf %s "checking for fgrep... " >&6; }
 if test ${ac_cv_path_FGREP+y}
@@ -10575,6 +10424,36 @@ fi
 
 
 # Set options
+# Check whether --enable-shared was given.
+if test ${enable_shared+y}
+then :
+  enableval=$enable_shared; p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_shared=yes ;;
+    no) enable_shared=no ;;
+    *)
+      enable_shared=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
+      for pkg in $enableval; do
+	IFS=$lt_save_ifs
+	if test "X$pkg" = "X$p"; then
+	  enable_shared=yes
+	fi
+      done
+      IFS=$lt_save_ifs
+      ;;
+    esac
+else $as_nop
+  enable_shared=no
+fi
+
+
+
+
+
+
+
 
 
 
@@ -14874,7 +14753,7 @@ CC=$lt_save_CC
 # Therefore, by default:
 # - use the version of libopts we ship with
 # - do not install it
-# - build a static copy (AC_DISABLE_SHARED - done earlier)
+# - build a static copy (disable-shared - done earlier)
 case "${enable_local_libopts+set}" in
  set) ;;
  *) enable_local_libopts=yes ;;
@@ -16526,8 +16405,6 @@ case "$ntp_use_local_libevent" in
  *) # If we have (a good enough) pkg-config, see if it can find libevent
     case "$PKG_CONFIG" in
      /*)
-	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if libevent $ntp_libevent_min_version or later is installed" >&5
-printf %s "checking if libevent $ntp_libevent_min_version or later is installed... " >&6; }
 	if $PKG_CONFIG --atleast-version=$ntp_libevent_min_version libevent
 	then
 	    ntp_use_local_libevent=no
@@ -16536,6 +16413,8 @@ printf %s "checking if libevent $ntp_libevent_min_version or later is installed.
 	     *.*) ;;
 	     *) ntp_libevent_version='(unknown)' ;;
 	    esac
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if libevent $ntp_libevent_min_version or later is installed" >&5
+printf %s "checking if libevent $ntp_libevent_min_version or later is installed... " >&6; }
 	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes, version $ntp_libevent_version" >&5
 printf "%s\n" "yes, version $ntp_libevent_version" >&6; }
 	    CFLAGS_LIBEVENT=`$PKG_CONFIG --cflags libevent_pthreads`
@@ -16570,6 +16449,8 @@ printf "%s\n" "yes, version $ntp_libevent_version" >&6; }
 	    # HMS: do we only need to do this if LIBISC_PTHREADS_NOTHREADS
 	    # is "pthreads"?
 	    CFLAGS_LIBEVENT=`$PKG_CONFIG --cflags libevent_pthreads`
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if libevent $ntp_libevent_min_version or later is installed" >&5
+printf %s "checking if libevent $ntp_libevent_min_version or later is installed... " >&6; }
 	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
 printf "%s\n" "no" >&6; }
 	fi
@@ -17483,11 +17364,23 @@ fi
 
 
 
+VER_SUFFIX=
+
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: " >&5
+printf "%s\n" "$as_me: " >&6;}
+	esac
+
+
+
+
+
+
 
 # HMS: Save $LIBS and empty it.
 # any LIBS we add here should go in to LDADD_LIBNTP
 
-__LIBS=$LIBS
+SAVED_LIBS=$LIBS
 LIBS=
 
 
@@ -19228,14 +19121,6 @@ printf "%s\n" "#define HAVE_INLINE 1" >>confdefs.h
 esac
 
 
-# Obsolete code to be removed.
-if test $ac_cv_header_sys_time_h = yes; then
-
-printf "%s\n" "#define TIME_WITH_SYS_TIME 1" >>confdefs.h
-
-fi
-# End of obsolete code.
-
 # The cast to long int works around a bug in the HP C Compiler
 # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
 # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
@@ -25091,100 +24976,6 @@ fi
 
 
 
-case "$ac_cv_type_int32::$ac_cv_header_resolv_h" in
- no::yes)
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for int32 with DNS headers included" >&5
-printf %s "checking for int32 with DNS headers included... " >&6; }
-if test ${ntp_cv_type_int32_with_dns+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-		    #ifdef HAVE_ARPA_NAMESER_H
-		    # include <arpa/nameser.h>
-		    #endif
-		    #include <resolv.h>
-
-int
-main (void)
-{
-
-		    size_t cb = sizeof(int32);
-
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"
-then :
-  ntp_cv_type_int32_with_dns=yes
-else $as_nop
-  ntp_cv_type_int32_with_dns=no
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
-
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_type_int32_with_dns" >&5
-printf "%s\n" "$ntp_cv_type_int32_with_dns" >&6; }
-    case "$ntp_cv_type_int32_with_dns" in
-     yes)
-
-printf "%s\n" "#define HAVE_INT32_ONLY_WITH_DNS 1" >>confdefs.h
-
-    esac
-esac
-
-case "$ac_cv_type_u_int32::$ac_cv_header_resolv_h" in
- no::yes)
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for u_int32 with DNS headers included" >&5
-printf %s "checking for u_int32 with DNS headers included... " >&6; }
-if test ${ntp_cv_type_u_int32_with_dns+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-		    #ifdef HAVE_ARPA_NAMESER_H
-		    # include <arpa/nameser.h>
-		    #endif
-		    #include <resolv.h>
-
-int
-main (void)
-{
-
-		    size_t cb = sizeof(u_int32);
-
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"
-then :
-  ntp_cv_type_u_int32_with_dns=yes
-else $as_nop
-  ntp_cv_type_u_int32_with_dns=no
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
-
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_type_u_int32_with_dns" >&5
-printf "%s\n" "$ntp_cv_type_u_int32_with_dns" >&6; }
-    case "$ntp_cv_type_u_int32_with_dns" in
-     yes)
-
-printf "%s\n" "#define HAVE_U_INT32_ONLY_WITH_DNS 1" >>confdefs.h
-
-    esac
-esac
-
 ac_fn_c_check_header_compile "$LINENO" "sys/timepps.h" "ac_cv_header_sys_timepps_h" "
 	#ifdef HAVE_SYS_TIME_H
 	# include <sys/time.h>
@@ -25766,34 +25557,1192 @@ printf "%s\n" "$as_me: WARNING: *** $ntp_warning ***" >&2;}
     ;;
 esac
 
+ if test x"$enable_dependency_tracking" = x"yes"; then
+  LIBNTP_SUBMAKES_TRUE=
+  LIBNTP_SUBMAKES_FALSE='#'
+else
+  LIBNTP_SUBMAKES_TRUE='#'
+  LIBNTP_SUBMAKES_FALSE=
+fi
 
-LDADD_LIBNTP="$LDADD_LIBNTP $LIBS"
-LIBS=$__LIBS
-{ __LIBS=; unset __LIBS;}
 
 
 
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for deprecated --with-arlib" >&5
-printf %s "checking for deprecated --with-arlib... " >&6; }
 
-# Check whether --with-arlib was given.
-if test ${with_arlib+y}
+# Check whether --with-crypto was given.
+if test ${with_crypto+y}
 then :
-  withval=$with_arlib; ans=$withval
+  withval=$with_crypto; 		case "$with_crypto" in
+	 yes)
+	    with_crypto=openssl,libcrypto
+	esac
+
 else $as_nop
-  ans=no
+  with_crypto=openssl,libcrypto
 fi
 
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ans" >&5
-printf "%s\n" "$ans" >&6; }
 
-case "$ans" in
+# Check whether --with-openssl-libdir was given.
+if test ${with_openssl_libdir+y}
+then :
+  withval=$with_openssl_libdir;
+fi
+
+
+# Check whether --with-openssl-incdir was given.
+if test ${with_openssl_incdir+y}
+then :
+  withval=$with_openssl_incdir;
+fi
+
+# Check whether --enable-verbose-ssl was given.
+if test ${enable_verbose_ssl+y}
+then :
+  enableval=$enable_verbose_ssl;
+else $as_nop
+  enable_verbose_ssl=no
+fi
+
+
+ntp_openssl=no
+ntp_openssl_from_pkg_config=no
+ntp_ssl_incdir=
+ntp_ssl_cflags=
+ntp_ssl_cppflags=
+ntp_ssl_libdir=
+ntp_ssl_libs_L=
+ntp_ssl_libs_l=
+ntp_ssl_libs=
+ntp_ssl_ldflags=
+
+NTPSSL_SAVED_CFLAGS="$CFLAGS"
+NTPSSL_SAVED_CPPFLAGS="$CPPFLAGS"
+NTPSSL_SAVED_LIBS="$LIBS"
+NTPSSL_SAVED_LDFLAGS="$LDFLAGS"
+
+# Extract the first word of "openssl", so it can be a program name with args.
+set dummy openssl; ac_word=$2
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_path_PATH_OPENSSL+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  case $PATH_OPENSSL in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PATH_OPENSSL="$PATH_OPENSSL" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_path_PATH_OPENSSL="$as_dir$ac_word$ac_exec_ext"
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+PATH_OPENSSL=$ac_cv_path_PATH_OPENSSL
+if test -n "$PATH_OPENSSL"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PATH_OPENSSL" >&5
+printf "%s\n" "$PATH_OPENSSL" >&6; }
+else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+fi
+
+
+
+str="$with_crypto:${PKG_CONFIG:+notempty}:${with_openssl_libdir-notgiven}:${with_openssl_incdir-notgiven}"
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: $str" >&5
+printf "%s\n" "$as_me: $str" >&6;}
+	esac
+
+
+{ str=; unset str;}
+
+# Make sure neither/both --with_openssl-{inc,lib}dir are given
+case "${with_openssl_libdir-notgiven}:${with_openssl_incdir-notgiven}" in
+ notgiven:notgiven) ;;
+ *notgiven*)
+    as_fn_error $? "only one of --with-openssl-{inc,lib}dir=... given - provide both or neither" "$LINENO" 5
+    ;;
+esac
+
+# HMS: Today there are only 2 case options.  We probably want a third
+# *:*:notgiven:notgiven
+# and in that case we would validate the path in PKG_CONFIG_PATH.
+# Unless we can do it with 2 cases, where the 2nd case is *:*:...
+# and we do a reality check on execpath and the headers/libraries.
+#
+##
+# if $with_crypto is not "no":
+#   if --with-openssl-{inc,lib}dir are not given:
+#     we should use pkg-config to find openssl
+#     if we don't have pkg-config, if openssl is in the base OS, use that.
+##
+case "$with_crypto:${PKG_CONFIG:+notempty}:${with_openssl_libdir-notgiven}:${with_openssl_incdir-notgiven}" in
+ no:*) ;;
+ *:notempty:notgiven:notgiven)
+    # If PKG_CONFIG is notempty and we haven't been given openssl paths,
+    # then let's make sure that the openssl executable's path corresponds
+    # to the path in openssl.pc, and 'openssl version' matches the Version
+    # in openssl.pc.  If $PKG_CONFIG tells us an INCPATH and/or a LIBPATH,
+    # then should we reality check them?
+    ## INCPATH
+    # harlan@ntp-testbuild.tal1> openssl version
+    # OpenSSL 1.1.1t  7 Feb 2023
+    # harlan@ntp-testbuild.tal1> grep 1.1.1t /ntpbuild/include/openssl/*
+    # /ntpbuild/include/openssl/opensslv.h:# define OPENSSL_VERSION_TEXT    "OpenSSL 1.1.1t  7 Feb 2023"
+    # harlan@ntp-testbuild.tal1>
+    ## LIBPATH
+    # harlan@ntp-testbuild.tal1> strings -a /ntpbuild/lib/libcrypto.* | fgrep 1.1.1t
+    # OpenSSL 1.1.1t  7 Feb 2023
+    # OpenSSL 1.1.1t  7 Feb 2023
+    # OpenSSL 1.1.1t  7 Feb 2023
+    # harlan@ntp-testbuild.tal1> ls /ntpbuild/lib/libcrypto.*
+    # /ntpbuild/lib/libcrypto.a       /ntpbuild/lib/libcrypto.so.1.1*
+    # /ntpbuild/lib/libcrypto.so@
+    # harlan@ntp-testbuild.tal1>
+    ##
+    # Having said this, do we really care if the openssl executable that
+    # we have found is matched with the INCPATH and LIBPATH?
+    # One answer: Probably not, but we should complain on a mismatch as
+    # otherwise runtime differences could easily cause problems/drama.
+
+    ##BO
+    # ntp_cv_build_framework_help=yes
+    save_PKG_CONFIG_PATH=${PKG_CONFIG_PATH}
+    for pkg in `echo $with_crypto | $SED -e 's/,/ /'`; do
+        case "$pkg" in
+	 openssl)
+	    if $PKG_CONFIG --exists $pkg ; then
+		# Found it - yay
+		# Do we want to check we found the right one?
+		# --modver
+		# --variable={libdir,includedir} (varname)
+		overf=`openssl version`
+		overs=`echo $overf | awk '{print }'`
+		case "$overs" in
+		 0.*) ;;	# Should we squawk?
+		 1.0.*) ;;	# Should we squawk?
+		 1.1.*) ;;	# Should we squawk?
+		 3.*)
+		    oinc=`openssl --variable=includedir`
+		    olib=`openssl --variable=libdir`
+		    # How should we use these?
+		    ;;
+		 *) ;;	# Should we squawk?
+		esac
+		# /ntpbuild/include/openssl/opensslv.h:# define OPENSSL_VERSION_TEXT    "OpenSSL 1.1.1t  7 Feb 2023"
+		# grep 1.1.1t /ntpbuild/lib/libcrypto.a
+		# strings -a /ntpbuild/lib/libcrypto.a | grep 1.1.1t
+		# OpenSSL 1.1.1t  7 Feb 2023
+		# harlan@ntp-testbuild.tal1>
+		# which should match $overf
+		##
+		# harlan@ntp-testbuild.tal1> echo '"OpenSSL 1.1.1t  7 Feb 2023"' | cut -f 2 -d\"
+		# OpenSSL 1.1.1t  7 Feb 2023
+		# harlan@ntp-testbuild.tal1> grep OPENSSL_VERSION_TEXT /ntpbuild/include/openssl/opensslv.h
+		# # define OPENSSL_VERSION_TEXT    "OpenSSL 1.1.1t  7 Feb 2023"
+		# harlan@ntp-testbuild.tal1>
+		##
+
+	    else
+		# This is a hack, but it's reasonable.
+		pkgpath="`echo $PATH_OPENSSL | sed -e 's:/bin/openssl$::'`/lib/pkgconfig"
+		test -d "$pkgpath" || pkgpath=
+		# echo "pkgpath is <$pkgpath>"
+		# echo "PKG_CONFIG_PATH is <$PKG_CONFIG_PATH>"
+		case "$pkgpath" in
+		 '') ;;	# Nothing to see here...
+		 *) case ":$PKG_CONFIG_PATH:" in
+		     ::)
+			PKG_CONFIG_PATH=$pkgpath
+			export PKG_CONFIG_PATH
+			;;
+		     *:$pkgpath:*)
+			# Already there...
+			;;
+		     *)
+			PKG_CONFIG_PATH="$pkgpath:$PKG_CONFIG_PATH"
+			export PKG_CONFIG_PATH
+			;;
+		    esac
+		    ;;
+		esac
+	    fi
+	    ;;
+        esac
+    done
+    ##EO
+
+    for pkg in `echo $with_crypto | $SED -e 's/,/ /'`; do
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking pkg-config for $pkg" >&5
+printf %s "checking pkg-config for $pkg... " >&6; }
+	if $PKG_CONFIG --exists $pkg ; then
+	    ntp_ssl_cppflags="`$PKG_CONFIG --cflags-only-I $pkg`"
+	    case "$ntp_ssl_cppflags" in
+	     '')
+		ntp_ssl_incdir='not needed'
+		;;
+	     *)
+		ntp_ssl_incdir="`echo $ntp_ssl_cppflags | $SED -e 's/-I//'`"
+	    esac
+	    ntp_ssl_cflags="`$PKG_CONFIG --cflags-only-other $pkg`"
+	    ntp_ssl_libs_L="`$PKG_CONFIG --libs-only-L $pkg`"
+	    case "$ntp_ssl_libs_L" in
+	     '')
+		ntp_ssl_libdir='not needed'
+		;;
+	     *)
+		ntp_ssl_libdir="`echo $ntp_ssl_libs_L | $SED -e 's/-L//'`"
+	    esac
+	    ntp_ssl_libs_l="`$PKG_CONFIG --libs-only-l $pkg`"
+	    ntp_ssl_libs="$ntp_ssl_libs_L $ntp_ssl_libs_l"
+	    ntp_ssl_ldflags="`$PKG_CONFIG --libs-only-other $pkg`"
+	    ntp_openssl=yes
+	    ntp_openssl_from_pkg_config=yes
+	    ntp_openssl_version="`$PKG_CONFIG --modversion $pkg`"
+	    case "$ntp_openssl_version" in
+	     *.*) ;;
+	     *) ntp_openssl_version='(unknown)' ;;
+	    esac
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes, version $ntp_openssl_version" >&5
+printf "%s\n" "yes, version $ntp_openssl_version" >&6; }
+
+	    break
+	fi
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+    done
+    { pkg=; unset pkg;}
+esac
+case "$with_crypto" in
+ no) ;;
+ *)
+    case "$with_openssl_libdir" in
+     '') ;;
+     *)
+	ntp_ssl_libdir="$with_openssl_libdir"
+	ntp_ssl_libs_L="-L$with_openssl_libdir"
+	ntp_ssl_libs_l="-lcrypto"
+	ntp_ssl_libs="$ntp_ssl_libs_L $ntp_ssl_libs_l"
+    esac
+    case "$with_openssl_incdir" in
+     '') ;;
+     *)
+	ntp_ssl_incdir="$with_openssl_incdir"
+	ntp_ssl_cppflags="-I$with_openssl_incdir"
+    esac
+esac
+
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: OpenSSL Phase I checks:" >&5
+printf "%s\n" "$as_me: OpenSSL Phase I checks:" >&6;}
+	esac
+
+
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: CPPFLAGS_NTP: ($CPPFLAGS_NTP)" >&5
+printf "%s\n" "$as_me: CPPFLAGS_NTP: ($CPPFLAGS_NTP)" >&6;}
+	esac
+
+
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: CFLAGS_NTP:   ($CFLAGS_NTP)" >&5
+printf "%s\n" "$as_me: CFLAGS_NTP:   ($CFLAGS_NTP)" >&6;}
+	esac
+
+
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: LDADD_NTP:    ($LDADD_NTP)" >&5
+printf "%s\n" "$as_me: LDADD_NTP:    ($LDADD_NTP)" >&6;}
+	esac
+
+
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: LDFLAGS_NTP:  ($LDFLAGS_NTP)" >&5
+printf "%s\n" "$as_me: LDFLAGS_NTP:  ($LDFLAGS_NTP)" >&6;}
+	esac
+
+
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_openssl_from_pkg_config: $ntp_openssl_from_pkg_config" >&5
+printf "%s\n" "$as_me: ntp_openssl_from_pkg_config: $ntp_openssl_from_pkg_config" >&6;}
+	esac
+
+
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_ssl_incdir:   ($ntp_ssl_incdir)" >&5
+printf "%s\n" "$as_me: ntp_ssl_incdir:   ($ntp_ssl_incdir)" >&6;}
+	esac
+
+
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_ssl_libdir:   ($ntp_ssl_libdir)" >&5
+printf "%s\n" "$as_me: ntp_ssl_libdir:   ($ntp_ssl_libdir)" >&6;}
+	esac
+
+
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_ssl_cflags:   ($ntp_ssl_cflags)" >&5
+printf "%s\n" "$as_me: ntp_ssl_cflags:   ($ntp_ssl_cflags)" >&6;}
+	esac
+
+
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_ssl_cppflags: ($ntp_ssl_cppflags)" >&5
+printf "%s\n" "$as_me: ntp_ssl_cppflags: ($ntp_ssl_cppflags)" >&6;}
+	esac
+
+
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_ssl_libs_L:   ($ntp_ssl_libs_L)" >&5
+printf "%s\n" "$as_me: ntp_ssl_libs_L:   ($ntp_ssl_libs_L)" >&6;}
+	esac
+
+
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_ssl_libs_l:   ($ntp_ssl_libs_l)" >&5
+printf "%s\n" "$as_me: ntp_ssl_libs_l:   ($ntp_ssl_libs_l)" >&6;}
+	esac
+
+
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_ssl_libs:     ($ntp_ssl_libs)" >&5
+printf "%s\n" "$as_me: ntp_ssl_libs:     ($ntp_ssl_libs)" >&6;}
+	esac
+
+
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_ssl_ldflags:  ($ntp_ssl_ldflags)" >&5
+printf "%s\n" "$as_me: ntp_ssl_ldflags:  ($ntp_ssl_ldflags)" >&6;}
+	esac
+
+
+
+case "$with_crypto" in
+ no)
+    ntp_openssl=no
+    ;;
+ *)
+    ntp_ssl_libs_l="${ntp_ssl_libs_l:--lcrypto}"
+    ntp_ssl_libs="$ntp_ssl_libs_L $ntp_ssl_libs_l"
+    case "$ntp_ssl_libdir" in
+     '')
+
+		{ ac_cv_lib_crypto_EVP_MD_CTX_new=; unset ac_cv_lib_crypto_EVP_MD_CTX_new;}
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: Searching for libcrypto without -L" >&5
+printf "%s\n" "$as_me: Searching for libcrypto without -L" >&6;}
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for EVP_MD_CTX_new in -lcrypto" >&5
+printf %s "checking for EVP_MD_CTX_new in -lcrypto... " >&6; }
+if test ${ac_cv_lib_crypto_EVP_MD_CTX_new+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lcrypto  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+char EVP_MD_CTX_new ();
+int
+main (void)
+{
+return EVP_MD_CTX_new ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
+then :
+  ac_cv_lib_crypto_EVP_MD_CTX_new=yes
+else $as_nop
+  ac_cv_lib_crypto_EVP_MD_CTX_new=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_EVP_MD_CTX_new" >&5
+printf "%s\n" "$ac_cv_lib_crypto_EVP_MD_CTX_new" >&6; }
+if test "x$ac_cv_lib_crypto_EVP_MD_CTX_new" = xyes
+then :
+  ntp_ssl_libdir='not needed'
+
+fi
+
+		{ ac_cv_lib_crypto_EVP_MD_CTX_new=; unset ac_cv_lib_crypto_EVP_MD_CTX_new;}
+    esac
+    case "$ntp_ssl_libdir" in
+     '')
+	ntp_ssl_libdir_search="/usr/lib /usr/lib/openssl /usr/sfw/lib"
+	ntp_ssl_libdir_search="$ntp_ssl_libdir_search /usr/local/lib"
+	ntp_ssl_libdir_search="$ntp_ssl_libdir_search /usr/local/ssl/lib"
+	ntp_ssl_libdir_search="$ntp_ssl_libdir_search /opt/local/lib"
+	ntp_ssl_libdir_search="$ntp_ssl_libdir_search /lib /lib64"
+	;;
+     *)
+	ntp_ssl_libdir_search="$ntp_ssl_libdir"
+    esac
+    case $ntp_ssl_libdir_search in
+     'not needed') ;;
+     *)
+	for i in $ntp_ssl_libdir_search not_found
+	do
+	    case "$i" in
+	     not_found) ;;
+	     *)
+		{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: Searching for libcrypto in $i" >&5
+printf "%s\n" "$as_me: Searching for libcrypto in $i" >&6;}
+		LIBS="-L$i $NTPSSL_SAVED_LIBS"
+		{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for EVP_MD_CTX_new in -lcrypto" >&5
+printf %s "checking for EVP_MD_CTX_new in -lcrypto... " >&6; }
+if test ${ac_cv_lib_crypto_EVP_MD_CTX_new+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lcrypto  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+char EVP_MD_CTX_new ();
+int
+main (void)
+{
+return EVP_MD_CTX_new ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
+then :
+  ac_cv_lib_crypto_EVP_MD_CTX_new=yes
+else $as_nop
+  ac_cv_lib_crypto_EVP_MD_CTX_new=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_EVP_MD_CTX_new" >&5
+printf "%s\n" "$ac_cv_lib_crypto_EVP_MD_CTX_new" >&6; }
+if test "x$ac_cv_lib_crypto_EVP_MD_CTX_new" = xyes
+then :
+  break
+
+fi
+
+				{ ac_cv_lib_crypto_EVP_MD_CTX_new=; unset ac_cv_lib_crypto_EVP_MD_CTX_new;}
+	    esac
+	done
+	ntp_ssl_libdir="$i"
+	ntp_ssl_libs_L="-L$i"
+	ntp_ssl_libs="$ntp_ssl_libs_L $ntp_ssl_libs_l"
+	LIBS="$NTPSSL_SAVED_LIBS"
+	case "$ntp_ssl_libdir" in
+	 not_found)
+	    as_fn_error $? "You may want to use --without-crypto, or add
+openssl.pc/libcrypto.pc to PKG_CONFIG_PATH, or use the
+--with-openssl-libdir=/some/path option to configure.
+libcrypto not found in any of the following directories:
+$ntp_ssl_libdir_search
+	    " "$LINENO" 5
+	esac
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: libcrypto found in $ntp_ssl_libdir" >&5
+printf "%s\n" "$as_me: libcrypto found in $ntp_ssl_libdir" >&6;}
+    esac
+
+    case "$ntp_openssl_from_pkg_config:$ntp_ssl_incdir" in
+     'yes:not needed' | no:)
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: Searching for openssl/evp.h without -I" >&5
+printf "%s\n" "$as_me: Searching for openssl/evp.h without -I" >&6;}
+		{ ac_cv_header_openssl_evp_h=; unset ac_cv_header_openssl_evp_h;}
+	ac_fn_c_check_header_compile "$LINENO" "openssl/evp.h" "ac_cv_header_openssl_evp_h" "$ac_includes_default"
+if test "x$ac_cv_header_openssl_evp_h" = xyes
+then :
+  ntp_ssl_incdir='not needed'
+
+fi
+
+    esac
+    case "$ntp_ssl_incdir" in
+     'not needed')
+	ntp_ssl_incdir_search="$ntp_ssl_incdir"
+	;;
+     *)
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: Searching for openssl include directory" >&5
+printf "%s\n" "$as_me: Searching for openssl include directory" >&6;}
+	case "$with_openssl_incdir" in
+	 '')
+	    case "$ntp_ssl_incdir" in
+	     '')
+		ntp_ssl_incdir_search="/usr/include /usr/sfw/include"
+		ntp_ssl_incdir_search="$ntp_ssl_incdir_search /usr/local/include"
+		ntp_ssl_incdir_search="$ntp_ssl_incdir_search /opt/local/include"
+		ntp_ssl_incdir_search="$ntp_ssl_incdir_search /usr/local/ssl/include"
+		;;
+	     *)
+	    esac
+	    ;;
+	 *)
+	    ntp_ssl_incdir_search="$with_openssl_incdir"
+	esac
+	case $ntp_ssl_incdir_search in
+	 'not needed') ;;
+	 *)
+	    for i in $ntp_ssl_incdir_search
+	    do
+		{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: Searching for openssl/evp.h in $i" >&5
+printf "%s\n" "$as_me: Searching for openssl/evp.h in $i" >&6;}
+		CPPFLAGS="$NTPSSL_SAVED_CPPFLAGS -I$i"
+				{ ac_cv_header_openssl_evp_h=; unset ac_cv_header_openssl_evp_h;}
+		ac_fn_c_check_header_compile "$LINENO" "openssl/evp.h" "ac_cv_header_openssl_evp_h" "$ac_includes_default"
+if test "x$ac_cv_header_openssl_evp_h" = xyes
+then :
+  ntp_ssl_incdir="$i" ; break
+
+fi
+
+	    done
+	    { ac_cv_header_openssl_evp_h=; unset ac_cv_header_openssl_evp_h;}
+	    { i=; unset i;}
+	    CPPFLAGS="$NTPSSL_SAVED_CPPFLAGS"
+	    case "$ntp_ssl_incdir" in
+	     '')
+		as_fn_error $? "You may want to use --without-crypto, or add
+openssl.pc/libcrypto.pc to PKG_CONFIG_PATH, or use the
+-with-openssl-incdir=/some/path option to configure.
+No usable openssl/evp.h found in any of the following direcotries:
+$ntp_ssl_incdir_search
+		" "$LINENO" 5
+	    esac
+	    ntp_ssl_cppflags="-I$ntp_ssl_incdir"
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Found evp.h in $ntp_ssl_incdir/openssl" >&5
+printf "%s\n" "$as_me: Found evp.h in $ntp_ssl_incdir/openssl" >&6;}
+	esac
+    esac
+    ntp_openssl=yes
+esac
+case "$ntp_openssl:$ntp_ssl_libdir" in
+ 'yes:not needed')
+    ;;
+ yes:*)
+    CFLAGS="$NTPSSL_SAVED_CFLAGS $ntp_ssl_cflags"
+    CPPFLAGS="$NTPSSL_SAVED_CPPFLAGS $ntp_ssl_cppflags"
+    LIBS="$ntp_ssl_libs $NTPSSL_SAVED_LIBS"
+    LDFLAGS="$ntp_ssl_ldflags $NTPSSL_SAVED_LDFLAGS"
+        { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if crypto works without runpath" >&5
+printf %s "checking if crypto works without runpath... " >&6; }
+if test ${ntp_cv_ssl_without_runpath+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  if test "$cross_compiling" = yes
+then :
+  ntp_cv_ssl_without_runpath=yes
+else $as_nop
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+		    #include "openssl/evp.h"
+
+int
+main (void)
+{
+
+		    if (!EVP_MD_CTX_new()) {
+			return 1;
+		    }
+
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"
+then :
+  ntp_cv_ssl_without_runpath=yes
+else $as_nop
+  ntp_cv_ssl_without_runpath=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_ssl_without_runpath" >&5
+printf "%s\n" "$ntp_cv_ssl_without_runpath" >&6; }
+    case "$ntp_cv_ssl_without_runpath" in
+     no)
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if crypto needs -Wl,-rpath,$ntp_ssl_libdir" >&5
+printf %s "checking if crypto needs -Wl,-rpath,$ntp_ssl_libdir... " >&6; }
+if test ${ntp_cv_ssl_needs_dashWl_rpath+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+
+		LDFLAGS="$ntp_ssl_ldflags -Wl,-rpath,$ntp_ssl_libdir $NTPSSL_SAVED_LDFLAGS"
+		if test "$cross_compiling" = yes
+then :
+  { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot run test program while cross compiling
+See \`config.log' for more details" "$LINENO" 5; }
+else $as_nop
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+			    #include "openssl/evp.h"
+
+int
+main (void)
+{
+
+			    if (!EVP_MD_CTX_new()) {
+				return 1;
+			    }
+
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"
+then :
+  ntp_cv_ssl_needs_dashWl_rpath=yes
+else $as_nop
+  ntp_cv_ssl_needs_dashWl_rpath=no
+
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+
+
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_ssl_needs_dashWl_rpath" >&5
+printf "%s\n" "$ntp_cv_ssl_needs_dashWl_rpath" >&6; }
+	case "$ntp_cv_ssl_needs_dashWl_rpath" in
+	 yes)
+	    ntp_ssl_ldflags="$ntp_ssl_ldflags -Wl,-rpath,$ntp_ssl_libdir"
+	    ;;
+	 no)
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if crypto needs -R$ntp_ssl_libdir" >&5
+printf %s "checking if crypto needs -R$ntp_ssl_libdir... " >&6; }
+if test ${ntp_cv_ssl_needs_dashR+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+
+		    LDFLAGS="$NTPSSL_SAVED_LDFLAGS $ntp_ssl_ldflags -R$ntp_ssl_libdir"
+		    if test "$cross_compiling" = yes
+then :
+  { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot run test program while cross compiling
+See \`config.log' for more details" "$LINENO" 5; }
+else $as_nop
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+				#include "openssl/evp.h"
+
+int
+main (void)
+{
+
+				if (!EVP_MD_CTX_new()) {
+				    return 1;
+				}
+
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"
+then :
+  ntp_cv_ssl_needs_dashR=yes
+else $as_nop
+  ntp_cv_ssl_needs_dashR=no
+
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+
+
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_ssl_needs_dashR" >&5
+printf "%s\n" "$ntp_cv_ssl_needs_dashR" >&6; }
+	    case "$ntp_cv_ssl_needs_dashR" in
+	     yes)
+		ntp_ssl_ldflags="$ntp_ssl_ldflags -R$ntp_ssl_libdir"
+	    esac
+	    case "$build:$ntp_cv_ssl_needs_dashR" in
+	     $host:no)
+		{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "Unable to run program using crypto, check openssl.pc
+or libcrypto.pc are in PKG_CONFIG_PATH, or provide the
+ --with-openssl-libdir=/some/path option to configure.
+
+See \`config.log' for more details" "$LINENO" 5; }
+	    esac
+	esac
+    esac
+esac
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: OpenSSL Phase II checks:" >&5
+printf "%s\n" "$as_me: OpenSSL Phase II checks:" >&6;}
+	esac
+
+
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_ssl_incdir:   ($ntp_ssl_incdir)" >&5
+printf "%s\n" "$as_me: ntp_ssl_incdir:   ($ntp_ssl_incdir)" >&6;}
+	esac
+
+
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_ssl_libdir:   ($ntp_ssl_libdir)" >&5
+printf "%s\n" "$as_me: ntp_ssl_libdir:   ($ntp_ssl_libdir)" >&6;}
+	esac
+
+
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_ssl_cflags:   ($ntp_ssl_cflags)" >&5
+printf "%s\n" "$as_me: ntp_ssl_cflags:   ($ntp_ssl_cflags)" >&6;}
+	esac
+
+
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_ssl_cppflags: ($ntp_ssl_cppflags)" >&5
+printf "%s\n" "$as_me: ntp_ssl_cppflags: ($ntp_ssl_cppflags)" >&6;}
+	esac
+
+
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_ssl_libs_L:   ($ntp_ssl_libs_L)" >&5
+printf "%s\n" "$as_me: ntp_ssl_libs_L:   ($ntp_ssl_libs_L)" >&6;}
+	esac
+
+
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_ssl_libs_l:   ($ntp_ssl_libs_l)" >&5
+printf "%s\n" "$as_me: ntp_ssl_libs_l:   ($ntp_ssl_libs_l)" >&6;}
+	esac
+
+
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_ssl_libs:     ($ntp_ssl_libs)" >&5
+printf "%s\n" "$as_me: ntp_ssl_libs:     ($ntp_ssl_libs)" >&6;}
+	esac
+
+
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_ssl_ldflags:  ($ntp_ssl_ldflags)" >&5
+printf "%s\n" "$as_me: ntp_ssl_ldflags:  ($ntp_ssl_ldflags)" >&6;}
+	esac
+
+
+
+case "$ntp_openssl:$ntp_openssl_from_pkg_config" in
+ yes:no)
+    CFLAGS="$NTPSSL_SAVED_CFLAGS $ntp_ssl_cflags"
+    CPPFLAGS="$NTPSSL_SAVED_CPPFLAGS $ntp_ssl_cppflags"
+    LIBS="$ntp_ssl_libs $NTPSSL_SAVED_LIBS"
+    LDFLAGS="$ntp_ssl_ldflags $NTPSSL_SAVED_LDFLAGS"
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if linking with $ntp_ssl_libs_l alone works" >&5
+printf %s "checking if linking with $ntp_ssl_libs_l alone works... " >&6; }
+if test ${ntp_cv_bare_lcrypto+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+		    #include "openssl/evp.h"
+
+int
+main (void)
+{
+
+		    EVP_MD_CTX_new();
+
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
+then :
+  ntp_cv_bare_lcrypto=yes
+else $as_nop
+  ntp_cv_bare_lcrypto=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext
+
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_bare_lcrypto" >&5
+printf "%s\n" "$ntp_cv_bare_lcrypto" >&6; }
+    case "$ntp_cv_bare_lcrypto" in
+     no)
+	LIBS="-$ntp_ssl_libs -lz $NTPSSL_SAVED_LIBS"
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if linking with $ntp_ssl_libs_l -lz works" >&5
+printf %s "checking if linking with $ntp_ssl_libs_l -lz works... " >&6; }
+if test ${ntp_cv_lcrypto_lz+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+			#include "openssl/evp.h"
+
+int
+main (void)
+{
+
+			EVP_MD_CTX_new();
+
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
+then :
+  ntp_cv_lcrypto_lz=yes
+else $as_nop
+  ntp_cv_lcrypto_lz=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext
+
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_lcrypto_lz" >&5
+printf "%s\n" "$ntp_cv_lcrypto_lz" >&6; }
+	case "$ntp_cv_lcrypto_lz" in
+	 yes)
+	     ntp_ssl_libs_l="$ntp_ssl_libs_l -lz"
+	     ntp_ssl_libs="$ntp_ssl_libs_L $ntp_ssl_libs_l"
+	esac
+    esac	esac
+case "$ntp_openssl:$GCC" in
+ yes:yes)
+    CFLAGS="$NTP_SAVED_CFLAGS $ntp_ssl_cflags -Werror"
+    CPPFLAGS="$NTPSSL_SAVED_CPPFLAGS $ntp_ssl_cppflags"
+    LIBS="$ntp_ssl_libs $NTPSSL_SAVED_LIBS"
+    LDFLAGS="$ntp_ssl_ldflags $NTPSSL_SAVED_LDFLAGS"
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking If $CC supports -Werror" >&5
+printf %s "checking If $CC supports -Werror... " >&6; }
+if test ${ntp_cv_gcc_supports_Werror+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main (void)
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+  ntp_cv_gcc_supports_Werror=yes
+else $as_nop
+  ntp_cv_gcc_supports_Werror=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_gcc_supports_Werror" >&5
+printf "%s\n" "$ntp_cv_gcc_supports_Werror" >&6; }
+    case "ntp_cv_gcc_supports_Werror" in
+     no)
+	ntp_use_Wstrict_prototypes=yes
+	;;
+     yes)
+	CFLAGS="$CFLAGS -Wstrict-prototypes"
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if OpenSSL triggers warnings" >&5
+printf %s "checking if OpenSSL triggers warnings... " >&6; }
+if test ${ntp_cv_ssl_triggers_warnings+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+			#include "openssl/asn1_mac.h"
+			#include "openssl/bn.h"
+			#include "openssl/err.h"
+			#include "openssl/evp.h"
+			#include "openssl/pem.h"
+			#include "openssl/rand.h"
+			#include "openssl/x509v3.h"
+
+int
+main (void)
+{
+
+			/* empty body */
+
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+  ntp_cv_ssl_triggers_warnings=no
+else $as_nop
+  ntp_cv_ssl_triggers_warnings=yes
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_ssl_triggers_warnings" >&5
+printf "%s\n" "$ntp_cv_ssl_triggers_warnings" >&6; }
+	case "$ntp_cv_ssl_triggers_warnings" in
+	 yes)
+	    ntp_use_Wstrict_prototypes=no
+	    ;;
+	 *)
+	    ntp_use_Wstrict_prototypes=yes
+	esac
+    esac
+    case "$ntp_use_Wstrict_prototypes" in
+     no)
+	ntp_ssl_cflags="$ntp_ssl_cflags -Wno-strict-prototypes"
+	;;
+     *)
+	ntp_ssl_cflags="$ntp_ssl_cflags -Wstrict-prototypes"
+    esac
+    ;;
+ no:yes)
+        ntp_ssl_cflags="$ntp_ssl_cflags -Wstrict-prototypes"
+esac
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if we will link to ssl library" >&5
+printf %s "checking if we will link to ssl library... " >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_openssl" >&5
+printf "%s\n" "$ntp_openssl" >&6; }
+
+case "$ntp_openssl" in
  yes)
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Please do not use --with-arlib, arlib is no longer included.  In the future, --with-arlib will not be recognized." >&5
-printf "%s\n" "$as_me: WARNING: Please do not use --with-arlib, arlib is no longer included.  In the future, --with-arlib will not be recognized." >&2;}
+    VER_SUFFIX=o
+           for ac_header in openssl/cmac.h
+do :
+  ac_fn_c_check_header_compile "$LINENO" "openssl/cmac.h" "ac_cv_header_openssl_cmac_h" "$ac_includes_default"
+if test "x$ac_cv_header_openssl_cmac_h" = xyes
+then :
+  printf "%s\n" "#define HAVE_OPENSSL_CMAC_H 1" >>confdefs.h
+ ntp_enable_cmac=yes
+else $as_nop
+  ntp_enable_cmac=no
+
+fi
+
+done
+    case "$ntp_enable_cmac" in
+     yes)
+
+printf "%s\n" "#define ENABLE_CMAC 1" >>confdefs.h
+
+    esac
+
+printf "%s\n" "#define OPENSSL /**/" >>confdefs.h
+
+
+printf "%s\n" "#define OPENSSL_SUPPRESS_DEPRECATED 1" >>confdefs.h
+
+        CFLAGS="$NTPSSL_SAVED_CFLAGS"
+    ac_fn_c_check_func "$LINENO" "EVP_MD_do_all_sorted" "ac_cv_func_EVP_MD_do_all_sorted"
+if test "x$ac_cv_func_EVP_MD_do_all_sorted" = xyes
+then :
+  printf "%s\n" "#define HAVE_EVP_MD_DO_ALL_SORTED 1" >>confdefs.h
+
+fi
+
+    CPPFLAGS_NTP="$CPPFLAGS_NTP $ntp_ssl_cppflags"
+    CFLAGS_NTP="$CFLAGS_NTP $ntp_ssl_cflags"
+    LDADD_NTP="$ntp_ssl_libs $LDADD_NTP"
+    LDFLAGS_NTP="$ntp_ssl_ldflags $LDFLAGS_NTP"
+esac
+
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: OpenSSL final checks:" >&5
+printf "%s\n" "$as_me: OpenSSL final checks:" >&6;}
+	esac
+
+
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_openssl:  $ntp_openssl" >&5
+printf "%s\n" "$as_me: ntp_openssl:  $ntp_openssl" >&6;}
+	esac
+
+
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: CPPFLAGS_NTP: ($CPPFLAGS_NTP)" >&5
+printf "%s\n" "$as_me: CPPFLAGS_NTP: ($CPPFLAGS_NTP)" >&6;}
+	esac
+
+
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: CFLAGS_NTP:   ($CFLAGS_NTP)" >&5
+printf "%s\n" "$as_me: CFLAGS_NTP:   ($CFLAGS_NTP)" >&6;}
+	esac
+
+
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: LDADD_NTP:    ($LDADD_NTP)" >&5
+printf "%s\n" "$as_me: LDADD_NTP:    ($LDADD_NTP)" >&6;}
+	esac
+
+
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: LDFLAGS_NTP:  ($LDFLAGS_NTP)" >&5
+printf "%s\n" "$as_me: LDFLAGS_NTP:  ($LDFLAGS_NTP)" >&6;}
+	esac
+
+
+
+CFLAGS="$NTPSSL_SAVED_CFLAGS"
+CPPFLAGS="$NTPSSL_SAVED_CPPFLAGS"
+LIBS="$NTPSSL_SAVED_LIBS"
+LDFLAGS="$NTPSSL_SAVED_LDFLAGS"
+
+{ NTPSSL_SAVED_CFLAGS=; unset NTPSSL_SAVED_CFLAGS;}
+{ NTPSSL_SAVED_CPPFLAGS=; unset NTPSSL_SAVED_CPPFLAGS;}
+{ NTPSSL_SAVED_LIBS=; unset NTPSSL_SAVED_LIBS;}
+{ NTPSSL_SAVED_LDFLAGS=; unset NTPSSL_SAVED_LDFLAGS;}
+{ ntp_enable_cmac=; unset ntp_enable_cmac;}
+{ ntp_use_Wstrict_prototypes=; unset ntp_use_Wstrict_prototypes;}
+{ ntp_openssl_from_pkg_config=; unset ntp_openssl_from_pkg_config;}
+{ ntp_openssl_version=; unset ntp_openssl_version;}
+{ ntp_ssl_cflags=; unset ntp_ssl_cflags;}
+{ ntp_ssl_cppflags=; unset ntp_ssl_cppflags;}
+{ ntp_ssl_libdir_search=; unset ntp_ssl_libdir_search;}
+{ ntp_ssl_incdir_search=; unset ntp_ssl_incdir_search;}
+{ ntp_ssl_libdir=; unset ntp_ssl_libdir;}
+{ ntp_ssl_incdir=; unset ntp_ssl_incdir;}
+{ ntp_ssl_libs_l=; unset ntp_ssl_libs_l;}
+{ ntp_ssl_libs_L=; unset ntp_ssl_libs_L;}
+{ ntp_ssl_ldflags=; unset ntp_ssl_ldflags;}
+
+
+
+
+
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if we want to use SSL library's secure random numbers" >&5
+printf %s "checking if we want to use SSL library's secure random numbers... " >&6; }
+# Check whether --enable-openssl-random was given.
+if test ${enable_openssl_random+y}
+then :
+  enableval=$enable_openssl_random; ntp_use_openssl_random=$enableval ; ntp_ssl_random_mandatory=$enableval
+else $as_nop
+  ntp_use_openssl_random=yes ; ntp_ssl_random_mandatory=no
+
+fi
+
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_use_openssl_random" >&5
+printf "%s\n" "$ntp_use_openssl_random" >&6; }
+
+# The following might need extra libraries
+NTPO_SAVED_LIBS="$LIBS"
+LIBS="$NTPO_SAVED_LIBS $LDADD_NTP"
+ac_fn_c_check_func "$LINENO" "RAND_bytes" "ac_cv_func_RAND_bytes"
+if test "x$ac_cv_func_RAND_bytes" = xyes
+then :
+  printf "%s\n" "#define HAVE_RAND_BYTES 1" >>confdefs.h
+
+fi
+ac_fn_c_check_func "$LINENO" "RAND_poll" "ac_cv_func_RAND_poll"
+if test "x$ac_cv_func_RAND_poll" = xyes
+then :
+  printf "%s\n" "#define HAVE_RAND_POLL 1" >>confdefs.h
+
+fi
+
+LIBS="$NTPO_SAVED_LIBS"
+case "$ntp_openssl$ntp_use_openssl_random$ac_cv_func_RAND_bytes$ac_cv_func_RAND_poll" in
+ yesyesyesyes)
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Using SSL library's secure random number generator" >&5
+printf "%s\n" "$as_me: Using SSL library's secure random number generator" >&6;}
+
+printf "%s\n" "#define USE_OPENSSL_CRYPTO_RAND 1" >>confdefs.h
+
     ;;
+ *)
+    ntp_use_openssl_random=no
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: SSL library's secure random number generator unavailable." >&5
+printf "%s\n" "$as_me: SSL library's secure random number generator unavailable." >&6;}
+    case "$ntp_ssl_random_mandatory" in
+     yes)
+	as_fn_error $? "No suitable SSL library was found and
+--enable-openssl-random was given..  Remove --enable-openssl-random
+if you wish to build without a cryptographically secure random number
+generator.
+
+WARNING: Use of ntp-keygen without a secure RNG may generate
+-------  keys that are predictable.
+	" "$LINENO" 5
+	;;
+     *)
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: WARNING: Use of ntp-keygen without a secure RNG may generate
+-------  keys that are predictable.
+	" >&5
+printf "%s\n" "$as_me: WARNING: WARNING: Use of ntp-keygen without a secure RNG may generate
+-------  keys that are predictable.
+	" >&2;}
+    esac
 esac
 
+{ ntp_ssl_random_mandatory=; unset ntp_ssl_random_mandatory;}
+
+
+
+LDADD_LIBNTP="$LDADD_LIBNTP $LIBS"
+LIBS=$SAVED_LIBS
+{ SAVED_LIBS=; unset SAVED_LIBS;}
+
+
+
 for ac_prog in gawk mawk nawk awk
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
@@ -25875,9 +26824,6 @@ printf "%s\n" "no" >&6; }
 fi
 
 
-
-
-
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5
 printf %s "checking whether ln -s works... " >&6; }
 LN_S=$as_ln_s
@@ -25889,65 +26835,6 @@ else
 printf "%s\n" "no, using $LN_S" >&6; }
 fi
 
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing strerror" >&5
-printf %s "checking for library containing strerror... " >&6; }
-if test ${ac_cv_search_strerror+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-char strerror ();
-int
-main (void)
-{
-return strerror ();
-  ;
-  return 0;
-}
-_ACEOF
-for ac_lib in '' cposix
-do
-  if test -z "$ac_lib"; then
-    ac_res="none required"
-  else
-    ac_res=-l$ac_lib
-    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
-  fi
-  if ac_fn_c_try_link "$LINENO"
-then :
-  ac_cv_search_strerror=$ac_res
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam \
-    conftest$ac_exeext
-  if test ${ac_cv_search_strerror+y}
-then :
-  break
-fi
-done
-if test ${ac_cv_search_strerror+y}
-then :
-
-else $as_nop
-  ac_cv_search_strerror=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_strerror" >&5
-printf "%s\n" "$ac_cv_search_strerror" >&6; }
-ac_res=$ac_cv_search_strerror
-if test "$ac_res" != no
-then :
-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-
-fi
-
 
 
 # Extract the first word of "perl", so it can be a program name with args.
@@ -26352,35 +27239,39 @@ fi
 esac
 
 
+
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for facilitynames in syslog.h" >&5
 printf %s "checking for facilitynames in syslog.h... " >&6; }
 if test ${ac_cv_HAVE_SYSLOG_FACILITYNAMES+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-#define SYSLOG_NAMES
-#include <stdlib.h>
-#include <syslog.h>
+		#define SYSLOG_NAMES
+		#include <stdlib.h>
+		#include <syslog.h>
 
 int
 main (void)
 {
- void *fnames; fnames = facilitynames;
+
+		void *fnames = facilitynames;
+
+
   ;
   return 0;
 }
+	ac_cv_HAVE_SYSLOG_FACILITYNAMES=yes
 _ACEOF
 if ac_fn_c_try_compile "$LINENO"
 then :
-  ac_cv_HAVE_SYSLOG_FACILITYNAMES=yes
-else $as_nop
   ac_cv_HAVE_SYSLOG_FACILITYNAMES=no
+
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+
 fi
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_HAVE_SYSLOG_FACILITYNAMES" >&5
 printf "%s\n" "$ac_cv_HAVE_SYSLOG_FACILITYNAMES" >&6; }
@@ -26393,11 +27284,6 @@ printf "%s\n" "#define HAVE_SYSLOG_FACILITYNAMES 1" >>confdefs.h
  no)
     { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: No facilitynames in <syslog.h>" >&5
 printf "%s\n" "$as_me: WARNING: No facilitynames in <syslog.h>" >&2;}
-    ;;
- cross)
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: facilitynames in <syslog.h> - cross-compiling" >&5
-printf "%s\n" "$as_me: WARNING: facilitynames in <syslog.h> - cross-compiling" >&2;}
-    ;;
 esac
 
 
@@ -26409,7 +27295,10 @@ case "$host" in
  *)
     # HMS: Make sure we check for -lrt for clock_* before this...
     case "$ac_cv_search_clock_gettime" in
-     '') as_fn_error $? "Internal Error: Haven't looked for clock_gettime() yet!" "$LINENO" 5 ;;
+     '') { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "Internal Error: Haven't looked for clock_gettime() yet!
+See \`config.log' for more details" "$LINENO" 5; } ;;
     esac
     { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing sched_setscheduler" >&5
 printf %s "checking for library containing sched_setscheduler... " >&6; }
@@ -26478,6 +27367,12 @@ if test "x$ac_cv_header_bstring_h" = xyes
 then :
   printf "%s\n" "#define HAVE_BSTRING_H 1" >>confdefs.h
 
+fi
+ac_fn_c_check_header_compile "$LINENO" "sys/procctl.h" "ac_cv_header_sys_procctl_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_procctl_h" = xyes
+then :
+  printf "%s\n" "#define HAVE_SYS_PROCCTL_H 1" >>confdefs.h
+
 fi
 
 ac_fn_c_check_header_compile "$LINENO" "dns_sd.h" "ac_cv_header_dns_sd_h" "$ac_includes_default"
@@ -31425,530 +32320,7 @@ esac
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ans" >&5
 printf "%s\n" "$ans" >&6; }
 
-
-
-
-VER_SUFFIX=
-
-
-
-
-# Check whether --with-crypto was given.
-if test ${with_crypto+y}
-then :
-  withval=$with_crypto;
-fi
-
-
-# Check whether --with-openssl-libdir was given.
-if test ${with_openssl_libdir+y}
-then :
-  withval=$with_openssl_libdir;
-fi
-
-
-# Check whether --with-openssl-incdir was given.
-if test ${with_openssl_incdir+y}
-then :
-  withval=$with_openssl_incdir;
-fi
-
-
-# Check whether --with-rpath was given.
-if test ${with_rpath+y}
-then :
-  withval=$with_rpath;
-fi
-
-
-ntp_openssl=no
-ntp_openssl_from_pkg_config=no
-
-with_crypto=${with_crypto:-openssl,libcrypto}
-case "$with_crypto" in
- yes)
-    with_crypto=openssl,libcrypto
-esac
-
-
-case "$with_crypto:${PKG_CONFIG:+notempty}:${with_openssl_libdir-notgiven}:${with_openssl_incdir-notgiven}" in
- no:*) ;;
- *:notempty:notgiven:notgiven)
-    for pkg in `echo $with_crypto | sed -e 's/,/ /'`; do
-	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking pkg-config for $pkg" >&5
-printf %s "checking pkg-config for $pkg... " >&6; }
-	if $PKG_CONFIG --exists $pkg ; then
-	    CPPFLAGS_NTP="$CPPFLAGS_NTP `$PKG_CONFIG --cflags-only-I $pkg`"
-	    CFLAGS_NTP="$CFLAGS_NTP `$PKG_CONFIG --cflags-only-other $pkg`"
-	    LDADD_NTP="$LDADD_NTP `$PKG_CONFIG --libs-only-L $pkg`"
-	    LDADD_NTP="$LDADD_NTP `$PKG_CONFIG --libs-only-l --static $pkg`"
-	    LDFLAGS_NTP="$LDFLAGS_NTP `$PKG_CONFIG --libs-only-other $pkg`"
-	    VER_SUFFIX=o
-	    ntp_openssl=yes
-	    ntp_openssl_from_pkg_config=yes
-	    ntp_openssl_version="`$PKG_CONFIG --modversion $pkg`"
-	    case "$ntp_openssl_version" in
-	     *.*) ;;
-	     *) ntp_openssl_version='(unknown)' ;;
-	    esac
-	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes, version $ntp_openssl_version" >&5
-printf "%s\n" "yes, version $ntp_openssl_version" >&6; }
-
-	    break
-	fi
-	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
-printf "%s\n" "no" >&6; }
-    done
-esac
-case "$with_crypto:$ntp_openssl" in
- no:*) ;;
- *:no)
-    need_dash_r=
-    need_dash_Wlrpath=
-    case "${with_rpath-notgiven}" in
-     yes)
-	# Lame - what to do if we need -Wl... but not -R?
-	need_dash_r=1
-	;;
-     notgiven)
-	case "$host" in
-	 *-*-linux*)
-	    # This may really only be true for gcc
-	    need_dash_Wlrpath=1
-	    ;;
-	 *-*-netbsd*)
-	    need_dash_r=1
-	    ;;
-	 *-*-solaris*)
-	    need_dash_r=1
-	    ;;
-	esac
-	;;
-    esac
-
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for openssl library directory" >&5
-printf %s "checking for openssl library directory... " >&6; }
-    with_openssl_libdir=${with_openssl_libdir-notgiven}
-    case "$with_openssl_libdir" in
-     notgiven)
-	case "$build" in
-	 $host)
-	    with_openssl_libdir=default
-	    ;;
-	 *)
-	    with_openssl_libdir=no
-	    ;;
-	esac
-    esac
-    case "$with_openssl_libdir" in
-     default)
-	# Look in:
-	with_openssl_libdir="/usr/lib /usr/lib/openssl /usr/sfw/lib"
-	with_openssl_libdir="$with_openssl_libdir /usr/local/lib"
-	with_openssl_libdir="$with_openssl_libdir /usr/local/ssl/lib /lib"
-    esac
-    case "$with_openssl_libdir" in
-     no)
-	;;
-     *) # Look for libcrypto.a and libssl.a:
-	for i in $with_openssl_libdir no
-	do
-	    case "$host" in
-	     *-*-darwin*)
-		test -f $i/libcrypto.dylib -a -f $i/libssl.dylib && break
-		;;
-	     *)
-		test -f $i/libcrypto.so -a -f $i/libssl.so && break
-		test -f $i/libcrypto.a -a -f $i/libssl.a && break
-		;;
-	    esac
-	done
-	openssl_libdir=$i
-	;;
-    esac
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $openssl_libdir" >&5
-printf "%s\n" "$openssl_libdir" >&6; }
-    case "$openssl_libdir" in
-     no)
-	openssl_libdir=
-	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: libcrypto and libssl not found in any of $with_openssl_libdir" >&5
-printf "%s\n" "$as_me: WARNING: libcrypto and libssl not found in any of $with_openssl_libdir" >&2;}
-    esac
-
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for openssl include directory" >&5
-printf %s "checking for openssl include directory... " >&6; }
-    with_openssl_incdir=${with_openssl_incdir-notgiven}
-    case "$with_openssl_incdir" in
-     notgiven)
-	# Look in:
-	with_openssl_incdir="/usr/include /usr/sfw/include"
-	with_openssl_incdir="$with_openssl_incdir /usr/local/include"
-	with_openssl_incdir="$with_openssl_incdir /usr/local/ssl/include"
-    esac
-    case "$with_openssl_incdir" in
-     no)
-	;;
-     *) # look for openssl/evp.h:
-	for i in $with_openssl_incdir no
-	do
-	    test -f $i/openssl/evp.h && break
-	done
-	openssl_incdir=$i
-	;;
-    esac
-    { i=; unset i;}
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $openssl_incdir" >&5
-printf "%s\n" "$openssl_incdir" >&6; }
-    case "$openssl_incdir" in
-     no)
-	openssl_incdir=
-	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: did not find openssl/evp.h in any of $with_openssl_incdir" >&5
-printf "%s\n" "$as_me: WARNING: did not find openssl/evp.h in any of $with_openssl_incdir" >&2;}
-    esac
-    if test -z "$openssl_libdir" -o -z "$openssl_incdir"
-    then
-	ntp_openssl=no
-    else
-	ntp_openssl=yes
-	VER_SUFFIX=o
-    fi
-    case "$ntp_openssl" in
-     yes)
-	# We have OpenSSL inc/lib dirs - use them.
-	case "$openssl_incdir" in
-	 /usr/include)
-	    ;;
-	 *)
-	    CPPFLAGS_NTP="$CPPFLAGS_NTP -I$openssl_incdir"
-	    ;;
-	esac
-	case "$openssl_libdir" in
-	 /usr/lib)
-	    ;;
-	 *)
-	    LDADD_NTP="$LDADD_NTP -L$openssl_libdir"
-	    case "$need_dash_r" in
-	     1)
-		LDFLAGS_NTP="$LDFLAGS_NTP -R$openssl_libdir"
-	    esac
-	    case "$need_dash_Wlrpath" in
-	     1)
-		LDFLAGS_NTP="$LDFLAGS_NTP -Wl,-rpath,$openssl_libdir"
-	    esac
-	    ;;
-	esac
-	LDADD_NTP="$LDADD_NTP -lcrypto"
-    esac
-esac
-
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if we will use crypto" >&5
-printf %s "checking if we will use crypto... " >&6; }
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_openssl" >&5
-printf "%s\n" "$ntp_openssl" >&6; }
-
-case "$ntp_openssl" in
- yes)
-    ac_fn_c_check_header_compile "$LINENO" "openssl/cmac.h" "ac_cv_header_openssl_cmac_h" "$ac_includes_default"
-if test "x$ac_cv_header_openssl_cmac_h" = xyes
-then :
-  printf "%s\n" "#define HAVE_OPENSSL_CMAC_H 1" >>confdefs.h
-
-fi
-ac_fn_c_check_header_compile "$LINENO" "openssl/hmac.h" "ac_cv_header_openssl_hmac_h" "$ac_includes_default"
-if test "x$ac_cv_header_openssl_hmac_h" = xyes
-then :
-  printf "%s\n" "#define HAVE_OPENSSL_HMAC_H 1" >>confdefs.h
-
-fi
-
-
-printf "%s\n" "#define OPENSSL /**/" >>confdefs.h
-
-    case "$VER_SUFFIX" in
-     *o*) ;;
-     *) as_fn_error $? "OPENSSL set but no 'o' in VER_SUFFIX!" "$LINENO" 5 ;;
-    esac
-    ;;
-esac
-
-NTPO_SAVED_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $CPPFLAGS_NTP"
-NTPO_SAVED_LIBS="$LIBS"
-
-#
-# check for linking with -lcrypto failure, and try -lcrypto -lz.
-# Helps m68k-atari-mint
-#
-case "$ntp_openssl:$ntp_openssl_from_pkg_config" in
- yes:no)
-    LIBS="$NTPO_SAVED_LIBS $LDADD_NTP"
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if linking with -lcrypto alone works" >&5
-printf %s "checking if linking with -lcrypto alone works... " >&6; }
-if test ${ntp_cv_bare_lcrypto+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-		    #include "openssl/err.h"
-		    #include "openssl/evp.h"
-
-int
-main (void)
-{
-
-		    ERR_load_crypto_strings();
-		    OpenSSL_add_all_algorithms();
-
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"
-then :
-  ntp_cv_bare_lcrypto=yes
-else $as_nop
-  ntp_cv_bare_lcrypto=no
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam \
-    conftest$ac_exeext conftest.$ac_ext
-
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_bare_lcrypto" >&5
-printf "%s\n" "$ntp_cv_bare_lcrypto" >&6; }
-    case "$ntp_cv_bare_lcrypto" in
-     no)
-	LIBS="$NTPO_SAVED_LIBS $LDADD_NTP -lz"
-	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if linking with -lcrypto -lz works" >&5
-printf %s "checking if linking with -lcrypto -lz works... " >&6; }
-if test ${ntp_cv_lcrypto_lz+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-			#include "openssl/err.h"
-			#include "openssl/evp.h"
-
-int
-main (void)
-{
-
-			ERR_load_crypto_strings();
-			OpenSSL_add_all_algorithms();
-
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"
-then :
-  ntp_cv_lcrypto_lz=yes
-else $as_nop
-  ntp_cv_lcrypto_lz=no
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam \
-    conftest$ac_exeext conftest.$ac_ext
-
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_lcrypto_lz" >&5
-printf "%s\n" "$ntp_cv_lcrypto_lz" >&6; }
-	case "$ntp_cv_lcrypto_lz" in
-	 yes)
-	     LDADD_NTP="$LDADD_NTP -lz"
-	esac
-    esac
-esac
-
-#
-# Older OpenSSL headers have a number of callback prototypes inside
-# other function prototypes which trigger copious warnings with gcc's
-# -Wstrict-prototypes, which is included in -Wall.
-#
-# An example:
-#
-# int i2d_RSA_NET(const RSA *a, unsigned char **pp,
-#		  int (*cb)(), int sgckey);
-#		  ^^^^^^^^^^^
-#
-#
-#
-openssl_triggers_warnings=unknown
-NTPO_SAVED_CFLAGS="$CFLAGS"
-
-case "$ntp_openssl:$GCC" in
- yes:yes)
-    CFLAGS="$CFLAGS -Werror"
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-
-int
-main (void)
-{
-
-		/* see if -Werror breaks gcc */
-
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"
-then :
-  gcc_handles_Werror=yes
-else $as_nop
-  gcc_handles_Werror=no
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
-    case "$gcc_handles_Werror" in
-     no)
-	# if this gcc doesn't do -Werror go ahead and use
-	# -Wstrict-prototypes.
-	openssl_triggers_warnings=yes
-	;;
-     yes)
-	CFLAGS="$CFLAGS -Wstrict-prototypes"
-	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-		    #include "openssl/asn1_mac.h"
-		    #include "openssl/bn.h"
-		    #include "openssl/err.h"
-		    #include "openssl/evp.h"
-		    #include "openssl/pem.h"
-		    #include "openssl/rand.h"
-		    #include "openssl/x509v3.h"
-
-int
-main (void)
-{
-
-		    /* empty body */
-
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"
-then :
-  openssl_triggers_warnings=no
-else $as_nop
-  openssl_triggers_warnings=yes
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
-    esac
-    case "$openssl_triggers_warnings" in
-     yes)
-	CFLAGS_NTP="$CFLAGS_NTP -Wno-strict-prototypes"
-	;;
-     *)
-	CFLAGS_NTP="$CFLAGS_NTP -Wstrict-prototypes"
-    esac
-    ;;
- no:yes)
-    # gcc without OpenSSL
-    CFLAGS_NTP="$CFLAGS_NTP -Wstrict-prototypes"
-esac
-
-# Because we don't want -Werror for the EVP_MD_do_all_sorted check
-CFLAGS="$NTPO_SAVED_CFLAGS"
-
-case "$ntp_openssl" in
- yes)
-    LIBS="$NTPO_SAVED_LIBS $LDADD_NTP"
-    ac_fn_c_check_func "$LINENO" "EVP_MD_do_all_sorted" "ac_cv_func_EVP_MD_do_all_sorted"
-if test "x$ac_cv_func_EVP_MD_do_all_sorted" = xyes
-then :
-  printf "%s\n" "#define HAVE_EVP_MD_DO_ALL_SORTED 1" >>confdefs.h
-
-fi
-
-    ;;
-esac
-
-
-CPPFLAGS="$NTPO_SAVED_CPPFLAGS"
-LIBS="$NTPO_SAVED_LIBS"
-{ NTPO_SAVED_CFLAGS=; unset NTPO_SAVED_CFLAGS;}
-{ NTPO_SAVED_CPPFLAGS=; unset NTPO_SAVED_CPPFLAGS;}
-{ NTPO_SAVED_LIBS=; unset NTPO_SAVED_LIBS;}
-{ openssl_triggers_warnings=; unset openssl_triggers_warnings;}
-{ ntp_openssl_from_pkg_config=; unset ntp_openssl_from_pkg_config;}
-
-
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if we want to enable CMAC support" >&5
-printf %s "checking if we want to enable CMAC support... " >&6; }
-case "$ac_cv_header_openssl_cmac_h" in
- yes)
-
-printf "%s\n" "#define ENABLE_CMAC 1" >>confdefs.h
-
-    ans="yes"
-    ;;
- *) ans="no"
-    ;;
-esac
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ans" >&5
-printf "%s\n" "$ans" >&6; }
-
-
-
-
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if we want to use OpenSSL's crypto random (if available)" >&5
-printf %s "checking if we want to use OpenSSL's crypto random (if available)... " >&6; }
-# Check whether --enable-openssl-random was given.
-if test ${enable_openssl_random+y}
-then :
-  enableval=$enable_openssl_random; ntp_use_openssl_random=$enableval
-else $as_nop
-  ntp_use_openssl_random=yes
-
-fi
-
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_use_openssl_random" >&5
-printf "%s\n" "$ntp_use_openssl_random" >&6; }
-
-# The following might need extra libraries
-NTPO_SAVED_LIBS="$LIBS"
-LIBS="$NTPO_SAVED_LIBS $LDADD_NTP"
-ac_fn_c_check_func "$LINENO" "RAND_bytes" "ac_cv_func_RAND_bytes"
-if test "x$ac_cv_func_RAND_bytes" = xyes
-then :
-  printf "%s\n" "#define HAVE_RAND_BYTES 1" >>confdefs.h
-
-fi
-ac_fn_c_check_func "$LINENO" "RAND_poll" "ac_cv_func_RAND_poll"
-if test "x$ac_cv_func_RAND_poll" = xyes
-then :
-  printf "%s\n" "#define HAVE_RAND_POLL 1" >>confdefs.h
-
-fi
-
-LIBS="$NTPO_SAVED_LIBS"
-case "$ntp_openssl$ntp_use_openssl_random$ac_cv_func_RAND_bytes$ac_cv_func_RAND_poll" in
- yesyesyesyes)
-
-printf "%s\n" "#define USE_OPENSSL_CRYPTO_RAND 1" >>confdefs.h
-
-     ;;
- *) ntp_use_openssl_random=no ;;
-esac
-
-
-
-# if we are using OpenSSL (--with-crypto), by default Autokey is enabled
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if we want to include NTP Autokey protocol support" >&5
-printf %s "checking if we want to include NTP Autokey protocol support... " >&6; }
+# if we have crypto, by default Autokey is enabled
 # Check whether --enable-autokey was given.
 if test ${enable_autokey+y}
 then :
@@ -31964,8 +32336,8 @@ case "$ntp_autokey" in
  *)
     case "$ntp_openssl" in
      no)
-	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Disabling Autokey, --enable-autokey requires --with-crypto." >&5
-printf "%s\n" "$as_me: WARNING: Disabling Autokey, --enable-autokey requires --with-crypto." >&2;}
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Disabling Autokey, crypto unavailable." >&5
+printf "%s\n" "$as_me: WARNING: Disabling Autokey, crypto unavailable." >&2;}
 	ntp_autokey=no
 	;;
      *)
@@ -31977,6 +32349,8 @@ printf "%s\n" "#define AUTOKEY 1" >>confdefs.h
     esac
     ;;
 esac
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if NTP Autokey protocol will be supported" >&5
+printf %s "checking if NTP Autokey protocol will be supported... " >&6; }
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_autokey" >&5
 printf "%s\n" "$ntp_autokey" >&6; }
 
@@ -34457,6 +34831,8 @@ printf "%s\n" "#define DYNAMIC_INTERLEAVE $ntp_dynamic_interleave" >>confdefs.h
 printf "%s\n" "$ntp_ok" >&6; }
 
 
+
+
 # We may not need have_unity
 have_unity=false
 # Extract the first word of "ruby", so it can be a program name with args.
@@ -34951,6 +35327,10 @@ if test -z "${PTHREADS_TRUE}" && test -z "${PTHREADS_FALSE}"; then
   as_fn_error $? "conditional \"PTHREADS\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${LIBNTP_SUBMAKES_TRUE}" && test -z "${LIBNTP_SUBMAKES_FALSE}"; then
+  as_fn_error $? "conditional \"LIBNTP_SUBMAKES\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 if test -z "${BUILD_SNTP_TRUE}" && test -z "${BUILD_SNTP_FALSE}"; then
   as_fn_error $? "conditional \"BUILD_SNTP\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
@@ -35365,7 +35745,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by ntp $as_me 4.2.8p17, which was
+This file was extended by ntp $as_me 4.2.8p18, which was
 generated by GNU Autoconf 2.71.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -35434,7 +35814,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config='$ac_cs_config_escaped'
 ac_cs_version="\\
-ntp config.status 4.2.8p17
+ntp config.status 4.2.8p18
 configured by $0, generated by GNU Autoconf 2.71,
   with options \\"\$ac_cs_config\\"
 
@@ -35563,9 +35943,9 @@ AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}"
 sed_quote_subst='$sed_quote_subst'
 double_quote_subst='$double_quote_subst'
 delay_variable_subst='$delay_variable_subst'
-enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`'
 macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`'
 macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`'
+enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`'
 enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`'
 pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`'
 enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`'
@@ -36674,13 +37054,13 @@ available_tags=''
 
 # ### BEGIN LIBTOOL CONFIG
 
-# Whether or not to build shared libraries.
-build_libtool_libs=$enable_shared
-
 # Which release of libtool.m4 was used?
 macro_version=$macro_version
 macro_revision=$macro_revision
 
+# Whether or not to build shared libraries.
+build_libtool_libs=$enable_shared
+
 # Whether or not to build static libraries.
 build_old_libs=$enable_static
 
@@ -37166,7 +37546,7 @@ ltmain=$ac_aux_dir/ltmain.sh
   chmod +x "$ofile"
 
  ;;
-    "ntpd/complete.conf":F) sed -e '/^rlimit$/d' -e '/^$/d' < ntpd/complete.conf > ntpd/complete.conf.new && mv ntpd/complete.conf.new ntpd/complete.conf ;;
+    "ntpd/complete.conf":F) $SED -e '/^rlimit$/d' -e '/^$/d' < ntpd/complete.conf > ntpd/complete.conf.new && mv ntpd/complete.conf.new ntpd/complete.conf ;;
     "ntpdc/nl.pl":F) chmod +x ntpdc/nl.pl ;;
     "scripts/build/genAuthors":F) chmod +x scripts/build/genAuthors ;;
     "scripts/build/mkver":F) chmod +x scripts/build/mkver ;;
diff --git a/contrib/ntp/configure.ac b/contrib/ntp/configure.ac
index c2dce35e800d..aef705394309 100644
--- a/contrib/ntp/configure.ac
+++ b/contrib/ntp/configure.ac
@@ -35,7 +35,7 @@ AC_PRESERVE_HELP_ORDER
 # the date YYYYMMDD optionally with -HHMM if there is more than one
 # bump in a day.
 
-ntp_configure_cache_version=20230326
+ntp_configure_cache_version=20240218
 
 # When the cache version of config.cache and configure do not
 # match, NTP_CACHEVERSION will flush the cache.
@@ -55,6 +55,23 @@ AC_DEFINE_UNQUOTED([STR_SYSTEM], ["$host"],
 AC_CONFIG_HEADERS([config.h])
 dnl AC_ARG_PROGRAM
 
+AC_MSG_CHECKING([if we should enable build framework help])
+AC_ARG_ENABLE(
+    [build-framework-help],
+    [AS_HELP_STRING(
+	[--enable-build-framework-help],
+	[+ enable build framework help]
+    )],
+    [ntp_ok=$enableval],
+    [ntp_ok=yes]
+)
+case "$ntp_ok" in
+ yes)
+    ntp_cv_build_framework_help=yes ;;
+ *) ntp_cv_build_framework_help=no ;;
+esac
+AC_MSG_RESULT([$ntp_ok])
+
 ntp_atom_ok=${ntp_atom_ok=no}
 ntp_oncore_ok=${ntp_oncore_ok=no}
 ntp_parse_ok=${ntp_parse_ok=no}
@@ -70,7 +87,7 @@ AX_C99_STRUCT_INIT
 
 NTP_HARDEN([sntp])
 
-NTP_VPATH_HACK		dnl used only by ntpd/Makefile.am
+NTP_VPATH_HACK		dnl used by ntpd/Makefile.am libparse/Makefile.am
 
 NTP_LOCINFO([sntp])	dnl takes over from NTP_BINDIR, in NTP_LIBNTP
 
@@ -78,8 +95,7 @@ AM_PROG_AR
 
 # So far, the only shared library we might use is libopts.
 # It's a small library - we might as well use a static version of it.
-AC_DISABLE_SHARED
-AC_PROG_LIBTOOL
+LT_INIT([disable-shared])
 AC_SUBST([LIBTOOL_DEPS])
 
 # NTP has (so far) been relying on leading-edge autogen, which
@@ -87,7 +103,7 @@ AC_SUBST([LIBTOOL_DEPS])
 # Therefore, by default:
 # - use the version of libopts we ship with
 # - do not install it
-# - build a static copy (AC_DISABLE_SHARED - done earlier)
+# - build a static copy (disable-shared - done earlier)
 case "${enable_local_libopts+set}" in
  set) ;;
  *) enable_local_libopts=yes ;;
@@ -103,29 +119,13 @@ NTP_LIBEVENT_CHECK_NOBUILD([2], [sntp/libevent])
 
 NTP_LIBNTP
 
-AC_MSG_CHECKING([for deprecated --with-arlib])
-AC_ARG_WITH([arlib],
-	AS_HELP_STRING([--with-arlib], [- deprecated, arlib not distributed]),
-	[ans=$withval], [ans=no])
-AC_MSG_RESULT([$ans])
-
-case "$ans" in
- yes)
-    AC_MSG_WARN([Please do not use --with-arlib, arlib is no longer included.  In the future, --with-arlib will not be recognized.])
-    ;;
-esac
-
 dnl  we need to check for cross compile tools for vxWorks here
 AC_PROG_AWK
 AS_UNSET([ac_cv_prog_AWK])
 AC_SUBST([AWK])				dnl scripts/ntpver.in
 AC_PROG_MAKE_SET
 
-AC_SUBST([CFLAGS])
-AC_SUBST([LDFLAGS])
-
 AC_PROG_LN_S
-AC_ISC_POSIX
 
 
 AC_PATH_PROG([PATH_PERL], [perl])
@@ -277,13 +277,13 @@ case "$host" in
  *)
     # HMS: Make sure we check for -lrt for clock_* before this...
     case "$ac_cv_search_clock_gettime" in
-     '') AC_MSG_ERROR([Internal Error: Haven't looked for clock_gettime() yet!]) ;;
+     '') AC_MSG_FAILURE([Internal Error: Haven't looked for clock_gettime() yet!]) ;;
     esac
     AC_SEARCH_LIBS([sched_setscheduler], [rt posix4])
     ;;
 esac
 
-AC_CHECK_HEADERS([bstring.h])
+AC_CHECK_HEADERS([bstring.h sys/procctl.h])
 AC_CHECK_HEADER(
     [dns_sd.h],
     [AC_SEARCH_LIBS(
@@ -3008,23 +3008,7 @@ case "$ntp_libparse" in
 esac
 AC_MSG_RESULT([$ans])
 
-NTP_OPENSSL
-
-AC_MSG_CHECKING([if we want to enable CMAC support])
-case "$ac_cv_header_openssl_cmac_h" in
- yes)
-    AC_DEFINE([ENABLE_CMAC], [1], [Enable CMAC support?])
-    ans="yes"
-    ;;
- *) ans="no"
-    ;;
-esac
-AC_MSG_RESULT([$ans])
-
-NTP_CRYPTO_RAND
-
-# if we are using OpenSSL (--with-crypto), by default Autokey is enabled
-AC_MSG_CHECKING([if we want to include NTP Autokey protocol support])
+# if we have crypto, by default Autokey is enabled
 AC_ARG_ENABLE(
     [autokey],
     AS_HELP_STRING(
@@ -3040,7 +3024,7 @@ case "$ntp_autokey" in
  *)
     case "$ntp_openssl" in
      no)
-	AC_MSG_WARN([Disabling Autokey, --enable-autokey requires --with-crypto.])
+	AC_MSG_WARN([Disabling Autokey, crypto unavailable.])
 	ntp_autokey=no
 	;;
      *)
@@ -3050,6 +3034,7 @@ case "$ntp_autokey" in
     esac
     ;;
 esac
+AC_MSG_CHECKING([if NTP Autokey protocol will be supported])
 AC_MSG_RESULT([$ntp_autokey])
 
 AC_SUBST([MAKE_CHECK_LAYOUT])
@@ -4432,6 +4417,18 @@ AC_DEFINE_UNQUOTED([DYNAMIC_INTERLEAVE], [$ntp_dynamic_interleave],
     [support dynamic interleave?])
 AC_MSG_RESULT([$ntp_ok])
 
+AH_BOTTOM([
+	/*
+	 * Macro to use in otherwise-empty source files to comply with ANSI C
+	 * requirement that each translation unit (source file) contain some
+	 * declaration.  This has commonly been done by declaring an unused
+	 * global variable of type int or char.  An extern reference to abs()
+	 * serves the same purpose without bloat.  We once used exit() but
+	 * that can produce warnings on systems that declare exit() noreturn.
+	 */
+	#define	NONEMPTY_TRANSLATION_UNIT	extern int abs(int);
+])
+
 NTP_UNITYBUILD
 
 NTP_PROBLEM_TESTS
@@ -4455,7 +4452,7 @@ AC_CONFIG_FILES([kernel/sys/Makefile])
 AC_CONFIG_FILES([libntp/Makefile])
 AC_CONFIG_FILES([libparse/Makefile])
 AC_CONFIG_FILES([ntpd/Makefile])
-AC_CONFIG_FILES([ntpd/complete.conf],	[sed -e '/^rlimit$/d' -e '/^$/d' < ntpd/complete.conf > ntpd/complete.conf.new && mv ntpd/complete.conf.new ntpd/complete.conf])
+AC_CONFIG_FILES([ntpd/complete.conf],	[$SED -e '/^rlimit$/d' -e '/^$/d' < ntpd/complete.conf > ntpd/complete.conf.new && mv ntpd/complete.conf.new ntpd/complete.conf])
 AC_CONFIG_FILES([ntpdate/Makefile])
 AC_CONFIG_FILES([ntpdc/Makefile])
 AC_CONFIG_FILES([ntpdc/nl.pl],		[chmod +x ntpdc/nl.pl])
diff --git a/contrib/ntp/flock-build b/contrib/ntp/flock-build
index b537ac349175..14767b934e17 100755
--- a/contrib/ntp/flock-build
+++ b/contrib/ntp/flock-build
@@ -34,23 +34,11 @@ case "$PARALLEL_BUILDS" in
  *)  echo Launching $PARALLEL_BUILDS parallel builds on each machine
 esac
 
-# Backroom:
-#   barnstable	   freebsd-6.1
-#   beauregard	   freebsd-6.0
-# X churchy	   alpha-dec-osf5.1
-#   deacon	   sparc-sun-solaris2.10
-#   grundoon	   freebsd-6.2
-#   howland	   freebsd-6.1
-# o macabre	   freebsd-6.1-STABLE
-# o mort	   freebsd-6.1
-#   whimsy	   sparc-sun-solaris2.10
-
 # Campus:
 # * baldwin	   sparc-sun-solaris2.10
 # * bridgeport	   sparc-sun-solaris2.10
-# * malarky	   sparc-sun-solaris2.10
 # * pogo	   sparc-sun-solaris2.10
-# * rackety	   freebsd-6.1
+# * rackety	   sparc-sun-solaris2.10
 
 if [ ! -r sntp/libevent/build-aux/config.guess ] ; then
 	echo "Error: bootstrap required." 1>&2 && exit 1
@@ -80,8 +68,8 @@ do
 	case "1" in
 	 0)
 	    ssh $i "cd $c_d ; ./build $SIG $PARSE $STD $BUILD_ARGS" &
-	    ssh $i "cd $c_d ; ./build $SIG $PARSE $STD --disable-debugging $BUILD_ARGS" &
-	    ssh $i "cd $c_d ; ./build $SIG $PARSE $STD --without-crypto --enable-c99-snprintf $BUILD_ARGS" &
+	    ssh $i "cd $c_d ; ./build $SIG $PARSE $STD --disable-debugging --disable-saveconfig $BUILD_ARGS" &
+	    ssh $i "cd $c_d ; ./build $SIG $PARSE $STD --without-crypto --enable-c99-snprintf --enable-leap-smear $BUILD_ARGS" &
 	    ssh $i "cd $c_d ; ./build $SIG        $STD --disable-all-clocks --disable-autokey --without-sntp --disable-thread-support $BUILD_ARGS" &
 	    ;;
 	 1)
@@ -103,13 +91,13 @@ do
 
 		case $FB_FIRSTONLY in
 		 '0')
-			./build $SIG $PARSE $STD --disable-debugging $BUILD_ARGS &
+			./build $SIG $PARSE $STD --disable-debugging --disable-saveconfig $BUILD_ARGS &
 
 			COUNT=\`expr \$COUNT + 1\`
 			echo \`date -u '+%H:%M:%S'\` $i started build \$COUNT of 4
 			[ 0 -lt \`expr \$COUNT % $PARALLEL_BUILDS\` ] || wait
 
-			./build $SIG $PARSE $STD --without-crypto --enable-c99-snprintf $BUILD_ARGS &
+			./build $SIG $PARSE $STD --without-crypto --enable-c99-snprintf --enable-leap-smear $BUILD_ARGS &
 
 			COUNT=\`expr \$COUNT + 1\`
 			echo \`date -u '+%H:%M:%S'\` $i started build \$COUNT of 4
diff --git a/contrib/ntp/html/.datecheck b/contrib/ntp/html/.datecheck
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/contrib/ntp/html/clockopt.html b/contrib/ntp/html/clockopt.html
index 5b2de7e58d6e..5a721a8a745e 100644
--- a/contrib/ntp/html/clockopt.html
+++ b/contrib/ntp/html/clockopt.html
@@ -29,8 +29,8 @@
       <dd>Marks the reference clock as preferred. All other things being equal, this host will be chosen for synchronization among a set of correctly operating hosts. See the <a href="prefer.html">Mitigation Rules and the <tt>prefer</tt> Keyword</a> page for further information.</dd>
       <dt><tt>mode <i>int</i></tt></dt>
       <dd>Specifies a mode number which is interpreted in a device-specific fashion. For instance, it selects a dialing protocol in the ACTS driver and a device subtype in the <tt>parse</tt> drivers.</dd>
-      <dt><tt>minpoll <i>int</i></tt><br>
-        <tt>maxpoll <i>int</i></tt></dt>
+      <dt><tt>minpoll <i>int</i></tt></dt>
+      <dt><tt>maxpoll <i>int</i></tt></dt>
       <dd>These options specify the minimum and maximum polling interval for reference clock messages in log<sub>2</sub> seconds. For most directly connected reference clocks, both <tt>minpoll</tt> and <tt>maxpoll</tt> default to 6 (64 s). For modem reference clocks, <tt>minpoll</tt> is ordinarily set to 10 (about 17 m) and <tt>maxpoll</tt> to  15 (about 9 h). The allowable range is 4 (16 s) to 17 (36 h) inclusive.</dd>
     </dl>
   </dd>
@@ -48,7 +48,10 @@
       <dd>Specifies the stratum number assigned to the driver in the range 0 to 15, inclusive. This number overrides the default stratum number ordinarily assigned by the driver itself, usually zero.</dd>
       <dt><tt>refid <i>string</i></tt></dt>
       <dd>Specifies an ASCII string of from one to four characters which defines the reference identifier used by the driver. This string overrides the default identifier ordinarily assigned by the driver itself.</dd>
-      <dt><tt>flag1 flag2 flag3 flag4</tt></dt>
+      <dt><tt>flag1 0|1</tt></dt>
+      <dt><tt>flag2 0|1</tt></dt>
+      <dt><tt>flag3 0|1</tt></dt>
+      <dt><tt>flag4 0|1</tt></dt>
       <dd>These four flags are used for customizing the clock driver. The interpretation of these values, and whether they are used at all, is a function of the particular  driver. However, by convention <tt>flag4</tt> is used to enable recording monitoring data to the <tt>clockstats</tt> file configured with the <tt>filegen</tt> command. Additional information on the <tt>filegen</tt> command is on the <a href="monopt.html">Monitoring Options</a> page.</dd>
       <dt><tt>minjitter <i>secs</i></tt></dt>
       <dd>If the source has a jitter that cannot be sensibly estimated, because
diff --git a/contrib/ntp/html/copyright.html b/contrib/ntp/html/copyright.html
index d00cf9712178..7584aefc3230 100644
--- a/contrib/ntp/html/copyright.html
+++ b/contrib/ntp/html/copyright.html
@@ -9,7 +9,7 @@
 <h3>Copyright Notice</h3>
 <img src="pic/sheepb.jpg" alt="jpg" align="left"> "Clone me," says Dolly sheepishly.
 <p>Last update:
-  <!-- #BeginDate format:En2m -->2-Mar-2023  05:21<!-- #EndDate -->
+  <!-- #BeginDate format:En2m -->7-Jan-2024  00:29<!-- #EndDate -->
     UTC</p>
 <br clear="left">
 </p>
@@ -38,7 +38,7 @@
 <pre>
 ***********************************************************************
 *                                                                     *
-* Copyright (c) Network Time Foundation 2011-2023                     *
+* Copyright (c) Network Time Foundation 2011-2024                     *
 *                                                                     *
 * All Rights Reserved                                                 *
 *                                                                     *
diff --git a/contrib/ntp/html/release.html b/contrib/ntp/html/release.html
index f940603a0947..d354ba653953 100644
--- a/contrib/ntp/html/release.html
+++ b/contrib/ntp/html/release.html
@@ -37,7 +37,7 @@
   <li>There are two new burst mode features available where special conditions apply. One of these is enabled by the <tt>iburst</tt> keyword in the <tt>server</tt> configuration command. It is intended for cases where it is important to set the clock quickly when an association is first mobilized. The other is enabled by the <tt>burst</tt> keyword in the <tt>server</tt> configuration command. It is intended for cases where the network attachment requires an initial calling or training procedure. See the <a href="assoc.html">Association Management</a> page for further information.</li>
   <li>The OpenSSL cryptographic library has replaced the library formerly available from RSA Laboratories. All cryptographic routines except a version of the MD5 message digest algorithm have been removed from the base distribution. All 128-bit and 160-bit message digests algorithms are now supported for both symmetric key and public key cryptosystems. See the <a href="authentic.html">Authentication Support</a> page for further information and the <a href="authopt.html">Authentication Options</a> page for a list of supported digest algorithms.</li>
   <li>This release includes  support for  Autokey public-key cryptography for authenticating public servers to clients, as described in RFC 5906. This support requires the --enable-autokey option when building the distribution, which is the default is OpenSSL is available. The deployment of Autokey subnets is now considerably simpler than in earlier versions. A subnet naming scheme is now available to filter manycast and pool configurations. Additional information about Autokey  is on the <a href="autokey.html">Autokey Public Key Authentication</a> page and links from there.</li>
-  <li>The NTP descrete even simulator has been substantially upgraded, now including scenarios with multiple servers and time-sensitive scripts. This allows  the NTP&nbsp;algorithms to be tested in an embedded environment with systematic and pseudo-random network delay and oscillator wander distributions. This has been used to verify correct operation under conditions of extreme error and misconfiguration. See the <a href="ntpdsim.html"><tt>ntpdsim</tt> - Network Time Protocol (NTP) simulator</a> page. A technical description and performance analysis is given in the white papers at the <a href="http://www.eecis.udel.edu/~mills/ntp.html">NTP Project Page</a>.</li>
+  <li>The NTP descrete event simulator has been substantially upgraded, now including scenarios with multiple servers and time-sensitive scripts. This allows  the NTP&nbsp;algorithms to be tested in an embedded environment with systematic and pseudo-random network delay and oscillator wander distributions. This has been used to verify correct operation under conditions of extreme error and misconfiguration. See the <a href="ntpdsim.html"><tt>ntpdsim</tt> - Network Time Protocol (NTP) simulator</a> page. A technical description and performance analysis is given in the white papers at the <a href="http://www.eecis.udel.edu/~mills/ntp.html">NTP Project Page</a>.</li>
   <li>NTPv4 includes three new server discovery schemes, which in most applications can avoid per-host configuration altogether. Two of these are based on IP multicast technology, while the remaining one is based on crafted DNS lookups. See the <a href="discover.html">Automatic NTP Configuration Schemes</a> page for further information.</li>
   <li>The status display and event report monitoring functions have been considerably expanded, including new statistics files and  event reporting to files and the system log. See the <a href="decode.html">Event Messages and Status Words</a> page for further information.</li>
   <li>Several new options have been added for the <tt>ntpd</tt> command line. For the inveterate knob twiddlers several of the more important performance variables can be changed to fit actual or perceived special conditions. In particular, the <tt>tinker</tt> and <tt>tos</tt> commands can be used to adjust thresholds, throw switches and change limits.</li>
diff --git a/contrib/ntp/include/Makefile.am b/contrib/ntp/include/Makefile.am
index dd739ebbcdbd..b661ca639f29 100644
--- a/contrib/ntp/include/Makefile.am
+++ b/contrib/ntp/include/Makefile.am
@@ -8,6 +8,7 @@ noinst_HEADERS =	\
 	ascii.h		\
 	audio.h		\
 	binio.h		\
+	c99_snprintf.h	\
 	declcond.h	\
 	gps.h		\
 	hopf6039.h	\
diff --git a/contrib/ntp/include/Makefile.in b/contrib/ntp/include/Makefile.in
index 5bf244e81bd8..317111a094b1 100644
--- a/contrib/ntp/include/Makefile.in
+++ b/contrib/ntp/include/Makefile.in
@@ -386,6 +386,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_NET_SNMP_CONFIG = @PATH_NET_SNMP_CONFIG@
+PATH_OPENSSL = @PATH_OPENSSL@
 PATH_PERL = @PATH_PERL@
 PATH_RUBY = @PATH_RUBY@
 PATH_SEPARATOR = @PATH_SEPARATOR@
@@ -492,6 +493,7 @@ noinst_HEADERS = \
 	ascii.h		\
 	audio.h		\
 	binio.h		\
+	c99_snprintf.h	\
 	declcond.h	\
 	gps.h		\
 	hopf6039.h	\
diff --git a/contrib/ntp/include/c99_snprintf.h b/contrib/ntp/include/c99_snprintf.h
new file mode 100644
index 000000000000..f5c1bf0e117c
--- /dev/null
+++ b/contrib/ntp/include/c99_snprintf.h
@@ -0,0 +1,28 @@
+/*
+ * ntp_c99_snprintf.h
+ *
+ * Included from config.h to deal with replacing [v]snprintf() on older
+ * systems.  The #undef lines below cannot be directly in config.h as
+ * config.status modifies each #undef in config.h.in to either be a
+ * commented-out #undef or a functional #define.  Here they are used
+ * to avoid redefinition warnings on systems such as macos ca. 2024
+ * where system headers define [v]snprintf as preprocessor macros.
+ *
+ * Do not include this file directly, leave it to config.h.
+ */
+
+#if !defined(_KERNEL) && !defined(PARSESTREAM)
+/*
+ * stdio.h must be included in config.h after _GNU_SOURCE is defined
+ * but before #define snprintf rpl_snprintf
+ */
+# include <stdio.h>
+#endif
+
+#ifdef HW_WANT_RPL_SNPRINTF
+# undef snprintf
+#endif
+#ifdef HW_WANT_RPL_VSNPRINTF
+# undef vsnprintf
+#endif
+
diff --git a/contrib/ntp/include/isc/Makefile.in b/contrib/ntp/include/isc/Makefile.in
index 037cfbe354bf..fadd48e1c8ee 100644
--- a/contrib/ntp/include/isc/Makefile.in
+++ b/contrib/ntp/include/isc/Makefile.in
@@ -344,6 +344,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_NET_SNMP_CONFIG = @PATH_NET_SNMP_CONFIG@
+PATH_OPENSSL = @PATH_OPENSSL@
 PATH_PERL = @PATH_PERL@
 PATH_RUBY = @PATH_RUBY@
 PATH_SEPARATOR = @PATH_SEPARATOR@
diff --git a/contrib/ntp/include/lib_strbuf.h b/contrib/ntp/include/lib_strbuf.h
index 5ee92d6f8341..89da450a5547 100644
--- a/contrib/ntp/include/lib_strbuf.h
+++ b/contrib/ntp/include/lib_strbuf.h
@@ -5,28 +5,28 @@
 #define LIB_STRBUF_H
 
 #include <ntp_types.h>
-#include <ntp_malloc.h>			/* for ZERO() */
+#include <ntp_malloc.h>			/* for zero_mem() */
 
-/*
- * Sizes of things
- */
-#define LIB_NUMBUF	16
 #define	LIB_BUFLENGTH	128
 
-typedef char libbufstr[LIB_BUFLENGTH];
-extern libbufstr lib_stringbuf[LIB_NUMBUF];
-extern int lib_nextbuf;
-extern int lib_inited;
+extern int	lib_inited;
+extern int	ipv4_works;
+extern int	ipv6_works;
 
+extern	void	init_lib(void);
 
 /*
- * Macro to get a pointer to the next buffer
+ * Get a pointer to the next string buffer of LIB_BUFLENGTH octets.
+ * New and modified code should use buf = lib_getbuf() directly to
+ * provide clarity for folks familiar with common C style, but there's
+ * no need to churn the history with a mechanical switch away from
+ * LIB_GETBUF(buf).
  */
-#define	LIB_GETBUF(bufp)					\
-	do {							\
-		ZERO(lib_stringbuf[lib_nextbuf]);		\
-		(bufp) = &lib_stringbuf[lib_nextbuf++][0];	\
-		lib_nextbuf %= COUNTOF(lib_stringbuf);		\
+extern	char* lib_getbuf(void);
+
+#define	LIB_GETBUF(bufp)		\
+	do {				\
+		(bufp) = lib_getbuf();	\
 	} while (FALSE)
 
 #endif	/* LIB_STRBUF_H */
diff --git a/contrib/ntp/include/ntp.h b/contrib/ntp/include/ntp.h
index 258ddd6138f7..7406a79ea8a4 100644
--- a/contrib/ntp/include/ntp.h
+++ b/contrib/ntp/include/ntp.h
@@ -171,8 +171,8 @@ typedef char s_char;
  * Eventually the struct tag will change from interface to endpt_tag.
  * endpt is unrelated to the select algorithm's struct endpoint.
  */
-typedef struct interface endpt;
-struct interface {
+typedef struct endpt_tag endpt;
+struct endpt_tag {
 	endpt *		elink;		/* endpt list link */
 	endpt *		mclink;		/* per-AF_* multicast list */
 	void *		ioreg_ctx;	/* IO registration context */
@@ -185,9 +185,12 @@ struct interface {
 	char		name[32];	/* name of interface */
 	u_short		family;		/* AF_INET/AF_INET6 */
 	u_short		phase;		/* phase in update cycle */
-	u_int32		flags;		/* interface flags */
+	u_int32		flags;		/* INT_ flags */
 	int		last_ttl;	/* last TTL specified */
 	u_int32		addr_refid;	/* IPv4 addr or IPv6 hash */
+#    ifdef WORDS_BIGENDIAN
+	u_int32		old_refid;	/* byte-swapped IPv6 refid */
+#    endif
 	int		num_mcast;	/* mcast addrs enabled */
 	u_long		starttime;	/* current_time at creation */
 	volatile long	received;	/* number of incoming packets */
@@ -200,11 +203,11 @@ struct interface {
 };
 
 /*
- * Flags for interfaces
+ * Flags for network endpoints (interfaces or really addresses)
  */
 #define INT_UP		0x001	/* Interface is up */
 #define	INT_PPP		0x002	/* Point-to-point interface */
-#define	INT_LOOPBACK	0x004	/* the loopback interface */
+#define	INT_LOOPBACK	0x004	/* ::1 or 127.0.0.1 */
 #define	INT_BROADCAST	0x008	/* can broadcast out this interface */
 #define INT_MULTICAST	0x010	/* can multicast out this interface */
 #define	INT_BCASTOPEN	0x020	/* broadcast receive socket is open */
@@ -212,7 +215,8 @@ struct interface {
 #define INT_WILDCARD	0x080	/* wildcard interface - usually skipped */
 #define INT_MCASTIF	0x100	/* bound directly to MCAST address */
 #define INT_PRIVACY	0x200	/* RFC 4941 IPv6 privacy address */
-#define INT_BCASTXMIT	0x400   /* socket setup to allow broadcasts */
+#define INT_BCASTXMIT	0x400	/* socket setup to allow broadcasts */
+#define INT_LL_OF_GLOB	0x800	/* IPv6 link-local duplicate of global */
 
 /*
  * Define flasher bits (tests 1 through 11 in packet procedure)
@@ -342,12 +346,12 @@ struct peer {
 	u_char	status;		/* peer status */
 	u_char	new_status;	/* under-construction status */
 	u_char	reach;		/* reachability register */
+	u_char	filter_nextpt;	/* index into filter shift register */
 	int	flash;		/* protocol error test tally bits */
 	u_long	epoch;		/* reference epoch */
 	int	burst;		/* packets remaining in burst */
 	int	retry;		/* retry counter */
 	int	flip;		/* interleave mode control */
-	int	filter_nextpt;	/* index into filter shift register */
 	double	filter_delay[NTP_SHIFT]; /* delay shift register */
 	double	filter_offset[NTP_SHIFT]; /* offset shift register */
 	double	filter_disp[NTP_SHIFT]; /* dispersion shift register */
@@ -463,11 +467,12 @@ struct peer {
 #define	FLAG_XLEAVE	0x1000	/* interleaved protocol */
 #define	FLAG_XB		0x2000	/* interleaved broadcast */
 #define	FLAG_XBOGUS	0x4000	/* interleaved bogus packet */
-#ifdef	OPENSSL
+#ifdef	AUTOKEY
 # define FLAG_ASSOC	0x8000	/* autokey request */
-#endif /* OPENSSL */
+#endif
 #define FLAG_TSTAMP_PPS	0x10000	/* PPS source provides absolute timestamp */
 #define FLAG_LOOPNONCE	0x20000	/* Use a nonce for the loopback test */
+#define FLAG_DISABLED	0x40000	/* peer is being torn down */
 
 /*
  * Definitions for the clear() routine.  We use memset() to clear
@@ -558,9 +563,15 @@ struct pkt {
 #define	MIN_V4_PKT_LEN	(12 * sizeof(u_int32))	/* min header length */
 #define	LEN_PKT_NOMAC	(12 * sizeof(u_int32))	/* min header length */
 #define	MIN_MAC_LEN	(1 * sizeof(u_int32))	/* crypto_NAK */
-#define	MAX_MD5_LEN	(5 * sizeof(u_int32))	/* MD5 */
-#define	MAX_MAC_LEN	(6 * sizeof(u_int32))	/* SHA */
+#define	MD5_LENGTH	16
+#define	SHAKE128_LENGTH	16
+#define	CMAC_LENGTH	16
+#define	SHA1_LENGTH	20
 #define	KEY_MAC_LEN	sizeof(u_int32)		/* key ID in MAC */
+#define	MAX_MD5_LEN	(KEY_MAC_LEN + MD5_LENGTH)
+#define	MAX_SHAKE128_LEN (KEY_MAC_LEN + SHAKE128_LENGTH)
+#define	MAX_SHA1_LEN	(KEY_MAC_LEN + SHA1_LENGTH)
+#define	MAX_MAC_LEN	(6 * sizeof(u_int32))	/* any MAC */
 #define	MAX_MDG_LEN	(MAX_MAC_LEN-KEY_MAC_LEN) /* max. digest len */
 
 	/*
@@ -703,6 +714,10 @@ struct pkt {
 #define	max(a,b)	(((a) > (b)) ? (a) : (b))
 #define	min3(a,b,c)	min(min((a),(b)), (c))
 
+/* clamp a value within a range */
+#define CLAMP(val, minval, maxval)				\
+			max((minval), min((val), (maxval)))
+
 
 /*
  * Configuration items.  These are for the protocol module (proto_config())
@@ -783,7 +798,7 @@ typedef struct mon_data	mon_entry;
 struct mon_data {
 	mon_entry *	hash_next;	/* next structure in hash list */
 	DECL_DLIST_LINK(mon_entry, mru);/* MRU list link pointers */
-	struct interface * lcladr;	/* address on which this arrived */
+	endpt *		lcladr;	/* address on which this arrived */
 	l_fp		first;		/* first time seen */
 	l_fp		last;		/* last time seen */
 	int		leak;		/* leaky bucket accumulator */
@@ -804,7 +819,7 @@ struct mon_data {
 #define	MDF_POOL	0x08	/* pool client solicitor */
 #define MDF_ACAST	0x10	/* manycast client solicitor */
 #define	MDF_BCLNT	0x20	/* eph. broadcast/multicast client */
-#define MDF_UCLNT	0x40	/* preemptible manycast or pool client */
+#define MDF_PCLNT	0x40	/* preemptible pool client */
 /*
  * In the context of struct peer in ntpd, three of the cast_flags bits
  * represent configured associations which never receive packets, and
@@ -841,11 +856,10 @@ typedef struct restrict_u_tag	restrict_u;
 struct restrict_u_tag {
 	restrict_u *	link;		/* link to next entry */
 	u_int32		count;		/* number of packets matched */
+	u_int32		expire;		/* valid until current_time */
 	u_short		rflags;		/* restrict (accesslist) flags */
-	u_short		mflags;		/* match flags */
-	short		ippeerlimit;	/* IP peer limit */
-	int		srvfuzrftpoll;	/* server response: fuzz reftime */
-	u_long		expire;		/* valid until time */
+	u_int32		mflags;		/* match flags */
+	short		ippeerlimit;	/* limit of associations matching */
 	union {				/* variant starting here */
 		res_addr4 v4;
 		res_addr6 v6;
@@ -856,16 +870,13 @@ struct restrict_u_tag {
 #define	V6_SIZEOF_RESTRICT_U	(offsetof(restrict_u, u)	\
 				 + sizeof(res_addr6))
 
+/* restrictions for (4) a given address */
 typedef struct r4addr_tag	r4addr;
 struct r4addr_tag {
 	u_short		rflags;		/* match flags */
 	short		ippeerlimit;	/* IP peer limit */
 };
 
-char *build_iflags(u_int32 flags);
-char *build_mflags(u_short mflags);
-char *build_rflags(u_short rflags);
-
 /*
  * Restrict (Access) flags (rflags)
  */
@@ -876,10 +887,6 @@ char *build_rflags(u_short rflags);
 #define	RES_NOPEER		0x0010	/* new association denied */
 #define	RES_NOEPEER		0x0020	/* new ephemeral association denied */
 #define RES_LIMITED		0x0040	/* packet rate exceeded */
-#define RES_FLAGS		(RES_IGNORE | RES_DONTSERVE |\
-				    RES_DONTTRUST | RES_VERSION |\
-				    RES_NOPEER | RES_NOEPEER | RES_LIMITED)
-
 #define	RES_NOQUERY		0x0080	/* mode 6/7 packet denied */
 #define	RES_NOMODIFY		0x0100	/* mode 6/7 modify denied */
 #define	RES_NOTRAP		0x0200	/* mode 6/7 set trap denied */
@@ -894,7 +901,10 @@ char *build_rflags(u_short rflags);
 
 #define RES_UNUSED		0x0000	/* Unused flag bits (none left) */
 
-#define	RES_ALLFLAGS		(RES_FLAGS | RES_NOQUERY |	\
+#define	RES_ALLFLAGS		(RES_IGNORE | RES_DONTSERVE |	\
+				 RES_DONTTRUST | RES_VERSION |	\
+				 RES_NOPEER | RES_NOEPEER |	\
+				 RES_LIMITED | RES_NOQUERY |	\
 				 RES_NOMODIFY | RES_NOTRAP |	\
 				 RES_LPTRAP | RES_KOD |		\
 				 RES_MSSNTP | RES_FLAKE |	\
@@ -948,4 +958,15 @@ struct endpoint {
 #define MRU_ROW_LIMIT	256
 /* similar datagrams per response limit for ntpd */
 #define MRU_FRAGS_LIMIT	128
+
+/* found on POSIX systems in sysexit.h */
+#ifndef EX_SOFTWARE
+# define EX_SOFTWARE	70	/* internal software error */
+#endif
+
+#define BYTESWAP32(u32)							\
+			(((u_int32)(u32) & 0xff000000) >> 24 |		\
+			 ((u_int32)(u32) &   0xff0000) >>  8 |		\
+			 ((u_int32)(u32) &     0xff00) <<  8 |		\
+			 ((u_int32)(u32) &       0xff) << 24)
 #endif /* NTP_H */
diff --git a/contrib/ntp/include/ntp_config.h b/contrib/ntp/include/ntp_config.h
index dbb64e3a2eee..2fce70945035 100644
--- a/contrib/ntp/include/ntp_config.h
+++ b/contrib/ntp/include/ntp_config.h
@@ -113,7 +113,9 @@ struct restrict_node_tag {
 	address_node *	addr;
 	address_node *	mask;
 	attr_val_fifo *	flag_tok_fifo;
+	int/*BOOL*/	remove;
 	int		line_no;
+	int		column;
 	short		ippeerlimit;
 	short		srvfuzrft;
 };
@@ -317,10 +319,13 @@ void	  destroy_attr_val(attr_val *node);
 filegen_node *create_filegen_node(int filegen_token,
 				  attr_val_fifo *options);
 string_node *create_string_node(char *str);
-restrict_node *create_restrict_node(address_node *addr,
-				    address_node *mask,
-				    short ippeerlimit,
-				    attr_val_fifo *flags, int line_no);
+restrict_node *create_restrict_node(address_node *	addr,
+				    address_node *	mask,
+				    short		ippeerlimit,
+				    attr_val_fifo *	flag_tok_fifo,
+				    int/*BOOL*/		remove,
+				    int			nline,
+				    int			ncol);
 int_node *create_int_node(int val);
 addr_opts_node *create_addr_opts_node(address_node *addr,
 				      attr_val_fifo *options);
diff --git a/contrib/ntp/include/ntp_control.h b/contrib/ntp/include/ntp_control.h
index 2fe0f30bbd78..91b85aa52df4 100644
--- a/contrib/ntp/include/ntp_control.h
+++ b/contrib/ntp/include/ntp_control.h
@@ -159,7 +159,7 @@ struct ntp_control {
  */
 struct ctl_trap {
 	sockaddr_u tr_addr;		/* address of trap recipient */
-	struct interface *tr_localaddr;	/* interface to send this through */
+	endpt *tr_localaddr;		/* interface to send this through */
 	u_long tr_settime;		/* time trap was set */
 	u_long tr_count;		/* async messages sent to this guy */
 	u_long tr_origtime;		/* time trap was originally set */
diff --git a/contrib/ntp/include/ntp_lists.h b/contrib/ntp/include/ntp_lists.h
index d741974943ef..bed692ff294e 100644
--- a/contrib/ntp/include/ntp_lists.h
+++ b/contrib/ntp/include/ntp_lists.h
@@ -181,7 +181,7 @@ do {								\
 
 #define UNLINK_EXPR_SLIST(punlinked, listhead, expr, nextlink,	\
 			  entrytype)				\
-do {								\
+if (NULL != (listhead)) {					\
 	entrytype **ppentry;					\
 								\
 	ppentry = &(listhead);					\
@@ -202,6 +202,8 @@ do {								\
 	} else {						\
 		(punlinked) = NULL;				\
 	}							\
+} else do {							\
+	(punlinked) = NULL;					\
 } while (FALSE)
 
 #define UNLINK_SLIST(punlinked, listhead, ptounlink, nextlink,	\
diff --git a/contrib/ntp/include/ntp_md5.h b/contrib/ntp/include/ntp_md5.h
index 8b5a7d0cbb49..22caff350cd9 100644
--- a/contrib/ntp/include/ntp_md5.h
+++ b/contrib/ntp/include/ntp_md5.h
@@ -6,6 +6,18 @@
 #ifndef NTP_MD5_H
 #define NTP_MD5_H
 
+/* Use the system MD5 or fall back on libisc's */
+# if defined HAVE_MD5_H && defined HAVE_MD5INIT
+#  include <md5.h>
+# else
+#  include "isc/md5.h"
+   typedef isc_md5_t		MD5_CTX;
+#  define MD5_DIGEST_LENGTH	ISC_MD5_DIGESTLENGTH
+#  define MD5Init(c)		isc_md5_init(c)
+#  define MD5Update(c, p, s)	isc_md5_update(c, (const void *)p, s)
+#  define MD5Final(d, c)	isc_md5_final((c), (d))	/* swapped */
+# endif
+
 # define KEY_TYPE_MD5			NID_md5
 
 #ifdef OPENSSL
@@ -20,20 +32,11 @@
 /*
  * Provide OpenSSL-alike MD5 API if we're not using OpenSSL
  */
-# if defined HAVE_MD5_H && defined HAVE_MD5INIT
-#  include <md5.h>
-# else
-#  include "isc/md5.h"
-   typedef isc_md5_t		MD5_CTX;
-#  define MD5Init(c)		isc_md5_init(c)
-#  define MD5Update(c, p, s)	isc_md5_update(c, p, s)
-#  define MD5Final(d, c)	isc_md5_final((c), (d))	/* swapped */
-# endif
 
   typedef MD5_CTX			EVP_MD_CTX;
 
 # define NID_md5			4	/* from openssl/objects.h */
-# define EVP_MAX_MD_SIZE		64	/* from openssl/evp.h */
+# define EVP_MAX_MD_SIZE		MD5_DIGEST_LENGTH
 # define EVP_MD_CTX_free(c)		free(c)
 # define EVP_MD_CTX_new()		calloc(1, sizeof(MD5_CTX))
 # define EVP_get_digestbynid(t)		NULL
@@ -47,7 +50,7 @@
 # define EVP_DigestFinal(c, d, pdl)	\
 	do {				\
 		MD5Final((d), (c));	\
-		*(pdl) = 16;		\
+		*(pdl) = MD5_LENGTH;	\
 	} while (0)
 # endif	/* !OPENSSL */
 #endif	/* NTP_MD5_H */
diff --git a/contrib/ntp/include/ntp_net.h b/contrib/ntp/include/ntp_net.h
index 0577402bfb2c..09cc7f65f97b 100644
--- a/contrib/ntp/include/ntp_net.h
+++ b/contrib/ntp/include/ntp_net.h
@@ -195,7 +195,7 @@ typedef union {
 #define SOCK_UNSPEC_S(psau)					\
 	(SOCK_UNSPEC(psau) && !SCOPE(psau))
 
-/* choose a default net interface (struct interface) for v4 or v6 */
+/* choose a default net interface (endpt) for v4 or v6 */
 #define ANY_INTERFACE_BYFAM(family)				\
 	((AF_INET == family)					\
 	     ? any_interface					\
@@ -227,6 +227,12 @@ typedef union {
  */
 #define	LOOPBACKADR	0x7f000001
 #define	LOOPNETMASK	0xff000000
+#ifdef WORDS_BIGENDIAN
+# define LOOPBACKADR_N	LOOPBACKADR
+#else 
+# define LOOPBACKADR_N	0x0100007f
+#endif
+
 
 #define	ISBADADR(srcadr)					\
 	(IS_IPV4(srcadr)					\
@@ -234,5 +240,10 @@ typedef union {
 	     == (LOOPBACKADR & LOOPNETMASK))			\
 	 && SRCADR(srcadr) != LOOPBACKADR)
 
+#define IS_LOOPBACK_ADDR(psau)					\
+		(IS_IPV4(psau)					\
+		    ? LOOPBACKADR == SRCADR(psau)		\
+		    : IN6_IS_ADDR_LOOPBACK(PSOCK_ADDR6(psau))	\
+		)
 
 #endif /* NTP_NET_H */
diff --git a/contrib/ntp/include/ntp_psl.h b/contrib/ntp/include/ntp_psl.h
index a0c2662d44c7..c3a6846f90d0 100644
--- a/contrib/ntp/include/ntp_psl.h
+++ b/contrib/ntp/include/ntp_psl.h
@@ -4,12 +4,15 @@
 
 /*
  * Poll Skew List Item
+ * u_in32 is large enough for sub and qty so long as NTP_MAXPOLL < 31
  */
-
+#if NTP_MAXPOLL >= 31
+#include "psl_item structure needs larger type"
+#endif
 typedef struct psl_item_tag {
-	int		sub;	/* int or short?  unsigned is OK, but why? */
-	int		qty;	/* int or short?  unsigned is OK, but why? */
-	int		msk;	/* int or short?  unsigned is OK */
+	u_int32	sub;
+	u_int32	qty;
+	u_int32	msk;
 } psl_item;
 
 int get_pollskew(int, psl_item *);
diff --git a/contrib/ntp/include/ntp_stdlib.h b/contrib/ntp/include/ntp_stdlib.h
index 446837e3adcb..6f667fbabed7 100644
--- a/contrib/ntp/include/ntp_stdlib.h
+++ b/contrib/ntp/include/ntp_stdlib.h
@@ -11,10 +11,12 @@
 
 #include "declcond.h"	/* ntpd uses ntpd/declcond.h, others include/ */
 #include "l_stdlib.h"
+#include "lib_strbuf.h"
 #include "ntp_md5.h"
 #include "ntp_net.h"
 #include "ntp_debug.h"
 #include "ntp_malloc.h"
+#include "lib_strbuf.h"
 #include "ntp_string.h"
 #include "ntp_syslog.h"
 #include "ntp_keyacc.h"
@@ -113,7 +115,7 @@ extern	size_t	MD5authencrypt	(int type, const u_char *key, size_t klen,
 extern	int	MD5authdecrypt	(int type, const u_char *key, size_t klen,
 				 u_int32 *pkt, size_t length, size_t size,
 				 keyid_t keyno);
-extern	u_int32	addr2refid(sockaddr_u *);
+extern	u_int32	addr2refid	(sockaddr_u *);
 
 /* authkeys.c */
 extern	void	MD5auth_setkey	(keyid_t, int, const u_char *, size_t,
@@ -180,7 +182,6 @@ extern	const char * k_st_flags	(u_int32);
 extern	char *	statustoa	(int, int);
 extern	sockaddr_u * netof	(sockaddr_u *);
 extern	char *	numtoa		(u_int32);
-extern	char *	numtohost	(u_int32);
 extern	const char * socktoa	(const sockaddr_u *);
 extern	const char * sockporttoa(const sockaddr_u *);
 extern	u_short	sock_hash	(const sockaddr_u *);
@@ -242,18 +243,21 @@ extern pset_tod_using	set_tod_using;
 #ifdef OPENSSL
 extern	void	ssl_init		(void);
 extern	void	ssl_check_version	(void);
-extern	int	ssl_init_done;
+extern	EVP_MD_CTX* digest_ctx;		/* also ssl_init_done */
 #define	INIT_SSL()				\
 	do {					\
-		if (!ssl_init_done)		\
+		if (NULL == digest_ctx)	{	\
 			ssl_init();		\
-	} while (0)
+		}				\
+	} while (FALSE)
 #else	/* !OPENSSL follows */
+#define ssl_check_version()	do {} while (0)
 #define	INIT_SSL()		do {} while (0)
 #endif
-extern	int	keytype_from_text	(const char *,	size_t *);
-extern	const char *keytype_name	(int);
-extern	char *	getpass_keytype		(int);
+extern	int	keytype_from_text	(const char *text,
+					 size_t *pdigest_len);
+extern	const char *keytype_name	(int type);
+extern	char *	getpass_keytype		(int type);
 
 /* strl-obsd.c */
 #ifndef HAVE_STRLCPY		/* + */
diff --git a/contrib/ntp/include/ntp_tty.h b/contrib/ntp/include/ntp_tty.h
index 6dc48b6c71f1..56f75c115907 100644
--- a/contrib/ntp/include/ntp_tty.h
+++ b/contrib/ntp/include/ntp_tty.h
@@ -100,4 +100,9 @@ extern	int	ntp_tty_ioctl(int, u_int);
 # endif
 #endif
 
+extern	int	symBaud2numBaud(int symBaud);
+# if 0
+extern	int	numBaud2symBaud(int numBaud);
+#endif
+
 #endif /* NTP_TTY_H */
diff --git a/contrib/ntp/include/ntp_types.h b/contrib/ntp/include/ntp_types.h
index c3cf2c196521..6553f01b8a97 100644
--- a/contrib/ntp/include/ntp_types.h
+++ b/contrib/ntp/include/ntp_types.h
@@ -254,16 +254,6 @@ aligned_ptr(
 	return base + ALIGN_UNITS((minsize < 1) ? 1 : minsize);
 }
 
-/*
- * Macro to use in otherwise-empty source files to comply with ANSI C
- * requirement that each translation unit (source file) contain some
- * declaration.  This has commonly been done by declaring an unused
- * global variable of type int or char.  An extern reference to abs()
- * serves the same purpose without bloat.  We once used exit() but
- * that can produce warnings on systems that declare exit() noreturn.
- */
-#define	NONEMPTY_TRANSLATION_UNIT	extern int abs(int);
-
 /*
  * On Unix struct sock_timeval is equivalent to struct timeval.
  * On Windows built with 64-bit time_t, sock_timeval.tv_sec is a long
diff --git a/contrib/ntp/include/ntpd.h b/contrib/ntp/include/ntpd.h
index ad3e30fbb889..7de19d72de5a 100644
--- a/contrib/ntp/include/ntpd.h
+++ b/contrib/ntp/include/ntpd.h
@@ -47,6 +47,17 @@
 # define DPRINTF(lvl, arg)	do {} while (0)
 #endif
 
+/* clear bitflag only on DEBUG builds */
+#ifdef DEBUG
+# define CLEAR_BIT_IF_DEBUG(bit, flags)			\
+	do {						\
+		(flags) &= ~(bit);			\
+	} while (FALSE)
+#else
+# define CLEAR_BIT_IF_DEBUG(bit, flags)			\
+	do {} while (FALSE)
+#endif
+
 
 /* nt_clockstuff.c */
 #ifdef SYS_WINNT
@@ -60,15 +71,15 @@ extern	char *	saveconfigdir;	/* ntpq saveconfig output directory */
 
 extern	void	getconfig	(int, char **);
 extern	void	ctl_clr_stats	(void);
-extern	int	ctlclrtrap	(sockaddr_u *, struct interface *, int);
+extern	int	ctlclrtrap	(sockaddr_u *, endpt *, int);
 extern	u_short ctlpeerstatus	(struct peer *);
-extern	int	ctlsettrap	(sockaddr_u *, struct interface *, int, int);
+extern	int	ctlsettrap	(sockaddr_u *, endpt *, int, int);
 extern	u_short ctlsysstatus	(void);
 extern	void	init_control	(void);
 extern	void	process_control (struct recvbuf *, int);
 extern	void	report_event	(int, struct peer *, const char *);
-extern	int	mprintf_event	(int, struct peer *, const char *, ...)
-			NTP_PRINTF(3, 4);
+extern	int	mprintf_event	(int evcode, struct peer *p,
+				 const char *fmt, ...) NTP_PRINTF(3, 4);
 
 /* ntp_control.c */
 /*
@@ -118,7 +129,9 @@ extern	void	enable_broadcast	(endpt *, sockaddr_u *);
 extern	void	enable_multicast_if	(endpt *, sockaddr_u *);
 extern	void	interface_update	(interface_receiver_t, void *);
 #ifndef HAVE_IO_COMPLETION_PORT
-extern  void    io_handler              (void);
+extern	void	io_handler		(void);
+#else
+extern	void WINAPI ip_interface_changed(ULONG_PTR ctx);
 #endif
 extern	void	init_io 	(void);
 extern	void	io_open_sockets	(void);
@@ -127,8 +140,10 @@ extern	void	io_setbclient	(void);
 extern	void	io_unsetbclient	(void);
 extern	void	io_multicast_add(sockaddr_u *);
 extern	void	io_multicast_del(sockaddr_u *);
-extern	void	sendpkt 	(sockaddr_u *, struct interface *, int, struct pkt *, int);
-#ifdef DEBUG
+extern	void	sendpkt		(sockaddr_u *dest, endpt * ep, int ttl,
+				 struct pkt *pkt, int len);
+extern	isc_boolean_t	is_linklocal(sockaddr_u *psau);
+#ifdef DEBUG_TIMING
 extern	void	collect_timing  (struct recvbuf *, const char *, int, l_fp *);
 #endif
 #ifdef HAVE_SIGNALED_IO
@@ -141,8 +156,13 @@ extern	void	block_io_and_alarm	(void);
 # define	UNBLOCK_IO_AND_ALARM()	do {} while (0)
 # define	BLOCK_IO_AND_ALARM()	do {} while (0)
 #endif
-#define		latoa(pif)	localaddrtoa(pif)
+#define		eptoa(pif)	localaddrtoa(pif)
+#define		latoa(pif)	eptoa(pif)
 extern const char * localaddrtoa(endpt *);
+#ifdef DEBUG
+extern const char * iflags_str(u_int32 iflags);
+#endif
+
 
 /* ntp_loopfilter.c */
 extern	void	init_loopfilter(void);
@@ -198,7 +218,7 @@ extern	int	crypto_xmit	(struct peer *, struct pkt *,
 				    struct exten *, keyid_t);
 extern	keyid_t	session_key	(sockaddr_u *, sockaddr_u *, keyid_t,
 				    keyid_t, u_long);
-extern	int	make_keylist	(struct peer *, struct interface *);
+extern	int	make_keylist	(struct peer *, endpt *);
 extern	void	key_expire	(struct peer *);
 extern	void	crypto_update	(void);
 extern	void	crypto_update_taichange(void);
@@ -226,7 +246,7 @@ extern	void	clock_select	(void);
 extern	void	set_sys_leap	(u_char);
 
 extern	u_long	leapsec;	/* seconds to next leap (proximity class) */
-extern  int     leapdif;        /* TAI difference step at next leap second*/
+extern  int	leapdif;	/* TAI difference step at next leap second */
 extern	int	sys_orphan;
 extern	double	sys_mindisp;
 extern	double	sys_maxdist;
@@ -258,18 +278,27 @@ extern	void	reset_auth_stats(void);
 /* ntp_restrict.c */
 extern	void	init_restrict	(void);
 extern	void	restrictions	(sockaddr_u *, r4addr *);
-extern	void	hack_restrict	(restrict_op, sockaddr_u *, sockaddr_u *,
-				 short, u_short, u_short, u_long);
-extern	void	restrict_source	(sockaddr_u *, int, u_long);
+extern	int/*BOOL*/hack_restrict(restrict_op op, sockaddr_u *resaddr,
+				 sockaddr_u *resmask, short ippeerlimit,
+				 u_short mflags, u_short rflags,
+				 u_int32 expire);
+extern	void	restrict_source	(sockaddr_u *addr, int/*BOOL*/ remove,
+				 u_int32 lifetime);
+#ifdef DEBUG
 extern	void	dump_restricts	(void);
+extern	const char *resop_str	(restrict_op op);
+extern	const char *rflags_str	(u_short rflags);
+extern	const char *mflags_str	(u_short mflags);
+#endif
+
 
 /* ntp_timer.c */
 extern	void	init_timer	(void);
 extern	void	reinit_timer	(void);
 extern	void	timer		(void);
 extern	void	timer_clr_stats (void);
-extern	void	timer_interfacetimeout (u_long);
-extern	volatile int interface_interval;
+extern	int	endpt_scan_period;	/* -U option default 301s */
+extern	u_long	endpt_scan_timer;	/* next scan current_time */
 extern	u_long	orphwait;		/* orphan wait time */
 #ifdef AUTOKEY
 extern	char	*sys_hostname;	/* host name */
@@ -288,17 +317,29 @@ extern	void	record_proto_stats (char *);
 extern	void	record_loop_stats (double, double, double, double, int);
 extern	void	record_clock_stats (sockaddr_u *, const char *);
 extern	int	mprintf_clock_stats(sockaddr_u *, const char *, ...)
-			NTP_PRINTF(2, 3);
-extern	void	record_raw_stats (sockaddr_u *srcadr, sockaddr_u *dstadr, l_fp *t1, l_fp *t2, l_fp *t3, l_fp *t4, int leap, int version, int mode, int stratum, int ppoll, int precision, double root_delay, double root_dispersion, u_int32 refid, int len, u_char *extra);
+					NTP_PRINTF(2, 3);
+extern	void	record_raw_stats (sockaddr_u *srcadr, sockaddr_u *dstadr,
+				  l_fp *t1, l_fp *t2, l_fp *t3, l_fp *t4,
+				  int leap, int version, int mode,
+				  int stratum, int ppoll, int precision,
+				  double root_delay, double root_dispersion,
+				  u_int32 refid, int len, u_char *extra);
 extern	void	check_leap_file	(int is_daily_check, u_int32 ntptime, const time_t * systime);
 extern	void	record_crypto_stats (sockaddr_u *, const char *);
 #ifdef DEBUG
 extern	void	record_timing_stats (const char *);
+extern	void	append_flagstr(char *flagstr, size_t sz, const char *text);
 #endif
 extern	char *	fstostr(time_t);	/* NTP timescale seconds */
 
 /* ntpd.c */
 extern	void	parse_cmdline_opts(int *, char ***);
+
+/* ntservice.c */
+#ifndef SYS_WINNT
+# define	ntservice_isup()	do {} while (FALSE)
+#endif
+
 /*
  * Signals we catch for debugging.
  */
@@ -381,7 +422,10 @@ extern volatile u_long handler_pkts;	/* number of pkts received by handler */
 extern u_long	io_timereset;		/* time counters were reset */
 
 /* ntp_io.c */
-extern  int	disable_dynamic_updates;
+extern int	no_periodic_scan;	/* no periodic net addr scans */
+extern int	scan_addrs_once;	/* no net addr rescans */
+extern int	nonlocal_v4_addr_up;	/* should we try IPv4 pool? */
+extern int	nonlocal_v6_addr_up;	/* should we try IPv6 pool? */
 extern u_int	sys_ifnum;		/* next .ifnum to assign */
 extern endpt *	any_interface;		/* IPv4 wildcard */
 extern endpt *	any6_interface;		/* IPv6 wildcard */
diff --git a/contrib/ntp/include/vint64ops.h b/contrib/ntp/include/vint64ops.h
index 888d342781fb..50a8c4016264 100644
--- a/contrib/ntp/include/vint64ops.h
+++ b/contrib/ntp/include/vint64ops.h
@@ -23,6 +23,6 @@ extern vint64 subv64i32(const vint64 * lhs, int32_t rhs);
 extern vint64 subv64u32(const vint64 * lhs, uint32_t rhs);
 
 /* parsing. works like strtoul() or strtoull() */
-extern vint64 strtouv64(char const * begp, char const ** const endp, int base);
+extern vint64 strtouv64(char * begp, char ** endp, int base);
 
 #endif /*!defined(VINT64OPS_H)*/
diff --git a/contrib/ntp/kernel/Makefile.in b/contrib/ntp/kernel/Makefile.in
index f0cf22e84381..40374fd18544 100644
--- a/contrib/ntp/kernel/Makefile.in
+++ b/contrib/ntp/kernel/Makefile.in
@@ -383,6 +383,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_NET_SNMP_CONFIG = @PATH_NET_SNMP_CONFIG@
+PATH_OPENSSL = @PATH_OPENSSL@
 PATH_PERL = @PATH_PERL@
 PATH_RUBY = @PATH_RUBY@
 PATH_SEPARATOR = @PATH_SEPARATOR@
diff --git a/contrib/ntp/kernel/sys/Makefile.in b/contrib/ntp/kernel/sys/Makefile.in
index 447e32e2cc8e..a09b0a1f39d4 100644
--- a/contrib/ntp/kernel/sys/Makefile.in
+++ b/contrib/ntp/kernel/sys/Makefile.in
@@ -344,6 +344,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_NET_SNMP_CONFIG = @PATH_NET_SNMP_CONFIG@
+PATH_OPENSSL = @PATH_OPENSSL@
 PATH_PERL = @PATH_PERL@
 PATH_RUBY = @PATH_RUBY@
 PATH_SEPARATOR = @PATH_SEPARATOR@
diff --git a/contrib/ntp/libntp/Makefile.am b/contrib/ntp/libntp/Makefile.am
index 99ce273d4cd1..85ac6e3f9b92 100644
--- a/contrib/ntp/libntp/Makefile.am
+++ b/contrib/ntp/libntp/Makefile.am
@@ -192,7 +192,6 @@ libntp_a_SRCS =						\
 	ntp_rfc2553.c					\
 	ntp_worker.c					\
 	numtoa.c					\
-	numtohost.c					\
 	octtoint.c					\
 	prettydate.c					\
 	refidsmear.c					\
diff --git a/contrib/ntp/libntp/Makefile.in b/contrib/ntp/libntp/Makefile.in
index 75d6b2abf8bc..69805f7ddca2 100644
--- a/contrib/ntp/libntp/Makefile.in
+++ b/contrib/ntp/libntp/Makefile.in
@@ -175,12 +175,12 @@ am__libntp_a_SOURCES_DIST = systime.c a_md5encrypt.c adjtime.c \
 	mktime.c modetoa.c mstolfp.c msyslog.c netof.c ntp_calendar.c \
 	ntp_calgps.c ntp_crypto_rnd.c ntp_intres.c ntp_libopts.c \
 	ntp_lineedit.c ntp_random.c ntp_realpath.c ntp_rfc2553.c \
-	ntp_worker.c numtoa.c numtohost.c octtoint.c prettydate.c \
-	refidsmear.c recvbuff.c refnumtoa.c snprintf.c socket.c \
-	socktoa.c socktohost.c ssl_init.c statestr.c strdup.c \
-	strl_obsd.c syssignal.c timespecops.c timetoa.c timevalops.c \
-	timexsup.c uglydate.c vint64ops.c work_fork.c work_thread.c \
-	xsbprintf.c ymd2yd.c lib/isc/assertions.c lib/isc/buffer.c \
+	ntp_worker.c numtoa.c octtoint.c prettydate.c refidsmear.c \
+	recvbuff.c refnumtoa.c snprintf.c socket.c socktoa.c \
+	socktohost.c ssl_init.c statestr.c strdup.c strl_obsd.c \
+	syssignal.c timespecops.c timetoa.c timevalops.c timexsup.c \
+	uglydate.c vint64ops.c work_fork.c work_thread.c xsbprintf.c \
+	ymd2yd.c lib/isc/assertions.c lib/isc/buffer.c \
 	lib/isc/backtrace-emptytbl.c lib/isc/backtrace.c \
 	lib/isc/unix/dir.c lib/isc/error.c lib/isc/unix/errno2result.c \
 	lib/isc/event.c lib/isc/unix/file.c lib/isc/inet_ntop.c \
@@ -238,15 +238,15 @@ am__objects_5 = a_md5encrypt.$(OBJEXT) adjtime.$(OBJEXT) \
 	ntp_libopts.$(OBJEXT) ntp_lineedit.$(OBJEXT) \
 	ntp_random.$(OBJEXT) ntp_realpath.$(OBJEXT) \
 	ntp_rfc2553.$(OBJEXT) ntp_worker.$(OBJEXT) numtoa.$(OBJEXT) \
-	numtohost.$(OBJEXT) octtoint.$(OBJEXT) prettydate.$(OBJEXT) \
-	refidsmear.$(OBJEXT) recvbuff.$(OBJEXT) refnumtoa.$(OBJEXT) \
-	snprintf.$(OBJEXT) socket.$(OBJEXT) socktoa.$(OBJEXT) \
-	socktohost.$(OBJEXT) ssl_init.$(OBJEXT) statestr.$(OBJEXT) \
-	strdup.$(OBJEXT) strl_obsd.$(OBJEXT) syssignal.$(OBJEXT) \
-	timespecops.$(OBJEXT) timetoa.$(OBJEXT) timevalops.$(OBJEXT) \
-	timexsup.$(OBJEXT) uglydate.$(OBJEXT) vint64ops.$(OBJEXT) \
-	work_fork.$(OBJEXT) work_thread.$(OBJEXT) xsbprintf.$(OBJEXT) \
-	ymd2yd.$(OBJEXT) $(am__objects_4) $(am__objects_1)
+	octtoint.$(OBJEXT) prettydate.$(OBJEXT) refidsmear.$(OBJEXT) \
+	recvbuff.$(OBJEXT) refnumtoa.$(OBJEXT) snprintf.$(OBJEXT) \
+	socket.$(OBJEXT) socktoa.$(OBJEXT) socktohost.$(OBJEXT) \
+	ssl_init.$(OBJEXT) statestr.$(OBJEXT) strdup.$(OBJEXT) \
+	strl_obsd.$(OBJEXT) syssignal.$(OBJEXT) timespecops.$(OBJEXT) \
+	timetoa.$(OBJEXT) timevalops.$(OBJEXT) timexsup.$(OBJEXT) \
+	uglydate.$(OBJEXT) vint64ops.$(OBJEXT) work_fork.$(OBJEXT) \
+	work_thread.$(OBJEXT) xsbprintf.$(OBJEXT) ymd2yd.$(OBJEXT) \
+	$(am__objects_4) $(am__objects_1)
 am_libntp_a_OBJECTS = systime.$(OBJEXT) $(am__objects_5)
 libntp_a_OBJECTS = $(am_libntp_a_OBJECTS)
 libntpsim_a_AR = $(AR) $(ARFLAGS)
@@ -261,12 +261,12 @@ am__libntpsim_a_SOURCES_DIST = systime_s.c a_md5encrypt.c adjtime.c \
 	mktime.c modetoa.c mstolfp.c msyslog.c netof.c ntp_calendar.c \
 	ntp_calgps.c ntp_crypto_rnd.c ntp_intres.c ntp_libopts.c \
 	ntp_lineedit.c ntp_random.c ntp_realpath.c ntp_rfc2553.c \
-	ntp_worker.c numtoa.c numtohost.c octtoint.c prettydate.c \
-	refidsmear.c recvbuff.c refnumtoa.c snprintf.c socket.c \
-	socktoa.c socktohost.c ssl_init.c statestr.c strdup.c \
-	strl_obsd.c syssignal.c timespecops.c timetoa.c timevalops.c \
-	timexsup.c uglydate.c vint64ops.c work_fork.c work_thread.c \
-	xsbprintf.c ymd2yd.c lib/isc/assertions.c lib/isc/buffer.c \
+	ntp_worker.c numtoa.c octtoint.c prettydate.c refidsmear.c \
+	recvbuff.c refnumtoa.c snprintf.c socket.c socktoa.c \
+	socktohost.c ssl_init.c statestr.c strdup.c strl_obsd.c \
+	syssignal.c timespecops.c timetoa.c timevalops.c timexsup.c \
+	uglydate.c vint64ops.c work_fork.c work_thread.c xsbprintf.c \
+	ymd2yd.c lib/isc/assertions.c lib/isc/buffer.c \
 	lib/isc/backtrace-emptytbl.c lib/isc/backtrace.c \
 	lib/isc/unix/dir.c lib/isc/error.c lib/isc/unix/errno2result.c \
 	lib/isc/event.c lib/isc/unix/file.c lib/isc/inet_ntop.c \
@@ -321,21 +321,20 @@ am__depfiles_remade = ./$(DEPDIR)/a_md5encrypt.Po \
 	./$(DEPDIR)/ntp_libopts.Po ./$(DEPDIR)/ntp_lineedit.Po \
 	./$(DEPDIR)/ntp_random.Po ./$(DEPDIR)/ntp_realpath.Po \
 	./$(DEPDIR)/ntp_rfc2553.Po ./$(DEPDIR)/ntp_worker.Po \
-	./$(DEPDIR)/numtoa.Po ./$(DEPDIR)/numtohost.Po \
-	./$(DEPDIR)/octtoint.Po ./$(DEPDIR)/prettydate.Po \
-	./$(DEPDIR)/recvbuff.Po ./$(DEPDIR)/refidsmear.Po \
-	./$(DEPDIR)/refnumtoa.Po ./$(DEPDIR)/snprintf.Po \
-	./$(DEPDIR)/socket.Po ./$(DEPDIR)/socktoa.Po \
-	./$(DEPDIR)/socktohost.Po ./$(DEPDIR)/ssl_init.Po \
-	./$(DEPDIR)/statestr.Po ./$(DEPDIR)/strdup.Po \
-	./$(DEPDIR)/strl_obsd.Po ./$(DEPDIR)/syssignal.Po \
-	./$(DEPDIR)/systime.Po ./$(DEPDIR)/systime_s.Po \
-	./$(DEPDIR)/timespecops.Po ./$(DEPDIR)/timetoa.Po \
-	./$(DEPDIR)/timevalops.Po ./$(DEPDIR)/timexsup.Po \
-	./$(DEPDIR)/uglydate.Po ./$(DEPDIR)/vint64ops.Po \
-	./$(DEPDIR)/work_fork.Po ./$(DEPDIR)/work_thread.Po \
-	./$(DEPDIR)/xsbprintf.Po ./$(DEPDIR)/ymd2yd.Po \
-	lib/isc/$(DEPDIR)/assertions.Po \
+	./$(DEPDIR)/numtoa.Po ./$(DEPDIR)/octtoint.Po \
+	./$(DEPDIR)/prettydate.Po ./$(DEPDIR)/recvbuff.Po \
+	./$(DEPDIR)/refidsmear.Po ./$(DEPDIR)/refnumtoa.Po \
+	./$(DEPDIR)/snprintf.Po ./$(DEPDIR)/socket.Po \
+	./$(DEPDIR)/socktoa.Po ./$(DEPDIR)/socktohost.Po \
+	./$(DEPDIR)/ssl_init.Po ./$(DEPDIR)/statestr.Po \
+	./$(DEPDIR)/strdup.Po ./$(DEPDIR)/strl_obsd.Po \
+	./$(DEPDIR)/syssignal.Po ./$(DEPDIR)/systime.Po \
+	./$(DEPDIR)/systime_s.Po ./$(DEPDIR)/timespecops.Po \
+	./$(DEPDIR)/timetoa.Po ./$(DEPDIR)/timevalops.Po \
+	./$(DEPDIR)/timexsup.Po ./$(DEPDIR)/uglydate.Po \
+	./$(DEPDIR)/vint64ops.Po ./$(DEPDIR)/work_fork.Po \
+	./$(DEPDIR)/work_thread.Po ./$(DEPDIR)/xsbprintf.Po \
+	./$(DEPDIR)/ymd2yd.Po lib/isc/$(DEPDIR)/assertions.Po \
 	lib/isc/$(DEPDIR)/backtrace-emptytbl.Po \
 	lib/isc/$(DEPDIR)/backtrace.Po lib/isc/$(DEPDIR)/buffer.Po \
 	lib/isc/$(DEPDIR)/error.Po lib/isc/$(DEPDIR)/event.Po \
@@ -581,6 +580,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_NET_SNMP_CONFIG = @PATH_NET_SNMP_CONFIG@
+PATH_OPENSSL = @PATH_OPENSSL@
 PATH_PERL = @PATH_PERL@
 PATH_RUBY = @PATH_RUBY@
 PATH_SEPARATOR = @PATH_SEPARATOR@
@@ -822,7 +822,6 @@ libntp_a_SRCS = \
 	ntp_rfc2553.c					\
 	ntp_worker.c					\
 	numtoa.c					\
-	numtohost.c					\
 	octtoint.c					\
 	prettydate.c					\
 	refidsmear.c					\
@@ -1093,7 +1092,6 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_rfc2553.Po@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_worker.Po@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/numtoa.Po@am__quote@ # am--include-marker
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/numtohost.Po@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/octtoint.Po@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/prettydate.Po@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/recvbuff.Po@am__quote@ # am--include-marker
@@ -1380,7 +1378,6 @@ distclean: distclean-am
 	-rm -f ./$(DEPDIR)/ntp_rfc2553.Po
 	-rm -f ./$(DEPDIR)/ntp_worker.Po
 	-rm -f ./$(DEPDIR)/numtoa.Po
-	-rm -f ./$(DEPDIR)/numtohost.Po
 	-rm -f ./$(DEPDIR)/octtoint.Po
 	-rm -f ./$(DEPDIR)/prettydate.Po
 	-rm -f ./$(DEPDIR)/recvbuff.Po
@@ -1535,7 +1532,6 @@ maintainer-clean: maintainer-clean-am
 	-rm -f ./$(DEPDIR)/ntp_rfc2553.Po
 	-rm -f ./$(DEPDIR)/ntp_worker.Po
 	-rm -f ./$(DEPDIR)/numtoa.Po
-	-rm -f ./$(DEPDIR)/numtohost.Po
 	-rm -f ./$(DEPDIR)/octtoint.Po
 	-rm -f ./$(DEPDIR)/prettydate.Po
 	-rm -f ./$(DEPDIR)/recvbuff.Po
diff --git a/contrib/ntp/libntp/a_md5encrypt.c b/contrib/ntp/libntp/a_md5encrypt.c
index 7a372969123f..a571405a5d87 100644
--- a/contrib/ntp/libntp/a_md5encrypt.c
+++ b/contrib/ntp/libntp/a_md5encrypt.c
@@ -21,7 +21,6 @@ typedef struct {
 	size_t		len;
 } rwbuffT;
 
-
 #if defined(OPENSSL) && defined(ENABLE_CMAC)
 static size_t
 cmac_ctx_size(
@@ -40,6 +39,37 @@ cmac_ctx_size(
 #endif	/* OPENSSL && ENABLE_CMAC */
 
 
+/*
+ * Allocate and initialize a digest context.  As a speed optimization,
+ * take an idea from ntpsec and cache the context to avoid malloc/free
+ * overhead in time-critical paths.  ntpsec also caches the algorithms
+ * with each key.
+ * This is not thread-safe, but that is
+ * not a problem at present.
+ */
+static EVP_MD_CTX *
+get_md_ctx(
+	int		nid
+	)
+{
+#ifndef OPENSSL
+	static MD5_CTX	md5_ctx;
+
+	DEBUG_INSIST(NID_md5 == nid);
+	MD5Init(&md5_ctx);
+
+	return &md5_ctx;
+#else
+	if (!EVP_DigestInit(digest_ctx, EVP_get_digestbynid(nid))) {
+		msyslog(LOG_ERR, "%s init failed", OBJ_nid2sn(nid));
+		return NULL;
+	}
+
+	return digest_ctx;
+#endif	/* OPENSSL */
+}
+
+
 static size_t
 make_mac(
 	const rwbuffT *	digest,
@@ -99,26 +129,13 @@ make_mac(
 			CMAC_CTX_free(ctx);
 	}
 	else
-#   endif /*ENABLE_CMAC*/
+#   endif /* ENABLE_CMAC */
 	{	/* generic MAC handling */
-		EVP_MD_CTX *	ctx   = EVP_MD_CTX_new();
+		EVP_MD_CTX *	ctx;
 		u_int		uilen = 0;
 
-		if ( ! ctx) {
-			msyslog(LOG_ERR, "MAC encrypt: MAC %s Digest CTX new failed.",
-				OBJ_nid2sn(ktype));
-			goto mac_fail;
-		}
-
-	   #ifdef EVP_MD_CTX_FLAG_NON_FIPS_ALLOW
-		/* make sure MD5 is allowd */
-		EVP_MD_CTX_set_flags(ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
-	   #endif
-		/* [Bug 3457] DON'T use plain EVP_DigestInit! It would
-		 * kill the flags! */
-		if (!EVP_DigestInit_ex(ctx, EVP_get_digestbynid(ktype), NULL)) {
-			msyslog(LOG_ERR, "MAC encrypt: MAC %s Digest Init failed.",
-				OBJ_nid2sn(ktype));
+		ctx = get_md_ctx(ktype);
+		if (NULL == ctx) {
 			goto mac_fail;
 		}
 		if ((size_t)EVP_MD_CTX_size(ctx) > digest->len) {
@@ -143,39 +160,25 @@ make_mac(
 		}
 	  mac_fail:
 		retlen = (size_t)uilen;
-
-		if (ctx)
-			EVP_MD_CTX_free(ctx);
 	}
 
 #else /* !OPENSSL follows */
 
-	if (ktype == NID_md5)
-	{
-		EVP_MD_CTX *	ctx   = EVP_MD_CTX_new();
-		u_int		uilen = 0;
+	if (NID_md5 == ktype) {
+		EVP_MD_CTX *	ctx;
 
-		if (digest->len < 16) {
+		ctx = get_md_ctx(ktype);
+		if (digest->len < MD5_LENGTH) {
 			msyslog(LOG_ERR, "%s", "MAC encrypt: MAC md5 buf too small.");
+		} else {
+			MD5Init(ctx);
+			MD5Update(ctx, (const void *)key->buf, key->len);
+			MD5Update(ctx, (const void *)msg->buf, msg->len);
+			MD5Final(digest->buf, ctx);
+			retlen = MD5_LENGTH;
 		}
-		else if ( ! ctx) {
-			msyslog(LOG_ERR, "%s", "MAC encrypt: MAC md5 Digest CTX new failed.");
-		}
-		else if (!EVP_DigestInit(ctx, EVP_get_digestbynid(ktype))) {
-			msyslog(LOG_ERR, "%s", "MAC encrypt: MAC md5 Digest INIT failed.");
-		}
-		else {
-			EVP_DigestUpdate(ctx, key->buf, key->len);
-			EVP_DigestUpdate(ctx, msg->buf, msg->len);
-			EVP_DigestFinal(ctx, digest->buf, &uilen);
-		}
-		if (ctx)
-			EVP_MD_CTX_free(ctx);
-		retlen = (size_t)uilen;
-	}
-	else
-	{
-		msyslog(LOG_ERR, "MAC encrypt: invalid key type %d"  , ktype);
+	} else {
+		msyslog(LOG_ERR, "MAC encrypt: invalid key type %d", ktype);
 	}
 
 #endif /* !OPENSSL */
@@ -187,7 +190,7 @@ make_mac(
 /*
  * MD5authencrypt - generate message digest
  *
- * Returns length of MAC including key ID and digest.
+ * Returns 0 on failure or length of MAC including key ID.
  */
 size_t
 MD5authencrypt(
@@ -202,13 +205,14 @@ MD5authencrypt(
 	rwbuffT digb = { digest, sizeof(digest) };
 	robuffT keyb = { key, klen };
 	robuffT msgb = { pkt, length };
-	size_t	dlen = 0;
+	size_t	dlen;
 
 	dlen = make_mac(&digb, type, &keyb, &msgb);
-	/* If the MAC is longer than the MAX then truncate it. */
-	if (dlen > MAX_MDG_LEN)
-		dlen = MAX_MDG_LEN;
-	memcpy((u_char *)pkt + length + KEY_MAC_LEN, digest, dlen);
+	if (0 == dlen) {
+		return 0;
+	}
+	memcpy((u_char *)pkt + length + KEY_MAC_LEN, digest,
+	       min(dlen, MAX_MDG_LEN));
 	return (dlen + KEY_MAC_LEN);
 }
 
@@ -236,15 +240,11 @@ MD5authdecrypt(
 	size_t	dlen = 0;
 
 	dlen = make_mac(&digb, type, &keyb, &msgb);
-
-	/* If the MAC is longer than the MAX then truncate it. */
-	if (dlen > MAX_MDG_LEN)
-		dlen = MAX_MDG_LEN;
-	if (size != (size_t)dlen + KEY_MAC_LEN) {
+	if (0 == dlen || size != dlen + KEY_MAC_LEN) {
 		msyslog(LOG_ERR,
-			"MAC decrypt: MAC length error: len=%u key=%d",
-			(u_int)size, keyno);
-		return (0);
+			"MAC decrypt: MAC length error: %u not %u for key %u",
+			(u_int)size, (u_int)(dlen + KEY_MAC_LEN), keyno);
+		return FALSE;
 	}
 	return !isc_tsmemcmp(digest,
 		 (u_char *)pkt + length + KEY_MAC_LEN, dlen);
@@ -254,39 +254,36 @@ MD5authdecrypt(
  * Calculate the reference id from the address. If it is an IPv4
  * address, use it as is. If it is an IPv6 address, do a md5 on
  * it and use the bottom 4 bytes.
- * The result is in network byte order.
+ * The result is in network byte order for IPv4 addreseses.  For
+ * IPv6, ntpd long differed in the hash calculated on big-endian
+ * vs. little-endian because the first four bytes of the MD5 hash
+ * were used as a u_int32 without any byte swapping.  This broke
+ * the refid-based loop detection between mixed-endian systems.
+ * In order to preserve behavior on the more-common little-endian
+ * systems, the hash is now byte-swapped on big-endian systems to
+ * match the little-endian hash.  This is ugly but it seems better
+ * than changing the IPv6 refid calculation on the more-common
+ * systems.
+ * This is not thread safe, not a problem so far.
  */
 u_int32
 addr2refid(sockaddr_u *addr)
 {
-	u_char		digest[EVP_MAX_MD_SIZE];
-	u_int32		addr_refid;
-	EVP_MD_CTX	*ctx;
-	u_int		len;
+	static MD5_CTX	md5_ctx;
+	union u_tag {
+		u_char		digest[MD5_DIGEST_LENGTH];
+		u_int32		addr_refid;
+	} u;
 
-	if (IS_IPV4(addr))
+	if (IS_IPV4(addr)) {
 		return (NSRCADR(addr));
-
-	INIT_SSL();
-
-	ctx = EVP_MD_CTX_new();
-#   ifdef EVP_MD_CTX_FLAG_NON_FIPS_ALLOW
-	/* MD5 is not used as a crypto hash here. */
-	EVP_MD_CTX_set_flags(ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
-#   endif
-	/* [Bug 3457] DON'T use plain EVP_DigestInit! It would kill the
-	 * flags! */
-	if (!EVP_DigestInit_ex(ctx, EVP_md5(), NULL)) {
-		msyslog(LOG_ERR,
-		    "MD5 init failed");
-		EVP_MD_CTX_free(ctx);	/* pedantic... but safe */
-		exit(1);
 	}
-
-	EVP_DigestUpdate(ctx, (u_char *)PSOCK_ADDR6(addr),
-	    sizeof(struct in6_addr));
-	EVP_DigestFinal(ctx, digest, &len);
-	EVP_MD_CTX_free(ctx);
-	memcpy(&addr_refid, digest, sizeof(addr_refid));
-	return (addr_refid);
+	/* MD5 is not used for authentication here. */
+	MD5Init(&md5_ctx);
+	MD5Update(&md5_ctx, (void *)&SOCK_ADDR6(addr), sizeof(SOCK_ADDR6(addr)));
+	MD5Final(u.digest, &md5_ctx);
+#ifdef WORDS_BIGENDIAN
+	u.addr_refid = BYTESWAP32(u.addr_refid);
+#endif
+	return u.addr_refid;
 }
diff --git a/contrib/ntp/libntp/adjtime.c b/contrib/ntp/libntp/adjtime.c
index b536cc555d9a..57accd68642d 100644
--- a/contrib/ntp/libntp/adjtime.c
+++ b/contrib/ntp/libntp/adjtime.c
@@ -381,6 +381,6 @@ adjtime (struct timeval *delta, struct timeval *olddelta)
     return 0;
 }
 # else /* no special adjtime() needed */
-int adjtime_bs;
+NONEMPTY_TRANSLATION_UNIT
 # endif
 #endif
diff --git a/contrib/ntp/libntp/audio.c b/contrib/ntp/libntp/audio.c
index f404cc078bdc..2cbae7a30a11 100644
--- a/contrib/ntp/libntp/audio.c
+++ b/contrib/ntp/libntp/audio.c
@@ -517,5 +517,5 @@ audio_show(void)
 #endif /* not PCM_STYLE_SOUND */
 }
 #else
-int audio_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* HAVE_{SYS_AUDIOIO,SUN_AUDIOIO,MACHINE_SOUNDCARD,SYS_SOUNDCARD}_H */
diff --git a/contrib/ntp/libntp/authkeys.c b/contrib/ntp/libntp/authkeys.c
index d28b4b932b84..29671ac922bb 100644
--- a/contrib/ntp/libntp/authkeys.c
+++ b/contrib/ntp/libntp/authkeys.c
@@ -611,6 +611,9 @@ authhavekey(
 
 	/*
 	 * The key is found and trusted. Initialize the key cache.
+	 * The cache really should be a struct savekey to streamline
+	 * this code.  Using a sk pointer would be even faster but more
+	 * fragile around pointing to freed memory.
 	 */
 	cache_keyid = sk->keyid;
 	cache_type = sk->type;
@@ -927,6 +930,7 @@ authdecrypt(
 			      pkt, length, size, keyno);
 }
 
+
 /* password decoding helpers */
 static size_t
 pwdecode_plain(
diff --git a/contrib/ntp/libntp/authreadkeys.c b/contrib/ntp/libntp/authreadkeys.c
index fa2f5b540de4..e4aee723d33a 100644
--- a/contrib/ntp/libntp/authreadkeys.c
+++ b/contrib/ntp/libntp/authreadkeys.c
@@ -218,14 +218,14 @@ authreadkeys(
 		keytype = keytype_from_text(token, NULL);
 		if (keytype == 0) {
 			log_maybe(NULL,
-				  "authreadkeys: invalid type for key %d",
-				  keyno);
+				  "authreadkeys: unsupported type %s for key %d",
+				  token, keyno);
 #  ifdef ENABLE_CMAC
 		} else if (NID_cmac != keytype &&
 				EVP_get_digestbynid(keytype) == NULL) {
 			log_maybe(NULL,
-				  "authreadkeys: no algorithm for key %d",
-				  keyno);
+				  "authreadkeys: no algorithm for %s key %d",
+				  token, keyno);
 			keytype = 0;
 #  endif /* ENABLE_CMAC */
 		}
@@ -270,11 +270,13 @@ authreadkeys(
 					  "authreadkeys: passwd has bad char for key %d",
 					  keyno);
 				break;
+#ifdef DEBUG
 			default:
 				log_maybe(&nerr,
-					  "authreadkeys: unknown errno %d for key %d",
+					  "authreadkeys: unexpected errno %d for key %d: %m",
 					  errno, keyno);
 				break;
+#endif
 			}
 			continue;
 		}
diff --git a/contrib/ntp/libntp/bsd_strerror.c b/contrib/ntp/libntp/bsd_strerror.c
index 5ace9aa48542..23888a2d1437 100644
--- a/contrib/ntp/libntp/bsd_strerror.c
+++ b/contrib/ntp/libntp/bsd_strerror.c
@@ -45,5 +45,5 @@ strerror(
 	return ebuf;
 }
 #else
-int strerror_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif
diff --git a/contrib/ntp/libntp/clocktypes.c b/contrib/ntp/libntp/clocktypes.c
index de7f6b4f3854..1b44546ee172 100644
--- a/contrib/ntp/libntp/clocktypes.c
+++ b/contrib/ntp/libntp/clocktypes.c
@@ -6,7 +6,6 @@
 
 #include "ntp_fp.h"
 #include "ntp.h"
-#include "lib_strbuf.h"
 #include "ntp_refclock.h"
 #include "ntp_stdlib.h"
 
diff --git a/contrib/ntp/libntp/dofptoa.c b/contrib/ntp/libntp/dofptoa.c
index c21d1455e7f0..a3f7c9e710dd 100644
--- a/contrib/ntp/libntp/dofptoa.c
+++ b/contrib/ntp/libntp/dofptoa.c
@@ -5,8 +5,6 @@
 #include <stdio.h>
 
 #include "ntp_fp.h"
-#include "lib_strbuf.h"
-#include "ntp_string.h"
 #include "ntp_stdlib.h"
 
 char *
diff --git a/contrib/ntp/libntp/dolfptoa.c b/contrib/ntp/libntp/dolfptoa.c
index 00e1faf793bc..2fa3cc5502d6 100644
--- a/contrib/ntp/libntp/dolfptoa.c
+++ b/contrib/ntp/libntp/dolfptoa.c
@@ -5,8 +5,6 @@
 #include <stdio.h>
 
 #include "ntp_fp.h"
-#include "lib_strbuf.h"
-#include "ntp_string.h"
 #include "ntp_stdlib.h"
 
 char *
diff --git a/contrib/ntp/libntp/humandate.c b/contrib/ntp/libntp/humandate.c
index d9d5e89df017..94b3e6023e17 100644
--- a/contrib/ntp/libntp/humandate.c
+++ b/contrib/ntp/libntp/humandate.c
@@ -6,7 +6,6 @@
 
 #include "ntp_fp.h"
 #include "ntp_unixtime.h"	/* includes <sys/time.h> and <time.h> */
-#include "lib_strbuf.h"
 #include "ntp_stdlib.h"
 
 
diff --git a/contrib/ntp/libntp/lib/isc/win32/strerror.c b/contrib/ntp/libntp/lib/isc/win32/strerror.c
index 40c5da002f8c..21bdad97778e 100644
--- a/contrib/ntp/libntp/lib/isc/win32/strerror.c
+++ b/contrib/ntp/libntp/lib/isc/win32/strerror.c
@@ -29,6 +29,8 @@
 #include <isc/strerror.h>
 #include <isc/util.h>
 
+#include "lib_strbuf.h"
+
 /*
  * Forward declarations
  */
@@ -88,19 +90,47 @@ isc__strerror(int num, char *buf, size_t size) {
  */
 char *
 FormatError(int error) {
-	LPVOID lpMsgBuf = NULL;
+	char *lpMsgBuf = NULL;
+	char *pch;
+	const char boiler[] =
+		" For information about network troubleshooting, see Windows Help.";
+	size_t last;
+
 	FormatMessage( 
 		FORMAT_MESSAGE_ALLOCATE_BUFFER | 
 		FORMAT_MESSAGE_FROM_SYSTEM | 
-		FORMAT_MESSAGE_IGNORE_INSERTS,
+		(FORMAT_MESSAGE_MAX_WIDTH_MASK - 1),
 		NULL,
 		error,
 		/* Default language */
 		MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
-		(LPTSTR) &lpMsgBuf,
+		(LPTSTR)(PVOID)&lpMsgBuf,
 		0,
 		NULL); 
 
+	/* remove useless boilerplate */
+	pch = strstr(lpMsgBuf, boiler);
+	if (pch != NULL) {
+		*pch = '\0';
+	}
+
+	/* strip any trailing CR/LF and spaces */
+	if (lpMsgBuf != NULL) {
+		last = strlen(lpMsgBuf);
+		if (last > 0) {
+			--last;
+		}
+		while ('\n' == lpMsgBuf[last] ||
+		       '\r' == lpMsgBuf[last] ||
+		       ' '  == lpMsgBuf[last]) {
+
+			lpMsgBuf[last] = '\0';
+			if (last > 0) {
+				--last;
+			}
+		}
+	}
+
 	return (lpMsgBuf);
 }
 
@@ -113,27 +143,31 @@ char *
 NTstrerror(int err, BOOL *bfreebuf) {
 	char *retmsg = NULL;
 
-	/* Copy the error value first in case of other errors */	
-	DWORD errval = err; 
-
 	*bfreebuf = FALSE;
 
 	/* Get the Winsock2 error messages */
-	if (errval >= WSABASEERR && errval <= (WSABASEERR + 1999)) {
-		retmsg = GetWSAErrorMessage(errval);
-		if (retmsg != NULL)
-			return (retmsg);
+	/* DLH this may not be needed, FormatError/FormatMessage may handle Winsock error codes */
+	if (err >= WSABASEERR && err <= (WSABASEERR + 1999)) {
+		retmsg = GetWSAErrorMessage(err);
 	}
 	/*
 	 * If it's not one of the standard Unix error codes,
 	 * try a system error message
 	 */
-	if (errval > (DWORD) _sys_nerr) {
-		*bfreebuf = TRUE;
-		return (FormatError(errval));
-	} else {
-		return (strerror(errval));
+	if (NULL == retmsg) {
+		if (err > _sys_nerr) {
+			*bfreebuf = TRUE;
+			retmsg = FormatError(err);
+		} else {
+			retmsg = lib_getbuf();
+			if (0 != strerror_s(retmsg, LIB_BUFLENGTH, err)) {
+				snprintf(retmsg, LIB_BUFLENGTH,
+					 "Unknown error number %d/0x%x",
+					 err, err);
+			}
+		}
 	}
+	return retmsg;
 }
 
 /*
diff --git a/contrib/ntp/libntp/lib_strbuf.c b/contrib/ntp/libntp/lib_strbuf.c
index 76f70163de98..225c430f7e02 100644
--- a/contrib/ntp/libntp/lib_strbuf.c
+++ b/contrib/ntp/libntp/lib_strbuf.c
@@ -1,10 +1,11 @@
 /*
- * lib_strbuf - library string storage
+ * lib_strbuf.c - init_lib() and library string storage
  */
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
 
+#include <isc/mutex.h>
 #include <isc/net.h>
 #include <isc/result.h>
 
@@ -12,17 +13,18 @@
 #include "ntp_stdlib.h"
 #include "lib_strbuf.h"
 
+#define LIB_NUMBUF	10
 
 /*
  * Storage declarations
  */
-int		debug;
-libbufstr	lib_stringbuf[LIB_NUMBUF];
-int		lib_nextbuf;
-int		ipv4_works;
-int		ipv6_works;
-int		lib_inited;
-
+static char		lib_stringbuf_storage[LIB_NUMBUF][LIB_BUFLENGTH];
+static char *		lib_stringbuf[LIB_NUMBUF];
+int			lib_inited;
+static isc_mutex_t	lib_mutex;
+int			ipv4_works;
+int			ipv6_works;
+int			debug;
 
 /*
  * initialization routine.  Might be needed if the code is ROMized.
@@ -30,10 +32,41 @@ int		lib_inited;
 void
 init_lib(void)
 {
-	if (lib_inited)
+	u_int	u;
+
+	if (lib_inited) {
 		return;
+	}
 	ipv4_works = (ISC_R_SUCCESS == isc_net_probeipv4());
 	ipv6_works = (ISC_R_SUCCESS == isc_net_probeipv6());
 	init_systime();
+	/*
+	 * Avoid -Wrestrict warnings by keeping a pointer to each buffer
+	 * so the compiler can see copying from one buffer to another is
+	 * not violating restrict qualifiers on, e.g. memcpy() args.
+	 */
+	for (u = 0; u < COUNTOF(lib_stringbuf); u++) {
+		lib_stringbuf[u] = lib_stringbuf_storage[u];
+	}
+	isc_mutex_init(&lib_mutex);
 	lib_inited = TRUE;
 }
+
+
+char *
+lib_getbuf(void)
+{
+	static int	lib_nextbuf;
+	int		mybuf;
+
+	if (!lib_inited) {
+		init_lib();
+	}
+	isc_mutex_lock(&lib_mutex);
+	mybuf = lib_nextbuf;
+	lib_nextbuf = (1 + mybuf) % COUNTOF(lib_stringbuf);
+	isc_mutex_unlock(&lib_mutex);
+	zero_mem(lib_stringbuf[mybuf], LIB_BUFLENGTH);
+
+	return lib_stringbuf[mybuf];
+}
\ No newline at end of file
diff --git a/contrib/ntp/libntp/machines.c b/contrib/ntp/libntp/machines.c
index 7a29ac07ea5f..163abf15c6db 100644
--- a/contrib/ntp/libntp/machines.c
+++ b/contrib/ntp/libntp/machines.c
@@ -13,17 +13,16 @@
 #include "ntp_syslog.h"
 #include "ntp_stdlib.h"
 #include "ntp_unixtime.h"
-#include "lib_strbuf.h"
 #include "ntp_debug.h"
+#include "ntp_tty.h"
 
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
 
 #ifdef SYS_WINNT
-int _getch(void);	/* Declare the one function rather than include conio.h */
+#include <conio.h>
 #else
-
 #ifdef SYS_VXWORKS
 #include "taskLib.h"
 #include "sysLib.h"
@@ -531,3 +530,58 @@ getpass(const char * prompt)
 	return password;
 }
 #endif /* SYS_WINNT */
+
+
+static const int baudTable[][2] = {
+	{B0, 0},
+	{B50, 50},
+	{B75, 75},
+	{B110, 110},
+	{B134, 134},
+	{B150, 150},
+	{B200, 200},
+	{B300, 300},
+	{B600, 600},
+	{B1200, 1200},
+	{B1800, 1800},
+	{B2400, 2400},
+	{B4800, 4800},
+	{B9600, 9600},
+	{B19200, 19200},
+	{B38400, 38400},
+#   ifdef B57600
+	{B57600, 57600 },
+#   endif
+#   ifdef B115200
+	{B115200, 115200},
+#   endif
+	{-1, -1}
+};
+
+
+int  symBaud2numBaud(int symBaud)
+{
+	int i;
+
+	for (i = 0; baudTable[i][1] >= 0; ++i) {
+		if (baudTable[i][0] == symBaud) {
+			break;
+		}
+	}
+	return baudTable[i][1];
+}
+
+
+#if 0	/* unused */
+int  numBaud2symBaud(int numBaud)
+{
+	int i;
+
+	for (i = 0; baudTable[i][1] >= 0; ++i) {
+		if (baudTable[i][1] == numBaud) {
+			break;
+		}
+	}
+	return baudTable[i][0];
+}
+#endif	/* unused fn */
diff --git a/contrib/ntp/libntp/modetoa.c b/contrib/ntp/libntp/modetoa.c
index 6f13d20580bf..de14c9edd34c 100644
--- a/contrib/ntp/libntp/modetoa.c
+++ b/contrib/ntp/libntp/modetoa.c
@@ -4,7 +4,6 @@
 #include <config.h>
 #include <stdio.h>
 
-#include "lib_strbuf.h"
 #include "ntp_stdlib.h"
 
 const char *
diff --git a/contrib/ntp/libntp/msyslog.c b/contrib/ntp/libntp/msyslog.c
index a1ba72792595..b72d5c8dc379 100644
--- a/contrib/ntp/libntp/msyslog.c
+++ b/contrib/ntp/libntp/msyslog.c
@@ -348,15 +348,14 @@ msyslog(
 	...
 	)
 {
-	char	buf[1024];
 	va_list	ap;
 
 	va_start(ap, fmt);
-	mvsnprintf(buf, sizeof(buf), fmt, ap);
+	mvsyslog(level, fmt, ap);
 	va_end(ap);
-	addto_syslog(level, buf);
 }
 
+
 void
 mvsyslog(
 	int		level,
@@ -365,6 +364,7 @@ mvsyslog(
 	)
 {
 	char	buf[1024];
+
 	mvsnprintf(buf, sizeof(buf), fmt, ap);
 	addto_syslog(level, buf);
 }
diff --git a/contrib/ntp/libntp/netof.c b/contrib/ntp/libntp/netof.c
index c8831c3dd9cd..5f1e3662de78 100644
--- a/contrib/ntp/libntp/netof.c
+++ b/contrib/ntp/libntp/netof.c
@@ -1,5 +1,5 @@
 /* 
- * netof - return the net address part of an ip address in a sockaddr_storage structure
+ * netof - return the net address part of an ip address in a sockaddr_u structure
  *         (zero out host part)
  */
 #include <config.h>
@@ -11,12 +11,19 @@
 #include "ntp_stdlib.h"
 #include "ntp.h"
 
+/* 
+ * Return the network portion of a host address.  Used by ntp_io.c
+ * findbcastinter() to find a multicast/broadcast interface for
+ * a given remote address.  Note static storage is used, with room
+ * for only two addresses, which is all that is needed at present.
+ * 
+ */
 sockaddr_u *
 netof(
 	sockaddr_u *hostaddr
 	)
 {
-	static sockaddr_u	netofbuf[8];
+	static sockaddr_u	netofbuf[2];
 	static int		next_netofbuf;
 	u_int32			netnum;
 	sockaddr_u *		netaddr;
@@ -27,20 +34,11 @@ netof(
 	memcpy(netaddr, hostaddr, sizeof(*netaddr));
 
 	if (IS_IPV4(netaddr)) {
-		netnum = SRCADR(netaddr);
-
 		/*
-		 * We live in a modern CIDR world where the basement nets, which
-		 * used to be class A, are now probably associated with each
-		 * host address. So, for class-A nets, all bits are significant.
+		 * We live in a modern classless IPv4 world.  Assume /24.
 		 */
-		if (IN_CLASSC(netnum))
-			netnum &= IN_CLASSC_NET;
-		else if (IN_CLASSB(netnum))
-			netnum &= IN_CLASSB_NET;
-
+		netnum = SRCADR(netaddr) & IN_CLASSC_NET;
 		SET_ADDR4(netaddr, netnum);
-
 	} else if (IS_IPV6(netaddr))
 		/* assume the typical /64 subnet size */
 		zero_mem(&NSRCADR6(netaddr)[8], 8);
diff --git a/contrib/ntp/libntp/ntp_calendar.c b/contrib/ntp/libntp/ntp_calendar.c
index 9fc0b48229f2..b850a9db59b8 100644
--- a/contrib/ntp/libntp/ntp_calendar.c
+++ b/contrib/ntp/libntp/ntp_calendar.c
@@ -56,7 +56,6 @@
 #include "ntp_unixtime.h"
 
 #include "ntpd.h"
-#include "lib_strbuf.h"
 
 /* For now, let's take the conservative approach: if the target property
  * macros are not defined, check a few well-known compiler/architecture
diff --git a/contrib/ntp/libntp/ntp_intres.c b/contrib/ntp/libntp/ntp_intres.c
index 9fc3815ef007..29546147db8a 100644
--- a/contrib/ntp/libntp/ntp_intres.c
+++ b/contrib/ntp/libntp/ntp_intres.c
@@ -84,12 +84,6 @@
 #  include <netdb.h>
 # endif
 # include <resolv.h>
-# ifdef HAVE_INT32_ONLY_WITH_DNS
-#  define HAVE_INT32
-# endif
-# ifdef HAVE_U_INT32_ONLY_WITH_DNS
-#  define HAVE_U_INT32
-# endif
 #endif
 
 #include "ntp.h"
diff --git a/contrib/ntp/libntp/ntp_realpath.c b/contrib/ntp/libntp/ntp_realpath.c
index 116542945153..90e5a0d59e75 100644
--- a/contrib/ntp/libntp/ntp_realpath.c
+++ b/contrib/ntp/libntp/ntp_realpath.c
@@ -103,7 +103,7 @@ realpath1(const char *path, char *resolved)
 	size_t left_len, resolved_len, next_token_len;
 	unsigned symlinks;
 	ssize_t slen;
-	char left[NTP_PATH_MAX], next_token[NTP_PATH_MAX], symlink[NTP_PATH_MAX];
+	char left[NTP_PATH_MAX], next_token[NTP_PATH_MAX], link_tgt[NTP_PATH_MAX];
 
 	symlinks = 0;
 	if (path[0] == '/') {
@@ -157,7 +157,7 @@ realpath1(const char *path, char *resolved)
 			resolved[resolved_len++] = '/';
 			resolved[resolved_len] = '\0';
 		}
-		if (next_token[0] == '\0') {
+		if ('\0' == next_token[0]) {
 			/* Handle consequential slashes. */
 			continue;
 		} else if (strcmp(next_token, ".") == 0) {
@@ -187,23 +187,24 @@ realpath1(const char *path, char *resolved)
 		if (lstat(resolved, &sb) != 0)
 			return (NULL);
 		if (S_ISLNK(sb.st_mode)) {
-			if (symlinks++ > NTP_MAXSYMLINKS) {
+			if (++symlinks > NTP_MAXSYMLINKS) {
 				errno = ELOOP;
 				return (NULL);
 			}
-			slen = readlink(resolved, symlink, sizeof(symlink));
-			if (slen <= 0 || slen >= (ssize_t)sizeof(symlink)) {
-				if (slen < 0)
-					; /* keep errno from readlink(2) call */
-				else if (slen == 0)
+			slen = readlink(resolved, link_tgt, sizeof(link_tgt));
+			if (slen <= 0 || slen >= (ssize_t)sizeof(link_tgt)) {
+				if (slen < 0) {
+					/* keep errno from readlink(2) call */
+				} else if (slen == 0) {
 					errno = ENOENT;
-				else
+				} else {
 					errno = ENAMETOOLONG;
+				}
 				return (NULL);
 			}
-			symlink[slen] = '\0';
-			if (symlink[0] == '/') {
-				resolved[1] = 0;
+			link_tgt[slen] = '\0';
+			if (link_tgt[0] == '/') {
+				resolved[1] = '\0';
 				resolved_len = 1;
 			} else {
 				/* Strip the last path component. */
@@ -214,26 +215,26 @@ realpath1(const char *path, char *resolved)
 
 			/*
 			 * If there are any path components left, then
-			 * append them to symlink. The result is placed
+			 * append them to link_tgt. The result is placed
 			 * in `left'.
 			 */
 			if (p != NULL) {
-				if (symlink[slen - 1] != '/') {
-					if (slen + 1 >= (ssize_t)sizeof(symlink)) {
+				if (link_tgt[slen - 1] != '/') {
+					if (slen + 1 >= (ssize_t)sizeof(link_tgt)) {
 						errno = ENAMETOOLONG;
 						return (NULL);
 					}
-					symlink[slen] = '/';
-					symlink[slen + 1] = 0;
+					link_tgt[slen] = '/';
+					link_tgt[slen + 1] = 0;
 				}
-				left_len = strlcat(symlink, left,
-				    sizeof(symlink));
-				if (left_len >= sizeof(symlink)) {
+				left_len = strlcat(link_tgt, left,
+						   sizeof(link_tgt));
+				if (left_len >= sizeof(link_tgt)) {
 					errno = ENAMETOOLONG;
 					return (NULL);
 				}
 			}
-			left_len = strlcpy(left, symlink, sizeof(left));
+			left_len = strlcpy(left, link_tgt, sizeof(left));
 		} else if (!S_ISDIR(sb.st_mode) && p != NULL) {
 			errno = ENOTDIR;
 			return (NULL);
diff --git a/contrib/ntp/libntp/numtoa.c b/contrib/ntp/libntp/numtoa.c
index 51645de01c30..ac8978ee5e58 100644
--- a/contrib/ntp/libntp/numtoa.c
+++ b/contrib/ntp/libntp/numtoa.c
@@ -12,7 +12,6 @@
 #include <ctype.h>
 
 #include "ntp_fp.h"
-#include "lib_strbuf.h"
 #include "ntp_stdlib.h"
 
 char *
@@ -34,7 +33,11 @@ numtoa(
 }
 
 
-/* Convert a refid & stratum to a string */
+/* 
+ * Convert a refid & stratum to a string.  If stratum is negative and the
+ * refid consists entirely of graphic chars, up to an optional
+ * terminating zero, display as text similar to stratum 0 & 1.
+ */
 const char *
 refid_str(
 	u_int32	refid,
@@ -43,33 +46,44 @@ refid_str(
 {
 	char *	text;
 	size_t	tlen;
-	char *  cp;
-
-	if (stratum > 1)
-		return numtoa(refid);
-
-	LIB_GETBUF(text);
-	text[0] = '.';
-	/* What if any non-NUL char is not printable? */
-	memcpy(&text[1], &refid, sizeof(refid));
-	text[1 + sizeof(refid)] = '\0';
-	tlen = strlen(text);
-	text[tlen] = '.';
-	text[tlen + 1] = '\0';
+	char *	cp;
+	int	printable;
 
 	/*
-	 * Now make sure the contents are 'graphic'.
-	 *
-	 * This refid is expected to be up to 4 ascii graphics.
-	 * If any character is not a graphic, replace it with a space.
-	 * This will at least alert the viewer of a problem.
+	 * ntpd can have stratum = 0 and refid 127.0.0.1 in orphan mode.
+	 * https://bugs.ntp.org/3854.  Mirror the refid logic in timer().
 	 */
-	for (cp = text + 1; *cp; ++cp) {
-		if (!isgraph((int)*cp)) {
-			*cp = ' ';
+	if (0 == stratum && LOOPBACKADR_N == refid) {
+		return ".ORPH.";
+	}
+	printable = FALSE;
+	if (stratum < 2) {
+		text = lib_getbuf();
+		text[0] = '.';
+		memcpy(&text[1], &refid, sizeof(refid));
+		text[1 + sizeof(refid)] = '\0';
+		tlen = strlen(text);
+		text[tlen] = '.';
+		text[tlen + 1] = '\0';
+		/*
+		 * Now make sure the contents are 'graphic'.
+		 *
+		 * This refid is expected to be up to 4 printable ASCII.
+		 * isgraph() is similar to isprint() but excludes space.
+		 * If any character is not graphic, replace it with a '?'.
+		 * This will at least alert the viewer of a problem.
+		 */
+		for (cp = text + 1; '\0' != *cp; ++cp) {
+			if (!isgraph((int)*cp)) {
+				printable = FALSE;
+				*cp = '?';
+			}
+		}
+		if (   (stratum < 0 && printable)
+		    || stratum < 2) {
+			return text;
 		}
 	}
-
-	return text;
+	return numtoa(refid);
 }
 
diff --git a/contrib/ntp/libntp/numtohost.c b/contrib/ntp/libntp/numtohost.c
deleted file mode 100644
index 6b250d602de0..000000000000
--- a/contrib/ntp/libntp/numtohost.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * numtohost - convert network number to host name.
- */
-#include <config.h>
-
-#include <sys/types.h>
-#ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h>		/* ntohl */
-#endif
-
-#include "ntp_fp.h"
-#include "ntp_stdlib.h"
-#include "lib_strbuf.h"
-
-#define	LOOPBACKNET	0x7f000000
-#define	LOOPBACKHOST	0x7f000001
-#define	LOOPBACKNETMASK	0xff000000
-
-char *
-numtohost(
-	u_int32 netnum
-	)
-{
-	char *bp;
-	struct hostent *hp;
-
-	/*
-	 * This is really gross, but saves lots of hanging looking for
-	 * hostnames for the radio clocks.  Don't bother looking up
-	 * addresses on the loopback network except for the loopback
-	 * host itself.
-	 */
-	if ((((ntohl(netnum) & LOOPBACKNETMASK) == LOOPBACKNET)
-	     && (ntohl(netnum) != LOOPBACKHOST))
-	    || ((hp = gethostbyaddr((char *)&netnum, sizeof netnum, AF_INET))
-		== 0))
-	    return numtoa(netnum);
-	
-	LIB_GETBUF(bp);
-	strlcpy(bp, hp->h_name, LIB_BUFLENGTH);
-
-	return bp;
-}
diff --git a/contrib/ntp/libntp/prettydate.c b/contrib/ntp/libntp/prettydate.c
index deacc26bbe2b..060f79e5e327 100644
--- a/contrib/ntp/libntp/prettydate.c
+++ b/contrib/ntp/libntp/prettydate.c
@@ -6,7 +6,6 @@
 
 #include "ntp_fp.h"
 #include "ntp_unixtime.h"	/* includes <sys/time.h> */
-#include "lib_strbuf.h"
 #include "ntp_stdlib.h"
 #include "ntp_assert.h"
 #include "ntp_calendar.h"
diff --git a/contrib/ntp/libntp/recvbuff.c b/contrib/ntp/libntp/recvbuff.c
index d84a87d68501..6e7cda5d373d 100644
--- a/contrib/ntp/libntp/recvbuff.c
+++ b/contrib/ntp/libntp/recvbuff.c
@@ -93,41 +93,54 @@ initialise_buffer(recvbuf_t *buff)
 
 static void
 create_buffers(
-	size_t		nbufs)
+	size_t			nbufs
+)
 {
+	static const u_int	chunk =
 #   ifndef DEBUG
-	static const u_int chunk = RECV_INC;
+					RECV_INC;
 #   else
 	/* Allocate each buffer individually so they can be free()d
 	 * during ntpd shutdown on DEBUG builds to keep them out of heap
 	 * leak reports.
 	 */
-	static const u_int chunk = 1;
+					1;
 #   endif
-
-	register recvbuf_t *bufp;
-	u_int i;
-	size_t abuf;
+	static int/*BOOL*/	doneonce;
+	recvbuf_t *		bufp;
+	u_int			i;
+	size_t			abuf;
 
 	/*[bug 3666]: followup -- reset shortfalls in all cases */
 	abuf = nbufs + buffer_shortfall;
 	buffer_shortfall = 0;
 
-	if (limit_recvbufs <= total_recvbufs)
+	if (limit_recvbufs <= total_recvbufs) {
+		if (!doneonce) {
+			msyslog(LOG_CRIT, "Unable to allocate receive"
+					  " buffer, %lu/%lu",
+				total_recvbufs, limit_recvbufs);
+			doneonce = TRUE;
+		}
 		return;
-	
-	if (abuf < nbufs || abuf > RECV_BATCH)
+	}
+
+	if (abuf < nbufs || abuf > RECV_BATCH) {
 		abuf = RECV_BATCH;	/* clamp on overflow */
-	else
+	} else {
 		abuf += (~abuf + 1) & (RECV_INC - 1);	/* round up */
-	
-	if (abuf > (limit_recvbufs - total_recvbufs))
+	}
+	if (abuf > (limit_recvbufs - total_recvbufs)) {
 		abuf = limit_recvbufs - total_recvbufs;
+	}
 	abuf += (~abuf + 1) & (chunk - 1);		/* round up */
 	
 	while (abuf) {
 		bufp = calloc(chunk, sizeof(*bufp));
 		if (!bufp) {
+			msyslog(LOG_CRIT, "Out of memory, allocating "
+					  "%u recvbufs, %lu bytes",
+				chunk, (u_long)sizeof(*bufp) * chunk);
 			limit_recvbufs = total_recvbufs;
 			break;
 		}
diff --git a/contrib/ntp/libntp/refnumtoa.c b/contrib/ntp/libntp/refnumtoa.c
index cfebefe1ed18..1e1aa4e06b4c 100644
--- a/contrib/ntp/libntp/refnumtoa.c
+++ b/contrib/ntp/libntp/refnumtoa.c
@@ -5,7 +5,6 @@
 #include <stdio.h>
 
 #include "ntp_net.h"
-#include "lib_strbuf.h"
 #include "ntp_stdlib.h"
 
 const char *
diff --git a/contrib/ntp/libntp/snprintf.c b/contrib/ntp/libntp/snprintf.c
index f4685e1ad4b6..52ec17a04eb2 100644
--- a/contrib/ntp/libntp/snprintf.c
+++ b/contrib/ntp/libntp/snprintf.c
@@ -1587,7 +1587,7 @@ rpl_asprintf(va_alist) va_dcl
 }
 #endif	/* HW_WANT_RPL_ASPRINTF */
 #else	/* Dummy declaration to avoid empty translation unit warnings. */
-int main(void);
+NONEMPTY_TRANSLATION_UNIT
 #endif	/* HW_WANT_RPL_SNPRINTF || HW_WANT_RPL_VSNPRINTF || HW_WANT_RPL_ASPRINTF || [...] */
 
 #if TEST_SNPRINTF
diff --git a/contrib/ntp/libntp/socket.c b/contrib/ntp/libntp/socket.c
index 11fb004690c4..08e6ffbebb6a 100644
--- a/contrib/ntp/libntp/socket.c
+++ b/contrib/ntp/libntp/socket.c
@@ -195,11 +195,11 @@ open_socket(
 	)
 void
 sendpkt(
-	sockaddr_u *		dest,
-	struct interface *	ep,
-	int			ttl,
-	struct pkt *		pkt,
-	int			len
+	sockaddr_u *	dest,
+	endpt *		ep,
+	int		ttl,
+	struct pkt *	pkt,
+	int		len
 	)
 
 static inline int
@@ -207,9 +207,9 @@ read_refclock_packet(SOCKET fd, struct refclockio *rp, l_fp ts)
 
 static inline int
 read_network_packet(
-	SOCKET			fd,
-	struct interface *	itf,
-	l_fp			ts
+	SOCKET	fd,
+	endpt *	itf,
+	l_fp	ts
 	)
 
 void
diff --git a/contrib/ntp/libntp/socktoa.c b/contrib/ntp/libntp/socktoa.c
index 4071b0a45be0..f83f78b87981 100644
--- a/contrib/ntp/libntp/socktoa.c
+++ b/contrib/ntp/libntp/socktoa.c
@@ -21,7 +21,6 @@
 #include <isc/sockaddr.h>
 
 #include "ntp_fp.h"
-#include "lib_strbuf.h"
 #include "ntp_stdlib.h"
 #include "ntp.h"
 
diff --git a/contrib/ntp/libntp/socktohost.c b/contrib/ntp/libntp/socktohost.c
index fdf9adb9e2e6..3ea5b56004d8 100644
--- a/contrib/ntp/libntp/socktohost.c
+++ b/contrib/ntp/libntp/socktohost.c
@@ -15,7 +15,6 @@
 #include <stdio.h>
 
 #include "ntp_fp.h"
-#include "lib_strbuf.h"
 #include "ntp_stdlib.h"
 #include "ntp.h"
 #include "ntp_debug.h"
diff --git a/contrib/ntp/libntp/ssl_init.c b/contrib/ntp/libntp/ssl_init.c
index 925893257b7f..6de8a0b5fccc 100644
--- a/contrib/ntp/libntp/ssl_init.c
+++ b/contrib/ntp/libntp/ssl_init.c
@@ -23,67 +23,60 @@
 #  define CMAC_LENGTH	16
 #  define CMAC		"AES128CMAC"
 # endif /*HAVE_OPENSSL_CMAC_H*/
-int ssl_init_done;
 
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+EVP_MD_CTX *digest_ctx;
+
 
 static void
 atexit_ssl_cleanup(void)
 {
-	if (!ssl_init_done) {
+	if (NULL == digest_ctx) {
 		return;
 	}
-
-	ssl_init_done = FALSE;
+	EVP_MD_CTX_free(digest_ctx);
+	digest_ctx = NULL;
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
 	EVP_cleanup();
 	ERR_free_strings();
+#endif	/* OpenSSL < 1.1 */
 }
 
+
 void
 ssl_init(void)
 {
 	init_lib();
 
-	if ( ! ssl_init_done) {
-	    ERR_load_crypto_strings();
-	    OpenSSL_add_all_algorithms();
-	    atexit(&atexit_ssl_cleanup);
-	    ssl_init_done = TRUE;
+	if (NULL == digest_ctx) {
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+		ERR_load_crypto_strings();
+		OpenSSL_add_all_algorithms();
+#endif	/* OpenSSL < 1.1 */
+		digest_ctx = EVP_MD_CTX_new();
+		INSIST(digest_ctx != NULL);
+		atexit(&atexit_ssl_cleanup);
 	}
 }
 
-#else /* OPENSSL_VERSION_NUMBER >= 0x10100000L */
-
-void
-ssl_init(void)
-{
-	init_lib();
-	ssl_init_done = TRUE;
-}
-
-#endif /* OPENSSL_VERSION_NUMBER */
-
 
 void
 ssl_check_version(void)
 {
 	u_long	v;
+	char *  buf;
 
 	v = OpenSSL_version_num();
 	if ((v ^ OPENSSL_VERSION_NUMBER) & ~0xff0L) {
-		msyslog(LOG_WARNING,
-		    "OpenSSL version mismatch. Built against %lx, you have %lx",
-		    (u_long)OPENSSL_VERSION_NUMBER, v);
-		fprintf(stderr,
-		    "OpenSSL version mismatch. Built against %lx, you have %lx\n",
-		    (u_long)OPENSSL_VERSION_NUMBER, v);
+		LIB_GETBUF(buf);
+		snprintf(buf, LIB_BUFLENGTH, 
+			 "OpenSSL version mismatch."
+			 "Built against %lx, you have %lx\n",
+			 (u_long)OPENSSL_VERSION_NUMBER, v);
+		msyslog(LOG_WARNING, "%s", buf);
+		fputs(buf, stderr);
 	}
-
 	INIT_SSL();
 }
-
-#else	/* !OPENSSL */
-# define MD5_LENGTH	16
 #endif	/* OPENSSL */
 
 
@@ -102,7 +95,7 @@ keytype_from_text(
 	int		key_type;
 	u_int		digest_len;
 #ifdef OPENSSL	/* --*-- OpenSSL code --*-- */
-	const u_long	max_digest_len = MAX_MAC_LEN - sizeof(keyid_t);
+	const u_long	max_digest_len = MAX_MDG_LEN;
 	char *		upcased;
 	char *		pch;
 	EVP_MD const *	md;
@@ -204,7 +197,7 @@ keytype_from_text(
  */
 const char *
 keytype_name(
-	int nid
+	int type
 	)
 {
 	static const char unknown_type[] = "(unknown key type)";
@@ -212,23 +205,18 @@ keytype_name(
 
 #ifdef OPENSSL
 	INIT_SSL();
-	name = OBJ_nid2sn(nid);
+	name = OBJ_nid2sn(type);
 
 #   ifdef ENABLE_CMAC
-	if (NID_cmac == nid) {
+	if (NID_cmac == type) {
 		name = CMAC;
-
-		if (debug) {
-			fprintf(stderr, "%s:%d:%s():%s:nid\n",
-				__FILE__, __LINE__, __func__, CMAC);
-		}
 	} else
 #   endif /*ENABLE_CMAC*/
 	if (NULL == name) {
 		name = unknown_type;
 	}
 #else	/* !OPENSSL follows */
-	if (NID_md5 == nid)
+	if (NID_md5 == type)
 		name = "MD5";
 	else
 		name = unknown_type;
@@ -251,13 +239,13 @@ keytype_name(
  */
 char *
 getpass_keytype(
-	int	keytype
+	int	type
 	)
 {
 	char	pass_prompt[64 + 11 + 1]; /* 11 for " Password: " */
 
 	snprintf(pass_prompt, sizeof(pass_prompt),
-		 "%.64s Password: ", keytype_name(keytype));
+		 "%.64s Password: ", keytype_name(type));
 
 	return getpass(pass_prompt);
 }
diff --git a/contrib/ntp/libntp/statestr.c b/contrib/ntp/libntp/statestr.c
index e712dc87e32d..bde1f50e7e74 100644
--- a/contrib/ntp/libntp/statestr.c
+++ b/contrib/ntp/libntp/statestr.c
@@ -8,7 +8,6 @@
 #include "ntp_stdlib.h"
 #include "ntp_fp.h"
 #include "ntp.h"
-#include "lib_strbuf.h"
 #include "ntp_refclock.h"
 #include "ntp_control.h"
 #include "ntp_string.h"
diff --git a/contrib/ntp/libntp/systime.c b/contrib/ntp/libntp/systime.c
index 76fba7fe1608..8d10b2e43f82 100644
--- a/contrib/ntp/libntp/systime.c
+++ b/contrib/ntp/libntp/systime.c
@@ -16,7 +16,6 @@
 #include "timevalops.h"
 #include "timespecops.h"
 #include "ntp_calendar.h"
-#include "lib_strbuf.h"
 
 #ifdef HAVE_SYS_PARAM_H
 # include <sys/param.h>
diff --git a/contrib/ntp/libntp/timexsup.c b/contrib/ntp/libntp/timexsup.c
index 979a7c4aea8e..21f7738d3e5f 100644
--- a/contrib/ntp/libntp/timexsup.c
+++ b/contrib/ntp/libntp/timexsup.c
@@ -6,14 +6,27 @@
  */
 
 #include "config.h"
-#include "timexsup.h"
 #include <limits.h>
 #include <math.h>
 
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#else
+# ifdef HAVE_TIME_H
+#  include <time.h>
+# endif
+#endif
 #ifdef HAVE_SYS_TIMEX_H
 # include <sys/timex.h>
+#else
+# ifdef HAVE_TIMEX_H
+#  include <timex.h>
+# endif
 #endif
 
+#include "ntp_types.h"
+#include "timexsup.h"
+
 #if defined(MOD_NANO) != defined(STA_NANO)
 # warning inconsistent definitions of MOD_NANO vs STA_NANO
 #endif
@@ -41,10 +54,11 @@ dbl_from_var_long(
 	)
 {
 #ifdef STA_NANO
-	if (status & STA_NANO)
+	if (STA_NANO & status) {
 		return (double)lval * 1e-9;
+	}
 #else
-	(void)status;
+	UNUSED_ARG(status);
 #endif
 	return (double)lval * 1e-6;
 }
@@ -67,7 +81,7 @@ var_long_from_dbl(
 	*modes |= MOD_NANO;
 	dval *= 1e+9;
 #else
-	(void)modes;
+	UNUSED_ARG(modes);
 	dval *= 1e+6;
 #endif
 	return clamp_rounded(dval);
diff --git a/contrib/ntp/libntp/uglydate.c b/contrib/ntp/libntp/uglydate.c
index 66b5139096b4..165578674185 100644
--- a/contrib/ntp/libntp/uglydate.c
+++ b/contrib/ntp/libntp/uglydate.c
@@ -7,7 +7,6 @@
 
 #include "ntp_fp.h"
 #include "ntp_unixtime.h"
-#include "lib_strbuf.h"
 #include "ntp_stdlib.h"
 
 
diff --git a/contrib/ntp/libntp/vint64ops.c b/contrib/ntp/libntp/vint64ops.c
index 1d5087d95438..23c9f26dcfac 100644
--- a/contrib/ntp/libntp/vint64ops.c
+++ b/contrib/ntp/libntp/vint64ops.c
@@ -15,24 +15,25 @@
 
 #include "ntp_types.h"
 #include "ntp_fp.h"
+#include "ntp_malloc.h"
 #include "vint64ops.h"
 
 /* -------------------------------------------------------------------------*/
 
 vint64
 strtouv64(
-	char const *		begp,
-	char const ** const	endp,
-	int			base
+	char *	begp,
+	char ** endp,
+	int	base
 	)
 {
-	vint64  res;
-	u_char  digit;
-	int     sig, num;
-	const u_char *src;
+	vint64	res;
+	u_char	digit;
+	int	sig, num;
+	u_char *src;
 	
 	num = sig = 0;
-	src = (const u_char*)begp;
+	src = (u_char *)begp;
 	while (isspace(*src))
 		src++;
 
@@ -61,7 +62,7 @@ strtouv64(
 		return res;
 	}
 	
-	memset(&res, 0, sizeof(res));
+	ZERO(res);
 	while (*src) {
 		if (isdigit(*src))
 			digit = *src - '0';
@@ -97,7 +98,7 @@ strtouv64(
 	if (!num)
 		errno = EINVAL;
 	if (endp)
-		*endp = (const char *)src;
+		*endp = (char *)src;
 	if (sig)
 		M_NEG(res.D_s.hi, res.D_s.lo);
 	return res;
diff --git a/contrib/ntp/libntp/work_thread.c b/contrib/ntp/libntp/work_thread.c
index c1fe5c20c995..0d15c6e36e6f 100644
--- a/contrib/ntp/libntp/work_thread.c
+++ b/contrib/ntp/libntp/work_thread.c
@@ -376,8 +376,12 @@ send_blocking_resp_internal(
 	{
 #	    ifdef WORK_PIPE
 		if (1 != write(c->resp_write_pipe, "", 1))
-			msyslog(LOG_WARNING, "async resolver: %s",
-				"failed to notify main thread!");
+			msyslog(LOG_WARNING, "async resolver: blocking_get%sinfo"
+				" failed to notify main thread!",
+				(BLOCKING_GETNAMEINFO == resp->rtype)
+				    ? "name"
+				    : "addr"
+				);
 #	    else
 		tickle_sem(c->responses_pending);
 #	    endif
@@ -489,7 +493,7 @@ start_blocking_thread(
 
 /* --------------------------------------------------------------------
  * Create a worker thread. There are several differences between POSIX
- * and Windows, of course -- most notably the Windows thread is no
+ * and Windows, of course -- most notably the Windows thread is a
  * detached thread, and we keep the handle around until we want to get
  * rid of the thread. The notification scheme also differs: Windows
  * makes use of semaphores in both directions, POSIX uses a pipe for
@@ -520,9 +524,12 @@ start_blocking_thread_internal(
 	}
 	/* remember the thread priority is only within the process class */
 	if (!SetThreadPriority(c->thr_table[0].thnd,
-			       THREAD_PRIORITY_BELOW_NORMAL))
+			       THREAD_PRIORITY_BELOW_NORMAL)) {
 		msyslog(LOG_ERR, "Error lowering blocking thread priority: %m");
-
+	}
+	if (NULL != pSetThreadDescription) {
+		(*pSetThreadDescription)(c->thr_table[0].thnd, L"ntp_worker");
+	}
 	resumed = ResumeThread(c->thr_table[0].thnd);
 	DEBUG_INSIST(resumed);
 	c->thread_ref = &c->thr_table[0];
diff --git a/contrib/ntp/libparse/Makefile.am b/contrib/ntp/libparse/Makefile.am
index a4a3ed264f2f..f88e3b2af36d 100644
--- a/contrib/ntp/libparse/Makefile.am
+++ b/contrib/ntp/libparse/Makefile.am
@@ -94,14 +94,9 @@ AM_LDFLAGS = $(NTP_HARD_LDFLAGS)
 EXTRA_DIST = parsesolaris.c parsestreams.c mkinfo_scmd.sed mkinfo_rcmd.sed info_trimble.c
 
 info_trimble.c: $(top_srcdir)/include/trimble.h $(srcdir)/Makefile.am $(srcdir)/mkinfo_scmd.sed $(srcdir)/mkinfo_rcmd.sed
-	sed -n -f $(srcdir)/mkinfo_scmd.sed $(top_srcdir)/include/trimble.h  > info_trimble.new
-	sed -n -f $(srcdir)/mkinfo_rcmd.sed $(top_srcdir)/include/trimble.h >> info_trimble.new
-	mv -f info_trimble.new $@
-
-#$(srcdir)/info_trimble.c: $(top_srcdir)/include/trimble.h $(srcdir)/Makefile.am $(srcdir)/mkinfo_scmd.sed $(srcdir)/mkinfo_rcmd.sed
-#	sed -n -f $(srcdir)/mkinfo_scmd.sed $(top_srcdir)/include/trimble.h  > info_trimble.new
-#	sed -n -f $(srcdir)/mkinfo_rcmd.sed $(top_srcdir)/include/trimble.h >> info_trimble.new
-#	mv -f info_trimble.new $@
+	$(AM_V_at)$(SED) -n -f $(srcdir)/mkinfo_scmd.sed $(top_srcdir)/include/trimble.h  > info_trimble.new
+	$(AM_V_at)$(SED) -n -f $(srcdir)/mkinfo_rcmd.sed $(top_srcdir)/include/trimble.h >> info_trimble.new
+	$(AM_V_at)mv -f info_trimble.new $@
 
 kieee754io.o: $(srcdir)/ieee754io.c
 	 $(COMPILE) $(K_CFLAGS) -c $(srcdir)/ieee754io.c -o $@
@@ -165,11 +160,11 @@ parse: $(parsesolaris_OBJECTS) libparse_kernel.a ../libntp/libntp.a
 
 parsesolaris.o: sys/systm.h
 
-# [Bug3608] Solaris has inconsistent definitions of ffs() and fls(). Drop the
+# [Bug 3608] Solaris has inconsistent definitions of ffs() and fls(). Drop the
 # ones from 'systm.h'.
 sys/systm.h:
 	-mkdir sys
-	sed -e '/f[fl]s(.*)/d' < /usr/include/sys/systm.h > sys/systm.h
+	$(SED) -e '/f[fl]s(.*)/d' < /usr/include/sys/systm.h > sys/systm.h
 
 ## check-libparse is invoked by ntpd/Makefile.am
 check-libparse: $(noinst_LIBRARIES)
diff --git a/contrib/ntp/libparse/Makefile.in b/contrib/ntp/libparse/Makefile.in
index 70fb2d0a5fea..88a42a6f12c7 100644
--- a/contrib/ntp/libparse/Makefile.in
+++ b/contrib/ntp/libparse/Makefile.in
@@ -90,6 +90,7 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 EXTRA_PROGRAMS = parsestreams$(EXEEXT) parsesolaris$(EXEEXT)
+@LIBNTP_SUBMAKES_TRUE@am__append_1 = check-libntp
 subdir = libparse
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
@@ -423,6 +424,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_NET_SNMP_CONFIG = @PATH_NET_SNMP_CONFIG@
+PATH_OPENSSL = @PATH_OPENSSL@
 PATH_PERL = @PATH_PERL@
 PATH_RUBY = @PATH_RUBY@
 PATH_SEPARATOR = @PATH_SEPARATOR@
@@ -522,9 +524,9 @@ top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 NULL = 
-BUILT_SOURCES = $(VPHACK) info_trimble.c $(VPHACK_AFTER) check-libntp \
-	.deps-ver
-CLEANFILES = check-libntp .deps-ver
+BUILT_SOURCES = $(VPHACK) info_trimble.c $(VPHACK_AFTER) \
+	$(am__append_1) .deps-ver
+CLEANFILES = .deps-ver
 DISTCLEANFILES = $(DEPDIR)/deps-ver
 noinst_LIBRARIES = @MAKE_LIBPARSE@ @MAKE_LIBPARSE_KERNEL@
 EXTRA_LIBRARIES = libparse.a libparse_kernel.a
@@ -998,14 +1000,9 @@ vphack_after:
 		)
 
 info_trimble.c: $(top_srcdir)/include/trimble.h $(srcdir)/Makefile.am $(srcdir)/mkinfo_scmd.sed $(srcdir)/mkinfo_rcmd.sed
-	sed -n -f $(srcdir)/mkinfo_scmd.sed $(top_srcdir)/include/trimble.h  > info_trimble.new
-	sed -n -f $(srcdir)/mkinfo_rcmd.sed $(top_srcdir)/include/trimble.h >> info_trimble.new
-	mv -f info_trimble.new $@
-
-#$(srcdir)/info_trimble.c: $(top_srcdir)/include/trimble.h $(srcdir)/Makefile.am $(srcdir)/mkinfo_scmd.sed $(srcdir)/mkinfo_rcmd.sed
-#	sed -n -f $(srcdir)/mkinfo_scmd.sed $(top_srcdir)/include/trimble.h  > info_trimble.new
-#	sed -n -f $(srcdir)/mkinfo_rcmd.sed $(top_srcdir)/include/trimble.h >> info_trimble.new
-#	mv -f info_trimble.new $@
+	$(AM_V_at)$(SED) -n -f $(srcdir)/mkinfo_scmd.sed $(top_srcdir)/include/trimble.h  > info_trimble.new
+	$(AM_V_at)$(SED) -n -f $(srcdir)/mkinfo_rcmd.sed $(top_srcdir)/include/trimble.h >> info_trimble.new
+	$(AM_V_at)mv -f info_trimble.new $@
 
 kieee754io.o: $(srcdir)/ieee754io.c
 	 $(COMPILE) $(K_CFLAGS) -c $(srcdir)/ieee754io.c -o $@
@@ -1069,20 +1066,19 @@ parse: $(parsesolaris_OBJECTS) libparse_kernel.a ../libntp/libntp.a
 
 parsesolaris.o: sys/systm.h
 
-# [Bug3608] Solaris has inconsistent definitions of ffs() and fls(). Drop the
+# [Bug 3608] Solaris has inconsistent definitions of ffs() and fls(). Drop the
 # ones from 'systm.h'.
 sys/systm.h:
 	-mkdir sys
-	sed -e '/f[fl]s(.*)/d' < /usr/include/sys/systm.h > sys/systm.h
+	$(SED) -e '/f[fl]s(.*)/d' < /usr/include/sys/systm.h > sys/systm.h
 
 check-libparse: $(noinst_LIBRARIES)
 	@: do-nothing action to avoid default SCCS get
 
-check-libntp: $(top_builddir)/libntp/libntp.a
-	@: avoid default SCCS get by some make implementations
+.PHONY: check-libntp
 
-$(top_builddir)/libntp/libntp.a:
-	cd $(top_builddir)/libntp && $(MAKE) $(AM_MAKEFLAGS) libntp.a
+@LIBNTP_SUBMAKES_TRUE@check-libntp:
+@LIBNTP_SUBMAKES_TRUE@	cd $(top_builddir)/libntp && $(MAKE) $(AM_MAKEFLAGS) libntp.a
 $(DEPDIR)/deps-ver: $(top_srcdir)/deps-ver
 	@[ -f $@ ] ||							\
 		cp $(top_srcdir)/deps-ver $@
diff --git a/contrib/ntp/libparse/clk_computime.c b/contrib/ntp/libparse/clk_computime.c
index 7273ac762e37..10ec9a7c1c97 100644
--- a/contrib/ntp/libparse/clk_computime.c
+++ b/contrib/ntp/libparse/clk_computime.c
@@ -182,7 +182,7 @@ inp_computime(
 }
 
 #else /* not (REFCLOCK && CLOCK_PARSE && CLOCK_COMPUTIME) */
-int clk_computime_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* not (REFCLOCK && CLOCK_PARSE && CLOCK_COMPUTIME) */
 
 /*
diff --git a/contrib/ntp/libparse/clk_dcf7000.c b/contrib/ntp/libparse/clk_dcf7000.c
index 0621cd5649e4..4aeb4c39ba9f 100644
--- a/contrib/ntp/libparse/clk_dcf7000.c
+++ b/contrib/ntp/libparse/clk_dcf7000.c
@@ -176,7 +176,7 @@ inp_dcf7000(
 }
 
 #else /* not (REFCLOCK && CLOCK_PARSE && CLOCK_DCF7000) */
-int clk_dcf7000_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* not (REFCLOCK && CLOCK_PARSE && CLOCK_DCF7000) */
 
 /*
diff --git a/contrib/ntp/libparse/clk_hopf6021.c b/contrib/ntp/libparse/clk_hopf6021.c
index a747581b75dc..436c92cb3b88 100644
--- a/contrib/ntp/libparse/clk_hopf6021.c
+++ b/contrib/ntp/libparse/clk_hopf6021.c
@@ -20,7 +20,7 @@
 # include <config.h>
 #endif
 
-#include <ntp_types.h>
+#include "ntp_types.h"
 
 #if defined(REFCLOCK) && defined(CLOCK_PARSE) && defined(CLOCK_HOPF6021)
 
diff --git a/contrib/ntp/libparse/clk_meinberg.c b/contrib/ntp/libparse/clk_meinberg.c
index e4ebf0acc605..1aa839bfd15a 100644
--- a/contrib/ntp/libparse/clk_meinberg.c
+++ b/contrib/ntp/libparse/clk_meinberg.c
@@ -733,7 +733,7 @@ gps_input(
 }
 
 #else /* not (REFCLOCK && CLOCK_PARSE && CLOCK_MEINBERG) */
-int clk_meinberg_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* not (REFCLOCK && CLOCK_PARSE && CLOCK_MEINBERG) */
 
 /*
diff --git a/contrib/ntp/libparse/clk_rawdcf.c b/contrib/ntp/libparse/clk_rawdcf.c
index 3fa74997c9bf..9b6eeafb163f 100644
--- a/contrib/ntp/libparse/clk_rawdcf.c
+++ b/contrib/ntp/libparse/clk_rawdcf.c
@@ -742,7 +742,7 @@ inp_rawdcf(
 }
 
 #else /* not (REFCLOCK && CLOCK_PARSE && CLOCK_RAWDCF) */
-int clk_rawdcf_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* not (REFCLOCK && CLOCK_PARSE && CLOCK_RAWDCF) */
 
 /*
diff --git a/contrib/ntp/libparse/clk_rcc8000.c b/contrib/ntp/libparse/clk_rcc8000.c
index 11d52acc5a24..e9bb115da4f5 100644
--- a/contrib/ntp/libparse/clk_rcc8000.c
+++ b/contrib/ntp/libparse/clk_rcc8000.c
@@ -163,7 +163,7 @@ inp_rcc8000(
 }
 
 #else  /* not (REFCLOCK && CLOCK_PARSE && CLOCK_RCC8000) */
-int clk_rcc8000_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif  /* not (REFCLOCK && CLOCK_PARSE && CLOCK_RCC8000) */
 
 /*
diff --git a/contrib/ntp/libparse/clk_schmid.c b/contrib/ntp/libparse/clk_schmid.c
index d85b1a5da512..5dd52047aa0f 100644
--- a/contrib/ntp/libparse/clk_schmid.c
+++ b/contrib/ntp/libparse/clk_schmid.c
@@ -222,7 +222,7 @@ inp_schmid(
 }
 
 #else /* not (REFCLOCK && CLOCK_PARSE && CLOCK_SCHMID) */
-int clk_schmid_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* not (REFCLOCK && CLOCK_PARSE && CLOCK_SCHMID) */
 
 /*
diff --git a/contrib/ntp/libparse/clk_sel240x.c b/contrib/ntp/libparse/clk_sel240x.c
index b1390b4cefb1..f27b662491f1 100644
--- a/contrib/ntp/libparse/clk_sel240x.c
+++ b/contrib/ntp/libparse/clk_sel240x.c
@@ -168,5 +168,5 @@ cvt_sel240x( unsigned char *buffer,
 }
 
 #else  /* not (REFCLOCK && CLOCK_PARSE && CLOCK_SEL240X) */
-int clk_sel240x_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* not (REFCLOCK && CLOCK_PARSE && CLOCK_SEL240X) */
diff --git a/contrib/ntp/libparse/clk_trimtaip.c b/contrib/ntp/libparse/clk_trimtaip.c
index a60d01ec1870..ce930952ffa2 100644
--- a/contrib/ntp/libparse/clk_trimtaip.c
+++ b/contrib/ntp/libparse/clk_trimtaip.c
@@ -181,7 +181,7 @@ inp_trimtaip(
 }
 
 #else /* not (REFCLOCK && CLOCK_PARSE && CLOCK_TRIMTAIP) */
-int clk_trimtaip_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* not (REFCLOCK && CLOCK_PARSE && CLOCK_TRIMTAIP) */
 
 /*
diff --git a/contrib/ntp/libparse/clk_trimtsip.c b/contrib/ntp/libparse/clk_trimtsip.c
index 8cf5660657cc..5af69d349eea 100644
--- a/contrib/ntp/libparse/clk_trimtsip.c
+++ b/contrib/ntp/libparse/clk_trimtsip.c
@@ -388,7 +388,7 @@ cvt_trimtsip(
 }
 
 #else /* not (REFCLOCK && CLOCK_PARSE && CLOCK_TRIMTSIP && !PARSESTREAM) */
-int clk_trimtsip_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* not (REFCLOCK && CLOCK_PARSE && CLOCK_TRIMTSIP && !PARSESTREAM) */
 
 /*
diff --git a/contrib/ntp/libparse/clk_varitext.c b/contrib/ntp/libparse/clk_varitext.c
index 0d830354d799..a4c6d31b797a 100644
--- a/contrib/ntp/libparse/clk_varitext.c
+++ b/contrib/ntp/libparse/clk_varitext.c
@@ -252,7 +252,7 @@ inp_varitext(
 }
 
 #else /* not (REFCLOCK && CLOCK_PARSE && CLOCK_VARITEXT) */
-int clk_varitext_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* not (REFCLOCK && CLOCK_PARSE && CLOCK_VARITEXT) */
 
 /*
diff --git a/contrib/ntp/libparse/clk_wharton.c b/contrib/ntp/libparse/clk_wharton.c
index e1ef61d55bdb..2df425bc67b7 100644
--- a/contrib/ntp/libparse/clk_wharton.c
+++ b/contrib/ntp/libparse/clk_wharton.c
@@ -9,7 +9,7 @@
 #include <config.h>
 #endif
 
-#include <ntp_types.h>
+#include "ntp_types.h"
 
 #if defined(REFCLOCK) && defined(CLOCK_PARSE) && defined(CLOCK_WHARTON_400A)
 /*
diff --git a/contrib/ntp/libparse/ieee754io.c b/contrib/ntp/libparse/ieee754io.c
index 61bc8533b0d7..b41a96c2170e 100644
--- a/contrib/ntp/libparse/ieee754io.c
+++ b/contrib/ntp/libparse/ieee754io.c
@@ -50,8 +50,6 @@ static void put_byte (unsigned char *, offsets_t, int *, unsigned char);
 
 #ifdef LIBDEBUG
 
-#include "lib_strbuf.h"
-
 static char *
 fmt_blong(
 	  unsigned long val,
@@ -396,7 +394,22 @@ fetch_ieee754(
 	}
     }
 }
-  
+
+/*
+ * DLH: This function is currently unused in ntpd.  If you think about
+ * using it, be sure it does what you intend.  I notice the bufpp arg
+ * is never referenced, and the calculated mantissa_high & mantissa_low
+ * are only referenced in debug output.  It seems they're supposed to
+ * be composed into an ieee754-format float and stored at *bufpp or
+ * possibly **bufpp.  Brought to my attention by this:
+ *
+ * ieee754io.c:414:10: warning: variable 'mantissa_low' set but not used
+ * [-Wunused-but-set-variable]
+ *
+ * To quiet it I'm #ifdef'ing the function away for now, here and below
+ * the call to it in main().
+ */
+#ifdef PUT_IEEE754_UNUSED_FUNC
 int
 put_ieee754(
 	    unsigned char **bufpp,
@@ -536,6 +549,7 @@ put_ieee754(
     }
   return IEEE_OK;
 }
+#endif	/* PUT_IEEE754_UNUSED_FUNC */
 
 
 #if defined(DEBUG) && defined(LIBDEBUG)
@@ -562,8 +576,11 @@ int main(
   printf("fetch from %f = %d\n", f, fetch_ieee754((void *)&f_p, IEEE_DOUBLE, &fp, native_off));
   printf("fp [%s %s] = %s\n", fmt_blong(fp.l_ui, 32), fmt_blong(fp.l_uf, 32), mfptoa(fp.l_ui, fp.l_uf, 15));
   f_p = &f;
+#ifdef PUT_IEEE754_UNUSED_FUNC
   put_ieee754((void *)&f_p, IEEE_DOUBLE, &fp, native_off);
-  
+/* there should be a check on *f_p (f) having the expected result here */
+#endif	/* PUT_IEEE754_UNUSED_FUNC */
+
   return 0;
 }
 
diff --git a/contrib/ntp/libparse/parse.c b/contrib/ntp/libparse/parse.c
index 69395ac4a560..56f2c3702bd8 100644
--- a/contrib/ntp/libparse/parse.c
+++ b/contrib/ntp/libparse/parse.c
@@ -875,7 +875,7 @@ parse_setcs(
 }
 
 #else /* not (REFCLOCK && CLOCK_PARSE) */
-int parse_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* not (REFCLOCK && CLOCK_PARSE) */
 
 /*
diff --git a/contrib/ntp/libparse/parse_conf.c b/contrib/ntp/libparse/parse_conf.c
index 37871c9de887..ad7a47aa937f 100644
--- a/contrib/ntp/libparse/parse_conf.c
+++ b/contrib/ntp/libparse/parse_conf.c
@@ -148,7 +148,7 @@ clockformat_t *clockformats[] =
 unsigned short nformats = sizeof(clockformats) / sizeof(clockformats[0]) - 1;
 
 #else /* not (REFCLOCK && CLOCK_PARSE) */
-int parse_conf_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* not (REFCLOCK && CLOCK_PARSE) */
 
 /*
diff --git a/contrib/ntp/ntpd/Makefile.in b/contrib/ntp/ntpd/Makefile.in
index 5b92df6c0906..57a7d30143fa 100644
--- a/contrib/ntp/ntpd/Makefile.in
+++ b/contrib/ntp/ntpd/Makefile.in
@@ -97,6 +97,7 @@ build_triplet = @build@
 host_triplet = @host@
 EXTRA_PROGRAMS = check_y2k$(EXEEXT) keyword-gen$(EXEEXT) ntpd$(EXEEXT) \
 	ntpdsim$(EXEEXT)
+@LIBNTP_SUBMAKES_TRUE@am__append_1 = check-libntp
 subdir = ntpd
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
@@ -551,6 +552,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_NET_SNMP_CONFIG = @PATH_NET_SNMP_CONFIG@
+PATH_OPENSSL = @PATH_OPENSSL@
 PATH_PERL = @PATH_PERL@
 PATH_RUBY = @PATH_RUBY@
 PATH_SEPARATOR = @PATH_SEPARATOR@
@@ -688,8 +690,8 @@ B_S_DIST = \
 	$(NULL)
 
 BUILT_SOURCES = $(VPHACK) $(LIBPARSE) ntp_parser.c ntp_parser.h \
-	$(VPHACK_AFTER) $(B_S_DIST) $(NULL) check-libopts check-libntp \
-	.deps-ver
+	$(VPHACK_AFTER) $(B_S_DIST) $(NULL) check-libopts \
+	$(am__append_1) .deps-ver
 man1_MANS = 
 man5_MANS = ntp.conf.5 ntp.keys.5
 man8_MANS = 
@@ -708,7 +710,7 @@ CLEANFILES = check-psl0 check-psl1 check-psl2 check-pslsaveconfig \
 	psl0save.conf psl0save.conf+ psl1save.conf psl1save.conf+ \
 	psl2save.conf psl2save.conf+ .version version.c ntpd-version.c \
 	sim-version.c $(EXTRA_PROGRAMS) $(NULL) check-libopts \
-	check-libntp .deps-ver
+	.deps-ver
 EXTRA_DIST = \
 	complete.conf.in	\
 	invoke-ntp.conf.menu	\
@@ -2124,18 +2126,16 @@ check-libopts: ../sntp/libopts/libopts.la
 ../sntp/libopts/libopts.la:
 	-cd ../sntp/libopts && $(MAKE) $(AM_MAKEFLAGS) libopts.la
 
-check-libntp: $(top_builddir)/libntp/libntp.a
-	@: avoid default SCCS get by some make implementations
+.PHONY: check-libntp
 
-$(top_builddir)/libntp/libntp.a:
-	cd $(top_builddir)/libntp && $(MAKE) $(AM_MAKEFLAGS) libntp.a
+@LIBNTP_SUBMAKES_TRUE@check-libntp:
+@LIBNTP_SUBMAKES_TRUE@	cd $(top_builddir)/libntp && $(MAKE) $(AM_MAKEFLAGS) libntp.a
 $(top_srcdir)/sntp/scm-rev: FRC.scm-rev
 	$(AM_V_GEN)cd $(top_builddir)/sntp && $(MAKE) $(AM_MAKEFLAGS) check-scm-rev
 
+.PHONY: FRC.scm-rev
 FRC.scm-rev:
-	@: FRC.scm-rev "force" depends on nothing and is not a file, so is	\
-	   always out-of-date causing targets which depend on it to also		\
-	   be outdated so their rules to fire each time they are built.
+	@: FRC.scm-rev is always out of date, triggering the check every make invocation.
 $(DEPDIR)/deps-ver: $(top_srcdir)/deps-ver
 	@[ -f $@ ] ||							\
 		cp $(top_srcdir)/deps-ver $@
diff --git a/contrib/ntp/ntpd/cmd_args.c b/contrib/ntp/ntpd/cmd_args.c
index aa461cb4dbe6..a604feb00b54 100644
--- a/contrib/ntp/ntpd/cmd_args.c
+++ b/contrib/ntp/ntpd/cmd_args.c
@@ -178,16 +178,14 @@ getCmdOpts(
 
 	if (HAVE_OPT( UPDATEINTERVAL )) {
 		long val = OPT_VALUE_UPDATEINTERVAL;
-
-		if (val >= 0)
-			interface_interval = val;
-		else {
-			fprintf(stderr,
-				"command line interface update interval %ld must not be negative\n",
-				val);
-			msyslog(LOG_ERR,
-				"command line interface update interval %ld must not be negative",
-				val);
+		const char errfmt[] =
+			"-U/--updateinterval %ld must be >= 0\n";
+
+		if (val >= 0) {
+			endpt_scan_period = val;
+		} else {
+			fprintf(stderr, errfmt, val);
+			msyslog(LOG_ERR, errfmt, val);
 			errflg++;
 		}
 	}
diff --git a/contrib/ntp/ntpd/complete.conf.in b/contrib/ntp/ntpd/complete.conf.in
index 77b619773fbf..adda4e4fa921 100644
--- a/contrib/ntp/ntpd/complete.conf.in
+++ b/contrib/ntp/ntpd/complete.conf.in
@@ -33,40 +33,45 @@ tinker allan 1500 dispersion 15 freq 0 huffpuff 7200 panic 1000 step 0.128 stepo
 broadcastclient
 server 127.127.1.0 mode 4294967295 prefer true
 fudge 127.127.1.0 time1 0 time2 1.1 stratum 7 refid Abcd minjitter 0.2
-pool 0.north-america.pool.ntp.org. iburst preempt
-server 1.north-america.pool.ntp.org. iburst
-server -4 2.north-america.pool.ntp.org. minpoll 6 maxpoll 10 iburst
-server -6 ntp.davehart.net. minpoll 6 maxpoll 10 version 5 burst iburst
-peer -6 davehart.broker.freenet6.net. ident "autokey-group" xleave autokey
-peer -4 192.168.192.168 key 1 noselect
+pool 2.ubuntu.pool.ntp.org. iburst preempt
+pool 2.freebsd.pool.ntp.org. iburst
+server -6 2.debian.pool.ntp.org. minpoll 6 maxpoll 10 iburst
+server -4 ntp.davehart.net. minpoll 6 maxpoll 10 version 5 burst iburst
+peer -6 ntp.md. ident "autokey-group" xleave autokey
+peer -4 198.51.100.123 key 1 noselect
 server [fe80::123%1] xmtnonce
-broadcast 192.168.192.255
-manycastclient 224.0.1.1
-manycastclient ff05::101
+broadcast 192.0.2.255
+manycastclient 224.0.1.1 key 14 iburst
+manycastclient ff05::101 maxpoll 6 key 1
 manycastserver 224.0.1.1 ff05::101
 multicastclient 224.0.1.1 ff05::101
 mru maxage 64 mindepth 600 initalloc 600 initmem 16 incalloc 99 incmem 4 maxdepth 1024 maxmem 4096
 discard minimum 1 average 3 monitor 3000
 pollskewlist 3 1|2 4 3|4 default 6|7
-restrict default ippeerlimit -1
-restrict default ippeerlimit 0 nomodify limited kod noserve nomrulist
+restrict default
+restrict default ippeerlimit 0 nomodify limited kod nopeer noserve nomrulist
 restrict source ippeerlimit 1
 restrict source ippeerlimit 2 nomodify limited kod
-restrict trusted.host.name.example.com. ippeerlimit -1 nomodify
-restrict [fe80::1] mask [ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff] ippeerlimit -1
-restrict 127.0.0.1 mask 255.255.255.255 ippeerlimit -1
-restrict 127.0.0.2 ippeerlimit -1 serverresponse fuzz
-restrict ::1 ippeerlimit -1
+restrict trusted.host.name.example.com. nomodify
+delrestrict trusted.host.name.example.com.
+restrict 192.0.2.66 epeer flake lowpriotrap mssntp noepeer noquery notrap notrust ntpport version
+delrestrict source 192.0.2.123
+delrestrict source [2001:db8::123]
+restrict fe80::1
+restrict 127.0.0.1
+restrict ::1
+restrict 198.51.100.123 serverresponse fuzz
+restrict fec0:: mask [ffff::] ignore
 interface drop ipv6
 interface ignore ipv4
 interface drop wildcard
 interface listen eth0
 interface listen ipv6
-interface listen 192.168.192.0/24
-interface listen 192.168.193.1
+interface listen 203.0.113.0/24
+interface listen 192.0.2.123
 phone "ATDT13034944774" "ATDT12027621594"
 setvar varnondef = "this variable does not have default after the value"
 setvar vanity = "name plate" default
 trap 127.0.0.1 interface 127.0.0.1 port 1234
-trap 127.0.0.2
+trap 192.0.2.2
 reset allpeers auth ctl io mem sys timer
diff --git a/contrib/ntp/ntpd/invoke-ntp.conf.texi b/contrib/ntp/ntpd/invoke-ntp.conf.texi
index 86a039ea6f49..1f232a313f57 100644
--- a/contrib/ntp/ntpd/invoke-ntp.conf.texi
+++ b/contrib/ntp/ntpd/invoke-ntp.conf.texi
@@ -6,7 +6,7 @@
 #
 # EDIT THIS FILE WITH CAUTION  (invoke-ntp.conf.texi)
 #
-# It has been AutoGen-ed  June  6, 2023 at 04:37:38 AM by AutoGen 5.18.16
+# It has been AutoGen-ed  May 25, 2024 at 12:03:56 AM by AutoGen 5.18.16
 # From the definitions    ntp.conf.def
 # and the template file   agtexi-file.tpl
 @end ignore
@@ -251,27 +251,15 @@ include authentication fields encrypted using the autokey scheme
 described in
 @ref{Authentication Options}.
 @item @code{burst}
-when the server is reachable, send a burst of eight packets
-instead of the usual one.
-The packet spacing is normally 2 s;
-however, the spacing between the first and second packets
-can be changed with the
-@code{calldelay}
-command to allow
-additional time for a modem or ISDN call to complete.
-This is designed to improve timekeeping quality
-with the
+when the server is reachable, send a burst of six packets
+instead of the usual one. The packet spacing is 2 s.
+This is designed to improve timekeeping quality with the
 @code{server}
 command and s addresses.
 @item @code{iburst}
 When the server is unreachable, send a burst of eight packets
 instead of the usual one.
-The packet spacing is normally 2 s;
-however, the spacing between the first two packets can be
-changed with the
-@code{calldelay}
-command to allow
-additional time for a modem or ISDN call to complete.
+The packet spacing is 2 s.
 This is designed to speed the initial synchronization
 acquisition with the
 @code{server}
@@ -833,7 +821,7 @@ The
 argument is
 the key identifier for a trusted key, where the value can be in the
 range 1 to 65,535, inclusive.
-@item @code{crypto} @code{[@code{cert} @kbd{file}]} @code{[@code{leap} @kbd{file}]} @code{[@code{randfile} @kbd{file}]} @code{[@code{host} @kbd{file}]} @code{[@code{sign} @kbd{file}]} @code{[@code{gq} @kbd{file}]} @code{[@code{gqpar} @kbd{file}]} @code{[@code{iffpar} @kbd{file}]} @code{[@code{mvpar} @kbd{file}]} @code{[@code{pw} @kbd{password}]}
+@item @code{crypto} @code{[@code{cert} @kbd{file}]} @code{[@code{leap} @kbd{file}]} @code{[@code{randfile} @kbd{file}]} @code{[@code{host} @kbd{file}]} @code{[@code{gq} @kbd{file}]} @code{[@code{gqpar} @kbd{file}]} @code{[@code{iffpar} @kbd{file}]} @code{[@code{mvpar} @kbd{file}]} @code{[@code{pw} @kbd{password}]}
 This command requires the OpenSSL library.
 It activates public key
 cryptography, selects the message digest and signature
@@ -890,14 +878,6 @@ encrypted.
 Specifies the location of the random seed file used by the OpenSSL
 library.
 The defaults are described in the main text above.
-@item @code{sign} @kbd{file}
-Specifies the location of the optional sign key file.
-This overrides
-the link
-@file{ntpkey_sign_}@kbd{hostname}
-in the keys directory.
-If this file is
-not found, the host key is also the sign key.
 @end table
 @item @code{keys} @kbd{keyfile}
 Specifies the complete path and location of the MD5 key file
@@ -1477,25 +1457,26 @@ by default the probability of replacing it with an
 entry representing the client request being processed
 now is 10%. Conversely, if the oldest entry is more
 than 3000 seconds old, the probability is 100%.
-@item @code{restrict} @code{address} @code{[@code{mask} @kbd{mask}]} @code{[@code{ippeerlimit} @kbd{int}]} @code{[@kbd{flag} @kbd{...}]}
+@item @code{restrict} @kbd{address} @code{[@code{mask} @kbd{mask}]} @code{[@code{ippeerlimit} @kbd{int}]} @code{[@kbd{flag} @kbd{...}]}
 The
 @kbd{address}
 argument expressed in
-dotted-quad form is the address of a host or network.
+numeric form is the address of a host or network.
 Alternatively, the
 @kbd{address}
-argument can be a valid host DNS name.
+argument can be a valid hostname.  When a hostname
+is provided, a restriction entry is created for each
+address the hostname resolves to, and any provided
+@kbd{mask}
+is ignored and an individual host mask is
+used for each entry.
 The
 @kbd{mask}
-argument expressed in dotted-quad form defaults to
-@code{255.255.255.255},
-meaning that the
+argument expressed in numeric form defaults to
+all bits lit, meaning that the
 @kbd{address}
 is treated as the address of an individual host.
-A default entry (address
-@code{0.0.0.0},
-mask
-@code{0.0.0.0})
+A default entry with address and mask all zeroes
 is always included and is always the first entry in the list.
 Note that text string
 @code{default},
@@ -1532,12 +1513,12 @@ and
 @code{ntpdc(1ntpdcmdoc)}
 queries.
 @item @code{kod}
-If this flag is set when an access violation occurs, a kiss-o'-death
-(KoD) packet is sent.
-KoD packets are rate limited to no more than one
-per second.
-If another KoD packet occurs within one second after the
-last one, the packet is dropped.
+If this flag is set when a rate violation occurs, a kiss-o'-death
+(KoD) packet is sometimes sent.
+KoD packets are rate limited to no more than one per minimum
+average interpacket spacing, set by
+@code{discard} @code{average}
+defaulting to 8s.  Otherwise, no response is sent.
 @item @code{limited}
 Deny service if the packet spacing violates the lower limits specified
 in the
@@ -1627,15 +1608,13 @@ restriction flag.
 Its presence causes the restriction entry to be
 matched only if the source port in the packet is the standard NTP
 UDP port (123).
-Both
+There can be two restriction entries with the same IP address if
+one specifies
 @code{ntpport}
-and
-@code{non-ntpport}
-may
-be specified.
+and the other does not.
 The
 @code{ntpport}
-is considered more specific and
+entry is considered more specific and
 is sorted later in the list.
 @item @code{serverresponse fuzz}
 When reponding to server requests,
@@ -1647,12 +1626,28 @@ Deny packets that do not match the current NTP version.
 
 Default restriction list entries with the flags ignore, interface,
 ntpport, for each of the local host's interface addresses are
-inserted into the table at startup to prevent the server
-from attempting to synchronize to its own time.
+inserted into the table at startup to prevent ntpd
+from attempting to synchronize to itself, such as with
+@code{manycastclient}
+when
+@code{manycast}
+is also specified with the same multicast address.
 A default entry is also always present, though if it is
 otherwise unconfigured; no flags are associated
 with the default entry (i.e., everything besides your own
 NTP server is unrestricted).
+@item @code{delrestrict} @code{[source]} @kbd{address}
+Remove a previously-set restriction.  This is useful for
+runtime configuration via
+@code{ntpq(1ntpqmdoc)}
+.  If
+@code{source}
+is specified, a dynamic restriction created from the 
+@code{restrict} @code{source}
+template at the time
+an association was added is removed.  Without
+@code{source}
+a static restriction is removed.
 @end table
 @node Automatic NTP Configuration Options
 @subsection Automatic NTP Configuration Options
@@ -2357,10 +2352,6 @@ Typically (for Ethernet), a
 number between 0.003 and 0.007 seconds is appropriate.
 The default
 when this command is not used is 0.004 seconds.
-@item @code{calldelay} @kbd{delay}
-This option controls the delay in seconds between the first and second
-packets sent in burst or iburst mode to allow additional time for a modem
-or ISDN call to complete.
 @item @code{driftfile} @kbd{driftfile}
 This command specifies the complete path and name of the file used to
 record the frequency of the local clock oscillator.
diff --git a/contrib/ntp/ntpd/invoke-ntp.keys.texi b/contrib/ntp/ntpd/invoke-ntp.keys.texi
index 3926518de3a2..189829f8516d 100644
--- a/contrib/ntp/ntpd/invoke-ntp.keys.texi
+++ b/contrib/ntp/ntpd/invoke-ntp.keys.texi
@@ -6,7 +6,7 @@
 #
 # EDIT THIS FILE WITH CAUTION  (invoke-ntp.keys.texi)
 #
-# It has been AutoGen-ed  June  6, 2023 at 04:37:41 AM by AutoGen 5.18.16
+# It has been AutoGen-ed  May 25, 2024 at 12:03:59 AM by AutoGen 5.18.16
 # From the definitions    ntp.keys.def
 # and the template file   agtexi-file.tpl
 @end ignore
diff --git a/contrib/ntp/ntpd/invoke-ntpd.texi b/contrib/ntp/ntpd/invoke-ntpd.texi
index 471bca5b86c8..ae05d92be524 100644
--- a/contrib/ntp/ntpd/invoke-ntpd.texi
+++ b/contrib/ntp/ntpd/invoke-ntpd.texi
@@ -6,7 +6,7 @@
 #
 # EDIT THIS FILE WITH CAUTION  (invoke-ntpd.texi)
 #
-# It has been AutoGen-ed  June  6, 2023 at 04:37:42 AM by AutoGen 5.18.16
+# It has been AutoGen-ed  May 25, 2024 at 12:04:00 AM by AutoGen 5.18.16
 # From the definitions    ntpd-opts.def
 # and the template file   agtexi-cmd.tpl
 @end ignore
@@ -142,7 +142,7 @@ with a status code of 0.
 
 @exampleindent 0
 @example
-ntpd - NTP daemon program - Ver. 4.2.8p17
+ntpd - NTP daemon program - Ver. 4.2.8p18
 Usage:  ntpd [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... \
                 [ <server1> ... <serverN> ]
   Flg Arg Option-Name    Description
diff --git a/contrib/ntp/ntpd/keyword-gen-utd b/contrib/ntp/ntpd/keyword-gen-utd
index 0eb94005b839..60bc132ce064 100644
--- a/contrib/ntp/ntpd/keyword-gen-utd
+++ b/contrib/ntp/ntpd/keyword-gen-utd
@@ -1 +1 @@
- *	 Generated 2022-03-27 14:17:11 UTC	  diff_ignore_line
+ *	 Generated 2023-09-25 05:34:02 UTC	  diff_ignore_line
diff --git a/contrib/ntp/ntpd/keyword-gen.c b/contrib/ntp/ntpd/keyword-gen.c
index 104d95e8b3e1..014227a2ba08 100644
--- a/contrib/ntp/ntpd/keyword-gen.c
+++ b/contrib/ntp/ntpd/keyword-gen.c
@@ -23,7 +23,6 @@
 
 #include <ntp_stdlib.h>
 #include <ntp_config.h>
-#include <lib_strbuf.h>
 #include "ntp_scanner.h"
 #include "ntp_parser.h"
 
@@ -45,6 +44,7 @@ struct key_tok ntp_keywords[] = {
 { "broadcastdelay",	T_Broadcastdelay,	FOLLBY_TOKEN },
 { "checkhash",		T_Checkhash,		FOLLBY_TOKEN },
 { "ctl",		T_Ctl,			FOLLBY_TOKEN },
+{ "delrestrict",	T_Delrestrict,		FOLLBY_TOKEN },
 { "device",		T_Device,		FOLLBY_STRING },
 { "disable",		T_Disable,		FOLLBY_TOKEN },
 { "driftfile",		T_Driftfile,		FOLLBY_STRING },
diff --git a/contrib/ntp/ntpd/ntp.conf.5man b/contrib/ntp/ntpd/ntp.conf.5man
index 4e7a47ab83ef..d5a82190c0b0 100644
--- a/contrib/ntp/ntpd/ntp.conf.5man
+++ b/contrib/ntp/ntpd/ntp.conf.5man
@@ -10,11 +10,11 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH ntp.conf 5man "06 Jun 2023" "4.2.8p17" "File Formats"
+.TH ntp.conf 5man "25 May 2024" "4.2.8p18" "File Formats"
 .\"
 .\" EDIT THIS FILE WITH CAUTION (in-mem file)
 .\"
-.\" It has been AutoGen-ed June 6, 2023 at 04:37:45 AM by AutoGen 5.18.16
+.\" It has been AutoGen-ed May 25, 2024 at 12:04:03 AM by AutoGen 5.18.16
 .\" From the definitions ntp.conf.def
 .\" and the template file agman-cmd.tpl
 .SH NAME
@@ -291,28 +291,16 @@ described in
 \fIAuthentication\f[] \fIOptions\f[].
 .TP 7
 .NOP \f\*[B-Font]burst\f[]
-when the server is reachable, send a burst of eight packets
-instead of the usual one.
-The packet spacing is normally 2 s;
-however, the spacing between the first and second packets
-can be changed with the
-\f\*[B-Font]calldelay\f[]
-command to allow
-additional time for a modem or ISDN call to complete.
-This is designed to improve timekeeping quality
-with the
+when the server is reachable, send a burst of six packets
+instead of the usual one. The packet spacing is 2 s.
+This is designed to improve timekeeping quality with the
 \f\*[B-Font]server\f[]
 command and s addresses.
 .TP 7
 .NOP \f\*[B-Font]iburst\f[]
 When the server is unreachable, send a burst of eight packets
 instead of the usual one.
-The packet spacing is normally 2 s;
-however, the spacing between the first two packets can be
-changed with the
-\f\*[B-Font]calldelay\f[]
-command to allow
-additional time for a modem or ISDN call to complete.
+The packet spacing is 2 s.
 This is designed to speed the initial synchronization
 acquisition with the
 \f\*[B-Font]server\f[]
@@ -938,7 +926,7 @@ argument is
 the key identifier for a trusted key, where the value can be in the
 range 1 to 65,535, inclusive.
 .TP 7
-.NOP \f\*[B-Font]crypto\f[] [\f\*[B-Font]cert\f[] \f\*[I-Font]file\f[]] [\f\*[B-Font]leap\f[] \f\*[I-Font]file\f[]] [\f\*[B-Font]randfile\f[] \f\*[I-Font]file\f[]] [\f\*[B-Font]host\f[] \f\*[I-Font]file\f[]] [\f\*[B-Font]sign\f[] \f\*[I-Font]file\f[]] [\f\*[B-Font]gq\f[] \f\*[I-Font]file\f[]] [\f\*[B-Font]gqpar\f[] \f\*[I-Font]file\f[]] [\f\*[B-Font]iffpar\f[] \f\*[I-Font]file\f[]] [\f\*[B-Font]mvpar\f[] \f\*[I-Font]file\f[]] [\f\*[B-Font]pw\f[] \f\*[I-Font]password\f[]]
+.NOP \f\*[B-Font]crypto\f[] [\f\*[B-Font]cert\f[] \f\*[I-Font]file\f[]] [\f\*[B-Font]leap\f[] \f\*[I-Font]file\f[]] [\f\*[B-Font]randfile\f[] \f\*[I-Font]file\f[]] [\f\*[B-Font]host\f[] \f\*[I-Font]file\f[]] [\f\*[B-Font]gq\f[] \f\*[I-Font]file\f[]] [\f\*[B-Font]gqpar\f[] \f\*[I-Font]file\f[]] [\f\*[B-Font]iffpar\f[] \f\*[I-Font]file\f[]] [\f\*[B-Font]mvpar\f[] \f\*[I-Font]file\f[]] [\f\*[B-Font]pw\f[] \f\*[I-Font]password\f[]]
 This command requires the OpenSSL library.
 It activates public key
 cryptography, selects the message digest and signature
@@ -1003,15 +991,6 @@ encrypted.
 Specifies the location of the random seed file used by the OpenSSL
 library.
 The defaults are described in the main text above.
-.TP 7
-.NOP \f\*[B-Font]sign\f[] \f\*[I-Font]file\f[]
-Specifies the location of the optional sign key file.
-This overrides
-the link
-\fIntpkey_sign_\f[]\f\*[I-Font]hostname\f[]
-in the keys directory.
-If this file is
-not found, the host key is also the sign key.
 .RE
 .TP 7
 .NOP \f\*[B-Font]keys\f[] \f\*[I-Font]keyfile\f[]
@@ -1679,25 +1658,26 @@ entry representing the client request being processed
 now is 10%. Conversely, if the oldest entry is more
 than 3000 seconds old, the probability is 100%.
 .TP 7
-.NOP \f\*[B-Font]restrict\f[] \f\*[B-Font]address\f[] [\f\*[B-Font]mask\f[] \f\*[I-Font]mask\f[]] [\f\*[B-Font]ippeerlimit\f[] \f\*[I-Font]int\f[]] [\f\*[I-Font]flag\f[] \f\*[I-Font]...\f[]]
+.NOP \f\*[B-Font]restrict\f[] \f\*[I-Font]address\f[] [\f\*[B-Font]mask\f[] \f\*[I-Font]mask\f[]] [\f\*[B-Font]ippeerlimit\f[] \f\*[I-Font]int\f[]] [\f\*[I-Font]flag\f[] \f\*[I-Font]...\f[]]
 The
 \f\*[I-Font]address\f[]
 argument expressed in
-dotted-quad form is the address of a host or network.
+numeric form is the address of a host or network.
 Alternatively, the
 \f\*[I-Font]address\f[]
-argument can be a valid host DNS name.
+argument can be a valid hostname.  When a hostname
+is provided, a restriction entry is created for each
+address the hostname resolves to, and any provided
+\f\*[I-Font]mask\f[]
+is ignored and an individual host mask is
+used for each entry.
 The
 \f\*[I-Font]mask\f[]
-argument expressed in dotted-quad form defaults to
-\f\*[B-Font]255.255.255.255\f[],
-meaning that the
+argument expressed in numeric form defaults to
+all bits lit, meaning that the
 \f\*[I-Font]address\f[]
 is treated as the address of an individual host.
-A default entry (address
-\f\*[B-Font]0.0.0.0\f[],
-mask
-\f\*[B-Font]0.0.0.0\f[])
+A default entry with address and mask all zeroes
 is always included and is always the first entry in the list.
 Note that text string
 \f\*[B-Font]default\f[],
@@ -1736,12 +1716,12 @@ and
 queries.
 .TP 7
 .NOP \f\*[B-Font]kod\f[]
-If this flag is set when an access violation occurs, a kiss-o'-death
-(KoD) packet is sent.
-KoD packets are rate limited to no more than one
-per second.
-If another KoD packet occurs within one second after the
-last one, the packet is dropped.
+If this flag is set when a rate violation occurs, a kiss-o'-death
+(KoD) packet is sometimes sent.
+KoD packets are rate limited to no more than one per minimum
+average interpacket spacing, set by
+\f\*[B-Font]discard\f[] \f\*[B-Font]average\f[]
+defaulting to 8s.  Otherwise, no response is sent.
 .TP 7
 .NOP \f\*[B-Font]limited\f[]
 Deny service if the packet spacing violates the lower limits specified
@@ -1841,15 +1821,13 @@ restriction flag.
 Its presence causes the restriction entry to be
 matched only if the source port in the packet is the standard NTP
 UDP port (123).
-Both
+There can be two restriction entries with the same IP address if
+one specifies
 \f\*[B-Font]ntpport\f[]
-and
-\f\*[B-Font]non-ntpport\f[]
-may
-be specified.
+and the other does not.
 The
 \f\*[B-Font]ntpport\f[]
-is considered more specific and
+entry is considered more specific and
 is sorted later in the list.
 .TP 7
 .NOP \f\*[B-Font]serverresponse fuzz\f[]
@@ -1865,12 +1843,29 @@ Deny packets that do not match the current NTP version.
 
 Default restriction list entries with the flags ignore, interface,
 ntpport, for each of the local host's interface addresses are
-inserted into the table at startup to prevent the server
-from attempting to synchronize to its own time.
+inserted into the table at startup to prevent ntpd
+from attempting to synchronize to itself, such as with
+\f\*[B-Font]manycastclient\f[]
+when
+\f\*[B-Font]manycast\f[]
+is also specified with the same multicast address.
 A default entry is also always present, though if it is
 otherwise unconfigured; no flags are associated
 with the default entry (i.e., everything besides your own
 NTP server is unrestricted).
+.TP 7
+.NOP \f\*[B-Font]delrestrict\f[] [source] \f\*[I-Font]address\f[]
+Remove a previously-set restriction.  This is useful for
+runtime configuration via
+\fCntpq\f[]\fR(1ntpqmdoc)\f[]
+.  If
+\f\*[B-Font]source\f[]
+is specified, a dynamic restriction created from the 
+\f\*[B-Font]restrict\f[] \f\*[B-Font]source\f[]
+template at the time
+an association was added is removed.  Without
+\f\*[B-Font]source\f[]
+a static restriction is removed.
 .PP
 .SH Automatic NTP Configuration Options
 .SS Manycasting
@@ -2635,11 +2630,6 @@ number between 0.003 and 0.007 seconds is appropriate.
 The default
 when this command is not used is 0.004 seconds.
 .TP 7
-.NOP \f\*[B-Font]calldelay\f[] \f\*[I-Font]delay\f[]
-This option controls the delay in seconds between the first and second
-packets sent in burst or iburst mode to allow additional time for a modem
-or ISDN call to complete.
-.TP 7
 .NOP \f\*[B-Font]driftfile\f[] \f\*[I-Font]driftfile\f[]
 This command specifies the complete path and name of the file used to
 record the frequency of the local clock oscillator.
@@ -3461,7 +3451,7 @@ RFC5905
 .SH "AUTHORS"
 The University of Delaware and Network Time Foundation
 .SH "COPYRIGHT"
-Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation all rights reserved.
 This program is released under the terms of the NTP license, <http://ntp.org/license>.
 .SH BUGS
 The syntax checking is not picky; some combinations of
diff --git a/contrib/ntp/ntpd/ntp.conf.5mdoc b/contrib/ntp/ntpd/ntp.conf.5mdoc
index 951f33da4faa..b950e92cdeb9 100644
--- a/contrib/ntp/ntpd/ntp.conf.5mdoc
+++ b/contrib/ntp/ntpd/ntp.conf.5mdoc
@@ -1,9 +1,9 @@
-.Dd June 6 2023
+.Dd May 25 2024
 .Dt NTP_CONF 5mdoc File Formats
 .Os
 .\"  EDIT THIS FILE WITH CAUTION  (ntp.mdoc)
 .\"
-.\"  It has been AutoGen-ed  June  6, 2023 at 04:37:32 AM by AutoGen 5.18.16
+.\"  It has been AutoGen-ed  May 25, 2024 at 12:03:50 AM by AutoGen 5.18.16
 .\"  From the definitions    ntp.conf.def
 .\"  and the template file   agmdoc-cmd.tpl
 .Sh NAME
@@ -294,27 +294,15 @@ include authentication fields encrypted using the autokey scheme
 described in
 .Sx Authentication Options .
 .It Cm burst
-when the server is reachable, send a burst of eight packets
-instead of the usual one.
-The packet spacing is normally 2 s;
-however, the spacing between the first and second packets
-can be changed with the
-.Ic calldelay
-command to allow
-additional time for a modem or ISDN call to complete.
-This is designed to improve timekeeping quality
-with the
+when the server is reachable, send a burst of six packets
+instead of the usual one. The packet spacing is 2 s.
+This is designed to improve timekeeping quality with the
 .Ic server
 command and s addresses.
 .It Cm iburst
 When the server is unreachable, send a burst of eight packets
 instead of the usual one.
-The packet spacing is normally 2 s;
-however, the spacing between the first two packets can be
-changed with the
-.Ic calldelay
-command to allow
-additional time for a modem or ISDN call to complete.
+The packet spacing is 2 s.
 This is designed to speed the initial synchronization
 acquisition with the
 .Ic server
@@ -889,7 +877,6 @@ range 1 to 65,535, inclusive.
 .Op Cm leap Ar file
 .Op Cm randfile Ar file
 .Op Cm host Ar file
-.Op Cm sign Ar file
 .Op Cm gq Ar file
 .Op Cm gqpar Ar file
 .Op Cm iffpar Ar file
@@ -952,14 +939,6 @@ encrypted.
 Specifies the location of the random seed file used by the OpenSSL
 library.
 The defaults are described in the main text above.
-.It Cm sign Ar file
-Specifies the location of the optional sign key file.
-This overrides
-the link
-.Pa ntpkey_sign_ Ns Ar hostname
-in the keys directory.
-If this file is
-not found, the host key is also the sign key.
 .El
 .It Ic keys Ar keyfile
 Specifies the complete path and location of the MD5 key file
@@ -1546,7 +1525,8 @@ by default the probability of replacing it with an
 entry representing the client request being processed
 now is 10%. Conversely, if the oldest entry is more
 than 3000 seconds old, the probability is 100%.
-.It Xo Ic restrict address
+.It Xo Ic restrict
+.Ar address
 .Op Cm mask Ar mask
 .Op Cm ippeerlimit Ar int
 .Op Ar flag ...
@@ -1554,21 +1534,22 @@ than 3000 seconds old, the probability is 100%.
 The
 .Ar address
 argument expressed in
-dotted\-quad form is the address of a host or network.
+numeric form is the address of a host or network.
 Alternatively, the
 .Ar address
-argument can be a valid host DNS name.
+argument can be a valid hostname.  When a hostname
+is provided, a restriction entry is created for each
+address the hostname resolves to, and any provided
+.Ar mask
+is ignored and an individual host mask is
+used for each entry.
 The
 .Ar mask
-argument expressed in dotted\-quad form defaults to
-.Cm 255.255.255.255 ,
-meaning that the
+argument expressed in numeric form defaults to
+all bits lit, meaning that the
 .Ar address
 is treated as the address of an individual host.
-A default entry (address
-.Cm 0.0.0.0 ,
-mask
-.Cm 0.0.0.0 )
+A default entry with address and mask all zeroes
 is always included and is always the first entry in the list.
 Note that text string
 .Cm default ,
@@ -1605,12 +1586,12 @@ and
 .Xr ntpdc 1ntpdcmdoc
 queries.
 .It Cm kod
-If this flag is set when an access violation occurs, a kiss\-o'\-death
-(KoD) packet is sent.
-KoD packets are rate limited to no more than one
-per second.
-If another KoD packet occurs within one second after the
-last one, the packet is dropped.
+If this flag is set when a rate violation occurs, a kiss\-o'\-death
+(KoD) packet is sometimes sent.
+KoD packets are rate limited to no more than one per minimum
+average interpacket spacing, set by
+.Cm discard average
+defaulting to 8s.  Otherwise, no response is sent.
 .It Cm limited
 Deny service if the packet spacing violates the lower limits specified
 in the
@@ -1700,15 +1681,13 @@ restriction flag.
 Its presence causes the restriction entry to be
 matched only if the source port in the packet is the standard NTP
 UDP port (123).
-Both
+There can be two restriction entries with the same IP address if
+one specifies
 .Cm ntpport
-and
-.Cm non\-ntpport
-may
-be specified.
+and the other does not.
 The
 .Cm ntpport
-is considered more specific and
+entry is considered more specific and
 is sorted later in the list.
 .It Ic "serverresponse fuzz"
 When reponding to server requests,
@@ -1720,12 +1699,31 @@ Deny packets that do not match the current NTP version.
 .Pp
 Default restriction list entries with the flags ignore, interface,
 ntpport, for each of the local host's interface addresses are
-inserted into the table at startup to prevent the server
-from attempting to synchronize to its own time.
+inserted into the table at startup to prevent ntpd
+from attempting to synchronize to itself, such as with
+.Cm manycastclient
+when
+.Cm manycast
+is also specified with the same multicast address.
 A default entry is also always present, though if it is
 otherwise unconfigured; no flags are associated
 with the default entry (i.e., everything besides your own
 NTP server is unrestricted).
+.It Xo Ic delrestrict
+.Op source
+.Ar address
+.Xc
+Remove a previously\-set restriction.  This is useful for
+runtime configuration via
+.Xr ntpq 1ntpqmdoc
+.  If
+.Cm source
+is specified, a dynamic restriction created from the 
+.Cm restrict source
+template at the time
+an association was added is removed.  Without
+.Cm source
+a static restriction is removed.
 .El
 .Sh Automatic NTP Configuration Options
 .Ss Manycasting
@@ -2462,10 +2460,6 @@ Typically (for Ethernet), a
 number between 0.003 and 0.007 seconds is appropriate.
 The default
 when this command is not used is 0.004 seconds.
-.It Ic calldelay Ar delay
-This option controls the delay in seconds between the first and second
-packets sent in burst or iburst mode to allow additional time for a modem
-or ISDN call to complete.
 .It Ic driftfile Ar driftfile
 This command specifies the complete path and name of the file used to
 record the frequency of the local clock oscillator.
@@ -3302,7 +3296,7 @@ A snapshot of this documentation is available in HTML format in
 .Sh "AUTHORS"
 The University of Delaware and Network Time Foundation
 .Sh "COPYRIGHT"
-Copyright (C) 1992\-2023 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992\-2024 The University of Delaware and Network Time Foundation all rights reserved.
 This program is released under the terms of the NTP license, <http://ntp.org/license>.
 .Sh BUGS
 The syntax checking is not picky; some combinations of
diff --git a/contrib/ntp/ntpd/ntp.conf.def b/contrib/ntp/ntpd/ntp.conf.def
index 03dd8b808099..444e3b35e351 100644
--- a/contrib/ntp/ntpd/ntp.conf.def
+++ b/contrib/ntp/ntpd/ntp.conf.def
@@ -296,27 +296,15 @@ include authentication fields encrypted using the autokey scheme
 described in
 .Sx Authentication Options .
 .It Cm burst
-when the server is reachable, send a burst of eight packets
-instead of the usual one.
-The packet spacing is normally 2 s;
-however, the spacing between the first and second packets
-can be changed with the
-.Ic calldelay
-command to allow
-additional time for a modem or ISDN call to complete.
-This is designed to improve timekeeping quality
-with the
+when the server is reachable, send a burst of six packets
+instead of the usual one. The packet spacing is 2 s.
+This is designed to improve timekeeping quality with the
 .Ic server
 command and s addresses.
 .It Cm iburst
 When the server is unreachable, send a burst of eight packets
 instead of the usual one.
-The packet spacing is normally 2 s;
-however, the spacing between the first two packets can be
-changed with the
-.Ic calldelay
-command to allow
-additional time for a modem or ISDN call to complete.
+The packet spacing is 2 s.
 This is designed to speed the initial synchronization
 acquisition with the
 .Ic server
@@ -892,7 +880,6 @@ range 1 to 65,535, inclusive.
 .Op Cm leap Ar file
 .Op Cm randfile Ar file
 .Op Cm host Ar file
-.Op Cm sign Ar file
 .Op Cm gq Ar file
 .Op Cm gqpar Ar file
 .Op Cm iffpar Ar file
@@ -955,14 +942,6 @@ encrypted.
 Specifies the location of the random seed file used by the OpenSSL
 library.
 The defaults are described in the main text above.
-.It Cm sign Ar file
-Specifies the location of the optional sign key file.
-This overrides
-the link
-.Pa ntpkey_sign_ Ns Ar hostname
-in the keys directory.
-If this file is
-not found, the host key is also the sign key.
 .El
 .It Ic keys Ar keyfile
 Specifies the complete path and location of the MD5 key file
@@ -1549,7 +1528,8 @@ by default the probability of replacing it with an
 entry representing the client request being processed
 now is 10%. Conversely, if the oldest entry is more
 than 3000 seconds old, the probability is 100%.
-.It Xo Ic restrict address
+.It Xo Ic restrict
+.Ar address
 .Op Cm mask Ar mask
 .Op Cm ippeerlimit Ar int
 .Op Ar flag ...
@@ -1557,21 +1537,22 @@ than 3000 seconds old, the probability is 100%.
 The
 .Ar address
 argument expressed in
-dotted-quad form is the address of a host or network.
+numeric form is the address of a host or network.
 Alternatively, the
 .Ar address
-argument can be a valid host DNS name.
+argument can be a valid hostname.  When a hostname
+is provided, a restriction entry is created for each
+address the hostname resolves to, and any provided
+.Ar mask
+is ignored and an individual host mask is
+used for each entry.
 The
 .Ar mask
-argument expressed in dotted-quad form defaults to
-.Cm 255.255.255.255 ,
-meaning that the
+argument expressed in numeric form defaults to
+all bits lit, meaning that the
 .Ar address
 is treated as the address of an individual host.
-A default entry (address
-.Cm 0.0.0.0 ,
-mask
-.Cm 0.0.0.0 )
+A default entry with address and mask all zeroes
 is always included and is always the first entry in the list.
 Note that text string
 .Cm default ,
@@ -1608,12 +1589,12 @@ and
 .Xr ntpdc 1ntpdcmdoc
 queries.
 .It Cm kod
-If this flag is set when an access violation occurs, a kiss-o'-death
-(KoD) packet is sent.
-KoD packets are rate limited to no more than one
-per second.
-If another KoD packet occurs within one second after the
-last one, the packet is dropped.
+If this flag is set when a rate violation occurs, a kiss-o'-death
+(KoD) packet is sometimes sent.
+KoD packets are rate limited to no more than one per minimum
+average interpacket spacing, set by
+.Cm discard average
+defaulting to 8s.  Otherwise, no response is sent.
 .It Cm limited
 Deny service if the packet spacing violates the lower limits specified
 in the
@@ -1703,15 +1684,13 @@ restriction flag.
 Its presence causes the restriction entry to be
 matched only if the source port in the packet is the standard NTP
 UDP port (123).
-Both
+There can be two restriction entries with the same IP address if
+one specifies
 .Cm ntpport
-and
-.Cm non-ntpport
-may
-be specified.
+and the other does not.
 The
 .Cm ntpport
-is considered more specific and
+entry is considered more specific and
 is sorted later in the list.
 .It Ic "serverresponse fuzz"
 When reponding to server requests,
@@ -1723,12 +1702,31 @@ Deny packets that do not match the current NTP version.
 .Pp
 Default restriction list entries with the flags ignore, interface,
 ntpport, for each of the local host's interface addresses are
-inserted into the table at startup to prevent the server
-from attempting to synchronize to its own time.
+inserted into the table at startup to prevent ntpd
+from attempting to synchronize to itself, such as with
+.Cm manycastclient
+when
+.Cm manycast
+is also specified with the same multicast address.
 A default entry is also always present, though if it is
 otherwise unconfigured; no flags are associated
 with the default entry (i.e., everything besides your own
 NTP server is unrestricted).
+.It Xo Ic delrestrict
+.Op source
+.Ar address
+.Xc
+Remove a previously-set restriction.  This is useful for
+runtime configuration via
+.Xr ntpq 1ntpqmdoc
+.  If
+.Cm source
+is specified, a dynamic restriction created from the 
+.Cm restrict source
+template at the time
+an association was added is removed.  Without
+.Cm source
+a static restriction is removed.
 .El
 .Sh Automatic NTP Configuration Options
 .Ss Manycasting
@@ -2465,10 +2463,6 @@ Typically (for Ethernet), a
 number between 0.003 and 0.007 seconds is appropriate.
 The default
 when this command is not used is 0.004 seconds.
-.It Ic calldelay Ar delay
-This option controls the delay in seconds between the first and second
-packets sent in burst or iburst mode to allow additional time for a modem
-or ISDN call to complete.
 .It Ic driftfile Ar driftfile
 This command specifies the complete path and name of the file used to
 record the frequency of the local clock oscillator.
diff --git a/contrib/ntp/ntpd/ntp.conf.html b/contrib/ntp/ntpd/ntp.conf.html
index f7f0b4bef931..ea82c6783a4b 100644
--- a/contrib/ntp/ntpd/ntp.conf.html
+++ b/contrib/ntp/ntpd/ntp.conf.html
@@ -50,7 +50,7 @@ Next: <a href="#ntp_002econf-Description" accesskey="n" rel="next">ntp.conf Desc
 <p>This document describes the configuration file for the NTP Project&rsquo;s
 <code>ntpd</code> program.
 </p>
-<p>This document applies to version 4.2.8p17 of <code>ntp.conf</code>.
+<p>This document applies to version 4.2.8p18 of <code>ntp.conf</code>.
 </p>
 <span id="SEC_Overview"></span>
 <h2 class="shortcontents-heading">Short Table of Contents</h2>
@@ -362,28 +362,16 @@ described in
 &lsquo;Authentication Options&rsquo;.
 </p></dd>
 <dt><code>burst</code></dt>
-<dd><p>when the server is reachable, send a burst of eight packets
-instead of the usual one.
-The packet spacing is normally 2 s;
-however, the spacing between the first and second packets
-can be changed with the
-<code>calldelay</code>
-command to allow
-additional time for a modem or ISDN call to complete.
-This is designed to improve timekeeping quality
-with the
+<dd><p>when the server is reachable, send a burst of six packets
+instead of the usual one. The packet spacing is 2 s.
+This is designed to improve timekeeping quality with the
 <code>server</code>
 command and s addresses.
 </p></dd>
 <dt><code>iburst</code></dt>
 <dd><p>When the server is unreachable, send a burst of eight packets
 instead of the usual one.
-The packet spacing is normally 2 s;
-however, the spacing between the first two packets can be
-changed with the
-<code>calldelay</code>
-command to allow
-additional time for a modem or ISDN call to complete.
+The packet spacing is 2 s.
 This is designed to speed the initial synchronization
 acquisition with the
 <code>server</code>
@@ -966,7 +954,7 @@ argument is
 the key identifier for a trusted key, where the value can be in the
 range 1 to 65,535, inclusive.
 </p></dd>
-<dt><code>crypto</code> <code>[<code>cert</code> <kbd>file</kbd>]</code> <code>[<code>leap</code> <kbd>file</kbd>]</code> <code>[<code>randfile</code> <kbd>file</kbd>]</code> <code>[<code>host</code> <kbd>file</kbd>]</code> <code>[<code>sign</code> <kbd>file</kbd>]</code> <code>[<code>gq</code> <kbd>file</kbd>]</code> <code>[<code>gqpar</code> <kbd>file</kbd>]</code> <code>[<code>iffpar</code> <kbd>file</kbd>]</code> <code>[<code>mvpar</code> <kbd>file</kbd>]</code> <code>[<code>pw</code> <kbd>password</kbd>]</code></dt>
+<dt><code>crypto</code> <code>[<code>cert</code> <kbd>file</kbd>]</code> <code>[<code>leap</code> <kbd>file</kbd>]</code> <code>[<code>randfile</code> <kbd>file</kbd>]</code> <code>[<code>host</code> <kbd>file</kbd>]</code> <code>[<code>gq</code> <kbd>file</kbd>]</code> <code>[<code>gqpar</code> <kbd>file</kbd>]</code> <code>[<code>iffpar</code> <kbd>file</kbd>]</code> <code>[<code>mvpar</code> <kbd>file</kbd>]</code> <code>[<code>pw</code> <kbd>password</kbd>]</code></dt>
 <dd><p>This command requires the OpenSSL library.
 It activates public key
 cryptography, selects the message digest and signature
@@ -1031,15 +1019,6 @@ encrypted.
 library.
 The defaults are described in the main text above.
 </p></dd>
-<dt><code>sign</code> <kbd>file</kbd></dt>
-<dd><p>Specifies the location of the optional sign key file.
-This overrides
-the link
-<samp>ntpkey_sign_</samp><kbd>hostname</kbd>
-in the keys directory.
-If this file is
-not found, the host key is also the sign key.
-</p></dd>
 </dl>
 </dd>
 <dt><code>keys</code> <kbd>keyfile</kbd></dt>
@@ -1670,25 +1649,26 @@ entry representing the client request being processed
 now is 10%. Conversely, if the oldest entry is more
 than 3000 seconds old, the probability is 100%.
 </p></dd>
-<dt><code>restrict</code> <code>address</code> <code>[<code>mask</code> <kbd>mask</kbd>]</code> <code>[<code>ippeerlimit</code> <kbd>int</kbd>]</code> <code>[<kbd>flag</kbd> <kbd>...</kbd>]</code></dt>
+<dt><code>restrict</code> <kbd>address</kbd> <code>[<code>mask</code> <kbd>mask</kbd>]</code> <code>[<code>ippeerlimit</code> <kbd>int</kbd>]</code> <code>[<kbd>flag</kbd> <kbd>...</kbd>]</code></dt>
 <dd><p>The
 <kbd>address</kbd>
 argument expressed in
-dotted-quad form is the address of a host or network.
+numeric form is the address of a host or network.
 Alternatively, the
 <kbd>address</kbd>
-argument can be a valid host DNS name.
+argument can be a valid hostname.  When a hostname
+is provided, a restriction entry is created for each
+address the hostname resolves to, and any provided
+<kbd>mask</kbd>
+is ignored and an individual host mask is
+used for each entry.
 The
 <kbd>mask</kbd>
-argument expressed in dotted-quad form defaults to
-<code>255.255.255.255</code>,
-meaning that the
+argument expressed in numeric form defaults to
+all bits lit, meaning that the
 <kbd>address</kbd>
 is treated as the address of an individual host.
-A default entry (address
-<code>0.0.0.0</code>,
-mask
-<code>0.0.0.0</code>)
+A default entry with address and mask all zeroes
 is always included and is always the first entry in the list.
 Note that text string
 <code>default</code>,
@@ -1726,12 +1706,12 @@ and
 queries.
 </p></dd>
 <dt><code>kod</code></dt>
-<dd><p>If this flag is set when an access violation occurs, a kiss-o&rsquo;-death
-(KoD) packet is sent.
-KoD packets are rate limited to no more than one
-per second.
-If another KoD packet occurs within one second after the
-last one, the packet is dropped.
+<dd><p>If this flag is set when a rate violation occurs, a kiss-o&rsquo;-death
+(KoD) packet is sometimes sent.
+KoD packets are rate limited to no more than one per minimum
+average interpacket spacing, set by
+<code>discard</code> <code>average</code>
+defaulting to 8s.  Otherwise, no response is sent.
 </p></dd>
 <dt><code>limited</code></dt>
 <dd><p>Deny service if the packet spacing violates the lower limits specified
@@ -1831,15 +1811,13 @@ restriction flag.
 Its presence causes the restriction entry to be
 matched only if the source port in the packet is the standard NTP
 UDP port (123).
-Both
+There can be two restriction entries with the same IP address if
+one specifies
 <code>ntpport</code>
-and
-<code>non-ntpport</code>
-may
-be specified.
+and the other does not.
 The
 <code>ntpport</code>
-is considered more specific and
+entry is considered more specific and
 is sorted later in the list.
 </p></dd>
 <dt><code>serverresponse fuzz</code></dt>
@@ -1854,13 +1832,30 @@ fuzz the low order bits of the
 
 <p>Default restriction list entries with the flags ignore, interface,
 ntpport, for each of the local host&rsquo;s interface addresses are
-inserted into the table at startup to prevent the server
-from attempting to synchronize to its own time.
+inserted into the table at startup to prevent ntpd
+from attempting to synchronize to itself, such as with
+<code>manycastclient</code>
+when
+<code>manycast</code>
+is also specified with the same multicast address.
 A default entry is also always present, though if it is
 otherwise unconfigured; no flags are associated
 with the default entry (i.e., everything besides your own
 NTP server is unrestricted).
 </p></dd>
+<dt><code>delrestrict</code> <code>[source]</code> <kbd>address</kbd></dt>
+<dd><p>Remove a previously-set restriction.  This is useful for
+runtime configuration via
+<code>ntpq(1ntpqmdoc)</code>
+.  If
+<code>source</code>
+is specified, a dynamic restriction created from the 
+<code>restrict</code> <code>source</code>
+template at the time
+an association was added is removed.  Without
+<code>source</code>
+a static restriction is removed.
+</p></dd>
 </dl>
 <hr>
 <span id="Automatic-NTP-Configuration-Options"></span><div class="header">
@@ -2597,11 +2592,6 @@ number between 0.003 and 0.007 seconds is appropriate.
 The default
 when this command is not used is 0.004 seconds.
 </p></dd>
-<dt><code>calldelay</code> <kbd>delay</kbd></dt>
-<dd><p>This option controls the delay in seconds between the first and second
-packets sent in burst or iburst mode to allow additional time for a modem
-or ISDN call to complete.
-</p></dd>
 <dt><code>driftfile</code> <kbd>driftfile</kbd></dt>
 <dd><p>This command specifies the complete path and name of the file used to
 record the frequency of the local clock oscillator.
diff --git a/contrib/ntp/ntpd/ntp.conf.man.in b/contrib/ntp/ntpd/ntp.conf.man.in
index 0c56ee503df6..175fcb8ab314 100644
--- a/contrib/ntp/ntpd/ntp.conf.man.in
+++ b/contrib/ntp/ntpd/ntp.conf.man.in
@@ -10,11 +10,11 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH ntp.conf 5 "06 Jun 2023" "4.2.8p17" "File Formats"
+.TH ntp.conf 5 "25 May 2024" "4.2.8p18" "File Formats"
 .\"
 .\" EDIT THIS FILE WITH CAUTION (in-mem file)
 .\"
-.\" It has been AutoGen-ed June 6, 2023 at 04:37:45 AM by AutoGen 5.18.16
+.\" It has been AutoGen-ed May 25, 2024 at 12:04:03 AM by AutoGen 5.18.16
 .\" From the definitions ntp.conf.def
 .\" and the template file agman-cmd.tpl
 .SH NAME
@@ -291,28 +291,16 @@ described in
 \fIAuthentication\f[] \fIOptions\f[].
 .TP 7
 .NOP \f\*[B-Font]burst\f[]
-when the server is reachable, send a burst of eight packets
-instead of the usual one.
-The packet spacing is normally 2 s;
-however, the spacing between the first and second packets
-can be changed with the
-\f\*[B-Font]calldelay\f[]
-command to allow
-additional time for a modem or ISDN call to complete.
-This is designed to improve timekeeping quality
-with the
+when the server is reachable, send a burst of six packets
+instead of the usual one. The packet spacing is 2 s.
+This is designed to improve timekeeping quality with the
 \f\*[B-Font]server\f[]
 command and s addresses.
 .TP 7
 .NOP \f\*[B-Font]iburst\f[]
 When the server is unreachable, send a burst of eight packets
 instead of the usual one.
-The packet spacing is normally 2 s;
-however, the spacing between the first two packets can be
-changed with the
-\f\*[B-Font]calldelay\f[]
-command to allow
-additional time for a modem or ISDN call to complete.
+The packet spacing is 2 s.
 This is designed to speed the initial synchronization
 acquisition with the
 \f\*[B-Font]server\f[]
@@ -938,7 +926,7 @@ argument is
 the key identifier for a trusted key, where the value can be in the
 range 1 to 65,535, inclusive.
 .TP 7
-.NOP \f\*[B-Font]crypto\f[] [\f\*[B-Font]cert\f[] \f\*[I-Font]file\f[]] [\f\*[B-Font]leap\f[] \f\*[I-Font]file\f[]] [\f\*[B-Font]randfile\f[] \f\*[I-Font]file\f[]] [\f\*[B-Font]host\f[] \f\*[I-Font]file\f[]] [\f\*[B-Font]sign\f[] \f\*[I-Font]file\f[]] [\f\*[B-Font]gq\f[] \f\*[I-Font]file\f[]] [\f\*[B-Font]gqpar\f[] \f\*[I-Font]file\f[]] [\f\*[B-Font]iffpar\f[] \f\*[I-Font]file\f[]] [\f\*[B-Font]mvpar\f[] \f\*[I-Font]file\f[]] [\f\*[B-Font]pw\f[] \f\*[I-Font]password\f[]]
+.NOP \f\*[B-Font]crypto\f[] [\f\*[B-Font]cert\f[] \f\*[I-Font]file\f[]] [\f\*[B-Font]leap\f[] \f\*[I-Font]file\f[]] [\f\*[B-Font]randfile\f[] \f\*[I-Font]file\f[]] [\f\*[B-Font]host\f[] \f\*[I-Font]file\f[]] [\f\*[B-Font]gq\f[] \f\*[I-Font]file\f[]] [\f\*[B-Font]gqpar\f[] \f\*[I-Font]file\f[]] [\f\*[B-Font]iffpar\f[] \f\*[I-Font]file\f[]] [\f\*[B-Font]mvpar\f[] \f\*[I-Font]file\f[]] [\f\*[B-Font]pw\f[] \f\*[I-Font]password\f[]]
 This command requires the OpenSSL library.
 It activates public key
 cryptography, selects the message digest and signature
@@ -1003,15 +991,6 @@ encrypted.
 Specifies the location of the random seed file used by the OpenSSL
 library.
 The defaults are described in the main text above.
-.TP 7
-.NOP \f\*[B-Font]sign\f[] \f\*[I-Font]file\f[]
-Specifies the location of the optional sign key file.
-This overrides
-the link
-\fIntpkey_sign_\f[]\f\*[I-Font]hostname\f[]
-in the keys directory.
-If this file is
-not found, the host key is also the sign key.
 .RE
 .TP 7
 .NOP \f\*[B-Font]keys\f[] \f\*[I-Font]keyfile\f[]
@@ -1679,25 +1658,26 @@ entry representing the client request being processed
 now is 10%. Conversely, if the oldest entry is more
 than 3000 seconds old, the probability is 100%.
 .TP 7
-.NOP \f\*[B-Font]restrict\f[] \f\*[B-Font]address\f[] [\f\*[B-Font]mask\f[] \f\*[I-Font]mask\f[]] [\f\*[B-Font]ippeerlimit\f[] \f\*[I-Font]int\f[]] [\f\*[I-Font]flag\f[] \f\*[I-Font]...\f[]]
+.NOP \f\*[B-Font]restrict\f[] \f\*[I-Font]address\f[] [\f\*[B-Font]mask\f[] \f\*[I-Font]mask\f[]] [\f\*[B-Font]ippeerlimit\f[] \f\*[I-Font]int\f[]] [\f\*[I-Font]flag\f[] \f\*[I-Font]...\f[]]
 The
 \f\*[I-Font]address\f[]
 argument expressed in
-dotted-quad form is the address of a host or network.
+numeric form is the address of a host or network.
 Alternatively, the
 \f\*[I-Font]address\f[]
-argument can be a valid host DNS name.
+argument can be a valid hostname.  When a hostname
+is provided, a restriction entry is created for each
+address the hostname resolves to, and any provided
+\f\*[I-Font]mask\f[]
+is ignored and an individual host mask is
+used for each entry.
 The
 \f\*[I-Font]mask\f[]
-argument expressed in dotted-quad form defaults to
-\f\*[B-Font]255.255.255.255\f[],
-meaning that the
+argument expressed in numeric form defaults to
+all bits lit, meaning that the
 \f\*[I-Font]address\f[]
 is treated as the address of an individual host.
-A default entry (address
-\f\*[B-Font]0.0.0.0\f[],
-mask
-\f\*[B-Font]0.0.0.0\f[])
+A default entry with address and mask all zeroes
 is always included and is always the first entry in the list.
 Note that text string
 \f\*[B-Font]default\f[],
@@ -1736,12 +1716,12 @@ and
 queries.
 .TP 7
 .NOP \f\*[B-Font]kod\f[]
-If this flag is set when an access violation occurs, a kiss-o'-death
-(KoD) packet is sent.
-KoD packets are rate limited to no more than one
-per second.
-If another KoD packet occurs within one second after the
-last one, the packet is dropped.
+If this flag is set when a rate violation occurs, a kiss-o'-death
+(KoD) packet is sometimes sent.
+KoD packets are rate limited to no more than one per minimum
+average interpacket spacing, set by
+\f\*[B-Font]discard\f[] \f\*[B-Font]average\f[]
+defaulting to 8s.  Otherwise, no response is sent.
 .TP 7
 .NOP \f\*[B-Font]limited\f[]
 Deny service if the packet spacing violates the lower limits specified
@@ -1841,15 +1821,13 @@ restriction flag.
 Its presence causes the restriction entry to be
 matched only if the source port in the packet is the standard NTP
 UDP port (123).
-Both
+There can be two restriction entries with the same IP address if
+one specifies
 \f\*[B-Font]ntpport\f[]
-and
-\f\*[B-Font]non-ntpport\f[]
-may
-be specified.
+and the other does not.
 The
 \f\*[B-Font]ntpport\f[]
-is considered more specific and
+entry is considered more specific and
 is sorted later in the list.
 .TP 7
 .NOP \f\*[B-Font]serverresponse fuzz\f[]
@@ -1865,12 +1843,29 @@ Deny packets that do not match the current NTP version.
 
 Default restriction list entries with the flags ignore, interface,
 ntpport, for each of the local host's interface addresses are
-inserted into the table at startup to prevent the server
-from attempting to synchronize to its own time.
+inserted into the table at startup to prevent ntpd
+from attempting to synchronize to itself, such as with
+\f\*[B-Font]manycastclient\f[]
+when
+\f\*[B-Font]manycast\f[]
+is also specified with the same multicast address.
 A default entry is also always present, though if it is
 otherwise unconfigured; no flags are associated
 with the default entry (i.e., everything besides your own
 NTP server is unrestricted).
+.TP 7
+.NOP \f\*[B-Font]delrestrict\f[] [source] \f\*[I-Font]address\f[]
+Remove a previously-set restriction.  This is useful for
+runtime configuration via
+\fCntpq\f[]\fR(@NTPQ_MS@)\f[]
+.  If
+\f\*[B-Font]source\f[]
+is specified, a dynamic restriction created from the 
+\f\*[B-Font]restrict\f[] \f\*[B-Font]source\f[]
+template at the time
+an association was added is removed.  Without
+\f\*[B-Font]source\f[]
+a static restriction is removed.
 .PP
 .SH Automatic NTP Configuration Options
 .SS Manycasting
@@ -2635,11 +2630,6 @@ number between 0.003 and 0.007 seconds is appropriate.
 The default
 when this command is not used is 0.004 seconds.
 .TP 7
-.NOP \f\*[B-Font]calldelay\f[] \f\*[I-Font]delay\f[]
-This option controls the delay in seconds between the first and second
-packets sent in burst or iburst mode to allow additional time for a modem
-or ISDN call to complete.
-.TP 7
 .NOP \f\*[B-Font]driftfile\f[] \f\*[I-Font]driftfile\f[]
 This command specifies the complete path and name of the file used to
 record the frequency of the local clock oscillator.
@@ -3461,7 +3451,7 @@ RFC5905
 .SH "AUTHORS"
 The University of Delaware and Network Time Foundation
 .SH "COPYRIGHT"
-Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation all rights reserved.
 This program is released under the terms of the NTP license, <http://ntp.org/license>.
 .SH BUGS
 The syntax checking is not picky; some combinations of
diff --git a/contrib/ntp/ntpd/ntp.conf.mdoc.in b/contrib/ntp/ntpd/ntp.conf.mdoc.in
index 22348ee727d0..70f9080257a2 100644
--- a/contrib/ntp/ntpd/ntp.conf.mdoc.in
+++ b/contrib/ntp/ntpd/ntp.conf.mdoc.in
@@ -1,9 +1,9 @@
-.Dd June 6 2023
+.Dd May 25 2024
 .Dt NTP_CONF 5 File Formats
 .Os
 .\"  EDIT THIS FILE WITH CAUTION  (ntp.mdoc)
 .\"
-.\"  It has been AutoGen-ed  June  6, 2023 at 04:37:32 AM by AutoGen 5.18.16
+.\"  It has been AutoGen-ed  May 25, 2024 at 12:03:50 AM by AutoGen 5.18.16
 .\"  From the definitions    ntp.conf.def
 .\"  and the template file   agmdoc-cmd.tpl
 .Sh NAME
@@ -294,27 +294,15 @@ include authentication fields encrypted using the autokey scheme
 described in
 .Sx Authentication Options .
 .It Cm burst
-when the server is reachable, send a burst of eight packets
-instead of the usual one.
-The packet spacing is normally 2 s;
-however, the spacing between the first and second packets
-can be changed with the
-.Ic calldelay
-command to allow
-additional time for a modem or ISDN call to complete.
-This is designed to improve timekeeping quality
-with the
+when the server is reachable, send a burst of six packets
+instead of the usual one. The packet spacing is 2 s.
+This is designed to improve timekeeping quality with the
 .Ic server
 command and s addresses.
 .It Cm iburst
 When the server is unreachable, send a burst of eight packets
 instead of the usual one.
-The packet spacing is normally 2 s;
-however, the spacing between the first two packets can be
-changed with the
-.Ic calldelay
-command to allow
-additional time for a modem or ISDN call to complete.
+The packet spacing is 2 s.
 This is designed to speed the initial synchronization
 acquisition with the
 .Ic server
@@ -889,7 +877,6 @@ range 1 to 65,535, inclusive.
 .Op Cm leap Ar file
 .Op Cm randfile Ar file
 .Op Cm host Ar file
-.Op Cm sign Ar file
 .Op Cm gq Ar file
 .Op Cm gqpar Ar file
 .Op Cm iffpar Ar file
@@ -952,14 +939,6 @@ encrypted.
 Specifies the location of the random seed file used by the OpenSSL
 library.
 The defaults are described in the main text above.
-.It Cm sign Ar file
-Specifies the location of the optional sign key file.
-This overrides
-the link
-.Pa ntpkey_sign_ Ns Ar hostname
-in the keys directory.
-If this file is
-not found, the host key is also the sign key.
 .El
 .It Ic keys Ar keyfile
 Specifies the complete path and location of the MD5 key file
@@ -1546,7 +1525,8 @@ by default the probability of replacing it with an
 entry representing the client request being processed
 now is 10%. Conversely, if the oldest entry is more
 than 3000 seconds old, the probability is 100%.
-.It Xo Ic restrict address
+.It Xo Ic restrict
+.Ar address
 .Op Cm mask Ar mask
 .Op Cm ippeerlimit Ar int
 .Op Ar flag ...
@@ -1554,21 +1534,22 @@ than 3000 seconds old, the probability is 100%.
 The
 .Ar address
 argument expressed in
-dotted\-quad form is the address of a host or network.
+numeric form is the address of a host or network.
 Alternatively, the
 .Ar address
-argument can be a valid host DNS name.
+argument can be a valid hostname.  When a hostname
+is provided, a restriction entry is created for each
+address the hostname resolves to, and any provided
+.Ar mask
+is ignored and an individual host mask is
+used for each entry.
 The
 .Ar mask
-argument expressed in dotted\-quad form defaults to
-.Cm 255.255.255.255 ,
-meaning that the
+argument expressed in numeric form defaults to
+all bits lit, meaning that the
 .Ar address
 is treated as the address of an individual host.
-A default entry (address
-.Cm 0.0.0.0 ,
-mask
-.Cm 0.0.0.0 )
+A default entry with address and mask all zeroes
 is always included and is always the first entry in the list.
 Note that text string
 .Cm default ,
@@ -1605,12 +1586,12 @@ and
 .Xr ntpdc @NTPDC_MS@
 queries.
 .It Cm kod
-If this flag is set when an access violation occurs, a kiss\-o'\-death
-(KoD) packet is sent.
-KoD packets are rate limited to no more than one
-per second.
-If another KoD packet occurs within one second after the
-last one, the packet is dropped.
+If this flag is set when a rate violation occurs, a kiss\-o'\-death
+(KoD) packet is sometimes sent.
+KoD packets are rate limited to no more than one per minimum
+average interpacket spacing, set by
+.Cm discard average
+defaulting to 8s.  Otherwise, no response is sent.
 .It Cm limited
 Deny service if the packet spacing violates the lower limits specified
 in the
@@ -1700,15 +1681,13 @@ restriction flag.
 Its presence causes the restriction entry to be
 matched only if the source port in the packet is the standard NTP
 UDP port (123).
-Both
+There can be two restriction entries with the same IP address if
+one specifies
 .Cm ntpport
-and
-.Cm non\-ntpport
-may
-be specified.
+and the other does not.
 The
 .Cm ntpport
-is considered more specific and
+entry is considered more specific and
 is sorted later in the list.
 .It Ic "serverresponse fuzz"
 When reponding to server requests,
@@ -1720,12 +1699,31 @@ Deny packets that do not match the current NTP version.
 .Pp
 Default restriction list entries with the flags ignore, interface,
 ntpport, for each of the local host's interface addresses are
-inserted into the table at startup to prevent the server
-from attempting to synchronize to its own time.
+inserted into the table at startup to prevent ntpd
+from attempting to synchronize to itself, such as with
+.Cm manycastclient
+when
+.Cm manycast
+is also specified with the same multicast address.
 A default entry is also always present, though if it is
 otherwise unconfigured; no flags are associated
 with the default entry (i.e., everything besides your own
 NTP server is unrestricted).
+.It Xo Ic delrestrict
+.Op source
+.Ar address
+.Xc
+Remove a previously\-set restriction.  This is useful for
+runtime configuration via
+.Xr ntpq @NTPQ_MS@
+.  If
+.Cm source
+is specified, a dynamic restriction created from the 
+.Cm restrict source
+template at the time
+an association was added is removed.  Without
+.Cm source
+a static restriction is removed.
 .El
 .Sh Automatic NTP Configuration Options
 .Ss Manycasting
@@ -2462,10 +2460,6 @@ Typically (for Ethernet), a
 number between 0.003 and 0.007 seconds is appropriate.
 The default
 when this command is not used is 0.004 seconds.
-.It Ic calldelay Ar delay
-This option controls the delay in seconds between the first and second
-packets sent in burst or iburst mode to allow additional time for a modem
-or ISDN call to complete.
 .It Ic driftfile Ar driftfile
 This command specifies the complete path and name of the file used to
 record the frequency of the local clock oscillator.
@@ -3302,7 +3296,7 @@ A snapshot of this documentation is available in HTML format in
 .Sh "AUTHORS"
 The University of Delaware and Network Time Foundation
 .Sh "COPYRIGHT"
-Copyright (C) 1992\-2023 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992\-2024 The University of Delaware and Network Time Foundation all rights reserved.
 This program is released under the terms of the NTP license, <http://ntp.org/license>.
 .Sh BUGS
 The syntax checking is not picky; some combinations of
diff --git a/contrib/ntp/ntpd/ntp.keys.5man b/contrib/ntp/ntpd/ntp.keys.5man
index 24dbfcf034a9..0b83cc6187e5 100644
--- a/contrib/ntp/ntpd/ntp.keys.5man
+++ b/contrib/ntp/ntpd/ntp.keys.5man
@@ -1,8 +1,8 @@
-.TH ntp.keys 5man "06 Jun 2023" "4.2.8p17" "File Formats"
+.TH ntp.keys 5man "25 May 2024" "4.2.8p18" "File Formats"
 .\"
 .\"  EDIT THIS FILE WITH CAUTION  (ntp.man)
 .\"
-.\"  It has been AutoGen-ed  June  6, 2023 at 04:37:47 AM by AutoGen 5.18.16
+.\"  It has been AutoGen-ed  May 25, 2024 at 12:04:05 AM by AutoGen 5.18.16
 .\"  From the definitions    ntp.keys.def
 .\"  and the template file   agman-file.tpl
 .Sh NAME
@@ -176,7 +176,7 @@ the default name of the configuration file
 .SH "AUTHORS"
 The University of Delaware and Network Time Foundation
 .SH "COPYRIGHT"
-Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation all rights reserved.
 This program is released under the terms of the NTP license, <http://ntp.org/license>.
 .SH "BUGS"
 Please send bug reports to: https://bugs.ntp.org, bugs@ntp.org
diff --git a/contrib/ntp/ntpd/ntp.keys.5mdoc b/contrib/ntp/ntpd/ntp.keys.5mdoc
index 100320fd2330..e51bd72d47b2 100644
--- a/contrib/ntp/ntpd/ntp.keys.5mdoc
+++ b/contrib/ntp/ntpd/ntp.keys.5mdoc
@@ -1,9 +1,9 @@
-.Dd June 6 2023
+.Dd May 25 2024
 .Dt NTP_KEYS 5mdoc File Formats
 .Os FreeBSD 12.1-RELEASE_SI
 .\"  EDIT THIS FILE WITH CAUTION  (ntp.mdoc)
 .\"
-.\"  It has been AutoGen-ed  June  6, 2023 at 04:37:34 AM by AutoGen 5.18.16
+.\"  It has been AutoGen-ed  May 25, 2024 at 12:03:52 AM by AutoGen 5.18.16
 .\"  From the definitions    ntp.keys.def
 .\"  and the template file   agmdoc-file.tpl
 .Sh NAME
@@ -163,7 +163,7 @@ it to autogen\-users@lists.sourceforge.net.  Thank you.
 .Sh "AUTHORS"
 The University of Delaware and Network Time Foundation
 .Sh "COPYRIGHT"
-Copyright (C) 1992\-2023 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992\-2024 The University of Delaware and Network Time Foundation all rights reserved.
 This program is released under the terms of the NTP license, <http://ntp.org/license>.
 .Sh "BUGS"
 Please send bug reports to: https://bugs.ntp.org, bugs@ntp.org
diff --git a/contrib/ntp/ntpd/ntp.keys.html b/contrib/ntp/ntpd/ntp.keys.html
index 2d53d91f4d40..9aaef4afc73c 100644
--- a/contrib/ntp/ntpd/ntp.keys.html
+++ b/contrib/ntp/ntpd/ntp.keys.html
@@ -50,7 +50,7 @@ Next: <a href="#ntp_002ekeys-Description" accesskey="n" rel="next">ntp.keys Desc
 <p>This document describes the symmetric key file for the NTP Project&rsquo;s
 <code>ntpd</code> program.
 </p>
-<p>This document applies to version 4.2.8p17 of <code>ntp.keys</code>.
+<p>This document applies to version 4.2.8p18 of <code>ntp.keys</code>.
 </p>
 <span id="SEC_Overview"></span>
 <h2 class="shortcontents-heading">Short Table of Contents</h2>
diff --git a/contrib/ntp/ntpd/ntp.keys.man.in b/contrib/ntp/ntpd/ntp.keys.man.in
index c646bb11e776..8d4a6a598fe8 100644
--- a/contrib/ntp/ntpd/ntp.keys.man.in
+++ b/contrib/ntp/ntpd/ntp.keys.man.in
@@ -1,8 +1,8 @@
-.TH ntp.keys 5 "06 Jun 2023" "4.2.8p17" "File Formats"
+.TH ntp.keys 5 "25 May 2024" "4.2.8p18" "File Formats"
 .\"
 .\"  EDIT THIS FILE WITH CAUTION  (ntp.man)
 .\"
-.\"  It has been AutoGen-ed  June  6, 2023 at 04:37:47 AM by AutoGen 5.18.16
+.\"  It has been AutoGen-ed  May 25, 2024 at 12:04:05 AM by AutoGen 5.18.16
 .\"  From the definitions    ntp.keys.def
 .\"  and the template file   agman-file.tpl
 .Sh NAME
@@ -176,7 +176,7 @@ the default name of the configuration file
 .SH "AUTHORS"
 The University of Delaware and Network Time Foundation
 .SH "COPYRIGHT"
-Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation all rights reserved.
 This program is released under the terms of the NTP license, <http://ntp.org/license>.
 .SH "BUGS"
 Please send bug reports to: https://bugs.ntp.org, bugs@ntp.org
diff --git a/contrib/ntp/ntpd/ntp.keys.mdoc.in b/contrib/ntp/ntpd/ntp.keys.mdoc.in
index fdeaeba4c938..2506b51e422c 100644
--- a/contrib/ntp/ntpd/ntp.keys.mdoc.in
+++ b/contrib/ntp/ntpd/ntp.keys.mdoc.in
@@ -1,9 +1,9 @@
-.Dd June 6 2023
+.Dd May 25 2024
 .Dt NTP_KEYS 5 File Formats
 .Os FreeBSD 12.1-RELEASE_SI
 .\"  EDIT THIS FILE WITH CAUTION  (ntp.mdoc)
 .\"
-.\"  It has been AutoGen-ed  June  6, 2023 at 04:37:34 AM by AutoGen 5.18.16
+.\"  It has been AutoGen-ed  May 25, 2024 at 12:03:52 AM by AutoGen 5.18.16
 .\"  From the definitions    ntp.keys.def
 .\"  and the template file   agmdoc-file.tpl
 .Sh NAME
@@ -163,7 +163,7 @@ it to autogen\-users@lists.sourceforge.net.  Thank you.
 .Sh "AUTHORS"
 The University of Delaware and Network Time Foundation
 .Sh "COPYRIGHT"
-Copyright (C) 1992\-2023 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992\-2024 The University of Delaware and Network Time Foundation all rights reserved.
 This program is released under the terms of the NTP license, <http://ntp.org/license>.
 .Sh "BUGS"
 Please send bug reports to: https://bugs.ntp.org, bugs@ntp.org
diff --git a/contrib/ntp/ntpd/ntp_config.c b/contrib/ntp/ntpd/ntp_config.c
index d9a753ee3a1e..701f5b52249e 100644
--- a/contrib/ntp/ntpd/ntp_config.c
+++ b/contrib/ntp/ntpd/ntp_config.c
@@ -42,7 +42,6 @@
 #include "ntp_clockdev.h"
 #include "ntp_filegen.h"
 #include "ntp_stdlib.h"
-#include "lib_strbuf.h"
 #include "ntp_assert.h"
 #include "ntp_random.h"
 /*
@@ -139,14 +138,11 @@ typedef struct peer_resolved_ctx_tag {
 #define MAXPPS		20	/* maximum length of PPS device string */
 
 /*
- * Poll Skew List
+ * Poll Skew List array has an entry for each supported poll
+ * interval.
  */
-
-static psl_item psl[17-3+1];	/* values for polls 3-17 */
-				/* To simplify the runtime code we */
-				/* don't want to have to special-case */
-				/* dealing with a default */
-
+#define PSL_ENTRIES	(NTP_MAXPOLL - NTP_MINPOLL + 1)
+static psl_item psl[PSL_ENTRIES];
 
 /*
  * Miscellaneous macros
@@ -338,7 +334,7 @@ static void config_ntpdsim(config_tree *);
 static void config_ntpd(config_tree *, int/*BOOL*/ input_from_file);
 static void config_other_modes(config_tree *);
 static void config_auth(config_tree *);
-static void attrtopsl(int poll, attr_val *avp);
+static void attrtopsl(u_char log2_poll, attr_val *avp);
 static void config_access(config_tree *);
 static void config_mdnstries(config_tree *);
 static void config_phone(config_tree *);
@@ -381,15 +377,9 @@ static u_int32 get_match(const char *, struct masks *);
 static u_int32 get_logmask(const char *);
 static int/*BOOL*/ is_refclk_addr(const address_node * addr);
 
-static void	appendstr(char *, size_t, const char *);
-
-
-#ifndef SIM
 static int getnetnum(const char *num, sockaddr_u *addr, int complain,
 		     enum gnn_type a_type);
 
-#endif
-
 #if defined(__GNUC__) /* this covers CLANG, too */
 static void  __attribute__((__noreturn__,format(printf,1,2))) fatal_error(const char *fmt, ...)
 #elif defined(_MSC_VER)
@@ -1009,18 +999,24 @@ dump_config_tree(
 	for (rest_node = HEAD_PFIFO(ptree->restrict_opts);
 	     rest_node != NULL;
 	     rest_node = rest_node->link) {
-		int is_default = 0;
+		int/*BOOL*/ is_default = FALSE;
+		int/*BOOL*/ omit_mask;
+		sockaddr_u mask;
+		sockaddr_u onesmask;
 
+		s = NULL;
+		atrv = HEAD_PFIFO(rest_node->flag_tok_fifo);
+		for (; atrv != NULL; atrv = atrv->link) {
+			if (   T_Integer == atrv->type
+			    && T_Source == atrv->attr) {
+				s = keyword(T_Source);
+				break;
+			}
+		}
 		if (NULL == rest_node->addr) {
-			s = "default";
-			/* Don't need to set is_default=1 here */
-			atrv = HEAD_PFIFO(rest_node->flag_tok_fifo);
-			for ( ; atrv != NULL; atrv = atrv->link) {
-				if (   T_Integer == atrv->type
-				    && T_Source == atrv->attr) {
-					s = "source";
-					break;
-				}
+			if (NULL == s) {
+				s = keyword(T_Default);
+				/* Don't need to set is_default here */
 			}
 		} else {
 			const char *ap = rest_node->addr->address;
@@ -1030,25 +1026,51 @@ dump_config_tree(
 				mp = rest_node->mask->address;
 
 			if (   rest_node->addr->type == AF_INET
-			    && !strcmp(ap, "0.0.0.0")
-			    && !strcmp(mp, "0.0.0.0")) {
-				is_default = 1;
+			    && !strcmp(mp, "0.0.0.0")
+			    && !strcmp(ap, mp)) {
+				is_default = TRUE;
 				s = "-4 default";
 			} else if (   rest_node->mask
 				   && rest_node->mask->type == AF_INET6
-				   && !strcmp(ap, "::")
-				   && !strcmp(mp, "::")) {
-				is_default = 1;
+				   && !strcmp(mp, "::")
+				   && !strcmp(ap, mp)) {
+				is_default = TRUE;
 				s = "-6 default";
 			} else {
-				s = ap;
+				if (NULL == s) {
+					s = ap;
+				} else {
+					LIB_GETBUF(s1);
+					snprintf(s1, LIB_BUFLENGTH,
+						 "%s %s",
+						 keyword(T_Source), ap);
+					s = s1;
+				}
+			}
+		}
+		fprintf(df, "%s %s",
+			keyword(rest_node->remove
+					? T_Delrestrict
+					: T_Restrict),
+			s);
+		if (rest_node->mask != NULL && !is_default) {
+			ZERO(mask);
+			AF(&mask) = AF_UNSPEC;
+			omit_mask = (0 != getnetnum(rest_node->mask->address,
+						    &mask, 0, t_UNK));
+			if (omit_mask) {
+				SET_HOSTMASK(&onesmask, AF(&mask));
+				omit_mask = SOCK_EQ(&mask, &onesmask);
+			}
+			if (!omit_mask) {
+				fprintf(df, " mask %s",
+					rest_node->mask->address);
 			}
 		}
-		fprintf(df, "restrict %s", s);
-		if (rest_node->mask != NULL && !is_default)
-			fprintf(df, " mask %s",
-				rest_node->mask->address);
-		fprintf(df, " ippeerlimit %d", rest_node->ippeerlimit);
+		if (-1 != rest_node->ippeerlimit) {
+			fprintf(df, " ippeerlimit %d",
+				rest_node->ippeerlimit);
+		}
 		atrv = HEAD_PFIFO(rest_node->flag_tok_fifo);
 		for ( ; atrv != NULL; atrv = atrv->link) {
 			if (   T_Integer == atrv->type
@@ -1056,7 +1078,7 @@ dump_config_tree(
 				fprintf(df, " %s", keyword(atrv->attr));
 			}
 		}
-		fprintf(df, "\n");            
+		fprintf(df, "\n");
 /**/
 #if 0
 msyslog(LOG_INFO, "Dumping flag_tok_fifo:");
@@ -1585,8 +1607,10 @@ create_restrict_node(
 	address_node *	mask,
 	short		ippeerlimit,
 	attr_val_fifo *	flag_tok_fifo,
-	int		nline
-	)
+	int/*BOOL*/	remove,
+	int		nline,
+	int		ncol
+)
 {
 	restrict_node *my_node;
 
@@ -1595,7 +1619,9 @@ create_restrict_node(
 	my_node->mask = mask;
 	my_node->ippeerlimit = ippeerlimit;
 	my_node->flag_tok_fifo = flag_tok_fifo;
+	my_node->remove = remove;
 	my_node->line_no = nline;
+	my_node->column = ncol;
 
 	return my_node;
 }
@@ -2193,6 +2219,7 @@ free_config_auth(
 }
 #endif	/* FREE_CFG_T */
 
+
 #ifndef SIM
 /* Configure low-level clock-related parameters. Return TRUE if the
  * clock might need adjustment like era-checking after the call, FALSE
@@ -2200,16 +2227,16 @@ free_config_auth(
  */
 static int/*BOOL*/
 config_tos_clock(
-	config_tree *ptree
-	)
+	config_tree* ptree
+)
 {
 	int		ret;
-	attr_val *	tos;
+	attr_val* tos;
 
 	ret = FALSE;
 	tos = HEAD_PFIFO(ptree->orphan_cmds);
 	for (; tos != NULL; tos = tos->link) {
-		switch(tos->attr) {
+		switch (tos->attr) {
 
 		default:
 			break;
@@ -2221,12 +2248,13 @@ config_tos_clock(
 		}
 	}
 
-	if (basedate_get_day() <= NTP_TO_UNIX_DAYS)
+	if (basedate_get_day() <= NTP_TO_UNIX_DAYS) {
 		basedate_set_day(basedate_eval_buildstamp() - 11);
-	    
+	}
 	return ret;
 }
-#endif	/* SIM */
+#endif	/* !SIM */
+
 
 static void
 config_tos(
@@ -2427,21 +2455,22 @@ free_config_tos(
 
 static void
 config_monitor(
-	config_tree *ptree
-	)
+	config_tree* ptree
+)
 {
-	int_node *pfilegen_token;
-	const char *filegen_string;
-	const char *filegen_file;
-	FILEGEN *filegen;
-	filegen_node *my_node;
-	attr_val *my_opts;
-	int filegen_type;
-	int filegen_flag;
+	int_node *	pfilegen_token;
+	const char *	filegen_string;
+	const char *	filegen_file;
+	FILEGEN *	filegen;
+	filegen_node *	my_node;
+	attr_val*	my_opts;
+	int		filegen_type;
+	int		filegen_flag;
 
 	/* Set the statistics directory */
-	if (ptree->stats_dir)
-	    stats_config(STATS_STATSDIR, ptree->stats_dir, 0);
+	if (ptree->stats_dir) {
+		stats_config(STATS_STATSDIR, ptree->stats_dir, TRUE);
+	}
 
 	/* NOTE:
 	 * Calling filegen_get is brain dead. Doing a string
@@ -2612,19 +2641,19 @@ config_access(
 	struct addrinfo *	ai_list;
 	struct addrinfo *	pai;
 	int			rc;
-	int			restrict_default;
+	int/*BOOL*/		success;
+	int/*BOOL*/		restrict_default;
 	u_short			rflags;
 	u_short			mflags;
 	short			ippeerlimit;
 	int			range_err;
-	psl_item		my_psl_item;
 	attr_val *		atrv;
 	attr_val *		dflt_psl_atr;
 	const char *		signd_warning =
 #ifdef HAVE_NTP_SIGND
-	    "MS-SNTP signd operations currently block ntpd degrading service to all clients.";
+	    "MS-SNTP signd operations currently block ntpd degrading service to all clients.\n";
 #else
-	    "mssntp restrict bit ignored, this ntpd was configured without --enable-ntp-signd.";
+	    "mssntp restrict bit ignored, this ntpd was configured without --enable-ntp-signd.\n";
 #endif
 
 	/* Configure the mru options */
@@ -2829,28 +2858,31 @@ config_access(
 		}
 
 		if ((RES_MSSNTP & rflags) && !warned_signd) {
-			warned_signd = 1;
-			fprintf(stderr, "%s\n", signd_warning);
+			warned_signd = TRUE;
+			fprintf(stderr, "%s", signd_warning);
 			msyslog(LOG_WARNING, "%s", signd_warning);
 		}
 
-		/* It would be swell if we could identify the line number */
 		if ((RES_KOD & rflags) && !(RES_LIMITED & rflags)) {
 			const char *kod_where = (my_node->addr)
 					  ? my_node->addr->address
 					  : (mflags & RESM_SOURCE)
 					    ? "source"
 					    : "default";
-			const char *kod_warn = "KOD does nothing without LIMITED.";
-
-			fprintf(stderr, "restrict %s: %s\n", kod_where, kod_warn);
-			msyslog(LOG_WARNING, "restrict %s: %s", kod_where, kod_warn);
+			const char *kod_warn = "'kod' does nothing without 'limited'.\n";
+
+			fprintf(stderr, "line %d col %d restrict %s: %s",
+				my_node->line_no, my_node->column, 
+				kod_where, kod_warn);
+			msyslog(LOG_WARNING, "line %d col %d restrict %s: %s",
+				my_node->line_no, my_node->column,
+				kod_where, kod_warn);
 		}
 
 		ZERO_SOCK(&addr);
 		ai_list = NULL;
 		pai = NULL;
-		restrict_default = 0;
+		restrict_default = FALSE;
 
 		if (NULL == my_node->addr) {
 			ZERO_SOCK(&mask);
@@ -2860,13 +2892,18 @@ config_access(
 				 * without a -4 / -6 qualifier, add to
 				 * both lists
 				 */
-				restrict_default = 1;
+				restrict_default = TRUE;
 			} else {
 				/* apply "restrict source ..." */
-				DPRINTF(1, ("restrict source template ippeerlimit %d mflags %x rflags %x\n",
-					ippeerlimit, mflags, rflags));
-				hack_restrict(RESTRICT_FLAGS, NULL, NULL,
-					      ippeerlimit, mflags, rflags, 0);
+				success = hack_restrict(RESTRICT_FLAGS,
+							NULL, NULL,
+							ippeerlimit,
+							mflags, rflags,
+							0);
+				if (!success) {
+					msyslog(LOG_ERR,
+						"unable to save restrict source");
+				}
 				continue;
 			}
 		} else {
@@ -2898,33 +2935,37 @@ config_access(
 						 &ai_list);
 				if (rc) {
 					msyslog(LOG_ERR,
-						"restrict: ignoring line %d, address/host '%s' unusable.",
+						"restrict: line %d col %d"
+						" address/host '%s' unusable.",
 						my_node->line_no,
+						my_node->column,
 						my_node->addr->address);
 					continue;
 				}
 				INSIST(ai_list != NULL);
 				pai = ai_list;
 				INSIST(pai->ai_addr != NULL);
-				INSIST(sizeof(addr) >=
-					   pai->ai_addrlen);
+				INSIST(sizeof(addr) >= pai->ai_addrlen);
 				memcpy(&addr, pai->ai_addr,
 				       pai->ai_addrlen);
 				INSIST(AF_INET == AF(&addr) ||
 					   AF_INET6 == AF(&addr));
 			}
 
+			/* default to all-ones mask for single address */
 			SET_HOSTMASK(&mask, AF(&addr));
 
-			/* Resolve the mask */
-			if (my_node->mask) {
+			/* Ignore mask if addr from hostname [Bug 3872] */
+			if (NULL == ai_list && my_node->mask) {
 				ZERO_SOCK(&mask);
 				AF(&mask) = my_node->mask->type;
 				if (getnetnum(my_node->mask->address,
 					      &mask, 1, t_MSK) != 1) {
 					msyslog(LOG_ERR,
-						"restrict: ignoring line %d, mask '%s' unusable.",
+						"restrict: line %d col %d"
+						" mask '%s' unusable.",
 						my_node->line_no,
+						my_node->column,
 						my_node->mask->address);
 					continue;
 				}
@@ -2935,15 +2976,43 @@ config_access(
 		if (restrict_default) {
 			AF(&addr) = AF_INET;
 			AF(&mask) = AF_INET;
-			hack_restrict(RESTRICT_FLAGS, &addr, &mask,
-				      ippeerlimit, mflags, rflags, 0);
+			success = hack_restrict(
+					RESTRICT_FLAGS,
+					&addr, 
+					&mask,
+					ippeerlimit,
+					mflags,
+					rflags,
+					0
+					);
+			if (!success) {
+				msyslog(LOG_ERR,
+					"unable to save %s %s restriction",
+					stoa(&addr), stoa(&mask));
+			}
 			AF(&addr) = AF_INET6;
 			AF(&mask) = AF_INET6;
 		}
 
 		do {
-			hack_restrict(RESTRICT_FLAGS, &addr, &mask,
-				      ippeerlimit, mflags, rflags, 0);
+			success = hack_restrict(
+					my_node->remove
+						? RESTRICT_REMOVE
+						: RESTRICT_FLAGS,
+					&addr,
+					&mask,
+					ippeerlimit,
+					mflags,
+					rflags,
+					0);
+			if (!success) {
+				msyslog(LOG_ERR,
+					"unable to %s %s %s restriction",
+					my_node->remove
+						? "delete"
+						: "save",
+					stoa(&addr), stoa(&mask));
+			}
 			if (pai != NULL &&
 			    NULL != (pai = pai->ai_next)) {
 				INSIST(pai->ai_addr != NULL);
@@ -2958,61 +3027,42 @@ config_access(
 			}
 		} while (pai != NULL);
 
-		if (ai_list != NULL)
+		if (ai_list != NULL) {
 			freeaddrinfo(ai_list);
+		}
 	}
 
-	/* Deal with the Poll Skew List */
-
+	/*
+	 * pollskewlist
+	 */
+	atrv = HEAD_PFIFO(ptree->pollskewlist);
+	if (NULL == atrv) {
+		/* don't touch the poll skew list */
+		return;
+	}
 	ZERO(psl);
-	ZERO(my_psl_item);
-
 	/*
 	 * First, find the last default pollskewlist item.
-	 * There should only be one of these with the current grammar,
-	 * but better safe than sorry.
 	 */
 	dflt_psl_atr = NULL;
-	atrv = HEAD_PFIFO(ptree->pollskewlist);
 	for ( ; atrv != NULL; atrv = atrv->link) {
-		switch (atrv->attr) {
-		case -1:	/* default */
+		if (-1 == atrv->attr) {	/* default */
 			dflt_psl_atr = atrv;
-			break;
-
-		case 3:		/* Fall through */
-		case 4:		/* Fall through */
-		case 5:		/* Fall through */
-		case 6:		/* Fall through */
-		case 7:		/* Fall through */
-		case 8:		/* Fall through */
-		case 9:		/* Fall through */
-		case 10:	/* Fall through */
-		case 11:	/* Fall through */
-		case 12:	/* Fall through */
-		case 13:	/* Fall through */
-		case 14:	/* Fall through */
-		case 15:	/* Fall through */
-		case 16:	/* Fall through */
-		case 17:
-			/* ignore */
-			break;
-
-		default:
+		} else if (   atrv->attr < NTP_MINPOLL
+			   || atrv->attr > NTP_MAXPOLL) {
 			msyslog(LOG_ERR,
-				"config_access: default PSL scan: ignoring unexpected poll value %d",
-				atrv->attr);
-			break;
+				"Poll %d out of bounds [%d-%d] for pollskewlist",
+				atrv->attr, NTP_MINPOLL, NTP_MAXPOLL);
 		}
 	}
 
-	/* If we have a nonzero default, initialize the PSL */
+	/* If we have a nonzero default, put it in all entries */
 	if (   dflt_psl_atr
 	    && (   0 != dflt_psl_atr->value.r.first
 		|| 0 != dflt_psl_atr->value.r.last)) {
 		int i;
 
-		for (i = 3; i <= 17; ++i) {
+		for (i = NTP_MINPOLL; i <= NTP_MAXPOLL; ++i) {
 			attrtopsl(i, dflt_psl_atr);
 		}
 	}
@@ -3020,38 +3070,15 @@ config_access(
 	/* Finally, update the PSL with any explicit entries */
 	atrv = HEAD_PFIFO(ptree->pollskewlist);
 	for ( ; atrv != NULL; atrv = atrv->link) {
-		switch (atrv->attr) {
-		case -1:	/* default */
-			/* Ignore */
-			break;
-
-		case 3:		/* Fall through */
-		case 4:		/* Fall through */
-		case 5:		/* Fall through */
-		case 6:		/* Fall through */
-		case 7:		/* Fall through */
-		case 8:		/* Fall through */
-		case 9:		/* Fall through */
-		case 10:	/* Fall through */
-		case 11:	/* Fall through */
-		case 12:	/* Fall through */
-		case 13:	/* Fall through */
-		case 14:	/* Fall through */
-		case 15:	/* Fall through */
-		case 16:	/* Fall through */
-		case 17:
+		if (atrv->attr >= NTP_MINPOLL && atrv->attr <= NTP_MAXPOLL) {
 			attrtopsl(atrv->attr, atrv);
-			break;
-
-		default:
-			break;	/* Ignore - we reported this above */
 		}
 	}
 
 #if 0
 	int p;
 	msyslog(LOG_INFO, "Dumping PSL:");
-	for (p = 3; p <= 17; ++p) {
+	for (p = NTP_MINPOLL; p <= NTP_MAXPOLL; ++p) {
 		psl_item psi;
 
 		if (0 == get_pollskew(p, &psi)) {
@@ -3065,43 +3092,40 @@ config_access(
 }
 
 
-void
-attrtopsl(int poll, attr_val *avp)
+static void
+attrtopsl(
+	u_char		log2_poll,
+	attr_val *	avp
+	)
 {
+	int	pao   = log2_poll - NTP_MINPOLL;     /* poll array offset */
+	u_int32	lower = (u_short)avp->value.r.first; /* ntp_parser.y ensures */
+	u_int32	upper = (u_short)avp->value.r.last;  /* non-neg. first/last */
+	u_int	psmax = 1 << (log2_poll - 1);
+	u_int32	qmsk;
 
-	DEBUG_INSIST((poll - 3) < sizeof psl);
-	if (poll < 3 || poll > 17) {
-		msyslog(LOG_ERR, "attrtopsl(%d, ...): Poll value is out of range - ignoring", poll);
-	} else {
-		int pao = poll - 3;		/* poll array offset */
-		int lower = avp->value.r.first;	/* a positive number */
-		int upper = avp->value.r.last;
-		int psmax = 1 << (poll - 1);
-		int qmsk;
-
-		if (lower > psmax) {
-			msyslog(LOG_WARNING, "attrtopsl: default: poll %d lower bound reduced from %d to %d",
-				poll, lower, psmax);
-			lower = psmax;
-		}
-		if (upper > psmax) {
-			msyslog(LOG_WARNING, "attrtopsl: default: poll %d upper bound reduced from %d to %d",
-				poll, upper, psmax);
-			upper = psmax;
-		}
-		psl[pao].sub = lower;
-		psl[pao].qty = lower + upper;
+	DEBUG_INSIST(pao >= 0 && pao < COUNTOF(psl));
 
-		qmsk = 1;
-		while (qmsk < (lower + upper)) {
-			qmsk <<= 1;
-			qmsk |=  1;
-		};
-		psl[pao].msk = qmsk;
+	if (lower > psmax) {
+		msyslog(LOG_WARNING, "pollskewlist %d lower bound reduced from %d to %d",
+			log2_poll, lower, psmax);
+		lower = psmax;
+	}
+	if (upper > psmax) {
+		msyslog(LOG_WARNING, "pollskewlist %d upper bound reduced from %d to %d",
+			log2_poll, upper, psmax);
+		upper = psmax;
 	}
+	psl[pao].sub = lower;
+	psl[pao].qty = lower + upper;
 
-	return;
-} 
+	qmsk = 1;
+	while (qmsk < (lower + upper)) {
+		qmsk <<= 1;
+		qmsk |=  1;
+	}
+	psl[pao].msk = qmsk;
+}
 #endif	/* !SIM */
 
 
@@ -3111,16 +3135,14 @@ get_pollskew(
 	psl_item *rv
 	)
 {
-
 #ifdef DISABLE_BUG3767_FIX
-	DEBUG_INSIST(3 <= p && 17 >= p);
+	DEBUG_INSIST(NTP_MINPOLL <= p && NTP_MAXPOLL >= p);
 #endif
-	if (3 <= p && 17 >= p) {
-		*rv = psl[p - 3];
-
+	if (NTP_MINPOLL <= p && p <= NTP_MAXPOLL) {
+		*rv = psl[p - NTP_MINPOLL];
 		return 0;
 	} else {
-		msyslog(LOG_ERR, "get_pollskew(%d): poll is not between 3 and 17!", p);
+		msyslog(LOG_DEBUG, "get_pollskew(%d): out of range", p);
 		return -1;
 	}
 
@@ -3339,9 +3361,13 @@ config_nic_rules(
 			if_name = estrdup(if_name);
 
 		switch (curr_node->match_class) {
-
 		default:
+#ifdef DEBUG
 			fatal_error("config_nic_rules: match-class-token=%d", curr_node->match_class);
+#endif
+		case T_All:
+			match_type = MATCH_ALL;
+			break;
 
 		case 0:
 			/*
@@ -3372,10 +3398,6 @@ config_nic_rules(
 			}
 			break;
 
-		case T_All:
-			match_type = MATCH_ALL;
-			break;
-
 		case T_Ipv4:
 			match_type = MATCH_IPV4;
 			break;
@@ -3390,10 +3412,10 @@ config_nic_rules(
 		}
 
 		switch (curr_node->action) {
-
 		default:
+#ifdef DEBUG
 			fatal_error("config_nic_rules: action-token=%d", curr_node->action);
-
+#endif
 		case T_Listen:
 			action = ACTION_LISTEN;
 			break;
@@ -3409,7 +3431,9 @@ config_nic_rules(
 
 		add_nic_rule(match_type, if_name, prefixlen,
 			     action);
-		timer_interfacetimeout(current_time + 2);
+		if (!initializing && !scan_addrs_once) {
+			endpt_scan_timer = 1 + current_time;
+		}
 		if (if_name != NULL)
 			free(if_name);
 	}
@@ -3733,7 +3757,7 @@ config_trap(
 	attr_val *curr_opt;
 	sockaddr_u addr_sock;
 	sockaddr_u peeraddr;
-	struct interface *localaddr;
+	endpt *localaddr;
 	struct addrinfo hints;
 	char port_text[8];
 	settrap_parms *pstp;
@@ -3867,7 +3891,7 @@ trap_name_resolved(
 	)
 {
 	settrap_parms *pstp;
-	struct interface *localaddr;
+	endpt *localaddr;
 	sockaddr_u peeraddr;
 
 	(void)gai_errno;
@@ -3920,7 +3944,7 @@ config_fudge(
 	sockaddr_u addr_sock;
 	address_node *addr_node;
 	struct refclockstat clock_stat;
-	char refid_str[5];
+	char refidstr[5];
 	int err_flag;
 
 	curr_fudge = HEAD_PFIFO(ptree->fudge);
@@ -3951,9 +3975,6 @@ config_fudge(
 		clock_stat.fudgeminjitter = 0.0;
 		clock_stat.fudgetime1     = 0.0;
 		clock_stat.fudgetime2     = 0.0;
-		clock_stat.p_lastcode     = NULL;
-		clock_stat.clockdesc      = NULL;
-		clock_stat.kv_list        = NULL;
 		curr_opt = HEAD_PFIFO(curr_fudge->options);
 		for (; curr_opt != NULL; curr_opt = curr_opt->link) {
 			switch (curr_opt->attr) {
@@ -3975,10 +3996,17 @@ config_fudge(
 
 			case T_Refid:
 				clock_stat.haveflags |= CLK_HAVEVAL2;
-				/* strncpy() does exactly what we want here: */
-				strncpy(refid_str, curr_opt->value.s, 
-					sizeof refid_str - 1);
-				memcpy(&clock_stat.fudgeval2, refid_str,
+				/*
+				 * strncpy() does exactly what we want
+				 * here, do not be tempted to replace
+				 * it with strlcpy(), we want it to
+				 * zero-fill refid's less than 4 chars
+				 * because we're going to stuff it
+				 * into a u_int32.
+				 */
+				strncpy(refidstr, curr_opt->value.s, 
+					sizeof refidstr - 1);
+				memcpy(&clock_stat.fudgeval2, refidstr,
 				       sizeof clock_stat.fudgeval2);
 				break;
 
@@ -4140,7 +4168,7 @@ config_vars(
 		case T_Driftfile:
 			if ('\0' == curr_var->value.s[0])
 				msyslog(LOG_INFO, "config: driftfile disabled");
-			stats_config(STATS_FREQ_FILE, curr_var->value.s, 0);
+			stats_config(STATS_FREQ_FILE, curr_var->value.s, TRUE);
 			break;
 
 		case T_Dscp:
@@ -4158,7 +4186,7 @@ config_vars(
 			break;
 
 		case T_Leapfile:
-		    stats_config(STATS_LEAP_FILE, curr_var->value.s, curr_var->flag);
+			stats_config(STATS_LEAP_FILE, curr_var->value.s, curr_var->flag);
 			break;
 
 #ifdef LEAP_SMEAR
@@ -5165,13 +5193,13 @@ getconfig(
 		}
 		cfgt.source.value.s = estrdup(alt_config_file);
 #endif	/* SYS_WINNT */
-	} else
+	} else {
 		cfgt.source.value.s = estrdup(config_file);
-
+	}
 
 	/*** BULK OF THE PARSER ***/
 #ifdef DEBUG
-	yydebug = !!(debug >= 5);
+	yydebug = (debug >= 9);
 #endif
 	yyparse();
 	lex_drop_stack();
@@ -5311,10 +5339,9 @@ normal_dtoa(
 	pch_nz = pch_e;
 	while ('0' == *pch_nz)
 		pch_nz++;
-	if (pch_nz == pch_e)
-		return buf;
-	strlcpy(pch_e, pch_nz, LIB_BUFLENGTH - (pch_e - buf));
-
+	if (pch_nz > pch_e) {
+		memmove(pch_e, pch_nz, 1 + strlen(pch_nz));
+	}
 	return buf;
 }
 
@@ -5576,12 +5603,11 @@ gettokens_netinfo (
  * returns 1 for success, and mysteriously, 0 for most failures, and
  * -1 if the address found is IPv6 and we believe IPv6 isn't working.
  */
-#ifndef SIM
 static int
 getnetnum(
 	const char *num,
 	sockaddr_u *addr,
-	int complain,
+	int complain,		/* ignored */
 	enum gnn_type a_type	/* ignored */
 	)
 {
@@ -5589,22 +5615,21 @@ getnetnum(
 		AF_INET == AF(addr) ||
 		AF_INET6 == AF(addr));
 
-	if (!is_ip_address(num, AF(addr), addr))
+	if (!is_ip_address(num, AF(addr), addr)) {
 		return 0;
-
-	if (IS_IPV6(addr) && !ipv6_works)
-		return -1;
-
+	}
 # ifdef ISC_PLATFORM_HAVESALEN
 	addr->sa.sa_len = SIZEOF_SOCKADDR(AF(addr));
 # endif
 	SET_PORT(addr, NTP_PORT);
 
-	DPRINTF(2, ("getnetnum given %s, got %s\n", num, stoa(addr)));
-
-	return 1;
+	if (IS_IPV6(addr) && !ipv6_works) {
+		return -1;
+	} else {
+		return 1;
+	}
 }
-#endif	/* !SIM */
+
 
 #if defined(HAVE_SETRLIMIT)
 void
@@ -5684,228 +5709,3 @@ ntp_rlimit(
 	}
 }
 #endif	/* HAVE_SETRLIMIT */
-
-
-char *
-build_iflags(
-	u_int32 iflags
-	)
-{
-	static char ifs[1024];
-
-	ifs[0] = '\0';
-
-	if (iflags & INT_UP) {
-		iflags &= ~INT_UP;
-		appendstr(ifs, sizeof ifs, "up");
-	}
-
-	if (iflags & INT_PPP) {
-		iflags &= ~INT_PPP;
-		appendstr(ifs, sizeof ifs, "ppp");
-	}
-
-	if (iflags & INT_LOOPBACK) {
-		iflags &= ~INT_LOOPBACK;
-		appendstr(ifs, sizeof ifs, "loopback");
-	}
-
-	if (iflags & INT_BROADCAST) {
-		iflags &= ~INT_BROADCAST;
-		appendstr(ifs, sizeof ifs, "broadcast");
-	}
-
-	if (iflags & INT_MULTICAST) {
-		iflags &= ~INT_MULTICAST;
-		appendstr(ifs, sizeof ifs, "multicast");
-	}
-
-	if (iflags & INT_BCASTOPEN) {
-		iflags &= ~INT_BCASTOPEN;
-		appendstr(ifs, sizeof ifs, "bcastopen");
-	}
-
-	if (iflags & INT_MCASTOPEN) {
-		iflags &= ~INT_MCASTOPEN;
-		appendstr(ifs, sizeof ifs, "mcastopen");
-	}
-
-	if (iflags & INT_WILDCARD) {
-		iflags &= ~INT_WILDCARD;
-		appendstr(ifs, sizeof ifs, "wildcard");
-	}
-
-	if (iflags & INT_MCASTIF) {
-		iflags &= ~INT_MCASTIF;
-		appendstr(ifs, sizeof ifs, "MCASTif");
-	}
-
-	if (iflags & INT_PRIVACY) {
-		iflags &= ~INT_PRIVACY;
-		appendstr(ifs, sizeof ifs, "IPv6privacy");
-	}
-
-	if (iflags & INT_BCASTXMIT) {
-		iflags &= ~INT_BCASTXMIT;
-		appendstr(ifs, sizeof ifs, "bcastxmit");
-	}
-
-	if (iflags) {
-		char string[10];
-
-		snprintf(string, sizeof string, "%0x", iflags);
-		appendstr(ifs, sizeof ifs, string);
-	}
-
-	return ifs;
-}
-
-
-char *
-build_mflags(
-	u_short mflags
-	)
-{
-	static char mfs[1024];
-
-	mfs[0] = '\0';
-
-	if (mflags & RESM_NTPONLY) {
-		mflags &= ~RESM_NTPONLY;
-		appendstr(mfs, sizeof mfs, "ntponly");
-	}
-
-	if (mflags & RESM_SOURCE) {
-		mflags &= ~RESM_SOURCE;
-		appendstr(mfs, sizeof mfs, "source");
-	}
-
-	if (mflags) {
-		char string[10];
-
-		snprintf(string, sizeof string, "%0x", mflags);
-		appendstr(mfs, sizeof mfs, string);
-	}
-
-	return mfs;
-}
-
-
-char *
-build_rflags(
-	u_short rflags
-	)
-{
-	static char rfs[1024];
-
-	rfs[0] = '\0';
-
-	if (rflags & RES_FLAKE) {
-		rflags &= ~RES_FLAKE;
-		appendstr(rfs, sizeof rfs, "flake");
-	}
-
-	if (rflags & RES_IGNORE) {
-		rflags &= ~RES_IGNORE;
-		appendstr(rfs, sizeof rfs, "ignore");
-	}
-
-	if (rflags & RES_KOD) {
-		rflags &= ~RES_KOD;
-		appendstr(rfs, sizeof rfs, "kod");
-	}
-
-	if (rflags & RES_MSSNTP) {
-		rflags &= ~RES_MSSNTP;
-		appendstr(rfs, sizeof rfs, "mssntp");
-	}
-
-	if (rflags & RES_LIMITED) {
-		rflags &= ~RES_LIMITED;
-		appendstr(rfs, sizeof rfs, "limited");
-	}
-
-	if (rflags & RES_LPTRAP) {
-		rflags &= ~RES_LPTRAP;
-		appendstr(rfs, sizeof rfs, "lptrap");
-	}
-
-	if (rflags & RES_NOMODIFY) {
-		rflags &= ~RES_NOMODIFY;
-		appendstr(rfs, sizeof rfs, "nomodify");
-	}
-
-	if (rflags & RES_NOMRULIST) {
-		rflags &= ~RES_NOMRULIST;
-		appendstr(rfs, sizeof rfs, "nomrulist");
-	}
-
-	if (rflags & RES_NOEPEER) {
-		rflags &= ~RES_NOEPEER;
-		appendstr(rfs, sizeof rfs, "noepeer");
-	}
-
-	if (rflags & RES_NOPEER) {
-		rflags &= ~RES_NOPEER;
-		appendstr(rfs, sizeof rfs, "nopeer");
-	}
-
-	if (rflags & RES_NOQUERY) {
-		rflags &= ~RES_NOQUERY;
-		appendstr(rfs, sizeof rfs, "noquery");
-	}
-
-	if (rflags & RES_DONTSERVE) {
-		rflags &= ~RES_DONTSERVE;
-		appendstr(rfs, sizeof rfs, "dontserve");
-	}
-
-	if (rflags & RES_NOTRAP) {
-		rflags &= ~RES_NOTRAP;
-		appendstr(rfs, sizeof rfs, "notrap");
-	}
-
-	if (rflags & RES_DONTTRUST) {
-		rflags &= ~RES_DONTTRUST;
-		appendstr(rfs, sizeof rfs, "notrust");
-	}
-
-	if (rflags & RES_SRVRSPFUZ) {
-		rflags &= ~RES_SRVRSPFUZ;
-		appendstr(rfs, sizeof rfs, "srvrspfuz");
-	}
-
-	if (rflags & RES_VERSION) {
-		rflags &= ~RES_VERSION;
-		appendstr(rfs, sizeof rfs, "version");
-	}
-
-	if (rflags) {
-		char string[10];
-
-		snprintf(string, sizeof string, "%0x", rflags);
-		appendstr(rfs, sizeof rfs, string);
-	}
-
-	if ('\0' == rfs[0]) {
-		appendstr(rfs, sizeof rfs, "(none)");
-	}
-
-	return rfs;
-}
-
-
-static void
-appendstr(
-	char *string,
-	size_t s,
-	const char *new
-	)
-{
-	if (*string != '\0') {
-		(void)strlcat(string, ",", s);
-	}
-	(void)strlcat(string, new, s);
-
-	return;
-}
diff --git a/contrib/ntp/ntpd/ntp_control.c b/contrib/ntp/ntpd/ntp_control.c
index 0cc7fcb47ecd..6756fa0300c1 100644
--- a/contrib/ntp/ntpd/ntp_control.c
+++ b/contrib/ntp/ntpd/ntp_control.c
@@ -26,7 +26,6 @@
 #include "ntp_crypto.h"
 #include "ntp_assert.h"
 #include "ntp_leapsec.h"
-#include "lib_strbuf.h"
 #include "timexsup.h"
 
 #include <rc_cmdlength.h>
@@ -110,7 +109,7 @@ static	int	validate_nonce	(const char *, struct recvbuf *);
 static	void	req_nonce	(struct recvbuf *, int);
 static	void	unset_trap	(struct recvbuf *, int);
 static	struct ctl_trap *ctlfindtrap(sockaddr_u *,
-				     struct interface *);
+				     endpt *);
 
 int/*BOOL*/ is_safe_filename(const char * name);
 
@@ -804,7 +803,7 @@ static int	datalinelen;
 static int	datasent;	/* flag to avoid initial ", " */
 static int	datanotbinflag;
 static sockaddr_u *rmt_addr;
-static struct interface *lcl_inter;
+static endpt *lcl_inter;
 
 static u_char	res_authenticate;
 static u_char	res_authokay;
@@ -3179,8 +3178,8 @@ ctl_getitem(
 	    if (quiet_until <= current_time) {
 		    quiet_until = current_time + 300;
 		    msyslog(LOG_WARNING,
-			    "Possible 'ntpdx' exploit from %s#%u (possibly spoofed)",
-			    stoa(rmt_addr), SRCPORT(rmt_addr));
+			    "Possible 'ntpdx' exploit from %s (possibly spoofed)",
+			    sptoa(rmt_addr));
 	    }
 	reqpt = reqend; /* never again for this packet! */
 	return NULL;
@@ -3634,8 +3633,13 @@ static void configure(
 
 
 /*
- * derive_nonce - generate client-address-specific nonce value
- *		  associated with a given timestamp.
+ * derive_nonce - generate 32-bit nonce value derived from the client
+ *		  address and a request-specific timestamp.
+ *
+ * This uses MD5 for a non-authentication purpose -- the nonce is used
+ * analogous to the TCP 3-way handshake to confirm the UDP client can
+ * receive traffic from which it claims to originate, that is, to
+ * prevent spoofed requests leading to reflected amplification.
  */
 static u_int32 derive_nonce(
 	sockaddr_u *	addr,
@@ -3645,13 +3649,11 @@ static u_int32 derive_nonce(
 {
 	static u_int32	salt[4];
 	static u_long	last_salt_update;
+	MD5_CTX		ctx;
 	union d_tag {
-		u_char	digest[EVP_MAX_MD_SIZE];
+		u_char	digest[MD5_DIGEST_LENGTH];
 		u_int32 extract;
 	}		d;
-	EVP_MD_CTX	*ctx;
-	u_int		len;
-	int rc;
 
 	while (!salt[0] || current_time - last_salt_update >= 3600) {
 		salt[0] = ntp_random();
@@ -3661,32 +3663,18 @@ static u_int32 derive_nonce(
 		last_salt_update = current_time;
 	}
 
-	ctx = EVP_MD_CTX_new();
-#   if defined(OPENSSL) && defined(EVP_MD_CTX_FLAG_NON_FIPS_ALLOW)
-	/* [Bug 3457] set flags and don't kill them again */
-	EVP_MD_CTX_set_flags(ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
-	rc = EVP_DigestInit_ex(ctx, EVP_get_digestbynid(NID_md5), NULL);
-#   else
-	rc = EVP_DigestInit(ctx, EVP_get_digestbynid(NID_md5));
-#   endif
-	if (!rc) {
-		msyslog(LOG_ERR, "EVP_DigestInit failed in '%s'", __func__);
-		return (0);
+	MD5Init(&ctx);
+	MD5Update(&ctx, salt, sizeof(salt));
+	MD5Update(&ctx, &ts_i, sizeof(ts_i));
+	MD5Update(&ctx, &ts_f, sizeof(ts_f));
+	if (IS_IPV4(addr)) {
+		MD5Update(&ctx, &SOCK_ADDR4(addr), sizeof(SOCK_ADDR4(addr)));
+	} else {
+		MD5Update(&ctx, &SOCK_ADDR6(addr), sizeof(SOCK_ADDR6(addr)));
 	}
-
-	EVP_DigestUpdate(ctx, salt, sizeof(salt));
-	EVP_DigestUpdate(ctx, &ts_i, sizeof(ts_i));
-	EVP_DigestUpdate(ctx, &ts_f, sizeof(ts_f));
-	if (IS_IPV4(addr))
-		EVP_DigestUpdate(ctx, &SOCK_ADDR4(addr),
-			         sizeof(SOCK_ADDR4(addr)));
-	else
-		EVP_DigestUpdate(ctx, &SOCK_ADDR6(addr),
-			         sizeof(SOCK_ADDR6(addr)));
-	EVP_DigestUpdate(ctx, &NSRCPORT(addr), sizeof(NSRCPORT(addr)));
-	EVP_DigestUpdate(ctx, salt, sizeof(salt));
-	EVP_DigestFinal(ctx, d.digest, &len);
-	EVP_MD_CTX_free(ctx);
+	MD5Update(&ctx, &NSRCPORT(addr), sizeof(NSRCPORT(addr)));
+	MD5Update(&ctx, salt, sizeof(salt));
+	MD5Final(d.digest, &ctx);
 
 	return d.extract;
 }
@@ -3986,7 +3974,7 @@ static void read_mru_list(
 	int			mincount;
 	u_int			maxlstint;
 	sockaddr_u		laddr;
-	struct interface *	lcladr;
+	endpt *			lcladr;
 	u_int			count;
 	u_int			ui;
 	u_int			uf;
@@ -4787,7 +4775,7 @@ unset_trap(
 int
 ctlsettrap(
 	sockaddr_u *raddr,
-	struct interface *linter,
+	endpt *linter,
 	int traptype,
 	int version
 	)
@@ -4910,7 +4898,7 @@ ctlsettrap(
 int
 ctlclrtrap(
 	sockaddr_u *raddr,
-	struct interface *linter,
+	endpt *linter,
 	int traptype
 	)
 {
@@ -4935,7 +4923,7 @@ ctlclrtrap(
 static struct ctl_trap *
 ctlfindtrap(
 	sockaddr_u *raddr,
-	struct interface *linter
+	endpt *linter
 	)
 {
 	size_t	n;
diff --git a/contrib/ntp/ntpd/ntp_crypto.c b/contrib/ntp/ntpd/ntp_crypto.c
index a5d8954a06b6..94f5f3c57ce9 100644
--- a/contrib/ntp/ntpd/ntp_crypto.c
+++ b/contrib/ntp/ntpd/ntp_crypto.c
@@ -267,17 +267,10 @@ session_key(
 		hdlen = 10 * sizeof(u_int32);
 		break;
 	}
-	ctx = EVP_MD_CTX_new();
-#   if defined(OPENSSL) && defined(EVP_MD_CTX_FLAG_NON_FIPS_ALLOW)
-	/* [Bug 3457] set flags and don't kill them again */
-	EVP_MD_CTX_set_flags(ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
-	EVP_DigestInit_ex(ctx, EVP_get_digestbynid(crypto_nid), NULL);
-#   else
+	ctx = digest_ctx;
 	EVP_DigestInit(ctx, EVP_get_digestbynid(crypto_nid));
-#   endif
 	EVP_DigestUpdate(ctx, (u_char *)header, hdlen);
 	EVP_DigestFinal(ctx, dgst, &len);
-	EVP_MD_CTX_free(ctx);
 	memcpy(&keyid, dgst, 4);
 	keyid = ntohl(keyid);
 	if (lifetime != 0) {
@@ -308,7 +301,7 @@ session_key(
 int
 make_keylist(
 	struct peer *peer,	/* peer structure pointer */
-	struct interface *dstadr /* interface */
+	endpt *dstadr		/* interface */
 	)
 {
 	EVP_MD_CTX *ctx;	/* signature context */
@@ -389,7 +382,7 @@ make_keylist(
 	if (tstamp != 0) {
 		if (vp->sig == NULL)
 			vp->sig = emalloc(sign_siglen);
-		ctx = EVP_MD_CTX_new();
+		ctx = digest_ctx;
 		EVP_SignInit(ctx, sign_digest);
 		EVP_SignUpdate(ctx, (u_char *)vp, 12);
 		EVP_SignUpdate(ctx, vp->ptr, sizeof(struct autokey));
@@ -398,7 +391,6 @@ make_keylist(
 			vp->siglen = htonl(len);
 			peer->flags |= FLAG_ASSOC;
 		}
-		EVP_MD_CTX_free(ctx);
 	}
 	DPRINTF(1, ("make_keys: %d %08x %08x ts %u fs %u poll %d\n",
 		    peer->keynumber, keyid, cookie, ntohl(vp->tstamp),
@@ -834,7 +826,7 @@ crypto_recv(
 			 * errors.
 			 */
 			if (vallen == (u_int)EVP_PKEY_size(host_pkey)) {
-				RSA *rsa = EVP_PKEY_get0_RSA(host_pkey);
+				RSA *rsa = EVP_PKEY_get1_RSA(host_pkey);
 				u_int32 *cookiebuf = malloc(RSA_size(rsa));
 				if (!cookiebuf) {
 					rval = XEVNT_CKY;
@@ -853,6 +845,7 @@ crypto_recv(
 					cookie = ntohl(*cookiebuf);
 					free(cookiebuf);
 				}
+				RSA_free(rsa);
 			} else {
 				rval = XEVNT_CKY;
 				break;
@@ -1548,16 +1541,15 @@ crypto_verify(
 	 * signature. If the identity exchange is verified, light the
 	 * proventic bit. What a relief.
 	 */
-	ctx = EVP_MD_CTX_new();
+	ctx = digest_ctx;
 	EVP_VerifyInit(ctx, peer->digest);
-	/* XXX: the "+ 12" needs to be at least documented... */
-	EVP_VerifyUpdate(ctx, (u_char *)&ep->tstamp, vallen + 12);
+	EVP_VerifyUpdate(ctx, (u_char *)&ep->tstamp, vallen + 
+			 sizeof(ep->tstamp) + sizeof(ep->fstamp) +
+			 sizeof(ep->vallen));
 	if (EVP_VerifyFinal(ctx, (u_char *)&ep->pkt[i], siglen,
 	    pkey) <= 0) {
-		EVP_MD_CTX_free(ctx);
 		return (XEVNT_SIG);
 	}
-	EVP_MD_CTX_free(ctx);
 
 	if (peer->crypto & CRYPTO_FLAG_VRFY)
 		peer->crypto |= CRYPTO_FLAG_PROV;
@@ -1583,6 +1575,7 @@ crypto_encrypt(
 	)
 {
 	EVP_PKEY *pkey;		/* public key */
+	RSA* rsa;		/* public key */
 	EVP_MD_CTX *ctx;	/* signature context */
 	tstamp_t tstamp;	/* NTP timestamp */
 	u_int32	temp32;
@@ -1610,8 +1603,9 @@ crypto_encrypt(
 	vp->ptr = emalloc(vallen);
 	puch = vp->ptr;
 	temp32 = htonl(*cookie);
-	if (RSA_public_encrypt(4, (u_char *)&temp32, puch,
-	    EVP_PKEY_get0_RSA(pkey), RSA_PKCS1_OAEP_PADDING) <= 0) {
+	rsa = EVP_PKEY_get1_RSA(pkey);
+	if (RSA_public_encrypt(4, (u_char *)&temp32, puch, rsa,
+	    RSA_PKCS1_OAEP_PADDING) <= 0) {
 		msyslog(LOG_ERR, "crypto_encrypt: %s",
 		    ERR_error_string(ERR_get_error(), NULL));
 		free(vp->ptr);
@@ -1619,11 +1613,14 @@ crypto_encrypt(
 		return (XEVNT_CKY);
 	}
 	EVP_PKEY_free(pkey);
+	pkey = NULL;
+	RSA_free(rsa);
+	rsa = NULL;
 	if (tstamp == 0)
 		return (XEVNT_OK);
 
 	vp->sig = emalloc(sign_siglen);
-	ctx = EVP_MD_CTX_new();
+	ctx = digest_ctx;
 	EVP_SignInit(ctx, sign_digest);
 	EVP_SignUpdate(ctx, (u_char *)&vp->tstamp, 12);
 	EVP_SignUpdate(ctx, vp->ptr, vallen);
@@ -1631,7 +1628,6 @@ crypto_encrypt(
 		INSIST(vallen <= sign_siglen);
 		vp->siglen = htonl(vallen);
 	}
-	EVP_MD_CTX_free(ctx);
 	return (XEVNT_OK);
 }
 
@@ -1849,7 +1845,7 @@ crypto_update(void)
 	if (hostval.tstamp == 0)
 		return;
 
-	ctx = EVP_MD_CTX_new();
+	ctx = digest_ctx;
 
 	/*
 	 * Sign public key and timestamps. The filestamp is derived from
@@ -1945,7 +1941,6 @@ crypto_update(void)
 	    ntohl(hostval.tstamp)); 
 	record_crypto_stats(NULL, statstr);
 	DPRINTF(1, ("crypto_update: %s\n", statstr));
-	EVP_MD_CTX_free(ctx);
 }
 
 /*
@@ -2003,7 +1998,7 @@ value_free(
  * Returns NTP seconds if in synch, 0 otherwise
  */
 tstamp_t
-crypto_time()
+crypto_time(void)
 {
 	l_fp	tstamp;		/* NTP time */
 
@@ -2075,7 +2070,7 @@ asn_to_calendar	(
 
 
 /*
- * bigdig() - compute a BIGNUM MD5 hash of a BIGNUM number.
+ * bighash() - compute a BIGNUM MD5 hash of a BIGNUM number.
  *
  * Returns void (no errors)
  */
@@ -2093,17 +2088,10 @@ bighash(
 	len = BN_num_bytes(bn);
 	ptr = emalloc(len);
 	BN_bn2bin(bn, ptr);
-	ctx = EVP_MD_CTX_new();
-#   if defined(OPENSSL) && defined(EVP_MD_CTX_FLAG_NON_FIPS_ALLOW)
-	/* [Bug 3457] set flags and don't kill them again */
-	EVP_MD_CTX_set_flags(ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
-	EVP_DigestInit_ex(ctx, EVP_md5(), NULL);
-#   else
+	ctx = digest_ctx;
 	EVP_DigestInit(ctx, EVP_md5());
-#   endif
 	EVP_DigestUpdate(ctx, ptr, len);
 	EVP_DigestFinal(ctx, dgst, &len);
-	EVP_MD_CTX_free(ctx);
 	BN_bin2bn(dgst, len, bk);
 	free(ptr);
 }
@@ -2169,12 +2157,12 @@ crypto_alice(
 	struct value *vp	/* value pointer */
 	)
 {
-	DSA	*dsa;		/* IFF parameters */
-	BN_CTX	*bctx;		/* BIGNUM context */
-	EVP_MD_CTX *ctx;	/* signature context */
-	tstamp_t tstamp;
-	u_int	len;
-	const BIGNUM *q;
+	const DSA	*dsa;		/* IFF parameters */
+	BN_CTX		*bctx;		/* BIGNUM context */
+	EVP_MD_CTX	*ctx;	/* signature context */
+	tstamp_t	tstamp;
+	u_int		len;
+	const BIGNUM	*q;
 
 	/*
 	 * The identity parameters must have correct format and content.
@@ -2216,7 +2204,7 @@ crypto_alice(
 		return (XEVNT_OK);
 
 	vp->sig = emalloc(sign_siglen);
-	ctx = EVP_MD_CTX_new();
+	ctx = digest_ctx; 
 	EVP_SignInit(ctx, sign_digest);
 	EVP_SignUpdate(ctx, (u_char *)&vp->tstamp, 12);
 	EVP_SignUpdate(ctx, vp->ptr, len);
@@ -2224,7 +2212,6 @@ crypto_alice(
 		INSIST(len <= sign_siglen);
 		vp->siglen = htonl(len);
 	}
-	EVP_MD_CTX_free(ctx);
 	return (XEVNT_OK);
 }
 
@@ -2243,7 +2230,8 @@ crypto_bob(
 	struct value *vp	/* value pointer */
 	)
 {
-	DSA	*dsa;		/* IFF parameters */
+	int	retv;		/* return value */
+	const DSA *dsa;		/* IFF parameters */
 	DSA_SIG	*sdsa;		/* DSA signature context fake */
 	BN_CTX	*bctx;		/* BIGNUM context */
 	EVP_MD_CTX *ctx;	/* signature context */
@@ -2262,6 +2250,10 @@ crypto_bob(
 		msyslog(LOG_NOTICE, "crypto_bob: scheme unavailable");
 		return (XEVNT_ID);
 	}
+
+	/* Initialize pointers that may need freeing in cleanup. */
+	sdsa = NULL;
+
 	dsa = EVP_PKEY_get0_DSA(iffkey_info->pkey);
 	DSA_get0_pqg(dsa, &p, &q, &g);
 	DSA_get0_key(dsa, NULL, &priv_key);
@@ -2306,16 +2298,16 @@ crypto_bob(
 	if (len == 0) {
 		msyslog(LOG_ERR, "crypto_bob: %s",
 		    ERR_error_string(ERR_get_error(), NULL));
-		DSA_SIG_free(sdsa);
-		return (XEVNT_ERR);
+		retv = XEVNT_ERR;
+		goto cleanup;
 	}
 	if (len > MAX_VALLEN) {
 		msyslog(LOG_ERR, "crypto_bob: signature is too big: %u",
 		    len);
-		DSA_SIG_free(sdsa);
-		return (XEVNT_LEN);
+		retv = XEVNT_ERR;
+		goto cleanup;
 	}
-	memset(vp, 0, sizeof(struct value));
+	ZERO(*vp);
 	tstamp = crypto_time();
 	vp->tstamp = htonl(tstamp);
 	vp->fstamp = htonl(iffkey_info->fstamp);
@@ -2323,13 +2315,14 @@ crypto_bob(
 	ptr = emalloc(len);
 	vp->ptr = ptr;
 	i2d_DSA_SIG(sdsa, &ptr);
-	DSA_SIG_free(sdsa);
-	if (tstamp == 0)
-		return (XEVNT_OK);
+	if (0 == tstamp) {
+		retv = XEVNT_OK;
+		goto cleanup;
+	}
 
 	/* XXX: more validation to make sure the sign fits... */
 	vp->sig = emalloc(sign_siglen);
-	ctx = EVP_MD_CTX_new();
+	ctx = digest_ctx;
 	EVP_SignInit(ctx, sign_digest);
 	EVP_SignUpdate(ctx, (u_char *)&vp->tstamp, 12);
 	EVP_SignUpdate(ctx, vp->ptr, len);
@@ -2337,8 +2330,11 @@ crypto_bob(
 		INSIST(len <= sign_siglen);
 		vp->siglen = htonl(len);
 	}
-	EVP_MD_CTX_free(ctx);
-	return (XEVNT_OK);
+	retv = XEVNT_OK;
+
+    cleanup:
+	DSA_SIG_free(sdsa);
+	return retv;
 }
 
 
@@ -2357,7 +2353,7 @@ crypto_iff(
 	struct peer *peer	/* peer structure pointer */
 	)
 {
-	DSA	*dsa;		/* IFF parameters */
+	const DSA *dsa;		/* IFF parameters */
 	BN_CTX	*bctx;		/* BIGNUM context */
 	DSA_SIG	*sdsa;		/* DSA parameters */
 	BIGNUM	*bn, *bk;
@@ -2501,7 +2497,7 @@ crypto_alice2(
 	struct value *vp	/* value pointer */
 	)
 {
-	RSA	*rsa;		/* GQ parameters */
+	const RSA *rsa;	/* GQ parameters */
 	BN_CTX	*bctx;		/* BIGNUM context */
 	EVP_MD_CTX *ctx;	/* signature context */
 	tstamp_t tstamp;
@@ -2546,7 +2542,7 @@ crypto_alice2(
 		return (XEVNT_OK);
 
 	vp->sig = emalloc(sign_siglen);
-	ctx = EVP_MD_CTX_new();
+	ctx = digest_ctx;
 	EVP_SignInit(ctx, sign_digest);
 	EVP_SignUpdate(ctx, (u_char *)&vp->tstamp, 12);
 	EVP_SignUpdate(ctx, vp->ptr, len);
@@ -2554,7 +2550,6 @@ crypto_alice2(
 		INSIST(len <= sign_siglen);
 		vp->siglen = htonl(len);
 	}
-	EVP_MD_CTX_free(ctx);
 	return (XEVNT_OK);
 }
 
@@ -2573,7 +2568,7 @@ crypto_bob2(
 	struct value *vp	/* value pointer */
 	)
 {
-	RSA	*rsa;		/* GQ parameters */
+	const RSA *rsa;		/* GQ parameters */
 	DSA_SIG	*sdsa;		/* DSA parameters */
 	BN_CTX	*bctx;		/* BIGNUM context */
 	EVP_MD_CTX *ctx;	/* signature context */
@@ -2651,7 +2646,7 @@ crypto_bob2(
 		return (XEVNT_OK);
 
 	vp->sig = emalloc(sign_siglen);
-	ctx = EVP_MD_CTX_new();
+	ctx = digest_ctx;
 	EVP_SignInit(ctx, sign_digest);
 	EVP_SignUpdate(ctx, (u_char *)&vp->tstamp, 12);
 	EVP_SignUpdate(ctx, vp->ptr, len);
@@ -2659,7 +2654,6 @@ crypto_bob2(
 		INSIST(len <= sign_siglen);
 		vp->siglen = htonl(len);
 	}
-	EVP_MD_CTX_free(ctx);
 	return (XEVNT_OK);
 }
 
@@ -2680,7 +2674,7 @@ crypto_gq(
 	struct peer *peer	/* peer structure pointer */
 	)
 {
-	RSA	*rsa;		/* GQ parameters */
+	const RSA *rsa;		/* GQ parameters */
 	BN_CTX	*bctx;		/* BIGNUM context */
 	DSA_SIG	*sdsa;		/* RSA signature context fake */
 	BIGNUM	*y, *v;
@@ -2845,7 +2839,7 @@ crypto_alice3(
 	struct value *vp	/* value pointer */
 	)
 {
-	DSA	*dsa;		/* MV parameters */
+	const DSA *dsa;		/* MV parameters */
 	BN_CTX	*bctx;		/* BIGNUM context */
 	EVP_MD_CTX *ctx;	/* signature context */
 	tstamp_t tstamp;
@@ -2890,7 +2884,7 @@ crypto_alice3(
 		return (XEVNT_OK);
 
 	vp->sig = emalloc(sign_siglen);
-	ctx = EVP_MD_CTX_new();
+	ctx = digest_ctx;
 	EVP_SignInit(ctx, sign_digest);
 	EVP_SignUpdate(ctx, (u_char *)&vp->tstamp, 12);
 	EVP_SignUpdate(ctx, vp->ptr, len);
@@ -2898,7 +2892,6 @@ crypto_alice3(
 		INSIST(len <= sign_siglen);
 		vp->siglen = htonl(len);
 	}
-	EVP_MD_CTX_free(ctx);
 	return (XEVNT_OK);
 }
 
@@ -2916,7 +2909,7 @@ crypto_bob3(
 	struct value *vp	/* value pointer */
 	)
 {
-	DSA	*dsa;		/* MV parameters */
+	const DSA *dsa;		/* MV parameters */
 	DSA	*sdsa;		/* DSA signature context fake */
 	BN_CTX	*bctx;		/* BIGNUM context */
 	EVP_MD_CTX *ctx;	/* signature context */
@@ -3003,7 +2996,7 @@ crypto_bob3(
 		return (XEVNT_OK);
 
 	vp->sig = emalloc(sign_siglen);
-	ctx = EVP_MD_CTX_new();
+	ctx = digest_ctx;
 	EVP_SignInit(ctx, sign_digest);
 	EVP_SignUpdate(ctx, (u_char *)&vp->tstamp, 12);
 	EVP_SignUpdate(ctx, vp->ptr, len);
@@ -3011,7 +3004,6 @@ crypto_bob3(
 		INSIST(len <= sign_siglen);
 		vp->siglen = htonl(len);
 	}
-	EVP_MD_CTX_free(ctx);
 	return (XEVNT_OK);
 }
 
@@ -3032,7 +3024,7 @@ crypto_mv(
 	struct peer *peer	/* peer structure pointer */
 	)
 {
-	DSA	*dsa;		/* MV parameters */
+	const DSA *dsa;		/* MV parameters */
 	DSA	*sdsa;		/* DSA parameters */
 	BN_CTX	*bctx;		/* BIGNUM context */
 	BIGNUM	*k, *u, *v;
@@ -3253,7 +3245,7 @@ cert_sign(
 	vp->siglen = 0;
 	if (tstamp != 0) {
 		vp->sig = emalloc(sign_siglen);
-		ctx = EVP_MD_CTX_new();
+		ctx = digest_ctx;
 		EVP_SignInit(ctx, sign_digest);
 		EVP_SignUpdate(ctx, (u_char *)vp, 12);
 		EVP_SignUpdate(ctx, vp->ptr, len);
@@ -3261,7 +3253,6 @@ cert_sign(
 			INSIST(len <= sign_siglen);
 			vp->siglen = htonl(len);
 		}
-		EVP_MD_CTX_free(ctx);
 	}
 #ifdef DEBUG
 	if (debug > 1)
@@ -3909,7 +3900,6 @@ crypto_setup(void)
 		    "crypto_setup: spurious crypto command");
 		return;
 	}
-	ssl_check_version();
 
 	/*
 	 * Load required random seed file and seed the random number
@@ -4168,5 +4158,5 @@ exten_payload_size(
 	return (u_int)data_size;
 }
 # else	/* !AUTOKEY follows */
-int ntp_crypto_bs_pubkey;
+NONEMPTY_TRANSLATION_UNIT
 # endif	/* !AUTOKEY */
diff --git a/contrib/ntp/ntpd/ntp_io.c b/contrib/ntp/ntpd/ntp_io.c
index bb35ffd68511..9d79fe493d9b 100644
--- a/contrib/ntp/ntpd/ntp_io.c
+++ b/contrib/ntp/ntpd/ntp_io.c
@@ -177,11 +177,14 @@ endpt *	any_interface;		/* wildcard ipv4 interface */
 endpt *	any6_interface;		/* wildcard ipv6 interface */
 endpt *	loopback_interface;	/* loopback ipv4 interface */
 
-static isc_boolean_t broadcast_client_enabled;	/* is broadcast client enabled */
+static isc_boolean_t broadcast_client_enabled;
 u_int sys_ifnum;			/* next .ifnum to assign */
 int ninterfaces;			/* Total number of interfaces */
 
-int disable_dynamic_updates;		/* scan interfaces once only */
+int no_periodic_scan;		/* network endpoint scans */
+int scan_addrs_once;		/* because dropped privs */
+int nonlocal_v4_addr_up;	/* should we try IPv4 pool? */
+int nonlocal_v6_addr_up;	/* should we try IPv6 pool? */
 
 #ifdef REFCLOCK
 /*
@@ -210,7 +213,7 @@ static int	update_interfaces(u_short, interface_receiver_t,
 static void	remove_interface(endpt *);
 static endpt *	create_interface(u_short, endpt *);
 
-static int	is_wildcard_addr	(const sockaddr_u *);
+static inline int is_wildcard_addr(const sockaddr_u *psau);
 
 /*
  * Multicast functions
@@ -229,7 +232,6 @@ static	isc_boolean_t	socket_multicast_disable(endpt *, sockaddr_u *);
 
 #ifdef DEBUG
 static void interface_dump	(const endpt *);
-static void sockaddr_dump	(const sockaddr_u *);
 static void print_interface	(const endpt *, const char *, const char *);
 #define DPRINT_INTERFACE(level, args) do { if (debug >= (level)) { print_interface args; } } while (0)
 #else
@@ -280,13 +282,13 @@ static int	addr_samesubnet	(const sockaddr_u *, const sockaddr_u *,
 static	int	create_sockets	(u_short);
 static	SOCKET	open_socket	(sockaddr_u *, int, int, endpt *);
 static	void	set_reuseaddr	(int);
-static	isc_boolean_t	socket_broadcast_enable	 (struct interface *, SOCKET, sockaddr_u *);
+static	isc_boolean_t	socket_broadcast_enable	 (endpt *, SOCKET, sockaddr_u *);
 
 #if !defined(HAVE_IO_COMPLETION_PORT) && !defined(HAVE_SIGNALED_IO)
 static	char *	fdbits		(int, const fd_set *);
 #endif
 #ifdef  OS_MISSES_SPECIFIC_ROUTE_UPDATES
-static	isc_boolean_t	socket_broadcast_disable (struct interface *, sockaddr_u *);
+static	isc_boolean_t	socket_broadcast_disable (endpt *, sockaddr_u *);
 #endif
 
 typedef struct remaddr remaddr_t;
@@ -305,10 +307,16 @@ endpt *		mc6_list;	/* IPv6 mcast-capable unicast endpts */
 static endpt *	wildipv4;
 static endpt *	wildipv6;
 
+#define		RFC3927_ADDR	0xa9fe0000	/* 169.254. */
+#define		RFC3927_MASK	0xffff0000
+#define		IS_AUTOCONF(addr4)					\
+		((SRCADR(addr4) & RFC3927_MASK) == RFC3927_ADDR)
+
 #ifdef SYS_WINNT
 int accept_wildcard_if_for_winnt;
 #else
 const int accept_wildcard_if_for_winnt = FALSE;
+#define		init_io_completion_port()	do {} while (FALSE)
 #endif
 
 static void	add_fd_to_list		(SOCKET, enum desc_type);
@@ -316,7 +324,7 @@ static endpt *	find_addr_in_list	(sockaddr_u *);
 static endpt *	find_flagged_addr_in_list(sockaddr_u *, u_int32);
 static void	delete_addr_from_list	(sockaddr_u *);
 static void	delete_interface_from_list(endpt *);
-static void	close_and_delete_fd_from_list(SOCKET);
+static void	close_and_delete_fd_from_list(SOCKET, endpt *);
 static void	add_addr_to_list	(sockaddr_u *, endpt *);
 static void	create_wildcards	(u_short);
 static endpt *	findlocalinterface	(sockaddr_u *, int, int);
@@ -337,7 +345,7 @@ static int		cmp_addr_distance(const sockaddr_u *,
  * Routines to read the ntp packets
  */
 #if !defined(HAVE_IO_COMPLETION_PORT)
-static inline int	read_network_packet	(SOCKET, struct interface *, l_fp);
+static inline int	read_network_packet	(SOCKET, endpt *, l_fp);
 static void		ntpd_addremove_io_fd	(int, int, int);
 static void 		input_handler_scan	(const l_fp*, const fd_set*);
 static int/*BOOL*/	sanitize_fdset		(int errc);
@@ -454,15 +462,14 @@ init_io(void)
 	/* Init buffer free list and stat counters */
 	init_recvbuff(RECV_INIT);
 	/* update interface every 5 minutes as default */
-	interface_interval = 300;
+	endpt_scan_period = 301;
 
 #ifdef WORK_PIPE
 	addremove_io_fd = &ntpd_addremove_io_fd;
 #endif
 
-#if defined(SYS_WINNT)
 	init_io_completion_port();
-#elif defined(HAVE_SIGNALED_IO)
+#if defined(HAVE_SIGNALED_IO)
 	(void) set_signal(input_handler);
 #endif
 }
@@ -528,11 +535,8 @@ interface_dump(const endpt *itf)
 	printf("fd = %lld\n", (long long)itf->fd);
 	printf("bfd = %lld\n", (long long)itf->bfd);
 	printf("sin = %s,\n", stoa(&itf->sin));
-	sockaddr_dump(&itf->sin);
 	printf("bcast = %s,\n", stoa(&itf->bcast));
-	sockaddr_dump(&itf->bcast);
 	printf("mask = %s,\n", stoa(&itf->mask));
-	sockaddr_dump(&itf->mask);
 	printf("name = %s\n", itf->name);
 	printf("flags = 0x%08x\n", itf->flags);
 	printf("last_ttl = %d\n", itf->last_ttl);
@@ -546,27 +550,6 @@ interface_dump(const endpt *itf)
 	printf("phase = %u\n", itf->phase);
 }
 
-/*
- * sockaddr_dump - hex dump the start of a sockaddr_u
- */
-static void
-sockaddr_dump(const sockaddr_u *psau)
-{
-	/* Limit the size of the sockaddr_in6 hex dump */
-	const int maxsize = min(32, sizeof(psau->sa6));
-	const u_char *	cp;
-	int		i;
-
-	/* XXX: Should we limit maxsize based on psau->saX.sin_family? */
-	cp = (const void *)&psau->sa6;
-
-	for(i = 0; i < maxsize; i++) {
-		printf("%02x", *cp++);
-		if (!((i + 1) % 4))
-			printf(" ");
-	}
-	printf("\n");
-}
 
 /*
  * print_interface - helper to output debug information
@@ -637,7 +620,7 @@ add_asyncio_reader(
 }
 
 /*
- * remove asynchio_reader
+ * remove asyncio_reader
  */
 static void
 remove_asyncio_reader(
@@ -649,9 +632,9 @@ remove_asyncio_reader(
 	UNLINK_SLIST(unlinked, asyncio_reader_list, reader, link,
 	    struct asyncio_reader);
 
-	if (reader->fd != INVALID_SOCKET)
-		close_and_delete_fd_from_list(reader->fd);
-
+	if (reader->fd != INVALID_SOCKET) {
+		close_and_delete_fd_from_list(reader->fd, NULL);
+	}
 	reader->fd = INVALID_SOCKET;
 }
 #endif /* !defined(HAVE_IO_COMPLETION_PORT) && defined(HAS_ROUTING_SOCKET) */
@@ -743,7 +726,7 @@ interface_enumerate(
 /*
  * do standard initialization of interface structure
  */
-static void
+static inline void
 init_interface(
 	endpt *ep
 	)
@@ -760,20 +743,19 @@ init_interface(
  * template structure or via standard initialization
  * function
  */
-static struct interface *
+static endpt *
 new_interface(
-	struct interface *interface
+	endpt *protot
 	)
 {
-	struct interface *	iface;
+	endpt *	iface;
 
 	iface = emalloc(sizeof(*iface));
-
-	if (NULL == interface)
-		init_interface(iface);
-	else				/* use the template */
-		memcpy(iface, interface, sizeof(*iface));
-
+	if (NULL == protot) {
+		ZERO(*iface);
+	} else {
+		memcpy(iface, protot, sizeof(*iface));
+	}
 	/* count every new instance of an interface in the system */
 	iface->ifnum = sys_ifnum++;
 	iface->starttime = current_time;
@@ -814,19 +796,16 @@ add_interface(
 	endpt **	pmclisthead;
 	endpt *		scan;
 	endpt *		scan_next;
-	endpt *		unlinked;
-	sockaddr_u *	addr;
-	int		ep_local;
-	int		scan_local;
 	int		same_subnet;
-	int		ep_univ_iid;	/* iface ID from MAC address */
-	int		scan_univ_iid;	/* see RFC 4291 */
-	int		ep_privacy;	/* random local iface ID */
-	int		scan_privacy;	/* see RFC 4941 */
 	int		rc;
 
 	/* Calculate the refid */
 	ep->addr_refid = addr2refid(&ep->sin);
+#    ifdef WORDS_BIGENDIAN
+	if (IS_IPV6(&ep->sin)) {
+		ep->old_refid = BYTESWAP32(ep->addr_refid);
+	}
+#    endif
 	/* link at tail so ntpdc -c ifstats index increases each row */
 	LINK_TAIL_SLIST(ep_list, ep, elink, endpt);
 	ninterfaces++;
@@ -843,101 +822,26 @@ add_interface(
 			 ? &mc4_list
 			 : &mc6_list;
 
-	if (AF_INET6 == ep->family) {
-		ep_local =
-		    IN6_IS_ADDR_LINKLOCAL(PSOCK_ADDR6(&ep->sin)) ||
-		    IN6_IS_ADDR_SITELOCAL(PSOCK_ADDR6(&ep->sin));
-		ep_univ_iid = IS_IID_UNIV(&ep->sin);
-		ep_privacy = !!(INT_PRIVACY & ep->flags);
-	} else {
-		ep_local = FALSE;
-		ep_univ_iid = FALSE;
-		ep_privacy = FALSE;
-	}
-	DPRINTF(4, ("add_interface mcast-capable %s%s%s%s\n",
-		    stoa(&ep->sin),
-		    (ep_local) ? " link/scope-local" : "",
-		    (ep_univ_iid) ? " univ-IID" : "",
-		    (ep_privacy) ? " privacy" : ""));
 	/*
-	 * If we have multiple local addresses on the same network
-	 * interface, and some are link- or site-local, do not multicast
-	 * out from the link-/site-local addresses by default, to avoid
-	 * duplicate manycastclient associations between v6 peers using
-	 * link-local and global addresses.  link-local can still be
-	 * chosen using "nic ignore myv6globalprefix::/64".
-	 * Similarly, if we have multiple global addresses from the same
-	 * prefix on the same network interface, multicast from one,
-	 * preferring EUI-64, then static, then least RFC 4941 privacy
-	 * addresses.
+	 * If we have multiple global addresses from the same prefix
+	 * on the same network interface, multicast from one.
 	 */
 	for (scan = *pmclisthead; scan != NULL; scan = scan_next) {
 		scan_next = scan->mclink;
-		if (ep->family != scan->family)
-			continue;
-		if (strcmp(ep->name, scan->name))
+		if (   ep->family != scan->family
+		    || ep->ifindex != scan->ifindex) {
 			continue;
+		}
 		same_subnet = addr_samesubnet(&ep->sin, &ep->mask,
 					      &scan->sin, &scan->mask);
-		if (AF_INET6 == ep->family) {
-			addr = &scan->sin;
-			scan_local =
-			    IN6_IS_ADDR_LINKLOCAL(PSOCK_ADDR6(addr)) ||
-			    IN6_IS_ADDR_SITELOCAL(PSOCK_ADDR6(addr));
-			scan_univ_iid = IS_IID_UNIV(addr);
-			scan_privacy = !!(INT_PRIVACY & scan->flags);
-		} else {
-			scan_local = FALSE;
-			scan_univ_iid = FALSE;
-			scan_privacy = FALSE;
-		}
-		DPRINTF(4, ("add_interface mcast-capable scan %s%s%s%s\n",
-			    stoa(&scan->sin),
-			    (scan_local) ? " link/scope-local" : "",
-			    (scan_univ_iid) ? " univ-IID" : "",
-			    (scan_privacy) ? " privacy" : ""));
-		if ((ep_local && !scan_local) || (same_subnet &&
-		    ((ep_privacy && !scan_privacy) ||
-		     (!ep_univ_iid && scan_univ_iid)))) {
-			DPRINTF(4, ("did not add %s to %s of IPv6 multicast-capable list which already has %s\n",
-				stoa(&ep->sin),
-				(ep_local)
-				    ? "tail"
-				    : "head",
-				stoa(&scan->sin)));
+		if (same_subnet) {
+			DPRINTF(4, ("did not add %s to multicast-capable list"
+				    "which already has %s\n",
+				    stoa(&ep->sin), stoa(&scan->sin)));
 			return;
 		}
-		if ((scan_local && !ep_local) || (same_subnet &&
-		    ((scan_privacy && !ep_privacy) ||
-		     (!scan_univ_iid && ep_univ_iid)))) {
-			UNLINK_SLIST(unlinked, *pmclisthead,
-				     scan, mclink, endpt);
-			DPRINTF(4, ("%s %s from IPv6 multicast-capable list to add %s\n",
-				(unlinked != scan)
-				    ? "Failed to remove"
-				    : "removed",
-				stoa(&scan->sin), stoa(&ep->sin)));
-		}
 	}
-	/*
-	 * Add link/site local at the tail of the multicast-
-	 * capable unicast interfaces list, so that ntpd will
-	 * send from global addresses before link-/site-local
-	 * ones.
-	 */
-	if (ep_local)
-		LINK_TAIL_SLIST(*pmclisthead, ep, mclink, endpt);
-	else
-		LINK_SLIST(*pmclisthead, ep, mclink);
-	DPRINTF(4, ("added %s to %s of IPv%s multicast-capable unicast local address list\n",
-		stoa(&ep->sin),
-		(ep_local)
-		    ? "tail"
-		    : "head",
-		(AF_INET == ep->family)
-		    ? "4"
-		    : "6"));
-
+	LINK_SLIST(*pmclisthead, ep, mclink);
 	if (INVALID_SOCKET == ep->fd)
 		return;
 
@@ -987,6 +891,7 @@ remove_interface(
 	endpt *		unlinked;
 	endpt **	pmclisthead;
 	sockaddr_u	resmask;
+	int/*BOOL*/	success;
 
 	UNLINK_SLIST(unlinked, ep_list, ep, elink, endpt);
 	if (!ep->ignore_packets && INT_MULTICAST & ep->flags) {
@@ -1007,7 +912,9 @@ remove_interface(
 
 	if (ep->fd != INVALID_SOCKET) {
 		msyslog(LOG_INFO,
-			"Deleting interface #%d %s, %s#%d, interface stats: received=%ld, sent=%ld, dropped=%ld, active_time=%ld secs",
+			"Deleting %d %s, [%s]:%hd, stats:"
+			" received=%ld, sent=%ld, dropped=%ld,"
+			" active_time=%ld secs",
 			ep->ifnum,
 			ep->name,
 			stoa(&ep->sin),
@@ -1016,10 +923,7 @@ remove_interface(
 			ep->sent,
 			ep->notsent,
 			current_time - ep->starttime);
-#	    ifdef HAVE_IO_COMPLETION_PORT
-		io_completion_port_remove_socket(ep->fd, ep);
-#	    endif
-		close_and_delete_fd_from_list(ep->fd);
+		close_and_delete_fd_from_list(ep->fd, ep);
 		ep->fd = INVALID_SOCKET;
 	}
 
@@ -1027,10 +931,7 @@ remove_interface(
 		msyslog(LOG_INFO,
 			"stop listening for broadcasts to %s on interface #%d %s",
 			stoa(&ep->bcast), ep->ifnum, ep->name);
-#	    ifdef HAVE_IO_COMPLETION_PORT
-		io_completion_port_remove_socket(ep->bfd, ep);
-#	    endif
-		close_and_delete_fd_from_list(ep->bfd);
+		close_and_delete_fd_from_list(ep->bfd, ep);
 		ep->bfd = INVALID_SOCKET;
 	}
 #   ifdef HAVE_IO_COMPLETION_PORT
@@ -1042,8 +943,14 @@ remove_interface(
 
 	/* remove restrict interface entry */
 	SET_HOSTMASK(&resmask, AF(&ep->sin));
-	hack_restrict(RESTRICT_REMOVEIF, &ep->sin, &resmask,
-		      -3, RESM_NTPONLY | RESM_INTERFACE, RES_IGNORE, 0);
+	success = hack_restrict(RESTRICT_REMOVEIF, &ep->sin, &resmask, 0,
+				RESM_NTPONLY | RESM_INTERFACE, 0, 0);
+	if (!success) {
+		msyslog(LOG_ERR,
+			"unable to remove self-restriction for %s",
+			stoa(&ep->sin));
+	}
+
 }
 
 
@@ -1073,7 +980,7 @@ create_wildcards(
 #endif
 	sockaddr_u		wildaddr;
 	nic_rule_action		action;
-	struct interface *	wildif;
+	endpt *			wildif;
 
 	/*
 	 * silence "potentially uninitialized" warnings from VC9
@@ -1404,9 +1311,6 @@ convert_isc_if(
 	u_short port
 	)
 {
-	const u_char v6loop[16] = {0, 0, 0, 0, 0, 0, 0, 0,
-				   0, 0, 0, 0, 0, 0, 0, 1};
-
 	strlcpy(itf->name, isc_if->name, sizeof(itf->name));
 	itf->ifindex = isc_if->ifindex;
 	itf->family = (u_short)isc_if->af;
@@ -1456,15 +1360,8 @@ convert_isc_if(
 	 * Clear the loopback flag if the address is not localhost.
 	 * http://bugs.ntp.org/1683
 	 */
-	if (INT_LOOPBACK & itf->flags) {
-		if (AF_INET == itf->family) {
-			if (127 != (SRCADR(&itf->sin) >> 24))
-				itf->flags &= ~INT_LOOPBACK;
-		} else {
-			if (memcmp(v6loop, NSRCADR6(&itf->sin),
-				   sizeof(NSRCADR6(&itf->sin))))
-				itf->flags &= ~INT_LOOPBACK;
-		}
+	if ((INT_LOOPBACK & itf->flags) && !IS_LOOPBACK_ADDR(&itf->sin)) {
+		itf->flags &= ~INT_LOOPBACK;
 	}
 }
 
@@ -1480,33 +1377,33 @@ convert_isc_if(
  */
 static int
 refresh_interface(
-	struct interface * interface
+	endpt *	iface
 	)
 {
 #ifdef  OS_MISSES_SPECIFIC_ROUTE_UPDATES
-	if (interface->fd != INVALID_SOCKET) {
-		int bcast = (interface->flags & INT_BCASTXMIT) != 0;
+	if (iface->fd != INVALID_SOCKET) {
+		int bcast = (iface->flags & INT_BCASTXMIT) != 0;
 		/* as we forcibly close() the socket remove the
 		   broadcast permission indication */
 		if (bcast)
-			socket_broadcast_disable(interface, &interface->sin);
+			socket_broadcast_disable(iface, &iface->sin);
 
-		close_and_delete_fd_from_list(interface->fd);
+		close_and_delete_fd_from_list(iface->fd);
 
 		/* create new socket picking up a new first hop binding
 		   at connect() time */
-		interface->fd = open_socket(&interface->sin,
-					    bcast, 0, interface);
+		iface->fd = open_socket(&iface->sin,
+					    bcast, 0, iface);
 		 /*
 		  * reset TTL indication so TTL is is set again
 		  * next time around
 		  */
-		interface->last_ttl = 0;
-		return (interface->fd != INVALID_SOCKET);
+		iface->last_ttl = 0;
+		return (iface->fd != INVALID_SOCKET);
 	} else
 		return 0;	/* invalid sockets are not refreshable */
 #else /* !OS_MISSES_SPECIFIC_ROUTE_UPDATES */
-	return (interface->fd != INVALID_SOCKET);
+	return (iface->fd != INVALID_SOCKET);
 #endif /* !OS_MISSES_SPECIFIC_ROUTE_UPDATES */
 }
 
@@ -1516,20 +1413,21 @@ refresh_interface(
 void
 interface_update(
 	interface_receiver_t	receiver,
-	void *			data)
+	void *			data
+	)
 {
 	int new_interface_found;
 
-	if (disable_dynamic_updates)
+	if (scan_addrs_once) {
 		return;
-
+	}
 	BLOCKIO();
 	new_interface_found = update_interfaces(NTP_PORT, receiver, data);
 	UNBLOCKIO();
 
-	if (!new_interface_found)
+	if (!new_interface_found) {
 		return;
-
+	}
 #ifdef DEBUG
 	msyslog(LOG_DEBUG, "new interface(s) found: waking up resolver");
 #endif
@@ -1552,13 +1450,11 @@ sau_from_netaddr(
 	switch (pna->family) {
 
 	case AF_INET:
-		memcpy(&psau->sa4.sin_addr, &pna->type.in,
-		       sizeof(psau->sa4.sin_addr));
+		psau->sa4.sin_addr = pna->type.in;
 		break;
 
 	case AF_INET6:
-		memcpy(&psau->sa6.sin6_addr, &pna->type.in6,
-		       sizeof(psau->sa6.sin6_addr));
+		psau->sa6.sin6_addr = pna->type.in6;
 		break;
 	}
 }
@@ -1581,6 +1477,30 @@ is_wildcard_addr(
 }
 
 
+isc_boolean_t
+is_linklocal(
+	sockaddr_u *		psau
+)
+{
+	struct in6_addr *	p6addr;
+
+	if (IS_IPV6(psau)) {
+		p6addr = &psau->sa6.sin6_addr;
+		if (   IN6_IS_ADDR_LINKLOCAL(p6addr)
+		    || IN6_IS_ADDR_SITELOCAL(p6addr)) {
+
+			return TRUE;
+		}
+	} else if (IS_IPV4(psau)) {
+		/* autoconf are link-local 169.254.0.0/16 */
+		if (IS_AUTOCONF(psau)) {
+			return TRUE;
+		}
+	}
+	return FALSE;
+}
+
+
 #ifdef OS_NEEDS_REUSEADDR_FOR_IFADDRBIND
 /*
  * enable/disable re-use of wildcard address socket
@@ -1591,7 +1511,7 @@ set_wildcard_reuse(
 	int	on
 	)
 {
-	struct interface *any;
+	endpt *any;
 	SOCKET fd = INVALID_SOCKET;
 
 	any = ANY_INTERFACE_BYFAM(family);
@@ -1722,13 +1642,18 @@ is_valid(
  *
  * toggle configuration phase
  *
- * Phase 1:
+ * Phase 1a:
  * forall currently existing interfaces
  *   if address is known:
  *	drop socket - rebind again
  *
  *   if address is NOT known:
- *	attempt to create a new interface entry
+ *	Add address to list of new addresses
+ * 
+ * Phase 1b:
+ *	Scan the list of new addresses marking IPv6 link-local addresses
+ *	   which also have a global v6 address using the same OS ifindex.
+ *	Attempt to create a new interface entry
  *
  * Phase 2:
  * forall currently known non MCAST and WILDCARD interfaces
@@ -1759,17 +1684,22 @@ update_interfaces(
 	endpt			enumep;
 	endpt *			ep;
 	endpt *			next_ep;
+	endpt *			newaddrs;
+	endpt *			newaddrs_tail;
+	endpt *			ep2;
 
 	DPRINTF(3, ("update_interfaces(%d)\n", port));
 
 	/*
-	 * phase one - scan interfaces
-	 * - create those that are not found
-	 * - update those that are found
+	 * phase 1a - scan OS local addresses
+	 * - update those that ntpd already knows
+	 * - build a list of newly-discovered addresses.
 	 */
 
 	new_interface_found = FALSE;
+	nonlocal_v4_addr_up = nonlocal_v6_addr_up = FALSE;
 	iter = NULL;
+	newaddrs = newaddrs_tail = NULL;
 	result = isc_interfaceiter_create(mctx, &iter);
 
 	if (result != ISC_R_SUCCESS)
@@ -1787,9 +1717,9 @@ update_interfaces(
 
 		result = isc_interfaceiter_current(iter, &isc_if);
 
-		if (result != ISC_R_SUCCESS)
+		if (result != ISC_R_SUCCESS) {
 			break;
-
+		}
 		/* See if we have a valid family to use */
 		family = isc_if.address.family;
 		if (AF_INET != family && AF_INET6 != family)
@@ -1854,6 +1784,19 @@ update_interfaces(
 		if (!is_valid(&enumep.sin, isc_if.name))
 			continue;
 
+		/*
+		 * Keep track of having non-linklocal connectivity
+		 * for IPv4 and IPv6 so we don't solicit pool hosts
+		 * when it can't work.
+		 */
+		if (   !(INT_LOOPBACK & enumep.flags)
+		    && !is_linklocal(&enumep.sin)) {
+			if (IS_IPV6(&enumep.sin)) {
+				nonlocal_v6_addr_up = TRUE;
+			} else {
+				nonlocal_v4_addr_up = TRUE;
+			}
+		}
 		/*
 		 * map to local *address* in order to map all duplicate
 		 * interfaces to an endpt structure with the appropriate
@@ -1862,106 +1805,131 @@ update_interfaces(
 		 */
 		ep = getinterface(&enumep.sin, INT_WILDCARD);
 
-		if (ep != NULL && refresh_interface(ep)) {
-			/*
-			 * found existing and up to date interface -
-			 * mark present.
-			 */
-			if (ep->phase != sys_interphase) {
-				/*
-				 * On a new round we reset the name so
-				 * the interface name shows up again if
-				 * this address is no longer shared.
-				 * We reset ignore_packets from the
-				 * new prototype to respect any runtime
-				 * changes to the nic rules.
-				 */
-				strlcpy(ep->name, enumep.name,
-					sizeof(ep->name));
-				ep->ignore_packets =
-					    enumep.ignore_packets;
+		if (NULL == ep) {
+			ep = emalloc(sizeof(*ep));
+			memcpy(ep, &enumep, sizeof(*ep));
+			if (NULL != newaddrs_tail) {
+				newaddrs_tail->elink = ep;
+				newaddrs_tail = ep;
 			} else {
-				/* name collision - rename interface */
-				strlcpy(ep->name, "*multiple*",
-					sizeof(ep->name));
+				newaddrs_tail = newaddrs = ep;
 			}
+			continue;
+		}
 
-			DPRINT_INTERFACE(4, (ep, "updating ",
-					     " present\n"));
-
-			if (ep->ignore_packets !=
-			    enumep.ignore_packets) {
-				/*
-				 * We have conflicting configurations
-				 * for the interface address. This is
-				 * caused by using -I <interfacename>
-				 * for an interface that shares its
-				 * address with other interfaces. We
-				 * can not disambiguate incoming
-				 * packets delivered to this socket
-				 * without extra syscalls/features.
-				 * These are not (commonly) available.
-				 * Note this is a more unusual
-				 * configuration where several
-				 * interfaces share an address but
-				 * filtering via interface name is
-				 * attempted.  We resolve the
-				 * configuration conflict by disabling
-				 * the processing of received packets.
-				 * This leads to no service on the
-				 * interface address where the conflict
-				 * occurs.
-				 */
-				msyslog(LOG_ERR,
-					"WARNING: conflicting enable configuration for interfaces %s and %s for address %s - unsupported configuration - address DISABLED",
-					enumep.name, ep->name,
-					stoa(&enumep.sin));
-
-				ep->ignore_packets = ISC_TRUE;
-			}
+		if (!refresh_interface(ep)) {
+			/*
+			 * Refreshing failed, we will delete the endpt
+			 * in phase 2 because it was not marked current.
+			 * We can bind to the address as the refresh
+			 * code already closed the endpt's socket.
+			*/
+			continue;
+		}
+		/*
+		 * found existing and up to date interface -
+		 * mark present.
+		 */
+		if (ep->phase != sys_interphase) {
+			/*
+			 * On a new round we reset the name so
+			 * the interface name shows up again if
+			 * this address is no longer shared.
+			 * We reset ignore_packets from the
+			 * new prototype to respect any runtime
+			 * changes to the nic rules.
+			 */
+			strlcpy(ep->name, enumep.name, sizeof(ep->name));
+			ep->ignore_packets = enumep.ignore_packets;
+		} else {
+			/*
+			 * DLH: else branch might be dead code from
+			 * when both address and name were compared.
+			 */
+			msyslog(LOG_INFO, "%s on %u %s -> *multiple*",
+				stoa(&ep->sin), ep->ifnum, ep->name);
+			/* name collision - rename interface */
+			strlcpy(ep->name, "*multiple*", sizeof(ep->name));
+		}
 
-			ep->phase = sys_interphase;
+		DPRINT_INTERFACE(4, (ep, "updating ", " present\n"));
 
-			ifi.action = IFS_EXISTS;
-			ifi.ep = ep;
-			if (receiver != NULL)
-				(*receiver)(data, &ifi);
-		} else {
+		if (ep->ignore_packets != enumep.ignore_packets) {
 			/*
-			 * This is new or refreshing failed - add to
-			 * our interface list.  If refreshing failed we
-			 * will delete the interface structure in phase
-			 * 2 as the interface was not marked current.
-			 * We can bind to the address as the refresh
-			 * code already closed the offending socket
+			 * We have conflicting configurations for the
+			 * address. This can happen with
+			 * -I <interfacename> on the command line for an
+			 *  interface that shares its address with other
+			 * interfaces. We cannot disambiguate incoming
+			 * packets delivered to this socket without extra
+			 * syscalls/features.  Note this is an unusual
+			 * configuration where several interfaces share
+			 * an address but filtering via interface name is
+			 * attempted.  We resolve the config conflict by
+			 * disabling the processing of received packets.
+			 * This leads to no service on the address where
+			 * the conflict occurs.
 			 */
-			ep = create_interface(port, &enumep);
-
-			if (ep != NULL) {
-				ifi.action = IFS_CREATED;
-				ifi.ep = ep;
-				if (receiver != NULL)
-					(*receiver)(data, &ifi);
-
-				new_interface_found = TRUE;
-				DPRINT_INTERFACE(3,
-					(ep, "updating ",
-					 " new - created\n"));
-			} else {
-				DPRINT_INTERFACE(3,
-					(&enumep, "updating ",
-					 " new - creation FAILED"));
+			msyslog(LOG_WARNING,
+				"conflicting listen configuration between"
+				" %s and %s for %s, disabled",
+				enumep.name, ep->name, stoa(&enumep.sin));
 
-				msyslog(LOG_INFO,
-					"failed to init interface for address %s",
-					stoa(&enumep.sin));
-				continue;
-			}
+			ep->ignore_packets = TRUE;
+		}
+
+		ep->phase = sys_interphase;
+
+		ifi.action = IFS_EXISTS;
+		ifi.ep = ep;
+		if (receiver != NULL) {
+			(*receiver)(data, &ifi);
 		}
 	}
 
 	isc_interfaceiter_destroy(&iter);
 
+	/*
+	 * Phase 1b
+	 */
+	for (ep = newaddrs; ep != NULL; ep = ep->elink) {
+		if (IS_IPV6(&ep->sin) && is_linklocal(&ep->sin)) {
+			for (ep2 = newaddrs; ep2 != NULL; ep2 = ep2->elink) {
+				if (   IS_IPV6(&ep2->sin)
+				    && ep != ep2
+				    && !is_linklocal(&ep2->sin)) {
+
+					ep->flags |= INT_LL_OF_GLOB;
+					break;
+				}
+			}
+		}
+	}
+	for (ep2 = newaddrs; ep2 != NULL; ep2 = next_ep) {
+		next_ep = ep2->elink;
+		ep2->elink = NULL;
+		ep = create_interface(port, ep2);
+		if (ep != NULL) {
+			ifi.action = IFS_CREATED;
+			ifi.ep = ep;
+			if (receiver != NULL) {
+				(*receiver)(data, &ifi);
+			}
+			new_interface_found = TRUE;
+			DPRINT_INTERFACE(3,
+				(ep, "updating ", " new - created\n"));
+		}
+		else {
+			DPRINT_INTERFACE(3,
+				(ep, "updating ", " new - FAILED"));
+
+			msyslog(LOG_ERR,
+				"cannot bind address %s",
+				stoa(&ep->sin));
+		}
+		free(ep2);
+	}
+
 	/*
 	 * phase 2 - delete gone interfaces - reassigning peers to
 	 * other interfaces
@@ -1986,20 +1954,20 @@ update_interfaces(
 
 		ifi.action = IFS_DELETED;
 		ifi.ep = ep;
-		if (receiver != NULL)
+		if (receiver != NULL) {
 			(*receiver)(data, &ifi);
-
+		}
 		/* disconnect peers from deleted endpt. */
-		while (ep->peers != NULL)
+		while (ep->peers != NULL) {
 			set_peerdstadr(ep->peers, NULL);
-
+		}
 		/*
 		 * update globals in case we lose
 		 * a loopback interface
 		 */
-		if (ep == loopback_interface)
+		if (ep == loopback_interface) {
 			loopback_interface = NULL;
-
+		}
 		delete_interface(ep);
 	}
 
@@ -2011,20 +1979,20 @@ update_interfaces(
 	 */
 	refresh_all_peerinterfaces();
 
-	if (sys_bclient)
+	if (sys_bclient) {
 		io_setbclient();
-
+	}
 #ifdef MCAST
 	/*
 	 * Check multicast interfaces and try to join multicast groups if
-         * not joined yet.
-         */
+	 * not joined yet.
+	 */
 	for (ep = ep_list; ep != NULL; ep = ep->elink) {
 		remaddr_t *entry;
 
-		if (!(INT_MCASTIF & ep->flags) || (INT_MCASTOPEN & ep->flags))
+		if (!(INT_MCASTIF & ep->flags) || (INT_MCASTOPEN & ep->flags)) {
 			continue;
-
+		}
 		/* Find remote address that was linked to this interface */
 		for (entry = remoteaddr_list;
 		     entry != NULL;
@@ -2084,20 +2052,20 @@ create_sockets(
  * create_interface - create a new interface for a given prototype
  *		      binding the socket.
  */
-static struct interface *
+static endpt *
 create_interface(
-	u_short			port,
-	struct interface *	protot
+	u_short	port,
+	endpt *	protot
 	)
 {
 	sockaddr_u	resmask;
 	endpt *		iface;
+	int/*BOOL*/	success;
 #if defined(MCAST) && defined(MULTICAST_NONEWSOCKET)
 	remaddr_t *	entry;
 	remaddr_t *	next_entry;
 #endif
-	DPRINTF(2, ("create_interface(%s#%d)\n", stoa(&protot->sin),
-		    port));
+	DPRINTF(2, ("create_interface(%s)\n", sptoa(&protot->sin)));
 
 	/* build an interface */
 	iface = new_interface(protot);
@@ -2112,16 +2080,15 @@ create_interface(
 
 	if ((INT_BROADCAST & iface->flags)
 	    && iface->bfd != INVALID_SOCKET)
-		msyslog(LOG_INFO, "Listening on broadcast address %s#%d",
-			stoa((&iface->bcast)), port);
+		msyslog(LOG_INFO, "Listening on broadcast address %s",
+			sptoa(&iface->bcast));
 
 	if (INVALID_SOCKET == iface->fd
 	    && INVALID_SOCKET == iface->bfd) {
-		msyslog(LOG_ERR, "unable to create socket on %s (%d) for %s#%d",
+		msyslog(LOG_ERR, "unable to create socket on %s (%d) for %s",
 			iface->name,
 			iface->ifnum,
-			stoa((&iface->sin)),
-			port);
+			sptoa(&iface->sin));
 		delete_interface(iface);
 		return NULL;
 	}
@@ -2130,8 +2097,13 @@ create_interface(
 	 * Blacklist our own addresses, no use talking to ourself
 	 */
 	SET_HOSTMASK(&resmask, AF(&iface->sin));
-	hack_restrict(RESTRICT_FLAGS, &iface->sin, &resmask,
-		      -4, RESM_NTPONLY | RESM_INTERFACE, RES_IGNORE, 0);
+	success = hack_restrict(RESTRICT_FLAGS, &iface->sin, &resmask,
+				-4, RESM_NTPONLY | RESM_INTERFACE,
+				RES_IGNORE, 0);
+	if (!success) {
+		msyslog(LOG_ERR,
+			"unable to self-restrict %s", stoa(&iface->sin));
+	}
 
 	/*
 	 * set globals with the first found
@@ -2181,6 +2153,85 @@ create_interface(
 }
 
 
+#ifdef DEBUG
+const char *
+iflags_str(
+	u_int32 iflags
+)
+{
+	const size_t	sz = LIB_BUFLENGTH;
+	char *		ifs;
+
+	LIB_GETBUF(ifs);
+	ifs[0] = '\0';
+
+	if (iflags & INT_UP) {
+		CLEAR_BIT_IF_DEBUG(INT_UP, iflags);
+		append_flagstr(ifs, sz, "up");
+	}
+
+	if (iflags & INT_PPP) {
+		CLEAR_BIT_IF_DEBUG(INT_PPP, iflags);
+		append_flagstr(ifs, sz, "ppp");
+	}
+
+	if (iflags & INT_LOOPBACK) {
+		CLEAR_BIT_IF_DEBUG(INT_LOOPBACK, iflags);
+		append_flagstr(ifs, sz, "loopback");
+	}
+
+	if (iflags & INT_BROADCAST) {
+		CLEAR_BIT_IF_DEBUG(INT_BROADCAST, iflags);
+		append_flagstr(ifs, sz, "broadcast");
+	}
+
+	if (iflags & INT_MULTICAST) {
+		CLEAR_BIT_IF_DEBUG(INT_MULTICAST, iflags);
+		append_flagstr(ifs, sz, "multicast");
+	}
+
+	if (iflags & INT_BCASTOPEN) {
+		CLEAR_BIT_IF_DEBUG(INT_BCASTOPEN, iflags);
+		append_flagstr(ifs, sz, "bcastopen");
+	}
+
+	if (iflags & INT_MCASTOPEN) {
+		CLEAR_BIT_IF_DEBUG(INT_MCASTOPEN, iflags);
+		append_flagstr(ifs, sz, "mcastopen");
+	}
+
+	if (iflags & INT_WILDCARD) {
+		CLEAR_BIT_IF_DEBUG(INT_WILDCARD, iflags);
+		append_flagstr(ifs, sz, "wildcard");
+	}
+
+	if (iflags & INT_MCASTIF) {
+		CLEAR_BIT_IF_DEBUG(INT_MCASTIF, iflags);
+		append_flagstr(ifs, sz, "mcastif");
+	}
+
+	if (iflags & INT_PRIVACY) {
+		CLEAR_BIT_IF_DEBUG(INT_PRIVACY, iflags);
+		append_flagstr(ifs, sz, "IPv6privacy");
+	}
+
+	if (iflags & INT_BCASTXMIT) {
+		CLEAR_BIT_IF_DEBUG(INT_BCASTXMIT, iflags);
+		append_flagstr(ifs, sz, "bcastxmit");
+	}
+
+	if (iflags & INT_LL_OF_GLOB) {
+		CLEAR_BIT_IF_DEBUG(INT_LL_OF_GLOB, iflags);
+		append_flagstr(ifs, sz, "linklocal-w-global");
+	}
+
+	DEBUG_INVARIANT(!iflags);
+
+	return ifs;
+}
+#endif	/* DEBUG */
+
+
 #ifdef SO_EXCLUSIVEADDRUSE
 static void
 set_excladdruse(
@@ -2263,8 +2314,8 @@ set_reuseaddr(
  */
 void
 enable_broadcast(
-	struct interface *	iface,
-	sockaddr_u *		baddr
+	endpt *		iface,
+	sockaddr_u *	baddr
 	)
 {
 #ifdef OPEN_BCAST_SOCKET
@@ -2280,9 +2331,9 @@ enable_broadcast(
  */
 static isc_boolean_t
 socket_broadcast_enable(
-	struct interface *	iface,
-	SOCKET			fd,
-	sockaddr_u *		baddr
+	endpt *		iface,
+	SOCKET		fd,
+	sockaddr_u *	baddr
 	)
 {
 #ifdef SO_BROADCAST
@@ -2314,7 +2365,7 @@ socket_broadcast_enable(
  */
 static isc_boolean_t
 socket_broadcast_disable(
-	struct interface *	iface,
+	endpt *	iface,
 	sockaddr_u *		baddr
 	)
 {
@@ -2337,15 +2388,6 @@ socket_broadcast_disable(
 
 #endif /* OPEN_BCAST_SOCKET */
 
-/*
- * return the broadcast client flag value
- */
-/*isc_boolean_t
-get_broadcastclient_flag(void)
-{
-	return (broadcast_client_enabled);
-}
-*/
 
 /*
  * Check to see if the address is a multicast address
@@ -2381,8 +2423,8 @@ addr_ismulticast(
  */
 void
 enable_multicast_if(
-	struct interface *	iface,
-	sockaddr_u *		maddr
+	endpt *		iface,
+	sockaddr_u *	maddr
 	)
 {
 #ifdef MCAST
@@ -2526,7 +2568,7 @@ socket_multicast_enable(
 #ifdef MCAST
 static isc_boolean_t
 socket_multicast_disable(
-	struct interface *	iface,
+	endpt *	iface,
 	sockaddr_u *		maddr
 	)
 {
@@ -2535,8 +2577,6 @@ socket_multicast_disable(
 # endif
 	struct ip_mreq mreq;
 
-	ZERO(mreq);
-
 	if (find_addr_in_list(maddr) == NULL) {
 		DPRINTF(4, ("socket_multicast_disable(%s): not found\n",
 			    stoa(maddr)));
@@ -2546,6 +2586,7 @@ socket_multicast_disable(
 	switch (AF(maddr)) {
 
 	case AF_INET:
+		ZERO(mreq);
 		mreq.imr_multiaddr = SOCK_ADDR4(maddr);
 		mreq.imr_interface = SOCK_ADDR4(&iface->sin);
 		if (setsockopt(iface->fd, IPPROTO_IP,
@@ -2569,6 +2610,7 @@ socket_multicast_disable(
 		 * for other types of multicast addresses. For now let
 		 * the kernel figure it out.
 		 */
+		ZERO(mreq6);
 		mreq6.ipv6mr_multiaddr = SOCK_ADDR6(maddr);
 		mreq6.ipv6mr_interface = iface->ifindex;
 
@@ -2589,13 +2631,14 @@ socket_multicast_disable(
 	}
 
 	iface->num_mcast--;
-	if (!iface->num_mcast)
+	if (iface->num_mcast <= 0) {
 		iface->flags &= ~INT_MCASTOPEN;
-
+	}
 	return ISC_TRUE;
 }
 #endif	/* MCAST */
 
+
 /*
  * io_setbclient - open the broadcast client sockets
  */
@@ -2705,6 +2748,7 @@ io_setbclient(void)
 #endif	/* OPEN_BCAST_SOCKET */
 }
 
+
 /*
  * io_unsetbclient - close the broadcast client sockets
  */
@@ -2724,10 +2768,7 @@ io_unsetbclient(void)
 			msyslog(LOG_INFO,
 				"stop listening for broadcasts to %s on interface #%d %s",
 				stoa(&ep->bcast), ep->ifnum, ep->name);
-#		    ifdef HAVE_IO_COMPLETION_PORT
-			io_completion_port_remove_socket(ep->bfd, ep);
-#		    endif
-			close_and_delete_fd_from_list(ep->bfd);
+			close_and_delete_fd_from_list(ep->bfd, ep);
 			ep->bfd = INVALID_SOCKET;
 		}
 		ep->flags &= ~INT_BCASTOPEN;
@@ -2735,6 +2776,7 @@ io_unsetbclient(void)
 	broadcast_client_enabled = ISC_FALSE;
 }
 
+
 /*
  * io_multicast_add() - add multicast group address
  */
@@ -2755,9 +2797,6 @@ io_multicast_add(
 
 	/* If we already have it we can just return */
 	if (NULL != find_flagged_addr_in_list(addr, INT_MCASTOPEN)) {
-		msyslog(LOG_INFO,
-			"Duplicate request found for multicast address %s",
-			stoa(addr));
 		return;
 	}
 
@@ -3041,9 +3080,9 @@ open_socket(
 #endif
 		    ) {
 			msyslog(LOG_ERR,
-				"bind(%d) AF_INET%s %s#%d%s flags 0x%x failed: %m",
+				"bind(%d) AF_INET%s %s%s flags 0x%x failed: %m",
 				fd, IS_IPV6(addr) ? "6" : "",
-				stoa(addr), SRCPORT(addr),
+				sptoa(addr),
 				IS_MCAST(addr) ? " (multicast)" : "",
 				interf->flags);
 		}
@@ -3090,9 +3129,8 @@ open_socket(
 	}
 #endif
 
-	DPRINTF(4, ("bind(%d) AF_INET%s, addr %s%%%d#%d, flags 0x%x\n",
-		   fd, IS_IPV6(addr) ? "6" : "", stoa(addr),
-		   SCOPE(addr), SRCPORT(addr), interf->flags));
+	DPRINTF(4, ("bind(%d) addr %s, flags 0x%x\n",
+		    fd, sptoa(addr), interf->flags));
 
 	make_socket_nonblocking(fd);
 
@@ -3123,17 +3161,16 @@ open_socket(
 
 /* XXX ELIMINATE sendpkt similar in ntpq.c, ntpdc.c, ntp_io.c, ntptrace.c */
 /*
- * sendpkt - send a packet to the specified destination. Maintain a
- * send error cache so that only the first consecutive error for a
- * destination is logged.
+ * sendpkt - send a packet to the specified destination from the given endpt
+ *	     except for multicast, which may be sent from several addresses.
  */
 void
 sendpkt(
-	sockaddr_u *		dest,
-	struct interface *	ep,
-	int			ttl,
-	struct pkt *		pkt,
-	int			len
+	sockaddr_u *	dest,
+	endpt *		ep,
+	int		ttl,
+	struct pkt *	pkt,
+	int		len
 	)
 {
 	endpt *	src;
@@ -3145,12 +3182,16 @@ sendpkt(
 	l_fp	org, rec, xmt;
 	
 	ismcast = IS_MCAST(dest);
-	if (!ismcast)
+	if (!ismcast) {
 		src = ep;
-	else
+	} else {
+#ifndef MCAST
+		return;
+#endif
 		src = (IS_IPV4(dest))
-			  ? mc4_list
-			  : mc6_list;
+			? mc4_list
+			: mc6_list;
+	}
 
 	if (NULL == src) {
 		/*
@@ -3164,13 +3205,14 @@ sendpkt(
 	}
 
 	do {
+		if (INT_LL_OF_GLOB & src->flags) {
+			/* avoid duplicate multicasts on same IPv6 net */
+			goto loop;
+		}
 		DPRINTF(2, ("%ssendpkt(%d, dst=%s, src=%s, ttl=%d, len=%d)\n",
 			    ismcast ? "\tMCAST\t***** " : "", src->fd,
 			    stoa(dest), stoa(&src->sin), ttl, len));
 #ifdef MCAST
-		/*
-		 * for the moment we use the bcast option to set multicast ttl
-		 */
 		if (ismcast && ttl > 0 && ttl != src->last_ttl) {
 			/*
 			 * set the multicast ttl for outgoing packets
@@ -3211,7 +3253,7 @@ sendpkt(
 		cc = simulate_server(dest, src, pkt);
 #elif defined(HAVE_IO_COMPLETION_PORT)
 		cc = io_completion_port_sendto(src, src->fd, pkt,
-			(size_t)len, (sockaddr_u *)&dest->sa);
+			(size_t)len, dest);
 #else
 		cc = sendto(src->fd, (char *)pkt, (u_int)len, 0,
 			    &dest->sa, SOCKLEN(dest));
@@ -3223,6 +3265,7 @@ sendpkt(
 			src->sent++;
 			packets_sent++;
 		}
+	    loop:
 		if (ismcast)
 			src = src->mclink;
 	} while (ismcast && src != NULL);
@@ -3241,8 +3284,6 @@ sendpkt(
 			FPTOD(NTOHS_FP(pkt->rootdelay)),
 			FPTOD(NTOHS_FP(pkt->rootdisp)),  pkt->refid,
 			len - MIN_V4_PKT_LEN, (u_char *)&pkt->exten);
-
-	return;
 }
 
 
@@ -3261,7 +3302,7 @@ fdbits(
 	static char buffer[256];
 	char * buf = buffer;
 
-	count = min(count,  255);
+	count = min(count,  sizeof(buffer) - 1);
 
 	while (count >= 0) {
 		*buf++ = FD_ISSET(count, set) ? '#' : '-';
@@ -3334,7 +3375,7 @@ read_refclock_packet(
 	 */
 	rb->recv_length = buflen;
 	rb->recv_peer = rp->srcclock;
-	rb->dstadr = 0;
+	rb->dstadr = NULL;
 	rb->fd = fd;
 	rb->recv_time = ts;
 	rb->receiver = rp->clock_recv;
@@ -3476,9 +3517,9 @@ fetch_timestamp(
  */
 static inline int
 read_network_packet(
-	SOCKET			fd,
-	struct interface *	itf,
-	l_fp			ts
+	SOCKET		fd,
+	endpt *		itf,
+	l_fp		ts
 	)
 {
 	GETSOCKNAME_SOCKLEN_TYPE fromlen;
@@ -3580,23 +3621,14 @@ read_network_packet(
 	** Bug 2672: Some OSes (MacOSX and Linux) don't block spoofed ::1
 	*/
 
-	if (AF_INET6 == itf->family) {
-		DPRINTF(2, ("Got an IPv6 packet, from <%s> (%d) to <%s> (%d)\n",
-			stoa(&rb->recv_srcadr),
-			IN6_IS_ADDR_LOOPBACK(PSOCK_ADDR6(&rb->recv_srcadr)),
-			stoa(&itf->sin),
-			!IN6_IS_ADDR_LOOPBACK(PSOCK_ADDR6(&itf->sin))
-			));
-
-		if (   IN6_IS_ADDR_LOOPBACK(PSOCK_ADDR6(&rb->recv_srcadr))
-		    && !IN6_IS_ADDR_LOOPBACK(PSOCK_ADDR6(&itf->sin))
-		   ) {
-			packets_dropped++;
-			DPRINTF(2, ("DROPPING that packet\n"));
-			freerecvbuf(rb);
-			return buflen;
-		}
-		DPRINTF(2, ("processing that packet\n"));
+	if (   IS_IPV6(&rb->recv_srcadr)
+	    && IN6_IS_ADDR_LOOPBACK(PSOCK_ADDR6(&rb->recv_srcadr))
+	    && !(INT_LOOPBACK & itf->flags)) {
+
+		packets_dropped++;
+		DPRINTF(2, ("DROPPING pkt with spoofed ::1 source on %s\n", latoa(itf)));
+		freerecvbuf(rb);
+		return -1;
 	}
 
 	/*
@@ -3954,8 +3986,9 @@ select_peerinterface(
 				stoa(srcadr)));
 	} else {
 		ep = dstadr;
-		if (NULL == ep)
+		if (NULL == ep) {
 			ep = wild;
+		}
 	}
 	/*
 	 * If it is a multicast address, findbcastinter() may not find
@@ -3963,16 +3996,19 @@ select_peerinterface(
 	 * given to us as the wildcard (ANY_INTERFACE_CHOOSE).  Either
 	 * way, try a little harder.
 	 */
-	if (wild == ep)
+	if (wild == ep) {
 		ep = findinterface(srcadr);
+	}
 	/*
 	 * we do not bind to the wildcard interfaces for output
 	 * as our (network) source address would be undefined and
 	 * crypto will not work without knowing the own transmit address
 	 */
-	if (ep != NULL && INT_WILDCARD & ep->flags)
-		if (!accept_wildcard_if_for_winnt)
+	if (ep != NULL && (INT_WILDCARD & ep->flags)) {
+		if (!accept_wildcard_if_for_winnt) {
 			ep = NULL;
+		}
+	}
 #else	/* SIM follows */
 	ep = loopback_interface;
 #endif
@@ -4007,7 +4043,7 @@ findinterface(
 
 /*
  * findlocalinterface - find local interface corresponding to addr,
- * which does not have any of flags set.  If bast is nonzero, addr is
+ * which does not have any of flags set.  If bcast is nonzero, addr is
  * a broadcast address.
  *
  * This code attempts to find the local sending address for an outgoing
@@ -4037,21 +4073,21 @@ findlocalinterface(
 	DPRINTF(4, ("Finding interface for addr %s in list of addresses\n",
 		    stoa(addr)));
 
-	/* [Bug 3437] The dummy POOL peer comes in with an AF of
-	 * zero. This is bound to fail, but on the way to nowhere it
+	/* [Bug 3437] The prototype POOL peer can be AF_UNSPEC.
+	 * This is bound to fail, but on the way to nowhere it
 	 * triggers a security incident on SELinux.
 	 *
-	 * Checking the condition and failing early is probably a good
+	 * Checking the condition and failing early is probably good
 	 * advice, and even saves us some syscalls in that case.
 	 * Thanks to Miroslav Lichvar for finding this.
 	 */
-	if (AF_UNSPEC == AF(addr))
+	if (AF_UNSPEC == AF(addr)) {
 		return NULL;
-
+	}
 	s = socket(AF(addr), SOCK_DGRAM, 0);
-	if (INVALID_SOCKET == s)
+	if (INVALID_SOCKET == s) {
 		return NULL;
-
+	}
 	/*
 	 * If we are looking for broadcast interface we need to set this
 	 * socket to allow broadcast
@@ -4092,14 +4128,18 @@ findlocalinterface(
 	 * See http://bugs.ntp.org/1184 and http://bugs.ntp.org/1683
 	 * for more background.
 	 */
-	if (NULL == iface || iface->ignore_packets)
+	if (NULL == iface || iface->ignore_packets) {
 		iface = findclosestinterface(&saddr,
 					     flags | INT_LOOPBACK);
-
-	/* Don't use an interface which will ignore replies */
-	if (iface != NULL && iface->ignore_packets)
+	}
+	/*
+	 * Don't select an interface which will ignore replies, or one
+	 * dedicated to multicast receive.
+	 */
+	if (   iface != NULL
+	    && (iface->ignore_packets || (INT_MCASTIF & iface->flags))) {
 		iface = NULL;
-
+	}
 	return iface;
 }
 
@@ -4169,47 +4209,40 @@ calc_addr_distance(
 	const sockaddr_u *	a2
 	)
 {
-	u_int32	a1val;
-	u_int32	a2val;
-	u_int32	v4dist;
-	int	found_greater;
-	int	a1_greater;
-	int	i;
+	u_char *	pdist;
+	const u_char *	p1;
+	const u_char *	p2;
+	size_t		cb;
+	int		different;
+	int		a1_greater;
+	u_int		u;
 
 	REQUIRE(AF(a1) == AF(a2));
 
 	ZERO_SOCK(dist);
 	AF(dist) = AF(a1);
 
-	/* v4 can be done a bit simpler */
 	if (IS_IPV4(a1)) {
-		a1val = SRCADR(a1);
-		a2val = SRCADR(a2);
-		v4dist = (a1val > a2val)
-			     ? a1val - a2val
-			     : a2val - a1val;
-		SET_ADDR4(dist, v4dist);
-
-		return;
+		pdist = (      u_char *)&NSRCADR(dist);
+		p1 =	(const u_char *)&NSRCADR(a1);
+		p2 =	(const u_char *)&NSRCADR(a2);
+	} else {
+		pdist = (      u_char *)&NSRCADR(dist);
+		p1 =	(const u_char *)&NSRCADR(a1);
+		p2 =	(const u_char *)&NSRCADR(a2);
 	}
-
-	found_greater = FALSE;
-	a1_greater = FALSE;	/* suppress pot. uninit. warning */
-	for (i = 0; i < (int)sizeof(NSRCADR6(a1)); i++) {
-		if (!found_greater &&
-		    NSRCADR6(a1)[i] != NSRCADR6(a2)[i]) {
-			found_greater = TRUE;
-			a1_greater = (NSRCADR6(a1)[i] > NSRCADR6(a2)[i]);
+	cb = SIZEOF_INADDR(AF(dist));
+	different = FALSE;
+	a1_greater = FALSE;
+	for (u = 0; u < cb; u++) {
+		if (!different && p1[u] != p2[u]) {
+			a1_greater = (p1[u] > p2[u]);
+			different = TRUE;
 		}
-		if (!found_greater) {
-			NSRCADR6(dist)[i] = 0;
+		if (a1_greater) {
+			pdist[u] = p1[u] - p2[u];
 		} else {
-			if (a1_greater)
-				NSRCADR6(dist)[i] = NSRCADR6(a1)[i] -
-						    NSRCADR6(a2)[i];
-			else
-				NSRCADR6(dist)[i] = NSRCADR6(a2)[i] -
-						    NSRCADR6(a1)[i];
+			pdist[u] = p2[u] - p1[u];
 		}
 	}
 }
@@ -4468,7 +4501,7 @@ io_closeclock(
 #	    ifdef HAVE_IO_COMPLETION_PORT
 		io_completion_port_remove_clock_io(rio);
 #	    endif
-		close_and_delete_fd_from_list(rio->fd);
+		close_and_delete_fd_from_list(rio->fd, NULL);
 		purge_recv_buffers_for_fd(rio->fd);
 		rio->fd = -1;
 	}
@@ -4503,7 +4536,7 @@ kill_asyncio(
 	maxactivefd = 0;
 
 	while (fd_list != NULL)
-		close_and_delete_fd_from_list(fd_list->fd);
+		close_and_delete_fd_from_list(fd_list->fd, NULL);
 
 	UNBLOCKIO();
 }
@@ -4531,7 +4564,8 @@ add_fd_to_list(
 
 static void
 close_and_delete_fd_from_list(
-	SOCKET fd
+	SOCKET fd,
+	endpt *ep	/* req. if fd is in struct endpt */
 	)
 {
 	vsock_t *lsock;
@@ -4545,6 +4579,11 @@ close_and_delete_fd_from_list(
 	switch (lsock->type) {
 
 	case FD_TYPE_SOCKET:
+	    #ifdef HAVE_IO_COMPLETION_PORT
+		if (ep != NULL) {
+			io_completion_port_remove_socket(fd, ep);
+		}
+	    #endif
 		closesocket(lsock->fd);
 		break;
 
@@ -4635,7 +4674,7 @@ delete_interface_from_list(
 }
 
 
-static struct interface *
+static endpt *
 find_addr_in_list(
 	sockaddr_u *addr
 	)
@@ -4707,7 +4746,7 @@ localaddrtoa(
 static void
 process_routing_msgs(struct asyncio_reader *reader)
 {
-	static char *	buffer;
+	static void *	buffer;
 	static size_t	buffsz = 8192;
 	int		cnt, new, msg_type;
 	socklen_t	len;
@@ -4716,16 +4755,15 @@ process_routing_msgs(struct asyncio_reader *reader)
 #else
 	struct rt_msghdr rtm;
 	char *p;
+	char *endp;
 #endif
 
-	if (disable_dynamic_updates) {
+	if (scan_addrs_once) {
 		/*
 		 * discard ourselves if we are not needed any more
 		 * usually happens when running unprivileged
 		 */
-		remove_asyncio_reader(reader);
-		delete_asyncio_reader(reader);
-		return;
+		goto disable;
 	}
 
 	if (NULL == buffer) {
@@ -4758,22 +4796,20 @@ process_routing_msgs(struct asyncio_reader *reader)
 		    disable:
 			remove_asyncio_reader(reader);
 			delete_asyncio_reader(reader);
+			return;
 		}
-		return;
 	}
 
 	/*
 	 * process routing message
 	 */
 #ifdef HAVE_RTNETLINK
-	for (nh = UA_PTR(struct nlmsghdr, buffer);
-	     NLMSG_OK(nh, cnt);
-	     nh = NLMSG_NEXT(nh, cnt))
+	for (nh = buffer; NLMSG_OK(nh, cnt); nh = NLMSG_NEXT(nh, cnt))
 	{
 		msg_type = nh->nlmsg_type;
 #else
-	for (p = buffer;
-	     (p + sizeof(struct rt_msghdr)) <= (buffer + cnt);
+	for (p = buffer, endp = p + cnt;
+	     (p + sizeof(struct rt_msghdr)) <= endp;
 	     p += rtm.rtm_msglen)
 	{
 		memcpy(&rtm, p, sizeof(rtm));
@@ -4787,7 +4823,7 @@ process_routing_msgs(struct asyncio_reader *reader)
 			return;
 		}
 		msg_type = rtm.rtm_type;
-#endif
+#endif	/* !HAVE_RTNETLINK */
 		switch (msg_type) {
 #ifdef RTM_NEWADDR
 		case RTM_NEWADDR:
@@ -4835,7 +4871,7 @@ process_routing_msgs(struct asyncio_reader *reader)
 			 */
 			DPRINTF(3, ("routing message op = %d: scheduling interface update\n",
 				    msg_type));
-			timer_interfacetimeout(current_time + UPDATE_GRACE);
+			endpt_scan_timer = UPDATE_GRACE + current_time;
 			break;
 #ifdef HAVE_RTNETLINK
 		case NLMSG_DONE:
@@ -4857,14 +4893,14 @@ process_routing_msgs(struct asyncio_reader *reader)
  * set up routing notifications
  */
 static void
-init_async_notifications()
+init_async_notifications(void)
 {
 	struct asyncio_reader *reader;
 #ifdef HAVE_RTNETLINK
 	int fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
 	struct sockaddr_nl sa;
 #else
-	int fd = socket(PF_ROUTE, SOCK_RAW, 0);
+	int fd = socket(PF_ROUTE, SOCK_RAW, AF_UNSPEC);
 #endif
 	if (fd < 0) {
 		msyslog(LOG_ERR,
@@ -4908,4 +4944,3 @@ init_async_notifications(void)
 {
 }
 #endif
-
diff --git a/contrib/ntp/ntpd/ntp_keyword.h b/contrib/ntp/ntpd/ntp_keyword.h
index 7b3efc2cda30..7fa610bb39b9 100644
--- a/contrib/ntp/ntpd/ntp_keyword.h
+++ b/contrib/ntp/ntpd/ntp_keyword.h
@@ -2,7 +2,7 @@
  * ntp_keyword.h
  * 
  * NOTE: edit this file with caution, it is generated by keyword-gen.c
- *	 Generated 2022-03-27 14:17:11 UTC	  diff_ignore_line
+ *	 Generated 2023-09-25 05:34:02 UTC	  diff_ignore_line
  *
  */
 #include "ntp_scanner.h"
@@ -10,7 +10,7 @@
 
 #define LOWEST_KEYWORD_ID 258
 
-const char * const keyword_text[212] = {
+const char * const keyword_text[213] = {
 	/* 0       258             T_Abbrev */	"abbrev",
 	/* 1       259                T_Age */	"age",
 	/* 2       260                T_All */	"all",
@@ -39,200 +39,201 @@ const char * const keyword_text[212] = {
 	/* 25      283                T_Ctl */	"ctl",
 	/* 26      284                T_Day */	"day",
 	/* 27      285            T_Default */	"default",
-	/* 28      286             T_Device */	"device",
-	/* 29      287             T_Digest */	"digest",
-	/* 30      288            T_Disable */	"disable",
-	/* 31      289            T_Discard */	"discard",
-	/* 32      290         T_Dispersion */	"dispersion",
-	/* 33      291             T_Double */	NULL,
-	/* 34      292          T_Driftfile */	"driftfile",
-	/* 35      293               T_Drop */	"drop",
-	/* 36      294               T_Dscp */	"dscp",
-	/* 37      295           T_Ellipsis */	"...",
-	/* 38      296             T_Enable */	"enable",
-	/* 39      297                T_End */	"end",
-	/* 40      298              T_Epeer */	"epeer",
-	/* 41      299              T_False */	NULL,
-	/* 42      300               T_File */	"file",
-	/* 43      301            T_Filegen */	"filegen",
-	/* 44      302            T_Filenum */	"filenum",
-	/* 45      303              T_Flag1 */	"flag1",
-	/* 46      304              T_Flag2 */	"flag2",
-	/* 47      305              T_Flag3 */	"flag3",
-	/* 48      306              T_Flag4 */	"flag4",
-	/* 49      307              T_Flake */	"flake",
-	/* 50      308              T_Floor */	"floor",
-	/* 51      309               T_Freq */	"freq",
-	/* 52      310              T_Fudge */	"fudge",
-	/* 53      311               T_Fuzz */	"fuzz",
-	/* 54      312               T_Host */	"host",
-	/* 55      313           T_Huffpuff */	"huffpuff",
-	/* 56      314             T_Iburst */	"iburst",
-	/* 57      315              T_Ident */	"ident",
-	/* 58      316             T_Ignore */	"ignore",
-	/* 59      317         T_Ignorehash */	"ignorehash",
-	/* 60      318           T_Incalloc */	"incalloc",
-	/* 61      319             T_Incmem */	"incmem",
-	/* 62      320          T_Initalloc */	"initalloc",
-	/* 63      321            T_Initmem */	"initmem",
-	/* 64      322        T_Includefile */	"includefile",
-	/* 65      323            T_Integer */	NULL,
-	/* 66      324          T_Interface */	"interface",
-	/* 67      325           T_Intrange */	NULL,
-	/* 68      326                 T_Io */	"io",
-	/* 69      327        T_Ippeerlimit */	"ippeerlimit",
-	/* 70      328               T_Ipv4 */	"ipv4",
-	/* 71      329          T_Ipv4_flag */	"-4",
-	/* 72      330               T_Ipv6 */	"ipv6",
-	/* 73      331          T_Ipv6_flag */	"-6",
-	/* 74      332             T_Kernel */	"kernel",
-	/* 75      333                T_Key */	"key",
-	/* 76      334               T_Keys */	"keys",
-	/* 77      335            T_Keysdir */	"keysdir",
-	/* 78      336                T_Kod */	"kod",
-	/* 79      337           T_Leapfile */	"leapfile",
-	/* 80      338  T_Leapsmearinterval */	"leapsmearinterval",
-	/* 81      339            T_Limited */	"limited",
-	/* 82      340               T_Link */	"link",
-	/* 83      341             T_Listen */	"listen",
-	/* 84      342          T_Logconfig */	"logconfig",
-	/* 85      343            T_Logfile */	"logfile",
-	/* 86      344          T_Loopstats */	"loopstats",
-	/* 87      345        T_Lowpriotrap */	"lowpriotrap",
-	/* 88      346     T_Manycastclient */	"manycastclient",
-	/* 89      347     T_Manycastserver */	"manycastserver",
-	/* 90      348               T_Mask */	"mask",
-	/* 91      349             T_Maxage */	"maxage",
-	/* 92      350           T_Maxclock */	"maxclock",
-	/* 93      351           T_Maxdepth */	"maxdepth",
-	/* 94      352            T_Maxdist */	"maxdist",
-	/* 95      353             T_Maxmem */	"maxmem",
-	/* 96      354            T_Maxpoll */	"maxpoll",
-	/* 97      355          T_Mdnstries */	"mdnstries",
-	/* 98      356                T_Mem */	"mem",
-	/* 99      357            T_Memlock */	"memlock",
-	/* 100     358           T_Minclock */	"minclock",
-	/* 101     359           T_Mindepth */	"mindepth",
-	/* 102     360            T_Mindist */	"mindist",
-	/* 103     361            T_Minimum */	"minimum",
-	/* 104     362          T_Minjitter */	"minjitter",
-	/* 105     363            T_Minpoll */	"minpoll",
-	/* 106     364            T_Minsane */	"minsane",
-	/* 107     365               T_Mode */	"mode",
-	/* 108     366              T_Mode7 */	"mode7",
-	/* 109     367            T_Monitor */	"monitor",
-	/* 110     368              T_Month */	"month",
-	/* 111     369                T_Mru */	"mru",
-	/* 112     370             T_Mssntp */	"mssntp",
-	/* 113     371    T_Multicastclient */	"multicastclient",
-	/* 114     372                T_Nic */	"nic",
-	/* 115     373             T_Nolink */	"nolink",
-	/* 116     374           T_Nomodify */	"nomodify",
-	/* 117     375          T_Nomrulist */	"nomrulist",
-	/* 118     376               T_None */	"none",
-	/* 119     377        T_Nonvolatile */	"nonvolatile",
-	/* 120     378            T_Noepeer */	"noepeer",
-	/* 121     379             T_Nopeer */	"nopeer",
-	/* 122     380            T_Noquery */	"noquery",
-	/* 123     381           T_Noselect */	"noselect",
-	/* 124     382            T_Noserve */	"noserve",
-	/* 125     383             T_Notrap */	"notrap",
-	/* 126     384            T_Notrust */	"notrust",
-	/* 127     385                T_Ntp */	"ntp",
-	/* 128     386            T_Ntpport */	"ntpport",
-	/* 129     387     T_NtpSignDsocket */	"ntpsigndsocket",
-	/* 130     388             T_Orphan */	"orphan",
-	/* 131     389         T_Orphanwait */	"orphanwait",
-	/* 132     390          T_PCEdigest */	"peer_clear_digest_early",
-	/* 133     391              T_Panic */	"panic",
-	/* 134     392               T_Peer */	"peer",
-	/* 135     393          T_Peerstats */	"peerstats",
-	/* 136     394              T_Phone */	"phone",
-	/* 137     395                T_Pid */	"pid",
-	/* 138     396            T_Pidfile */	"pidfile",
-	/* 139     397               T_Poll */	"poll",
-	/* 140     398       T_PollSkewList */	"pollskewlist",
-	/* 141     399               T_Pool */	"pool",
-	/* 142     400               T_Port */	"port",
-	/* 143     401            T_PpsData */	"ppsdata",
-	/* 144     402            T_Preempt */	"preempt",
-	/* 145     403             T_Prefer */	"prefer",
-	/* 146     404         T_Protostats */	"protostats",
-	/* 147     405                 T_Pw */	"pw",
-	/* 148     406           T_Randfile */	"randfile",
-	/* 149     407           T_Rawstats */	"rawstats",
-	/* 150     408              T_Refid */	"refid",
-	/* 151     409         T_Requestkey */	"requestkey",
-	/* 152     410              T_Reset */	"reset",
-	/* 153     411           T_Restrict */	"restrict",
-	/* 154     412             T_Revoke */	"revoke",
-	/* 155     413             T_Rlimit */	"rlimit",
-	/* 156     414      T_Saveconfigdir */	"saveconfigdir",
-	/* 157     415             T_Server */	"server",
-	/* 158     416     T_Serverresponse */	"serverresponse",
-	/* 159     417 T_ServerresponseFuzz */	NULL,
-	/* 160     418             T_Setvar */	"setvar",
-	/* 161     419             T_Source */	"source",
-	/* 162     420          T_Stacksize */	"stacksize",
-	/* 163     421         T_Statistics */	"statistics",
-	/* 164     422              T_Stats */	"stats",
-	/* 165     423           T_Statsdir */	"statsdir",
-	/* 166     424               T_Step */	"step",
-	/* 167     425           T_Stepback */	"stepback",
-	/* 168     426            T_Stepfwd */	"stepfwd",
-	/* 169     427            T_Stepout */	"stepout",
-	/* 170     428            T_Stratum */	"stratum",
-	/* 171     429             T_String */	NULL,
-	/* 172     430                T_Sys */	"sys",
-	/* 173     431           T_Sysstats */	"sysstats",
-	/* 174     432               T_Tick */	"tick",
-	/* 175     433              T_Time1 */	"time1",
-	/* 176     434              T_Time2 */	"time2",
-	/* 177     435           T_TimeData */	"timedata",
-	/* 178     436              T_Timer */	"timer",
-	/* 179     437        T_Timingstats */	"timingstats",
-	/* 180     438             T_Tinker */	"tinker",
-	/* 181     439                T_Tos */	"tos",
-	/* 182     440               T_Trap */	"trap",
-	/* 183     441               T_True */	"true",
-	/* 184     442         T_Trustedkey */	"trustedkey",
-	/* 185     443                T_Ttl */	"ttl",
-	/* 186     444               T_Type */	"type",
-	/* 187     445              T_U_int */	NULL,
-	/* 188     446           T_UEcrypto */	"unpeer_crypto_early",
-	/* 189     447        T_UEcryptonak */	"unpeer_crypto_nak_early",
-	/* 190     448           T_UEdigest */	"unpeer_digest_early",
-	/* 191     449           T_Unconfig */	"unconfig",
-	/* 192     450             T_Unpeer */	"unpeer",
-	/* 193     451            T_Version */	"version",
-	/* 194     452    T_WanderThreshold */	NULL,
-	/* 195     453               T_Week */	"week",
-	/* 196     454           T_Wildcard */	"wildcard",
-	/* 197     455             T_Xleave */	"xleave",
-	/* 198     456           T_Xmtnonce */	"xmtnonce",
-	/* 199     457               T_Year */	"year",
-	/* 200     458               T_Flag */	NULL,
-	/* 201     459                T_EOC */	NULL,
-	/* 202     460           T_Simulate */	"simulate",
-	/* 203     461         T_Beep_Delay */	"beep_delay",
-	/* 204     462       T_Sim_Duration */	"simulation_duration",
-	/* 205     463      T_Server_Offset */	"server_offset",
-	/* 206     464           T_Duration */	"duration",
-	/* 207     465        T_Freq_Offset */	"freq_offset",
-	/* 208     466             T_Wander */	"wander",
-	/* 209     467             T_Jitter */	"jitter",
-	/* 210     468         T_Prop_Delay */	"prop_delay",
-	/* 211     469         T_Proc_Delay */	"proc_delay"
+	/* 28      286        T_Delrestrict */	"delrestrict",
+	/* 29      287             T_Device */	"device",
+	/* 30      288             T_Digest */	"digest",
+	/* 31      289            T_Disable */	"disable",
+	/* 32      290            T_Discard */	"discard",
+	/* 33      291         T_Dispersion */	"dispersion",
+	/* 34      292             T_Double */	NULL,
+	/* 35      293          T_Driftfile */	"driftfile",
+	/* 36      294               T_Drop */	"drop",
+	/* 37      295               T_Dscp */	"dscp",
+	/* 38      296           T_Ellipsis */	"...",
+	/* 39      297             T_Enable */	"enable",
+	/* 40      298                T_End */	"end",
+	/* 41      299              T_Epeer */	"epeer",
+	/* 42      300              T_False */	NULL,
+	/* 43      301               T_File */	"file",
+	/* 44      302            T_Filegen */	"filegen",
+	/* 45      303            T_Filenum */	"filenum",
+	/* 46      304              T_Flag1 */	"flag1",
+	/* 47      305              T_Flag2 */	"flag2",
+	/* 48      306              T_Flag3 */	"flag3",
+	/* 49      307              T_Flag4 */	"flag4",
+	/* 50      308              T_Flake */	"flake",
+	/* 51      309              T_Floor */	"floor",
+	/* 52      310               T_Freq */	"freq",
+	/* 53      311              T_Fudge */	"fudge",
+	/* 54      312               T_Fuzz */	"fuzz",
+	/* 55      313               T_Host */	"host",
+	/* 56      314           T_Huffpuff */	"huffpuff",
+	/* 57      315             T_Iburst */	"iburst",
+	/* 58      316              T_Ident */	"ident",
+	/* 59      317             T_Ignore */	"ignore",
+	/* 60      318         T_Ignorehash */	"ignorehash",
+	/* 61      319           T_Incalloc */	"incalloc",
+	/* 62      320             T_Incmem */	"incmem",
+	/* 63      321          T_Initalloc */	"initalloc",
+	/* 64      322            T_Initmem */	"initmem",
+	/* 65      323        T_Includefile */	"includefile",
+	/* 66      324            T_Integer */	NULL,
+	/* 67      325          T_Interface */	"interface",
+	/* 68      326           T_Intrange */	NULL,
+	/* 69      327                 T_Io */	"io",
+	/* 70      328        T_Ippeerlimit */	"ippeerlimit",
+	/* 71      329               T_Ipv4 */	"ipv4",
+	/* 72      330          T_Ipv4_flag */	"-4",
+	/* 73      331               T_Ipv6 */	"ipv6",
+	/* 74      332          T_Ipv6_flag */	"-6",
+	/* 75      333             T_Kernel */	"kernel",
+	/* 76      334                T_Key */	"key",
+	/* 77      335               T_Keys */	"keys",
+	/* 78      336            T_Keysdir */	"keysdir",
+	/* 79      337                T_Kod */	"kod",
+	/* 80      338           T_Leapfile */	"leapfile",
+	/* 81      339  T_Leapsmearinterval */	"leapsmearinterval",
+	/* 82      340            T_Limited */	"limited",
+	/* 83      341               T_Link */	"link",
+	/* 84      342             T_Listen */	"listen",
+	/* 85      343          T_Logconfig */	"logconfig",
+	/* 86      344            T_Logfile */	"logfile",
+	/* 87      345          T_Loopstats */	"loopstats",
+	/* 88      346        T_Lowpriotrap */	"lowpriotrap",
+	/* 89      347     T_Manycastclient */	"manycastclient",
+	/* 90      348     T_Manycastserver */	"manycastserver",
+	/* 91      349               T_Mask */	"mask",
+	/* 92      350             T_Maxage */	"maxage",
+	/* 93      351           T_Maxclock */	"maxclock",
+	/* 94      352           T_Maxdepth */	"maxdepth",
+	/* 95      353            T_Maxdist */	"maxdist",
+	/* 96      354             T_Maxmem */	"maxmem",
+	/* 97      355            T_Maxpoll */	"maxpoll",
+	/* 98      356          T_Mdnstries */	"mdnstries",
+	/* 99      357                T_Mem */	"mem",
+	/* 100     358            T_Memlock */	"memlock",
+	/* 101     359           T_Minclock */	"minclock",
+	/* 102     360           T_Mindepth */	"mindepth",
+	/* 103     361            T_Mindist */	"mindist",
+	/* 104     362            T_Minimum */	"minimum",
+	/* 105     363          T_Minjitter */	"minjitter",
+	/* 106     364            T_Minpoll */	"minpoll",
+	/* 107     365            T_Minsane */	"minsane",
+	/* 108     366               T_Mode */	"mode",
+	/* 109     367              T_Mode7 */	"mode7",
+	/* 110     368            T_Monitor */	"monitor",
+	/* 111     369              T_Month */	"month",
+	/* 112     370                T_Mru */	"mru",
+	/* 113     371             T_Mssntp */	"mssntp",
+	/* 114     372    T_Multicastclient */	"multicastclient",
+	/* 115     373                T_Nic */	"nic",
+	/* 116     374             T_Nolink */	"nolink",
+	/* 117     375           T_Nomodify */	"nomodify",
+	/* 118     376          T_Nomrulist */	"nomrulist",
+	/* 119     377               T_None */	"none",
+	/* 120     378        T_Nonvolatile */	"nonvolatile",
+	/* 121     379            T_Noepeer */	"noepeer",
+	/* 122     380             T_Nopeer */	"nopeer",
+	/* 123     381            T_Noquery */	"noquery",
+	/* 124     382           T_Noselect */	"noselect",
+	/* 125     383            T_Noserve */	"noserve",
+	/* 126     384             T_Notrap */	"notrap",
+	/* 127     385            T_Notrust */	"notrust",
+	/* 128     386                T_Ntp */	"ntp",
+	/* 129     387            T_Ntpport */	"ntpport",
+	/* 130     388     T_NtpSignDsocket */	"ntpsigndsocket",
+	/* 131     389             T_Orphan */	"orphan",
+	/* 132     390         T_Orphanwait */	"orphanwait",
+	/* 133     391          T_PCEdigest */	"peer_clear_digest_early",
+	/* 134     392              T_Panic */	"panic",
+	/* 135     393               T_Peer */	"peer",
+	/* 136     394          T_Peerstats */	"peerstats",
+	/* 137     395              T_Phone */	"phone",
+	/* 138     396                T_Pid */	"pid",
+	/* 139     397            T_Pidfile */	"pidfile",
+	/* 140     398               T_Poll */	"poll",
+	/* 141     399       T_PollSkewList */	"pollskewlist",
+	/* 142     400               T_Pool */	"pool",
+	/* 143     401               T_Port */	"port",
+	/* 144     402            T_PpsData */	"ppsdata",
+	/* 145     403            T_Preempt */	"preempt",
+	/* 146     404             T_Prefer */	"prefer",
+	/* 147     405         T_Protostats */	"protostats",
+	/* 148     406                 T_Pw */	"pw",
+	/* 149     407           T_Randfile */	"randfile",
+	/* 150     408           T_Rawstats */	"rawstats",
+	/* 151     409              T_Refid */	"refid",
+	/* 152     410         T_Requestkey */	"requestkey",
+	/* 153     411              T_Reset */	"reset",
+	/* 154     412           T_Restrict */	"restrict",
+	/* 155     413             T_Revoke */	"revoke",
+	/* 156     414             T_Rlimit */	"rlimit",
+	/* 157     415      T_Saveconfigdir */	"saveconfigdir",
+	/* 158     416             T_Server */	"server",
+	/* 159     417     T_Serverresponse */	"serverresponse",
+	/* 160     418 T_ServerresponseFuzz */	NULL,
+	/* 161     419             T_Setvar */	"setvar",
+	/* 162     420             T_Source */	"source",
+	/* 163     421          T_Stacksize */	"stacksize",
+	/* 164     422         T_Statistics */	"statistics",
+	/* 165     423              T_Stats */	"stats",
+	/* 166     424           T_Statsdir */	"statsdir",
+	/* 167     425               T_Step */	"step",
+	/* 168     426           T_Stepback */	"stepback",
+	/* 169     427            T_Stepfwd */	"stepfwd",
+	/* 170     428            T_Stepout */	"stepout",
+	/* 171     429            T_Stratum */	"stratum",
+	/* 172     430             T_String */	NULL,
+	/* 173     431                T_Sys */	"sys",
+	/* 174     432           T_Sysstats */	"sysstats",
+	/* 175     433               T_Tick */	"tick",
+	/* 176     434              T_Time1 */	"time1",
+	/* 177     435              T_Time2 */	"time2",
+	/* 178     436           T_TimeData */	"timedata",
+	/* 179     437              T_Timer */	"timer",
+	/* 180     438        T_Timingstats */	"timingstats",
+	/* 181     439             T_Tinker */	"tinker",
+	/* 182     440                T_Tos */	"tos",
+	/* 183     441               T_Trap */	"trap",
+	/* 184     442               T_True */	"true",
+	/* 185     443         T_Trustedkey */	"trustedkey",
+	/* 186     444                T_Ttl */	"ttl",
+	/* 187     445               T_Type */	"type",
+	/* 188     446              T_U_int */	NULL,
+	/* 189     447           T_UEcrypto */	"unpeer_crypto_early",
+	/* 190     448        T_UEcryptonak */	"unpeer_crypto_nak_early",
+	/* 191     449           T_UEdigest */	"unpeer_digest_early",
+	/* 192     450           T_Unconfig */	"unconfig",
+	/* 193     451             T_Unpeer */	"unpeer",
+	/* 194     452            T_Version */	"version",
+	/* 195     453    T_WanderThreshold */	NULL,
+	/* 196     454               T_Week */	"week",
+	/* 197     455           T_Wildcard */	"wildcard",
+	/* 198     456             T_Xleave */	"xleave",
+	/* 199     457           T_Xmtnonce */	"xmtnonce",
+	/* 200     458               T_Year */	"year",
+	/* 201     459               T_Flag */	NULL,
+	/* 202     460                T_EOC */	NULL,
+	/* 203     461           T_Simulate */	"simulate",
+	/* 204     462         T_Beep_Delay */	"beep_delay",
+	/* 205     463       T_Sim_Duration */	"simulation_duration",
+	/* 206     464      T_Server_Offset */	"server_offset",
+	/* 207     465           T_Duration */	"duration",
+	/* 208     466        T_Freq_Offset */	"freq_offset",
+	/* 209     467             T_Wander */	"wander",
+	/* 210     468             T_Jitter */	"jitter",
+	/* 211     469         T_Prop_Delay */	"prop_delay",
+	/* 212     470         T_Proc_Delay */	"proc_delay"
 };
 
-#define SCANNER_INIT_S 999
+#define SCANNER_INIT_S 1008
 
-const scan_state sst[1002] = {
+const scan_state sst[1011] = {
 /*SS_T( ch,	f-by, match, other ),				 */
   0,				      /*     0                   */
-  S_ST( '-',	3,      331,     0 ), /*     1                   */
+  S_ST( '-',	3,      332,     0 ), /*     1                   */
   S_ST( '.',	3,        3,     1 ), /*     2                   */
-  S_ST( '.',	3,      295,     0 ), /*     3 .                 */
+  S_ST( '.',	3,      296,     0 ), /*     3 .                 */
   S_ST( 'a',	3,       23,     2 ), /*     4                   */
   S_ST( 'b',	3,        6,     0 ), /*     5 a                 */
   S_ST( 'b',	3,        7,     0 ), /*     6 ab                */
@@ -287,7 +288,7 @@ const scan_state sst[1002] = {
   S_ST( 'd',	3,       56,     0 ), /*    55 beep_             */
   S_ST( 'e',	3,       57,     0 ), /*    56 beep_d            */
   S_ST( 'l',	3,       58,     0 ), /*    57 beep_de           */
-  S_ST( 'a',	3,      461,     0 ), /*    58 beep_del          */
+  S_ST( 'a',	3,      462,     0 ), /*    58 beep_del          */
   S_ST( 'r',	3,       60,    48 ), /*    59 b                 */
   S_ST( 'o',	3,       61,     0 ), /*    60 br                */
   S_ST( 'a',	3,       62,     0 ), /*    61 bro               */
@@ -355,138 +356,138 @@ const scan_state sst[1002] = {
   S_ST( 'a',	3,      124,     0 ), /*   123 cryptost          */
   S_ST( 't',	3,      282,     0 ), /*   124 cryptosta         */
   S_ST( 't',	3,      283,   117 ), /*   125 c                 */
-  S_ST( 'd',	3,      163,    78 ), /*   126                   */
+  S_ST( 'd',	3,      171,    78 ), /*   126                   */
   S_ST( 'a',	3,      284,     0 ), /*   127 d                 */
-  S_ST( 'e',	3,      133,   127 ), /*   128 d                 */
+  S_ST( 'e',	3,      141,   127 ), /*   128 d                 */
   S_ST( 'f',	3,      130,     0 ), /*   129 de                */
   S_ST( 'a',	3,      131,     0 ), /*   130 def               */
   S_ST( 'u',	3,      132,     0 ), /*   131 defa              */
   S_ST( 'l',	3,      285,     0 ), /*   132 defau             */
-  S_ST( 'v',	3,      134,   129 ), /*   133 de                */
-  S_ST( 'i',	3,      135,     0 ), /*   134 dev               */
-  S_ST( 'c',	3,      286,     0 ), /*   135 devi              */
-  S_ST( 'i',	3,      140,   128 ), /*   136 d                 */
-  S_ST( 'g',	3,      138,     0 ), /*   137 di                */
-  S_ST( 'e',	3,      139,     0 ), /*   138 dig               */
-  S_ST( 's',	3,      287,     0 ), /*   139 dige              */
-  S_ST( 's',	3,      147,   137 ), /*   140 di                */
-  S_ST( 'a',	3,      142,     0 ), /*   141 dis               */
-  S_ST( 'b',	3,      143,     0 ), /*   142 disa              */
-  S_ST( 'l',	3,      288,     0 ), /*   143 disab             */
-  S_ST( 'c',	3,      145,   141 ), /*   144 dis               */
-  S_ST( 'a',	3,      146,     0 ), /*   145 disc              */
-  S_ST( 'r',	3,      289,     0 ), /*   146 disca             */
-  S_ST( 'p',	3,      148,   144 ), /*   147 dis               */
-  S_ST( 'e',	3,      149,     0 ), /*   148 disp              */
-  S_ST( 'r',	3,      150,     0 ), /*   149 dispe             */
-  S_ST( 's',	3,      151,     0 ), /*   150 disper            */
-  S_ST( 'i',	3,      152,     0 ), /*   151 dispers           */
-  S_ST( 'o',	3,      290,     0 ), /*   152 dispersi          */
-  S_ST( 'r',	3,      160,   136 ), /*   153 d                 */
-  S_ST( 'i',	3,      155,     0 ), /*   154 dr                */
-  S_ST( 'f',	3,      156,     0 ), /*   155 dri               */
-  S_ST( 't',	3,      157,     0 ), /*   156 drif              */
-  S_ST( 'f',	3,      158,     0 ), /*   157 drift             */
-  S_ST( 'i',	3,      159,     0 ), /*   158 driftf            */
-  S_ST( 'l',	3,      292,     0 ), /*   159 driftfi           */
-  S_ST( 'o',	3,      293,   154 ), /*   160 dr                */
-  S_ST( 's',	3,      162,   153 ), /*   161 d                 */
-  S_ST( 'c',	3,      294,     0 ), /*   162 ds                */
-  S_ST( 'u',	3,      164,   161 ), /*   163 d                 */
-  S_ST( 'r',	3,      165,     0 ), /*   164 du                */
-  S_ST( 'a',	3,      166,     0 ), /*   165 dur               */
-  S_ST( 't',	3,      167,     0 ), /*   166 dura              */
-  S_ST( 'i',	3,      168,     0 ), /*   167 durat             */
-  S_ST( 'o',	3,      464,     0 ), /*   168 durati            */
-  S_ST( 'e',	3,      174,   126 ), /*   169                   */
-  S_ST( 'n',	3,      297,     0 ), /*   170 e                 */
-  S_ST( 'a',	3,      172,     0 ), /*   171 en                */
-  S_ST( 'b',	3,      173,     0 ), /*   172 ena               */
-  S_ST( 'l',	3,      296,     0 ), /*   173 enab              */
-  S_ST( 'p',	3,      175,   170 ), /*   174 e                 */
-  S_ST( 'e',	3,      176,     0 ), /*   175 ep                */
-  S_ST( 'e',	3,      298,     0 ), /*   176 epe               */
-  S_ST( 'f',	3,      198,   169 ), /*   177                   */
-  S_ST( 'i',	3,      179,     0 ), /*   178 f                 */
-  S_ST( 'l',	3,      300,     0 ), /*   179 fi                */
-  S_ST( 'g',	3,      181,     0 ), /*   180 file              */
-  S_ST( 'e',	3,      301,     0 ), /*   181 fileg             */
-  S_ST( 'n',	3,      183,   180 ), /*   182 file              */
-  S_ST( 'u',	3,      302,     0 ), /*   183 filen             */
-  S_ST( 'l',	3,      188,   178 ), /*   184 f                 */
-  S_ST( 'a',	3,      187,     0 ), /*   185 fl                */
-  S_ST( 'g',	3,      306,     0 ), /*   186 fla               */
-  S_ST( 'k',	3,      307,   186 ), /*   187 fla               */
-  S_ST( 'o',	3,      189,   185 ), /*   188 fl                */
-  S_ST( 'o',	3,      308,     0 ), /*   189 flo               */
-  S_ST( 'r',	3,      191,   184 ), /*   190 f                 */
-  S_ST( 'e',	3,      309,     0 ), /*   191 fr                */
-  S_ST( '_',	3,      193,     0 ), /*   192 freq              */
-  S_ST( 'o',	3,      194,     0 ), /*   193 freq_             */
-  S_ST( 'f',	3,      195,     0 ), /*   194 freq_o            */
-  S_ST( 'f',	3,      196,     0 ), /*   195 freq_of           */
-  S_ST( 's',	3,      197,     0 ), /*   196 freq_off          */
-  S_ST( 'e',	3,      465,     0 ), /*   197 freq_offs         */
-  S_ST( 'u',	3,      201,   190 ), /*   198 f                 */
-  S_ST( 'd',	3,      200,     0 ), /*   199 fu                */
-  S_ST( 'g',	3,      310,     0 ), /*   200 fud               */
-  S_ST( 'z',	3,      311,   199 ), /*   201 fu                */
-  S_ST( 'h',	3,      205,   177 ), /*   202                   */
-  S_ST( 'o',	3,      204,     0 ), /*   203 h                 */
-  S_ST( 's',	3,      312,     0 ), /*   204 ho                */
-  S_ST( 'u',	3,      206,   203 ), /*   205 h                 */
-  S_ST( 'f',	3,      207,     0 ), /*   206 hu                */
-  S_ST( 'f',	3,      208,     0 ), /*   207 huf               */
-  S_ST( 'p',	3,      209,     0 ), /*   208 huff              */
-  S_ST( 'u',	3,      210,     0 ), /*   209 huffp             */
-  S_ST( 'f',	3,      313,     0 ), /*   210 huffpu            */
-  S_ST( 'i',	3,      255,   202 ), /*   211                   */
-  S_ST( 'b',	3,      213,     0 ), /*   212 i                 */
-  S_ST( 'u',	3,      214,     0 ), /*   213 ib                */
-  S_ST( 'r',	3,      215,     0 ), /*   214 ibu               */
-  S_ST( 's',	3,      314,     0 ), /*   215 ibur              */
-  S_ST( 'd',	3,      217,   212 ), /*   216 i                 */
-  S_ST( 'e',	3,      218,     0 ), /*   217 id                */
-  S_ST( 'n',	3,      315,     0 ), /*   218 ide               */
-  S_ST( 'g',	3,      220,   216 ), /*   219 i                 */
-  S_ST( 'n',	3,      221,     0 ), /*   220 ig                */
-  S_ST( 'o',	3,      222,     0 ), /*   221 ign               */
-  S_ST( 'r',	3,      316,     0 ), /*   222 igno              */
-  S_ST( 'h',	3,      224,     0 ), /*   223 ignore            */
-  S_ST( 'a',	3,      225,     0 ), /*   224 ignoreh           */
-  S_ST( 's',	3,      317,     0 ), /*   225 ignoreha          */
-  S_ST( 'n',	3,      249,   219 ), /*   226 i                 */
-  S_ST( 'c',	3,      239,     0 ), /*   227 in                */
-  S_ST( 'a',	3,      229,     0 ), /*   228 inc               */
-  S_ST( 'l',	3,      230,     0 ), /*   229 inca              */
-  S_ST( 'l',	3,      231,     0 ), /*   230 incal             */
-  S_ST( 'o',	3,      318,     0 ), /*   231 incall            */
-  S_ST( 'l',	3,      233,   228 ), /*   232 inc               */
-  S_ST( 'u',	3,      234,     0 ), /*   233 incl              */
-  S_ST( 'd',	3,      235,     0 ), /*   234 inclu             */
-  S_ST( 'e',	3,      236,     0 ), /*   235 includ            */
-  S_ST( 'f',	3,      237,     0 ), /*   236 include           */
-  S_ST( 'i',	3,      238,     0 ), /*   237 includef          */
-  S_ST( 'l',	3,      322,     0 ), /*   238 includefi         */
-  S_ST( 'm',	3,      240,   232 ), /*   239 inc               */
-  S_ST( 'e',	3,      319,     0 ), /*   240 incm              */
-  S_ST( 'i',	3,      242,   227 ), /*   241 in                */
-  S_ST( 't',	3,      247,     0 ), /*   242 ini               */
-  S_ST( 'a',	3,      244,     0 ), /*   243 init              */
-  S_ST( 'l',	3,      245,     0 ), /*   244 inita             */
-  S_ST( 'l',	3,      246,     0 ), /*   245 inital            */
-  S_ST( 'o',	3,      320,     0 ), /*   246 initall           */
-  S_ST( 'm',	3,      248,   243 ), /*   247 init              */
-  S_ST( 'e',	3,      321,     0 ), /*   248 initm             */
-  S_ST( 't',	3,      250,   241 ), /*   249 in                */
-  S_ST( 'e',	3,      251,     0 ), /*   250 int               */
-  S_ST( 'r',	3,      252,     0 ), /*   251 inte              */
-  S_ST( 'f',	3,      253,     0 ), /*   252 inter             */
-  S_ST( 'a',	3,      254,     0 ), /*   253 interf            */
-  S_ST( 'c',	3,      324,     0 ), /*   254 interfa           */
-  S_ST( 'p',	3,      445,   326 ), /*   255 i                 */
-  S_ST( 'p',	3,      257,     0 ), /*   256 ip                */
-  S_ST( 'e',	3,      291,     0 ), /*   257 ipp               */
+  S_ST( 'l',	3,      134,   129 ), /*   133 de                */
+  S_ST( 'r',	3,      135,     0 ), /*   134 del               */
+  S_ST( 'e',	3,      136,     0 ), /*   135 delr              */
+  S_ST( 's',	3,      137,     0 ), /*   136 delre             */
+  S_ST( 't',	3,      138,     0 ), /*   137 delres            */
+  S_ST( 'r',	3,      139,     0 ), /*   138 delrest           */
+  S_ST( 'i',	3,      140,     0 ), /*   139 delrestr          */
+  S_ST( 'c',	3,      286,     0 ), /*   140 delrestri         */
+  S_ST( 'v',	3,      142,   133 ), /*   141 de                */
+  S_ST( 'i',	3,      143,     0 ), /*   142 dev               */
+  S_ST( 'c',	3,      287,     0 ), /*   143 devi              */
+  S_ST( 'i',	3,      148,   128 ), /*   144 d                 */
+  S_ST( 'g',	3,      146,     0 ), /*   145 di                */
+  S_ST( 'e',	3,      147,     0 ), /*   146 dig               */
+  S_ST( 's',	3,      288,     0 ), /*   147 dige              */
+  S_ST( 's',	3,      155,   145 ), /*   148 di                */
+  S_ST( 'a',	3,      150,     0 ), /*   149 dis               */
+  S_ST( 'b',	3,      151,     0 ), /*   150 disa              */
+  S_ST( 'l',	3,      289,     0 ), /*   151 disab             */
+  S_ST( 'c',	3,      153,   149 ), /*   152 dis               */
+  S_ST( 'a',	3,      154,     0 ), /*   153 disc              */
+  S_ST( 'r',	3,      290,     0 ), /*   154 disca             */
+  S_ST( 'p',	3,      156,   152 ), /*   155 dis               */
+  S_ST( 'e',	3,      157,     0 ), /*   156 disp              */
+  S_ST( 'r',	3,      158,     0 ), /*   157 dispe             */
+  S_ST( 's',	3,      159,     0 ), /*   158 disper            */
+  S_ST( 'i',	3,      160,     0 ), /*   159 dispers           */
+  S_ST( 'o',	3,      291,     0 ), /*   160 dispersi          */
+  S_ST( 'r',	3,      168,   144 ), /*   161 d                 */
+  S_ST( 'i',	3,      163,     0 ), /*   162 dr                */
+  S_ST( 'f',	3,      164,     0 ), /*   163 dri               */
+  S_ST( 't',	3,      165,     0 ), /*   164 drif              */
+  S_ST( 'f',	3,      166,     0 ), /*   165 drift             */
+  S_ST( 'i',	3,      167,     0 ), /*   166 driftf            */
+  S_ST( 'l',	3,      293,     0 ), /*   167 driftfi           */
+  S_ST( 'o',	3,      294,   162 ), /*   168 dr                */
+  S_ST( 's',	3,      170,   161 ), /*   169 d                 */
+  S_ST( 'c',	3,      295,     0 ), /*   170 ds                */
+  S_ST( 'u',	3,      172,   169 ), /*   171 d                 */
+  S_ST( 'r',	3,      173,     0 ), /*   172 du                */
+  S_ST( 'a',	3,      174,     0 ), /*   173 dur               */
+  S_ST( 't',	3,      175,     0 ), /*   174 dura              */
+  S_ST( 'i',	3,      176,     0 ), /*   175 durat             */
+  S_ST( 'o',	3,      465,     0 ), /*   176 durati            */
+  S_ST( 'e',	3,      182,   126 ), /*   177                   */
+  S_ST( 'n',	3,      298,     0 ), /*   178 e                 */
+  S_ST( 'a',	3,      180,     0 ), /*   179 en                */
+  S_ST( 'b',	3,      181,     0 ), /*   180 ena               */
+  S_ST( 'l',	3,      297,     0 ), /*   181 enab              */
+  S_ST( 'p',	3,      183,   178 ), /*   182 e                 */
+  S_ST( 'e',	3,      184,     0 ), /*   183 ep                */
+  S_ST( 'e',	3,      299,     0 ), /*   184 epe               */
+  S_ST( 'f',	3,      206,   177 ), /*   185                   */
+  S_ST( 'i',	3,      187,     0 ), /*   186 f                 */
+  S_ST( 'l',	3,      301,     0 ), /*   187 fi                */
+  S_ST( 'g',	3,      189,     0 ), /*   188 file              */
+  S_ST( 'e',	3,      302,     0 ), /*   189 fileg             */
+  S_ST( 'n',	3,      191,   188 ), /*   190 file              */
+  S_ST( 'u',	3,      303,     0 ), /*   191 filen             */
+  S_ST( 'l',	3,      196,   186 ), /*   192 f                 */
+  S_ST( 'a',	3,      195,     0 ), /*   193 fl                */
+  S_ST( 'g',	3,      307,     0 ), /*   194 fla               */
+  S_ST( 'k',	3,      308,   194 ), /*   195 fla               */
+  S_ST( 'o',	3,      197,   193 ), /*   196 fl                */
+  S_ST( 'o',	3,      309,     0 ), /*   197 flo               */
+  S_ST( 'r',	3,      199,   192 ), /*   198 f                 */
+  S_ST( 'e',	3,      310,     0 ), /*   199 fr                */
+  S_ST( '_',	3,      201,     0 ), /*   200 freq              */
+  S_ST( 'o',	3,      202,     0 ), /*   201 freq_             */
+  S_ST( 'f',	3,      203,     0 ), /*   202 freq_o            */
+  S_ST( 'f',	3,      204,     0 ), /*   203 freq_of           */
+  S_ST( 's',	3,      205,     0 ), /*   204 freq_off          */
+  S_ST( 'e',	3,      466,     0 ), /*   205 freq_offs         */
+  S_ST( 'u',	3,      209,   198 ), /*   206 f                 */
+  S_ST( 'd',	3,      208,     0 ), /*   207 fu                */
+  S_ST( 'g',	3,      311,     0 ), /*   208 fud               */
+  S_ST( 'z',	3,      312,   207 ), /*   209 fu                */
+  S_ST( 'h',	3,      213,   185 ), /*   210                   */
+  S_ST( 'o',	3,      212,     0 ), /*   211 h                 */
+  S_ST( 's',	3,      313,     0 ), /*   212 ho                */
+  S_ST( 'u',	3,      214,   211 ), /*   213 h                 */
+  S_ST( 'f',	3,      215,     0 ), /*   214 hu                */
+  S_ST( 'f',	3,      216,     0 ), /*   215 huf               */
+  S_ST( 'p',	3,      217,     0 ), /*   216 huff              */
+  S_ST( 'u',	3,      218,     0 ), /*   217 huffp             */
+  S_ST( 'f',	3,      314,     0 ), /*   218 huffpu            */
+  S_ST( 'i',	3,      430,   210 ), /*   219                   */
+  S_ST( 'b',	3,      221,     0 ), /*   220 i                 */
+  S_ST( 'u',	3,      222,     0 ), /*   221 ib                */
+  S_ST( 'r',	3,      223,     0 ), /*   222 ibu               */
+  S_ST( 's',	3,      315,     0 ), /*   223 ibur              */
+  S_ST( 'd',	3,      225,   220 ), /*   224 i                 */
+  S_ST( 'e',	3,      226,     0 ), /*   225 id                */
+  S_ST( 'n',	3,      316,     0 ), /*   226 ide               */
+  S_ST( 'g',	3,      228,   224 ), /*   227 i                 */
+  S_ST( 'n',	3,      229,     0 ), /*   228 ig                */
+  S_ST( 'o',	3,      230,     0 ), /*   229 ign               */
+  S_ST( 'r',	3,      317,     0 ), /*   230 igno              */
+  S_ST( 'h',	3,      232,     0 ), /*   231 ignore            */
+  S_ST( 'a',	3,      233,     0 ), /*   232 ignoreh           */
+  S_ST( 's',	3,      318,     0 ), /*   233 ignoreha          */
+  S_ST( 'n',	3,      257,   227 ), /*   234 i                 */
+  S_ST( 'c',	3,      247,     0 ), /*   235 in                */
+  S_ST( 'a',	3,      237,     0 ), /*   236 inc               */
+  S_ST( 'l',	3,      238,     0 ), /*   237 inca              */
+  S_ST( 'l',	3,      239,     0 ), /*   238 incal             */
+  S_ST( 'o',	3,      319,     0 ), /*   239 incall            */
+  S_ST( 'l',	3,      241,   236 ), /*   240 inc               */
+  S_ST( 'u',	3,      242,     0 ), /*   241 incl              */
+  S_ST( 'd',	3,      243,     0 ), /*   242 inclu             */
+  S_ST( 'e',	3,      244,     0 ), /*   243 includ            */
+  S_ST( 'f',	3,      245,     0 ), /*   244 include           */
+  S_ST( 'i',	3,      246,     0 ), /*   245 includef          */
+  S_ST( 'l',	3,      323,     0 ), /*   246 includefi         */
+  S_ST( 'm',	3,      248,   240 ), /*   247 inc               */
+  S_ST( 'e',	3,      320,     0 ), /*   248 incm              */
+  S_ST( 'i',	3,      250,   235 ), /*   249 in                */
+  S_ST( 't',	3,      255,     0 ), /*   250 ini               */
+  S_ST( 'a',	3,      252,     0 ), /*   251 init              */
+  S_ST( 'l',	3,      253,     0 ), /*   252 inita             */
+  S_ST( 'l',	3,      254,     0 ), /*   253 inital            */
+  S_ST( 'o',	3,      321,     0 ), /*   254 initall           */
+  S_ST( 'm',	3,      256,   251 ), /*   255 init              */
+  S_ST( 'e',	3,      322,     0 ), /*   256 initm             */
+  S_ST( 't',	3,      292,   249 ), /*   257 in                */
   S_ST( 'v',	1,        0,     0 ), /*   258 T_Abbrev          */
   S_ST( 'e',	0,        0,     0 ), /*   259 T_Age             */
   S_ST( 'l',	0,       12,     0 ), /*   260 T_All             */
@@ -515,721 +516,730 @@ const scan_state sst[1002] = {
   S_ST( 'l',	0,        0,     0 ), /*   283 T_Ctl             */
   S_ST( 'y',	0,        0,     0 ), /*   284 T_Day             */
   S_ST( 't',	0,        0,     0 ), /*   285 T_Default         */
-  S_ST( 'e',	1,        0,     0 ), /*   286 T_Device          */
-  S_ST( 't',	1,        0,     0 ), /*   287 T_Digest          */
-  S_ST( 'e',	0,        0,     0 ), /*   288 T_Disable         */
-  S_ST( 'd',	0,        0,     0 ), /*   289 T_Discard         */
-  S_ST( 'n',	0,        0,     0 ), /*   290 T_Dispersion      */
-  S_ST( 'e',	3,      299,     0 ), /*   291 ippe              */
-  S_ST( 'e',	1,        0,     0 ), /*   292 T_Driftfile       */
-  S_ST( 'p',	0,        0,     0 ), /*   293 T_Drop            */
-  S_ST( 'p',	0,        0,     0 ), /*   294 T_Dscp            */
-  S_ST( '.',	0,        0,     0 ), /*   295 T_Ellipsis        */
-  S_ST( 'e',	0,        0,     0 ), /*   296 T_Enable          */
-  S_ST( 'd',	0,        0,   171 ), /*   297 T_End             */
-  S_ST( 'r',	0,        0,     0 ), /*   298 T_Epeer           */
-  S_ST( 'r',	3,      323,     0 ), /*   299 ippee             */
-  S_ST( 'e',	1,      182,     0 ), /*   300 T_File            */
-  S_ST( 'n',	0,        0,     0 ), /*   301 T_Filegen         */
-  S_ST( 'm',	0,        0,     0 ), /*   302 T_Filenum         */
-  S_ST( '1',	0,        0,     0 ), /*   303 T_Flag1           */
-  S_ST( '2',	0,        0,   303 ), /*   304 T_Flag2           */
-  S_ST( '3',	0,        0,   304 ), /*   305 T_Flag3           */
-  S_ST( '4',	0,        0,   305 ), /*   306 T_Flag4           */
-  S_ST( 'e',	0,        0,     0 ), /*   307 T_Flake           */
-  S_ST( 'r',	0,        0,     0 ), /*   308 T_Floor           */
-  S_ST( 'q',	0,      192,     0 ), /*   309 T_Freq            */
-  S_ST( 'e',	1,        0,     0 ), /*   310 T_Fudge           */
-  S_ST( 'z',	0,        0,     0 ), /*   311 T_Fuzz            */
-  S_ST( 't',	1,        0,     0 ), /*   312 T_Host            */
-  S_ST( 'f',	0,        0,     0 ), /*   313 T_Huffpuff        */
-  S_ST( 't',	0,        0,     0 ), /*   314 T_Iburst          */
-  S_ST( 't',	1,        0,     0 ), /*   315 T_Ident           */
-  S_ST( 'e',	0,      223,     0 ), /*   316 T_Ignore          */
-  S_ST( 'h',	0,        0,     0 ), /*   317 T_Ignorehash      */
-  S_ST( 'c',	0,        0,     0 ), /*   318 T_Incalloc        */
-  S_ST( 'm',	0,        0,     0 ), /*   319 T_Incmem          */
-  S_ST( 'c',	0,        0,     0 ), /*   320 T_Initalloc       */
-  S_ST( 'm',	0,        0,     0 ), /*   321 T_Initmem         */
-  S_ST( 'e',	1,        0,     0 ), /*   322 T_Includefile     */
-  S_ST( 'l',	3,      325,     0 ), /*   323 ippeer            */
-  S_ST( 'e',	0,        0,     0 ), /*   324 T_Interface       */
-  S_ST( 'i',	3,      417,     0 ), /*   325 ippeerl           */
-  S_ST( 'o',	0,        0,   226 ), /*   326 T_Io              */
-  S_ST( 't',	0,        0,     0 ), /*   327 T_Ippeerlimit     */
-  S_ST( '4',	0,        0,     0 ), /*   328 T_Ipv4            */
-  S_ST( '4',	0,        0,     0 ), /*   329 T_Ipv4_flag       */
-  S_ST( '6',	0,        0,   328 ), /*   330 T_Ipv6            */
-  S_ST( '6',	0,        0,   329 ), /*   331 T_Ipv6_flag       */
-  S_ST( 'l',	0,        0,     0 ), /*   332 T_Kernel          */
-  S_ST( 'y',	0,      334,   474 ), /*   333 T_Key             */
-  S_ST( 's',	1,      477,     0 ), /*   334 T_Keys            */
-  S_ST( 'r',	1,        0,     0 ), /*   335 T_Keysdir         */
-  S_ST( 'd',	0,        0,     0 ), /*   336 T_Kod             */
-  S_ST( 'e',	1,        0,     0 ), /*   337 T_Leapfile        */
-  S_ST( 'l',	0,        0,     0 ), /*   338 T_Leapsmearinterval */
-  S_ST( 'd',	0,        0,     0 ), /*   339 T_Limited         */
-  S_ST( 'k',	0,        0,     0 ), /*   340 T_Link            */
-  S_ST( 'n',	0,        0,     0 ), /*   341 T_Listen          */
-  S_ST( 'g',	2,        0,     0 ), /*   342 T_Logconfig       */
-  S_ST( 'e',	1,        0,     0 ), /*   343 T_Logfile         */
-  S_ST( 's',	0,        0,     0 ), /*   344 T_Loopstats       */
-  S_ST( 'p',	0,        0,     0 ), /*   345 T_Lowpriotrap     */
-  S_ST( 't',	1,        0,     0 ), /*   346 T_Manycastclient  */
-  S_ST( 'r',	2,        0,     0 ), /*   347 T_Manycastserver  */
-  S_ST( 'k',	0,        0,     0 ), /*   348 T_Mask            */
-  S_ST( 'e',	0,        0,     0 ), /*   349 T_Maxage          */
-  S_ST( 'k',	0,        0,     0 ), /*   350 T_Maxclock        */
-  S_ST( 'h',	0,        0,     0 ), /*   351 T_Maxdepth        */
-  S_ST( 't',	0,        0,     0 ), /*   352 T_Maxdist         */
-  S_ST( 'm',	0,        0,     0 ), /*   353 T_Maxmem          */
-  S_ST( 'l',	0,        0,     0 ), /*   354 T_Maxpoll         */
-  S_ST( 's',	0,        0,     0 ), /*   355 T_Mdnstries       */
-  S_ST( 'm',	0,      577,     0 ), /*   356 T_Mem             */
-  S_ST( 'k',	0,        0,     0 ), /*   357 T_Memlock         */
-  S_ST( 'k',	0,        0,     0 ), /*   358 T_Minclock        */
-  S_ST( 'h',	0,        0,     0 ), /*   359 T_Mindepth        */
-  S_ST( 't',	0,        0,     0 ), /*   360 T_Mindist         */
-  S_ST( 'm',	0,        0,     0 ), /*   361 T_Minimum         */
-  S_ST( 'r',	0,        0,     0 ), /*   362 T_Minjitter       */
-  S_ST( 'l',	0,        0,     0 ), /*   363 T_Minpoll         */
-  S_ST( 'e',	0,        0,     0 ), /*   364 T_Minsane         */
-  S_ST( 'e',	0,      366,     0 ), /*   365 T_Mode            */
-  S_ST( '7',	0,        0,     0 ), /*   366 T_Mode7           */
-  S_ST( 'r',	0,        0,     0 ), /*   367 T_Monitor         */
-  S_ST( 'h',	0,        0,     0 ), /*   368 T_Month           */
-  S_ST( 'u',	0,        0,     0 ), /*   369 T_Mru             */
-  S_ST( 'p',	0,        0,     0 ), /*   370 T_Mssntp          */
-  S_ST( 't',	2,        0,     0 ), /*   371 T_Multicastclient */
-  S_ST( 'c',	0,        0,     0 ), /*   372 T_Nic             */
-  S_ST( 'k',	0,        0,     0 ), /*   373 T_Nolink          */
-  S_ST( 'y',	0,        0,     0 ), /*   374 T_Nomodify        */
-  S_ST( 't',	0,        0,     0 ), /*   375 T_Nomrulist       */
-  S_ST( 'e',	0,        0,     0 ), /*   376 T_None            */
-  S_ST( 'e',	0,        0,     0 ), /*   377 T_Nonvolatile     */
-  S_ST( 'r',	0,        0,     0 ), /*   378 T_Noepeer         */
-  S_ST( 'r',	0,        0,     0 ), /*   379 T_Nopeer          */
-  S_ST( 'y',	0,        0,     0 ), /*   380 T_Noquery         */
-  S_ST( 't',	0,        0,     0 ), /*   381 T_Noselect        */
-  S_ST( 'e',	0,        0,     0 ), /*   382 T_Noserve         */
-  S_ST( 'p',	0,        0,     0 ), /*   383 T_Notrap          */
-  S_ST( 't',	0,        0,     0 ), /*   384 T_Notrust         */
-  S_ST( 'p',	0,      682,     0 ), /*   385 T_Ntp             */
-  S_ST( 't',	0,        0,     0 ), /*   386 T_Ntpport         */
-  S_ST( 't',	1,        0,     0 ), /*   387 T_NtpSignDsocket  */
-  S_ST( 'n',	0,      697,     0 ), /*   388 T_Orphan          */
-  S_ST( 't',	0,        0,     0 ), /*   389 T_Orphanwait      */
-  S_ST( 'y',	0,        0,     0 ), /*   390 T_PCEdigest       */
-  S_ST( 'c',	0,        0,     0 ), /*   391 T_Panic           */
-  S_ST( 'r',	1,      724,     0 ), /*   392 T_Peer            */
-  S_ST( 's',	0,        0,     0 ), /*   393 T_Peerstats       */
-  S_ST( 'e',	2,        0,     0 ), /*   394 T_Phone           */
-  S_ST( 'd',	0,      732,     0 ), /*   395 T_Pid             */
-  S_ST( 'e',	1,        0,     0 ), /*   396 T_Pidfile         */
-  S_ST( 'l',	0,      737,     0 ), /*   397 T_Poll            */
-  S_ST( 't',	0,        0,     0 ), /*   398 T_PollSkewList    */
-  S_ST( 'l',	1,        0,     0 ), /*   399 T_Pool            */
-  S_ST( 't',	0,        0,     0 ), /*   400 T_Port            */
-  S_ST( 'a',	1,        0,     0 ), /*   401 T_PpsData         */
-  S_ST( 't',	0,        0,     0 ), /*   402 T_Preempt         */
-  S_ST( 'r',	0,        0,     0 ), /*   403 T_Prefer          */
-  S_ST( 's',	0,        0,     0 ), /*   404 T_Protostats      */
-  S_ST( 'w',	1,        0,   751 ), /*   405 T_Pw              */
-  S_ST( 'e',	1,        0,     0 ), /*   406 T_Randfile        */
-  S_ST( 's',	0,        0,     0 ), /*   407 T_Rawstats        */
-  S_ST( 'd',	1,        0,     0 ), /*   408 T_Refid           */
-  S_ST( 'y',	0,        0,     0 ), /*   409 T_Requestkey      */
-  S_ST( 't',	0,        0,     0 ), /*   410 T_Reset           */
-  S_ST( 't',	0,        0,     0 ), /*   411 T_Restrict        */
-  S_ST( 'e',	0,        0,     0 ), /*   412 T_Revoke          */
-  S_ST( 't',	0,        0,     0 ), /*   413 T_Rlimit          */
-  S_ST( 'r',	1,        0,     0 ), /*   414 T_Saveconfigdir   */
-  S_ST( 'r',	1,      834,     0 ), /*   415 T_Server          */
-  S_ST( 'e',	0,        0,     0 ), /*   416 T_Serverresponse  */
-  S_ST( 'm',	3,      429,     0 ), /*   417 ippeerli          */
-  S_ST( 'r',	1,        0,     0 ), /*   418 T_Setvar          */
-  S_ST( 'e',	0,        0,     0 ), /*   419 T_Source          */
-  S_ST( 'e',	0,        0,     0 ), /*   420 T_Stacksize       */
-  S_ST( 's',	0,        0,     0 ), /*   421 T_Statistics      */
-  S_ST( 's',	0,      878,   873 ), /*   422 T_Stats           */
-  S_ST( 'r',	1,        0,     0 ), /*   423 T_Statsdir        */
-  S_ST( 'p',	0,      886,     0 ), /*   424 T_Step            */
-  S_ST( 'k',	0,        0,     0 ), /*   425 T_Stepback        */
-  S_ST( 'd',	0,        0,     0 ), /*   426 T_Stepfwd         */
-  S_ST( 't',	0,        0,     0 ), /*   427 T_Stepout         */
-  S_ST( 'm',	0,        0,     0 ), /*   428 T_Stratum         */
-  S_ST( 'i',	3,      327,     0 ), /*   429 ippeerlim         */
-  S_ST( 's',	0,      893,     0 ), /*   430 T_Sys             */
-  S_ST( 's',	0,        0,     0 ), /*   431 T_Sysstats        */
-  S_ST( 'k',	0,        0,     0 ), /*   432 T_Tick            */
-  S_ST( '1',	0,        0,     0 ), /*   433 T_Time1           */
-  S_ST( '2',	0,        0,   433 ), /*   434 T_Time2           */
-  S_ST( 'a',	1,        0,     0 ), /*   435 T_TimeData        */
-  S_ST( 'r',	0,        0,   902 ), /*   436 T_Timer           */
-  S_ST( 's',	0,        0,     0 ), /*   437 T_Timingstats     */
-  S_ST( 'r',	0,        0,     0 ), /*   438 T_Tinker          */
-  S_ST( 's',	0,        0,     0 ), /*   439 T_Tos             */
-  S_ST( 'p',	1,        0,     0 ), /*   440 T_Trap            */
-  S_ST( 'e',	0,        0,     0 ), /*   441 T_True            */
-  S_ST( 'y',	0,        0,     0 ), /*   442 T_Trustedkey      */
-  S_ST( 'l',	0,        0,     0 ), /*   443 T_Ttl             */
-  S_ST( 'e',	0,        0,     0 ), /*   444 T_Type            */
-  S_ST( 'v',	3,      330,   256 ), /*   445 ip                */
-  S_ST( 'y',	0,        0,     0 ), /*   446 T_UEcrypto        */
-  S_ST( 'y',	0,        0,     0 ), /*   447 T_UEcryptonak     */
-  S_ST( 'y',	0,        0,     0 ), /*   448 T_UEdigest        */
-  S_ST( 'g',	1,        0,     0 ), /*   449 T_Unconfig        */
-  S_ST( 'r',	1,      938,     0 ), /*   450 T_Unpeer          */
-  S_ST( 'n',	0,        0,     0 ), /*   451 T_Version         */
-  S_ST( 'j',	3,      458,   211 ), /*   452                   */
-  S_ST( 'k',	0,        0,     0 ), /*   453 T_Week            */
-  S_ST( 'd',	0,        0,     0 ), /*   454 T_Wildcard        */
-  S_ST( 'e',	0,        0,     0 ), /*   455 T_Xleave          */
-  S_ST( 'e',	0,        0,     0 ), /*   456 T_Xmtnonce        */
-  S_ST( 'r',	0,        0,     0 ), /*   457 T_Year            */
-  S_ST( 'i',	3,      459,     0 ), /*   458 j                 */
-  S_ST( 't',	3,      470,     0 ), /*   459 ji                */
-  S_ST( 'e',	0,        0,     0 ), /*   460 T_Simulate        */
-  S_ST( 'y',	0,        0,     0 ), /*   461 T_Beep_Delay      */
-  S_ST( 'n',	0,        0,     0 ), /*   462 T_Sim_Duration    */
-  S_ST( 't',	0,        0,     0 ), /*   463 T_Server_Offset   */
-  S_ST( 'n',	0,        0,     0 ), /*   464 T_Duration        */
-  S_ST( 't',	0,        0,     0 ), /*   465 T_Freq_Offset     */
-  S_ST( 'r',	0,        0,     0 ), /*   466 T_Wander          */
-  S_ST( 'r',	0,        0,     0 ), /*   467 T_Jitter          */
-  S_ST( 'y',	0,        0,     0 ), /*   468 T_Prop_Delay      */
-  S_ST( 'y',	0,        0,     0 ), /*   469 T_Proc_Delay      */
-  S_ST( 't',	3,      471,     0 ), /*   470 jit               */
-  S_ST( 'e',	3,      467,     0 ), /*   471 jitt              */
-  S_ST( 'k',	3,      479,   452 ), /*   472                   */
-  S_ST( 'e',	3,      333,     0 ), /*   473 k                 */
-  S_ST( 'r',	3,      475,     0 ), /*   474 ke                */
-  S_ST( 'n',	3,      476,     0 ), /*   475 ker               */
-  S_ST( 'e',	3,      332,     0 ), /*   476 kern              */
-  S_ST( 'd',	3,      478,     0 ), /*   477 keys              */
-  S_ST( 'i',	3,      335,     0 ), /*   478 keysd             */
-  S_ST( 'o',	3,      336,   473 ), /*   479 k                 */
-  S_ST( 'l',	3,      508,   472 ), /*   480                   */
-  S_ST( 'e',	3,      482,     0 ), /*   481 l                 */
-  S_ST( 'a',	3,      483,     0 ), /*   482 le                */
-  S_ST( 'p',	3,      487,     0 ), /*   483 lea               */
-  S_ST( 'f',	3,      485,     0 ), /*   484 leap              */
-  S_ST( 'i',	3,      486,     0 ), /*   485 leapf             */
-  S_ST( 'l',	3,      337,     0 ), /*   486 leapfi            */
-  S_ST( 's',	3,      488,   484 ), /*   487 leap              */
-  S_ST( 'm',	3,      489,     0 ), /*   488 leaps             */
-  S_ST( 'e',	3,      490,     0 ), /*   489 leapsm            */
-  S_ST( 'a',	3,      491,     0 ), /*   490 leapsme           */
-  S_ST( 'r',	3,      492,     0 ), /*   491 leapsmea          */
-  S_ST( 'i',	3,      493,     0 ), /*   492 leapsmear         */
-  S_ST( 'n',	3,      494,     0 ), /*   493 leapsmeari        */
-  S_ST( 't',	3,      495,     0 ), /*   494 leapsmearin       */
-  S_ST( 'e',	3,      496,     0 ), /*   495 leapsmearint      */
-  S_ST( 'r',	3,      497,     0 ), /*   496 leapsmearinte     */
-  S_ST( 'v',	3,      498,     0 ), /*   497 leapsmearinter    */
-  S_ST( 'a',	3,      338,     0 ), /*   498 leapsmearinterv   */
-  S_ST( 'i',	3,      505,   481 ), /*   499 l                 */
-  S_ST( 'm',	3,      501,     0 ), /*   500 li                */
-  S_ST( 'i',	3,      502,     0 ), /*   501 lim               */
-  S_ST( 't',	3,      503,     0 ), /*   502 limi              */
-  S_ST( 'e',	3,      339,     0 ), /*   503 limit             */
-  S_ST( 'n',	3,      340,   500 ), /*   504 li                */
-  S_ST( 's',	3,      506,   504 ), /*   505 li                */
-  S_ST( 't',	3,      507,     0 ), /*   506 lis               */
-  S_ST( 'e',	3,      341,     0 ), /*   507 list              */
-  S_ST( 'o',	3,      524,   499 ), /*   508 l                 */
-  S_ST( 'g',	3,      515,     0 ), /*   509 lo                */
-  S_ST( 'c',	3,      511,     0 ), /*   510 log               */
-  S_ST( 'o',	3,      512,     0 ), /*   511 logc              */
-  S_ST( 'n',	3,      513,     0 ), /*   512 logco             */
-  S_ST( 'f',	3,      514,     0 ), /*   513 logcon            */
-  S_ST( 'i',	3,      342,     0 ), /*   514 logconf           */
-  S_ST( 'f',	3,      516,   510 ), /*   515 log               */
-  S_ST( 'i',	3,      517,     0 ), /*   516 logf              */
-  S_ST( 'l',	3,      343,     0 ), /*   517 logfi             */
-  S_ST( 'o',	3,      519,   509 ), /*   518 lo                */
-  S_ST( 'p',	3,      520,     0 ), /*   519 loo               */
-  S_ST( 's',	3,      521,     0 ), /*   520 loop              */
-  S_ST( 't',	3,      522,     0 ), /*   521 loops             */
-  S_ST( 'a',	3,      523,     0 ), /*   522 loopst            */
-  S_ST( 't',	3,      344,     0 ), /*   523 loopsta           */
-  S_ST( 'w',	3,      525,   518 ), /*   524 lo                */
-  S_ST( 'p',	3,      526,     0 ), /*   525 low               */
-  S_ST( 'r',	3,      527,     0 ), /*   526 lowp              */
-  S_ST( 'i',	3,      528,     0 ), /*   527 lowpr             */
-  S_ST( 'o',	3,      529,     0 ), /*   528 lowpri            */
-  S_ST( 't',	3,      530,     0 ), /*   529 lowprio           */
-  S_ST( 'r',	3,      531,     0 ), /*   530 lowpriot          */
-  S_ST( 'a',	3,      345,     0 ), /*   531 lowpriotr         */
-  S_ST( 'm',	3,      618,   480 ), /*   532                   */
-  S_ST( 'a',	3,      551,     0 ), /*   533 m                 */
-  S_ST( 'n',	3,      535,     0 ), /*   534 ma                */
-  S_ST( 'y',	3,      536,     0 ), /*   535 man               */
-  S_ST( 'c',	3,      537,     0 ), /*   536 many              */
-  S_ST( 'a',	3,      538,     0 ), /*   537 manyc             */
-  S_ST( 's',	3,      539,     0 ), /*   538 manyca            */
-  S_ST( 't',	3,      545,     0 ), /*   539 manycas           */
-  S_ST( 'c',	3,      541,     0 ), /*   540 manycast          */
-  S_ST( 'l',	3,      542,     0 ), /*   541 manycastc         */
-  S_ST( 'i',	3,      543,     0 ), /*   542 manycastcl        */
-  S_ST( 'e',	3,      544,     0 ), /*   543 manycastcli       */
-  S_ST( 'n',	3,      346,     0 ), /*   544 manycastclie      */
-  S_ST( 's',	3,      546,   540 ), /*   545 manycast          */
-  S_ST( 'e',	3,      547,     0 ), /*   546 manycasts         */
-  S_ST( 'r',	3,      548,     0 ), /*   547 manycastse        */
-  S_ST( 'v',	3,      549,     0 ), /*   548 manycastser       */
-  S_ST( 'e',	3,      347,     0 ), /*   549 manycastserv      */
-  S_ST( 's',	3,      348,   534 ), /*   550 ma                */
-  S_ST( 'x',	3,      566,   550 ), /*   551 ma                */
-  S_ST( 'a',	3,      553,     0 ), /*   552 max               */
-  S_ST( 'g',	3,      349,     0 ), /*   553 maxa              */
-  S_ST( 'c',	3,      555,   552 ), /*   554 max               */
-  S_ST( 'l',	3,      556,     0 ), /*   555 maxc              */
-  S_ST( 'o',	3,      557,     0 ), /*   556 maxcl             */
-  S_ST( 'c',	3,      350,     0 ), /*   557 maxclo            */
-  S_ST( 'd',	3,      562,   554 ), /*   558 max               */
-  S_ST( 'e',	3,      560,     0 ), /*   559 maxd              */
-  S_ST( 'p',	3,      561,     0 ), /*   560 maxde             */
-  S_ST( 't',	3,      351,     0 ), /*   561 maxdep            */
-  S_ST( 'i',	3,      563,   559 ), /*   562 maxd              */
-  S_ST( 's',	3,      352,     0 ), /*   563 maxdi             */
-  S_ST( 'm',	3,      565,   558 ), /*   564 max               */
-  S_ST( 'e',	3,      353,     0 ), /*   565 maxm              */
-  S_ST( 'p',	3,      567,   564 ), /*   566 max               */
-  S_ST( 'o',	3,      568,     0 ), /*   567 maxp              */
-  S_ST( 'l',	3,      354,     0 ), /*   568 maxpo             */
-  S_ST( 'd',	3,      570,   533 ), /*   569 m                 */
-  S_ST( 'n',	3,      571,     0 ), /*   570 md                */
-  S_ST( 's',	3,      572,     0 ), /*   571 mdn               */
-  S_ST( 't',	3,      573,     0 ), /*   572 mdns              */
-  S_ST( 'r',	3,      574,     0 ), /*   573 mdnst             */
-  S_ST( 'i',	3,      575,     0 ), /*   574 mdnstr            */
-  S_ST( 'e',	3,      355,     0 ), /*   575 mdnstri           */
-  S_ST( 'e',	3,      356,   569 ), /*   576 m                 */
-  S_ST( 'l',	3,      578,     0 ), /*   577 mem               */
-  S_ST( 'o',	3,      579,     0 ), /*   578 meml              */
-  S_ST( 'c',	3,      357,     0 ), /*   579 memlo             */
-  S_ST( 'i',	3,      581,   576 ), /*   580 m                 */
-  S_ST( 'n',	3,      603,     0 ), /*   581 mi                */
-  S_ST( 'c',	3,      583,     0 ), /*   582 min               */
-  S_ST( 'l',	3,      584,     0 ), /*   583 minc              */
-  S_ST( 'o',	3,      585,     0 ), /*   584 mincl             */
-  S_ST( 'c',	3,      358,     0 ), /*   585 minclo            */
-  S_ST( 'd',	3,      590,   582 ), /*   586 min               */
-  S_ST( 'e',	3,      588,     0 ), /*   587 mind              */
-  S_ST( 'p',	3,      589,     0 ), /*   588 minde             */
-  S_ST( 't',	3,      359,     0 ), /*   589 mindep            */
-  S_ST( 'i',	3,      591,   587 ), /*   590 mind              */
-  S_ST( 's',	3,      360,     0 ), /*   591 mindi             */
-  S_ST( 'i',	3,      593,   586 ), /*   592 min               */
-  S_ST( 'm',	3,      594,     0 ), /*   593 mini              */
-  S_ST( 'u',	3,      361,     0 ), /*   594 minim             */
-  S_ST( 'j',	3,      596,   592 ), /*   595 min               */
-  S_ST( 'i',	3,      597,     0 ), /*   596 minj              */
-  S_ST( 't',	3,      598,     0 ), /*   597 minji             */
-  S_ST( 't',	3,      599,     0 ), /*   598 minjit            */
-  S_ST( 'e',	3,      362,     0 ), /*   599 minjitt           */
-  S_ST( 'p',	3,      601,   595 ), /*   600 min               */
-  S_ST( 'o',	3,      602,     0 ), /*   601 minp              */
-  S_ST( 'l',	3,      363,     0 ), /*   602 minpo             */
-  S_ST( 's',	3,      604,   600 ), /*   603 min               */
-  S_ST( 'a',	3,      605,     0 ), /*   604 mins              */
-  S_ST( 'n',	3,      364,     0 ), /*   605 minsa             */
-  S_ST( 'o',	3,      608,   580 ), /*   606 m                 */
-  S_ST( 'd',	3,      365,     0 ), /*   607 mo                */
-  S_ST( 'n',	3,      612,   607 ), /*   608 mo                */
-  S_ST( 'i',	3,      610,     0 ), /*   609 mon               */
-  S_ST( 't',	3,      611,     0 ), /*   610 moni              */
-  S_ST( 'o',	3,      367,     0 ), /*   611 monit             */
-  S_ST( 't',	3,      368,   609 ), /*   612 mon               */
-  S_ST( 'r',	3,      369,   606 ), /*   613 m                 */
-  S_ST( 's',	3,      615,   613 ), /*   614 m                 */
-  S_ST( 's',	3,      616,     0 ), /*   615 ms                */
-  S_ST( 'n',	3,      617,     0 ), /*   616 mss               */
-  S_ST( 't',	3,      370,     0 ), /*   617 mssn              */
-  S_ST( 'u',	3,      619,   614 ), /*   618 m                 */
-  S_ST( 'l',	3,      620,     0 ), /*   619 mu                */
-  S_ST( 't',	3,      621,     0 ), /*   620 mul               */
-  S_ST( 'i',	3,      622,     0 ), /*   621 mult              */
-  S_ST( 'c',	3,      623,     0 ), /*   622 multi             */
-  S_ST( 'a',	3,      624,     0 ), /*   623 multic            */
-  S_ST( 's',	3,      625,     0 ), /*   624 multica           */
-  S_ST( 't',	3,      626,     0 ), /*   625 multicas          */
-  S_ST( 'c',	3,      627,     0 ), /*   626 multicast         */
-  S_ST( 'l',	3,      628,     0 ), /*   627 multicastc        */
-  S_ST( 'i',	3,      629,     0 ), /*   628 multicastcl       */
-  S_ST( 'e',	3,      630,     0 ), /*   629 multicastcli      */
-  S_ST( 'n',	3,      371,     0 ), /*   630 multicastclie     */
-  S_ST( 'n',	3,      678,   532 ), /*   631                   */
-  S_ST( 'i',	3,      372,     0 ), /*   632 n                 */
-  S_ST( 'o',	3,      673,   632 ), /*   633 n                 */
-  S_ST( 'e',	3,      635,     0 ), /*   634 no                */
-  S_ST( 'p',	3,      636,     0 ), /*   635 noe               */
-  S_ST( 'e',	3,      637,     0 ), /*   636 noep              */
-  S_ST( 'e',	3,      378,     0 ), /*   637 noepe             */
-  S_ST( 'l',	3,      639,   634 ), /*   638 no                */
-  S_ST( 'i',	3,      640,     0 ), /*   639 nol               */
-  S_ST( 'n',	3,      373,     0 ), /*   640 noli              */
-  S_ST( 'm',	3,      646,   638 ), /*   641 no                */
-  S_ST( 'o',	3,      643,     0 ), /*   642 nom               */
-  S_ST( 'd',	3,      644,     0 ), /*   643 nomo              */
-  S_ST( 'i',	3,      645,     0 ), /*   644 nomod             */
-  S_ST( 'f',	3,      374,     0 ), /*   645 nomodi            */
-  S_ST( 'r',	3,      647,   642 ), /*   646 nom               */
-  S_ST( 'u',	3,      648,     0 ), /*   647 nomr              */
-  S_ST( 'l',	3,      649,     0 ), /*   648 nomru             */
-  S_ST( 'i',	3,      650,     0 ), /*   649 nomrul            */
-  S_ST( 's',	3,      375,     0 ), /*   650 nomruli           */
-  S_ST( 'n',	3,      652,   641 ), /*   651 no                */
-  S_ST( 'v',	3,      653,   376 ), /*   652 non               */
-  S_ST( 'o',	3,      654,     0 ), /*   653 nonv              */
-  S_ST( 'l',	3,      655,     0 ), /*   654 nonvo             */
-  S_ST( 'a',	3,      656,     0 ), /*   655 nonvol            */
-  S_ST( 't',	3,      657,     0 ), /*   656 nonvola           */
-  S_ST( 'i',	3,      658,     0 ), /*   657 nonvolat          */
-  S_ST( 'l',	3,      377,     0 ), /*   658 nonvolati         */
-  S_ST( 'p',	3,      660,   651 ), /*   659 no                */
-  S_ST( 'e',	3,      661,     0 ), /*   660 nop               */
-  S_ST( 'e',	3,      379,     0 ), /*   661 nope              */
-  S_ST( 'q',	3,      663,   659 ), /*   662 no                */
-  S_ST( 'u',	3,      664,     0 ), /*   663 noq               */
-  S_ST( 'e',	3,      665,     0 ), /*   664 noqu              */
-  S_ST( 'r',	3,      380,     0 ), /*   665 noque             */
-  S_ST( 's',	3,      667,   662 ), /*   666 no                */
-  S_ST( 'e',	3,      671,     0 ), /*   667 nos               */
-  S_ST( 'l',	3,      669,     0 ), /*   668 nose              */
-  S_ST( 'e',	3,      670,     0 ), /*   669 nosel             */
-  S_ST( 'c',	3,      381,     0 ), /*   670 nosele            */
-  S_ST( 'r',	3,      672,   668 ), /*   671 nose              */
-  S_ST( 'v',	3,      382,     0 ), /*   672 noser             */
-  S_ST( 't',	3,      674,   666 ), /*   673 no                */
-  S_ST( 'r',	3,      676,     0 ), /*   674 not               */
-  S_ST( 'a',	3,      383,     0 ), /*   675 notr              */
-  S_ST( 'u',	3,      677,   675 ), /*   676 notr              */
-  S_ST( 's',	3,      384,     0 ), /*   677 notru             */
-  S_ST( 't',	3,      385,   633 ), /*   678 n                 */
-  S_ST( 'p',	3,      680,     0 ), /*   679 ntp               */
-  S_ST( 'o',	3,      681,     0 ), /*   680 ntpp              */
-  S_ST( 'r',	3,      386,     0 ), /*   681 ntppo             */
-  S_ST( 's',	3,      683,   679 ), /*   682 ntp               */
-  S_ST( 'i',	3,      684,     0 ), /*   683 ntps              */
-  S_ST( 'g',	3,      685,     0 ), /*   684 ntpsi             */
-  S_ST( 'n',	3,      686,     0 ), /*   685 ntpsig            */
-  S_ST( 'd',	3,      687,     0 ), /*   686 ntpsign           */
-  S_ST( 's',	3,      688,     0 ), /*   687 ntpsignd          */
-  S_ST( 'o',	3,      689,     0 ), /*   688 ntpsignds         */
-  S_ST( 'c',	3,      690,     0 ), /*   689 ntpsigndso        */
-  S_ST( 'k',	3,      691,     0 ), /*   690 ntpsigndsoc       */
-  S_ST( 'e',	3,      387,     0 ), /*   691 ntpsigndsock      */
-  S_ST( 'o',	3,      693,   631 ), /*   692                   */
-  S_ST( 'r',	3,      694,     0 ), /*   693 o                 */
-  S_ST( 'p',	3,      695,     0 ), /*   694 or                */
-  S_ST( 'h',	3,      696,     0 ), /*   695 orp               */
-  S_ST( 'a',	3,      388,     0 ), /*   696 orph              */
-  S_ST( 'w',	3,      698,     0 ), /*   697 orphan            */
-  S_ST( 'a',	3,      699,     0 ), /*   698 orphanw           */
-  S_ST( 'i',	3,      389,     0 ), /*   699 orphanwa          */
-  S_ST( 'p',	3,      405,   692 ), /*   700                   */
-  S_ST( 'a',	3,      702,     0 ), /*   701 p                 */
-  S_ST( 'n',	3,      703,     0 ), /*   702 pa                */
-  S_ST( 'i',	3,      391,     0 ), /*   703 pan               */
-  S_ST( 'e',	3,      705,   701 ), /*   704 p                 */
-  S_ST( 'e',	3,      392,     0 ), /*   705 pe                */
-  S_ST( '_',	3,      707,     0 ), /*   706 peer              */
-  S_ST( 'c',	3,      708,     0 ), /*   707 peer_             */
-  S_ST( 'l',	3,      709,     0 ), /*   708 peer_c            */
-  S_ST( 'e',	3,      710,     0 ), /*   709 peer_cl           */
-  S_ST( 'a',	3,      711,     0 ), /*   710 peer_cle          */
-  S_ST( 'r',	3,      712,     0 ), /*   711 peer_clea         */
-  S_ST( '_',	3,      713,     0 ), /*   712 peer_clear        */
-  S_ST( 'd',	3,      714,     0 ), /*   713 peer_clear_       */
-  S_ST( 'i',	3,      715,     0 ), /*   714 peer_clear_d      */
-  S_ST( 'g',	3,      716,     0 ), /*   715 peer_clear_di     */
-  S_ST( 'e',	3,      717,     0 ), /*   716 peer_clear_dig    */
-  S_ST( 's',	3,      718,     0 ), /*   717 peer_clear_dige   */
-  S_ST( 't',	3,      719,     0 ), /*   718 peer_clear_diges  */
-  S_ST( '_',	3,      720,     0 ), /*   719 peer_clear_digest */
-  S_ST( 'e',	3,      721,     0 ), /*   720 peer_clear_digest_ */
-  S_ST( 'a',	3,      722,     0 ), /*   721 peer_clear_digest_e */
-  S_ST( 'r',	3,      723,     0 ), /*   722 peer_clear_digest_ea */
-  S_ST( 'l',	3,      390,     0 ), /*   723 peer_clear_digest_ear */
-  S_ST( 's',	3,      725,   706 ), /*   724 peer              */
-  S_ST( 't',	3,      726,     0 ), /*   725 peers             */
-  S_ST( 'a',	3,      727,     0 ), /*   726 peerst            */
-  S_ST( 't',	3,      393,     0 ), /*   727 peersta           */
-  S_ST( 'h',	3,      729,   704 ), /*   728 p                 */
-  S_ST( 'o',	3,      730,     0 ), /*   729 ph                */
-  S_ST( 'n',	3,      394,     0 ), /*   730 pho               */
-  S_ST( 'i',	3,      395,   728 ), /*   731 p                 */
-  S_ST( 'f',	3,      733,     0 ), /*   732 pid               */
-  S_ST( 'i',	3,      734,     0 ), /*   733 pidf              */
-  S_ST( 'l',	3,      396,     0 ), /*   734 pidfi             */
-  S_ST( 'o',	3,      745,   731 ), /*   735 p                 */
-  S_ST( 'l',	3,      397,     0 ), /*   736 po                */
-  S_ST( 's',	3,      738,     0 ), /*   737 poll              */
-  S_ST( 'k',	3,      739,     0 ), /*   738 polls             */
-  S_ST( 'e',	3,      740,     0 ), /*   739 pollsk            */
-  S_ST( 'w',	3,      741,     0 ), /*   740 pollske           */
-  S_ST( 'l',	3,      742,     0 ), /*   741 pollskew          */
-  S_ST( 'i',	3,      743,     0 ), /*   742 pollskewl         */
-  S_ST( 's',	3,      398,     0 ), /*   743 pollskewli        */
-  S_ST( 'o',	3,      399,   736 ), /*   744 po                */
-  S_ST( 'r',	3,      400,   744 ), /*   745 po                */
-  S_ST( 'p',	3,      747,   735 ), /*   746 p                 */
-  S_ST( 's',	3,      748,     0 ), /*   747 pp                */
-  S_ST( 'd',	3,      749,     0 ), /*   748 pps               */
-  S_ST( 'a',	3,      750,     0 ), /*   749 ppsd              */
-  S_ST( 't',	3,      401,     0 ), /*   750 ppsda             */
-  S_ST( 'r',	3,      758,   746 ), /*   751 p                 */
-  S_ST( 'e',	3,      756,     0 ), /*   752 pr                */
-  S_ST( 'e',	3,      754,     0 ), /*   753 pre               */
-  S_ST( 'm',	3,      755,     0 ), /*   754 pree              */
-  S_ST( 'p',	3,      402,     0 ), /*   755 preem             */
-  S_ST( 'f',	3,      757,   753 ), /*   756 pre               */
-  S_ST( 'e',	3,      403,     0 ), /*   757 pref              */
-  S_ST( 'o',	3,      771,   752 ), /*   758 pr                */
-  S_ST( 'c',	3,      760,     0 ), /*   759 pro               */
-  S_ST( '_',	3,      761,     0 ), /*   760 proc              */
-  S_ST( 'd',	3,      762,     0 ), /*   761 proc_             */
-  S_ST( 'e',	3,      763,     0 ), /*   762 proc_d            */
-  S_ST( 'l',	3,      764,     0 ), /*   763 proc_de           */
-  S_ST( 'a',	3,      469,     0 ), /*   764 proc_del          */
-  S_ST( 'p',	3,      766,   759 ), /*   765 pro               */
-  S_ST( '_',	3,      767,     0 ), /*   766 prop              */
-  S_ST( 'd',	3,      768,     0 ), /*   767 prop_             */
-  S_ST( 'e',	3,      769,     0 ), /*   768 prop_d            */
-  S_ST( 'l',	3,      770,     0 ), /*   769 prop_de           */
-  S_ST( 'a',	3,      468,     0 ), /*   770 prop_del          */
-  S_ST( 't',	3,      772,   765 ), /*   771 pro               */
-  S_ST( 'o',	3,      773,     0 ), /*   772 prot              */
-  S_ST( 's',	3,      774,     0 ), /*   773 proto             */
-  S_ST( 't',	3,      775,     0 ), /*   774 protos            */
-  S_ST( 'a',	3,      776,     0 ), /*   775 protost           */
-  S_ST( 't',	3,      404,     0 ), /*   776 protosta          */
-  S_ST( 'r',	3,      808,   700 ), /*   777                   */
-  S_ST( 'a',	3,      784,     0 ), /*   778 r                 */
-  S_ST( 'n',	3,      780,     0 ), /*   779 ra                */
-  S_ST( 'd',	3,      781,     0 ), /*   780 ran               */
-  S_ST( 'f',	3,      782,     0 ), /*   781 rand              */
-  S_ST( 'i',	3,      783,     0 ), /*   782 randf             */
-  S_ST( 'l',	3,      406,     0 ), /*   783 randfi            */
-  S_ST( 'w',	3,      785,   779 ), /*   784 ra                */
-  S_ST( 's',	3,      786,     0 ), /*   785 raw               */
-  S_ST( 't',	3,      787,     0 ), /*   786 raws              */
-  S_ST( 'a',	3,      788,     0 ), /*   787 rawst             */
-  S_ST( 't',	3,      407,     0 ), /*   788 rawsta            */
-  S_ST( 'e',	3,      805,   778 ), /*   789 r                 */
-  S_ST( 'f',	3,      791,     0 ), /*   790 re                */
-  S_ST( 'i',	3,      408,     0 ), /*   791 ref               */
-  S_ST( 'q',	3,      793,   790 ), /*   792 re                */
-  S_ST( 'u',	3,      794,     0 ), /*   793 req               */
-  S_ST( 'e',	3,      795,     0 ), /*   794 requ              */
-  S_ST( 's',	3,      796,     0 ), /*   795 reque             */
-  S_ST( 't',	3,      797,     0 ), /*   796 reques            */
-  S_ST( 'k',	3,      798,     0 ), /*   797 request           */
-  S_ST( 'e',	3,      409,     0 ), /*   798 requestk          */
-  S_ST( 's',	3,      801,   792 ), /*   799 re                */
-  S_ST( 'e',	3,      410,     0 ), /*   800 res               */
-  S_ST( 't',	3,      802,   800 ), /*   801 res               */
-  S_ST( 'r',	3,      803,     0 ), /*   802 rest              */
-  S_ST( 'i',	3,      804,     0 ), /*   803 restr             */
-  S_ST( 'c',	3,      411,     0 ), /*   804 restri            */
-  S_ST( 'v',	3,      806,   799 ), /*   805 re                */
-  S_ST( 'o',	3,      807,     0 ), /*   806 rev               */
-  S_ST( 'k',	3,      412,     0 ), /*   807 revo              */
-  S_ST( 'l',	3,      809,   789 ), /*   808 r                 */
-  S_ST( 'i',	3,      810,     0 ), /*   809 rl                */
-  S_ST( 'm',	3,      811,     0 ), /*   810 rli               */
-  S_ST( 'i',	3,      413,     0 ), /*   811 rlim              */
-  S_ST( 's',	3,      892,   777 ), /*   812                   */
-  S_ST( 'a',	3,      814,     0 ), /*   813 s                 */
-  S_ST( 'v',	3,      815,     0 ), /*   814 sa                */
-  S_ST( 'e',	3,      816,     0 ), /*   815 sav               */
-  S_ST( 'c',	3,      817,     0 ), /*   816 save              */
-  S_ST( 'o',	3,      818,     0 ), /*   817 savec             */
-  S_ST( 'n',	3,      819,     0 ), /*   818 saveco            */
-  S_ST( 'f',	3,      820,     0 ), /*   819 savecon           */
-  S_ST( 'i',	3,      821,     0 ), /*   820 saveconf          */
-  S_ST( 'g',	3,      822,     0 ), /*   821 saveconfi         */
-  S_ST( 'd',	3,      823,     0 ), /*   822 saveconfig        */
-  S_ST( 'i',	3,      414,     0 ), /*   823 saveconfigd       */
-  S_ST( 'e',	3,      841,   813 ), /*   824 s                 */
-  S_ST( 'r',	3,      826,     0 ), /*   825 se                */
-  S_ST( 'v',	3,      827,     0 ), /*   826 ser               */
-  S_ST( 'e',	3,      415,     0 ), /*   827 serv              */
-  S_ST( '_',	3,      829,     0 ), /*   828 server            */
-  S_ST( 'o',	3,      830,     0 ), /*   829 server_           */
-  S_ST( 'f',	3,      831,     0 ), /*   830 server_o          */
-  S_ST( 'f',	3,      832,     0 ), /*   831 server_of         */
-  S_ST( 's',	3,      833,     0 ), /*   832 server_off        */
-  S_ST( 'e',	3,      463,     0 ), /*   833 server_offs       */
-  S_ST( 'r',	3,      835,   828 ), /*   834 server            */
-  S_ST( 'e',	3,      836,     0 ), /*   835 serverr           */
-  S_ST( 's',	3,      837,     0 ), /*   836 serverre          */
-  S_ST( 'p',	3,      838,     0 ), /*   837 serverres         */
-  S_ST( 'o',	3,      839,     0 ), /*   838 serverresp        */
-  S_ST( 'n',	3,      840,     0 ), /*   839 serverrespo       */
-  S_ST( 's',	3,      416,     0 ), /*   840 serverrespon      */
-  S_ST( 't',	3,      842,   825 ), /*   841 se                */
-  S_ST( 'v',	3,      843,     0 ), /*   842 set               */
-  S_ST( 'a',	3,      418,     0 ), /*   843 setv              */
-  S_ST( 'i',	3,      845,   824 ), /*   844 s                 */
-  S_ST( 'm',	3,      846,     0 ), /*   845 si                */
-  S_ST( 'u',	3,      847,     0 ), /*   846 sim               */
-  S_ST( 'l',	3,      848,     0 ), /*   847 simu              */
-  S_ST( 'a',	3,      849,     0 ), /*   848 simul             */
-  S_ST( 't',	3,      850,     0 ), /*   849 simula            */
-  S_ST( 'i',	3,      851,   460 ), /*   850 simulat           */
-  S_ST( 'o',	3,      852,     0 ), /*   851 simulati          */
-  S_ST( 'n',	3,      853,     0 ), /*   852 simulatio         */
-  S_ST( '_',	3,      854,     0 ), /*   853 simulation        */
-  S_ST( 'd',	3,      855,     0 ), /*   854 simulation_       */
-  S_ST( 'u',	3,      856,     0 ), /*   855 simulation_d      */
-  S_ST( 'r',	3,      857,     0 ), /*   856 simulation_du     */
-  S_ST( 'a',	3,      858,     0 ), /*   857 simulation_dur    */
-  S_ST( 't',	3,      859,     0 ), /*   858 simulation_dura   */
-  S_ST( 'i',	3,      860,     0 ), /*   859 simulation_durat  */
-  S_ST( 'o',	3,      462,     0 ), /*   860 simulation_durati */
-  S_ST( 'o',	3,      862,   844 ), /*   861 s                 */
-  S_ST( 'u',	3,      863,     0 ), /*   862 so                */
-  S_ST( 'r',	3,      864,     0 ), /*   863 sou               */
-  S_ST( 'c',	3,      419,     0 ), /*   864 sour              */
-  S_ST( 't',	3,      888,   861 ), /*   865 s                 */
-  S_ST( 'a',	3,      872,     0 ), /*   866 st                */
-  S_ST( 'c',	3,      868,     0 ), /*   867 sta               */
-  S_ST( 'k',	3,      869,     0 ), /*   868 stac              */
-  S_ST( 's',	3,      870,     0 ), /*   869 stack             */
-  S_ST( 'i',	3,      871,     0 ), /*   870 stacks            */
-  S_ST( 'z',	3,      420,     0 ), /*   871 stacksi           */
-  S_ST( 't',	3,      422,   867 ), /*   872 sta               */
-  S_ST( 'i',	3,      874,     0 ), /*   873 stat              */
-  S_ST( 's',	3,      875,     0 ), /*   874 stati             */
-  S_ST( 't',	3,      876,     0 ), /*   875 statis            */
-  S_ST( 'i',	3,      877,     0 ), /*   876 statist           */
-  S_ST( 'c',	3,      421,     0 ), /*   877 statisti          */
-  S_ST( 'd',	3,      879,     0 ), /*   878 stats             */
-  S_ST( 'i',	3,      423,     0 ), /*   879 statsd            */
-  S_ST( 'e',	3,      424,   866 ), /*   880 st                */
-  S_ST( 'b',	3,      882,     0 ), /*   881 step              */
-  S_ST( 'a',	3,      883,     0 ), /*   882 stepb             */
-  S_ST( 'c',	3,      425,     0 ), /*   883 stepba            */
-  S_ST( 'f',	3,      885,   881 ), /*   884 step              */
-  S_ST( 'w',	3,      426,     0 ), /*   885 stepf             */
-  S_ST( 'o',	3,      887,   884 ), /*   886 step              */
-  S_ST( 'u',	3,      427,     0 ), /*   887 stepo             */
-  S_ST( 'r',	3,      889,   880 ), /*   888 st                */
-  S_ST( 'a',	3,      890,     0 ), /*   889 str               */
-  S_ST( 't',	3,      891,     0 ), /*   890 stra              */
-  S_ST( 'u',	3,      428,     0 ), /*   891 strat             */
-  S_ST( 'y',	3,      430,   865 ), /*   892 s                 */
-  S_ST( 's',	3,      894,     0 ), /*   893 sys               */
-  S_ST( 't',	3,      895,     0 ), /*   894 syss              */
-  S_ST( 'a',	3,      896,     0 ), /*   895 sysst             */
-  S_ST( 't',	3,      431,     0 ), /*   896 syssta            */
-  S_ST( 't',	3,      926,   812 ), /*   897                   */
-  S_ST( 'i',	3,      912,     0 ), /*   898 t                 */
-  S_ST( 'c',	3,      432,     0 ), /*   899 ti                */
-  S_ST( 'm',	3,      905,   899 ), /*   900 ti                */
-  S_ST( 'e',	3,      436,     0 ), /*   901 tim               */
-  S_ST( 'd',	3,      903,   434 ), /*   902 time              */
-  S_ST( 'a',	3,      904,     0 ), /*   903 timed             */
-  S_ST( 't',	3,      435,     0 ), /*   904 timeda            */
-  S_ST( 'i',	3,      906,   901 ), /*   905 tim               */
-  S_ST( 'n',	3,      907,     0 ), /*   906 timi              */
-  S_ST( 'g',	3,      908,     0 ), /*   907 timin             */
-  S_ST( 's',	3,      909,     0 ), /*   908 timing            */
-  S_ST( 't',	3,      910,     0 ), /*   909 timings           */
-  S_ST( 'a',	3,      911,     0 ), /*   910 timingst          */
-  S_ST( 't',	3,      437,     0 ), /*   911 timingsta         */
-  S_ST( 'n',	3,      913,   900 ), /*   912 ti                */
-  S_ST( 'k',	3,      914,     0 ), /*   913 tin               */
-  S_ST( 'e',	3,      438,     0 ), /*   914 tink              */
-  S_ST( 'o',	3,      439,   898 ), /*   915 t                 */
-  S_ST( 'r',	3,      918,   915 ), /*   916 t                 */
-  S_ST( 'a',	3,      440,     0 ), /*   917 tr                */
-  S_ST( 'u',	3,      919,   917 ), /*   918 tr                */
-  S_ST( 's',	3,      920,   441 ), /*   919 tru               */
-  S_ST( 't',	3,      921,     0 ), /*   920 trus              */
-  S_ST( 'e',	3,      922,     0 ), /*   921 trust             */
-  S_ST( 'd',	3,      923,     0 ), /*   922 truste            */
-  S_ST( 'k',	3,      924,     0 ), /*   923 trusted           */
-  S_ST( 'e',	3,      442,     0 ), /*   924 trustedk          */
-  S_ST( 't',	3,      443,   916 ), /*   925 t                 */
-  S_ST( 'y',	3,      927,   925 ), /*   926 t                 */
-  S_ST( 'p',	3,      444,     0 ), /*   927 ty                */
-  S_ST( 'u',	3,      929,   897 ), /*   928                   */
-  S_ST( 'n',	3,      935,     0 ), /*   929 u                 */
-  S_ST( 'c',	3,      931,     0 ), /*   930 un                */
-  S_ST( 'o',	3,      932,     0 ), /*   931 unc               */
-  S_ST( 'n',	3,      933,     0 ), /*   932 unco              */
-  S_ST( 'f',	3,      934,     0 ), /*   933 uncon             */
-  S_ST( 'i',	3,      449,     0 ), /*   934 unconf            */
-  S_ST( 'p',	3,      936,   930 ), /*   935 un                */
-  S_ST( 'e',	3,      937,     0 ), /*   936 unp               */
-  S_ST( 'e',	3,      450,     0 ), /*   937 unpe              */
-  S_ST( '_',	3,      958,     0 ), /*   938 unpeer            */
-  S_ST( 'c',	3,      940,     0 ), /*   939 unpeer_           */
-  S_ST( 'r',	3,      941,     0 ), /*   940 unpeer_c          */
-  S_ST( 'y',	3,      942,     0 ), /*   941 unpeer_cr         */
-  S_ST( 'p',	3,      943,     0 ), /*   942 unpeer_cry        */
-  S_ST( 't',	3,      944,     0 ), /*   943 unpeer_cryp       */
-  S_ST( 'o',	3,      945,     0 ), /*   944 unpeer_crypt      */
-  S_ST( '_',	3,      950,     0 ), /*   945 unpeer_crypto     */
-  S_ST( 'e',	3,      947,     0 ), /*   946 unpeer_crypto_    */
-  S_ST( 'a',	3,      948,     0 ), /*   947 unpeer_crypto_e   */
-  S_ST( 'r',	3,      949,     0 ), /*   948 unpeer_crypto_ea  */
-  S_ST( 'l',	3,      446,     0 ), /*   949 unpeer_crypto_ear */
-  S_ST( 'n',	3,      951,   946 ), /*   950 unpeer_crypto_    */
-  S_ST( 'a',	3,      952,     0 ), /*   951 unpeer_crypto_n   */
-  S_ST( 'k',	3,      953,     0 ), /*   952 unpeer_crypto_na  */
-  S_ST( '_',	3,      954,     0 ), /*   953 unpeer_crypto_nak */
-  S_ST( 'e',	3,      955,     0 ), /*   954 unpeer_crypto_nak_ */
-  S_ST( 'a',	3,      956,     0 ), /*   955 unpeer_crypto_nak_e */
-  S_ST( 'r',	3,      957,     0 ), /*   956 unpeer_crypto_nak_ea */
-  S_ST( 'l',	3,      447,     0 ), /*   957 unpeer_crypto_nak_ear */
-  S_ST( 'd',	3,      959,   939 ), /*   958 unpeer_           */
-  S_ST( 'i',	3,      960,     0 ), /*   959 unpeer_d          */
-  S_ST( 'g',	3,      961,     0 ), /*   960 unpeer_di         */
-  S_ST( 'e',	3,      962,     0 ), /*   961 unpeer_dig        */
-  S_ST( 's',	3,      963,     0 ), /*   962 unpeer_dige       */
-  S_ST( 't',	3,      964,     0 ), /*   963 unpeer_diges      */
-  S_ST( '_',	3,      965,     0 ), /*   964 unpeer_digest     */
-  S_ST( 'e',	3,      966,     0 ), /*   965 unpeer_digest_    */
-  S_ST( 'a',	3,      967,     0 ), /*   966 unpeer_digest_e   */
-  S_ST( 'r',	3,      968,     0 ), /*   967 unpeer_digest_ea  */
-  S_ST( 'l',	3,      448,     0 ), /*   968 unpeer_digest_ear */
-  S_ST( 'v',	3,      970,   928 ), /*   969                   */
-  S_ST( 'e',	3,      971,     0 ), /*   970 v                 */
-  S_ST( 'r',	3,      972,     0 ), /*   971 ve                */
-  S_ST( 's',	3,      973,     0 ), /*   972 ver               */
-  S_ST( 'i',	3,      974,     0 ), /*   973 vers              */
-  S_ST( 'o',	3,      451,     0 ), /*   974 versi             */
-  S_ST( 'w',	3,      982,   969 ), /*   975                   */
-  S_ST( 'a',	3,      977,     0 ), /*   976 w                 */
-  S_ST( 'n',	3,      978,     0 ), /*   977 wa                */
-  S_ST( 'd',	3,      979,     0 ), /*   978 wan               */
-  S_ST( 'e',	3,      466,     0 ), /*   979 wand              */
-  S_ST( 'e',	3,      981,   976 ), /*   980 w                 */
-  S_ST( 'e',	3,      453,     0 ), /*   981 we                */
-  S_ST( 'i',	3,      983,   980 ), /*   982 w                 */
-  S_ST( 'l',	3,      984,     0 ), /*   983 wi                */
-  S_ST( 'd',	3,      985,     0 ), /*   984 wil               */
-  S_ST( 'c',	3,      986,     0 ), /*   985 wild              */
-  S_ST( 'a',	3,      987,     0 ), /*   986 wildc             */
-  S_ST( 'r',	3,      454,     0 ), /*   987 wildca            */
-  S_ST( 'x',	3,      993,   975 ), /*   988                   */
-  S_ST( 'l',	3,      990,     0 ), /*   989 x                 */
-  S_ST( 'e',	3,      991,     0 ), /*   990 xl                */
-  S_ST( 'a',	3,      992,     0 ), /*   991 xle               */
-  S_ST( 'v',	3,      455,     0 ), /*   992 xlea              */
-  S_ST( 'm',	3,      994,   989 ), /*   993 x                 */
-  S_ST( 't',	3,      995,     0 ), /*   994 xm                */
-  S_ST( 'n',	3,      996,     0 ), /*   995 xmt               */
-  S_ST( 'o',	3,      997,     0 ), /*   996 xmtn              */
-  S_ST( 'n',	3,      998,     0 ), /*   997 xmtno             */
-  S_ST( 'c',	3,      456,     0 ), /*   998 xmtnon            */
-  S_ST( 'y',	3,     1000,   988 ), /*   999 [initial state]   */
-  S_ST( 'e',	3,     1001,     0 ), /*  1000 y                 */
-  S_ST( 'a',	3,      457,     0 )  /*  1001 ye                */
+  S_ST( 't',	0,        0,     0 ), /*   286 T_Delrestrict     */
+  S_ST( 'e',	1,        0,     0 ), /*   287 T_Device          */
+  S_ST( 't',	1,        0,     0 ), /*   288 T_Digest          */
+  S_ST( 'e',	0,        0,     0 ), /*   289 T_Disable         */
+  S_ST( 'd',	0,        0,     0 ), /*   290 T_Discard         */
+  S_ST( 'n',	0,        0,     0 ), /*   291 T_Dispersion      */
+  S_ST( 'e',	3,      300,     0 ), /*   292 int               */
+  S_ST( 'e',	1,        0,     0 ), /*   293 T_Driftfile       */
+  S_ST( 'p',	0,        0,     0 ), /*   294 T_Drop            */
+  S_ST( 'p',	0,        0,     0 ), /*   295 T_Dscp            */
+  S_ST( '.',	0,        0,     0 ), /*   296 T_Ellipsis        */
+  S_ST( 'e',	0,        0,     0 ), /*   297 T_Enable          */
+  S_ST( 'd',	0,        0,   179 ), /*   298 T_End             */
+  S_ST( 'r',	0,        0,     0 ), /*   299 T_Epeer           */
+  S_ST( 'r',	3,      324,     0 ), /*   300 inte              */
+  S_ST( 'e',	1,      190,     0 ), /*   301 T_File            */
+  S_ST( 'n',	0,        0,     0 ), /*   302 T_Filegen         */
+  S_ST( 'm',	0,        0,     0 ), /*   303 T_Filenum         */
+  S_ST( '1',	0,        0,     0 ), /*   304 T_Flag1           */
+  S_ST( '2',	0,        0,   304 ), /*   305 T_Flag2           */
+  S_ST( '3',	0,        0,   305 ), /*   306 T_Flag3           */
+  S_ST( '4',	0,        0,   306 ), /*   307 T_Flag4           */
+  S_ST( 'e',	0,        0,     0 ), /*   308 T_Flake           */
+  S_ST( 'r',	0,        0,     0 ), /*   309 T_Floor           */
+  S_ST( 'q',	0,      200,     0 ), /*   310 T_Freq            */
+  S_ST( 'e',	1,        0,     0 ), /*   311 T_Fudge           */
+  S_ST( 'z',	0,        0,     0 ), /*   312 T_Fuzz            */
+  S_ST( 't',	1,        0,     0 ), /*   313 T_Host            */
+  S_ST( 'f',	0,        0,     0 ), /*   314 T_Huffpuff        */
+  S_ST( 't',	0,        0,     0 ), /*   315 T_Iburst          */
+  S_ST( 't',	1,        0,     0 ), /*   316 T_Ident           */
+  S_ST( 'e',	0,      231,     0 ), /*   317 T_Ignore          */
+  S_ST( 'h',	0,        0,     0 ), /*   318 T_Ignorehash      */
+  S_ST( 'c',	0,        0,     0 ), /*   319 T_Incalloc        */
+  S_ST( 'm',	0,        0,     0 ), /*   320 T_Incmem          */
+  S_ST( 'c',	0,        0,     0 ), /*   321 T_Initalloc       */
+  S_ST( 'm',	0,        0,     0 ), /*   322 T_Initmem         */
+  S_ST( 'e',	1,        0,     0 ), /*   323 T_Includefile     */
+  S_ST( 'f',	3,      326,     0 ), /*   324 inter             */
+  S_ST( 'e',	0,        0,     0 ), /*   325 T_Interface       */
+  S_ST( 'a',	3,      418,     0 ), /*   326 interf            */
+  S_ST( 'o',	0,        0,   234 ), /*   327 T_Io              */
+  S_ST( 't',	0,        0,     0 ), /*   328 T_Ippeerlimit     */
+  S_ST( '4',	0,        0,     0 ), /*   329 T_Ipv4            */
+  S_ST( '4',	0,        0,     0 ), /*   330 T_Ipv4_flag       */
+  S_ST( '6',	0,        0,   329 ), /*   331 T_Ipv6            */
+  S_ST( '6',	0,        0,   330 ), /*   332 T_Ipv6_flag       */
+  S_ST( 'l',	0,        0,     0 ), /*   333 T_Kernel          */
+  S_ST( 'y',	0,      335,   483 ), /*   334 T_Key             */
+  S_ST( 's',	1,      486,     0 ), /*   335 T_Keys            */
+  S_ST( 'r',	1,        0,     0 ), /*   336 T_Keysdir         */
+  S_ST( 'd',	0,        0,     0 ), /*   337 T_Kod             */
+  S_ST( 'e',	1,        0,     0 ), /*   338 T_Leapfile        */
+  S_ST( 'l',	0,        0,     0 ), /*   339 T_Leapsmearinterval */
+  S_ST( 'd',	0,        0,     0 ), /*   340 T_Limited         */
+  S_ST( 'k',	0,        0,     0 ), /*   341 T_Link            */
+  S_ST( 'n',	0,        0,     0 ), /*   342 T_Listen          */
+  S_ST( 'g',	2,        0,     0 ), /*   343 T_Logconfig       */
+  S_ST( 'e',	1,        0,     0 ), /*   344 T_Logfile         */
+  S_ST( 's',	0,        0,     0 ), /*   345 T_Loopstats       */
+  S_ST( 'p',	0,        0,     0 ), /*   346 T_Lowpriotrap     */
+  S_ST( 't',	1,        0,     0 ), /*   347 T_Manycastclient  */
+  S_ST( 'r',	2,        0,     0 ), /*   348 T_Manycastserver  */
+  S_ST( 'k',	0,        0,     0 ), /*   349 T_Mask            */
+  S_ST( 'e',	0,        0,     0 ), /*   350 T_Maxage          */
+  S_ST( 'k',	0,        0,     0 ), /*   351 T_Maxclock        */
+  S_ST( 'h',	0,        0,     0 ), /*   352 T_Maxdepth        */
+  S_ST( 't',	0,        0,     0 ), /*   353 T_Maxdist         */
+  S_ST( 'm',	0,        0,     0 ), /*   354 T_Maxmem          */
+  S_ST( 'l',	0,        0,     0 ), /*   355 T_Maxpoll         */
+  S_ST( 's',	0,        0,     0 ), /*   356 T_Mdnstries       */
+  S_ST( 'm',	0,      586,     0 ), /*   357 T_Mem             */
+  S_ST( 'k',	0,        0,     0 ), /*   358 T_Memlock         */
+  S_ST( 'k',	0,        0,     0 ), /*   359 T_Minclock        */
+  S_ST( 'h',	0,        0,     0 ), /*   360 T_Mindepth        */
+  S_ST( 't',	0,        0,     0 ), /*   361 T_Mindist         */
+  S_ST( 'm',	0,        0,     0 ), /*   362 T_Minimum         */
+  S_ST( 'r',	0,        0,     0 ), /*   363 T_Minjitter       */
+  S_ST( 'l',	0,        0,     0 ), /*   364 T_Minpoll         */
+  S_ST( 'e',	0,        0,     0 ), /*   365 T_Minsane         */
+  S_ST( 'e',	0,      367,     0 ), /*   366 T_Mode            */
+  S_ST( '7',	0,        0,     0 ), /*   367 T_Mode7           */
+  S_ST( 'r',	0,        0,     0 ), /*   368 T_Monitor         */
+  S_ST( 'h',	0,        0,     0 ), /*   369 T_Month           */
+  S_ST( 'u',	0,        0,     0 ), /*   370 T_Mru             */
+  S_ST( 'p',	0,        0,     0 ), /*   371 T_Mssntp          */
+  S_ST( 't',	2,        0,     0 ), /*   372 T_Multicastclient */
+  S_ST( 'c',	0,        0,     0 ), /*   373 T_Nic             */
+  S_ST( 'k',	0,        0,     0 ), /*   374 T_Nolink          */
+  S_ST( 'y',	0,        0,     0 ), /*   375 T_Nomodify        */
+  S_ST( 't',	0,        0,     0 ), /*   376 T_Nomrulist       */
+  S_ST( 'e',	0,        0,     0 ), /*   377 T_None            */
+  S_ST( 'e',	0,        0,     0 ), /*   378 T_Nonvolatile     */
+  S_ST( 'r',	0,        0,     0 ), /*   379 T_Noepeer         */
+  S_ST( 'r',	0,        0,     0 ), /*   380 T_Nopeer          */
+  S_ST( 'y',	0,        0,     0 ), /*   381 T_Noquery         */
+  S_ST( 't',	0,        0,     0 ), /*   382 T_Noselect        */
+  S_ST( 'e',	0,        0,     0 ), /*   383 T_Noserve         */
+  S_ST( 'p',	0,        0,     0 ), /*   384 T_Notrap          */
+  S_ST( 't',	0,        0,     0 ), /*   385 T_Notrust         */
+  S_ST( 'p',	0,      691,     0 ), /*   386 T_Ntp             */
+  S_ST( 't',	0,        0,     0 ), /*   387 T_Ntpport         */
+  S_ST( 't',	1,        0,     0 ), /*   388 T_NtpSignDsocket  */
+  S_ST( 'n',	0,      706,     0 ), /*   389 T_Orphan          */
+  S_ST( 't',	0,        0,     0 ), /*   390 T_Orphanwait      */
+  S_ST( 'y',	0,        0,     0 ), /*   391 T_PCEdigest       */
+  S_ST( 'c',	0,        0,     0 ), /*   392 T_Panic           */
+  S_ST( 'r',	1,      733,     0 ), /*   393 T_Peer            */
+  S_ST( 's',	0,        0,     0 ), /*   394 T_Peerstats       */
+  S_ST( 'e',	2,        0,     0 ), /*   395 T_Phone           */
+  S_ST( 'd',	0,      741,     0 ), /*   396 T_Pid             */
+  S_ST( 'e',	1,        0,     0 ), /*   397 T_Pidfile         */
+  S_ST( 'l',	0,      746,     0 ), /*   398 T_Poll            */
+  S_ST( 't',	0,        0,     0 ), /*   399 T_PollSkewList    */
+  S_ST( 'l',	1,        0,     0 ), /*   400 T_Pool            */
+  S_ST( 't',	0,        0,     0 ), /*   401 T_Port            */
+  S_ST( 'a',	1,        0,     0 ), /*   402 T_PpsData         */
+  S_ST( 't',	0,        0,     0 ), /*   403 T_Preempt         */
+  S_ST( 'r',	0,        0,     0 ), /*   404 T_Prefer          */
+  S_ST( 's',	0,        0,     0 ), /*   405 T_Protostats      */
+  S_ST( 'w',	1,        0,   760 ), /*   406 T_Pw              */
+  S_ST( 'e',	1,        0,     0 ), /*   407 T_Randfile        */
+  S_ST( 's',	0,        0,     0 ), /*   408 T_Rawstats        */
+  S_ST( 'd',	1,        0,     0 ), /*   409 T_Refid           */
+  S_ST( 'y',	0,        0,     0 ), /*   410 T_Requestkey      */
+  S_ST( 't',	0,        0,     0 ), /*   411 T_Reset           */
+  S_ST( 't',	0,        0,     0 ), /*   412 T_Restrict        */
+  S_ST( 'e',	0,        0,     0 ), /*   413 T_Revoke          */
+  S_ST( 't',	0,        0,     0 ), /*   414 T_Rlimit          */
+  S_ST( 'r',	1,        0,     0 ), /*   415 T_Saveconfigdir   */
+  S_ST( 'r',	1,      843,     0 ), /*   416 T_Server          */
+  S_ST( 'e',	0,        0,     0 ), /*   417 T_Serverresponse  */
+  S_ST( 'c',	3,      325,     0 ), /*   418 interfa           */
+  S_ST( 'r',	1,        0,     0 ), /*   419 T_Setvar          */
+  S_ST( 'e',	0,        0,     0 ), /*   420 T_Source          */
+  S_ST( 'e',	0,        0,     0 ), /*   421 T_Stacksize       */
+  S_ST( 's',	0,        0,     0 ), /*   422 T_Statistics      */
+  S_ST( 's',	0,      887,   882 ), /*   423 T_Stats           */
+  S_ST( 'r',	1,        0,     0 ), /*   424 T_Statsdir        */
+  S_ST( 'p',	0,      895,     0 ), /*   425 T_Step            */
+  S_ST( 'k',	0,        0,     0 ), /*   426 T_Stepback        */
+  S_ST( 'd',	0,        0,     0 ), /*   427 T_Stepfwd         */
+  S_ST( 't',	0,        0,     0 ), /*   428 T_Stepout         */
+  S_ST( 'm',	0,        0,     0 ), /*   429 T_Stratum         */
+  S_ST( 'p',	3,      475,   327 ), /*   430 i                 */
+  S_ST( 's',	0,      902,     0 ), /*   431 T_Sys             */
+  S_ST( 's',	0,        0,     0 ), /*   432 T_Sysstats        */
+  S_ST( 'k',	0,        0,     0 ), /*   433 T_Tick            */
+  S_ST( '1',	0,        0,     0 ), /*   434 T_Time1           */
+  S_ST( '2',	0,        0,   434 ), /*   435 T_Time2           */
+  S_ST( 'a',	1,        0,     0 ), /*   436 T_TimeData        */
+  S_ST( 'r',	0,        0,   911 ), /*   437 T_Timer           */
+  S_ST( 's',	0,        0,     0 ), /*   438 T_Timingstats     */
+  S_ST( 'r',	0,        0,     0 ), /*   439 T_Tinker          */
+  S_ST( 's',	0,        0,     0 ), /*   440 T_Tos             */
+  S_ST( 'p',	1,        0,     0 ), /*   441 T_Trap            */
+  S_ST( 'e',	0,        0,     0 ), /*   442 T_True            */
+  S_ST( 'y',	0,        0,     0 ), /*   443 T_Trustedkey      */
+  S_ST( 'l',	0,        0,     0 ), /*   444 T_Ttl             */
+  S_ST( 'e',	0,        0,     0 ), /*   445 T_Type            */
+  S_ST( 'p',	3,      453,     0 ), /*   446 ip                */
+  S_ST( 'y',	0,        0,     0 ), /*   447 T_UEcrypto        */
+  S_ST( 'y',	0,        0,     0 ), /*   448 T_UEcryptonak     */
+  S_ST( 'y',	0,        0,     0 ), /*   449 T_UEdigest        */
+  S_ST( 'g',	1,        0,     0 ), /*   450 T_Unconfig        */
+  S_ST( 'r',	1,      947,     0 ), /*   451 T_Unpeer          */
+  S_ST( 'n',	0,        0,     0 ), /*   452 T_Version         */
+  S_ST( 'e',	3,      459,     0 ), /*   453 ipp               */
+  S_ST( 'k',	0,        0,     0 ), /*   454 T_Week            */
+  S_ST( 'd',	0,        0,     0 ), /*   455 T_Wildcard        */
+  S_ST( 'e',	0,        0,     0 ), /*   456 T_Xleave          */
+  S_ST( 'e',	0,        0,     0 ), /*   457 T_Xmtnonce        */
+  S_ST( 'r',	0,        0,     0 ), /*   458 T_Year            */
+  S_ST( 'e',	3,      460,     0 ), /*   459 ippe              */
+  S_ST( 'r',	3,      471,     0 ), /*   460 ippee             */
+  S_ST( 'e',	0,        0,     0 ), /*   461 T_Simulate        */
+  S_ST( 'y',	0,        0,     0 ), /*   462 T_Beep_Delay      */
+  S_ST( 'n',	0,        0,     0 ), /*   463 T_Sim_Duration    */
+  S_ST( 't',	0,        0,     0 ), /*   464 T_Server_Offset   */
+  S_ST( 'n',	0,        0,     0 ), /*   465 T_Duration        */
+  S_ST( 't',	0,        0,     0 ), /*   466 T_Freq_Offset     */
+  S_ST( 'r',	0,        0,     0 ), /*   467 T_Wander          */
+  S_ST( 'r',	0,        0,     0 ), /*   468 T_Jitter          */
+  S_ST( 'y',	0,        0,     0 ), /*   469 T_Prop_Delay      */
+  S_ST( 'y',	0,        0,     0 ), /*   470 T_Proc_Delay      */
+  S_ST( 'l',	3,      472,     0 ), /*   471 ippeer            */
+  S_ST( 'i',	3,      473,     0 ), /*   472 ippeerl           */
+  S_ST( 'm',	3,      474,     0 ), /*   473 ippeerli          */
+  S_ST( 'i',	3,      328,     0 ), /*   474 ippeerlim         */
+  S_ST( 'v',	3,      331,   446 ), /*   475 ip                */
+  S_ST( 'j',	3,      477,   219 ), /*   476                   */
+  S_ST( 'i',	3,      478,     0 ), /*   477 j                 */
+  S_ST( 't',	3,      479,     0 ), /*   478 ji                */
+  S_ST( 't',	3,      480,     0 ), /*   479 jit               */
+  S_ST( 'e',	3,      468,     0 ), /*   480 jitt              */
+  S_ST( 'k',	3,      488,   476 ), /*   481                   */
+  S_ST( 'e',	3,      334,     0 ), /*   482 k                 */
+  S_ST( 'r',	3,      484,     0 ), /*   483 ke                */
+  S_ST( 'n',	3,      485,     0 ), /*   484 ker               */
+  S_ST( 'e',	3,      333,     0 ), /*   485 kern              */
+  S_ST( 'd',	3,      487,     0 ), /*   486 keys              */
+  S_ST( 'i',	3,      336,     0 ), /*   487 keysd             */
+  S_ST( 'o',	3,      337,   482 ), /*   488 k                 */
+  S_ST( 'l',	3,      517,   481 ), /*   489                   */
+  S_ST( 'e',	3,      491,     0 ), /*   490 l                 */
+  S_ST( 'a',	3,      492,     0 ), /*   491 le                */
+  S_ST( 'p',	3,      496,     0 ), /*   492 lea               */
+  S_ST( 'f',	3,      494,     0 ), /*   493 leap              */
+  S_ST( 'i',	3,      495,     0 ), /*   494 leapf             */
+  S_ST( 'l',	3,      338,     0 ), /*   495 leapfi            */
+  S_ST( 's',	3,      497,   493 ), /*   496 leap              */
+  S_ST( 'm',	3,      498,     0 ), /*   497 leaps             */
+  S_ST( 'e',	3,      499,     0 ), /*   498 leapsm            */
+  S_ST( 'a',	3,      500,     0 ), /*   499 leapsme           */
+  S_ST( 'r',	3,      501,     0 ), /*   500 leapsmea          */
+  S_ST( 'i',	3,      502,     0 ), /*   501 leapsmear         */
+  S_ST( 'n',	3,      503,     0 ), /*   502 leapsmeari        */
+  S_ST( 't',	3,      504,     0 ), /*   503 leapsmearin       */
+  S_ST( 'e',	3,      505,     0 ), /*   504 leapsmearint      */
+  S_ST( 'r',	3,      506,     0 ), /*   505 leapsmearinte     */
+  S_ST( 'v',	3,      507,     0 ), /*   506 leapsmearinter    */
+  S_ST( 'a',	3,      339,     0 ), /*   507 leapsmearinterv   */
+  S_ST( 'i',	3,      514,   490 ), /*   508 l                 */
+  S_ST( 'm',	3,      510,     0 ), /*   509 li                */
+  S_ST( 'i',	3,      511,     0 ), /*   510 lim               */
+  S_ST( 't',	3,      512,     0 ), /*   511 limi              */
+  S_ST( 'e',	3,      340,     0 ), /*   512 limit             */
+  S_ST( 'n',	3,      341,   509 ), /*   513 li                */
+  S_ST( 's',	3,      515,   513 ), /*   514 li                */
+  S_ST( 't',	3,      516,     0 ), /*   515 lis               */
+  S_ST( 'e',	3,      342,     0 ), /*   516 list              */
+  S_ST( 'o',	3,      533,   508 ), /*   517 l                 */
+  S_ST( 'g',	3,      524,     0 ), /*   518 lo                */
+  S_ST( 'c',	3,      520,     0 ), /*   519 log               */
+  S_ST( 'o',	3,      521,     0 ), /*   520 logc              */
+  S_ST( 'n',	3,      522,     0 ), /*   521 logco             */
+  S_ST( 'f',	3,      523,     0 ), /*   522 logcon            */
+  S_ST( 'i',	3,      343,     0 ), /*   523 logconf           */
+  S_ST( 'f',	3,      525,   519 ), /*   524 log               */
+  S_ST( 'i',	3,      526,     0 ), /*   525 logf              */
+  S_ST( 'l',	3,      344,     0 ), /*   526 logfi             */
+  S_ST( 'o',	3,      528,   518 ), /*   527 lo                */
+  S_ST( 'p',	3,      529,     0 ), /*   528 loo               */
+  S_ST( 's',	3,      530,     0 ), /*   529 loop              */
+  S_ST( 't',	3,      531,     0 ), /*   530 loops             */
+  S_ST( 'a',	3,      532,     0 ), /*   531 loopst            */
+  S_ST( 't',	3,      345,     0 ), /*   532 loopsta           */
+  S_ST( 'w',	3,      534,   527 ), /*   533 lo                */
+  S_ST( 'p',	3,      535,     0 ), /*   534 low               */
+  S_ST( 'r',	3,      536,     0 ), /*   535 lowp              */
+  S_ST( 'i',	3,      537,     0 ), /*   536 lowpr             */
+  S_ST( 'o',	3,      538,     0 ), /*   537 lowpri            */
+  S_ST( 't',	3,      539,     0 ), /*   538 lowprio           */
+  S_ST( 'r',	3,      540,     0 ), /*   539 lowpriot          */
+  S_ST( 'a',	3,      346,     0 ), /*   540 lowpriotr         */
+  S_ST( 'm',	3,      627,   489 ), /*   541                   */
+  S_ST( 'a',	3,      560,     0 ), /*   542 m                 */
+  S_ST( 'n',	3,      544,     0 ), /*   543 ma                */
+  S_ST( 'y',	3,      545,     0 ), /*   544 man               */
+  S_ST( 'c',	3,      546,     0 ), /*   545 many              */
+  S_ST( 'a',	3,      547,     0 ), /*   546 manyc             */
+  S_ST( 's',	3,      548,     0 ), /*   547 manyca            */
+  S_ST( 't',	3,      554,     0 ), /*   548 manycas           */
+  S_ST( 'c',	3,      550,     0 ), /*   549 manycast          */
+  S_ST( 'l',	3,      551,     0 ), /*   550 manycastc         */
+  S_ST( 'i',	3,      552,     0 ), /*   551 manycastcl        */
+  S_ST( 'e',	3,      553,     0 ), /*   552 manycastcli       */
+  S_ST( 'n',	3,      347,     0 ), /*   553 manycastclie      */
+  S_ST( 's',	3,      555,   549 ), /*   554 manycast          */
+  S_ST( 'e',	3,      556,     0 ), /*   555 manycasts         */
+  S_ST( 'r',	3,      557,     0 ), /*   556 manycastse        */
+  S_ST( 'v',	3,      558,     0 ), /*   557 manycastser       */
+  S_ST( 'e',	3,      348,     0 ), /*   558 manycastserv      */
+  S_ST( 's',	3,      349,   543 ), /*   559 ma                */
+  S_ST( 'x',	3,      575,   559 ), /*   560 ma                */
+  S_ST( 'a',	3,      562,     0 ), /*   561 max               */
+  S_ST( 'g',	3,      350,     0 ), /*   562 maxa              */
+  S_ST( 'c',	3,      564,   561 ), /*   563 max               */
+  S_ST( 'l',	3,      565,     0 ), /*   564 maxc              */
+  S_ST( 'o',	3,      566,     0 ), /*   565 maxcl             */
+  S_ST( 'c',	3,      351,     0 ), /*   566 maxclo            */
+  S_ST( 'd',	3,      571,   563 ), /*   567 max               */
+  S_ST( 'e',	3,      569,     0 ), /*   568 maxd              */
+  S_ST( 'p',	3,      570,     0 ), /*   569 maxde             */
+  S_ST( 't',	3,      352,     0 ), /*   570 maxdep            */
+  S_ST( 'i',	3,      572,   568 ), /*   571 maxd              */
+  S_ST( 's',	3,      353,     0 ), /*   572 maxdi             */
+  S_ST( 'm',	3,      574,   567 ), /*   573 max               */
+  S_ST( 'e',	3,      354,     0 ), /*   574 maxm              */
+  S_ST( 'p',	3,      576,   573 ), /*   575 max               */
+  S_ST( 'o',	3,      577,     0 ), /*   576 maxp              */
+  S_ST( 'l',	3,      355,     0 ), /*   577 maxpo             */
+  S_ST( 'd',	3,      579,   542 ), /*   578 m                 */
+  S_ST( 'n',	3,      580,     0 ), /*   579 md                */
+  S_ST( 's',	3,      581,     0 ), /*   580 mdn               */
+  S_ST( 't',	3,      582,     0 ), /*   581 mdns              */
+  S_ST( 'r',	3,      583,     0 ), /*   582 mdnst             */
+  S_ST( 'i',	3,      584,     0 ), /*   583 mdnstr            */
+  S_ST( 'e',	3,      356,     0 ), /*   584 mdnstri           */
+  S_ST( 'e',	3,      357,   578 ), /*   585 m                 */
+  S_ST( 'l',	3,      587,     0 ), /*   586 mem               */
+  S_ST( 'o',	3,      588,     0 ), /*   587 meml              */
+  S_ST( 'c',	3,      358,     0 ), /*   588 memlo             */
+  S_ST( 'i',	3,      590,   585 ), /*   589 m                 */
+  S_ST( 'n',	3,      612,     0 ), /*   590 mi                */
+  S_ST( 'c',	3,      592,     0 ), /*   591 min               */
+  S_ST( 'l',	3,      593,     0 ), /*   592 minc              */
+  S_ST( 'o',	3,      594,     0 ), /*   593 mincl             */
+  S_ST( 'c',	3,      359,     0 ), /*   594 minclo            */
+  S_ST( 'd',	3,      599,   591 ), /*   595 min               */
+  S_ST( 'e',	3,      597,     0 ), /*   596 mind              */
+  S_ST( 'p',	3,      598,     0 ), /*   597 minde             */
+  S_ST( 't',	3,      360,     0 ), /*   598 mindep            */
+  S_ST( 'i',	3,      600,   596 ), /*   599 mind              */
+  S_ST( 's',	3,      361,     0 ), /*   600 mindi             */
+  S_ST( 'i',	3,      602,   595 ), /*   601 min               */
+  S_ST( 'm',	3,      603,     0 ), /*   602 mini              */
+  S_ST( 'u',	3,      362,     0 ), /*   603 minim             */
+  S_ST( 'j',	3,      605,   601 ), /*   604 min               */
+  S_ST( 'i',	3,      606,     0 ), /*   605 minj              */
+  S_ST( 't',	3,      607,     0 ), /*   606 minji             */
+  S_ST( 't',	3,      608,     0 ), /*   607 minjit            */
+  S_ST( 'e',	3,      363,     0 ), /*   608 minjitt           */
+  S_ST( 'p',	3,      610,   604 ), /*   609 min               */
+  S_ST( 'o',	3,      611,     0 ), /*   610 minp              */
+  S_ST( 'l',	3,      364,     0 ), /*   611 minpo             */
+  S_ST( 's',	3,      613,   609 ), /*   612 min               */
+  S_ST( 'a',	3,      614,     0 ), /*   613 mins              */
+  S_ST( 'n',	3,      365,     0 ), /*   614 minsa             */
+  S_ST( 'o',	3,      617,   589 ), /*   615 m                 */
+  S_ST( 'd',	3,      366,     0 ), /*   616 mo                */
+  S_ST( 'n',	3,      621,   616 ), /*   617 mo                */
+  S_ST( 'i',	3,      619,     0 ), /*   618 mon               */
+  S_ST( 't',	3,      620,     0 ), /*   619 moni              */
+  S_ST( 'o',	3,      368,     0 ), /*   620 monit             */
+  S_ST( 't',	3,      369,   618 ), /*   621 mon               */
+  S_ST( 'r',	3,      370,   615 ), /*   622 m                 */
+  S_ST( 's',	3,      624,   622 ), /*   623 m                 */
+  S_ST( 's',	3,      625,     0 ), /*   624 ms                */
+  S_ST( 'n',	3,      626,     0 ), /*   625 mss               */
+  S_ST( 't',	3,      371,     0 ), /*   626 mssn              */
+  S_ST( 'u',	3,      628,   623 ), /*   627 m                 */
+  S_ST( 'l',	3,      629,     0 ), /*   628 mu                */
+  S_ST( 't',	3,      630,     0 ), /*   629 mul               */
+  S_ST( 'i',	3,      631,     0 ), /*   630 mult              */
+  S_ST( 'c',	3,      632,     0 ), /*   631 multi             */
+  S_ST( 'a',	3,      633,     0 ), /*   632 multic            */
+  S_ST( 's',	3,      634,     0 ), /*   633 multica           */
+  S_ST( 't',	3,      635,     0 ), /*   634 multicas          */
+  S_ST( 'c',	3,      636,     0 ), /*   635 multicast         */
+  S_ST( 'l',	3,      637,     0 ), /*   636 multicastc        */
+  S_ST( 'i',	3,      638,     0 ), /*   637 multicastcl       */
+  S_ST( 'e',	3,      639,     0 ), /*   638 multicastcli      */
+  S_ST( 'n',	3,      372,     0 ), /*   639 multicastclie     */
+  S_ST( 'n',	3,      687,   541 ), /*   640                   */
+  S_ST( 'i',	3,      373,     0 ), /*   641 n                 */
+  S_ST( 'o',	3,      682,   641 ), /*   642 n                 */
+  S_ST( 'e',	3,      644,     0 ), /*   643 no                */
+  S_ST( 'p',	3,      645,     0 ), /*   644 noe               */
+  S_ST( 'e',	3,      646,     0 ), /*   645 noep              */
+  S_ST( 'e',	3,      379,     0 ), /*   646 noepe             */
+  S_ST( 'l',	3,      648,   643 ), /*   647 no                */
+  S_ST( 'i',	3,      649,     0 ), /*   648 nol               */
+  S_ST( 'n',	3,      374,     0 ), /*   649 noli              */
+  S_ST( 'm',	3,      655,   647 ), /*   650 no                */
+  S_ST( 'o',	3,      652,     0 ), /*   651 nom               */
+  S_ST( 'd',	3,      653,     0 ), /*   652 nomo              */
+  S_ST( 'i',	3,      654,     0 ), /*   653 nomod             */
+  S_ST( 'f',	3,      375,     0 ), /*   654 nomodi            */
+  S_ST( 'r',	3,      656,   651 ), /*   655 nom               */
+  S_ST( 'u',	3,      657,     0 ), /*   656 nomr              */
+  S_ST( 'l',	3,      658,     0 ), /*   657 nomru             */
+  S_ST( 'i',	3,      659,     0 ), /*   658 nomrul            */
+  S_ST( 's',	3,      376,     0 ), /*   659 nomruli           */
+  S_ST( 'n',	3,      661,   650 ), /*   660 no                */
+  S_ST( 'v',	3,      662,   377 ), /*   661 non               */
+  S_ST( 'o',	3,      663,     0 ), /*   662 nonv              */
+  S_ST( 'l',	3,      664,     0 ), /*   663 nonvo             */
+  S_ST( 'a',	3,      665,     0 ), /*   664 nonvol            */
+  S_ST( 't',	3,      666,     0 ), /*   665 nonvola           */
+  S_ST( 'i',	3,      667,     0 ), /*   666 nonvolat          */
+  S_ST( 'l',	3,      378,     0 ), /*   667 nonvolati         */
+  S_ST( 'p',	3,      669,   660 ), /*   668 no                */
+  S_ST( 'e',	3,      670,     0 ), /*   669 nop               */
+  S_ST( 'e',	3,      380,     0 ), /*   670 nope              */
+  S_ST( 'q',	3,      672,   668 ), /*   671 no                */
+  S_ST( 'u',	3,      673,     0 ), /*   672 noq               */
+  S_ST( 'e',	3,      674,     0 ), /*   673 noqu              */
+  S_ST( 'r',	3,      381,     0 ), /*   674 noque             */
+  S_ST( 's',	3,      676,   671 ), /*   675 no                */
+  S_ST( 'e',	3,      680,     0 ), /*   676 nos               */
+  S_ST( 'l',	3,      678,     0 ), /*   677 nose              */
+  S_ST( 'e',	3,      679,     0 ), /*   678 nosel             */
+  S_ST( 'c',	3,      382,     0 ), /*   679 nosele            */
+  S_ST( 'r',	3,      681,   677 ), /*   680 nose              */
+  S_ST( 'v',	3,      383,     0 ), /*   681 noser             */
+  S_ST( 't',	3,      683,   675 ), /*   682 no                */
+  S_ST( 'r',	3,      685,     0 ), /*   683 not               */
+  S_ST( 'a',	3,      384,     0 ), /*   684 notr              */
+  S_ST( 'u',	3,      686,   684 ), /*   685 notr              */
+  S_ST( 's',	3,      385,     0 ), /*   686 notru             */
+  S_ST( 't',	3,      386,   642 ), /*   687 n                 */
+  S_ST( 'p',	3,      689,     0 ), /*   688 ntp               */
+  S_ST( 'o',	3,      690,     0 ), /*   689 ntpp              */
+  S_ST( 'r',	3,      387,     0 ), /*   690 ntppo             */
+  S_ST( 's',	3,      692,   688 ), /*   691 ntp               */
+  S_ST( 'i',	3,      693,     0 ), /*   692 ntps              */
+  S_ST( 'g',	3,      694,     0 ), /*   693 ntpsi             */
+  S_ST( 'n',	3,      695,     0 ), /*   694 ntpsig            */
+  S_ST( 'd',	3,      696,     0 ), /*   695 ntpsign           */
+  S_ST( 's',	3,      697,     0 ), /*   696 ntpsignd          */
+  S_ST( 'o',	3,      698,     0 ), /*   697 ntpsignds         */
+  S_ST( 'c',	3,      699,     0 ), /*   698 ntpsigndso        */
+  S_ST( 'k',	3,      700,     0 ), /*   699 ntpsigndsoc       */
+  S_ST( 'e',	3,      388,     0 ), /*   700 ntpsigndsock      */
+  S_ST( 'o',	3,      702,   640 ), /*   701                   */
+  S_ST( 'r',	3,      703,     0 ), /*   702 o                 */
+  S_ST( 'p',	3,      704,     0 ), /*   703 or                */
+  S_ST( 'h',	3,      705,     0 ), /*   704 orp               */
+  S_ST( 'a',	3,      389,     0 ), /*   705 orph              */
+  S_ST( 'w',	3,      707,     0 ), /*   706 orphan            */
+  S_ST( 'a',	3,      708,     0 ), /*   707 orphanw           */
+  S_ST( 'i',	3,      390,     0 ), /*   708 orphanwa          */
+  S_ST( 'p',	3,      406,   701 ), /*   709                   */
+  S_ST( 'a',	3,      711,     0 ), /*   710 p                 */
+  S_ST( 'n',	3,      712,     0 ), /*   711 pa                */
+  S_ST( 'i',	3,      392,     0 ), /*   712 pan               */
+  S_ST( 'e',	3,      714,   710 ), /*   713 p                 */
+  S_ST( 'e',	3,      393,     0 ), /*   714 pe                */
+  S_ST( '_',	3,      716,     0 ), /*   715 peer              */
+  S_ST( 'c',	3,      717,     0 ), /*   716 peer_             */
+  S_ST( 'l',	3,      718,     0 ), /*   717 peer_c            */
+  S_ST( 'e',	3,      719,     0 ), /*   718 peer_cl           */
+  S_ST( 'a',	3,      720,     0 ), /*   719 peer_cle          */
+  S_ST( 'r',	3,      721,     0 ), /*   720 peer_clea         */
+  S_ST( '_',	3,      722,     0 ), /*   721 peer_clear        */
+  S_ST( 'd',	3,      723,     0 ), /*   722 peer_clear_       */
+  S_ST( 'i',	3,      724,     0 ), /*   723 peer_clear_d      */
+  S_ST( 'g',	3,      725,     0 ), /*   724 peer_clear_di     */
+  S_ST( 'e',	3,      726,     0 ), /*   725 peer_clear_dig    */
+  S_ST( 's',	3,      727,     0 ), /*   726 peer_clear_dige   */
+  S_ST( 't',	3,      728,     0 ), /*   727 peer_clear_diges  */
+  S_ST( '_',	3,      729,     0 ), /*   728 peer_clear_digest */
+  S_ST( 'e',	3,      730,     0 ), /*   729 peer_clear_digest_ */
+  S_ST( 'a',	3,      731,     0 ), /*   730 peer_clear_digest_e */
+  S_ST( 'r',	3,      732,     0 ), /*   731 peer_clear_digest_ea */
+  S_ST( 'l',	3,      391,     0 ), /*   732 peer_clear_digest_ear */
+  S_ST( 's',	3,      734,   715 ), /*   733 peer              */
+  S_ST( 't',	3,      735,     0 ), /*   734 peers             */
+  S_ST( 'a',	3,      736,     0 ), /*   735 peerst            */
+  S_ST( 't',	3,      394,     0 ), /*   736 peersta           */
+  S_ST( 'h',	3,      738,   713 ), /*   737 p                 */
+  S_ST( 'o',	3,      739,     0 ), /*   738 ph                */
+  S_ST( 'n',	3,      395,     0 ), /*   739 pho               */
+  S_ST( 'i',	3,      396,   737 ), /*   740 p                 */
+  S_ST( 'f',	3,      742,     0 ), /*   741 pid               */
+  S_ST( 'i',	3,      743,     0 ), /*   742 pidf              */
+  S_ST( 'l',	3,      397,     0 ), /*   743 pidfi             */
+  S_ST( 'o',	3,      754,   740 ), /*   744 p                 */
+  S_ST( 'l',	3,      398,     0 ), /*   745 po                */
+  S_ST( 's',	3,      747,     0 ), /*   746 poll              */
+  S_ST( 'k',	3,      748,     0 ), /*   747 polls             */
+  S_ST( 'e',	3,      749,     0 ), /*   748 pollsk            */
+  S_ST( 'w',	3,      750,     0 ), /*   749 pollske           */
+  S_ST( 'l',	3,      751,     0 ), /*   750 pollskew          */
+  S_ST( 'i',	3,      752,     0 ), /*   751 pollskewl         */
+  S_ST( 's',	3,      399,     0 ), /*   752 pollskewli        */
+  S_ST( 'o',	3,      400,   745 ), /*   753 po                */
+  S_ST( 'r',	3,      401,   753 ), /*   754 po                */
+  S_ST( 'p',	3,      756,   744 ), /*   755 p                 */
+  S_ST( 's',	3,      757,     0 ), /*   756 pp                */
+  S_ST( 'd',	3,      758,     0 ), /*   757 pps               */
+  S_ST( 'a',	3,      759,     0 ), /*   758 ppsd              */
+  S_ST( 't',	3,      402,     0 ), /*   759 ppsda             */
+  S_ST( 'r',	3,      767,   755 ), /*   760 p                 */
+  S_ST( 'e',	3,      765,     0 ), /*   761 pr                */
+  S_ST( 'e',	3,      763,     0 ), /*   762 pre               */
+  S_ST( 'm',	3,      764,     0 ), /*   763 pree              */
+  S_ST( 'p',	3,      403,     0 ), /*   764 preem             */
+  S_ST( 'f',	3,      766,   762 ), /*   765 pre               */
+  S_ST( 'e',	3,      404,     0 ), /*   766 pref              */
+  S_ST( 'o',	3,      780,   761 ), /*   767 pr                */
+  S_ST( 'c',	3,      769,     0 ), /*   768 pro               */
+  S_ST( '_',	3,      770,     0 ), /*   769 proc              */
+  S_ST( 'd',	3,      771,     0 ), /*   770 proc_             */
+  S_ST( 'e',	3,      772,     0 ), /*   771 proc_d            */
+  S_ST( 'l',	3,      773,     0 ), /*   772 proc_de           */
+  S_ST( 'a',	3,      470,     0 ), /*   773 proc_del          */
+  S_ST( 'p',	3,      775,   768 ), /*   774 pro               */
+  S_ST( '_',	3,      776,     0 ), /*   775 prop              */
+  S_ST( 'd',	3,      777,     0 ), /*   776 prop_             */
+  S_ST( 'e',	3,      778,     0 ), /*   777 prop_d            */
+  S_ST( 'l',	3,      779,     0 ), /*   778 prop_de           */
+  S_ST( 'a',	3,      469,     0 ), /*   779 prop_del          */
+  S_ST( 't',	3,      781,   774 ), /*   780 pro               */
+  S_ST( 'o',	3,      782,     0 ), /*   781 prot              */
+  S_ST( 's',	3,      783,     0 ), /*   782 proto             */
+  S_ST( 't',	3,      784,     0 ), /*   783 protos            */
+  S_ST( 'a',	3,      785,     0 ), /*   784 protost           */
+  S_ST( 't',	3,      405,     0 ), /*   785 protosta          */
+  S_ST( 'r',	3,      817,   709 ), /*   786                   */
+  S_ST( 'a',	3,      793,     0 ), /*   787 r                 */
+  S_ST( 'n',	3,      789,     0 ), /*   788 ra                */
+  S_ST( 'd',	3,      790,     0 ), /*   789 ran               */
+  S_ST( 'f',	3,      791,     0 ), /*   790 rand              */
+  S_ST( 'i',	3,      792,     0 ), /*   791 randf             */
+  S_ST( 'l',	3,      407,     0 ), /*   792 randfi            */
+  S_ST( 'w',	3,      794,   788 ), /*   793 ra                */
+  S_ST( 's',	3,      795,     0 ), /*   794 raw               */
+  S_ST( 't',	3,      796,     0 ), /*   795 raws              */
+  S_ST( 'a',	3,      797,     0 ), /*   796 rawst             */
+  S_ST( 't',	3,      408,     0 ), /*   797 rawsta            */
+  S_ST( 'e',	3,      814,   787 ), /*   798 r                 */
+  S_ST( 'f',	3,      800,     0 ), /*   799 re                */
+  S_ST( 'i',	3,      409,     0 ), /*   800 ref               */
+  S_ST( 'q',	3,      802,   799 ), /*   801 re                */
+  S_ST( 'u',	3,      803,     0 ), /*   802 req               */
+  S_ST( 'e',	3,      804,     0 ), /*   803 requ              */
+  S_ST( 's',	3,      805,     0 ), /*   804 reque             */
+  S_ST( 't',	3,      806,     0 ), /*   805 reques            */
+  S_ST( 'k',	3,      807,     0 ), /*   806 request           */
+  S_ST( 'e',	3,      410,     0 ), /*   807 requestk          */
+  S_ST( 's',	3,      810,   801 ), /*   808 re                */
+  S_ST( 'e',	3,      411,     0 ), /*   809 res               */
+  S_ST( 't',	3,      811,   809 ), /*   810 res               */
+  S_ST( 'r',	3,      812,     0 ), /*   811 rest              */
+  S_ST( 'i',	3,      813,     0 ), /*   812 restr             */
+  S_ST( 'c',	3,      412,     0 ), /*   813 restri            */
+  S_ST( 'v',	3,      815,   808 ), /*   814 re                */
+  S_ST( 'o',	3,      816,     0 ), /*   815 rev               */
+  S_ST( 'k',	3,      413,     0 ), /*   816 revo              */
+  S_ST( 'l',	3,      818,   798 ), /*   817 r                 */
+  S_ST( 'i',	3,      819,     0 ), /*   818 rl                */
+  S_ST( 'm',	3,      820,     0 ), /*   819 rli               */
+  S_ST( 'i',	3,      414,     0 ), /*   820 rlim              */
+  S_ST( 's',	3,      901,   786 ), /*   821                   */
+  S_ST( 'a',	3,      823,     0 ), /*   822 s                 */
+  S_ST( 'v',	3,      824,     0 ), /*   823 sa                */
+  S_ST( 'e',	3,      825,     0 ), /*   824 sav               */
+  S_ST( 'c',	3,      826,     0 ), /*   825 save              */
+  S_ST( 'o',	3,      827,     0 ), /*   826 savec             */
+  S_ST( 'n',	3,      828,     0 ), /*   827 saveco            */
+  S_ST( 'f',	3,      829,     0 ), /*   828 savecon           */
+  S_ST( 'i',	3,      830,     0 ), /*   829 saveconf          */
+  S_ST( 'g',	3,      831,     0 ), /*   830 saveconfi         */
+  S_ST( 'd',	3,      832,     0 ), /*   831 saveconfig        */
+  S_ST( 'i',	3,      415,     0 ), /*   832 saveconfigd       */
+  S_ST( 'e',	3,      850,   822 ), /*   833 s                 */
+  S_ST( 'r',	3,      835,     0 ), /*   834 se                */
+  S_ST( 'v',	3,      836,     0 ), /*   835 ser               */
+  S_ST( 'e',	3,      416,     0 ), /*   836 serv              */
+  S_ST( '_',	3,      838,     0 ), /*   837 server            */
+  S_ST( 'o',	3,      839,     0 ), /*   838 server_           */
+  S_ST( 'f',	3,      840,     0 ), /*   839 server_o          */
+  S_ST( 'f',	3,      841,     0 ), /*   840 server_of         */
+  S_ST( 's',	3,      842,     0 ), /*   841 server_off        */
+  S_ST( 'e',	3,      464,     0 ), /*   842 server_offs       */
+  S_ST( 'r',	3,      844,   837 ), /*   843 server            */
+  S_ST( 'e',	3,      845,     0 ), /*   844 serverr           */
+  S_ST( 's',	3,      846,     0 ), /*   845 serverre          */
+  S_ST( 'p',	3,      847,     0 ), /*   846 serverres         */
+  S_ST( 'o',	3,      848,     0 ), /*   847 serverresp        */
+  S_ST( 'n',	3,      849,     0 ), /*   848 serverrespo       */
+  S_ST( 's',	3,      417,     0 ), /*   849 serverrespon      */
+  S_ST( 't',	3,      851,   834 ), /*   850 se                */
+  S_ST( 'v',	3,      852,     0 ), /*   851 set               */
+  S_ST( 'a',	3,      419,     0 ), /*   852 setv              */
+  S_ST( 'i',	3,      854,   833 ), /*   853 s                 */
+  S_ST( 'm',	3,      855,     0 ), /*   854 si                */
+  S_ST( 'u',	3,      856,     0 ), /*   855 sim               */
+  S_ST( 'l',	3,      857,     0 ), /*   856 simu              */
+  S_ST( 'a',	3,      858,     0 ), /*   857 simul             */
+  S_ST( 't',	3,      859,     0 ), /*   858 simula            */
+  S_ST( 'i',	3,      860,   461 ), /*   859 simulat           */
+  S_ST( 'o',	3,      861,     0 ), /*   860 simulati          */
+  S_ST( 'n',	3,      862,     0 ), /*   861 simulatio         */
+  S_ST( '_',	3,      863,     0 ), /*   862 simulation        */
+  S_ST( 'd',	3,      864,     0 ), /*   863 simulation_       */
+  S_ST( 'u',	3,      865,     0 ), /*   864 simulation_d      */
+  S_ST( 'r',	3,      866,     0 ), /*   865 simulation_du     */
+  S_ST( 'a',	3,      867,     0 ), /*   866 simulation_dur    */
+  S_ST( 't',	3,      868,     0 ), /*   867 simulation_dura   */
+  S_ST( 'i',	3,      869,     0 ), /*   868 simulation_durat  */
+  S_ST( 'o',	3,      463,     0 ), /*   869 simulation_durati */
+  S_ST( 'o',	3,      871,   853 ), /*   870 s                 */
+  S_ST( 'u',	3,      872,     0 ), /*   871 so                */
+  S_ST( 'r',	3,      873,     0 ), /*   872 sou               */
+  S_ST( 'c',	3,      420,     0 ), /*   873 sour              */
+  S_ST( 't',	3,      897,   870 ), /*   874 s                 */
+  S_ST( 'a',	3,      881,     0 ), /*   875 st                */
+  S_ST( 'c',	3,      877,     0 ), /*   876 sta               */
+  S_ST( 'k',	3,      878,     0 ), /*   877 stac              */
+  S_ST( 's',	3,      879,     0 ), /*   878 stack             */
+  S_ST( 'i',	3,      880,     0 ), /*   879 stacks            */
+  S_ST( 'z',	3,      421,     0 ), /*   880 stacksi           */
+  S_ST( 't',	3,      423,   876 ), /*   881 sta               */
+  S_ST( 'i',	3,      883,     0 ), /*   882 stat              */
+  S_ST( 's',	3,      884,     0 ), /*   883 stati             */
+  S_ST( 't',	3,      885,     0 ), /*   884 statis            */
+  S_ST( 'i',	3,      886,     0 ), /*   885 statist           */
+  S_ST( 'c',	3,      422,     0 ), /*   886 statisti          */
+  S_ST( 'd',	3,      888,     0 ), /*   887 stats             */
+  S_ST( 'i',	3,      424,     0 ), /*   888 statsd            */
+  S_ST( 'e',	3,      425,   875 ), /*   889 st                */
+  S_ST( 'b',	3,      891,     0 ), /*   890 step              */
+  S_ST( 'a',	3,      892,     0 ), /*   891 stepb             */
+  S_ST( 'c',	3,      426,     0 ), /*   892 stepba            */
+  S_ST( 'f',	3,      894,   890 ), /*   893 step              */
+  S_ST( 'w',	3,      427,     0 ), /*   894 stepf             */
+  S_ST( 'o',	3,      896,   893 ), /*   895 step              */
+  S_ST( 'u',	3,      428,     0 ), /*   896 stepo             */
+  S_ST( 'r',	3,      898,   889 ), /*   897 st                */
+  S_ST( 'a',	3,      899,     0 ), /*   898 str               */
+  S_ST( 't',	3,      900,     0 ), /*   899 stra              */
+  S_ST( 'u',	3,      429,     0 ), /*   900 strat             */
+  S_ST( 'y',	3,      431,   874 ), /*   901 s                 */
+  S_ST( 's',	3,      903,     0 ), /*   902 sys               */
+  S_ST( 't',	3,      904,     0 ), /*   903 syss              */
+  S_ST( 'a',	3,      905,     0 ), /*   904 sysst             */
+  S_ST( 't',	3,      432,     0 ), /*   905 syssta            */
+  S_ST( 't',	3,      935,   821 ), /*   906                   */
+  S_ST( 'i',	3,      921,     0 ), /*   907 t                 */
+  S_ST( 'c',	3,      433,     0 ), /*   908 ti                */
+  S_ST( 'm',	3,      914,   908 ), /*   909 ti                */
+  S_ST( 'e',	3,      437,     0 ), /*   910 tim               */
+  S_ST( 'd',	3,      912,   435 ), /*   911 time              */
+  S_ST( 'a',	3,      913,     0 ), /*   912 timed             */
+  S_ST( 't',	3,      436,     0 ), /*   913 timeda            */
+  S_ST( 'i',	3,      915,   910 ), /*   914 tim               */
+  S_ST( 'n',	3,      916,     0 ), /*   915 timi              */
+  S_ST( 'g',	3,      917,     0 ), /*   916 timin             */
+  S_ST( 's',	3,      918,     0 ), /*   917 timing            */
+  S_ST( 't',	3,      919,     0 ), /*   918 timings           */
+  S_ST( 'a',	3,      920,     0 ), /*   919 timingst          */
+  S_ST( 't',	3,      438,     0 ), /*   920 timingsta         */
+  S_ST( 'n',	3,      922,   909 ), /*   921 ti                */
+  S_ST( 'k',	3,      923,     0 ), /*   922 tin               */
+  S_ST( 'e',	3,      439,     0 ), /*   923 tink              */
+  S_ST( 'o',	3,      440,   907 ), /*   924 t                 */
+  S_ST( 'r',	3,      927,   924 ), /*   925 t                 */
+  S_ST( 'a',	3,      441,     0 ), /*   926 tr                */
+  S_ST( 'u',	3,      928,   926 ), /*   927 tr                */
+  S_ST( 's',	3,      929,   442 ), /*   928 tru               */
+  S_ST( 't',	3,      930,     0 ), /*   929 trus              */
+  S_ST( 'e',	3,      931,     0 ), /*   930 trust             */
+  S_ST( 'd',	3,      932,     0 ), /*   931 truste            */
+  S_ST( 'k',	3,      933,     0 ), /*   932 trusted           */
+  S_ST( 'e',	3,      443,     0 ), /*   933 trustedk          */
+  S_ST( 't',	3,      444,   925 ), /*   934 t                 */
+  S_ST( 'y',	3,      936,   934 ), /*   935 t                 */
+  S_ST( 'p',	3,      445,     0 ), /*   936 ty                */
+  S_ST( 'u',	3,      938,   906 ), /*   937                   */
+  S_ST( 'n',	3,      944,     0 ), /*   938 u                 */
+  S_ST( 'c',	3,      940,     0 ), /*   939 un                */
+  S_ST( 'o',	3,      941,     0 ), /*   940 unc               */
+  S_ST( 'n',	3,      942,     0 ), /*   941 unco              */
+  S_ST( 'f',	3,      943,     0 ), /*   942 uncon             */
+  S_ST( 'i',	3,      450,     0 ), /*   943 unconf            */
+  S_ST( 'p',	3,      945,   939 ), /*   944 un                */
+  S_ST( 'e',	3,      946,     0 ), /*   945 unp               */
+  S_ST( 'e',	3,      451,     0 ), /*   946 unpe              */
+  S_ST( '_',	3,      967,     0 ), /*   947 unpeer            */
+  S_ST( 'c',	3,      949,     0 ), /*   948 unpeer_           */
+  S_ST( 'r',	3,      950,     0 ), /*   949 unpeer_c          */
+  S_ST( 'y',	3,      951,     0 ), /*   950 unpeer_cr         */
+  S_ST( 'p',	3,      952,     0 ), /*   951 unpeer_cry        */
+  S_ST( 't',	3,      953,     0 ), /*   952 unpeer_cryp       */
+  S_ST( 'o',	3,      954,     0 ), /*   953 unpeer_crypt      */
+  S_ST( '_',	3,      959,     0 ), /*   954 unpeer_crypto     */
+  S_ST( 'e',	3,      956,     0 ), /*   955 unpeer_crypto_    */
+  S_ST( 'a',	3,      957,     0 ), /*   956 unpeer_crypto_e   */
+  S_ST( 'r',	3,      958,     0 ), /*   957 unpeer_crypto_ea  */
+  S_ST( 'l',	3,      447,     0 ), /*   958 unpeer_crypto_ear */
+  S_ST( 'n',	3,      960,   955 ), /*   959 unpeer_crypto_    */
+  S_ST( 'a',	3,      961,     0 ), /*   960 unpeer_crypto_n   */
+  S_ST( 'k',	3,      962,     0 ), /*   961 unpeer_crypto_na  */
+  S_ST( '_',	3,      963,     0 ), /*   962 unpeer_crypto_nak */
+  S_ST( 'e',	3,      964,     0 ), /*   963 unpeer_crypto_nak_ */
+  S_ST( 'a',	3,      965,     0 ), /*   964 unpeer_crypto_nak_e */
+  S_ST( 'r',	3,      966,     0 ), /*   965 unpeer_crypto_nak_ea */
+  S_ST( 'l',	3,      448,     0 ), /*   966 unpeer_crypto_nak_ear */
+  S_ST( 'd',	3,      968,   948 ), /*   967 unpeer_           */
+  S_ST( 'i',	3,      969,     0 ), /*   968 unpeer_d          */
+  S_ST( 'g',	3,      970,     0 ), /*   969 unpeer_di         */
+  S_ST( 'e',	3,      971,     0 ), /*   970 unpeer_dig        */
+  S_ST( 's',	3,      972,     0 ), /*   971 unpeer_dige       */
+  S_ST( 't',	3,      973,     0 ), /*   972 unpeer_diges      */
+  S_ST( '_',	3,      974,     0 ), /*   973 unpeer_digest     */
+  S_ST( 'e',	3,      975,     0 ), /*   974 unpeer_digest_    */
+  S_ST( 'a',	3,      976,     0 ), /*   975 unpeer_digest_e   */
+  S_ST( 'r',	3,      977,     0 ), /*   976 unpeer_digest_ea  */
+  S_ST( 'l',	3,      449,     0 ), /*   977 unpeer_digest_ear */
+  S_ST( 'v',	3,      979,   937 ), /*   978                   */
+  S_ST( 'e',	3,      980,     0 ), /*   979 v                 */
+  S_ST( 'r',	3,      981,     0 ), /*   980 ve                */
+  S_ST( 's',	3,      982,     0 ), /*   981 ver               */
+  S_ST( 'i',	3,      983,     0 ), /*   982 vers              */
+  S_ST( 'o',	3,      452,     0 ), /*   983 versi             */
+  S_ST( 'w',	3,      991,   978 ), /*   984                   */
+  S_ST( 'a',	3,      986,     0 ), /*   985 w                 */
+  S_ST( 'n',	3,      987,     0 ), /*   986 wa                */
+  S_ST( 'd',	3,      988,     0 ), /*   987 wan               */
+  S_ST( 'e',	3,      467,     0 ), /*   988 wand              */
+  S_ST( 'e',	3,      990,   985 ), /*   989 w                 */
+  S_ST( 'e',	3,      454,     0 ), /*   990 we                */
+  S_ST( 'i',	3,      992,   989 ), /*   991 w                 */
+  S_ST( 'l',	3,      993,     0 ), /*   992 wi                */
+  S_ST( 'd',	3,      994,     0 ), /*   993 wil               */
+  S_ST( 'c',	3,      995,     0 ), /*   994 wild              */
+  S_ST( 'a',	3,      996,     0 ), /*   995 wildc             */
+  S_ST( 'r',	3,      455,     0 ), /*   996 wildca            */
+  S_ST( 'x',	3,     1002,   984 ), /*   997                   */
+  S_ST( 'l',	3,      999,     0 ), /*   998 x                 */
+  S_ST( 'e',	3,     1000,     0 ), /*   999 xl                */
+  S_ST( 'a',	3,     1001,     0 ), /*  1000 xle               */
+  S_ST( 'v',	3,      456,     0 ), /*  1001 xlea              */
+  S_ST( 'm',	3,     1003,   998 ), /*  1002 x                 */
+  S_ST( 't',	3,     1004,     0 ), /*  1003 xm                */
+  S_ST( 'n',	3,     1005,     0 ), /*  1004 xmt               */
+  S_ST( 'o',	3,     1006,     0 ), /*  1005 xmtn              */
+  S_ST( 'n',	3,     1007,     0 ), /*  1006 xmtno             */
+  S_ST( 'c',	3,      457,     0 ), /*  1007 xmtnon            */
+  S_ST( 'y',	3,     1009,   997 ), /*  1008 [initial state]   */
+  S_ST( 'e',	3,     1010,     0 ), /*  1009 y                 */
+  S_ST( 'a',	3,      458,     0 )  /*  1010 ye                */
 };
 
diff --git a/contrib/ntp/ntpd/ntp_leapsec.c b/contrib/ntp/ntpd/ntp_leapsec.c
index 88f9d4e1cc23..2618862c57ba 100644
--- a/contrib/ntp/ntpd/ntp_leapsec.c
+++ b/contrib/ntp/ntpd/ntp_leapsec.c
@@ -13,38 +13,16 @@
 #include <sys/stat.h>
 #include <ctype.h>
 
-#include "ntp_types.h"
-#include "ntp_fp.h"
+#include "ntp.h"
 #include "ntp_stdlib.h"
 #include "ntp_calendar.h"
 #include "ntp_leapsec.h"
-#include "ntp.h"
 #include "vint64ops.h"
-#include "lib_strbuf.h"
 
 #include "isc/sha1.h"
 
 static const char * const logPrefix = "leapsecond file";
 
-/* ---------------------------------------------------------------------
- * GCC is rather sticky with its 'const' attribute. We have to do it more
- * explicit than with a cast if we want to get rid of a CONST qualifier.
- * Greetings from the PASCAL world, where casting was only possible via
- * untagged unions...
- */
-static inline void*
-noconst(
-	const void* ptr
-	)
-{
-	union {
-		const void * cp;
-		void *       vp;
-	} tmp;
-	tmp.cp = ptr;
-	return tmp.vp;
-}
-
 /* ---------------------------------------------------------------------
  * Our internal data structure
  */
@@ -84,18 +62,20 @@ static leap_table_t _ltab[2], *_lptr;
 static int/*BOOL*/  _electric;
 
 /* Forward decls of local helpers */
-static int    add_range(leap_table_t*, const leap_info_t*);
-static char * get_line(leapsec_reader, void*, char*, size_t);
-static char * skipws(const char*);
-static int    parsefail(const char * cp, const char * ep);
-static void   reload_limits(leap_table_t*, const vint64*);
-static void   fetch_leap_era(leap_era_t*, const leap_table_t*,
-			     const vint64*);
-static int    betweenu32(uint32_t, uint32_t, uint32_t);
-static void   reset_times(leap_table_t*);
-static int    leapsec_add(leap_table_t*, const vint64*, int);
-static int    leapsec_raw(leap_table_t*, const vint64 *, int, int);
-static const char * lstostr(const vint64 * ts);
+static int		add_range	(leap_table_t *, const leap_info_t *);
+static char *		get_line	(leapsec_reader, void *, char *,
+					 size_t);
+static inline char *	skipws		(char *ptr);
+static int		parsefail	(const char *cp, const char *ep);
+static void		reload_limits	(leap_table_t *, const vint64 *);
+static void		fetch_leap_era	(leap_era_t *, const leap_table_t *,
+					 const vint64 *);
+static int		betweenu32	(u_int32, u_int32, u_int32);
+static void		reset_times	(leap_table_t *);
+static int		leapsec_add	(leap_table_t *, const vint64 *, int);
+static int		leapsec_raw	(leap_table_t *, const vint64 *, int,
+					 int);
+static const char *	lstostr		(const vint64 *ts);
 
 /* =====================================================================
  * Get & Set the current leap table
@@ -178,13 +158,13 @@ leapsec_clear(
  */
 int/*BOOL*/
 leapsec_load(
-	leap_table_t * pt  ,
-	leapsec_reader func,
-	void *         farg,
-	int            use_build_limit)
+	leap_table_t *	pt,
+	leapsec_reader	func,
+	void *		farg,
+	int		use_build_limit
+	)
 {
-	char const	*ep;
-	char		*cp, *endp, linebuf[50];
+	char		*cp, *ep, *endp, linebuf[50];
 	vint64		ttime, limit;
 	long		taiof;
 	struct calendar	build;
@@ -415,7 +395,7 @@ leapsec_reset_frame(void)
 }
 
 /* ------------------------------------------------------------------ */
-/* load a file from a FILE pointer. Note: If hcheck is true, load
+/* load a file from a FILE pointer. Note: If vhash is true, load
  * only after successful signature check. The stream must be seekable
  * or this will fail.
  */
@@ -433,7 +413,7 @@ leapsec_load_stream(
 		fname = "<unknown>";
 
 	if (vhash) {
-		rcheck = leapsec_validate((leapsec_reader)getc, ifp);
+		rcheck = leapsec_validate((leapsec_reader)&getc, ifp);
 		if (logall)
 			switch (rcheck)
 			{
@@ -822,13 +802,15 @@ get_line(
 }
 
 /* [internal] skips whitespace characters from a character buffer. */
-static char *
+static inline char *
 skipws(
-	const char *ptr)
+	char *	ptr
+	)
 {
-	while (isspace((u_char)*ptr))
+	while (isspace((u_char)*ptr)) {
 		ptr++;
-	return (char*)noconst(ptr);
+	}
+	return ptr;
 }
 
 /* [internal] check if a strtoXYZ ended at EOL or whitespace and
@@ -887,7 +869,7 @@ reload_limits(
 
 		if (_electric)
 			pt->head.dtime = pt->head.ttime;
-                else
+		else
 			pt->head.dtime = addv64i32(
 				&pt->head.ttime,
 				pt->head.next_tai - pt->head.this_tai);
diff --git a/contrib/ntp/ntpd/ntp_loopfilter.c b/contrib/ntp/ntpd/ntp_loopfilter.c
index e76e4dce0711..6378e0d7e669 100644
--- a/contrib/ntp/ntpd/ntp_loopfilter.c
+++ b/contrib/ntp/ntpd/ntp_loopfilter.c
@@ -1027,6 +1027,22 @@ rstclock(
 		    tc_counter));
 	if (trans != state && trans != EVNT_FSET)
 		report_event(trans, NULL, NULL);
+#ifdef HAVE_WORKING_FORK
+	if (trans != state && EVNT_SYNC == trans) {
+		/*
+		 * If our parent process is waiting for the
+		 * first clock sync, send them home satisfied.
+		 */
+		if (daemon_pipe[1] != -1) {
+			if (2 != write(daemon_pipe[1], "S\n", 2)) {
+				msyslog(LOG_ERR, "daemon failed to notify parent ntpd (--wait-sync)");
+			}
+			close(daemon_pipe[1]);
+			daemon_pipe[1] = -1;
+		}
+	}
+#endif /* HAVE_WORKING_FORK */
+
 	state = trans;
 	last_offset = clock_offset = offset;
 	clock_epoch = current_time;
diff --git a/contrib/ntp/ntpd/ntp_monitor.c b/contrib/ntp/ntpd/ntp_monitor.c
index b3db452a243e..8af8dff301c4 100644
--- a/contrib/ntp/ntpd/ntp_monitor.c
+++ b/contrib/ntp/ntpd/ntp_monitor.c
@@ -329,9 +329,9 @@ ntp_monitor(
 
 	REQUIRE(rbufp != NULL);
 
-	if (mon_enabled == MON_OFF)
+	if (mon_enabled == MON_OFF) {
 		return ~(RES_LIMITED | RES_KOD) & flags;
-
+	}
 	pkt = &rbufp->recv_pkt;
 	hash = MON_HASH(&rbufp->recv_srcadr);
 	mode = PKT_MODE(pkt->li_vn_mode);
@@ -343,10 +343,11 @@ ntp_monitor(
 	 * otherwise cron'ed ntpdate or similar evades RES_LIMITED.
 	 */
 
-	for (; mon != NULL; mon = mon->hash_next)
-		if (SOCK_EQ(&mon->rmtadr, &rbufp->recv_srcadr))
+	for (; mon != NULL; mon = mon->hash_next) {
+		if (SOCK_EQ(&mon->rmtadr, &rbufp->recv_srcadr)) {
 			break;
-
+		}
+	}
 	if (mon != NULL) {
 		interval_fp = rbufp->recv_time;
 		L_SUB(&interval_fp, &mon->last);
@@ -388,17 +389,17 @@ ntp_monitor(
 		 * the average threshold plus the increment and leave
 		 * the RES_LIMITED and RES_KOD bits lit. Otherwise,
 		 * leave the counter alone and douse the RES_KOD bit.
-		 * This rate-limits the KoDs to no less than the average
-		 * headway.
+		 * This rate-limits the KoDs to no more often than the
+		 * average headway.
 		 */
 		if (interval + 1 >= ntp_minpkt && leak < limit) {
 			mon->leak = leak - 2;
 			restrict_mask &= ~(RES_LIMITED | RES_KOD);
-		} else if (mon->leak < limit)
+		} else if (mon->leak < limit) {
 			mon->leak = limit + head;
-		else
+		} else {
 			restrict_mask &= ~RES_KOD;
-
+		}
 		mon->flags = restrict_mask;
 
 		return mon->flags;
diff --git a/contrib/ntp/ntpd/ntp_parser.c b/contrib/ntp/ntpd/ntp_parser.c
index 834b1fbd1acc..e5ee5e10a459 100644
--- a/contrib/ntp/ntpd/ntp_parser.c
+++ b/contrib/ntp/ntpd/ntp_parser.c
@@ -1,4 +1,4 @@
-/* A Bison parser, made by GNU Bison 3.7.6.  */
+/* A Bison parser, made by GNU Bison 3.8.2.  */
 
 /* Bison implementation for Yacc-like parsers in C
 
@@ -46,10 +46,10 @@
    USER NAME SPACE" below.  */
 
 /* Identify Bison output, and Bison version.  */
-#define YYBISON 30706
+#define YYBISON 30802
 
 /* Bison version string.  */
-#define YYBISON_VERSION "3.7.6"
+#define YYBISON_VERSION "3.8.2"
 
 /* Skeleton name.  */
 #define YYSKELETON_NAME "yacc.c"
@@ -67,7 +67,7 @@
 
 
 /* First part of user prologue.  */
-#line 11 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 11 "../../ntpd/ntp_parser.y"
 
   #ifdef HAVE_CONFIG_H
   # include <config.h>
@@ -102,7 +102,7 @@
   #  define ONLY_SIM(a)	NULL
   #endif
 
-#line 106 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 106 "ntp_parser.c"
 
 # ifndef YY_CAST
 #  ifdef __cplusplus
@@ -127,8 +127,8 @@
 
 /* Use api.header.include to #include this header
    instead of duplicating it here.  */
-#ifndef YY_YY__SRC_NTP_STABLE_NTPD_NTP_PARSER_H_INCLUDED
-# define YY_YY__SRC_NTP_STABLE_NTPD_NTP_PARSER_H_INCLUDED
+#ifndef YY_YY_NTP_PARSER_H_INCLUDED
+# define YY_YY_NTP_PARSER_H_INCLUDED
 /* Debug traces.  */
 #ifndef YYDEBUG
 # define YYDEBUG 1
@@ -174,190 +174,191 @@ extern int yydebug;
     T_Ctl = 283,                   /* T_Ctl  */
     T_Day = 284,                   /* T_Day  */
     T_Default = 285,               /* T_Default  */
-    T_Device = 286,                /* T_Device  */
-    T_Digest = 287,                /* T_Digest  */
-    T_Disable = 288,               /* T_Disable  */
-    T_Discard = 289,               /* T_Discard  */
-    T_Dispersion = 290,            /* T_Dispersion  */
-    T_Double = 291,                /* T_Double  */
-    T_Driftfile = 292,             /* T_Driftfile  */
-    T_Drop = 293,                  /* T_Drop  */
-    T_Dscp = 294,                  /* T_Dscp  */
-    T_Ellipsis = 295,              /* T_Ellipsis  */
-    T_Enable = 296,                /* T_Enable  */
-    T_End = 297,                   /* T_End  */
-    T_Epeer = 298,                 /* T_Epeer  */
-    T_False = 299,                 /* T_False  */
-    T_File = 300,                  /* T_File  */
-    T_Filegen = 301,               /* T_Filegen  */
-    T_Filenum = 302,               /* T_Filenum  */
-    T_Flag1 = 303,                 /* T_Flag1  */
-    T_Flag2 = 304,                 /* T_Flag2  */
-    T_Flag3 = 305,                 /* T_Flag3  */
-    T_Flag4 = 306,                 /* T_Flag4  */
-    T_Flake = 307,                 /* T_Flake  */
-    T_Floor = 308,                 /* T_Floor  */
-    T_Freq = 309,                  /* T_Freq  */
-    T_Fudge = 310,                 /* T_Fudge  */
-    T_Fuzz = 311,                  /* T_Fuzz  */
-    T_Host = 312,                  /* T_Host  */
-    T_Huffpuff = 313,              /* T_Huffpuff  */
-    T_Iburst = 314,                /* T_Iburst  */
-    T_Ident = 315,                 /* T_Ident  */
-    T_Ignore = 316,                /* T_Ignore  */
-    T_Ignorehash = 317,            /* T_Ignorehash  */
-    T_Incalloc = 318,              /* T_Incalloc  */
-    T_Incmem = 319,                /* T_Incmem  */
-    T_Initalloc = 320,             /* T_Initalloc  */
-    T_Initmem = 321,               /* T_Initmem  */
-    T_Includefile = 322,           /* T_Includefile  */
-    T_Integer = 323,               /* T_Integer  */
-    T_Interface = 324,             /* T_Interface  */
-    T_Intrange = 325,              /* T_Intrange  */
-    T_Io = 326,                    /* T_Io  */
-    T_Ippeerlimit = 327,           /* T_Ippeerlimit  */
-    T_Ipv4 = 328,                  /* T_Ipv4  */
-    T_Ipv4_flag = 329,             /* T_Ipv4_flag  */
-    T_Ipv6 = 330,                  /* T_Ipv6  */
-    T_Ipv6_flag = 331,             /* T_Ipv6_flag  */
-    T_Kernel = 332,                /* T_Kernel  */
-    T_Key = 333,                   /* T_Key  */
-    T_Keys = 334,                  /* T_Keys  */
-    T_Keysdir = 335,               /* T_Keysdir  */
-    T_Kod = 336,                   /* T_Kod  */
-    T_Leapfile = 337,              /* T_Leapfile  */
-    T_Leapsmearinterval = 338,     /* T_Leapsmearinterval  */
-    T_Limited = 339,               /* T_Limited  */
-    T_Link = 340,                  /* T_Link  */
-    T_Listen = 341,                /* T_Listen  */
-    T_Logconfig = 342,             /* T_Logconfig  */
-    T_Logfile = 343,               /* T_Logfile  */
-    T_Loopstats = 344,             /* T_Loopstats  */
-    T_Lowpriotrap = 345,           /* T_Lowpriotrap  */
-    T_Manycastclient = 346,        /* T_Manycastclient  */
-    T_Manycastserver = 347,        /* T_Manycastserver  */
-    T_Mask = 348,                  /* T_Mask  */
-    T_Maxage = 349,                /* T_Maxage  */
-    T_Maxclock = 350,              /* T_Maxclock  */
-    T_Maxdepth = 351,              /* T_Maxdepth  */
-    T_Maxdist = 352,               /* T_Maxdist  */
-    T_Maxmem = 353,                /* T_Maxmem  */
-    T_Maxpoll = 354,               /* T_Maxpoll  */
-    T_Mdnstries = 355,             /* T_Mdnstries  */
-    T_Mem = 356,                   /* T_Mem  */
-    T_Memlock = 357,               /* T_Memlock  */
-    T_Minclock = 358,              /* T_Minclock  */
-    T_Mindepth = 359,              /* T_Mindepth  */
-    T_Mindist = 360,               /* T_Mindist  */
-    T_Minimum = 361,               /* T_Minimum  */
-    T_Minjitter = 362,             /* T_Minjitter  */
-    T_Minpoll = 363,               /* T_Minpoll  */
-    T_Minsane = 364,               /* T_Minsane  */
-    T_Mode = 365,                  /* T_Mode  */
-    T_Mode7 = 366,                 /* T_Mode7  */
-    T_Monitor = 367,               /* T_Monitor  */
-    T_Month = 368,                 /* T_Month  */
-    T_Mru = 369,                   /* T_Mru  */
-    T_Mssntp = 370,                /* T_Mssntp  */
-    T_Multicastclient = 371,       /* T_Multicastclient  */
-    T_Nic = 372,                   /* T_Nic  */
-    T_Nolink = 373,                /* T_Nolink  */
-    T_Nomodify = 374,              /* T_Nomodify  */
-    T_Nomrulist = 375,             /* T_Nomrulist  */
-    T_None = 376,                  /* T_None  */
-    T_Nonvolatile = 377,           /* T_Nonvolatile  */
-    T_Noepeer = 378,               /* T_Noepeer  */
-    T_Nopeer = 379,                /* T_Nopeer  */
-    T_Noquery = 380,               /* T_Noquery  */
-    T_Noselect = 381,              /* T_Noselect  */
-    T_Noserve = 382,               /* T_Noserve  */
-    T_Notrap = 383,                /* T_Notrap  */
-    T_Notrust = 384,               /* T_Notrust  */
-    T_Ntp = 385,                   /* T_Ntp  */
-    T_Ntpport = 386,               /* T_Ntpport  */
-    T_NtpSignDsocket = 387,        /* T_NtpSignDsocket  */
-    T_Orphan = 388,                /* T_Orphan  */
-    T_Orphanwait = 389,            /* T_Orphanwait  */
-    T_PCEdigest = 390,             /* T_PCEdigest  */
-    T_Panic = 391,                 /* T_Panic  */
-    T_Peer = 392,                  /* T_Peer  */
-    T_Peerstats = 393,             /* T_Peerstats  */
-    T_Phone = 394,                 /* T_Phone  */
-    T_Pid = 395,                   /* T_Pid  */
-    T_Pidfile = 396,               /* T_Pidfile  */
-    T_Poll = 397,                  /* T_Poll  */
-    T_PollSkewList = 398,          /* T_PollSkewList  */
-    T_Pool = 399,                  /* T_Pool  */
-    T_Port = 400,                  /* T_Port  */
-    T_PpsData = 401,               /* T_PpsData  */
-    T_Preempt = 402,               /* T_Preempt  */
-    T_Prefer = 403,                /* T_Prefer  */
-    T_Protostats = 404,            /* T_Protostats  */
-    T_Pw = 405,                    /* T_Pw  */
-    T_Randfile = 406,              /* T_Randfile  */
-    T_Rawstats = 407,              /* T_Rawstats  */
-    T_Refid = 408,                 /* T_Refid  */
-    T_Requestkey = 409,            /* T_Requestkey  */
-    T_Reset = 410,                 /* T_Reset  */
-    T_Restrict = 411,              /* T_Restrict  */
-    T_Revoke = 412,                /* T_Revoke  */
-    T_Rlimit = 413,                /* T_Rlimit  */
-    T_Saveconfigdir = 414,         /* T_Saveconfigdir  */
-    T_Server = 415,                /* T_Server  */
-    T_Serverresponse = 416,        /* T_Serverresponse  */
-    T_ServerresponseFuzz = 417,    /* T_ServerresponseFuzz  */
-    T_Setvar = 418,                /* T_Setvar  */
-    T_Source = 419,                /* T_Source  */
-    T_Stacksize = 420,             /* T_Stacksize  */
-    T_Statistics = 421,            /* T_Statistics  */
-    T_Stats = 422,                 /* T_Stats  */
-    T_Statsdir = 423,              /* T_Statsdir  */
-    T_Step = 424,                  /* T_Step  */
-    T_Stepback = 425,              /* T_Stepback  */
-    T_Stepfwd = 426,               /* T_Stepfwd  */
-    T_Stepout = 427,               /* T_Stepout  */
-    T_Stratum = 428,               /* T_Stratum  */
-    T_String = 429,                /* T_String  */
-    T_Sys = 430,                   /* T_Sys  */
-    T_Sysstats = 431,              /* T_Sysstats  */
-    T_Tick = 432,                  /* T_Tick  */
-    T_Time1 = 433,                 /* T_Time1  */
-    T_Time2 = 434,                 /* T_Time2  */
-    T_TimeData = 435,              /* T_TimeData  */
-    T_Timer = 436,                 /* T_Timer  */
-    T_Timingstats = 437,           /* T_Timingstats  */
-    T_Tinker = 438,                /* T_Tinker  */
-    T_Tos = 439,                   /* T_Tos  */
-    T_Trap = 440,                  /* T_Trap  */
-    T_True = 441,                  /* T_True  */
-    T_Trustedkey = 442,            /* T_Trustedkey  */
-    T_Ttl = 443,                   /* T_Ttl  */
-    T_Type = 444,                  /* T_Type  */
-    T_U_int = 445,                 /* T_U_int  */
-    T_UEcrypto = 446,              /* T_UEcrypto  */
-    T_UEcryptonak = 447,           /* T_UEcryptonak  */
-    T_UEdigest = 448,              /* T_UEdigest  */
-    T_Unconfig = 449,              /* T_Unconfig  */
-    T_Unpeer = 450,                /* T_Unpeer  */
-    T_Version = 451,               /* T_Version  */
-    T_WanderThreshold = 452,       /* T_WanderThreshold  */
-    T_Week = 453,                  /* T_Week  */
-    T_Wildcard = 454,              /* T_Wildcard  */
-    T_Xleave = 455,                /* T_Xleave  */
-    T_Xmtnonce = 456,              /* T_Xmtnonce  */
-    T_Year = 457,                  /* T_Year  */
-    T_Flag = 458,                  /* T_Flag  */
-    T_EOC = 459,                   /* T_EOC  */
-    T_Simulate = 460,              /* T_Simulate  */
-    T_Beep_Delay = 461,            /* T_Beep_Delay  */
-    T_Sim_Duration = 462,          /* T_Sim_Duration  */
-    T_Server_Offset = 463,         /* T_Server_Offset  */
-    T_Duration = 464,              /* T_Duration  */
-    T_Freq_Offset = 465,           /* T_Freq_Offset  */
-    T_Wander = 466,                /* T_Wander  */
-    T_Jitter = 467,                /* T_Jitter  */
-    T_Prop_Delay = 468,            /* T_Prop_Delay  */
-    T_Proc_Delay = 469             /* T_Proc_Delay  */
+    T_Delrestrict = 286,           /* T_Delrestrict  */
+    T_Device = 287,                /* T_Device  */
+    T_Digest = 288,                /* T_Digest  */
+    T_Disable = 289,               /* T_Disable  */
+    T_Discard = 290,               /* T_Discard  */
+    T_Dispersion = 291,            /* T_Dispersion  */
+    T_Double = 292,                /* T_Double  */
+    T_Driftfile = 293,             /* T_Driftfile  */
+    T_Drop = 294,                  /* T_Drop  */
+    T_Dscp = 295,                  /* T_Dscp  */
+    T_Ellipsis = 296,              /* T_Ellipsis  */
+    T_Enable = 297,                /* T_Enable  */
+    T_End = 298,                   /* T_End  */
+    T_Epeer = 299,                 /* T_Epeer  */
+    T_False = 300,                 /* T_False  */
+    T_File = 301,                  /* T_File  */
+    T_Filegen = 302,               /* T_Filegen  */
+    T_Filenum = 303,               /* T_Filenum  */
+    T_Flag1 = 304,                 /* T_Flag1  */
+    T_Flag2 = 305,                 /* T_Flag2  */
+    T_Flag3 = 306,                 /* T_Flag3  */
+    T_Flag4 = 307,                 /* T_Flag4  */
+    T_Flake = 308,                 /* T_Flake  */
+    T_Floor = 309,                 /* T_Floor  */
+    T_Freq = 310,                  /* T_Freq  */
+    T_Fudge = 311,                 /* T_Fudge  */
+    T_Fuzz = 312,                  /* T_Fuzz  */
+    T_Host = 313,                  /* T_Host  */
+    T_Huffpuff = 314,              /* T_Huffpuff  */
+    T_Iburst = 315,                /* T_Iburst  */
+    T_Ident = 316,                 /* T_Ident  */
+    T_Ignore = 317,                /* T_Ignore  */
+    T_Ignorehash = 318,            /* T_Ignorehash  */
+    T_Incalloc = 319,              /* T_Incalloc  */
+    T_Incmem = 320,                /* T_Incmem  */
+    T_Initalloc = 321,             /* T_Initalloc  */
+    T_Initmem = 322,               /* T_Initmem  */
+    T_Includefile = 323,           /* T_Includefile  */
+    T_Integer = 324,               /* T_Integer  */
+    T_Interface = 325,             /* T_Interface  */
+    T_Intrange = 326,              /* T_Intrange  */
+    T_Io = 327,                    /* T_Io  */
+    T_Ippeerlimit = 328,           /* T_Ippeerlimit  */
+    T_Ipv4 = 329,                  /* T_Ipv4  */
+    T_Ipv4_flag = 330,             /* T_Ipv4_flag  */
+    T_Ipv6 = 331,                  /* T_Ipv6  */
+    T_Ipv6_flag = 332,             /* T_Ipv6_flag  */
+    T_Kernel = 333,                /* T_Kernel  */
+    T_Key = 334,                   /* T_Key  */
+    T_Keys = 335,                  /* T_Keys  */
+    T_Keysdir = 336,               /* T_Keysdir  */
+    T_Kod = 337,                   /* T_Kod  */
+    T_Leapfile = 338,              /* T_Leapfile  */
+    T_Leapsmearinterval = 339,     /* T_Leapsmearinterval  */
+    T_Limited = 340,               /* T_Limited  */
+    T_Link = 341,                  /* T_Link  */
+    T_Listen = 342,                /* T_Listen  */
+    T_Logconfig = 343,             /* T_Logconfig  */
+    T_Logfile = 344,               /* T_Logfile  */
+    T_Loopstats = 345,             /* T_Loopstats  */
+    T_Lowpriotrap = 346,           /* T_Lowpriotrap  */
+    T_Manycastclient = 347,        /* T_Manycastclient  */
+    T_Manycastserver = 348,        /* T_Manycastserver  */
+    T_Mask = 349,                  /* T_Mask  */
+    T_Maxage = 350,                /* T_Maxage  */
+    T_Maxclock = 351,              /* T_Maxclock  */
+    T_Maxdepth = 352,              /* T_Maxdepth  */
+    T_Maxdist = 353,               /* T_Maxdist  */
+    T_Maxmem = 354,                /* T_Maxmem  */
+    T_Maxpoll = 355,               /* T_Maxpoll  */
+    T_Mdnstries = 356,             /* T_Mdnstries  */
+    T_Mem = 357,                   /* T_Mem  */
+    T_Memlock = 358,               /* T_Memlock  */
+    T_Minclock = 359,              /* T_Minclock  */
+    T_Mindepth = 360,              /* T_Mindepth  */
+    T_Mindist = 361,               /* T_Mindist  */
+    T_Minimum = 362,               /* T_Minimum  */
+    T_Minjitter = 363,             /* T_Minjitter  */
+    T_Minpoll = 364,               /* T_Minpoll  */
+    T_Minsane = 365,               /* T_Minsane  */
+    T_Mode = 366,                  /* T_Mode  */
+    T_Mode7 = 367,                 /* T_Mode7  */
+    T_Monitor = 368,               /* T_Monitor  */
+    T_Month = 369,                 /* T_Month  */
+    T_Mru = 370,                   /* T_Mru  */
+    T_Mssntp = 371,                /* T_Mssntp  */
+    T_Multicastclient = 372,       /* T_Multicastclient  */
+    T_Nic = 373,                   /* T_Nic  */
+    T_Nolink = 374,                /* T_Nolink  */
+    T_Nomodify = 375,              /* T_Nomodify  */
+    T_Nomrulist = 376,             /* T_Nomrulist  */
+    T_None = 377,                  /* T_None  */
+    T_Nonvolatile = 378,           /* T_Nonvolatile  */
+    T_Noepeer = 379,               /* T_Noepeer  */
+    T_Nopeer = 380,                /* T_Nopeer  */
+    T_Noquery = 381,               /* T_Noquery  */
+    T_Noselect = 382,              /* T_Noselect  */
+    T_Noserve = 383,               /* T_Noserve  */
+    T_Notrap = 384,                /* T_Notrap  */
+    T_Notrust = 385,               /* T_Notrust  */
+    T_Ntp = 386,                   /* T_Ntp  */
+    T_Ntpport = 387,               /* T_Ntpport  */
+    T_NtpSignDsocket = 388,        /* T_NtpSignDsocket  */
+    T_Orphan = 389,                /* T_Orphan  */
+    T_Orphanwait = 390,            /* T_Orphanwait  */
+    T_PCEdigest = 391,             /* T_PCEdigest  */
+    T_Panic = 392,                 /* T_Panic  */
+    T_Peer = 393,                  /* T_Peer  */
+    T_Peerstats = 394,             /* T_Peerstats  */
+    T_Phone = 395,                 /* T_Phone  */
+    T_Pid = 396,                   /* T_Pid  */
+    T_Pidfile = 397,               /* T_Pidfile  */
+    T_Poll = 398,                  /* T_Poll  */
+    T_PollSkewList = 399,          /* T_PollSkewList  */
+    T_Pool = 400,                  /* T_Pool  */
+    T_Port = 401,                  /* T_Port  */
+    T_PpsData = 402,               /* T_PpsData  */
+    T_Preempt = 403,               /* T_Preempt  */
+    T_Prefer = 404,                /* T_Prefer  */
+    T_Protostats = 405,            /* T_Protostats  */
+    T_Pw = 406,                    /* T_Pw  */
+    T_Randfile = 407,              /* T_Randfile  */
+    T_Rawstats = 408,              /* T_Rawstats  */
+    T_Refid = 409,                 /* T_Refid  */
+    T_Requestkey = 410,            /* T_Requestkey  */
+    T_Reset = 411,                 /* T_Reset  */
+    T_Restrict = 412,              /* T_Restrict  */
+    T_Revoke = 413,                /* T_Revoke  */
+    T_Rlimit = 414,                /* T_Rlimit  */
+    T_Saveconfigdir = 415,         /* T_Saveconfigdir  */
+    T_Server = 416,                /* T_Server  */
+    T_Serverresponse = 417,        /* T_Serverresponse  */
+    T_ServerresponseFuzz = 418,    /* T_ServerresponseFuzz  */
+    T_Setvar = 419,                /* T_Setvar  */
+    T_Source = 420,                /* T_Source  */
+    T_Stacksize = 421,             /* T_Stacksize  */
+    T_Statistics = 422,            /* T_Statistics  */
+    T_Stats = 423,                 /* T_Stats  */
+    T_Statsdir = 424,              /* T_Statsdir  */
+    T_Step = 425,                  /* T_Step  */
+    T_Stepback = 426,              /* T_Stepback  */
+    T_Stepfwd = 427,               /* T_Stepfwd  */
+    T_Stepout = 428,               /* T_Stepout  */
+    T_Stratum = 429,               /* T_Stratum  */
+    T_String = 430,                /* T_String  */
+    T_Sys = 431,                   /* T_Sys  */
+    T_Sysstats = 432,              /* T_Sysstats  */
+    T_Tick = 433,                  /* T_Tick  */
+    T_Time1 = 434,                 /* T_Time1  */
+    T_Time2 = 435,                 /* T_Time2  */
+    T_TimeData = 436,              /* T_TimeData  */
+    T_Timer = 437,                 /* T_Timer  */
+    T_Timingstats = 438,           /* T_Timingstats  */
+    T_Tinker = 439,                /* T_Tinker  */
+    T_Tos = 440,                   /* T_Tos  */
+    T_Trap = 441,                  /* T_Trap  */
+    T_True = 442,                  /* T_True  */
+    T_Trustedkey = 443,            /* T_Trustedkey  */
+    T_Ttl = 444,                   /* T_Ttl  */
+    T_Type = 445,                  /* T_Type  */
+    T_U_int = 446,                 /* T_U_int  */
+    T_UEcrypto = 447,              /* T_UEcrypto  */
+    T_UEcryptonak = 448,           /* T_UEcryptonak  */
+    T_UEdigest = 449,              /* T_UEdigest  */
+    T_Unconfig = 450,              /* T_Unconfig  */
+    T_Unpeer = 451,                /* T_Unpeer  */
+    T_Version = 452,               /* T_Version  */
+    T_WanderThreshold = 453,       /* T_WanderThreshold  */
+    T_Week = 454,                  /* T_Week  */
+    T_Wildcard = 455,              /* T_Wildcard  */
+    T_Xleave = 456,                /* T_Xleave  */
+    T_Xmtnonce = 457,              /* T_Xmtnonce  */
+    T_Year = 458,                  /* T_Year  */
+    T_Flag = 459,                  /* T_Flag  */
+    T_EOC = 460,                   /* T_EOC  */
+    T_Simulate = 461,              /* T_Simulate  */
+    T_Beep_Delay = 462,            /* T_Beep_Delay  */
+    T_Sim_Duration = 463,          /* T_Sim_Duration  */
+    T_Server_Offset = 464,         /* T_Server_Offset  */
+    T_Duration = 465,              /* T_Duration  */
+    T_Freq_Offset = 466,           /* T_Freq_Offset  */
+    T_Wander = 467,                /* T_Wander  */
+    T_Jitter = 468,                /* T_Jitter  */
+    T_Prop_Delay = 469,            /* T_Prop_Delay  */
+    T_Proc_Delay = 470             /* T_Proc_Delay  */
   };
   typedef enum yytokentype yytoken_kind_t;
 #endif
@@ -394,196 +395,197 @@ extern int yydebug;
 #define T_Ctl 283
 #define T_Day 284
 #define T_Default 285
-#define T_Device 286
-#define T_Digest 287
-#define T_Disable 288
-#define T_Discard 289
-#define T_Dispersion 290
-#define T_Double 291
-#define T_Driftfile 292
-#define T_Drop 293
-#define T_Dscp 294
-#define T_Ellipsis 295
-#define T_Enable 296
-#define T_End 297
-#define T_Epeer 298
-#define T_False 299
-#define T_File 300
-#define T_Filegen 301
-#define T_Filenum 302
-#define T_Flag1 303
-#define T_Flag2 304
-#define T_Flag3 305
-#define T_Flag4 306
-#define T_Flake 307
-#define T_Floor 308
-#define T_Freq 309
-#define T_Fudge 310
-#define T_Fuzz 311
-#define T_Host 312
-#define T_Huffpuff 313
-#define T_Iburst 314
-#define T_Ident 315
-#define T_Ignore 316
-#define T_Ignorehash 317
-#define T_Incalloc 318
-#define T_Incmem 319
-#define T_Initalloc 320
-#define T_Initmem 321
-#define T_Includefile 322
-#define T_Integer 323
-#define T_Interface 324
-#define T_Intrange 325
-#define T_Io 326
-#define T_Ippeerlimit 327
-#define T_Ipv4 328
-#define T_Ipv4_flag 329
-#define T_Ipv6 330
-#define T_Ipv6_flag 331
-#define T_Kernel 332
-#define T_Key 333
-#define T_Keys 334
-#define T_Keysdir 335
-#define T_Kod 336
-#define T_Leapfile 337
-#define T_Leapsmearinterval 338
-#define T_Limited 339
-#define T_Link 340
-#define T_Listen 341
-#define T_Logconfig 342
-#define T_Logfile 343
-#define T_Loopstats 344
-#define T_Lowpriotrap 345
-#define T_Manycastclient 346
-#define T_Manycastserver 347
-#define T_Mask 348
-#define T_Maxage 349
-#define T_Maxclock 350
-#define T_Maxdepth 351
-#define T_Maxdist 352
-#define T_Maxmem 353
-#define T_Maxpoll 354
-#define T_Mdnstries 355
-#define T_Mem 356
-#define T_Memlock 357
-#define T_Minclock 358
-#define T_Mindepth 359
-#define T_Mindist 360
-#define T_Minimum 361
-#define T_Minjitter 362
-#define T_Minpoll 363
-#define T_Minsane 364
-#define T_Mode 365
-#define T_Mode7 366
-#define T_Monitor 367
-#define T_Month 368
-#define T_Mru 369
-#define T_Mssntp 370
-#define T_Multicastclient 371
-#define T_Nic 372
-#define T_Nolink 373
-#define T_Nomodify 374
-#define T_Nomrulist 375
-#define T_None 376
-#define T_Nonvolatile 377
-#define T_Noepeer 378
-#define T_Nopeer 379
-#define T_Noquery 380
-#define T_Noselect 381
-#define T_Noserve 382
-#define T_Notrap 383
-#define T_Notrust 384
-#define T_Ntp 385
-#define T_Ntpport 386
-#define T_NtpSignDsocket 387
-#define T_Orphan 388
-#define T_Orphanwait 389
-#define T_PCEdigest 390
-#define T_Panic 391
-#define T_Peer 392
-#define T_Peerstats 393
-#define T_Phone 394
-#define T_Pid 395
-#define T_Pidfile 396
-#define T_Poll 397
-#define T_PollSkewList 398
-#define T_Pool 399
-#define T_Port 400
-#define T_PpsData 401
-#define T_Preempt 402
-#define T_Prefer 403
-#define T_Protostats 404
-#define T_Pw 405
-#define T_Randfile 406
-#define T_Rawstats 407
-#define T_Refid 408
-#define T_Requestkey 409
-#define T_Reset 410
-#define T_Restrict 411
-#define T_Revoke 412
-#define T_Rlimit 413
-#define T_Saveconfigdir 414
-#define T_Server 415
-#define T_Serverresponse 416
-#define T_ServerresponseFuzz 417
-#define T_Setvar 418
-#define T_Source 419
-#define T_Stacksize 420
-#define T_Statistics 421
-#define T_Stats 422
-#define T_Statsdir 423
-#define T_Step 424
-#define T_Stepback 425
-#define T_Stepfwd 426
-#define T_Stepout 427
-#define T_Stratum 428
-#define T_String 429
-#define T_Sys 430
-#define T_Sysstats 431
-#define T_Tick 432
-#define T_Time1 433
-#define T_Time2 434
-#define T_TimeData 435
-#define T_Timer 436
-#define T_Timingstats 437
-#define T_Tinker 438
-#define T_Tos 439
-#define T_Trap 440
-#define T_True 441
-#define T_Trustedkey 442
-#define T_Ttl 443
-#define T_Type 444
-#define T_U_int 445
-#define T_UEcrypto 446
-#define T_UEcryptonak 447
-#define T_UEdigest 448
-#define T_Unconfig 449
-#define T_Unpeer 450
-#define T_Version 451
-#define T_WanderThreshold 452
-#define T_Week 453
-#define T_Wildcard 454
-#define T_Xleave 455
-#define T_Xmtnonce 456
-#define T_Year 457
-#define T_Flag 458
-#define T_EOC 459
-#define T_Simulate 460
-#define T_Beep_Delay 461
-#define T_Sim_Duration 462
-#define T_Server_Offset 463
-#define T_Duration 464
-#define T_Freq_Offset 465
-#define T_Wander 466
-#define T_Jitter 467
-#define T_Prop_Delay 468
-#define T_Proc_Delay 469
+#define T_Delrestrict 286
+#define T_Device 287
+#define T_Digest 288
+#define T_Disable 289
+#define T_Discard 290
+#define T_Dispersion 291
+#define T_Double 292
+#define T_Driftfile 293
+#define T_Drop 294
+#define T_Dscp 295
+#define T_Ellipsis 296
+#define T_Enable 297
+#define T_End 298
+#define T_Epeer 299
+#define T_False 300
+#define T_File 301
+#define T_Filegen 302
+#define T_Filenum 303
+#define T_Flag1 304
+#define T_Flag2 305
+#define T_Flag3 306
+#define T_Flag4 307
+#define T_Flake 308
+#define T_Floor 309
+#define T_Freq 310
+#define T_Fudge 311
+#define T_Fuzz 312
+#define T_Host 313
+#define T_Huffpuff 314
+#define T_Iburst 315
+#define T_Ident 316
+#define T_Ignore 317
+#define T_Ignorehash 318
+#define T_Incalloc 319
+#define T_Incmem 320
+#define T_Initalloc 321
+#define T_Initmem 322
+#define T_Includefile 323
+#define T_Integer 324
+#define T_Interface 325
+#define T_Intrange 326
+#define T_Io 327
+#define T_Ippeerlimit 328
+#define T_Ipv4 329
+#define T_Ipv4_flag 330
+#define T_Ipv6 331
+#define T_Ipv6_flag 332
+#define T_Kernel 333
+#define T_Key 334
+#define T_Keys 335
+#define T_Keysdir 336
+#define T_Kod 337
+#define T_Leapfile 338
+#define T_Leapsmearinterval 339
+#define T_Limited 340
+#define T_Link 341
+#define T_Listen 342
+#define T_Logconfig 343
+#define T_Logfile 344
+#define T_Loopstats 345
+#define T_Lowpriotrap 346
+#define T_Manycastclient 347
+#define T_Manycastserver 348
+#define T_Mask 349
+#define T_Maxage 350
+#define T_Maxclock 351
+#define T_Maxdepth 352
+#define T_Maxdist 353
+#define T_Maxmem 354
+#define T_Maxpoll 355
+#define T_Mdnstries 356
+#define T_Mem 357
+#define T_Memlock 358
+#define T_Minclock 359
+#define T_Mindepth 360
+#define T_Mindist 361
+#define T_Minimum 362
+#define T_Minjitter 363
+#define T_Minpoll 364
+#define T_Minsane 365
+#define T_Mode 366
+#define T_Mode7 367
+#define T_Monitor 368
+#define T_Month 369
+#define T_Mru 370
+#define T_Mssntp 371
+#define T_Multicastclient 372
+#define T_Nic 373
+#define T_Nolink 374
+#define T_Nomodify 375
+#define T_Nomrulist 376
+#define T_None 377
+#define T_Nonvolatile 378
+#define T_Noepeer 379
+#define T_Nopeer 380
+#define T_Noquery 381
+#define T_Noselect 382
+#define T_Noserve 383
+#define T_Notrap 384
+#define T_Notrust 385
+#define T_Ntp 386
+#define T_Ntpport 387
+#define T_NtpSignDsocket 388
+#define T_Orphan 389
+#define T_Orphanwait 390
+#define T_PCEdigest 391
+#define T_Panic 392
+#define T_Peer 393
+#define T_Peerstats 394
+#define T_Phone 395
+#define T_Pid 396
+#define T_Pidfile 397
+#define T_Poll 398
+#define T_PollSkewList 399
+#define T_Pool 400
+#define T_Port 401
+#define T_PpsData 402
+#define T_Preempt 403
+#define T_Prefer 404
+#define T_Protostats 405
+#define T_Pw 406
+#define T_Randfile 407
+#define T_Rawstats 408
+#define T_Refid 409
+#define T_Requestkey 410
+#define T_Reset 411
+#define T_Restrict 412
+#define T_Revoke 413
+#define T_Rlimit 414
+#define T_Saveconfigdir 415
+#define T_Server 416
+#define T_Serverresponse 417
+#define T_ServerresponseFuzz 418
+#define T_Setvar 419
+#define T_Source 420
+#define T_Stacksize 421
+#define T_Statistics 422
+#define T_Stats 423
+#define T_Statsdir 424
+#define T_Step 425
+#define T_Stepback 426
+#define T_Stepfwd 427
+#define T_Stepout 428
+#define T_Stratum 429
+#define T_String 430
+#define T_Sys 431
+#define T_Sysstats 432
+#define T_Tick 433
+#define T_Time1 434
+#define T_Time2 435
+#define T_TimeData 436
+#define T_Timer 437
+#define T_Timingstats 438
+#define T_Tinker 439
+#define T_Tos 440
+#define T_Trap 441
+#define T_True 442
+#define T_Trustedkey 443
+#define T_Ttl 444
+#define T_Type 445
+#define T_U_int 446
+#define T_UEcrypto 447
+#define T_UEcryptonak 448
+#define T_UEdigest 449
+#define T_Unconfig 450
+#define T_Unpeer 451
+#define T_Version 452
+#define T_WanderThreshold 453
+#define T_Week 454
+#define T_Wildcard 455
+#define T_Xleave 456
+#define T_Xmtnonce 457
+#define T_Year 458
+#define T_Flag 459
+#define T_EOC 460
+#define T_Simulate 461
+#define T_Beep_Delay 462
+#define T_Sim_Duration 463
+#define T_Server_Offset 464
+#define T_Duration 465
+#define T_Freq_Offset 466
+#define T_Wander 467
+#define T_Jitter 468
+#define T_Prop_Delay 469
+#define T_Proc_Delay 470
 
 /* Value type.  */
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
 union YYSTYPE
 {
-#line 52 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 52 "../../ntpd/ntp_parser.y"
 
 	char *			String;
 	double			Double;
@@ -602,7 +604,7 @@ union YYSTYPE
 	script_info *		Sim_script;
 	script_info_fifo *	Sim_script_fifo;
 
-#line 606 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 608 "ntp_parser.c"
 
 };
 typedef union YYSTYPE YYSTYPE;
@@ -613,9 +615,11 @@ typedef union YYSTYPE YYSTYPE;
 
 extern YYSTYPE yylval;
 
+
 int yyparse (void);
 
-#endif /* !YY_YY__SRC_NTP_STABLE_NTPD_NTP_PARSER_H_INCLUDED  */
+
+#endif /* !YY_YY_NTP_PARSER_H_INCLUDED  */
 /* Symbol kind.  */
 enum yysymbol_kind_t
 {
@@ -651,311 +655,313 @@ enum yysymbol_kind_t
   YYSYMBOL_T_Ctl = 28,                     /* T_Ctl  */
   YYSYMBOL_T_Day = 29,                     /* T_Day  */
   YYSYMBOL_T_Default = 30,                 /* T_Default  */
-  YYSYMBOL_T_Device = 31,                  /* T_Device  */
-  YYSYMBOL_T_Digest = 32,                  /* T_Digest  */
-  YYSYMBOL_T_Disable = 33,                 /* T_Disable  */
-  YYSYMBOL_T_Discard = 34,                 /* T_Discard  */
-  YYSYMBOL_T_Dispersion = 35,              /* T_Dispersion  */
-  YYSYMBOL_T_Double = 36,                  /* T_Double  */
-  YYSYMBOL_T_Driftfile = 37,               /* T_Driftfile  */
-  YYSYMBOL_T_Drop = 38,                    /* T_Drop  */
-  YYSYMBOL_T_Dscp = 39,                    /* T_Dscp  */
-  YYSYMBOL_T_Ellipsis = 40,                /* T_Ellipsis  */
-  YYSYMBOL_T_Enable = 41,                  /* T_Enable  */
-  YYSYMBOL_T_End = 42,                     /* T_End  */
-  YYSYMBOL_T_Epeer = 43,                   /* T_Epeer  */
-  YYSYMBOL_T_False = 44,                   /* T_False  */
-  YYSYMBOL_T_File = 45,                    /* T_File  */
-  YYSYMBOL_T_Filegen = 46,                 /* T_Filegen  */
-  YYSYMBOL_T_Filenum = 47,                 /* T_Filenum  */
-  YYSYMBOL_T_Flag1 = 48,                   /* T_Flag1  */
-  YYSYMBOL_T_Flag2 = 49,                   /* T_Flag2  */
-  YYSYMBOL_T_Flag3 = 50,                   /* T_Flag3  */
-  YYSYMBOL_T_Flag4 = 51,                   /* T_Flag4  */
-  YYSYMBOL_T_Flake = 52,                   /* T_Flake  */
-  YYSYMBOL_T_Floor = 53,                   /* T_Floor  */
-  YYSYMBOL_T_Freq = 54,                    /* T_Freq  */
-  YYSYMBOL_T_Fudge = 55,                   /* T_Fudge  */
-  YYSYMBOL_T_Fuzz = 56,                    /* T_Fuzz  */
-  YYSYMBOL_T_Host = 57,                    /* T_Host  */
-  YYSYMBOL_T_Huffpuff = 58,                /* T_Huffpuff  */
-  YYSYMBOL_T_Iburst = 59,                  /* T_Iburst  */
-  YYSYMBOL_T_Ident = 60,                   /* T_Ident  */
-  YYSYMBOL_T_Ignore = 61,                  /* T_Ignore  */
-  YYSYMBOL_T_Ignorehash = 62,              /* T_Ignorehash  */
-  YYSYMBOL_T_Incalloc = 63,                /* T_Incalloc  */
-  YYSYMBOL_T_Incmem = 64,                  /* T_Incmem  */
-  YYSYMBOL_T_Initalloc = 65,               /* T_Initalloc  */
-  YYSYMBOL_T_Initmem = 66,                 /* T_Initmem  */
-  YYSYMBOL_T_Includefile = 67,             /* T_Includefile  */
-  YYSYMBOL_T_Integer = 68,                 /* T_Integer  */
-  YYSYMBOL_T_Interface = 69,               /* T_Interface  */
-  YYSYMBOL_T_Intrange = 70,                /* T_Intrange  */
-  YYSYMBOL_T_Io = 71,                      /* T_Io  */
-  YYSYMBOL_T_Ippeerlimit = 72,             /* T_Ippeerlimit  */
-  YYSYMBOL_T_Ipv4 = 73,                    /* T_Ipv4  */
-  YYSYMBOL_T_Ipv4_flag = 74,               /* T_Ipv4_flag  */
-  YYSYMBOL_T_Ipv6 = 75,                    /* T_Ipv6  */
-  YYSYMBOL_T_Ipv6_flag = 76,               /* T_Ipv6_flag  */
-  YYSYMBOL_T_Kernel = 77,                  /* T_Kernel  */
-  YYSYMBOL_T_Key = 78,                     /* T_Key  */
-  YYSYMBOL_T_Keys = 79,                    /* T_Keys  */
-  YYSYMBOL_T_Keysdir = 80,                 /* T_Keysdir  */
-  YYSYMBOL_T_Kod = 81,                     /* T_Kod  */
-  YYSYMBOL_T_Leapfile = 82,                /* T_Leapfile  */
-  YYSYMBOL_T_Leapsmearinterval = 83,       /* T_Leapsmearinterval  */
-  YYSYMBOL_T_Limited = 84,                 /* T_Limited  */
-  YYSYMBOL_T_Link = 85,                    /* T_Link  */
-  YYSYMBOL_T_Listen = 86,                  /* T_Listen  */
-  YYSYMBOL_T_Logconfig = 87,               /* T_Logconfig  */
-  YYSYMBOL_T_Logfile = 88,                 /* T_Logfile  */
-  YYSYMBOL_T_Loopstats = 89,               /* T_Loopstats  */
-  YYSYMBOL_T_Lowpriotrap = 90,             /* T_Lowpriotrap  */
-  YYSYMBOL_T_Manycastclient = 91,          /* T_Manycastclient  */
-  YYSYMBOL_T_Manycastserver = 92,          /* T_Manycastserver  */
-  YYSYMBOL_T_Mask = 93,                    /* T_Mask  */
-  YYSYMBOL_T_Maxage = 94,                  /* T_Maxage  */
-  YYSYMBOL_T_Maxclock = 95,                /* T_Maxclock  */
-  YYSYMBOL_T_Maxdepth = 96,                /* T_Maxdepth  */
-  YYSYMBOL_T_Maxdist = 97,                 /* T_Maxdist  */
-  YYSYMBOL_T_Maxmem = 98,                  /* T_Maxmem  */
-  YYSYMBOL_T_Maxpoll = 99,                 /* T_Maxpoll  */
-  YYSYMBOL_T_Mdnstries = 100,              /* T_Mdnstries  */
-  YYSYMBOL_T_Mem = 101,                    /* T_Mem  */
-  YYSYMBOL_T_Memlock = 102,                /* T_Memlock  */
-  YYSYMBOL_T_Minclock = 103,               /* T_Minclock  */
-  YYSYMBOL_T_Mindepth = 104,               /* T_Mindepth  */
-  YYSYMBOL_T_Mindist = 105,                /* T_Mindist  */
-  YYSYMBOL_T_Minimum = 106,                /* T_Minimum  */
-  YYSYMBOL_T_Minjitter = 107,              /* T_Minjitter  */
-  YYSYMBOL_T_Minpoll = 108,                /* T_Minpoll  */
-  YYSYMBOL_T_Minsane = 109,                /* T_Minsane  */
-  YYSYMBOL_T_Mode = 110,                   /* T_Mode  */
-  YYSYMBOL_T_Mode7 = 111,                  /* T_Mode7  */
-  YYSYMBOL_T_Monitor = 112,                /* T_Monitor  */
-  YYSYMBOL_T_Month = 113,                  /* T_Month  */
-  YYSYMBOL_T_Mru = 114,                    /* T_Mru  */
-  YYSYMBOL_T_Mssntp = 115,                 /* T_Mssntp  */
-  YYSYMBOL_T_Multicastclient = 116,        /* T_Multicastclient  */
-  YYSYMBOL_T_Nic = 117,                    /* T_Nic  */
-  YYSYMBOL_T_Nolink = 118,                 /* T_Nolink  */
-  YYSYMBOL_T_Nomodify = 119,               /* T_Nomodify  */
-  YYSYMBOL_T_Nomrulist = 120,              /* T_Nomrulist  */
-  YYSYMBOL_T_None = 121,                   /* T_None  */
-  YYSYMBOL_T_Nonvolatile = 122,            /* T_Nonvolatile  */
-  YYSYMBOL_T_Noepeer = 123,                /* T_Noepeer  */
-  YYSYMBOL_T_Nopeer = 124,                 /* T_Nopeer  */
-  YYSYMBOL_T_Noquery = 125,                /* T_Noquery  */
-  YYSYMBOL_T_Noselect = 126,               /* T_Noselect  */
-  YYSYMBOL_T_Noserve = 127,                /* T_Noserve  */
-  YYSYMBOL_T_Notrap = 128,                 /* T_Notrap  */
-  YYSYMBOL_T_Notrust = 129,                /* T_Notrust  */
-  YYSYMBOL_T_Ntp = 130,                    /* T_Ntp  */
-  YYSYMBOL_T_Ntpport = 131,                /* T_Ntpport  */
-  YYSYMBOL_T_NtpSignDsocket = 132,         /* T_NtpSignDsocket  */
-  YYSYMBOL_T_Orphan = 133,                 /* T_Orphan  */
-  YYSYMBOL_T_Orphanwait = 134,             /* T_Orphanwait  */
-  YYSYMBOL_T_PCEdigest = 135,              /* T_PCEdigest  */
-  YYSYMBOL_T_Panic = 136,                  /* T_Panic  */
-  YYSYMBOL_T_Peer = 137,                   /* T_Peer  */
-  YYSYMBOL_T_Peerstats = 138,              /* T_Peerstats  */
-  YYSYMBOL_T_Phone = 139,                  /* T_Phone  */
-  YYSYMBOL_T_Pid = 140,                    /* T_Pid  */
-  YYSYMBOL_T_Pidfile = 141,                /* T_Pidfile  */
-  YYSYMBOL_T_Poll = 142,                   /* T_Poll  */
-  YYSYMBOL_T_PollSkewList = 143,           /* T_PollSkewList  */
-  YYSYMBOL_T_Pool = 144,                   /* T_Pool  */
-  YYSYMBOL_T_Port = 145,                   /* T_Port  */
-  YYSYMBOL_T_PpsData = 146,                /* T_PpsData  */
-  YYSYMBOL_T_Preempt = 147,                /* T_Preempt  */
-  YYSYMBOL_T_Prefer = 148,                 /* T_Prefer  */
-  YYSYMBOL_T_Protostats = 149,             /* T_Protostats  */
-  YYSYMBOL_T_Pw = 150,                     /* T_Pw  */
-  YYSYMBOL_T_Randfile = 151,               /* T_Randfile  */
-  YYSYMBOL_T_Rawstats = 152,               /* T_Rawstats  */
-  YYSYMBOL_T_Refid = 153,                  /* T_Refid  */
-  YYSYMBOL_T_Requestkey = 154,             /* T_Requestkey  */
-  YYSYMBOL_T_Reset = 155,                  /* T_Reset  */
-  YYSYMBOL_T_Restrict = 156,               /* T_Restrict  */
-  YYSYMBOL_T_Revoke = 157,                 /* T_Revoke  */
-  YYSYMBOL_T_Rlimit = 158,                 /* T_Rlimit  */
-  YYSYMBOL_T_Saveconfigdir = 159,          /* T_Saveconfigdir  */
-  YYSYMBOL_T_Server = 160,                 /* T_Server  */
-  YYSYMBOL_T_Serverresponse = 161,         /* T_Serverresponse  */
-  YYSYMBOL_T_ServerresponseFuzz = 162,     /* T_ServerresponseFuzz  */
-  YYSYMBOL_T_Setvar = 163,                 /* T_Setvar  */
-  YYSYMBOL_T_Source = 164,                 /* T_Source  */
-  YYSYMBOL_T_Stacksize = 165,              /* T_Stacksize  */
-  YYSYMBOL_T_Statistics = 166,             /* T_Statistics  */
-  YYSYMBOL_T_Stats = 167,                  /* T_Stats  */
-  YYSYMBOL_T_Statsdir = 168,               /* T_Statsdir  */
-  YYSYMBOL_T_Step = 169,                   /* T_Step  */
-  YYSYMBOL_T_Stepback = 170,               /* T_Stepback  */
-  YYSYMBOL_T_Stepfwd = 171,                /* T_Stepfwd  */
-  YYSYMBOL_T_Stepout = 172,                /* T_Stepout  */
-  YYSYMBOL_T_Stratum = 173,                /* T_Stratum  */
-  YYSYMBOL_T_String = 174,                 /* T_String  */
-  YYSYMBOL_T_Sys = 175,                    /* T_Sys  */
-  YYSYMBOL_T_Sysstats = 176,               /* T_Sysstats  */
-  YYSYMBOL_T_Tick = 177,                   /* T_Tick  */
-  YYSYMBOL_T_Time1 = 178,                  /* T_Time1  */
-  YYSYMBOL_T_Time2 = 179,                  /* T_Time2  */
-  YYSYMBOL_T_TimeData = 180,               /* T_TimeData  */
-  YYSYMBOL_T_Timer = 181,                  /* T_Timer  */
-  YYSYMBOL_T_Timingstats = 182,            /* T_Timingstats  */
-  YYSYMBOL_T_Tinker = 183,                 /* T_Tinker  */
-  YYSYMBOL_T_Tos = 184,                    /* T_Tos  */
-  YYSYMBOL_T_Trap = 185,                   /* T_Trap  */
-  YYSYMBOL_T_True = 186,                   /* T_True  */
-  YYSYMBOL_T_Trustedkey = 187,             /* T_Trustedkey  */
-  YYSYMBOL_T_Ttl = 188,                    /* T_Ttl  */
-  YYSYMBOL_T_Type = 189,                   /* T_Type  */
-  YYSYMBOL_T_U_int = 190,                  /* T_U_int  */
-  YYSYMBOL_T_UEcrypto = 191,               /* T_UEcrypto  */
-  YYSYMBOL_T_UEcryptonak = 192,            /* T_UEcryptonak  */
-  YYSYMBOL_T_UEdigest = 193,               /* T_UEdigest  */
-  YYSYMBOL_T_Unconfig = 194,               /* T_Unconfig  */
-  YYSYMBOL_T_Unpeer = 195,                 /* T_Unpeer  */
-  YYSYMBOL_T_Version = 196,                /* T_Version  */
-  YYSYMBOL_T_WanderThreshold = 197,        /* T_WanderThreshold  */
-  YYSYMBOL_T_Week = 198,                   /* T_Week  */
-  YYSYMBOL_T_Wildcard = 199,               /* T_Wildcard  */
-  YYSYMBOL_T_Xleave = 200,                 /* T_Xleave  */
-  YYSYMBOL_T_Xmtnonce = 201,               /* T_Xmtnonce  */
-  YYSYMBOL_T_Year = 202,                   /* T_Year  */
-  YYSYMBOL_T_Flag = 203,                   /* T_Flag  */
-  YYSYMBOL_T_EOC = 204,                    /* T_EOC  */
-  YYSYMBOL_T_Simulate = 205,               /* T_Simulate  */
-  YYSYMBOL_T_Beep_Delay = 206,             /* T_Beep_Delay  */
-  YYSYMBOL_T_Sim_Duration = 207,           /* T_Sim_Duration  */
-  YYSYMBOL_T_Server_Offset = 208,          /* T_Server_Offset  */
-  YYSYMBOL_T_Duration = 209,               /* T_Duration  */
-  YYSYMBOL_T_Freq_Offset = 210,            /* T_Freq_Offset  */
-  YYSYMBOL_T_Wander = 211,                 /* T_Wander  */
-  YYSYMBOL_T_Jitter = 212,                 /* T_Jitter  */
-  YYSYMBOL_T_Prop_Delay = 213,             /* T_Prop_Delay  */
-  YYSYMBOL_T_Proc_Delay = 214,             /* T_Proc_Delay  */
-  YYSYMBOL_215_ = 215,                     /* '|'  */
-  YYSYMBOL_216_ = 216,                     /* '='  */
-  YYSYMBOL_217_ = 217,                     /* '('  */
-  YYSYMBOL_218_ = 218,                     /* ')'  */
-  YYSYMBOL_219_ = 219,                     /* '{'  */
-  YYSYMBOL_220_ = 220,                     /* '}'  */
-  YYSYMBOL_YYACCEPT = 221,                 /* $accept  */
-  YYSYMBOL_configuration = 222,            /* configuration  */
-  YYSYMBOL_command_list = 223,             /* command_list  */
-  YYSYMBOL_command = 224,                  /* command  */
-  YYSYMBOL_server_command = 225,           /* server_command  */
-  YYSYMBOL_client_type = 226,              /* client_type  */
-  YYSYMBOL_address = 227,                  /* address  */
-  YYSYMBOL_ip_address = 228,               /* ip_address  */
-  YYSYMBOL_address_fam = 229,              /* address_fam  */
-  YYSYMBOL_option_list = 230,              /* option_list  */
-  YYSYMBOL_option = 231,                   /* option  */
-  YYSYMBOL_option_flag = 232,              /* option_flag  */
-  YYSYMBOL_option_flag_keyword = 233,      /* option_flag_keyword  */
-  YYSYMBOL_option_int = 234,               /* option_int  */
-  YYSYMBOL_option_int_keyword = 235,       /* option_int_keyword  */
-  YYSYMBOL_option_str = 236,               /* option_str  */
-  YYSYMBOL_option_str_keyword = 237,       /* option_str_keyword  */
-  YYSYMBOL_unpeer_command = 238,           /* unpeer_command  */
-  YYSYMBOL_unpeer_keyword = 239,           /* unpeer_keyword  */
-  YYSYMBOL_other_mode_command = 240,       /* other_mode_command  */
-  YYSYMBOL_authentication_command = 241,   /* authentication_command  */
-  YYSYMBOL_crypto_command_list = 242,      /* crypto_command_list  */
-  YYSYMBOL_crypto_command = 243,           /* crypto_command  */
-  YYSYMBOL_crypto_str_keyword = 244,       /* crypto_str_keyword  */
-  YYSYMBOL_orphan_mode_command = 245,      /* orphan_mode_command  */
-  YYSYMBOL_tos_option_list = 246,          /* tos_option_list  */
-  YYSYMBOL_tos_option = 247,               /* tos_option  */
-  YYSYMBOL_tos_option_int_keyword = 248,   /* tos_option_int_keyword  */
-  YYSYMBOL_tos_option_dbl_keyword = 249,   /* tos_option_dbl_keyword  */
-  YYSYMBOL_monitoring_command = 250,       /* monitoring_command  */
-  YYSYMBOL_stats_list = 251,               /* stats_list  */
-  YYSYMBOL_stat = 252,                     /* stat  */
-  YYSYMBOL_filegen_option_list = 253,      /* filegen_option_list  */
-  YYSYMBOL_filegen_option = 254,           /* filegen_option  */
-  YYSYMBOL_link_nolink = 255,              /* link_nolink  */
-  YYSYMBOL_enable_disable = 256,           /* enable_disable  */
-  YYSYMBOL_filegen_type = 257,             /* filegen_type  */
-  YYSYMBOL_access_control_command = 258,   /* access_control_command  */
-  YYSYMBOL_res_ippeerlimit = 259,          /* res_ippeerlimit  */
-  YYSYMBOL_ac_flag_list = 260,             /* ac_flag_list  */
-  YYSYMBOL_access_control_flag = 261,      /* access_control_flag  */
-  YYSYMBOL_discard_option_list = 262,      /* discard_option_list  */
-  YYSYMBOL_discard_option = 263,           /* discard_option  */
-  YYSYMBOL_discard_option_keyword = 264,   /* discard_option_keyword  */
-  YYSYMBOL_mru_option_list = 265,          /* mru_option_list  */
-  YYSYMBOL_mru_option = 266,               /* mru_option  */
-  YYSYMBOL_mru_option_keyword = 267,       /* mru_option_keyword  */
-  YYSYMBOL_fudge_command = 268,            /* fudge_command  */
-  YYSYMBOL_fudge_factor_list = 269,        /* fudge_factor_list  */
-  YYSYMBOL_fudge_factor = 270,             /* fudge_factor  */
-  YYSYMBOL_fudge_factor_dbl_keyword = 271, /* fudge_factor_dbl_keyword  */
-  YYSYMBOL_fudge_factor_bool_keyword = 272, /* fudge_factor_bool_keyword  */
-  YYSYMBOL_device_command = 273,           /* device_command  */
-  YYSYMBOL_device_item_list = 274,         /* device_item_list  */
-  YYSYMBOL_device_item = 275,              /* device_item  */
-  YYSYMBOL_device_item_path_keyword = 276, /* device_item_path_keyword  */
-  YYSYMBOL_rlimit_command = 277,           /* rlimit_command  */
-  YYSYMBOL_rlimit_option_list = 278,       /* rlimit_option_list  */
-  YYSYMBOL_rlimit_option = 279,            /* rlimit_option  */
-  YYSYMBOL_rlimit_option_keyword = 280,    /* rlimit_option_keyword  */
-  YYSYMBOL_system_option_command = 281,    /* system_option_command  */
-  YYSYMBOL_system_option_list = 282,       /* system_option_list  */
-  YYSYMBOL_system_option = 283,            /* system_option  */
-  YYSYMBOL_system_option_flag_keyword = 284, /* system_option_flag_keyword  */
-  YYSYMBOL_system_option_local_flag_keyword = 285, /* system_option_local_flag_keyword  */
-  YYSYMBOL_tinker_command = 286,           /* tinker_command  */
-  YYSYMBOL_tinker_option_list = 287,       /* tinker_option_list  */
-  YYSYMBOL_tinker_option = 288,            /* tinker_option  */
-  YYSYMBOL_tinker_option_keyword = 289,    /* tinker_option_keyword  */
-  YYSYMBOL_miscellaneous_command = 290,    /* miscellaneous_command  */
-  YYSYMBOL_misc_cmd_dbl_keyword = 291,     /* misc_cmd_dbl_keyword  */
-  YYSYMBOL_misc_cmd_int_keyword = 292,     /* misc_cmd_int_keyword  */
-  YYSYMBOL_opt_hash_check = 293,           /* opt_hash_check  */
-  YYSYMBOL_misc_cmd_str_keyword = 294,     /* misc_cmd_str_keyword  */
-  YYSYMBOL_misc_cmd_str_lcl_keyword = 295, /* misc_cmd_str_lcl_keyword  */
-  YYSYMBOL_drift_parm = 296,               /* drift_parm  */
-  YYSYMBOL_pollskew_list = 297,            /* pollskew_list  */
-  YYSYMBOL_pollskew_spec = 298,            /* pollskew_spec  */
-  YYSYMBOL_pollskew_cycle = 299,           /* pollskew_cycle  */
-  YYSYMBOL_variable_assign = 300,          /* variable_assign  */
-  YYSYMBOL_t_default_or_zero = 301,        /* t_default_or_zero  */
-  YYSYMBOL_trap_option_list = 302,         /* trap_option_list  */
-  YYSYMBOL_trap_option = 303,              /* trap_option  */
-  YYSYMBOL_log_config_list = 304,          /* log_config_list  */
-  YYSYMBOL_log_config_command = 305,       /* log_config_command  */
-  YYSYMBOL_interface_command = 306,        /* interface_command  */
-  YYSYMBOL_interface_nic = 307,            /* interface_nic  */
-  YYSYMBOL_nic_rule_class = 308,           /* nic_rule_class  */
-  YYSYMBOL_nic_rule_action = 309,          /* nic_rule_action  */
-  YYSYMBOL_reset_command = 310,            /* reset_command  */
-  YYSYMBOL_counter_set_list = 311,         /* counter_set_list  */
-  YYSYMBOL_counter_set_keyword = 312,      /* counter_set_keyword  */
-  YYSYMBOL_integer_list = 313,             /* integer_list  */
-  YYSYMBOL_integer_list_range = 314,       /* integer_list_range  */
-  YYSYMBOL_integer_list_range_elt = 315,   /* integer_list_range_elt  */
-  YYSYMBOL_integer_range = 316,            /* integer_range  */
-  YYSYMBOL_string_list = 317,              /* string_list  */
-  YYSYMBOL_address_list = 318,             /* address_list  */
-  YYSYMBOL_boolean = 319,                  /* boolean  */
-  YYSYMBOL_number = 320,                   /* number  */
-  YYSYMBOL_basedate = 321,                 /* basedate  */
-  YYSYMBOL_simulate_command = 322,         /* simulate_command  */
-  YYSYMBOL_sim_conf_start = 323,           /* sim_conf_start  */
-  YYSYMBOL_sim_init_statement_list = 324,  /* sim_init_statement_list  */
-  YYSYMBOL_sim_init_statement = 325,       /* sim_init_statement  */
-  YYSYMBOL_sim_init_keyword = 326,         /* sim_init_keyword  */
-  YYSYMBOL_sim_server_list = 327,          /* sim_server_list  */
-  YYSYMBOL_sim_server = 328,               /* sim_server  */
-  YYSYMBOL_sim_server_offset = 329,        /* sim_server_offset  */
-  YYSYMBOL_sim_server_name = 330,          /* sim_server_name  */
-  YYSYMBOL_sim_act_list = 331,             /* sim_act_list  */
-  YYSYMBOL_sim_act = 332,                  /* sim_act  */
-  YYSYMBOL_sim_act_stmt_list = 333,        /* sim_act_stmt_list  */
-  YYSYMBOL_sim_act_stmt = 334,             /* sim_act_stmt  */
-  YYSYMBOL_sim_act_keyword = 335           /* sim_act_keyword  */
+  YYSYMBOL_T_Delrestrict = 31,             /* T_Delrestrict  */
+  YYSYMBOL_T_Device = 32,                  /* T_Device  */
+  YYSYMBOL_T_Digest = 33,                  /* T_Digest  */
+  YYSYMBOL_T_Disable = 34,                 /* T_Disable  */
+  YYSYMBOL_T_Discard = 35,                 /* T_Discard  */
+  YYSYMBOL_T_Dispersion = 36,              /* T_Dispersion  */
+  YYSYMBOL_T_Double = 37,                  /* T_Double  */
+  YYSYMBOL_T_Driftfile = 38,               /* T_Driftfile  */
+  YYSYMBOL_T_Drop = 39,                    /* T_Drop  */
+  YYSYMBOL_T_Dscp = 40,                    /* T_Dscp  */
+  YYSYMBOL_T_Ellipsis = 41,                /* T_Ellipsis  */
+  YYSYMBOL_T_Enable = 42,                  /* T_Enable  */
+  YYSYMBOL_T_End = 43,                     /* T_End  */
+  YYSYMBOL_T_Epeer = 44,                   /* T_Epeer  */
+  YYSYMBOL_T_False = 45,                   /* T_False  */
+  YYSYMBOL_T_File = 46,                    /* T_File  */
+  YYSYMBOL_T_Filegen = 47,                 /* T_Filegen  */
+  YYSYMBOL_T_Filenum = 48,                 /* T_Filenum  */
+  YYSYMBOL_T_Flag1 = 49,                   /* T_Flag1  */
+  YYSYMBOL_T_Flag2 = 50,                   /* T_Flag2  */
+  YYSYMBOL_T_Flag3 = 51,                   /* T_Flag3  */
+  YYSYMBOL_T_Flag4 = 52,                   /* T_Flag4  */
+  YYSYMBOL_T_Flake = 53,                   /* T_Flake  */
+  YYSYMBOL_T_Floor = 54,                   /* T_Floor  */
+  YYSYMBOL_T_Freq = 55,                    /* T_Freq  */
+  YYSYMBOL_T_Fudge = 56,                   /* T_Fudge  */
+  YYSYMBOL_T_Fuzz = 57,                    /* T_Fuzz  */
+  YYSYMBOL_T_Host = 58,                    /* T_Host  */
+  YYSYMBOL_T_Huffpuff = 59,                /* T_Huffpuff  */
+  YYSYMBOL_T_Iburst = 60,                  /* T_Iburst  */
+  YYSYMBOL_T_Ident = 61,                   /* T_Ident  */
+  YYSYMBOL_T_Ignore = 62,                  /* T_Ignore  */
+  YYSYMBOL_T_Ignorehash = 63,              /* T_Ignorehash  */
+  YYSYMBOL_T_Incalloc = 64,                /* T_Incalloc  */
+  YYSYMBOL_T_Incmem = 65,                  /* T_Incmem  */
+  YYSYMBOL_T_Initalloc = 66,               /* T_Initalloc  */
+  YYSYMBOL_T_Initmem = 67,                 /* T_Initmem  */
+  YYSYMBOL_T_Includefile = 68,             /* T_Includefile  */
+  YYSYMBOL_T_Integer = 69,                 /* T_Integer  */
+  YYSYMBOL_T_Interface = 70,               /* T_Interface  */
+  YYSYMBOL_T_Intrange = 71,                /* T_Intrange  */
+  YYSYMBOL_T_Io = 72,                      /* T_Io  */
+  YYSYMBOL_T_Ippeerlimit = 73,             /* T_Ippeerlimit  */
+  YYSYMBOL_T_Ipv4 = 74,                    /* T_Ipv4  */
+  YYSYMBOL_T_Ipv4_flag = 75,               /* T_Ipv4_flag  */
+  YYSYMBOL_T_Ipv6 = 76,                    /* T_Ipv6  */
+  YYSYMBOL_T_Ipv6_flag = 77,               /* T_Ipv6_flag  */
+  YYSYMBOL_T_Kernel = 78,                  /* T_Kernel  */
+  YYSYMBOL_T_Key = 79,                     /* T_Key  */
+  YYSYMBOL_T_Keys = 80,                    /* T_Keys  */
+  YYSYMBOL_T_Keysdir = 81,                 /* T_Keysdir  */
+  YYSYMBOL_T_Kod = 82,                     /* T_Kod  */
+  YYSYMBOL_T_Leapfile = 83,                /* T_Leapfile  */
+  YYSYMBOL_T_Leapsmearinterval = 84,       /* T_Leapsmearinterval  */
+  YYSYMBOL_T_Limited = 85,                 /* T_Limited  */
+  YYSYMBOL_T_Link = 86,                    /* T_Link  */
+  YYSYMBOL_T_Listen = 87,                  /* T_Listen  */
+  YYSYMBOL_T_Logconfig = 88,               /* T_Logconfig  */
+  YYSYMBOL_T_Logfile = 89,                 /* T_Logfile  */
+  YYSYMBOL_T_Loopstats = 90,               /* T_Loopstats  */
+  YYSYMBOL_T_Lowpriotrap = 91,             /* T_Lowpriotrap  */
+  YYSYMBOL_T_Manycastclient = 92,          /* T_Manycastclient  */
+  YYSYMBOL_T_Manycastserver = 93,          /* T_Manycastserver  */
+  YYSYMBOL_T_Mask = 94,                    /* T_Mask  */
+  YYSYMBOL_T_Maxage = 95,                  /* T_Maxage  */
+  YYSYMBOL_T_Maxclock = 96,                /* T_Maxclock  */
+  YYSYMBOL_T_Maxdepth = 97,                /* T_Maxdepth  */
+  YYSYMBOL_T_Maxdist = 98,                 /* T_Maxdist  */
+  YYSYMBOL_T_Maxmem = 99,                  /* T_Maxmem  */
+  YYSYMBOL_T_Maxpoll = 100,                /* T_Maxpoll  */
+  YYSYMBOL_T_Mdnstries = 101,              /* T_Mdnstries  */
+  YYSYMBOL_T_Mem = 102,                    /* T_Mem  */
+  YYSYMBOL_T_Memlock = 103,                /* T_Memlock  */
+  YYSYMBOL_T_Minclock = 104,               /* T_Minclock  */
+  YYSYMBOL_T_Mindepth = 105,               /* T_Mindepth  */
+  YYSYMBOL_T_Mindist = 106,                /* T_Mindist  */
+  YYSYMBOL_T_Minimum = 107,                /* T_Minimum  */
+  YYSYMBOL_T_Minjitter = 108,              /* T_Minjitter  */
+  YYSYMBOL_T_Minpoll = 109,                /* T_Minpoll  */
+  YYSYMBOL_T_Minsane = 110,                /* T_Minsane  */
+  YYSYMBOL_T_Mode = 111,                   /* T_Mode  */
+  YYSYMBOL_T_Mode7 = 112,                  /* T_Mode7  */
+  YYSYMBOL_T_Monitor = 113,                /* T_Monitor  */
+  YYSYMBOL_T_Month = 114,                  /* T_Month  */
+  YYSYMBOL_T_Mru = 115,                    /* T_Mru  */
+  YYSYMBOL_T_Mssntp = 116,                 /* T_Mssntp  */
+  YYSYMBOL_T_Multicastclient = 117,        /* T_Multicastclient  */
+  YYSYMBOL_T_Nic = 118,                    /* T_Nic  */
+  YYSYMBOL_T_Nolink = 119,                 /* T_Nolink  */
+  YYSYMBOL_T_Nomodify = 120,               /* T_Nomodify  */
+  YYSYMBOL_T_Nomrulist = 121,              /* T_Nomrulist  */
+  YYSYMBOL_T_None = 122,                   /* T_None  */
+  YYSYMBOL_T_Nonvolatile = 123,            /* T_Nonvolatile  */
+  YYSYMBOL_T_Noepeer = 124,                /* T_Noepeer  */
+  YYSYMBOL_T_Nopeer = 125,                 /* T_Nopeer  */
+  YYSYMBOL_T_Noquery = 126,                /* T_Noquery  */
+  YYSYMBOL_T_Noselect = 127,               /* T_Noselect  */
+  YYSYMBOL_T_Noserve = 128,                /* T_Noserve  */
+  YYSYMBOL_T_Notrap = 129,                 /* T_Notrap  */
+  YYSYMBOL_T_Notrust = 130,                /* T_Notrust  */
+  YYSYMBOL_T_Ntp = 131,                    /* T_Ntp  */
+  YYSYMBOL_T_Ntpport = 132,                /* T_Ntpport  */
+  YYSYMBOL_T_NtpSignDsocket = 133,         /* T_NtpSignDsocket  */
+  YYSYMBOL_T_Orphan = 134,                 /* T_Orphan  */
+  YYSYMBOL_T_Orphanwait = 135,             /* T_Orphanwait  */
+  YYSYMBOL_T_PCEdigest = 136,              /* T_PCEdigest  */
+  YYSYMBOL_T_Panic = 137,                  /* T_Panic  */
+  YYSYMBOL_T_Peer = 138,                   /* T_Peer  */
+  YYSYMBOL_T_Peerstats = 139,              /* T_Peerstats  */
+  YYSYMBOL_T_Phone = 140,                  /* T_Phone  */
+  YYSYMBOL_T_Pid = 141,                    /* T_Pid  */
+  YYSYMBOL_T_Pidfile = 142,                /* T_Pidfile  */
+  YYSYMBOL_T_Poll = 143,                   /* T_Poll  */
+  YYSYMBOL_T_PollSkewList = 144,           /* T_PollSkewList  */
+  YYSYMBOL_T_Pool = 145,                   /* T_Pool  */
+  YYSYMBOL_T_Port = 146,                   /* T_Port  */
+  YYSYMBOL_T_PpsData = 147,                /* T_PpsData  */
+  YYSYMBOL_T_Preempt = 148,                /* T_Preempt  */
+  YYSYMBOL_T_Prefer = 149,                 /* T_Prefer  */
+  YYSYMBOL_T_Protostats = 150,             /* T_Protostats  */
+  YYSYMBOL_T_Pw = 151,                     /* T_Pw  */
+  YYSYMBOL_T_Randfile = 152,               /* T_Randfile  */
+  YYSYMBOL_T_Rawstats = 153,               /* T_Rawstats  */
+  YYSYMBOL_T_Refid = 154,                  /* T_Refid  */
+  YYSYMBOL_T_Requestkey = 155,             /* T_Requestkey  */
+  YYSYMBOL_T_Reset = 156,                  /* T_Reset  */
+  YYSYMBOL_T_Restrict = 157,               /* T_Restrict  */
+  YYSYMBOL_T_Revoke = 158,                 /* T_Revoke  */
+  YYSYMBOL_T_Rlimit = 159,                 /* T_Rlimit  */
+  YYSYMBOL_T_Saveconfigdir = 160,          /* T_Saveconfigdir  */
+  YYSYMBOL_T_Server = 161,                 /* T_Server  */
+  YYSYMBOL_T_Serverresponse = 162,         /* T_Serverresponse  */
+  YYSYMBOL_T_ServerresponseFuzz = 163,     /* T_ServerresponseFuzz  */
+  YYSYMBOL_T_Setvar = 164,                 /* T_Setvar  */
+  YYSYMBOL_T_Source = 165,                 /* T_Source  */
+  YYSYMBOL_T_Stacksize = 166,              /* T_Stacksize  */
+  YYSYMBOL_T_Statistics = 167,             /* T_Statistics  */
+  YYSYMBOL_T_Stats = 168,                  /* T_Stats  */
+  YYSYMBOL_T_Statsdir = 169,               /* T_Statsdir  */
+  YYSYMBOL_T_Step = 170,                   /* T_Step  */
+  YYSYMBOL_T_Stepback = 171,               /* T_Stepback  */
+  YYSYMBOL_T_Stepfwd = 172,                /* T_Stepfwd  */
+  YYSYMBOL_T_Stepout = 173,                /* T_Stepout  */
+  YYSYMBOL_T_Stratum = 174,                /* T_Stratum  */
+  YYSYMBOL_T_String = 175,                 /* T_String  */
+  YYSYMBOL_T_Sys = 176,                    /* T_Sys  */
+  YYSYMBOL_T_Sysstats = 177,               /* T_Sysstats  */
+  YYSYMBOL_T_Tick = 178,                   /* T_Tick  */
+  YYSYMBOL_T_Time1 = 179,                  /* T_Time1  */
+  YYSYMBOL_T_Time2 = 180,                  /* T_Time2  */
+  YYSYMBOL_T_TimeData = 181,               /* T_TimeData  */
+  YYSYMBOL_T_Timer = 182,                  /* T_Timer  */
+  YYSYMBOL_T_Timingstats = 183,            /* T_Timingstats  */
+  YYSYMBOL_T_Tinker = 184,                 /* T_Tinker  */
+  YYSYMBOL_T_Tos = 185,                    /* T_Tos  */
+  YYSYMBOL_T_Trap = 186,                   /* T_Trap  */
+  YYSYMBOL_T_True = 187,                   /* T_True  */
+  YYSYMBOL_T_Trustedkey = 188,             /* T_Trustedkey  */
+  YYSYMBOL_T_Ttl = 189,                    /* T_Ttl  */
+  YYSYMBOL_T_Type = 190,                   /* T_Type  */
+  YYSYMBOL_T_U_int = 191,                  /* T_U_int  */
+  YYSYMBOL_T_UEcrypto = 192,               /* T_UEcrypto  */
+  YYSYMBOL_T_UEcryptonak = 193,            /* T_UEcryptonak  */
+  YYSYMBOL_T_UEdigest = 194,               /* T_UEdigest  */
+  YYSYMBOL_T_Unconfig = 195,               /* T_Unconfig  */
+  YYSYMBOL_T_Unpeer = 196,                 /* T_Unpeer  */
+  YYSYMBOL_T_Version = 197,                /* T_Version  */
+  YYSYMBOL_T_WanderThreshold = 198,        /* T_WanderThreshold  */
+  YYSYMBOL_T_Week = 199,                   /* T_Week  */
+  YYSYMBOL_T_Wildcard = 200,               /* T_Wildcard  */
+  YYSYMBOL_T_Xleave = 201,                 /* T_Xleave  */
+  YYSYMBOL_T_Xmtnonce = 202,               /* T_Xmtnonce  */
+  YYSYMBOL_T_Year = 203,                   /* T_Year  */
+  YYSYMBOL_T_Flag = 204,                   /* T_Flag  */
+  YYSYMBOL_T_EOC = 205,                    /* T_EOC  */
+  YYSYMBOL_T_Simulate = 206,               /* T_Simulate  */
+  YYSYMBOL_T_Beep_Delay = 207,             /* T_Beep_Delay  */
+  YYSYMBOL_T_Sim_Duration = 208,           /* T_Sim_Duration  */
+  YYSYMBOL_T_Server_Offset = 209,          /* T_Server_Offset  */
+  YYSYMBOL_T_Duration = 210,               /* T_Duration  */
+  YYSYMBOL_T_Freq_Offset = 211,            /* T_Freq_Offset  */
+  YYSYMBOL_T_Wander = 212,                 /* T_Wander  */
+  YYSYMBOL_T_Jitter = 213,                 /* T_Jitter  */
+  YYSYMBOL_T_Prop_Delay = 214,             /* T_Prop_Delay  */
+  YYSYMBOL_T_Proc_Delay = 215,             /* T_Proc_Delay  */
+  YYSYMBOL_216_ = 216,                     /* '|'  */
+  YYSYMBOL_217_ = 217,                     /* '='  */
+  YYSYMBOL_218_ = 218,                     /* '('  */
+  YYSYMBOL_219_ = 219,                     /* ')'  */
+  YYSYMBOL_220_ = 220,                     /* '{'  */
+  YYSYMBOL_221_ = 221,                     /* '}'  */
+  YYSYMBOL_YYACCEPT = 222,                 /* $accept  */
+  YYSYMBOL_configuration = 223,            /* configuration  */
+  YYSYMBOL_command_list = 224,             /* command_list  */
+  YYSYMBOL_command = 225,                  /* command  */
+  YYSYMBOL_server_command = 226,           /* server_command  */
+  YYSYMBOL_client_type = 227,              /* client_type  */
+  YYSYMBOL_address = 228,                  /* address  */
+  YYSYMBOL_ip_address = 229,               /* ip_address  */
+  YYSYMBOL_address_fam = 230,              /* address_fam  */
+  YYSYMBOL_option_list = 231,              /* option_list  */
+  YYSYMBOL_option = 232,                   /* option  */
+  YYSYMBOL_option_flag = 233,              /* option_flag  */
+  YYSYMBOL_option_flag_keyword = 234,      /* option_flag_keyword  */
+  YYSYMBOL_option_int = 235,               /* option_int  */
+  YYSYMBOL_option_int_keyword = 236,       /* option_int_keyword  */
+  YYSYMBOL_option_str = 237,               /* option_str  */
+  YYSYMBOL_option_str_keyword = 238,       /* option_str_keyword  */
+  YYSYMBOL_unpeer_command = 239,           /* unpeer_command  */
+  YYSYMBOL_unpeer_keyword = 240,           /* unpeer_keyword  */
+  YYSYMBOL_other_mode_command = 241,       /* other_mode_command  */
+  YYSYMBOL_authentication_command = 242,   /* authentication_command  */
+  YYSYMBOL_crypto_command_list = 243,      /* crypto_command_list  */
+  YYSYMBOL_crypto_command = 244,           /* crypto_command  */
+  YYSYMBOL_crypto_str_keyword = 245,       /* crypto_str_keyword  */
+  YYSYMBOL_orphan_mode_command = 246,      /* orphan_mode_command  */
+  YYSYMBOL_tos_option_list = 247,          /* tos_option_list  */
+  YYSYMBOL_tos_option = 248,               /* tos_option  */
+  YYSYMBOL_tos_option_int_keyword = 249,   /* tos_option_int_keyword  */
+  YYSYMBOL_tos_option_dbl_keyword = 250,   /* tos_option_dbl_keyword  */
+  YYSYMBOL_monitoring_command = 251,       /* monitoring_command  */
+  YYSYMBOL_stats_list = 252,               /* stats_list  */
+  YYSYMBOL_stat = 253,                     /* stat  */
+  YYSYMBOL_filegen_option_list = 254,      /* filegen_option_list  */
+  YYSYMBOL_filegen_option = 255,           /* filegen_option  */
+  YYSYMBOL_link_nolink = 256,              /* link_nolink  */
+  YYSYMBOL_enable_disable = 257,           /* enable_disable  */
+  YYSYMBOL_filegen_type = 258,             /* filegen_type  */
+  YYSYMBOL_access_control_command = 259,   /* access_control_command  */
+  YYSYMBOL_restrict_mask = 260,            /* restrict_mask  */
+  YYSYMBOL_res_ippeerlimit = 261,          /* res_ippeerlimit  */
+  YYSYMBOL_ac_flag_list = 262,             /* ac_flag_list  */
+  YYSYMBOL_access_control_flag = 263,      /* access_control_flag  */
+  YYSYMBOL_discard_option_list = 264,      /* discard_option_list  */
+  YYSYMBOL_discard_option = 265,           /* discard_option  */
+  YYSYMBOL_discard_option_keyword = 266,   /* discard_option_keyword  */
+  YYSYMBOL_mru_option_list = 267,          /* mru_option_list  */
+  YYSYMBOL_mru_option = 268,               /* mru_option  */
+  YYSYMBOL_mru_option_keyword = 269,       /* mru_option_keyword  */
+  YYSYMBOL_fudge_command = 270,            /* fudge_command  */
+  YYSYMBOL_fudge_factor_list = 271,        /* fudge_factor_list  */
+  YYSYMBOL_fudge_factor = 272,             /* fudge_factor  */
+  YYSYMBOL_fudge_factor_dbl_keyword = 273, /* fudge_factor_dbl_keyword  */
+  YYSYMBOL_fudge_factor_bool_keyword = 274, /* fudge_factor_bool_keyword  */
+  YYSYMBOL_device_command = 275,           /* device_command  */
+  YYSYMBOL_device_item_list = 276,         /* device_item_list  */
+  YYSYMBOL_device_item = 277,              /* device_item  */
+  YYSYMBOL_device_item_path_keyword = 278, /* device_item_path_keyword  */
+  YYSYMBOL_rlimit_command = 279,           /* rlimit_command  */
+  YYSYMBOL_rlimit_option_list = 280,       /* rlimit_option_list  */
+  YYSYMBOL_rlimit_option = 281,            /* rlimit_option  */
+  YYSYMBOL_rlimit_option_keyword = 282,    /* rlimit_option_keyword  */
+  YYSYMBOL_system_option_command = 283,    /* system_option_command  */
+  YYSYMBOL_system_option_list = 284,       /* system_option_list  */
+  YYSYMBOL_system_option = 285,            /* system_option  */
+  YYSYMBOL_system_option_flag_keyword = 286, /* system_option_flag_keyword  */
+  YYSYMBOL_system_option_local_flag_keyword = 287, /* system_option_local_flag_keyword  */
+  YYSYMBOL_tinker_command = 288,           /* tinker_command  */
+  YYSYMBOL_tinker_option_list = 289,       /* tinker_option_list  */
+  YYSYMBOL_tinker_option = 290,            /* tinker_option  */
+  YYSYMBOL_tinker_option_keyword = 291,    /* tinker_option_keyword  */
+  YYSYMBOL_miscellaneous_command = 292,    /* miscellaneous_command  */
+  YYSYMBOL_misc_cmd_dbl_keyword = 293,     /* misc_cmd_dbl_keyword  */
+  YYSYMBOL_misc_cmd_int_keyword = 294,     /* misc_cmd_int_keyword  */
+  YYSYMBOL_opt_hash_check = 295,           /* opt_hash_check  */
+  YYSYMBOL_misc_cmd_str_keyword = 296,     /* misc_cmd_str_keyword  */
+  YYSYMBOL_misc_cmd_str_lcl_keyword = 297, /* misc_cmd_str_lcl_keyword  */
+  YYSYMBOL_drift_parm = 298,               /* drift_parm  */
+  YYSYMBOL_pollskew_list = 299,            /* pollskew_list  */
+  YYSYMBOL_pollskew_spec = 300,            /* pollskew_spec  */
+  YYSYMBOL_pollskew_cycle = 301,           /* pollskew_cycle  */
+  YYSYMBOL_variable_assign = 302,          /* variable_assign  */
+  YYSYMBOL_t_default_or_zero = 303,        /* t_default_or_zero  */
+  YYSYMBOL_trap_option_list = 304,         /* trap_option_list  */
+  YYSYMBOL_trap_option = 305,              /* trap_option  */
+  YYSYMBOL_log_config_list = 306,          /* log_config_list  */
+  YYSYMBOL_log_config_command = 307,       /* log_config_command  */
+  YYSYMBOL_interface_command = 308,        /* interface_command  */
+  YYSYMBOL_interface_nic = 309,            /* interface_nic  */
+  YYSYMBOL_nic_rule_class = 310,           /* nic_rule_class  */
+  YYSYMBOL_nic_rule_action = 311,          /* nic_rule_action  */
+  YYSYMBOL_reset_command = 312,            /* reset_command  */
+  YYSYMBOL_counter_set_list = 313,         /* counter_set_list  */
+  YYSYMBOL_counter_set_keyword = 314,      /* counter_set_keyword  */
+  YYSYMBOL_integer_list = 315,             /* integer_list  */
+  YYSYMBOL_integer_list_range = 316,       /* integer_list_range  */
+  YYSYMBOL_integer_list_range_elt = 317,   /* integer_list_range_elt  */
+  YYSYMBOL_integer_range = 318,            /* integer_range  */
+  YYSYMBOL_string_list = 319,              /* string_list  */
+  YYSYMBOL_address_list = 320,             /* address_list  */
+  YYSYMBOL_boolean = 321,                  /* boolean  */
+  YYSYMBOL_number = 322,                   /* number  */
+  YYSYMBOL_basedate = 323,                 /* basedate  */
+  YYSYMBOL_simulate_command = 324,         /* simulate_command  */
+  YYSYMBOL_sim_conf_start = 325,           /* sim_conf_start  */
+  YYSYMBOL_sim_init_statement_list = 326,  /* sim_init_statement_list  */
+  YYSYMBOL_sim_init_statement = 327,       /* sim_init_statement  */
+  YYSYMBOL_sim_init_keyword = 328,         /* sim_init_keyword  */
+  YYSYMBOL_sim_server_list = 329,          /* sim_server_list  */
+  YYSYMBOL_sim_server = 330,               /* sim_server  */
+  YYSYMBOL_sim_server_offset = 331,        /* sim_server_offset  */
+  YYSYMBOL_sim_server_name = 332,          /* sim_server_name  */
+  YYSYMBOL_sim_act_list = 333,             /* sim_act_list  */
+  YYSYMBOL_sim_act = 334,                  /* sim_act  */
+  YYSYMBOL_sim_act_stmt_list = 335,        /* sim_act_stmt_list  */
+  YYSYMBOL_sim_act_stmt = 336,             /* sim_act_stmt  */
+  YYSYMBOL_sim_act_keyword = 337           /* sim_act_keyword  */
 };
 typedef enum yysymbol_kind_t yysymbol_kind_t;
 
@@ -1113,12 +1119,18 @@ typedef int yy_state_fast_t;
 # define YY_USE(E) /* empty */
 #endif
 
-#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
 /* Suppress an incorrect diagnostic about yylval being uninitialized.  */
-# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN                            \
+#if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
+# if __GNUC__ * 100 + __GNUC_MINOR__ < 407
+#  define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN                           \
+    _Pragma ("GCC diagnostic push")                                     \
+    _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
+# else
+#  define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN                           \
     _Pragma ("GCC diagnostic push")                                     \
     _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")              \
     _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
+# endif
 # define YY_IGNORE_MAYBE_UNINITIALIZED_END      \
     _Pragma ("GCC diagnostic pop")
 #else
@@ -1275,21 +1287,21 @@ union yyalloc
 #endif /* !YYCOPY_NEEDED */
 
 /* YYFINAL -- State number of the termination state.  */
-#define YYFINAL  222
+#define YYFINAL  225
 /* YYLAST -- Last index in YYTABLE.  */
-#define YYLAST   688
+#define YYLAST   717
 
 /* YYNTOKENS -- Number of terminals.  */
-#define YYNTOKENS  221
+#define YYNTOKENS  222
 /* YYNNTS -- Number of nonterminals.  */
-#define YYNNTS  115
+#define YYNNTS  116
 /* YYNRULES -- Number of rules.  */
-#define YYNRULES  343
+#define YYNRULES  346
 /* YYNSTATES -- Number of states.  */
-#define YYNSTATES  463
+#define YYNSTATES  467
 
 /* YYMAXUTOK -- Last valid token kind.  */
-#define YYMAXUTOK   469
+#define YYMAXUTOK   470
 
 
 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
@@ -1307,15 +1319,15 @@ static const yytype_uint8 yytranslate[] =
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     217,   218,     2,     2,     2,     2,     2,     2,     2,     2,
+     218,   219,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,   216,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,   217,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,   219,   215,   220,     2,     2,     2,     2,
+       2,     2,     2,   220,   216,   221,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
@@ -1349,48 +1361,49 @@ static const yytype_uint8 yytranslate[] =
      175,   176,   177,   178,   179,   180,   181,   182,   183,   184,
      185,   186,   187,   188,   189,   190,   191,   192,   193,   194,
      195,   196,   197,   198,   199,   200,   201,   202,   203,   204,
-     205,   206,   207,   208,   209,   210,   211,   212,   213,   214
+     205,   206,   207,   208,   209,   210,   211,   212,   213,   214,
+     215
 };
 
 #if YYDEBUG
-  /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
+/* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
 static const yytype_int16 yyrline[] =
 {
-       0,   397,   397,   401,   402,   403,   418,   419,   420,   421,
-     422,   423,   424,   425,   426,   427,   428,   429,   430,   431,
-     432,   440,   450,   451,   452,   453,   454,   458,   459,   464,
-     469,   471,   477,   478,   486,   487,   488,   492,   497,   498,
-     499,   500,   501,   502,   503,   504,   505,   509,   511,   516,
-     517,   518,   519,   520,   521,   525,   530,   539,   549,   550,
-     560,   562,   564,   566,   577,   584,   586,   591,   593,   595,
-     597,   599,   609,   615,   616,   624,   626,   638,   639,   640,
-     641,   642,   651,   656,   661,   669,   671,   673,   675,   680,
-     681,   682,   683,   684,   685,   686,   687,   688,   692,   693,
-     702,   704,   713,   723,   728,   736,   737,   738,   739,   740,
-     741,   742,   743,   748,   749,   757,   767,   776,   791,   796,
-     797,   801,   802,   806,   807,   808,   809,   810,   811,   812,
-     821,   825,   829,   837,   845,   853,   868,   883,   896,   897,
-     917,   918,   926,   937,   938,   939,   940,   941,   942,   943,
-     944,   945,   946,   947,   948,   949,   950,   951,   952,   953,
-     957,   962,   970,   975,   976,   977,   981,   986,   994,   999,
-    1000,  1001,  1002,  1003,  1004,  1005,  1006,  1014,  1024,  1029,
-    1037,  1039,  1041,  1050,  1052,  1057,  1058,  1059,  1063,  1064,
-    1065,  1066,  1074,  1084,  1089,  1097,  1102,  1103,  1111,  1116,
-    1121,  1129,  1134,  1135,  1136,  1145,  1147,  1152,  1157,  1165,
-    1167,  1184,  1185,  1186,  1187,  1188,  1189,  1193,  1194,  1195,
-    1196,  1197,  1198,  1206,  1211,  1216,  1224,  1229,  1230,  1231,
-    1232,  1233,  1234,  1235,  1236,  1237,  1238,  1247,  1248,  1249,
-    1256,  1263,  1270,  1286,  1305,  1313,  1315,  1317,  1319,  1321,
-    1323,  1325,  1332,  1337,  1338,  1339,  1343,  1347,  1356,  1358,
-    1361,  1365,  1369,  1370,  1371,  1375,  1386,  1404,  1417,  1418,
-    1423,  1449,  1450,  1455,  1460,  1462,  1467,  1468,  1476,  1478,
-    1486,  1491,  1499,  1524,  1531,  1541,  1542,  1546,  1547,  1548,
-    1549,  1553,  1554,  1555,  1559,  1564,  1569,  1577,  1578,  1579,
-    1580,  1581,  1582,  1583,  1593,  1598,  1606,  1611,  1619,  1621,
-    1625,  1630,  1635,  1643,  1648,  1656,  1665,  1666,  1670,  1671,
-    1675,  1683,  1701,  1705,  1710,  1718,  1723,  1724,  1728,  1733,
-    1741,  1746,  1751,  1756,  1761,  1769,  1774,  1779,  1787,  1792,
-    1793,  1794,  1795,  1796
+       0,   399,   399,   403,   404,   405,   420,   421,   422,   423,
+     424,   425,   426,   427,   428,   429,   430,   431,   432,   433,
+     434,   442,   452,   453,   454,   455,   456,   460,   461,   466,
+     471,   473,   479,   480,   488,   489,   490,   494,   499,   500,
+     501,   502,   503,   504,   505,   506,   507,   511,   513,   518,
+     519,   520,   521,   522,   523,   527,   532,   541,   551,   552,
+     562,   564,   566,   568,   579,   586,   588,   593,   595,   597,
+     599,   601,   611,   617,   618,   626,   628,   640,   641,   642,
+     643,   644,   653,   658,   663,   671,   673,   675,   677,   682,
+     683,   684,   685,   686,   687,   688,   689,   690,   694,   695,
+     704,   706,   715,   725,   730,   738,   739,   740,   741,   742,
+     743,   744,   745,   750,   751,   759,   769,   778,   793,   798,
+     799,   803,   804,   808,   809,   810,   811,   812,   813,   814,
+     823,   827,   831,   840,   849,   865,   881,   891,   900,   916,
+     917,   925,   926,   946,   947,   955,   966,   967,   968,   969,
+     970,   971,   972,   973,   974,   975,   976,   977,   978,   979,
+     980,   981,   982,   986,   991,   999,  1004,  1005,  1006,  1010,
+    1015,  1023,  1028,  1029,  1030,  1031,  1032,  1033,  1034,  1035,
+    1043,  1053,  1058,  1066,  1068,  1070,  1079,  1081,  1086,  1087,
+    1088,  1092,  1093,  1094,  1095,  1103,  1113,  1118,  1126,  1131,
+    1132,  1140,  1145,  1150,  1158,  1163,  1164,  1165,  1174,  1176,
+    1181,  1186,  1194,  1196,  1213,  1214,  1215,  1216,  1217,  1218,
+    1222,  1223,  1224,  1225,  1226,  1227,  1235,  1240,  1245,  1253,
+    1258,  1259,  1260,  1261,  1262,  1263,  1264,  1265,  1266,  1267,
+    1276,  1277,  1278,  1285,  1292,  1299,  1315,  1334,  1342,  1344,
+    1346,  1348,  1350,  1352,  1354,  1361,  1366,  1367,  1368,  1372,
+    1376,  1385,  1387,  1390,  1394,  1398,  1399,  1400,  1404,  1415,
+    1433,  1446,  1447,  1452,  1478,  1484,  1489,  1494,  1496,  1501,
+    1502,  1510,  1512,  1520,  1525,  1533,  1558,  1565,  1575,  1576,
+    1580,  1581,  1582,  1583,  1587,  1588,  1589,  1593,  1598,  1603,
+    1611,  1612,  1613,  1614,  1615,  1616,  1617,  1627,  1632,  1640,
+    1645,  1653,  1655,  1659,  1664,  1669,  1677,  1682,  1690,  1699,
+    1700,  1704,  1705,  1709,  1717,  1735,  1739,  1744,  1752,  1757,
+    1758,  1762,  1767,  1775,  1780,  1785,  1790,  1795,  1803,  1808,
+    1813,  1821,  1826,  1827,  1828,  1829,  1830
 };
 #endif
 
@@ -1412,11 +1425,11 @@ static const char *const yytname[] =
   "T_Broadcast", "T_Broadcastclient", "T_Broadcastdelay", "T_Burst",
   "T_Calibrate", "T_Ceiling", "T_Checkhash", "T_Clockstats", "T_Cohort",
   "T_ControlKey", "T_Crypto", "T_Cryptostats", "T_Ctl", "T_Day",
-  "T_Default", "T_Device", "T_Digest", "T_Disable", "T_Discard",
-  "T_Dispersion", "T_Double", "T_Driftfile", "T_Drop", "T_Dscp",
-  "T_Ellipsis", "T_Enable", "T_End", "T_Epeer", "T_False", "T_File",
-  "T_Filegen", "T_Filenum", "T_Flag1", "T_Flag2", "T_Flag3", "T_Flag4",
-  "T_Flake", "T_Floor", "T_Freq", "T_Fudge", "T_Fuzz", "T_Host",
+  "T_Default", "T_Delrestrict", "T_Device", "T_Digest", "T_Disable",
+  "T_Discard", "T_Dispersion", "T_Double", "T_Driftfile", "T_Drop",
+  "T_Dscp", "T_Ellipsis", "T_Enable", "T_End", "T_Epeer", "T_False",
+  "T_File", "T_Filegen", "T_Filenum", "T_Flag1", "T_Flag2", "T_Flag3",
+  "T_Flag4", "T_Flake", "T_Floor", "T_Freq", "T_Fudge", "T_Fuzz", "T_Host",
   "T_Huffpuff", "T_Iburst", "T_Ident", "T_Ignore", "T_Ignorehash",
   "T_Incalloc", "T_Incmem", "T_Initalloc", "T_Initmem", "T_Includefile",
   "T_Integer", "T_Interface", "T_Intrange", "T_Io", "T_Ippeerlimit",
@@ -1458,10 +1471,10 @@ static const char *const yytname[] =
   "tos_option", "tos_option_int_keyword", "tos_option_dbl_keyword",
   "monitoring_command", "stats_list", "stat", "filegen_option_list",
   "filegen_option", "link_nolink", "enable_disable", "filegen_type",
-  "access_control_command", "res_ippeerlimit", "ac_flag_list",
-  "access_control_flag", "discard_option_list", "discard_option",
-  "discard_option_keyword", "mru_option_list", "mru_option",
-  "mru_option_keyword", "fudge_command", "fudge_factor_list",
+  "access_control_command", "restrict_mask", "res_ippeerlimit",
+  "ac_flag_list", "access_control_flag", "discard_option_list",
+  "discard_option", "discard_option_keyword", "mru_option_list",
+  "mru_option", "mru_option_keyword", "fudge_command", "fudge_factor_list",
   "fudge_factor", "fudge_factor_dbl_keyword", "fudge_factor_bool_keyword",
   "device_command", "device_item_list", "device_item",
   "device_item_path_keyword", "rlimit_command", "rlimit_option_list",
@@ -1492,38 +1505,7 @@ yysymbol_name (yysymbol_kind_t yysymbol)
 }
 #endif
 
-#ifdef YYPRINT
-/* YYTOKNUM[NUM] -- (External) token number corresponding to the
-   (internal) symbol number NUM (which must be that of a token).  */
-static const yytype_int16 yytoknum[] =
-{
-       0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
-     265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
-     275,   276,   277,   278,   279,   280,   281,   282,   283,   284,
-     285,   286,   287,   288,   289,   290,   291,   292,   293,   294,
-     295,   296,   297,   298,   299,   300,   301,   302,   303,   304,
-     305,   306,   307,   308,   309,   310,   311,   312,   313,   314,
-     315,   316,   317,   318,   319,   320,   321,   322,   323,   324,
-     325,   326,   327,   328,   329,   330,   331,   332,   333,   334,
-     335,   336,   337,   338,   339,   340,   341,   342,   343,   344,
-     345,   346,   347,   348,   349,   350,   351,   352,   353,   354,
-     355,   356,   357,   358,   359,   360,   361,   362,   363,   364,
-     365,   366,   367,   368,   369,   370,   371,   372,   373,   374,
-     375,   376,   377,   378,   379,   380,   381,   382,   383,   384,
-     385,   386,   387,   388,   389,   390,   391,   392,   393,   394,
-     395,   396,   397,   398,   399,   400,   401,   402,   403,   404,
-     405,   406,   407,   408,   409,   410,   411,   412,   413,   414,
-     415,   416,   417,   418,   419,   420,   421,   422,   423,   424,
-     425,   426,   427,   428,   429,   430,   431,   432,   433,   434,
-     435,   436,   437,   438,   439,   440,   441,   442,   443,   444,
-     445,   446,   447,   448,   449,   450,   451,   452,   453,   454,
-     455,   456,   457,   458,   459,   460,   461,   462,   463,   464,
-     465,   466,   467,   468,   469,   124,    61,    40,    41,   123,
-     125
-};
-#endif
-
-#define YYPACT_NINF (-247)
+#define YYPACT_NINF (-280)
 
 #define yypact_value_is_default(Yyn) \
   ((Yyn) == YYPACT_NINF)
@@ -1533,390 +1515,396 @@ static const yytype_int16 yytoknum[] =
 #define yytable_value_is_error(Yyn) \
   0
 
-  /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
-     STATE-NUM.  */
+/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
+   STATE-NUM.  */
 static const yytype_int16 yypact[] =
 {
-       5,  -178,   -19,  -247,  -247,  -247,    -2,  -247,   -58,   294,
-      29,   -94,  -247,   294,  -247,   109,   -58,  -247,   -79,  -247,
-     -70,   -68,   -65,  -247,   -63,  -247,  -247,   -58,    42,   205,
-     -58,  -247,  -247,   -56,  -247,   -50,  -247,  -247,  -247,    45,
-      27,    41,    55,   -34,  -247,  -247,   -49,   109,   -41,  -247,
-     271,   554,   -40,   -64,    72,  -247,  -247,  -247,   145,   196,
-     -54,  -247,   -58,  -247,   -58,  -247,  -247,  -247,  -247,  -247,
-    -247,  -247,  -247,  -247,  -247,  -247,    33,    83,   -22,   -17,
-    -247,   -11,  -247,  -247,   -52,  -247,  -247,  -247,    26,  -247,
-    -247,  -247,  -121,  -247,    -5,  -247,  -247,  -247,  -247,  -247,
-    -247,  -247,  -247,  -247,  -247,  -247,  -247,   294,  -247,  -247,
-    -247,  -247,  -247,  -247,    29,  -247,    86,   119,  -247,   294,
-    -247,  -247,  -247,  -247,  -247,  -247,  -247,  -247,  -247,   319,
-     377,  -247,  -247,   -10,  -247,   -63,  -247,  -247,   -58,  -247,
-    -247,  -247,  -247,  -247,  -247,  -247,  -247,  -247,   205,  -247,
-     104,   -58,  -247,  -247,     7,    23,  -247,  -247,  -247,  -247,
-    -247,  -247,  -247,  -247,    27,  -247,   103,   154,   156,   103,
-       1,  -247,  -247,  -247,  -247,   -34,  -247,   126,   -29,  -247,
-     109,  -247,  -247,  -247,  -247,  -247,  -247,  -247,  -247,  -247,
-    -247,  -247,  -247,   271,  -247,    33,    30,  -247,  -247,  -247,
-     -20,  -247,  -247,  -247,  -247,  -247,  -247,  -247,  -247,   554,
-    -247,   139,    33,  -247,  -247,  -247,   143,   -64,  -247,  -247,
-    -247,   155,  -247,    20,  -247,  -247,  -247,  -247,  -247,  -247,
-    -247,  -247,  -247,  -247,  -247,  -247,     4,  -104,  -247,  -247,
-    -247,  -247,  -247,   157,  -247,    54,  -247,  -247,  -121,  -247,
-      57,  -247,  -247,  -247,  -247,  -247,    -4,    58,  -247,  -247,
-    -247,  -247,  -247,    67,   175,  -247,  -247,   319,  -247,    33,
-     -20,  -247,  -247,  -247,  -247,  -247,  -247,  -247,  -247,  -247,
-    -247,  -247,  -247,   178,  -247,   184,  -247,   103,   103,  -247,
-     -40,  -247,  -247,  -247,    79,  -247,  -247,  -247,  -247,  -247,
-    -247,  -247,  -247,  -247,  -247,  -247,   -55,   214,  -247,  -247,
-    -247,    48,  -247,  -247,  -247,  -247,  -247,  -247,  -247,  -247,
-    -143,    51,    43,  -247,  -247,  -247,  -247,  -247,  -247,    88,
-    -247,  -247,    -1,  -247,  -247,  -247,  -247,  -247,  -247,  -247,
-    -247,  -247,    49,  -247,   465,  -247,  -247,   465,   103,   465,
-     227,   -40,   192,  -247,   198,  -247,  -247,  -247,  -247,  -247,
-    -247,  -247,  -247,  -247,  -247,  -247,  -247,  -247,  -247,  -247,
-    -247,  -247,  -247,  -247,  -247,   -61,  -247,    98,    64,    69,
-    -150,  -247,    62,  -247,    33,  -247,  -247,  -247,  -247,  -247,
-    -247,  -247,  -247,  -247,   206,  -247,  -247,  -247,  -247,  -247,
-    -247,  -247,  -247,  -247,  -247,  -247,  -247,  -247,  -247,  -247,
-    -247,   226,  -247,  -247,   465,   465,  -247,  -247,  -247,  -247,
-    -247,    68,  -247,  -247,  -247,   -58,  -247,  -247,  -247,    81,
-    -247,  -247,  -247,   465,  -247,  -247,    74,    84,    33,    76,
-    -131,  -247,    90,    33,  -247,  -247,  -247,    78,   131,  -247,
-    -247,  -247,  -247,  -247,     6,    91,    82,  -247,   100,  -247,
-      33,  -247,  -247
+      10,  -173,   -31,  -280,  -280,  -280,   -11,  -280,   -89,   -28,
+     301,     3,  -115,  -280,   301,  -280,    82,   -28,  -280,   -98,
+    -280,   -94,   -83,   -75,  -280,   -74,  -280,  -280,   -28,    19,
+     213,   -28,  -280,  -280,   -69,  -280,   -62,  -280,  -280,  -280,
+      35,    15,   101,    45,   -42,  -280,  -280,   -56,    82,   -53,
+    -280,    53,   582,   -49,   -65,    49,  -280,  -280,  -280,   129,
+     202,   -64,  -280,   -28,  -280,   -28,  -280,  -280,  -280,  -280,
+    -280,  -280,  -280,  -280,  -280,  -280,  -280,     0,    61,   -29,
+     -24,  -280,   -22,  -280,  -280,   -76,  -280,  -280,  -280,   102,
+     -49,  -280,    62,  -280,  -280,  -113,  -280,   -18,  -280,  -280,
+    -280,  -280,  -280,  -280,  -280,  -280,  -280,  -280,  -280,  -280,
+     301,  -280,  -280,  -280,  -280,  -280,  -280,     3,  -280,    89,
+     122,  -280,   301,  -280,  -280,  -280,  -280,  -280,  -280,  -280,
+    -280,  -280,   281,   384,  -280,  -280,    -1,  -280,   -74,  -280,
+    -280,   -28,  -280,  -280,  -280,  -280,  -280,  -280,  -280,  -280,
+    -280,   213,  -280,    92,   -28,  -280,  -280,   -13,    -5,  -280,
+    -280,  -280,  -280,  -280,  -280,  -280,  -280,    15,  -280,    91,
+     143,   145,    91,    62,  -280,  -280,  -280,  -280,   -42,  -280,
+     111,   -35,  -280,    82,  -280,  -280,  -280,  -280,  -280,  -280,
+    -280,  -280,  -280,  -280,  -280,  -280,    53,  -280,     0,     6,
+    -280,  -280,  -280,   -38,  -280,  -280,  -280,  -280,  -280,  -280,
+    -280,  -280,   582,  -280,   115,     0,  -280,  -280,  -280,   116,
+     -65,  -280,  -280,  -280,   117,  -280,   -16,  -280,  -280,  -280,
+    -280,  -280,  -280,  -280,  -280,  -280,  -280,  -280,  -280,     8,
+    -112,  -280,  -280,  -280,  -280,  -280,   118,  -280,    17,  -280,
+     -49,  -280,  -280,  -280,  -113,  -280,    26,  -280,  -280,  -280,
+    -280,  -280,    21,    27,  -280,  -280,  -280,  -280,  -280,    28,
+     138,  -280,  -280,   281,  -280,     0,   -38,  -280,  -280,  -280,
+    -280,  -280,  -280,  -280,  -280,  -280,  -280,  -280,  -280,   140,
+    -280,   141,  -280,    91,    91,  -280,    91,  -280,  -280,    38,
+    -280,  -280,  -280,  -280,  -280,  -280,  -280,  -280,  -280,  -280,
+    -280,   -61,   173,  -280,  -280,  -280,   387,  -280,  -280,  -280,
+    -280,  -280,  -280,  -280,  -280,   -87,    12,     5,  -280,  -280,
+    -280,  -280,  -280,  -280,  -280,    54,  -280,  -280,     1,  -280,
+    -280,  -280,  -280,  -280,  -280,  -280,  -280,  -280,    14,  -280,
+     513,  -280,  -280,   513,  -280,   208,   -49,   170,  -280,   172,
+    -280,  -280,  -280,  -280,  -280,  -280,  -280,  -280,  -280,  -280,
+    -280,  -280,  -280,  -280,  -280,  -280,  -280,  -280,  -280,  -280,
+     -57,  -280,    72,    31,    47,  -151,  -280,    30,  -280,     0,
+    -280,  -280,  -280,  -280,  -280,  -280,  -280,  -280,  -280,   186,
+    -280,  -280,  -280,  -280,  -280,  -280,  -280,  -280,  -280,  -280,
+    -280,  -280,  -280,  -280,  -280,  -280,   199,  -280,  -280,   513,
+     513,   513,  -280,  -280,  -280,  -280,    42,  -280,  -280,  -280,
+     -28,  -280,  -280,  -280,    48,  -280,  -280,  -280,  -280,  -280,
+      50,    52,     0,    56,  -192,  -280,    59,     0,  -280,  -280,
+    -280,    51,   139,  -280,  -280,  -280,  -280,  -280,    85,    64,
+      57,  -280,    70,  -280,     0,  -280,  -280
 };
 
-  /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
-     Performed when YYTABLE does not specify something else to do.  Zero
-     means the default is an error.  */
+/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
+   Performed when YYTABLE does not specify something else to do.  Zero
+   means the default is an error.  */
 static const yytype_int16 yydefact[] =
 {
-       0,     0,     0,    25,    60,   253,     0,    73,     0,     0,
-       0,   267,   256,     0,   245,     0,     0,   261,     0,   285,
-       0,     0,     0,   257,     0,   262,    26,     0,     0,     0,
-       0,   286,   254,     0,    24,     0,   263,   268,    23,     0,
-       0,     0,     0,     0,   264,    22,     0,     0,     0,   255,
-       0,     0,     0,     0,     0,    58,    59,   322,     0,     2,
-       0,     7,     0,     8,     0,     9,    10,    13,    11,    12,
-      14,    20,    15,    16,    17,    18,     0,     0,     0,     0,
-     237,     0,   238,    19,     0,     5,    64,    65,    66,    30,
-      31,    29,     0,    27,     0,   211,   212,   213,   214,   217,
-     215,   216,   218,   219,   220,   221,   222,   206,   208,   209,
-     210,   163,   164,   165,   130,   161,     0,   265,   246,   205,
-     105,   106,   107,   108,   112,   109,   110,   111,   113,     0,
-       6,    67,    68,   260,   282,   247,   281,   314,    61,    63,
-     169,   170,   171,   172,   173,   174,   175,   176,   131,   167,
-       0,    62,    72,   312,   248,   249,    69,   297,   298,   299,
-     300,   301,   302,   303,   294,   296,   138,    30,    31,   138,
-     138,    70,   204,   202,   203,   198,   200,     0,     0,   250,
-     100,   104,   101,   227,   228,   229,   230,   231,   232,   233,
-     234,   235,   236,   223,   225,     0,     0,    89,    90,    91,
-       0,    92,    93,    99,    94,    98,    95,    96,    97,    82,
-      84,     0,     0,    88,   276,   308,     0,    71,   307,   309,
-     305,   252,     1,     0,     4,    32,    57,   319,   318,   239,
-     240,   241,   242,   293,   292,   291,     0,     0,    81,    77,
-      78,    79,    80,     0,    74,     0,   197,   196,   192,   194,
-       0,    28,   207,   160,   162,   266,   102,     0,   188,   189,
-     190,   191,   187,     0,     0,   185,   186,   177,   179,     0,
-       0,   243,   259,   258,   244,   280,   313,   166,   168,   311,
-     272,   271,   269,     0,   295,     0,   140,   138,   138,   140,
-       0,   140,   199,   201,     0,   103,   224,   226,   320,   317,
-     315,   316,    87,    83,    85,    86,   251,     0,   306,   304,
-       3,    21,   287,   288,   289,   284,   290,   283,   326,   327,
-       0,     0,     0,    76,    75,   193,   195,   122,   121,     0,
-     119,   120,     0,   114,   117,   118,   183,   184,   182,   178,
-     180,   181,     0,   139,   134,   140,   140,   137,   138,   132,
-     275,     0,     0,   277,     0,    38,    39,    40,    56,    49,
-      51,    50,    53,    41,    42,    43,    44,    52,    54,    45,
-      46,    33,    34,    37,    35,     0,    36,     0,     0,     0,
-       0,   329,     0,   324,     0,   115,   129,   125,   127,   123,
-     124,   126,   128,   116,     0,   143,   144,   145,   146,   147,
-     148,   149,   151,   152,   150,   153,   154,   155,   156,   157,
-     158,     0,   159,   141,   135,   136,   140,   274,   273,   279,
-     278,     0,    47,    48,    55,     0,   323,   321,   328,     0,
-     325,   270,   142,   133,   310,   332,     0,     0,     0,     0,
-       0,   334,     0,     0,   330,   333,   331,     0,     0,   339,
-     340,   341,   342,   343,     0,     0,     0,   335,     0,   337,
-       0,   336,   338
+       0,     0,     0,    25,    60,   256,     0,    73,     0,     0,
+       0,     0,   270,   259,     0,   248,     0,     0,   264,     0,
+     288,     0,     0,     0,   260,     0,   265,    26,     0,     0,
+       0,     0,   289,   257,     0,    24,     0,   266,   271,    23,
+       0,     0,     0,     0,     0,   267,    22,     0,     0,     0,
+     258,     0,     0,     0,     0,     0,    58,    59,   325,     0,
+       2,     0,     7,     0,     8,     0,     9,    10,    13,    11,
+      12,    14,    20,    15,    16,    17,    18,     0,     0,     0,
+       0,   240,     0,   241,    19,     0,     5,    64,    65,    66,
+       0,    29,   139,    30,    31,     0,    27,     0,   214,   215,
+     216,   217,   220,   218,   219,   221,   222,   223,   224,   225,
+     209,   211,   212,   213,   166,   167,   168,   130,   164,     0,
+     268,   249,   208,   105,   106,   107,   108,   112,   109,   110,
+     111,   113,     0,     6,    67,    68,   263,   285,   250,   284,
+     317,    61,    63,   172,   173,   174,   175,   176,   177,   178,
+     179,   131,   170,     0,    62,    72,   315,   251,   252,    69,
+     300,   301,   302,   303,   304,   305,   306,   297,   299,   141,
+      30,    31,   141,   139,    70,   207,   205,   206,   201,   203,
+       0,     0,   253,   100,   104,   101,   230,   231,   232,   233,
+     234,   235,   236,   237,   238,   239,   226,   228,     0,     0,
+      89,    90,    91,     0,    92,    93,    99,    94,    98,    95,
+      96,    97,    82,    84,     0,     0,    88,   279,   311,     0,
+      71,   310,   312,   308,   255,     1,     0,     4,    32,    57,
+     322,   321,   242,   243,   244,   245,   296,   295,   294,     0,
+       0,    81,    77,    78,    79,    80,     0,    74,     0,   138,
+       0,   137,   200,   199,   195,   197,     0,    28,   210,   163,
+     165,   269,   102,     0,   191,   192,   193,   194,   190,     0,
+       0,   188,   189,   180,   182,     0,     0,   246,   262,   261,
+     247,   283,   316,   169,   171,   314,   275,   274,   272,     0,
+     298,     0,   143,   141,   141,   143,   141,   202,   204,     0,
+     103,   227,   229,   323,   320,   318,   319,    87,    83,    85,
+      86,   254,     0,   309,   307,     3,    21,   290,   291,   292,
+     287,   293,   286,   329,   330,     0,     0,     0,    76,    75,
+     140,   196,   198,   122,   121,     0,   119,   120,     0,   114,
+     117,   118,   186,   187,   185,   181,   183,   184,     0,   142,
+     133,   143,   143,   136,   143,   278,     0,     0,   280,     0,
+      38,    39,    40,    56,    49,    51,    50,    53,    41,    42,
+      43,    44,    52,    54,    45,    46,    33,    34,    37,    35,
+       0,    36,     0,     0,     0,     0,   332,     0,   327,     0,
+     115,   129,   125,   127,   123,   124,   126,   128,   116,     0,
+     146,   147,   148,   149,   150,   151,   152,   154,   155,   153,
+     156,   157,   158,   159,   160,   161,     0,   162,   144,   134,
+     135,   132,   277,   276,   282,   281,     0,    47,    48,    55,
+       0,   326,   324,   331,     0,   328,   273,   145,   313,   335,
+       0,     0,     0,     0,     0,   337,     0,     0,   333,   336,
+     334,     0,     0,   342,   343,   344,   345,   346,     0,     0,
+       0,   338,     0,   340,     0,   339,   341
 };
 
-  /* YYPGOTO[NTERM-NUM].  */
+/* YYPGOTO[NTERM-NUM].  */
 static const yytype_int16 yypgoto[] =
 {
-    -247,  -247,  -247,   -48,  -247,  -247,    -8,   -51,  -247,  -247,
-    -247,  -247,  -247,  -247,  -247,  -247,  -247,  -247,  -247,  -247,
-    -247,  -247,  -247,  -247,  -247,  -247,    96,  -247,  -247,  -247,
-    -247,   -42,  -247,  -247,  -247,  -247,  -247,  -247,  -108,  -246,
-    -247,  -247,   194,  -247,  -247,   163,  -247,  -247,  -247,    50,
-    -247,  -247,  -247,  -247,    71,  -247,  -247,  -247,   140,  -247,
-    -247,   303,   -87,  -247,  -247,  -247,  -247,   127,  -247,  -247,
-    -247,  -247,  -247,  -247,  -247,  -247,  -247,  -247,  -247,  -247,
-    -247,  -247,  -247,  -247,   186,  -247,  -247,  -247,  -247,  -247,
-    -247,   159,  -247,  -247,   107,  -247,  -247,   296,    60,  -193,
-    -247,  -247,  -247,  -247,    11,  -247,  -247,   -53,  -247,  -247,
-    -247,  -106,  -247,  -122,  -247
+    -280,  -280,  -280,   -36,  -280,  -280,    -9,    -7,  -280,  -280,
+    -280,  -280,  -280,  -280,  -280,  -280,  -280,  -280,  -280,  -280,
+    -280,  -280,  -280,  -280,  -280,  -280,    69,  -280,  -280,  -280,
+    -280,   -45,  -280,  -280,  -280,  -280,  -280,  -280,   114,  -157,
+    -279,  -280,  -280,   171,  -280,  -280,   142,  -280,  -280,  -280,
+      16,  -280,  -280,  -280,  -280,    68,  -280,  -280,  -280,   123,
+    -280,  -280,   278,   -71,  -280,  -280,  -280,  -280,   106,  -280,
+    -280,  -280,  -280,  -280,  -280,  -280,  -280,  -280,  -280,  -280,
+    -280,  -280,  -280,  -280,  -280,   166,  -280,  -280,  -280,  -280,
+    -280,  -280,   144,  -280,  -280,    87,  -280,  -280,   274,    37,
+    -196,  -280,  -280,  -280,  -280,   -10,  -280,  -280,   -59,  -280,
+    -280,  -280,  -128,  -280,  -135,  -280
 };
 
-  /* YYDEFGOTO[NTERM-NUM].  */
+/* YYDEFGOTO[NTERM-NUM].  */
 static const yytype_int16 yydefgoto[] =
 {
-       0,    58,    59,    60,    61,    62,   137,    93,    94,   311,
-     371,   372,   373,   374,   375,   376,   377,    63,    64,    65,
-      66,    88,   244,   245,    67,   209,   210,   211,   212,    68,
-     180,   128,   256,   333,   334,   335,   393,    69,   286,   344,
-     413,   114,   115,   116,   148,   149,   150,    70,   267,   268,
-     269,   270,    71,   248,   249,   250,    72,   175,   176,   177,
-      73,   107,   108,   109,   110,    74,   193,   194,   195,    75,
-      76,    77,   274,    78,    79,   118,   155,   282,   283,   179,
-     418,   306,   353,   135,   136,    80,    81,   317,   236,    82,
-     164,   165,   221,   217,   218,   219,   154,   138,   302,   229,
-     213,    83,    84,   320,   321,   322,   380,   381,   437,   382,
-     440,   441,   454,   455,   456
+       0,    59,    60,    61,    62,    63,   140,    96,    97,   316,
+     376,   377,   378,   379,   380,   381,   382,    64,    65,    66,
+      67,    89,   247,   248,    68,   212,   213,   214,   215,    69,
+     183,   131,   262,   339,   340,   341,   398,    70,   251,   292,
+     350,   418,   117,   118,   119,   151,   152,   153,    71,   273,
+     274,   275,   276,    72,   254,   255,   256,    73,   178,   179,
+     180,    74,   110,   111,   112,   113,    75,   196,   197,   198,
+      76,    77,    78,   280,    79,    80,   121,   158,   288,   289,
+     182,   423,   311,   358,   138,   139,    81,    82,   322,   239,
+      83,   167,   168,   224,   220,   221,   222,   157,   141,   307,
+     232,   216,    84,    85,   325,   326,   327,   385,   386,   441,
+     387,   444,   445,   458,   459,   460
 };
 
-  /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
-     positive, shift that token.  If negative, reduce the rule whose
-     number is the opposite.  If YYTABLE_NINF, syntax error.  */
+/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
+   positive, shift that token.  If negative, reduce the rule whose
+   number is the opposite.  If YYTABLE_NINF, syntax error.  */
 static const yytype_int16 yytable[] =
 {
-      92,   214,   297,   386,   215,   181,     1,   422,   129,   312,
-     378,   223,   272,   172,   351,     2,    89,   378,    90,   305,
-     252,     3,     4,     5,   299,   246,    85,   233,   387,   327,
-       6,     7,   252,   170,   157,   158,     8,   328,     9,    10,
-     111,   329,    11,   347,    12,   349,    13,    14,   300,    86,
-     234,    15,   273,   280,   225,   159,   226,   355,   238,   247,
-      16,   289,   291,   318,   319,    17,    87,   356,   173,   227,
-     427,   166,    18,   285,    19,   235,   340,   313,   439,   314,
-     117,   330,   271,   239,    20,    21,   240,    22,    23,   444,
-     352,   281,    24,    25,   290,   130,    26,    27,   160,   414,
-     415,   228,   318,   319,   131,    28,   132,   357,   358,   133,
-     139,   134,   388,   156,   331,   167,    91,   168,   152,    29,
-     389,    30,    31,   171,   153,   178,   359,    32,   161,   423,
-     276,   174,   120,   182,    91,   112,   121,    33,   295,   390,
-     220,   113,    34,   276,    35,   222,    36,   360,    37,    38,
-     224,   230,   231,   216,   254,   255,   361,   232,   362,    39,
-      40,    41,    42,    43,    44,    45,   301,   237,    46,   251,
-     433,    47,   278,    48,   363,   285,   241,   242,   315,   345,
-     346,   279,    49,   243,   287,   332,   288,   294,    50,    51,
-      52,   430,    53,    54,   293,   364,   365,   391,   122,    55,
-      56,   392,   162,   316,   298,   169,     2,   304,   163,    -6,
-      57,   307,     3,     4,     5,    91,   449,   450,   451,   452,
-     453,     6,     7,   309,   310,   323,   457,     8,   324,     9,
-      10,   326,   336,    11,   366,    12,   367,    13,    14,   348,
-     416,   337,    15,   338,   368,   442,   342,   123,   369,   370,
-     447,    16,   343,   350,   354,   383,    17,   417,   124,   384,
-     420,   125,   385,    18,   394,    19,   421,   462,   140,   141,
-     142,   143,   424,   426,   431,    20,    21,   183,    22,    23,
-     425,   429,   432,    24,    25,   126,   434,    26,    27,   436,
-     438,   127,   443,   439,   446,   459,    28,   448,   460,   144,
-     419,   145,    95,   146,   461,   303,   184,    96,   253,   147,
-      29,   277,    30,    31,    97,   292,   119,   339,    32,   325,
-     296,   275,   257,   284,   308,   185,   151,   428,    33,   186,
-     341,   379,   458,    34,   445,    35,     0,    36,     0,    37,
-      38,   449,   450,   451,   452,   453,     0,     0,     0,     0,
-      39,    40,    41,    42,    43,    44,    45,     0,     0,    46,
-       0,     0,    47,     0,    48,     0,     0,   258,   259,   260,
-     261,    98,     0,    49,     0,     0,     0,     0,     0,    50,
-      51,    52,     0,    53,    54,     0,     0,     2,     0,     0,
-      55,    56,     0,     3,     4,     5,     0,     0,     0,     0,
-      -6,    57,     6,     7,     0,    99,   100,   187,     8,     0,
-       9,    10,     0,     0,    11,     0,    12,   435,    13,    14,
-       0,     0,     0,    15,   101,     0,   262,     0,     0,   102,
-       0,     0,    16,     0,     0,     0,     0,    17,     0,     0,
-     188,   189,   190,   191,    18,     0,    19,     0,   192,     0,
-       0,     0,     0,     0,     0,     0,    20,    21,     0,    22,
-      23,   103,     0,     0,    24,    25,     0,     0,    26,    27,
-       0,     0,   263,     0,     0,     0,     0,    28,     0,     0,
-       0,     0,     0,     0,     0,   104,   105,   106,     0,     0,
-       0,    29,   264,    30,    31,     0,     0,   265,   266,    32,
-       0,     0,     0,     0,     0,     0,     0,     0,   395,    33,
-       0,     0,     0,     0,    34,     0,    35,   396,    36,     0,
-      37,    38,     0,     0,     0,     0,   397,     0,     0,     0,
-       0,    39,    40,    41,    42,    43,    44,    45,     0,     0,
-      46,     0,     0,    47,     0,    48,   398,     0,     0,   399,
-       0,     0,     0,     0,    49,   400,     0,     0,     0,     0,
-      50,    51,    52,     0,    53,    54,   196,     0,   197,   198,
-       0,    55,    56,     0,     0,   199,     0,     0,   200,     0,
-     401,     0,    57,     0,   402,   403,     0,     0,   404,   405,
-     406,     0,   407,   408,   409,     0,   410,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,   201,     0,     0,
+      95,    92,   302,   184,   218,   391,   175,   304,   132,   356,
+     383,     1,   427,   317,   114,   295,   353,   236,   443,   310,
+       2,   278,   160,   161,   226,   286,     3,     4,     5,   448,
+     392,   305,    86,   173,   252,     6,     7,   230,    87,   258,
+     237,     8,     9,   162,    10,    11,   217,    93,    12,    94,
+      13,   258,    14,    15,   228,   333,   229,    16,    88,   186,
+     120,   176,   279,   334,   287,   238,    17,   335,   253,   231,
+     432,    18,   419,   420,   383,   421,    90,   133,    19,   346,
+      20,   134,   318,   249,   319,   357,    91,   163,   142,   187,
+      21,    22,   135,    23,    24,   323,   324,   277,    25,    26,
+     136,   137,    27,    28,   159,   123,   155,   336,   188,   124,
+     115,    29,   189,   156,   174,   393,   116,   164,   223,   181,
+     323,   324,   185,   394,   177,    30,    91,    31,    32,   225,
+     233,   169,   282,    33,   428,   241,   351,   352,   300,   354,
+     337,   227,   395,    34,   240,   282,   234,    91,    35,   306,
+      36,   235,    37,   219,    38,    39,   250,   257,   260,   261,
+     242,   284,   285,   243,   291,    40,    41,    42,    43,    44,
+      45,    46,   125,   293,    47,   294,   170,    48,   171,    49,
+     298,   303,   299,   320,   309,   312,   314,   328,    50,   315,
+     190,   165,   329,   435,    51,    52,    53,   166,    54,    55,
+     396,   332,   342,   343,   397,    56,    57,   344,   321,   348,
+     349,   338,     2,   355,   359,    -6,    58,   388,     3,     4,
+       5,   126,   389,   191,   192,   193,   194,     6,     7,   390,
+     399,   195,   127,     8,     9,   128,    10,    11,   422,   425,
+      12,   426,    13,   330,    14,    15,   446,   429,   430,    16,
+     434,   451,   431,   244,   245,   436,   437,   440,    17,   129,
+     246,   438,   443,    18,   450,   130,   172,   442,   466,   463,
+      19,   452,    20,   447,   464,   465,    91,   143,   144,   145,
+     146,   308,    21,    22,   263,    23,    24,   296,   259,   345,
+      25,    26,   122,   283,    27,    28,   453,   454,   455,   456,
+     457,   297,   301,    29,   281,   154,   461,   313,   147,    98,
+     148,   290,   149,   347,    99,   384,   449,    30,   150,    31,
+      32,   100,   331,   462,     0,    33,   433,     0,     0,     0,
+     264,   265,   266,   267,     0,    34,     0,     0,     0,     0,
+      35,     0,    36,     0,    37,     0,    38,    39,     0,   424,
+     453,   454,   455,   456,   457,     0,     0,    40,    41,    42,
+      43,    44,    45,    46,     0,     0,    47,     0,     0,    48,
+       0,    49,     0,     0,     0,     0,     0,     0,     0,   101,
+      50,     0,     0,     0,     0,     0,    51,    52,    53,   268,
+      54,    55,     0,     0,     2,     0,   360,    56,    57,     0,
+       3,     4,     5,     0,     0,     0,   361,    -6,    58,     6,
+       7,     0,     0,   102,   103,     8,     9,     0,    10,    11,
+       0,   439,    12,     0,    13,     0,    14,    15,     0,     0,
+       0,    16,   104,     0,     0,   269,     0,   105,     0,     0,
+      17,     0,     0,     0,     0,    18,     0,   362,   363,     0,
+       0,     0,    19,     0,    20,   270,     0,     0,     0,     0,
+     271,   272,     0,     0,    21,    22,   364,    23,    24,   106,
+       0,     0,    25,    26,     0,     0,    27,    28,     0,     0,
+       0,     0,     0,     0,     0,    29,     0,   365,     0,     0,
+       0,     0,     0,   107,   108,   109,   366,     0,   367,    30,
+       0,    31,    32,     0,     0,     0,     0,    33,     0,     0,
+       0,     0,     0,     0,   368,     0,     0,    34,     0,     0,
+       0,     0,    35,     0,    36,     0,    37,     0,    38,    39,
+       0,     0,     0,     0,     0,   369,   370,     0,     0,    40,
+      41,    42,    43,    44,    45,    46,     0,     0,    47,     0,
+       0,    48,     0,    49,     0,     0,     0,   400,     0,     0,
+       0,     0,    50,     0,     0,     0,   401,     0,    51,    52,
+      53,     0,    54,    55,   371,   402,   372,     0,     0,    56,
+      57,     0,     0,     0,   373,     0,     0,     0,   374,   375,
+      58,     0,     0,     0,   199,   403,   200,   201,   404,     0,
+       0,     0,     0,   202,   405,     0,   203,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,   406,
+       0,     0,     0,   407,   408,     0,   204,   409,   410,   411,
+       0,   412,   413,   414,     0,   415,     0,     0,     0,     0,
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,   411,     0,     0,     0,
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,   202,
-       0,   203,     0,     0,     0,     0,     0,   204,     0,   205,
-       0,   412,     0,   206,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,   416,     0,     0,   205,     0,
+     206,     0,     0,     0,     0,     0,   207,     0,   208,     0,
+       0,     0,   209,     0,     0,     0,     0,     0,     0,     0,
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,   207,   208
+     417,     0,     0,     0,     0,     0,   210,   211
 };
 
 static const yytype_int16 yycheck[] =
 {
-       8,    52,   195,     4,    68,    47,     1,    68,    16,     5,
-     160,    59,    22,    47,    69,    10,    74,   160,    76,   212,
-     107,    16,    17,    18,    44,   146,   204,    38,    29,    33,
-      25,    26,   119,    41,     7,     8,    31,    41,    33,    34,
-      11,    45,    37,   289,    39,   291,    41,    42,    68,    68,
-      61,    46,    62,    30,    62,    28,    64,     9,    32,   180,
-      55,   169,   170,   206,   207,    60,    68,    19,   102,    36,
-     220,    30,    67,    72,    69,    86,   269,    73,   209,    75,
-     174,    85,   130,    57,    79,    80,    60,    82,    83,   220,
-     145,    68,    87,    88,    93,   174,    91,    92,    71,   345,
-     346,    68,   206,   207,   174,   100,   174,    59,    60,   174,
-      68,   174,   113,    68,   118,    74,   174,    76,   174,   114,
-     121,   116,   117,    68,   174,   174,    78,   122,   101,   190,
-     138,   165,    23,   174,   174,   106,    27,   132,   180,   140,
-      68,   112,   137,   151,   139,     0,   141,    99,   143,   144,
-     204,    68,   174,   217,    68,    36,   108,   174,   110,   154,
-     155,   156,   157,   158,   159,   160,   186,   219,   163,   174,
-     416,   166,    68,   168,   126,    72,   150,   151,   174,   287,
-     288,   174,   177,   157,    30,   189,    30,   216,   183,   184,
-     185,   384,   187,   188,    68,   147,   148,   198,    89,   194,
-     195,   202,   175,   199,   174,   164,    10,    68,   181,   204,
-     205,    68,    16,    17,    18,   174,   210,   211,   212,   213,
-     214,    25,    26,    68,   204,    68,   220,    31,   174,    33,
-      34,   174,   174,    37,   186,    39,   188,    41,    42,   290,
-     348,   174,    46,    68,   196,   438,    68,   138,   200,   201,
-     443,    55,    68,   174,    40,   204,    60,    30,   149,   216,
-      68,   152,   174,    67,   215,    69,    68,   460,    63,    64,
-      65,    66,   174,   204,    68,    79,    80,     6,    82,    83,
-     216,   219,    56,    87,    88,   176,   218,    91,    92,   208,
-     216,   182,   216,   209,   204,   204,   100,   219,   216,    94,
-     351,    96,     8,    98,   204,   209,    35,    13,   114,   104,
-     114,   148,   116,   117,    20,   175,    13,   267,   122,   248,
-     193,   135,     3,   164,   217,    54,    30,   380,   132,    58,
-     270,   320,   454,   137,   440,   139,    -1,   141,    -1,   143,
-     144,   210,   211,   212,   213,   214,    -1,    -1,    -1,    -1,
-     154,   155,   156,   157,   158,   159,   160,    -1,    -1,   163,
-      -1,    -1,   166,    -1,   168,    -1,    -1,    48,    49,    50,
-      51,    77,    -1,   177,    -1,    -1,    -1,    -1,    -1,   183,
-     184,   185,    -1,   187,   188,    -1,    -1,    10,    -1,    -1,
-     194,   195,    -1,    16,    17,    18,    -1,    -1,    -1,    -1,
-     204,   205,    25,    26,    -1,   111,   112,   136,    31,    -1,
-      33,    34,    -1,    -1,    37,    -1,    39,   425,    41,    42,
-      -1,    -1,    -1,    46,   130,    -1,   107,    -1,    -1,   135,
-      -1,    -1,    55,    -1,    -1,    -1,    -1,    60,    -1,    -1,
-     169,   170,   171,   172,    67,    -1,    69,    -1,   177,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    79,    80,    -1,    82,
-      83,   167,    -1,    -1,    87,    88,    -1,    -1,    91,    92,
-      -1,    -1,   153,    -1,    -1,    -1,    -1,   100,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,   191,   192,   193,    -1,    -1,
-      -1,   114,   173,   116,   117,    -1,    -1,   178,   179,   122,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    43,   132,
-      -1,    -1,    -1,    -1,   137,    -1,   139,    52,   141,    -1,
-     143,   144,    -1,    -1,    -1,    -1,    61,    -1,    -1,    -1,
-      -1,   154,   155,   156,   157,   158,   159,   160,    -1,    -1,
-     163,    -1,    -1,   166,    -1,   168,    81,    -1,    -1,    84,
-      -1,    -1,    -1,    -1,   177,    90,    -1,    -1,    -1,    -1,
-     183,   184,   185,    -1,   187,   188,    12,    -1,    14,    15,
-      -1,   194,   195,    -1,    -1,    21,    -1,    -1,    24,    -1,
-     115,    -1,   205,    -1,   119,   120,    -1,    -1,   123,   124,
-     125,    -1,   127,   128,   129,    -1,   131,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    53,    -1,    -1,
+       9,     8,   198,    48,    69,     4,    48,    45,    17,    70,
+     161,     1,    69,     5,    11,   172,   295,    39,   210,   215,
+      10,    22,     7,     8,    60,    30,    16,    17,    18,   221,
+      29,    69,   205,    42,   147,    25,    26,    37,    69,   110,
+      62,    31,    32,    28,    34,    35,    53,    75,    38,    77,
+      40,   122,    42,    43,    63,    34,    65,    47,    69,     6,
+     175,   103,    63,    42,    69,    87,    56,    46,   181,    69,
+     221,    61,   351,   352,   161,   354,   165,   175,    68,   275,
+      70,   175,    74,    90,    76,   146,   175,    72,    69,    36,
+      80,    81,   175,    83,    84,   207,   208,   133,    88,    89,
+     175,   175,    92,    93,    69,    23,   175,    86,    55,    27,
+     107,   101,    59,   175,    69,   114,   113,   102,    69,   175,
+     207,   208,   175,   122,   166,   115,   175,   117,   118,     0,
+      69,    30,   141,   123,   191,    33,   293,   294,   183,   296,
+     119,   205,   141,   133,   220,   154,   175,   175,   138,   187,
+     140,   175,   142,   218,   144,   145,    94,   175,    69,    37,
+      58,    69,   175,    61,    73,   155,   156,   157,   158,   159,
+     160,   161,    90,    30,   164,    30,    75,   167,    77,   169,
+      69,   175,   217,   175,    69,    69,    69,    69,   178,   205,
+     137,   176,   175,   389,   184,   185,   186,   182,   188,   189,
+     199,   175,   175,   175,   203,   195,   196,    69,   200,    69,
+      69,   190,    10,   175,    41,   205,   206,   205,    16,    17,
+      18,   139,   217,   170,   171,   172,   173,    25,    26,   175,
+     216,   178,   150,    31,    32,   153,    34,    35,    30,    69,
+      38,    69,    40,   250,    42,    43,   442,   175,   217,    47,
+     220,   447,   205,   151,   152,    69,    57,   209,    56,   177,
+     158,   219,   210,    61,   205,   183,   165,   217,   464,   205,
+      68,   220,    70,   217,   217,   205,   175,    64,    65,    66,
+      67,   212,    80,    81,     3,    83,    84,   173,   117,   273,
+      88,    89,    14,   151,    92,    93,   211,   212,   213,   214,
+     215,   178,   196,   101,   138,    31,   221,   220,    95,     8,
+      97,   167,    99,   276,    13,   325,   444,   115,   105,   117,
+     118,    20,   254,   458,    -1,   123,   385,    -1,    -1,    -1,
+      49,    50,    51,    52,    -1,   133,    -1,    -1,    -1,    -1,
+     138,    -1,   140,    -1,   142,    -1,   144,   145,    -1,   356,
+     211,   212,   213,   214,   215,    -1,    -1,   155,   156,   157,
+     158,   159,   160,   161,    -1,    -1,   164,    -1,    -1,   167,
+      -1,   169,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    78,
+     178,    -1,    -1,    -1,    -1,    -1,   184,   185,   186,   108,
+     188,   189,    -1,    -1,    10,    -1,     9,   195,   196,    -1,
+      16,    17,    18,    -1,    -1,    -1,    19,   205,   206,    25,
+      26,    -1,    -1,   112,   113,    31,    32,    -1,    34,    35,
+      -1,   430,    38,    -1,    40,    -1,    42,    43,    -1,    -1,
+      -1,    47,   131,    -1,    -1,   154,    -1,   136,    -1,    -1,
+      56,    -1,    -1,    -1,    -1,    61,    -1,    60,    61,    -1,
+      -1,    -1,    68,    -1,    70,   174,    -1,    -1,    -1,    -1,
+     179,   180,    -1,    -1,    80,    81,    79,    83,    84,   168,
+      -1,    -1,    88,    89,    -1,    -1,    92,    93,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,   101,    -1,   100,    -1,    -1,
+      -1,    -1,    -1,   192,   193,   194,   109,    -1,   111,   115,
+      -1,   117,   118,    -1,    -1,    -1,    -1,   123,    -1,    -1,
+      -1,    -1,    -1,    -1,   127,    -1,    -1,   133,    -1,    -1,
+      -1,    -1,   138,    -1,   140,    -1,   142,    -1,   144,   145,
+      -1,    -1,    -1,    -1,    -1,   148,   149,    -1,    -1,   155,
+     156,   157,   158,   159,   160,   161,    -1,    -1,   164,    -1,
+      -1,   167,    -1,   169,    -1,    -1,    -1,    44,    -1,    -1,
+      -1,    -1,   178,    -1,    -1,    -1,    53,    -1,   184,   185,
+     186,    -1,   188,   189,   187,    62,   189,    -1,    -1,   195,
+     196,    -1,    -1,    -1,   197,    -1,    -1,    -1,   201,   202,
+     206,    -1,    -1,    -1,    12,    82,    14,    15,    85,    -1,
+      -1,    -1,    -1,    21,    91,    -1,    24,    -1,    -1,    -1,
       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,   161,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   116,
+      -1,    -1,    -1,   120,   121,    -1,    54,   124,   125,   126,
+      -1,   128,   129,   130,    -1,   132,    -1,    -1,    -1,    -1,
       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    95,
-      -1,    97,    -1,    -1,    -1,    -1,    -1,   103,    -1,   105,
-      -1,   196,    -1,   109,    -1,    -1,    -1,    -1,    -1,    -1,
       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,   133,   134
+      -1,    -1,    -1,    -1,    -1,   162,    -1,    -1,    96,    -1,
+      98,    -1,    -1,    -1,    -1,    -1,   104,    -1,   106,    -1,
+      -1,    -1,   110,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+     197,    -1,    -1,    -1,    -1,    -1,   134,   135
 };
 
-  /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
-     symbol of state STATE-NUM.  */
+/* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
+   state STATE-NUM.  */
 static const yytype_int16 yystos[] =
 {
-       0,     1,    10,    16,    17,    18,    25,    26,    31,    33,
-      34,    37,    39,    41,    42,    46,    55,    60,    67,    69,
-      79,    80,    82,    83,    87,    88,    91,    92,   100,   114,
-     116,   117,   122,   132,   137,   139,   141,   143,   144,   154,
-     155,   156,   157,   158,   159,   160,   163,   166,   168,   177,
-     183,   184,   185,   187,   188,   194,   195,   205,   222,   223,
-     224,   225,   226,   238,   239,   240,   241,   245,   250,   258,
-     268,   273,   277,   281,   286,   290,   291,   292,   294,   295,
-     306,   307,   310,   322,   323,   204,    68,    68,   242,    74,
-      76,   174,   227,   228,   229,     8,    13,    20,    77,   111,
-     112,   130,   135,   167,   191,   192,   193,   282,   283,   284,
-     285,    11,   106,   112,   262,   263,   264,   174,   296,   282,
-      23,    27,    89,   138,   149,   152,   176,   182,   252,   227,
-     174,   174,   174,   174,   174,   304,   305,   227,   318,    68,
-      63,    64,    65,    66,    94,    96,    98,   104,   265,   266,
-     267,   318,   174,   174,   317,   297,    68,     7,     8,    28,
-      71,   101,   175,   181,   311,   312,    30,    74,    76,   164,
-     227,    68,    47,   102,   165,   278,   279,   280,   174,   300,
-     251,   252,   174,     6,    35,    54,    58,   136,   169,   170,
-     171,   172,   177,   287,   288,   289,    12,    14,    15,    21,
-      24,    53,    95,    97,   103,   105,   109,   133,   134,   246,
-     247,   248,   249,   321,   228,    68,   217,   314,   315,   316,
-      68,   313,     0,   224,   204,   227,   227,    36,    68,   320,
-      68,   174,   174,    38,    61,    86,   309,   219,    32,    57,
-      60,   150,   151,   157,   243,   244,   146,   180,   274,   275,
-     276,   174,   283,   263,    68,    36,   253,     3,    48,    49,
-      50,    51,   107,   153,   173,   178,   179,   269,   270,   271,
-     272,   224,    22,    62,   293,   305,   227,   266,    68,   174,
-      30,    68,   298,   299,   312,    72,   259,    30,    30,   259,
-      93,   259,   279,    68,   216,   252,   288,   320,   174,    44,
-      68,   186,   319,   247,    68,   320,   302,    68,   315,    68,
-     204,   230,     5,    73,    75,   174,   199,   308,   206,   207,
-     324,   325,   326,    68,   174,   275,   174,    33,    41,    45,
-      85,   118,   189,   254,   255,   256,   174,   174,    68,   270,
-     320,   319,    68,    68,   260,   259,   259,   260,   228,   260,
-     174,    69,   145,   303,    40,     9,    19,    59,    60,    78,
-      99,   108,   110,   126,   147,   148,   186,   188,   196,   200,
-     201,   231,   232,   233,   234,   235,   236,   237,   160,   325,
-     327,   328,   330,   204,   216,   174,     4,    29,   113,   121,
-     140,   198,   202,   257,   215,    43,    52,    61,    81,    84,
-      90,   115,   119,   120,   123,   124,   125,   127,   128,   129,
-     131,   161,   196,   261,   260,   260,   259,    30,   301,   228,
-      68,    68,    68,   190,   174,   216,   204,   220,   328,   219,
-     320,    68,    56,   260,   218,   227,   208,   329,   216,   209,
-     331,   332,   320,   216,   220,   332,   204,   320,   219,   210,
-     211,   212,   213,   214,   333,   334,   335,   220,   334,   204,
-     216,   204,   320
+       0,     1,    10,    16,    17,    18,    25,    26,    31,    32,
+      34,    35,    38,    40,    42,    43,    47,    56,    61,    68,
+      70,    80,    81,    83,    84,    88,    89,    92,    93,   101,
+     115,   117,   118,   123,   133,   138,   140,   142,   144,   145,
+     155,   156,   157,   158,   159,   160,   161,   164,   167,   169,
+     178,   184,   185,   186,   188,   189,   195,   196,   206,   223,
+     224,   225,   226,   227,   239,   240,   241,   242,   246,   251,
+     259,   270,   275,   279,   283,   288,   292,   293,   294,   296,
+     297,   308,   309,   312,   324,   325,   205,    69,    69,   243,
+     165,   175,   229,    75,    77,   228,   229,   230,     8,    13,
+      20,    78,   112,   113,   131,   136,   168,   192,   193,   194,
+     284,   285,   286,   287,    11,   107,   113,   264,   265,   266,
+     175,   298,   284,    23,    27,    90,   139,   150,   153,   177,
+     183,   253,   228,   175,   175,   175,   175,   175,   306,   307,
+     228,   320,    69,    64,    65,    66,    67,    95,    97,    99,
+     105,   267,   268,   269,   320,   175,   175,   319,   299,    69,
+       7,     8,    28,    72,   102,   176,   182,   313,   314,    30,
+      75,    77,   165,   228,    69,    48,   103,   166,   280,   281,
+     282,   175,   302,   252,   253,   175,     6,    36,    55,    59,
+     137,   170,   171,   172,   173,   178,   289,   290,   291,    12,
+      14,    15,    21,    24,    54,    96,    98,   104,   106,   110,
+     134,   135,   247,   248,   249,   250,   323,   229,    69,   218,
+     316,   317,   318,    69,   315,     0,   225,   205,   228,   228,
+      37,    69,   322,    69,   175,   175,    39,    62,    87,   311,
+     220,    33,    58,    61,   151,   152,   158,   244,   245,   229,
+      94,   260,   147,   181,   276,   277,   278,   175,   285,   265,
+      69,    37,   254,     3,    49,    50,    51,    52,   108,   154,
+     174,   179,   180,   271,   272,   273,   274,   225,    22,    63,
+     295,   307,   228,   268,    69,   175,    30,    69,   300,   301,
+     314,    73,   261,    30,    30,   261,   260,   281,    69,   217,
+     253,   290,   322,   175,    45,    69,   187,   321,   248,    69,
+     322,   304,    69,   317,    69,   205,   231,     5,    74,    76,
+     175,   200,   310,   207,   208,   326,   327,   328,    69,   175,
+     229,   277,   175,    34,    42,    46,    86,   119,   190,   255,
+     256,   257,   175,   175,    69,   272,   322,   321,    69,    69,
+     262,   261,   261,   262,   261,   175,    70,   146,   305,    41,
+       9,    19,    60,    61,    79,   100,   109,   111,   127,   148,
+     149,   187,   189,   197,   201,   202,   232,   233,   234,   235,
+     236,   237,   238,   161,   327,   329,   330,   332,   205,   217,
+     175,     4,    29,   114,   122,   141,   199,   203,   258,   216,
+      44,    53,    62,    82,    85,    91,   116,   120,   121,   124,
+     125,   126,   128,   129,   130,   132,   162,   197,   263,   262,
+     262,   262,    30,   303,   229,    69,    69,    69,   191,   175,
+     217,   205,   221,   330,   220,   322,    69,    57,   219,   228,
+     209,   331,   217,   210,   333,   334,   322,   217,   221,   334,
+     205,   322,   220,   211,   212,   213,   214,   215,   335,   336,
+     337,   221,   336,   205,   217,   205,   322
 };
 
-  /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
+/* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM.  */
 static const yytype_int16 yyr1[] =
 {
-       0,   221,   222,   223,   223,   223,   224,   224,   224,   224,
-     224,   224,   224,   224,   224,   224,   224,   224,   224,   224,
-     224,   225,   226,   226,   226,   226,   226,   227,   227,   228,
-     229,   229,   230,   230,   231,   231,   231,   232,   233,   233,
-     233,   233,   233,   233,   233,   233,   233,   234,   234,   235,
-     235,   235,   235,   235,   235,   236,   237,   238,   239,   239,
-     240,   240,   240,   240,   241,   241,   241,   241,   241,   241,
-     241,   241,   241,   242,   242,   243,   243,   244,   244,   244,
-     244,   244,   245,   246,   246,   247,   247,   247,   247,   248,
-     248,   248,   248,   248,   248,   248,   248,   248,   249,   249,
-     250,   250,   250,   251,   251,   252,   252,   252,   252,   252,
-     252,   252,   252,   253,   253,   254,   254,   254,   254,   255,
-     255,   256,   256,   257,   257,   257,   257,   257,   257,   257,
-     258,   258,   258,   258,   258,   258,   258,   258,   259,   259,
-     260,   260,   260,   261,   261,   261,   261,   261,   261,   261,
-     261,   261,   261,   261,   261,   261,   261,   261,   261,   261,
-     262,   262,   263,   264,   264,   264,   265,   265,   266,   267,
-     267,   267,   267,   267,   267,   267,   267,   268,   269,   269,
-     270,   270,   270,   270,   270,   271,   271,   271,   272,   272,
-     272,   272,   273,   274,   274,   275,   276,   276,   277,   278,
-     278,   279,   280,   280,   280,   281,   281,   282,   282,   283,
-     283,   284,   284,   284,   284,   284,   284,   285,   285,   285,
-     285,   285,   285,   286,   287,   287,   288,   289,   289,   289,
-     289,   289,   289,   289,   289,   289,   289,   290,   290,   290,
-     290,   290,   290,   290,   290,   290,   290,   290,   290,   290,
-     290,   290,   290,   291,   291,   291,   292,   292,   293,   293,
-     293,   294,   295,   295,   295,   296,   296,   296,   297,   297,
-     298,   299,   299,   300,   301,   301,   302,   302,   303,   303,
-     304,   304,   305,   306,   306,   307,   307,   308,   308,   308,
-     308,   309,   309,   309,   310,   311,   311,   312,   312,   312,
-     312,   312,   312,   312,   313,   313,   314,   314,   315,   315,
-     316,   317,   317,   318,   318,   319,   319,   319,   320,   320,
-     321,   322,   323,   324,   324,   325,   326,   326,   327,   327,
-     328,   329,   330,   331,   331,   332,   333,   333,   334,   335,
-     335,   335,   335,   335
+       0,   222,   223,   224,   224,   224,   225,   225,   225,   225,
+     225,   225,   225,   225,   225,   225,   225,   225,   225,   225,
+     225,   226,   227,   227,   227,   227,   227,   228,   228,   229,
+     230,   230,   231,   231,   232,   232,   232,   233,   234,   234,
+     234,   234,   234,   234,   234,   234,   234,   235,   235,   236,
+     236,   236,   236,   236,   236,   237,   238,   239,   240,   240,
+     241,   241,   241,   241,   242,   242,   242,   242,   242,   242,
+     242,   242,   242,   243,   243,   244,   244,   245,   245,   245,
+     245,   245,   246,   247,   247,   248,   248,   248,   248,   249,
+     249,   249,   249,   249,   249,   249,   249,   249,   250,   250,
+     251,   251,   251,   252,   252,   253,   253,   253,   253,   253,
+     253,   253,   253,   254,   254,   255,   255,   255,   255,   256,
+     256,   257,   257,   258,   258,   258,   258,   258,   258,   258,
+     259,   259,   259,   259,   259,   259,   259,   259,   259,   260,
+     260,   261,   261,   262,   262,   262,   263,   263,   263,   263,
+     263,   263,   263,   263,   263,   263,   263,   263,   263,   263,
+     263,   263,   263,   264,   264,   265,   266,   266,   266,   267,
+     267,   268,   269,   269,   269,   269,   269,   269,   269,   269,
+     270,   271,   271,   272,   272,   272,   272,   272,   273,   273,
+     273,   274,   274,   274,   274,   275,   276,   276,   277,   278,
+     278,   279,   280,   280,   281,   282,   282,   282,   283,   283,
+     284,   284,   285,   285,   286,   286,   286,   286,   286,   286,
+     287,   287,   287,   287,   287,   287,   288,   289,   289,   290,
+     291,   291,   291,   291,   291,   291,   291,   291,   291,   291,
+     292,   292,   292,   292,   292,   292,   292,   292,   292,   292,
+     292,   292,   292,   292,   292,   292,   293,   293,   293,   294,
+     294,   295,   295,   295,   296,   297,   297,   297,   298,   298,
+     298,   299,   299,   300,   301,   301,   302,   303,   303,   304,
+     304,   305,   305,   306,   306,   307,   308,   308,   309,   309,
+     310,   310,   310,   310,   311,   311,   311,   312,   313,   313,
+     314,   314,   314,   314,   314,   314,   314,   315,   315,   316,
+     316,   317,   317,   318,   319,   319,   320,   320,   321,   321,
+     321,   322,   322,   323,   324,   325,   326,   326,   327,   328,
+     328,   329,   329,   330,   331,   332,   333,   333,   334,   335,
+     335,   336,   337,   337,   337,   337,   337
 };
 
-  /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.  */
+/* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM.  */
 static const yytype_int8 yyr2[] =
 {
        0,     2,     1,     3,     2,     2,     0,     1,     1,     1,
@@ -1932,28 +1920,28 @@ static const yytype_int8 yyr2[] =
        2,     2,     3,     2,     1,     1,     1,     1,     1,     1,
        1,     1,     1,     0,     2,     2,     2,     1,     1,     1,
        1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
-       2,     2,     4,     6,     4,     5,     5,     4,     0,     2,
-       0,     2,     3,     1,     1,     1,     1,     1,     1,     1,
+       2,     2,     5,     4,     5,     5,     4,     3,     3,     0,
+       2,     0,     2,     0,     2,     3,     1,     1,     1,     1,
        1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
-       2,     1,     2,     1,     1,     1,     2,     1,     2,     1,
-       1,     1,     1,     1,     1,     1,     1,     3,     2,     1,
-       2,     2,     2,     2,     2,     1,     1,     1,     1,     1,
-       1,     1,     3,     2,     1,     2,     1,     1,     2,     2,
-       1,     2,     1,     1,     1,     2,     2,     2,     1,     1,
+       1,     1,     1,     2,     1,     2,     1,     1,     1,     2,
+       1,     2,     1,     1,     1,     1,     1,     1,     1,     1,
+       3,     2,     1,     2,     2,     2,     2,     2,     1,     1,
+       1,     1,     1,     1,     1,     3,     2,     1,     2,     1,
+       1,     2,     2,     1,     2,     1,     1,     1,     2,     2,
+       2,     1,     1,     1,     1,     1,     1,     1,     1,     1,
+       1,     1,     1,     1,     1,     1,     2,     2,     1,     2,
        1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
-       1,     1,     1,     2,     2,     1,     2,     1,     1,     1,
-       1,     1,     1,     1,     1,     1,     1,     1,     1,     2,
-       2,     2,     2,     3,     3,     1,     2,     2,     2,     2,
-       2,     3,     2,     1,     1,     1,     1,     1,     1,     1,
-       0,     1,     1,     1,     1,     1,     2,     0,     0,     2,
-       4,     1,     1,     4,     1,     0,     0,     2,     2,     2,
-       2,     1,     1,     3,     3,     1,     1,     1,     1,     1,
-       1,     1,     1,     1,     2,     2,     1,     1,     1,     1,
-       1,     1,     1,     1,     2,     1,     2,     1,     1,     1,
-       5,     2,     1,     2,     1,     1,     1,     1,     1,     1,
-       2,     5,     1,     3,     2,     3,     1,     1,     2,     1,
-       5,     4,     3,     2,     1,     6,     3,     2,     3,     1,
-       1,     1,     1,     1
+       1,     1,     2,     2,     2,     2,     3,     3,     1,     2,
+       2,     2,     2,     2,     3,     2,     1,     1,     1,     1,
+       1,     1,     1,     0,     1,     1,     1,     1,     1,     2,
+       0,     0,     2,     4,     1,     1,     4,     1,     0,     0,
+       2,     2,     2,     2,     1,     1,     3,     3,     1,     1,
+       1,     1,     1,     1,     1,     1,     1,     2,     2,     1,
+       1,     1,     1,     1,     1,     1,     1,     2,     1,     2,
+       1,     1,     1,     5,     2,     1,     2,     1,     1,     1,
+       1,     1,     1,     2,     5,     1,     3,     2,     3,     1,
+       1,     2,     1,     5,     4,     3,     2,     1,     6,     3,
+       2,     3,     1,     1,     1,     1,     1
 };
 
 
@@ -1965,6 +1953,7 @@ enum { YYENOMEM = -2 };
 #define YYACCEPT        goto yyacceptlab
 #define YYABORT         goto yyabortlab
 #define YYERROR         goto yyerrorlab
+#define YYNOMEM         goto yyexhaustedlab
 
 
 #define YYRECOVERING()  (!!yyerrstatus)
@@ -2005,10 +1994,7 @@ do {                                            \
     YYFPRINTF Args;                             \
 } while (0)
 
-/* This macro is provided for backward compatibility. */
-# ifndef YY_LOCATION_PRINT
-#  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
-# endif
+
 
 
 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)                    \
@@ -2035,10 +2021,6 @@ yy_symbol_value_print (FILE *yyo,
   YY_USE (yyoutput);
   if (!yyvaluep)
     return;
-# ifdef YYPRINT
-  if (yykind < YYNTOKENS)
-    YYPRINT (yyo, yytoknum[yykind], *yyvaluep);
-# endif
   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
   YY_USE (yykind);
   YY_IGNORE_MAYBE_UNINITIALIZED_END
@@ -2223,6 +2205,7 @@ yyparse (void)
   YYDPRINTF ((stderr, "Starting parse\n"));
 
   yychar = YYEMPTY; /* Cause a token to be read.  */
+
   goto yysetstate;
 
 
@@ -2248,7 +2231,7 @@ yyparse (void)
 
   if (yyss + yystacksize - 1 <= yyssp)
 #if !defined yyoverflow && !defined YYSTACK_RELOCATE
-    goto yyexhaustedlab;
+    YYNOMEM;
 #else
     {
       /* Get the current used size of the three stacks, in elements.  */
@@ -2276,7 +2259,7 @@ yyparse (void)
 # else /* defined YYSTACK_RELOCATE */
       /* Extend the stack our own way.  */
       if (YYMAXDEPTH <= yystacksize)
-        goto yyexhaustedlab;
+        YYNOMEM;
       yystacksize *= 2;
       if (YYMAXDEPTH < yystacksize)
         yystacksize = YYMAXDEPTH;
@@ -2287,7 +2270,7 @@ yyparse (void)
           YY_CAST (union yyalloc *,
                    YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
         if (! yyptr)
-          goto yyexhaustedlab;
+          YYNOMEM;
         YYSTACK_RELOCATE (yyss_alloc, yyss);
         YYSTACK_RELOCATE (yyvs_alloc, yyvs);
 #  undef YYSTACK_RELOCATE
@@ -2309,6 +2292,7 @@ yyparse (void)
     }
 #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
 
+
   if (yystate == YYFINAL)
     YYACCEPT;
 
@@ -2421,7 +2405,7 @@ yyparse (void)
   switch (yyn)
     {
   case 5: /* command_list: error T_EOC  */
-#line 404 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 406 "../../ntpd/ntp_parser.y"
                 {
 			/* I will need to incorporate much more fine grained
 			 * error messages. The following should suffice for
@@ -2434,85 +2418,85 @@ yyparse (void)
 				ip_ctx->errpos.nline,
 				ip_ctx->errpos.ncol);
 		}
-#line 2438 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2422 "ntp_parser.c"
     break;
 
   case 21: /* server_command: client_type address option_list  */
-#line 441 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 443 "../../ntpd/ntp_parser.y"
                 {
 			peer_node *my_node;
 
 			my_node = create_peer_node((yyvsp[-2].Integer), (yyvsp[-1].Address_node), (yyvsp[0].Attr_val_fifo));
 			APPEND_G_FIFO(cfgt.peers, my_node);
 		}
-#line 2449 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2433 "ntp_parser.c"
     break;
 
   case 28: /* address: address_fam T_String  */
-#line 460 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 462 "../../ntpd/ntp_parser.y"
                         { (yyval.Address_node) = create_address_node((yyvsp[0].String), (yyvsp[-1].Integer)); }
-#line 2455 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2439 "ntp_parser.c"
     break;
 
   case 29: /* ip_address: T_String  */
-#line 465 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 467 "../../ntpd/ntp_parser.y"
                         { (yyval.Address_node) = create_address_node((yyvsp[0].String), AF_UNSPEC); }
-#line 2461 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2445 "ntp_parser.c"
     break;
 
   case 30: /* address_fam: T_Ipv4_flag  */
-#line 470 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 472 "../../ntpd/ntp_parser.y"
                         { (yyval.Integer) = AF_INET; }
-#line 2467 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2451 "ntp_parser.c"
     break;
 
   case 31: /* address_fam: T_Ipv6_flag  */
-#line 472 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 474 "../../ntpd/ntp_parser.y"
                         { (yyval.Integer) = AF_INET6; }
-#line 2473 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2457 "ntp_parser.c"
     break;
 
   case 32: /* option_list: %empty  */
-#line 477 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 479 "../../ntpd/ntp_parser.y"
                         { (yyval.Attr_val_fifo) = NULL; }
-#line 2479 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2463 "ntp_parser.c"
     break;
 
   case 33: /* option_list: option_list option  */
-#line 479 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 481 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
 		}
-#line 2488 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2472 "ntp_parser.c"
     break;
 
   case 37: /* option_flag: option_flag_keyword  */
-#line 493 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 495 "../../ntpd/ntp_parser.y"
                         { (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[0].Integer)); }
-#line 2494 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2478 "ntp_parser.c"
     break;
 
   case 47: /* option_int: option_int_keyword T_Integer  */
-#line 510 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 512 "../../ntpd/ntp_parser.y"
                         { (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); }
-#line 2500 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2484 "ntp_parser.c"
     break;
 
   case 48: /* option_int: option_int_keyword T_U_int  */
-#line 512 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 514 "../../ntpd/ntp_parser.y"
                         { (yyval.Attr_val) = create_attr_uval((yyvsp[-1].Integer), (yyvsp[0].Integer)); }
-#line 2506 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2490 "ntp_parser.c"
     break;
 
   case 55: /* option_str: option_str_keyword T_String  */
-#line 526 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 528 "../../ntpd/ntp_parser.y"
                         { (yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String)); }
-#line 2512 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2496 "ntp_parser.c"
     break;
 
   case 57: /* unpeer_command: unpeer_keyword address  */
-#line 540 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 542 "../../ntpd/ntp_parser.y"
                 {
 			unpeer_node *my_node;
 
@@ -2520,85 +2504,85 @@ yyparse (void)
 			if (my_node)
 				APPEND_G_FIFO(cfgt.unpeers, my_node);
 		}
-#line 2524 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2508 "ntp_parser.c"
     break;
 
   case 60: /* other_mode_command: T_Broadcastclient  */
-#line 561 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 563 "../../ntpd/ntp_parser.y"
                         { cfgt.broadcastclient = 1; }
-#line 2530 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2514 "ntp_parser.c"
     break;
 
   case 61: /* other_mode_command: T_Manycastserver address_list  */
-#line 563 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 565 "../../ntpd/ntp_parser.y"
                         { CONCAT_G_FIFOS(cfgt.manycastserver, (yyvsp[0].Address_fifo)); }
-#line 2536 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2520 "ntp_parser.c"
     break;
 
   case 62: /* other_mode_command: T_Multicastclient address_list  */
-#line 565 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 567 "../../ntpd/ntp_parser.y"
                         { CONCAT_G_FIFOS(cfgt.multicastclient, (yyvsp[0].Address_fifo)); }
-#line 2542 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2526 "ntp_parser.c"
     break;
 
   case 63: /* other_mode_command: T_Mdnstries T_Integer  */
-#line 567 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 569 "../../ntpd/ntp_parser.y"
                         { cfgt.mdnstries = (yyvsp[0].Integer); }
-#line 2548 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2532 "ntp_parser.c"
     break;
 
   case 64: /* authentication_command: T_Automax T_Integer  */
-#line 578 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 580 "../../ntpd/ntp_parser.y"
                 {
 			attr_val *atrv;
 
 			atrv = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer));
 			APPEND_G_FIFO(cfgt.vars, atrv);
 		}
-#line 2559 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2543 "ntp_parser.c"
     break;
 
   case 65: /* authentication_command: T_ControlKey T_Integer  */
-#line 585 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 587 "../../ntpd/ntp_parser.y"
                         { cfgt.auth.control_key = (yyvsp[0].Integer); }
-#line 2565 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2549 "ntp_parser.c"
     break;
 
   case 66: /* authentication_command: T_Crypto crypto_command_list  */
-#line 587 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 589 "../../ntpd/ntp_parser.y"
                 {
 			cfgt.auth.cryptosw++;
 			CONCAT_G_FIFOS(cfgt.auth.crypto_cmd_list, (yyvsp[0].Attr_val_fifo));
 		}
-#line 2574 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2558 "ntp_parser.c"
     break;
 
   case 67: /* authentication_command: T_Keys T_String  */
-#line 592 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 594 "../../ntpd/ntp_parser.y"
                         { cfgt.auth.keys = (yyvsp[0].String); }
-#line 2580 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2564 "ntp_parser.c"
     break;
 
   case 68: /* authentication_command: T_Keysdir T_String  */
-#line 594 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 596 "../../ntpd/ntp_parser.y"
                         { cfgt.auth.keysdir = (yyvsp[0].String); }
-#line 2586 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2570 "ntp_parser.c"
     break;
 
   case 69: /* authentication_command: T_Requestkey T_Integer  */
-#line 596 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 598 "../../ntpd/ntp_parser.y"
                         { cfgt.auth.request_key = (yyvsp[0].Integer); }
-#line 2592 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2576 "ntp_parser.c"
     break;
 
   case 70: /* authentication_command: T_Revoke T_Integer  */
-#line 598 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 600 "../../ntpd/ntp_parser.y"
                         { cfgt.auth.revoke = (yyvsp[0].Integer); }
-#line 2598 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2582 "ntp_parser.c"
     break;
 
   case 71: /* authentication_command: T_Trustedkey integer_list_range  */
-#line 600 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 602 "../../ntpd/ntp_parser.y"
                 {
 			/* [Bug 948] leaves it open if appending or
 			 * replacing the trusted key list is the right
@@ -2608,38 +2592,38 @@ yyparse (void)
 			DESTROY_G_FIFO(cfgt.auth.trusted_key_list, destroy_attr_val); /* remove for append */
 			CONCAT_G_FIFOS(cfgt.auth.trusted_key_list, (yyvsp[0].Attr_val_fifo));
 		}
-#line 2612 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2596 "ntp_parser.c"
     break;
 
   case 72: /* authentication_command: T_NtpSignDsocket T_String  */
-#line 610 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 612 "../../ntpd/ntp_parser.y"
                         { cfgt.auth.ntp_signd_socket = (yyvsp[0].String); }
-#line 2618 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2602 "ntp_parser.c"
     break;
 
   case 73: /* crypto_command_list: %empty  */
-#line 615 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 617 "../../ntpd/ntp_parser.y"
                         { (yyval.Attr_val_fifo) = NULL; }
-#line 2624 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2608 "ntp_parser.c"
     break;
 
   case 74: /* crypto_command_list: crypto_command_list crypto_command  */
-#line 617 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 619 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
 		}
-#line 2633 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2617 "ntp_parser.c"
     break;
 
   case 75: /* crypto_command: crypto_str_keyword T_String  */
-#line 625 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 627 "../../ntpd/ntp_parser.y"
                         { (yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String)); }
-#line 2639 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2623 "ntp_parser.c"
     break;
 
   case 76: /* crypto_command: T_Revoke T_Integer  */
-#line 627 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 629 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Attr_val) = NULL;
 			cfgt.auth.revoke = (yyvsp[0].Integer);
@@ -2648,65 +2632,65 @@ yyparse (void)
 				"please use 'revoke %d' instead.",
 				cfgt.auth.revoke, cfgt.auth.revoke);
 		}
-#line 2652 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2636 "ntp_parser.c"
     break;
 
   case 82: /* orphan_mode_command: T_Tos tos_option_list  */
-#line 652 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 654 "../../ntpd/ntp_parser.y"
                         { CONCAT_G_FIFOS(cfgt.orphan_cmds, (yyvsp[0].Attr_val_fifo)); }
-#line 2658 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2642 "ntp_parser.c"
     break;
 
   case 83: /* tos_option_list: tos_option_list tos_option  */
-#line 657 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 659 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
 		}
-#line 2667 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2651 "ntp_parser.c"
     break;
 
   case 84: /* tos_option_list: tos_option  */
-#line 662 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 664 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Attr_val_fifo) = NULL;
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
 		}
-#line 2676 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2660 "ntp_parser.c"
     break;
 
   case 85: /* tos_option: tos_option_int_keyword T_Integer  */
-#line 670 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 672 "../../ntpd/ntp_parser.y"
                         { (yyval.Attr_val) = create_attr_dval((yyvsp[-1].Integer), (double)(yyvsp[0].Integer)); }
-#line 2682 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2666 "ntp_parser.c"
     break;
 
   case 86: /* tos_option: tos_option_dbl_keyword number  */
-#line 672 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 674 "../../ntpd/ntp_parser.y"
                         { (yyval.Attr_val) = create_attr_dval((yyvsp[-1].Integer), (yyvsp[0].Double)); }
-#line 2688 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2672 "ntp_parser.c"
     break;
 
   case 87: /* tos_option: T_Cohort boolean  */
-#line 674 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 676 "../../ntpd/ntp_parser.y"
                         { (yyval.Attr_val) = create_attr_dval((yyvsp[-1].Integer), (double)(yyvsp[0].Integer)); }
-#line 2694 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2678 "ntp_parser.c"
     break;
 
   case 88: /* tos_option: basedate  */
-#line 676 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 678 "../../ntpd/ntp_parser.y"
                         { (yyval.Attr_val) = create_attr_ival(T_Basedate, (yyvsp[0].Integer)); }
-#line 2700 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2684 "ntp_parser.c"
     break;
 
   case 100: /* monitoring_command: T_Statistics stats_list  */
-#line 703 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 705 "../../ntpd/ntp_parser.y"
                         { CONCAT_G_FIFOS(cfgt.stats_list, (yyvsp[0].Int_fifo)); }
-#line 2706 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2690 "ntp_parser.c"
     break;
 
   case 101: /* monitoring_command: T_Statsdir T_String  */
-#line 705 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 707 "../../ntpd/ntp_parser.y"
                 {
 			if (lex_from_file()) {
 				cfgt.stats_dir = (yyvsp[0].String);
@@ -2715,55 +2699,55 @@ yyparse (void)
 				yyerror("statsdir remote configuration ignored");
 			}
 		}
-#line 2719 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2703 "ntp_parser.c"
     break;
 
   case 102: /* monitoring_command: T_Filegen stat filegen_option_list  */
-#line 714 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 716 "../../ntpd/ntp_parser.y"
                 {
 			filegen_node *fgn;
 
 			fgn = create_filegen_node((yyvsp[-1].Integer), (yyvsp[0].Attr_val_fifo));
 			APPEND_G_FIFO(cfgt.filegen_opts, fgn);
 		}
-#line 2730 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2714 "ntp_parser.c"
     break;
 
   case 103: /* stats_list: stats_list stat  */
-#line 724 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 726 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Int_fifo) = (yyvsp[-1].Int_fifo);
 			APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[0].Integer)));
 		}
-#line 2739 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2723 "ntp_parser.c"
     break;
 
   case 104: /* stats_list: stat  */
-#line 729 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 731 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Int_fifo) = NULL;
 			APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[0].Integer)));
 		}
-#line 2748 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2732 "ntp_parser.c"
     break;
 
   case 113: /* filegen_option_list: %empty  */
-#line 748 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 750 "../../ntpd/ntp_parser.y"
                         { (yyval.Attr_val_fifo) = NULL; }
-#line 2754 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2738 "ntp_parser.c"
     break;
 
   case 114: /* filegen_option_list: filegen_option_list filegen_option  */
-#line 750 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 752 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
 		}
-#line 2763 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2747 "ntp_parser.c"
     break;
 
   case 115: /* filegen_option: T_File T_String  */
-#line 758 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 760 "../../ntpd/ntp_parser.y"
                 {
 			if (lex_from_file()) {
 				(yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String));
@@ -2773,11 +2757,11 @@ yyparse (void)
 				yyerror("filegen file remote config ignored");
 			}
 		}
-#line 2777 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2761 "ntp_parser.c"
     break;
 
   case 116: /* filegen_option: T_Type filegen_type  */
-#line 768 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 770 "../../ntpd/ntp_parser.y"
                 {
 			if (lex_from_file()) {
 				(yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer));
@@ -2786,11 +2770,11 @@ yyparse (void)
 				yyerror("filegen type remote config ignored");
 			}
 		}
-#line 2790 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2774 "ntp_parser.c"
     break;
 
   case 117: /* filegen_option: link_nolink  */
-#line 777 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 779 "../../ntpd/ntp_parser.y"
                 {
 			const char *err;
 
@@ -2805,69 +2789,59 @@ yyparse (void)
 				yyerror(err);
 			}
 		}
-#line 2809 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2793 "ntp_parser.c"
     break;
 
   case 118: /* filegen_option: enable_disable  */
-#line 792 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 794 "../../ntpd/ntp_parser.y"
                         { (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[0].Integer)); }
-#line 2815 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2799 "ntp_parser.c"
     break;
 
   case 130: /* access_control_command: T_Discard discard_option_list  */
-#line 822 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 824 "../../ntpd/ntp_parser.y"
                 {
 			CONCAT_G_FIFOS(cfgt.discard_opts, (yyvsp[0].Attr_val_fifo));
 		}
-#line 2823 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2807 "ntp_parser.c"
     break;
 
   case 131: /* access_control_command: T_Mru mru_option_list  */
-#line 826 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 828 "../../ntpd/ntp_parser.y"
                 {
 			CONCAT_G_FIFOS(cfgt.mru_opts, (yyvsp[0].Attr_val_fifo));
 		}
-#line 2831 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
-    break;
-
-  case 132: /* access_control_command: T_Restrict address res_ippeerlimit ac_flag_list  */
-#line 830 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
-                {
-			restrict_node *rn;
-
-			rn = create_restrict_node((yyvsp[-2].Address_node), NULL, (yyvsp[-1].Integer), (yyvsp[0].Attr_val_fifo),
-						  lex_current()->curpos.nline);
-			APPEND_G_FIFO(cfgt.restrict_opts, rn);
-		}
-#line 2843 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2815 "ntp_parser.c"
     break;
 
-  case 133: /* access_control_command: T_Restrict address T_Mask ip_address res_ippeerlimit ac_flag_list  */
-#line 838 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 132: /* access_control_command: T_Restrict address restrict_mask res_ippeerlimit ac_flag_list  */
+#line 832 "../../ntpd/ntp_parser.y"
                 {
 			restrict_node *rn;
 
-			rn = create_restrict_node((yyvsp[-4].Address_node), (yyvsp[-2].Address_node), (yyvsp[-1].Integer), (yyvsp[0].Attr_val_fifo),
-						  lex_current()->curpos.nline);
+			rn = create_restrict_node((yyvsp[-3].Address_node), (yyvsp[-2].Address_node), (yyvsp[-1].Integer), (yyvsp[0].Attr_val_fifo), FALSE,
+						  lex_current()->curpos.nline,
+						  lex_current()->curpos.ncol);
 			APPEND_G_FIFO(cfgt.restrict_opts, rn);
 		}
-#line 2855 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2828 "ntp_parser.c"
     break;
 
-  case 134: /* access_control_command: T_Restrict T_Default res_ippeerlimit ac_flag_list  */
-#line 846 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 133: /* access_control_command: T_Restrict T_Default res_ippeerlimit ac_flag_list  */
+#line 841 "../../ntpd/ntp_parser.y"
                 {
 			restrict_node *rn;
 
-			rn = create_restrict_node(NULL, NULL, (yyvsp[-1].Integer), (yyvsp[0].Attr_val_fifo),
-						  lex_current()->curpos.nline);
+			rn = create_restrict_node(NULL, NULL, (yyvsp[-1].Integer), (yyvsp[0].Attr_val_fifo), FALSE,
+						  lex_current()->curpos.nline,
+						  lex_current()->curpos.ncol);
 			APPEND_G_FIFO(cfgt.restrict_opts, rn);
 		}
-#line 2867 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2841 "ntp_parser.c"
     break;
 
-  case 135: /* access_control_command: T_Restrict T_Ipv4_flag T_Default res_ippeerlimit ac_flag_list  */
-#line 854 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 134: /* access_control_command: T_Restrict T_Ipv4_flag T_Default res_ippeerlimit ac_flag_list  */
+#line 850 "../../ntpd/ntp_parser.y"
                 {
 			restrict_node *rn;
 
@@ -2878,15 +2852,16 @@ yyparse (void)
 				create_address_node(
 					estrdup("0.0.0.0"),
 					AF_INET),
-				(yyvsp[-1].Integer), (yyvsp[0].Attr_val_fifo),
-				lex_current()->curpos.nline);
+				(yyvsp[-1].Integer), (yyvsp[0].Attr_val_fifo), FALSE,
+				lex_current()->curpos.nline,
+				lex_current()->curpos.ncol);
 			APPEND_G_FIFO(cfgt.restrict_opts, rn);
 		}
-#line 2886 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2861 "ntp_parser.c"
     break;
 
-  case 136: /* access_control_command: T_Restrict T_Ipv6_flag T_Default res_ippeerlimit ac_flag_list  */
-#line 869 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 135: /* access_control_command: T_Restrict T_Ipv6_flag T_Default res_ippeerlimit ac_flag_list  */
+#line 866 "../../ntpd/ntp_parser.y"
                 {
 			restrict_node *rn;
 
@@ -2897,34 +2872,79 @@ yyparse (void)
 				create_address_node(
 					estrdup("::"),
 					AF_INET6),
-				(yyvsp[-1].Integer), (yyvsp[0].Attr_val_fifo),
-				lex_current()->curpos.nline);
+				(yyvsp[-1].Integer), (yyvsp[0].Attr_val_fifo), FALSE,
+				lex_current()->curpos.nline,
+				lex_current()->curpos.ncol);
 			APPEND_G_FIFO(cfgt.restrict_opts, rn);
 		}
-#line 2905 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2881 "ntp_parser.c"
     break;
 
-  case 137: /* access_control_command: T_Restrict T_Source res_ippeerlimit ac_flag_list  */
-#line 884 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 136: /* access_control_command: T_Restrict T_Source res_ippeerlimit ac_flag_list  */
+#line 882 "../../ntpd/ntp_parser.y"
                 {
 			restrict_node *	rn;
 
 			APPEND_G_FIFO((yyvsp[0].Attr_val_fifo), create_attr_ival((yyvsp[-2].Integer), 1));
-			rn = create_restrict_node(
-				NULL, NULL, (yyvsp[-1].Integer), (yyvsp[0].Attr_val_fifo), lex_current()->curpos.nline);
+			rn = create_restrict_node(NULL, NULL, (yyvsp[-1].Integer), (yyvsp[0].Attr_val_fifo), FALSE,
+						  lex_current()->curpos.nline,
+						  lex_current()->curpos.ncol);
 			APPEND_G_FIFO(cfgt.restrict_opts, rn);
 		}
-#line 2918 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2895 "ntp_parser.c"
     break;
 
-  case 138: /* res_ippeerlimit: %empty  */
-#line 896 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 137: /* access_control_command: T_Delrestrict ip_address restrict_mask  */
+#line 892 "../../ntpd/ntp_parser.y"
+                {
+			restrict_node *	rn;
+
+			rn = create_restrict_node((yyvsp[-1].Address_node), (yyvsp[0].Address_node), -1, NULL, TRUE,
+						  lex_current()->curpos.nline,
+						  lex_current()->curpos.ncol);
+			APPEND_G_FIFO(cfgt.restrict_opts, rn);
+		}
+#line 2908 "ntp_parser.c"
+    break;
+
+  case 138: /* access_control_command: T_Delrestrict T_Source ip_address  */
+#line 901 "../../ntpd/ntp_parser.y"
+                {
+			restrict_node *	rn;
+			attr_val_fifo * avf;
+
+			avf = NULL;
+			APPEND_G_FIFO(avf, create_attr_ival((yyvsp[-1].Integer), 1));
+			rn = create_restrict_node((yyvsp[0].Address_node), NULL, -1, avf, TRUE,
+						  lex_current()->curpos.nline,
+						  lex_current()->curpos.ncol);
+			APPEND_G_FIFO(cfgt.restrict_opts, rn);
+		}
+#line 2924 "ntp_parser.c"
+    break;
+
+  case 139: /* restrict_mask: %empty  */
+#line 916 "../../ntpd/ntp_parser.y"
+                        { (yyval.Address_node) = NULL; }
+#line 2930 "ntp_parser.c"
+    break;
+
+  case 140: /* restrict_mask: T_Mask ip_address  */
+#line 918 "../../ntpd/ntp_parser.y"
+                {
+			(yyval.Address_node) = (yyvsp[0].Address_node);
+		}
+#line 2938 "ntp_parser.c"
+    break;
+
+  case 141: /* res_ippeerlimit: %empty  */
+#line 925 "../../ntpd/ntp_parser.y"
                         { (yyval.Integer) = -1; }
-#line 2924 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2944 "ntp_parser.c"
     break;
 
-  case 139: /* res_ippeerlimit: T_Ippeerlimit T_Integer  */
-#line 898 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 142: /* res_ippeerlimit: T_Ippeerlimit T_Integer  */
+#line 927 "../../ntpd/ntp_parser.y"
                 {
 			if (((yyvsp[0].Integer) < -1) || ((yyvsp[0].Integer) > 100)) {
 				struct FILE_INFO * ip_ctx;
@@ -2934,23 +2954,23 @@ yyparse (void)
 					"Unreasonable ippeerlimit value (%d) in %s line %d, column %d.  Using 0.",
 					(yyvsp[0].Integer),
 					ip_ctx->fname,
-					ip_ctx->errpos.nline,
-					ip_ctx->errpos.ncol);
+					ip_ctx->curpos.nline,
+					ip_ctx->curpos.ncol);
 				(yyvsp[0].Integer) = 0;
 			}
 			(yyval.Integer) = (yyvsp[0].Integer);
 		}
-#line 2944 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2964 "ntp_parser.c"
     break;
 
-  case 140: /* ac_flag_list: %empty  */
-#line 917 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 143: /* ac_flag_list: %empty  */
+#line 946 "../../ntpd/ntp_parser.y"
                         { (yyval.Attr_val_fifo) = NULL; }
-#line 2950 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2970 "ntp_parser.c"
     break;
 
-  case 141: /* ac_flag_list: ac_flag_list access_control_flag  */
-#line 919 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 144: /* ac_flag_list: ac_flag_list access_control_flag  */
+#line 948 "../../ntpd/ntp_parser.y"
                 {
 			attr_val *av;
 
@@ -2958,11 +2978,11 @@ yyparse (void)
 			av = create_attr_ival((yyvsp[0].Integer), 1);
 			APPEND_G_FIFO((yyval.Attr_val_fifo), av);
 		}
-#line 2962 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2982 "ntp_parser.c"
     break;
 
-  case 142: /* ac_flag_list: ac_flag_list T_Serverresponse T_Fuzz  */
-#line 927 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 145: /* ac_flag_list: ac_flag_list T_Serverresponse T_Fuzz  */
+#line 956 "../../ntpd/ntp_parser.y"
                 {
 			attr_val *av;
 
@@ -2970,100 +2990,100 @@ yyparse (void)
 			av = create_attr_ival(T_ServerresponseFuzz, 1);
 			APPEND_G_FIFO((yyval.Attr_val_fifo), av);
 		}
-#line 2974 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 2994 "ntp_parser.c"
     break;
 
-  case 160: /* discard_option_list: discard_option_list discard_option  */
-#line 958 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 163: /* discard_option_list: discard_option_list discard_option  */
+#line 987 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
 		}
-#line 2983 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3003 "ntp_parser.c"
     break;
 
-  case 161: /* discard_option_list: discard_option  */
-#line 963 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 164: /* discard_option_list: discard_option  */
+#line 992 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Attr_val_fifo) = NULL;
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
 		}
-#line 2992 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3012 "ntp_parser.c"
     break;
 
-  case 162: /* discard_option: discard_option_keyword T_Integer  */
-#line 971 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 165: /* discard_option: discard_option_keyword T_Integer  */
+#line 1000 "../../ntpd/ntp_parser.y"
                         { (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); }
-#line 2998 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3018 "ntp_parser.c"
     break;
 
-  case 166: /* mru_option_list: mru_option_list mru_option  */
-#line 982 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 169: /* mru_option_list: mru_option_list mru_option  */
+#line 1011 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
 		}
-#line 3007 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3027 "ntp_parser.c"
     break;
 
-  case 167: /* mru_option_list: mru_option  */
-#line 987 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 170: /* mru_option_list: mru_option  */
+#line 1016 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Attr_val_fifo) = NULL;
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
 		}
-#line 3016 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3036 "ntp_parser.c"
     break;
 
-  case 168: /* mru_option: mru_option_keyword T_Integer  */
-#line 995 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 171: /* mru_option: mru_option_keyword T_Integer  */
+#line 1024 "../../ntpd/ntp_parser.y"
                         { (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); }
-#line 3022 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3042 "ntp_parser.c"
     break;
 
-  case 177: /* fudge_command: T_Fudge address fudge_factor_list  */
-#line 1015 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 180: /* fudge_command: T_Fudge address fudge_factor_list  */
+#line 1044 "../../ntpd/ntp_parser.y"
                 {
 			addr_opts_node *aon;
 
 			aon = create_addr_opts_node((yyvsp[-1].Address_node), (yyvsp[0].Attr_val_fifo));
 			APPEND_G_FIFO(cfgt.fudge, aon);
 		}
-#line 3033 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3053 "ntp_parser.c"
     break;
 
-  case 178: /* fudge_factor_list: fudge_factor_list fudge_factor  */
-#line 1025 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 181: /* fudge_factor_list: fudge_factor_list fudge_factor  */
+#line 1054 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
 		}
-#line 3042 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3062 "ntp_parser.c"
     break;
 
-  case 179: /* fudge_factor_list: fudge_factor  */
-#line 1030 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 182: /* fudge_factor_list: fudge_factor  */
+#line 1059 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Attr_val_fifo) = NULL;
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
 		}
-#line 3051 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3071 "ntp_parser.c"
     break;
 
-  case 180: /* fudge_factor: fudge_factor_dbl_keyword number  */
-#line 1038 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 183: /* fudge_factor: fudge_factor_dbl_keyword number  */
+#line 1067 "../../ntpd/ntp_parser.y"
                         { (yyval.Attr_val) = create_attr_dval((yyvsp[-1].Integer), (yyvsp[0].Double)); }
-#line 3057 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3077 "ntp_parser.c"
     break;
 
-  case 181: /* fudge_factor: fudge_factor_bool_keyword boolean  */
-#line 1040 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 184: /* fudge_factor: fudge_factor_bool_keyword boolean  */
+#line 1069 "../../ntpd/ntp_parser.y"
                         { (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); }
-#line 3063 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3083 "ntp_parser.c"
     break;
 
-  case 182: /* fudge_factor: T_Stratum T_Integer  */
-#line 1042 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 185: /* fudge_factor: T_Stratum T_Integer  */
+#line 1071 "../../ntpd/ntp_parser.y"
                 {
 			if ((yyvsp[0].Integer) >= 0 && (yyvsp[0].Integer) <= 16) {
 				(yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer));
@@ -3072,124 +3092,124 @@ yyparse (void)
 				yyerror("fudge factor: stratum value not in [0..16], ignored");
 			}
 		}
-#line 3076 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3096 "ntp_parser.c"
     break;
 
-  case 183: /* fudge_factor: T_Abbrev T_String  */
-#line 1051 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 186: /* fudge_factor: T_Abbrev T_String  */
+#line 1080 "../../ntpd/ntp_parser.y"
                         { (yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String)); }
-#line 3082 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3102 "ntp_parser.c"
     break;
 
-  case 184: /* fudge_factor: T_Refid T_String  */
-#line 1053 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 187: /* fudge_factor: T_Refid T_String  */
+#line 1082 "../../ntpd/ntp_parser.y"
                         { (yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String)); }
-#line 3088 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3108 "ntp_parser.c"
     break;
 
-  case 192: /* device_command: T_Device address device_item_list  */
-#line 1075 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 195: /* device_command: T_Device address device_item_list  */
+#line 1104 "../../ntpd/ntp_parser.y"
                 {
 			addr_opts_node *aon;
 
 			aon = create_addr_opts_node((yyvsp[-1].Address_node), (yyvsp[0].Attr_val_fifo));
 			APPEND_G_FIFO(cfgt.device, aon);
 		}
-#line 3099 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3119 "ntp_parser.c"
     break;
 
-  case 193: /* device_item_list: device_item_list device_item  */
-#line 1085 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 196: /* device_item_list: device_item_list device_item  */
+#line 1114 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
 		}
-#line 3108 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3128 "ntp_parser.c"
     break;
 
-  case 194: /* device_item_list: device_item  */
-#line 1090 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 197: /* device_item_list: device_item  */
+#line 1119 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Attr_val_fifo) = NULL;
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
 		}
-#line 3117 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3137 "ntp_parser.c"
     break;
 
-  case 195: /* device_item: device_item_path_keyword T_String  */
-#line 1098 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 198: /* device_item: device_item_path_keyword T_String  */
+#line 1127 "../../ntpd/ntp_parser.y"
                         { (yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String)); }
-#line 3123 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3143 "ntp_parser.c"
     break;
 
-  case 198: /* rlimit_command: T_Rlimit rlimit_option_list  */
-#line 1112 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 201: /* rlimit_command: T_Rlimit rlimit_option_list  */
+#line 1141 "../../ntpd/ntp_parser.y"
                         { CONCAT_G_FIFOS(cfgt.rlimit, (yyvsp[0].Attr_val_fifo)); }
-#line 3129 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3149 "ntp_parser.c"
     break;
 
-  case 199: /* rlimit_option_list: rlimit_option_list rlimit_option  */
-#line 1117 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 202: /* rlimit_option_list: rlimit_option_list rlimit_option  */
+#line 1146 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
 		}
-#line 3138 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3158 "ntp_parser.c"
     break;
 
-  case 200: /* rlimit_option_list: rlimit_option  */
-#line 1122 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 203: /* rlimit_option_list: rlimit_option  */
+#line 1151 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Attr_val_fifo) = NULL;
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
 		}
-#line 3147 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3167 "ntp_parser.c"
     break;
 
-  case 201: /* rlimit_option: rlimit_option_keyword T_Integer  */
-#line 1130 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 204: /* rlimit_option: rlimit_option_keyword T_Integer  */
+#line 1159 "../../ntpd/ntp_parser.y"
                         { (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); }
-#line 3153 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3173 "ntp_parser.c"
     break;
 
-  case 205: /* system_option_command: T_Enable system_option_list  */
-#line 1146 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 208: /* system_option_command: T_Enable system_option_list  */
+#line 1175 "../../ntpd/ntp_parser.y"
                         { CONCAT_G_FIFOS(cfgt.enable_opts, (yyvsp[0].Attr_val_fifo)); }
-#line 3159 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3179 "ntp_parser.c"
     break;
 
-  case 206: /* system_option_command: T_Disable system_option_list  */
-#line 1148 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 209: /* system_option_command: T_Disable system_option_list  */
+#line 1177 "../../ntpd/ntp_parser.y"
                         { CONCAT_G_FIFOS(cfgt.disable_opts, (yyvsp[0].Attr_val_fifo)); }
-#line 3165 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3185 "ntp_parser.c"
     break;
 
-  case 207: /* system_option_list: system_option_list system_option  */
-#line 1153 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 210: /* system_option_list: system_option_list system_option  */
+#line 1182 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
 		}
-#line 3174 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3194 "ntp_parser.c"
     break;
 
-  case 208: /* system_option_list: system_option  */
-#line 1158 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 211: /* system_option_list: system_option  */
+#line 1187 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Attr_val_fifo) = NULL;
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
 		}
-#line 3183 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3203 "ntp_parser.c"
     break;
 
-  case 209: /* system_option: system_option_flag_keyword  */
-#line 1166 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 212: /* system_option: system_option_flag_keyword  */
+#line 1195 "../../ntpd/ntp_parser.y"
                         { (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[0].Integer)); }
-#line 3189 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3209 "ntp_parser.c"
     break;
 
-  case 210: /* system_option: system_option_local_flag_keyword  */
-#line 1168 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 213: /* system_option: system_option_local_flag_keyword  */
+#line 1197 "../../ntpd/ntp_parser.y"
                 {
 			if (lex_from_file()) {
 				(yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[0].Integer));
@@ -3203,74 +3223,74 @@ yyparse (void)
 				yyerror(err_str);
 			}
 		}
-#line 3207 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3227 "ntp_parser.c"
     break;
 
-  case 223: /* tinker_command: T_Tinker tinker_option_list  */
-#line 1207 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 226: /* tinker_command: T_Tinker tinker_option_list  */
+#line 1236 "../../ntpd/ntp_parser.y"
                         { CONCAT_G_FIFOS(cfgt.tinker, (yyvsp[0].Attr_val_fifo)); }
-#line 3213 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3233 "ntp_parser.c"
     break;
 
-  case 224: /* tinker_option_list: tinker_option_list tinker_option  */
-#line 1212 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 227: /* tinker_option_list: tinker_option_list tinker_option  */
+#line 1241 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
 		}
-#line 3222 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3242 "ntp_parser.c"
     break;
 
-  case 225: /* tinker_option_list: tinker_option  */
-#line 1217 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 228: /* tinker_option_list: tinker_option  */
+#line 1246 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Attr_val_fifo) = NULL;
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
 		}
-#line 3231 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3251 "ntp_parser.c"
     break;
 
-  case 226: /* tinker_option: tinker_option_keyword number  */
-#line 1225 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 229: /* tinker_option: tinker_option_keyword number  */
+#line 1254 "../../ntpd/ntp_parser.y"
                         { (yyval.Attr_val) = create_attr_dval((yyvsp[-1].Integer), (yyvsp[0].Double)); }
-#line 3237 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3257 "ntp_parser.c"
     break;
 
-  case 239: /* miscellaneous_command: misc_cmd_dbl_keyword number  */
-#line 1250 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 242: /* miscellaneous_command: misc_cmd_dbl_keyword number  */
+#line 1279 "../../ntpd/ntp_parser.y"
                 {
 			attr_val *av;
 
 			av = create_attr_dval((yyvsp[-1].Integer), (yyvsp[0].Double));
 			APPEND_G_FIFO(cfgt.vars, av);
 		}
-#line 3248 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3268 "ntp_parser.c"
     break;
 
-  case 240: /* miscellaneous_command: misc_cmd_int_keyword T_Integer  */
-#line 1257 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 243: /* miscellaneous_command: misc_cmd_int_keyword T_Integer  */
+#line 1286 "../../ntpd/ntp_parser.y"
                 {
 			attr_val *av;
 
 			av = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer));
 			APPEND_G_FIFO(cfgt.vars, av);
 		}
-#line 3259 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3279 "ntp_parser.c"
     break;
 
-  case 241: /* miscellaneous_command: misc_cmd_str_keyword T_String  */
-#line 1264 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 244: /* miscellaneous_command: misc_cmd_str_keyword T_String  */
+#line 1293 "../../ntpd/ntp_parser.y"
                 {
 			attr_val *av;
 
 			av = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String));
 			APPEND_G_FIFO(cfgt.vars, av);
 		}
-#line 3270 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3290 "ntp_parser.c"
     break;
 
-  case 242: /* miscellaneous_command: misc_cmd_str_lcl_keyword T_String  */
-#line 1271 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 245: /* miscellaneous_command: misc_cmd_str_lcl_keyword T_String  */
+#line 1300 "../../ntpd/ntp_parser.y"
                 {
 			char error_text[64];
 			attr_val *av;
@@ -3286,11 +3306,11 @@ yyparse (void)
 				yyerror(error_text);
 			}
 		}
-#line 3290 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3310 "ntp_parser.c"
     break;
 
-  case 243: /* miscellaneous_command: T_Includefile T_String command  */
-#line 1287 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 246: /* miscellaneous_command: T_Includefile T_String command  */
+#line 1316 "../../ntpd/ntp_parser.y"
                 {
 			if (!lex_from_file()) {
 				YYFREE((yyvsp[-1].String)); /* avoid leak */
@@ -3309,11 +3329,11 @@ yyparse (void)
 			}
 			YYFREE((yyvsp[-1].String)); /* avoid leak */
 		}
-#line 3313 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3333 "ntp_parser.c"
     break;
 
-  case 244: /* miscellaneous_command: T_Leapfile T_String opt_hash_check  */
-#line 1306 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 247: /* miscellaneous_command: T_Leapfile T_String opt_hash_check  */
+#line 1335 "../../ntpd/ntp_parser.y"
                 {
 			attr_val *av;
 
@@ -3321,92 +3341,92 @@ yyparse (void)
 			av->flag = (yyvsp[0].Integer);
 			APPEND_G_FIFO(cfgt.vars, av);
 		}
-#line 3325 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3345 "ntp_parser.c"
     break;
 
-  case 245: /* miscellaneous_command: T_End  */
-#line 1314 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 248: /* miscellaneous_command: T_End  */
+#line 1343 "../../ntpd/ntp_parser.y"
                         { lex_flush_stack(); }
-#line 3331 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3351 "ntp_parser.c"
     break;
 
-  case 246: /* miscellaneous_command: T_Driftfile drift_parm  */
-#line 1316 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 249: /* miscellaneous_command: T_Driftfile drift_parm  */
+#line 1345 "../../ntpd/ntp_parser.y"
                         { /* see drift_parm below for actions */ }
-#line 3337 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3357 "ntp_parser.c"
     break;
 
-  case 247: /* miscellaneous_command: T_Logconfig log_config_list  */
-#line 1318 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 250: /* miscellaneous_command: T_Logconfig log_config_list  */
+#line 1347 "../../ntpd/ntp_parser.y"
                         { CONCAT_G_FIFOS(cfgt.logconfig, (yyvsp[0].Attr_val_fifo)); }
-#line 3343 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3363 "ntp_parser.c"
     break;
 
-  case 248: /* miscellaneous_command: T_Phone string_list  */
-#line 1320 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 251: /* miscellaneous_command: T_Phone string_list  */
+#line 1349 "../../ntpd/ntp_parser.y"
                         { CONCAT_G_FIFOS(cfgt.phone, (yyvsp[0].String_fifo)); }
-#line 3349 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3369 "ntp_parser.c"
     break;
 
-  case 249: /* miscellaneous_command: T_PollSkewList pollskew_list  */
-#line 1322 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 252: /* miscellaneous_command: T_PollSkewList pollskew_list  */
+#line 1351 "../../ntpd/ntp_parser.y"
                         { CONCAT_G_FIFOS(cfgt.pollskewlist, (yyvsp[0].Attr_val_fifo)); }
-#line 3355 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3375 "ntp_parser.c"
     break;
 
-  case 250: /* miscellaneous_command: T_Setvar variable_assign  */
-#line 1324 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 253: /* miscellaneous_command: T_Setvar variable_assign  */
+#line 1353 "../../ntpd/ntp_parser.y"
                         { APPEND_G_FIFO(cfgt.setvar, (yyvsp[0].Set_var)); }
-#line 3361 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3381 "ntp_parser.c"
     break;
 
-  case 251: /* miscellaneous_command: T_Trap ip_address trap_option_list  */
-#line 1326 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 254: /* miscellaneous_command: T_Trap ip_address trap_option_list  */
+#line 1355 "../../ntpd/ntp_parser.y"
                 {
 			addr_opts_node *aon;
 
 			aon = create_addr_opts_node((yyvsp[-1].Address_node), (yyvsp[0].Attr_val_fifo));
 			APPEND_G_FIFO(cfgt.trap, aon);
 		}
-#line 3372 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3392 "ntp_parser.c"
     break;
 
-  case 252: /* miscellaneous_command: T_Ttl integer_list  */
-#line 1333 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 255: /* miscellaneous_command: T_Ttl integer_list  */
+#line 1362 "../../ntpd/ntp_parser.y"
                         { CONCAT_G_FIFOS(cfgt.ttl, (yyvsp[0].Attr_val_fifo)); }
-#line 3378 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3398 "ntp_parser.c"
     break;
 
-  case 257: /* misc_cmd_int_keyword: T_Leapsmearinterval  */
-#line 1348 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 260: /* misc_cmd_int_keyword: T_Leapsmearinterval  */
+#line 1377 "../../ntpd/ntp_parser.y"
                 {
 #ifndef LEAP_SMEAR
 			yyerror("Built without LEAP_SMEAR support.");
 #endif
 		}
-#line 3388 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3408 "ntp_parser.c"
     break;
 
-  case 258: /* opt_hash_check: T_Ignorehash  */
-#line 1357 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 261: /* opt_hash_check: T_Ignorehash  */
+#line 1386 "../../ntpd/ntp_parser.y"
                         { (yyval.Integer) = FALSE; }
-#line 3394 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3414 "ntp_parser.c"
     break;
 
-  case 259: /* opt_hash_check: T_Checkhash  */
-#line 1359 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 262: /* opt_hash_check: T_Checkhash  */
+#line 1388 "../../ntpd/ntp_parser.y"
                         { (yyval.Integer) = TRUE; }
-#line 3400 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3420 "ntp_parser.c"
     break;
 
-  case 260: /* opt_hash_check: %empty  */
-#line 1361 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 263: /* opt_hash_check: %empty  */
+#line 1390 "../../ntpd/ntp_parser.y"
                         {  (yyval.Integer) = TRUE; }
-#line 3406 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3426 "ntp_parser.c"
     break;
 
-  case 265: /* drift_parm: T_String  */
-#line 1376 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 268: /* drift_parm: T_String  */
+#line 1405 "../../ntpd/ntp_parser.y"
                 {
 			if (lex_from_file()) {
 				attr_val *av;
@@ -3417,11 +3437,11 @@ yyparse (void)
 				yyerror("driftfile remote configuration ignored");
 			}
 		}
-#line 3421 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3441 "ntp_parser.c"
     break;
 
-  case 266: /* drift_parm: T_String T_Double  */
-#line 1387 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 269: /* drift_parm: T_String T_Double  */
+#line 1416 "../../ntpd/ntp_parser.y"
                 {
 			if (lex_from_file()) {
 				attr_val *av;
@@ -3438,11 +3458,11 @@ yyparse (void)
 				yyerror("driftfile remote configuration ignored");
 			}
 		}
-#line 3442 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3462 "ntp_parser.c"
     break;
 
-  case 267: /* drift_parm: %empty  */
-#line 1404 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 270: /* drift_parm: %empty  */
+#line 1433 "../../ntpd/ntp_parser.y"
                 {
 			if (lex_from_file()) {
 				attr_val *av;
@@ -3452,23 +3472,23 @@ yyparse (void)
 				yyerror("driftfile remote configuration ignored");
 			}
 		}
-#line 3456 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3476 "ntp_parser.c"
     break;
 
-  case 268: /* pollskew_list: %empty  */
-#line 1417 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 271: /* pollskew_list: %empty  */
+#line 1446 "../../ntpd/ntp_parser.y"
                         { (yyval.Attr_val_fifo) = NULL; }
-#line 3462 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3482 "ntp_parser.c"
     break;
 
-  case 269: /* pollskew_list: pollskew_list pollskew_spec  */
-#line 1419 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 272: /* pollskew_list: pollskew_list pollskew_spec  */
+#line 1448 "../../ntpd/ntp_parser.y"
                         { (yyval.Attr_val_fifo) = append_gen_fifo((yyvsp[-1].Attr_val_fifo), (yyvsp[0].Attr_val)); }
-#line 3468 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3488 "ntp_parser.c"
     break;
 
-  case 270: /* pollskew_spec: pollskew_cycle T_Integer '|' T_Integer  */
-#line 1424 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 273: /* pollskew_spec: pollskew_cycle T_Integer '|' T_Integer  */
+#line 1453 "../../ntpd/ntp_parser.y"
                 {
 			if ((yyvsp[-2].Integer) < 0 || (yyvsp[0].Integer) < 0) {
 				/* bad numbers */
@@ -3491,83 +3511,87 @@ yyparse (void)
 			}
 			(yyval.Attr_val) = (yyvsp[-3].Attr_val);
 		}
-#line 3495 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3515 "ntp_parser.c"
     break;
 
-  case 271: /* pollskew_cycle: T_Integer  */
-#line 1449 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
-                          { (yyval.Attr_val) = ((yyvsp[0].Integer) >= 3 && (yyvsp[0].Integer) <= 17) ? create_attr_rval((yyvsp[0].Integer), 0, 0) : NULL; }
-#line 3501 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+  case 274: /* pollskew_cycle: T_Integer  */
+#line 1479 "../../ntpd/ntp_parser.y"
+                { 
+			(yyval.Attr_val) = ((yyvsp[0].Integer) >= NTP_MINPOLL && (yyvsp[0].Integer) <= NTP_MAXPOLL) 
+				? create_attr_rval((yyvsp[0].Integer), 0, 0) 
+				: NULL;
+		}
+#line 3525 "ntp_parser.c"
     break;
 
-  case 272: /* pollskew_cycle: T_Default  */
-#line 1450 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 275: /* pollskew_cycle: T_Default  */
+#line 1484 "../../ntpd/ntp_parser.y"
                           { (yyval.Attr_val) = create_attr_rval(-1, 0, 0); }
-#line 3507 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3531 "ntp_parser.c"
     break;
 
-  case 273: /* variable_assign: T_String '=' T_String t_default_or_zero  */
-#line 1456 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 276: /* variable_assign: T_String '=' T_String t_default_or_zero  */
+#line 1490 "../../ntpd/ntp_parser.y"
                         { (yyval.Set_var) = create_setvar_node((yyvsp[-3].String), (yyvsp[-1].String), (yyvsp[0].Integer)); }
-#line 3513 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3537 "ntp_parser.c"
     break;
 
-  case 275: /* t_default_or_zero: %empty  */
-#line 1462 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 278: /* t_default_or_zero: %empty  */
+#line 1496 "../../ntpd/ntp_parser.y"
                         { (yyval.Integer) = 0; }
-#line 3519 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3543 "ntp_parser.c"
     break;
 
-  case 276: /* trap_option_list: %empty  */
-#line 1467 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 279: /* trap_option_list: %empty  */
+#line 1501 "../../ntpd/ntp_parser.y"
                         { (yyval.Attr_val_fifo) = NULL; }
-#line 3525 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3549 "ntp_parser.c"
     break;
 
-  case 277: /* trap_option_list: trap_option_list trap_option  */
-#line 1469 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 280: /* trap_option_list: trap_option_list trap_option  */
+#line 1503 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
 		}
-#line 3534 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3558 "ntp_parser.c"
     break;
 
-  case 278: /* trap_option: T_Port T_Integer  */
-#line 1477 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 281: /* trap_option: T_Port T_Integer  */
+#line 1511 "../../ntpd/ntp_parser.y"
                         { (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); }
-#line 3540 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3564 "ntp_parser.c"
     break;
 
-  case 279: /* trap_option: T_Interface ip_address  */
-#line 1479 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 282: /* trap_option: T_Interface ip_address  */
+#line 1513 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), estrdup((yyvsp[0].Address_node)->address));
 			destroy_address_node((yyvsp[0].Address_node));
 		}
-#line 3549 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3573 "ntp_parser.c"
     break;
 
-  case 280: /* log_config_list: log_config_list log_config_command  */
-#line 1487 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 283: /* log_config_list: log_config_list log_config_command  */
+#line 1521 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
 		}
-#line 3558 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3582 "ntp_parser.c"
     break;
 
-  case 281: /* log_config_list: log_config_command  */
-#line 1492 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 284: /* log_config_list: log_config_command  */
+#line 1526 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Attr_val_fifo) = NULL;
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
 		}
-#line 3567 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3591 "ntp_parser.c"
     break;
 
-  case 282: /* log_config_command: T_String  */
-#line 1500 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 285: /* log_config_command: T_String  */
+#line 1534 "../../ntpd/ntp_parser.y"
                 {
 			char	prefix;
 			char *	type;
@@ -3589,141 +3613,141 @@ yyparse (void)
 			(yyval.Attr_val) = create_attr_sval(prefix, estrdup(type));
 			YYFREE((yyvsp[0].String));
 		}
-#line 3593 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3617 "ntp_parser.c"
     break;
 
-  case 283: /* interface_command: interface_nic nic_rule_action nic_rule_class  */
-#line 1525 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 286: /* interface_command: interface_nic nic_rule_action nic_rule_class  */
+#line 1559 "../../ntpd/ntp_parser.y"
                 {
 			nic_rule_node *nrn;
 
 			nrn = create_nic_rule_node((yyvsp[0].Integer), NULL, (yyvsp[-1].Integer));
 			APPEND_G_FIFO(cfgt.nic_rules, nrn);
 		}
-#line 3604 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3628 "ntp_parser.c"
     break;
 
-  case 284: /* interface_command: interface_nic nic_rule_action T_String  */
-#line 1532 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 287: /* interface_command: interface_nic nic_rule_action T_String  */
+#line 1566 "../../ntpd/ntp_parser.y"
                 {
 			nic_rule_node *nrn;
 
 			nrn = create_nic_rule_node(0, (yyvsp[0].String), (yyvsp[-1].Integer));
 			APPEND_G_FIFO(cfgt.nic_rules, nrn);
 		}
-#line 3615 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3639 "ntp_parser.c"
     break;
 
-  case 294: /* reset_command: T_Reset counter_set_list  */
-#line 1560 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 297: /* reset_command: T_Reset counter_set_list  */
+#line 1594 "../../ntpd/ntp_parser.y"
                         { CONCAT_G_FIFOS(cfgt.reset_counters, (yyvsp[0].Int_fifo)); }
-#line 3621 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3645 "ntp_parser.c"
     break;
 
-  case 295: /* counter_set_list: counter_set_list counter_set_keyword  */
-#line 1565 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 298: /* counter_set_list: counter_set_list counter_set_keyword  */
+#line 1599 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Int_fifo) = (yyvsp[-1].Int_fifo);
 			APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[0].Integer)));
 		}
-#line 3630 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3654 "ntp_parser.c"
     break;
 
-  case 296: /* counter_set_list: counter_set_keyword  */
-#line 1570 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 299: /* counter_set_list: counter_set_keyword  */
+#line 1604 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Int_fifo) = NULL;
 			APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[0].Integer)));
 		}
-#line 3639 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3663 "ntp_parser.c"
     break;
 
-  case 304: /* integer_list: integer_list T_Integer  */
-#line 1594 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 307: /* integer_list: integer_list T_Integer  */
+#line 1628 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
 			APPEND_G_FIFO((yyval.Attr_val_fifo), create_int_node((yyvsp[0].Integer)));
 		}
-#line 3648 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3672 "ntp_parser.c"
     break;
 
-  case 305: /* integer_list: T_Integer  */
-#line 1599 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 308: /* integer_list: T_Integer  */
+#line 1633 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Attr_val_fifo) = NULL;
 			APPEND_G_FIFO((yyval.Attr_val_fifo), create_int_node((yyvsp[0].Integer)));
 		}
-#line 3657 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3681 "ntp_parser.c"
     break;
 
-  case 306: /* integer_list_range: integer_list_range integer_list_range_elt  */
-#line 1607 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 309: /* integer_list_range: integer_list_range integer_list_range_elt  */
+#line 1641 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
 		}
-#line 3666 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3690 "ntp_parser.c"
     break;
 
-  case 307: /* integer_list_range: integer_list_range_elt  */
-#line 1612 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 310: /* integer_list_range: integer_list_range_elt  */
+#line 1646 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Attr_val_fifo) = NULL;
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
 		}
-#line 3675 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3699 "ntp_parser.c"
     break;
 
-  case 308: /* integer_list_range_elt: T_Integer  */
-#line 1620 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 311: /* integer_list_range_elt: T_Integer  */
+#line 1654 "../../ntpd/ntp_parser.y"
                         { (yyval.Attr_val) = create_attr_ival('i', (yyvsp[0].Integer)); }
-#line 3681 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3705 "ntp_parser.c"
     break;
 
-  case 310: /* integer_range: '(' T_Integer T_Ellipsis T_Integer ')'  */
-#line 1626 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 313: /* integer_range: '(' T_Integer T_Ellipsis T_Integer ')'  */
+#line 1660 "../../ntpd/ntp_parser.y"
                         { (yyval.Attr_val) = create_attr_rval('-', (yyvsp[-3].Integer), (yyvsp[-1].Integer)); }
-#line 3687 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3711 "ntp_parser.c"
     break;
 
-  case 311: /* string_list: string_list T_String  */
-#line 1631 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 314: /* string_list: string_list T_String  */
+#line 1665 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.String_fifo) = (yyvsp[-1].String_fifo);
 			APPEND_G_FIFO((yyval.String_fifo), create_string_node((yyvsp[0].String)));
 		}
-#line 3696 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3720 "ntp_parser.c"
     break;
 
-  case 312: /* string_list: T_String  */
-#line 1636 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 315: /* string_list: T_String  */
+#line 1670 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.String_fifo) = NULL;
 			APPEND_G_FIFO((yyval.String_fifo), create_string_node((yyvsp[0].String)));
 		}
-#line 3705 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3729 "ntp_parser.c"
     break;
 
-  case 313: /* address_list: address_list address  */
-#line 1644 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 316: /* address_list: address_list address  */
+#line 1678 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Address_fifo) = (yyvsp[-1].Address_fifo);
 			APPEND_G_FIFO((yyval.Address_fifo), (yyvsp[0].Address_node));
 		}
-#line 3714 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3738 "ntp_parser.c"
     break;
 
-  case 314: /* address_list: address  */
-#line 1649 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 317: /* address_list: address  */
+#line 1683 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Address_fifo) = NULL;
 			APPEND_G_FIFO((yyval.Address_fifo), (yyvsp[0].Address_node));
 		}
-#line 3723 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3747 "ntp_parser.c"
     break;
 
-  case 315: /* boolean: T_Integer  */
-#line 1657 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 318: /* boolean: T_Integer  */
+#line 1691 "../../ntpd/ntp_parser.y"
                 {
 			if ((yyvsp[0].Integer) != 0 && (yyvsp[0].Integer) != 1) {
 				yyerror("Integer value is not boolean (0 or 1). Assuming 1");
@@ -3732,35 +3756,35 @@ yyparse (void)
 				(yyval.Integer) = (yyvsp[0].Integer);
 			}
 		}
-#line 3736 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3760 "ntp_parser.c"
     break;
 
-  case 316: /* boolean: T_True  */
-#line 1665 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 319: /* boolean: T_True  */
+#line 1699 "../../ntpd/ntp_parser.y"
                         { (yyval.Integer) = 1; }
-#line 3742 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3766 "ntp_parser.c"
     break;
 
-  case 317: /* boolean: T_False  */
-#line 1666 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 320: /* boolean: T_False  */
+#line 1700 "../../ntpd/ntp_parser.y"
                         { (yyval.Integer) = 0; }
-#line 3748 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3772 "ntp_parser.c"
     break;
 
-  case 318: /* number: T_Integer  */
-#line 1670 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 321: /* number: T_Integer  */
+#line 1704 "../../ntpd/ntp_parser.y"
                                 { (yyval.Double) = (double)(yyvsp[0].Integer); }
-#line 3754 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3778 "ntp_parser.c"
     break;
 
-  case 320: /* basedate: T_Basedate T_String  */
-#line 1676 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 323: /* basedate: T_Basedate T_String  */
+#line 1710 "../../ntpd/ntp_parser.y"
                         { (yyval.Integer) = basedate_eval_string((yyvsp[0].String)); YYFREE((yyvsp[0].String)); }
-#line 3760 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3784 "ntp_parser.c"
     break;
 
-  case 321: /* simulate_command: sim_conf_start '{' sim_init_statement_list sim_server_list '}'  */
-#line 1684 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 324: /* simulate_command: sim_conf_start '{' sim_init_statement_list sim_server_list '}'  */
+#line 1718 "../../ntpd/ntp_parser.y"
                 {
 			sim_node *sn;
 
@@ -3770,125 +3794,125 @@ yyparse (void)
 			/* Revert from ; to \n for end-of-command */
 			old_config_style = 1;
 		}
-#line 3774 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3798 "ntp_parser.c"
     break;
 
-  case 322: /* sim_conf_start: T_Simulate  */
-#line 1701 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 325: /* sim_conf_start: T_Simulate  */
+#line 1735 "../../ntpd/ntp_parser.y"
                            { old_config_style = 0; }
-#line 3780 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3804 "ntp_parser.c"
     break;
 
-  case 323: /* sim_init_statement_list: sim_init_statement_list sim_init_statement T_EOC  */
-#line 1706 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 326: /* sim_init_statement_list: sim_init_statement_list sim_init_statement T_EOC  */
+#line 1740 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Attr_val_fifo) = (yyvsp[-2].Attr_val_fifo);
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[-1].Attr_val));
 		}
-#line 3789 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3813 "ntp_parser.c"
     break;
 
-  case 324: /* sim_init_statement_list: sim_init_statement T_EOC  */
-#line 1711 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 327: /* sim_init_statement_list: sim_init_statement T_EOC  */
+#line 1745 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Attr_val_fifo) = NULL;
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[-1].Attr_val));
 		}
-#line 3798 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3822 "ntp_parser.c"
     break;
 
-  case 325: /* sim_init_statement: sim_init_keyword '=' number  */
-#line 1719 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 328: /* sim_init_statement: sim_init_keyword '=' number  */
+#line 1753 "../../ntpd/ntp_parser.y"
                         { (yyval.Attr_val) = create_attr_dval((yyvsp[-2].Integer), (yyvsp[0].Double)); }
-#line 3804 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3828 "ntp_parser.c"
     break;
 
-  case 328: /* sim_server_list: sim_server_list sim_server  */
-#line 1729 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 331: /* sim_server_list: sim_server_list sim_server  */
+#line 1763 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Sim_server_fifo) = (yyvsp[-1].Sim_server_fifo);
 			APPEND_G_FIFO((yyval.Sim_server_fifo), (yyvsp[0].Sim_server));
 		}
-#line 3813 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3837 "ntp_parser.c"
     break;
 
-  case 329: /* sim_server_list: sim_server  */
-#line 1734 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 332: /* sim_server_list: sim_server  */
+#line 1768 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Sim_server_fifo) = NULL;
 			APPEND_G_FIFO((yyval.Sim_server_fifo), (yyvsp[0].Sim_server));
 		}
-#line 3822 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3846 "ntp_parser.c"
     break;
 
-  case 330: /* sim_server: sim_server_name '{' sim_server_offset sim_act_list '}'  */
-#line 1742 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 333: /* sim_server: sim_server_name '{' sim_server_offset sim_act_list '}'  */
+#line 1776 "../../ntpd/ntp_parser.y"
                         { (yyval.Sim_server) = ONLY_SIM(create_sim_server((yyvsp[-4].Address_node), (yyvsp[-2].Double), (yyvsp[-1].Sim_script_fifo))); }
-#line 3828 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3852 "ntp_parser.c"
     break;
 
-  case 331: /* sim_server_offset: T_Server_Offset '=' number T_EOC  */
-#line 1747 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 334: /* sim_server_offset: T_Server_Offset '=' number T_EOC  */
+#line 1781 "../../ntpd/ntp_parser.y"
                         { (yyval.Double) = (yyvsp[-1].Double); }
-#line 3834 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3858 "ntp_parser.c"
     break;
 
-  case 332: /* sim_server_name: T_Server '=' address  */
-#line 1752 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 335: /* sim_server_name: T_Server '=' address  */
+#line 1786 "../../ntpd/ntp_parser.y"
                         { (yyval.Address_node) = (yyvsp[0].Address_node); }
-#line 3840 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3864 "ntp_parser.c"
     break;
 
-  case 333: /* sim_act_list: sim_act_list sim_act  */
-#line 1757 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 336: /* sim_act_list: sim_act_list sim_act  */
+#line 1791 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Sim_script_fifo) = (yyvsp[-1].Sim_script_fifo);
 			APPEND_G_FIFO((yyval.Sim_script_fifo), (yyvsp[0].Sim_script));
 		}
-#line 3849 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3873 "ntp_parser.c"
     break;
 
-  case 334: /* sim_act_list: sim_act  */
-#line 1762 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 337: /* sim_act_list: sim_act  */
+#line 1796 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Sim_script_fifo) = NULL;
 			APPEND_G_FIFO((yyval.Sim_script_fifo), (yyvsp[0].Sim_script));
 		}
-#line 3858 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3882 "ntp_parser.c"
     break;
 
-  case 335: /* sim_act: T_Duration '=' number '{' sim_act_stmt_list '}'  */
-#line 1770 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 338: /* sim_act: T_Duration '=' number '{' sim_act_stmt_list '}'  */
+#line 1804 "../../ntpd/ntp_parser.y"
                         { (yyval.Sim_script) = ONLY_SIM(create_sim_script_info((yyvsp[-3].Double), (yyvsp[-1].Attr_val_fifo))); }
-#line 3864 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3888 "ntp_parser.c"
     break;
 
-  case 336: /* sim_act_stmt_list: sim_act_stmt_list sim_act_stmt T_EOC  */
-#line 1775 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 339: /* sim_act_stmt_list: sim_act_stmt_list sim_act_stmt T_EOC  */
+#line 1809 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Attr_val_fifo) = (yyvsp[-2].Attr_val_fifo);
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[-1].Attr_val));
 		}
-#line 3873 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3897 "ntp_parser.c"
     break;
 
-  case 337: /* sim_act_stmt_list: sim_act_stmt T_EOC  */
-#line 1780 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 340: /* sim_act_stmt_list: sim_act_stmt T_EOC  */
+#line 1814 "../../ntpd/ntp_parser.y"
                 {
 			(yyval.Attr_val_fifo) = NULL;
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[-1].Attr_val));
 		}
-#line 3882 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3906 "ntp_parser.c"
     break;
 
-  case 338: /* sim_act_stmt: sim_act_keyword '=' number  */
-#line 1788 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+  case 341: /* sim_act_stmt: sim_act_keyword '=' number  */
+#line 1822 "../../ntpd/ntp_parser.y"
                         { (yyval.Attr_val) = create_attr_dval((yyvsp[-2].Integer), (yyvsp[0].Double)); }
-#line 3888 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3912 "ntp_parser.c"
     break;
 
 
-#line 3892 "../../../src/ntp-stable-3758/ntpd/ntp_parser.c"
+#line 3916 "ntp_parser.c"
 
       default: break;
     }
@@ -3970,6 +3994,7 @@ yyparse (void)
      label yyerrorlab therefore never appears in user code.  */
   if (0)
     YYERROR;
+  ++yynerrs;
 
   /* Do not reclaim the symbols of the rule whose action triggered
      this YYERROR.  */
@@ -4030,7 +4055,7 @@ yyparse (void)
 `-------------------------------------*/
 yyacceptlab:
   yyresult = 0;
-  goto yyreturn;
+  goto yyreturnlab;
 
 
 /*-----------------------------------.
@@ -4038,24 +4063,22 @@ yyparse (void)
 `-----------------------------------*/
 yyabortlab:
   yyresult = 1;
-  goto yyreturn;
+  goto yyreturnlab;
 
 
-#if !defined yyoverflow
-/*-------------------------------------------------.
-| yyexhaustedlab -- memory exhaustion comes here.  |
-`-------------------------------------------------*/
+/*-----------------------------------------------------------.
+| yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here.  |
+`-----------------------------------------------------------*/
 yyexhaustedlab:
   yyerror (YY_("memory exhausted"));
   yyresult = 2;
-  goto yyreturn;
-#endif
+  goto yyreturnlab;
 
 
-/*-------------------------------------------------------.
-| yyreturn -- parsing is finished, clean up and return.  |
-`-------------------------------------------------------*/
-yyreturn:
+/*----------------------------------------------------------.
+| yyreturnlab -- parsing is finished, clean up and return.  |
+`----------------------------------------------------------*/
+yyreturnlab:
   if (yychar != YYEMPTY)
     {
       /* Make sure we have latest lookahead translation.  See comments at
@@ -4082,7 +4105,7 @@ yyparse (void)
   return yyresult;
 }
 
-#line 1799 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 1833 "../../ntpd/ntp_parser.y"
 
 
 void
diff --git a/contrib/ntp/ntpd/ntp_parser.h b/contrib/ntp/ntpd/ntp_parser.h
index 426b4b9666ba..2f8501a4b1dc 100644
--- a/contrib/ntp/ntpd/ntp_parser.h
+++ b/contrib/ntp/ntpd/ntp_parser.h
@@ -1,4 +1,4 @@
-/* A Bison parser, made by GNU Bison 3.7.6.  */
+/* A Bison parser, made by GNU Bison 3.8.2.  */
 
 /* Bison interface for Yacc-like parsers in C
 
@@ -35,8 +35,8 @@
    especially those whose name start with YY_ or yy_.  They are
    private implementation details that can be changed or removed.  */
 
-#ifndef YY_YY__SRC_NTP_STABLE_NTPD_NTP_PARSER_H_INCLUDED
-# define YY_YY__SRC_NTP_STABLE_NTPD_NTP_PARSER_H_INCLUDED
+#ifndef YY_YY_NTP_PARSER_H_INCLUDED
+# define YY_YY_NTP_PARSER_H_INCLUDED
 /* Debug traces.  */
 #ifndef YYDEBUG
 # define YYDEBUG 1
@@ -82,190 +82,191 @@ extern int yydebug;
     T_Ctl = 283,                   /* T_Ctl  */
     T_Day = 284,                   /* T_Day  */
     T_Default = 285,               /* T_Default  */
-    T_Device = 286,                /* T_Device  */
-    T_Digest = 287,                /* T_Digest  */
-    T_Disable = 288,               /* T_Disable  */
-    T_Discard = 289,               /* T_Discard  */
-    T_Dispersion = 290,            /* T_Dispersion  */
-    T_Double = 291,                /* T_Double  */
-    T_Driftfile = 292,             /* T_Driftfile  */
-    T_Drop = 293,                  /* T_Drop  */
-    T_Dscp = 294,                  /* T_Dscp  */
-    T_Ellipsis = 295,              /* T_Ellipsis  */
-    T_Enable = 296,                /* T_Enable  */
-    T_End = 297,                   /* T_End  */
-    T_Epeer = 298,                 /* T_Epeer  */
-    T_False = 299,                 /* T_False  */
-    T_File = 300,                  /* T_File  */
-    T_Filegen = 301,               /* T_Filegen  */
-    T_Filenum = 302,               /* T_Filenum  */
-    T_Flag1 = 303,                 /* T_Flag1  */
-    T_Flag2 = 304,                 /* T_Flag2  */
-    T_Flag3 = 305,                 /* T_Flag3  */
-    T_Flag4 = 306,                 /* T_Flag4  */
-    T_Flake = 307,                 /* T_Flake  */
-    T_Floor = 308,                 /* T_Floor  */
-    T_Freq = 309,                  /* T_Freq  */
-    T_Fudge = 310,                 /* T_Fudge  */
-    T_Fuzz = 311,                  /* T_Fuzz  */
-    T_Host = 312,                  /* T_Host  */
-    T_Huffpuff = 313,              /* T_Huffpuff  */
-    T_Iburst = 314,                /* T_Iburst  */
-    T_Ident = 315,                 /* T_Ident  */
-    T_Ignore = 316,                /* T_Ignore  */
-    T_Ignorehash = 317,            /* T_Ignorehash  */
-    T_Incalloc = 318,              /* T_Incalloc  */
-    T_Incmem = 319,                /* T_Incmem  */
-    T_Initalloc = 320,             /* T_Initalloc  */
-    T_Initmem = 321,               /* T_Initmem  */
-    T_Includefile = 322,           /* T_Includefile  */
-    T_Integer = 323,               /* T_Integer  */
-    T_Interface = 324,             /* T_Interface  */
-    T_Intrange = 325,              /* T_Intrange  */
-    T_Io = 326,                    /* T_Io  */
-    T_Ippeerlimit = 327,           /* T_Ippeerlimit  */
-    T_Ipv4 = 328,                  /* T_Ipv4  */
-    T_Ipv4_flag = 329,             /* T_Ipv4_flag  */
-    T_Ipv6 = 330,                  /* T_Ipv6  */
-    T_Ipv6_flag = 331,             /* T_Ipv6_flag  */
-    T_Kernel = 332,                /* T_Kernel  */
-    T_Key = 333,                   /* T_Key  */
-    T_Keys = 334,                  /* T_Keys  */
-    T_Keysdir = 335,               /* T_Keysdir  */
-    T_Kod = 336,                   /* T_Kod  */
-    T_Leapfile = 337,              /* T_Leapfile  */
-    T_Leapsmearinterval = 338,     /* T_Leapsmearinterval  */
-    T_Limited = 339,               /* T_Limited  */
-    T_Link = 340,                  /* T_Link  */
-    T_Listen = 341,                /* T_Listen  */
-    T_Logconfig = 342,             /* T_Logconfig  */
-    T_Logfile = 343,               /* T_Logfile  */
-    T_Loopstats = 344,             /* T_Loopstats  */
-    T_Lowpriotrap = 345,           /* T_Lowpriotrap  */
-    T_Manycastclient = 346,        /* T_Manycastclient  */
-    T_Manycastserver = 347,        /* T_Manycastserver  */
-    T_Mask = 348,                  /* T_Mask  */
-    T_Maxage = 349,                /* T_Maxage  */
-    T_Maxclock = 350,              /* T_Maxclock  */
-    T_Maxdepth = 351,              /* T_Maxdepth  */
-    T_Maxdist = 352,               /* T_Maxdist  */
-    T_Maxmem = 353,                /* T_Maxmem  */
-    T_Maxpoll = 354,               /* T_Maxpoll  */
-    T_Mdnstries = 355,             /* T_Mdnstries  */
-    T_Mem = 356,                   /* T_Mem  */
-    T_Memlock = 357,               /* T_Memlock  */
-    T_Minclock = 358,              /* T_Minclock  */
-    T_Mindepth = 359,              /* T_Mindepth  */
-    T_Mindist = 360,               /* T_Mindist  */
-    T_Minimum = 361,               /* T_Minimum  */
-    T_Minjitter = 362,             /* T_Minjitter  */
-    T_Minpoll = 363,               /* T_Minpoll  */
-    T_Minsane = 364,               /* T_Minsane  */
-    T_Mode = 365,                  /* T_Mode  */
-    T_Mode7 = 366,                 /* T_Mode7  */
-    T_Monitor = 367,               /* T_Monitor  */
-    T_Month = 368,                 /* T_Month  */
-    T_Mru = 369,                   /* T_Mru  */
-    T_Mssntp = 370,                /* T_Mssntp  */
-    T_Multicastclient = 371,       /* T_Multicastclient  */
-    T_Nic = 372,                   /* T_Nic  */
-    T_Nolink = 373,                /* T_Nolink  */
-    T_Nomodify = 374,              /* T_Nomodify  */
-    T_Nomrulist = 375,             /* T_Nomrulist  */
-    T_None = 376,                  /* T_None  */
-    T_Nonvolatile = 377,           /* T_Nonvolatile  */
-    T_Noepeer = 378,               /* T_Noepeer  */
-    T_Nopeer = 379,                /* T_Nopeer  */
-    T_Noquery = 380,               /* T_Noquery  */
-    T_Noselect = 381,              /* T_Noselect  */
-    T_Noserve = 382,               /* T_Noserve  */
-    T_Notrap = 383,                /* T_Notrap  */
-    T_Notrust = 384,               /* T_Notrust  */
-    T_Ntp = 385,                   /* T_Ntp  */
-    T_Ntpport = 386,               /* T_Ntpport  */
-    T_NtpSignDsocket = 387,        /* T_NtpSignDsocket  */
-    T_Orphan = 388,                /* T_Orphan  */
-    T_Orphanwait = 389,            /* T_Orphanwait  */
-    T_PCEdigest = 390,             /* T_PCEdigest  */
-    T_Panic = 391,                 /* T_Panic  */
-    T_Peer = 392,                  /* T_Peer  */
-    T_Peerstats = 393,             /* T_Peerstats  */
-    T_Phone = 394,                 /* T_Phone  */
-    T_Pid = 395,                   /* T_Pid  */
-    T_Pidfile = 396,               /* T_Pidfile  */
-    T_Poll = 397,                  /* T_Poll  */
-    T_PollSkewList = 398,          /* T_PollSkewList  */
-    T_Pool = 399,                  /* T_Pool  */
-    T_Port = 400,                  /* T_Port  */
-    T_PpsData = 401,               /* T_PpsData  */
-    T_Preempt = 402,               /* T_Preempt  */
-    T_Prefer = 403,                /* T_Prefer  */
-    T_Protostats = 404,            /* T_Protostats  */
-    T_Pw = 405,                    /* T_Pw  */
-    T_Randfile = 406,              /* T_Randfile  */
-    T_Rawstats = 407,              /* T_Rawstats  */
-    T_Refid = 408,                 /* T_Refid  */
-    T_Requestkey = 409,            /* T_Requestkey  */
-    T_Reset = 410,                 /* T_Reset  */
-    T_Restrict = 411,              /* T_Restrict  */
-    T_Revoke = 412,                /* T_Revoke  */
-    T_Rlimit = 413,                /* T_Rlimit  */
-    T_Saveconfigdir = 414,         /* T_Saveconfigdir  */
-    T_Server = 415,                /* T_Server  */
-    T_Serverresponse = 416,        /* T_Serverresponse  */
-    T_ServerresponseFuzz = 417,    /* T_ServerresponseFuzz  */
-    T_Setvar = 418,                /* T_Setvar  */
-    T_Source = 419,                /* T_Source  */
-    T_Stacksize = 420,             /* T_Stacksize  */
-    T_Statistics = 421,            /* T_Statistics  */
-    T_Stats = 422,                 /* T_Stats  */
-    T_Statsdir = 423,              /* T_Statsdir  */
-    T_Step = 424,                  /* T_Step  */
-    T_Stepback = 425,              /* T_Stepback  */
-    T_Stepfwd = 426,               /* T_Stepfwd  */
-    T_Stepout = 427,               /* T_Stepout  */
-    T_Stratum = 428,               /* T_Stratum  */
-    T_String = 429,                /* T_String  */
-    T_Sys = 430,                   /* T_Sys  */
-    T_Sysstats = 431,              /* T_Sysstats  */
-    T_Tick = 432,                  /* T_Tick  */
-    T_Time1 = 433,                 /* T_Time1  */
-    T_Time2 = 434,                 /* T_Time2  */
-    T_TimeData = 435,              /* T_TimeData  */
-    T_Timer = 436,                 /* T_Timer  */
-    T_Timingstats = 437,           /* T_Timingstats  */
-    T_Tinker = 438,                /* T_Tinker  */
-    T_Tos = 439,                   /* T_Tos  */
-    T_Trap = 440,                  /* T_Trap  */
-    T_True = 441,                  /* T_True  */
-    T_Trustedkey = 442,            /* T_Trustedkey  */
-    T_Ttl = 443,                   /* T_Ttl  */
-    T_Type = 444,                  /* T_Type  */
-    T_U_int = 445,                 /* T_U_int  */
-    T_UEcrypto = 446,              /* T_UEcrypto  */
-    T_UEcryptonak = 447,           /* T_UEcryptonak  */
-    T_UEdigest = 448,              /* T_UEdigest  */
-    T_Unconfig = 449,              /* T_Unconfig  */
-    T_Unpeer = 450,                /* T_Unpeer  */
-    T_Version = 451,               /* T_Version  */
-    T_WanderThreshold = 452,       /* T_WanderThreshold  */
-    T_Week = 453,                  /* T_Week  */
-    T_Wildcard = 454,              /* T_Wildcard  */
-    T_Xleave = 455,                /* T_Xleave  */
-    T_Xmtnonce = 456,              /* T_Xmtnonce  */
-    T_Year = 457,                  /* T_Year  */
-    T_Flag = 458,                  /* T_Flag  */
-    T_EOC = 459,                   /* T_EOC  */
-    T_Simulate = 460,              /* T_Simulate  */
-    T_Beep_Delay = 461,            /* T_Beep_Delay  */
-    T_Sim_Duration = 462,          /* T_Sim_Duration  */
-    T_Server_Offset = 463,         /* T_Server_Offset  */
-    T_Duration = 464,              /* T_Duration  */
-    T_Freq_Offset = 465,           /* T_Freq_Offset  */
-    T_Wander = 466,                /* T_Wander  */
-    T_Jitter = 467,                /* T_Jitter  */
-    T_Prop_Delay = 468,            /* T_Prop_Delay  */
-    T_Proc_Delay = 469             /* T_Proc_Delay  */
+    T_Delrestrict = 286,           /* T_Delrestrict  */
+    T_Device = 287,                /* T_Device  */
+    T_Digest = 288,                /* T_Digest  */
+    T_Disable = 289,               /* T_Disable  */
+    T_Discard = 290,               /* T_Discard  */
+    T_Dispersion = 291,            /* T_Dispersion  */
+    T_Double = 292,                /* T_Double  */
+    T_Driftfile = 293,             /* T_Driftfile  */
+    T_Drop = 294,                  /* T_Drop  */
+    T_Dscp = 295,                  /* T_Dscp  */
+    T_Ellipsis = 296,              /* T_Ellipsis  */
+    T_Enable = 297,                /* T_Enable  */
+    T_End = 298,                   /* T_End  */
+    T_Epeer = 299,                 /* T_Epeer  */
+    T_False = 300,                 /* T_False  */
+    T_File = 301,                  /* T_File  */
+    T_Filegen = 302,               /* T_Filegen  */
+    T_Filenum = 303,               /* T_Filenum  */
+    T_Flag1 = 304,                 /* T_Flag1  */
+    T_Flag2 = 305,                 /* T_Flag2  */
+    T_Flag3 = 306,                 /* T_Flag3  */
+    T_Flag4 = 307,                 /* T_Flag4  */
+    T_Flake = 308,                 /* T_Flake  */
+    T_Floor = 309,                 /* T_Floor  */
+    T_Freq = 310,                  /* T_Freq  */
+    T_Fudge = 311,                 /* T_Fudge  */
+    T_Fuzz = 312,                  /* T_Fuzz  */
+    T_Host = 313,                  /* T_Host  */
+    T_Huffpuff = 314,              /* T_Huffpuff  */
+    T_Iburst = 315,                /* T_Iburst  */
+    T_Ident = 316,                 /* T_Ident  */
+    T_Ignore = 317,                /* T_Ignore  */
+    T_Ignorehash = 318,            /* T_Ignorehash  */
+    T_Incalloc = 319,              /* T_Incalloc  */
+    T_Incmem = 320,                /* T_Incmem  */
+    T_Initalloc = 321,             /* T_Initalloc  */
+    T_Initmem = 322,               /* T_Initmem  */
+    T_Includefile = 323,           /* T_Includefile  */
+    T_Integer = 324,               /* T_Integer  */
+    T_Interface = 325,             /* T_Interface  */
+    T_Intrange = 326,              /* T_Intrange  */
+    T_Io = 327,                    /* T_Io  */
+    T_Ippeerlimit = 328,           /* T_Ippeerlimit  */
+    T_Ipv4 = 329,                  /* T_Ipv4  */
+    T_Ipv4_flag = 330,             /* T_Ipv4_flag  */
+    T_Ipv6 = 331,                  /* T_Ipv6  */
+    T_Ipv6_flag = 332,             /* T_Ipv6_flag  */
+    T_Kernel = 333,                /* T_Kernel  */
+    T_Key = 334,                   /* T_Key  */
+    T_Keys = 335,                  /* T_Keys  */
+    T_Keysdir = 336,               /* T_Keysdir  */
+    T_Kod = 337,                   /* T_Kod  */
+    T_Leapfile = 338,              /* T_Leapfile  */
+    T_Leapsmearinterval = 339,     /* T_Leapsmearinterval  */
+    T_Limited = 340,               /* T_Limited  */
+    T_Link = 341,                  /* T_Link  */
+    T_Listen = 342,                /* T_Listen  */
+    T_Logconfig = 343,             /* T_Logconfig  */
+    T_Logfile = 344,               /* T_Logfile  */
+    T_Loopstats = 345,             /* T_Loopstats  */
+    T_Lowpriotrap = 346,           /* T_Lowpriotrap  */
+    T_Manycastclient = 347,        /* T_Manycastclient  */
+    T_Manycastserver = 348,        /* T_Manycastserver  */
+    T_Mask = 349,                  /* T_Mask  */
+    T_Maxage = 350,                /* T_Maxage  */
+    T_Maxclock = 351,              /* T_Maxclock  */
+    T_Maxdepth = 352,              /* T_Maxdepth  */
+    T_Maxdist = 353,               /* T_Maxdist  */
+    T_Maxmem = 354,                /* T_Maxmem  */
+    T_Maxpoll = 355,               /* T_Maxpoll  */
+    T_Mdnstries = 356,             /* T_Mdnstries  */
+    T_Mem = 357,                   /* T_Mem  */
+    T_Memlock = 358,               /* T_Memlock  */
+    T_Minclock = 359,              /* T_Minclock  */
+    T_Mindepth = 360,              /* T_Mindepth  */
+    T_Mindist = 361,               /* T_Mindist  */
+    T_Minimum = 362,               /* T_Minimum  */
+    T_Minjitter = 363,             /* T_Minjitter  */
+    T_Minpoll = 364,               /* T_Minpoll  */
+    T_Minsane = 365,               /* T_Minsane  */
+    T_Mode = 366,                  /* T_Mode  */
+    T_Mode7 = 367,                 /* T_Mode7  */
+    T_Monitor = 368,               /* T_Monitor  */
+    T_Month = 369,                 /* T_Month  */
+    T_Mru = 370,                   /* T_Mru  */
+    T_Mssntp = 371,                /* T_Mssntp  */
+    T_Multicastclient = 372,       /* T_Multicastclient  */
+    T_Nic = 373,                   /* T_Nic  */
+    T_Nolink = 374,                /* T_Nolink  */
+    T_Nomodify = 375,              /* T_Nomodify  */
+    T_Nomrulist = 376,             /* T_Nomrulist  */
+    T_None = 377,                  /* T_None  */
+    T_Nonvolatile = 378,           /* T_Nonvolatile  */
+    T_Noepeer = 379,               /* T_Noepeer  */
+    T_Nopeer = 380,                /* T_Nopeer  */
+    T_Noquery = 381,               /* T_Noquery  */
+    T_Noselect = 382,              /* T_Noselect  */
+    T_Noserve = 383,               /* T_Noserve  */
+    T_Notrap = 384,                /* T_Notrap  */
+    T_Notrust = 385,               /* T_Notrust  */
+    T_Ntp = 386,                   /* T_Ntp  */
+    T_Ntpport = 387,               /* T_Ntpport  */
+    T_NtpSignDsocket = 388,        /* T_NtpSignDsocket  */
+    T_Orphan = 389,                /* T_Orphan  */
+    T_Orphanwait = 390,            /* T_Orphanwait  */
+    T_PCEdigest = 391,             /* T_PCEdigest  */
+    T_Panic = 392,                 /* T_Panic  */
+    T_Peer = 393,                  /* T_Peer  */
+    T_Peerstats = 394,             /* T_Peerstats  */
+    T_Phone = 395,                 /* T_Phone  */
+    T_Pid = 396,                   /* T_Pid  */
+    T_Pidfile = 397,               /* T_Pidfile  */
+    T_Poll = 398,                  /* T_Poll  */
+    T_PollSkewList = 399,          /* T_PollSkewList  */
+    T_Pool = 400,                  /* T_Pool  */
+    T_Port = 401,                  /* T_Port  */
+    T_PpsData = 402,               /* T_PpsData  */
+    T_Preempt = 403,               /* T_Preempt  */
+    T_Prefer = 404,                /* T_Prefer  */
+    T_Protostats = 405,            /* T_Protostats  */
+    T_Pw = 406,                    /* T_Pw  */
+    T_Randfile = 407,              /* T_Randfile  */
+    T_Rawstats = 408,              /* T_Rawstats  */
+    T_Refid = 409,                 /* T_Refid  */
+    T_Requestkey = 410,            /* T_Requestkey  */
+    T_Reset = 411,                 /* T_Reset  */
+    T_Restrict = 412,              /* T_Restrict  */
+    T_Revoke = 413,                /* T_Revoke  */
+    T_Rlimit = 414,                /* T_Rlimit  */
+    T_Saveconfigdir = 415,         /* T_Saveconfigdir  */
+    T_Server = 416,                /* T_Server  */
+    T_Serverresponse = 417,        /* T_Serverresponse  */
+    T_ServerresponseFuzz = 418,    /* T_ServerresponseFuzz  */
+    T_Setvar = 419,                /* T_Setvar  */
+    T_Source = 420,                /* T_Source  */
+    T_Stacksize = 421,             /* T_Stacksize  */
+    T_Statistics = 422,            /* T_Statistics  */
+    T_Stats = 423,                 /* T_Stats  */
+    T_Statsdir = 424,              /* T_Statsdir  */
+    T_Step = 425,                  /* T_Step  */
+    T_Stepback = 426,              /* T_Stepback  */
+    T_Stepfwd = 427,               /* T_Stepfwd  */
+    T_Stepout = 428,               /* T_Stepout  */
+    T_Stratum = 429,               /* T_Stratum  */
+    T_String = 430,                /* T_String  */
+    T_Sys = 431,                   /* T_Sys  */
+    T_Sysstats = 432,              /* T_Sysstats  */
+    T_Tick = 433,                  /* T_Tick  */
+    T_Time1 = 434,                 /* T_Time1  */
+    T_Time2 = 435,                 /* T_Time2  */
+    T_TimeData = 436,              /* T_TimeData  */
+    T_Timer = 437,                 /* T_Timer  */
+    T_Timingstats = 438,           /* T_Timingstats  */
+    T_Tinker = 439,                /* T_Tinker  */
+    T_Tos = 440,                   /* T_Tos  */
+    T_Trap = 441,                  /* T_Trap  */
+    T_True = 442,                  /* T_True  */
+    T_Trustedkey = 443,            /* T_Trustedkey  */
+    T_Ttl = 444,                   /* T_Ttl  */
+    T_Type = 445,                  /* T_Type  */
+    T_U_int = 446,                 /* T_U_int  */
+    T_UEcrypto = 447,              /* T_UEcrypto  */
+    T_UEcryptonak = 448,           /* T_UEcryptonak  */
+    T_UEdigest = 449,              /* T_UEdigest  */
+    T_Unconfig = 450,              /* T_Unconfig  */
+    T_Unpeer = 451,                /* T_Unpeer  */
+    T_Version = 452,               /* T_Version  */
+    T_WanderThreshold = 453,       /* T_WanderThreshold  */
+    T_Week = 454,                  /* T_Week  */
+    T_Wildcard = 455,              /* T_Wildcard  */
+    T_Xleave = 456,                /* T_Xleave  */
+    T_Xmtnonce = 457,              /* T_Xmtnonce  */
+    T_Year = 458,                  /* T_Year  */
+    T_Flag = 459,                  /* T_Flag  */
+    T_EOC = 460,                   /* T_EOC  */
+    T_Simulate = 461,              /* T_Simulate  */
+    T_Beep_Delay = 462,            /* T_Beep_Delay  */
+    T_Sim_Duration = 463,          /* T_Sim_Duration  */
+    T_Server_Offset = 464,         /* T_Server_Offset  */
+    T_Duration = 465,              /* T_Duration  */
+    T_Freq_Offset = 466,           /* T_Freq_Offset  */
+    T_Wander = 467,                /* T_Wander  */
+    T_Jitter = 468,                /* T_Jitter  */
+    T_Prop_Delay = 469,            /* T_Prop_Delay  */
+    T_Proc_Delay = 470             /* T_Proc_Delay  */
   };
   typedef enum yytokentype yytoken_kind_t;
 #endif
@@ -302,196 +303,197 @@ extern int yydebug;
 #define T_Ctl 283
 #define T_Day 284
 #define T_Default 285
-#define T_Device 286
-#define T_Digest 287
-#define T_Disable 288
-#define T_Discard 289
-#define T_Dispersion 290
-#define T_Double 291
-#define T_Driftfile 292
-#define T_Drop 293
-#define T_Dscp 294
-#define T_Ellipsis 295
-#define T_Enable 296
-#define T_End 297
-#define T_Epeer 298
-#define T_False 299
-#define T_File 300
-#define T_Filegen 301
-#define T_Filenum 302
-#define T_Flag1 303
-#define T_Flag2 304
-#define T_Flag3 305
-#define T_Flag4 306
-#define T_Flake 307
-#define T_Floor 308
-#define T_Freq 309
-#define T_Fudge 310
-#define T_Fuzz 311
-#define T_Host 312
-#define T_Huffpuff 313
-#define T_Iburst 314
-#define T_Ident 315
-#define T_Ignore 316
-#define T_Ignorehash 317
-#define T_Incalloc 318
-#define T_Incmem 319
-#define T_Initalloc 320
-#define T_Initmem 321
-#define T_Includefile 322
-#define T_Integer 323
-#define T_Interface 324
-#define T_Intrange 325
-#define T_Io 326
-#define T_Ippeerlimit 327
-#define T_Ipv4 328
-#define T_Ipv4_flag 329
-#define T_Ipv6 330
-#define T_Ipv6_flag 331
-#define T_Kernel 332
-#define T_Key 333
-#define T_Keys 334
-#define T_Keysdir 335
-#define T_Kod 336
-#define T_Leapfile 337
-#define T_Leapsmearinterval 338
-#define T_Limited 339
-#define T_Link 340
-#define T_Listen 341
-#define T_Logconfig 342
-#define T_Logfile 343
-#define T_Loopstats 344
-#define T_Lowpriotrap 345
-#define T_Manycastclient 346
-#define T_Manycastserver 347
-#define T_Mask 348
-#define T_Maxage 349
-#define T_Maxclock 350
-#define T_Maxdepth 351
-#define T_Maxdist 352
-#define T_Maxmem 353
-#define T_Maxpoll 354
-#define T_Mdnstries 355
-#define T_Mem 356
-#define T_Memlock 357
-#define T_Minclock 358
-#define T_Mindepth 359
-#define T_Mindist 360
-#define T_Minimum 361
-#define T_Minjitter 362
-#define T_Minpoll 363
-#define T_Minsane 364
-#define T_Mode 365
-#define T_Mode7 366
-#define T_Monitor 367
-#define T_Month 368
-#define T_Mru 369
-#define T_Mssntp 370
-#define T_Multicastclient 371
-#define T_Nic 372
-#define T_Nolink 373
-#define T_Nomodify 374
-#define T_Nomrulist 375
-#define T_None 376
-#define T_Nonvolatile 377
-#define T_Noepeer 378
-#define T_Nopeer 379
-#define T_Noquery 380
-#define T_Noselect 381
-#define T_Noserve 382
-#define T_Notrap 383
-#define T_Notrust 384
-#define T_Ntp 385
-#define T_Ntpport 386
-#define T_NtpSignDsocket 387
-#define T_Orphan 388
-#define T_Orphanwait 389
-#define T_PCEdigest 390
-#define T_Panic 391
-#define T_Peer 392
-#define T_Peerstats 393
-#define T_Phone 394
-#define T_Pid 395
-#define T_Pidfile 396
-#define T_Poll 397
-#define T_PollSkewList 398
-#define T_Pool 399
-#define T_Port 400
-#define T_PpsData 401
-#define T_Preempt 402
-#define T_Prefer 403
-#define T_Protostats 404
-#define T_Pw 405
-#define T_Randfile 406
-#define T_Rawstats 407
-#define T_Refid 408
-#define T_Requestkey 409
-#define T_Reset 410
-#define T_Restrict 411
-#define T_Revoke 412
-#define T_Rlimit 413
-#define T_Saveconfigdir 414
-#define T_Server 415
-#define T_Serverresponse 416
-#define T_ServerresponseFuzz 417
-#define T_Setvar 418
-#define T_Source 419
-#define T_Stacksize 420
-#define T_Statistics 421
-#define T_Stats 422
-#define T_Statsdir 423
-#define T_Step 424
-#define T_Stepback 425
-#define T_Stepfwd 426
-#define T_Stepout 427
-#define T_Stratum 428
-#define T_String 429
-#define T_Sys 430
-#define T_Sysstats 431
-#define T_Tick 432
-#define T_Time1 433
-#define T_Time2 434
-#define T_TimeData 435
-#define T_Timer 436
-#define T_Timingstats 437
-#define T_Tinker 438
-#define T_Tos 439
-#define T_Trap 440
-#define T_True 441
-#define T_Trustedkey 442
-#define T_Ttl 443
-#define T_Type 444
-#define T_U_int 445
-#define T_UEcrypto 446
-#define T_UEcryptonak 447
-#define T_UEdigest 448
-#define T_Unconfig 449
-#define T_Unpeer 450
-#define T_Version 451
-#define T_WanderThreshold 452
-#define T_Week 453
-#define T_Wildcard 454
-#define T_Xleave 455
-#define T_Xmtnonce 456
-#define T_Year 457
-#define T_Flag 458
-#define T_EOC 459
-#define T_Simulate 460
-#define T_Beep_Delay 461
-#define T_Sim_Duration 462
-#define T_Server_Offset 463
-#define T_Duration 464
-#define T_Freq_Offset 465
-#define T_Wander 466
-#define T_Jitter 467
-#define T_Prop_Delay 468
-#define T_Proc_Delay 469
+#define T_Delrestrict 286
+#define T_Device 287
+#define T_Digest 288
+#define T_Disable 289
+#define T_Discard 290
+#define T_Dispersion 291
+#define T_Double 292
+#define T_Driftfile 293
+#define T_Drop 294
+#define T_Dscp 295
+#define T_Ellipsis 296
+#define T_Enable 297
+#define T_End 298
+#define T_Epeer 299
+#define T_False 300
+#define T_File 301
+#define T_Filegen 302
+#define T_Filenum 303
+#define T_Flag1 304
+#define T_Flag2 305
+#define T_Flag3 306
+#define T_Flag4 307
+#define T_Flake 308
+#define T_Floor 309
+#define T_Freq 310
+#define T_Fudge 311
+#define T_Fuzz 312
+#define T_Host 313
+#define T_Huffpuff 314
+#define T_Iburst 315
+#define T_Ident 316
+#define T_Ignore 317
+#define T_Ignorehash 318
+#define T_Incalloc 319
+#define T_Incmem 320
+#define T_Initalloc 321
+#define T_Initmem 322
+#define T_Includefile 323
+#define T_Integer 324
+#define T_Interface 325
+#define T_Intrange 326
+#define T_Io 327
+#define T_Ippeerlimit 328
+#define T_Ipv4 329
+#define T_Ipv4_flag 330
+#define T_Ipv6 331
+#define T_Ipv6_flag 332
+#define T_Kernel 333
+#define T_Key 334
+#define T_Keys 335
+#define T_Keysdir 336
+#define T_Kod 337
+#define T_Leapfile 338
+#define T_Leapsmearinterval 339
+#define T_Limited 340
+#define T_Link 341
+#define T_Listen 342
+#define T_Logconfig 343
+#define T_Logfile 344
+#define T_Loopstats 345
+#define T_Lowpriotrap 346
+#define T_Manycastclient 347
+#define T_Manycastserver 348
+#define T_Mask 349
+#define T_Maxage 350
+#define T_Maxclock 351
+#define T_Maxdepth 352
+#define T_Maxdist 353
+#define T_Maxmem 354
+#define T_Maxpoll 355
+#define T_Mdnstries 356
+#define T_Mem 357
+#define T_Memlock 358
+#define T_Minclock 359
+#define T_Mindepth 360
+#define T_Mindist 361
+#define T_Minimum 362
+#define T_Minjitter 363
+#define T_Minpoll 364
+#define T_Minsane 365
+#define T_Mode 366
+#define T_Mode7 367
+#define T_Monitor 368
+#define T_Month 369
+#define T_Mru 370
+#define T_Mssntp 371
+#define T_Multicastclient 372
+#define T_Nic 373
+#define T_Nolink 374
+#define T_Nomodify 375
+#define T_Nomrulist 376
+#define T_None 377
+#define T_Nonvolatile 378
+#define T_Noepeer 379
+#define T_Nopeer 380
+#define T_Noquery 381
+#define T_Noselect 382
+#define T_Noserve 383
+#define T_Notrap 384
+#define T_Notrust 385
+#define T_Ntp 386
+#define T_Ntpport 387
+#define T_NtpSignDsocket 388
+#define T_Orphan 389
+#define T_Orphanwait 390
+#define T_PCEdigest 391
+#define T_Panic 392
+#define T_Peer 393
+#define T_Peerstats 394
+#define T_Phone 395
+#define T_Pid 396
+#define T_Pidfile 397
+#define T_Poll 398
+#define T_PollSkewList 399
+#define T_Pool 400
+#define T_Port 401
+#define T_PpsData 402
+#define T_Preempt 403
+#define T_Prefer 404
+#define T_Protostats 405
+#define T_Pw 406
+#define T_Randfile 407
+#define T_Rawstats 408
+#define T_Refid 409
+#define T_Requestkey 410
+#define T_Reset 411
+#define T_Restrict 412
+#define T_Revoke 413
+#define T_Rlimit 414
+#define T_Saveconfigdir 415
+#define T_Server 416
+#define T_Serverresponse 417
+#define T_ServerresponseFuzz 418
+#define T_Setvar 419
+#define T_Source 420
+#define T_Stacksize 421
+#define T_Statistics 422
+#define T_Stats 423
+#define T_Statsdir 424
+#define T_Step 425
+#define T_Stepback 426
+#define T_Stepfwd 427
+#define T_Stepout 428
+#define T_Stratum 429
+#define T_String 430
+#define T_Sys 431
+#define T_Sysstats 432
+#define T_Tick 433
+#define T_Time1 434
+#define T_Time2 435
+#define T_TimeData 436
+#define T_Timer 437
+#define T_Timingstats 438
+#define T_Tinker 439
+#define T_Tos 440
+#define T_Trap 441
+#define T_True 442
+#define T_Trustedkey 443
+#define T_Ttl 444
+#define T_Type 445
+#define T_U_int 446
+#define T_UEcrypto 447
+#define T_UEcryptonak 448
+#define T_UEdigest 449
+#define T_Unconfig 450
+#define T_Unpeer 451
+#define T_Version 452
+#define T_WanderThreshold 453
+#define T_Week 454
+#define T_Wildcard 455
+#define T_Xleave 456
+#define T_Xmtnonce 457
+#define T_Year 458
+#define T_Flag 459
+#define T_EOC 460
+#define T_Simulate 461
+#define T_Beep_Delay 462
+#define T_Sim_Duration 463
+#define T_Server_Offset 464
+#define T_Duration 465
+#define T_Freq_Offset 466
+#define T_Wander 467
+#define T_Jitter 468
+#define T_Prop_Delay 469
+#define T_Proc_Delay 470
 
 /* Value type.  */
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
 union YYSTYPE
 {
-#line 52 "../../../src/ntp-stable-3758/ntpd/ntp_parser.y"
+#line 52 "../../ntpd/ntp_parser.y"
 
 	char *			String;
 	double			Double;
@@ -510,7 +512,7 @@ union YYSTYPE
 	script_info *		Sim_script;
 	script_info_fifo *	Sim_script_fifo;
 
-#line 514 "../../../src/ntp-stable-3758/ntpd/ntp_parser.h"
+#line 516 "ntp_parser.h"
 
 };
 typedef union YYSTYPE YYSTYPE;
@@ -521,6 +523,8 @@ typedef union YYSTYPE YYSTYPE;
 
 extern YYSTYPE yylval;
 
+
 int yyparse (void);
 
-#endif /* !YY_YY__SRC_NTP_STABLE_NTPD_NTP_PARSER_H_INCLUDED  */
+
+#endif /* !YY_YY_NTP_PARSER_H_INCLUDED  */
diff --git a/contrib/ntp/ntpd/ntp_peer.c b/contrib/ntp/ntpd/ntp_peer.c
index c1716ffe0d83..69c1eff45822 100644
--- a/contrib/ntp/ntpd/ntp_peer.c
+++ b/contrib/ntp/ntpd/ntp_peer.c
@@ -39,7 +39,7 @@
 #define AM_MODES	7	/* number of rows and columns */
 #define NO_PEER		0	/* action when no peer is found */
 
-int AM[AM_MODES][AM_MODES] = {
+const s_char AM[AM_MODES][AM_MODES] = {
 /*			packet->mode					    */
 /* peer { UNSPEC,   ACTIVE,     PASSIVE,    CLIENT,     SERVER,     BCAST } */
 /* mode */
@@ -58,7 +58,7 @@ int AM[AM_MODES][AM_MODES] = {
 /*BCL*/ { AM_ERR, AM_NOMATCH, AM_NOMATCH, AM_NOMATCH, AM_NOMATCH,  AM_PROCPKT},
 };
 
-#define MATCH_ASSOC(x, y)	AM[(x)][(y)]
+#define MATCH_ASSOC(x, y) (AM[CLAMP((x), 0, AM_MODES)][CLAMP((y), 0, AM_MODES)])
 
 /*
  * These routines manage the allocation of memory to peer structures
@@ -91,8 +91,8 @@ int	peer_free_count;		/* count of free structures */
  * Association ID.  We initialize this value randomly, then assign a new
  * value every time an association is mobilized.
  */
-static associd_t current_association_ID; /* association ID */
-static associd_t initial_association_ID; /* association ID */
+static associd_t current_association_ID; /* actually next poss. ID */
+static associd_t initial_association_ID;
 
 /*
  * Memory allocation watermarks.
@@ -256,7 +256,7 @@ findexistingpeer_addr(
 
 
 /*
- * findexistingpeer - search by address and return a pointer to a peer.
+ * findexistingpeer - search by name+family or address.
  */
 struct peer *
 findexistingpeer(
@@ -294,7 +294,7 @@ findexistingpeer(
  * enough. Authentication alone does not help here, since it does not
  * protect the UDP layer and leaves us open for a replay attack.
  *
- * So we do not update the adresses and wait until the next interface
+ * So we do not update the addresses and wait until the next interface
  * list update does the right thing for us.
  */
 struct peer *
@@ -347,18 +347,20 @@ findpeer(
 		}
 
 		/* if an error was returned, exit back right here. */
-		if (*action == AM_ERR)
+		if (*action == AM_ERR) {
 			return NULL;
+		}
 
 		/* if a match is found, we stop our search. */
-		if (*action != AM_NOMATCH)
+		if (*action != AM_NOMATCH) {
 			break;
+		}
 	}
 
 	/* If no matching association is found... */
-	if (NULL == p)
+	if (NULL == p) {
 		*action = MATCH_ASSOC(NO_PEER, pkt_mode);
-
+	}
 	return p;
 }
 
@@ -542,7 +544,8 @@ unpeer(
 	)
 {
 	mprintf_event(PEVNT_DEMOBIL, peer, "assoc %u", peer->associd);
-	restrict_source(&peer->srcadr, 1, 0);
+	restrict_source(&peer->srcadr, TRUE, 0);
+	peer->flags |= FLAG_DISABLED;
 	set_peerdstadr(peer, NULL);
 	peer_demobilizations++;
 	peer_associations--;
@@ -644,6 +647,24 @@ set_peerdstadr(
 	if (p->dstadr == dstadr)
 		return;
 
+	/*
+	 * Do not change the local address of a link-local
+	 * peer address.
+	 */
+	if (   p->dstadr != NULL && is_linklocal(&p->dstadr->sin)
+	    && dstadr != NULL) {
+		return;
+	}
+
+	/*
+	 * Do not set the local address for a link-local IPv6 peer
+	 * to one with a different scope ID.
+	 */
+	if (   dstadr != NULL && IS_IPV6(&p->srcadr)
+	    && SCOPE(&dstadr->sin) != SCOPE(&p->srcadr)) {
+		return;
+	}
+
 	/*
 	 * Don't accept updates to a separate multicast receive-only
 	 * endpt while a BCLNT peer is running its unicast protocol.
@@ -658,11 +679,14 @@ set_peerdstadr(
 		p->dstadr->peercnt--;
 		UNLINK_SLIST(unlinked, p->dstadr->peers, p, ilink,
 			     struct peer);
+	}
+	if (   !IS_MCAST(&p->srcadr) && !(FLAG_DISABLED & p->flags)
+	    && !initializing) {
 		msyslog(LOG_INFO, "%s local addr %s -> %s",
-			stoa(&p->srcadr), latoa(p->dstadr),
-			latoa(dstadr));
+			stoa(&p->srcadr), eptoa(p->dstadr),
+			eptoa(dstadr));
 	}
-	
+
 	p->dstadr = dstadr;
 
 	/* link to list if we have an address after assignment */
@@ -741,14 +765,20 @@ refresh_all_peerinterfaces(void)
 	struct peer *p;
 
 	/*
-	 * this is called when the interface list has changed
-	 * give all peers a chance to find a better interface
-	 * but only if either they don't have an address already
-	 * or if the one they have hasn't worked for a while.
+	 * This is called when the interface list has changed.
+	 * Give peers a chance to find a better interface.
 	 */
 	for (p = peer_list; p != NULL; p = p->p_link) {
-		if (!(p->dstadr && (p->reach & 0x3)))	// Bug 2849 XOR 2043
-			peer_refresh_interface(p);
+		/* 
+		 * Bug 2849 XOR 2043
+		 * Change local address only if the peer doesn't
+		 * have a local address already or if the one
+		 * they have hasn't worked for a while.
+		 */
+		if (p->dstadr != NULL && (p->reach & 0x3)) {
+			continue;
+		}
+		peer_refresh_interface(p);
 	}
 }
 
@@ -777,7 +807,6 @@ newpeer(
 	u_int		hash;
 	int		ip_count = 0;
 
-
 	DEBUG_REQUIRE(srcadr);
 
 #ifdef AUTOKEY
@@ -789,7 +818,9 @@ newpeer(
 			return (NULL);
 
 		} else if (flags & FLAG_SKEY) {
-			msyslog(LOG_ERR, "Autokey not configured");
+			msyslog(LOG_ERR, "Rejecting Autokey with %s,"
+					 " built without support.",
+					 stoa(srcadr));
 			return (NULL);
 		} 
 	}
@@ -830,6 +861,26 @@ newpeer(
 					cast_flags, &ip_count);
 	}
 
+	/*
+	 * In any case, do not create an association with a duplicate
+	 * remote address (srcadr) except for undefined (zero) address.
+	 * Arguably this should be part of the logic above but
+	 * [Bug 3888] exposed a situation with manycastclient where
+	 * duplicate associations happened.
+	 */
+	if (NULL == peer) {
+		for (peer = peer_list;
+		     peer != NULL;
+		     peer = peer->p_link) {
+			if (   SOCK_EQ(srcadr, &peer->srcadr)
+			    && !SOCK_UNSPEC(srcadr)
+			    && !SOCK_UNSPEC(&peer->srcadr)) {
+				/* leave peer non-NULL */
+				break;
+			}
+		}
+	}
+
 	/*
 	 * If a peer is found, this would be a duplicate and we don't
 	 * allow that. This avoids duplicate ephemeral (broadcast/
@@ -837,7 +888,8 @@ newpeer(
 	 * associations.
 	 */
 	if (peer != NULL) {
-		DPRINTF(2, ("newpeer(%s) found existing association\n",
+		DPRINTF(2, ("%s(%s) found existing association\n",
+			__func__,
 			(hostname)
 			    ? hostname
 			    : stoa(srcadr)));
@@ -845,7 +897,7 @@ newpeer(
 	}
 
 #if 0
-DPRINTF(1, ("newpeer(%s) found no existing and %d other associations\n",
+	DPRINTF(1, ("newpeer(%s) found no existing and %d other associations\n",
 		(hostname)
 		    ? hostname
 		    : stoa(srcadr),
@@ -884,15 +936,19 @@ DPRINTF(1, ("newpeer(%s) found no existing and %d other associations\n",
 		peer_preempt++;
 
 	/*
-	 * Assign an association ID and increment the system variable.
+	 * Assign an available association ID.  Zero is reserved.
 	 */
+	do {
+		while (0 == ++current_association_ID) {
+			/* EMPTY */
+		}
+	} while (NULL != findpeerbyassoc(current_association_ID));
 	peer->associd = current_association_ID;
-	if (++current_association_ID == 0)
-		++current_association_ID;
 
 	peer->srcadr = *srcadr;
-	if (hostname != NULL)
+	if (hostname != NULL) {
 		peer->hostname = estrdup(hostname);
+	}
 	peer->hmode = hmode;
 	peer->version = version;
 	peer->flags = flags;
@@ -901,66 +957,67 @@ DPRINTF(1, ("newpeer(%s) found no existing and %d other associations\n",
 		       select_peerinterface(peer, srcadr, dstadr));
 
 	/*
-	 * It is an error to set minpoll less than NTP_MINPOLL or to
-	 * set maxpoll greater than NTP_MAXPOLL. However, minpoll is
-	 * clamped not greater than NTP_MAXPOLL and maxpoll is clamped
-	 * not less than NTP_MINPOLL without complaint. Finally,
-	 * minpoll is clamped not greater than maxpoll.
+	 * Zero for minpoll or maxpoll means use defaults.
 	 */
-	if (minpoll == 0)
-		peer->minpoll = NTP_MINDPOLL;
-	else
-		peer->minpoll = min(minpoll, NTP_MAXPOLL);
-	if (maxpoll == 0)
-		peer->maxpoll = NTP_MAXDPOLL;
-	else
-		peer->maxpoll = max(maxpoll, NTP_MINPOLL);
-	if (peer->minpoll > peer->maxpoll)
-		peer->minpoll = peer->maxpoll;
+	peer->maxpoll = (0 == maxpoll)
+			    ? NTP_MAXDPOLL
+			    : maxpoll;
+	peer->minpoll = (0 == minpoll)
+			    ? NTP_MINDPOLL
+			    : minpoll;
+
+	/*
+	 * Clamp maxpoll and minpoll within NTP_MINPOLL and NTP_MAXPOLL,
+	 * and further clamp minpoll less than or equal maxpoll.
+	 */
+	peer->maxpoll = CLAMP(peer->maxpoll, NTP_MINPOLL, NTP_MAXPOLL);
+	peer->minpoll = CLAMP(peer->minpoll, NTP_MINPOLL, peer->maxpoll);
 
-	if (peer->dstadr != NULL)
+	if (peer->dstadr != NULL) {
 		DPRINTF(3, ("newpeer(%s): using fd %d and our addr %s\n",
 			stoa(srcadr), peer->dstadr->fd,
 			stoa(&peer->dstadr->sin)));
-	else
-		DPRINTF(3, ("newpeer(%s): local interface currently not bound\n",
+	} else {
+		DPRINTF(3, ("newpeer(%s): local addr unavailable\n",
 			stoa(srcadr)));	
-
+	}
 	/*
 	 * Broadcast needs the socket enabled for broadcast
 	 */
-	if ((MDF_BCAST & cast_flags) && peer->dstadr != NULL)
+	if ((MDF_BCAST & cast_flags) && peer->dstadr != NULL) {
 		enable_broadcast(peer->dstadr, srcadr);
-
+	}
 	/*
 	 * Multicast needs the socket interface enabled for multicast
 	 */
-	if ((MDF_MCAST & cast_flags) && peer->dstadr != NULL)
+	if ((MDF_MCAST & cast_flags) && peer->dstadr != NULL) {
 		enable_multicast_if(peer->dstadr, srcadr);
-
+	}
 #ifdef AUTOKEY
 	if (key > NTP_MAXKEY)
 		peer->flags |= FLAG_SKEY;
 #endif	/* AUTOKEY */
 	peer->ttl = ttl;
 	peer->keyid = key;
-	if (ident != NULL)
+	if (ident != NULL) {
 		peer->ident = estrdup(ident);
+	}
 	peer->precision = sys_precision;
 	peer->hpoll = peer->minpoll;
-	if (cast_flags & MDF_ACAST)
+	if (cast_flags & MDF_ACAST) {
 		peer_clear(peer, "ACST");
-	else if (cast_flags & MDF_POOL)
+	} else if (cast_flags & MDF_POOL) {
 		peer_clear(peer, "POOL");
-	else if (cast_flags & MDF_MCAST)
+	} else if (cast_flags & MDF_MCAST) {
 		peer_clear(peer, "MCST");
-	else if (cast_flags & MDF_BCAST)
+	} else if (cast_flags & MDF_BCAST) {
 		peer_clear(peer, "BCST");
-	else
+	} else {
 		peer_clear(peer, "INIT");
-	if (mode_ntpdate)
+	}
+	if (mode_ntpdate) {
 		peer_ntpdate++;
-
+	}
 	/*
 	 * Note time on statistics timers.
 	 */
@@ -976,8 +1033,6 @@ DPRINTF(1, ("newpeer(%s) found no existing and %d other associations\n",
 		 * the peer timer, since the clock may have requirements
 		 * for this.
 		 */
-		if (maxpoll == 0)
-			peer->maxpoll = peer->minpoll;
 		if (!refclock_newpeer(peer)) {
 			/*
 			 * Dump it, something screwed up
@@ -1006,7 +1061,7 @@ DPRINTF(1, ("newpeer(%s) found no existing and %d other associations\n",
 	assoc_hash_count[hash]++;
 	LINK_SLIST(peer_list, peer, p_link);
 
-	restrict_source(&peer->srcadr, 0, 0);
+	restrict_source(&peer->srcadr, FALSE, 0);
 	mprintf_event(PEVNT_MOBIL, peer, "assoc %d", peer->associd);
 	DPRINTF(1, ("newpeer: %s->%s mode %u vers %u poll %u %u flags 0x%x 0x%x ttl %u key %08x\n",
 	    latoa(peer->dstadr), stoa(&peer->srcadr), peer->hmode,
@@ -1093,8 +1148,9 @@ findmanycastpeer(
 	for (peer = peer_list; peer != NULL; peer = peer->p_link)
 		if (MDF_SOLICIT_MASK & peer->cast_flags) {
 			NTOHL_FP(&pkt->org, &p_org);
-			if (L_ISEQU(&p_org, &peer->aorg))
+			if (L_ISEQU(&p_org, &peer->aorg)) {
 				break;
+			}
 		}
 
 	return peer;
@@ -1103,17 +1159,11 @@ findmanycastpeer(
 /* peer_cleanup - clean peer list prior to shutdown */
 void peer_cleanup(void)
 {
-        struct peer *peer;
-        associd_t assoc;
-
-        for (assoc = initial_association_ID; assoc != current_association_ID; assoc++) {
-            if (assoc != 0U) {
-                peer = findpeerbyassoc(assoc);
-                if (peer != NULL)
-                    unpeer(peer);
-            }
-        }
-        peer = findpeerbyassoc(current_association_ID);
-        if (peer != NULL)
-            unpeer(peer);
+	struct peer *peer;
+	struct peer *nextpeer;
+
+	for (peer = peer_list; peer != NULL; peer = nextpeer) {
+		nextpeer = peer->p_link;
+		unpeer(peer);
+	}
 }
diff --git a/contrib/ntp/ntpd/ntp_proto.c b/contrib/ntp/ntpd/ntp_proto.c
index f2c59238432a..170294c68bb6 100644
--- a/contrib/ntp/ntpd/ntp_proto.c
+++ b/contrib/ntp/ntpd/ntp_proto.c
@@ -17,7 +17,6 @@
 #include "ntp_leapsec.h"
 #include "ntp_psl.h"
 #include "refidsmear.h"
-#include "lib_strbuf.h"
 
 #include <stdio.h>
 #ifdef HAVE_LIBSCF_H
@@ -35,9 +34,9 @@
 #define SRVFUZ_SHIFT	6	/* 64 seconds */
 #define SRVRSP_FUZZ(x)					\
 	do {						\
-		x.l_uf &= 0;				\
+		x.l_uf = 0;				\
 		x.l_ui &= ~((1 << SRVFUZ_SHIFT) - 1U);	\
-	} while(0)
+	} while (FALSE)
 
 /*
  * This macro defines the authentication state. If x is 1 authentication
@@ -472,7 +471,16 @@ transmit(
 		return;
 	}
 
-	/*
+	/* [Bug 3851] drop pool servers which can no longer be reached. */
+	if (MDF_PCLNT & peer->cast_flags) {
+		if (   (IS_IPV6(&peer->srcadr) && !nonlocal_v6_addr_up)
+		    || !nonlocal_v4_addr_up) {
+			unpeer(peer);
+			return;
+		}
+	}
+
+	 /*
 	 * In unicast modes the dance is much more intricate. It is
 	 * designed to back off whenever possible to minimize network
 	 * traffic.
@@ -584,6 +592,7 @@ transmit(
 }
 
 
+#ifdef DEBUG
 const char *
 amtoa(
 	int am
@@ -607,6 +616,7 @@ amtoa(
 		return bp;
 	}
 }
+#endif	/* DEBUG */
 
 
 /*
@@ -626,7 +636,6 @@ receive(
 	r4addr	r4a;			/* address restrictions */
 	u_short	restrict_mask;		/* restrict bits */
 	const char *hm_str;		/* hismode string */
-	const char *am_str;		/* association match string */
 	int	kissCode = NOKISS;	/* Kiss Code */
 	int	has_mac;		/* length of MAC field */
 	int	authlen;		/* offset of MAC field */
@@ -636,11 +645,15 @@ receive(
 	keyid_t	skeyid = 0;		/* key IDs */
 	u_int32	opcode = 0;		/* extension field opcode */
 	sockaddr_u *dstadr_sin;		/* active runway */
+	u_char	cast_flags;		/* MDF_* flags for newpeer() */
 	struct peer *peer2;		/* aux peer structure pointer */
 	endpt	*match_ep;		/* newpeer() local address */
 	l_fp	p_org;			/* origin timestamp */
 	l_fp	p_rec;			/* receive timestamp */
 	l_fp	p_xmt;			/* transmit timestamp */
+#ifdef DEBUG
+	const char *am_str;		/* association match string */
+#endif
 #ifdef AUTOKEY
 	char	hostname[NTP_MAXSTRLEN + 1];
 	char	*groupname = NULL;
@@ -689,12 +702,11 @@ receive(
 	}
 	if (hismode == MODE_PRIVATE) {
 		if (!ntp_mode7 || (restrict_mask & RES_NOQUERY)) {
-			DPRINTF(2, ("receive: drop: RES_NOQUERY\n"));
+			DPRINTF(2, ("receive: drop: !mode7 or RES_NOQUERY\n"));
 			sys_restricted++;
 			return;			/* no query private */
 		}
-		process_private(rbufp, ((restrict_mask &
-		    RES_NOMODIFY) == 0));
+		process_private(rbufp, !(RES_NOMODIFY & restrict_mask));
 		return;
 	}
 	if (hismode == MODE_CONTROL) {
@@ -725,14 +737,14 @@ receive(
 	
 	hisleap = PKT_LEAP(pkt->li_vn_mode);
 	hisstratum = PKT_TO_STRATUM(pkt->stratum);
-	INSIST(0 != hisstratum); /* paranoia check PKT_TO_STRATUM result */
-
+	DEBUG_INSIST(0 != hisstratum);	/* paranoia check PKT_TO_STRATUM result */
+					/* TODO: this should be in a unit test */
 	DPRINTF(1, ("receive: at %ld %s<-%s ippeerlimit %d mode %d iflags %s "
-		    "restrict %s org %#010x.%08x xmt %#010x.%08x\n",
+		    "restrict %s org 0x%x.%08x xmt 0x%x.%08x\n",
 		    current_time, stoa(&rbufp->dstadr->sin),
 		    stoa(&rbufp->recv_srcadr), r4a.ippeerlimit, hismode,
-		    build_iflags(rbufp->dstadr->flags),
-		    build_rflags(restrict_mask),
+		    iflags_str(rbufp->dstadr->flags),
+		    rflags_str(restrict_mask),
 		    ntohl(pkt->org.l_ui), ntohl(pkt->org.l_uf),
 		    ntohl(pkt->xmt.l_ui), ntohl(pkt->xmt.l_uf)));
 
@@ -807,10 +819,15 @@ receive(
 	        || (NTP_MAXPOLL < pkt->ppoll)
 	       )
 	   ) {
+#ifdef BUG3870
 		DPRINTF(2, ("receive: drop: Invalid ppoll (%d) from %s\n",
 				pkt->ppoll, stoa(&rbufp->recv_srcadr)));
 		sys_badlength++;
 		return;			/* invalid packet poll */
+#else
+		DPRINTF(2, ("receive: info: Invalid ppoll (%d) from %s\n",
+				pkt->ppoll, stoa(&rbufp->recv_srcadr)));
+#endif
 	}
 
 	/*
@@ -987,7 +1004,9 @@ receive(
 	NTOHL_FP(&pkt->rec, &p_rec);
 	NTOHL_FP(&pkt->xmt, &p_xmt);
 	hm_str = modetoa(hismode);
+#ifdef DEBUG
 	am_str = amtoa(retcode);
+#endif
 
 	/*
 	 * Authentication is conditioned by three switches:
@@ -1030,7 +1049,7 @@ receive(
 	if (has_mac == 0) {
 		restrict_mask &= ~RES_MSSNTP;
 		is_authentic = AUTH_NONE; /* not required */
-		DPRINTF(1, ("receive: at %ld %s<-%s mode %d/%s:%s len %d org %#010x.%08x xmt %#010x.%08x NOMAC\n",
+		DPRINTF(1, ("receive: at %ld %s<-%s mode %d/%s:%s len %d org 0x%x.%08x xmt 0x%x.%08x NOMAC\n",
 			    current_time, stoa(dstadr_sin),
 			    stoa(&rbufp->recv_srcadr), hismode, hm_str, am_str,
 			    authlen,
@@ -1039,7 +1058,7 @@ receive(
 	} else if (crypto_nak_test == VALIDNAK) {
 		restrict_mask &= ~RES_MSSNTP;
 		is_authentic = AUTH_CRYPTO; /* crypto-NAK */
-		DPRINTF(1, ("receive: at %ld %s<-%s mode %d/%s:%s keyid %08x len %d auth %d org %#010x.%08x xmt %#010x.%08x CRYPTONAK\n",
+		DPRINTF(1, ("receive: at %ld %s<-%s mode %d/%s:%s keyid %08x len %d auth %d org 0x%x.%08x xmt 0x%x.%08x CRYPTONAK\n",
 			    current_time, stoa(dstadr_sin),
 			    stoa(&rbufp->recv_srcadr), hismode, hm_str, am_str,
 			    skeyid, authlen + has_mac, is_authentic,
@@ -1062,7 +1081,7 @@ receive(
 		   && (memcmp(zero_key, (char *)pkt + authlen + 4,
 			      MAX_MD5_LEN - 4) == 0)) {
 		is_authentic = AUTH_NONE;
-		DPRINTF(1, ("receive: at %ld %s<-%s mode %d/%s:%s len %d org %#010x.%08x xmt %#010x.%08x SIGND\n",
+		DPRINTF(1, ("receive: at %ld %s<-%s mode %d/%s:%s len %d org %x.%08x xmt %x.%08x SIGND\n",
 			    current_time, stoa(dstadr_sin),
 			    stoa(&rbufp->recv_srcadr), hismode, hm_str, am_str,
 			    authlen,
@@ -1185,7 +1204,7 @@ receive(
 		if (crypto_flags && skeyid > NTP_MAXKEY)
 			authtrust(skeyid, 0);
 #endif	/* AUTOKEY */
-		DPRINTF(1, ("receive: at %ld %s<-%s mode %d/%s:%s keyid %08x len %d auth %d org %#010x.%08x xmt %#010x.%08x MAC\n",
+		DPRINTF(1, ("receive: at %ld %s<-%s mode %d/%s:%s keyid %08x len %d auth %d org 0x%x.%08x xmt 0x%x.%08x MAC\n",
 			    current_time, stoa(dstadr_sin),
 			    stoa(&rbufp->recv_srcadr), hismode, hm_str, am_str,
 			    skeyid, authlen + has_mac, is_authentic,
@@ -1358,13 +1377,29 @@ receive(
 		if (   sys_leap == LEAP_NOTINSYNC
 		    || sys_stratum >= hisstratum
 		    || (!sys_cohort && sys_stratum == hisstratum + 1)
-		    || rbufp->dstadr->addr_refid == pkt->refid) {
+		    || rbufp->dstadr->addr_refid == pkt->refid
+#	    ifdef WORDS_BIGENDIAN	/* see local_refid() comment */
+		    || (   IS_IPV6(&rbufp->dstadr->sin)
+			&&rbufp->dstadr->old_refid ==  pkt->refid)
+#	    endif
+								  ) {
 			DPRINTF(2, ("receive: sys leap: %0x, sys_stratum %d > hisstratum+1 %d, !sys_cohort %d && sys_stratum == hisstratum+1, loop refid %#x == pkt refid %#x\n", sys_leap, sys_stratum, hisstratum + 1, !sys_cohort, rbufp->dstadr->addr_refid, pkt->refid));
 			DPRINTF(2, ("receive: AM_FXMIT drop: LEAP_NOTINSYNC || stratum || loop\n"));
 			sys_declined++;
 			return;			/* no help */
 		}
 
+		/*
+		 * Do not respond if the packet came into an IPv6 link-local
+		 * address on an interface where we also have a usable
+		 * global address, to avoid duplicate associations.
+		 */
+		if (INT_LL_OF_GLOB & rbufp->dstadr->flags) {
+			DPRINTF(2, ("receive: declining manycast solicitation on link-local IPv6\n"));
+			sys_declined++;
+			return;
+		}
+
 		/*
 		 * Respond only if authentication succeeds. Don't do a
 		 * crypto-NAK, as that would not be useful.
@@ -1423,6 +1458,12 @@ receive(
 			return;
 		}
 #endif /* AUTOKEY */
+		/* Do not spin up duplicate manycast associations */
+		if (INT_LL_OF_GLOB & rbufp->dstadr->flags) {
+			DPRINTF(2, ("receive: AM_MANYCAST drop: link-local server\n"));
+			sys_declined++;
+			return;
+		}
 		if ((peer2 = findmanycastpeer(rbufp)) == NULL) {
 			DPRINTF(2, ("receive: AM_MANYCAST drop: No manycast peer\n"));
 			sys_restricted++;
@@ -1450,11 +1491,15 @@ receive(
 			sys_declined++;
 			return;			/* no help */
 		}
+		cast_flags = MDF_UCAST;
+		if (MDF_POOL & peer2->cast_flags) {
+			cast_flags |= MDF_PCLNT;
+		}
 		peer = newpeer(&rbufp->recv_srcadr, NULL, rbufp->dstadr,
 			       r4a.ippeerlimit, MODE_CLIENT, hisversion,
 			       peer2->minpoll, peer2->maxpoll,
 			       (FLAG_PREEMPT | (POOL_FLAG_PMASK & peer2->flags)),
-			       (MDF_UCAST | MDF_UCLNT), 0, skeyid, sys_ident);
+			       cast_flags, 0, skeyid, sys_ident);
 		if (NULL == peer) {
 			DPRINTF(2, ("receive: AM_MANYCAST drop: duplicate\n"));
 			sys_declined++;
@@ -1840,7 +1885,7 @@ receive(
 			if (   tdiff.l_i < 0
 			    && (current_time - peer->timereceived) < deadband)
 			{
-				msyslog(LOG_INFO, "receive: broadcast packet from %s contains non-monotonic timestamp: %#010x.%08x -> %#010x.%08x",
+				msyslog(LOG_INFO, "receive: broadcast packet from %s contains non-monotonic timestamp: 0x%x.%08x -> 0x%x.%08x",
 					stoa(&rbufp->recv_srcadr),
 					peer->bxmt.l_ui, peer->bxmt.l_uf,
 					p_xmt.l_ui, p_xmt.l_uf
@@ -1991,7 +2036,7 @@ receive(
 		if (peer->flip == 0 && !L_ISEQU(&p_org, &peer->aorg)) {
 			peer->bogusorg++;
 			msyslog(LOG_INFO,
-				"receive: flip 0 KoD origin timestamp %#010x.%08x from %s does not match %#010x.%08x - ignoring.",
+				"receive: flip 0 KoD origin timestamp 0x%x.%08x from %s does not match 0x%x.%08x - ignoring.",
 				p_org.l_ui, p_org.l_uf,
 				ntoa(&peer->srcadr),
 				peer->aorg.l_ui, peer->aorg.l_uf);
@@ -1999,7 +2044,7 @@ receive(
 		} else if (peer->flip == 1 && !L_ISEQU(&p_org, &peer->borg)) {
 			peer->bogusorg++;
 			msyslog(LOG_INFO,
-				"receive: flip 1 KoD origin timestamp %#010x.%08x from %s does not match interleave %#010x.%08x - ignoring.",
+				"receive: flip 1 KoD origin timestamp 0x%x.%08x from %s does not match interleave 0x%x.%08x - ignoring.",
 				p_org.l_ui, p_org.l_uf,
 				ntoa(&peer->srcadr),
 				peer->borg.l_ui, peer->borg.l_uf);
@@ -2033,9 +2078,14 @@ receive(
 		/* XXX: FLAG_LOOPNONCE */
 		DEBUG_INSIST(0 == (FLAG_LOOPNONCE & peer->flags));
 
-		msyslog(LOG_INFO,
-			"receive: Got KoD %s from %s",
-			refid_str(pkt->refid, hisstratum), ntoa(&peer->srcadr));
+		if (RATEKISS == kissCode) {
+			msyslog(LOG_INFO, "RATE KoD from %s poll %u",
+				ntoa(&peer->srcadr), 1u << pkt->ppoll);
+		} else {
+			msyslog(LOG_INFO, "KoD %s from %s",
+				refid_str(pkt->refid, -1),
+				ntoa(&peer->srcadr));
+		}
 	} else if (peer->flip == 0) {
 		if (0) {
 		} else if (L_ISZERO(&p_org)) {
@@ -2049,11 +2099,11 @@ receive(
 #endif
 			/**/
 			switch (hismode) {
-			/* We allow 0org for: */
+				/* We allow 0org for: */
 			    case UCHAR_MAX:
 				action = "Allow";
 				break;
-			/* We disallow 0org for: */
+				/* We disallow 0org for: */
 			    case MODE_UNSPEC:
 			    case MODE_ACTIVE:
 			    case MODE_PASSIVE:
@@ -2071,20 +2121,22 @@ receive(
 			}
 			/**/
 			msyslog(LOG_INFO,
-				"receive: %s 0 origin timestamp from %s@%s xmt %#010x.%08x",
+				"receive: %s 0 origin timestamp from %s@%s xmt 0x%x.%08x",
 				action, hm_str, ntoa(&peer->srcadr),
 				ntohl(pkt->xmt.l_ui), ntohl(pkt->xmt.l_uf));
+		} else if (   L_ISZERO(&peer->aorg) && MODE_CLIENT != hismode
+			   && !memcmp("STEP", &peer->refid, 4)) {
+			/* response came in just after we stepped clock, normal */
 		} else if (!L_ISEQU(&p_org, &peer->aorg)) {
 			/* are there cases here where we should bail? */
 			/* Should we set TEST2 if we decide to try xleave? */
 			peer->bogusorg++;
 			peer->flash |= TEST2;	/* bogus */
-			msyslog(LOG_INFO,
-				"receive: Unexpected origin timestamp %#010x.%08x does not match aorg %#010x.%08x from %s@%s xmt %#010x.%08x",
+			msyslog(LOG_INFO, 
+				"duplicate or replay: org 0x%x.%08x does not match 0x%x.%08x from %s@%s",
 				ntohl(pkt->org.l_ui), ntohl(pkt->org.l_uf),
 				peer->aorg.l_ui, peer->aorg.l_uf,
-				hm_str, ntoa(&peer->srcadr),
-				ntohl(pkt->xmt.l_ui), ntohl(pkt->xmt.l_uf));
+				hm_str, ntoa(&peer->srcadr));
 			if (  !L_ISZERO(&peer->dst)
 			    && L_ISEQU(&p_org, &peer->dst)) {
 				/* Might be the start of an interleave */
@@ -2474,8 +2526,10 @@ receive(
 	 * more flashers. Leave if the packet is not good.
 	 */
 	process_packet(peer, pkt, rbufp->recv_length);
-	if (peer->flash & PKT_TEST_MASK)
+	/* Bug 2734: TEST3 prevents initial interleave sync */
+	if ((~TEST3 & peer->flash) & PKT_TEST_MASK) {
 		return;
+	}
 
 	/* [bug 3592] Update poll. Ideally this should not happen in a
 	 * receive branch, but too much is going on here... at least we
@@ -2516,7 +2570,6 @@ process_packet(
 	double	p_offset, p_del, p_disp;
 	l_fp	p_rec, p_xmt, p_org, p_reftime, ci;
 	u_char	pmode, pleap, pversion, pstratum;
-	char	statstr[NTP_MAXSTRLEN];
 #ifdef ASSYM
 	int	itemp;
 	double	etemp, ftemp, td;
@@ -2652,9 +2705,8 @@ process_packet(
 		p_del = t21 - t34;
 		p_offset = (t21 + t34) / 2.;
 		if (p_del < 0 || p_del > 1.) {
-			snprintf(statstr, sizeof(statstr),
-			    "t21 %.6f t34 %.6f", t21, t34);
-			report_event(PEVNT_XERR, peer, statstr);
+			mprintf_event(PEVNT_XERR, peer,
+				      "t21 %.9f t34 %.9f", t21, t34);
 			return;
 		}
 
@@ -2680,9 +2732,9 @@ process_packet(
 				/* drop all if in the initial volley */
 				if (FLAG_BC_VOL & peer->flags)
 					goto bcc_init_volley_fail;
-				snprintf(statstr, sizeof(statstr),
-				    "offset %.6f delay %.6f", t21, t34);
-				report_event(PEVNT_XERR, peer, statstr);
+				mprintf_event(PEVNT_XERR, peer,
+					      "offset %.9f delay %.9f",
+					      t21, t34);
 				return;
 			}
 			p_offset = t21;
@@ -2981,20 +3033,6 @@ clock_update(
 			if (crypto_flags)
 				crypto_update();
 #endif	/* AUTOKEY */
-			/*
-			 * If our parent process is waiting for the
-			 * first clock sync, send them home satisfied.
-			 */
-#ifdef HAVE_WORKING_FORK
-			if (daemon_pipe[1] != -1) {
-				if (2 != write(daemon_pipe[1], "S\n", 2)) {
-					msyslog(LOG_ERR, "daemon failed to notify parent ntpd (--wait-sync)");
-				}
-				close(daemon_pipe[1]);
-				daemon_pipe[1] = -1;
-				DPRINTF(1, ("notified parent --wait-sync is done\n"));
-			}
-#endif /* HAVE_WORKING_FORK */
 
 		}
 
@@ -3150,7 +3188,7 @@ poll_update(
 
 				if (   0 != sub
 				    || 0 != qty) {
-				    	do {
+					do {
 						val = ntp_random() & msk;
 					} while (val > qty);
 
@@ -3193,8 +3231,9 @@ peer_clear(
 	const char *ident		/* tally lights */
 	)
 {
-	u_char	u;
-	l_fp	bxmt = peer->bxmt;	/* bcast clients retain this! */
+	static u_long	earliest;
+	u_char		u;
+	l_fp		bxmt = peer->bxmt;	/* bcast clients retain this! */
 
 #ifdef AUTOKEY
 	/*
@@ -3271,6 +3310,11 @@ peer_clear(
 		peer->nextdate += peer_associations;
 	} else if (!(FLAG_CONFIG & peer->flags)) {
 		peer->nextdate += ntp_minpkt + 1;
+		/* space out manycastclient first polls */
+		if (peer->nextdate < earliest) {
+			peer->nextdate = earliest;
+		}
+		earliest = peer->nextdate + 1;
 	} else {
 		peer->nextdate += ntp_random() % (1 << peer->minpoll);
 	}
@@ -3296,10 +3340,10 @@ clock_filter(
 	)
 {
 	double	dst[NTP_SHIFT];		/* distance vector */
-	int	ord[NTP_SHIFT];		/* index vector */
-	int	i, j, k, m;
+	u_char	ord[NTP_SHIFT];		/* index vector */
+	short	i, j;
+	u_char	k, m;
 	double	dtemp, etemp;
-	char	tbuf[80];
 
 	/*
 	 * A sample consists of the offset, delay, dispersion and epoch
@@ -3316,7 +3360,7 @@ clock_filter(
 	peer->filter_disp[j] = sample_disp;
 	peer->filter_epoch[j] = current_time;
 	j = (j + 1) % NTP_SHIFT;
-	peer->filter_nextpt = j;
+	peer->filter_nextpt = (u_char)j;
 
 	/*
 	 * Update dispersions since the last update and at the same
@@ -3344,7 +3388,7 @@ clock_filter(
 		} else {
 			dst[i] = peer->filter_delay[j];
 		}
-		ord[i] = j;
+		ord[i] = (u_char)j;
 		j = (j + 1) % NTP_SHIFT;
 	}
 
@@ -3377,7 +3421,7 @@ clock_filter(
 	 */
 	m = 0;
 	for (i = 0; i < NTP_SHIFT; i++) {
-		peer->filter_order[i] = (u_char) ord[i];
+		peer->filter_order[i] = ord[i];
 		if (   dst[i] >= MAXDISPERSE
 		    || (m >= 2 && dst[i] >= sys_maxdist))
 			continue;
@@ -3394,11 +3438,12 @@ clock_filter(
 	k = ord[0];
 	for (i = NTP_SHIFT - 1; i >= 0; i--) {
 		j = ord[i];
-		peer->disp = NTP_FWEIGHT * (peer->disp +
-		    peer->filter_disp[j]);
-		if (i < m)
+		peer->disp = NTP_FWEIGHT * (  peer->disp
+					    + peer->filter_disp[j]);
+		if (i < m) {
 			peer->jitter += DIFF(peer->filter_offset[j],
-			    peer->filter_offset[k]);
+					     peer->filter_offset[k]);
+		}
 	}
 
 	/*
@@ -3407,15 +3452,16 @@ clock_filter(
 	 * save the offset, delay and jitter. Note the jitter must not
 	 * be less than the precision.
 	 */
-	if (m == 0) {
+	if (0 == m) {
 		clock_select();
 		return;
 	}
 	etemp = fabs(peer->offset - peer->filter_offset[k]);
 	peer->offset = peer->filter_offset[k];
 	peer->delay = peer->filter_delay[k];
-	if (m > 1)
+	if (m > 1) {
 		peer->jitter /= m - 1;
+	}
 	peer->jitter = max(SQRT(peer->jitter), LOGTOD(sys_precision));
 
 	/*
@@ -3428,23 +3474,22 @@ clock_filter(
 	if (   peer->disp < sys_maxdist
 	    && peer->filter_disp[k] < sys_maxdist
 	    && etemp > CLOCK_SGATE * peer->jitter
-	    && peer->filter_epoch[k] - peer->epoch
+	    &&   peer->filter_epoch[k] - peer->epoch
 	       < 2. * ULOGTOD(peer->hpoll)) {
-		snprintf(tbuf, sizeof(tbuf), "%.6f s", etemp);
-		report_event(PEVNT_POPCORN, peer, tbuf);
+		mprintf_event(PEVNT_POPCORN, peer, "%.9f s", etemp);
 		return;
 	}
 
 	/*
 	 * A new minimum sample is useful only if it is later than the
 	 * last one used. In this design the maximum lifetime of any
-	 * sample is not greater than eight times the poll interval, so
-	 * the maximum interval between minimum samples is eight
-	 * packets.
+	 * sample is not greater than NTP_SHIFT (8) times the poll
+	 * interval, so the maximum interval between minimum samples is
+	 * NTP_SHIFT packets.
 	 */
 	if (peer->filter_epoch[k] <= peer->epoch) {
-	DPRINTF(2, ("clock_filter: old sample %lu\n", current_time -
-		    peer->filter_epoch[k]));
+		DPRINTF(2, ("clock_filter: old sample %lu s\n",
+			    current_time - peer->filter_epoch[k]));
 		return;
 	}
 	peer->epoch = peer->filter_epoch[k];
@@ -3454,13 +3499,14 @@ clock_filter(
 	 * processing. If not synchronized or not in a burst, tickle the
 	 * clock select algorithm.
 	 */
-	record_peer_stats(&peer->srcadr, ctlpeerstatus(peer),
-	    peer->offset, peer->delay, peer->disp, peer->jitter);
-	DPRINTF(1, ("clock_filter: n %d off %.6f del %.6f dsp %.6f jit %.6f\n",
-		    m, peer->offset, peer->delay, peer->disp,
+	record_peer_stats(&peer->srcadr, ctlpeerstatus(peer), peer->offset,
+			  peer->delay, peer->disp, peer->jitter);
+	DPRINTF(1, ("clock_filter: n %hu off %.9f del %.9f dsp %.9f jit %.9f\n",
+		    (u_short)m, peer->offset, peer->delay, peer->disp,
 		    peer->jitter));
-	if (peer->burst == 0 || sys_leap == LEAP_NOTINSYNC)
+	if (0 == peer->burst || LEAP_NOTINSYNC == sys_leap) {
 		clock_select();
+	}
 }
 
 
@@ -3854,7 +3900,7 @@ clock_select(void)
 		    || ((FLAG_TRUE | FLAG_PREFER) & peers[k].peer->flags))
 			break;
 
-		DPRINTF(3, ("select: drop %s seljit %.6f jit %.6f\n",
+		DPRINTF(3, ("select: drop %s seljit %.9f jit %.9f\n",
 			ntoa(&peers[k].peer->srcadr), g, d));
 		if (nlist > sys_maxclock)
 			peers[k].peer->new_status = CTL_PST_SEL_EXCESS;
@@ -3933,13 +3979,13 @@ clock_select(void)
 			sys_clockhop = 0;
 		} else if ((x = fabs(typesystem->offset -
 		    osys_peer->offset)) < sys_mindisp) {
-			if (sys_clockhop == 0)
+			if (0 == sys_clockhop)
 				sys_clockhop = sys_mindisp;
 			else
 				sys_clockhop *= .5;
-			DPRINTF(1, ("select: clockhop %d %.6f %.6f\n",
+			DPRINTF(1, ("select: clockhop %d %.9f %.9f\n",
 				j, x, sys_clockhop));
-			if (fabs(x) < sys_clockhop)
+			if (x < sys_clockhop)
 				typesystem = osys_peer;
 			else
 				sys_clockhop = 0;
@@ -4108,9 +4154,9 @@ peer_xmit(
 	keyid_t	xkeyid = 0;	/* transmit key ID */
 	l_fp	xmt_tx, xmt_ty;
 
-	if (!peer->dstadr)	/* drop peers without interface */
+	if (!peer->dstadr) {	/* can't send */
 		return;
-
+	}
 	xpkt.li_vn_mode = PKT_LI_VN_MODE(sys_leap, peer->version,
 	    peer->hmode);
 	xpkt.stratum = STRATUM_TO_PKT(sys_stratum);
@@ -4188,9 +4234,8 @@ peer_xmit(
 		}
 		L_SUB(&xmt_ty, &xmt_tx);
 		LFPTOD(&xmt_ty, peer->xleave);
-		DPRINTF(1, ("peer_xmit: at %ld %s->%s mode %d len %zu xmt %#010x.%08x\n",
-			    current_time,
-			    peer->dstadr ? stoa(&peer->dstadr->sin) : "-",
+		DPRINTF(1, ("peer_xmit: at %ld %s->%s mode %d len %zu xmt 0x%x.%08x\n",
+			    current_time, latoa(peer->dstadr),
 			    stoa(&peer->srcadr), peer->hmode, sendlen,
 			    xmt_tx.l_ui, xmt_tx.l_uf));
 		return;
@@ -4477,8 +4522,8 @@ peer_xmit(
 		authtrust(xkeyid, 0);
 #endif	/* AUTOKEY */
 	if (sendlen > sizeof(xpkt)) {
-		msyslog(LOG_ERR, "peer_xmit: buffer overflow %zu", sendlen);
-		exit (-1);
+		msyslog(LOG_ERR, "peer_xmit: buffer overflow %u", (u_int)sendlen);
+		exit(EX_SOFTWARE);
 	}
 	peer->t21_bytes = sendlen;
 	sendpkt(&peer->srcadr, peer->dstadr,
@@ -4502,9 +4547,8 @@ peer_xmit(
 	LFPTOD(&xmt_ty, peer->xleave);
 #ifdef AUTOKEY
 	DPRINTF(1, ("peer_xmit: at %ld %s->%s mode %d keyid %08x len %zu index %d\n",
-		    current_time, latoa(peer->dstadr),
-		    ntoa(&peer->srcadr), peer->hmode, xkeyid, sendlen,
-		    peer->keynumber));
+		    current_time, latoa(peer->dstadr), stoa(&peer->srcadr),
+		    peer->hmode, xkeyid, sendlen, peer->keynumber));
 #else	/* !AUTOKEY follows */
 	DPRINTF(1, ("peer_xmit: at %ld %s->%s mode %d keyid %08x len %zu\n",
 		    current_time, peer->dstadr ?
@@ -4543,14 +4587,14 @@ leap_smear_add_offs(
  */
 static void
 fast_xmit(
-	struct recvbuf *rbufp,	/* receive packet pointer */
+	struct recvbuf* rbufp,	/* receive packet pointer */
 	int	xmode,		/* receive mode */  /* XXX: HMS: really? */
 	keyid_t	xkeyid,		/* transmit key ID */
 	int	flags		/* restrict mask */
-	)
+)
 {
 	struct pkt xpkt;	/* transmit packet structure */
-	struct pkt *rpkt;	/* receive packet structure */
+	struct pkt* rpkt;	/* receive packet structure */
 	l_fp	xmt_tx, xmt_ty;
 	size_t	sendlen;
 #ifdef AUTOKEY
@@ -4564,13 +4608,26 @@ fast_xmit(
 	 * the system minimum poll (ntp_minpoll). This is for KoD rate
 	 * control and not strictly specification compliant, but doesn't
 	 * break anything.
-	 *
-	 * If the gazinta was from a multicast address, the gazoutta
-	 * must go out another way.
 	 */
 	rpkt = &rbufp->recv_pkt;
-	if (rbufp->dstadr->flags & INT_MCASTOPEN)
+	/*
+	 * If the packet was received on an endpoint open only on
+	 * a multicast address, the response needs to go out from
+	 * a unicast endpoint.
+	 */
+#ifndef MULTICAST_NONEWSOCKET
+	if (rbufp->dstadr->flags & INT_MCASTOPEN) {
 		rbufp->dstadr = findinterface(&rbufp->recv_srcadr);
+		if (NULL == rbufp->dstadr ||
+		    ANY_INTERFACE_CHOOSE(&rbufp->recv_srcadr) /* wildcard */
+		      == rbufp->dstadr) {
+			DPRINTF(2, ("No unicast local address found for"
+				    " reply to %s mcast.",
+				    stoa(&rbufp->recv_srcadr)));
+			return;
+		}
+	}
+#endif
 
 	/*
 	 * If this is a kiss-o'-death (KoD) packet, show leap
@@ -4802,15 +4859,14 @@ pool_xmit(
 	)
 {
 #ifdef WORKER
-	struct pkt		xpkt;	/* transmit packet structure */
-	struct addrinfo		hints;
-	int			rc;
-	struct interface *	lcladr;
-	sockaddr_u *		rmtadr;
-	r4addr			r4a;
-	u_short			restrict_mask;
-	struct peer *		p;
-	l_fp			xmt_tx;
+	struct pkt	xpkt;	/* transmit packet structure */
+	struct addrinfo	hints;
+	int		rc;
+	endpt *		lcladr;
+	sockaddr_u *	rmtadr;
+	u_short		af;
+	struct peer *	p;
+	l_fp		xmt_tx;
 
 	DEBUG_REQUIRE(pool);
 	if (NULL == pool->ai) {
@@ -4819,6 +4875,16 @@ pool_xmit(
 			free(pool->addrs);
 			pool->addrs = NULL;
 		}
+		af = AF(&pool->srcadr);
+		if (   (AF_INET == af && !nonlocal_v4_addr_up)
+		    || (AF_INET6 == af && !nonlocal_v6_addr_up)
+		    || (   AF_UNSPEC == af
+			&& !nonlocal_v4_addr_up
+			&& !nonlocal_v6_addr_up)) {
+
+			/* POOL DNS query would be useless [Bug 3845] */
+			return;
+		}
 		ZERO(hints);
 		hints.ai_family = AF(&pool->srcadr);
 		hints.ai_socktype = SOCK_DGRAM;
@@ -4845,15 +4911,17 @@ pool_xmit(
 		/* copy_addrinfo_list ai_addr points to a sockaddr_u */
 		rmtadr = (sockaddr_u *)(void *)pool->ai->ai_addr;
 		pool->ai = pool->ai->ai_next;
+		/* do not solicit when hopeless [Bug 3845] */
+		if (   (IS_IPV4(rmtadr) && !nonlocal_v4_addr_up)
+		    || (IS_IPV6(rmtadr) && !nonlocal_v6_addr_up)) {
+			continue;
+		}
 		p = findexistingpeer(rmtadr, NULL, NULL, MODE_CLIENT, 0, NULL);
 	} while (p != NULL && pool->ai != NULL);
-	if (p != NULL)
+	if (p != NULL) {
 		return;	/* out of addresses, re-query DNS next poll */
-	restrictions(rmtadr, &r4a);
-	restrict_mask = r4a.rflags;
-	if (RES_FLAGS & restrict_mask)
-		restrict_source(rmtadr, 0,
-				current_time + POOL_SOLICIT_WINDOW + 1);
+	}
+	restrict_source(rmtadr, FALSE, 1 + POOL_SOLICIT_WINDOW);
 	lcladr = findinterface(rmtadr);
 	memset(&xpkt, 0, sizeof(xpkt));
 	xpkt.li_vn_mode = PKT_LI_VN_MODE(sys_leap, pool->version,
@@ -4867,7 +4935,6 @@ pool_xmit(
 	/* Bug 3596: What are the pros/cons of using sys_reftime here? */
 	HTONL_FP(&sys_reftime, &xpkt.reftime);
 
-	/* HMS: the following is better done after the ntp_random() calls */
 	get_systime(&xmt_tx);
 	pool->aorg = xmt_tx;
 
@@ -4886,14 +4953,14 @@ pool_xmit(
 		L_CLR(&pool->nonce);
 		HTONL_FP(&xmt_tx, &xpkt.xmt);
 	}
-	sendpkt(rmtadr, lcladr,
-		sys_ttl[(pool->ttl >= sys_ttlmax) ? sys_ttlmax : pool->ttl],
-		&xpkt, LEN_PKT_NOMAC);
 	pool->sent++;
 	pool->throttle += (1 << pool->minpoll) - 2;
 	DPRINTF(1, ("pool_xmit: at %ld %s->%s pool\n",
 		    current_time, latoa(lcladr), stoa(rmtadr)));
 	msyslog(LOG_INFO, "Soliciting pool server %s", stoa(rmtadr));
+	sendpkt(rmtadr, lcladr,
+		sys_ttl[(pool->ttl >= sys_ttlmax) ? sys_ttlmax : pool->ttl],
+		&xpkt, LEN_PKT_NOMAC);
 #endif	/* WORKER */
 }
 
@@ -4999,8 +5066,18 @@ key_expire(
 
 
 /*
- * local_refid(peer) - check peer refid to avoid selecting peers
+ * local_refid(peer) - Check peer refid to avoid selecting peers
  *		       currently synced to this ntpd.
+ * Note that until 4.2.8p18 and 4.3.1XX ntpd calculated the IPv6
+ * refid differently on different-endian systems.  It now calculates
+ * the refid the same on both, the same way it did on little-endian
+ * in the past.  On big-endian systems, ntpd also calculates a
+ * byte-swapped version of each of its IPv6 local addresses' refids,
+ * as endpt.old_refid and also detects a loop when seeing it.  This
+ * ensures new BE ntpd will detect loops interoperating with older
+ * BE ntpd, and keeps the more-common LE old ntpd code detecting
+ * loops with IPv6 refids correctly.  Thanks to Hal Murray for
+ * the byte-swapping idea.
  */
 static int
 local_refid(
@@ -5014,10 +5091,17 @@ local_refid(
 	else
 		unicast_ep = findinterface(&p->srcadr);
 
-	if (unicast_ep != NULL && p->refid == unicast_ep->addr_refid)
+	if (unicast_ep != NULL
+	    && (   p->refid == unicast_ep->addr_refid
+#ifdef WORDS_BIGENDIAN
+		|| (   IS_IPV6(&unicast_ep->sin)
+		    && p->refid == unicast_ep->old_refid)
+#endif
+							 )) {
 		return TRUE;
-	else
+	} else {
 		return FALSE;
+	}
 }
 
 
diff --git a/contrib/ntp/ntpd/ntp_refclock.c b/contrib/ntp/ntpd/ntp_refclock.c
index a16c980e5b09..d96a524c8841 100644
--- a/contrib/ntp/ntpd/ntp_refclock.c
+++ b/contrib/ntp/ntpd/ntp_refclock.c
@@ -72,8 +72,6 @@ static int  refclock_cmpl_fp (const void *, const void *);
 static int  refclock_sample (struct refclockproc *);
 static int  refclock_ioctl(int, u_int);
 static void refclock_checkburst(struct peer *, struct refclockproc *);
-static int  symBaud2numBaud(int symBaud);
-static int  numBaud2symBaud(int numBaud);
 
 /* circular buffer functions
  *
@@ -841,9 +839,9 @@ refclock_fdwrite(
 		} else if (nret != len) {
 			nerr = errno;
 			msyslog(LOG_NOTICE,
-				"%s: %s shortened, fd=%d, wrote %zu of %zu bytes",
+				"%s: %s shortened, fd=%d, wrote %u of %u bytes",
 				refnumtoa(&peer->srcadr), what,
-				fd, nret, len);
+				fd, (u_int)nret, (u_int)len);
 			errno = nerr;
 		}
 	}
@@ -1651,7 +1649,7 @@ refclock_pps(
  * -------------------------------------------------------------------
  */
 
-int/*BOOL*/
+int
 refclock_ppsaugment(
 	const struct refclock_atom * ap	    ,	/* for PPS io	  */
 	l_fp 			   * rcvtime ,
@@ -1826,10 +1824,11 @@ refclock_vformat_lcode(
 	long len;
 
 	len = vsnprintf(pp->a_lastcode, sizeof(pp->a_lastcode), fmt, va);
-	if (len <= 0)
+	if (len <= 0) {
 		len = 0;
-	else if (len >= sizeof(pp->a_lastcode))
+	} else if (len >= sizeof(pp->a_lastcode)) {
 		len = sizeof(pp->a_lastcode) - 1;
+	}
 
 	pp->lencode = (u_short)len;
 	pp->a_lastcode[len] = '\0';
@@ -1850,47 +1849,4 @@ refclock_format_lcode(
 	va_end(va);
 }
 
-static const int baudTable[][2] = {
-	{B0, 0},
-	{B50, 50},
-	{B75, 75},
-	{B110, 110},
-	{B134, 134},
-	{B150, 150},
-	{B200, 200},
-	{B300, 300},
-	{B600, 600},
-	{B1200, 1200},
-	{B1800, 1800},
-	{B2400, 2400},
-	{B4800, 4800},
-	{B9600, 9600},
-	{B19200, 19200},
-	{B38400, 38400},
-#   ifdef B57600
-	{B57600, 57600 },
-#   endif
-#   ifdef B115200
-	{B115200, 115200},
-#   endif
-	{-1, -1}
-};
-    
-
-static int  symBaud2numBaud(int symBaud)
-{
-	int i;
-	for (i = 0; baudTable[i][1] >= 0; ++i)
-		if (baudTable[i][0] == symBaud)
-			break;
-	return baudTable[i][1];
-}
-static int  numBaud2symBaud(int numBaud)
-{
-	int i;
-	for (i = 0; baudTable[i][1] >= 0; ++i)
-		if (baudTable[i][1] == numBaud)
-			break;
-	return baudTable[i][0];
-}
-#endif /* REFCLOCK */
+#endif	/* REFCLOCK */
diff --git a/contrib/ntp/ntpd/ntp_request.c b/contrib/ntp/ntpd/ntp_request.c
index e61d014808de..89c051b64f0b 100644
--- a/contrib/ntp/ntpd/ntp_request.c
+++ b/contrib/ntp/ntpd/ntp_request.c
@@ -1790,6 +1790,7 @@ do_restrict(
 	sockaddr_u		matchaddr;
 	sockaddr_u		matchmask;
 	int			bad;
+	int/*BOOL*/		success;
 
 	switch(op) {
 	    case RESTRICT_FLAGS:
@@ -1838,7 +1839,7 @@ do_restrict(
 	}
 
 	if (bad) {
-		msyslog(LOG_ERR, "do_restrict: bad = %#x", bad);
+		msyslog(LOG_ERR, "%s: bad = 0x%x", __func__, bad);
 		req_ack(srcadr, inter, inpkt, INFO_ERR_FMT);
 		return;
 	}
@@ -1868,8 +1869,16 @@ do_restrict(
 			NSRCADR(&matchaddr) = cr.addr;
 			NSRCADR(&matchmask) = cr.mask;
 		}
-		hack_restrict(op, &matchaddr, &matchmask, cr.mflags,
-			      cr.ippeerlimit, cr.flags, 0);
+		success =  hack_restrict(op, &matchaddr, &matchmask,
+					 cr.ippeerlimit, cr.mflags,
+					 cr.flags, 0);
+		if (!success) {
+			DPRINTF(1, ("%s: %s %s mask %s ippeerlimit %hd %s %s failed",
+				    __func__, resop_str(op),
+				    stoa(&matchaddr), stoa(&matchmask),
+				    cr.ippeerlimit, mflags_str(cr.mflags),
+				    rflags_str(cr.flags)));
+		}
 		datap += item_sz;
 	}
 
diff --git a/contrib/ntp/ntpd/ntp_restrict.c b/contrib/ntp/ntpd/ntp_restrict.c
index fe2935d9e071..f1df8ccf3079 100644
--- a/contrib/ntp/ntpd/ntp_restrict.c
+++ b/contrib/ntp/ntpd/ntp_restrict.c
@@ -15,21 +15,11 @@
 #include "ntp_assert.h"
 
 /*
- * This code keeps a simple address-and-mask list of hosts we want
- * to place restrictions on (or remove them from). The restrictions
- * are implemented as a set of flags which tell you what the host
- * can't do. There is a subroutine entry to return the flags. The
- * list is kept sorted to reduce the average number of comparisons
- * and make sure you get the set of restrictions most specific to
- * the address.
- *
- * The algorithm is that, when looking up a host, it is first assumed
- * that the default set of restrictions will apply. It then searches
- * down through the list. Whenever it finds a match it adopts the
- * match's flags instead. When you hit the point where the sorted
- * address is greater than the target, you return with the last set of
- * flags you found. Because of the ordering of the list, the most
- * specific match will provide the final set of flags.
+ * This code keeps a simple address-and-mask list of addressses we want
+ * to place restrictions on (or remove them from). The restrictions are
+ * implemented as a set of flags which tell you what matching addresses
+ * can't do.  The list is sorted retrieve the restrictions most specific
+*  to the address.
  *
  * This was originally intended to restrict you from sync'ing to your
  * own broadcasts when you are doing that, by restricting yourself from
@@ -38,27 +28,23 @@
  * has been expanded, however, to suit the needs of those with more
  * restrictive access policies.
  */
-/*
- * We will use two lists, one for IPv4 addresses and one for IPv6
- * addresses. This is not protocol-independant but for now I can't
- * find a way to respect this. We'll check this later... JFB 07/2001
- */
 #define MASK_IPV6_ADDR(dst, src, msk)					\
 	do {								\
-		int idx;						\
-		for (idx = 0; idx < (int)COUNTOF((dst)->s6_addr); idx++) { \
-			(dst)->s6_addr[idx] = (src)->s6_addr[idx]	\
-					      & (msk)->s6_addr[idx];	\
+		int x;							\
+									\
+		for (x = 0; x < (int)COUNTOF((dst)->s6_addr); x++) {	\
+			(dst)->s6_addr[x] =   (src)->s6_addr[x]		\
+					    & (msk)->s6_addr[x];	\
 		}							\
-	} while (0)
+	} while (FALSE)
 
 /*
  * We allocate INC_RESLIST{4|6} entries to the free list whenever empty.
- * Auto-tune these to be just less than 1KB (leaving at least 16 bytes
+ * Auto-tune these to be just less than 1KB (leaving at least 32 bytes
  * for allocator overhead).
  */
-#define	INC_RESLIST4	((1024 - 16) / V4_SIZEOF_RESTRICT_U)
-#define	INC_RESLIST6	((1024 - 16) / V6_SIZEOF_RESTRICT_U)
+#define	INC_RESLIST4	((1024 - 32) / V4_SIZEOF_RESTRICT_U)
+#define	INC_RESLIST6	((1024 - 32) / V6_SIZEOF_RESTRICT_U)
 
 /*
  * The restriction list
@@ -103,30 +89,35 @@ static	short		restrict_source_ippeerlimit;
 /*
  * private functions
  */
-static restrict_u *	alloc_res4(void);
-static restrict_u *	alloc_res6(void);
-static void		free_res(restrict_u *, int);
-static void		inc_res_limited(void);
-static void		dec_res_limited(void);
-static restrict_u *	match_restrict4_addr(u_int32, u_short);
-static restrict_u *	match_restrict6_addr(const struct in6_addr *,
+static	restrict_u *	alloc_res4(void);
+static	restrict_u *	alloc_res6(void);
+static	void		free_res(restrict_u *, int);
+static	inline void	inc_res_limited(void);
+static	inline void	dec_res_limited(void);
+static	restrict_u *	match_restrict4_addr(u_int32, u_short);
+static	restrict_u *	match_restrict6_addr(const struct in6_addr *,
 					     u_short);
-static restrict_u *	match_restrict_entry(const restrict_u *, int);
-static int		res_sorts_before4(restrict_u *, restrict_u *);
-static int		res_sorts_before6(restrict_u *, restrict_u *);
-static char *		roptoa(restrict_op op);
+static	restrict_u *	match_restrict_entry(const restrict_u *, int);
+static inline int/*BOOL*/	mflags_sorts_before(u_short, u_short);
+static	int/*BOOL*/	res_sorts_before4(restrict_u *, restrict_u *);
+static	int/*BOOL*/	res_sorts_before6(restrict_u *, restrict_u *);
 
+typedef int (*res_sort_fn)(restrict_u *, restrict_u *);
+
+
+/* dump_restrict() & dump_restricts() are DEBUG-only */
+#ifdef DEBUG	
+static void		dump_restrict(restrict_u *, int);
 
-void	dump_restricts(void);
 
 /*
- * dump_restrict - spit out a restrict_u
+ * dump_restrict - spit out a single restriction entry
  */
 static void
 dump_restrict(
 	restrict_u *	res,
 	int		is_ipv6
-	)
+)
 {
 	char as[INET6_ADDRSTRLEN];
 	char ms[INET6_ADDRSTRLEN];
@@ -135,57 +126,47 @@ dump_restrict(
 		inet_ntop(AF_INET6, &res->u.v6.addr, as, sizeof as);
 		inet_ntop(AF_INET6, &res->u.v6.mask, ms, sizeof ms);
 	} else {
-		struct in_addr	sia = { htonl(res->u.v4.addr) };
-		struct in_addr	sim = { htonl(res->u.v4.mask) };
+		struct in_addr	sia, sim;
 
+		sia.s_addr = htonl(res->u.v4.addr);
+		sim.s_addr = htonl(res->u.v4.addr);
 		inet_ntop(AF_INET, &sia, as, sizeof as);
 		inet_ntop(AF_INET, &sim, ms, sizeof ms);
 	}
-	mprintf("restrict node at %p: %s/%s count %d, rflags %08x, mflags %04x, ippeerlimit %d, expire %lu, next %p\n",
-		res, as, ms, res->count, res->rflags, res->mflags,
-		res->ippeerlimit, res->expire, res->link);
-	return;
+	printf("%s/%s: hits %u ippeerlimit %hd mflags %s rflags %s",
+		as, ms, res->count, res->ippeerlimit,
+		mflags_str(res->mflags),
+		rflags_str(res->rflags));
+	if (res->expire > 0) {
+		printf(" expire %u\n", res->expire);
+	} else {
+		printf("\n");
+	}
 }
 
 
 /*
- * dump_restricts - spit out the 'restrict' lines
+ * dump_restricts - spit out the 'restrict' entries
  */
 void
 dump_restricts(void)
 {
 	restrict_u *	res;
-	restrict_u *	next;
-
-	mprintf("dump_restrict: restrict_def4: %p\n", &restrict_def4);
-	/* Spit out 'restrict {,-4,-6} default ...' lines, if needed */
-	for (res = &restrict_def4; res != NULL; res = next) {
-		dump_restrict(res, 0);
-		next = res->link;
-	}
-
-	mprintf("dump_restrict: restrict_def6: %p\n", &restrict_def6);
-	for (res = &restrict_def6; res != NULL; res = next) {
-		dump_restrict(res, 1);
-		next = res->link;
-	}
 
 	/* Spit out the IPv4 list */
-	mprintf("dump_restrict: restrictlist4: %p\n", &restrictlist4);
-	for (res = restrictlist4; res != NULL; res = next) {
+	printf("dump_restricts: restrictlist4: %p\n", restrictlist4);
+	for (res = restrictlist4; res != NULL; res = res->link) {
 		dump_restrict(res, 0);
-		next = res->link;
 	}
 
 	/* Spit out the IPv6 list */
-	mprintf("dump_restrict: restrictlist6: %p\n", &restrictlist6);
-	for (res = restrictlist6; res != NULL; res = next) {
+	printf("dump_restricts: restrictlist6: %p\n", restrictlist6);
+	for (res = restrictlist6; res != NULL; res = res->link) {
 		dump_restrict(res, 1);
-		next = res->link;
 	}
-
-	return;
 }
+#endif /* DEBUG - dump_restrict() / dump_restricts() */
+
 
 /*
  * init_restrict - initialize the restriction data structures
@@ -194,7 +175,7 @@ void
 init_restrict(void)
 {
 	/*
-	 * The restriction lists begin with a default entry with address
+	 * The restriction lists end with a default entry with address
 	 * and mask 0, which will match any entry.  The lists are kept
 	 * sorted by descending address followed by descending mask:
 	 *
@@ -215,11 +196,20 @@ init_restrict(void)
 	 *
 	 * An additional wrinkle is we may have multiple entries with
 	 * the same address and mask but differing match flags (mflags).
-	 * At present there is only one, RESM_NTPONLY.  Entries with
-	 * RESM_NTPONLY are sorted earlier so they take precedence over
-	 * any otherwise similar entry without.  Again, this is the same
-	 * behavior as but reversed implementation compared to the docs.
-	 * 
+	 * We want to never talk to ourself, so RES_IGNORE entries for
+	 * each local address are added by ntp_io.c with a host mask and
+	 * both RESM_INTERFACE and RESM_NTPONLY set.  We sort those
+	 * entries before entries without those flags to achieve this.
+	 * The remaining match flag is RESM_SOURCE, used to dynamically
+	 * set restrictions for each peer based on the prototype set by
+	 * "restrict source" in the configuration.  We want those entries
+	 * to be considered only when there is not a static host
+	 * restriction for the address in the configuration, to allow
+	 * operators to blacklist pool and manycast servers at runtime as
+	 * desired using ntpq runtime configuration.  Such static entries
+	 * have no RESM_ bits set, so the sort order for mflags is first
+	 * RESM_INTERFACE, then entries without RESM_SOURCE, finally the
+	 * remaining.
 	 */
 
 	restrict_def4.ippeerlimit = -1;		/* Cleaner if we have C99 */
@@ -236,14 +226,14 @@ alloc_res4(void)
 {
 	const size_t	cb = V4_SIZEOF_RESTRICT_U;
 	const size_t	count = INC_RESLIST4;
-	restrict_u *	rl;
-	restrict_u *	res;
+	restrict_u*	rl;
+	restrict_u*	res;
 	size_t		i;
 
 	UNLINK_HEAD_SLIST(res, resfree4, link);
-	if (res != NULL)
+	if (res != NULL) {
 		return res;
-
+	}
 	rl = eallocarray(count, cb);
 	/* link all but the first onto free list */
 	res = (void *)((char *)rl + (count - 1) * cb);
@@ -251,7 +241,7 @@ alloc_res4(void)
 		LINK_SLIST(resfree4, res, link);
 		res = (void *)((char *)res - cb);
 	}
-	INSIST(rl == res);
+	DEBUG_INSIST(rl == res);
 	/* allocate the first */
 	return res;
 }
@@ -267,9 +257,9 @@ alloc_res6(void)
 	size_t		i;
 
 	UNLINK_HEAD_SLIST(res, resfree6, link);
-	if (res != NULL)
+	if (res != NULL) {
 		return res;
-
+	}
 	rl = eallocarray(count, cb);
 	/* link all but the first onto free list */
 	res = (void *)((char *)rl + (count - 1) * cb);
@@ -277,7 +267,7 @@ alloc_res6(void)
 		LINK_SLIST(resfree6, res, link);
 		res = (void *)((char *)res - cb);
 	}
-	INSIST(rl == res);
+	DEBUG_INSIST(rl == res);
 	/* allocate the first */
 	return res;
 }
@@ -289,46 +279,48 @@ free_res(
 	int		v6
 	)
 {
-	restrict_u **	plisthead;
+	restrict_u **	rlisthead_ptr;
+	restrict_u **	flisthead_ptr;
 	restrict_u *	unlinked;
+	size_t		sz;
 
 	restrictcount--;
-	if (RES_LIMITED & res->rflags)
+	if (RES_LIMITED & res->rflags) {
 		dec_res_limited();
-
-	if (v6)
-		plisthead = &restrictlist6;
-	else
-		plisthead = &restrictlist4;
-	UNLINK_SLIST(unlinked, *plisthead, res, link, restrict_u);
-	INSIST(unlinked == res);
-
+	}
 	if (v6) {
-		zero_mem(res, V6_SIZEOF_RESTRICT_U);
-		plisthead = &resfree6;
+		rlisthead_ptr = &restrictlist6;
+		flisthead_ptr = &resfree6;
+		sz = V6_SIZEOF_RESTRICT_U;
 	} else {
-		zero_mem(res, V4_SIZEOF_RESTRICT_U);
-		plisthead = &resfree4;
+		rlisthead_ptr = &restrictlist4;
+		flisthead_ptr = &resfree4;
+		sz = V4_SIZEOF_RESTRICT_U;
 	}
-	LINK_SLIST(*plisthead, res, link);
+	UNLINK_SLIST(unlinked, *rlisthead_ptr, res, link, restrict_u);
+	INSIST(unlinked == res);
+	zero_mem(res, sz);
+	LINK_SLIST(*flisthead_ptr, res, link);
 }
 
 
-static void
+static inline void
 inc_res_limited(void)
 {
-	if (!res_limited_refcnt)
+	if (0 == res_limited_refcnt) {
 		mon_start(MON_RES);
+	}
 	res_limited_refcnt++;
 }
 
 
-static void
+static inline void
 dec_res_limited(void)
 {
 	res_limited_refcnt--;
-	if (!res_limited_refcnt)
+	if (0 == res_limited_refcnt) {
 		mon_stop(MON_RES);
+	}
 }
 
 
@@ -338,26 +330,21 @@ match_restrict4_addr(
 	u_short	port
 	)
 {
-	const int	v6 = 0;
+	const int	v6 = FALSE;
 	restrict_u *	res;
 	restrict_u *	next;
 
 	for (res = restrictlist4; res != NULL; res = next) {
-		struct in_addr	sia = { htonl(res->u.v4.addr) };
-
 		next = res->link;
-		DPRINTF(2, ("match_restrict4_addr: Checking %s, port %d ... ",
-			    inet_ntoa(sia), port));
-		if (   res->expire
-		    && res->expire <= current_time)
+		if (res->expire && res->expire <= current_time) {
 			free_res(res, v6);	/* zeroes the contents */
+		}
 		if (   res->u.v4.addr == (addr & res->u.v4.mask)
 		    && (   !(RESM_NTPONLY & res->mflags)
 			|| NTP_PORT == port)) {
-			DPRINTF(2, ("MATCH: ippeerlimit %d\n", res->ippeerlimit));
+
 			break;
 		}
-		DPRINTF(2, ("doesn't match: ippeerlimit %d\n", res->ippeerlimit));
 	}
 	return res;
 }
@@ -369,22 +356,23 @@ match_restrict6_addr(
 	u_short			port
 	)
 {
-	const int	v6 = 1;
+	const int	v6 = TRUE;
 	restrict_u *	res;
 	restrict_u *	next;
 	struct in6_addr	masked;
 
 	for (res = restrictlist6; res != NULL; res = next) {
 		next = res->link;
-		INSIST(next != res);
-		if (res->expire &&
-		    res->expire <= current_time)
+		if (res->expire && res->expire <= current_time) {
 			free_res(res, v6);
+		}
 		MASK_IPV6_ADDR(&masked, addr, &res->u.v6.mask);
 		if (ADDR6_EQ(&masked, &res->u.v6.addr)
-		    && (!(RESM_NTPONLY & res->mflags)
-			|| NTP_PORT == (int)port))
+		    && (   !(RESM_NTPONLY & res->mflags)
+			|| NTP_PORT == (int)port)) {
+
 			break;
+		}
 	}
 	return res;
 }
@@ -417,22 +405,47 @@ match_restrict_entry(
 		cb = sizeof(pmatch->u.v4);
 	}
 
-	for (res = rlist; res != NULL; res = res->link)
+	for (res = rlist; res != NULL; res = res->link) {
 		if (res->mflags == pmatch->mflags &&
-		    !memcmp(&res->u, &pmatch->u, cb))
+		    !memcmp(&res->u, &pmatch->u, cb)) {
 			break;
+		}
+	}
 	return res;
 }
 
 
 /*
- * res_sorts_before4 - compare two restrict4 entries
+ * mflags_sorts_before - common mflags sorting code
+ * 
+ * See block comment in init_restrict() above for rationale.
+ */
+static inline int/*BOOL*/
+mflags_sorts_before(
+	u_short	m1,
+	u_short	m2
+	)
+{
+	if (    (RESM_INTERFACE & m1)
+	    && !(RESM_INTERFACE & m2)) {
+		return TRUE;
+	} else if (   !(RESM_SOURCE & m1)
+		   &&  (RESM_SOURCE & m2)) {
+		return TRUE;
+	} else {
+		return FALSE;
+	}
+}
+
+
+/*
+ * res_sorts_before4 - compare IPv4 restriction entries
  *
  * Returns nonzero if r1 sorts before r2.  We sort by descending
- * address, then descending mask, then descending mflags, so sorting
- * before means having a higher value.
+ * address, then descending mask, then an intricate mflags sort
+ * order explained in a block comment near the top of this file.
  */
-static int
+static int/*BOOL*/
 res_sorts_before4(
 	restrict_u *r1,
 	restrict_u *r2
@@ -440,54 +453,53 @@ res_sorts_before4(
 {
 	int r1_before_r2;
 
-	if (r1->u.v4.addr > r2->u.v4.addr)
-		r1_before_r2 = 1;
-	else if (r1->u.v4.addr < r2->u.v4.addr)
-		r1_before_r2 = 0;
-	else if (r1->u.v4.mask > r2->u.v4.mask)
-		r1_before_r2 = 1;
-	else if (r1->u.v4.mask < r2->u.v4.mask)
-		r1_before_r2 = 0;
-	else if (r1->mflags > r2->mflags)
-		r1_before_r2 = 1;
-	else
-		r1_before_r2 = 0;
+	if (r1->u.v4.addr > r2->u.v4.addr) {
+		r1_before_r2 = TRUE;
+	} else if (r1->u.v4.addr < r2->u.v4.addr) {
+		r1_before_r2 = FALSE;
+	} else if (r1->u.v4.mask > r2->u.v4.mask) {
+		r1_before_r2 = TRUE;
+	} else if (r1->u.v4.mask < r2->u.v4.mask) {
+		r1_before_r2 = FALSE;
+	} else {
+		r1_before_r2 = mflags_sorts_before(r1->mflags, r2->mflags);
+	}
 
 	return r1_before_r2;
 }
 
 
 /*
- * res_sorts_before6 - compare two restrict6 entries
+ * res_sorts_before6 - compare IPv6 restriction entries
  *
  * Returns nonzero if r1 sorts before r2.  We sort by descending
- * address, then descending mask, then descending mflags, so sorting
- * before means having a higher value.
+ * address, then descending mask, then an intricate mflags sort
+ * order explained in a block comment near the top of this file.
  */
-static int
+static int/*BOOL*/
 res_sorts_before6(
-	restrict_u *r1,
-	restrict_u *r2
-	)
+	restrict_u* r1,
+	restrict_u* r2
+)
 {
 	int r1_before_r2;
 	int cmp;
 
 	cmp = ADDR6_CMP(&r1->u.v6.addr, &r2->u.v6.addr);
-	if (cmp > 0)		/* r1->addr > r2->addr */
-		r1_before_r2 = 1;
-	else if (cmp < 0)	/* r2->addr > r1->addr */
-		r1_before_r2 = 0;
-	else {
+	if (cmp > 0) {		/* r1->addr > r2->addr */
+		r1_before_r2 = TRUE;
+	} else if (cmp < 0) {	/* r2->addr > r1->addr */
+		r1_before_r2 = FALSE;
+	} else {
 		cmp = ADDR6_CMP(&r1->u.v6.mask, &r2->u.v6.mask);
-		if (cmp > 0)		/* r1->mask > r2->mask*/
-			r1_before_r2 = 1;
-		else if (cmp < 0)	/* r2->mask > r1->mask */
-			r1_before_r2 = 0;
-		else if (r1->mflags > r2->mflags)
-			r1_before_r2 = 1;
-		else
-			r1_before_r2 = 0;
+		if (cmp > 0) {		/* r1->mask > r2->mask*/
+			r1_before_r2 = TRUE;
+		} else if (cmp < 0) {	/* r2->mask > r1->mask */
+			r1_before_r2 = FALSE;
+		} else {
+			r1_before_r2 = mflags_sorts_before(r1->mflags,
+							   r2->mflags);
+		}
 	}
 
 	return r1_before_r2;
@@ -506,15 +518,10 @@ restrictions(
 	restrict_u *match;
 	struct in6_addr *pin6;
 
-	REQUIRE(NULL != r4a);
+	DEBUG_REQUIRE(NULL != r4a);
 
 	res_calls++;
-	r4a->rflags = RES_IGNORE;
-	r4a->ippeerlimit = 0;
 
-	DPRINTF(1, ("restrictions: looking up %s\n", stoa(srcadr)));
-
-	/* IPv4 source address */
 	if (IS_IPV4(srcadr)) {
 		/*
 		 * Ignore any packets with a multicast source address
@@ -522,16 +529,12 @@ restrictions(
 		 * not later!)
 		 */
 		if (IN_CLASSD(SRCADR(srcadr))) {
-			DPRINTF(1, ("restrictions: srcadr %s is multicast\n", stoa(srcadr)));
-			r4a->ippeerlimit = 2;	/* XXX: we should use a better value */
-			return;
+			goto multicast;
 		}
 
 		match = match_restrict4_addr(SRCADR(srcadr),
 					     SRCPORT(srcadr));
-
-		INSIST(match != NULL);
-
+		DEBUG_INSIST(match != NULL);
 		match->count++;
 		/*
 		 * res_not_found counts only use of the final default
@@ -544,10 +547,9 @@ restrictions(
 			res_found++;
 		r4a->rflags = match->rflags;
 		r4a->ippeerlimit = match->ippeerlimit;
-	}
+	} else {
+		DEBUG_REQUIRE(IS_IPV6(srcadr));
 
-	/* IPv6 source address */
-	if (IS_IPV6(srcadr)) {
 		pin6 = PSOCK_ADDR6(srcadr);
 
 		/*
@@ -555,11 +557,11 @@ restrictions(
 		 * (this should be done early in the receive process,
 		 * not later!)
 		 */
-		if (IN6_IS_ADDR_MULTICAST(pin6))
-			return;
-
+		if (IN6_IS_ADDR_MULTICAST(pin6)) {
+			goto multicast;
+		}
 		match = match_restrict6_addr(pin6, SRCPORT(srcadr));
-		INSIST(match != NULL);
+		DEBUG_INSIST(match != NULL);
 		match->count++;
 		if (&restrict_def6 == match)
 			res_not_found++;
@@ -570,32 +572,34 @@ restrictions(
 	}
 
 	return;
-}
 
+    multicast:
+	r4a->rflags = RES_IGNORE;
+	r4a->ippeerlimit = 0;
+}
 
-/*
- * roptoa - convert a restrict_op to a string
- */
-char *
-roptoa(restrict_op op) {
-	static char sb[30];
 
-	switch(op) {
+#ifdef DEBUG
+/* display string for restrict_op */
+const char *
+resop_str(restrict_op op)
+{
+	switch (op) {
 	    case RESTRICT_FLAGS:	return "RESTRICT_FLAGS";
-	    case RESTRICT_UNFLAG:	return "RESTRICT_UNFLAGS";
+	    case RESTRICT_UNFLAG:	return "RESTRICT_UNFLAG";
 	    case RESTRICT_REMOVE:	return "RESTRICT_REMOVE";
 	    case RESTRICT_REMOVEIF:	return "RESTRICT_REMOVEIF";
-	    default:
-		snprintf(sb, sizeof sb, "**RESTRICT_#%d**", op);
-		return sb;
 	}
+	DEBUG_INVARIANT(!"bad restrict_op in resop_str");
+	return "";	/* silence not all paths return value warning */
 }
+#endif	/* DEBUG */
 
 
 /*
  * hack_restrict - add/subtract/manipulate entries on the restrict list
  */
-void
+int/*BOOL*/
 hack_restrict(
 	restrict_op	op,
 	sockaddr_u *	resaddr,
@@ -603,38 +607,51 @@ hack_restrict(
 	short		ippeerlimit,
 	u_short		mflags,
 	u_short		rflags,
-	u_long		expire
+	u_int32		expire
 	)
 {
 	int		v6;
+	int		bump_res_limited = FALSE;
 	restrict_u	match;
 	restrict_u *	res;
 	restrict_u **	plisthead;
-
-	DPRINTF(1, ("hack_restrict: op %s addr %s mask %s ippeerlimit %d mflags %08x rflags %08x\n",
-		    roptoa(op), stoa(resaddr), stoa(resmask), ippeerlimit, mflags, rflags));
+	res_sort_fn	pfn_sort;
+
+#ifdef DEBUG
+	if (debug > 0) {
+		printf("hack_restrict: op %s addr %s mask %s",
+			resop_str(op), stoa(resaddr), stoa(resmask));
+		if (ippeerlimit >= 0) {
+			printf(" ippeerlimit %d", ippeerlimit);
+		}
+		printf(" mflags %s rflags %s", mflags_str(mflags),
+		       rflags_str(rflags));
+		if (expire) {
+			printf("lifetime %u\n",
+			       expire - (u_int32)current_time);
+		} else {
+			printf("\n");
+		}
+	}
+#endif
 
 	if (NULL == resaddr) {
-		REQUIRE(NULL == resmask);
-		REQUIRE(RESTRICT_FLAGS == op);
+		DEBUG_REQUIRE(NULL == resmask);
+		DEBUG_REQUIRE(RESTRICT_FLAGS == op);
+		DEBUG_REQUIRE(RESM_SOURCE & mflags);
 		restrict_source_rflags = rflags;
 		restrict_source_mflags = mflags;
 		restrict_source_ippeerlimit = ippeerlimit;
-		restrict_source_enabled = 1;
-		return;
+		restrict_source_enabled = TRUE;
+		DPRINTF(1, ("restrict source template saved\n"));
+		return TRUE;
 	}
 
 	ZERO(match);
 
-#if 0
-	/* silence VC9 potentially uninit warnings */
-	// HMS: let's use a compiler-specific "enable" for this.
-	res = NULL;
-	v6 = 0;
-#endif
-
 	if (IS_IPV4(resaddr)) {
-		v6 = 0;
+		DEBUG_INVARIANT(IS_IPV4(resmask));
+		v6 = FALSE;
 		/*
 		 * Get address and mask in host byte order for easy
 		 * comparison as u_int32
@@ -642,9 +659,10 @@ hack_restrict(
 		match.u.v4.addr = SRCADR(resaddr);
 		match.u.v4.mask = SRCADR(resmask);
 		match.u.v4.addr &= match.u.v4.mask;
-
-	} else if (IS_IPV6(resaddr)) {
-		v6 = 1;
+	} else {
+		DEBUG_INVARIANT(IS_IPV6(resaddr));
+		DEBUG_INVARIANT(IS_IPV6(resmask));
+		v6 = TRUE;
 		/*
 		 * Get address and mask in network byte order for easy
 		 * comparison as byte sequences (e.g. memcmp())
@@ -652,88 +670,95 @@ hack_restrict(
 		match.u.v6.mask = SOCK_ADDR6(resmask);
 		MASK_IPV6_ADDR(&match.u.v6.addr, PSOCK_ADDR6(resaddr),
 			       &match.u.v6.mask);
+	}
 
-	} else	/* not IPv4 nor IPv6 */
-		REQUIRE(0);
-
-	match.rflags = rflags;
 	match.mflags = mflags;
-	match.ippeerlimit = ippeerlimit;
-	match.expire = expire;
 	res = match_restrict_entry(&match, v6);
 
 	switch (op) {
 
 	case RESTRICT_FLAGS:
 		/*
-		 * Here we add bits to the rflags. If this is a
-		 * new restriction add it.
+		 * Here we add bits to the rflags. If we already have
+		 * this restriction modify it.
 		 */
-		if (NULL == res) {
+		if (NULL != res) {
+			if (    (RES_LIMITED & rflags)
+			    && !(RES_LIMITED & res->rflags)) {
+
+				bump_res_limited = TRUE;
+			}
+			res->rflags |= rflags;
+			res->expire = expire;
+		} else {
+			match.rflags = rflags;
+			match.expire = expire;
+			match.ippeerlimit = ippeerlimit;
 			if (v6) {
 				res = alloc_res6();
-				memcpy(res, &match,
-				       V6_SIZEOF_RESTRICT_U);
+				memcpy(res, &match, V6_SIZEOF_RESTRICT_U);
 				plisthead = &restrictlist6;
+				pfn_sort = &res_sorts_before6;
 			} else {
 				res = alloc_res4();
-				memcpy(res, &match,
-				       V4_SIZEOF_RESTRICT_U);
+				memcpy(res, &match, V4_SIZEOF_RESTRICT_U);
 				plisthead = &restrictlist4;
+				pfn_sort = &res_sorts_before4;
 			}
 			LINK_SORT_SLIST(
 				*plisthead, res,
-				(v6)
-				  ? res_sorts_before6(res, L_S_S_CUR())
-				  : res_sorts_before4(res, L_S_S_CUR()),
+				(*pfn_sort)(res, L_S_S_CUR()),
 				link, restrict_u);
 			restrictcount++;
-			if (RES_LIMITED & rflags)
-				inc_res_limited();
-		} else {
-			if (   (RES_LIMITED & rflags)
-			    && !(RES_LIMITED & res->rflags))
-				inc_res_limited();
-			res->rflags |= rflags;
+			if (RES_LIMITED & rflags) {
+				bump_res_limited = TRUE;
+			}
 		}
-
-		res->ippeerlimit = match.ippeerlimit;
-
-		break;
+		if (bump_res_limited) {
+			inc_res_limited();
+		}
+		return TRUE;
 
 	case RESTRICT_UNFLAG:
 		/*
 		 * Remove some bits from the rflags. If we didn't
 		 * find this one, just return.
 		 */
-		if (res != NULL) {
-			if (   (RES_LIMITED & res->rflags)
-			    && (RES_LIMITED & rflags))
-				dec_res_limited();
-			res->rflags &= ~rflags;
+		if (NULL == res) {
+			DPRINTF(1, ("No match for %s %s removing rflags %s\n",
+				    stoa(resaddr), stoa(resmask),
+				    rflags_str(rflags)));
+			return FALSE;
 		}
-		break;
+		if (   (RES_LIMITED & res->rflags)
+		    && (RES_LIMITED & rflags)) {
+			dec_res_limited();
+		}
+		res->rflags &= ~rflags;
+		return TRUE;
 
 	case RESTRICT_REMOVE:
 	case RESTRICT_REMOVEIF:
 		/*
 		 * Remove an entry from the table entirely if we
 		 * found one. Don't remove the default entry and
-		 * don't remove an interface entry.
+		 * don't remove an interface entry unless asked.
 		 */
-		if (res != NULL
-		    && (RESTRICT_REMOVEIF == op
+		if (   res != NULL
+		    && (   RESTRICT_REMOVEIF == op
 			|| !(RESM_INTERFACE & res->mflags))
 		    && res != &restrict_def4
-		    && res != &restrict_def6)
-			free_res(res, v6);
-		break;
+		    && res != &restrict_def6) {
 
-	default:	/* unknown op */
-		INSIST(0);
-		break;
+			free_res(res, v6);
+			return TRUE;
+		}
+		DPRINTF(1, ("No match removing %s %s restriction\n",
+			    stoa(resaddr), stoa(resmask)));
+		return FALSE;
 	}
-
+	/* notreached */
+	return FALSE;
 }
 
 
@@ -744,58 +769,182 @@ hack_restrict(
 void
 restrict_source(
 	sockaddr_u *	addr,
-	int		farewell,	/* 0 to add, 1 to remove */
-	u_long		expire		/* 0 is infinite, valid until */
+	int		farewell,	/* TRUE to remove */
+	u_int32		lifetime	/* seconds, 0 forever */
 	)
 {
 	sockaddr_u	onesmask;
-	restrict_u *	res;
-	int		found_specific;
+	int/*BOOL*/	success;
 
-	if (!restrict_source_enabled || SOCK_UNSPEC(addr) ||
-	    IS_MCAST(addr) || ISREFCLOCKADR(addr))
+	if (   !restrict_source_enabled || SOCK_UNSPEC(addr)
+	    || IS_MCAST(addr) || ISREFCLOCKADR(addr)) {
 		return;
+	}
 
 	REQUIRE(AF_INET == AF(addr) || AF_INET6 == AF(addr));
 
 	SET_HOSTMASK(&onesmask, AF(addr));
 	if (farewell) {
-		hack_restrict(RESTRICT_REMOVE, addr, &onesmask,
-			      -2, 0, 0, 0);
-		DPRINTF(1, ("restrict_source: %s removed", stoa(addr)));
+		success = hack_restrict(RESTRICT_REMOVE, addr, &onesmask,
+					0, RESM_SOURCE, 0, 0);
+		if (success) {
+			DPRINTF(1, ("%s %s removed", __func__,
+				    stoa(addr)));
+		} else {
+			msyslog(LOG_ERR, "%s remove %s failed",
+					 __func__, stoa(addr));
+		}
 		return;
 	}
 
-	/*
-	 * If there is a specific entry for this address, hands
-	 * off, as it is condidered more specific than "restrict
-	 * server ...".
-	 * However, if the specific entry found is a fleeting one
-	 * added by pool_xmit() before soliciting, replace it
-	 * immediately regardless of the expire value to make way
-	 * for the more persistent entry.
-	 */
-	if (IS_IPV4(addr)) {
-		res = match_restrict4_addr(SRCADR(addr), SRCPORT(addr));
-		INSIST(res != NULL);
-		found_specific = (SRCADR(&onesmask) == res->u.v4.mask);
+	success = hack_restrict(RESTRICT_FLAGS, addr, &onesmask,
+				restrict_source_ippeerlimit,
+				restrict_source_mflags,
+				restrict_source_rflags, 
+				lifetime > 0
+				    ? lifetime + current_time
+				    : 0);
+	if (success) {
+		DPRINTF(1, ("%s %s add/upd\n", __func__,
+			    stoa(addr)));
 	} else {
-		res = match_restrict6_addr(&SOCK_ADDR6(addr),
-					   SRCPORT(addr));
-		INSIST(res != NULL);
-		found_specific = ADDR6_EQ(&res->u.v6.mask,
-					  &SOCK_ADDR6(&onesmask));
+		msyslog(LOG_ERR, "%s %s failed", __func__, stoa(addr));
 	}
-	if (!expire && found_specific && res->expire) {
-		found_specific = 0;
-		free_res(res, IS_IPV6(addr));
+}
+
+
+#ifdef DEBUG
+/* Convert restriction RES_ flag bits into a display string */
+const char *
+rflags_str(
+	u_short rflags
+	)
+{
+	const size_t	sz = LIB_BUFLENGTH;
+	char *		rfs;
+
+	LIB_GETBUF(rfs);
+	rfs[0] = '\0';
+
+	if (rflags & RES_FLAKE) {
+		CLEAR_BIT_IF_DEBUG(RES_FLAKE, rflags);
+		append_flagstr(rfs, sz, "flake");
 	}
-	if (found_specific)
-		return;
 
-	hack_restrict(RESTRICT_FLAGS, addr, &onesmask,
-		      restrict_source_ippeerlimit, 
-		      restrict_source_mflags, restrict_source_rflags, expire);
-	DPRINTF(1, ("restrict_source: %s host restriction added\n", 
-		    stoa(addr)));
+	if (rflags & RES_IGNORE) {
+		CLEAR_BIT_IF_DEBUG(RES_IGNORE, rflags);
+		append_flagstr(rfs, sz, "ignore");
+	}
+
+	if (rflags & RES_KOD) {
+		CLEAR_BIT_IF_DEBUG(RES_KOD, rflags);
+		append_flagstr(rfs, sz, "kod");
+	}
+
+	if (rflags & RES_MSSNTP) {
+		CLEAR_BIT_IF_DEBUG(RES_MSSNTP, rflags);
+		append_flagstr(rfs, sz, "mssntp");
+	}
+
+	if (rflags & RES_LIMITED) {
+		CLEAR_BIT_IF_DEBUG(RES_LIMITED, rflags);
+		append_flagstr(rfs, sz, "limited");
+	}
+
+	if (rflags & RES_LPTRAP) {
+		CLEAR_BIT_IF_DEBUG(RES_LPTRAP, rflags);
+		append_flagstr(rfs, sz, "lptrap");
+	}
+
+	if (rflags & RES_NOMODIFY) {
+		CLEAR_BIT_IF_DEBUG(RES_NOMODIFY, rflags);
+		append_flagstr(rfs, sz, "nomodify");
+	}
+
+	if (rflags & RES_NOMRULIST) {
+		CLEAR_BIT_IF_DEBUG(RES_NOMRULIST, rflags);
+		append_flagstr(rfs, sz, "nomrulist");
+	}
+
+	if (rflags & RES_NOEPEER) {
+		CLEAR_BIT_IF_DEBUG(RES_NOEPEER, rflags);
+		append_flagstr(rfs, sz, "noepeer");
+	}
+
+	if (rflags & RES_NOPEER) {
+		CLEAR_BIT_IF_DEBUG(RES_NOPEER, rflags);
+		append_flagstr(rfs, sz, "nopeer");
+	}
+
+	if (rflags & RES_NOQUERY) {
+		CLEAR_BIT_IF_DEBUG(RES_NOQUERY, rflags);
+		append_flagstr(rfs, sz, "noquery");
+	}
+
+	if (rflags & RES_DONTSERVE) {
+		CLEAR_BIT_IF_DEBUG(RES_DONTSERVE, rflags);
+		append_flagstr(rfs, sz, "dontserve");
+	}
+
+	if (rflags & RES_NOTRAP) {
+		CLEAR_BIT_IF_DEBUG(RES_NOTRAP, rflags);
+		append_flagstr(rfs, sz, "notrap");
+	}
+
+	if (rflags & RES_DONTTRUST) {
+		CLEAR_BIT_IF_DEBUG(RES_DONTTRUST, rflags);
+		append_flagstr(rfs, sz, "notrust");
+	}
+
+	if (rflags & RES_SRVRSPFUZ) {
+		CLEAR_BIT_IF_DEBUG(RES_SRVRSPFUZ, rflags);
+		append_flagstr(rfs, sz, "srvrspfuz");
+	}
+
+	if (rflags & RES_VERSION) {
+		CLEAR_BIT_IF_DEBUG(RES_VERSION, rflags);
+		append_flagstr(rfs, sz, "version");
+	}
+
+	DEBUG_INVARIANT(!rflags);
+
+	if ('\0' == rfs[0]) {
+		append_flagstr(rfs, sz, "(none)");
+	}
+
+	return rfs;
+}
+
+
+/* Convert restriction match RESM_ flag bits into a display string */
+const char *
+mflags_str(
+	u_short mflags
+	)
+{
+	const size_t	sz = LIB_BUFLENGTH;
+	char *		mfs;
+
+	LIB_GETBUF(mfs);
+	mfs[0] = '\0';
+
+	if (mflags & RESM_NTPONLY) {
+		CLEAR_BIT_IF_DEBUG(RESM_NTPONLY, mflags);
+		append_flagstr(mfs, sz, "ntponly");
+	}
+
+	if (mflags & RESM_SOURCE) {
+		CLEAR_BIT_IF_DEBUG(RESM_SOURCE, mflags);
+		append_flagstr(mfs, sz, "source");
+	}
+
+	if (mflags & RESM_INTERFACE) {
+		CLEAR_BIT_IF_DEBUG(RESM_INTERFACE, mflags);
+		append_flagstr(mfs, sz, "interface");
+	}
+
+	DEBUG_INVARIANT(!mflags);
+
+	return mfs;
 }
+#endif	/* DEBUG */
diff --git a/contrib/ntp/ntpd/ntp_scanner.c b/contrib/ntp/ntpd/ntp_scanner.c
index 08c203c63e8a..531d66024982 100644
--- a/contrib/ntp/ntpd/ntp_scanner.c
+++ b/contrib/ntp/ntpd/ntp_scanner.c
@@ -34,7 +34,7 @@
  * ------------------------
  */
 
-#define MAX_LEXEME (1024 + 1)	/* The maximum size of a lexeme */
+#define MAX_LEXEME	128	/* The maximum size of a lexeme */
 char yytext[MAX_LEXEME];	/* Buffer for storing the input text/lexeme */
 u_int32 conf_file_sum;		/* Simple sum of characters read */
 
@@ -278,7 +278,7 @@ lex_close(
  */
 
 static struct FILE_INFO *
-_drop_stack_do(
+drop_stack_do(
 	struct FILE_INFO * head
 	)
 {
@@ -320,9 +320,9 @@ lex_init_stack(
  * anything until the next 'lex_init_stack()' succeeded.
  */
 void
-lex_drop_stack()
+lex_drop_stack(void)
 {
-	lex_stack = _drop_stack_do(lex_stack);
+	lex_stack = drop_stack_do(lex_stack);
 }
 
 /* Flush the lexer input stack: This will nip all input objects on the
@@ -334,14 +334,14 @@ lex_drop_stack()
  * in the force-eof mode before this call.
  */
 int/*BOOL*/
-lex_flush_stack()
+lex_flush_stack(void)
 {
 	int retv = FALSE;
 
 	if (NULL != lex_stack) {
 		retv = !lex_stack->force_eof;
 		lex_stack->force_eof = TRUE;
-		lex_stack->st_next = _drop_stack_do(
+		lex_stack->st_next = drop_stack_do(
 					lex_stack->st_next);
 	}
 	return retv;
@@ -425,7 +425,7 @@ lex_from_file(void)
 }
 
 struct FILE_INFO *
-lex_current()
+lex_current(void)
 {
 	/* this became so simple, it could be a macro. But then,
 	 * lex_stack needed to be global...
@@ -910,9 +910,9 @@ yylex(void)
 
 normal_return:
 	if (T_EOC == token)
-		DPRINTF(4,("\t<end of command>\n"));
+		DPRINTF(10, ("\t<end of command>\n"));
 	else
-		DPRINTF(4, ("yylex: lexeme '%s' -> %s\n", yytext,
+		DPRINTF(10, ("yylex: lexeme '%s' -> %s\n", yytext,
 			    token_name(token)));
 
 	if (!yylval_was_set)
@@ -921,6 +921,10 @@ yylex(void)
 	return token;
 
 lex_too_long:
+	/*
+	 * DLH: What is the purpose of the limit of 50?
+	 * Is there any reason for yytext[] to be bigger?
+	 */
 	yytext[min(sizeof(yytext) - 1, 50)] = 0;
 	msyslog(LOG_ERR, 
 		"configuration item on line %d longer than limit of %lu, began with '%s'",
diff --git a/contrib/ntp/ntpd/ntp_timer.c b/contrib/ntp/ntpd/ntp_timer.c
index 4f669f0699fa..c8164d798b04 100644
--- a/contrib/ntp/ntpd/ntp_timer.c
+++ b/contrib/ntp/ntpd/ntp_timer.c
@@ -46,7 +46,7 @@ static void check_leapsec(u_int32, const time_t*, int/*BOOL*/);
 
 /*
  * These routines provide support for the event timer.  The timer is
- * implemented by an interrupt routine which sets a flag once every
+ * implemented by a signal routine which sets a flag once every
  * second, and a timer routine which is called when the mainline code
  * gets around to seeing the flag.  The timer routine dispatches the
  * clock adjustment code if its time has come, then searches the timer
@@ -54,7 +54,6 @@ static void check_leapsec(u_int32, const time_t*, int/*BOOL*/);
  * Finally, we call the hourly procedure to do cleanup and print a
  * message.
  */
-volatile int interface_interval;     /* init_io() sets def. 300s */
 
 /*
  * Initializing flag.  All async routines watch this and only do their
@@ -70,14 +69,15 @@ volatile int alarm_flag;
 /*
  * The counters and timeouts
  */
-static  u_long interface_timer;	/* interface update timer */
+	u_long endpt_scan_timer;	/* interface update timer */
 static	u_long adjust_timer;	/* second timer */
 static	u_long stats_timer;	/* stats timer */
 static	u_long leapf_timer;	/* Report leapfile problems once/day */
 static	u_long huffpuff_timer;	/* huff-n'-puff timer */
 static	u_long worker_idle_timer;/* next check for idle intres */
-u_long	leapsec;	        /* seconds to next leap (proximity class) */
-int     leapdif;                /* TAI difference step at next leap second*/
+int	endpt_scan_period;	/* init_io() sets def. 301s */
+u_long	leapsec;		/* seconds to next leap (proximity class) */
+int	leapdif;		/* TAI difference step at next leap second*/
 u_long	orphwait; 		/* orphan wait time */
 #ifdef AUTOKEY
 static	u_long revoke_timer;	/* keys revoke timer */
@@ -198,7 +198,7 @@ init_timer(void)
 	stats_timer = SECSPERHR;
 	leapf_timer = SECSPERDAY;
 	huffpuff_timer = 0;
-	interface_timer = 0;
+	endpt_scan_timer = 0;
 	current_time = 0;
 	timer_overflows = 0;
 	timer_xmtcalls = 0;
@@ -249,7 +249,7 @@ init_timer(void)
 		BOOL		rc;
 
 		Period = (1 << EVENT_TIMEOUT) * 1000;
-		DueTime.QuadPart = Period * 10000i64;
+		DueTime.QuadPart = Period * 10000ll;
 		rc = SetWaitableTimer(WaitableTimerHandle, &DueTime,
 				      Period, NULL, NULL, FALSE);
 		if (!rc) {
@@ -296,10 +296,10 @@ intres_timeout_req(
 void
 timer(void)
 {
-	struct peer *	p;
-	struct peer *	next_peer;
+	struct peer* p;
+	struct peer* next_peer;
 	l_fp		now;
-	time_t          tnow;
+	time_t		tnow;
 
 	/*
 	 * The basic timerevent is one second.  This is used to adjust the
@@ -333,15 +333,18 @@ timer(void)
 		 * usually tripped using iburst and minpoll of
 		 * 128 s or less.
 		 */
-		if (p->throttle > 0)
+		if (p->throttle > 0) {
 			p->throttle--;
+		}
 		if (p->nextdate <= current_time) {
 #ifdef REFCLOCK
-			if (FLAG_REFCLOCK & p->flags)
+			if (FLAG_REFCLOCK & p->flags) {
 				refclock_transmit(p);
-			else
+			} else
 #endif	/* REFCLOCK */
+			{
 				transmit(p);
+			}
 		}
 	}
 
@@ -370,7 +373,8 @@ timer(void)
 #endif	/* AUTOKEY */
 			}
 			sys_stratum = (u_char)sys_orphan;
-		} else {
+		}
+		else {
 			if (sys_leap != LEAP_NOTINSYNC) {
 				set_sys_leap(LEAP_NOTINSYNC);
 				msyslog(LOG_WARNING, "%s",
@@ -379,9 +383,9 @@ timer(void)
 			sys_stratum = STRATUM_UNSPEC;
 		}
 		if (sys_stratum > 1)
-		    sys_refid = htonl(LOOPBACKADR);
+			sys_refid = htonl(LOOPBACKADR);
 		else
-		    memcpy(&sys_refid, "LOOP", 4);
+			memcpy(&sys_refid, "ORPH", 4);
 		sys_offset = 0;
 		sys_rootdelay = 0;
 		sys_rootdisp = 0;
@@ -395,17 +399,19 @@ timer(void)
 	 * is imminent or every 8th second.
 	 */
 	if (leapsec > LSPROX_NOWARN || 0 == (current_time & 7))
-		check_leapsec(now.l_ui, &tnow,
-                                (sys_leap == LEAP_NOTINSYNC));
-        if (sys_leap != LEAP_NOTINSYNC) {
-                if (leapsec >= LSPROX_ANNOUNCE && leapdif) {
-		        if (leapdif > 0)
-			        set_sys_leap(LEAP_ADDSECOND);
-		        else
-			        set_sys_leap(LEAP_DELSECOND);
-                } else {
-                        set_sys_leap(LEAP_NOWARNING);
-                }
+		check_leapsec( now.l_ui
+			     , &tnow
+			     , (sys_leap == LEAP_NOTINSYNC));
+	if (sys_leap != LEAP_NOTINSYNC) {
+		if (leapsec >= LSPROX_ANNOUNCE && leapdif) {
+			if (leapdif > 0) {
+				set_sys_leap(LEAP_ADDSECOND);
+			} else {
+				set_sys_leap(LEAP_DELSECOND);
+			}
+		} else {
+			set_sys_leap(LEAP_NOWARNING);
+		}
 	}
 
 	/*
@@ -431,23 +437,28 @@ timer(void)
 	 */
 	if (revoke_timer && revoke_timer <= current_time) {
 		revoke_timer += (1UL << sys_revoke);
-		RAND_bytes((u_char *)&sys_private, 4);
+		RAND_bytes((u_char *)&sys_private, sizeof(sys_private));
 	}
 #endif	/* AUTOKEY */
 
 	/*
-	 * Interface update timer
+	 * Network interface rescan timer
 	 */
-	if (interface_interval && interface_timer <= current_time) {
-		timer_interfacetimeout(current_time +
-		    interface_interval);
-		DPRINTF(2, ("timer: interface update\n"));
+	if (endpt_scan_timer && endpt_scan_timer <= current_time) {
+		if (no_periodic_scan) {
+			endpt_scan_timer = 0;
+			DPRINTF(2, ("timer: network interface rescan disabled\n"));
+		} else {
+			endpt_scan_timer =   current_time
+					   + endpt_scan_period;
+			DPRINTF(2, ("timer: network interface rescan in %d seconds\n", endpt_scan_period));
+		}
 		interface_update(NULL, NULL);
 	}
 
-	if (worker_idle_timer && worker_idle_timer <= current_time)
+	if (worker_idle_timer && worker_idle_timer <= current_time) {
 		worker_idle_timer_fired();
-
+	}
 	/*
 	 * Finally, write hourly stats and do the hourly
 	 * and daily leapfile checks.
@@ -508,13 +519,6 @@ alarming(
 #endif /* SYS_WINNT */
 
 
-void
-timer_interfacetimeout(u_long timeout)
-{
-	interface_timer = timeout;
-}
-
-
 /*
  * timer_clr_stats - clear timer module stat counters
  */
@@ -528,21 +532,27 @@ timer_clr_stats(void)
 
 
 static void
-check_leap_sec_in_progress( const leap_result_t *lsdata ) {
+check_leap_sec_in_progress(
+	const leap_result_t *lsdata
+	)
+{
 	int prv_leap_sec_in_progress = leap_sec_in_progress;
+
 	leap_sec_in_progress = lsdata->tai_diff && (lsdata->ddist < 3);
 
-	/* if changed we may have to update the leap status sent to clients */
-	if (leap_sec_in_progress != prv_leap_sec_in_progress)
+	/* if changed we have to update the leap bits sent to clients */
+	if (leap_sec_in_progress != prv_leap_sec_in_progress) {
 		set_sys_leap(sys_leap);
+	}
 }
 
 
 static void
 check_leapsec(
-	u_int32        now  ,
-	const time_t * tpiv ,
-        int/*BOOL*/    reset)
+	u_int32		now,
+	const time_t *	tpiv,
+	int/*BOOL*/	reset
+	)
 {
 	static const char leapmsg_p_step[] =
 	    "Positive leap second, stepped backward.";
@@ -556,10 +566,10 @@ check_leapsec(
 	    "Negative leap second, no step correction. "
 	    "System clock will be inaccurate for a long time.";
 
-	leap_result_t lsdata;
-	u_int32       lsprox;
+	leap_result_t	lsdata;
+	u_int32		lsprox;
 #ifdef AUTOKEY
-	int/*BOOL*/   update_autokey = FALSE;
+	int/*BOOL*/	update_autokey = FALSE;
 #endif
 
 #ifndef SYS_WINNT  /* WinNT port has its own leap second handling */
@@ -568,122 +578,116 @@ check_leapsec(
 # else
 	leapsec_electric(0);
 # endif
-#endif
+#endif	/* !SYS_WINNT */
+
 #ifdef LEAP_SMEAR
 	leap_smear.enabled = leap_smear_intv != 0;
 #endif
 	if (reset) {
 		lsprox = LSPROX_NOWARN;
 		leapsec_reset_frame();
-		memset(&lsdata, 0, sizeof(lsdata));
+		ZERO(lsdata);
 	} else {
-	  int fired;
+		int fired;
 
-	  fired = leapsec_query(&lsdata, now, tpiv);
+		fired = leapsec_query(&lsdata, now, tpiv);
 
-	  DPRINTF(3, ("*** leapsec_query: fired %i, now %u (0x%08X), tai_diff %i, ddist %u\n",
-		  fired, now, now, lsdata.tai_diff, lsdata.ddist));
+		DPRINTF(3, ("*** leapsec_query: fired %i, now %u (0x%08X),"
+			    " tai_diff %i, ddist %u\n",
+			    fired, now, now, lsdata.tai_diff, lsdata.ddist));
 
 #ifdef LEAP_SMEAR
-	  leap_smear.in_progress = 0;
-	  leap_smear.doffset = 0.0;
-
-	  if (leap_smear.enabled) {
-		if (lsdata.tai_diff) {
-			if (leap_smear.interval == 0) {
-				leap_smear.interval = leap_smear_intv;
-				leap_smear.intv_end = lsdata.ttime.Q_s;
-				leap_smear.intv_start = leap_smear.intv_end - leap_smear.interval;
-				DPRINTF(1, ("*** leapsec_query: setting leap_smear interval %li, begin %.0f, end %.0f\n",
+		leap_smear.in_progress = FALSE;
+		leap_smear.doffset = 0.0;
+
+		if (leap_smear.enabled) {
+			if (lsdata.tai_diff) {
+				if (0 == leap_smear.interval) {
+					leap_smear.interval = leap_smear_intv;
+					leap_smear.intv_end = lsdata.ttime.Q_s;
+					leap_smear.intv_start = leap_smear.intv_end - leap_smear.interval;
+					DPRINTF(1, ("*** leapsec_query: setting leap_smear interval %li, begin %.0f, end %.0f\n",
 					leap_smear.interval, leap_smear.intv_start, leap_smear.intv_end));
+				}
+			} else {
+				if (leap_smear.interval) {
+					DPRINTF(1, ("*** leapsec_query: clearing leap_smear interval\n"));
+					leap_smear.interval = 0;
+				}
 			}
-		} else {
-			if (leap_smear.interval)
-				DPRINTF(1, ("*** leapsec_query: clearing leap_smear interval\n"));
-			leap_smear.interval = 0;
-		}
 
-		if (leap_smear.interval) {
-			double dtemp = now;
-			if (dtemp >= leap_smear.intv_start && dtemp <= leap_smear.intv_end) {
-				double leap_smear_time = dtemp - leap_smear.intv_start;
-				/*
-				 * For now we just do a linear interpolation over the smear interval
-				 */
+			if (leap_smear.interval) {
+				double dtemp = now;
+
+				if (dtemp >= leap_smear.intv_start && dtemp <= leap_smear.intv_end) {
+					double leap_smear_time = dtemp - leap_smear.intv_start;
 #if 0
-				// linear interpolation
-				leap_smear.doffset = -(leap_smear_time * lsdata.tai_diff / leap_smear.interval);
+					/*  linear interpolation */
+					leap_smear.doffset = -(leap_smear_time * lsdata.tai_diff / leap_smear.interval);
 #else
-				// Google approach: lie(t) = (1.0 - cos(pi * t / w)) / 2.0
-				leap_smear.doffset = -((double) lsdata.tai_diff - cos( M_PI * leap_smear_time / leap_smear.interval)) / 2.0;
+					/* Google approach : lie(t) = (1.0 - cos(pi * t / w)) / 2.0 */
+					leap_smear.doffset = -((double) lsdata.tai_diff - cos( M_PI * leap_smear_time / leap_smear.interval)) / 2.0;
 #endif
-				/*
-				 * TODO see if we're inside an inserted leap second, so we need to compute
-				 * leap_smear.doffset = 1.0 - leap_smear.doffset
-				 */
-				leap_smear.in_progress = 1;
-#if 0 && defined( DEBUG )
-				msyslog(LOG_NOTICE, "*** leapsec_query: [%.0f:%.0f] (%li), now %u (%.0f), smear offset %.6f ms\n",
-					leap_smear.intv_start, leap_smear.intv_end, leap_smear.interval,
-					now, leap_smear_time, leap_smear.doffset);
-#else
-				DPRINTF(1, ("*** leapsec_query: [%.0f:%.0f] (%li), now %u (%.0f), smear offset %.6f ms\n",
+					/*
+					 * TODO see if we're inside an inserted leap second, so we need to compute
+					 * leap_smear.doffset = 1.0 - leap_smear.doffset
+					 */
+					leap_smear.in_progress = TRUE;
+					DPRINTF(1, ("*** leapsec_query: [%.0f:%.0f] (%li), now %u (%.0f), smear offset %.6f ms\n",
 					leap_smear.intv_start, leap_smear.intv_end, leap_smear.interval,
 					now, leap_smear_time, leap_smear.doffset));
-#endif
 
+				}
 			}
+		} else {
+			leap_smear.interval = 0;
 		}
-	  }
-	  else
-		leap_smear.interval = 0;
-
-	  /*
-	   * Update the current leap smear offset, eventually 0.0 if outside smear interval.
-	   */
-	  DTOLFP(leap_smear.doffset, &leap_smear.offset);
-
+		/*
+		 * Update the current leap smear offset, eventually 0.0 if outside smear interval.
+		 */
+		DTOLFP(leap_smear.doffset, &leap_smear.offset);
 #endif	/* LEAP_SMEAR */
 
-	  if (fired) {
-		/* Full hit. Eventually step the clock, but always
-		 * announce the leap event has happened.
-		 */
-		const char *leapmsg = NULL;
-		double      lswarp  = lsdata.warped;
-		if (lswarp < 0.0) {
-			if (clock_max_back > 0.0 &&
-			    clock_max_back < -lswarp) {
-				step_systime(lswarp);
-				leapmsg = leapmsg_p_step;
-			} else {
-				leapmsg = leapmsg_p_slew;
+		if (fired) {
+			/* Full hit. Eventually step the clock, but always
+			 * announce the leap event has happened.
+			 */
+			const char *leapmsg = NULL;
+			double      lswarp  = lsdata.warped;
+			if (lswarp < 0.0) {
+				if (clock_max_back > 0.0 &&
+				    clock_max_back < -lswarp) {
+					step_systime(lswarp);
+					leapmsg = leapmsg_p_step;
+				} else {
+					leapmsg = leapmsg_p_slew;
+				}
+			} else 	if (lswarp > 0.0) {
+				if (clock_max_fwd > 0.0 &&
+				    clock_max_fwd < lswarp) {
+					step_systime(lswarp);
+					leapmsg = leapmsg_n_step;
+				} else {
+					leapmsg = leapmsg_n_slew;
+				}
 			}
-		} else 	if (lswarp > 0.0) {
-			if (clock_max_fwd > 0.0 &&
-			    clock_max_fwd < lswarp) {
-				step_systime(lswarp);
-				leapmsg = leapmsg_n_step;
-			} else {
-				leapmsg = leapmsg_n_slew;
+			if (leapmsg) {
+				msyslog(LOG_NOTICE, "%s", leapmsg);
 			}
-		}
-		if (leapmsg)
-			msyslog(LOG_NOTICE, "%s", leapmsg);
-		report_event(EVNT_LEAP, NULL, NULL);
+			report_event(EVNT_LEAP, NULL, NULL);
 #ifdef AUTOKEY
-		update_autokey = TRUE;
+			update_autokey = TRUE;
 #endif
-		lsprox  = LSPROX_NOWARN;
-		leapsec = LSPROX_NOWARN;
-		sys_tai = lsdata.tai_offs;
-	  } else {
+			lsprox  = LSPROX_NOWARN;
+			leapsec = LSPROX_NOWARN;
+			sys_tai = lsdata.tai_offs;
+		} else {
 #ifdef AUTOKEY
-		  update_autokey = (sys_tai != (u_int)lsdata.tai_offs);
+			update_autokey = (sys_tai != (u_int)lsdata.tai_offs);
 #endif
-		  lsprox  = lsdata.proximity;
-		  sys_tai = lsdata.tai_offs;
-	  }
+			lsprox  = lsdata.proximity;
+			sys_tai = lsdata.tai_offs;
+		}
 	}
 
 	/* We guard against panic alarming during the red alert phase.
@@ -691,13 +695,13 @@ check_leapsec(
 	 * to piping hot in one step. If things are already that wobbly,
 	 * we let the normal clock correction take over, even if a jump
 	 * is involved.
-         * Also make sure the alarming events are edge-triggered, that is,
-         * ceated only when the threshold is crossed.
-         */
-	if (  (leapsec > 0 || lsprox < LSPROX_ALERT)
-	    && leapsec < lsprox                     ) {
+	 * Also make sure the alarming events are edge-triggered, that is,
+	 * created only when the threshold is crossed.
+	 */
+	if (   (leapsec > 0 || lsprox < LSPROX_ALERT)
+	    && leapsec < lsprox) {
 		if (  leapsec < LSPROX_SCHEDULE
-                   && lsprox >= LSPROX_SCHEDULE) {
+		   && lsprox >= LSPROX_SCHEDULE) {
 			if (lsdata.dynamic)
 				report_event(PEVNT_ARMED, sys_peer, NULL);
 			else
@@ -706,22 +710,23 @@ check_leapsec(
 		leapsec = lsprox;
 	}
 	if (leapsec > lsprox) {
-		if (  leapsec >= LSPROX_SCHEDULE
-                   && lsprox   < LSPROX_SCHEDULE) {
+		if (   leapsec >= LSPROX_SCHEDULE
+		    && lsprox   < LSPROX_SCHEDULE) {
 			report_event(EVNT_DISARMED, NULL, NULL);
 		}
 		leapsec = lsprox;
 	}
 
-	if (leapsec >= LSPROX_SCHEDULE)
+	if (leapsec >= LSPROX_SCHEDULE) {
 		leapdif = lsdata.tai_diff;
-	else
+	} else {
 		leapdif = 0;
-
+	}
 	check_leap_sec_in_progress(&lsdata);
 
 #ifdef AUTOKEY
-	if (update_autokey)
+	if (update_autokey) {
 		crypto_update_taichange();
+	}
 #endif
 }
diff --git a/contrib/ntp/ntpd/ntp_util.c b/contrib/ntp/ntpd/ntp_util.c
index 62a997e43aad..e7b374fc346f 100644
--- a/contrib/ntp/ntpd/ntp_util.c
+++ b/contrib/ntp/ntpd/ntp_util.c
@@ -13,7 +13,6 @@
 #include "ntp_assert.h"
 #include "ntp_calendar.h"
 #include "ntp_leapsec.h"
-#include "lib_strbuf.h"
 
 #include <stdio.h>
 #include <ctype.h>
@@ -63,7 +62,6 @@ char	*stats_drift_file;		/* frequency file name */
 static	char *stats_temp_file;		/* temp frequency file name */
 static double wander_resid;		/* last frequency update */
 double	wander_threshold = 1e-7;	/* initial frequency threshold */
-static unsigned int cmdargs_seen = 0;	/* stat options seen from command line */
 
 /*
  * Statistics file stuff
@@ -183,7 +181,7 @@ init_util(void)
 void
 write_stats(void)
 {
-	FILE	*fp;
+	FILE	*fp = NULL;
 #ifdef DOSYNCTODR
 	struct timeval tv;
 #if !defined(VMS)
@@ -267,12 +265,10 @@ write_stats(void)
 		 * the frequncy file. This minimizes the file writes to
 		 * nonvolaile storage.
 		 */
-#ifdef DEBUG
-		if (debug)
-			printf("write_stats: frequency %.6lf thresh %.6lf, freq %.6lf\n",
+		DPRINTF(1, ("write_stats: frequency %.6f thresh %.6f, freq %.6f\n",
 			    (prev_drift_comp - drift_comp) * 1e6, wander_resid *
-			    1e6, drift_comp * 1e6);
-#endif
+			    1e6, drift_comp * 1e6));
+
 		if (fabs(prev_drift_comp - drift_comp) < wander_resid) {
 			wander_resid *= 0.5;
 			return;
@@ -284,7 +280,7 @@ write_stats(void)
 			    stats_temp_file);
 			return;
 		}
-		fprintf(fp, "%.3f\n", drift_comp * 1e6);
+		fprintf(fp, "%.6f\n", drift_comp * 1e6);
 		(void)fclose(fp);
 		/* atomic */
 #ifdef SYS_WINNT
@@ -326,29 +322,38 @@ write_stats(void)
 
 
 /*
- * stats_config - configure the stats operation
+ * If an option was given on the command line make sure it takes
+ * precedence over the configuration file, as command-line options
+ * are processed first.  Similarly, if an option is given in the
+ * configuration file, do not allow it to be overridden with runtime
+ * configuration.  Done by simply remembering an option was already
+ * seen.
  */
 static int
 allow_config(
-	unsigned int	option,
-	int/*BOOL*/	cmdopt)
+	u_int		option,
+	int/*BOOL*/	cmdopt
+	)
 {
-	/* If an option was given on the command line, make sure it
-	 * persists and is not later changed by a corresponding option
-	 * from the config file. Done by simply remembering an option was
-	 * already seen from the command line.
-	 * 
-	 * BTW, if we ever define stats options beyond 31, this needs a
-	 * fix. Until then, simply assume the shift will not overflow.
-	 */
-	unsigned int mask = 1u << option;
-	int          retv = cmdopt || !(cmdargs_seen & mask);
-	if (cmdopt) 
-		cmdargs_seen |= mask;
+	static u_int	seen = 0;	/* stat options previously set */
+	u_int		mask;
+	int		retv;
+
+	if (cmdopt) {
+		DEBUG_REQUIRE(option < sizeof(mask) * 8);
+		mask = 1u << option;
+		retv = !(seen & mask);
+		seen |= mask;
+	} else {
+		retv = FALSE;
+	}
 	return retv;
 }
 
 
+/*
+ * stats_config - configure the stats operation
+ */
 void
 stats_config(
 	int item,
@@ -356,12 +361,13 @@ stats_config(
 	int optflag
 	)
 {
-	FILE	*fp;
+	FILE	*fp = NULL;
 	const char *value;
 	size_t	len;
 	double	old_drift;
 	l_fp	now;
 	time_t  ttnow;
+	char	dirsep_or_nul;
 #ifndef VMS
 	static const char temp_ext[] = ".TEMP";
 #else
@@ -415,137 +421,131 @@ stats_config(
 
 	switch (item) {
 
-	/*
-	 * Open and read frequency file.
-	 */
+		/*
+		 * Open and read frequency file.
+		 */
 	case STATS_FREQ_FILE:
-		if (!allow_config(STATS_FREQ_FILE, optflag))
+		if (!allow_config(STATS_FREQ_FILE, optflag)) {
 			break;
-		
-		if (!value || (len = strlen(value)) == 0)
-		{
+		}
+		if (!value || 0 == (len = strlen(value))) {
 			free(stats_drift_file);
 			free(stats_temp_file);
-			stats_drift_file = stats_temp_file = NULL;    
-		}
-		else
-		{
-			stats_drift_file = erealloc(stats_drift_file, len + 1);
+			stats_drift_file = stats_temp_file = NULL;
+		} else {
+			stats_drift_file = erealloc(stats_drift_file,
+						    1 + len);
 			stats_temp_file = erealloc(stats_temp_file,
-						   len + sizeof(".TEMP"));
-			memcpy(stats_drift_file, value, (size_t)(len+1));
-			memcpy(stats_temp_file, value, (size_t)len);
-			memcpy(stats_temp_file + len, temp_ext, sizeof(temp_ext));
+						   len + sizeof(temp_ext));
+			memcpy(stats_drift_file, value, 1 + len);
+			memcpy(stats_temp_file, value, len);
+			memcpy(stats_temp_file + len, temp_ext, 
+			       sizeof(temp_ext));
 		}
-		
+
 		/*
 		 * Open drift file and read frequency. If the file is
 		 * missing or contains errors, tell the loop to reset.
 		 */
 		if (NULL == stats_drift_file) {
-			loop_config(LOOP_NOFREQ, 0.0);
-			prev_drift_comp = 0.0;
+			goto nofreq;
 		} else if ((fp = fopen(stats_drift_file, "r")) == NULL) {
-			if (errno != ENOENT)
+			if (errno != ENOENT) {
 				msyslog(LOG_WARNING,
-					"cannot read frequency file %s: %s",
-					stats_drift_file, strerror(errno));
+					"cannot read frequency file %s: %m",
+					stats_drift_file);
+			}
+			goto nofreq;
 		} else if (fscanf(fp, "%lf", &old_drift) != 1) {
 			msyslog(LOG_ERR,
 				"format error frequency file %s",
 				stats_drift_file);
-			fclose(fp);
+	nofreq:
+			prev_drift_comp = 0.0;
+			loop_config(LOOP_NOFREQ, prev_drift_comp);
 		} else {
 			loop_config(LOOP_FREQ, old_drift);
 			prev_drift_comp = drift_comp;
 			msyslog(LOG_INFO,
-				"initial drift restored to %f",
+				"initial drift restored to %.6f",
 				old_drift);
+		}
+		if (NULL != fp) {
 			fclose(fp);
 		}
 		break;
 
-	/*
-	 * Specify statistics directory.
-	 */
+		/*
+		 * Specify statistics directory.
+		 */
 	case STATS_STATSDIR:
-		if (!allow_config(STATS_STATSDIR, optflag))
+		if (!allow_config(STATS_STATSDIR, optflag)) {
 			break;
-
-		/* - 1 since value may be missing the DIR_SEP. */
-		if (strlen(value) >= sizeof(statsdir) - 1) {
+		}
+		/* - 2 since value may be missing the DIR_SEP. */
+		len = strlen(value);
+		if (len > sizeof(statsdir) - 2) {
 			msyslog(LOG_ERR,
-			    "statsdir too long (>%d, sigh)",
-			    (int)sizeof(statsdir) - 2);
+				"statsdir %s too long (>%u)", value,
+				(u_int)sizeof(statsdir) - 2);
+			break;
+		}
+		/* Add a DIR_SEP unless we already have one. */
+		if (0 == len || DIR_SEP == value[len - 1]) {
+			dirsep_or_nul = '\0';
 		} else {
-			int add_dir_sep;
-			size_t value_l;
-
-			/* Add a DIR_SEP unless we already have one. */
-			value_l = strlen(value);
-			if (0 == value_l)
-				add_dir_sep = FALSE;
-			else
-				add_dir_sep = (DIR_SEP !=
-				    value[value_l - 1]);
-
-			if (add_dir_sep)
-				snprintf(statsdir, sizeof(statsdir),
-				    "%s%c", value, DIR_SEP);
-			else
-				snprintf(statsdir, sizeof(statsdir),
-				    "%s", value);
-			filegen_statsdir();
+			dirsep_or_nul = DIR_SEP;
 		}
+		snprintf(statsdir, sizeof(statsdir), "%s%c",
+			 value, dirsep_or_nul);
+		filegen_statsdir();
 		break;
 
-	/*
-	 * Open pid file.
-	 */
+		/*
+		 * Write pid file.
+		 */
 	case STATS_PID_FILE:
-		if (!allow_config(STATS_PID_FILE, optflag))
+		if (!allow_config(STATS_PID_FILE, optflag)) {
 			break;
-		
+		}
 		if ((fp = fopen(value, "w")) == NULL) {
-			msyslog(LOG_ERR, "pid file %s: %m",
-			    value);
+			msyslog(LOG_ERR, "pid file %s: %m", value);
 			break;
 		}
-		fprintf(fp, "%d", (int)getpid());
+		fprintf(fp, "%ld", (long)getpid());
 		fclose(fp);
 		break;
 
 	/*
 	 * Read leapseconds file.
 	 *
-	 * Note: Currently a leap file without SHA1 signature is
-	 * accepted, but if there is a signature line, the signature
-	 * must be valid or the file is rejected.
+	 * By default a leap file without SHA1 signature is accepted,
+	 * but if there is a signature line, the signature must be
+	 * valid or the leapfile line in ntp.conf must have ignorehash.
 	 */
 	case STATS_LEAP_FILE:
-		if (!value || (len = strlen(value)) == 0)
+		if (NULL == value || 0 == (len = strlen(value))) {
 			break;
-
+		}
 		leapfile_name = erealloc(leapfile_name, len + 1);
 		memcpy(leapfile_name, value, len + 1);
 		chck_leaphash = optflag;
 
 		if (leapsec_load_file(
 			    leapfile_name, &leapfile_stat,
-			    TRUE, TRUE, chck_leaphash))
-		{
+			    TRUE, TRUE, chck_leaphash)) {
 			leap_signature_t lsig;
 
 			get_systime(&now);
 			time(&ttnow);
 			leapsec_getsig(&lsig);
 			mprintf_event(EVNT_TAI, NULL,
-				      "%d leap %s %s %s",
+				      "%d leap %s expire%s %s",
 				      lsig.taiof,
 				      fstostr(lsig.ttime),
 				      leapsec_expired(now.l_ui, NULL)
-					  ? "expired"
-					  : "expires",
+					  ? "d"
+					  : "s",
 				      fstostr(lsig.etime));
 
 			have_leapfile = TRUE;
@@ -579,31 +579,32 @@ stats_config(
 */
 void
 record_peer_stats(
-	sockaddr_u *addr,
-	int	status,
-	double	offset,		/* offset */
-	double	delay,		/* delay */
-	double	dispersion,	/* dispersion */
-	double	jitter		/* jitter */
+	sockaddr_u *	addr,
+	int		status,
+	double		offset,
+	double		delay,
+	double		dispersion,
+	double		jitter
 	)
 {
-	l_fp	now;
-	u_long	day;
+	l_fp		now;
+	u_long		day;
 
-	if (!stats_control)
+	if (!stats_control) {
 		return;
-
+	}
 	get_systime(&now);
 	filegen_setup(&peerstats, now.l_ui);
+	if (NULL == peerstats.fp) {
+		return;
+	}
 	day = now.l_ui / 86400 + MJD_1900;
 	now.l_ui %= 86400;
-	if (peerstats.fp != NULL) {
-		fprintf(peerstats.fp,
-		    "%lu %s %s %x %.9f %.9f %.9f %.9f\n", day,
-		    ulfptoa(&now, 3), stoa(addr), status, offset,
-		    delay, dispersion, jitter);
-		fflush(peerstats.fp);
-	}
+	fprintf(peerstats.fp,
+		"%lu %s %s %x %.9f %.9f %.9f %.9f\n", day,
+		ulfptoa(&now, 3), stoa(addr), status, offset,
+		delay, dispersion, jitter);
+	fflush(peerstats.fp);
 }
 
 
@@ -934,13 +935,14 @@ record_timing_stats(
  *
  * Note: This loads a new leapfile on the fly. Currently a leap file
  * without SHA1 signature is accepted, but if there is a signature line,
- * the signature must be valid or the file is rejected.
+ * the signature must be valid unless the ntp.conf leapfile line specified
+ * ignorehash.
  */
 void
 check_leap_file(
-	int           is_daily_check,
-	uint32_t      ntptime       ,
-	const time_t *systime
+	int		is_daily_check,
+	uint32_t	ntptime,
+	const time_t *	systime
 	)
 {
 	/* just do nothing if there is no leap file */
@@ -1097,3 +1099,20 @@ ntpd_time_stepped(void)
 	win_time_stepped();
 #endif
 }
+
+
+#ifdef DEBUG
+void
+append_flagstr(
+	char *		flagstr,
+	size_t		sz,
+	const char *	text
+)
+{
+	if ('\0' != flagstr[0]) {
+		strlcat(flagstr, ",", sz);
+	}
+	/* bail if we ran out of room */
+	INSIST(strlcat(flagstr, text, sz) < sz);
+}
+#endif	/* DEBUG */
diff --git a/contrib/ntp/ntpd/ntpd-opts.c b/contrib/ntp/ntpd/ntpd-opts.c
index 14774d684f2d..5d8b0bb33659 100644
--- a/contrib/ntp/ntpd/ntpd-opts.c
+++ b/contrib/ntp/ntpd/ntpd-opts.c
@@ -1,7 +1,7 @@
 /*
  *  EDIT THIS FILE WITH CAUTION  (ntpd-opts.c)
  *
- *  It has been AutoGen-ed  June  6, 2023 at 04:36:50 AM by AutoGen 5.18.16
+ *  It has been AutoGen-ed  May 25, 2024 at 12:03:09 AM by AutoGen 5.18.16
  *  From the definitions    ntpd-opts.def
  *  and the template file   options
  *
@@ -18,7 +18,7 @@
  * The ntpd program is copyrighted and licensed
  * under the following terms:
  *
- *  Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation, all rights reserved.
+ *  Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation, all rights reserved.
  *  This is free software. It is licensed for use, modification and
  *  redistribution under the terms of the NTP License, copies of which
  *  can be seen at:
@@ -80,8 +80,8 @@ extern FILE * option_usage_fp;
  *  static const strings for ntpd options
  */
 static char const ntpd_opt_strs[3133] =
-/*     0 */ "ntpd 4.2.8p17\n"
-            "Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation, all rights reserved.\n"
+/*     0 */ "ntpd 4.2.8p18\n"
+            "Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation, all rights reserved.\n"
             "This is free software. It is licensed for use, modification and\n"
             "redistribution under the terms of the NTP License, copies of which\n"
             "can be seen at:\n"
@@ -210,12 +210,12 @@ static char const ntpd_opt_strs[3133] =
 /*  2901 */ "output version information and exit\0"
 /*  2937 */ "version\0"
 /*  2945 */ "NTPD\0"
-/*  2950 */ "ntpd - NTP daemon program - Ver. 4.2.8p17\n"
+/*  2950 */ "ntpd - NTP daemon program - Ver. 4.2.8p18\n"
             "Usage:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n"
             "\t\t[ <server1> ... <serverN> ]\n\0"
 /*  3082 */ "https://bugs.ntp.org, bugs@ntp.org\0"
 /*  3117 */ "\n\0"
-/*  3119 */ "ntpd 4.2.8p17";
+/*  3119 */ "ntpd 4.2.8p18";
 
 /**
  *  ipv4 option description with
@@ -1534,8 +1534,8 @@ static void bogus_function(void) {
      translate option names.
    */
   /* referenced via ntpdOptions.pzCopyright */
-  puts(_("ntpd 4.2.8p17\n\
-Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation, all rights reserved.\n\
+  puts(_("ntpd 4.2.8p18\n\
+Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation, all rights reserved.\n\
 This is free software. It is licensed for use, modification and\n\
 redistribution under the terms of the NTP License, copies of which\n\
 can be seen at:\n"));
@@ -1675,7 +1675,7 @@ implied warranty.\n"));
   puts(_("output version information and exit"));
 
   /* referenced via ntpdOptions.pzUsageTitle */
-  puts(_("ntpd - NTP daemon program - Ver. 4.2.8p17\n\
+  puts(_("ntpd - NTP daemon program - Ver. 4.2.8p18\n\
 Usage:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n\
 \t\t[ <server1> ... <serverN> ]\n"));
 
@@ -1683,7 +1683,7 @@ Usage:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n\
   puts(_("\n"));
 
   /* referenced via ntpdOptions.pzFullVersion */
-  puts(_("ntpd 4.2.8p17"));
+  puts(_("ntpd 4.2.8p18"));
 
   /* referenced via ntpdOptions.pzFullUsage */
   puts(_("<<<NOT-FOUND>>>"));
diff --git a/contrib/ntp/ntpd/ntpd-opts.h b/contrib/ntp/ntpd/ntpd-opts.h
index 3541255bb6fb..99fb3dcd230f 100644
--- a/contrib/ntp/ntpd/ntpd-opts.h
+++ b/contrib/ntp/ntpd/ntpd-opts.h
@@ -1,7 +1,7 @@
 /*
  *  EDIT THIS FILE WITH CAUTION  (ntpd-opts.h)
  *
- *  It has been AutoGen-ed  June  6, 2023 at 04:36:50 AM by AutoGen 5.18.16
+ *  It has been AutoGen-ed  May 25, 2024 at 12:03:08 AM by AutoGen 5.18.16
  *  From the definitions    ntpd-opts.def
  *  and the template file   options
  *
@@ -18,7 +18,7 @@
  * The ntpd program is copyrighted and licensed
  * under the following terms:
  *
- *  Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation, all rights reserved.
+ *  Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation, all rights reserved.
  *  This is free software. It is licensed for use, modification and
  *  redistribution under the terms of the NTP License, copies of which
  *  can be seen at:
@@ -114,9 +114,9 @@ typedef enum {
 /** count of all options for ntpd */
 #define OPTION_CT    38
 /** ntpd version */
-#define NTPD_VERSION       "4.2.8p17"
+#define NTPD_VERSION       "4.2.8p18"
 /** Full ntpd version text */
-#define NTPD_FULL_VERSION  "ntpd 4.2.8p17"
+#define NTPD_FULL_VERSION  "ntpd 4.2.8p18"
 
 /**
  *  Interface defines for all options.  Replace "n" with the UPPER_CASED
diff --git a/contrib/ntp/ntpd/ntpd.1ntpdman b/contrib/ntp/ntpd/ntpd.1ntpdman
index 237a9179f62e..6d91d5725284 100644
--- a/contrib/ntp/ntpd/ntpd.1ntpdman
+++ b/contrib/ntp/ntpd/ntpd.1ntpdman
@@ -10,11 +10,11 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH ntpd 1ntpdman "06 Jun 2023" "4.2.8p17" "User Commands"
+.TH ntpd 1ntpdman "25 May 2024" "4.2.8p18" "User Commands"
 .\"
 .\" EDIT THIS FILE WITH CAUTION (in-mem file)
 .\"
-.\" It has been AutoGen-ed June 6, 2023 at 04:37:49 AM by AutoGen 5.18.16
+.\" It has been AutoGen-ed May 25, 2024 at 12:04:07 AM by AutoGen 5.18.16
 .\" From the definitions ntpd-opts.def
 .\" and the template file agman-cmd.tpl
 .SH NAME
@@ -979,7 +979,7 @@ RFC5908
 .SH "AUTHORS"
 The University of Delaware and Network Time Foundation
 .SH "COPYRIGHT"
-Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation all rights reserved.
 This program is released under the terms of the NTP license, <http://ntp.org/license>.
 .SH BUGS
 The
diff --git a/contrib/ntp/ntpd/ntpd.1ntpdmdoc b/contrib/ntp/ntpd/ntpd.1ntpdmdoc
index 536e7f672840..90e08b7aa825 100644
--- a/contrib/ntp/ntpd/ntpd.1ntpdmdoc
+++ b/contrib/ntp/ntpd/ntpd.1ntpdmdoc
@@ -1,9 +1,9 @@
-.Dd June 6 2023
+.Dd May 25 2024
 .Dt NTPD 1ntpdmdoc User Commands
 .Os
 .\"  EDIT THIS FILE WITH CAUTION  (ntpd-opts.mdoc)
 .\"
-.\"  It has been AutoGen-ed  June  6, 2023 at 04:37:36 AM by AutoGen 5.18.16
+.\"  It has been AutoGen-ed  May 25, 2024 at 12:03:54 AM by AutoGen 5.18.16
 .\"  From the definitions    ntpd-opts.def
 .\"  and the template file   agmdoc-cmd.tpl
 .Sh NAME
@@ -886,7 +886,7 @@ A snapshot of this documentation is available in HTML format in
 .Sh "AUTHORS"
 The University of Delaware and Network Time Foundation
 .Sh "COPYRIGHT"
-Copyright (C) 1992\-2023 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992\-2024 The University of Delaware and Network Time Foundation all rights reserved.
 This program is released under the terms of the NTP license, <http://ntp.org/license>.
 .Sh BUGS
 The
diff --git a/contrib/ntp/ntpd/ntpd.c b/contrib/ntp/ntpd/ntpd.c
index e58a0613bdcc..b64caae06da1 100644
--- a/contrib/ntp/ntpd/ntpd.c
+++ b/contrib/ntp/ntpd/ntpd.c
@@ -101,16 +101,6 @@
 #include "recvbuff.h"
 #include "ntp_cmdargs.h"
 
-#if 0				/* HMS: I don't think we need this. 961223 */
-#ifdef LOCK_PROCESS
-# ifdef SYS_SOLARIS
-#  include <sys/mman.h>
-# else
-#  include <sys/lock.h>
-# endif
-#endif
-#endif
-
 #ifdef SYS_WINNT
 # include "ntservice.h"
 #endif
@@ -145,6 +135,13 @@
 # include <seccomp.h>
 #endif /* LIBSECCOMP and KERN_SECCOMP */
 
+#if defined(__FreeBSD__) &&  __FreeBSD_version < 1400037 && defined(HAVE_SYS_PROCCTL_H)
+# include <sys/procctl.h>
+# ifdef PROC_STACKGAP_DISABLE
+#  define DISABLE_FREEBSD_STACKGAP
+# endif
+#endif
+
 #ifdef HAVE_DNSREGISTRATION
 # include <dns_sd.h>
 DNSServiceRef mdns;
@@ -427,6 +424,24 @@ main(
 	char *argv[]
 	)
 {
+# ifdef DISABLE_FREEBSD_STACKGAP
+	/*
+	* We must disable ASLR stack gap on FreeBSD that has
+	* PROC_STACKGAP_DISABLE up through early FreeBSD 14
+	* versions to avoid a segfault. See:
+	* 
+	* https://bugs.ntp.org/3627
+	* https://cgit.freebsd.org/src/commit/?id=889b56c8cd84c9a9f2d9e3b019c154d6f14d9021
+	* https://cgit.freebsd.org/src/commit/?id=fc393054398ea50fb0cee52704e9385afe888b48
+	* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=253208
+	* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=241421
+	* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=241960
+	*/
+	int aslr_var = PROC_STACKGAP_DISABLE;
+
+	procctl(P_PID, getpid(), PROC_STACKGAP_CTL, &aslr_var);
+# endif	/* DISABLE_FREEBSD_STACKGAP */
+
 	return ntpdmain(argc, argv);
 }
 #endif /* !SYS_WINNT */
@@ -560,7 +575,7 @@ set_process_priority(void)
 # ifdef HAVE_WORKING_FORK
 static void
 detach_from_terminal(
-	int pipe[2],
+	int pipes[2],
 	long wait_sync,
 	const char *logfilename
 	)
@@ -581,11 +596,10 @@ detach_from_terminal(
 			msyslog(LOG_ERR, "fork: %m");
 			exit_code = EX_OSERR;
 		} else {
-			close(pipe[1]);
-			pipe[1] = -1;
+			close(pipes[1]);
+			pipes[1] = -1;
 			exit_code = wait_child_sync_if(
-					pipe[0], wait_sync);
-			DPRINTF(1, ("sync_if: rc=%d\n", exit_code));
+					pipes[0], wait_sync);
 			if (exit_code <= 0) {
 				/* probe daemon exit code -- wait for
 				 * child process if we have an unexpected
@@ -593,7 +607,6 @@ detach_from_terminal(
 				 */
 				exit_code = wait_child_exit_if(
 						cpid, (exit_code < 0));
-				DPRINTF(1, ("exit_if: rc=%d\n", exit_code));
 			}
 		}
 		exit(exit_code);
@@ -610,8 +623,8 @@ detach_from_terminal(
 		syslog_file = NULL;
 		syslogit = TRUE;
 	}
-	close_all_except(pipe[1]);
-	pipe[0] = -1;
+	close_all_except(pipes[1]);
+	pipes[0] = -1;
 	INSIST(0 == open("/dev/null", 0) && 1 == dup2(0, 1) \
 		&& 2 == dup2(0, 2));
 
@@ -655,6 +668,7 @@ detach_from_terminal(
 	return;
 }
 # endif /* HAVE_WORKING_FORK */
+#endif /* !SIM && !SYS_WINNT */
 
 #ifdef HAVE_DROPROOT
 /*
@@ -793,7 +807,6 @@ set_user_group_ids(void)
 	return 1;
 }
 #endif /* HAVE_DROPROOT */
-#endif /* !SIM */
 
 /*
  * Main program.  Initialize us, disconnect us from the tty if necessary,
@@ -892,10 +905,13 @@ ntpdmain(
 	msyslog(LOG_NOTICE, "available at https://www.nwtime.org/support");
 	msyslog(LOG_NOTICE, "----------------------------------------------------");
 #ifdef DEBUG
-	msyslog(LOG_NOTICE, "DEBUG behavior is enabled - a violation of any");
-	msyslog(LOG_NOTICE, "diagnostic assertion will cause %s to abort", progname);
+	msyslog(LOG_NOTICE, "DEBUG behavior is enabled - a violation of any"
+			    " diagnostic assertion will cause %s to abort", 
+			    progname);
 #endif
 
+	ssl_check_version();
+
 	/*
 	 * Install trap handlers to log errors and assertion failures.
 	 * Default handlers print to stderr which doesn't work if detached.
@@ -1267,11 +1283,10 @@ ntpdmain(
 		 * is associated with running with uid 0 - should be refined on
 		 * ports that allow binding to NTP_PORT with uid != 0
 		 */
-		disable_dynamic_updates |= (sw_uid != 0);  /* also notifies routing message listener */
+		scan_addrs_once |= (sw_uid != 0);  /* used by routing socket code */
 #  endif /* !HAVE_LINUX_CAPABILITIES && !HAVE_SOLARIS_PRIVS */
 
-		if (disable_dynamic_updates && interface_interval) {
-			interface_interval = 0;
+		if (scan_addrs_once) {
 			msyslog(LOG_INFO, "running as non-root disables dynamic interface tracking");
 		}
 
@@ -1285,9 +1300,9 @@ ntpdmain(
 			cap_t caps;
 			char *captext;
 			
-			captext = (0 != interface_interval)
-				      ? "cap_sys_time,cap_net_bind_service=pe"
-				      : "cap_sys_time=pe";
+			captext = (scan_addrs_once)
+				    ? "cap_sys_time=pe"
+				    : "cap_sys_time,cap_net_bind_service=pe";
 			caps = cap_from_text(captext);
 			if (!caps) {
 				msyslog(LOG_ERR,
@@ -1424,10 +1439,9 @@ int scmp_sc[] = {
 	}
 #endif /* LIBSECCOMP and KERN_SECCOMP */
 
-#if defined(SYS_WINNT)
 	ntservice_isup();
-#elif defined(HAVE_WORKING_FORK)
-	if (daemon_pipe[1] != -1) {
+#if defined(HAVE_WORKING_FORK)
+	if (daemon_pipe[1] != -1 && 0 == wait_sync) {
 		if (2 != write(daemon_pipe[1], "R\n", 2)) {
 			msyslog(LOG_ERR, "daemon failed to notify parent ntpd after init");
 		}
@@ -1436,6 +1450,10 @@ int scmp_sc[] = {
 	}
 #endif /* HAVE_WORKING_FORK */
 
+	if (scan_addrs_once || no_periodic_scan) {
+		endpt_scan_timer = 0;
+	}
+
 # ifndef HAVE_IO_COMPLETION_PORT
 	BLOCK_IO_AND_ALARM();
 	was_alarmed = FALSE;
@@ -1674,29 +1692,31 @@ wait_child_sync_if(
 		}
 		rc = read(pipe_read_fd, &ch, 1);
 		if (rc == 0) {
-			DPRINTF(2, ("daemon control: got EOF\n"));
+			/* DPRINTF is useless here as -d/-D disable forking */
+			fprintf(stderr, "daemon control: got EOF\n");
 			return -1;	/* unexpected EOF, check daemon */
 		} else if (rc == 1) {
-			DPRINTF(2, ("daemon control: got '%c'\n",
-				    (ch >= ' ' ? ch : '.')));
-			if (ch == 'R' && !wait_sync)
-				return 0;
-			if (ch == 'S' && wait_sync)
+			if (   ('S' == ch && wait_sync > 0)
+			    || ('R' == ch && 0 == wait_sync)) {
 				return 0;
+			}
 		} else {
-			DPRINTF(2, ("daemon control: read 1 char failed: %s\n",
-				    strerror(errno)));
+			mfprintf(stderr, "%s: daemon control: read 1 char failed: %m\n",
+				 progname);
+			msyslog(LOG_ERR, "daemon control: read 1 char failed: %m");
 			return EX_IOERR;
 		}
 	} while (wait_rem > 0);
 
-	if (wait_sync) {
+	if (wait_sync > 0) {
 		fprintf(stderr, "%s: -w/--wait-sync %ld timed out.\n",
 			progname, wait_sync);
+		msyslog(LOG_ERR, "-w/--wait-sync %ld timed out.", wait_sync);
 		return EX_PROTOCOL;
 	} else {
 		fprintf(stderr, "%s: daemon startup monitoring timed out.\n",
 			progname);
+		msyslog(LOG_ERR, "daemon startup monitoring timed out.");
 		return 0;
 	}
 }
@@ -1712,7 +1732,6 @@ wait_child_exit_if(
 	int	rc = 0;
 	int	wstatus;
 	if (cpid == waitpid(cpid, &wstatus, (blocking ? 0 : WNOHANG))) {
-		DPRINTF(1, ("child (pid=%d) dead now\n", cpid));
 		if (WIFEXITED(wstatus)) {
 			rc = WEXITSTATUS(wstatus);
 			msyslog(LOG_ERR, "daemon child exited with code %d",
@@ -1725,8 +1744,6 @@ wait_child_exit_if(
 			rc = EX_SOFTWARE;
 			msyslog(LOG_ERR, "daemon child died with unknown cause");
 		}
-	} else {
-		DPRINTF(1, ("child (pid=%d) still alive\n", cpid));
 	}
 	return rc;
 #    else
diff --git a/contrib/ntp/ntpd/ntpd.html b/contrib/ntp/ntpd/ntpd.html
index 3947f57f1a9b..a95695ef88b9 100644
--- a/contrib/ntp/ntpd/ntpd.html
+++ b/contrib/ntp/ntpd/ntpd.html
@@ -56,7 +56,7 @@ The program can operate in any of several modes, including client/server,
 symmetric and broadcast modes, and with both symmetric-key and public-key
 cryptography.
 </p>
-<p>This document applies to version 4.2.8p17 of <code>ntpd</code>.
+<p>This document applies to version 4.2.8p18 of <code>ntpd</code>.
 </p>
 <span id="SEC_Overview"></span>
 <h2 class="shortcontents-heading">Short Table of Contents</h2>
@@ -292,7 +292,7 @@ used to select the program, defaulting to <samp>more</samp>.  Both will exit
 with a status code of 0.
 </p>
 <div class="example">
-<pre class="example">ntpd - NTP daemon program - Ver. 4.2.8p17
+<pre class="example">ntpd - NTP daemon program - Ver. 4.2.8p18
 Usage:  ntpd [ -&lt;flag&gt; [&lt;val&gt;] | --&lt;name&gt;[{=| }&lt;val&gt;] ]... \
                 [ &lt;server1&gt; ... &lt;serverN&gt; ]
   Flg Arg Option-Name    Description
diff --git a/contrib/ntp/ntpd/ntpd.man.in b/contrib/ntp/ntpd/ntpd.man.in
index addee5d56e77..2474c8d18d9b 100644
--- a/contrib/ntp/ntpd/ntpd.man.in
+++ b/contrib/ntp/ntpd/ntpd.man.in
@@ -10,11 +10,11 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH ntpd @NTPD_MS@ "06 Jun 2023" "4.2.8p17" "User Commands"
+.TH ntpd @NTPD_MS@ "25 May 2024" "4.2.8p18" "User Commands"
 .\"
 .\" EDIT THIS FILE WITH CAUTION (in-mem file)
 .\"
-.\" It has been AutoGen-ed June 6, 2023 at 04:37:49 AM by AutoGen 5.18.16
+.\" It has been AutoGen-ed May 25, 2024 at 12:04:07 AM by AutoGen 5.18.16
 .\" From the definitions ntpd-opts.def
 .\" and the template file agman-cmd.tpl
 .SH NAME
@@ -979,7 +979,7 @@ RFC5908
 .SH "AUTHORS"
 The University of Delaware and Network Time Foundation
 .SH "COPYRIGHT"
-Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation all rights reserved.
 This program is released under the terms of the NTP license, <http://ntp.org/license>.
 .SH BUGS
 The
diff --git a/contrib/ntp/ntpd/ntpd.mdoc.in b/contrib/ntp/ntpd/ntpd.mdoc.in
index 6d99fbcf5e7a..874a6c778ed7 100644
--- a/contrib/ntp/ntpd/ntpd.mdoc.in
+++ b/contrib/ntp/ntpd/ntpd.mdoc.in
@@ -1,9 +1,9 @@
-.Dd June 6 2023
+.Dd May 25 2024
 .Dt NTPD @NTPD_MS@ User Commands
 .Os
 .\"  EDIT THIS FILE WITH CAUTION  (ntpd-opts.mdoc)
 .\"
-.\"  It has been AutoGen-ed  June  6, 2023 at 04:37:36 AM by AutoGen 5.18.16
+.\"  It has been AutoGen-ed  May 25, 2024 at 12:03:54 AM by AutoGen 5.18.16
 .\"  From the definitions    ntpd-opts.def
 .\"  and the template file   agmdoc-cmd.tpl
 .Sh NAME
@@ -886,7 +886,7 @@ A snapshot of this documentation is available in HTML format in
 .Sh "AUTHORS"
 The University of Delaware and Network Time Foundation
 .Sh "COPYRIGHT"
-Copyright (C) 1992\-2023 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992\-2024 The University of Delaware and Network Time Foundation all rights reserved.
 This program is released under the terms of the NTP license, <http://ntp.org/license>.
 .Sh BUGS
 The
diff --git a/contrib/ntp/ntpd/refclock_acts.c b/contrib/ntp/ntpd/refclock_acts.c
index 944ac764ccff..709427d34e9e 100644
--- a/contrib/ntp/ntpd/refclock_acts.c
+++ b/contrib/ntp/ntpd/refclock_acts.c
@@ -897,5 +897,5 @@ acts_timecode(
 	pp->lastref = pp->lastrec;
 }
 #else
-int refclock_acts_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* REFCLOCK */
diff --git a/contrib/ntp/ntpd/refclock_arbiter.c b/contrib/ntp/ntpd/refclock_arbiter.c
index 7de613fa751e..b92e72361bb1 100644
--- a/contrib/ntp/ntpd/refclock_arbiter.c
+++ b/contrib/ntp/ntpd/refclock_arbiter.c
@@ -473,5 +473,5 @@ arb_poll(
 }
 
 #else
-int refclock_arbiter_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* REFCLOCK */
diff --git a/contrib/ntp/ntpd/refclock_arc.c b/contrib/ntp/ntpd/refclock_arc.c
index d2dba54cb462..73bb63bc408a 100644
--- a/contrib/ntp/ntpd/refclock_arc.c
+++ b/contrib/ntp/ntpd/refclock_arc.c
@@ -870,15 +870,18 @@ arc_receive(
 	struct recvbuf *rbufp
 	)
 {
+	static int quality_average = 0;
+	static int quality_sum = 0;
+	static int quality_polls = 0;
 	register struct arcunit *up;
 	struct refclockproc *pp;
 	struct peer *peer;
 	char c;
-	int i, n, wday, month, flags, status;
+	int i, wday, month, flags, status;
 	int arc_last_offset;
-	static int quality_average = 0;
-	static int quality_sum = 0;
-	static int quality_polls = 0;
+    #ifdef DEBUG
+	int n;
+    #endif
 
 	/*
 	 * Initialize pointers and read the timecode and timestamp
@@ -1182,8 +1185,8 @@ arc_receive(
 	status = pp->a_lastcode[15];
 #ifdef DEBUG
 	if(debug) { printf("arc: status 0x%.2x flags 0x%.2x\n", flags, status); }
-#endif
 	n = 9;
+#endif
 
 	/*
 	  Validate received values at least enough to prevent internal
diff --git a/contrib/ntp/ntpd/refclock_as2201.c b/contrib/ntp/ntpd/refclock_as2201.c
index d71284173cbb..bb485551bb6c 100644
--- a/contrib/ntp/ntpd/refclock_as2201.c
+++ b/contrib/ntp/ntpd/refclock_as2201.c
@@ -385,5 +385,5 @@ as2201_poll(
 }
 
 #else
-int refclock_as2201_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* REFCLOCK */
diff --git a/contrib/ntp/ntpd/refclock_atom.c b/contrib/ntp/ntpd/refclock_atom.c
index b3c0d6b46ab0..6e01352db982 100644
--- a/contrib/ntp/ntpd/refclock_atom.c
+++ b/contrib/ntp/ntpd/refclock_atom.c
@@ -235,5 +235,5 @@ atom_poll(
 	refclock_receive(peer);
 }
 #else
-int refclock_atom_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* REFCLOCK */
diff --git a/contrib/ntp/ntpd/refclock_bancomm.c b/contrib/ntp/ntpd/refclock_bancomm.c
index 577ad277213c..d0d855d57b22 100644
--- a/contrib/ntp/ntpd/refclock_bancomm.c
+++ b/contrib/ntp/ntpd/refclock_bancomm.c
@@ -617,5 +617,5 @@ stfp_time2tvme(struct vmedate *time_vme, struct stfp_time *stfp)
 	return;
 }
 #else
-int refclock_bancomm_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* REFCLOCK */
diff --git a/contrib/ntp/ntpd/refclock_chronolog.c b/contrib/ntp/ntpd/refclock_chronolog.c
index 1499ee4c81ed..4a8a4aa86efb 100644
--- a/contrib/ntp/ntpd/refclock_chronolog.c
+++ b/contrib/ntp/ntpd/refclock_chronolog.c
@@ -339,5 +339,5 @@ chronolog_poll(
 }
 
 #else
-int refclock_chronolog_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* REFCLOCK */
diff --git a/contrib/ntp/ntpd/refclock_conf.c b/contrib/ntp/ntpd/refclock_conf.c
index 30cc632065c8..ddabf932ea98 100644
--- a/contrib/ntp/ntpd/refclock_conf.c
+++ b/contrib/ntp/ntpd/refclock_conf.c
@@ -322,5 +322,5 @@ struct refclock * const refclock_conf[] = {
 u_char num_refclock_conf = sizeof(refclock_conf)/sizeof(struct refclock *);
 
 #else
-int refclock_conf_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif
diff --git a/contrib/ntp/ntpd/refclock_dumbclock.c b/contrib/ntp/ntpd/refclock_dumbclock.c
index 3563847dac05..37aaf28fa02a 100644
--- a/contrib/ntp/ntpd/refclock_dumbclock.c
+++ b/contrib/ntp/ntpd/refclock_dumbclock.c
@@ -373,5 +373,5 @@ dumbclock_poll(
 #endif
 
 #else
-int refclock_dumbclock_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif	/* defined(REFCLOCK) && defined(CLOCK_DUMBCLOCK) */
diff --git a/contrib/ntp/ntpd/refclock_fg.c b/contrib/ntp/ntpd/refclock_fg.c
index abcf43f9cb9e..9ded8c7e79e0 100644
--- a/contrib/ntp/ntpd/refclock_fg.c
+++ b/contrib/ntp/ntpd/refclock_fg.c
@@ -331,5 +331,5 @@ fg_receive(
 
 
 #else
-int refclock_fg_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* REFCLOCK */
diff --git a/contrib/ntp/ntpd/refclock_gpsvme.c b/contrib/ntp/ntpd/refclock_gpsvme.c
index 66ccc9a3ec90..3920b7a3cccc 100644
--- a/contrib/ntp/ntpd/refclock_gpsvme.c
+++ b/contrib/ntp/ntpd/refclock_gpsvme.c
@@ -249,5 +249,5 @@ check_leap_sec(struct refclockproc *pp, int unit)
 }
 
 #else
-int	refclock_gpsvme_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif	/* REFCLOCK	*/
diff --git a/contrib/ntp/ntpd/refclock_heath.c b/contrib/ntp/ntpd/refclock_heath.c
index e34fa6b93628..2d9aa45a5b6d 100644
--- a/contrib/ntp/ntpd/refclock_heath.c
+++ b/contrib/ntp/ntpd/refclock_heath.c
@@ -446,5 +446,5 @@ heath_poll(
 }
 
 #else
-int refclock_heath_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* REFCLOCK */
diff --git a/contrib/ntp/ntpd/refclock_hopfpci.c b/contrib/ntp/ntpd/refclock_hopfpci.c
index 95bcab983c4d..5b63e593fa2b 100644
--- a/contrib/ntp/ntpd/refclock_hopfpci.c
+++ b/contrib/ntp/ntpd/refclock_hopfpci.c
@@ -254,5 +254,5 @@ hopfpci_poll(
 }
 
 #else
-int refclock_hopfpci_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* REFCLOCK */
diff --git a/contrib/ntp/ntpd/refclock_hopfser.c b/contrib/ntp/ntpd/refclock_hopfser.c
index e8e5ecefdc40..6cc39c90b774 100644
--- a/contrib/ntp/ntpd/refclock_hopfser.c
+++ b/contrib/ntp/ntpd/refclock_hopfser.c
@@ -362,5 +362,5 @@ hopfserial_poll (
 }
 
 #else
-int refclock_hopfser_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* REFCLOCK */
diff --git a/contrib/ntp/ntpd/refclock_hpgps.c b/contrib/ntp/ntpd/refclock_hpgps.c
index fb7085a799e5..e9a87172136d 100644
--- a/contrib/ntp/ntpd/refclock_hpgps.c
+++ b/contrib/ntp/ntpd/refclock_hpgps.c
@@ -622,5 +622,5 @@ hpgps_poll(
 }
 
 #else
-int refclock_hpgps_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* REFCLOCK */
diff --git a/contrib/ntp/ntpd/refclock_irig.c b/contrib/ntp/ntpd/refclock_irig.c
index abc94f62e8fb..29cf5d6a748e 100644
--- a/contrib/ntp/ntpd/refclock_irig.c
+++ b/contrib/ntp/ntpd/refclock_irig.c
@@ -1039,5 +1039,5 @@ irig_gain(
 
 
 #else
-int refclock_irig_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* REFCLOCK */
diff --git a/contrib/ntp/ntpd/refclock_jjy.c b/contrib/ntp/ntpd/refclock_jjy.c
index c4e1697bfdf7..84956eb1da2a 100644
--- a/contrib/ntp/ntpd/refclock_jjy.c
+++ b/contrib/ntp/ntpd/refclock_jjy.c
@@ -4525,5 +4525,5 @@ printableString ( char *sOutput, int iOutputLen, const char *sInput, int iInputL
 /**************************************************************************************************/
 
 #else
-int refclock_jjy_bs ;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* REFCLOCK */
diff --git a/contrib/ntp/ntpd/refclock_jupiter.c b/contrib/ntp/ntpd/refclock_jupiter.c
index 7db0198ec692..4deac7401dc4 100644
--- a/contrib/ntp/ntpd/refclock_jupiter.c
+++ b/contrib/ntp/ntpd/refclock_jupiter.c
@@ -1028,5 +1028,5 @@ jupiter_recv(
 }
 
 #else /* not (REFCLOCK && CLOCK_JUPITER && HAVE_PPSAPI) */
-int refclock_jupiter_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* not (REFCLOCK && CLOCK_JUPITER && HAVE_PPSAPI) */
diff --git a/contrib/ntp/ntpd/refclock_local.c b/contrib/ntp/ntpd/refclock_local.c
index 8c0f74f62c24..62de1a98e84e 100644
--- a/contrib/ntp/ntpd/refclock_local.c
+++ b/contrib/ntp/ntpd/refclock_local.c
@@ -213,5 +213,5 @@ local_poll(
 	refclock_receive(peer);
 }
 #else
-int refclock_local_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* REFCLOCK */
diff --git a/contrib/ntp/ntpd/refclock_mx4200.c b/contrib/ntp/ntpd/refclock_mx4200.c
index 11c17d069dd4..0de856ee1edb 100644
--- a/contrib/ntp/ntpd/refclock_mx4200.c
+++ b/contrib/ntp/ntpd/refclock_mx4200.c
@@ -1635,5 +1635,5 @@ mx4200_send(peer, fmt, va_alist)
 }
 
 #else
-int refclock_mx4200_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* REFCLOCK */
diff --git a/contrib/ntp/ntpd/refclock_neoclock4x.c b/contrib/ntp/ntpd/refclock_neoclock4x.c
index a54381678310..a8c0a336307f 100644
--- a/contrib/ntp/ntpd/refclock_neoclock4x.c
+++ b/contrib/ntp/ntpd/refclock_neoclock4x.c
@@ -1057,7 +1057,7 @@ neol_check_firmware(int unit,
 #endif
 
 #else
-int refclock_neoclock4x_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* REFCLOCK */
 
 /*
diff --git a/contrib/ntp/ntpd/refclock_nmea.c b/contrib/ntp/ntpd/refclock_nmea.c
index 131ccf641a56..a2d8d499156f 100644
--- a/contrib/ntp/ntpd/refclock_nmea.c
+++ b/contrib/ntp/ntpd/refclock_nmea.c
@@ -1408,6 +1408,7 @@ typedef unsigned char const UCC;
 
 static char const * const s_eof_chars = ",*\r\n";
 
+#ifdef DEBUG
 static int field_length(UCC *cp, unsigned int nfields)
 {
 	char const * ep = (char const*)cp;
@@ -1419,6 +1420,7 @@ static int field_length(UCC *cp, unsigned int nfields)
 	    ? (int)((UCC*)ep - cp)
 	    : (int)strlen((char const*)cp);
 }
+#endif	/* DEBUG */
 
 /* /[,*\r\n]/ --> skip */
 static int _parse_eof(UCC *cp, UCC ** ep)
diff --git a/contrib/ntp/ntpd/refclock_oncore.c b/contrib/ntp/ntpd/refclock_oncore.c
index d41d54023348..512e64b644da 100644
--- a/contrib/ntp/ntpd/refclock_oncore.c
+++ b/contrib/ntp/ntpd/refclock_oncore.c
@@ -4136,5 +4136,5 @@ oncore_log_f(
 }
 
 #else
-int refclock_oncore_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif	/* REFCLOCK && CLOCK_ONCORE */
diff --git a/contrib/ntp/ntpd/refclock_palisade.c b/contrib/ntp/ntpd/refclock_palisade.c
index a9fe2689575b..3a61d6012213 100644
--- a/contrib/ntp/ntpd/refclock_palisade.c
+++ b/contrib/ntp/ntpd/refclock_palisade.c
@@ -1567,5 +1567,5 @@ getsingle(
 }
 
 #else	/* REFCLOCK && CLOCK_PALISADE*/
-int refclock_palisade_c_notempty;
+NONEMPTY_TRANSLATION_UNIT
 #endif
diff --git a/contrib/ntp/ntpd/refclock_pcf.c b/contrib/ntp/ntpd/refclock_pcf.c
index 45b3475c0d68..4e92370ece10 100644
--- a/contrib/ntp/ntpd/refclock_pcf.c
+++ b/contrib/ntp/ntpd/refclock_pcf.c
@@ -223,5 +223,5 @@ pcf_poll(
 	refclock_receive(peer);
 }
 #else
-int refclock_pcf_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* REFCLOCK */
diff --git a/contrib/ntp/ntpd/refclock_pst.c b/contrib/ntp/ntpd/refclock_pst.c
index 1d3e1ffcfd6a..bd0f15938101 100644
--- a/contrib/ntp/ntpd/refclock_pst.c
+++ b/contrib/ntp/ntpd/refclock_pst.c
@@ -314,5 +314,5 @@ pst_poll(
 }
 
 #else
-int refclock_pst_int;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* REFCLOCK */
diff --git a/contrib/ntp/ntpd/refclock_ripencc.c b/contrib/ntp/ntpd/refclock_ripencc.c
index 789029f8aad5..a7339e3d4936 100644
--- a/contrib/ntp/ntpd/refclock_ripencc.c
+++ b/contrib/ntp/ntpd/refclock_ripencc.c
@@ -5250,6 +5250,6 @@ TranslateTSIPReportToText(
 #endif /* TRIMBLE_OUTPUT_FUNC */
 
 #else  /* defined(REFCLOCK) && defined(CLOCK_RIPENCC) */
-int refclock_ripencc_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* defined(REFCLOCK) && defined(CLOCK_RIPENCC) */
 
diff --git a/contrib/ntp/ntpd/refclock_tpro.c b/contrib/ntp/ntpd/refclock_tpro.c
index ac511bb4b392..9adcb5c6c7b3 100644
--- a/contrib/ntp/ntpd/refclock_tpro.c
+++ b/contrib/ntp/ntpd/refclock_tpro.c
@@ -204,5 +204,5 @@ tpro_poll(
 }
 
 #else
-int refclock_tpro_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* REFCLOCK */
diff --git a/contrib/ntp/ntpd/refclock_true.c b/contrib/ntp/ntpd/refclock_true.c
index 78e6adb9acaa..e41cd1351840 100644
--- a/contrib/ntp/ntpd/refclock_true.c
+++ b/contrib/ntp/ntpd/refclock_true.c
@@ -977,5 +977,5 @@ true_sample720(void)
 #endif
 
 #else
-int refclock_true_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* REFCLOCK */
diff --git a/contrib/ntp/ntpd/refclock_tsyncpci.c b/contrib/ntp/ntpd/refclock_tsyncpci.c
index e14a3fd122c5..49097ea72420 100644
--- a/contrib/ntp/ntpd/refclock_tsyncpci.c
+++ b/contrib/ntp/ntpd/refclock_tsyncpci.c
@@ -908,5 +908,5 @@ void DoyTimeFromSecTime(DoyTimeObj* pDt, SecTimeObj* pSt)
 } // End DoyTimeFromSecTime
 
 #else
-int refclock_tsyncpci_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* REFCLOCK */
diff --git a/contrib/ntp/ntpd/refclock_tt560.c b/contrib/ntp/ntpd/refclock_tt560.c
index 171ba5c8cc44..89bca13617f3 100644
--- a/contrib/ntp/ntpd/refclock_tt560.c
+++ b/contrib/ntp/ntpd/refclock_tt560.c
@@ -266,5 +266,5 @@ byte_swap(unsigned int input_num)
 }
 
 #else
-int refclock_tt560_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* REFCLOCK */
diff --git a/contrib/ntp/ntpd/refclock_ulink.c b/contrib/ntp/ntpd/refclock_ulink.c
index 60147adba219..c09638c21ca0 100644
--- a/contrib/ntp/ntpd/refclock_ulink.c
+++ b/contrib/ntp/ntpd/refclock_ulink.c
@@ -564,5 +564,5 @@ ulink_poll(
 }
 
 #else
-int refclock_ulink_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* REFCLOCK */
diff --git a/contrib/ntp/ntpd/refclock_wwv.c b/contrib/ntp/ntpd/refclock_wwv.c
index 2736cfa32fd7..f4098ae81cd7 100644
--- a/contrib/ntp/ntpd/refclock_wwv.c
+++ b/contrib/ntp/ntpd/refclock_wwv.c
@@ -2707,5 +2707,5 @@ wwv_gain(
 
 
 #else
-int refclock_wwv_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* REFCLOCK */
diff --git a/contrib/ntp/ntpd/refclock_wwvb.c b/contrib/ntp/ntpd/refclock_wwvb.c
index 6aafc26f1408..3720cdf80a1c 100644
--- a/contrib/ntp/ntpd/refclock_wwvb.c
+++ b/contrib/ntp/ntpd/refclock_wwvb.c
@@ -599,5 +599,5 @@ wwvb_control(
 #endif	/* HAVE_PPSAPI */
 
 #else
-int refclock_wwvb_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* REFCLOCK */
diff --git a/contrib/ntp/ntpd/refclock_zyfer.c b/contrib/ntp/ntpd/refclock_zyfer.c
index f77604868617..0ec566d5aec7 100644
--- a/contrib/ntp/ntpd/refclock_zyfer.c
+++ b/contrib/ntp/ntpd/refclock_zyfer.c
@@ -344,5 +344,5 @@ zyfer_poll(
 }
 
 #else
-int refclock_zyfer_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif /* REFCLOCK */
diff --git a/contrib/ntp/ntpdate/Makefile.in b/contrib/ntp/ntpdate/Makefile.in
index b46352555475..66d3c93ceb63 100644
--- a/contrib/ntp/ntpdate/Makefile.in
+++ b/contrib/ntp/ntpdate/Makefile.in
@@ -94,6 +94,7 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 EXTRA_PROGRAMS = ntpdate$(EXEEXT)
+@LIBNTP_SUBMAKES_TRUE@am__append_1 = check-libntp
 subdir = ntpdate
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
@@ -390,6 +391,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_NET_SNMP_CONFIG = @PATH_NET_SNMP_CONFIG@
+PATH_OPENSSL = @PATH_OPENSSL@
 PATH_PERL = @PATH_PERL@
 PATH_RUBY = @PATH_RUBY@
 PATH_SEPARATOR = @PATH_SEPARATOR@
@@ -489,7 +491,7 @@ top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 NULL = 
-BUILT_SOURCES = check-libntp .deps-ver
+BUILT_SOURCES = $(am__append_1) .deps-ver
 DISTCLEANFILES = $(DEPDIR)/deps-ver
 bin_PROGRAMS = $(NTPDATE_DB)
 libexec_PROGRAMS = $(NTPDATE_DL)
@@ -502,7 +504,7 @@ AM_LDFLAGS = $(LDFLAGS_NTP) $(NTP_HARD_LDFLAGS)
 LDADD = ../libntp/libntp.a
 ntpdate_LDADD = $(LDADD) $(LDADD_LIBNTP) $(PTHREAD_LIBS) \
 	$(LIBOPTS_LDADD) $(LIBM) $(LDADD_NTP)
-CLEANFILES = .version version.c check-libntp .deps-ver
+CLEANFILES = .version version.c .deps-ver
 noinst_HEADERS = ntpdate.h
 ntpdate_SOURCES = ntpdate.c
 nodist_ntpdate_SOURCES = version.c
@@ -985,18 +987,16 @@ install-exec-hook:
 
 #
 
-check-libntp: $(top_builddir)/libntp/libntp.a
-	@: avoid default SCCS get by some make implementations
+.PHONY: check-libntp
 
-$(top_builddir)/libntp/libntp.a:
-	cd $(top_builddir)/libntp && $(MAKE) $(AM_MAKEFLAGS) libntp.a
+@LIBNTP_SUBMAKES_TRUE@check-libntp:
+@LIBNTP_SUBMAKES_TRUE@	cd $(top_builddir)/libntp && $(MAKE) $(AM_MAKEFLAGS) libntp.a
 $(top_srcdir)/sntp/scm-rev: FRC.scm-rev
 	$(AM_V_GEN)cd $(top_builddir)/sntp && $(MAKE) $(AM_MAKEFLAGS) check-scm-rev
 
+.PHONY: FRC.scm-rev
 FRC.scm-rev:
-	@: FRC.scm-rev "force" depends on nothing and is not a file, so is	\
-	   always out-of-date causing targets which depend on it to also		\
-	   be outdated so their rules to fire each time they are built.
+	@: FRC.scm-rev is always out of date, triggering the check every make invocation.
 $(DEPDIR)/deps-ver: $(top_srcdir)/deps-ver
 	@[ -f $@ ] ||							\
 		cp $(top_srcdir)/deps-ver $@
diff --git a/contrib/ntp/ntpdc/Makefile.in b/contrib/ntp/ntpdc/Makefile.in
index 3864e523a4ea..bb9c0986065e 100644
--- a/contrib/ntp/ntpdc/Makefile.in
+++ b/contrib/ntp/ntpdc/Makefile.in
@@ -95,6 +95,7 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 EXTRA_PROGRAMS = ntpdc$(EXEEXT) ntpdc-layout$(EXEEXT)
+@LIBNTP_SUBMAKES_TRUE@am__append_1 = check-libntp
 subdir = ntpdc
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
@@ -432,6 +433,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_NET_SNMP_CONFIG = @PATH_NET_SNMP_CONFIG@
+PATH_OPENSSL = @PATH_OPENSSL@
 PATH_PERL = @PATH_PERL@
 PATH_RUBY = @PATH_RUBY@
 PATH_SEPARATOR = @PATH_SEPARATOR@
@@ -536,7 +538,7 @@ libexec_PROGRAMS = $(NTPDC_DL)
 sbin_PROGRAMS = $(NTPDC_DS)
 EXTRA_DATA = check-layout
 BUILT_SOURCES = @MAKE_CHECK_LAYOUT@ ntpdc-opts.c ntpdc-opts.h \
-	check-libopts check-libntp .deps-ver
+	check-libopts $(am__append_1) .deps-ver
 AM_CFLAGS = $(CFLAGS_NTP) $(NTP_HARD_CFLAGS)
 AM_CPPFLAGS = $(NTP_INCS) $(LIBOPTS_CFLAGS) $(CPPFLAGS_NTP) \
 	$(NTP_HARD_CPPFLAGS)
@@ -549,7 +551,7 @@ ntpdc_LDADD = $(LIBOPTS_LDADD) ../libntp/libntp.a $(LDADD_LIBNTP) \
 ntpdc_layout_LDADD = 
 DISTCLEANFILES = $(man_MANS) config.log $(NULL) $(DEPDIR)/deps-ver
 CLEANFILES = check-layout layout.here nl.c ntpdc-layout .version \
-	version.c $(NULL) check-libopts check-libntp .deps-ver
+	version.c $(NULL) check-libopts .deps-ver
 noinst_HEADERS = ntpdc.h
 ETAGS_ARGS = Makefile.am
 EXTRA_DIST = \
@@ -1264,18 +1266,16 @@ check-libopts: ../sntp/libopts/libopts.la
 ../sntp/libopts/libopts.la:
 	-cd ../sntp/libopts && $(MAKE) $(AM_MAKEFLAGS) libopts.la
 
-check-libntp: $(top_builddir)/libntp/libntp.a
-	@: avoid default SCCS get by some make implementations
+.PHONY: check-libntp
 
-$(top_builddir)/libntp/libntp.a:
-	cd $(top_builddir)/libntp && $(MAKE) $(AM_MAKEFLAGS) libntp.a
+@LIBNTP_SUBMAKES_TRUE@check-libntp:
+@LIBNTP_SUBMAKES_TRUE@	cd $(top_builddir)/libntp && $(MAKE) $(AM_MAKEFLAGS) libntp.a
 $(top_srcdir)/sntp/scm-rev: FRC.scm-rev
 	$(AM_V_GEN)cd $(top_builddir)/sntp && $(MAKE) $(AM_MAKEFLAGS) check-scm-rev
 
+.PHONY: FRC.scm-rev
 FRC.scm-rev:
-	@: FRC.scm-rev "force" depends on nothing and is not a file, so is	\
-	   always out-of-date causing targets which depend on it to also		\
-	   be outdated so their rules to fire each time they are built.
+	@: FRC.scm-rev is always out of date, triggering the check every make invocation.
 $(DEPDIR)/deps-ver: $(top_srcdir)/deps-ver
 	@[ -f $@ ] ||							\
 		cp $(top_srcdir)/deps-ver $@
diff --git a/contrib/ntp/ntpdc/invoke-ntpdc.texi b/contrib/ntp/ntpdc/invoke-ntpdc.texi
index 30b4a66d6a87..07bcce67051f 100644
--- a/contrib/ntp/ntpdc/invoke-ntpdc.texi
+++ b/contrib/ntp/ntpdc/invoke-ntpdc.texi
@@ -6,7 +6,7 @@
 #
 # EDIT THIS FILE WITH CAUTION  (invoke-ntpdc.texi)
 #
-# It has been AutoGen-ed  June  6, 2023 at 04:37:59 AM by AutoGen 5.18.16
+# It has been AutoGen-ed  May 25, 2024 at 12:04:17 AM by AutoGen 5.18.16
 # From the definitions    ntpdc-opts.def
 # and the template file   agtexi-cmd.tpl
 @end ignore
@@ -77,7 +77,7 @@ with a status code of 0.
 
 @exampleindent 0
 @example
-ntpdc - vendor-specific NTPD control program - Ver. 4.2.8p17
+ntpdc - vendor-specific NTPD control program - Ver. 4.2.8p18
 Usage:  ntpdc [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... [ host ...]
   Flg Arg Option-Name    Description
    -4 no  ipv4           Force IPv4 DNS name resolution
diff --git a/contrib/ntp/ntpdc/nl.pl b/contrib/ntp/ntpdc/nl.pl
index 9e79bf06a741..e65862f2f181 100755
--- a/contrib/ntp/ntpdc/nl.pl
+++ b/contrib/ntp/ntpdc/nl.pl
@@ -1,4 +1,5 @@
 #! /ntpbuild/bin/perl -w
+# ntpdc/nl.pl.  Generated from nl.pl.in by configure.
 
 $found = 0;
 $last = 0;
diff --git a/contrib/ntp/ntpdc/nl.pl.in b/contrib/ntp/ntpdc/nl.pl.in
index 8007538dc056..acf98d13a916 100644
--- a/contrib/ntp/ntpdc/nl.pl.in
+++ b/contrib/ntp/ntpdc/nl.pl.in
@@ -1,4 +1,5 @@
 #! @PATH_PERL@ -w
+# @configure_input@
 
 $found = 0;
 $last = 0;
diff --git a/contrib/ntp/ntpdc/ntpdc-opts.c b/contrib/ntp/ntpdc/ntpdc-opts.c
index 536d1b970f98..f1c637659bf6 100644
--- a/contrib/ntp/ntpdc/ntpdc-opts.c
+++ b/contrib/ntp/ntpdc/ntpdc-opts.c
@@ -1,7 +1,7 @@
 /*
  *  EDIT THIS FILE WITH CAUTION  (ntpdc-opts.c)
  *
- *  It has been AutoGen-ed  June  6, 2023 at 04:37:53 AM by AutoGen 5.18.16
+ *  It has been AutoGen-ed  May 25, 2024 at 12:04:11 AM by AutoGen 5.18.16
  *  From the definitions    ntpdc-opts.def
  *  and the template file   options
  *
@@ -18,7 +18,7 @@
  * The ntpdc program is copyrighted and licensed
  * under the following terms:
  *
- *  Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation, all rights reserved.
+ *  Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation, all rights reserved.
  *  This is free software. It is licensed for use, modification and
  *  redistribution under the terms of the NTP License, copies of which
  *  can be seen at:
@@ -74,8 +74,8 @@ extern FILE * option_usage_fp;
  *  static const strings for ntpdc options
  */
 static char const ntpdc_opt_strs[2005] =
-/*     0 */ "ntpdc 4.2.8p17\n"
-            "Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation, all rights reserved.\n"
+/*     0 */ "ntpdc 4.2.8p18\n"
+            "Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation, all rights reserved.\n"
             "This is free software. It is licensed for use, modification and\n"
             "redistribution under the terms of the NTP License, copies of which\n"
             "can be seen at:\n"
@@ -136,14 +136,14 @@ static char const ntpdc_opt_strs[2005] =
 /*  1785 */ "no-load-opts\0"
 /*  1798 */ "no\0"
 /*  1801 */ "NTPDC\0"
-/*  1807 */ "ntpdc - vendor-specific NTPD control program - Ver. 4.2.8p17\n"
+/*  1807 */ "ntpdc - vendor-specific NTPD control program - Ver. 4.2.8p18\n"
             "Usage:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [ host ...]\n\0"
 /*  1938 */ "$HOME\0"
 /*  1944 */ ".\0"
 /*  1946 */ ".ntprc\0"
 /*  1953 */ "https://bugs.ntp.org, bugs@ntp.org\0"
 /*  1988 */ "\n\0"
-/*  1990 */ "ntpdc 4.2.8p17";
+/*  1990 */ "ntpdc 4.2.8p18";
 
 /**
  *  ipv4 option description with
@@ -828,8 +828,8 @@ static void bogus_function(void) {
      translate option names.
    */
   /* referenced via ntpdcOptions.pzCopyright */
-  puts(_("ntpdc 4.2.8p17\n\
-Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation, all rights reserved.\n\
+  puts(_("ntpdc 4.2.8p18\n\
+Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation, all rights reserved.\n\
 This is free software. It is licensed for use, modification and\n\
 redistribution under the terms of the NTP License, copies of which\n\
 can be seen at:\n"));
@@ -897,14 +897,14 @@ implied warranty.\n"));
   puts(_("load options from a config file"));
 
   /* referenced via ntpdcOptions.pzUsageTitle */
-  puts(_("ntpdc - vendor-specific NTPD control program - Ver. 4.2.8p17\n\
+  puts(_("ntpdc - vendor-specific NTPD control program - Ver. 4.2.8p18\n\
 Usage:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [ host ...]\n"));
 
   /* referenced via ntpdcOptions.pzExplain */
   puts(_("\n"));
 
   /* referenced via ntpdcOptions.pzFullVersion */
-  puts(_("ntpdc 4.2.8p17"));
+  puts(_("ntpdc 4.2.8p18"));
 
   /* referenced via ntpdcOptions.pzFullUsage */
   puts(_("<<<NOT-FOUND>>>"));
diff --git a/contrib/ntp/ntpdc/ntpdc-opts.h b/contrib/ntp/ntpdc/ntpdc-opts.h
index 47d3f481a54e..8f2638e55556 100644
--- a/contrib/ntp/ntpdc/ntpdc-opts.h
+++ b/contrib/ntp/ntpdc/ntpdc-opts.h
@@ -1,7 +1,7 @@
 /*
  *  EDIT THIS FILE WITH CAUTION  (ntpdc-opts.h)
  *
- *  It has been AutoGen-ed  June  6, 2023 at 04:37:52 AM by AutoGen 5.18.16
+ *  It has been AutoGen-ed  May 25, 2024 at 12:04:11 AM by AutoGen 5.18.16
  *  From the definitions    ntpdc-opts.def
  *  and the template file   options
  *
@@ -18,7 +18,7 @@
  * The ntpdc program is copyrighted and licensed
  * under the following terms:
  *
- *  Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation, all rights reserved.
+ *  Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation, all rights reserved.
  *  This is free software. It is licensed for use, modification and
  *  redistribution under the terms of the NTP License, copies of which
  *  can be seen at:
@@ -92,9 +92,9 @@ typedef enum {
 /** count of all options for ntpdc */
 #define OPTION_CT    16
 /** ntpdc version */
-#define NTPDC_VERSION       "4.2.8p17"
+#define NTPDC_VERSION       "4.2.8p18"
 /** Full ntpdc version text */
-#define NTPDC_FULL_VERSION  "ntpdc 4.2.8p17"
+#define NTPDC_FULL_VERSION  "ntpdc 4.2.8p18"
 
 /**
  *  Interface defines for all options.  Replace "n" with the UPPER_CASED
diff --git a/contrib/ntp/ntpdc/ntpdc.1ntpdcman b/contrib/ntp/ntpdc/ntpdc.1ntpdcman
index f101aadac589..3f95f941a058 100644
--- a/contrib/ntp/ntpdc/ntpdc.1ntpdcman
+++ b/contrib/ntp/ntpdc/ntpdc.1ntpdcman
@@ -10,11 +10,11 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH ntpdc 1ntpdcman "06 Jun 2023" "4.2.8p17" "User Commands"
+.TH ntpdc 1ntpdcman "25 May 2024" "4.2.8p18" "User Commands"
 .\"
 .\" EDIT THIS FILE WITH CAUTION (in-mem file)
 .\"
-.\" It has been AutoGen-ed June 6, 2023 at 04:38:01 AM by AutoGen 5.18.16
+.\" It has been AutoGen-ed May 25, 2024 at 12:04:19 AM by AutoGen 5.18.16
 .\" From the definitions ntpdc-opts.def
 .\" and the template file agman-cmd.tpl
 .SH NAME
@@ -854,7 +854,7 @@ RFC1305
 .SH AUTHORS
 The formatting directives in this document came from FreeBSD.
 .SH "COPYRIGHT"
-Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation all rights reserved.
 This program is released under the terms of the NTP license, <http://ntp.org/license>.
 .SH BUGS
 The
diff --git a/contrib/ntp/ntpdc/ntpdc.1ntpdcmdoc b/contrib/ntp/ntpdc/ntpdc.1ntpdcmdoc
index 376443dae434..68d6f1c1c1c0 100644
--- a/contrib/ntp/ntpdc/ntpdc.1ntpdcmdoc
+++ b/contrib/ntp/ntpdc/ntpdc.1ntpdcmdoc
@@ -1,9 +1,9 @@
-.Dd June 6 2023
+.Dd May 25 2024
 .Dt NTPDC 1ntpdcmdoc User Commands
 .Os
 .\"  EDIT THIS FILE WITH CAUTION  (ntpdc-opts.mdoc)
 .\"
-.\"  It has been AutoGen-ed  June  6, 2023 at 04:37:57 AM by AutoGen 5.18.16
+.\"  It has been AutoGen-ed  May 25, 2024 at 12:04:15 AM by AutoGen 5.18.16
 .\"  From the definitions    ntpdc-opts.def
 .\"  and the template file   agmdoc-cmd.tpl
 .Sh NAME
@@ -792,7 +792,7 @@ it to autogen\-users@lists.sourceforge.net.  Thank you.
 .Sh AUTHORS
 The formatting directives in this document came from FreeBSD.
 .Sh "COPYRIGHT"
-Copyright (C) 1992\-2023 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992\-2024 The University of Delaware and Network Time Foundation all rights reserved.
 This program is released under the terms of the NTP license, <http://ntp.org/license>.
 .Sh BUGS
 The
diff --git a/contrib/ntp/ntpdc/ntpdc.html b/contrib/ntp/ntpdc/ntpdc.html
index 1a566baca91b..c9be00b30975 100644
--- a/contrib/ntp/ntpdc/ntpdc.html
+++ b/contrib/ntp/ntpdc/ntpdc.html
@@ -53,7 +53,7 @@ display the time offset of the system clock relative to the server
 clock.  Run as root, it can correct the system clock to this offset as
 well.  It can be run as an interactive command or from a cron job.
 </p>
-<p>This document applies to version 4.2.8p17 of <code>ntpdc</code>.
+<p>This document applies to version 4.2.8p18 of <code>ntpdc</code>.
 </p>
 <p>The program implements the SNTP protocol as defined by RFC 5905, the NTPv4
 IETF specification.
@@ -199,7 +199,7 @@ used to select the program, defaulting to <samp>more</samp>.  Both will exit
 with a status code of 0.
 </p>
 <div class="example">
-<pre class="example">ntpdc - vendor-specific NTPD control program - Ver. 4.2.8p17
+<pre class="example">ntpdc - vendor-specific NTPD control program - Ver. 4.2.8p18
 Usage:  ntpdc [ -&lt;flag&gt; [&lt;val&gt;] | --&lt;name&gt;[{=| }&lt;val&gt;] ]... [ host ...]
   Flg Arg Option-Name    Description
    -4 no  ipv4           Force IPv4 DNS name resolution
diff --git a/contrib/ntp/ntpdc/ntpdc.man.in b/contrib/ntp/ntpdc/ntpdc.man.in
index 151c23b0c5c1..4bf6a788dfdd 100644
--- a/contrib/ntp/ntpdc/ntpdc.man.in
+++ b/contrib/ntp/ntpdc/ntpdc.man.in
@@ -10,11 +10,11 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH ntpdc @NTPDC_MS@ "06 Jun 2023" "4.2.8p17" "User Commands"
+.TH ntpdc @NTPDC_MS@ "25 May 2024" "4.2.8p18" "User Commands"
 .\"
 .\" EDIT THIS FILE WITH CAUTION (in-mem file)
 .\"
-.\" It has been AutoGen-ed June 6, 2023 at 04:38:01 AM by AutoGen 5.18.16
+.\" It has been AutoGen-ed May 25, 2024 at 12:04:19 AM by AutoGen 5.18.16
 .\" From the definitions ntpdc-opts.def
 .\" and the template file agman-cmd.tpl
 .SH NAME
@@ -854,7 +854,7 @@ RFC1305
 .SH AUTHORS
 The formatting directives in this document came from FreeBSD.
 .SH "COPYRIGHT"
-Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation all rights reserved.
 This program is released under the terms of the NTP license, <http://ntp.org/license>.
 .SH BUGS
 The
diff --git a/contrib/ntp/ntpdc/ntpdc.mdoc.in b/contrib/ntp/ntpdc/ntpdc.mdoc.in
index 1a7859c448e6..b1c0cf42e917 100644
--- a/contrib/ntp/ntpdc/ntpdc.mdoc.in
+++ b/contrib/ntp/ntpdc/ntpdc.mdoc.in
@@ -1,9 +1,9 @@
-.Dd June 6 2023
+.Dd May 25 2024
 .Dt NTPDC @NTPDC_MS@ User Commands
 .Os
 .\"  EDIT THIS FILE WITH CAUTION  (ntpdc-opts.mdoc)
 .\"
-.\"  It has been AutoGen-ed  June  6, 2023 at 04:37:57 AM by AutoGen 5.18.16
+.\"  It has been AutoGen-ed  May 25, 2024 at 12:04:15 AM by AutoGen 5.18.16
 .\"  From the definitions    ntpdc-opts.def
 .\"  and the template file   agmdoc-cmd.tpl
 .Sh NAME
@@ -792,7 +792,7 @@ it to autogen\-users@lists.sourceforge.net.  Thank you.
 .Sh AUTHORS
 The formatting directives in this document came from FreeBSD.
 .Sh "COPYRIGHT"
-Copyright (C) 1992\-2023 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992\-2024 The University of Delaware and Network Time Foundation all rights reserved.
 This program is released under the terms of the NTP license, <http://ntp.org/license>.
 .Sh BUGS
 The
diff --git a/contrib/ntp/ntpq/Makefile.in b/contrib/ntp/ntpq/Makefile.in
index dd77e591e3d8..ecfefb4ef5f1 100644
--- a/contrib/ntp/ntpq/Makefile.in
+++ b/contrib/ntp/ntpq/Makefile.in
@@ -96,6 +96,7 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 EXTRA_PROGRAMS = ntpq$(EXEEXT)
+@LIBNTP_SUBMAKES_TRUE@am__append_1 = check-libntp
 subdir = ntpq
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
@@ -442,6 +443,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_NET_SNMP_CONFIG = @PATH_NET_SNMP_CONFIG@
+PATH_OPENSSL = @PATH_OPENSSL@
 PATH_PERL = @PATH_PERL@
 PATH_RUBY = @PATH_RUBY@
 PATH_SEPARATOR = @PATH_SEPARATOR@
@@ -557,7 +559,7 @@ noinst_HEADERS = ntpq.h
 noinst_LIBRARIES = libntpq.a
 libntpq_a_CFLAGS = $(AM_CFLAGS) -DNO_MAIN_ALLOWED -DBUILD_AS_LIB
 libntpq_a_CPPFLAGS = $(AM_CPPFLAGS)
-CLEANFILES = .version version.c check-libopts check-libntp .deps-ver
+CLEANFILES = .version version.c check-libopts .deps-ver
 DISTCLEANFILES = config.log $(man_MANS) $(DEPDIR)/deps-ver
 ETAGS_ARGS = Makefile.am
 EXTRA_DIST = \
@@ -572,7 +574,7 @@ EXTRA_DIST = \
 	ntpq.texi		\
 	$(NULL)
 
-BUILT_SOURCES = ntpq-opts.c ntpq-opts.h check-libopts check-libntp \
+BUILT_SOURCES = ntpq-opts.c ntpq-opts.h check-libopts $(am__append_1) \
 	.deps-ver
 html_DATA = \
 	$(srcdir)/ntpq.html		\
@@ -1295,18 +1297,16 @@ check-libopts: ../sntp/libopts/libopts.la
 ../sntp/libopts/libopts.la:
 	-cd ../sntp/libopts && $(MAKE) $(AM_MAKEFLAGS) libopts.la
 
-check-libntp: $(top_builddir)/libntp/libntp.a
-	@: avoid default SCCS get by some make implementations
+.PHONY: check-libntp
 
-$(top_builddir)/libntp/libntp.a:
-	cd $(top_builddir)/libntp && $(MAKE) $(AM_MAKEFLAGS) libntp.a
+@LIBNTP_SUBMAKES_TRUE@check-libntp:
+@LIBNTP_SUBMAKES_TRUE@	cd $(top_builddir)/libntp && $(MAKE) $(AM_MAKEFLAGS) libntp.a
 $(top_srcdir)/sntp/scm-rev: FRC.scm-rev
 	$(AM_V_GEN)cd $(top_builddir)/sntp && $(MAKE) $(AM_MAKEFLAGS) check-scm-rev
 
+.PHONY: FRC.scm-rev
 FRC.scm-rev:
-	@: FRC.scm-rev "force" depends on nothing and is not a file, so is	\
-	   always out-of-date causing targets which depend on it to also		\
-	   be outdated so their rules to fire each time they are built.
+	@: FRC.scm-rev is always out of date, triggering the check every make invocation.
 $(DEPDIR)/deps-ver: $(top_srcdir)/deps-ver
 	@[ -f $@ ] ||							\
 		cp $(top_srcdir)/deps-ver $@
diff --git a/contrib/ntp/ntpq/invoke-ntpq.texi b/contrib/ntp/ntpq/invoke-ntpq.texi
index 715dbcba764e..cdb1453d5a24 100644
--- a/contrib/ntp/ntpq/invoke-ntpq.texi
+++ b/contrib/ntp/ntpq/invoke-ntpq.texi
@@ -6,7 +6,7 @@
 #
 # EDIT THIS FILE WITH CAUTION  (invoke-ntpq.texi)
 #
-# It has been AutoGen-ed  June  6, 2023 at 04:38:12 AM by AutoGen 5.18.16
+# It has been AutoGen-ed  May 25, 2024 at 12:04:30 AM by AutoGen 5.18.16
 # From the definitions    ntpq-opts.def
 # and the template file   agtexi-cmd.tpl
 @end ignore
@@ -945,7 +945,7 @@ with a status code of 0.
 
 @exampleindent 0
 @example
-ntpq - standard NTP query program - Ver. 4.2.8p17
+ntpq - standard NTP query program - Ver. 4.2.8p18
 Usage:  ntpq [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... [ host ...]
   Flg Arg Option-Name    Description
    -4 no  ipv4           Force IPv4 name resolution
diff --git a/contrib/ntp/ntpq/ntpq-opts.c b/contrib/ntp/ntpq/ntpq-opts.c
index 3e176c057652..12042e4a1431 100644
--- a/contrib/ntp/ntpq/ntpq-opts.c
+++ b/contrib/ntp/ntpq/ntpq-opts.c
@@ -1,7 +1,7 @@
 /*
  *  EDIT THIS FILE WITH CAUTION  (ntpq-opts.c)
  *
- *  It has been AutoGen-ed  June  6, 2023 at 04:38:03 AM by AutoGen 5.18.16
+ *  It has been AutoGen-ed  May 25, 2024 at 12:04:21 AM by AutoGen 5.18.16
  *  From the definitions    ntpq-opts.def
  *  and the template file   options
  *
@@ -18,7 +18,7 @@
  * The ntpq program is copyrighted and licensed
  * under the following terms:
  *
- *  Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation, all rights reserved.
+ *  Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation, all rights reserved.
  *  This is free software. It is licensed for use, modification and
  *  redistribution under the terms of the NTP License, copies of which
  *  can be seen at:
@@ -74,8 +74,8 @@ extern FILE * option_usage_fp;
  *  static const strings for ntpq options
  */
 static char const ntpq_opt_strs[2068] =
-/*     0 */ "ntpq 4.2.8p17\n"
-            "Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation, all rights reserved.\n"
+/*     0 */ "ntpq 4.2.8p18\n"
+            "Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation, all rights reserved.\n"
             "This is free software. It is licensed for use, modification and\n"
             "redistribution under the terms of the NTP License, copies of which\n"
             "can be seen at:\n"
@@ -140,13 +140,13 @@ static char const ntpq_opt_strs[2068] =
 /*  1858 */ "no-load-opts\0"
 /*  1871 */ "no\0"
 /*  1874 */ "NTPQ\0"
-/*  1879 */ "ntpq - standard NTP query program - Ver. 4.2.8p17\n"
+/*  1879 */ "ntpq - standard NTP query program - Ver. 4.2.8p18\n"
             "Usage:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [ host ...]\n\0"
 /*  1999 */ "$HOME\0"
 /*  2005 */ ".\0"
 /*  2007 */ ".ntprc\0"
 /*  2014 */ "https://bugs.ntp.org, bugs@ntp.org\0"
-/*  2049 */ "ntpq 4.2.8p17\0"
+/*  2049 */ "ntpq 4.2.8p18\0"
 /*  2063 */ "hash";
 
 /**
@@ -873,8 +873,8 @@ static void bogus_function(void) {
      translate option names.
    */
   /* referenced via ntpqOptions.pzCopyright */
-  puts(_("ntpq 4.2.8p17\n\
-Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation, all rights reserved.\n\
+  puts(_("ntpq 4.2.8p18\n\
+Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation, all rights reserved.\n\
 This is free software. It is licensed for use, modification and\n\
 redistribution under the terms of the NTP License, copies of which\n\
 can be seen at:\n"));
@@ -945,11 +945,11 @@ implied warranty.\n"));
   puts(_("load options from a config file"));
 
   /* referenced via ntpqOptions.pzUsageTitle */
-  puts(_("ntpq - standard NTP query program - Ver. 4.2.8p17\n\
+  puts(_("ntpq - standard NTP query program - Ver. 4.2.8p18\n\
 Usage:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [ host ...]\n"));
 
   /* referenced via ntpqOptions.pzFullVersion */
-  puts(_("ntpq 4.2.8p17"));
+  puts(_("ntpq 4.2.8p18"));
 
   /* referenced via ntpqOptions.pzFullUsage */
   puts(_("<<<NOT-FOUND>>>"));
diff --git a/contrib/ntp/ntpq/ntpq-opts.h b/contrib/ntp/ntpq/ntpq-opts.h
index 60d2ba1278c6..f1413deefcd1 100644
--- a/contrib/ntp/ntpq/ntpq-opts.h
+++ b/contrib/ntp/ntpq/ntpq-opts.h
@@ -1,7 +1,7 @@
 /*
  *  EDIT THIS FILE WITH CAUTION  (ntpq-opts.h)
  *
- *  It has been AutoGen-ed  June  6, 2023 at 04:38:02 AM by AutoGen 5.18.16
+ *  It has been AutoGen-ed  May 25, 2024 at 12:04:21 AM by AutoGen 5.18.16
  *  From the definitions    ntpq-opts.def
  *  and the template file   options
  *
@@ -18,7 +18,7 @@
  * The ntpq program is copyrighted and licensed
  * under the following terms:
  *
- *  Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation, all rights reserved.
+ *  Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation, all rights reserved.
  *  This is free software. It is licensed for use, modification and
  *  redistribution under the terms of the NTP License, copies of which
  *  can be seen at:
@@ -93,9 +93,9 @@ typedef enum {
 /** count of all options for ntpq */
 #define OPTION_CT    17
 /** ntpq version */
-#define NTPQ_VERSION       "4.2.8p17"
+#define NTPQ_VERSION       "4.2.8p18"
 /** Full ntpq version text */
-#define NTPQ_FULL_VERSION  "ntpq 4.2.8p17"
+#define NTPQ_FULL_VERSION  "ntpq 4.2.8p18"
 
 /**
  *  Interface defines for all options.  Replace "n" with the UPPER_CASED
diff --git a/contrib/ntp/ntpq/ntpq-subs.c b/contrib/ntp/ntpq/ntpq-subs.c
index 527be098b561..6aded4050c15 100644
--- a/contrib/ntp/ntpq/ntpq-subs.c
+++ b/contrib/ntp/ntpq/ntpq-subs.c
@@ -1495,7 +1495,7 @@ radiostatus(
 #endif	/* UNUSED */
 
 /*
- * when - print how long its been since his last packet arrived
+ * when - return how long its been since his last packet arrived
  */
 static long
 when(
@@ -1691,6 +1691,7 @@ doprintpeers(
 	u_int32 u32;
 	const char *dstadr_refid = "0.0.0.0";
 	const char *serverlocal;
+	char *drbuf = NULL;
 	size_t drlen;
 	u_long stratum = 0;
 	long ppoll = 0;
@@ -1772,12 +1773,13 @@ doprintpeers(
 				} else if (decodenetnum(value, &refidadr)) {
 					if (SOCK_UNSPEC(&refidadr))
 						dstadr_refid = "0.0.0.0";
-					else if (ISREFCLOCKADR(&refidadr))
+					else if (ISREFCLOCKADR(&refidadr)) {
 						dstadr_refid =
 						    refnumtoa(&refidadr);
-					else
+					} else {
 						dstadr_refid =
 						    stoa(&refidadr);
+					}
 				} else {
 					have_da_rid = FALSE;
 				}
@@ -1796,19 +1798,25 @@ doprintpeers(
 				} else if (decodenetnum(value, &refidadr)) {
 					if (SOCK_UNSPEC(&refidadr))
 						dstadr_refid = "0.0.0.0";
-					else if (ISREFCLOCKADR(&refidadr))
+					else if (ISREFCLOCKADR(&refidadr)) {
 						dstadr_refid =
-						    refnumtoa(&refidadr);
-					else {
-						char *buf = emalloc(10);
-						int i = ntohl(refidadr.sa4.sin_addr.s_addr);
-
-						snprintf(buf, 10,
-							"%0x", i);
-						dstadr_refid = buf;
-					//xprintf(stderr, "apeervarlist refid: value=<%x>\n", i);
+							refnumtoa(&refidadr);
+						if (pvl == apeervarlist) {
+							/*
+							 * restrict refid to
+							 * 8 chars [Bug 3850]
+							 */
+							dstadr_refid =
+								trunc_right(
+									dstadr_refid,
+									8);
+						}
+					} else {
+						drbuf = emalloc(10);
+						snprintf(drbuf, 10, "%0x",
+							 SRCADR(&refidadr));
+						dstadr_refid = drbuf;
 					}
-					//xprintf(stderr, "apeervarlist refid: value=<%s>\n", value);
 				} else {
 					have_da_rid = FALSE;
 				}
@@ -1843,7 +1851,7 @@ doprintpeers(
 			if (!decodets(value, &reftime))
 				L_CLR(&reftime);
 		} else if (!strcmp("flash", name)) {
-		    decodeuint(value, &flash);
+			decodeuint(value, &flash);
 		} else {
 			// xprintf(stderr, "UNRECOGNIZED name=%s ", name);
 		}
@@ -1931,6 +1939,7 @@ doprintpeers(
 			drlen = strlen(dstadr_refid);
 			makeascii(drlen, dstadr_refid, fp);
 		}
+		free(drbuf);
 		if (pvl == apeervarlist) {
 			while (drlen++ < 9)
 				xputc(' ', fp);
@@ -2452,7 +2461,7 @@ fetch_nonce(
 		return FALSE;
 	}
 
-	if ((size_t)rsize <= sizeof(nonce_eq) - 1 ||
+	if (rsize <= sizeof(nonce_eq) - 1 ||
 	    strncmp(rdata, nonce_eq, sizeof(nonce_eq) - 1)) {
 		xprintf(stderr, "unexpected nonce response format: %.*s\n",
 			(int)rsize, rdata); /* cast is wobbly */
diff --git a/contrib/ntp/ntpq/ntpq.1ntpqman b/contrib/ntp/ntpq/ntpq.1ntpqman
index e4f93b336110..5578f8ef3acb 100644
--- a/contrib/ntp/ntpq/ntpq.1ntpqman
+++ b/contrib/ntp/ntpq/ntpq.1ntpqman
@@ -10,11 +10,11 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH ntpq 1ntpqman "06 Jun 2023" "4.2.8p17" "User Commands"
+.TH ntpq 1ntpqman "25 May 2024" "4.2.8p18" "User Commands"
 .\"
 .\" EDIT THIS FILE WITH CAUTION (in-mem file)
 .\"
-.\" It has been AutoGen-ed June 6, 2023 at 04:38:15 AM by AutoGen 5.18.16
+.\" It has been AutoGen-ed May 25, 2024 at 12:04:33 AM by AutoGen 5.18.16
 .\" From the definitions ntpq-opts.def
 .\" and the template file agman-cmd.tpl
 .SH NAME
@@ -1585,7 +1585,7 @@ it to autogen-users@lists.sourceforge.net.  Thank you.
 .SH "AUTHORS"
 The University of Delaware and Network Time Foundation
 .SH "COPYRIGHT"
-Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation all rights reserved.
 This program is released under the terms of the NTP license, <http://ntp.org/license>.
 .SH "BUGS"
 Please send bug reports to: https://bugs.ntp.org, bugs@ntp.org
diff --git a/contrib/ntp/ntpq/ntpq.1ntpqmdoc b/contrib/ntp/ntpq/ntpq.1ntpqmdoc
index 9ce7db9484d3..bbb061bebf98 100644
--- a/contrib/ntp/ntpq/ntpq.1ntpqmdoc
+++ b/contrib/ntp/ntpq/ntpq.1ntpqmdoc
@@ -1,9 +1,9 @@
-.Dd June 6 2023
+.Dd May 25 2024
 .Dt NTPQ 1ntpqmdoc User Commands
 .Os
 .\"  EDIT THIS FILE WITH CAUTION  (ntpq-opts.mdoc)
 .\"
-.\"  It has been AutoGen-ed  June  6, 2023 at 04:38:10 AM by AutoGen 5.18.16
+.\"  It has been AutoGen-ed  May 25, 2024 at 12:04:29 AM by AutoGen 5.18.16
 .\"  From the definitions    ntpq-opts.def
 .\"  and the template file   agmdoc-cmd.tpl
 .Sh NAME
@@ -1051,7 +1051,7 @@ it to autogen\-users@lists.sourceforge.net.  Thank you.
 .Sh "AUTHORS"
 The University of Delaware and Network Time Foundation
 .Sh "COPYRIGHT"
-Copyright (C) 1992\-2023 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992\-2024 The University of Delaware and Network Time Foundation all rights reserved.
 This program is released under the terms of the NTP license, <http://ntp.org/license>.
 .Sh "BUGS"
 Please send bug reports to: https://bugs.ntp.org, bugs@ntp.org
diff --git a/contrib/ntp/ntpq/ntpq.c b/contrib/ntp/ntpq/ntpq.c
index 1a0e9b1a6867..56ff4e50e9eb 100644
--- a/contrib/ntp/ntpq/ntpq.c
+++ b/contrib/ntp/ntpq/ntpq.c
@@ -25,13 +25,9 @@
 #include <isc/result.h>
 
 #include "ntpq.h"
-#include "ntp_assert.h"
-#include "ntp_stdlib.h"
 #include "ntp_unixtime.h"
 #include "ntp_calendar.h"
 #include "ntp_select.h"
-#include "ntp_assert.h"
-#include "lib_strbuf.h"
 #include "ntp_lineedit.h"
 #include "ntp_debug.h"
 #ifdef OPENSSL
@@ -3941,31 +3937,25 @@ list_md_fn(const EVP_MD *m, const char *from, const char *to, void *arg)
 	size_t 	       len, n;
 	const char    *name, **seen;
 	struct hstate *hstate = arg;
-	const char    *cp;
 
 	/* m is MD obj, from is name or alias, to is base name for alias */
-	if (!m || !from || to)
+	if (!m || !from || to) {
 		return; /* Ignore aliases */
+	}
 
 	/* Discard MACs that NTP won't accept. */
 	/* Keep this consistent with keytype_from_text() in ssl_init.c. */
-	if (EVP_MD_size(m) > (MAX_MAC_LEN - sizeof(keyid_t)))
+	if (EVP_MD_size(m) > MAX_MDG_LEN) {
 		return;
+	}
 
 	name = EVP_MD_name(m);
-
-	/* Lowercase names aren't accepted by keytype_from_text in ssl_init.c */
-
-	for (cp = name; *cp; cp++)
-		if (islower((unsigned char)*cp))
-			return;
-
-	len = (cp - name) + 1;
+	len = strlen(name) + 1;
 
 	/* There are duplicates.  Discard if name has been seen. */
 
 	for (seen = hstate->seen; *seen; seen++)
-		if (!strcmp(*seen, name))
+		if (!strcasecmp(*seen, name))
 			return;
 
 	n = (seen - hstate->seen) + 2;
@@ -4057,11 +4047,12 @@ insert_cmac(char *list)
 					/* No - end of list */
 					if (!delim && !last_nl) {
 						delim = list + len;
-					} else
+					} else {
 						/* New line and no delim or before delim? */
 						if (last_nl && (!delim || last_nl < delim)) {
 							delim = last_nl;
 						}
+					}
 
 					/* Found insertion point where CMAC before entry? */
 					if (strncmp(CMAC, point, delim - point) < 0) {
diff --git a/contrib/ntp/ntpq/ntpq.h b/contrib/ntp/ntpq/ntpq.h
index 53f76387ace0..ed200951d303 100644
--- a/contrib/ntp/ntpq/ntpq.h
+++ b/contrib/ntp/ntpq/ntpq.h
@@ -11,7 +11,6 @@
 #include "ntp_malloc.h"
 #include "ntp_assert.h"
 #include "ntp_control.h"
-#include "lib_strbuf.h"
 
 #include "ntpq-opts.h"
 
diff --git a/contrib/ntp/ntpq/ntpq.html b/contrib/ntp/ntpq/ntpq.html
index 1ca91e4f3cd4..03b654a33486 100644
--- a/contrib/ntp/ntpq/ntpq.html
+++ b/contrib/ntp/ntpq/ntpq.html
@@ -62,7 +62,7 @@ monitor the operational status
 and determine the performance of
 <code>ntpd</code>, the NTP daemon.
 </p>
-<p>This document applies to version 4.2.8p17 of <code>ntpq</code>.
+<p>This document applies to version 4.2.8p18 of <code>ntpq</code>.
 </p>
 <table class="menu" border="0" cellspacing="0">
 <tr><td align="left" valign="top">&bull; <a href="#ntpq-Description" accesskey="1">ntpq Description</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
@@ -1274,7 +1274,7 @@ used to select the program, defaulting to <samp>more</samp>.  Both will exit
 with a status code of 0.
 </p>
 <div class="example">
-<pre class="example">ntpq - standard NTP query program - Ver. 4.2.8p17
+<pre class="example">ntpq - standard NTP query program - Ver. 4.2.8p18
 Usage:  ntpq [ -&lt;flag&gt; [&lt;val&gt;] | --&lt;name&gt;[{=| }&lt;val&gt;] ]... [ host ...]
   Flg Arg Option-Name    Description
    -4 no  ipv4           Force IPv4 name resolution
diff --git a/contrib/ntp/ntpq/ntpq.man.in b/contrib/ntp/ntpq/ntpq.man.in
index 12c085baf761..66ef65cad235 100644
--- a/contrib/ntp/ntpq/ntpq.man.in
+++ b/contrib/ntp/ntpq/ntpq.man.in
@@ -10,11 +10,11 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH ntpq @NTPQ_MS@ "06 Jun 2023" "4.2.8p17" "User Commands"
+.TH ntpq @NTPQ_MS@ "25 May 2024" "4.2.8p18" "User Commands"
 .\"
 .\" EDIT THIS FILE WITH CAUTION (in-mem file)
 .\"
-.\" It has been AutoGen-ed June 6, 2023 at 04:38:15 AM by AutoGen 5.18.16
+.\" It has been AutoGen-ed May 25, 2024 at 12:04:33 AM by AutoGen 5.18.16
 .\" From the definitions ntpq-opts.def
 .\" and the template file agman-cmd.tpl
 .SH NAME
@@ -1585,7 +1585,7 @@ it to autogen-users@lists.sourceforge.net.  Thank you.
 .SH "AUTHORS"
 The University of Delaware and Network Time Foundation
 .SH "COPYRIGHT"
-Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation all rights reserved.
 This program is released under the terms of the NTP license, <http://ntp.org/license>.
 .SH "BUGS"
 Please send bug reports to: https://bugs.ntp.org, bugs@ntp.org
diff --git a/contrib/ntp/ntpq/ntpq.mdoc.in b/contrib/ntp/ntpq/ntpq.mdoc.in
index d5ace4c4fd43..3bb46622c6d0 100644
--- a/contrib/ntp/ntpq/ntpq.mdoc.in
+++ b/contrib/ntp/ntpq/ntpq.mdoc.in
@@ -1,9 +1,9 @@
-.Dd June 6 2023
+.Dd May 25 2024
 .Dt NTPQ @NTPQ_MS@ User Commands
 .Os
 .\"  EDIT THIS FILE WITH CAUTION  (ntpq-opts.mdoc)
 .\"
-.\"  It has been AutoGen-ed  June  6, 2023 at 04:38:10 AM by AutoGen 5.18.16
+.\"  It has been AutoGen-ed  May 25, 2024 at 12:04:29 AM by AutoGen 5.18.16
 .\"  From the definitions    ntpq-opts.def
 .\"  and the template file   agmdoc-cmd.tpl
 .Sh NAME
@@ -1051,7 +1051,7 @@ it to autogen\-users@lists.sourceforge.net.  Thank you.
 .Sh "AUTHORS"
 The University of Delaware and Network Time Foundation
 .Sh "COPYRIGHT"
-Copyright (C) 1992\-2023 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992\-2024 The University of Delaware and Network Time Foundation all rights reserved.
 This program is released under the terms of the NTP license, <http://ntp.org/license>.
 .Sh "BUGS"
 Please send bug reports to: https://bugs.ntp.org, bugs@ntp.org
diff --git a/contrib/ntp/ntpsnmpd/Makefile.am b/contrib/ntp/ntpsnmpd/Makefile.am
index 5729bb85cd46..d3cd0be85607 100644
--- a/contrib/ntp/ntpsnmpd/Makefile.am
+++ b/contrib/ntp/ntpsnmpd/Makefile.am
@@ -9,9 +9,9 @@ ntpsnmpd_SOURCES= netsnmp_daemonize.c ntpsnmpd.c ntpSnmpSubagentObject.c \
 		ntpsnmpd-opts.c ntpsnmpd-opts.h ntpSnmpSubagentObject.h \
 		ntp_snmp.h
 # HMS: we probably want a version.o file here, too.
-LDADD  = ../ntpq/libntpq.a ../libntp/libntp.a
-LDADD += $(SNMP_LIBS) $(LDADD_LIBNTP) $(LIBM)
-LDADD += $(PTHREAD_LIBS) $(LDADD_NTP) $(LIBOPTS_LDADD)
+ntpsnmpd_LDADD  = ../ntpq/libntpq.a ../libntp/libntp.a
+ntpsnmpd_LDADD += $(LDADD_LIBNTP) $(LIBM) $(PTHREAD_LIBS)
+ntpsnmpd_LDADD += $(LDADD_NTP) $(LIBOPTS_LDADD) $(SNMP_LIBS)
 
 AM_CFLAGS  = $(SNMP_CFLAGS) $(CFLAGS_NTP)
 AM_CFLAGS += $(NTP_HARD_CFLAGS)
@@ -19,8 +19,8 @@ AM_CFLAGS += $(NTP_HARD_CFLAGS)
 AM_CPPFLAGS  = -I$(top_srcdir)/ntpq
 AM_CPPFLAGS += $(NTP_INCS)
 AM_CPPFLAGS += $(LIBOPTS_CFLAGS)
-AM_CPPFLAGS += $(SNMP_CPPFLAGS)
 AM_CPPFLAGS += $(CPPFLAGS_NTP)
+AM_CPPFLAGS += $(SNMP_CPPFLAGS)
 AM_CPPFLAGS += $(NTP_HARD_CPPFLAGS)
 
 AM_LDFLAGS  = $(LDFLAGS_NTP)
diff --git a/contrib/ntp/ntpsnmpd/Makefile.in b/contrib/ntp/ntpsnmpd/Makefile.in
index 329d255cd277..77df2343799d 100644
--- a/contrib/ntp/ntpsnmpd/Makefile.in
+++ b/contrib/ntp/ntpsnmpd/Makefile.in
@@ -94,6 +94,7 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 EXTRA_PROGRAMS = ntpsnmpd$(EXEEXT)
+@LIBNTP_SUBMAKES_TRUE@am__append_1 = check-libntp
 subdir = ntpsnmpd
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
@@ -150,7 +151,6 @@ PROGRAMS = $(bin_PROGRAMS) $(libexec_PROGRAMS) $(sbin_PROGRAMS)
 am_ntpsnmpd_OBJECTS = netsnmp_daemonize.$(OBJEXT) ntpsnmpd.$(OBJEXT) \
 	ntpSnmpSubagentObject.$(OBJEXT) ntpsnmpd-opts.$(OBJEXT)
 ntpsnmpd_OBJECTS = $(am_ntpsnmpd_OBJECTS)
-ntpsnmpd_LDADD = $(LDADD)
 am__DEPENDENCIES_1 =
 ntpsnmpd_DEPENDENCIES = ../ntpq/libntpq.a ../libntp/libntp.a \
 	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
@@ -425,6 +425,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_NET_SNMP_CONFIG = @PATH_NET_SNMP_CONFIG@
+PATH_OPENSSL = @PATH_OPENSSL@
 PATH_PERL = @PATH_PERL@
 PATH_RUBY = @PATH_RUBY@
 PATH_SEPARATOR = @PATH_SEPARATOR@
@@ -532,12 +533,12 @@ ntpsnmpd_SOURCES = netsnmp_daemonize.c ntpsnmpd.c ntpSnmpSubagentObject.c \
 		ntp_snmp.h
 
 # HMS: we probably want a version.o file here, too.
-LDADD = ../ntpq/libntpq.a ../libntp/libntp.a $(SNMP_LIBS) \
-	$(LDADD_LIBNTP) $(LIBM) $(PTHREAD_LIBS) $(LDADD_NTP) \
-	$(LIBOPTS_LDADD)
+ntpsnmpd_LDADD = ../ntpq/libntpq.a ../libntp/libntp.a $(LDADD_LIBNTP) \
+	$(LIBM) $(PTHREAD_LIBS) $(LDADD_NTP) $(LIBOPTS_LDADD) \
+	$(SNMP_LIBS)
 AM_CFLAGS = $(SNMP_CFLAGS) $(CFLAGS_NTP) $(NTP_HARD_CFLAGS)
 AM_CPPFLAGS = -I$(top_srcdir)/ntpq $(NTP_INCS) $(LIBOPTS_CFLAGS) \
-	$(SNMP_CPPFLAGS) $(CPPFLAGS_NTP) $(NTP_HARD_CPPFLAGS)
+	$(CPPFLAGS_NTP) $(SNMP_CPPFLAGS) $(NTP_HARD_CPPFLAGS)
 AM_LDFLAGS = $(LDFLAGS_NTP) $(NTP_HARD_LDFLAGS)
 EXTRA_DIST = \
 	invoke-ntpsnmpd.menu	\
@@ -552,9 +553,9 @@ EXTRA_DIST = \
 	ntpv4-mib.mib		\
 	$(NULL)
 
-BUILT_SOURCES = ntpsnmpd-opts.c ntpsnmpd-opts.h check-libntp \
+BUILT_SOURCES = ntpsnmpd-opts.c ntpsnmpd-opts.h $(am__append_1) \
 	check-libopts .deps-ver
-CLEANFILES = check-libntp check-libopts .deps-ver
+CLEANFILES = check-libopts .deps-ver
 DISTCLEANFILES = config.log $(man_MANS) $(DEPDIR)/deps-ver
 html_DATA = \
 	$(srcdir)/ntpsnmpd.html		\
@@ -1219,11 +1220,10 @@ install-exec-hook:
 
 #
 
-check-libntp: $(top_builddir)/libntp/libntp.a
-	@: avoid default SCCS get by some make implementations
+.PHONY: check-libntp
 
-$(top_builddir)/libntp/libntp.a:
-	cd $(top_builddir)/libntp && $(MAKE) $(AM_MAKEFLAGS) libntp.a
+@LIBNTP_SUBMAKES_TRUE@check-libntp:
+@LIBNTP_SUBMAKES_TRUE@	cd $(top_builddir)/libntp && $(MAKE) $(AM_MAKEFLAGS) libntp.a
 
 check-libopts: ../sntp/libopts/libopts.la
 	@echo stamp > $@
diff --git a/contrib/ntp/ntpsnmpd/invoke-ntpsnmpd.texi b/contrib/ntp/ntpsnmpd/invoke-ntpsnmpd.texi
index 3f99a3f35f6f..326dace34e63 100644
--- a/contrib/ntp/ntpsnmpd/invoke-ntpsnmpd.texi
+++ b/contrib/ntp/ntpsnmpd/invoke-ntpsnmpd.texi
@@ -6,7 +6,7 @@
 #
 # EDIT THIS FILE WITH CAUTION  (invoke-ntpsnmpd.texi)
 #
-# It has been AutoGen-ed  June  6, 2023 at 04:38:20 AM by AutoGen 5.18.16
+# It has been AutoGen-ed  May 25, 2024 at 12:04:39 AM by AutoGen 5.18.16
 # From the definitions    ntpsnmpd-opts.def
 # and the template file   agtexi-cmd.tpl
 @end ignore
@@ -47,7 +47,7 @@ with a status code of 0.
 
 @exampleindent 0
 @example
-ntpsnmpd - NTP SNMP MIB agent - Ver. 4.2.8p16
+ntpsnmpd - NTP SNMP MIB agent - Ver. 4.2.8p18
 Usage:  ntpsnmpd [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]...
   Flg Arg Option-Name    Description
    -n no  nofork         Do not fork
diff --git a/contrib/ntp/ntpsnmpd/netsnmp_daemonize.c b/contrib/ntp/ntpsnmpd/netsnmp_daemonize.c
index 44fad1ad3965..55f8c3596492 100644
--- a/contrib/ntp/ntpsnmpd/netsnmp_daemonize.c
+++ b/contrib/ntp/ntpsnmpd/netsnmp_daemonize.c
@@ -57,20 +57,12 @@ SOFTWARE.
 #include <stdlib.h>
 #endif
 
-#if TIME_WITH_SYS_TIME
-# ifdef WIN32
-#  include <sys/timeb.h>
-# else
-#  include <sys/time.h>
-# endif
-# include <time.h>
+#ifdef WIN32
+# include <sys/timeb.h>
 #else
-# if HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
+# include <sys/time.h>
 #endif
+#include <time.h>
 
 #include <sys/types.h>
 
@@ -267,5 +259,5 @@ netsnmp_daemonize(int quit_immediately, int stderr_log)
 }
 
 #else /* !NEED_NETSNMP_DAEMONIZE */
-int netsnp_daemonize_bs;
+NONEMPTY_TRANSLATION_UNIT
 #endif
diff --git a/contrib/ntp/ntpsnmpd/ntpsnmpd-opts.c b/contrib/ntp/ntpsnmpd/ntpsnmpd-opts.c
index f13108da18d2..a05c8acdd05d 100644
--- a/contrib/ntp/ntpsnmpd/ntpsnmpd-opts.c
+++ b/contrib/ntp/ntpsnmpd/ntpsnmpd-opts.c
@@ -1,7 +1,7 @@
 /*
  *  EDIT THIS FILE WITH CAUTION  (ntpsnmpd-opts.c)
  *
- *  It has been AutoGen-ed  June  6, 2023 at 04:38:17 AM by AutoGen 5.18.16
+ *  It has been AutoGen-ed  May 25, 2024 at 12:04:35 AM by AutoGen 5.18.16
  *  From the definitions    ntpsnmpd-opts.def
  *  and the template file   options
  *
@@ -18,7 +18,7 @@
  * The ntpsnmpd program is copyrighted and licensed
  * under the following terms:
  *
- *  Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation, all rights reserved.
+ *  Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation, all rights reserved.
  *  This is free software. It is licensed for use, modification and
  *  redistribution under the terms of the NTP License, copies of which
  *  can be seen at:
@@ -66,8 +66,8 @@ extern FILE * option_usage_fp;
  *  static const strings for ntpsnmpd options
  */
 static char const ntpsnmpd_opt_strs[1614] =
-/*     0 */ "ntpsnmpd 4.2.8p17\n"
-            "Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation, all rights reserved.\n"
+/*     0 */ "ntpsnmpd 4.2.8p18\n"
+            "Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation, all rights reserved.\n"
             "This is free software. It is licensed for use, modification and\n"
             "redistribution under the terms of the NTP License, copies of which\n"
             "can be seen at:\n"
@@ -106,14 +106,14 @@ static char const ntpsnmpd_opt_strs[1614] =
 /*  1415 */ "no-load-opts\0"
 /*  1428 */ "no\0"
 /*  1431 */ "NTPSNMPD\0"
-/*  1440 */ "ntpsnmpd - NTP SNMP MIB agent - Ver. 4.2.8p17\n"
+/*  1440 */ "ntpsnmpd - NTP SNMP MIB agent - Ver. 4.2.8p18\n"
             "Usage:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n\0"
 /*  1544 */ "$HOME\0"
 /*  1550 */ ".\0"
 /*  1552 */ ".ntprc\0"
 /*  1559 */ "https://bugs.ntp.org, bugs@ntp.org\0"
 /*  1594 */ "\n\0"
-/*  1596 */ "ntpsnmpd 4.2.8p17";
+/*  1596 */ "ntpsnmpd 4.2.8p18";
 
 /**
  *  nofork option description:
@@ -559,8 +559,8 @@ static void bogus_function(void) {
      translate option names.
    */
   /* referenced via ntpsnmpdOptions.pzCopyright */
-  puts(_("ntpsnmpd 4.2.8p17\n\
-Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation, all rights reserved.\n\
+  puts(_("ntpsnmpd 4.2.8p18\n\
+Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation, all rights reserved.\n\
 This is free software. It is licensed for use, modification and\n\
 redistribution under the terms of the NTP License, copies of which\n\
 can be seen at:\n"));
@@ -604,14 +604,14 @@ implied warranty.\n"));
   puts(_("load options from a config file"));
 
   /* referenced via ntpsnmpdOptions.pzUsageTitle */
-  puts(_("ntpsnmpd - NTP SNMP MIB agent - Ver. 4.2.8p17\n\
+  puts(_("ntpsnmpd - NTP SNMP MIB agent - Ver. 4.2.8p18\n\
 Usage:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n"));
 
   /* referenced via ntpsnmpdOptions.pzExplain */
   puts(_("\n"));
 
   /* referenced via ntpsnmpdOptions.pzFullVersion */
-  puts(_("ntpsnmpd 4.2.8p17"));
+  puts(_("ntpsnmpd 4.2.8p18"));
 
   /* referenced via ntpsnmpdOptions.pzFullUsage */
   puts(_("<<<NOT-FOUND>>>"));
diff --git a/contrib/ntp/ntpsnmpd/ntpsnmpd-opts.h b/contrib/ntp/ntpsnmpd/ntpsnmpd-opts.h
index d5239d2e3050..5eab9a6cbf19 100644
--- a/contrib/ntp/ntpsnmpd/ntpsnmpd-opts.h
+++ b/contrib/ntp/ntpsnmpd/ntpsnmpd-opts.h
@@ -1,7 +1,7 @@
 /*
  *  EDIT THIS FILE WITH CAUTION  (ntpsnmpd-opts.h)
  *
- *  It has been AutoGen-ed  June  6, 2023 at 04:38:16 AM by AutoGen 5.18.16
+ *  It has been AutoGen-ed  May 25, 2024 at 12:04:34 AM by AutoGen 5.18.16
  *  From the definitions    ntpsnmpd-opts.def
  *  and the template file   options
  *
@@ -18,7 +18,7 @@
  * The ntpsnmpd program is copyrighted and licensed
  * under the following terms:
  *
- *  Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation, all rights reserved.
+ *  Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation, all rights reserved.
  *  This is free software. It is licensed for use, modification and
  *  redistribution under the terms of the NTP License, copies of which
  *  can be seen at:
@@ -84,9 +84,9 @@ typedef enum {
 /** count of all options for ntpsnmpd */
 #define OPTION_CT    8
 /** ntpsnmpd version */
-#define NTPSNMPD_VERSION       "4.2.8p17"
+#define NTPSNMPD_VERSION       "4.2.8p18"
 /** Full ntpsnmpd version text */
-#define NTPSNMPD_FULL_VERSION  "ntpsnmpd 4.2.8p17"
+#define NTPSNMPD_FULL_VERSION  "ntpsnmpd 4.2.8p18"
 
 /**
  *  Interface defines for all options.  Replace "n" with the UPPER_CASED
diff --git a/contrib/ntp/ntpsnmpd/ntpsnmpd.1ntpsnmpdman b/contrib/ntp/ntpsnmpd/ntpsnmpd.1ntpsnmpdman
index 29f12c6c913d..469f652aef46 100644
--- a/contrib/ntp/ntpsnmpd/ntpsnmpd.1ntpsnmpdman
+++ b/contrib/ntp/ntpsnmpd/ntpsnmpd.1ntpsnmpdman
@@ -10,11 +10,11 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH ntpsnmpd 1ntpsnmpdman "06 Jun 2023" "4.2.8p17" "User Commands"
+.TH ntpsnmpd 1ntpsnmpdman "25 May 2024" "4.2.8p18" "User Commands"
 .\"
 .\" EDIT THIS FILE WITH CAUTION (in-mem file)
 .\"
-.\" It has been AutoGen-ed June 6, 2023 at 04:38:21 AM by AutoGen 5.18.16
+.\" It has been AutoGen-ed May 25, 2024 at 12:04:40 AM by AutoGen 5.18.16
 .\" From the definitions ntpsnmpd-opts.def
 .\" and the template file agman-cmd.tpl
 .SH NAME
@@ -138,7 +138,7 @@ it to autogen-users@lists.sourceforge.net.  Thank you.
 .NOP  "Heiko Gerstung" 
 .br
 .SH "COPYRIGHT"
-Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation all rights reserved.
 This program is released under the terms of the NTP license, <http://ntp.org/license>.
 .SH "BUGS"
 Please send bug reports to: https://bugs.ntp.org, bugs@ntp.org
diff --git a/contrib/ntp/ntpsnmpd/ntpsnmpd.1ntpsnmpdmdoc b/contrib/ntp/ntpsnmpd/ntpsnmpd.1ntpsnmpdmdoc
index be353c7468ce..273e7f7479f7 100644
--- a/contrib/ntp/ntpsnmpd/ntpsnmpd.1ntpsnmpdmdoc
+++ b/contrib/ntp/ntpsnmpd/ntpsnmpd.1ntpsnmpdmdoc
@@ -1,9 +1,9 @@
-.Dd June 6 2023
+.Dd May 25 2024
 .Dt NTPSNMPD 1ntpsnmpdmdoc User Commands
 .Os
 .\"  EDIT THIS FILE WITH CAUTION  (ntpsnmpd-opts.mdoc)
 .\"
-.\"  It has been AutoGen-ed  June  6, 2023 at 04:38:18 AM by AutoGen 5.18.16
+.\"  It has been AutoGen-ed  May 25, 2024 at 12:04:37 AM by AutoGen 5.18.16
 .\"  From the definitions    ntpsnmpd-opts.def
 .\"  and the template file   agmdoc-cmd.tpl
 .Sh NAME
@@ -110,7 +110,7 @@ it to autogen\-users@lists.sourceforge.net.  Thank you.
 .Sh AUTHORS
 .An "Heiko Gerstung"
 .Sh "COPYRIGHT"
-Copyright (C) 1992\-2023 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992\-2024 The University of Delaware and Network Time Foundation all rights reserved.
 This program is released under the terms of the NTP license, <http://ntp.org/license>.
 .Sh "BUGS"
 Please send bug reports to: https://bugs.ntp.org, bugs@ntp.org
diff --git a/contrib/ntp/ntpsnmpd/ntpsnmpd.html b/contrib/ntp/ntpsnmpd/ntpsnmpd.html
index e31de98c7b90..1bb8f560f220 100644
--- a/contrib/ntp/ntpsnmpd/ntpsnmpd.html
+++ b/contrib/ntp/ntpsnmpd/ntpsnmpd.html
@@ -60,7 +60,7 @@ Next: <a href="#ntpsnmpd-Description" accesskey="n" rel="next">ntpsnmpd Descript
 <p>The <code>ntpsnmpd</code> utility program is used to monitor NTP daemon <code>ntpd</code>
 operations and determine performance.  It uses the standard NTP mode 6 control
 </p>
-<p>This document applies to version 4.2.8p17 of <code>ntpsnmpd</code>.
+<p>This document applies to version 4.2.8p18 of <code>ntpsnmpd</code>.
 </p>
 <table class="menu" border="0" cellspacing="0">
 <tr><td align="left" valign="top">&bull; <a href="#ntpsnmpd-Description" accesskey="1">ntpsnmpd Description</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Description
diff --git a/contrib/ntp/ntpsnmpd/ntpsnmpd.man.in b/contrib/ntp/ntpsnmpd/ntpsnmpd.man.in
index 7080d07b3310..9990ae66a0ef 100644
--- a/contrib/ntp/ntpsnmpd/ntpsnmpd.man.in
+++ b/contrib/ntp/ntpsnmpd/ntpsnmpd.man.in
@@ -10,11 +10,11 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH ntpsnmpd @NTPSNMPD_MS@ "06 Jun 2023" "4.2.8p17" "User Commands"
+.TH ntpsnmpd @NTPSNMPD_MS@ "25 May 2024" "4.2.8p18" "User Commands"
 .\"
 .\" EDIT THIS FILE WITH CAUTION (in-mem file)
 .\"
-.\" It has been AutoGen-ed June 6, 2023 at 04:38:21 AM by AutoGen 5.18.16
+.\" It has been AutoGen-ed May 25, 2024 at 12:04:40 AM by AutoGen 5.18.16
 .\" From the definitions ntpsnmpd-opts.def
 .\" and the template file agman-cmd.tpl
 .SH NAME
@@ -138,7 +138,7 @@ it to autogen-users@lists.sourceforge.net.  Thank you.
 .NOP  "Heiko Gerstung" 
 .br
 .SH "COPYRIGHT"
-Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation all rights reserved.
 This program is released under the terms of the NTP license, <http://ntp.org/license>.
 .SH "BUGS"
 Please send bug reports to: https://bugs.ntp.org, bugs@ntp.org
diff --git a/contrib/ntp/ntpsnmpd/ntpsnmpd.mdoc.in b/contrib/ntp/ntpsnmpd/ntpsnmpd.mdoc.in
index b0f89d34b309..144a1d192f9d 100644
--- a/contrib/ntp/ntpsnmpd/ntpsnmpd.mdoc.in
+++ b/contrib/ntp/ntpsnmpd/ntpsnmpd.mdoc.in
@@ -1,9 +1,9 @@
-.Dd June 6 2023
+.Dd May 25 2024
 .Dt NTPSNMPD @NTPSNMPD_MS@ User Commands
 .Os
 .\"  EDIT THIS FILE WITH CAUTION  (ntpsnmpd-opts.mdoc)
 .\"
-.\"  It has been AutoGen-ed  June  6, 2023 at 04:38:18 AM by AutoGen 5.18.16
+.\"  It has been AutoGen-ed  May 25, 2024 at 12:04:37 AM by AutoGen 5.18.16
 .\"  From the definitions    ntpsnmpd-opts.def
 .\"  and the template file   agmdoc-cmd.tpl
 .Sh NAME
@@ -110,7 +110,7 @@ it to autogen\-users@lists.sourceforge.net.  Thank you.
 .Sh AUTHORS
 .An "Heiko Gerstung"
 .Sh "COPYRIGHT"
-Copyright (C) 1992\-2023 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992\-2024 The University of Delaware and Network Time Foundation all rights reserved.
 This program is released under the terms of the NTP license, <http://ntp.org/license>.
 .Sh "BUGS"
 Please send bug reports to: https://bugs.ntp.org, bugs@ntp.org
diff --git a/contrib/ntp/packageinfo.sh b/contrib/ntp/packageinfo.sh
index 0ee08b67086d..bb31a6277a9d 100644
--- a/contrib/ntp/packageinfo.sh
+++ b/contrib/ntp/packageinfo.sh
@@ -33,6 +33,8 @@
 #
 # To skip over -stable beta1 directly to -RC1, set prerelease=rc.
 #
+# To proceed from  a -stable RC to the release set rcpoint=GO
+#
 # To skip all -stable prereleases and move from one primary or point 
 #   release directly to the next point release, set rcpoint=GO.
 #
@@ -83,7 +85,7 @@ CLTAG=NTP_4_2_0
 # - Numeric values increment
 # - empty 'increments' to 1
 # - NEW 'increments' to empty
-point=17
+point=18
 
 ### betapoint is normally modified by script.
 # ntp-stable Beta number (betapoint)
diff --git a/contrib/ntp/parseutil/Makefile.in b/contrib/ntp/parseutil/Makefile.in
index 66d6f695d8dc..7deca0773120 100644
--- a/contrib/ntp/parseutil/Makefile.in
+++ b/contrib/ntp/parseutil/Makefile.in
@@ -384,6 +384,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_NET_SNMP_CONFIG = @PATH_NET_SNMP_CONFIG@
+PATH_OPENSSL = @PATH_OPENSSL@
 PATH_PERL = @PATH_PERL@
 PATH_RUBY = @PATH_RUBY@
 PATH_SEPARATOR = @PATH_SEPARATOR@
diff --git a/contrib/ntp/scripts/Makefile.in b/contrib/ntp/scripts/Makefile.in
index 026185093d03..a2156011a514 100644
--- a/contrib/ntp/scripts/Makefile.in
+++ b/contrib/ntp/scripts/Makefile.in
@@ -420,6 +420,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_NET_SNMP_CONFIG = @PATH_NET_SNMP_CONFIG@
+PATH_OPENSSL = @PATH_OPENSSL@
 PATH_PERL = @PATH_PERL@
 PATH_RUBY = @PATH_RUBY@
 PATH_SEPARATOR = @PATH_SEPARATOR@
diff --git a/contrib/ntp/scripts/build/Makefile.in b/contrib/ntp/scripts/build/Makefile.in
index 51446d9bf3cc..cd023719137b 100644
--- a/contrib/ntp/scripts/build/Makefile.in
+++ b/contrib/ntp/scripts/build/Makefile.in
@@ -328,6 +328,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_NET_SNMP_CONFIG = @PATH_NET_SNMP_CONFIG@
+PATH_OPENSSL = @PATH_OPENSSL@
 PATH_PERL = @PATH_PERL@
 PATH_RUBY = @PATH_RUBY@
 PATH_SEPARATOR = @PATH_SEPARATOR@
diff --git a/contrib/ntp/scripts/build/checkHtmlFileDates b/contrib/ntp/scripts/build/checkHtmlFileDates
index 9d9a2f2625d0..5eae87f7af41 100755
--- a/contrib/ntp/scripts/build/checkHtmlFileDates
+++ b/contrib/ntp/scripts/build/checkHtmlFileDates
@@ -1,11 +1,29 @@
 #! /bin/sh
 
-bk version > /dev/null 2>&1 || exit 0
+#
+# checkHtmlFileDates
+#
+# This script is invoked in html directory when any html/*.html file
+# is newer than html/.datecheck to update the last modified time
+# within the HTML.  Each file is compared against the checked-in
+# version is compared to any uncommitted edits and if there are
+# any, scripts/build/updateBEDate is used to update the embedded
+# timestamp.  html/.datecheck is not distributed in releases so
+# this will be invoked once building a newly-extracted tarball.
+# 'bk diff' is used to check for modifications so if bk is not
+# on the path there's no need to invoke this repeatedly.
+# Therefore touch .datecheck unconditionally right away.
+#
+touch .datecheck
 
-for i in `find * -type f -name '*.html' -print | grep -v SCCS/`
+# Do nothing if the directory is not a BK repo,
+# or if BK is not even installed.
+bk status > /dev/null 2>&1 || exit 0
+
+for i in `echo *.html`
 do
     # echo $i
-    set `bk diffs $i | wc -l`
+    set `bk diff --normal $i | wc -l`
     lines=$1
     case "$lines" in
      0) ;;
diff --git a/contrib/ntp/scripts/build/genAuthors.in b/contrib/ntp/scripts/build/genAuthors.in
index a5a15e1270b0..a1b5a4023acd 100644
--- a/contrib/ntp/scripts/build/genAuthors.in
+++ b/contrib/ntp/scripts/build/genAuthors.in
@@ -1,4 +1,5 @@
 #! @PATH_PERL@
+# @configure_input@
 
 # DESCRIPTION
 #
diff --git a/contrib/ntp/scripts/build/mkver.in b/contrib/ntp/scripts/build/mkver.in
index c58d8040f1d9..89ea50bc5e51 100644
--- a/contrib/ntp/scripts/build/mkver.in
+++ b/contrib/ntp/scripts/build/mkver.in
@@ -1,4 +1,6 @@
 #!@CONFIG_SHELL@
+# @configure_input@
+
 PROG=${1-UNKNOWN}
 
 ConfStr="$PROG"
diff --git a/contrib/ntp/scripts/calc_tickadj/Makefile.in b/contrib/ntp/scripts/calc_tickadj/Makefile.in
index f4dc33b2209c..050ab5af6000 100644
--- a/contrib/ntp/scripts/calc_tickadj/Makefile.in
+++ b/contrib/ntp/scripts/calc_tickadj/Makefile.in
@@ -364,6 +364,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_NET_SNMP_CONFIG = @PATH_NET_SNMP_CONFIG@
+PATH_OPENSSL = @PATH_OPENSSL@
 PATH_PERL = @PATH_PERL@
 PATH_RUBY = @PATH_RUBY@
 PATH_SEPARATOR = @PATH_SEPARATOR@
diff --git a/contrib/ntp/scripts/calc_tickadj/calc_tickadj.1calc_tickadjman b/contrib/ntp/scripts/calc_tickadj/calc_tickadj.1calc_tickadjman
index e1d2216c31d8..3d42eca9f834 100644
--- a/contrib/ntp/scripts/calc_tickadj/calc_tickadj.1calc_tickadjman
+++ b/contrib/ntp/scripts/calc_tickadj/calc_tickadj.1calc_tickadjman
@@ -10,11 +10,11 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH calc_tickadj 1calc_tickadjman "06 Jun 2023" "ntp (4.2.8p17)" "User Commands"
+.TH calc_tickadj 1calc_tickadjman "25 May 2024" "ntp (4.2.8p18)" "User Commands"
 .\"
 .\" EDIT THIS FILE WITH CAUTION (in-mem file)
 .\"
-.\" It has been AutoGen-ed June 6, 2023 at 04:39:10 AM by AutoGen 5.18.16
+.\" It has been AutoGen-ed May 25, 2024 at 12:05:32 AM by AutoGen 5.18.16
 .\" From the definitions calc_tickadj-opts.def
 .\" and the template file agman-cmd.tpl
 .SH NAME
diff --git a/contrib/ntp/scripts/calc_tickadj/calc_tickadj.1calc_tickadjmdoc b/contrib/ntp/scripts/calc_tickadj/calc_tickadj.1calc_tickadjmdoc
index 71507c329099..6098e246b70d 100644
--- a/contrib/ntp/scripts/calc_tickadj/calc_tickadj.1calc_tickadjmdoc
+++ b/contrib/ntp/scripts/calc_tickadj/calc_tickadj.1calc_tickadjmdoc
@@ -1,9 +1,9 @@
-.Dd June 6 2023
+.Dd May 25 2024
 .Dt CALC_TICKADJ 1calc_tickadjmdoc User Commands
 .Os
 .\"  EDIT THIS FILE WITH CAUTION  (calc_tickadj-opts.mdoc)
 .\"
-.\"  It has been AutoGen-ed  June  6, 2023 at 04:39:12 AM by AutoGen 5.18.16
+.\"  It has been AutoGen-ed  May 25, 2024 at 12:05:33 AM by AutoGen 5.18.16
 .\"  From the definitions    calc_tickadj-opts.def
 .\"  and the template file   agmdoc-cmd.tpl
 .Sh NAME
diff --git a/contrib/ntp/scripts/calc_tickadj/calc_tickadj.html b/contrib/ntp/scripts/calc_tickadj/calc_tickadj.html
index fb583099b5d8..77c9f29bf9f6 100644
--- a/contrib/ntp/scripts/calc_tickadj/calc_tickadj.html
+++ b/contrib/ntp/scripts/calc_tickadj/calc_tickadj.html
@@ -47,7 +47,7 @@ Previous: <a href="dir.html#Top" accesskey="p" rel="prev">(dir)</a>, Up: <a href
 <span id="calc_005ftickadj-User_0027s-Manual"></span><h1 class="top">calc_tickadj User&rsquo;s Manual</h1>
 
 <p>This document describes the use of the NTP Project&rsquo;s <code>calc_tickadj</code> program.
-This document applies to version 4.2.8p17 of <code>calc_tickadj</code>.
+This document applies to version 4.2.8p18 of <code>calc_tickadj</code>.
 </p>
 <span id="SEC_Overview"></span>
 <h2 class="shortcontents-heading">Short Table of Contents</h2>
diff --git a/contrib/ntp/scripts/calc_tickadj/calc_tickadj.in b/contrib/ntp/scripts/calc_tickadj/calc_tickadj.in
index 38b826eb2fff..56c549adc82a 100644
--- a/contrib/ntp/scripts/calc_tickadj/calc_tickadj.in
+++ b/contrib/ntp/scripts/calc_tickadj/calc_tickadj.in
@@ -1,4 +1,5 @@
 #! @PATH_PERL@ -w
+# @configure_input@
 #
 # drift of 104.8576 -> +1 tick.  Base  of 10000 ticks.
 #
diff --git a/contrib/ntp/scripts/calc_tickadj/calc_tickadj.man.in b/contrib/ntp/scripts/calc_tickadj/calc_tickadj.man.in
index e1d2216c31d8..3d42eca9f834 100644
--- a/contrib/ntp/scripts/calc_tickadj/calc_tickadj.man.in
+++ b/contrib/ntp/scripts/calc_tickadj/calc_tickadj.man.in
@@ -10,11 +10,11 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH calc_tickadj 1calc_tickadjman "06 Jun 2023" "ntp (4.2.8p17)" "User Commands"
+.TH calc_tickadj 1calc_tickadjman "25 May 2024" "ntp (4.2.8p18)" "User Commands"
 .\"
 .\" EDIT THIS FILE WITH CAUTION (in-mem file)
 .\"
-.\" It has been AutoGen-ed June 6, 2023 at 04:39:10 AM by AutoGen 5.18.16
+.\" It has been AutoGen-ed May 25, 2024 at 12:05:32 AM by AutoGen 5.18.16
 .\" From the definitions calc_tickadj-opts.def
 .\" and the template file agman-cmd.tpl
 .SH NAME
diff --git a/contrib/ntp/scripts/calc_tickadj/calc_tickadj.mdoc.in b/contrib/ntp/scripts/calc_tickadj/calc_tickadj.mdoc.in
index 71507c329099..6098e246b70d 100644
--- a/contrib/ntp/scripts/calc_tickadj/calc_tickadj.mdoc.in
+++ b/contrib/ntp/scripts/calc_tickadj/calc_tickadj.mdoc.in
@@ -1,9 +1,9 @@
-.Dd June 6 2023
+.Dd May 25 2024
 .Dt CALC_TICKADJ 1calc_tickadjmdoc User Commands
 .Os
 .\"  EDIT THIS FILE WITH CAUTION  (calc_tickadj-opts.mdoc)
 .\"
-.\"  It has been AutoGen-ed  June  6, 2023 at 04:39:12 AM by AutoGen 5.18.16
+.\"  It has been AutoGen-ed  May 25, 2024 at 12:05:33 AM by AutoGen 5.18.16
 .\"  From the definitions    calc_tickadj-opts.def
 .\"  and the template file   agmdoc-cmd.tpl
 .Sh NAME
diff --git a/contrib/ntp/scripts/calc_tickadj/invoke-calc_tickadj.texi b/contrib/ntp/scripts/calc_tickadj/invoke-calc_tickadj.texi
index 6d0ce24f0096..c0ca429e83f2 100644
--- a/contrib/ntp/scripts/calc_tickadj/invoke-calc_tickadj.texi
+++ b/contrib/ntp/scripts/calc_tickadj/invoke-calc_tickadj.texi
@@ -6,7 +6,7 @@
 #
 # EDIT THIS FILE WITH CAUTION  (invoke-calc_tickadj.texi)
 #
-# It has been AutoGen-ed  June  6, 2023 at 04:39:13 AM by AutoGen 5.18.16
+# It has been AutoGen-ed  May 25, 2024 at 12:05:34 AM by AutoGen 5.18.16
 # From the definitions    calc_tickadj-opts.def
 # and the template file   agtexi-cmd.tpl
 @end ignore
diff --git a/contrib/ntp/scripts/invoke-plot_summary.texi b/contrib/ntp/scripts/invoke-plot_summary.texi
index 65faebaa7d97..39fe8082ef80 100644
--- a/contrib/ntp/scripts/invoke-plot_summary.texi
+++ b/contrib/ntp/scripts/invoke-plot_summary.texi
@@ -6,7 +6,7 @@
 #
 # EDIT THIS FILE WITH CAUTION  (invoke-plot_summary.texi)
 #
-# It has been AutoGen-ed  June  6, 2023 at 04:39:36 AM by AutoGen 5.18.16
+# It has been AutoGen-ed  May 25, 2024 at 12:05:57 AM by AutoGen 5.18.16
 # From the definitions    plot_summary-opts.def
 # and the template file   agtexi-cmd.tpl
 @end ignore
@@ -41,7 +41,7 @@ with a status code of 0.
 
 @exampleindent 0
 @example
-plot_summary - plot statistics generated by summary script - Ver. 4.2.8p17
+plot_summary - plot statistics generated by summary script - Ver. 4.2.8p18
 USAGE: plot_summary [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... 
 
         --directory=str          Where the summary files are
diff --git a/contrib/ntp/scripts/invoke-summary.texi b/contrib/ntp/scripts/invoke-summary.texi
index 1b82c93397b7..4a4bf7c44f13 100644
--- a/contrib/ntp/scripts/invoke-summary.texi
+++ b/contrib/ntp/scripts/invoke-summary.texi
@@ -6,7 +6,7 @@
 #
 # EDIT THIS FILE WITH CAUTION  (invoke-summary.texi)
 #
-# It has been AutoGen-ed  June  6, 2023 at 04:39:40 AM by AutoGen 5.18.16
+# It has been AutoGen-ed  May 25, 2024 at 12:06:02 AM by AutoGen 5.18.16
 # From the definitions    summary-opts.def
 # and the template file   agtexi-cmd.tpl
 @end ignore
@@ -42,7 +42,7 @@ with a status code of 0.
 
 @exampleindent 0
 @example
-summary - compute various stastics from NTP stat files - Ver. 4.2.8p17
+summary - compute various stastics from NTP stat files - Ver. 4.2.8p18
 USAGE: summary [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... 
 
         --directory=str          Directory containing stat files
diff --git a/contrib/ntp/scripts/lib/Makefile.in b/contrib/ntp/scripts/lib/Makefile.in
index 90d82539d476..e370bf134e31 100644
--- a/contrib/ntp/scripts/lib/Makefile.in
+++ b/contrib/ntp/scripts/lib/Makefile.in
@@ -355,6 +355,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_NET_SNMP_CONFIG = @PATH_NET_SNMP_CONFIG@
+PATH_OPENSSL = @PATH_OPENSSL@
 PATH_PERL = @PATH_PERL@
 PATH_RUBY = @PATH_RUBY@
 PATH_SEPARATOR = @PATH_SEPARATOR@
diff --git a/contrib/ntp/scripts/ntp-wait/Makefile.in b/contrib/ntp/scripts/ntp-wait/Makefile.in
index 9aa6ee7afb34..854c10ff9716 100644
--- a/contrib/ntp/scripts/ntp-wait/Makefile.in
+++ b/contrib/ntp/scripts/ntp-wait/Makefile.in
@@ -363,6 +363,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_NET_SNMP_CONFIG = @PATH_NET_SNMP_CONFIG@
+PATH_OPENSSL = @PATH_OPENSSL@
 PATH_PERL = @PATH_PERL@
 PATH_RUBY = @PATH_RUBY@
 PATH_SEPARATOR = @PATH_SEPARATOR@
diff --git a/contrib/ntp/scripts/ntp-wait/invoke-ntp-wait.texi b/contrib/ntp/scripts/ntp-wait/invoke-ntp-wait.texi
index 138a43d9b2fc..aff658518c97 100644
--- a/contrib/ntp/scripts/ntp-wait/invoke-ntp-wait.texi
+++ b/contrib/ntp/scripts/ntp-wait/invoke-ntp-wait.texi
@@ -6,7 +6,7 @@
 #
 # EDIT THIS FILE WITH CAUTION  (invoke-ntp-wait.texi)
 #
-# It has been AutoGen-ed  June  6, 2023 at 04:39:17 AM by AutoGen 5.18.16
+# It has been AutoGen-ed  May 25, 2024 at 12:05:38 AM by AutoGen 5.18.16
 # From the definitions    ntp-wait-opts.def
 # and the template file   agtexi-cmd.tpl
 @end ignore
@@ -61,7 +61,7 @@ with a status code of 0.
 
 @exampleindent 0
 @example
-ntp-wait - Wait for ntpd to stabilize the system clock - Ver. 4.2.8p17
+ntp-wait - Wait for ntpd to stabilize the system clock - Ver. 4.2.8p18
 USAGE: ntp-wait [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... 
 
     -n, --tries=num              Number of times to check ntpd
diff --git a/contrib/ntp/scripts/ntp-wait/ntp-wait-opts b/contrib/ntp/scripts/ntp-wait/ntp-wait-opts
index 944d4c1404ab..8358c3bbcada 100644
--- a/contrib/ntp/scripts/ntp-wait/ntp-wait-opts
+++ b/contrib/ntp/scripts/ntp-wait/ntp-wait-opts
@@ -1,6 +1,6 @@
 # EDIT THIS FILE WITH CAUTION  (ntp-wait-opts)
 #
-# It has been AutoGen-ed  June  6, 2023 at 04:39:15 AM by AutoGen 5.18.16
+# It has been AutoGen-ed  May 25, 2024 at 12:05:36 AM by AutoGen 5.18.16
 # From the definitions    ntp-wait-opts.def
 # and the template file   perlopt
 
@@ -40,7 +40,7 @@ sub processOptions {
         'help|?', 'more-help'));
 
     $usage = <<'USAGE';
-ntp-wait - Wait for ntpd to stabilize the system clock - Ver. 4.2.8p17
+ntp-wait - Wait for ntpd to stabilize the system clock - Ver. 4.2.8p18
 USAGE: ntp-wait [ -<flag> [<val>] | --<name>[{=| }<val>] ]... 
 
     -n, --tries=num              Number of times to check ntpd
diff --git a/contrib/ntp/scripts/ntp-wait/ntp-wait.1ntp-waitman b/contrib/ntp/scripts/ntp-wait/ntp-wait.1ntp-waitman
index 1a01d97b5729..d5a54e07880e 100644
--- a/contrib/ntp/scripts/ntp-wait/ntp-wait.1ntp-waitman
+++ b/contrib/ntp/scripts/ntp-wait/ntp-wait.1ntp-waitman
@@ -10,11 +10,11 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH ntp-wait 1ntp-waitman "06 Jun 2023" "ntp (4.2.8p17)" "User Commands"
+.TH ntp-wait 1ntp-waitman "25 May 2024" "ntp (4.2.8p18)" "User Commands"
 .\"
 .\" EDIT THIS FILE WITH CAUTION (in-mem file)
 .\"
-.\" It has been AutoGen-ed June 6, 2023 at 04:39:18 AM by AutoGen 5.18.16
+.\" It has been AutoGen-ed May 25, 2024 at 12:05:40 AM by AutoGen 5.18.16
 .\" From the definitions ntp-wait-opts.def
 .\" and the template file agman-cmd.tpl
 .SH NAME
diff --git a/contrib/ntp/scripts/ntp-wait/ntp-wait.1ntp-waitmdoc b/contrib/ntp/scripts/ntp-wait/ntp-wait.1ntp-waitmdoc
index cb5ad0252df6..3da960f0409c 100644
--- a/contrib/ntp/scripts/ntp-wait/ntp-wait.1ntp-waitmdoc
+++ b/contrib/ntp/scripts/ntp-wait/ntp-wait.1ntp-waitmdoc
@@ -1,9 +1,9 @@
-.Dd June 6 2023
+.Dd May 25 2024
 .Dt NTP_WAIT 1ntp-waitmdoc User Commands
 .Os
 .\"  EDIT THIS FILE WITH CAUTION  (ntp-wait-opts.mdoc)
 .\"
-.\"  It has been AutoGen-ed  June  6, 2023 at 04:39:15 AM by AutoGen 5.18.16
+.\"  It has been AutoGen-ed  May 25, 2024 at 12:05:37 AM by AutoGen 5.18.16
 .\"  From the definitions    ntp-wait-opts.def
 .\"  and the template file   agmdoc-cmd.tpl
 .Sh NAME
diff --git a/contrib/ntp/scripts/ntp-wait/ntp-wait.html b/contrib/ntp/scripts/ntp-wait/ntp-wait.html
index 282f5db6e517..d21222c12fc5 100644
--- a/contrib/ntp/scripts/ntp-wait/ntp-wait.html
+++ b/contrib/ntp/scripts/ntp-wait/ntp-wait.html
@@ -58,7 +58,7 @@ until the system&rsquo;s time has stabilized and synchronized,
 and only then start any applicaitons (like database servers) that require
 accurate and stable time.
 </p>
-<p>This document applies to version 4.2.8p17 of <code>ntp-wait</code>.
+<p>This document applies to version 4.2.8p18 of <code>ntp-wait</code>.
 </p>
 <span id="SEC_Overview"></span>
 <h2 class="shortcontents-heading">Short Table of Contents</h2>
@@ -145,7 +145,7 @@ used to select the program, defaulting to <samp>more</samp>.  Both will exit
 with a status code of 0.
 </p>
 <div class="example">
-<pre class="example">ntp-wait - Wait for ntpd to stabilize the system clock - Ver. 4.2.8p17
+<pre class="example">ntp-wait - Wait for ntpd to stabilize the system clock - Ver. 4.2.8p18
 USAGE: ntp-wait [ -&lt;flag&gt; [&lt;val&gt;] | --&lt;name&gt;[{=| }&lt;val&gt;] ]... 
 
     -n, --tries=num              Number of times to check ntpd
diff --git a/contrib/ntp/scripts/ntp-wait/ntp-wait.in b/contrib/ntp/scripts/ntp-wait/ntp-wait.in
index cfccbe0ac2ad..3b7a3ce4c647 100644
--- a/contrib/ntp/scripts/ntp-wait/ntp-wait.in
+++ b/contrib/ntp/scripts/ntp-wait/ntp-wait.in
@@ -1,4 +1,5 @@
 #! @PATH_PERL@
+# @configure_input@
 
 package ntp_wait;
 use 5.006_000;
diff --git a/contrib/ntp/scripts/ntp-wait/ntp-wait.man.in b/contrib/ntp/scripts/ntp-wait/ntp-wait.man.in
index 4e9b184b847f..a2c54e4f2ed1 100644
--- a/contrib/ntp/scripts/ntp-wait/ntp-wait.man.in
+++ b/contrib/ntp/scripts/ntp-wait/ntp-wait.man.in
@@ -10,11 +10,11 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH ntp-wait @NTP_WAIT_MS@ "06 Jun 2023" "ntp (4.2.8p17)" "User Commands"
+.TH ntp-wait @NTP_WAIT_MS@ "25 May 2024" "ntp (4.2.8p18)" "User Commands"
 .\"
 .\" EDIT THIS FILE WITH CAUTION (in-mem file)
 .\"
-.\" It has been AutoGen-ed June 6, 2023 at 04:39:18 AM by AutoGen 5.18.16
+.\" It has been AutoGen-ed May 25, 2024 at 12:05:40 AM by AutoGen 5.18.16
 .\" From the definitions ntp-wait-opts.def
 .\" and the template file agman-cmd.tpl
 .SH NAME
diff --git a/contrib/ntp/scripts/ntp-wait/ntp-wait.mdoc.in b/contrib/ntp/scripts/ntp-wait/ntp-wait.mdoc.in
index 35e7a2ab06fd..1b7d34ba3888 100644
--- a/contrib/ntp/scripts/ntp-wait/ntp-wait.mdoc.in
+++ b/contrib/ntp/scripts/ntp-wait/ntp-wait.mdoc.in
@@ -1,9 +1,9 @@
-.Dd June 6 2023
+.Dd May 25 2024
 .Dt NTP_WAIT @NTP_WAIT_MS@ User Commands
 .Os
 .\"  EDIT THIS FILE WITH CAUTION  (ntp-wait-opts.mdoc)
 .\"
-.\"  It has been AutoGen-ed  June  6, 2023 at 04:39:15 AM by AutoGen 5.18.16
+.\"  It has been AutoGen-ed  May 25, 2024 at 12:05:37 AM by AutoGen 5.18.16
 .\"  From the definitions    ntp-wait-opts.def
 .\"  and the template file   agmdoc-cmd.tpl
 .Sh NAME
diff --git a/contrib/ntp/scripts/ntpsweep/Makefile.in b/contrib/ntp/scripts/ntpsweep/Makefile.in
index 027f0847ecdf..01b0143e4439 100644
--- a/contrib/ntp/scripts/ntpsweep/Makefile.in
+++ b/contrib/ntp/scripts/ntpsweep/Makefile.in
@@ -364,6 +364,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_NET_SNMP_CONFIG = @PATH_NET_SNMP_CONFIG@
+PATH_OPENSSL = @PATH_OPENSSL@
 PATH_PERL = @PATH_PERL@
 PATH_RUBY = @PATH_RUBY@
 PATH_SEPARATOR = @PATH_SEPARATOR@
diff --git a/contrib/ntp/scripts/ntpsweep/invoke-ntpsweep.texi b/contrib/ntp/scripts/ntpsweep/invoke-ntpsweep.texi
index d81aa76d21d2..f0d8720ae66b 100644
--- a/contrib/ntp/scripts/ntpsweep/invoke-ntpsweep.texi
+++ b/contrib/ntp/scripts/ntpsweep/invoke-ntpsweep.texi
@@ -6,7 +6,7 @@
 #
 # EDIT THIS FILE WITH CAUTION  (invoke-ntpsweep.texi)
 #
-# It has been AutoGen-ed  June  6, 2023 at 04:39:20 AM by AutoGen 5.18.16
+# It has been AutoGen-ed  May 25, 2024 at 12:05:42 AM by AutoGen 5.18.16
 # From the definitions    ntpsweep-opts.def
 # and the template file   agtexi-cmd.tpl
 @end ignore
@@ -45,7 +45,7 @@ with a status code of 0.
 
 @exampleindent 0
 @example
-ntpsweep - Print various informations about given ntp servers - Ver. 4.2.8p17
+ntpsweep - Print various informations about given ntp servers - Ver. 4.2.8p18
 USAGE: ntpsweep [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... [hostfile]
 
     -l, --host-list=str          Host to execute actions on
diff --git a/contrib/ntp/scripts/ntpsweep/ntpsweep-opts b/contrib/ntp/scripts/ntpsweep/ntpsweep-opts
index 61bfb34159f0..9fad3f4be01c 100644
--- a/contrib/ntp/scripts/ntpsweep/ntpsweep-opts
+++ b/contrib/ntp/scripts/ntpsweep/ntpsweep-opts
@@ -1,6 +1,6 @@
 # EDIT THIS FILE WITH CAUTION  (ntpsweep-opts)
 #
-# It has been AutoGen-ed  June  6, 2023 at 04:39:20 AM by AutoGen 5.18.16
+# It has been AutoGen-ed  May 25, 2024 at 12:05:41 AM by AutoGen 5.18.16
 # From the definitions    ntpsweep-opts.def
 # and the template file   perlopt
 
@@ -43,7 +43,7 @@ sub processOptions {
         'help|?', 'more-help'));
 
     $usage = <<'USAGE';
-ntpsweep - Print various informations about given ntp servers - Ver. 4.2.8p17
+ntpsweep - Print various informations about given ntp servers - Ver. 4.2.8p18
 USAGE: ntpsweep [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [hostfile]
 
     -l, --host-list=str          Host to execute actions on
diff --git a/contrib/ntp/scripts/ntpsweep/ntpsweep.1ntpsweepman b/contrib/ntp/scripts/ntpsweep/ntpsweep.1ntpsweepman
index e609f54128ee..6fe4d206711f 100644
--- a/contrib/ntp/scripts/ntpsweep/ntpsweep.1ntpsweepman
+++ b/contrib/ntp/scripts/ntpsweep/ntpsweep.1ntpsweepman
@@ -10,11 +10,11 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH ntpsweep 1ntpsweepman "06 Jun 2023" "ntp (4.2.8p17)" "User Commands"
+.TH ntpsweep 1ntpsweepman "25 May 2024" "ntp (4.2.8p18)" "User Commands"
 .\"
 .\" EDIT THIS FILE WITH CAUTION (in-mem file)
 .\"
-.\" It has been AutoGen-ed June 6, 2023 at 04:39:23 AM by AutoGen 5.18.16
+.\" It has been AutoGen-ed May 25, 2024 at 12:05:45 AM by AutoGen 5.18.16
 .\" From the definitions ntpsweep-opts.def
 .\" and the template file agman-cmd.tpl
 .SH NAME
diff --git a/contrib/ntp/scripts/ntpsweep/ntpsweep.1ntpsweepmdoc b/contrib/ntp/scripts/ntpsweep/ntpsweep.1ntpsweepmdoc
index 37b9e81f20f7..07e1db269a2a 100644
--- a/contrib/ntp/scripts/ntpsweep/ntpsweep.1ntpsweepmdoc
+++ b/contrib/ntp/scripts/ntpsweep/ntpsweep.1ntpsweepmdoc
@@ -1,9 +1,9 @@
-.Dd June 6 2023
+.Dd May 25 2024
 .Dt NTPSWEEP 1ntpsweepmdoc User Commands
 .Os
 .\"  EDIT THIS FILE WITH CAUTION  (ntpsweep-opts.mdoc)
 .\"
-.\"  It has been AutoGen-ed  June  6, 2023 at 04:39:22 AM by AutoGen 5.18.16
+.\"  It has been AutoGen-ed  May 25, 2024 at 12:05:44 AM by AutoGen 5.18.16
 .\"  From the definitions    ntpsweep-opts.def
 .\"  and the template file   agmdoc-cmd.tpl
 .Sh NAME
diff --git a/contrib/ntp/scripts/ntpsweep/ntpsweep.html b/contrib/ntp/scripts/ntpsweep/ntpsweep.html
index bca4b02986cf..a030c541a323 100644
--- a/contrib/ntp/scripts/ntpsweep/ntpsweep.html
+++ b/contrib/ntp/scripts/ntpsweep/ntpsweep.html
@@ -49,7 +49,7 @@ Previous: <a href="dir.html#Top" accesskey="p" rel="prev">(dir)</a>, Up: <a href
 
 <p>This document describes the use of the NTP Project&rsquo;s <code>ntpsweep</code> program.
 </p>
-<p>This document applies to version 4.2.8p17 of <code>ntpsweep</code>.
+<p>This document applies to version 4.2.8p18 of <code>ntpsweep</code>.
 </p>
 <span id="SEC_Overview"></span>
 <h2 class="shortcontents-heading">Short Table of Contents</h2>
@@ -120,7 +120,7 @@ used to select the program, defaulting to <samp>more</samp>.  Both will exit
 with a status code of 0.
 </p>
 <div class="example">
-<pre class="example">ntpsweep - Print various informations about given ntp servers - Ver. 4.2.8p17
+<pre class="example">ntpsweep - Print various informations about given ntp servers - Ver. 4.2.8p18
 USAGE: ntpsweep [ -&lt;flag&gt; [&lt;val&gt;] | --&lt;name&gt;[{=| }&lt;val&gt;] ]... [hostfile]
 
     -l, --host-list=str          Host to execute actions on
diff --git a/contrib/ntp/scripts/ntpsweep/ntpsweep.in b/contrib/ntp/scripts/ntpsweep/ntpsweep.in
index 75ac0c8b06d9..b9b329e5dbda 100644
--- a/contrib/ntp/scripts/ntpsweep/ntpsweep.in
+++ b/contrib/ntp/scripts/ntpsweep/ntpsweep.in
@@ -1,4 +1,5 @@
 #! @PATH_PERL@ -w
+# @configure_input@
 #
 # $Id$
 #
diff --git a/contrib/ntp/scripts/ntpsweep/ntpsweep.man.in b/contrib/ntp/scripts/ntpsweep/ntpsweep.man.in
index e609f54128ee..6fe4d206711f 100644
--- a/contrib/ntp/scripts/ntpsweep/ntpsweep.man.in
+++ b/contrib/ntp/scripts/ntpsweep/ntpsweep.man.in
@@ -10,11 +10,11 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH ntpsweep 1ntpsweepman "06 Jun 2023" "ntp (4.2.8p17)" "User Commands"
+.TH ntpsweep 1ntpsweepman "25 May 2024" "ntp (4.2.8p18)" "User Commands"
 .\"
 .\" EDIT THIS FILE WITH CAUTION (in-mem file)
 .\"
-.\" It has been AutoGen-ed June 6, 2023 at 04:39:23 AM by AutoGen 5.18.16
+.\" It has been AutoGen-ed May 25, 2024 at 12:05:45 AM by AutoGen 5.18.16
 .\" From the definitions ntpsweep-opts.def
 .\" and the template file agman-cmd.tpl
 .SH NAME
diff --git a/contrib/ntp/scripts/ntpsweep/ntpsweep.mdoc.in b/contrib/ntp/scripts/ntpsweep/ntpsweep.mdoc.in
index 37b9e81f20f7..07e1db269a2a 100644
--- a/contrib/ntp/scripts/ntpsweep/ntpsweep.mdoc.in
+++ b/contrib/ntp/scripts/ntpsweep/ntpsweep.mdoc.in
@@ -1,9 +1,9 @@
-.Dd June 6 2023
+.Dd May 25 2024
 .Dt NTPSWEEP 1ntpsweepmdoc User Commands
 .Os
 .\"  EDIT THIS FILE WITH CAUTION  (ntpsweep-opts.mdoc)
 .\"
-.\"  It has been AutoGen-ed  June  6, 2023 at 04:39:22 AM by AutoGen 5.18.16
+.\"  It has been AutoGen-ed  May 25, 2024 at 12:05:44 AM by AutoGen 5.18.16
 .\"  From the definitions    ntpsweep-opts.def
 .\"  and the template file   agmdoc-cmd.tpl
 .Sh NAME
diff --git a/contrib/ntp/scripts/ntptrace/Makefile.in b/contrib/ntp/scripts/ntptrace/Makefile.in
index df8e287aa48d..4a9bc393b3d0 100644
--- a/contrib/ntp/scripts/ntptrace/Makefile.in
+++ b/contrib/ntp/scripts/ntptrace/Makefile.in
@@ -363,6 +363,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_NET_SNMP_CONFIG = @PATH_NET_SNMP_CONFIG@
+PATH_OPENSSL = @PATH_OPENSSL@
 PATH_PERL = @PATH_PERL@
 PATH_RUBY = @PATH_RUBY@
 PATH_SEPARATOR = @PATH_SEPARATOR@
diff --git a/contrib/ntp/scripts/ntptrace/invoke-ntptrace.texi b/contrib/ntp/scripts/ntptrace/invoke-ntptrace.texi
index 0169c0eb6a97..e813a78f7543 100644
--- a/contrib/ntp/scripts/ntptrace/invoke-ntptrace.texi
+++ b/contrib/ntp/scripts/ntptrace/invoke-ntptrace.texi
@@ -6,7 +6,7 @@
 #
 # EDIT THIS FILE WITH CAUTION  (invoke-ntptrace.texi)
 #
-# It has been AutoGen-ed  June  6, 2023 at 04:39:27 AM by AutoGen 5.18.16
+# It has been AutoGen-ed  May 25, 2024 at 12:05:48 AM by AutoGen 5.18.16
 # From the definitions    ntptrace-opts.def
 # and the template file   agtexi-cmd.tpl
 @end ignore
@@ -62,7 +62,7 @@ with a status code of 0.
 
 @exampleindent 0
 @example
-ntptrace - Trace peers of an NTP server - Ver. 4.2.8p17
+ntptrace - Trace peers of an NTP server - Ver. 4.2.8p18
 USAGE: ntptrace [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... [host]
 
     -n, --numeric                Print IP addresses instead of hostnames
diff --git a/contrib/ntp/scripts/ntptrace/ntptrace-opts b/contrib/ntp/scripts/ntptrace/ntptrace-opts
index ea17cb0f66c9..8857e8939c17 100644
--- a/contrib/ntp/scripts/ntptrace/ntptrace-opts
+++ b/contrib/ntp/scripts/ntptrace/ntptrace-opts
@@ -1,6 +1,6 @@
 # EDIT THIS FILE WITH CAUTION  (ntptrace-opts)
 #
-# It has been AutoGen-ed  June  6, 2023 at 04:39:25 AM by AutoGen 5.18.16
+# It has been AutoGen-ed  May 25, 2024 at 12:05:47 AM by AutoGen 5.18.16
 # From the definitions    ntptrace-opts.def
 # and the template file   perlopt
 
@@ -40,7 +40,7 @@ sub processOptions {
         'help|?', 'more-help'));
 
     $usage = <<'USAGE';
-ntptrace - Trace peers of an NTP server - Ver. 4.2.8p17
+ntptrace - Trace peers of an NTP server - Ver. 4.2.8p18
 USAGE: ntptrace [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [host]
 
     -n, --numeric                Print IP addresses instead of hostnames
diff --git a/contrib/ntp/scripts/ntptrace/ntptrace.1ntptraceman b/contrib/ntp/scripts/ntptrace/ntptrace.1ntptraceman
index c1833697961a..4da059ad556a 100644
--- a/contrib/ntp/scripts/ntptrace/ntptrace.1ntptraceman
+++ b/contrib/ntp/scripts/ntptrace/ntptrace.1ntptraceman
@@ -10,11 +10,11 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH ntptrace 1ntptraceman "06 Jun 2023" "ntp (4.2.8p17)" "User Commands"
+.TH ntptrace 1ntptraceman "25 May 2024" "ntp (4.2.8p18)" "User Commands"
 .\"
 .\" EDIT THIS FILE WITH CAUTION (in-mem file)
 .\"
-.\" It has been AutoGen-ed June 6, 2023 at 04:39:28 AM by AutoGen 5.18.16
+.\" It has been AutoGen-ed May 25, 2024 at 12:05:50 AM by AutoGen 5.18.16
 .\" From the definitions ntptrace-opts.def
 .\" and the template file agman-cmd.tpl
 .SH NAME
diff --git a/contrib/ntp/scripts/ntptrace/ntptrace.1ntptracemdoc b/contrib/ntp/scripts/ntptrace/ntptrace.1ntptracemdoc
index d42f63a644fc..0f26eb3d090f 100644
--- a/contrib/ntp/scripts/ntptrace/ntptrace.1ntptracemdoc
+++ b/contrib/ntp/scripts/ntptrace/ntptrace.1ntptracemdoc
@@ -1,9 +1,9 @@
-.Dd June 6 2023
+.Dd May 25 2024
 .Dt NTPTRACE 1ntptracemdoc User Commands
 .Os
 .\"  EDIT THIS FILE WITH CAUTION  (ntptrace-opts.mdoc)
 .\"
-.\"  It has been AutoGen-ed  June  6, 2023 at 04:39:25 AM by AutoGen 5.18.16
+.\"  It has been AutoGen-ed  May 25, 2024 at 12:05:47 AM by AutoGen 5.18.16
 .\"  From the definitions    ntptrace-opts.def
 .\"  and the template file   agmdoc-cmd.tpl
 .Sh NAME
diff --git a/contrib/ntp/scripts/ntptrace/ntptrace.html b/contrib/ntp/scripts/ntptrace/ntptrace.html
index 594c9ef59cd7..f445a25c63b0 100644
--- a/contrib/ntp/scripts/ntptrace/ntptrace.html
+++ b/contrib/ntp/scripts/ntptrace/ntptrace.html
@@ -48,7 +48,7 @@ Previous: <a href="dir.html#Top" accesskey="p" rel="prev">(dir)</a>, Up: <a href
 <span id="Simple-Network-Time-Protocol-User-Manual"></span><h1 class="top">Simple Network Time Protocol User Manual</h1>
 
 <p>This document describes the use of the NTP Project&rsquo;s <code>ntptrace</code> program.
-This document applies to version 4.2.8p17 of <code>ntptrace</code>.
+This document applies to version 4.2.8p18 of <code>ntptrace</code>.
 </p>
 <span id="SEC_Overview"></span>
 <h2 class="shortcontents-heading">Short Table of Contents</h2>
@@ -135,7 +135,7 @@ used to select the program, defaulting to <samp>more</samp>.  Both will exit
 with a status code of 0.
 </p>
 <div class="example">
-<pre class="example">ntptrace - Trace peers of an NTP server - Ver. 4.2.8p17
+<pre class="example">ntptrace - Trace peers of an NTP server - Ver. 4.2.8p18
 USAGE: ntptrace [ -&lt;flag&gt; [&lt;val&gt;] | --&lt;name&gt;[{=| }&lt;val&gt;] ]... [host]
 
     -n, --numeric                Print IP addresses instead of hostnames
diff --git a/contrib/ntp/scripts/ntptrace/ntptrace.in b/contrib/ntp/scripts/ntptrace/ntptrace.in
index 7cc5ce7f7224..d92e0796391d 100755
--- a/contrib/ntp/scripts/ntptrace/ntptrace.in
+++ b/contrib/ntp/scripts/ntptrace/ntptrace.in
@@ -1,4 +1,5 @@
 #! @PATH_PERL@ -w
+# @configure_input@
 # John Hay -- John.Hay@icomtek.csir.co.za / jhay@FreeBSD.org
 
 package ntptrace;
@@ -6,6 +7,7 @@ use 5.006_000;
 use strict;
 use lib "@PERLLIBDIR@";
 use NTP::Util qw(ntp_read_vars do_dns);
+use Scalar::Util qw(looks_like_number);
 
 exit run(@ARGV) unless caller;
 
@@ -59,7 +61,16 @@ sub get_info {
     return if not defined $info;
     return if not exists $info->{stratum};
 
+    if (not (exists $info->{offset} && looks_like_number($info->{offset}))) {
+        $info->{offset} = "NaN";
+    }
     $info->{offset} /= 1000;
+    if (not (exists $info->{rootdisp} && looks_like_number($info->{rootdisp}))) {
+        $info->{rootdisp} = "NaN";
+    }
+    if (not (exists $info->{rootdelay} && looks_like_number($info->{rootdelay}))) {
+        $info->{rootdelay} = "NaN";
+    }
     $info->{syncdistance} = ($info->{rootdisp} + ($info->{rootdelay} / 2)) / 1000;
 
     return %$info;
diff --git a/contrib/ntp/scripts/ntptrace/ntptrace.man.in b/contrib/ntp/scripts/ntptrace/ntptrace.man.in
index db4e5ab6c3aa..fe9275e63607 100644
--- a/contrib/ntp/scripts/ntptrace/ntptrace.man.in
+++ b/contrib/ntp/scripts/ntptrace/ntptrace.man.in
@@ -10,11 +10,11 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH ntptrace @NTPTRACE_MS@ "06 Jun 2023" "ntp (4.2.8p17)" "User Commands"
+.TH ntptrace @NTPTRACE_MS@ "25 May 2024" "ntp (4.2.8p18)" "User Commands"
 .\"
 .\" EDIT THIS FILE WITH CAUTION (in-mem file)
 .\"
-.\" It has been AutoGen-ed June 6, 2023 at 04:39:28 AM by AutoGen 5.18.16
+.\" It has been AutoGen-ed May 25, 2024 at 12:05:50 AM by AutoGen 5.18.16
 .\" From the definitions ntptrace-opts.def
 .\" and the template file agman-cmd.tpl
 .SH NAME
diff --git a/contrib/ntp/scripts/ntptrace/ntptrace.mdoc.in b/contrib/ntp/scripts/ntptrace/ntptrace.mdoc.in
index 1d64345f1689..53f2bb990dee 100644
--- a/contrib/ntp/scripts/ntptrace/ntptrace.mdoc.in
+++ b/contrib/ntp/scripts/ntptrace/ntptrace.mdoc.in
@@ -1,9 +1,9 @@
-.Dd June 6 2023
+.Dd May 25 2024
 .Dt NTPTRACE @NTPTRACE_MS@ User Commands
 .Os
 .\"  EDIT THIS FILE WITH CAUTION  (ntptrace-opts.mdoc)
 .\"
-.\"  It has been AutoGen-ed  June  6, 2023 at 04:39:25 AM by AutoGen 5.18.16
+.\"  It has been AutoGen-ed  May 25, 2024 at 12:05:47 AM by AutoGen 5.18.16
 .\"  From the definitions    ntptrace-opts.def
 .\"  and the template file   agmdoc-cmd.tpl
 .Sh NAME
diff --git a/contrib/ntp/scripts/ntpver.in b/contrib/ntp/scripts/ntpver.in
index 9615e66d61c6..4037e4403065 100644
--- a/contrib/ntp/scripts/ntpver.in
+++ b/contrib/ntp/scripts/ntpver.in
@@ -1,7 +1,8 @@
 #!@CONFIG_SHELL@
+# @configure_input@
 # print version string of NTP daemon
 # Copyright (c) 1997 by Ulrich Windl
 # Modified 970318: Harlan Stenn: rewritten...
 # usage: ntpver hostname
 
-ntpq -c "rv 0 daemon_version" $* | @AWK@ '/daemon_version/ { print $2 }'
+ntpq -c "rv 0 version" $* | @AWK@ '/version/ { print $2 }'
diff --git a/contrib/ntp/scripts/plot_summary-opts b/contrib/ntp/scripts/plot_summary-opts
index 10e2fdfaec7f..acf9ba865d64 100644
--- a/contrib/ntp/scripts/plot_summary-opts
+++ b/contrib/ntp/scripts/plot_summary-opts
@@ -1,6 +1,6 @@
 # EDIT THIS FILE WITH CAUTION  (plot_summary-opts)
 #
-# It has been AutoGen-ed  June  6, 2023 at 04:39:35 AM by AutoGen 5.18.16
+# It has been AutoGen-ed  May 25, 2024 at 12:05:57 AM by AutoGen 5.18.16
 # From the definitions    plot_summary-opts.def
 # and the template file   perlopt
 
@@ -46,7 +46,7 @@ sub processOptions {
         'help|?', 'more-help'));
 
     $usage = <<'USAGE';
-plot_summary - plot statistics generated by summary script - Ver. 4.2.8p17
+plot_summary - plot statistics generated by summary script - Ver. 4.2.8p18
 USAGE: plot_summary [ -<flag> [<val>] | --<name>[{=| }<val>] ]... 
 
         --directory=str          Where the summary files are
diff --git a/contrib/ntp/scripts/plot_summary.1plot_summaryman b/contrib/ntp/scripts/plot_summary.1plot_summaryman
index 14bc3202139b..952316138950 100644
--- a/contrib/ntp/scripts/plot_summary.1plot_summaryman
+++ b/contrib/ntp/scripts/plot_summary.1plot_summaryman
@@ -10,11 +10,11 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH plot_summary 1plot_summaryman "06 Jun 2023" "ntp (4.2.8p17)" "User Commands"
+.TH plot_summary 1plot_summaryman "25 May 2024" "ntp (4.2.8p18)" "User Commands"
 .\"
 .\" EDIT THIS FILE WITH CAUTION (in-mem file)
 .\"
-.\" It has been AutoGen-ed June 6, 2023 at 04:39:37 AM by AutoGen 5.18.16
+.\" It has been AutoGen-ed May 25, 2024 at 12:05:59 AM by AutoGen 5.18.16
 .\" From the definitions plot_summary-opts.def
 .\" and the template file agman-cmd.tpl
 .SH NAME
diff --git a/contrib/ntp/scripts/plot_summary.1plot_summarymdoc b/contrib/ntp/scripts/plot_summary.1plot_summarymdoc
index 338e8e5debac..a948db4e8c67 100644
--- a/contrib/ntp/scripts/plot_summary.1plot_summarymdoc
+++ b/contrib/ntp/scripts/plot_summary.1plot_summarymdoc
@@ -1,9 +1,9 @@
-.Dd June 6 2023
+.Dd May 25 2024
 .Dt PLOT_SUMMARY 1plot_summarymdoc User Commands
 .Os
 .\"  EDIT THIS FILE WITH CAUTION  (plot_summary-opts.mdoc)
 .\"
-.\"  It has been AutoGen-ed  June  6, 2023 at 04:39:38 AM by AutoGen 5.18.16
+.\"  It has been AutoGen-ed  May 25, 2024 at 12:06:00 AM by AutoGen 5.18.16
 .\"  From the definitions    plot_summary-opts.def
 .\"  and the template file   agmdoc-cmd.tpl
 .Sh NAME
diff --git a/contrib/ntp/scripts/plot_summary.html b/contrib/ntp/scripts/plot_summary.html
index fc944c708e11..fa0b4e10e24b 100644
--- a/contrib/ntp/scripts/plot_summary.html
+++ b/contrib/ntp/scripts/plot_summary.html
@@ -48,7 +48,7 @@ Previous: <a href="dir.html#Top" accesskey="p" rel="prev">(dir)</a>, Up: <a href
 <span id="Plot_005fsummary-User-Manual"></span><h1 class="top">Plot_summary User Manual</h1>
 
 <p>This document describes the use of the NTP Project&rsquo;s <code>plot_summary</code> program.
-This document applies to version 4.2.8p17 of <code>plot_summary</code>.
+This document applies to version 4.2.8p18 of <code>plot_summary</code>.
 </p>
 <span id="SEC_Overview"></span>
 <h2 class="shortcontents-heading">Short Table of Contents</h2>
@@ -116,7 +116,7 @@ used to select the program, defaulting to <samp>more</samp>.  Both will exit
 with a status code of 0.
 </p>
 <div class="example">
-<pre class="example">plot_summary - plot statistics generated by summary script - Ver. 4.2.8p17
+<pre class="example">plot_summary - plot statistics generated by summary script - Ver. 4.2.8p18
 USAGE: plot_summary [ -&lt;flag&gt; [&lt;val&gt;] | --&lt;name&gt;[{=| }&lt;val&gt;] ]... 
 
         --directory=str          Where the summary files are
diff --git a/contrib/ntp/scripts/plot_summary.in b/contrib/ntp/scripts/plot_summary.in
index 3401b0d0b8b8..f081fd1aa06d 100644
--- a/contrib/ntp/scripts/plot_summary.in
+++ b/contrib/ntp/scripts/plot_summary.in
@@ -1,4 +1,5 @@
 #! @PATH_PERL@ -w
+# @configure_input@
 # $Id$
 #
 # Use Gnuplot to display data in summary files produced by summary.pl.
diff --git a/contrib/ntp/scripts/plot_summary.man.in b/contrib/ntp/scripts/plot_summary.man.in
index 14bc3202139b..952316138950 100644
--- a/contrib/ntp/scripts/plot_summary.man.in
+++ b/contrib/ntp/scripts/plot_summary.man.in
@@ -10,11 +10,11 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH plot_summary 1plot_summaryman "06 Jun 2023" "ntp (4.2.8p17)" "User Commands"
+.TH plot_summary 1plot_summaryman "25 May 2024" "ntp (4.2.8p18)" "User Commands"
 .\"
 .\" EDIT THIS FILE WITH CAUTION (in-mem file)
 .\"
-.\" It has been AutoGen-ed June 6, 2023 at 04:39:37 AM by AutoGen 5.18.16
+.\" It has been AutoGen-ed May 25, 2024 at 12:05:59 AM by AutoGen 5.18.16
 .\" From the definitions plot_summary-opts.def
 .\" and the template file agman-cmd.tpl
 .SH NAME
diff --git a/contrib/ntp/scripts/plot_summary.mdoc.in b/contrib/ntp/scripts/plot_summary.mdoc.in
index 338e8e5debac..a948db4e8c67 100644
--- a/contrib/ntp/scripts/plot_summary.mdoc.in
+++ b/contrib/ntp/scripts/plot_summary.mdoc.in
@@ -1,9 +1,9 @@
-.Dd June 6 2023
+.Dd May 25 2024
 .Dt PLOT_SUMMARY 1plot_summarymdoc User Commands
 .Os
 .\"  EDIT THIS FILE WITH CAUTION  (plot_summary-opts.mdoc)
 .\"
-.\"  It has been AutoGen-ed  June  6, 2023 at 04:39:38 AM by AutoGen 5.18.16
+.\"  It has been AutoGen-ed  May 25, 2024 at 12:06:00 AM by AutoGen 5.18.16
 .\"  From the definitions    plot_summary-opts.def
 .\"  and the template file   agmdoc-cmd.tpl
 .Sh NAME
diff --git a/contrib/ntp/scripts/summary-opts b/contrib/ntp/scripts/summary-opts
index 4cb1515193d6..a7dfd969037a 100644
--- a/contrib/ntp/scripts/summary-opts
+++ b/contrib/ntp/scripts/summary-opts
@@ -1,6 +1,6 @@
 # EDIT THIS FILE WITH CAUTION  (summary-opts)
 #
-# It has been AutoGen-ed  June  6, 2023 at 04:39:35 AM by AutoGen 5.18.16
+# It has been AutoGen-ed  May 25, 2024 at 12:05:57 AM by AutoGen 5.18.16
 # From the definitions    summary-opts.def
 # and the template file   perlopt
 
@@ -44,7 +44,7 @@ sub processOptions {
         'help|?', 'more-help'));
 
     $usage = <<'USAGE';
-summary - compute various stastics from NTP stat files - Ver. 4.2.8p17
+summary - compute various stastics from NTP stat files - Ver. 4.2.8p18
 USAGE: summary [ -<flag> [<val>] | --<name>[{=| }<val>] ]... 
 
         --directory=str          Directory containing stat files
diff --git a/contrib/ntp/scripts/summary.1summaryman b/contrib/ntp/scripts/summary.1summaryman
index 282e7640fa3b..9e68fa41ef73 100644
--- a/contrib/ntp/scripts/summary.1summaryman
+++ b/contrib/ntp/scripts/summary.1summaryman
@@ -10,11 +10,11 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH summary 1summaryman "06 Jun 2023" "ntp (4.2.8p17)" "User Commands"
+.TH summary 1summaryman "25 May 2024" "ntp (4.2.8p18)" "User Commands"
 .\"
 .\" EDIT THIS FILE WITH CAUTION (in-mem file)
 .\"
-.\" It has been AutoGen-ed June 6, 2023 at 04:39:41 AM by AutoGen 5.18.16
+.\" It has been AutoGen-ed May 25, 2024 at 12:06:03 AM by AutoGen 5.18.16
 .\" From the definitions summary-opts.def
 .\" and the template file agman-cmd.tpl
 .SH NAME
diff --git a/contrib/ntp/scripts/summary.1summarymdoc b/contrib/ntp/scripts/summary.1summarymdoc
index 0c83fddc9219..ea74e1728906 100644
--- a/contrib/ntp/scripts/summary.1summarymdoc
+++ b/contrib/ntp/scripts/summary.1summarymdoc
@@ -1,9 +1,9 @@
-.Dd June 6 2023
+.Dd May 25 2024
 .Dt SUMMARY 1summarymdoc User Commands
 .Os
 .\"  EDIT THIS FILE WITH CAUTION  (summary-opts.mdoc)
 .\"
-.\"  It has been AutoGen-ed  June  6, 2023 at 04:39:43 AM by AutoGen 5.18.16
+.\"  It has been AutoGen-ed  May 25, 2024 at 12:06:04 AM by AutoGen 5.18.16
 .\"  From the definitions    summary-opts.def
 .\"  and the template file   agmdoc-cmd.tpl
 .Sh NAME
diff --git a/contrib/ntp/scripts/summary.html b/contrib/ntp/scripts/summary.html
index 6ce82201c38e..7fb8b6fb1d85 100644
--- a/contrib/ntp/scripts/summary.html
+++ b/contrib/ntp/scripts/summary.html
@@ -48,7 +48,7 @@ Previous: <a href="dir.html#Top" accesskey="p" rel="prev">(dir)</a>, Up: <a href
 <span id="Summary-User-Manual"></span><h1 class="top">Summary User Manual</h1>
 
 <p>This document describes the use of the NTP Project&rsquo;s <code>summary</code> program.
-This document applies to version 4.2.8p17 of <code>summary</code>.
+This document applies to version 4.2.8p18 of <code>summary</code>.
 </p>
 <span id="SEC_Overview"></span>
 <h2 class="shortcontents-heading">Short Table of Contents</h2>
@@ -116,7 +116,7 @@ used to select the program, defaulting to <samp>more</samp>.  Both will exit
 with a status code of 0.
 </p>
 <div class="example">
-<pre class="example">summary - compute various stastics from NTP stat files - Ver. 4.2.8p17
+<pre class="example">summary - compute various stastics from NTP stat files - Ver. 4.2.8p18
 USAGE: summary [ -&lt;flag&gt; [&lt;val&gt;] | --&lt;name&gt;[{=| }&lt;val&gt;] ]... 
 
         --directory=str          Directory containing stat files
diff --git a/contrib/ntp/scripts/summary.in b/contrib/ntp/scripts/summary.in
index a99f8df0e73e..7e346d80fbfa 100644
--- a/contrib/ntp/scripts/summary.in
+++ b/contrib/ntp/scripts/summary.in
@@ -1,4 +1,5 @@
 #! @PATH_PERL@ -w
+# @configure_input@
 # $Id$
 # Perl version of (summary.sh, loop.awk, peer.awk):
 # Create summaries from xntpd's loop and peer statistics.
diff --git a/contrib/ntp/scripts/summary.man.in b/contrib/ntp/scripts/summary.man.in
index 282e7640fa3b..9e68fa41ef73 100644
--- a/contrib/ntp/scripts/summary.man.in
+++ b/contrib/ntp/scripts/summary.man.in
@@ -10,11 +10,11 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH summary 1summaryman "06 Jun 2023" "ntp (4.2.8p17)" "User Commands"
+.TH summary 1summaryman "25 May 2024" "ntp (4.2.8p18)" "User Commands"
 .\"
 .\" EDIT THIS FILE WITH CAUTION (in-mem file)
 .\"
-.\" It has been AutoGen-ed June 6, 2023 at 04:39:41 AM by AutoGen 5.18.16
+.\" It has been AutoGen-ed May 25, 2024 at 12:06:03 AM by AutoGen 5.18.16
 .\" From the definitions summary-opts.def
 .\" and the template file agman-cmd.tpl
 .SH NAME
diff --git a/contrib/ntp/scripts/summary.mdoc.in b/contrib/ntp/scripts/summary.mdoc.in
index 0c83fddc9219..ea74e1728906 100644
--- a/contrib/ntp/scripts/summary.mdoc.in
+++ b/contrib/ntp/scripts/summary.mdoc.in
@@ -1,9 +1,9 @@
-.Dd June 6 2023
+.Dd May 25 2024
 .Dt SUMMARY 1summarymdoc User Commands
 .Os
 .\"  EDIT THIS FILE WITH CAUTION  (summary-opts.mdoc)
 .\"
-.\"  It has been AutoGen-ed  June  6, 2023 at 04:39:43 AM by AutoGen 5.18.16
+.\"  It has been AutoGen-ed  May 25, 2024 at 12:06:04 AM by AutoGen 5.18.16
 .\"  From the definitions    summary-opts.def
 .\"  and the template file   agmdoc-cmd.tpl
 .Sh NAME
diff --git a/contrib/ntp/scripts/update-leap/Makefile.in b/contrib/ntp/scripts/update-leap/Makefile.in
index 19f20fe16902..3d5400bcca32 100644
--- a/contrib/ntp/scripts/update-leap/Makefile.in
+++ b/contrib/ntp/scripts/update-leap/Makefile.in
@@ -364,6 +364,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_NET_SNMP_CONFIG = @PATH_NET_SNMP_CONFIG@
+PATH_OPENSSL = @PATH_OPENSSL@
 PATH_PERL = @PATH_PERL@
 PATH_RUBY = @PATH_RUBY@
 PATH_SEPARATOR = @PATH_SEPARATOR@
diff --git a/contrib/ntp/scripts/update-leap/invoke-update-leap.texi b/contrib/ntp/scripts/update-leap/invoke-update-leap.texi
index bc80b5a40936..9e1bdcbd7abb 100644
--- a/contrib/ntp/scripts/update-leap/invoke-update-leap.texi
+++ b/contrib/ntp/scripts/update-leap/invoke-update-leap.texi
@@ -6,7 +6,7 @@
 #
 # EDIT THIS FILE WITH CAUTION  (invoke-update-leap.texi)
 #
-# It has been AutoGen-ed  June  6, 2023 at 04:39:31 AM by AutoGen 5.18.16
+# It has been AutoGen-ed  May 25, 2024 at 12:05:53 AM by AutoGen 5.18.16
 # From the definitions    update-leap-opts.def
 # and the template file   agtexi-cmd.tpl
 @end ignore
diff --git a/contrib/ntp/scripts/update-leap/update-leap-opts b/contrib/ntp/scripts/update-leap/update-leap-opts
index 2aab11deb6a1..1b99167b6e8f 100644
--- a/contrib/ntp/scripts/update-leap/update-leap-opts
+++ b/contrib/ntp/scripts/update-leap/update-leap-opts
@@ -1,6 +1,6 @@
 # EDIT THIS FILE WITH CAUTION  (update-leap-opts)
 #
-# It has been AutoGen-ed  June  6, 2023 at 04:39:35 AM by AutoGen 5.18.16
+# It has been AutoGen-ed  May 25, 2024 at 12:05:57 AM by AutoGen 5.18.16
 # From the definitions    update-leap-opts.def
 # and the template file   perlopt
 
@@ -46,7 +46,7 @@ sub processOptions {
         'help|?', 'more-help'));
 
     $usage = <<'USAGE';
-update-leap - leap-seconds file manager/updater - Ver. 4.2.8p17
+update-leap - leap-seconds file manager/updater - Ver. 4.2.8p18
 USAGE: update-leap [ -<flag> [<val>] | --<name>[{=| }<val>] ]... 
 
     -s, --source-url=str         The URL of the master copy of the leapseconds file
diff --git a/contrib/ntp/scripts/update-leap/update-leap.1update-leapman b/contrib/ntp/scripts/update-leap/update-leap.1update-leapman
index 83871441e444..12e3c23d5208 100644
--- a/contrib/ntp/scripts/update-leap/update-leap.1update-leapman
+++ b/contrib/ntp/scripts/update-leap/update-leap.1update-leapman
@@ -10,11 +10,11 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH update-leap 1update-leapman "06 Jun 2023" "ntp (4.2.8p17)" "User Commands"
+.TH update-leap 1update-leapman "25 May 2024" "ntp (4.2.8p18)" "User Commands"
 .\"
 .\" EDIT THIS FILE WITH CAUTION (in-mem file)
 .\"
-.\" It has been AutoGen-ed June 6, 2023 at 04:39:33 AM by AutoGen 5.18.16
+.\" It has been AutoGen-ed May 25, 2024 at 12:05:55 AM by AutoGen 5.18.16
 .\" From the definitions update-leap-opts.def
 .\" and the template file agman-cmd.tpl
 .SH NAME
diff --git a/contrib/ntp/scripts/update-leap/update-leap.1update-leapmdoc b/contrib/ntp/scripts/update-leap/update-leap.1update-leapmdoc
index 449a0840a946..6acbe102bc51 100644
--- a/contrib/ntp/scripts/update-leap/update-leap.1update-leapmdoc
+++ b/contrib/ntp/scripts/update-leap/update-leap.1update-leapmdoc
@@ -1,9 +1,9 @@
-.Dd June 6 2023
+.Dd May 25 2024
 .Dt UPDATE_LEAP 1update-leapmdoc User Commands
 .Os
 .\"  EDIT THIS FILE WITH CAUTION  (update-leap-opts.mdoc)
 .\"
-.\"  It has been AutoGen-ed  June  6, 2023 at 04:39:30 AM by AutoGen 5.18.16
+.\"  It has been AutoGen-ed  May 25, 2024 at 12:05:51 AM by AutoGen 5.18.16
 .\"  From the definitions    update-leap-opts.def
 .\"  and the template file   agmdoc-cmd.tpl
 .Sh NAME
diff --git a/contrib/ntp/scripts/update-leap/update-leap.html b/contrib/ntp/scripts/update-leap/update-leap.html
index afdc9977d604..6040b23001f9 100644
--- a/contrib/ntp/scripts/update-leap/update-leap.html
+++ b/contrib/ntp/scripts/update-leap/update-leap.html
@@ -49,7 +49,7 @@ Previous: <a href="dir.html#Top" accesskey="p" rel="prev">(dir)</a>, Up: <a href
 
 <p>This document describes the use of the NTP Project&rsquo;s <code>update-leap</code> program.
 </p>
-<p>This document applies to version 4.2.8p17 of <code>update-leap</code>.
+<p>This document applies to version 4.2.8p18 of <code>update-leap</code>.
 </p>
 <span id="SEC_Overview"></span>
 <h2 class="shortcontents-heading">Short Table of Contents</h2>
diff --git a/contrib/ntp/scripts/update-leap/update-leap.in b/contrib/ntp/scripts/update-leap/update-leap.in
index abf1134c1ff5..defc6176b80a 100755
--- a/contrib/ntp/scripts/update-leap/update-leap.in
+++ b/contrib/ntp/scripts/update-leap/update-leap.in
@@ -1,4 +1,5 @@
 #! @PATH_PERL@ -w
+# @configure_input
 
 # Copyright (C) 2015, 2017 Network Time Foundation
 # Author: Harlan Stenn
diff --git a/contrib/ntp/scripts/update-leap/update-leap.man.in b/contrib/ntp/scripts/update-leap/update-leap.man.in
index 83871441e444..12e3c23d5208 100644
--- a/contrib/ntp/scripts/update-leap/update-leap.man.in
+++ b/contrib/ntp/scripts/update-leap/update-leap.man.in
@@ -10,11 +10,11 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH update-leap 1update-leapman "06 Jun 2023" "ntp (4.2.8p17)" "User Commands"
+.TH update-leap 1update-leapman "25 May 2024" "ntp (4.2.8p18)" "User Commands"
 .\"
 .\" EDIT THIS FILE WITH CAUTION (in-mem file)
 .\"
-.\" It has been AutoGen-ed June 6, 2023 at 04:39:33 AM by AutoGen 5.18.16
+.\" It has been AutoGen-ed May 25, 2024 at 12:05:55 AM by AutoGen 5.18.16
 .\" From the definitions update-leap-opts.def
 .\" and the template file agman-cmd.tpl
 .SH NAME
diff --git a/contrib/ntp/scripts/update-leap/update-leap.mdoc.in b/contrib/ntp/scripts/update-leap/update-leap.mdoc.in
index 449a0840a946..6acbe102bc51 100644
--- a/contrib/ntp/scripts/update-leap/update-leap.mdoc.in
+++ b/contrib/ntp/scripts/update-leap/update-leap.mdoc.in
@@ -1,9 +1,9 @@
-.Dd June 6 2023
+.Dd May 25 2024
 .Dt UPDATE_LEAP 1update-leapmdoc User Commands
 .Os
 .\"  EDIT THIS FILE WITH CAUTION  (update-leap-opts.mdoc)
 .\"
-.\"  It has been AutoGen-ed  June  6, 2023 at 04:39:30 AM by AutoGen 5.18.16
+.\"  It has been AutoGen-ed  May 25, 2024 at 12:05:51 AM by AutoGen 5.18.16
 .\"  From the definitions    update-leap-opts.def
 .\"  and the template file   agmdoc-cmd.tpl
 .Sh NAME
diff --git a/contrib/ntp/sntp/COPYRIGHT b/contrib/ntp/sntp/COPYRIGHT
index 013202c0fb09..0cb57168ebfc 100644
--- a/contrib/ntp/sntp/COPYRIGHT
+++ b/contrib/ntp/sntp/COPYRIGHT
@@ -3,7 +3,7 @@ This file is automatically generated from html/copyright.html
 
    jpg "Clone me," says Dolly sheepishly.
 
-   Last update: 2-Mar-2023 05:21 UTC
+   Last update: 7-Jan-2024 00:29 UTC
      __________________________________________________________________
 
    The following copyright notice applies to all files collectively called
@@ -32,7 +32,7 @@ This file is automatically generated from html/copyright.html
    Hart, Danny Mayer, Martin Burnicki, and possibly others is:
 ***********************************************************************
 *                                                                     *
-* Copyright (c) Network Time Foundation 2011-2023                     *
+* Copyright (c) Network Time Foundation 2011-2024                     *
 *                                                                     *
 * All Rights Reserved                                                 *
 *                                                                     *
diff --git a/contrib/ntp/sntp/Makefile.am b/contrib/ntp/sntp/Makefile.am
index 8f9d1f612534..4c4e19ed81d8 100644
--- a/contrib/ntp/sntp/Makefile.am
+++ b/contrib/ntp/sntp/Makefile.am
@@ -274,8 +274,7 @@ libevent: distdir-pre-check
 distdir-pre-check:
 	case "$(DIST_FAIL)" in	\
 	 '')  ;;		\
-	 *) $(error re-run configure adding $(DIST_FAIL) if you want to make a distribution.);	\
-	    echo "re-run configure adding $(DIST_FAIL) if you want to make a distribution.";	\
+	 *) echo "re-run configure adding $(DIST_FAIL) if you want to make a distribution.";	\
 	    exit 1 ;;		\
 	esac
 
diff --git a/contrib/ntp/sntp/Makefile.in b/contrib/ntp/sntp/Makefile.in
index 02af2211d10a..b7e7858a27f4 100644
--- a/contrib/ntp/sntp/Makefile.in
+++ b/contrib/ntp/sntp/Makefile.in
@@ -100,6 +100,7 @@ EXTRA_PROGRAMS = sntp$(EXEEXT)
 @BUILD_LIBEVENT_FALSE@am__append_2 = "--enable-local-libevent"
 @NEED_LIBOPTS_TRUE@am__append_3 = libopts
 @BUILD_SNTP_TRUE@am__append_4 = tests
+@LIBNTP_SUBMAKES_TRUE@am__append_5 = check-libntp
 subdir = .
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
@@ -110,6 +111,7 @@ am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
 	$(top_srcdir)/m4/ntp_cacheversion.m4 \
 	$(top_srcdir)/m4/ntp_compiler.m4 \
 	$(top_srcdir)/m4/ntp_crosscompile.m4 \
+	$(top_srcdir)/m4/ntp_crypto_rand.m4 \
 	$(top_srcdir)/m4/ntp_debug.m4 $(top_srcdir)/m4/ntp_dir_sep.m4 \
 	$(top_srcdir)/m4/ntp_facilitynames.m4 \
 	$(top_srcdir)/m4/ntp_harden.m4 $(top_srcdir)/m4/ntp_ipv6.m4 \
@@ -489,6 +491,7 @@ PACKAGE_STRING = @PACKAGE_STRING@
 PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_OPENSSL = @PATH_OPENSSL@
 PATH_RUBY = @PATH_RUBY@
 PATH_SEPARATOR = @PATH_SEPARATOR@
 PKG_CONFIG = @PKG_CONFIG@
@@ -660,9 +663,9 @@ EXTRA_DIST = \
 BUILT_SOURCES = $(srcdir)/COPYRIGHT libtool $(srcdir)/sntp-opts.c \
 	$(srcdir)/sntp-opts.h $(srcdir)/include/version.def \
 	$(srcdir)/m4/version.m4 $(srcdir)/include/version.texi $(NULL) \
-	check-libntp check-libopts .deps-ver
+	$(am__append_5) check-libopts .deps-ver
 CLEANFILES = check-COPYRIGHT-submake .version version.c $(NULL) \
-	check-libntp check-libopts .deps-ver
+	check-libopts .deps-ver
 man1_MANS = 
 man8_MANS = 
 man_MANS = sntp.$(SNTP_MS)
@@ -1648,8 +1651,7 @@ libevent: distdir-pre-check
 distdir-pre-check:
 	case "$(DIST_FAIL)" in	\
 	 '')  ;;		\
-	 *) $(error re-run configure adding $(DIST_FAIL) if you want to make a distribution.);	\
-	    echo "re-run configure adding $(DIST_FAIL) if you want to make a distribution.";	\
+	 *) echo "re-run configure adding $(DIST_FAIL) if you want to make a distribution.";	\
 	    exit 1 ;;		\
 	esac
 
@@ -1667,11 +1669,10 @@ install-exec-hook:
 
 #
 
-check-libntp: $(top_builddir)/../libntp/libntp.a
-	@: avoid default SCCS get by some make implementations
+.PHONY: check-libntp
 
-$(top_builddir)/../libntp/libntp.a:
-	cd $(top_builddir)/../libntp && $(MAKE) $(AM_MAKEFLAGS) libntp.a
+@LIBNTP_SUBMAKES_TRUE@check-libntp:
+@LIBNTP_SUBMAKES_TRUE@	cd $(top_builddir)/../libntp && $(MAKE) $(AM_MAKEFLAGS) libntp.a
 
 check-libopts: libopts/libopts.la
 	@echo stamp > $@
diff --git a/contrib/ntp/sntp/aclocal.m4 b/contrib/ntp/sntp/aclocal.m4
index 3bc30c477a33..e1177cd472bb 100644
--- a/contrib/ntp/sntp/aclocal.m4
+++ b/contrib/ntp/sntp/aclocal.m4
@@ -1219,6 +1219,7 @@ m4_include([m4/lt~obsolete.m4])
 m4_include([m4/ntp_cacheversion.m4])
 m4_include([m4/ntp_compiler.m4])
 m4_include([m4/ntp_crosscompile.m4])
+m4_include([m4/ntp_crypto_rand.m4])
 m4_include([m4/ntp_debug.m4])
 m4_include([m4/ntp_dir_sep.m4])
 m4_include([m4/ntp_facilitynames.m4])
diff --git a/contrib/ntp/sntp/check-libntp.mf b/contrib/ntp/sntp/check-libntp.mf
index 649f605a8d07..f27aeb66e4f7 100644
--- a/contrib/ntp/sntp/check-libntp.mf
+++ b/contrib/ntp/sntp/check-libntp.mf
@@ -4,12 +4,12 @@
 ## The above file has a version of this for the non-sntp portion
 ## of the NTP package.
 
-BUILT_SOURCES	+= check-libntp
-CLEANFILES	+= check-libntp
+.PHONY: check-libntp
 
-check-libntp: $(top_builddir)/../libntp/libntp.a
-	@: avoid default SCCS get by some make implementations
+if LIBNTP_SUBMAKES
+BUILT_SOURCES	+= check-libntp
 
-$(top_builddir)/../libntp/libntp.a:
+check-libntp:
 	cd $(top_builddir)/../libntp && $(MAKE) $(AM_MAKEFLAGS) libntp.a
 
+endif
diff --git a/contrib/ntp/sntp/check-libsntp.mf b/contrib/ntp/sntp/check-libsntp.mf
index d05a3d02fd07..297a8947a57e 100644
--- a/contrib/ntp/sntp/check-libsntp.mf
+++ b/contrib/ntp/sntp/check-libsntp.mf
@@ -3,11 +3,7 @@
 ##
 
 BUILT_SOURCES	+= check-libsntp
-CLEANFILES	+= check-libsntp
 
-check-libsntp: $(top_builddir)/sntp/libsntp.a
-	@: avoid default SCCS get by some make implementations
-
-$(top_builddir)/sntp/libsntp.a:
+.PHONY: check-libsntp
+check-libsntp:
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) libsntp.a
-
diff --git a/contrib/ntp/sntp/check-libunity.mf b/contrib/ntp/sntp/check-libunity.mf
index bf5ec3bde1ed..af394da6e504 100644
--- a/contrib/ntp/sntp/check-libunity.mf
+++ b/contrib/ntp/sntp/check-libunity.mf
@@ -8,8 +8,7 @@ BUILT_SOURCES	+= check-libunity
 CLEANFILES	+= check-libunity
 
 check-libunity: $(top_builddir)/unity/libunity.a
-	 @: avoid default SCCS get by some make implementations
+	@echo stamp > $@
 
 $(top_builddir)/unity/libunity.a:
 	cd $(top_builddir)/unity && $(MAKE) $(AM_MAKEFLAGS) libunity.a
-
diff --git a/contrib/ntp/sntp/config.h.in b/contrib/ntp/sntp/config.h.in
index a4a15b82fcf1..d1cd7070a106 100644
--- a/contrib/ntp/sntp/config.h.in
+++ b/contrib/ntp/sntp/config.h.in
@@ -18,6 +18,9 @@
 /* number of args to el_init() */
 #undef EL_INIT_ARGS
 
+/* Enable CMAC support? */
+#undef ENABLE_CMAC
+
 /* nls support in libopts */
 #undef ENABLE_NLS
 
@@ -131,9 +134,6 @@
 /* Define to 1 if the system has the type `int32'. */
 #undef HAVE_INT32
 
-/* int32 type in DNS headers, not others. */
-#undef HAVE_INT32_ONLY_WITH_DNS
-
 /* Define to 1 if the system has the type `int32_t'. */
 #undef HAVE_INT32_T
 
@@ -260,9 +260,6 @@
 /* Define to 1 if you have the <openssl/cmac.h> header file. */
 #undef HAVE_OPENSSL_CMAC_H
 
-/* Define to 1 if you have the <openssl/hmac.h> header file. */
-#undef HAVE_OPENSSL_HMAC_H
-
 /* Define this if pathfind(3) works */
 #undef HAVE_PATHFIND
 
@@ -314,6 +311,12 @@
 /* Define to 1 if the system has the type `ptrdiff_t'. */
 #undef HAVE_PTRDIFF_T
 
+/* Define to 1 if you have the `RAND_bytes' function. */
+#undef HAVE_RAND_BYTES
+
+/* Define to 1 if you have the `RAND_poll' function. */
+#undef HAVE_RAND_POLL
+
 /* Define to 1 if you have the <readline.h> header file. */
 #undef HAVE_READLINE_H
 
@@ -464,7 +467,7 @@
 /* Define to 1 if you have the <sysexits.h> header file. */
 #undef HAVE_SYSEXITS_H
 
-/* */
+/* syslog.h provides facilitynames */
 #undef HAVE_SYSLOG_FACILITYNAMES
 
 /* Define to 1 if you have the <syslog.h> header file. */
@@ -601,9 +604,6 @@
 /* Define to 1 if the system has the type `u_int32'. */
 #undef HAVE_U_INT32
 
-/* u_int32 type in DNS headers, not others. */
-#undef HAVE_U_INT32_ONLY_WITH_DNS
-
 /* Define to 1 if you have the <values.h> header file. */
 #undef HAVE_VALUES_H
 
@@ -754,6 +754,9 @@
 /* Use OpenSSL? */
 #undef OPENSSL
 
+/* Suppress OpenSSL 3 deprecation warnings */
+#undef OPENSSL_SUPPRESS_DEPRECATED
+
 /* Name of package */
 #undef PACKAGE
 
@@ -839,10 +842,6 @@
 /* enable thread safety */
 #undef THREAD_SAFE
 
-/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. This
-   macro is obsolete. */
-#undef TIME_WITH_SYS_TIME
-
 /* Provide a typedef for uintptr_t? */
 #ifndef HAVE_UINTPTR_T
 typedef unsigned int	uintptr_t;
@@ -852,6 +851,9 @@ typedef unsigned int	uintptr_t;
 /* What type to use for setsockopt */
 #undef TYPEOF_IP_MULTICAST_LOOP
 
+/* Use OpenSSL's crypto random functions */
+#undef USE_OPENSSL_CRYPTO_RAND
+
 /* OK to use snprintb()? */
 #undef USE_SNPRINTB
 
@@ -1016,15 +1018,8 @@ typedef unsigned int	uintptr_t;
 /* Define to `unsigned int' if <sys/types.h> does not define. */
 #undef size_t
 
-	
-	    #if !defined(_KERNEL) && !defined(PARSESTREAM)
-	    /*
-	     * stdio.h must be included after _GNU_SOURCE is defined
-	     * but before #define snprintf rpl_snprintf
-	     */
-	    # include <stdio.h>	
-	    #endif
-	
+	#include "c99_snprintf.h"
+    
 
 /* Define to rpl_snprintf if the replacement function should be used. */
 #undef snprintf
diff --git a/contrib/ntp/sntp/configure b/contrib/ntp/sntp/configure
index b435871daf0e..c39a17dcad27 100755
--- a/contrib/ntp/sntp/configure
+++ b/contrib/ntp/sntp/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.71 for sntp 4.2.8p17.
+# Generated by GNU Autoconf 2.71 for sntp 4.2.8p18.
 #
 # Report bugs to <https://bugs.ntp.org/>.
 #
@@ -621,8 +621,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='sntp'
 PACKAGE_TARNAME='sntp'
-PACKAGE_VERSION='4.2.8p17'
-PACKAGE_STRING='sntp 4.2.8p17'
+PACKAGE_VERSION='4.2.8p18'
+PACKAGE_STRING='sntp 4.2.8p18'
 PACKAGE_BUGREPORT='https://bugs.ntp.org/'
 PACKAGE_URL='https://www.ntp.org/'
 
@@ -670,7 +670,6 @@ BUILD_TEST_KODDATABASE_TRUE
 UNITYBUILD_AVAILABLE_FALSE
 UNITYBUILD_AVAILABLE_TRUE
 PATH_RUBY
-VER_SUFFIX
 LIB_SYSLOG
 subdirs
 BUILD_LIBEVENT_FALSE
@@ -678,7 +677,6 @@ BUILD_LIBEVENT_TRUE
 LDADD_LIBEVENT
 CPPFLAGS_LIBEVENT
 CFLAGS_LIBEVENT
-PKG_CONFIG
 NTP_FORCE_LIBEVENT_DIST
 LIBOPTS_DIR
 LIBOPTS_CFLAGS
@@ -710,6 +708,11 @@ NM
 ac_ct_DUMPBIN
 DUMPBIN
 LIBTOOL
+PATH_OPENSSL
+VER_SUFFIX
+PKG_CONFIG
+LIBNTP_SUBMAKES_FALSE
+LIBNTP_SUBMAKES_TRUE
 LIBOBJS
 PTHREADS_FALSE
 PTHREADS_TRUE
@@ -724,10 +727,12 @@ LIBM
 EDITLINE_LIBS
 LD
 FGREP
-SED
+EGREP
+GREP
 LDADD_LIBNTP
 NTP_CROSSCOMPILE_FALSE
 NTP_CROSSCOMPILE_TRUE
+SED
 ac_ct_AR
 AR
 INSTALL_UPDATE_LEAP_FALSE
@@ -820,14 +825,12 @@ WANT_CALC_TICKADJ_MS_TRUE
 NTP_HARD_LDFLAGS
 NTP_HARD_CPPFLAGS
 NTP_HARD_CFLAGS
+CPP
 LDFLAGS_NTP
 LDADD_NTP
 CPPFLAGS_NTP
 CFLAGS_NTP
 CC_NOFORMAT
-EGREP
-GREP
-CPP
 am__fastdepCC_FALSE
 am__fastdepCC_TRUE
 CCDEPMODE
@@ -941,6 +944,11 @@ enable_linuxcaps
 enable_solarisprivs
 enable_trustedbsd_mac
 enable_signalled_io
+with_crypto
+with_openssl_libdir
+with_openssl_incdir
+enable_verbose_ssl
+enable_openssl_random
 enable_shared
 enable_static
 with_pic
@@ -959,10 +967,6 @@ with_libregex_cflags
 with_libregex_libs
 enable_optional_args
 enable_local_libevent
-with_crypto
-with_openssl_libdir
-with_openssl_incdir
-with_rpath
 enable_ipv6
 with_kame
 enable_getifaddrs
@@ -1526,7 +1530,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures sntp 4.2.8p17 to adapt to many kinds of systems.
+\`configure' configures sntp 4.2.8p18 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1597,7 +1601,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of sntp 4.2.8p17:";;
+     short | recursive ) echo "Configuration of sntp 4.2.8p18:";;
    esac
   cat <<\_ACEOF
 
@@ -1614,13 +1618,15 @@ Optional Features:
   defaults:               + yes, - no, s system-specific
   --enable-debugging      + include ntpd debugging code
   --enable-thread-support s use threads (+ if available)
-  --enable-c99-snprintf   s force replacement
+  --enable-c99-snprintf   s use replacement printf family
   --enable-clockctl       s Use /dev/clockctl for non-root clock control
   --enable-linuxcaps      + Use Linux capabilities for non-root clock control
   --enable-solarisprivs   + Use Solaris privileges for non-root clock control
   --enable-trustedbsd-mac s Use TrustedBSD MAC policy for non-root clock
                           control
   --enable-signalled-io   s Use signalled IO if we can
+  --enable-verbose-ssl    - show crypto lib detection details
+  --enable-openssl-random + Use SSL lib's secure random numbers
   --enable-shared[=PKGS]  build shared libraries [default=no]
   --enable-static[=PKGS]  build static libraries [default=yes]
   --enable-fast-install[=PKGS]
@@ -1646,6 +1652,11 @@ Optional Packages:
   --with-lineeditlibs     edit,editline (readline may be specified if desired)
   --with-threads	  with threads [auto]
   --with-yielding-select  with yielding select [auto]
+  --with-crypto           + =openssl,libcrypto
+  --with-openssl-libdir   + =/something/reasonable
+
+  --with-openssl-incdir   + =search likely dirs
+
   --with-pic[=PKGS]       try to use only PIC/non-PIC objects [default=use
                           both]
   --with-aix-soname=aix|svr4|both
@@ -1659,14 +1670,6 @@ Optional Packages:
   --with-libregex         libregex installation prefix
   --with-libregex-cflags  libregex compile flags
   --with-libregex-libs    libregex link command arguments
-  --with-crypto           + =openssl,libcrypto
-
-  --with-openssl-libdir   + =/something/reasonable
-
-  --with-openssl-incdir   + =/something/reasonable
-
-  --without-rpath         s Disable auto-added -R linker paths
-
   --with-kame             - =/usr/local/v6
 
 Some influential environment variables:
@@ -1749,7 +1752,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-sntp configure 4.2.8p17
+sntp configure 4.2.8p18
 generated by GNU Autoconf 2.71
 
 Copyright (C) 2021 Free Software Foundation, Inc.
@@ -1835,44 +1838,6 @@ printf "%s\n" "$ac_res" >&6; }
 
 } # ac_fn_c_check_header_compile
 
-# ac_fn_c_try_cpp LINENO
-# ----------------------
-# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
-ac_fn_c_try_cpp ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  if { { ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-printf "%s\n" "$ac_try_echo"; } >&5
-  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    grep -v '^ *+' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-    mv -f conftest.er1 conftest.err
-  fi
-  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } > conftest.i && {
-	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       }
-then :
-  ac_retval=0
-else $as_nop
-  printf "%s\n" "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-    ac_retval=1
-fi
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-  as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_cpp
-
 # ac_fn_c_try_link LINENO
 # -----------------------
 # Try to link conftest.$ac_ext, and return whether this succeeded.
@@ -1963,6 +1928,44 @@ fi
 
 } # ac_fn_c_try_run
 
+# ac_fn_c_try_cpp LINENO
+# ----------------------
+# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_cpp ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { { ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+printf "%s\n" "$ac_try_echo"; } >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } > conftest.i && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }
+then :
+  ac_retval=0
+else $as_nop
+  printf "%s\n" "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+    ac_retval=1
+fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_cpp
+
 # ac_fn_c_check_type LINENO TYPE VAR INCLUDES
 # -------------------------------------------
 # Tests whether TYPE exists after having included INCLUDES, setting cache
@@ -2406,7 +2409,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by sntp $as_me 4.2.8p17, which was
+It was created by sntp $as_me 4.2.8p18, which was
 generated by GNU Autoconf 2.71.  Invocation command line was
 
   $ $0$ac_configure_args_raw
@@ -2999,7 +3002,6 @@ as_fn_append ac_header_c_list " minix/config.h minix_config_h HAVE_MINIX_CONFIG_
 as_fn_append ac_header_c_list " vfork.h vfork_h HAVE_VFORK_H"
 as_fn_append ac_func_c_list " fork HAVE_FORK"
 as_fn_append ac_func_c_list " vfork HAVE_VFORK"
-as_fn_append ac_header_c_list " sys/time.h sys_time_h HAVE_SYS_TIME_H"
 as_fn_append ac_header_c_list " stdarg.h stdarg_h HAVE_STDARG_H"
 as_fn_append ac_func_c_list " vprintf HAVE_VPRINTF"
 
@@ -3198,7 +3200,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 # the date YYYYMMDD optionally with -HHMM if there is more than one
 # bump in a day.
 
-sntp_configure_cache_version=20120806
+sntp_configure_cache_version=20240218
 
 # When the version of config.cache and configure do not
 # match, NTP_CACHEVERSION will flush the cache.
@@ -3817,7 +3819,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='sntp'
- VERSION='4.2.8p17'
+ VERSION='4.2.8p18'
 
 
 printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h
@@ -4993,6 +4995,7 @@ fi
 
 
 
+
 ac_header= ac_cache=
 for ac_item in $ac_header_c_list
 do
@@ -5164,551 +5167,256 @@ then :
 fi
 
 
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
-printf %s "checking how to run the C preprocessor... " >&6; }
-# On Suns, sometimes $CPP names a directory.
-if test -n "$CPP" && test -d "$CPP"; then
-  CPP=
-fi
-if test -z "$CPP"; then
-  if test ${ac_cv_prog_CPP+y}
+
+
+
+
+CC_NOFORMAT=
+CFLAGS_NTP=
+CPPFLAGS_NTP=
+LDADD_NTP=
+LDFLAGS_NTP=
+
+
+
+
+
+
+case "$ac_cv_prog_cc_c89" in
+ no)
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: ANSI C89/ISO C90 is the minimum to compile NTP
+		 version 4.2.5 and higher." >&5
+printf "%s\n" "$as_me: WARNING: ANSI C89/ISO C90 is the minimum to compile NTP
+		 version 4.2.5 and higher." >&2;}
+    ;;
+esac
+
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC can handle #warning" >&5
+printf %s "checking if $CC can handle #warning... " >&6; }
+if test ${ntp_cv_cpp_warning+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-      # Double quotes because $CC needs to be expanded
-    for CPP in "$CC -E" "$CC -E -traditional-cpp" cpp /lib/cpp
-    do
-      ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
-  # Use a header file that comes with gcc, so configuring glibc
-  # with a fresh cross-compiler works.
-  # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp. "Syntax error" is here to catch this case.
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-#include <limits.h>
-		     Syntax error
+
+int
+main (void)
+{
+#warning foo
+  ;
+  return 0;
+}
 _ACEOF
-if ac_fn_c_try_cpp "$LINENO"
+if ac_fn_c_try_compile "$LINENO"
 then :
-
+  ntp_cv_cpp_warning=yes
 else $as_nop
-  # Broken: fails on valid input.
-continue
+  ntp_cv_cpp_warning=no
+
 fi
-rm -f conftest.err conftest.i conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 
-  # OK, works on sane cases.  Now check whether nonexistent headers
-  # can be detected and how.
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_cpp_warning" >&5
+printf "%s\n" "$ntp_cv_cpp_warning" >&6; }
+case "$ntp_cv_cpp_warning" in
+ no)
+
+printf "%s\n" "#define NO_OPTION_NAME_WARNINGS 1" >>confdefs.h
+
+esac
+
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC supports __attribute__((...))" >&5
+printf %s "checking if $CC supports __attribute__((...))... " >&6; }
+if test ${ntp_cv_cc_attribute+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-#include <ac_nonexistent.h>
+
+int
+main (void)
+{
+void foo(void) __attribute__((__noreturn__));
+
+  ;
+  return 0;
+}
 _ACEOF
-if ac_fn_c_try_cpp "$LINENO"
+if ac_fn_c_try_compile "$LINENO"
 then :
-  # Broken: success on invalid input.
-continue
+  ntp_cv_cc_attribute=yes
 else $as_nop
-  # Passes both tests.
-ac_preproc_ok=:
-break
+  ntp_cv_cc_attribute=no
+
 fi
-rm -f conftest.err conftest.i conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.i conftest.err conftest.$ac_ext
-if $ac_preproc_ok
-then :
-  break
 fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_cc_attribute" >&5
+printf "%s\n" "$ntp_cv_cc_attribute" >&6; }
+case "$ntp_cv_cc_attribute" in
+ yes)
 
-    done
-    ac_cv_prog_CPP=$CPP
+printf "%s\n" "#define HAVE___ATTRIBUTE__ /**/" >>confdefs.h
 
-fi
-  CPP=$ac_cv_prog_CPP
-else
-  ac_cv_prog_CPP=$CPP
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
-printf "%s\n" "$CPP" >&6; }
-ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
-  # Use a header file that comes with gcc, so configuring glibc
-  # with a fresh cross-compiler works.
-  # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp. "Syntax error" is here to catch this case.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <limits.h>
-		     Syntax error
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"
-then :
+esac
 
-else $as_nop
-  # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
 
-  # OK, works on sane cases.  Now check whether nonexistent headers
-  # can be detected and how.
+case "$GCC" in
+ yes)
+    SAVED_CFLAGS="$CFLAGS"
+    CFLAGS="$SAVED_CFLAGS -Wstrict-overflow"
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC can handle -Wstrict-overflow" >&5
+printf %s "checking if $CC can handle -Wstrict-overflow... " >&6; }
+if test ${ntp_cv_gcc_Wstrict_overflow+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-#include <ac_nonexistent.h>
+
+int
+main (void)
+{
+
+  ;
+  return 0;
+}
 _ACEOF
-if ac_fn_c_try_cpp "$LINENO"
+if ac_fn_c_try_compile "$LINENO"
 then :
-  # Broken: success on invalid input.
-continue
+  ntp_cv_gcc_Wstrict_overflow=yes
 else $as_nop
-  # Passes both tests.
-ac_preproc_ok=:
-break
+  ntp_cv_gcc_Wstrict_overflow=no
+
 fi
-rm -f conftest.err conftest.i conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.i conftest.err conftest.$ac_ext
-if $ac_preproc_ok
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_gcc_Wstrict_overflow" >&5
+printf "%s\n" "$ntp_cv_gcc_Wstrict_overflow" >&6; }
+    #
+    # $ntp_cv_gcc_Wstrict_overflow is tested later to add the
+    # flag to CFLAGS.
+    #
+    CFLAGS="$SAVED_CFLAGS -Winit-self"
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC can handle -Winit-self" >&5
+printf %s "checking if $CC can handle -Winit-self... " >&6; }
+if test ${ntp_cv_gcc_Winit_self+y}
 then :
-
+  printf %s "(cached) " >&6
 else $as_nop
-  { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details" "$LINENO" 5; }
-fi
 
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
+	    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
+int
+main (void)
+{
 
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
-printf %s "checking for grep that handles long lines and -e... " >&6; }
-if test ${ac_cv_path_GREP+y}
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
 then :
-  printf %s "(cached) " >&6
+  ntp_cv_gcc_Winit_self=yes
 else $as_nop
-  if test -z "$GREP"; then
-  ac_path_GREP_found=false
-  # Loop through the user's path and test for each of PROGNAME-LIST
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
-do
-  IFS=$as_save_IFS
-  case $as_dir in #(((
-    '') as_dir=./ ;;
-    */) ;;
-    *) as_dir=$as_dir/ ;;
-  esac
-    for ac_prog in grep ggrep
-   do
-    for ac_exec_ext in '' $ac_executable_extensions; do
-      ac_path_GREP="$as_dir$ac_prog$ac_exec_ext"
-      as_fn_executable_p "$ac_path_GREP" || continue
-# Check for GNU ac_path_GREP and select it if it is found.
-  # Check for GNU $ac_path_GREP
-case `"$ac_path_GREP" --version 2>&1` in
-*GNU*)
-  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
-*)
-  ac_count=0
-  printf %s 0123456789 >"conftest.in"
-  while :
-  do
-    cat "conftest.in" "conftest.in" >"conftest.tmp"
-    mv "conftest.tmp" "conftest.in"
-    cp "conftest.in" "conftest.nl"
-    printf "%s\n" 'GREP' >> "conftest.nl"
-    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
-    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
-    as_fn_arith $ac_count + 1 && ac_count=$as_val
-    if test $ac_count -gt ${ac_path_GREP_max-0}; then
-      # Best one so far, save it but keep looking for a better one
-      ac_cv_path_GREP="$ac_path_GREP"
-      ac_path_GREP_max=$ac_count
-    fi
-    # 10*(2^10) chars as input seems more than enough
-    test $ac_count -gt 10 && break
-  done
-  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
-esac
-
-      $ac_path_GREP_found && break 3
-    done
-  done
-  done
-IFS=$as_save_IFS
-  if test -z "$ac_cv_path_GREP"; then
-    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
-  fi
-else
-  ac_cv_path_GREP=$GREP
-fi
+  ntp_cv_gcc_Winit_self=no
 
 fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
-printf "%s\n" "$ac_cv_path_GREP" >&6; }
- GREP="$ac_cv_path_GREP"
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 
 
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
-printf %s "checking for egrep... " >&6; }
-if test ${ac_cv_path_EGREP+y}
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_gcc_Winit_self" >&5
+printf "%s\n" "$ntp_cv_gcc_Winit_self" >&6; }
+    #
+    # $ntp_cv_gcc_Winit_self is tested later to add the
+    # flag to CFLAGS_NTP.
+    #
+    # libopts specifically builds a string with embedded NULs.
+    # This causes a bunch of distracting warnings due to -Wformat.
+    #
+    CFLAGS="$SAVED_CFLAGS -Wno-format -Wno-format-security"
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC can handle -Wno-format -Wno-format-security" >&5
+printf %s "checking if $CC can handle -Wno-format -Wno-format-security... " >&6; }
+if test ${ntp_cv_gcc_Wno_format+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
-   then ac_cv_path_EGREP="$GREP -E"
-   else
-     if test -z "$EGREP"; then
-  ac_path_EGREP_found=false
-  # Loop through the user's path and test for each of PROGNAME-LIST
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
-do
-  IFS=$as_save_IFS
-  case $as_dir in #(((
-    '') as_dir=./ ;;
-    */) ;;
-    *) as_dir=$as_dir/ ;;
-  esac
-    for ac_prog in egrep
-   do
-    for ac_exec_ext in '' $ac_executable_extensions; do
-      ac_path_EGREP="$as_dir$ac_prog$ac_exec_ext"
-      as_fn_executable_p "$ac_path_EGREP" || continue
-# Check for GNU ac_path_EGREP and select it if it is found.
-  # Check for GNU $ac_path_EGREP
-case `"$ac_path_EGREP" --version 2>&1` in
-*GNU*)
-  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
-*)
-  ac_count=0
-  printf %s 0123456789 >"conftest.in"
-  while :
-  do
-    cat "conftest.in" "conftest.in" >"conftest.tmp"
-    mv "conftest.tmp" "conftest.in"
-    cp "conftest.in" "conftest.nl"
-    printf "%s\n" 'EGREP' >> "conftest.nl"
-    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
-    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
-    as_fn_arith $ac_count + 1 && ac_count=$as_val
-    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
-      # Best one so far, save it but keep looking for a better one
-      ac_cv_path_EGREP="$ac_path_EGREP"
-      ac_path_EGREP_max=$ac_count
-    fi
-    # 10*(2^10) chars as input seems more than enough
-    test $ac_count -gt 10 && break
-  done
-  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
-esac
-
-      $ac_path_EGREP_found && break 3
-    done
-  done
-  done
-IFS=$as_save_IFS
-  if test -z "$ac_cv_path_EGREP"; then
-    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
-  fi
-else
-  ac_cv_path_EGREP=$EGREP
-fi
-
-   fi
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
-printf "%s\n" "$ac_cv_path_EGREP" >&6; }
- EGREP="$ac_cv_path_EGREP"
-
-
 
+	    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
+int
+main (void)
+{
 
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+  ntp_cv_gcc_Wno_format=yes
+else $as_nop
+  ntp_cv_gcc_Wno_format=no
 
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 
-# Ralf Wildenhues: With per-target flags we need CC_C_O
-# AM_PROG_CC_C_O supersets AC_PROG_CC_C_O
 
-if test $ac_cv_c_compiler_gnu = yes; then
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC needs -traditional" >&5
-printf %s "checking whether $CC needs -traditional... " >&6; }
-if test ${ac_cv_prog_gcc_traditional+y}
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_gcc_Wno_format" >&5
+printf "%s\n" "$ntp_cv_gcc_Wno_format" >&6; }
+    case "$ntp_cv_gcc_Wno_format" in
+      no) ntp_cv_gcc_Wno_format_truncation=no
+	  ;;
+     yes)
+	CC_NOFORMAT="-Wno-format -Wno-format-security"
+	CFLAGS="$SAVED_CFLAGS -Wformat -Wno-format-truncation -Werror"
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC can handle -Wformat -Wno-format-truncation" >&5
+printf %s "checking if $CC can handle -Wformat -Wno-format-truncation... " >&6; }
+if test ${ntp_cv_gcc_Wno_format_truncation+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-    ac_pattern="Autoconf.*'x'"
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-#include <sgtty.h>
-Autoconf TIOCGETP
+
+int
+main (void)
+{
+
+  ;
+  return 0;
+}
 _ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "$ac_pattern" >/dev/null 2>&1
+if ac_fn_c_try_compile "$LINENO"
 then :
-  ac_cv_prog_gcc_traditional=yes
+  ntp_cv_gcc_Wno_format_truncation=yes
 else $as_nop
-  ac_cv_prog_gcc_traditional=no
+  ntp_cv_gcc_Wno_format_truncation=no
+
 fi
-rm -rf conftest*
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 
-
-  if test $ac_cv_prog_gcc_traditional = no; then
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <termio.h>
-Autoconf TCGETA
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "$ac_pattern" >/dev/null 2>&1
-then :
-  ac_cv_prog_gcc_traditional=yes
-fi
-rm -rf conftest*
-
-  fi
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_gcc_traditional" >&5
-printf "%s\n" "$ac_cv_prog_gcc_traditional" >&6; }
-  if test $ac_cv_prog_gcc_traditional = yes; then
-    CC="$CC -traditional"
-  fi
-fi
-
-
-
-CC_NOFORMAT=
-CFLAGS_NTP=
-CPPFLAGS_NTP=
-LDADD_NTP=
-LDFLAGS_NTP=
-
-
-
-
-
-
-case "$ac_cv_prog_cc_c89" in
- no)
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: ANSI C89/ISO C90 is the minimum to compile NTP
-		 version 4.2.5 and higher." >&5
-printf "%s\n" "$as_me: WARNING: ANSI C89/ISO C90 is the minimum to compile NTP
-		 version 4.2.5 and higher." >&2;}
-    ;;
-esac
-
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC can handle #warning" >&5
-printf %s "checking if $CC can handle #warning... " >&6; }
-if test ${ntp_cv_cpp_warning+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main (void)
-{
-#warning foo
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"
-then :
-  ntp_cv_cpp_warning=yes
-else $as_nop
-  ntp_cv_cpp_warning=no
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
-
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_cpp_warning" >&5
-printf "%s\n" "$ntp_cv_cpp_warning" >&6; }
-case "$ntp_cv_cpp_warning" in
- no)
-
-printf "%s\n" "#define NO_OPTION_NAME_WARNINGS 1" >>confdefs.h
-
-esac
-
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC supports __attribute__((...))" >&5
-printf %s "checking if $CC supports __attribute__((...))... " >&6; }
-if test ${ntp_cv_cc_attribute+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main (void)
-{
-void foo(void) __attribute__((__noreturn__));
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"
-then :
-  ntp_cv_cc_attribute=yes
-else $as_nop
-  ntp_cv_cc_attribute=no
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
-
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_cc_attribute" >&5
-printf "%s\n" "$ntp_cv_cc_attribute" >&6; }
-case "$ntp_cv_cc_attribute" in
- yes)
-
-printf "%s\n" "#define HAVE___ATTRIBUTE__ /**/" >>confdefs.h
-
-esac
-
-
-case "$GCC" in
- yes)
-    SAVED_CFLAGS="$CFLAGS"
-    CFLAGS="$SAVED_CFLAGS -Wstrict-overflow"
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC can handle -Wstrict-overflow" >&5
-printf %s "checking if $CC can handle -Wstrict-overflow... " >&6; }
-if test ${ntp_cv_gcc_Wstrict_overflow+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main (void)
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"
-then :
-  ntp_cv_gcc_Wstrict_overflow=yes
-else $as_nop
-  ntp_cv_gcc_Wstrict_overflow=no
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
-
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_gcc_Wstrict_overflow" >&5
-printf "%s\n" "$ntp_cv_gcc_Wstrict_overflow" >&6; }
-    #
-    # $ntp_cv_gcc_Wstrict_overflow is tested later to add the
-    # flag to CFLAGS.
-    #
-    CFLAGS="$SAVED_CFLAGS -Winit-self"
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC can handle -Winit-self" >&5
-printf %s "checking if $CC can handle -Winit-self... " >&6; }
-if test ${ntp_cv_gcc_Winit_self+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-
-	    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main (void)
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"
-then :
-  ntp_cv_gcc_Winit_self=yes
-else $as_nop
-  ntp_cv_gcc_Winit_self=no
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
-
-
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_gcc_Winit_self" >&5
-printf "%s\n" "$ntp_cv_gcc_Winit_self" >&6; }
-    #
-    # libopts specifically builds a string with embedded NULs.
-    # This causes a bunch of distracting warnings due to -Wformat.
-    # Let's see if we can figure out how to disable these.
-    #
-    CFLAGS="$SAVED_CFLAGS -Wno-format"
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC can handle -Wno-format" >&5
-printf %s "checking if $CC can handle -Wno-format... " >&6; }
-if test ${ntp_cv_gcc_Wno_format+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-
-	    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main (void)
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"
-then :
-  ntp_cv_gcc_Wno_format=yes
-else $as_nop
-  ntp_cv_gcc_Wno_format=no
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
-
-
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_gcc_Wno_format" >&5
-printf "%s\n" "$ntp_cv_gcc_Wno_format" >&6; }
-
-    case "$ntp_cv_gcc_Wno_format" in
-     yes)
-	CC_NOFORMAT="$CC_NOFORMAT -Wno-format"
-	;;
-     no)
-	;;
-    esac
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_gcc_Wno_format_truncation" >&5
+printf "%s\n" "$ntp_cv_gcc_Wno_format_truncation" >&6; }
+	#
+	# $ntp_cv_gcc_Wno_format_truncation is tested later to add the
+	# flag to CFLAGS.
+	#
+    esac
 
     CFLAGS="$SAVED_CFLAGS"
     { SAVED_CFLAGS=; unset SAVED_CFLAGS;}
-    #
-    # $ntp_cv_gcc_Winit_self is tested later to add the
-    # flag to CFLAGS_NTP.
-    #
+
     { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if linker supports omitting unused code and data" >&5
 printf %s "checking if linker supports omitting unused code and data... " >&6; }
 if test ${ntp_cv_gc_sections_runs+y}
@@ -5716,7 +5424,17 @@ then :
   printf %s "(cached) " >&6
 else $as_nop
 
-	    	    	    	    	    	    	    	    	    	    	    origCFLAGS="$CFLAGS"
+	    #  NetBSD will link but likely not run with --gc-sections
+	    #  http://bugs.ntp.org/1844
+	    #  http://gnats.netbsd.org/40401
+	    #  --gc-sections causes attempt to load as linux elf, with
+	    #  wrong syscalls in place.  Test a little gauntlet of
+	    #  simple stdio read code checking for errors, expecting
+	    #  enough syscall differences that the NetBSD code will
+	    #  fail even with Linux emulation working as designed.
+	    #  A shorter test could be refined by someone with access
+	    #  to a NetBSD host with Linux emulation working.
+	    origCFLAGS="$CFLAGS"
 	    CFLAGS="$CFLAGS -Wl,--gc-sections"
 	    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
@@ -5806,6 +5524,10 @@ printf "%s\n" "$ntp_cv_gc_sections_runs" >&6; }
      yes)
 	CFLAGS_NTP="$CFLAGS_NTP -Wstrict-overflow"
     esac
+    case "$ntp_cv_gcc_Wno_format_truncation" in
+     yes)
+	CFLAGS_NTP="$CFLAGS_NTP -Wno-format-truncation"
+    esac
     # -W[no-]strict-prototypes might be added by NTP_OPENSSL
 esac
 
@@ -6734,19 +6456,6 @@ unknown)
 esac
 
 
-
-
-# Expose a cross-compilation indicator to makefiles
- if test $build != $host; then
-  NTP_CROSSCOMPILE_TRUE=
-  NTP_CROSSCOMPILE_FALSE='#'
-else
-  NTP_CROSSCOMPILE_TRUE='#'
-  NTP_CROSSCOMPILE_FALSE=
-fi
-
-
-
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5
 printf %s "checking for a sed that does not truncate output... " >&6; }
 if test ${ac_cv_path_SED+y}
@@ -6822,21 +6531,251 @@ printf "%s\n" "$ac_cv_path_SED" >&6; }
  SED="$ac_cv_path_SED"
   rm -f conftest.sed
 
-test -z "$SED" && SED=sed
-Xsed="$SED -e 1s/^X//"
-
-
-
-
-
-
 
 
+# Expose a cross-compilation indicator to makefiles
+ if test $build != $host; then
+  NTP_CROSSCOMPILE_TRUE=
+  NTP_CROSSCOMPILE_FALSE='#'
+else
+  NTP_CROSSCOMPILE_TRUE='#'
+  NTP_CROSSCOMPILE_FALSE=
+fi
 
 
 
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5
-printf %s "checking for fgrep... " >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5
+printf %s "checking for a sed that does not truncate output... " >&6; }
+if test ${ac_cv_path_SED+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+            ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
+     for ac_i in 1 2 3 4 5 6 7; do
+       ac_script="$ac_script$as_nl$ac_script"
+     done
+     echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed
+     { ac_script=; unset ac_script;}
+     if test -z "$SED"; then
+  ac_path_SED_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_prog in sed gsed
+   do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_SED="$as_dir$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_SED" || continue
+# Check for GNU ac_path_SED and select it if it is found.
+  # Check for GNU $ac_path_SED
+case `"$ac_path_SED" --version 2>&1` in
+*GNU*)
+  ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;;
+*)
+  ac_count=0
+  printf %s 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    printf "%s\n" '' >> "conftest.nl"
+    "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_SED_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_SED="$ac_path_SED"
+      ac_path_SED_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_SED_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_SED"; then
+    as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5
+  fi
+else
+  ac_cv_path_SED=$SED
+fi
+
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5
+printf "%s\n" "$ac_cv_path_SED" >&6; }
+ SED="$ac_cv_path_SED"
+  rm -f conftest.sed
+
+test -z "$SED" && SED=sed
+Xsed="$SED -e 1s/^X//"
+
+
+
+
+
+
+
+
+
+
+
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
+printf %s "checking for grep that handles long lines and -e... " >&6; }
+if test ${ac_cv_path_GREP+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  if test -z "$GREP"; then
+  ac_path_GREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_prog in grep ggrep
+   do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_GREP="$as_dir$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_GREP" || continue
+# Check for GNU ac_path_GREP and select it if it is found.
+  # Check for GNU $ac_path_GREP
+case `"$ac_path_GREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
+*)
+  ac_count=0
+  printf %s 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    printf "%s\n" 'GREP' >> "conftest.nl"
+    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_GREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_GREP="$ac_path_GREP"
+      ac_path_GREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_GREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_GREP"; then
+    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_GREP=$GREP
+fi
+
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
+printf "%s\n" "$ac_cv_path_GREP" >&6; }
+ GREP="$ac_cv_path_GREP"
+
+
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
+printf %s "checking for egrep... " >&6; }
+if test ${ac_cv_path_EGREP+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+   then ac_cv_path_EGREP="$GREP -E"
+   else
+     if test -z "$EGREP"; then
+  ac_path_EGREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_prog in egrep
+   do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_EGREP="$as_dir$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_EGREP" || continue
+# Check for GNU ac_path_EGREP and select it if it is found.
+  # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+  ac_count=0
+  printf %s 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    printf "%s\n" 'EGREP' >> "conftest.nl"
+    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_EGREP="$ac_path_EGREP"
+      ac_path_EGREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_EGREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_EGREP"; then
+    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_EGREP=$EGREP
+fi
+
+   fi
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
+printf "%s\n" "$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
+
+
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5
+printf %s "checking for fgrep... " >&6; }
 if test ${ac_cv_path_FGREP+y}
 then :
   printf %s "(cached) " >&6
@@ -7892,25 +7831,167 @@ fi
 
 
 
-
-
-# HMS: Save $LIBS and empty it.
-# any LIBS we add here should go in to LDADD_LIBNTP
-
-__LIBS=$LIBS
-LIBS=
-
-
-
-# [Bug 2332] because we need to know if we are using GNU ld...
-
-
-# Check whether --with-gnu-ld was given.
-if test ${with_gnu_ld+y}
+ntp_pkgconfig_min_version='0.15.0'
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
+set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_path_PKG_CONFIG+y}
 then :
-  withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes
+  printf %s "(cached) " >&6
 else $as_nop
-  with_gnu_ld=no
+  case $PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_path_PKG_CONFIG="$as_dir$ac_word$ac_exec_ext"
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
+if test -n "$PKG_CONFIG"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
+printf "%s\n" "$PKG_CONFIG" >&6; }
+else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_path_PKG_CONFIG"; then
+  ac_pt_PKG_CONFIG=$PKG_CONFIG
+  # Extract the first word of "pkg-config", so it can be a program name with args.
+set dummy pkg-config; ac_word=$2
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_path_ac_pt_PKG_CONFIG+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  case $ac_pt_PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_path_ac_pt_PKG_CONFIG="$as_dir$ac_word$ac_exec_ext"
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
+if test -n "$ac_pt_PKG_CONFIG"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
+printf "%s\n" "$ac_pt_PKG_CONFIG" >&6; }
+else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+fi
+
+  if test "x$ac_pt_PKG_CONFIG" = x; then
+    PKG_CONFIG=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    PKG_CONFIG=$ac_pt_PKG_CONFIG
+  fi
+else
+  PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
+fi
+
+{ ac_cv_path_PKG_CONFIG=; unset ac_cv_path_PKG_CONFIG;}
+{ ac_cv_path_ac_pt_PKG_CONFIG=; unset ac_cv_path_ac_pt_PKG_CONFIG;}
+
+case "$PKG_CONFIG" in
+ /*)
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if pkg-config is at least version $ntp_pkgconfig_min_version" >&5
+printf %s "checking if pkg-config is at least version $ntp_pkgconfig_min_version... " >&6; }
+    if $PKG_CONFIG --atleast-pkgconfig-version $ntp_pkgconfig_min_version; then
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s\n" "yes" >&6; }
+    else
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+	PKG_CONFIG=""
+    fi
+    ;;
+esac
+
+
+
+
+
+VER_SUFFIX=
+
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: " >&5
+printf "%s\n" "$as_me: " >&6;}
+	esac
+
+
+
+
+
+
+
+# HMS: Save $LIBS and empty it.
+# any LIBS we add here should go in to LDADD_LIBNTP
+
+SAVED_LIBS=$LIBS
+LIBS=
+
+
+
+# [Bug 2332] because we need to know if we are using GNU ld...
+
+
+# Check whether --with-gnu-ld was given.
+if test ${with_gnu_ld+y}
+then :
+  withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes
+else $as_nop
+  with_gnu_ld=no
 fi
 
 ac_prog=ld
@@ -9641,14 +9722,6 @@ printf "%s\n" "#define HAVE_INLINE 1" >>confdefs.h
 esac
 
 
-# Obsolete code to be removed.
-if test $ac_cv_header_sys_time_h = yes; then
-
-printf "%s\n" "#define TIME_WITH_SYS_TIME 1" >>confdefs.h
-
-fi
-# End of obsolete code.
-
 # The cast to long int works around a bug in the HP C Compiler
 # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
 # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
@@ -15504,100 +15577,6 @@ fi
 
 
 
-case "$ac_cv_type_int32::$ac_cv_header_resolv_h" in
- no::yes)
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for int32 with DNS headers included" >&5
-printf %s "checking for int32 with DNS headers included... " >&6; }
-if test ${ntp_cv_type_int32_with_dns+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-		    #ifdef HAVE_ARPA_NAMESER_H
-		    # include <arpa/nameser.h>
-		    #endif
-		    #include <resolv.h>
-
-int
-main (void)
-{
-
-		    size_t cb = sizeof(int32);
-
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"
-then :
-  ntp_cv_type_int32_with_dns=yes
-else $as_nop
-  ntp_cv_type_int32_with_dns=no
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
-
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_type_int32_with_dns" >&5
-printf "%s\n" "$ntp_cv_type_int32_with_dns" >&6; }
-    case "$ntp_cv_type_int32_with_dns" in
-     yes)
-
-printf "%s\n" "#define HAVE_INT32_ONLY_WITH_DNS 1" >>confdefs.h
-
-    esac
-esac
-
-case "$ac_cv_type_u_int32::$ac_cv_header_resolv_h" in
- no::yes)
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for u_int32 with DNS headers included" >&5
-printf %s "checking for u_int32 with DNS headers included... " >&6; }
-if test ${ntp_cv_type_u_int32_with_dns+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-		    #ifdef HAVE_ARPA_NAMESER_H
-		    # include <arpa/nameser.h>
-		    #endif
-		    #include <resolv.h>
-
-int
-main (void)
-{
-
-		    size_t cb = sizeof(u_int32);
-
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"
-then :
-  ntp_cv_type_u_int32_with_dns=yes
-else $as_nop
-  ntp_cv_type_u_int32_with_dns=no
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
-
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_type_u_int32_with_dns" >&5
-printf "%s\n" "$ntp_cv_type_u_int32_with_dns" >&6; }
-    case "$ntp_cv_type_u_int32_with_dns" in
-     yes)
-
-printf "%s\n" "#define HAVE_U_INT32_ONLY_WITH_DNS 1" >>confdefs.h
-
-    esac
-esac
-
 ac_fn_c_check_header_compile "$LINENO" "sys/timepps.h" "ac_cv_header_sys_timepps_h" "
 	#ifdef HAVE_SYS_TIME_H
 	# include <sys/time.h>
@@ -16179,216 +16158,83 @@ printf "%s\n" "$as_me: WARNING: *** $ntp_warning ***" >&2;}
     ;;
 esac
 
+ if test x"$enable_dependency_tracking" = x"yes"; then
+  LIBNTP_SUBMAKES_TRUE=
+  LIBNTP_SUBMAKES_FALSE='#'
+else
+  LIBNTP_SUBMAKES_TRUE='#'
+  LIBNTP_SUBMAKES_FALSE=
+fi
+
 
-LDADD_LIBNTP="$LDADD_LIBNTP $LIBS"
-LIBS=$__LIBS
-{ __LIBS=; unset __LIBS;}
 
 
 
-# Check whether --enable-shared was given.
-if test ${enable_shared+y}
+# Check whether --with-crypto was given.
+if test ${with_crypto+y}
 then :
-  enableval=$enable_shared; p=${PACKAGE-default}
-    case $enableval in
-    yes) enable_shared=yes ;;
-    no) enable_shared=no ;;
-    *)
-      enable_shared=no
-      # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
-      for pkg in $enableval; do
-	IFS=$lt_save_ifs
-	if test "X$pkg" = "X$p"; then
-	  enable_shared=yes
-	fi
-      done
-      IFS=$lt_save_ifs
-      ;;
-    esac
+  withval=$with_crypto; 		case "$with_crypto" in
+	 yes)
+	    with_crypto=openssl,libcrypto
+	esac
+
 else $as_nop
-  enable_shared=no
+  with_crypto=openssl,libcrypto
 fi
 
 
+# Check whether --with-openssl-libdir was given.
+if test ${with_openssl_libdir+y}
+then :
+  withval=$with_openssl_libdir;
+fi
 
 
+# Check whether --with-openssl-incdir was given.
+if test ${with_openssl_incdir+y}
+then :
+  withval=$with_openssl_incdir;
+fi
 
-
-
-
-
-case `pwd` in
-  *\ * | *\	*)
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
-printf "%s\n" "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;;
-esac
-
-
-
-macro_version='2.4.6'
-macro_revision='2.4.6'
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-ltmain=$ac_aux_dir/ltmain.sh
-
-# Backslashify metacharacters that are still active within
-# double-quoted strings.
-sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
-
-# Same as above, but do not quote variable references.
-double_quote_subst='s/\(["`\\]\)/\\\1/g'
-
-# Sed substitution to delay expansion of an escaped shell variable in a
-# double_quote_subst'ed string.
-delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
-
-# Sed substitution to delay expansion of an escaped single quote.
-delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
-
-# Sed substitution to avoid accidental globbing in evaled expressions
-no_glob_subst='s/\*/\\\*/g'
-
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5
-printf %s "checking for BSD- or MS-compatible name lister (nm)... " >&6; }
-if test ${lt_cv_path_NM+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  if test -n "$NM"; then
-  # Let the user override the test.
-  lt_cv_path_NM=$NM
-else
-  lt_nm_to_check=${ac_tool_prefix}nm
-  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
-    lt_nm_to_check="$lt_nm_to_check nm"
-  fi
-  for lt_tmp_nm in $lt_nm_to_check; do
-    lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
-    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
-      IFS=$lt_save_ifs
-      test -z "$ac_dir" && ac_dir=.
-      tmp_nm=$ac_dir/$lt_tmp_nm
-      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then
-	# Check to see if the nm accepts a BSD-compat flag.
-	# Adding the 'sed 1q' prevents false positives on HP-UX, which says:
-	#   nm: unknown option "B" ignored
-	# Tru64's nm complains that /dev/null is an invalid object file
-	# MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty
-	case $build_os in
-	mingw*) lt_bad_file=conftest.nm/nofile ;;
-	*) lt_bad_file=/dev/null ;;
-	esac
-	case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in
-	*$lt_bad_file* | *'Invalid file or object type'*)
-	  lt_cv_path_NM="$tmp_nm -B"
-	  break 2
-	  ;;
-	*)
-	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
-	  */dev/null*)
-	    lt_cv_path_NM="$tmp_nm -p"
-	    break 2
-	    ;;
-	  *)
-	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
-	    continue # so that we can try to find one that supports BSD flags
-	    ;;
-	  esac
-	  ;;
-	esac
-      fi
-    done
-    IFS=$lt_save_ifs
-  done
-  : ${lt_cv_path_NM=no}
-fi
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5
-printf "%s\n" "$lt_cv_path_NM" >&6; }
-if test no != "$lt_cv_path_NM"; then
-  NM=$lt_cv_path_NM
-else
-  # Didn't find any BSD compatible name lister, look for dumpbin.
-  if test -n "$DUMPBIN"; then :
-    # Let the user override the test.
-  else
-    if test -n "$ac_tool_prefix"; then
-  for ac_prog in dumpbin "link -dump"
-  do
-    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-printf %s "checking for $ac_word... " >&6; }
-if test ${ac_cv_prog_DUMPBIN+y}
+# Check whether --enable-verbose-ssl was given.
+if test ${enable_verbose_ssl+y}
 then :
-  printf %s "(cached) " >&6
+  enableval=$enable_verbose_ssl;
 else $as_nop
-  if test -n "$DUMPBIN"; then
-  ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  case $as_dir in #(((
-    '') as_dir=./ ;;
-    */) ;;
-    *) as_dir=$as_dir/ ;;
-  esac
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
-    ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog"
-    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-DUMPBIN=$ac_cv_prog_DUMPBIN
-if test -n "$DUMPBIN"; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5
-printf "%s\n" "$DUMPBIN" >&6; }
-else
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
-printf "%s\n" "no" >&6; }
+  enable_verbose_ssl=no
 fi
 
 
-    test -n "$DUMPBIN" && break
-  done
-fi
-if test -z "$DUMPBIN"; then
-  ac_ct_DUMPBIN=$DUMPBIN
-  for ac_prog in dumpbin "link -dump"
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
+ntp_openssl=no
+ntp_openssl_from_pkg_config=no
+ntp_ssl_incdir=
+ntp_ssl_cflags=
+ntp_ssl_cppflags=
+ntp_ssl_libdir=
+ntp_ssl_libs_L=
+ntp_ssl_libs_l=
+ntp_ssl_libs=
+ntp_ssl_ldflags=
+
+NTPSSL_SAVED_CFLAGS="$CFLAGS"
+NTPSSL_SAVED_CPPFLAGS="$CPPFLAGS"
+NTPSSL_SAVED_LIBS="$LIBS"
+NTPSSL_SAVED_LDFLAGS="$LDFLAGS"
+
+# Extract the first word of "openssl", so it can be a program name with args.
+set dummy openssl; ac_word=$2
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 printf %s "checking for $ac_word... " >&6; }
-if test ${ac_cv_prog_ac_ct_DUMPBIN+y}
+if test ${ac_cv_path_PATH_OPENSSL+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  if test -n "$ac_ct_DUMPBIN"; then
-  ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+  case $PATH_OPENSSL in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PATH_OPENSSL="$PATH_OPENSSL" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
@@ -16399,7 +16245,7 @@ do
   esac
     for ac_exec_ext in '' $ac_executable_extensions; do
   if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_DUMPBIN="$ac_prog"
+    ac_cv_path_PATH_OPENSSL="$as_dir$ac_word$ac_exec_ext"
     printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
@@ -16407,906 +16253,1217 @@ done
   done
 IFS=$as_save_IFS
 
+  ;;
+esac
 fi
-fi
-ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN
-if test -n "$ac_ct_DUMPBIN"; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5
-printf "%s\n" "$ac_ct_DUMPBIN" >&6; }
+PATH_OPENSSL=$ac_cv_path_PATH_OPENSSL
+if test -n "$PATH_OPENSSL"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PATH_OPENSSL" >&5
+printf "%s\n" "$PATH_OPENSSL" >&6; }
 else
   { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
 printf "%s\n" "no" >&6; }
 fi
 
 
-  test -n "$ac_ct_DUMPBIN" && break
-done
-
-  if test "x$ac_ct_DUMPBIN" = x; then
-    DUMPBIN=":"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    DUMPBIN=$ac_ct_DUMPBIN
-  fi
-fi
-
-    case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in
-    *COFF*)
-      DUMPBIN="$DUMPBIN -symbols -headers"
-      ;;
-    *)
-      DUMPBIN=:
-      ;;
-    esac
-  fi
 
-  if test : != "$DUMPBIN"; then
-    NM=$DUMPBIN
-  fi
-fi
-test -z "$NM" && NM=nm
+str="$with_crypto:${PKG_CONFIG:+notempty}:${with_openssl_libdir-notgiven}:${with_openssl_incdir-notgiven}"
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: $str" >&5
+printf "%s\n" "$as_me: $str" >&6;}
+	esac
 
 
+{ str=; unset str;}
 
+# Make sure neither/both --with_openssl-{inc,lib}dir are given
+case "${with_openssl_libdir-notgiven}:${with_openssl_incdir-notgiven}" in
+ notgiven:notgiven) ;;
+ *notgiven*)
+    as_fn_error $? "only one of --with-openssl-{inc,lib}dir=... given - provide both or neither" "$LINENO" 5
+    ;;
+esac
 
+# HMS: Today there are only 2 case options.  We probably want a third
+# *:*:notgiven:notgiven
+# and in that case we would validate the path in PKG_CONFIG_PATH.
+# Unless we can do it with 2 cases, where the 2nd case is *:*:...
+# and we do a reality check on execpath and the headers/libraries.
+#
+##
+# if $with_crypto is not "no":
+#   if --with-openssl-{inc,lib}dir are not given:
+#     we should use pkg-config to find openssl
+#     if we don't have pkg-config, if openssl is in the base OS, use that.
+##
+case "$with_crypto:${PKG_CONFIG:+notempty}:${with_openssl_libdir-notgiven}:${with_openssl_incdir-notgiven}" in
+ no:*) ;;
+ *:notempty:notgiven:notgiven)
+    # If PKG_CONFIG is notempty and we haven't been given openssl paths,
+    # then let's make sure that the openssl executable's path corresponds
+    # to the path in openssl.pc, and 'openssl version' matches the Version
+    # in openssl.pc.  If $PKG_CONFIG tells us an INCPATH and/or a LIBPATH,
+    # then should we reality check them?
+    ## INCPATH
+    # harlan@ntp-testbuild.tal1> openssl version
+    # OpenSSL 1.1.1t  7 Feb 2023
+    # harlan@ntp-testbuild.tal1> grep 1.1.1t /ntpbuild/include/openssl/*
+    # /ntpbuild/include/openssl/opensslv.h:# define OPENSSL_VERSION_TEXT    "OpenSSL 1.1.1t  7 Feb 2023"
+    # harlan@ntp-testbuild.tal1>
+    ## LIBPATH
+    # harlan@ntp-testbuild.tal1> strings -a /ntpbuild/lib/libcrypto.* | fgrep 1.1.1t
+    # OpenSSL 1.1.1t  7 Feb 2023
+    # OpenSSL 1.1.1t  7 Feb 2023
+    # OpenSSL 1.1.1t  7 Feb 2023
+    # harlan@ntp-testbuild.tal1> ls /ntpbuild/lib/libcrypto.*
+    # /ntpbuild/lib/libcrypto.a       /ntpbuild/lib/libcrypto.so.1.1*
+    # /ntpbuild/lib/libcrypto.so@
+    # harlan@ntp-testbuild.tal1>
+    ##
+    # Having said this, do we really care if the openssl executable that
+    # we have found is matched with the INCPATH and LIBPATH?
+    # One answer: Probably not, but we should complain on a mismatch as
+    # otherwise runtime differences could easily cause problems/drama.
+
+    ##BO
+    # ntp_cv_build_framework_help=yes
+    save_PKG_CONFIG_PATH=${PKG_CONFIG_PATH}
+    for pkg in `echo $with_crypto | $SED -e 's/,/ /'`; do
+        case "$pkg" in
+	 openssl)
+	    if $PKG_CONFIG --exists $pkg ; then
+		# Found it - yay
+		# Do we want to check we found the right one?
+		# --modver
+		# --variable={libdir,includedir} (varname)
+		overf=`openssl version`
+		overs=`echo $overf | awk '{print }'`
+		case "$overs" in
+		 0.*) ;;	# Should we squawk?
+		 1.0.*) ;;	# Should we squawk?
+		 1.1.*) ;;	# Should we squawk?
+		 3.*)
+		    oinc=`openssl --variable=includedir`
+		    olib=`openssl --variable=libdir`
+		    # How should we use these?
+		    ;;
+		 *) ;;	# Should we squawk?
+		esac
+		# /ntpbuild/include/openssl/opensslv.h:# define OPENSSL_VERSION_TEXT    "OpenSSL 1.1.1t  7 Feb 2023"
+		# grep 1.1.1t /ntpbuild/lib/libcrypto.a
+		# strings -a /ntpbuild/lib/libcrypto.a | grep 1.1.1t
+		# OpenSSL 1.1.1t  7 Feb 2023
+		# harlan@ntp-testbuild.tal1>
+		# which should match $overf
+		##
+		# harlan@ntp-testbuild.tal1> echo '"OpenSSL 1.1.1t  7 Feb 2023"' | cut -f 2 -d\"
+		# OpenSSL 1.1.1t  7 Feb 2023
+		# harlan@ntp-testbuild.tal1> grep OPENSSL_VERSION_TEXT /ntpbuild/include/openssl/opensslv.h
+		# # define OPENSSL_VERSION_TEXT    "OpenSSL 1.1.1t  7 Feb 2023"
+		# harlan@ntp-testbuild.tal1>
+		##
+
+	    else
+		# This is a hack, but it's reasonable.
+		pkgpath="`echo $PATH_OPENSSL | sed -e 's:/bin/openssl$::'`/lib/pkgconfig"
+		test -d "$pkgpath" || pkgpath=
+		# echo "pkgpath is <$pkgpath>"
+		# echo "PKG_CONFIG_PATH is <$PKG_CONFIG_PATH>"
+		case "$pkgpath" in
+		 '') ;;	# Nothing to see here...
+		 *) case ":$PKG_CONFIG_PATH:" in
+		     ::)
+			PKG_CONFIG_PATH=$pkgpath
+			export PKG_CONFIG_PATH
+			;;
+		     *:$pkgpath:*)
+			# Already there...
+			;;
+		     *)
+			PKG_CONFIG_PATH="$pkgpath:$PKG_CONFIG_PATH"
+			export PKG_CONFIG_PATH
+			;;
+		    esac
+		    ;;
+		esac
+	    fi
+	    ;;
+        esac
+    done
+    ##EO
 
+    for pkg in `echo $with_crypto | $SED -e 's/,/ /'`; do
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking pkg-config for $pkg" >&5
+printf %s "checking pkg-config for $pkg... " >&6; }
+	if $PKG_CONFIG --exists $pkg ; then
+	    ntp_ssl_cppflags="`$PKG_CONFIG --cflags-only-I $pkg`"
+	    case "$ntp_ssl_cppflags" in
+	     '')
+		ntp_ssl_incdir='not needed'
+		;;
+	     *)
+		ntp_ssl_incdir="`echo $ntp_ssl_cppflags | $SED -e 's/-I//'`"
+	    esac
+	    ntp_ssl_cflags="`$PKG_CONFIG --cflags-only-other $pkg`"
+	    ntp_ssl_libs_L="`$PKG_CONFIG --libs-only-L $pkg`"
+	    case "$ntp_ssl_libs_L" in
+	     '')
+		ntp_ssl_libdir='not needed'
+		;;
+	     *)
+		ntp_ssl_libdir="`echo $ntp_ssl_libs_L | $SED -e 's/-L//'`"
+	    esac
+	    ntp_ssl_libs_l="`$PKG_CONFIG --libs-only-l $pkg`"
+	    ntp_ssl_libs="$ntp_ssl_libs_L $ntp_ssl_libs_l"
+	    ntp_ssl_ldflags="`$PKG_CONFIG --libs-only-other $pkg`"
+	    ntp_openssl=yes
+	    ntp_openssl_from_pkg_config=yes
+	    ntp_openssl_version="`$PKG_CONFIG --modversion $pkg`"
+	    case "$ntp_openssl_version" in
+	     *.*) ;;
+	     *) ntp_openssl_version='(unknown)' ;;
+	    esac
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes, version $ntp_openssl_version" >&5
+printf "%s\n" "yes, version $ntp_openssl_version" >&6; }
 
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5
-printf %s "checking the name lister ($NM) interface... " >&6; }
-if test ${lt_cv_nm_interface+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  lt_cv_nm_interface="BSD nm"
-  echo "int some_variable = 0;" > conftest.$ac_ext
-  (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5)
-  (eval "$ac_compile" 2>conftest.err)
-  cat conftest.err >&5
-  (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
-  (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
-  cat conftest.err >&5
-  (eval echo "\"\$as_me:$LINENO: output\"" >&5)
-  cat conftest.out >&5
-  if $GREP 'External.*some_variable' conftest.out > /dev/null; then
-    lt_cv_nm_interface="MS dumpbin"
-  fi
-  rm -f conftest*
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5
-printf "%s\n" "$lt_cv_nm_interface" >&6; }
+	    break
+	fi
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+    done
+    { pkg=; unset pkg;}
+esac
+case "$with_crypto" in
+ no) ;;
+ *)
+    case "$with_openssl_libdir" in
+     '') ;;
+     *)
+	ntp_ssl_libdir="$with_openssl_libdir"
+	ntp_ssl_libs_L="-L$with_openssl_libdir"
+	ntp_ssl_libs_l="-lcrypto"
+	ntp_ssl_libs="$ntp_ssl_libs_L $ntp_ssl_libs_l"
+    esac
+    case "$with_openssl_incdir" in
+     '') ;;
+     *)
+	ntp_ssl_incdir="$with_openssl_incdir"
+	ntp_ssl_cppflags="-I$with_openssl_incdir"
+    esac
+esac
 
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5
-printf %s "checking whether ln -s works... " >&6; }
-LN_S=$as_ln_s
-if test "$LN_S" = "ln -s"; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-printf "%s\n" "yes" >&6; }
-else
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5
-printf "%s\n" "no, using $LN_S" >&6; }
-fi
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: OpenSSL Phase I checks:" >&5
+printf "%s\n" "$as_me: OpenSSL Phase I checks:" >&6;}
+	esac
 
-# find the maximum length of command line arguments
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5
-printf %s "checking the maximum length of command line arguments... " >&6; }
-if test ${lt_cv_sys_max_cmd_len+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-    i=0
-  teststring=ABCD
 
-  case $build_os in
-  msdosdjgpp*)
-    # On DJGPP, this test can blow up pretty badly due to problems in libc
-    # (any single argument exceeding 2000 bytes causes a buffer overrun
-    # during glob expansion).  Even if it were fixed, the result of this
-    # check would be larger than it should be.
-    lt_cv_sys_max_cmd_len=12288;    # 12K is about right
-    ;;
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: CPPFLAGS_NTP: ($CPPFLAGS_NTP)" >&5
+printf "%s\n" "$as_me: CPPFLAGS_NTP: ($CPPFLAGS_NTP)" >&6;}
+	esac
 
-  gnu*)
-    # Under GNU Hurd, this test is not required because there is
-    # no limit to the length of command line arguments.
-    # Libtool will interpret -1 as no limit whatsoever
-    lt_cv_sys_max_cmd_len=-1;
-    ;;
 
-  cygwin* | mingw* | cegcc*)
-    # On Win9x/ME, this test blows up -- it succeeds, but takes
-    # about 5 minutes as the teststring grows exponentially.
-    # Worse, since 9x/ME are not pre-emptively multitasking,
-    # you end up with a "frozen" computer, even though with patience
-    # the test eventually succeeds (with a max line length of 256k).
-    # Instead, let's just punt: use the minimum linelength reported by
-    # all of the supported platforms: 8192 (on NT/2K/XP).
-    lt_cv_sys_max_cmd_len=8192;
-    ;;
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: CFLAGS_NTP:   ($CFLAGS_NTP)" >&5
+printf "%s\n" "$as_me: CFLAGS_NTP:   ($CFLAGS_NTP)" >&6;}
+	esac
 
-  mint*)
-    # On MiNT this can take a long time and run out of memory.
-    lt_cv_sys_max_cmd_len=8192;
-    ;;
 
-  amigaos*)
-    # On AmigaOS with pdksh, this test takes hours, literally.
-    # So we just punt and use a minimum line length of 8192.
-    lt_cv_sys_max_cmd_len=8192;
-    ;;
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: LDADD_NTP:    ($LDADD_NTP)" >&5
+printf "%s\n" "$as_me: LDADD_NTP:    ($LDADD_NTP)" >&6;}
+	esac
 
-  bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*)
-    # This has been around since 386BSD, at least.  Likely further.
-    if test -x /sbin/sysctl; then
-      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
-    elif test -x /usr/sbin/sysctl; then
-      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
-    else
-      lt_cv_sys_max_cmd_len=65536	# usable default for all BSDs
-    fi
-    # And add a safety zone
-    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
-    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
-    ;;
 
-  interix*)
-    # We know the value 262144 and hardcode it with a safety zone (like BSD)
-    lt_cv_sys_max_cmd_len=196608
-    ;;
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: LDFLAGS_NTP:  ($LDFLAGS_NTP)" >&5
+printf "%s\n" "$as_me: LDFLAGS_NTP:  ($LDFLAGS_NTP)" >&6;}
+	esac
 
-  os2*)
-    # The test takes a long time on OS/2.
-    lt_cv_sys_max_cmd_len=8192
-    ;;
 
-  osf*)
-    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
-    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
-    # nice to cause kernel panics so lets avoid the loop below.
-    # First set a reasonable default.
-    lt_cv_sys_max_cmd_len=16384
-    #
-    if test -x /sbin/sysconfig; then
-      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
-        *1*) lt_cv_sys_max_cmd_len=-1 ;;
-      esac
-    fi
-    ;;
-  sco3.2v5*)
-    lt_cv_sys_max_cmd_len=102400
-    ;;
-  sysv5* | sco5v6* | sysv4.2uw2*)
-    kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
-    if test -n "$kargmax"; then
-      lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[	 ]//'`
-    else
-      lt_cv_sys_max_cmd_len=32768
-    fi
-    ;;
-  *)
-    lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
-    if test -n "$lt_cv_sys_max_cmd_len" && \
-       test undefined != "$lt_cv_sys_max_cmd_len"; then
-      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
-      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
-    else
-      # Make teststring a little bigger before we do anything with it.
-      # a 1K string should be a reasonable start.
-      for i in 1 2 3 4 5 6 7 8; do
-        teststring=$teststring$teststring
-      done
-      SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
-      # If test is not a shell built-in, we'll probably end up computing a
-      # maximum length that is only half of the actual maximum length, but
-      # we can't tell.
-      while { test X`env echo "$teststring$teststring" 2>/dev/null` \
-	         = "X$teststring$teststring"; } >/dev/null 2>&1 &&
-	      test 17 != "$i" # 1/2 MB should be enough
-      do
-        i=`expr $i + 1`
-        teststring=$teststring$teststring
-      done
-      # Only check the string length outside the loop.
-      lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
-      teststring=
-      # Add a significant safety factor because C++ compilers can tack on
-      # massive amounts of additional arguments before passing them to the
-      # linker.  It appears as though 1/2 is a usable value.
-      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
-    fi
-    ;;
-  esac
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_openssl_from_pkg_config: $ntp_openssl_from_pkg_config" >&5
+printf "%s\n" "$as_me: ntp_openssl_from_pkg_config: $ntp_openssl_from_pkg_config" >&6;}
+	esac
 
-fi
 
-if test -n "$lt_cv_sys_max_cmd_len"; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5
-printf "%s\n" "$lt_cv_sys_max_cmd_len" >&6; }
-else
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none" >&5
-printf "%s\n" "none" >&6; }
-fi
-max_cmd_len=$lt_cv_sys_max_cmd_len
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_ssl_incdir:   ($ntp_ssl_incdir)" >&5
+printf "%s\n" "$as_me: ntp_ssl_incdir:   ($ntp_ssl_incdir)" >&6;}
+	esac
 
 
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_ssl_libdir:   ($ntp_ssl_libdir)" >&5
+printf "%s\n" "$as_me: ntp_ssl_libdir:   ($ntp_ssl_libdir)" >&6;}
+	esac
 
 
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_ssl_cflags:   ($ntp_ssl_cflags)" >&5
+printf "%s\n" "$as_me: ntp_ssl_cflags:   ($ntp_ssl_cflags)" >&6;}
+	esac
 
 
-: ${CP="cp -f"}
-: ${MV="mv -f"}
-: ${RM="rm -f"}
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_ssl_cppflags: ($ntp_ssl_cppflags)" >&5
+printf "%s\n" "$as_me: ntp_ssl_cppflags: ($ntp_ssl_cppflags)" >&6;}
+	esac
 
-if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
-  lt_unset=unset
-else
-  lt_unset=false
-fi
 
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_ssl_libs_L:   ($ntp_ssl_libs_L)" >&5
+printf "%s\n" "$as_me: ntp_ssl_libs_L:   ($ntp_ssl_libs_L)" >&6;}
+	esac
 
 
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_ssl_libs_l:   ($ntp_ssl_libs_l)" >&5
+printf "%s\n" "$as_me: ntp_ssl_libs_l:   ($ntp_ssl_libs_l)" >&6;}
+	esac
 
 
-# test EBCDIC or ASCII
-case `echo X|tr X '\101'` in
- A) # ASCII based system
-    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
-  lt_SP2NL='tr \040 \012'
-  lt_NL2SP='tr \015\012 \040\040'
-  ;;
- *) # EBCDIC based system
-  lt_SP2NL='tr \100 \n'
-  lt_NL2SP='tr \r\n \100\100'
-  ;;
-esac
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_ssl_libs:     ($ntp_ssl_libs)" >&5
+printf "%s\n" "$as_me: ntp_ssl_libs:     ($ntp_ssl_libs)" >&6;}
+	esac
 
 
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_ssl_ldflags:  ($ntp_ssl_ldflags)" >&5
+printf "%s\n" "$as_me: ntp_ssl_ldflags:  ($ntp_ssl_ldflags)" >&6;}
+	esac
 
 
 
+case "$with_crypto" in
+ no)
+    ntp_openssl=no
+    ;;
+ *)
+    ntp_ssl_libs_l="${ntp_ssl_libs_l:--lcrypto}"
+    ntp_ssl_libs="$ntp_ssl_libs_L $ntp_ssl_libs_l"
+    case "$ntp_ssl_libdir" in
+     '')
 
+		{ ac_cv_lib_crypto_EVP_MD_CTX_new=; unset ac_cv_lib_crypto_EVP_MD_CTX_new;}
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: Searching for libcrypto without -L" >&5
+printf "%s\n" "$as_me: Searching for libcrypto without -L" >&6;}
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for EVP_MD_CTX_new in -lcrypto" >&5
+printf %s "checking for EVP_MD_CTX_new in -lcrypto... " >&6; }
+if test ${ac_cv_lib_crypto_EVP_MD_CTX_new+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lcrypto  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+char EVP_MD_CTX_new ();
+int
+main (void)
+{
+return EVP_MD_CTX_new ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
+then :
+  ac_cv_lib_crypto_EVP_MD_CTX_new=yes
+else $as_nop
+  ac_cv_lib_crypto_EVP_MD_CTX_new=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_EVP_MD_CTX_new" >&5
+printf "%s\n" "$ac_cv_lib_crypto_EVP_MD_CTX_new" >&6; }
+if test "x$ac_cv_lib_crypto_EVP_MD_CTX_new" = xyes
+then :
+  ntp_ssl_libdir='not needed'
 
+fi
 
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5
-printf %s "checking how to convert $build file names to $host format... " >&6; }
-if test ${lt_cv_to_host_file_cmd+y}
+		{ ac_cv_lib_crypto_EVP_MD_CTX_new=; unset ac_cv_lib_crypto_EVP_MD_CTX_new;}
+    esac
+    case "$ntp_ssl_libdir" in
+     '')
+	ntp_ssl_libdir_search="/usr/lib /usr/lib/openssl /usr/sfw/lib"
+	ntp_ssl_libdir_search="$ntp_ssl_libdir_search /usr/local/lib"
+	ntp_ssl_libdir_search="$ntp_ssl_libdir_search /usr/local/ssl/lib"
+	ntp_ssl_libdir_search="$ntp_ssl_libdir_search /opt/local/lib"
+	ntp_ssl_libdir_search="$ntp_ssl_libdir_search /lib /lib64"
+	;;
+     *)
+	ntp_ssl_libdir_search="$ntp_ssl_libdir"
+    esac
+    case $ntp_ssl_libdir_search in
+     'not needed') ;;
+     *)
+	for i in $ntp_ssl_libdir_search not_found
+	do
+	    case "$i" in
+	     not_found) ;;
+	     *)
+		{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: Searching for libcrypto in $i" >&5
+printf "%s\n" "$as_me: Searching for libcrypto in $i" >&6;}
+		LIBS="-L$i $NTPSSL_SAVED_LIBS"
+		{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for EVP_MD_CTX_new in -lcrypto" >&5
+printf %s "checking for EVP_MD_CTX_new in -lcrypto... " >&6; }
+if test ${ac_cv_lib_crypto_EVP_MD_CTX_new+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  case $host in
-  *-*-mingw* )
-    case $build in
-      *-*-mingw* ) # actually msys
-        lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32
-        ;;
-      *-*-cygwin* )
-        lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32
-        ;;
-      * ) # otherwise, assume *nix
-        lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32
-        ;;
-    esac
-    ;;
-  *-*-cygwin* )
-    case $build in
-      *-*-mingw* ) # actually msys
-        lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin
-        ;;
-      *-*-cygwin* )
-        lt_cv_to_host_file_cmd=func_convert_file_noop
-        ;;
-      * ) # otherwise, assume *nix
-        lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin
-        ;;
-    esac
-    ;;
-  * ) # unhandled hosts (and "normal" native builds)
-    lt_cv_to_host_file_cmd=func_convert_file_noop
-    ;;
-esac
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lcrypto  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+char EVP_MD_CTX_new ();
+int
+main (void)
+{
+return EVP_MD_CTX_new ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
+then :
+  ac_cv_lib_crypto_EVP_MD_CTX_new=yes
+else $as_nop
+  ac_cv_lib_crypto_EVP_MD_CTX_new=no
 fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_EVP_MD_CTX_new" >&5
+printf "%s\n" "$ac_cv_lib_crypto_EVP_MD_CTX_new" >&6; }
+if test "x$ac_cv_lib_crypto_EVP_MD_CTX_new" = xyes
+then :
+  break
 
-to_host_file_cmd=$lt_cv_to_host_file_cmd
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5
-printf "%s\n" "$lt_cv_to_host_file_cmd" >&6; }
-
+fi
 
+				{ ac_cv_lib_crypto_EVP_MD_CTX_new=; unset ac_cv_lib_crypto_EVP_MD_CTX_new;}
+	    esac
+	done
+	ntp_ssl_libdir="$i"
+	ntp_ssl_libs_L="-L$i"
+	ntp_ssl_libs="$ntp_ssl_libs_L $ntp_ssl_libs_l"
+	LIBS="$NTPSSL_SAVED_LIBS"
+	case "$ntp_ssl_libdir" in
+	 not_found)
+	    as_fn_error $? "You may want to use --without-crypto, or add
+openssl.pc/libcrypto.pc to PKG_CONFIG_PATH, or use the
+--with-openssl-libdir=/some/path option to configure.
+libcrypto not found in any of the following directories:
+$ntp_ssl_libdir_search
+	    " "$LINENO" 5
+	esac
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: libcrypto found in $ntp_ssl_libdir" >&5
+printf "%s\n" "$as_me: libcrypto found in $ntp_ssl_libdir" >&6;}
+    esac
 
+    case "$ntp_openssl_from_pkg_config:$ntp_ssl_incdir" in
+     'yes:not needed' | no:)
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: Searching for openssl/evp.h without -I" >&5
+printf "%s\n" "$as_me: Searching for openssl/evp.h without -I" >&6;}
+		{ ac_cv_header_openssl_evp_h=; unset ac_cv_header_openssl_evp_h;}
+	ac_fn_c_check_header_compile "$LINENO" "openssl/evp.h" "ac_cv_header_openssl_evp_h" "$ac_includes_default"
+if test "x$ac_cv_header_openssl_evp_h" = xyes
+then :
+  ntp_ssl_incdir='not needed'
 
+fi
 
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5
-printf %s "checking how to convert $build file names to toolchain format... " >&6; }
-if test ${lt_cv_to_tool_file_cmd+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  #assume ordinary cross tools, or native build.
-lt_cv_to_tool_file_cmd=func_convert_file_noop
-case $host in
-  *-*-mingw* )
-    case $build in
-      *-*-mingw* ) # actually msys
-        lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32
-        ;;
     esac
-    ;;
-esac
+    case "$ntp_ssl_incdir" in
+     'not needed')
+	ntp_ssl_incdir_search="$ntp_ssl_incdir"
+	;;
+     *)
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: Searching for openssl include directory" >&5
+printf "%s\n" "$as_me: Searching for openssl include directory" >&6;}
+	case "$with_openssl_incdir" in
+	 '')
+	    case "$ntp_ssl_incdir" in
+	     '')
+		ntp_ssl_incdir_search="/usr/include /usr/sfw/include"
+		ntp_ssl_incdir_search="$ntp_ssl_incdir_search /usr/local/include"
+		ntp_ssl_incdir_search="$ntp_ssl_incdir_search /opt/local/include"
+		ntp_ssl_incdir_search="$ntp_ssl_incdir_search /usr/local/ssl/include"
+		;;
+	     *)
+	    esac
+	    ;;
+	 *)
+	    ntp_ssl_incdir_search="$with_openssl_incdir"
+	esac
+	case $ntp_ssl_incdir_search in
+	 'not needed') ;;
+	 *)
+	    for i in $ntp_ssl_incdir_search
+	    do
+		{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: Searching for openssl/evp.h in $i" >&5
+printf "%s\n" "$as_me: Searching for openssl/evp.h in $i" >&6;}
+		CPPFLAGS="$NTPSSL_SAVED_CPPFLAGS -I$i"
+				{ ac_cv_header_openssl_evp_h=; unset ac_cv_header_openssl_evp_h;}
+		ac_fn_c_check_header_compile "$LINENO" "openssl/evp.h" "ac_cv_header_openssl_evp_h" "$ac_includes_default"
+if test "x$ac_cv_header_openssl_evp_h" = xyes
+then :
+  ntp_ssl_incdir="$i" ; break
 
 fi
 
-to_tool_file_cmd=$lt_cv_to_tool_file_cmd
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5
-printf "%s\n" "$lt_cv_to_tool_file_cmd" >&6; }
+	    done
+	    { ac_cv_header_openssl_evp_h=; unset ac_cv_header_openssl_evp_h;}
+	    { i=; unset i;}
+	    CPPFLAGS="$NTPSSL_SAVED_CPPFLAGS"
+	    case "$ntp_ssl_incdir" in
+	     '')
+		as_fn_error $? "You may want to use --without-crypto, or add
+openssl.pc/libcrypto.pc to PKG_CONFIG_PATH, or use the
+-with-openssl-incdir=/some/path option to configure.
+No usable openssl/evp.h found in any of the following direcotries:
+$ntp_ssl_incdir_search
+		" "$LINENO" 5
+	    esac
+	    ntp_ssl_cppflags="-I$ntp_ssl_incdir"
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Found evp.h in $ntp_ssl_incdir/openssl" >&5
+printf "%s\n" "$as_me: Found evp.h in $ntp_ssl_incdir/openssl" >&6;}
+	esac
+    esac
+    ntp_openssl=yes
+esac
+case "$ntp_openssl:$ntp_ssl_libdir" in
+ 'yes:not needed')
+    ;;
+ yes:*)
+    CFLAGS="$NTPSSL_SAVED_CFLAGS $ntp_ssl_cflags"
+    CPPFLAGS="$NTPSSL_SAVED_CPPFLAGS $ntp_ssl_cppflags"
+    LIBS="$ntp_ssl_libs $NTPSSL_SAVED_LIBS"
+    LDFLAGS="$ntp_ssl_ldflags $NTPSSL_SAVED_LDFLAGS"
+        { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if crypto works without runpath" >&5
+printf %s "checking if crypto works without runpath... " >&6; }
+if test ${ntp_cv_ssl_without_runpath+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  if test "$cross_compiling" = yes
+then :
+  ntp_cv_ssl_without_runpath=yes
+else $as_nop
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
+		    #include "openssl/evp.h"
 
+int
+main (void)
+{
 
+		    if (!EVP_MD_CTX_new()) {
+			return 1;
+		    }
 
 
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5
-printf %s "checking for $LD option to reload object files... " >&6; }
-if test ${lt_cv_ld_reload_flag+y}
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"
 then :
-  printf %s "(cached) " >&6
+  ntp_cv_ssl_without_runpath=yes
 else $as_nop
-  lt_cv_ld_reload_flag='-r'
+  ntp_cv_ssl_without_runpath=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5
-printf "%s\n" "$lt_cv_ld_reload_flag" >&6; }
-reload_flag=$lt_cv_ld_reload_flag
-case $reload_flag in
-"" | " "*) ;;
-*) reload_flag=" $reload_flag" ;;
-esac
-reload_cmds='$LD$reload_flag -o $output$reload_objs'
-case $host_os in
-  cygwin* | mingw* | pw32* | cegcc*)
-    if test yes != "$GCC"; then
-      reload_cmds=false
-    fi
-    ;;
-  darwin*)
-    if test yes = "$GCC"; then
-      reload_cmds='$LTCC $LTCFLAGS -nostdlib $wl-r -o $output$reload_objs'
-    else
-      reload_cmds='$LD$reload_flag -o $output$reload_objs'
-    fi
-    ;;
-esac
-
 
 
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_ssl_without_runpath" >&5
+printf "%s\n" "$ntp_cv_ssl_without_runpath" >&6; }
+    case "$ntp_cv_ssl_without_runpath" in
+     no)
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if crypto needs -Wl,-rpath,$ntp_ssl_libdir" >&5
+printf %s "checking if crypto needs -Wl,-rpath,$ntp_ssl_libdir... " >&6; }
+if test ${ntp_cv_ssl_needs_dashWl_rpath+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
 
+		LDFLAGS="$ntp_ssl_ldflags -Wl,-rpath,$ntp_ssl_libdir $NTPSSL_SAVED_LDFLAGS"
+		if test "$cross_compiling" = yes
+then :
+  { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot run test program while cross compiling
+See \`config.log' for more details" "$LINENO" 5; }
+else $as_nop
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
+			    #include "openssl/evp.h"
 
+int
+main (void)
+{
 
+			    if (!EVP_MD_CTX_new()) {
+				return 1;
+			    }
 
 
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args.
-set dummy ${ac_tool_prefix}objdump; ac_word=$2
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-printf %s "checking for $ac_word... " >&6; }
-if test ${ac_cv_prog_OBJDUMP+y}
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"
 then :
-  printf %s "(cached) " >&6
+  ntp_cv_ssl_needs_dashWl_rpath=yes
 else $as_nop
-  if test -n "$OBJDUMP"; then
-  ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  case $as_dir in #(((
-    '') as_dir=./ ;;
-    */) ;;
-    *) as_dir=$as_dir/ ;;
-  esac
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
-    ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump"
-    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+  ntp_cv_ssl_needs_dashWl_rpath=no
 
 fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
-OBJDUMP=$ac_cv_prog_OBJDUMP
-if test -n "$OBJDUMP"; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5
-printf "%s\n" "$OBJDUMP" >&6; }
-else
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
-printf "%s\n" "no" >&6; }
-fi
+
 
 
 fi
-if test -z "$ac_cv_prog_OBJDUMP"; then
-  ac_ct_OBJDUMP=$OBJDUMP
-  # Extract the first word of "objdump", so it can be a program name with args.
-set dummy objdump; ac_word=$2
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-printf %s "checking for $ac_word... " >&6; }
-if test ${ac_cv_prog_ac_ct_OBJDUMP+y}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_ssl_needs_dashWl_rpath" >&5
+printf "%s\n" "$ntp_cv_ssl_needs_dashWl_rpath" >&6; }
+	case "$ntp_cv_ssl_needs_dashWl_rpath" in
+	 yes)
+	    ntp_ssl_ldflags="$ntp_ssl_ldflags -Wl,-rpath,$ntp_ssl_libdir"
+	    ;;
+	 no)
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if crypto needs -R$ntp_ssl_libdir" >&5
+printf %s "checking if crypto needs -R$ntp_ssl_libdir... " >&6; }
+if test ${ntp_cv_ssl_needs_dashR+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  if test -n "$ac_ct_OBJDUMP"; then
-  ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  case $as_dir in #(((
-    '') as_dir=./ ;;
-    */) ;;
-    *) as_dir=$as_dir/ ;;
-  esac
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_OBJDUMP="objdump"
-    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+
+		    LDFLAGS="$NTPSSL_SAVED_LDFLAGS $ntp_ssl_ldflags -R$ntp_ssl_libdir"
+		    if test "$cross_compiling" = yes
+then :
+  { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot run test program while cross compiling
+See \`config.log' for more details" "$LINENO" 5; }
+else $as_nop
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+				#include "openssl/evp.h"
+
+int
+main (void)
+{
+
+				if (!EVP_MD_CTX_new()) {
+				    return 1;
+				}
+
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"
+then :
+  ntp_cv_ssl_needs_dashR=yes
+else $as_nop
+  ntp_cv_ssl_needs_dashR=no
 
 fi
-fi
-ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP
-if test -n "$ac_ct_OBJDUMP"; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5
-printf "%s\n" "$ac_ct_OBJDUMP" >&6; }
-else
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
-printf "%s\n" "no" >&6; }
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
 
-  if test "x$ac_ct_OBJDUMP" = x; then
-    OBJDUMP="false"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    OBJDUMP=$ac_ct_OBJDUMP
-  fi
-else
-  OBJDUMP="$ac_cv_prog_OBJDUMP"
-fi
 
-test -z "$OBJDUMP" && OBJDUMP=objdump
 
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_ssl_needs_dashR" >&5
+printf "%s\n" "$ntp_cv_ssl_needs_dashR" >&6; }
+	    case "$ntp_cv_ssl_needs_dashR" in
+	     yes)
+		ntp_ssl_ldflags="$ntp_ssl_ldflags -R$ntp_ssl_libdir"
+	    esac
+	    case "$build:$ntp_cv_ssl_needs_dashR" in
+	     $host:no)
+		{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "Unable to run program using crypto, check openssl.pc
+or libcrypto.pc are in PKG_CONFIG_PATH, or provide the
+ --with-openssl-libdir=/some/path option to configure.
 
+See \`config.log' for more details" "$LINENO" 5; }
+	    esac
+	esac
+    esac
+esac
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: OpenSSL Phase II checks:" >&5
+printf "%s\n" "$as_me: OpenSSL Phase II checks:" >&6;}
+	esac
 
 
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_ssl_incdir:   ($ntp_ssl_incdir)" >&5
+printf "%s\n" "$as_me: ntp_ssl_incdir:   ($ntp_ssl_incdir)" >&6;}
+	esac
 
 
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_ssl_libdir:   ($ntp_ssl_libdir)" >&5
+printf "%s\n" "$as_me: ntp_ssl_libdir:   ($ntp_ssl_libdir)" >&6;}
+	esac
 
 
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_ssl_cflags:   ($ntp_ssl_cflags)" >&5
+printf "%s\n" "$as_me: ntp_ssl_cflags:   ($ntp_ssl_cflags)" >&6;}
+	esac
 
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5
-printf %s "checking how to recognize dependent libraries... " >&6; }
-if test ${lt_cv_deplibs_check_method+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  lt_cv_file_magic_cmd='$MAGIC_CMD'
-lt_cv_file_magic_test_file=
-lt_cv_deplibs_check_method='unknown'
-# Need to set the preceding variable on all platforms that support
-# interlibrary dependencies.
-# 'none' -- dependencies not supported.
-# 'unknown' -- same as none, but documents that we really don't know.
-# 'pass_all' -- all dependencies passed with no checks.
-# 'test_compile' -- check by making test program.
-# 'file_magic [[regex]]' -- check by looking for files in library path
-# that responds to the $file_magic_cmd with a given extended regex.
-# If you have 'file' or equivalent on your system and you're not sure
-# whether 'pass_all' will *always* work, you probably want this one.
 
-case $host_os in
-aix[4-9]*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_ssl_cppflags: ($ntp_ssl_cppflags)" >&5
+printf "%s\n" "$as_me: ntp_ssl_cppflags: ($ntp_ssl_cppflags)" >&6;}
+	esac
 
-beos*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
 
-bsdi[45]*)
-  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
-  lt_cv_file_magic_cmd='/usr/bin/file -L'
-  lt_cv_file_magic_test_file=/shlib/libc.so
-  ;;
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_ssl_libs_L:   ($ntp_ssl_libs_L)" >&5
+printf "%s\n" "$as_me: ntp_ssl_libs_L:   ($ntp_ssl_libs_L)" >&6;}
+	esac
 
-cygwin*)
-  # func_win32_libid is a shell function defined in ltmain.sh
-  lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
-  lt_cv_file_magic_cmd='func_win32_libid'
-  ;;
 
-mingw* | pw32*)
-  # Base MSYS/MinGW do not provide the 'file' command needed by
-  # func_win32_libid shell function, so use a weaker test based on 'objdump',
-  # unless we find 'file', for example because we are cross-compiling.
-  if ( file / ) >/dev/null 2>&1; then
-    lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
-    lt_cv_file_magic_cmd='func_win32_libid'
-  else
-    # Keep this pattern in sync with the one in func_win32_libid.
-    lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)'
-    lt_cv_file_magic_cmd='$OBJDUMP -f'
-  fi
-  ;;
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_ssl_libs_l:   ($ntp_ssl_libs_l)" >&5
+printf "%s\n" "$as_me: ntp_ssl_libs_l:   ($ntp_ssl_libs_l)" >&6;}
+	esac
 
-cegcc*)
-  # use the weaker test based on 'objdump'. See mingw*.
-  lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?'
-  lt_cv_file_magic_cmd='$OBJDUMP -f'
-  ;;
 
-darwin* | rhapsody*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_ssl_libs:     ($ntp_ssl_libs)" >&5
+printf "%s\n" "$as_me: ntp_ssl_libs:     ($ntp_ssl_libs)" >&6;}
+	esac
 
-freebsd* | dragonfly*)
-  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
-    case $host_cpu in
-    i*86 )
-      # Not sure whether the presence of OpenBSD here was a mistake.
-      # Let's accept both of them until this is cleared up.
-      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library'
-      lt_cv_file_magic_cmd=/usr/bin/file
-      lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
-      ;;
-    esac
-  else
-    lt_cv_deplibs_check_method=pass_all
-  fi
-  ;;
 
-haiku*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_ssl_ldflags:  ($ntp_ssl_ldflags)" >&5
+printf "%s\n" "$as_me: ntp_ssl_ldflags:  ($ntp_ssl_ldflags)" >&6;}
+	esac
 
-hpux10.20* | hpux11*)
-  lt_cv_file_magic_cmd=/usr/bin/file
-  case $host_cpu in
-  ia64*)
-    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
-    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
-    ;;
-  hppa*64*)
-    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'
-    lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
-    ;;
-  *)
-    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library'
-    lt_cv_file_magic_test_file=/usr/lib/libc.sl
-    ;;
-  esac
-  ;;
 
-interix[3-9]*)
-  # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
-  lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$'
-  ;;
 
-irix5* | irix6* | nonstopux*)
-  case $LD in
-  *-32|*"-32 ") libmagic=32-bit;;
-  *-n32|*"-n32 ") libmagic=N32;;
-  *-64|*"-64 ") libmagic=64-bit;;
-  *) libmagic=never-match;;
-  esac
-  lt_cv_deplibs_check_method=pass_all
-  ;;
+case "$ntp_openssl:$ntp_openssl_from_pkg_config" in
+ yes:no)
+    CFLAGS="$NTPSSL_SAVED_CFLAGS $ntp_ssl_cflags"
+    CPPFLAGS="$NTPSSL_SAVED_CPPFLAGS $ntp_ssl_cppflags"
+    LIBS="$ntp_ssl_libs $NTPSSL_SAVED_LIBS"
+    LDFLAGS="$ntp_ssl_ldflags $NTPSSL_SAVED_LDFLAGS"
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if linking with $ntp_ssl_libs_l alone works" >&5
+printf %s "checking if linking with $ntp_ssl_libs_l alone works... " >&6; }
+if test ${ntp_cv_bare_lcrypto+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
-# This must be glibc/ELF.
-linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
+		    #include "openssl/evp.h"
 
-netbsd*)
-  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
-    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
-  else
-    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$'
-  fi
-  ;;
+int
+main (void)
+{
 
-newos6*)
-  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'
-  lt_cv_file_magic_cmd=/usr/bin/file
-  lt_cv_file_magic_test_file=/usr/lib/libnls.so
-  ;;
+		    EVP_MD_CTX_new();
 
-*nto* | *qnx*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
 
-openbsd* | bitrig*)
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
-    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$'
-  else
-    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
-  fi
-  ;;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
+then :
+  ntp_cv_bare_lcrypto=yes
+else $as_nop
+  ntp_cv_bare_lcrypto=no
 
-osf3* | osf4* | osf5*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext
 
-rdos*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_bare_lcrypto" >&5
+printf "%s\n" "$ntp_cv_bare_lcrypto" >&6; }
+    case "$ntp_cv_bare_lcrypto" in
+     no)
+	LIBS="-$ntp_ssl_libs -lz $NTPSSL_SAVED_LIBS"
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if linking with $ntp_ssl_libs_l -lz works" >&5
+printf %s "checking if linking with $ntp_ssl_libs_l -lz works... " >&6; }
+if test ${ntp_cv_lcrypto_lz+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
-solaris*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
+			#include "openssl/evp.h"
 
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
+int
+main (void)
+{
 
-sysv4 | sysv4.3*)
-  case $host_vendor in
-  motorola)
-    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'
-    lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
-    ;;
-  ncr)
-    lt_cv_deplibs_check_method=pass_all
-    ;;
-  sequent)
-    lt_cv_file_magic_cmd='/bin/file'
-    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'
-    ;;
-  sni)
-    lt_cv_file_magic_cmd='/bin/file'
-    lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib"
-    lt_cv_file_magic_test_file=/lib/libc.so
-    ;;
-  siemens)
-    lt_cv_deplibs_check_method=pass_all
-    ;;
-  pc)
-    lt_cv_deplibs_check_method=pass_all
-    ;;
-  esac
-  ;;
+			EVP_MD_CTX_new();
 
-tpf*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-os2*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-esac
 
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5
-printf "%s\n" "$lt_cv_deplibs_check_method" >&6; }
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
+then :
+  ntp_cv_lcrypto_lz=yes
+else $as_nop
+  ntp_cv_lcrypto_lz=no
 
-file_magic_glob=
-want_nocaseglob=no
-if test "$build" = "$host"; then
-  case $host_os in
-  mingw* | pw32*)
-    if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then
-      want_nocaseglob=yes
-    else
-      file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"`
-    fi
-    ;;
-  esac
 fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext
 
-file_magic_cmd=$lt_cv_file_magic_cmd
-deplibs_check_method=$lt_cv_deplibs_check_method
-test -z "$deplibs_check_method" && deplibs_check_method=unknown
-
-
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_lcrypto_lz" >&5
+printf "%s\n" "$ntp_cv_lcrypto_lz" >&6; }
+	case "$ntp_cv_lcrypto_lz" in
+	 yes)
+	     ntp_ssl_libs_l="$ntp_ssl_libs_l -lz"
+	     ntp_ssl_libs="$ntp_ssl_libs_L $ntp_ssl_libs_l"
+	esac
+    esac	esac
+case "$ntp_openssl:$GCC" in
+ yes:yes)
+    CFLAGS="$NTP_SAVED_CFLAGS $ntp_ssl_cflags -Werror"
+    CPPFLAGS="$NTPSSL_SAVED_CPPFLAGS $ntp_ssl_cppflags"
+    LIBS="$ntp_ssl_libs $NTPSSL_SAVED_LIBS"
+    LDFLAGS="$ntp_ssl_ldflags $NTPSSL_SAVED_LDFLAGS"
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking If $CC supports -Werror" >&5
+printf %s "checking If $CC supports -Werror... " >&6; }
+if test ${ntp_cv_gcc_supports_Werror+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
+int
+main (void)
+{
 
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+  ntp_cv_gcc_supports_Werror=yes
+else $as_nop
+  ntp_cv_gcc_supports_Werror=no
 
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_gcc_supports_Werror" >&5
+printf "%s\n" "$ntp_cv_gcc_supports_Werror" >&6; }
+    case "ntp_cv_gcc_supports_Werror" in
+     no)
+	ntp_use_Wstrict_prototypes=yes
+	;;
+     yes)
+	CFLAGS="$CFLAGS -Wstrict-prototypes"
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if OpenSSL triggers warnings" >&5
+printf %s "checking if OpenSSL triggers warnings... " >&6; }
+if test ${ntp_cv_ssl_triggers_warnings+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
+			#include "openssl/asn1_mac.h"
+			#include "openssl/bn.h"
+			#include "openssl/err.h"
+			#include "openssl/evp.h"
+			#include "openssl/pem.h"
+			#include "openssl/rand.h"
+			#include "openssl/x509v3.h"
 
+int
+main (void)
+{
 
+			/* empty body */
 
 
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+  ntp_cv_ssl_triggers_warnings=no
+else $as_nop
+  ntp_cv_ssl_triggers_warnings=yes
 
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_ssl_triggers_warnings" >&5
+printf "%s\n" "$ntp_cv_ssl_triggers_warnings" >&6; }
+	case "$ntp_cv_ssl_triggers_warnings" in
+	 yes)
+	    ntp_use_Wstrict_prototypes=no
+	    ;;
+	 *)
+	    ntp_use_Wstrict_prototypes=yes
+	esac
+    esac
+    case "$ntp_use_Wstrict_prototypes" in
+     no)
+	ntp_ssl_cflags="$ntp_ssl_cflags -Wno-strict-prototypes"
+	;;
+     *)
+	ntp_ssl_cflags="$ntp_ssl_cflags -Wstrict-prototypes"
+    esac
+    ;;
+ no:yes)
+        ntp_ssl_cflags="$ntp_ssl_cflags -Wstrict-prototypes"
+esac
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if we will link to ssl library" >&5
+printf %s "checking if we will link to ssl library... " >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_openssl" >&5
+printf "%s\n" "$ntp_openssl" >&6; }
 
+case "$ntp_openssl" in
+ yes)
+    VER_SUFFIX=o
+           for ac_header in openssl/cmac.h
+do :
+  ac_fn_c_check_header_compile "$LINENO" "openssl/cmac.h" "ac_cv_header_openssl_cmac_h" "$ac_includes_default"
+if test "x$ac_cv_header_openssl_cmac_h" = xyes
+then :
+  printf "%s\n" "#define HAVE_OPENSSL_CMAC_H 1" >>confdefs.h
+ ntp_enable_cmac=yes
+else $as_nop
+  ntp_enable_cmac=no
 
+fi
 
+done
+    case "$ntp_enable_cmac" in
+     yes)
 
+printf "%s\n" "#define ENABLE_CMAC 1" >>confdefs.h
 
+    esac
 
+printf "%s\n" "#define OPENSSL /**/" >>confdefs.h
 
 
+printf "%s\n" "#define OPENSSL_SUPPRESS_DEPRECATED 1" >>confdefs.h
 
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args.
-set dummy ${ac_tool_prefix}dlltool; ac_word=$2
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-printf %s "checking for $ac_word... " >&6; }
-if test ${ac_cv_prog_DLLTOOL+y}
+        CFLAGS="$NTPSSL_SAVED_CFLAGS"
+    ac_fn_c_check_func "$LINENO" "EVP_MD_do_all_sorted" "ac_cv_func_EVP_MD_do_all_sorted"
+if test "x$ac_cv_func_EVP_MD_do_all_sorted" = xyes
 then :
-  printf %s "(cached) " >&6
-else $as_nop
-  if test -n "$DLLTOOL"; then
-  ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  case $as_dir in #(((
-    '') as_dir=./ ;;
-    */) ;;
-    *) as_dir=$as_dir/ ;;
-  esac
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
-    ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool"
-    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+  printf "%s\n" "#define HAVE_EVP_MD_DO_ALL_SORTED 1" >>confdefs.h
 
 fi
-fi
-DLLTOOL=$ac_cv_prog_DLLTOOL
-if test -n "$DLLTOOL"; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5
-printf "%s\n" "$DLLTOOL" >&6; }
-else
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
-printf "%s\n" "no" >&6; }
-fi
 
+    CPPFLAGS_NTP="$CPPFLAGS_NTP $ntp_ssl_cppflags"
+    CFLAGS_NTP="$CFLAGS_NTP $ntp_ssl_cflags"
+    LDADD_NTP="$ntp_ssl_libs $LDADD_NTP"
+    LDFLAGS_NTP="$ntp_ssl_ldflags $LDFLAGS_NTP"
+esac
 
-fi
-if test -z "$ac_cv_prog_DLLTOOL"; then
-  ac_ct_DLLTOOL=$DLLTOOL
-  # Extract the first word of "dlltool", so it can be a program name with args.
-set dummy dlltool; ac_word=$2
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-printf %s "checking for $ac_word... " >&6; }
-if test ${ac_cv_prog_ac_ct_DLLTOOL+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  if test -n "$ac_ct_DLLTOOL"; then
-  ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  case $as_dir in #(((
-    '') as_dir=./ ;;
-    */) ;;
-    *) as_dir=$as_dir/ ;;
-  esac
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_DLLTOOL="dlltool"
-    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: OpenSSL final checks:" >&5
+printf "%s\n" "$as_me: OpenSSL final checks:" >&6;}
+	esac
 
-fi
-fi
-ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL
-if test -n "$ac_ct_DLLTOOL"; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5
-printf "%s\n" "$ac_ct_DLLTOOL" >&6; }
-else
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
-printf "%s\n" "no" >&6; }
-fi
 
-  if test "x$ac_ct_DLLTOOL" = x; then
-    DLLTOOL="false"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    DLLTOOL=$ac_ct_DLLTOOL
-  fi
-else
-  DLLTOOL="$ac_cv_prog_DLLTOOL"
-fi
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: ntp_openssl:  $ntp_openssl" >&5
+printf "%s\n" "$as_me: ntp_openssl:  $ntp_openssl" >&6;}
+	esac
 
-test -z "$DLLTOOL" && DLLTOOL=dlltool
+
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: CPPFLAGS_NTP: ($CPPFLAGS_NTP)" >&5
+printf "%s\n" "$as_me: CPPFLAGS_NTP: ($CPPFLAGS_NTP)" >&6;}
+	esac
 
 
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: CFLAGS_NTP:   ($CFLAGS_NTP)" >&5
+printf "%s\n" "$as_me: CFLAGS_NTP:   ($CFLAGS_NTP)" >&6;}
+	esac
 
 
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: LDADD_NTP:    ($LDADD_NTP)" >&5
+printf "%s\n" "$as_me: LDADD_NTP:    ($LDADD_NTP)" >&6;}
+	esac
 
 
+	case "$enable_verbose_ssl" in
+	 yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: LDFLAGS_NTP:  ($LDFLAGS_NTP)" >&5
+printf "%s\n" "$as_me: LDFLAGS_NTP:  ($LDFLAGS_NTP)" >&6;}
+	esac
 
 
 
+CFLAGS="$NTPSSL_SAVED_CFLAGS"
+CPPFLAGS="$NTPSSL_SAVED_CPPFLAGS"
+LIBS="$NTPSSL_SAVED_LIBS"
+LDFLAGS="$NTPSSL_SAVED_LDFLAGS"
 
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5
-printf %s "checking how to associate runtime and link libraries... " >&6; }
-if test ${lt_cv_sharedlib_from_linklib_cmd+y}
+{ NTPSSL_SAVED_CFLAGS=; unset NTPSSL_SAVED_CFLAGS;}
+{ NTPSSL_SAVED_CPPFLAGS=; unset NTPSSL_SAVED_CPPFLAGS;}
+{ NTPSSL_SAVED_LIBS=; unset NTPSSL_SAVED_LIBS;}
+{ NTPSSL_SAVED_LDFLAGS=; unset NTPSSL_SAVED_LDFLAGS;}
+{ ntp_enable_cmac=; unset ntp_enable_cmac;}
+{ ntp_use_Wstrict_prototypes=; unset ntp_use_Wstrict_prototypes;}
+{ ntp_openssl_from_pkg_config=; unset ntp_openssl_from_pkg_config;}
+{ ntp_openssl_version=; unset ntp_openssl_version;}
+{ ntp_ssl_cflags=; unset ntp_ssl_cflags;}
+{ ntp_ssl_cppflags=; unset ntp_ssl_cppflags;}
+{ ntp_ssl_libdir_search=; unset ntp_ssl_libdir_search;}
+{ ntp_ssl_incdir_search=; unset ntp_ssl_incdir_search;}
+{ ntp_ssl_libdir=; unset ntp_ssl_libdir;}
+{ ntp_ssl_incdir=; unset ntp_ssl_incdir;}
+{ ntp_ssl_libs_l=; unset ntp_ssl_libs_l;}
+{ ntp_ssl_libs_L=; unset ntp_ssl_libs_L;}
+{ ntp_ssl_ldflags=; unset ntp_ssl_ldflags;}
+
+
+
+
+
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if we want to use SSL library's secure random numbers" >&5
+printf %s "checking if we want to use SSL library's secure random numbers... " >&6; }
+# Check whether --enable-openssl-random was given.
+if test ${enable_openssl_random+y}
 then :
-  printf %s "(cached) " >&6
+  enableval=$enable_openssl_random; ntp_use_openssl_random=$enableval ; ntp_ssl_random_mandatory=$enableval
 else $as_nop
-  lt_cv_sharedlib_from_linklib_cmd='unknown'
-
-case $host_os in
-cygwin* | mingw* | pw32* | cegcc*)
-  # two different shell functions defined in ltmain.sh;
-  # decide which one to use based on capabilities of $DLLTOOL
-  case `$DLLTOOL --help 2>&1` in
-  *--identify-strict*)
-    lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib
-    ;;
-  *)
-    lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback
-    ;;
-  esac
-  ;;
-*)
-  # fallback: assume linklib IS sharedlib
-  lt_cv_sharedlib_from_linklib_cmd=$ECHO
-  ;;
-esac
+  ntp_use_openssl_random=yes ; ntp_ssl_random_mandatory=no
 
 fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5
-printf "%s\n" "$lt_cv_sharedlib_from_linklib_cmd" >&6; }
-sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd
-test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO
 
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_use_openssl_random" >&5
+printf "%s\n" "$ntp_use_openssl_random" >&6; }
 
+# The following might need extra libraries
+NTPO_SAVED_LIBS="$LIBS"
+LIBS="$NTPO_SAVED_LIBS $LDADD_NTP"
+ac_fn_c_check_func "$LINENO" "RAND_bytes" "ac_cv_func_RAND_bytes"
+if test "x$ac_cv_func_RAND_bytes" = xyes
+then :
+  printf "%s\n" "#define HAVE_RAND_BYTES 1" >>confdefs.h
 
+fi
+ac_fn_c_check_func "$LINENO" "RAND_poll" "ac_cv_func_RAND_poll"
+if test "x$ac_cv_func_RAND_poll" = xyes
+then :
+  printf "%s\n" "#define HAVE_RAND_POLL 1" >>confdefs.h
 
+fi
 
+LIBS="$NTPO_SAVED_LIBS"
+case "$ntp_openssl$ntp_use_openssl_random$ac_cv_func_RAND_bytes$ac_cv_func_RAND_poll" in
+ yesyesyesyes)
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Using SSL library's secure random number generator" >&5
+printf "%s\n" "$as_me: Using SSL library's secure random number generator" >&6;}
 
+printf "%s\n" "#define USE_OPENSSL_CRYPTO_RAND 1" >>confdefs.h
 
-if test -n "$ac_tool_prefix"; then
-  for ac_prog in ar
-  do
-    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+    ;;
+ *)
+    ntp_use_openssl_random=no
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: SSL library's secure random number generator unavailable." >&5
+printf "%s\n" "$as_me: SSL library's secure random number generator unavailable." >&6;}
+    case "$ntp_ssl_random_mandatory" in
+     yes)
+	as_fn_error $? "No suitable SSL library was found and
+--enable-openssl-random was given..  Remove --enable-openssl-random
+if you wish to build without a cryptographically secure random number
+generator.
+
+WARNING: Use of ntp-keygen without a secure RNG may generate
+-------  keys that are predictable.
+	" "$LINENO" 5
+	;;
+     *)
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: WARNING: Use of ntp-keygen without a secure RNG may generate
+-------  keys that are predictable.
+	" >&5
+printf "%s\n" "$as_me: WARNING: WARNING: Use of ntp-keygen without a secure RNG may generate
+-------  keys that are predictable.
+	" >&2;}
+    esac
+esac
+
+{ ntp_ssl_random_mandatory=; unset ntp_ssl_random_mandatory;}
+
+
+
+LDADD_LIBNTP="$LDADD_LIBNTP $LIBS"
+LIBS=$SAVED_LIBS
+{ SAVED_LIBS=; unset SAVED_LIBS;}
+
+
+
+case `pwd` in
+  *\ * | *\	*)
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
+printf "%s\n" "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;;
+esac
+
+
+
+macro_version='2.4.6'
+macro_revision='2.4.6'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ltmain=$ac_aux_dir/ltmain.sh
+
+# Backslashify metacharacters that are still active within
+# double-quoted strings.
+sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\(["`\\]\)/\\\1/g'
+
+# Sed substitution to delay expansion of an escaped shell variable in a
+# double_quote_subst'ed string.
+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
+# Sed substitution to delay expansion of an escaped single quote.
+delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
+
+# Sed substitution to avoid accidental globbing in evaled expressions
+no_glob_subst='s/\*/\\\*/g'
+
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5
+printf %s "checking for BSD- or MS-compatible name lister (nm)... " >&6; }
+if test ${lt_cv_path_NM+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  if test -n "$NM"; then
+  # Let the user override the test.
+  lt_cv_path_NM=$NM
+else
+  lt_nm_to_check=${ac_tool_prefix}nm
+  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+    lt_nm_to_check="$lt_nm_to_check nm"
+  fi
+  for lt_tmp_nm in $lt_nm_to_check; do
+    lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
+    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+      IFS=$lt_save_ifs
+      test -z "$ac_dir" && ac_dir=.
+      tmp_nm=$ac_dir/$lt_tmp_nm
+      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then
+	# Check to see if the nm accepts a BSD-compat flag.
+	# Adding the 'sed 1q' prevents false positives on HP-UX, which says:
+	#   nm: unknown option "B" ignored
+	# Tru64's nm complains that /dev/null is an invalid object file
+	# MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty
+	case $build_os in
+	mingw*) lt_bad_file=conftest.nm/nofile ;;
+	*) lt_bad_file=/dev/null ;;
+	esac
+	case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in
+	*$lt_bad_file* | *'Invalid file or object type'*)
+	  lt_cv_path_NM="$tmp_nm -B"
+	  break 2
+	  ;;
+	*)
+	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+	  */dev/null*)
+	    lt_cv_path_NM="$tmp_nm -p"
+	    break 2
+	    ;;
+	  *)
+	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+	    continue # so that we can try to find one that supports BSD flags
+	    ;;
+	  esac
+	  ;;
+	esac
+      fi
+    done
+    IFS=$lt_save_ifs
+  done
+  : ${lt_cv_path_NM=no}
+fi
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5
+printf "%s\n" "$lt_cv_path_NM" >&6; }
+if test no != "$lt_cv_path_NM"; then
+  NM=$lt_cv_path_NM
+else
+  # Didn't find any BSD compatible name lister, look for dumpbin.
+  if test -n "$DUMPBIN"; then :
+    # Let the user override the test.
+  else
+    if test -n "$ac_tool_prefix"; then
+  for ac_prog in dumpbin "link -dump"
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 printf %s "checking for $ac_word... " >&6; }
-if test ${ac_cv_prog_AR+y}
+if test ${ac_cv_prog_DUMPBIN+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  if test -n "$AR"; then
-  ac_cv_prog_AR="$AR" # Let the user override the test.
+  if test -n "$DUMPBIN"; then
+  ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
@@ -17319,7 +17476,7 @@ do
   esac
     for ac_exec_ext in '' $ac_executable_extensions; do
   if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
-    ac_cv_prog_AR="$ac_tool_prefix$ac_prog"
+    ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog"
     printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
@@ -17329,33 +17486,33 @@ IFS=$as_save_IFS
 
 fi
 fi
-AR=$ac_cv_prog_AR
-if test -n "$AR"; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
-printf "%s\n" "$AR" >&6; }
+DUMPBIN=$ac_cv_prog_DUMPBIN
+if test -n "$DUMPBIN"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5
+printf "%s\n" "$DUMPBIN" >&6; }
 else
   { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
 printf "%s\n" "no" >&6; }
 fi
 
 
-    test -n "$AR" && break
+    test -n "$DUMPBIN" && break
   done
 fi
-if test -z "$AR"; then
-  ac_ct_AR=$AR
-  for ac_prog in ar
+if test -z "$DUMPBIN"; then
+  ac_ct_DUMPBIN=$DUMPBIN
+  for ac_prog in dumpbin "link -dump"
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 printf %s "checking for $ac_word... " >&6; }
-if test ${ac_cv_prog_ac_ct_AR+y}
+if test ${ac_cv_prog_ac_ct_DUMPBIN+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  if test -n "$ac_ct_AR"; then
-  ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
+  if test -n "$ac_ct_DUMPBIN"; then
+  ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
@@ -17368,7 +17525,7 @@ do
   esac
     for ac_exec_ext in '' $ac_executable_extensions; do
   if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_AR="$ac_prog"
+    ac_cv_prog_ac_ct_DUMPBIN="$ac_prog"
     printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
@@ -17378,21 +17535,21 @@ IFS=$as_save_IFS
 
 fi
 fi
-ac_ct_AR=$ac_cv_prog_ac_ct_AR
-if test -n "$ac_ct_AR"; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
-printf "%s\n" "$ac_ct_AR" >&6; }
+ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN
+if test -n "$ac_ct_DUMPBIN"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5
+printf "%s\n" "$ac_ct_DUMPBIN" >&6; }
 else
   { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
 printf "%s\n" "no" >&6; }
 fi
 
 
-  test -n "$ac_ct_AR" && break
+  test -n "$ac_ct_DUMPBIN" && break
 done
 
-  if test "x$ac_ct_AR" = x; then
-    AR="false"
+  if test "x$ac_ct_DUMPBIN" = x; then
+    DUMPBIN=":"
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
@@ -17400,203 +17557,373 @@ yes:)
 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
-    AR=$ac_ct_AR
+    DUMPBIN=$ac_ct_DUMPBIN
   fi
 fi
 
-: ${AR=ar}
-: ${AR_FLAGS=cru}
-
-
+    case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in
+    *COFF*)
+      DUMPBIN="$DUMPBIN -symbols -headers"
+      ;;
+    *)
+      DUMPBIN=:
+      ;;
+    esac
+  fi
 
+  if test : != "$DUMPBIN"; then
+    NM=$DUMPBIN
+  fi
+fi
+test -z "$NM" && NM=nm
 
 
 
 
 
 
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5
+printf %s "checking the name lister ($NM) interface... " >&6; }
+if test ${lt_cv_nm_interface+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  lt_cv_nm_interface="BSD nm"
+  echo "int some_variable = 0;" > conftest.$ac_ext
+  (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5)
+  (eval "$ac_compile" 2>conftest.err)
+  cat conftest.err >&5
+  (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
+  (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
+  cat conftest.err >&5
+  (eval echo "\"\$as_me:$LINENO: output\"" >&5)
+  cat conftest.out >&5
+  if $GREP 'External.*some_variable' conftest.out > /dev/null; then
+    lt_cv_nm_interface="MS dumpbin"
+  fi
+  rm -f conftest*
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5
+printf "%s\n" "$lt_cv_nm_interface" >&6; }
 
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5
+printf %s "checking whether ln -s works... " >&6; }
+LN_S=$as_ln_s
+if test "$LN_S" = "ln -s"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s\n" "yes" >&6; }
+else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5
+printf "%s\n" "no, using $LN_S" >&6; }
+fi
 
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5
-printf %s "checking for archiver @FILE support... " >&6; }
-if test ${lt_cv_ar_at_file+y}
+# find the maximum length of command line arguments
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5
+printf %s "checking the maximum length of command line arguments... " >&6; }
+if test ${lt_cv_sys_max_cmd_len+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  lt_cv_ar_at_file=no
-   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
+    i=0
+  teststring=ABCD
 
-int
-main (void)
-{
+  case $build_os in
+  msdosdjgpp*)
+    # On DJGPP, this test can blow up pretty badly due to problems in libc
+    # (any single argument exceeding 2000 bytes causes a buffer overrun
+    # during glob expansion).  Even if it were fixed, the result of this
+    # check would be larger than it should be.
+    lt_cv_sys_max_cmd_len=12288;    # 12K is about right
+    ;;
 
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"
-then :
-  echo conftest.$ac_objext > conftest.lst
-      lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5'
-      { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5
-  (eval $lt_ar_try) 2>&5
-  ac_status=$?
-  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
-      if test 0 -eq "$ac_status"; then
-	# Ensure the archiver fails upon bogus file names.
-	rm -f conftest.$ac_objext libconftest.a
-	{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5
-  (eval $lt_ar_try) 2>&5
-  ac_status=$?
-  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
-	if test 0 -ne "$ac_status"; then
-          lt_cv_ar_at_file=@
-        fi
-      fi
-      rm -f conftest.* libconftest.a
+  gnu*)
+    # Under GNU Hurd, this test is not required because there is
+    # no limit to the length of command line arguments.
+    # Libtool will interpret -1 as no limit whatsoever
+    lt_cv_sys_max_cmd_len=-1;
+    ;;
 
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+  cygwin* | mingw* | cegcc*)
+    # On Win9x/ME, this test blows up -- it succeeds, but takes
+    # about 5 minutes as the teststring grows exponentially.
+    # Worse, since 9x/ME are not pre-emptively multitasking,
+    # you end up with a "frozen" computer, even though with patience
+    # the test eventually succeeds (with a max line length of 256k).
+    # Instead, let's just punt: use the minimum linelength reported by
+    # all of the supported platforms: 8192 (on NT/2K/XP).
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  mint*)
+    # On MiNT this can take a long time and run out of memory.
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  amigaos*)
+    # On AmigaOS with pdksh, this test takes hours, literally.
+    # So we just punt and use a minimum line length of 8192.
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*)
+    # This has been around since 386BSD, at least.  Likely further.
+    if test -x /sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
+    elif test -x /usr/sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+    else
+      lt_cv_sys_max_cmd_len=65536	# usable default for all BSDs
+    fi
+    # And add a safety zone
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    ;;
+
+  interix*)
+    # We know the value 262144 and hardcode it with a safety zone (like BSD)
+    lt_cv_sys_max_cmd_len=196608
+    ;;
+
+  os2*)
+    # The test takes a long time on OS/2.
+    lt_cv_sys_max_cmd_len=8192
+    ;;
+
+  osf*)
+    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
+    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
+    # nice to cause kernel panics so lets avoid the loop below.
+    # First set a reasonable default.
+    lt_cv_sys_max_cmd_len=16384
+    #
+    if test -x /sbin/sysconfig; then
+      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
+        *1*) lt_cv_sys_max_cmd_len=-1 ;;
+      esac
+    fi
+    ;;
+  sco3.2v5*)
+    lt_cv_sys_max_cmd_len=102400
+    ;;
+  sysv5* | sco5v6* | sysv4.2uw2*)
+    kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
+    if test -n "$kargmax"; then
+      lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[	 ]//'`
+    else
+      lt_cv_sys_max_cmd_len=32768
+    fi
+    ;;
+  *)
+    lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
+    if test -n "$lt_cv_sys_max_cmd_len" && \
+       test undefined != "$lt_cv_sys_max_cmd_len"; then
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    else
+      # Make teststring a little bigger before we do anything with it.
+      # a 1K string should be a reasonable start.
+      for i in 1 2 3 4 5 6 7 8; do
+        teststring=$teststring$teststring
+      done
+      SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+      # If test is not a shell built-in, we'll probably end up computing a
+      # maximum length that is only half of the actual maximum length, but
+      # we can't tell.
+      while { test X`env echo "$teststring$teststring" 2>/dev/null` \
+	         = "X$teststring$teststring"; } >/dev/null 2>&1 &&
+	      test 17 != "$i" # 1/2 MB should be enough
+      do
+        i=`expr $i + 1`
+        teststring=$teststring$teststring
+      done
+      # Only check the string length outside the loop.
+      lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
+      teststring=
+      # Add a significant safety factor because C++ compilers can tack on
+      # massive amounts of additional arguments before passing them to the
+      # linker.  It appears as though 1/2 is a usable value.
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+    fi
+    ;;
+  esac
 
 fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5
-printf "%s\n" "$lt_cv_ar_at_file" >&6; }
 
-if test no = "$lt_cv_ar_at_file"; then
-  archiver_list_spec=
+if test -n "$lt_cv_sys_max_cmd_len"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5
+printf "%s\n" "$lt_cv_sys_max_cmd_len" >&6; }
 else
-  archiver_list_spec=$lt_cv_ar_at_file
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none" >&5
+printf "%s\n" "none" >&6; }
 fi
+max_cmd_len=$lt_cv_sys_max_cmd_len
 
 
 
 
 
 
+: ${CP="cp -f"}
+: ${MV="mv -f"}
+: ${RM="rm -f"}
 
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
-set dummy ${ac_tool_prefix}strip; ac_word=$2
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-printf %s "checking for $ac_word... " >&6; }
-if test ${ac_cv_prog_STRIP+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  if test -n "$STRIP"; then
-  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  case $as_dir in #(((
-    '') as_dir=./ ;;
-    */) ;;
-    *) as_dir=$as_dir/ ;;
-  esac
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
-    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
-    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-STRIP=$ac_cv_prog_STRIP
-if test -n "$STRIP"; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
-printf "%s\n" "$STRIP" >&6; }
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+  lt_unset=unset
 else
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
-printf "%s\n" "no" >&6; }
+  lt_unset=false
 fi
 
 
-fi
-if test -z "$ac_cv_prog_STRIP"; then
-  ac_ct_STRIP=$STRIP
-  # Extract the first word of "strip", so it can be a program name with args.
-set dummy strip; ac_word=$2
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-printf %s "checking for $ac_word... " >&6; }
-if test ${ac_cv_prog_ac_ct_STRIP+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  if test -n "$ac_ct_STRIP"; then
-  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  case $as_dir in #(((
-    '') as_dir=./ ;;
-    */) ;;
-    *) as_dir=$as_dir/ ;;
-  esac
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_STRIP="strip"
-    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
 
-fi
-fi
-ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
-if test -n "$ac_ct_STRIP"; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
-printf "%s\n" "$ac_ct_STRIP" >&6; }
-else
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
-printf "%s\n" "no" >&6; }
-fi
 
-  if test "x$ac_ct_STRIP" = x; then
-    STRIP=":"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
+
+# test EBCDIC or ASCII
+case `echo X|tr X '\101'` in
+ A) # ASCII based system
+    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
+  lt_SP2NL='tr \040 \012'
+  lt_NL2SP='tr \015\012 \040\040'
+  ;;
+ *) # EBCDIC based system
+  lt_SP2NL='tr \100 \n'
+  lt_NL2SP='tr \r\n \100\100'
+  ;;
 esac
-    STRIP=$ac_ct_STRIP
-  fi
-else
-  STRIP="$ac_cv_prog_STRIP"
-fi
 
-test -z "$STRIP" && STRIP=:
 
 
 
 
 
 
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ranlib; ac_word=$2
+
+
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5
+printf %s "checking how to convert $build file names to $host format... " >&6; }
+if test ${lt_cv_to_host_file_cmd+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  case $host in
+  *-*-mingw* )
+    case $build in
+      *-*-mingw* ) # actually msys
+        lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32
+        ;;
+      *-*-cygwin* )
+        lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32
+        ;;
+      * ) # otherwise, assume *nix
+        lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32
+        ;;
+    esac
+    ;;
+  *-*-cygwin* )
+    case $build in
+      *-*-mingw* ) # actually msys
+        lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin
+        ;;
+      *-*-cygwin* )
+        lt_cv_to_host_file_cmd=func_convert_file_noop
+        ;;
+      * ) # otherwise, assume *nix
+        lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin
+        ;;
+    esac
+    ;;
+  * ) # unhandled hosts (and "normal" native builds)
+    lt_cv_to_host_file_cmd=func_convert_file_noop
+    ;;
+esac
+
+fi
+
+to_host_file_cmd=$lt_cv_to_host_file_cmd
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5
+printf "%s\n" "$lt_cv_to_host_file_cmd" >&6; }
+
+
+
+
+
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5
+printf %s "checking how to convert $build file names to toolchain format... " >&6; }
+if test ${lt_cv_to_tool_file_cmd+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  #assume ordinary cross tools, or native build.
+lt_cv_to_tool_file_cmd=func_convert_file_noop
+case $host in
+  *-*-mingw* )
+    case $build in
+      *-*-mingw* ) # actually msys
+        lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32
+        ;;
+    esac
+    ;;
+esac
+
+fi
+
+to_tool_file_cmd=$lt_cv_to_tool_file_cmd
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5
+printf "%s\n" "$lt_cv_to_tool_file_cmd" >&6; }
+
+
+
+
+
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5
+printf %s "checking for $LD option to reload object files... " >&6; }
+if test ${lt_cv_ld_reload_flag+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  lt_cv_ld_reload_flag='-r'
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5
+printf "%s\n" "$lt_cv_ld_reload_flag" >&6; }
+reload_flag=$lt_cv_ld_reload_flag
+case $reload_flag in
+"" | " "*) ;;
+*) reload_flag=" $reload_flag" ;;
+esac
+reload_cmds='$LD$reload_flag -o $output$reload_objs'
+case $host_os in
+  cygwin* | mingw* | pw32* | cegcc*)
+    if test yes != "$GCC"; then
+      reload_cmds=false
+    fi
+    ;;
+  darwin*)
+    if test yes = "$GCC"; then
+      reload_cmds='$LTCC $LTCFLAGS -nostdlib $wl-r -o $output$reload_objs'
+    else
+      reload_cmds='$LD$reload_flag -o $output$reload_objs'
+    fi
+    ;;
+esac
+
+
+
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args.
+set dummy ${ac_tool_prefix}objdump; ac_word=$2
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 printf %s "checking for $ac_word... " >&6; }
-if test ${ac_cv_prog_RANLIB+y}
+if test ${ac_cv_prog_OBJDUMP+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  if test -n "$RANLIB"; then
-  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+  if test -n "$OBJDUMP"; then
+  ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
@@ -17609,7 +17936,7 @@ do
   esac
     for ac_exec_ext in '' $ac_executable_extensions; do
   if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
-    ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
+    ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump"
     printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
@@ -17619,10 +17946,10 @@ IFS=$as_save_IFS
 
 fi
 fi
-RANLIB=$ac_cv_prog_RANLIB
-if test -n "$RANLIB"; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
-printf "%s\n" "$RANLIB" >&6; }
+OBJDUMP=$ac_cv_prog_OBJDUMP
+if test -n "$OBJDUMP"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5
+printf "%s\n" "$OBJDUMP" >&6; }
 else
   { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
 printf "%s\n" "no" >&6; }
@@ -17630,18 +17957,18 @@ fi
 
 
 fi
-if test -z "$ac_cv_prog_RANLIB"; then
-  ac_ct_RANLIB=$RANLIB
-  # Extract the first word of "ranlib", so it can be a program name with args.
-set dummy ranlib; ac_word=$2
+if test -z "$ac_cv_prog_OBJDUMP"; then
+  ac_ct_OBJDUMP=$OBJDUMP
+  # Extract the first word of "objdump", so it can be a program name with args.
+set dummy objdump; ac_word=$2
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 printf %s "checking for $ac_word... " >&6; }
-if test ${ac_cv_prog_ac_ct_RANLIB+y}
+if test ${ac_cv_prog_ac_ct_OBJDUMP+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  if test -n "$ac_ct_RANLIB"; then
-  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
+  if test -n "$ac_ct_OBJDUMP"; then
+  ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
@@ -17654,7 +17981,7 @@ do
   esac
     for ac_exec_ext in '' $ac_executable_extensions; do
   if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_RANLIB="ranlib"
+    ac_cv_prog_ac_ct_OBJDUMP="objdump"
     printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
@@ -17664,17 +17991,17 @@ IFS=$as_save_IFS
 
 fi
 fi
-ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
-if test -n "$ac_ct_RANLIB"; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
-printf "%s\n" "$ac_ct_RANLIB" >&6; }
+ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP
+if test -n "$ac_ct_OBJDUMP"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5
+printf "%s\n" "$ac_ct_OBJDUMP" >&6; }
 else
   { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
 printf "%s\n" "no" >&6; }
 fi
 
-  if test "x$ac_ct_RANLIB" = x; then
-    RANLIB=":"
+  if test "x$ac_ct_OBJDUMP" = x; then
+    OBJDUMP="false"
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
@@ -17682,42 +18009,14 @@ yes:)
 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
-    RANLIB=$ac_ct_RANLIB
+    OBJDUMP=$ac_ct_OBJDUMP
   fi
 else
-  RANLIB="$ac_cv_prog_RANLIB"
+  OBJDUMP="$ac_cv_prog_OBJDUMP"
 fi
 
-test -z "$RANLIB" && RANLIB=:
-
-
-
-
-
-
-# Determine commands to create old-style static archives.
-old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
-old_postinstall_cmds='chmod 644 $oldlib'
-old_postuninstall_cmds=
-
-if test -n "$RANLIB"; then
-  case $host_os in
-  bitrig* | openbsd*)
-    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib"
-    ;;
-  *)
-    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib"
-    ;;
-  esac
-  old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib"
-fi
+test -z "$OBJDUMP" && OBJDUMP=objdump
 
-case $host_os in
-  darwin*)
-    lock_old_archive_extraction=yes ;;
-  *)
-    lock_old_archive_extraction=no ;;
-esac
 
 
 
@@ -17726,330 +18025,352 @@ esac
 
 
 
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5
+printf %s "checking how to recognize dependent libraries... " >&6; }
+if test ${lt_cv_deplibs_check_method+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  lt_cv_file_magic_cmd='$MAGIC_CMD'
+lt_cv_file_magic_test_file=
+lt_cv_deplibs_check_method='unknown'
+# Need to set the preceding variable on all platforms that support
+# interlibrary dependencies.
+# 'none' -- dependencies not supported.
+# 'unknown' -- same as none, but documents that we really don't know.
+# 'pass_all' -- all dependencies passed with no checks.
+# 'test_compile' -- check by making test program.
+# 'file_magic [[regex]]' -- check by looking for files in library path
+# that responds to the $file_magic_cmd with a given extended regex.
+# If you have 'file' or equivalent on your system and you're not sure
+# whether 'pass_all' will *always* work, you probably want this one.
 
+case $host_os in
+aix[4-9]*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 
+beos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 
+bsdi[45]*)
+  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
+  lt_cv_file_magic_cmd='/usr/bin/file -L'
+  lt_cv_file_magic_test_file=/shlib/libc.so
+  ;;
 
+cygwin*)
+  # func_win32_libid is a shell function defined in ltmain.sh
+  lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+  lt_cv_file_magic_cmd='func_win32_libid'
+  ;;
 
+mingw* | pw32*)
+  # Base MSYS/MinGW do not provide the 'file' command needed by
+  # func_win32_libid shell function, so use a weaker test based on 'objdump',
+  # unless we find 'file', for example because we are cross-compiling.
+  if ( file / ) >/dev/null 2>&1; then
+    lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+    lt_cv_file_magic_cmd='func_win32_libid'
+  else
+    # Keep this pattern in sync with the one in func_win32_libid.
+    lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)'
+    lt_cv_file_magic_cmd='$OBJDUMP -f'
+  fi
+  ;;
 
+cegcc*)
+  # use the weaker test based on 'objdump'. See mingw*.
+  lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?'
+  lt_cv_file_magic_cmd='$OBJDUMP -f'
+  ;;
 
+darwin* | rhapsody*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 
+freebsd* | dragonfly*)
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+    case $host_cpu in
+    i*86 )
+      # Not sure whether the presence of OpenBSD here was a mistake.
+      # Let's accept both of them until this is cleared up.
+      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library'
+      lt_cv_file_magic_cmd=/usr/bin/file
+      lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
+      ;;
+    esac
+  else
+    lt_cv_deplibs_check_method=pass_all
+  fi
+  ;;
 
+haiku*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 
+hpux10.20* | hpux11*)
+  lt_cv_file_magic_cmd=/usr/bin/file
+  case $host_cpu in
+  ia64*)
+    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
+    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+    ;;
+  hppa*64*)
+    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'
+    lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+    ;;
+  *)
+    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library'
+    lt_cv_file_magic_test_file=/usr/lib/libc.sl
+    ;;
+  esac
+  ;;
 
+interix[3-9]*)
+  # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
+  lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$'
+  ;;
 
+irix5* | irix6* | nonstopux*)
+  case $LD in
+  *-32|*"-32 ") libmagic=32-bit;;
+  *-n32|*"-n32 ") libmagic=N32;;
+  *-64|*"-64 ") libmagic=64-bit;;
+  *) libmagic=never-match;;
+  esac
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 
+# This must be glibc/ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 
+netbsd*)
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$'
+  fi
+  ;;
 
+newos6*)
+  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'
+  lt_cv_file_magic_cmd=/usr/bin/file
+  lt_cv_file_magic_test_file=/usr/lib/libnls.so
+  ;;
 
+*nto* | *qnx*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 
+openbsd* | bitrig*)
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
+  fi
+  ;;
 
+osf3* | osf4* | osf5*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 
+rdos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 
+solaris*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 
+sysv4 | sysv4.3*)
+  case $host_vendor in
+  motorola)
+    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'
+    lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
+    ;;
+  ncr)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  sequent)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'
+    ;;
+  sni)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib"
+    lt_cv_file_magic_test_file=/lib/libc.so
+    ;;
+  siemens)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  pc)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  esac
+  ;;
 
+tpf*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+os2*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+esac
 
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5
+printf "%s\n" "$lt_cv_deplibs_check_method" >&6; }
 
+file_magic_glob=
+want_nocaseglob=no
+if test "$build" = "$host"; then
+  case $host_os in
+  mingw* | pw32*)
+    if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then
+      want_nocaseglob=yes
+    else
+      file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"`
+    fi
+    ;;
+  esac
+fi
 
+file_magic_cmd=$lt_cv_file_magic_cmd
+deplibs_check_method=$lt_cv_deplibs_check_method
+test -z "$deplibs_check_method" && deplibs_check_method=unknown
 
 
 
 
 
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
 
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
 
-# Allow CC to be a program name with arguments.
-compiler=$CC
 
 
-# Check for command to grab the raw symbol name followed by C symbol from nm.
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5
-printf %s "checking command to parse $NM output from $compiler object... " >&6; }
-if test ${lt_cv_sys_global_symbol_pipe+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
 
-# These are sane defaults that work on at least a few old systems.
-# [They come from Ultrix.  What could be older than Ultrix?!! ;)]
 
-# Character class describing NM global symbol codes.
-symcode='[BCDEGRST]'
 
-# Regexp to match symbols that can be accessed directly from C.
-sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
 
-# Define system-specific variables.
-case $host_os in
-aix*)
-  symcode='[BCDT]'
-  ;;
-cygwin* | mingw* | pw32* | cegcc*)
-  symcode='[ABCDGISTW]'
-  ;;
-hpux*)
-  if test ia64 = "$host_cpu"; then
-    symcode='[ABCDEGRST]'
-  fi
-  ;;
-irix* | nonstopux*)
-  symcode='[BCDEGRST]'
-  ;;
-osf*)
-  symcode='[BCDEGQRST]'
-  ;;
-solaris*)
-  symcode='[BDRT]'
-  ;;
-sco3.2v5*)
-  symcode='[DT]'
-  ;;
-sysv4.2uw2*)
-  symcode='[DT]'
-  ;;
-sysv5* | sco5v6* | unixware* | OpenUNIX*)
-  symcode='[ABDT]'
-  ;;
-sysv4)
-  symcode='[DFNSTU]'
-  ;;
-esac
 
-# If we're using GNU nm, then use its standard symbol codes.
-case `$NM -V 2>&1` in
-*GNU* | *'with BFD'*)
-  symcode='[ABCDGIRSTW]' ;;
-esac
 
-if test "$lt_cv_nm_interface" = "MS dumpbin"; then
-  # Gets list of data symbols to import.
-  lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'"
-  # Adjust the below global symbol transforms to fixup imported variables.
-  lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'"
-  lt_c_name_hook=" -e 's/^I .* \(.*\)$/  {\"\1\", (void *) 0},/p'"
-  lt_c_name_lib_hook="\
-  -e 's/^I .* \(lib.*\)$/  {\"\1\", (void *) 0},/p'\
-  -e 's/^I .* \(.*\)$/  {\"lib\1\", (void *) 0},/p'"
-else
-  # Disable hooks by default.
-  lt_cv_sys_global_symbol_to_import=
-  lt_cdecl_hook=
-  lt_c_name_hook=
-  lt_c_name_lib_hook=
-fi
 
-# Transform an extracted symbol line into a proper C declaration.
-# Some systems (esp. on ia64) link data and code symbols differently,
-# so use this general approach.
-lt_cv_sys_global_symbol_to_cdecl="sed -n"\
-$lt_cdecl_hook\
-" -e 's/^T .* \(.*\)$/extern int \1();/p'"\
-" -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'"
 
-# Transform an extracted symbol line into symbol name and symbol address
-lt_cv_sys_global_symbol_to_c_name_address="sed -n"\
-$lt_c_name_hook\
-" -e 's/^: \(.*\) .*$/  {\"\1\", (void *) 0},/p'"\
-" -e 's/^$symcode$symcode* .* \(.*\)$/  {\"\1\", (void *) \&\1},/p'"
 
-# Transform an extracted symbol line into symbol name with lib prefix and
-# symbol address.
-lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\
-$lt_c_name_lib_hook\
-" -e 's/^: \(.*\) .*$/  {\"\1\", (void *) 0},/p'"\
-" -e 's/^$symcode$symcode* .* \(lib.*\)$/  {\"\1\", (void *) \&\1},/p'"\
-" -e 's/^$symcode$symcode* .* \(.*\)$/  {\"lib\1\", (void *) \&\1},/p'"
 
-# Handle CRLF in mingw tool chain
-opt_cr=
-case $build_os in
-mingw*)
-  opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
-  ;;
-esac
 
-# Try without a prefix underscore, then with it.
-for ac_symprfx in "" "_"; do
 
-  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
-  symxfrm="\\1 $ac_symprfx\\2 \\2"
 
-  # Write the raw and C identifiers.
-  if test "$lt_cv_nm_interface" = "MS dumpbin"; then
-    # Fake it for dumpbin and say T for any non-static function,
-    # D for any global variable and I for any imported variable.
-    # Also find C++ and __fastcall symbols from MSVC++,
-    # which start with @ or ?.
-    lt_cv_sys_global_symbol_pipe="$AWK '"\
-"     {last_section=section; section=\$ 3};"\
-"     /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\
-"     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
-"     /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\
-"     /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\
-"     /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\
-"     \$ 0!~/External *\|/{next};"\
-"     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
-"     {if(hide[section]) next};"\
-"     {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\
-"     {split(\$ 0,a,/\||\r/); split(a[2],s)};"\
-"     s[1]~/^[@?]/{print f,s[1],s[1]; next};"\
-"     s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\
-"     ' prfx=^$ac_symprfx"
-  else
-    lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[	 ]\($symcode$symcode*\)[	 ][	 ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args.
+set dummy ${ac_tool_prefix}dlltool; ac_word=$2
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_DLLTOOL+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  if test -n "$DLLTOOL"; then
+  ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool"
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
+    break 2
   fi
-  lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'"
-
-  # Check to see that the pipe works correctly.
-  pipe_works=no
-
-  rm -f conftest*
-  cat > conftest.$ac_ext <<_LT_EOF
-#ifdef __cplusplus
-extern "C" {
-#endif
-char nm_test_var;
-void nm_test_func(void);
-void nm_test_func(void){}
-#ifdef __cplusplus
-}
-#endif
-int main(){nm_test_var='a';nm_test_func();return(0);}
-_LT_EOF
-
-  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then
-    # Now try to grab the symbols.
-    nlist=conftest.nm
-    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5
-  (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5
-  ac_status=$?
-  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && test -s "$nlist"; then
-      # Try sorting and uniquifying the output.
-      if sort "$nlist" | uniq > "$nlist"T; then
-	mv -f "$nlist"T "$nlist"
-      else
-	rm -f "$nlist"T
-      fi
-
-      # Make sure that we snagged all the symbols we need.
-      if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
-	if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
-	  cat <<_LT_EOF > conftest.$ac_ext
-/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
-#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
-/* DATA imports from DLLs on WIN32 can't be const, because runtime
-   relocations are performed -- see ld's documentation on pseudo-relocs.  */
-# define LT_DLSYM_CONST
-#elif defined __osf__
-/* This system does not cope well with relocations in const data.  */
-# define LT_DLSYM_CONST
-#else
-# define LT_DLSYM_CONST const
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-_LT_EOF
-	  # Now generate the symbol file.
-	  eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
-
-	  cat <<_LT_EOF >> conftest.$ac_ext
-
-/* The mapping between symbol names and symbols.  */
-LT_DLSYM_CONST struct {
-  const char *name;
-  void       *address;
-}
-lt__PROGRAM__LTX_preloaded_symbols[] =
-{
-  { "@PROGRAM@", (void *) 0 },
-_LT_EOF
-	  $SED "s/^$symcode$symcode* .* \(.*\)$/  {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
-	  cat <<\_LT_EOF >> conftest.$ac_ext
-  {0, (void *) 0}
-};
+done
+  done
+IFS=$as_save_IFS
 
-/* This works around a problem in FreeBSD linker */
-#ifdef FREEBSD_WORKAROUND
-static const void *lt_preloaded_setup() {
-  return lt__PROGRAM__LTX_preloaded_symbols;
-}
-#endif
+fi
+fi
+DLLTOOL=$ac_cv_prog_DLLTOOL
+if test -n "$DLLTOOL"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5
+printf "%s\n" "$DLLTOOL" >&6; }
+else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+fi
 
-#ifdef __cplusplus
-}
-#endif
-_LT_EOF
-	  # Now try linking the two files.
-	  mv conftest.$ac_objext conftstm.$ac_objext
-	  lt_globsym_save_LIBS=$LIBS
-	  lt_globsym_save_CFLAGS=$CFLAGS
-	  LIBS=conftstm.$ac_objext
-	  CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag"
-	  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && test -s conftest$ac_exeext; then
-	    pipe_works=yes
-	  fi
-	  LIBS=$lt_globsym_save_LIBS
-	  CFLAGS=$lt_globsym_save_CFLAGS
-	else
-	  echo "cannot find nm_test_func in $nlist" >&5
-	fi
-      else
-	echo "cannot find nm_test_var in $nlist" >&5
-      fi
-    else
-      echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5
-    fi
-  else
-    echo "$progname: failed program was:" >&5
-    cat conftest.$ac_ext >&5
-  fi
-  rm -rf conftest* conftst*
 
-  # Do not use the global_symbol_pipe unless it works.
-  if test yes = "$pipe_works"; then
-    break
-  else
-    lt_cv_sys_global_symbol_pipe=
+fi
+if test -z "$ac_cv_prog_DLLTOOL"; then
+  ac_ct_DLLTOOL=$DLLTOOL
+  # Extract the first word of "dlltool", so it can be a program name with args.
+set dummy dlltool; ac_word=$2
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_DLLTOOL+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  if test -n "$ac_ct_DLLTOOL"; then
+  ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_DLLTOOL="dlltool"
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
+    break 2
   fi
 done
+  done
+IFS=$as_save_IFS
 
 fi
-
-if test -z "$lt_cv_sys_global_symbol_pipe"; then
-  lt_cv_sys_global_symbol_to_cdecl=
 fi
-if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: failed" >&5
-printf "%s\n" "failed" >&6; }
+ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL
+if test -n "$ac_ct_DLLTOOL"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5
+printf "%s\n" "$ac_ct_DLLTOOL" >&6; }
 else
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ok" >&5
-printf "%s\n" "ok" >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
-# Response file support.
-if test "$lt_cv_nm_interface" = "MS dumpbin"; then
-  nm_file_list_spec='@'
-elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then
-  nm_file_list_spec='@'
+  if test "x$ac_ct_DLLTOOL" = x; then
+    DLLTOOL="false"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    DLLTOOL=$ac_ct_DLLTOOL
+  fi
+else
+  DLLTOOL="$ac_cv_prog_DLLTOOL"
 fi
 
+test -z "$DLLTOOL" && DLLTOOL=dlltool
 
 
 
@@ -18060,8 +18381,38 @@ fi
 
 
 
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5
+printf %s "checking how to associate runtime and link libraries... " >&6; }
+if test ${lt_cv_sharedlib_from_linklib_cmd+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  lt_cv_sharedlib_from_linklib_cmd='unknown'
 
+case $host_os in
+cygwin* | mingw* | pw32* | cegcc*)
+  # two different shell functions defined in ltmain.sh;
+  # decide which one to use based on capabilities of $DLLTOOL
+  case `$DLLTOOL --help 2>&1` in
+  *--identify-strict*)
+    lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib
+    ;;
+  *)
+    lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback
+    ;;
+  esac
+  ;;
+*)
+  # fallback: assume linklib IS sharedlib
+  lt_cv_sharedlib_from_linklib_cmd=$ECHO
+  ;;
+esac
 
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5
+printf "%s\n" "$lt_cv_sharedlib_from_linklib_cmd" >&6; }
+sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd
+test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO
 
 
 
@@ -18069,74 +18420,70 @@ fi
 
 
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5
-printf %s "checking for sysroot... " >&6; }
-
-# Check whether --with-sysroot was given.
-if test ${with_sysroot+y}
+if test -n "$ac_tool_prefix"; then
+  for ac_prog in ar
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_AR+y}
 then :
-  withval=$with_sysroot;
+  printf %s "(cached) " >&6
 else $as_nop
-  with_sysroot=no
-fi
-
-
-lt_sysroot=
-case $with_sysroot in #(
- yes)
-   if test yes = "$GCC"; then
-     lt_sysroot=`$CC --print-sysroot 2>/dev/null`
-   fi
-   ;; #(
- /*)
-   lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"`
-   ;; #(
- no|'')
-   ;; #(
- *)
-   { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_sysroot" >&5
-printf "%s\n" "$with_sysroot" >&6; }
-   as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5
-   ;;
-esac
-
- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5
-printf "%s\n" "${lt_sysroot:-no}" >&6; }
-
-
+  if test -n "$AR"; then
+  ac_cv_prog_AR="$AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_prog_AR="$ac_tool_prefix$ac_prog"
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
 
+fi
+fi
+AR=$ac_cv_prog_AR
+if test -n "$AR"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
+printf "%s\n" "$AR" >&6; }
+else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+fi
 
 
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a working dd" >&5
-printf %s "checking for a working dd... " >&6; }
-if test ${ac_cv_path_lt_DD+y}
+    test -n "$AR" && break
+  done
+fi
+if test -z "$AR"; then
+  ac_ct_AR=$AR
+  for ac_prog in ar
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_AR+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  printf 0123456789abcdef0123456789abcdef >conftest.i
-cat conftest.i conftest.i >conftest2.i
-: ${lt_DD:=$DD}
-if test -z "$lt_DD"; then
-  ac_path_lt_DD_found=false
-  # Loop through the user's path and test for each of PROGNAME-LIST
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+  if test -n "$ac_ct_AR"; then
+  ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
@@ -18145,349 +18492,128 @@ do
     */) ;;
     *) as_dir=$as_dir/ ;;
   esac
-    for ac_prog in dd
-   do
     for ac_exec_ext in '' $ac_executable_extensions; do
-      ac_path_lt_DD="$as_dir$ac_prog$ac_exec_ext"
-      as_fn_executable_p "$ac_path_lt_DD" || continue
-if "$ac_path_lt_DD" bs=32 count=1 <conftest2.i >conftest.out 2>/dev/null; then
-  cmp -s conftest.i conftest.out \
-  && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=:
-fi
-      $ac_path_lt_DD_found && break 3
-    done
-  done
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_AR="$ac_prog"
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
   done
 IFS=$as_save_IFS
-  if test -z "$ac_cv_path_lt_DD"; then
-    :
-  fi
+
+fi
+fi
+ac_ct_AR=$ac_cv_prog_ac_ct_AR
+if test -n "$ac_ct_AR"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
+printf "%s\n" "$ac_ct_AR" >&6; }
 else
-  ac_cv_path_lt_DD=$lt_DD
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
-rm -f conftest.i conftest2.i conftest.out
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_lt_DD" >&5
-printf "%s\n" "$ac_cv_path_lt_DD" >&6; }
 
+  test -n "$ac_ct_AR" && break
+done
 
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to truncate binary pipes" >&5
-printf %s "checking how to truncate binary pipes... " >&6; }
-if test ${lt_cv_truncate_bin+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  printf 0123456789abcdef0123456789abcdef >conftest.i
-cat conftest.i conftest.i >conftest2.i
-lt_cv_truncate_bin=
-if "$ac_cv_path_lt_DD" bs=32 count=1 <conftest2.i >conftest.out 2>/dev/null; then
-  cmp -s conftest.i conftest.out \
-  && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1"
-fi
-rm -f conftest.i conftest2.i conftest.out
-test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q"
+  if test "x$ac_ct_AR" = x; then
+    AR="false"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    AR=$ac_ct_AR
+  fi
 fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_truncate_bin" >&5
-printf "%s\n" "$lt_cv_truncate_bin" >&6; }
 
+: ${AR=ar}
+: ${AR_FLAGS=cru}
 
 
 
 
 
 
-# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
-func_cc_basename ()
-{
-    for cc_temp in $*""; do
-      case $cc_temp in
-        compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-        distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-        \-*) ;;
-        *) break;;
-      esac
-    done
-    func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
-}
 
-# Check whether --enable-libtool-lock was given.
-if test ${enable_libtool_lock+y}
+
+
+
+
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5
+printf %s "checking for archiver @FILE support... " >&6; }
+if test ${lt_cv_ar_at_file+y}
 then :
-  enableval=$enable_libtool_lock;
-fi
+  printf %s "(cached) " >&6
+else $as_nop
+  lt_cv_ar_at_file=no
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
-test no = "$enable_libtool_lock" || enable_libtool_lock=yes
+int
+main (void)
+{
 
-# Some flags need to be propagated to the compiler or linker for good
-# libtool support.
-case $host in
-ia64-*-hpux*)
-  # Find out what ABI is being produced by ac_compile, and set mode
-  # options accordingly.
-  echo 'int i;' > conftest.$ac_ext
-  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
-  (eval $ac_compile) 2>&5
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+  echo conftest.$ac_objext > conftest.lst
+      lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5'
+      { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5
+  (eval $lt_ar_try) 2>&5
   ac_status=$?
   printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then
-    case `/usr/bin/file conftest.$ac_objext` in
-      *ELF-32*)
-	HPUX_IA64_MODE=32
-	;;
-      *ELF-64*)
-	HPUX_IA64_MODE=64
-	;;
-    esac
-  fi
-  rm -rf conftest*
-  ;;
-*-*-irix6*)
-  # Find out what ABI is being produced by ac_compile, and set linker
-  # options accordingly.
-  echo '#line '$LINENO' "configure"' > conftest.$ac_ext
-  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
-  (eval $ac_compile) 2>&5
+  test $ac_status = 0; }
+      if test 0 -eq "$ac_status"; then
+	# Ensure the archiver fails upon bogus file names.
+	rm -f conftest.$ac_objext libconftest.a
+	{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5
+  (eval $lt_ar_try) 2>&5
   ac_status=$?
   printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then
-    if test yes = "$lt_cv_prog_gnu_ld"; then
-      case `/usr/bin/file conftest.$ac_objext` in
-	*32-bit*)
-	  LD="${LD-ld} -melf32bsmip"
-	  ;;
-	*N32*)
-	  LD="${LD-ld} -melf32bmipn32"
-	  ;;
-	*64-bit*)
-	  LD="${LD-ld} -melf64bmip"
-	;;
-      esac
-    else
-      case `/usr/bin/file conftest.$ac_objext` in
-	*32-bit*)
-	  LD="${LD-ld} -32"
-	  ;;
-	*N32*)
-	  LD="${LD-ld} -n32"
-	  ;;
-	*64-bit*)
-	  LD="${LD-ld} -64"
-	  ;;
-      esac
-    fi
-  fi
-  rm -rf conftest*
-  ;;
+  test $ac_status = 0; }
+	if test 0 -ne "$ac_status"; then
+          lt_cv_ar_at_file=@
+        fi
+      fi
+      rm -f conftest.* libconftest.a
 
-mips64*-*linux*)
-  # Find out what ABI is being produced by ac_compile, and set linker
-  # options accordingly.
-  echo '#line '$LINENO' "configure"' > conftest.$ac_ext
-  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then
-    emul=elf
-    case `/usr/bin/file conftest.$ac_objext` in
-      *32-bit*)
-	emul="${emul}32"
-	;;
-      *64-bit*)
-	emul="${emul}64"
-	;;
-    esac
-    case `/usr/bin/file conftest.$ac_objext` in
-      *MSB*)
-	emul="${emul}btsmip"
-	;;
-      *LSB*)
-	emul="${emul}ltsmip"
-	;;
-    esac
-    case `/usr/bin/file conftest.$ac_objext` in
-      *N32*)
-	emul="${emul}n32"
-	;;
-    esac
-    LD="${LD-ld} -m $emul"
-  fi
-  rm -rf conftest*
-  ;;
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
-s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
-  # Find out what ABI is being produced by ac_compile, and set linker
-  # options accordingly.  Note that the listed cases only cover the
-  # situations where additional linker options are needed (such as when
-  # doing 32-bit compilation for a host where ld defaults to 64-bit, or
-  # vice versa); the common cases where no linker options are needed do
-  # not appear in the list.
-  echo 'int i;' > conftest.$ac_ext
-  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then
-    case `/usr/bin/file conftest.o` in
-      *32-bit*)
-	case $host in
-	  x86_64-*kfreebsd*-gnu)
-	    LD="${LD-ld} -m elf_i386_fbsd"
-	    ;;
-	  x86_64-*linux*)
-	    case `/usr/bin/file conftest.o` in
-	      *x86-64*)
-		LD="${LD-ld} -m elf32_x86_64"
-		;;
-	      *)
-		LD="${LD-ld} -m elf_i386"
-		;;
-	    esac
-	    ;;
-	  powerpc64le-*linux*)
-	    LD="${LD-ld} -m elf32lppclinux"
-	    ;;
-	  powerpc64-*linux*)
-	    LD="${LD-ld} -m elf32ppclinux"
-	    ;;
-	  s390x-*linux*)
-	    LD="${LD-ld} -m elf_s390"
-	    ;;
-	  sparc64-*linux*)
-	    LD="${LD-ld} -m elf32_sparc"
-	    ;;
-	esac
-	;;
-      *64-bit*)
-	case $host in
-	  x86_64-*kfreebsd*-gnu)
-	    LD="${LD-ld} -m elf_x86_64_fbsd"
-	    ;;
-	  x86_64-*linux*)
-	    LD="${LD-ld} -m elf_x86_64"
-	    ;;
-	  powerpcle-*linux*)
-	    LD="${LD-ld} -m elf64lppc"
-	    ;;
-	  powerpc-*linux*)
-	    LD="${LD-ld} -m elf64ppc"
-	    ;;
-	  s390*-*linux*|s390*-*tpf*)
-	    LD="${LD-ld} -m elf64_s390"
-	    ;;
-	  sparc*-*linux*)
-	    LD="${LD-ld} -m elf64_sparc"
-	    ;;
-	esac
-	;;
-    esac
-  fi
-  rm -rf conftest*
-  ;;
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5
+printf "%s\n" "$lt_cv_ar_at_file" >&6; }
+
+if test no = "$lt_cv_ar_at_file"; then
+  archiver_list_spec=
+else
+  archiver_list_spec=$lt_cv_ar_at_file
+fi
 
-*-*-sco3.2v5*)
-  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
-  SAVE_CFLAGS=$CFLAGS
-  CFLAGS="$CFLAGS -belf"
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5
-printf %s "checking whether the C compiler needs -belf... " >&6; }
-if test ${lt_cv_cc_needs_belf+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
 
-int
-main (void)
-{
 
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"
-then :
-  lt_cv_cc_needs_belf=yes
-else $as_nop
-  lt_cv_cc_needs_belf=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam \
-    conftest$ac_exeext conftest.$ac_ext
-     ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5
-printf "%s\n" "$lt_cv_cc_needs_belf" >&6; }
-  if test yes != "$lt_cv_cc_needs_belf"; then
-    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
-    CFLAGS=$SAVE_CFLAGS
-  fi
-  ;;
-*-*solaris*)
-  # Find out what ABI is being produced by ac_compile, and set linker
-  # options accordingly.
-  echo 'int i;' > conftest.$ac_ext
-  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then
-    case `/usr/bin/file conftest.o` in
-    *64-bit*)
-      case $lt_cv_prog_gnu_ld in
-      yes*)
-        case $host in
-        i?86-*-solaris*|x86_64-*-solaris*)
-          LD="${LD-ld} -m elf_x86_64"
-          ;;
-        sparc*-*-solaris*)
-          LD="${LD-ld} -m elf64_sparc"
-          ;;
-        esac
-        # GNU ld 2.21 introduced _sol2 emulations.  Use them if available.
-        if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then
-          LD=${LD-ld}_sol2
-        fi
-        ;;
-      *)
-	if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
-	  LD="${LD-ld} -64"
-	fi
-	;;
-      esac
-      ;;
-    esac
-  fi
-  rm -rf conftest*
-  ;;
-esac
 
-need_locks=$enable_libtool_lock
 
 if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args.
-set dummy ${ac_tool_prefix}mt; ac_word=$2
+  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 printf %s "checking for $ac_word... " >&6; }
-if test ${ac_cv_prog_MANIFEST_TOOL+y}
+if test ${ac_cv_prog_STRIP+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  if test -n "$MANIFEST_TOOL"; then
-  ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test.
+  if test -n "$STRIP"; then
+  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
@@ -18500,7 +18626,7 @@ do
   esac
     for ac_exec_ext in '' $ac_executable_extensions; do
   if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
-    ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt"
+    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
     printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
@@ -18510,10 +18636,10 @@ IFS=$as_save_IFS
 
 fi
 fi
-MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL
-if test -n "$MANIFEST_TOOL"; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5
-printf "%s\n" "$MANIFEST_TOOL" >&6; }
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
+printf "%s\n" "$STRIP" >&6; }
 else
   { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
 printf "%s\n" "no" >&6; }
@@ -18521,18 +18647,18 @@ fi
 
 
 fi
-if test -z "$ac_cv_prog_MANIFEST_TOOL"; then
-  ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL
-  # Extract the first word of "mt", so it can be a program name with args.
-set dummy mt; ac_word=$2
+if test -z "$ac_cv_prog_STRIP"; then
+  ac_ct_STRIP=$STRIP
+  # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 printf %s "checking for $ac_word... " >&6; }
-if test ${ac_cv_prog_ac_ct_MANIFEST_TOOL+y}
+if test ${ac_cv_prog_ac_ct_STRIP+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  if test -n "$ac_ct_MANIFEST_TOOL"; then
-  ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test.
+  if test -n "$ac_ct_STRIP"; then
+  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
@@ -18545,7 +18671,7 @@ do
   esac
     for ac_exec_ext in '' $ac_executable_extensions; do
   if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_MANIFEST_TOOL="mt"
+    ac_cv_prog_ac_ct_STRIP="strip"
     printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
@@ -18555,17 +18681,17 @@ IFS=$as_save_IFS
 
 fi
 fi
-ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL
-if test -n "$ac_ct_MANIFEST_TOOL"; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5
-printf "%s\n" "$ac_ct_MANIFEST_TOOL" >&6; }
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
+printf "%s\n" "$ac_ct_STRIP" >&6; }
 else
   { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
 printf "%s\n" "no" >&6; }
 fi
 
-  if test "x$ac_ct_MANIFEST_TOOL" = x; then
-    MANIFEST_TOOL=":"
+  if test "x$ac_ct_STRIP" = x; then
+    STRIP=":"
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
@@ -18573,52 +18699,30 @@ yes:)
 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
-    MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL
+    STRIP=$ac_ct_STRIP
   fi
 else
-  MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL"
+  STRIP="$ac_cv_prog_STRIP"
 fi
 
-test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5
-printf %s "checking if $MANIFEST_TOOL is a manifest tool... " >&6; }
-if test ${lt_cv_path_mainfest_tool+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  lt_cv_path_mainfest_tool=no
-  echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5
-  $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out
-  cat conftest.err >&5
-  if $GREP 'Manifest Tool' conftest.out > /dev/null; then
-    lt_cv_path_mainfest_tool=yes
-  fi
-  rm -f conftest*
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5
-printf "%s\n" "$lt_cv_path_mainfest_tool" >&6; }
-if test yes != "$lt_cv_path_mainfest_tool"; then
-  MANIFEST_TOOL=:
-fi
+test -z "$STRIP" && STRIP=:
 
 
 
 
 
 
-  case $host_os in
-    rhapsody* | darwin*)
-    if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args.
-set dummy ${ac_tool_prefix}dsymutil; ac_word=$2
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ranlib; ac_word=$2
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 printf %s "checking for $ac_word... " >&6; }
-if test ${ac_cv_prog_DSYMUTIL+y}
+if test ${ac_cv_prog_RANLIB+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  if test -n "$DSYMUTIL"; then
-  ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test.
+  if test -n "$RANLIB"; then
+  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
@@ -18631,7 +18735,7 @@ do
   esac
     for ac_exec_ext in '' $ac_executable_extensions; do
   if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
-    ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil"
+    ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
     printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
@@ -18641,10 +18745,10 @@ IFS=$as_save_IFS
 
 fi
 fi
-DSYMUTIL=$ac_cv_prog_DSYMUTIL
-if test -n "$DSYMUTIL"; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5
-printf "%s\n" "$DSYMUTIL" >&6; }
+RANLIB=$ac_cv_prog_RANLIB
+if test -n "$RANLIB"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
+printf "%s\n" "$RANLIB" >&6; }
 else
   { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
 printf "%s\n" "no" >&6; }
@@ -18652,18 +18756,18 @@ fi
 
 
 fi
-if test -z "$ac_cv_prog_DSYMUTIL"; then
-  ac_ct_DSYMUTIL=$DSYMUTIL
-  # Extract the first word of "dsymutil", so it can be a program name with args.
-set dummy dsymutil; ac_word=$2
+if test -z "$ac_cv_prog_RANLIB"; then
+  ac_ct_RANLIB=$RANLIB
+  # Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 printf %s "checking for $ac_word... " >&6; }
-if test ${ac_cv_prog_ac_ct_DSYMUTIL+y}
+if test ${ac_cv_prog_ac_ct_RANLIB+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  if test -n "$ac_ct_DSYMUTIL"; then
-  ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test.
+  if test -n "$ac_ct_RANLIB"; then
+  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
@@ -18676,7 +18780,7 @@ do
   esac
     for ac_exec_ext in '' $ac_executable_extensions; do
   if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_DSYMUTIL="dsymutil"
+    ac_cv_prog_ac_ct_RANLIB="ranlib"
     printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
     break 2
   fi
@@ -18686,17 +18790,17 @@ IFS=$as_save_IFS
 
 fi
 fi
-ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL
-if test -n "$ac_ct_DSYMUTIL"; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5
-printf "%s\n" "$ac_ct_DSYMUTIL" >&6; }
+ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
+if test -n "$ac_ct_RANLIB"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
+printf "%s\n" "$ac_ct_RANLIB" >&6; }
 else
   { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
 printf "%s\n" "no" >&6; }
 fi
 
-  if test "x$ac_ct_DSYMUTIL" = x; then
-    DSYMUTIL=":"
+  if test "x$ac_ct_RANLIB" = x; then
+    RANLIB=":"
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
@@ -18704,669 +18808,391 @@ yes:)
 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
-    DSYMUTIL=$ac_ct_DSYMUTIL
+    RANLIB=$ac_ct_RANLIB
   fi
 else
-  DSYMUTIL="$ac_cv_prog_DSYMUTIL"
+  RANLIB="$ac_cv_prog_RANLIB"
 fi
 
-    if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args.
-set dummy ${ac_tool_prefix}nmedit; ac_word=$2
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-printf %s "checking for $ac_word... " >&6; }
-if test ${ac_cv_prog_NMEDIT+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  if test -n "$NMEDIT"; then
-  ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  case $as_dir in #(((
-    '') as_dir=./ ;;
-    */) ;;
-    *) as_dir=$as_dir/ ;;
-  esac
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
-    ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit"
-    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+test -z "$RANLIB" && RANLIB=:
 
-fi
-fi
-NMEDIT=$ac_cv_prog_NMEDIT
-if test -n "$NMEDIT"; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5
-printf "%s\n" "$NMEDIT" >&6; }
-else
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
-printf "%s\n" "no" >&6; }
-fi
 
 
-fi
-if test -z "$ac_cv_prog_NMEDIT"; then
-  ac_ct_NMEDIT=$NMEDIT
-  # Extract the first word of "nmedit", so it can be a program name with args.
-set dummy nmedit; ac_word=$2
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-printf %s "checking for $ac_word... " >&6; }
-if test ${ac_cv_prog_ac_ct_NMEDIT+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  if test -n "$ac_ct_NMEDIT"; then
-  ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  case $as_dir in #(((
-    '') as_dir=./ ;;
-    */) ;;
-    *) as_dir=$as_dir/ ;;
-  esac
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_NMEDIT="nmedit"
-    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
 
-fi
-fi
-ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT
-if test -n "$ac_ct_NMEDIT"; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5
-printf "%s\n" "$ac_ct_NMEDIT" >&6; }
-else
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
-printf "%s\n" "no" >&6; }
+
+
+# Determine commands to create old-style static archives.
+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
+old_postinstall_cmds='chmod 644 $oldlib'
+old_postuninstall_cmds=
+
+if test -n "$RANLIB"; then
+  case $host_os in
+  bitrig* | openbsd*)
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib"
+    ;;
+  *)
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib"
+    ;;
+  esac
+  old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib"
 fi
 
-  if test "x$ac_ct_NMEDIT" = x; then
-    NMEDIT=":"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
+case $host_os in
+  darwin*)
+    lock_old_archive_extraction=yes ;;
+  *)
+    lock_old_archive_extraction=no ;;
 esac
-    NMEDIT=$ac_ct_NMEDIT
-  fi
-else
-  NMEDIT="$ac_cv_prog_NMEDIT"
-fi
 
-    if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args.
-set dummy ${ac_tool_prefix}lipo; ac_word=$2
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-printf %s "checking for $ac_word... " >&6; }
-if test ${ac_cv_prog_LIPO+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  if test -n "$LIPO"; then
-  ac_cv_prog_LIPO="$LIPO" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  case $as_dir in #(((
-    '') as_dir=./ ;;
-    */) ;;
-    *) as_dir=$as_dir/ ;;
-  esac
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
-    ac_cv_prog_LIPO="${ac_tool_prefix}lipo"
-    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
 
-fi
-fi
-LIPO=$ac_cv_prog_LIPO
-if test -n "$LIPO"; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5
-printf "%s\n" "$LIPO" >&6; }
-else
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
-printf "%s\n" "no" >&6; }
-fi
 
 
-fi
-if test -z "$ac_cv_prog_LIPO"; then
-  ac_ct_LIPO=$LIPO
-  # Extract the first word of "lipo", so it can be a program name with args.
-set dummy lipo; ac_word=$2
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-printf %s "checking for $ac_word... " >&6; }
-if test ${ac_cv_prog_ac_ct_LIPO+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  if test -n "$ac_ct_LIPO"; then
-  ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  case $as_dir in #(((
-    '') as_dir=./ ;;
-    */) ;;
-    *) as_dir=$as_dir/ ;;
-  esac
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_LIPO="lipo"
-    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
 
-fi
-fi
-ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO
-if test -n "$ac_ct_LIPO"; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5
-printf "%s\n" "$ac_ct_LIPO" >&6; }
-else
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
-printf "%s\n" "no" >&6; }
-fi
 
-  if test "x$ac_ct_LIPO" = x; then
-    LIPO=":"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    LIPO=$ac_ct_LIPO
-  fi
-else
-  LIPO="$ac_cv_prog_LIPO"
-fi
 
-    if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args.
-set dummy ${ac_tool_prefix}otool; ac_word=$2
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-printf %s "checking for $ac_word... " >&6; }
-if test ${ac_cv_prog_OTOOL+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  if test -n "$OTOOL"; then
-  ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  case $as_dir in #(((
-    '') as_dir=./ ;;
-    */) ;;
-    *) as_dir=$as_dir/ ;;
-  esac
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
-    ac_cv_prog_OTOOL="${ac_tool_prefix}otool"
-    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
 
-fi
-fi
-OTOOL=$ac_cv_prog_OTOOL
-if test -n "$OTOOL"; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5
-printf "%s\n" "$OTOOL" >&6; }
-else
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
-printf "%s\n" "no" >&6; }
-fi
 
 
-fi
-if test -z "$ac_cv_prog_OTOOL"; then
-  ac_ct_OTOOL=$OTOOL
-  # Extract the first word of "otool", so it can be a program name with args.
-set dummy otool; ac_word=$2
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-printf %s "checking for $ac_word... " >&6; }
-if test ${ac_cv_prog_ac_ct_OTOOL+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  if test -n "$ac_ct_OTOOL"; then
-  ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  case $as_dir in #(((
-    '') as_dir=./ ;;
-    */) ;;
-    *) as_dir=$as_dir/ ;;
-  esac
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_OTOOL="otool"
-    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
 
-fi
-fi
-ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL
-if test -n "$ac_ct_OTOOL"; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5
-printf "%s\n" "$ac_ct_OTOOL" >&6; }
-else
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
-printf "%s\n" "no" >&6; }
-fi
 
-  if test "x$ac_ct_OTOOL" = x; then
-    OTOOL=":"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    OTOOL=$ac_ct_OTOOL
-  fi
-else
-  OTOOL="$ac_cv_prog_OTOOL"
-fi
 
-    if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args.
-set dummy ${ac_tool_prefix}otool64; ac_word=$2
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-printf %s "checking for $ac_word... " >&6; }
-if test ${ac_cv_prog_OTOOL64+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  if test -n "$OTOOL64"; then
-  ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  case $as_dir in #(((
-    '') as_dir=./ ;;
-    */) ;;
-    *) as_dir=$as_dir/ ;;
-  esac
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
-    ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64"
-    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
 
-fi
-fi
-OTOOL64=$ac_cv_prog_OTOOL64
-if test -n "$OTOOL64"; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5
-printf "%s\n" "$OTOOL64" >&6; }
-else
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
-printf "%s\n" "no" >&6; }
-fi
 
 
-fi
-if test -z "$ac_cv_prog_OTOOL64"; then
-  ac_ct_OTOOL64=$OTOOL64
-  # Extract the first word of "otool64", so it can be a program name with args.
-set dummy otool64; ac_word=$2
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-printf %s "checking for $ac_word... " >&6; }
-if test ${ac_cv_prog_ac_ct_OTOOL64+y}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5
+printf %s "checking command to parse $NM output from $compiler object... " >&6; }
+if test ${lt_cv_sys_global_symbol_pipe+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  if test -n "$ac_ct_OTOOL64"; then
-  ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  case $as_dir in #(((
-    '') as_dir=./ ;;
-    */) ;;
-    *) as_dir=$as_dir/ ;;
-  esac
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_OTOOL64="otool64"
-    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64
-if test -n "$ac_ct_OTOOL64"; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5
-printf "%s\n" "$ac_ct_OTOOL64" >&6; }
-else
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
-printf "%s\n" "no" >&6; }
-fi
-
-  if test "x$ac_ct_OTOOL64" = x; then
-    OTOOL64=":"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    OTOOL64=$ac_ct_OTOOL64
-  fi
-else
-  OTOOL64="$ac_cv_prog_OTOOL64"
-fi
-
-
-
-
 
+# These are sane defaults that work on at least a few old systems.
+# [They come from Ultrix.  What could be older than Ultrix?!! ;)]
 
+# Character class describing NM global symbol codes.
+symcode='[BCDEGRST]'
 
+# Regexp to match symbols that can be accessed directly from C.
+sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
 
+# Define system-specific variables.
+case $host_os in
+aix*)
+  symcode='[BCDT]'
+  ;;
+cygwin* | mingw* | pw32* | cegcc*)
+  symcode='[ABCDGISTW]'
+  ;;
+hpux*)
+  if test ia64 = "$host_cpu"; then
+    symcode='[ABCDEGRST]'
+  fi
+  ;;
+irix* | nonstopux*)
+  symcode='[BCDEGRST]'
+  ;;
+osf*)
+  symcode='[BCDEGQRST]'
+  ;;
+solaris*)
+  symcode='[BDRT]'
+  ;;
+sco3.2v5*)
+  symcode='[DT]'
+  ;;
+sysv4.2uw2*)
+  symcode='[DT]'
+  ;;
+sysv5* | sco5v6* | unixware* | OpenUNIX*)
+  symcode='[ABDT]'
+  ;;
+sysv4)
+  symcode='[DFNSTU]'
+  ;;
+esac
 
+# If we're using GNU nm, then use its standard symbol codes.
+case `$NM -V 2>&1` in
+*GNU* | *'with BFD'*)
+  symcode='[ABCDGIRSTW]' ;;
+esac
 
+if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+  # Gets list of data symbols to import.
+  lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'"
+  # Adjust the below global symbol transforms to fixup imported variables.
+  lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'"
+  lt_c_name_hook=" -e 's/^I .* \(.*\)$/  {\"\1\", (void *) 0},/p'"
+  lt_c_name_lib_hook="\
+  -e 's/^I .* \(lib.*\)$/  {\"\1\", (void *) 0},/p'\
+  -e 's/^I .* \(.*\)$/  {\"lib\1\", (void *) 0},/p'"
+else
+  # Disable hooks by default.
+  lt_cv_sys_global_symbol_to_import=
+  lt_cdecl_hook=
+  lt_c_name_hook=
+  lt_c_name_lib_hook=
+fi
 
+# Transform an extracted symbol line into a proper C declaration.
+# Some systems (esp. on ia64) link data and code symbols differently,
+# so use this general approach.
+lt_cv_sys_global_symbol_to_cdecl="sed -n"\
+$lt_cdecl_hook\
+" -e 's/^T .* \(.*\)$/extern int \1();/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'"
 
+# Transform an extracted symbol line into symbol name and symbol address
+lt_cv_sys_global_symbol_to_c_name_address="sed -n"\
+$lt_c_name_hook\
+" -e 's/^: \(.*\) .*$/  {\"\1\", (void *) 0},/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/  {\"\1\", (void *) \&\1},/p'"
 
+# Transform an extracted symbol line into symbol name with lib prefix and
+# symbol address.
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\
+$lt_c_name_lib_hook\
+" -e 's/^: \(.*\) .*$/  {\"\1\", (void *) 0},/p'"\
+" -e 's/^$symcode$symcode* .* \(lib.*\)$/  {\"\1\", (void *) \&\1},/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/  {\"lib\1\", (void *) \&\1},/p'"
 
+# Handle CRLF in mingw tool chain
+opt_cr=
+case $build_os in
+mingw*)
+  opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
+  ;;
+esac
 
+# Try without a prefix underscore, then with it.
+for ac_symprfx in "" "_"; do
 
+  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
+  symxfrm="\\1 $ac_symprfx\\2 \\2"
 
+  # Write the raw and C identifiers.
+  if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+    # Fake it for dumpbin and say T for any non-static function,
+    # D for any global variable and I for any imported variable.
+    # Also find C++ and __fastcall symbols from MSVC++,
+    # which start with @ or ?.
+    lt_cv_sys_global_symbol_pipe="$AWK '"\
+"     {last_section=section; section=\$ 3};"\
+"     /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\
+"     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
+"     /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\
+"     /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\
+"     /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\
+"     \$ 0!~/External *\|/{next};"\
+"     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
+"     {if(hide[section]) next};"\
+"     {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\
+"     {split(\$ 0,a,/\||\r/); split(a[2],s)};"\
+"     s[1]~/^[@?]/{print f,s[1],s[1]; next};"\
+"     s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\
+"     ' prfx=^$ac_symprfx"
+  else
+    lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[	 ]\($symcode$symcode*\)[	 ][	 ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+  fi
+  lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'"
 
+  # Check to see that the pipe works correctly.
+  pipe_works=no
 
+  rm -f conftest*
+  cat > conftest.$ac_ext <<_LT_EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(void);
+void nm_test_func(void){}
+#ifdef __cplusplus
+}
+#endif
+int main(){nm_test_var='a';nm_test_func();return(0);}
+_LT_EOF
 
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    # Now try to grab the symbols.
+    nlist=conftest.nm
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5
+  (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5
+  ac_status=$?
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s "$nlist"; then
+      # Try sorting and uniquifying the output.
+      if sort "$nlist" | uniq > "$nlist"T; then
+	mv -f "$nlist"T "$nlist"
+      else
+	rm -f "$nlist"T
+      fi
 
+      # Make sure that we snagged all the symbols we need.
+      if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
+	if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
+	  cat <<_LT_EOF > conftest.$ac_ext
+/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
+#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
+/* DATA imports from DLLs on WIN32 can't be const, because runtime
+   relocations are performed -- see ld's documentation on pseudo-relocs.  */
+# define LT_DLSYM_CONST
+#elif defined __osf__
+/* This system does not cope well with relocations in const data.  */
+# define LT_DLSYM_CONST
+#else
+# define LT_DLSYM_CONST const
+#endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 
+_LT_EOF
+	  # Now generate the symbol file.
+	  eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
 
+	  cat <<_LT_EOF >> conftest.$ac_ext
 
+/* The mapping between symbol names and symbols.  */
+LT_DLSYM_CONST struct {
+  const char *name;
+  void       *address;
+}
+lt__PROGRAM__LTX_preloaded_symbols[] =
+{
+  { "@PROGRAM@", (void *) 0 },
+_LT_EOF
+	  $SED "s/^$symcode$symcode* .* \(.*\)$/  {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
+	  cat <<\_LT_EOF >> conftest.$ac_ext
+  {0, (void *) 0}
+};
 
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+  return lt__PROGRAM__LTX_preloaded_symbols;
+}
+#endif
 
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5
-printf %s "checking for -single_module linker flag... " >&6; }
-if test ${lt_cv_apple_cc_single_mod+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  lt_cv_apple_cc_single_mod=no
-      if test -z "$LT_MULTI_MODULE"; then
-	# By default we will add the -single_module flag. You can override
-	# by either setting the environment variable LT_MULTI_MODULE
-	# non-empty at configure time, or by adding -multi_module to the
-	# link flags.
-	rm -rf libconftest.dylib*
-	echo "int foo(void){return 1;}" > conftest.c
-	echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
--dynamiclib -Wl,-single_module conftest.c" >&5
-	$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
-	  -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
-        _lt_result=$?
-	# If there is a non-empty error log, and "single_module"
-	# appears in it, assume the flag caused a linker warning
-        if test -s conftest.err && $GREP single_module conftest.err; then
-	  cat conftest.err >&5
-	# Otherwise, if the output was created with a 0 exit code from
-	# the compiler, it worked.
-	elif test -f libconftest.dylib && test 0 = "$_lt_result"; then
-	  lt_cv_apple_cc_single_mod=yes
+#ifdef __cplusplus
+}
+#endif
+_LT_EOF
+	  # Now try linking the two files.
+	  mv conftest.$ac_objext conftstm.$ac_objext
+	  lt_globsym_save_LIBS=$LIBS
+	  lt_globsym_save_CFLAGS=$CFLAGS
+	  LIBS=conftstm.$ac_objext
+	  CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag"
+	  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest$ac_exeext; then
+	    pipe_works=yes
+	  fi
+	  LIBS=$lt_globsym_save_LIBS
+	  CFLAGS=$lt_globsym_save_CFLAGS
 	else
-	  cat conftest.err >&5
+	  echo "cannot find nm_test_func in $nlist" >&5
 	fi
-	rm -rf libconftest.dylib*
-	rm -f conftest.*
+      else
+	echo "cannot find nm_test_var in $nlist" >&5
       fi
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5
-printf "%s\n" "$lt_cv_apple_cc_single_mod" >&6; }
+    else
+      echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5
+    fi
+  else
+    echo "$progname: failed program was:" >&5
+    cat conftest.$ac_ext >&5
+  fi
+  rm -rf conftest* conftst*
 
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5
-printf %s "checking for -exported_symbols_list linker flag... " >&6; }
-if test ${lt_cv_ld_exported_symbols_list+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  lt_cv_ld_exported_symbols_list=no
-      save_LDFLAGS=$LDFLAGS
-      echo "_main" > conftest.sym
-      LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
-      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
+  # Do not use the global_symbol_pipe unless it works.
+  if test yes = "$pipe_works"; then
+    break
+  else
+    lt_cv_sys_global_symbol_pipe=
+  fi
+done
 
-int
-main (void)
-{
+fi
 
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"
-then :
-  lt_cv_ld_exported_symbols_list=yes
-else $as_nop
-  lt_cv_ld_exported_symbols_list=no
+if test -z "$lt_cv_sys_global_symbol_pipe"; then
+  lt_cv_sys_global_symbol_to_cdecl=
+fi
+if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: failed" >&5
+printf "%s\n" "failed" >&6; }
+else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ok" >&5
+printf "%s\n" "ok" >&6; }
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam \
-    conftest$ac_exeext conftest.$ac_ext
-	LDFLAGS=$save_LDFLAGS
 
+# Response file support.
+if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+  nm_file_list_spec='@'
+elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then
+  nm_file_list_spec='@'
 fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5
-printf "%s\n" "$lt_cv_ld_exported_symbols_list" >&6; }
 
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5
-printf %s "checking for -force_load linker flag... " >&6; }
-if test ${lt_cv_ld_force_load+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  lt_cv_ld_force_load=no
-      cat > conftest.c << _LT_EOF
-int forced_loaded() { return 2;}
-_LT_EOF
-      echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5
-      $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5
-      echo "$AR cru libconftest.a conftest.o" >&5
-      $AR cru libconftest.a conftest.o 2>&5
-      echo "$RANLIB libconftest.a" >&5
-      $RANLIB libconftest.a 2>&5
-      cat > conftest.c << _LT_EOF
-int main() { return 0;}
-_LT_EOF
-      echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5
-      $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err
-      _lt_result=$?
-      if test -s conftest.err && $GREP force_load conftest.err; then
-	cat conftest.err >&5
-      elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then
-	lt_cv_ld_force_load=yes
-      else
-	cat conftest.err >&5
-      fi
-        rm -f conftest.err libconftest.a conftest conftest.c
-        rm -rf conftest.dSYM
 
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5
-printf "%s\n" "$lt_cv_ld_force_load" >&6; }
-    case $host_os in
-    rhapsody* | darwin1.[012])
-      _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;;
-    darwin1.*)
-      _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
-    darwin*) # darwin 5.x on
-      # if running on 10.5 or later, the deployment target defaults
-      # to the OS version, if on x86, and 10.4, the deployment
-      # target defaults to 10.4. Don't you love it?
-      case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
-	10.0,*86*-darwin8*|10.0,*-darwin[91]*)
-	  _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
-	10.[012][,.]*)
-	  _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
-	10.*)
-	  _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
-      esac
-    ;;
-  esac
-    if test yes = "$lt_cv_apple_cc_single_mod"; then
-      _lt_dar_single_mod='$single_module'
-    fi
-    if test yes = "$lt_cv_ld_exported_symbols_list"; then
-      _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym'
-    else
-      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib'
-    fi
-    if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then
-      _lt_dsymutil='~$DSYMUTIL $lib || :'
-    else
-      _lt_dsymutil=
-    fi
-    ;;
-  esac
 
-# func_munge_path_list VARIABLE PATH
-# -----------------------------------
-# VARIABLE is name of variable containing _space_ separated list of
-# directories to be munged by the contents of PATH, which is string
-# having a format:
-# "DIR[:DIR]:"
-#       string "DIR[ DIR]" will be prepended to VARIABLE
-# ":DIR[:DIR]"
-#       string "DIR[ DIR]" will be appended to VARIABLE
-# "DIRP[:DIRP]::[DIRA:]DIRA"
-#       string "DIRP[ DIRP]" will be prepended to VARIABLE and string
-#       "DIRA[ DIRA]" will be appended to VARIABLE
-# "DIR[:DIR]"
-#       VARIABLE will be replaced by "DIR[ DIR]"
-func_munge_path_list ()
-{
-    case x$2 in
-    x)
-        ;;
-    *:)
-        eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\"
-        ;;
-    x:*)
-        eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\"
-        ;;
-    *::*)
-        eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\"
-        eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\"
-        ;;
-    *)
-        eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\"
-        ;;
-    esac
-}
 
-ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default
-"
-if test "x$ac_cv_header_dlfcn_h" = xyes
-then :
-  printf "%s\n" "#define HAVE_DLFCN_H 1" >>confdefs.h
 
-fi
 
 
 
 
 
-# Set options
 
 
 
-        enable_dlopen=no
 
 
-  enable_win32_dll=no
 
 
 
-  # Check whether --enable-static was given.
-if test ${enable_static+y}
-then :
-  enableval=$enable_static; p=${PACKAGE-default}
-    case $enableval in
-    yes) enable_static=yes ;;
-    no) enable_static=no ;;
-    *)
-     enable_static=no
-      # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
-      for pkg in $enableval; do
-	IFS=$lt_save_ifs
-	if test "X$pkg" = "X$p"; then
-	  enable_static=yes
-	fi
-      done
-      IFS=$lt_save_ifs
-      ;;
-    esac
-else $as_nop
-  enable_static=yes
-fi
 
 
 
@@ -19377,28 +19203,6 @@ fi
 
 
 
-# Check whether --with-pic was given.
-if test ${with_pic+y}
-then :
-  withval=$with_pic; lt_p=${PACKAGE-default}
-    case $withval in
-    yes|no) pic_mode=$withval ;;
-    *)
-      pic_mode=default
-      # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
-      for lt_pkg in $withval; do
-	IFS=$lt_save_ifs
-	if test "X$lt_pkg" = "X$lt_p"; then
-	  pic_mode=yes
-	fi
-      done
-      IFS=$lt_save_ifs
-      ;;
-    esac
-else $as_nop
-  pic_mode=default
-fi
 
 
 
@@ -19407,887 +19211,1037 @@ fi
 
 
 
-  # Check whether --enable-fast-install was given.
-if test ${enable_fast_install+y}
+
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5
+printf %s "checking for sysroot... " >&6; }
+
+# Check whether --with-sysroot was given.
+if test ${with_sysroot+y}
 then :
-  enableval=$enable_fast_install; p=${PACKAGE-default}
-    case $enableval in
-    yes) enable_fast_install=yes ;;
-    no) enable_fast_install=no ;;
-    *)
-      enable_fast_install=no
-      # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
-      for pkg in $enableval; do
-	IFS=$lt_save_ifs
-	if test "X$pkg" = "X$p"; then
-	  enable_fast_install=yes
-	fi
-      done
-      IFS=$lt_save_ifs
-      ;;
-    esac
+  withval=$with_sysroot;
 else $as_nop
-  enable_fast_install=yes
+  with_sysroot=no
 fi
 
 
+lt_sysroot=
+case $with_sysroot in #(
+ yes)
+   if test yes = "$GCC"; then
+     lt_sysroot=`$CC --print-sysroot 2>/dev/null`
+   fi
+   ;; #(
+ /*)
+   lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"`
+   ;; #(
+ no|'')
+   ;; #(
+ *)
+   { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_sysroot" >&5
+printf "%s\n" "$with_sysroot" >&6; }
+   as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5
+   ;;
+esac
 
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5
+printf "%s\n" "${lt_sysroot:-no}" >&6; }
 
 
 
 
 
-  shared_archive_member_spec=
-case $host,$enable_shared in
-power*-*-aix[5-9]*,yes)
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking which variant of shared library versioning to provide" >&5
-printf %s "checking which variant of shared library versioning to provide... " >&6; }
-
-# Check whether --with-aix-soname was given.
-if test ${with_aix_soname+y}
-then :
-  withval=$with_aix_soname; case $withval in
-    aix|svr4|both)
-      ;;
-    *)
-      as_fn_error $? "Unknown argument to --with-aix-soname" "$LINENO" 5
-      ;;
-    esac
-    lt_cv_with_aix_soname=$with_aix_soname
-else $as_nop
-  if test ${lt_cv_with_aix_soname+y}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a working dd" >&5
+printf %s "checking for a working dd... " >&6; }
+if test ${ac_cv_path_lt_DD+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  lt_cv_with_aix_soname=aix
-fi
-
-    with_aix_soname=$lt_cv_with_aix_soname
+  printf 0123456789abcdef0123456789abcdef >conftest.i
+cat conftest.i conftest.i >conftest2.i
+: ${lt_DD:=$DD}
+if test -z "$lt_DD"; then
+  ac_path_lt_DD_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_prog in dd
+   do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_lt_DD="$as_dir$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_lt_DD" || continue
+if "$ac_path_lt_DD" bs=32 count=1 <conftest2.i >conftest.out 2>/dev/null; then
+  cmp -s conftest.i conftest.out \
+  && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=:
 fi
-
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_aix_soname" >&5
-printf "%s\n" "$with_aix_soname" >&6; }
-  if test aix != "$with_aix_soname"; then
-    # For the AIX way of multilib, we name the shared archive member
-    # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o',
-    # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File.
-    # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag,
-    # the AIX toolchain works better with OBJECT_MODE set (default 32).
-    if test 64 = "${OBJECT_MODE-32}"; then
-      shared_archive_member_spec=shr_64
-    else
-      shared_archive_member_spec=shr
-    fi
+      $ac_path_lt_DD_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_lt_DD"; then
+    :
   fi
-  ;;
-*)
-  with_aix_soname=aix
-  ;;
-esac
-
-
-
-
-
-
-
-
-
-
-# This can be used to rebuild libtool when needed
-LIBTOOL_DEPS=$ltmain
-
-# Always use our own libtool.
-LIBTOOL='$(SHELL) $(top_builddir)/libtool'
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-test -z "$LN_S" && LN_S="ln -s"
-
-
-
-
-
-
-
-
-
-
-
-
-
+else
+  ac_cv_path_lt_DD=$lt_DD
+fi
 
-if test -n "${ZSH_VERSION+set}"; then
-   setopt NO_GLOB_SUBST
+rm -f conftest.i conftest2.i conftest.out
 fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_lt_DD" >&5
+printf "%s\n" "$ac_cv_path_lt_DD" >&6; }
 
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5
-printf %s "checking for objdir... " >&6; }
-if test ${lt_cv_objdir+y}
+
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to truncate binary pipes" >&5
+printf %s "checking how to truncate binary pipes... " >&6; }
+if test ${lt_cv_truncate_bin+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  rm -f .libs 2>/dev/null
-mkdir .libs 2>/dev/null
-if test -d .libs; then
-  lt_cv_objdir=.libs
-else
-  # MS-DOS does not allow filenames that begin with a dot.
-  lt_cv_objdir=_libs
+  printf 0123456789abcdef0123456789abcdef >conftest.i
+cat conftest.i conftest.i >conftest2.i
+lt_cv_truncate_bin=
+if "$ac_cv_path_lt_DD" bs=32 count=1 <conftest2.i >conftest.out 2>/dev/null; then
+  cmp -s conftest.i conftest.out \
+  && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1"
 fi
-rmdir .libs 2>/dev/null
+rm -f conftest.i conftest2.i conftest.out
+test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q"
 fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5
-printf "%s\n" "$lt_cv_objdir" >&6; }
-objdir=$lt_cv_objdir
-
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_truncate_bin" >&5
+printf "%s\n" "$lt_cv_truncate_bin" >&6; }
 
 
 
 
-printf "%s\n" "#define LT_OBJDIR \"$lt_cv_objdir/\"" >>confdefs.h
 
 
 
+# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
+func_cc_basename ()
+{
+    for cc_temp in $*""; do
+      case $cc_temp in
+        compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+        distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+        \-*) ;;
+        *) break;;
+      esac
+    done
+    func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+}
 
-case $host_os in
-aix3*)
-  # AIX sometimes has problems with the GCC collect2 program.  For some
-  # reason, if we set the COLLECT_NAMES environment variable, the problems
-  # vanish in a puff of smoke.
-  if test set != "${COLLECT_NAMES+set}"; then
-    COLLECT_NAMES=
-    export COLLECT_NAMES
-  fi
-  ;;
-esac
+# Check whether --enable-libtool-lock was given.
+if test ${enable_libtool_lock+y}
+then :
+  enableval=$enable_libtool_lock;
+fi
 
-# Global variables:
-ofile=libtool
-can_build_shared=yes
+test no = "$enable_libtool_lock" || enable_libtool_lock=yes
 
-# All known linkers require a '.a' archive for static linking (except MSVC,
-# which needs '.lib').
-libext=a
-
-with_gnu_ld=$lt_cv_prog_gnu_ld
-
-old_CC=$CC
-old_CFLAGS=$CFLAGS
-
-# Set sane defaults for various variables
-test -z "$CC" && CC=cc
-test -z "$LTCC" && LTCC=$CC
-test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
-test -z "$LD" && LD=ld
-test -z "$ac_objext" && ac_objext=o
-
-func_cc_basename $compiler
-cc_basename=$func_cc_basename_result
-
-
-# Only perform the check for file, if the check method requires it
-test -z "$MAGIC_CMD" && MAGIC_CMD=file
-case $deplibs_check_method in
-file_magic*)
-  if test "$file_magic_cmd" = '$MAGIC_CMD'; then
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5
-printf %s "checking for ${ac_tool_prefix}file... " >&6; }
-if test ${lt_cv_path_MAGIC_CMD+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  case $MAGIC_CMD in
-[\\/*] |  ?:[\\/]*)
-  lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path.
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case $host in
+ia64-*-hpux*)
+  # Find out what ABI is being produced by ac_compile, and set mode
+  # options accordingly.
+  echo 'int i;' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    case `/usr/bin/file conftest.$ac_objext` in
+      *ELF-32*)
+	HPUX_IA64_MODE=32
+	;;
+      *ELF-64*)
+	HPUX_IA64_MODE=64
+	;;
+    esac
+  fi
+  rm -rf conftest*
   ;;
-*)
-  lt_save_MAGIC_CMD=$MAGIC_CMD
-  lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
-  ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
-  for ac_dir in $ac_dummy; do
-    IFS=$lt_save_ifs
-    test -z "$ac_dir" && ac_dir=.
-    if test -f "$ac_dir/${ac_tool_prefix}file"; then
-      lt_cv_path_MAGIC_CMD=$ac_dir/"${ac_tool_prefix}file"
-      if test -n "$file_magic_test_file"; then
-	case $deplibs_check_method in
-	"file_magic "*)
-	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
-	  MAGIC_CMD=$lt_cv_path_MAGIC_CMD
-	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
-	    $EGREP "$file_magic_regex" > /dev/null; then
-	    :
-	  else
-	    cat <<_LT_EOF 1>&2
-
-*** Warning: the command libtool uses to detect shared libraries,
-*** $file_magic_cmd, produces output that libtool cannot recognize.
-*** The result is that libtool may fail to recognize shared libraries
-*** as such.  This will affect the creation of libtool libraries that
-*** depend on shared libraries, but programs linked with such libtool
-*** libraries will work regardless of this problem.  Nevertheless, you
-*** may want to report the problem to your system manager and/or to
-*** bug-libtool@gnu.org
-
-_LT_EOF
-	  fi ;;
-	esac
-      fi
-      break
+*-*-irix6*)
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.
+  echo '#line '$LINENO' "configure"' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    if test yes = "$lt_cv_prog_gnu_ld"; then
+      case `/usr/bin/file conftest.$ac_objext` in
+	*32-bit*)
+	  LD="${LD-ld} -melf32bsmip"
+	  ;;
+	*N32*)
+	  LD="${LD-ld} -melf32bmipn32"
+	  ;;
+	*64-bit*)
+	  LD="${LD-ld} -melf64bmip"
+	;;
+      esac
+    else
+      case `/usr/bin/file conftest.$ac_objext` in
+	*32-bit*)
+	  LD="${LD-ld} -32"
+	  ;;
+	*N32*)
+	  LD="${LD-ld} -n32"
+	  ;;
+	*64-bit*)
+	  LD="${LD-ld} -64"
+	  ;;
+      esac
     fi
-  done
-  IFS=$lt_save_ifs
-  MAGIC_CMD=$lt_save_MAGIC_CMD
+  fi
+  rm -rf conftest*
   ;;
-esac
-fi
-
-MAGIC_CMD=$lt_cv_path_MAGIC_CMD
-if test -n "$MAGIC_CMD"; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
-printf "%s\n" "$MAGIC_CMD" >&6; }
-else
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
-printf "%s\n" "no" >&6; }
-fi
-
-
 
+mips64*-*linux*)
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.
+  echo '#line '$LINENO' "configure"' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    emul=elf
+    case `/usr/bin/file conftest.$ac_objext` in
+      *32-bit*)
+	emul="${emul}32"
+	;;
+      *64-bit*)
+	emul="${emul}64"
+	;;
+    esac
+    case `/usr/bin/file conftest.$ac_objext` in
+      *MSB*)
+	emul="${emul}btsmip"
+	;;
+      *LSB*)
+	emul="${emul}ltsmip"
+	;;
+    esac
+    case `/usr/bin/file conftest.$ac_objext` in
+      *N32*)
+	emul="${emul}n32"
+	;;
+    esac
+    LD="${LD-ld} -m $emul"
+  fi
+  rm -rf conftest*
+  ;;
 
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
+s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.  Note that the listed cases only cover the
+  # situations where additional linker options are needed (such as when
+  # doing 32-bit compilation for a host where ld defaults to 64-bit, or
+  # vice versa); the common cases where no linker options are needed do
+  # not appear in the list.
+  echo 'int i;' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    case `/usr/bin/file conftest.o` in
+      *32-bit*)
+	case $host in
+	  x86_64-*kfreebsd*-gnu)
+	    LD="${LD-ld} -m elf_i386_fbsd"
+	    ;;
+	  x86_64-*linux*)
+	    case `/usr/bin/file conftest.o` in
+	      *x86-64*)
+		LD="${LD-ld} -m elf32_x86_64"
+		;;
+	      *)
+		LD="${LD-ld} -m elf_i386"
+		;;
+	    esac
+	    ;;
+	  powerpc64le-*linux*)
+	    LD="${LD-ld} -m elf32lppclinux"
+	    ;;
+	  powerpc64-*linux*)
+	    LD="${LD-ld} -m elf32ppclinux"
+	    ;;
+	  s390x-*linux*)
+	    LD="${LD-ld} -m elf_s390"
+	    ;;
+	  sparc64-*linux*)
+	    LD="${LD-ld} -m elf32_sparc"
+	    ;;
+	esac
+	;;
+      *64-bit*)
+	case $host in
+	  x86_64-*kfreebsd*-gnu)
+	    LD="${LD-ld} -m elf_x86_64_fbsd"
+	    ;;
+	  x86_64-*linux*)
+	    LD="${LD-ld} -m elf_x86_64"
+	    ;;
+	  powerpcle-*linux*)
+	    LD="${LD-ld} -m elf64lppc"
+	    ;;
+	  powerpc-*linux*)
+	    LD="${LD-ld} -m elf64ppc"
+	    ;;
+	  s390*-*linux*|s390*-*tpf*)
+	    LD="${LD-ld} -m elf64_s390"
+	    ;;
+	  sparc*-*linux*)
+	    LD="${LD-ld} -m elf64_sparc"
+	    ;;
+	esac
+	;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
 
-if test -z "$lt_cv_path_MAGIC_CMD"; then
-  if test -n "$ac_tool_prefix"; then
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for file" >&5
-printf %s "checking for file... " >&6; }
-if test ${lt_cv_path_MAGIC_CMD+y}
+*-*-sco3.2v5*)
+  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+  SAVE_CFLAGS=$CFLAGS
+  CFLAGS="$CFLAGS -belf"
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5
+printf %s "checking whether the C compiler needs -belf... " >&6; }
+if test ${lt_cv_cc_needs_belf+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  case $MAGIC_CMD in
-[\\/*] |  ?:[\\/]*)
-  lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path.
-  ;;
-*)
-  lt_save_MAGIC_CMD=$MAGIC_CMD
-  lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
-  ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
-  for ac_dir in $ac_dummy; do
-    IFS=$lt_save_ifs
-    test -z "$ac_dir" && ac_dir=.
-    if test -f "$ac_dir/file"; then
-      lt_cv_path_MAGIC_CMD=$ac_dir/"file"
-      if test -n "$file_magic_test_file"; then
-	case $deplibs_check_method in
-	"file_magic "*)
-	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
-	  MAGIC_CMD=$lt_cv_path_MAGIC_CMD
-	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
-	    $EGREP "$file_magic_regex" > /dev/null; then
-	    :
-	  else
-	    cat <<_LT_EOF 1>&2
+  ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-*** Warning: the command libtool uses to detect shared libraries,
-*** $file_magic_cmd, produces output that libtool cannot recognize.
-*** The result is that libtool may fail to recognize shared libraries
-*** as such.  This will affect the creation of libtool libraries that
-*** depend on shared libraries, but programs linked with such libtool
-*** libraries will work regardless of this problem.  Nevertheless, you
-*** may want to report the problem to your system manager and/or to
-*** bug-libtool@gnu.org
+     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
-_LT_EOF
-	  fi ;;
-	esac
-      fi
-      break
-    fi
-  done
-  IFS=$lt_save_ifs
-  MAGIC_CMD=$lt_save_MAGIC_CMD
-  ;;
-esac
-fi
+int
+main (void)
+{
 
-MAGIC_CMD=$lt_cv_path_MAGIC_CMD
-if test -n "$MAGIC_CMD"; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
-printf "%s\n" "$MAGIC_CMD" >&6; }
-else
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
-printf "%s\n" "no" >&6; }
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
+then :
+  lt_cv_cc_needs_belf=yes
+else $as_nop
+  lt_cv_cc_needs_belf=no
 fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext
+     ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-
-  else
-    MAGIC_CMD=:
-  fi
 fi
-
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5
+printf "%s\n" "$lt_cv_cc_needs_belf" >&6; }
+  if test yes != "$lt_cv_cc_needs_belf"; then
+    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+    CFLAGS=$SAVE_CFLAGS
+  fi
+  ;;
+*-*solaris*)
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.
+  echo 'int i;' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    case `/usr/bin/file conftest.o` in
+    *64-bit*)
+      case $lt_cv_prog_gnu_ld in
+      yes*)
+        case $host in
+        i?86-*-solaris*|x86_64-*-solaris*)
+          LD="${LD-ld} -m elf_x86_64"
+          ;;
+        sparc*-*-solaris*)
+          LD="${LD-ld} -m elf64_sparc"
+          ;;
+        esac
+        # GNU ld 2.21 introduced _sol2 emulations.  Use them if available.
+        if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then
+          LD=${LD-ld}_sol2
+        fi
+        ;;
+      *)
+	if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
+	  LD="${LD-ld} -64"
+	fi
+	;;
+      esac
+      ;;
+    esac
   fi
+  rm -rf conftest*
   ;;
 esac
 
-# Use C for the default configuration in the libtool script
+need_locks=$enable_libtool_lock
 
-lt_save_CC=$CC
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args.
+set dummy ${ac_tool_prefix}mt; ac_word=$2
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_MANIFEST_TOOL+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  if test -n "$MANIFEST_TOOL"; then
+  ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt"
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
 
+fi
+fi
+MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL
+if test -n "$MANIFEST_TOOL"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5
+printf "%s\n" "$MANIFEST_TOOL" >&6; }
+else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+fi
 
-# Source file extension for C test sources.
-ac_ext=c
 
-# Object file extension for compiled C test sources.
-objext=o
-objext=$objext
+fi
+if test -z "$ac_cv_prog_MANIFEST_TOOL"; then
+  ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL
+  # Extract the first word of "mt", so it can be a program name with args.
+set dummy mt; ac_word=$2
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_MANIFEST_TOOL+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  if test -n "$ac_ct_MANIFEST_TOOL"; then
+  ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_MANIFEST_TOOL="mt"
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
 
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="int some_variable = 0;"
+fi
+fi
+ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL
+if test -n "$ac_ct_MANIFEST_TOOL"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5
+printf "%s\n" "$ac_ct_MANIFEST_TOOL" >&6; }
+else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+fi
 
-# Code to be used in simple link tests
-lt_simple_link_test_code='int main(){return(0);}'
+  if test "x$ac_ct_MANIFEST_TOOL" = x; then
+    MANIFEST_TOOL=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL
+  fi
+else
+  MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL"
+fi
 
+test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5
+printf %s "checking if $MANIFEST_TOOL is a manifest tool... " >&6; }
+if test ${lt_cv_path_mainfest_tool+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  lt_cv_path_mainfest_tool=no
+  echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5
+  $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out
+  cat conftest.err >&5
+  if $GREP 'Manifest Tool' conftest.out > /dev/null; then
+    lt_cv_path_mainfest_tool=yes
+  fi
+  rm -f conftest*
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5
+printf "%s\n" "$lt_cv_path_mainfest_tool" >&6; }
+if test yes != "$lt_cv_path_mainfest_tool"; then
+  MANIFEST_TOOL=:
+fi
 
 
 
 
 
 
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
-
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
-# Allow CC to be a program name with arguments.
-compiler=$CC
-
-# Save the default compiler, since it gets overwritten when the other
-# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
-compiler_DEFAULT=$CC
-
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-echo "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$RM conftest*
-
-ac_outfile=conftest.$ac_objext
-echo "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$RM -r conftest*
-
-
-## CAVEAT EMPTOR:
-## There is no encapsulation within the following macros, do not change
-## the running order or otherwise move them around unless you know exactly
-## what you are doing...
-if test -n "$compiler"; then
+  case $host_os in
+    rhapsody* | darwin*)
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args.
+set dummy ${ac_tool_prefix}dsymutil; ac_word=$2
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_DSYMUTIL+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  if test -n "$DSYMUTIL"; then
+  ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil"
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
 
-lt_prog_compiler_no_builtin_flag=
+fi
+fi
+DSYMUTIL=$ac_cv_prog_DSYMUTIL
+if test -n "$DSYMUTIL"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5
+printf "%s\n" "$DSYMUTIL" >&6; }
+else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+fi
 
-if test yes = "$GCC"; then
-  case $cc_basename in
-  nvcc*)
-    lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;;
-  *)
-    lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;;
-  esac
 
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
-printf %s "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; }
-if test ${lt_cv_prog_compiler_rtti_exceptions+y}
+fi
+if test -z "$ac_cv_prog_DSYMUTIL"; then
+  ac_ct_DSYMUTIL=$DSYMUTIL
+  # Extract the first word of "dsymutil", so it can be a program name with args.
+set dummy dsymutil; ac_word=$2
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_DSYMUTIL+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  lt_cv_prog_compiler_rtti_exceptions=no
-   ac_outfile=conftest.$ac_objext
-   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="-fno-rtti -fno-exceptions"  ## exclude from sc_useless_quotes_in_assignment
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   # The option is referenced via a variable to avoid confusing sed.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>conftest.err)
-   ac_status=$?
-   cat conftest.err >&5
-   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s "$ac_outfile"; then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
-     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
-       lt_cv_prog_compiler_rtti_exceptions=yes
-     fi
-   fi
-   $RM conftest*
+  if test -n "$ac_ct_DSYMUTIL"; then
+  ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_DSYMUTIL="dsymutil"
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
 
 fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
-printf "%s\n" "$lt_cv_prog_compiler_rtti_exceptions" >&6; }
-
-if test yes = "$lt_cv_prog_compiler_rtti_exceptions"; then
-    lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions"
+fi
+ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL
+if test -n "$ac_ct_DSYMUTIL"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5
+printf "%s\n" "$ac_ct_DSYMUTIL" >&6; }
 else
-    :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
+  if test "x$ac_ct_DSYMUTIL" = x; then
+    DSYMUTIL=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    DSYMUTIL=$ac_ct_DSYMUTIL
+  fi
+else
+  DSYMUTIL="$ac_cv_prog_DSYMUTIL"
 fi
 
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args.
+set dummy ${ac_tool_prefix}nmedit; ac_word=$2
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_NMEDIT+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  if test -n "$NMEDIT"; then
+  ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit"
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
 
+fi
+fi
+NMEDIT=$ac_cv_prog_NMEDIT
+if test -n "$NMEDIT"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5
+printf "%s\n" "$NMEDIT" >&6; }
+else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+fi
 
 
+fi
+if test -z "$ac_cv_prog_NMEDIT"; then
+  ac_ct_NMEDIT=$NMEDIT
+  # Extract the first word of "nmedit", so it can be a program name with args.
+set dummy nmedit; ac_word=$2
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_NMEDIT+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  if test -n "$ac_ct_NMEDIT"; then
+  ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_NMEDIT="nmedit"
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
 
+fi
+fi
+ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT
+if test -n "$ac_ct_NMEDIT"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5
+printf "%s\n" "$ac_ct_NMEDIT" >&6; }
+else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+fi
 
-  lt_prog_compiler_wl=
-lt_prog_compiler_pic=
-lt_prog_compiler_static=
-
-
-  if test yes = "$GCC"; then
-    lt_prog_compiler_wl='-Wl,'
-    lt_prog_compiler_static='-static'
-
-    case $host_os in
-      aix*)
-      # All AIX code is PIC.
-      if test ia64 = "$host_cpu"; then
-	# AIX 5 now supports IA64 processor
-	lt_prog_compiler_static='-Bstatic'
-      fi
-      lt_prog_compiler_pic='-fPIC'
-      ;;
-
-    amigaos*)
-      case $host_cpu in
-      powerpc)
-            # see comment about AmigaOS4 .so support
-            lt_prog_compiler_pic='-fPIC'
-        ;;
-      m68k)
-            # FIXME: we need at least 68020 code to build shared libraries, but
-            # adding the '-m68020' flag to GCC prevents building anything better,
-            # like '-m68040'.
-            lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4'
-        ;;
-      esac
-      ;;
-
-    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
-      # PIC is the default for these OSes.
-      ;;
+  if test "x$ac_ct_NMEDIT" = x; then
+    NMEDIT=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    NMEDIT=$ac_ct_NMEDIT
+  fi
+else
+  NMEDIT="$ac_cv_prog_NMEDIT"
+fi
 
-    mingw* | cygwin* | pw32* | os2* | cegcc*)
-      # This hack is so that the source file can tell whether it is being
-      # built for inclusion in a dll (and should export symbols for example).
-      # Although the cygwin gcc ignores -fPIC, still need this for old-style
-      # (--disable-auto-import) libraries
-      lt_prog_compiler_pic='-DDLL_EXPORT'
-      case $host_os in
-      os2*)
-	lt_prog_compiler_static='$wl-static'
-	;;
-      esac
-      ;;
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args.
+set dummy ${ac_tool_prefix}lipo; ac_word=$2
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_LIPO+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  if test -n "$LIPO"; then
+  ac_cv_prog_LIPO="$LIPO" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_prog_LIPO="${ac_tool_prefix}lipo"
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
 
-    darwin* | rhapsody*)
-      # PIC is the default on this platform
-      # Common symbols not allowed in MH_DYLIB files
-      lt_prog_compiler_pic='-fno-common'
-      ;;
+fi
+fi
+LIPO=$ac_cv_prog_LIPO
+if test -n "$LIPO"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5
+printf "%s\n" "$LIPO" >&6; }
+else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+fi
 
-    haiku*)
-      # PIC is the default for Haiku.
-      # The "-static" flag exists, but is broken.
-      lt_prog_compiler_static=
-      ;;
 
-    hpux*)
-      # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
-      # PA HP-UX.  On IA64 HP-UX, PIC is the default but the pic flag
-      # sets the default TLS model and affects inlining.
-      case $host_cpu in
-      hppa*64*)
-	# +Z the default
-	;;
-      *)
-	lt_prog_compiler_pic='-fPIC'
-	;;
-      esac
-      ;;
+fi
+if test -z "$ac_cv_prog_LIPO"; then
+  ac_ct_LIPO=$LIPO
+  # Extract the first word of "lipo", so it can be a program name with args.
+set dummy lipo; ac_word=$2
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_LIPO+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  if test -n "$ac_ct_LIPO"; then
+  ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_LIPO="lipo"
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
 
-    interix[3-9]*)
-      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
-      # Instead, we relocate shared libraries at runtime.
-      ;;
+fi
+fi
+ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO
+if test -n "$ac_ct_LIPO"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5
+printf "%s\n" "$ac_ct_LIPO" >&6; }
+else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+fi
 
-    msdosdjgpp*)
-      # Just because we use GCC doesn't mean we suddenly get shared libraries
-      # on systems that don't support them.
-      lt_prog_compiler_can_build_shared=no
-      enable_shared=no
-      ;;
+  if test "x$ac_ct_LIPO" = x; then
+    LIPO=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    LIPO=$ac_ct_LIPO
+  fi
+else
+  LIPO="$ac_cv_prog_LIPO"
+fi
 
-    *nto* | *qnx*)
-      # QNX uses GNU C++, but need to define -shared option too, otherwise
-      # it will coredump.
-      lt_prog_compiler_pic='-fPIC -shared'
-      ;;
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args.
+set dummy ${ac_tool_prefix}otool; ac_word=$2
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_OTOOL+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  if test -n "$OTOOL"; then
+  ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_prog_OTOOL="${ac_tool_prefix}otool"
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
 
-    sysv4*MP*)
-      if test -d /usr/nec; then
-	lt_prog_compiler_pic=-Kconform_pic
-      fi
-      ;;
+fi
+fi
+OTOOL=$ac_cv_prog_OTOOL
+if test -n "$OTOOL"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5
+printf "%s\n" "$OTOOL" >&6; }
+else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+fi
 
-    *)
-      lt_prog_compiler_pic='-fPIC'
-      ;;
-    esac
 
-    case $cc_basename in
-    nvcc*) # Cuda Compiler Driver 2.2
-      lt_prog_compiler_wl='-Xlinker '
-      if test -n "$lt_prog_compiler_pic"; then
-        lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic"
-      fi
-      ;;
-    esac
-  else
-    # PORTME Check for flag to pass linker flags through the system compiler.
-    case $host_os in
-    aix*)
-      lt_prog_compiler_wl='-Wl,'
-      if test ia64 = "$host_cpu"; then
-	# AIX 5 now supports IA64 processor
-	lt_prog_compiler_static='-Bstatic'
-      else
-	lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp'
-      fi
-      ;;
-
-    darwin* | rhapsody*)
-      # PIC is the default on this platform
-      # Common symbols not allowed in MH_DYLIB files
-      lt_prog_compiler_pic='-fno-common'
-      case $cc_basename in
-      nagfor*)
-        # NAG Fortran compiler
-        lt_prog_compiler_wl='-Wl,-Wl,,'
-        lt_prog_compiler_pic='-PIC'
-        lt_prog_compiler_static='-Bstatic'
-        ;;
-      esac
-      ;;
-
-    mingw* | cygwin* | pw32* | os2* | cegcc*)
-      # This hack is so that the source file can tell whether it is being
-      # built for inclusion in a dll (and should export symbols for example).
-      lt_prog_compiler_pic='-DDLL_EXPORT'
-      case $host_os in
-      os2*)
-	lt_prog_compiler_static='$wl-static'
-	;;
-      esac
-      ;;
-
-    hpux9* | hpux10* | hpux11*)
-      lt_prog_compiler_wl='-Wl,'
-      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
-      # not for PA HP-UX.
-      case $host_cpu in
-      hppa*64*|ia64*)
-	# +Z the default
-	;;
-      *)
-	lt_prog_compiler_pic='+Z'
-	;;
-      esac
-      # Is there a better lt_prog_compiler_static that works with the bundled CC?
-      lt_prog_compiler_static='$wl-a ${wl}archive'
-      ;;
-
-    irix5* | irix6* | nonstopux*)
-      lt_prog_compiler_wl='-Wl,'
-      # PIC (with -KPIC) is the default.
-      lt_prog_compiler_static='-non_shared'
-      ;;
-
-    linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
-      case $cc_basename in
-      # old Intel for x86_64, which still supported -KPIC.
-      ecc*)
-	lt_prog_compiler_wl='-Wl,'
-	lt_prog_compiler_pic='-KPIC'
-	lt_prog_compiler_static='-static'
-        ;;
-      # icc used to be incompatible with GCC.
-      # ICC 10 doesn't accept -KPIC any more.
-      icc* | ifort*)
-	lt_prog_compiler_wl='-Wl,'
-	lt_prog_compiler_pic='-fPIC'
-	lt_prog_compiler_static='-static'
-        ;;
-      # Lahey Fortran 8.1.
-      lf95*)
-	lt_prog_compiler_wl='-Wl,'
-	lt_prog_compiler_pic='--shared'
-	lt_prog_compiler_static='--static'
-	;;
-      nagfor*)
-	# NAG Fortran compiler
-	lt_prog_compiler_wl='-Wl,-Wl,,'
-	lt_prog_compiler_pic='-PIC'
-	lt_prog_compiler_static='-Bstatic'
-	;;
-      tcc*)
-	# Fabrice Bellard et al's Tiny C Compiler
-	lt_prog_compiler_wl='-Wl,'
-	lt_prog_compiler_pic='-fPIC'
-	lt_prog_compiler_static='-static'
-	;;
-      pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
-        # Portland Group compilers (*not* the Pentium gcc compiler,
-	# which looks to be a dead project)
-	lt_prog_compiler_wl='-Wl,'
-	lt_prog_compiler_pic='-fpic'
-	lt_prog_compiler_static='-Bstatic'
-        ;;
-      ccc*)
-        lt_prog_compiler_wl='-Wl,'
-        # All Alpha code is PIC.
-        lt_prog_compiler_static='-non_shared'
-        ;;
-      xl* | bgxl* | bgf* | mpixl*)
-	# IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene
-	lt_prog_compiler_wl='-Wl,'
-	lt_prog_compiler_pic='-qpic'
-	lt_prog_compiler_static='-qstaticlink'
-	;;
-      *)
-	case `$CC -V 2>&1 | sed 5q` in
-	*Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*)
-	  # Sun Fortran 8.3 passes all unrecognized flags to the linker
-	  lt_prog_compiler_pic='-KPIC'
-	  lt_prog_compiler_static='-Bstatic'
-	  lt_prog_compiler_wl=''
-	  ;;
-	*Sun\ F* | *Sun*Fortran*)
-	  lt_prog_compiler_pic='-KPIC'
-	  lt_prog_compiler_static='-Bstatic'
-	  lt_prog_compiler_wl='-Qoption ld '
-	  ;;
-	*Sun\ C*)
-	  # Sun C 5.9
-	  lt_prog_compiler_pic='-KPIC'
-	  lt_prog_compiler_static='-Bstatic'
-	  lt_prog_compiler_wl='-Wl,'
-	  ;;
-        *Intel*\ [CF]*Compiler*)
-	  lt_prog_compiler_wl='-Wl,'
-	  lt_prog_compiler_pic='-fPIC'
-	  lt_prog_compiler_static='-static'
-	  ;;
-	*Portland\ Group*)
-	  lt_prog_compiler_wl='-Wl,'
-	  lt_prog_compiler_pic='-fpic'
-	  lt_prog_compiler_static='-Bstatic'
-	  ;;
-	esac
-	;;
-      esac
-      ;;
-
-    newsos6)
-      lt_prog_compiler_pic='-KPIC'
-      lt_prog_compiler_static='-Bstatic'
-      ;;
-
-    *nto* | *qnx*)
-      # QNX uses GNU C++, but need to define -shared option too, otherwise
-      # it will coredump.
-      lt_prog_compiler_pic='-fPIC -shared'
-      ;;
-
-    osf3* | osf4* | osf5*)
-      lt_prog_compiler_wl='-Wl,'
-      # All OSF/1 code is PIC.
-      lt_prog_compiler_static='-non_shared'
-      ;;
-
-    rdos*)
-      lt_prog_compiler_static='-non_shared'
-      ;;
-
-    solaris*)
-      lt_prog_compiler_pic='-KPIC'
-      lt_prog_compiler_static='-Bstatic'
-      case $cc_basename in
-      f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)
-	lt_prog_compiler_wl='-Qoption ld ';;
-      *)
-	lt_prog_compiler_wl='-Wl,';;
-      esac
-      ;;
-
-    sunos4*)
-      lt_prog_compiler_wl='-Qoption ld '
-      lt_prog_compiler_pic='-PIC'
-      lt_prog_compiler_static='-Bstatic'
-      ;;
-
-    sysv4 | sysv4.2uw2* | sysv4.3*)
-      lt_prog_compiler_wl='-Wl,'
-      lt_prog_compiler_pic='-KPIC'
-      lt_prog_compiler_static='-Bstatic'
-      ;;
-
-    sysv4*MP*)
-      if test -d /usr/nec; then
-	lt_prog_compiler_pic='-Kconform_pic'
-	lt_prog_compiler_static='-Bstatic'
-      fi
-      ;;
-
-    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
-      lt_prog_compiler_wl='-Wl,'
-      lt_prog_compiler_pic='-KPIC'
-      lt_prog_compiler_static='-Bstatic'
-      ;;
-
-    unicos*)
-      lt_prog_compiler_wl='-Wl,'
-      lt_prog_compiler_can_build_shared=no
-      ;;
-
-    uts4*)
-      lt_prog_compiler_pic='-pic'
-      lt_prog_compiler_static='-Bstatic'
-      ;;
-
-    *)
-      lt_prog_compiler_can_build_shared=no
-      ;;
-    esac
+fi
+if test -z "$ac_cv_prog_OTOOL"; then
+  ac_ct_OTOOL=$OTOOL
+  # Extract the first word of "otool", so it can be a program name with args.
+set dummy otool; ac_word=$2
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_OTOOL+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  if test -n "$ac_ct_OTOOL"; then
+  ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_OTOOL="otool"
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
+    break 2
   fi
+done
+  done
+IFS=$as_save_IFS
 
-case $host_os in
-  # For platforms that do not support PIC, -DPIC is meaningless:
-  *djgpp*)
-    lt_prog_compiler_pic=
-    ;;
-  *)
-    lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC"
-    ;;
+fi
+fi
+ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL
+if test -n "$ac_ct_OTOOL"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5
+printf "%s\n" "$ac_ct_OTOOL" >&6; }
+else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+fi
+
+  if test "x$ac_ct_OTOOL" = x; then
+    OTOOL=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
 esac
+    OTOOL=$ac_ct_OTOOL
+  fi
+else
+  OTOOL="$ac_cv_prog_OTOOL"
+fi
 
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5
-printf %s "checking for $compiler option to produce PIC... " >&6; }
-if test ${lt_cv_prog_compiler_pic+y}
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args.
+set dummy ${ac_tool_prefix}otool64; ac_word=$2
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_OTOOL64+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  lt_cv_prog_compiler_pic=$lt_prog_compiler_pic
+  if test -n "$OTOOL64"; then
+  ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64"
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+OTOOL64=$ac_cv_prog_OTOOL64
+if test -n "$OTOOL64"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5
+printf "%s\n" "$OTOOL64" >&6; }
+else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5
-printf "%s\n" "$lt_cv_prog_compiler_pic" >&6; }
-lt_prog_compiler_pic=$lt_cv_prog_compiler_pic
 
-#
-# Check to make sure the PIC flag actually works.
-#
-if test -n "$lt_prog_compiler_pic"; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5
-printf %s "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; }
-if test ${lt_cv_prog_compiler_pic_works+y}
+
+fi
+if test -z "$ac_cv_prog_OTOOL64"; then
+  ac_ct_OTOOL64=$OTOOL64
+  # Extract the first word of "otool64", so it can be a program name with args.
+set dummy otool64; ac_word=$2
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_OTOOL64+y}
 then :
   printf %s "(cached) " >&6
-else $as_nop
-  lt_cv_prog_compiler_pic_works=no
-   ac_outfile=conftest.$ac_objext
-   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="$lt_prog_compiler_pic -DPIC"  ## exclude from sc_useless_quotes_in_assignment
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   # The option is referenced via a variable to avoid confusing sed.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>conftest.err)
-   ac_status=$?
-   cat conftest.err >&5
-   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s "$ac_outfile"; then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
-     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
-       lt_cv_prog_compiler_pic_works=yes
-     fi
-   fi
-   $RM conftest*
+else $as_nop
+  if test -n "$ac_ct_OTOOL64"; then
+  ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_OTOOL64="otool64"
+    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
 
 fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5
-printf "%s\n" "$lt_cv_prog_compiler_pic_works" >&6; }
-
-if test yes = "$lt_cv_prog_compiler_pic_works"; then
-    case $lt_prog_compiler_pic in
-     "" | " "*) ;;
-     *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;;
-     esac
+fi
+ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64
+if test -n "$ac_ct_OTOOL64"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5
+printf "%s\n" "$ac_ct_OTOOL64" >&6; }
 else
-    lt_prog_compiler_pic=
-     lt_prog_compiler_can_build_shared=no
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
 fi
 
+  if test "x$ac_ct_OTOOL64" = x; then
+    OTOOL64=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    OTOOL64=$ac_ct_OTOOL64
+  fi
+else
+  OTOOL64="$ac_cv_prog_OTOOL64"
 fi
 
 
@@ -20300,1576 +20254,1197 @@ fi
 
 
 
-#
-# Check to make sure the static flag actually works.
-#
-wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\"
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5
-printf %s "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }
-if test ${lt_cv_prog_compiler_static_works+y}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5
+printf %s "checking for -single_module linker flag... " >&6; }
+if test ${lt_cv_apple_cc_single_mod+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  lt_cv_prog_compiler_static_works=no
-   save_LDFLAGS=$LDFLAGS
-   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
-   echo "$lt_simple_link_test_code" > conftest.$ac_ext
-   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
-     # The linker can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     if test -s conftest.err; then
-       # Append any errors to the config.log.
-       cat conftest.err 1>&5
-       $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
-       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-       if diff conftest.exp conftest.er2 >/dev/null; then
-         lt_cv_prog_compiler_static_works=yes
-       fi
-     else
-       lt_cv_prog_compiler_static_works=yes
-     fi
-   fi
-   $RM -r conftest*
-   LDFLAGS=$save_LDFLAGS
-
+  lt_cv_apple_cc_single_mod=no
+      if test -z "$LT_MULTI_MODULE"; then
+	# By default we will add the -single_module flag. You can override
+	# by either setting the environment variable LT_MULTI_MODULE
+	# non-empty at configure time, or by adding -multi_module to the
+	# link flags.
+	rm -rf libconftest.dylib*
+	echo "int foo(void){return 1;}" > conftest.c
+	echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+-dynamiclib -Wl,-single_module conftest.c" >&5
+	$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+	  -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
+        _lt_result=$?
+	# If there is a non-empty error log, and "single_module"
+	# appears in it, assume the flag caused a linker warning
+        if test -s conftest.err && $GREP single_module conftest.err; then
+	  cat conftest.err >&5
+	# Otherwise, if the output was created with a 0 exit code from
+	# the compiler, it worked.
+	elif test -f libconftest.dylib && test 0 = "$_lt_result"; then
+	  lt_cv_apple_cc_single_mod=yes
+	else
+	  cat conftest.err >&5
+	fi
+	rm -rf libconftest.dylib*
+	rm -f conftest.*
+      fi
 fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5
-printf "%s\n" "$lt_cv_prog_compiler_static_works" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5
+printf "%s\n" "$lt_cv_apple_cc_single_mod" >&6; }
 
-if test yes = "$lt_cv_prog_compiler_static_works"; then
-    :
-else
-    lt_prog_compiler_static=
-fi
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5
+printf %s "checking for -exported_symbols_list linker flag... " >&6; }
+if test ${lt_cv_ld_exported_symbols_list+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  lt_cv_ld_exported_symbols_list=no
+      save_LDFLAGS=$LDFLAGS
+      echo "_main" > conftest.sym
+      LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
+int
+main (void)
+{
 
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
+then :
+  lt_cv_ld_exported_symbols_list=yes
+else $as_nop
+  lt_cv_ld_exported_symbols_list=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext
+	LDFLAGS=$save_LDFLAGS
 
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5
+printf "%s\n" "$lt_cv_ld_exported_symbols_list" >&6; }
 
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5
+printf %s "checking for -force_load linker flag... " >&6; }
+if test ${lt_cv_ld_force_load+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  lt_cv_ld_force_load=no
+      cat > conftest.c << _LT_EOF
+int forced_loaded() { return 2;}
+_LT_EOF
+      echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5
+      $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5
+      echo "$AR cru libconftest.a conftest.o" >&5
+      $AR cru libconftest.a conftest.o 2>&5
+      echo "$RANLIB libconftest.a" >&5
+      $RANLIB libconftest.a 2>&5
+      cat > conftest.c << _LT_EOF
+int main() { return 0;}
+_LT_EOF
+      echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5
+      $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err
+      _lt_result=$?
+      if test -s conftest.err && $GREP force_load conftest.err; then
+	cat conftest.err >&5
+      elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then
+	lt_cv_ld_force_load=yes
+      else
+	cat conftest.err >&5
+      fi
+        rm -f conftest.err libconftest.a conftest conftest.c
+        rm -rf conftest.dSYM
 
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5
+printf "%s\n" "$lt_cv_ld_force_load" >&6; }
+    case $host_os in
+    rhapsody* | darwin1.[012])
+      _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;;
+    darwin1.*)
+      _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
+    darwin*) # darwin 5.x on
+      # if running on 10.5 or later, the deployment target defaults
+      # to the OS version, if on x86, and 10.4, the deployment
+      # target defaults to 10.4. Don't you love it?
+      case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
+	10.0,*86*-darwin8*|10.0,*-darwin[91]*)
+	  _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
+	10.[012][,.]*)
+	  _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
+	10.*)
+	  _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
+      esac
+    ;;
+  esac
+    if test yes = "$lt_cv_apple_cc_single_mod"; then
+      _lt_dar_single_mod='$single_module'
+    fi
+    if test yes = "$lt_cv_ld_exported_symbols_list"; then
+      _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym'
+    else
+      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib'
+    fi
+    if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then
+      _lt_dsymutil='~$DSYMUTIL $lib || :'
+    else
+      _lt_dsymutil=
+    fi
+    ;;
+  esac
 
+# func_munge_path_list VARIABLE PATH
+# -----------------------------------
+# VARIABLE is name of variable containing _space_ separated list of
+# directories to be munged by the contents of PATH, which is string
+# having a format:
+# "DIR[:DIR]:"
+#       string "DIR[ DIR]" will be prepended to VARIABLE
+# ":DIR[:DIR]"
+#       string "DIR[ DIR]" will be appended to VARIABLE
+# "DIRP[:DIRP]::[DIRA:]DIRA"
+#       string "DIRP[ DIRP]" will be prepended to VARIABLE and string
+#       "DIRA[ DIRA]" will be appended to VARIABLE
+# "DIR[:DIR]"
+#       VARIABLE will be replaced by "DIR[ DIR]"
+func_munge_path_list ()
+{
+    case x$2 in
+    x)
+        ;;
+    *:)
+        eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\"
+        ;;
+    x:*)
+        eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\"
+        ;;
+    *::*)
+        eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\"
+        eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\"
+        ;;
+    *)
+        eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\"
+        ;;
+    esac
+}
 
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
-printf %s "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
-if test ${lt_cv_prog_compiler_c_o+y}
+ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default
+"
+if test "x$ac_cv_header_dlfcn_h" = xyes
 then :
-  printf %s "(cached) " >&6
-else $as_nop
-  lt_cv_prog_compiler_c_o=no
-   $RM -r conftest 2>/dev/null
-   mkdir conftest
-   cd conftest
-   mkdir out
-   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-
-   lt_compiler_flag="-o out/conftest2.$ac_objext"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>out/conftest.err)
-   ac_status=$?
-   cat out/conftest.err >&5
-   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s out/conftest2.$ac_objext
-   then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
-     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
-       lt_cv_prog_compiler_c_o=yes
-     fi
-   fi
-   chmod u+w . 2>&5
-   $RM conftest*
-   # SGI C++ compiler will create directory out/ii_files/ for
-   # template instantiation
-   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
-   $RM out/* && rmdir out
-   cd ..
-   $RM -r conftest
-   $RM conftest*
+  printf "%s\n" "#define HAVE_DLFCN_H 1" >>confdefs.h
 
 fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5
-printf "%s\n" "$lt_cv_prog_compiler_c_o" >&6; }
 
 
 
 
 
-
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
-printf %s "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
-if test ${lt_cv_prog_compiler_c_o+y}
+# Set options
+# Check whether --enable-shared was given.
+if test ${enable_shared+y}
 then :
-  printf %s "(cached) " >&6
+  enableval=$enable_shared; p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_shared=yes ;;
+    no) enable_shared=no ;;
+    *)
+      enable_shared=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
+      for pkg in $enableval; do
+	IFS=$lt_save_ifs
+	if test "X$pkg" = "X$p"; then
+	  enable_shared=yes
+	fi
+      done
+      IFS=$lt_save_ifs
+      ;;
+    esac
 else $as_nop
-  lt_cv_prog_compiler_c_o=no
-   $RM -r conftest 2>/dev/null
-   mkdir conftest
-   cd conftest
-   mkdir out
-   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-
-   lt_compiler_flag="-o out/conftest2.$ac_objext"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>out/conftest.err)
-   ac_status=$?
-   cat out/conftest.err >&5
-   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s out/conftest2.$ac_objext
-   then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
-     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
-       lt_cv_prog_compiler_c_o=yes
-     fi
-   fi
-   chmod u+w . 2>&5
-   $RM conftest*
-   # SGI C++ compiler will create directory out/ii_files/ for
-   # template instantiation
-   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
-   $RM out/* && rmdir out
-   cd ..
-   $RM -r conftest
-   $RM conftest*
-
+  enable_shared=no
 fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5
-printf "%s\n" "$lt_cv_prog_compiler_c_o" >&6; }
 
 
 
 
-hard_links=nottested
-if test no = "$lt_cv_prog_compiler_c_o" && test no != "$need_locks"; then
-  # do not overwrite the value of need_locks provided by the user
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
-printf %s "checking if we can lock with hard links... " >&6; }
-  hard_links=yes
-  $RM conftest*
-  ln conftest.a conftest.b 2>/dev/null && hard_links=no
-  touch conftest.a
-  ln conftest.a conftest.b 2>&5 || hard_links=no
-  ln conftest.a conftest.b 2>/dev/null && hard_links=no
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
-printf "%s\n" "$hard_links" >&6; }
-  if test no = "$hard_links"; then
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5
-printf "%s\n" "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;}
-    need_locks=warn
-  fi
-else
-  need_locks=no
-fi
 
 
 
 
 
 
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
-printf %s "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
+        enable_dlopen=no
 
-  runpath_var=
-  allow_undefined_flag=
-  always_export_symbols=no
-  archive_cmds=
-  archive_expsym_cmds=
-  compiler_needs_object=no
-  enable_shared_with_static_runtimes=no
-  export_dynamic_flag_spec=
-  export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
-  hardcode_automatic=no
-  hardcode_direct=no
-  hardcode_direct_absolute=no
-  hardcode_libdir_flag_spec=
-  hardcode_libdir_separator=
-  hardcode_minus_L=no
-  hardcode_shlibpath_var=unsupported
-  inherit_rpath=no
-  link_all_deplibs=unknown
-  module_cmds=
-  module_expsym_cmds=
-  old_archive_from_new_cmds=
-  old_archive_from_expsyms_cmds=
-  thread_safe_flag_spec=
-  whole_archive_flag_spec=
-  # include_expsyms should be a list of space-separated symbols to be *always*
-  # included in the symbol list
-  include_expsyms=
-  # exclude_expsyms can be an extended regexp of symbols to exclude
-  # it will be wrapped by ' (' and ')$', so one must not match beginning or
-  # end of line.  Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc',
-  # as well as any symbol that contains 'd'.
-  exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
-  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
-  # platforms (ab)use it in PIC code, but their linkers get confused if
-  # the symbol is explicitly referenced.  Since portable code cannot
-  # rely on this symbol name, it's probably fine to never include it in
-  # preloaded symbol tables.
-  # Exclude shared library initialization/finalization symbols.
-  extract_expsyms_cmds=
 
-  case $host_os in
-  cygwin* | mingw* | pw32* | cegcc*)
-    # FIXME: the MSVC++ port hasn't been tested in a loooong time
-    # When not using gcc, we currently assume that we are using
-    # Microsoft Visual C++.
-    if test yes != "$GCC"; then
-      with_gnu_ld=no
-    fi
-    ;;
-  interix*)
-    # we just hope/assume this is gcc and not c89 (= MSVC++)
-    with_gnu_ld=yes
-    ;;
-  openbsd* | bitrig*)
-    with_gnu_ld=no
-    ;;
-  esac
+  enable_win32_dll=no
 
-  ld_shlibs=yes
 
-  # On some targets, GNU ld is compatible enough with the native linker
-  # that we're better off using the native interface for both.
-  lt_use_gnu_ld_interface=no
-  if test yes = "$with_gnu_ld"; then
-    case $host_os in
-      aix*)
-	# The AIX port of GNU ld has always aspired to compatibility
-	# with the native linker.  However, as the warning in the GNU ld
-	# block says, versions before 2.19.5* couldn't really create working
-	# shared libraries, regardless of the interface used.
-	case `$LD -v 2>&1` in
-	  *\ \(GNU\ Binutils\)\ 2.19.5*) ;;
-	  *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;;
-	  *\ \(GNU\ Binutils\)\ [3-9]*) ;;
-	  *)
-	    lt_use_gnu_ld_interface=yes
-	    ;;
-	esac
-	;;
-      *)
-	lt_use_gnu_ld_interface=yes
-	;;
+
+  # Check whether --enable-static was given.
+if test ${enable_static+y}
+then :
+  enableval=$enable_static; p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_static=yes ;;
+    no) enable_static=no ;;
+    *)
+     enable_static=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
+      for pkg in $enableval; do
+	IFS=$lt_save_ifs
+	if test "X$pkg" = "X$p"; then
+	  enable_static=yes
+	fi
+      done
+      IFS=$lt_save_ifs
+      ;;
     esac
-  fi
+else $as_nop
+  enable_static=yes
+fi
 
-  if test yes = "$lt_use_gnu_ld_interface"; then
-    # If archive_cmds runs LD, not CC, wlarc should be empty
-    wlarc='$wl'
 
-    # Set some defaults for GNU ld with shared library support. These
-    # are reset later if shared libraries are not supported. Putting them
-    # here allows them to be overridden if necessary.
-    runpath_var=LD_RUN_PATH
-    hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
-    export_dynamic_flag_spec='$wl--export-dynamic'
-    # ancient GNU ld didn't support --whole-archive et. al.
-    if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
-      whole_archive_flag_spec=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
-    else
-      whole_archive_flag_spec=
-    fi
-    supports_anon_versioning=no
-    case `$LD -v | $SED -e 's/(^)\+)\s\+//' 2>&1` in
-      *GNU\ gold*) supports_anon_versioning=yes ;;
-      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
-      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
-      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
-      *\ 2.11.*) ;; # other 2.11 versions
-      *) supports_anon_versioning=yes ;;
-    esac
 
-    # See if GNU ld supports shared libraries.
-    case $host_os in
-    aix[3-9]*)
-      # On AIX/PPC, the GNU linker is very broken
-      if test ia64 != "$host_cpu"; then
-	ld_shlibs=no
-	cat <<_LT_EOF 1>&2
 
-*** Warning: the GNU linker, at least up to release 2.19, is reported
-*** to be unable to reliably create shared libraries on AIX.
-*** Therefore, libtool is disabling shared libraries support.  If you
-*** really care for shared libraries, you may want to install binutils
-*** 2.20 or above, or modify your PATH so that a non-GNU linker is found.
-*** You will then need to restart the configuration process.
 
-_LT_EOF
-      fi
-      ;;
 
-    amigaos*)
-      case $host_cpu in
-      powerpc)
-            # see comment about AmigaOS4 .so support
-            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
-            archive_expsym_cmds=''
-        ;;
-      m68k)
-            archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
-            hardcode_libdir_flag_spec='-L$libdir'
-            hardcode_minus_L=yes
-        ;;
-      esac
-      ;;
 
-    beos*)
-      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	allow_undefined_flag=unsupported
-	# Joseph Beckenbach <jrb3@best.com> says some releases of gcc
-	# support --undefined.  This deserves some investigation.  FIXME
-	archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
-      else
-	ld_shlibs=no
-      fi
-      ;;
 
-    cygwin* | mingw* | pw32* | cegcc*)
-      # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
-      # as there is no search path for DLLs.
-      hardcode_libdir_flag_spec='-L$libdir'
-      export_dynamic_flag_spec='$wl--export-all-symbols'
-      allow_undefined_flag=unsupported
-      always_export_symbols=no
-      enable_shared_with_static_runtimes=yes
-      export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols'
-      exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'
 
-      if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
-        archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	# If the export-symbols file already is a .def file, use it as
-	# is; otherwise, prepend EXPORTS...
-	archive_expsym_cmds='if   test DEF = "`$SED -n     -e '\''s/^[	 ]*//'\''     -e '\''/^\(;.*\)*$/d'\''     -e '\''s/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p'\''     -e q     $export_symbols`" ; then
-          cp $export_symbols $output_objdir/$soname.def;
-        else
-          echo EXPORTS > $output_objdir/$soname.def;
-          cat $export_symbols >> $output_objdir/$soname.def;
-        fi~
-        $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-      else
-	ld_shlibs=no
-      fi
-      ;;
 
-    haiku*)
-      archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
-      link_all_deplibs=yes
+# Check whether --with-pic was given.
+if test ${with_pic+y}
+then :
+  withval=$with_pic; lt_p=${PACKAGE-default}
+    case $withval in
+    yes|no) pic_mode=$withval ;;
+    *)
+      pic_mode=default
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
+      for lt_pkg in $withval; do
+	IFS=$lt_save_ifs
+	if test "X$lt_pkg" = "X$lt_p"; then
+	  pic_mode=yes
+	fi
+      done
+      IFS=$lt_save_ifs
       ;;
+    esac
+else $as_nop
+  pic_mode=default
+fi
 
-    os2*)
-      hardcode_libdir_flag_spec='-L$libdir'
-      hardcode_minus_L=yes
-      allow_undefined_flag=unsupported
-      shrext_cmds=.dll
-      archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
-	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
-	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
-	$ECHO EXPORTS >> $output_objdir/$libname.def~
-	emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
-	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
-	emximp -o $lib $output_objdir/$libname.def'
-      archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
-	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
-	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
-	$ECHO EXPORTS >> $output_objdir/$libname.def~
-	prefix_cmds="$SED"~
-	if test EXPORTS = "`$SED 1q $export_symbols`"; then
-	  prefix_cmds="$prefix_cmds -e 1d";
-	fi~
-	prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
-	cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
-	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
-	emximp -o $lib $output_objdir/$libname.def'
-      old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
-      enable_shared_with_static_runtimes=yes
-      ;;
 
-    interix[3-9]*)
-      hardcode_direct=no
-      hardcode_shlibpath_var=no
-      hardcode_libdir_flag_spec='$wl-rpath,$libdir'
-      export_dynamic_flag_spec='$wl-E'
-      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
-      # Instead, shared libraries are loaded at an image base (0x10000000 by
-      # default) and relocated if they conflict, which is a slow very memory
-      # consuming and fragmenting process.  To avoid this, we pick a random,
-      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
-      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-      archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      archive_expsym_cmds='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      ;;
 
-    gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
-      tmp_diet=no
-      if test linux-dietlibc = "$host_os"; then
-	case $cc_basename in
-	  diet\ *) tmp_diet=yes;;	# linux-dietlibc with static linking (!diet-dyn)
-	esac
-      fi
-      if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
-	 && test no = "$tmp_diet"
-      then
-	tmp_addflag=' $pic_flag'
-	tmp_sharedflag='-shared'
-	case $cc_basename,$host_cpu in
-        pgcc*)				# Portland Group C compiler
-	  whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
-	  tmp_addflag=' $pic_flag'
-	  ;;
-	pgf77* | pgf90* | pgf95* | pgfortran*)
-					# Portland Group f77 and f90 compilers
-	  whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
-	  tmp_addflag=' $pic_flag -Mnomain' ;;
-	ecc*,ia64* | icc*,ia64*)	# Intel C compiler on ia64
-	  tmp_addflag=' -i_dynamic' ;;
-	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
-	  tmp_addflag=' -i_dynamic -nofor_main' ;;
-	ifc* | ifort*)			# Intel Fortran compiler
-	  tmp_addflag=' -nofor_main' ;;
-	lf95*)				# Lahey Fortran 8.1
-	  whole_archive_flag_spec=
-	  tmp_sharedflag='--shared' ;;
-        nagfor*)                        # NAGFOR 5.3
-          tmp_sharedflag='-Wl,-shared' ;;
-	xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below)
-	  tmp_sharedflag='-qmkshrobj'
-	  tmp_addflag= ;;
-	nvcc*)	# Cuda Compiler Driver 2.2
-	  whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
-	  compiler_needs_object=yes
-	  ;;
-	esac
-	case `$CC -V 2>&1 | sed 5q` in
-	*Sun\ C*)			# Sun C 5.9
-	  whole_archive_flag_spec='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
-	  compiler_needs_object=yes
-	  tmp_sharedflag='-G' ;;
-	*Sun\ F*)			# Sun Fortran 8.3
-	  tmp_sharedflag='-G' ;;
-	esac
-	archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
 
-        if test yes = "$supports_anon_versioning"; then
-          archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
-            cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-            echo "local: *; };" >> $output_objdir/$libname.ver~
-            $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib'
-        fi
 
-	case $cc_basename in
-	tcc*)
-	  export_dynamic_flag_spec='-rdynamic'
-	  ;;
-	xlf* | bgf* | bgxlf* | mpixlf*)
-	  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
-	  whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive'
-	  hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
-	  archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
-	  if test yes = "$supports_anon_versioning"; then
-	    archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
-              cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-              echo "local: *; };" >> $output_objdir/$libname.ver~
-              $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
-	  fi
-	  ;;
-	esac
-      else
-        ld_shlibs=no
-      fi
-      ;;
 
-    netbsd*)
-      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-	archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
-	wlarc=
-      else
-	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
-	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
-      fi
+
+
+  # Check whether --enable-fast-install was given.
+if test ${enable_fast_install+y}
+then :
+  enableval=$enable_fast_install; p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_fast_install=yes ;;
+    no) enable_fast_install=no ;;
+    *)
+      enable_fast_install=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
+      for pkg in $enableval; do
+	IFS=$lt_save_ifs
+	if test "X$pkg" = "X$p"; then
+	  enable_fast_install=yes
+	fi
+      done
+      IFS=$lt_save_ifs
       ;;
+    esac
+else $as_nop
+  enable_fast_install=yes
+fi
 
-    solaris*)
-      if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
-	ld_shlibs=no
-	cat <<_LT_EOF 1>&2
 
-*** Warning: The releases 2.8.* of the GNU linker cannot reliably
-*** create shared libraries on Solaris systems.  Therefore, libtool
-*** is disabling shared libraries support.  We urge you to upgrade GNU
-*** binutils to release 2.9.1 or newer.  Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
 
-_LT_EOF
-      elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
-	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
-      else
-	ld_shlibs=no
-      fi
-      ;;
 
-    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
-      case `$LD -v 2>&1` in
-        *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
-	ld_shlibs=no
-	cat <<_LT_EOF 1>&2
 
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot
-*** reliably create shared libraries on SCO systems.  Therefore, libtool
-*** is disabling shared libraries support.  We urge you to upgrade GNU
-*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
 
-_LT_EOF
-	;;
-	*)
-	  # For security reasons, it is highly recommended that you always
-	  # use absolute paths for naming shared libraries, and exclude the
-	  # DT_RUNPATH tag from executables and libraries.  But doing so
-	  # requires that you compile everything twice, which is a pain.
-	  if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	    hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
-	    archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
-	    archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
-	  else
-	    ld_shlibs=no
-	  fi
-	;;
-      esac
-      ;;
 
-    sunos4*)
-      archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-      wlarc=
-      hardcode_direct=yes
-      hardcode_shlibpath_var=no
-      ;;
 
+  shared_archive_member_spec=
+case $host,$enable_shared in
+power*-*-aix[5-9]*,yes)
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking which variant of shared library versioning to provide" >&5
+printf %s "checking which variant of shared library versioning to provide... " >&6; }
+
+# Check whether --with-aix-soname was given.
+if test ${with_aix_soname+y}
+then :
+  withval=$with_aix_soname; case $withval in
+    aix|svr4|both)
+      ;;
     *)
-      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
-	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
-      else
-	ld_shlibs=no
-      fi
+      as_fn_error $? "Unknown argument to --with-aix-soname" "$LINENO" 5
       ;;
     esac
+    lt_cv_with_aix_soname=$with_aix_soname
+else $as_nop
+  if test ${lt_cv_with_aix_soname+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  lt_cv_with_aix_soname=aix
+fi
 
-    if test no = "$ld_shlibs"; then
-      runpath_var=
-      hardcode_libdir_flag_spec=
-      export_dynamic_flag_spec=
-      whole_archive_flag_spec=
+    with_aix_soname=$lt_cv_with_aix_soname
+fi
+
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_aix_soname" >&5
+printf "%s\n" "$with_aix_soname" >&6; }
+  if test aix != "$with_aix_soname"; then
+    # For the AIX way of multilib, we name the shared archive member
+    # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o',
+    # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File.
+    # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag,
+    # the AIX toolchain works better with OBJECT_MODE set (default 32).
+    if test 64 = "${OBJECT_MODE-32}"; then
+      shared_archive_member_spec=shr_64
+    else
+      shared_archive_member_spec=shr
     fi
-  else
-    # PORTME fill in a description of your system's linker (not GNU ld)
-    case $host_os in
-    aix3*)
-      allow_undefined_flag=unsupported
-      always_export_symbols=yes
-      archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
-      # Note: this linker hardcodes the directories in LIBPATH if there
-      # are no directories specified by -L.
-      hardcode_minus_L=yes
-      if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then
-	# Neither direct hardcoding nor static linking is supported with a
-	# broken collect2.
-	hardcode_direct=unsupported
-      fi
-      ;;
+  fi
+  ;;
+*)
+  with_aix_soname=aix
+  ;;
+esac
+
+
 
-    aix[4-9]*)
-      if test ia64 = "$host_cpu"; then
-	# On IA64, the linker does run time linking by default, so we don't
-	# have to do anything special.
-	aix_use_runtimelinking=no
-	exp_sym_flag='-Bexport'
-	no_entry_flag=
-      else
-	# If we're using GNU nm, then we don't want the "-C" option.
-	# -C means demangle to GNU nm, but means don't demangle to AIX nm.
-	# Without the "-l" option, or with the "-B" option, AIX nm treats
-	# weak defined symbols like other global defined symbols, whereas
-	# GNU nm marks them as "W".
-	# While the 'weak' keyword is ignored in the Export File, we need
-	# it in the Import File for the 'aix-soname' feature, so we have
-	# to replace the "-B" option with "-P" for AIX nm.
-	if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
-	  export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols'
-	else
-	  export_symbols_cmds='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols'
-	fi
-	aix_use_runtimelinking=no
 
-	# Test if we are trying to use run time linking or normal
-	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
-	# have runtime linking enabled, and use it for executables.
-	# For shared libraries, we enable/disable runtime linking
-	# depending on the kind of the shared library created -
-	# when "with_aix_soname,aix_use_runtimelinking" is:
-	# "aix,no"   lib.a(lib.so.V) shared, rtl:no,  for executables
-	# "aix,yes"  lib.so          shared, rtl:yes, for executables
-	#            lib.a           static archive
-	# "both,no"  lib.so.V(shr.o) shared, rtl:yes
-	#            lib.a(lib.so.V) shared, rtl:no,  for executables
-	# "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables
-	#            lib.a(lib.so.V) shared, rtl:no
-	# "svr4,*"   lib.so.V(shr.o) shared, rtl:yes, for executables
-	#            lib.a           static archive
-	case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
-	  for ld_flag in $LDFLAGS; do
-	  if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then
-	    aix_use_runtimelinking=yes
-	    break
-	  fi
-	  done
-	  if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then
-	    # With aix-soname=svr4, we create the lib.so.V shared archives only,
-	    # so we don't have lib.a shared libs to link our executables.
-	    # We have to force runtime linking in this case.
-	    aix_use_runtimelinking=yes
-	    LDFLAGS="$LDFLAGS -Wl,-brtl"
-	  fi
-	  ;;
-	esac
 
-	exp_sym_flag='-bexport'
-	no_entry_flag='-bnoentry'
-      fi
 
-      # When large executables or shared objects are built, AIX ld can
-      # have problems creating the table of contents.  If linking a library
-      # or program results in "error TOC overflow" add -mminimal-toc to
-      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
-      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
 
-      archive_cmds=''
-      hardcode_direct=yes
-      hardcode_direct_absolute=yes
-      hardcode_libdir_separator=':'
-      link_all_deplibs=yes
-      file_list_spec='$wl-f,'
-      case $with_aix_soname,$aix_use_runtimelinking in
-      aix,*) ;; # traditional, no import file
-      svr4,* | *,yes) # use import file
-	# The Import File defines what to hardcode.
-	hardcode_direct=no
-	hardcode_direct_absolute=no
-	;;
-      esac
 
-      if test yes = "$GCC"; then
-	case $host_os in aix4.[012]|aix4.[012].*)
-	# We only want to do this on AIX 4.2 and lower, the check
-	# below for broken collect2 doesn't work under 4.3+
-	  collect2name=`$CC -print-prog-name=collect2`
-	  if test -f "$collect2name" &&
-	   strings "$collect2name" | $GREP resolve_lib_name >/dev/null
-	  then
-	  # We have reworked collect2
-	  :
-	  else
-	  # We have old collect2
-	  hardcode_direct=unsupported
-	  # It fails to find uninstalled libraries when the uninstalled
-	  # path is not listed in the libpath.  Setting hardcode_minus_L
-	  # to unsupported forces relinking
-	  hardcode_minus_L=yes
-	  hardcode_libdir_flag_spec='-L$libdir'
-	  hardcode_libdir_separator=
-	  fi
-	  ;;
-	esac
-	shared_flag='-shared'
-	if test yes = "$aix_use_runtimelinking"; then
-	  shared_flag="$shared_flag "'$wl-G'
-	fi
-	# Need to ensure runtime linking is disabled for the traditional
-	# shared library, or the linker may eventually find shared libraries
-	# /with/ Import File - we do not want to mix them.
-	shared_flag_aix='-shared'
-	shared_flag_svr4='-shared $wl-G'
-      else
-	# not using gcc
-	if test ia64 = "$host_cpu"; then
-	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
-	# chokes on -Wl,-G. The following line is correct:
-	  shared_flag='-G'
-	else
-	  if test yes = "$aix_use_runtimelinking"; then
-	    shared_flag='$wl-G'
-	  else
-	    shared_flag='$wl-bM:SRE'
-	  fi
-	  shared_flag_aix='$wl-bM:SRE'
-	  shared_flag_svr4='$wl-G'
-	fi
-      fi
 
-      export_dynamic_flag_spec='$wl-bexpall'
-      # It seems that -bexpall does not export symbols beginning with
-      # underscore (_), so it is better to generate a list of symbols to export.
-      always_export_symbols=yes
-      if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then
-	# Warning - without using the other runtime loading flags (-brtl),
-	# -berok will link without error, but may produce a broken library.
-	allow_undefined_flag='-berok'
-        # Determine the default libpath from the value encoded in an
-        # empty executable.
-        if test set = "${lt_cv_aix_libpath+set}"; then
-  aix_libpath=$lt_cv_aix_libpath
-else
-  if test ${lt_cv_aix_libpath_+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
 
-int
-main (void)
-{
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS=$ltmain
 
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"
-then :
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
 
-  lt_aix_libpath_sed='
-      /Import File Strings/,/^$/ {
-	  /^0/ {
-	      s/^0  *\([^ ]*\) *$/\1/
-	      p
-	  }
-      }'
-  lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
-  # Check for a 64-bit object if we didn't find anything.
-  if test -z "$lt_cv_aix_libpath_"; then
-    lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
-  fi
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam \
-    conftest$ac_exeext conftest.$ac_ext
-  if test -z "$lt_cv_aix_libpath_"; then
-    lt_cv_aix_libpath_=/usr/lib:/lib
-  fi
 
-fi
 
-  aix_libpath=$lt_cv_aix_libpath_
-fi
 
-        hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath"
-        archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag
-      else
-	if test ia64 = "$host_cpu"; then
-	  hardcode_libdir_flag_spec='$wl-R $libdir:/usr/lib:/lib'
-	  allow_undefined_flag="-z nodefs"
-	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols"
-	else
-	 # Determine the default libpath from the value encoded in an
-	 # empty executable.
-	 if test set = "${lt_cv_aix_libpath+set}"; then
-  aix_libpath=$lt_cv_aix_libpath
-else
-  if test ${lt_cv_aix_libpath_+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
 
-int
-main (void)
-{
 
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"
-then :
 
-  lt_aix_libpath_sed='
-      /Import File Strings/,/^$/ {
-	  /^0/ {
-	      s/^0  *\([^ ]*\) *$/\1/
-	      p
-	  }
-      }'
-  lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
-  # Check for a 64-bit object if we didn't find anything.
-  if test -z "$lt_cv_aix_libpath_"; then
-    lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
-  fi
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam \
-    conftest$ac_exeext conftest.$ac_ext
-  if test -z "$lt_cv_aix_libpath_"; then
-    lt_cv_aix_libpath_=/usr/lib:/lib
-  fi
 
-fi
 
-  aix_libpath=$lt_cv_aix_libpath_
-fi
 
-	 hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath"
-	  # Warning - without using the other run time loading flags,
-	  # -berok will link without error, but may produce a broken library.
-	  no_undefined_flag=' $wl-bernotok'
-	  allow_undefined_flag=' $wl-berok'
-	  if test yes = "$with_gnu_ld"; then
-	    # We only use this code for GNU lds that support --whole-archive.
-	    whole_archive_flag_spec='$wl--whole-archive$convenience $wl--no-whole-archive'
-	  else
-	    # Exported symbols can be pulled into shared objects from archives
-	    whole_archive_flag_spec='$convenience'
-	  fi
-	  archive_cmds_need_lc=yes
-	  archive_expsym_cmds='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d'
-	  # -brtl affects multiple linker settings, -berok does not and is overridden later
-	  compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([, ]\\)%-berok\\1%g"`'
-	  if test svr4 != "$with_aix_soname"; then
-	    # This is similar to how AIX traditionally builds its shared libraries.
-	    archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname'
-	  fi
-	  if test aix != "$with_aix_soname"; then
-	    archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp'
-	  else
-	    # used by -dlpreopen to get the symbols
-	    archive_expsym_cmds="$archive_expsym_cmds"'~$MV  $output_objdir/$realname.d/$soname $output_objdir'
-	  fi
-	  archive_expsym_cmds="$archive_expsym_cmds"'~$RM -r $output_objdir/$realname.d'
-	fi
-      fi
-      ;;
 
-    amigaos*)
-      case $host_cpu in
-      powerpc)
-            # see comment about AmigaOS4 .so support
-            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
-            archive_expsym_cmds=''
-        ;;
-      m68k)
-            archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
-            hardcode_libdir_flag_spec='-L$libdir'
-            hardcode_minus_L=yes
-        ;;
-      esac
-      ;;
 
-    bsdi[45]*)
-      export_dynamic_flag_spec=-rdynamic
-      ;;
 
-    cygwin* | mingw* | pw32* | cegcc*)
-      # When not using gcc, we currently assume that we are using
-      # Microsoft Visual C++.
-      # hardcode_libdir_flag_spec is actually meaningless, as there is
-      # no search path for DLLs.
-      case $cc_basename in
-      cl*)
-	# Native MSVC
-	hardcode_libdir_flag_spec=' '
-	allow_undefined_flag=unsupported
-	always_export_symbols=yes
-	file_list_spec='@'
-	# Tell ltmain to make .lib files, not .a files.
-	libext=lib
-	# Tell ltmain to make .dll files, not .so files.
-	shrext_cmds=.dll
-	# FIXME: Setting linknames here is a bad hack.
-	archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames='
-	archive_expsym_cmds='if   test DEF = "`$SED -n     -e '\''s/^[	 ]*//'\''     -e '\''/^\(;.*\)*$/d'\''     -e '\''s/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p'\''     -e q     $export_symbols`" ; then
-            cp "$export_symbols" "$output_objdir/$soname.def";
-            echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp";
-          else
-            $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp;
-          fi~
-          $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
-          linknames='
-	# The linker will not automatically build a static lib if we build a DLL.
-	# _LT_TAGVAR(old_archive_from_new_cmds, )='true'
-	enable_shared_with_static_runtimes=yes
-	exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'
-	export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols'
-	# Don't use ranlib
-	old_postinstall_cmds='chmod 644 $oldlib'
-	postlink_cmds='lt_outputfile="@OUTPUT@"~
-          lt_tool_outputfile="@TOOL_OUTPUT@"~
-          case $lt_outputfile in
-            *.exe|*.EXE) ;;
-            *)
-              lt_outputfile=$lt_outputfile.exe
-              lt_tool_outputfile=$lt_tool_outputfile.exe
-              ;;
-          esac~
-          if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then
-            $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
-            $RM "$lt_outputfile.manifest";
-          fi'
-	;;
-      *)
-	# Assume MSVC wrapper
-	hardcode_libdir_flag_spec=' '
-	allow_undefined_flag=unsupported
-	# Tell ltmain to make .lib files, not .a files.
-	libext=lib
-	# Tell ltmain to make .dll files, not .so files.
-	shrext_cmds=.dll
-	# FIXME: Setting linknames here is a bad hack.
-	archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames='
-	# The linker will automatically build a .lib file if we build a DLL.
-	old_archive_from_new_cmds='true'
-	# FIXME: Should let the user specify the lib program.
-	old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs'
-	enable_shared_with_static_runtimes=yes
-	;;
-      esac
-      ;;
 
-    darwin* | rhapsody*)
 
 
-  archive_cmds_need_lc=no
-  hardcode_direct=no
-  hardcode_automatic=yes
-  hardcode_shlibpath_var=unsupported
-  if test yes = "$lt_cv_ld_force_load"; then
-    whole_archive_flag_spec='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
 
-  else
-    whole_archive_flag_spec=''
-  fi
-  link_all_deplibs=yes
-  allow_undefined_flag=$_lt_dar_allow_undefined
-  case $cc_basename in
-     ifort*|nagfor*) _lt_dar_can_shared=yes ;;
-     *) _lt_dar_can_shared=$GCC ;;
-  esac
-  if test yes = "$_lt_dar_can_shared"; then
-    output_verbose_link_cmd=func_echo_all
-    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil"
-    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil"
-    archive_expsym_cmds="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil"
-    module_expsym_cmds="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil"
 
-  else
-  ld_shlibs=no
-  fi
 
-      ;;
 
-    dgux*)
-      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_libdir_flag_spec='-L$libdir'
-      hardcode_shlibpath_var=no
-      ;;
 
-    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
-    # support.  Future versions do this automatically, but an explicit c++rt0.o
-    # does not break anything, and helps significantly (at the cost of a little
-    # extra space).
-    freebsd2.2*)
-      archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
-      hardcode_libdir_flag_spec='-R$libdir'
-      hardcode_direct=yes
-      hardcode_shlibpath_var=no
-      ;;
 
-    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
-    freebsd2.*)
-      archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_direct=yes
-      hardcode_minus_L=yes
-      hardcode_shlibpath_var=no
-      ;;
 
-    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
-    freebsd* | dragonfly*)
-      archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-      hardcode_libdir_flag_spec='-R$libdir'
-      hardcode_direct=yes
-      hardcode_shlibpath_var=no
-      ;;
 
-    hpux9*)
-      if test yes = "$GCC"; then
-	archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
-      else
-	archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
-      fi
-      hardcode_libdir_flag_spec='$wl+b $wl$libdir'
-      hardcode_libdir_separator=:
-      hardcode_direct=yes
 
-      # hardcode_minus_L: Not really in the search PATH,
-      # but as the default location of the library.
-      hardcode_minus_L=yes
-      export_dynamic_flag_spec='$wl-E'
-      ;;
 
-    hpux10*)
-      if test yes,no = "$GCC,$with_gnu_ld"; then
-	archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
-      fi
-      if test no = "$with_gnu_ld"; then
-	hardcode_libdir_flag_spec='$wl+b $wl$libdir'
-	hardcode_libdir_separator=:
-	hardcode_direct=yes
-	hardcode_direct_absolute=yes
-	export_dynamic_flag_spec='$wl-E'
-	# hardcode_minus_L: Not really in the search PATH,
-	# but as the default location of the library.
-	hardcode_minus_L=yes
-      fi
-      ;;
 
-    hpux11*)
-      if test yes,no = "$GCC,$with_gnu_ld"; then
-	case $host_cpu in
-	hppa*64*)
-	  archive_cmds='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	ia64*)
-	  archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	*)
-	  archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	esac
-      else
-	case $host_cpu in
-	hppa*64*)
-	  archive_cmds='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	ia64*)
-	  archive_cmds='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	*)
 
-	  # Older versions of the 11.00 compiler do not understand -b yet
-	  # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does)
-	  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5
-printf %s "checking if $CC understands -b... " >&6; }
-if test ${lt_cv_prog_compiler__b+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  lt_cv_prog_compiler__b=no
-   save_LDFLAGS=$LDFLAGS
-   LDFLAGS="$LDFLAGS -b"
-   echo "$lt_simple_link_test_code" > conftest.$ac_ext
-   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
-     # The linker can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     if test -s conftest.err; then
-       # Append any errors to the config.log.
-       cat conftest.err 1>&5
-       $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
-       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-       if diff conftest.exp conftest.er2 >/dev/null; then
-         lt_cv_prog_compiler__b=yes
-       fi
-     else
-       lt_cv_prog_compiler__b=yes
-     fi
-   fi
-   $RM -r conftest*
-   LDFLAGS=$save_LDFLAGS
 
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5
-printf "%s\n" "$lt_cv_prog_compiler__b" >&6; }
 
-if test yes = "$lt_cv_prog_compiler__b"; then
-    archive_cmds='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-else
-    archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
-fi
+test -z "$LN_S" && LN_S="ln -s"
+
+
+
+
+
+
+
+
+
+
 
-	  ;;
-	esac
-      fi
-      if test no = "$with_gnu_ld"; then
-	hardcode_libdir_flag_spec='$wl+b $wl$libdir'
-	hardcode_libdir_separator=:
 
-	case $host_cpu in
-	hppa*64*|ia64*)
-	  hardcode_direct=no
-	  hardcode_shlibpath_var=no
-	  ;;
-	*)
-	  hardcode_direct=yes
-	  hardcode_direct_absolute=yes
-	  export_dynamic_flag_spec='$wl-E'
 
-	  # hardcode_minus_L: Not really in the search PATH,
-	  # but as the default location of the library.
-	  hardcode_minus_L=yes
-	  ;;
-	esac
-      fi
-      ;;
 
-    irix5* | irix6* | nonstopux*)
-      if test yes = "$GCC"; then
-	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
-	# Try to use the -exported_symbol ld option, if it does not
-	# work, assume that -exports_file does not work either and
-	# implicitly export all symbols.
-	# This should be the same for all languages, so no per-tag cache variable.
-	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5
-printf %s "checking whether the $host_os linker accepts -exported_symbol... " >&6; }
-if test ${lt_cv_irix_exported_symbol+y}
+if test -n "${ZSH_VERSION+set}"; then
+   setopt NO_GLOB_SUBST
+fi
+
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5
+printf %s "checking for objdir... " >&6; }
+if test ${lt_cv_objdir+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  save_LDFLAGS=$LDFLAGS
-	   LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null"
-	   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-int foo (void) { return 0; }
-_ACEOF
-if ac_fn_c_try_link "$LINENO"
-then :
-  lt_cv_irix_exported_symbol=yes
-else $as_nop
-  lt_cv_irix_exported_symbol=no
+  rm -f .libs 2>/dev/null
+mkdir .libs 2>/dev/null
+if test -d .libs; then
+  lt_cv_objdir=.libs
+else
+  # MS-DOS does not allow filenames that begin with a dot.
+  lt_cv_objdir=_libs
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam \
-    conftest$ac_exeext conftest.$ac_ext
-           LDFLAGS=$save_LDFLAGS
+rmdir .libs 2>/dev/null
 fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5
-printf "%s\n" "$lt_cv_irix_exported_symbol" >&6; }
-	if test yes = "$lt_cv_irix_exported_symbol"; then
-          archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib'
-	fi
-      else
-	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
-	archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib'
-      fi
-      archive_cmds_need_lc='no'
-      hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
-      hardcode_libdir_separator=:
-      inherit_rpath=yes
-      link_all_deplibs=yes
-      ;;
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5
+printf "%s\n" "$lt_cv_objdir" >&6; }
+objdir=$lt_cv_objdir
 
-    linux*)
-      case $cc_basename in
-      tcc*)
-	# Fabrice Bellard et al's Tiny C Compiler
-	ld_shlibs=yes
-	archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	;;
-      esac
-      ;;
 
-    netbsd*)
-      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-	archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
-      else
-	archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
-      fi
-      hardcode_libdir_flag_spec='-R$libdir'
-      hardcode_direct=yes
-      hardcode_shlibpath_var=no
-      ;;
 
-    newsos6)
-      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_direct=yes
-      hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
-      hardcode_libdir_separator=:
-      hardcode_shlibpath_var=no
-      ;;
 
-    *nto* | *qnx*)
-      ;;
 
-    openbsd* | bitrig*)
-      if test -f /usr/libexec/ld.so; then
-	hardcode_direct=yes
-	hardcode_shlibpath_var=no
-	hardcode_direct_absolute=yes
-	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
-	  archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	  archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols'
-	  hardcode_libdir_flag_spec='$wl-rpath,$libdir'
-	  export_dynamic_flag_spec='$wl-E'
-	else
-	  archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	  hardcode_libdir_flag_spec='$wl-rpath,$libdir'
-	fi
-      else
-	ld_shlibs=no
-      fi
-      ;;
+printf "%s\n" "#define LT_OBJDIR \"$lt_cv_objdir/\"" >>confdefs.h
+
+
+
+
+case $host_os in
+aix3*)
+  # AIX sometimes has problems with the GCC collect2 program.  For some
+  # reason, if we set the COLLECT_NAMES environment variable, the problems
+  # vanish in a puff of smoke.
+  if test set != "${COLLECT_NAMES+set}"; then
+    COLLECT_NAMES=
+    export COLLECT_NAMES
+  fi
+  ;;
+esac
+
+# Global variables:
+ofile=libtool
+can_build_shared=yes
+
+# All known linkers require a '.a' archive for static linking (except MSVC,
+# which needs '.lib').
+libext=a
+
+with_gnu_ld=$lt_cv_prog_gnu_ld
+
+old_CC=$CC
+old_CFLAGS=$CFLAGS
+
+# Set sane defaults for various variables
+test -z "$CC" && CC=cc
+test -z "$LTCC" && LTCC=$CC
+test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
+test -z "$LD" && LD=ld
+test -z "$ac_objext" && ac_objext=o
+
+func_cc_basename $compiler
+cc_basename=$func_cc_basename_result
+
 
-    os2*)
-      hardcode_libdir_flag_spec='-L$libdir'
-      hardcode_minus_L=yes
-      allow_undefined_flag=unsupported
-      shrext_cmds=.dll
-      archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
-	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
-	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
-	$ECHO EXPORTS >> $output_objdir/$libname.def~
-	emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
-	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
-	emximp -o $lib $output_objdir/$libname.def'
-      archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
-	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
-	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
-	$ECHO EXPORTS >> $output_objdir/$libname.def~
-	prefix_cmds="$SED"~
-	if test EXPORTS = "`$SED 1q $export_symbols`"; then
-	  prefix_cmds="$prefix_cmds -e 1d";
-	fi~
-	prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
-	cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
-	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
-	emximp -o $lib $output_objdir/$libname.def'
-      old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
-      enable_shared_with_static_runtimes=yes
-      ;;
+# Only perform the check for file, if the check method requires it
+test -z "$MAGIC_CMD" && MAGIC_CMD=file
+case $deplibs_check_method in
+file_magic*)
+  if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5
+printf %s "checking for ${ac_tool_prefix}file... " >&6; }
+if test ${lt_cv_path_MAGIC_CMD+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  case $MAGIC_CMD in
+[\\/*] |  ?:[\\/]*)
+  lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path.
+  ;;
+*)
+  lt_save_MAGIC_CMD=$MAGIC_CMD
+  lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
+  ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
+  for ac_dir in $ac_dummy; do
+    IFS=$lt_save_ifs
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/${ac_tool_prefix}file"; then
+      lt_cv_path_MAGIC_CMD=$ac_dir/"${ac_tool_prefix}file"
+      if test -n "$file_magic_test_file"; then
+	case $deplibs_check_method in
+	"file_magic "*)
+	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+	  MAGIC_CMD=$lt_cv_path_MAGIC_CMD
+	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+	    $EGREP "$file_magic_regex" > /dev/null; then
+	    :
+	  else
+	    cat <<_LT_EOF 1>&2
 
-    osf3*)
-      if test yes = "$GCC"; then
-	allow_undefined_flag=' $wl-expect_unresolved $wl\*'
-	archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
-      else
-	allow_undefined_flag=' -expect_unresolved \*'
-	archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such.  This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem.  Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+_LT_EOF
+	  fi ;;
+	esac
       fi
-      archive_cmds_need_lc='no'
-      hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
-      hardcode_libdir_separator=:
-      ;;
+      break
+    fi
+  done
+  IFS=$lt_save_ifs
+  MAGIC_CMD=$lt_save_MAGIC_CMD
+  ;;
+esac
+fi
 
-    osf4* | osf5*)	# as osf3* with the addition of -msym flag
-      if test yes = "$GCC"; then
-	allow_undefined_flag=' $wl-expect_unresolved $wl\*'
-	archive_cmds='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
-	hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
-      else
-	allow_undefined_flag=' -expect_unresolved \*'
-	archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
-	archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
-          $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp'
+MAGIC_CMD=$lt_cv_path_MAGIC_CMD
+if test -n "$MAGIC_CMD"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
+printf "%s\n" "$MAGIC_CMD" >&6; }
+else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+fi
 
-	# Both c and cxx compiler support -rpath directly
-	hardcode_libdir_flag_spec='-rpath $libdir'
-      fi
-      archive_cmds_need_lc='no'
-      hardcode_libdir_separator=:
-      ;;
 
-    solaris*)
-      no_undefined_flag=' -z defs'
-      if test yes = "$GCC"; then
-	wlarc='$wl'
-	archive_cmds='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-          $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
-      else
-	case `$CC -V 2>&1` in
-	*"Compilers 5.0"*)
-	  wlarc=''
-	  archive_cmds='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	  archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-            $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
-	  ;;
-	*)
-	  wlarc='$wl'
-	  archive_cmds='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags'
-	  archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-            $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
-	  ;;
-	esac
-      fi
-      hardcode_libdir_flag_spec='-R$libdir'
-      hardcode_shlibpath_var=no
-      case $host_os in
-      solaris2.[0-5] | solaris2.[0-5].*) ;;
-      *)
-	# The compiler driver will combine and reorder linker options,
-	# but understands '-z linker_flag'.  GCC discards it without '$wl',
-	# but is careful enough not to reorder.
-	# Supported since Solaris 2.6 (maybe 2.5.1?)
-	if test yes = "$GCC"; then
-	  whole_archive_flag_spec='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract'
-	else
-	  whole_archive_flag_spec='-z allextract$convenience -z defaultextract'
-	fi
-	;;
-      esac
-      link_all_deplibs=yes
-      ;;
 
-    sunos4*)
-      if test sequent = "$host_vendor"; then
-	# Use $CC to link under sequent, because it throws in some extra .o
-	# files that make .init and .fini sections work.
-	archive_cmds='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
-      fi
-      hardcode_libdir_flag_spec='-L$libdir'
-      hardcode_direct=yes
-      hardcode_minus_L=yes
-      hardcode_shlibpath_var=no
-      ;;
 
-    sysv4)
-      case $host_vendor in
-	sni)
-	  archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	  hardcode_direct=yes # is this really true???
-	;;
-	siemens)
-	  ## LD is ld it makes a PLAMLIB
-	  ## CC just makes a GrossModule.
-	  archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'
-	  reload_cmds='$CC -r -o $output$reload_objs'
-	  hardcode_direct=no
-        ;;
-	motorola)
-	  archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	  hardcode_direct=no #Motorola manual says yes, but my tests say they lie
-	;;
-      esac
-      runpath_var='LD_RUN_PATH'
-      hardcode_shlibpath_var=no
-      ;;
 
-    sysv4.3*)
-      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_shlibpath_var=no
-      export_dynamic_flag_spec='-Bexport'
-      ;;
+if test -z "$lt_cv_path_MAGIC_CMD"; then
+  if test -n "$ac_tool_prefix"; then
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for file" >&5
+printf %s "checking for file... " >&6; }
+if test ${lt_cv_path_MAGIC_CMD+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  case $MAGIC_CMD in
+[\\/*] |  ?:[\\/]*)
+  lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path.
+  ;;
+*)
+  lt_save_MAGIC_CMD=$MAGIC_CMD
+  lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
+  ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
+  for ac_dir in $ac_dummy; do
+    IFS=$lt_save_ifs
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/file"; then
+      lt_cv_path_MAGIC_CMD=$ac_dir/"file"
+      if test -n "$file_magic_test_file"; then
+	case $deplibs_check_method in
+	"file_magic "*)
+	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+	  MAGIC_CMD=$lt_cv_path_MAGIC_CMD
+	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+	    $EGREP "$file_magic_regex" > /dev/null; then
+	    :
+	  else
+	    cat <<_LT_EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such.  This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem.  Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
 
-    sysv4*MP*)
-      if test -d /usr/nec; then
-	archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	hardcode_shlibpath_var=no
-	runpath_var=LD_RUN_PATH
-	hardcode_runpath_var=yes
-	ld_shlibs=yes
+_LT_EOF
+	  fi ;;
+	esac
       fi
-      ;;
+      break
+    fi
+  done
+  IFS=$lt_save_ifs
+  MAGIC_CMD=$lt_save_MAGIC_CMD
+  ;;
+esac
+fi
 
-    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
-      no_undefined_flag='$wl-z,text'
-      archive_cmds_need_lc=no
-      hardcode_shlibpath_var=no
-      runpath_var='LD_RUN_PATH'
+MAGIC_CMD=$lt_cv_path_MAGIC_CMD
+if test -n "$MAGIC_CMD"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
+printf "%s\n" "$MAGIC_CMD" >&6; }
+else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+fi
 
-      if test yes = "$GCC"; then
-	archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-      fi
-      ;;
 
-    sysv5* | sco3.2v5* | sco5v6*)
-      # Note: We CANNOT use -z defs as we might desire, because we do not
-      # link with -lc, and that would cause any symbols used from libc to
-      # always be unresolved, which means just about no library would
-      # ever link correctly.  If we're not using GNU ld we use -z text
-      # though, which does catch some bad symbols but isn't as heavy-handed
-      # as -z defs.
-      no_undefined_flag='$wl-z,text'
-      allow_undefined_flag='$wl-z,nodefs'
-      archive_cmds_need_lc=no
-      hardcode_shlibpath_var=no
-      hardcode_libdir_flag_spec='$wl-R,$libdir'
-      hardcode_libdir_separator=':'
-      link_all_deplibs=yes
-      export_dynamic_flag_spec='$wl-Bexport'
-      runpath_var='LD_RUN_PATH'
+  else
+    MAGIC_CMD=:
+  fi
+fi
 
-      if test yes = "$GCC"; then
-	archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-      fi
-      ;;
+  fi
+  ;;
+esac
 
-    uts4*)
-      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_libdir_flag_spec='-L$libdir'
-      hardcode_shlibpath_var=no
-      ;;
+# Use C for the default configuration in the libtool script
 
-    *)
-      ld_shlibs=no
-      ;;
-    esac
+lt_save_CC=$CC
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-    if test sni = "$host_vendor"; then
-      case $host in
-      sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
-	export_dynamic_flag_spec='$wl-Blargedynsym'
-	;;
-      esac
-    fi
-  fi
 
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5
-printf "%s\n" "$ld_shlibs" >&6; }
-test no = "$ld_shlibs" && can_build_shared=no
+# Source file extension for C test sources.
+ac_ext=c
+
+# Object file extension for compiled C test sources.
+objext=o
+objext=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(){return(0);}'
 
-with_gnu_ld=$with_gnu_ld
 
 
 
 
 
 
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
 
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
 
+# Allow CC to be a program name with arguments.
+compiler=$CC
 
+# Save the default compiler, since it gets overwritten when the other
+# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
+compiler_DEFAULT=$CC
 
+# save warnings/boilerplate of simple test code
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$RM conftest*
 
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$RM -r conftest*
 
 
+## CAVEAT EMPTOR:
+## There is no encapsulation within the following macros, do not change
+## the running order or otherwise move them around unless you know exactly
+## what you are doing...
+if test -n "$compiler"; then
 
+lt_prog_compiler_no_builtin_flag=
 
-#
-# Do we need to explicitly link libc?
-#
-case "x$archive_cmds_need_lc" in
-x|xyes)
-  # Assume -lc should be added
-  archive_cmds_need_lc=yes
+if test yes = "$GCC"; then
+  case $cc_basename in
+  nvcc*)
+    lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;;
+  *)
+    lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;;
+  esac
 
-  if test yes,yes = "$GCC,$enable_shared"; then
-    case $archive_cmds in
-    *'~'*)
-      # FIXME: we may have to deal with multi-command sequences.
-      ;;
-    '$CC '*)
-      # Test whether the compiler implicitly links with -lc since on some
-      # systems, -lgcc has to come before -lc. If gcc already passes -lc
-      # to ld, don't add -lc before -lgcc.
-      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5
-printf %s "checking whether -lc should be explicitly linked in... " >&6; }
-if test ${lt_cv_archive_cmds_need_lc+y}
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
+printf %s "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; }
+if test ${lt_cv_prog_compiler_rtti_exceptions+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  $RM conftest*
-	echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+  lt_cv_prog_compiler_rtti_exceptions=no
+   ac_outfile=conftest.$ac_objext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="-fno-rtti -fno-exceptions"  ## exclude from sc_useless_quotes_in_assignment
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_rtti_exceptions=yes
+     fi
+   fi
+   $RM conftest*
+
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
+printf "%s\n" "$lt_cv_prog_compiler_rtti_exceptions" >&6; }
+
+if test yes = "$lt_cv_prog_compiler_rtti_exceptions"; then
+    lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions"
+else
+    :
+fi
+
+fi
+
+
+
+
+
+
+  lt_prog_compiler_wl=
+lt_prog_compiler_pic=
+lt_prog_compiler_static=
+
+
+  if test yes = "$GCC"; then
+    lt_prog_compiler_wl='-Wl,'
+    lt_prog_compiler_static='-static'
+
+    case $host_os in
+      aix*)
+      # All AIX code is PIC.
+      if test ia64 = "$host_cpu"; then
+	# AIX 5 now supports IA64 processor
+	lt_prog_compiler_static='-Bstatic'
+      fi
+      lt_prog_compiler_pic='-fPIC'
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            lt_prog_compiler_pic='-fPIC'
+        ;;
+      m68k)
+            # FIXME: we need at least 68020 code to build shared libraries, but
+            # adding the '-m68020' flag to GCC prevents building anything better,
+            # like '-m68040'.
+            lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4'
+        ;;
+      esac
+      ;;
+
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+
+    mingw* | cygwin* | pw32* | os2* | cegcc*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+      lt_prog_compiler_pic='-DDLL_EXPORT'
+      case $host_os in
+      os2*)
+	lt_prog_compiler_static='$wl-static'
+	;;
+      esac
+      ;;
 
-	if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } 2>conftest.err; then
-	  soname=conftest
-	  lib=conftest
-	  libobjs=conftest.$ac_objext
-	  deplibs=
-	  wl=$lt_prog_compiler_wl
-	  pic_flag=$lt_prog_compiler_pic
-	  compiler_flags=-v
-	  linker_flags=-v
-	  verstring=
-	  output_objdir=.
-	  libname=conftest
-	  lt_save_allow_undefined_flag=$allow_undefined_flag
-	  allow_undefined_flag=
-	  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5
-  (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
-  ac_status=$?
-  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
-	  then
-	    lt_cv_archive_cmds_need_lc=no
-	  else
-	    lt_cv_archive_cmds_need_lc=yes
-	  fi
-	  allow_undefined_flag=$lt_save_allow_undefined_flag
-	else
-	  cat conftest.err 1>&5
-	fi
-	$RM conftest*
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      lt_prog_compiler_pic='-fno-common'
+      ;;
 
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5
-printf "%s\n" "$lt_cv_archive_cmds_need_lc" >&6; }
-      archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc
+    haiku*)
+      # PIC is the default for Haiku.
+      # The "-static" flag exists, but is broken.
+      lt_prog_compiler_static=
       ;;
-    esac
-  fi
-  ;;
-esac
 
+    hpux*)
+      # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
+      # PA HP-UX.  On IA64 HP-UX, PIC is the default but the pic flag
+      # sets the default TLS model and affects inlining.
+      case $host_cpu in
+      hppa*64*)
+	# +Z the default
+	;;
+      *)
+	lt_prog_compiler_pic='-fPIC'
+	;;
+      esac
+      ;;
 
+    interix[3-9]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
 
+    msdosdjgpp*)
+      # Just because we use GCC doesn't mean we suddenly get shared libraries
+      # on systems that don't support them.
+      lt_prog_compiler_can_build_shared=no
+      enable_shared=no
+      ;;
 
+    *nto* | *qnx*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      lt_prog_compiler_pic='-fPIC -shared'
+      ;;
 
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	lt_prog_compiler_pic=-Kconform_pic
+      fi
+      ;;
 
+    *)
+      lt_prog_compiler_pic='-fPIC'
+      ;;
+    esac
 
+    case $cc_basename in
+    nvcc*) # Cuda Compiler Driver 2.2
+      lt_prog_compiler_wl='-Xlinker '
+      if test -n "$lt_prog_compiler_pic"; then
+        lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic"
+      fi
+      ;;
+    esac
+  else
+    # PORTME Check for flag to pass linker flags through the system compiler.
+    case $host_os in
+    aix*)
+      lt_prog_compiler_wl='-Wl,'
+      if test ia64 = "$host_cpu"; then
+	# AIX 5 now supports IA64 processor
+	lt_prog_compiler_static='-Bstatic'
+      else
+	lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp'
+      fi
+      ;;
 
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      lt_prog_compiler_pic='-fno-common'
+      case $cc_basename in
+      nagfor*)
+        # NAG Fortran compiler
+        lt_prog_compiler_wl='-Wl,-Wl,,'
+        lt_prog_compiler_pic='-PIC'
+        lt_prog_compiler_static='-Bstatic'
+        ;;
+      esac
+      ;;
 
+    mingw* | cygwin* | pw32* | os2* | cegcc*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      lt_prog_compiler_pic='-DDLL_EXPORT'
+      case $host_os in
+      os2*)
+	lt_prog_compiler_static='$wl-static'
+	;;
+      esac
+      ;;
 
+    hpux9* | hpux10* | hpux11*)
+      lt_prog_compiler_wl='-Wl,'
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+	# +Z the default
+	;;
+      *)
+	lt_prog_compiler_pic='+Z'
+	;;
+      esac
+      # Is there a better lt_prog_compiler_static that works with the bundled CC?
+      lt_prog_compiler_static='$wl-a ${wl}archive'
+      ;;
 
+    irix5* | irix6* | nonstopux*)
+      lt_prog_compiler_wl='-Wl,'
+      # PIC (with -KPIC) is the default.
+      lt_prog_compiler_static='-non_shared'
+      ;;
 
+    linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
+      case $cc_basename in
+      # old Intel for x86_64, which still supported -KPIC.
+      ecc*)
+	lt_prog_compiler_wl='-Wl,'
+	lt_prog_compiler_pic='-KPIC'
+	lt_prog_compiler_static='-static'
+        ;;
+      # icc used to be incompatible with GCC.
+      # ICC 10 doesn't accept -KPIC any more.
+      icc* | ifort*)
+	lt_prog_compiler_wl='-Wl,'
+	lt_prog_compiler_pic='-fPIC'
+	lt_prog_compiler_static='-static'
+        ;;
+      # Lahey Fortran 8.1.
+      lf95*)
+	lt_prog_compiler_wl='-Wl,'
+	lt_prog_compiler_pic='--shared'
+	lt_prog_compiler_static='--static'
+	;;
+      nagfor*)
+	# NAG Fortran compiler
+	lt_prog_compiler_wl='-Wl,-Wl,,'
+	lt_prog_compiler_pic='-PIC'
+	lt_prog_compiler_static='-Bstatic'
+	;;
+      tcc*)
+	# Fabrice Bellard et al's Tiny C Compiler
+	lt_prog_compiler_wl='-Wl,'
+	lt_prog_compiler_pic='-fPIC'
+	lt_prog_compiler_static='-static'
+	;;
+      pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
+        # Portland Group compilers (*not* the Pentium gcc compiler,
+	# which looks to be a dead project)
+	lt_prog_compiler_wl='-Wl,'
+	lt_prog_compiler_pic='-fpic'
+	lt_prog_compiler_static='-Bstatic'
+        ;;
+      ccc*)
+        lt_prog_compiler_wl='-Wl,'
+        # All Alpha code is PIC.
+        lt_prog_compiler_static='-non_shared'
+        ;;
+      xl* | bgxl* | bgf* | mpixl*)
+	# IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene
+	lt_prog_compiler_wl='-Wl,'
+	lt_prog_compiler_pic='-qpic'
+	lt_prog_compiler_static='-qstaticlink'
+	;;
+      *)
+	case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*)
+	  # Sun Fortran 8.3 passes all unrecognized flags to the linker
+	  lt_prog_compiler_pic='-KPIC'
+	  lt_prog_compiler_static='-Bstatic'
+	  lt_prog_compiler_wl=''
+	  ;;
+	*Sun\ F* | *Sun*Fortran*)
+	  lt_prog_compiler_pic='-KPIC'
+	  lt_prog_compiler_static='-Bstatic'
+	  lt_prog_compiler_wl='-Qoption ld '
+	  ;;
+	*Sun\ C*)
+	  # Sun C 5.9
+	  lt_prog_compiler_pic='-KPIC'
+	  lt_prog_compiler_static='-Bstatic'
+	  lt_prog_compiler_wl='-Wl,'
+	  ;;
+        *Intel*\ [CF]*Compiler*)
+	  lt_prog_compiler_wl='-Wl,'
+	  lt_prog_compiler_pic='-fPIC'
+	  lt_prog_compiler_static='-static'
+	  ;;
+	*Portland\ Group*)
+	  lt_prog_compiler_wl='-Wl,'
+	  lt_prog_compiler_pic='-fpic'
+	  lt_prog_compiler_static='-Bstatic'
+	  ;;
+	esac
+	;;
+      esac
+      ;;
 
+    newsos6)
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
 
+    *nto* | *qnx*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      lt_prog_compiler_pic='-fPIC -shared'
+      ;;
 
+    osf3* | osf4* | osf5*)
+      lt_prog_compiler_wl='-Wl,'
+      # All OSF/1 code is PIC.
+      lt_prog_compiler_static='-non_shared'
+      ;;
 
+    rdos*)
+      lt_prog_compiler_static='-non_shared'
+      ;;
 
+    solaris*)
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      case $cc_basename in
+      f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)
+	lt_prog_compiler_wl='-Qoption ld ';;
+      *)
+	lt_prog_compiler_wl='-Wl,';;
+      esac
+      ;;
 
+    sunos4*)
+      lt_prog_compiler_wl='-Qoption ld '
+      lt_prog_compiler_pic='-PIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
 
+    sysv4 | sysv4.2uw2* | sysv4.3*)
+      lt_prog_compiler_wl='-Wl,'
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
 
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	lt_prog_compiler_pic='-Kconform_pic'
+	lt_prog_compiler_static='-Bstatic'
+      fi
+      ;;
 
+    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+      lt_prog_compiler_wl='-Wl,'
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
 
+    unicos*)
+      lt_prog_compiler_wl='-Wl,'
+      lt_prog_compiler_can_build_shared=no
+      ;;
 
+    uts4*)
+      lt_prog_compiler_pic='-pic'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
 
+    *)
+      lt_prog_compiler_can_build_shared=no
+      ;;
+    esac
+  fi
 
+case $host_os in
+  # For platforms that do not support PIC, -DPIC is meaningless:
+  *djgpp*)
+    lt_prog_compiler_pic=
+    ;;
+  *)
+    lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC"
+    ;;
+esac
 
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5
+printf %s "checking for $compiler option to produce PIC... " >&6; }
+if test ${lt_cv_prog_compiler_pic+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  lt_cv_prog_compiler_pic=$lt_prog_compiler_pic
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5
+printf "%s\n" "$lt_cv_prog_compiler_pic" >&6; }
+lt_prog_compiler_pic=$lt_cv_prog_compiler_pic
 
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic"; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5
+printf %s "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; }
+if test ${lt_cv_prog_compiler_pic_works+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  lt_cv_prog_compiler_pic_works=no
+   ac_outfile=conftest.$ac_objext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="$lt_prog_compiler_pic -DPIC"  ## exclude from sc_useless_quotes_in_assignment
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_pic_works=yes
+     fi
+   fi
+   $RM conftest*
 
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5
+printf "%s\n" "$lt_cv_prog_compiler_pic_works" >&6; }
 
+if test yes = "$lt_cv_prog_compiler_pic_works"; then
+    case $lt_prog_compiler_pic in
+     "" | " "*) ;;
+     *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;;
+     esac
+else
+    lt_prog_compiler_pic=
+     lt_prog_compiler_can_build_shared=no
+fi
 
+fi
 
 
 
@@ -21881,8 +21456,47 @@ esac
 
 
 
+#
+# Check to make sure the static flag actually works.
+#
+wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\"
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5
+printf %s "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }
+if test ${lt_cv_prog_compiler_static_works+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  lt_cv_prog_compiler_static_works=no
+   save_LDFLAGS=$LDFLAGS
+   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
+   echo "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&5
+       $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
+       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         lt_cv_prog_compiler_static_works=yes
+       fi
+     else
+       lt_cv_prog_compiler_static_works=yes
+     fi
+   fi
+   $RM -r conftest*
+   LDFLAGS=$save_LDFLAGS
 
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5
+printf "%s\n" "$lt_cv_prog_compiler_static_works" >&6; }
 
+if test yes = "$lt_cv_prog_compiler_static_works"; then
+    :
+else
+    lt_prog_compiler_static=
+fi
 
 
 
@@ -21890,954 +21504,1572 @@ esac
 
 
 
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+printf %s "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if test ${lt_cv_prog_compiler_c_o+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  lt_cv_prog_compiler_c_o=no
+   $RM -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
 
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $RM conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+   $RM out/* && rmdir out
+   cd ..
+   $RM -r conftest
+   $RM conftest*
 
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5
+printf "%s\n" "$lt_cv_prog_compiler_c_o" >&6; }
 
 
 
 
 
 
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+printf %s "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if test ${lt_cv_prog_compiler_c_o+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  lt_cv_prog_compiler_c_o=no
+   $RM -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
 
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $RM conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+   $RM out/* && rmdir out
+   cd ..
+   $RM -r conftest
+   $RM conftest*
 
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5
+printf "%s\n" "$lt_cv_prog_compiler_c_o" >&6; }
 
 
 
 
+hard_links=nottested
+if test no = "$lt_cv_prog_compiler_c_o" && test no != "$need_locks"; then
+  # do not overwrite the value of need_locks provided by the user
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
+printf %s "checking if we can lock with hard links... " >&6; }
+  hard_links=yes
+  $RM conftest*
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  touch conftest.a
+  ln conftest.a conftest.b 2>&5 || hard_links=no
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
+printf "%s\n" "$hard_links" >&6; }
+  if test no = "$hard_links"; then
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5
+printf "%s\n" "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;}
+    need_locks=warn
+  fi
+else
+  need_locks=no
+fi
 
 
 
 
 
 
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+printf %s "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
 
+  runpath_var=
+  allow_undefined_flag=
+  always_export_symbols=no
+  archive_cmds=
+  archive_expsym_cmds=
+  compiler_needs_object=no
+  enable_shared_with_static_runtimes=no
+  export_dynamic_flag_spec=
+  export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  hardcode_automatic=no
+  hardcode_direct=no
+  hardcode_direct_absolute=no
+  hardcode_libdir_flag_spec=
+  hardcode_libdir_separator=
+  hardcode_minus_L=no
+  hardcode_shlibpath_var=unsupported
+  inherit_rpath=no
+  link_all_deplibs=unknown
+  module_cmds=
+  module_expsym_cmds=
+  old_archive_from_new_cmds=
+  old_archive_from_expsyms_cmds=
+  thread_safe_flag_spec=
+  whole_archive_flag_spec=
+  # include_expsyms should be a list of space-separated symbols to be *always*
+  # included in the symbol list
+  include_expsyms=
+  # exclude_expsyms can be an extended regexp of symbols to exclude
+  # it will be wrapped by ' (' and ')$', so one must not match beginning or
+  # end of line.  Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc',
+  # as well as any symbol that contains 'd'.
+  exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
+  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+  # platforms (ab)use it in PIC code, but their linkers get confused if
+  # the symbol is explicitly referenced.  Since portable code cannot
+  # rely on this symbol name, it's probably fine to never include it in
+  # preloaded symbol tables.
+  # Exclude shared library initialization/finalization symbols.
+  extract_expsyms_cmds=
 
+  case $host_os in
+  cygwin* | mingw* | pw32* | cegcc*)
+    # FIXME: the MSVC++ port hasn't been tested in a loooong time
+    # When not using gcc, we currently assume that we are using
+    # Microsoft Visual C++.
+    if test yes != "$GCC"; then
+      with_gnu_ld=no
+    fi
+    ;;
+  interix*)
+    # we just hope/assume this is gcc and not c89 (= MSVC++)
+    with_gnu_ld=yes
+    ;;
+  openbsd* | bitrig*)
+    with_gnu_ld=no
+    ;;
+  esac
 
+  ld_shlibs=yes
 
+  # On some targets, GNU ld is compatible enough with the native linker
+  # that we're better off using the native interface for both.
+  lt_use_gnu_ld_interface=no
+  if test yes = "$with_gnu_ld"; then
+    case $host_os in
+      aix*)
+	# The AIX port of GNU ld has always aspired to compatibility
+	# with the native linker.  However, as the warning in the GNU ld
+	# block says, versions before 2.19.5* couldn't really create working
+	# shared libraries, regardless of the interface used.
+	case `$LD -v 2>&1` in
+	  *\ \(GNU\ Binutils\)\ 2.19.5*) ;;
+	  *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;;
+	  *\ \(GNU\ Binutils\)\ [3-9]*) ;;
+	  *)
+	    lt_use_gnu_ld_interface=yes
+	    ;;
+	esac
+	;;
+      *)
+	lt_use_gnu_ld_interface=yes
+	;;
+    esac
+  fi
 
+  if test yes = "$lt_use_gnu_ld_interface"; then
+    # If archive_cmds runs LD, not CC, wlarc should be empty
+    wlarc='$wl'
 
+    # Set some defaults for GNU ld with shared library support. These
+    # are reset later if shared libraries are not supported. Putting them
+    # here allows them to be overridden if necessary.
+    runpath_var=LD_RUN_PATH
+    hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
+    export_dynamic_flag_spec='$wl--export-dynamic'
+    # ancient GNU ld didn't support --whole-archive et. al.
+    if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
+      whole_archive_flag_spec=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
+    else
+      whole_archive_flag_spec=
+    fi
+    supports_anon_versioning=no
+    case `$LD -v | $SED -e 's/(^)\+)\s\+//' 2>&1` in
+      *GNU\ gold*) supports_anon_versioning=yes ;;
+      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
+      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+      *\ 2.11.*) ;; # other 2.11 versions
+      *) supports_anon_versioning=yes ;;
+    esac
 
+    # See if GNU ld supports shared libraries.
+    case $host_os in
+    aix[3-9]*)
+      # On AIX/PPC, the GNU linker is very broken
+      if test ia64 != "$host_cpu"; then
+	ld_shlibs=no
+	cat <<_LT_EOF 1>&2
 
+*** Warning: the GNU linker, at least up to release 2.19, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support.  If you
+*** really care for shared libraries, you may want to install binutils
+*** 2.20 or above, or modify your PATH so that a non-GNU linker is found.
+*** You will then need to restart the configuration process.
 
+_LT_EOF
+      fi
+      ;;
 
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+            archive_expsym_cmds=''
+        ;;
+      m68k)
+            archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+            hardcode_libdir_flag_spec='-L$libdir'
+            hardcode_minus_L=yes
+        ;;
+      esac
+      ;;
 
+    beos*)
+      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	allow_undefined_flag=unsupported
+	# Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+	# support --undefined.  This deserves some investigation.  FIXME
+	archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+      else
+	ld_shlibs=no
+      fi
+      ;;
 
+    cygwin* | mingw* | pw32* | cegcc*)
+      # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
+      # as there is no search path for DLLs.
+      hardcode_libdir_flag_spec='-L$libdir'
+      export_dynamic_flag_spec='$wl--export-all-symbols'
+      allow_undefined_flag=unsupported
+      always_export_symbols=no
+      enable_shared_with_static_runtimes=yes
+      export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols'
+      exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'
 
+      if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+        archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	# If the export-symbols file already is a .def file, use it as
+	# is; otherwise, prepend EXPORTS...
+	archive_expsym_cmds='if   test DEF = "`$SED -n     -e '\''s/^[	 ]*//'\''     -e '\''/^\(;.*\)*$/d'\''     -e '\''s/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p'\''     -e q     $export_symbols`" ; then
+          cp $export_symbols $output_objdir/$soname.def;
+        else
+          echo EXPORTS > $output_objdir/$soname.def;
+          cat $export_symbols >> $output_objdir/$soname.def;
+        fi~
+        $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+      else
+	ld_shlibs=no
+      fi
+      ;;
 
+    haiku*)
+      archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+      link_all_deplibs=yes
+      ;;
 
+    os2*)
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_minus_L=yes
+      allow_undefined_flag=unsupported
+      shrext_cmds=.dll
+      archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	prefix_cmds="$SED"~
+	if test EXPORTS = "`$SED 1q $export_symbols`"; then
+	  prefix_cmds="$prefix_cmds -e 1d";
+	fi~
+	prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+	cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+      enable_shared_with_static_runtimes=yes
+      ;;
 
+    interix[3-9]*)
+      hardcode_direct=no
+      hardcode_shlibpath_var=no
+      hardcode_libdir_flag_spec='$wl-rpath,$libdir'
+      export_dynamic_flag_spec='$wl-E'
+      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+      # Instead, shared libraries are loaded at an image base (0x10000000 by
+      # default) and relocated if they conflict, which is a slow very memory
+      # consuming and fragmenting process.  To avoid this, we pick a random,
+      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+      archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      archive_expsym_cmds='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      ;;
 
+    gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
+      tmp_diet=no
+      if test linux-dietlibc = "$host_os"; then
+	case $cc_basename in
+	  diet\ *) tmp_diet=yes;;	# linux-dietlibc with static linking (!diet-dyn)
+	esac
+      fi
+      if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
+	 && test no = "$tmp_diet"
+      then
+	tmp_addflag=' $pic_flag'
+	tmp_sharedflag='-shared'
+	case $cc_basename,$host_cpu in
+        pgcc*)				# Portland Group C compiler
+	  whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
+	  tmp_addflag=' $pic_flag'
+	  ;;
+	pgf77* | pgf90* | pgf95* | pgfortran*)
+					# Portland Group f77 and f90 compilers
+	  whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
+	  tmp_addflag=' $pic_flag -Mnomain' ;;
+	ecc*,ia64* | icc*,ia64*)	# Intel C compiler on ia64
+	  tmp_addflag=' -i_dynamic' ;;
+	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
+	  tmp_addflag=' -i_dynamic -nofor_main' ;;
+	ifc* | ifort*)			# Intel Fortran compiler
+	  tmp_addflag=' -nofor_main' ;;
+	lf95*)				# Lahey Fortran 8.1
+	  whole_archive_flag_spec=
+	  tmp_sharedflag='--shared' ;;
+        nagfor*)                        # NAGFOR 5.3
+          tmp_sharedflag='-Wl,-shared' ;;
+	xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below)
+	  tmp_sharedflag='-qmkshrobj'
+	  tmp_addflag= ;;
+	nvcc*)	# Cuda Compiler Driver 2.2
+	  whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
+	  compiler_needs_object=yes
+	  ;;
+	esac
+	case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)			# Sun C 5.9
+	  whole_archive_flag_spec='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
+	  compiler_needs_object=yes
+	  tmp_sharedflag='-G' ;;
+	*Sun\ F*)			# Sun Fortran 8.3
+	  tmp_sharedflag='-G' ;;
+	esac
+	archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
 
+        if test yes = "$supports_anon_versioning"; then
+          archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
+            cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+            echo "local: *; };" >> $output_objdir/$libname.ver~
+            $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib'
+        fi
 
+	case $cc_basename in
+	tcc*)
+	  export_dynamic_flag_spec='-rdynamic'
+	  ;;
+	xlf* | bgf* | bgxlf* | mpixlf*)
+	  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
+	  whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive'
+	  hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
+	  archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
+	  if test yes = "$supports_anon_versioning"; then
+	    archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
+              cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+              echo "local: *; };" >> $output_objdir/$libname.ver~
+              $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+	  fi
+	  ;;
+	esac
+      else
+        ld_shlibs=no
+      fi
+      ;;
 
+    netbsd*)
+      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+	archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+	wlarc=
+      else
+	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
+      fi
+      ;;
 
+    solaris*)
+      if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
+	ld_shlibs=no
+	cat <<_LT_EOF 1>&2
 
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
 
+_LT_EOF
+      elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+	ld_shlibs=no
+      fi
+      ;;
 
+    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+      case `$LD -v 2>&1` in
+        *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
+	ld_shlibs=no
+	cat <<_LT_EOF 1>&2
 
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot
+*** reliably create shared libraries on SCO systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
 
+_LT_EOF
+	;;
+	*)
+	  # For security reasons, it is highly recommended that you always
+	  # use absolute paths for naming shared libraries, and exclude the
+	  # DT_RUNPATH tag from executables and libraries.  But doing so
+	  # requires that you compile everything twice, which is a pain.
+	  if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	    hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
+	    archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	    archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
+	  else
+	    ld_shlibs=no
+	  fi
+	;;
+      esac
+      ;;
 
+    sunos4*)
+      archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      wlarc=
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      ;;
 
+    *)
+      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+	ld_shlibs=no
+      fi
+      ;;
+    esac
 
+    if test no = "$ld_shlibs"; then
+      runpath_var=
+      hardcode_libdir_flag_spec=
+      export_dynamic_flag_spec=
+      whole_archive_flag_spec=
+    fi
+  else
+    # PORTME fill in a description of your system's linker (not GNU ld)
+    case $host_os in
+    aix3*)
+      allow_undefined_flag=unsupported
+      always_export_symbols=yes
+      archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+      # Note: this linker hardcodes the directories in LIBPATH if there
+      # are no directories specified by -L.
+      hardcode_minus_L=yes
+      if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then
+	# Neither direct hardcoding nor static linking is supported with a
+	# broken collect2.
+	hardcode_direct=unsupported
+      fi
+      ;;
 
+    aix[4-9]*)
+      if test ia64 = "$host_cpu"; then
+	# On IA64, the linker does run time linking by default, so we don't
+	# have to do anything special.
+	aix_use_runtimelinking=no
+	exp_sym_flag='-Bexport'
+	no_entry_flag=
+      else
+	# If we're using GNU nm, then we don't want the "-C" option.
+	# -C means demangle to GNU nm, but means don't demangle to AIX nm.
+	# Without the "-l" option, or with the "-B" option, AIX nm treats
+	# weak defined symbols like other global defined symbols, whereas
+	# GNU nm marks them as "W".
+	# While the 'weak' keyword is ignored in the Export File, we need
+	# it in the Import File for the 'aix-soname' feature, so we have
+	# to replace the "-B" option with "-P" for AIX nm.
+	if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+	  export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols'
+	else
+	  export_symbols_cmds='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols'
+	fi
+	aix_use_runtimelinking=no
 
+	# Test if we are trying to use run time linking or normal
+	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
+	# have runtime linking enabled, and use it for executables.
+	# For shared libraries, we enable/disable runtime linking
+	# depending on the kind of the shared library created -
+	# when "with_aix_soname,aix_use_runtimelinking" is:
+	# "aix,no"   lib.a(lib.so.V) shared, rtl:no,  for executables
+	# "aix,yes"  lib.so          shared, rtl:yes, for executables
+	#            lib.a           static archive
+	# "both,no"  lib.so.V(shr.o) shared, rtl:yes
+	#            lib.a(lib.so.V) shared, rtl:no,  for executables
+	# "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables
+	#            lib.a(lib.so.V) shared, rtl:no
+	# "svr4,*"   lib.so.V(shr.o) shared, rtl:yes, for executables
+	#            lib.a           static archive
+	case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
+	  for ld_flag in $LDFLAGS; do
+	  if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then
+	    aix_use_runtimelinking=yes
+	    break
+	  fi
+	  done
+	  if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then
+	    # With aix-soname=svr4, we create the lib.so.V shared archives only,
+	    # so we don't have lib.a shared libs to link our executables.
+	    # We have to force runtime linking in this case.
+	    aix_use_runtimelinking=yes
+	    LDFLAGS="$LDFLAGS -Wl,-brtl"
+	  fi
+	  ;;
+	esac
 
+	exp_sym_flag='-bexport'
+	no_entry_flag='-bnoentry'
+      fi
 
+      # When large executables or shared objects are built, AIX ld can
+      # have problems creating the table of contents.  If linking a library
+      # or program results in "error TOC overflow" add -mminimal-toc to
+      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
 
+      archive_cmds=''
+      hardcode_direct=yes
+      hardcode_direct_absolute=yes
+      hardcode_libdir_separator=':'
+      link_all_deplibs=yes
+      file_list_spec='$wl-f,'
+      case $with_aix_soname,$aix_use_runtimelinking in
+      aix,*) ;; # traditional, no import file
+      svr4,* | *,yes) # use import file
+	# The Import File defines what to hardcode.
+	hardcode_direct=no
+	hardcode_direct_absolute=no
+	;;
+      esac
 
+      if test yes = "$GCC"; then
+	case $host_os in aix4.[012]|aix4.[012].*)
+	# We only want to do this on AIX 4.2 and lower, the check
+	# below for broken collect2 doesn't work under 4.3+
+	  collect2name=`$CC -print-prog-name=collect2`
+	  if test -f "$collect2name" &&
+	   strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+	  then
+	  # We have reworked collect2
+	  :
+	  else
+	  # We have old collect2
+	  hardcode_direct=unsupported
+	  # It fails to find uninstalled libraries when the uninstalled
+	  # path is not listed in the libpath.  Setting hardcode_minus_L
+	  # to unsupported forces relinking
+	  hardcode_minus_L=yes
+	  hardcode_libdir_flag_spec='-L$libdir'
+	  hardcode_libdir_separator=
+	  fi
+	  ;;
+	esac
+	shared_flag='-shared'
+	if test yes = "$aix_use_runtimelinking"; then
+	  shared_flag="$shared_flag "'$wl-G'
+	fi
+	# Need to ensure runtime linking is disabled for the traditional
+	# shared library, or the linker may eventually find shared libraries
+	# /with/ Import File - we do not want to mix them.
+	shared_flag_aix='-shared'
+	shared_flag_svr4='-shared $wl-G'
+      else
+	# not using gcc
+	if test ia64 = "$host_cpu"; then
+	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+	# chokes on -Wl,-G. The following line is correct:
+	  shared_flag='-G'
+	else
+	  if test yes = "$aix_use_runtimelinking"; then
+	    shared_flag='$wl-G'
+	  else
+	    shared_flag='$wl-bM:SRE'
+	  fi
+	  shared_flag_aix='$wl-bM:SRE'
+	  shared_flag_svr4='$wl-G'
+	fi
+      fi
 
+      export_dynamic_flag_spec='$wl-bexpall'
+      # It seems that -bexpall does not export symbols beginning with
+      # underscore (_), so it is better to generate a list of symbols to export.
+      always_export_symbols=yes
+      if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then
+	# Warning - without using the other runtime loading flags (-brtl),
+	# -berok will link without error, but may produce a broken library.
+	allow_undefined_flag='-berok'
+        # Determine the default libpath from the value encoded in an
+        # empty executable.
+        if test set = "${lt_cv_aix_libpath+set}"; then
+  aix_libpath=$lt_cv_aix_libpath
+else
+  if test ${lt_cv_aix_libpath_+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
+int
+main (void)
+{
 
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
+then :
 
+  lt_aix_libpath_sed='
+      /Import File Strings/,/^$/ {
+	  /^0/ {
+	      s/^0  *\([^ ]*\) *$/\1/
+	      p
+	  }
+      }'
+  lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+  # Check for a 64-bit object if we didn't find anything.
+  if test -z "$lt_cv_aix_libpath_"; then
+    lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+  fi
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext
+  if test -z "$lt_cv_aix_libpath_"; then
+    lt_cv_aix_libpath_=/usr/lib:/lib
+  fi
 
+fi
 
+  aix_libpath=$lt_cv_aix_libpath_
+fi
 
+        hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath"
+        archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag
+      else
+	if test ia64 = "$host_cpu"; then
+	  hardcode_libdir_flag_spec='$wl-R $libdir:/usr/lib:/lib'
+	  allow_undefined_flag="-z nodefs"
+	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols"
+	else
+	 # Determine the default libpath from the value encoded in an
+	 # empty executable.
+	 if test set = "${lt_cv_aix_libpath+set}"; then
+  aix_libpath=$lt_cv_aix_libpath
+else
+  if test ${lt_cv_aix_libpath_+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
+int
+main (void)
+{
 
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
+then :
 
+  lt_aix_libpath_sed='
+      /Import File Strings/,/^$/ {
+	  /^0/ {
+	      s/^0  *\([^ ]*\) *$/\1/
+	      p
+	  }
+      }'
+  lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+  # Check for a 64-bit object if we didn't find anything.
+  if test -z "$lt_cv_aix_libpath_"; then
+    lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+  fi
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext
+  if test -z "$lt_cv_aix_libpath_"; then
+    lt_cv_aix_libpath_=/usr/lib:/lib
+  fi
 
+fi
 
+  aix_libpath=$lt_cv_aix_libpath_
+fi
 
+	 hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath"
+	  # Warning - without using the other run time loading flags,
+	  # -berok will link without error, but may produce a broken library.
+	  no_undefined_flag=' $wl-bernotok'
+	  allow_undefined_flag=' $wl-berok'
+	  if test yes = "$with_gnu_ld"; then
+	    # We only use this code for GNU lds that support --whole-archive.
+	    whole_archive_flag_spec='$wl--whole-archive$convenience $wl--no-whole-archive'
+	  else
+	    # Exported symbols can be pulled into shared objects from archives
+	    whole_archive_flag_spec='$convenience'
+	  fi
+	  archive_cmds_need_lc=yes
+	  archive_expsym_cmds='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d'
+	  # -brtl affects multiple linker settings, -berok does not and is overridden later
+	  compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([, ]\\)%-berok\\1%g"`'
+	  if test svr4 != "$with_aix_soname"; then
+	    # This is similar to how AIX traditionally builds its shared libraries.
+	    archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname'
+	  fi
+	  if test aix != "$with_aix_soname"; then
+	    archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp'
+	  else
+	    # used by -dlpreopen to get the symbols
+	    archive_expsym_cmds="$archive_expsym_cmds"'~$MV  $output_objdir/$realname.d/$soname $output_objdir'
+	  fi
+	  archive_expsym_cmds="$archive_expsym_cmds"'~$RM -r $output_objdir/$realname.d'
+	fi
+      fi
+      ;;
 
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+            archive_expsym_cmds=''
+        ;;
+      m68k)
+            archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+            hardcode_libdir_flag_spec='-L$libdir'
+            hardcode_minus_L=yes
+        ;;
+      esac
+      ;;
 
+    bsdi[45]*)
+      export_dynamic_flag_spec=-rdynamic
+      ;;
 
+    cygwin* | mingw* | pw32* | cegcc*)
+      # When not using gcc, we currently assume that we are using
+      # Microsoft Visual C++.
+      # hardcode_libdir_flag_spec is actually meaningless, as there is
+      # no search path for DLLs.
+      case $cc_basename in
+      cl*)
+	# Native MSVC
+	hardcode_libdir_flag_spec=' '
+	allow_undefined_flag=unsupported
+	always_export_symbols=yes
+	file_list_spec='@'
+	# Tell ltmain to make .lib files, not .a files.
+	libext=lib
+	# Tell ltmain to make .dll files, not .so files.
+	shrext_cmds=.dll
+	# FIXME: Setting linknames here is a bad hack.
+	archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames='
+	archive_expsym_cmds='if   test DEF = "`$SED -n     -e '\''s/^[	 ]*//'\''     -e '\''/^\(;.*\)*$/d'\''     -e '\''s/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p'\''     -e q     $export_symbols`" ; then
+            cp "$export_symbols" "$output_objdir/$soname.def";
+            echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp";
+          else
+            $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp;
+          fi~
+          $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+          linknames='
+	# The linker will not automatically build a static lib if we build a DLL.
+	# _LT_TAGVAR(old_archive_from_new_cmds, )='true'
+	enable_shared_with_static_runtimes=yes
+	exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'
+	export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols'
+	# Don't use ranlib
+	old_postinstall_cmds='chmod 644 $oldlib'
+	postlink_cmds='lt_outputfile="@OUTPUT@"~
+          lt_tool_outputfile="@TOOL_OUTPUT@"~
+          case $lt_outputfile in
+            *.exe|*.EXE) ;;
+            *)
+              lt_outputfile=$lt_outputfile.exe
+              lt_tool_outputfile=$lt_tool_outputfile.exe
+              ;;
+          esac~
+          if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then
+            $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+            $RM "$lt_outputfile.manifest";
+          fi'
+	;;
+      *)
+	# Assume MSVC wrapper
+	hardcode_libdir_flag_spec=' '
+	allow_undefined_flag=unsupported
+	# Tell ltmain to make .lib files, not .a files.
+	libext=lib
+	# Tell ltmain to make .dll files, not .so files.
+	shrext_cmds=.dll
+	# FIXME: Setting linknames here is a bad hack.
+	archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames='
+	# The linker will automatically build a .lib file if we build a DLL.
+	old_archive_from_new_cmds='true'
+	# FIXME: Should let the user specify the lib program.
+	old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs'
+	enable_shared_with_static_runtimes=yes
+	;;
+      esac
+      ;;
 
+    darwin* | rhapsody*)
 
 
+  archive_cmds_need_lc=no
+  hardcode_direct=no
+  hardcode_automatic=yes
+  hardcode_shlibpath_var=unsupported
+  if test yes = "$lt_cv_ld_force_load"; then
+    whole_archive_flag_spec='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
 
+  else
+    whole_archive_flag_spec=''
+  fi
+  link_all_deplibs=yes
+  allow_undefined_flag=$_lt_dar_allow_undefined
+  case $cc_basename in
+     ifort*|nagfor*) _lt_dar_can_shared=yes ;;
+     *) _lt_dar_can_shared=$GCC ;;
+  esac
+  if test yes = "$_lt_dar_can_shared"; then
+    output_verbose_link_cmd=func_echo_all
+    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil"
+    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil"
+    archive_expsym_cmds="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil"
+    module_expsym_cmds="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil"
 
+  else
+  ld_shlibs=no
+  fi
 
+      ;;
 
+    dgux*)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_shlibpath_var=no
+      ;;
 
+    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+    # support.  Future versions do this automatically, but an explicit c++rt0.o
+    # does not break anything, and helps significantly (at the cost of a little
+    # extra space).
+    freebsd2.2*)
+      archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      ;;
 
+    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+    freebsd2.*)
+      archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct=yes
+      hardcode_minus_L=yes
+      hardcode_shlibpath_var=no
+      ;;
 
+    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+    freebsd* | dragonfly*)
+      archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      ;;
 
+    hpux9*)
+      if test yes = "$GCC"; then
+	archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
+      else
+	archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
+      fi
+      hardcode_libdir_flag_spec='$wl+b $wl$libdir'
+      hardcode_libdir_separator=:
+      hardcode_direct=yes
 
+      # hardcode_minus_L: Not really in the search PATH,
+      # but as the default location of the library.
+      hardcode_minus_L=yes
+      export_dynamic_flag_spec='$wl-E'
+      ;;
 
+    hpux10*)
+      if test yes,no = "$GCC,$with_gnu_ld"; then
+	archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      if test no = "$with_gnu_ld"; then
+	hardcode_libdir_flag_spec='$wl+b $wl$libdir'
+	hardcode_libdir_separator=:
+	hardcode_direct=yes
+	hardcode_direct_absolute=yes
+	export_dynamic_flag_spec='$wl-E'
+	# hardcode_minus_L: Not really in the search PATH,
+	# but as the default location of the library.
+	hardcode_minus_L=yes
+      fi
+      ;;
 
+    hpux11*)
+      if test yes,no = "$GCC,$with_gnu_ld"; then
+	case $host_cpu in
+	hppa*64*)
+	  archive_cmds='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	ia64*)
+	  archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	  archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	esac
+      else
+	case $host_cpu in
+	hppa*64*)
+	  archive_cmds='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	ia64*)
+	  archive_cmds='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
 
+	  # Older versions of the 11.00 compiler do not understand -b yet
+	  # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does)
+	  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5
+printf %s "checking if $CC understands -b... " >&6; }
+if test ${lt_cv_prog_compiler__b+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  lt_cv_prog_compiler__b=no
+   save_LDFLAGS=$LDFLAGS
+   LDFLAGS="$LDFLAGS -b"
+   echo "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&5
+       $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
+       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         lt_cv_prog_compiler__b=yes
+       fi
+     else
+       lt_cv_prog_compiler__b=yes
+     fi
+   fi
+   $RM -r conftest*
+   LDFLAGS=$save_LDFLAGS
 
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5
+printf "%s\n" "$lt_cv_prog_compiler__b" >&6; }
 
+if test yes = "$lt_cv_prog_compiler__b"; then
+    archive_cmds='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+else
+    archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+fi
 
+	  ;;
+	esac
+      fi
+      if test no = "$with_gnu_ld"; then
+	hardcode_libdir_flag_spec='$wl+b $wl$libdir'
+	hardcode_libdir_separator=:
 
+	case $host_cpu in
+	hppa*64*|ia64*)
+	  hardcode_direct=no
+	  hardcode_shlibpath_var=no
+	  ;;
+	*)
+	  hardcode_direct=yes
+	  hardcode_direct_absolute=yes
+	  export_dynamic_flag_spec='$wl-E'
 
+	  # hardcode_minus_L: Not really in the search PATH,
+	  # but as the default location of the library.
+	  hardcode_minus_L=yes
+	  ;;
+	esac
+      fi
+      ;;
 
+    irix5* | irix6* | nonstopux*)
+      if test yes = "$GCC"; then
+	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
+	# Try to use the -exported_symbol ld option, if it does not
+	# work, assume that -exports_file does not work either and
+	# implicitly export all symbols.
+	# This should be the same for all languages, so no per-tag cache variable.
+	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5
+printf %s "checking whether the $host_os linker accepts -exported_symbol... " >&6; }
+if test ${lt_cv_irix_exported_symbol+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  save_LDFLAGS=$LDFLAGS
+	   LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null"
+	   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+int foo (void) { return 0; }
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
+then :
+  lt_cv_irix_exported_symbol=yes
+else $as_nop
+  lt_cv_irix_exported_symbol=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext
+           LDFLAGS=$save_LDFLAGS
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5
+printf "%s\n" "$lt_cv_irix_exported_symbol" >&6; }
+	if test yes = "$lt_cv_irix_exported_symbol"; then
+          archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib'
+	fi
+      else
+	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
+	archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib'
+      fi
+      archive_cmds_need_lc='no'
+      hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
+      hardcode_libdir_separator=:
+      inherit_rpath=yes
+      link_all_deplibs=yes
+      ;;
 
+    linux*)
+      case $cc_basename in
+      tcc*)
+	# Fabrice Bellard et al's Tiny C Compiler
+	ld_shlibs=yes
+	archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+      esac
+      ;;
 
+    netbsd*)
+      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+	archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
+      else
+	archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
+      fi
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      ;;
 
+    newsos6)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct=yes
+      hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
+      hardcode_libdir_separator=:
+      hardcode_shlibpath_var=no
+      ;;
 
+    *nto* | *qnx*)
+      ;;
 
+    openbsd* | bitrig*)
+      if test -f /usr/libexec/ld.so; then
+	hardcode_direct=yes
+	hardcode_shlibpath_var=no
+	hardcode_direct_absolute=yes
+	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
+	  archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols'
+	  hardcode_libdir_flag_spec='$wl-rpath,$libdir'
+	  export_dynamic_flag_spec='$wl-E'
+	else
+	  archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	  hardcode_libdir_flag_spec='$wl-rpath,$libdir'
+	fi
+      else
+	ld_shlibs=no
+      fi
+      ;;
 
+    os2*)
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_minus_L=yes
+      allow_undefined_flag=unsupported
+      shrext_cmds=.dll
+      archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	prefix_cmds="$SED"~
+	if test EXPORTS = "`$SED 1q $export_symbols`"; then
+	  prefix_cmds="$prefix_cmds -e 1d";
+	fi~
+	prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+	cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+      enable_shared_with_static_runtimes=yes
+      ;;
 
+    osf3*)
+      if test yes = "$GCC"; then
+	allow_undefined_flag=' $wl-expect_unresolved $wl\*'
+	archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
+      else
+	allow_undefined_flag=' -expect_unresolved \*'
+	archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
+      fi
+      archive_cmds_need_lc='no'
+      hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
+      hardcode_libdir_separator=:
+      ;;
 
+    osf4* | osf5*)	# as osf3* with the addition of -msym flag
+      if test yes = "$GCC"; then
+	allow_undefined_flag=' $wl-expect_unresolved $wl\*'
+	archive_cmds='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
+	hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
+      else
+	allow_undefined_flag=' -expect_unresolved \*'
+	archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
+	archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
+          $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp'
 
+	# Both c and cxx compiler support -rpath directly
+	hardcode_libdir_flag_spec='-rpath $libdir'
+      fi
+      archive_cmds_need_lc='no'
+      hardcode_libdir_separator=:
+      ;;
 
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
-printf %s "checking dynamic linker characteristics... " >&6; }
+    solaris*)
+      no_undefined_flag=' -z defs'
+      if test yes = "$GCC"; then
+	wlarc='$wl'
+	archive_cmds='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+          $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+      else
+	case `$CC -V 2>&1` in
+	*"Compilers 5.0"*)
+	  wlarc=''
+	  archive_cmds='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+            $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
+	  ;;
+	*)
+	  wlarc='$wl'
+	  archive_cmds='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+            $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+	  ;;
+	esac
+      fi
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_shlibpath_var=no
+      case $host_os in
+      solaris2.[0-5] | solaris2.[0-5].*) ;;
+      *)
+	# The compiler driver will combine and reorder linker options,
+	# but understands '-z linker_flag'.  GCC discards it without '$wl',
+	# but is careful enough not to reorder.
+	# Supported since Solaris 2.6 (maybe 2.5.1?)
+	if test yes = "$GCC"; then
+	  whole_archive_flag_spec='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract'
+	else
+	  whole_archive_flag_spec='-z allextract$convenience -z defaultextract'
+	fi
+	;;
+      esac
+      link_all_deplibs=yes
+      ;;
 
-if test yes = "$GCC"; then
-  case $host_os in
-    darwin*) lt_awk_arg='/^libraries:/,/LR/' ;;
-    *) lt_awk_arg='/^libraries:/' ;;
-  esac
-  case $host_os in
-    mingw* | cegcc*) lt_sed_strip_eq='s|=\([A-Za-z]:\)|\1|g' ;;
-    *) lt_sed_strip_eq='s|=/|/|g' ;;
-  esac
-  lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`
-  case $lt_search_path_spec in
-  *\;*)
-    # if the path contains ";" then we assume it to be the separator
-    # otherwise default to the standard path separator (i.e. ":") - it is
-    # assumed that no part of a normal pathname contains ";" but that should
-    # okay in the real world where ";" in dirpaths is itself problematic.
-    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'`
-    ;;
-  *)
-    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"`
-    ;;
-  esac
-  # Ok, now we have the path, separated by spaces, we can step through it
-  # and add multilib dir if necessary...
-  lt_tmp_lt_search_path_spec=
-  lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
-  # ...but if some path component already ends with the multilib dir we assume
-  # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer).
-  case "$lt_multi_os_dir; $lt_search_path_spec " in
-  "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*)
-    lt_multi_os_dir=
-    ;;
-  esac
-  for lt_sys_path in $lt_search_path_spec; do
-    if test -d "$lt_sys_path$lt_multi_os_dir"; then
-      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir"
-    elif test -n "$lt_multi_os_dir"; then
-      test -d "$lt_sys_path" && \
-	lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
-    fi
-  done
-  lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk '
-BEGIN {RS = " "; FS = "/|\n";} {
-  lt_foo = "";
-  lt_count = 0;
-  for (lt_i = NF; lt_i > 0; lt_i--) {
-    if ($lt_i != "" && $lt_i != ".") {
-      if ($lt_i == "..") {
-        lt_count++;
-      } else {
-        if (lt_count == 0) {
-          lt_foo = "/" $lt_i lt_foo;
-        } else {
-          lt_count--;
-        }
-      }
-    }
-  }
-  if (lt_foo != "") { lt_freq[lt_foo]++; }
-  if (lt_freq[lt_foo] == 1) { print lt_foo; }
-}'`
-  # AWK program above erroneously prepends '/' to C:/dos/paths
-  # for these hosts.
-  case $host_os in
-    mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\
-      $SED 's|/\([A-Za-z]:\)|\1|g'` ;;
-  esac
-  sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP`
-else
-  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
-fi
-library_names_spec=
-libname_spec='lib$name'
-soname_spec=
-shrext_cmds=.so
-postinstall_cmds=
-postuninstall_cmds=
-finish_cmds=
-finish_eval=
-shlibpath_var=
-shlibpath_overrides_runpath=unknown
-version_type=none
-dynamic_linker="$host_os ld.so"
-sys_lib_dlsearch_path_spec="/lib /usr/lib"
-need_lib_prefix=unknown
-hardcode_into_libs=no
+    sunos4*)
+      if test sequent = "$host_vendor"; then
+	# Use $CC to link under sequent, because it throws in some extra .o
+	# files that make .init and .fini sections work.
+	archive_cmds='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_direct=yes
+      hardcode_minus_L=yes
+      hardcode_shlibpath_var=no
+      ;;
 
-# when you set need_version to no, make sure it does not cause -set_version
-# flags to be left without arguments
-need_version=unknown
+    sysv4)
+      case $host_vendor in
+	sni)
+	  archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  hardcode_direct=yes # is this really true???
+	;;
+	siemens)
+	  ## LD is ld it makes a PLAMLIB
+	  ## CC just makes a GrossModule.
+	  archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+	  reload_cmds='$CC -r -o $output$reload_objs'
+	  hardcode_direct=no
+        ;;
+	motorola)
+	  archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  hardcode_direct=no #Motorola manual says yes, but my tests say they lie
+	;;
+      esac
+      runpath_var='LD_RUN_PATH'
+      hardcode_shlibpath_var=no
+      ;;
 
+    sysv4.3*)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_shlibpath_var=no
+      export_dynamic_flag_spec='-Bexport'
+      ;;
 
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	hardcode_shlibpath_var=no
+	runpath_var=LD_RUN_PATH
+	hardcode_runpath_var=yes
+	ld_shlibs=yes
+      fi
+      ;;
 
-case $host_os in
-aix3*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='$libname$release$shared_ext$versuffix $libname.a'
-  shlibpath_var=LIBPATH
+    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
+      no_undefined_flag='$wl-z,text'
+      archive_cmds_need_lc=no
+      hardcode_shlibpath_var=no
+      runpath_var='LD_RUN_PATH'
 
-  # AIX 3 has no versioning support, so we append a major version to the name.
-  soname_spec='$libname$release$shared_ext$major'
-  ;;
+      if test yes = "$GCC"; then
+	archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
 
-aix[4-9]*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  hardcode_into_libs=yes
-  if test ia64 = "$host_cpu"; then
-    # AIX 5 supports IA64
-    library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext'
-    shlibpath_var=LD_LIBRARY_PATH
-  else
-    # With GCC up to 2.95.x, collect2 would create an import file
-    # for dependence libraries.  The import file would start with
-    # the line '#! .'.  This would cause the generated library to
-    # depend on '.', always an invalid library.  This was fixed in
-    # development snapshots of GCC prior to 3.0.
-    case $host_os in
-      aix4 | aix4.[01] | aix4.[01].*)
-      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
-	   echo ' yes '
-	   echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then
-	:
+    sysv5* | sco3.2v5* | sco5v6*)
+      # Note: We CANNOT use -z defs as we might desire, because we do not
+      # link with -lc, and that would cause any symbols used from libc to
+      # always be unresolved, which means just about no library would
+      # ever link correctly.  If we're not using GNU ld we use -z text
+      # though, which does catch some bad symbols but isn't as heavy-handed
+      # as -z defs.
+      no_undefined_flag='$wl-z,text'
+      allow_undefined_flag='$wl-z,nodefs'
+      archive_cmds_need_lc=no
+      hardcode_shlibpath_var=no
+      hardcode_libdir_flag_spec='$wl-R,$libdir'
+      hardcode_libdir_separator=':'
+      link_all_deplibs=yes
+      export_dynamic_flag_spec='$wl-Bexport'
+      runpath_var='LD_RUN_PATH'
+
+      if test yes = "$GCC"; then
+	archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       else
-	can_build_shared=no
+	archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       fi
       ;;
-    esac
-    # Using Import Files as archive members, it is possible to support
-    # filename-based versioning of shared library archives on AIX. While
-    # this would work for both with and without runtime linking, it will
-    # prevent static linking of such archives. So we do filename-based
-    # shared library versioning with .so extension only, which is used
-    # when both runtime linking and shared linking is enabled.
-    # Unfortunately, runtime linking may impact performance, so we do
-    # not want this to be the default eventually. Also, we use the
-    # versioned .so libs for executables only if there is the -brtl
-    # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only.
-    # To allow for filename-based versioning support, we need to create
-    # libNAME.so.V as an archive file, containing:
-    # *) an Import File, referring to the versioned filename of the
-    #    archive as well as the shared archive member, telling the
-    #    bitwidth (32 or 64) of that shared object, and providing the
-    #    list of exported symbols of that shared object, eventually
-    #    decorated with the 'weak' keyword
-    # *) the shared object with the F_LOADONLY flag set, to really avoid
-    #    it being seen by the linker.
-    # At run time we better use the real file rather than another symlink,
-    # but for link time we create the symlink libNAME.so -> libNAME.so.V
 
-    case $with_aix_soname,$aix_use_runtimelinking in
-    # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct
-    # soname into executable. Probably we can add versioning support to
-    # collect2, so additional links can be useful in future.
-    aix,yes) # traditional libtool
-      dynamic_linker='AIX unversionable lib.so'
-      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
-      # instead of lib<name>.a to let people know that these are not
-      # typical AIX shared libraries.
-      library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
-      ;;
-    aix,no) # traditional AIX only
-      dynamic_linker='AIX lib.a(lib.so.V)'
-      # We preserve .a as extension for shared libraries through AIX4.2
-      # and later when we are not doing run time linking.
-      library_names_spec='$libname$release.a $libname.a'
-      soname_spec='$libname$release$shared_ext$major'
-      ;;
-    svr4,*) # full svr4 only
-      dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o)"
-      library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
-      # We do not specify a path in Import Files, so LIBPATH fires.
-      shlibpath_overrides_runpath=yes
-      ;;
-    *,yes) # both, prefer svr4
-      dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o), lib.a(lib.so.V)"
-      library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
-      # unpreferred sharedlib libNAME.a needs extra handling
-      postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"'
-      postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"'
-      # We do not specify a path in Import Files, so LIBPATH fires.
-      shlibpath_overrides_runpath=yes
+    uts4*)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_shlibpath_var=no
       ;;
-    *,no) # both, prefer aix
-      dynamic_linker="AIX lib.a(lib.so.V), lib.so.V($shared_archive_member_spec.o)"
-      library_names_spec='$libname$release.a $libname.a'
-      soname_spec='$libname$release$shared_ext$major'
-      # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling
-      postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)'
-      postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"'
+
+    *)
+      ld_shlibs=no
       ;;
     esac
-    shlibpath_var=LIBPATH
+
+    if test sni = "$host_vendor"; then
+      case $host in
+      sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+	export_dynamic_flag_spec='$wl-Blargedynsym'
+	;;
+      esac
+    fi
   fi
-  ;;
 
-amigaos*)
-  case $host_cpu in
-  powerpc)
-    # Since July 2007 AmigaOS4 officially supports .so libraries.
-    # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
-    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
-    ;;
-  m68k)
-    library_names_spec='$libname.ixlibrary $libname.a'
-    # Create ${libname}_ixlibrary.a entries in /sys/libs.
-    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
-    ;;
-  esac
-  ;;
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5
+printf "%s\n" "$ld_shlibs" >&6; }
+test no = "$ld_shlibs" && can_build_shared=no
 
-beos*)
-  library_names_spec='$libname$shared_ext'
-  dynamic_linker="$host_os ld.so"
-  shlibpath_var=LIBRARY_PATH
-  ;;
+with_gnu_ld=$with_gnu_ld
 
-bsdi[45]*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_version=no
-  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
-  soname_spec='$libname$release$shared_ext$major'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
-  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
-  # the default ld.so.conf also contains /usr/contrib/lib and
-  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
-  # libtool to hard-code these into programs
-  ;;
 
-cygwin* | mingw* | pw32* | cegcc*)
-  version_type=windows
-  shrext_cmds=.dll
-  need_version=no
-  need_lib_prefix=no
 
-  case $GCC,$cc_basename in
-  yes,*)
-    # gcc
-    library_names_spec='$libname.dll.a'
-    # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \$file`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
-      dldir=$destdir/`dirname \$dlpath`~
-      test -d \$dldir || mkdir -p \$dldir~
-      $install_prog $dir/$dlname \$dldir/$dlname~
-      chmod a+x \$dldir/$dlname~
-      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
-        eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
-      fi'
-    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
-      dlpath=$dir/\$dldll~
-       $RM \$dlpath'
-    shlibpath_overrides_runpath=yes
 
-    case $host_os in
-    cygwin*)
-      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
-      soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
 
-      sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
-      ;;
-    mingw* | cegcc*)
-      # MinGW DLLs use traditional 'lib' prefix
-      soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
-      ;;
-    pw32*)
-      # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
-      ;;
-    esac
-    dynamic_linker='Win32 ld.exe'
-    ;;
 
-  *,cl*)
-    # Native MSVC
-    libname_spec='$name'
-    soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
-    library_names_spec='$libname.dll.lib'
 
-    case $build_os in
-    mingw*)
-      sys_lib_search_path_spec=
-      lt_save_ifs=$IFS
-      IFS=';'
-      for lt_path in $LIB
-      do
-        IFS=$lt_save_ifs
-        # Let DOS variable expansion print the short 8.3 style file name.
-        lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"`
-        sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path"
-      done
-      IFS=$lt_save_ifs
-      # Convert to MSYS style.
-      sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'`
-      ;;
-    cygwin*)
-      # Convert to unix form, then to dos form, then back to unix form
-      # but this time dos style (no spaces!) so that the unix form looks
-      # like /cygdrive/c/PROGRA~1:/cygdr...
-      sys_lib_search_path_spec=`cygpath --path --unix "$LIB"`
-      sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null`
-      sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+
+
+
+
+
+
+
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc" in
+x|xyes)
+  # Assume -lc should be added
+  archive_cmds_need_lc=yes
+
+  if test yes,yes = "$GCC,$enable_shared"; then
+    case $archive_cmds in
+    *'~'*)
+      # FIXME: we may have to deal with multi-command sequences.
       ;;
-    *)
-      sys_lib_search_path_spec=$LIB
-      if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
-        # It is most probably a Windows format PATH.
-        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
-      else
-        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
-      fi
-      # FIXME: find the short name or the path components, as spaces are
-      # common. (e.g. "Program Files" -> "PROGRA~1")
+    '$CC '*)
+      # Test whether the compiler implicitly links with -lc since on some
+      # systems, -lgcc has to come before -lc. If gcc already passes -lc
+      # to ld, don't add -lc before -lgcc.
+      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5
+printf %s "checking whether -lc should be explicitly linked in... " >&6; }
+if test ${lt_cv_archive_cmds_need_lc+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  $RM conftest*
+	echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+	if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } 2>conftest.err; then
+	  soname=conftest
+	  lib=conftest
+	  libobjs=conftest.$ac_objext
+	  deplibs=
+	  wl=$lt_prog_compiler_wl
+	  pic_flag=$lt_prog_compiler_pic
+	  compiler_flags=-v
+	  linker_flags=-v
+	  verstring=
+	  output_objdir=.
+	  libname=conftest
+	  lt_save_allow_undefined_flag=$allow_undefined_flag
+	  allow_undefined_flag=
+	  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5
+  (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
+  ac_status=$?
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+	  then
+	    lt_cv_archive_cmds_need_lc=no
+	  else
+	    lt_cv_archive_cmds_need_lc=yes
+	  fi
+	  allow_undefined_flag=$lt_save_allow_undefined_flag
+	else
+	  cat conftest.err 1>&5
+	fi
+	$RM conftest*
+
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5
+printf "%s\n" "$lt_cv_archive_cmds_need_lc" >&6; }
+      archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc
       ;;
     esac
+  fi
+  ;;
+esac
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 
-    # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \$file`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
-      dldir=$destdir/`dirname \$dlpath`~
-      test -d \$dldir || mkdir -p \$dldir~
-      $install_prog $dir/$dlname \$dldir/$dlname'
-    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
-      dlpath=$dir/\$dldll~
-       $RM \$dlpath'
-    shlibpath_overrides_runpath=yes
-    dynamic_linker='Win32 link.exe'
-    ;;
 
-  *)
-    # Assume MSVC wrapper
-    library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib'
-    dynamic_linker='Win32 ld.exe'
-    ;;
-  esac
-  # FIXME: first we should search . and the directory the executable is in
-  shlibpath_var=PATH
-  ;;
 
-darwin* | rhapsody*)
-  dynamic_linker="$host_os dyld"
-  version_type=darwin
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='$libname$release$major$shared_ext $libname$shared_ext'
-  soname_spec='$libname$release$major$shared_ext'
-  shlibpath_overrides_runpath=yes
-  shlibpath_var=DYLD_LIBRARY_PATH
-  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
 
-  sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"
-  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
-  ;;
 
-dgux*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
-  soname_spec='$libname$release$shared_ext$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
 
-freebsd* | dragonfly*)
-  # DragonFly does not have aout.  When/if they implement a new
-  # versioning mechanism, adjust this.
-  if test -x /usr/bin/objformat; then
-    objformat=`/usr/bin/objformat`
-  else
-    case $host_os in
-    freebsd[23].*) objformat=aout ;;
-    *) objformat=elf ;;
-    esac
-  fi
-  version_type=freebsd-$objformat
-  case $version_type in
-    freebsd-elf*)
-      library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
-      soname_spec='$libname$release$shared_ext$major'
-      need_version=no
-      need_lib_prefix=no
-      ;;
-    freebsd-*)
-      library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
-      need_version=yes
-      ;;
-  esac
-  shlibpath_var=LD_LIBRARY_PATH
-  case $host_os in
-  freebsd2.*)
-    shlibpath_overrides_runpath=yes
-    ;;
-  freebsd3.[01]* | freebsdelf3.[01]*)
-    shlibpath_overrides_runpath=yes
-    hardcode_into_libs=yes
-    ;;
-  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
-  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
-    shlibpath_overrides_runpath=no
-    hardcode_into_libs=yes
-    ;;
-  *) # from 4.6 on, and DragonFly
-    shlibpath_overrides_runpath=yes
-    hardcode_into_libs=yes
-    ;;
-  esac
-  ;;
 
-haiku*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  dynamic_linker="$host_os runtime_loader"
-  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
-  soname_spec='$libname$release$shared_ext$major'
-  shlibpath_var=LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
-  hardcode_into_libs=yes
-  ;;
 
-hpux9* | hpux10* | hpux11*)
-  # Give a soname corresponding to the major version so that dld.sl refuses to
-  # link against other versions.
-  version_type=sunos
-  need_lib_prefix=no
-  need_version=no
-  case $host_cpu in
-  ia64*)
-    shrext_cmds='.so'
-    hardcode_into_libs=yes
-    dynamic_linker="$host_os dld.so"
-    shlibpath_var=LD_LIBRARY_PATH
-    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
-    soname_spec='$libname$release$shared_ext$major'
-    if test 32 = "$HPUX_IA64_MODE"; then
-      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
-      sys_lib_dlsearch_path_spec=/usr/lib/hpux32
-    else
-      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
-      sys_lib_dlsearch_path_spec=/usr/lib/hpux64
-    fi
-    ;;
-  hppa*64*)
-    shrext_cmds='.sl'
-    hardcode_into_libs=yes
-    dynamic_linker="$host_os dld.sl"
-    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
-    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
-    soname_spec='$libname$release$shared_ext$major'
-    sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
-    ;;
-  *)
-    shrext_cmds='.sl'
-    dynamic_linker="$host_os dld.sl"
-    shlibpath_var=SHLIB_PATH
-    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
-    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
-    soname_spec='$libname$release$shared_ext$major'
-    ;;
-  esac
-  # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
-  postinstall_cmds='chmod 555 $lib'
-  # or fails outright, so override atomically:
-  install_override_mode=555
-  ;;
 
-interix[3-9]*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
-  soname_spec='$libname$release$shared_ext$major'
-  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  ;;
 
-irix5* | irix6* | nonstopux*)
-  case $host_os in
-    nonstopux*) version_type=nonstopux ;;
-    *)
-	if test yes = "$lt_cv_prog_gnu_ld"; then
-		version_type=linux # correct to gnu/linux during the next big refactor
-	else
-		version_type=irix
-	fi ;;
-  esac
-  need_lib_prefix=no
-  need_version=no
-  soname_spec='$libname$release$shared_ext$major'
-  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext'
-  case $host_os in
-  irix5* | nonstopux*)
-    libsuff= shlibsuff=
-    ;;
-  *)
-    case $LD in # libtool.m4 will add one of these switches to LD
-    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
-      libsuff= shlibsuff= libmagic=32-bit;;
-    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
-      libsuff=32 shlibsuff=N32 libmagic=N32;;
-    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
-      libsuff=64 shlibsuff=64 libmagic=64-bit;;
-    *) libsuff= shlibsuff= libmagic=never-match;;
-    esac
-    ;;
-  esac
-  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
-  shlibpath_overrides_runpath=no
-  sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff"
-  sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff"
-  hardcode_into_libs=yes
-  ;;
 
-# No shared lib support for Linux oldld, aout, or coff.
-linux*oldld* | linux*aout* | linux*coff*)
-  dynamic_linker=no
-  ;;
 
-linux*android*)
-  version_type=none # Android doesn't support versioned libraries.
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='$libname$release$shared_ext'
-  soname_spec='$libname$release$shared_ext'
-  finish_cmds=
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
 
-  # This implies no fast_install, which is unacceptable.
-  # Some rework will be needed to allow for fast_install
-  # before this can be enabled.
-  hardcode_into_libs=yes
 
-  dynamic_linker='Android linker'
-  # Don't embed -rpath directories since the linker doesn't support them.
-  hardcode_libdir_flag_spec='-L$libdir'
-  ;;
 
-# This must be glibc/ELF.
-linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
-  soname_spec='$libname$release$shared_ext$major'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
 
-  # Some binutils ld are patched to set DT_RUNPATH
-  if test ${lt_cv_shlibpath_overrides_runpath+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  lt_cv_shlibpath_overrides_runpath=no
-    save_LDFLAGS=$LDFLAGS
-    save_libdir=$libdir
-    eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \
-	 LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\""
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
 
-int
-main (void)
-{
 
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"
-then :
-  if  ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null
-then :
-  lt_cv_shlibpath_overrides_runpath=yes
-fi
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam \
-    conftest$ac_exeext conftest.$ac_ext
-    LDFLAGS=$save_LDFLAGS
-    libdir=$save_libdir
 
-fi
 
-  shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath
 
-  # This implies no fast_install, which is unacceptable.
-  # Some rework will be needed to allow for fast_install
-  # before this can be enabled.
-  hardcode_into_libs=yes
 
-  # Ideally, we could use ldconfig to report *all* directores which are
-  # searched for libraries, however this is still not possible.  Aside from not
-  # being certain /sbin/ldconfig is available, command
-  # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64,
-  # even though it is searched at run-time.  Try to do the best guess by
-  # appending ld.so.conf contents (and includes) to the search path.
-  if test -f /etc/ld.so.conf; then
-    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
-    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
-  fi
 
-  # We used to test for /lib/ld.so.1 and disable shared libraries on
-  # powerpc, because MkLinux only supported shared libraries with the
-  # GNU dynamic linker.  Since this was broken with cross compilers,
-  # most powerpc-linux boxes support dynamic linking these days and
-  # people can always --disable-shared, the test was removed, and we
-  # assume the GNU/Linux dynamic linker is in use.
-  dynamic_linker='GNU/Linux ld.so'
-  ;;
 
-netbsd*)
-  version_type=sunos
-  need_lib_prefix=no
-  need_version=no
-  if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-    library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
-    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-    dynamic_linker='NetBSD (a.out) ld.so'
-  else
-    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
-    soname_spec='$libname$release$shared_ext$major'
-    dynamic_linker='NetBSD ld.elf_so'
-  fi
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  ;;
 
-newsos6)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  ;;
 
-*nto* | *qnx*)
-  version_type=qnx
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
-  soname_spec='$libname$release$shared_ext$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='ldqnx.so'
-  ;;
 
-openbsd* | bitrig*)
-  version_type=sunos
-  sys_lib_dlsearch_path_spec=/usr/lib
-  need_lib_prefix=no
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
-    need_version=no
-  else
-    need_version=yes
-  fi
-  library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  ;;
 
-os2*)
-  libname_spec='$name'
-  version_type=windows
-  shrext_cmds=.dll
-  need_version=no
-  need_lib_prefix=no
-  # OS/2 can only load a DLL with a base name of 8 characters or less.
-  soname_spec='`test -n "$os2dllname" && libname="$os2dllname";
-    v=$($ECHO $release$versuffix | tr -d .-);
-    n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _);
-    $ECHO $n$v`$shared_ext'
-  library_names_spec='${libname}_dll.$libext'
-  dynamic_linker='OS/2 ld.exe'
-  shlibpath_var=BEGINLIBPATH
-  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
-  sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
-  postinstall_cmds='base_file=`basename \$file`~
-    dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~
-    dldir=$destdir/`dirname \$dlpath`~
-    test -d \$dldir || mkdir -p \$dldir~
-    $install_prog $dir/$dlname \$dldir/$dlname~
-    chmod a+x \$dldir/$dlname~
-    if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
-      eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
-    fi'
-  postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~
-    dlpath=$dir/\$dldll~
-    $RM \$dlpath'
-  ;;
 
-osf3* | osf4* | osf5*)
-  version_type=osf
-  need_lib_prefix=no
-  need_version=no
-  soname_spec='$libname$release$shared_ext$major'
-  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
-  shlibpath_var=LD_LIBRARY_PATH
-  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
-  sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
-  ;;
 
-rdos*)
-  dynamic_linker=no
-  ;;
 
-solaris*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
-  soname_spec='$libname$release$shared_ext$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  # ldd complains unless libraries are executable
-  postinstall_cmds='chmod +x $lib'
-  ;;
 
-sunos4*)
-  version_type=sunos
-  library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
-  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  if test yes = "$with_gnu_ld"; then
-    need_lib_prefix=no
-  fi
-  need_version=yes
-  ;;
 
-sysv4 | sysv4.3*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
-  soname_spec='$libname$release$shared_ext$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  case $host_vendor in
-    sni)
-      shlibpath_overrides_runpath=no
-      need_lib_prefix=no
-      runpath_var=LD_RUN_PATH
-      ;;
-    siemens)
-      need_lib_prefix=no
-      ;;
-    motorola)
-      need_lib_prefix=no
-      need_version=no
-      shlibpath_overrides_runpath=no
-      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
-      ;;
-  esac
-  ;;
 
-sysv4*MP*)
-  if test -d /usr/nec; then
-    version_type=linux # correct to gnu/linux during the next big refactor
-    library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext'
-    soname_spec='$libname$shared_ext.$major'
-    shlibpath_var=LD_LIBRARY_PATH
-  fi
-  ;;
 
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  version_type=sco
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext'
-  soname_spec='$libname$release$shared_ext$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  if test yes = "$with_gnu_ld"; then
-    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
-  else
-    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
-    case $host_os in
-      sco3.2v5*)
-        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
-	;;
-    esac
-  fi
-  sys_lib_dlsearch_path_spec='/usr/lib'
-  ;;
 
-tpf*)
-  # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  ;;
 
-uts4*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
-  soname_spec='$libname$release$shared_ext$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
 
-*)
-  dynamic_linker=no
-  ;;
-esac
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
-printf "%s\n" "$dynamic_linker" >&6; }
-test no = "$dynamic_linker" && can_build_shared=no
 
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test yes = "$GCC"; then
-  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
 
-if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then
-  sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec
-fi
 
-if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then
-  sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec
-fi
 
-# remember unaugmented sys_lib_dlsearch_path content for libtool script decls...
-configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec
 
-# ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code
-func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH"
 
-# to be used as default LT_SYS_LIBRARY_PATH value in generated libtool
-configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH
 
 
 
@@ -22915,584 +23147,870 @@ configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH
 
 
 
+
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
+printf %s "checking dynamic linker characteristics... " >&6; }
+
+if test yes = "$GCC"; then
+  case $host_os in
+    darwin*) lt_awk_arg='/^libraries:/,/LR/' ;;
+    *) lt_awk_arg='/^libraries:/' ;;
+  esac
+  case $host_os in
+    mingw* | cegcc*) lt_sed_strip_eq='s|=\([A-Za-z]:\)|\1|g' ;;
+    *) lt_sed_strip_eq='s|=/|/|g' ;;
+  esac
+  lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`
+  case $lt_search_path_spec in
+  *\;*)
+    # if the path contains ";" then we assume it to be the separator
+    # otherwise default to the standard path separator (i.e. ":") - it is
+    # assumed that no part of a normal pathname contains ";" but that should
+    # okay in the real world where ";" in dirpaths is itself problematic.
+    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'`
+    ;;
+  *)
+    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"`
+    ;;
+  esac
+  # Ok, now we have the path, separated by spaces, we can step through it
+  # and add multilib dir if necessary...
+  lt_tmp_lt_search_path_spec=
+  lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  # ...but if some path component already ends with the multilib dir we assume
+  # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer).
+  case "$lt_multi_os_dir; $lt_search_path_spec " in
+  "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*)
+    lt_multi_os_dir=
+    ;;
+  esac
+  for lt_sys_path in $lt_search_path_spec; do
+    if test -d "$lt_sys_path$lt_multi_os_dir"; then
+      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir"
+    elif test -n "$lt_multi_os_dir"; then
+      test -d "$lt_sys_path" && \
+	lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
+    fi
+  done
+  lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk '
+BEGIN {RS = " "; FS = "/|\n";} {
+  lt_foo = "";
+  lt_count = 0;
+  for (lt_i = NF; lt_i > 0; lt_i--) {
+    if ($lt_i != "" && $lt_i != ".") {
+      if ($lt_i == "..") {
+        lt_count++;
+      } else {
+        if (lt_count == 0) {
+          lt_foo = "/" $lt_i lt_foo;
+        } else {
+          lt_count--;
+        }
+      }
+    }
+  }
+  if (lt_foo != "") { lt_freq[lt_foo]++; }
+  if (lt_freq[lt_foo] == 1) { print lt_foo; }
+}'`
+  # AWK program above erroneously prepends '/' to C:/dos/paths
+  # for these hosts.
+  case $host_os in
+    mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\
+      $SED 's|/\([A-Za-z]:\)|\1|g'` ;;
+  esac
+  sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP`
+else
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=.so
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
 
 
 
+case $host_os in
+aix3*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  library_names_spec='$libname$release$shared_ext$versuffix $libname.a'
+  shlibpath_var=LIBPATH
 
+  # AIX 3 has no versioning support, so we append a major version to the name.
+  soname_spec='$libname$release$shared_ext$major'
+  ;;
 
+aix[4-9]*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  hardcode_into_libs=yes
+  if test ia64 = "$host_cpu"; then
+    # AIX 5 supports IA64
+    library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext'
+    shlibpath_var=LD_LIBRARY_PATH
+  else
+    # With GCC up to 2.95.x, collect2 would create an import file
+    # for dependence libraries.  The import file would start with
+    # the line '#! .'.  This would cause the generated library to
+    # depend on '.', always an invalid library.  This was fixed in
+    # development snapshots of GCC prior to 3.0.
+    case $host_os in
+      aix4 | aix4.[01] | aix4.[01].*)
+      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+	   echo ' yes '
+	   echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then
+	:
+      else
+	can_build_shared=no
+      fi
+      ;;
+    esac
+    # Using Import Files as archive members, it is possible to support
+    # filename-based versioning of shared library archives on AIX. While
+    # this would work for both with and without runtime linking, it will
+    # prevent static linking of such archives. So we do filename-based
+    # shared library versioning with .so extension only, which is used
+    # when both runtime linking and shared linking is enabled.
+    # Unfortunately, runtime linking may impact performance, so we do
+    # not want this to be the default eventually. Also, we use the
+    # versioned .so libs for executables only if there is the -brtl
+    # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only.
+    # To allow for filename-based versioning support, we need to create
+    # libNAME.so.V as an archive file, containing:
+    # *) an Import File, referring to the versioned filename of the
+    #    archive as well as the shared archive member, telling the
+    #    bitwidth (32 or 64) of that shared object, and providing the
+    #    list of exported symbols of that shared object, eventually
+    #    decorated with the 'weak' keyword
+    # *) the shared object with the F_LOADONLY flag set, to really avoid
+    #    it being seen by the linker.
+    # At run time we better use the real file rather than another symlink,
+    # but for link time we create the symlink libNAME.so -> libNAME.so.V
 
+    case $with_aix_soname,$aix_use_runtimelinking in
+    # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct
+    # soname into executable. Probably we can add versioning support to
+    # collect2, so additional links can be useful in future.
+    aix,yes) # traditional libtool
+      dynamic_linker='AIX unversionable lib.so'
+      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+      # instead of lib<name>.a to let people know that these are not
+      # typical AIX shared libraries.
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+      ;;
+    aix,no) # traditional AIX only
+      dynamic_linker='AIX lib.a(lib.so.V)'
+      # We preserve .a as extension for shared libraries through AIX4.2
+      # and later when we are not doing run time linking.
+      library_names_spec='$libname$release.a $libname.a'
+      soname_spec='$libname$release$shared_ext$major'
+      ;;
+    svr4,*) # full svr4 only
+      dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o)"
+      library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
+      # We do not specify a path in Import Files, so LIBPATH fires.
+      shlibpath_overrides_runpath=yes
+      ;;
+    *,yes) # both, prefer svr4
+      dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o), lib.a(lib.so.V)"
+      library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
+      # unpreferred sharedlib libNAME.a needs extra handling
+      postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"'
+      postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"'
+      # We do not specify a path in Import Files, so LIBPATH fires.
+      shlibpath_overrides_runpath=yes
+      ;;
+    *,no) # both, prefer aix
+      dynamic_linker="AIX lib.a(lib.so.V), lib.so.V($shared_archive_member_spec.o)"
+      library_names_spec='$libname$release.a $libname.a'
+      soname_spec='$libname$release$shared_ext$major'
+      # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling
+      postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)'
+      postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"'
+      ;;
+    esac
+    shlibpath_var=LIBPATH
+  fi
+  ;;
 
+amigaos*)
+  case $host_cpu in
+  powerpc)
+    # Since July 2007 AmigaOS4 officially supports .so libraries.
+    # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    ;;
+  m68k)
+    library_names_spec='$libname.ixlibrary $libname.a'
+    # Create ${libname}_ixlibrary.a entries in /sys/libs.
+    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+    ;;
+  esac
+  ;;
 
+beos*)
+  library_names_spec='$libname$shared_ext'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
 
+bsdi[45]*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_version=no
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+  # the default ld.so.conf also contains /usr/contrib/lib and
+  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+  # libtool to hard-code these into programs
+  ;;
 
+cygwin* | mingw* | pw32* | cegcc*)
+  version_type=windows
+  shrext_cmds=.dll
+  need_version=no
+  need_lib_prefix=no
 
+  case $GCC,$cc_basename in
+  yes,*)
+    # gcc
+    library_names_spec='$libname.dll.a'
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \$file`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+      fi'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $RM \$dlpath'
+    shlibpath_overrides_runpath=yes
 
+    case $host_os in
+    cygwin*)
+      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+      soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
 
+      sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
+      ;;
+    mingw* | cegcc*)
+      # MinGW DLLs use traditional 'lib' prefix
+      soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
+      ;;
+    pw32*)
+      # pw32 DLLs use 'pw' prefix rather than 'lib'
+      library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
+      ;;
+    esac
+    dynamic_linker='Win32 ld.exe'
+    ;;
 
+  *,cl*)
+    # Native MSVC
+    libname_spec='$name'
+    soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
+    library_names_spec='$libname.dll.lib'
 
+    case $build_os in
+    mingw*)
+      sys_lib_search_path_spec=
+      lt_save_ifs=$IFS
+      IFS=';'
+      for lt_path in $LIB
+      do
+        IFS=$lt_save_ifs
+        # Let DOS variable expansion print the short 8.3 style file name.
+        lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"`
+        sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path"
+      done
+      IFS=$lt_save_ifs
+      # Convert to MSYS style.
+      sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'`
+      ;;
+    cygwin*)
+      # Convert to unix form, then to dos form, then back to unix form
+      # but this time dos style (no spaces!) so that the unix form looks
+      # like /cygdrive/c/PROGRA~1:/cygdr...
+      sys_lib_search_path_spec=`cygpath --path --unix "$LIB"`
+      sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null`
+      sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+      ;;
+    *)
+      sys_lib_search_path_spec=$LIB
+      if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
+        # It is most probably a Windows format PATH.
+        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+      else
+        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+      fi
+      # FIXME: find the short name or the path components, as spaces are
+      # common. (e.g. "Program Files" -> "PROGRA~1")
+      ;;
+    esac
 
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \$file`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $RM \$dlpath'
+    shlibpath_overrides_runpath=yes
+    dynamic_linker='Win32 link.exe'
+    ;;
 
+  *)
+    # Assume MSVC wrapper
+    library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib'
+    dynamic_linker='Win32 ld.exe'
+    ;;
+  esac
+  # FIXME: first we should search . and the directory the executable is in
+  shlibpath_var=PATH
+  ;;
 
+darwin* | rhapsody*)
+  dynamic_linker="$host_os dyld"
+  version_type=darwin
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='$libname$release$major$shared_ext $libname$shared_ext'
+  soname_spec='$libname$release$major$shared_ext'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
 
+  sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"
+  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+  ;;
 
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5
-printf %s "checking how to hardcode library paths into programs... " >&6; }
-hardcode_action=
-if test -n "$hardcode_libdir_flag_spec" ||
-   test -n "$runpath_var" ||
-   test yes = "$hardcode_automatic"; then
+dgux*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
 
-  # We can hardcode non-existent directories.
-  if test no != "$hardcode_direct" &&
-     # If the only mechanism to avoid hardcoding is shlibpath_var, we
-     # have to relink, otherwise we might link with an installed library
-     # when we should be linking with a yet-to-be-installed one
-     ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, )" &&
-     test no != "$hardcode_minus_L"; then
-    # Linking always hardcodes the temporary library directory.
-    hardcode_action=relink
+freebsd* | dragonfly*)
+  # DragonFly does not have aout.  When/if they implement a new
+  # versioning mechanism, adjust this.
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
   else
-    # We can link without hardcoding, and we can hardcode nonexisting dirs.
-    hardcode_action=immediate
+    case $host_os in
+    freebsd[23].*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
   fi
-else
-  # We cannot hardcode anything, or else we can only hardcode existing
-  # directories.
-  hardcode_action=unsupported
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5
-printf "%s\n" "$hardcode_action" >&6; }
-
-if test relink = "$hardcode_action" ||
-   test yes = "$inherit_rpath"; then
-  # Fast installation is not supported
-  enable_fast_install=no
-elif test yes = "$shlibpath_overrides_runpath" ||
-     test no = "$enable_shared"; then
-  # Fast installation is not necessary
-  enable_fast_install=needless
-fi
-
-
-
-
-
-
-  if test yes != "$enable_dlopen"; then
-  enable_dlopen=unknown
-  enable_dlopen_self=unknown
-  enable_dlopen_self_static=unknown
-else
-  lt_cv_dlopen=no
-  lt_cv_dlopen_libs=
-
+  version_type=freebsd-$objformat
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+      soname_spec='$libname$release$shared_ext$major'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
+      need_version=yes
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
   case $host_os in
-  beos*)
-    lt_cv_dlopen=load_add_on
-    lt_cv_dlopen_libs=
-    lt_cv_dlopen_self=yes
+  freebsd2.*)
+    shlibpath_overrides_runpath=yes
     ;;
-
-  mingw* | pw32* | cegcc*)
-    lt_cv_dlopen=LoadLibrary
-    lt_cv_dlopen_libs=
+  freebsd3.[01]* | freebsdelf3.[01]*)
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
     ;;
-
-  cygwin*)
-    lt_cv_dlopen=dlopen
-    lt_cv_dlopen_libs=
+  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
+  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
     ;;
+  *) # from 4.6 on, and DragonFly
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
 
-  darwin*)
-    # if libdl is installed we need to link against it
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
-printf %s "checking for dlopen in -ldl... " >&6; }
-if test ${ac_cv_lib_dl_dlopen+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldl  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-char dlopen ();
-int
-main (void)
-{
-return dlopen ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"
-then :
-  ac_cv_lib_dl_dlopen=yes
-else $as_nop
-  ac_cv_lib_dl_dlopen=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
-printf "%s\n" "$ac_cv_lib_dl_dlopen" >&6; }
-if test "x$ac_cv_lib_dl_dlopen" = xyes
-then :
-  lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl
-else $as_nop
-
-    lt_cv_dlopen=dyld
-    lt_cv_dlopen_libs=
-    lt_cv_dlopen_self=yes
-
-fi
+haiku*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  dynamic_linker="$host_os runtime_loader"
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
+  shlibpath_var=LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
+  hardcode_into_libs=yes
+  ;;
 
+hpux9* | hpux10* | hpux11*)
+  # Give a soname corresponding to the major version so that dld.sl refuses to
+  # link against other versions.
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  case $host_cpu in
+  ia64*)
+    shrext_cmds='.so'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.so"
+    shlibpath_var=LD_LIBRARY_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
+    if test 32 = "$HPUX_IA64_MODE"; then
+      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+      sys_lib_dlsearch_path_spec=/usr/lib/hpux32
+    else
+      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+      sys_lib_dlsearch_path_spec=/usr/lib/hpux64
+    fi
     ;;
-
-  tpf*)
-    # Don't try to run any link tests for TPF.  We know it's impossible
-    # because TPF is a cross-compiler, and we know how we open DSOs.
-    lt_cv_dlopen=dlopen
-    lt_cv_dlopen_libs=
-    lt_cv_dlopen_self=no
+  hppa*64*)
+    shrext_cmds='.sl'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
+    sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
     ;;
-
   *)
-    ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load"
-if test "x$ac_cv_func_shl_load" = xyes
-then :
-  lt_cv_dlopen=shl_load
-else $as_nop
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5
-printf %s "checking for shl_load in -ldld... " >&6; }
-if test ${ac_cv_lib_dld_shl_load+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldld  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
+    shrext_cmds='.sl'
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=SHLIB_PATH
+    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
+    ;;
+  esac
+  # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
+  postinstall_cmds='chmod 555 $lib'
+  # or fails outright, so override atomically:
+  install_override_mode=555
+  ;;
 
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-char shl_load ();
-int
-main (void)
-{
-return shl_load ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"
-then :
-  ac_cv_lib_dld_shl_load=yes
-else $as_nop
-  ac_cv_lib_dld_shl_load=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5
-printf "%s\n" "$ac_cv_lib_dld_shl_load" >&6; }
-if test "x$ac_cv_lib_dld_shl_load" = xyes
-then :
-  lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld
-else $as_nop
-  ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen"
-if test "x$ac_cv_func_dlopen" = xyes
-then :
-  lt_cv_dlopen=dlopen
-else $as_nop
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
-printf %s "checking for dlopen in -ldl... " >&6; }
-if test ${ac_cv_lib_dl_dlopen+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldl  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
+interix[3-9]*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
+  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
 
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-char dlopen ();
-int
-main (void)
-{
-return dlopen ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"
-then :
-  ac_cv_lib_dl_dlopen=yes
-else $as_nop
-  ac_cv_lib_dl_dlopen=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
-printf "%s\n" "$ac_cv_lib_dl_dlopen" >&6; }
-if test "x$ac_cv_lib_dl_dlopen" = xyes
-then :
-  lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl
-else $as_nop
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5
-printf %s "checking for dlopen in -lsvld... " >&6; }
-if test ${ac_cv_lib_svld_dlopen+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lsvld  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)
+	if test yes = "$lt_cv_prog_gnu_ld"; then
+		version_type=linux # correct to gnu/linux during the next big refactor
+	else
+		version_type=irix
+	fi ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='$libname$release$shared_ext$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
+    ;;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+      libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+      libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+      libsuff=64 shlibsuff=64 libmagic=64-bit;;
+    *) libsuff= shlibsuff= libmagic=never-match;;
+    esac
+    ;;
+  esac
+  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+  shlibpath_overrides_runpath=no
+  sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff"
+  sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff"
+  hardcode_into_libs=yes
+  ;;
 
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-char dlopen ();
-int
-main (void)
-{
-return dlopen ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"
-then :
-  ac_cv_lib_svld_dlopen=yes
-else $as_nop
-  ac_cv_lib_svld_dlopen=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5
-printf "%s\n" "$ac_cv_lib_svld_dlopen" >&6; }
-if test "x$ac_cv_lib_svld_dlopen" = xyes
-then :
-  lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld
-else $as_nop
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5
-printf %s "checking for dld_link in -ldld... " >&6; }
-if test ${ac_cv_lib_dld_dld_link+y}
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+  dynamic_linker=no
+  ;;
+
+linux*android*)
+  version_type=none # Android doesn't support versioned libraries.
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='$libname$release$shared_ext'
+  soname_spec='$libname$release$shared_ext'
+  finish_cmds=
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  dynamic_linker='Android linker'
+  # Don't embed -rpath directories since the linker doesn't support them.
+  hardcode_libdir_flag_spec='-L$libdir'
+  ;;
+
+# This must be glibc/ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+
+  # Some binutils ld are patched to set DT_RUNPATH
+  if test ${lt_cv_shlibpath_overrides_runpath+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldld  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+  lt_cv_shlibpath_overrides_runpath=no
+    save_LDFLAGS=$LDFLAGS
+    save_libdir=$libdir
+    eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \
+	 LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\""
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-char dld_link ();
 int
 main (void)
 {
-return dld_link ();
+
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"
 then :
-  ac_cv_lib_dld_dld_link=yes
-else $as_nop
-  ac_cv_lib_dld_dld_link=no
+  if  ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null
+then :
+  lt_cv_shlibpath_overrides_runpath=yes
+fi
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5
-printf "%s\n" "$ac_cv_lib_dld_dld_link" >&6; }
-if test "x$ac_cv_lib_dld_dld_link" = xyes
-then :
-  lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld
+    LDFLAGS=$save_LDFLAGS
+    libdir=$save_libdir
+
 fi
 
+  shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath
 
-fi
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  # Ideally, we could use ldconfig to report *all* directores which are
+  # searched for libraries, however this is still not possible.  Aside from not
+  # being certain /sbin/ldconfig is available, command
+  # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64,
+  # even though it is searched at run-time.  Try to do the best guess by
+  # appending ld.so.conf contents (and includes) to the search path.
+  if test -f /etc/ld.so.conf; then
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+  fi
+
+  # We used to test for /lib/ld.so.1 and disable shared libraries on
+  # powerpc, because MkLinux only supported shared libraries with the
+  # GNU dynamic linker.  Since this was broken with cross compilers,
+  # most powerpc-linux boxes support dynamic linking these days and
+  # people can always --disable-shared, the test was removed, and we
+  # assume the GNU/Linux dynamic linker is in use.
+  dynamic_linker='GNU/Linux ld.so'
+  ;;
+
+netbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
+    dynamic_linker='NetBSD ld.elf_so'
+  fi
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  ;;
+
+newsos6)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+*nto* | *qnx*)
+  version_type=qnx
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='ldqnx.so'
+  ;;
+
+openbsd* | bitrig*)
+  version_type=sunos
+  sys_lib_dlsearch_path_spec=/usr/lib
+  need_lib_prefix=no
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
+    need_version=no
+  else
+    need_version=yes
+  fi
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+os2*)
+  libname_spec='$name'
+  version_type=windows
+  shrext_cmds=.dll
+  need_version=no
+  need_lib_prefix=no
+  # OS/2 can only load a DLL with a base name of 8 characters or less.
+  soname_spec='`test -n "$os2dllname" && libname="$os2dllname";
+    v=$($ECHO $release$versuffix | tr -d .-);
+    n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _);
+    $ECHO $n$v`$shared_ext'
+  library_names_spec='${libname}_dll.$libext'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=BEGINLIBPATH
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+  postinstall_cmds='base_file=`basename \$file`~
+    dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~
+    dldir=$destdir/`dirname \$dlpath`~
+    test -d \$dldir || mkdir -p \$dldir~
+    $install_prog $dir/$dlname \$dldir/$dlname~
+    chmod a+x \$dldir/$dlname~
+    if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+      eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+    fi'
+  postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~
+    dlpath=$dir/\$dldll~
+    $RM \$dlpath'
+  ;;
+
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='$libname$release$shared_ext$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+  sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+  ;;
+
+rdos*)
+  dynamic_linker=no
+  ;;
+
+solaris*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  # ldd complains unless libraries are executable
+  postinstall_cmds='chmod +x $lib'
+  ;;
+
+sunos4*)
+  version_type=sunos
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
+  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  if test yes = "$with_gnu_ld"; then
+    need_lib_prefix=no
+  fi
+  need_version=yes
+  ;;
+
+sysv4 | sysv4.3*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_vendor in
+    sni)
+      shlibpath_overrides_runpath=no
+      need_lib_prefix=no
+      runpath_var=LD_RUN_PATH
+      ;;
+    siemens)
+      need_lib_prefix=no
+      ;;
+    motorola)
+      need_lib_prefix=no
+      need_version=no
+      shlibpath_overrides_runpath=no
+      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+      ;;
+  esac
+  ;;
+
+sysv4*MP*)
+  if test -d /usr/nec; then
+    version_type=linux # correct to gnu/linux during the next big refactor
+    library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext'
+    soname_spec='$libname$shared_ext.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  version_type=sco
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  if test yes = "$with_gnu_ld"; then
+    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+  else
+    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+    case $host_os in
+      sco3.2v5*)
+        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+	;;
+    esac
+  fi
+  sys_lib_dlsearch_path_spec='/usr/lib'
+  ;;
 
+tpf*)
+  # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
 
-fi
+uts4*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
 
+*)
+  dynamic_linker=no
+  ;;
+esac
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
+printf "%s\n" "$dynamic_linker" >&6; }
+test no = "$dynamic_linker" && can_build_shared=no
 
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test yes = "$GCC"; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
 fi
 
-
+if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then
+  sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec
 fi
 
-
+if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then
+  sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec
 fi
 
-    ;;
-  esac
-
-  if test no = "$lt_cv_dlopen"; then
-    enable_dlopen=no
-  else
-    enable_dlopen=yes
-  fi
-
-  case $lt_cv_dlopen in
-  dlopen)
-    save_CPPFLAGS=$CPPFLAGS
-    test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
-
-    save_LDFLAGS=$LDFLAGS
-    wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
-
-    save_LIBS=$LIBS
-    LIBS="$lt_cv_dlopen_libs $LIBS"
-
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5
-printf %s "checking whether a program can dlopen itself... " >&6; }
-if test ${lt_cv_dlopen_self+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  	  if test yes = "$cross_compiling"; then :
-  lt_cv_dlopen_self=cross
-else
-  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
-  lt_status=$lt_dlunknown
-  cat > conftest.$ac_ext <<_LT_EOF
-#line $LINENO "configure"
-#include "confdefs.h"
-
-#if HAVE_DLFCN_H
-#include <dlfcn.h>
-#endif
-
-#include <stdio.h>
-
-#ifdef RTLD_GLOBAL
-#  define LT_DLGLOBAL		RTLD_GLOBAL
-#else
-#  ifdef DL_GLOBAL
-#    define LT_DLGLOBAL		DL_GLOBAL
-#  else
-#    define LT_DLGLOBAL		0
-#  endif
-#endif
-
-/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
-   find out it does not work in some platform. */
-#ifndef LT_DLLAZY_OR_NOW
-#  ifdef RTLD_LAZY
-#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
-#  else
-#    ifdef DL_LAZY
-#      define LT_DLLAZY_OR_NOW		DL_LAZY
-#    else
-#      ifdef RTLD_NOW
-#        define LT_DLLAZY_OR_NOW	RTLD_NOW
-#      else
-#        ifdef DL_NOW
-#          define LT_DLLAZY_OR_NOW	DL_NOW
-#        else
-#          define LT_DLLAZY_OR_NOW	0
-#        endif
-#      endif
-#    endif
-#  endif
-#endif
-
-/* When -fvisibility=hidden is used, assume the code has been annotated
-   correspondingly for the symbols needed.  */
-#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
-int fnord () __attribute__((visibility("default")));
-#endif
+# remember unaugmented sys_lib_dlsearch_path content for libtool script decls...
+configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec
 
-int fnord () { return 42; }
-int main ()
-{
-  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
-  int status = $lt_dlunknown;
+# ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code
+func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH"
 
-  if (self)
-    {
-      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
-      else
-        {
-	  if (dlsym( self,"_fnord"))  status = $lt_dlneed_uscore;
-          else puts (dlerror ());
-	}
-      /* dlclose (self); */
-    }
-  else
-    puts (dlerror ());
+# to be used as default LT_SYS_LIBRARY_PATH value in generated libtool
+configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH
 
-  return status;
-}
-_LT_EOF
-  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then
-    (./conftest; exit; ) >&5 2>/dev/null
-    lt_status=$?
-    case x$lt_status in
-      x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
-      x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
-      x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;;
-    esac
-  else :
-    # compilation failed
-    lt_cv_dlopen_self=no
-  fi
-fi
-rm -fr conftest*
 
 
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5
-printf "%s\n" "$lt_cv_dlopen_self" >&6; }
 
-    if test yes = "$lt_cv_dlopen_self"; then
-      wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
-      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5
-printf %s "checking whether a statically linked program can dlopen itself... " >&6; }
-if test ${lt_cv_dlopen_self_static+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  	  if test yes = "$cross_compiling"; then :
-  lt_cv_dlopen_self_static=cross
-else
-  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
-  lt_status=$lt_dlunknown
-  cat > conftest.$ac_ext <<_LT_EOF
-#line $LINENO "configure"
-#include "confdefs.h"
 
-#if HAVE_DLFCN_H
-#include <dlfcn.h>
-#endif
 
-#include <stdio.h>
 
-#ifdef RTLD_GLOBAL
-#  define LT_DLGLOBAL		RTLD_GLOBAL
-#else
-#  ifdef DL_GLOBAL
-#    define LT_DLGLOBAL		DL_GLOBAL
-#  else
-#    define LT_DLGLOBAL		0
-#  endif
-#endif
 
-/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
-   find out it does not work in some platform. */
-#ifndef LT_DLLAZY_OR_NOW
-#  ifdef RTLD_LAZY
-#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
-#  else
-#    ifdef DL_LAZY
-#      define LT_DLLAZY_OR_NOW		DL_LAZY
-#    else
-#      ifdef RTLD_NOW
-#        define LT_DLLAZY_OR_NOW	RTLD_NOW
-#      else
-#        ifdef DL_NOW
-#          define LT_DLLAZY_OR_NOW	DL_NOW
-#        else
-#          define LT_DLLAZY_OR_NOW	0
-#        endif
-#      endif
-#    endif
-#  endif
-#endif
 
-/* When -fvisibility=hidden is used, assume the code has been annotated
-   correspondingly for the symbols needed.  */
-#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
-int fnord () __attribute__((visibility("default")));
-#endif
 
-int fnord () { return 42; }
-int main ()
-{
-  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
-  int status = $lt_dlunknown;
 
-  if (self)
-    {
-      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
-      else
-        {
-	  if (dlsym( self,"_fnord"))  status = $lt_dlneed_uscore;
-          else puts (dlerror ());
-	}
-      /* dlclose (self); */
-    }
-  else
-    puts (dlerror ());
 
-  return status;
-}
-_LT_EOF
-  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then
-    (./conftest; exit; ) >&5 2>/dev/null
-    lt_status=$?
-    case x$lt_status in
-      x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
-      x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
-      x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;;
-    esac
-  else :
-    # compilation failed
-    lt_cv_dlopen_self_static=no
-  fi
-fi
-rm -fr conftest*
 
 
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5
-printf "%s\n" "$lt_cv_dlopen_self_static" >&6; }
-    fi
 
-    CPPFLAGS=$save_CPPFLAGS
-    LDFLAGS=$save_LDFLAGS
-    LIBS=$save_LIBS
-    ;;
-  esac
 
-  case $lt_cv_dlopen_self in
-  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
-  *) enable_dlopen_self=unknown ;;
-  esac
 
-  case $lt_cv_dlopen_self_static in
-  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
-  *) enable_dlopen_self_static=unknown ;;
-  esac
-fi
 
 
 
@@ -23510,35 +24028,6 @@ fi
 
 
 
-striplib=
-old_striplib=
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5
-printf %s "checking whether stripping libraries is possible... " >&6; }
-if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
-  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
-  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-printf "%s\n" "yes" >&6; }
-else
-# FIXME - insert some real tests, host_os isn't really good enough
-  case $host_os in
-  darwin*)
-    if test -n "$STRIP"; then
-      striplib="$STRIP -x"
-      old_striplib="$STRIP -S"
-      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-printf "%s\n" "yes" >&6; }
-    else
-      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
-printf "%s\n" "no" >&6; }
-    fi
-    ;;
-  *)
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
-printf "%s\n" "no" >&6; }
-    ;;
-  esac
-fi
 
 
 
@@ -23551,58 +24040,15 @@ fi
 
 
 
-  # Report what library types will actually be built
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5
-printf %s "checking if libtool supports shared libraries... " >&6; }
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5
-printf "%s\n" "$can_build_shared" >&6; }
 
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5
-printf %s "checking whether to build shared libraries... " >&6; }
-  test no = "$can_build_shared" && enable_shared=no
 
-  # On AIX, shared libraries and static libraries use the same namespace, and
-  # are all built from PIC.
-  case $host_os in
-  aix3*)
-    test yes = "$enable_shared" && enable_static=no
-    if test -n "$RANLIB"; then
-      archive_cmds="$archive_cmds~\$RANLIB \$lib"
-      postinstall_cmds='$RANLIB $lib'
-    fi
-    ;;
 
-  aix[4-9]*)
-    if test ia64 != "$host_cpu"; then
-      case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in
-      yes,aix,yes) ;;			# shared object as lib.so file only
-      yes,svr4,*) ;;			# shared object as lib.so archive member only
-      yes,*) enable_static=no ;;	# shared object in lib.a archive as well
-      esac
-    fi
-    ;;
-  esac
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5
-printf "%s\n" "$enable_shared" >&6; }
 
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5
-printf %s "checking whether to build static libraries... " >&6; }
-  # Make sure either enable_shared or enable_static is yes.
-  test yes = "$enable_shared" || enable_static=yes
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5
-printf "%s\n" "$enable_static" >&6; }
 
 
 
 
-fi
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-CC=$lt_save_CC
 
 
 
@@ -23618,3030 +24064,3181 @@ CC=$lt_save_CC
 
 
 
-        ac_config_commands="$ac_config_commands libtool"
 
 
 
 
-# Only expand once:
 
 
 
 
 
 
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if sntp will be built" >&5
-printf %s "checking if sntp will be built... " >&6; }
 
-# Check whether --with-sntp was given.
-if test ${with_sntp+y}
-then :
-  withval=$with_sntp;
-else $as_nop
-  with_sntp="${withsntp=yes}"
 
-fi
 
-case "$with_sntp" in
- no)
-    SNTP=
-    ;;
- *)
-    SNTP=sntp
-    ;;
-esac
 
- if test -n "$SNTP"; then
-  BUILD_SNTP_TRUE=
-  BUILD_SNTP_FALSE='#'
-else
-  BUILD_SNTP_TRUE='#'
-  BUILD_SNTP_FALSE=
-fi
 
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_sntp" >&5
-printf "%s\n" "$with_sntp" >&6; }
 
 
 
-case "$SNTP" in
- '')
-    SNTP_DB=
-    SNTP_DL=
-    SNTP_DS=
-    ;;
-esac
 
-###
 
-# NTP has (so far) been relying on leading-edge autogen.
-# Therefore, by default:
-# - use the version we ship with
-# - do not install it
-# - build a static copy (AC_DISABLE_SHARED - done earlier)
-case "${enable_local_libopts+set}" in
- set) ;;
- *) enable_local_libopts=yes ;;
-esac
-case "${enable_libopts_install+set}" in
- set) ;;
- *) enable_libopts_install=no ;;
-esac
-enable_nls=no
-# Autoupdate added the next two lines to ensure that your configure
-# script's behavior did not change.  They are probably safe to remove.
 
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
-printf %s "checking for egrep... " >&6; }
-if test ${ac_cv_path_EGREP+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
-   then ac_cv_path_EGREP="$GREP -E"
-   else
-     if test -z "$EGREP"; then
-  ac_path_EGREP_found=false
-  # Loop through the user's path and test for each of PROGNAME-LIST
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
-do
-  IFS=$as_save_IFS
-  case $as_dir in #(((
-    '') as_dir=./ ;;
-    */) ;;
-    *) as_dir=$as_dir/ ;;
-  esac
-    for ac_prog in egrep
-   do
-    for ac_exec_ext in '' $ac_executable_extensions; do
-      ac_path_EGREP="$as_dir$ac_prog$ac_exec_ext"
-      as_fn_executable_p "$ac_path_EGREP" || continue
-# Check for GNU ac_path_EGREP and select it if it is found.
-  # Check for GNU $ac_path_EGREP
-case `"$ac_path_EGREP" --version 2>&1` in
-*GNU*)
-  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
-*)
-  ac_count=0
-  printf %s 0123456789 >"conftest.in"
-  while :
-  do
-    cat "conftest.in" "conftest.in" >"conftest.tmp"
-    mv "conftest.tmp" "conftest.in"
-    cp "conftest.in" "conftest.nl"
-    printf "%s\n" 'EGREP' >> "conftest.nl"
-    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
-    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
-    as_fn_arith $ac_count + 1 && ac_count=$as_val
-    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
-      # Best one so far, save it but keep looking for a better one
-      ac_cv_path_EGREP="$ac_path_EGREP"
-      ac_path_EGREP_max=$ac_count
-    fi
-    # 10*(2^10) chars as input seems more than enough
-    test $ac_count -gt 10 && break
-  done
-  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
-esac
 
-      $ac_path_EGREP_found && break 3
-    done
-  done
-  done
-IFS=$as_save_IFS
-  if test -z "$ac_cv_path_EGREP"; then
-    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+
+
+
+
+
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5
+printf %s "checking how to hardcode library paths into programs... " >&6; }
+hardcode_action=
+if test -n "$hardcode_libdir_flag_spec" ||
+   test -n "$runpath_var" ||
+   test yes = "$hardcode_automatic"; then
+
+  # We can hardcode non-existent directories.
+  if test no != "$hardcode_direct" &&
+     # If the only mechanism to avoid hardcoding is shlibpath_var, we
+     # have to relink, otherwise we might link with an installed library
+     # when we should be linking with a yet-to-be-installed one
+     ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, )" &&
+     test no != "$hardcode_minus_L"; then
+    # Linking always hardcodes the temporary library directory.
+    hardcode_action=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    hardcode_action=immediate
   fi
 else
-  ac_cv_path_EGREP=$EGREP
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  hardcode_action=unsupported
 fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5
+printf "%s\n" "$hardcode_action" >&6; }
 
-   fi
+if test relink = "$hardcode_action" ||
+   test yes = "$inherit_rpath"; then
+  # Fast installation is not supported
+  enable_fast_install=no
+elif test yes = "$shlibpath_overrides_runpath" ||
+     test no = "$enable_shared"; then
+  # Fast installation is not necessary
+  enable_fast_install=needless
 fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
-printf "%s\n" "$ac_cv_path_EGREP" >&6; }
- EGREP="$ac_cv_path_EGREP"
 
 
 
 
 
 
-  ac_header_dirent=no
-for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
-  as_ac_Header=`printf "%s\n" "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh`
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_hdr that defines DIR" >&5
-printf %s "checking for $ac_hdr that defines DIR... " >&6; }
-if eval test \${$as_ac_Header+y}
+  if test yes != "$enable_dlopen"; then
+  enable_dlopen=unknown
+  enable_dlopen_self=unknown
+  enable_dlopen_self_static=unknown
+else
+  lt_cv_dlopen=no
+  lt_cv_dlopen_libs=
+
+  case $host_os in
+  beos*)
+    lt_cv_dlopen=load_add_on
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+    ;;
+
+  mingw* | pw32* | cegcc*)
+    lt_cv_dlopen=LoadLibrary
+    lt_cv_dlopen_libs=
+    ;;
+
+  cygwin*)
+    lt_cv_dlopen=dlopen
+    lt_cv_dlopen_libs=
+    ;;
+
+  darwin*)
+    # if libdl is installed we need to link against it
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+printf %s "checking for dlopen in -ldl... " >&6; }
+if test ${ac_cv_lib_dl_dlopen+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-#include <sys/types.h>
-#include <$ac_hdr>
 
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+char dlopen ();
 int
 main (void)
 {
-if ((DIR *) 0)
-return 0;
+return dlopen ();
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"
+if ac_fn_c_try_link "$LINENO"
 then :
-  eval "$as_ac_Header=yes"
+  ac_cv_lib_dl_dlopen=yes
 else $as_nop
-  eval "$as_ac_Header=no"
+  ac_cv_lib_dl_dlopen=no
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
 fi
-eval ac_res=\$$as_ac_Header
-	       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-printf "%s\n" "$ac_res" >&6; }
-if eval test \"x\$"$as_ac_Header"\" = x"yes"
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+printf "%s\n" "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = xyes
 then :
-  cat >>confdefs.h <<_ACEOF
-#define `printf "%s\n" "HAVE_$ac_hdr" | $as_tr_cpp` 1
-_ACEOF
+  lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl
+else $as_nop
+
+    lt_cv_dlopen=dyld
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
 
-ac_header_dirent=$ac_hdr; break
 fi
 
-done
-# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
-if test $ac_header_dirent = dirent.h; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5
-printf %s "checking for library containing opendir... " >&6; }
-if test ${ac_cv_search_opendir+y}
+    ;;
+
+  tpf*)
+    # Don't try to run any link tests for TPF.  We know it's impossible
+    # because TPF is a cross-compiler, and we know how we open DSOs.
+    lt_cv_dlopen=dlopen
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=no
+    ;;
+
+  *)
+    ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load"
+if test "x$ac_cv_func_shl_load" = xyes
+then :
+  lt_cv_dlopen=shl_load
+else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5
+printf %s "checking for shl_load in -ldld... " >&6; }
+if test ${ac_cv_lib_dld_shl_load+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  ac_func_search_save_LIBS=$LIBS
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 /* Override any GCC internal prototype to avoid an error.
    Use char because int might match the return type of a GCC
    builtin and then its argument prototype would still apply.  */
-char opendir ();
+char shl_load ();
 int
 main (void)
 {
-return opendir ();
+return shl_load ();
   ;
   return 0;
 }
 _ACEOF
-for ac_lib in '' dir
-do
-  if test -z "$ac_lib"; then
-    ac_res="none required"
-  else
-    ac_res=-l$ac_lib
-    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
-  fi
-  if ac_fn_c_try_link "$LINENO"
+if ac_fn_c_try_link "$LINENO"
 then :
-  ac_cv_search_opendir=$ac_res
+  ac_cv_lib_dld_shl_load=yes
+else $as_nop
+  ac_cv_lib_dld_shl_load=no
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.beam \
-    conftest$ac_exeext
-  if test ${ac_cv_search_opendir+y}
-then :
-  break
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
 fi
-done
-if test ${ac_cv_search_opendir+y}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5
+printf "%s\n" "$ac_cv_lib_dld_shl_load" >&6; }
+if test "x$ac_cv_lib_dld_shl_load" = xyes
 then :
-
+  lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld
 else $as_nop
-  ac_cv_search_opendir=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5
-printf "%s\n" "$ac_cv_search_opendir" >&6; }
-ac_res=$ac_cv_search_opendir
-if test "$ac_res" != no
+  ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen"
+if test "x$ac_cv_func_dlopen" = xyes
 then :
-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-
-fi
-
-else
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5
-printf %s "checking for library containing opendir... " >&6; }
-if test ${ac_cv_search_opendir+y}
+  lt_cv_dlopen=dlopen
+else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+printf %s "checking for dlopen in -ldl... " >&6; }
+if test ${ac_cv_lib_dl_dlopen+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  ac_func_search_save_LIBS=$LIBS
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 /* Override any GCC internal prototype to avoid an error.
    Use char because int might match the return type of a GCC
    builtin and then its argument prototype would still apply.  */
-char opendir ();
+char dlopen ();
 int
 main (void)
 {
-return opendir ();
+return dlopen ();
   ;
   return 0;
 }
 _ACEOF
-for ac_lib in '' x
-do
-  if test -z "$ac_lib"; then
-    ac_res="none required"
-  else
-    ac_res=-l$ac_lib
-    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
-  fi
-  if ac_fn_c_try_link "$LINENO"
+if ac_fn_c_try_link "$LINENO"
 then :
-  ac_cv_search_opendir=$ac_res
+  ac_cv_lib_dl_dlopen=yes
+else $as_nop
+  ac_cv_lib_dl_dlopen=no
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.beam \
-    conftest$ac_exeext
-  if test ${ac_cv_search_opendir+y}
-then :
-  break
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
 fi
-done
-if test ${ac_cv_search_opendir+y}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+printf "%s\n" "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = xyes
 then :
-
+  lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl
 else $as_nop
-  ac_cv_search_opendir=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5
-printf "%s\n" "$ac_cv_search_opendir" >&6; }
-ac_res=$ac_cv_search_opendir
-if test "$ac_res" != no
-then :
-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-
-fi
-
-fi
-
-
-  # =================
-  # AC_CHECK_HEADERS
-  # =================
-  ac_fn_c_check_header_compile "$LINENO" "sys/mman.h" "ac_cv_header_sys_mman_h" "$ac_includes_default"
-if test "x$ac_cv_header_sys_mman_h" = xyes
-then :
-  printf "%s\n" "#define HAVE_SYS_MMAN_H 1" >>confdefs.h
-
-fi
-ac_fn_c_check_header_compile "$LINENO" "sys/param.h" "ac_cv_header_sys_param_h" "$ac_includes_default"
-if test "x$ac_cv_header_sys_param_h" = xyes
-then :
-  printf "%s\n" "#define HAVE_SYS_PARAM_H 1" >>confdefs.h
-
-fi
-ac_fn_c_check_header_compile "$LINENO" "sys/poll.h" "ac_cv_header_sys_poll_h" "$ac_includes_default"
-if test "x$ac_cv_header_sys_poll_h" = xyes
-then :
-  printf "%s\n" "#define HAVE_SYS_POLL_H 1" >>confdefs.h
-
-fi
-ac_fn_c_check_header_compile "$LINENO" "sys/procset.h" "ac_cv_header_sys_procset_h" "$ac_includes_default"
-if test "x$ac_cv_header_sys_procset_h" = xyes
-then :
-  printf "%s\n" "#define HAVE_SYS_PROCSET_H 1" >>confdefs.h
-
-fi
-ac_fn_c_check_header_compile "$LINENO" "sys/select.h" "ac_cv_header_sys_select_h" "$ac_includes_default"
-if test "x$ac_cv_header_sys_select_h" = xyes
-then :
-  printf "%s\n" "#define HAVE_SYS_SELECT_H 1" >>confdefs.h
-
-fi
-ac_fn_c_check_header_compile "$LINENO" "sys/socket.h" "ac_cv_header_sys_socket_h" "$ac_includes_default"
-if test "x$ac_cv_header_sys_socket_h" = xyes
-then :
-  printf "%s\n" "#define HAVE_SYS_SOCKET_H 1" >>confdefs.h
-
-fi
-ac_fn_c_check_header_compile "$LINENO" "sys/stropts.h" "ac_cv_header_sys_stropts_h" "$ac_includes_default"
-if test "x$ac_cv_header_sys_stropts_h" = xyes
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5
+printf %s "checking for dlopen in -lsvld... " >&6; }
+if test ${ac_cv_lib_svld_dlopen+y}
 then :
-  printf "%s\n" "#define HAVE_SYS_STROPTS_H 1" >>confdefs.h
+  printf %s "(cached) " >&6
+else $as_nop
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lsvld  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
-fi
-ac_fn_c_check_header_compile "$LINENO" "sys/time.h" "ac_cv_header_sys_time_h" "$ac_includes_default"
-if test "x$ac_cv_header_sys_time_h" = xyes
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+char dlopen ();
+int
+main (void)
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
 then :
-  printf "%s\n" "#define HAVE_SYS_TIME_H 1" >>confdefs.h
-
+  ac_cv_lib_svld_dlopen=yes
+else $as_nop
+  ac_cv_lib_svld_dlopen=no
 fi
-ac_fn_c_check_header_compile "$LINENO" "sys/un.h" "ac_cv_header_sys_un_h" "$ac_includes_default"
-if test "x$ac_cv_header_sys_un_h" = xyes
-then :
-  printf "%s\n" "#define HAVE_SYS_UN_H 1" >>confdefs.h
-
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
 fi
-ac_fn_c_check_header_compile "$LINENO" "sys/wait.h" "ac_cv_header_sys_wait_h" "$ac_includes_default"
-if test "x$ac_cv_header_sys_wait_h" = xyes
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5
+printf "%s\n" "$ac_cv_lib_svld_dlopen" >&6; }
+if test "x$ac_cv_lib_svld_dlopen" = xyes
 then :
-  printf "%s\n" "#define HAVE_SYS_WAIT_H 1" >>confdefs.h
-
-fi
-ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default"
-if test "x$ac_cv_header_dlfcn_h" = xyes
+  lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld
+else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5
+printf %s "checking for dld_link in -ldld... " >&6; }
+if test ${ac_cv_lib_dld_dld_link+y}
 then :
-  printf "%s\n" "#define HAVE_DLFCN_H 1" >>confdefs.h
+  printf %s "(cached) " >&6
+else $as_nop
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
-fi
-ac_fn_c_check_header_compile "$LINENO" "errno.h" "ac_cv_header_errno_h" "$ac_includes_default"
-if test "x$ac_cv_header_errno_h" = xyes
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+char dld_link ();
+int
+main (void)
+{
+return dld_link ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
 then :
-  printf "%s\n" "#define HAVE_ERRNO_H 1" >>confdefs.h
-
+  ac_cv_lib_dld_dld_link=yes
+else $as_nop
+  ac_cv_lib_dld_dld_link=no
 fi
-ac_fn_c_check_header_compile "$LINENO" "fcntl.h" "ac_cv_header_fcntl_h" "$ac_includes_default"
-if test "x$ac_cv_header_fcntl_h" = xyes
-then :
-  printf "%s\n" "#define HAVE_FCNTL_H 1" >>confdefs.h
-
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
 fi
-ac_fn_c_check_header_compile "$LINENO" "libgen.h" "ac_cv_header_libgen_h" "$ac_includes_default"
-if test "x$ac_cv_header_libgen_h" = xyes
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5
+printf "%s\n" "$ac_cv_lib_dld_dld_link" >&6; }
+if test "x$ac_cv_lib_dld_dld_link" = xyes
 then :
-  printf "%s\n" "#define HAVE_LIBGEN_H 1" >>confdefs.h
-
+  lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld
 fi
-ac_fn_c_check_header_compile "$LINENO" "libintl.h" "ac_cv_header_libintl_h" "$ac_includes_default"
-if test "x$ac_cv_header_libintl_h" = xyes
-then :
-  printf "%s\n" "#define HAVE_LIBINTL_H 1" >>confdefs.h
 
-fi
-ac_fn_c_check_header_compile "$LINENO" "memory.h" "ac_cv_header_memory_h" "$ac_includes_default"
-if test "x$ac_cv_header_memory_h" = xyes
-then :
-  printf "%s\n" "#define HAVE_MEMORY_H 1" >>confdefs.h
 
 fi
-ac_fn_c_check_header_compile "$LINENO" "netinet/in.h" "ac_cv_header_netinet_in_h" "$ac_includes_default"
-if test "x$ac_cv_header_netinet_in_h" = xyes
-then :
-  printf "%s\n" "#define HAVE_NETINET_IN_H 1" >>confdefs.h
 
-fi
-ac_fn_c_check_header_compile "$LINENO" "setjmp.h" "ac_cv_header_setjmp_h" "$ac_includes_default"
-if test "x$ac_cv_header_setjmp_h" = xyes
-then :
-  printf "%s\n" "#define HAVE_SETJMP_H 1" >>confdefs.h
 
 fi
-ac_fn_c_check_header_compile "$LINENO" "stdbool.h" "ac_cv_header_stdbool_h" "$ac_includes_default"
-if test "x$ac_cv_header_stdbool_h" = xyes
-then :
-  printf "%s\n" "#define HAVE_STDBOOL_H 1" >>confdefs.h
 
-fi
-ac_fn_c_check_header_compile "$LINENO" "sysexits.h" "ac_cv_header_sysexits_h" "$ac_includes_default"
-if test "x$ac_cv_header_sysexits_h" = xyes
-then :
-  printf "%s\n" "#define HAVE_SYSEXITS_H 1" >>confdefs.h
 
 fi
-ac_fn_c_check_header_compile "$LINENO" "unistd.h" "ac_cv_header_unistd_h" "$ac_includes_default"
-if test "x$ac_cv_header_unistd_h" = xyes
-then :
-  printf "%s\n" "#define HAVE_UNISTD_H 1" >>confdefs.h
 
-fi
-ac_fn_c_check_header_compile "$LINENO" "utime.h" "ac_cv_header_utime_h" "$ac_includes_default"
-if test "x$ac_cv_header_utime_h" = xyes
-then :
-  printf "%s\n" "#define HAVE_UTIME_H 1" >>confdefs.h
 
 fi
 
 
-         for ac_header in stdarg.h varargs.h
-do :
-  as_ac_Header=`printf "%s\n" "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"
-then :
-  cat >>confdefs.h <<_ACEOF
-#define `printf "%s\n" "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
- lo_have_arg_hdr=true;break
-else $as_nop
-  lo_have_arg_hdr=false
 fi
 
-done
+    ;;
+  esac
 
-         for ac_header in string.h strings.h
-do :
-  as_ac_Header=`printf "%s\n" "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"
-then :
-  cat >>confdefs.h <<_ACEOF
-#define `printf "%s\n" "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
- lo_have_str_hdr=true;break
-else $as_nop
-  lo_have_str_hdr=false
-fi
+  if test no = "$lt_cv_dlopen"; then
+    enable_dlopen=no
+  else
+    enable_dlopen=yes
+  fi
 
-done
+  case $lt_cv_dlopen in
+  dlopen)
+    save_CPPFLAGS=$CPPFLAGS
+    test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
 
-         for ac_header in limits.h sys/limits.h values.h
-do :
-  as_ac_Header=`printf "%s\n" "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"
-then :
-  cat >>confdefs.h <<_ACEOF
-#define `printf "%s\n" "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
- lo_have_lim_hdr=true;break
-else $as_nop
-  lo_have_lim_hdr=false
-fi
+    save_LDFLAGS=$LDFLAGS
+    wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
 
-done
+    save_LIBS=$LIBS
+    LIBS="$lt_cv_dlopen_libs $LIBS"
 
-         for ac_header in inttypes.h stdint.h
-do :
-  as_ac_Header=`printf "%s\n" "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5
+printf %s "checking whether a program can dlopen itself... " >&6; }
+if test ${lt_cv_dlopen_self+y}
 then :
-  cat >>confdefs.h <<_ACEOF
-#define `printf "%s\n" "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
- lo_have_typ_hdr=true;break
+  printf %s "(cached) " >&6
 else $as_nop
-  lo_have_typ_hdr=false
-fi
+  	  if test yes = "$cross_compiling"; then :
+  lt_cv_dlopen_self=cross
+else
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<_LT_EOF
+#line $LINENO "configure"
+#include "confdefs.h"
 
-done
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
 
+#include <stdio.h>
 
-  case "$host_os" in
-    cygwin*)
-                        STDNORETURN_H='stdnoreturn.h'
-      ;;
-    *)
-      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for working stdnoreturn.h" >&5
-printf %s "checking for working stdnoreturn.h... " >&6; }
-if test ${gl_cv_header_working_stdnoreturn_h+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdlib.h>
-                #include <stdnoreturn.h>
-                /* Do not check for 'noreturn' after the return type.
-                   C11 allows it, but it's rarely done that way
-                   and circa-2012 bleeding-edge GCC rejects it when given
-                   -Werror=old-style-declaration.  */
-                noreturn void foo1 (void) { exit (0); }
-                _Noreturn void foo2 (void) { exit (0); }
-                int testit (int argc, char **argv)
-                {
-                  if (argc & 1)
-                    return 0;
-                  (argv[0][0] ? foo1 : foo2) ();
-                }
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL		RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL		DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL		0
+#  endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW		DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW	RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW	DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW	0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
 
-int
-main (void)
+/* When -fvisibility=hidden is used, assume the code has been annotated
+   correspondingly for the symbols needed.  */
+#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
+int fnord () __attribute__((visibility("default")));
+#endif
+
+int fnord () { return 42; }
+int main ()
 {
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
 
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"
-then :
-  gl_cv_header_working_stdnoreturn_h=yes
-else $as_nop
-  gl_cv_header_working_stdnoreturn_h=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_working_stdnoreturn_h" >&5
-printf "%s\n" "$gl_cv_header_working_stdnoreturn_h" >&6; }
-      if test $gl_cv_header_working_stdnoreturn_h = yes; then
-        STDNORETURN_H=''
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
       else
-        STDNORETURN_H='stdnoreturn.h'
-      fi
-      ;;
-  esac
+        {
+	  if (dlsym( self,"_fnord"))  status = $lt_dlneed_uscore;
+          else puts (dlerror ());
+	}
+      /* dlclose (self); */
+    }
+  else
+    puts (dlerror ());
 
-   if test -n "$STDNORETURN_H"; then
-  GL_GENERATE_STDNORETURN_H_TRUE=
-  GL_GENERATE_STDNORETURN_H_FALSE='#'
-else
-  GL_GENERATE_STDNORETURN_H_TRUE='#'
-  GL_GENERATE_STDNORETURN_H_FALSE=
+  return status;
+}
+_LT_EOF
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then
+    (./conftest; exit; ) >&5 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
+      x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
+      x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;;
+    esac
+  else :
+    # compilation failed
+    lt_cv_dlopen_self=no
+  fi
 fi
+rm -fr conftest*
 
 
-
-  # ----------------------------------------------------------------------
-  # check for various programs used during the build.
-  # On OS/X, "wchar.h" needs "runetype.h" to work properly.
-  # ----------------------------------------------------------------------
-  ac_fn_c_check_header_compile "$LINENO" "runetype.h" "ac_cv_header_runetype_h" "
-  $ac_includes_default
-  #if HAVE_RUNETYPE_H
-  # include <runetype.h>
-  #endif
-
-"
-if test "x$ac_cv_header_runetype_h" = xyes
-then :
-  printf "%s\n" "#define HAVE_RUNETYPE_H 1" >>confdefs.h
-
 fi
-ac_fn_c_check_header_compile "$LINENO" "wchar.h" "ac_cv_header_wchar_h" "
-  $ac_includes_default
-  #if HAVE_RUNETYPE_H
-  # include <runetype.h>
-  #endif
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5
+printf "%s\n" "$lt_cv_dlopen_self" >&6; }
 
-"
-if test "x$ac_cv_header_wchar_h" = xyes
+    if test yes = "$lt_cv_dlopen_self"; then
+      wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
+      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5
+printf %s "checking whether a statically linked program can dlopen itself... " >&6; }
+if test ${lt_cv_dlopen_self_static+y}
 then :
-  printf "%s\n" "#define HAVE_WCHAR_H 1" >>confdefs.h
+  printf %s "(cached) " >&6
+else $as_nop
+  	  if test yes = "$cross_compiling"; then :
+  lt_cv_dlopen_self_static=cross
+else
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<_LT_EOF
+#line $LINENO "configure"
+#include "confdefs.h"
 
-fi
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
 
+#include <stdio.h>
 
-  # Check whether --enable-nls was given.
-if test ${enable_nls+y}
-then :
-  enableval=$enable_nls;
-fi
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL		RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL		DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL		0
+#  endif
+#endif
 
-  if test "x$enable_nls" != "xno" && \
-  test "X${ac_cv_header_libintl_h}" = Xyes
-then :
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW		DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW	RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW	DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW	0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
 
+/* When -fvisibility=hidden is used, assume the code has been annotated
+   correspondingly for the symbols needed.  */
+#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
+int fnord () __attribute__((visibility("default")));
+#endif
 
-printf "%s\n" "#define ENABLE_NLS 1" >>confdefs.h
+int fnord () { return 42; }
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
 
-fi
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else
+        {
+	  if (dlsym( self,"_fnord"))  status = $lt_dlneed_uscore;
+          else puts (dlerror ());
+	}
+      /* dlclose (self); */
+    }
+  else
+    puts (dlerror ());
 
-  # --------------------------------------------
-  # Verify certain entries from AC_CHECK_HEADERS
-  # --------------------------------------------
-  ${lo_have_arg_hdr} || \
-    as_fn_error $? "you must have stdarg.h or varargs.h on your system" "$LINENO" 5
+  return status;
+}
+_LT_EOF
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then
+    (./conftest; exit; ) >&5 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
+      x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
+      x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;;
+    esac
+  else :
+    # compilation failed
+    lt_cv_dlopen_self_static=no
+  fi
+fi
+rm -fr conftest*
 
-  ${lo_have_str_hdr} || \
-    as_fn_error $? "you must have string.h or strings.h on your system" "$LINENO" 5
 
-  ${lo_have_lim_hdr} || \
-    as_fn_error $? "you must have one of limits.h, sys/limits.h or values.h" "$LINENO" 5
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5
+printf "%s\n" "$lt_cv_dlopen_self_static" >&6; }
+    fi
 
-  ${lo_have_typ_hdr} || \
-    as_fn_error $? "you must have inttypes.h or stdint.h on your system" "$LINENO" 5
+    CPPFLAGS=$save_CPPFLAGS
+    LDFLAGS=$save_LDFLAGS
+    LIBS=$save_LIBS
+    ;;
+  esac
 
-  for f in sys_types sys_param sys_stat string errno stdlib memory setjmp
-  do eval as_ac_var=\${ac_cv_header_${f}_h}
-     test "X${as_ac_var}" = Xyes || {
-       as_fn_error $? "you must have ${f}.h on your system" "$LINENO" 5
-     }
-  done
-  test "X${ac_cv_header_inttypes_h-no}" = Xyes || \
-    echo '#include <stdint.h>' > inttypes.h
+  case $lt_cv_dlopen_self in
+  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+  *) enable_dlopen_self=unknown ;;
+  esac
+
+  case $lt_cv_dlopen_self_static in
+  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+  *) enable_dlopen_self_static=unknown ;;
+  esac
+fi
 
-  # ----------------------------------------------------------------------
-  # Checks for typedefs
-  # ----------------------------------------------------------------------
-  ac_fn_c_check_type "$LINENO" "wchar_t" "ac_cv_type_wchar_t" "$ac_includes_default"
-if test "x$ac_cv_type_wchar_t" = xyes
-then :
 
-printf "%s\n" "#define HAVE_WCHAR_T 1" >>confdefs.h
 
 
-fi
 
-  ac_fn_c_check_type "$LINENO" "wint_t" "ac_cv_type_wint_t" "
-    $ac_includes_default
-    #if HAVE_RUNETYPE_H
-    # include <runetype.h>
-    #endif
-    #if HAVE_WCHAR_H
-    # include <wchar.h>
-    #endif
 
-"
-if test "x$ac_cv_type_wint_t" = xyes
-then :
 
-printf "%s\n" "#define HAVE_WINT_T 1" >>confdefs.h
 
 
-fi
 
-  ac_fn_c_check_type "$LINENO" "int8_t" "ac_cv_type_int8_t" "$ac_includes_default"
-if test "x$ac_cv_type_int8_t" = xyes
-then :
 
-printf "%s\n" "#define HAVE_INT8_T 1" >>confdefs.h
 
 
-fi
-ac_fn_c_check_type "$LINENO" "uint8_t" "ac_cv_type_uint8_t" "$ac_includes_default"
-if test "x$ac_cv_type_uint8_t" = xyes
-then :
 
-printf "%s\n" "#define HAVE_UINT8_T 1" >>confdefs.h
 
 
+
+striplib=
+old_striplib=
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5
+printf %s "checking whether stripping libraries is possible... " >&6; }
+if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
+  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s\n" "yes" >&6; }
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+  case $host_os in
+  darwin*)
+    if test -n "$STRIP"; then
+      striplib="$STRIP -x"
+      old_striplib="$STRIP -S"
+      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s\n" "yes" >&6; }
+    else
+      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+    fi
+    ;;
+  *)
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+    ;;
+  esac
 fi
-ac_fn_c_check_type "$LINENO" "int16_t" "ac_cv_type_int16_t" "$ac_includes_default"
-if test "x$ac_cv_type_int16_t" = xyes
-then :
 
-printf "%s\n" "#define HAVE_INT16_T 1" >>confdefs.h
 
 
-fi
-ac_fn_c_check_type "$LINENO" "uint16_t" "ac_cv_type_uint16_t" "$ac_includes_default"
-if test "x$ac_cv_type_uint16_t" = xyes
-then :
 
-printf "%s\n" "#define HAVE_UINT16_T 1" >>confdefs.h
 
 
-fi
-ac_fn_c_check_type "$LINENO" "int32_t" "ac_cv_type_int32_t" "$ac_includes_default"
-if test "x$ac_cv_type_int32_t" = xyes
-then :
 
-printf "%s\n" "#define HAVE_INT32_T 1" >>confdefs.h
 
 
-fi
-ac_fn_c_check_type "$LINENO" "uint32_t" "ac_cv_type_uint32_t" "$ac_includes_default"
-if test "x$ac_cv_type_uint32_t" = xyes
-then :
 
-printf "%s\n" "#define HAVE_UINT32_T 1" >>confdefs.h
 
 
-fi
-ac_fn_c_check_type "$LINENO" "intptr_t" "ac_cv_type_intptr_t" "$ac_includes_default"
-if test "x$ac_cv_type_intptr_t" = xyes
-then :
+  # Report what library types will actually be built
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5
+printf %s "checking if libtool supports shared libraries... " >&6; }
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5
+printf "%s\n" "$can_build_shared" >&6; }
 
-printf "%s\n" "#define HAVE_INTPTR_T 1" >>confdefs.h
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5
+printf %s "checking whether to build shared libraries... " >&6; }
+  test no = "$can_build_shared" && enable_shared=no
 
+  # On AIX, shared libraries and static libraries use the same namespace, and
+  # are all built from PIC.
+  case $host_os in
+  aix3*)
+    test yes = "$enable_shared" && enable_static=no
+    if test -n "$RANLIB"; then
+      archive_cmds="$archive_cmds~\$RANLIB \$lib"
+      postinstall_cmds='$RANLIB $lib'
+    fi
+    ;;
+
+  aix[4-9]*)
+    if test ia64 != "$host_cpu"; then
+      case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in
+      yes,aix,yes) ;;			# shared object as lib.so file only
+      yes,svr4,*) ;;			# shared object as lib.so archive member only
+      yes,*) enable_static=no ;;	# shared object in lib.a archive as well
+      esac
+    fi
+    ;;
+  esac
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5
+printf "%s\n" "$enable_shared" >&6; }
+
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5
+printf %s "checking whether to build static libraries... " >&6; }
+  # Make sure either enable_shared or enable_static is yes.
+  test yes = "$enable_shared" || enable_static=yes
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5
+printf "%s\n" "$enable_static" >&6; }
 
-fi
-ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "$ac_includes_default"
-if test "x$ac_cv_type_uintptr_t" = xyes
-then :
 
-printf "%s\n" "#define HAVE_UINTPTR_T 1" >>confdefs.h
 
 
 fi
-ac_fn_c_check_type "$LINENO" "uint_t" "ac_cv_type_uint_t" "$ac_includes_default"
-if test "x$ac_cv_type_uint_t" = xyes
-then :
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-printf "%s\n" "#define HAVE_UINT_T 1" >>confdefs.h
+CC=$lt_save_CC
 
 
-fi
-ac_fn_c_check_type "$LINENO" "pid_t" "ac_cv_type_pid_t" "$ac_includes_default"
-if test "x$ac_cv_type_pid_t" = xyes
-then :
 
-printf "%s\n" "#define HAVE_PID_T 1" >>confdefs.h
 
 
-fi
-ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default"
-if test "x$ac_cv_type_size_t" = xyes
-then :
 
-printf "%s\n" "#define HAVE_SIZE_T 1" >>confdefs.h
 
 
-fi
-ac_fn_c_check_type "$LINENO" "ptrdiff_t" "ac_cv_type_ptrdiff_t" "$ac_includes_default"
-if test "x$ac_cv_type_ptrdiff_t" = xyes
-then :
 
-printf "%s\n" "#define HAVE_PTRDIFF_T 1" >>confdefs.h
 
 
-fi
 
-  # The cast to long int works around a bug in the HP C Compiler
-# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
-# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
-# This bug is HP SR number 8606223364.
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking size of char *" >&5
-printf %s "checking size of char *... " >&6; }
-if test ${ac_cv_sizeof_char_p+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (char *))" "ac_cv_sizeof_char_p"        "$ac_includes_default"
-then :
 
-else $as_nop
-  if test "$ac_cv_type_char_p" = yes; then
-     { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error 77 "cannot compute sizeof (char *)
-See \`config.log' for more details" "$LINENO" 5; }
-   else
-     ac_cv_sizeof_char_p=0
-   fi
-fi
 
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_char_p" >&5
-printf "%s\n" "$ac_cv_sizeof_char_p" >&6; }
 
+        ac_config_commands="$ac_config_commands libtool"
 
 
-printf "%s\n" "#define SIZEOF_CHAR_P $ac_cv_sizeof_char_p" >>confdefs.h
 
 
-  # The cast to long int works around a bug in the HP C Compiler
-# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
-# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
-# This bug is HP SR number 8606223364.
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking size of int" >&5
-printf %s "checking size of int... " >&6; }
-if test ${ac_cv_sizeof_int+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int))" "ac_cv_sizeof_int"        "$ac_includes_default"
-then :
+# Only expand once:
 
-else $as_nop
-  if test "$ac_cv_type_int" = yes; then
-     { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error 77 "cannot compute sizeof (int)
-See \`config.log' for more details" "$LINENO" 5; }
-   else
-     ac_cv_sizeof_int=0
-   fi
-fi
 
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int" >&5
-printf "%s\n" "$ac_cv_sizeof_int" >&6; }
 
 
 
-printf "%s\n" "#define SIZEOF_INT $ac_cv_sizeof_int" >>confdefs.h
 
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if sntp will be built" >&5
+printf %s "checking if sntp will be built... " >&6; }
 
-  # The cast to long int works around a bug in the HP C Compiler
-# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
-# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
-# This bug is HP SR number 8606223364.
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking size of long" >&5
-printf %s "checking size of long... " >&6; }
-if test ${ac_cv_sizeof_long+y}
+# Check whether --with-sntp was given.
+if test ${with_sntp+y}
 then :
-  printf %s "(cached) " >&6
+  withval=$with_sntp;
 else $as_nop
-  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long))" "ac_cv_sizeof_long"        "$ac_includes_default"
-then :
+  with_sntp="${withsntp=yes}"
 
-else $as_nop
-  if test "$ac_cv_type_long" = yes; then
-     { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error 77 "cannot compute sizeof (long)
-See \`config.log' for more details" "$LINENO" 5; }
-   else
-     ac_cv_sizeof_long=0
-   fi
 fi
 
+case "$with_sntp" in
+ no)
+    SNTP=
+    ;;
+ *)
+    SNTP=sntp
+    ;;
+esac
+
+ if test -n "$SNTP"; then
+  BUILD_SNTP_TRUE=
+  BUILD_SNTP_FALSE='#'
+else
+  BUILD_SNTP_TRUE='#'
+  BUILD_SNTP_FALSE=
 fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long" >&5
-printf "%s\n" "$ac_cv_sizeof_long" >&6; }
+
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_sntp" >&5
+printf "%s\n" "$with_sntp" >&6; }
 
 
 
-printf "%s\n" "#define SIZEOF_LONG $ac_cv_sizeof_long" >>confdefs.h
+case "$SNTP" in
+ '')
+    SNTP_DB=
+    SNTP_DL=
+    SNTP_DS=
+    ;;
+esac
+
+###
 
+# NTP has (so far) been relying on leading-edge autogen.
+# Therefore, by default:
+# - use the version we ship with
+# - do not install it
+# - build a static copy (disable-shared - done earlier)
+case "${enable_local_libopts+set}" in
+ set) ;;
+ *) enable_local_libopts=yes ;;
+esac
+case "${enable_libopts_install+set}" in
+ set) ;;
+ *) enable_libopts_install=no ;;
+esac
+enable_nls=no
+# Autoupdate added the next two lines to ensure that your configure
+# script's behavior did not change.  They are probably safe to remove.
 
-  # The cast to long int works around a bug in the HP C Compiler
-# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
-# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
-# This bug is HP SR number 8606223364.
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking size of short" >&5
-printf %s "checking size of short... " >&6; }
-if test ${ac_cv_sizeof_short+y}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
+printf %s "checking for egrep... " >&6; }
+if test ${ac_cv_path_EGREP+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (short))" "ac_cv_sizeof_short"        "$ac_includes_default"
-then :
-
-else $as_nop
-  if test "$ac_cv_type_short" = yes; then
-     { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error 77 "cannot compute sizeof (short)
-See \`config.log' for more details" "$LINENO" 5; }
+  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+   then ac_cv_path_EGREP="$GREP -E"
    else
-     ac_cv_sizeof_short=0
-   fi
+     if test -z "$EGREP"; then
+  ac_path_EGREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_prog in egrep
+   do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_EGREP="$as_dir$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_EGREP" || continue
+# Check for GNU ac_path_EGREP and select it if it is found.
+  # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+  ac_count=0
+  printf %s 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    printf "%s\n" 'EGREP' >> "conftest.nl"
+    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_EGREP="$ac_path_EGREP"
+      ac_path_EGREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_EGREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_EGREP"; then
+    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_EGREP=$EGREP
 fi
 
+   fi
 fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_short" >&5
-printf "%s\n" "$ac_cv_sizeof_short" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
+printf "%s\n" "$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
 
 
 
-printf "%s\n" "#define SIZEOF_SHORT $ac_cv_sizeof_short" >>confdefs.h
 
 
 
-  # ------------
-  # AC_CHECK_LIB
-  # ------------
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pathfind in -lgen" >&5
-printf %s "checking for pathfind in -lgen... " >&6; }
-if test ${ac_cv_lib_gen_pathfind+y}
+  ac_header_dirent=no
+for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
+  as_ac_Header=`printf "%s\n" "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh`
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_hdr that defines DIR" >&5
+printf %s "checking for $ac_hdr that defines DIR... " >&6; }
+if eval test \${$as_ac_Header+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lgen  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
+#include <sys/types.h>
+#include <$ac_hdr>
 
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-char pathfind ();
 int
 main (void)
 {
-return pathfind ();
+if ((DIR *) 0)
+return 0;
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"
+if ac_fn_c_try_compile "$LINENO"
 then :
-  ac_cv_lib_gen_pathfind=yes
+  eval "$as_ac_Header=yes"
 else $as_nop
-  ac_cv_lib_gen_pathfind=no
+  eval "$as_ac_Header=no"
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gen_pathfind" >&5
-printf "%s\n" "$ac_cv_lib_gen_pathfind" >&6; }
-if test "x$ac_cv_lib_gen_pathfind" = xyes
+eval ac_res=\$$as_ac_Header
+	       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+printf "%s\n" "$ac_res" >&6; }
+if eval test \"x\$"$as_ac_Header"\" = x"yes"
 then :
-  printf "%s\n" "#define HAVE_LIBGEN 1" >>confdefs.h
-
-  LIBS="-lgen $LIBS"
+  cat >>confdefs.h <<_ACEOF
+#define `printf "%s\n" "HAVE_$ac_hdr" | $as_tr_cpp` 1
+_ACEOF
 
+ac_header_dirent=$ac_hdr; break
 fi
 
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gettext in -lintl" >&5
-printf %s "checking for gettext in -lintl... " >&6; }
-if test ${ac_cv_lib_intl_gettext+y}
+done
+# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
+if test $ac_header_dirent = dirent.h; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5
+printf %s "checking for library containing opendir... " >&6; }
+if test ${ac_cv_search_opendir+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lintl  $LIBS"
+  ac_func_search_save_LIBS=$LIBS
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 /* Override any GCC internal prototype to avoid an error.
    Use char because int might match the return type of a GCC
    builtin and then its argument prototype would still apply.  */
-char gettext ();
+char opendir ();
 int
 main (void)
 {
-return gettext ();
+return opendir ();
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"
+for ac_lib in '' dir
+do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"
 then :
-  ac_cv_lib_intl_gettext=yes
-else $as_nop
-  ac_cv_lib_intl_gettext=no
+  ac_cv_search_opendir=$ac_res
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.beam \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_intl_gettext" >&5
-printf "%s\n" "$ac_cv_lib_intl_gettext" >&6; }
-if test "x$ac_cv_lib_intl_gettext" = xyes
-then :
-  printf "%s\n" "#define HAVE_LIBINTL 1" >>confdefs.h
-
-  LIBS="-lintl $LIBS"
-
-fi
-
-
-if test "x$ac_cv_func_vprintf" = xno
-then :
-  ac_fn_c_check_func "$LINENO" "_doprnt" "ac_cv_func__doprnt"
-if test "x$ac_cv_func__doprnt" = xyes
-then :
-
-printf "%s\n" "#define HAVE_DOPRNT 1" >>confdefs.h
-
-fi
-
-fi
-
-
-if test "x$ac_cv_func_fork" = xyes; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for working fork" >&5
-printf %s "checking for working fork... " >&6; }
-if test ${ac_cv_func_fork_works+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  if test "$cross_compiling" = yes
-then :
-  ac_cv_func_fork_works=cross
-else $as_nop
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main (void)
-{
-
-	  /* By Ruediger Kuhlmann. */
-	  return fork () < 0;
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"
+    conftest$ac_exeext
+  if test ${ac_cv_search_opendir+y}
 then :
-  ac_cv_func_fork_works=yes
-else $as_nop
-  ac_cv_func_fork_works=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_fork_works" >&5
-printf "%s\n" "$ac_cv_func_fork_works" >&6; }
-
-else
-  ac_cv_func_fork_works=$ac_cv_func_fork
-fi
-if test "x$ac_cv_func_fork_works" = xcross; then
-  case $host in
-    *-*-amigaos* | *-*-msdosdjgpp*)
-      # Override, as these systems have only a dummy fork() stub
-      ac_cv_func_fork_works=no
-      ;;
-    *)
-      ac_cv_func_fork_works=yes
-      ;;
-  esac
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&5
-printf "%s\n" "$as_me: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&2;}
+  break
 fi
-ac_cv_func_vfork_works=$ac_cv_func_vfork
-if test "x$ac_cv_func_vfork" = xyes; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for working vfork" >&5
-printf %s "checking for working vfork... " >&6; }
-if test ${ac_cv_func_vfork_works+y}
+done
+if test ${ac_cv_search_opendir+y}
 then :
-  printf %s "(cached) " >&6
+
 else $as_nop
-  if test "$cross_compiling" = yes
+  ac_cv_search_opendir=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5
+printf "%s\n" "$ac_cv_search_opendir" >&6; }
+ac_res=$ac_cv_search_opendir
+if test "$ac_res" != no
 then :
-  ac_cv_func_vfork_works=cross
-else $as_nop
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-/* Thanks to Paul Eggert for this test.  */
-$ac_includes_default
-#include <signal.h>
-#include <sys/wait.h>
-#ifdef HAVE_VFORK_H
-# include <vfork.h>
-#endif
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
 
-static void
-do_nothing (int sig)
-{
-  (void) sig;
-}
+fi
 
-/* On some sparc systems, changes by the child to local and incoming
-   argument registers are propagated back to the parent.  The compiler
-   is told about this with #include <vfork.h>, but some compilers
-   (e.g. gcc -O) don't grok <vfork.h>.  Test for this by using a
-   static variable whose address is put into a register that is
-   clobbered by the vfork.  */
-static void
-sparc_address_test (int arg)
-{
-  static pid_t child;
-  if (!child) {
-    child = vfork ();
-    if (child < 0) {
-      perror ("vfork");
-      _exit(2);
-    }
-    if (!child) {
-      arg = getpid();
-      write(-1, "", 0);
-      _exit (arg);
-    }
-  }
-}
+else
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5
+printf %s "checking for library containing opendir... " >&6; }
+if test ${ac_cv_search_opendir+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+char opendir ();
 int
 main (void)
 {
-  pid_t parent = getpid ();
-  pid_t child;
-
-  sparc_address_test (0);
-
-  /* On Solaris 2.4, changes by the child to the signal handler
-     also munge signal handlers in the parent.  To detect this,
-     start by putting the parent's handler in a known state.  */
-  signal (SIGTERM, SIG_DFL);
-
-  child = vfork ();
-
-  if (child == 0) {
-    /* Here is another test for sparc vfork register problems.  This
-       test uses lots of local variables, at least as many local
-       variables as main has allocated so far including compiler
-       temporaries.  4 locals are enough for gcc 1.40.3 on a Solaris
-       4.1.3 sparc, but we use 8 to be safe.  A buggy compiler should
-       reuse the register of parent for one of the local variables,
-       since it will think that parent can't possibly be used any more
-       in this routine.  Assigning to the local variable will thus
-       munge parent in the parent process.  */
-    pid_t
-      p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(),
-      p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid();
-    /* Convince the compiler that p..p7 are live; otherwise, it might
-       use the same hardware register for all 8 local variables.  */
-    if (p != p1 || p != p2 || p != p3 || p != p4
-	|| p != p5 || p != p6 || p != p7)
-      _exit(1);
+return opendir ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' x
+do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"
+then :
+  ac_cv_search_opendir=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext
+  if test ${ac_cv_search_opendir+y}
+then :
+  break
+fi
+done
+if test ${ac_cv_search_opendir+y}
+then :
 
-    /* Alter the child's signal handler.  */
-    if (signal (SIGTERM, do_nothing) != SIG_DFL)
-      _exit(1);
+else $as_nop
+  ac_cv_search_opendir=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5
+printf "%s\n" "$ac_cv_search_opendir" >&6; }
+ac_res=$ac_cv_search_opendir
+if test "$ac_res" != no
+then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
 
-    /* On some systems (e.g. IRIX 3.3), vfork doesn't separate parent
-       from child file descriptors.  If the child closes a descriptor
-       before it execs or exits, this munges the parent's descriptor
-       as well.  Test for this by closing stdout in the child.  */
-    _exit(close(fileno(stdout)) != 0);
-  } else {
-    int status;
-    struct stat st;
+fi
 
-    while (wait(&status) != child)
-      ;
-    return (
-	 /* Was there some problem with vforking?  */
-	 child < 0
+fi
 
-	 /* Did the child munge the parent's signal handler?  */
-	 || signal (SIGTERM, SIG_DFL) != SIG_DFL
 
-	 /* Did the child fail?  (This shouldn't happen.)  */
-	 || status
+  # =================
+  # AC_CHECK_HEADERS
+  # =================
+  ac_fn_c_check_header_compile "$LINENO" "sys/mman.h" "ac_cv_header_sys_mman_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_mman_h" = xyes
+then :
+  printf "%s\n" "#define HAVE_SYS_MMAN_H 1" >>confdefs.h
 
-	 /* Did the vfork/compiler bug occur?  */
-	 || parent != getpid()
+fi
+ac_fn_c_check_header_compile "$LINENO" "sys/param.h" "ac_cv_header_sys_param_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_param_h" = xyes
+then :
+  printf "%s\n" "#define HAVE_SYS_PARAM_H 1" >>confdefs.h
 
-	 /* Did the file descriptor bug occur?  */
-	 || fstat(fileno(stdout), &st) != 0
-	 );
-  }
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"
+fi
+ac_fn_c_check_header_compile "$LINENO" "sys/poll.h" "ac_cv_header_sys_poll_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_poll_h" = xyes
 then :
-  ac_cv_func_vfork_works=yes
-else $as_nop
-  ac_cv_func_vfork_works=no
+  printf "%s\n" "#define HAVE_SYS_POLL_H 1" >>confdefs.h
+
 fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
+ac_fn_c_check_header_compile "$LINENO" "sys/procset.h" "ac_cv_header_sys_procset_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_procset_h" = xyes
+then :
+  printf "%s\n" "#define HAVE_SYS_PROCSET_H 1" >>confdefs.h
+
 fi
+ac_fn_c_check_header_compile "$LINENO" "sys/select.h" "ac_cv_header_sys_select_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_select_h" = xyes
+then :
+  printf "%s\n" "#define HAVE_SYS_SELECT_H 1" >>confdefs.h
 
 fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_vfork_works" >&5
-printf "%s\n" "$ac_cv_func_vfork_works" >&6; }
+ac_fn_c_check_header_compile "$LINENO" "sys/socket.h" "ac_cv_header_sys_socket_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_socket_h" = xyes
+then :
+  printf "%s\n" "#define HAVE_SYS_SOCKET_H 1" >>confdefs.h
 
-fi;
-if test "x$ac_cv_func_fork_works" = xcross; then
-  ac_cv_func_vfork_works=$ac_cv_func_vfork
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&5
-printf "%s\n" "$as_me: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&2;}
 fi
+ac_fn_c_check_header_compile "$LINENO" "sys/stropts.h" "ac_cv_header_sys_stropts_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_stropts_h" = xyes
+then :
+  printf "%s\n" "#define HAVE_SYS_STROPTS_H 1" >>confdefs.h
 
-if test "x$ac_cv_func_vfork_works" = xyes; then
+fi
+ac_fn_c_check_header_compile "$LINENO" "sys/time.h" "ac_cv_header_sys_time_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_time_h" = xyes
+then :
+  printf "%s\n" "#define HAVE_SYS_TIME_H 1" >>confdefs.h
 
-printf "%s\n" "#define HAVE_WORKING_VFORK 1" >>confdefs.h
+fi
+ac_fn_c_check_header_compile "$LINENO" "sys/un.h" "ac_cv_header_sys_un_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_un_h" = xyes
+then :
+  printf "%s\n" "#define HAVE_SYS_UN_H 1" >>confdefs.h
 
-else
+fi
+ac_fn_c_check_header_compile "$LINENO" "sys/wait.h" "ac_cv_header_sys_wait_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_wait_h" = xyes
+then :
+  printf "%s\n" "#define HAVE_SYS_WAIT_H 1" >>confdefs.h
 
-printf "%s\n" "#define vfork fork" >>confdefs.h
+fi
+ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default"
+if test "x$ac_cv_header_dlfcn_h" = xyes
+then :
+  printf "%s\n" "#define HAVE_DLFCN_H 1" >>confdefs.h
 
 fi
-if test "x$ac_cv_func_fork_works" = xyes; then
+ac_fn_c_check_header_compile "$LINENO" "errno.h" "ac_cv_header_errno_h" "$ac_includes_default"
+if test "x$ac_cv_header_errno_h" = xyes
+then :
+  printf "%s\n" "#define HAVE_ERRNO_H 1" >>confdefs.h
 
-printf "%s\n" "#define HAVE_WORKING_FORK 1" >>confdefs.h
+fi
+ac_fn_c_check_header_compile "$LINENO" "fcntl.h" "ac_cv_header_fcntl_h" "$ac_includes_default"
+if test "x$ac_cv_header_fcntl_h" = xyes
+then :
+  printf "%s\n" "#define HAVE_FCNTL_H 1" >>confdefs.h
 
 fi
+ac_fn_c_check_header_compile "$LINENO" "libgen.h" "ac_cv_header_libgen_h" "$ac_includes_default"
+if test "x$ac_cv_header_libgen_h" = xyes
+then :
+  printf "%s\n" "#define HAVE_LIBGEN_H 1" >>confdefs.h
 
-  ac_fn_c_check_func "$LINENO" "mmap" "ac_cv_func_mmap"
-if test "x$ac_cv_func_mmap" = xyes
+fi
+ac_fn_c_check_header_compile "$LINENO" "libintl.h" "ac_cv_header_libintl_h" "$ac_includes_default"
+if test "x$ac_cv_header_libintl_h" = xyes
 then :
-  printf "%s\n" "#define HAVE_MMAP 1" >>confdefs.h
+  printf "%s\n" "#define HAVE_LIBINTL_H 1" >>confdefs.h
 
 fi
-ac_fn_c_check_func "$LINENO" "canonicalize_file_name" "ac_cv_func_canonicalize_file_name"
-if test "x$ac_cv_func_canonicalize_file_name" = xyes
+ac_fn_c_check_header_compile "$LINENO" "memory.h" "ac_cv_header_memory_h" "$ac_includes_default"
+if test "x$ac_cv_header_memory_h" = xyes
 then :
-  printf "%s\n" "#define HAVE_CANONICALIZE_FILE_NAME 1" >>confdefs.h
+  printf "%s\n" "#define HAVE_MEMORY_H 1" >>confdefs.h
 
 fi
-ac_fn_c_check_func "$LINENO" "snprintf" "ac_cv_func_snprintf"
-if test "x$ac_cv_func_snprintf" = xyes
+ac_fn_c_check_header_compile "$LINENO" "netinet/in.h" "ac_cv_header_netinet_in_h" "$ac_includes_default"
+if test "x$ac_cv_header_netinet_in_h" = xyes
 then :
-  printf "%s\n" "#define HAVE_SNPRINTF 1" >>confdefs.h
+  printf "%s\n" "#define HAVE_NETINET_IN_H 1" >>confdefs.h
 
 fi
-ac_fn_c_check_func "$LINENO" "strdup" "ac_cv_func_strdup"
-if test "x$ac_cv_func_strdup" = xyes
+ac_fn_c_check_header_compile "$LINENO" "setjmp.h" "ac_cv_header_setjmp_h" "$ac_includes_default"
+if test "x$ac_cv_header_setjmp_h" = xyes
 then :
-  printf "%s\n" "#define HAVE_STRDUP 1" >>confdefs.h
+  printf "%s\n" "#define HAVE_SETJMP_H 1" >>confdefs.h
 
 fi
-ac_fn_c_check_func "$LINENO" "strchr" "ac_cv_func_strchr"
-if test "x$ac_cv_func_strchr" = xyes
+ac_fn_c_check_header_compile "$LINENO" "stdbool.h" "ac_cv_header_stdbool_h" "$ac_includes_default"
+if test "x$ac_cv_header_stdbool_h" = xyes
 then :
-  printf "%s\n" "#define HAVE_STRCHR 1" >>confdefs.h
+  printf "%s\n" "#define HAVE_STDBOOL_H 1" >>confdefs.h
 
 fi
-ac_fn_c_check_func "$LINENO" "strrchr" "ac_cv_func_strrchr"
-if test "x$ac_cv_func_strrchr" = xyes
+ac_fn_c_check_header_compile "$LINENO" "sysexits.h" "ac_cv_header_sysexits_h" "$ac_includes_default"
+if test "x$ac_cv_header_sysexits_h" = xyes
 then :
-  printf "%s\n" "#define HAVE_STRRCHR 1" >>confdefs.h
+  printf "%s\n" "#define HAVE_SYSEXITS_H 1" >>confdefs.h
 
 fi
-ac_fn_c_check_func "$LINENO" "strsignal" "ac_cv_func_strsignal"
-if test "x$ac_cv_func_strsignal" = xyes
+ac_fn_c_check_header_compile "$LINENO" "unistd.h" "ac_cv_header_unistd_h" "$ac_includes_default"
+if test "x$ac_cv_header_unistd_h" = xyes
 then :
-  printf "%s\n" "#define HAVE_STRSIGNAL 1" >>confdefs.h
+  printf "%s\n" "#define HAVE_UNISTD_H 1" >>confdefs.h
 
 fi
-ac_fn_c_check_func "$LINENO" "fchmod" "ac_cv_func_fchmod"
-if test "x$ac_cv_func_fchmod" = xyes
+ac_fn_c_check_header_compile "$LINENO" "utime.h" "ac_cv_header_utime_h" "$ac_includes_default"
+if test "x$ac_cv_header_utime_h" = xyes
 then :
-  printf "%s\n" "#define HAVE_FCHMOD 1" >>confdefs.h
+  printf "%s\n" "#define HAVE_UTIME_H 1" >>confdefs.h
 
 fi
-ac_fn_c_check_func "$LINENO" "fstat" "ac_cv_func_fstat"
-if test "x$ac_cv_func_fstat" = xyes
+
+
+         for ac_header in stdarg.h varargs.h
+do :
+  as_ac_Header=`printf "%s\n" "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"
 then :
-  printf "%s\n" "#define HAVE_FSTAT 1" >>confdefs.h
+  cat >>confdefs.h <<_ACEOF
+#define `printf "%s\n" "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+ lo_have_arg_hdr=true;break
+else $as_nop
+  lo_have_arg_hdr=false
+fi
+
+done
 
+         for ac_header in string.h strings.h
+do :
+  as_ac_Header=`printf "%s\n" "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"
+then :
+  cat >>confdefs.h <<_ACEOF
+#define `printf "%s\n" "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+ lo_have_str_hdr=true;break
+else $as_nop
+  lo_have_str_hdr=false
 fi
-ac_fn_c_check_func "$LINENO" "chmod" "ac_cv_func_chmod"
-if test "x$ac_cv_func_chmod" = xyes
+
+done
+
+         for ac_header in limits.h sys/limits.h values.h
+do :
+  as_ac_Header=`printf "%s\n" "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"
 then :
-  printf "%s\n" "#define HAVE_CHMOD 1" >>confdefs.h
+  cat >>confdefs.h <<_ACEOF
+#define `printf "%s\n" "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+ lo_have_lim_hdr=true;break
+else $as_nop
+  lo_have_lim_hdr=false
+fi
+
+done
 
+         for ac_header in inttypes.h stdint.h
+do :
+  as_ac_Header=`printf "%s\n" "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"
+then :
+  cat >>confdefs.h <<_ACEOF
+#define `printf "%s\n" "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+ lo_have_typ_hdr=true;break
+else $as_nop
+  lo_have_typ_hdr=false
 fi
 
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5
-printf %s "checking for a sed that does not truncate output... " >&6; }
-if test ${ac_cv_path_SED+y}
+done
+
+
+  case "$host_os" in
+    cygwin*)
+                        STDNORETURN_H='stdnoreturn.h'
+      ;;
+    *)
+      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for working stdnoreturn.h" >&5
+printf %s "checking for working stdnoreturn.h... " >&6; }
+if test ${gl_cv_header_working_stdnoreturn_h+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-            ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
-     for ac_i in 1 2 3 4 5 6 7; do
-       ac_script="$ac_script$as_nl$ac_script"
-     done
-     echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed
-     { ac_script=; unset ac_script;}
-     if test -z "$SED"; then
-  ac_path_SED_found=false
-  # Loop through the user's path and test for each of PROGNAME-LIST
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  case $as_dir in #(((
-    '') as_dir=./ ;;
-    */) ;;
-    *) as_dir=$as_dir/ ;;
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+                #include <stdnoreturn.h>
+                /* Do not check for 'noreturn' after the return type.
+                   C11 allows it, but it's rarely done that way
+                   and circa-2012 bleeding-edge GCC rejects it when given
+                   -Werror=old-style-declaration.  */
+                noreturn void foo1 (void) { exit (0); }
+                _Noreturn void foo2 (void) { exit (0); }
+                int testit (int argc, char **argv)
+                {
+                  if (argc & 1)
+                    return 0;
+                  (argv[0][0] ? foo1 : foo2) ();
+                }
+
+int
+main (void)
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+  gl_cv_header_working_stdnoreturn_h=yes
+else $as_nop
+  gl_cv_header_working_stdnoreturn_h=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_working_stdnoreturn_h" >&5
+printf "%s\n" "$gl_cv_header_working_stdnoreturn_h" >&6; }
+      if test $gl_cv_header_working_stdnoreturn_h = yes; then
+        STDNORETURN_H=''
+      else
+        STDNORETURN_H='stdnoreturn.h'
+      fi
+      ;;
   esac
-    for ac_prog in sed gsed
-   do
-    for ac_exec_ext in '' $ac_executable_extensions; do
-      ac_path_SED="$as_dir$ac_prog$ac_exec_ext"
-      as_fn_executable_p "$ac_path_SED" || continue
-# Check for GNU ac_path_SED and select it if it is found.
-  # Check for GNU $ac_path_SED
-case `"$ac_path_SED" --version 2>&1` in
-*GNU*)
-  ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;;
-*)
-  ac_count=0
-  printf %s 0123456789 >"conftest.in"
-  while :
-  do
-    cat "conftest.in" "conftest.in" >"conftest.tmp"
-    mv "conftest.tmp" "conftest.in"
-    cp "conftest.in" "conftest.nl"
-    printf "%s\n" '' >> "conftest.nl"
-    "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break
-    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
-    as_fn_arith $ac_count + 1 && ac_count=$as_val
-    if test $ac_count -gt ${ac_path_SED_max-0}; then
-      # Best one so far, save it but keep looking for a better one
-      ac_cv_path_SED="$ac_path_SED"
-      ac_path_SED_max=$ac_count
-    fi
-    # 10*(2^10) chars as input seems more than enough
-    test $ac_count -gt 10 && break
-  done
-  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
-esac
 
-      $ac_path_SED_found && break 3
-    done
-  done
-  done
-IFS=$as_save_IFS
-  if test -z "$ac_cv_path_SED"; then
-    as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5
-  fi
+   if test -n "$STDNORETURN_H"; then
+  GL_GENERATE_STDNORETURN_H_TRUE=
+  GL_GENERATE_STDNORETURN_H_FALSE='#'
 else
-  ac_cv_path_SED=$SED
+  GL_GENERATE_STDNORETURN_H_TRUE='#'
+  GL_GENERATE_STDNORETURN_H_FALSE=
+fi
+
+
+
+  # ----------------------------------------------------------------------
+  # check for various programs used during the build.
+  # On OS/X, "wchar.h" needs "runetype.h" to work properly.
+  # ----------------------------------------------------------------------
+  ac_fn_c_check_header_compile "$LINENO" "runetype.h" "ac_cv_header_runetype_h" "
+  $ac_includes_default
+  #if HAVE_RUNETYPE_H
+  # include <runetype.h>
+  #endif
+
+"
+if test "x$ac_cv_header_runetype_h" = xyes
+then :
+  printf "%s\n" "#define HAVE_RUNETYPE_H 1" >>confdefs.h
+
+fi
+ac_fn_c_check_header_compile "$LINENO" "wchar.h" "ac_cv_header_wchar_h" "
+  $ac_includes_default
+  #if HAVE_RUNETYPE_H
+  # include <runetype.h>
+  #endif
+
+"
+if test "x$ac_cv_header_wchar_h" = xyes
+then :
+  printf "%s\n" "#define HAVE_WCHAR_H 1" >>confdefs.h
+
 fi
 
+
+  # Check whether --enable-nls was given.
+if test ${enable_nls+y}
+then :
+  enableval=$enable_nls;
 fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5
-printf "%s\n" "$ac_cv_path_SED" >&6; }
- SED="$ac_cv_path_SED"
-  rm -f conftest.sed
 
-  while :
-  do
-      test -x "$POSIX_SHELL" && break
-      POSIX_SHELL=`which bash`
-      test -x "$POSIX_SHELL" && break
-      POSIX_SHELL=`which dash`
-      test -x "$POSIX_SHELL" && break
-      POSIX_SHELL=/usr/xpg4/bin/sh
-      test -x "$POSIX_SHELL" && break
-      POSIX_SHELL=`/bin/sh -c '
-          exec 2>/dev/null
-          if ! true ; then exit 1 ; fi
-          echo /bin/sh'`
-      test -x "$POSIX_SHELL" && break
-      as_fn_error $? "cannot locate a working POSIX shell" "$LINENO" 5
-  done
+  if test "x$enable_nls" != "xno" && \
+  test "X${ac_cv_header_libintl_h}" = Xyes
+then :
 
-printf "%s\n" "#define POSIX_SHELL \"${POSIX_SHELL}\"" >>confdefs.h
 
+printf "%s\n" "#define ENABLE_NLS 1" >>confdefs.h
 
+fi
 
+  # --------------------------------------------
+  # Verify certain entries from AC_CHECK_HEADERS
+  # --------------------------------------------
+  ${lo_have_arg_hdr} || \
+    as_fn_error $? "you must have stdarg.h or varargs.h on your system" "$LINENO" 5
 
+  ${lo_have_str_hdr} || \
+    as_fn_error $? "you must have string.h or strings.h on your system" "$LINENO" 5
 
-  LIBOPTS_BUILD_BLOCKED=''
+  ${lo_have_lim_hdr} || \
+    as_fn_error $? "you must have one of limits.h, sys/limits.h or values.h" "$LINENO" 5
 
+  ${lo_have_typ_hdr} || \
+    as_fn_error $? "you must have inttypes.h or stdint.h on your system" "$LINENO" 5
 
-  NEED_LIBOPTS_DIR=''
+  for f in sys_types sys_param sys_stat string errno stdlib memory setjmp
+  do eval as_ac_var=\${ac_cv_header_${f}_h}
+     test "X${as_ac_var}" = Xyes || {
+       as_fn_error $? "you must have ${f}.h on your system" "$LINENO" 5
+     }
+  done
+  test "X${ac_cv_header_inttypes_h-no}" = Xyes || \
+    echo '#include <stdint.h>' > inttypes.h
 
-  # Check whether --enable-local-libopts was given.
-if test ${enable_local_libopts+y}
+  # ----------------------------------------------------------------------
+  # Checks for typedefs
+  # ----------------------------------------------------------------------
+  ac_fn_c_check_type "$LINENO" "wchar_t" "ac_cv_type_wchar_t" "$ac_includes_default"
+if test "x$ac_cv_type_wchar_t" = xyes
 then :
-  enableval=$enable_local_libopts;
-    if test x$enableval = xyes ; then
-       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Using supplied libopts tearoff" >&5
-printf "%s\n" "$as_me: Using supplied libopts tearoff" >&6;}
-       LIBOPTS_CFLAGS='-I$(top_srcdir)/libopts'
-       NEED_LIBOPTS_DIR=true
-       LIBOPTS_LDADD='$(top_builddir)/libopts/libopts.la'
-    fi
+
+printf "%s\n" "#define HAVE_WCHAR_T 1" >>confdefs.h
+
+
 fi
 
+  ac_fn_c_check_type "$LINENO" "wint_t" "ac_cv_type_wint_t" "
+    $ac_includes_default
+    #if HAVE_RUNETYPE_H
+    # include <runetype.h>
+    #endif
+    #if HAVE_WCHAR_H
+    # include <wchar.h>
+    #endif
 
-  # Check whether --enable-libopts-install was given.
-if test ${enable_libopts_install+y}
+"
+if test "x$ac_cv_type_wint_t" = xyes
 then :
-  enableval=$enable_libopts_install;
+
+printf "%s\n" "#define HAVE_WINT_T 1" >>confdefs.h
+
+
 fi
 
-   if test "X${enable_libopts_install}" = Xyes; then
-  INSTALL_LIBOPTS_TRUE=
-  INSTALL_LIBOPTS_FALSE='#'
-else
-  INSTALL_LIBOPTS_TRUE='#'
-  INSTALL_LIBOPTS_FALSE=
+  ac_fn_c_check_type "$LINENO" "int8_t" "ac_cv_type_int8_t" "$ac_includes_default"
+if test "x$ac_cv_type_int8_t" = xyes
+then :
+
+printf "%s\n" "#define HAVE_INT8_T 1" >>confdefs.h
+
+
 fi
+ac_fn_c_check_type "$LINENO" "uint8_t" "ac_cv_type_uint8_t" "$ac_includes_default"
+if test "x$ac_cv_type_uint8_t" = xyes
+then :
 
+printf "%s\n" "#define HAVE_UINT8_T 1" >>confdefs.h
 
-  if test -z "${NEED_LIBOPTS_DIR}" ; then
-     { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether autoopts-config can be found" >&5
-printf %s "checking whether autoopts-config can be found... " >&6; }
 
-# Check whether --with-autoopts-config was given.
-if test ${with_autoopts_config+y}
+fi
+ac_fn_c_check_type "$LINENO" "int16_t" "ac_cv_type_int16_t" "$ac_includes_default"
+if test "x$ac_cv_type_int16_t" = xyes
 then :
-  withval=$with_autoopts_config; lo_cv_with_autoopts_config=${with_autoopts_config}
-else $as_nop
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether autoopts-config is specified" >&5
-printf %s "checking whether autoopts-config is specified... " >&6; }
-if test ${lo_cv_with_autoopts_config+y}
+
+printf "%s\n" "#define HAVE_INT16_T 1" >>confdefs.h
+
+
+fi
+ac_fn_c_check_type "$LINENO" "uint16_t" "ac_cv_type_uint16_t" "$ac_includes_default"
+if test "x$ac_cv_type_uint16_t" = xyes
 then :
-  printf %s "(cached) " >&6
-else $as_nop
-  if autoopts-config --help 2>/dev/null 1>&2
-        then lo_cv_with_autoopts_config=autoopts-config
-        elif libopts-config --help 2>/dev/null 1>&2
-        then lo_cv_with_autoopts_config=libopts-config
-        else lo_cv_with_autoopts_config=no ; fi
+
+printf "%s\n" "#define HAVE_UINT16_T 1" >>confdefs.h
+
+
 fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lo_cv_with_autoopts_config" >&5
-printf "%s\n" "$lo_cv_with_autoopts_config" >&6; }
+ac_fn_c_check_type "$LINENO" "int32_t" "ac_cv_type_int32_t" "$ac_includes_default"
+if test "x$ac_cv_type_int32_t" = xyes
+then :
+
+printf "%s\n" "#define HAVE_INT32_T 1" >>confdefs.h
+
 
 fi
- # end of AC_ARG_WITH
+ac_fn_c_check_type "$LINENO" "uint32_t" "ac_cv_type_uint32_t" "$ac_includes_default"
+if test "x$ac_cv_type_uint32_t" = xyes
+then :
 
-     if test ${lo_cv_test_autoopts+y}
+printf "%s\n" "#define HAVE_UINT32_T 1" >>confdefs.h
+
+
+fi
+ac_fn_c_check_type "$LINENO" "intptr_t" "ac_cv_type_intptr_t" "$ac_includes_default"
+if test "x$ac_cv_type_intptr_t" = xyes
 then :
-  printf %s "(cached) " >&6
-else $as_nop
 
-        if test -z "${lo_cv_with_autoopts_config}" \
-                -o X"${lo_cv_with_autoopts_config}" = Xno
-        then
-           if autoopts-config --help 2>/dev/null 1>&2
-           then lo_cv_with_autoopts_config=autoopts-config
-           elif libopts-config --help 2>/dev/null 1>&2
-           then lo_cv_with_autoopts_config=libopts-config
-           else lo_cv_with_autoopts_config=false ; fi
-        fi
-        lo_cv_test_autoopts=`
-            ${lo_cv_with_autoopts_config} --libs` 2> /dev/null
-        if test $? -ne 0 -o -z "${lo_cv_test_autoopts}"
-        then lo_cv_test_autoopts=no ; fi
+printf "%s\n" "#define HAVE_INTPTR_T 1" >>confdefs.h
+
 
 fi
- # end of CACHE_VAL
-     { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${lo_cv_test_autoopts}" >&5
-printf "%s\n" "${lo_cv_test_autoopts}" >&6; }
+ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "$ac_includes_default"
+if test "x$ac_cv_type_uintptr_t" = xyes
+then :
+
+printf "%s\n" "#define HAVE_UINTPTR_T 1" >>confdefs.h
+
 
-     if test "X${lo_cv_test_autoopts}" != Xno
-     then
-        LIBOPTS_LDADD="${lo_cv_test_autoopts}"
-        LIBOPTS_CFLAGS="`${lo_cv_with_autoopts_config} --cflags`"
-     else
-        LIBOPTS_LDADD='$(top_builddir)/libopts/libopts.la'
-        LIBOPTS_CFLAGS='-I$(top_srcdir)/libopts'
-        NEED_LIBOPTS_DIR=true
-     fi
-  fi # end of if test -z "${NEED_LIBOPTS_DIR}"
-  if test -n "${LIBOPTS_BUILD_BLOCKED}" ; then
-    NEED_LIBOPTS_DIR=''
-  fi
-   if test -n "${NEED_LIBOPTS_DIR}"; then
-  NEED_LIBOPTS_TRUE=
-  NEED_LIBOPTS_FALSE='#'
-else
-  NEED_LIBOPTS_TRUE='#'
-  NEED_LIBOPTS_FALSE=
 fi
+ac_fn_c_check_type "$LINENO" "uint_t" "ac_cv_type_uint_t" "$ac_includes_default"
+if test "x$ac_cv_type_uint_t" = xyes
+then :
 
+printf "%s\n" "#define HAVE_UINT_T 1" >>confdefs.h
 
 
-  LIBOPTS_DIR=libopts
+fi
+ac_fn_c_check_type "$LINENO" "pid_t" "ac_cv_type_pid_t" "$ac_includes_default"
+if test "x$ac_cv_type_pid_t" = xyes
+then :
 
+printf "%s\n" "#define HAVE_PID_T 1" >>confdefs.h
 
-# end of AC_DEFUN of LIBOPTS_CHECK_COMMON
 
+fi
+ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default"
+if test "x$ac_cv_type_size_t" = xyes
+then :
 
-    if test -z "$NEED_LIBOPTS_TRUE"; then :
+printf "%s\n" "#define HAVE_SIZE_T 1" >>confdefs.h
+
+
+fi
+ac_fn_c_check_type "$LINENO" "ptrdiff_t" "ac_cv_type_ptrdiff_t" "$ac_includes_default"
+if test "x$ac_cv_type_ptrdiff_t" = xyes
+then :
+
+printf "%s\n" "#define HAVE_PTRDIFF_T 1" >>confdefs.h
+
+
+fi
+
+  # The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking size of char *" >&5
+printf %s "checking size of char *... " >&6; }
+if test ${ac_cv_sizeof_char_p+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (char *))" "ac_cv_sizeof_char_p"        "$ac_includes_default"
+then :
+
+else $as_nop
+  if test "$ac_cv_type_char_p" = yes; then
+     { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "cannot compute sizeof (char *)
+See \`config.log' for more details" "$LINENO" 5; }
+   else
+     ac_cv_sizeof_char_p=0
+   fi
+fi
+
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_char_p" >&5
+printf "%s\n" "$ac_cv_sizeof_char_p" >&6; }
 
 
 
-  # Check to see if a reg expr header is specified.
+printf "%s\n" "#define SIZEOF_CHAR_P $ac_cv_sizeof_char_p" >>confdefs.h
 
 
-# Check whether --with-regex-header was given.
-if test ${with_regex_header+y}
+  # The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking size of int" >&5
+printf %s "checking size of int... " >&6; }
+if test ${ac_cv_sizeof_int+y}
 then :
-  withval=$with_regex_header; libopts_cv_with_regex_header=${with_regex_header}
+  printf %s "(cached) " >&6
 else $as_nop
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether a reg expr header is specified" >&5
-printf %s "checking whether a reg expr header is specified... " >&6; }
-if test ${libopts_cv_with_regex_header+y}
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int))" "ac_cv_sizeof_int"        "$ac_includes_default"
 then :
-  printf %s "(cached) " >&6
+
 else $as_nop
-  libopts_cv_with_regex_header=no
+  if test "$ac_cv_type_int" = yes; then
+     { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "cannot compute sizeof (int)
+See \`config.log' for more details" "$LINENO" 5; }
+   else
+     ac_cv_sizeof_int=0
+   fi
 fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libopts_cv_with_regex_header" >&5
-printf "%s\n" "$libopts_cv_with_regex_header" >&6; }
 
 fi
- # end of AC_ARG_WITH
-  if test "X${libopts_cv_with_regex_header}" != Xno
-  then
-    printf "%s\n" "#define REGEX_HEADER <${libopts_cv_with_regex_header}>" >>confdefs.h
-
-  else
-
-printf "%s\n" "#define REGEX_HEADER <regex.h>" >>confdefs.h
-
-  fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int" >&5
+printf "%s\n" "$ac_cv_sizeof_int" >&6; }
 
 
 
-  # Check to see if a working libregex can be found.
+printf "%s\n" "#define SIZEOF_INT $ac_cv_sizeof_int" >>confdefs.h
 
 
-# Check whether --with-libregex was given.
-if test ${with_libregex+y}
+  # The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking size of long" >&5
+printf %s "checking size of long... " >&6; }
+if test ${ac_cv_sizeof_long+y}
 then :
-  withval=$with_libregex; libopts_cv_with_libregex_root=${with_libregex}
+  printf %s "(cached) " >&6
 else $as_nop
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether with-libregex was specified" >&5
-printf %s "checking whether with-libregex was specified... " >&6; }
-if test ${libopts_cv_with_libregex_root+y}
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long))" "ac_cv_sizeof_long"        "$ac_includes_default"
 then :
-  printf %s "(cached) " >&6
+
 else $as_nop
-  libopts_cv_with_libregex_root=no
+  if test "$ac_cv_type_long" = yes; then
+     { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "cannot compute sizeof (long)
+See \`config.log' for more details" "$LINENO" 5; }
+   else
+     ac_cv_sizeof_long=0
+   fi
 fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libopts_cv_with_libregex_root" >&5
-printf "%s\n" "$libopts_cv_with_libregex_root" >&6; }
 
 fi
- # end of AC_ARG_WITH libregex
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long" >&5
+printf "%s\n" "$ac_cv_sizeof_long" >&6; }
 
-  if test "${with_libregex+set}" = set && \
-     test "X${withval}" = Xno
-  then ## disabled by request
-    libopts_cv_with_libregex_root=no
-    libopts_cv_with_libregex_cflags=no
-    libopts_cv_with_libregex_libs=no
-  else
 
 
-# Check whether --with-libregex-cflags was given.
-if test ${with_libregex_cflags+y}
+printf "%s\n" "#define SIZEOF_LONG $ac_cv_sizeof_long" >>confdefs.h
+
+
+  # The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking size of short" >&5
+printf %s "checking size of short... " >&6; }
+if test ${ac_cv_sizeof_short+y}
 then :
-  withval=$with_libregex_cflags; libopts_cv_with_libregex_cflags=${with_libregex_cflags}
+  printf %s "(cached) " >&6
 else $as_nop
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether with-libregex-cflags was specified" >&5
-printf %s "checking whether with-libregex-cflags was specified... " >&6; }
-if test ${libopts_cv_with_libregex_cflags+y}
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (short))" "ac_cv_sizeof_short"        "$ac_includes_default"
 then :
-  printf %s "(cached) " >&6
+
 else $as_nop
-  libopts_cv_with_libregex_cflags=no
+  if test "$ac_cv_type_short" = yes; then
+     { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "cannot compute sizeof (short)
+See \`config.log' for more details" "$LINENO" 5; }
+   else
+     ac_cv_sizeof_short=0
+   fi
 fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libopts_cv_with_libregex_cflags" >&5
-printf "%s\n" "$libopts_cv_with_libregex_cflags" >&6; }
 
 fi
- # end of AC_ARG_WITH libregex-cflags
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_short" >&5
+printf "%s\n" "$ac_cv_sizeof_short" >&6; }
 
 
-# Check whether --with-libregex-libs was given.
-if test ${with_libregex_libs+y}
+
+printf "%s\n" "#define SIZEOF_SHORT $ac_cv_sizeof_short" >>confdefs.h
+
+
+
+  # ------------
+  # AC_CHECK_LIB
+  # ------------
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pathfind in -lgen" >&5
+printf %s "checking for pathfind in -lgen... " >&6; }
+if test ${ac_cv_lib_gen_pathfind+y}
 then :
-  withval=$with_libregex_libs; libopts_cv_with_libregex_libs=${with_libregex_libs}
+  printf %s "(cached) " >&6
 else $as_nop
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether with-libregex-libs was specified" >&5
-printf %s "checking whether with-libregex-libs was specified... " >&6; }
-if test ${libopts_cv_with_libregex_libs+y}
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lgen  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+char pathfind ();
+int
+main (void)
+{
+return pathfind ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
 then :
-  printf %s "(cached) " >&6
+  ac_cv_lib_gen_pathfind=yes
 else $as_nop
-  libopts_cv_with_libregex_libs=no
+  ac_cv_lib_gen_pathfind=no
 fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libopts_cv_with_libregex_libs" >&5
-printf "%s\n" "$libopts_cv_with_libregex_libs" >&6; }
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gen_pathfind" >&5
+printf "%s\n" "$ac_cv_lib_gen_pathfind" >&6; }
+if test "x$ac_cv_lib_gen_pathfind" = xyes
+then :
+  printf "%s\n" "#define HAVE_LIBGEN 1" >>confdefs.h
+
+  LIBS="-lgen $LIBS"
 
 fi
- # end of AC_ARG_WITH libregex-libs
 
-  case "X${libopts_cv_with_libregex_cflags}" in
-  Xyes|Xno|X )
-    case "X${libopts_cv_with_libregex_root}" in
-    Xyes|Xno|X ) libopts_cv_with_libregex_cflags=no ;;
-    * ) libopts_cv_with_libregex_cflags=-I${libopts_cv_with_libregex_root}/include ;;
-    esac
-  esac
-  case "X${libopts_cv_with_libregex_libs}" in
-  Xyes|Xno|X )
-    case "X${libopts_cv_with_libregex_root}" in
-    Xyes|Xno|X ) libopts_cv_with_libregex_libs=no ;;
-    * )        libopts_cv_with_libregex_libs="-L${libopts_cv_with_libregex_root}/lib -lregex" ;;
-    esac
-  esac
-  libopts_save_CPPFLAGS="${CPPFLAGS}"
-  libopts_save_LIBS="${LIBS}"
-  case "X${libopts_cv_with_libregex_cflags}" in
-  Xyes|Xno|X )
-    libopts_cv_with_libregex_cflags="" ;;
-  * ) CPPFLAGS="${CPPFLAGS} ${libopts_cv_with_libregex_cflags}" ;;
-  esac
-  case "X${libopts_cv_with_libregex_libs}" in
-  Xyes|Xno|X )
-    libopts_cv_with_libregex_libs="" ;;
-  * )
-    LIBS="${LIBS} ${libopts_cv_with_libregex_libs}" ;;
-  esac
-  LIBREGEX_CFLAGS=""
-  LIBREGEX_LIBS=""
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether libregex functions properly" >&5
-printf %s "checking whether libregex functions properly... " >&6; }
-  if test ${libopts_cv_with_libregex+y}
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gettext in -lintl" >&5
+printf %s "checking for gettext in -lintl... " >&6; }
+if test ${ac_cv_lib_intl_gettext+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-
-  if test "$cross_compiling" = yes
-then :
-  libopts_cv_with_libregex=no
-else $as_nop
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lintl  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include REGEX_HEADER
-static regex_t re;
-void comp_re(char const * pzPat) {
-  int res = regcomp( &re, pzPat, REG_EXTENDED|REG_ICASE|REG_NEWLINE );
-  if (res == 0) return;
-  exit( res ); }
-int main() {
-  regmatch_t m[2];
-  comp_re( "^.*\$"   );
-  comp_re( "()|no.*" );
-  comp_re( "."       );
-  if (regexec( &re, "X", 2, m, 0 ) != 0)  return 1;
-  if ((m[0].rm_so != 0) || (m[0].rm_eo != 1)) {
-    fputs( "error: regex -->.<-- did not match\n", stderr );
-    return 1;
-  }
-  return 0; }
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+char gettext ();
+int
+main (void)
+{
+return gettext ();
+  ;
+  return 0;
+}
 _ACEOF
-if ac_fn_c_try_run "$LINENO"
+if ac_fn_c_try_link "$LINENO"
 then :
-  libopts_cv_with_libregex=yes
+  ac_cv_lib_intl_gettext=yes
 else $as_nop
-  libopts_cv_with_libregex=no
+  ac_cv_lib_intl_gettext=no
 fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
 fi
- # end of AC_RUN_IFELSE
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_intl_gettext" >&5
+printf "%s\n" "$ac_cv_lib_intl_gettext" >&6; }
+if test "x$ac_cv_lib_intl_gettext" = xyes
+then :
+  printf "%s\n" "#define HAVE_LIBINTL 1" >>confdefs.h
+
+  LIBS="-lintl $LIBS"
 
 fi
- # end of AC_CACHE_VAL for libopts_cv_with_libregex
-  fi ## disabled by request
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_with_libregex}" >&5
-printf "%s\n" "${libopts_cv_with_libregex}" >&6; }
-  if test "X${libopts_cv_with_libregex}" != Xno
-  then
 
-printf "%s\n" "#define WITH_LIBREGEX 1" >>confdefs.h
 
-  else
-    CPPFLAGS="${libopts_save_CPPFLAGS}"
-    LIBS="${libopts_save_LIBS}"
-    libopts_cv_with_libregex_root=no
-libopts_cv_with_libregex_cflags=no
-libopts_cv_with_libregex_libs=no
-libopts_cv_with_libregex=no
-  fi
+if test "x$ac_cv_func_vprintf" = xno
+then :
+  ac_fn_c_check_func "$LINENO" "_doprnt" "ac_cv_func__doprnt"
+if test "x$ac_cv_func__doprnt" = xyes
+then :
 
+printf "%s\n" "#define HAVE_DOPRNT 1" >>confdefs.h
 
+fi
 
-  # Check to see if pathfind(3) works.
+fi
 
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether pathfind(3) works" >&5
-printf %s "checking whether pathfind(3) works... " >&6; }
-  if test ${libopts_cv_run_pathfind+y}
+
+if test "x$ac_cv_func_fork" = xyes; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for working fork" >&5
+printf %s "checking for working fork... " >&6; }
+if test ${ac_cv_func_fork_works+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-
   if test "$cross_compiling" = yes
 then :
-  libopts_cv_run_pathfind=no
-
+  ac_cv_func_fork_works=cross
 else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-#include <string.h>
-#include <stdlib.h>
-int main (int argc, char ** argv) {
-   char * pz = pathfind( getenv( "PATH" ), "sh", "x" );
-   return (pz == 0) ? 1 : 0;
+$ac_includes_default
+int
+main (void)
+{
+
+	  /* By Ruediger Kuhlmann. */
+	  return fork () < 0;
+
+  ;
+  return 0;
 }
 _ACEOF
 if ac_fn_c_try_run "$LINENO"
 then :
-  libopts_cv_run_pathfind=yes
+  ac_cv_func_fork_works=yes
 else $as_nop
-  libopts_cv_run_pathfind=no
+  ac_cv_func_fork_works=no
 fi
 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
   conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
- # end of RUN_IFELSE
 
 fi
- # end of AC_CACHE_VAL for libopts_cv_run_pathfind
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_run_pathfind}" >&5
-printf "%s\n" "${libopts_cv_run_pathfind}" >&6; }
-  if test "X${libopts_cv_run_pathfind}" != Xno
-  then
-
-printf "%s\n" "#define HAVE_PATHFIND 1" >>confdefs.h
-
-  fi
-
-
-
-  # Check to see if /dev/zero is readable device.
-
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether /dev/zero is readable device" >&5
-printf %s "checking whether /dev/zero is readable device... " >&6; }
-  if test ${libopts_cv_test_dev_zero+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-
-    libopts_cv_test_dev_zero=`exec 2> /dev/null
-dzero=\`ls -lL /dev/zero | egrep ^c......r\`
-test -z "${dzero}" && exit 1
-echo ${dzero}`
-    if test $? -ne 0 || test -z "$libopts_cv_test_dev_zero"
-    then libopts_cv_test_dev_zero=no
-    fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_fork_works" >&5
+printf "%s\n" "$ac_cv_func_fork_works" >&6; }
 
+else
+  ac_cv_func_fork_works=$ac_cv_func_fork
 fi
- # end of CACHE_VAL of libopts_cv_test_dev_zero
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_test_dev_zero}" >&5
-printf "%s\n" "${libopts_cv_test_dev_zero}" >&6; }
-  if test "X${libopts_cv_test_dev_zero}" != Xno
-  then
-
-printf "%s\n" "#define HAVE_DEV_ZERO 1" >>confdefs.h
-
-  fi
-
-
-
-  # Check to see if we have a functional realpath(3C).
-
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we have a functional realpath(3C)" >&5
-printf %s "checking whether we have a functional realpath(3C)... " >&6; }
-  if test ${libopts_cv_run_realpath+y}
+if test "x$ac_cv_func_fork_works" = xcross; then
+  case $host in
+    *-*-amigaos* | *-*-msdosdjgpp*)
+      # Override, as these systems have only a dummy fork() stub
+      ac_cv_func_fork_works=no
+      ;;
+    *)
+      ac_cv_func_fork_works=yes
+      ;;
+  esac
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&5
+printf "%s\n" "$as_me: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&2;}
+fi
+ac_cv_func_vfork_works=$ac_cv_func_vfork
+if test "x$ac_cv_func_vfork" = xyes; then
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for working vfork" >&5
+printf %s "checking for working vfork... " >&6; }
+if test ${ac_cv_func_vfork_works+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-
   if test "$cross_compiling" = yes
 then :
-  libopts_cv_run_realpath=no
-
+  ac_cv_func_vfork_works=cross
 else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-#include <limits.h>
-#include <stdlib.h>
-int main (int argc, char ** argv) {
-#ifndef PATH_MAX
-choke me!!
-#else
-   char zPath[PATH_MAX+1];
+/* Thanks to Paul Eggert for this test.  */
+$ac_includes_default
+#include <signal.h>
+#include <sys/wait.h>
+#ifdef HAVE_VFORK_H
+# include <vfork.h>
 #endif
-   char *pz = realpath(argv[0], zPath);
-   return (pz == zPath) ? 0 : 1;
+
+static void
+do_nothing (int sig)
+{
+  (void) sig;
 }
-_ACEOF
-if ac_fn_c_try_run "$LINENO"
-then :
-  libopts_cv_run_realpath=yes
-else $as_nop
-  libopts_cv_run_realpath=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
- # end of RUN_IFELSE
 
-fi
- # end of AC_CACHE_VAL for libopts_cv_run_realpath
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_run_realpath}" >&5
-printf "%s\n" "${libopts_cv_run_realpath}" >&6; }
-  if test "X${libopts_cv_run_realpath}" != Xno
-  then
+/* On some sparc systems, changes by the child to local and incoming
+   argument registers are propagated back to the parent.  The compiler
+   is told about this with #include <vfork.h>, but some compilers
+   (e.g. gcc -O) don't grok <vfork.h>.  Test for this by using a
+   static variable whose address is put into a register that is
+   clobbered by the vfork.  */
+static void
+sparc_address_test (int arg)
+{
+  static pid_t child;
+  if (!child) {
+    child = vfork ();
+    if (child < 0) {
+      perror ("vfork");
+      _exit(2);
+    }
+    if (!child) {
+      arg = getpid();
+      write(-1, "", 0);
+      _exit (arg);
+    }
+  }
+}
 
-printf "%s\n" "#define HAVE_REALPATH 1" >>confdefs.h
+int
+main (void)
+{
+  pid_t parent = getpid ();
+  pid_t child;
 
-  fi
+  sparc_address_test (0);
 
+  /* On Solaris 2.4, changes by the child to the signal handler
+     also munge signal handlers in the parent.  To detect this,
+     start by putting the parent's handler in a known state.  */
+  signal (SIGTERM, SIG_DFL);
 
+  child = vfork ();
 
-  # Check to see if strftime() works.
+  if (child == 0) {
+    /* Here is another test for sparc vfork register problems.  This
+       test uses lots of local variables, at least as many local
+       variables as main has allocated so far including compiler
+       temporaries.  4 locals are enough for gcc 1.40.3 on a Solaris
+       4.1.3 sparc, but we use 8 to be safe.  A buggy compiler should
+       reuse the register of parent for one of the local variables,
+       since it will think that parent can't possibly be used any more
+       in this routine.  Assigning to the local variable will thus
+       munge parent in the parent process.  */
+    pid_t
+      p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(),
+      p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid();
+    /* Convince the compiler that p..p7 are live; otherwise, it might
+       use the same hardware register for all 8 local variables.  */
+    if (p != p1 || p != p2 || p != p3 || p != p4
+	|| p != p5 || p != p6 || p != p7)
+      _exit(1);
 
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether strftime() works" >&5
-printf %s "checking whether strftime() works... " >&6; }
-  if test ${libopts_cv_run_strftime+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
+    /* Alter the child's signal handler.  */
+    if (signal (SIGTERM, do_nothing) != SIG_DFL)
+      _exit(1);
+
+    /* On some systems (e.g. IRIX 3.3), vfork doesn't separate parent
+       from child file descriptors.  If the child closes a descriptor
+       before it execs or exits, this munges the parent's descriptor
+       as well.  Test for this by closing stdout in the child.  */
+    _exit(close(fileno(stdout)) != 0);
+  } else {
+    int status;
+    struct stat st;
+
+    while (wait(&status) != child)
+      ;
+    return (
+	 /* Was there some problem with vforking?  */
+	 child < 0
+
+	 /* Did the child munge the parent's signal handler?  */
+	 || signal (SIGTERM, SIG_DFL) != SIG_DFL
+
+	 /* Did the child fail?  (This shouldn't happen.)  */
+	 || status
 
-  if test "$cross_compiling" = yes
-then :
-  libopts_cv_run_strftime=no
+	 /* Did the vfork/compiler bug occur?  */
+	 || parent != getpid()
 
-else $as_nop
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <time.h>
-#include <string.h>
-char t_buf[ 64 ];
-int main() {
-  static char const z[] = "Thursday Aug 28 240";
-  struct tm tm;
-  tm.tm_sec   = 36;  /* seconds after the minute [0, 61]  */
-  tm.tm_min   = 44;  /* minutes after the hour [0, 59] */
-  tm.tm_hour  = 12;  /* hour since midnight [0, 23] */
-  tm.tm_mday  = 28;  /* day of the month [1, 31] */
-  tm.tm_mon   =  7;  /* months since January [0, 11] */
-  tm.tm_year  = 86;  /* years since 1900 */
-  tm.tm_wday  =  4;  /* days since Sunday [0, 6] */
-  tm.tm_yday  = 239; /* days since January 1 [0, 365] */
-  tm.tm_isdst =  1;  /* flag for daylight savings time */
-  strftime( t_buf, sizeof( t_buf ), "%A %b %d %j", &tm );
-  return (strcmp( t_buf, z ) != 0); }
+	 /* Did the file descriptor bug occur?  */
+	 || fstat(fileno(stdout), &st) != 0
+	 );
+  }
+}
 _ACEOF
 if ac_fn_c_try_run "$LINENO"
 then :
-  libopts_cv_run_strftime=yes
+  ac_cv_func_vfork_works=yes
 else $as_nop
-  libopts_cv_run_strftime=no
+  ac_cv_func_vfork_works=no
 fi
 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
   conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
- # end of RUN_IFELSE
 
 fi
- # end of AC_CACHE_VAL for libopts_cv_run_strftime
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_run_strftime}" >&5
-printf "%s\n" "${libopts_cv_run_strftime}" >&6; }
-  if test "X${libopts_cv_run_strftime}" != Xno
-  then
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_vfork_works" >&5
+printf "%s\n" "$ac_cv_func_vfork_works" >&6; }
 
-printf "%s\n" "#define HAVE_STRFTIME 1" >>confdefs.h
+fi;
+if test "x$ac_cv_func_fork_works" = xcross; then
+  ac_cv_func_vfork_works=$ac_cv_func_vfork
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&5
+printf "%s\n" "$as_me: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&2;}
+fi
 
-  fi
+if test "x$ac_cv_func_vfork_works" = xyes; then
 
+printf "%s\n" "#define HAVE_WORKING_VFORK 1" >>confdefs.h
 
+else
 
-  # Check to see if fopen accepts "b" mode.
+printf "%s\n" "#define vfork fork" >>confdefs.h
 
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether fopen accepts \"b\" mode" >&5
-printf %s "checking whether fopen accepts \"b\" mode... " >&6; }
-  if test ${libopts_cv_run_fopen_binary+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
+fi
+if test "x$ac_cv_func_fork_works" = xyes; then
 
-  if test "$cross_compiling" = yes
-then :
-  libopts_cv_run_fopen_binary=no
+printf "%s\n" "#define HAVE_WORKING_FORK 1" >>confdefs.h
 
-else $as_nop
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdio.h>
-int main (int argc, char ** argv) {
-FILE * fp = fopen("conftest.$ac_ext", "rb");
-return (fp == NULL) ? 1 : fclose(fp); }
-_ACEOF
-if ac_fn_c_try_run "$LINENO"
+fi
+
+  ac_fn_c_check_func "$LINENO" "mmap" "ac_cv_func_mmap"
+if test "x$ac_cv_func_mmap" = xyes
 then :
-  libopts_cv_run_fopen_binary=yes
-else $as_nop
-  libopts_cv_run_fopen_binary=no
+  printf "%s\n" "#define HAVE_MMAP 1" >>confdefs.h
+
 fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
+ac_fn_c_check_func "$LINENO" "canonicalize_file_name" "ac_cv_func_canonicalize_file_name"
+if test "x$ac_cv_func_canonicalize_file_name" = xyes
+then :
+  printf "%s\n" "#define HAVE_CANONICALIZE_FILE_NAME 1" >>confdefs.h
+
 fi
- # end of RUN_IFELSE
+ac_fn_c_check_func "$LINENO" "snprintf" "ac_cv_func_snprintf"
+if test "x$ac_cv_func_snprintf" = xyes
+then :
+  printf "%s\n" "#define HAVE_SNPRINTF 1" >>confdefs.h
 
 fi
- # end of AC_CACHE_VAL for libopts_cv_run_fopen_binary
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_run_fopen_binary}" >&5
-printf "%s\n" "${libopts_cv_run_fopen_binary}" >&6; }
-  if test "X${libopts_cv_run_fopen_binary}" != Xno
-  then
+ac_fn_c_check_func "$LINENO" "strdup" "ac_cv_func_strdup"
+if test "x$ac_cv_func_strdup" = xyes
+then :
+  printf "%s\n" "#define HAVE_STRDUP 1" >>confdefs.h
 
-printf "%s\n" "#define FOPEN_BINARY_FLAG \"b\"" >>confdefs.h
+fi
+ac_fn_c_check_func "$LINENO" "strchr" "ac_cv_func_strchr"
+if test "x$ac_cv_func_strchr" = xyes
+then :
+  printf "%s\n" "#define HAVE_STRCHR 1" >>confdefs.h
 
-  else
+fi
+ac_fn_c_check_func "$LINENO" "strrchr" "ac_cv_func_strrchr"
+if test "x$ac_cv_func_strrchr" = xyes
+then :
+  printf "%s\n" "#define HAVE_STRRCHR 1" >>confdefs.h
 
-printf "%s\n" "#define FOPEN_BINARY_FLAG \"\"" >>confdefs.h
+fi
+ac_fn_c_check_func "$LINENO" "strsignal" "ac_cv_func_strsignal"
+if test "x$ac_cv_func_strsignal" = xyes
+then :
+  printf "%s\n" "#define HAVE_STRSIGNAL 1" >>confdefs.h
 
-  fi
+fi
+ac_fn_c_check_func "$LINENO" "fchmod" "ac_cv_func_fchmod"
+if test "x$ac_cv_func_fchmod" = xyes
+then :
+  printf "%s\n" "#define HAVE_FCHMOD 1" >>confdefs.h
 
+fi
+ac_fn_c_check_func "$LINENO" "fstat" "ac_cv_func_fstat"
+if test "x$ac_cv_func_fstat" = xyes
+then :
+  printf "%s\n" "#define HAVE_FSTAT 1" >>confdefs.h
 
+fi
+ac_fn_c_check_func "$LINENO" "chmod" "ac_cv_func_chmod"
+if test "x$ac_cv_func_chmod" = xyes
+then :
+  printf "%s\n" "#define HAVE_CHMOD 1" >>confdefs.h
 
-  # Check to see if fopen accepts "t" mode.
+fi
 
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether fopen accepts \"t\" mode" >&5
-printf %s "checking whether fopen accepts \"t\" mode... " >&6; }
-  if test ${libopts_cv_run_fopen_text+y}
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5
+printf %s "checking for a sed that does not truncate output... " >&6; }
+if test ${ac_cv_path_SED+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
+            ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
+     for ac_i in 1 2 3 4 5 6 7; do
+       ac_script="$ac_script$as_nl$ac_script"
+     done
+     echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed
+     { ac_script=; unset ac_script;}
+     if test -z "$SED"; then
+  ac_path_SED_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_prog in sed gsed
+   do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_SED="$as_dir$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_SED" || continue
+# Check for GNU ac_path_SED and select it if it is found.
+  # Check for GNU $ac_path_SED
+case `"$ac_path_SED" --version 2>&1` in
+*GNU*)
+  ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;;
+*)
+  ac_count=0
+  printf %s 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    printf "%s\n" '' >> "conftest.nl"
+    "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_SED_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_SED="$ac_path_SED"
+      ac_path_SED_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
 
-  if test "$cross_compiling" = yes
-then :
-  libopts_cv_run_fopen_text=no
-
-else $as_nop
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdio.h>
-int main (int argc, char ** argv) {
-FILE * fp = fopen("conftest.$ac_ext", "rt");
-return (fp == NULL) ? 1 : fclose(fp); }
-_ACEOF
-if ac_fn_c_try_run "$LINENO"
-then :
-  libopts_cv_run_fopen_text=yes
-else $as_nop
-  libopts_cv_run_fopen_text=no
+      $ac_path_SED_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_SED"; then
+    as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5
+  fi
+else
+  ac_cv_path_SED=$SED
 fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
+
 fi
- # end of RUN_IFELSE
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5
+printf "%s\n" "$ac_cv_path_SED" >&6; }
+ SED="$ac_cv_path_SED"
+  rm -f conftest.sed
+
+  while :
+  do
+      test -x "$POSIX_SHELL" && break
+      POSIX_SHELL=`which bash`
+      test -x "$POSIX_SHELL" && break
+      POSIX_SHELL=`which dash`
+      test -x "$POSIX_SHELL" && break
+      POSIX_SHELL=/usr/xpg4/bin/sh
+      test -x "$POSIX_SHELL" && break
+      POSIX_SHELL=`/bin/sh -c '
+          exec 2>/dev/null
+          if ! true ; then exit 1 ; fi
+          echo /bin/sh'`
+      test -x "$POSIX_SHELL" && break
+      as_fn_error $? "cannot locate a working POSIX shell" "$LINENO" 5
+  done
+
+printf "%s\n" "#define POSIX_SHELL \"${POSIX_SHELL}\"" >>confdefs.h
+
+
 
-fi
- # end of AC_CACHE_VAL for libopts_cv_run_fopen_text
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_run_fopen_text}" >&5
-printf "%s\n" "${libopts_cv_run_fopen_text}" >&6; }
-  if test "X${libopts_cv_run_fopen_text}" != Xno
-  then
 
-printf "%s\n" "#define FOPEN_TEXT_FLAG \"t\"" >>confdefs.h
 
-  else
+  LIBOPTS_BUILD_BLOCKED=''
 
-printf "%s\n" "#define FOPEN_TEXT_FLAG \"\"" >>confdefs.h
 
-  fi
+  NEED_LIBOPTS_DIR=''
 
+  # Check whether --enable-local-libopts was given.
+if test ${enable_local_libopts+y}
+then :
+  enableval=$enable_local_libopts;
+    if test x$enableval = xyes ; then
+       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Using supplied libopts tearoff" >&5
+printf "%s\n" "$as_me: Using supplied libopts tearoff" >&6;}
+       LIBOPTS_CFLAGS='-I$(top_srcdir)/libopts'
+       NEED_LIBOPTS_DIR=true
+       LIBOPTS_LDADD='$(top_builddir)/libopts/libopts.la'
+    fi
+fi
 
 
-  # Check to see if not wanting optional option args.
+  # Check whether --enable-libopts-install was given.
+if test ${enable_libopts_install+y}
+then :
+  enableval=$enable_libopts_install;
+fi
 
-  # Check whether --enable-optional-args was given.
-if test ${enable_optional_args+y}
+   if test "X${enable_libopts_install}" = Xyes; then
+  INSTALL_LIBOPTS_TRUE=
+  INSTALL_LIBOPTS_FALSE='#'
+else
+  INSTALL_LIBOPTS_TRUE='#'
+  INSTALL_LIBOPTS_FALSE=
+fi
+
+
+  if test -z "${NEED_LIBOPTS_DIR}" ; then
+     { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether autoopts-config can be found" >&5
+printf %s "checking whether autoopts-config can be found... " >&6; }
+
+# Check whether --with-autoopts-config was given.
+if test ${with_autoopts_config+y}
 then :
-  enableval=$enable_optional_args; libopts_cv_enable_optional_args=${enable_optional_args}
+  withval=$with_autoopts_config; lo_cv_with_autoopts_config=${with_autoopts_config}
 else $as_nop
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether not wanting optional option args" >&5
-printf %s "checking whether not wanting optional option args... " >&6; }
-if test ${libopts_cv_enable_optional_args+y}
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether autoopts-config is specified" >&5
+printf %s "checking whether autoopts-config is specified... " >&6; }
+if test ${lo_cv_with_autoopts_config+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  libopts_cv_enable_optional_args=yes
+  if autoopts-config --help 2>/dev/null 1>&2
+        then lo_cv_with_autoopts_config=autoopts-config
+        elif libopts-config --help 2>/dev/null 1>&2
+        then lo_cv_with_autoopts_config=libopts-config
+        else lo_cv_with_autoopts_config=no ; fi
 fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libopts_cv_enable_optional_args" >&5
-printf "%s\n" "$libopts_cv_enable_optional_args" >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lo_cv_with_autoopts_config" >&5
+printf "%s\n" "$lo_cv_with_autoopts_config" >&6; }
 
 fi
- # end of AC_ARG_ENABLE
-  if test "X${libopts_cv_enable_optional_args}" = Xno
-  then
+ # end of AC_ARG_WITH
 
-printf "%s\n" "#define NO_OPTIONAL_OPT_ARGS 1" >>confdefs.h
+     if test ${lo_cv_test_autoopts+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
 
-  fi
+        if test -z "${lo_cv_with_autoopts_config}" \
+                -o X"${lo_cv_with_autoopts_config}" = Xno
+        then
+           if autoopts-config --help 2>/dev/null 1>&2
+           then lo_cv_with_autoopts_config=autoopts-config
+           elif libopts-config --help 2>/dev/null 1>&2
+           then lo_cv_with_autoopts_config=libopts-config
+           else lo_cv_with_autoopts_config=false ; fi
+        fi
+        lo_cv_test_autoopts=`
+            ${lo_cv_with_autoopts_config} --libs` 2> /dev/null
+        if test $? -ne 0 -o -z "${lo_cv_test_autoopts}"
+        then lo_cv_test_autoopts=no ; fi
 
+fi
+ # end of CACHE_VAL
+     { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${lo_cv_test_autoopts}" >&5
+printf "%s\n" "${lo_cv_test_autoopts}" >&6; }
 
+     if test "X${lo_cv_test_autoopts}" != Xno
+     then
+        LIBOPTS_LDADD="${lo_cv_test_autoopts}"
+        LIBOPTS_CFLAGS="`${lo_cv_with_autoopts_config} --cflags`"
+     else
+        LIBOPTS_LDADD='$(top_builddir)/libopts/libopts.la'
+        LIBOPTS_CFLAGS='-I$(top_srcdir)/libopts'
+        NEED_LIBOPTS_DIR=true
+     fi
+  fi # end of if test -z "${NEED_LIBOPTS_DIR}"
+  if test -n "${LIBOPTS_BUILD_BLOCKED}" ; then
+    NEED_LIBOPTS_DIR=''
+  fi
+   if test -n "${NEED_LIBOPTS_DIR}"; then
+  NEED_LIBOPTS_TRUE=
+  NEED_LIBOPTS_FALSE='#'
+else
+  NEED_LIBOPTS_TRUE='#'
+  NEED_LIBOPTS_FALSE=
+fi
 
 
 
-          fi
-  ac_config_files="$ac_config_files libopts/Makefile"
+  LIBOPTS_DIR=libopts
 
-  # end of AC_DEFUN of LIBOPTS_CHECK
 
+# end of AC_DEFUN of LIBOPTS_CHECK_COMMON
 
-# From when we only used libevent for sntp:
-#AM_COND_IF(
-#    [BUILD_SNTP],
-#    [NTP_LIBEVENT_CHECK],
-#    [NTP_LIBEVENT_CHECK_NOBUILD]
-#)
 
+    if test -z "$NEED_LIBOPTS_TRUE"; then :
 
 
-ntp_pkgconfig_min_version='0.15.0'
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
-set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-printf %s "checking for $ac_word... " >&6; }
-if test ${ac_cv_path_PKG_CONFIG+y}
-then :
-  printf %s "(cached) " >&6
-else $as_nop
-  case $PKG_CONFIG in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  case $as_dir in #(((
-    '') as_dir=./ ;;
-    */) ;;
-    *) as_dir=$as_dir/ ;;
-  esac
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
-    ac_cv_path_PKG_CONFIG="$as_dir$ac_word$ac_exec_ext"
-    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
 
-  ;;
-esac
-fi
-PKG_CONFIG=$ac_cv_path_PKG_CONFIG
-if test -n "$PKG_CONFIG"; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
-printf "%s\n" "$PKG_CONFIG" >&6; }
-else
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
-printf "%s\n" "no" >&6; }
-fi
+  # Check to see if a reg expr header is specified.
 
 
-fi
-if test -z "$ac_cv_path_PKG_CONFIG"; then
-  ac_pt_PKG_CONFIG=$PKG_CONFIG
-  # Extract the first word of "pkg-config", so it can be a program name with args.
-set dummy pkg-config; ac_word=$2
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-printf %s "checking for $ac_word... " >&6; }
-if test ${ac_cv_path_ac_pt_PKG_CONFIG+y}
+# Check whether --with-regex-header was given.
+if test ${with_regex_header+y}
+then :
+  withval=$with_regex_header; libopts_cv_with_regex_header=${with_regex_header}
+else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether a reg expr header is specified" >&5
+printf %s "checking whether a reg expr header is specified... " >&6; }
+if test ${libopts_cv_with_regex_header+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  case $ac_pt_PKG_CONFIG in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  case $as_dir in #(((
-    '') as_dir=./ ;;
-    */) ;;
-    *) as_dir=$as_dir/ ;;
-  esac
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
-    ac_cv_path_ac_pt_PKG_CONFIG="$as_dir$ac_word$ac_exec_ext"
-    printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
-if test -n "$ac_pt_PKG_CONFIG"; then
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
-printf "%s\n" "$ac_pt_PKG_CONFIG" >&6; }
-else
-  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
-printf "%s\n" "no" >&6; }
+  libopts_cv_with_regex_header=no
 fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libopts_cv_with_regex_header" >&5
+printf "%s\n" "$libopts_cv_with_regex_header" >&6; }
 
-  if test "x$ac_pt_PKG_CONFIG" = x; then
-    PKG_CONFIG=""
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    PKG_CONFIG=$ac_pt_PKG_CONFIG
-  fi
-else
-  PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
 fi
+ # end of AC_ARG_WITH
+  if test "X${libopts_cv_with_regex_header}" != Xno
+  then
+    printf "%s\n" "#define REGEX_HEADER <${libopts_cv_with_regex_header}>" >>confdefs.h
 
-{ ac_cv_path_PKG_CONFIG=; unset ac_cv_path_PKG_CONFIG;}
-{ ac_cv_path_ac_pt_PKG_CONFIG=; unset ac_cv_path_ac_pt_PKG_CONFIG;}
+  else
 
-case "$PKG_CONFIG" in
- /*)
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if pkg-config is at least version $ntp_pkgconfig_min_version" >&5
-printf %s "checking if pkg-config is at least version $ntp_pkgconfig_min_version... " >&6; }
-    if $PKG_CONFIG --atleast-pkgconfig-version $ntp_pkgconfig_min_version; then
-	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-printf "%s\n" "yes" >&6; }
-    else
-	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
-printf "%s\n" "no" >&6; }
-	PKG_CONFIG=""
-    fi
-    ;;
-esac
+printf "%s\n" "#define REGEX_HEADER <regex.h>" >>confdefs.h
 
+  fi
 
 
 
-# Check whether --enable-local-libevent was given.
-if test ${enable_local_libevent+y}
+  # Check to see if a working libregex can be found.
+
+
+# Check whether --with-libregex was given.
+if test ${with_libregex+y}
 then :
-  enableval=$enable_local_libevent; ntp_use_local_libevent=$enableval
+  withval=$with_libregex; libopts_cv_with_libregex_root=${with_libregex}
 else $as_nop
-  ntp_use_local_libevent=${ntp_use_local_libevent-detect}
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether with-libregex was specified" >&5
+printf %s "checking whether with-libregex was specified... " >&6; }
+if test ${libopts_cv_with_libregex_root+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  libopts_cv_with_libregex_root=no
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libopts_cv_with_libregex_root" >&5
+printf "%s\n" "$libopts_cv_with_libregex_root" >&6; }
 
 fi
+ # end of AC_ARG_WITH libregex
+
+  if test "${with_libregex+set}" = set && \
+     test "X${withval}" = Xno
+  then ## disabled by request
+    libopts_cv_with_libregex_root=no
+    libopts_cv_with_libregex_cflags=no
+    libopts_cv_with_libregex_libs=no
+  else
 
 
+# Check whether --with-libregex-cflags was given.
+if test ${with_libregex_cflags+y}
+then :
+  withval=$with_libregex_cflags; libopts_cv_with_libregex_cflags=${with_libregex_cflags}
+else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether with-libregex-cflags was specified" >&5
+printf %s "checking whether with-libregex-cflags was specified... " >&6; }
+if test ${libopts_cv_with_libregex_cflags+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  libopts_cv_with_libregex_cflags=no
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libopts_cv_with_libregex_cflags" >&5
+printf "%s\n" "$libopts_cv_with_libregex_cflags" >&6; }
 
+fi
+ # end of AC_ARG_WITH libregex-cflags
 
 
+# Check whether --with-libregex-libs was given.
+if test ${with_libregex_libs+y}
+then :
+  withval=$with_libregex_libs; libopts_cv_with_libregex_libs=${with_libregex_libs}
+else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether with-libregex-libs was specified" >&5
+printf %s "checking whether with-libregex-libs was specified... " >&6; }
+if test ${libopts_cv_with_libregex_libs+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  libopts_cv_with_libregex_libs=no
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libopts_cv_with_libregex_libs" >&5
+printf "%s\n" "$libopts_cv_with_libregex_libs" >&6; }
 
+fi
+ # end of AC_ARG_WITH libregex-libs
 
+  case "X${libopts_cv_with_libregex_cflags}" in
+  Xyes|Xno|X )
+    case "X${libopts_cv_with_libregex_root}" in
+    Xyes|Xno|X ) libopts_cv_with_libregex_cflags=no ;;
+    * ) libopts_cv_with_libregex_cflags=-I${libopts_cv_with_libregex_root}/include ;;
+    esac
+  esac
+  case "X${libopts_cv_with_libregex_libs}" in
+  Xyes|Xno|X )
+    case "X${libopts_cv_with_libregex_root}" in
+    Xyes|Xno|X ) libopts_cv_with_libregex_libs=no ;;
+    * )        libopts_cv_with_libregex_libs="-L${libopts_cv_with_libregex_root}/lib -lregex" ;;
+    esac
+  esac
+  libopts_save_CPPFLAGS="${CPPFLAGS}"
+  libopts_save_LIBS="${LIBS}"
+  case "X${libopts_cv_with_libregex_cflags}" in
+  Xyes|Xno|X )
+    libopts_cv_with_libregex_cflags="" ;;
+  * ) CPPFLAGS="${CPPFLAGS} ${libopts_cv_with_libregex_cflags}" ;;
+  esac
+  case "X${libopts_cv_with_libregex_libs}" in
+  Xyes|Xno|X )
+    libopts_cv_with_libregex_libs="" ;;
+  * )
+    LIBS="${LIBS} ${libopts_cv_with_libregex_libs}" ;;
+  esac
+  LIBREGEX_CFLAGS=""
+  LIBREGEX_LIBS=""
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether libregex functions properly" >&5
+printf %s "checking whether libregex functions properly... " >&6; }
+  if test ${libopts_cv_with_libregex+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
 
+  if test "$cross_compiling" = yes
+then :
+  libopts_cv_with_libregex=no
+else $as_nop
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include REGEX_HEADER
+static regex_t re;
+void comp_re(char const * pzPat) {
+  int res = regcomp( &re, pzPat, REG_EXTENDED|REG_ICASE|REG_NEWLINE );
+  if (res == 0) return;
+  exit( res ); }
+int main() {
+  regmatch_t m[2];
+  comp_re( "^.*\$"   );
+  comp_re( "()|no.*" );
+  comp_re( "."       );
+  if (regexec( &re, "X", 2, m, 0 ) != 0)  return 1;
+  if ((m[0].rm_so != 0) || (m[0].rm_eo != 1)) {
+    fputs( "error: regex -->.<-- did not match\n", stderr );
+    return 1;
+  }
+  return 0; }
+_ACEOF
+if ac_fn_c_try_run "$LINENO"
+then :
+  libopts_cv_with_libregex=yes
+else $as_nop
+  libopts_cv_with_libregex=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+ # end of AC_RUN_IFELSE
 
+fi
+ # end of AC_CACHE_VAL for libopts_cv_with_libregex
+  fi ## disabled by request
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_with_libregex}" >&5
+printf "%s\n" "${libopts_cv_with_libregex}" >&6; }
+  if test "X${libopts_cv_with_libregex}" != Xno
+  then
 
-ntp_libevent_min_version=2
-ntp_libevent_tearoff=libevent
+printf "%s\n" "#define WITH_LIBREGEX 1" >>confdefs.h
 
+  else
+    CPPFLAGS="${libopts_save_CPPFLAGS}"
+    LIBS="${libopts_save_LIBS}"
+    libopts_cv_with_libregex_root=no
+libopts_cv_with_libregex_cflags=no
+libopts_cv_with_libregex_libs=no
+libopts_cv_with_libregex=no
+  fi
 
 
 
+  # Check to see if pathfind(3) works.
 
-case "$ntp_use_local_libevent" in
- yes)
-    ;;
- *) # If we have (a good enough) pkg-config, see if it can find libevent
-    case "$PKG_CONFIG" in
-     /*)
-	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if libevent $ntp_libevent_min_version or later is installed" >&5
-printf %s "checking if libevent $ntp_libevent_min_version or later is installed... " >&6; }
-	if $PKG_CONFIG --atleast-version=$ntp_libevent_min_version libevent
-	then
-	    ntp_use_local_libevent=no
-	    ntp_libevent_version="`$PKG_CONFIG --modversion libevent`"
-	    case "$ntp_libevent_version" in
-	     *.*) ;;
-	     *) ntp_libevent_version='(unknown)' ;;
-	    esac
-	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes, version $ntp_libevent_version" >&5
-printf "%s\n" "yes, version $ntp_libevent_version" >&6; }
-	    CFLAGS_LIBEVENT=`$PKG_CONFIG --cflags libevent_pthreads`
-	    CPPFLAGS_LIBEVENT=`$PKG_CONFIG --cflags-only-I libevent`
-	    # HMS: I hope the following is accurate.
-	    # We don't need -levent, we only need  -levent_core.
-	    # While we could grab only the -L stuff, there *might* be
-	    # other flags there we want.  Originally we just removed -levent
-	    # but then somebody decided to install -levent-2.0
-	    # LDADD_LIBEVENT=`$PKG_CONFIG --libs libevent | sed 's:-levent::'`
-	    # So now we dance...
-	    LDADD_LIBEVENT=
-	    for i in `$PKG_CONFIG --libs libevent` `$PKG_CONFIG --cflags-only-other libevent_pthreads`
-	    do
-		case "$i" in
-		 -D*) ;;
-		 -levent*) ;;
-		 *) case "$LDADD_LIBEVENT" in
-		     '') LDADD_LIBEVENT="$i" ;;
-		     *) LDADD_LIBEVENT="$LDADD_LIBEVENT $i" ;;
-		    esac
-		    ;;
-		esac
-	    done
-	    case "$LIBISC_PTHREADS_NOTHREADS" in
-	     pthreads)
-		LDADD_LIBEVENT="$LDADD_LIBEVENT -levent_pthreads"
-	    esac
-	    LDADD_LIBEVENT="$LDADD_LIBEVENT -levent_core"
-	else
-	    ntp_use_local_libevent=yes
-	    # HMS: do we only need to do this if LIBISC_PTHREADS_NOTHREADS
-	    # is "pthreads"?
-	    CFLAGS_LIBEVENT=`$PKG_CONFIG --cflags libevent_pthreads`
-	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
-printf "%s\n" "no" >&6; }
-	fi
-	;;
-     *)
-	ntp_use_local_libevent=yes
-	;;
-    esac
-    ;;
-esac
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether pathfind(3) works" >&5
+printf %s "checking whether pathfind(3) works... " >&6; }
+  if test ${libopts_cv_run_pathfind+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
 
-case "$ntp_use_local_libevent" in
- yes)
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Using libevent tearoff" >&5
-printf "%s\n" "$as_me: Using libevent tearoff" >&6;}
-    CPPFLAGS_LIBEVENT="-I\$(top_builddir)/$ntp_libevent_tearoff/include -I\$(top_srcdir)/$ntp_libevent_tearoff/include"
-    case "$LIBISC_PTHREADS_NOTHREADS" in
-     pthreads)
-	LDADD_LIBEVENT="\$(top_builddir)/$ntp_libevent_tearoff/libevent_pthreads.la \$(top_builddir)/$ntp_libevent_tearoff/libevent_core.la"
-	;;
-     *)
-	LDADD_LIBEVENT="\$(top_builddir)/$ntp_libevent_tearoff/libevent_core.la"
-    esac
-esac
+  if test "$cross_compiling" = yes
+then :
+  libopts_cv_run_pathfind=no
 
+else $as_nop
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <string.h>
+#include <stdlib.h>
+int main (int argc, char ** argv) {
+   char * pz = pathfind( getenv( "PATH" ), "sh", "x" );
+   return (pz == 0) ? 1 : 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"
+then :
+  libopts_cv_run_pathfind=yes
+else $as_nop
+  libopts_cv_run_pathfind=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+ # end of RUN_IFELSE
 
- if test "x$ntp_use_local_libevent" = "xyes"; then
-  BUILD_LIBEVENT_TRUE=
-  BUILD_LIBEVENT_FALSE='#'
-else
-  BUILD_LIBEVENT_TRUE='#'
-  BUILD_LIBEVENT_FALSE=
 fi
+ # end of AC_CACHE_VAL for libopts_cv_run_pathfind
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_run_pathfind}" >&5
+printf "%s\n" "${libopts_cv_run_pathfind}" >&6; }
+  if test "X${libopts_cv_run_pathfind}" != Xno
+  then
 
+printf "%s\n" "#define HAVE_PATHFIND 1" >>confdefs.h
 
+  fi
 
 
-case "$ntp_libevent_tearoff" in
- libevent)
-    ;;
- *)
-    as_fn_error $? "ntp_libevent.m4 dir must be libevent, not $ntp_libevent_tearoff" "$LINENO" 5
-    ;;
-esac
 
-case "$ntp_use_local_libevent" in
- yes)
-                        ac_configure_args=" --disable-openssl${ac_configure_args}"
-    ac_configure_args=" --disable-shared${ac_configure_args}"
-    ac_configure_args=" --disable-libevent-regress${ac_configure_args}"
-    ac_configure_args=" --disable-libevent-install${ac_configure_args}"
-    ac_configure_args=" --enable-silent-rules${ac_configure_args}"
-    ac_configure_args=" --enable-function-sections${ac_configure_args}"
-    ac_configure_args=" LEP_CFLAGS='${NTP_HARD_CFLAGS}'${ac_configure_args}"
-    ac_configure_args=" LEP_CPPFLAGS='${NTP_HARD_CPPFLAGS}'${ac_configure_args}"
-    ac_configure_args=" LEP_LDFLAGS='${NTP_HARD_LDFLAGS}'${ac_configure_args}"
-    subdirs="$subdirs libevent"
+  # Check to see if /dev/zero is readable device.
 
-    ;;
- *)
-    NTP_FORCE_LIBEVENT_DIST=libevent
-    ;;
-esac
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether /dev/zero is readable device" >&5
+printf %s "checking whether /dev/zero is readable device... " >&6; }
+  if test ${libopts_cv_test_dev_zero+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+
+    libopts_cv_test_dev_zero=`exec 2> /dev/null
+dzero=\`ls -lL /dev/zero | egrep ^c......r\`
+test -z "${dzero}" && exit 1
+echo ${dzero}`
+    if test $? -ne 0 || test -z "$libopts_cv_test_dev_zero"
+    then libopts_cv_test_dev_zero=no
+    fi
 
+fi
+ # end of CACHE_VAL of libopts_cv_test_dev_zero
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_test_dev_zero}" >&5
+printf "%s\n" "${libopts_cv_test_dev_zero}" >&6; }
+  if test "X${libopts_cv_test_dev_zero}" != Xno
+  then
 
+printf "%s\n" "#define HAVE_DEV_ZERO 1" >>confdefs.h
 
-# Checks for libraries.
+  fi
 
 
-LIB_SYSLOG=''
 
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing openlog" >&5
-printf %s "checking for library containing openlog... " >&6; }
-if test ${ac_cv_search_openlog+y}
+  # Check to see if we have a functional realpath(3C).
+
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we have a functional realpath(3C)" >&5
+printf %s "checking whether we have a functional realpath(3C)... " >&6; }
+  if test ${libopts_cv_run_realpath+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
 
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-char openlog ();
-int
-main (void)
-{
-return openlog ();
-  ;
-  return 0;
+  if test "$cross_compiling" = yes
+then :
+  libopts_cv_run_realpath=no
+
+else $as_nop
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <limits.h>
+#include <stdlib.h>
+int main (int argc, char ** argv) {
+#ifndef PATH_MAX
+choke me!!
+#else
+   char zPath[PATH_MAX+1];
+#endif
+   char *pz = realpath(argv[0], zPath);
+   return (pz == zPath) ? 0 : 1;
 }
 _ACEOF
-for ac_lib in '' gen syslog
-do
-  if test -z "$ac_lib"; then
-    ac_res="none required"
-  else
-    ac_res=-l$ac_lib
-    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
-  fi
-  if ac_fn_c_try_link "$LINENO"
+if ac_fn_c_try_run "$LINENO"
 then :
-  ac_cv_search_openlog=$ac_res
+  libopts_cv_run_realpath=yes
+else $as_nop
+  libopts_cv_run_realpath=no
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam \
-    conftest$ac_exeext
-  if test ${ac_cv_search_openlog+y}
-then :
-  break
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
-done
-if test ${ac_cv_search_openlog+y}
+ # end of RUN_IFELSE
+
+fi
+ # end of AC_CACHE_VAL for libopts_cv_run_realpath
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_run_realpath}" >&5
+printf "%s\n" "${libopts_cv_run_realpath}" >&6; }
+  if test "X${libopts_cv_run_realpath}" != Xno
+  then
+
+printf "%s\n" "#define HAVE_REALPATH 1" >>confdefs.h
+
+  fi
+
+
+
+  # Check to see if strftime() works.
+
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether strftime() works" >&5
+printf %s "checking whether strftime() works... " >&6; }
+  if test ${libopts_cv_run_strftime+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+
+  if test "$cross_compiling" = yes
 then :
+  libopts_cv_run_strftime=no
 
 else $as_nop
-  ac_cv_search_openlog=no
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <time.h>
+#include <string.h>
+char t_buf[ 64 ];
+int main() {
+  static char const z[] = "Thursday Aug 28 240";
+  struct tm tm;
+  tm.tm_sec   = 36;  /* seconds after the minute [0, 61]  */
+  tm.tm_min   = 44;  /* minutes after the hour [0, 59] */
+  tm.tm_hour  = 12;  /* hour since midnight [0, 23] */
+  tm.tm_mday  = 28;  /* day of the month [1, 31] */
+  tm.tm_mon   =  7;  /* months since January [0, 11] */
+  tm.tm_year  = 86;  /* years since 1900 */
+  tm.tm_wday  =  4;  /* days since Sunday [0, 6] */
+  tm.tm_yday  = 239; /* days since January 1 [0, 365] */
+  tm.tm_isdst =  1;  /* flag for daylight savings time */
+  strftime( t_buf, sizeof( t_buf ), "%A %b %d %j", &tm );
+  return (strcmp( t_buf, z ) != 0); }
+_ACEOF
+if ac_fn_c_try_run "$LINENO"
+then :
+  libopts_cv_run_strftime=yes
+else $as_nop
+  libopts_cv_run_strftime=no
 fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_openlog" >&5
-printf "%s\n" "$ac_cv_search_openlog" >&6; }
-ac_res=$ac_cv_search_openlog
-if test "$ac_res" != no
-then :
-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-  case "$ac_cv_search_openlog" in
- 'none required') ;;
- no) ;;
- *) LIB_SYSLOG="$ac_cv_search_openlog $LIB_SYSLOG" ;;
- esac
+ # end of RUN_IFELSE
 
 fi
+ # end of AC_CACHE_VAL for libopts_cv_run_strftime
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_run_strftime}" >&5
+printf "%s\n" "${libopts_cv_run_strftime}" >&6; }
+  if test "X${libopts_cv_run_strftime}" != Xno
+  then
 
+printf "%s\n" "#define HAVE_STRFTIME 1" >>confdefs.h
 
-# Checks for header files.
-ac_fn_c_check_header_compile "$LINENO" "netdb.h" "ac_cv_header_netdb_h" "$ac_includes_default"
-if test "x$ac_cv_header_netdb_h" = xyes
-then :
-  printf "%s\n" "#define HAVE_NETDB_H 1" >>confdefs.h
+  fi
 
-fi
-ac_fn_c_check_header_compile "$LINENO" "string.h" "ac_cv_header_string_h" "$ac_includes_default"
-if test "x$ac_cv_header_string_h" = xyes
+
+
+  # Check to see if fopen accepts "b" mode.
+
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether fopen accepts \"b\" mode" >&5
+printf %s "checking whether fopen accepts \"b\" mode... " >&6; }
+  if test ${libopts_cv_run_fopen_binary+y}
 then :
-  printf "%s\n" "#define HAVE_STRING_H 1" >>confdefs.h
+  printf %s "(cached) " >&6
+else $as_nop
 
-fi
-ac_fn_c_check_header_compile "$LINENO" "strings.h" "ac_cv_header_strings_h" "$ac_includes_default"
-if test "x$ac_cv_header_strings_h" = xyes
+  if test "$cross_compiling" = yes
 then :
-  printf "%s\n" "#define HAVE_STRINGS_H 1" >>confdefs.h
+  libopts_cv_run_fopen_binary=no
 
-fi
-ac_fn_c_check_header_compile "$LINENO" "syslog.h" "ac_cv_header_syslog_h" "$ac_includes_default"
-if test "x$ac_cv_header_syslog_h" = xyes
+else $as_nop
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdio.h>
+int main (int argc, char ** argv) {
+FILE * fp = fopen("conftest.$ac_ext", "rb");
+return (fp == NULL) ? 1 : fclose(fp); }
+_ACEOF
+if ac_fn_c_try_run "$LINENO"
 then :
-  printf "%s\n" "#define HAVE_SYSLOG_H 1" >>confdefs.h
+  libopts_cv_run_fopen_binary=yes
+else $as_nop
+  libopts_cv_run_fopen_binary=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+ # end of RUN_IFELSE
 
 fi
+ # end of AC_CACHE_VAL for libopts_cv_run_fopen_binary
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_run_fopen_binary}" >&5
+printf "%s\n" "${libopts_cv_run_fopen_binary}" >&6; }
+  if test "X${libopts_cv_run_fopen_binary}" != Xno
+  then
+
+printf "%s\n" "#define FOPEN_BINARY_FLAG \"b\"" >>confdefs.h
+
+  else
+
+printf "%s\n" "#define FOPEN_BINARY_FLAG \"\"" >>confdefs.h
+
+  fi
+
+
 
+  # Check to see if fopen accepts "t" mode.
 
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether fopen accepts \"t\" mode" >&5
+printf %s "checking whether fopen accepts \"t\" mode... " >&6; }
+  if test ${libopts_cv_run_fopen_text+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
 
-       for ac_header in sysexits.h
-do :
-  ac_fn_c_check_header_compile "$LINENO" "sysexits.h" "ac_cv_header_sysexits_h" "$ac_includes_default"
-if test "x$ac_cv_header_sysexits_h" = xyes
+  if test "$cross_compiling" = yes
 then :
-  printf "%s\n" "#define HAVE_SYSEXITS_H 1" >>confdefs.h
+  libopts_cv_run_fopen_text=no
 
 else $as_nop
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdio.h>
+int main (int argc, char ** argv) {
+FILE * fp = fopen("conftest.$ac_ext", "rt");
+return (fp == NULL) ? 1 : fclose(fp); }
+_ACEOF
+if ac_fn_c_try_run "$LINENO"
+then :
+  libopts_cv_run_fopen_text=yes
+else $as_nop
+  libopts_cv_run_fopen_text=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+ # end of RUN_IFELSE
 
+fi
+ # end of AC_CACHE_VAL for libopts_cv_run_fopen_text
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_run_fopen_text}" >&5
+printf "%s\n" "${libopts_cv_run_fopen_text}" >&6; }
+  if test "X${libopts_cv_run_fopen_text}" != Xno
+  then
 
-printf "%s\n" "#define EX_OK 0" >>confdefs.h
+printf "%s\n" "#define FOPEN_TEXT_FLAG \"t\"" >>confdefs.h
 
+  else
 
-printf "%s\n" "#define EX_SOFTWARE 70" >>confdefs.h
+printf "%s\n" "#define FOPEN_TEXT_FLAG \"\"" >>confdefs.h
 
+  fi
 
-fi
 
-done
 
+  # Check to see if not wanting optional option args.
 
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for facilitynames in syslog.h" >&5
-printf %s "checking for facilitynames in syslog.h... " >&6; }
-if test ${ac_cv_HAVE_SYSLOG_FACILITYNAMES+y}
+  # Check whether --enable-optional-args was given.
+if test ${enable_optional_args+y}
 then :
-  printf %s "(cached) " >&6
+  enableval=$enable_optional_args; libopts_cv_enable_optional_args=${enable_optional_args}
 else $as_nop
-
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#define SYSLOG_NAMES
-#include <stdlib.h>
-#include <syslog.h>
-
-int
-main (void)
-{
- void *fnames; fnames = facilitynames;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether not wanting optional option args" >&5
+printf %s "checking whether not wanting optional option args... " >&6; }
+if test ${libopts_cv_enable_optional_args+y}
 then :
-  ac_cv_HAVE_SYSLOG_FACILITYNAMES=yes
+  printf %s "(cached) " >&6
 else $as_nop
-  ac_cv_HAVE_SYSLOG_FACILITYNAMES=no
+  libopts_cv_enable_optional_args=yes
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libopts_cv_enable_optional_args" >&5
+printf "%s\n" "$libopts_cv_enable_optional_args" >&6; }
+
 fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_HAVE_SYSLOG_FACILITYNAMES" >&5
-printf "%s\n" "$ac_cv_HAVE_SYSLOG_FACILITYNAMES" >&6; }
-case "$ac_cv_HAVE_SYSLOG_FACILITYNAMES" in
- yes)
+ # end of AC_ARG_ENABLE
+  if test "X${libopts_cv_enable_optional_args}" = Xno
+  then
 
-printf "%s\n" "#define HAVE_SYSLOG_FACILITYNAMES 1" >>confdefs.h
+printf "%s\n" "#define NO_OPTIONAL_OPT_ARGS 1" >>confdefs.h
 
-    ;;
- no)
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: No facilitynames in <syslog.h>" >&5
-printf "%s\n" "$as_me: WARNING: No facilitynames in <syslog.h>" >&2;}
-    ;;
- cross)
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: facilitynames in <syslog.h> - cross-compiling" >&5
-printf "%s\n" "$as_me: WARNING: facilitynames in <syslog.h> - cross-compiling" >&2;}
-    ;;
-esac
+  fi
 
 
-# Checks for typedefs, structures, and compiler characteristics.
-ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default"
-if test "x$ac_cv_type__Bool" = xyes
-then :
 
-printf "%s\n" "#define HAVE__BOOL 1" >>confdefs.h
 
 
-fi
+          fi
+  ac_config_files="$ac_config_files libopts/Makefile"
 
-   { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5
-printf %s "checking for stdbool.h that conforms to C99... " >&6; }
-if test ${ac_cv_header_stdbool_h+y}
+  # end of AC_DEFUN of LIBOPTS_CHECK
+
+
+# From when we only used libevent for sntp:
+#AM_COND_IF(
+#    [BUILD_SNTP],
+#    [NTP_LIBEVENT_CHECK],
+#    [NTP_LIBEVENT_CHECK_NOBUILD]
+#)
+
+
+
+# Check whether --enable-local-libevent was given.
+if test ${enable_local_libevent+y}
 then :
-  printf %s "(cached) " >&6
+  enableval=$enable_local_libevent; ntp_use_local_libevent=$enableval
 else $as_nop
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdbool.h>
+  ntp_use_local_libevent=${ntp_use_local_libevent-detect}
 
-             #ifndef __bool_true_false_are_defined
-               #error "__bool_true_false_are_defined is not defined"
-             #endif
-             char a[__bool_true_false_are_defined == 1 ? 1 : -1];
+fi
 
-             /* Regardless of whether this is C++ or "_Bool" is a
-                valid type name, "true" and "false" should be usable
-                in #if expressions and integer constant expressions,
-                and "bool" should be a valid type name.  */
 
-             #if !true
-               #error "'true' is not true"
-             #endif
-             #if true != 1
-               #error "'true' is not equal to 1"
-             #endif
-             char b[true == 1 ? 1 : -1];
-             char c[true];
 
-             #if false
-               #error "'false' is not false"
-             #endif
-             #if false != 0
-               #error "'false' is not equal to 0"
-             #endif
-             char d[false == 0 ? 1 : -1];
 
-             enum { e = false, f = true, g = false * true, h = true * 256 };
 
-             char i[(bool) 0.5 == true ? 1 : -1];
-             char j[(bool) 0.0 == false ? 1 : -1];
-             char k[sizeof (bool) > 0 ? 1 : -1];
 
-             struct sb { bool s: 1; bool t; } s;
-             char l[sizeof s.t > 0 ? 1 : -1];
 
-             /* The following fails for
-                HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
-             bool m[h];
-             char n[sizeof m == h * sizeof m[0] ? 1 : -1];
-             char o[-1 - (bool) 0 < 0 ? 1 : -1];
-             /* Catch a bug in an HP-UX C compiler.  See
-         https://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
-         https://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
-              */
-             bool p = true;
-             bool *pp = &p;
 
-             /* C 1999 specifies that bool, true, and false are to be
-                macros, but C++ 2011 and later overrule this.  */
-             #if __cplusplus < 201103
-              #ifndef bool
-               #error "bool is not defined"
-              #endif
-              #ifndef false
-               #error "false is not defined"
-              #endif
-              #ifndef true
-               #error "true is not defined"
-              #endif
-             #endif
 
-             /* If _Bool is available, repeat with it all the tests
-                above that used bool.  */
-             #ifdef HAVE__BOOL
-               struct sB { _Bool s: 1; _Bool t; } t;
 
-               char q[(_Bool) 0.5 == true ? 1 : -1];
-               char r[(_Bool) 0.0 == false ? 1 : -1];
-               char u[sizeof (_Bool) > 0 ? 1 : -1];
-               char v[sizeof t.t > 0 ? 1 : -1];
+ntp_libevent_min_version=2
+ntp_libevent_tearoff=libevent
 
-               _Bool w[h];
-               char x[sizeof m == h * sizeof m[0] ? 1 : -1];
-               char y[-1 - (_Bool) 0 < 0 ? 1 : -1];
-               _Bool z = true;
-               _Bool *pz = &p;
-             #endif
 
-int
-main (void)
-{
 
-             bool ps = &s;
-             *pp |= p;
-             *pp |= ! p;
 
-             #ifdef HAVE__BOOL
-               _Bool pt = &t;
-               *pz |= z;
-               *pz |= ! z;
-             #endif
 
-             /* Refer to every declared value, so they cannot be
-                discarded as unused.  */
-             return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !j + !k
-                     + !l + !m + !n + !o + !p + !pp + !ps
-             #ifdef HAVE__BOOL
-                     + !q + !r + !u + !v + !w + !x + !y + !z + !pt
-             #endif
-                    );
+case "$ntp_use_local_libevent" in
+ yes)
+    ;;
+ *) # If we have (a good enough) pkg-config, see if it can find libevent
+    case "$PKG_CONFIG" in
+     /*)
+	if $PKG_CONFIG --atleast-version=$ntp_libevent_min_version libevent
+	then
+	    ntp_use_local_libevent=no
+	    ntp_libevent_version="`$PKG_CONFIG --modversion libevent`"
+	    case "$ntp_libevent_version" in
+	     *.*) ;;
+	     *) ntp_libevent_version='(unknown)' ;;
+	    esac
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if libevent $ntp_libevent_min_version or later is installed" >&5
+printf %s "checking if libevent $ntp_libevent_min_version or later is installed... " >&6; }
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes, version $ntp_libevent_version" >&5
+printf "%s\n" "yes, version $ntp_libevent_version" >&6; }
+	    CFLAGS_LIBEVENT=`$PKG_CONFIG --cflags libevent_pthreads`
+	    CPPFLAGS_LIBEVENT=`$PKG_CONFIG --cflags-only-I libevent`
+	    # HMS: I hope the following is accurate.
+	    # We don't need -levent, we only need  -levent_core.
+	    # While we could grab only the -L stuff, there *might* be
+	    # other flags there we want.  Originally we just removed -levent
+	    # but then somebody decided to install -levent-2.0
+	    # LDADD_LIBEVENT=`$PKG_CONFIG --libs libevent | sed 's:-levent::'`
+	    # So now we dance...
+	    LDADD_LIBEVENT=
+	    for i in `$PKG_CONFIG --libs libevent` `$PKG_CONFIG --cflags-only-other libevent_pthreads`
+	    do
+		case "$i" in
+		 -D*) ;;
+		 -levent*) ;;
+		 *) case "$LDADD_LIBEVENT" in
+		     '') LDADD_LIBEVENT="$i" ;;
+		     *) LDADD_LIBEVENT="$LDADD_LIBEVENT $i" ;;
+		    esac
+		    ;;
+		esac
+	    done
+	    case "$LIBISC_PTHREADS_NOTHREADS" in
+	     pthreads)
+		LDADD_LIBEVENT="$LDADD_LIBEVENT -levent_pthreads"
+	    esac
+	    LDADD_LIBEVENT="$LDADD_LIBEVENT -levent_core"
+	else
+	    ntp_use_local_libevent=yes
+	    # HMS: do we only need to do this if LIBISC_PTHREADS_NOTHREADS
+	    # is "pthreads"?
+	    CFLAGS_LIBEVENT=`$PKG_CONFIG --cflags libevent_pthreads`
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if libevent $ntp_libevent_min_version or later is installed" >&5
+printf %s "checking if libevent $ntp_libevent_min_version or later is installed... " >&6; }
+	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+	fi
+	;;
+     *)
+	ntp_use_local_libevent=yes
+	;;
+    esac
+    ;;
+esac
+
+case "$ntp_use_local_libevent" in
+ yes)
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Using libevent tearoff" >&5
+printf "%s\n" "$as_me: Using libevent tearoff" >&6;}
+    CPPFLAGS_LIBEVENT="-I\$(top_builddir)/$ntp_libevent_tearoff/include -I\$(top_srcdir)/$ntp_libevent_tearoff/include"
+    case "$LIBISC_PTHREADS_NOTHREADS" in
+     pthreads)
+	LDADD_LIBEVENT="\$(top_builddir)/$ntp_libevent_tearoff/libevent_pthreads.la \$(top_builddir)/$ntp_libevent_tearoff/libevent_core.la"
+	;;
+     *)
+	LDADD_LIBEVENT="\$(top_builddir)/$ntp_libevent_tearoff/libevent_core.la"
+    esac
+esac
+
 
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"
-then :
-  ac_cv_header_stdbool_h=yes
-else $as_nop
-  ac_cv_header_stdbool_h=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+ if test "x$ntp_use_local_libevent" = "xyes"; then
+  BUILD_LIBEVENT_TRUE=
+  BUILD_LIBEVENT_FALSE='#'
+else
+  BUILD_LIBEVENT_TRUE='#'
+  BUILD_LIBEVENT_FALSE=
 fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5
-printf "%s\n" "$ac_cv_header_stdbool_h" >&6; }
 
-if test $ac_cv_header_stdbool_h = yes; then
 
-printf "%s\n" "#define HAVE_STDBOOL_H 1" >>confdefs.h
 
-fi
 
+case "$ntp_libevent_tearoff" in
+ libevent)
+    ;;
+ *)
+    as_fn_error $? "ntp_libevent.m4 dir must be libevent, not $ntp_libevent_tearoff" "$LINENO" 5
+    ;;
+esac
 
+case "$ntp_use_local_libevent" in
+ yes)
+                        ac_configure_args=" --disable-openssl${ac_configure_args}"
+    ac_configure_args=" --disable-samples${ac_configure_args}"
+    ac_configure_args=" --disable-shared${ac_configure_args}"
+    ac_configure_args=" --disable-libevent-regress${ac_configure_args}"
+    ac_configure_args=" --disable-libevent-install${ac_configure_args}"
+    ac_configure_args=" --enable-silent-rules${ac_configure_args}"
+    ac_configure_args=" --enable-function-sections${ac_configure_args}"
+    ac_configure_args=" LIBEVENT_CFLAGS='${NTP_HARD_CFLAGS}'${ac_configure_args}"
+    ac_configure_args=" LIBEVENT_CPPFLAGS='${NTP_HARD_CPPFLAGS}'${ac_configure_args}"
+    ac_configure_args=" LIBEVENT_LDFLAGS='${NTP_HARD_LDFLAGS}'${ac_configure_args}"
+    subdirs="$subdirs libevent"
 
+    ;;
+ *)
+    NTP_FORCE_LIBEVENT_DIST=libevent
+    ;;
+esac
 
 
-VER_SUFFIX=
 
+# Checks for libraries.
 
 
+LIB_SYSLOG=''
 
-# Check whether --with-crypto was given.
-if test ${with_crypto+y}
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing openlog" >&5
+printf %s "checking for library containing openlog... " >&6; }
+if test ${ac_cv_search_openlog+y}
 then :
-  withval=$with_crypto;
-fi
-
+  printf %s "(cached) " >&6
+else $as_nop
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
-# Check whether --with-openssl-libdir was given.
-if test ${with_openssl_libdir+y}
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+char openlog ();
+int
+main (void)
+{
+return openlog ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' gen syslog
+do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"
 then :
-  withval=$with_openssl_libdir;
+  ac_cv_search_openlog=$ac_res
 fi
-
-
-# Check whether --with-openssl-incdir was given.
-if test ${with_openssl_incdir+y}
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext
+  if test ${ac_cv_search_openlog+y}
 then :
-  withval=$with_openssl_incdir;
+  break
 fi
-
-
-# Check whether --with-rpath was given.
-if test ${with_rpath+y}
+done
+if test ${ac_cv_search_openlog+y}
 then :
-  withval=$with_rpath;
-fi
-
-
-ntp_openssl=no
-ntp_openssl_from_pkg_config=no
-
-with_crypto=${with_crypto:-openssl,libcrypto}
-case "$with_crypto" in
- yes)
-    with_crypto=openssl,libcrypto
-esac
 
+else $as_nop
+  ac_cv_search_openlog=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_openlog" >&5
+printf "%s\n" "$ac_cv_search_openlog" >&6; }
+ac_res=$ac_cv_search_openlog
+if test "$ac_res" != no
+then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+  case "$ac_cv_search_openlog" in
+ 'none required') ;;
+ no) ;;
+ *) LIB_SYSLOG="$ac_cv_search_openlog $LIB_SYSLOG" ;;
+ esac
 
-case "$with_crypto:${PKG_CONFIG:+notempty}:${with_openssl_libdir-notgiven}:${with_openssl_incdir-notgiven}" in
- no:*) ;;
- *:notempty:notgiven:notgiven)
-    for pkg in `echo $with_crypto | sed -e 's/,/ /'`; do
-	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking pkg-config for $pkg" >&5
-printf %s "checking pkg-config for $pkg... " >&6; }
-	if $PKG_CONFIG --exists $pkg ; then
-	    CPPFLAGS_NTP="$CPPFLAGS_NTP `$PKG_CONFIG --cflags-only-I $pkg`"
-	    CFLAGS_NTP="$CFLAGS_NTP `$PKG_CONFIG --cflags-only-other $pkg`"
-	    LDADD_NTP="$LDADD_NTP `$PKG_CONFIG --libs-only-L $pkg`"
-	    LDADD_NTP="$LDADD_NTP `$PKG_CONFIG --libs-only-l --static $pkg`"
-	    LDFLAGS_NTP="$LDFLAGS_NTP `$PKG_CONFIG --libs-only-other $pkg`"
-	    VER_SUFFIX=o
-	    ntp_openssl=yes
-	    ntp_openssl_from_pkg_config=yes
-	    ntp_openssl_version="`$PKG_CONFIG --modversion $pkg`"
-	    case "$ntp_openssl_version" in
-	     *.*) ;;
-	     *) ntp_openssl_version='(unknown)' ;;
-	    esac
-	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes, version $ntp_openssl_version" >&5
-printf "%s\n" "yes, version $ntp_openssl_version" >&6; }
-
-	    break
-	fi
-	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
-printf "%s\n" "no" >&6; }
-    done
-esac
-case "$with_crypto:$ntp_openssl" in
- no:*) ;;
- *:no)
-    need_dash_r=
-    need_dash_Wlrpath=
-    case "${with_rpath-notgiven}" in
-     yes)
-	# Lame - what to do if we need -Wl... but not -R?
-	need_dash_r=1
-	;;
-     notgiven)
-	case "$host" in
-	 *-*-linux*)
-	    # This may really only be true for gcc
-	    need_dash_Wlrpath=1
-	    ;;
-	 *-*-netbsd*)
-	    need_dash_r=1
-	    ;;
-	 *-*-solaris*)
-	    need_dash_r=1
-	    ;;
-	esac
-	;;
-    esac
+fi
 
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for openssl library directory" >&5
-printf %s "checking for openssl library directory... " >&6; }
-    with_openssl_libdir=${with_openssl_libdir-notgiven}
-    case "$with_openssl_libdir" in
-     notgiven)
-	case "$build" in
-	 $host)
-	    with_openssl_libdir=default
-	    ;;
-	 *)
-	    with_openssl_libdir=no
-	    ;;
-	esac
-    esac
-    case "$with_openssl_libdir" in
-     default)
-	# Look in:
-	with_openssl_libdir="/usr/lib /usr/lib/openssl /usr/sfw/lib"
-	with_openssl_libdir="$with_openssl_libdir /usr/local/lib"
-	with_openssl_libdir="$with_openssl_libdir /usr/local/ssl/lib /lib"
-    esac
-    case "$with_openssl_libdir" in
-     no)
-	;;
-     *) # Look for libcrypto.a and libssl.a:
-	for i in $with_openssl_libdir no
-	do
-	    case "$host" in
-	     *-*-darwin*)
-		test -f $i/libcrypto.dylib -a -f $i/libssl.dylib && break
-		;;
-	     *)
-		test -f $i/libcrypto.so -a -f $i/libssl.so && break
-		test -f $i/libcrypto.a -a -f $i/libssl.a && break
-		;;
-	    esac
-	done
-	openssl_libdir=$i
-	;;
-    esac
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $openssl_libdir" >&5
-printf "%s\n" "$openssl_libdir" >&6; }
-    case "$openssl_libdir" in
-     no)
-	openssl_libdir=
-	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: libcrypto and libssl not found in any of $with_openssl_libdir" >&5
-printf "%s\n" "$as_me: WARNING: libcrypto and libssl not found in any of $with_openssl_libdir" >&2;}
-    esac
 
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for openssl include directory" >&5
-printf %s "checking for openssl include directory... " >&6; }
-    with_openssl_incdir=${with_openssl_incdir-notgiven}
-    case "$with_openssl_incdir" in
-     notgiven)
-	# Look in:
-	with_openssl_incdir="/usr/include /usr/sfw/include"
-	with_openssl_incdir="$with_openssl_incdir /usr/local/include"
-	with_openssl_incdir="$with_openssl_incdir /usr/local/ssl/include"
-    esac
-    case "$with_openssl_incdir" in
-     no)
-	;;
-     *) # look for openssl/evp.h:
-	for i in $with_openssl_incdir no
-	do
-	    test -f $i/openssl/evp.h && break
-	done
-	openssl_incdir=$i
-	;;
-    esac
-    { i=; unset i;}
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $openssl_incdir" >&5
-printf "%s\n" "$openssl_incdir" >&6; }
-    case "$openssl_incdir" in
-     no)
-	openssl_incdir=
-	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: did not find openssl/evp.h in any of $with_openssl_incdir" >&5
-printf "%s\n" "$as_me: WARNING: did not find openssl/evp.h in any of $with_openssl_incdir" >&2;}
-    esac
-    if test -z "$openssl_libdir" -o -z "$openssl_incdir"
-    then
-	ntp_openssl=no
-    else
-	ntp_openssl=yes
-	VER_SUFFIX=o
-    fi
-    case "$ntp_openssl" in
-     yes)
-	# We have OpenSSL inc/lib dirs - use them.
-	case "$openssl_incdir" in
-	 /usr/include)
-	    ;;
-	 *)
-	    CPPFLAGS_NTP="$CPPFLAGS_NTP -I$openssl_incdir"
-	    ;;
-	esac
-	case "$openssl_libdir" in
-	 /usr/lib)
-	    ;;
-	 *)
-	    LDADD_NTP="$LDADD_NTP -L$openssl_libdir"
-	    case "$need_dash_r" in
-	     1)
-		LDFLAGS_NTP="$LDFLAGS_NTP -R$openssl_libdir"
-	    esac
-	    case "$need_dash_Wlrpath" in
-	     1)
-		LDFLAGS_NTP="$LDFLAGS_NTP -Wl,-rpath,$openssl_libdir"
-	    esac
-	    ;;
-	esac
-	LDADD_NTP="$LDADD_NTP -lcrypto"
-    esac
-esac
+# Checks for header files.
+ac_fn_c_check_header_compile "$LINENO" "netdb.h" "ac_cv_header_netdb_h" "$ac_includes_default"
+if test "x$ac_cv_header_netdb_h" = xyes
+then :
+  printf "%s\n" "#define HAVE_NETDB_H 1" >>confdefs.h
 
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if we will use crypto" >&5
-printf %s "checking if we will use crypto... " >&6; }
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_openssl" >&5
-printf "%s\n" "$ntp_openssl" >&6; }
+fi
+ac_fn_c_check_header_compile "$LINENO" "string.h" "ac_cv_header_string_h" "$ac_includes_default"
+if test "x$ac_cv_header_string_h" = xyes
+then :
+  printf "%s\n" "#define HAVE_STRING_H 1" >>confdefs.h
 
-case "$ntp_openssl" in
- yes)
-    ac_fn_c_check_header_compile "$LINENO" "openssl/cmac.h" "ac_cv_header_openssl_cmac_h" "$ac_includes_default"
-if test "x$ac_cv_header_openssl_cmac_h" = xyes
+fi
+ac_fn_c_check_header_compile "$LINENO" "strings.h" "ac_cv_header_strings_h" "$ac_includes_default"
+if test "x$ac_cv_header_strings_h" = xyes
 then :
-  printf "%s\n" "#define HAVE_OPENSSL_CMAC_H 1" >>confdefs.h
+  printf "%s\n" "#define HAVE_STRINGS_H 1" >>confdefs.h
 
 fi
-ac_fn_c_check_header_compile "$LINENO" "openssl/hmac.h" "ac_cv_header_openssl_hmac_h" "$ac_includes_default"
-if test "x$ac_cv_header_openssl_hmac_h" = xyes
+ac_fn_c_check_header_compile "$LINENO" "syslog.h" "ac_cv_header_syslog_h" "$ac_includes_default"
+if test "x$ac_cv_header_syslog_h" = xyes
 then :
-  printf "%s\n" "#define HAVE_OPENSSL_HMAC_H 1" >>confdefs.h
+  printf "%s\n" "#define HAVE_SYSLOG_H 1" >>confdefs.h
 
 fi
 
 
-printf "%s\n" "#define OPENSSL /**/" >>confdefs.h
-
-    case "$VER_SUFFIX" in
-     *o*) ;;
-     *) as_fn_error $? "OPENSSL set but no 'o' in VER_SUFFIX!" "$LINENO" 5 ;;
-    esac
-    ;;
-esac
-
-NTPO_SAVED_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $CPPFLAGS_NTP"
-NTPO_SAVED_LIBS="$LIBS"
 
-#
-# check for linking with -lcrypto failure, and try -lcrypto -lz.
-# Helps m68k-atari-mint
-#
-case "$ntp_openssl:$ntp_openssl_from_pkg_config" in
- yes:no)
-    LIBS="$NTPO_SAVED_LIBS $LDADD_NTP"
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if linking with -lcrypto alone works" >&5
-printf %s "checking if linking with -lcrypto alone works... " >&6; }
-if test ${ntp_cv_bare_lcrypto+y}
+       for ac_header in sysexits.h
+do :
+  ac_fn_c_check_header_compile "$LINENO" "sysexits.h" "ac_cv_header_sysexits_h" "$ac_includes_default"
+if test "x$ac_cv_header_sysexits_h" = xyes
 then :
-  printf %s "(cached) " >&6
+  printf "%s\n" "#define HAVE_SYSEXITS_H 1" >>confdefs.h
+
 else $as_nop
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
 
-		    #include "openssl/err.h"
-		    #include "openssl/evp.h"
 
-int
-main (void)
-{
+printf "%s\n" "#define EX_OK 0" >>confdefs.h
 
-		    ERR_load_crypto_strings();
-		    OpenSSL_add_all_algorithms();
 
+printf "%s\n" "#define EX_SOFTWARE 70" >>confdefs.h
 
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"
-then :
-  ntp_cv_bare_lcrypto=yes
-else $as_nop
-  ntp_cv_bare_lcrypto=no
 
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam \
-    conftest$ac_exeext conftest.$ac_ext
 
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_bare_lcrypto" >&5
-printf "%s\n" "$ntp_cv_bare_lcrypto" >&6; }
-    case "$ntp_cv_bare_lcrypto" in
-     no)
-	LIBS="$NTPO_SAVED_LIBS $LDADD_NTP -lz"
-	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if linking with -lcrypto -lz works" >&5
-printf %s "checking if linking with -lcrypto -lz works... " >&6; }
-if test ${ntp_cv_lcrypto_lz+y}
+done
+
+
+
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for facilitynames in syslog.h" >&5
+printf %s "checking for facilitynames in syslog.h... " >&6; }
+if test ${ac_cv_HAVE_SYSLOG_FACILITYNAMES+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-			#include "openssl/err.h"
-			#include "openssl/evp.h"
+		#define SYSLOG_NAMES
+		#include <stdlib.h>
+		#include <syslog.h>
 
 int
 main (void)
 {
 
-			ERR_load_crypto_strings();
-			OpenSSL_add_all_algorithms();
+		void *fnames = facilitynames;
 
 
   ;
   return 0;
 }
+	ac_cv_HAVE_SYSLOG_FACILITYNAMES=yes
 _ACEOF
-if ac_fn_c_try_link "$LINENO"
+if ac_fn_c_try_compile "$LINENO"
 then :
-  ntp_cv_lcrypto_lz=yes
-else $as_nop
-  ntp_cv_lcrypto_lz=no
+  ac_cv_HAVE_SYSLOG_FACILITYNAMES=no
 
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam \
-    conftest$ac_exeext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 
 fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ntp_cv_lcrypto_lz" >&5
-printf "%s\n" "$ntp_cv_lcrypto_lz" >&6; }
-	case "$ntp_cv_lcrypto_lz" in
-	 yes)
-	     LDADD_NTP="$LDADD_NTP -lz"
-	esac
-    esac
-esac
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_HAVE_SYSLOG_FACILITYNAMES" >&5
+printf "%s\n" "$ac_cv_HAVE_SYSLOG_FACILITYNAMES" >&6; }
+case "$ac_cv_HAVE_SYSLOG_FACILITYNAMES" in
+ yes)
 
-#
-# Older OpenSSL headers have a number of callback prototypes inside
-# other function prototypes which trigger copious warnings with gcc's
-# -Wstrict-prototypes, which is included in -Wall.
-#
-# An example:
-#
-# int i2d_RSA_NET(const RSA *a, unsigned char **pp,
-#		  int (*cb)(), int sgckey);
-#		  ^^^^^^^^^^^
-#
-#
-#
-openssl_triggers_warnings=unknown
-NTPO_SAVED_CFLAGS="$CFLAGS"
+printf "%s\n" "#define HAVE_SYSLOG_FACILITYNAMES 1" >>confdefs.h
 
-case "$ntp_openssl:$GCC" in
- yes:yes)
-    CFLAGS="$CFLAGS -Werror"
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
+    ;;
+ no)
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: No facilitynames in <syslog.h>" >&5
+printf "%s\n" "$as_me: WARNING: No facilitynames in <syslog.h>" >&2;}
+esac
 
 
-int
-main (void)
-{
+# Checks for typedefs, structures, and compiler characteristics.
+ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default"
+if test "x$ac_cv_type__Bool" = xyes
+then :
 
-		/* see if -Werror breaks gcc */
+printf "%s\n" "#define HAVE__BOOL 1" >>confdefs.h
 
 
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"
+fi
+
+   { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5
+printf %s "checking for stdbool.h that conforms to C99... " >&6; }
+if test ${ac_cv_header_stdbool_h+y}
 then :
-  gcc_handles_Werror=yes
+  printf %s "(cached) " >&6
 else $as_nop
-  gcc_handles_Werror=no
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
-    case "$gcc_handles_Werror" in
-     no)
-	# if this gcc doesn't do -Werror go ahead and use
-	# -Wstrict-prototypes.
-	openssl_triggers_warnings=yes
-	;;
-     yes)
-	CFLAGS="$CFLAGS -Wstrict-prototypes"
-	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
+#include <stdbool.h>
 
-		    #include "openssl/asn1_mac.h"
-		    #include "openssl/bn.h"
-		    #include "openssl/err.h"
-		    #include "openssl/evp.h"
-		    #include "openssl/pem.h"
-		    #include "openssl/rand.h"
-		    #include "openssl/x509v3.h"
+             #ifndef __bool_true_false_are_defined
+               #error "__bool_true_false_are_defined is not defined"
+             #endif
+             char a[__bool_true_false_are_defined == 1 ? 1 : -1];
+
+             /* Regardless of whether this is C++ or "_Bool" is a
+                valid type name, "true" and "false" should be usable
+                in #if expressions and integer constant expressions,
+                and "bool" should be a valid type name.  */
+
+             #if !true
+               #error "'true' is not true"
+             #endif
+             #if true != 1
+               #error "'true' is not equal to 1"
+             #endif
+             char b[true == 1 ? 1 : -1];
+             char c[true];
+
+             #if false
+               #error "'false' is not false"
+             #endif
+             #if false != 0
+               #error "'false' is not equal to 0"
+             #endif
+             char d[false == 0 ? 1 : -1];
+
+             enum { e = false, f = true, g = false * true, h = true * 256 };
+
+             char i[(bool) 0.5 == true ? 1 : -1];
+             char j[(bool) 0.0 == false ? 1 : -1];
+             char k[sizeof (bool) > 0 ? 1 : -1];
+
+             struct sb { bool s: 1; bool t; } s;
+             char l[sizeof s.t > 0 ? 1 : -1];
+
+             /* The following fails for
+                HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
+             bool m[h];
+             char n[sizeof m == h * sizeof m[0] ? 1 : -1];
+             char o[-1 - (bool) 0 < 0 ? 1 : -1];
+             /* Catch a bug in an HP-UX C compiler.  See
+         https://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
+         https://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
+              */
+             bool p = true;
+             bool *pp = &p;
+
+             /* C 1999 specifies that bool, true, and false are to be
+                macros, but C++ 2011 and later overrule this.  */
+             #if __cplusplus < 201103
+              #ifndef bool
+               #error "bool is not defined"
+              #endif
+              #ifndef false
+               #error "false is not defined"
+              #endif
+              #ifndef true
+               #error "true is not defined"
+              #endif
+             #endif
+
+             /* If _Bool is available, repeat with it all the tests
+                above that used bool.  */
+             #ifdef HAVE__BOOL
+               struct sB { _Bool s: 1; _Bool t; } t;
+
+               char q[(_Bool) 0.5 == true ? 1 : -1];
+               char r[(_Bool) 0.0 == false ? 1 : -1];
+               char u[sizeof (_Bool) > 0 ? 1 : -1];
+               char v[sizeof t.t > 0 ? 1 : -1];
+
+               _Bool w[h];
+               char x[sizeof m == h * sizeof m[0] ? 1 : -1];
+               char y[-1 - (_Bool) 0 < 0 ? 1 : -1];
+               _Bool z = true;
+               _Bool *pz = &p;
+             #endif
 
 int
 main (void)
 {
 
-		    /* empty body */
+             bool ps = &s;
+             *pp |= p;
+             *pp |= ! p;
+
+             #ifdef HAVE__BOOL
+               _Bool pt = &t;
+               *pz |= z;
+               *pz |= ! z;
+             #endif
 
+             /* Refer to every declared value, so they cannot be
+                discarded as unused.  */
+             return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !j + !k
+                     + !l + !m + !n + !o + !p + !pp + !ps
+             #ifdef HAVE__BOOL
+                     + !q + !r + !u + !v + !w + !x + !y + !z + !pt
+             #endif
+                    );
 
   ;
   return 0;
@@ -26649,50 +27246,21 @@ main (void)
 _ACEOF
 if ac_fn_c_try_compile "$LINENO"
 then :
-  openssl_triggers_warnings=no
+  ac_cv_header_stdbool_h=yes
 else $as_nop
-  openssl_triggers_warnings=yes
-
+  ac_cv_header_stdbool_h=no
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
-    esac
-    case "$openssl_triggers_warnings" in
-     yes)
-	CFLAGS_NTP="$CFLAGS_NTP -Wno-strict-prototypes"
-	;;
-     *)
-	CFLAGS_NTP="$CFLAGS_NTP -Wstrict-prototypes"
-    esac
-    ;;
- no:yes)
-    # gcc without OpenSSL
-    CFLAGS_NTP="$CFLAGS_NTP -Wstrict-prototypes"
-esac
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5
+printf "%s\n" "$ac_cv_header_stdbool_h" >&6; }
 
-# Because we don't want -Werror for the EVP_MD_do_all_sorted check
-CFLAGS="$NTPO_SAVED_CFLAGS"
+if test $ac_cv_header_stdbool_h = yes; then
 
-case "$ntp_openssl" in
- yes)
-    LIBS="$NTPO_SAVED_LIBS $LDADD_NTP"
-    ac_fn_c_check_func "$LINENO" "EVP_MD_do_all_sorted" "ac_cv_func_EVP_MD_do_all_sorted"
-if test "x$ac_cv_func_EVP_MD_do_all_sorted" = xyes
-then :
-  printf "%s\n" "#define HAVE_EVP_MD_DO_ALL_SORTED 1" >>confdefs.h
+printf "%s\n" "#define HAVE_STDBOOL_H 1" >>confdefs.h
 
 fi
 
-    ;;
-esac
-
-
-CPPFLAGS="$NTPO_SAVED_CPPFLAGS"
-LIBS="$NTPO_SAVED_LIBS"
-{ NTPO_SAVED_CFLAGS=; unset NTPO_SAVED_CFLAGS;}
-{ NTPO_SAVED_CPPFLAGS=; unset NTPO_SAVED_CPPFLAGS;}
-{ NTPO_SAVED_LIBS=; unset NTPO_SAVED_LIBS;}
-{ openssl_triggers_warnings=; unset openssl_triggers_warnings;}
-{ ntp_openssl_from_pkg_config=; unset ntp_openssl_from_pkg_config;}
 
 
 
@@ -27842,6 +28410,10 @@ if test -z "${PTHREADS_TRUE}" && test -z "${PTHREADS_FALSE}"; then
   as_fn_error $? "conditional \"PTHREADS\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${LIBNTP_SUBMAKES_TRUE}" && test -z "${LIBNTP_SUBMAKES_FALSE}"; then
+  as_fn_error $? "conditional \"LIBNTP_SUBMAKES\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 if test -z "${BUILD_SNTP_TRUE}" && test -z "${BUILD_SNTP_FALSE}"; then
   as_fn_error $? "conditional \"BUILD_SNTP\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
@@ -28264,7 +28836,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by sntp $as_me 4.2.8p17, which was
+This file was extended by sntp $as_me 4.2.8p18, which was
 generated by GNU Autoconf 2.71.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -28333,7 +28905,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config='$ac_cs_config_escaped'
 ac_cs_version="\\
-sntp config.status 4.2.8p17
+sntp config.status 4.2.8p18
 configured by $0, generated by GNU Autoconf 2.71,
   with options \\"\$ac_cs_config\\"
 
@@ -28470,9 +29042,9 @@ FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`'
 SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`'
 ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`'
 LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`'
-enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`'
 macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`'
 macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`'
+enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`'
 enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`'
 pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`'
 enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`'
@@ -29519,13 +30091,13 @@ SHELL=$lt_SHELL
 # An echo program that protects backslashes.
 ECHO=$lt_ECHO
 
-# Whether or not to build shared libraries.
-build_libtool_libs=$enable_shared
-
 # Which release of libtool.m4 was used?
 macro_version=$macro_version
 macro_revision=$macro_revision
 
+# Whether or not to build shared libraries.
+build_libtool_libs=$enable_shared
+
 # Whether or not to build static libraries.
 build_old_libs=$enable_static
 
diff --git a/contrib/ntp/sntp/configure.ac b/contrib/ntp/sntp/configure.ac
index 43c2ad6c5828..4fb182bc0ef5 100644
--- a/contrib/ntp/sntp/configure.ac
+++ b/contrib/ntp/sntp/configure.ac
@@ -33,7 +33,7 @@ AC_LANG([C])
 # the date YYYYMMDD optionally with -HHMM if there is more than one
 # bump in a day.
 
-sntp_configure_cache_version=20120806
+sntp_configure_cache_version=20240218
 
 # When the version of config.cache and configure do not
 # match, NTP_CACHEVERSION will flush the cache.
@@ -62,8 +62,7 @@ AM_PROG_AR
 
 NTP_LIBNTP
 
-AC_DISABLE_SHARED
-AC_PROG_LIBTOOL
+LT_INIT([disable-shared])
 AC_SUBST([LIBTOOL_DEPS])
 
 NTP_WITHSNTP
@@ -82,7 +81,7 @@ esac
 # Therefore, by default:
 # - use the version we ship with
 # - do not install it
-# - build a static copy (AC_DISABLE_SHARED - done earlier)
+# - build a static copy (disable-shared - done earlier)
 case "${enable_local_libopts+set}" in
  set) ;;
  *) enable_local_libopts=yes ;;
@@ -121,7 +120,6 @@ NTP_FACILITYNAMES
 # Checks for typedefs, structures, and compiler characteristics.
 AC_HEADER_STDBOOL
 
-NTP_OPENSSL
 NTP_IPV6
 
 ###
diff --git a/contrib/ntp/sntp/crypto.c b/contrib/ntp/sntp/crypto.c
index 7807ccc00b03..1be2ea3f0c39 100644
--- a/contrib/ntp/sntp/crypto.c
+++ b/contrib/ntp/sntp/crypto.c
@@ -16,14 +16,15 @@ size_t key_cnt = 0;
 
 typedef struct key Key_T;
 
-static u_int
+static size_t
 compute_mac(
-	u_char		digest[EVP_MAX_MD_SIZE],
+	u_char *	digest,
+	size_t		dig_sz,
 	char const *	macname,
 	void const *	pkt_data,
-	u_int		pkt_size,
+	size_t		pkt_len,
 	void const *	key_data,
-	u_int		key_size
+	size_t		key_size
 	)
 {
 	u_int		len  = 0;
@@ -56,7 +57,7 @@ compute_mac(
 				    EVP_aes_128_cbc(), NULL)) {
 			msyslog(LOG_ERR, "make_mac: CMAC %s Init failed.",      CMAC);
 		}
-		else if (!CMAC_Update(ctx, pkt_data, (size_t)pkt_size)) {
+		else if (!CMAC_Update(ctx, pkt_data, pkt_len)) {
 			msyslog(LOG_ERR, "make_mac: CMAC %s Update failed.",    CMAC);
 		}
 		else if (!CMAC_Final(ctx, digest, &slen)) {
@@ -95,7 +96,7 @@ compute_mac(
 				macname);
 			goto mac_fail;
 		}
-		if (!EVP_DigestUpdate(ctx, pkt_data, pkt_size)) {
+		if (!EVP_DigestUpdate(ctx, pkt_data, pkt_len)) {
 			msyslog(LOG_ERR, "make_mac: MAC %s Digest Update data failed.",
 				macname);
 			goto mac_fail;
@@ -112,7 +113,7 @@ compute_mac(
 			goto mac_fail;
 		}
 		EVP_DigestUpdate(ctx, key_data, key_size);
-		EVP_DigestUpdate(ctx, pkt_data, pkt_size);
+		EVP_DigestUpdate(ctx, pkt_data, pkt_len);
 		EVP_DigestFinal(ctx, digest, &len);
 #endif
 	  mac_fail:
@@ -122,34 +123,28 @@ compute_mac(
 	return len;
 }
 
-int
+
+size_t
 make_mac(
 	const void *	pkt_data,
-	int		pkt_size,
-	int		mac_size,
+	size_t		pkt_len,
 	Key_T const *	cmp_key,
-	void * 		digest
+	void * 		digest,
+	size_t		dig_sz
 	)
 {
 	u_int		len;
 	u_char		dbuf[EVP_MAX_MD_SIZE];
 
-	if (cmp_key->key_len > 64 || mac_size <= 0)
-		return 0;
-	if (pkt_size % 4 != 0)
+	if (cmp_key->key_len > 64 || pkt_len % 4 != 0) {
 		return 0;
-
-	len = compute_mac(dbuf, cmp_key->typen,
-			  pkt_data, (u_int)pkt_size,
-			  cmp_key->key_seq, (u_int)cmp_key->key_len);
-
-
-	if (len) {
-		if (len > (u_int)mac_size)
-			len = (u_int)mac_size;
-		memcpy(digest, dbuf, len);
 	}
-	return (int)len;
+	len = compute_mac(dbuf, sizeof(dbuf),  cmp_key->typen, pkt_data,
+			  pkt_len, cmp_key->key_seq, cmp_key->key_len);
+	INSIST(len <= dig_sz);
+	memcpy(digest, dbuf, len);
+
+	return len;
 }
 
 
@@ -161,8 +156,8 @@ make_mac(
 int
 auth_md5(
 	void const *	pkt_data,
-	int 		pkt_size,
-	int		mac_size,
+	size_t		pkt_len,
+	size_t		mac_len,
 	Key_T const *	cmp_key
 	)
 {
@@ -170,22 +165,20 @@ auth_md5(
 	u_char const *	pkt_ptr   = pkt_data;
 	u_char		dbuf[EVP_MAX_MD_SIZE];
 
-	if (mac_size <= 0 || (size_t)mac_size > sizeof(dbuf))
+	if (0 == mac_len || mac_len > sizeof(dbuf)) {
 		return FALSE;
+	}
+	len = compute_mac(dbuf, sizeof(dbuf), cmp_key->typen,
+			  pkt_ptr, pkt_len, cmp_key->key_seq,
+			  cmp_key->key_len);
 
-	len = compute_mac(dbuf, cmp_key->typen,
-			  pkt_ptr, (u_int)pkt_size,
-			  cmp_key->key_seq, (u_int)cmp_key->key_len);
-
-	pkt_ptr += pkt_size + 4;
-	if (len > (u_int)mac_size)
-		len = (u_int)mac_size;
+	pkt_ptr += pkt_len + sizeof(keyid_t);
 
 	/* isc_tsmemcmp will be better when its easy to link with.  sntp
 	 * is a 1-shot program, so snooping for timing attacks is
 	 * Harder.
 	 */
-	return ((u_int)mac_size == len) && !memcmp(dbuf, pkt_ptr, len);
+	return mac_len == len && !memcmp(dbuf, pkt_ptr, mac_len);
 }
 
 static int
@@ -312,14 +305,15 @@ auth_init(
  */
 void
 get_key(
-	int key_id,
-	struct key **d_key
+	keyid_t		key_id,
+	struct key **	d_key
 	)
 {
 	struct key *itr_key;
 
-	if (key_cnt == 0)
+	if (key_cnt == 0) {
 		return;
+	}
 	for (itr_key = key_ptr; itr_key; itr_key = itr_key->next) {
 		if (itr_key->key_id == key_id) {
 			*d_key = itr_key;
diff --git a/contrib/ntp/sntp/crypto.h b/contrib/ntp/sntp/crypto.h
index 4e75df20a9a3..4afe865e53e5 100644
--- a/contrib/ntp/sntp/crypto.h
+++ b/contrib/ntp/sntp/crypto.h
@@ -17,18 +17,19 @@
 
 struct key {
 	struct key *	next;
-	int		key_id;
-	int		key_len;
+	keyid_t		key_id;
+	size_t		key_len;
 	int		typei;
 	char		typen[20];
 	char		key_seq[64];
 };
 
 extern	int	auth_init(const char *keyfile, struct key **keys);
-extern	void	get_key(int key_id, struct key **d_key);
-extern	int	make_mac(const void *pkt_data, int pkt_size, int mac_size,
-			 const struct key *cmp_key, void *digest);
-extern	int	auth_md5(const void *pkt_data, int pkt_size, int mac_size,
-			 const struct key *cmp_key);
+extern	void	get_key(keyid_t key_id, struct key **d_key);
+extern	size_t	make_mac(const void *pkt_data, size_t pkt_len,
+			 const struct key *cmp_key, void *digest,
+			 size_t dig_sz);
+extern	int	auth_md5(const void *pkt_data, size_t pkt_len,
+			 size_t dig_len, const struct key *cmp_key);
 
 #endif
diff --git a/contrib/ntp/sntp/include/Makefile.in b/contrib/ntp/sntp/include/Makefile.in
index c3db03921ec4..4cfad3135b91 100644
--- a/contrib/ntp/sntp/include/Makefile.in
+++ b/contrib/ntp/sntp/include/Makefile.in
@@ -98,6 +98,7 @@ am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
 	$(top_srcdir)/m4/ntp_cacheversion.m4 \
 	$(top_srcdir)/m4/ntp_compiler.m4 \
 	$(top_srcdir)/m4/ntp_crosscompile.m4 \
+	$(top_srcdir)/m4/ntp_crypto_rand.m4 \
 	$(top_srcdir)/m4/ntp_debug.m4 $(top_srcdir)/m4/ntp_dir_sep.m4 \
 	$(top_srcdir)/m4/ntp_facilitynames.m4 \
 	$(top_srcdir)/m4/ntp_harden.m4 $(top_srcdir)/m4/ntp_ipv6.m4 \
@@ -293,6 +294,7 @@ PACKAGE_STRING = @PACKAGE_STRING@
 PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_OPENSSL = @PATH_OPENSSL@
 PATH_RUBY = @PATH_RUBY@
 PATH_SEPARATOR = @PATH_SEPARATOR@
 PKG_CONFIG = @PKG_CONFIG@
diff --git a/contrib/ntp/sntp/include/copyright.def b/contrib/ntp/sntp/include/copyright.def
index c93887e2cdae..137ff6df4664 100644
--- a/contrib/ntp/sntp/include/copyright.def
+++ b/contrib/ntp/sntp/include/copyright.def
@@ -1,7 +1,7 @@
 /* -*- Mode: Text -*- */
 
 copyright = {
-    date  = "1992-2023";
+    date  = "1992-2024";
     owner = "The University of Delaware and Network Time Foundation";
     eaddr = "https://bugs.ntp.org, bugs@ntp.org";
     type  = ntp;
diff --git a/contrib/ntp/sntp/include/version.def b/contrib/ntp/sntp/include/version.def
index bba075cfff5f..64683799012a 100644
--- a/contrib/ntp/sntp/include/version.def
+++ b/contrib/ntp/sntp/include/version.def
@@ -1 +1 @@
-version = '4.2.8p17';
+version = '4.2.8p18';
diff --git a/contrib/ntp/sntp/include/version.texi b/contrib/ntp/sntp/include/version.texi
index eaead228a2d3..be3254dadc0b 100644
--- a/contrib/ntp/sntp/include/version.texi
+++ b/contrib/ntp/sntp/include/version.texi
@@ -1,3 +1,3 @@
-@set UPDATED 06 June 2023
-@set EDITION 4.2.8p17
-@set VERSION 4.2.8p17
+@set UPDATED 25 May 2024
+@set EDITION 4.2.8p18
+@set VERSION 4.2.8p18
diff --git a/contrib/ntp/sntp/invoke-sntp.texi b/contrib/ntp/sntp/invoke-sntp.texi
index 4c03b3a498f3..4abdd3b00ff2 100644
--- a/contrib/ntp/sntp/invoke-sntp.texi
+++ b/contrib/ntp/sntp/invoke-sntp.texi
@@ -6,7 +6,7 @@
 #
 # EDIT THIS FILE WITH CAUTION  (invoke-sntp.texi)
 #
-# It has been AutoGen-ed  June  6, 2023 at 04:36:12 AM by AutoGen 5.18.16
+# It has been AutoGen-ed  May 25, 2024 at 12:02:28 AM by AutoGen 5.18.16
 # From the definitions    sntp-opts.def
 # and the template file   agtexi-cmd.tpl
 @end ignore
@@ -101,7 +101,7 @@ with a status code of 0.
 
 @exampleindent 0
 @example
-sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p17
+sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p18
 Usage:  sntp [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... \
                 [ hostname-or-IP ...]
   Flg Arg Option-Name    Description
diff --git a/contrib/ntp/sntp/libevent/Makefile.in b/contrib/ntp/sntp/libevent/Makefile.in
index 6a285613eace..2429f95d355d 100644
--- a/contrib/ntp/sntp/libevent/Makefile.in
+++ b/contrib/ntp/sntp/libevent/Makefile.in
@@ -935,7 +935,10 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
 LD = @LD@
 LDFLAGS = @LDFLAGS@
+LIBEVENT_CFLAGS = @LIBEVENT_CFLAGS@
+LIBEVENT_CPPFLAGS = @LIBEVENT_CPPFLAGS@
 LIBEVENT_GC_SECTIONS = @LIBEVENT_GC_SECTIONS@
+LIBEVENT_LDFLAGS = @LIBEVENT_LDFLAGS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
diff --git a/contrib/ntp/sntp/libevent/configure b/contrib/ntp/sntp/libevent/configure
index c497e6dfd28c..c212b0001057 100755
--- a/contrib/ntp/sntp/libevent/configure
+++ b/contrib/ntp/sntp/libevent/configure
@@ -703,6 +703,9 @@ DX_ENV
 DX_DOCDIR
 DX_CONFIG
 DX_PROJECT
+LIBEVENT_LDFLAGS
+LIBEVENT_CPPFLAGS
+LIBEVENT_CFLAGS
 INSTALL_LIBEVENT_FALSE
 INSTALL_LIBEVENT_TRUE
 LIBEVENT_GC_SECTIONS
@@ -15135,7 +15138,6 @@ then :
   LIBS="-lws2_32 $LIBS"
 
 fi
-ac_cv_lib_ws2_32=ac_cv_lib_ws2_32_main
 
 fi
 
@@ -17811,6 +17813,10 @@ else
 fi
 
 
+
+
+
+
 # Doxygen support
 
 
diff --git a/contrib/ntp/sntp/libevent/configure.ac b/contrib/ntp/sntp/libevent/configure.ac
index d00e063a1474..6c2646c219de 100644
--- a/contrib/ntp/sntp/libevent/configure.ac
+++ b/contrib/ntp/sntp/libevent/configure.ac
@@ -348,7 +348,7 @@ AM_CONDITIONAL(BUILD_MIDIPIX, test x$midipix = xtrue)
 AM_CONDITIONAL(BUILD_WITH_NO_UNDEFINED, test x$bwin32 = xtrue || test x$cygwin = xtrue || test x$midipix = xtrue)
 
 if test x$bwin32 = xtrue; then
-  AC_HAVE_LIBRARY([ws2_32])
+  AC_CHECK_LIB([ws2_32], [main])
 fi
 
 dnl Checks for typedefs, structures, and compiler characteristics.
@@ -989,6 +989,11 @@ AC_SUBST([LIBEVENT_GC_SECTIONS])
 
 AM_CONDITIONAL([INSTALL_LIBEVENT], [test "$enable_libevent_install" = "yes"])
 
+dnl Aloow addtional flags from a containing package such as NTP
+AC_SUBST([LIBEVENT_CFLAGS])
+AC_SUBST([LIBEVENT_CPPFLAGS])
+AC_SUBST([LIBEVENT_LDFLAGS])
+
 # Doxygen support
 DX_HTML_FEATURE(ON)
 DX_MAN_FEATURE(OFF)
diff --git a/contrib/ntp/sntp/libevent/kqueue.c b/contrib/ntp/sntp/libevent/kqueue.c
index dfd7751d6497..14a8946fe99d 100644
--- a/contrib/ntp/sntp/libevent/kqueue.c
+++ b/contrib/ntp/sntp/libevent/kqueue.c
@@ -346,7 +346,7 @@ kq_dispatch(struct event_base *base, struct timeval *tv)
 			 * on FreeBSD. */
 			case EINVAL:
 				continue;
-#if defined(__FreeBSD__)
+#if defined(__FreeBSD__) && defined(ENOTCAPABLE)
 			/*
 			 * This currently occurs if an FD is closed
 			 * before the EV_DELETE makes it out via kevent().
diff --git a/contrib/ntp/sntp/libevent/m4/acx_pthread.m4 b/contrib/ntp/sntp/libevent/m4/acx_pthread.m4
index d2b116945f9f..92ac1089b4ee 100644
--- a/contrib/ntp/sntp/libevent/m4/acx_pthread.m4
+++ b/contrib/ntp/sntp/libevent/m4/acx_pthread.m4
@@ -86,7 +86,7 @@
 AC_DEFUN([ACX_PTHREAD], [
 AC_REQUIRE([AC_CANONICAL_HOST])
 AC_LANG_SAVE
-AC_LANG_C
+AC_LANG([C])
 acx_pthread_ok=no
 
 # We used to check for pthread.h first, but this fails if pthread.h
diff --git a/contrib/ntp/sntp/libopts/Makefile.am b/contrib/ntp/sntp/libopts/Makefile.am
index 7490a75e6ca5..72e9dc44760e 100644
--- a/contrib/ntp/sntp/libopts/Makefile.am
+++ b/contrib/ntp/sntp/libopts/Makefile.am
@@ -6,7 +6,6 @@ else
 noinst_LTLIBRARIES      = libopts.la
 endif
 libopts_la_SOURCES      = libopts.c
-libopts_la_CPPFLAGS     = -I$(srcdir)
 libopts_la_LDFLAGS      = -version-info  42:1:17
 
 EXTRA_DIST		=
@@ -14,8 +13,7 @@ BUILT_SOURCES		=
 MOSTLYCLEANFILES	=
 
 AM_CFLAGS	= $(NTP_HARD_CFLAGS) $(CC_NOFORMAT)
-AM_CPPFLAGS	= $(NTP_HARD_CPPFLAGS)
-AM_LDFLAGS	= $(NTP_HARD_LDFLAGS)
+AM_CPPFLAGS	= $(NTP_HARD_CPPFLAGS) -I$(top_srcdir)/../include
 
 libopts.c:		$(BUILT_SOURCES)
 	@: do-nothing rule to avoid default SCCS get
diff --git a/contrib/ntp/sntp/libopts/Makefile.in b/contrib/ntp/sntp/libopts/Makefile.in
index 448142558e46..1bb5ff038b76 100644
--- a/contrib/ntp/sntp/libopts/Makefile.in
+++ b/contrib/ntp/sntp/libopts/Makefile.in
@@ -98,6 +98,7 @@ am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
 	$(top_srcdir)/m4/ntp_cacheversion.m4 \
 	$(top_srcdir)/m4/ntp_compiler.m4 \
 	$(top_srcdir)/m4/ntp_crosscompile.m4 \
+	$(top_srcdir)/m4/ntp_crypto_rand.m4 \
 	$(top_srcdir)/m4/ntp_debug.m4 $(top_srcdir)/m4/ntp_dir_sep.m4 \
 	$(top_srcdir)/m4/ntp_facilitynames.m4 \
 	$(top_srcdir)/m4/ntp_harden.m4 $(top_srcdir)/m4/ntp_ipv6.m4 \
@@ -153,7 +154,7 @@ am__uninstall_files_from_dir = { \
 am__installdirs = "$(DESTDIR)$(libdir)"
 LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES)
 libopts_la_LIBADD =
-am_libopts_la_OBJECTS = libopts_la-libopts.lo
+am_libopts_la_OBJECTS = libopts.lo
 libopts_la_OBJECTS = $(am_libopts_la_OBJECTS)
 AM_V_lt = $(am__v_lt_@AM_V@)
 am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
@@ -179,7 +180,7 @@ am__v_at_1 =
 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/libevent/build-aux/depcomp
 am__maybe_remake_depfiles = depfiles
-am__depfiles_remade = ./$(DEPDIR)/libopts_la-libopts.Plo
+am__depfiles_remade = ./$(DEPDIR)/libopts.Plo
 am__mv = mv -f
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@@ -372,6 +373,7 @@ PACKAGE_STRING = @PACKAGE_STRING@
 PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_OPENSSL = @PATH_OPENSSL@
 PATH_RUBY = @PATH_RUBY@
 PATH_SEPARATOR = @PATH_SEPARATOR@
 PKG_CONFIG = @PKG_CONFIG@
@@ -464,7 +466,6 @@ MAINTAINERCLEANFILES = Makefile.in
 @INSTALL_LIBOPTS_TRUE@lib_LTLIBRARIES = libopts.la
 @INSTALL_LIBOPTS_FALSE@noinst_LTLIBRARIES = libopts.la
 libopts_la_SOURCES = libopts.c
-libopts_la_CPPFLAGS = -I$(srcdir)
 libopts_la_LDFLAGS = -version-info  42:1:17
 EXTRA_DIST = _Noreturn.h stdnoreturn.in.h COPYING.gplv3 COPYING.lgplv3 \
 	COPYING.mbsd MakeDefs.inc README _Noreturn.h ag-char-map.h \
@@ -484,8 +485,7 @@ EXTRA_DIST = _Noreturn.h stdnoreturn.in.h COPYING.gplv3 COPYING.lgplv3 \
 BUILT_SOURCES = $(STDNORETURN_H)
 MOSTLYCLEANFILES = stdnoreturn.h stdnoreturn.h-t
 AM_CFLAGS = $(NTP_HARD_CFLAGS) $(CC_NOFORMAT)
-AM_CPPFLAGS = $(NTP_HARD_CPPFLAGS)
-AM_LDFLAGS = $(NTP_HARD_LDFLAGS)
+AM_CPPFLAGS = $(NTP_HARD_CPPFLAGS) -I$(top_srcdir)/../include
 
 # Makefile fragment from gnulib-s stdnoreturn module:
 #
@@ -580,7 +580,7 @@ mostlyclean-compile:
 distclean-compile:
 	-rm -f *.tab.c
 
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libopts_la-libopts.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libopts.Plo@am__quote@ # am--include-marker
 
 $(am__depfiles_remade):
 	@$(MKDIR_P) $(@D)
@@ -612,13 +612,6 @@ am--depfiles: $(am__depfiles_remade)
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
 
-libopts_la-libopts.lo: libopts.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libopts_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libopts_la-libopts.lo -MD -MP -MF $(DEPDIR)/libopts_la-libopts.Tpo -c -o libopts_la-libopts.lo `test -f 'libopts.c' || echo '$(srcdir)/'`libopts.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libopts_la-libopts.Tpo $(DEPDIR)/libopts_la-libopts.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='libopts.c' object='libopts_la-libopts.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libopts_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libopts_la-libopts.lo `test -f 'libopts.c' || echo '$(srcdir)/'`libopts.c
-
 mostlyclean-libtool:
 	-rm -f *.lo
 
@@ -758,7 +751,7 @@ clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
 	clean-noinstLTLIBRARIES mostlyclean-am
 
 distclean: distclean-am
-		-rm -f ./$(DEPDIR)/libopts_la-libopts.Plo
+		-rm -f ./$(DEPDIR)/libopts.Plo
 	-rm -f Makefile
 distclean-am: clean-am distclean-compile distclean-generic \
 	distclean-tags
@@ -804,7 +797,7 @@ install-ps-am:
 installcheck-am:
 
 maintainer-clean: maintainer-clean-am
-		-rm -f ./$(DEPDIR)/libopts_la-libopts.Plo
+		-rm -f ./$(DEPDIR)/libopts.Plo
 	-rm -f Makefile
 maintainer-clean-am: distclean-am maintainer-clean-generic
 
diff --git a/contrib/ntp/sntp/m4/ntp_compiler.m4 b/contrib/ntp/sntp/m4/ntp_compiler.m4
index ddce106fe522..7a00e64c8439 100644
--- a/contrib/ntp/sntp/m4/ntp_compiler.m4
+++ b/contrib/ntp/sntp/m4/ntp_compiler.m4
@@ -1,17 +1,10 @@
 dnl ######################################################################
 dnl Common m4sh code for compiler stuff
 AC_DEFUN([NTP_COMPILER], [
+AC_REQUIRE([AC_PROG_CC_STDC])
 
 AC_USE_SYSTEM_EXTENSIONS
 
-# Ralf Wildenhues: With per-target flags we need CC_C_O
-# AM_PROG_CC_C_O supersets AC_PROG_CC_C_O
-AM_PROG_CC_C_O
-AC_PROG_GCC_TRADITIONAL
-AC_REQUIRE([AC_PROG_CC_STDC])
-dnl AC_REQUIRE([AC_PROG_CC_C89])
-dnl AC_REQUIRE([AC_PROG_CC_C99])
-
 CC_NOFORMAT=
 CFLAGS_NTP=
 CPPFLAGS_NTP=
@@ -104,13 +97,15 @@ case "$GCC" in
 	]
     )
     #
+    # $ntp_cv_gcc_Winit_self is tested later to add the 
+    # flag to CFLAGS_NTP.
+    #
     # libopts specifically builds a string with embedded NULs.
     # This causes a bunch of distracting warnings due to -Wformat.
-    # Let's see if we can figure out how to disable these.
     #
-    CFLAGS="$SAVED_CFLAGS -Wno-format"
+    CFLAGS="$SAVED_CFLAGS -Wno-format -Wno-format-security"
     AC_CACHE_CHECK(
-	[if $CC can handle -Wno-format], 
+	[if $CC can handle -Wno-format -Wno-format-security], 
 	[ntp_cv_gcc_Wno_format],
 	[
 	    AC_COMPILE_IFELSE(
@@ -120,35 +115,44 @@ case "$GCC" in
 	    )
 	]
     )
-
     case "$ntp_cv_gcc_Wno_format" in
+      no) ntp_cv_gcc_Wno_format_truncation=no
+	  ;;
      yes)
-	CC_NOFORMAT="$CC_NOFORMAT -Wno-format"
-	;;
-     no)
-	;;
+	CC_NOFORMAT="-Wno-format -Wno-format-security"
+	CFLAGS="$SAVED_CFLAGS -Wformat -Wno-format-truncation -Werror"
+	AC_CACHE_CHECK(
+		[if $CC can handle -Wformat -Wno-format-truncation], 
+		[ntp_cv_gcc_Wno_format_truncation], 
+		[AC_COMPILE_IFELSE(
+		    [AC_LANG_PROGRAM([[]], [[]])],
+		    [ntp_cv_gcc_Wno_format_truncation=yes],
+		    [ntp_cv_gcc_Wno_format_truncation=no]
+		)	]
+	)
+	#
+	# $ntp_cv_gcc_Wno_format_truncation is tested later to add the 
+	# flag to CFLAGS.
+	#
     esac
 
     CFLAGS="$SAVED_CFLAGS"
     AS_UNSET([SAVED_CFLAGS])
-    #
-    # $ntp_cv_gcc_Winit_self is tested later to add the 
-    # flag to CFLAGS_NTP.
-    #
+
     AC_CACHE_CHECK(
 	[if linker supports omitting unused code and data],
 	[ntp_cv_gc_sections_runs],
 	[
-	    dnl  NetBSD will link but likely not run with --gc-sections
-	    dnl  http://bugs.ntp.org/1844
-	    dnl  http://gnats.netbsd.org/40401
-	    dnl  --gc-sections causes attempt to load as linux elf, with
-	    dnl  wrong syscalls in place.  Test a little gauntlet of
-	    dnl  simple stdio read code checking for errors, expecting
-	    dnl  enough syscall differences that the NetBSD code will
-	    dnl  fail even with Linux emulation working as designed.
-	    dnl  A shorter test could be refined by someone with access
-	    dnl  to a NetBSD host with Linux emulation working.
+	    #  NetBSD will link but likely not run with --gc-sections
+	    #  http://bugs.ntp.org/1844
+	    #  http://gnats.netbsd.org/40401
+	    #  --gc-sections causes attempt to load as linux elf, with
+	    #  wrong syscalls in place.  Test a little gauntlet of
+	    #  simple stdio read code checking for errors, expecting
+	    #  enough syscall differences that the NetBSD code will
+	    #  fail even with Linux emulation working as designed.
+	    #  A shorter test could be refined by someone with access
+	    #  to a NetBSD host with Linux emulation working.
 	    origCFLAGS="$CFLAGS"
 	    CFLAGS="$CFLAGS -Wl,--gc-sections"
 	    AC_LINK_IFELSE(
@@ -223,6 +227,10 @@ case "$GCC" in
      yes)
 	CFLAGS_NTP="$CFLAGS_NTP -Wstrict-overflow"
     esac
+    case "$ntp_cv_gcc_Wno_format_truncation" in
+     yes)
+	CFLAGS_NTP="$CFLAGS_NTP -Wno-format-truncation"
+    esac
     # -W[no-]strict-prototypes might be added by NTP_OPENSSL
 esac
 
diff --git a/contrib/ntp/sntp/m4/ntp_crypto_rand.m4 b/contrib/ntp/sntp/m4/ntp_crypto_rand.m4
index 9d554226f44c..391f1cbd5992 100644
--- a/contrib/ntp/sntp/m4/ntp_crypto_rand.m4
+++ b/contrib/ntp/sntp/m4/ntp_crypto_rand.m4
@@ -25,15 +25,15 @@ dnl if that's not specified:
 dnl - Look for RAND_poll and RAND_bytes
 dnl - if they exist, define USE_OPENSSL_CRYPTO_RAND
 
-AC_MSG_CHECKING([if we want to use OpenSSL's crypto random (if available)])
+AC_MSG_CHECKING([if we want to use SSL library's secure random numbers])
 AC_ARG_ENABLE(
     [openssl-random],
     [AS_HELP_STRING(
     	[--enable-openssl-random],
-	[Use OpenSSL's crypto random number functions, if available (default is yes)]
+	[+ Use SSL lib's secure random numbers]
     )],
-    [ntp_use_openssl_random=$enableval],
-    [ntp_use_openssl_random=yes]
+    [ntp_use_openssl_random=$enableval ; ntp_ssl_random_mandatory=$enableval],
+    [ntp_use_openssl_random=yes ; ntp_ssl_random_mandatory=no]
 )
 AC_MSG_RESULT([$ntp_use_openssl_random])
 
@@ -45,10 +45,33 @@ AC_CHECK_FUNCS([RAND_bytes RAND_poll])
 LIBS="$NTPO_SAVED_LIBS"
 case "$ntp_openssl$ntp_use_openssl_random$ac_cv_func_RAND_bytes$ac_cv_func_RAND_poll" in
  yesyesyesyes)
-     AC_DEFINE([USE_OPENSSL_CRYPTO_RAND], [1], [Use OpenSSL's crypto random functions])
-     ;;
- *) ntp_use_openssl_random=no ;;
+    AC_MSG_NOTICE([Using SSL library's secure random number generator])
+    AC_DEFINE([USE_OPENSSL_CRYPTO_RAND], [1], [Use OpenSSL's crypto random functions])
+    ;;
+ *)
+    ntp_use_openssl_random=no
+    AC_MSG_NOTICE([SSL library's secure random number generator unavailable.])
+    case "$ntp_ssl_random_mandatory" in
+     yes)
+	AC_MSG_ERROR(
+[No suitable SSL library was found and
+--enable-openssl-random was given..  Remove --enable-openssl-random
+if you wish to build without a cryptographically secure random number
+generator.
+
+WARNING: Use of ntp-keygen without a secure RNG may generate
+-------  keys that are predictable.]
+	)
+	;;
+     *)
+	AC_MSG_WARN(
+[WARNING: Use of ntp-keygen without a secure RNG may generate
+-------  keys that are predictable.]
+	)
+    esac
 esac
 
+AS_UNSET([ntp_ssl_random_mandatory])
+
 ]) dnl NTP_CRYPTO_RAND
 
diff --git a/contrib/ntp/sntp/m4/ntp_facilitynames.m4 b/contrib/ntp/sntp/m4/ntp_facilitynames.m4
index f58f8943890d..5b79fafe363e 100644
--- a/contrib/ntp/sntp/m4/ntp_facilitynames.m4
+++ b/contrib/ntp/sntp/m4/ntp_facilitynames.m4
@@ -1,24 +1,31 @@
 dnl ######################################################################
 dnl Check syslog.h for 'facilitynames' table
 AC_DEFUN([NTP_FACILITYNAMES], [
-AC_CACHE_CHECK([for facilitynames in syslog.h],ac_cv_HAVE_SYSLOG_FACILITYNAMES,[
-AC_TRY_COMPILE([
-#define SYSLOG_NAMES
-#include <stdlib.h>
-#include <syslog.h>
-],
-[ void *fnames; fnames = facilitynames; ],
-ac_cv_HAVE_SYSLOG_FACILITYNAMES=yes,ac_cv_HAVE_SYSLOG_FACILITYNAMES=no,ac_cv_HAVE_SYSLOG_FACILITYNAMES=cross)])
+
+AC_CACHE_CHECK(
+    [for facilitynames in syslog.h],
+    [ac_cv_HAVE_SYSLOG_FACILITYNAMES],
+    [AC_COMPILE_IFELSE(
+	[AC_LANG_PROGRAM(
+	    [[
+		#define SYSLOG_NAMES
+		#include <stdlib.h>
+		#include <syslog.h>
+	    ]],
+	    [[
+		void *fnames = facilitynames;
+	    ]]
+	)]
+	[ac_cv_HAVE_SYSLOG_FACILITYNAMES=yes],
+	[ac_cv_HAVE_SYSLOG_FACILITYNAMES=no]
+    )]
+)
 case "$ac_cv_HAVE_SYSLOG_FACILITYNAMES" in
  yes)
-    AC_DEFINE(HAVE_SYSLOG_FACILITYNAMES,1,[ ])
+    AC_DEFINE([HAVE_SYSLOG_FACILITYNAMES], [1], [syslog.h provides facilitynames])
     ;;
  no)
     AC_MSG_WARN([No facilitynames in <syslog.h>])
-    ;;
- cross)
-    AC_MSG_WARN([facilitynames in <syslog.h> - cross-compiling])
-    ;;
 esac
 ])
 dnl ======================================================================
diff --git a/contrib/ntp/sntp/m4/ntp_libevent.m4 b/contrib/ntp/sntp/m4/ntp_libevent.m4
index 14b614b465a3..451eac58fb06 100644
--- a/contrib/ntp/sntp/m4/ntp_libevent.m4
+++ b/contrib/ntp/sntp/m4/ntp_libevent.m4
@@ -74,7 +74,6 @@ case "$ntp_use_local_libevent" in
  *) # If we have (a good enough) pkg-config, see if it can find libevent
     case "$PKG_CONFIG" in
      /*)
-	AC_MSG_CHECKING([if libevent $ntp_libevent_min_version or later is installed])
 	if $PKG_CONFIG --atleast-version=$ntp_libevent_min_version libevent
 	then
 	    ntp_use_local_libevent=no
@@ -83,6 +82,7 @@ case "$ntp_use_local_libevent" in
 	     *.*) ;;
 	     *) ntp_libevent_version='(unknown)' ;;
 	    esac
+	    AC_MSG_CHECKING([if libevent $ntp_libevent_min_version or later is installed])
 	    AC_MSG_RESULT([yes, version $ntp_libevent_version])
 	    CFLAGS_LIBEVENT=`$PKG_CONFIG --cflags libevent_pthreads`
 	    CPPFLAGS_LIBEVENT=`$PKG_CONFIG --cflags-only-I libevent`
@@ -116,6 +116,7 @@ case "$ntp_use_local_libevent" in
 	    # HMS: do we only need to do this if LIBISC_PTHREADS_NOTHREADS
 	    # is "pthreads"?
 	    CFLAGS_LIBEVENT=`$PKG_CONFIG --cflags libevent_pthreads`
+	    AC_MSG_CHECKING([if libevent $ntp_libevent_min_version or later is installed])
 	    AC_MSG_RESULT([no])
 	fi
 	;;
@@ -181,14 +182,15 @@ case "$ntp_use_local_libevent" in
     dnl User-supplied contradictory choices should prevail thanks to
     dnl "last wins".
     ac_configure_args=" --disable-openssl${ac_configure_args}"
+    ac_configure_args=" --disable-samples${ac_configure_args}"
     ac_configure_args=" --disable-shared${ac_configure_args}"
     ac_configure_args=" --disable-libevent-regress${ac_configure_args}"
     ac_configure_args=" --disable-libevent-install${ac_configure_args}"
     ac_configure_args=" --enable-silent-rules${ac_configure_args}"
     ac_configure_args=" --enable-function-sections${ac_configure_args}"
-    ac_configure_args=" LEP_CFLAGS='${NTP_HARD_CFLAGS}'${ac_configure_args}"
-    ac_configure_args=" LEP_CPPFLAGS='${NTP_HARD_CPPFLAGS}'${ac_configure_args}"
-    ac_configure_args=" LEP_LDFLAGS='${NTP_HARD_LDFLAGS}'${ac_configure_args}"
+    ac_configure_args=" LIBEVENT_CFLAGS='${NTP_HARD_CFLAGS}'${ac_configure_args}"
+    ac_configure_args=" LIBEVENT_CPPFLAGS='${NTP_HARD_CPPFLAGS}'${ac_configure_args}"
+    ac_configure_args=" LIBEVENT_LDFLAGS='${NTP_HARD_LDFLAGS}'${ac_configure_args}"
     AC_CONFIG_SUBDIRS([libevent])
     ;;
  *)
diff --git a/contrib/ntp/sntp/m4/ntp_libntp.m4 b/contrib/ntp/sntp/m4/ntp_libntp.m4
index 21d0cff82c07..e0cc2169aa59 100644
--- a/contrib/ntp/sntp/m4/ntp_libntp.m4
+++ b/contrib/ntp/sntp/m4/ntp_libntp.m4
@@ -8,12 +8,13 @@ dnl subpackage while retaining access to such test results.
 dnl
 AC_DEFUN([NTP_LIBNTP], [
 
+AC_REQUIRE([AC_PROG_SED])
 AC_REQUIRE([NTP_CROSSCOMPILE])
 
 # HMS: Save $LIBS and empty it.
 # any LIBS we add here should go in to LDADD_LIBNTP
 AC_SUBST([LDADD_LIBNTP])
-__LIBS=$LIBS
+SAVED_LIBS=$LIBS
 LIBS=
 
 dnl The contents of NTP_PROG_CC used to be here...
@@ -267,7 +268,7 @@ case "$ac_cv_c_inline" in
     AC_SUBST([HAVE_INLINE])
 esac
 
-AC_HEADER_TIME
+
 AC_CHECK_SIZEOF([time_t])
 AC_C_CHAR_UNSIGNED		dnl CROSS_COMPILE?
 AC_CHECK_SIZEOF([signed char])
@@ -490,7 +491,10 @@ AC_DEFUN([NTP_BEFORE_HW_FUNC_VSNPRINTF], [
     AC_BEFORE([$0], [HW_FUNC_SNPRINTF])dnl
     AC_ARG_ENABLE(
 	[c99-snprintf],
-	[AS_HELP_STRING([--enable-c99-snprintf], [s force replacement])],
+	[AS_HELP_STRING(
+	    [--enable-c99-snprintf],
+	    [s use replacement printf family]
+	)],
 	[force_c99_snprintf=$enableval],
 	[force_c99_snprintf=no]
 	)
@@ -501,15 +505,8 @@ AC_DEFUN([NTP_BEFORE_HW_FUNC_VSNPRINTF], [
     esac
     AH_VERBATIM(
 	[snprinte],dnl	sorted in config.h just before #define snprintf
-	[
-	    #if !defined(_KERNEL) && !defined(PARSESTREAM)
-	    /*
-	     * stdio.h must be included after _GNU_SOURCE is defined
-	     * but before #define snprintf rpl_snprintf
-	     */
-	    # include <stdio.h>	
-	    #endif
-	])
+	[#include "c99_snprintf.h"]
+    )
     AH_BOTTOM([
 	#if !defined(_KERNEL) && !defined(PARSESTREAM)
 	# if defined(HW_WANT_RPL_VSNPRINTF)
@@ -752,62 +749,6 @@ typedef unsigned int	uintptr_t;
 #define HAVE_UINTPTR_T	1
 #endif])
 
-case "$ac_cv_type_int32::$ac_cv_header_resolv_h" in
- no::yes)
-    AC_CACHE_CHECK(
-	[for int32 with DNS headers included],
-	[ntp_cv_type_int32_with_dns],
-	[AC_COMPILE_IFELSE(
-	    [AC_LANG_PROGRAM(
-		[[
-		    #ifdef HAVE_ARPA_NAMESER_H
-		    # include <arpa/nameser.h>
-		    #endif
-		    #include <resolv.h>
-		]],
-		[[
-		    size_t cb = sizeof(int32);
-		]]
-	    )],
-	    [ntp_cv_type_int32_with_dns=yes],
-	    [ntp_cv_type_int32_with_dns=no]
-	)]
-    )
-    case "$ntp_cv_type_int32_with_dns" in
-     yes)
-	AC_DEFINE([HAVE_INT32_ONLY_WITH_DNS], [1],
-	    [int32 type in DNS headers, not others.])
-    esac
-esac
-
-case "$ac_cv_type_u_int32::$ac_cv_header_resolv_h" in
- no::yes)
-    AC_CACHE_CHECK(
-	[for u_int32 with DNS headers included],
-	[ntp_cv_type_u_int32_with_dns],
-	[AC_COMPILE_IFELSE(
-	    [AC_LANG_PROGRAM(
-		[[
-		    #ifdef HAVE_ARPA_NAMESER_H
-		    # include <arpa/nameser.h>
-		    #endif
-		    #include <resolv.h>
-		]],
-		[[
-		    size_t cb = sizeof(u_int32);
-		]]
-	    )],
-	    [ntp_cv_type_u_int32_with_dns=yes],
-	    [ntp_cv_type_u_int32_with_dns=no]
-	)]
-    )
-    case "$ntp_cv_type_u_int32_with_dns" in
-     yes)
-	AC_DEFINE([HAVE_U_INT32_ONLY_WITH_DNS], [1],
-	    [u_int32 type in DNS headers, not others.])
-    esac
-esac
-
 AC_CHECK_HEADERS(
     [sys/timepps.h],
     [],
@@ -1176,11 +1117,19 @@ case "$ntp_warning" in
     ;;
 esac
 
+dnl Do not ensure libntp.a is up to date when building client directories
+dnl if --disable-dependency-tracking is used to save build time for one-off
+dnl build from tarball.  It's only useful when modifying libntp source code
+dnl and rebuilding in a client subdir rather than the whole package.
+AM_CONDITIONAL([LIBNTP_SUBMAKES], [test x"$enable_dependency_tracking" = x"yes"])
+
+NTP_OPENSSL
+NTP_CRYPTO_RAND
 
 dnl add to LDADD_LIBNTP set by ntp_compiler.m4
 LDADD_LIBNTP="$LDADD_LIBNTP $LIBS"
-LIBS=$__LIBS
-AS_UNSET([__LIBS])
+LIBS=$SAVED_LIBS
+AS_UNSET([SAVED_LIBS])
 
 ])dnl
 dnl ======================================================================
diff --git a/contrib/ntp/sntp/m4/ntp_openssl.m4 b/contrib/ntp/sntp/m4/ntp_openssl.m4
index 2f9d6c4318ad..74cfdf08b749 100644
--- a/contrib/ntp/sntp/m4/ntp_openssl.m4
+++ b/contrib/ntp/sntp/m4/ntp_openssl.m4
@@ -2,18 +2,22 @@ dnl ####################################################################
 dnl OpenSSL support shared by top-level and sntp/configure.ac
 dnl
 dnl Provides command-line option --with-crypto, as well as deprecated
-dnl options --with-openssl-incdir, --with-openssl-libdir, and the
-dnl latter's suboption --with-rpath.
+dnl options --with-openssl-incdir, --with-openssl-libdir..
 dnl
-dnl Specifying --with-openssl-libdir or --with-openssl-incdir causes any
-dnl pkg-config openssl information to be ignored in favor of the legacy
-dnl manual search for directories and specified library names.
+dnl Specifying --with-openssl-libdir or --with-openssl-incdir skips
+dnl pkg-config search.
+dnl
+dnl In the past, use of crypto would be silently disabled if the needed
+dnl headers and library were not found.  Now --without-crypto must be
+dnl used or configure will fail with an error.  It is now uncommon
+dnl to want to build ntpd without crypto, so don't be quiet about it.
 dnl
 dnl Output AC_DEFINEs (for config.h)
 dnl	OPENSSL		defined only if using OpenSSL
 dnl
 dnl Output variables:
 dnl	ntp_openssl	yes if using OpenSSL, no otherwise
+dnl	VER_SUFFIX	"o" if using OpenSSL
 dnl
 dnl Output substitutions:
 dnl	CFLAGS_NTP	OpenSSL-specific flags added as needed, and
@@ -22,19 +26,29 @@ dnl			trigger a flood of warnings for each file
 dnl			including OpenSSL headers.
 dnl	CPPFLAGS_NTP	OpenSSL -Iincludedir flags added as needed.
 dnl	LDADD_NTP	OpenSSL -L and -l flags added as needed.
-dnl	LDFLAGS_NTP	Other OpenSSL link flags added as needed.
+dnl	LDFLAGS_NTP	OpenSSL runpath flags as needed.
 dnl
 dnl ####################################################################
+dnl
 AC_DEFUN([NTP_OPENSSL], [
+AC_REQUIRE([AC_PROG_SED])dnl
 AC_REQUIRE([NTP_PKG_CONFIG])dnl
 AC_REQUIRE([NTP_VER_SUFFIX])dnl
+AC_REQUIRE([NTP_OPENSSL_VERBOSE_MSG])dnl
 
 AC_ARG_WITH(
     [crypto],
     [AS_HELP_STRING(
 	[--with-crypto],
 	[+ =openssl,libcrypto]
-    )]
+    )],
+    [	dnl if given
+	case "$with_crypto" in
+	 yes)
+	    with_crypto=openssl,libcrypto
+	esac
+    ],
+    [with_crypto=openssl,libcrypto]	dnl if not given
 )
 AC_ARG_WITH(
     [openssl-libdir],
@@ -47,42 +61,180 @@ AC_ARG_WITH(
     [openssl-incdir],
     [AS_HELP_STRING(
 	[--with-openssl-incdir],
-	[+ =/something/reasonable]
+	[+ =search likely dirs]
     )]
 )
-AC_ARG_WITH(
-    [rpath],
+AC_ARG_ENABLE(
+    [verbose-ssl],
     [AS_HELP_STRING(
-	[--without-rpath],
-	[s Disable auto-added -R linker paths]
-    )]
+	[--enable-verbose-ssl],
+	[- show crypto lib detection details]
+    )],
+    [],
+    [enable_verbose_ssl=no]	dnl default to quiet
 )
 
 ntp_openssl=no
 ntp_openssl_from_pkg_config=no
+ntp_ssl_incdir=
+ntp_ssl_cflags=
+ntp_ssl_cppflags=
+ntp_ssl_libdir=
+ntp_ssl_libs_L=
+ntp_ssl_libs_l=
+ntp_ssl_libs=
+ntp_ssl_ldflags=
 
-with_crypto=${with_crypto:-openssl,libcrypto}
-case "$with_crypto" in
- yes)
-    with_crypto=openssl,libcrypto
-esac
+NTPSSL_SAVED_CFLAGS="$CFLAGS"
+NTPSSL_SAVED_CPPFLAGS="$CPPFLAGS"
+NTPSSL_SAVED_LIBS="$LIBS"
+NTPSSL_SAVED_LDFLAGS="$LDFLAGS"
 
-dnl AC_MSG_NOTICE(['%with_crypto:%{PKG_CONFIG:+notempty}:%{with_openssl_libdir-notgiven}:%{with_openssl_incdir-notgiven}'])
-dnl str="$with_crypto:${PKG_CONFIG:+notempty}:${with_openssl_libdir-notgiven}:${with_openssl_incdir-notgiven}"
-dnl AC_MSG_NOTICE([$str])
+AC_PATH_PROG([PATH_OPENSSL], [openssl])
 
+str="$with_crypto:${PKG_CONFIG:+notempty}:${with_openssl_libdir-notgiven}:${with_openssl_incdir-notgiven}"
+NTP_OPENSSL_VERBOSE_MSG([$str])
+AS_UNSET([str])
+
+# Make sure neither/both --with_openssl-{inc,lib}dir are given
+case "${with_openssl_libdir-notgiven}:${with_openssl_incdir-notgiven}" in
+ notgiven:notgiven) ;;
+ *notgiven*)
+    AC_MSG_ERROR([only one of --with-openssl-{inc,lib}dir=... given - provide both or neither])
+    ;;
+esac
+
+# HMS: Today there are only 2 case options.  We probably want a third
+# *:*:notgiven:notgiven
+# and in that case we would validate the path in PKG_CONFIG_PATH.
+# Unless we can do it with 2 cases, where the 2nd case is *:*:...
+# and we do a reality check on execpath and the headers/libraries.
+#
+##
+# if $with_crypto is not "no":
+#   if --with-openssl-{inc,lib}dir are not given:
+#     we should use pkg-config to find openssl
+#     if we don't have pkg-config, if openssl is in the base OS, use that.
+##
 case "$with_crypto:${PKG_CONFIG:+notempty}:${with_openssl_libdir-notgiven}:${with_openssl_incdir-notgiven}" in
  no:*) ;;
  *:notempty:notgiven:notgiven)
-    for pkg in `echo $with_crypto | sed -e 's/,/ /'`; do
+    # If PKG_CONFIG is notempty and we haven't been given openssl paths,
+    # then let's make sure that the openssl executable's path corresponds
+    # to the path in openssl.pc, and 'openssl version' matches the Version
+    # in openssl.pc.  If $PKG_CONFIG tells us an INCPATH and/or a LIBPATH,
+    # then should we reality check them?
+    ## INCPATH
+    # harlan@ntp-testbuild.tal1> openssl version
+    # OpenSSL 1.1.1t  7 Feb 2023
+    # harlan@ntp-testbuild.tal1> grep 1.1.1t /ntpbuild/include/openssl/*
+    # /ntpbuild/include/openssl/opensslv.h:# define OPENSSL_VERSION_TEXT    "OpenSSL 1.1.1t  7 Feb 2023"
+    # harlan@ntp-testbuild.tal1>
+    ## LIBPATH
+    # harlan@ntp-testbuild.tal1> strings -a /ntpbuild/lib/libcrypto.* | fgrep 1.1.1t
+    # OpenSSL 1.1.1t  7 Feb 2023
+    # OpenSSL 1.1.1t  7 Feb 2023
+    # OpenSSL 1.1.1t  7 Feb 2023
+    # harlan@ntp-testbuild.tal1> ls /ntpbuild/lib/libcrypto.*
+    # /ntpbuild/lib/libcrypto.a       /ntpbuild/lib/libcrypto.so.1.1*
+    # /ntpbuild/lib/libcrypto.so@
+    # harlan@ntp-testbuild.tal1>
+    ##
+    # Having said this, do we really care if the openssl executable that
+    # we have found is matched with the INCPATH and LIBPATH?
+    # One answer: Probably not, but we should complain on a mismatch as
+    # otherwise runtime differences could easily cause problems/drama.
+
+    ##BO
+    # ntp_cv_build_framework_help=yes
+    save_PKG_CONFIG_PATH=${PKG_CONFIG_PATH}
+    for pkg in `echo $with_crypto | $SED -e 's/,/ /'`; do
+        case "$pkg" in
+	 openssl)
+	    if $PKG_CONFIG --exists $pkg ; then
+		# Found it - yay
+		# Do we want to check we found the right one?
+		# --modver
+		# --variable={libdir,includedir} (varname)
+		overf=`openssl version`
+		overs=`echo $overf | awk '{print $2}'`
+		case "$overs" in
+		 0.*) ;;	# Should we squawk?
+		 1.0.*) ;;	# Should we squawk?
+		 1.1.*) ;;	# Should we squawk?
+		 3.*)
+		    oinc=`openssl --variable=includedir`
+		    olib=`openssl --variable=libdir`
+		    # How should we use these?
+		    ;;
+		 *) ;;	# Should we squawk?
+		esac
+		# /ntpbuild/include/openssl/opensslv.h:# define OPENSSL_VERSION_TEXT    "OpenSSL 1.1.1t  7 Feb 2023"
+		# grep 1.1.1t /ntpbuild/lib/libcrypto.a
+		# strings -a /ntpbuild/lib/libcrypto.a | grep 1.1.1t
+		# OpenSSL 1.1.1t  7 Feb 2023
+		# harlan@ntp-testbuild.tal1>
+		# which should match $overf
+		##
+		# harlan@ntp-testbuild.tal1> echo '"OpenSSL 1.1.1t  7 Feb 2023"' | cut -f 2 -d\"
+		# OpenSSL 1.1.1t  7 Feb 2023
+		# harlan@ntp-testbuild.tal1> grep OPENSSL_VERSION_TEXT /ntpbuild/include/openssl/opensslv.h
+		# # define OPENSSL_VERSION_TEXT    "OpenSSL 1.1.1t  7 Feb 2023"
+		# harlan@ntp-testbuild.tal1>
+		##
+
+	    else
+		# This is a hack, but it's reasonable.
+		pkgpath="`echo $PATH_OPENSSL | sed -e 's:/bin/openssl$::'`/lib/pkgconfig"
+		test -d "$pkgpath" || pkgpath=
+		# echo "pkgpath is <$pkgpath>"
+		# echo "PKG_CONFIG_PATH is <$PKG_CONFIG_PATH>"
+		case "$pkgpath" in
+		 '') ;;	# Nothing to see here...
+		 *) case ":$PKG_CONFIG_PATH:" in
+		     ::)
+			PKG_CONFIG_PATH=$pkgpath
+			export PKG_CONFIG_PATH
+			;;
+		     *:$pkgpath:*)
+			# Already there...
+			;;
+		     *)
+			PKG_CONFIG_PATH="$pkgpath:$PKG_CONFIG_PATH"
+			export PKG_CONFIG_PATH
+			;;
+		    esac
+		    ;;
+		esac
+	    fi
+	    ;;
+        esac
+    done
+    ##EO
+
+    for pkg in `echo $with_crypto | $SED -e 's/,/ /'`; do
 	AC_MSG_CHECKING([pkg-config for $pkg])
 	if $PKG_CONFIG --exists $pkg ; then
-	    CPPFLAGS_NTP="$CPPFLAGS_NTP `$PKG_CONFIG --cflags-only-I $pkg`"
-	    CFLAGS_NTP="$CFLAGS_NTP `$PKG_CONFIG --cflags-only-other $pkg`"
-	    LDADD_NTP="$LDADD_NTP `$PKG_CONFIG --libs-only-L $pkg`"
-	    LDADD_NTP="$LDADD_NTP `$PKG_CONFIG --libs-only-l --static $pkg`"
-	    LDFLAGS_NTP="$LDFLAGS_NTP `$PKG_CONFIG --libs-only-other $pkg`"
-	    VER_SUFFIX=o
+	    ntp_ssl_cppflags="`$PKG_CONFIG --cflags-only-I $pkg`"
+	    case "$ntp_ssl_cppflags" in
+	     '')
+		ntp_ssl_incdir='not needed'
+		;;
+	     *)
+		ntp_ssl_incdir="`echo $ntp_ssl_cppflags | $SED -e 's/-I//'`"
+	    esac
+	    ntp_ssl_cflags="`$PKG_CONFIG --cflags-only-other $pkg`"
+	    ntp_ssl_libs_L="`$PKG_CONFIG --libs-only-L $pkg`"
+	    case "$ntp_ssl_libs_L" in
+	     '')
+		ntp_ssl_libdir='not needed'
+		;;
+	     *)
+		ntp_ssl_libdir="`echo $ntp_ssl_libs_L | $SED -e 's/-L//'`"
+	    esac
+	    ntp_ssl_libs_l="`$PKG_CONFIG --libs-only-l $pkg`"
+	    ntp_ssl_libs="$ntp_ssl_libs_L $ntp_ssl_libs_l"
+	    ntp_ssl_ldflags="`$PKG_CONFIG --libs-only-other $pkg`"
 	    ntp_openssl=yes
 	    ntp_openssl_from_pkg_config=yes
 	    ntp_openssl_version="`$PKG_CONFIG --modversion $pkg`"
@@ -96,184 +248,304 @@ case "$with_crypto:${PKG_CONFIG:+notempty}:${with_openssl_libdir-notgiven}:${wit
 	fi
 	AC_MSG_RESULT([no])
     done
+    AS_UNSET([pkg])
 esac
-dnl AC_MSG_NOTICE([OpenSSL Phase I checks:])
-dnl AC_MSG_NOTICE([CPPFLAGS_NTP: $CPPFLAGS_NTP])
-dnl AC_MSG_NOTICE([CFLAGS_NTP: $CFLAGS_NTP])
-dnl AC_MSG_NOTICE([LDADD_NTP: $LDADD_NTP])
-dnl AC_MSG_NOTICE([LDFLAGS_NTP: $LDFLAGS_NTP])
-case "$with_crypto:$ntp_openssl" in
- no:*) ;;
- *:no)
-    need_dash_r=
-    need_dash_Wlrpath=
-    case "${with_rpath-notgiven}" in
-     yes)
-	# Lame - what to do if we need -Wl... but not -R?
-	need_dash_r=1
-	;;
-     notgiven)
-	case "$host" in
-	 *-*-linux*)
-	    # This may really only be true for gcc
-	    need_dash_Wlrpath=1
-	    ;;
-	 *-*-netbsd*)
-	    need_dash_r=1
-	    ;;
-	 *-*-solaris*)
-	    need_dash_r=1
-	    ;;
-	esac
-	;;
-    esac
-
-    AC_MSG_CHECKING([for openssl library directory])
-    with_openssl_libdir=${with_openssl_libdir-notgiven}
+case "$with_crypto" in
+ no) ;;
+ *)
     case "$with_openssl_libdir" in
-     notgiven)
-	case "$build" in
-	 $host)
-	    with_openssl_libdir=default
-	    ;;
-	 *)
-	    with_openssl_libdir=no
-	    ;;
-	esac
+     '') ;;
+     *)
+	ntp_ssl_libdir="$with_openssl_libdir"
+	ntp_ssl_libs_L="-L$with_openssl_libdir"
+	ntp_ssl_libs_l="-lcrypto"
+	ntp_ssl_libs="$ntp_ssl_libs_L $ntp_ssl_libs_l"
     esac
-    case "$with_openssl_libdir" in
-     default)
-	# Look in:
-	with_openssl_libdir="/usr/lib /usr/lib/openssl /usr/sfw/lib"
-	with_openssl_libdir="$with_openssl_libdir /usr/local/lib"
-	with_openssl_libdir="$with_openssl_libdir /usr/local/ssl/lib /lib"
+    case "$with_openssl_incdir" in
+     '') ;;
+     *)
+	ntp_ssl_incdir="$with_openssl_incdir"
+	ntp_ssl_cppflags="-I$with_openssl_incdir"
     esac
-    case "$with_openssl_libdir" in
-     no)
+esac
+
+NTP_OPENSSL_VERBOSE_MSG([OpenSSL Phase I checks:])
+NTP_OPENSSL_VERBOSE_MSG([CPPFLAGS_NTP: ($CPPFLAGS_NTP)])
+NTP_OPENSSL_VERBOSE_MSG([CFLAGS_NTP:   ($CFLAGS_NTP)])
+NTP_OPENSSL_VERBOSE_MSG([LDADD_NTP:    ($LDADD_NTP)])
+NTP_OPENSSL_VERBOSE_MSG([LDFLAGS_NTP:  ($LDFLAGS_NTP)])
+NTP_OPENSSL_VERBOSE_MSG([ntp_openssl_from_pkg_config: $ntp_openssl_from_pkg_config])
+NTP_OPENSSL_VERBOSE_MSG([ntp_ssl_incdir:   ($ntp_ssl_incdir)])
+NTP_OPENSSL_VERBOSE_MSG([ntp_ssl_libdir:   ($ntp_ssl_libdir)])
+NTP_OPENSSL_VERBOSE_MSG([ntp_ssl_cflags:   ($ntp_ssl_cflags)])
+NTP_OPENSSL_VERBOSE_MSG([ntp_ssl_cppflags: ($ntp_ssl_cppflags)])
+NTP_OPENSSL_VERBOSE_MSG([ntp_ssl_libs_L:   ($ntp_ssl_libs_L)])
+NTP_OPENSSL_VERBOSE_MSG([ntp_ssl_libs_l:   ($ntp_ssl_libs_l)])
+NTP_OPENSSL_VERBOSE_MSG([ntp_ssl_libs:     ($ntp_ssl_libs)])
+NTP_OPENSSL_VERBOSE_MSG([ntp_ssl_ldflags:  ($ntp_ssl_ldflags)])
+
+case "$with_crypto" in
+ no)
+    ntp_openssl=no
+    ;;
+ *)
+    ntp_ssl_libs_l="${ntp_ssl_libs_l:--lcrypto}"
+    ntp_ssl_libs="$ntp_ssl_libs_L $ntp_ssl_libs_l"
+    case "$ntp_ssl_libdir" in
+     '')
+	dnl ### set ntp_ssl_libdir ###
+
+	dnl unconventional, using AC_CHECK_LIB repeatedly, clear cached result.
+	AS_UNSET([ac_cv_lib_crypto_EVP_MD_CTX_new])
+	AC_MSG_NOTICE([Searching for libcrypto without -L])
+	AC_CHECK_LIB(
+	    [crypto],
+	    [EVP_MD_CTX_new],
+	    [ntp_ssl_libdir='not needed']
+	)
+	dnl unconventional, using AC_CHECK_LIB repeatedly, clear cached result.
+	AS_UNSET([ac_cv_lib_crypto_EVP_MD_CTX_new])
+    esac
+    case "$ntp_ssl_libdir" in
+     '')
+	ntp_ssl_libdir_search="/usr/lib /usr/lib/openssl /usr/sfw/lib"
+	ntp_ssl_libdir_search="$ntp_ssl_libdir_search /usr/local/lib"
+	ntp_ssl_libdir_search="$ntp_ssl_libdir_search /usr/local/ssl/lib"
+	ntp_ssl_libdir_search="$ntp_ssl_libdir_search /opt/local/lib"
+	ntp_ssl_libdir_search="$ntp_ssl_libdir_search /lib /lib64"
 	;;
-     *) # Look for libcrypto.a and libssl.a:
-	for i in $with_openssl_libdir no
+     *)
+	ntp_ssl_libdir_search="$ntp_ssl_libdir"
+    esac
+    case $ntp_ssl_libdir_search in
+     'not needed') ;;
+     *)
+	for i in $ntp_ssl_libdir_search not_found
 	do
-	    case "$host" in
-	     *-*-darwin*)
-		test -f $i/libcrypto.dylib -a -f $i/libssl.dylib && break
-		;;
+	    case "$i" in
+	     not_found) ;;
 	     *)
-		test -f $i/libcrypto.so -a -f $i/libssl.so && break
-		test -f $i/libcrypto.a -a -f $i/libssl.a && break
-		;;
+		AC_MSG_NOTICE([Searching for libcrypto in $i])
+		LIBS="-L$i $NTPSSL_SAVED_LIBS"
+		AC_CHECK_LIB(
+		    [crypto],
+		    [EVP_MD_CTX_new],
+		    [break]
+		)
+		dnl unconventional, using AC_CHECK_LIB repeatedly, clear cached result.
+		AS_UNSET([ac_cv_lib_crypto_EVP_MD_CTX_new])
 	    esac
 	done
-	openssl_libdir=$i
-	;;
-    esac
-    AC_MSG_RESULT([$openssl_libdir])
-    case "$openssl_libdir" in
-     no)
-	openssl_libdir=
-	AC_MSG_WARN([libcrypto and libssl not found in any of $with_openssl_libdir])
+	ntp_ssl_libdir="$i"
+	ntp_ssl_libs_L="-L$i"
+	ntp_ssl_libs="$ntp_ssl_libs_L $ntp_ssl_libs_l"
+	LIBS="$NTPSSL_SAVED_LIBS"
+	case "$ntp_ssl_libdir" in
+	 not_found)
+	    AC_MSG_ERROR(
+[You may want to use --without-crypto, or add 
+openssl.pc/libcrypto.pc to PKG_CONFIG_PATH, or use the 
+--with-openssl-libdir=/some/path option to configure.
+libcrypto not found in any of the following directories:
+$ntp_ssl_libdir_search]
+	    )
+	esac
+	AC_MSG_NOTICE([libcrypto found in $ntp_ssl_libdir])
     esac
 
-    AC_MSG_CHECKING([for openssl include directory])
-    with_openssl_incdir=${with_openssl_incdir-notgiven}
-    case "$with_openssl_incdir" in
-     notgiven)
-	# Look in:
-	with_openssl_incdir="/usr/include /usr/sfw/include"
-	with_openssl_incdir="$with_openssl_incdir /usr/local/include"
-	with_openssl_incdir="$with_openssl_incdir /usr/local/ssl/include"
+    case "$ntp_openssl_from_pkg_config:$ntp_ssl_incdir" in
+     'yes:not needed' | no:)
+	AC_MSG_NOTICE([Searching for openssl/evp.h without -I])
+	dnl force uncached AC_CHECK_HEADER
+	AS_UNSET([ac_cv_header_openssl_evp_h])
+	AC_CHECK_HEADER(
+	    [openssl/evp.h],
+	    [ntp_ssl_incdir='not needed']
+	    )
     esac
-    case "$with_openssl_incdir" in
-     no)
+    case "$ntp_ssl_incdir" in
+     'not needed')
+	ntp_ssl_incdir_search="$ntp_ssl_incdir"
 	;;
-     *) # look for openssl/evp.h:
-	for i in $with_openssl_incdir no
-	do
-	    test -f $i/openssl/evp.h && break
-	done
-	openssl_incdir=$i
-	;;
-    esac
-    AS_UNSET([i])
-    AC_MSG_RESULT([$openssl_incdir])
-    case "$openssl_incdir" in
-     no)
-	openssl_incdir=
-	AC_MSG_WARN([did not find openssl/evp.h in any of $with_openssl_incdir])
-    esac
-    if test -z "$openssl_libdir" -o -z "$openssl_incdir"
-    then
-	ntp_openssl=no
-    else
-	ntp_openssl=yes
-	VER_SUFFIX=o
-    fi
-    case "$ntp_openssl" in
-     yes)
-	# We have OpenSSL inc/lib dirs - use them.
-	case "$openssl_incdir" in
-	 /usr/include)
+     *)
+	AC_MSG_NOTICE([Searching for openssl include directory])
+	case "$with_openssl_incdir" in
+	 '')
+	    case "$ntp_ssl_incdir" in
+	     '')
+		ntp_ssl_incdir_search="/usr/include /usr/sfw/include"
+		ntp_ssl_incdir_search="$ntp_ssl_incdir_search /usr/local/include"
+		ntp_ssl_incdir_search="$ntp_ssl_incdir_search /opt/local/include"
+		ntp_ssl_incdir_search="$ntp_ssl_incdir_search /usr/local/ssl/include"
+		;;
+	     *)
+	    esac
 	    ;;
 	 *)
-	    CPPFLAGS_NTP="$CPPFLAGS_NTP -I$openssl_incdir"
-	    ;;
+	    ntp_ssl_incdir_search="$with_openssl_incdir"
 	esac
-	case "$openssl_libdir" in
-	 /usr/lib)
-	    ;;
+	case $ntp_ssl_incdir_search in
+	 'not needed') ;;
 	 *)
-	    LDADD_NTP="$LDADD_NTP -L$openssl_libdir"
-	    case "$need_dash_r" in
-	     1)
-		LDFLAGS_NTP="$LDFLAGS_NTP -R$openssl_libdir"
+	    for i in $ntp_ssl_incdir_search
+	    do
+		AC_MSG_NOTICE([Searching for openssl/evp.h in $i])
+		CPPFLAGS="$NTPSSL_SAVED_CPPFLAGS -I$i"
+		dnl force uncached AC_CHECK_HEADER
+		AS_UNSET([ac_cv_header_openssl_evp_h])
+		AC_CHECK_HEADER(
+		    [openssl/evp.h],
+		    [ntp_ssl_incdir="$i" ; break]
+		    )
+	    done
+	    AS_UNSET([ac_cv_header_openssl_evp_h])
+	    AS_UNSET([i])
+	    CPPFLAGS="$NTPSSL_SAVED_CPPFLAGS"
+	    case "$ntp_ssl_incdir" in
+	     '')
+		AC_MSG_ERROR(
+[You may want to use --without-crypto, or add
+openssl.pc/libcrypto.pc to PKG_CONFIG_PATH, or use the
+-with-openssl-incdir=/some/path option to configure.
+No usable openssl/evp.h found in any of the following direcotries:
+$ntp_ssl_incdir_search]
+		)
 	    esac
-	    case "$need_dash_Wlrpath" in
-	     1)
-		LDFLAGS_NTP="$LDFLAGS_NTP -Wl,-rpath,$openssl_libdir"
-	    esac
-	    ;;
+	    ntp_ssl_cppflags="-I$ntp_ssl_incdir"
+	    AC_MSG_NOTICE([Found evp.h in $ntp_ssl_incdir/openssl])
 	esac
-	LDADD_NTP="$LDADD_NTP -lcrypto"
     esac
-esac
-
-AC_MSG_CHECKING([if we will use crypto])
-AC_MSG_RESULT([$ntp_openssl])
+    ntp_openssl=yes
+esac	dnl building with SSL ($with_crypto not "no")
 
-case "$ntp_openssl" in
- yes)
-    AC_CHECK_HEADERS([openssl/cmac.h openssl/hmac.h])
-    AC_DEFINE([OPENSSL], [], [Use OpenSSL?])
-    case "$VER_SUFFIX" in
-     *o*) ;;
-     *) AC_MSG_ERROR([OPENSSL set but no 'o' in VER_SUFFIX!]) ;;
-    esac
+case "$ntp_openssl:$ntp_ssl_libdir" in
+ 'yes:not needed')
     ;;
-esac
+ yes:*)
+    CFLAGS="$NTPSSL_SAVED_CFLAGS $ntp_ssl_cflags"
+    CPPFLAGS="$NTPSSL_SAVED_CPPFLAGS $ntp_ssl_cppflags"
+    LIBS="$ntp_ssl_libs $NTPSSL_SAVED_LIBS"
+    LDFLAGS="$ntp_ssl_ldflags $NTPSSL_SAVED_LDFLAGS"
+    dnl ### test if runpath is needed for crypto ###
+    AC_CACHE_CHECK(
+	[if crypto works without runpath],
+	[ntp_cv_ssl_without_runpath],
+	[AC_RUN_IFELSE(
+	    [AC_LANG_PROGRAM(
+		[[
+		    #include "openssl/evp.h"
+		]],
+		[[
+		    if (!EVP_MD_CTX_new()) {
+			return 1;
+		    }
+		]]
+	    )],
+	    [ntp_cv_ssl_without_runpath=yes],
+	    [ntp_cv_ssl_without_runpath=no],
+	    [ntp_cv_ssl_without_runpath=yes]		dnl cross-compile
+	)]
+    )
+    case "$ntp_cv_ssl_without_runpath" in
+     no)
+	AC_CACHE_CHECK(
+	    [if crypto needs -Wl,-rpath,$ntp_ssl_libdir],
+	    [ntp_cv_ssl_needs_dashWl_rpath],
+	    [
+		LDFLAGS="$ntp_ssl_ldflags -Wl,-rpath,$ntp_ssl_libdir $NTPSSL_SAVED_LDFLAGS"
+		AC_RUN_IFELSE(
+		    [AC_LANG_PROGRAM(
+			[[
+			    #include "openssl/evp.h"
+			]],
+			[[
+			    if (!EVP_MD_CTX_new()) {
+				return 1;
+			    }
+			]]
+		    )],
+		    [ntp_cv_ssl_needs_dashWl_rpath=yes],
+		    [ntp_cv_ssl_needs_dashWl_rpath=no]
+		)
+	    ]
+	)
+	case "$ntp_cv_ssl_needs_dashWl_rpath" in
+	 yes)
+	    ntp_ssl_ldflags="$ntp_ssl_ldflags -Wl,-rpath,$ntp_ssl_libdir"
+	    ;;
+	 no)
+	    AC_CACHE_CHECK(
+		[if crypto needs -R$ntp_ssl_libdir],
+		[ntp_cv_ssl_needs_dashR],
+		[
+		    LDFLAGS="$NTPSSL_SAVED_LDFLAGS $ntp_ssl_ldflags -R$ntp_ssl_libdir"
+		    AC_RUN_IFELSE(
+			[AC_LANG_PROGRAM(
+			    [[
+				#include "openssl/evp.h"
+			    ]],
+			    [[
+				if (!EVP_MD_CTX_new()) {
+				    return 1;
+				}
+			    ]]
+			)],
+			[ntp_cv_ssl_needs_dashR=yes],
+			[ntp_cv_ssl_needs_dashR=no]
+		    )
+		]
+	    )
+	    case "$ntp_cv_ssl_needs_dashR" in
+	     yes)
+		ntp_ssl_ldflags="$ntp_ssl_ldflags -R$ntp_ssl_libdir"
+	    esac
+	    case "$build:$ntp_cv_ssl_needs_dashR" in
+	     $host:no)
+		AC_MSG_FAILURE(
+[Unable to run program using crypto, check openssl.pc
+or libcrypto.pc are in PKG_CONFIG_PATH, or provide the
+ --with-openssl-libdir=/some/path option to configure.]
+		)
+	    esac
+	esac
+    esac
+esac	dnl ntp_openssl was yes
 
-NTPO_SAVED_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $CPPFLAGS_NTP"
-NTPO_SAVED_LIBS="$LIBS"
+NTP_OPENSSL_VERBOSE_MSG([OpenSSL Phase II checks:])
+NTP_OPENSSL_VERBOSE_MSG([ntp_ssl_incdir:   ($ntp_ssl_incdir)])
+NTP_OPENSSL_VERBOSE_MSG([ntp_ssl_libdir:   ($ntp_ssl_libdir)])
+NTP_OPENSSL_VERBOSE_MSG([ntp_ssl_cflags:   ($ntp_ssl_cflags)])
+NTP_OPENSSL_VERBOSE_MSG([ntp_ssl_cppflags: ($ntp_ssl_cppflags)])
+NTP_OPENSSL_VERBOSE_MSG([ntp_ssl_libs_L:   ($ntp_ssl_libs_L)])
+NTP_OPENSSL_VERBOSE_MSG([ntp_ssl_libs_l:   ($ntp_ssl_libs_l)])
+NTP_OPENSSL_VERBOSE_MSG([ntp_ssl_libs:     ($ntp_ssl_libs)])
+NTP_OPENSSL_VERBOSE_MSG([ntp_ssl_ldflags:  ($ntp_ssl_ldflags)])
 
-#
-# check for linking with -lcrypto failure, and try -lcrypto -lz.
-# Helps m68k-atari-mint
-#
+dnl check for linking with -lcrypto failure, and try -lcrypto -lz.
+dnl Helps m68k-atari-mint
+dnl
+dnl Needs work with the changes to run-test whether runpath is needed.
+dnl Probably needs to be moved ahead of runpath testing.
+dnl hart@ is reaching out to MiNT users to try to find a tester.
+dnl Meanwhile can be forced by passing both ntp_cv_bare_lcrypto=no
+dnl and ntp_cv_lcrypto_lz=yes on the configure command line.
+dnl
 case "$ntp_openssl:$ntp_openssl_from_pkg_config" in
  yes:no)
-    LIBS="$NTPO_SAVED_LIBS $LDADD_NTP"
+    CFLAGS="$NTPSSL_SAVED_CFLAGS $ntp_ssl_cflags"
+    CPPFLAGS="$NTPSSL_SAVED_CPPFLAGS $ntp_ssl_cppflags"
+    LIBS="$ntp_ssl_libs $NTPSSL_SAVED_LIBS"
+    LDFLAGS="$ntp_ssl_ldflags $NTPSSL_SAVED_LDFLAGS"
     AC_CACHE_CHECK(
-	[if linking with -lcrypto alone works],
+	[if linking with $ntp_ssl_libs_l alone works],
 	[ntp_cv_bare_lcrypto],
 	[AC_LINK_IFELSE(
 	    [AC_LANG_PROGRAM(
 		[[
-		    #include "openssl/err.h"
 		    #include "openssl/evp.h"
 		]],
 		[[
-		    ERR_load_crypto_strings();
-		    OpenSSL_add_all_algorithms();
+		    EVP_MD_CTX_new();
 		]]
 	    )],
 	    [ntp_cv_bare_lcrypto=yes],
@@ -282,19 +554,17 @@ case "$ntp_openssl:$ntp_openssl_from_pkg_config" in
     )
     case "$ntp_cv_bare_lcrypto" in
      no)
-	LIBS="$NTPO_SAVED_LIBS $LDADD_NTP -lz"
+	LIBS="-$ntp_ssl_libs -lz $NTPSSL_SAVED_LIBS"
 	AC_CACHE_CHECK(
-	    [if linking with -lcrypto -lz works],
+	    [if linking with $ntp_ssl_libs_l -lz works],
 	    [ntp_cv_lcrypto_lz],
 	    [AC_LINK_IFELSE(
 		[AC_LANG_PROGRAM(
 		    [[
-			#include "openssl/err.h"
 			#include "openssl/evp.h"
 		    ]],
 		    [[
-			ERR_load_crypto_strings();
-			OpenSSL_add_all_algorithms();
+			EVP_MD_CTX_new();
 		    ]]
 		)],
 		[ntp_cv_lcrypto_lz=yes],
@@ -303,103 +573,160 @@ case "$ntp_openssl:$ntp_openssl_from_pkg_config" in
 	)
 	case "$ntp_cv_lcrypto_lz" in
 	 yes)
-	     LDADD_NTP="$LDADD_NTP -lz"
+	     ntp_ssl_libs_l="$ntp_ssl_libs_l -lz"
+	     ntp_ssl_libs="$ntp_ssl_libs_L $ntp_ssl_libs_l"
 	esac
-    esac
-esac
-
-#
-# Older OpenSSL headers have a number of callback prototypes inside
-# other function prototypes which trigger copious warnings with gcc's
-# -Wstrict-prototypes, which is included in -Wall.
-#
-# An example:
-#
-# int i2d_RSA_NET(const RSA *a, unsigned char **pp, 
-#		  int (*cb)(), int sgckey);
-#		  ^^^^^^^^^^^
-#
-# 
-#
-openssl_triggers_warnings=unknown
-NTPO_SAVED_CFLAGS="$CFLAGS"
+    esac	dnl linking with -lcrypto alone fails
+esac		dnl using SSL and not from pkg-config
 
+dnl
+dnl Older OpenSSL headers have a number of callback prototypes inside
+dnl other function prototypes which trigger copious warnings with gcc's
+dnl -Wstrict-prototypes, which is included in -Wall.
+dnl
+dnl An example:
+dnl
+dnl int i2d_RSA_NET(const RSA *a, unsigned char **pp, 
+dnl		  int (*cb)(), int sgckey);
+dnl		  ^^^^^^^^^^^
+dnl
 case "$ntp_openssl:$GCC" in
  yes:yes)
-    CFLAGS="$CFLAGS -Werror"
-    AC_COMPILE_IFELSE(
-	[AC_LANG_PROGRAM(
-	    [[
-	    ]],
-	    [[
-		/* see if -Werror breaks gcc */
-	    ]]
-	)],
-	[gcc_handles_Werror=yes],
-	[gcc_handles_Werror=no]
+    CFLAGS="$NTP_SAVED_CFLAGS $ntp_ssl_cflags -Werror"
+    CPPFLAGS="$NTPSSL_SAVED_CPPFLAGS $ntp_ssl_cppflags"
+    LIBS="$ntp_ssl_libs $NTPSSL_SAVED_LIBS"
+    LDFLAGS="$ntp_ssl_ldflags $NTPSSL_SAVED_LDFLAGS"
+    AC_CACHE_CHECK(
+	[If $CC supports -Werror],
+	[ntp_cv_gcc_supports_Werror],
+	[AC_COMPILE_IFELSE(
+	    [AC_LANG_PROGRAM([], [])],
+	    [ntp_cv_gcc_supports_Werror=yes],
+	    [ntp_cv_gcc_supports_Werror=no]
+	)]
     )
-    case "$gcc_handles_Werror" in
+    case "ntp_cv_gcc_supports_Werror" in
      no)
-	# if this gcc doesn't do -Werror go ahead and use
-	# -Wstrict-prototypes.
-	openssl_triggers_warnings=yes
+	ntp_use_Wstrict_prototypes=yes
 	;;
      yes)
 	CFLAGS="$CFLAGS -Wstrict-prototypes"
-	AC_COMPILE_IFELSE(
-	    [AC_LANG_PROGRAM(
-		[[
-		    #include "openssl/asn1_mac.h"
-		    #include "openssl/bn.h"
-		    #include "openssl/err.h"
-		    #include "openssl/evp.h"
-		    #include "openssl/pem.h"
-		    #include "openssl/rand.h"
-		    #include "openssl/x509v3.h"
-		]],
-		[[
-		    /* empty body */
-		]]
-	    )],
-	    [openssl_triggers_warnings=no],
-	    [openssl_triggers_warnings=yes]
+	AC_CACHE_CHECK(
+	    [if OpenSSL triggers warnings],
+	    [ntp_cv_ssl_triggers_warnings],
+	    [AC_COMPILE_IFELSE(
+		[AC_LANG_PROGRAM(
+		    [[
+			#include "openssl/asn1_mac.h"
+			#include "openssl/bn.h"
+			#include "openssl/err.h"
+			#include "openssl/evp.h"
+			#include "openssl/pem.h"
+			#include "openssl/rand.h"
+			#include "openssl/x509v3.h"
+		    ]],
+		    [[
+			/* empty body */
+		    ]]
+		)],
+		[ntp_cv_ssl_triggers_warnings=no],
+		[ntp_cv_ssl_triggers_warnings=yes]
+	    )]
 	)
+	case "$ntp_cv_ssl_triggers_warnings" in
+	 yes)
+	    ntp_use_Wstrict_prototypes=no
+	    ;;
+	 *)
+	    ntp_use_Wstrict_prototypes=yes
+	esac
     esac
-    case "$openssl_triggers_warnings" in
-     yes)
-	CFLAGS_NTP="$CFLAGS_NTP -Wno-strict-prototypes"
+    case "$ntp_use_Wstrict_prototypes" in
+     no)
+	ntp_ssl_cflags="$ntp_ssl_cflags -Wno-strict-prototypes"
 	;;
      *)
-	CFLAGS_NTP="$CFLAGS_NTP -Wstrict-prototypes"
+	ntp_ssl_cflags="$ntp_ssl_cflags -Wstrict-prototypes"
     esac
     ;;
  no:yes)
-    # gcc without OpenSSL
-    CFLAGS_NTP="$CFLAGS_NTP -Wstrict-prototypes"
-esac
+    dnl gcc without OpenSSL
+    ntp_ssl_cflags="$ntp_ssl_cflags -Wstrict-prototypes"
+esac	dnl checking for gcc problems with -Werror and -Wstrict-prototypes
 
-# Because we don't want -Werror for the EVP_MD_do_all_sorted check
-CFLAGS="$NTPO_SAVED_CFLAGS"
+AC_MSG_CHECKING([if we will link to ssl library])
+AC_MSG_RESULT([$ntp_openssl])
 
 case "$ntp_openssl" in
  yes)
-    LIBS="$NTPO_SAVED_LIBS $LDADD_NTP"
+    VER_SUFFIX=o
+    AC_CHECK_HEADERS(
+	[openssl/cmac.h],
+	[ntp_enable_cmac=yes],
+	[ntp_enable_cmac=no]
+    )
+    case "$ntp_enable_cmac" in
+     yes)
+    	AC_DEFINE([ENABLE_CMAC], [1], [Enable CMAC support?])
+    esac
+    AC_DEFINE([OPENSSL], [], [Use OpenSSL?])
+    dnl OpenSSL 3 deprecates a bunch of functions used by Autokey.
+    dnl Adapting our code to the bold new way is not a priority
+    dnl for us because we do not want to require OpenSSL 3 yet.
+    dnl The deprecation warnings clutter up the build output
+    dnl encouraging the habit of ignoring warnings.
+    dnl So, tell it to the hand, OpenSSL deprecation warnings...
+    AC_DEFINE([OPENSSL_SUPPRESS_DEPRECATED], [1],
+	      [Suppress OpenSSL 3 deprecation warnings])
+    dnl We don't want -Werror for the EVP_MD_do_all_sorted check
+    CFLAGS="$NTPSSL_SAVED_CFLAGS"
     AC_CHECK_FUNCS([EVP_MD_do_all_sorted])
-    ;;
+    CPPFLAGS_NTP="$CPPFLAGS_NTP $ntp_ssl_cppflags"
+    CFLAGS_NTP="$CFLAGS_NTP $ntp_ssl_cflags"
+    LDADD_NTP="$ntp_ssl_libs $LDADD_NTP"
+    LDFLAGS_NTP="$ntp_ssl_ldflags $LDFLAGS_NTP"
 esac
 
-dnl AC_MSG_NOTICE([OpenSSL final checks:])
-dnl AC_MSG_NOTICE([CPPFLAGS_NTP: $CPPFLAGS_NTP])
-dnl AC_MSG_NOTICE([CFLAGS_NTP: $CFLAGS_NTP])
-dnl AC_MSG_NOTICE([LDADD_NTP: $LDADD_NTP])
-dnl AC_MSG_NOTICE([LDFLAGS_NTP: $LDFLAGS_NTP])
+NTP_OPENSSL_VERBOSE_MSG([OpenSSL final checks:])
+NTP_OPENSSL_VERBOSE_MSG([ntp_openssl:  $ntp_openssl])
+NTP_OPENSSL_VERBOSE_MSG([CPPFLAGS_NTP: ($CPPFLAGS_NTP)])
+NTP_OPENSSL_VERBOSE_MSG([CFLAGS_NTP:   ($CFLAGS_NTP)])
+NTP_OPENSSL_VERBOSE_MSG([LDADD_NTP:    ($LDADD_NTP)])
+NTP_OPENSSL_VERBOSE_MSG([LDFLAGS_NTP:  ($LDFLAGS_NTP)])
+
+CFLAGS="$NTPSSL_SAVED_CFLAGS"
+CPPFLAGS="$NTPSSL_SAVED_CPPFLAGS"
+LIBS="$NTPSSL_SAVED_LIBS"
+LDFLAGS="$NTPSSL_SAVED_LDFLAGS"
 
-CPPFLAGS="$NTPO_SAVED_CPPFLAGS"
-LIBS="$NTPO_SAVED_LIBS"
-AS_UNSET([NTPO_SAVED_CFLAGS])
-AS_UNSET([NTPO_SAVED_CPPFLAGS])
-AS_UNSET([NTPO_SAVED_LIBS])
-AS_UNSET([openssl_triggers_warnings])
+AS_UNSET([NTPSSL_SAVED_CFLAGS])
+AS_UNSET([NTPSSL_SAVED_CPPFLAGS])
+AS_UNSET([NTPSSL_SAVED_LIBS])
+AS_UNSET([NTPSSL_SAVED_LDFLAGS])
+AS_UNSET([ntp_enable_cmac])
+AS_UNSET([ntp_use_Wstrict_prototypes])
 AS_UNSET([ntp_openssl_from_pkg_config])
+AS_UNSET([ntp_openssl_version])
+AS_UNSET([ntp_ssl_cflags])
+AS_UNSET([ntp_ssl_cppflags])
+AS_UNSET([ntp_ssl_libdir_search])
+AS_UNSET([ntp_ssl_incdir_search])
+AS_UNSET([ntp_ssl_libdir])
+AS_UNSET([ntp_ssl_incdir])
+AS_UNSET([ntp_ssl_libs_l])
+AS_UNSET([ntp_ssl_libs_L])
+AS_UNSET([ntp_ssl_ldflags])
+
 ])
+dnl end of AC_DEFUN([NTP_OPENSSL])
+dnl
+AC_DEFUN(
+    [NTP_OPENSSL_VERBOSE_MSG],
+    [dnl
+	case "$enable_verbose_ssl" in
+	 yes) AC_MSG_NOTICE([$1])
+	esac
+    ]
+)
+dnl
 dnl ======================================================================
diff --git a/contrib/ntp/sntp/m4/version.m4 b/contrib/ntp/sntp/m4/version.m4
index 95deaa41c695..add8fc6018cb 100644
--- a/contrib/ntp/sntp/m4/version.m4
+++ b/contrib/ntp/sntp/m4/version.m4
@@ -1 +1 @@
-m4_define([VERSION_NUMBER],[4.2.8p17])
+m4_define([VERSION_NUMBER],[4.2.8p18])
diff --git a/contrib/ntp/sntp/main.c b/contrib/ntp/sntp/main.c
index 08064a6c0eaa..b1a35b42a431 100644
--- a/contrib/ntp/sntp/main.c
+++ b/contrib/ntp/sntp/main.c
@@ -1010,12 +1010,12 @@ kill_asyncio(
 		sock6 = INVALID_SOCKET;
 	}
 	if (INVALID_SOCKET != bsock4) {
-		closesocket(sock4);
-		sock4 = INVALID_SOCKET;
+		closesocket(bsock4);
+		bsock4 = INVALID_SOCKET;
 	}
 	if (INVALID_SOCKET != bsock6) {
-		closesocket(sock6);
-		sock6 = INVALID_SOCKET;
+		closesocket(bsock6);
+		bsock6 = INVALID_SOCKET;
 	}
 }
 #endif
@@ -1033,9 +1033,9 @@ worker_resp_cb(
 {
 	blocking_child *	c;
 
-	DEBUG_INSIST(EV_READ & what);
+	REQUIRE(EV_READ & what);
 	c = ctx;
-	DEBUG_INSIST(fd == c->resp_read_pipe);
+	INSIST(fd == c->resp_read_pipe);
 	process_blocking_resp(c);
 }
 
@@ -1060,7 +1060,7 @@ intres_timeout_req(
 		ev_worker_timeout = event_new(base, -1,
 					      EV_TIMEOUT | EV_PERSIST,
 					      &worker_timeout, NULL);
-		DEBUG_INSIST(NULL != ev_worker_timeout);
+		INSIST(NULL != ev_worker_timeout);
 	} else {
 		event_del(ev_worker_timeout);
 	}
@@ -1082,7 +1082,7 @@ worker_timeout(
 	UNUSED_ARG(fd);
 	UNUSED_ARG(ctx);
 
-	DEBUG_REQUIRE(EV_TIMEOUT & what);
+	REQUIRE(EV_TIMEOUT & what);
 	worker_idle_timer_fired();
 }
 
@@ -1144,8 +1144,8 @@ generate_pkt (
 	}
 	if (pkt_key != NULL) {
 		x_pkt->exten[0] = htonl(key_id);
-		mac_size = make_mac(x_pkt, pkt_len, MAX_MDG_LEN,
-				    pkt_key, (char *)&x_pkt->exten[1]);
+		mac_size = make_mac(x_pkt, pkt_len, pkt_key,
+				    (char *)&x_pkt->exten[1], MAX_MDG_LEN);
 		if (mac_size > 0)
 			pkt_len += mac_size + KEY_MAC_LEN;
 #ifdef DEBUG
diff --git a/contrib/ntp/sntp/scm-rev b/contrib/ntp/sntp/scm-rev
index 5e3d42f5e853..3e354b6addff 100644
--- a/contrib/ntp/sntp/scm-rev
+++ b/contrib/ntp/sntp/scm-rev
@@ -1 +1 @@
-1.4004
+1.4062
diff --git a/contrib/ntp/sntp/scripts/Makefile.in b/contrib/ntp/sntp/scripts/Makefile.in
index 42d86ecb59d3..4ad3e371b4e1 100644
--- a/contrib/ntp/sntp/scripts/Makefile.in
+++ b/contrib/ntp/sntp/scripts/Makefile.in
@@ -97,6 +97,7 @@ am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
 	$(top_srcdir)/m4/ntp_cacheversion.m4 \
 	$(top_srcdir)/m4/ntp_compiler.m4 \
 	$(top_srcdir)/m4/ntp_crosscompile.m4 \
+	$(top_srcdir)/m4/ntp_crypto_rand.m4 \
 	$(top_srcdir)/m4/ntp_debug.m4 $(top_srcdir)/m4/ntp_dir_sep.m4 \
 	$(top_srcdir)/m4/ntp_facilitynames.m4 \
 	$(top_srcdir)/m4/ntp_harden.m4 $(top_srcdir)/m4/ntp_ipv6.m4 \
@@ -290,6 +291,7 @@ PACKAGE_STRING = @PACKAGE_STRING@
 PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_OPENSSL = @PATH_OPENSSL@
 PATH_RUBY = @PATH_RUBY@
 PATH_SEPARATOR = @PATH_SEPARATOR@
 PKG_CONFIG = @PKG_CONFIG@
diff --git a/contrib/ntp/sntp/scripts/cvo.sh b/contrib/ntp/sntp/scripts/cvo.sh
index ecd80922301f..77a161172499 100755
--- a/contrib/ntp/sntp/scripts/cvo.sh
+++ b/contrib/ntp/sntp/scripts/cvo.sh
@@ -26,7 +26,13 @@ case "$#" in
     CVO_OS=$4
     case "$cvo_KERN" in
      linux)			# Braindamage.  We want OS, not kernel info
-	if lsb_release > /dev/null 2>&1
+	if test -f /etc/os-release
+	then
+	    . /etc/os-release
+	    ID=`echo $ID | tr '-' '_'`
+	    CVO_OS="${ID}${VERSION_ID}"
+	    CVO_KOSVER=`uname -r`
+	elif lsb_release > /dev/null 2>&1
 	then
 	    CVO_OS=`lsb_release --id --short | tr '[:upper:]' '[:lower:]'`
 	    CVO_OS="$CVO_OS`lsb_release --release --short`"
diff --git a/contrib/ntp/sntp/sntp-opts.c b/contrib/ntp/sntp/sntp-opts.c
index 29c726cb5973..d4634aa8d710 100644
--- a/contrib/ntp/sntp/sntp-opts.c
+++ b/contrib/ntp/sntp/sntp-opts.c
@@ -1,7 +1,7 @@
 /*
  *  EDIT THIS FILE WITH CAUTION  (sntp-opts.c)
  *
- *  It has been AutoGen-ed  June  6, 2023 at 04:35:52 AM by AutoGen 5.18.16
+ *  It has been AutoGen-ed  May 25, 2024 at 12:02:07 AM by AutoGen 5.18.16
  *  From the definitions    sntp-opts.def
  *  and the template file   options
  *
@@ -18,7 +18,7 @@
  * The sntp program is copyrighted and licensed
  * under the following terms:
  *
- *  Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation, all rights reserved.
+ *  Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation, all rights reserved.
  *  This is free software. It is licensed for use, modification and
  *  redistribution under the terms of the NTP License, copies of which
  *  can be seen at:
@@ -74,8 +74,8 @@ extern FILE * option_usage_fp;
  *  static const strings for sntp options
  */
 static char const sntp_opt_strs[2567] =
-/*     0 */ "sntp 4.2.8p17\n"
-            "Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation, all rights reserved.\n"
+/*     0 */ "sntp 4.2.8p18\n"
+            "Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation, all rights reserved.\n"
             "This is free software. It is licensed for use, modification and\n"
             "redistribution under the terms of the NTP License, copies of which\n"
             "can be seen at:\n"
@@ -160,7 +160,7 @@ static char const sntp_opt_strs[2567] =
 /*  2313 */ "LOAD_OPTS\0"
 /*  2323 */ "no-load-opts\0"
 /*  2336 */ "SNTP\0"
-/*  2341 */ "sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p17\n"
+/*  2341 */ "sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p18\n"
             "Usage:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n"
             "\t\t[ hostname-or-IP ...]\n\0"
 /*  2501 */ "$HOME\0"
@@ -168,7 +168,7 @@ static char const sntp_opt_strs[2567] =
 /*  2509 */ ".ntprc\0"
 /*  2516 */ "https://bugs.ntp.org, bugs@ntp.org\0"
 /*  2551 */ "\n\0"
-/*  2553 */ "sntp 4.2.8p17";
+/*  2553 */ "sntp 4.2.8p18";
 
 /**
  *  ipv4 option description with
@@ -1180,8 +1180,8 @@ static void bogus_function(void) {
      translate option names.
    */
   /* referenced via sntpOptions.pzCopyright */
-  puts(_("sntp 4.2.8p17\n\
-Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation, all rights reserved.\n\
+  puts(_("sntp 4.2.8p18\n\
+Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation, all rights reserved.\n\
 This is free software. It is licensed for use, modification and\n\
 redistribution under the terms of the NTP License, copies of which\n\
 can be seen at:\n"));
@@ -1270,7 +1270,7 @@ implied warranty.\n"));
   puts(_("load options from a config file"));
 
   /* referenced via sntpOptions.pzUsageTitle */
-  puts(_("sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p17\n\
+  puts(_("sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p18\n\
 Usage:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n\
 \t\t[ hostname-or-IP ...]\n"));
 
@@ -1278,7 +1278,7 @@ Usage:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n\
   puts(_("\n"));
 
   /* referenced via sntpOptions.pzFullVersion */
-  puts(_("sntp 4.2.8p17"));
+  puts(_("sntp 4.2.8p18"));
 
   /* referenced via sntpOptions.pzFullUsage */
   puts(_("<<<NOT-FOUND>>>"));
diff --git a/contrib/ntp/sntp/sntp-opts.h b/contrib/ntp/sntp/sntp-opts.h
index a7cff4d550b0..e9efb0c4da62 100644
--- a/contrib/ntp/sntp/sntp-opts.h
+++ b/contrib/ntp/sntp/sntp-opts.h
@@ -1,7 +1,7 @@
 /*
  *  EDIT THIS FILE WITH CAUTION  (sntp-opts.h)
  *
- *  It has been AutoGen-ed  June  6, 2023 at 04:35:52 AM by AutoGen 5.18.16
+ *  It has been AutoGen-ed  May 25, 2024 at 12:02:07 AM by AutoGen 5.18.16
  *  From the definitions    sntp-opts.def
  *  and the template file   options
  *
@@ -18,7 +18,7 @@
  * The sntp program is copyrighted and licensed
  * under the following terms:
  *
- *  Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation, all rights reserved.
+ *  Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation, all rights reserved.
  *  This is free software. It is licensed for use, modification and
  *  redistribution under the terms of the NTP License, copies of which
  *  can be seen at:
@@ -99,9 +99,9 @@ typedef enum {
 /** count of all options for sntp */
 #define OPTION_CT    23
 /** sntp version */
-#define SNTP_VERSION       "4.2.8p17"
+#define SNTP_VERSION       "4.2.8p18"
 /** Full sntp version text */
-#define SNTP_FULL_VERSION  "sntp 4.2.8p17"
+#define SNTP_FULL_VERSION  "sntp 4.2.8p18"
 
 /**
  *  Interface defines for all options.  Replace "n" with the UPPER_CASED
diff --git a/contrib/ntp/sntp/sntp.1sntpman b/contrib/ntp/sntp/sntp.1sntpman
index 7d532020c280..d10d13cddbbc 100644
--- a/contrib/ntp/sntp/sntp.1sntpman
+++ b/contrib/ntp/sntp/sntp.1sntpman
@@ -10,11 +10,11 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH sntp 1sntpman "06 Jun 2023" "4.2.8p17" "User Commands"
+.TH sntp 1sntpman "25 May 2024" "4.2.8p18" "User Commands"
 .\"
 .\" EDIT THIS FILE WITH CAUTION (in-mem file)
 .\"
-.\" It has been AutoGen-ed June 6, 2023 at 04:36:14 AM by AutoGen 5.18.16
+.\" It has been AutoGen-ed May 25, 2024 at 12:02:30 AM by AutoGen 5.18.16
 .\" From the definitions sntp-opts.def
 .\" and the template file agman-cmd.tpl
 .SH NAME
@@ -353,7 +353,7 @@ it to autogen-users@lists.sourceforge.net.  Thank you.
 .NOP  "Dave Hart" 
 .br
 .SH "COPYRIGHT"
-Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation all rights reserved.
 This program is released under the terms of the NTP license, <http://ntp.org/license>.
 .SH "BUGS"
 Please send bug reports to: https://bugs.ntp.org, bugs@ntp.org
diff --git a/contrib/ntp/sntp/sntp.1sntpmdoc b/contrib/ntp/sntp/sntp.1sntpmdoc
index 0f58ff4090af..f0b3f4641ea1 100644
--- a/contrib/ntp/sntp/sntp.1sntpmdoc
+++ b/contrib/ntp/sntp/sntp.1sntpmdoc
@@ -1,9 +1,9 @@
-.Dd June 6 2023
+.Dd May 25 2024
 .Dt SNTP 1sntpmdoc User Commands
 .Os
 .\"  EDIT THIS FILE WITH CAUTION  (sntp-opts.mdoc)
 .\"
-.\"  It has been AutoGen-ed  June  6, 2023 at 04:36:10 AM by AutoGen 5.18.16
+.\"  It has been AutoGen-ed  May 25, 2024 at 12:02:26 AM by AutoGen 5.18.16
 .\"  From the definitions    sntp-opts.def
 .\"  and the template file   agmdoc-cmd.tpl
 .Sh NAME
@@ -308,7 +308,7 @@ it to autogen\-users@lists.sourceforge.net.  Thank you.
 .An "Harlan Stenn"
 .An "Dave Hart"
 .Sh "COPYRIGHT"
-Copyright (C) 1992\-2023 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992\-2024 The University of Delaware and Network Time Foundation all rights reserved.
 This program is released under the terms of the NTP license, <http://ntp.org/license>.
 .Sh "BUGS"
 Please send bug reports to: https://bugs.ntp.org, bugs@ntp.org
diff --git a/contrib/ntp/sntp/sntp.html b/contrib/ntp/sntp/sntp.html
index 71d3c35d439c..b5154d115d87 100644
--- a/contrib/ntp/sntp/sntp.html
+++ b/contrib/ntp/sntp/sntp.html
@@ -53,7 +53,7 @@ display the time offset of the system clock relative to the server
 clock.  Run as root, it can correct the system clock to this offset as
 well.  It can be run as an interactive command or from a cron job.
 </p>
-<p>This document applies to version 4.2.8p17 of <code>sntp</code>.
+<p>This document applies to version 4.2.8p18 of <code>sntp</code>.
 </p>
 <p>The program implements the SNTP protocol as defined by RFC 5905, the NTPv4
 IETF specification.
@@ -226,7 +226,7 @@ used to select the program, defaulting to <samp>more</samp>.  Both will exit
 with a status code of 0.
 </p>
 <div class="example">
-<pre class="example">sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p17
+<pre class="example">sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p18
 Usage:  sntp [ -&lt;flag&gt; [&lt;val&gt;] | --&lt;name&gt;[{=| }&lt;val&gt;] ]... \
                 [ hostname-or-IP ...]
   Flg Arg Option-Name    Description
diff --git a/contrib/ntp/sntp/sntp.man.in b/contrib/ntp/sntp/sntp.man.in
index ca4ddea8e35c..050d1e9cd3f0 100644
--- a/contrib/ntp/sntp/sntp.man.in
+++ b/contrib/ntp/sntp/sntp.man.in
@@ -10,11 +10,11 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH sntp @SNTP_MS@ "06 Jun 2023" "4.2.8p17" "User Commands"
+.TH sntp @SNTP_MS@ "25 May 2024" "4.2.8p18" "User Commands"
 .\"
 .\" EDIT THIS FILE WITH CAUTION (in-mem file)
 .\"
-.\" It has been AutoGen-ed June 6, 2023 at 04:36:14 AM by AutoGen 5.18.16
+.\" It has been AutoGen-ed May 25, 2024 at 12:02:30 AM by AutoGen 5.18.16
 .\" From the definitions sntp-opts.def
 .\" and the template file agman-cmd.tpl
 .SH NAME
@@ -353,7 +353,7 @@ it to autogen-users@lists.sourceforge.net.  Thank you.
 .NOP  "Dave Hart" 
 .br
 .SH "COPYRIGHT"
-Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation all rights reserved.
 This program is released under the terms of the NTP license, <http://ntp.org/license>.
 .SH "BUGS"
 Please send bug reports to: https://bugs.ntp.org, bugs@ntp.org
diff --git a/contrib/ntp/sntp/sntp.mdoc.in b/contrib/ntp/sntp/sntp.mdoc.in
index 3e5fa337725f..2a3f8cfaa9c9 100644
--- a/contrib/ntp/sntp/sntp.mdoc.in
+++ b/contrib/ntp/sntp/sntp.mdoc.in
@@ -1,9 +1,9 @@
-.Dd June 6 2023
+.Dd May 25 2024
 .Dt SNTP @SNTP_MS@ User Commands
 .Os
 .\"  EDIT THIS FILE WITH CAUTION  (sntp-opts.mdoc)
 .\"
-.\"  It has been AutoGen-ed  June  6, 2023 at 04:36:10 AM by AutoGen 5.18.16
+.\"  It has been AutoGen-ed  May 25, 2024 at 12:02:26 AM by AutoGen 5.18.16
 .\"  From the definitions    sntp-opts.def
 .\"  and the template file   agmdoc-cmd.tpl
 .Sh NAME
@@ -308,7 +308,7 @@ it to autogen\-users@lists.sourceforge.net.  Thank you.
 .An "Harlan Stenn"
 .An "Dave Hart"
 .Sh "COPYRIGHT"
-Copyright (C) 1992\-2023 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992\-2024 The University of Delaware and Network Time Foundation all rights reserved.
 This program is released under the terms of the NTP license, <http://ntp.org/license>.
 .Sh "BUGS"
 Please send bug reports to: https://bugs.ntp.org, bugs@ntp.org
diff --git a/contrib/ntp/sntp/tests/Makefile.in b/contrib/ntp/sntp/tests/Makefile.in
index 2e52ab0b27ca..4363ed10d34e 100644
--- a/contrib/ntp/sntp/tests/Makefile.in
+++ b/contrib/ntp/sntp/tests/Makefile.in
@@ -97,6 +97,7 @@ check_PROGRAMS = test-crypto$(EXEEXT) test-keyFile$(EXEEXT) \
 @BUILD_TEST_KODDATABASE_TRUE@am__append_1 = test-kodDatabase
 @BUILD_TEST_KODFILE_TRUE@am__append_2 = test-kodFile
 @NTP_CROSSCOMPILE_FALSE@am__append_3 = $(check_PROGRAMS)
+@LIBNTP_SUBMAKES_TRUE@am__append_4 = check-libntp
 subdir = tests
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
@@ -107,6 +108,7 @@ am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
 	$(top_srcdir)/m4/ntp_cacheversion.m4 \
 	$(top_srcdir)/m4/ntp_compiler.m4 \
 	$(top_srcdir)/m4/ntp_crosscompile.m4 \
+	$(top_srcdir)/m4/ntp_crypto_rand.m4 \
 	$(top_srcdir)/m4/ntp_debug.m4 $(top_srcdir)/m4/ntp_dir_sep.m4 \
 	$(top_srcdir)/m4/ntp_facilitynames.m4 \
 	$(top_srcdir)/m4/ntp_harden.m4 $(top_srcdir)/m4/ntp_ipv6.m4 \
@@ -675,6 +677,7 @@ PACKAGE_STRING = @PACKAGE_STRING@
 PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_OPENSSL = @PATH_OPENSSL@
 PATH_RUBY = @PATH_RUBY@
 PATH_SEPARATOR = @PATH_SEPARATOR@
 PKG_CONFIG = @PKG_CONFIG@
@@ -768,7 +771,7 @@ BUILT_SOURCES = $(srcdir)/run-crypto.c $(srcdir)/run-keyFile.c \
 	$(srcdir)/run-kodDatabase.c $(srcdir)/run-kodFile.c \
 	$(srcdir)/run-networking.c $(srcdir)/run-packetHandling.c \
 	$(srcdir)/run-packetProcessing.c $(srcdir)/run-utilities.c \
-	$(NULL) check-libntp check-libsntp check-libunity .deps-ver
+	$(NULL) $(am__append_4) check-libsntp check-libunity .deps-ver
 
 # data CLEANFILES down below
 CLEANFILES = debug-output-lfp-bin debug-output-lfp-dec \
@@ -777,8 +780,7 @@ CLEANFILES = debug-output-lfp-bin debug-output-lfp-dec \
 	version.c $(NULL) data/kod-output-multiple \
 	data/kod-output-single data/debug-output-pkt \
 	data/debug-output-lfp-dec data/kod-output-blank \
-	data/debug-output-lfp-bin $(NULL) check-libntp check-libsntp \
-	check-libunity .deps-ver
+	data/debug-output-lfp-bin $(NULL) check-libunity .deps-ver
 DISTCLEANFILES = kod-output-blank kod-output-single \
 	kod-output-multiple testLogfile.log testLogfile2.log $(NULL) \
 	$(DEPDIR)/deps-ver
@@ -1614,20 +1616,17 @@ FRC.scm-rev:
 	   always out-of-date causing targets which depend on it to also	\
 	   be outdated so their rules to fire each time they are built.
 
-check-libntp: $(top_builddir)/../libntp/libntp.a
-	@: avoid default SCCS get by some make implementations
+.PHONY: check-libntp
 
-$(top_builddir)/../libntp/libntp.a:
-	cd $(top_builddir)/../libntp && $(MAKE) $(AM_MAKEFLAGS) libntp.a
+@LIBNTP_SUBMAKES_TRUE@check-libntp:
+@LIBNTP_SUBMAKES_TRUE@	cd $(top_builddir)/../libntp && $(MAKE) $(AM_MAKEFLAGS) libntp.a
 
-check-libsntp: $(top_builddir)/sntp/libsntp.a
-	@: avoid default SCCS get by some make implementations
-
-$(top_builddir)/sntp/libsntp.a:
+.PHONY: check-libsntp
+check-libsntp:
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) libsntp.a
 
 check-libunity: $(top_builddir)/unity/libunity.a
-	 @: avoid default SCCS get by some make implementations
+	@echo stamp > $@
 
 $(top_builddir)/unity/libunity.a:
 	cd $(top_builddir)/unity && $(MAKE) $(AM_MAKEFLAGS) libunity.a
diff --git a/contrib/ntp/sntp/tests/crypto.c b/contrib/ntp/sntp/tests/crypto.c
index 8ecd74368011..509efe79c3a2 100644
--- a/contrib/ntp/sntp/tests/crypto.c
+++ b/contrib/ntp/sntp/tests/crypto.c
@@ -7,15 +7,14 @@
 
 #define CMAC "AES128CMAC"
 
-#define MD5_LENGTH 16
 #define SHA1_LENGTH 20
 #define CMAC_LENGTH 16
 
 
-void test_MakeMd5Mac(void);
+void test_MakeSHAKE128Mac(void);
 void test_MakeSHA1Mac(void);
 void test_MakeCMac(void);
-void test_VerifyCorrectMD5(void);
+void test_VerifySHAKE128(void);
 void test_VerifySHA1(void);
 void test_VerifyCMAC(void);
 void test_VerifyFailure(void);
@@ -26,26 +25,36 @@ void VerifyOpenSSLCMAC(struct key *cmac);
 
 
 void
-test_MakeMd5Mac(void)
+test_MakeSHAKE128Mac(void)
 {
-	const char* PKT_DATA = "abcdefgh0123";
-	const int PKT_LEN = strlen(PKT_DATA);
-	const char* EXPECTED_DIGEST =
-		"\x52\x6c\xb8\x38\xaf\x06\x5a\xfb\x6c\x98\xbb\xc0\x9b\x0a\x7a\x1b";
-	char actual[MD5_LENGTH];
-
-	struct key md5;
-	md5.next = NULL;
-	md5.key_id = 10;
-	md5.key_len = 6;
-	memcpy(&md5.key_seq, "md5seq", md5.key_len);
-	strlcpy(md5.typen, "MD5", sizeof(md5.typen));
-	md5.typei = keytype_from_text(md5.typen, NULL);
-	
-	TEST_ASSERT_EQUAL(MD5_LENGTH,
-			  make_mac(PKT_DATA, PKT_LEN, MD5_LENGTH, &md5, actual));
-
-	TEST_ASSERT_TRUE(memcmp(EXPECTED_DIGEST, actual, MD5_LENGTH) == 0);
+#ifdef OPENSSL
+
+	const char KEY[] = "SHAKE128 unit test key";
+	const u_char PAYLOAD[] = "packettestdata16";
+	const size_t PAYLOAD_LEN = sizeof(PAYLOAD) - 1;
+	const u_char EXPECTED_DIGEST[] =
+		"\x62\x5A\x8F\xE4\x66\xCB\xF3\xA6"
+		"\x73\x62\x68\x8D\x11\xB8\x42\xBB";
+	u_char actual[sizeof(EXPECTED_DIGEST) - 1];
+	struct key sk;
+
+	sk.next = NULL;
+	sk.key_id = 10;
+	sk.key_len = sizeof(KEY) - 1;
+	memcpy(&sk.key_seq, KEY, min(sizeof(sk.key_seq), sk.key_len));
+	strlcpy(sk.typen, "SHAKE128", sizeof(sk.typen));
+	sk.typei = keytype_from_text(sk.typen, NULL);
+
+	TEST_ASSERT_EQUAL(sizeof(actual),
+			  make_mac(PAYLOAD, PAYLOAD_LEN, &sk, actual,
+				   sizeof(actual)));
+
+	TEST_ASSERT_EQUAL_HEX8_ARRAY(EXPECTED_DIGEST, actual, sizeof(actual));
+#else
+
+	TEST_IGNORE_MESSAGE("OpenSSL not found, skipping...");
+
+#endif	/* OPENSSL */
 }
 
 
@@ -70,14 +79,15 @@ test_MakeSHA1Mac(void)
 	sha1.typei = keytype_from_text(sha1.typen, NULL);
 
 	TEST_ASSERT_EQUAL(SHA1_LENGTH,
-			  make_mac(PKT_DATA, PKT_LEN, SHA1_LENGTH, &sha1, actual));
+			  make_mac(PKT_DATA, PKT_LEN, &sha1, actual,
+				   SHA1_LENGTH));
 
 	TEST_ASSERT_EQUAL_MEMORY(EXPECTED_DIGEST, actual, SHA1_LENGTH);
-	
+
 #else
-	
+
 	TEST_IGNORE_MESSAGE("OpenSSL not found, skipping...");
-	
+
 #endif	/* OPENSSL */
 }
 
@@ -93,8 +103,8 @@ test_MakeCMac(void)
 		"\xdd\x35\xd5\xf5\x14\x23\xd9\xd6"
 		"\x38\x5d\x29\x80\xfe\x51\xb9\x6b";
 	char actual[CMAC_LENGTH];
-
 	struct key cmac;
+
 	cmac.next = NULL;
 	cmac.key_id = 30;
 	cmac.key_len = CMAC_LENGTH;
@@ -102,37 +112,53 @@ test_MakeCMac(void)
 	memcpy(&cmac.typen, CMAC, strlen(CMAC) + 1);
 
 	TEST_ASSERT_EQUAL(CMAC_LENGTH,
-		    make_mac(PKT_DATA, PKT_LEN, CMAC_LENGTH, &cmac, actual));
+		    make_mac(PKT_DATA, PKT_LEN, &cmac, actual, CMAC_LENGTH));
 
 	TEST_ASSERT_EQUAL_MEMORY(EXPECTED_DIGEST, actual, CMAC_LENGTH);
-	
+
 #else
-	
-	TEST_IGNORE_MESSAGE("OpenSSL not found, skipping...");
-	
+
+	TEST_IGNORE_MESSAGE("CMAC not enabled, skipping...");
+
 #endif	/* OPENSSL */
 }
 
 
 void
-test_VerifyCorrectMD5(void)
+test_VerifySHAKE128(void)
 {
-	const char* PKT_DATA =
-	    "sometestdata"			/* Data */
-	    "\0\0\0\0"				/* Key-ID (unused) */
-	    "\xc7\x58\x99\xdd\x99\x32\x0f\x71"	/* MAC */
-	    "\x2b\x7b\xfe\x4f\xa2\x32\xcf\xac";
-	const int PKT_LEN = 12;
+#ifdef OPENSSL
+	const char KEY[] = "SHAKE128 unit test key";
+	const u_char PAYLOAD[] = "packettestdata16";
+	const size_t PAYLOAD_LEN = sizeof(PAYLOAD) - 1;
+	const u_char EXPECTED_DIGEST[] =
+		"\x62\x5A\x8F\xE4\x66\xCB\xF3\xA6"
+		"\x73\x62\x68\x8D\x11\xB8\x42\xBB";
+	const size_t DIGEST_LEN = sizeof(EXPECTED_DIGEST) - 1;
+	struct key sk;
+	u_char PKT_DATA[  PAYLOAD_LEN + sizeof(sk.key_id)
+			+ DIGEST_LEN];
+	u_char *p;
+
+	sk.next = NULL;
+	sk.key_id = 0;
+	sk.key_len = sizeof(KEY) - 1;
+	memcpy(&sk.key_seq, KEY, min(sizeof(sk.key_seq), sk.key_len));
+	strlcpy(sk.typen, "SHAKE128", sizeof(sk.typen));
+	sk.typei = keytype_from_text(sk.typen, NULL);
+
+	p = PKT_DATA;
+	memcpy(p, PAYLOAD, PAYLOAD_LEN);	  p += PAYLOAD_LEN;
+	memcpy(p, &sk.key_id, sizeof(sk.key_id)); p += sizeof(sk.key_id);
+	memcpy(p, EXPECTED_DIGEST, DIGEST_LEN);	  p += DIGEST_LEN;
+	TEST_ASSERT_TRUE(sizeof(PKT_DATA) == p - PKT_DATA);
+
+	TEST_ASSERT_TRUE(auth_md5(PKT_DATA, PAYLOAD_LEN, DIGEST_LEN, &sk));
+#else
 
-	struct key md5;
-	md5.next = NULL;
-	md5.key_id = 0;
-	md5.key_len = 6;
-	memcpy(&md5.key_seq, "md5key", md5.key_len);
-	strlcpy(md5.typen, "MD5", sizeof(md5.typen));
-	md5.typei = keytype_from_text(md5.typen, NULL);
+	TEST_IGNORE_MESSAGE("OpenSSL not found, skipping...");
 
-	TEST_ASSERT_TRUE(auth_md5(PKT_DATA, PKT_LEN, MD5_LENGTH, &md5));
+#endif	/* OPENSSL */
 }
 
 
@@ -147,21 +173,21 @@ test_VerifySHA1(void)
 	    "\xad\x07\xde\x36\x39\xa6\x77\xfa\x5b\xce"	/* MAC */
 	    "\x2d\x8a\x7d\x06\x96\xe6\x0c\xbc\xed\xe1";
 	const int PKT_LEN = 12;
-
 	struct key sha1;
+
 	sha1.next = NULL;
 	sha1.key_id = 0;
 	sha1.key_len = 7;
 	memcpy(&sha1.key_seq, "sha1key", sha1.key_len);
-	strlcpy(sha1.typen, "SHA1", sizeof(sha1.typen));	
+	strlcpy(sha1.typen, "SHA1", sizeof(sha1.typen));
 	sha1.typei = keytype_from_text(sha1.typen, NULL);
 
 	TEST_ASSERT_TRUE(auth_md5(PKT_DATA, PKT_LEN, SHA1_LENGTH, &sha1));
-	
+
 #else
-	
+
 	TEST_IGNORE_MESSAGE("OpenSSL not found, skipping...");
-	
+
 #endif	/* OPENSSL */
 }
 
@@ -169,12 +195,6 @@ test_VerifySHA1(void)
 void
 test_VerifyCMAC(void)
 {
-	const char* PKT_DATA =
-	    "sometestdata"				/* Data */
-	    "\0\0\0\0"					/* Key-ID (unused) */
-	    "\x4e\x0c\xf0\xe2\xc7\x8e\xbb\xbf"		/* MAC */
-	    "\x79\xfc\x87\xc7\x8b\xb7\x4a\x0b";
-	const int PKT_LEN = 12;
 	struct key cmac;
 
 	cmac.next = NULL;
@@ -198,9 +218,9 @@ VerifyOpenSSLCMAC(struct key *cmac)
 	TEST_IGNORE_MESSAGE("VerifyOpenSSLCMAC needs to be implemented, skipping...");
 
 #else
-	
-	TEST_IGNORE_MESSAGE("OpenSSL not found, skipping...");
-	
+
+	TEST_IGNORE_MESSAGE("CMAC not enabled, skipping...");
+
 #endif	/* OPENSSL */
 	return;
 }
@@ -222,42 +242,77 @@ VerifyLocalCMAC(struct key *cmac)
 void
 test_VerifyFailure(void)
 {
-	/* We use a copy of the MD5 verification code, but modify the
-	 * last bit to make sure verification fails.
+	/*
+	 * We use a copy of test_VerifySHAKE128(), but modify the
+	 * last packet octet to make sure verification fails.
 	 */
-	const char* PKT_DATA =
-	    "sometestdata"			/* Data */
-	    "\0\0\0\0"				/* Key-ID (unused) */
-	    "\xc7\x58\x99\xdd\x99\x32\x0f\x71"	/* MAC */
-	    "\x2b\x7b\xfe\x4f\xa2\x32\xcf\x00"; /* Last byte is wrong! */
-	const int PKT_LEN = 12;
+#ifdef OPENSSL
+	const char KEY[] = "SHAKE128 unit test key";
+	const u_char PAYLOAD[] = "packettestdata1_";
+				/* last packet byte different */
+	const size_t PAYLOAD_LEN = sizeof(PAYLOAD) - 1;
+	const u_char EXPECTED_DIGEST[] =
+		"\x62\x5A\x8F\xE4\x66\xCB\xF3\xA6"
+		"\x73\x62\x68\x8D\x11\xB8\x42\xBB";
+	const size_t DIGEST_LEN = sizeof(EXPECTED_DIGEST) - 1;
+	struct key sk;
+	u_char PKT_DATA[  PAYLOAD_LEN + sizeof(sk.key_id)
+			+ DIGEST_LEN];
+	u_char *p;
+
+	sk.next = NULL;
+	sk.key_id = 0;
+	sk.key_len = sizeof(KEY) - 1;
+	memcpy(&sk.key_seq, KEY, min(sizeof(sk.key_seq), sk.key_len));
+	strlcpy(sk.typen, "SHAKE128", sizeof(sk.typen));
+	sk.typei = keytype_from_text(sk.typen, NULL);
+
+	p = PKT_DATA;
+	memcpy(p, PAYLOAD, PAYLOAD_LEN);	  p += PAYLOAD_LEN;
+	memcpy(p, &sk.key_id, sizeof(sk.key_id)); p += sizeof(sk.key_id);
+	memcpy(p, EXPECTED_DIGEST, DIGEST_LEN);	  p += DIGEST_LEN;
+	TEST_ASSERT_TRUE(sizeof(PKT_DATA) == p - PKT_DATA);
+
+	TEST_ASSERT_FALSE(auth_md5(PKT_DATA, PAYLOAD_LEN, DIGEST_LEN, &sk));
+#else
 
-	struct key md5;
-	md5.next = NULL;
-	md5.key_id = 0;
-	md5.key_len = 6;
-	memcpy(&md5.key_seq, "md5key", md5.key_len);
-	strlcpy(md5.typen, "MD5", sizeof(md5.typen));
-	md5.typei = keytype_from_text(md5.typen, NULL);
+	TEST_IGNORE_MESSAGE("OpenSSL not found, skipping...");
 
-	TEST_ASSERT_FALSE(auth_md5(PKT_DATA, PKT_LEN, MD5_LENGTH, &md5));
+#endif	/* OPENSSL */
 }
 
 
 void
 test_PacketSizeNotMultipleOfFourBytes(void)
 {
-	const char* PKT_DATA = "123456";
-	const int PKT_LEN = 6;
-	char actual[MD5_LENGTH];
-
-	struct key md5;
-	md5.next = NULL;
-	md5.key_id = 10;
-	md5.key_len = 6;
-	memcpy(&md5.key_seq, "md5seq", md5.key_len);
-	strlcpy(md5.typen, "MD5", sizeof(md5.typen));
-	md5.typei = keytype_from_text(md5.typen, NULL);
-
-	TEST_ASSERT_EQUAL(0, make_mac(PKT_DATA, PKT_LEN, MD5_LENGTH, &md5, actual));
+	/*
+	 * We use a copy of test_MakeSHAKE128Mac(), but modify
+	 * the packet length to 17.
+	 */
+#ifdef OPENSSL
+
+	const char KEY[] = "SHAKE128 unit test key";
+	const u_char PAYLOAD[] = "packettestdata_17";
+	const size_t PAYLOAD_LEN = sizeof(PAYLOAD) - 1;
+	const u_char EXPECTED_DIGEST[] =
+		"\x62\x5A\x8F\xE4\x66\xCB\xF3\xA6"
+		"\x73\x62\x68\x8D\x11\xB8\x42\xBB";
+	u_char actual[sizeof(EXPECTED_DIGEST) - 1];
+	struct key sk;
+
+	sk.next = NULL;
+	sk.key_id = 10;
+	sk.key_len = sizeof(KEY) - 1;
+	memcpy(&sk.key_seq, KEY, min(sizeof(sk.key_seq), sk.key_len));
+	strlcpy(sk.typen, "SHAKE128", sizeof(sk.typen));
+	sk.typei = keytype_from_text(sk.typen, NULL);
+
+	TEST_ASSERT_EQUAL(0,
+			  make_mac(PAYLOAD, PAYLOAD_LEN, &sk, actual,
+				   sizeof(actual)));
+#else
+
+	TEST_IGNORE_MESSAGE("OpenSSL not found, skipping...");
+
+#endif	/* OPENSSL */
 }
diff --git a/contrib/ntp/sntp/tests/fileHandlingTest.h.in b/contrib/ntp/sntp/tests/fileHandlingTest.h.in
index b93ed9e90293..86c9f2c7cd0e 100644
--- a/contrib/ntp/sntp/tests/fileHandlingTest.h.in
+++ b/contrib/ntp/sntp/tests/fileHandlingTest.h.in
@@ -1,3 +1,9 @@
+/*
+ * fileHandlingTest.h[.in]
+ *
+ * @configure_input@
+ */
+
 #ifndef FILE_HANDLING_TEST_H
 #define FILE_HANDLING_TEST_H
 
@@ -23,4 +29,4 @@ extern	int		GetFileSize(FILE *file);
 extern	bool		CompareFileContent(FILE* expected, FILE* actual);
 extern	void		ClearFile(const char * filename) ;
 
-#endif // FILE_HANDLING_TEST_H
+#endif	/* FILE_HANDLING_TEST_H */
diff --git a/contrib/ntp/sntp/tests/packetHandling.c b/contrib/ntp/sntp/tests/packetHandling.c
index 6787eeaa2fe9..cf52ccd60faa 100644
--- a/contrib/ntp/sntp/tests/packetHandling.c
+++ b/contrib/ntp/sntp/tests/packetHandling.c
@@ -72,26 +72,36 @@ test_GenerateUnauthenticatedPacket(void)
 void
 test_GenerateAuthenticatedPacket(void)
 {
-	static const int EXPECTED_PKTLEN = LEN_PKT_NOMAC + MAX_MD5_LEN;
-	
+#ifdef OPENSSL
+
+	const int EXPECTED_PKTLEN = LEN_PKT_NOMAC + MAX_SHAKE128_LEN;
+
 	struct key	testkey;
 	struct pkt	testpkt;
 	struct timeval	xmt;
 	l_fp		expected_xmt, actual_xmt;
-	char 		expected_mac[MAX_MD5_LEN];
-	
+	const char key[] = "123456789";
+	size_t		mac_sz;
+	const u_char 	expected_mac[] = {
+				0x46, 0x79, 0x81, 0x6b,
+				0x22, 0xe3, 0xa7, 0xaf,
+				0x1d, 0x63, 0x20, 0xfb,
+				0xc7, 0xd6, 0x87, 0x2c
+			};
+
 	testkey.next = NULL;
 	testkey.key_id = 30;
-	testkey.key_len = 9;
-	memcpy(testkey.key_seq, "123456789", testkey.key_len);
-	strlcpy(testkey.typen, "MD5", sizeof(testkey.typen));
+	strlcpy(testkey.key_seq, key, sizeof(testkey.key_seq));
+	testkey.key_len = strlen(testkey.key_seq);
+	strlcpy(testkey.typen, "SHAKE128", sizeof(testkey.typen));
 	testkey.typei = keytype_from_text(testkey.typen, NULL);
 
-	GETTIMEOFDAY(&xmt, NULL);
-	xmt.tv_sec += JAN_1970;
+	xmt.tv_sec = JAN_1970;
+	xmt.tv_usec = 0;
 
 	TEST_ASSERT_EQUAL(EXPECTED_PKTLEN,
-			  generate_pkt(&testpkt, &xmt, testkey.key_id, &testkey));
+			  generate_pkt(&testpkt, &xmt, testkey.key_id,
+			  &testkey));
 
 	TEST_ASSERT_EQUAL(LEAP_NOTINSYNC, PKT_LEAP(testpkt.li_vn_mode));
 	TEST_ASSERT_EQUAL(NTP_VERSION, PKT_VERSION(testpkt.li_vn_mode));
@@ -105,10 +115,20 @@ test_GenerateAuthenticatedPacket(void)
 	TEST_ASSERT_TRUE(LfpEquality(expected_xmt, actual_xmt));
 
 	TEST_ASSERT_EQUAL(testkey.key_id, ntohl(testpkt.exten[0]));
-	
-	TEST_ASSERT_EQUAL(MAX_MD5_LEN - 4, /* Remove the key_id, only keep the mac. */
-			  make_mac(&testpkt, LEN_PKT_NOMAC, MAX_MD5_LEN-4, &testkey, expected_mac));
-	TEST_ASSERT_EQUAL_MEMORY(expected_mac, (char*)&testpkt.exten[1], MAX_MD5_LEN -4);
+
+	TEST_ASSERT_EQUAL(sizeof(expected_mac), SHAKE128_LENGTH);
+ 	mac_sz = make_mac(&testpkt, LEN_PKT_NOMAC, &testkey,
+			  &testpkt.exten[1], MAX_MDG_LEN);
+	TEST_ASSERT_EQUAL(mac_sz, SHAKE128_LENGTH);
+
+	TEST_ASSERT_EQUAL_MEMORY(expected_mac, (void *)&testpkt.exten[1],
+				 SHAKE128_LENGTH);
+
+#else	/* !OPENSSL follows */
+
+	TEST_IGNORE_MESSAGE("OpenSSL not found, skipping...");
+
+#endif
 }
 
 
@@ -169,7 +189,7 @@ test_OffsetCalculationNegativeOffset(void)
 	rpkt.precision = -1;
 	rpkt.rootdelay = HTONS_FP(DTOUFP(0.5));
 	rpkt.rootdisp = HTONS_FP(DTOUFP(0.5));
-	
+
 	/* Synch Distance is (0.5+0.5)/2.0, or 0.5 */
 	get_systime(&reftime);
 	HTONL_FP(&reftime, &rpkt.reftime);
diff --git a/contrib/ntp/sntp/tests/packetProcessing.c b/contrib/ntp/sntp/tests/packetProcessing.c
index 53c454a9f064..0e7fedee271c 100644
--- a/contrib/ntp/sntp/tests/packetProcessing.c
+++ b/contrib/ntp/sntp/tests/packetProcessing.c
@@ -15,7 +15,6 @@ extern int key_cnt;
 
 
 void PrepareAuthenticationTest(int key_id,int key_len,const char* type,const void* key_seq);
-void PrepareAuthenticationTestMD5(int key_id,int key_len,const void* key_seq);
 void setUp(void);
 void tearDown(void);
 void test_TooShortLength(void);
@@ -35,14 +34,15 @@ void test_RejectWrongResponseServerMode(void);
 void test_AcceptNoSentPacketBroadcastMode(void);
 void test_CorrectUnauthenticatedPacket(void);
 void test_CorrectAuthenticatedPacketMD5(void);
+void test_CorrectAuthenticatedPacketSHAKE128(void);
 void test_CorrectAuthenticatedPacketSHA1(void);
 void test_CorrectAuthenticatedPacketCMAC(void);
 
 /* [Bug 2998] There are some issues whith the definition of 'struct pkt'
  * when AUTOKEY is undefined -- the formal struct is too small to hold
  * all the extension fields that are going to be tested. We have to make
- * sure we have the extra bytes, or the test yield undefined results due
- * to buffer overrun. 
+ * sure we have the extra bytes, or the test yields undefined results due
+ * to buffer overrun.
  */
 #ifndef AUTOKEY
 # define EXTRA_BUFSIZE 256
@@ -53,7 +53,7 @@ void test_CorrectAuthenticatedPacketCMAC(void);
 union tpkt {
 	struct pkt p;
 	u_char     b[sizeof(struct pkt) + EXTRA_BUFSIZE];
-}; 
+};
 
 static union tpkt testpkt;
 static union tpkt testspkt;
@@ -70,34 +70,27 @@ PrepareAuthenticationTest(
 	)
 {
 	char str[25];
-	snprintf(str, 25, "%d", key_id);
+
+	snprintf(str, sizeof(str), "%d", key_id);
 	ActivateOption("-a", str);
 
 	key_cnt = 1;
-	key_ptr = emalloc(sizeof(struct key));
+	if (NULL == key_ptr) {
+		key_ptr = emalloc(sizeof(*key_ptr));
+	}
 	key_ptr->next = NULL;
 	key_ptr->key_id = key_id;
 	key_ptr->key_len = key_len;
-	memcpy(key_ptr->typen, type, strlen(type) + 1);
+	strncpy(key_ptr->typen, type, sizeof(key_ptr->typen));
 
 	TEST_ASSERT_TRUE(key_len < sizeof(key_ptr->key_seq));
 
-	memcpy(key_ptr->key_seq, key_seq, key_ptr->key_len);
+	memcpy(key_ptr->key_seq, key_seq,
+	       min(key_len, sizeof(key_ptr->key_seq)));
 	restoreKeyDb = true;
 }
 
 
-void
-PrepareAuthenticationTestMD5(
-	int 		key_id,
-	int 		key_len,
-	const void *	key_seq
-	)
-{
-	PrepareAuthenticationTest(key_id, key_len, "MD5", key_seq);
-}
-
-
 void
 setUp(void)
 {
@@ -109,7 +102,7 @@ setUp(void)
 	 * so they contain at least some valid data.
 	 */
 	testpkt.p.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOWARNING, NTP_VERSION,
-										MODE_SERVER);
+					      MODE_SERVER);
 	testpkt.p.stratum = STRATUM_REFCLOCK;
 	memcpy(&testpkt.p.refid, "GPS\0", 4);
 
@@ -127,7 +120,7 @@ setUp(void)
 
 void
 tearDown(void)
-{	
+{
 	if (restoreKeyDb) {
 		key_cnt = 0;
 		free(key_ptr);
@@ -171,7 +164,7 @@ test_TooShortExtensionFieldLength(void)
 	 * still...
 	 */
 	uint32_t * pe = testpkt.p.exten + 7;
-	
+
 	/* The lower 16-bits are the length of the extension field.
 	 * This lengths must be multiples of 4 bytes, which gives
 	 * a minimum of 4 byte extension field length.
@@ -224,19 +217,20 @@ test_CryptoNAKPacketReject(void)
 void
 test_AuthenticatedPacketInvalid(void)
 {
+#ifdef OPENSSL
+	size_t pkt_len = LEN_PKT_NOMAC;
+	size_t mac_len;
+
 	/* Activate authentication option */
-	PrepareAuthenticationTestMD5(50, 9, "123456789");
+	PrepareAuthenticationTest(50, 9, "SHAKE128", "123456789");
 	TEST_ASSERT_TRUE(ENABLED_OPT(AUTHENTICATION));
-	
-	/* Prepare the packet. */
-	int pkt_len = LEN_PKT_NOMAC;
 
+	/* Prepare the packet. */
 	testpkt.p.exten[0] = htonl(50);
-	int mac_len = make_mac(&testpkt.p, pkt_len,
-			       MAX_MD5_LEN - KEY_MAC_LEN, key_ptr,
-			       &testpkt.p.exten[1]);
+	mac_len = make_mac(&testpkt.p, pkt_len, key_ptr,
+			   &testpkt.p.exten[1], MAX_MDG_LEN);
 
-	pkt_len += 4 + mac_len;
+	pkt_len += KEY_MAC_LEN + mac_len;
 
 	/* Now, alter the MAC so it becomes invalid. */
 	testpkt.p.exten[1] += 1;
@@ -244,30 +238,43 @@ test_AuthenticatedPacketInvalid(void)
 	TEST_ASSERT_EQUAL(SERVER_AUTH_FAIL,
 			  process_pkt(&testpkt.p, &testsock, pkt_len,
 				      MODE_SERVER, &testspkt.p, "UnitTest"));
+
+#else
+
+	TEST_IGNORE_MESSAGE("OpenSSL not enabled, skipping...");
+
+#endif
 }
 
 
 void
 test_AuthenticatedPacketUnknownKey(void)
 {
+#ifdef OPENSSL
+	size_t pkt_len = LEN_PKT_NOMAC;
+	size_t mac_len;
+
 	/* Activate authentication option */
-	PrepareAuthenticationTestMD5(30, 9, "123456789");
+	PrepareAuthenticationTest(30, 9, "SHAKE128", "123456789");
 	TEST_ASSERT_TRUE(ENABLED_OPT(AUTHENTICATION));
-	
+
 	/* Prepare the packet. Note that the Key-ID expected is 30, but
 	 * the packet has a key id of 50.
 	 */
-	int pkt_len = LEN_PKT_NOMAC;
-
 	testpkt.p.exten[0] = htonl(50);
-	int mac_len = make_mac(&testpkt.p, pkt_len,
-			       MAX_MD5_LEN - KEY_MAC_LEN, key_ptr,
-			       &testpkt.p.exten[1]);
+	mac_len = make_mac(&testpkt.p, pkt_len, key_ptr,
+			   &testpkt.p.exten[1], MAX_MDG_LEN);
 	pkt_len += KEY_MAC_LEN + mac_len;
 
 	TEST_ASSERT_EQUAL(SERVER_AUTH_FAIL,
 			  process_pkt(&testpkt.p, &testsock, pkt_len,
 				      MODE_SERVER, &testspkt.p, "UnitTest"));
+
+#else
+
+	TEST_IGNORE_MESSAGE("OpenSSL not enabled, skipping...");
+
+#endif
 }
 
 
@@ -282,7 +289,7 @@ test_ServerVersionTooOld(void)
 	TEST_ASSERT_TRUE(PKT_VERSION(testpkt.p.li_vn_mode) < NTP_OLDVERSION);
 
 	int pkt_len = LEN_PKT_NOMAC;
-	
+
 	TEST_ASSERT_EQUAL(SERVER_UNUSEABLE,
 			  process_pkt(&testpkt.p, &testsock, pkt_len,
 				      MODE_SERVER, &testspkt.p, "UnitTest"));
@@ -418,44 +425,96 @@ test_CorrectUnauthenticatedPacket(void)
 void
 test_CorrectAuthenticatedPacketMD5(void)
 {
-	PrepareAuthenticationTestMD5(10, 15, "123456789abcdef");
+#ifdef OPENSSL
+
+	keyid_t k_id = 10;
+	int pkt_len = LEN_PKT_NOMAC;
+	int mac_len;
+
+	PrepareAuthenticationTest(k_id, 15, "MD5", "123456789abcdef");
 	TEST_ASSERT_TRUE(ENABLED_OPT(AUTHENTICATION));
 
+	/* Prepare the packet. */
+	testpkt.p.exten[0] = htonl(k_id);
+	mac_len = make_mac(&testpkt.p, pkt_len, key_ptr,
+			   &testpkt.p.exten[1], MAX_MDG_LEN);
+
+	/* TODO: Should not expect failure if non-FIPS OpenSSL */
+	TEST_EXPECT_FAIL_MESSAGE("FIPS OpenSSL bars MD5");
+
+	pkt_len += KEY_MAC_LEN + mac_len;
+
+	TEST_ASSERT_EQUAL(pkt_len,
+			  process_pkt(&testpkt.p, &testsock, pkt_len,
+				      MODE_SERVER, &testspkt.p, "UnitTest"));
+
+#else
+
+	TEST_IGNORE_MESSAGE("OpenSSL not enabled, skipping...");
+
+#endif
+}
+
+
+void
+test_CorrectAuthenticatedPacketSHAKE128(void)
+{
+#ifdef OPENSSL
+
+	keyid_t k_id = 10;
 	int pkt_len = LEN_PKT_NOMAC;
+	int mac_len;
+
+	PrepareAuthenticationTest(k_id, 15, "SHAKE128", "123456789abcdef");
+	TEST_ASSERT_TRUE(ENABLED_OPT(AUTHENTICATION));
 
 	/* Prepare the packet. */
-	testpkt.p.exten[0] = htonl(10);
-	int mac_len = make_mac(&testpkt.p, pkt_len,
-			       MAX_MD5_LEN - KEY_MAC_LEN, key_ptr,
-			       &testpkt.p.exten[1]);
+	testpkt.p.exten[0] = htonl(k_id);
+	mac_len = make_mac(&testpkt.p, pkt_len, key_ptr, &testpkt.p.exten[1],
+			   SHAKE128_LENGTH);
 
 	pkt_len += KEY_MAC_LEN + mac_len;
 
 	TEST_ASSERT_EQUAL(pkt_len,
 			  process_pkt(&testpkt.p, &testsock, pkt_len,
 				      MODE_SERVER, &testspkt.p, "UnitTest"));
+
+#else
+
+	TEST_IGNORE_MESSAGE("OpenSSL not enabled, skipping...");
+
+#endif
 }
 
 
 void
 test_CorrectAuthenticatedPacketSHA1(void)
 {
-	PrepareAuthenticationTest(20, 15, "SHA1", "abcdefghijklmno");
-	TEST_ASSERT_TRUE(ENABLED_OPT(AUTHENTICATION));
+#ifdef OPENSSL
 
+	keyid_t k_id = 20;
 	int pkt_len = LEN_PKT_NOMAC;
+	int mac_len;
+
+	PrepareAuthenticationTest(k_id, 15, "SHA1", "abcdefghijklmno");
+	TEST_ASSERT_TRUE(ENABLED_OPT(AUTHENTICATION));
 
 	/* Prepare the packet. */
-	testpkt.p.exten[0] = htonl(20);
-	int mac_len = make_mac(&testpkt.p, pkt_len,
-			       MAX_MDG_LEN, key_ptr,
-			       &testpkt.p.exten[1]);
+	testpkt.p.exten[0] = htonl(k_id);
+	mac_len = make_mac(&testpkt.p, pkt_len, key_ptr, &testpkt.p.exten[1],
+			   SHA1_LENGTH);
 
 	pkt_len += KEY_MAC_LEN + mac_len;
 
 	TEST_ASSERT_EQUAL(pkt_len,
 			  process_pkt(&testpkt.p, &testsock, pkt_len,
 				      MODE_SERVER, &testspkt.p, "UnitTest"));
+
+#else
+
+	TEST_IGNORE_MESSAGE("OpenSSL not enabled, skipping...");
+
+#endif
 }
 
 
@@ -471,9 +530,8 @@ test_CorrectAuthenticatedPacketCMAC(void)
 
 	/* Prepare the packet. */
 	testpkt.p.exten[0] = htonl(30);
-	int mac_len = make_mac(&testpkt.p, pkt_len,
-			       MAX_MAC_LEN, key_ptr,
-			       &testpkt.p.exten[1]);
+	int mac_len = make_mac(&testpkt.p, pkt_len, key_ptr,
+			       &testpkt.p.exten[1], MAX_MAC_LEN);
 
 	pkt_len += 4 + mac_len;
 
@@ -482,9 +540,9 @@ test_CorrectAuthenticatedPacketCMAC(void)
 				      MODE_SERVER, &testspkt.p, "UnitTest"));
 
 #else
-	
-	TEST_IGNORE_MESSAGE("OpenSSL CMAC not used, skipping...");
-	
+
+	TEST_IGNORE_MESSAGE("CMAC not enabled, skipping...");
+
 #endif	/* OPENSSL */
 }
 
diff --git a/contrib/ntp/sntp/tests/run-crypto.c b/contrib/ntp/sntp/tests/run-crypto.c
index a486f86c4035..83e8d19434aa 100644
--- a/contrib/ntp/sntp/tests/run-crypto.c
+++ b/contrib/ntp/sntp/tests/run-crypto.c
@@ -30,10 +30,10 @@
 //=======External Functions This Runner Calls=====
 extern void setUp(void);
 extern void tearDown(void);
-extern void test_MakeMd5Mac(void);
+extern void test_MakeSHAKE128Mac(void);
 extern void test_MakeSHA1Mac(void);
 extern void test_MakeCMac(void);
-extern void test_VerifyCorrectMD5(void);
+extern void test_VerifySHAKE128(void);
 extern void test_VerifySHA1(void);
 extern void test_VerifyCMAC(void);
 extern void test_VerifyFailure(void);
@@ -66,14 +66,14 @@ int main(int argc, char *argv[])
   progname = argv[0];
   suite_setup();
   UnityBegin("crypto.c");
-  RUN_TEST(test_MakeMd5Mac, 15);
-  RUN_TEST(test_MakeSHA1Mac, 16);
-  RUN_TEST(test_MakeCMac, 17);
-  RUN_TEST(test_VerifyCorrectMD5, 18);
-  RUN_TEST(test_VerifySHA1, 19);
-  RUN_TEST(test_VerifyCMAC, 20);
-  RUN_TEST(test_VerifyFailure, 21);
-  RUN_TEST(test_PacketSizeNotMultipleOfFourBytes, 22);
+  RUN_TEST(test_MakeSHAKE128Mac, 14);
+  RUN_TEST(test_MakeSHA1Mac, 15);
+  RUN_TEST(test_MakeCMac, 16);
+  RUN_TEST(test_VerifySHAKE128, 17);
+  RUN_TEST(test_VerifySHA1, 18);
+  RUN_TEST(test_VerifyCMAC, 19);
+  RUN_TEST(test_VerifyFailure, 20);
+  RUN_TEST(test_PacketSizeNotMultipleOfFourBytes, 21);
 
   return (UnityEnd());
 }
diff --git a/contrib/ntp/sntp/tests/run-packetProcessing.c b/contrib/ntp/sntp/tests/run-packetProcessing.c
index c91a6d340a39..eeeb6f1bf2f6 100644
--- a/contrib/ntp/sntp/tests/run-packetProcessing.c
+++ b/contrib/ntp/sntp/tests/run-packetProcessing.c
@@ -47,6 +47,7 @@ extern void test_RejectWrongResponseServerMode(void);
 extern void test_AcceptNoSentPacketBroadcastMode(void);
 extern void test_CorrectUnauthenticatedPacket(void);
 extern void test_CorrectAuthenticatedPacketMD5(void);
+extern void test_CorrectAuthenticatedPacketSHAKE128(void);
 extern void test_CorrectAuthenticatedPacketSHA1(void);
 extern void test_CorrectAuthenticatedPacketCMAC(void);
 
@@ -77,25 +78,26 @@ int main(int argc, char *argv[])
   progname = argv[0];
   suite_setup();
   UnityBegin("packetProcessing.c");
-  RUN_TEST(test_TooShortLength, 23);
-  RUN_TEST(test_LengthNotMultipleOfFour, 24);
-  RUN_TEST(test_TooShortExtensionFieldLength, 25);
-  RUN_TEST(test_UnauthenticatedPacketReject, 26);
-  RUN_TEST(test_CryptoNAKPacketReject, 27);
-  RUN_TEST(test_AuthenticatedPacketInvalid, 28);
-  RUN_TEST(test_AuthenticatedPacketUnknownKey, 29);
-  RUN_TEST(test_ServerVersionTooOld, 30);
-  RUN_TEST(test_ServerVersionTooNew, 31);
-  RUN_TEST(test_NonWantedMode, 32);
-  RUN_TEST(test_KoDRate, 33);
-  RUN_TEST(test_KoDDeny, 34);
-  RUN_TEST(test_RejectUnsyncedServer, 35);
-  RUN_TEST(test_RejectWrongResponseServerMode, 36);
-  RUN_TEST(test_AcceptNoSentPacketBroadcastMode, 37);
-  RUN_TEST(test_CorrectUnauthenticatedPacket, 38);
-  RUN_TEST(test_CorrectAuthenticatedPacketMD5, 39);
-  RUN_TEST(test_CorrectAuthenticatedPacketSHA1, 40);
-  RUN_TEST(test_CorrectAuthenticatedPacketCMAC, 41);
+  RUN_TEST(test_TooShortLength, 20);
+  RUN_TEST(test_LengthNotMultipleOfFour, 21);
+  RUN_TEST(test_TooShortExtensionFieldLength, 22);
+  RUN_TEST(test_UnauthenticatedPacketReject, 23);
+  RUN_TEST(test_CryptoNAKPacketReject, 24);
+  RUN_TEST(test_AuthenticatedPacketInvalid, 25);
+  RUN_TEST(test_AuthenticatedPacketUnknownKey, 26);
+  RUN_TEST(test_ServerVersionTooOld, 27);
+  RUN_TEST(test_ServerVersionTooNew, 28);
+  RUN_TEST(test_NonWantedMode, 29);
+  RUN_TEST(test_KoDRate, 30);
+  RUN_TEST(test_KoDDeny, 31);
+  RUN_TEST(test_RejectUnsyncedServer, 32);
+  RUN_TEST(test_RejectWrongResponseServerMode, 33);
+  RUN_TEST(test_AcceptNoSentPacketBroadcastMode, 34);
+  RUN_TEST(test_CorrectUnauthenticatedPacket, 35);
+  RUN_TEST(test_CorrectAuthenticatedPacketMD5, 36);
+  RUN_TEST(test_CorrectAuthenticatedPacketSHAKE128, 37);
+  RUN_TEST(test_CorrectAuthenticatedPacketSHA1, 38);
+  RUN_TEST(test_CorrectAuthenticatedPacketCMAC, 39);
 
   return (UnityEnd());
 }
diff --git a/contrib/ntp/sntp/unity/Makefile.in b/contrib/ntp/sntp/unity/Makefile.in
index 927f648ffea8..424d7ca4497f 100644
--- a/contrib/ntp/sntp/unity/Makefile.in
+++ b/contrib/ntp/sntp/unity/Makefile.in
@@ -98,6 +98,7 @@ am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
 	$(top_srcdir)/m4/ntp_cacheversion.m4 \
 	$(top_srcdir)/m4/ntp_compiler.m4 \
 	$(top_srcdir)/m4/ntp_crosscompile.m4 \
+	$(top_srcdir)/m4/ntp_crypto_rand.m4 \
 	$(top_srcdir)/m4/ntp_debug.m4 $(top_srcdir)/m4/ntp_dir_sep.m4 \
 	$(top_srcdir)/m4/ntp_facilitynames.m4 \
 	$(top_srcdir)/m4/ntp_harden.m4 $(top_srcdir)/m4/ntp_ipv6.m4 \
@@ -354,6 +355,7 @@ PACKAGE_STRING = @PACKAGE_STRING@
 PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_OPENSSL = @PATH_OPENSSL@
 PATH_RUBY = @PATH_RUBY@
 PATH_SEPARATOR = @PATH_SEPARATOR@
 PKG_CONFIG = @PKG_CONFIG@
diff --git a/contrib/ntp/sntp/unity/unity_internals.h b/contrib/ntp/sntp/unity/unity_internals.h
index a04f52b478bb..3d22e7aa20e8 100644
--- a/contrib/ntp/sntp/unity/unity_internals.h
+++ b/contrib/ntp/sntp/unity/unity_internals.h
@@ -519,6 +519,9 @@ void UnityAssertDoubleSpecial(const _UD actual,
                               const UNITY_FLOAT_TRAIT_T style);
 #endif
 
+void UnityExpectFailMessage(const char* msg,
+                            const UNITY_LINE_TYPE line);
+
 //-------------------------------------------------------
 // Error Strings We Might Need
 //-------------------------------------------------------
@@ -708,8 +711,7 @@ extern const char UnityStrErr64[];
 //End of UNITY_INTERNALS_H
 #endif
 
-//#define TEST_EXPECT_FAIL()																		Unity.isExpectingFail = 1;
-//#define TEST_EXPECT_FAIL_MESSAGE(message)														Unity.isExpectingFail = 1; Unity.XFAILMessage = message; //PROBLEM : does this work on all compilers?
+// Not part of standard distribution
 
-#define TEST_EXPECT_FAIL()																		UnityExpectFail();
-#define TEST_EXPECT_FAIL_MESSAGE(message)														UnityExpectFailMessage( (message) );
+#define TEST_EXPECT_FAIL()									UnityExpectFail();
+#define TEST_EXPECT_FAIL_MESSAGE(message)							UnityExpectFailMessage((message), __LINE__);
diff --git a/contrib/ntp/sntp/utilities.h b/contrib/ntp/sntp/utilities.h
index a022c7d49769..4503877bc256 100644
--- a/contrib/ntp/sntp/utilities.h
+++ b/contrib/ntp/sntp/utilities.h
@@ -7,7 +7,6 @@
 
 #include "ntp.h"
 #include "ntp_stdlib.h"
-#include "lib_strbuf.h"
 
 #define HLINE "--------------------------------------------------------------------------------\n"
 #define PHLINE fprintf(output, HLINE);
diff --git a/contrib/ntp/tests/libntp/data/ntp.keys b/contrib/ntp/tests/libntp/data/ntp.keys
index 6c8c743fd7d2..ef634dd00ebd 100644
--- a/contrib/ntp/tests/libntp/data/ntp.keys
+++ b/contrib/ntp/tests/libntp/data/ntp.keys
@@ -1,15 +1,16 @@
-# This unit test ntp.keys file has hard-coded the current set
-# of OpenSSL-supported digest algorithms.  It needs to be updated
-# after newer algorithms are available.  The current list can be
+# This unit test ntp.keys file has hard-coded the union of sets
+# of OpenSSL-supported digest algorithms we've come across.  It
+# needs to be updated as algorithms are observed.  A list can be
 # obtained with:
 #
 # ntpq -c "help keytype"
 #
-# tests/libntp/digest.c similarly hardcodes the list of digests
-# to test.
+# tests/libntp/digests.c similarly hardcodes the list of digests
+# to test.  This file must be kept in sync with it.
 #
 # Each digest is tested twice with keyids separated by 50 for
 # plaintext and hex-encoded keys.
+#
 
  1 AES128CMAC	X~A=%NWlo]p$dGq,S3M9
  2 MD4		oV'8?f+J5`_EOvW!B,R`
@@ -18,9 +19,9 @@
  5 RIPEMD160	I89p}f6QopwC\LwHBm;e
  6 SHA1		A;H=E;.m4N%t%EeJ90[d
  7 SHAKE128	|HxLoa,mzG<"y>^TI_(1
- 8 MD5		306+^SHLV5{"v7W`U3aY	# unused so far
- 9 MD5		lGyKZgsI_Pi"y"8JAT98	# unused
-10 MD5		2:VO]Q5u%/b&}.<P?T~9	# unused
+ 8 DSA		306+^SHLV5{"v7W`U3aY
+ 9 DSA-SHA	lGyKZgsI_Pi"y"8JAT98
+10 SHA		2:VO]Q5u%/b&}.<P?T~9
 
 51 AES128CMAC 	d0cd9f3ee181769ca7cccaada09f093c5fe8e628
 52 MD4		7080bc47eea6b379b2ff841805a144fb4a241a16
@@ -29,6 +30,6 @@
 55 RIPEMD160	6028ec169bfbe55ab61ffa7baa34b482020f0619
 56 SHA1		17d96a86eb9b9075f33e1c0a08bb2bb61e916e33
 57 SHAKE128	70da1a91030eb91836c1cf76cf67ddfd6b96fa91
-58 SHA1		7ce5deea7569d7423d5e1b497c8eb3bfeff852d5	# unused so far
-59 SHA1		9fd568e8f371deae54a65bc50b52bbe1f6529589	# unused
-60 SHA1		ce85046978a4df8366e102c4f1267399bbc25737	# unused
+58 DSA		7ce5deea7569d7423d5e1b497c8eb3bfeff852d5
+59 DSA-SHA	9fd568e8f371deae54a65bc50b52bbe1f6529589
+60 SHA		ce85046978a4df8366e102c4f1267399bbc25737
diff --git a/contrib/ntp/tests/libntp/digests.c b/contrib/ntp/tests/libntp/digests.c
index 03e9ef1b838e..10b9d2c12ac0 100644
--- a/contrib/ntp/tests/libntp/digests.c
+++ b/contrib/ntp/tests/libntp/digests.c
@@ -110,7 +110,7 @@ do {									\
 	authtrust((key), 1);						\
 									\
 	res_sz = authencrypt((key), pkt, pkt_sz);			\
-	if (KEY_MAC_LEN == res_sz) {					\
+	if (0 == res_sz) {						\
 		TEST_IGNORE_MESSAGE("Likely OpenSSL 3 failed digest "	\
 				    "init.");				\
 		return;							\
@@ -363,7 +363,7 @@ void test_Digest_SHAKE128(void)
 			0xaa, 0xa6, 0xcd, 0x76
 		};
 	u_char expectedB[MAX_MAC_LEN] =
-		{ 
+		{
 			0, 0, 0, KEYID_B,
 			0x07, 0x04, 0x63, 0xcc,
 			0x46, 0xaf, 0xca, 0x00,
@@ -380,6 +380,123 @@ void test_Digest_SHAKE128(void)
 }
 
 
+#define DSA_KEYID		8
+#undef KEYID_A
+#define KEYID_A			DSA_KEYID
+#undef DG_SZ
+#define DG_SZ			20
+#undef KEYID_B
+#define KEYID_B			(KEYID_A + HEX_KEYID_OFFSET)
+void test_Digest_DSA(void);
+void test_Digest_DSA(void)
+{
+#ifdef OPENSSL
+	u_char expectedA[MAX_MAC_LEN] =
+		{
+			0, 0, 0, KEYID_A,
+			0xaf, 0xa0, 0x1d, 0x0c,
+			0x92, 0xcb, 0xca, 0x95,
+			0x0d, 0x57, 0x60, 0x49,
+			0xe5, 0x28, 0x03, 0xf2,
+			0x7b, 0x5b, 0xb1, 0x4a
+		};
+	u_char expectedB[MAX_MAC_LEN] =
+		{
+			0, 0, 0, KEYID_B,
+			0x77, 0xcd, 0x88, 0xc2,
+			0xed, 0x5d, 0x57, 0xc5,
+			0x28, 0x92, 0xf0, 0x21,
+			0x2b, 0xb9, 0x48, 0xac,
+			0xfe, 0x9f, 0xf5, 0x1c
+		};
+
+	TEST_ASSERT(setup);
+	TEST_ONE_DIGEST(KEYID_A, DG_SZ, expectedA);
+	TEST_ONE_DIGEST(KEYID_B, DG_SZ, expectedB);
+#else	/* ! OPENSSL follows  */
+	TEST_IGNORE_MESSAGE("Skipping, no OPENSSL");
+#endif
+}
+
+
+#define DSA_SHA_KEYID		9
+#undef KEYID_A
+#define KEYID_A			DSA_SHA_KEYID
+#undef DG_SZ
+#define DG_SZ			20
+#undef KEYID_B
+#define KEYID_B			(KEYID_A + HEX_KEYID_OFFSET)
+void test_Digest_DSA_SHA(void);
+void test_Digest_DSA_SHA(void)
+{
+#ifdef OPENSSL
+	u_char expectedA[MAX_MAC_LEN] =
+		{
+			0, 0, 0, KEYID_A,
+			0x7c, 0xb5, 0x79, 0xd0,
+			0xf2, 0xcd, 0x47, 0xc0,
+			0x21, 0xf3, 0xf5, 0x04,
+			0x10, 0xc4, 0x59, 0x5c,
+			0xd9, 0xa4, 0x4f, 0x3b
+		};
+	u_char expectedB[MAX_MAC_LEN] =
+		{
+			0, 0, 0, KEYID_B,
+			0xb9, 0xca, 0xa6, 0x8e,
+			0xd3, 0xcb, 0x94, 0x6a,
+			0x6d, 0xae, 0xb4, 0xc8,
+			0x0e, 0xc9, 0xf6, 0xed,
+			0x58, 0x1a, 0xed, 0x22
+		};
+
+	TEST_ASSERT(setup);
+	TEST_ONE_DIGEST(KEYID_A, DG_SZ, expectedA);
+	TEST_ONE_DIGEST(KEYID_B, DG_SZ, expectedB);
+#else	/* ! OPENSSL follows  */
+	TEST_IGNORE_MESSAGE("Skipping, no OPENSSL");
+#endif
+}
+
+
+#define SHA_KEYID		10
+#undef KEYID_A
+#define KEYID_A			SHA_KEYID
+#undef DG_SZ
+#define DG_SZ			20
+#undef KEYID_B
+#define KEYID_B			(KEYID_A + HEX_KEYID_OFFSET)
+void test_Digest_SHA(void);
+void test_Digest_SHA(void)
+{
+#ifdef OPENSSL
+	u_char expectedA[MAX_MAC_LEN] =
+		{
+			0, 0, 0, KEYID_A,
+			0xd5, 0xbd, 0xb8, 0x55,
+			0x9b, 0x9e, 0x5e, 0x8f,
+			0x1a, 0x3d, 0x99, 0x60,
+			0xbd, 0x70, 0x0c, 0x5c,
+			0x68, 0xae, 0xb0, 0xbd
+		};
+	u_char expectedB[MAX_MAC_LEN] =
+		{
+			0, 0, 0, KEYID_B,
+			0x63, 0x05, 0x41, 0x45,
+			0xe9, 0x61, 0x84, 0xe7,
+			0xc6, 0x94, 0x24, 0xa4,
+			0x84, 0x76, 0xc7, 0xc9,
+			0xdd, 0x80, 0x80, 0x89
+		};
+
+	TEST_ASSERT(setup);
+	TEST_ONE_DIGEST(KEYID_A, DG_SZ, expectedA);
+	TEST_ONE_DIGEST(KEYID_B, DG_SZ, expectedB);
+#else	/* ! OPENSSL follows  */
+	TEST_IGNORE_MESSAGE("Skipping, no OPENSSL");
+#endif
+}
+
+
 /*
  * Dump a MAC in a form easy to cut and paste into the expected declaration.
  */
@@ -395,8 +512,8 @@ void dump_mac(
 
 	dc += snprintf(dump + dc, sizeof(dump) - dc, "digest with key %u { ", keyid);
 
-	for (idx = 0; idx < octets; idx++) {
-		if (10 == idx) {
+	for (idx = 4; idx < octets; idx++) {
+		if (14 == idx) {
 			msyslog(LOG_DEBUG, "%s", dump);
 			dc = 0;
 		}
diff --git a/contrib/ntp/tests/libntp/run-digests.c b/contrib/ntp/tests/libntp/run-digests.c
index ae574d0e239e..bc56f1cb92e6 100644
--- a/contrib/ntp/tests/libntp/run-digests.c
+++ b/contrib/ntp/tests/libntp/run-digests.c
@@ -40,6 +40,9 @@ extern void test_Digest_MDC2(void);
 extern void test_Digest_RIPEMD160(void);
 extern void test_Digest_SHA1(void);
 extern void test_Digest_SHAKE128(void);
+extern void test_Digest_DSA(void);
+extern void test_Digest_DSA_SHA(void);
+extern void test_Digest_SHA(void);
 
 
 //=======Suite Setup=====
@@ -75,6 +78,9 @@ int main(int argc, char *argv[])
   RUN_TEST(test_Digest_RIPEMD160, 275);
   RUN_TEST(test_Digest_SHA1, 314);
   RUN_TEST(test_Digest_SHAKE128, 353);
+  RUN_TEST(test_Digest_DSA, 390);
+  RUN_TEST(test_Digest_DSA_SHA, 429);
+  RUN_TEST(test_Digest_SHA, 468);
 
   return (UnityEnd());
 }
diff --git a/contrib/ntp/util/Makefile.am b/contrib/ntp/util/Makefile.am
index cef623c592d0..db0e8e65d747 100644
--- a/contrib/ntp/util/Makefile.am
+++ b/contrib/ntp/util/Makefile.am
@@ -4,7 +4,8 @@ bin_PROGRAMS=	$(NTP_KEYGEN_DB) $(NTPTIME_DB) $(TICKADJ_DB) $(TIMETRIM_DB)
 libexec_PROGRAMS=	$(NTP_KEYGEN_DL) $(NTPTIME_DL) $(TICKADJ_DL) $(TIMETRIM_DL)
 sbin_PROGRAMS=	$(NTP_KEYGEN_DS) $(NTPTIME_DS) $(TICKADJ_DS) $(TIMETRIM_DS)
 
-EXTRA_PROGRAMS=	audio-pcm byteorder hist jitter kern longsize ntp-keygen \
+EXTRA_PROGRAMS=	audio-pcm byteorder hist jitter kern longsize lsf-times \
+	ntp-keygen \
 	ntptime pps-api precision sht testrs6000 tg tg2 tickadj timetrim
 
 AM_CFLAGS  = $(CFLAGS_NTP)
@@ -32,6 +33,7 @@ tickadj_LDADD=	../libntp/libntp.a $(LDADD_LIBNTP) $(LIBM) $(PTHREAD_LIBS) $(LDAD
 EXTRA_DIST=				\
 	invoke-ntp-keygen.menu		\
 	invoke-ntp-keygen.texi		\
+	lsf-times.c			\
 	ntp-keygen-opts.def		\
 	ntp-keygen.1ntp-keygenman	\
 	ntp-keygen.1ntp-keygenmdoc	\
diff --git a/contrib/ntp/util/Makefile.in b/contrib/ntp/util/Makefile.in
index bfc308c6cc5f..f98e15193aa4 100644
--- a/contrib/ntp/util/Makefile.in
+++ b/contrib/ntp/util/Makefile.in
@@ -95,9 +95,11 @@ build_triplet = @build@
 host_triplet = @host@
 EXTRA_PROGRAMS = audio-pcm$(EXEEXT) byteorder$(EXEEXT) hist$(EXEEXT) \
 	jitter$(EXEEXT) kern$(EXEEXT) longsize$(EXEEXT) \
-	ntp-keygen$(EXEEXT) ntptime$(EXEEXT) pps-api$(EXEEXT) \
-	precision$(EXEEXT) sht$(EXEEXT) testrs6000$(EXEEXT) \
-	tg$(EXEEXT) tg2$(EXEEXT) tickadj$(EXEEXT) timetrim$(EXEEXT)
+	lsf-times$(EXEEXT) ntp-keygen$(EXEEXT) ntptime$(EXEEXT) \
+	pps-api$(EXEEXT) precision$(EXEEXT) sht$(EXEEXT) \
+	testrs6000$(EXEEXT) tg$(EXEEXT) tg2$(EXEEXT) tickadj$(EXEEXT) \
+	timetrim$(EXEEXT)
+@LIBNTP_SUBMAKES_TRUE@am__append_1 = check-libntp
 subdir = util
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
@@ -184,6 +186,11 @@ longsize_OBJECTS = longsize.$(OBJEXT)
 longsize_LDADD = $(LDADD)
 longsize_DEPENDENCIES = ../libntp/libntp.a $(am__DEPENDENCIES_1) \
 	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+lsf_times_SOURCES = lsf-times.c
+lsf_times_OBJECTS = lsf-times.$(OBJEXT)
+lsf_times_LDADD = $(LDADD)
+lsf_times_DEPENDENCIES = ../libntp/libntp.a $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
 am_ntp_keygen_OBJECTS = ntp-keygen.$(OBJEXT) ntp-keygen-opts.$(OBJEXT)
 nodist_ntp_keygen_OBJECTS = version.$(OBJEXT)
 ntp_keygen_OBJECTS = $(am_ntp_keygen_OBJECTS) \
@@ -254,12 +261,13 @@ am__maybe_remake_depfiles = depfiles
 am__depfiles_remade = ./$(DEPDIR)/audio-pcm.Po \
 	./$(DEPDIR)/byteorder.Po ./$(DEPDIR)/hist.Po \
 	./$(DEPDIR)/jitter.Po ./$(DEPDIR)/kern.Po \
-	./$(DEPDIR)/longsize.Po ./$(DEPDIR)/ntp-keygen-opts.Po \
-	./$(DEPDIR)/ntp-keygen.Po ./$(DEPDIR)/ntptime.Po \
-	./$(DEPDIR)/pps-api.Po ./$(DEPDIR)/precision.Po \
-	./$(DEPDIR)/sht.Po ./$(DEPDIR)/testrs6000.Po ./$(DEPDIR)/tg.Po \
-	./$(DEPDIR)/tg2.Po ./$(DEPDIR)/tickadj.Po \
-	./$(DEPDIR)/timetrim.Po ./$(DEPDIR)/version.Po
+	./$(DEPDIR)/longsize.Po ./$(DEPDIR)/lsf-times.Po \
+	./$(DEPDIR)/ntp-keygen-opts.Po ./$(DEPDIR)/ntp-keygen.Po \
+	./$(DEPDIR)/ntptime.Po ./$(DEPDIR)/pps-api.Po \
+	./$(DEPDIR)/precision.Po ./$(DEPDIR)/sht.Po \
+	./$(DEPDIR)/testrs6000.Po ./$(DEPDIR)/tg.Po ./$(DEPDIR)/tg2.Po \
+	./$(DEPDIR)/tickadj.Po ./$(DEPDIR)/timetrim.Po \
+	./$(DEPDIR)/version.Po
 am__mv = mv -f
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@@ -280,12 +288,13 @@ am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
 am__v_CCLD_0 = @echo "  CCLD    " $@;
 am__v_CCLD_1 = 
 SOURCES = audio-pcm.c byteorder.c hist.c $(jitter_SOURCES) kern.c \
-	longsize.c $(ntp_keygen_SOURCES) $(nodist_ntp_keygen_SOURCES) \
-	ntptime.c pps-api.c precision.c sht.c testrs6000.c tg.c tg2.c \
-	tickadj.c timetrim.c
+	longsize.c lsf-times.c $(ntp_keygen_SOURCES) \
+	$(nodist_ntp_keygen_SOURCES) ntptime.c pps-api.c precision.c \
+	sht.c testrs6000.c tg.c tg2.c tickadj.c timetrim.c
 DIST_SOURCES = audio-pcm.c byteorder.c hist.c $(jitter_SOURCES) kern.c \
-	longsize.c $(ntp_keygen_SOURCES) ntptime.c pps-api.c \
-	precision.c sht.c testrs6000.c tg.c tg2.c tickadj.c timetrim.c
+	longsize.c lsf-times.c $(ntp_keygen_SOURCES) ntptime.c \
+	pps-api.c precision.c sht.c testrs6000.c tg.c tg2.c tickadj.c \
+	timetrim.c
 am__can_run_installinfo = \
   case $$AM_UPDATE_INFO_DIR in \
     n|no|NO) false;; \
@@ -513,6 +522,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_NET_SNMP_CONFIG = @PATH_NET_SNMP_CONFIG@
+PATH_OPENSSL = @PATH_OPENSSL@
 PATH_PERL = @PATH_PERL@
 PATH_RUBY = @PATH_RUBY@
 PATH_SEPARATOR = @PATH_SEPARATOR@
@@ -632,6 +642,7 @@ tickadj_LDADD = ../libntp/libntp.a $(LDADD_LIBNTP) $(LIBM) $(PTHREAD_LIBS) $(LDA
 EXTRA_DIST = \
 	invoke-ntp-keygen.menu		\
 	invoke-ntp-keygen.texi		\
+	lsf-times.c			\
 	ntp-keygen-opts.def		\
 	ntp-keygen.1ntp-keygenman	\
 	ntp-keygen.1ntp-keygenmdoc	\
@@ -642,9 +653,9 @@ EXTRA_DIST = \
 	ntp-keygen.texi			\
 	$(NULL)
 
-BUILT_SOURCES = ntp-keygen-opts.c ntp-keygen-opts.h check-libntp \
+BUILT_SOURCES = ntp-keygen-opts.c ntp-keygen-opts.h $(am__append_1) \
 	check-libopts .deps-ver
-CLEANFILES = .version version.c check-libntp check-libopts .deps-ver
+CLEANFILES = .version version.c check-libopts .deps-ver
 DISTCLEANFILES = config.log $(man_MANS) $(DEPDIR)/deps-ver
 html_DATA = \
 	$(srcdir)/ntp-keygen.html	\
@@ -886,6 +897,10 @@ longsize$(EXEEXT): $(longsize_OBJECTS) $(longsize_DEPENDENCIES) $(EXTRA_longsize
 	@rm -f longsize$(EXEEXT)
 	$(AM_V_CCLD)$(LINK) $(longsize_OBJECTS) $(longsize_LDADD) $(LIBS)
 
+lsf-times$(EXEEXT): $(lsf_times_OBJECTS) $(lsf_times_DEPENDENCIES) $(EXTRA_lsf_times_DEPENDENCIES) 
+	@rm -f lsf-times$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(lsf_times_OBJECTS) $(lsf_times_LDADD) $(LIBS)
+
 ntp-keygen$(EXEEXT): $(ntp_keygen_OBJECTS) $(ntp_keygen_DEPENDENCIES) $(EXTRA_ntp_keygen_DEPENDENCIES) 
 	@rm -f ntp-keygen$(EXEEXT)
 	$(AM_V_CCLD)$(LINK) $(ntp_keygen_OBJECTS) $(ntp_keygen_LDADD) $(LIBS)
@@ -938,6 +953,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jitter.Po@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kern.Po@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/longsize.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lsf-times.Po@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp-keygen-opts.Po@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp-keygen.Po@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntptime.Po@am__quote@ # am--include-marker
@@ -1233,6 +1249,7 @@ distclean: distclean-am
 	-rm -f ./$(DEPDIR)/jitter.Po
 	-rm -f ./$(DEPDIR)/kern.Po
 	-rm -f ./$(DEPDIR)/longsize.Po
+	-rm -f ./$(DEPDIR)/lsf-times.Po
 	-rm -f ./$(DEPDIR)/ntp-keygen-opts.Po
 	-rm -f ./$(DEPDIR)/ntp-keygen.Po
 	-rm -f ./$(DEPDIR)/ntptime.Po
@@ -1298,6 +1315,7 @@ maintainer-clean: maintainer-clean-am
 	-rm -f ./$(DEPDIR)/jitter.Po
 	-rm -f ./$(DEPDIR)/kern.Po
 	-rm -f ./$(DEPDIR)/longsize.Po
+	-rm -f ./$(DEPDIR)/lsf-times.Po
 	-rm -f ./$(DEPDIR)/ntp-keygen-opts.Po
 	-rm -f ./$(DEPDIR)/ntp-keygen.Po
 	-rm -f ./$(DEPDIR)/ntptime.Po
@@ -1418,11 +1436,10 @@ install-exec-hook:
 
 #
 
-check-libntp: $(top_builddir)/libntp/libntp.a
-	@: avoid default SCCS get by some make implementations
+.PHONY: check-libntp
 
-$(top_builddir)/libntp/libntp.a:
-	cd $(top_builddir)/libntp && $(MAKE) $(AM_MAKEFLAGS) libntp.a
+@LIBNTP_SUBMAKES_TRUE@check-libntp:
+@LIBNTP_SUBMAKES_TRUE@	cd $(top_builddir)/libntp && $(MAKE) $(AM_MAKEFLAGS) libntp.a
 
 check-libopts: ../sntp/libopts/libopts.la
 	@echo stamp > $@
@@ -1432,10 +1449,9 @@ check-libopts: ../sntp/libopts/libopts.la
 $(top_srcdir)/sntp/scm-rev: FRC.scm-rev
 	$(AM_V_GEN)cd $(top_builddir)/sntp && $(MAKE) $(AM_MAKEFLAGS) check-scm-rev
 
+.PHONY: FRC.scm-rev
 FRC.scm-rev:
-	@: FRC.scm-rev "force" depends on nothing and is not a file, so is	\
-	   always out-of-date causing targets which depend on it to also		\
-	   be outdated so their rules to fire each time they are built.
+	@: FRC.scm-rev is always out of date, triggering the check every make invocation.
 $(DEPDIR)/deps-ver: $(top_srcdir)/deps-ver
 	@[ -f $@ ] ||							\
 		cp $(top_srcdir)/deps-ver $@
diff --git a/contrib/ntp/util/invoke-ntp-keygen.texi b/contrib/ntp/util/invoke-ntp-keygen.texi
index 2ee45b30970c..a4571231a4f6 100644
--- a/contrib/ntp/util/invoke-ntp-keygen.texi
+++ b/contrib/ntp/util/invoke-ntp-keygen.texi
@@ -6,7 +6,7 @@
 #
 # EDIT THIS FILE WITH CAUTION  (invoke-ntp-keygen.texi)
 #
-# It has been AutoGen-ed  June  6, 2023 at 04:38:29 AM by AutoGen 5.18.16
+# It has been AutoGen-ed  May 25, 2024 at 12:04:48 AM by AutoGen 5.18.16
 # From the definitions    ntp-keygen-opts.def
 # and the template file   agtexi-cmd.tpl
 @end ignore
@@ -1056,7 +1056,7 @@ with a status code of 0.
 
 @exampleindent 0
 @example
-ntp-keygen (ntp) - Create a NTP host key - Ver. 4.2.8p17
+ntp-keygen (ntp) - Create a NTP host key - Ver. 4.2.8p18
 Usage:  ntp-keygen [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]...
   Flg Arg Option-Name    Description
    -b Num imbits         identity modulus bits
diff --git a/contrib/ntp/util/lsf-times.c b/contrib/ntp/util/lsf-times.c
new file mode 100644
index 000000000000..5b719e13360f
--- /dev/null
+++ b/contrib/ntp/util/lsf-times.c
@@ -0,0 +1,220 @@
+#include "config.h"
+#include "ntp_calendar.h"
+
+#include <stdlib.h>
+#include <errno.h>
+
+#include "ntp_types.h"
+#include "ntp_fp.h"
+#include "vint64ops.h"
+
+/*
+ * If we're called with 1 arg, it's a u_long timestamp.
+ * If we're called with 3 args, we're expecting YYYY MM DD,
+ *   and MM must be 6 or 12, and DD must be 28,
+ * If we're called with 2 args, we're expecting YYYY MM, and
+ *   MM mst be 6 or 12, and we assume DD is 28.
+ */
+
+char *progname;
+static const char *MONTHS[] =
+                { "January", "February", "March", "April", "May", "June",
+		  "July", "August", "September", "October", "November",
+		  "December" };
+
+void usage(void);
+
+void
+usage(void)
+{
+	printf("Usage:\n");
+	printf(" %s nnnnnn\n", progname);
+	printf(" %s YYYY [6|12]\n", progname);
+	printf(" %s YYYY [6|12] 28\n", progname);
+
+	return;
+}
+
+
+int
+main(
+	int	argc,		/* command line options */
+	char	**argv		/* poiniter to list of tokens */
+	)
+{
+	int err = 0;
+	vint64 expires;
+	unsigned int year = 0;
+	unsigned int mon = 0;
+	unsigned int dom = 0;
+	int scount;
+	char *ep;
+	struct calendar cal = {0};
+
+	progname = argv[0];
+
+	switch(argc) {
+	 case 2:	/* 1 arg, must be a string of digits */
+		expires = strtouv64(argv[1], &ep, 10);
+
+		if (0 == *ep) {
+			ntpcal_ntp64_to_date(&cal, &expires);
+
+			printf("%02u %s %04u %02u:%02u:%02u\n"
+				, cal.monthday
+				, MONTHS[cal.month - 1]
+				, cal.year
+				, cal.hour
+				, cal.minute
+				, cal.second
+				);
+
+			exit(0);
+		} else {
+			printf("1 arg, but not a string of digits: <%s>\n",
+				argv[1]);
+			err = 1;
+		}
+		break;
+		;;
+	 case 3:	/* 2 args, must be YY MM, where MM is 6 or 12 */
+		dom = 28;
+		scount = sscanf(argv[1], "%u", &year);
+		if (1 == scount) {
+			// printf("2 args: year %u\n", year);
+		} else {
+			printf("2 args, but #1 is not a string of digits: <%s>\n", argv[1]);
+			err = 1;
+		}
+
+		scount = sscanf(argv[2], "%u", &mon);
+		if (1 == scount) {
+			if (6 == mon || 12 == mon) {
+				// printf("2 args: month %u\n", mon);
+			} else {
+				printf("2 arg, but #2 is not 6 or 12: <%d>\n", mon);
+				err = 1;
+			}
+		} else {
+			printf("2 arg, but #2 is not a string of digits: <%s>\n", argv[2]);
+			err = 1;
+		}
+
+		break;
+		;;
+	 case 4:	/* 3 args, YY MM DD, where MM is 6 or 12, DD is 28 */
+		scount = sscanf(argv[1], "%u", &year);
+		if (1 == scount) {
+			// printf("3 args: year %u\n", year);
+		} else {
+			printf("3 args, but #1 is not a string of digits: <%s>\n", argv[1]);
+			err = 1;
+		}
+
+		scount = sscanf(argv[2], "%u", &mon);
+		if (1 == scount) {
+			if (6 == mon || 12 == mon) {
+				// printf("3 args: month %u\n", mon);
+			} else {
+				printf("3 arg, but #2 is not 6 or 12: <%d>\n", mon);
+				err = 1;
+			}
+		} else {
+			printf("3 arg, but #2 is not a string of digits: <%s>\n", argv[2]);
+			err = 1;
+		}
+
+		scount = sscanf(argv[3], "%u", &dom);
+		if (1 == scount) {
+			if (28 == dom) {
+				// printf("3 args: dom %u\n", dom);
+			} else {
+				printf("3 arg, but #3 is not 28: <%d>\n", dom);
+				err = 1;
+			}
+		} else {
+			printf("3 arg, but #3 is not a string of digits: <%s>\n", argv[2]);
+			err = 1;
+		}
+
+		break;
+		;;
+	 default:
+		err = 1;
+		break;
+		;;
+	}
+
+	if (err) {
+		usage();
+		exit(err);
+	}
+
+	cal.year = year;
+	cal.month = mon;
+	cal.monthday = dom;
+	cal.hour = 0;
+	cal.minute = 0;
+	cal.second = 0;
+
+	printf("%u ", ntpcal_date_to_ntp(&cal));
+
+	printf("%02d %s %04d "
+		, cal.monthday
+		, MONTHS[cal.month - 1]
+		, cal.year
+		);
+	printf("\n");
+
+	exit(err);
+}
+
+#if 0
+
+
+void
+test_DateGivenMonthDay(void) {
+	// 2010-06-24 12:50:00
+	struct calendar input = {2010, 0, 6, 24, 12, 50, 0};
+
+	u_long expected = 3486372600UL; // This is the timestamp above.
+
+	TEST_ASSERT_EQUAL_UINT(expected, caltontp(&input));
+}
+
+void
+test_DateGivenYearDay(void) {
+	// 2010-06-24 12:50:00
+	// This is the 175th day of 2010.
+	struct calendar input = {2010, 175, 0, 0, 12, 50, 0};
+
+	u_long expected = 3486372600UL; // This is the timestamp above.
+
+	TEST_ASSERT_EQUAL_UINT(expected, caltontp(&input));
+}
+
+void
+test_DateLeapYear(void) {
+	// 2012-06-24 12:00:00
+	// This is the 176th day of 2012 (since 2012 is a leap year).
+	struct calendar inputYd = {2012, 176, 0, 0, 12, 00, 00};
+	struct calendar inputMd = {2012, 0, 6, 24, 12, 00, 00};
+
+	u_long expected = 3549528000UL;
+
+	TEST_ASSERT_EQUAL_UINT(expected, caltontp(&inputYd));
+	TEST_ASSERT_EQUAL_UINT(expected, caltontp(&inputMd));
+}
+
+void
+test_WraparoundDateIn2036(void) {
+	// 2036-02-07 06:28:16
+	// This is (one) wrapping boundary where we go from ULONG_MAX to 0.
+	struct calendar input = {2036, 0, 2, 7, 6, 28, 16};
+
+	u_long expected = 0UL;
+
+	TEST_ASSERT_EQUAL_UINT(expected, caltontp(&input));
+}
+
+#endif
diff --git a/contrib/ntp/util/ntp-keygen-opts.c b/contrib/ntp/util/ntp-keygen-opts.c
index fb3c78fdff51..6d532651e3b2 100644
--- a/contrib/ntp/util/ntp-keygen-opts.c
+++ b/contrib/ntp/util/ntp-keygen-opts.c
@@ -1,7 +1,7 @@
 /*
  *  EDIT THIS FILE WITH CAUTION  (ntp-keygen-opts.c)
  *
- *  It has been AutoGen-ed  June  6, 2023 at 04:38:24 AM by AutoGen 5.18.16
+ *  It has been AutoGen-ed  May 25, 2024 at 12:04:43 AM by AutoGen 5.18.16
  *  From the definitions    ntp-keygen-opts.def
  *  and the template file   options
  *
@@ -18,7 +18,7 @@
  * The ntp-keygen program is copyrighted and licensed
  * under the following terms:
  *
- *  Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation, all rights reserved.
+ *  Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation, all rights reserved.
  *  This is free software. It is licensed for use, modification and
  *  redistribution under the terms of the NTP License, copies of which
  *  can be seen at:
@@ -76,8 +76,8 @@ extern FILE * option_usage_fp;
  *  static const strings for ntp-keygen options
  */
 static char const ntp_keygen_opt_strs[2443] =
-/*     0 */ "ntp-keygen (ntp) 4.2.8p17\n"
-            "Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation, all rights reserved.\n"
+/*     0 */ "ntp-keygen (ntp) 4.2.8p18\n"
+            "Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation, all rights reserved.\n"
             "This is free software. It is licensed for use, modification and\n"
             "redistribution under the terms of the NTP License, copies of which\n"
             "can be seen at:\n"
@@ -169,14 +169,14 @@ static char const ntp_keygen_opt_strs[2443] =
 /*  2223 */ "no-load-opts\0"
 /*  2236 */ "no\0"
 /*  2239 */ "NTP_KEYGEN\0"
-/*  2250 */ "ntp-keygen (ntp) - Create a NTP host key - Ver. 4.2.8p17\n"
+/*  2250 */ "ntp-keygen (ntp) - Create a NTP host key - Ver. 4.2.8p18\n"
             "Usage:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n\0"
 /*  2365 */ "$HOME\0"
 /*  2371 */ ".\0"
 /*  2373 */ ".ntprc\0"
 /*  2380 */ "https://bugs.ntp.org, bugs@ntp.org\0"
 /*  2415 */ "\n\0"
-/*  2417 */ "ntp-keygen (ntp) 4.2.8p17";
+/*  2417 */ "ntp-keygen (ntp) 4.2.8p18";
 
 /**
  *  imbits option description:
@@ -1314,8 +1314,8 @@ static void bogus_function(void) {
      translate option names.
    */
   /* referenced via ntp_keygenOptions.pzCopyright */
-  puts(_("ntp-keygen (ntp) 4.2.8p17\n\
-Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation, all rights reserved.\n\
+  puts(_("ntp-keygen (ntp) 4.2.8p18\n\
+Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation, all rights reserved.\n\
 This is free software. It is licensed for use, modification and\n\
 redistribution under the terms of the NTP License, copies of which\n\
 can be seen at:\n"));
@@ -1413,14 +1413,14 @@ implied warranty.\n"));
   puts(_("load options from a config file"));
 
   /* referenced via ntp_keygenOptions.pzUsageTitle */
-  puts(_("ntp-keygen (ntp) - Create a NTP host key - Ver. 4.2.8p17\n\
+  puts(_("ntp-keygen (ntp) - Create a NTP host key - Ver. 4.2.8p18\n\
 Usage:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n"));
 
   /* referenced via ntp_keygenOptions.pzExplain */
   puts(_("\n"));
 
   /* referenced via ntp_keygenOptions.pzFullVersion */
-  puts(_("ntp-keygen (ntp) 4.2.8p17"));
+  puts(_("ntp-keygen (ntp) 4.2.8p18"));
 
   /* referenced via ntp_keygenOptions.pzFullUsage */
   puts(_("<<<NOT-FOUND>>>"));
diff --git a/contrib/ntp/util/ntp-keygen-opts.h b/contrib/ntp/util/ntp-keygen-opts.h
index 9e266d2b164f..a2cb606e0af2 100644
--- a/contrib/ntp/util/ntp-keygen-opts.h
+++ b/contrib/ntp/util/ntp-keygen-opts.h
@@ -1,7 +1,7 @@
 /*
  *  EDIT THIS FILE WITH CAUTION  (ntp-keygen-opts.h)
  *
- *  It has been AutoGen-ed  June  6, 2023 at 04:38:23 AM by AutoGen 5.18.16
+ *  It has been AutoGen-ed  May 25, 2024 at 12:04:42 AM by AutoGen 5.18.16
  *  From the definitions    ntp-keygen-opts.def
  *  and the template file   options
  *
@@ -18,7 +18,7 @@
  * The ntp-keygen program is copyrighted and licensed
  * under the following terms:
  *
- *  Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation, all rights reserved.
+ *  Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation, all rights reserved.
  *  This is free software. It is licensed for use, modification and
  *  redistribution under the terms of the NTP License, copies of which
  *  can be seen at:
@@ -102,9 +102,9 @@ typedef enum {
 /** count of all options for ntp-keygen */
 #define OPTION_CT    26
 /** ntp-keygen version */
-#define NTP_KEYGEN_VERSION       "4.2.8p17"
+#define NTP_KEYGEN_VERSION       "4.2.8p18"
 /** Full ntp-keygen version text */
-#define NTP_KEYGEN_FULL_VERSION  "ntp-keygen (ntp) 4.2.8p17"
+#define NTP_KEYGEN_FULL_VERSION  "ntp-keygen (ntp) 4.2.8p18"
 
 /**
  *  Interface defines for all options.  Replace "n" with the UPPER_CASED
diff --git a/contrib/ntp/util/ntp-keygen.1ntp-keygenman b/contrib/ntp/util/ntp-keygen.1ntp-keygenman
index f96a7689b17c..23fb3e1dc5cd 100644
--- a/contrib/ntp/util/ntp-keygen.1ntp-keygenman
+++ b/contrib/ntp/util/ntp-keygen.1ntp-keygenman
@@ -10,11 +10,11 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH ntp-keygen 1ntp-keygenman "06 Jun 2023" "ntp (4.2.8p17)" "User Commands"
+.TH ntp-keygen 1ntp-keygenman "25 May 2024" "ntp (4.2.8p18)" "User Commands"
 .\"
 .\" EDIT THIS FILE WITH CAUTION (in-mem file)
 .\"
-.\" It has been AutoGen-ed June 6, 2023 at 04:38:32 AM by AutoGen 5.18.16
+.\" It has been AutoGen-ed May 25, 2024 at 12:04:51 AM by AutoGen 5.18.16
 .\" From the definitions ntp-keygen-opts.def
 .\" and the template file agman-cmd.tpl
 .SH NAME
@@ -1351,7 +1351,7 @@ it to autogen-users@lists.sourceforge.net.  Thank you.
 .SH "AUTHORS"
 The University of Delaware and Network Time Foundation
 .SH "COPYRIGHT"
-Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation all rights reserved.
 This program is released under the terms of the NTP license, <http://ntp.org/license>.
 .SH BUGS
 It can take quite a while to generate some cryptographic values.
diff --git a/contrib/ntp/util/ntp-keygen.1ntp-keygenmdoc b/contrib/ntp/util/ntp-keygen.1ntp-keygenmdoc
index ce6b988d7670..9ac815e24657 100644
--- a/contrib/ntp/util/ntp-keygen.1ntp-keygenmdoc
+++ b/contrib/ntp/util/ntp-keygen.1ntp-keygenmdoc
@@ -1,9 +1,9 @@
-.Dd June 6 2023
+.Dd May 25 2024
 .Dt NTP_KEYGEN 1ntp-keygenmdoc User Commands
 .Os
 .\"  EDIT THIS FILE WITH CAUTION  (ntp-keygen-opts.mdoc)
 .\"
-.\"  It has been AutoGen-ed  June  6, 2023 at 04:38:27 AM by AutoGen 5.18.16
+.\"  It has been AutoGen-ed  May 25, 2024 at 12:04:46 AM by AutoGen 5.18.16
 .\"  From the definitions    ntp-keygen-opts.def
 .\"  and the template file   agmdoc-cmd.tpl
 .Sh NAME
@@ -1208,7 +1208,7 @@ it to autogen\-users@lists.sourceforge.net.  Thank you.
 .Sh "AUTHORS"
 The University of Delaware and Network Time Foundation
 .Sh "COPYRIGHT"
-Copyright (C) 1992\-2023 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992\-2024 The University of Delaware and Network Time Foundation all rights reserved.
 This program is released under the terms of the NTP license, <http://ntp.org/license>.
 .Sh BUGS
 It can take quite a while to generate some cryptographic values.
diff --git a/contrib/ntp/util/ntp-keygen.c b/contrib/ntp/util/ntp-keygen.c
index ff9d6cad8980..c9c0ff9ef75f 100644
--- a/contrib/ntp/util/ntp-keygen.c
+++ b/contrib/ntp/util/ntp-keygen.c
@@ -409,11 +409,11 @@ main(
 		iffkey++;
 
 	if (HAVE_OPT( MV_PARAMS )) {
-		mvkey++;
+		mvkey++;			/* DLH are these two swapped? */
 		nkeys = OPT_VALUE_MV_PARAMS;
 	}
 	if (HAVE_OPT( MV_KEYS )) {
-		mvpar++;
+		mvpar++;	/* not used! */	/* DLH are these two swapped? */
 		nkeys = OPT_VALUE_MV_KEYS;
 	}
 
@@ -642,12 +642,13 @@ main(
 		}
 	}
 	if (pkey_gqkey != NULL) {
-		RSA	*rsa;
-		const BIGNUM *q;
+		RSA		*rsa;
+		const BIGNUM	*q;
 
-		rsa = EVP_PKEY_get0_RSA(pkey_gqkey);
+		rsa = EVP_PKEY_get1_RSA(pkey_gqkey);
 		RSA_get0_factors(rsa, NULL, &q);
 		grpkey = BN_bn2hex(q);
+		RSA_free(rsa);
 	}
 
 	/*
@@ -664,17 +665,19 @@ main(
 		    filename);
 		fprintf(stdout, "# %s\n# %s\n", filename,
 		    ctime(&epoch));
-		/* XXX: This modifies the private key and should probably use a
-		 * copy of it instead. */
-		rsa = EVP_PKEY_get0_RSA(pkey_gqkey);
+		rsa = EVP_PKEY_get1_RSA(pkey_gqkey);
 		RSA_set0_factors(rsa, BN_dup(BN_value_one()), BN_dup(BN_value_one()));
 		pkey = EVP_PKEY_new();
 		EVP_PKEY_assign_RSA(pkey, rsa);
 		PEM_write_PKCS8PrivateKey(stdout, pkey, NULL, NULL, 0,
 		    NULL, NULL);
 		fflush(stdout);
-		if (debug)
+		if (debug) {
 			RSA_print_fp(stderr, rsa, 0);
+		}
+		EVP_PKEY_free(pkey);
+		pkey = NULL;
+		RSA_free(rsa);
 	}
 
 	/*
@@ -689,14 +692,18 @@ main(
 		    filename);
 		fprintf(stdout, "# %s\n# %s\n", filename,
 		    ctime(&epoch));
-		rsa = EVP_PKEY_get0_RSA(pkey_gqkey);
+		rsa = EVP_PKEY_get1_RSA(pkey_gqkey);
 		pkey = EVP_PKEY_new();
 		EVP_PKEY_assign_RSA(pkey, rsa);
 		PEM_write_PKCS8PrivateKey(stdout, pkey, cipher, NULL, 0,
 		    NULL, passwd2);
 		fflush(stdout);
-		if (debug)
+		if (debug) {
 			RSA_print_fp(stderr, rsa, 0);
+		}
+		EVP_PKEY_free(pkey);
+		pkey = NULL;
+		RSA_free(rsa);
 	}
 
 	/*
@@ -730,17 +737,19 @@ main(
 		    filename);
 		fprintf(stdout, "# %s\n# %s\n", filename,
 		    ctime(&epoch));
-		/* XXX: This modifies the private key and should probably use a
-		 * copy of it instead. */
-		dsa = EVP_PKEY_get0_DSA(pkey_iffkey);
+		dsa = EVP_PKEY_get1_DSA(pkey_iffkey);
 		DSA_set0_key(dsa, NULL, BN_dup(BN_value_one()));
 		pkey = EVP_PKEY_new();
 		EVP_PKEY_assign_DSA(pkey, dsa);
 		PEM_write_PKCS8PrivateKey(stdout, pkey, NULL, NULL, 0,
 		    NULL, NULL);
 		fflush(stdout);
-		if (debug)
+		if (debug) {
 			DSA_print_fp(stderr, dsa, 0);
+		}
+		EVP_PKEY_free(pkey);
+		pkey = NULL;
+		DSA_free(dsa);
 	}
 
 	/*
@@ -755,14 +764,18 @@ main(
 		    filename);
 		fprintf(stdout, "# %s\n# %s\n", filename,
 		    ctime(&epoch));
-		dsa = EVP_PKEY_get0_DSA(pkey_iffkey);
+		dsa = EVP_PKEY_get1_DSA(pkey_iffkey);
 		pkey = EVP_PKEY_new();
 		EVP_PKEY_assign_DSA(pkey, dsa);
 		PEM_write_PKCS8PrivateKey(stdout, pkey, cipher, NULL, 0,
 		    NULL, passwd2);
 		fflush(stdout);
-		if (debug)
+		if (debug) {
 			DSA_print_fp(stderr, dsa, 0);
+		}
+		EVP_PKEY_free(pkey);
+		pkey = NULL;
+		DSA_free(dsa);
 	}
 
 	/*
@@ -799,8 +812,9 @@ main(
 		PEM_write_PKCS8PrivateKey(stdout, pkey, NULL, NULL, 0,
 		    NULL, NULL);
 		fflush(stdout);
-		if (debug)
+		if (debug) {
 			DSA_print_fp(stderr, EVP_PKEY_get0_DSA(pkey), 0);
+		}
 	}
 
 	/*
@@ -817,8 +831,9 @@ main(
 		PEM_write_PKCS8PrivateKey(stdout, pkey, cipher, NULL, 0,
 		    NULL, passwd2);
 		fflush(stdout);
-		if (debug)
+		if (debug) {
 			DSA_print_fp(stderr, EVP_PKEY_get0_DSA(pkey), 0);
+		}
 	}
 
 	/*
@@ -830,7 +845,7 @@ main(
 		fprintf(stderr,
 		    "Invalid digest/signature combination %s\n",
 		    scheme);
-			exit (-1);
+		exit (-1);
 	}
 	x509(pkey_sign, ectx, grpkey, exten, certname);
 #endif	/* AUTOKEY */
diff --git a/contrib/ntp/util/ntp-keygen.html b/contrib/ntp/util/ntp-keygen.html
index 0d16b09b5b46..4027f108af31 100644
--- a/contrib/ntp/util/ntp-keygen.html
+++ b/contrib/ntp/util/ntp-keygen.html
@@ -84,7 +84,7 @@ All other files are in PEM-encoded
 printable ASCII format so they can be embedded as MIME attachments in
 mail to other sites.
 </p>
-<p>This document applies to version 4.2.8p17 of <code>ntp-keygen</code>.
+<p>This document applies to version 4.2.8p18 of <code>ntp-keygen</code>.
 </p>
 <table class="menu" border="0" cellspacing="0">
 <tr><td align="left" valign="top">&bull; <a href="#Description" accesskey="1">Description</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
@@ -1380,7 +1380,7 @@ used to select the program, defaulting to <samp>more</samp>.  Both will exit
 with a status code of 0.
 </p>
 <div class="example">
-<pre class="example">ntp-keygen (ntp) - Create a NTP host key - Ver. 4.2.8p17
+<pre class="example">ntp-keygen (ntp) - Create a NTP host key - Ver. 4.2.8p18
 Usage:  ntp-keygen [ -&lt;flag&gt; [&lt;val&gt;] | --&lt;name&gt;[{=| }&lt;val&gt;] ]...
   Flg Arg Option-Name    Description
    -b Num imbits         identity modulus bits
diff --git a/contrib/ntp/util/ntp-keygen.man.in b/contrib/ntp/util/ntp-keygen.man.in
index 1495530155b6..284d52409bcb 100644
--- a/contrib/ntp/util/ntp-keygen.man.in
+++ b/contrib/ntp/util/ntp-keygen.man.in
@@ -10,11 +10,11 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH ntp-keygen @NTP_KEYGEN_MS@ "06 Jun 2023" "ntp (4.2.8p17)" "User Commands"
+.TH ntp-keygen @NTP_KEYGEN_MS@ "25 May 2024" "ntp (4.2.8p18)" "User Commands"
 .\"
 .\" EDIT THIS FILE WITH CAUTION (in-mem file)
 .\"
-.\" It has been AutoGen-ed June 6, 2023 at 04:38:32 AM by AutoGen 5.18.16
+.\" It has been AutoGen-ed May 25, 2024 at 12:04:51 AM by AutoGen 5.18.16
 .\" From the definitions ntp-keygen-opts.def
 .\" and the template file agman-cmd.tpl
 .SH NAME
@@ -1351,7 +1351,7 @@ it to autogen-users@lists.sourceforge.net.  Thank you.
 .SH "AUTHORS"
 The University of Delaware and Network Time Foundation
 .SH "COPYRIGHT"
-Copyright (C) 1992-2023 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation all rights reserved.
 This program is released under the terms of the NTP license, <http://ntp.org/license>.
 .SH BUGS
 It can take quite a while to generate some cryptographic values.
diff --git a/contrib/ntp/util/ntp-keygen.mdoc.in b/contrib/ntp/util/ntp-keygen.mdoc.in
index 44b1954cc648..c0feb670e118 100644
--- a/contrib/ntp/util/ntp-keygen.mdoc.in
+++ b/contrib/ntp/util/ntp-keygen.mdoc.in
@@ -1,9 +1,9 @@
-.Dd June 6 2023
+.Dd May 25 2024
 .Dt NTP_KEYGEN @NTP_KEYGEN_MS@ User Commands
 .Os
 .\"  EDIT THIS FILE WITH CAUTION  (ntp-keygen-opts.mdoc)
 .\"
-.\"  It has been AutoGen-ed  June  6, 2023 at 04:38:27 AM by AutoGen 5.18.16
+.\"  It has been AutoGen-ed  May 25, 2024 at 12:04:46 AM by AutoGen 5.18.16
 .\"  From the definitions    ntp-keygen-opts.def
 .\"  and the template file   agmdoc-cmd.tpl
 .Sh NAME
@@ -1208,7 +1208,7 @@ it to autogen\-users@lists.sourceforge.net.  Thank you.
 .Sh "AUTHORS"
 The University of Delaware and Network Time Foundation
 .Sh "COPYRIGHT"
-Copyright (C) 1992\-2023 The University of Delaware and Network Time Foundation all rights reserved.
+Copyright (C) 1992\-2024 The University of Delaware and Network Time Foundation all rights reserved.
 This program is released under the terms of the NTP license, <http://ntp.org/license>.
 .Sh BUGS
 It can take quite a while to generate some cryptographic values.
diff --git a/contrib/smbfs/mount_smbfs/mount_smbfs.8 b/contrib/smbfs/mount_smbfs/mount_smbfs.8
index 4b4c205dc7da..604b1b414243 100644
--- a/contrib/smbfs/mount_smbfs/mount_smbfs.8
+++ b/contrib/smbfs/mount_smbfs/mount_smbfs.8
@@ -1,11 +1,10 @@
 .\" $Id: mount_smbfs.8,v 1.10 2002/04/16 02:47:41 bp Exp $
-.\" $FreeBSD$
 .Dd November 1, 2018
 .Dt MOUNT_SMBFS 8
 .Os
 .Sh NAME
 .Nm mount_smbfs
-.Nd "mount a shared resource from an SMB file server"
+.Nd mount a server message block (SMB1/CIFS) file system
 .Sh SYNOPSIS
 .Nm
 .Op Fl E Ar cs1 Ns Cm \&: Ns Ar cs2
diff --git a/contrib/smbfs/smbutil/smbutil.1 b/contrib/smbfs/smbutil/smbutil.1
index cf133bad309a..c82ba91ea99e 100644
--- a/contrib/smbfs/smbutil/smbutil.1
+++ b/contrib/smbfs/smbutil/smbutil.1
@@ -4,7 +4,7 @@
 .Os
 .Sh NAME
 .Nm smbutil
-.Nd "interface to the SMB requester"
+.Nd interface to the server message block (SMB1/CIFS) requester
 .Sh SYNOPSIS
 .Nm
 .Op Fl hv
diff --git a/contrib/sqlite3/Makefile.msc b/contrib/sqlite3/Makefile.msc
index 45a07a9f317c..a4270fb2ae71 100644
--- a/contrib/sqlite3/Makefile.msc
+++ b/contrib/sqlite3/Makefile.msc
@@ -18,6 +18,13 @@
 TOP = .
 
 
+# Optionally set EXTRA_SRC to a list of C files to append to
+# the generated sqlite3.c.
+#
+!IFNDEF EXTRA_SRC
+EXTRA_SRC =
+!ENDIF
+
 # Set this non-0 to enable full warnings (-W4, etc) when compiling.
 #
 !IFNDEF USE_FULLWARN
diff --git a/contrib/sqlite3/configure b/contrib/sqlite3/configure
index 472e8acd0097..f2f70b5ae802 100755
--- a/contrib/sqlite3/configure
+++ b/contrib/sqlite3/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.71 for sqlite 3.45.1.
+# Generated by GNU Autoconf 2.71 for sqlite 3.46.0.
 #
 # Report bugs to <http://www.sqlite.org>.
 #
@@ -621,8 +621,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='sqlite'
 PACKAGE_TARNAME='sqlite'
-PACKAGE_VERSION='3.45.1'
-PACKAGE_STRING='sqlite 3.45.1'
+PACKAGE_VERSION='3.46.0'
+PACKAGE_STRING='sqlite 3.46.0'
 PACKAGE_BUGREPORT='http://www.sqlite.org'
 PACKAGE_URL=''
 
@@ -1367,7 +1367,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures sqlite 3.45.1 to adapt to many kinds of systems.
+\`configure' configures sqlite 3.46.0 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1438,7 +1438,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of sqlite 3.45.1:";;
+     short | recursive ) echo "Configuration of sqlite 3.46.0:";;
    esac
   cat <<\_ACEOF
 
@@ -1563,7 +1563,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-sqlite configure 3.45.1
+sqlite configure 3.46.0
 generated by GNU Autoconf 2.71
 
 Copyright (C) 2021 Free Software Foundation, Inc.
@@ -1833,7 +1833,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by sqlite $as_me 3.45.1, which was
+It was created by sqlite $as_me 3.46.0, which was
 generated by GNU Autoconf 2.71.  Invocation command line was
 
   $ $0$ac_configure_args_raw
@@ -3106,7 +3106,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='sqlite'
- VERSION='3.45.1'
+ VERSION='3.46.0'
 
 
 printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h
@@ -15314,7 +15314,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by sqlite $as_me 3.45.1, which was
+This file was extended by sqlite $as_me 3.46.0, which was
 generated by GNU Autoconf 2.71.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -15373,7 +15373,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config='$ac_cs_config_escaped'
 ac_cs_version="\\
-sqlite config.status 3.45.1
+sqlite config.status 3.46.0
 configured by $0, generated by GNU Autoconf 2.71,
   with options \\"\$ac_cs_config\\"
 
diff --git a/contrib/sqlite3/configure.ac b/contrib/sqlite3/configure.ac
index 3ce8855cc762..c83f381d90b1 100644
--- a/contrib/sqlite3/configure.ac
+++ b/contrib/sqlite3/configure.ac
@@ -10,7 +10,7 @@
 #
 
 AC_PREREQ(2.61)
-AC_INIT(sqlite, 3.45.1, http://www.sqlite.org)
+AC_INIT(sqlite, 3.46.0, http://www.sqlite.org)
 AC_CONFIG_SRCDIR([sqlite3.c])
 AC_CONFIG_AUX_DIR([.])
 
diff --git a/contrib/sqlite3/shell.c b/contrib/sqlite3/shell.c
index 1e02a12fbc2f..7d46e4acac57 100644
--- a/contrib/sqlite3/shell.c
+++ b/contrib/sqlite3/shell.c
@@ -580,6 +580,9 @@ zSkipValidUtf8(const char *z, int nAccept, long ccm);
 #ifndef HAVE_CONSOLE_IO_H
 # include "console_io.h"
 #endif
+#if defined(_MSC_VER)
+# pragma warning(disable : 4204)
+#endif
 
 #ifndef SQLITE_CIO_NO_TRANSLATE
 # if (defined(_WIN32) || defined(WIN32)) && !SQLITE_OS_WINRT
@@ -678,6 +681,10 @@ static short streamOfConsole(FILE *pf, /* out */ PerStreamTags *ppst){
 # endif
 }
 
+# ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING
+#  define ENABLE_VIRTUAL_TERMINAL_PROCESSING  (0x4)
+# endif
+
 # if CIO_WIN_WC_XLATE
 /* Define console modes for use with the Windows Console API. */
 #  define SHELL_CONI_MODE \
@@ -1228,6 +1235,10 @@ SQLITE_INTERNAL_LINKAGE char* fGetsUtf8(char *cBuf, int ncMax, FILE *pfIn){
 }
 #endif /* !defined(SQLITE_CIO_NO_TRANSLATE) */
 
+#if defined(_MSC_VER)
+# pragma warning(default : 4204)
+#endif
+
 #undef SHELL_INVALID_FILE_PTR
 
 /************************* End ../ext/consio/console_io.c ********************/
@@ -1250,6 +1261,9 @@ SQLITE_INTERNAL_LINKAGE char* fGetsUtf8(char *cBuf, int ncMax, FILE *pfIn){
  *   setOutputStream(FILE *pf)
  * This is normally the stream that CLI normal output goes to.
  * For the stand-alone CLI, it is stdout with no .output redirect.
+ *
+ * The ?putz(z) forms are required for the Fiddle builds for string literal
+ * output, in aid of enforcing format string to argument correspondence.
  */
 # define sputz(s,z) fPutsUtf8(z,s)
 # define sputf fPrintfUtf8
@@ -1261,12 +1275,18 @@ SQLITE_INTERNAL_LINKAGE char* fGetsUtf8(char *cBuf, int ncMax, FILE *pfIn){
 
 #else
 /* For Fiddle, all console handling and emit redirection is omitted. */
-# define sputz(fp,z) fputs(z,fp)
+/* These next 3 macros are for emitting formatted output. When complaints
+ * from the WASM build are issued for non-formatted output, (when a mere
+ * string literal is to be emitted, the ?putz(z) forms should be used.
+ * (This permits compile-time checking of format string / argument mismatch.)
+ */
+# define oputf(fmt, ...) printf(fmt,__VA_ARGS__)
+# define eputf(fmt, ...) fprintf(stderr,fmt,__VA_ARGS__)
 # define sputf(fp,fmt, ...) fprintf(fp,fmt,__VA_ARGS__)
+/* These next 3 macros are for emitting simple string literals. */
 # define oputz(z) fputs(z,stdout)
-# define oputf(fmt, ...) printf(fmt,__VA_ARGS__)
 # define eputz(z) fputs(z,stderr)
-# define eputf(fmt, ...) fprintf(stderr,fmt,__VA_ARGS__)
+# define sputz(fp,z) fputs(z,fp)
 # define oputb(buf,na) fwrite(buf,1,na,stdout)
 #endif
 
@@ -5711,16 +5731,20 @@ SQLITE_EXTENSION_INIT1
 ** index is ix. The 0th member is given by smBase. The sequence members
 ** progress per ix increment by smStep.
 */
-static sqlite3_int64 genSeqMember(sqlite3_int64 smBase,
-                                  sqlite3_int64 smStep,
-                                  sqlite3_uint64 ix){
-  if( ix>=(sqlite3_uint64)LLONG_MAX ){
+static sqlite3_int64 genSeqMember(
+  sqlite3_int64 smBase,
+  sqlite3_int64 smStep,
+  sqlite3_uint64 ix
+){
+  static const sqlite3_uint64 mxI64 =
+      ((sqlite3_uint64)0x7fffffff)<<32 | 0xffffffff;
+  if( ix>=mxI64 ){
     /* Get ix into signed i64 range. */
-    ix -= (sqlite3_uint64)LLONG_MAX;
+    ix -= mxI64;
     /* With 2's complement ALU, this next can be 1 step, but is split into
      * 2 for UBSAN's satisfaction (and hypothetical 1's complement ALUs.) */
-    smBase += (LLONG_MAX/2) * smStep;
-    smBase += (LLONG_MAX - LLONG_MAX/2) * smStep;
+    smBase += (mxI64/2) * smStep;
+    smBase += (mxI64 - mxI64/2) * smStep;
   }
   /* Under UBSAN (or on 1's complement machines), must do this last term
    * in steps to avoid the dreaded (and harmless) signed multiply overlow. */
@@ -5980,13 +6004,13 @@ static int seriesEof(sqlite3_vtab_cursor *cur){
 ** parameter.  (idxStr is not used in this implementation.)  idxNum
 ** is a bitmask showing which constraints are available:
 **
-**    1:    start=VALUE
-**    2:    stop=VALUE
-**    4:    step=VALUE
-**
-** Also, if bit 8 is set, that means that the series should be output
-** in descending order rather than in ascending order.  If bit 16 is
-** set, then output must appear in ascending order.
+**   0x01:    start=VALUE
+**   0x02:    stop=VALUE
+**   0x04:    step=VALUE
+**   0x08:    descending order
+**   0x10:    ascending order
+**   0x20:    LIMIT  VALUE
+**   0x40:    OFFSET  VALUE
 **
 ** This routine should initialize the cursor and position it so that it
 ** is pointing at the first row, or pointing off the end of the table
@@ -6000,26 +6024,44 @@ static int seriesFilter(
   series_cursor *pCur = (series_cursor *)pVtabCursor;
   int i = 0;
   (void)idxStrUnused;
-  if( idxNum & 1 ){
+  if( idxNum & 0x01 ){
     pCur->ss.iBase = sqlite3_value_int64(argv[i++]);
   }else{
     pCur->ss.iBase = 0;
   }
-  if( idxNum & 2 ){
+  if( idxNum & 0x02 ){
     pCur->ss.iTerm = sqlite3_value_int64(argv[i++]);
   }else{
     pCur->ss.iTerm = 0xffffffff;
   }
-  if( idxNum & 4 ){
+  if( idxNum & 0x04 ){
     pCur->ss.iStep = sqlite3_value_int64(argv[i++]);
     if( pCur->ss.iStep==0 ){
       pCur->ss.iStep = 1;
     }else if( pCur->ss.iStep<0 ){
-      if( (idxNum & 16)==0 ) idxNum |= 8;
+      if( (idxNum & 0x10)==0 ) idxNum |= 0x08;
     }
   }else{
     pCur->ss.iStep = 1;
   }
+  if( idxNum & 0x20 ){
+    sqlite3_int64 iLimit = sqlite3_value_int64(argv[i++]);
+    sqlite3_int64 iTerm;
+    if( idxNum & 0x40 ){
+      sqlite3_int64 iOffset = sqlite3_value_int64(argv[i++]);
+      if( iOffset>0 ){
+        pCur->ss.iBase += pCur->ss.iStep*iOffset;
+      }
+    }
+    if( iLimit>=0 ){
+      iTerm = pCur->ss.iBase + (iLimit - 1)*pCur->ss.iStep;
+      if( pCur->ss.iStep<0 ){
+        if( iTerm>pCur->ss.iTerm ) pCur->ss.iTerm = iTerm;
+      }else{
+        if( iTerm<pCur->ss.iTerm ) pCur->ss.iTerm = iTerm;
+      }
+    }
+  }
   for(i=0; i<argc; i++){
     if( sqlite3_value_type(argv[i])==SQLITE_NULL ){
       /* If any of the constraints have a NULL value, then return no rows.
@@ -6030,7 +6072,7 @@ static int seriesFilter(
       break;
     }
   }
-  if( idxNum & 8 ){
+  if( idxNum & 0x08 ){
     pCur->ss.isReversing = pCur->ss.iStep > 0;
   }else{
     pCur->ss.isReversing = pCur->ss.iStep < 0;
@@ -6050,10 +6092,13 @@ static int seriesFilter(
 **
 ** The query plan is represented by bits in idxNum:
 **
-**  (1)  start = $value  -- constraint exists
-**  (2)  stop = $value   -- constraint exists
-**  (4)  step = $value   -- constraint exists
-**  (8)  output in descending order
+**   0x01  start = $value  -- constraint exists
+**   0x02  stop = $value   -- constraint exists
+**   0x04  step = $value   -- constraint exists
+**   0x08  output is in descending order
+**   0x10  output is in ascending order
+**   0x20  LIMIT $value    -- constraint exists
+**   0x40  OFFSET $value   -- constraint exists
 */
 static int seriesBestIndex(
   sqlite3_vtab *pVTab,
@@ -6061,10 +6106,12 @@ static int seriesBestIndex(
 ){
   int i, j;              /* Loop over constraints */
   int idxNum = 0;        /* The query plan bitmask */
+#ifndef ZERO_ARGUMENT_GENERATE_SERIES
   int bStartSeen = 0;    /* EQ constraint seen on the START column */
+#endif
   int unusableMask = 0;  /* Mask of unusable constraints */
   int nArg = 0;          /* Number of arguments that seriesFilter() expects */
-  int aIdx[3];           /* Constraints on start, stop, and step */
+  int aIdx[5];           /* Constraints on start, stop, step, LIMIT, OFFSET */
   const struct sqlite3_index_constraint *pConstraint;
 
   /* This implementation assumes that the start, stop, and step columns
@@ -6072,28 +6119,54 @@ static int seriesBestIndex(
   assert( SERIES_COLUMN_STOP == SERIES_COLUMN_START+1 );
   assert( SERIES_COLUMN_STEP == SERIES_COLUMN_START+2 );
 
-  aIdx[0] = aIdx[1] = aIdx[2] = -1;
+  aIdx[0] = aIdx[1] = aIdx[2] = aIdx[3] = aIdx[4] = -1;
   pConstraint = pIdxInfo->aConstraint;
   for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){
     int iCol;    /* 0 for start, 1 for stop, 2 for step */
     int iMask;   /* bitmask for those column */
+    int op = pConstraint->op;
+    if( op>=SQLITE_INDEX_CONSTRAINT_LIMIT
+     && op<=SQLITE_INDEX_CONSTRAINT_OFFSET
+    ){
+      if( pConstraint->usable==0 ){
+        /* do nothing */
+      }else if( op==SQLITE_INDEX_CONSTRAINT_LIMIT ){
+        aIdx[3] = i;
+        idxNum |= 0x20;
+      }else{
+        assert( op==SQLITE_INDEX_CONSTRAINT_OFFSET );
+        aIdx[4] = i;
+        idxNum |= 0x40;
+      }
+      continue;
+    }
     if( pConstraint->iColumn<SERIES_COLUMN_START ) continue;
     iCol = pConstraint->iColumn - SERIES_COLUMN_START;
     assert( iCol>=0 && iCol<=2 );
     iMask = 1 << iCol;
-    if( iCol==0 ) bStartSeen = 1;
+#ifndef ZERO_ARGUMENT_GENERATE_SERIES
+    if( iCol==0 && op==SQLITE_INDEX_CONSTRAINT_EQ ){
+      bStartSeen = 1;
+    }
+#endif
     if( pConstraint->usable==0 ){
       unusableMask |=  iMask;
       continue;
-    }else if( pConstraint->op==SQLITE_INDEX_CONSTRAINT_EQ ){
+    }else if( op==SQLITE_INDEX_CONSTRAINT_EQ ){
       idxNum |= iMask;
       aIdx[iCol] = i;
     }
   }
-  for(i=0; i<3; i++){
+  if( aIdx[3]==0 ){
+    /* Ignore OFFSET if LIMIT is omitted */
+    idxNum &= ~0x60;
+    aIdx[4] = 0;
+  }
+  for(i=0; i<5; i++){
     if( (j = aIdx[i])>=0 ){
       pIdxInfo->aConstraintUsage[j].argvIndex = ++nArg;
-      pIdxInfo->aConstraintUsage[j].omit = !SQLITE_SERIES_CONSTRAINT_VERIFY;
+      pIdxInfo->aConstraintUsage[j].omit =
+         !SQLITE_SERIES_CONSTRAINT_VERIFY || i>=3;
     }
   }
   /* The current generate_column() implementation requires at least one
@@ -6114,19 +6187,22 @@ static int seriesBestIndex(
     ** this plan is unusable */
     return SQLITE_CONSTRAINT;
   }
-  if( (idxNum & 3)==3 ){
+  if( (idxNum & 0x03)==0x03 ){
     /* Both start= and stop= boundaries are available.  This is the 
     ** the preferred case */
     pIdxInfo->estimatedCost = (double)(2 - ((idxNum&4)!=0));
     pIdxInfo->estimatedRows = 1000;
     if( pIdxInfo->nOrderBy>=1 && pIdxInfo->aOrderBy[0].iColumn==0 ){
       if( pIdxInfo->aOrderBy[0].desc ){
-        idxNum |= 8;
+        idxNum |= 0x08;
       }else{
-        idxNum |= 16;
+        idxNum |= 0x10;
       }
       pIdxInfo->orderByConsumed = 1;
     }
+  }else if( (idxNum & 0x21)==0x21 ){
+    /* We have start= and LIMIT */
+    pIdxInfo->estimatedRows = 2500;
   }else{
     /* If either boundary is missing, we have to generate a huge span
     ** of numbers.  Make this case very expensive so that the query
@@ -7453,7 +7529,9 @@ static int writeFile(
 #if !defined(_WIN32) && !defined(WIN32)
   if( S_ISLNK(mode) ){
     const char *zTo = (const char*)sqlite3_value_text(pData);
-    if( zTo==0 || symlink(zTo, zFile)<0 ) return 1;
+    if( zTo==0 ) return 1;
+    unlink(zFile);
+    if( symlink(zTo, zFile)<0 ) return 1;
   }else
 #endif
   {
@@ -7539,13 +7617,19 @@ static int writeFile(
       return 1;
     }
 #else
-    /* Legacy unix */
-    struct timeval times[2];
-    times[0].tv_usec = times[1].tv_usec = 0;
-    times[0].tv_sec = time(0);
-    times[1].tv_sec = mtime;
-    if( utimes(zFile, times) ){
-      return 1;
+    /* Legacy unix. 
+    **
+    ** Do not use utimes() on a symbolic link - it sees through the link and
+    ** modifies the timestamps on the target. Or fails if the target does 
+    ** not exist.  */
+    if( 0==S_ISLNK(mode) ){
+      struct timeval times[2];
+      times[0].tv_usec = times[1].tv_usec = 0;
+      times[0].tv_sec = time(0);
+      times[1].tv_sec = mtime;
+      if( utimes(zFile, times) ){
+        return 1;
+      }
     }
 #endif
   }
@@ -11617,7 +11701,7 @@ static void sqlarUncompressFunc(
   sqlite3_value **argv
 ){
   uLong nData;
-  uLongf sz;
+  sqlite3_int64 sz;
 
   assert( argc==2 );
   sz = sqlite3_value_int(argv[1]);
@@ -11625,14 +11709,15 @@ static void sqlarUncompressFunc(
   if( sz<=0 || sz==(nData = sqlite3_value_bytes(argv[0])) ){
     sqlite3_result_value(context, argv[0]);
   }else{
+    uLongf szf = sz;
     const Bytef *pData= sqlite3_value_blob(argv[0]);
     Bytef *pOut = sqlite3_malloc(sz);
     if( pOut==0 ){
       sqlite3_result_error_nomem(context);
-    }else if( Z_OK!=uncompress(pOut, &sz, pData, nData) ){
+    }else if( Z_OK!=uncompress(pOut, &szf, pData, nData) ){
       sqlite3_result_error(context, "error in uncompress()", -1);
     }else{
-      sqlite3_result_blob(context, pOut, sz, SQLITE_TRANSIENT);
+      sqlite3_result_blob(context, pOut, szf, SQLITE_TRANSIENT);
     }
     sqlite3_free(pOut);
   }
@@ -13784,7 +13869,7 @@ sqlite3expert *sqlite3_expert_new(sqlite3 *db, char **pzErrmsg){
     sqlite3_stmt *pSql = 0;
     rc = idxPrintfPrepareStmt(pNew->db, &pSql, pzErrmsg, 
         "SELECT sql FROM sqlite_schema WHERE name NOT LIKE 'sqlite_%%'"
-        " AND sql NOT LIKE 'CREATE VIRTUAL %%'"
+        " AND sql NOT LIKE 'CREATE VIRTUAL %%' ORDER BY rowid"
     );
     while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){
       const char *zSql = (const char*)sqlite3_column_text(pSql, 0);
@@ -13888,103 +13973,1221 @@ int sqlite3_expert_sql(
   return rc;
 }
 
-int sqlite3_expert_analyze(sqlite3expert *p, char **pzErr){
-  int rc;
-  IdxHashEntry *pEntry;
+int sqlite3_expert_analyze(sqlite3expert *p, char **pzErr){
+  int rc;
+  IdxHashEntry *pEntry;
+
+  /* Do trigger processing to collect any extra IdxScan structures */
+  rc = idxProcessTriggers(p, pzErr);
+
+  /* Create candidate indexes within the in-memory database file */
+  if( rc==SQLITE_OK ){
+    rc = idxCreateCandidates(p);
+  }else if ( rc==SQLITE_BUSY_TIMEOUT ){
+    if( pzErr )
+      *pzErr = sqlite3_mprintf("Cannot find a unique index name to propose.");
+    return rc;
+  }
+
+  /* Generate the stat1 data */
+  if( rc==SQLITE_OK ){
+    rc = idxPopulateStat1(p, pzErr);
+  }
+
+  /* Formulate the EXPERT_REPORT_CANDIDATES text */
+  for(pEntry=p->hIdx.pFirst; pEntry; pEntry=pEntry->pNext){
+    p->zCandidates = idxAppendText(&rc, p->zCandidates, 
+        "%s;%s%s\n", pEntry->zVal, 
+        pEntry->zVal2 ? " -- stat1: " : "", pEntry->zVal2
+    );
+  }
+
+  /* Figure out which of the candidate indexes are preferred by the query
+  ** planner and report the results to the user.  */
+  if( rc==SQLITE_OK ){
+    rc = idxFindIndexes(p, pzErr);
+  }
+
+  if( rc==SQLITE_OK ){
+    p->bRun = 1;
+  }
+  return rc;
+}
+
+/*
+** Return the total number of statements that have been added to this
+** sqlite3expert using sqlite3_expert_sql().
+*/
+int sqlite3_expert_count(sqlite3expert *p){
+  int nRet = 0;
+  if( p->pStatement ) nRet = p->pStatement->iId+1;
+  return nRet;
+}
+
+/*
+** Return a component of the report.
+*/
+const char *sqlite3_expert_report(sqlite3expert *p, int iStmt, int eReport){
+  const char *zRet = 0;
+  IdxStatement *pStmt;
+
+  if( p->bRun==0 ) return 0;
+  for(pStmt=p->pStatement; pStmt && pStmt->iId!=iStmt; pStmt=pStmt->pNext);
+  switch( eReport ){
+    case EXPERT_REPORT_SQL:
+      if( pStmt ) zRet = pStmt->zSql;
+      break;
+    case EXPERT_REPORT_INDEXES:
+      if( pStmt ) zRet = pStmt->zIdx;
+      break;
+    case EXPERT_REPORT_PLAN:
+      if( pStmt ) zRet = pStmt->zEQP;
+      break;
+    case EXPERT_REPORT_CANDIDATES:
+      zRet = p->zCandidates;
+      break;
+  }
+  return zRet;
+}
+
+/*
+** Free an sqlite3expert object.
+*/
+void sqlite3_expert_destroy(sqlite3expert *p){
+  if( p ){
+    sqlite3_close(p->dbm);
+    sqlite3_close(p->dbv);
+    idxScanFree(p->pScan, 0);
+    idxStatementFree(p->pStatement, 0);
+    idxTableFree(p->pTable);
+    idxWriteFree(p->pWrite);
+    idxHashClear(&p->hIdx);
+    sqlite3_free(p->zCandidates);
+    sqlite3_free(p);
+  }
+}
+
+#endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */
+
+/************************* End ../ext/expert/sqlite3expert.c ********************/
+
+/************************* Begin ../ext/intck/sqlite3intck.h ******************/
+/*
+** 2024-02-08
+**
+** The author disclaims copyright to this source code.  In place of
+** a legal notice, here is a blessing:
+**
+**    May you do good and not evil.
+**    May you find forgiveness for yourself and forgive others.
+**    May you share freely, never taking more than you give.
+**
+*************************************************************************
+*/
+
+/*
+** Incremental Integrity-Check Extension
+** -------------------------------------
+**
+** This module contains code to check whether or not an SQLite database
+** is well-formed or corrupt. This is the same task as performed by SQLite's
+** built-in "PRAGMA integrity_check" command. This module differs from
+** "PRAGMA integrity_check" in that:
+**
+**   +  It is less thorough - this module does not detect certain types
+**      of corruption that are detected by the PRAGMA command. However,
+**      it does detect all kinds of corruption that are likely to cause
+**      errors in SQLite applications.
+**
+**   +  It is slower. Sometimes up to three times slower.
+**
+**   +  It allows integrity-check operations to be split into multiple
+**      transactions, so that the database does not need to be read-locked
+**      for the duration of the integrity-check.
+**
+** One way to use the API to run integrity-check on the "main" database
+** of handle db is:
+**
+**   int rc = SQLITE_OK;
+**   sqlite3_intck *p = 0;
+**
+**   sqlite3_intck_open(db, "main", &p);
+**   while( SQLITE_OK==sqlite3_intck_step(p) ){
+**     const char *zMsg = sqlite3_intck_message(p);
+**     if( zMsg ) printf("corruption: %s\n", zMsg);
+**   }
+**   rc = sqlite3_intck_error(p, &zErr);
+**   if( rc!=SQLITE_OK ){
+**     printf("error occured (rc=%d), (errmsg=%s)\n", rc, zErr);
+**   }
+**   sqlite3_intck_close(p);
+**
+** Usually, the sqlite3_intck object opens a read transaction within the
+** first call to sqlite3_intck_step() and holds it open until the 
+** integrity-check is complete. However, if sqlite3_intck_unlock() is
+** called, the read transaction is ended and a new read transaction opened
+** by the subsequent call to sqlite3_intck_step().
+*/
+
+#ifndef _SQLITE_INTCK_H
+#define _SQLITE_INTCK_H
+
+/* #include "sqlite3.h" */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+** An ongoing incremental integrity-check operation is represented by an
+** opaque pointer of the following type.
+*/
+typedef struct sqlite3_intck sqlite3_intck;
+
+/*
+** Open a new incremental integrity-check object. If successful, populate
+** output variable (*ppOut) with the new object handle and return SQLITE_OK.
+** Or, if an error occurs, set (*ppOut) to NULL and return an SQLite error
+** code (e.g. SQLITE_NOMEM).
+**
+** The integrity-check will be conducted on database zDb (which must be "main",
+** "temp", or the name of an attached database) of database handle db. Once
+** this function has been called successfully, the caller should not use 
+** database handle db until the integrity-check object has been destroyed
+** using sqlite3_intck_close().
+*/
+int sqlite3_intck_open(
+  sqlite3 *db,                    /* Database handle */
+  const char *zDb,                /* Database name ("main", "temp" etc.) */
+  sqlite3_intck **ppOut           /* OUT: New sqlite3_intck handle */
+);
+
+/*
+** Close and release all resources associated with a handle opened by an
+** earlier call to sqlite3_intck_open(). The results of using an
+** integrity-check handle after it has been passed to this function are
+** undefined.
+*/
+void sqlite3_intck_close(sqlite3_intck *pCk);
+
+/*
+** Do the next step of the integrity-check operation specified by the handle
+** passed as the only argument. This function returns SQLITE_DONE if the 
+** integrity-check operation is finished, or an SQLite error code if
+** an error occurs, or SQLITE_OK if no error occurs but the integrity-check
+** is not finished. It is not considered an error if database corruption
+** is encountered.
+**
+** Following a successful call to sqlite3_intck_step() (one that returns
+** SQLITE_OK), sqlite3_intck_message() returns a non-NULL value if 
+** corruption was detected in the db.
+**
+** If an error occurs and a value other than SQLITE_OK or SQLITE_DONE is
+** returned, then the integrity-check handle is placed in an error state.
+** In this state all subsequent calls to sqlite3_intck_step() or 
+** sqlite3_intck_unlock() will immediately return the same error. The 
+** sqlite3_intck_error() method may be used to obtain an English language 
+** error message in this case.
+*/
+int sqlite3_intck_step(sqlite3_intck *pCk);
+
+/*
+** If the previous call to sqlite3_intck_step() encountered corruption 
+** within the database, then this function returns a pointer to a buffer
+** containing a nul-terminated string describing the corruption in 
+** English. If the previous call to sqlite3_intck_step() did not encounter
+** corruption, or if there was no previous call, this function returns 
+** NULL.
+*/
+const char *sqlite3_intck_message(sqlite3_intck *pCk);
+
+/*
+** Close any read-transaction opened by an earlier call to 
+** sqlite3_intck_step(). Any subsequent call to sqlite3_intck_step() will
+** open a new transaction. Return SQLITE_OK if successful, or an SQLite error
+** code otherwise.
+**
+** If an error occurs, then the integrity-check handle is placed in an error
+** state. In this state all subsequent calls to sqlite3_intck_step() or 
+** sqlite3_intck_unlock() will immediately return the same error. The 
+** sqlite3_intck_error() method may be used to obtain an English language 
+** error message in this case.
+*/
+int sqlite3_intck_unlock(sqlite3_intck *pCk);
+
+/*
+** If an error has occurred in an earlier call to sqlite3_intck_step()
+** or sqlite3_intck_unlock(), then this method returns the associated 
+** SQLite error code. Additionally, if pzErr is not NULL, then (*pzErr)
+** may be set to point to a nul-terminated string containing an English
+** language error message. Or, if no error message is available, to
+** NULL.
+**
+** If no error has occurred within sqlite3_intck_step() or
+** sqlite_intck_unlock() calls on the handle passed as the first argument, 
+** then SQLITE_OK is returned and (*pzErr) set to NULL.
+*/
+int sqlite3_intck_error(sqlite3_intck *pCk, const char **pzErr);
+
+/*
+** This API is used for testing only. It returns the full-text of an SQL
+** statement used to test object zObj, which may be a table or index.
+** The returned buffer is valid until the next call to either this function
+** or sqlite3_intck_close() on the same sqlite3_intck handle.
+*/
+const char *sqlite3_intck_test_sql(sqlite3_intck *pCk, const char *zObj);
+
+
+#ifdef __cplusplus
+}  /* end of the 'extern "C"' block */
+#endif
+
+#endif /* ifndef _SQLITE_INTCK_H */
+
+/************************* End ../ext/intck/sqlite3intck.h ********************/
+/************************* Begin ../ext/intck/sqlite3intck.c ******************/
+/*
+** 2024-02-08
+**
+** The author disclaims copyright to this source code.  In place of
+** a legal notice, here is a blessing:
+**
+**    May you do good and not evil.
+**    May you find forgiveness for yourself and forgive others.
+**    May you share freely, never taking more than you give.
+**
+*************************************************************************
+*/
+
+/* #include "sqlite3intck.h" */
+#include <string.h>
+#include <assert.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+/*
+** nKeyVal:
+**   The number of values that make up the 'key' for the current pCheck
+**   statement.
+**
+** rc:
+**   Error code returned by most recent sqlite3_intck_step() or 
+**   sqlite3_intck_unlock() call. This is set to SQLITE_DONE when
+**   the integrity-check operation is finished.
+**
+** zErr:
+**   If the object has entered the error state, this is the error message.
+**   Is freed using sqlite3_free() when the object is deleted.
+**
+** zTestSql:
+**   The value returned by the most recent call to sqlite3_intck_testsql().
+**   Each call to testsql() frees the previous zTestSql value (using
+**   sqlite3_free()) and replaces it with the new value it will return.
+*/
+struct sqlite3_intck {
+  sqlite3 *db;
+  const char *zDb;                /* Copy of zDb parameter to _open() */
+  char *zObj;                     /* Current object. Or NULL. */
+
+  sqlite3_stmt *pCheck;           /* Current check statement */
+  char *zKey;
+  int nKeyVal;
+
+  char *zMessage;
+  int bCorruptSchema;
+
+  int rc;                         /* Error code */
+  char *zErr;                     /* Error message */
+  char *zTestSql;                 /* Returned by sqlite3_intck_test_sql() */
+};
+
+
+/*
+** Some error has occurred while using database p->db. Save the error message
+** and error code currently held by the database handle in p->rc and p->zErr.
+*/
+static void intckSaveErrmsg(sqlite3_intck *p){
+  p->rc = sqlite3_errcode(p->db);
+  sqlite3_free(p->zErr);
+  p->zErr = sqlite3_mprintf("%s", sqlite3_errmsg(p->db));
+}
+
+/*
+** If the handle passed as the first argument is already in the error state,
+** then this function is a no-op (returns NULL immediately). Otherwise, if an
+** error occurs within this function, it leaves an error in said handle.
+**
+** Otherwise, this function attempts to prepare SQL statement zSql and
+** return the resulting statement handle to the user.
+*/
+static sqlite3_stmt *intckPrepare(sqlite3_intck *p, const char *zSql){
+  sqlite3_stmt *pRet = 0;
+  if( p->rc==SQLITE_OK ){
+    p->rc = sqlite3_prepare_v2(p->db, zSql, -1, &pRet, 0);
+    if( p->rc!=SQLITE_OK ){
+      intckSaveErrmsg(p);
+      assert( pRet==0 );
+    }
+  }
+  return pRet;
+}
+
+/*
+** If the handle passed as the first argument is already in the error state,
+** then this function is a no-op (returns NULL immediately). Otherwise, if an
+** error occurs within this function, it leaves an error in said handle.
+**
+** Otherwise, this function treats argument zFmt as a printf() style format
+** string. It formats it according to the trailing arguments and then 
+** attempts to prepare the results and return the resulting prepared
+** statement.
+*/
+static sqlite3_stmt *intckPrepareFmt(sqlite3_intck *p, const char *zFmt, ...){
+  sqlite3_stmt *pRet = 0;
+  va_list ap;
+  char *zSql = 0;
+  va_start(ap, zFmt);
+  zSql = sqlite3_vmprintf(zFmt, ap);
+  if( p->rc==SQLITE_OK && zSql==0 ){
+    p->rc = SQLITE_NOMEM;
+  }
+  pRet = intckPrepare(p, zSql);
+  sqlite3_free(zSql);
+  va_end(ap);
+  return pRet;
+}
+
+/*
+** Finalize SQL statement pStmt. If an error occurs and the handle passed
+** as the first argument does not already contain an error, store the
+** error in the handle.
+*/
+static void intckFinalize(sqlite3_intck *p, sqlite3_stmt *pStmt){
+  int rc = sqlite3_finalize(pStmt);
+  if( p->rc==SQLITE_OK && rc!=SQLITE_OK ){
+    intckSaveErrmsg(p);
+  }
+}
+
+/*
+** If there is already an error in handle p, return it. Otherwise, call
+** sqlite3_step() on the statement handle and return that value.
+*/
+static int intckStep(sqlite3_intck *p, sqlite3_stmt *pStmt){
+  if( p->rc ) return p->rc;
+  return sqlite3_step(pStmt);
+}
+
+/*
+** Execute SQL statement zSql. There is no way to obtain any results 
+** returned by the statement. This function uses the sqlite3_intck error
+** code convention.
+*/
+static void intckExec(sqlite3_intck *p, const char *zSql){
+  sqlite3_stmt *pStmt = 0;
+  pStmt = intckPrepare(p, zSql);
+  intckStep(p, pStmt);
+  intckFinalize(p, pStmt);
+}
+
+/*
+** A wrapper around sqlite3_mprintf() that uses the sqlite3_intck error
+** code convention.
+*/
+static char *intckMprintf(sqlite3_intck *p, const char *zFmt, ...){
+  va_list ap;
+  char *zRet = 0;
+  va_start(ap, zFmt);
+  zRet = sqlite3_vmprintf(zFmt, ap);
+  if( p->rc==SQLITE_OK ){
+    if( zRet==0 ){
+      p->rc = SQLITE_NOMEM;
+    }
+  }else{
+    sqlite3_free(zRet);
+    zRet = 0;
+  }
+  return zRet;
+}
+
+/*
+** This is used by sqlite3_intck_unlock() to save the vector key value 
+** required to restart the current pCheck query as a nul-terminated string 
+** in p->zKey.
+*/
+static void intckSaveKey(sqlite3_intck *p){
+  int ii;
+  char *zSql = 0;
+  sqlite3_stmt *pStmt = 0;
+  sqlite3_stmt *pXinfo = 0;
+  const char *zDir = 0;
+
+  assert( p->pCheck );
+  assert( p->zKey==0 );
+
+  pXinfo = intckPrepareFmt(p, 
+      "SELECT group_concat(desc, '') FROM %Q.sqlite_schema s, "
+      "pragma_index_xinfo(%Q, %Q) "
+      "WHERE s.type='index' AND s.name=%Q",
+      p->zDb, p->zObj, p->zDb, p->zObj
+  );
+  if( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pXinfo) ){
+    zDir = (const char*)sqlite3_column_text(pXinfo, 0);
+  }
+
+  if( zDir==0 ){
+    /* Object is a table, not an index. This is the easy case,as there are 
+    ** no DESC columns or NULL values in a primary key.  */
+    const char *zSep = "SELECT '(' || ";
+    for(ii=0; ii<p->nKeyVal; ii++){
+      zSql = intckMprintf(p, "%z%squote(?)", zSql, zSep);
+      zSep = " || ', ' || ";
+    }
+    zSql = intckMprintf(p, "%z || ')'", zSql);
+  }else{
+
+    /* Object is an index. */
+    assert( p->nKeyVal>1 );
+    for(ii=p->nKeyVal; ii>0; ii--){
+      int bLastIsDesc = zDir[ii-1]=='1';
+      int bLastIsNull = sqlite3_column_type(p->pCheck, ii)==SQLITE_NULL;
+      const char *zLast = sqlite3_column_name(p->pCheck, ii);
+      char *zLhs = 0;
+      char *zRhs = 0;
+      char *zWhere = 0;
+
+      if( bLastIsNull ){
+        if( bLastIsDesc ) continue;
+        zWhere = intckMprintf(p, "'%s IS NOT NULL'", zLast);
+      }else{
+        const char *zOp = bLastIsDesc ? "<" : ">";
+        zWhere = intckMprintf(p, "'%s %s ' || quote(?%d)", zLast, zOp, ii);
+      }
+
+      if( ii>1 ){
+        const char *zLhsSep = "";
+        const char *zRhsSep = "";
+        int jj;
+        for(jj=0; jj<ii-1; jj++){
+          const char *zAlias = (const char*)sqlite3_column_name(p->pCheck,jj+1);
+          zLhs = intckMprintf(p, "%z%s%s", zLhs, zLhsSep, zAlias);
+          zRhs = intckMprintf(p, "%z%squote(?%d)", zRhs, zRhsSep, jj+1);
+          zLhsSep = ",";
+          zRhsSep = " || ',' || ";
+        }
+
+        zWhere = intckMprintf(p, 
+            "'(%z) IS (' || %z || ') AND ' || %z",
+            zLhs, zRhs, zWhere);
+      }
+      zWhere = intckMprintf(p, "'WHERE ' || %z", zWhere);
+
+      zSql = intckMprintf(p, "%z%s(quote( %z ) )",
+          zSql,
+          (zSql==0 ? "VALUES" : ",\n      "),
+          zWhere
+      );
+    }
+    zSql = intckMprintf(p, 
+        "WITH wc(q) AS (\n%z\n)"
+        "SELECT 'VALUES' || group_concat('(' || q || ')', ',\n      ') FROM wc"
+        , zSql
+    );
+  }
+
+  pStmt = intckPrepare(p, zSql);
+  if( p->rc==SQLITE_OK ){
+    for(ii=0; ii<p->nKeyVal; ii++){
+      sqlite3_bind_value(pStmt, ii+1, sqlite3_column_value(p->pCheck, ii+1));
+    }
+    if( SQLITE_ROW==sqlite3_step(pStmt) ){
+      p->zKey = intckMprintf(p,"%s",(const char*)sqlite3_column_text(pStmt, 0));
+    }
+    intckFinalize(p, pStmt);
+  }
+
+  sqlite3_free(zSql);
+  intckFinalize(p, pXinfo);
+}
+
+/*
+** Find the next database object (table or index) to check. If successful,
+** set sqlite3_intck.zObj to point to a nul-terminated buffer containing
+** the object's name before returning.
+*/
+static void intckFindObject(sqlite3_intck *p){
+  sqlite3_stmt *pStmt = 0;
+  char *zPrev = p->zObj;
+  p->zObj = 0;
+
+  assert( p->rc==SQLITE_OK );
+  assert( p->pCheck==0 );
+
+  pStmt = intckPrepareFmt(p, 
+    "WITH tables(table_name) AS (" 
+    "  SELECT name"
+    "  FROM %Q.sqlite_schema WHERE (type='table' OR type='index') AND rootpage"
+    "  UNION ALL "
+    "  SELECT 'sqlite_schema'"
+    ")"
+    "SELECT table_name FROM tables "
+    "WHERE ?1 IS NULL OR table_name%s?1 "
+    "ORDER BY 1"
+    , p->zDb, (p->zKey ? ">=" : ">")
+  );
+
+  if( p->rc==SQLITE_OK ){
+    sqlite3_bind_text(pStmt, 1, zPrev, -1, SQLITE_TRANSIENT);
+    if( sqlite3_step(pStmt)==SQLITE_ROW ){
+      p->zObj = intckMprintf(p,"%s",(const char*)sqlite3_column_text(pStmt, 0));
+    }
+  }
+  intckFinalize(p, pStmt);
+
+  /* If this is a new object, ensure the previous key value is cleared. */
+  if( sqlite3_stricmp(p->zObj, zPrev) ){
+    sqlite3_free(p->zKey);
+    p->zKey = 0;
+  }
+
+  sqlite3_free(zPrev);
+}
+
+/*
+** Return the size in bytes of the first token in nul-terminated buffer z.
+** For the purposes of this call, a token is either:
+**
+**   *  a quoted SQL string,
+*    *  a contiguous series of ascii alphabet characters, or
+*    *  any other single byte.
+*/
+static int intckGetToken(const char *z){
+  char c = z[0];
+  int iRet = 1;
+  if( c=='\'' || c=='"' || c=='`' ){
+    while( 1 ){
+      if( z[iRet]==c ){
+        iRet++;
+        if( z[iRet]!=c ) break;
+      }
+      iRet++;
+    }
+  }
+  else if( c=='[' ){
+    while( z[iRet++]!=']' && z[iRet] );
+  }
+  else if( (c>='A' && c<='Z') || (c>='a' && c<='z') ){
+    while( (z[iRet]>='A' && z[iRet]<='Z') || (z[iRet]>='a' && z[iRet]<='z') ){
+      iRet++;
+    }
+  }
+
+  return iRet;
+}
+
+/*
+** Return true if argument c is an ascii whitespace character.
+*/
+static int intckIsSpace(char c){
+  return (c==' ' || c=='\t' || c=='\n' || c=='\r');
+}
+
+/*
+** Argument z points to the text of a CREATE INDEX statement. This function
+** identifies the part of the text that contains either the index WHERE 
+** clause (if iCol<0) or the iCol'th column of the index.
+**
+** If (iCol<0), the identified fragment does not include the "WHERE" keyword,
+** only the expression that follows it. If (iCol>=0) then the identified
+** fragment does not include any trailing sort-order keywords - "ASC" or 
+** "DESC".
+**
+** If the CREATE INDEX statement does not contain the requested field or
+** clause, NULL is returned and (*pnByte) is set to 0. Otherwise, a pointer to
+** the identified fragment is returned and output parameter (*pnByte) set
+** to its size in bytes.
+*/
+static const char *intckParseCreateIndex(const char *z, int iCol, int *pnByte){
+  int iOff = 0;
+  int iThisCol = 0;
+  int iStart = 0;
+  int nOpen = 0;
+
+  const char *zRet = 0;
+  int nRet = 0;
+
+  int iEndOfCol = 0;
+
+  /* Skip forward until the first "(" token */
+  while( z[iOff]!='(' ){
+    iOff += intckGetToken(&z[iOff]);
+    if( z[iOff]=='\0' ) return 0;
+  }
+  assert( z[iOff]=='(' );
+
+  nOpen = 1;
+  iOff++;
+  iStart = iOff;
+  while( z[iOff] ){
+    const char *zToken = &z[iOff];
+    int nToken = 0;
+
+    /* Check if this is the end of the current column - either a "," or ")"
+    ** when nOpen==1.  */
+    if( nOpen==1 ){
+      if( z[iOff]==',' || z[iOff]==')' ){
+        if( iCol==iThisCol ){
+          int iEnd = iEndOfCol ? iEndOfCol : iOff;
+          nRet = (iEnd - iStart);
+          zRet = &z[iStart];
+          break;
+        }
+        iStart = iOff+1;
+        while( intckIsSpace(z[iStart]) ) iStart++;
+        iThisCol++;
+      }
+      if( z[iOff]==')' ) break;
+    }
+    if( z[iOff]=='(' ) nOpen++;
+    if( z[iOff]==')' ) nOpen--;
+    nToken = intckGetToken(zToken);
+
+    if( (nToken==3 && 0==sqlite3_strnicmp(zToken, "ASC", nToken))
+     || (nToken==4 && 0==sqlite3_strnicmp(zToken, "DESC", nToken))
+    ){
+      iEndOfCol = iOff;
+    }else if( 0==intckIsSpace(zToken[0]) ){
+      iEndOfCol = 0;
+    }
+
+    iOff += nToken;
+  }
+
+  /* iStart is now the byte offset of 1 byte passed the final ')' in the
+  ** CREATE INDEX statement. Try to find a WHERE clause to return.  */
+  while( zRet==0 && z[iOff] ){
+    int n = intckGetToken(&z[iOff]);
+    if( n==5 && 0==sqlite3_strnicmp(&z[iOff], "where", 5) ){
+      zRet = &z[iOff+5];
+      nRet = (int)strlen(zRet);
+    }
+    iOff += n;
+  }
+
+  /* Trim any whitespace from the start and end of the returned string. */
+  if( zRet ){
+    while( intckIsSpace(zRet[0]) ){
+      nRet--;
+      zRet++;
+    }
+    while( nRet>0 && intckIsSpace(zRet[nRet-1]) ) nRet--;
+  }
+
+  *pnByte = nRet;
+  return zRet;
+}
+
+/*
+** User-defined SQL function wrapper for intckParseCreateIndex():
+**
+**     SELECT parse_create_index(<sql>, <icol>);
+*/
+static void intckParseCreateIndexFunc(
+  sqlite3_context *pCtx, 
+  int nVal, 
+  sqlite3_value **apVal
+){
+  const char *zSql = (const char*)sqlite3_value_text(apVal[0]);
+  int idx = sqlite3_value_int(apVal[1]);
+  const char *zRes = 0;
+  int nRes = 0;
+
+  assert( nVal==2 );
+  if( zSql ){
+    zRes = intckParseCreateIndex(zSql, idx, &nRes);
+  }
+  sqlite3_result_text(pCtx, zRes, nRes, SQLITE_TRANSIENT);
+}
+
+/*
+** Return true if sqlite3_intck.db has automatic indexes enabled, false
+** otherwise.
+*/
+static int intckGetAutoIndex(sqlite3_intck *p){
+  int bRet = 0;
+  sqlite3_stmt *pStmt = 0;
+  pStmt = intckPrepare(p, "PRAGMA automatic_index");
+  if( SQLITE_ROW==intckStep(p, pStmt) ){
+    bRet = sqlite3_column_int(pStmt, 0);
+  }
+  intckFinalize(p, pStmt);
+  return bRet;
+}
+
+/*
+** Return true if zObj is an index, or false otherwise.
+*/
+static int intckIsIndex(sqlite3_intck *p, const char *zObj){
+  int bRet = 0;
+  sqlite3_stmt *pStmt = 0;
+  pStmt = intckPrepareFmt(p, 
+      "SELECT 1 FROM %Q.sqlite_schema WHERE name=%Q AND type='index'",
+      p->zDb, zObj
+  );
+  if( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){
+    bRet = 1;
+  }
+  intckFinalize(p, pStmt);
+  return bRet;
+}
+
+/*
+** Return a pointer to a nul-terminated buffer containing the SQL statement
+** used to check database object zObj (a table or index) for corruption.
+** If parameter zPrev is not NULL, then it must be a string containing the
+** vector key required to restart the check where it left off last time.
+** If pnKeyVal is not NULL, then (*pnKeyVal) is set to the number of
+** columns in the vector key value for the specified object.
+**
+** This function uses the sqlite3_intck error code convention.
+*/
+static char *intckCheckObjectSql(
+  sqlite3_intck *p,               /* Integrity check object */
+  const char *zObj,               /* Object (table or index) to scan */
+  const char *zPrev,              /* Restart key vector, if any */
+  int *pnKeyVal                   /* OUT: Number of key-values for this scan */
+){
+  char *zRet = 0;
+  sqlite3_stmt *pStmt = 0;
+  int bAutoIndex = 0;
+  int bIsIndex = 0;
+
+  const char *zCommon = 
+      /* Relation without_rowid also contains just one row. Column "b" is
+      ** set to true if the table being examined is a WITHOUT ROWID table,
+      ** or false otherwise.  */
+      ", without_rowid(b) AS ("
+      "  SELECT EXISTS ("
+      "    SELECT 1 FROM tabname, pragma_index_list(tab, db) AS l"
+      "      WHERE origin='pk' "
+      "      AND NOT EXISTS (SELECT 1 FROM sqlite_schema WHERE name=l.name)"
+      "  )"
+      ")"
+      ""
+      /* Table idx_cols contains 1 row for each column in each index on the
+      ** table being checked. Columns are:
+      **
+      **   idx_name: Name of the index.
+      **   idx_ispk: True if this index is the PK of a WITHOUT ROWID table.
+      **   col_name: Name of indexed column, or NULL for index on expression.
+      **   col_expr: Indexed expression, including COLLATE clause.
+      **   col_alias: Alias used for column in 'intck_wrapper' table.
+      */
+      ", idx_cols(idx_name, idx_ispk, col_name, col_expr, col_alias) AS ("
+      "  SELECT l.name, (l.origin=='pk' AND w.b), i.name, COALESCE(("
+      "    SELECT parse_create_index(sql, i.seqno) FROM "
+      "    sqlite_schema WHERE name = l.name"
+      "  ), format('\"%w\"', i.name) || ' COLLATE ' || quote(i.coll)),"
+      "  'c' || row_number() OVER ()"
+      "  FROM "
+      "      tabname t,"
+      "      without_rowid w,"
+      "      pragma_index_list(t.tab, t.db) l,"
+      "      pragma_index_xinfo(l.name) i"
+      "      WHERE i.key"
+      "  UNION ALL"
+      "  SELECT '', 1, '_rowid_', '_rowid_', 'r1' FROM without_rowid WHERE b=0"
+      ")"
+      ""
+      ""
+      /*
+      ** For a PK declared as "PRIMARY KEY(a, b) ... WITHOUT ROWID", where
+      ** the intck_wrapper aliases of "a" and "b" are "c1" and "c2":
+      **
+      **   o_pk:   "o.c1, o.c2"
+      **   i_pk:   "i.'a', i.'b'"
+      **   ...
+      **   n_pk:   2
+      */ 
+      ", tabpk(db, tab, idx, o_pk, i_pk, q_pk, eq_pk, ps_pk, pk_pk, n_pk) AS ("
+      "    WITH pkfields(f, a) AS ("
+      "      SELECT i.col_name, i.col_alias FROM idx_cols i WHERE i.idx_ispk"
+      "    )"
+      "    SELECT t.db, t.tab, t.idx, "
+      "           group_concat(a, ', '), "
+      "           group_concat('i.'||quote(f), ', '), "
+      "           group_concat('quote(o.'||a||')', ' || '','' || '),  "
+      "           format('(%s)==(%s)',"
+      "               group_concat('o.'||a, ', '), "
+      "               group_concat(format('\"%w\"', f), ', ')"
+      "           ),"
+      "           group_concat('%s', ','),"
+      "           group_concat('quote('||a||')', ', '),  "
+      "           count(*)"
+      "    FROM tabname t, pkfields"
+      ")"
+      ""
+      ", idx(name, match_expr, partial, partial_alias, idx_ps, idx_idx) AS ("
+      "  SELECT idx_name,"
+      "    format('(%s,%s) IS (%s,%s)', "
+      "           group_concat(i.col_expr, ', '), i_pk,"
+      "           group_concat('o.'||i.col_alias, ', '), o_pk"
+      "    ), "
+      "    parse_create_index("
+      "        (SELECT sql FROM sqlite_schema WHERE name=idx_name), -1"
+      "    ),"
+      "    'cond' || row_number() OVER ()"
+      "    , group_concat('%s', ',')"
+      "    , group_concat('quote('||i.col_alias||')', ', ')"
+      "  FROM tabpk t, "
+      "       without_rowid w,"
+      "       idx_cols i"
+      "  WHERE i.idx_ispk==0 "
+      "  GROUP BY idx_name"
+      ")"
+      ""
+      ", wrapper_with(s) AS ("
+      "  SELECT 'intck_wrapper AS (\n  SELECT\n    ' || ("
+      "      WITH f(a, b) AS ("
+      "        SELECT col_expr, col_alias FROM idx_cols"
+      "          UNION ALL "
+      "        SELECT partial, partial_alias FROM idx WHERE partial IS NOT NULL"
+      "      )"
+      "      SELECT group_concat(format('%s AS %s', a, b), ',\n    ') FROM f"
+      "    )"
+      "    || format('\n  FROM %Q.%Q ', t.db, t.tab)"
+           /* If the object being checked is a table, append "NOT INDEXED".
+           ** Otherwise, append "INDEXED BY <index>", and then, if the index 
+           ** is a partial index " WHERE <condition>".  */
+      "    || CASE WHEN t.idx IS NULL THEN "
+      "        'NOT INDEXED'"
+      "       ELSE"
+      "        format('INDEXED BY %Q%s', t.idx, ' WHERE '||i.partial)"
+      "       END"
+      "    || '\n)'"
+      "    FROM tabname t LEFT JOIN idx i ON (i.name=t.idx)"
+      ")"
+      ""
+  ;
+
+  bAutoIndex = intckGetAutoIndex(p);
+  if( bAutoIndex ) intckExec(p, "PRAGMA automatic_index = 0");
+
+  bIsIndex = intckIsIndex(p, zObj);
+  if( bIsIndex ){
+    pStmt = intckPrepareFmt(p,
+      /* Table idxname contains a single row. The first column, "db", contains
+      ** the name of the db containing the table (e.g. "main") and the second,
+      ** "tab", the name of the table itself.  */
+      "WITH tabname(db, tab, idx) AS ("
+      "  SELECT %Q, (SELECT tbl_name FROM %Q.sqlite_schema WHERE name=%Q), %Q "
+      ")"
+      ""
+      ", whereclause(w_c) AS (%s)"
+      ""
+      "%s" /* zCommon */
+      ""
+      ", case_statement(c) AS ("
+      "  SELECT "
+      "    'CASE WHEN (' || group_concat(col_alias, ', ') || ', 1) IS (\n' "
+      "    || '      SELECT ' || group_concat(col_expr, ', ') || ', 1 FROM '"
+      "    || format('%%Q.%%Q NOT INDEXED WHERE %%s\n', t.db, t.tab, p.eq_pk)"
+      "    || '    )\n  THEN NULL\n    '"
+      "    || 'ELSE format(''surplus entry ('"
+      "    ||   group_concat('%%s', ',') || ',' || p.ps_pk"
+      "    || ') in index ' || t.idx || ''', ' "
+      "    ||   group_concat('quote('||i.col_alias||')', ', ') || ', ' || p.pk_pk"
+      "    || ')'"
+      "    || '\n  END AS error_message'"
+      "  FROM tabname t, tabpk p, idx_cols i WHERE i.idx_name=t.idx"
+      ")"
+      ""
+      ", thiskey(k, n) AS ("
+      "    SELECT group_concat(i.col_alias, ', ') || ', ' || p.o_pk, "
+      "           count(*) + p.n_pk "
+      "    FROM tabpk p, idx_cols i WHERE i.idx_name=p.idx"
+      ")"
+      ""
+      ", main_select(m, n) AS ("
+      "  SELECT format("
+      "      'WITH %%s\n' ||"
+      "      ', idx_checker AS (\n' ||"
+      "      '  SELECT %%s,\n' ||"
+      "      '  %%s\n' || "
+      "      '  FROM intck_wrapper AS o\n' ||"
+      "      ')\n',"
+      "      ww.s, c, t.k"
+      "  ), t.n"
+      "  FROM case_statement, wrapper_with ww, thiskey t"
+      ")"
+
+      "SELECT m || "
+      "    group_concat('SELECT * FROM idx_checker ' || w_c, ' UNION ALL '), n"
+      " FROM "
+      "main_select, whereclause "
+      , p->zDb, p->zDb, zObj, zObj
+      , zPrev ? zPrev : "VALUES('')", zCommon
+      );
+  }else{
+    pStmt = intckPrepareFmt(p,
+      /* Table tabname contains a single row. The first column, "db", contains
+      ** the name of the db containing the table (e.g. "main") and the second,
+      ** "tab", the name of the table itself.  */
+      "WITH tabname(db, tab, idx, prev) AS (SELECT %Q, %Q, NULL, %Q)"
+      ""
+      "%s" /* zCommon */
+
+      /* expr(e) contains one row for each index on table zObj. Value e
+      ** is set to an expression that evaluates to NULL if the required
+      ** entry is present in the index, or an error message otherwise.  */
+      ", expr(e, p) AS ("
+      "  SELECT format('CASE WHEN EXISTS \n"
+      "    (SELECT 1 FROM %%Q.%%Q AS i INDEXED BY %%Q WHERE %%s%%s)\n"
+      "    THEN NULL\n"
+      "    ELSE format(''entry (%%s,%%s) missing from index %%s'', %%s, %%s)\n"
+      "  END\n'"
+      "    , t.db, t.tab, i.name, i.match_expr, ' AND (' || partial || ')',"
+      "      i.idx_ps, t.ps_pk, i.name, i.idx_idx, t.pk_pk),"
+      "    CASE WHEN partial IS NULL THEN NULL ELSE i.partial_alias END"
+      "  FROM tabpk t, idx i"
+      ")"
+
+      ", numbered(ii, cond, e) AS ("
+      "  SELECT 0, 'n.ii=0', 'NULL'"
+      "    UNION ALL "
+      "  SELECT row_number() OVER (),"
+      "      '(n.ii='||row_number() OVER ()||COALESCE(' AND '||p||')', ')'), e"
+      "  FROM expr"
+      ")"
+
+      ", counter_with(w) AS ("
+      "    SELECT 'WITH intck_counter(ii) AS (\n  ' || "
+      "       group_concat('SELECT '||ii, ' UNION ALL\n  ') "
+      "    || '\n)' FROM numbered"
+      ")"
+      ""
+      ", case_statement(c) AS ("
+      "    SELECT 'CASE ' || "
+      "    group_concat(format('\n  WHEN %%s THEN (%%s)', cond, e), '') ||"
+      "    '\nEND AS error_message'"
+      "    FROM numbered"
+      ")"
+      ""
+
+      /* This table contains a single row consisting of a single value -
+      ** the text of an SQL expression that may be used by the main SQL
+      ** statement to output an SQL literal that can be used to resume
+      ** the scan if it is suspended. e.g. for a rowid table, an expression
+      ** like:
+      **
+      **     format('(%d,%d)', _rowid_, n.ii)
+      */
+      ", thiskey(k, n) AS ("
+      "    SELECT o_pk || ', ii', n_pk+1 FROM tabpk"
+      ")"
+      ""
+      ", whereclause(w_c) AS ("
+      "    SELECT CASE WHEN prev!='' THEN "
+      "    '\nWHERE (' || o_pk ||', n.ii) > ' || prev"
+      "    ELSE ''"
+      "    END"
+      "    FROM tabpk, tabname"
+      ")"
+      ""
+      ", main_select(m, n) AS ("
+      "  SELECT format("
+      "      '%%s, %%s\nSELECT %%s,\n%%s\nFROM intck_wrapper AS o"
+               ", intck_counter AS n%%s\nORDER BY %%s', "
+      "      w, ww.s, c, thiskey.k, whereclause.w_c, t.o_pk"
+      "  ), thiskey.n"
+      "  FROM case_statement, tabpk t, counter_with, "
+      "       wrapper_with ww, thiskey, whereclause"
+      ")"
+
+      "SELECT m, n FROM main_select",
+      p->zDb, zObj, zPrev, zCommon
+    );
+  }
+
+  while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){
+    zRet = intckMprintf(p, "%s", (const char*)sqlite3_column_text(pStmt, 0));
+    if( pnKeyVal ){
+      *pnKeyVal = sqlite3_column_int(pStmt, 1);
+    }
+  }
+  intckFinalize(p, pStmt);
+
+  if( bAutoIndex ) intckExec(p, "PRAGMA automatic_index = 1");
+  return zRet;
+}
+
+/*
+** Open a new integrity-check object.
+*/
+int sqlite3_intck_open(
+  sqlite3 *db,                    /* Database handle to operate on */
+  const char *zDbArg,             /* "main", "temp" etc. */
+  sqlite3_intck **ppOut           /* OUT: New integrity-check handle */
+){
+  sqlite3_intck *pNew = 0;
+  int rc = SQLITE_OK;
+  const char *zDb = zDbArg ? zDbArg : "main";
+  int nDb = (int)strlen(zDb);
+
+  pNew = (sqlite3_intck*)sqlite3_malloc(sizeof(*pNew) + nDb + 1);
+  if( pNew==0 ){
+    rc = SQLITE_NOMEM;
+  }else{
+    memset(pNew, 0, sizeof(*pNew));
+    pNew->db = db;
+    pNew->zDb = (const char*)&pNew[1];
+    memcpy(&pNew[1], zDb, nDb+1);
+    rc = sqlite3_create_function(db, "parse_create_index", 
+        2, SQLITE_UTF8, 0, intckParseCreateIndexFunc, 0, 0
+    );
+    if( rc!=SQLITE_OK ){
+      sqlite3_intck_close(pNew);
+      pNew = 0;
+    }
+  }
+
+  *ppOut = pNew;
+  return rc;
+}
+
+/*
+** Free the integrity-check object.
+*/
+void sqlite3_intck_close(sqlite3_intck *p){
+  if( p ){
+    sqlite3_finalize(p->pCheck);
+    sqlite3_create_function(
+        p->db, "parse_create_index", 1, SQLITE_UTF8, 0, 0, 0, 0
+    );
+    sqlite3_free(p->zObj);
+    sqlite3_free(p->zKey);
+    sqlite3_free(p->zTestSql);
+    sqlite3_free(p->zErr);
+    sqlite3_free(p->zMessage);
+    sqlite3_free(p);
+  }
+}
 
-  /* Do trigger processing to collect any extra IdxScan structures */
-  rc = idxProcessTriggers(p, pzErr);
+/*
+** Step the integrity-check object.
+*/
+int sqlite3_intck_step(sqlite3_intck *p){
+  if( p->rc==SQLITE_OK ){
 
-  /* Create candidate indexes within the in-memory database file */
-  if( rc==SQLITE_OK ){
-    rc = idxCreateCandidates(p);
-  }else if ( rc==SQLITE_BUSY_TIMEOUT ){
-    if( pzErr )
-      *pzErr = sqlite3_mprintf("Cannot find a unique index name to propose.");
-    return rc;
-  }
+    if( p->zMessage ){
+      sqlite3_free(p->zMessage);
+      p->zMessage = 0;
+    }
 
-  /* Generate the stat1 data */
-  if( rc==SQLITE_OK ){
-    rc = idxPopulateStat1(p, pzErr);
-  }
+    if( p->bCorruptSchema ){
+      p->rc = SQLITE_DONE;
+    }else
+    if( p->pCheck==0 ){
+      intckFindObject(p);
+      if( p->rc==SQLITE_OK ){
+        if( p->zObj ){
+          char *zSql = 0;
+          zSql = intckCheckObjectSql(p, p->zObj, p->zKey, &p->nKeyVal);
+          p->pCheck = intckPrepare(p, zSql);
+          sqlite3_free(zSql);
+          sqlite3_free(p->zKey);
+          p->zKey = 0;
+        }else{
+          p->rc = SQLITE_DONE;
+        }
+      }else if( p->rc==SQLITE_CORRUPT ){
+        p->rc = SQLITE_OK;
+        p->zMessage = intckMprintf(p, "%s",
+            "corruption found while reading database schema"
+        );
+        p->bCorruptSchema = 1;
+      }
+    }
 
-  /* Formulate the EXPERT_REPORT_CANDIDATES text */
-  for(pEntry=p->hIdx.pFirst; pEntry; pEntry=pEntry->pNext){
-    p->zCandidates = idxAppendText(&rc, p->zCandidates, 
-        "%s;%s%s\n", pEntry->zVal, 
-        pEntry->zVal2 ? " -- stat1: " : "", pEntry->zVal2
-    );
+    if( p->pCheck ){
+      assert( p->rc==SQLITE_OK );
+      if( sqlite3_step(p->pCheck)==SQLITE_ROW ){
+        /* Normal case, do nothing. */
+      }else{
+        intckFinalize(p, p->pCheck);
+        p->pCheck = 0;
+        p->nKeyVal = 0;
+        if( p->rc==SQLITE_CORRUPT ){
+          p->rc = SQLITE_OK;
+          p->zMessage = intckMprintf(p, 
+              "corruption found while scanning database object %s", p->zObj
+          );
+        }
+      }
+    }
   }
 
-  /* Figure out which of the candidate indexes are preferred by the query
-  ** planner and report the results to the user.  */
-  if( rc==SQLITE_OK ){
-    rc = idxFindIndexes(p, pzErr);
-  }
+  return p->rc;
+}
 
-  if( rc==SQLITE_OK ){
-    p->bRun = 1;
+/*
+** Return a message describing the corruption encountered by the most recent
+** call to sqlite3_intck_step(), or NULL if no corruption was encountered.
+*/
+const char *sqlite3_intck_message(sqlite3_intck *p){
+  assert( p->pCheck==0 || p->zMessage==0 );
+  if( p->zMessage ){
+    return p->zMessage;
   }
-  return rc;
+  if( p->pCheck ){
+    return (const char*)sqlite3_column_text(p->pCheck, 0);
+  }
+  return 0;
 }
 
 /*
-** Return the total number of statements that have been added to this
-** sqlite3expert using sqlite3_expert_sql().
+** Return the error code and message.
 */
-int sqlite3_expert_count(sqlite3expert *p){
-  int nRet = 0;
-  if( p->pStatement ) nRet = p->pStatement->iId+1;
-  return nRet;
+int sqlite3_intck_error(sqlite3_intck *p, const char **pzErr){
+  if( pzErr ) *pzErr = p->zErr;
+  return (p->rc==SQLITE_DONE ? SQLITE_OK : p->rc);
 }
 
 /*
-** Return a component of the report.
+** Close any read transaction the integrity-check object is holding open
+** on the database.
 */
-const char *sqlite3_expert_report(sqlite3expert *p, int iStmt, int eReport){
-  const char *zRet = 0;
-  IdxStatement *pStmt;
-
-  if( p->bRun==0 ) return 0;
-  for(pStmt=p->pStatement; pStmt && pStmt->iId!=iStmt; pStmt=pStmt->pNext);
-  switch( eReport ){
-    case EXPERT_REPORT_SQL:
-      if( pStmt ) zRet = pStmt->zSql;
-      break;
-    case EXPERT_REPORT_INDEXES:
-      if( pStmt ) zRet = pStmt->zIdx;
-      break;
-    case EXPERT_REPORT_PLAN:
-      if( pStmt ) zRet = pStmt->zEQP;
-      break;
-    case EXPERT_REPORT_CANDIDATES:
-      zRet = p->zCandidates;
-      break;
+int sqlite3_intck_unlock(sqlite3_intck *p){
+  if( p->rc==SQLITE_OK && p->pCheck ){
+    assert( p->zKey==0 && p->nKeyVal>0 );
+    intckSaveKey(p);
+    intckFinalize(p, p->pCheck);
+    p->pCheck = 0;
   }
-  return zRet;
+  return p->rc;
 }
 
 /*
-** Free an sqlite3expert object.
+** Return the SQL statement used to check object zObj. Or, if zObj is 
+** NULL, the current SQL statement.
 */
-void sqlite3_expert_destroy(sqlite3expert *p){
-  if( p ){
-    sqlite3_close(p->dbm);
-    sqlite3_close(p->dbv);
-    idxScanFree(p->pScan, 0);
-    idxStatementFree(p->pStatement, 0);
-    idxTableFree(p->pTable);
-    idxWriteFree(p->pWrite);
-    idxHashClear(&p->hIdx);
-    sqlite3_free(p->zCandidates);
-    sqlite3_free(p);
+const char *sqlite3_intck_test_sql(sqlite3_intck *p, const char *zObj){
+  sqlite3_free(p->zTestSql);
+  if( zObj ){
+    p->zTestSql = intckCheckObjectSql(p, zObj, 0, 0);
+  }else{
+    if( p->zObj ){
+      p->zTestSql = intckCheckObjectSql(p, p->zObj, p->zKey, 0);
+    }else{
+      sqlite3_free(p->zTestSql);
+      p->zTestSql = 0;
+    }
   }
+  return p->zTestSql;
 }
 
-#endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */
-
-/************************* End ../ext/expert/sqlite3expert.c ********************/
+/************************* End ../ext/intck/sqlite3intck.c ********************/
 
 #if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB)
 #define SQLITE_SHELL_HAVE_RECOVER 1
@@ -14336,6 +15539,15 @@ int sqlite3_recover_finish(sqlite3_recover*);
 
 typedef struct DbdataTable DbdataTable;
 typedef struct DbdataCursor DbdataCursor;
+typedef struct DbdataBuffer DbdataBuffer;
+
+/*
+** Buffer type.
+*/
+struct DbdataBuffer {
+  u8 *aBuf;
+  sqlite3_int64 nBuf;
+};
 
 /* Cursor object */
 struct DbdataCursor {
@@ -14352,7 +15564,7 @@ struct DbdataCursor {
   sqlite3_int64 iRowid;
 
   /* Only for the sqlite_dbdata table */
-  u8 *pRec;                       /* Buffer containing current record */
+  DbdataBuffer rec;
   sqlite3_int64 nRec;             /* Size of pRec[] in bytes */
   sqlite3_int64 nHdr;             /* Size of header in bytes */
   int iField;                     /* Current field number */
@@ -14397,6 +15609,31 @@ struct DbdataTable {
       "  schema TEXT HIDDEN"      \
       ")"
 
+/*
+** Ensure the buffer passed as the first argument is at least nMin bytes
+** in size. If an error occurs while attempting to resize the buffer,
+** SQLITE_NOMEM is returned. Otherwise, SQLITE_OK.
+*/
+static int dbdataBufferSize(DbdataBuffer *pBuf, sqlite3_int64 nMin){
+  if( nMin>pBuf->nBuf ){
+    sqlite3_int64 nNew = nMin+16384;
+    u8 *aNew = (u8*)sqlite3_realloc64(pBuf->aBuf, nNew);
+
+    if( aNew==0 ) return SQLITE_NOMEM;
+    pBuf->aBuf = aNew;
+    pBuf->nBuf = nNew;
+  }
+  return SQLITE_OK;
+}
+
+/*
+** Release the allocation managed by buffer pBuf.
+*/
+static void dbdataBufferFree(DbdataBuffer *pBuf){
+  sqlite3_free(pBuf->aBuf);
+  memset(pBuf, 0, sizeof(*pBuf));
+}
+
 /*
 ** Connect to an sqlite_dbdata (pAux==0) or sqlite_dbptr (pAux!=0) virtual 
 ** table.
@@ -14537,9 +15774,9 @@ static void dbdataResetCursor(DbdataCursor *pCsr){
   pCsr->iField = 0;
   pCsr->bOnePage = 0;
   sqlite3_free(pCsr->aPage);
-  sqlite3_free(pCsr->pRec);
-  pCsr->pRec = 0;
+  dbdataBufferFree(&pCsr->rec);
   pCsr->aPage = 0;
+  pCsr->nRec = 0;
 }
 
 /*
@@ -14681,67 +15918,88 @@ static void dbdataValue(
   u8 *pData,
   sqlite3_int64 nData
 ){
-  if( eType>=0 && dbdataValueBytes(eType)<=nData ){
-    switch( eType ){
-      case 0: 
-      case 10: 
-      case 11: 
-        sqlite3_result_null(pCtx);
-        break;
-      
-      case 8: 
-        sqlite3_result_int(pCtx, 0);
-        break;
-      case 9:
-        sqlite3_result_int(pCtx, 1);
-        break;
-  
-      case 1: case 2: case 3: case 4: case 5: case 6: case 7: {
-        sqlite3_uint64 v = (signed char)pData[0];
-        pData++;
-        switch( eType ){
-          case 7:
-          case 6:  v = (v<<16) + (pData[0]<<8) + pData[1];  pData += 2;
-          case 5:  v = (v<<16) + (pData[0]<<8) + pData[1];  pData += 2;
-          case 4:  v = (v<<8) + pData[0];  pData++;
-          case 3:  v = (v<<8) + pData[0];  pData++;
-          case 2:  v = (v<<8) + pData[0];  pData++;
-        }
-  
-        if( eType==7 ){
-          double r;
-          memcpy(&r, &v, sizeof(r));
-          sqlite3_result_double(pCtx, r);
-        }else{
-          sqlite3_result_int64(pCtx, (sqlite3_int64)v);
+  if( eType>=0 ){
+    if( dbdataValueBytes(eType)<=nData ){
+      switch( eType ){
+        case 0: 
+        case 10: 
+        case 11: 
+          sqlite3_result_null(pCtx);
+          break;
+        
+        case 8: 
+          sqlite3_result_int(pCtx, 0);
+          break;
+        case 9:
+          sqlite3_result_int(pCtx, 1);
+          break;
+    
+        case 1: case 2: case 3: case 4: case 5: case 6: case 7: {
+          sqlite3_uint64 v = (signed char)pData[0];
+          pData++;
+          switch( eType ){
+            case 7:
+            case 6:  v = (v<<16) + (pData[0]<<8) + pData[1];  pData += 2;
+            case 5:  v = (v<<16) + (pData[0]<<8) + pData[1];  pData += 2;
+            case 4:  v = (v<<8) + pData[0];  pData++;
+            case 3:  v = (v<<8) + pData[0];  pData++;
+            case 2:  v = (v<<8) + pData[0];  pData++;
+          }
+    
+          if( eType==7 ){
+            double r;
+            memcpy(&r, &v, sizeof(r));
+            sqlite3_result_double(pCtx, r);
+          }else{
+            sqlite3_result_int64(pCtx, (sqlite3_int64)v);
+          }
+          break;
         }
-        break;
-      }
-  
-      default: {
-        int n = ((eType-12) / 2);
-        if( eType % 2 ){
-          switch( enc ){
-#ifndef SQLITE_OMIT_UTF16
-            case SQLITE_UTF16BE:
-              sqlite3_result_text16be(pCtx, (void*)pData, n, SQLITE_TRANSIENT);
-              break;
-            case SQLITE_UTF16LE:
-              sqlite3_result_text16le(pCtx, (void*)pData, n, SQLITE_TRANSIENT);
-              break;
-#endif
-            default:
-              sqlite3_result_text(pCtx, (char*)pData, n, SQLITE_TRANSIENT);
-              break;
+    
+        default: {
+          int n = ((eType-12) / 2);
+          if( eType % 2 ){
+            switch( enc ){
+  #ifndef SQLITE_OMIT_UTF16
+              case SQLITE_UTF16BE:
+                sqlite3_result_text16be(pCtx, (void*)pData, n, SQLITE_TRANSIENT);
+                break;
+              case SQLITE_UTF16LE:
+                sqlite3_result_text16le(pCtx, (void*)pData, n, SQLITE_TRANSIENT);
+                break;
+  #endif
+              default:
+                sqlite3_result_text(pCtx, (char*)pData, n, SQLITE_TRANSIENT);
+                break;
+            }
+          }else{
+            sqlite3_result_blob(pCtx, pData, n, SQLITE_TRANSIENT);
           }
-        }else{
-          sqlite3_result_blob(pCtx, pData, n, SQLITE_TRANSIENT);
         }
       }
+    }else{
+      if( eType==7 ){
+        sqlite3_result_double(pCtx, 0.0);
+      }else if( eType<7 ){
+        sqlite3_result_int(pCtx, 0);
+      }else if( eType%2 ){
+        sqlite3_result_text(pCtx, "", 0, SQLITE_STATIC);
+      }else{
+        sqlite3_result_blob(pCtx, "", 0, SQLITE_STATIC);
+      }
     }
   }
 }
 
+/* This macro is a copy of the MX_CELL() macro in the SQLite core. Given
+** a page-size, it returns the maximum number of cells that may be present
+** on the page.  */
+#define DBDATA_MX_CELL(pgsz) ((pgsz-8)/6)
+
+/* Maximum number of fields that may appear in a single record. This is
+** the "hard-limit", according to comments in sqliteLimit.h. */
+#define DBDATA_MX_FIELD 32676
+
 /*
 ** Move an sqlite_dbdata or sqlite_dbptr cursor to the next entry.
 */
@@ -14770,6 +16028,9 @@ static int dbdataNext(sqlite3_vtab_cursor *pCursor){
       assert( iOff+3+2<=pCsr->nPage );
       pCsr->iCell = pTab->bPtr ? -2 : 0;
       pCsr->nCell = get_uint16(&pCsr->aPage[iOff+3]);
+      if( pCsr->nCell>DBDATA_MX_CELL(pCsr->nPage) ){
+        pCsr->nCell = DBDATA_MX_CELL(pCsr->nPage);
+      }
     }
 
     if( pTab->bPtr ){
@@ -14787,7 +16048,8 @@ static int dbdataNext(sqlite3_vtab_cursor *pCursor){
       }
     }else{
       /* If there is no record loaded, load it now. */
-      if( pCsr->pRec==0 ){
+      assert( pCsr->rec.aBuf!=0 || pCsr->nRec==0 );
+      if( pCsr->nRec==0 ){
         int bHasRowid = 0;
         int nPointer = 0;
         sqlite3_int64 nPayload = 0;
@@ -14814,23 +16076,24 @@ static int dbdataNext(sqlite3_vtab_cursor *pCursor){
         if( pCsr->iCell>=pCsr->nCell ){
           bNextPage = 1;
         }else{
+          int iCellPtr = iOff + 8 + nPointer + pCsr->iCell*2;
   
-          iOff += 8 + nPointer + pCsr->iCell*2;
-          if( iOff>pCsr->nPage ){
+          if( iCellPtr>pCsr->nPage ){
             bNextPage = 1;
           }else{
-            iOff = get_uint16(&pCsr->aPage[iOff]);
+            iOff = get_uint16(&pCsr->aPage[iCellPtr]);
           }
     
           /* For an interior node cell, skip past the child-page number */
           iOff += nPointer;
     
           /* Load the "byte of payload including overflow" field */
-          if( bNextPage || iOff>pCsr->nPage ){
+          if( bNextPage || iOff>pCsr->nPage || iOff<=iCellPtr ){
             bNextPage = 1;
           }else{
             iOff += dbdataGetVarintU32(&pCsr->aPage[iOff], &nPayload);
             if( nPayload>0x7fffff00 ) nPayload &= 0x3fff;
+            if( nPayload==0 ) nPayload = 1;
           }
     
           /* If this is a leaf intkey cell, load the rowid */
@@ -14865,13 +16128,12 @@ static int dbdataNext(sqlite3_vtab_cursor *pCursor){
             /* Allocate space for payload. And a bit more to catch small buffer
             ** overruns caused by attempting to read a varint or similar from 
             ** near the end of a corrupt record.  */
-            pCsr->pRec = (u8*)sqlite3_malloc64(nPayload+DBDATA_PADDING_BYTES);
-            if( pCsr->pRec==0 ) return SQLITE_NOMEM;
-            memset(pCsr->pRec, 0, nPayload+DBDATA_PADDING_BYTES);
-            pCsr->nRec = nPayload;
+            rc = dbdataBufferSize(&pCsr->rec, nPayload+DBDATA_PADDING_BYTES);
+            if( rc!=SQLITE_OK ) return rc;
+            assert( nPayload!=0 );
 
             /* Load the nLocal bytes of payload */
-            memcpy(pCsr->pRec, &pCsr->aPage[iOff], nLocal);
+            memcpy(pCsr->rec.aBuf, &pCsr->aPage[iOff], nLocal);
             iOff += nLocal;
 
             /* Load content from overflow pages */
@@ -14889,19 +16151,22 @@ static int dbdataNext(sqlite3_vtab_cursor *pCursor){
 
                 nCopy = U-4;
                 if( nCopy>nRem ) nCopy = nRem;
-                memcpy(&pCsr->pRec[nPayload-nRem], &aOvfl[4], nCopy);
+                memcpy(&pCsr->rec.aBuf[nPayload-nRem], &aOvfl[4], nCopy);
                 nRem -= nCopy;
 
                 pgnoOvfl = get_uint32(aOvfl);
                 sqlite3_free(aOvfl);
               }
+              nPayload -= nRem;
             }
+            memset(&pCsr->rec.aBuf[nPayload], 0, DBDATA_PADDING_BYTES);
+            pCsr->nRec = nPayload;
     
-            iHdr = dbdataGetVarintU32(pCsr->pRec, &nHdr);
+            iHdr = dbdataGetVarintU32(pCsr->rec.aBuf, &nHdr);
             if( nHdr>nPayload ) nHdr = 0;
             pCsr->nHdr = nHdr;
-            pCsr->pHdrPtr = &pCsr->pRec[iHdr];
-            pCsr->pPtr = &pCsr->pRec[pCsr->nHdr];
+            pCsr->pHdrPtr = &pCsr->rec.aBuf[iHdr];
+            pCsr->pPtr = &pCsr->rec.aBuf[pCsr->nHdr];
             pCsr->iField = (bHasRowid ? -1 : 0);
           }
         }
@@ -14909,14 +16174,16 @@ static int dbdataNext(sqlite3_vtab_cursor *pCursor){
         pCsr->iField++;
         if( pCsr->iField>0 ){
           sqlite3_int64 iType;
-          if( pCsr->pHdrPtr>&pCsr->pRec[pCsr->nRec] ){
+          if( pCsr->pHdrPtr>=&pCsr->rec.aBuf[pCsr->nRec] 
+           || pCsr->iField>=DBDATA_MX_FIELD
+          ){
             bNextPage = 1;
           }else{
             int szField = 0;
             pCsr->pHdrPtr += dbdataGetVarintU32(pCsr->pHdrPtr, &iType);
             szField = dbdataValueBytes(iType);
-            if( (pCsr->nRec - (pCsr->pPtr - pCsr->pRec))<szField ){
-              pCsr->pPtr = &pCsr->pRec[pCsr->nRec];
+            if( (pCsr->nRec - (pCsr->pPtr - pCsr->rec.aBuf))<szField ){
+              pCsr->pPtr = &pCsr->rec.aBuf[pCsr->nRec];
             }else{
               pCsr->pPtr += szField;
             }
@@ -14926,20 +16193,18 @@ static int dbdataNext(sqlite3_vtab_cursor *pCursor){
 
       if( bNextPage ){
         sqlite3_free(pCsr->aPage);
-        sqlite3_free(pCsr->pRec);
         pCsr->aPage = 0;
-        pCsr->pRec = 0;
+        pCsr->nRec = 0;
         if( pCsr->bOnePage ) return SQLITE_OK;
         pCsr->iPgno++;
       }else{
-        if( pCsr->iField<0 || pCsr->pHdrPtr<&pCsr->pRec[pCsr->nHdr] ){
+        if( pCsr->iField<0 || pCsr->pHdrPtr<&pCsr->rec.aBuf[pCsr->nHdr] ){
           return SQLITE_OK;
         }
 
         /* Advance to the next cell. The next iteration of the loop will load
         ** the record and so on. */
-        sqlite3_free(pCsr->pRec);
-        pCsr->pRec = 0;
+        pCsr->nRec = 0;
         pCsr->iCell++;
       }
     }
@@ -15129,12 +16394,12 @@ static int dbdataColumn(
       case DBDATA_COLUMN_VALUE: {
         if( pCsr->iField<0 ){
           sqlite3_result_int64(ctx, pCsr->iIntkey);
-        }else if( &pCsr->pRec[pCsr->nRec] >= pCsr->pPtr ){
+        }else if( &pCsr->rec.aBuf[pCsr->nRec] >= pCsr->pPtr ){
           sqlite3_int64 iType;
           dbdataGetVarintU32(pCsr->pHdrPtr, &iType);
           dbdataValue(
               ctx, pCsr->enc, iType, pCsr->pPtr, 
-              &pCsr->pRec[pCsr->nRec] - pCsr->pPtr
+              &pCsr->rec.aBuf[pCsr->nRec] - pCsr->pPtr
           );
         }
         break;
@@ -16397,7 +17662,7 @@ static int recoverWriteSchema1(sqlite3_recover *p){
         if( bTable && !bVirtual ){
           if( SQLITE_ROW==sqlite3_step(pTblname) ){
             const char *zTbl = (const char*)sqlite3_column_text(pTblname, 0);
-            recoverAddTable(p, zTbl, iRoot);
+            if( zTbl ) recoverAddTable(p, zTbl, iRoot);
           }
           recoverReset(p, pTblname);
         }
@@ -20619,6 +21884,7 @@ static void exec_prepared_stmt_columnar(
   rc = sqlite3_step(pStmt);
   if( rc!=SQLITE_ROW ) return;
   nColumn = sqlite3_column_count(pStmt);
+  if( nColumn==0 ) goto columnar_end;
   nAlloc = nColumn*4;
   if( nAlloc<=0 ) nAlloc = 1;
   azData = sqlite3_malloc64( nAlloc*sizeof(char*) );
@@ -20704,7 +21970,6 @@ static void exec_prepared_stmt_columnar(
     if( n>p->actualWidth[j] ) p->actualWidth[j] = n;
   }
   if( seenInterrupt ) goto columnar_end;
-  if( nColumn==0 ) goto columnar_end;
   switch( p->cMode ){
     case MODE_Column: {
       colSep = "  ";
@@ -21587,6 +22852,7 @@ static const char *(azHelp[]) = {
   ".indexes ?TABLE?         Show names of indexes",
   "                           If TABLE is specified, only show indexes for",
   "                           tables matching TABLE using the LIKE operator.",
+  ".intck ?STEPS_PER_UNLOCK?  Run an incremental integrity check on the db",
 #ifdef SQLITE_ENABLE_IOTRACE
   ",iotrace FILE            Enable I/O diagnostic logging to FILE",
 #endif
@@ -24496,6 +25762,40 @@ static int recoverDatabaseCmd(ShellState *pState, int nArg, char **azArg){
 }
 #endif /* SQLITE_SHELL_HAVE_RECOVER */
 
+/*
+** Implementation of ".intck STEPS_PER_UNLOCK" command.
+*/
+static int intckDatabaseCmd(ShellState *pState, i64 nStepPerUnlock){
+  sqlite3_intck *p = 0;
+  int rc = SQLITE_OK;
+
+  rc = sqlite3_intck_open(pState->db, "main", &p);
+  if( rc==SQLITE_OK ){
+    i64 nStep = 0;
+    i64 nError = 0;
+    const char *zErr = 0;
+    while( SQLITE_OK==sqlite3_intck_step(p) ){
+      const char *zMsg = sqlite3_intck_message(p);
+      if( zMsg ){
+        oputf("%s\n", zMsg);
+        nError++;
+      }
+      nStep++;
+      if( nStepPerUnlock && (nStep % nStepPerUnlock)==0 ){
+        sqlite3_intck_unlock(p);
+      }
+    }
+    rc = sqlite3_intck_error(p, &zErr);
+    if( zErr ){
+      eputf("%s\n", zErr);
+    }
+    sqlite3_intck_close(p);
+
+    oputf("%lld steps, %lld errors\n", nStep, nError);
+  }
+
+  return rc;
+}
 
 /*
  * zAutoColumn(zCol, &db, ?) => Maybe init db, add column zCol to it.
@@ -24739,6 +26039,45 @@ static int outputDumpWarning(ShellState *p, const char *zLike){
   return rc;
 }
 
+/*
+** Fault-Simulator state and logic.
+*/
+static struct {
+  int iId;           /* ID that triggers a simulated fault.  -1 means "any" */
+  int iErr;          /* The error code to return on a fault */
+  int iCnt;          /* Trigger the fault only if iCnt is already zero */
+  int iInterval;     /* Reset iCnt to this value after each fault */
+  int eVerbose;      /* When to print output */
+  int nHit;          /* Number of hits seen so far */
+  int nRepeat;       /* Turn off after this many hits.  0 for never */
+  int nSkip;         /* Skip this many before first fault */
+} faultsim_state = {-1, 0, 0, 0, 0, 0, 0, 0};
+
+/*
+** This is the fault-sim callback
+*/
+static int faultsim_callback(int iArg){
+  if( faultsim_state.iId>0 && faultsim_state.iId!=iArg ){
+    return SQLITE_OK;
+  }
+  if( faultsim_state.iCnt ){
+    if( faultsim_state.iCnt>0 ) faultsim_state.iCnt--;
+    if( faultsim_state.eVerbose>=2 ){
+      oputf("FAULT-SIM id=%d no-fault (cnt=%d)\n", iArg, faultsim_state.iCnt);
+    }
+    return SQLITE_OK;
+  }
+  if( faultsim_state.eVerbose>=1 ){
+    oputf("FAULT-SIM id=%d returns %d\n", iArg, faultsim_state.iErr);
+  }
+  faultsim_state.iCnt = faultsim_state.iInterval;
+  faultsim_state.nHit++;
+  if( faultsim_state.nRepeat>0 && faultsim_state.nRepeat<=faultsim_state.nHit ){
+    faultsim_state.iCnt = -1;
+  }
+  return faultsim_state.iErr;
+}
+
 /*
 ** If an input line begins with "." then invoke this routine to
 ** process that line.
@@ -25230,7 +26569,8 @@ static int do_meta_command(char *zLine, ShellState *p){
       zSql = sqlite3_mprintf(
         "SELECT sql FROM sqlite_schema AS o "
         "WHERE (%s) AND sql NOT NULL"
-        "  AND type IN ('index','trigger','view')",
+        "  AND type IN ('index','trigger','view') "
+        "ORDER BY type COLLATE NOCASE DESC",
         zLike
       );
       run_table_dump_query(p, zSql);
@@ -25553,16 +26893,15 @@ static int do_meta_command(char *zLine, ShellState *p){
 #ifndef SQLITE_SHELL_FIDDLE
   if( c=='i' && cli_strncmp(azArg[0], "import", n)==0 ){
     char *zTable = 0;           /* Insert data into this table */
-    char *zSchema = 0;          /* within this schema (may default to "main") */
+    char *zSchema = 0;          /* Schema of zTable */
     char *zFile = 0;            /* Name of file to extra content from */
     sqlite3_stmt *pStmt = NULL; /* A statement */
     int nCol;                   /* Number of columns in the table */
-    int nByte;                  /* Number of bytes in an SQL string */
+    i64 nByte;                  /* Number of bytes in an SQL string */
     int i, j;                   /* Loop counters */
     int needCommit;             /* True to COMMIT or ROLLBACK at end */
     int nSep;                   /* Number of bytes in p->colSeparator[] */
-    char *zSql;                 /* An SQL statement */
-    char *zFullTabName;         /* Table name with schema if applicable */
+    char *zSql = 0;             /* An SQL statement */
     ImportCtx sCtx;             /* Reader context */
     char *(SQLITE_CDECL *xRead)(ImportCtx*); /* Func to read one value */
     int eVerbose = 0;           /* Larger for more console output */
@@ -25696,24 +27035,14 @@ static int do_meta_command(char *zLine, ShellState *p){
     while( (nSkip--)>0 ){
       while( xRead(&sCtx) && sCtx.cTerm==sCtx.cColSep ){}
     }
-    if( zSchema!=0 ){
-      zFullTabName = sqlite3_mprintf("\"%w\".\"%w\"", zSchema, zTable);
-    }else{
-      zFullTabName = sqlite3_mprintf("\"%w\"", zTable);
-    }
-    zSql = sqlite3_mprintf("SELECT * FROM %s", zFullTabName);
-    if( zSql==0 || zFullTabName==0 ){
-      import_cleanup(&sCtx);
-      shell_out_of_memory();
-    }
-    nByte = strlen30(zSql);
-    rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
     import_append_char(&sCtx, 0);    /* To ensure sCtx.z is allocated */
-    if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(p->db))==0 ){
+    if( sqlite3_table_column_metadata(p->db, zSchema, zTable,0,0,0,0,0,0) ){
+      /* Table does not exist.  Create it. */
       sqlite3 *dbCols = 0;
       char *zRenames = 0;
       char *zColDefs;
-      zCreate = sqlite3_mprintf("CREATE TABLE %s", zFullTabName);
+      zCreate = sqlite3_mprintf("CREATE TABLE \"%w\".\"%w\"", 
+                    zSchema ? zSchema : "main", zTable);
       while( xRead(&sCtx) ){
         zAutoColumn(sCtx.z, &dbCols, 0);
         if( sCtx.cTerm!=sCtx.cColSep ) break;
@@ -25728,34 +27057,50 @@ static int do_meta_command(char *zLine, ShellState *p){
       assert(dbCols==0);
       if( zColDefs==0 ){
         eputf("%s: empty file\n", sCtx.zFile);
-      import_fail:
-        sqlite3_free(zCreate);
-        sqlite3_free(zSql);
-        sqlite3_free(zFullTabName);
         import_cleanup(&sCtx);
         rc = 1;
         goto meta_command_exit;
       }
       zCreate = sqlite3_mprintf("%z%z\n", zCreate, zColDefs);
+      if( zCreate==0 ){
+        import_cleanup(&sCtx);
+        shell_out_of_memory();
+      }
       if( eVerbose>=1 ){
         oputf("%s\n", zCreate);
       }
       rc = sqlite3_exec(p->db, zCreate, 0, 0, 0);
+      sqlite3_free(zCreate);
+      zCreate = 0;
       if( rc ){
         eputf("%s failed:\n%s\n", zCreate, sqlite3_errmsg(p->db));
-        goto import_fail;
+        import_cleanup(&sCtx);
+        rc = 1;
+        goto meta_command_exit;
       }
-      sqlite3_free(zCreate);
-      zCreate = 0;
-      rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
     }
+    zSql = sqlite3_mprintf("SELECT count(*) FROM pragma_table_info(%Q,%Q);",
+                           zTable, zSchema);
+    if( zSql==0 ){
+      import_cleanup(&sCtx);
+      shell_out_of_memory();
+    }
+    nByte = strlen(zSql);    
+    rc =  sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
+    sqlite3_free(zSql);
+    zSql = 0;
     if( rc ){
       if (pStmt) sqlite3_finalize(pStmt);
       eputf("Error: %s\n", sqlite3_errmsg(p->db));
-      goto import_fail;
+      import_cleanup(&sCtx);
+      rc = 1;
+      goto meta_command_exit;
+    }
+    if( sqlite3_step(pStmt)==SQLITE_ROW ){
+      nCol = sqlite3_column_int(pStmt, 0);
+    }else{
+      nCol = 0;
     }
-    sqlite3_free(zSql);
-    nCol = sqlite3_column_count(pStmt);
     sqlite3_finalize(pStmt);
     pStmt = 0;
     if( nCol==0 ) return 0; /* no columns, no error */
@@ -25764,7 +27109,12 @@ static int do_meta_command(char *zLine, ShellState *p){
       import_cleanup(&sCtx);
       shell_out_of_memory();
     }
-    sqlite3_snprintf(nByte+20, zSql, "INSERT INTO %s VALUES(?", zFullTabName);
+    if( zSchema ){
+      sqlite3_snprintf(nByte+20, zSql, "INSERT INTO \"%w\".\"%w\" VALUES(?", 
+                       zSchema, zTable);
+    }else{
+      sqlite3_snprintf(nByte+20, zSql, "INSERT INTO \"%w\" VALUES(?", zTable);
+    }
     j = strlen30(zSql);
     for(i=1; i<nCol; i++){
       zSql[j++] = ',';
@@ -25776,13 +27126,15 @@ static int do_meta_command(char *zLine, ShellState *p){
       oputf("Insert using: %s\n", zSql);
     }
     rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
+    sqlite3_free(zSql);
+    zSql = 0;
     if( rc ){
       eputf("Error: %s\n", sqlite3_errmsg(p->db));
       if (pStmt) sqlite3_finalize(pStmt);
-      goto import_fail;
+      import_cleanup(&sCtx);
+      rc = 1;
+      goto meta_command_exit;
     }
-    sqlite3_free(zSql);
-    sqlite3_free(zFullTabName);
     needCommit = sqlite3_get_autocommit(p->db);
     if( needCommit ) sqlite3_exec(p->db, "BEGIN", 0, 0, 0);
     do{
@@ -25953,6 +27305,21 @@ static int do_meta_command(char *zLine, ShellState *p){
   }else
 #endif /* !defined(SQLITE_OMIT_TEST_CONTROL) */
 
+  if( c=='i' && cli_strncmp(azArg[0], "intck", n)==0 ){
+    i64 iArg = 0;
+    if( nArg==2 ){
+      iArg = integerValue(azArg[1]);
+      if( iArg==0 ) iArg = -1;
+    }
+    if( (nArg!=1 && nArg!=2) || iArg<0 ){
+      eputf("%s","Usage: .intck STEPS_PER_UNLOCK\n");
+      rc = 1;
+      goto meta_command_exit;
+    }
+    open_db(p, 0);
+    rc = intckDatabaseCmd(p, iArg);
+  }else
+
 #ifdef SQLITE_ENABLE_IOTRACE
   if( c=='i' && cli_strncmp(azArg[0], "iotrace", n)==0 ){
     SQLITE_API extern void (SQLITE_CDECL *sqlite3IoTrace)(const char*, ...);
@@ -27626,7 +28993,7 @@ static int do_meta_command(char *zLine, ShellState *p){
   /*{"bitvec_test",        SQLITE_TESTCTRL_BITVEC_TEST, 1,  ""              },*/
     {"byteorder",          SQLITE_TESTCTRL_BYTEORDER, 0,  ""                },
     {"extra_schema_checks",SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS,0,"BOOLEAN"  },
-  /*{"fault_install",      SQLITE_TESTCTRL_FAULT_INSTALL, 1,""              },*/
+    {"fault_install",      SQLITE_TESTCTRL_FAULT_INSTALL, 1,"args..."       },
     {"fk_no_action",       SQLITE_TESTCTRL_FK_NO_ACTION, 0, "BOOLEAN"       },
     {"imposter",         SQLITE_TESTCTRL_IMPOSTER,1,"SCHEMA ON/OFF ROOTPAGE"},
     {"internal_functions", SQLITE_TESTCTRL_INTERNAL_FUNCTIONS,0,""          },
@@ -27859,6 +29226,76 @@ static int do_meta_command(char *zLine, ShellState *p){
           }
           sqlite3_test_control(testctrl, &rc2);
           break;
+        case SQLITE_TESTCTRL_FAULT_INSTALL: {
+          int kk;
+          int bShowHelp = nArg<=2;
+          isOk = 3;
+          for(kk=2; kk<nArg; kk++){
+            const char *z = azArg[kk];
+            if( z[0]=='-' && z[1]=='-' ) z++;
+            if( cli_strcmp(z,"off")==0 ){
+              sqlite3_test_control(testctrl, 0);
+            }else if( cli_strcmp(z,"on")==0 ){
+              faultsim_state.iCnt = faultsim_state.nSkip;
+              if( faultsim_state.iErr==0 ) faultsim_state.iErr = 1;
+              faultsim_state.nHit = 0;
+              sqlite3_test_control(testctrl, faultsim_callback);
+            }else if( cli_strcmp(z,"reset")==0 ){
+              faultsim_state.iCnt = faultsim_state.nSkip;
+              faultsim_state.nHit = 0;
+              sqlite3_test_control(testctrl, faultsim_callback);
+            }else if( cli_strcmp(z,"status")==0 ){
+              oputf("faultsim.iId:       %d\n", faultsim_state.iId);
+              oputf("faultsim.iErr:      %d\n", faultsim_state.iErr);
+              oputf("faultsim.iCnt:      %d\n", faultsim_state.iCnt);
+              oputf("faultsim.nHit:      %d\n", faultsim_state.nHit);
+              oputf("faultsim.iInterval: %d\n", faultsim_state.iInterval);
+              oputf("faultsim.eVerbose:  %d\n", faultsim_state.eVerbose);
+              oputf("faultsim.nRepeat:   %d\n", faultsim_state.nRepeat);
+              oputf("faultsim.nSkip:     %d\n", faultsim_state.nSkip);
+            }else if( cli_strcmp(z,"-v")==0 ){
+              if( faultsim_state.eVerbose<2 ) faultsim_state.eVerbose++;
+            }else if( cli_strcmp(z,"-q")==0 ){
+              if( faultsim_state.eVerbose>0 ) faultsim_state.eVerbose--;
+            }else if( cli_strcmp(z,"-id")==0 && kk+1<nArg ){
+              faultsim_state.iId = atoi(azArg[++kk]);
+            }else if( cli_strcmp(z,"-errcode")==0 && kk+1<nArg ){
+              faultsim_state.iErr = atoi(azArg[++kk]);
+            }else if( cli_strcmp(z,"-interval")==0 && kk+1<nArg ){
+              faultsim_state.iInterval = atoi(azArg[++kk]);
+            }else if( cli_strcmp(z,"-repeat")==0 && kk+1<nArg ){
+              faultsim_state.nRepeat = atoi(azArg[++kk]);
+           }else if( cli_strcmp(z,"-skip")==0 && kk+1<nArg ){
+              faultsim_state.nSkip = atoi(azArg[++kk]);
+            }else if( cli_strcmp(z,"-?")==0 || sqlite3_strglob("*help*",z)==0){
+              bShowHelp = 1;
+            }else{
+              eputf("Unrecognized fault_install argument: \"%s\"\n",
+                  azArg[kk]);
+              rc = 1;
+              bShowHelp = 1;
+              break;
+            }
+          }
+          if( bShowHelp ){
+            oputz(
+               "Usage: .testctrl fault_install ARGS\n"
+               "Possible arguments:\n"
+               "   off               Disable faultsim\n"
+               "   on                Activate faultsim\n"
+               "   reset             Reset the trigger counter\n"
+               "   status            Show current status\n"
+               "   -v                Increase verbosity\n"
+               "   -q                Decrease verbosity\n"
+               "   --errcode N       When triggered, return N as error code\n"
+               "   --id ID           Trigger only for the ID specified\n"
+               "   --interval N      Trigger only after every N-th call\n"
+               "   --repeat N        Turn off after N hits.  0 means never\n"
+               "   --skip N          Skip the first N encounters\n"
+            );
+          }
+          break;
+        }
       }
     }
     if( isOk==0 && iCtrl>=0 ){
@@ -28748,6 +30185,7 @@ static const char zOptions[] =
   "   -newline SEP         set output row separator. Default: '\\n'\n"
   "   -nofollow            refuse to open symbolic links to database files\n"
   "   -nonce STRING        set the safe-mode escape nonce\n"
+  "   -no-rowid-in-view    Disable rowid-in-view using sqlite3_config()\n"
   "   -nullvalue TEXT      set text string for NULL values. Default ''\n"
   "   -pagecache SIZE N    use N slots of SZ bytes each for page cache memory\n"
   "   -pcachetrace         trace all page cache operations\n"
@@ -28780,7 +30218,7 @@ static void usage(int showDetail){
   }else{
     eputz("Use the -help option for additional information\n");
   }
-  exit(1);
+  exit(0);
 }
 
 /*
@@ -29038,6 +30476,10 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
       stdin_is_interactive = 0;
     }else if( cli_strcmp(z,"-utf8")==0 ){
     }else if( cli_strcmp(z,"-no-utf8")==0 ){
+    }else if( cli_strcmp(z,"-no-rowid-in-view")==0 ){
+      int val = 0;
+      sqlite3_config(SQLITE_CONFIG_ROWID_IN_VIEW, &val);
+      assert( val==0 );
     }else if( cli_strcmp(z,"-heap")==0 ){
 #if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5)
       const char *zSize;
@@ -29313,6 +30755,8 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
       /* already handled */
     }else if( cli_strcmp(z,"-no-utf8")==0 ){
       /* already handled */
+    }else if( cli_strcmp(z,"-no-rowid-in-view")==0 ){
+      /* already handled */
     }else if( cli_strcmp(z,"-heap")==0 ){
       i++;
     }else if( cli_strcmp(z,"-pagecache")==0 ){
@@ -29474,6 +30918,11 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
 #ifndef SQLITE_SHELL_FIDDLE
   /* In WASM mode we have to leave the db state in place so that
   ** client code can "push" SQL into it after this call returns. */
+#ifndef SQLITE_OMIT_VIRTUALTABLE
+  if( data.expert.pExpert ){
+    expertFinish(&data, 1, 0);
+  }
+#endif
   free(azCmd);
   set_table_name(&data, 0);
   if( data.db ){
@@ -29540,7 +30989,7 @@ sqlite3_vfs * fiddle_db_vfs(const char *zDbName){
 
 /* Only for emcc experimentation purposes. */
 sqlite3 * fiddle_db_arg(sqlite3 *arg){
-    printf("fiddle_db_arg(%p)\n", (const void*)arg);
+    oputf("fiddle_db_arg(%p)\n", (const void*)arg);
     return arg;
 }
 
@@ -29566,12 +31015,22 @@ const char * fiddle_db_filename(const char * zDbName){
 
 /*
 ** Completely wipes out the contents of the currently-opened database
-** but leaves its storage intact for reuse.
+** but leaves its storage intact for reuse. If any transactions are
+** active, they are forcibly rolled back.
 */
 void fiddle_reset_db(void){
   if( globalDb ){
-    int rc = sqlite3_db_config(globalDb, SQLITE_DBCONFIG_RESET_DATABASE, 1, 0);
-    if( 0==rc ) rc = sqlite3_exec(globalDb, "VACUUM", 0, 0, 0);
+    int rc;
+    while( sqlite3_txn_state(globalDb,0)>0 ){
+      /*
+      ** Resolve problem reported in
+      ** https://sqlite.org/forum/forumpost/0b41a25d65
+      */
+      oputz("Rolling back in-progress transaction.\n");
+      sqlite3_exec(globalDb,"ROLLBACK", 0, 0, 0);
+    }
+    rc = sqlite3_db_config(globalDb, SQLITE_DBCONFIG_RESET_DATABASE, 1, 0);
+    if( 0==rc ) sqlite3_exec(globalDb, "VACUUM", 0, 0, 0);
     sqlite3_db_config(globalDb, SQLITE_DBCONFIG_RESET_DATABASE, 0, 0);
   }
 }
diff --git a/contrib/sqlite3/sqlite3.c b/contrib/sqlite3/sqlite3.c
index 139ee46a6a94..eaa24a131073 100644
--- a/contrib/sqlite3/sqlite3.c
+++ b/contrib/sqlite3/sqlite3.c
@@ -1,6 +1,6 @@
 /******************************************************************************
 ** This file is an amalgamation of many separate C source files from SQLite
-** version 3.45.1.  By combining all the individual C code files into this
+** version 3.46.0.  By combining all the individual C code files into this
 ** single large file, the entire code can be compiled as a single translation
 ** unit.  This allows many compilers to do optimizations that would not be
 ** possible if the files were compiled separately.  Performance improvements
@@ -18,7 +18,7 @@
 ** separate file. This file contains only code for the core SQLite library.
 **
 ** The content in this amalgamation comes from Fossil check-in
-** e876e51a0ed5c5b3126f52e532044363a014.
+** 96c92aba00c8375bc32fafcdf12429c58bd8.
 */
 #define SQLITE_CORE 1
 #define SQLITE_AMALGAMATION 1
@@ -459,9 +459,9 @@ extern "C" {
 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
 ** [sqlite_version()] and [sqlite_source_id()].
 */
-#define SQLITE_VERSION        "3.45.1"
-#define SQLITE_VERSION_NUMBER 3045001
-#define SQLITE_SOURCE_ID      "2024-01-30 16:01:20 e876e51a0ed5c5b3126f52e532044363a014bc594cfefa87ffb5b82257cc467a"
+#define SQLITE_VERSION        "3.46.0"
+#define SQLITE_VERSION_NUMBER 3046000
+#define SQLITE_SOURCE_ID      "2024-05-23 13:25:27 96c92aba00c8375bc32fafcdf12429c58bd8aabfcadab6683e35bbb9cdebf19e"
 
 /*
 ** CAPI3REF: Run-Time Library Version Numbers
@@ -733,6 +733,8 @@ typedef int (*sqlite3_callback)(void*,int,char**, char**);
 **      the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
 ** <li> The application must not modify the SQL statement text passed into
 **      the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
+** <li> The application must not dereference the arrays or string pointers
+**       passed as the 3rd and 4th callback parameters after it returns.
 ** </ul>
 */
 SQLITE_API int sqlite3_exec(
@@ -1075,11 +1077,11 @@ struct sqlite3_file {
 ** </ul>
 ** xLock() upgrades the database file lock.  In other words, xLock() moves the
 ** database file lock in the direction NONE toward EXCLUSIVE. The argument to
-** xLock() is always on of SHARED, RESERVED, PENDING, or EXCLUSIVE, never
+** xLock() is always one of SHARED, RESERVED, PENDING, or EXCLUSIVE, never
 ** SQLITE_LOCK_NONE.  If the database file lock is already at or above the
 ** requested lock, then the call to xLock() is a no-op.
 ** xUnlock() downgrades the database file lock to either SHARED or NONE.
-*  If the lock is already at or below the requested lock state, then the call
+** If the lock is already at or below the requested lock state, then the call
 ** to xUnlock() is a no-op.
 ** The xCheckReservedLock() method checks whether any database connection,
 ** either in this process or in some other process, is holding a RESERVED,
@@ -2454,6 +2456,22 @@ struct sqlite3_mem_methods {
 ** configuration setting is never used, then the default maximum is determined
 ** by the [SQLITE_MEMDB_DEFAULT_MAXSIZE] compile-time option.  If that
 ** compile-time option is not set, then the default maximum is 1073741824.
+**
+** [[SQLITE_CONFIG_ROWID_IN_VIEW]]
+** <dt>SQLITE_CONFIG_ROWID_IN_VIEW
+** <dd>The SQLITE_CONFIG_ROWID_IN_VIEW option enables or disables the ability
+** for VIEWs to have a ROWID.  The capability can only be enabled if SQLite is
+** compiled with -DSQLITE_ALLOW_ROWID_IN_VIEW, in which case the capability
+** defaults to on.  This configuration option queries the current setting or
+** changes the setting to off or on.  The argument is a pointer to an integer.
+** If that integer initially holds a value of 1, then the ability for VIEWs to
+** have ROWIDs is activated.  If the integer initially holds zero, then the
+** ability is deactivated.  Any other initial value for the integer leaves the
+** setting unchanged.  After changes, if any, the integer is written with
+** a 1 or 0, if the ability for VIEWs to have ROWIDs is on or off.  If SQLite
+** is compiled without -DSQLITE_ALLOW_ROWID_IN_VIEW (which is the usual and
+** recommended case) then the integer is always filled with zero, regardless
+** if its initial value.
 ** </dl>
 */
 #define SQLITE_CONFIG_SINGLETHREAD         1  /* nil */
@@ -2485,6 +2503,7 @@ struct sqlite3_mem_methods {
 #define SQLITE_CONFIG_SMALL_MALLOC        27  /* boolean */
 #define SQLITE_CONFIG_SORTERREF_SIZE      28  /* int nByte */
 #define SQLITE_CONFIG_MEMDB_MAXSIZE       29  /* sqlite3_int64 */
+#define SQLITE_CONFIG_ROWID_IN_VIEW       30  /* int* */
 
 /*
 ** CAPI3REF: Database Connection Configuration Options
@@ -3599,8 +3618,8 @@ SQLITE_API int sqlite3_set_authorizer(
 #define SQLITE_RECURSIVE            33   /* NULL            NULL            */
 
 /*
-** CAPI3REF: Tracing And Profiling Functions
-** METHOD: sqlite3
+** CAPI3REF: Deprecated Tracing And Profiling Functions
+** DEPRECATED
 **
 ** These routines are deprecated. Use the [sqlite3_trace_v2()] interface
 ** instead of the routines described here.
@@ -7181,6 +7200,12 @@ SQLITE_API int sqlite3_autovacuum_pages(
 ** The exceptions defined in this paragraph might change in a future
 ** release of SQLite.
 **
+** Whether the update hook is invoked before or after the
+** corresponding change is currently unspecified and may differ
+** depending on the type of change. Do not rely on the order of the
+** hook call with regards to the final result of the operation which
+** triggers the hook.
+**
 ** The update hook implementation must not do anything that will modify
 ** the database connection that invoked the update hook.  Any actions
 ** to modify the database connection must be deferred until after the
@@ -8651,7 +8676,7 @@ SQLITE_API int sqlite3_test_control(int op, ...);
 ** The sqlite3_keyword_count() interface returns the number of distinct
 ** keywords understood by SQLite.
 **
-** The sqlite3_keyword_name(N,Z,L) interface finds the N-th keyword and
+** The sqlite3_keyword_name(N,Z,L) interface finds the 0-based N-th keyword and
 ** makes *Z point to that keyword expressed as UTF8 and writes the number
 ** of bytes in the keyword into *L.  The string that *Z points to is not
 ** zero-terminated.  The sqlite3_keyword_name(N,Z,L) routine returns
@@ -10230,24 +10255,45 @@ SQLITE_API const char *sqlite3_vtab_collation(sqlite3_index_info*,int);
 ** <li value="2"><p>
 ** ^(If the sqlite3_vtab_distinct() interface returns 2, that means
 ** that the query planner does not need the rows returned in any particular
-** order, as long as rows with the same values in all "aOrderBy" columns
-** are adjacent.)^  ^(Furthermore, only a single row for each particular
-** combination of values in the columns identified by the "aOrderBy" field
-** needs to be returned.)^  ^It is always ok for two or more rows with the same
-** values in all "aOrderBy" columns to be returned, as long as all such rows
-** are adjacent.  ^The virtual table may, if it chooses, omit extra rows
-** that have the same value for all columns identified by "aOrderBy".
-** ^However omitting the extra rows is optional.
+** order, as long as rows with the same values in all columns identified
+** by "aOrderBy" are adjacent.)^  ^(Furthermore, when two or more rows
+** contain the same values for all columns identified by "colUsed", all but
+** one such row may optionally be omitted from the result.)^
+** The virtual table is not required to omit rows that are duplicates
+** over the "colUsed" columns, but if the virtual table can do that without
+** too much extra effort, it could potentially help the query to run faster.
 ** This mode is used for a DISTINCT query.
 ** <li value="3"><p>
-** ^(If the sqlite3_vtab_distinct() interface returns 3, that means
-** that the query planner needs only distinct rows but it does need the
-** rows to be sorted.)^ ^The virtual table implementation is free to omit
-** rows that are identical in all aOrderBy columns, if it wants to, but
-** it is not required to omit any rows.  This mode is used for queries
+** ^(If the sqlite3_vtab_distinct() interface returns 3, that means the
+** virtual table must return rows in the order defined by "aOrderBy" as
+** if the sqlite3_vtab_distinct() interface had returned 0.  However if
+** two or more rows in the result have the same values for all columns
+** identified by "colUsed", then all but one such row may optionally be
+** omitted.)^  Like when the return value is 2, the virtual table
+** is not required to omit rows that are duplicates over the "colUsed"
+** columns, but if the virtual table can do that without
+** too much extra effort, it could potentially help the query to run faster.
+** This mode is used for queries
 ** that have both DISTINCT and ORDER BY clauses.
 ** </ol>
 **
+** <p>The following table summarizes the conditions under which the
+** virtual table is allowed to set the "orderByConsumed" flag based on
+** the value returned by sqlite3_vtab_distinct().  This table is a
+** restatement of the previous four paragraphs:
+**
+** <table border=1 cellspacing=0 cellpadding=10 width="90%">
+** <tr>
+** <td valign="top">sqlite3_vtab_distinct() return value
+** <td valign="top">Rows are returned in aOrderBy order
+** <td valign="top">Rows with the same value in all aOrderBy columns are adjacent
+** <td valign="top">Duplicates over all colUsed columns may be omitted
+** <tr><td>0<td>yes<td>yes<td>no
+** <tr><td>1<td>no<td>yes<td>no
+** <tr><td>2<td>no<td>yes<td>yes
+** <tr><td>3<td>yes<td>yes<td>yes
+** </table>
+**
 ** ^For the purposes of comparing virtual table output values to see if the
 ** values are same value for sorting purposes, two NULL values are considered
 ** to be the same.  In other words, the comparison operator is "IS"
@@ -12292,6 +12338,30 @@ SQLITE_API int sqlite3changegroup_schema(sqlite3_changegroup*, sqlite3*, const c
 */
 SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData);
 
+/*
+** CAPI3REF: Add A Single Change To A Changegroup
+** METHOD: sqlite3_changegroup
+**
+** This function adds the single change currently indicated by the iterator
+** passed as the second argument to the changegroup object. The rules for
+** adding the change are just as described for [sqlite3changegroup_add()].
+**
+** If the change is successfully added to the changegroup, SQLITE_OK is
+** returned. Otherwise, an SQLite error code is returned.
+**
+** The iterator must point to a valid entry when this function is called.
+** If it does not, SQLITE_ERROR is returned and no change is added to the
+** changegroup. Additionally, the iterator must not have been opened with
+** the SQLITE_CHANGESETAPPLY_INVERT flag. In this case SQLITE_ERROR is also
+** returned.
+*/
+SQLITE_API int sqlite3changegroup_add_change(
+  sqlite3_changegroup*,
+  sqlite3_changeset_iter*
+);
+
+
+
 /*
 ** CAPI3REF: Obtain A Composite Changeset From A Changegroup
 ** METHOD: sqlite3_changegroup
@@ -13096,8 +13166,8 @@ struct Fts5PhraseIter {
 ** EXTENSION API FUNCTIONS
 **
 ** xUserData(pFts):
-**   Return a copy of the context pointer the extension function was
-**   registered with.
+**   Return a copy of the pUserData pointer passed to the xCreateFunction()
+**   API when the extension function was registered.
 **
 ** xColumnTotalSize(pFts, iCol, pnToken):
 **   If parameter iCol is less than zero, set output variable *pnToken
@@ -14295,6 +14365,8 @@ struct fts5_api {
 # define SQLITE_OMIT_ALTERTABLE
 #endif
 
+#define SQLITE_DIGIT_SEPARATOR '_'
+
 /*
 ** Return true (non-zero) if the input is an integer that is too large
 ** to fit in 32-bits.  This macro is used inside of various testcase()
@@ -14587,8 +14659,8 @@ SQLITE_PRIVATE void sqlite3HashClear(Hash*);
 #define TK_TRUEFALSE                      170
 #define TK_ISNOT                          171
 #define TK_FUNCTION                       172
-#define TK_UMINUS                         173
-#define TK_UPLUS                          174
+#define TK_UPLUS                          173
+#define TK_UMINUS                         174
 #define TK_TRUTH                          175
 #define TK_REGISTER                       176
 #define TK_VECTOR                         177
@@ -14597,8 +14669,9 @@ SQLITE_PRIVATE void sqlite3HashClear(Hash*);
 #define TK_ASTERISK                       180
 #define TK_SPAN                           181
 #define TK_ERROR                          182
-#define TK_SPACE                          183
-#define TK_ILLEGAL                        184
+#define TK_QNUMBER                        183
+#define TK_SPACE                          184
+#define TK_ILLEGAL                        185
 
 /************** End of parse.h ***********************************************/
 /************** Continuing where we left off in sqliteInt.h ******************/
@@ -14860,7 +14933,7 @@ typedef INT16_TYPE LogEst;
 #   define SQLITE_PTRSIZE __SIZEOF_POINTER__
 # elif defined(i386)     || defined(__i386__)   || defined(_M_IX86) ||    \
        defined(_M_ARM)   || defined(__arm__)    || defined(__x86)   ||    \
-      (defined(__APPLE__) && defined(__POWERPC__)) ||                     \
+      (defined(__APPLE__) && defined(__ppc__)) ||                         \
       (defined(__TOS_AIX__) && !defined(__64BIT__))
 #   define SQLITE_PTRSIZE 4
 # else
@@ -15097,6 +15170,7 @@ SQLITE_PRIVATE u32 sqlite3TreeTrace;
 **   0x00010000     Beginning of DELETE/INSERT/UPDATE processing
 **   0x00020000     Transform DISTINCT into GROUP BY
 **   0x00040000     SELECT tree dump after all code has been generated
+**   0x00080000     NOT NULL strength reduction
 */
 
 /*
@@ -15127,7 +15201,7 @@ SQLITE_PRIVATE u32 sqlite3WhereTrace;
 ** 0x00000010   Display sqlite3_index_info xBestIndex calls
 ** 0x00000020   Range an equality scan metrics
 ** 0x00000040   IN operator decisions
-** 0x00000080   WhereLoop cost adjustements
+** 0x00000080   WhereLoop cost adjustments
 ** 0x00000100
 ** 0x00000200   Covering index decisions
 ** 0x00000400   OR optimization
@@ -16276,6 +16350,7 @@ SQLITE_PRIVATE int sqlite3BtreeIntegrityCheck(
   sqlite3 *db,  /* Database connection that is running the check */
   Btree *p,     /* The btree to be checked */
   Pgno *aRoot,  /* An array of root pages numbers for individual trees */
+  sqlite3_value *aCnt,  /* OUT: entry counts for each btree in aRoot[] */
   int nRoot,    /* Number of entries in aRoot[] */
   int mxErr,    /* Stop reporting errors after this many */
   int *pnErr,   /* OUT: Write number of errors seen to this variable */
@@ -16546,12 +16621,12 @@ typedef struct VdbeOpList VdbeOpList;
 #define OP_Vacuum          5
 #define OP_VFilter         6 /* jump, synopsis: iplan=r[P3] zplan='P4'     */
 #define OP_VUpdate         7 /* synopsis: data=r[P3@P2]                    */
-#define OP_Init            8 /* jump, synopsis: Start at P2                */
+#define OP_Init            8 /* jump0, synopsis: Start at P2               */
 #define OP_Goto            9 /* jump                                       */
 #define OP_Gosub          10 /* jump                                       */
-#define OP_InitCoroutine  11 /* jump                                       */
-#define OP_Yield          12 /* jump                                       */
-#define OP_MustBeInt      13 /* jump                                       */
+#define OP_InitCoroutine  11 /* jump0                                      */
+#define OP_Yield          12 /* jump0                                      */
+#define OP_MustBeInt      13 /* jump0                                      */
 #define OP_Jump           14 /* jump                                       */
 #define OP_Once           15 /* jump                                       */
 #define OP_If             16 /* jump                                       */
@@ -16559,22 +16634,22 @@ typedef struct VdbeOpList VdbeOpList;
 #define OP_IsType         18 /* jump, synopsis: if typeof(P1.P3) in P5 goto P2 */
 #define OP_Not            19 /* same as TK_NOT, synopsis: r[P2]= !r[P1]    */
 #define OP_IfNullRow      20 /* jump, synopsis: if P1.nullRow then r[P3]=NULL, goto P2 */
-#define OP_SeekLT         21 /* jump, synopsis: key=r[P3@P4]               */
-#define OP_SeekLE         22 /* jump, synopsis: key=r[P3@P4]               */
-#define OP_SeekGE         23 /* jump, synopsis: key=r[P3@P4]               */
-#define OP_SeekGT         24 /* jump, synopsis: key=r[P3@P4]               */
+#define OP_SeekLT         21 /* jump0, synopsis: key=r[P3@P4]              */
+#define OP_SeekLE         22 /* jump0, synopsis: key=r[P3@P4]              */
+#define OP_SeekGE         23 /* jump0, synopsis: key=r[P3@P4]              */
+#define OP_SeekGT         24 /* jump0, synopsis: key=r[P3@P4]              */
 #define OP_IfNotOpen      25 /* jump, synopsis: if( !csr[P1] ) goto P2     */
 #define OP_IfNoHope       26 /* jump, synopsis: key=r[P3@P4]               */
 #define OP_NoConflict     27 /* jump, synopsis: key=r[P3@P4]               */
 #define OP_NotFound       28 /* jump, synopsis: key=r[P3@P4]               */
 #define OP_Found          29 /* jump, synopsis: key=r[P3@P4]               */
-#define OP_SeekRowid      30 /* jump, synopsis: intkey=r[P3]               */
+#define OP_SeekRowid      30 /* jump0, synopsis: intkey=r[P3]              */
 #define OP_NotExists      31 /* jump, synopsis: intkey=r[P3]               */
-#define OP_Last           32 /* jump                                       */
-#define OP_IfSmaller      33 /* jump                                       */
+#define OP_Last           32 /* jump0                                      */
+#define OP_IfSizeBetween  33 /* jump                                       */
 #define OP_SorterSort     34 /* jump                                       */
 #define OP_Sort           35 /* jump                                       */
-#define OP_Rewind         36 /* jump                                       */
+#define OP_Rewind         36 /* jump0                                      */
 #define OP_SorterNext     37 /* jump                                       */
 #define OP_Prev           38 /* jump                                       */
 #define OP_Next           39 /* jump                                       */
@@ -16586,7 +16661,7 @@ typedef struct VdbeOpList VdbeOpList;
 #define OP_IdxGE          45 /* jump, synopsis: key=r[P3@P4]               */
 #define OP_RowSetRead     46 /* jump, synopsis: r[P3]=rowset(P1)           */
 #define OP_RowSetTest     47 /* jump, synopsis: if r[P3] in rowset(P1) goto P2 */
-#define OP_Program        48 /* jump                                       */
+#define OP_Program        48 /* jump0                                      */
 #define OP_FkIfZero       49 /* jump, synopsis: if fkctr[P1]==0 goto P2    */
 #define OP_IsNull         50 /* jump, same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */
 #define OP_NotNull        51 /* jump, same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */
@@ -16616,7 +16691,7 @@ typedef struct VdbeOpList VdbeOpList;
 #define OP_Null           75 /* synopsis: r[P2..P3]=NULL                   */
 #define OP_SoftNull       76 /* synopsis: r[P1]=NULL                       */
 #define OP_Blob           77 /* synopsis: r[P2]=P4 (len=P1)                */
-#define OP_Variable       78 /* synopsis: r[P2]=parameter(P1,P4)           */
+#define OP_Variable       78 /* synopsis: r[P2]=parameter(P1)              */
 #define OP_Move           79 /* synopsis: r[P2@P3]=r[P1@P3]                */
 #define OP_Copy           80 /* synopsis: r[P2@P3+1]=r[P1@P3+1]            */
 #define OP_SCopy          81 /* synopsis: r[P2]=r[P1]                      */
@@ -16740,14 +16815,15 @@ typedef struct VdbeOpList VdbeOpList;
 #define OPFLG_OUT2        0x10  /* out2:  P2 is an output */
 #define OPFLG_OUT3        0x20  /* out3:  P3 is an output */
 #define OPFLG_NCYCLE      0x40  /* ncycle:Cycles count against P1 */
+#define OPFLG_JUMP0       0x80  /* jump0:  P2 might be zero */
 #define OPFLG_INITIALIZER {\
 /*   0 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x41, 0x00,\
-/*   8 */ 0x01, 0x01, 0x01, 0x01, 0x03, 0x03, 0x01, 0x01,\
-/*  16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0x49, 0x49, 0x49,\
-/*  24 */ 0x49, 0x01, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49,\
-/*  32 */ 0x41, 0x01, 0x41, 0x41, 0x41, 0x01, 0x41, 0x41,\
+/*   8 */ 0x81, 0x01, 0x01, 0x81, 0x83, 0x83, 0x01, 0x01,\
+/*  16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0xc9, 0xc9, 0xc9,\
+/*  24 */ 0xc9, 0x01, 0x49, 0x49, 0x49, 0x49, 0xc9, 0x49,\
+/*  32 */ 0xc1, 0x01, 0x41, 0x41, 0xc1, 0x01, 0x41, 0x41,\
 /*  40 */ 0x41, 0x41, 0x41, 0x26, 0x26, 0x41, 0x23, 0x0b,\
-/*  48 */ 0x01, 0x01, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
+/*  48 */ 0x81, 0x01, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
 /*  56 */ 0x0b, 0x0b, 0x01, 0x03, 0x03, 0x03, 0x01, 0x41,\
 /*  64 */ 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10,\
 /*  72 */ 0x10, 0x10, 0x00, 0x10, 0x00, 0x10, 0x10, 0x00,\
@@ -16907,6 +16983,8 @@ SQLITE_PRIVATE RecordCompare sqlite3VdbeFindCompare(UnpackedRecord*);
 SQLITE_PRIVATE void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *);
 SQLITE_PRIVATE int sqlite3VdbeHasSubProgram(Vdbe*);
 
+SQLITE_PRIVATE void sqlite3MemSetArrayInt64(sqlite3_value *aMem, int iIdx, i64 val);
+
 SQLITE_PRIVATE int sqlite3NotPureFunc(sqlite3_context*);
 #ifdef SQLITE_ENABLE_BYTECODE_VTAB
 SQLITE_PRIVATE int sqlite3VdbeBytecodeVtabInit(sqlite3*);
@@ -17494,6 +17572,10 @@ struct FuncDefHash {
 };
 #define SQLITE_FUNC_HASH(C,L) (((C)+(L))%SQLITE_FUNC_HASH_SZ)
 
+#if defined(SQLITE_USER_AUTHENTICATION)
+# warning  "The SQLITE_USER_AUTHENTICATION extension is deprecated. \
+ See ext/userauth/user-auth.txt for details."
+#endif
 #ifdef SQLITE_USER_AUTHENTICATION
 /*
 ** Information held in the "sqlite3" database connection object and used
@@ -17797,7 +17879,7 @@ struct sqlite3 {
 #define SQLITE_CursorHints    0x00000400 /* Add OP_CursorHint opcodes */
 #define SQLITE_Stat4          0x00000800 /* Use STAT4 data */
    /* TH3 expects this value  ^^^^^^^^^^ to be 0x0000800. Don't change it */
-#define SQLITE_PushDown       0x00001000 /* The push-down optimization */
+#define SQLITE_PushDown       0x00001000 /* WHERE-clause push-down opt */
 #define SQLITE_SimplifyJoin   0x00002000 /* Convert LEFT JOIN to JOIN */
 #define SQLITE_SkipScan       0x00004000 /* Skip-scans */
 #define SQLITE_PropagateConst 0x00008000 /* The constant propagation opt */
@@ -18370,8 +18452,7 @@ struct Table {
 #define TF_HasStored      0x00000040 /* Has one or more STORED columns */
 #define TF_HasGenerated   0x00000060 /* Combo: HasVirtual + HasStored */
 #define TF_WithoutRowid   0x00000080 /* No rowid.  PRIMARY KEY is the key */
-#define TF_StatsUsed      0x00000100 /* Query planner decisions affected by
-                                     ** Index.aiRowLogEst[] values */
+#define TF_MaybeReanalyze 0x00000100 /* Maybe run ANALYZE on this table */
 #define TF_NoVisibleRowid 0x00000200 /* No user-visible "rowid" column */
 #define TF_OOOHidden      0x00000400 /* Out-of-Order hidden columns */
 #define TF_HasNotNull     0x00000800 /* Contains NOT NULL constraints */
@@ -18427,6 +18508,15 @@ struct Table {
 #define HasRowid(X)     (((X)->tabFlags & TF_WithoutRowid)==0)
 #define VisibleRowid(X) (((X)->tabFlags & TF_NoVisibleRowid)==0)
 
+/* Macro is true if the SQLITE_ALLOW_ROWID_IN_VIEW (mis-)feature is
+** available.  By default, this macro is false
+*/
+#ifndef SQLITE_ALLOW_ROWID_IN_VIEW
+# define ViewCanHaveRowid     0
+#else
+# define ViewCanHaveRowid     (sqlite3Config.mNoVisibleRowid==0)
+#endif
+
 /*
 ** Each foreign key constraint is an instance of the following structure.
 **
@@ -19162,10 +19252,12 @@ struct IdList {
 **
 ** Union member validity:
 **
-**    u1.zIndexedBy          fg.isIndexedBy && !fg.isTabFunc
-**    u1.pFuncArg            fg.isTabFunc   && !fg.isIndexedBy
-**    u2.pIBIndex            fg.isIndexedBy && !fg.isCte
-**    u2.pCteUse             fg.isCte       && !fg.isIndexedBy
+**    u1.zIndexedBy      fg.isIndexedBy && !fg.isTabFunc
+**    u1.pFuncArg        fg.isTabFunc   && !fg.isIndexedBy
+**    u1.nRow            !fg.isTabFunc  && !fg.isIndexedBy
+**
+**    u2.pIBIndex        fg.isIndexedBy && !fg.isCte
+**    u2.pCteUse         fg.isCte       && !fg.isIndexedBy
 */
 struct SrcItem {
   Schema *pSchema;  /* Schema to which this item is fixed */
@@ -19193,6 +19285,7 @@ struct SrcItem {
     unsigned isOn :1;          /* u3.pOn was once valid and non-NULL */
     unsigned isSynthUsing :1;  /* u3.pUsing is synthesized from NATURAL */
     unsigned isNestedFrom :1;  /* pSelect is a SF_NestedFrom subquery */
+    unsigned rowidUsed :1;     /* The ROWID of this table is referenced */
   } fg;
   int iCursor;      /* The VDBE cursor number used to access this table */
   union {
@@ -19203,6 +19296,7 @@ struct SrcItem {
   union {
     char *zIndexedBy;    /* Identifier from "INDEXED BY <zIndex>" clause */
     ExprList *pFuncArg;  /* Arguments to table-valued-function */
+    u32 nRow;            /* Number of rows in a VALUES clause */
   } u1;
   union {
     Index *pIBIndex;  /* Index structure corresponding to u1.zIndexedBy */
@@ -19346,6 +19440,7 @@ struct NameContext {
 #define NC_InAggFunc 0x020000 /* True if analyzing arguments to an agg func */
 #define NC_FromDDL   0x040000 /* SQL text comes from sqlite_schema */
 #define NC_NoSelect  0x080000 /* Do not descend into sub-selects */
+#define NC_Where     0x100000 /* Processing WHERE clause of a SELECT */
 #define NC_OrderAgg 0x8000000 /* Has an aggregate other than count/min/max */
 
 /*
@@ -19369,6 +19464,7 @@ struct Upsert {
   Expr *pUpsertWhere;       /* WHERE clause for the ON CONFLICT UPDATE */
   Upsert *pNextUpsert;      /* Next ON CONFLICT clause in the list */
   u8 isDoUpdate;            /* True for DO UPDATE.  False for DO NOTHING */
+  u8 isDup;                 /* True if 2nd or later with same pUpsertIdx */
   /* Above this point is the parse tree for the ON CONFLICT clauses.
   ** The next group of fields stores intermediate data. */
   void *pToFree;            /* Free memory when deleting the Upsert object */
@@ -19458,11 +19554,12 @@ struct Select {
 #define SF_View          0x0200000 /* SELECT statement is a view */
 #define SF_NoopOrderBy   0x0400000 /* ORDER BY is ignored for this query */
 #define SF_UFSrcCheck    0x0800000 /* Check pSrc as required by UPDATE...FROM */
-#define SF_PushDown      0x1000000 /* SELECT has be modified by push-down opt */
+#define SF_PushDown      0x1000000 /* Modified by WHERE-clause push-down opt */
 #define SF_MultiPart     0x2000000 /* Has multiple incompatible PARTITIONs */
 #define SF_CopyCte       0x4000000 /* SELECT statement is a copy of a CTE */
 #define SF_OrderByReqd   0x8000000 /* The ORDER BY clause may not be omitted */
 #define SF_UpdateFrom   0x10000000 /* Query originates with UPDATE FROM */
+#define SF_Correlated   0x20000000 /* True if references the outer context */
 
 /* True if S exists and has SF_NestedFrom */
 #define IsNestedFrom(S) ((S)!=0 && ((S)->selFlags&SF_NestedFrom)!=0)
@@ -19702,6 +19799,7 @@ struct Parse {
   u8 disableLookaside; /* Number of times lookaside has been disabled */
   u8 prepFlags;        /* SQLITE_PREPARE_* flags */
   u8 withinRJSubrtn;   /* Nesting level for RIGHT JOIN body subroutines */
+  u8 bHasWith;         /* True if statement contains WITH */
 #if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST)
   u8 earlyCleanup;     /* OOM inside sqlite3ParserAddCleanup() */
 #endif
@@ -20139,6 +20237,11 @@ struct Sqlite3Config {
 #endif
 #ifndef SQLITE_UNTESTABLE
   int (*xTestCallback)(int);        /* Invoked by sqlite3FaultSim() */
+#endif
+#ifdef SQLITE_ALLOW_ROWID_IN_VIEW
+  u32 mNoVisibleRowid;              /* TF_NoVisibleRowid if the ROWID_IN_VIEW
+                                    ** feature is disabled.  0 if rowids can
+                                    ** occur in views. */
 #endif
   int bLocaltimeFault;              /* True to fail localtime() calls */
   int (*xAltLocaltime)(const void*,void*); /* Alternative localtime() routine */
@@ -20376,6 +20479,9 @@ struct Window {
                           ** due to the SQLITE_SUBTYPE flag */
 };
 
+SQLITE_PRIVATE Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow);
+SQLITE_PRIVATE void sqlite3MultiValuesEnd(Parse *pParse, Select *pVal);
+
 #ifndef SQLITE_OMIT_WINDOWFUNC
 SQLITE_PRIVATE void sqlite3WindowDelete(sqlite3*, Window*);
 SQLITE_PRIVATE void sqlite3WindowUnlinkFromSelect(Window*);
@@ -20595,10 +20701,13 @@ SQLITE_PRIVATE void sqlite3MutexWarnOnContention(sqlite3_mutex*);
 # define EXP754 (((u64)0x7ff)<<52)
 # define MAN754 ((((u64)1)<<52)-1)
 # define IsNaN(X) (((X)&EXP754)==EXP754 && ((X)&MAN754)!=0)
+# define IsOvfl(X) (((X)&EXP754)==EXP754)
 SQLITE_PRIVATE   int sqlite3IsNaN(double);
+SQLITE_PRIVATE   int sqlite3IsOverflow(double);
 #else
-# define IsNaN(X)         0
-# define sqlite3IsNaN(X)  0
+# define IsNaN(X)             0
+# define sqlite3IsNaN(X)      0
+# define sqlite3IsOVerflow(X) 0
 #endif
 
 /*
@@ -20690,6 +20799,7 @@ SQLITE_PRIVATE int sqlite3ErrorToParser(sqlite3*,int);
 SQLITE_PRIVATE void sqlite3Dequote(char*);
 SQLITE_PRIVATE void sqlite3DequoteExpr(Expr*);
 SQLITE_PRIVATE void sqlite3DequoteToken(Token*);
+SQLITE_PRIVATE void sqlite3DequoteNumber(Parse*, Expr*);
 SQLITE_PRIVATE void sqlite3TokenInit(Token*,char*);
 SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char*, int);
 SQLITE_PRIVATE int sqlite3RunParser(Parse*, const char*);
@@ -20720,7 +20830,7 @@ SQLITE_PRIVATE void sqlite3ExprFunctionUsable(Parse*,const Expr*,const FuncDef*)
 SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32);
 SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*);
 SQLITE_PRIVATE void sqlite3ExprDeleteGeneric(sqlite3*,void*);
-SQLITE_PRIVATE void sqlite3ExprDeferredDelete(Parse*, Expr*);
+SQLITE_PRIVATE int sqlite3ExprDeferredDelete(Parse*, Expr*);
 SQLITE_PRIVATE void sqlite3ExprUnmapAndDelete(Parse*, Expr*);
 SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*);
 SQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*);
@@ -20943,12 +21053,10 @@ SQLITE_PRIVATE void sqlite3LeaveMutexAndCloseZombie(sqlite3*);
 SQLITE_PRIVATE u32 sqlite3IsTrueOrFalse(const char*);
 SQLITE_PRIVATE int sqlite3ExprIdToTrueFalse(Expr*);
 SQLITE_PRIVATE int sqlite3ExprTruthValue(const Expr*);
-SQLITE_PRIVATE int sqlite3ExprIsConstant(Expr*);
-SQLITE_PRIVATE int sqlite3ExprIsConstantNotJoin(Expr*);
+SQLITE_PRIVATE int sqlite3ExprIsConstant(Parse*,Expr*);
 SQLITE_PRIVATE int sqlite3ExprIsConstantOrFunction(Expr*, u8);
 SQLITE_PRIVATE int sqlite3ExprIsConstantOrGroupBy(Parse*, Expr*, ExprList*);
-SQLITE_PRIVATE int sqlite3ExprIsTableConstant(Expr*,int);
-SQLITE_PRIVATE int sqlite3ExprIsSingleTableConstraint(Expr*,const SrcList*,int);
+SQLITE_PRIVATE int sqlite3ExprIsSingleTableConstraint(Expr*,const SrcList*,int,int);
 #ifdef SQLITE_ENABLE_CURSOR_HINTS
 SQLITE_PRIVATE int sqlite3ExprContainsSubquery(Expr*);
 #endif
@@ -21133,7 +21241,9 @@ SQLITE_PRIVATE void sqlite3ErrorWithMsg(sqlite3*, int, const char*,...);
 SQLITE_PRIVATE void sqlite3Error(sqlite3*,int);
 SQLITE_PRIVATE void sqlite3ErrorClear(sqlite3*);
 SQLITE_PRIVATE void sqlite3SystemError(sqlite3*,int);
+#if !defined(SQLITE_OMIT_BLOB_LITERAL)
 SQLITE_PRIVATE void *sqlite3HexToBlob(sqlite3*, const char *z, int n);
+#endif
 SQLITE_PRIVATE u8 sqlite3HexToInt(int h);
 SQLITE_PRIVATE int sqlite3TwoPartName(Parse *, Token *, Token *, Token **);
 
@@ -21444,7 +21554,7 @@ SQLITE_PRIVATE   With *sqlite3WithPush(Parse*, With*, u8);
 SQLITE_PRIVATE   Upsert *sqlite3UpsertNew(sqlite3*,ExprList*,Expr*,ExprList*,Expr*,Upsert*);
 SQLITE_PRIVATE   void sqlite3UpsertDelete(sqlite3*,Upsert*);
 SQLITE_PRIVATE   Upsert *sqlite3UpsertDup(sqlite3*,Upsert*);
-SQLITE_PRIVATE   int sqlite3UpsertAnalyzeTarget(Parse*,SrcList*,Upsert*);
+SQLITE_PRIVATE   int sqlite3UpsertAnalyzeTarget(Parse*,SrcList*,Upsert*,Upsert*);
 SQLITE_PRIVATE   void sqlite3UpsertDoUpdate(Parse*,Upsert*,Table*,Index*,int);
 SQLITE_PRIVATE   Upsert *sqlite3UpsertOfIndex(Upsert*,Index*);
 SQLITE_PRIVATE   int sqlite3UpsertNextIsIPK(Upsert*);
@@ -21834,6 +21944,9 @@ static const char * const sqlite3azCompileOpt[] = {
   "ALLOW_COVERING_INDEX_SCAN=" CTIMEOPT_VAL(SQLITE_ALLOW_COVERING_INDEX_SCAN),
 # endif
 #endif
+#ifdef SQLITE_ALLOW_ROWID_IN_VIEW
+  "ALLOW_ROWID_IN_VIEW",
+#endif
 #ifdef SQLITE_ALLOW_URI_AUTHORITY
   "ALLOW_URI_AUTHORITY",
 #endif
@@ -22853,6 +22966,9 @@ SQLITE_PRIVATE SQLITE_WSD struct Sqlite3Config sqlite3Config = {
 #endif
 #ifndef SQLITE_UNTESTABLE
    0,                         /* xTestCallback */
+#endif
+#ifdef SQLITE_ALLOW_ROWID_IN_VIEW
+   0,                         /* mNoVisibleRowid.  0 == allow rowid-in-view */
 #endif
    0,                         /* bLocaltimeFault */
    0,                         /* xAltLocaltime */
@@ -24174,13 +24290,14 @@ struct DateTime {
   int tz;             /* Timezone offset in minutes */
   double s;           /* Seconds */
   char validJD;       /* True (1) if iJD is valid */
-  char rawS;          /* Raw numeric value stored in s */
   char validYMD;      /* True (1) if Y,M,D are valid */
   char validHMS;      /* True (1) if h,m,s are valid */
-  char validTZ;       /* True (1) if tz is valid */
-  char tzSet;         /* Timezone was set explicitly */
-  char isError;       /* An overflow has occurred */
-  char useSubsec;     /* Display subsecond precision */
+  char nFloor;            /* Days to implement "floor" */
+  unsigned rawS      : 1; /* Raw numeric value stored in s */
+  unsigned isError   : 1; /* An overflow has occurred */
+  unsigned useSubsec : 1; /* Display subsecond precision */
+  unsigned isUtc     : 1; /* Time is known to be UTC */
+  unsigned isLocal   : 1; /* Time is known to be localtime */
 };
 
 
@@ -24278,6 +24395,8 @@ static int parseTimezone(const char *zDate, DateTime *p){
     sgn = +1;
   }else if( c=='Z' || c=='z' ){
     zDate++;
+    p->isLocal = 0;
+    p->isUtc = 1;
     goto zulu_time;
   }else{
     return c!=0;
@@ -24290,7 +24409,6 @@ static int parseTimezone(const char *zDate, DateTime *p){
   p->tz = sgn*(nMn + nHr*60);
 zulu_time:
   while( sqlite3Isspace(*zDate) ){ zDate++; }
-  p->tzSet = 1;
   return *zDate!=0;
 }
 
@@ -24334,7 +24452,6 @@ static int parseHhMmSs(const char *zDate, DateTime *p){
   p->m = m;
   p->s = s + ms;
   if( parseTimezone(zDate, p) ) return 1;
-  p->validTZ = (p->tz!=0)?1:0;
   return 0;
 }
 
@@ -24381,15 +24498,40 @@ static void computeJD(DateTime *p){
   p->validJD = 1;
   if( p->validHMS ){
     p->iJD += p->h*3600000 + p->m*60000 + (sqlite3_int64)(p->s*1000 + 0.5);
-    if( p->validTZ ){
+    if( p->tz ){
       p->iJD -= p->tz*60000;
       p->validYMD = 0;
       p->validHMS = 0;
-      p->validTZ = 0;
+      p->tz = 0;
+      p->isUtc = 1;
+      p->isLocal = 0;
     }
   }
 }
 
+/*
+** Given the YYYY-MM-DD information current in p, determine if there
+** is day-of-month overflow and set nFloor to the number of days that
+** would need to be subtracted from the date in order to bring the
+** date back to the end of the month.
+*/
+static void computeFloor(DateTime *p){
+  assert( p->validYMD || p->isError );
+  assert( p->D>=0 && p->D<=31 );
+  assert( p->M>=0 && p->M<=12 );
+  if( p->D<=28 ){
+    p->nFloor = 0;
+  }else if( (1<<p->M) & 0x15aa ){
+    p->nFloor = 0;
+  }else if( p->M!=2 ){
+    p->nFloor = (p->D==31);
+  }else if( p->Y%4!=0 || (p->Y%100==0 && p->Y%400!=0) ){
+    p->nFloor = p->D - 28;
+  }else{
+    p->nFloor = p->D - 29;
+  }
+}
+
 /*
 ** Parse dates of the form
 **
@@ -24428,12 +24570,16 @@ static int parseYyyyMmDd(const char *zDate, DateTime *p){
   p->Y = neg ? -Y : Y;
   p->M = M;
   p->D = D;
-  if( p->validTZ ){
+  computeFloor(p);
+  if( p->tz ){
     computeJD(p);
   }
   return 0;
 }
 
+
+static void clearYMD_HMS_TZ(DateTime *p);  /* Forward declaration */
+
 /*
 ** Set the time to the current time reported by the VFS.
 **
@@ -24443,6 +24589,9 @@ static int setDateTimeToCurrent(sqlite3_context *context, DateTime *p){
   p->iJD = sqlite3StmtCurrentTime(context);
   if( p->iJD>0 ){
     p->validJD = 1;
+    p->isUtc = 1;
+    p->isLocal = 0;
+    clearYMD_HMS_TZ(p);
     return 0;
   }else{
     return 1;
@@ -24581,7 +24730,7 @@ static void computeYMD_HMS(DateTime *p){
 static void clearYMD_HMS_TZ(DateTime *p){
   p->validYMD = 0;
   p->validHMS = 0;
-  p->validTZ = 0;
+  p->tz = 0;
 }
 
 #ifndef SQLITE_OMIT_LOCALTIME
@@ -24713,7 +24862,7 @@ static int toLocaltime(
   p->validHMS = 1;
   p->validJD = 0;
   p->rawS = 0;
-  p->validTZ = 0;
+  p->tz = 0;
   p->isError = 0;
   return SQLITE_OK;
 }
@@ -24733,12 +24882,12 @@ static const struct {
   float rLimit;       /* Maximum NNN value for this transform */
   float rXform;       /* Constant used for this transform */
 } aXformType[] = {
-  { 6, "second", 4.6427e+14,       1.0  },
-  { 6, "minute", 7.7379e+12,      60.0  },
-  { 4, "hour",   1.2897e+11,    3600.0  },
-  { 3, "day",    5373485.0,    86400.0  },
-  { 5, "month",  176546.0,   2592000.0  },
-  { 4, "year",   14713.0,   31536000.0  },
+  /* 0 */ { 6, "second",   4.6427e+14,         1.0  },
+  /* 1 */ { 6, "minute",   7.7379e+12,        60.0  },
+  /* 2 */ { 4, "hour",     1.2897e+11,      3600.0  },
+  /* 3 */ { 3, "day",      5373485.0,      86400.0  },
+  /* 4 */ { 5, "month",    176546.0,  30.0*86400.0  },
+  /* 5 */ { 4, "year",     14713.0,  365.0*86400.0  },
 };
 
 /*
@@ -24770,14 +24919,20 @@ static void autoAdjustDate(DateTime *p){
 **     NNN.NNNN seconds
 **     NNN months
 **     NNN years
+**     +/-YYYY-MM-DD HH:MM:SS.SSS
+**     ceiling
+**     floor
 **     start of month
 **     start of year
 **     start of week
 **     start of day
 **     weekday N
 **     unixepoch
+**     auto
 **     localtime
 **     utc
+**     subsec
+**     subsecond
 **
 ** Return 0 on success and 1 if there is any kind of error. If the error
 ** is in a system call (i.e. localtime()), then an error message is written
@@ -24808,6 +24963,37 @@ static int parseModifier(
       }
       break;
     }
+    case 'c': {
+      /*
+      **    ceiling
+      **
+      ** Resolve day-of-month overflow by rolling forward into the next
+      ** month.  As this is the default action, this modifier is really
+      ** a no-op that is only included for symmetry.  See "floor".
+      */
+      if( sqlite3_stricmp(z, "ceiling")==0 ){
+        computeJD(p);
+        clearYMD_HMS_TZ(p);
+        rc = 0;
+        p->nFloor = 0;
+      }
+      break;
+    }
+    case 'f': {
+      /*
+      **    floor
+      **
+      ** Resolve day-of-month overflow by rolling back to the end of the
+      ** previous month.
+      */
+      if( sqlite3_stricmp(z, "floor")==0 ){
+        computeJD(p);
+        p->iJD -= p->nFloor*86400000;
+        clearYMD_HMS_TZ(p);
+        rc = 0;
+      }
+      break;
+    }
     case 'j': {
       /*
       **    julianday
@@ -24834,7 +25020,9 @@ static int parseModifier(
       ** show local time.
       */
       if( sqlite3_stricmp(z, "localtime")==0 && sqlite3NotPureFunc(pCtx) ){
-        rc = toLocaltime(p, pCtx);
+        rc = p->isLocal ? SQLITE_OK : toLocaltime(p, pCtx);
+        p->isUtc = 0;
+        p->isLocal = 1;
       }
       break;
     }
@@ -24859,7 +25047,7 @@ static int parseModifier(
       }
 #ifndef SQLITE_OMIT_LOCALTIME
       else if( sqlite3_stricmp(z, "utc")==0 && sqlite3NotPureFunc(pCtx) ){
-        if( p->tzSet==0 ){
+        if( p->isUtc==0 ){
           i64 iOrigJD;              /* Original localtime */
           i64 iGuess;               /* Guess at the corresponding utc time */
           int cnt = 0;              /* Safety to prevent infinite loop */
@@ -24882,7 +25070,8 @@ static int parseModifier(
           memset(p, 0, sizeof(*p));
           p->iJD = iGuess;
           p->validJD = 1;
-          p->tzSet = 1;
+          p->isUtc = 1;
+          p->isLocal = 0;
         }
         rc = SQLITE_OK;
       }
@@ -24902,7 +25091,7 @@ static int parseModifier(
                && r>=0.0 && r<7.0 && (n=(int)r)==r ){
         sqlite3_int64 Z;
         computeYMD_HMS(p);
-        p->validTZ = 0;
+        p->tz = 0;
         p->validJD = 0;
         computeJD(p);
         Z = ((p->iJD + 129600000)/86400000) % 7;
@@ -24942,7 +25131,7 @@ static int parseModifier(
       p->h = p->m = 0;
       p->s = 0.0;
       p->rawS = 0;
-      p->validTZ = 0;
+      p->tz = 0;
       p->validJD = 0;
       if( sqlite3_stricmp(z,"month")==0 ){
         p->D = 1;
@@ -25013,6 +25202,7 @@ static int parseModifier(
         x = p->M>0 ? (p->M-1)/12 : (p->M-12)/12;
         p->Y += x;
         p->M -= x*12;
+        computeFloor(p);
         computeJD(p);
         p->validHMS = 0;
         p->validYMD = 0;
@@ -25059,11 +25249,12 @@ static int parseModifier(
       z += n;
       while( sqlite3Isspace(*z) ) z++;
       n = sqlite3Strlen30(z);
-      if( n>10 || n<3 ) break;
+      if( n<3 || n>10 ) break;
       if( sqlite3UpperToLower[(u8)z[n-1]]=='s' ) n--;
       computeJD(p);
       assert( rc==1 );
       rRounder = r<0 ? -0.5 : +0.5;
+      p->nFloor = 0;
       for(i=0; i<ArraySize(aXformType); i++){
         if( aXformType[i].nName==n
          && sqlite3_strnicmp(aXformType[i].zName, z, n)==0
@@ -25071,21 +25262,24 @@ static int parseModifier(
         ){
           switch( i ){
             case 4: { /* Special processing to add months */
-              assert( strcmp(aXformType[i].zName,"month")==0 );
+              assert( strcmp(aXformType[4].zName,"month")==0 );
               computeYMD_HMS(p);
               p->M += (int)r;
               x = p->M>0 ? (p->M-1)/12 : (p->M-12)/12;
               p->Y += x;
               p->M -= x*12;
+              computeFloor(p);
               p->validJD = 0;
               r -= (int)r;
               break;
             }
             case 5: { /* Special processing to add years */
               int y = (int)r;
-              assert( strcmp(aXformType[i].zName,"year")==0 );
+              assert( strcmp(aXformType[5].zName,"year")==0 );
               computeYMD_HMS(p);
+              assert( p->M>=0 && p->M<=12 );
               p->Y += y;
+              computeFloor(p);
               p->validJD = 0;
               r -= (int)r;
               break;
@@ -25339,22 +25533,83 @@ static void dateFunc(
   }
 }
 
+/*
+** Compute the number of days after the most recent January 1.
+**
+** In other words, compute the zero-based day number for the
+** current year:
+**
+**   Jan01 = 0,  Jan02 = 1, ..., Jan31 = 30, Feb01 = 31, ...
+**   Dec31 = 364 or 365.
+*/
+static int daysAfterJan01(DateTime *pDate){
+  DateTime jan01 = *pDate;
+  assert( jan01.validYMD );
+  assert( jan01.validHMS );
+  assert( pDate->validJD );
+  jan01.validJD = 0;
+  jan01.M = 1;
+  jan01.D = 1;
+  computeJD(&jan01);
+  return (int)((pDate->iJD-jan01.iJD+43200000)/86400000);
+}
+
+/*
+** Return the number of days after the most recent Monday.
+**
+** In other words, return the day of the week according
+** to this code:
+**
+**   0=Monday, 1=Tuesday, 2=Wednesday, ..., 6=Sunday.
+*/
+static int daysAfterMonday(DateTime *pDate){
+  assert( pDate->validJD );
+  return (int)((pDate->iJD+43200000)/86400000) % 7;
+}
+
+/*
+** Return the number of days after the most recent Sunday.
+**
+** In other words, return the day of the week according
+** to this code:
+**
+**   0=Sunday, 1=Monday, 2=Tues, ..., 6=Saturday
+*/
+static int daysAfterSunday(DateTime *pDate){
+  assert( pDate->validJD );
+  return (int)((pDate->iJD+129600000)/86400000) % 7;
+}
+
 /*
 **    strftime( FORMAT, TIMESTRING, MOD, MOD, ...)
 **
 ** Return a string described by FORMAT.  Conversions as follows:
 **
-**   %d  day of month
+**   %d  day of month  01-31
+**   %e  day of month  1-31
 **   %f  ** fractional seconds  SS.SSS
+**   %F  ISO date.  YYYY-MM-DD
+**   %G  ISO year corresponding to %V 0000-9999.
+**   %g  2-digit ISO year corresponding to %V 00-99
 **   %H  hour 00-24
-**   %j  day of year 000-366
+**   %k  hour  0-24  (leading zero converted to space)
+**   %I  hour 01-12
+**   %j  day of year 001-366
 **   %J  ** julian day number
+**   %l  hour  1-12  (leading zero converted to space)
 **   %m  month 01-12
 **   %M  minute 00-59
+**   %p  "am" or "pm"
+**   %P  "AM" or "PM"
+**   %R  time as HH:MM
 **   %s  seconds since 1970-01-01
 **   %S  seconds 00-59
-**   %w  day of week 0-6  Sunday==0
-**   %W  week of year 00-53
+**   %T  time as HH:MM:SS
+**   %u  day of week 1-7  Monday==1, Sunday==7
+**   %w  day of week 0-6  Sunday==0, Monday==1
+**   %U  week of year 00-53  (First Sunday is start of week 01)
+**   %V  week of year 01-53  (First week containing Thursday is week 01)
+**   %W  week of year 00-53  (First Monday is start of week 01)
 **   %Y  year 0000-9999
 **   %%  %
 */
@@ -25391,7 +25646,7 @@ static void strftimeFunc(
         sqlite3_str_appendf(&sRes, cf=='d' ? "%02d" : "%2d", x.D);
         break;
       }
-      case 'f': {
+      case 'f': {  /* Fractional seconds.  (Non-standard) */
         double s = x.s;
         if( s>59.999 ) s = 59.999;
         sqlite3_str_appendf(&sRes, "%06.3f", s);
@@ -25401,6 +25656,21 @@ static void strftimeFunc(
         sqlite3_str_appendf(&sRes, "%04d-%02d-%02d", x.Y, x.M, x.D);
         break;
       }
+      case 'G': /* Fall thru */
+      case 'g': {
+        DateTime y = x;
+        assert( y.validJD );
+        /* Move y so that it is the Thursday in the same week as x */
+        y.iJD += (3 - daysAfterMonday(&x))*86400000;
+        y.validYMD = 0;
+        computeYMD(&y);
+        if( cf=='g' ){
+          sqlite3_str_appendf(&sRes, "%02d", y.Y%100);
+        }else{
+          sqlite3_str_appendf(&sRes, "%04d", y.Y);
+        }
+        break;
+      }
       case 'H':
       case 'k': {
         sqlite3_str_appendf(&sRes, cf=='H' ? "%02d" : "%2d", x.h);
@@ -25414,25 +25684,11 @@ static void strftimeFunc(
         sqlite3_str_appendf(&sRes, cf=='I' ? "%02d" : "%2d", h);
         break;
       }
-      case 'W': /* Fall thru */
-      case 'j': {
-        int nDay;             /* Number of days since 1st day of year */
-        DateTime y = x;
-        y.validJD = 0;
-        y.M = 1;
-        y.D = 1;
-        computeJD(&y);
-        nDay = (int)((x.iJD-y.iJD+43200000)/86400000);
-        if( cf=='W' ){
-          int wd;   /* 0=Monday, 1=Tuesday, ... 6=Sunday */
-          wd = (int)(((x.iJD+43200000)/86400000)%7);
-          sqlite3_str_appendf(&sRes,"%02d",(nDay+7-wd)/7);
-        }else{
-          sqlite3_str_appendf(&sRes,"%03d",nDay+1);
-        }
+      case 'j': {  /* Day of year.  Jan01==1, Jan02==2, and so forth */
+        sqlite3_str_appendf(&sRes,"%03d",daysAfterJan01(&x)+1);
         break;
       }
-      case 'J': {
+      case 'J': {  /* Julian day number.  (Non-standard) */
         sqlite3_str_appendf(&sRes,"%.16g",x.iJD/86400000.0);
         break;
       }
@@ -25475,13 +25731,33 @@ static void strftimeFunc(
         sqlite3_str_appendf(&sRes,"%02d:%02d:%02d", x.h, x.m, (int)x.s);
         break;
       }
-      case 'u': /* Fall thru */
-      case 'w': {
-        char c = (char)(((x.iJD+129600000)/86400000) % 7) + '0';
+      case 'u':    /* Day of week.  1 to 7.  Monday==1, Sunday==7 */
+      case 'w': {  /* Day of week.  0 to 6.  Sunday==0, Monday==1 */
+        char c = (char)daysAfterSunday(&x) + '0';
         if( c=='0' && cf=='u' ) c = '7';
         sqlite3_str_appendchar(&sRes, 1, c);
         break;
       }
+      case 'U': {  /* Week num. 00-53. First Sun of the year is week 01 */
+        sqlite3_str_appendf(&sRes,"%02d",
+              (daysAfterJan01(&x)-daysAfterSunday(&x)+7)/7);
+        break;
+      }
+      case 'V': {  /* Week num. 01-53. First week with a Thur is week 01 */
+        DateTime y = x;
+        /* Adjust y so that is the Thursday in the same week as x */
+        assert( y.validJD );
+        y.iJD += (3 - daysAfterMonday(&x))*86400000;
+        y.validYMD = 0;
+        computeYMD(&y);
+        sqlite3_str_appendf(&sRes,"%02d", daysAfterJan01(&y)/7+1);
+        break;
+      }
+      case 'W': {  /* Week num. 00-53. First Mon of the year is week 01 */
+        sqlite3_str_appendf(&sRes,"%02d",
+           (daysAfterJan01(&x)-daysAfterMonday(&x)+7)/7);
+        break;
+      }
       case 'Y': {
         sqlite3_str_appendf(&sRes,"%04d",x.Y);
         break;
@@ -25628,9 +25904,7 @@ static void timediffFunc(
     d1.iJD = d2.iJD - d1.iJD;
     d1.iJD += (u64)1486995408 * (u64)100000;
   }
-  d1.validYMD = 0;
-  d1.validHMS = 0;
-  d1.validTZ = 0;
+  clearYMD_HMS_TZ(&d1);
   computeYMD_HMS(&d1);
   sqlite3StrAccumInit(&sRes, 0, 0, 0, 100);
   sqlite3_str_appendf(&sRes, "%c%04d-%02d-%02d %02d:%02d:%06.3f",
@@ -25699,6 +25973,36 @@ static void currentTimeFunc(
 }
 #endif
 
+#if !defined(SQLITE_OMIT_DATETIME_FUNCS) && defined(SQLITE_DEBUG)
+/*
+**   datedebug(...)
+**
+** This routine returns JSON that describes the internal DateTime object.
+** Used for debugging and testing only.  Subject to change.
+*/
+static void datedebugFunc(
+  sqlite3_context *context,
+  int argc,
+  sqlite3_value **argv
+){
+  DateTime x;
+  if( isDate(context, argc, argv, &x)==0 ){
+    char *zJson;
+    zJson = sqlite3_mprintf(
+      "{iJD:%lld,Y:%d,M:%d,D:%d,h:%d,m:%d,tz:%d,"
+      "s:%.3f,validJD:%d,validYMS:%d,validHMS:%d,"
+      "nFloor:%d,rawS:%d,isError:%d,useSubsec:%d,"
+      "isUtc:%d,isLocal:%d}",
+      x.iJD, x.Y, x.M, x.D, x.h, x.m, x.tz,
+      x.s, x.validJD, x.validYMD, x.validHMS,
+      x.nFloor, x.rawS, x.isError, x.useSubsec,
+      x.isUtc, x.isLocal);
+    sqlite3_result_text(context, zJson, -1, sqlite3_free);
+  }
+}
+#endif /* !SQLITE_OMIT_DATETIME_FUNCS && SQLITE_DEBUG */
+
+
 /*
 ** This function registered all of the above C functions as SQL
 ** functions.  This should be the only routine in this file with
@@ -25714,6 +26018,9 @@ SQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void){
     PURE_DATE(datetime,         -1, 0, 0, datetimeFunc  ),
     PURE_DATE(strftime,         -1, 0, 0, strftimeFunc  ),
     PURE_DATE(timediff,          2, 0, 0, timediffFunc  ),
+#ifdef SQLITE_DEBUG
+    PURE_DATE(datedebug,        -1, 0, 0, datedebugFunc ),
+#endif
     DFUNCTION(current_time,      0, 0, 0, ctimeFunc     ),
     DFUNCTION(current_timestamp, 0, 0, 0, ctimestampFunc),
     DFUNCTION(current_date,      0, 0, 0, cdateFunc     ),
@@ -30129,6 +30436,24 @@ static void sqlite3MallocAlarm(int nByte){
   sqlite3_mutex_enter(mem0.mutex);
 }
 
+#ifdef SQLITE_DEBUG
+/*
+** This routine is called whenever an out-of-memory condition is seen,
+** It's only purpose to to serve as a breakpoint for gdb or similar
+** code debuggers when working on out-of-memory conditions, for example
+** caused by PRAGMA hard_heap_limit=N.
+*/
+static SQLITE_NOINLINE void test_oom_breakpoint(u64 n){
+  static u64 nOomFault = 0;
+  nOomFault += n;
+  /* The assert() is never reached in a human lifetime.  It  is here mostly
+  ** to prevent code optimizers from optimizing out this function. */
+  assert( (nOomFault>>32) < 0xffffffff );
+}
+#else
+# define test_oom_breakpoint(X)   /* No-op for production builds */
+#endif
+
 /*
 ** Do a memory allocation with statistics and alarms.  Assume the
 ** lock is already held.
@@ -30155,6 +30480,7 @@ static void mallocWithAlarm(int n, void **pp){
       if( mem0.hardLimit ){
         nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);
         if( nUsed >= mem0.hardLimit - nFull ){
+          test_oom_breakpoint(1);
           *pp = 0;
           return;
         }
@@ -30443,6 +30769,7 @@ SQLITE_PRIVATE void *sqlite3Realloc(void *pOld, u64 nBytes){
       sqlite3MallocAlarm(nDiff);
       if( mem0.hardLimit>0 && nUsed >= mem0.hardLimit - nDiff ){
         sqlite3_mutex_leave(mem0.mutex);
+        test_oom_breakpoint(1);
         return 0;
       }
     }
@@ -31309,6 +31636,7 @@ SQLITE_API void sqlite3_str_vappendf(
         if( xtype==etFLOAT ){
           iRound = -precision;
         }else if( xtype==etGENERIC ){
+          if( precision==0 ) precision = 1;
           iRound = precision;
         }else{
           iRound = precision+1;
@@ -31344,13 +31672,14 @@ SQLITE_API void sqlite3_str_vappendf(
         }
 
         exp = s.iDP-1;
-        if( xtype==etGENERIC && precision>0 ) precision--;
 
         /*
         ** If the field type is etGENERIC, then convert to either etEXP
         ** or etFLOAT, as appropriate.
         */
         if( xtype==etGENERIC ){
+          assert( precision>0 );
+          precision--;
           flag_rtz = !flag_alternateform;
           if( exp<-4 || exp>precision ){
             xtype = etEXP;
@@ -31666,9 +31995,13 @@ SQLITE_API void sqlite3_str_vappendf(
           sqlite3_str_appendall(pAccum, pItem->zAlias);
         }else{
           Select *pSel = pItem->pSelect;
-          assert( pSel!=0 );
+          assert( pSel!=0 ); /* Because of tag-20240424-1 */
           if( pSel->selFlags & SF_NestedFrom ){
             sqlite3_str_appendf(pAccum, "(join-%u)", pSel->selId);
+          }else if( pSel->selFlags & SF_MultiValue ){
+            assert( !pItem->fg.isTabFunc && !pItem->fg.isIndexedBy );
+            sqlite3_str_appendf(pAccum, "%u-ROW VALUES CLAUSE",
+                                pItem->u1.nRow);
           }else{
             sqlite3_str_appendf(pAccum, "(subquery-%u)", pSel->selId);
           }
@@ -32445,8 +32778,10 @@ SQLITE_PRIVATE void sqlite3TreeViewSrcList(TreeView *pView, const SrcList *pSrc)
     x.printfFlags |= SQLITE_PRINTF_INTERNAL;
     sqlite3_str_appendf(&x, "{%d:*} %!S", pItem->iCursor, pItem);
     if( pItem->pTab ){
-      sqlite3_str_appendf(&x, " tab=%Q nCol=%d ptr=%p used=%llx",
-           pItem->pTab->zName, pItem->pTab->nCol, pItem->pTab, pItem->colUsed);
+      sqlite3_str_appendf(&x, " tab=%Q nCol=%d ptr=%p used=%llx%s",
+           pItem->pTab->zName, pItem->pTab->nCol, pItem->pTab,
+           pItem->colUsed,
+           pItem->fg.rowidUsed ? "+rowid" : "");
     }
     if( (pItem->fg.jointype & (JT_LEFT|JT_RIGHT))==(JT_LEFT|JT_RIGHT) ){
       sqlite3_str_appendf(&x, " FULL-OUTER-JOIN");
@@ -32486,12 +32821,14 @@ SQLITE_PRIVATE void sqlite3TreeViewSrcList(TreeView *pView, const SrcList *pSrc)
       sqlite3TreeViewIdList(pView, pItem->u3.pUsing, (--n)>0, "USING");
     }
     if( pItem->pSelect ){
+      sqlite3TreeViewPush(&pView, i+1<pSrc->nSrc);
       if( pItem->pTab ){
         Table *pTab = pItem->pTab;
         sqlite3TreeViewColumnList(pView, pTab->aCol, pTab->nCol, 1);
       }
       assert( (int)pItem->fg.isNestedFrom == IsNestedFrom(pItem->pSelect) );
       sqlite3TreeViewSelect(pView, pItem->pSelect, (--n)>0);
+      sqlite3TreeViewPop(&pView);
     }
     if( pItem->fg.isTabFunc ){
       sqlite3TreeViewExprList(pView, pItem->u1.pFuncArg, 0, "func-args:");
@@ -32595,7 +32932,7 @@ SQLITE_PRIVATE void sqlite3TreeViewSelect(TreeView *pView, const Select *p, u8 m
       sqlite3TreeViewItem(pView, "LIMIT", (n--)>0);
       sqlite3TreeViewExpr(pView, p->pLimit->pLeft, p->pLimit->pRight!=0);
       if( p->pLimit->pRight ){
-        sqlite3TreeViewItem(pView, "OFFSET", (n--)>0);
+        sqlite3TreeViewItem(pView, "OFFSET", 0);
         sqlite3TreeViewExpr(pView, p->pLimit->pRight, 0);
         sqlite3TreeViewPop(&pView);
       }
@@ -34640,6 +34977,19 @@ SQLITE_PRIVATE int sqlite3IsNaN(double x){
 }
 #endif /* SQLITE_OMIT_FLOATING_POINT */
 
+#ifndef SQLITE_OMIT_FLOATING_POINT
+/*
+** Return true if the floating point value is NaN or +Inf or -Inf.
+*/
+SQLITE_PRIVATE int sqlite3IsOverflow(double x){
+  int rc;   /* The value return */
+  u64 y;
+  memcpy(&y,&x,sizeof(y));
+  rc = IsOvfl(y);
+  return rc;
+}
+#endif /* SQLITE_OMIT_FLOATING_POINT */
+
 /*
 ** Compute a string length that is limited to what can be stored in
 ** lower 30 bits of a 32-bit signed integer.
@@ -34883,6 +35233,44 @@ SQLITE_PRIVATE void sqlite3DequoteExpr(Expr *p){
   sqlite3Dequote(p->u.zToken);
 }
 
+/*
+** Expression p is a QNUMBER (quoted number). Dequote the value in p->u.zToken
+** and set the type to INTEGER or FLOAT. "Quoted" integers or floats are those
+** that contain '_' characters that must be removed before further processing.
+*/
+SQLITE_PRIVATE void sqlite3DequoteNumber(Parse *pParse, Expr *p){
+  assert( p!=0 || pParse->db->mallocFailed );
+  if( p ){
+    const char *pIn = p->u.zToken;
+    char *pOut = p->u.zToken;
+    int bHex = (pIn[0]=='0' && (pIn[1]=='x' || pIn[1]=='X'));
+    int iValue;
+    assert( p->op==TK_QNUMBER );
+    p->op = TK_INTEGER;
+    do {
+      if( *pIn!=SQLITE_DIGIT_SEPARATOR ){
+        *pOut++ = *pIn;
+        if( *pIn=='e' || *pIn=='E' || *pIn=='.' ) p->op = TK_FLOAT;
+      }else{
+        if( (bHex==0 && (!sqlite3Isdigit(pIn[-1]) || !sqlite3Isdigit(pIn[1])))
+         || (bHex==1 && (!sqlite3Isxdigit(pIn[-1]) || !sqlite3Isxdigit(pIn[1])))
+        ){
+          sqlite3ErrorMsg(pParse, "unrecognized token: \"%s\"", p->u.zToken);
+        }
+      }
+    }while( *pIn++ );
+    if( bHex ) p->op = TK_INTEGER;
+
+    /* tag-20240227-a: If after dequoting, the number is an integer that
+    ** fits in 32 bits, then it must be converted into EP_IntValue.  Other
+    ** parts of the code expect this.  See also tag-20240227-b. */
+    if( p->op==TK_INTEGER && sqlite3GetInt32(p->u.zToken, &iValue) ){
+      p->u.iValue = iValue;
+      p->flags |= EP_IntValue;
+    }
+  }
+}
+
 /*
 ** If the input token p is quoted, try to adjust the token to remove
 ** the quotes.  This is not always possible:
@@ -35199,6 +35587,9 @@ SQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult, int length, u8 en
     u64 s2;
     rr[0] = (double)s;
     s2 = (u64)rr[0];
+#if defined(_MSC_VER) && _MSC_VER<1700
+    if( s2==0x8000000000000000LL ){ s2 = 2*(u64)(0.5*rr[0]); }
+#endif
     rr[1] = s>=s2 ? (double)(s - s2) : -(double)(s2 - s);
     if( e>0 ){
       while( e>=100  ){
@@ -35641,7 +36032,7 @@ SQLITE_PRIVATE void sqlite3FpDecode(FpDecode *p, double r, int iRound, int mxRou
   assert( p->n>0 );
   assert( p->n<sizeof(p->zBuf) );
   p->iDP = p->n + exp;
-  if( iRound<0 ){
+  if( iRound<=0 ){
     iRound = p->iDP - iRound;
     if( iRound==0 && p->zBuf[i+1]>='5' ){
       iRound = 1;
@@ -36819,7 +37210,7 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
     /*  30 */ "SeekRowid"        OpHelp("intkey=r[P3]"),
     /*  31 */ "NotExists"        OpHelp("intkey=r[P3]"),
     /*  32 */ "Last"             OpHelp(""),
-    /*  33 */ "IfSmaller"        OpHelp(""),
+    /*  33 */ "IfSizeBetween"    OpHelp(""),
     /*  34 */ "SorterSort"       OpHelp(""),
     /*  35 */ "Sort"             OpHelp(""),
     /*  36 */ "Rewind"           OpHelp(""),
@@ -36864,7 +37255,7 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
     /*  75 */ "Null"             OpHelp("r[P2..P3]=NULL"),
     /*  76 */ "SoftNull"         OpHelp("r[P1]=NULL"),
     /*  77 */ "Blob"             OpHelp("r[P2]=P4 (len=P1)"),
-    /*  78 */ "Variable"         OpHelp("r[P2]=parameter(P1,P4)"),
+    /*  78 */ "Variable"         OpHelp("r[P2]=parameter(P1)"),
     /*  79 */ "Move"             OpHelp("r[P2@P3]=r[P1@P3]"),
     /*  80 */ "Copy"             OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
     /*  81 */ "SCopy"            OpHelp("r[P2]=r[P1]"),
@@ -39262,8 +39653,12 @@ static int unixLogErrorAtLine(
   ** available, the error message will often be an empty string. Not a
   ** huge problem. Incorrectly concluding that the GNU version is available
   ** could lead to a segfault though.
+  **
+  ** Forum post 3f13857fa4062301 reports that the Android SDK may use
+  ** int-type return, depending on its version.
   */
-#if defined(STRERROR_R_CHAR_P) || defined(__USE_GNU)
+#if (defined(STRERROR_R_CHAR_P) || defined(__USE_GNU)) \
+  && !defined(ANDROID) && !defined(__ANDROID__)
   zErr =
 # endif
   strerror_r(iErrno, aErr, sizeof(aErr)-1);
@@ -44361,12 +44756,19 @@ static int unixOpen(
         rc = SQLITE_READONLY_DIRECTORY;
       }else if( errno!=EISDIR && isReadWrite ){
         /* Failed to open the file for read/write access. Try read-only. */
+        UnixUnusedFd *pReadonly = 0;
         flags &= ~(SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE);
         openFlags &= ~(O_RDWR|O_CREAT);
         flags |= SQLITE_OPEN_READONLY;
         openFlags |= O_RDONLY;
         isReadonly = 1;
-        fd = robust_open(zName, openFlags, openMode);
+        pReadonly = findReusableFd(zName, flags);
+        if( pReadonly ){
+          fd = pReadonly->fd;
+          sqlite3_free(pReadonly);
+        }else{
+          fd = robust_open(zName, openFlags, openMode);
+        }
       }
     }
     if( fd<0 ){
@@ -53262,6 +53664,14 @@ SQLITE_API unsigned char *sqlite3_serialize(
     pOut = 0;
   }else{
     sz = sqlite3_column_int64(pStmt, 0)*szPage;
+    if( sz==0 ){
+      sqlite3_reset(pStmt);
+      sqlite3_exec(db, "BEGIN IMMEDIATE; COMMIT;", 0, 0, 0);
+      rc = sqlite3_step(pStmt);
+      if( rc==SQLITE_ROW ){
+        sz = sqlite3_column_int64(pStmt, 0)*szPage;
+      }
+    }
     if( piSize ) *piSize = sz;
     if( mFlags & SQLITE_SERIALIZE_NOCOPY ){
       pOut = 0;
@@ -63785,7 +64195,7 @@ SQLITE_PRIVATE sqlite3_file *sqlite3PagerFile(Pager *pPager){
 ** This will be either the rollback journal or the WAL file.
 */
 SQLITE_PRIVATE sqlite3_file *sqlite3PagerJrnlFile(Pager *pPager){
-#if SQLITE_OMIT_WAL
+#ifdef SQLITE_OMIT_WAL
   return pPager->jfd;
 #else
   return pPager->pWal ? sqlite3WalFile(pPager->pWal) : pPager->jfd;
@@ -69809,6 +70219,7 @@ struct IntegrityCk {
   StrAccum errMsg;  /* Accumulate the error message text here */
   u32 *heap;        /* Min-heap used for analyzing cell coverage */
   sqlite3 *db;      /* Database connection running the check */
+  i64 nRow;         /* Number of rows visited in current tree */
 };
 
 /*
@@ -70283,8 +70694,47 @@ int corruptPageError(int lineno, MemPage *p){
 # define SQLITE_CORRUPT_PAGE(pMemPage) SQLITE_CORRUPT_PGNO(pMemPage->pgno)
 #endif
 
+/* Default value for SHARED_LOCK_TRACE macro if shared-cache is disabled
+** or if the lock tracking is disabled.  This is always the value for
+** release builds.
+*/
+#define SHARED_LOCK_TRACE(X,MSG,TAB,TYPE)  /*no-op*/
+
 #ifndef SQLITE_OMIT_SHARED_CACHE
 
+#if 0
+/*  ^----  Change to 1 and recompile to enable shared-lock tracing
+**         for debugging purposes.
+**
+** Print all shared-cache locks on a BtShared.  Debugging use only.
+*/
+static void sharedLockTrace(
+  BtShared *pBt,
+  const char *zMsg,
+  int iRoot,
+  int eLockType
+){
+  BtLock *pLock;
+  if( iRoot>0 ){
+    printf("%s-%p %u%s:", zMsg, pBt, iRoot, eLockType==READ_LOCK?"R":"W");
+  }else{
+    printf("%s-%p:", zMsg, pBt);
+  }
+  for(pLock=pBt->pLock; pLock; pLock=pLock->pNext){
+    printf(" %p/%u%s", pLock->pBtree, pLock->iTable,
+           pLock->eLock==READ_LOCK ? "R" : "W");
+    while( pLock->pNext && pLock->pBtree==pLock->pNext->pBtree ){
+      pLock = pLock->pNext;
+      printf(",%u%s", pLock->iTable, pLock->eLock==READ_LOCK ? "R" : "W");
+    }
+  }
+  printf("\n");
+  fflush(stdout);
+}
+#undef SHARED_LOCK_TRACE
+#define SHARED_LOCK_TRACE(X,MSG,TAB,TYPE)  sharedLockTrace(X,MSG,TAB,TYPE)
+#endif /* Shared-lock tracing */
+
 #ifdef SQLITE_DEBUG
 /*
 **** This function is only used as part of an assert() statement. ***
@@ -70361,6 +70811,8 @@ static int hasSharedCacheTableLock(
     iTab = iRoot;
   }
 
+  SHARED_LOCK_TRACE(pBtree->pBt,"hasLock",iRoot,eLockType);
+
   /* Search for the required lock. Either a write-lock on root-page iTab, a
   ** write-lock on the schema table, or (if the client is reading) a
   ** read-lock on iTab will suffice. Return 1 if any of these are found.  */
@@ -70494,6 +70946,8 @@ static int setSharedCacheTableLock(Btree *p, Pgno iTable, u8 eLock){
   BtLock *pLock = 0;
   BtLock *pIter;
 
+  SHARED_LOCK_TRACE(pBt,"setLock", iTable, eLock);
+
   assert( sqlite3BtreeHoldsMutex(p) );
   assert( eLock==READ_LOCK || eLock==WRITE_LOCK );
   assert( p->db!=0 );
@@ -70561,6 +71015,8 @@ static void clearAllSharedCacheTableLocks(Btree *p){
   assert( p->sharable || 0==*ppIter );
   assert( p->inTrans>0 );
 
+  SHARED_LOCK_TRACE(pBt, "clearAllLocks", 0, 0);
+
   while( *ppIter ){
     BtLock *pLock = *ppIter;
     assert( (pBt->btsFlags & BTS_EXCLUSIVE)==0 || pBt->pWriter==pLock->pBtree );
@@ -70599,6 +71055,9 @@ static void clearAllSharedCacheTableLocks(Btree *p){
 */
 static void downgradeAllSharedCacheTableLocks(Btree *p){
   BtShared *pBt = p->pBt;
+
+  SHARED_LOCK_TRACE(pBt, "downgradeLocks", 0, 0);
+
   if( pBt->pWriter==p ){
     BtLock *pLock;
     pBt->pWriter = 0;
@@ -75212,9 +75671,12 @@ static int accessPayload(
       if( pCur->aOverflow==0
        || nOvfl*(int)sizeof(Pgno) > sqlite3MallocSize(pCur->aOverflow)
       ){
-        Pgno *aNew = (Pgno*)sqlite3Realloc(
-            pCur->aOverflow, nOvfl*2*sizeof(Pgno)
-        );
+        Pgno *aNew;
+        if( sqlite3FaultSim(413) ){
+          aNew = 0;
+        }else{
+          aNew = (Pgno*)sqlite3Realloc(pCur->aOverflow, nOvfl*2*sizeof(Pgno));
+        }
         if( aNew==0 ){
           return SQLITE_NOMEM_BKPT;
         }else{
@@ -75224,6 +75686,12 @@ static int accessPayload(
       memset(pCur->aOverflow, 0, nOvfl*sizeof(Pgno));
       pCur->curFlags |= BTCF_ValidOvfl;
     }else{
+      /* Sanity check the validity of the overflow page cache */
+      assert( pCur->aOverflow[0]==nextPage
+           || pCur->aOverflow[0]==0
+           || CORRUPT_DB );
+      assert( pCur->aOverflow[0]!=0 || pCur->aOverflow[offset/ovflSize]==0 );
+
       /* If the overflow page-list cache has been allocated and the
       ** entry for the first required overflow page is valid, skip
       ** directly to it.
@@ -75705,6 +76173,23 @@ SQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor *pCur, int *pRes){
   return rc;
 }
 
+#ifdef SQLITE_DEBUG
+/* The cursors is CURSOR_VALID and has BTCF_AtLast set.  Verify that
+** this flags are true for a consistent database.
+**
+** This routine is is called from within assert() statements only.
+** It is an internal verification routine and does not appear in production
+** builds.
+*/
+static int cursorIsAtLastEntry(BtCursor *pCur){
+  int ii;
+  for(ii=0; ii<pCur->iPage; ii++){
+    if( pCur->aiIdx[ii]!=pCur->apPage[ii]->nCell ) return 0;
+  }
+  return pCur->ix==pCur->pPage->nCell-1 && pCur->pPage->leaf!=0;
+}
+#endif
+
 /* Move the cursor to the last entry in the table.  Return SQLITE_OK
 ** on success.  Set *pRes to 0 if the cursor actually points to something
 ** or set *pRes to 1 if the table is empty.
@@ -75733,18 +76218,7 @@ SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor *pCur, int *pRes){
 
   /* If the cursor already points to the last entry, this is a no-op. */
   if( CURSOR_VALID==pCur->eState && (pCur->curFlags & BTCF_AtLast)!=0 ){
-#ifdef SQLITE_DEBUG
-    /* This block serves to assert() that the cursor really does point
-    ** to the last entry in the b-tree. */
-    int ii;
-    for(ii=0; ii<pCur->iPage; ii++){
-      assert( pCur->aiIdx[ii]==pCur->apPage[ii]->nCell );
-    }
-    assert( pCur->ix==pCur->pPage->nCell-1 || CORRUPT_DB );
-    testcase( pCur->ix!=pCur->pPage->nCell-1 );
-    /* ^-- dbsqlfuzz b92b72e4de80b5140c30ab71372ca719b8feb618 */
-    assert( pCur->pPage->leaf );
-#endif
+    assert( cursorIsAtLastEntry(pCur) || CORRUPT_DB );
     *pRes = 0;
     return SQLITE_OK;
   }
@@ -75797,6 +76271,7 @@ SQLITE_PRIVATE int sqlite3BtreeTableMoveto(
     }
     if( pCur->info.nKey<intKey ){
       if( (pCur->curFlags & BTCF_AtLast)!=0 ){
+        assert( cursorIsAtLastEntry(pCur) || CORRUPT_DB );
         *pRes = -1;
         return SQLITE_OK;
       }
@@ -76263,10 +76738,10 @@ SQLITE_PRIVATE i64 sqlite3BtreeRowCountEst(BtCursor *pCur){
   assert( cursorOwnsBtShared(pCur) );
   assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
 
-  /* Currently this interface is only called by the OP_IfSmaller
-  ** opcode, and it that case the cursor will always be valid and
-  ** will always point to a leaf node. */
-  if( NEVER(pCur->eState!=CURSOR_VALID) ) return -1;
+  /* Currently this interface is only called by the OP_IfSizeBetween
+  ** opcode and the OP_Count opcode with P3=1.  In either case,
+  ** the cursor will always be valid unless the btree is empty. */
+  if( pCur->eState!=CURSOR_VALID ) return 0;
   if( NEVER(pCur->pPage->leaf==0) ) return -1;
 
   n = pCur->pPage->nCell;
@@ -77088,7 +77563,10 @@ static int fillInCell(
     n = nHeader + nPayload;
     testcase( n==3 );
     testcase( n==4 );
-    if( n<4 ) n = 4;
+    if( n<4 ){
+      n = 4;
+      pPayload[nPayload] = 0;
+    }
     *pnSize = n;
     assert( nSrc<=nPayload );
     testcase( nSrc<nPayload );
@@ -78394,7 +78872,7 @@ static int balance_nonroot(
     ** table-interior, index-leaf, or index-interior).
     */
     if( pOld->aData[0]!=apOld[0]->aData[0] ){
-      rc = SQLITE_CORRUPT_BKPT;
+      rc = SQLITE_CORRUPT_PAGE(pOld);
       goto balance_cleanup;
     }
 
@@ -78418,7 +78896,7 @@ static int balance_nonroot(
     memset(&b.szCell[b.nCell], 0, sizeof(b.szCell[0])*(limit+pOld->nOverflow));
     if( pOld->nOverflow>0 ){
       if( NEVER(limit<pOld->aiOvfl[0]) ){
-        rc = SQLITE_CORRUPT_BKPT;
+        rc = SQLITE_CORRUPT_PAGE(pOld);
         goto balance_cleanup;
       }
       limit = pOld->aiOvfl[0];
@@ -79061,7 +79539,7 @@ static int anotherValidCursor(BtCursor *pCur){
      && pOther->eState==CURSOR_VALID
      && pOther->pPage==pCur->pPage
     ){
-      return SQLITE_CORRUPT_BKPT;
+      return SQLITE_CORRUPT_PAGE(pCur->pPage);
     }
   }
   return SQLITE_OK;
@@ -79121,7 +79599,7 @@ static int balance(BtCursor *pCur){
       /* The page being written is not a root page, and there is currently
       ** more than one reference to it. This only happens if the page is one
       ** of its own ancestor pages. Corruption. */
-      rc = SQLITE_CORRUPT_BKPT;
+      rc = SQLITE_CORRUPT_PAGE(pPage);
     }else{
       MemPage * const pParent = pCur->apPage[iPage-1];
       int const iIdx = pCur->aiIdx[iPage-1];
@@ -79285,7 +79763,7 @@ static SQLITE_NOINLINE int btreeOverwriteOverflowCell(
     rc = btreeGetPage(pBt, ovflPgno, &pPage, 0);
     if( rc ) return rc;
     if( sqlite3PagerPageRefcount(pPage->pDbPage)!=1 || pPage->isInit ){
-      rc = SQLITE_CORRUPT_BKPT;
+      rc = SQLITE_CORRUPT_PAGE(pPage);
     }else{
       if( iOffset+ovflPageSize<(u32)nTotal ){
         ovflPgno = get4byte(pPage->aData);
@@ -79313,7 +79791,7 @@ static int btreeOverwriteCell(BtCursor *pCur, const BtreePayload *pX){
   if( pCur->info.pPayload + pCur->info.nLocal > pPage->aDataEnd
    || pCur->info.pPayload < pPage->aData + pPage->cellOffset
   ){
-    return SQLITE_CORRUPT_BKPT;
+    return SQLITE_CORRUPT_PAGE(pPage);
   }
   if( pCur->info.nLocal==nTotal ){
     /* The entire cell is local */
@@ -79394,7 +79872,7 @@ SQLITE_PRIVATE int sqlite3BtreeInsert(
       ** Which can only happen if the SQLITE_NoSchemaError flag was set when
       ** the schema was loaded. This cannot be asserted though, as a user might
       ** set the flag, load the schema, and then unset the flag.  */
-      return SQLITE_CORRUPT_BKPT;
+      return SQLITE_CORRUPT_PGNO(pCur->pgnoRoot);
     }
   }
 
@@ -79517,7 +79995,7 @@ SQLITE_PRIVATE int sqlite3BtreeInsert(
   if( pPage->nFree<0 ){
     if( NEVER(pCur->eState>CURSOR_INVALID) ){
      /* ^^^^^--- due to the moveToRoot() call above */
-      rc = SQLITE_CORRUPT_BKPT;
+      rc = SQLITE_CORRUPT_PAGE(pPage);
     }else{
       rc = btreeComputeFreeSpace(pPage);
     }
@@ -79534,7 +80012,10 @@ SQLITE_PRIVATE int sqlite3BtreeInsert(
   if( flags & BTREE_PREFORMAT ){
     rc = SQLITE_OK;
     szNew = p->pBt->nPreformatSize;
-    if( szNew<4 ) szNew = 4;
+    if( szNew<4 ){
+      szNew = 4;
+      newCell[3] = 0;
+    }
     if( ISAUTOVACUUM(p->pBt) && szNew>pPage->maxLocal ){
       CellInfo info;
       pPage->xParseCell(pPage, newCell, &info);
@@ -79556,7 +80037,7 @@ SQLITE_PRIVATE int sqlite3BtreeInsert(
     CellInfo info;
     assert( idx>=0 );
     if( idx>=pPage->nCell ){
-      return SQLITE_CORRUPT_BKPT;
+      return SQLITE_CORRUPT_PAGE(pPage);
     }
     rc = sqlite3PagerWrite(pPage->pDbPage);
     if( rc ){
@@ -79583,10 +80064,10 @@ SQLITE_PRIVATE int sqlite3BtreeInsert(
       ** necessary to add the PTRMAP_OVERFLOW1 pointer-map entry.  */
       assert( rc==SQLITE_OK ); /* clearCell never fails when nLocal==nPayload */
       if( oldCell < pPage->aData+pPage->hdrOffset+10 ){
-        return SQLITE_CORRUPT_BKPT;
+        return SQLITE_CORRUPT_PAGE(pPage);
       }
       if( oldCell+szNew > pPage->aDataEnd ){
-        return SQLITE_CORRUPT_BKPT;
+        return SQLITE_CORRUPT_PAGE(pPage);
       }
       memcpy(oldCell, newCell, szNew);
       return SQLITE_OK;
@@ -79596,7 +80077,7 @@ SQLITE_PRIVATE int sqlite3BtreeInsert(
   }else if( loc<0 && pPage->nCell>0 ){
     assert( pPage->leaf );
     idx = ++pCur->ix;
-    pCur->curFlags &= ~BTCF_ValidNKey;
+    pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl);
   }else{
     assert( pPage->leaf );
   }
@@ -79626,7 +80107,7 @@ SQLITE_PRIVATE int sqlite3BtreeInsert(
   */
   if( pPage->nOverflow ){
     assert( rc==SQLITE_OK );
-    pCur->curFlags &= ~(BTCF_ValidNKey);
+    pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl);
     rc = balance(pCur);
 
     /* Must make sure nOverflow is reset to zero even if the balance()
@@ -79688,7 +80169,7 @@ SQLITE_PRIVATE int sqlite3BtreeTransferRow(BtCursor *pDest, BtCursor *pSrc, i64
   nIn = pSrc->info.nLocal;
   aIn = pSrc->info.pPayload;
   if( aIn+nIn>pSrc->pPage->aDataEnd ){
-    return SQLITE_CORRUPT_BKPT;
+    return SQLITE_CORRUPT_PAGE(pSrc->pPage);
   }
   nRem = pSrc->info.nPayload;
   if( nIn==nRem && nIn<pDest->pPage->maxLocal ){
@@ -79713,7 +80194,7 @@ SQLITE_PRIVATE int sqlite3BtreeTransferRow(BtCursor *pDest, BtCursor *pSrc, i64
 
     if( nRem>nIn ){
       if( aIn+nIn+4>pSrc->pPage->aDataEnd ){
-        return SQLITE_CORRUPT_BKPT;
+        return SQLITE_CORRUPT_PAGE(pSrc->pPage);
       }
       ovflIn = get4byte(&pSrc->info.pPayload[nIn]);
     }
@@ -79809,7 +80290,7 @@ SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){
       assert( rc!=SQLITE_OK || CORRUPT_DB || pCur->eState==CURSOR_VALID );
       if( rc || pCur->eState!=CURSOR_VALID ) return rc;
     }else{
-      return SQLITE_CORRUPT_BKPT;
+      return SQLITE_CORRUPT_PGNO(pCur->pgnoRoot);
     }
   }
   assert( pCur->eState==CURSOR_VALID );
@@ -79818,14 +80299,14 @@ SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){
   iCellIdx = pCur->ix;
   pPage = pCur->pPage;
   if( pPage->nCell<=iCellIdx ){
-    return SQLITE_CORRUPT_BKPT;
+    return SQLITE_CORRUPT_PAGE(pPage);
   }
   pCell = findCell(pPage, iCellIdx);
   if( pPage->nFree<0 && btreeComputeFreeSpace(pPage) ){
-    return SQLITE_CORRUPT_BKPT;
+    return SQLITE_CORRUPT_PAGE(pPage);
   }
   if( pCell<&pPage->aCellIdx[pPage->nCell] ){
-    return SQLITE_CORRUPT_BKPT;
+    return SQLITE_CORRUPT_PAGE(pPage);
   }
 
   /* If the BTREE_SAVEPOSITION bit is on, then the cursor position must
@@ -79916,7 +80397,7 @@ SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){
       n = pCur->pPage->pgno;
     }
     pCell = findCell(pLeaf, pLeaf->nCell-1);
-    if( pCell<&pLeaf->aData[4] ) return SQLITE_CORRUPT_BKPT;
+    if( pCell<&pLeaf->aData[4] ) return SQLITE_CORRUPT_PAGE(pLeaf);
     nCell = pLeaf->xCellSize(pLeaf, pCell);
     assert( MX_CELL_SIZE(pBt) >= nCell );
     pTmp = pBt->pTmpSpace;
@@ -80032,7 +80513,7 @@ static int btreeCreateTable(Btree *p, Pgno *piTable, int createTabFlags){
     */
     sqlite3BtreeGetMeta(p, BTREE_LARGEST_ROOT_PAGE, &pgnoRoot);
     if( pgnoRoot>btreePagecount(pBt) ){
-      return SQLITE_CORRUPT_BKPT;
+      return SQLITE_CORRUPT_PGNO(pgnoRoot);
     }
     pgnoRoot++;
 
@@ -80080,7 +80561,7 @@ static int btreeCreateTable(Btree *p, Pgno *piTable, int createTabFlags){
       }
       rc = ptrmapGet(pBt, pgnoRoot, &eType, &iPtrPage);
       if( eType==PTRMAP_ROOTPAGE || eType==PTRMAP_FREEPAGE ){
-        rc = SQLITE_CORRUPT_BKPT;
+        rc = SQLITE_CORRUPT_PGNO(pgnoRoot);
       }
       if( rc!=SQLITE_OK ){
         releasePage(pRoot);
@@ -80170,14 +80651,14 @@ static int clearDatabasePage(
 
   assert( sqlite3_mutex_held(pBt->mutex) );
   if( pgno>btreePagecount(pBt) ){
-    return SQLITE_CORRUPT_BKPT;
+    return SQLITE_CORRUPT_PGNO(pgno);
   }
   rc = getAndInitPage(pBt, pgno, &pPage, 0);
   if( rc ) return rc;
   if( (pBt->openFlags & BTREE_SINGLE)==0
    && sqlite3PagerPageRefcount(pPage->pDbPage) != (1 + (pgno==1))
   ){
-    rc = SQLITE_CORRUPT_BKPT;
+    rc = SQLITE_CORRUPT_PAGE(pPage);
     goto cleardatabasepage_out;
   }
   hdr = pPage->hdrOffset;
@@ -80281,7 +80762,7 @@ static int btreeDropTable(Btree *p, Pgno iTable, int *piMoved){
   assert( p->inTrans==TRANS_WRITE );
   assert( iTable>=2 );
   if( iTable>btreePagecount(pBt) ){
-    return SQLITE_CORRUPT_BKPT;
+    return SQLITE_CORRUPT_PGNO(iTable);
   }
 
   rc = sqlite3BtreeClearTable(p, iTable, 0);
@@ -80875,6 +81356,9 @@ static int checkTreePage(
   ** number of cells on the page. */
   nCell = get2byte(&data[hdr+3]);
   assert( pPage->nCell==nCell );
+  if( pPage->leaf || pPage->intKey==0 ){
+    pCheck->nRow += nCell;
+  }
 
   /* EVIDENCE-OF: R-23882-45353 The cell pointer array of a b-tree page
   ** immediately follows the b-tree page header. */
@@ -80986,6 +81470,7 @@ static int checkTreePage(
         btreeHeapInsert(heap, (pc<<16)|(pc+size-1));
       }
     }
+    assert( heap!=0 );
     /* Add the freeblocks to the min-heap
     **
     ** EVIDENCE-OF: R-20690-50594 The second field of the b-tree page header
@@ -81085,6 +81570,7 @@ SQLITE_PRIVATE int sqlite3BtreeIntegrityCheck(
   sqlite3 *db,  /* Database connection that is running the check */
   Btree *p,     /* The btree to be checked */
   Pgno *aRoot,  /* An array of root pages numbers for individual trees */
+  Mem *aCnt,    /* Memory cells to write counts for each tree to */
   int nRoot,    /* Number of entries in aRoot[] */
   int mxErr,    /* Stop reporting errors after this many */
   int *pnErr,   /* OUT: Write number of errors seen to this variable */
@@ -81098,7 +81584,9 @@ SQLITE_PRIVATE int sqlite3BtreeIntegrityCheck(
   int bPartial = 0;            /* True if not checking all btrees */
   int bCkFreelist = 1;         /* True to scan the freelist */
   VVA_ONLY( int nRef );
+
   assert( nRoot>0 );
+  assert( aCnt!=0 );
 
   /* aRoot[0]==0 means this is a partial check */
   if( aRoot[0]==0 ){
@@ -81171,15 +81659,18 @@ SQLITE_PRIVATE int sqlite3BtreeIntegrityCheck(
   testcase( pBt->db->flags & SQLITE_CellSizeCk );
   pBt->db->flags &= ~(u64)SQLITE_CellSizeCk;
   for(i=0; (int)i<nRoot && sCheck.mxErr; i++){
-    i64 notUsed;
-    if( aRoot[i]==0 ) continue;
+    sCheck.nRow = 0;
+    if( aRoot[i] ){
+      i64 notUsed;
 #ifndef SQLITE_OMIT_AUTOVACUUM
-    if( pBt->autoVacuum && aRoot[i]>1 && !bPartial ){
-      checkPtrmap(&sCheck, aRoot[i], PTRMAP_ROOTPAGE, 0);
-    }
+      if( pBt->autoVacuum && aRoot[i]>1 && !bPartial ){
+        checkPtrmap(&sCheck, aRoot[i], PTRMAP_ROOTPAGE, 0);
+      }
 #endif
-    sCheck.v0 = aRoot[i];
-    checkTreePage(&sCheck, aRoot[i], &notUsed, LARGEST_INT64);
+      sCheck.v0 = aRoot[i];
+      checkTreePage(&sCheck, aRoot[i], &notUsed, LARGEST_INT64);
+    }
+    sqlite3MemSetArrayInt64(aCnt, i, sCheck.nRow);
   }
   pBt->db->flags = savedDbFlags;
 
@@ -83234,6 +83725,13 @@ SQLITE_PRIVATE void sqlite3VdbeMemSetInt64(Mem *pMem, i64 val){
   }
 }
 
+/*
+** Set the iIdx'th entry of array aMem[] to contain integer value val.
+*/
+SQLITE_PRIVATE void sqlite3MemSetArrayInt64(sqlite3_value *aMem, int iIdx, i64 val){
+  sqlite3VdbeMemSetInt64(&aMem[iIdx], val);
+}
+
 /* A no-op destructor */
 SQLITE_PRIVATE void sqlite3NoopDestructor(void *p){ UNUSED_PARAMETER(p); }
 
@@ -83922,14 +84420,20 @@ static int valueFromExpr(
   }
 
   /* Handle negative integers in a single step.  This is needed in the
-  ** case when the value is -9223372036854775808.
-  */
-  if( op==TK_UMINUS
-   && (pExpr->pLeft->op==TK_INTEGER || pExpr->pLeft->op==TK_FLOAT) ){
-    pExpr = pExpr->pLeft;
-    op = pExpr->op;
-    negInt = -1;
-    zNeg = "-";
+  ** case when the value is -9223372036854775808. Except - do not do this
+  ** for hexadecimal literals.  */
+  if( op==TK_UMINUS ){
+    Expr *pLeft = pExpr->pLeft;
+    if( (pLeft->op==TK_INTEGER || pLeft->op==TK_FLOAT) ){
+      if( ExprHasProperty(pLeft, EP_IntValue)
+       || pLeft->u.zToken[0]!='0' || (pLeft->u.zToken[1] & ~0x20)!='X'
+      ){
+        pExpr = pLeft;
+        op = pExpr->op;
+        negInt = -1;
+        zNeg = "-";
+      }
+    }
   }
 
   if( op==TK_STRING || op==TK_FLOAT || op==TK_INTEGER ){
@@ -83938,12 +84442,26 @@ static int valueFromExpr(
     if( ExprHasProperty(pExpr, EP_IntValue) ){
       sqlite3VdbeMemSetInt64(pVal, (i64)pExpr->u.iValue*negInt);
     }else{
-      zVal = sqlite3MPrintf(db, "%s%s", zNeg, pExpr->u.zToken);
-      if( zVal==0 ) goto no_mem;
-      sqlite3ValueSetStr(pVal, -1, zVal, SQLITE_UTF8, SQLITE_DYNAMIC);
+      i64 iVal;
+      if( op==TK_INTEGER && 0==sqlite3DecOrHexToI64(pExpr->u.zToken, &iVal) ){
+        sqlite3VdbeMemSetInt64(pVal, iVal*negInt);
+      }else{
+        zVal = sqlite3MPrintf(db, "%s%s", zNeg, pExpr->u.zToken);
+        if( zVal==0 ) goto no_mem;
+        sqlite3ValueSetStr(pVal, -1, zVal, SQLITE_UTF8, SQLITE_DYNAMIC);
+      }
     }
-    if( (op==TK_INTEGER || op==TK_FLOAT ) && affinity==SQLITE_AFF_BLOB ){
-      sqlite3ValueApplyAffinity(pVal, SQLITE_AFF_NUMERIC, SQLITE_UTF8);
+    if( affinity==SQLITE_AFF_BLOB ){
+      if( op==TK_FLOAT ){
+        assert( pVal && pVal->z && pVal->flags==(MEM_Str|MEM_Term) );
+        sqlite3AtoF(pVal->z, &pVal->u.r, pVal->n, SQLITE_UTF8);
+        pVal->flags = MEM_Real;
+      }else if( op==TK_INTEGER ){
+        /* This case is required by -9223372036854775808 and other strings
+        ** that look like integers but cannot be handled by the
+        ** sqlite3DecOrHexToI64() call above.  */
+        sqlite3ValueApplyAffinity(pVal, SQLITE_AFF_NUMERIC, SQLITE_UTF8);
+      }
     }else{
       sqlite3ValueApplyAffinity(pVal, affinity, SQLITE_UTF8);
     }
@@ -84213,17 +84731,17 @@ SQLITE_PRIVATE int sqlite3Stat4Column(
   sqlite3_value **ppVal           /* OUT: Extracted value */
 ){
   u32 t = 0;                      /* a column type code */
-  int nHdr;                       /* Size of the header in the record */
-  int iHdr;                       /* Next unread header byte */
-  int iField;                     /* Next unread data byte */
-  int szField = 0;                /* Size of the current data field */
+  u32 nHdr;                       /* Size of the header in the record */
+  u32 iHdr;                       /* Next unread header byte */
+  i64 iField;                     /* Next unread data byte */
+  u32 szField = 0;                /* Size of the current data field */
   int i;                          /* Column index */
   u8 *a = (u8*)pRec;              /* Typecast byte array */
   Mem *pMem = *ppVal;             /* Write result into this Mem object */
 
   assert( iCol>0 );
   iHdr = getVarint32(a, nHdr);
-  if( nHdr>nRec || iHdr>=nHdr ) return SQLITE_CORRUPT_BKPT;
+  if( nHdr>(u32)nRec || iHdr>=nHdr ) return SQLITE_CORRUPT_BKPT;
   iField = nHdr;
   for(i=0; i<=iCol; i++){
     iHdr += getVarint32(&a[iHdr], t);
@@ -85258,6 +85776,15 @@ static void resolveP2Values(Vdbe *p, int *pMaxFuncArgs){
             assert( aLabel!=0 );  /* True because of tag-20230419-1 */
             pOp->p2 = aLabel[ADDR(pOp->p2)];
           }
+
+          /* OPFLG_JUMP opcodes never have P2==0, though OPFLG_JUMP0 opcodes
+          ** might */
+          assert( pOp->p2>0
+                  || (sqlite3OpcodeProperty[pOp->opcode] & OPFLG_JUMP0)!=0 );
+
+          /* Jumps never go off the end of the bytecode array */
+          assert( pOp->p2<p->nOp
+                  || (sqlite3OpcodeProperty[pOp->opcode] & OPFLG_JUMP)==0 );
           break;
         }
       }
@@ -87665,7 +88192,7 @@ SQLITE_PRIVATE int sqlite3VdbeHalt(Vdbe *p){
 
     /* Check for immediate foreign key violations. */
     if( p->rc==SQLITE_OK || (p->errorAction==OE_Fail && !isSpecialError) ){
-      sqlite3VdbeCheckFk(p, 0);
+      (void)sqlite3VdbeCheckFk(p, 0);
     }
 
     /* If the auto-commit flag is set and this is the only active writer
@@ -88379,6 +88906,23 @@ static void serialGet(
     pMem->flags = IsNaN(x) ? MEM_Null : MEM_Real;
   }
 }
+static int serialGet7(
+  const unsigned char *buf,     /* Buffer to deserialize from */
+  Mem *pMem                     /* Memory cell to write value into */
+){
+  u64 x = FOUR_BYTE_UINT(buf);
+  u32 y = FOUR_BYTE_UINT(buf+4);
+  x = (x<<32) + y;
+  assert( sizeof(x)==8 && sizeof(pMem->u.r)==8 );
+  swapMixedEndianFloat(x);
+  memcpy(&pMem->u.r, &x, sizeof(x));
+  if( IsNaN(x) ){
+    pMem->flags = MEM_Null;
+    return 1;
+  }
+  pMem->flags = MEM_Real;
+  return 0;
+}
 SQLITE_PRIVATE void sqlite3VdbeSerialGet(
   const unsigned char *buf,     /* Buffer to deserialize from */
   u32 serial_type,              /* Serial type to deserialize */
@@ -88818,17 +89362,15 @@ SQLITE_PRIVATE int sqlite3IntFloatCompare(i64 i, double r){
     return (x<r) ? -1 : (x>r);
   }else{
     i64 y;
-    double s;
     if( r<-9223372036854775808.0 ) return +1;
     if( r>=9223372036854775808.0 ) return -1;
     y = (i64)r;
     if( i<y ) return -1;
     if( i>y ) return +1;
-    s = (double)i;
-    testcase( doubleLt(s,r) );
-    testcase( doubleLt(r,s) );
-    testcase( doubleEq(r,s) );
-    return (s<r) ? -1 : (s>r);
+    testcase( doubleLt(((double)i),r) );
+    testcase( doubleLt(r,((double)i)) );
+    testcase( doubleEq(r,((double)i)) );
+    return (((double)i)<r) ? -1 : (((double)i)>r);
   }
 }
 
@@ -89058,7 +89600,7 @@ SQLITE_PRIVATE int sqlite3VdbeRecordCompareWithSkip(
       }else if( serial_type==0 ){
         rc = -1;
       }else if( serial_type==7 ){
-        sqlite3VdbeSerialGet(&aKey1[d1], serial_type, &mem1);
+        serialGet7(&aKey1[d1], &mem1);
         rc = -sqlite3IntFloatCompare(pRhs->u.i, mem1.u.r);
       }else{
         i64 lhs = vdbeRecordDecodeInt(serial_type, &aKey1[d1]);
@@ -89083,14 +89625,18 @@ SQLITE_PRIVATE int sqlite3VdbeRecordCompareWithSkip(
       }else if( serial_type==0 ){
         rc = -1;
       }else{
-        sqlite3VdbeSerialGet(&aKey1[d1], serial_type, &mem1);
         if( serial_type==7 ){
-          if( mem1.u.r<pRhs->u.r ){
+          if( serialGet7(&aKey1[d1], &mem1) ){
+            rc = -1;  /* mem1 is a NaN */
+          }else if( mem1.u.r<pRhs->u.r ){
             rc = -1;
           }else if( mem1.u.r>pRhs->u.r ){
             rc = +1;
+          }else{
+            assert( rc==0 );
           }
         }else{
+          sqlite3VdbeSerialGet(&aKey1[d1], serial_type, &mem1);
           rc = sqlite3IntFloatCompare(mem1.u.i, pRhs->u.r);
         }
       }
@@ -89160,7 +89706,14 @@ SQLITE_PRIVATE int sqlite3VdbeRecordCompareWithSkip(
     /* RHS is null */
     else{
       serial_type = aKey1[idx1];
-      rc = (serial_type!=0 && serial_type!=10);
+      if( serial_type==0
+       || serial_type==10
+       || (serial_type==7 && serialGet7(&aKey1[d1], &mem1)!=0)
+      ){
+        assert( rc==0 );
+      }else{
+        rc = 1;
+      }
     }
 
     if( rc!=0 ){
@@ -92225,7 +92778,6 @@ SQLITE_API int sqlite3_stmt_scanstatus_v2(
   }
   if( flags & SQLITE_SCANSTAT_COMPLEX ){
     idx = iScan;
-    pScan = &p->aScan[idx];
   }else{
     /* If the COMPLEX flag is clear, then this function must ignore any
     ** ScanStatus structures with ScanStatus.addrLoop set to 0. */
@@ -92238,6 +92790,8 @@ SQLITE_API int sqlite3_stmt_scanstatus_v2(
     }
   }
   if( idx>=p->nScan ) return 1;
+  assert( pScan==0 || pScan==&p->aScan[idx] );
+  pScan = &p->aScan[idx];
 
   switch( iScanStatusOp ){
     case SQLITE_SCANSTAT_NLOOP: {
@@ -93686,7 +94240,7 @@ case OP_Return: {           /* in1 */
 **
 ** See also: EndCoroutine
 */
-case OP_InitCoroutine: {     /* jump */
+case OP_InitCoroutine: {     /* jump0 */
   assert( pOp->p1>0 &&  pOp->p1<=(p->nMem+1 - p->nCursor) );
   assert( pOp->p2>=0 && pOp->p2<p->nOp );
   assert( pOp->p3>=0 && pOp->p3<p->nOp );
@@ -93709,7 +94263,9 @@ case OP_InitCoroutine: {     /* jump */
 **
 ** The instruction at the address in register P1 is a Yield.
 ** Jump to the P2 parameter of that Yield.
-** After the jump, register P1 becomes undefined.
+** After the jump, the value register P1 is left with a value
+** such that subsequent OP_Yields go back to the this same
+** OP_EndCoroutine instruction.
 **
 ** See also: InitCoroutine
 */
@@ -93721,8 +94277,8 @@ case OP_EndCoroutine: {           /* in1 */
   pCaller = &aOp[pIn1->u.i];
   assert( pCaller->opcode==OP_Yield );
   assert( pCaller->p2>=0 && pCaller->p2<p->nOp );
+  pIn1->u.i = (int)(pOp - p->aOp) - 1;
   pOp = &aOp[pCaller->p2 - 1];
-  pIn1->flags = MEM_Undefined;
   break;
 }
 
@@ -93739,7 +94295,7 @@ case OP_EndCoroutine: {           /* in1 */
 **
 ** See also: InitCoroutine
 */
-case OP_Yield: {            /* in1, jump */
+case OP_Yield: {            /* in1, jump0 */
   int pcDest;
   pIn1 = &aMem[pOp->p1];
   assert( VdbeMemDynamic(pIn1)==0 );
@@ -94069,19 +94625,15 @@ case OP_Blob: {                /* out2 */
   break;
 }
 
-/* Opcode: Variable P1 P2 * P4 *
-** Synopsis: r[P2]=parameter(P1,P4)
+/* Opcode: Variable P1 P2 * * *
+** Synopsis: r[P2]=parameter(P1)
 **
 ** Transfer the values of bound parameter P1 into register P2
-**
-** If the parameter is named, then its name appears in P4.
-** The P4 value is used by sqlite3_bind_parameter_name().
 */
 case OP_Variable: {            /* out2 */
   Mem *pVar;       /* Value being transferred */
 
   assert( pOp->p1>0 && pOp->p1<=p->nVar );
-  assert( pOp->p4.z==0 || pOp->p4.z==sqlite3VListNumToName(p->pVList,pOp->p1) );
   pVar = &p->aVar[pOp->p1 - 1];
   if( sqlite3VdbeMemTooBig(pVar) ){
     goto too_big;
@@ -94602,7 +95154,7 @@ case OP_AddImm: {            /* in1 */
 ** without data loss, then jump immediately to P2, or if P2==0
 ** raise an SQLITE_MISMATCH exception.
 */
-case OP_MustBeInt: {            /* jump, in1 */
+case OP_MustBeInt: {            /* jump0, in1 */
   pIn1 = &aMem[pOp->p1];
   if( (pIn1->flags & MEM_Int)==0 ){
     applyAffinity(pIn1, SQLITE_AFF_NUMERIC, encoding);
@@ -94643,7 +95195,7 @@ case OP_RealAffinity: {                  /* in1 */
 }
 #endif
 
-#ifndef SQLITE_OMIT_CAST
+#if !defined(SQLITE_OMIT_CAST) && !defined(SQLITE_OMIT_ANALYZE)
 /* Opcode: Cast P1 P2 * * *
 ** Synopsis: affinity(r[P1])
 **
@@ -94858,7 +95410,9 @@ case OP_Ge: {             /* same as TK_GE, jump, in1, in3 */
         }
       }
     }else if( affinity==SQLITE_AFF_TEXT && ((flags1 | flags3) & MEM_Str)!=0 ){
-      if( (flags1 & MEM_Str)==0 && (flags1&(MEM_Int|MEM_Real|MEM_IntReal))!=0 ){
+      if( (flags1 & MEM_Str)!=0 ){
+        pIn1->flags &= ~(MEM_Int|MEM_Real|MEM_IntReal);
+      }else if( (flags1&(MEM_Int|MEM_Real|MEM_IntReal))!=0 ){
         testcase( pIn1->flags & MEM_Int );
         testcase( pIn1->flags & MEM_Real );
         testcase( pIn1->flags & MEM_IntReal );
@@ -94867,7 +95421,9 @@ case OP_Ge: {             /* same as TK_GE, jump, in1, in3 */
         flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask);
         if( NEVER(pIn1==pIn3) ) flags3 = flags1 | MEM_Str;
       }
-      if( (flags3 & MEM_Str)==0 && (flags3&(MEM_Int|MEM_Real|MEM_IntReal))!=0 ){
+      if( (flags3 & MEM_Str)!=0 ){
+        pIn3->flags &= ~(MEM_Int|MEM_Real|MEM_IntReal);
+      }else if( (flags3&(MEM_Int|MEM_Real|MEM_IntReal))!=0 ){
         testcase( pIn3->flags & MEM_Int );
         testcase( pIn3->flags & MEM_Real );
         testcase( pIn3->flags & MEM_IntReal );
@@ -96211,11 +96767,16 @@ case OP_MakeRecord: {
         switch( len ){
           default: zPayload[7] = (u8)(v&0xff); v >>= 8;
                    zPayload[6] = (u8)(v&0xff); v >>= 8;
+                   /* no break */ deliberate_fall_through
           case 6:  zPayload[5] = (u8)(v&0xff); v >>= 8;
                    zPayload[4] = (u8)(v&0xff); v >>= 8;
+                   /* no break */ deliberate_fall_through
           case 4:  zPayload[3] = (u8)(v&0xff); v >>= 8;
+                   /* no break */ deliberate_fall_through
           case 3:  zPayload[2] = (u8)(v&0xff); v >>= 8;
+                   /* no break */ deliberate_fall_through
           case 2:  zPayload[1] = (u8)(v&0xff); v >>= 8;
+                   /* no break */ deliberate_fall_through
           case 1:  zPayload[0] = (u8)(v&0xff);
         }
         zPayload += len;
@@ -97134,7 +97695,8 @@ case OP_SequenceTest: {
 ** is the only cursor opcode that works with a pseudo-table.
 **
 ** P3 is the number of fields in the records that will be stored by
-** the pseudo-table.
+** the pseudo-table.  If P2 is 0 or negative then the pseudo-cursor
+** will return NULL for every column.
 */
 case OP_OpenPseudo: {
   VdbeCursor *pCx;
@@ -97277,10 +97839,10 @@ case OP_ColumnsUsed: {
 **
 ** See also: Found, NotFound, SeekGt, SeekGe, SeekLt
 */
-case OP_SeekLT:         /* jump, in3, group, ncycle */
-case OP_SeekLE:         /* jump, in3, group, ncycle */
-case OP_SeekGE:         /* jump, in3, group, ncycle */
-case OP_SeekGT: {       /* jump, in3, group, ncycle */
+case OP_SeekLT:         /* jump0, in3, group, ncycle */
+case OP_SeekLE:         /* jump0, in3, group, ncycle */
+case OP_SeekGE:         /* jump0, in3, group, ncycle */
+case OP_SeekGT: {       /* jump0, in3, group, ncycle */
   int res;           /* Comparison result */
   int oc;            /* Opcode */
   VdbeCursor *pC;    /* The cursor to seek */
@@ -97947,7 +98509,7 @@ case OP_Found: {        /* jump, in3, ncycle */
 **
 ** See also: Found, NotFound, NoConflict, SeekRowid
 */
-case OP_SeekRowid: {        /* jump, in3, ncycle */
+case OP_SeekRowid: {        /* jump0, in3, ncycle */
   VdbeCursor *pC;
   BtCursor *pCrsr;
   int res;
@@ -98706,7 +99268,7 @@ case OP_NullRow: {
 ** configured to use Prev, not Next.
 */
 case OP_SeekEnd:             /* ncycle */
-case OP_Last: {              /* jump, ncycle */
+case OP_Last: {              /* jump0, ncycle */
   VdbeCursor *pC;
   BtCursor *pCrsr;
   int res;
@@ -98740,28 +99302,38 @@ case OP_Last: {              /* jump, ncycle */
   break;
 }
 
-/* Opcode: IfSmaller P1 P2 P3 * *
+/* Opcode: IfSizeBetween P1 P2 P3 P4 *
 **
-** Estimate the number of rows in the table P1.  Jump to P2 if that
-** estimate is less than approximately 2**(0.1*P3).
+** Let N be the approximate number of rows in the table or index
+** with cursor P1 and let X be 10*log2(N) if N is positive or -1
+** if N is zero.
+**
+** Jump to P2 if X is in between P3 and P4, inclusive.
 */
-case OP_IfSmaller: {        /* jump */
+case OP_IfSizeBetween: {        /* jump */
   VdbeCursor *pC;
   BtCursor *pCrsr;
   int res;
   i64 sz;
 
   assert( pOp->p1>=0 && pOp->p1<p->nCursor );
+  assert( pOp->p4type==P4_INT32 );
+  assert( pOp->p3>=-1 && pOp->p3<=640*2 );
+  assert( pOp->p4.i>=-1 && pOp->p4.i<=640*2 );
   pC = p->apCsr[pOp->p1];
   assert( pC!=0 );
   pCrsr = pC->uc.pCursor;
   assert( pCrsr );
   rc = sqlite3BtreeFirst(pCrsr, &res);
   if( rc ) goto abort_due_to_error;
-  if( res==0 ){
+  if( res!=0 ){
+    sz = -1;  /* -Infinity encoding */
+  }else{
     sz = sqlite3BtreeRowCountEst(pCrsr);
-    if( ALWAYS(sz>=0) && sqlite3LogEst((u64)sz)<pOp->p3 ) res = 1;
+    assert( sz>0 );
+    sz = sqlite3LogEst((u64)sz);
   }
+  res = sz>=pOp->p3 && sz<=pOp->p4.i;
   VdbeBranchTaken(res!=0,2);
   if( res ) goto jump_to_p2;
   break;
@@ -98814,7 +99386,7 @@ case OP_Sort: {        /* jump ncycle */
 ** from the beginning toward the end.  In other words, the cursor is
 ** configured to use Next, not Prev.
 */
-case OP_Rewind: {        /* jump, ncycle */
+case OP_Rewind: {        /* jump0, ncycle */
   VdbeCursor *pC;
   BtCursor *pCrsr;
   int res;
@@ -99461,11 +100033,18 @@ case OP_CreateBtree: {          /* out2 */
   break;
 }
 
-/* Opcode: SqlExec * * * P4 *
+/* Opcode: SqlExec P1 P2 * P4 *
 **
 ** Run the SQL statement or statements specified in the P4 string.
-** Disable Auth and Trace callbacks while those statements are running if
-** P1 is true.
+**
+** The P1 parameter is a bitmask of options:
+**
+**    0x0001     Disable Auth and Trace callbacks while the statements
+**               in P4 are running.
+**
+**    0x0002     Set db->nAnalysisLimit to P2 while the statements in
+**               P4 are running.
+**
 */
 case OP_SqlExec: {
   char *zErr;
@@ -99473,6 +100052,7 @@ case OP_SqlExec: {
   sqlite3_xauth xAuth;
 #endif
   u8 mTrace;
+  int savedAnalysisLimit;
 
   sqlite3VdbeIncrWriteCounter(p, 0);
   db->nSqlExec++;
@@ -99481,18 +100061,23 @@ case OP_SqlExec: {
   xAuth = db->xAuth;
 #endif
   mTrace = db->mTrace;
-  if( pOp->p1 ){
+  savedAnalysisLimit = db->nAnalysisLimit;
+  if( pOp->p1 & 0x0001 ){
 #ifndef SQLITE_OMIT_AUTHORIZATION
     db->xAuth = 0;
 #endif
     db->mTrace = 0;
   }
+  if( pOp->p1 & 0x0002 ){
+    db->nAnalysisLimit = pOp->p2;
+  }
   rc = sqlite3_exec(db, pOp->p4.z, 0, 0, &zErr);
   db->nSqlExec--;
 #ifndef SQLITE_OMIT_AUTHORIZATION
   db->xAuth = xAuth;
 #endif
   db->mTrace = mTrace;
+  db->nAnalysisLimit = savedAnalysisLimit;
   if( zErr || rc ){
     sqlite3VdbeError(p, "%s", zErr);
     sqlite3_free(zErr);
@@ -99644,11 +100229,11 @@ case OP_DropTrigger: {
 /* Opcode: IntegrityCk P1 P2 P3 P4 P5
 **
 ** Do an analysis of the currently open database.  Store in
-** register P1 the text of an error message describing any problems.
-** If no problems are found, store a NULL in register P1.
+** register (P1+1) the text of an error message describing any problems.
+** If no problems are found, store a NULL in register (P1+1).
 **
-** The register P3 contains one less than the maximum number of allowed errors.
-** At most reg(P3) errors will be reported.
+** The register (P1) contains one less than the maximum number of allowed
+** errors.  At most reg(P1) errors will be reported.
 ** In other words, the analysis stops as soon as reg(P1) errors are
 ** seen.  Reg(P1) is updated with the number of errors remaining.
 **
@@ -99668,19 +100253,21 @@ case OP_IntegrityCk: {
   Mem *pnErr;     /* Register keeping track of errors remaining */
 
   assert( p->bIsReader );
+  assert( pOp->p4type==P4_INTARRAY );
   nRoot = pOp->p2;
   aRoot = pOp->p4.ai;
   assert( nRoot>0 );
+  assert( aRoot!=0 );
   assert( aRoot[0]==(Pgno)nRoot );
-  assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );
-  pnErr = &aMem[pOp->p3];
+  assert( pOp->p1>0 && (pOp->p1+1)<=(p->nMem+1 - p->nCursor) );
+  pnErr = &aMem[pOp->p1];
   assert( (pnErr->flags & MEM_Int)!=0 );
   assert( (pnErr->flags & (MEM_Str|MEM_Blob))==0 );
-  pIn1 = &aMem[pOp->p1];
+  pIn1 = &aMem[pOp->p1+1];
   assert( pOp->p5<db->nDb );
   assert( DbMaskTest(p->btreeMask, pOp->p5) );
-  rc = sqlite3BtreeIntegrityCheck(db, db->aDb[pOp->p5].pBt, &aRoot[1], nRoot,
-                                 (int)pnErr->u.i+1, &nErr, &z);
+  rc = sqlite3BtreeIntegrityCheck(db, db->aDb[pOp->p5].pBt, &aRoot[1],
+      &aMem[pOp->p3], nRoot, (int)pnErr->u.i+1, &nErr, &z);
   sqlite3VdbeMemSetNull(pIn1);
   if( nErr==0 ){
     assert( z==0 );
@@ -99807,7 +100394,9 @@ case OP_RowSetTest: {                     /* jump, in1, in3 */
 ** P1 contains the address of the memory cell that contains the first memory
 ** cell in an array of values used as arguments to the sub-program. P2
 ** contains the address to jump to if the sub-program throws an IGNORE
-** exception using the RAISE() function. Register P3 contains the address
+** exception using the RAISE() function. P2 might be zero, if there is
+** no possibility that an IGNORE exception will be raised.
+** Register P3 contains the address
 ** of a memory cell in this (the parent) VM that is used to allocate the
 ** memory required by the sub-vdbe at runtime.
 **
@@ -99815,7 +100404,7 @@ case OP_RowSetTest: {                     /* jump, in1, in3 */
 **
 ** If P5 is non-zero, then recursive program invocation is enabled.
 */
-case OP_Program: {        /* jump */
+case OP_Program: {        /* jump0 */
   int nMem;               /* Number of memory registers for sub-program */
   int nByte;              /* Bytes of runtime space required for sub-program */
   Mem *pRt;               /* Register to allocate runtime space */
@@ -101364,7 +101953,7 @@ case OP_Filter: {          /* jump */
 ** error is encountered.
 */
 case OP_Trace:
-case OP_Init: {          /* jump */
+case OP_Init: {          /* jump0 */
   int i;
 #ifndef SQLITE_OMIT_TRACE
   char *zTrace;
@@ -105265,10 +105854,10 @@ static int bytecodevtabColumn(
 
 #ifdef SQLITE_ENABLE_STMT_SCANSTATUS
     case 9:     /* nexec */
-      sqlite3_result_int(ctx, pOp->nExec);
+      sqlite3_result_int64(ctx, pOp->nExec);
       break;
     case 10:    /* ncycle */
-      sqlite3_result_int(ctx, pOp->nCycle);
+      sqlite3_result_int64(ctx, pOp->nCycle);
       break;
 #else
     case 9:     /* nexec */
@@ -106212,6 +106801,8 @@ static void resolveAlias(
   assert( iCol>=0 && iCol<pEList->nExpr );
   pOrig = pEList->a[iCol].pExpr;
   assert( pOrig!=0 );
+  assert( !ExprHasProperty(pExpr, EP_Reduced|EP_TokenOnly) );
+  if( pExpr->pAggInfo ) return;
   db = pParse->db;
   pDup = sqlite3ExprDup(db, pOrig, 0);
   if( db->mallocFailed ){
@@ -106410,7 +107001,7 @@ static int lookupName(
   Parse *pParse,       /* The parsing context */
   const char *zDb,     /* Name of the database containing table, or NULL */
   const char *zTab,    /* Name of table containing column, or NULL */
-  const char *zCol,    /* Name of the column. */
+  const Expr *pRight,  /* Name of the column. */
   NameContext *pNC,    /* The name context used to resolve the name */
   Expr *pExpr          /* Make this EXPR node point to the selected column */
 ){
@@ -106427,6 +107018,7 @@ static int lookupName(
   Table *pTab = 0;                  /* Table holding the row */
   Column *pCol;                     /* A column of pTab */
   ExprList *pFJMatch = 0;           /* Matches for FULL JOIN .. USING */
+  const char *zCol = pRight->u.zToken;
 
   assert( pNC );     /* the name context cannot be NULL. */
   assert( zCol );    /* The Z in X.Y.Z cannot be NULL */
@@ -106599,8 +107191,37 @@ static int lookupName(
           }
         }
         if( 0==cnt && VisibleRowid(pTab) ){
+          /* pTab is a potential ROWID match.  Keep track of it and match
+          ** the ROWID later if that seems appropriate.  (Search for "cntTab"
+          ** to find related code.)  Only allow a ROWID match if there is
+          ** a single ROWID match candidate.
+          */
+#ifdef SQLITE_ALLOW_ROWID_IN_VIEW
+          /* In SQLITE_ALLOW_ROWID_IN_VIEW mode, allow a ROWID match
+          ** if there is a single VIEW candidate or if there is a single
+          ** non-VIEW candidate plus multiple VIEW candidates.  In other
+          ** words non-VIEW candidate terms take precedence over VIEWs.
+          */
+          if( cntTab==0
+           || (cntTab==1
+               && ALWAYS(pMatch!=0)
+               && ALWAYS(pMatch->pTab!=0)
+               && (pMatch->pTab->tabFlags & TF_Ephemeral)!=0
+               && (pTab->tabFlags & TF_Ephemeral)==0)
+          ){
+            cntTab = 1;
+            pMatch = pItem;
+          }else{
+            cntTab++;
+          }
+#else
+          /* The (much more common) non-SQLITE_ALLOW_ROWID_IN_VIEW case is
+          ** simpler since we require exactly one candidate, which will
+          ** always be a non-VIEW
+          */
           cntTab++;
           pMatch = pItem;
+#endif
         }
       }
       if( pMatch ){
@@ -106629,7 +107250,8 @@ static int lookupName(
         if( pParse->bReturning ){
           if( (pNC->ncFlags & NC_UBaseReg)!=0
            && ALWAYS(zTab==0
-                     || sqlite3StrICmp(zTab,pParse->pTriggerTab->zName)==0)
+                     || sqlite3StrICmp(zTab,pParse->pTriggerTab->zName)==0
+                     || isValidSchemaTableName(zTab, pParse->pTriggerTab, 0))
           ){
             pExpr->iTable = op!=TK_DELETE;
             pTab = pParse->pTriggerTab;
@@ -106726,13 +107348,18 @@ static int lookupName(
     ** Perhaps the name is a reference to the ROWID
     */
     if( cnt==0
-     && cntTab==1
+     && cntTab>=1
      && pMatch
      && (pNC->ncFlags & (NC_IdxExpr|NC_GenCol))==0
      && sqlite3IsRowid(zCol)
      && ALWAYS(VisibleRowid(pMatch->pTab) || pMatch->fg.isNestedFrom)
     ){
-      cnt = 1;
+      cnt = cntTab;
+#if SQLITE_ALLOW_ROWID_IN_VIEW+0==2
+      if( pMatch->pTab!=0 && IsView(pMatch->pTab) ){
+        eNewExprOp = TK_NULL;
+      }
+#endif
       if( pMatch->fg.isNestedFrom==0 ) pExpr->iColumn = -1;
       pExpr->affExpr = SQLITE_AFF_INTEGER;
     }
@@ -106886,6 +107513,10 @@ static int lookupName(
       sqlite3ErrorMsg(pParse, "%s: %s.%s.%s", zErr, zDb, zTab, zCol);
     }else if( zTab ){
       sqlite3ErrorMsg(pParse, "%s: %s.%s", zErr, zTab, zCol);
+    }else if( cnt==0 && ExprHasProperty(pRight,EP_DblQuoted) ){
+      sqlite3ErrorMsg(pParse, "%s: \"%s\" - should this be a"
+                              " string literal in single-quotes?",
+                              zErr, zCol);
     }else{
       sqlite3ErrorMsg(pParse, "%s: %s", zErr, zCol);
     }
@@ -106919,8 +107550,12 @@ static int lookupName(
   ** If a generated column is referenced, set bits for every column
   ** of the table.
   */
-  if( pExpr->iColumn>=0 && cnt==1 && pMatch!=0 ){
-    pMatch->colUsed |= sqlite3ExprColUsed(pExpr);
+  if( pMatch ){
+    if( pExpr->iColumn>=0 ){
+      pMatch->colUsed |= sqlite3ExprColUsed(pExpr);
+    }else{
+      pMatch->fg.rowidUsed = 1;
+    }
   }
 
   pExpr->op = eNewExprOp;
@@ -107097,6 +107732,19 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
     ** resolved.  This prevents "column" from being counted as having been
     ** referenced, which might prevent a SELECT from being erroneously
     ** marked as correlated.
+    **
+    ** 2024-03-28: Beware of aggregates.  A bare column of aggregated table
+    ** can still evaluate to NULL even though it is marked as NOT NULL.
+    ** Example:
+    **
+    **       CREATE TABLE t1(a INT NOT NULL);
+    **       SELECT a, a IS NULL, a IS NOT NULL, count(*) FROM t1;
+    **
+    ** The "a IS NULL" and "a IS NOT NULL" expressions cannot be optimized
+    ** here because at the time this case is hit, we do not yet know whether
+    ** or not t1 is being aggregated.  We have to assume the worst and omit
+    ** the optimization.  The only time it is safe to apply this optimization
+    ** is within the WHERE clause.
     */
     case TK_NOTNULL:
     case TK_ISNULL: {
@@ -107107,19 +107755,36 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
         anRef[i] = p->nRef;
       }
       sqlite3WalkExpr(pWalker, pExpr->pLeft);
-      if( 0==sqlite3ExprCanBeNull(pExpr->pLeft) && !IN_RENAME_OBJECT ){
-        testcase( ExprHasProperty(pExpr, EP_OuterON) );
-        assert( !ExprHasProperty(pExpr, EP_IntValue) );
-        pExpr->u.iValue = (pExpr->op==TK_NOTNULL);
-        pExpr->flags |= EP_IntValue;
-        pExpr->op = TK_INTEGER;
+      if( IN_RENAME_OBJECT ) return WRC_Prune;
+      if( sqlite3ExprCanBeNull(pExpr->pLeft) ){
+        /* The expression can be NULL.  So the optimization does not apply */
+        return WRC_Prune;
+      }
 
-        for(i=0, p=pNC; p && i<ArraySize(anRef); p=p->pNext, i++){
-          p->nRef = anRef[i];
+      for(i=0, p=pNC; p; p=p->pNext, i++){
+        if( (p->ncFlags & NC_Where)==0 ){
+          return WRC_Prune;  /* Not in a WHERE clause.  Unsafe to optimize. */
         }
-        sqlite3ExprDelete(pParse->db, pExpr->pLeft);
-        pExpr->pLeft = 0;
       }
+      testcase( ExprHasProperty(pExpr, EP_OuterON) );
+      assert( !ExprHasProperty(pExpr, EP_IntValue) );
+#if TREETRACE_ENABLED
+      if( sqlite3TreeTrace & 0x80000 ){
+        sqlite3DebugPrintf(
+           "NOT NULL strength reduction converts the following to %d:\n",
+           pExpr->op==TK_NOTNULL
+        );
+        sqlite3ShowExpr(pExpr);
+      }
+#endif /* TREETRACE_ENABLED */
+      pExpr->u.iValue = (pExpr->op==TK_NOTNULL);
+      pExpr->flags |= EP_IntValue;
+      pExpr->op = TK_INTEGER;
+      for(i=0, p=pNC; p && i<ArraySize(anRef); p=p->pNext, i++){
+        p->nRef = anRef[i];
+      }
+      sqlite3ExprDelete(pParse->db, pExpr->pLeft);
+      pExpr->pLeft = 0;
       return WRC_Prune;
     }
 
@@ -107133,7 +107798,6 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
     */
     case TK_ID:
     case TK_DOT: {
-      const char *zColumn;
       const char *zTable;
       const char *zDb;
       Expr *pRight;
@@ -107142,7 +107806,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
         zDb = 0;
         zTable = 0;
         assert( !ExprHasProperty(pExpr, EP_IntValue) );
-        zColumn = pExpr->u.zToken;
+        pRight = pExpr;
       }else{
         Expr *pLeft = pExpr->pLeft;
         testcase( pNC->ncFlags & NC_IdxExpr );
@@ -107161,14 +107825,13 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
         }
         assert( ExprUseUToken(pLeft) && ExprUseUToken(pRight) );
         zTable = pLeft->u.zToken;
-        zColumn = pRight->u.zToken;
         assert( ExprUseYTab(pExpr) );
         if( IN_RENAME_OBJECT ){
           sqlite3RenameTokenRemap(pParse, (void*)pExpr, (void*)pRight);
           sqlite3RenameTokenRemap(pParse, (void*)&pExpr->y.pTab, (void*)pLeft);
         }
       }
-      return lookupName(pParse, zDb, zTable, zColumn, pNC, pExpr);
+      return lookupName(pParse, zDb, zTable, pRight, pNC, pExpr);
     }
 
     /* Resolve function names
@@ -107344,11 +108007,9 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
 #endif
         }
       }
-#ifndef SQLITE_OMIT_WINDOWFUNC
-      else if( ExprHasProperty(pExpr, EP_WinFunc) ){
+      else if( ExprHasProperty(pExpr, EP_WinFunc) || pExpr->pLeft ){
         is_agg = 1;
       }
-#endif
       sqlite3WalkExprList(pWalker, pList);
       if( is_agg ){
         if( pExpr->pLeft ){
@@ -107418,6 +108079,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
         testcase( pNC->ncFlags & NC_PartIdx );
         testcase( pNC->ncFlags & NC_IdxExpr );
         testcase( pNC->ncFlags & NC_GenCol );
+        assert( pExpr->x.pSelect );
         if( pNC->ncFlags & NC_SelfRef ){
           notValidImpl(pParse, pNC, "subqueries", pExpr, pExpr);
         }else{
@@ -107426,6 +108088,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
         assert( pNC->nRef>=nRef );
         if( nRef!=pNC->nRef ){
           ExprSetProperty(pExpr, EP_VarSelect);
+          pExpr->x.pSelect->selFlags |= SF_Correlated;
         }
         pNC->ncFlags |= NC_Subquery;
       }
@@ -107951,6 +108614,7 @@ static int resolveSelectStep(Walker *pWalker, Select *p){
     if( pOuterNC ) pOuterNC->nNestedSelect++;
     for(i=0; i<p->pSrc->nSrc; i++){
       SrcItem *pItem = &p->pSrc->a[i];
+      assert( pItem->zName!=0 || pItem->pSelect!=0 );/* Test of tag-20240424-1*/
       if( pItem->pSelect && (pItem->pSelect->selFlags & SF_Resolved)==0 ){
         int nRef = pOuterNC ? pOuterNC->nRef : 0;
         const char *zSavedContext = pParse->zAuthContext;
@@ -108019,7 +108683,9 @@ static int resolveSelectStep(Walker *pWalker, Select *p){
       }
       if( sqlite3ResolveExprNames(&sNC, p->pHaving) ) return WRC_Abort;
     }
+    sNC.ncFlags |= NC_Where;
     if( sqlite3ResolveExprNames(&sNC, p->pWhere) ) return WRC_Abort;
+    sNC.ncFlags &= ~NC_Where;
 
     /* Resolve names in table-valued-function arguments */
     for(i=0; i<p->pSrc->nSrc; i++){
@@ -108558,9 +109224,10 @@ SQLITE_PRIVATE Expr *sqlite3ExprSkipCollateAndLikely(Expr *pExpr){
       assert( pExpr->x.pList->nExpr>0 );
       assert( pExpr->op==TK_FUNCTION );
       pExpr = pExpr->x.pList->a[0].pExpr;
-    }else{
-      assert( pExpr->op==TK_COLLATE );
+    }else if( pExpr->op==TK_COLLATE ){
       pExpr = pExpr->pLeft;
+    }else{
+      break;
     }
   }
   return pExpr;
@@ -109254,11 +109921,12 @@ SQLITE_PRIVATE void sqlite3ExprSetErrorOffset(Expr *pExpr, int iOfst){
 ** appear to be quoted.  If the quotes were of the form "..." (double-quotes)
 ** then the EP_DblQuoted flag is set on the expression node.
 **
-** Special case:  If op==TK_INTEGER and pToken points to a string that
-** can be translated into a 32-bit integer, then the token is not
-** stored in u.zToken.  Instead, the integer values is written
-** into u.iValue and the EP_IntValue flag is set.  No extra storage
+** Special case (tag-20240227-a):  If op==TK_INTEGER and pToken points to
+** a string that can be translated into a 32-bit integer, then the token is
+** not stored in u.zToken.  Instead, the integer values is written
+** into u.iValue and the EP_IntValue flag is set. No extra storage
 ** is allocated to hold the integer text and the dequote flag is ignored.
+** See also tag-20240227-b.
 */
 SQLITE_PRIVATE Expr *sqlite3ExprAlloc(
   sqlite3 *db,            /* Handle for sqlite3DbMallocRawNN() */
@@ -109274,7 +109942,7 @@ SQLITE_PRIVATE Expr *sqlite3ExprAlloc(
   if( pToken ){
     if( op!=TK_INTEGER || pToken->z==0
           || sqlite3GetInt32(pToken->z, &iValue)==0 ){
-      nExtra = pToken->n+1;
+      nExtra = pToken->n+1;  /* tag-20240227-a */
       assert( iValue>=0 );
     }
   }
@@ -109706,6 +110374,7 @@ SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr, u32 n
 static SQLITE_NOINLINE void sqlite3ExprDeleteNN(sqlite3 *db, Expr *p){
   assert( p!=0 );
   assert( db!=0 );
+exprDeleteRestart:
   assert( !ExprUseUValue(p) || p->u.iValue>=0 );
   assert( !ExprUseYWin(p) || !ExprUseYSub(p) );
   assert( !ExprUseYWin(p) || p->y.pWin!=0 || db->mallocFailed );
@@ -109721,7 +110390,6 @@ static SQLITE_NOINLINE void sqlite3ExprDeleteNN(sqlite3 *db, Expr *p){
   if( !ExprHasProperty(p, (EP_TokenOnly|EP_Leaf)) ){
     /* The Expr.x union is never used at the same time as Expr.pRight */
     assert( (ExprUseXList(p) && p->x.pList==0) || p->pRight==0 );
-    if( p->pLeft && p->op!=TK_SELECT_COLUMN ) sqlite3ExprDeleteNN(db, p->pLeft);
     if( p->pRight ){
       assert( !ExprHasProperty(p, EP_WinFunc) );
       sqlite3ExprDeleteNN(db, p->pRight);
@@ -109736,6 +110404,19 @@ static SQLITE_NOINLINE void sqlite3ExprDeleteNN(sqlite3 *db, Expr *p){
       }
 #endif
     }
+    if( p->pLeft && p->op!=TK_SELECT_COLUMN ){
+      Expr *pLeft = p->pLeft;
+      if( !ExprHasProperty(p, EP_Static)
+       && !ExprHasProperty(pLeft, EP_Static)
+      ){
+        /* Avoid unnecessary recursion on unary operators */
+        sqlite3DbNNFreeNN(db, p);
+        p = pLeft;
+        goto exprDeleteRestart;
+      }else{
+        sqlite3ExprDeleteNN(db, pLeft);
+      }
+    }
   }
   if( !ExprHasProperty(p, EP_Static) ){
     sqlite3DbNNFreeNN(db, p);
@@ -109768,11 +110449,11 @@ SQLITE_PRIVATE void sqlite3ClearOnOrUsing(sqlite3 *db, OnOrUsing *p){
 **
 ** The pExpr might be deleted immediately on an OOM error.
 **
-** The deferred delete is (currently) implemented by adding the
-** pExpr to the pParse->pConstExpr list with a register number of 0.
+** Return 0 if the delete was successfully deferred.  Return non-zero
+** if the delete happened immediately because of an OOM.
 */
-SQLITE_PRIVATE void sqlite3ExprDeferredDelete(Parse *pParse, Expr *pExpr){
-  sqlite3ParserAddCleanup(pParse, sqlite3ExprDeleteGeneric, pExpr);
+SQLITE_PRIVATE int sqlite3ExprDeferredDelete(Parse *pParse, Expr *pExpr){
+  return 0==sqlite3ParserAddCleanup(pParse, sqlite3ExprDeleteGeneric, pExpr);
 }
 
 /* Invoke sqlite3RenameExprUnmap() and sqlite3ExprDelete() on the
@@ -110208,17 +110889,19 @@ SQLITE_PRIVATE SrcList *sqlite3SrcListDup(sqlite3 *db, const SrcList *p, int fla
     pNewItem->iCursor = pOldItem->iCursor;
     pNewItem->addrFillSub = pOldItem->addrFillSub;
     pNewItem->regReturn = pOldItem->regReturn;
+    pNewItem->regResult = pOldItem->regResult;
     if( pNewItem->fg.isIndexedBy ){
       pNewItem->u1.zIndexedBy = sqlite3DbStrDup(db, pOldItem->u1.zIndexedBy);
+    }else if( pNewItem->fg.isTabFunc ){
+      pNewItem->u1.pFuncArg =
+          sqlite3ExprListDup(db, pOldItem->u1.pFuncArg, flags);
+    }else{
+      pNewItem->u1.nRow = pOldItem->u1.nRow;
     }
     pNewItem->u2 = pOldItem->u2;
     if( pNewItem->fg.isCte ){
       pNewItem->u2.pCteUse->nUse++;
     }
-    if( pNewItem->fg.isTabFunc ){
-      pNewItem->u1.pFuncArg =
-          sqlite3ExprListDup(db, pOldItem->u1.pFuncArg, flags);
-    }
     pTab = pNewItem->pTab = pOldItem->pTab;
     if( pTab ){
       pTab->nTabRef++;
@@ -110684,6 +111367,54 @@ SQLITE_PRIVATE Expr *sqlite3ExprSimplifiedAndOr(Expr *pExpr){
   return pExpr;
 }
 
+/*
+** pExpr is a TK_FUNCTION node.  Try to determine whether or not the
+** function is a constant function.  A function is constant if all of
+** the following are true:
+**
+**    (1)  It is a scalar function (not an aggregate or window function)
+**    (2)  It has either the SQLITE_FUNC_CONSTANT or SQLITE_FUNC_SLOCHNG
+**         property.
+**    (3)  All of its arguments are constants
+**
+** This routine sets pWalker->eCode to 0 if pExpr is not a constant.
+** It makes no changes to pWalker->eCode if pExpr is constant.  In
+** every case, it returns WRC_Abort.
+**
+** Called as a service subroutine from exprNodeIsConstant().
+*/
+static SQLITE_NOINLINE int exprNodeIsConstantFunction(
+  Walker *pWalker,
+  Expr *pExpr
+){
+  int n;             /* Number of arguments */
+  ExprList *pList;   /* List of arguments */
+  FuncDef *pDef;     /* The function */
+  sqlite3 *db;       /* The database */
+
+  assert( pExpr->op==TK_FUNCTION );
+  if( ExprHasProperty(pExpr, EP_TokenOnly)
+   || (pList = pExpr->x.pList)==0
+  ){;
+    n = 0;
+  }else{
+    n = pList->nExpr;
+    sqlite3WalkExprList(pWalker, pList);
+    if( pWalker->eCode==0 ) return WRC_Abort;
+  }
+  db = pWalker->pParse->db;
+  pDef = sqlite3FindFunction(db, pExpr->u.zToken, n, ENC(db), 0);
+  if( pDef==0
+   || pDef->xFinalize!=0
+   || (pDef->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG))==0
+   || ExprHasProperty(pExpr, EP_WinFunc)
+  ){
+    pWalker->eCode = 0;
+    return WRC_Abort;
+  }
+  return WRC_Prune;
+}
+
 
 /*
 ** These routines are Walker callbacks used to check expressions to
@@ -110712,6 +111443,7 @@ SQLITE_PRIVATE Expr *sqlite3ExprSimplifiedAndOr(Expr *pExpr){
 ** malformed schema error.
 */
 static int exprNodeIsConstant(Walker *pWalker, Expr *pExpr){
+  assert( pWalker->eCode>0 );
 
   /* If pWalker->eCode is 2 then any term of the expression that comes from
   ** the ON or USING clauses of an outer join disqualifies the expression
@@ -110731,6 +111463,8 @@ static int exprNodeIsConstant(Walker *pWalker, Expr *pExpr){
       ){
         if( pWalker->eCode==5 ) ExprSetProperty(pExpr, EP_FromDDL);
         return WRC_Continue;
+      }else if( pWalker->pParse ){
+        return exprNodeIsConstantFunction(pWalker, pExpr);
       }else{
         pWalker->eCode = 0;
         return WRC_Abort;
@@ -110759,9 +111493,11 @@ static int exprNodeIsConstant(Walker *pWalker, Expr *pExpr){
     case TK_IF_NULL_ROW:
     case TK_REGISTER:
     case TK_DOT:
+    case TK_RAISE:
       testcase( pExpr->op==TK_REGISTER );
       testcase( pExpr->op==TK_IF_NULL_ROW );
       testcase( pExpr->op==TK_DOT );
+      testcase( pExpr->op==TK_RAISE );
       pWalker->eCode = 0;
       return WRC_Abort;
     case TK_VARIABLE:
@@ -110783,15 +111519,15 @@ static int exprNodeIsConstant(Walker *pWalker, Expr *pExpr){
       return WRC_Continue;
   }
 }
-static int exprIsConst(Expr *p, int initFlag, int iCur){
+static int exprIsConst(Parse *pParse, Expr *p, int initFlag){
   Walker w;
   w.eCode = initFlag;
+  w.pParse = pParse;
   w.xExprCallback = exprNodeIsConstant;
   w.xSelectCallback = sqlite3SelectWalkFail;
 #ifdef SQLITE_DEBUG
   w.xSelectCallback2 = sqlite3SelectWalkAssert2;
 #endif
-  w.u.iCur = iCur;
   sqlite3WalkExpr(&w, p);
   return w.eCode;
 }
@@ -110803,9 +111539,15 @@ static int exprIsConst(Expr *p, int initFlag, int iCur){
 ** For the purposes of this function, a double-quoted string (ex: "abc")
 ** is considered a variable but a single-quoted string (ex: 'abc') is
 ** a constant.
+**
+** The pParse parameter may be NULL.  But if it is NULL, there is no way
+** to determine if function calls are constant or not, and hence all
+** function calls will be considered to be non-constant.  If pParse is
+** not NULL, then a function call might be constant, depending on the
+** function and on its parameters.
 */
-SQLITE_PRIVATE int sqlite3ExprIsConstant(Expr *p){
-  return exprIsConst(p, 1, 0);
+SQLITE_PRIVATE int sqlite3ExprIsConstant(Parse *pParse, Expr *p){
+  return exprIsConst(pParse, p, 1);
 }
 
 /*
@@ -110821,8 +111563,24 @@ SQLITE_PRIVATE int sqlite3ExprIsConstant(Expr *p){
 ** can be added to the pParse->pConstExpr list and evaluated once when
 ** the prepared statement starts up.  See sqlite3ExprCodeRunJustOnce().
 */
-SQLITE_PRIVATE int sqlite3ExprIsConstantNotJoin(Expr *p){
-  return exprIsConst(p, 2, 0);
+static int sqlite3ExprIsConstantNotJoin(Parse *pParse, Expr *p){
+  return exprIsConst(pParse, p, 2);
+}
+
+/*
+** This routine examines sub-SELECT statements as an expression is being
+** walked as part of sqlite3ExprIsTableConstant().  Sub-SELECTs are considered
+** constant as long as they are uncorrelated - meaning that they do not
+** contain any terms from outer contexts.
+*/
+static int exprSelectWalkTableConstant(Walker *pWalker, Select *pSelect){
+  assert( pSelect!=0 );
+  assert( pWalker->eCode==3 || pWalker->eCode==0 );
+  if( (pSelect->selFlags & SF_Correlated)!=0 ){
+    pWalker->eCode = 0;
+    return WRC_Abort;
+  }
+  return WRC_Prune;
 }
 
 /*
@@ -110830,9 +111588,26 @@ SQLITE_PRIVATE int sqlite3ExprIsConstantNotJoin(Expr *p){
 ** for any single row of the table with cursor iCur.  In other words, the
 ** expression must not refer to any non-deterministic function nor any
 ** table other than iCur.
+**
+** Consider uncorrelated subqueries to be constants if the bAllowSubq
+** parameter is true.
 */
-SQLITE_PRIVATE int sqlite3ExprIsTableConstant(Expr *p, int iCur){
-  return exprIsConst(p, 3, iCur);
+static int sqlite3ExprIsTableConstant(Expr *p, int iCur, int bAllowSubq){
+  Walker w;
+  w.eCode = 3;
+  w.pParse = 0;
+  w.xExprCallback = exprNodeIsConstant;
+  if( bAllowSubq ){
+    w.xSelectCallback = exprSelectWalkTableConstant;
+  }else{
+    w.xSelectCallback = sqlite3SelectWalkFail;
+#ifdef SQLITE_DEBUG
+    w.xSelectCallback2 = sqlite3SelectWalkAssert2;
+#endif
+  }
+  w.u.iCur = iCur;
+  sqlite3WalkExpr(&w, p);
+  return w.eCode;
 }
 
 /*
@@ -110850,7 +111625,10 @@ SQLITE_PRIVATE int sqlite3ExprIsTableConstant(Expr *p, int iCur){
 **
 **   (1)  pExpr cannot refer to any table other than pSrc->iCursor.
 **
-**   (2)  pExpr cannot use subqueries or non-deterministic functions.
+**   (2a) pExpr cannot use subqueries unless the bAllowSubq parameter is
+**        true and the subquery is non-correlated
+**
+**   (2b) pExpr cannot use non-deterministic functions.
 **
 **   (3)  pSrc cannot be part of the left operand for a RIGHT JOIN.
 **        (Is there some way to relax this constraint?)
@@ -110879,7 +111657,8 @@ SQLITE_PRIVATE int sqlite3ExprIsTableConstant(Expr *p, int iCur){
 SQLITE_PRIVATE int sqlite3ExprIsSingleTableConstraint(
   Expr *pExpr,                 /* The constraint */
   const SrcList *pSrcList,     /* Complete FROM clause */
-  int iSrc                     /* Which element of pSrcList to use */
+  int iSrc,                    /* Which element of pSrcList to use */
+  int bAllowSubq               /* Allow non-correlated subqueries */
 ){
   const SrcItem *pSrc = &pSrcList->a[iSrc];
   if( pSrc->fg.jointype & JT_LTORJ ){
@@ -110904,7 +111683,8 @@ SQLITE_PRIVATE int sqlite3ExprIsSingleTableConstraint(
       }
     }
   }
-  return sqlite3ExprIsTableConstant(pExpr, pSrc->iCursor); /* rules (1), (2) */
+  /* Rules (1), (2a), and (2b) handled by the following: */
+  return sqlite3ExprIsTableConstant(pExpr, pSrc->iCursor, bAllowSubq);
 }
 
 
@@ -110989,7 +111769,7 @@ SQLITE_PRIVATE int sqlite3ExprIsConstantOrGroupBy(Parse *pParse, Expr *p, ExprLi
 */
 SQLITE_PRIVATE int sqlite3ExprIsConstantOrFunction(Expr *p, u8 isInit){
   assert( isInit==0 || isInit==1 );
-  return exprIsConst(p, 4+isInit, 0);
+  return exprIsConst(0, p, 4+isInit);
 }
 
 #ifdef SQLITE_ENABLE_CURSOR_HINTS
@@ -111079,9 +111859,12 @@ SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr *p){
       return 0;
     case TK_COLUMN:
       assert( ExprUseYTab(p) );
-      return ExprHasProperty(p, EP_CanBeNull) ||
-             NEVER(p->y.pTab==0) ||  /* Reference to column of index on expr */
-             (p->iColumn>=0
+      return ExprHasProperty(p, EP_CanBeNull)
+          || NEVER(p->y.pTab==0) /* Reference to column of index on expr */
+#ifdef SQLITE_ALLOW_ROWID_IN_VIEW
+          || (p->iColumn==XN_ROWID && IsView(p->y.pTab))
+#endif
+          || (p->iColumn>=0
               && p->y.pTab->aCol!=0 /* Possible due to prior error */
               && ALWAYS(p->iColumn<p->y.pTab->nCol)
               && p->y.pTab->aCol[p->iColumn].notNull==0);
@@ -111234,13 +112017,13 @@ static void sqlite3SetHasNullFlag(Vdbe *v, int iCur, int regHasNull){
 ** The argument is an IN operator with a list (not a subquery) on the
 ** right-hand side.  Return TRUE if that list is constant.
 */
-static int sqlite3InRhsIsConstant(Expr *pIn){
+static int sqlite3InRhsIsConstant(Parse *pParse, Expr *pIn){
   Expr *pLHS;
   int res;
   assert( !ExprHasProperty(pIn, EP_xIsSelect) );
   pLHS = pIn->pLeft;
   pIn->pLeft = 0;
-  res = sqlite3ExprIsConstant(pIn);
+  res = sqlite3ExprIsConstant(pParse, pIn);
   pIn->pLeft = pLHS;
   return res;
 }
@@ -111509,7 +112292,7 @@ SQLITE_PRIVATE int sqlite3FindInIndex(
   if( eType==0
    && (inFlags & IN_INDEX_NOOP_OK)
    && ExprUseXList(pX)
-   && (!sqlite3InRhsIsConstant(pX) || pX->x.pList->nExpr<=2)
+   && (!sqlite3InRhsIsConstant(pParse,pX) || pX->x.pList->nExpr<=2)
   ){
     pParse->nTab--;  /* Back out the allocation of the unused cursor */
     iTab = -1;       /* Cursor is not allocated */
@@ -111792,7 +112575,7 @@ SQLITE_PRIVATE void sqlite3CodeRhsOfIN(
       ** this code only executes once.  Because for a non-constant
       ** expression we need to rerun this code each time.
       */
-      if( addrOnce && !sqlite3ExprIsConstant(pE2) ){
+      if( addrOnce && !sqlite3ExprIsConstant(pParse, pE2) ){
         sqlite3VdbeChangeToNoop(v, addrOnce-1);
         sqlite3VdbeChangeToNoop(v, addrOnce);
         ExprClearProperty(pExpr, EP_Subrtn);
@@ -112956,12 +113739,6 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target)
       assert( pExpr->u.zToken!=0 );
       assert( pExpr->u.zToken[0]!=0 );
       sqlite3VdbeAddOp2(v, OP_Variable, pExpr->iColumn, target);
-      if( pExpr->u.zToken[1]!=0 ){
-        const char *z = sqlite3VListNumToName(pParse->pVList, pExpr->iColumn);
-        assert( pExpr->u.zToken[0]=='?' || (z && !strcmp(pExpr->u.zToken, z)) );
-        pParse->pVList[0] = 0; /* Indicate VList may no longer be enlarged */
-        sqlite3VdbeAppendP4(v, (char*)z, P4_STATIC);
-      }
       return target;
     }
     case TK_REGISTER: {
@@ -113135,7 +113912,9 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target)
       }
 #endif
 
-      if( ConstFactorOk(pParse) && sqlite3ExprIsConstantNotJoin(pExpr) ){
+      if( ConstFactorOk(pParse)
+       && sqlite3ExprIsConstantNotJoin(pParse,pExpr)
+      ){
         /* SQL functions can be expensive. So try to avoid running them
         ** multiple times if we know they always give the same result */
         return sqlite3ExprCodeRunJustOnce(pParse, pExpr, -1);
@@ -113166,7 +113945,7 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target)
       }
 
       for(i=0; i<nFarg; i++){
-        if( i<32 && sqlite3ExprIsConstant(pFarg->a[i].pExpr) ){
+        if( i<32 && sqlite3ExprIsConstant(pParse, pFarg->a[i].pExpr) ){
           testcase( i==31 );
           constMask |= MASKBIT32(i);
         }
@@ -113308,8 +114087,9 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target)
       if( !ExprHasProperty(pExpr, EP_Collate) ){
         /* A TK_COLLATE Expr node without the EP_Collate tag is a so-called
         ** "SOFT-COLLATE" that is added to constraints that are pushed down
-        ** from outer queries into sub-queries by the push-down optimization.
-        ** Clear subtypes as subtypes may not cross a subquery boundary.
+        ** from outer queries into sub-queries by the WHERE-clause push-down
+        ** optimization. Clear subtypes as subtypes may not cross a subquery
+        ** boundary.
         */
         assert( pExpr->pLeft );
         sqlite3ExprCode(pParse, pExpr->pLeft, target);
@@ -113633,7 +114413,7 @@ SQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse *pParse, Expr *pExpr, int *pReg){
   if( ConstFactorOk(pParse)
    && ALWAYS(pExpr!=0)
    && pExpr->op!=TK_REGISTER
-   && sqlite3ExprIsConstantNotJoin(pExpr)
+   && sqlite3ExprIsConstantNotJoin(pParse, pExpr)
   ){
     *pReg  = 0;
     r2 = sqlite3ExprCodeRunJustOnce(pParse, pExpr, -1);
@@ -113697,7 +114477,7 @@ SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse *pParse, Expr *pExpr, int target){
 ** might choose to code the expression at initialization time.
 */
 SQLITE_PRIVATE void sqlite3ExprCodeFactorable(Parse *pParse, Expr *pExpr, int target){
-  if( pParse->okConstFactor && sqlite3ExprIsConstantNotJoin(pExpr) ){
+  if( pParse->okConstFactor && sqlite3ExprIsConstantNotJoin(pParse,pExpr) ){
     sqlite3ExprCodeRunJustOnce(pParse, pExpr, target);
   }else{
     sqlite3ExprCodeCopy(pParse, pExpr, target);
@@ -113756,7 +114536,7 @@ SQLITE_PRIVATE int sqlite3ExprCodeExprList(
         sqlite3VdbeAddOp2(v, copyOp, j+srcReg-1, target+i);
       }
     }else if( (flags & SQLITE_ECEL_FACTOR)!=0
-           && sqlite3ExprIsConstantNotJoin(pExpr)
+           && sqlite3ExprIsConstantNotJoin(pParse,pExpr)
     ){
       sqlite3ExprCodeRunJustOnce(pParse, pExpr, target+i);
     }else{
@@ -114907,9 +115687,8 @@ static int agginfoPersistExprCb(Walker *pWalker, Expr *pExpr){
        && pAggInfo->aCol[iAgg].pCExpr==pExpr
       ){
         pExpr = sqlite3ExprDup(db, pExpr, 0);
-        if( pExpr ){
+        if( pExpr && !sqlite3ExprDeferredDelete(pParse, pExpr) ){
           pAggInfo->aCol[iAgg].pCExpr = pExpr;
-          sqlite3ExprDeferredDelete(pParse, pExpr);
         }
       }
     }else{
@@ -114918,9 +115697,8 @@ static int agginfoPersistExprCb(Walker *pWalker, Expr *pExpr){
        && pAggInfo->aFunc[iAgg].pFExpr==pExpr
       ){
         pExpr = sqlite3ExprDup(db, pExpr, 0);
-        if( pExpr ){
+        if( pExpr && !sqlite3ExprDeferredDelete(pParse, pExpr) ){
           pAggInfo->aFunc[iAgg].pFExpr = pExpr;
-          sqlite3ExprDeferredDelete(pParse, pExpr);
         }
       }
     }
@@ -117621,7 +118399,12 @@ SQLITE_PRIVATE void sqlite3AlterDropColumn(Parse *pParse, SrcList *pSrc, const T
         if( i==pTab->iPKey ){
           sqlite3VdbeAddOp2(v, OP_Null, 0, regOut);
         }else{
+          char aff = pTab->aCol[i].affinity;
+          if( aff==SQLITE_AFF_REAL ){
+            pTab->aCol[i].affinity = SQLITE_AFF_NUMERIC;
+          }
           sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, i, regOut);
+          pTab->aCol[i].affinity = aff;
         }
         nField++;
       }
@@ -118540,7 +119323,7 @@ static void statGet(
       if( iVal==2 && p->nRow*10 <= nDistinct*11 ) iVal = 1;
       sqlite3_str_appendf(&sStat, " %llu", iVal);
 #ifdef SQLITE_ENABLE_STAT4
-      assert( p->current.anEq[i] );
+      assert( p->current.anEq[i] || p->nRow==0 );
 #endif
     }
     sqlite3ResultStrAccum(context, &sStat);
@@ -118725,7 +119508,7 @@ static void analyzeOneTable(
 
   for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
     int nCol;                     /* Number of columns in pIdx. "N" */
-    int addrRewind;               /* Address of "OP_Rewind iIdxCur" */
+    int addrGotoEnd;               /* Address of "OP_Rewind iIdxCur" */
     int addrNextRow;              /* Address of "next_row:" */
     const char *zIdxName;         /* Name of the index */
     int nColTest;                 /* Number of columns to test for changes */
@@ -118749,9 +119532,14 @@ static void analyzeOneTable(
     /*
     ** Pseudo-code for loop that calls stat_push():
     **
-    **   Rewind csr
-    **   if eof(csr) goto end_of_scan;
     **   regChng = 0
+    **   Rewind csr
+    **   if eof(csr){
+    **      stat_init() with count = 0;
+    **      goto end_of_scan;
+    **   }
+    **   count()
+    **   stat_init()
     **   goto chng_addr_0;
     **
     **  next_row:
@@ -118790,41 +119578,36 @@ static void analyzeOneTable(
     sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
     VdbeComment((v, "%s", pIdx->zName));
 
-    /* Invoke the stat_init() function. The arguments are:
+    /* Implementation of the following:
     **
+    **   regChng = 0
+    **   Rewind csr
+    **   if eof(csr){
+    **      stat_init() with count = 0;
+    **      goto end_of_scan;
+    **   }
+    **   count()
+    **   stat_init()
+    **   goto chng_addr_0;
+    */
+    assert( regTemp2==regStat+4 );
+    sqlite3VdbeAddOp2(v, OP_Integer, db->nAnalysisLimit, regTemp2);
+
+    /* Arguments to stat_init():
     **    (1) the number of columns in the index including the rowid
     **        (or for a WITHOUT ROWID table, the number of PK columns),
     **    (2) the number of columns in the key without the rowid/pk
-    **    (3) estimated number of rows in the index,
-    */
+    **    (3) estimated number of rows in the index. */
     sqlite3VdbeAddOp2(v, OP_Integer, nCol, regStat+1);
     assert( regRowid==regStat+2 );
     sqlite3VdbeAddOp2(v, OP_Integer, pIdx->nKeyCol, regRowid);
-#ifdef SQLITE_ENABLE_STAT4
-    if( OptimizationEnabled(db, SQLITE_Stat4) ){
-      sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regTemp);
-      addrRewind = sqlite3VdbeAddOp1(v, OP_Rewind, iIdxCur);
-      VdbeCoverage(v);
-    }else
-#endif
-    {
-      addrRewind = sqlite3VdbeAddOp1(v, OP_Rewind, iIdxCur);
-      VdbeCoverage(v);
-      sqlite3VdbeAddOp3(v, OP_Count, iIdxCur, regTemp, 1);
-    }
-    assert( regTemp2==regStat+4 );
-    sqlite3VdbeAddOp2(v, OP_Integer, db->nAnalysisLimit, regTemp2);
+    sqlite3VdbeAddOp3(v, OP_Count, iIdxCur, regTemp,
+                      OptimizationDisabled(db, SQLITE_Stat4));
     sqlite3VdbeAddFunctionCall(pParse, 0, regStat+1, regStat, 4,
                                &statInitFuncdef, 0);
+    addrGotoEnd = sqlite3VdbeAddOp1(v, OP_Rewind, iIdxCur);
+    VdbeCoverage(v);
 
-    /* Implementation of the following:
-    **
-    **   Rewind csr
-    **   if eof(csr) goto end_of_scan;
-    **   regChng = 0
-    **   goto next_push_0;
-    **
-    */
     sqlite3VdbeAddOp2(v, OP_Integer, 0, regChng);
     addrNextRow = sqlite3VdbeCurrentAddr(v);
 
@@ -118931,6 +119714,12 @@ static void analyzeOneTable(
     }
 
     /* Add the entry to the stat1 table. */
+    if( pIdx->pPartIdxWhere ){
+      /* Partial indexes might get a zero-entry in sqlite_stat1.  But
+      ** an empty table is omitted from sqlite_stat1. */
+      sqlite3VdbeJumpHere(v, addrGotoEnd);
+      addrGotoEnd = 0;
+    }
     callStatGet(pParse, regStat, STAT_GET_STAT1, regStat1);
     assert( "BBB"[0]==SQLITE_AFF_TEXT );
     sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regTemp, "BBB", 0);
@@ -118954,6 +119743,13 @@ static void analyzeOneTable(
       int addrIsNull;
       u8 seekOp = HasRowid(pTab) ? OP_NotExists : OP_NotFound;
 
+      /* No STAT4 data is generated if the number of rows is zero */
+      if( addrGotoEnd==0 ){
+        sqlite3VdbeAddOp2(v, OP_Cast, regStat1, SQLITE_AFF_INTEGER);
+        addrGotoEnd = sqlite3VdbeAddOp1(v, OP_IfNot, regStat1);
+        VdbeCoverage(v);
+      }
+
       if( doOnce ){
         int mxCol = nCol;
         Index *pX;
@@ -119006,7 +119802,7 @@ static void analyzeOneTable(
 #endif /* SQLITE_ENABLE_STAT4 */
 
     /* End of analysis */
-    sqlite3VdbeJumpHere(v, addrRewind);
+    if( addrGotoEnd ) sqlite3VdbeJumpHere(v, addrGotoEnd);
   }
 
 
@@ -120755,7 +121551,7 @@ SQLITE_PRIVATE void sqlite3FinishCoding(Parse *pParse){
     }
     sqlite3VdbeAddOp0(v, OP_Halt);
 
-#if SQLITE_USER_AUTHENTICATION
+#if SQLITE_USER_AUTHENTICATION && !defined(SQLITE_OMIT_SHARED_CACHE)
     if( pParse->nTableLock>0 && db->init.busy==0 ){
       sqlite3UserAuthInit(db);
       if( db->auth.authLevel<UAUTH_User ){
@@ -123394,20 +124190,20 @@ SQLITE_PRIVATE void sqlite3EndTable(
       int regRowid;       /* Rowid of the next row to insert */
       int addrInsLoop;    /* Top of the loop for inserting rows */
       Table *pSelTab;     /* A table that describes the SELECT results */
+      int iCsr;           /* Write cursor on the new table */
 
       if( IN_SPECIAL_PARSE ){
         pParse->rc = SQLITE_ERROR;
         pParse->nErr++;
         return;
       }
+      iCsr = pParse->nTab++;
       regYield = ++pParse->nMem;
       regRec = ++pParse->nMem;
       regRowid = ++pParse->nMem;
-      assert(pParse->nTab==1);
       sqlite3MayAbort(pParse);
-      sqlite3VdbeAddOp3(v, OP_OpenWrite, 1, pParse->regRoot, iDb);
+      sqlite3VdbeAddOp3(v, OP_OpenWrite, iCsr, pParse->regRoot, iDb);
       sqlite3VdbeChangeP5(v, OPFLAG_P2ISREG);
-      pParse->nTab = 2;
       addrTop = sqlite3VdbeCurrentAddr(v) + 1;
       sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, addrTop);
       if( pParse->nErr ) return;
@@ -123428,11 +124224,11 @@ SQLITE_PRIVATE void sqlite3EndTable(
       VdbeCoverage(v);
       sqlite3VdbeAddOp3(v, OP_MakeRecord, dest.iSdst, dest.nSdst, regRec);
       sqlite3TableAffinity(v, p, 0);
-      sqlite3VdbeAddOp2(v, OP_NewRowid, 1, regRowid);
-      sqlite3VdbeAddOp3(v, OP_Insert, 1, regRec, regRowid);
+      sqlite3VdbeAddOp2(v, OP_NewRowid, iCsr, regRowid);
+      sqlite3VdbeAddOp3(v, OP_Insert, iCsr, regRec, regRowid);
       sqlite3VdbeGoto(v, addrInsLoop);
       sqlite3VdbeJumpHere(v, addrInsLoop);
-      sqlite3VdbeAddOp1(v, OP_Close, 1);
+      sqlite3VdbeAddOp1(v, OP_Close, iCsr);
     }
 
     /* Compute the complete text of the CREATE statement */
@@ -123489,13 +124285,10 @@ SQLITE_PRIVATE void sqlite3EndTable(
     /* Test for cycles in generated columns and illegal expressions
     ** in CHECK constraints and in DEFAULT clauses. */
     if( p->tabFlags & TF_HasGenerated ){
-      sqlite3VdbeAddOp4(v, OP_SqlExec, 1, 0, 0,
+      sqlite3VdbeAddOp4(v, OP_SqlExec, 0x0001, 0, 0,
              sqlite3MPrintf(db, "SELECT*FROM\"%w\".\"%w\"",
                    db->aDb[iDb].zDbSName, p->zName), P4_DYNAMIC);
     }
-    sqlite3VdbeAddOp4(v, OP_SqlExec, 1, 0, 0,
-           sqlite3MPrintf(db, "PRAGMA \"%w\".integrity_check(%Q)",
-                 db->aDb[iDb].zDbSName, p->zName), P4_DYNAMIC);
   }
 
   /* Add the table to the in-memory representation of the database.
@@ -123572,9 +124365,12 @@ SQLITE_PRIVATE void sqlite3CreateView(
   ** on a view, even though views do not have rowids.  The following flag
   ** setting fixes this problem.  But the fix can be disabled by compiling
   ** with -DSQLITE_ALLOW_ROWID_IN_VIEW in case there are legacy apps that
-  ** depend upon the old buggy behavior. */
-#ifndef SQLITE_ALLOW_ROWID_IN_VIEW
-  p->tabFlags |= TF_NoVisibleRowid;
+  ** depend upon the old buggy behavior.  The ability can also be toggled
+  ** using sqlite3_config(SQLITE_CONFIG_ROWID_IN_VIEW,...) */
+#ifdef SQLITE_ALLOW_ROWID_IN_VIEW
+  p->tabFlags |= sqlite3Config.mNoVisibleRowid; /* Optional. Allow by default */
+#else
+  p->tabFlags |= TF_NoVisibleRowid;             /* Never allow rowid in view */
 #endif
 
   sqlite3TwoPartName(pParse, pName1, pName2, &pName);
@@ -128947,13 +129743,13 @@ SQLITE_PRIVATE void sqlite3QuoteValue(StrAccum *pStr, sqlite3_value *pValue){
       double r1, r2;
       const char *zVal;
       r1 = sqlite3_value_double(pValue);
-      sqlite3_str_appendf(pStr, "%!.15g", r1);
+      sqlite3_str_appendf(pStr, "%!0.15g", r1);
       zVal = sqlite3_str_value(pStr);
       if( zVal ){
         sqlite3AtoF(zVal, &r2, pStr->nChar, SQLITE_UTF8);
         if( r1!=r2 ){
           sqlite3_str_reset(pStr);
-          sqlite3_str_appendf(pStr, "%!.20e", r1);
+          sqlite3_str_appendf(pStr, "%!0.20e", r1);
         }
       }
       break;
@@ -129255,7 +130051,7 @@ static void replaceFunc(
   }
   if( zPattern[0]==0 ){
     assert( sqlite3_value_type(argv[1])!=SQLITE_NULL );
-    sqlite3_result_value(context, argv[0]);
+    sqlite3_result_text(context, (const char*)zStr, nStr, SQLITE_TRANSIENT);
     return;
   }
   nPattern = sqlite3_value_bytes(argv[1]);
@@ -129738,7 +130534,7 @@ static void sumFinalize(sqlite3_context *context){
     if( p->approx ){
       if( p->ovrfl ){
         sqlite3_result_error(context,"integer overflow",-1);
-      }else if( !sqlite3IsNaN(p->rErr) ){
+      }else if( !sqlite3IsOverflow(p->rErr) ){
         sqlite3_result_double(context, p->rSum+p->rErr);
       }else{
         sqlite3_result_double(context, p->rSum);
@@ -129755,7 +130551,7 @@ static void avgFinalize(sqlite3_context *context){
     double r;
     if( p->approx ){
       r = p->rSum;
-      if( !sqlite3IsNaN(p->rErr) ) r += p->rErr;
+      if( !sqlite3IsOverflow(p->rErr) ) r += p->rErr;
     }else{
       r = (double)(p->iSum);
     }
@@ -129769,7 +130565,7 @@ static void totalFinalize(sqlite3_context *context){
   if( p ){
     if( p->approx ){
       r = p->rSum;
-      if( !sqlite3IsNaN(p->rErr) ) r += p->rErr;
+      if( !sqlite3IsOverflow(p->rErr) ) r += p->rErr;
     }else{
       r = (double)(p->iSum);
     }
@@ -132666,6 +133462,195 @@ SQLITE_PRIVATE void sqlite3AutoincrementEnd(Parse *pParse){
 # define autoIncStep(A,B,C)
 #endif /* SQLITE_OMIT_AUTOINCREMENT */
 
+/*
+** If argument pVal is a Select object returned by an sqlite3MultiValues()
+** that was able to use the co-routine optimization, finish coding the
+** co-routine.
+*/
+SQLITE_PRIVATE void sqlite3MultiValuesEnd(Parse *pParse, Select *pVal){
+  if( ALWAYS(pVal) && pVal->pSrc->nSrc>0 ){
+    SrcItem *pItem = &pVal->pSrc->a[0];
+    sqlite3VdbeEndCoroutine(pParse->pVdbe, pItem->regReturn);
+    sqlite3VdbeJumpHere(pParse->pVdbe, pItem->addrFillSub - 1);
+  }
+}
+
+/*
+** Return true if all expressions in the expression-list passed as the
+** only argument are constant.
+*/
+static int exprListIsConstant(Parse *pParse, ExprList *pRow){
+  int ii;
+  for(ii=0; ii<pRow->nExpr; ii++){
+    if( 0==sqlite3ExprIsConstant(pParse, pRow->a[ii].pExpr) ) return 0;
+  }
+  return 1;
+}
+
+/*
+** Return true if all expressions in the expression-list passed as the
+** only argument are both constant and have no affinity.
+*/
+static int exprListIsNoAffinity(Parse *pParse, ExprList *pRow){
+  int ii;
+  if( exprListIsConstant(pParse,pRow)==0 ) return 0;
+  for(ii=0; ii<pRow->nExpr; ii++){
+    Expr *pExpr = pRow->a[ii].pExpr;
+    assert( pExpr->op!=TK_RAISE );
+    assert( pExpr->affExpr==0 );
+    if( 0!=sqlite3ExprAffinity(pExpr) ) return 0;
+  }
+  return 1;
+
+}
+
+/*
+** This function is called by the parser for the second and subsequent
+** rows of a multi-row VALUES clause. Argument pLeft is the part of
+** the VALUES clause already parsed, argument pRow is the vector of values
+** for the new row. The Select object returned represents the complete
+** VALUES clause, including the new row.
+**
+** There are two ways in which this may be achieved - by incremental
+** coding of a co-routine (the "co-routine" method) or by returning a
+** Select object equivalent to the following (the "UNION ALL" method):
+**
+**        "pLeft UNION ALL SELECT pRow"
+**
+** If the VALUES clause contains a lot of rows, this compound Select
+** object may consume a lot of memory.
+**
+** When the co-routine method is used, each row that will be returned
+** by the VALUES clause is coded into part of a co-routine as it is
+** passed to this function. The returned Select object is equivalent to:
+**
+**     SELECT * FROM (
+**       Select object to read co-routine
+**     )
+**
+** The co-routine method is used in most cases. Exceptions are:
+**
+**    a) If the current statement has a WITH clause. This is to avoid
+**       statements like:
+**
+**            WITH cte AS ( VALUES('x'), ('y') ... )
+**            SELECT * FROM cte AS a, cte AS b;
+**
+**       This will not work, as the co-routine uses a hard-coded register
+**       for its OP_Yield instructions, and so it is not possible for two
+**       cursors to iterate through it concurrently.
+**
+**    b) The schema is currently being parsed (i.e. the VALUES clause is part
+**       of a schema item like a VIEW or TRIGGER). In this case there is no VM
+**       being generated when parsing is taking place, and so generating
+**       a co-routine is not possible.
+**
+**    c) There are non-constant expressions in the VALUES clause (e.g.
+**       the VALUES clause is part of a correlated sub-query).
+**
+**    d) One or more of the values in the first row of the VALUES clause
+**       has an affinity (i.e. is a CAST expression). This causes problems
+**       because the complex rules SQLite uses (see function
+**       sqlite3SubqueryColumnTypes() in select.c) to determine the effective
+**       affinity of such a column for all rows require access to all values in
+**       the column simultaneously.
+*/
+SQLITE_PRIVATE Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){
+
+  if( pParse->bHasWith                   /* condition (a) above */
+   || pParse->db->init.busy              /* condition (b) above */
+   || exprListIsConstant(pParse,pRow)==0 /* condition (c) above */
+   || (pLeft->pSrc->nSrc==0 &&
+       exprListIsNoAffinity(pParse,pLeft->pEList)==0) /* condition (d) above */
+   || IN_SPECIAL_PARSE
+  ){
+    /* The co-routine method cannot be used. Fall back to UNION ALL. */
+    Select *pSelect = 0;
+    int f = SF_Values | SF_MultiValue;
+    if( pLeft->pSrc->nSrc ){
+      sqlite3MultiValuesEnd(pParse, pLeft);
+      f = SF_Values;
+    }else if( pLeft->pPrior ){
+      /* In this case set the SF_MultiValue flag only if it was set on pLeft */
+      f = (f & pLeft->selFlags);
+    }
+    pSelect = sqlite3SelectNew(pParse, pRow, 0, 0, 0, 0, 0, f, 0);
+    pLeft->selFlags &= ~SF_MultiValue;
+    if( pSelect ){
+      pSelect->op = TK_ALL;
+      pSelect->pPrior = pLeft;
+      pLeft = pSelect;
+    }
+  }else{
+    SrcItem *p = 0;               /* SrcItem that reads from co-routine */
+
+    if( pLeft->pSrc->nSrc==0 ){
+      /* Co-routine has not yet been started and the special Select object
+      ** that accesses the co-routine has not yet been created. This block
+      ** does both those things. */
+      Vdbe *v = sqlite3GetVdbe(pParse);
+      Select *pRet = sqlite3SelectNew(pParse, 0, 0, 0, 0, 0, 0, 0, 0);
+
+      /* Ensure the database schema has been read. This is to ensure we have
+      ** the correct text encoding.  */
+      if( (pParse->db->mDbFlags & DBFLAG_SchemaKnownOk)==0 ){
+        sqlite3ReadSchema(pParse);
+      }
+
+      if( pRet ){
+        SelectDest dest;
+        pRet->pSrc->nSrc = 1;
+        pRet->pPrior = pLeft->pPrior;
+        pRet->op = pLeft->op;
+        pLeft->pPrior = 0;
+        pLeft->op = TK_SELECT;
+        assert( pLeft->pNext==0 );
+        assert( pRet->pNext==0 );
+        p = &pRet->pSrc->a[0];
+        p->pSelect = pLeft;
+        p->fg.viaCoroutine = 1;
+        p->addrFillSub = sqlite3VdbeCurrentAddr(v) + 1;
+        p->regReturn = ++pParse->nMem;
+        p->iCursor = -1;
+        p->u1.nRow = 2;
+        sqlite3VdbeAddOp3(v,OP_InitCoroutine,p->regReturn,0,p->addrFillSub);
+        sqlite3SelectDestInit(&dest, SRT_Coroutine, p->regReturn);
+
+        /* Allocate registers for the output of the co-routine. Do so so
+        ** that there are two unused registers immediately before those
+        ** used by the co-routine. This allows the code in sqlite3Insert()
+        ** to use these registers directly, instead of copying the output
+        ** of the co-routine to a separate array for processing.  */
+        dest.iSdst = pParse->nMem + 3;
+        dest.nSdst = pLeft->pEList->nExpr;
+        pParse->nMem += 2 + dest.nSdst;
+
+        pLeft->selFlags |= SF_MultiValue;
+        sqlite3Select(pParse, pLeft, &dest);
+        p->regResult = dest.iSdst;
+        assert( pParse->nErr || dest.iSdst>0 );
+        pLeft = pRet;
+      }
+    }else{
+      p = &pLeft->pSrc->a[0];
+      assert( !p->fg.isTabFunc && !p->fg.isIndexedBy );
+      p->u1.nRow++;
+    }
+
+    if( pParse->nErr==0 ){
+      assert( p!=0 );
+      if( p->pSelect->pEList->nExpr!=pRow->nExpr ){
+        sqlite3SelectWrongNumTermsError(pParse, p->pSelect);
+      }else{
+        sqlite3ExprCodeExprList(pParse, pRow, p->regResult, 0, 0);
+        sqlite3VdbeAddOp1(pParse->pVdbe, OP_Yield, p->regReturn);
+      }
+    }
+    sqlite3ExprListDelete(pParse->db, pRow);
+  }
+
+  return pLeft;
+}
 
 /* Forward declaration */
 static int xferOptimization(
@@ -133002,25 +133987,40 @@ SQLITE_PRIVATE void sqlite3Insert(
   if( pSelect ){
     /* Data is coming from a SELECT or from a multi-row VALUES clause.
     ** Generate a co-routine to run the SELECT. */
-    int regYield;       /* Register holding co-routine entry-point */
-    int addrTop;        /* Top of the co-routine */
     int rc;             /* Result code */
 
-    regYield = ++pParse->nMem;
-    addrTop = sqlite3VdbeCurrentAddr(v) + 1;
-    sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, addrTop);
-    sqlite3SelectDestInit(&dest, SRT_Coroutine, regYield);
-    dest.iSdst = bIdListInOrder ? regData : 0;
-    dest.nSdst = pTab->nCol;
-    rc = sqlite3Select(pParse, pSelect, &dest);
-    regFromSelect = dest.iSdst;
-    assert( db->pParse==pParse );
-    if( rc || pParse->nErr ) goto insert_cleanup;
-    assert( db->mallocFailed==0 );
-    sqlite3VdbeEndCoroutine(v, regYield);
-    sqlite3VdbeJumpHere(v, addrTop - 1);                       /* label B: */
-    assert( pSelect->pEList );
-    nColumn = pSelect->pEList->nExpr;
+    if( pSelect->pSrc->nSrc==1
+     && pSelect->pSrc->a[0].fg.viaCoroutine
+     && pSelect->pPrior==0
+    ){
+      SrcItem *pItem = &pSelect->pSrc->a[0];
+      dest.iSDParm = pItem->regReturn;
+      regFromSelect = pItem->regResult;
+      nColumn = pItem->pSelect->pEList->nExpr;
+      ExplainQueryPlan((pParse, 0, "SCAN %S", pItem));
+      if( bIdListInOrder && nColumn==pTab->nCol ){
+        regData = regFromSelect;
+        regRowid = regData - 1;
+        regIns = regRowid - (IsVirtual(pTab) ? 1 : 0);
+      }
+    }else{
+      int addrTop;        /* Top of the co-routine */
+      int regYield = ++pParse->nMem;
+      addrTop = sqlite3VdbeCurrentAddr(v) + 1;
+      sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, addrTop);
+      sqlite3SelectDestInit(&dest, SRT_Coroutine, regYield);
+      dest.iSdst = bIdListInOrder ? regData : 0;
+      dest.nSdst = pTab->nCol;
+      rc = sqlite3Select(pParse, pSelect, &dest);
+      regFromSelect = dest.iSdst;
+      assert( db->pParse==pParse );
+      if( rc || pParse->nErr ) goto insert_cleanup;
+      assert( db->mallocFailed==0 );
+      sqlite3VdbeEndCoroutine(v, regYield);
+      sqlite3VdbeJumpHere(v, addrTop - 1);                       /* label B: */
+      assert( pSelect->pEList );
+      nColumn = pSelect->pEList->nExpr;
+    }
 
     /* Set useTempTable to TRUE if the result of the SELECT statement
     ** should be written into a temporary table (template 4).  Set to
@@ -133175,7 +134175,7 @@ SQLITE_PRIVATE void sqlite3Insert(
       pNx->iDataCur = iDataCur;
       pNx->iIdxCur = iIdxCur;
       if( pNx->pUpsertTarget ){
-        if( sqlite3UpsertAnalyzeTarget(pParse, pTabList, pNx) ){
+        if( sqlite3UpsertAnalyzeTarget(pParse, pTabList, pNx, pUpsert) ){
           goto insert_cleanup;
         }
       }
@@ -135067,7 +136067,10 @@ static int xferOptimization(
     }
   }
 #ifndef SQLITE_OMIT_CHECK
-  if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck,pDest->pCheck,-1) ){
+  if( pDest->pCheck
+   && (db->mDbFlags & DBFLAG_Vacuum)==0
+   && sqlite3ExprListCompare(pSrc->pCheck,pDest->pCheck,-1)
+  ){
     return 0;   /* Tables have different CHECK constraints.  Ticket #2252 */
   }
 #endif
@@ -137742,6 +138745,34 @@ static const PragmaName aPragmaName[] = {
 /************** End of pragma.h **********************************************/
 /************** Continuing where we left off in pragma.c *********************/
 
+/*
+** When the 0x10 bit of PRAGMA optimize is set, any ANALYZE commands
+** will be run with an analysis_limit set to the lessor of the value of
+** the following macro or to the actual analysis_limit if it is non-zero,
+** in order to prevent PRAGMA optimize from running for too long.
+**
+** The value of 2000 is chosen emperically so that the worst-case run-time
+** for PRAGMA optimize does not exceed 100 milliseconds against a variety
+** of test databases on a RaspberryPI-4 compiled using -Os and without
+** -DSQLITE_DEBUG.  Of course, your mileage may vary.  For the purpose of
+** this paragraph, "worst-case" means that ANALYZE ends up being
+** run on every table in the database.  The worst case typically only
+** happens if PRAGMA optimize is run on a database file for which ANALYZE
+** has not been previously run and the 0x10000 flag is included so that
+** all tables are analyzed.  The usual case for PRAGMA optimize is that
+** no ANALYZE commands will be run at all, or if any ANALYZE happens it
+** will be against a single table, so that expected timing for PRAGMA
+** optimize on a PI-4 is more like 1 millisecond or less with the 0x10000
+** flag or less than 100 microseconds without the 0x10000 flag.
+**
+** An analysis limit of 2000 is almost always sufficient for the query
+** planner to fully characterize an index.  The additional accuracy from
+** a larger analysis is not usually helpful.
+*/
+#ifndef SQLITE_DEFAULT_OPTIMIZE_LIMIT
+# define SQLITE_DEFAULT_OPTIMIZE_LIMIT 2000
+#endif
+
 /*
 ** Interpret the given string as a safety level.  Return 0 for OFF,
 ** 1 for ON or NORMAL, 2 for FULL, and 3 for EXTRA.  Return 1 for an empty or
@@ -139387,7 +140418,7 @@ SQLITE_PRIVATE void sqlite3Pragma(
     /* Set the maximum error count */
     mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX;
     if( zRight ){
-      if( sqlite3GetInt32(zRight, &mxErr) ){
+      if( sqlite3GetInt32(pValue->z, &mxErr) ){
         if( mxErr<=0 ){
           mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX;
         }
@@ -139404,7 +140435,6 @@ SQLITE_PRIVATE void sqlite3Pragma(
       Hash *pTbls;     /* Set of all tables in the schema */
       int *aRoot;      /* Array of root page numbers of all btrees */
       int cnt = 0;     /* Number of entries in aRoot[] */
-      int mxIdx = 0;   /* Maximum number of indexes for any table */
 
       if( OMIT_TEMPDB && i==1 ) continue;
       if( iDb>=0 && i!=iDb ) continue;
@@ -139426,7 +140456,6 @@ SQLITE_PRIVATE void sqlite3Pragma(
         if( pObjTab && pObjTab!=pTab ) continue;
         if( HasRowid(pTab) ) cnt++;
         for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){ cnt++; }
-        if( nIdx>mxIdx ) mxIdx = nIdx;
       }
       if( cnt==0 ) continue;
       if( pObjTab ) cnt++;
@@ -139446,11 +140475,11 @@ SQLITE_PRIVATE void sqlite3Pragma(
       aRoot[0] = cnt;
 
       /* Make sure sufficient number of registers have been allocated */
-      sqlite3TouchRegister(pParse, 8+mxIdx);
+      sqlite3TouchRegister(pParse, 8+cnt);
       sqlite3ClearTempRegCache(pParse);
 
       /* Do the b-tree integrity checks */
-      sqlite3VdbeAddOp4(v, OP_IntegrityCk, 2, cnt, 1, (char*)aRoot,P4_INTARRAY);
+      sqlite3VdbeAddOp4(v, OP_IntegrityCk, 1, cnt, 8, (char*)aRoot,P4_INTARRAY);
       sqlite3VdbeChangeP5(v, (u8)i);
       addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2); VdbeCoverage(v);
       sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0,
@@ -139460,6 +140489,36 @@ SQLITE_PRIVATE void sqlite3Pragma(
       integrityCheckResultRow(v);
       sqlite3VdbeJumpHere(v, addr);
 
+      /* Check that the indexes all have the right number of rows */
+      cnt = pObjTab ? 1 : 0;
+      sqlite3VdbeLoadString(v, 2, "wrong # of entries in index ");
+      for(x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){
+        int iTab = 0;
+        Table *pTab = sqliteHashData(x);
+        Index *pIdx;
+        if( pObjTab && pObjTab!=pTab ) continue;
+        if( HasRowid(pTab) ){
+          iTab = cnt++;
+        }else{
+          iTab = cnt;
+          for(pIdx=pTab->pIndex; ALWAYS(pIdx); pIdx=pIdx->pNext){
+            if( IsPrimaryKeyIndex(pIdx) ) break;
+            iTab++;
+          }
+        }
+        for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
+          if( pIdx->pPartIdxWhere==0 ){
+            addr = sqlite3VdbeAddOp3(v, OP_Eq, 8+cnt, 0, 8+iTab);
+            VdbeCoverageNeverNull(v);
+            sqlite3VdbeLoadString(v, 4, pIdx->zName);
+            sqlite3VdbeAddOp3(v, OP_Concat, 4, 2, 3);
+            integrityCheckResultRow(v);
+            sqlite3VdbeJumpHere(v, addr);
+          }
+          cnt++;
+        }
+      }
+
       /* Make sure all the indices are constructed correctly.
       */
       for(x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){
@@ -139474,31 +140533,7 @@ SQLITE_PRIVATE void sqlite3Pragma(
         int mxCol;              /* Maximum non-virtual column number */
 
         if( pObjTab && pObjTab!=pTab ) continue;
-        if( !IsOrdinaryTable(pTab) ){
-#ifndef SQLITE_OMIT_VIRTUALTABLE
-          sqlite3_vtab *pVTab;
-          int a1;
-          if( !IsVirtual(pTab) ) continue;
-          if( pTab->nCol<=0 ){
-            const char *zMod = pTab->u.vtab.azArg[0];
-            if( sqlite3HashFind(&db->aModule, zMod)==0 ) continue;
-          }
-          sqlite3ViewGetColumnNames(pParse, pTab);
-          if( pTab->u.vtab.p==0 ) continue;
-          pVTab = pTab->u.vtab.p->pVtab;
-          if( NEVER(pVTab==0) ) continue;
-          if( NEVER(pVTab->pModule==0) ) continue;
-          if( pVTab->pModule->iVersion<4 ) continue;
-          if( pVTab->pModule->xIntegrity==0 ) continue;
-          sqlite3VdbeAddOp3(v, OP_VCheck, i, 3, isQuick);
-          pTab->nTabRef++;
-          sqlite3VdbeAppendP4(v, pTab, P4_TABLEREF);
-          a1 = sqlite3VdbeAddOp1(v, OP_IsNull, 3); VdbeCoverage(v);
-          integrityCheckResultRow(v);
-          sqlite3VdbeJumpHere(v, a1);
-#endif
-          continue;
-        }
+        if( !IsOrdinaryTable(pTab) ) continue;
         if( isQuick || HasRowid(pTab) ){
           pPk = 0;
           r2 = 0;
@@ -139633,6 +140668,7 @@ SQLITE_PRIVATE void sqlite3Pragma(
               ** is REAL, we have to load the actual data using OP_Column
               ** to reliably determine if the value is a NULL. */
               sqlite3VdbeAddOp3(v, OP_Column, p1, p3, 3);
+              sqlite3ColumnDefault(v, pTab, j, 3);
               jmp3 = sqlite3VdbeAddOp2(v, OP_NotNull, 3, labelOk);
               VdbeCoverage(v);
             }
@@ -139806,23 +140842,43 @@ SQLITE_PRIVATE void sqlite3Pragma(
         }
         sqlite3VdbeAddOp2(v, OP_Next, iDataCur, loopTop); VdbeCoverage(v);
         sqlite3VdbeJumpHere(v, loopTop-1);
-        if( !isQuick ){
-          sqlite3VdbeLoadString(v, 2, "wrong # of entries in index ");
-          for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
-            if( pPk==pIdx ) continue;
-            sqlite3VdbeAddOp2(v, OP_Count, iIdxCur+j, 3);
-            addr = sqlite3VdbeAddOp3(v, OP_Eq, 8+j, 0, 3); VdbeCoverage(v);
-            sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);
-            sqlite3VdbeLoadString(v, 4, pIdx->zName);
-            sqlite3VdbeAddOp3(v, OP_Concat, 4, 2, 3);
-            integrityCheckResultRow(v);
-            sqlite3VdbeJumpHere(v, addr);
-          }
-          if( pPk ){
-            sqlite3ReleaseTempRange(pParse, r2, pPk->nKeyCol);
-          }
+        if( pPk ){
+          assert( !isQuick );
+          sqlite3ReleaseTempRange(pParse, r2, pPk->nKeyCol);
         }
       }
+
+#ifndef SQLITE_OMIT_VIRTUALTABLE
+      /* Second pass to invoke the xIntegrity method on all virtual
+      ** tables.
+      */
+      for(x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){
+        Table *pTab = sqliteHashData(x);
+        sqlite3_vtab *pVTab;
+        int a1;
+        if( pObjTab && pObjTab!=pTab ) continue;
+        if( IsOrdinaryTable(pTab) ) continue;
+        if( !IsVirtual(pTab) ) continue;
+        if( pTab->nCol<=0 ){
+          const char *zMod = pTab->u.vtab.azArg[0];
+          if( sqlite3HashFind(&db->aModule, zMod)==0 ) continue;
+        }
+        sqlite3ViewGetColumnNames(pParse, pTab);
+        if( pTab->u.vtab.p==0 ) continue;
+        pVTab = pTab->u.vtab.p->pVtab;
+        if( NEVER(pVTab==0) ) continue;
+        if( NEVER(pVTab->pModule==0) ) continue;
+        if( pVTab->pModule->iVersion<4 ) continue;
+        if( pVTab->pModule->xIntegrity==0 ) continue;
+        sqlite3VdbeAddOp3(v, OP_VCheck, i, 3, isQuick);
+        pTab->nTabRef++;
+        sqlite3VdbeAppendP4(v, pTab, P4_TABLEREF);
+        a1 = sqlite3VdbeAddOp1(v, OP_IsNull, 3); VdbeCoverage(v);
+        integrityCheckResultRow(v);
+        sqlite3VdbeJumpHere(v, a1);
+        continue;
+      }
+#endif
     }
     {
       static const int iLn = VDBE_OFFSET_LINENO(2);
@@ -140086,44 +141142,63 @@ SQLITE_PRIVATE void sqlite3Pragma(
   **
   ** The optional argument is a bitmask of optimizations to perform:
   **
-  **    0x0001    Debugging mode.  Do not actually perform any optimizations
-  **              but instead return one line of text for each optimization
-  **              that would have been done.  Off by default.
+  **    0x00001    Debugging mode.  Do not actually perform any optimizations
+  **               but instead return one line of text for each optimization
+  **               that would have been done.  Off by default.
   **
-  **    0x0002    Run ANALYZE on tables that might benefit.  On by default.
-  **              See below for additional information.
+  **    0x00002    Run ANALYZE on tables that might benefit.  On by default.
+  **               See below for additional information.
   **
-  **    0x0004    (Not yet implemented) Record usage and performance
-  **              information from the current session in the
-  **              database file so that it will be available to "optimize"
-  **              pragmas run by future database connections.
+  **    0x00010    Run all ANALYZE operations using an analysis_limit that
+  **               is the lessor of the current analysis_limit and the
+  **               SQLITE_DEFAULT_OPTIMIZE_LIMIT compile-time option.
+  **               The default value of SQLITE_DEFAULT_OPTIMIZE_LIMIT is
+  **               currently (2024-02-19) set to 2000, which is such that
+  **               the worst case run-time for PRAGMA optimize on a 100MB
+  **               database will usually be less than 100 milliseconds on
+  **               a RaspberryPI-4 class machine.  On by default.
   **
-  **    0x0008    (Not yet implemented) Create indexes that might have
-  **              been helpful to recent queries
+  **    0x10000    Look at tables to see if they need to be reanalyzed
+  **               due to growth or shrinkage even if they have not been
+  **               queried during the current connection.  Off by default.
   **
-  ** The default MASK is and always shall be 0xfffe.  0xfffe means perform all
-  ** of the optimizations listed above except Debug Mode, including new
-  ** optimizations that have not yet been invented.  If new optimizations are
-  ** ever added that should be off by default, those off-by-default
-  ** optimizations will have bitmasks of 0x10000 or larger.
+  ** The default MASK is and always shall be 0x0fffe.  In the current
+  ** implementation, the default mask only covers the 0x00002 optimization,
+  ** though additional optimizations that are covered by 0x0fffe might be
+  ** added in the future.  Optimizations that are off by default and must
+  ** be explicitly requested have masks of 0x10000 or greater.
   **
   ** DETERMINATION OF WHEN TO RUN ANALYZE
   **
   ** In the current implementation, a table is analyzed if only if all of
   ** the following are true:
   **
-  ** (1) MASK bit 0x02 is set.
+  ** (1) MASK bit 0x00002 is set.
   **
-  ** (2) The query planner used sqlite_stat1-style statistics for one or
-  **     more indexes of the table at some point during the lifetime of
-  **     the current connection.
+  ** (2) The table is an ordinary table, not a virtual table or view.
   **
-  ** (3) One or more indexes of the table are currently unanalyzed OR
-  **     the number of rows in the table has increased by 25 times or more
-  **     since the last time ANALYZE was run.
+  ** (3) The table name does not begin with "sqlite_".
+  **
+  ** (4) One or more of the following is true:
+  **      (4a) The 0x10000 MASK bit is set.
+  **      (4b) One or more indexes on the table lacks an entry
+  **           in the sqlite_stat1 table.
+  **      (4c) The query planner used sqlite_stat1-style statistics for one
+  **           or more indexes of the table at some point during the lifetime
+  **           of the current connection.
+  **
+  ** (5) One or more of the following is true:
+  **      (5a) One or more indexes on the table lacks an entry
+  **           in the sqlite_stat1 table.  (Same as 4a)
+  **      (5b) The number of rows in the table has increased or decreased by
+  **           10-fold.  In other words, the current size of the table is
+  **           10 times larger than the size in sqlite_stat1 or else the
+  **           current size is less than 1/10th the size in sqlite_stat1.
   **
   ** The rules for when tables are analyzed are likely to change in
-  ** future releases.
+  ** future releases.  Future versions of SQLite might accept a string
+  ** literal argument to this pragma that contains a mnemonic description
+  ** of the options rather than a bitmap.
   */
   case PragTyp_OPTIMIZE: {
     int iDbLast;           /* Loop termination point for the schema loop */
@@ -140135,6 +141210,10 @@ SQLITE_PRIVATE void sqlite3Pragma(
     LogEst szThreshold;    /* Size threshold above which reanalysis needed */
     char *zSubSql;         /* SQL statement for the OP_SqlExec opcode */
     u32 opMask;            /* Mask of operations to perform */
+    int nLimit;            /* Analysis limit to use */
+    int nCheck = 0;        /* Number of tables to be optimized */
+    int nBtree = 0;        /* Number of btrees to scan */
+    int nIndex;            /* Number of indexes on the current table */
 
     if( zRight ){
       opMask = (u32)sqlite3Atoi(zRight);
@@ -140142,6 +141221,14 @@ SQLITE_PRIVATE void sqlite3Pragma(
     }else{
       opMask = 0xfffe;
     }
+    if( (opMask & 0x10)==0 ){
+      nLimit = 0;
+    }else if( db->nAnalysisLimit>0
+           && db->nAnalysisLimit<SQLITE_DEFAULT_OPTIMIZE_LIMIT ){
+      nLimit = 0;
+    }else{
+      nLimit = SQLITE_DEFAULT_OPTIMIZE_LIMIT;
+    }
     iTabCur = pParse->nTab++;
     for(iDbLast = zDb?iDb:db->nDb-1; iDb<=iDbLast; iDb++){
       if( iDb==1 ) continue;
@@ -140150,23 +141237,61 @@ SQLITE_PRIVATE void sqlite3Pragma(
       for(k=sqliteHashFirst(&pSchema->tblHash); k; k=sqliteHashNext(k)){
         pTab = (Table*)sqliteHashData(k);
 
-        /* If table pTab has not been used in a way that would benefit from
-        ** having analysis statistics during the current session, then skip it.
-        ** This also has the effect of skipping virtual tables and views */
-        if( (pTab->tabFlags & TF_StatsUsed)==0 ) continue;
+        /* This only works for ordinary tables */
+        if( !IsOrdinaryTable(pTab) ) continue;
 
-        /* Reanalyze if the table is 25 times larger than the last analysis */
-        szThreshold = pTab->nRowLogEst + 46; assert( sqlite3LogEst(25)==46 );
+        /* Do not scan system tables */
+        if( 0==sqlite3StrNICmp(pTab->zName, "sqlite_", 7) ) continue;
+
+        /* Find the size of the table as last recorded in sqlite_stat1.
+        ** If any index is unanalyzed, then the threshold is -1 to
+        ** indicate a new, unanalyzed index
+        */
+        szThreshold = pTab->nRowLogEst;
+        nIndex = 0;
         for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
+          nIndex++;
           if( !pIdx->hasStat1 ){
-            szThreshold = 0; /* Always analyze if any index lacks statistics */
-            break;
+            szThreshold = -1; /* Always analyze if any index lacks statistics */
           }
         }
-        if( szThreshold ){
-          sqlite3OpenTable(pParse, iTabCur, iDb, pTab, OP_OpenRead);
-          sqlite3VdbeAddOp3(v, OP_IfSmaller, iTabCur,
-                         sqlite3VdbeCurrentAddr(v)+2+(opMask&1), szThreshold);
+
+        /* If table pTab has not been used in a way that would benefit from
+        ** having analysis statistics during the current session, then skip it,
+        ** unless the 0x10000 MASK bit is set. */
+        if( (pTab->tabFlags & TF_MaybeReanalyze)!=0 ){
+          /* Check for size change if stat1 has been used for a query */
+        }else if( opMask & 0x10000 ){
+          /* Check for size change if 0x10000 is set */
+        }else if( pTab->pIndex!=0 && szThreshold<0 ){
+          /* Do analysis if unanalyzed indexes exists */
+        }else{
+          /* Otherwise, we can skip this table */
+          continue;
+        }
+
+        nCheck++;
+        if( nCheck==2 ){
+          /* If ANALYZE might be invoked two or more times, hold a write
+          ** transaction for efficiency */
+          sqlite3BeginWriteOperation(pParse, 0, iDb);
+        }
+        nBtree += nIndex+1;
+
+        /* Reanalyze if the table is 10 times larger or smaller than
+        ** the last analysis.  Unconditional reanalysis if there are
+        ** unanalyzed indexes. */
+        sqlite3OpenTable(pParse, iTabCur, iDb, pTab, OP_OpenRead);
+        if( szThreshold>=0 ){
+          const LogEst iRange = 33;   /* 10x size change */
+          sqlite3VdbeAddOp4Int(v, OP_IfSizeBetween, iTabCur,
+                         sqlite3VdbeCurrentAddr(v)+2+(opMask&1),
+                         szThreshold>=iRange ? szThreshold-iRange : -1,
+                         szThreshold+iRange);
+          VdbeCoverage(v);
+        }else{
+          sqlite3VdbeAddOp2(v, OP_Rewind, iTabCur,
+                         sqlite3VdbeCurrentAddr(v)+2+(opMask&1));
           VdbeCoverage(v);
         }
         zSubSql = sqlite3MPrintf(db, "ANALYZE \"%w\".\"%w\"",
@@ -140176,11 +141301,27 @@ SQLITE_PRIVATE void sqlite3Pragma(
           sqlite3VdbeAddOp4(v, OP_String8, 0, r1, 0, zSubSql, P4_DYNAMIC);
           sqlite3VdbeAddOp2(v, OP_ResultRow, r1, 1);
         }else{
-          sqlite3VdbeAddOp4(v, OP_SqlExec, 0, 0, 0, zSubSql, P4_DYNAMIC);
+          sqlite3VdbeAddOp4(v, OP_SqlExec, nLimit ? 0x02 : 00, nLimit, 0,
+                            zSubSql, P4_DYNAMIC);
         }
       }
     }
     sqlite3VdbeAddOp0(v, OP_Expire);
+
+    /* In a schema with a large number of tables and indexes, scale back
+    ** the analysis_limit to avoid excess run-time in the worst case.
+    */
+    if( !db->mallocFailed && nLimit>0 && nBtree>100 ){
+      int iAddr, iEnd;
+      VdbeOp *aOp;
+      nLimit = 100*nLimit/nBtree;
+      if( nLimit<100 ) nLimit = 100;
+      aOp = sqlite3VdbeGetOp(v, 0);
+      iEnd = sqlite3VdbeCurrentAddr(v);
+      for(iAddr=0; iAddr<iEnd; iAddr++){
+        if( aOp[iAddr].opcode==OP_SqlExec ) aOp[iAddr].p2 = nLimit;
+      }
+    }
     break;
   }
 
@@ -140444,9 +141585,9 @@ static int pragmaVtabBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
   seen[0] = 0;
   seen[1] = 0;
   for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){
-    if( pConstraint->usable==0 ) continue;
-    if( pConstraint->op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue;
     if( pConstraint->iColumn < pTab->iHidden ) continue;
+    if( pConstraint->op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue;
+    if( pConstraint->usable==0 ) return SQLITE_CONSTRAINT;
     j = pConstraint->iColumn - pTab->iHidden;
     assert( j < 2 );
     seen[j] = i+1;
@@ -140459,12 +141600,13 @@ static int pragmaVtabBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
   j = seen[0]-1;
   pIdxInfo->aConstraintUsage[j].argvIndex = 1;
   pIdxInfo->aConstraintUsage[j].omit = 1;
-  if( seen[1]==0 ) return SQLITE_OK;
   pIdxInfo->estimatedCost = (double)20;
   pIdxInfo->estimatedRows = 20;
-  j = seen[1]-1;
-  pIdxInfo->aConstraintUsage[j].argvIndex = 2;
-  pIdxInfo->aConstraintUsage[j].omit = 1;
+  if( seen[1] ){
+    j = seen[1]-1;
+    pIdxInfo->aConstraintUsage[j].argvIndex = 2;
+    pIdxInfo->aConstraintUsage[j].omit = 1;
+  }
   return SQLITE_OK;
 }
 
@@ -140484,6 +141626,7 @@ static void pragmaVtabCursorClear(PragmaVtabCursor *pCsr){
   int i;
   sqlite3_finalize(pCsr->pPragma);
   pCsr->pPragma = 0;
+  pCsr->iRowid = 0;
   for(i=0; i<ArraySize(pCsr->azArg); i++){
     sqlite3_free(pCsr->azArg[i]);
     pCsr->azArg[i] = 0;
@@ -141284,7 +142427,13 @@ SQLITE_PRIVATE void *sqlite3ParserAddCleanup(
   void (*xCleanup)(sqlite3*,void*),   /* The cleanup routine */
   void *pPtr                          /* Pointer to object to be cleaned up */
 ){
-  ParseCleanup *pCleanup = sqlite3DbMallocRaw(pParse->db, sizeof(*pCleanup));
+  ParseCleanup *pCleanup;
+  if( sqlite3FaultSim(300) ){
+    pCleanup = 0;
+    sqlite3OomFault(pParse->db);
+  }else{
+    pCleanup = sqlite3DbMallocRaw(pParse->db, sizeof(*pCleanup));
+  }
   if( pCleanup ){
     pCleanup->pNext = pParse->pCleanup;
     pParse->pCleanup = pCleanup;
@@ -143406,9 +144555,16 @@ static void generateSortTail(
   int addrExplain;                /* Address of OP_Explain instruction */
 #endif
 
-  ExplainQueryPlan2(addrExplain, (pParse, 0,
-        "USE TEMP B-TREE FOR %sORDER BY", pSort->nOBSat>0?"RIGHT PART OF ":"")
-  );
+  nKey = pOrderBy->nExpr - pSort->nOBSat;
+  if( pSort->nOBSat==0 || nKey==1 ){
+    ExplainQueryPlan2(addrExplain, (pParse, 0,
+      "USE TEMP B-TREE FOR %sORDER BY", pSort->nOBSat?"LAST TERM OF ":""
+    ));
+  }else{
+    ExplainQueryPlan2(addrExplain, (pParse, 0,
+      "USE TEMP B-TREE FOR LAST %d TERMS OF ORDER BY", nKey
+    ));
+  }
   sqlite3VdbeScanStatusRange(v, addrExplain,pSort->addrPush,pSort->addrPushEnd);
   sqlite3VdbeScanStatusCounters(v, addrExplain, addrExplain, pSort->addrPush);
 
@@ -143446,7 +144602,6 @@ static void generateSortTail(
       regRow = sqlite3GetTempRange(pParse, nColumn);
     }
   }
-  nKey = pOrderBy->nExpr - pSort->nOBSat;
   if( pSort->sortFlags & SORTFLAG_UseSorter ){
     int regSortOut = ++pParse->nMem;
     iSortTab = pParse->nTab++;
@@ -143686,11 +144841,7 @@ static const char *columnTypeImpl(
         ** data for the result-set column of the sub-select.
         */
         if( iCol<pS->pEList->nExpr
-#ifdef SQLITE_ALLOW_ROWID_IN_VIEW
-         && iCol>=0
-#else
-         && ALWAYS(iCol>=0)
-#endif
+         && (!ViewCanHaveRowid || iCol>=0)
         ){
           /* If iCol is less than zero, then the expression requests the
           ** rowid of the sub-select or view. This expression is legal (see
@@ -144055,8 +145206,7 @@ SQLITE_PRIVATE void sqlite3SubqueryColumnTypes(
   NameContext sNC;
 
   assert( pSelect!=0 );
-  testcase( (pSelect->selFlags & SF_Resolved)==0 );
-  assert( (pSelect->selFlags & SF_Resolved)!=0 || IN_RENAME_OBJECT );
+  assert( (pSelect->selFlags & SF_Resolved)!=0 );
   assert( pTab->nCol==pSelect->pEList->nExpr || pParse->nErr>0 );
   assert( aff==SQLITE_AFF_NONE || aff==SQLITE_AFF_BLOB );
   if( db->mallocFailed || IN_RENAME_OBJECT ) return;
@@ -144067,17 +145217,22 @@ SQLITE_PRIVATE void sqlite3SubqueryColumnTypes(
   for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){
     const char *zType;
     i64 n;
+    int m = 0;
+    Select *pS2 = pSelect;
     pTab->tabFlags |= (pCol->colFlags & COLFLAG_NOINSERT);
     p = a[i].pExpr;
     /* pCol->szEst = ... // Column size est for SELECT tables never used */
     pCol->affinity = sqlite3ExprAffinity(p);
+    while( pCol->affinity<=SQLITE_AFF_NONE && pS2->pNext!=0 ){
+      m |= sqlite3ExprDataType(pS2->pEList->a[i].pExpr);
+      pS2 = pS2->pNext;
+      pCol->affinity = sqlite3ExprAffinity(pS2->pEList->a[i].pExpr);
+    }
     if( pCol->affinity<=SQLITE_AFF_NONE ){
       pCol->affinity = aff;
     }
-    if( pCol->affinity>=SQLITE_AFF_TEXT && pSelect->pNext ){
-      int m = 0;
-      Select *pS2;
-      for(m=0, pS2=pSelect->pNext; pS2; pS2=pS2->pNext){
+    if( pCol->affinity>=SQLITE_AFF_TEXT && (pS2->pNext || pS2!=pSelect) ){
+      for(pS2=pS2->pNext; pS2; pS2=pS2->pNext){
         m |= sqlite3ExprDataType(pS2->pEList->a[i].pExpr);
       }
       if( pCol->affinity==SQLITE_AFF_TEXT && (m&0x01)!=0 ){
@@ -144107,12 +145262,12 @@ SQLITE_PRIVATE void sqlite3SubqueryColumnTypes(
       }
     }
     if( zType ){
-      i64 m = sqlite3Strlen30(zType);
+      const i64 k = sqlite3Strlen30(zType);
       n = sqlite3Strlen30(pCol->zCnName);
-      pCol->zCnName = sqlite3DbReallocOrFree(db, pCol->zCnName, n+m+2);
+      pCol->zCnName = sqlite3DbReallocOrFree(db, pCol->zCnName, n+k+2);
       pCol->colFlags &= ~(COLFLAG_HASTYPE|COLFLAG_HASCOLL);
       if( pCol->zCnName ){
-        memcpy(&pCol->zCnName[n+1], zType, m+1);
+        memcpy(&pCol->zCnName[n+1], zType, k+1);
         pCol->colFlags |= COLFLAG_HASTYPE;
       }
     }
@@ -146509,7 +147664,7 @@ static void constInsert(
 ){
   int i;
   assert( pColumn->op==TK_COLUMN );
-  assert( sqlite3ExprIsConstant(pValue) );
+  assert( sqlite3ExprIsConstant(pConst->pParse, pValue) );
 
   if( ExprHasProperty(pColumn, EP_FixedCol) ) return;
   if( sqlite3ExprAffinity(pValue)!=0 ) return;
@@ -146567,10 +147722,10 @@ static void findConstInWhere(WhereConst *pConst, Expr *pExpr){
   pLeft = pExpr->pLeft;
   assert( pRight!=0 );
   assert( pLeft!=0 );
-  if( pRight->op==TK_COLUMN && sqlite3ExprIsConstant(pLeft) ){
+  if( pRight->op==TK_COLUMN && sqlite3ExprIsConstant(pConst->pParse, pLeft) ){
     constInsert(pConst,pRight,pLeft,pExpr);
   }
-  if( pLeft->op==TK_COLUMN && sqlite3ExprIsConstant(pRight) ){
+  if( pLeft->op==TK_COLUMN && sqlite3ExprIsConstant(pConst->pParse, pRight) ){
     constInsert(pConst,pLeft,pRight,pExpr);
   }
 }
@@ -146791,6 +147946,18 @@ static int pushDownWindowCheck(Parse *pParse, Select *pSubq, Expr *pExpr){
 ** The hope is that the terms added to the inner query will make it more
 ** efficient.
 **
+** NAME AMBIGUITY
+**
+** This optimization is called the "WHERE-clause push-down optimization".
+**
+** Do not confuse this optimization with another unrelated optimization
+** with a similar name:  The "MySQL push-down optimization" causes WHERE
+** clause terms that can be evaluated using only the index and without
+** reference to the table are run first, so that if they are false,
+** unnecessary table seeks are avoided.
+**
+** RULES
+**
 ** Do not attempt this optimization if:
 **
 **   (1) (** This restriction was removed on 2017-09-29.  We used to
@@ -146856,15 +148023,19 @@ static int pushDownWindowCheck(Parse *pParse, Select *pSubq, Expr *pExpr){
 **       (9c) There is a RIGHT JOIN (or FULL JOIN) in between the ON/USING
 **            clause and the subquery.
 **
-**       Without this restriction, the push-down optimization might move
-**       the ON/USING filter expression from the left side of a RIGHT JOIN
-**       over to the right side, which leads to incorrect answers.  See
-**       also restriction (6) in sqlite3ExprIsSingleTableConstraint().
+**       Without this restriction, the WHERE-clause push-down optimization
+**       might move the ON/USING filter expression from the left side of a
+**       RIGHT JOIN over to the right side, which leads to incorrect answers.
+**       See also restriction (6) in sqlite3ExprIsSingleTableConstraint().
 **
 **  (10) The inner query is not the right-hand table of a RIGHT JOIN.
 **
 **  (11) The subquery is not a VALUES clause
 **
+**  (12) The WHERE clause is not "rowid ISNULL" or the equivalent.  This
+**       case only comes up if SQLite is compiled using
+**       SQLITE_ALLOW_ROWID_IN_VIEW.
+**
 ** Return 0 if no changes are made and non-zero if one or more WHERE clause
 ** terms are duplicated into the subquery.
 */
@@ -146975,7 +148146,19 @@ static int pushDownWhereTerms(
   }
 #endif
 
-  if( sqlite3ExprIsSingleTableConstraint(pWhere, pSrcList, iSrc) ){
+#ifdef SQLITE_ALLOW_ROWID_IN_VIEW
+  if( ViewCanHaveRowid && (pWhere->op==TK_ISNULL || pWhere->op==TK_NOTNULL) ){
+    Expr *pLeft = pWhere->pLeft;
+    if( ALWAYS(pLeft)
+     && pLeft->op==TK_COLUMN
+     && pLeft->iColumn < 0
+    ){
+      return 0;  /* Restriction (12) */
+    }
+  }
+#endif
+
+  if( sqlite3ExprIsSingleTableConstraint(pWhere, pSrcList, iSrc, 1) ){
     nChng++;
     pSubq->selFlags |= SF_PushDown;
     while( pSubq ){
@@ -147602,12 +148785,14 @@ SQLITE_PRIVATE int sqlite3ExpandSubquery(Parse *pParse, SrcItem *pFrom){
   while( pSel->pPrior ){ pSel = pSel->pPrior; }
   sqlite3ColumnsFromExprList(pParse, pSel->pEList,&pTab->nCol,&pTab->aCol);
   pTab->iPKey = -1;
+  pTab->eTabType = TABTYP_VIEW;
   pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );
 #ifndef SQLITE_ALLOW_ROWID_IN_VIEW
   /* The usual case - do not allow ROWID on a subquery */
   pTab->tabFlags |= TF_Ephemeral | TF_NoVisibleRowid;
 #else
-  pTab->tabFlags |= TF_Ephemeral;  /* Legacy compatibility mode */
+  /* Legacy compatibility mode */
+  pTab->tabFlags |= TF_Ephemeral | sqlite3Config.mNoVisibleRowid;
 #endif
   return pParse->nErr ? SQLITE_ERROR : SQLITE_OK;
 }
@@ -147875,7 +149060,7 @@ static int selectExpander(Walker *pWalker, Select *p){
             pNestedFrom = pFrom->pSelect->pEList;
             assert( pNestedFrom!=0 );
             assert( pNestedFrom->nExpr==pTab->nCol );
-            assert( VisibleRowid(pTab)==0 );
+            assert( VisibleRowid(pTab)==0 || ViewCanHaveRowid );
           }else{
             if( zTName && sqlite3StrICmp(zTName, zTabName)!=0 ){
               continue;
@@ -147907,7 +149092,8 @@ static int selectExpander(Walker *pWalker, Select *p){
             pUsing = 0;
           }
 
-          nAdd = pTab->nCol + (VisibleRowid(pTab) && (selFlags&SF_NestedFrom));
+          nAdd = pTab->nCol;
+          if( VisibleRowid(pTab) && (selFlags & SF_NestedFrom)!=0 ) nAdd++;
           for(j=0; j<nAdd; j++){
             const char *zName;
             struct ExprList_item *pX; /* Newly added ExprList term */
@@ -147989,7 +149175,8 @@ static int selectExpander(Walker *pWalker, Select *p){
             pX = &pNew->a[pNew->nExpr-1];
             assert( pX->zEName==0 );
             if( (selFlags & SF_NestedFrom)!=0 && !IN_RENAME_OBJECT ){
-              if( pNestedFrom ){
+              if( pNestedFrom && (!ViewCanHaveRowid || j<pNestedFrom->nExpr) ){
+                assert( j<pNestedFrom->nExpr );
                 pX->zEName = sqlite3DbStrDup(db, pNestedFrom->a[j].zEName);
                 testcase( pX->zEName==0 );
               }else{
@@ -148106,8 +149293,7 @@ static void selectAddSubqueryTypeInfo(Walker *pWalker, Select *p){
   if( p->selFlags & SF_HasTypeInfo ) return;
   p->selFlags |= SF_HasTypeInfo;
   pParse = pWalker->pParse;
-  testcase( (p->selFlags & SF_Resolved)==0 );
-  assert( (p->selFlags & SF_Resolved) || IN_RENAME_OBJECT );
+  assert( (p->selFlags & SF_Resolved) );
   pTabList = p->pSrc;
   for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){
     Table *pTab = pFrom->pTab;
@@ -148177,6 +149363,8 @@ SQLITE_PRIVATE void sqlite3SelectPrep(
 */
 static void printAggInfo(AggInfo *pAggInfo){
   int ii;
+  sqlite3DebugPrintf("AggInfo %d/%p:\n",
+     pAggInfo->selId, pAggInfo);
   for(ii=0; ii<pAggInfo->nColumn; ii++){
     struct AggInfo_col *pCol = &pAggInfo->aCol[ii];
     sqlite3DebugPrintf(
@@ -149367,7 +150555,7 @@ SQLITE_PRIVATE int sqlite3Select(
     /* Generate code for all sub-queries in the FROM clause
     */
     pSub = pItem->pSelect;
-    if( pSub==0 ) continue;
+    if( pSub==0 || pItem->addrFillSub!=0 ) continue;
 
     /* The code for a subquery should only be generated once. */
     assert( pItem->addrFillSub==0 );
@@ -149398,7 +150586,7 @@ SQLITE_PRIVATE int sqlite3Select(
 #endif
       assert( pItem->pSelect && (pItem->pSelect->selFlags & SF_PushDown)!=0 );
     }else{
-      TREETRACE(0x4000,pParse,p,("Push-down not possible\n"));
+      TREETRACE(0x4000,pParse,p,("WHERE-lcause push-down not possible\n"));
     }
 
     /* Convert unused result columns of the subquery into simple NULL
@@ -150279,6 +151467,12 @@ SQLITE_PRIVATE int sqlite3Select(
   sqlite3ExprListDelete(db, pMinMaxOrderBy);
 #ifdef SQLITE_DEBUG
   if( pAggInfo && !db->mallocFailed ){
+#if TREETRACE_ENABLED
+    if( sqlite3TreeTrace & 0x20 ){
+      TREETRACE(0x20,pParse,p,("Finished with AggInfo\n"));
+      printAggInfo(pAggInfo);
+    }
+#endif
     for(i=0; i<pAggInfo->nColumn; i++){
       Expr *pExpr = pAggInfo->aCol[i].pCExpr;
       if( pExpr==0 ) continue;
@@ -151460,6 +152654,72 @@ static ExprList *sqlite3ExpandReturning(
   return pNew;
 }
 
+/* If the Expr node is a subquery or an EXISTS operator or an IN operator that
+** uses a subquery, and if the subquery is SF_Correlated, then mark the
+** expression as EP_VarSelect.
+*/
+static int sqlite3ReturningSubqueryVarSelect(Walker *NotUsed, Expr *pExpr){
+  UNUSED_PARAMETER(NotUsed);
+  if( ExprUseXSelect(pExpr)
+   && (pExpr->x.pSelect->selFlags & SF_Correlated)!=0
+  ){
+    testcase( ExprHasProperty(pExpr, EP_VarSelect) );
+    ExprSetProperty(pExpr, EP_VarSelect);
+  }
+  return WRC_Continue;
+}
+
+
+/*
+** If the SELECT references the table pWalker->u.pTab, then do two things:
+**
+**    (1) Mark the SELECT as as SF_Correlated.
+**    (2) Set pWalker->eCode to non-zero so that the caller will know
+**        that (1) has happened.
+*/
+static int sqlite3ReturningSubqueryCorrelated(Walker *pWalker, Select *pSelect){
+  int i;
+  SrcList *pSrc;
+  assert( pSelect!=0 );
+  pSrc = pSelect->pSrc;
+  assert( pSrc!=0 );
+  for(i=0; i<pSrc->nSrc; i++){
+    if( pSrc->a[i].pTab==pWalker->u.pTab ){
+      testcase( pSelect->selFlags & SF_Correlated );
+      pSelect->selFlags |= SF_Correlated;
+      pWalker->eCode = 1;
+      break;
+    }
+  }
+  return WRC_Continue;
+}
+
+/*
+** Scan the expression list that is the argument to RETURNING looking
+** for subqueries that depend on the table which is being modified in the
+** statement that is hosting the RETURNING clause (pTab).  Mark all such
+** subqueries as SF_Correlated.  If the subqueries are part of an
+** expression, mark the expression as EP_VarSelect.
+**
+** https://sqlite.org/forum/forumpost/2c83569ce8945d39
+*/
+static void sqlite3ProcessReturningSubqueries(
+  ExprList *pEList,
+  Table *pTab
+){
+  Walker w;
+  memset(&w, 0, sizeof(w));
+  w.xExprCallback = sqlite3ExprWalkNoop;
+  w.xSelectCallback = sqlite3ReturningSubqueryCorrelated;
+  w.u.pTab = pTab;
+  sqlite3WalkExprList(&w, pEList);
+  if( w.eCode ){
+    w.xExprCallback = sqlite3ReturningSubqueryVarSelect;
+    w.xSelectCallback = sqlite3SelectWalkNoop;
+    sqlite3WalkExprList(&w, pEList);
+  }
+}
+
 /*
 ** Generate code for the RETURNING trigger.  Unlike other triggers
 ** that invoke a subprogram in the bytecode, the code for RETURNING
@@ -151496,6 +152756,7 @@ static void codeReturningTrigger(
   sSelect.pSrc = &sFrom;
   sFrom.nSrc = 1;
   sFrom.a[0].pTab = pTab;
+  sFrom.a[0].zName = pTab->zName; /* tag-20240424-1 */
   sFrom.a[0].iCursor = -1;
   sqlite3SelectPrep(pParse, &sSelect, 0);
   if( pParse->nErr==0 ){
@@ -151522,6 +152783,7 @@ static void codeReturningTrigger(
       int i;
       int nCol = pNew->nExpr;
       int reg = pParse->nMem+1;
+      sqlite3ProcessReturningSubqueries(pNew, pTab);
       pParse->nMem += nCol+2;
       pReturning->iRetReg = reg;
       for(i=0; i<nCol; i++){
@@ -152923,6 +154185,9 @@ SQLITE_PRIVATE void sqlite3Update(
       }
     }
     if( chngRowid==0 && pPk==0 ){
+#ifdef SQLITE_ALLOW_ROWID_IN_VIEW
+      if( isView ) sqlite3VdbeAddOp2(v, OP_Null, 0, regOldRowid);
+#endif
       sqlite3VdbeAddOp2(v, OP_Copy, regOldRowid, regNewRowid);
     }
   }
@@ -153460,7 +154725,8 @@ SQLITE_PRIVATE Upsert *sqlite3UpsertNew(
 SQLITE_PRIVATE int sqlite3UpsertAnalyzeTarget(
   Parse *pParse,     /* The parsing context */
   SrcList *pTabList, /* Table into which we are inserting */
-  Upsert *pUpsert    /* The ON CONFLICT clauses */
+  Upsert *pUpsert,   /* The ON CONFLICT clauses */
+  Upsert *pAll       /* Complete list of all ON CONFLICT clauses */
 ){
   Table *pTab;            /* That table into which we are inserting */
   int rc;                 /* Result code */
@@ -153563,6 +154829,14 @@ SQLITE_PRIVATE int sqlite3UpsertAnalyzeTarget(
         continue;
       }
       pUpsert->pUpsertIdx = pIdx;
+      if( sqlite3UpsertOfIndex(pAll,pIdx)!=pUpsert ){
+        /* Really this should be an error.  The isDup ON CONFLICT clause will
+        ** never fire.  But this problem was not discovered until three years
+        ** after multi-CONFLICT upsert was added, and so we silently ignore
+        ** the problem to prevent breaking applications that might actually
+        ** have redundant ON CONFLICT clauses. */
+        pUpsert->isDup = 1;
+      }
       break;
     }
     if( pUpsert->pUpsertIdx==0 ){
@@ -153589,9 +154863,13 @@ SQLITE_PRIVATE int sqlite3UpsertNextIsIPK(Upsert *pUpsert){
   Upsert *pNext;
   if( NEVER(pUpsert==0) ) return 0;
   pNext = pUpsert->pNextUpsert;
-  if( pNext==0 ) return 1;
-  if( pNext->pUpsertTarget==0 ) return 1;
-  if( pNext->pUpsertIdx==0 ) return 1;
+  while( 1 /*exit-by-return*/ ){
+    if( pNext==0 ) return 1;
+    if( pNext->pUpsertTarget==0 ) return 1;
+    if( pNext->pUpsertIdx==0 ) return 1;
+    if( !pNext->isDup ) return 0;
+    pNext = pNext->pNextUpsert;
+  }
   return 0;
 }
 
@@ -154716,6 +155994,8 @@ static int vtabCallConstructor(
   db->pVtabCtx = &sCtx;
   pTab->nTabRef++;
   rc = xConstruct(db, pMod->pAux, nArg, azArg, &pVTable->pVtab, &zErr);
+  assert( pTab!=0 );
+  assert( pTab->nTabRef>1 || rc!=SQLITE_OK );
   sqlite3DeleteTable(db, pTab);
   db->pVtabCtx = sCtx.pPrior;
   if( rc==SQLITE_NOMEM ) sqlite3OomFault(db);
@@ -154738,7 +156018,7 @@ static int vtabCallConstructor(
     pVTable->nRef = 1;
     if( sCtx.bDeclared==0 ){
       const char *zFormat = "vtable constructor did not declare schema: %s";
-      *pzErr = sqlite3MPrintf(db, zFormat, pTab->zName);
+      *pzErr = sqlite3MPrintf(db, zFormat, zModuleName);
       sqlite3VtabUnlock(pVTable);
       rc = SQLITE_ERROR;
     }else{
@@ -154916,12 +156196,30 @@ SQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
   Table *pTab;
   Parse sParse;
   int initBusy;
+  int i;
+  const unsigned char *z;
+  static const u8 aKeyword[] = { TK_CREATE, TK_TABLE, 0 };
 
 #ifdef SQLITE_ENABLE_API_ARMOR
   if( !sqlite3SafetyCheckOk(db) || zCreateTable==0 ){
     return SQLITE_MISUSE_BKPT;
   }
 #endif
+
+  /* Verify that the first two keywords in the CREATE TABLE statement
+  ** really are "CREATE" and "TABLE".  If this is not the case, then
+  ** sqlite3_declare_vtab() is being misused.
+  */
+  z = (const unsigned char*)zCreateTable;
+  for(i=0; aKeyword[i]; i++){
+    int tokenType = 0;
+    do{ z += sqlite3GetToken(z, &tokenType); }while( tokenType==TK_SPACE );
+    if( tokenType!=aKeyword[i] ){
+      sqlite3ErrorWithMsg(db, SQLITE_ERROR, "syntax error");
+      return SQLITE_ERROR;
+    }
+  }
+
   sqlite3_mutex_enter(db->mutex);
   pCtx = db->pVtabCtx;
   if( !pCtx || pCtx->bDeclared ){
@@ -154929,6 +156227,7 @@ SQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
     sqlite3_mutex_leave(db->mutex);
     return SQLITE_MISUSE_BKPT;
   }
+
   pTab = pCtx->pTab;
   assert( IsVirtual(pTab) );
 
@@ -154942,11 +156241,10 @@ SQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
   initBusy = db->init.busy;
   db->init.busy = 0;
   sParse.nQueryLoop = 1;
-  if( SQLITE_OK==sqlite3RunParser(&sParse, zCreateTable)
-   && ALWAYS(sParse.pNewTable!=0)
-   && ALWAYS(!db->mallocFailed)
-   && IsOrdinaryTable(sParse.pNewTable)
-  ){
+  if( SQLITE_OK==sqlite3RunParser(&sParse, zCreateTable) ){
+    assert( sParse.pNewTable!=0 );
+    assert( !db->mallocFailed );
+    assert( IsOrdinaryTable(sParse.pNewTable) );
     assert( sParse.zErrMsg==0 );
     if( !pTab->aCol ){
       Table *pNew = sParse.pNewTable;
@@ -157441,6 +158739,27 @@ static SQLITE_NOINLINE void filterPullDown(
   }
 }
 
+/*
+** Loop pLoop is a WHERE_INDEXED level that uses at least one IN(...)
+** operator. Return true if level pLoop is guaranteed to visit only one
+** row for each key generated for the index.
+*/
+static int whereLoopIsOneRow(WhereLoop *pLoop){
+  if( pLoop->u.btree.pIndex->onError
+   && pLoop->nSkip==0
+   && pLoop->u.btree.nEq==pLoop->u.btree.pIndex->nKeyCol
+  ){
+    int ii;
+    for(ii=0; ii<pLoop->u.btree.nEq; ii++){
+      if( pLoop->aLTerm[ii]->eOperator & (WO_IS|WO_ISNULL) ){
+        return 0;
+      }
+    }
+    return 1;
+  }
+  return 0;
+}
+
 /*
 ** Generate code for the start of the iLevel-th loop in the WHERE clause
 ** implementation described by pWInfo.
@@ -157519,7 +158838,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
   if( pLevel->iFrom>0 && (pTabItem[0].fg.jointype & JT_LEFT)!=0 ){
     pLevel->iLeftJoin = ++pParse->nMem;
     sqlite3VdbeAddOp2(v, OP_Integer, 0, pLevel->iLeftJoin);
-    VdbeComment((v, "init LEFT JOIN no-match flag"));
+    VdbeComment((v, "init LEFT JOIN match flag"));
   }
 
   /* Compute a safe address to jump to if we discover that the table for
@@ -158188,7 +159507,9 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
     }
 
     /* Record the instruction used to terminate the loop. */
-    if( pLoop->wsFlags & WHERE_ONEROW ){
+    if( (pLoop->wsFlags & WHERE_ONEROW)
+     || (pLevel->u.in.nIn && regBignull==0 && whereLoopIsOneRow(pLoop))
+    ){
       pLevel->op = OP_Noop;
     }else if( bRev ){
       pLevel->op = OP_Prev;
@@ -158578,6 +159899,12 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
   ** iLoop==3: Code all remaining expressions.
   **
   ** An effort is made to skip unnecessary iterations of the loop.
+  **
+  ** This optimization of causing simple query restrictions to occur before
+  ** more complex one is call the "push-down" optimization in MySQL.  Here
+  ** in SQLite, the name is "MySQL push-down", since there is also another
+  ** totally unrelated optimization called "WHERE-clause push-down".
+  ** Sometimes the qualifier is omitted, resulting in an ambiguity, so beware.
   */
   iLoop = (pIdx ? 1 : 2);
   do{
@@ -158828,7 +160155,16 @@ SQLITE_PRIVATE SQLITE_NOINLINE void sqlite3WhereRightJoinLoop(
                                   pRJ->regReturn);
   for(k=0; k<iLevel; k++){
     int iIdxCur;
+    SrcItem *pRight;
+    assert( pWInfo->a[k].pWLoop->iTab == pWInfo->a[k].iFrom );
+    pRight = &pWInfo->pTabList->a[pWInfo->a[k].iFrom];
     mAll |= pWInfo->a[k].pWLoop->maskSelf;
+    if( pRight->fg.viaCoroutine ){
+      sqlite3VdbeAddOp3(
+          v, OP_Null, 0, pRight->regResult,
+          pRight->regResult + pRight->pSelect->pEList->nExpr-1
+      );
+    }
     sqlite3VdbeAddOp1(v, OP_NullRow, pWInfo->a[k].iTabCur);
     iIdxCur = pWInfo->a[k].iIdxCur;
     if( iIdxCur ){
@@ -159885,7 +161221,7 @@ static SQLITE_NOINLINE int exprMightBeIndexed2(
         if( pIdx->aiColumn[i]!=XN_EXPR ) continue;
         assert( pIdx->bHasExpr );
         if( sqlite3ExprCompareSkip(pExpr,pIdx->aColExpr->a[i].pExpr,iCur)==0
-          && pExpr->op!=TK_STRING
+         && !sqlite3ExprIsConstant(0,pIdx->aColExpr->a[i].pExpr)
         ){
           aiCurCol[0] = iCur;
           aiCurCol[1] = XN_EXPR;
@@ -160534,6 +161870,7 @@ SQLITE_PRIVATE void SQLITE_NOINLINE sqlite3WhereAddLimit(WhereClause *pWC, Selec
         continue;
       }
       if( pWC->a[ii].leftCursor!=iCsr ) return;
+      if( pWC->a[ii].prereqRight!=0 ) return;
     }
 
     /* Check condition (5). Return early if it is not met. */
@@ -160548,12 +161885,14 @@ SQLITE_PRIVATE void SQLITE_NOINLINE sqlite3WhereAddLimit(WhereClause *pWC, Selec
 
     /* All conditions are met. Add the terms to the where-clause object. */
     assert( p->pLimit->op==TK_LIMIT );
-    whereAddLimitExpr(pWC, p->iLimit, p->pLimit->pLeft,
-                      iCsr, SQLITE_INDEX_CONSTRAINT_LIMIT);
-    if( p->iOffset>0 ){
+    if( p->iOffset!=0 && (p->selFlags & SF_Compound)==0 ){
       whereAddLimitExpr(pWC, p->iOffset, p->pLimit->pRight,
                         iCsr, SQLITE_INDEX_CONSTRAINT_OFFSET);
     }
+    if( p->iOffset==0 || (p->selFlags & SF_Compound)==0 ){
+      whereAddLimitExpr(pWC, p->iLimit, p->pLimit->pLeft,
+                        iCsr, SQLITE_INDEX_CONSTRAINT_LIMIT);
+    }
   }
 }
 
@@ -161071,6 +162410,42 @@ static Expr *whereRightSubexprIsColumn(Expr *p){
   return 0;
 }
 
+/*
+** Term pTerm is guaranteed to be a WO_IN term. It may be a component term
+** of a vector IN expression of the form "(x, y, ...) IN (SELECT ...)".
+** This function checks to see if the term is compatible with an index
+** column with affinity idxaff (one of the SQLITE_AFF_XYZ values). If so,
+** it returns a pointer to the name of the collation sequence (e.g. "BINARY"
+** or "NOCASE") used by the comparison in pTerm. If it is not compatible
+** with affinity idxaff, NULL is returned.
+*/
+static SQLITE_NOINLINE const char *indexInAffinityOk(
+  Parse *pParse,
+  WhereTerm *pTerm,
+  u8 idxaff
+){
+  Expr *pX = pTerm->pExpr;
+  Expr inexpr;
+
+  assert( pTerm->eOperator & WO_IN );
+
+  if( sqlite3ExprIsVector(pX->pLeft) ){
+    int iField = pTerm->u.x.iField - 1;
+    inexpr.flags = 0;
+    inexpr.op = TK_EQ;
+    inexpr.pLeft = pX->pLeft->x.pList->a[iField].pExpr;
+    assert( ExprUseXSelect(pX) );
+    inexpr.pRight = pX->x.pSelect->pEList->a[iField].pExpr;
+    pX = &inexpr;
+  }
+
+  if( sqlite3IndexAffinityOk(pX, idxaff) ){
+    CollSeq *pRet = sqlite3ExprCompareCollSeq(pParse, pX);
+    return pRet ? pRet->zName : sqlite3StrBINARY;
+  }
+  return 0;
+}
+
 /*
 ** Advance to the next WhereTerm that matches according to the criteria
 ** established when the pScan object was initialized by whereScanInit().
@@ -161121,16 +162496,24 @@ static WhereTerm *whereScanNext(WhereScan *pScan){
           if( (pTerm->eOperator & pScan->opMask)!=0 ){
             /* Verify the affinity and collating sequence match */
             if( pScan->zCollName && (pTerm->eOperator & WO_ISNULL)==0 ){
-              CollSeq *pColl;
+              const char *zCollName;
               Parse *pParse = pWC->pWInfo->pParse;
               pX = pTerm->pExpr;
-              if( !sqlite3IndexAffinityOk(pX, pScan->idxaff) ){
-                continue;
+
+              if( (pTerm->eOperator & WO_IN) ){
+                zCollName = indexInAffinityOk(pParse, pTerm, pScan->idxaff);
+                if( !zCollName ) continue;
+              }else{
+                CollSeq *pColl;
+                if( !sqlite3IndexAffinityOk(pX, pScan->idxaff) ){
+                  continue;
+                }
+                assert(pX->pLeft);
+                pColl = sqlite3ExprCompareCollSeq(pParse, pX);
+                zCollName = pColl ? pColl->zName : sqlite3StrBINARY;
               }
-              assert(pX->pLeft);
-              pColl = sqlite3ExprCompareCollSeq(pParse, pX);
-              if( pColl==0 ) pColl = pParse->db->pDfltColl;
-              if( sqlite3StrICmp(pColl->zName, pScan->zCollName) ){
+
+              if( sqlite3StrICmp(zCollName, pScan->zCollName) ){
                 continue;
               }
             }
@@ -161482,9 +162865,13 @@ static void translateColumnToCopy(
 ** are no-ops.
 */
 #if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(WHERETRACE_ENABLED)
-static void whereTraceIndexInfoInputs(sqlite3_index_info *p){
+static void whereTraceIndexInfoInputs(
+  sqlite3_index_info *p,   /* The IndexInfo object */
+  Table *pTab              /* The TABLE that is the virtual table */
+){
   int i;
   if( (sqlite3WhereTrace & 0x10)==0 ) return;
+  sqlite3DebugPrintf("sqlite3_index_info inputs for %s:\n", pTab->zName);
   for(i=0; i<p->nConstraint; i++){
     sqlite3DebugPrintf(
        "  constraint[%d]: col=%d termid=%d op=%d usabled=%d collseq=%s\n",
@@ -161502,9 +162889,13 @@ static void whereTraceIndexInfoInputs(sqlite3_index_info *p){
        p->aOrderBy[i].desc);
   }
 }
-static void whereTraceIndexInfoOutputs(sqlite3_index_info *p){
+static void whereTraceIndexInfoOutputs(
+  sqlite3_index_info *p,   /* The IndexInfo object */
+  Table *pTab              /* The TABLE that is the virtual table */
+){
   int i;
   if( (sqlite3WhereTrace & 0x10)==0 ) return;
+  sqlite3DebugPrintf("sqlite3_index_info outputs for %s:\n", pTab->zName);
   for(i=0; i<p->nConstraint; i++){
     sqlite3DebugPrintf("  usage[%d]: argvIdx=%d omit=%d\n",
        i,
@@ -161518,8 +162909,8 @@ static void whereTraceIndexInfoOutputs(sqlite3_index_info *p){
   sqlite3DebugPrintf("  estimatedRows=%lld\n", p->estimatedRows);
 }
 #else
-#define whereTraceIndexInfoInputs(A)
-#define whereTraceIndexInfoOutputs(A)
+#define whereTraceIndexInfoInputs(A,B)
+#define whereTraceIndexInfoOutputs(A,B)
 #endif
 
 /*
@@ -161703,7 +163094,7 @@ static SQLITE_NOINLINE void constructAutomaticIndex(
     ** WHERE clause (or the ON clause of a LEFT join) that constrain which
     ** rows of the target table (pSrc) that can be used. */
     if( (pTerm->wtFlags & TERM_VIRTUAL)==0
-     && sqlite3ExprIsSingleTableConstraint(pExpr, pTabList, pLevel->iFrom)
+     && sqlite3ExprIsSingleTableConstraint(pExpr, pTabList, pLevel->iFrom, 0)
     ){
       pPartial = sqlite3ExprAnd(pParse, pPartial,
                                 sqlite3ExprDup(pParse->db, pExpr, 0));
@@ -161745,7 +163136,7 @@ static SQLITE_NOINLINE void constructAutomaticIndex(
   ** if they go out of sync.
   */
   if( IsView(pTable) ){
-    extraCols = ALLBITS;
+    extraCols = ALLBITS & ~idxCols;
   }else{
     extraCols = pSrc->colUsed & (~idxCols | MASKBIT(BMS-1));
   }
@@ -161972,7 +163363,7 @@ static SQLITE_NOINLINE void sqlite3ConstructBloomFilter(
     for(pTerm=pWInfo->sWC.a; pTerm<pWCEnd; pTerm++){
       Expr *pExpr = pTerm->pExpr;
       if( (pTerm->wtFlags & TERM_VIRTUAL)==0
-       && sqlite3ExprIsSingleTableConstraint(pExpr, pTabList, iSrc)
+       && sqlite3ExprIsSingleTableConstraint(pExpr, pTabList, iSrc, 0)
       ){
         sqlite3ExprIfFalse(pParse, pTerm->pExpr, addrCont, SQLITE_JUMPIFNULL);
       }
@@ -162098,7 +163489,7 @@ static sqlite3_index_info *allocateIndexInfo(
       Expr *pE2;
 
       /* Skip over constant terms in the ORDER BY clause */
-      if( sqlite3ExprIsConstant(pExpr) ){
+      if( sqlite3ExprIsConstant(0, pExpr) ){
         continue;
       }
 
@@ -162133,7 +163524,7 @@ static sqlite3_index_info *allocateIndexInfo(
     }
     if( i==n ){
       nOrderBy = n;
-      if( (pWInfo->wctrlFlags & WHERE_DISTINCTBY) ){
+      if( (pWInfo->wctrlFlags & WHERE_DISTINCTBY) && !pSrc->fg.rowidUsed ){
         eDistinct = 2 + ((pWInfo->wctrlFlags & WHERE_SORTBYGROUP)!=0);
       }else if( pWInfo->wctrlFlags & WHERE_GROUPBY ){
         eDistinct = 1;
@@ -162210,7 +163601,7 @@ static sqlite3_index_info *allocateIndexInfo(
   pIdxInfo->nConstraint = j;
   for(i=j=0; i<nOrderBy; i++){
     Expr *pExpr = pOrderBy->a[i].pExpr;
-    if( sqlite3ExprIsConstant(pExpr) ) continue;
+    if( sqlite3ExprIsConstant(0, pExpr) ) continue;
     assert( pExpr->op==TK_COLUMN
          || (pExpr->op==TK_COLLATE && pExpr->pLeft->op==TK_COLUMN
               && pExpr->iColumn==pExpr->pLeft->iColumn) );
@@ -162262,11 +163653,11 @@ static int vtabBestIndex(Parse *pParse, Table *pTab, sqlite3_index_info *p){
   sqlite3_vtab *pVtab = sqlite3GetVTable(pParse->db, pTab)->pVtab;
   int rc;
 
-  whereTraceIndexInfoInputs(p);
+  whereTraceIndexInfoInputs(p, pTab);
   pParse->db->nSchemaLock++;
   rc = pVtab->pModule->xBestIndex(pVtab, p);
   pParse->db->nSchemaLock--;
-  whereTraceIndexInfoOutputs(p);
+  whereTraceIndexInfoOutputs(p, pTab);
 
   if( rc!=SQLITE_OK && rc!=SQLITE_CONSTRAINT ){
     if( rc==SQLITE_NOMEM ){
@@ -163744,7 +165135,9 @@ static int whereLoopAddBtreeIndex(
   }
   if( pProbe->bUnordered || pProbe->bLowQual ){
     if( pProbe->bUnordered ) opMask &= ~(WO_GT|WO_GE|WO_LT|WO_LE);
-    if( pProbe->bLowQual )   opMask &= ~(WO_EQ|WO_IN|WO_IS);
+    if( pProbe->bLowQual && pSrc->fg.isIndexedBy==0 ){
+      opMask &= ~(WO_EQ|WO_IN|WO_IS);
+    }
   }
 
   assert( pNew->u.btree.nEq<pProbe->nColumn );
@@ -164011,10 +165404,13 @@ static int whereLoopAddBtreeIndex(
       }
     }
 
-    /* Set rCostIdx to the cost of visiting selected rows in index. Add
-    ** it to pNew->rRun, which is currently set to the cost of the index
-    ** seek only. Then, if this is a non-covering index, add the cost of
-    ** visiting the rows in the main table.  */
+    /* Set rCostIdx to the estimated cost of visiting selected rows in the
+    ** index.  The estimate is the sum of two values:
+    **   1.  The cost of doing one search-by-key to find the first matching
+    **       entry
+    **   2.  Stepping forward in the index pNew->nOut times to find all
+    **       additional matching entries.
+    */
     assert( pSrc->pTab->szTabRow>0 );
     if( pProbe->idxType==SQLITE_IDXTYPE_IPK ){
       /* The pProbe->szIdxRow is low for an IPK table since the interior
@@ -164025,7 +165421,15 @@ static int whereLoopAddBtreeIndex(
     }else{
       rCostIdx = pNew->nOut + 1 + (15*pProbe->szIdxRow)/pSrc->pTab->szTabRow;
     }
-    pNew->rRun = sqlite3LogEstAdd(rLogSize, rCostIdx);
+    rCostIdx = sqlite3LogEstAdd(rLogSize, rCostIdx);
+
+    /* Estimate the cost of running the loop.  If all data is coming
+    ** from the index, then this is just the cost of doing the index
+    ** lookup and scan.  But if some data is coming out of the main table,
+    ** we also have to add in the cost of doing pNew->nOut searches to
+    ** locate the row in the main table that corresponds to the index entry.
+    */
+    pNew->rRun = rCostIdx;
     if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK|WHERE_EXPRIDX))==0 ){
       pNew->rRun = sqlite3LogEstAdd(pNew->rRun, pNew->nOut + 16);
     }
@@ -164131,7 +165535,9 @@ static int indexMightHelpWithOrderBy(
   for(ii=0; ii<pOB->nExpr; ii++){
     Expr *pExpr = sqlite3ExprSkipCollateAndLikely(pOB->a[ii].pExpr);
     if( NEVER(pExpr==0) ) continue;
-    if( pExpr->op==TK_COLUMN && pExpr->iTable==iCursor ){
+    if( (pExpr->op==TK_COLUMN || pExpr->op==TK_AGG_COLUMN)
+     && pExpr->iTable==iCursor
+    ){
       if( pExpr->iColumn<0 ) return 1;
       for(jj=0; jj<pIndex->nKeyCol; jj++){
         if( pExpr->iColumn==pIndex->aiColumn[jj] ) return 1;
@@ -164388,7 +165794,7 @@ static void wherePartIdxExpr(
     u8 aff;
 
     if( pLeft->op!=TK_COLUMN ) return;
-    if( !sqlite3ExprIsConstant(pRight) ) return;
+    if( !sqlite3ExprIsConstant(0, pRight) ) return;
     if( !sqlite3IsBinary(sqlite3ExprCompareCollSeq(pParse, pPart)) ) return;
     if( pLeft->iColumn<0 ) return;
     aff = pIdx->pTable->aCol[pLeft->iColumn].affinity;
@@ -164737,7 +166143,7 @@ static int whereLoopAddBtree(
       ** unique index is used (making the index functionally non-unique)
       ** then the sqlite_stat1 data becomes important for scoring the
       ** plan */
-      pTab->tabFlags |= TF_StatsUsed;
+      pTab->tabFlags |= TF_MaybeReanalyze;
     }
 #ifdef SQLITE_ENABLE_STAT4
     sqlite3Stat4ProbeFree(pBuilder->pRec);
@@ -164759,6 +166165,21 @@ static int isLimitTerm(WhereTerm *pTerm){
       && pTerm->eMatchOp<=SQLITE_INDEX_CONSTRAINT_OFFSET;
 }
 
+/*
+** Return true if the first nCons constraints in the pUsage array are
+** marked as in-use (have argvIndex>0). False otherwise.
+*/
+static int allConstraintsUsed(
+  struct sqlite3_index_constraint_usage *aUsage,
+  int nCons
+){
+  int ii;
+  for(ii=0; ii<nCons; ii++){
+    if( aUsage[ii].argvIndex<=0 ) return 0;
+  }
+  return 1;
+}
+
 /*
 ** Argument pIdxInfo is already populated with all constraints that may
 ** be used by the virtual table identified by pBuilder->pNew->iTab. This
@@ -164899,13 +166320,20 @@ static int whereLoopAddVirtualOne(
         *pbIn = 1; assert( (mExclude & WO_IN)==0 );
       }
 
+      /* Unless pbRetryLimit is non-NULL, there should be no LIMIT/OFFSET
+      ** terms. And if there are any, they should follow all other terms. */
       assert( pbRetryLimit || !isLimitTerm(pTerm) );
-      if( isLimitTerm(pTerm) && *pbIn ){
+      assert( !isLimitTerm(pTerm) || i>=nConstraint-2 );
+      assert( !isLimitTerm(pTerm) || i==nConstraint-1 || isLimitTerm(pTerm+1) );
+
+      if( isLimitTerm(pTerm) && (*pbIn || !allConstraintsUsed(pUsage, i)) ){
         /* If there is an IN(...) term handled as an == (separate call to
         ** xFilter for each value on the RHS of the IN) and a LIMIT or
-        ** OFFSET term handled as well, the plan is unusable. Set output
-        ** variable *pbRetryLimit to true to tell the caller to retry with
-        ** LIMIT and OFFSET disabled. */
+        ** OFFSET term handled as well, the plan is unusable. Similarly,
+        ** if there is a LIMIT/OFFSET and there are other unused terms,
+        ** the plan cannot be used. In these cases set variable *pbRetryLimit
+        ** to true to tell the caller to retry with LIMIT and OFFSET
+        ** disabled. */
         if( pIdxInfo->needToFreeIdxStr ){
           sqlite3_free(pIdxInfo->idxStr);
           pIdxInfo->idxStr = 0;
@@ -165762,7 +167190,7 @@ static i8 wherePathSatisfiesOrderBy(
         if( MASKBIT(i) & obSat ) continue;
         p = pOrderBy->a[i].pExpr;
         mTerm = sqlite3WhereExprUsage(&pWInfo->sMaskSet,p);
-        if( mTerm==0 && !sqlite3ExprIsConstant(p) ) continue;
+        if( mTerm==0 && !sqlite3ExprIsConstant(0,p) ) continue;
         if( (mTerm&~orderDistinctMask)==0 ){
           obSat |= MASKBIT(i);
         }
@@ -166231,10 +167659,9 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
       if( pFrom->isOrdered==pWInfo->pOrderBy->nExpr ){
         pWInfo->eDistinct = WHERE_DISTINCT_ORDERED;
       }
-      if( pWInfo->pSelect->pOrderBy
-       && pWInfo->nOBSat > pWInfo->pSelect->pOrderBy->nExpr ){
-        pWInfo->nOBSat = pWInfo->pSelect->pOrderBy->nExpr;
-      }
+      /* vvv--- See check-in [12ad822d9b827777] on 2023-03-16 ---vvv */
+      assert( pWInfo->pSelect->pOrderBy==0
+           || pWInfo->nOBSat <= pWInfo->pSelect->pOrderBy->nExpr );
     }else{
       pWInfo->revMask = pFrom->revLoop;
       if( pWInfo->nOBSat<=0 ){
@@ -166277,7 +167704,6 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
     }
   }
 
-
   pWInfo->nRowOut = pFrom->nRow;
 
   /* Free temporary memory and return success */
@@ -166285,6 +167711,83 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
   return SQLITE_OK;
 }
 
+/*
+** This routine implements a heuristic designed to improve query planning.
+** This routine is called in between the first and second call to
+** wherePathSolver().  Hence the name "Interstage" "Heuristic".
+**
+** The first call to wherePathSolver() (hereafter just "solver()") computes
+** the best path without regard to the order of the outputs.  The second call
+** to the solver() builds upon the first call to try to find an alternative
+** path that satisfies the ORDER BY clause.
+**
+** This routine looks at the results of the first solver() run, and for
+** every FROM clause term in the resulting query plan that uses an equality
+** constraint against an index, disable other WhereLoops for that same
+** FROM clause term that would try to do a full-table scan.  This prevents
+** an index search from being converted into a full-table scan in order to
+** satisfy an ORDER BY clause, since even though we might get slightly better
+** performance using the full-scan without sorting if the output size
+** estimates are very precise, we might also get severe performance
+** degradation using the full-scan if the output size estimate is too large.
+** It is better to err on the side of caution.
+**
+** Except, if the first solver() call generated a full-table scan in an outer
+** loop then stop this analysis at the first full-scan, since the second
+** solver() run might try to swap that full-scan for another in order to
+** get the output into the correct order.  In other words, we allow a
+** rewrite like this:
+**
+**     First Solver()                      Second Solver()
+**       |-- SCAN t1                         |-- SCAN t2
+**       |-- SEARCH t2                       `-- SEARCH t1
+**       `-- SORT USING B-TREE
+**
+** The purpose of this routine is to disallow rewrites such as:
+**
+**     First Solver()                      Second Solver()
+**       |-- SEARCH t1                       |-- SCAN t2     <--- bad!
+**       |-- SEARCH t2                       `-- SEARCH t1
+**       `-- SORT USING B-TREE
+**
+** See test cases in test/whereN.test for the real-world query that
+** originally provoked this heuristic.
+*/
+static SQLITE_NOINLINE void whereInterstageHeuristic(WhereInfo *pWInfo){
+  int i;
+#ifdef WHERETRACE_ENABLED
+  int once = 0;
+#endif
+  for(i=0; i<pWInfo->nLevel; i++){
+    WhereLoop *p = pWInfo->a[i].pWLoop;
+    if( p==0 ) break;
+    if( (p->wsFlags & WHERE_VIRTUALTABLE)!=0 ) continue;
+    if( (p->wsFlags & (WHERE_COLUMN_EQ|WHERE_COLUMN_NULL|WHERE_COLUMN_IN))!=0 ){
+      u8 iTab = p->iTab;
+      WhereLoop *pLoop;
+      for(pLoop=pWInfo->pLoops; pLoop; pLoop=pLoop->pNextLoop){
+        if( pLoop->iTab!=iTab ) continue;
+        if( (pLoop->wsFlags & (WHERE_CONSTRAINT|WHERE_AUTO_INDEX))!=0 ){
+          /* Auto-index and index-constrained loops allowed to remain */
+          continue;
+        }
+#ifdef WHERETRACE_ENABLED
+        if( sqlite3WhereTrace & 0x80 ){
+          if( once==0 ){
+            sqlite3DebugPrintf("Loops disabled by interstage heuristic:\n");
+            once = 1;
+          }
+          sqlite3WhereLoopPrint(pLoop, &pWInfo->sWC);
+        }
+#endif /* WHERETRACE_ENABLED */
+        pLoop->prereq = ALLBITS;  /* Prevent 2nd solver() from using this one */
+      }
+    }else{
+      break;
+    }
+  }
+}
+
 /*
 ** Most queries use only a single table (they are not joins) and have
 ** simple == constraints against indexed fields.  This routine attempts
@@ -166573,7 +168076,7 @@ static SQLITE_NOINLINE void whereCheckIfBloomFilterIsUseful(
     SrcItem *pItem = &pWInfo->pTabList->a[pLoop->iTab];
     Table *pTab = pItem->pTab;
     if( (pTab->tabFlags & TF_HasStat1)==0 ) break;
-    pTab->tabFlags |= TF_StatsUsed;
+    pTab->tabFlags |= TF_MaybeReanalyze;
     if( i>=1
      && (pLoop->wsFlags & reqFlags)==reqFlags
      /* vvvvvv--- Always the case if WHERE_COLUMN_EQ is defined */
@@ -166594,6 +168097,58 @@ static SQLITE_NOINLINE void whereCheckIfBloomFilterIsUseful(
   }
 }
 
+/*
+** Expression Node callback for sqlite3ExprCanReturnSubtype().
+**
+** Only a function call is able to return a subtype.  So if the node
+** is not a function call, return WRC_Prune immediately.
+**
+** A function call is able to return a subtype if it has the
+** SQLITE_RESULT_SUBTYPE property.
+**
+** Assume that every function is able to pass-through a subtype from
+** one of its argument (using sqlite3_result_value()).  Most functions
+** are not this way, but we don't have a mechanism to distinguish those
+** that are from those that are not, so assume they all work this way.
+** That means that if one of its arguments is another function and that
+** other function is able to return a subtype, then this function is
+** able to return a subtype.
+*/
+static int exprNodeCanReturnSubtype(Walker *pWalker, Expr *pExpr){
+  int n;
+  FuncDef *pDef;
+  sqlite3 *db;
+  if( pExpr->op!=TK_FUNCTION ){
+    return WRC_Prune;
+  }
+  assert( ExprUseXList(pExpr) );
+  db = pWalker->pParse->db;
+  n = pExpr->x.pList ? pExpr->x.pList->nExpr : 0;
+  pDef = sqlite3FindFunction(db, pExpr->u.zToken, n, ENC(db), 0);
+  if( pDef==0 || (pDef->funcFlags & SQLITE_RESULT_SUBTYPE)!=0 ){
+    pWalker->eCode = 1;
+    return WRC_Prune;
+  }
+  return WRC_Continue;
+}
+
+/*
+** Return TRUE if expression pExpr is able to return a subtype.
+**
+** A TRUE return does not guarantee that a subtype will be returned.
+** It only indicates that a subtype return is possible.  False positives
+** are acceptable as they only disable an optimization.  False negatives,
+** on the other hand, can lead to incorrect answers.
+*/
+static int sqlite3ExprCanReturnSubtype(Parse *pParse, Expr *pExpr){
+  Walker w;
+  memset(&w, 0, sizeof(w));
+  w.pParse = pParse;
+  w.xExprCallback = exprNodeCanReturnSubtype;
+  sqlite3WalkExpr(&w, pExpr);
+  return w.eCode;
+}
+
 /*
 ** The index pIdx is used by a query and contains one or more expressions.
 ** In other words pIdx is an index on an expression.  iIdxCur is the cursor
@@ -166619,33 +168174,19 @@ static SQLITE_NOINLINE void whereAddIndexedExpr(
   for(i=0; i<pIdx->nColumn; i++){
     Expr *pExpr;
     int j = pIdx->aiColumn[i];
-    int bMaybeNullRow;
     if( j==XN_EXPR ){
       pExpr = pIdx->aColExpr->a[i].pExpr;
-      testcase( pTabItem->fg.jointype & JT_LEFT );
-      testcase( pTabItem->fg.jointype & JT_RIGHT );
-      testcase( pTabItem->fg.jointype & JT_LTORJ );
-      bMaybeNullRow = (pTabItem->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))!=0;
     }else if( j>=0 && (pTab->aCol[j].colFlags & COLFLAG_VIRTUAL)!=0 ){
       pExpr = sqlite3ColumnExpr(pTab, &pTab->aCol[j]);
-      bMaybeNullRow = 0;
     }else{
       continue;
     }
-    if( sqlite3ExprIsConstant(pExpr) ) continue;
-    if( pExpr->op==TK_FUNCTION ){
+    if( sqlite3ExprIsConstant(0,pExpr) ) continue;
+    if( pExpr->op==TK_FUNCTION && sqlite3ExprCanReturnSubtype(pParse,pExpr) ){
       /* Functions that might set a subtype should not be replaced by the
       ** value taken from an expression index since the index omits the
       ** subtype.  https://sqlite.org/forum/forumpost/68d284c86b082c3e */
-      int n;
-      FuncDef *pDef;
-      sqlite3 *db = pParse->db;
-      assert( ExprUseXList(pExpr) );
-      n = pExpr->x.pList ? pExpr->x.pList->nExpr : 0;
-      pDef = sqlite3FindFunction(db, pExpr->u.zToken, n, ENC(db), 0);
-      if( pDef==0 || (pDef->funcFlags & SQLITE_RESULT_SUBTYPE)!=0 ){
-        continue;
-      }
+      continue;
     }
     p = sqlite3DbMallocRaw(pParse->db,  sizeof(IndexedExpr));
     if( p==0 ) break;
@@ -166660,7 +168201,7 @@ static SQLITE_NOINLINE void whereAddIndexedExpr(
     p->iDataCur = pTabItem->iCursor;
     p->iIdxCur = iIdxCur;
     p->iIdxCol = i;
-    p->bMaybeNullRow = bMaybeNullRow;
+    p->bMaybeNullRow = (pTabItem->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT))!=0;
     if( sqlite3IndexAffinityStr(pParse->db, pIdx) ){
       p->aff = pIdx->zColAff[i];
     }
@@ -166910,7 +168451,11 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
     ){
       pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE;
     }
-    ExplainQueryPlan((pParse, 0, "SCAN CONSTANT ROW"));
+    if( ALWAYS(pWInfo->pSelect)
+     && (pWInfo->pSelect->selFlags & SF_MultiValue)==0
+    ){
+      ExplainQueryPlan((pParse, 0, "SCAN CONSTANT ROW"));
+    }
   }else{
     /* Assign a bit from the bitmask to every term in the FROM clause.
     **
@@ -167063,6 +168608,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
     wherePathSolver(pWInfo, 0);
     if( db->mallocFailed ) goto whereBeginError;
     if( pWInfo->pOrderBy ){
+       whereInterstageHeuristic(pWInfo);
        wherePathSolver(pWInfo, pWInfo->nRowOut+1);
        if( db->mallocFailed ) goto whereBeginError;
     }
@@ -167612,7 +169158,15 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){
       addr = sqlite3VdbeAddOp1(v, OP_IfPos, pLevel->iLeftJoin); VdbeCoverage(v);
       assert( (ws & WHERE_IDX_ONLY)==0 || (ws & WHERE_INDEXED)!=0 );
       if( (ws & WHERE_IDX_ONLY)==0 ){
-        assert( pLevel->iTabCur==pTabList->a[pLevel->iFrom].iCursor );
+        SrcItem *pSrc = &pTabList->a[pLevel->iFrom];
+        assert( pLevel->iTabCur==pSrc->iCursor );
+        if( pSrc->fg.viaCoroutine ){
+          int m, n;
+          n = pSrc->regResult;
+          assert( pSrc->pTab!=0 );
+          m = pSrc->pTab->nCol;
+          sqlite3VdbeAddOp3(v, OP_Null, 0, n, n+m-1);
+        }
         sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iTabCur);
       }
       if( (ws & WHERE_INDEXED)
@@ -167662,6 +169216,7 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){
     */
     if( pTabItem->fg.viaCoroutine ){
       testcase( pParse->db->mallocFailed );
+      assert( pTabItem->regResult>=0 );
       translateColumnToCopy(pParse, pLevel->addrBody, pLevel->iTabCur,
                             pTabItem->regResult, 0);
       continue;
@@ -168966,7 +170521,7 @@ SQLITE_PRIVATE void sqlite3WindowListDelete(sqlite3 *db, Window *p){
 ** variable values in the expression tree.
 */
 static Expr *sqlite3WindowOffsetExpr(Parse *pParse, Expr *pExpr){
-  if( 0==sqlite3ExprIsConstant(pExpr) ){
+  if( 0==sqlite3ExprIsConstant(0,pExpr) ){
     if( IN_RENAME_OBJECT ) sqlite3RenameExprUnmap(pParse, pExpr);
     sqlite3ExprDelete(pParse->db, pExpr);
     pExpr = sqlite3ExprAlloc(pParse->db, TK_NULL, 0, 0);
@@ -171058,6 +172613,14 @@ static void updateDeleteLimitError(
     return pSelect;
   }
 
+  /* Memory allocator for parser stack resizing.  This is a thin wrapper around
+  ** sqlite3_realloc() that includes a call to sqlite3FaultSim() to facilitate
+  ** testing.
+  */
+  static void *parserStackRealloc(void *pOld, sqlite3_uint64 newSize){
+    return sqlite3FaultSim(700) ? 0 : sqlite3_realloc(pOld, newSize);
+  }
+
 
   /* Construct a new Expr object from a single token */
   static Expr *tokenExpr(Parse *pParse, int op, Token t){
@@ -171307,8 +172870,8 @@ static void updateDeleteLimitError(
 #define TK_TRUEFALSE                      170
 #define TK_ISNOT                          171
 #define TK_FUNCTION                       172
-#define TK_UMINUS                         173
-#define TK_UPLUS                          174
+#define TK_UPLUS                          173
+#define TK_UMINUS                         174
 #define TK_TRUTH                          175
 #define TK_REGISTER                       176
 #define TK_VECTOR                         177
@@ -171317,8 +172880,9 @@ static void updateDeleteLimitError(
 #define TK_ASTERISK                       180
 #define TK_SPAN                           181
 #define TK_ERROR                          182
-#define TK_SPACE                          183
-#define TK_ILLEGAL                        184
+#define TK_QNUMBER                        183
+#define TK_SPACE                          184
+#define TK_ILLEGAL                        185
 #endif
 /**************** End token definitions ***************************************/
 
@@ -171359,6 +172923,9 @@ static void updateDeleteLimitError(
 **    sqlite3ParserARG_STORE     Code to store %extra_argument into yypParser
 **    sqlite3ParserARG_FETCH     Code to extract %extra_argument from yypParser
 **    sqlite3ParserCTX_*         As sqlite3ParserARG_ except for %extra_context
+**    YYREALLOC          Name of the realloc() function to use
+**    YYFREE             Name of the free() function to use
+**    YYDYNSTACK         True if stack space should be extended on heap
 **    YYERRORSYMBOL      is the code number of the error symbol.  If not
 **                       defined, then do no error processing.
 **    YYNSTATE           the combined number of states.
@@ -171372,37 +172939,39 @@ static void updateDeleteLimitError(
 **    YY_NO_ACTION       The yy_action[] code for no-op
 **    YY_MIN_REDUCE      Minimum value for reduce actions
 **    YY_MAX_REDUCE      Maximum value for reduce actions
+**    YY_MIN_DSTRCTR     Minimum symbol value that has a destructor
+**    YY_MAX_DSTRCTR     Maximum symbol value that has a destructor
 */
 #ifndef INTERFACE
 # define INTERFACE 1
 #endif
 /************* Begin control #defines *****************************************/
 #define YYCODETYPE unsigned short int
-#define YYNOCODE 319
+#define YYNOCODE 322
 #define YYACTIONTYPE unsigned short int
 #define YYWILDCARD 101
 #define sqlite3ParserTOKENTYPE Token
 typedef union {
   int yyinit;
   sqlite3ParserTOKENTYPE yy0;
-  TriggerStep* yy33;
-  Window* yy41;
-  Select* yy47;
-  SrcList* yy131;
-  struct TrigEvent yy180;
-  struct {int value; int mask;} yy231;
-  IdList* yy254;
-  u32 yy285;
-  ExprList* yy322;
-  Cte* yy385;
-  int yy394;
-  Upsert* yy444;
-  u8 yy516;
-  With* yy521;
-  const char* yy522;
-  Expr* yy528;
-  OnOrUsing yy561;
-  struct FrameBound yy595;
+  ExprList* yy14;
+  With* yy59;
+  Cte* yy67;
+  Upsert* yy122;
+  IdList* yy132;
+  int yy144;
+  const char* yy168;
+  SrcList* yy203;
+  Window* yy211;
+  OnOrUsing yy269;
+  struct TrigEvent yy286;
+  struct {int value; int mask;} yy383;
+  u32 yy391;
+  TriggerStep* yy427;
+  Expr* yy454;
+  u8 yy462;
+  struct FrameBound yy509;
+  Select* yy555;
 } YYMINORTYPE;
 #ifndef YYSTACKDEPTH
 #define YYSTACKDEPTH 100
@@ -171412,24 +172981,29 @@ typedef union {
 #define sqlite3ParserARG_PARAM
 #define sqlite3ParserARG_FETCH
 #define sqlite3ParserARG_STORE
+#define YYREALLOC parserStackRealloc
+#define YYFREE sqlite3_free
+#define YYDYNSTACK 1
 #define sqlite3ParserCTX_SDECL Parse *pParse;
 #define sqlite3ParserCTX_PDECL ,Parse *pParse
 #define sqlite3ParserCTX_PARAM ,pParse
 #define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse;
 #define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
 #define YYFALLBACK 1
-#define YYNSTATE             579
-#define YYNRULE              405
-#define YYNRULE_WITH_ACTION  340
-#define YYNTOKEN             185
-#define YY_MAX_SHIFT         578
-#define YY_MIN_SHIFTREDUCE   838
-#define YY_MAX_SHIFTREDUCE   1242
-#define YY_ERROR_ACTION      1243
-#define YY_ACCEPT_ACTION     1244
-#define YY_NO_ACTION         1245
-#define YY_MIN_REDUCE        1246
-#define YY_MAX_REDUCE        1650
+#define YYNSTATE             583
+#define YYNRULE              409
+#define YYNRULE_WITH_ACTION  344
+#define YYNTOKEN             186
+#define YY_MAX_SHIFT         582
+#define YY_MIN_SHIFTREDUCE   845
+#define YY_MAX_SHIFTREDUCE   1253
+#define YY_ERROR_ACTION      1254
+#define YY_ACCEPT_ACTION     1255
+#define YY_NO_ACTION         1256
+#define YY_MIN_REDUCE        1257
+#define YY_MAX_REDUCE        1665
+#define YY_MIN_DSTRCTR       205
+#define YY_MAX_DSTRCTR       319
 /************* End control #defines *******************************************/
 #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
 
@@ -171445,6 +173019,22 @@ typedef union {
 # define yytestcase(X)
 #endif
 
+/* Macro to determine if stack space has the ability to grow using
+** heap memory.
+*/
+#if YYSTACKDEPTH<=0 || YYDYNSTACK
+# define YYGROWABLESTACK 1
+#else
+# define YYGROWABLESTACK 0
+#endif
+
+/* Guarantee a minimum number of initial stack slots.
+*/
+#if YYSTACKDEPTH<=0
+# undef YYSTACKDEPTH
+# define YYSTACKDEPTH 2  /* Need a minimum stack size */
+#endif
+
 
 /* Next are the tables used to determine what action to take based on the
 ** current state and lookahead token.  These tables are used to implement
@@ -171496,619 +173086,630 @@ typedef union {
 **  yy_default[]       Default action for each state.
 **
 *********** Begin parsing tables **********************************************/
-#define YY_ACTTAB_COUNT (2100)
+#define YY_ACTTAB_COUNT (2142)
 static const YYACTIONTYPE yy_action[] = {
- /*     0 */   572,  210,  572,  119,  116,  231,  572,  119,  116,  231,
- /*    10 */   572, 1317,  379, 1296,  410,  566,  566,  566,  572,  411,
- /*    20 */   380, 1317, 1279,   42,   42,   42,   42,  210, 1529,   72,
- /*    30 */    72,  974,  421,   42,   42,  495,  305,  281,  305,  975,
- /*    40 */   399,   72,   72,  126,  127,   81, 1217, 1217, 1054, 1057,
- /*    50 */  1044, 1044,  124,  124,  125,  125,  125,  125,  480,  411,
- /*    60 */  1244,    1,    1,  578,    2, 1248,  554,  119,  116,  231,
- /*    70 */   319,  484,  147,  484,  528,  119,  116,  231,  533, 1330,
- /*    80 */   419,  527,  143,  126,  127,   81, 1217, 1217, 1054, 1057,
- /*    90 */  1044, 1044,  124,  124,  125,  125,  125,  125,  119,  116,
- /*   100 */   231,  329,  123,  123,  123,  123,  122,  122,  121,  121,
- /*   110 */   121,  120,  117,  448,  286,  286,  286,  286,  446,  446,
- /*   120 */   446, 1568,  378, 1570, 1193,  377, 1164,  569, 1164,  569,
- /*   130 */   411, 1568,  541,  261,  228,  448,  102,  146,  453,  318,
- /*   140 */   563,  242,  123,  123,  123,  123,  122,  122,  121,  121,
- /*   150 */   121,  120,  117,  448,  126,  127,   81, 1217, 1217, 1054,
- /*   160 */  1057, 1044, 1044,  124,  124,  125,  125,  125,  125,  143,
- /*   170 */   296, 1193,  341,  452,  121,  121,  121,  120,  117,  448,
- /*   180 */   128, 1193, 1194, 1193,  149,  445,  444,  572,  120,  117,
- /*   190 */   448,  125,  125,  125,  125,  118,  123,  123,  123,  123,
- /*   200 */   122,  122,  121,  121,  121,  120,  117,  448,  458,  114,
- /*   210 */    13,   13,  550,  123,  123,  123,  123,  122,  122,  121,
- /*   220 */   121,  121,  120,  117,  448,  424,  318,  563, 1193, 1194,
- /*   230 */  1193,  150, 1225,  411, 1225,  125,  125,  125,  125,  123,
- /*   240 */   123,  123,  123,  122,  122,  121,  121,  121,  120,  117,
- /*   250 */   448,  469,  344, 1041, 1041, 1055, 1058,  126,  127,   81,
- /*   260 */  1217, 1217, 1054, 1057, 1044, 1044,  124,  124,  125,  125,
- /*   270 */   125,  125, 1282,  526,  224, 1193,  572,  411,  226,  519,
- /*   280 */   177,   83,   84,  123,  123,  123,  123,  122,  122,  121,
- /*   290 */   121,  121,  120,  117,  448, 1010,   16,   16, 1193,  134,
- /*   300 */   134,  126,  127,   81, 1217, 1217, 1054, 1057, 1044, 1044,
- /*   310 */   124,  124,  125,  125,  125,  125,  123,  123,  123,  123,
- /*   320 */   122,  122,  121,  121,  121,  120,  117,  448, 1045,  550,
- /*   330 */  1193,  375, 1193, 1194, 1193,  254, 1438,  401,  508,  505,
- /*   340 */   504,  112,  564,  570,    4,  929,  929,  435,  503,  342,
- /*   350 */   464,  330,  362,  396, 1238, 1193, 1194, 1193,  567,  572,
- /*   360 */   123,  123,  123,  123,  122,  122,  121,  121,  121,  120,
- /*   370 */   117,  448,  286,  286,  371, 1581, 1607,  445,  444,  155,
- /*   380 */   411,  449,   72,   72, 1289,  569, 1222, 1193, 1194, 1193,
- /*   390 */    86, 1224,  273,  561,  547,  520,  520,  572,   99, 1223,
- /*   400 */     6, 1281,  476,  143,  126,  127,   81, 1217, 1217, 1054,
- /*   410 */  1057, 1044, 1044,  124,  124,  125,  125,  125,  125,  554,
- /*   420 */    13,   13, 1031,  511, 1225, 1193, 1225,  553,  110,  110,
- /*   430 */   224,  572, 1239,  177,  572,  429,  111,  199,  449,  573,
- /*   440 */   449,  432, 1555, 1019,  327,  555, 1193,  272,  289,  370,
- /*   450 */   514,  365,  513,  259,   72,   72,  547,   72,   72,  361,
- /*   460 */   318,  563, 1613,  123,  123,  123,  123,  122,  122,  121,
- /*   470 */   121,  121,  120,  117,  448, 1019, 1019, 1021, 1022,   28,
- /*   480 */   286,  286, 1193, 1194, 1193, 1159,  572, 1612,  411,  904,
- /*   490 */   192,  554,  358,  569,  554,  940,  537,  521, 1159,  437,
- /*   500 */   415, 1159,  556, 1193, 1194, 1193,  572,  548,  548,   52,
- /*   510 */    52,  216,  126,  127,   81, 1217, 1217, 1054, 1057, 1044,
- /*   520 */  1044,  124,  124,  125,  125,  125,  125, 1193,  478,  136,
- /*   530 */   136,  411,  286,  286, 1493,  509,  122,  122,  121,  121,
- /*   540 */   121,  120,  117,  448, 1010,  569,  522,  219,  545,  545,
- /*   550 */   318,  563,  143,    6,  536,  126,  127,   81, 1217, 1217,
- /*   560 */  1054, 1057, 1044, 1044,  124,  124,  125,  125,  125,  125,
- /*   570 */  1557,  123,  123,  123,  123,  122,  122,  121,  121,  121,
- /*   580 */   120,  117,  448,  489, 1193, 1194, 1193,  486,  283, 1270,
- /*   590 */   960,  254, 1193,  375,  508,  505,  504, 1193,  342,  574,
- /*   600 */  1193,  574,  411,  294,  503,  960,  879,  193,  484,  318,
- /*   610 */   563,  386,  292,  382,  123,  123,  123,  123,  122,  122,
- /*   620 */   121,  121,  121,  120,  117,  448,  126,  127,   81, 1217,
- /*   630 */  1217, 1054, 1057, 1044, 1044,  124,  124,  125,  125,  125,
- /*   640 */   125,  411,  396, 1139, 1193,  872,  101,  286,  286, 1193,
- /*   650 */  1194, 1193,  375, 1096, 1193, 1194, 1193, 1193, 1194, 1193,
- /*   660 */   569,  459,   33,  375,  235,  126,  127,   81, 1217, 1217,
- /*   670 */  1054, 1057, 1044, 1044,  124,  124,  125,  125,  125,  125,
- /*   680 */  1437,  962,  572,  230,  961,  123,  123,  123,  123,  122,
- /*   690 */   122,  121,  121,  121,  120,  117,  448, 1159,  230, 1193,
- /*   700 */   158, 1193, 1194, 1193, 1556,   13,   13,  303,  960, 1233,
- /*   710 */  1159,  154,  411, 1159,  375, 1584, 1177,    5,  371, 1581,
- /*   720 */   431, 1239,    3,  960,  123,  123,  123,  123,  122,  122,
- /*   730 */   121,  121,  121,  120,  117,  448,  126,  127,   81, 1217,
- /*   740 */  1217, 1054, 1057, 1044, 1044,  124,  124,  125,  125,  125,
- /*   750 */   125,  411,  210,  571, 1193, 1032, 1193, 1194, 1193, 1193,
- /*   760 */   390,  855,  156, 1555,  376,  404, 1101, 1101,  492,  572,
- /*   770 */   469,  344, 1322, 1322, 1555,  126,  127,   81, 1217, 1217,
- /*   780 */  1054, 1057, 1044, 1044,  124,  124,  125,  125,  125,  125,
- /*   790 */   130,  572,   13,   13,  532,  123,  123,  123,  123,  122,
- /*   800 */   122,  121,  121,  121,  120,  117,  448,  304,  572,  457,
- /*   810 */   229, 1193, 1194, 1193,   13,   13, 1193, 1194, 1193, 1300,
- /*   820 */   467, 1270,  411, 1320, 1320, 1555, 1015,  457,  456,  436,
- /*   830 */   301,   72,   72, 1268,  123,  123,  123,  123,  122,  122,
- /*   840 */   121,  121,  121,  120,  117,  448,  126,  127,   81, 1217,
- /*   850 */  1217, 1054, 1057, 1044, 1044,  124,  124,  125,  125,  125,
- /*   860 */   125,  411,  384, 1076, 1159,  286,  286,  421,  314,  280,
- /*   870 */   280,  287,  287,  461,  408,  407, 1539, 1159,  569,  572,
- /*   880 */  1159, 1196,  569,  409,  569,  126,  127,   81, 1217, 1217,
- /*   890 */  1054, 1057, 1044, 1044,  124,  124,  125,  125,  125,  125,
- /*   900 */   457, 1485,   13,   13, 1541,  123,  123,  123,  123,  122,
- /*   910 */   122,  121,  121,  121,  120,  117,  448,  202,  572,  462,
- /*   920 */  1587,  578,    2, 1248,  843,  844,  845, 1563,  319,  409,
- /*   930 */   147,    6,  411,  257,  256,  255,  208, 1330,    9, 1196,
- /*   940 */   264,   72,   72, 1436,  123,  123,  123,  123,  122,  122,
- /*   950 */   121,  121,  121,  120,  117,  448,  126,  127,   81, 1217,
- /*   960 */  1217, 1054, 1057, 1044, 1044,  124,  124,  125,  125,  125,
- /*   970 */   125,  572,  286,  286,  572, 1213,  411,  577,  315, 1248,
- /*   980 */   421,  371, 1581,  356,  319,  569,  147,  495,  529, 1644,
- /*   990 */   397,  935,  495, 1330,   71,   71,  934,   72,   72,  242,
- /*  1000 */  1328,  105,   81, 1217, 1217, 1054, 1057, 1044, 1044,  124,
- /*  1010 */   124,  125,  125,  125,  125,  123,  123,  123,  123,  122,
- /*  1020 */   122,  121,  121,  121,  120,  117,  448, 1117,  286,  286,
- /*  1030 */  1422,  452, 1528, 1213,  443,  286,  286, 1492, 1355,  313,
- /*  1040 */   478,  569, 1118,  454,  351,  495,  354, 1266,  569,  209,
- /*  1050 */   572,  418,  179,  572, 1031,  242,  385, 1119,  523,  123,
- /*  1060 */   123,  123,  123,  122,  122,  121,  121,  121,  120,  117,
- /*  1070 */   448, 1020,  108,   72,   72, 1019,   13,   13,  915,  572,
- /*  1080 */  1498,  572,  286,  286,   98,  530, 1537,  452,  916, 1334,
- /*  1090 */  1329,  203,  411,  286,  286,  569,  152,  211, 1498, 1500,
- /*  1100 */   426,  569,   56,   56,   57,   57,  569, 1019, 1019, 1021,
- /*  1110 */   447,  572,  411,  531,   12,  297,  126,  127,   81, 1217,
- /*  1120 */  1217, 1054, 1057, 1044, 1044,  124,  124,  125,  125,  125,
- /*  1130 */   125,  572,  411,  867,   15,   15,  126,  127,   81, 1217,
- /*  1140 */  1217, 1054, 1057, 1044, 1044,  124,  124,  125,  125,  125,
- /*  1150 */   125,  373,  529,  264,   44,   44,  126,  115,   81, 1217,
- /*  1160 */  1217, 1054, 1057, 1044, 1044,  124,  124,  125,  125,  125,
- /*  1170 */   125, 1498,  478, 1271,  417,  123,  123,  123,  123,  122,
- /*  1180 */   122,  121,  121,  121,  120,  117,  448,  205, 1213,  495,
- /*  1190 */   430,  867,  468,  322,  495,  123,  123,  123,  123,  122,
- /*  1200 */   122,  121,  121,  121,  120,  117,  448,  572,  557, 1140,
- /*  1210 */  1642, 1422, 1642,  543,  572,  123,  123,  123,  123,  122,
- /*  1220 */   122,  121,  121,  121,  120,  117,  448,  572, 1422,  572,
- /*  1230 */    13,   13,  542,  323, 1325,  411,  334,   58,   58,  349,
- /*  1240 */  1422, 1170,  326,  286,  286,  549, 1213,  300,  895,  530,
- /*  1250 */    45,   45,   59,   59, 1140, 1643,  569, 1643,  565,  417,
- /*  1260 */   127,   81, 1217, 1217, 1054, 1057, 1044, 1044,  124,  124,
- /*  1270 */   125,  125,  125,  125, 1367,  373,  500,  290, 1193,  512,
- /*  1280 */  1366,  427,  394,  394,  393,  275,  391,  896, 1138,  852,
- /*  1290 */   478,  258, 1422, 1170,  463, 1159,   12,  331,  428,  333,
- /*  1300 */  1117,  460,  236,  258,  325,  460,  544, 1544, 1159, 1098,
- /*  1310 */   491, 1159,  324, 1098,  440, 1118,  335,  516,  123,  123,
- /*  1320 */   123,  123,  122,  122,  121,  121,  121,  120,  117,  448,
- /*  1330 */  1119,  318,  563, 1138,  572, 1193, 1194, 1193,  112,  564,
- /*  1340 */   201,    4,  238,  433,  935,  490,  285,  228, 1517,  934,
- /*  1350 */   170,  560,  572,  142, 1516,  567,  572,   60,   60,  572,
- /*  1360 */   416,  572,  441,  572,  535,  302,  875,    8,  487,  572,
- /*  1370 */   237,  572,  416,  572,  485,   61,   61,  572,  449,   62,
- /*  1380 */    62,  332,   63,   63,   46,   46,   47,   47,  361,  572,
- /*  1390 */   561,  572,   48,   48,   50,   50,   51,   51,  572,  295,
- /*  1400 */    64,   64,  482,  295,  539,  412,  471, 1031,  572,  538,
- /*  1410 */   318,  563,   65,   65,   66,   66,  409,  475,  572, 1031,
- /*  1420 */   572,   14,   14,  875, 1020,  110,  110,  409, 1019,  572,
- /*  1430 */   474,   67,   67,  111,  455,  449,  573,  449,   98,  317,
- /*  1440 */  1019,  132,  132,  133,  133,  572, 1561,  572,  974,  409,
- /*  1450 */     6, 1562,   68,   68, 1560,    6,  975,  572,    6, 1559,
- /*  1460 */  1019, 1019, 1021,    6,  346,  218,  101,  531,   53,   53,
- /*  1470 */    69,   69, 1019, 1019, 1021, 1022,   28, 1586, 1181,  451,
- /*  1480 */    70,   70,  290,   87,  215,   31, 1363,  394,  394,  393,
- /*  1490 */   275,  391,  350,  109,  852,  107,  572,  112,  564,  483,
- /*  1500 */     4, 1212,  572,  239,  153,  572,   39,  236, 1299,  325,
- /*  1510 */   112,  564, 1298,    4,  567,  572,   32,  324,  572,   54,
- /*  1520 */    54,  572, 1135,  353,  398,  165,  165,  567,  166,  166,
- /*  1530 */   572,  291,  355,  572,   17,  357,  572,  449,   77,   77,
- /*  1540 */  1313,   55,   55, 1297,   73,   73,  572,  238,  470,  561,
- /*  1550 */   449,  472,  364,  135,  135,  170,   74,   74,  142,  163,
- /*  1560 */   163,  374,  561,  539,  572,  321,  572,  886,  540,  137,
- /*  1570 */   137,  339, 1353,  422,  298,  237,  539,  572, 1031,  572,
- /*  1580 */   340,  538,  101,  369,  110,  110,  162,  131,  131,  164,
- /*  1590 */   164, 1031,  111,  368,  449,  573,  449,  110,  110, 1019,
- /*  1600 */   157,  157,  141,  141,  572,  111,  572,  449,  573,  449,
- /*  1610 */   412,  288, 1019,  572,  882,  318,  563,  572,  219,  572,
- /*  1620 */   241, 1012,  477,  263,  263,  894,  893,  140,  140,  138,
- /*  1630 */   138, 1019, 1019, 1021, 1022,   28,  139,  139,  525,  455,
- /*  1640 */    76,   76,   78,   78, 1019, 1019, 1021, 1022,   28, 1181,
- /*  1650 */   451,  572, 1083,  290,  112,  564, 1575,    4,  394,  394,
- /*  1660 */   393,  275,  391,  572, 1023,  852,  572,  479,  345,  263,
- /*  1670 */   101,  567,  882, 1376,   75,   75, 1421,  501,  236,  260,
- /*  1680 */   325,  112,  564,  359,    4,  101,   43,   43,  324,   49,
- /*  1690 */    49,  901,  902,  161,  449,  101,  977,  978,  567, 1079,
- /*  1700 */  1349,  260,  965,  932,  263,  114,  561, 1095,  517, 1095,
- /*  1710 */  1083, 1094,  865, 1094,  151,  933, 1144,  114,  238, 1361,
- /*  1720 */   558,  449, 1023,  559, 1426, 1278,  170, 1269, 1257,  142,
- /*  1730 */  1601, 1256, 1258,  561, 1594, 1031,  496,  278,  213, 1346,
- /*  1740 */   310,  110,  110,  939,  311,  312,  237,   11,  234,  111,
- /*  1750 */   221,  449,  573,  449,  293,  395, 1019, 1408,  337, 1403,
- /*  1760 */  1396,  338, 1031,  299,  343, 1413, 1412,  481,  110,  110,
- /*  1770 */   506,  402,  225, 1296,  206,  367,  111, 1358,  449,  573,
- /*  1780 */   449,  412, 1359, 1019, 1489, 1488,  318,  563, 1019, 1019,
- /*  1790 */  1021, 1022,   28,  562,  207,  220,   80,  564,  389,    4,
- /*  1800 */  1597, 1357,  552, 1356, 1233,  181,  267,  232, 1536, 1534,
- /*  1810 */   455, 1230,  420,  567,   82, 1019, 1019, 1021, 1022,   28,
- /*  1820 */    86,  217,   85, 1494,  190,  175,  183,  465,  185,  466,
- /*  1830 */    36, 1409,  186,  187,  188,  499,  449,  244,   37,   99,
- /*  1840 */   400, 1415, 1414,  488, 1417,  194,  473,  403,  561, 1483,
- /*  1850 */   248,   92, 1505,  494,  198,  279,  112,  564,  250,    4,
- /*  1860 */   348,  497,  405,  352, 1259,  251,  252,  515, 1316,  434,
- /*  1870 */  1315, 1314,   94,  567, 1307,  886, 1306, 1031,  226,  406,
- /*  1880 */  1611, 1610,  438,  110,  110, 1580, 1286,  524,  439,  308,
- /*  1890 */   266,  111, 1285,  449,  573,  449,  449,  309, 1019,  366,
- /*  1900 */  1284, 1609,  265, 1566, 1565,  442,  372, 1381,  561,  129,
- /*  1910 */   550, 1380,   10, 1470,  383,  106,  316,  551,  100,   35,
- /*  1920 */   534,  575,  212, 1339,  381,  387, 1187, 1338,  274,  276,
- /*  1930 */  1019, 1019, 1021, 1022,   28,  277,  413, 1031,  576, 1254,
- /*  1940 */   388, 1521, 1249,  110,  110,  167, 1522,  168,  148, 1520,
- /*  1950 */  1519,  111,  306,  449,  573,  449,  222,  223, 1019,  839,
- /*  1960 */   169,   79,  450,  214,  414,  233,  320,  145, 1093, 1091,
- /*  1970 */   328,  182,  171, 1212,  918,  184,  240,  336,  243, 1107,
- /*  1980 */   189,  172,  173,  423,  425,   88,  180,  191,   89,   90,
- /*  1990 */  1019, 1019, 1021, 1022,   28,   91,  174, 1110,  245, 1106,
- /*  2000 */   246,  159,   18,  247,  347, 1099,  263,  195, 1227,  493,
- /*  2010 */   249,  196,   38,  854,  498,  368,  253,  360,  897,  197,
- /*  2020 */   502,   93,   19,   20,  507,  884,  363,  510,   95,  307,
- /*  2030 */   160,   96,  518,   97, 1175, 1060, 1146,   40,   21,  227,
- /*  2040 */   176, 1145,  282,  284,  969,  200,  963,  114,  262, 1165,
- /*  2050 */    22,   23,   24, 1161, 1169,   25, 1163, 1150,   34,   26,
- /*  2060 */  1168,  546,   27,  204,  101,  103,  104, 1074,    7, 1061,
- /*  2070 */  1059, 1063, 1116, 1064, 1115,  268,  269,   29,   41,  270,
- /*  2080 */  1024,  866,  113,   30,  568,  392, 1183,  144,  178, 1182,
- /*  2090 */   271,  928, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1602,
+ /*     0 */   576,  128,  125,  232, 1622,  549,  576, 1290, 1281,  576,
+ /*    10 */   328,  576, 1300,  212,  576,  128,  125,  232,  578,  412,
+ /*    20 */   578,  391, 1542,   51,   51,  523,  405, 1293,  529,   51,
+ /*    30 */    51,  983,   51,   51,   81,   81, 1107,   61,   61,  984,
+ /*    40 */  1107, 1292,  380,  135,  136,   90, 1228, 1228, 1063, 1066,
+ /*    50 */  1053, 1053,  133,  133,  134,  134,  134,  134, 1577,  412,
+ /*    60 */   287,  287,    7,  287,  287,  422, 1050, 1050, 1064, 1067,
+ /*    70 */   289,  556,  492,  573,  524,  561,  573,  497,  561,  482,
+ /*    80 */   530,  262,  229,  135,  136,   90, 1228, 1228, 1063, 1066,
+ /*    90 */  1053, 1053,  133,  133,  134,  134,  134,  134,  128,  125,
+ /*   100 */   232, 1506,  132,  132,  132,  132,  131,  131,  130,  130,
+ /*   110 */   130,  129,  126,  450, 1204, 1255,    1,    1,  582,    2,
+ /*   120 */  1259, 1571,  420, 1582,  379,  320, 1174,  153, 1174, 1584,
+ /*   130 */   412,  378, 1582,  543, 1341,  330,  111,  570,  570,  570,
+ /*   140 */   293, 1054,  132,  132,  132,  132,  131,  131,  130,  130,
+ /*   150 */   130,  129,  126,  450,  135,  136,   90, 1228, 1228, 1063,
+ /*   160 */  1066, 1053, 1053,  133,  133,  134,  134,  134,  134,  287,
+ /*   170 */   287, 1204, 1205, 1204,  255,  287,  287,  510,  507,  506,
+ /*   180 */   137,  455,  573,  212,  561,  447,  446,  505,  573, 1616,
+ /*   190 */   561,  134,  134,  134,  134,  127,  400,  243,  132,  132,
+ /*   200 */   132,  132,  131,  131,  130,  130,  130,  129,  126,  450,
+ /*   210 */   282,  471,  345,  132,  132,  132,  132,  131,  131,  130,
+ /*   220 */   130,  130,  129,  126,  450,  574,  155,  936,  936,  454,
+ /*   230 */   227,  521, 1236,  412, 1236,  134,  134,  134,  134,  132,
+ /*   240 */   132,  132,  132,  131,  131,  130,  130,  130,  129,  126,
+ /*   250 */   450,  130,  130,  130,  129,  126,  450,  135,  136,   90,
+ /*   260 */  1228, 1228, 1063, 1066, 1053, 1053,  133,  133,  134,  134,
+ /*   270 */   134,  134,  128,  125,  232,  450,  576,  412,  397, 1249,
+ /*   280 */   180,   92,   93,  132,  132,  132,  132,  131,  131,  130,
+ /*   290 */   130,  130,  129,  126,  450,  381,  387, 1204,  383,   81,
+ /*   300 */    81,  135,  136,   90, 1228, 1228, 1063, 1066, 1053, 1053,
+ /*   310 */   133,  133,  134,  134,  134,  134,  132,  132,  132,  132,
+ /*   320 */   131,  131,  130,  130,  130,  129,  126,  450,  131,  131,
+ /*   330 */   130,  130,  130,  129,  126,  450,  556, 1204,  302,  319,
+ /*   340 */   567,  121,  568,  480,    4,  555, 1149, 1657, 1628, 1657,
+ /*   350 */    45,  128,  125,  232, 1204, 1205, 1204, 1250,  571, 1169,
+ /*   360 */   132,  132,  132,  132,  131,  131,  130,  130,  130,  129,
+ /*   370 */   126,  450, 1169,  287,  287, 1169, 1019,  576,  422, 1019,
+ /*   380 */   412,  451, 1602,  582,    2, 1259,  573,   44,  561,   95,
+ /*   390 */   320,  110,  153,  565, 1204, 1205, 1204,  522,  522, 1341,
+ /*   400 */    81,   81,    7,   44,  135,  136,   90, 1228, 1228, 1063,
+ /*   410 */  1066, 1053, 1053,  133,  133,  134,  134,  134,  134,  295,
+ /*   420 */  1149, 1658, 1040, 1658, 1204, 1147,  319,  567,  119,  119,
+ /*   430 */   343,  466,  331,  343,  287,  287,  120,  556,  451,  577,
+ /*   440 */   451, 1169, 1169, 1028,  319,  567,  438,  573,  210,  561,
+ /*   450 */  1339, 1451,  546,  531, 1169, 1169, 1598, 1169, 1169,  416,
+ /*   460 */   319,  567,  243,  132,  132,  132,  132,  131,  131,  130,
+ /*   470 */   130,  130,  129,  126,  450, 1028, 1028, 1030, 1031,   35,
+ /*   480 */    44, 1204, 1205, 1204,  472,  287,  287, 1328,  412, 1307,
+ /*   490 */   372, 1595,  359,  225,  454, 1204,  195, 1328,  573, 1147,
+ /*   500 */   561, 1333, 1333,  274,  576, 1188,  576,  340,   46,  196,
+ /*   510 */   537,  217,  135,  136,   90, 1228, 1228, 1063, 1066, 1053,
+ /*   520 */  1053,  133,  133,  134,  134,  134,  134,   19,   19,   19,
+ /*   530 */    19,  412,  581, 1204, 1259,  511, 1204,  319,  567,  320,
+ /*   540 */   944,  153,  425,  491,  430,  943, 1204,  488, 1341, 1450,
+ /*   550 */   532, 1277, 1204, 1205, 1204,  135,  136,   90, 1228, 1228,
+ /*   560 */  1063, 1066, 1053, 1053,  133,  133,  134,  134,  134,  134,
+ /*   570 */   575,  132,  132,  132,  132,  131,  131,  130,  130,  130,
+ /*   580 */   129,  126,  450,  287,  287,  528,  287,  287,  372, 1595,
+ /*   590 */  1204, 1205, 1204, 1204, 1205, 1204,  573,  486,  561,  573,
+ /*   600 */   889,  561,  412, 1204, 1205, 1204,  886,   40,   22,   22,
+ /*   610 */   220,  243,  525, 1449,  132,  132,  132,  132,  131,  131,
+ /*   620 */   130,  130,  130,  129,  126,  450,  135,  136,   90, 1228,
+ /*   630 */  1228, 1063, 1066, 1053, 1053,  133,  133,  134,  134,  134,
+ /*   640 */   134,  412,  180,  454, 1204,  879,  255,  287,  287,  510,
+ /*   650 */   507,  506,  372, 1595, 1568, 1331, 1331,  576,  889,  505,
+ /*   660 */   573,   44,  561,  559, 1207,  135,  136,   90, 1228, 1228,
+ /*   670 */  1063, 1066, 1053, 1053,  133,  133,  134,  134,  134,  134,
+ /*   680 */    81,   81,  422,  576,  377,  132,  132,  132,  132,  131,
+ /*   690 */   131,  130,  130,  130,  129,  126,  450,  297,  287,  287,
+ /*   700 */   460, 1204, 1205, 1204, 1204,  534,   19,   19,  448,  448,
+ /*   710 */   448,  573,  412,  561,  230,  436, 1187,  535,  319,  567,
+ /*   720 */   363,  432, 1207, 1435,  132,  132,  132,  132,  131,  131,
+ /*   730 */   130,  130,  130,  129,  126,  450,  135,  136,   90, 1228,
+ /*   740 */  1228, 1063, 1066, 1053, 1053,  133,  133,  134,  134,  134,
+ /*   750 */   134,  412,  211,  949, 1169, 1041, 1110, 1110,  494,  547,
+ /*   760 */   547, 1204, 1205, 1204,    7,  539, 1570, 1169,  376,  576,
+ /*   770 */  1169,    5, 1204,  486,    3,  135,  136,   90, 1228, 1228,
+ /*   780 */  1063, 1066, 1053, 1053,  133,  133,  134,  134,  134,  134,
+ /*   790 */   576,  513,   19,   19,  427,  132,  132,  132,  132,  131,
+ /*   800 */   131,  130,  130,  130,  129,  126,  450,  305, 1204,  433,
+ /*   810 */   225, 1204,  385,   19,   19,  273,  290,  371,  516,  366,
+ /*   820 */   515,  260,  412,  538, 1568,  549, 1024,  362,  437, 1204,
+ /*   830 */  1205, 1204,  902, 1552,  132,  132,  132,  132,  131,  131,
+ /*   840 */   130,  130,  130,  129,  126,  450,  135,  136,   90, 1228,
+ /*   850 */  1228, 1063, 1066, 1053, 1053,  133,  133,  134,  134,  134,
+ /*   860 */   134,  412, 1435,  514, 1281, 1204, 1205, 1204, 1204, 1205,
+ /*   870 */  1204,  903,   48,  342, 1568, 1568, 1279, 1627, 1568,  911,
+ /*   880 */   576,  129,  126,  450,  110,  135,  136,   90, 1228, 1228,
+ /*   890 */  1063, 1066, 1053, 1053,  133,  133,  134,  134,  134,  134,
+ /*   900 */   265,  576,  459,   19,   19,  132,  132,  132,  132,  131,
+ /*   910 */   131,  130,  130,  130,  129,  126,  450, 1345,  204,  576,
+ /*   920 */   459,  458,   50,   47,   19,   19,   49,  434, 1105,  573,
+ /*   930 */   497,  561,  412,  428,  108, 1224, 1569, 1554,  376,  205,
+ /*   940 */   550,  550,   81,   81,  132,  132,  132,  132,  131,  131,
+ /*   950 */   130,  130,  130,  129,  126,  450,  135,  136,   90, 1228,
+ /*   960 */  1228, 1063, 1066, 1053, 1053,  133,  133,  134,  134,  134,
+ /*   970 */   134,  480,  576, 1204,  576, 1541,  412, 1435,  969,  315,
+ /*   980 */  1659,  398,  284,  497,  969,  893, 1569, 1569,  376,  376,
+ /*   990 */  1569,  461,  376, 1224,  459,   80,   80,   81,   81,  497,
+ /*  1000 */   374,  114,   90, 1228, 1228, 1063, 1066, 1053, 1053,  133,
+ /*  1010 */   133,  134,  134,  134,  134,  132,  132,  132,  132,  131,
+ /*  1020 */   131,  130,  130,  130,  129,  126,  450, 1204, 1505,  576,
+ /*  1030 */  1204, 1205, 1204, 1366,  316,  486,  281,  281,  497,  431,
+ /*  1040 */   557,  288,  288,  402, 1340,  471,  345,  298,  429,  573,
+ /*  1050 */   576,  561,   81,   81,  573,  374,  561,  971,  386,  132,
+ /*  1060 */   132,  132,  132,  131,  131,  130,  130,  130,  129,  126,
+ /*  1070 */   450,  231,  117,   81,   81,  287,  287,  231,  287,  287,
+ /*  1080 */   576, 1511,  576, 1336, 1204, 1205, 1204,  139,  573,  556,
+ /*  1090 */   561,  573,  412,  561,  441,  456,  969,  213,  558, 1511,
+ /*  1100 */  1513, 1550,  969,  143,  143,  145,  145, 1368,  314,  478,
+ /*  1110 */   444,  970,  412,  850,  851,  852,  135,  136,   90, 1228,
+ /*  1120 */  1228, 1063, 1066, 1053, 1053,  133,  133,  134,  134,  134,
+ /*  1130 */   134,  357,  412,  397, 1148,  304,  135,  136,   90, 1228,
+ /*  1140 */  1228, 1063, 1066, 1053, 1053,  133,  133,  134,  134,  134,
+ /*  1150 */   134, 1575,  323,    6,  862,    7,  135,  124,   90, 1228,
+ /*  1160 */  1228, 1063, 1066, 1053, 1053,  133,  133,  134,  134,  134,
+ /*  1170 */   134,  409,  408, 1511,  212,  132,  132,  132,  132,  131,
+ /*  1180 */   131,  130,  130,  130,  129,  126,  450,  411,  118, 1204,
+ /*  1190 */   116,   10,  352,  265,  355,  132,  132,  132,  132,  131,
+ /*  1200 */   131,  130,  130,  130,  129,  126,  450,  576,  324,  306,
+ /*  1210 */   576,  306, 1250,  469,  158,  132,  132,  132,  132,  131,
+ /*  1220 */   131,  130,  130,  130,  129,  126,  450,  207, 1224, 1126,
+ /*  1230 */    65,   65,  470,   66,   66,  412,  447,  446,  882,  531,
+ /*  1240 */   335,  258,  257,  256, 1127, 1233, 1204, 1205, 1204,  327,
+ /*  1250 */  1235,  874,  159,  576,   16,  480, 1085, 1040, 1234, 1128,
+ /*  1260 */   136,   90, 1228, 1228, 1063, 1066, 1053, 1053,  133,  133,
+ /*  1270 */   134,  134,  134,  134, 1029,  576,   81,   81, 1028, 1040,
+ /*  1280 */   922,  576,  463, 1236,  576, 1236, 1224,  502,  107, 1435,
+ /*  1290 */   923,    6,  576,  410, 1498,  882, 1029,  480,   21,   21,
+ /*  1300 */  1028,  332, 1380,  334,   53,   53,  497,   81,   81,  874,
+ /*  1310 */  1028, 1028, 1030,  445,  259,   19,   19,  533,  132,  132,
+ /*  1320 */   132,  132,  131,  131,  130,  130,  130,  129,  126,  450,
+ /*  1330 */   551,  301, 1028, 1028, 1030,  107,  532,  545,  121,  568,
+ /*  1340 */  1188,    4, 1126, 1576,  449,  576,  462,    7, 1282,  418,
+ /*  1350 */   462,  350, 1435,  576,  518,  571,  544, 1127,  121,  568,
+ /*  1360 */   442,    4, 1188,  464,  533, 1180, 1223,    9,   67,   67,
+ /*  1370 */   487,  576, 1128,  303,  410,  571,   54,   54,  451,  576,
+ /*  1380 */   123,  944,  576,  417,  576,  333,  943, 1379,  576,  236,
+ /*  1390 */   565,  576, 1574,  564,   68,   68,    7,  576,  451,  362,
+ /*  1400 */   419,  182,   69,   69,  541,   70,   70,   71,   71,  540,
+ /*  1410 */   565,   72,   72,  484,   55,   55,  473, 1180,  296, 1040,
+ /*  1420 */    56,   56,  296,  493,  541,  119,  119,  410, 1573,  542,
+ /*  1430 */   569,  418,    7,  120, 1244,  451,  577,  451,  465, 1040,
+ /*  1440 */  1028,  576, 1557,  552,  476,  119,  119,  527,  259,  121,
+ /*  1450 */   568,  240,    4,  120,  576,  451,  577,  451,  576,  477,
+ /*  1460 */  1028,  576,  156,  576,   57,   57,  571,  576,  286,  229,
+ /*  1470 */   410,  336, 1028, 1028, 1030, 1031,   35,   59,   59,  219,
+ /*  1480 */   983,   60,   60,  220,   73,   73,   74,   74,  984,  451,
+ /*  1490 */    75,   75, 1028, 1028, 1030, 1031,   35,   96,  216,  291,
+ /*  1500 */   552,  565, 1188,  318,  395,  395,  394,  276,  392,  576,
+ /*  1510 */   485,  859,  474, 1311,  410,  541,  576,  417, 1530, 1144,
+ /*  1520 */   540,  399, 1188,  292,  237, 1153,  326,   38,   23,  576,
+ /*  1530 */  1040,  576,   20,   20,  325,  299,  119,  119,  164,   76,
+ /*  1540 */    76, 1529,  121,  568,  120,    4,  451,  577,  451,  203,
+ /*  1550 */   576, 1028,  141,  141,  142,  142,  576,  322,   39,  571,
+ /*  1560 */   341, 1021,  110,  264,  239,  901,  900,  423,  242,  908,
+ /*  1570 */   909,  370,  173,   77,   77,   43,  479, 1310,  264,   62,
+ /*  1580 */    62,  369,  451, 1028, 1028, 1030, 1031,   35, 1601, 1192,
+ /*  1590 */   453, 1092,  238,  291,  565,  163, 1309,  110,  395,  395,
+ /*  1600 */   394,  276,  392,  986,  987,  859,  481,  346,  264,  110,
+ /*  1610 */  1032,  489,  576, 1188,  503, 1088,  261,  261,  237,  576,
+ /*  1620 */   326,  121,  568, 1040,    4,  347, 1376,  413,  325,  119,
+ /*  1630 */   119,  948,  319,  567,  351,   78,   78,  120,  571,  451,
+ /*  1640 */   577,  451,   79,   79, 1028,  354,  356,  576,  360, 1092,
+ /*  1650 */   110,  576,  974,  942,  264,  123,  457,  358,  239,  576,
+ /*  1660 */   519,  451,  939, 1104,  123, 1104,  173,  576, 1032,   43,
+ /*  1670 */    63,   63, 1324,  565,  168,  168, 1028, 1028, 1030, 1031,
+ /*  1680 */    35,  576,  169,  169, 1308,  872,  238,  157, 1589,  576,
+ /*  1690 */    86,   86,  365,   89,  568,  375,    4, 1103,  941, 1103,
+ /*  1700 */   123,  576, 1040, 1389,   64,   64, 1188, 1434,  119,  119,
+ /*  1710 */   571,  576,   82,   82,  563,  576,  120,  165,  451,  577,
+ /*  1720 */   451,  413, 1362, 1028,  144,  144,  319,  567,  576, 1374,
+ /*  1730 */   562,  498,  279,  451,   83,   83, 1439,  576,  166,  166,
+ /*  1740 */   576, 1289,  554,  576, 1280,  565,  576,   12,  576, 1268,
+ /*  1750 */   457,  146,  146, 1267,  576, 1028, 1028, 1030, 1031,   35,
+ /*  1760 */   140,  140, 1269,  167,  167, 1609,  160,  160, 1359,  150,
+ /*  1770 */   150,  149,  149,  311, 1040,  576,  312,  147,  147,  313,
+ /*  1780 */   119,  119,  222,  235,  576, 1188,  396,  576,  120,  576,
+ /*  1790 */   451,  577,  451, 1192,  453, 1028,  508,  291,  148,  148,
+ /*  1800 */  1421, 1612,  395,  395,  394,  276,  392,   85,   85,  859,
+ /*  1810 */    87,   87,   84,   84,  553,  576,  294,  576, 1426,  338,
+ /*  1820 */   339, 1425,  237,  300,  326, 1416, 1409, 1028, 1028, 1030,
+ /*  1830 */  1031,   35,  325,  344,  403,  483,  226, 1307,   52,   52,
+ /*  1840 */    58,   58,  368, 1371, 1502,  566, 1501,  121,  568,  221,
+ /*  1850 */     4,  208,  268,  209,  390, 1244, 1549, 1188, 1372, 1370,
+ /*  1860 */  1369, 1547,  239,  184,  571,  233,  421, 1241,   95,  218,
+ /*  1870 */   173, 1507,  193,   43,   91,   94,  178,  186,  467,  188,
+ /*  1880 */   468, 1422,   13,  189,  190,  191,  501,  451,  245,  108,
+ /*  1890 */   238,  401, 1428, 1427, 1430,  475,  404, 1496,  197,  565,
+ /*  1900 */    14,  490,  249,  101, 1518,  496,  349,  280,  251,  201,
+ /*  1910 */   353,  499,  252,  406, 1270,  253,  517, 1327, 1326,  435,
+ /*  1920 */  1325, 1318,  103,  893, 1296,  413,  227,  407, 1040, 1626,
+ /*  1930 */   319,  567, 1625, 1297,  119,  119,  439,  367, 1317, 1295,
+ /*  1940 */  1624,  526,  120,  440,  451,  577,  451, 1594,  309, 1028,
+ /*  1950 */   310,  373,  266,  267,  457, 1580, 1579,  443,  138, 1394,
+ /*  1960 */   552, 1393,   11, 1483,  384,  115,  317, 1350,  109,  536,
+ /*  1970 */    42,  579,  382,  214, 1349,  388, 1198,  389,  275,  277,
+ /*  1980 */   278, 1028, 1028, 1030, 1031,   35,  580, 1265,  414, 1260,
+ /*  1990 */   170,  415,  183, 1534, 1535, 1533,  171,  154,  307, 1532,
+ /*  2000 */   846,  223,  224,   88,  452,  215,  172,  321,  234, 1102,
+ /*  2010 */   152, 1188, 1100,  329,  185,  174, 1223,  925,  187,  241,
+ /*  2020 */   337,  244, 1116,  192,  175,  176,  424,  426,   97,  194,
+ /*  2030 */    98,   99,  100,  177, 1119, 1115,  246,  247,  161,   24,
+ /*  2040 */   248,  348, 1238,  264, 1108,  250,  495,  199,  198,   15,
+ /*  2050 */   861,  500,  369,  254,  504,  509,  512,  200,  102,   25,
+ /*  2060 */   179,  361,   26,  364,  104,  891,  308,  162,  105,  904,
+ /*  2070 */   520,  106, 1185, 1069, 1155,   17,  228,   27, 1154,  283,
+ /*  2080 */   285,  263,  978,  202,  972,  123,   28, 1175,   29,   30,
+ /*  2090 */  1179, 1171,   31, 1173, 1160,   41,   32,  206,  548,   33,
+ /*  2100 */   110, 1178, 1083,    8,  112, 1070,  113, 1068, 1072,   34,
+ /*  2110 */  1073,  560, 1125,  269, 1124,  270,   36,   18, 1194, 1033,
+ /*  2120 */   873,  151,  122,   37,  393,  271,  272,  572,  181, 1193,
+ /*  2130 */  1256, 1256, 1256,  935, 1256, 1256, 1256, 1256, 1256, 1256,
+ /*  2140 */  1256, 1617,
 };
 static const YYCODETYPE yy_lookahead[] = {
- /*     0 */   193,  193,  193,  274,  275,  276,  193,  274,  275,  276,
- /*    10 */   193,  223,  219,  225,  206,  210,  211,  212,  193,   19,
- /*    20 */   219,  233,  216,  216,  217,  216,  217,  193,  295,  216,
- /*    30 */   217,   31,  193,  216,  217,  193,  228,  213,  230,   39,
- /*    40 */   206,  216,  217,   43,   44,   45,   46,   47,   48,   49,
- /*    50 */    50,   51,   52,   53,   54,   55,   56,   57,  193,   19,
- /*    60 */   185,  186,  187,  188,  189,  190,  253,  274,  275,  276,
- /*    70 */   195,  193,  197,  193,  261,  274,  275,  276,  253,  204,
- /*    80 */   238,  204,   81,   43,   44,   45,   46,   47,   48,   49,
- /*    90 */    50,   51,   52,   53,   54,   55,   56,   57,  274,  275,
- /*   100 */   276,  262,  102,  103,  104,  105,  106,  107,  108,  109,
- /*   110 */   110,  111,  112,  113,  239,  240,  239,  240,  210,  211,
- /*   120 */   212,  314,  315,  314,   59,  316,   86,  252,   88,  252,
- /*   130 */    19,  314,  315,  256,  257,  113,   25,   72,  296,  138,
- /*   140 */   139,  266,  102,  103,  104,  105,  106,  107,  108,  109,
+ /*     0 */   194,  276,  277,  278,  216,  194,  194,  217,  194,  194,
+ /*    10 */   194,  194,  224,  194,  194,  276,  277,  278,  204,   19,
+ /*    20 */   206,  202,  297,  217,  218,  205,  207,  217,  205,  217,
+ /*    30 */   218,   31,  217,  218,  217,  218,   29,  217,  218,   39,
+ /*    40 */    33,  217,  220,   43,   44,   45,   46,   47,   48,   49,
+ /*    50 */    50,   51,   52,   53,   54,   55,   56,   57,  312,   19,
+ /*    60 */   240,  241,  316,  240,  241,  194,   46,   47,   48,   49,
+ /*    70 */    22,  254,   65,  253,  254,  255,  253,  194,  255,  194,
+ /*    80 */   263,  258,  259,   43,   44,   45,   46,   47,   48,   49,
+ /*    90 */    50,   51,   52,   53,   54,   55,   56,   57,  276,  277,
+ /*   100 */   278,  285,  102,  103,  104,  105,  106,  107,  108,  109,
+ /*   110 */   110,  111,  112,  113,   59,  186,  187,  188,  189,  190,
+ /*   120 */   191,  310,  239,  317,  318,  196,   86,  198,   88,  317,
+ /*   130 */    19,  319,  317,  318,  205,  264,   25,  211,  212,  213,
+ /*   140 */   205,  121,  102,  103,  104,  105,  106,  107,  108,  109,
  /*   150 */   110,  111,  112,  113,   43,   44,   45,   46,   47,   48,
- /*   160 */    49,   50,   51,   52,   53,   54,   55,   56,   57,   81,
- /*   170 */   292,   59,  292,  298,  108,  109,  110,  111,  112,  113,
- /*   180 */    69,  116,  117,  118,   72,  106,  107,  193,  111,  112,
- /*   190 */   113,   54,   55,   56,   57,   58,  102,  103,  104,  105,
- /*   200 */   106,  107,  108,  109,  110,  111,  112,  113,  120,   25,
- /*   210 */   216,  217,  145,  102,  103,  104,  105,  106,  107,  108,
- /*   220 */   109,  110,  111,  112,  113,  231,  138,  139,  116,  117,
- /*   230 */   118,  164,  153,   19,  155,   54,   55,   56,   57,  102,
+ /*   160 */    49,   50,   51,   52,   53,   54,   55,   56,   57,  240,
+ /*   170 */   241,  116,  117,  118,  119,  240,  241,  122,  123,  124,
+ /*   180 */    69,  298,  253,  194,  255,  106,  107,  132,  253,  141,
+ /*   190 */   255,   54,   55,   56,   57,   58,  207,  268,  102,  103,
+ /*   200 */   104,  105,  106,  107,  108,  109,  110,  111,  112,  113,
+ /*   210 */   214,  128,  129,  102,  103,  104,  105,  106,  107,  108,
+ /*   220 */   109,  110,  111,  112,  113,  134,   25,  136,  137,  300,
+ /*   230 */   165,  166,  153,   19,  155,   54,   55,   56,   57,  102,
  /*   240 */   103,  104,  105,  106,  107,  108,  109,  110,  111,  112,
- /*   250 */   113,  128,  129,   46,   47,   48,   49,   43,   44,   45,
+ /*   250 */   113,  108,  109,  110,  111,  112,  113,   43,   44,   45,
  /*   260 */    46,   47,   48,   49,   50,   51,   52,   53,   54,   55,
- /*   270 */    56,   57,  216,  193,   25,   59,  193,   19,  165,  166,
- /*   280 */   193,   67,   24,  102,  103,  104,  105,  106,  107,  108,
- /*   290 */   109,  110,  111,  112,  113,   73,  216,  217,   59,  216,
- /*   300 */   217,   43,   44,   45,   46,   47,   48,   49,   50,   51,
+ /*   270 */    56,   57,  276,  277,  278,  113,  194,   19,   22,   23,
+ /*   280 */   194,   67,   24,  102,  103,  104,  105,  106,  107,  108,
+ /*   290 */   109,  110,  111,  112,  113,  220,  250,   59,  252,  217,
+ /*   300 */   218,   43,   44,   45,   46,   47,   48,   49,   50,   51,
  /*   310 */    52,   53,   54,   55,   56,   57,  102,  103,  104,  105,
- /*   320 */   106,  107,  108,  109,  110,  111,  112,  113,  121,  145,
- /*   330 */    59,  193,  116,  117,  118,  119,  273,  204,  122,  123,
- /*   340 */   124,   19,   20,  134,   22,  136,  137,   19,  132,  127,
- /*   350 */   128,  129,   24,   22,   23,  116,  117,  118,   36,  193,
+ /*   320 */   106,  107,  108,  109,  110,  111,  112,  113,  106,  107,
+ /*   330 */   108,  109,  110,  111,  112,  113,  254,   59,  205,  138,
+ /*   340 */   139,   19,   20,  194,   22,  263,   22,   23,  231,   25,
+ /*   350 */    72,  276,  277,  278,  116,  117,  118,  101,   36,   76,
  /*   360 */   102,  103,  104,  105,  106,  107,  108,  109,  110,  111,
- /*   370 */   112,  113,  239,  240,  311,  312,  215,  106,  107,  241,
- /*   380 */    19,   59,  216,  217,  223,  252,  115,  116,  117,  118,
- /*   390 */   151,  120,   26,   71,  193,  308,  309,  193,  149,  128,
- /*   400 */   313,  216,  269,   81,   43,   44,   45,   46,   47,   48,
- /*   410 */    49,   50,   51,   52,   53,   54,   55,   56,   57,  253,
- /*   420 */   216,  217,  100,   95,  153,   59,  155,  261,  106,  107,
- /*   430 */    25,  193,  101,  193,  193,  231,  114,   25,  116,  117,
- /*   440 */   118,  113,  304,  121,  193,  204,   59,  119,  120,  121,
- /*   450 */   122,  123,  124,  125,  216,  217,  193,  216,  217,  131,
- /*   460 */   138,  139,  230,  102,  103,  104,  105,  106,  107,  108,
+ /*   370 */   112,  113,   89,  240,  241,   92,   73,  194,  194,   73,
+ /*   380 */    19,   59,  188,  189,  190,  191,  253,   81,  255,  151,
+ /*   390 */   196,   25,  198,   71,  116,  117,  118,  311,  312,  205,
+ /*   400 */   217,  218,  316,   81,   43,   44,   45,   46,   47,   48,
+ /*   410 */    49,   50,   51,   52,   53,   54,   55,   56,   57,  270,
+ /*   420 */    22,   23,  100,   25,   59,  101,  138,  139,  106,  107,
+ /*   430 */   127,  128,  129,  127,  240,  241,  114,  254,  116,  117,
+ /*   440 */   118,   76,   76,  121,  138,  139,  263,  253,  264,  255,
+ /*   450 */   205,  275,   87,   19,   89,   89,  194,   92,   92,  199,
+ /*   460 */   138,  139,  268,  102,  103,  104,  105,  106,  107,  108,
  /*   470 */   109,  110,  111,  112,  113,  153,  154,  155,  156,  157,
- /*   480 */   239,  240,  116,  117,  118,   76,  193,   23,   19,   25,
- /*   490 */    22,  253,   23,  252,  253,  108,   87,  204,   89,  261,
- /*   500 */   198,   92,  261,  116,  117,  118,  193,  306,  307,  216,
- /*   510 */   217,  150,   43,   44,   45,   46,   47,   48,   49,   50,
- /*   520 */    51,   52,   53,   54,   55,   56,   57,   59,  193,  216,
- /*   530 */   217,   19,  239,  240,  283,   23,  106,  107,  108,  109,
- /*   540 */   110,  111,  112,  113,   73,  252,  253,  142,  308,  309,
- /*   550 */   138,  139,   81,  313,  145,   43,   44,   45,   46,   47,
+ /*   480 */    81,  116,  117,  118,  129,  240,  241,  224,   19,  226,
+ /*   490 */   314,  315,   23,   25,  300,   59,   22,  234,  253,  101,
+ /*   500 */   255,  236,  237,   26,  194,  183,  194,  152,   72,   22,
+ /*   510 */   145,  150,   43,   44,   45,   46,   47,   48,   49,   50,
+ /*   520 */    51,   52,   53,   54,   55,   56,   57,  217,  218,  217,
+ /*   530 */   218,   19,  189,   59,  191,   23,   59,  138,  139,  196,
+ /*   540 */   135,  198,  232,  283,  232,  140,   59,  287,  205,  275,
+ /*   550 */   116,  205,  116,  117,  118,   43,   44,   45,   46,   47,
  /*   560 */    48,   49,   50,   51,   52,   53,   54,   55,   56,   57,
- /*   570 */   307,  102,  103,  104,  105,  106,  107,  108,  109,  110,
- /*   580 */   111,  112,  113,  281,  116,  117,  118,  285,   23,  193,
- /*   590 */    25,  119,   59,  193,  122,  123,  124,   59,  127,  203,
- /*   600 */    59,  205,   19,  268,  132,   25,   23,   22,  193,  138,
- /*   610 */   139,  249,  204,  251,  102,  103,  104,  105,  106,  107,
+ /*   570 */   194,  102,  103,  104,  105,  106,  107,  108,  109,  110,
+ /*   580 */   111,  112,  113,  240,  241,  194,  240,  241,  314,  315,
+ /*   590 */   116,  117,  118,  116,  117,  118,  253,  194,  255,  253,
+ /*   600 */    59,  255,   19,  116,  117,  118,   23,   22,  217,  218,
+ /*   610 */   142,  268,  205,  275,  102,  103,  104,  105,  106,  107,
  /*   620 */   108,  109,  110,  111,  112,  113,   43,   44,   45,   46,
  /*   630 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
- /*   640 */    57,   19,   22,   23,   59,   23,   25,  239,  240,  116,
- /*   650 */   117,  118,  193,   11,  116,  117,  118,  116,  117,  118,
- /*   660 */   252,  269,   22,  193,   15,   43,   44,   45,   46,   47,
+ /*   640 */    57,   19,  194,  300,   59,   23,  119,  240,  241,  122,
+ /*   650 */   123,  124,  314,  315,  194,  236,  237,  194,  117,  132,
+ /*   660 */   253,   81,  255,  205,   59,   43,   44,   45,   46,   47,
  /*   670 */    48,   49,   50,   51,   52,   53,   54,   55,   56,   57,
- /*   680 */   273,  143,  193,  118,  143,  102,  103,  104,  105,  106,
- /*   690 */   107,  108,  109,  110,  111,  112,  113,   76,  118,   59,
- /*   700 */   241,  116,  117,  118,  304,  216,  217,  292,  143,   60,
- /*   710 */    89,  241,   19,   92,  193,  193,   23,   22,  311,  312,
- /*   720 */   231,  101,   22,  143,  102,  103,  104,  105,  106,  107,
+ /*   680 */   217,  218,  194,  194,  194,  102,  103,  104,  105,  106,
+ /*   690 */   107,  108,  109,  110,  111,  112,  113,  294,  240,  241,
+ /*   700 */   120,  116,  117,  118,   59,  194,  217,  218,  211,  212,
+ /*   710 */   213,  253,   19,  255,  194,   19,   23,  254,  138,  139,
+ /*   720 */    24,  232,  117,  194,  102,  103,  104,  105,  106,  107,
  /*   730 */   108,  109,  110,  111,  112,  113,   43,   44,   45,   46,
  /*   740 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
- /*   750 */    57,   19,  193,  193,   59,   23,  116,  117,  118,   59,
- /*   760 */   201,   21,  241,  304,  193,  206,  127,  128,  129,  193,
- /*   770 */   128,  129,  235,  236,  304,   43,   44,   45,   46,   47,
+ /*   750 */    57,   19,  264,  108,   76,   23,  127,  128,  129,  311,
+ /*   760 */   312,  116,  117,  118,  316,   87,  306,   89,  308,  194,
+ /*   770 */    92,   22,   59,  194,   22,   43,   44,   45,   46,   47,
  /*   780 */    48,   49,   50,   51,   52,   53,   54,   55,   56,   57,
- /*   790 */    22,  193,  216,  217,  193,  102,  103,  104,  105,  106,
- /*   800 */   107,  108,  109,  110,  111,  112,  113,  231,  193,  193,
- /*   810 */   193,  116,  117,  118,  216,  217,  116,  117,  118,  226,
- /*   820 */    80,  193,   19,  235,  236,  304,   23,  211,  212,  231,
- /*   830 */   204,  216,  217,  205,  102,  103,  104,  105,  106,  107,
+ /*   790 */   194,   95,  217,  218,  265,  102,  103,  104,  105,  106,
+ /*   800 */   107,  108,  109,  110,  111,  112,  113,  232,   59,  113,
+ /*   810 */    25,   59,  194,  217,  218,  119,  120,  121,  122,  123,
+ /*   820 */   124,  125,   19,  145,  194,  194,   23,  131,  232,  116,
+ /*   830 */   117,  118,   35,  194,  102,  103,  104,  105,  106,  107,
  /*   840 */   108,  109,  110,  111,  112,  113,   43,   44,   45,   46,
  /*   850 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
- /*   860 */    57,   19,  193,  123,   76,  239,  240,  193,  253,  239,
- /*   870 */   240,  239,  240,  244,  106,  107,  193,   89,  252,  193,
- /*   880 */    92,   59,  252,  254,  252,   43,   44,   45,   46,   47,
+ /*   860 */    57,   19,  194,   66,  194,  116,  117,  118,  116,  117,
+ /*   870 */   118,   74,  242,  294,  194,  194,  206,   23,  194,   25,
+ /*   880 */   194,  111,  112,  113,   25,   43,   44,   45,   46,   47,
  /*   890 */    48,   49,   50,   51,   52,   53,   54,   55,   56,   57,
- /*   900 */   284,  161,  216,  217,  193,  102,  103,  104,  105,  106,
- /*   910 */   107,  108,  109,  110,  111,  112,  113,  231,  193,  244,
- /*   920 */   187,  188,  189,  190,    7,    8,    9,  309,  195,  254,
- /*   930 */   197,  313,   19,  127,  128,  129,  262,  204,   22,  117,
- /*   940 */    24,  216,  217,  273,  102,  103,  104,  105,  106,  107,
+ /*   900 */    24,  194,  194,  217,  218,  102,  103,  104,  105,  106,
+ /*   910 */   107,  108,  109,  110,  111,  112,  113,  241,  232,  194,
+ /*   920 */   212,  213,  242,  242,  217,  218,  242,  130,   11,  253,
+ /*   930 */   194,  255,   19,  265,  149,   59,  306,  194,  308,  232,
+ /*   940 */   309,  310,  217,  218,  102,  103,  104,  105,  106,  107,
  /*   950 */   108,  109,  110,  111,  112,  113,   43,   44,   45,   46,
  /*   960 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
- /*   970 */    57,  193,  239,  240,  193,   59,   19,  188,  253,  190,
- /*   980 */   193,  311,  312,   16,  195,  252,  197,  193,   19,  301,
- /*   990 */   302,  135,  193,  204,  216,  217,  140,  216,  217,  266,
- /*  1000 */   204,  159,   45,   46,   47,   48,   49,   50,   51,   52,
+ /*   970 */    57,  194,  194,   59,  194,  239,   19,  194,   25,  254,
+ /*   980 */   303,  304,   23,  194,   25,  126,  306,  306,  308,  308,
+ /*   990 */   306,  271,  308,  117,  286,  217,  218,  217,  218,  194,
+ /*  1000 */   194,  159,   45,   46,   47,   48,   49,   50,   51,   52,
  /*  1010 */    53,   54,   55,   56,   57,  102,  103,  104,  105,  106,
- /*  1020 */   107,  108,  109,  110,  111,  112,  113,   12,  239,  240,
- /*  1030 */   193,  298,  238,  117,  253,  239,  240,  238,  259,  260,
- /*  1040 */   193,  252,   27,  193,   77,  193,   79,  204,  252,  262,
- /*  1050 */   193,  299,  300,  193,  100,  266,  278,   42,  204,  102,
+ /*  1020 */   107,  108,  109,  110,  111,  112,  113,   59,  239,  194,
+ /*  1030 */   116,  117,  118,  260,  254,  194,  240,  241,  194,  233,
+ /*  1040 */   205,  240,  241,  205,  239,  128,  129,  270,  265,  253,
+ /*  1050 */   194,  255,  217,  218,  253,  194,  255,  143,  280,  102,
  /*  1060 */   103,  104,  105,  106,  107,  108,  109,  110,  111,  112,
- /*  1070 */   113,  117,  159,  216,  217,  121,  216,  217,   63,  193,
- /*  1080 */   193,  193,  239,  240,  115,  116,  193,  298,   73,  240,
- /*  1090 */   238,  231,   19,  239,  240,  252,   22,   24,  211,  212,
- /*  1100 */   263,  252,  216,  217,  216,  217,  252,  153,  154,  155,
- /*  1110 */   253,  193,   19,  144,  213,  268,   43,   44,   45,   46,
+ /*  1070 */   113,  118,  159,  217,  218,  240,  241,  118,  240,  241,
+ /*  1080 */   194,  194,  194,  239,  116,  117,  118,   22,  253,  254,
+ /*  1090 */   255,  253,   19,  255,  233,  194,  143,   24,  263,  212,
+ /*  1100 */   213,  194,  143,  217,  218,  217,  218,  261,  262,  271,
+ /*  1110 */   254,  143,   19,    7,    8,    9,   43,   44,   45,   46,
  /*  1120 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
- /*  1130 */    57,  193,   19,   59,  216,  217,   43,   44,   45,   46,
+ /*  1130 */    57,   16,   19,   22,   23,  294,   43,   44,   45,   46,
  /*  1140 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
- /*  1150 */    57,  193,   19,   24,  216,  217,   43,   44,   45,   46,
+ /*  1150 */    57,  312,  194,  214,   21,  316,   43,   44,   45,   46,
  /*  1160 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
- /*  1170 */    57,  284,  193,  208,  209,  102,  103,  104,  105,  106,
- /*  1180 */   107,  108,  109,  110,  111,  112,  113,  286,   59,  193,
- /*  1190 */   232,  117,  291,  193,  193,  102,  103,  104,  105,  106,
- /*  1200 */   107,  108,  109,  110,  111,  112,  113,  193,  204,   22,
- /*  1210 */    23,  193,   25,   66,  193,  102,  103,  104,  105,  106,
- /*  1220 */   107,  108,  109,  110,  111,  112,  113,  193,  193,  193,
- /*  1230 */   216,  217,   85,  193,  238,   19,   16,  216,  217,  238,
- /*  1240 */   193,   94,  193,  239,  240,  231,  117,  268,   35,  116,
- /*  1250 */   216,  217,  216,  217,   22,   23,  252,   25,  208,  209,
+ /*  1170 */    57,  106,  107,  286,  194,  102,  103,  104,  105,  106,
+ /*  1180 */   107,  108,  109,  110,  111,  112,  113,  207,  158,   59,
+ /*  1190 */   160,   22,   77,   24,   79,  102,  103,  104,  105,  106,
+ /*  1200 */   107,  108,  109,  110,  111,  112,  113,  194,  194,  229,
+ /*  1210 */   194,  231,  101,   80,   22,  102,  103,  104,  105,  106,
+ /*  1220 */   107,  108,  109,  110,  111,  112,  113,  288,   59,   12,
+ /*  1230 */   217,  218,  293,  217,  218,   19,  106,  107,   59,   19,
+ /*  1240 */    16,  127,  128,  129,   27,  115,  116,  117,  118,  194,
+ /*  1250 */   120,   59,   22,  194,   24,  194,  123,  100,  128,   42,
  /*  1260 */    44,   45,   46,   47,   48,   49,   50,   51,   52,   53,
- /*  1270 */    54,   55,   56,   57,  193,  193,   19,    5,   59,   66,
- /*  1280 */   193,  263,   10,   11,   12,   13,   14,   74,  101,   17,
- /*  1290 */   193,   46,  193,  146,  193,   76,  213,   77,  263,   79,
- /*  1300 */    12,  260,   30,   46,   32,  264,   87,  193,   89,   29,
- /*  1310 */   263,   92,   40,   33,  232,   27,  193,  108,  102,  103,
+ /*  1270 */    54,   55,   56,   57,  117,  194,  217,  218,  121,  100,
+ /*  1280 */    63,  194,  245,  153,  194,  155,  117,   19,  115,  194,
+ /*  1290 */    73,  214,  194,  256,  161,  116,  117,  194,  217,  218,
+ /*  1300 */   121,   77,  194,   79,  217,  218,  194,  217,  218,  117,
+ /*  1310 */   153,  154,  155,  254,   46,  217,  218,  144,  102,  103,
  /*  1320 */   104,  105,  106,  107,  108,  109,  110,  111,  112,  113,
- /*  1330 */    42,  138,  139,  101,  193,  116,  117,  118,   19,   20,
- /*  1340 */   255,   22,   70,  130,  135,   65,  256,  257,  193,  140,
- /*  1350 */    78,   63,  193,   81,  193,   36,  193,  216,  217,  193,
- /*  1360 */   115,  193,  263,  193,  145,  268,   59,   48,  193,  193,
- /*  1370 */    98,  193,  115,  193,  291,  216,  217,  193,   59,  216,
- /*  1380 */   217,  161,  216,  217,  216,  217,  216,  217,  131,  193,
- /*  1390 */    71,  193,  216,  217,  216,  217,  216,  217,  193,  260,
- /*  1400 */   216,  217,   19,  264,   85,  133,  244,  100,  193,   90,
- /*  1410 */   138,  139,  216,  217,  216,  217,  254,  244,  193,  100,
- /*  1420 */   193,  216,  217,  116,  117,  106,  107,  254,  121,  193,
- /*  1430 */   115,  216,  217,  114,  162,  116,  117,  118,  115,  244,
- /*  1440 */   121,  216,  217,  216,  217,  193,  309,  193,   31,  254,
- /*  1450 */   313,  309,  216,  217,  309,  313,   39,  193,  313,  309,
- /*  1460 */   153,  154,  155,  313,  193,  150,   25,  144,  216,  217,
- /*  1470 */   216,  217,  153,  154,  155,  156,  157,    0,    1,    2,
- /*  1480 */   216,  217,    5,  149,  150,   22,  193,   10,   11,   12,
- /*  1490 */    13,   14,  193,  158,   17,  160,  193,   19,   20,  116,
- /*  1500 */    22,   25,  193,   24,   22,  193,   24,   30,  226,   32,
- /*  1510 */    19,   20,  226,   22,   36,  193,   53,   40,  193,  216,
- /*  1520 */   217,  193,   23,  193,   25,  216,  217,   36,  216,  217,
- /*  1530 */   193,   99,  193,  193,   22,  193,  193,   59,  216,  217,
- /*  1540 */   193,  216,  217,  193,  216,  217,  193,   70,  129,   71,
- /*  1550 */    59,  129,  193,  216,  217,   78,  216,  217,   81,  216,
- /*  1560 */   217,  193,   71,   85,  193,  133,  193,  126,   90,  216,
- /*  1570 */   217,  152,  258,   61,  152,   98,   85,  193,  100,  193,
- /*  1580 */    23,   90,   25,  121,  106,  107,   23,  216,  217,  216,
- /*  1590 */   217,  100,  114,  131,  116,  117,  118,  106,  107,  121,
- /*  1600 */   216,  217,  216,  217,  193,  114,  193,  116,  117,  118,
- /*  1610 */   133,   22,  121,  193,   59,  138,  139,  193,  142,  193,
- /*  1620 */   141,   23,   23,   25,   25,  120,  121,  216,  217,  216,
- /*  1630 */   217,  153,  154,  155,  156,  157,  216,  217,   19,  162,
- /*  1640 */   216,  217,  216,  217,  153,  154,  155,  156,  157,    1,
- /*  1650 */     2,  193,   59,    5,   19,   20,  318,   22,   10,   11,
- /*  1660 */    12,   13,   14,  193,   59,   17,  193,   23,   23,   25,
- /*  1670 */    25,   36,  117,  193,  216,  217,  193,   23,   30,   25,
- /*  1680 */    32,   19,   20,   23,   22,   25,  216,  217,   40,  216,
- /*  1690 */   217,    7,    8,   23,   59,   25,   83,   84,   36,   23,
- /*  1700 */   193,   25,   23,   23,   25,   25,   71,  153,  145,  155,
- /*  1710 */   117,  153,   23,  155,   25,   23,   97,   25,   70,  193,
- /*  1720 */   193,   59,  117,  236,  193,  193,   78,  193,  193,   81,
- /*  1730 */   141,  193,  193,   71,  193,  100,  288,  287,  242,  255,
- /*  1740 */   255,  106,  107,  108,  255,  255,   98,  243,  297,  114,
- /*  1750 */   214,  116,  117,  118,  245,  191,  121,  271,  293,  267,
- /*  1760 */   267,  246,  100,  246,  245,  271,  271,  293,  106,  107,
- /*  1770 */   220,  271,  229,  225,  249,  219,  114,  259,  116,  117,
- /*  1780 */   118,  133,  259,  121,  219,  219,  138,  139,  153,  154,
- /*  1790 */   155,  156,  157,  280,  249,  243,   19,   20,  245,   22,
- /*  1800 */   196,  259,  140,  259,   60,  297,  141,  297,  200,  200,
- /*  1810 */   162,   38,  200,   36,  294,  153,  154,  155,  156,  157,
- /*  1820 */   151,  150,  294,  283,   22,   43,  234,   18,  237,  200,
- /*  1830 */   270,  272,  237,  237,  237,   18,   59,  199,  270,  149,
- /*  1840 */   246,  272,  272,  200,  234,  234,  246,  246,   71,  246,
- /*  1850 */   199,  158,  290,   62,   22,  200,   19,   20,  199,   22,
- /*  1860 */   289,  221,  221,  200,  200,  199,  199,  115,  218,   64,
- /*  1870 */   218,  218,   22,   36,  227,  126,  227,  100,  165,  221,
- /*  1880 */   224,  224,   24,  106,  107,  312,  218,  305,  113,  282,
- /*  1890 */    91,  114,  220,  116,  117,  118,   59,  282,  121,  218,
- /*  1900 */   218,  218,  200,  317,  317,   82,  221,  265,   71,  148,
- /*  1910 */   145,  265,   22,  277,  200,  158,  279,  140,  147,   25,
- /*  1920 */   146,  202,  248,  250,  249,  247,   13,  250,  194,  194,
- /*  1930 */   153,  154,  155,  156,  157,    6,  303,  100,  192,  192,
- /*  1940 */   246,  213,  192,  106,  107,  207,  213,  207,  222,  213,
- /*  1950 */   213,  114,  222,  116,  117,  118,  214,  214,  121,    4,
- /*  1960 */   207,  213,    3,   22,  303,   15,  163,   16,   23,   23,
- /*  1970 */   139,  151,  130,   25,   20,  142,   24,   16,  144,    1,
- /*  1980 */   142,  130,  130,   61,   37,   53,  300,  151,   53,   53,
- /*  1990 */   153,  154,  155,  156,  157,   53,  130,  116,   34,    1,
- /*  2000 */   141,    5,   22,  115,  161,   68,   25,   68,   75,   41,
- /*  2010 */   141,  115,   24,   20,   19,  131,  125,   23,   28,   22,
- /*  2020 */    67,   22,   22,   22,   67,   59,   24,   96,   22,   67,
- /*  2030 */    23,  149,   22,   25,   23,   23,   23,   22,   34,  141,
- /*  2040 */    37,   97,   23,   23,  116,   22,  143,   25,   34,   75,
- /*  2050 */    34,   34,   34,   88,   75,   34,   86,   23,   22,   34,
- /*  2060 */    93,   24,   34,   25,   25,  142,  142,   23,   44,   23,
- /*  2070 */    23,   23,   23,   11,   23,   25,   22,   22,   22,  141,
- /*  2080 */    23,   23,   22,   22,   25,   15,    1,   23,   25,    1,
- /*  2090 */   141,  135,  319,  319,  319,  319,  319,  319,  319,  141,
- /*  2100 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
- /*  2110 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
- /*  2120 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
- /*  2130 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
- /*  2140 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
- /*  2150 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
- /*  2160 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
- /*  2170 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
- /*  2180 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
- /*  2190 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
- /*  2200 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
- /*  2210 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
- /*  2220 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
- /*  2230 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
- /*  2240 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
- /*  2250 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
- /*  2260 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
- /*  2270 */   319,  319,  319,  319,  319,  319,  319,  319,  319,  319,
- /*  2280 */   319,  319,  319,  319,  319,
+ /*  1330 */   232,  270,  153,  154,  155,  115,  116,   66,   19,   20,
+ /*  1340 */   183,   22,   12,  312,  254,  194,  262,  316,  209,  210,
+ /*  1350 */   266,  239,  194,  194,  108,   36,   85,   27,   19,   20,
+ /*  1360 */   265,   22,  183,  245,  144,   94,   25,   48,  217,  218,
+ /*  1370 */   293,  194,   42,  270,  256,   36,  217,  218,   59,  194,
+ /*  1380 */    25,  135,  194,  115,  194,  161,  140,  194,  194,   15,
+ /*  1390 */    71,  194,  312,   63,  217,  218,  316,  194,   59,  131,
+ /*  1400 */   301,  302,  217,  218,   85,  217,  218,  217,  218,   90,
+ /*  1410 */    71,  217,  218,   19,  217,  218,  245,  146,  262,  100,
+ /*  1420 */   217,  218,  266,  265,   85,  106,  107,  256,  312,   90,
+ /*  1430 */   209,  210,  316,  114,   60,  116,  117,  118,  194,  100,
+ /*  1440 */   121,  194,  194,  145,  115,  106,  107,   19,   46,   19,
+ /*  1450 */    20,   24,   22,  114,  194,  116,  117,  118,  194,  245,
+ /*  1460 */   121,  194,  164,  194,  217,  218,   36,  194,  258,  259,
+ /*  1470 */   256,  194,  153,  154,  155,  156,  157,  217,  218,  150,
+ /*  1480 */    31,  217,  218,  142,  217,  218,  217,  218,   39,   59,
+ /*  1490 */   217,  218,  153,  154,  155,  156,  157,  149,  150,    5,
+ /*  1500 */   145,   71,  183,  245,   10,   11,   12,   13,   14,  194,
+ /*  1510 */   116,   17,  129,  227,  256,   85,  194,  115,  194,   23,
+ /*  1520 */    90,   25,  183,   99,   30,   97,   32,   22,   22,  194,
+ /*  1530 */   100,  194,  217,  218,   40,  152,  106,  107,   23,  217,
+ /*  1540 */   218,  194,   19,   20,  114,   22,  116,  117,  118,  257,
+ /*  1550 */   194,  121,  217,  218,  217,  218,  194,  133,   53,   36,
+ /*  1560 */    23,   23,   25,   25,   70,  120,  121,   61,  141,    7,
+ /*  1570 */     8,  121,   78,  217,  218,   81,   23,  227,   25,  217,
+ /*  1580 */   218,  131,   59,  153,  154,  155,  156,  157,    0,    1,
+ /*  1590 */     2,   59,   98,    5,   71,   23,  227,   25,   10,   11,
+ /*  1600 */    12,   13,   14,   83,   84,   17,   23,   23,   25,   25,
+ /*  1610 */    59,  194,  194,  183,   23,   23,   25,   25,   30,  194,
+ /*  1620 */    32,   19,   20,  100,   22,  194,  194,  133,   40,  106,
+ /*  1630 */   107,  108,  138,  139,  194,  217,  218,  114,   36,  116,
+ /*  1640 */   117,  118,  217,  218,  121,  194,  194,  194,   23,  117,
+ /*  1650 */    25,  194,   23,   23,   25,   25,  162,  194,   70,  194,
+ /*  1660 */   145,   59,   23,  153,   25,  155,   78,  194,  117,   81,
+ /*  1670 */   217,  218,  194,   71,  217,  218,  153,  154,  155,  156,
+ /*  1680 */   157,  194,  217,  218,  194,   23,   98,   25,  321,  194,
+ /*  1690 */   217,  218,  194,   19,   20,  194,   22,  153,   23,  155,
+ /*  1700 */    25,  194,  100,  194,  217,  218,  183,  194,  106,  107,
+ /*  1710 */    36,  194,  217,  218,  237,  194,  114,  243,  116,  117,
+ /*  1720 */   118,  133,  194,  121,  217,  218,  138,  139,  194,  194,
+ /*  1730 */   194,  290,  289,   59,  217,  218,  194,  194,  217,  218,
+ /*  1740 */   194,  194,  140,  194,  194,   71,  194,  244,  194,  194,
+ /*  1750 */   162,  217,  218,  194,  194,  153,  154,  155,  156,  157,
+ /*  1760 */   217,  218,  194,  217,  218,  194,  217,  218,  257,  217,
+ /*  1770 */   218,  217,  218,  257,  100,  194,  257,  217,  218,  257,
+ /*  1780 */   106,  107,  215,  299,  194,  183,  192,  194,  114,  194,
+ /*  1790 */   116,  117,  118,    1,    2,  121,  221,    5,  217,  218,
+ /*  1800 */   273,  197,   10,   11,   12,   13,   14,  217,  218,   17,
+ /*  1810 */   217,  218,  217,  218,  140,  194,  246,  194,  273,  295,
+ /*  1820 */   247,  273,   30,  247,   32,  269,  269,  153,  154,  155,
+ /*  1830 */   156,  157,   40,  246,  273,  295,  230,  226,  217,  218,
+ /*  1840 */   217,  218,  220,  261,  220,  282,  220,   19,   20,  244,
+ /*  1850 */    22,  250,  141,  250,  246,   60,  201,  183,  261,  261,
+ /*  1860 */   261,  201,   70,  299,   36,  299,  201,   38,  151,  150,
+ /*  1870 */    78,  285,   22,   81,  296,  296,   43,  235,   18,  238,
+ /*  1880 */   201,  274,  272,  238,  238,  238,   18,   59,  200,  149,
+ /*  1890 */    98,  247,  274,  274,  235,  247,  247,  247,  235,   71,
+ /*  1900 */   272,  201,  200,  158,  292,   62,  291,  201,  200,   22,
+ /*  1910 */   201,  222,  200,  222,  201,  200,  115,  219,  219,   64,
+ /*  1920 */   219,  228,   22,  126,  221,  133,  165,  222,  100,  225,
+ /*  1930 */   138,  139,  225,  219,  106,  107,   24,  219,  228,  219,
+ /*  1940 */   219,  307,  114,  113,  116,  117,  118,  315,  284,  121,
+ /*  1950 */   284,  222,  201,   91,  162,  320,  320,   82,  148,  267,
+ /*  1960 */   145,  267,   22,  279,  201,  158,  281,  251,  147,  146,
+ /*  1970 */    25,  203,  250,  249,  251,  248,   13,  247,  195,  195,
+ /*  1980 */     6,  153,  154,  155,  156,  157,  193,  193,  305,  193,
+ /*  1990 */   208,  305,  302,  214,  214,  214,  208,  223,  223,  214,
+ /*  2000 */     4,  215,  215,  214,    3,   22,  208,  163,   15,   23,
+ /*  2010 */    16,  183,   23,  139,  151,  130,   25,   20,  142,   24,
+ /*  2020 */    16,  144,    1,  142,  130,  130,   61,   37,   53,  151,
+ /*  2030 */    53,   53,   53,  130,  116,    1,   34,  141,    5,   22,
+ /*  2040 */   115,  161,   75,   25,   68,  141,   41,  115,   68,   24,
+ /*  2050 */    20,   19,  131,  125,   67,   67,   96,   22,   22,   22,
+ /*  2060 */    37,   23,   22,   24,   22,   59,   67,   23,  149,   28,
+ /*  2070 */    22,   25,   23,   23,   23,   22,  141,   34,   97,   23,
+ /*  2080 */    23,   34,  116,   22,  143,   25,   34,   75,   34,   34,
+ /*  2090 */    75,   88,   34,   86,   23,   22,   34,   25,   24,   34,
+ /*  2100 */    25,   93,   23,   44,  142,   23,  142,   23,   23,   22,
+ /*  2110 */    11,   25,   23,   25,   23,   22,   22,   22,    1,   23,
+ /*  2120 */    23,   23,   22,   22,   15,  141,  141,   25,   25,    1,
+ /*  2130 */   322,  322,  322,  135,  322,  322,  322,  322,  322,  322,
+ /*  2140 */   322,  141,  322,  322,  322,  322,  322,  322,  322,  322,
+ /*  2150 */   322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
+ /*  2160 */   322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
+ /*  2170 */   322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
+ /*  2180 */   322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
+ /*  2190 */   322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
+ /*  2200 */   322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
+ /*  2210 */   322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
+ /*  2220 */   322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
+ /*  2230 */   322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
+ /*  2240 */   322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
+ /*  2250 */   322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
+ /*  2260 */   322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
+ /*  2270 */   322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
+ /*  2280 */   322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
+ /*  2290 */   322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
+ /*  2300 */   322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
+ /*  2310 */   322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
+ /*  2320 */   322,  322,  322,  322,  322,  322,  322,  322,
 };
-#define YY_SHIFT_COUNT    (578)
+#define YY_SHIFT_COUNT    (582)
 #define YY_SHIFT_MIN      (0)
-#define YY_SHIFT_MAX      (2088)
+#define YY_SHIFT_MAX      (2128)
 static const unsigned short int yy_shift_ofst[] = {
- /*     0 */  1648, 1477, 1272,  322,  322,    1, 1319, 1478, 1491, 1837,
- /*    10 */  1837, 1837,  471,    0,    0,  214, 1093, 1837, 1837, 1837,
- /*    20 */  1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837,
- /*    30 */  1837,  271,  271, 1219, 1219,  216,   88,    1,    1,    1,
- /*    40 */     1,    1,   40,  111,  258,  361,  469,  512,  583,  622,
- /*    50 */   693,  732,  803,  842,  913, 1073, 1093, 1093, 1093, 1093,
- /*    60 */  1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093,
- /*    70 */  1093, 1093, 1093, 1093, 1113, 1093, 1216,  957,  957, 1635,
- /*    80 */  1662, 1777, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837,
- /*    90 */  1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837,
- /*   100 */  1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837,
- /*   110 */  1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837,
- /*   120 */  1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837,
- /*   130 */  1837,  137,  181,  181,  181,  181,  181,  181,  181,   94,
- /*   140 */   430,   66,   65,  112,  366,  533,  533,  740, 1257,  533,
- /*   150 */   533,   79,   79,  533,  412,  412,  412,   77,  412,  123,
- /*   160 */   113,  113,  113,   22,   22, 2100, 2100,  328,  328,  328,
- /*   170 */   239,  468,  468,  468,  468, 1015, 1015,  409,  366, 1187,
- /*   180 */  1232,  533,  533,  533,  533,  533,  533,  533,  533,  533,
- /*   190 */   533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
- /*   200 */   533,  969,  621,  621,  533,  642,  788,  788, 1133, 1133,
- /*   210 */   822,  822,   67, 1193, 2100, 2100, 2100, 2100, 2100, 2100,
- /*   220 */  2100, 1307,  954,  954,  585,  472,  640,  387,  695,  538,
- /*   230 */   541,  700,  533,  533,  533,  533,  533,  533,  533,  533,
- /*   240 */   533,  533,  222,  533,  533,  533,  533,  533,  533,  533,
- /*   250 */   533,  533,  533,  533,  533, 1213, 1213, 1213,  533,  533,
- /*   260 */   533,  565,  533,  533,  533,  916, 1147,  533,  533, 1288,
- /*   270 */   533,  533,  533,  533,  533,  533,  533,  533,  639, 1280,
- /*   280 */   209, 1129, 1129, 1129, 1129,  580,  209,  209, 1209,  768,
- /*   290 */   917,  649, 1315, 1334,  405, 1334, 1383,  249, 1315, 1315,
- /*   300 */   249, 1315,  405, 1383, 1441,  464, 1245, 1417, 1417, 1417,
- /*   310 */  1323, 1323, 1323, 1323,  184,  184, 1335, 1476,  856, 1482,
- /*   320 */  1744, 1744, 1665, 1665, 1773, 1773, 1665, 1669, 1671, 1802,
- /*   330 */  1782, 1809, 1809, 1809, 1809, 1665, 1817, 1690, 1671, 1671,
- /*   340 */  1690, 1802, 1782, 1690, 1782, 1690, 1665, 1817, 1693, 1791,
- /*   350 */  1665, 1817, 1832, 1665, 1817, 1665, 1817, 1832, 1752, 1752,
- /*   360 */  1752, 1805, 1850, 1850, 1832, 1752, 1749, 1752, 1805, 1752,
- /*   370 */  1752, 1713, 1858, 1775, 1775, 1832, 1665, 1799, 1799, 1823,
- /*   380 */  1823, 1761, 1765, 1890, 1665, 1757, 1761, 1771, 1774, 1690,
- /*   390 */  1894, 1913, 1913, 1929, 1929, 1929, 2100, 2100, 2100, 2100,
- /*   400 */  2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100,
- /*   410 */  2100,  207, 1220,  331,  620,  967,  806, 1074, 1499, 1432,
- /*   420 */  1463, 1479, 1419, 1422, 1557, 1512, 1598, 1599, 1644, 1645,
- /*   430 */  1654, 1660, 1555, 1505, 1684, 1462, 1670, 1563, 1619, 1593,
- /*   440 */  1676, 1679, 1613, 1680, 1554, 1558, 1689, 1692, 1605, 1589,
- /*   450 */  1955, 1959, 1941, 1803, 1950, 1951, 1945, 1946, 1831, 1820,
- /*   460 */  1842, 1948, 1948, 1952, 1833, 1954, 1834, 1961, 1978, 1838,
- /*   470 */  1851, 1948, 1852, 1922, 1947, 1948, 1836, 1932, 1935, 1936,
- /*   480 */  1942, 1866, 1881, 1964, 1859, 1998, 1996, 1980, 1888, 1843,
- /*   490 */  1937, 1981, 1939, 1933, 1968, 1869, 1896, 1988, 1993, 1995,
- /*   500 */  1884, 1891, 1997, 1953, 1999, 2000, 1994, 2001, 1957, 1966,
- /*   510 */  2002, 1931, 1990, 2006, 1962, 2003, 2007, 2004, 1882, 2010,
- /*   520 */  2011, 2012, 2008, 2013, 2015, 1944, 1898, 2019, 2020, 1928,
- /*   530 */  2014, 2023, 1903, 2022, 2016, 2017, 2018, 2021, 1965, 1974,
- /*   540 */  1970, 2024, 1979, 1967, 2025, 2034, 2036, 2037, 2038, 2039,
- /*   550 */  2028, 1923, 1924, 2044, 2022, 2046, 2047, 2048, 2049, 2050,
- /*   560 */  2051, 2054, 2062, 2055, 2056, 2057, 2058, 2060, 2061, 2059,
- /*   570 */  1956, 1938, 1949, 1958, 2063, 2064, 2070, 2085, 2088,
+ /*     0 */  1792, 1588, 1494,  322,  322,  399,  306, 1319, 1339, 1430,
+ /*    10 */  1828, 1828, 1828,  580,  399,  399,  399,  399,  399,    0,
+ /*    20 */     0,  214, 1093, 1828, 1828, 1828, 1828, 1828, 1828, 1828,
+ /*    30 */  1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1130, 1130,
+ /*    40 */   365,  365,   55,  278,  436,  713,  713,  201,  201,  201,
+ /*    50 */   201,   40,  111,  258,  361,  469,  512,  583,  622,  693,
+ /*    60 */   732,  803,  842,  913, 1073, 1093, 1093, 1093, 1093, 1093,
+ /*    70 */  1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093,
+ /*    80 */  1093, 1093, 1093, 1113, 1093, 1216,  957,  957, 1523, 1602,
+ /*    90 */  1674, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828,
+ /*   100 */  1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828,
+ /*   110 */  1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828,
+ /*   120 */  1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828,
+ /*   130 */  1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828,
+ /*   140 */   137,  181,  181,  181,  181,  181,  181,  181,   96,  222,
+ /*   150 */   143,  477,  713, 1133, 1268,  713,  713,   79,   79,  713,
+ /*   160 */   770,   83,   65,   65,   65,  288,  162,  162, 2142, 2142,
+ /*   170 */   696,  696,  696,  238,  474,  474,  474,  474, 1217, 1217,
+ /*   180 */   678,  477,  324,  398,  713,  713,  713,  713,  713,  713,
+ /*   190 */   713,  713,  713,  713,  713,  713,  713,  713,  713,  713,
+ /*   200 */   713,  713,  713, 1220,  366,  366,  713,  917,  283,  283,
+ /*   210 */   434,  434,  605,  605, 1298, 2142, 2142, 2142, 2142, 2142,
+ /*   220 */  2142, 2142, 1179, 1157, 1157,  487,  527,  585,  645,  749,
+ /*   230 */   914,  968,  752,  713,  713,  713,  713,  713,  713,  713,
+ /*   240 */   713,  713,  713,  303,  713,  713,  713,  713,  713,  713,
+ /*   250 */   713,  713,  713,  713,  713,  713,  797,  797,  797,  713,
+ /*   260 */   713,  713,  959,  713,  713,  713, 1169, 1271,  713,  713,
+ /*   270 */  1330,  713,  713,  713,  713,  713,  713,  713,  713,  629,
+ /*   280 */     7,   91,  876,  876,  876,  876,  953,   91,   91, 1246,
+ /*   290 */  1065, 1106, 1374, 1329, 1348,  468, 1348, 1394,  785, 1329,
+ /*   300 */  1329,  785, 1329,  468, 1394,  859,  854, 1402, 1449, 1449,
+ /*   310 */  1449, 1173, 1173, 1173, 1173, 1355, 1355, 1030, 1341,  405,
+ /*   320 */  1230, 1795, 1795, 1711, 1711, 1829, 1829, 1711, 1717, 1719,
+ /*   330 */  1850, 1833, 1860, 1860, 1860, 1860, 1711, 1868, 1740, 1719,
+ /*   340 */  1719, 1740, 1850, 1833, 1740, 1833, 1740, 1711, 1868, 1745,
+ /*   350 */  1843, 1711, 1868, 1887, 1711, 1868, 1711, 1868, 1887, 1801,
+ /*   360 */  1801, 1801, 1855, 1900, 1900, 1887, 1801, 1797, 1801, 1855,
+ /*   370 */  1801, 1801, 1761, 1912, 1830, 1830, 1887, 1711, 1862, 1862,
+ /*   380 */  1875, 1875, 1810, 1815, 1940, 1711, 1807, 1810, 1821, 1823,
+ /*   390 */  1740, 1945, 1963, 1963, 1974, 1974, 1974, 2142, 2142, 2142,
+ /*   400 */  2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142,
+ /*   410 */  2142, 2142,   20, 1224,  256, 1111, 1115, 1114, 1192, 1496,
+ /*   420 */  1424, 1505, 1427,  355, 1383, 1537, 1506, 1538, 1553, 1583,
+ /*   430 */  1584, 1591, 1625,  541, 1445, 1562, 1450, 1572, 1515, 1428,
+ /*   440 */  1532, 1592, 1629, 1520, 1630, 1639, 1510, 1544, 1662, 1675,
+ /*   450 */  1551,   48, 1996, 2001, 1983, 1844, 1993, 1994, 1986, 1989,
+ /*   460 */  1874, 1863, 1885, 1991, 1991, 1995, 1876, 1997, 1877, 2004,
+ /*   470 */  2021, 1881, 1894, 1991, 1895, 1965, 1990, 1991, 1878, 1975,
+ /*   480 */  1977, 1978, 1979, 1903, 1918, 2002, 1896, 2034, 2033, 2017,
+ /*   490 */  1925, 1880, 1976, 2018, 1980, 1967, 2005, 1904, 1932, 2025,
+ /*   500 */  2030, 2032, 1921, 1928, 2035, 1987, 2036, 2037, 2038, 2040,
+ /*   510 */  1988, 2006, 2039, 1960, 2041, 2042, 1999, 2023, 2044, 2043,
+ /*   520 */  1919, 2048, 2049, 2050, 2046, 2051, 2053, 1981, 1935, 2056,
+ /*   530 */  2057, 1966, 2047, 2061, 1941, 2060, 2052, 2054, 2055, 2058,
+ /*   540 */  2003, 2012, 2007, 2059, 2015, 2008, 2062, 2071, 2073, 2074,
+ /*   550 */  2072, 2075, 2065, 1962, 1964, 2079, 2060, 2082, 2084, 2085,
+ /*   560 */  2087, 2086, 2089, 2088, 2091, 2093, 2099, 2094, 2095, 2096,
+ /*   570 */  2097, 2100, 2101, 2102, 1998, 1984, 1985, 2000, 2103, 2098,
+ /*   580 */  2109, 2117, 2128,
 };
-#define YY_REDUCE_COUNT (410)
-#define YY_REDUCE_MIN   (-271)
-#define YY_REDUCE_MAX   (1753)
+#define YY_REDUCE_COUNT (411)
+#define YY_REDUCE_MIN   (-275)
+#define YY_REDUCE_MAX   (1798)
 static const short yy_reduce_ofst[] = {
- /*     0 */  -125,  733,  789,  241,  293, -123, -193, -191, -183, -187,
- /*    10 */   166,  238,  133, -207, -199, -267, -176,   -6,  204,  489,
- /*    20 */   576,  598, -175,  686,  860,  615,  725, 1014,  778,  781,
- /*    30 */   857,  616,  887,   87,  240, -192,  408,  626,  796,  843,
- /*    40 */   854, 1004, -271, -271, -271, -271, -271, -271, -271, -271,
- /*    50 */  -271, -271, -271, -271, -271, -271, -271, -271, -271, -271,
- /*    60 */  -271, -271, -271, -271, -271, -271, -271, -271, -271, -271,
- /*    70 */  -271, -271, -271, -271, -271, -271, -271, -271, -271,   80,
- /*    80 */    83,  313,  886,  888,  918,  938, 1021, 1034, 1036, 1141,
- /*    90 */  1159, 1163, 1166, 1168, 1170, 1176, 1178, 1180, 1184, 1196,
- /*   100 */  1198, 1205, 1215, 1225, 1227, 1236, 1252, 1254, 1264, 1303,
- /*   110 */  1309, 1312, 1322, 1325, 1328, 1337, 1340, 1343, 1353, 1371,
- /*   120 */  1373, 1384, 1386, 1411, 1413, 1420, 1424, 1426, 1458, 1470,
- /*   130 */  1473, -271, -271, -271, -271, -271, -271, -271, -271, -271,
- /*   140 */  -271, -271,  138,  459,  396, -158,  470,  302, -212,  521,
- /*   150 */   201, -195,  -92,  559,  630,  632,  630, -271,  632,  901,
- /*   160 */    63,  407,  670, -271, -271, -271, -271,  161,  161,  161,
- /*   170 */   251,  335,  847,  979, 1097,  537,  588,  618,  628,  688,
- /*   180 */   688, -166, -161,  674,  787,  794,  799,  852,  996, -122,
- /*   190 */   837, -120, 1018, 1035,  415, 1047, 1001,  958, 1082,  400,
- /*   200 */  1099,  779, 1137, 1142,  263, 1083, 1145, 1150, 1041, 1139,
- /*   210 */   965, 1050,  362,  849,  752,  629,  675, 1162, 1173, 1090,
- /*   220 */  1195, -194,   56,  185, -135,  232,  522,  560,  571,  601,
- /*   230 */   617,  669,  683,  711,  850,  893, 1000, 1040, 1049, 1081,
- /*   240 */  1087, 1101,  392, 1114, 1123, 1155, 1161, 1175, 1271, 1293,
- /*   250 */  1299, 1330, 1339, 1342, 1347,  593, 1282, 1286, 1350, 1359,
- /*   260 */  1368, 1314, 1480, 1483, 1507, 1085, 1338, 1526, 1527, 1487,
- /*   270 */  1531,  560, 1532, 1534, 1535, 1538, 1539, 1541, 1448, 1450,
- /*   280 */  1496, 1484, 1485, 1489, 1490, 1314, 1496, 1496, 1504, 1536,
- /*   290 */  1564, 1451, 1486, 1492, 1509, 1493, 1465, 1515, 1494, 1495,
- /*   300 */  1517, 1500, 1519, 1474, 1550, 1543, 1548, 1556, 1565, 1566,
- /*   310 */  1518, 1523, 1542, 1544, 1525, 1545, 1513, 1553, 1552, 1604,
- /*   320 */  1508, 1510, 1608, 1609, 1520, 1528, 1612, 1540, 1559, 1560,
- /*   330 */  1592, 1591, 1595, 1596, 1597, 1629, 1638, 1594, 1569, 1570,
- /*   340 */  1600, 1568, 1610, 1601, 1611, 1603, 1643, 1651, 1562, 1571,
- /*   350 */  1655, 1659, 1640, 1663, 1666, 1664, 1667, 1641, 1650, 1652,
- /*   360 */  1653, 1647, 1656, 1657, 1658, 1668, 1672, 1681, 1649, 1682,
- /*   370 */  1683, 1573, 1582, 1607, 1615, 1685, 1702, 1586, 1587, 1642,
- /*   380 */  1646, 1673, 1675, 1636, 1714, 1637, 1677, 1674, 1678, 1694,
- /*   390 */  1719, 1734, 1735, 1746, 1747, 1750, 1633, 1661, 1686, 1738,
- /*   400 */  1728, 1733, 1736, 1737, 1740, 1726, 1730, 1742, 1743, 1748,
- /*   410 */  1753,
+ /*     0 */   -71,  194,  343,  835, -180, -177,  838, -194, -188, -185,
+ /*    10 */  -183,   82,  183,  -65,  133,  245,  346,  407,  458, -178,
+ /*    20 */    75, -275,   -4,  310,  312,  489,  575,  596,  463,  686,
+ /*    30 */   707,  725,  780, 1098,  856,  778, 1059, 1090,  708,  887,
+ /*    40 */    86,  448,  980,  630,  680,  681,  684,  796,  801,  796,
+ /*    50 */   801, -261, -261, -261, -261, -261, -261, -261, -261, -261,
+ /*    60 */  -261, -261, -261, -261, -261, -261, -261, -261, -261, -261,
+ /*    70 */  -261, -261, -261, -261, -261, -261, -261, -261, -261, -261,
+ /*    80 */  -261, -261, -261, -261, -261, -261, -261, -261,  391,  886,
+ /*    90 */   888, 1013, 1016, 1081, 1087, 1151, 1159, 1177, 1185, 1188,
+ /*   100 */  1190, 1194, 1197, 1203, 1247, 1260, 1264, 1267, 1269, 1273,
+ /*   110 */  1315, 1322, 1335, 1337, 1356, 1362, 1418, 1425, 1453, 1457,
+ /*   120 */  1465, 1473, 1487, 1495, 1507, 1517, 1521, 1534, 1543, 1546,
+ /*   130 */  1549, 1552, 1554, 1560, 1581, 1590, 1593, 1595, 1621, 1623,
+ /*   140 */  -261, -261, -261, -261, -261, -261, -261, -261, -261, -261,
+ /*   150 */  -261, -186, -117,  260,  263,  460,  631,  -74,  497, -181,
+ /*   160 */  -261,  939,  176,  274,  338,  676, -261, -261, -261, -261,
+ /*   170 */  -212, -212, -212, -184,  149,  777, 1061, 1103,  265,  419,
+ /*   180 */  -254,  670,  677,  677,  -11, -129,  184,  488,  736,  789,
+ /*   190 */   805,  844,  403,  529,  579,  668,  783,  841, 1158, 1112,
+ /*   200 */   806,  861, 1095,  846,  839, 1031, -189, 1077, 1080, 1116,
+ /*   210 */  1084, 1156, 1139, 1221,   46, 1099, 1037, 1118, 1171, 1214,
+ /*   220 */  1210, 1258, -210, -190, -176, -115,  117,  262,  376,  490,
+ /*   230 */   511,  520,  618,  639,  743,  901,  907,  958, 1014, 1055,
+ /*   240 */  1108, 1193, 1244,  720, 1248, 1277, 1324, 1347, 1417, 1431,
+ /*   250 */  1432, 1440, 1451, 1452, 1463, 1478, 1286, 1350, 1369, 1490,
+ /*   260 */  1498, 1501,  773, 1509, 1513, 1528, 1292, 1367, 1535, 1536,
+ /*   270 */  1477, 1542,  376, 1547, 1550, 1555, 1559, 1568, 1571, 1441,
+ /*   280 */  1443, 1474, 1511, 1516, 1519, 1522,  773, 1474, 1474, 1503,
+ /*   290 */  1567, 1594, 1484, 1527, 1556, 1570, 1557, 1524, 1573, 1545,
+ /*   300 */  1548, 1576, 1561, 1587, 1540, 1575, 1606, 1611, 1622, 1624,
+ /*   310 */  1626, 1582, 1597, 1598, 1599, 1601, 1603, 1563, 1608, 1605,
+ /*   320 */  1604, 1564, 1566, 1655, 1660, 1578, 1579, 1665, 1586, 1607,
+ /*   330 */  1610, 1642, 1641, 1645, 1646, 1647, 1679, 1688, 1644, 1618,
+ /*   340 */  1619, 1648, 1628, 1659, 1649, 1663, 1650, 1700, 1702, 1612,
+ /*   350 */  1615, 1706, 1708, 1689, 1709, 1712, 1713, 1715, 1691, 1698,
+ /*   360 */  1699, 1701, 1693, 1704, 1707, 1705, 1714, 1703, 1718, 1710,
+ /*   370 */  1720, 1721, 1632, 1634, 1664, 1666, 1729, 1751, 1635, 1636,
+ /*   380 */  1692, 1694, 1716, 1722, 1684, 1763, 1685, 1723, 1724, 1727,
+ /*   390 */  1730, 1768, 1783, 1784, 1793, 1794, 1796, 1683, 1686, 1690,
+ /*   400 */  1782, 1779, 1780, 1781, 1785, 1788, 1774, 1775, 1786, 1787,
+ /*   410 */  1789, 1798,
 };
 static const YYACTIONTYPE yy_default[] = {
- /*     0 */  1648, 1648, 1648, 1478, 1243, 1354, 1243, 1243, 1243, 1478,
- /*    10 */  1478, 1478, 1243, 1384, 1384, 1531, 1276, 1243, 1243, 1243,
- /*    20 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1477, 1243,
- /*    30 */  1243, 1243, 1243, 1564, 1564, 1243, 1243, 1243, 1243, 1243,
- /*    40 */  1243, 1243, 1243, 1393, 1243, 1400, 1243, 1243, 1243, 1243,
- /*    50 */  1243, 1479, 1480, 1243, 1243, 1243, 1530, 1532, 1495, 1407,
- /*    60 */  1406, 1405, 1404, 1513, 1372, 1398, 1391, 1395, 1474, 1475,
- /*    70 */  1473, 1626, 1480, 1479, 1243, 1394, 1442, 1458, 1441, 1243,
- /*    80 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
- /*    90 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
- /*   100 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
- /*   110 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
- /*   120 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
- /*   130 */  1243, 1450, 1457, 1456, 1455, 1464, 1454, 1451, 1444, 1443,
- /*   140 */  1445, 1446, 1243, 1243, 1267, 1243, 1243, 1264, 1318, 1243,
- /*   150 */  1243, 1243, 1243, 1243, 1550, 1549, 1243, 1447, 1243, 1276,
- /*   160 */  1435, 1434, 1433, 1461, 1448, 1460, 1459, 1538, 1600, 1599,
- /*   170 */  1496, 1243, 1243, 1243, 1243, 1243, 1243, 1564, 1243, 1243,
- /*   180 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
- /*   190 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
- /*   200 */  1243, 1374, 1564, 1564, 1243, 1276, 1564, 1564, 1375, 1375,
- /*   210 */  1272, 1272, 1378, 1243, 1545, 1345, 1345, 1345, 1345, 1354,
- /*   220 */  1345, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
- /*   230 */  1243, 1243, 1243, 1243, 1243, 1243, 1535, 1533, 1243, 1243,
- /*   240 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
- /*   250 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
- /*   260 */  1243, 1243, 1243, 1243, 1243, 1350, 1243, 1243, 1243, 1243,
- /*   270 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1593, 1243, 1508,
- /*   280 */  1332, 1350, 1350, 1350, 1350, 1352, 1333, 1331, 1344, 1277,
- /*   290 */  1250, 1640, 1410, 1399, 1351, 1399, 1637, 1397, 1410, 1410,
- /*   300 */  1397, 1410, 1351, 1637, 1293, 1615, 1288, 1384, 1384, 1384,
- /*   310 */  1374, 1374, 1374, 1374, 1378, 1378, 1476, 1351, 1344, 1243,
- /*   320 */  1640, 1640, 1360, 1360, 1639, 1639, 1360, 1496, 1623, 1419,
- /*   330 */  1321, 1327, 1327, 1327, 1327, 1360, 1261, 1397, 1623, 1623,
- /*   340 */  1397, 1419, 1321, 1397, 1321, 1397, 1360, 1261, 1512, 1634,
- /*   350 */  1360, 1261, 1486, 1360, 1261, 1360, 1261, 1486, 1319, 1319,
- /*   360 */  1319, 1308, 1243, 1243, 1486, 1319, 1293, 1319, 1308, 1319,
- /*   370 */  1319, 1582, 1243, 1490, 1490, 1486, 1360, 1574, 1574, 1387,
- /*   380 */  1387, 1392, 1378, 1481, 1360, 1243, 1392, 1390, 1388, 1397,
- /*   390 */  1311, 1596, 1596, 1592, 1592, 1592, 1645, 1645, 1545, 1608,
- /*   400 */  1276, 1276, 1276, 1276, 1608, 1295, 1295, 1277, 1277, 1276,
- /*   410 */  1608, 1243, 1243, 1243, 1243, 1243, 1243, 1603, 1243, 1540,
- /*   420 */  1497, 1364, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
- /*   430 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1551, 1243,
- /*   440 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1424,
- /*   450 */  1243, 1246, 1542, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
- /*   460 */  1243, 1401, 1402, 1365, 1243, 1243, 1243, 1243, 1243, 1243,
- /*   470 */  1243, 1416, 1243, 1243, 1243, 1411, 1243, 1243, 1243, 1243,
- /*   480 */  1243, 1243, 1243, 1243, 1636, 1243, 1243, 1243, 1243, 1243,
- /*   490 */  1243, 1511, 1510, 1243, 1243, 1362, 1243, 1243, 1243, 1243,
- /*   500 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1291,
- /*   510 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
- /*   520 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243,
- /*   530 */  1243, 1243, 1243, 1389, 1243, 1243, 1243, 1243, 1243, 1243,
- /*   540 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1579, 1379,
- /*   550 */  1243, 1243, 1243, 1243, 1627, 1243, 1243, 1243, 1243, 1243,
- /*   560 */  1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1619,
- /*   570 */  1335, 1425, 1243, 1428, 1265, 1243, 1255, 1243, 1243,
+ /*     0 */  1663, 1663, 1663, 1491, 1254, 1367, 1254, 1254, 1254, 1254,
+ /*    10 */  1491, 1491, 1491, 1254, 1254, 1254, 1254, 1254, 1254, 1397,
+ /*    20 */  1397, 1544, 1287, 1254, 1254, 1254, 1254, 1254, 1254, 1254,
+ /*    30 */  1254, 1254, 1254, 1254, 1254, 1490, 1254, 1254, 1254, 1254,
+ /*    40 */  1578, 1578, 1254, 1254, 1254, 1254, 1254, 1563, 1562, 1254,
+ /*    50 */  1254, 1254, 1406, 1254, 1413, 1254, 1254, 1254, 1254, 1254,
+ /*    60 */  1492, 1493, 1254, 1254, 1254, 1543, 1545, 1508, 1420, 1419,
+ /*    70 */  1418, 1417, 1526, 1385, 1411, 1404, 1408, 1487, 1488, 1486,
+ /*    80 */  1641, 1493, 1492, 1254, 1407, 1455, 1471, 1454, 1254, 1254,
+ /*    90 */  1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254,
+ /*   100 */  1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254,
+ /*   110 */  1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254,
+ /*   120 */  1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254,
+ /*   130 */  1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254,
+ /*   140 */  1463, 1470, 1469, 1468, 1477, 1467, 1464, 1457, 1456, 1458,
+ /*   150 */  1459, 1278, 1254, 1275, 1329, 1254, 1254, 1254, 1254, 1254,
+ /*   160 */  1460, 1287, 1448, 1447, 1446, 1254, 1474, 1461, 1473, 1472,
+ /*   170 */  1551, 1615, 1614, 1509, 1254, 1254, 1254, 1254, 1254, 1254,
+ /*   180 */  1578, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254,
+ /*   190 */  1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254,
+ /*   200 */  1254, 1254, 1254, 1387, 1578, 1578, 1254, 1287, 1578, 1578,
+ /*   210 */  1388, 1388, 1283, 1283, 1391, 1558, 1358, 1358, 1358, 1358,
+ /*   220 */  1367, 1358, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254,
+ /*   230 */  1254, 1254, 1254, 1254, 1254, 1254, 1254, 1548, 1546, 1254,
+ /*   240 */  1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254,
+ /*   250 */  1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254,
+ /*   260 */  1254, 1254, 1254, 1254, 1254, 1254, 1363, 1254, 1254, 1254,
+ /*   270 */  1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1608, 1254,
+ /*   280 */  1521, 1343, 1363, 1363, 1363, 1363, 1365, 1344, 1342, 1357,
+ /*   290 */  1288, 1261, 1655, 1423, 1412, 1364, 1412, 1652, 1410, 1423,
+ /*   300 */  1423, 1410, 1423, 1364, 1652, 1304, 1630, 1299, 1397, 1397,
+ /*   310 */  1397, 1387, 1387, 1387, 1387, 1391, 1391, 1489, 1364, 1357,
+ /*   320 */  1254, 1655, 1655, 1373, 1373, 1654, 1654, 1373, 1509, 1638,
+ /*   330 */  1432, 1332, 1338, 1338, 1338, 1338, 1373, 1272, 1410, 1638,
+ /*   340 */  1638, 1410, 1432, 1332, 1410, 1332, 1410, 1373, 1272, 1525,
+ /*   350 */  1649, 1373, 1272, 1499, 1373, 1272, 1373, 1272, 1499, 1330,
+ /*   360 */  1330, 1330, 1319, 1254, 1254, 1499, 1330, 1304, 1330, 1319,
+ /*   370 */  1330, 1330, 1596, 1254, 1503, 1503, 1499, 1373, 1588, 1588,
+ /*   380 */  1400, 1400, 1405, 1391, 1494, 1373, 1254, 1405, 1403, 1401,
+ /*   390 */  1410, 1322, 1611, 1611, 1607, 1607, 1607, 1660, 1660, 1558,
+ /*   400 */  1623, 1287, 1287, 1287, 1287, 1623, 1306, 1306, 1288, 1288,
+ /*   410 */  1287, 1623, 1254, 1254, 1254, 1254, 1254, 1254, 1618, 1254,
+ /*   420 */  1553, 1510, 1377, 1254, 1254, 1254, 1254, 1254, 1254, 1254,
+ /*   430 */  1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1564,
+ /*   440 */  1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254,
+ /*   450 */  1254, 1437, 1254, 1257, 1555, 1254, 1254, 1254, 1254, 1254,
+ /*   460 */  1254, 1254, 1254, 1414, 1415, 1378, 1254, 1254, 1254, 1254,
+ /*   470 */  1254, 1254, 1254, 1429, 1254, 1254, 1254, 1424, 1254, 1254,
+ /*   480 */  1254, 1254, 1254, 1254, 1254, 1254, 1651, 1254, 1254, 1254,
+ /*   490 */  1254, 1254, 1254, 1524, 1523, 1254, 1254, 1375, 1254, 1254,
+ /*   500 */  1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254,
+ /*   510 */  1254, 1302, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254,
+ /*   520 */  1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254,
+ /*   530 */  1254, 1254, 1254, 1254, 1254, 1402, 1254, 1254, 1254, 1254,
+ /*   540 */  1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254,
+ /*   550 */  1593, 1392, 1254, 1254, 1254, 1254, 1642, 1254, 1254, 1254,
+ /*   560 */  1254, 1352, 1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254,
+ /*   570 */  1254, 1254, 1254, 1634, 1346, 1438, 1254, 1441, 1276, 1254,
+ /*   580 */  1266, 1254, 1254,
 };
 /********** End of lemon-generated parsing tables *****************************/
 
@@ -172301,8 +173902,8 @@ static const YYCODETYPE yyFallback[] = {
     0,  /*  TRUEFALSE => nothing */
     0,  /*      ISNOT => nothing */
     0,  /*   FUNCTION => nothing */
-    0,  /*     UMINUS => nothing */
     0,  /*      UPLUS => nothing */
+    0,  /*     UMINUS => nothing */
     0,  /*      TRUTH => nothing */
     0,  /*   REGISTER => nothing */
     0,  /*     VECTOR => nothing */
@@ -172311,6 +173912,7 @@ static const YYCODETYPE yyFallback[] = {
     0,  /*   ASTERISK => nothing */
     0,  /*       SPAN => nothing */
     0,  /*      ERROR => nothing */
+    0,  /*    QNUMBER => nothing */
     0,  /*      SPACE => nothing */
     0,  /*    ILLEGAL => nothing */
 };
@@ -172353,14 +173955,9 @@ struct yyParser {
 #endif
   sqlite3ParserARG_SDECL                /* A place to hold %extra_argument */
   sqlite3ParserCTX_SDECL                /* A place to hold %extra_context */
-#if YYSTACKDEPTH<=0
-  int yystksz;                  /* Current side of the stack */
-  yyStackEntry *yystack;        /* The parser's stack */
-  yyStackEntry yystk0;          /* First stack entry */
-#else
-  yyStackEntry yystack[YYSTACKDEPTH];  /* The parser's stack */
-  yyStackEntry *yystackEnd;            /* Last entry in the stack */
-#endif
+  yyStackEntry *yystackEnd;           /* Last entry in the stack */
+  yyStackEntry *yystack;              /* The parser stack */
+  yyStackEntry yystk0[YYSTACKDEPTH];  /* Initial stack space */
 };
 typedef struct yyParser yyParser;
 
@@ -172574,8 +174171,8 @@ static const char *const yyTokenName[] = {
   /*  170 */ "TRUEFALSE",
   /*  171 */ "ISNOT",
   /*  172 */ "FUNCTION",
-  /*  173 */ "UMINUS",
-  /*  174 */ "UPLUS",
+  /*  173 */ "UPLUS",
+  /*  174 */ "UMINUS",
   /*  175 */ "TRUTH",
   /*  176 */ "REGISTER",
   /*  177 */ "VECTOR",
@@ -172584,142 +174181,145 @@ static const char *const yyTokenName[] = {
   /*  180 */ "ASTERISK",
   /*  181 */ "SPAN",
   /*  182 */ "ERROR",
-  /*  183 */ "SPACE",
-  /*  184 */ "ILLEGAL",
-  /*  185 */ "input",
-  /*  186 */ "cmdlist",
-  /*  187 */ "ecmd",
-  /*  188 */ "cmdx",
-  /*  189 */ "explain",
-  /*  190 */ "cmd",
-  /*  191 */ "transtype",
-  /*  192 */ "trans_opt",
-  /*  193 */ "nm",
-  /*  194 */ "savepoint_opt",
-  /*  195 */ "create_table",
-  /*  196 */ "create_table_args",
-  /*  197 */ "createkw",
-  /*  198 */ "temp",
-  /*  199 */ "ifnotexists",
-  /*  200 */ "dbnm",
-  /*  201 */ "columnlist",
-  /*  202 */ "conslist_opt",
-  /*  203 */ "table_option_set",
-  /*  204 */ "select",
-  /*  205 */ "table_option",
-  /*  206 */ "columnname",
-  /*  207 */ "carglist",
-  /*  208 */ "typetoken",
-  /*  209 */ "typename",
-  /*  210 */ "signed",
-  /*  211 */ "plus_num",
-  /*  212 */ "minus_num",
-  /*  213 */ "scanpt",
-  /*  214 */ "scantok",
-  /*  215 */ "ccons",
-  /*  216 */ "term",
-  /*  217 */ "expr",
-  /*  218 */ "onconf",
-  /*  219 */ "sortorder",
-  /*  220 */ "autoinc",
-  /*  221 */ "eidlist_opt",
-  /*  222 */ "refargs",
-  /*  223 */ "defer_subclause",
-  /*  224 */ "generated",
-  /*  225 */ "refarg",
-  /*  226 */ "refact",
-  /*  227 */ "init_deferred_pred_opt",
-  /*  228 */ "conslist",
-  /*  229 */ "tconscomma",
-  /*  230 */ "tcons",
-  /*  231 */ "sortlist",
-  /*  232 */ "eidlist",
-  /*  233 */ "defer_subclause_opt",
-  /*  234 */ "orconf",
-  /*  235 */ "resolvetype",
-  /*  236 */ "raisetype",
-  /*  237 */ "ifexists",
-  /*  238 */ "fullname",
-  /*  239 */ "selectnowith",
-  /*  240 */ "oneselect",
-  /*  241 */ "wqlist",
-  /*  242 */ "multiselect_op",
-  /*  243 */ "distinct",
-  /*  244 */ "selcollist",
-  /*  245 */ "from",
-  /*  246 */ "where_opt",
-  /*  247 */ "groupby_opt",
-  /*  248 */ "having_opt",
-  /*  249 */ "orderby_opt",
-  /*  250 */ "limit_opt",
-  /*  251 */ "window_clause",
-  /*  252 */ "values",
-  /*  253 */ "nexprlist",
-  /*  254 */ "sclp",
-  /*  255 */ "as",
-  /*  256 */ "seltablist",
-  /*  257 */ "stl_prefix",
-  /*  258 */ "joinop",
-  /*  259 */ "on_using",
-  /*  260 */ "indexed_by",
-  /*  261 */ "exprlist",
-  /*  262 */ "xfullname",
-  /*  263 */ "idlist",
-  /*  264 */ "indexed_opt",
-  /*  265 */ "nulls",
-  /*  266 */ "with",
-  /*  267 */ "where_opt_ret",
-  /*  268 */ "setlist",
-  /*  269 */ "insert_cmd",
-  /*  270 */ "idlist_opt",
-  /*  271 */ "upsert",
-  /*  272 */ "returning",
-  /*  273 */ "filter_over",
-  /*  274 */ "likeop",
-  /*  275 */ "between_op",
-  /*  276 */ "in_op",
-  /*  277 */ "paren_exprlist",
-  /*  278 */ "case_operand",
-  /*  279 */ "case_exprlist",
-  /*  280 */ "case_else",
-  /*  281 */ "uniqueflag",
-  /*  282 */ "collate",
-  /*  283 */ "vinto",
-  /*  284 */ "nmnum",
-  /*  285 */ "trigger_decl",
-  /*  286 */ "trigger_cmd_list",
-  /*  287 */ "trigger_time",
-  /*  288 */ "trigger_event",
-  /*  289 */ "foreach_clause",
-  /*  290 */ "when_clause",
-  /*  291 */ "trigger_cmd",
-  /*  292 */ "trnm",
-  /*  293 */ "tridxby",
-  /*  294 */ "database_kw_opt",
-  /*  295 */ "key_opt",
-  /*  296 */ "add_column_fullname",
-  /*  297 */ "kwcolumn_opt",
-  /*  298 */ "create_vtab",
-  /*  299 */ "vtabarglist",
-  /*  300 */ "vtabarg",
-  /*  301 */ "vtabargtoken",
-  /*  302 */ "lp",
-  /*  303 */ "anylist",
-  /*  304 */ "wqitem",
-  /*  305 */ "wqas",
-  /*  306 */ "windowdefn_list",
-  /*  307 */ "windowdefn",
-  /*  308 */ "window",
-  /*  309 */ "frame_opt",
-  /*  310 */ "part_opt",
-  /*  311 */ "filter_clause",
-  /*  312 */ "over_clause",
-  /*  313 */ "range_or_rows",
-  /*  314 */ "frame_bound",
-  /*  315 */ "frame_bound_s",
-  /*  316 */ "frame_bound_e",
-  /*  317 */ "frame_exclude_opt",
-  /*  318 */ "frame_exclude",
+  /*  183 */ "QNUMBER",
+  /*  184 */ "SPACE",
+  /*  185 */ "ILLEGAL",
+  /*  186 */ "input",
+  /*  187 */ "cmdlist",
+  /*  188 */ "ecmd",
+  /*  189 */ "cmdx",
+  /*  190 */ "explain",
+  /*  191 */ "cmd",
+  /*  192 */ "transtype",
+  /*  193 */ "trans_opt",
+  /*  194 */ "nm",
+  /*  195 */ "savepoint_opt",
+  /*  196 */ "create_table",
+  /*  197 */ "create_table_args",
+  /*  198 */ "createkw",
+  /*  199 */ "temp",
+  /*  200 */ "ifnotexists",
+  /*  201 */ "dbnm",
+  /*  202 */ "columnlist",
+  /*  203 */ "conslist_opt",
+  /*  204 */ "table_option_set",
+  /*  205 */ "select",
+  /*  206 */ "table_option",
+  /*  207 */ "columnname",
+  /*  208 */ "carglist",
+  /*  209 */ "typetoken",
+  /*  210 */ "typename",
+  /*  211 */ "signed",
+  /*  212 */ "plus_num",
+  /*  213 */ "minus_num",
+  /*  214 */ "scanpt",
+  /*  215 */ "scantok",
+  /*  216 */ "ccons",
+  /*  217 */ "term",
+  /*  218 */ "expr",
+  /*  219 */ "onconf",
+  /*  220 */ "sortorder",
+  /*  221 */ "autoinc",
+  /*  222 */ "eidlist_opt",
+  /*  223 */ "refargs",
+  /*  224 */ "defer_subclause",
+  /*  225 */ "generated",
+  /*  226 */ "refarg",
+  /*  227 */ "refact",
+  /*  228 */ "init_deferred_pred_opt",
+  /*  229 */ "conslist",
+  /*  230 */ "tconscomma",
+  /*  231 */ "tcons",
+  /*  232 */ "sortlist",
+  /*  233 */ "eidlist",
+  /*  234 */ "defer_subclause_opt",
+  /*  235 */ "orconf",
+  /*  236 */ "resolvetype",
+  /*  237 */ "raisetype",
+  /*  238 */ "ifexists",
+  /*  239 */ "fullname",
+  /*  240 */ "selectnowith",
+  /*  241 */ "oneselect",
+  /*  242 */ "wqlist",
+  /*  243 */ "multiselect_op",
+  /*  244 */ "distinct",
+  /*  245 */ "selcollist",
+  /*  246 */ "from",
+  /*  247 */ "where_opt",
+  /*  248 */ "groupby_opt",
+  /*  249 */ "having_opt",
+  /*  250 */ "orderby_opt",
+  /*  251 */ "limit_opt",
+  /*  252 */ "window_clause",
+  /*  253 */ "values",
+  /*  254 */ "nexprlist",
+  /*  255 */ "mvalues",
+  /*  256 */ "sclp",
+  /*  257 */ "as",
+  /*  258 */ "seltablist",
+  /*  259 */ "stl_prefix",
+  /*  260 */ "joinop",
+  /*  261 */ "on_using",
+  /*  262 */ "indexed_by",
+  /*  263 */ "exprlist",
+  /*  264 */ "xfullname",
+  /*  265 */ "idlist",
+  /*  266 */ "indexed_opt",
+  /*  267 */ "nulls",
+  /*  268 */ "with",
+  /*  269 */ "where_opt_ret",
+  /*  270 */ "setlist",
+  /*  271 */ "insert_cmd",
+  /*  272 */ "idlist_opt",
+  /*  273 */ "upsert",
+  /*  274 */ "returning",
+  /*  275 */ "filter_over",
+  /*  276 */ "likeop",
+  /*  277 */ "between_op",
+  /*  278 */ "in_op",
+  /*  279 */ "paren_exprlist",
+  /*  280 */ "case_operand",
+  /*  281 */ "case_exprlist",
+  /*  282 */ "case_else",
+  /*  283 */ "uniqueflag",
+  /*  284 */ "collate",
+  /*  285 */ "vinto",
+  /*  286 */ "nmnum",
+  /*  287 */ "trigger_decl",
+  /*  288 */ "trigger_cmd_list",
+  /*  289 */ "trigger_time",
+  /*  290 */ "trigger_event",
+  /*  291 */ "foreach_clause",
+  /*  292 */ "when_clause",
+  /*  293 */ "trigger_cmd",
+  /*  294 */ "trnm",
+  /*  295 */ "tridxby",
+  /*  296 */ "database_kw_opt",
+  /*  297 */ "key_opt",
+  /*  298 */ "add_column_fullname",
+  /*  299 */ "kwcolumn_opt",
+  /*  300 */ "create_vtab",
+  /*  301 */ "vtabarglist",
+  /*  302 */ "vtabarg",
+  /*  303 */ "vtabargtoken",
+  /*  304 */ "lp",
+  /*  305 */ "anylist",
+  /*  306 */ "wqitem",
+  /*  307 */ "wqas",
+  /*  308 */ "withnm",
+  /*  309 */ "windowdefn_list",
+  /*  310 */ "windowdefn",
+  /*  311 */ "window",
+  /*  312 */ "frame_opt",
+  /*  313 */ "part_opt",
+  /*  314 */ "filter_clause",
+  /*  315 */ "over_clause",
+  /*  316 */ "range_or_rows",
+  /*  317 */ "frame_bound",
+  /*  318 */ "frame_bound_s",
+  /*  319 */ "frame_bound_e",
+  /*  320 */ "frame_exclude_opt",
+  /*  321 */ "frame_exclude",
 };
 #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
 
@@ -172822,351 +174422,363 @@ static const char *const yyRuleName[] = {
  /*  92 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt",
  /*  93 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt",
  /*  94 */ "values ::= VALUES LP nexprlist RP",
- /*  95 */ "values ::= values COMMA LP nexprlist RP",
- /*  96 */ "distinct ::= DISTINCT",
- /*  97 */ "distinct ::= ALL",
- /*  98 */ "distinct ::=",
- /*  99 */ "sclp ::=",
- /* 100 */ "selcollist ::= sclp scanpt expr scanpt as",
- /* 101 */ "selcollist ::= sclp scanpt STAR",
- /* 102 */ "selcollist ::= sclp scanpt nm DOT STAR",
- /* 103 */ "as ::= AS nm",
- /* 104 */ "as ::=",
- /* 105 */ "from ::=",
- /* 106 */ "from ::= FROM seltablist",
- /* 107 */ "stl_prefix ::= seltablist joinop",
- /* 108 */ "stl_prefix ::=",
- /* 109 */ "seltablist ::= stl_prefix nm dbnm as on_using",
- /* 110 */ "seltablist ::= stl_prefix nm dbnm as indexed_by on_using",
- /* 111 */ "seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_using",
- /* 112 */ "seltablist ::= stl_prefix LP select RP as on_using",
- /* 113 */ "seltablist ::= stl_prefix LP seltablist RP as on_using",
- /* 114 */ "dbnm ::=",
- /* 115 */ "dbnm ::= DOT nm",
- /* 116 */ "fullname ::= nm",
- /* 117 */ "fullname ::= nm DOT nm",
- /* 118 */ "xfullname ::= nm",
- /* 119 */ "xfullname ::= nm DOT nm",
- /* 120 */ "xfullname ::= nm DOT nm AS nm",
- /* 121 */ "xfullname ::= nm AS nm",
- /* 122 */ "joinop ::= COMMA|JOIN",
- /* 123 */ "joinop ::= JOIN_KW JOIN",
- /* 124 */ "joinop ::= JOIN_KW nm JOIN",
- /* 125 */ "joinop ::= JOIN_KW nm nm JOIN",
- /* 126 */ "on_using ::= ON expr",
- /* 127 */ "on_using ::= USING LP idlist RP",
- /* 128 */ "on_using ::=",
- /* 129 */ "indexed_opt ::=",
- /* 130 */ "indexed_by ::= INDEXED BY nm",
- /* 131 */ "indexed_by ::= NOT INDEXED",
- /* 132 */ "orderby_opt ::=",
- /* 133 */ "orderby_opt ::= ORDER BY sortlist",
- /* 134 */ "sortlist ::= sortlist COMMA expr sortorder nulls",
- /* 135 */ "sortlist ::= expr sortorder nulls",
- /* 136 */ "sortorder ::= ASC",
- /* 137 */ "sortorder ::= DESC",
- /* 138 */ "sortorder ::=",
- /* 139 */ "nulls ::= NULLS FIRST",
- /* 140 */ "nulls ::= NULLS LAST",
- /* 141 */ "nulls ::=",
- /* 142 */ "groupby_opt ::=",
- /* 143 */ "groupby_opt ::= GROUP BY nexprlist",
- /* 144 */ "having_opt ::=",
- /* 145 */ "having_opt ::= HAVING expr",
- /* 146 */ "limit_opt ::=",
- /* 147 */ "limit_opt ::= LIMIT expr",
- /* 148 */ "limit_opt ::= LIMIT expr OFFSET expr",
- /* 149 */ "limit_opt ::= LIMIT expr COMMA expr",
- /* 150 */ "cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret",
- /* 151 */ "where_opt ::=",
- /* 152 */ "where_opt ::= WHERE expr",
- /* 153 */ "where_opt_ret ::=",
- /* 154 */ "where_opt_ret ::= WHERE expr",
- /* 155 */ "where_opt_ret ::= RETURNING selcollist",
- /* 156 */ "where_opt_ret ::= WHERE expr RETURNING selcollist",
- /* 157 */ "cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret",
- /* 158 */ "setlist ::= setlist COMMA nm EQ expr",
- /* 159 */ "setlist ::= setlist COMMA LP idlist RP EQ expr",
- /* 160 */ "setlist ::= nm EQ expr",
- /* 161 */ "setlist ::= LP idlist RP EQ expr",
- /* 162 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert",
- /* 163 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning",
- /* 164 */ "upsert ::=",
- /* 165 */ "upsert ::= RETURNING selcollist",
- /* 166 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert",
- /* 167 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert",
- /* 168 */ "upsert ::= ON CONFLICT DO NOTHING returning",
- /* 169 */ "upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning",
- /* 170 */ "returning ::= RETURNING selcollist",
- /* 171 */ "insert_cmd ::= INSERT orconf",
- /* 172 */ "insert_cmd ::= REPLACE",
- /* 173 */ "idlist_opt ::=",
- /* 174 */ "idlist_opt ::= LP idlist RP",
- /* 175 */ "idlist ::= idlist COMMA nm",
- /* 176 */ "idlist ::= nm",
- /* 177 */ "expr ::= LP expr RP",
- /* 178 */ "expr ::= ID|INDEXED|JOIN_KW",
- /* 179 */ "expr ::= nm DOT nm",
- /* 180 */ "expr ::= nm DOT nm DOT nm",
- /* 181 */ "term ::= NULL|FLOAT|BLOB",
- /* 182 */ "term ::= STRING",
- /* 183 */ "term ::= INTEGER",
- /* 184 */ "expr ::= VARIABLE",
- /* 185 */ "expr ::= expr COLLATE ID|STRING",
- /* 186 */ "expr ::= CAST LP expr AS typetoken RP",
- /* 187 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP",
- /* 188 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP",
- /* 189 */ "expr ::= ID|INDEXED|JOIN_KW LP STAR RP",
- /* 190 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over",
- /* 191 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over",
- /* 192 */ "expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over",
- /* 193 */ "term ::= CTIME_KW",
- /* 194 */ "expr ::= LP nexprlist COMMA expr RP",
- /* 195 */ "expr ::= expr AND expr",
- /* 196 */ "expr ::= expr OR expr",
- /* 197 */ "expr ::= expr LT|GT|GE|LE expr",
- /* 198 */ "expr ::= expr EQ|NE expr",
- /* 199 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
- /* 200 */ "expr ::= expr PLUS|MINUS expr",
- /* 201 */ "expr ::= expr STAR|SLASH|REM expr",
- /* 202 */ "expr ::= expr CONCAT expr",
- /* 203 */ "likeop ::= NOT LIKE_KW|MATCH",
- /* 204 */ "expr ::= expr likeop expr",
- /* 205 */ "expr ::= expr likeop expr ESCAPE expr",
- /* 206 */ "expr ::= expr ISNULL|NOTNULL",
- /* 207 */ "expr ::= expr NOT NULL",
- /* 208 */ "expr ::= expr IS expr",
- /* 209 */ "expr ::= expr IS NOT expr",
- /* 210 */ "expr ::= expr IS NOT DISTINCT FROM expr",
- /* 211 */ "expr ::= expr IS DISTINCT FROM expr",
- /* 212 */ "expr ::= NOT expr",
- /* 213 */ "expr ::= BITNOT expr",
- /* 214 */ "expr ::= PLUS|MINUS expr",
- /* 215 */ "expr ::= expr PTR expr",
- /* 216 */ "between_op ::= BETWEEN",
- /* 217 */ "between_op ::= NOT BETWEEN",
- /* 218 */ "expr ::= expr between_op expr AND expr",
- /* 219 */ "in_op ::= IN",
- /* 220 */ "in_op ::= NOT IN",
- /* 221 */ "expr ::= expr in_op LP exprlist RP",
- /* 222 */ "expr ::= LP select RP",
- /* 223 */ "expr ::= expr in_op LP select RP",
- /* 224 */ "expr ::= expr in_op nm dbnm paren_exprlist",
- /* 225 */ "expr ::= EXISTS LP select RP",
- /* 226 */ "expr ::= CASE case_operand case_exprlist case_else END",
- /* 227 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
- /* 228 */ "case_exprlist ::= WHEN expr THEN expr",
- /* 229 */ "case_else ::= ELSE expr",
- /* 230 */ "case_else ::=",
- /* 231 */ "case_operand ::=",
- /* 232 */ "exprlist ::=",
- /* 233 */ "nexprlist ::= nexprlist COMMA expr",
- /* 234 */ "nexprlist ::= expr",
- /* 235 */ "paren_exprlist ::=",
- /* 236 */ "paren_exprlist ::= LP exprlist RP",
- /* 237 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
- /* 238 */ "uniqueflag ::= UNIQUE",
- /* 239 */ "uniqueflag ::=",
- /* 240 */ "eidlist_opt ::=",
- /* 241 */ "eidlist_opt ::= LP eidlist RP",
- /* 242 */ "eidlist ::= eidlist COMMA nm collate sortorder",
- /* 243 */ "eidlist ::= nm collate sortorder",
- /* 244 */ "collate ::=",
- /* 245 */ "collate ::= COLLATE ID|STRING",
- /* 246 */ "cmd ::= DROP INDEX ifexists fullname",
- /* 247 */ "cmd ::= VACUUM vinto",
- /* 248 */ "cmd ::= VACUUM nm vinto",
- /* 249 */ "vinto ::= INTO expr",
- /* 250 */ "vinto ::=",
- /* 251 */ "cmd ::= PRAGMA nm dbnm",
- /* 252 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
- /* 253 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
- /* 254 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
- /* 255 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
- /* 256 */ "plus_num ::= PLUS INTEGER|FLOAT",
- /* 257 */ "minus_num ::= MINUS INTEGER|FLOAT",
- /* 258 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
- /* 259 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
- /* 260 */ "trigger_time ::= BEFORE|AFTER",
- /* 261 */ "trigger_time ::= INSTEAD OF",
- /* 262 */ "trigger_time ::=",
- /* 263 */ "trigger_event ::= DELETE|INSERT",
- /* 264 */ "trigger_event ::= UPDATE",
- /* 265 */ "trigger_event ::= UPDATE OF idlist",
- /* 266 */ "when_clause ::=",
- /* 267 */ "when_clause ::= WHEN expr",
- /* 268 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
- /* 269 */ "trigger_cmd_list ::= trigger_cmd SEMI",
- /* 270 */ "trnm ::= nm DOT nm",
- /* 271 */ "tridxby ::= INDEXED BY nm",
- /* 272 */ "tridxby ::= NOT INDEXED",
- /* 273 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt",
- /* 274 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt",
- /* 275 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt",
- /* 276 */ "trigger_cmd ::= scanpt select scanpt",
- /* 277 */ "expr ::= RAISE LP IGNORE RP",
- /* 278 */ "expr ::= RAISE LP raisetype COMMA nm RP",
- /* 279 */ "raisetype ::= ROLLBACK",
- /* 280 */ "raisetype ::= ABORT",
- /* 281 */ "raisetype ::= FAIL",
- /* 282 */ "cmd ::= DROP TRIGGER ifexists fullname",
- /* 283 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
- /* 284 */ "cmd ::= DETACH database_kw_opt expr",
- /* 285 */ "key_opt ::=",
- /* 286 */ "key_opt ::= KEY expr",
- /* 287 */ "cmd ::= REINDEX",
- /* 288 */ "cmd ::= REINDEX nm dbnm",
- /* 289 */ "cmd ::= ANALYZE",
- /* 290 */ "cmd ::= ANALYZE nm dbnm",
- /* 291 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
- /* 292 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
- /* 293 */ "cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm",
- /* 294 */ "add_column_fullname ::= fullname",
- /* 295 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm",
- /* 296 */ "cmd ::= create_vtab",
- /* 297 */ "cmd ::= create_vtab LP vtabarglist RP",
- /* 298 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
- /* 299 */ "vtabarg ::=",
- /* 300 */ "vtabargtoken ::= ANY",
- /* 301 */ "vtabargtoken ::= lp anylist RP",
- /* 302 */ "lp ::= LP",
- /* 303 */ "with ::= WITH wqlist",
- /* 304 */ "with ::= WITH RECURSIVE wqlist",
- /* 305 */ "wqas ::= AS",
- /* 306 */ "wqas ::= AS MATERIALIZED",
- /* 307 */ "wqas ::= AS NOT MATERIALIZED",
- /* 308 */ "wqitem ::= nm eidlist_opt wqas LP select RP",
- /* 309 */ "wqlist ::= wqitem",
- /* 310 */ "wqlist ::= wqlist COMMA wqitem",
- /* 311 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn",
- /* 312 */ "windowdefn ::= nm AS LP window RP",
- /* 313 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt",
- /* 314 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt",
- /* 315 */ "window ::= ORDER BY sortlist frame_opt",
- /* 316 */ "window ::= nm ORDER BY sortlist frame_opt",
- /* 317 */ "window ::= nm frame_opt",
- /* 318 */ "frame_opt ::=",
- /* 319 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt",
- /* 320 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt",
- /* 321 */ "range_or_rows ::= RANGE|ROWS|GROUPS",
- /* 322 */ "frame_bound_s ::= frame_bound",
- /* 323 */ "frame_bound_s ::= UNBOUNDED PRECEDING",
- /* 324 */ "frame_bound_e ::= frame_bound",
- /* 325 */ "frame_bound_e ::= UNBOUNDED FOLLOWING",
- /* 326 */ "frame_bound ::= expr PRECEDING|FOLLOWING",
- /* 327 */ "frame_bound ::= CURRENT ROW",
- /* 328 */ "frame_exclude_opt ::=",
- /* 329 */ "frame_exclude_opt ::= EXCLUDE frame_exclude",
- /* 330 */ "frame_exclude ::= NO OTHERS",
- /* 331 */ "frame_exclude ::= CURRENT ROW",
- /* 332 */ "frame_exclude ::= GROUP|TIES",
- /* 333 */ "window_clause ::= WINDOW windowdefn_list",
- /* 334 */ "filter_over ::= filter_clause over_clause",
- /* 335 */ "filter_over ::= over_clause",
- /* 336 */ "filter_over ::= filter_clause",
- /* 337 */ "over_clause ::= OVER LP window RP",
- /* 338 */ "over_clause ::= OVER nm",
- /* 339 */ "filter_clause ::= FILTER LP WHERE expr RP",
- /* 340 */ "input ::= cmdlist",
- /* 341 */ "cmdlist ::= cmdlist ecmd",
- /* 342 */ "cmdlist ::= ecmd",
- /* 343 */ "ecmd ::= SEMI",
- /* 344 */ "ecmd ::= cmdx SEMI",
- /* 345 */ "ecmd ::= explain cmdx SEMI",
- /* 346 */ "trans_opt ::=",
- /* 347 */ "trans_opt ::= TRANSACTION",
- /* 348 */ "trans_opt ::= TRANSACTION nm",
- /* 349 */ "savepoint_opt ::= SAVEPOINT",
- /* 350 */ "savepoint_opt ::=",
- /* 351 */ "cmd ::= create_table create_table_args",
- /* 352 */ "table_option_set ::= table_option",
- /* 353 */ "columnlist ::= columnlist COMMA columnname carglist",
- /* 354 */ "columnlist ::= columnname carglist",
- /* 355 */ "nm ::= ID|INDEXED|JOIN_KW",
- /* 356 */ "nm ::= STRING",
- /* 357 */ "typetoken ::= typename",
- /* 358 */ "typename ::= ID|STRING",
- /* 359 */ "signed ::= plus_num",
- /* 360 */ "signed ::= minus_num",
- /* 361 */ "carglist ::= carglist ccons",
- /* 362 */ "carglist ::=",
- /* 363 */ "ccons ::= NULL onconf",
- /* 364 */ "ccons ::= GENERATED ALWAYS AS generated",
- /* 365 */ "ccons ::= AS generated",
- /* 366 */ "conslist_opt ::= COMMA conslist",
- /* 367 */ "conslist ::= conslist tconscomma tcons",
- /* 368 */ "conslist ::= tcons",
- /* 369 */ "tconscomma ::=",
- /* 370 */ "defer_subclause_opt ::= defer_subclause",
- /* 371 */ "resolvetype ::= raisetype",
- /* 372 */ "selectnowith ::= oneselect",
- /* 373 */ "oneselect ::= values",
- /* 374 */ "sclp ::= selcollist COMMA",
- /* 375 */ "as ::= ID|STRING",
- /* 376 */ "indexed_opt ::= indexed_by",
- /* 377 */ "returning ::=",
- /* 378 */ "expr ::= term",
- /* 379 */ "likeop ::= LIKE_KW|MATCH",
- /* 380 */ "case_operand ::= expr",
- /* 381 */ "exprlist ::= nexprlist",
- /* 382 */ "nmnum ::= plus_num",
- /* 383 */ "nmnum ::= nm",
- /* 384 */ "nmnum ::= ON",
- /* 385 */ "nmnum ::= DELETE",
- /* 386 */ "nmnum ::= DEFAULT",
- /* 387 */ "plus_num ::= INTEGER|FLOAT",
- /* 388 */ "foreach_clause ::=",
- /* 389 */ "foreach_clause ::= FOR EACH ROW",
- /* 390 */ "trnm ::= nm",
- /* 391 */ "tridxby ::=",
- /* 392 */ "database_kw_opt ::= DATABASE",
- /* 393 */ "database_kw_opt ::=",
- /* 394 */ "kwcolumn_opt ::=",
- /* 395 */ "kwcolumn_opt ::= COLUMNKW",
- /* 396 */ "vtabarglist ::= vtabarg",
- /* 397 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
- /* 398 */ "vtabarg ::= vtabarg vtabargtoken",
- /* 399 */ "anylist ::=",
- /* 400 */ "anylist ::= anylist LP anylist RP",
- /* 401 */ "anylist ::= anylist ANY",
- /* 402 */ "with ::=",
- /* 403 */ "windowdefn_list ::= windowdefn",
- /* 404 */ "window ::= frame_opt",
+ /*  95 */ "oneselect ::= mvalues",
+ /*  96 */ "mvalues ::= values COMMA LP nexprlist RP",
+ /*  97 */ "mvalues ::= mvalues COMMA LP nexprlist RP",
+ /*  98 */ "distinct ::= DISTINCT",
+ /*  99 */ "distinct ::= ALL",
+ /* 100 */ "distinct ::=",
+ /* 101 */ "sclp ::=",
+ /* 102 */ "selcollist ::= sclp scanpt expr scanpt as",
+ /* 103 */ "selcollist ::= sclp scanpt STAR",
+ /* 104 */ "selcollist ::= sclp scanpt nm DOT STAR",
+ /* 105 */ "as ::= AS nm",
+ /* 106 */ "as ::=",
+ /* 107 */ "from ::=",
+ /* 108 */ "from ::= FROM seltablist",
+ /* 109 */ "stl_prefix ::= seltablist joinop",
+ /* 110 */ "stl_prefix ::=",
+ /* 111 */ "seltablist ::= stl_prefix nm dbnm as on_using",
+ /* 112 */ "seltablist ::= stl_prefix nm dbnm as indexed_by on_using",
+ /* 113 */ "seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_using",
+ /* 114 */ "seltablist ::= stl_prefix LP select RP as on_using",
+ /* 115 */ "seltablist ::= stl_prefix LP seltablist RP as on_using",
+ /* 116 */ "dbnm ::=",
+ /* 117 */ "dbnm ::= DOT nm",
+ /* 118 */ "fullname ::= nm",
+ /* 119 */ "fullname ::= nm DOT nm",
+ /* 120 */ "xfullname ::= nm",
+ /* 121 */ "xfullname ::= nm DOT nm",
+ /* 122 */ "xfullname ::= nm DOT nm AS nm",
+ /* 123 */ "xfullname ::= nm AS nm",
+ /* 124 */ "joinop ::= COMMA|JOIN",
+ /* 125 */ "joinop ::= JOIN_KW JOIN",
+ /* 126 */ "joinop ::= JOIN_KW nm JOIN",
+ /* 127 */ "joinop ::= JOIN_KW nm nm JOIN",
+ /* 128 */ "on_using ::= ON expr",
+ /* 129 */ "on_using ::= USING LP idlist RP",
+ /* 130 */ "on_using ::=",
+ /* 131 */ "indexed_opt ::=",
+ /* 132 */ "indexed_by ::= INDEXED BY nm",
+ /* 133 */ "indexed_by ::= NOT INDEXED",
+ /* 134 */ "orderby_opt ::=",
+ /* 135 */ "orderby_opt ::= ORDER BY sortlist",
+ /* 136 */ "sortlist ::= sortlist COMMA expr sortorder nulls",
+ /* 137 */ "sortlist ::= expr sortorder nulls",
+ /* 138 */ "sortorder ::= ASC",
+ /* 139 */ "sortorder ::= DESC",
+ /* 140 */ "sortorder ::=",
+ /* 141 */ "nulls ::= NULLS FIRST",
+ /* 142 */ "nulls ::= NULLS LAST",
+ /* 143 */ "nulls ::=",
+ /* 144 */ "groupby_opt ::=",
+ /* 145 */ "groupby_opt ::= GROUP BY nexprlist",
+ /* 146 */ "having_opt ::=",
+ /* 147 */ "having_opt ::= HAVING expr",
+ /* 148 */ "limit_opt ::=",
+ /* 149 */ "limit_opt ::= LIMIT expr",
+ /* 150 */ "limit_opt ::= LIMIT expr OFFSET expr",
+ /* 151 */ "limit_opt ::= LIMIT expr COMMA expr",
+ /* 152 */ "cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret",
+ /* 153 */ "where_opt ::=",
+ /* 154 */ "where_opt ::= WHERE expr",
+ /* 155 */ "where_opt_ret ::=",
+ /* 156 */ "where_opt_ret ::= WHERE expr",
+ /* 157 */ "where_opt_ret ::= RETURNING selcollist",
+ /* 158 */ "where_opt_ret ::= WHERE expr RETURNING selcollist",
+ /* 159 */ "cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret",
+ /* 160 */ "setlist ::= setlist COMMA nm EQ expr",
+ /* 161 */ "setlist ::= setlist COMMA LP idlist RP EQ expr",
+ /* 162 */ "setlist ::= nm EQ expr",
+ /* 163 */ "setlist ::= LP idlist RP EQ expr",
+ /* 164 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert",
+ /* 165 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning",
+ /* 166 */ "upsert ::=",
+ /* 167 */ "upsert ::= RETURNING selcollist",
+ /* 168 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert",
+ /* 169 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert",
+ /* 170 */ "upsert ::= ON CONFLICT DO NOTHING returning",
+ /* 171 */ "upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning",
+ /* 172 */ "returning ::= RETURNING selcollist",
+ /* 173 */ "insert_cmd ::= INSERT orconf",
+ /* 174 */ "insert_cmd ::= REPLACE",
+ /* 175 */ "idlist_opt ::=",
+ /* 176 */ "idlist_opt ::= LP idlist RP",
+ /* 177 */ "idlist ::= idlist COMMA nm",
+ /* 178 */ "idlist ::= nm",
+ /* 179 */ "expr ::= LP expr RP",
+ /* 180 */ "expr ::= ID|INDEXED|JOIN_KW",
+ /* 181 */ "expr ::= nm DOT nm",
+ /* 182 */ "expr ::= nm DOT nm DOT nm",
+ /* 183 */ "term ::= NULL|FLOAT|BLOB",
+ /* 184 */ "term ::= STRING",
+ /* 185 */ "term ::= INTEGER",
+ /* 186 */ "expr ::= VARIABLE",
+ /* 187 */ "expr ::= expr COLLATE ID|STRING",
+ /* 188 */ "expr ::= CAST LP expr AS typetoken RP",
+ /* 189 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP",
+ /* 190 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP",
+ /* 191 */ "expr ::= ID|INDEXED|JOIN_KW LP STAR RP",
+ /* 192 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over",
+ /* 193 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over",
+ /* 194 */ "expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over",
+ /* 195 */ "term ::= CTIME_KW",
+ /* 196 */ "expr ::= LP nexprlist COMMA expr RP",
+ /* 197 */ "expr ::= expr AND expr",
+ /* 198 */ "expr ::= expr OR expr",
+ /* 199 */ "expr ::= expr LT|GT|GE|LE expr",
+ /* 200 */ "expr ::= expr EQ|NE expr",
+ /* 201 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
+ /* 202 */ "expr ::= expr PLUS|MINUS expr",
+ /* 203 */ "expr ::= expr STAR|SLASH|REM expr",
+ /* 204 */ "expr ::= expr CONCAT expr",
+ /* 205 */ "likeop ::= NOT LIKE_KW|MATCH",
+ /* 206 */ "expr ::= expr likeop expr",
+ /* 207 */ "expr ::= expr likeop expr ESCAPE expr",
+ /* 208 */ "expr ::= expr ISNULL|NOTNULL",
+ /* 209 */ "expr ::= expr NOT NULL",
+ /* 210 */ "expr ::= expr IS expr",
+ /* 211 */ "expr ::= expr IS NOT expr",
+ /* 212 */ "expr ::= expr IS NOT DISTINCT FROM expr",
+ /* 213 */ "expr ::= expr IS DISTINCT FROM expr",
+ /* 214 */ "expr ::= NOT expr",
+ /* 215 */ "expr ::= BITNOT expr",
+ /* 216 */ "expr ::= PLUS|MINUS expr",
+ /* 217 */ "expr ::= expr PTR expr",
+ /* 218 */ "between_op ::= BETWEEN",
+ /* 219 */ "between_op ::= NOT BETWEEN",
+ /* 220 */ "expr ::= expr between_op expr AND expr",
+ /* 221 */ "in_op ::= IN",
+ /* 222 */ "in_op ::= NOT IN",
+ /* 223 */ "expr ::= expr in_op LP exprlist RP",
+ /* 224 */ "expr ::= LP select RP",
+ /* 225 */ "expr ::= expr in_op LP select RP",
+ /* 226 */ "expr ::= expr in_op nm dbnm paren_exprlist",
+ /* 227 */ "expr ::= EXISTS LP select RP",
+ /* 228 */ "expr ::= CASE case_operand case_exprlist case_else END",
+ /* 229 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
+ /* 230 */ "case_exprlist ::= WHEN expr THEN expr",
+ /* 231 */ "case_else ::= ELSE expr",
+ /* 232 */ "case_else ::=",
+ /* 233 */ "case_operand ::=",
+ /* 234 */ "exprlist ::=",
+ /* 235 */ "nexprlist ::= nexprlist COMMA expr",
+ /* 236 */ "nexprlist ::= expr",
+ /* 237 */ "paren_exprlist ::=",
+ /* 238 */ "paren_exprlist ::= LP exprlist RP",
+ /* 239 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
+ /* 240 */ "uniqueflag ::= UNIQUE",
+ /* 241 */ "uniqueflag ::=",
+ /* 242 */ "eidlist_opt ::=",
+ /* 243 */ "eidlist_opt ::= LP eidlist RP",
+ /* 244 */ "eidlist ::= eidlist COMMA nm collate sortorder",
+ /* 245 */ "eidlist ::= nm collate sortorder",
+ /* 246 */ "collate ::=",
+ /* 247 */ "collate ::= COLLATE ID|STRING",
+ /* 248 */ "cmd ::= DROP INDEX ifexists fullname",
+ /* 249 */ "cmd ::= VACUUM vinto",
+ /* 250 */ "cmd ::= VACUUM nm vinto",
+ /* 251 */ "vinto ::= INTO expr",
+ /* 252 */ "vinto ::=",
+ /* 253 */ "cmd ::= PRAGMA nm dbnm",
+ /* 254 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
+ /* 255 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
+ /* 256 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
+ /* 257 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
+ /* 258 */ "plus_num ::= PLUS INTEGER|FLOAT",
+ /* 259 */ "minus_num ::= MINUS INTEGER|FLOAT",
+ /* 260 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
+ /* 261 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
+ /* 262 */ "trigger_time ::= BEFORE|AFTER",
+ /* 263 */ "trigger_time ::= INSTEAD OF",
+ /* 264 */ "trigger_time ::=",
+ /* 265 */ "trigger_event ::= DELETE|INSERT",
+ /* 266 */ "trigger_event ::= UPDATE",
+ /* 267 */ "trigger_event ::= UPDATE OF idlist",
+ /* 268 */ "when_clause ::=",
+ /* 269 */ "when_clause ::= WHEN expr",
+ /* 270 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
+ /* 271 */ "trigger_cmd_list ::= trigger_cmd SEMI",
+ /* 272 */ "trnm ::= nm DOT nm",
+ /* 273 */ "tridxby ::= INDEXED BY nm",
+ /* 274 */ "tridxby ::= NOT INDEXED",
+ /* 275 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt",
+ /* 276 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt",
+ /* 277 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt",
+ /* 278 */ "trigger_cmd ::= scanpt select scanpt",
+ /* 279 */ "expr ::= RAISE LP IGNORE RP",
+ /* 280 */ "expr ::= RAISE LP raisetype COMMA nm RP",
+ /* 281 */ "raisetype ::= ROLLBACK",
+ /* 282 */ "raisetype ::= ABORT",
+ /* 283 */ "raisetype ::= FAIL",
+ /* 284 */ "cmd ::= DROP TRIGGER ifexists fullname",
+ /* 285 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
+ /* 286 */ "cmd ::= DETACH database_kw_opt expr",
+ /* 287 */ "key_opt ::=",
+ /* 288 */ "key_opt ::= KEY expr",
+ /* 289 */ "cmd ::= REINDEX",
+ /* 290 */ "cmd ::= REINDEX nm dbnm",
+ /* 291 */ "cmd ::= ANALYZE",
+ /* 292 */ "cmd ::= ANALYZE nm dbnm",
+ /* 293 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
+ /* 294 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
+ /* 295 */ "cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm",
+ /* 296 */ "add_column_fullname ::= fullname",
+ /* 297 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm",
+ /* 298 */ "cmd ::= create_vtab",
+ /* 299 */ "cmd ::= create_vtab LP vtabarglist RP",
+ /* 300 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
+ /* 301 */ "vtabarg ::=",
+ /* 302 */ "vtabargtoken ::= ANY",
+ /* 303 */ "vtabargtoken ::= lp anylist RP",
+ /* 304 */ "lp ::= LP",
+ /* 305 */ "with ::= WITH wqlist",
+ /* 306 */ "with ::= WITH RECURSIVE wqlist",
+ /* 307 */ "wqas ::= AS",
+ /* 308 */ "wqas ::= AS MATERIALIZED",
+ /* 309 */ "wqas ::= AS NOT MATERIALIZED",
+ /* 310 */ "wqitem ::= withnm eidlist_opt wqas LP select RP",
+ /* 311 */ "withnm ::= nm",
+ /* 312 */ "wqlist ::= wqitem",
+ /* 313 */ "wqlist ::= wqlist COMMA wqitem",
+ /* 314 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn",
+ /* 315 */ "windowdefn ::= nm AS LP window RP",
+ /* 316 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt",
+ /* 317 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt",
+ /* 318 */ "window ::= ORDER BY sortlist frame_opt",
+ /* 319 */ "window ::= nm ORDER BY sortlist frame_opt",
+ /* 320 */ "window ::= nm frame_opt",
+ /* 321 */ "frame_opt ::=",
+ /* 322 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt",
+ /* 323 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt",
+ /* 324 */ "range_or_rows ::= RANGE|ROWS|GROUPS",
+ /* 325 */ "frame_bound_s ::= frame_bound",
+ /* 326 */ "frame_bound_s ::= UNBOUNDED PRECEDING",
+ /* 327 */ "frame_bound_e ::= frame_bound",
+ /* 328 */ "frame_bound_e ::= UNBOUNDED FOLLOWING",
+ /* 329 */ "frame_bound ::= expr PRECEDING|FOLLOWING",
+ /* 330 */ "frame_bound ::= CURRENT ROW",
+ /* 331 */ "frame_exclude_opt ::=",
+ /* 332 */ "frame_exclude_opt ::= EXCLUDE frame_exclude",
+ /* 333 */ "frame_exclude ::= NO OTHERS",
+ /* 334 */ "frame_exclude ::= CURRENT ROW",
+ /* 335 */ "frame_exclude ::= GROUP|TIES",
+ /* 336 */ "window_clause ::= WINDOW windowdefn_list",
+ /* 337 */ "filter_over ::= filter_clause over_clause",
+ /* 338 */ "filter_over ::= over_clause",
+ /* 339 */ "filter_over ::= filter_clause",
+ /* 340 */ "over_clause ::= OVER LP window RP",
+ /* 341 */ "over_clause ::= OVER nm",
+ /* 342 */ "filter_clause ::= FILTER LP WHERE expr RP",
+ /* 343 */ "term ::= QNUMBER",
+ /* 344 */ "input ::= cmdlist",
+ /* 345 */ "cmdlist ::= cmdlist ecmd",
+ /* 346 */ "cmdlist ::= ecmd",
+ /* 347 */ "ecmd ::= SEMI",
+ /* 348 */ "ecmd ::= cmdx SEMI",
+ /* 349 */ "ecmd ::= explain cmdx SEMI",
+ /* 350 */ "trans_opt ::=",
+ /* 351 */ "trans_opt ::= TRANSACTION",
+ /* 352 */ "trans_opt ::= TRANSACTION nm",
+ /* 353 */ "savepoint_opt ::= SAVEPOINT",
+ /* 354 */ "savepoint_opt ::=",
+ /* 355 */ "cmd ::= create_table create_table_args",
+ /* 356 */ "table_option_set ::= table_option",
+ /* 357 */ "columnlist ::= columnlist COMMA columnname carglist",
+ /* 358 */ "columnlist ::= columnname carglist",
+ /* 359 */ "nm ::= ID|INDEXED|JOIN_KW",
+ /* 360 */ "nm ::= STRING",
+ /* 361 */ "typetoken ::= typename",
+ /* 362 */ "typename ::= ID|STRING",
+ /* 363 */ "signed ::= plus_num",
+ /* 364 */ "signed ::= minus_num",
+ /* 365 */ "carglist ::= carglist ccons",
+ /* 366 */ "carglist ::=",
+ /* 367 */ "ccons ::= NULL onconf",
+ /* 368 */ "ccons ::= GENERATED ALWAYS AS generated",
+ /* 369 */ "ccons ::= AS generated",
+ /* 370 */ "conslist_opt ::= COMMA conslist",
+ /* 371 */ "conslist ::= conslist tconscomma tcons",
+ /* 372 */ "conslist ::= tcons",
+ /* 373 */ "tconscomma ::=",
+ /* 374 */ "defer_subclause_opt ::= defer_subclause",
+ /* 375 */ "resolvetype ::= raisetype",
+ /* 376 */ "selectnowith ::= oneselect",
+ /* 377 */ "oneselect ::= values",
+ /* 378 */ "sclp ::= selcollist COMMA",
+ /* 379 */ "as ::= ID|STRING",
+ /* 380 */ "indexed_opt ::= indexed_by",
+ /* 381 */ "returning ::=",
+ /* 382 */ "expr ::= term",
+ /* 383 */ "likeop ::= LIKE_KW|MATCH",
+ /* 384 */ "case_operand ::= expr",
+ /* 385 */ "exprlist ::= nexprlist",
+ /* 386 */ "nmnum ::= plus_num",
+ /* 387 */ "nmnum ::= nm",
+ /* 388 */ "nmnum ::= ON",
+ /* 389 */ "nmnum ::= DELETE",
+ /* 390 */ "nmnum ::= DEFAULT",
+ /* 391 */ "plus_num ::= INTEGER|FLOAT",
+ /* 392 */ "foreach_clause ::=",
+ /* 393 */ "foreach_clause ::= FOR EACH ROW",
+ /* 394 */ "trnm ::= nm",
+ /* 395 */ "tridxby ::=",
+ /* 396 */ "database_kw_opt ::= DATABASE",
+ /* 397 */ "database_kw_opt ::=",
+ /* 398 */ "kwcolumn_opt ::=",
+ /* 399 */ "kwcolumn_opt ::= COLUMNKW",
+ /* 400 */ "vtabarglist ::= vtabarg",
+ /* 401 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
+ /* 402 */ "vtabarg ::= vtabarg vtabargtoken",
+ /* 403 */ "anylist ::=",
+ /* 404 */ "anylist ::= anylist LP anylist RP",
+ /* 405 */ "anylist ::= anylist ANY",
+ /* 406 */ "with ::=",
+ /* 407 */ "windowdefn_list ::= windowdefn",
+ /* 408 */ "window ::= frame_opt",
 };
 #endif /* NDEBUG */
 
 
-#if YYSTACKDEPTH<=0
+#if YYGROWABLESTACK
 /*
 ** Try to increase the size of the parser stack.  Return the number
 ** of errors.  Return 0 on success.
 */
 static int yyGrowStack(yyParser *p){
+  int oldSize = 1 + (int)(p->yystackEnd - p->yystack);
   int newSize;
   int idx;
   yyStackEntry *pNew;
 
-  newSize = p->yystksz*2 + 100;
-  idx = p->yytos ? (int)(p->yytos - p->yystack) : 0;
-  if( p->yystack==&p->yystk0 ){
-    pNew = malloc(newSize*sizeof(pNew[0]));
-    if( pNew ) pNew[0] = p->yystk0;
+  newSize = oldSize*2 + 100;
+  idx = (int)(p->yytos - p->yystack);
+  if( p->yystack==p->yystk0 ){
+    pNew = YYREALLOC(0, newSize*sizeof(pNew[0]));
+    if( pNew==0 ) return 1;
+    memcpy(pNew, p->yystack, oldSize*sizeof(pNew[0]));
   }else{
-    pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
+    pNew = YYREALLOC(p->yystack, newSize*sizeof(pNew[0]));
+    if( pNew==0 ) return 1;
   }
-  if( pNew ){
-    p->yystack = pNew;
-    p->yytos = &p->yystack[idx];
+  p->yystack = pNew;
+  p->yytos = &p->yystack[idx];
 #ifndef NDEBUG
-    if( yyTraceFILE ){
-      fprintf(yyTraceFILE,"%sStack grows from %d to %d entries.\n",
-              yyTracePrompt, p->yystksz, newSize);
-    }
-#endif
-    p->yystksz = newSize;
+  if( yyTraceFILE ){
+    fprintf(yyTraceFILE,"%sStack grows from %d to %d entries.\n",
+            yyTracePrompt, oldSize, newSize);
   }
-  return pNew==0;
+#endif
+  p->yystackEnd = &p->yystack[newSize-1];
+  return 0;
 }
+#endif /* YYGROWABLESTACK */
+
+#if !YYGROWABLESTACK
+/* For builds that do no have a growable stack, yyGrowStack always
+** returns an error.
+*/
+# define yyGrowStack(X) 1
 #endif
 
 /* Datatype of the argument to the memory allocated passed as the
@@ -173186,24 +174798,14 @@ SQLITE_PRIVATE void sqlite3ParserInit(void *yypRawParser sqlite3ParserCTX_PDECL)
 #ifdef YYTRACKMAXSTACKDEPTH
   yypParser->yyhwm = 0;
 #endif
-#if YYSTACKDEPTH<=0
-  yypParser->yytos = NULL;
-  yypParser->yystack = NULL;
-  yypParser->yystksz = 0;
-  if( yyGrowStack(yypParser) ){
-    yypParser->yystack = &yypParser->yystk0;
-    yypParser->yystksz = 1;
-  }
-#endif
+  yypParser->yystack = yypParser->yystk0;
+  yypParser->yystackEnd = &yypParser->yystack[YYSTACKDEPTH-1];
 #ifndef YYNOERRORRECOVERY
   yypParser->yyerrcnt = -1;
 #endif
   yypParser->yytos = yypParser->yystack;
   yypParser->yystack[0].stateno = 0;
   yypParser->yystack[0].major = 0;
-#if YYSTACKDEPTH>0
-  yypParser->yystackEnd = &yypParser->yystack[YYSTACKDEPTH-1];
-#endif
 }
 
 #ifndef sqlite3Parser_ENGINEALWAYSONSTACK
@@ -173257,97 +174859,98 @@ static void yy_destructor(
     ** inside the C code.
     */
 /********* Begin destructor definitions ***************************************/
-    case 204: /* select */
-    case 239: /* selectnowith */
-    case 240: /* oneselect */
-    case 252: /* values */
+    case 205: /* select */
+    case 240: /* selectnowith */
+    case 241: /* oneselect */
+    case 253: /* values */
+    case 255: /* mvalues */
 {
-sqlite3SelectDelete(pParse->db, (yypminor->yy47));
-}
-      break;
-    case 216: /* term */
-    case 217: /* expr */
-    case 246: /* where_opt */
-    case 248: /* having_opt */
-    case 267: /* where_opt_ret */
-    case 278: /* case_operand */
-    case 280: /* case_else */
-    case 283: /* vinto */
-    case 290: /* when_clause */
-    case 295: /* key_opt */
-    case 311: /* filter_clause */
+sqlite3SelectDelete(pParse->db, (yypminor->yy555));
+}
+      break;
+    case 217: /* term */
+    case 218: /* expr */
+    case 247: /* where_opt */
+    case 249: /* having_opt */
+    case 269: /* where_opt_ret */
+    case 280: /* case_operand */
+    case 282: /* case_else */
+    case 285: /* vinto */
+    case 292: /* when_clause */
+    case 297: /* key_opt */
+    case 314: /* filter_clause */
 {
-sqlite3ExprDelete(pParse->db, (yypminor->yy528));
-}
-      break;
-    case 221: /* eidlist_opt */
-    case 231: /* sortlist */
-    case 232: /* eidlist */
-    case 244: /* selcollist */
-    case 247: /* groupby_opt */
-    case 249: /* orderby_opt */
-    case 253: /* nexprlist */
-    case 254: /* sclp */
-    case 261: /* exprlist */
-    case 268: /* setlist */
-    case 277: /* paren_exprlist */
-    case 279: /* case_exprlist */
-    case 310: /* part_opt */
+sqlite3ExprDelete(pParse->db, (yypminor->yy454));
+}
+      break;
+    case 222: /* eidlist_opt */
+    case 232: /* sortlist */
+    case 233: /* eidlist */
+    case 245: /* selcollist */
+    case 248: /* groupby_opt */
+    case 250: /* orderby_opt */
+    case 254: /* nexprlist */
+    case 256: /* sclp */
+    case 263: /* exprlist */
+    case 270: /* setlist */
+    case 279: /* paren_exprlist */
+    case 281: /* case_exprlist */
+    case 313: /* part_opt */
 {
-sqlite3ExprListDelete(pParse->db, (yypminor->yy322));
+sqlite3ExprListDelete(pParse->db, (yypminor->yy14));
 }
       break;
-    case 238: /* fullname */
-    case 245: /* from */
-    case 256: /* seltablist */
-    case 257: /* stl_prefix */
-    case 262: /* xfullname */
+    case 239: /* fullname */
+    case 246: /* from */
+    case 258: /* seltablist */
+    case 259: /* stl_prefix */
+    case 264: /* xfullname */
 {
-sqlite3SrcListDelete(pParse->db, (yypminor->yy131));
+sqlite3SrcListDelete(pParse->db, (yypminor->yy203));
 }
       break;
-    case 241: /* wqlist */
+    case 242: /* wqlist */
 {
-sqlite3WithDelete(pParse->db, (yypminor->yy521));
+sqlite3WithDelete(pParse->db, (yypminor->yy59));
 }
       break;
-    case 251: /* window_clause */
-    case 306: /* windowdefn_list */
+    case 252: /* window_clause */
+    case 309: /* windowdefn_list */
 {
-sqlite3WindowListDelete(pParse->db, (yypminor->yy41));
+sqlite3WindowListDelete(pParse->db, (yypminor->yy211));
 }
       break;
-    case 263: /* idlist */
-    case 270: /* idlist_opt */
+    case 265: /* idlist */
+    case 272: /* idlist_opt */
 {
-sqlite3IdListDelete(pParse->db, (yypminor->yy254));
+sqlite3IdListDelete(pParse->db, (yypminor->yy132));
 }
       break;
-    case 273: /* filter_over */
-    case 307: /* windowdefn */
-    case 308: /* window */
-    case 309: /* frame_opt */
-    case 312: /* over_clause */
+    case 275: /* filter_over */
+    case 310: /* windowdefn */
+    case 311: /* window */
+    case 312: /* frame_opt */
+    case 315: /* over_clause */
 {
-sqlite3WindowDelete(pParse->db, (yypminor->yy41));
+sqlite3WindowDelete(pParse->db, (yypminor->yy211));
 }
       break;
-    case 286: /* trigger_cmd_list */
-    case 291: /* trigger_cmd */
+    case 288: /* trigger_cmd_list */
+    case 293: /* trigger_cmd */
 {
-sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy33));
+sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy427));
 }
       break;
-    case 288: /* trigger_event */
+    case 290: /* trigger_event */
 {
-sqlite3IdListDelete(pParse->db, (yypminor->yy180).b);
+sqlite3IdListDelete(pParse->db, (yypminor->yy286).b);
 }
       break;
-    case 314: /* frame_bound */
-    case 315: /* frame_bound_s */
-    case 316: /* frame_bound_e */
+    case 317: /* frame_bound */
+    case 318: /* frame_bound_s */
+    case 319: /* frame_bound_e */
 {
-sqlite3ExprDelete(pParse->db, (yypminor->yy595).pExpr);
+sqlite3ExprDelete(pParse->db, (yypminor->yy509).pExpr);
 }
       break;
 /********* End destructor definitions *****************************************/
@@ -173381,9 +174984,26 @@ static void yy_pop_parser_stack(yyParser *pParser){
 */
 SQLITE_PRIVATE void sqlite3ParserFinalize(void *p){
   yyParser *pParser = (yyParser*)p;
-  while( pParser->yytos>pParser->yystack ) yy_pop_parser_stack(pParser);
-#if YYSTACKDEPTH<=0
-  if( pParser->yystack!=&pParser->yystk0 ) free(pParser->yystack);
+
+  /* In-lined version of calling yy_pop_parser_stack() for each
+  ** element left in the stack */
+  yyStackEntry *yytos = pParser->yytos;
+  while( yytos>pParser->yystack ){
+#ifndef NDEBUG
+    if( yyTraceFILE ){
+      fprintf(yyTraceFILE,"%sPopping %s\n",
+        yyTracePrompt,
+        yyTokenName[yytos->major]);
+    }
+#endif
+    if( yytos->major>=YY_MIN_DSTRCTR ){
+      yy_destructor(pParser, yytos->major, &yytos->minor);
+    }
+    yytos--;
+  }
+
+#if YYGROWABLESTACK
+  if( pParser->yystack!=pParser->yystk0 ) YYFREE(pParser->yystack);
 #endif
 }
 
@@ -173566,7 +175186,7 @@ static void yyStackOverflow(yyParser *yypParser){
    ** stack every overflows */
 /******** Begin %stack_overflow code ******************************************/
 
-  sqlite3ErrorMsg(pParse, "parser stack overflow");
+  sqlite3OomFault(pParse->db);
 /******** End %stack_overflow code ********************************************/
    sqlite3ParserARG_STORE /* Suppress warning about unused %extra_argument var */
    sqlite3ParserCTX_STORE
@@ -173610,25 +175230,19 @@ static void yy_shift(
     assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack) );
   }
 #endif
-#if YYSTACKDEPTH>0
-  if( yypParser->yytos>yypParser->yystackEnd ){
-    yypParser->yytos--;
-    yyStackOverflow(yypParser);
-    return;
-  }
-#else
-  if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz] ){
+  yytos = yypParser->yytos;
+  if( yytos>yypParser->yystackEnd ){
     if( yyGrowStack(yypParser) ){
       yypParser->yytos--;
       yyStackOverflow(yypParser);
       return;
     }
+    yytos = yypParser->yytos;
+    assert( yytos <= yypParser->yystackEnd );
   }
-#endif
   if( yyNewState > YY_MAX_SHIFT ){
     yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
   }
-  yytos = yypParser->yytos;
   yytos->stateno = yyNewState;
   yytos->major = yyMajor;
   yytos->minor.yy0 = yyMinor;
@@ -173638,411 +175252,415 @@ static void yy_shift(
 /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side
 ** of that rule */
 static const YYCODETYPE yyRuleInfoLhs[] = {
-   189,  /* (0) explain ::= EXPLAIN */
-   189,  /* (1) explain ::= EXPLAIN QUERY PLAN */
-   188,  /* (2) cmdx ::= cmd */
-   190,  /* (3) cmd ::= BEGIN transtype trans_opt */
-   191,  /* (4) transtype ::= */
-   191,  /* (5) transtype ::= DEFERRED */
-   191,  /* (6) transtype ::= IMMEDIATE */
-   191,  /* (7) transtype ::= EXCLUSIVE */
-   190,  /* (8) cmd ::= COMMIT|END trans_opt */
-   190,  /* (9) cmd ::= ROLLBACK trans_opt */
-   190,  /* (10) cmd ::= SAVEPOINT nm */
-   190,  /* (11) cmd ::= RELEASE savepoint_opt nm */
-   190,  /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
-   195,  /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
-   197,  /* (14) createkw ::= CREATE */
-   199,  /* (15) ifnotexists ::= */
-   199,  /* (16) ifnotexists ::= IF NOT EXISTS */
-   198,  /* (17) temp ::= TEMP */
-   198,  /* (18) temp ::= */
-   196,  /* (19) create_table_args ::= LP columnlist conslist_opt RP table_option_set */
-   196,  /* (20) create_table_args ::= AS select */
-   203,  /* (21) table_option_set ::= */
-   203,  /* (22) table_option_set ::= table_option_set COMMA table_option */
-   205,  /* (23) table_option ::= WITHOUT nm */
-   205,  /* (24) table_option ::= nm */
-   206,  /* (25) columnname ::= nm typetoken */
-   208,  /* (26) typetoken ::= */
-   208,  /* (27) typetoken ::= typename LP signed RP */
-   208,  /* (28) typetoken ::= typename LP signed COMMA signed RP */
-   209,  /* (29) typename ::= typename ID|STRING */
-   213,  /* (30) scanpt ::= */
-   214,  /* (31) scantok ::= */
-   215,  /* (32) ccons ::= CONSTRAINT nm */
-   215,  /* (33) ccons ::= DEFAULT scantok term */
-   215,  /* (34) ccons ::= DEFAULT LP expr RP */
-   215,  /* (35) ccons ::= DEFAULT PLUS scantok term */
-   215,  /* (36) ccons ::= DEFAULT MINUS scantok term */
-   215,  /* (37) ccons ::= DEFAULT scantok ID|INDEXED */
-   215,  /* (38) ccons ::= NOT NULL onconf */
-   215,  /* (39) ccons ::= PRIMARY KEY sortorder onconf autoinc */
-   215,  /* (40) ccons ::= UNIQUE onconf */
-   215,  /* (41) ccons ::= CHECK LP expr RP */
-   215,  /* (42) ccons ::= REFERENCES nm eidlist_opt refargs */
-   215,  /* (43) ccons ::= defer_subclause */
-   215,  /* (44) ccons ::= COLLATE ID|STRING */
-   224,  /* (45) generated ::= LP expr RP */
-   224,  /* (46) generated ::= LP expr RP ID */
-   220,  /* (47) autoinc ::= */
-   220,  /* (48) autoinc ::= AUTOINCR */
-   222,  /* (49) refargs ::= */
-   222,  /* (50) refargs ::= refargs refarg */
-   225,  /* (51) refarg ::= MATCH nm */
-   225,  /* (52) refarg ::= ON INSERT refact */
-   225,  /* (53) refarg ::= ON DELETE refact */
-   225,  /* (54) refarg ::= ON UPDATE refact */
-   226,  /* (55) refact ::= SET NULL */
-   226,  /* (56) refact ::= SET DEFAULT */
-   226,  /* (57) refact ::= CASCADE */
-   226,  /* (58) refact ::= RESTRICT */
-   226,  /* (59) refact ::= NO ACTION */
-   223,  /* (60) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
-   223,  /* (61) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
-   227,  /* (62) init_deferred_pred_opt ::= */
-   227,  /* (63) init_deferred_pred_opt ::= INITIALLY DEFERRED */
-   227,  /* (64) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
-   202,  /* (65) conslist_opt ::= */
-   229,  /* (66) tconscomma ::= COMMA */
-   230,  /* (67) tcons ::= CONSTRAINT nm */
-   230,  /* (68) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
-   230,  /* (69) tcons ::= UNIQUE LP sortlist RP onconf */
-   230,  /* (70) tcons ::= CHECK LP expr RP onconf */
-   230,  /* (71) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
-   233,  /* (72) defer_subclause_opt ::= */
-   218,  /* (73) onconf ::= */
-   218,  /* (74) onconf ::= ON CONFLICT resolvetype */
-   234,  /* (75) orconf ::= */
-   234,  /* (76) orconf ::= OR resolvetype */
-   235,  /* (77) resolvetype ::= IGNORE */
-   235,  /* (78) resolvetype ::= REPLACE */
-   190,  /* (79) cmd ::= DROP TABLE ifexists fullname */
-   237,  /* (80) ifexists ::= IF EXISTS */
-   237,  /* (81) ifexists ::= */
-   190,  /* (82) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
-   190,  /* (83) cmd ::= DROP VIEW ifexists fullname */
-   190,  /* (84) cmd ::= select */
-   204,  /* (85) select ::= WITH wqlist selectnowith */
-   204,  /* (86) select ::= WITH RECURSIVE wqlist selectnowith */
-   204,  /* (87) select ::= selectnowith */
-   239,  /* (88) selectnowith ::= selectnowith multiselect_op oneselect */
-   242,  /* (89) multiselect_op ::= UNION */
-   242,  /* (90) multiselect_op ::= UNION ALL */
-   242,  /* (91) multiselect_op ::= EXCEPT|INTERSECT */
-   240,  /* (92) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
-   240,  /* (93) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
-   252,  /* (94) values ::= VALUES LP nexprlist RP */
-   252,  /* (95) values ::= values COMMA LP nexprlist RP */
-   243,  /* (96) distinct ::= DISTINCT */
-   243,  /* (97) distinct ::= ALL */
-   243,  /* (98) distinct ::= */
-   254,  /* (99) sclp ::= */
-   244,  /* (100) selcollist ::= sclp scanpt expr scanpt as */
-   244,  /* (101) selcollist ::= sclp scanpt STAR */
-   244,  /* (102) selcollist ::= sclp scanpt nm DOT STAR */
-   255,  /* (103) as ::= AS nm */
-   255,  /* (104) as ::= */
-   245,  /* (105) from ::= */
-   245,  /* (106) from ::= FROM seltablist */
-   257,  /* (107) stl_prefix ::= seltablist joinop */
-   257,  /* (108) stl_prefix ::= */
-   256,  /* (109) seltablist ::= stl_prefix nm dbnm as on_using */
-   256,  /* (110) seltablist ::= stl_prefix nm dbnm as indexed_by on_using */
-   256,  /* (111) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_using */
-   256,  /* (112) seltablist ::= stl_prefix LP select RP as on_using */
-   256,  /* (113) seltablist ::= stl_prefix LP seltablist RP as on_using */
-   200,  /* (114) dbnm ::= */
-   200,  /* (115) dbnm ::= DOT nm */
-   238,  /* (116) fullname ::= nm */
-   238,  /* (117) fullname ::= nm DOT nm */
-   262,  /* (118) xfullname ::= nm */
-   262,  /* (119) xfullname ::= nm DOT nm */
-   262,  /* (120) xfullname ::= nm DOT nm AS nm */
-   262,  /* (121) xfullname ::= nm AS nm */
-   258,  /* (122) joinop ::= COMMA|JOIN */
-   258,  /* (123) joinop ::= JOIN_KW JOIN */
-   258,  /* (124) joinop ::= JOIN_KW nm JOIN */
-   258,  /* (125) joinop ::= JOIN_KW nm nm JOIN */
-   259,  /* (126) on_using ::= ON expr */
-   259,  /* (127) on_using ::= USING LP idlist RP */
-   259,  /* (128) on_using ::= */
-   264,  /* (129) indexed_opt ::= */
-   260,  /* (130) indexed_by ::= INDEXED BY nm */
-   260,  /* (131) indexed_by ::= NOT INDEXED */
-   249,  /* (132) orderby_opt ::= */
-   249,  /* (133) orderby_opt ::= ORDER BY sortlist */
-   231,  /* (134) sortlist ::= sortlist COMMA expr sortorder nulls */
-   231,  /* (135) sortlist ::= expr sortorder nulls */
-   219,  /* (136) sortorder ::= ASC */
-   219,  /* (137) sortorder ::= DESC */
-   219,  /* (138) sortorder ::= */
-   265,  /* (139) nulls ::= NULLS FIRST */
-   265,  /* (140) nulls ::= NULLS LAST */
-   265,  /* (141) nulls ::= */
-   247,  /* (142) groupby_opt ::= */
-   247,  /* (143) groupby_opt ::= GROUP BY nexprlist */
-   248,  /* (144) having_opt ::= */
-   248,  /* (145) having_opt ::= HAVING expr */
-   250,  /* (146) limit_opt ::= */
-   250,  /* (147) limit_opt ::= LIMIT expr */
-   250,  /* (148) limit_opt ::= LIMIT expr OFFSET expr */
-   250,  /* (149) limit_opt ::= LIMIT expr COMMA expr */
-   190,  /* (150) cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */
-   246,  /* (151) where_opt ::= */
-   246,  /* (152) where_opt ::= WHERE expr */
-   267,  /* (153) where_opt_ret ::= */
-   267,  /* (154) where_opt_ret ::= WHERE expr */
-   267,  /* (155) where_opt_ret ::= RETURNING selcollist */
-   267,  /* (156) where_opt_ret ::= WHERE expr RETURNING selcollist */
-   190,  /* (157) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */
-   268,  /* (158) setlist ::= setlist COMMA nm EQ expr */
-   268,  /* (159) setlist ::= setlist COMMA LP idlist RP EQ expr */
-   268,  /* (160) setlist ::= nm EQ expr */
-   268,  /* (161) setlist ::= LP idlist RP EQ expr */
-   190,  /* (162) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
-   190,  /* (163) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */
-   271,  /* (164) upsert ::= */
-   271,  /* (165) upsert ::= RETURNING selcollist */
-   271,  /* (166) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */
-   271,  /* (167) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */
-   271,  /* (168) upsert ::= ON CONFLICT DO NOTHING returning */
-   271,  /* (169) upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */
-   272,  /* (170) returning ::= RETURNING selcollist */
-   269,  /* (171) insert_cmd ::= INSERT orconf */
-   269,  /* (172) insert_cmd ::= REPLACE */
-   270,  /* (173) idlist_opt ::= */
-   270,  /* (174) idlist_opt ::= LP idlist RP */
-   263,  /* (175) idlist ::= idlist COMMA nm */
-   263,  /* (176) idlist ::= nm */
-   217,  /* (177) expr ::= LP expr RP */
-   217,  /* (178) expr ::= ID|INDEXED|JOIN_KW */
-   217,  /* (179) expr ::= nm DOT nm */
-   217,  /* (180) expr ::= nm DOT nm DOT nm */
-   216,  /* (181) term ::= NULL|FLOAT|BLOB */
-   216,  /* (182) term ::= STRING */
-   216,  /* (183) term ::= INTEGER */
-   217,  /* (184) expr ::= VARIABLE */
-   217,  /* (185) expr ::= expr COLLATE ID|STRING */
-   217,  /* (186) expr ::= CAST LP expr AS typetoken RP */
-   217,  /* (187) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */
-   217,  /* (188) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */
-   217,  /* (189) expr ::= ID|INDEXED|JOIN_KW LP STAR RP */
-   217,  /* (190) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */
-   217,  /* (191) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */
-   217,  /* (192) expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */
-   216,  /* (193) term ::= CTIME_KW */
-   217,  /* (194) expr ::= LP nexprlist COMMA expr RP */
-   217,  /* (195) expr ::= expr AND expr */
-   217,  /* (196) expr ::= expr OR expr */
-   217,  /* (197) expr ::= expr LT|GT|GE|LE expr */
-   217,  /* (198) expr ::= expr EQ|NE expr */
-   217,  /* (199) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
-   217,  /* (200) expr ::= expr PLUS|MINUS expr */
-   217,  /* (201) expr ::= expr STAR|SLASH|REM expr */
-   217,  /* (202) expr ::= expr CONCAT expr */
-   274,  /* (203) likeop ::= NOT LIKE_KW|MATCH */
-   217,  /* (204) expr ::= expr likeop expr */
-   217,  /* (205) expr ::= expr likeop expr ESCAPE expr */
-   217,  /* (206) expr ::= expr ISNULL|NOTNULL */
-   217,  /* (207) expr ::= expr NOT NULL */
-   217,  /* (208) expr ::= expr IS expr */
-   217,  /* (209) expr ::= expr IS NOT expr */
-   217,  /* (210) expr ::= expr IS NOT DISTINCT FROM expr */
-   217,  /* (211) expr ::= expr IS DISTINCT FROM expr */
-   217,  /* (212) expr ::= NOT expr */
-   217,  /* (213) expr ::= BITNOT expr */
-   217,  /* (214) expr ::= PLUS|MINUS expr */
-   217,  /* (215) expr ::= expr PTR expr */
-   275,  /* (216) between_op ::= BETWEEN */
-   275,  /* (217) between_op ::= NOT BETWEEN */
-   217,  /* (218) expr ::= expr between_op expr AND expr */
-   276,  /* (219) in_op ::= IN */
-   276,  /* (220) in_op ::= NOT IN */
-   217,  /* (221) expr ::= expr in_op LP exprlist RP */
-   217,  /* (222) expr ::= LP select RP */
-   217,  /* (223) expr ::= expr in_op LP select RP */
-   217,  /* (224) expr ::= expr in_op nm dbnm paren_exprlist */
-   217,  /* (225) expr ::= EXISTS LP select RP */
-   217,  /* (226) expr ::= CASE case_operand case_exprlist case_else END */
-   279,  /* (227) case_exprlist ::= case_exprlist WHEN expr THEN expr */
-   279,  /* (228) case_exprlist ::= WHEN expr THEN expr */
-   280,  /* (229) case_else ::= ELSE expr */
-   280,  /* (230) case_else ::= */
-   278,  /* (231) case_operand ::= */
-   261,  /* (232) exprlist ::= */
-   253,  /* (233) nexprlist ::= nexprlist COMMA expr */
-   253,  /* (234) nexprlist ::= expr */
-   277,  /* (235) paren_exprlist ::= */
-   277,  /* (236) paren_exprlist ::= LP exprlist RP */
-   190,  /* (237) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
-   281,  /* (238) uniqueflag ::= UNIQUE */
-   281,  /* (239) uniqueflag ::= */
-   221,  /* (240) eidlist_opt ::= */
-   221,  /* (241) eidlist_opt ::= LP eidlist RP */
-   232,  /* (242) eidlist ::= eidlist COMMA nm collate sortorder */
-   232,  /* (243) eidlist ::= nm collate sortorder */
-   282,  /* (244) collate ::= */
-   282,  /* (245) collate ::= COLLATE ID|STRING */
-   190,  /* (246) cmd ::= DROP INDEX ifexists fullname */
-   190,  /* (247) cmd ::= VACUUM vinto */
-   190,  /* (248) cmd ::= VACUUM nm vinto */
-   283,  /* (249) vinto ::= INTO expr */
-   283,  /* (250) vinto ::= */
-   190,  /* (251) cmd ::= PRAGMA nm dbnm */
-   190,  /* (252) cmd ::= PRAGMA nm dbnm EQ nmnum */
-   190,  /* (253) cmd ::= PRAGMA nm dbnm LP nmnum RP */
-   190,  /* (254) cmd ::= PRAGMA nm dbnm EQ minus_num */
-   190,  /* (255) cmd ::= PRAGMA nm dbnm LP minus_num RP */
-   211,  /* (256) plus_num ::= PLUS INTEGER|FLOAT */
-   212,  /* (257) minus_num ::= MINUS INTEGER|FLOAT */
-   190,  /* (258) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
-   285,  /* (259) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
-   287,  /* (260) trigger_time ::= BEFORE|AFTER */
-   287,  /* (261) trigger_time ::= INSTEAD OF */
-   287,  /* (262) trigger_time ::= */
-   288,  /* (263) trigger_event ::= DELETE|INSERT */
-   288,  /* (264) trigger_event ::= UPDATE */
-   288,  /* (265) trigger_event ::= UPDATE OF idlist */
-   290,  /* (266) when_clause ::= */
-   290,  /* (267) when_clause ::= WHEN expr */
-   286,  /* (268) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
-   286,  /* (269) trigger_cmd_list ::= trigger_cmd SEMI */
-   292,  /* (270) trnm ::= nm DOT nm */
-   293,  /* (271) tridxby ::= INDEXED BY nm */
-   293,  /* (272) tridxby ::= NOT INDEXED */
-   291,  /* (273) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
-   291,  /* (274) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
-   291,  /* (275) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
-   291,  /* (276) trigger_cmd ::= scanpt select scanpt */
-   217,  /* (277) expr ::= RAISE LP IGNORE RP */
-   217,  /* (278) expr ::= RAISE LP raisetype COMMA nm RP */
-   236,  /* (279) raisetype ::= ROLLBACK */
-   236,  /* (280) raisetype ::= ABORT */
-   236,  /* (281) raisetype ::= FAIL */
-   190,  /* (282) cmd ::= DROP TRIGGER ifexists fullname */
-   190,  /* (283) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
-   190,  /* (284) cmd ::= DETACH database_kw_opt expr */
-   295,  /* (285) key_opt ::= */
-   295,  /* (286) key_opt ::= KEY expr */
-   190,  /* (287) cmd ::= REINDEX */
-   190,  /* (288) cmd ::= REINDEX nm dbnm */
-   190,  /* (289) cmd ::= ANALYZE */
-   190,  /* (290) cmd ::= ANALYZE nm dbnm */
-   190,  /* (291) cmd ::= ALTER TABLE fullname RENAME TO nm */
-   190,  /* (292) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
-   190,  /* (293) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
-   296,  /* (294) add_column_fullname ::= fullname */
-   190,  /* (295) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
-   190,  /* (296) cmd ::= create_vtab */
-   190,  /* (297) cmd ::= create_vtab LP vtabarglist RP */
-   298,  /* (298) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
-   300,  /* (299) vtabarg ::= */
-   301,  /* (300) vtabargtoken ::= ANY */
-   301,  /* (301) vtabargtoken ::= lp anylist RP */
-   302,  /* (302) lp ::= LP */
-   266,  /* (303) with ::= WITH wqlist */
-   266,  /* (304) with ::= WITH RECURSIVE wqlist */
-   305,  /* (305) wqas ::= AS */
-   305,  /* (306) wqas ::= AS MATERIALIZED */
-   305,  /* (307) wqas ::= AS NOT MATERIALIZED */
-   304,  /* (308) wqitem ::= nm eidlist_opt wqas LP select RP */
-   241,  /* (309) wqlist ::= wqitem */
-   241,  /* (310) wqlist ::= wqlist COMMA wqitem */
-   306,  /* (311) windowdefn_list ::= windowdefn_list COMMA windowdefn */
-   307,  /* (312) windowdefn ::= nm AS LP window RP */
-   308,  /* (313) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
-   308,  /* (314) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
-   308,  /* (315) window ::= ORDER BY sortlist frame_opt */
-   308,  /* (316) window ::= nm ORDER BY sortlist frame_opt */
-   308,  /* (317) window ::= nm frame_opt */
-   309,  /* (318) frame_opt ::= */
-   309,  /* (319) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
-   309,  /* (320) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
-   313,  /* (321) range_or_rows ::= RANGE|ROWS|GROUPS */
-   315,  /* (322) frame_bound_s ::= frame_bound */
-   315,  /* (323) frame_bound_s ::= UNBOUNDED PRECEDING */
-   316,  /* (324) frame_bound_e ::= frame_bound */
-   316,  /* (325) frame_bound_e ::= UNBOUNDED FOLLOWING */
-   314,  /* (326) frame_bound ::= expr PRECEDING|FOLLOWING */
-   314,  /* (327) frame_bound ::= CURRENT ROW */
-   317,  /* (328) frame_exclude_opt ::= */
-   317,  /* (329) frame_exclude_opt ::= EXCLUDE frame_exclude */
-   318,  /* (330) frame_exclude ::= NO OTHERS */
-   318,  /* (331) frame_exclude ::= CURRENT ROW */
-   318,  /* (332) frame_exclude ::= GROUP|TIES */
-   251,  /* (333) window_clause ::= WINDOW windowdefn_list */
-   273,  /* (334) filter_over ::= filter_clause over_clause */
-   273,  /* (335) filter_over ::= over_clause */
-   273,  /* (336) filter_over ::= filter_clause */
-   312,  /* (337) over_clause ::= OVER LP window RP */
-   312,  /* (338) over_clause ::= OVER nm */
-   311,  /* (339) filter_clause ::= FILTER LP WHERE expr RP */
-   185,  /* (340) input ::= cmdlist */
-   186,  /* (341) cmdlist ::= cmdlist ecmd */
-   186,  /* (342) cmdlist ::= ecmd */
-   187,  /* (343) ecmd ::= SEMI */
-   187,  /* (344) ecmd ::= cmdx SEMI */
-   187,  /* (345) ecmd ::= explain cmdx SEMI */
-   192,  /* (346) trans_opt ::= */
-   192,  /* (347) trans_opt ::= TRANSACTION */
-   192,  /* (348) trans_opt ::= TRANSACTION nm */
-   194,  /* (349) savepoint_opt ::= SAVEPOINT */
-   194,  /* (350) savepoint_opt ::= */
-   190,  /* (351) cmd ::= create_table create_table_args */
-   203,  /* (352) table_option_set ::= table_option */
-   201,  /* (353) columnlist ::= columnlist COMMA columnname carglist */
-   201,  /* (354) columnlist ::= columnname carglist */
-   193,  /* (355) nm ::= ID|INDEXED|JOIN_KW */
-   193,  /* (356) nm ::= STRING */
-   208,  /* (357) typetoken ::= typename */
-   209,  /* (358) typename ::= ID|STRING */
-   210,  /* (359) signed ::= plus_num */
-   210,  /* (360) signed ::= minus_num */
-   207,  /* (361) carglist ::= carglist ccons */
-   207,  /* (362) carglist ::= */
-   215,  /* (363) ccons ::= NULL onconf */
-   215,  /* (364) ccons ::= GENERATED ALWAYS AS generated */
-   215,  /* (365) ccons ::= AS generated */
-   202,  /* (366) conslist_opt ::= COMMA conslist */
-   228,  /* (367) conslist ::= conslist tconscomma tcons */
-   228,  /* (368) conslist ::= tcons */
-   229,  /* (369) tconscomma ::= */
-   233,  /* (370) defer_subclause_opt ::= defer_subclause */
-   235,  /* (371) resolvetype ::= raisetype */
-   239,  /* (372) selectnowith ::= oneselect */
-   240,  /* (373) oneselect ::= values */
-   254,  /* (374) sclp ::= selcollist COMMA */
-   255,  /* (375) as ::= ID|STRING */
-   264,  /* (376) indexed_opt ::= indexed_by */
-   272,  /* (377) returning ::= */
-   217,  /* (378) expr ::= term */
-   274,  /* (379) likeop ::= LIKE_KW|MATCH */
-   278,  /* (380) case_operand ::= expr */
-   261,  /* (381) exprlist ::= nexprlist */
-   284,  /* (382) nmnum ::= plus_num */
-   284,  /* (383) nmnum ::= nm */
-   284,  /* (384) nmnum ::= ON */
-   284,  /* (385) nmnum ::= DELETE */
-   284,  /* (386) nmnum ::= DEFAULT */
-   211,  /* (387) plus_num ::= INTEGER|FLOAT */
-   289,  /* (388) foreach_clause ::= */
-   289,  /* (389) foreach_clause ::= FOR EACH ROW */
-   292,  /* (390) trnm ::= nm */
-   293,  /* (391) tridxby ::= */
-   294,  /* (392) database_kw_opt ::= DATABASE */
-   294,  /* (393) database_kw_opt ::= */
-   297,  /* (394) kwcolumn_opt ::= */
-   297,  /* (395) kwcolumn_opt ::= COLUMNKW */
-   299,  /* (396) vtabarglist ::= vtabarg */
-   299,  /* (397) vtabarglist ::= vtabarglist COMMA vtabarg */
-   300,  /* (398) vtabarg ::= vtabarg vtabargtoken */
-   303,  /* (399) anylist ::= */
-   303,  /* (400) anylist ::= anylist LP anylist RP */
-   303,  /* (401) anylist ::= anylist ANY */
-   266,  /* (402) with ::= */
-   306,  /* (403) windowdefn_list ::= windowdefn */
-   308,  /* (404) window ::= frame_opt */
+   190,  /* (0) explain ::= EXPLAIN */
+   190,  /* (1) explain ::= EXPLAIN QUERY PLAN */
+   189,  /* (2) cmdx ::= cmd */
+   191,  /* (3) cmd ::= BEGIN transtype trans_opt */
+   192,  /* (4) transtype ::= */
+   192,  /* (5) transtype ::= DEFERRED */
+   192,  /* (6) transtype ::= IMMEDIATE */
+   192,  /* (7) transtype ::= EXCLUSIVE */
+   191,  /* (8) cmd ::= COMMIT|END trans_opt */
+   191,  /* (9) cmd ::= ROLLBACK trans_opt */
+   191,  /* (10) cmd ::= SAVEPOINT nm */
+   191,  /* (11) cmd ::= RELEASE savepoint_opt nm */
+   191,  /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
+   196,  /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
+   198,  /* (14) createkw ::= CREATE */
+   200,  /* (15) ifnotexists ::= */
+   200,  /* (16) ifnotexists ::= IF NOT EXISTS */
+   199,  /* (17) temp ::= TEMP */
+   199,  /* (18) temp ::= */
+   197,  /* (19) create_table_args ::= LP columnlist conslist_opt RP table_option_set */
+   197,  /* (20) create_table_args ::= AS select */
+   204,  /* (21) table_option_set ::= */
+   204,  /* (22) table_option_set ::= table_option_set COMMA table_option */
+   206,  /* (23) table_option ::= WITHOUT nm */
+   206,  /* (24) table_option ::= nm */
+   207,  /* (25) columnname ::= nm typetoken */
+   209,  /* (26) typetoken ::= */
+   209,  /* (27) typetoken ::= typename LP signed RP */
+   209,  /* (28) typetoken ::= typename LP signed COMMA signed RP */
+   210,  /* (29) typename ::= typename ID|STRING */
+   214,  /* (30) scanpt ::= */
+   215,  /* (31) scantok ::= */
+   216,  /* (32) ccons ::= CONSTRAINT nm */
+   216,  /* (33) ccons ::= DEFAULT scantok term */
+   216,  /* (34) ccons ::= DEFAULT LP expr RP */
+   216,  /* (35) ccons ::= DEFAULT PLUS scantok term */
+   216,  /* (36) ccons ::= DEFAULT MINUS scantok term */
+   216,  /* (37) ccons ::= DEFAULT scantok ID|INDEXED */
+   216,  /* (38) ccons ::= NOT NULL onconf */
+   216,  /* (39) ccons ::= PRIMARY KEY sortorder onconf autoinc */
+   216,  /* (40) ccons ::= UNIQUE onconf */
+   216,  /* (41) ccons ::= CHECK LP expr RP */
+   216,  /* (42) ccons ::= REFERENCES nm eidlist_opt refargs */
+   216,  /* (43) ccons ::= defer_subclause */
+   216,  /* (44) ccons ::= COLLATE ID|STRING */
+   225,  /* (45) generated ::= LP expr RP */
+   225,  /* (46) generated ::= LP expr RP ID */
+   221,  /* (47) autoinc ::= */
+   221,  /* (48) autoinc ::= AUTOINCR */
+   223,  /* (49) refargs ::= */
+   223,  /* (50) refargs ::= refargs refarg */
+   226,  /* (51) refarg ::= MATCH nm */
+   226,  /* (52) refarg ::= ON INSERT refact */
+   226,  /* (53) refarg ::= ON DELETE refact */
+   226,  /* (54) refarg ::= ON UPDATE refact */
+   227,  /* (55) refact ::= SET NULL */
+   227,  /* (56) refact ::= SET DEFAULT */
+   227,  /* (57) refact ::= CASCADE */
+   227,  /* (58) refact ::= RESTRICT */
+   227,  /* (59) refact ::= NO ACTION */
+   224,  /* (60) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
+   224,  /* (61) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
+   228,  /* (62) init_deferred_pred_opt ::= */
+   228,  /* (63) init_deferred_pred_opt ::= INITIALLY DEFERRED */
+   228,  /* (64) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
+   203,  /* (65) conslist_opt ::= */
+   230,  /* (66) tconscomma ::= COMMA */
+   231,  /* (67) tcons ::= CONSTRAINT nm */
+   231,  /* (68) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
+   231,  /* (69) tcons ::= UNIQUE LP sortlist RP onconf */
+   231,  /* (70) tcons ::= CHECK LP expr RP onconf */
+   231,  /* (71) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
+   234,  /* (72) defer_subclause_opt ::= */
+   219,  /* (73) onconf ::= */
+   219,  /* (74) onconf ::= ON CONFLICT resolvetype */
+   235,  /* (75) orconf ::= */
+   235,  /* (76) orconf ::= OR resolvetype */
+   236,  /* (77) resolvetype ::= IGNORE */
+   236,  /* (78) resolvetype ::= REPLACE */
+   191,  /* (79) cmd ::= DROP TABLE ifexists fullname */
+   238,  /* (80) ifexists ::= IF EXISTS */
+   238,  /* (81) ifexists ::= */
+   191,  /* (82) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
+   191,  /* (83) cmd ::= DROP VIEW ifexists fullname */
+   191,  /* (84) cmd ::= select */
+   205,  /* (85) select ::= WITH wqlist selectnowith */
+   205,  /* (86) select ::= WITH RECURSIVE wqlist selectnowith */
+   205,  /* (87) select ::= selectnowith */
+   240,  /* (88) selectnowith ::= selectnowith multiselect_op oneselect */
+   243,  /* (89) multiselect_op ::= UNION */
+   243,  /* (90) multiselect_op ::= UNION ALL */
+   243,  /* (91) multiselect_op ::= EXCEPT|INTERSECT */
+   241,  /* (92) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
+   241,  /* (93) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
+   253,  /* (94) values ::= VALUES LP nexprlist RP */
+   241,  /* (95) oneselect ::= mvalues */
+   255,  /* (96) mvalues ::= values COMMA LP nexprlist RP */
+   255,  /* (97) mvalues ::= mvalues COMMA LP nexprlist RP */
+   244,  /* (98) distinct ::= DISTINCT */
+   244,  /* (99) distinct ::= ALL */
+   244,  /* (100) distinct ::= */
+   256,  /* (101) sclp ::= */
+   245,  /* (102) selcollist ::= sclp scanpt expr scanpt as */
+   245,  /* (103) selcollist ::= sclp scanpt STAR */
+   245,  /* (104) selcollist ::= sclp scanpt nm DOT STAR */
+   257,  /* (105) as ::= AS nm */
+   257,  /* (106) as ::= */
+   246,  /* (107) from ::= */
+   246,  /* (108) from ::= FROM seltablist */
+   259,  /* (109) stl_prefix ::= seltablist joinop */
+   259,  /* (110) stl_prefix ::= */
+   258,  /* (111) seltablist ::= stl_prefix nm dbnm as on_using */
+   258,  /* (112) seltablist ::= stl_prefix nm dbnm as indexed_by on_using */
+   258,  /* (113) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_using */
+   258,  /* (114) seltablist ::= stl_prefix LP select RP as on_using */
+   258,  /* (115) seltablist ::= stl_prefix LP seltablist RP as on_using */
+   201,  /* (116) dbnm ::= */
+   201,  /* (117) dbnm ::= DOT nm */
+   239,  /* (118) fullname ::= nm */
+   239,  /* (119) fullname ::= nm DOT nm */
+   264,  /* (120) xfullname ::= nm */
+   264,  /* (121) xfullname ::= nm DOT nm */
+   264,  /* (122) xfullname ::= nm DOT nm AS nm */
+   264,  /* (123) xfullname ::= nm AS nm */
+   260,  /* (124) joinop ::= COMMA|JOIN */
+   260,  /* (125) joinop ::= JOIN_KW JOIN */
+   260,  /* (126) joinop ::= JOIN_KW nm JOIN */
+   260,  /* (127) joinop ::= JOIN_KW nm nm JOIN */
+   261,  /* (128) on_using ::= ON expr */
+   261,  /* (129) on_using ::= USING LP idlist RP */
+   261,  /* (130) on_using ::= */
+   266,  /* (131) indexed_opt ::= */
+   262,  /* (132) indexed_by ::= INDEXED BY nm */
+   262,  /* (133) indexed_by ::= NOT INDEXED */
+   250,  /* (134) orderby_opt ::= */
+   250,  /* (135) orderby_opt ::= ORDER BY sortlist */
+   232,  /* (136) sortlist ::= sortlist COMMA expr sortorder nulls */
+   232,  /* (137) sortlist ::= expr sortorder nulls */
+   220,  /* (138) sortorder ::= ASC */
+   220,  /* (139) sortorder ::= DESC */
+   220,  /* (140) sortorder ::= */
+   267,  /* (141) nulls ::= NULLS FIRST */
+   267,  /* (142) nulls ::= NULLS LAST */
+   267,  /* (143) nulls ::= */
+   248,  /* (144) groupby_opt ::= */
+   248,  /* (145) groupby_opt ::= GROUP BY nexprlist */
+   249,  /* (146) having_opt ::= */
+   249,  /* (147) having_opt ::= HAVING expr */
+   251,  /* (148) limit_opt ::= */
+   251,  /* (149) limit_opt ::= LIMIT expr */
+   251,  /* (150) limit_opt ::= LIMIT expr OFFSET expr */
+   251,  /* (151) limit_opt ::= LIMIT expr COMMA expr */
+   191,  /* (152) cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */
+   247,  /* (153) where_opt ::= */
+   247,  /* (154) where_opt ::= WHERE expr */
+   269,  /* (155) where_opt_ret ::= */
+   269,  /* (156) where_opt_ret ::= WHERE expr */
+   269,  /* (157) where_opt_ret ::= RETURNING selcollist */
+   269,  /* (158) where_opt_ret ::= WHERE expr RETURNING selcollist */
+   191,  /* (159) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */
+   270,  /* (160) setlist ::= setlist COMMA nm EQ expr */
+   270,  /* (161) setlist ::= setlist COMMA LP idlist RP EQ expr */
+   270,  /* (162) setlist ::= nm EQ expr */
+   270,  /* (163) setlist ::= LP idlist RP EQ expr */
+   191,  /* (164) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
+   191,  /* (165) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */
+   273,  /* (166) upsert ::= */
+   273,  /* (167) upsert ::= RETURNING selcollist */
+   273,  /* (168) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */
+   273,  /* (169) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */
+   273,  /* (170) upsert ::= ON CONFLICT DO NOTHING returning */
+   273,  /* (171) upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */
+   274,  /* (172) returning ::= RETURNING selcollist */
+   271,  /* (173) insert_cmd ::= INSERT orconf */
+   271,  /* (174) insert_cmd ::= REPLACE */
+   272,  /* (175) idlist_opt ::= */
+   272,  /* (176) idlist_opt ::= LP idlist RP */
+   265,  /* (177) idlist ::= idlist COMMA nm */
+   265,  /* (178) idlist ::= nm */
+   218,  /* (179) expr ::= LP expr RP */
+   218,  /* (180) expr ::= ID|INDEXED|JOIN_KW */
+   218,  /* (181) expr ::= nm DOT nm */
+   218,  /* (182) expr ::= nm DOT nm DOT nm */
+   217,  /* (183) term ::= NULL|FLOAT|BLOB */
+   217,  /* (184) term ::= STRING */
+   217,  /* (185) term ::= INTEGER */
+   218,  /* (186) expr ::= VARIABLE */
+   218,  /* (187) expr ::= expr COLLATE ID|STRING */
+   218,  /* (188) expr ::= CAST LP expr AS typetoken RP */
+   218,  /* (189) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */
+   218,  /* (190) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */
+   218,  /* (191) expr ::= ID|INDEXED|JOIN_KW LP STAR RP */
+   218,  /* (192) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */
+   218,  /* (193) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */
+   218,  /* (194) expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */
+   217,  /* (195) term ::= CTIME_KW */
+   218,  /* (196) expr ::= LP nexprlist COMMA expr RP */
+   218,  /* (197) expr ::= expr AND expr */
+   218,  /* (198) expr ::= expr OR expr */
+   218,  /* (199) expr ::= expr LT|GT|GE|LE expr */
+   218,  /* (200) expr ::= expr EQ|NE expr */
+   218,  /* (201) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
+   218,  /* (202) expr ::= expr PLUS|MINUS expr */
+   218,  /* (203) expr ::= expr STAR|SLASH|REM expr */
+   218,  /* (204) expr ::= expr CONCAT expr */
+   276,  /* (205) likeop ::= NOT LIKE_KW|MATCH */
+   218,  /* (206) expr ::= expr likeop expr */
+   218,  /* (207) expr ::= expr likeop expr ESCAPE expr */
+   218,  /* (208) expr ::= expr ISNULL|NOTNULL */
+   218,  /* (209) expr ::= expr NOT NULL */
+   218,  /* (210) expr ::= expr IS expr */
+   218,  /* (211) expr ::= expr IS NOT expr */
+   218,  /* (212) expr ::= expr IS NOT DISTINCT FROM expr */
+   218,  /* (213) expr ::= expr IS DISTINCT FROM expr */
+   218,  /* (214) expr ::= NOT expr */
+   218,  /* (215) expr ::= BITNOT expr */
+   218,  /* (216) expr ::= PLUS|MINUS expr */
+   218,  /* (217) expr ::= expr PTR expr */
+   277,  /* (218) between_op ::= BETWEEN */
+   277,  /* (219) between_op ::= NOT BETWEEN */
+   218,  /* (220) expr ::= expr between_op expr AND expr */
+   278,  /* (221) in_op ::= IN */
+   278,  /* (222) in_op ::= NOT IN */
+   218,  /* (223) expr ::= expr in_op LP exprlist RP */
+   218,  /* (224) expr ::= LP select RP */
+   218,  /* (225) expr ::= expr in_op LP select RP */
+   218,  /* (226) expr ::= expr in_op nm dbnm paren_exprlist */
+   218,  /* (227) expr ::= EXISTS LP select RP */
+   218,  /* (228) expr ::= CASE case_operand case_exprlist case_else END */
+   281,  /* (229) case_exprlist ::= case_exprlist WHEN expr THEN expr */
+   281,  /* (230) case_exprlist ::= WHEN expr THEN expr */
+   282,  /* (231) case_else ::= ELSE expr */
+   282,  /* (232) case_else ::= */
+   280,  /* (233) case_operand ::= */
+   263,  /* (234) exprlist ::= */
+   254,  /* (235) nexprlist ::= nexprlist COMMA expr */
+   254,  /* (236) nexprlist ::= expr */
+   279,  /* (237) paren_exprlist ::= */
+   279,  /* (238) paren_exprlist ::= LP exprlist RP */
+   191,  /* (239) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
+   283,  /* (240) uniqueflag ::= UNIQUE */
+   283,  /* (241) uniqueflag ::= */
+   222,  /* (242) eidlist_opt ::= */
+   222,  /* (243) eidlist_opt ::= LP eidlist RP */
+   233,  /* (244) eidlist ::= eidlist COMMA nm collate sortorder */
+   233,  /* (245) eidlist ::= nm collate sortorder */
+   284,  /* (246) collate ::= */
+   284,  /* (247) collate ::= COLLATE ID|STRING */
+   191,  /* (248) cmd ::= DROP INDEX ifexists fullname */
+   191,  /* (249) cmd ::= VACUUM vinto */
+   191,  /* (250) cmd ::= VACUUM nm vinto */
+   285,  /* (251) vinto ::= INTO expr */
+   285,  /* (252) vinto ::= */
+   191,  /* (253) cmd ::= PRAGMA nm dbnm */
+   191,  /* (254) cmd ::= PRAGMA nm dbnm EQ nmnum */
+   191,  /* (255) cmd ::= PRAGMA nm dbnm LP nmnum RP */
+   191,  /* (256) cmd ::= PRAGMA nm dbnm EQ minus_num */
+   191,  /* (257) cmd ::= PRAGMA nm dbnm LP minus_num RP */
+   212,  /* (258) plus_num ::= PLUS INTEGER|FLOAT */
+   213,  /* (259) minus_num ::= MINUS INTEGER|FLOAT */
+   191,  /* (260) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
+   287,  /* (261) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
+   289,  /* (262) trigger_time ::= BEFORE|AFTER */
+   289,  /* (263) trigger_time ::= INSTEAD OF */
+   289,  /* (264) trigger_time ::= */
+   290,  /* (265) trigger_event ::= DELETE|INSERT */
+   290,  /* (266) trigger_event ::= UPDATE */
+   290,  /* (267) trigger_event ::= UPDATE OF idlist */
+   292,  /* (268) when_clause ::= */
+   292,  /* (269) when_clause ::= WHEN expr */
+   288,  /* (270) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
+   288,  /* (271) trigger_cmd_list ::= trigger_cmd SEMI */
+   294,  /* (272) trnm ::= nm DOT nm */
+   295,  /* (273) tridxby ::= INDEXED BY nm */
+   295,  /* (274) tridxby ::= NOT INDEXED */
+   293,  /* (275) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
+   293,  /* (276) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
+   293,  /* (277) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
+   293,  /* (278) trigger_cmd ::= scanpt select scanpt */
+   218,  /* (279) expr ::= RAISE LP IGNORE RP */
+   218,  /* (280) expr ::= RAISE LP raisetype COMMA nm RP */
+   237,  /* (281) raisetype ::= ROLLBACK */
+   237,  /* (282) raisetype ::= ABORT */
+   237,  /* (283) raisetype ::= FAIL */
+   191,  /* (284) cmd ::= DROP TRIGGER ifexists fullname */
+   191,  /* (285) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
+   191,  /* (286) cmd ::= DETACH database_kw_opt expr */
+   297,  /* (287) key_opt ::= */
+   297,  /* (288) key_opt ::= KEY expr */
+   191,  /* (289) cmd ::= REINDEX */
+   191,  /* (290) cmd ::= REINDEX nm dbnm */
+   191,  /* (291) cmd ::= ANALYZE */
+   191,  /* (292) cmd ::= ANALYZE nm dbnm */
+   191,  /* (293) cmd ::= ALTER TABLE fullname RENAME TO nm */
+   191,  /* (294) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
+   191,  /* (295) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
+   298,  /* (296) add_column_fullname ::= fullname */
+   191,  /* (297) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
+   191,  /* (298) cmd ::= create_vtab */
+   191,  /* (299) cmd ::= create_vtab LP vtabarglist RP */
+   300,  /* (300) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
+   302,  /* (301) vtabarg ::= */
+   303,  /* (302) vtabargtoken ::= ANY */
+   303,  /* (303) vtabargtoken ::= lp anylist RP */
+   304,  /* (304) lp ::= LP */
+   268,  /* (305) with ::= WITH wqlist */
+   268,  /* (306) with ::= WITH RECURSIVE wqlist */
+   307,  /* (307) wqas ::= AS */
+   307,  /* (308) wqas ::= AS MATERIALIZED */
+   307,  /* (309) wqas ::= AS NOT MATERIALIZED */
+   306,  /* (310) wqitem ::= withnm eidlist_opt wqas LP select RP */
+   308,  /* (311) withnm ::= nm */
+   242,  /* (312) wqlist ::= wqitem */
+   242,  /* (313) wqlist ::= wqlist COMMA wqitem */
+   309,  /* (314) windowdefn_list ::= windowdefn_list COMMA windowdefn */
+   310,  /* (315) windowdefn ::= nm AS LP window RP */
+   311,  /* (316) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
+   311,  /* (317) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
+   311,  /* (318) window ::= ORDER BY sortlist frame_opt */
+   311,  /* (319) window ::= nm ORDER BY sortlist frame_opt */
+   311,  /* (320) window ::= nm frame_opt */
+   312,  /* (321) frame_opt ::= */
+   312,  /* (322) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
+   312,  /* (323) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
+   316,  /* (324) range_or_rows ::= RANGE|ROWS|GROUPS */
+   318,  /* (325) frame_bound_s ::= frame_bound */
+   318,  /* (326) frame_bound_s ::= UNBOUNDED PRECEDING */
+   319,  /* (327) frame_bound_e ::= frame_bound */
+   319,  /* (328) frame_bound_e ::= UNBOUNDED FOLLOWING */
+   317,  /* (329) frame_bound ::= expr PRECEDING|FOLLOWING */
+   317,  /* (330) frame_bound ::= CURRENT ROW */
+   320,  /* (331) frame_exclude_opt ::= */
+   320,  /* (332) frame_exclude_opt ::= EXCLUDE frame_exclude */
+   321,  /* (333) frame_exclude ::= NO OTHERS */
+   321,  /* (334) frame_exclude ::= CURRENT ROW */
+   321,  /* (335) frame_exclude ::= GROUP|TIES */
+   252,  /* (336) window_clause ::= WINDOW windowdefn_list */
+   275,  /* (337) filter_over ::= filter_clause over_clause */
+   275,  /* (338) filter_over ::= over_clause */
+   275,  /* (339) filter_over ::= filter_clause */
+   315,  /* (340) over_clause ::= OVER LP window RP */
+   315,  /* (341) over_clause ::= OVER nm */
+   314,  /* (342) filter_clause ::= FILTER LP WHERE expr RP */
+   217,  /* (343) term ::= QNUMBER */
+   186,  /* (344) input ::= cmdlist */
+   187,  /* (345) cmdlist ::= cmdlist ecmd */
+   187,  /* (346) cmdlist ::= ecmd */
+   188,  /* (347) ecmd ::= SEMI */
+   188,  /* (348) ecmd ::= cmdx SEMI */
+   188,  /* (349) ecmd ::= explain cmdx SEMI */
+   193,  /* (350) trans_opt ::= */
+   193,  /* (351) trans_opt ::= TRANSACTION */
+   193,  /* (352) trans_opt ::= TRANSACTION nm */
+   195,  /* (353) savepoint_opt ::= SAVEPOINT */
+   195,  /* (354) savepoint_opt ::= */
+   191,  /* (355) cmd ::= create_table create_table_args */
+   204,  /* (356) table_option_set ::= table_option */
+   202,  /* (357) columnlist ::= columnlist COMMA columnname carglist */
+   202,  /* (358) columnlist ::= columnname carglist */
+   194,  /* (359) nm ::= ID|INDEXED|JOIN_KW */
+   194,  /* (360) nm ::= STRING */
+   209,  /* (361) typetoken ::= typename */
+   210,  /* (362) typename ::= ID|STRING */
+   211,  /* (363) signed ::= plus_num */
+   211,  /* (364) signed ::= minus_num */
+   208,  /* (365) carglist ::= carglist ccons */
+   208,  /* (366) carglist ::= */
+   216,  /* (367) ccons ::= NULL onconf */
+   216,  /* (368) ccons ::= GENERATED ALWAYS AS generated */
+   216,  /* (369) ccons ::= AS generated */
+   203,  /* (370) conslist_opt ::= COMMA conslist */
+   229,  /* (371) conslist ::= conslist tconscomma tcons */
+   229,  /* (372) conslist ::= tcons */
+   230,  /* (373) tconscomma ::= */
+   234,  /* (374) defer_subclause_opt ::= defer_subclause */
+   236,  /* (375) resolvetype ::= raisetype */
+   240,  /* (376) selectnowith ::= oneselect */
+   241,  /* (377) oneselect ::= values */
+   256,  /* (378) sclp ::= selcollist COMMA */
+   257,  /* (379) as ::= ID|STRING */
+   266,  /* (380) indexed_opt ::= indexed_by */
+   274,  /* (381) returning ::= */
+   218,  /* (382) expr ::= term */
+   276,  /* (383) likeop ::= LIKE_KW|MATCH */
+   280,  /* (384) case_operand ::= expr */
+   263,  /* (385) exprlist ::= nexprlist */
+   286,  /* (386) nmnum ::= plus_num */
+   286,  /* (387) nmnum ::= nm */
+   286,  /* (388) nmnum ::= ON */
+   286,  /* (389) nmnum ::= DELETE */
+   286,  /* (390) nmnum ::= DEFAULT */
+   212,  /* (391) plus_num ::= INTEGER|FLOAT */
+   291,  /* (392) foreach_clause ::= */
+   291,  /* (393) foreach_clause ::= FOR EACH ROW */
+   294,  /* (394) trnm ::= nm */
+   295,  /* (395) tridxby ::= */
+   296,  /* (396) database_kw_opt ::= DATABASE */
+   296,  /* (397) database_kw_opt ::= */
+   299,  /* (398) kwcolumn_opt ::= */
+   299,  /* (399) kwcolumn_opt ::= COLUMNKW */
+   301,  /* (400) vtabarglist ::= vtabarg */
+   301,  /* (401) vtabarglist ::= vtabarglist COMMA vtabarg */
+   302,  /* (402) vtabarg ::= vtabarg vtabargtoken */
+   305,  /* (403) anylist ::= */
+   305,  /* (404) anylist ::= anylist LP anylist RP */
+   305,  /* (405) anylist ::= anylist ANY */
+   268,  /* (406) with ::= */
+   309,  /* (407) windowdefn_list ::= windowdefn */
+   311,  /* (408) window ::= frame_opt */
 };
 
 /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number
@@ -174143,316 +175761,320 @@ static const signed char yyRuleInfoNRhs[] = {
    -9,  /* (92) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
   -10,  /* (93) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
    -4,  /* (94) values ::= VALUES LP nexprlist RP */
-   -5,  /* (95) values ::= values COMMA LP nexprlist RP */
-   -1,  /* (96) distinct ::= DISTINCT */
-   -1,  /* (97) distinct ::= ALL */
-    0,  /* (98) distinct ::= */
-    0,  /* (99) sclp ::= */
-   -5,  /* (100) selcollist ::= sclp scanpt expr scanpt as */
-   -3,  /* (101) selcollist ::= sclp scanpt STAR */
-   -5,  /* (102) selcollist ::= sclp scanpt nm DOT STAR */
-   -2,  /* (103) as ::= AS nm */
-    0,  /* (104) as ::= */
-    0,  /* (105) from ::= */
-   -2,  /* (106) from ::= FROM seltablist */
-   -2,  /* (107) stl_prefix ::= seltablist joinop */
-    0,  /* (108) stl_prefix ::= */
-   -5,  /* (109) seltablist ::= stl_prefix nm dbnm as on_using */
-   -6,  /* (110) seltablist ::= stl_prefix nm dbnm as indexed_by on_using */
-   -8,  /* (111) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_using */
-   -6,  /* (112) seltablist ::= stl_prefix LP select RP as on_using */
-   -6,  /* (113) seltablist ::= stl_prefix LP seltablist RP as on_using */
-    0,  /* (114) dbnm ::= */
-   -2,  /* (115) dbnm ::= DOT nm */
-   -1,  /* (116) fullname ::= nm */
-   -3,  /* (117) fullname ::= nm DOT nm */
-   -1,  /* (118) xfullname ::= nm */
-   -3,  /* (119) xfullname ::= nm DOT nm */
-   -5,  /* (120) xfullname ::= nm DOT nm AS nm */
-   -3,  /* (121) xfullname ::= nm AS nm */
-   -1,  /* (122) joinop ::= COMMA|JOIN */
-   -2,  /* (123) joinop ::= JOIN_KW JOIN */
-   -3,  /* (124) joinop ::= JOIN_KW nm JOIN */
-   -4,  /* (125) joinop ::= JOIN_KW nm nm JOIN */
-   -2,  /* (126) on_using ::= ON expr */
-   -4,  /* (127) on_using ::= USING LP idlist RP */
-    0,  /* (128) on_using ::= */
-    0,  /* (129) indexed_opt ::= */
-   -3,  /* (130) indexed_by ::= INDEXED BY nm */
-   -2,  /* (131) indexed_by ::= NOT INDEXED */
-    0,  /* (132) orderby_opt ::= */
-   -3,  /* (133) orderby_opt ::= ORDER BY sortlist */
-   -5,  /* (134) sortlist ::= sortlist COMMA expr sortorder nulls */
-   -3,  /* (135) sortlist ::= expr sortorder nulls */
-   -1,  /* (136) sortorder ::= ASC */
-   -1,  /* (137) sortorder ::= DESC */
-    0,  /* (138) sortorder ::= */
-   -2,  /* (139) nulls ::= NULLS FIRST */
-   -2,  /* (140) nulls ::= NULLS LAST */
-    0,  /* (141) nulls ::= */
-    0,  /* (142) groupby_opt ::= */
-   -3,  /* (143) groupby_opt ::= GROUP BY nexprlist */
-    0,  /* (144) having_opt ::= */
-   -2,  /* (145) having_opt ::= HAVING expr */
-    0,  /* (146) limit_opt ::= */
-   -2,  /* (147) limit_opt ::= LIMIT expr */
-   -4,  /* (148) limit_opt ::= LIMIT expr OFFSET expr */
-   -4,  /* (149) limit_opt ::= LIMIT expr COMMA expr */
-   -6,  /* (150) cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */
-    0,  /* (151) where_opt ::= */
-   -2,  /* (152) where_opt ::= WHERE expr */
-    0,  /* (153) where_opt_ret ::= */
-   -2,  /* (154) where_opt_ret ::= WHERE expr */
-   -2,  /* (155) where_opt_ret ::= RETURNING selcollist */
-   -4,  /* (156) where_opt_ret ::= WHERE expr RETURNING selcollist */
-   -9,  /* (157) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */
-   -5,  /* (158) setlist ::= setlist COMMA nm EQ expr */
-   -7,  /* (159) setlist ::= setlist COMMA LP idlist RP EQ expr */
-   -3,  /* (160) setlist ::= nm EQ expr */
-   -5,  /* (161) setlist ::= LP idlist RP EQ expr */
-   -7,  /* (162) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
-   -8,  /* (163) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */
-    0,  /* (164) upsert ::= */
-   -2,  /* (165) upsert ::= RETURNING selcollist */
-  -12,  /* (166) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */
-   -9,  /* (167) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */
-   -5,  /* (168) upsert ::= ON CONFLICT DO NOTHING returning */
-   -8,  /* (169) upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */
-   -2,  /* (170) returning ::= RETURNING selcollist */
-   -2,  /* (171) insert_cmd ::= INSERT orconf */
-   -1,  /* (172) insert_cmd ::= REPLACE */
-    0,  /* (173) idlist_opt ::= */
-   -3,  /* (174) idlist_opt ::= LP idlist RP */
-   -3,  /* (175) idlist ::= idlist COMMA nm */
-   -1,  /* (176) idlist ::= nm */
-   -3,  /* (177) expr ::= LP expr RP */
-   -1,  /* (178) expr ::= ID|INDEXED|JOIN_KW */
-   -3,  /* (179) expr ::= nm DOT nm */
-   -5,  /* (180) expr ::= nm DOT nm DOT nm */
-   -1,  /* (181) term ::= NULL|FLOAT|BLOB */
-   -1,  /* (182) term ::= STRING */
-   -1,  /* (183) term ::= INTEGER */
-   -1,  /* (184) expr ::= VARIABLE */
-   -3,  /* (185) expr ::= expr COLLATE ID|STRING */
-   -6,  /* (186) expr ::= CAST LP expr AS typetoken RP */
-   -5,  /* (187) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */
-   -8,  /* (188) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */
-   -4,  /* (189) expr ::= ID|INDEXED|JOIN_KW LP STAR RP */
-   -6,  /* (190) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */
-   -9,  /* (191) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */
-   -5,  /* (192) expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */
-   -1,  /* (193) term ::= CTIME_KW */
-   -5,  /* (194) expr ::= LP nexprlist COMMA expr RP */
-   -3,  /* (195) expr ::= expr AND expr */
-   -3,  /* (196) expr ::= expr OR expr */
-   -3,  /* (197) expr ::= expr LT|GT|GE|LE expr */
-   -3,  /* (198) expr ::= expr EQ|NE expr */
-   -3,  /* (199) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
-   -3,  /* (200) expr ::= expr PLUS|MINUS expr */
-   -3,  /* (201) expr ::= expr STAR|SLASH|REM expr */
-   -3,  /* (202) expr ::= expr CONCAT expr */
-   -2,  /* (203) likeop ::= NOT LIKE_KW|MATCH */
-   -3,  /* (204) expr ::= expr likeop expr */
-   -5,  /* (205) expr ::= expr likeop expr ESCAPE expr */
-   -2,  /* (206) expr ::= expr ISNULL|NOTNULL */
-   -3,  /* (207) expr ::= expr NOT NULL */
-   -3,  /* (208) expr ::= expr IS expr */
-   -4,  /* (209) expr ::= expr IS NOT expr */
-   -6,  /* (210) expr ::= expr IS NOT DISTINCT FROM expr */
-   -5,  /* (211) expr ::= expr IS DISTINCT FROM expr */
-   -2,  /* (212) expr ::= NOT expr */
-   -2,  /* (213) expr ::= BITNOT expr */
-   -2,  /* (214) expr ::= PLUS|MINUS expr */
-   -3,  /* (215) expr ::= expr PTR expr */
-   -1,  /* (216) between_op ::= BETWEEN */
-   -2,  /* (217) between_op ::= NOT BETWEEN */
-   -5,  /* (218) expr ::= expr between_op expr AND expr */
-   -1,  /* (219) in_op ::= IN */
-   -2,  /* (220) in_op ::= NOT IN */
-   -5,  /* (221) expr ::= expr in_op LP exprlist RP */
-   -3,  /* (222) expr ::= LP select RP */
-   -5,  /* (223) expr ::= expr in_op LP select RP */
-   -5,  /* (224) expr ::= expr in_op nm dbnm paren_exprlist */
-   -4,  /* (225) expr ::= EXISTS LP select RP */
-   -5,  /* (226) expr ::= CASE case_operand case_exprlist case_else END */
-   -5,  /* (227) case_exprlist ::= case_exprlist WHEN expr THEN expr */
-   -4,  /* (228) case_exprlist ::= WHEN expr THEN expr */
-   -2,  /* (229) case_else ::= ELSE expr */
-    0,  /* (230) case_else ::= */
-    0,  /* (231) case_operand ::= */
-    0,  /* (232) exprlist ::= */
-   -3,  /* (233) nexprlist ::= nexprlist COMMA expr */
-   -1,  /* (234) nexprlist ::= expr */
-    0,  /* (235) paren_exprlist ::= */
-   -3,  /* (236) paren_exprlist ::= LP exprlist RP */
-  -12,  /* (237) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
-   -1,  /* (238) uniqueflag ::= UNIQUE */
-    0,  /* (239) uniqueflag ::= */
-    0,  /* (240) eidlist_opt ::= */
-   -3,  /* (241) eidlist_opt ::= LP eidlist RP */
-   -5,  /* (242) eidlist ::= eidlist COMMA nm collate sortorder */
-   -3,  /* (243) eidlist ::= nm collate sortorder */
-    0,  /* (244) collate ::= */
-   -2,  /* (245) collate ::= COLLATE ID|STRING */
-   -4,  /* (246) cmd ::= DROP INDEX ifexists fullname */
-   -2,  /* (247) cmd ::= VACUUM vinto */
-   -3,  /* (248) cmd ::= VACUUM nm vinto */
-   -2,  /* (249) vinto ::= INTO expr */
-    0,  /* (250) vinto ::= */
-   -3,  /* (251) cmd ::= PRAGMA nm dbnm */
-   -5,  /* (252) cmd ::= PRAGMA nm dbnm EQ nmnum */
-   -6,  /* (253) cmd ::= PRAGMA nm dbnm LP nmnum RP */
-   -5,  /* (254) cmd ::= PRAGMA nm dbnm EQ minus_num */
-   -6,  /* (255) cmd ::= PRAGMA nm dbnm LP minus_num RP */
-   -2,  /* (256) plus_num ::= PLUS INTEGER|FLOAT */
-   -2,  /* (257) minus_num ::= MINUS INTEGER|FLOAT */
-   -5,  /* (258) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
-  -11,  /* (259) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
-   -1,  /* (260) trigger_time ::= BEFORE|AFTER */
-   -2,  /* (261) trigger_time ::= INSTEAD OF */
-    0,  /* (262) trigger_time ::= */
-   -1,  /* (263) trigger_event ::= DELETE|INSERT */
-   -1,  /* (264) trigger_event ::= UPDATE */
-   -3,  /* (265) trigger_event ::= UPDATE OF idlist */
-    0,  /* (266) when_clause ::= */
-   -2,  /* (267) when_clause ::= WHEN expr */
-   -3,  /* (268) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
-   -2,  /* (269) trigger_cmd_list ::= trigger_cmd SEMI */
-   -3,  /* (270) trnm ::= nm DOT nm */
-   -3,  /* (271) tridxby ::= INDEXED BY nm */
-   -2,  /* (272) tridxby ::= NOT INDEXED */
-   -9,  /* (273) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
-   -8,  /* (274) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
-   -6,  /* (275) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
-   -3,  /* (276) trigger_cmd ::= scanpt select scanpt */
-   -4,  /* (277) expr ::= RAISE LP IGNORE RP */
-   -6,  /* (278) expr ::= RAISE LP raisetype COMMA nm RP */
-   -1,  /* (279) raisetype ::= ROLLBACK */
-   -1,  /* (280) raisetype ::= ABORT */
-   -1,  /* (281) raisetype ::= FAIL */
-   -4,  /* (282) cmd ::= DROP TRIGGER ifexists fullname */
-   -6,  /* (283) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
-   -3,  /* (284) cmd ::= DETACH database_kw_opt expr */
-    0,  /* (285) key_opt ::= */
-   -2,  /* (286) key_opt ::= KEY expr */
-   -1,  /* (287) cmd ::= REINDEX */
-   -3,  /* (288) cmd ::= REINDEX nm dbnm */
-   -1,  /* (289) cmd ::= ANALYZE */
-   -3,  /* (290) cmd ::= ANALYZE nm dbnm */
-   -6,  /* (291) cmd ::= ALTER TABLE fullname RENAME TO nm */
-   -7,  /* (292) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
-   -6,  /* (293) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
-   -1,  /* (294) add_column_fullname ::= fullname */
-   -8,  /* (295) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
-   -1,  /* (296) cmd ::= create_vtab */
-   -4,  /* (297) cmd ::= create_vtab LP vtabarglist RP */
-   -8,  /* (298) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
-    0,  /* (299) vtabarg ::= */
-   -1,  /* (300) vtabargtoken ::= ANY */
-   -3,  /* (301) vtabargtoken ::= lp anylist RP */
-   -1,  /* (302) lp ::= LP */
-   -2,  /* (303) with ::= WITH wqlist */
-   -3,  /* (304) with ::= WITH RECURSIVE wqlist */
-   -1,  /* (305) wqas ::= AS */
-   -2,  /* (306) wqas ::= AS MATERIALIZED */
-   -3,  /* (307) wqas ::= AS NOT MATERIALIZED */
-   -6,  /* (308) wqitem ::= nm eidlist_opt wqas LP select RP */
-   -1,  /* (309) wqlist ::= wqitem */
-   -3,  /* (310) wqlist ::= wqlist COMMA wqitem */
-   -3,  /* (311) windowdefn_list ::= windowdefn_list COMMA windowdefn */
-   -5,  /* (312) windowdefn ::= nm AS LP window RP */
-   -5,  /* (313) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
-   -6,  /* (314) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
-   -4,  /* (315) window ::= ORDER BY sortlist frame_opt */
-   -5,  /* (316) window ::= nm ORDER BY sortlist frame_opt */
-   -2,  /* (317) window ::= nm frame_opt */
-    0,  /* (318) frame_opt ::= */
-   -3,  /* (319) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
-   -6,  /* (320) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
-   -1,  /* (321) range_or_rows ::= RANGE|ROWS|GROUPS */
-   -1,  /* (322) frame_bound_s ::= frame_bound */
-   -2,  /* (323) frame_bound_s ::= UNBOUNDED PRECEDING */
-   -1,  /* (324) frame_bound_e ::= frame_bound */
-   -2,  /* (325) frame_bound_e ::= UNBOUNDED FOLLOWING */
-   -2,  /* (326) frame_bound ::= expr PRECEDING|FOLLOWING */
-   -2,  /* (327) frame_bound ::= CURRENT ROW */
-    0,  /* (328) frame_exclude_opt ::= */
-   -2,  /* (329) frame_exclude_opt ::= EXCLUDE frame_exclude */
-   -2,  /* (330) frame_exclude ::= NO OTHERS */
-   -2,  /* (331) frame_exclude ::= CURRENT ROW */
-   -1,  /* (332) frame_exclude ::= GROUP|TIES */
-   -2,  /* (333) window_clause ::= WINDOW windowdefn_list */
-   -2,  /* (334) filter_over ::= filter_clause over_clause */
-   -1,  /* (335) filter_over ::= over_clause */
-   -1,  /* (336) filter_over ::= filter_clause */
-   -4,  /* (337) over_clause ::= OVER LP window RP */
-   -2,  /* (338) over_clause ::= OVER nm */
-   -5,  /* (339) filter_clause ::= FILTER LP WHERE expr RP */
-   -1,  /* (340) input ::= cmdlist */
-   -2,  /* (341) cmdlist ::= cmdlist ecmd */
-   -1,  /* (342) cmdlist ::= ecmd */
-   -1,  /* (343) ecmd ::= SEMI */
-   -2,  /* (344) ecmd ::= cmdx SEMI */
-   -3,  /* (345) ecmd ::= explain cmdx SEMI */
-    0,  /* (346) trans_opt ::= */
-   -1,  /* (347) trans_opt ::= TRANSACTION */
-   -2,  /* (348) trans_opt ::= TRANSACTION nm */
-   -1,  /* (349) savepoint_opt ::= SAVEPOINT */
-    0,  /* (350) savepoint_opt ::= */
-   -2,  /* (351) cmd ::= create_table create_table_args */
-   -1,  /* (352) table_option_set ::= table_option */
-   -4,  /* (353) columnlist ::= columnlist COMMA columnname carglist */
-   -2,  /* (354) columnlist ::= columnname carglist */
-   -1,  /* (355) nm ::= ID|INDEXED|JOIN_KW */
-   -1,  /* (356) nm ::= STRING */
-   -1,  /* (357) typetoken ::= typename */
-   -1,  /* (358) typename ::= ID|STRING */
-   -1,  /* (359) signed ::= plus_num */
-   -1,  /* (360) signed ::= minus_num */
-   -2,  /* (361) carglist ::= carglist ccons */
-    0,  /* (362) carglist ::= */
-   -2,  /* (363) ccons ::= NULL onconf */
-   -4,  /* (364) ccons ::= GENERATED ALWAYS AS generated */
-   -2,  /* (365) ccons ::= AS generated */
-   -2,  /* (366) conslist_opt ::= COMMA conslist */
-   -3,  /* (367) conslist ::= conslist tconscomma tcons */
-   -1,  /* (368) conslist ::= tcons */
-    0,  /* (369) tconscomma ::= */
-   -1,  /* (370) defer_subclause_opt ::= defer_subclause */
-   -1,  /* (371) resolvetype ::= raisetype */
-   -1,  /* (372) selectnowith ::= oneselect */
-   -1,  /* (373) oneselect ::= values */
-   -2,  /* (374) sclp ::= selcollist COMMA */
-   -1,  /* (375) as ::= ID|STRING */
-   -1,  /* (376) indexed_opt ::= indexed_by */
-    0,  /* (377) returning ::= */
-   -1,  /* (378) expr ::= term */
-   -1,  /* (379) likeop ::= LIKE_KW|MATCH */
-   -1,  /* (380) case_operand ::= expr */
-   -1,  /* (381) exprlist ::= nexprlist */
-   -1,  /* (382) nmnum ::= plus_num */
-   -1,  /* (383) nmnum ::= nm */
-   -1,  /* (384) nmnum ::= ON */
-   -1,  /* (385) nmnum ::= DELETE */
-   -1,  /* (386) nmnum ::= DEFAULT */
-   -1,  /* (387) plus_num ::= INTEGER|FLOAT */
-    0,  /* (388) foreach_clause ::= */
-   -3,  /* (389) foreach_clause ::= FOR EACH ROW */
-   -1,  /* (390) trnm ::= nm */
-    0,  /* (391) tridxby ::= */
-   -1,  /* (392) database_kw_opt ::= DATABASE */
-    0,  /* (393) database_kw_opt ::= */
-    0,  /* (394) kwcolumn_opt ::= */
-   -1,  /* (395) kwcolumn_opt ::= COLUMNKW */
-   -1,  /* (396) vtabarglist ::= vtabarg */
-   -3,  /* (397) vtabarglist ::= vtabarglist COMMA vtabarg */
-   -2,  /* (398) vtabarg ::= vtabarg vtabargtoken */
-    0,  /* (399) anylist ::= */
-   -4,  /* (400) anylist ::= anylist LP anylist RP */
-   -2,  /* (401) anylist ::= anylist ANY */
-    0,  /* (402) with ::= */
-   -1,  /* (403) windowdefn_list ::= windowdefn */
-   -1,  /* (404) window ::= frame_opt */
+   -1,  /* (95) oneselect ::= mvalues */
+   -5,  /* (96) mvalues ::= values COMMA LP nexprlist RP */
+   -5,  /* (97) mvalues ::= mvalues COMMA LP nexprlist RP */
+   -1,  /* (98) distinct ::= DISTINCT */
+   -1,  /* (99) distinct ::= ALL */
+    0,  /* (100) distinct ::= */
+    0,  /* (101) sclp ::= */
+   -5,  /* (102) selcollist ::= sclp scanpt expr scanpt as */
+   -3,  /* (103) selcollist ::= sclp scanpt STAR */
+   -5,  /* (104) selcollist ::= sclp scanpt nm DOT STAR */
+   -2,  /* (105) as ::= AS nm */
+    0,  /* (106) as ::= */
+    0,  /* (107) from ::= */
+   -2,  /* (108) from ::= FROM seltablist */
+   -2,  /* (109) stl_prefix ::= seltablist joinop */
+    0,  /* (110) stl_prefix ::= */
+   -5,  /* (111) seltablist ::= stl_prefix nm dbnm as on_using */
+   -6,  /* (112) seltablist ::= stl_prefix nm dbnm as indexed_by on_using */
+   -8,  /* (113) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_using */
+   -6,  /* (114) seltablist ::= stl_prefix LP select RP as on_using */
+   -6,  /* (115) seltablist ::= stl_prefix LP seltablist RP as on_using */
+    0,  /* (116) dbnm ::= */
+   -2,  /* (117) dbnm ::= DOT nm */
+   -1,  /* (118) fullname ::= nm */
+   -3,  /* (119) fullname ::= nm DOT nm */
+   -1,  /* (120) xfullname ::= nm */
+   -3,  /* (121) xfullname ::= nm DOT nm */
+   -5,  /* (122) xfullname ::= nm DOT nm AS nm */
+   -3,  /* (123) xfullname ::= nm AS nm */
+   -1,  /* (124) joinop ::= COMMA|JOIN */
+   -2,  /* (125) joinop ::= JOIN_KW JOIN */
+   -3,  /* (126) joinop ::= JOIN_KW nm JOIN */
+   -4,  /* (127) joinop ::= JOIN_KW nm nm JOIN */
+   -2,  /* (128) on_using ::= ON expr */
+   -4,  /* (129) on_using ::= USING LP idlist RP */
+    0,  /* (130) on_using ::= */
+    0,  /* (131) indexed_opt ::= */
+   -3,  /* (132) indexed_by ::= INDEXED BY nm */
+   -2,  /* (133) indexed_by ::= NOT INDEXED */
+    0,  /* (134) orderby_opt ::= */
+   -3,  /* (135) orderby_opt ::= ORDER BY sortlist */
+   -5,  /* (136) sortlist ::= sortlist COMMA expr sortorder nulls */
+   -3,  /* (137) sortlist ::= expr sortorder nulls */
+   -1,  /* (138) sortorder ::= ASC */
+   -1,  /* (139) sortorder ::= DESC */
+    0,  /* (140) sortorder ::= */
+   -2,  /* (141) nulls ::= NULLS FIRST */
+   -2,  /* (142) nulls ::= NULLS LAST */
+    0,  /* (143) nulls ::= */
+    0,  /* (144) groupby_opt ::= */
+   -3,  /* (145) groupby_opt ::= GROUP BY nexprlist */
+    0,  /* (146) having_opt ::= */
+   -2,  /* (147) having_opt ::= HAVING expr */
+    0,  /* (148) limit_opt ::= */
+   -2,  /* (149) limit_opt ::= LIMIT expr */
+   -4,  /* (150) limit_opt ::= LIMIT expr OFFSET expr */
+   -4,  /* (151) limit_opt ::= LIMIT expr COMMA expr */
+   -6,  /* (152) cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */
+    0,  /* (153) where_opt ::= */
+   -2,  /* (154) where_opt ::= WHERE expr */
+    0,  /* (155) where_opt_ret ::= */
+   -2,  /* (156) where_opt_ret ::= WHERE expr */
+   -2,  /* (157) where_opt_ret ::= RETURNING selcollist */
+   -4,  /* (158) where_opt_ret ::= WHERE expr RETURNING selcollist */
+   -9,  /* (159) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */
+   -5,  /* (160) setlist ::= setlist COMMA nm EQ expr */
+   -7,  /* (161) setlist ::= setlist COMMA LP idlist RP EQ expr */
+   -3,  /* (162) setlist ::= nm EQ expr */
+   -5,  /* (163) setlist ::= LP idlist RP EQ expr */
+   -7,  /* (164) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
+   -8,  /* (165) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */
+    0,  /* (166) upsert ::= */
+   -2,  /* (167) upsert ::= RETURNING selcollist */
+  -12,  /* (168) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */
+   -9,  /* (169) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */
+   -5,  /* (170) upsert ::= ON CONFLICT DO NOTHING returning */
+   -8,  /* (171) upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */
+   -2,  /* (172) returning ::= RETURNING selcollist */
+   -2,  /* (173) insert_cmd ::= INSERT orconf */
+   -1,  /* (174) insert_cmd ::= REPLACE */
+    0,  /* (175) idlist_opt ::= */
+   -3,  /* (176) idlist_opt ::= LP idlist RP */
+   -3,  /* (177) idlist ::= idlist COMMA nm */
+   -1,  /* (178) idlist ::= nm */
+   -3,  /* (179) expr ::= LP expr RP */
+   -1,  /* (180) expr ::= ID|INDEXED|JOIN_KW */
+   -3,  /* (181) expr ::= nm DOT nm */
+   -5,  /* (182) expr ::= nm DOT nm DOT nm */
+   -1,  /* (183) term ::= NULL|FLOAT|BLOB */
+   -1,  /* (184) term ::= STRING */
+   -1,  /* (185) term ::= INTEGER */
+   -1,  /* (186) expr ::= VARIABLE */
+   -3,  /* (187) expr ::= expr COLLATE ID|STRING */
+   -6,  /* (188) expr ::= CAST LP expr AS typetoken RP */
+   -5,  /* (189) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */
+   -8,  /* (190) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */
+   -4,  /* (191) expr ::= ID|INDEXED|JOIN_KW LP STAR RP */
+   -6,  /* (192) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */
+   -9,  /* (193) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */
+   -5,  /* (194) expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */
+   -1,  /* (195) term ::= CTIME_KW */
+   -5,  /* (196) expr ::= LP nexprlist COMMA expr RP */
+   -3,  /* (197) expr ::= expr AND expr */
+   -3,  /* (198) expr ::= expr OR expr */
+   -3,  /* (199) expr ::= expr LT|GT|GE|LE expr */
+   -3,  /* (200) expr ::= expr EQ|NE expr */
+   -3,  /* (201) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
+   -3,  /* (202) expr ::= expr PLUS|MINUS expr */
+   -3,  /* (203) expr ::= expr STAR|SLASH|REM expr */
+   -3,  /* (204) expr ::= expr CONCAT expr */
+   -2,  /* (205) likeop ::= NOT LIKE_KW|MATCH */
+   -3,  /* (206) expr ::= expr likeop expr */
+   -5,  /* (207) expr ::= expr likeop expr ESCAPE expr */
+   -2,  /* (208) expr ::= expr ISNULL|NOTNULL */
+   -3,  /* (209) expr ::= expr NOT NULL */
+   -3,  /* (210) expr ::= expr IS expr */
+   -4,  /* (211) expr ::= expr IS NOT expr */
+   -6,  /* (212) expr ::= expr IS NOT DISTINCT FROM expr */
+   -5,  /* (213) expr ::= expr IS DISTINCT FROM expr */
+   -2,  /* (214) expr ::= NOT expr */
+   -2,  /* (215) expr ::= BITNOT expr */
+   -2,  /* (216) expr ::= PLUS|MINUS expr */
+   -3,  /* (217) expr ::= expr PTR expr */
+   -1,  /* (218) between_op ::= BETWEEN */
+   -2,  /* (219) between_op ::= NOT BETWEEN */
+   -5,  /* (220) expr ::= expr between_op expr AND expr */
+   -1,  /* (221) in_op ::= IN */
+   -2,  /* (222) in_op ::= NOT IN */
+   -5,  /* (223) expr ::= expr in_op LP exprlist RP */
+   -3,  /* (224) expr ::= LP select RP */
+   -5,  /* (225) expr ::= expr in_op LP select RP */
+   -5,  /* (226) expr ::= expr in_op nm dbnm paren_exprlist */
+   -4,  /* (227) expr ::= EXISTS LP select RP */
+   -5,  /* (228) expr ::= CASE case_operand case_exprlist case_else END */
+   -5,  /* (229) case_exprlist ::= case_exprlist WHEN expr THEN expr */
+   -4,  /* (230) case_exprlist ::= WHEN expr THEN expr */
+   -2,  /* (231) case_else ::= ELSE expr */
+    0,  /* (232) case_else ::= */
+    0,  /* (233) case_operand ::= */
+    0,  /* (234) exprlist ::= */
+   -3,  /* (235) nexprlist ::= nexprlist COMMA expr */
+   -1,  /* (236) nexprlist ::= expr */
+    0,  /* (237) paren_exprlist ::= */
+   -3,  /* (238) paren_exprlist ::= LP exprlist RP */
+  -12,  /* (239) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
+   -1,  /* (240) uniqueflag ::= UNIQUE */
+    0,  /* (241) uniqueflag ::= */
+    0,  /* (242) eidlist_opt ::= */
+   -3,  /* (243) eidlist_opt ::= LP eidlist RP */
+   -5,  /* (244) eidlist ::= eidlist COMMA nm collate sortorder */
+   -3,  /* (245) eidlist ::= nm collate sortorder */
+    0,  /* (246) collate ::= */
+   -2,  /* (247) collate ::= COLLATE ID|STRING */
+   -4,  /* (248) cmd ::= DROP INDEX ifexists fullname */
+   -2,  /* (249) cmd ::= VACUUM vinto */
+   -3,  /* (250) cmd ::= VACUUM nm vinto */
+   -2,  /* (251) vinto ::= INTO expr */
+    0,  /* (252) vinto ::= */
+   -3,  /* (253) cmd ::= PRAGMA nm dbnm */
+   -5,  /* (254) cmd ::= PRAGMA nm dbnm EQ nmnum */
+   -6,  /* (255) cmd ::= PRAGMA nm dbnm LP nmnum RP */
+   -5,  /* (256) cmd ::= PRAGMA nm dbnm EQ minus_num */
+   -6,  /* (257) cmd ::= PRAGMA nm dbnm LP minus_num RP */
+   -2,  /* (258) plus_num ::= PLUS INTEGER|FLOAT */
+   -2,  /* (259) minus_num ::= MINUS INTEGER|FLOAT */
+   -5,  /* (260) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
+  -11,  /* (261) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
+   -1,  /* (262) trigger_time ::= BEFORE|AFTER */
+   -2,  /* (263) trigger_time ::= INSTEAD OF */
+    0,  /* (264) trigger_time ::= */
+   -1,  /* (265) trigger_event ::= DELETE|INSERT */
+   -1,  /* (266) trigger_event ::= UPDATE */
+   -3,  /* (267) trigger_event ::= UPDATE OF idlist */
+    0,  /* (268) when_clause ::= */
+   -2,  /* (269) when_clause ::= WHEN expr */
+   -3,  /* (270) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
+   -2,  /* (271) trigger_cmd_list ::= trigger_cmd SEMI */
+   -3,  /* (272) trnm ::= nm DOT nm */
+   -3,  /* (273) tridxby ::= INDEXED BY nm */
+   -2,  /* (274) tridxby ::= NOT INDEXED */
+   -9,  /* (275) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
+   -8,  /* (276) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
+   -6,  /* (277) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
+   -3,  /* (278) trigger_cmd ::= scanpt select scanpt */
+   -4,  /* (279) expr ::= RAISE LP IGNORE RP */
+   -6,  /* (280) expr ::= RAISE LP raisetype COMMA nm RP */
+   -1,  /* (281) raisetype ::= ROLLBACK */
+   -1,  /* (282) raisetype ::= ABORT */
+   -1,  /* (283) raisetype ::= FAIL */
+   -4,  /* (284) cmd ::= DROP TRIGGER ifexists fullname */
+   -6,  /* (285) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
+   -3,  /* (286) cmd ::= DETACH database_kw_opt expr */
+    0,  /* (287) key_opt ::= */
+   -2,  /* (288) key_opt ::= KEY expr */
+   -1,  /* (289) cmd ::= REINDEX */
+   -3,  /* (290) cmd ::= REINDEX nm dbnm */
+   -1,  /* (291) cmd ::= ANALYZE */
+   -3,  /* (292) cmd ::= ANALYZE nm dbnm */
+   -6,  /* (293) cmd ::= ALTER TABLE fullname RENAME TO nm */
+   -7,  /* (294) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
+   -6,  /* (295) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
+   -1,  /* (296) add_column_fullname ::= fullname */
+   -8,  /* (297) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
+   -1,  /* (298) cmd ::= create_vtab */
+   -4,  /* (299) cmd ::= create_vtab LP vtabarglist RP */
+   -8,  /* (300) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
+    0,  /* (301) vtabarg ::= */
+   -1,  /* (302) vtabargtoken ::= ANY */
+   -3,  /* (303) vtabargtoken ::= lp anylist RP */
+   -1,  /* (304) lp ::= LP */
+   -2,  /* (305) with ::= WITH wqlist */
+   -3,  /* (306) with ::= WITH RECURSIVE wqlist */
+   -1,  /* (307) wqas ::= AS */
+   -2,  /* (308) wqas ::= AS MATERIALIZED */
+   -3,  /* (309) wqas ::= AS NOT MATERIALIZED */
+   -6,  /* (310) wqitem ::= withnm eidlist_opt wqas LP select RP */
+   -1,  /* (311) withnm ::= nm */
+   -1,  /* (312) wqlist ::= wqitem */
+   -3,  /* (313) wqlist ::= wqlist COMMA wqitem */
+   -3,  /* (314) windowdefn_list ::= windowdefn_list COMMA windowdefn */
+   -5,  /* (315) windowdefn ::= nm AS LP window RP */
+   -5,  /* (316) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
+   -6,  /* (317) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
+   -4,  /* (318) window ::= ORDER BY sortlist frame_opt */
+   -5,  /* (319) window ::= nm ORDER BY sortlist frame_opt */
+   -2,  /* (320) window ::= nm frame_opt */
+    0,  /* (321) frame_opt ::= */
+   -3,  /* (322) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
+   -6,  /* (323) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
+   -1,  /* (324) range_or_rows ::= RANGE|ROWS|GROUPS */
+   -1,  /* (325) frame_bound_s ::= frame_bound */
+   -2,  /* (326) frame_bound_s ::= UNBOUNDED PRECEDING */
+   -1,  /* (327) frame_bound_e ::= frame_bound */
+   -2,  /* (328) frame_bound_e ::= UNBOUNDED FOLLOWING */
+   -2,  /* (329) frame_bound ::= expr PRECEDING|FOLLOWING */
+   -2,  /* (330) frame_bound ::= CURRENT ROW */
+    0,  /* (331) frame_exclude_opt ::= */
+   -2,  /* (332) frame_exclude_opt ::= EXCLUDE frame_exclude */
+   -2,  /* (333) frame_exclude ::= NO OTHERS */
+   -2,  /* (334) frame_exclude ::= CURRENT ROW */
+   -1,  /* (335) frame_exclude ::= GROUP|TIES */
+   -2,  /* (336) window_clause ::= WINDOW windowdefn_list */
+   -2,  /* (337) filter_over ::= filter_clause over_clause */
+   -1,  /* (338) filter_over ::= over_clause */
+   -1,  /* (339) filter_over ::= filter_clause */
+   -4,  /* (340) over_clause ::= OVER LP window RP */
+   -2,  /* (341) over_clause ::= OVER nm */
+   -5,  /* (342) filter_clause ::= FILTER LP WHERE expr RP */
+   -1,  /* (343) term ::= QNUMBER */
+   -1,  /* (344) input ::= cmdlist */
+   -2,  /* (345) cmdlist ::= cmdlist ecmd */
+   -1,  /* (346) cmdlist ::= ecmd */
+   -1,  /* (347) ecmd ::= SEMI */
+   -2,  /* (348) ecmd ::= cmdx SEMI */
+   -3,  /* (349) ecmd ::= explain cmdx SEMI */
+    0,  /* (350) trans_opt ::= */
+   -1,  /* (351) trans_opt ::= TRANSACTION */
+   -2,  /* (352) trans_opt ::= TRANSACTION nm */
+   -1,  /* (353) savepoint_opt ::= SAVEPOINT */
+    0,  /* (354) savepoint_opt ::= */
+   -2,  /* (355) cmd ::= create_table create_table_args */
+   -1,  /* (356) table_option_set ::= table_option */
+   -4,  /* (357) columnlist ::= columnlist COMMA columnname carglist */
+   -2,  /* (358) columnlist ::= columnname carglist */
+   -1,  /* (359) nm ::= ID|INDEXED|JOIN_KW */
+   -1,  /* (360) nm ::= STRING */
+   -1,  /* (361) typetoken ::= typename */
+   -1,  /* (362) typename ::= ID|STRING */
+   -1,  /* (363) signed ::= plus_num */
+   -1,  /* (364) signed ::= minus_num */
+   -2,  /* (365) carglist ::= carglist ccons */
+    0,  /* (366) carglist ::= */
+   -2,  /* (367) ccons ::= NULL onconf */
+   -4,  /* (368) ccons ::= GENERATED ALWAYS AS generated */
+   -2,  /* (369) ccons ::= AS generated */
+   -2,  /* (370) conslist_opt ::= COMMA conslist */
+   -3,  /* (371) conslist ::= conslist tconscomma tcons */
+   -1,  /* (372) conslist ::= tcons */
+    0,  /* (373) tconscomma ::= */
+   -1,  /* (374) defer_subclause_opt ::= defer_subclause */
+   -1,  /* (375) resolvetype ::= raisetype */
+   -1,  /* (376) selectnowith ::= oneselect */
+   -1,  /* (377) oneselect ::= values */
+   -2,  /* (378) sclp ::= selcollist COMMA */
+   -1,  /* (379) as ::= ID|STRING */
+   -1,  /* (380) indexed_opt ::= indexed_by */
+    0,  /* (381) returning ::= */
+   -1,  /* (382) expr ::= term */
+   -1,  /* (383) likeop ::= LIKE_KW|MATCH */
+   -1,  /* (384) case_operand ::= expr */
+   -1,  /* (385) exprlist ::= nexprlist */
+   -1,  /* (386) nmnum ::= plus_num */
+   -1,  /* (387) nmnum ::= nm */
+   -1,  /* (388) nmnum ::= ON */
+   -1,  /* (389) nmnum ::= DELETE */
+   -1,  /* (390) nmnum ::= DEFAULT */
+   -1,  /* (391) plus_num ::= INTEGER|FLOAT */
+    0,  /* (392) foreach_clause ::= */
+   -3,  /* (393) foreach_clause ::= FOR EACH ROW */
+   -1,  /* (394) trnm ::= nm */
+    0,  /* (395) tridxby ::= */
+   -1,  /* (396) database_kw_opt ::= DATABASE */
+    0,  /* (397) database_kw_opt ::= */
+    0,  /* (398) kwcolumn_opt ::= */
+   -1,  /* (399) kwcolumn_opt ::= COLUMNKW */
+   -1,  /* (400) vtabarglist ::= vtabarg */
+   -3,  /* (401) vtabarglist ::= vtabarglist COMMA vtabarg */
+   -2,  /* (402) vtabarg ::= vtabarg vtabargtoken */
+    0,  /* (403) anylist ::= */
+   -4,  /* (404) anylist ::= anylist LP anylist RP */
+   -2,  /* (405) anylist ::= anylist ANY */
+    0,  /* (406) with ::= */
+   -1,  /* (407) windowdefn_list ::= windowdefn */
+   -1,  /* (408) window ::= frame_opt */
 };
 
 static void yy_accept(yyParser*);  /* Forward Declaration */
@@ -174504,16 +176126,16 @@ static YYACTIONTYPE yy_reduce(
 { sqlite3FinishCoding(pParse); }
         break;
       case 3: /* cmd ::= BEGIN transtype trans_opt */
-{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy394);}
+{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy144);}
         break;
       case 4: /* transtype ::= */
-{yymsp[1].minor.yy394 = TK_DEFERRED;}
+{yymsp[1].minor.yy144 = TK_DEFERRED;}
         break;
       case 5: /* transtype ::= DEFERRED */
       case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
       case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
-      case 321: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==321);
-{yymsp[0].minor.yy394 = yymsp[0].major; /*A-overwrites-X*/}
+      case 324: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==324);
+{yymsp[0].minor.yy144 = yymsp[0].major; /*A-overwrites-X*/}
         break;
       case 8: /* cmd ::= COMMIT|END trans_opt */
       case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9);
@@ -174536,7 +176158,7 @@ static YYACTIONTYPE yy_reduce(
         break;
       case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
 {
-   sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy394,0,0,yymsp[-2].minor.yy394);
+   sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy144,0,0,yymsp[-2].minor.yy144);
 }
         break;
       case 14: /* createkw ::= CREATE */
@@ -174548,40 +176170,40 @@ static YYACTIONTYPE yy_reduce(
       case 62: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==62);
       case 72: /* defer_subclause_opt ::= */ yytestcase(yyruleno==72);
       case 81: /* ifexists ::= */ yytestcase(yyruleno==81);
-      case 98: /* distinct ::= */ yytestcase(yyruleno==98);
-      case 244: /* collate ::= */ yytestcase(yyruleno==244);
-{yymsp[1].minor.yy394 = 0;}
+      case 100: /* distinct ::= */ yytestcase(yyruleno==100);
+      case 246: /* collate ::= */ yytestcase(yyruleno==246);
+{yymsp[1].minor.yy144 = 0;}
         break;
       case 16: /* ifnotexists ::= IF NOT EXISTS */
-{yymsp[-2].minor.yy394 = 1;}
+{yymsp[-2].minor.yy144 = 1;}
         break;
       case 17: /* temp ::= TEMP */
-{yymsp[0].minor.yy394 = pParse->db->init.busy==0;}
+{yymsp[0].minor.yy144 = pParse->db->init.busy==0;}
         break;
       case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_option_set */
 {
-  sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy285,0);
+  sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy391,0);
 }
         break;
       case 20: /* create_table_args ::= AS select */
 {
-  sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy47);
-  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy47);
+  sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy555);
+  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy555);
 }
         break;
       case 21: /* table_option_set ::= */
-{yymsp[1].minor.yy285 = 0;}
+{yymsp[1].minor.yy391 = 0;}
         break;
       case 22: /* table_option_set ::= table_option_set COMMA table_option */
-{yylhsminor.yy285 = yymsp[-2].minor.yy285|yymsp[0].minor.yy285;}
-  yymsp[-2].minor.yy285 = yylhsminor.yy285;
+{yylhsminor.yy391 = yymsp[-2].minor.yy391|yymsp[0].minor.yy391;}
+  yymsp[-2].minor.yy391 = yylhsminor.yy391;
         break;
       case 23: /* table_option ::= WITHOUT nm */
 {
   if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
-    yymsp[-1].minor.yy285 = TF_WithoutRowid | TF_NoVisibleRowid;
+    yymsp[-1].minor.yy391 = TF_WithoutRowid | TF_NoVisibleRowid;
   }else{
-    yymsp[-1].minor.yy285 = 0;
+    yymsp[-1].minor.yy391 = 0;
     sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
   }
 }
@@ -174589,20 +176211,20 @@ static YYACTIONTYPE yy_reduce(
       case 24: /* table_option ::= nm */
 {
   if( yymsp[0].minor.yy0.n==6 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"strict",6)==0 ){
-    yylhsminor.yy285 = TF_Strict;
+    yylhsminor.yy391 = TF_Strict;
   }else{
-    yylhsminor.yy285 = 0;
+    yylhsminor.yy391 = 0;
     sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
   }
 }
-  yymsp[0].minor.yy285 = yylhsminor.yy285;
+  yymsp[0].minor.yy391 = yylhsminor.yy391;
         break;
       case 25: /* columnname ::= nm typetoken */
 {sqlite3AddColumn(pParse,yymsp[-1].minor.yy0,yymsp[0].minor.yy0);}
         break;
       case 26: /* typetoken ::= */
       case 65: /* conslist_opt ::= */ yytestcase(yyruleno==65);
-      case 104: /* as ::= */ yytestcase(yyruleno==104);
+      case 106: /* as ::= */ yytestcase(yyruleno==106);
 {yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = 0;}
         break;
       case 27: /* typetoken ::= typename LP signed RP */
@@ -174621,7 +176243,7 @@ static YYACTIONTYPE yy_reduce(
       case 30: /* scanpt ::= */
 {
   assert( yyLookahead!=YYNOCODE );
-  yymsp[1].minor.yy522 = yyLookaheadToken.z;
+  yymsp[1].minor.yy168 = yyLookaheadToken.z;
 }
         break;
       case 31: /* scantok ::= */
@@ -174635,17 +176257,17 @@ static YYACTIONTYPE yy_reduce(
 {pParse->constraintName = yymsp[0].minor.yy0;}
         break;
       case 33: /* ccons ::= DEFAULT scantok term */
-{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy528,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
+{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy454,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
         break;
       case 34: /* ccons ::= DEFAULT LP expr RP */
-{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy528,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
+{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy454,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
         break;
       case 35: /* ccons ::= DEFAULT PLUS scantok term */
-{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy528,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
+{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy454,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
         break;
       case 36: /* ccons ::= DEFAULT MINUS scantok term */
 {
-  Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy528, 0);
+  Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy454, 0);
   sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);
 }
         break;
@@ -174660,151 +176282,151 @@ static YYACTIONTYPE yy_reduce(
 }
         break;
       case 38: /* ccons ::= NOT NULL onconf */
-{sqlite3AddNotNull(pParse, yymsp[0].minor.yy394);}
+{sqlite3AddNotNull(pParse, yymsp[0].minor.yy144);}
         break;
       case 39: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
-{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy394,yymsp[0].minor.yy394,yymsp[-2].minor.yy394);}
+{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy144,yymsp[0].minor.yy144,yymsp[-2].minor.yy144);}
         break;
       case 40: /* ccons ::= UNIQUE onconf */
-{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy394,0,0,0,0,
+{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy144,0,0,0,0,
                                    SQLITE_IDXTYPE_UNIQUE);}
         break;
       case 41: /* ccons ::= CHECK LP expr RP */
-{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy528,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy0.z);}
+{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy454,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy0.z);}
         break;
       case 42: /* ccons ::= REFERENCES nm eidlist_opt refargs */
-{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy322,yymsp[0].minor.yy394);}
+{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy14,yymsp[0].minor.yy144);}
         break;
       case 43: /* ccons ::= defer_subclause */
-{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy394);}
+{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy144);}
         break;
       case 44: /* ccons ::= COLLATE ID|STRING */
 {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
         break;
       case 45: /* generated ::= LP expr RP */
-{sqlite3AddGenerated(pParse,yymsp[-1].minor.yy528,0);}
+{sqlite3AddGenerated(pParse,yymsp[-1].minor.yy454,0);}
         break;
       case 46: /* generated ::= LP expr RP ID */
-{sqlite3AddGenerated(pParse,yymsp[-2].minor.yy528,&yymsp[0].minor.yy0);}
+{sqlite3AddGenerated(pParse,yymsp[-2].minor.yy454,&yymsp[0].minor.yy0);}
         break;
       case 48: /* autoinc ::= AUTOINCR */
-{yymsp[0].minor.yy394 = 1;}
+{yymsp[0].minor.yy144 = 1;}
         break;
       case 49: /* refargs ::= */
-{ yymsp[1].minor.yy394 = OE_None*0x0101; /* EV: R-19803-45884 */}
+{ yymsp[1].minor.yy144 = OE_None*0x0101; /* EV: R-19803-45884 */}
         break;
       case 50: /* refargs ::= refargs refarg */
-{ yymsp[-1].minor.yy394 = (yymsp[-1].minor.yy394 & ~yymsp[0].minor.yy231.mask) | yymsp[0].minor.yy231.value; }
+{ yymsp[-1].minor.yy144 = (yymsp[-1].minor.yy144 & ~yymsp[0].minor.yy383.mask) | yymsp[0].minor.yy383.value; }
         break;
       case 51: /* refarg ::= MATCH nm */
-{ yymsp[-1].minor.yy231.value = 0;     yymsp[-1].minor.yy231.mask = 0x000000; }
+{ yymsp[-1].minor.yy383.value = 0;     yymsp[-1].minor.yy383.mask = 0x000000; }
         break;
       case 52: /* refarg ::= ON INSERT refact */
-{ yymsp[-2].minor.yy231.value = 0;     yymsp[-2].minor.yy231.mask = 0x000000; }
+{ yymsp[-2].minor.yy383.value = 0;     yymsp[-2].minor.yy383.mask = 0x000000; }
         break;
       case 53: /* refarg ::= ON DELETE refact */
-{ yymsp[-2].minor.yy231.value = yymsp[0].minor.yy394;     yymsp[-2].minor.yy231.mask = 0x0000ff; }
+{ yymsp[-2].minor.yy383.value = yymsp[0].minor.yy144;     yymsp[-2].minor.yy383.mask = 0x0000ff; }
         break;
       case 54: /* refarg ::= ON UPDATE refact */
-{ yymsp[-2].minor.yy231.value = yymsp[0].minor.yy394<<8;  yymsp[-2].minor.yy231.mask = 0x00ff00; }
+{ yymsp[-2].minor.yy383.value = yymsp[0].minor.yy144<<8;  yymsp[-2].minor.yy383.mask = 0x00ff00; }
         break;
       case 55: /* refact ::= SET NULL */
-{ yymsp[-1].minor.yy394 = OE_SetNull;  /* EV: R-33326-45252 */}
+{ yymsp[-1].minor.yy144 = OE_SetNull;  /* EV: R-33326-45252 */}
         break;
       case 56: /* refact ::= SET DEFAULT */
-{ yymsp[-1].minor.yy394 = OE_SetDflt;  /* EV: R-33326-45252 */}
+{ yymsp[-1].minor.yy144 = OE_SetDflt;  /* EV: R-33326-45252 */}
         break;
       case 57: /* refact ::= CASCADE */
-{ yymsp[0].minor.yy394 = OE_Cascade;  /* EV: R-33326-45252 */}
+{ yymsp[0].minor.yy144 = OE_Cascade;  /* EV: R-33326-45252 */}
         break;
       case 58: /* refact ::= RESTRICT */
-{ yymsp[0].minor.yy394 = OE_Restrict; /* EV: R-33326-45252 */}
+{ yymsp[0].minor.yy144 = OE_Restrict; /* EV: R-33326-45252 */}
         break;
       case 59: /* refact ::= NO ACTION */
-{ yymsp[-1].minor.yy394 = OE_None;     /* EV: R-33326-45252 */}
+{ yymsp[-1].minor.yy144 = OE_None;     /* EV: R-33326-45252 */}
         break;
       case 60: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
-{yymsp[-2].minor.yy394 = 0;}
+{yymsp[-2].minor.yy144 = 0;}
         break;
       case 61: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
       case 76: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==76);
-      case 171: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==171);
-{yymsp[-1].minor.yy394 = yymsp[0].minor.yy394;}
+      case 173: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==173);
+{yymsp[-1].minor.yy144 = yymsp[0].minor.yy144;}
         break;
       case 63: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
       case 80: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==80);
-      case 217: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==217);
-      case 220: /* in_op ::= NOT IN */ yytestcase(yyruleno==220);
-      case 245: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==245);
-{yymsp[-1].minor.yy394 = 1;}
+      case 219: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==219);
+      case 222: /* in_op ::= NOT IN */ yytestcase(yyruleno==222);
+      case 247: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==247);
+{yymsp[-1].minor.yy144 = 1;}
         break;
       case 64: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
-{yymsp[-1].minor.yy394 = 0;}
+{yymsp[-1].minor.yy144 = 0;}
         break;
       case 66: /* tconscomma ::= COMMA */
 {pParse->constraintName.n = 0;}
         break;
       case 68: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
-{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy322,yymsp[0].minor.yy394,yymsp[-2].minor.yy394,0);}
+{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy14,yymsp[0].minor.yy144,yymsp[-2].minor.yy144,0);}
         break;
       case 69: /* tcons ::= UNIQUE LP sortlist RP onconf */
-{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy322,yymsp[0].minor.yy394,0,0,0,0,
+{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy14,yymsp[0].minor.yy144,0,0,0,0,
                                        SQLITE_IDXTYPE_UNIQUE);}
         break;
       case 70: /* tcons ::= CHECK LP expr RP onconf */
-{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy528,yymsp[-3].minor.yy0.z,yymsp[-1].minor.yy0.z);}
+{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy454,yymsp[-3].minor.yy0.z,yymsp[-1].minor.yy0.z);}
         break;
       case 71: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
 {
-    sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy322, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy322, yymsp[-1].minor.yy394);
-    sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy394);
+    sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy14, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy14, yymsp[-1].minor.yy144);
+    sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy144);
 }
         break;
       case 73: /* onconf ::= */
       case 75: /* orconf ::= */ yytestcase(yyruleno==75);
-{yymsp[1].minor.yy394 = OE_Default;}
+{yymsp[1].minor.yy144 = OE_Default;}
         break;
       case 74: /* onconf ::= ON CONFLICT resolvetype */
-{yymsp[-2].minor.yy394 = yymsp[0].minor.yy394;}
+{yymsp[-2].minor.yy144 = yymsp[0].minor.yy144;}
         break;
       case 77: /* resolvetype ::= IGNORE */
-{yymsp[0].minor.yy394 = OE_Ignore;}
+{yymsp[0].minor.yy144 = OE_Ignore;}
         break;
       case 78: /* resolvetype ::= REPLACE */
-      case 172: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==172);
-{yymsp[0].minor.yy394 = OE_Replace;}
+      case 174: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==174);
+{yymsp[0].minor.yy144 = OE_Replace;}
         break;
       case 79: /* cmd ::= DROP TABLE ifexists fullname */
 {
-  sqlite3DropTable(pParse, yymsp[0].minor.yy131, 0, yymsp[-1].minor.yy394);
+  sqlite3DropTable(pParse, yymsp[0].minor.yy203, 0, yymsp[-1].minor.yy144);
 }
         break;
       case 82: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
 {
-  sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy322, yymsp[0].minor.yy47, yymsp[-7].minor.yy394, yymsp[-5].minor.yy394);
+  sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy14, yymsp[0].minor.yy555, yymsp[-7].minor.yy144, yymsp[-5].minor.yy144);
 }
         break;
       case 83: /* cmd ::= DROP VIEW ifexists fullname */
 {
-  sqlite3DropTable(pParse, yymsp[0].minor.yy131, 1, yymsp[-1].minor.yy394);
+  sqlite3DropTable(pParse, yymsp[0].minor.yy203, 1, yymsp[-1].minor.yy144);
 }
         break;
       case 84: /* cmd ::= select */
 {
   SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0, 0};
-  sqlite3Select(pParse, yymsp[0].minor.yy47, &dest);
-  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy47);
+  sqlite3Select(pParse, yymsp[0].minor.yy555, &dest);
+  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy555);
 }
         break;
       case 85: /* select ::= WITH wqlist selectnowith */
-{yymsp[-2].minor.yy47 = attachWithToSelect(pParse,yymsp[0].minor.yy47,yymsp[-1].minor.yy521);}
+{yymsp[-2].minor.yy555 = attachWithToSelect(pParse,yymsp[0].minor.yy555,yymsp[-1].minor.yy59);}
         break;
       case 86: /* select ::= WITH RECURSIVE wqlist selectnowith */
-{yymsp[-3].minor.yy47 = attachWithToSelect(pParse,yymsp[0].minor.yy47,yymsp[-1].minor.yy521);}
+{yymsp[-3].minor.yy555 = attachWithToSelect(pParse,yymsp[0].minor.yy555,yymsp[-1].minor.yy59);}
         break;
       case 87: /* select ::= selectnowith */
 {
-  Select *p = yymsp[0].minor.yy47;
+  Select *p = yymsp[0].minor.yy555;
   if( p ){
     parserDoubleLinkSelect(pParse, p);
   }
@@ -174812,8 +176434,8 @@ static YYACTIONTYPE yy_reduce(
         break;
       case 88: /* selectnowith ::= selectnowith multiselect_op oneselect */
 {
-  Select *pRhs = yymsp[0].minor.yy47;
-  Select *pLhs = yymsp[-2].minor.yy47;
+  Select *pRhs = yymsp[0].minor.yy555;
+  Select *pLhs = yymsp[-2].minor.yy555;
   if( pRhs && pRhs->pPrior ){
     SrcList *pFrom;
     Token x;
@@ -174823,148 +176445,145 @@ static YYACTIONTYPE yy_reduce(
     pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0);
   }
   if( pRhs ){
-    pRhs->op = (u8)yymsp[-1].minor.yy394;
+    pRhs->op = (u8)yymsp[-1].minor.yy144;
     pRhs->pPrior = pLhs;
     if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
     pRhs->selFlags &= ~SF_MultiValue;
-    if( yymsp[-1].minor.yy394!=TK_ALL ) pParse->hasCompound = 1;
+    if( yymsp[-1].minor.yy144!=TK_ALL ) pParse->hasCompound = 1;
   }else{
     sqlite3SelectDelete(pParse->db, pLhs);
   }
-  yymsp[-2].minor.yy47 = pRhs;
+  yymsp[-2].minor.yy555 = pRhs;
 }
         break;
       case 89: /* multiselect_op ::= UNION */
       case 91: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==91);
-{yymsp[0].minor.yy394 = yymsp[0].major; /*A-overwrites-OP*/}
+{yymsp[0].minor.yy144 = yymsp[0].major; /*A-overwrites-OP*/}
         break;
       case 90: /* multiselect_op ::= UNION ALL */
-{yymsp[-1].minor.yy394 = TK_ALL;}
+{yymsp[-1].minor.yy144 = TK_ALL;}
         break;
       case 92: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
 {
-  yymsp[-8].minor.yy47 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy322,yymsp[-5].minor.yy131,yymsp[-4].minor.yy528,yymsp[-3].minor.yy322,yymsp[-2].minor.yy528,yymsp[-1].minor.yy322,yymsp[-7].minor.yy394,yymsp[0].minor.yy528);
+  yymsp[-8].minor.yy555 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy14,yymsp[-5].minor.yy203,yymsp[-4].minor.yy454,yymsp[-3].minor.yy14,yymsp[-2].minor.yy454,yymsp[-1].minor.yy14,yymsp[-7].minor.yy144,yymsp[0].minor.yy454);
 }
         break;
       case 93: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
 {
-  yymsp[-9].minor.yy47 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy322,yymsp[-6].minor.yy131,yymsp[-5].minor.yy528,yymsp[-4].minor.yy322,yymsp[-3].minor.yy528,yymsp[-1].minor.yy322,yymsp[-8].minor.yy394,yymsp[0].minor.yy528);
-  if( yymsp[-9].minor.yy47 ){
-    yymsp[-9].minor.yy47->pWinDefn = yymsp[-2].minor.yy41;
+  yymsp[-9].minor.yy555 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy14,yymsp[-6].minor.yy203,yymsp[-5].minor.yy454,yymsp[-4].minor.yy14,yymsp[-3].minor.yy454,yymsp[-1].minor.yy14,yymsp[-8].minor.yy144,yymsp[0].minor.yy454);
+  if( yymsp[-9].minor.yy555 ){
+    yymsp[-9].minor.yy555->pWinDefn = yymsp[-2].minor.yy211;
   }else{
-    sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy41);
+    sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy211);
   }
 }
         break;
       case 94: /* values ::= VALUES LP nexprlist RP */
 {
-  yymsp[-3].minor.yy47 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy322,0,0,0,0,0,SF_Values,0);
+  yymsp[-3].minor.yy555 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy14,0,0,0,0,0,SF_Values,0);
 }
         break;
-      case 95: /* values ::= values COMMA LP nexprlist RP */
+      case 95: /* oneselect ::= mvalues */
 {
-  Select *pRight, *pLeft = yymsp[-4].minor.yy47;
-  pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy322,0,0,0,0,0,SF_Values|SF_MultiValue,0);
-  if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
-  if( pRight ){
-    pRight->op = TK_ALL;
-    pRight->pPrior = pLeft;
-    yymsp[-4].minor.yy47 = pRight;
-  }else{
-    yymsp[-4].minor.yy47 = pLeft;
-  }
+  sqlite3MultiValuesEnd(pParse, yymsp[0].minor.yy555);
+}
+        break;
+      case 96: /* mvalues ::= values COMMA LP nexprlist RP */
+      case 97: /* mvalues ::= mvalues COMMA LP nexprlist RP */ yytestcase(yyruleno==97);
+{
+  yymsp[-4].minor.yy555 = sqlite3MultiValues(pParse, yymsp[-4].minor.yy555, yymsp[-1].minor.yy14);
 }
         break;
-      case 96: /* distinct ::= DISTINCT */
-{yymsp[0].minor.yy394 = SF_Distinct;}
+      case 98: /* distinct ::= DISTINCT */
+{yymsp[0].minor.yy144 = SF_Distinct;}
         break;
-      case 97: /* distinct ::= ALL */
-{yymsp[0].minor.yy394 = SF_All;}
+      case 99: /* distinct ::= ALL */
+{yymsp[0].minor.yy144 = SF_All;}
         break;
-      case 99: /* sclp ::= */
-      case 132: /* orderby_opt ::= */ yytestcase(yyruleno==132);
-      case 142: /* groupby_opt ::= */ yytestcase(yyruleno==142);
-      case 232: /* exprlist ::= */ yytestcase(yyruleno==232);
-      case 235: /* paren_exprlist ::= */ yytestcase(yyruleno==235);
-      case 240: /* eidlist_opt ::= */ yytestcase(yyruleno==240);
-{yymsp[1].minor.yy322 = 0;}
+      case 101: /* sclp ::= */
+      case 134: /* orderby_opt ::= */ yytestcase(yyruleno==134);
+      case 144: /* groupby_opt ::= */ yytestcase(yyruleno==144);
+      case 234: /* exprlist ::= */ yytestcase(yyruleno==234);
+      case 237: /* paren_exprlist ::= */ yytestcase(yyruleno==237);
+      case 242: /* eidlist_opt ::= */ yytestcase(yyruleno==242);
+{yymsp[1].minor.yy14 = 0;}
         break;
-      case 100: /* selcollist ::= sclp scanpt expr scanpt as */
+      case 102: /* selcollist ::= sclp scanpt expr scanpt as */
 {
-   yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy322, yymsp[-2].minor.yy528);
-   if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy322, &yymsp[0].minor.yy0, 1);
-   sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy322,yymsp[-3].minor.yy522,yymsp[-1].minor.yy522);
+   yymsp[-4].minor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy14, yymsp[-2].minor.yy454);
+   if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy14, &yymsp[0].minor.yy0, 1);
+   sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy14,yymsp[-3].minor.yy168,yymsp[-1].minor.yy168);
 }
         break;
-      case 101: /* selcollist ::= sclp scanpt STAR */
+      case 103: /* selcollist ::= sclp scanpt STAR */
 {
   Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
   sqlite3ExprSetErrorOffset(p, (int)(yymsp[0].minor.yy0.z - pParse->zTail));
-  yymsp[-2].minor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy322, p);
+  yymsp[-2].minor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy14, p);
 }
         break;
-      case 102: /* selcollist ::= sclp scanpt nm DOT STAR */
+      case 104: /* selcollist ::= sclp scanpt nm DOT STAR */
 {
   Expr *pRight, *pLeft, *pDot;
   pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
   sqlite3ExprSetErrorOffset(pRight, (int)(yymsp[0].minor.yy0.z - pParse->zTail));
   pLeft = tokenExpr(pParse, TK_ID, yymsp[-2].minor.yy0);
   pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
-  yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, pDot);
+  yymsp[-4].minor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14, pDot);
 }
         break;
-      case 103: /* as ::= AS nm */
-      case 115: /* dbnm ::= DOT nm */ yytestcase(yyruleno==115);
-      case 256: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==256);
-      case 257: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==257);
+      case 105: /* as ::= AS nm */
+      case 117: /* dbnm ::= DOT nm */ yytestcase(yyruleno==117);
+      case 258: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==258);
+      case 259: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==259);
 {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
         break;
-      case 105: /* from ::= */
-      case 108: /* stl_prefix ::= */ yytestcase(yyruleno==108);
-{yymsp[1].minor.yy131 = 0;}
+      case 107: /* from ::= */
+      case 110: /* stl_prefix ::= */ yytestcase(yyruleno==110);
+{yymsp[1].minor.yy203 = 0;}
         break;
-      case 106: /* from ::= FROM seltablist */
+      case 108: /* from ::= FROM seltablist */
 {
-  yymsp[-1].minor.yy131 = yymsp[0].minor.yy131;
-  sqlite3SrcListShiftJoinType(pParse,yymsp[-1].minor.yy131);
+  yymsp[-1].minor.yy203 = yymsp[0].minor.yy203;
+  sqlite3SrcListShiftJoinType(pParse,yymsp[-1].minor.yy203);
 }
         break;
-      case 107: /* stl_prefix ::= seltablist joinop */
+      case 109: /* stl_prefix ::= seltablist joinop */
 {
-   if( ALWAYS(yymsp[-1].minor.yy131 && yymsp[-1].minor.yy131->nSrc>0) ) yymsp[-1].minor.yy131->a[yymsp[-1].minor.yy131->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy394;
+   if( ALWAYS(yymsp[-1].minor.yy203 && yymsp[-1].minor.yy203->nSrc>0) ) yymsp[-1].minor.yy203->a[yymsp[-1].minor.yy203->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy144;
 }
         break;
-      case 109: /* seltablist ::= stl_prefix nm dbnm as on_using */
+      case 111: /* seltablist ::= stl_prefix nm dbnm as on_using */
 {
-  yymsp[-4].minor.yy131 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-4].minor.yy131,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy561);
+  yymsp[-4].minor.yy203 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-4].minor.yy203,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy269);
 }
         break;
-      case 110: /* seltablist ::= stl_prefix nm dbnm as indexed_by on_using */
+      case 112: /* seltablist ::= stl_prefix nm dbnm as indexed_by on_using */
 {
-  yymsp[-5].minor.yy131 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy131,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,0,&yymsp[0].minor.yy561);
-  sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy131, &yymsp[-1].minor.yy0);
+  yymsp[-5].minor.yy203 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy203,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,0,&yymsp[0].minor.yy269);
+  sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy203, &yymsp[-1].minor.yy0);
 }
         break;
-      case 111: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_using */
+      case 113: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_using */
 {
-  yymsp[-7].minor.yy131 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-7].minor.yy131,&yymsp[-6].minor.yy0,&yymsp[-5].minor.yy0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy561);
-  sqlite3SrcListFuncArgs(pParse, yymsp[-7].minor.yy131, yymsp[-3].minor.yy322);
+  yymsp[-7].minor.yy203 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-7].minor.yy203,&yymsp[-6].minor.yy0,&yymsp[-5].minor.yy0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy269);
+  sqlite3SrcListFuncArgs(pParse, yymsp[-7].minor.yy203, yymsp[-3].minor.yy14);
 }
         break;
-      case 112: /* seltablist ::= stl_prefix LP select RP as on_using */
+      case 114: /* seltablist ::= stl_prefix LP select RP as on_using */
 {
-    yymsp[-5].minor.yy131 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy131,0,0,&yymsp[-1].minor.yy0,yymsp[-3].minor.yy47,&yymsp[0].minor.yy561);
+    yymsp[-5].minor.yy203 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy203,0,0,&yymsp[-1].minor.yy0,yymsp[-3].minor.yy555,&yymsp[0].minor.yy269);
   }
         break;
-      case 113: /* seltablist ::= stl_prefix LP seltablist RP as on_using */
+      case 115: /* seltablist ::= stl_prefix LP seltablist RP as on_using */
 {
-    if( yymsp[-5].minor.yy131==0 && yymsp[-1].minor.yy0.n==0 && yymsp[0].minor.yy561.pOn==0 && yymsp[0].minor.yy561.pUsing==0 ){
-      yymsp[-5].minor.yy131 = yymsp[-3].minor.yy131;
-    }else if( ALWAYS(yymsp[-3].minor.yy131!=0) && yymsp[-3].minor.yy131->nSrc==1 ){
-      yymsp[-5].minor.yy131 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy131,0,0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy561);
-      if( yymsp[-5].minor.yy131 ){
-        SrcItem *pNew = &yymsp[-5].minor.yy131->a[yymsp[-5].minor.yy131->nSrc-1];
-        SrcItem *pOld = yymsp[-3].minor.yy131->a;
+    if( yymsp[-5].minor.yy203==0 && yymsp[-1].minor.yy0.n==0 && yymsp[0].minor.yy269.pOn==0 && yymsp[0].minor.yy269.pUsing==0 ){
+      yymsp[-5].minor.yy203 = yymsp[-3].minor.yy203;
+    }else if( ALWAYS(yymsp[-3].minor.yy203!=0) && yymsp[-3].minor.yy203->nSrc==1 ){
+      yymsp[-5].minor.yy203 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy203,0,0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy269);
+      if( yymsp[-5].minor.yy203 ){
+        SrcItem *pNew = &yymsp[-5].minor.yy203->a[yymsp[-5].minor.yy203->nSrc-1];
+        SrcItem *pOld = yymsp[-3].minor.yy203->a;
         pNew->zName = pOld->zName;
         pNew->zDatabase = pOld->zDatabase;
         pNew->pSelect = pOld->pSelect;
@@ -174980,153 +176599,153 @@ static YYACTIONTYPE yy_reduce(
         pOld->zName = pOld->zDatabase = 0;
         pOld->pSelect = 0;
       }
-      sqlite3SrcListDelete(pParse->db, yymsp[-3].minor.yy131);
+      sqlite3SrcListDelete(pParse->db, yymsp[-3].minor.yy203);
     }else{
       Select *pSubquery;
-      sqlite3SrcListShiftJoinType(pParse,yymsp[-3].minor.yy131);
-      pSubquery = sqlite3SelectNew(pParse,0,yymsp[-3].minor.yy131,0,0,0,0,SF_NestedFrom,0);
-      yymsp[-5].minor.yy131 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy131,0,0,&yymsp[-1].minor.yy0,pSubquery,&yymsp[0].minor.yy561);
+      sqlite3SrcListShiftJoinType(pParse,yymsp[-3].minor.yy203);
+      pSubquery = sqlite3SelectNew(pParse,0,yymsp[-3].minor.yy203,0,0,0,0,SF_NestedFrom,0);
+      yymsp[-5].minor.yy203 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy203,0,0,&yymsp[-1].minor.yy0,pSubquery,&yymsp[0].minor.yy269);
     }
   }
         break;
-      case 114: /* dbnm ::= */
-      case 129: /* indexed_opt ::= */ yytestcase(yyruleno==129);
+      case 116: /* dbnm ::= */
+      case 131: /* indexed_opt ::= */ yytestcase(yyruleno==131);
 {yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
         break;
-      case 116: /* fullname ::= nm */
+      case 118: /* fullname ::= nm */
 {
-  yylhsminor.yy131 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0);
-  if( IN_RENAME_OBJECT && yylhsminor.yy131 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy131->a[0].zName, &yymsp[0].minor.yy0);
+  yylhsminor.yy203 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0);
+  if( IN_RENAME_OBJECT && yylhsminor.yy203 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy203->a[0].zName, &yymsp[0].minor.yy0);
 }
-  yymsp[0].minor.yy131 = yylhsminor.yy131;
+  yymsp[0].minor.yy203 = yylhsminor.yy203;
         break;
-      case 117: /* fullname ::= nm DOT nm */
+      case 119: /* fullname ::= nm DOT nm */
 {
-  yylhsminor.yy131 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
-  if( IN_RENAME_OBJECT && yylhsminor.yy131 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy131->a[0].zName, &yymsp[0].minor.yy0);
+  yylhsminor.yy203 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
+  if( IN_RENAME_OBJECT && yylhsminor.yy203 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy203->a[0].zName, &yymsp[0].minor.yy0);
 }
-  yymsp[-2].minor.yy131 = yylhsminor.yy131;
+  yymsp[-2].minor.yy203 = yylhsminor.yy203;
         break;
-      case 118: /* xfullname ::= nm */
-{yymsp[0].minor.yy131 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
+      case 120: /* xfullname ::= nm */
+{yymsp[0].minor.yy203 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
         break;
-      case 119: /* xfullname ::= nm DOT nm */
-{yymsp[-2].minor.yy131 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
+      case 121: /* xfullname ::= nm DOT nm */
+{yymsp[-2].minor.yy203 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
         break;
-      case 120: /* xfullname ::= nm DOT nm AS nm */
+      case 122: /* xfullname ::= nm DOT nm AS nm */
 {
-   yymsp[-4].minor.yy131 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
-   if( yymsp[-4].minor.yy131 ) yymsp[-4].minor.yy131->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
+   yymsp[-4].minor.yy203 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
+   if( yymsp[-4].minor.yy203 ) yymsp[-4].minor.yy203->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
 }
         break;
-      case 121: /* xfullname ::= nm AS nm */
+      case 123: /* xfullname ::= nm AS nm */
 {
-   yymsp[-2].minor.yy131 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
-   if( yymsp[-2].minor.yy131 ) yymsp[-2].minor.yy131->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
+   yymsp[-2].minor.yy203 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
+   if( yymsp[-2].minor.yy203 ) yymsp[-2].minor.yy203->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
 }
         break;
-      case 122: /* joinop ::= COMMA|JOIN */
-{ yymsp[0].minor.yy394 = JT_INNER; }
+      case 124: /* joinop ::= COMMA|JOIN */
+{ yymsp[0].minor.yy144 = JT_INNER; }
         break;
-      case 123: /* joinop ::= JOIN_KW JOIN */
-{yymsp[-1].minor.yy394 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0);  /*X-overwrites-A*/}
+      case 125: /* joinop ::= JOIN_KW JOIN */
+{yymsp[-1].minor.yy144 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0);  /*X-overwrites-A*/}
         break;
-      case 124: /* joinop ::= JOIN_KW nm JOIN */
-{yymsp[-2].minor.yy394 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
+      case 126: /* joinop ::= JOIN_KW nm JOIN */
+{yymsp[-2].minor.yy144 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
         break;
-      case 125: /* joinop ::= JOIN_KW nm nm JOIN */
-{yymsp[-3].minor.yy394 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
+      case 127: /* joinop ::= JOIN_KW nm nm JOIN */
+{yymsp[-3].minor.yy144 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
         break;
-      case 126: /* on_using ::= ON expr */
-{yymsp[-1].minor.yy561.pOn = yymsp[0].minor.yy528; yymsp[-1].minor.yy561.pUsing = 0;}
+      case 128: /* on_using ::= ON expr */
+{yymsp[-1].minor.yy269.pOn = yymsp[0].minor.yy454; yymsp[-1].minor.yy269.pUsing = 0;}
         break;
-      case 127: /* on_using ::= USING LP idlist RP */
-{yymsp[-3].minor.yy561.pOn = 0; yymsp[-3].minor.yy561.pUsing = yymsp[-1].minor.yy254;}
+      case 129: /* on_using ::= USING LP idlist RP */
+{yymsp[-3].minor.yy269.pOn = 0; yymsp[-3].minor.yy269.pUsing = yymsp[-1].minor.yy132;}
         break;
-      case 128: /* on_using ::= */
-{yymsp[1].minor.yy561.pOn = 0; yymsp[1].minor.yy561.pUsing = 0;}
+      case 130: /* on_using ::= */
+{yymsp[1].minor.yy269.pOn = 0; yymsp[1].minor.yy269.pUsing = 0;}
         break;
-      case 130: /* indexed_by ::= INDEXED BY nm */
+      case 132: /* indexed_by ::= INDEXED BY nm */
 {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
         break;
-      case 131: /* indexed_by ::= NOT INDEXED */
+      case 133: /* indexed_by ::= NOT INDEXED */
 {yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
         break;
-      case 133: /* orderby_opt ::= ORDER BY sortlist */
-      case 143: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==143);
-{yymsp[-2].minor.yy322 = yymsp[0].minor.yy322;}
+      case 135: /* orderby_opt ::= ORDER BY sortlist */
+      case 145: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==145);
+{yymsp[-2].minor.yy14 = yymsp[0].minor.yy14;}
         break;
-      case 134: /* sortlist ::= sortlist COMMA expr sortorder nulls */
+      case 136: /* sortlist ::= sortlist COMMA expr sortorder nulls */
 {
-  yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322,yymsp[-2].minor.yy528);
-  sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy322,yymsp[-1].minor.yy394,yymsp[0].minor.yy394);
+  yymsp[-4].minor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14,yymsp[-2].minor.yy454);
+  sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy14,yymsp[-1].minor.yy144,yymsp[0].minor.yy144);
 }
         break;
-      case 135: /* sortlist ::= expr sortorder nulls */
+      case 137: /* sortlist ::= expr sortorder nulls */
 {
-  yymsp[-2].minor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy528); /*A-overwrites-Y*/
-  sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy322,yymsp[-1].minor.yy394,yymsp[0].minor.yy394);
+  yymsp[-2].minor.yy14 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy454); /*A-overwrites-Y*/
+  sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy14,yymsp[-1].minor.yy144,yymsp[0].minor.yy144);
 }
         break;
-      case 136: /* sortorder ::= ASC */
-{yymsp[0].minor.yy394 = SQLITE_SO_ASC;}
+      case 138: /* sortorder ::= ASC */
+{yymsp[0].minor.yy144 = SQLITE_SO_ASC;}
         break;
-      case 137: /* sortorder ::= DESC */
-{yymsp[0].minor.yy394 = SQLITE_SO_DESC;}
+      case 139: /* sortorder ::= DESC */
+{yymsp[0].minor.yy144 = SQLITE_SO_DESC;}
         break;
-      case 138: /* sortorder ::= */
-      case 141: /* nulls ::= */ yytestcase(yyruleno==141);
-{yymsp[1].minor.yy394 = SQLITE_SO_UNDEFINED;}
+      case 140: /* sortorder ::= */
+      case 143: /* nulls ::= */ yytestcase(yyruleno==143);
+{yymsp[1].minor.yy144 = SQLITE_SO_UNDEFINED;}
         break;
-      case 139: /* nulls ::= NULLS FIRST */
-{yymsp[-1].minor.yy394 = SQLITE_SO_ASC;}
+      case 141: /* nulls ::= NULLS FIRST */
+{yymsp[-1].minor.yy144 = SQLITE_SO_ASC;}
         break;
-      case 140: /* nulls ::= NULLS LAST */
-{yymsp[-1].minor.yy394 = SQLITE_SO_DESC;}
+      case 142: /* nulls ::= NULLS LAST */
+{yymsp[-1].minor.yy144 = SQLITE_SO_DESC;}
         break;
-      case 144: /* having_opt ::= */
-      case 146: /* limit_opt ::= */ yytestcase(yyruleno==146);
-      case 151: /* where_opt ::= */ yytestcase(yyruleno==151);
-      case 153: /* where_opt_ret ::= */ yytestcase(yyruleno==153);
-      case 230: /* case_else ::= */ yytestcase(yyruleno==230);
-      case 231: /* case_operand ::= */ yytestcase(yyruleno==231);
-      case 250: /* vinto ::= */ yytestcase(yyruleno==250);
-{yymsp[1].minor.yy528 = 0;}
+      case 146: /* having_opt ::= */
+      case 148: /* limit_opt ::= */ yytestcase(yyruleno==148);
+      case 153: /* where_opt ::= */ yytestcase(yyruleno==153);
+      case 155: /* where_opt_ret ::= */ yytestcase(yyruleno==155);
+      case 232: /* case_else ::= */ yytestcase(yyruleno==232);
+      case 233: /* case_operand ::= */ yytestcase(yyruleno==233);
+      case 252: /* vinto ::= */ yytestcase(yyruleno==252);
+{yymsp[1].minor.yy454 = 0;}
         break;
-      case 145: /* having_opt ::= HAVING expr */
-      case 152: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==152);
-      case 154: /* where_opt_ret ::= WHERE expr */ yytestcase(yyruleno==154);
-      case 229: /* case_else ::= ELSE expr */ yytestcase(yyruleno==229);
-      case 249: /* vinto ::= INTO expr */ yytestcase(yyruleno==249);
-{yymsp[-1].minor.yy528 = yymsp[0].minor.yy528;}
+      case 147: /* having_opt ::= HAVING expr */
+      case 154: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==154);
+      case 156: /* where_opt_ret ::= WHERE expr */ yytestcase(yyruleno==156);
+      case 231: /* case_else ::= ELSE expr */ yytestcase(yyruleno==231);
+      case 251: /* vinto ::= INTO expr */ yytestcase(yyruleno==251);
+{yymsp[-1].minor.yy454 = yymsp[0].minor.yy454;}
         break;
-      case 147: /* limit_opt ::= LIMIT expr */
-{yymsp[-1].minor.yy528 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy528,0);}
+      case 149: /* limit_opt ::= LIMIT expr */
+{yymsp[-1].minor.yy454 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy454,0);}
         break;
-      case 148: /* limit_opt ::= LIMIT expr OFFSET expr */
-{yymsp[-3].minor.yy528 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy528,yymsp[0].minor.yy528);}
+      case 150: /* limit_opt ::= LIMIT expr OFFSET expr */
+{yymsp[-3].minor.yy454 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy454,yymsp[0].minor.yy454);}
         break;
-      case 149: /* limit_opt ::= LIMIT expr COMMA expr */
-{yymsp[-3].minor.yy528 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy528,yymsp[-2].minor.yy528);}
+      case 151: /* limit_opt ::= LIMIT expr COMMA expr */
+{yymsp[-3].minor.yy454 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy454,yymsp[-2].minor.yy454);}
         break;
-      case 150: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */
+      case 152: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */
 {
-  sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy131, &yymsp[-1].minor.yy0);
-  sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy131,yymsp[0].minor.yy528,0,0);
+  sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy203, &yymsp[-1].minor.yy0);
+  sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy203,yymsp[0].minor.yy454,0,0);
 }
         break;
-      case 155: /* where_opt_ret ::= RETURNING selcollist */
-{sqlite3AddReturning(pParse,yymsp[0].minor.yy322); yymsp[-1].minor.yy528 = 0;}
+      case 157: /* where_opt_ret ::= RETURNING selcollist */
+{sqlite3AddReturning(pParse,yymsp[0].minor.yy14); yymsp[-1].minor.yy454 = 0;}
         break;
-      case 156: /* where_opt_ret ::= WHERE expr RETURNING selcollist */
-{sqlite3AddReturning(pParse,yymsp[0].minor.yy322); yymsp[-3].minor.yy528 = yymsp[-2].minor.yy528;}
+      case 158: /* where_opt_ret ::= WHERE expr RETURNING selcollist */
+{sqlite3AddReturning(pParse,yymsp[0].minor.yy14); yymsp[-3].minor.yy454 = yymsp[-2].minor.yy454;}
         break;
-      case 157: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */
+      case 159: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */
 {
-  sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy131, &yymsp[-4].minor.yy0);
-  sqlite3ExprListCheckLength(pParse,yymsp[-2].minor.yy322,"set list");
-  if( yymsp[-1].minor.yy131 ){
-    SrcList *pFromClause = yymsp[-1].minor.yy131;
+  sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy203, &yymsp[-4].minor.yy0);
+  sqlite3ExprListCheckLength(pParse,yymsp[-2].minor.yy14,"set list");
+  if( yymsp[-1].minor.yy203 ){
+    SrcList *pFromClause = yymsp[-1].minor.yy203;
     if( pFromClause->nSrc>1 ){
       Select *pSubquery;
       Token as;
@@ -175135,92 +176754,92 @@ static YYACTIONTYPE yy_reduce(
       as.z = 0;
       pFromClause = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&as,pSubquery,0);
     }
-    yymsp[-5].minor.yy131 = sqlite3SrcListAppendList(pParse, yymsp[-5].minor.yy131, pFromClause);
+    yymsp[-5].minor.yy203 = sqlite3SrcListAppendList(pParse, yymsp[-5].minor.yy203, pFromClause);
   }
-  sqlite3Update(pParse,yymsp[-5].minor.yy131,yymsp[-2].minor.yy322,yymsp[0].minor.yy528,yymsp[-6].minor.yy394,0,0,0);
+  sqlite3Update(pParse,yymsp[-5].minor.yy203,yymsp[-2].minor.yy14,yymsp[0].minor.yy454,yymsp[-6].minor.yy144,0,0,0);
 }
         break;
-      case 158: /* setlist ::= setlist COMMA nm EQ expr */
+      case 160: /* setlist ::= setlist COMMA nm EQ expr */
 {
-  yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy322, yymsp[0].minor.yy528);
-  sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy322, &yymsp[-2].minor.yy0, 1);
+  yymsp[-4].minor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy14, yymsp[0].minor.yy454);
+  sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy14, &yymsp[-2].minor.yy0, 1);
 }
         break;
-      case 159: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
+      case 161: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
 {
-  yymsp[-6].minor.yy322 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy322, yymsp[-3].minor.yy254, yymsp[0].minor.yy528);
+  yymsp[-6].minor.yy14 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy14, yymsp[-3].minor.yy132, yymsp[0].minor.yy454);
 }
         break;
-      case 160: /* setlist ::= nm EQ expr */
+      case 162: /* setlist ::= nm EQ expr */
 {
-  yylhsminor.yy322 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy528);
-  sqlite3ExprListSetName(pParse, yylhsminor.yy322, &yymsp[-2].minor.yy0, 1);
+  yylhsminor.yy14 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy454);
+  sqlite3ExprListSetName(pParse, yylhsminor.yy14, &yymsp[-2].minor.yy0, 1);
 }
-  yymsp[-2].minor.yy322 = yylhsminor.yy322;
+  yymsp[-2].minor.yy14 = yylhsminor.yy14;
         break;
-      case 161: /* setlist ::= LP idlist RP EQ expr */
+      case 163: /* setlist ::= LP idlist RP EQ expr */
 {
-  yymsp[-4].minor.yy322 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy254, yymsp[0].minor.yy528);
+  yymsp[-4].minor.yy14 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy132, yymsp[0].minor.yy454);
 }
         break;
-      case 162: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
+      case 164: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
 {
-  sqlite3Insert(pParse, yymsp[-3].minor.yy131, yymsp[-1].minor.yy47, yymsp[-2].minor.yy254, yymsp[-5].minor.yy394, yymsp[0].minor.yy444);
+  sqlite3Insert(pParse, yymsp[-3].minor.yy203, yymsp[-1].minor.yy555, yymsp[-2].minor.yy132, yymsp[-5].minor.yy144, yymsp[0].minor.yy122);
 }
         break;
-      case 163: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */
+      case 165: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */
 {
-  sqlite3Insert(pParse, yymsp[-4].minor.yy131, 0, yymsp[-3].minor.yy254, yymsp[-6].minor.yy394, 0);
+  sqlite3Insert(pParse, yymsp[-4].minor.yy203, 0, yymsp[-3].minor.yy132, yymsp[-6].minor.yy144, 0);
 }
         break;
-      case 164: /* upsert ::= */
-{ yymsp[1].minor.yy444 = 0; }
+      case 166: /* upsert ::= */
+{ yymsp[1].minor.yy122 = 0; }
         break;
-      case 165: /* upsert ::= RETURNING selcollist */
-{ yymsp[-1].minor.yy444 = 0; sqlite3AddReturning(pParse,yymsp[0].minor.yy322); }
+      case 167: /* upsert ::= RETURNING selcollist */
+{ yymsp[-1].minor.yy122 = 0; sqlite3AddReturning(pParse,yymsp[0].minor.yy14); }
         break;
-      case 166: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */
-{ yymsp[-11].minor.yy444 = sqlite3UpsertNew(pParse->db,yymsp[-8].minor.yy322,yymsp[-6].minor.yy528,yymsp[-2].minor.yy322,yymsp[-1].minor.yy528,yymsp[0].minor.yy444);}
+      case 168: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */
+{ yymsp[-11].minor.yy122 = sqlite3UpsertNew(pParse->db,yymsp[-8].minor.yy14,yymsp[-6].minor.yy454,yymsp[-2].minor.yy14,yymsp[-1].minor.yy454,yymsp[0].minor.yy122);}
         break;
-      case 167: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */
-{ yymsp[-8].minor.yy444 = sqlite3UpsertNew(pParse->db,yymsp[-5].minor.yy322,yymsp[-3].minor.yy528,0,0,yymsp[0].minor.yy444); }
+      case 169: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */
+{ yymsp[-8].minor.yy122 = sqlite3UpsertNew(pParse->db,yymsp[-5].minor.yy14,yymsp[-3].minor.yy454,0,0,yymsp[0].minor.yy122); }
         break;
-      case 168: /* upsert ::= ON CONFLICT DO NOTHING returning */
-{ yymsp[-4].minor.yy444 = sqlite3UpsertNew(pParse->db,0,0,0,0,0); }
+      case 170: /* upsert ::= ON CONFLICT DO NOTHING returning */
+{ yymsp[-4].minor.yy122 = sqlite3UpsertNew(pParse->db,0,0,0,0,0); }
         break;
-      case 169: /* upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */
-{ yymsp[-7].minor.yy444 = sqlite3UpsertNew(pParse->db,0,0,yymsp[-2].minor.yy322,yymsp[-1].minor.yy528,0);}
+      case 171: /* upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */
+{ yymsp[-7].minor.yy122 = sqlite3UpsertNew(pParse->db,0,0,yymsp[-2].minor.yy14,yymsp[-1].minor.yy454,0);}
         break;
-      case 170: /* returning ::= RETURNING selcollist */
-{sqlite3AddReturning(pParse,yymsp[0].minor.yy322);}
+      case 172: /* returning ::= RETURNING selcollist */
+{sqlite3AddReturning(pParse,yymsp[0].minor.yy14);}
         break;
-      case 173: /* idlist_opt ::= */
-{yymsp[1].minor.yy254 = 0;}
+      case 175: /* idlist_opt ::= */
+{yymsp[1].minor.yy132 = 0;}
         break;
-      case 174: /* idlist_opt ::= LP idlist RP */
-{yymsp[-2].minor.yy254 = yymsp[-1].minor.yy254;}
+      case 176: /* idlist_opt ::= LP idlist RP */
+{yymsp[-2].minor.yy132 = yymsp[-1].minor.yy132;}
         break;
-      case 175: /* idlist ::= idlist COMMA nm */
-{yymsp[-2].minor.yy254 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy254,&yymsp[0].minor.yy0);}
+      case 177: /* idlist ::= idlist COMMA nm */
+{yymsp[-2].minor.yy132 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy132,&yymsp[0].minor.yy0);}
         break;
-      case 176: /* idlist ::= nm */
-{yymsp[0].minor.yy254 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
+      case 178: /* idlist ::= nm */
+{yymsp[0].minor.yy132 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
         break;
-      case 177: /* expr ::= LP expr RP */
-{yymsp[-2].minor.yy528 = yymsp[-1].minor.yy528;}
+      case 179: /* expr ::= LP expr RP */
+{yymsp[-2].minor.yy454 = yymsp[-1].minor.yy454;}
         break;
-      case 178: /* expr ::= ID|INDEXED|JOIN_KW */
-{yymsp[0].minor.yy528=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
+      case 180: /* expr ::= ID|INDEXED|JOIN_KW */
+{yymsp[0].minor.yy454=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
         break;
-      case 179: /* expr ::= nm DOT nm */
+      case 181: /* expr ::= nm DOT nm */
 {
   Expr *temp1 = tokenExpr(pParse,TK_ID,yymsp[-2].minor.yy0);
   Expr *temp2 = tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0);
-  yylhsminor.yy528 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
+  yylhsminor.yy454 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
 }
-  yymsp[-2].minor.yy528 = yylhsminor.yy528;
+  yymsp[-2].minor.yy454 = yylhsminor.yy454;
         break;
-      case 180: /* expr ::= nm DOT nm DOT nm */
+      case 182: /* expr ::= nm DOT nm DOT nm */
 {
   Expr *temp1 = tokenExpr(pParse,TK_ID,yymsp[-4].minor.yy0);
   Expr *temp2 = tokenExpr(pParse,TK_ID,yymsp[-2].minor.yy0);
@@ -175229,27 +176848,27 @@ static YYACTIONTYPE yy_reduce(
   if( IN_RENAME_OBJECT ){
     sqlite3RenameTokenRemap(pParse, 0, temp1);
   }
-  yylhsminor.yy528 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
+  yylhsminor.yy454 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
 }
-  yymsp[-4].minor.yy528 = yylhsminor.yy528;
+  yymsp[-4].minor.yy454 = yylhsminor.yy454;
         break;
-      case 181: /* term ::= NULL|FLOAT|BLOB */
-      case 182: /* term ::= STRING */ yytestcase(yyruleno==182);
-{yymsp[0].minor.yy528=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
+      case 183: /* term ::= NULL|FLOAT|BLOB */
+      case 184: /* term ::= STRING */ yytestcase(yyruleno==184);
+{yymsp[0].minor.yy454=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
         break;
-      case 183: /* term ::= INTEGER */
+      case 185: /* term ::= INTEGER */
 {
-  yylhsminor.yy528 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
-  if( yylhsminor.yy528 ) yylhsminor.yy528->w.iOfst = (int)(yymsp[0].minor.yy0.z - pParse->zTail);
+  yylhsminor.yy454 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
+  if( yylhsminor.yy454 ) yylhsminor.yy454->w.iOfst = (int)(yymsp[0].minor.yy0.z - pParse->zTail);
 }
-  yymsp[0].minor.yy528 = yylhsminor.yy528;
+  yymsp[0].minor.yy454 = yylhsminor.yy454;
         break;
-      case 184: /* expr ::= VARIABLE */
+      case 186: /* expr ::= VARIABLE */
 {
   if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
     u32 n = yymsp[0].minor.yy0.n;
-    yymsp[0].minor.yy528 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
-    sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy528, n);
+    yymsp[0].minor.yy454 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
+    sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy454, n);
   }else{
     /* When doing a nested parse, one can include terms in an expression
     ** that look like this:   #1 #2 ...  These terms refer to registers
@@ -175258,194 +176877,203 @@ static YYACTIONTYPE yy_reduce(
     assert( t.n>=2 );
     if( pParse->nested==0 ){
       sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t);
-      yymsp[0].minor.yy528 = 0;
+      yymsp[0].minor.yy454 = 0;
     }else{
-      yymsp[0].minor.yy528 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
-      if( yymsp[0].minor.yy528 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy528->iTable);
+      yymsp[0].minor.yy454 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
+      if( yymsp[0].minor.yy454 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy454->iTable);
     }
   }
 }
         break;
-      case 185: /* expr ::= expr COLLATE ID|STRING */
+      case 187: /* expr ::= expr COLLATE ID|STRING */
 {
-  yymsp[-2].minor.yy528 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy528, &yymsp[0].minor.yy0, 1);
+  yymsp[-2].minor.yy454 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy454, &yymsp[0].minor.yy0, 1);
 }
         break;
-      case 186: /* expr ::= CAST LP expr AS typetoken RP */
+      case 188: /* expr ::= CAST LP expr AS typetoken RP */
 {
-  yymsp[-5].minor.yy528 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
-  sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy528, yymsp[-3].minor.yy528, 0);
+  yymsp[-5].minor.yy454 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
+  sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy454, yymsp[-3].minor.yy454, 0);
 }
         break;
-      case 187: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */
+      case 189: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */
 {
-  yylhsminor.yy528 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy322, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy394);
+  yylhsminor.yy454 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy14, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy144);
 }
-  yymsp[-4].minor.yy528 = yylhsminor.yy528;
+  yymsp[-4].minor.yy454 = yylhsminor.yy454;
         break;
-      case 188: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */
+      case 190: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */
 {
-  yylhsminor.yy528 = sqlite3ExprFunction(pParse, yymsp[-4].minor.yy322, &yymsp[-7].minor.yy0, yymsp[-5].minor.yy394);
-  sqlite3ExprAddFunctionOrderBy(pParse, yylhsminor.yy528, yymsp[-1].minor.yy322);
+  yylhsminor.yy454 = sqlite3ExprFunction(pParse, yymsp[-4].minor.yy14, &yymsp[-7].minor.yy0, yymsp[-5].minor.yy144);
+  sqlite3ExprAddFunctionOrderBy(pParse, yylhsminor.yy454, yymsp[-1].minor.yy14);
 }
-  yymsp[-7].minor.yy528 = yylhsminor.yy528;
+  yymsp[-7].minor.yy454 = yylhsminor.yy454;
         break;
-      case 189: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP */
+      case 191: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP */
 {
-  yylhsminor.yy528 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
+  yylhsminor.yy454 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
 }
-  yymsp[-3].minor.yy528 = yylhsminor.yy528;
+  yymsp[-3].minor.yy454 = yylhsminor.yy454;
         break;
-      case 190: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */
+      case 192: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */
 {
-  yylhsminor.yy528 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy322, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy394);
-  sqlite3WindowAttach(pParse, yylhsminor.yy528, yymsp[0].minor.yy41);
+  yylhsminor.yy454 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy14, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy144);
+  sqlite3WindowAttach(pParse, yylhsminor.yy454, yymsp[0].minor.yy211);
 }
-  yymsp[-5].minor.yy528 = yylhsminor.yy528;
+  yymsp[-5].minor.yy454 = yylhsminor.yy454;
         break;
-      case 191: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */
+      case 193: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */
 {
-  yylhsminor.yy528 = sqlite3ExprFunction(pParse, yymsp[-5].minor.yy322, &yymsp[-8].minor.yy0, yymsp[-6].minor.yy394);
-  sqlite3WindowAttach(pParse, yylhsminor.yy528, yymsp[0].minor.yy41);
-  sqlite3ExprAddFunctionOrderBy(pParse, yylhsminor.yy528, yymsp[-2].minor.yy322);
+  yylhsminor.yy454 = sqlite3ExprFunction(pParse, yymsp[-5].minor.yy14, &yymsp[-8].minor.yy0, yymsp[-6].minor.yy144);
+  sqlite3WindowAttach(pParse, yylhsminor.yy454, yymsp[0].minor.yy211);
+  sqlite3ExprAddFunctionOrderBy(pParse, yylhsminor.yy454, yymsp[-2].minor.yy14);
 }
-  yymsp[-8].minor.yy528 = yylhsminor.yy528;
+  yymsp[-8].minor.yy454 = yylhsminor.yy454;
         break;
-      case 192: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */
+      case 194: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */
 {
-  yylhsminor.yy528 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0);
-  sqlite3WindowAttach(pParse, yylhsminor.yy528, yymsp[0].minor.yy41);
+  yylhsminor.yy454 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0);
+  sqlite3WindowAttach(pParse, yylhsminor.yy454, yymsp[0].minor.yy211);
 }
-  yymsp[-4].minor.yy528 = yylhsminor.yy528;
+  yymsp[-4].minor.yy454 = yylhsminor.yy454;
         break;
-      case 193: /* term ::= CTIME_KW */
+      case 195: /* term ::= CTIME_KW */
 {
-  yylhsminor.yy528 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
+  yylhsminor.yy454 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
 }
-  yymsp[0].minor.yy528 = yylhsminor.yy528;
+  yymsp[0].minor.yy454 = yylhsminor.yy454;
         break;
-      case 194: /* expr ::= LP nexprlist COMMA expr RP */
+      case 196: /* expr ::= LP nexprlist COMMA expr RP */
 {
-  ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy322, yymsp[-1].minor.yy528);
-  yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
-  if( yymsp[-4].minor.yy528 ){
-    yymsp[-4].minor.yy528->x.pList = pList;
+  ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy14, yymsp[-1].minor.yy454);
+  yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
+  if( yymsp[-4].minor.yy454 ){
+    yymsp[-4].minor.yy454->x.pList = pList;
     if( ALWAYS(pList->nExpr) ){
-      yymsp[-4].minor.yy528->flags |= pList->a[0].pExpr->flags & EP_Propagate;
+      yymsp[-4].minor.yy454->flags |= pList->a[0].pExpr->flags & EP_Propagate;
     }
   }else{
     sqlite3ExprListDelete(pParse->db, pList);
   }
 }
         break;
-      case 195: /* expr ::= expr AND expr */
-{yymsp[-2].minor.yy528=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy528,yymsp[0].minor.yy528);}
+      case 197: /* expr ::= expr AND expr */
+{yymsp[-2].minor.yy454=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy454,yymsp[0].minor.yy454);}
         break;
-      case 196: /* expr ::= expr OR expr */
-      case 197: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==197);
-      case 198: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==198);
-      case 199: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==199);
-      case 200: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==200);
-      case 201: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==201);
-      case 202: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==202);
-{yymsp[-2].minor.yy528=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy528,yymsp[0].minor.yy528);}
+      case 198: /* expr ::= expr OR expr */
+      case 199: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==199);
+      case 200: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==200);
+      case 201: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==201);
+      case 202: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==202);
+      case 203: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==203);
+      case 204: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==204);
+{yymsp[-2].minor.yy454=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy454,yymsp[0].minor.yy454);}
         break;
-      case 203: /* likeop ::= NOT LIKE_KW|MATCH */
+      case 205: /* likeop ::= NOT LIKE_KW|MATCH */
 {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
         break;
-      case 204: /* expr ::= expr likeop expr */
+      case 206: /* expr ::= expr likeop expr */
 {
   ExprList *pList;
   int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
   yymsp[-1].minor.yy0.n &= 0x7fffffff;
-  pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy528);
-  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy528);
-  yymsp[-2].minor.yy528 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
-  if( bNot ) yymsp[-2].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy528, 0);
-  if( yymsp[-2].minor.yy528 ) yymsp[-2].minor.yy528->flags |= EP_InfixFunc;
+  pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy454);
+  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy454);
+  yymsp[-2].minor.yy454 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
+  if( bNot ) yymsp[-2].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy454, 0);
+  if( yymsp[-2].minor.yy454 ) yymsp[-2].minor.yy454->flags |= EP_InfixFunc;
 }
         break;
-      case 205: /* expr ::= expr likeop expr ESCAPE expr */
+      case 207: /* expr ::= expr likeop expr ESCAPE expr */
 {
   ExprList *pList;
   int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
   yymsp[-3].minor.yy0.n &= 0x7fffffff;
-  pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy528);
-  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy528);
-  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy528);
-  yymsp[-4].minor.yy528 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0);
-  if( bNot ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0);
-  if( yymsp[-4].minor.yy528 ) yymsp[-4].minor.yy528->flags |= EP_InfixFunc;
+  pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy454);
+  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy454);
+  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy454);
+  yymsp[-4].minor.yy454 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0);
+  if( bNot ) yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy454, 0);
+  if( yymsp[-4].minor.yy454 ) yymsp[-4].minor.yy454->flags |= EP_InfixFunc;
 }
         break;
-      case 206: /* expr ::= expr ISNULL|NOTNULL */
-{yymsp[-1].minor.yy528 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy528,0);}
+      case 208: /* expr ::= expr ISNULL|NOTNULL */
+{yymsp[-1].minor.yy454 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy454,0);}
         break;
-      case 207: /* expr ::= expr NOT NULL */
-{yymsp[-2].minor.yy528 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy528,0);}
+      case 209: /* expr ::= expr NOT NULL */
+{yymsp[-2].minor.yy454 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy454,0);}
         break;
-      case 208: /* expr ::= expr IS expr */
+      case 210: /* expr ::= expr IS expr */
 {
-  yymsp[-2].minor.yy528 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy528,yymsp[0].minor.yy528);
-  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-2].minor.yy528, TK_ISNULL);
+  yymsp[-2].minor.yy454 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy454,yymsp[0].minor.yy454);
+  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy454, yymsp[-2].minor.yy454, TK_ISNULL);
 }
         break;
-      case 209: /* expr ::= expr IS NOT expr */
+      case 211: /* expr ::= expr IS NOT expr */
 {
-  yymsp[-3].minor.yy528 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy528,yymsp[0].minor.yy528);
-  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-3].minor.yy528, TK_NOTNULL);
+  yymsp[-3].minor.yy454 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy454,yymsp[0].minor.yy454);
+  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy454, yymsp[-3].minor.yy454, TK_NOTNULL);
 }
         break;
-      case 210: /* expr ::= expr IS NOT DISTINCT FROM expr */
+      case 212: /* expr ::= expr IS NOT DISTINCT FROM expr */
 {
-  yymsp[-5].minor.yy528 = sqlite3PExpr(pParse,TK_IS,yymsp[-5].minor.yy528,yymsp[0].minor.yy528);
-  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-5].minor.yy528, TK_ISNULL);
+  yymsp[-5].minor.yy454 = sqlite3PExpr(pParse,TK_IS,yymsp[-5].minor.yy454,yymsp[0].minor.yy454);
+  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy454, yymsp[-5].minor.yy454, TK_ISNULL);
 }
         break;
-      case 211: /* expr ::= expr IS DISTINCT FROM expr */
+      case 213: /* expr ::= expr IS DISTINCT FROM expr */
 {
-  yymsp[-4].minor.yy528 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-4].minor.yy528,yymsp[0].minor.yy528);
-  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-4].minor.yy528, TK_NOTNULL);
+  yymsp[-4].minor.yy454 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-4].minor.yy454,yymsp[0].minor.yy454);
+  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy454, yymsp[-4].minor.yy454, TK_NOTNULL);
 }
         break;
-      case 212: /* expr ::= NOT expr */
-      case 213: /* expr ::= BITNOT expr */ yytestcase(yyruleno==213);
-{yymsp[-1].minor.yy528 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy528, 0);/*A-overwrites-B*/}
+      case 214: /* expr ::= NOT expr */
+      case 215: /* expr ::= BITNOT expr */ yytestcase(yyruleno==215);
+{yymsp[-1].minor.yy454 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy454, 0);/*A-overwrites-B*/}
         break;
-      case 214: /* expr ::= PLUS|MINUS expr */
+      case 216: /* expr ::= PLUS|MINUS expr */
 {
-  yymsp[-1].minor.yy528 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy528, 0);
-  /*A-overwrites-B*/
+  Expr *p = yymsp[0].minor.yy454;
+  u8 op = yymsp[-1].major + (TK_UPLUS-TK_PLUS);
+  assert( TK_UPLUS>TK_PLUS );
+  assert( TK_UMINUS == TK_MINUS + (TK_UPLUS - TK_PLUS) );
+  if( p && p->op==TK_UPLUS ){
+    p->op = op;
+    yymsp[-1].minor.yy454 = p;
+  }else{
+    yymsp[-1].minor.yy454 = sqlite3PExpr(pParse, op, p, 0);
+    /*A-overwrites-B*/
+  }
 }
         break;
-      case 215: /* expr ::= expr PTR expr */
+      case 217: /* expr ::= expr PTR expr */
 {
-  ExprList *pList = sqlite3ExprListAppend(pParse, 0, yymsp[-2].minor.yy528);
-  pList = sqlite3ExprListAppend(pParse, pList, yymsp[0].minor.yy528);
-  yylhsminor.yy528 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
+  ExprList *pList = sqlite3ExprListAppend(pParse, 0, yymsp[-2].minor.yy454);
+  pList = sqlite3ExprListAppend(pParse, pList, yymsp[0].minor.yy454);
+  yylhsminor.yy454 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
 }
-  yymsp[-2].minor.yy528 = yylhsminor.yy528;
+  yymsp[-2].minor.yy454 = yylhsminor.yy454;
         break;
-      case 216: /* between_op ::= BETWEEN */
-      case 219: /* in_op ::= IN */ yytestcase(yyruleno==219);
-{yymsp[0].minor.yy394 = 0;}
+      case 218: /* between_op ::= BETWEEN */
+      case 221: /* in_op ::= IN */ yytestcase(yyruleno==221);
+{yymsp[0].minor.yy144 = 0;}
         break;
-      case 218: /* expr ::= expr between_op expr AND expr */
+      case 220: /* expr ::= expr between_op expr AND expr */
 {
-  ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy528);
-  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy528);
-  yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy528, 0);
-  if( yymsp[-4].minor.yy528 ){
-    yymsp[-4].minor.yy528->x.pList = pList;
+  ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy454);
+  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy454);
+  yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy454, 0);
+  if( yymsp[-4].minor.yy454 ){
+    yymsp[-4].minor.yy454->x.pList = pList;
   }else{
     sqlite3ExprListDelete(pParse->db, pList);
   }
-  if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0);
+  if( yymsp[-3].minor.yy144 ) yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy454, 0);
 }
         break;
-      case 221: /* expr ::= expr in_op LP exprlist RP */
+      case 223: /* expr ::= expr in_op LP exprlist RP */
 {
-    if( yymsp[-1].minor.yy322==0 ){
+    if( yymsp[-1].minor.yy14==0 ){
       /* Expressions of the form
       **
       **      expr1 IN ()
@@ -175454,208 +177082,208 @@ static YYACTIONTYPE yy_reduce(
       ** simplify to constants 0 (false) and 1 (true), respectively,
       ** regardless of the value of expr1.
       */
-      sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy528);
-      yymsp[-4].minor.yy528 = sqlite3Expr(pParse->db, TK_STRING, yymsp[-3].minor.yy394 ? "true" : "false");
-      if( yymsp[-4].minor.yy528 ) sqlite3ExprIdToTrueFalse(yymsp[-4].minor.yy528);
-    }else{
-      Expr *pRHS = yymsp[-1].minor.yy322->a[0].pExpr;
-      if( yymsp[-1].minor.yy322->nExpr==1 && sqlite3ExprIsConstant(pRHS) && yymsp[-4].minor.yy528->op!=TK_VECTOR ){
-        yymsp[-1].minor.yy322->a[0].pExpr = 0;
-        sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy322);
+      sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy454);
+      yymsp[-4].minor.yy454 = sqlite3Expr(pParse->db, TK_STRING, yymsp[-3].minor.yy144 ? "true" : "false");
+      if( yymsp[-4].minor.yy454 ) sqlite3ExprIdToTrueFalse(yymsp[-4].minor.yy454);
+    }else{
+      Expr *pRHS = yymsp[-1].minor.yy14->a[0].pExpr;
+      if( yymsp[-1].minor.yy14->nExpr==1 && sqlite3ExprIsConstant(pParse,pRHS) && yymsp[-4].minor.yy454->op!=TK_VECTOR ){
+        yymsp[-1].minor.yy14->a[0].pExpr = 0;
+        sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy14);
         pRHS = sqlite3PExpr(pParse, TK_UPLUS, pRHS, 0);
-        yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_EQ, yymsp[-4].minor.yy528, pRHS);
-      }else if( yymsp[-1].minor.yy322->nExpr==1 && pRHS->op==TK_SELECT ){
-        yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy528, 0);
-        sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy528, pRHS->x.pSelect);
+        yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_EQ, yymsp[-4].minor.yy454, pRHS);
+      }else if( yymsp[-1].minor.yy14->nExpr==1 && pRHS->op==TK_SELECT ){
+        yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy454, 0);
+        sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy454, pRHS->x.pSelect);
         pRHS->x.pSelect = 0;
-        sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy322);
-      }else{
-        yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy528, 0);
-        if( yymsp[-4].minor.yy528==0 ){
-          sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy322);
-        }else if( yymsp[-4].minor.yy528->pLeft->op==TK_VECTOR ){
-          int nExpr = yymsp[-4].minor.yy528->pLeft->x.pList->nExpr;
-          Select *pSelectRHS = sqlite3ExprListToValues(pParse, nExpr, yymsp[-1].minor.yy322);
+        sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy14);
+      }else{
+        yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy454, 0);
+        if( yymsp[-4].minor.yy454==0 ){
+          sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy14);
+        }else if( yymsp[-4].minor.yy454->pLeft->op==TK_VECTOR ){
+          int nExpr = yymsp[-4].minor.yy454->pLeft->x.pList->nExpr;
+          Select *pSelectRHS = sqlite3ExprListToValues(pParse, nExpr, yymsp[-1].minor.yy14);
           if( pSelectRHS ){
             parserDoubleLinkSelect(pParse, pSelectRHS);
-            sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy528, pSelectRHS);
+            sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy454, pSelectRHS);
           }
         }else{
-          yymsp[-4].minor.yy528->x.pList = yymsp[-1].minor.yy322;
-          sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy528);
+          yymsp[-4].minor.yy454->x.pList = yymsp[-1].minor.yy14;
+          sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy454);
         }
       }
-      if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0);
+      if( yymsp[-3].minor.yy144 ) yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy454, 0);
     }
   }
         break;
-      case 222: /* expr ::= LP select RP */
+      case 224: /* expr ::= LP select RP */
 {
-    yymsp[-2].minor.yy528 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
-    sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy528, yymsp[-1].minor.yy47);
+    yymsp[-2].minor.yy454 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
+    sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy454, yymsp[-1].minor.yy555);
   }
         break;
-      case 223: /* expr ::= expr in_op LP select RP */
+      case 225: /* expr ::= expr in_op LP select RP */
 {
-    yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy528, 0);
-    sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy528, yymsp[-1].minor.yy47);
-    if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0);
+    yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy454, 0);
+    sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy454, yymsp[-1].minor.yy555);
+    if( yymsp[-3].minor.yy144 ) yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy454, 0);
   }
         break;
-      case 224: /* expr ::= expr in_op nm dbnm paren_exprlist */
+      case 226: /* expr ::= expr in_op nm dbnm paren_exprlist */
 {
     SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
     Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0);
-    if( yymsp[0].minor.yy322 )  sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy322);
-    yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy528, 0);
-    sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy528, pSelect);
-    if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0);
+    if( yymsp[0].minor.yy14 )  sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy14);
+    yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy454, 0);
+    sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy454, pSelect);
+    if( yymsp[-3].minor.yy144 ) yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy454, 0);
   }
         break;
-      case 225: /* expr ::= EXISTS LP select RP */
+      case 227: /* expr ::= EXISTS LP select RP */
 {
     Expr *p;
-    p = yymsp[-3].minor.yy528 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
-    sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy47);
+    p = yymsp[-3].minor.yy454 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
+    sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy555);
   }
         break;
-      case 226: /* expr ::= CASE case_operand case_exprlist case_else END */
+      case 228: /* expr ::= CASE case_operand case_exprlist case_else END */
 {
-  yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy528, 0);
-  if( yymsp[-4].minor.yy528 ){
-    yymsp[-4].minor.yy528->x.pList = yymsp[-1].minor.yy528 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[-1].minor.yy528) : yymsp[-2].minor.yy322;
-    sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy528);
+  yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy454, 0);
+  if( yymsp[-4].minor.yy454 ){
+    yymsp[-4].minor.yy454->x.pList = yymsp[-1].minor.yy454 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy14,yymsp[-1].minor.yy454) : yymsp[-2].minor.yy14;
+    sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy454);
   }else{
-    sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy322);
-    sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy528);
+    sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy14);
+    sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy454);
   }
 }
         break;
-      case 227: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
+      case 229: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
 {
-  yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[-2].minor.yy528);
-  yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[0].minor.yy528);
+  yymsp[-4].minor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14, yymsp[-2].minor.yy454);
+  yymsp[-4].minor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14, yymsp[0].minor.yy454);
 }
         break;
-      case 228: /* case_exprlist ::= WHEN expr THEN expr */
+      case 230: /* case_exprlist ::= WHEN expr THEN expr */
 {
-  yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy528);
-  yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy322, yymsp[0].minor.yy528);
+  yymsp[-3].minor.yy14 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy454);
+  yymsp[-3].minor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy14, yymsp[0].minor.yy454);
 }
         break;
-      case 233: /* nexprlist ::= nexprlist COMMA expr */
-{yymsp[-2].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[0].minor.yy528);}
+      case 235: /* nexprlist ::= nexprlist COMMA expr */
+{yymsp[-2].minor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy14,yymsp[0].minor.yy454);}
         break;
-      case 234: /* nexprlist ::= expr */
-{yymsp[0].minor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy528); /*A-overwrites-Y*/}
+      case 236: /* nexprlist ::= expr */
+{yymsp[0].minor.yy14 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy454); /*A-overwrites-Y*/}
         break;
-      case 236: /* paren_exprlist ::= LP exprlist RP */
-      case 241: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==241);
-{yymsp[-2].minor.yy322 = yymsp[-1].minor.yy322;}
+      case 238: /* paren_exprlist ::= LP exprlist RP */
+      case 243: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==243);
+{yymsp[-2].minor.yy14 = yymsp[-1].minor.yy14;}
         break;
-      case 237: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
+      case 239: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
 {
   sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
-                     sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy322, yymsp[-10].minor.yy394,
-                      &yymsp[-11].minor.yy0, yymsp[0].minor.yy528, SQLITE_SO_ASC, yymsp[-8].minor.yy394, SQLITE_IDXTYPE_APPDEF);
+                     sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy14, yymsp[-10].minor.yy144,
+                      &yymsp[-11].minor.yy0, yymsp[0].minor.yy454, SQLITE_SO_ASC, yymsp[-8].minor.yy144, SQLITE_IDXTYPE_APPDEF);
   if( IN_RENAME_OBJECT && pParse->pNewIndex ){
     sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0);
   }
 }
         break;
-      case 238: /* uniqueflag ::= UNIQUE */
-      case 280: /* raisetype ::= ABORT */ yytestcase(yyruleno==280);
-{yymsp[0].minor.yy394 = OE_Abort;}
+      case 240: /* uniqueflag ::= UNIQUE */
+      case 282: /* raisetype ::= ABORT */ yytestcase(yyruleno==282);
+{yymsp[0].minor.yy144 = OE_Abort;}
         break;
-      case 239: /* uniqueflag ::= */
-{yymsp[1].minor.yy394 = OE_None;}
+      case 241: /* uniqueflag ::= */
+{yymsp[1].minor.yy144 = OE_None;}
         break;
-      case 242: /* eidlist ::= eidlist COMMA nm collate sortorder */
+      case 244: /* eidlist ::= eidlist COMMA nm collate sortorder */
 {
-  yymsp[-4].minor.yy322 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy322, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy394, yymsp[0].minor.yy394);
+  yymsp[-4].minor.yy14 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy14, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy144, yymsp[0].minor.yy144);
 }
         break;
-      case 243: /* eidlist ::= nm collate sortorder */
+      case 245: /* eidlist ::= nm collate sortorder */
 {
-  yymsp[-2].minor.yy322 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy394, yymsp[0].minor.yy394); /*A-overwrites-Y*/
+  yymsp[-2].minor.yy14 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy144, yymsp[0].minor.yy144); /*A-overwrites-Y*/
 }
         break;
-      case 246: /* cmd ::= DROP INDEX ifexists fullname */
-{sqlite3DropIndex(pParse, yymsp[0].minor.yy131, yymsp[-1].minor.yy394);}
+      case 248: /* cmd ::= DROP INDEX ifexists fullname */
+{sqlite3DropIndex(pParse, yymsp[0].minor.yy203, yymsp[-1].minor.yy144);}
         break;
-      case 247: /* cmd ::= VACUUM vinto */
-{sqlite3Vacuum(pParse,0,yymsp[0].minor.yy528);}
+      case 249: /* cmd ::= VACUUM vinto */
+{sqlite3Vacuum(pParse,0,yymsp[0].minor.yy454);}
         break;
-      case 248: /* cmd ::= VACUUM nm vinto */
-{sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy528);}
+      case 250: /* cmd ::= VACUUM nm vinto */
+{sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy454);}
         break;
-      case 251: /* cmd ::= PRAGMA nm dbnm */
+      case 253: /* cmd ::= PRAGMA nm dbnm */
 {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
         break;
-      case 252: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
+      case 254: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
         break;
-      case 253: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
+      case 255: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
         break;
-      case 254: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
+      case 256: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
         break;
-      case 255: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
+      case 257: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
         break;
-      case 258: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
+      case 260: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
 {
   Token all;
   all.z = yymsp[-3].minor.yy0.z;
   all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
-  sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy33, &all);
+  sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy427, &all);
 }
         break;
-      case 259: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
+      case 261: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
 {
-  sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy394, yymsp[-4].minor.yy180.a, yymsp[-4].minor.yy180.b, yymsp[-2].minor.yy131, yymsp[0].minor.yy528, yymsp[-10].minor.yy394, yymsp[-8].minor.yy394);
+  sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy144, yymsp[-4].minor.yy286.a, yymsp[-4].minor.yy286.b, yymsp[-2].minor.yy203, yymsp[0].minor.yy454, yymsp[-10].minor.yy144, yymsp[-8].minor.yy144);
   yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
 }
         break;
-      case 260: /* trigger_time ::= BEFORE|AFTER */
-{ yymsp[0].minor.yy394 = yymsp[0].major; /*A-overwrites-X*/ }
+      case 262: /* trigger_time ::= BEFORE|AFTER */
+{ yymsp[0].minor.yy144 = yymsp[0].major; /*A-overwrites-X*/ }
         break;
-      case 261: /* trigger_time ::= INSTEAD OF */
-{ yymsp[-1].minor.yy394 = TK_INSTEAD;}
+      case 263: /* trigger_time ::= INSTEAD OF */
+{ yymsp[-1].minor.yy144 = TK_INSTEAD;}
         break;
-      case 262: /* trigger_time ::= */
-{ yymsp[1].minor.yy394 = TK_BEFORE; }
+      case 264: /* trigger_time ::= */
+{ yymsp[1].minor.yy144 = TK_BEFORE; }
         break;
-      case 263: /* trigger_event ::= DELETE|INSERT */
-      case 264: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==264);
-{yymsp[0].minor.yy180.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy180.b = 0;}
+      case 265: /* trigger_event ::= DELETE|INSERT */
+      case 266: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==266);
+{yymsp[0].minor.yy286.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy286.b = 0;}
         break;
-      case 265: /* trigger_event ::= UPDATE OF idlist */
-{yymsp[-2].minor.yy180.a = TK_UPDATE; yymsp[-2].minor.yy180.b = yymsp[0].minor.yy254;}
+      case 267: /* trigger_event ::= UPDATE OF idlist */
+{yymsp[-2].minor.yy286.a = TK_UPDATE; yymsp[-2].minor.yy286.b = yymsp[0].minor.yy132;}
         break;
-      case 266: /* when_clause ::= */
-      case 285: /* key_opt ::= */ yytestcase(yyruleno==285);
-{ yymsp[1].minor.yy528 = 0; }
+      case 268: /* when_clause ::= */
+      case 287: /* key_opt ::= */ yytestcase(yyruleno==287);
+{ yymsp[1].minor.yy454 = 0; }
         break;
-      case 267: /* when_clause ::= WHEN expr */
-      case 286: /* key_opt ::= KEY expr */ yytestcase(yyruleno==286);
-{ yymsp[-1].minor.yy528 = yymsp[0].minor.yy528; }
+      case 269: /* when_clause ::= WHEN expr */
+      case 288: /* key_opt ::= KEY expr */ yytestcase(yyruleno==288);
+{ yymsp[-1].minor.yy454 = yymsp[0].minor.yy454; }
         break;
-      case 268: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
+      case 270: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
 {
-  assert( yymsp[-2].minor.yy33!=0 );
-  yymsp[-2].minor.yy33->pLast->pNext = yymsp[-1].minor.yy33;
-  yymsp[-2].minor.yy33->pLast = yymsp[-1].minor.yy33;
+  assert( yymsp[-2].minor.yy427!=0 );
+  yymsp[-2].minor.yy427->pLast->pNext = yymsp[-1].minor.yy427;
+  yymsp[-2].minor.yy427->pLast = yymsp[-1].minor.yy427;
 }
         break;
-      case 269: /* trigger_cmd_list ::= trigger_cmd SEMI */
+      case 271: /* trigger_cmd_list ::= trigger_cmd SEMI */
 {
-  assert( yymsp[-1].minor.yy33!=0 );
-  yymsp[-1].minor.yy33->pLast = yymsp[-1].minor.yy33;
+  assert( yymsp[-1].minor.yy427!=0 );
+  yymsp[-1].minor.yy427->pLast = yymsp[-1].minor.yy427;
 }
         break;
-      case 270: /* trnm ::= nm DOT nm */
+      case 272: /* trnm ::= nm DOT nm */
 {
   yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
   sqlite3ErrorMsg(pParse,
@@ -175663,367 +177291,377 @@ static YYACTIONTYPE yy_reduce(
         "statements within triggers");
 }
         break;
-      case 271: /* tridxby ::= INDEXED BY nm */
+      case 273: /* tridxby ::= INDEXED BY nm */
 {
   sqlite3ErrorMsg(pParse,
         "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
         "within triggers");
 }
         break;
-      case 272: /* tridxby ::= NOT INDEXED */
+      case 274: /* tridxby ::= NOT INDEXED */
 {
   sqlite3ErrorMsg(pParse,
         "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
         "within triggers");
 }
         break;
-      case 273: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
-{yylhsminor.yy33 = sqlite3TriggerUpdateStep(pParse, &yymsp[-6].minor.yy0, yymsp[-2].minor.yy131, yymsp[-3].minor.yy322, yymsp[-1].minor.yy528, yymsp[-7].minor.yy394, yymsp[-8].minor.yy0.z, yymsp[0].minor.yy522);}
-  yymsp[-8].minor.yy33 = yylhsminor.yy33;
+      case 275: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
+{yylhsminor.yy427 = sqlite3TriggerUpdateStep(pParse, &yymsp[-6].minor.yy0, yymsp[-2].minor.yy203, yymsp[-3].minor.yy14, yymsp[-1].minor.yy454, yymsp[-7].minor.yy144, yymsp[-8].minor.yy0.z, yymsp[0].minor.yy168);}
+  yymsp[-8].minor.yy427 = yylhsminor.yy427;
         break;
-      case 274: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
+      case 276: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
 {
-   yylhsminor.yy33 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy254,yymsp[-2].minor.yy47,yymsp[-6].minor.yy394,yymsp[-1].minor.yy444,yymsp[-7].minor.yy522,yymsp[0].minor.yy522);/*yylhsminor.yy33-overwrites-yymsp[-6].minor.yy394*/
+   yylhsminor.yy427 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy132,yymsp[-2].minor.yy555,yymsp[-6].minor.yy144,yymsp[-1].minor.yy122,yymsp[-7].minor.yy168,yymsp[0].minor.yy168);/*yylhsminor.yy427-overwrites-yymsp[-6].minor.yy144*/
 }
-  yymsp[-7].minor.yy33 = yylhsminor.yy33;
+  yymsp[-7].minor.yy427 = yylhsminor.yy427;
         break;
-      case 275: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
-{yylhsminor.yy33 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy528, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy522);}
-  yymsp[-5].minor.yy33 = yylhsminor.yy33;
+      case 277: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
+{yylhsminor.yy427 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy454, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy168);}
+  yymsp[-5].minor.yy427 = yylhsminor.yy427;
         break;
-      case 276: /* trigger_cmd ::= scanpt select scanpt */
-{yylhsminor.yy33 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy47, yymsp[-2].minor.yy522, yymsp[0].minor.yy522); /*yylhsminor.yy33-overwrites-yymsp[-1].minor.yy47*/}
-  yymsp[-2].minor.yy33 = yylhsminor.yy33;
+      case 278: /* trigger_cmd ::= scanpt select scanpt */
+{yylhsminor.yy427 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy555, yymsp[-2].minor.yy168, yymsp[0].minor.yy168); /*yylhsminor.yy427-overwrites-yymsp[-1].minor.yy555*/}
+  yymsp[-2].minor.yy427 = yylhsminor.yy427;
         break;
-      case 277: /* expr ::= RAISE LP IGNORE RP */
+      case 279: /* expr ::= RAISE LP IGNORE RP */
 {
-  yymsp[-3].minor.yy528 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
-  if( yymsp[-3].minor.yy528 ){
-    yymsp[-3].minor.yy528->affExpr = OE_Ignore;
+  yymsp[-3].minor.yy454 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
+  if( yymsp[-3].minor.yy454 ){
+    yymsp[-3].minor.yy454->affExpr = OE_Ignore;
   }
 }
         break;
-      case 278: /* expr ::= RAISE LP raisetype COMMA nm RP */
+      case 280: /* expr ::= RAISE LP raisetype COMMA nm RP */
 {
-  yymsp[-5].minor.yy528 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
-  if( yymsp[-5].minor.yy528 ) {
-    yymsp[-5].minor.yy528->affExpr = (char)yymsp[-3].minor.yy394;
+  yymsp[-5].minor.yy454 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
+  if( yymsp[-5].minor.yy454 ) {
+    yymsp[-5].minor.yy454->affExpr = (char)yymsp[-3].minor.yy144;
   }
 }
         break;
-      case 279: /* raisetype ::= ROLLBACK */
-{yymsp[0].minor.yy394 = OE_Rollback;}
+      case 281: /* raisetype ::= ROLLBACK */
+{yymsp[0].minor.yy144 = OE_Rollback;}
         break;
-      case 281: /* raisetype ::= FAIL */
-{yymsp[0].minor.yy394 = OE_Fail;}
+      case 283: /* raisetype ::= FAIL */
+{yymsp[0].minor.yy144 = OE_Fail;}
         break;
-      case 282: /* cmd ::= DROP TRIGGER ifexists fullname */
+      case 284: /* cmd ::= DROP TRIGGER ifexists fullname */
 {
-  sqlite3DropTrigger(pParse,yymsp[0].minor.yy131,yymsp[-1].minor.yy394);
+  sqlite3DropTrigger(pParse,yymsp[0].minor.yy203,yymsp[-1].minor.yy144);
 }
         break;
-      case 283: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
+      case 285: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
 {
-  sqlite3Attach(pParse, yymsp[-3].minor.yy528, yymsp[-1].minor.yy528, yymsp[0].minor.yy528);
+  sqlite3Attach(pParse, yymsp[-3].minor.yy454, yymsp[-1].minor.yy454, yymsp[0].minor.yy454);
 }
         break;
-      case 284: /* cmd ::= DETACH database_kw_opt expr */
+      case 286: /* cmd ::= DETACH database_kw_opt expr */
 {
-  sqlite3Detach(pParse, yymsp[0].minor.yy528);
+  sqlite3Detach(pParse, yymsp[0].minor.yy454);
 }
         break;
-      case 287: /* cmd ::= REINDEX */
+      case 289: /* cmd ::= REINDEX */
 {sqlite3Reindex(pParse, 0, 0);}
         break;
-      case 288: /* cmd ::= REINDEX nm dbnm */
+      case 290: /* cmd ::= REINDEX nm dbnm */
 {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
         break;
-      case 289: /* cmd ::= ANALYZE */
+      case 291: /* cmd ::= ANALYZE */
 {sqlite3Analyze(pParse, 0, 0);}
         break;
-      case 290: /* cmd ::= ANALYZE nm dbnm */
+      case 292: /* cmd ::= ANALYZE nm dbnm */
 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
         break;
-      case 291: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
+      case 293: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
 {
-  sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy131,&yymsp[0].minor.yy0);
+  sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy203,&yymsp[0].minor.yy0);
 }
         break;
-      case 292: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
+      case 294: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
 {
   yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
   sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
 }
         break;
-      case 293: /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
+      case 295: /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
 {
-  sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy131, &yymsp[0].minor.yy0);
+  sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy203, &yymsp[0].minor.yy0);
 }
         break;
-      case 294: /* add_column_fullname ::= fullname */
+      case 296: /* add_column_fullname ::= fullname */
 {
   disableLookaside(pParse);
-  sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy131);
+  sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy203);
 }
         break;
-      case 295: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
+      case 297: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
 {
-  sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy131, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
+  sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy203, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
 }
         break;
-      case 296: /* cmd ::= create_vtab */
+      case 298: /* cmd ::= create_vtab */
 {sqlite3VtabFinishParse(pParse,0);}
         break;
-      case 297: /* cmd ::= create_vtab LP vtabarglist RP */
+      case 299: /* cmd ::= create_vtab LP vtabarglist RP */
 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
         break;
-      case 298: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
+      case 300: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
 {
-    sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy394);
+    sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy144);
 }
         break;
-      case 299: /* vtabarg ::= */
+      case 301: /* vtabarg ::= */
 {sqlite3VtabArgInit(pParse);}
         break;
-      case 300: /* vtabargtoken ::= ANY */
-      case 301: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==301);
-      case 302: /* lp ::= LP */ yytestcase(yyruleno==302);
+      case 302: /* vtabargtoken ::= ANY */
+      case 303: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==303);
+      case 304: /* lp ::= LP */ yytestcase(yyruleno==304);
 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
         break;
-      case 303: /* with ::= WITH wqlist */
-      case 304: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==304);
-{ sqlite3WithPush(pParse, yymsp[0].minor.yy521, 1); }
+      case 305: /* with ::= WITH wqlist */
+      case 306: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==306);
+{ sqlite3WithPush(pParse, yymsp[0].minor.yy59, 1); }
         break;
-      case 305: /* wqas ::= AS */
-{yymsp[0].minor.yy516 = M10d_Any;}
+      case 307: /* wqas ::= AS */
+{yymsp[0].minor.yy462 = M10d_Any;}
         break;
-      case 306: /* wqas ::= AS MATERIALIZED */
-{yymsp[-1].minor.yy516 = M10d_Yes;}
+      case 308: /* wqas ::= AS MATERIALIZED */
+{yymsp[-1].minor.yy462 = M10d_Yes;}
         break;
-      case 307: /* wqas ::= AS NOT MATERIALIZED */
-{yymsp[-2].minor.yy516 = M10d_No;}
+      case 309: /* wqas ::= AS NOT MATERIALIZED */
+{yymsp[-2].minor.yy462 = M10d_No;}
         break;
-      case 308: /* wqitem ::= nm eidlist_opt wqas LP select RP */
+      case 310: /* wqitem ::= withnm eidlist_opt wqas LP select RP */
 {
-  yymsp[-5].minor.yy385 = sqlite3CteNew(pParse, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy322, yymsp[-1].minor.yy47, yymsp[-3].minor.yy516); /*A-overwrites-X*/
+  yymsp[-5].minor.yy67 = sqlite3CteNew(pParse, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy14, yymsp[-1].minor.yy555, yymsp[-3].minor.yy462); /*A-overwrites-X*/
 }
         break;
-      case 309: /* wqlist ::= wqitem */
+      case 311: /* withnm ::= nm */
+{pParse->bHasWith = 1;}
+        break;
+      case 312: /* wqlist ::= wqitem */
 {
-  yymsp[0].minor.yy521 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy385); /*A-overwrites-X*/
+  yymsp[0].minor.yy59 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy67); /*A-overwrites-X*/
 }
         break;
-      case 310: /* wqlist ::= wqlist COMMA wqitem */
+      case 313: /* wqlist ::= wqlist COMMA wqitem */
 {
-  yymsp[-2].minor.yy521 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy521, yymsp[0].minor.yy385);
+  yymsp[-2].minor.yy59 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy59, yymsp[0].minor.yy67);
 }
         break;
-      case 311: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */
+      case 314: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */
 {
-  assert( yymsp[0].minor.yy41!=0 );
-  sqlite3WindowChain(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy41);
-  yymsp[0].minor.yy41->pNextWin = yymsp[-2].minor.yy41;
-  yylhsminor.yy41 = yymsp[0].minor.yy41;
+  assert( yymsp[0].minor.yy211!=0 );
+  sqlite3WindowChain(pParse, yymsp[0].minor.yy211, yymsp[-2].minor.yy211);
+  yymsp[0].minor.yy211->pNextWin = yymsp[-2].minor.yy211;
+  yylhsminor.yy211 = yymsp[0].minor.yy211;
 }
-  yymsp[-2].minor.yy41 = yylhsminor.yy41;
+  yymsp[-2].minor.yy211 = yylhsminor.yy211;
         break;
-      case 312: /* windowdefn ::= nm AS LP window RP */
+      case 315: /* windowdefn ::= nm AS LP window RP */
 {
-  if( ALWAYS(yymsp[-1].minor.yy41) ){
-    yymsp[-1].minor.yy41->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n);
+  if( ALWAYS(yymsp[-1].minor.yy211) ){
+    yymsp[-1].minor.yy211->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n);
   }
-  yylhsminor.yy41 = yymsp[-1].minor.yy41;
+  yylhsminor.yy211 = yymsp[-1].minor.yy211;
 }
-  yymsp[-4].minor.yy41 = yylhsminor.yy41;
+  yymsp[-4].minor.yy211 = yylhsminor.yy211;
         break;
-      case 313: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */
+      case 316: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */
 {
-  yymsp[-4].minor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy322, yymsp[-1].minor.yy322, 0);
+  yymsp[-4].minor.yy211 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy211, yymsp[-2].minor.yy14, yymsp[-1].minor.yy14, 0);
 }
         break;
-      case 314: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
+      case 317: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
 {
-  yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy322, yymsp[-1].minor.yy322, &yymsp[-5].minor.yy0);
+  yylhsminor.yy211 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy211, yymsp[-2].minor.yy14, yymsp[-1].minor.yy14, &yymsp[-5].minor.yy0);
 }
-  yymsp[-5].minor.yy41 = yylhsminor.yy41;
+  yymsp[-5].minor.yy211 = yylhsminor.yy211;
         break;
-      case 315: /* window ::= ORDER BY sortlist frame_opt */
+      case 318: /* window ::= ORDER BY sortlist frame_opt */
 {
-  yymsp[-3].minor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, yymsp[-1].minor.yy322, 0);
+  yymsp[-3].minor.yy211 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy211, 0, yymsp[-1].minor.yy14, 0);
 }
         break;
-      case 316: /* window ::= nm ORDER BY sortlist frame_opt */
+      case 319: /* window ::= nm ORDER BY sortlist frame_opt */
 {
-  yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, yymsp[-1].minor.yy322, &yymsp[-4].minor.yy0);
+  yylhsminor.yy211 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy211, 0, yymsp[-1].minor.yy14, &yymsp[-4].minor.yy0);
 }
-  yymsp[-4].minor.yy41 = yylhsminor.yy41;
+  yymsp[-4].minor.yy211 = yylhsminor.yy211;
         break;
-      case 317: /* window ::= nm frame_opt */
+      case 320: /* window ::= nm frame_opt */
 {
-  yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, 0, &yymsp[-1].minor.yy0);
+  yylhsminor.yy211 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy211, 0, 0, &yymsp[-1].minor.yy0);
 }
-  yymsp[-1].minor.yy41 = yylhsminor.yy41;
+  yymsp[-1].minor.yy211 = yylhsminor.yy211;
         break;
-      case 318: /* frame_opt ::= */
+      case 321: /* frame_opt ::= */
 {
-  yymsp[1].minor.yy41 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0);
+  yymsp[1].minor.yy211 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0);
 }
         break;
-      case 319: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
+      case 322: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
 {
-  yylhsminor.yy41 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy394, yymsp[-1].minor.yy595.eType, yymsp[-1].minor.yy595.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy516);
+  yylhsminor.yy211 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy144, yymsp[-1].minor.yy509.eType, yymsp[-1].minor.yy509.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy462);
 }
-  yymsp[-2].minor.yy41 = yylhsminor.yy41;
+  yymsp[-2].minor.yy211 = yylhsminor.yy211;
         break;
-      case 320: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
+      case 323: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
 {
-  yylhsminor.yy41 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy394, yymsp[-3].minor.yy595.eType, yymsp[-3].minor.yy595.pExpr, yymsp[-1].minor.yy595.eType, yymsp[-1].minor.yy595.pExpr, yymsp[0].minor.yy516);
+  yylhsminor.yy211 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy144, yymsp[-3].minor.yy509.eType, yymsp[-3].minor.yy509.pExpr, yymsp[-1].minor.yy509.eType, yymsp[-1].minor.yy509.pExpr, yymsp[0].minor.yy462);
 }
-  yymsp[-5].minor.yy41 = yylhsminor.yy41;
+  yymsp[-5].minor.yy211 = yylhsminor.yy211;
         break;
-      case 322: /* frame_bound_s ::= frame_bound */
-      case 324: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==324);
-{yylhsminor.yy595 = yymsp[0].minor.yy595;}
-  yymsp[0].minor.yy595 = yylhsminor.yy595;
+      case 325: /* frame_bound_s ::= frame_bound */
+      case 327: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==327);
+{yylhsminor.yy509 = yymsp[0].minor.yy509;}
+  yymsp[0].minor.yy509 = yylhsminor.yy509;
         break;
-      case 323: /* frame_bound_s ::= UNBOUNDED PRECEDING */
-      case 325: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==325);
-      case 327: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==327);
-{yylhsminor.yy595.eType = yymsp[-1].major; yylhsminor.yy595.pExpr = 0;}
-  yymsp[-1].minor.yy595 = yylhsminor.yy595;
+      case 326: /* frame_bound_s ::= UNBOUNDED PRECEDING */
+      case 328: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==328);
+      case 330: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==330);
+{yylhsminor.yy509.eType = yymsp[-1].major; yylhsminor.yy509.pExpr = 0;}
+  yymsp[-1].minor.yy509 = yylhsminor.yy509;
         break;
-      case 326: /* frame_bound ::= expr PRECEDING|FOLLOWING */
-{yylhsminor.yy595.eType = yymsp[0].major; yylhsminor.yy595.pExpr = yymsp[-1].minor.yy528;}
-  yymsp[-1].minor.yy595 = yylhsminor.yy595;
+      case 329: /* frame_bound ::= expr PRECEDING|FOLLOWING */
+{yylhsminor.yy509.eType = yymsp[0].major; yylhsminor.yy509.pExpr = yymsp[-1].minor.yy454;}
+  yymsp[-1].minor.yy509 = yylhsminor.yy509;
         break;
-      case 328: /* frame_exclude_opt ::= */
-{yymsp[1].minor.yy516 = 0;}
+      case 331: /* frame_exclude_opt ::= */
+{yymsp[1].minor.yy462 = 0;}
         break;
-      case 329: /* frame_exclude_opt ::= EXCLUDE frame_exclude */
-{yymsp[-1].minor.yy516 = yymsp[0].minor.yy516;}
+      case 332: /* frame_exclude_opt ::= EXCLUDE frame_exclude */
+{yymsp[-1].minor.yy462 = yymsp[0].minor.yy462;}
         break;
-      case 330: /* frame_exclude ::= NO OTHERS */
-      case 331: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==331);
-{yymsp[-1].minor.yy516 = yymsp[-1].major; /*A-overwrites-X*/}
+      case 333: /* frame_exclude ::= NO OTHERS */
+      case 334: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==334);
+{yymsp[-1].minor.yy462 = yymsp[-1].major; /*A-overwrites-X*/}
         break;
-      case 332: /* frame_exclude ::= GROUP|TIES */
-{yymsp[0].minor.yy516 = yymsp[0].major; /*A-overwrites-X*/}
+      case 335: /* frame_exclude ::= GROUP|TIES */
+{yymsp[0].minor.yy462 = yymsp[0].major; /*A-overwrites-X*/}
         break;
-      case 333: /* window_clause ::= WINDOW windowdefn_list */
-{ yymsp[-1].minor.yy41 = yymsp[0].minor.yy41; }
+      case 336: /* window_clause ::= WINDOW windowdefn_list */
+{ yymsp[-1].minor.yy211 = yymsp[0].minor.yy211; }
         break;
-      case 334: /* filter_over ::= filter_clause over_clause */
+      case 337: /* filter_over ::= filter_clause over_clause */
 {
-  if( yymsp[0].minor.yy41 ){
-    yymsp[0].minor.yy41->pFilter = yymsp[-1].minor.yy528;
+  if( yymsp[0].minor.yy211 ){
+    yymsp[0].minor.yy211->pFilter = yymsp[-1].minor.yy454;
   }else{
-    sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy528);
+    sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy454);
   }
-  yylhsminor.yy41 = yymsp[0].minor.yy41;
+  yylhsminor.yy211 = yymsp[0].minor.yy211;
 }
-  yymsp[-1].minor.yy41 = yylhsminor.yy41;
+  yymsp[-1].minor.yy211 = yylhsminor.yy211;
         break;
-      case 335: /* filter_over ::= over_clause */
+      case 338: /* filter_over ::= over_clause */
 {
-  yylhsminor.yy41 = yymsp[0].minor.yy41;
+  yylhsminor.yy211 = yymsp[0].minor.yy211;
 }
-  yymsp[0].minor.yy41 = yylhsminor.yy41;
+  yymsp[0].minor.yy211 = yylhsminor.yy211;
         break;
-      case 336: /* filter_over ::= filter_clause */
+      case 339: /* filter_over ::= filter_clause */
 {
-  yylhsminor.yy41 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
-  if( yylhsminor.yy41 ){
-    yylhsminor.yy41->eFrmType = TK_FILTER;
-    yylhsminor.yy41->pFilter = yymsp[0].minor.yy528;
+  yylhsminor.yy211 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
+  if( yylhsminor.yy211 ){
+    yylhsminor.yy211->eFrmType = TK_FILTER;
+    yylhsminor.yy211->pFilter = yymsp[0].minor.yy454;
   }else{
-    sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy528);
+    sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy454);
   }
 }
-  yymsp[0].minor.yy41 = yylhsminor.yy41;
+  yymsp[0].minor.yy211 = yylhsminor.yy211;
         break;
-      case 337: /* over_clause ::= OVER LP window RP */
+      case 340: /* over_clause ::= OVER LP window RP */
 {
-  yymsp[-3].minor.yy41 = yymsp[-1].minor.yy41;
-  assert( yymsp[-3].minor.yy41!=0 );
+  yymsp[-3].minor.yy211 = yymsp[-1].minor.yy211;
+  assert( yymsp[-3].minor.yy211!=0 );
 }
         break;
-      case 338: /* over_clause ::= OVER nm */
+      case 341: /* over_clause ::= OVER nm */
 {
-  yymsp[-1].minor.yy41 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
-  if( yymsp[-1].minor.yy41 ){
-    yymsp[-1].minor.yy41->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
+  yymsp[-1].minor.yy211 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
+  if( yymsp[-1].minor.yy211 ){
+    yymsp[-1].minor.yy211->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
   }
 }
         break;
-      case 339: /* filter_clause ::= FILTER LP WHERE expr RP */
-{ yymsp[-4].minor.yy528 = yymsp[-1].minor.yy528; }
+      case 342: /* filter_clause ::= FILTER LP WHERE expr RP */
+{ yymsp[-4].minor.yy454 = yymsp[-1].minor.yy454; }
+        break;
+      case 343: /* term ::= QNUMBER */
+{
+  yylhsminor.yy454=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0);
+  sqlite3DequoteNumber(pParse, yylhsminor.yy454);
+}
+  yymsp[0].minor.yy454 = yylhsminor.yy454;
         break;
       default:
-      /* (340) input ::= cmdlist */ yytestcase(yyruleno==340);
-      /* (341) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==341);
-      /* (342) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=342);
-      /* (343) ecmd ::= SEMI */ yytestcase(yyruleno==343);
-      /* (344) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==344);
-      /* (345) ecmd ::= explain cmdx SEMI (NEVER REDUCES) */ assert(yyruleno!=345);
-      /* (346) trans_opt ::= */ yytestcase(yyruleno==346);
-      /* (347) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==347);
-      /* (348) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==348);
-      /* (349) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==349);
-      /* (350) savepoint_opt ::= */ yytestcase(yyruleno==350);
-      /* (351) cmd ::= create_table create_table_args */ yytestcase(yyruleno==351);
-      /* (352) table_option_set ::= table_option (OPTIMIZED OUT) */ assert(yyruleno!=352);
-      /* (353) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==353);
-      /* (354) columnlist ::= columnname carglist */ yytestcase(yyruleno==354);
-      /* (355) nm ::= ID|INDEXED|JOIN_KW */ yytestcase(yyruleno==355);
-      /* (356) nm ::= STRING */ yytestcase(yyruleno==356);
-      /* (357) typetoken ::= typename */ yytestcase(yyruleno==357);
-      /* (358) typename ::= ID|STRING */ yytestcase(yyruleno==358);
-      /* (359) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=359);
-      /* (360) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=360);
-      /* (361) carglist ::= carglist ccons */ yytestcase(yyruleno==361);
-      /* (362) carglist ::= */ yytestcase(yyruleno==362);
-      /* (363) ccons ::= NULL onconf */ yytestcase(yyruleno==363);
-      /* (364) ccons ::= GENERATED ALWAYS AS generated */ yytestcase(yyruleno==364);
-      /* (365) ccons ::= AS generated */ yytestcase(yyruleno==365);
-      /* (366) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==366);
-      /* (367) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==367);
-      /* (368) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=368);
-      /* (369) tconscomma ::= */ yytestcase(yyruleno==369);
-      /* (370) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=370);
-      /* (371) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=371);
-      /* (372) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=372);
-      /* (373) oneselect ::= values */ yytestcase(yyruleno==373);
-      /* (374) sclp ::= selcollist COMMA */ yytestcase(yyruleno==374);
-      /* (375) as ::= ID|STRING */ yytestcase(yyruleno==375);
-      /* (376) indexed_opt ::= indexed_by (OPTIMIZED OUT) */ assert(yyruleno!=376);
-      /* (377) returning ::= */ yytestcase(yyruleno==377);
-      /* (378) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=378);
-      /* (379) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==379);
-      /* (380) case_operand ::= expr */ yytestcase(yyruleno==380);
-      /* (381) exprlist ::= nexprlist */ yytestcase(yyruleno==381);
-      /* (382) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=382);
-      /* (383) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=383);
-      /* (384) nmnum ::= ON */ yytestcase(yyruleno==384);
-      /* (385) nmnum ::= DELETE */ yytestcase(yyruleno==385);
-      /* (386) nmnum ::= DEFAULT */ yytestcase(yyruleno==386);
-      /* (387) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==387);
-      /* (388) foreach_clause ::= */ yytestcase(yyruleno==388);
-      /* (389) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==389);
-      /* (390) trnm ::= nm */ yytestcase(yyruleno==390);
-      /* (391) tridxby ::= */ yytestcase(yyruleno==391);
-      /* (392) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==392);
-      /* (393) database_kw_opt ::= */ yytestcase(yyruleno==393);
-      /* (394) kwcolumn_opt ::= */ yytestcase(yyruleno==394);
-      /* (395) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==395);
-      /* (396) vtabarglist ::= vtabarg */ yytestcase(yyruleno==396);
-      /* (397) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==397);
-      /* (398) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==398);
-      /* (399) anylist ::= */ yytestcase(yyruleno==399);
-      /* (400) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==400);
-      /* (401) anylist ::= anylist ANY */ yytestcase(yyruleno==401);
-      /* (402) with ::= */ yytestcase(yyruleno==402);
-      /* (403) windowdefn_list ::= windowdefn (OPTIMIZED OUT) */ assert(yyruleno!=403);
-      /* (404) window ::= frame_opt (OPTIMIZED OUT) */ assert(yyruleno!=404);
+      /* (344) input ::= cmdlist */ yytestcase(yyruleno==344);
+      /* (345) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==345);
+      /* (346) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=346);
+      /* (347) ecmd ::= SEMI */ yytestcase(yyruleno==347);
+      /* (348) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==348);
+      /* (349) ecmd ::= explain cmdx SEMI (NEVER REDUCES) */ assert(yyruleno!=349);
+      /* (350) trans_opt ::= */ yytestcase(yyruleno==350);
+      /* (351) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==351);
+      /* (352) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==352);
+      /* (353) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==353);
+      /* (354) savepoint_opt ::= */ yytestcase(yyruleno==354);
+      /* (355) cmd ::= create_table create_table_args */ yytestcase(yyruleno==355);
+      /* (356) table_option_set ::= table_option (OPTIMIZED OUT) */ assert(yyruleno!=356);
+      /* (357) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==357);
+      /* (358) columnlist ::= columnname carglist */ yytestcase(yyruleno==358);
+      /* (359) nm ::= ID|INDEXED|JOIN_KW */ yytestcase(yyruleno==359);
+      /* (360) nm ::= STRING */ yytestcase(yyruleno==360);
+      /* (361) typetoken ::= typename */ yytestcase(yyruleno==361);
+      /* (362) typename ::= ID|STRING */ yytestcase(yyruleno==362);
+      /* (363) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=363);
+      /* (364) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=364);
+      /* (365) carglist ::= carglist ccons */ yytestcase(yyruleno==365);
+      /* (366) carglist ::= */ yytestcase(yyruleno==366);
+      /* (367) ccons ::= NULL onconf */ yytestcase(yyruleno==367);
+      /* (368) ccons ::= GENERATED ALWAYS AS generated */ yytestcase(yyruleno==368);
+      /* (369) ccons ::= AS generated */ yytestcase(yyruleno==369);
+      /* (370) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==370);
+      /* (371) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==371);
+      /* (372) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=372);
+      /* (373) tconscomma ::= */ yytestcase(yyruleno==373);
+      /* (374) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=374);
+      /* (375) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=375);
+      /* (376) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=376);
+      /* (377) oneselect ::= values */ yytestcase(yyruleno==377);
+      /* (378) sclp ::= selcollist COMMA */ yytestcase(yyruleno==378);
+      /* (379) as ::= ID|STRING */ yytestcase(yyruleno==379);
+      /* (380) indexed_opt ::= indexed_by (OPTIMIZED OUT) */ assert(yyruleno!=380);
+      /* (381) returning ::= */ yytestcase(yyruleno==381);
+      /* (382) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=382);
+      /* (383) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==383);
+      /* (384) case_operand ::= expr */ yytestcase(yyruleno==384);
+      /* (385) exprlist ::= nexprlist */ yytestcase(yyruleno==385);
+      /* (386) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=386);
+      /* (387) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=387);
+      /* (388) nmnum ::= ON */ yytestcase(yyruleno==388);
+      /* (389) nmnum ::= DELETE */ yytestcase(yyruleno==389);
+      /* (390) nmnum ::= DEFAULT */ yytestcase(yyruleno==390);
+      /* (391) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==391);
+      /* (392) foreach_clause ::= */ yytestcase(yyruleno==392);
+      /* (393) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==393);
+      /* (394) trnm ::= nm */ yytestcase(yyruleno==394);
+      /* (395) tridxby ::= */ yytestcase(yyruleno==395);
+      /* (396) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==396);
+      /* (397) database_kw_opt ::= */ yytestcase(yyruleno==397);
+      /* (398) kwcolumn_opt ::= */ yytestcase(yyruleno==398);
+      /* (399) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==399);
+      /* (400) vtabarglist ::= vtabarg */ yytestcase(yyruleno==400);
+      /* (401) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==401);
+      /* (402) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==402);
+      /* (403) anylist ::= */ yytestcase(yyruleno==403);
+      /* (404) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==404);
+      /* (405) anylist ::= anylist ANY */ yytestcase(yyruleno==405);
+      /* (406) with ::= */ yytestcase(yyruleno==406);
+      /* (407) windowdefn_list ::= windowdefn (OPTIMIZED OUT) */ assert(yyruleno!=407);
+      /* (408) window ::= frame_opt (OPTIMIZED OUT) */ assert(yyruleno!=408);
         break;
 /********** End reduce actions ************************************************/
   };
@@ -176210,19 +177848,12 @@ SQLITE_PRIVATE void sqlite3Parser(
                   (int)(yypParser->yytos - yypParser->yystack));
         }
 #endif
-#if YYSTACKDEPTH>0
         if( yypParser->yytos>=yypParser->yystackEnd ){
-          yyStackOverflow(yypParser);
-          break;
-        }
-#else
-        if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){
           if( yyGrowStack(yypParser) ){
             yyStackOverflow(yypParser);
             break;
           }
         }
-#endif
       }
       yyact = yy_reduce(yypParser,yyruleno,yymajor,yyminor sqlite3ParserCTX_PARAM);
     }else if( yyact <= YY_MAX_SHIFTREDUCE ){
@@ -177293,27 +178924,58 @@ SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *z, int *tokenType){
       *tokenType = TK_INTEGER;
 #ifndef SQLITE_OMIT_HEX_INTEGER
       if( z[0]=='0' && (z[1]=='x' || z[1]=='X') && sqlite3Isxdigit(z[2]) ){
-        for(i=3; sqlite3Isxdigit(z[i]); i++){}
-        return i;
-      }
+        for(i=3; 1; i++){
+          if( sqlite3Isxdigit(z[i])==0 ){
+            if( z[i]==SQLITE_DIGIT_SEPARATOR ){
+              *tokenType = TK_QNUMBER;
+            }else{
+              break;
+            }
+          }
+        }
+      }else
 #endif
-      for(i=0; sqlite3Isdigit(z[i]); i++){}
+        {
+        for(i=0; 1; i++){
+          if( sqlite3Isdigit(z[i])==0 ){
+            if( z[i]==SQLITE_DIGIT_SEPARATOR ){
+              *tokenType = TK_QNUMBER;
+            }else{
+              break;
+            }
+          }
+        }
 #ifndef SQLITE_OMIT_FLOATING_POINT
-      if( z[i]=='.' ){
-        i++;
-        while( sqlite3Isdigit(z[i]) ){ i++; }
-        *tokenType = TK_FLOAT;
-      }
-      if( (z[i]=='e' || z[i]=='E') &&
-           ( sqlite3Isdigit(z[i+1])
-            || ((z[i+1]=='+' || z[i+1]=='-') && sqlite3Isdigit(z[i+2]))
-           )
-      ){
-        i += 2;
-        while( sqlite3Isdigit(z[i]) ){ i++; }
-        *tokenType = TK_FLOAT;
-      }
+        if( z[i]=='.' ){
+          if( *tokenType==TK_INTEGER ) *tokenType = TK_FLOAT;
+          for(i++; 1; i++){
+            if( sqlite3Isdigit(z[i])==0 ){
+              if( z[i]==SQLITE_DIGIT_SEPARATOR ){
+                *tokenType = TK_QNUMBER;
+              }else{
+                break;
+              }
+            }
+          }
+        }
+        if( (z[i]=='e' || z[i]=='E') &&
+             ( sqlite3Isdigit(z[i+1])
+              || ((z[i+1]=='+' || z[i+1]=='-') && sqlite3Isdigit(z[i+2]))
+             )
+        ){
+          if( *tokenType==TK_INTEGER ) *tokenType = TK_FLOAT;
+          for(i+=2; 1; i++){
+            if( sqlite3Isdigit(z[i])==0 ){
+              if( z[i]==SQLITE_DIGIT_SEPARATOR ){
+                *tokenType = TK_QNUMBER;
+              }else{
+                break;
+              }
+            }
+          }
+        }
 #endif
+      }
       while( IdChar(z[i]) ){
         *tokenType = TK_ILLEGAL;
         i++;
@@ -177478,10 +179140,13 @@ SQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql){
     if( tokenType>=TK_WINDOW ){
       assert( tokenType==TK_SPACE || tokenType==TK_OVER || tokenType==TK_FILTER
            || tokenType==TK_ILLEGAL || tokenType==TK_WINDOW
+           || tokenType==TK_QNUMBER
       );
 #else
     if( tokenType>=TK_SPACE ){
-      assert( tokenType==TK_SPACE || tokenType==TK_ILLEGAL );
+      assert( tokenType==TK_SPACE || tokenType==TK_ILLEGAL
+           || tokenType==TK_QNUMBER
+      );
 #endif /* SQLITE_OMIT_WINDOWFUNC */
       if( AtomicLoad(&db->u1.isInterrupted) ){
         pParse->rc = SQLITE_INTERRUPT;
@@ -177514,7 +179179,7 @@ SQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql){
         assert( n==6 );
         tokenType = analyzeFilterKeyword((const u8*)&zSql[6], lastTokenParsed);
 #endif /* SQLITE_OMIT_WINDOWFUNC */
-      }else{
+      }else if( tokenType!=TK_QNUMBER ){
         Token x;
         x.z = zSql;
         x.n = n;
@@ -178865,6 +180530,18 @@ SQLITE_API int sqlite3_config(int op, ...){
     }
 #endif /* SQLITE_OMIT_DESERIALIZE */
 
+    case SQLITE_CONFIG_ROWID_IN_VIEW: {
+      int *pVal = va_arg(ap,int*);
+#ifdef SQLITE_ALLOW_ROWID_IN_VIEW
+      if( 0==*pVal ) sqlite3GlobalConfig.mNoVisibleRowid = TF_NoVisibleRowid;
+      if( 1==*pVal ) sqlite3GlobalConfig.mNoVisibleRowid = 0;
+      *pVal = (sqlite3GlobalConfig.mNoVisibleRowid==0);
+#else
+      *pVal = 0;
+#endif
+      break;
+    }
+
     default: {
       rc = SQLITE_ERROR;
       break;
@@ -188497,22 +190174,24 @@ static int fts3IntegrityMethod(
   char **pzErr              /* Write error message here */
 ){
   Fts3Table *p = (Fts3Table*)pVtab;
-  int rc;
+  int rc = SQLITE_OK;
   int bOk = 0;
 
   UNUSED_PARAMETER(isQuick);
   rc = sqlite3Fts3IntegrityCheck(p, &bOk);
-  assert( rc!=SQLITE_CORRUPT_VTAB || bOk==0 );
-  if( rc!=SQLITE_OK && rc!=SQLITE_CORRUPT_VTAB ){
+  assert( rc!=SQLITE_CORRUPT_VTAB );
+  if( rc==SQLITE_ERROR || (rc&0xFF)==SQLITE_CORRUPT ){
     *pzErr = sqlite3_mprintf("unable to validate the inverted index for"
                              " FTS%d table %s.%s: %s",
                 p->bFts4 ? 4 : 3, zSchema, zTabname, sqlite3_errstr(rc));
-  }else if( bOk==0 ){
+    if( *pzErr ) rc = SQLITE_OK;
+  }else if( rc==SQLITE_OK && bOk==0 ){
     *pzErr = sqlite3_mprintf("malformed inverted index for FTS%d table %s.%s",
                 p->bFts4 ? 4 : 3, zSchema, zTabname);
+    if( *pzErr==0 ) rc = SQLITE_NOMEM;
   }
   sqlite3Fts3SegmentsClose(p);
-  return SQLITE_OK;
+  return rc;
 }
 
 
@@ -200174,7 +201853,12 @@ SQLITE_PRIVATE int sqlite3Fts3IntegrityCheck(Fts3Table *p, int *pbOk){
     sqlite3_finalize(pStmt);
   }
 
-  *pbOk = (rc==SQLITE_OK && cksum1==cksum2);
+  if( rc==SQLITE_CORRUPT_VTAB ){
+    rc = SQLITE_OK;
+    *pbOk = 0;
+  }else{
+    *pbOk = (rc==SQLITE_OK && cksum1==cksum2);
+  }
   return rc;
 }
 
@@ -201080,7 +202764,7 @@ static void fts3SnippetDetails(
         }
         mCover |= mPhrase;
 
-        for(j=0; j<pPhrase->nToken; j++){
+        for(j=0; j<pPhrase->nToken && j<pIter->nSnippet; j++){
           mHighlight |= (mPos>>j);
         }
 
@@ -203741,7 +205425,6 @@ static void jsonAppendRawNZ(JsonString *p, const char *zIn, u32 N){
   }
 }
 
-
 /* Append formatted text (not to exceed N bytes) to the JsonString.
 */
 static void jsonPrintf(int N, JsonString *p, const char *zFormat, ...){
@@ -203799,6 +205482,40 @@ static void jsonAppendSeparator(JsonString *p){
   jsonAppendChar(p, ',');
 }
 
+/* c is a control character.  Append the canonical JSON representation
+** of that control character to p.
+**
+** This routine assumes that the output buffer has already been enlarged
+** sufficiently to hold the worst-case encoding plus a nul terminator.
+*/
+static void jsonAppendControlChar(JsonString *p, u8 c){
+  static const char aSpecial[] = {
+     0, 0, 0, 0, 0, 0, 0, 0, 'b', 't', 'n', 0, 'f', 'r', 0, 0,
+     0, 0, 0, 0, 0, 0, 0, 0,   0,   0,   0, 0,   0,   0, 0, 0
+  };
+  assert( sizeof(aSpecial)==32 );
+  assert( aSpecial['\b']=='b' );
+  assert( aSpecial['\f']=='f' );
+  assert( aSpecial['\n']=='n' );
+  assert( aSpecial['\r']=='r' );
+  assert( aSpecial['\t']=='t' );
+  assert( c>=0 && c<sizeof(aSpecial) );
+  assert( p->nUsed+7 <= p->nAlloc );
+  if( aSpecial[c] ){
+    p->zBuf[p->nUsed] = '\\';
+    p->zBuf[p->nUsed+1] = aSpecial[c];
+    p->nUsed += 2;
+  }else{
+    p->zBuf[p->nUsed] = '\\';
+    p->zBuf[p->nUsed+1] = 'u';
+    p->zBuf[p->nUsed+2] = '0';
+    p->zBuf[p->nUsed+3] = '0';
+    p->zBuf[p->nUsed+4] = "0123456789abcdef"[c>>4];
+    p->zBuf[p->nUsed+5] = "0123456789abcdef"[c&0xf];
+    p->nUsed += 6;
+  }
+}
+
 /* Append the N-byte string in zIn to the end of the JsonString string
 ** under construction.  Enclose the string in double-quotes ("...") and
 ** escape any double-quotes or backslash characters contained within the
@@ -203858,35 +205575,14 @@ static void jsonAppendString(JsonString *p, const char *zIn, u32 N){
     }
     c = z[0];
     if( c=='"' || c=='\\' ){
-      json_simple_escape:
       if( (p->nUsed+N+3 > p->nAlloc) && jsonStringGrow(p,N+3)!=0 ) return;
       p->zBuf[p->nUsed++] = '\\';
       p->zBuf[p->nUsed++] = c;
     }else if( c=='\'' ){
       p->zBuf[p->nUsed++] = c;
     }else{
-      static const char aSpecial[] = {
-         0, 0, 0, 0, 0, 0, 0, 0, 'b', 't', 'n', 0, 'f', 'r', 0, 0,
-         0, 0, 0, 0, 0, 0, 0, 0,   0,   0,   0, 0,   0,   0, 0, 0
-      };
-      assert( sizeof(aSpecial)==32 );
-      assert( aSpecial['\b']=='b' );
-      assert( aSpecial['\f']=='f' );
-      assert( aSpecial['\n']=='n' );
-      assert( aSpecial['\r']=='r' );
-      assert( aSpecial['\t']=='t' );
-      assert( c>=0 && c<sizeof(aSpecial) );
-      if( aSpecial[c] ){
-        c = aSpecial[c];
-        goto json_simple_escape;
-      }
       if( (p->nUsed+N+7 > p->nAlloc) && jsonStringGrow(p,N+7)!=0 ) return;
-      p->zBuf[p->nUsed++] = '\\';
-      p->zBuf[p->nUsed++] = 'u';
-      p->zBuf[p->nUsed++] = '0';
-      p->zBuf[p->nUsed++] = '0';
-      p->zBuf[p->nUsed++] = "0123456789abcdef"[c>>4];
-      p->zBuf[p->nUsed++] = "0123456789abcdef"[c&0xf];
+      jsonAppendControlChar(p, c);
     }
     z++;
     N--;
@@ -204587,7 +206283,10 @@ static u32 jsonbValidityCheck(
         if( !jsonIsOk[z[j]] && z[j]!='\'' ){
           if( z[j]=='"' ){
             if( x==JSONB_TEXTJ ) return j+1;
-          }else if( z[j]!='\\' || j+1>=k ){
+          }else if( z[j]<=0x1f ){
+            /* Control characters in JSON5 string literals are ok */
+            if( x==JSONB_TEXTJ ) return j+1;
+          }else if( NEVER(z[j]!='\\') || j+1>=k ){
             return j+1;
           }else if( strchr("\"\\/bfnrt",z[j+1])!=0 ){
             j++;
@@ -204785,6 +206484,7 @@ static int jsonTranslateTextToBlob(JsonParse *pParse, u32 i){
   case '[': {
     /* Parse array */
     iThis = pParse->nBlob;
+    assert( i<=(u32)pParse->nJson );
     jsonBlobAppendNode(pParse, JSONB_ARRAY, pParse->nJson - i, 0);
     iStart = pParse->nBlob;
     if( pParse->oom ) return -1;
@@ -204881,9 +206581,14 @@ static int jsonTranslateTextToBlob(JsonParse *pParse, u32 i){
           return -1;
         }
       }else if( c<=0x1f ){
-        /* Control characters are not allowed in strings */
-        pParse->iErr = j;
-        return -1;
+        if( c==0 ){
+          pParse->iErr = j;
+          return -1;
+        }
+        /* Control characters are not allowed in canonical JSON string
+        ** literals, but are allowed in JSON5 string literals. */
+        opcode = JSONB_TEXT5;
+        pParse->hasNonstd = 1;
       }else if( c=='"' ){
         opcode = JSONB_TEXT5;
       }
@@ -205099,6 +206804,7 @@ static int jsonTranslateTextToBlob(JsonParse *pParse, u32 i){
       return i+4;
     }
     /* fall-through into the default case that checks for NaN */
+    /* no break */ deliberate_fall_through
   }
   default: {
     u32 k;
@@ -205183,6 +206889,10 @@ static void jsonReturnStringAsBlob(JsonString *pStr){
   JsonParse px;
   memset(&px, 0, sizeof(px));
   jsonStringTerminate(pStr);
+  if( pStr->eErr ){
+    sqlite3_result_error_nomem(pStr->pCtx);
+    return;
+  }
   px.zJson = pStr->zBuf;
   px.nJson = pStr->nUsed;
   px.db = sqlite3_context_db_handle(pStr->pCtx);
@@ -205363,7 +207073,7 @@ static u32 jsonTranslateBlobToText(
       zIn = (const char*)&pParse->aBlob[i+n];
       jsonAppendChar(pOut, '"');
       while( sz2>0 ){
-        for(k=0; k<sz2 && zIn[k]!='\\' && zIn[k]!='"'; k++){}
+        for(k=0; k<sz2 && (jsonIsOk[(u8)zIn[k]] || zIn[k]=='\''); k++){}
         if( k>0 ){
           jsonAppendRawNZ(pOut, zIn, k);
           if( k>=sz2 ){
@@ -205378,6 +207088,13 @@ static u32 jsonTranslateBlobToText(
           sz2--;
           continue;
         }
+        if( zIn[0]<=0x1f ){
+          if( pOut->nUsed+7>pOut->nAlloc && jsonStringGrow(pOut,7) ) break;
+          jsonAppendControlChar(pOut, zIn[0]);
+          zIn++;
+          sz2--;
+          continue;
+        }
         assert( zIn[0]=='\\' );
         assert( sz2>=1 );
         if( sz2<2 ){
@@ -205480,6 +207197,112 @@ static u32 jsonTranslateBlobToText(
   return i+n+sz;
 }
 
+/* Context for recursion of json_pretty()
+*/
+typedef struct JsonPretty JsonPretty;
+struct JsonPretty {
+  JsonParse *pParse;        /* The BLOB being rendered */
+  JsonString *pOut;         /* Generate pretty output into this string */
+  const char *zIndent;      /* Use this text for indentation */
+  u32 szIndent;             /* Bytes in zIndent[] */
+  u32 nIndent;              /* Current level of indentation */
+};
+
+/* Append indentation to the pretty JSON under construction */
+static void jsonPrettyIndent(JsonPretty *pPretty){
+  u32 jj;
+  for(jj=0; jj<pPretty->nIndent; jj++){
+    jsonAppendRaw(pPretty->pOut, pPretty->zIndent, pPretty->szIndent);
+  }
+}
+
+/*
+** Translate the binary JSONB representation of JSON beginning at
+** pParse->aBlob[i] into a JSON text string.  Append the JSON
+** text onto the end of pOut.  Return the index in pParse->aBlob[]
+** of the first byte past the end of the element that is translated.
+**
+** This is a variant of jsonTranslateBlobToText() that "pretty-prints"
+** the output.  Extra whitespace is inserted to make the JSON easier
+** for humans to read.
+**
+** If an error is detected in the BLOB input, the pOut->eErr flag
+** might get set to JSTRING_MALFORMED.  But not all BLOB input errors
+** are detected.  So a malformed JSONB input might either result
+** in an error, or in incorrect JSON.
+**
+** The pOut->eErr JSTRING_OOM flag is set on a OOM.
+*/
+static u32 jsonTranslateBlobToPrettyText(
+  JsonPretty *pPretty,       /* Pretty-printing context */
+  u32 i                      /* Start rendering at this index */
+){
+  u32 sz, n, j, iEnd;
+  const JsonParse *pParse = pPretty->pParse;
+  JsonString *pOut = pPretty->pOut;
+  n = jsonbPayloadSize(pParse, i, &sz);
+  if( n==0 ){
+    pOut->eErr |= JSTRING_MALFORMED;
+    return pParse->nBlob+1;
+  }
+  switch( pParse->aBlob[i] & 0x0f ){
+    case JSONB_ARRAY: {
+      j = i+n;
+      iEnd = j+sz;
+      jsonAppendChar(pOut, '[');
+      if( j<iEnd ){
+        jsonAppendChar(pOut, '\n');
+        pPretty->nIndent++;
+        while( pOut->eErr==0 ){
+          jsonPrettyIndent(pPretty);
+          j = jsonTranslateBlobToPrettyText(pPretty, j);
+          if( j>=iEnd ) break;
+          jsonAppendRawNZ(pOut, ",\n", 2);
+        }
+        jsonAppendChar(pOut, '\n');
+        pPretty->nIndent--;
+        jsonPrettyIndent(pPretty);
+      }
+      jsonAppendChar(pOut, ']');
+      i = iEnd;
+      break;
+    }
+    case JSONB_OBJECT: {
+      j = i+n;
+      iEnd = j+sz;
+      jsonAppendChar(pOut, '{');
+      if( j<iEnd ){
+        jsonAppendChar(pOut, '\n');
+        pPretty->nIndent++;
+        while( pOut->eErr==0 ){
+          jsonPrettyIndent(pPretty);
+          j = jsonTranslateBlobToText(pParse, j, pOut);
+          if( j>iEnd ){
+            pOut->eErr |= JSTRING_MALFORMED;
+            break;
+          }
+          jsonAppendRawNZ(pOut, ": ", 2);
+          j = jsonTranslateBlobToPrettyText(pPretty, j);
+          if( j>=iEnd ) break;
+          jsonAppendRawNZ(pOut, ",\n", 2);
+        }
+        jsonAppendChar(pOut, '\n');
+        pPretty->nIndent--;
+        jsonPrettyIndent(pPretty);
+      }
+      jsonAppendChar(pOut, '}');
+      i = iEnd;
+      break;
+    }
+    default: {
+      i = jsonTranslateBlobToText(pParse, i, pOut);
+      break;
+    }
+  }
+  return i;
+}
+
+
 /* Return true if the input pJson
 **
 ** For performance reasons, this routine does not do a detailed check of the
@@ -206508,8 +208331,9 @@ static JsonParse *jsonParseFuncArg(
   }
   p->zJson = (char*)sqlite3_value_text(pArg);
   p->nJson = sqlite3_value_bytes(pArg);
+  if( db->mallocFailed ) goto json_pfa_oom;
   if( p->nJson==0 ) goto json_pfa_malformed;
-  if( NEVER(p->zJson==0) ) goto json_pfa_oom;
+  assert( p->zJson!=0 );
   if( jsonConvertTextToBlob(p, (flgs & JSON_KEEPERROR) ? 0 : ctx) ){
     if( flgs & JSON_KEEPERROR ){
       p->nErr = 1;
@@ -206675,10 +208499,10 @@ static void jsonDebugPrintBlob(
       if( sz==0 && x<=JSONB_FALSE ){
         sqlite3_str_append(pOut, "\n", 1);
       }else{
-        u32 i;
+        u32 j;
         sqlite3_str_appendall(pOut, ": \"");
-        for(i=iStart+n; i<iStart+n+sz; i++){
-          u8 c = pParse->aBlob[i];
+        for(j=iStart+n; j<iStart+n+sz; j++){
+          u8 c = pParse->aBlob[j];
           if( c<0x20 || c>=0x7f ) c = '.';
           sqlite3_str_append(pOut, (char*)&c, 1);
         }
@@ -206729,11 +208553,12 @@ static void jsonParseFunc(
   if( p==0 ) return;
   if( argc==1 ){
     jsonDebugPrintBlob(p, 0, p->nBlob, 0, &out);
-    sqlite3_result_text64(ctx, out.zText, out.nChar, SQLITE_DYNAMIC, SQLITE_UTF8);
+    sqlite3_result_text64(ctx,out.zText,out.nChar,SQLITE_TRANSIENT,SQLITE_UTF8);
   }else{
     jsonShowParse(p);
   }
   jsonParseFree(p);
+  sqlite3_str_reset(&out);
 }
 #endif /* SQLITE_DEBUG */
 
@@ -206832,13 +208657,6 @@ static void jsonArrayLengthFunc(
   jsonParseFree(p);
 }
 
-/* True if the string is all digits */
-static int jsonAllDigits(const char *z, int n){
-  int i;
-  for(i=0; i<n && sqlite3Isdigit(z[i]); i++){}
-  return i==n;
-}
-
 /* True if the string is all alphanumerics and underscores */
 static int jsonAllAlphanum(const char *z, int n){
   int i;
@@ -206903,7 +208721,7 @@ static void jsonExtractFunc(
       **     [NUMBER] ==>  $[NUMBER]     // Not PG.  Purely for convenience
       */
       jsonStringInit(&jx, ctx);
-      if( jsonAllDigits(zPath, nPath) ){
+      if( sqlite3_value_type(argv[i])==SQLITE_INTEGER ){
         jsonAppendRawNZ(&jx, "[", 1);
         jsonAppendRaw(&jx, zPath, nPath);
         jsonAppendRawNZ(&jx, "]", 2);
@@ -207397,6 +209215,40 @@ static void jsonTypeFunc(
   jsonParseFree(p);
 }
 
+/*
+** json_pretty(JSON)
+** json_pretty(JSON, INDENT)
+**
+** Return text that is a pretty-printed rendering of the input JSON.
+** If the argument is not valid JSON, return NULL.
+**
+** The INDENT argument is text that is used for indentation.  If omitted,
+** it defaults to four spaces (the same as PostgreSQL).
+*/
+static void jsonPrettyFunc(
+  sqlite3_context *ctx,
+  int argc,
+  sqlite3_value **argv
+){
+  JsonString s;          /* The output string */
+  JsonPretty x;          /* Pretty printing context */
+
+  memset(&x, 0, sizeof(x));
+  x.pParse = jsonParseFuncArg(ctx, argv[0], 0);
+  if( x.pParse==0 ) return;
+  x.pOut = &s;
+  jsonStringInit(&s, ctx);
+  if( argc==1 || (x.zIndent = (const char*)sqlite3_value_text(argv[1]))==0 ){
+    x.zIndent = "    ";
+    x.szIndent = 4;
+  }else{
+    x.szIndent = (u32)strlen(x.zIndent);
+  }
+  jsonTranslateBlobToPrettyText(&x, 0);
+  jsonReturnString(&s, 0, 0);
+  jsonParseFree(x.pParse);
+}
+
 /*
 ** json_valid(JSON)
 ** json_valid(JSON, FLAGS)
@@ -208086,6 +209938,9 @@ static int jsonEachColumn(
     case JEACH_VALUE: {
       u32 i = jsonSkipLabel(p);
       jsonReturnFromBlob(&p->sParse, i, ctx, 1);
+      if( (p->sParse.aBlob[i] & 0x0f)>=JSONB_ARRAY ){
+        sqlite3_result_subtype(ctx, JSON_SUBTYPE);
+      }
       break;
     }
     case JEACH_TYPE: {
@@ -208132,9 +209987,9 @@ static int jsonEachColumn(
     case JEACH_JSON: {
       if( p->sParse.zJson==0 ){
         sqlite3_result_blob(ctx, p->sParse.aBlob, p->sParse.nBlob,
-                            SQLITE_STATIC);
+                            SQLITE_TRANSIENT);
       }else{
-        sqlite3_result_text(ctx, p->sParse.zJson, -1, SQLITE_STATIC);
+        sqlite3_result_text(ctx, p->sParse.zJson, -1, SQLITE_TRANSIENT);
       }
       break;
     }
@@ -208408,6 +210263,8 @@ SQLITE_PRIVATE void sqlite3RegisterJsonFunctions(void){
     JFUNCTION(jsonb_object,      -1,0,1, 1,1,0,          jsonObjectFunc),
     JFUNCTION(json_patch,         2,1,1, 0,0,0,          jsonPatchFunc),
     JFUNCTION(jsonb_patch,        2,1,0, 0,1,0,          jsonPatchFunc),
+    JFUNCTION(json_pretty,        1,1,0, 0,0,0,          jsonPrettyFunc),
+    JFUNCTION(json_pretty,        2,1,0, 0,0,0,          jsonPrettyFunc),
     JFUNCTION(json_quote,         1,0,1, 1,0,0,          jsonQuoteFunc),
     JFUNCTION(json_remove,       -1,1,1, 0,0,0,          jsonRemoveFunc),
     JFUNCTION(jsonb_remove,      -1,1,0, 0,1,0,          jsonRemoveFunc),
@@ -209160,11 +211017,9 @@ static RtreeNode *nodeNew(Rtree *pRtree, RtreeNode *pParent){
 ** Clear the Rtree.pNodeBlob object
 */
 static void nodeBlobReset(Rtree *pRtree){
-  if( pRtree->pNodeBlob && pRtree->inWrTrans==0 && pRtree->nCursor==0 ){
-    sqlite3_blob *pBlob = pRtree->pNodeBlob;
-    pRtree->pNodeBlob = 0;
-    sqlite3_blob_close(pBlob);
-  }
+  sqlite3_blob *pBlob = pRtree->pNodeBlob;
+  pRtree->pNodeBlob = 0;
+  sqlite3_blob_close(pBlob);
 }
 
 /*
@@ -209208,7 +211063,6 @@ static int nodeAcquire(
                            &pRtree->pNodeBlob);
   }
   if( rc ){
-    nodeBlobReset(pRtree);
     *ppNode = 0;
     /* If unable to open an sqlite3_blob on the desired row, that can only
     ** be because the shadow tables hold erroneous data. */
@@ -209268,6 +211122,7 @@ static int nodeAcquire(
     }
     *ppNode = pNode;
   }else{
+    nodeBlobReset(pRtree);
     if( pNode ){
       pRtree->nNodeRef--;
       sqlite3_free(pNode);
@@ -209412,6 +211267,7 @@ static void nodeGetCoord(
   int iCoord,                  /* Which coordinate to extract */
   RtreeCoord *pCoord           /* OUT: Space to write result to */
 ){
+  assert( iCell<NCELL(pNode) );
   readCoord(&pNode->zData[12 + pRtree->nBytesPerCell*iCell + 4*iCoord], pCoord);
 }
 
@@ -209601,7 +211457,9 @@ static int rtreeClose(sqlite3_vtab_cursor *cur){
   sqlite3_finalize(pCsr->pReadAux);
   sqlite3_free(pCsr);
   pRtree->nCursor--;
-  nodeBlobReset(pRtree);
+  if( pRtree->nCursor==0 && pRtree->inWrTrans==0 ){
+    nodeBlobReset(pRtree);
+  }
   return SQLITE_OK;
 }
 
@@ -210186,7 +212044,11 @@ static int rtreeRowid(sqlite3_vtab_cursor *pVtabCursor, sqlite_int64 *pRowid){
   int rc = SQLITE_OK;
   RtreeNode *pNode = rtreeNodeOfFirstSearchPoint(pCsr, &rc);
   if( rc==SQLITE_OK && ALWAYS(p) ){
-    *pRowid = nodeGetRowid(RTREE_OF_CURSOR(pCsr), pNode, p->iCell);
+    if( p->iCell>=NCELL(pNode) ){
+      rc = SQLITE_ABORT;
+    }else{
+      *pRowid = nodeGetRowid(RTREE_OF_CURSOR(pCsr), pNode, p->iCell);
+    }
   }
   return rc;
 }
@@ -210204,6 +212066,7 @@ static int rtreeColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){
 
   if( rc ) return rc;
   if( NEVER(p==0) ) return SQLITE_OK;
+  if( p->iCell>=NCELL(pNode) ) return SQLITE_ABORT;
   if( i==0 ){
     sqlite3_result_int64(ctx, nodeGetRowid(pRtree, pNode, p->iCell));
   }else if( i<=pRtree->nDim2 ){
@@ -210301,6 +212164,8 @@ static int deserializeGeometry(sqlite3_value *pValue, RtreeConstraint *pCons){
   return SQLITE_OK;
 }
 
+SQLITE_PRIVATE int sqlite3IntFloatCompare(i64,double);
+
 /*
 ** Rtree virtual table module xFilter method.
 */
@@ -210330,7 +212195,8 @@ static int rtreeFilter(
     i64 iNode = 0;
     int eType = sqlite3_value_numeric_type(argv[0]);
     if( eType==SQLITE_INTEGER
-     || (eType==SQLITE_FLOAT && sqlite3_value_double(argv[0])==iRowid)
+     || (eType==SQLITE_FLOAT
+         && 0==sqlite3IntFloatCompare(iRowid,sqlite3_value_double(argv[0])))
     ){
       rc = findLeafNode(pRtree, iRowid, &pLeaf, &iNode);
     }else{
@@ -211686,7 +213552,7 @@ static int rtreeUpdate(
 static int rtreeBeginTransaction(sqlite3_vtab *pVtab){
   Rtree *pRtree = (Rtree *)pVtab;
   assert( pRtree->inWrTrans==0 );
-  pRtree->inWrTrans++;
+  pRtree->inWrTrans = 1;
   return SQLITE_OK;
 }
 
@@ -211700,6 +213566,9 @@ static int rtreeEndTransaction(sqlite3_vtab *pVtab){
   nodeBlobReset(pRtree);
   return SQLITE_OK;
 }
+static int rtreeRollback(sqlite3_vtab *pVtab){
+  return rtreeEndTransaction(pVtab);
+}
 
 /*
 ** The xRename method for rtree module virtual tables.
@@ -211818,7 +213687,7 @@ static sqlite3_module rtreeModule = {
   rtreeBeginTransaction,      /* xBegin - begin transaction */
   rtreeEndTransaction,        /* xSync - sync transaction */
   rtreeEndTransaction,        /* xCommit - commit transaction */
-  rtreeEndTransaction,        /* xRollback - rollback transaction */
+  rtreeRollback,              /* xRollback - rollback transaction */
   0,                          /* xFindFunction - function overloading */
   rtreeRename,                /* xRename - rename the table */
   rtreeSavepoint,             /* xSavepoint */
@@ -215237,7 +217106,7 @@ static void icuLoadCollation(
   UCollator *pUCollator;    /* ICU library collation object */
   int rc;                   /* Return code from sqlite3_create_collation_x() */
 
-  assert(nArg==2);
+  assert(nArg==2 || nArg==3);
   (void)nArg; /* Unused parameter */
   zLocale = (const char *)sqlite3_value_text(apArg[0]);
   zName = (const char *)sqlite3_value_text(apArg[1]);
@@ -215252,7 +217121,39 @@ static void icuLoadCollation(
     return;
   }
   assert(p);
-
+  if(nArg==3){
+    const char *zOption = (const char*)sqlite3_value_text(apArg[2]);
+    static const struct {
+       const char *zName;
+       UColAttributeValue val;
+    } aStrength[] = {
+      {  "PRIMARY",      UCOL_PRIMARY           },
+      {  "SECONDARY",    UCOL_SECONDARY         },
+      {  "TERTIARY",     UCOL_TERTIARY          },
+      {  "DEFAULT",      UCOL_DEFAULT_STRENGTH  },
+      {  "QUARTERNARY",  UCOL_QUATERNARY        },
+      {  "IDENTICAL",    UCOL_IDENTICAL         },
+    };
+    unsigned int i;
+    for(i=0; i<sizeof(aStrength)/sizeof(aStrength[0]); i++){
+      if( sqlite3_stricmp(zOption,aStrength[i].zName)==0 ){
+        ucol_setStrength(pUCollator, aStrength[i].val);
+        break;
+      }
+    }
+    if( i>=sizeof(aStrength)/sizeof(aStrength[0]) ){
+      sqlite3_str *pStr = sqlite3_str_new(sqlite3_context_db_handle(p));
+      sqlite3_str_appendf(pStr,
+         "unknown collation strength \"%s\" - should be one of:",
+         zOption);
+      for(i=0; i<sizeof(aStrength)/sizeof(aStrength[0]); i++){
+         sqlite3_str_appendf(pStr, " %s", aStrength[i].zName);
+      }
+      sqlite3_result_error(p, sqlite3_str_value(pStr), -1);
+      sqlite3_free(sqlite3_str_finish(pStr));
+      return;
+    }
+  }
   rc = sqlite3_create_collation_v2(db, zName, SQLITE_UTF16, (void *)pUCollator,
       icuCollationColl, icuCollationDel
   );
@@ -215275,6 +217176,7 @@ SQLITE_PRIVATE int sqlite3IcuInit(sqlite3 *db){
     void (*xFunc)(sqlite3_context*,int,sqlite3_value**);
   } scalars[] = {
     {"icu_load_collation",2,SQLITE_UTF8|SQLITE_DIRECTONLY,1, icuLoadCollation},
+    {"icu_load_collation",3,SQLITE_UTF8|SQLITE_DIRECTONLY,1, icuLoadCollation},
 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_ICU)
     {"regexp", 2, SQLITE_ANY|SQLITEICU_EXTRAFLAGS,         0, icuRegexpFunc},
     {"lower",  1, SQLITE_UTF16|SQLITEICU_EXTRAFLAGS,       0, icuCaseFunc16},
@@ -216425,6 +218327,7 @@ typedef unsigned int u32;
 typedef unsigned short u16;
 typedef unsigned char u8;
 typedef sqlite3_int64 i64;
+typedef sqlite3_uint64 u64;
 #endif
 
 /*
@@ -217111,6 +219014,7 @@ static int rbuObjIterNext(sqlite3rbu *p, RbuObjIter *pIter){
         if( rc!=SQLITE_ROW ){
           rc = resetAndCollectError(pIter->pTblIter, &p->zErrmsg);
           pIter->zTbl = 0;
+          pIter->zDataTbl = 0;
         }else{
           pIter->zTbl = (const char*)sqlite3_column_text(pIter->pTblIter, 0);
           pIter->zDataTbl = (const char*)sqlite3_column_text(pIter->pTblIter,1);
@@ -219205,7 +221109,7 @@ static i64 rbuShmChecksum(sqlite3rbu *p){
     u32 volatile *ptr;
     p->rc = pDb->pMethods->xShmMap(pDb, 0, 32*1024, 0, (void volatile**)&ptr);
     if( p->rc==SQLITE_OK ){
-      iRet = ((i64)ptr[10] << 32) + ptr[11];
+      iRet = (i64)(((u64)ptr[10] << 32) + ptr[11]);
     }
   }
   return iRet;
@@ -226676,14 +228580,14 @@ static int sessionChangesetNextOne(
   p->rc = sessionInputBuffer(&p->in, 2);
   if( p->rc!=SQLITE_OK ) return p->rc;
 
+  sessionDiscardData(&p->in);
+  p->in.iCurrent = p->in.iNext;
+
   /* If the iterator is already at the end of the changeset, return DONE. */
   if( p->in.iNext>=p->in.nData ){
     return SQLITE_DONE;
   }
 
-  sessionDiscardData(&p->in);
-  p->in.iCurrent = p->in.iNext;
-
   op = p->in.aData[p->in.iNext++];
   while( op=='T' || op=='P' ){
     if( pbNew ) *pbNew = 1;
@@ -228418,6 +230322,7 @@ struct sqlite3_changegroup {
   int rc;                         /* Error code */
   int bPatch;                     /* True to accumulate patchsets */
   SessionTable *pList;            /* List of tables in current patch */
+  SessionBuffer rec;
 
   sqlite3 *db;                    /* Configured by changegroup_schema() */
   char *zDb;                      /* Configured by changegroup_schema() */
@@ -228716,108 +230621,128 @@ static int sessionChangesetExtendRecord(
 }
 
 /*
-** Add all changes in the changeset traversed by the iterator passed as
-** the first argument to the changegroup hash tables.
+** Locate or create a SessionTable object that may be used to add the
+** change currently pointed to by iterator pIter to changegroup pGrp.
+** If successful, set output variable (*ppTab) to point to the table
+** object and return SQLITE_OK. Otherwise, if some error occurs, return
+** an SQLite error code and leave (*ppTab) set to NULL.
 */
-static int sessionChangesetToHash(
-  sqlite3_changeset_iter *pIter,   /* Iterator to read from */
-  sqlite3_changegroup *pGrp,       /* Changegroup object to add changeset to */
-  int bRebase                      /* True if hash table is for rebasing */
+static int sessionChangesetFindTable(
+  sqlite3_changegroup *pGrp,
+  const char *zTab,
+  sqlite3_changeset_iter *pIter,
+  SessionTable **ppTab
 ){
-  u8 *aRec;
-  int nRec;
   int rc = SQLITE_OK;
   SessionTable *pTab = 0;
-  SessionBuffer rec = {0, 0, 0};
-
-  while( SQLITE_ROW==sessionChangesetNext(pIter, &aRec, &nRec, 0) ){
-    const char *zNew;
-    int nCol;
-    int op;
-    int iHash;
-    int bIndirect;
-    SessionChange *pChange;
-    SessionChange *pExist = 0;
-    SessionChange **pp;
-
-    /* Ensure that only changesets, or only patchsets, but not a mixture
-    ** of both, are being combined. It is an error to try to combine a
-    ** changeset and a patchset.  */
-    if( pGrp->pList==0 ){
-      pGrp->bPatch = pIter->bPatchset;
-    }else if( pIter->bPatchset!=pGrp->bPatch ){
-      rc = SQLITE_ERROR;
-      break;
-    }
+  int nTab = (int)strlen(zTab);
+  u8 *abPK = 0;
+  int nCol = 0;
 
-    sqlite3changeset_op(pIter, &zNew, &nCol, &op, &bIndirect);
-    if( !pTab || sqlite3_stricmp(zNew, pTab->zName) ){
-      /* Search the list for a matching table */
-      int nNew = (int)strlen(zNew);
-      u8 *abPK;
+  *ppTab = 0;
+  sqlite3changeset_pk(pIter, &abPK, &nCol);
 
-      sqlite3changeset_pk(pIter, &abPK, 0);
-      for(pTab = pGrp->pList; pTab; pTab=pTab->pNext){
-        if( 0==sqlite3_strnicmp(pTab->zName, zNew, nNew+1) ) break;
-      }
-      if( !pTab ){
-        SessionTable **ppTab;
+  /* Search the list for an existing table */
+  for(pTab = pGrp->pList; pTab; pTab=pTab->pNext){
+    if( 0==sqlite3_strnicmp(pTab->zName, zTab, nTab+1) ) break;
+  }
 
-        pTab = sqlite3_malloc64(sizeof(SessionTable) + nCol + nNew+1);
-        if( !pTab ){
-          rc = SQLITE_NOMEM;
-          break;
-        }
-        memset(pTab, 0, sizeof(SessionTable));
-        pTab->nCol = nCol;
-        pTab->abPK = (u8*)&pTab[1];
-        memcpy(pTab->abPK, abPK, nCol);
-        pTab->zName = (char*)&pTab->abPK[nCol];
-        memcpy(pTab->zName, zNew, nNew+1);
-
-        if( pGrp->db ){
-          pTab->nCol = 0;
-          rc = sessionInitTable(0, pTab, pGrp->db, pGrp->zDb);
-          if( rc ){
-            assert( pTab->azCol==0 );
-            sqlite3_free(pTab);
-            break;
-          }
-        }
+  /* If one was not found above, create a new table now */
+  if( !pTab ){
+    SessionTable **ppNew;
 
-        /* The new object must be linked on to the end of the list, not
-        ** simply added to the start of it. This is to ensure that the
-        ** tables within the output of sqlite3changegroup_output() are in
-        ** the right order.  */
-        for(ppTab=&pGrp->pList; *ppTab; ppTab=&(*ppTab)->pNext);
-        *ppTab = pTab;
-      }
+    pTab = sqlite3_malloc64(sizeof(SessionTable) + nCol + nTab+1);
+    if( !pTab ){
+      return SQLITE_NOMEM;
+    }
+    memset(pTab, 0, sizeof(SessionTable));
+    pTab->nCol = nCol;
+    pTab->abPK = (u8*)&pTab[1];
+    memcpy(pTab->abPK, abPK, nCol);
+    pTab->zName = (char*)&pTab->abPK[nCol];
+    memcpy(pTab->zName, zTab, nTab+1);
 
-      if( !sessionChangesetCheckCompat(pTab, nCol, abPK) ){
-        rc = SQLITE_SCHEMA;
-        break;
+    if( pGrp->db ){
+      pTab->nCol = 0;
+      rc = sessionInitTable(0, pTab, pGrp->db, pGrp->zDb);
+      if( rc ){
+        assert( pTab->azCol==0 );
+        sqlite3_free(pTab);
+        return rc;
       }
     }
 
-    if( nCol<pTab->nCol ){
-      assert( pGrp->db );
-      rc = sessionChangesetExtendRecord(pGrp, pTab, nCol, op, aRec, nRec, &rec);
-      if( rc ) break;
-      aRec = rec.aBuf;
-      nRec = rec.nBuf;
-    }
+    /* The new object must be linked on to the end of the list, not
+    ** simply added to the start of it. This is to ensure that the
+    ** tables within the output of sqlite3changegroup_output() are in
+    ** the right order.  */
+    for(ppNew=&pGrp->pList; *ppNew; ppNew=&(*ppNew)->pNext);
+    *ppNew = pTab;
+  }
 
-    if( sessionGrowHash(0, pIter->bPatchset, pTab) ){
-      rc = SQLITE_NOMEM;
-      break;
-    }
+  /* Check that the table is compatible. */
+  if( !sessionChangesetCheckCompat(pTab, nCol, abPK) ){
+    rc = SQLITE_SCHEMA;
+  }
+
+  *ppTab = pTab;
+  return rc;
+}
+
+/*
+** Add the change currently indicated by iterator pIter to the hash table
+** belonging to changegroup pGrp.
+*/
+static int sessionOneChangeToHash(
+  sqlite3_changegroup *pGrp,
+  sqlite3_changeset_iter *pIter,
+  int bRebase
+){
+  int rc = SQLITE_OK;
+  int nCol = 0;
+  int op = 0;
+  int iHash = 0;
+  int bIndirect = 0;
+  SessionChange *pChange = 0;
+  SessionChange *pExist = 0;
+  SessionChange **pp = 0;
+  SessionTable *pTab = 0;
+  u8 *aRec = &pIter->in.aData[pIter->in.iCurrent + 2];
+  int nRec = (pIter->in.iNext - pIter->in.iCurrent) - 2;
+
+  /* Ensure that only changesets, or only patchsets, but not a mixture
+  ** of both, are being combined. It is an error to try to combine a
+  ** changeset and a patchset.  */
+  if( pGrp->pList==0 ){
+    pGrp->bPatch = pIter->bPatchset;
+  }else if( pIter->bPatchset!=pGrp->bPatch ){
+    rc = SQLITE_ERROR;
+  }
+
+  if( rc==SQLITE_OK ){
+    const char *zTab = 0;
+    sqlite3changeset_op(pIter, &zTab, &nCol, &op, &bIndirect);
+    rc = sessionChangesetFindTable(pGrp, zTab, pIter, &pTab);
+  }
+
+  if( rc==SQLITE_OK && nCol<pTab->nCol ){
+    SessionBuffer *pBuf = &pGrp->rec;
+    rc = sessionChangesetExtendRecord(pGrp, pTab, nCol, op, aRec, nRec, pBuf);
+    aRec = pBuf->aBuf;
+    nRec = pBuf->nBuf;
+    assert( pGrp->db );
+  }
+
+  if( rc==SQLITE_OK && sessionGrowHash(0, pIter->bPatchset, pTab) ){
+    rc = SQLITE_NOMEM;
+  }
+
+  if( rc==SQLITE_OK ){
+    /* Search for existing entry. If found, remove it from the hash table.
+    ** Code below may link it back in.  */
     iHash = sessionChangeHash(
         pTab, (pIter->bPatchset && op==SQLITE_DELETE), aRec, pTab->nChange
     );
-
-    /* Search for existing entry. If found, remove it from the hash table.
-    ** Code below may link it back in.
-    */
     for(pp=&pTab->apChange[iHash]; *pp; pp=&(*pp)->pNext){
       int bPkOnly1 = 0;
       int bPkOnly2 = 0;
@@ -228832,19 +230757,41 @@ static int sessionChangesetToHash(
         break;
       }
     }
+  }
 
+  if( rc==SQLITE_OK ){
     rc = sessionChangeMerge(pTab, bRebase,
         pIter->bPatchset, pExist, op, bIndirect, aRec, nRec, &pChange
     );
-    if( rc ) break;
-    if( pChange ){
-      pChange->pNext = pTab->apChange[iHash];
-      pTab->apChange[iHash] = pChange;
-      pTab->nEntry++;
-    }
+  }
+  if( rc==SQLITE_OK && pChange ){
+    pChange->pNext = pTab->apChange[iHash];
+    pTab->apChange[iHash] = pChange;
+    pTab->nEntry++;
+  }
+
+  if( rc==SQLITE_OK ) rc = pIter->rc;
+  return rc;
+}
+
+/*
+** Add all changes in the changeset traversed by the iterator passed as
+** the first argument to the changegroup hash tables.
+*/
+static int sessionChangesetToHash(
+  sqlite3_changeset_iter *pIter,   /* Iterator to read from */
+  sqlite3_changegroup *pGrp,       /* Changegroup object to add changeset to */
+  int bRebase                      /* True if hash table is for rebasing */
+){
+  u8 *aRec;
+  int nRec;
+  int rc = SQLITE_OK;
+
+  while( SQLITE_ROW==(sessionChangesetNext(pIter, &aRec, &nRec, 0)) ){
+    rc = sessionOneChangeToHash(pGrp, pIter, bRebase);
+    if( rc!=SQLITE_OK ) break;
   }
 
-  sqlite3_free(rec.aBuf);
   if( rc==SQLITE_OK ) rc = pIter->rc;
   return rc;
 }
@@ -228972,6 +230919,23 @@ SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup *pGrp, int nData, void
   return rc;
 }
 
+/*
+** Add a single change to a changeset-group.
+*/
+SQLITE_API int sqlite3changegroup_add_change(
+  sqlite3_changegroup *pGrp,
+  sqlite3_changeset_iter *pIter
+){
+  if( pIter->in.iCurrent==pIter->in.iNext
+   || pIter->rc!=SQLITE_OK
+   || pIter->bInvert
+  ){
+    /* Iterator does not point to any valid entry or is an INVERT iterator. */
+    return SQLITE_ERROR;
+  }
+  return sessionOneChangeToHash(pGrp, pIter, 0);
+}
+
 /*
 ** Obtain a buffer containing a changeset representing the concatenation
 ** of all changesets added to the group so far.
@@ -229021,6 +230985,7 @@ SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup *pGrp){
   if( pGrp ){
     sqlite3_free(pGrp->zDb);
     sessionDeleteTable(0, pGrp->pList);
+    sqlite3_free(pGrp->rec.aBuf);
     sqlite3_free(pGrp);
   }
 }
@@ -229422,6 +231387,7 @@ SQLITE_API int sqlite3rebaser_rebase_strm(
 SQLITE_API void sqlite3rebaser_delete(sqlite3_rebaser *p){
   if( p ){
     sessionDeleteTable(0, p->grp.pList);
+    sqlite3_free(p->grp.rec.aBuf);
     sqlite3_free(p);
   }
 }
@@ -229519,8 +231485,8 @@ struct Fts5PhraseIter {
 ** EXTENSION API FUNCTIONS
 **
 ** xUserData(pFts):
-**   Return a copy of the context pointer the extension function was
-**   registered with.
+**   Return a copy of the pUserData pointer passed to the xCreateFunction()
+**   API when the extension function was registered.
 **
 ** xColumnTotalSize(pFts, iCol, pnToken):
 **   If parameter iCol is less than zero, set output variable *pnToken
@@ -231116,6 +233082,9 @@ static void sqlite3Fts5UnicodeAscii(u8*, u8*);
 **    sqlite3Fts5ParserARG_STORE     Code to store %extra_argument into fts5yypParser
 **    sqlite3Fts5ParserARG_FETCH     Code to extract %extra_argument from fts5yypParser
 **    sqlite3Fts5ParserCTX_*         As sqlite3Fts5ParserARG_ except for %extra_context
+**    fts5YYREALLOC          Name of the realloc() function to use
+**    fts5YYFREE             Name of the free() function to use
+**    fts5YYDYNSTACK         True if stack space should be extended on heap
 **    fts5YYERRORSYMBOL      is the code number of the error symbol.  If not
 **                       defined, then do no error processing.
 **    fts5YYNSTATE           the combined number of states.
@@ -231129,6 +233098,8 @@ static void sqlite3Fts5UnicodeAscii(u8*, u8*);
 **    fts5YY_NO_ACTION       The fts5yy_action[] code for no-op
 **    fts5YY_MIN_REDUCE      Minimum value for reduce actions
 **    fts5YY_MAX_REDUCE      Maximum value for reduce actions
+**    fts5YY_MIN_DSTRCTR     Minimum symbol value that has a destructor
+**    fts5YY_MAX_DSTRCTR     Maximum symbol value that has a destructor
 */
 #ifndef INTERFACE
 # define INTERFACE 1
@@ -231155,6 +233126,9 @@ typedef union {
 #define sqlite3Fts5ParserARG_PARAM ,pParse
 #define sqlite3Fts5ParserARG_FETCH Fts5Parse *pParse=fts5yypParser->pParse;
 #define sqlite3Fts5ParserARG_STORE fts5yypParser->pParse=pParse;
+#define fts5YYREALLOC realloc
+#define fts5YYFREE free
+#define fts5YYDYNSTACK 0
 #define sqlite3Fts5ParserCTX_SDECL
 #define sqlite3Fts5ParserCTX_PDECL
 #define sqlite3Fts5ParserCTX_PARAM
@@ -231172,6 +233146,8 @@ typedef union {
 #define fts5YY_NO_ACTION         82
 #define fts5YY_MIN_REDUCE        83
 #define fts5YY_MAX_REDUCE        110
+#define fts5YY_MIN_DSTRCTR       16
+#define fts5YY_MAX_DSTRCTR       24
 /************* End control #defines *******************************************/
 #define fts5YY_NLOOKAHEAD ((int)(sizeof(fts5yy_lookahead)/sizeof(fts5yy_lookahead[0])))
 
@@ -231187,6 +233163,22 @@ typedef union {
 # define fts5yytestcase(X)
 #endif
 
+/* Macro to determine if stack space has the ability to grow using
+** heap memory.
+*/
+#if fts5YYSTACKDEPTH<=0 || fts5YYDYNSTACK
+# define fts5YYGROWABLESTACK 1
+#else
+# define fts5YYGROWABLESTACK 0
+#endif
+
+/* Guarantee a minimum number of initial stack slots.
+*/
+#if fts5YYSTACKDEPTH<=0
+# undef fts5YYSTACKDEPTH
+# define fts5YYSTACKDEPTH 2  /* Need a minimum stack size */
+#endif
+
 
 /* Next are the tables used to determine what action to take based on the
 ** current state and lookahead token.  These tables are used to implement
@@ -231347,14 +233339,9 @@ struct fts5yyParser {
 #endif
   sqlite3Fts5ParserARG_SDECL                /* A place to hold %extra_argument */
   sqlite3Fts5ParserCTX_SDECL                /* A place to hold %extra_context */
-#if fts5YYSTACKDEPTH<=0
-  int fts5yystksz;                  /* Current side of the stack */
-  fts5yyStackEntry *fts5yystack;        /* The parser's stack */
-  fts5yyStackEntry fts5yystk0;          /* First stack entry */
-#else
-  fts5yyStackEntry fts5yystack[fts5YYSTACKDEPTH];  /* The parser's stack */
-  fts5yyStackEntry *fts5yystackEnd;            /* Last entry in the stack */
-#endif
+  fts5yyStackEntry *fts5yystackEnd;           /* Last entry in the stack */
+  fts5yyStackEntry *fts5yystack;              /* The parser stack */
+  fts5yyStackEntry fts5yystk0[fts5YYSTACKDEPTH];  /* Initial stack space */
 };
 typedef struct fts5yyParser fts5yyParser;
 
@@ -231461,37 +233448,45 @@ static const char *const fts5yyRuleName[] = {
 #endif /* NDEBUG */
 
 
-#if fts5YYSTACKDEPTH<=0
+#if fts5YYGROWABLESTACK
 /*
 ** Try to increase the size of the parser stack.  Return the number
 ** of errors.  Return 0 on success.
 */
 static int fts5yyGrowStack(fts5yyParser *p){
+  int oldSize = 1 + (int)(p->fts5yystackEnd - p->fts5yystack);
   int newSize;
   int idx;
   fts5yyStackEntry *pNew;
 
-  newSize = p->fts5yystksz*2 + 100;
-  idx = p->fts5yytos ? (int)(p->fts5yytos - p->fts5yystack) : 0;
-  if( p->fts5yystack==&p->fts5yystk0 ){
-    pNew = malloc(newSize*sizeof(pNew[0]));
-    if( pNew ) pNew[0] = p->fts5yystk0;
+  newSize = oldSize*2 + 100;
+  idx = (int)(p->fts5yytos - p->fts5yystack);
+  if( p->fts5yystack==p->fts5yystk0 ){
+    pNew = fts5YYREALLOC(0, newSize*sizeof(pNew[0]));
+    if( pNew==0 ) return 1;
+    memcpy(pNew, p->fts5yystack, oldSize*sizeof(pNew[0]));
   }else{
-    pNew = realloc(p->fts5yystack, newSize*sizeof(pNew[0]));
+    pNew = fts5YYREALLOC(p->fts5yystack, newSize*sizeof(pNew[0]));
+    if( pNew==0 ) return 1;
   }
-  if( pNew ){
-    p->fts5yystack = pNew;
-    p->fts5yytos = &p->fts5yystack[idx];
+  p->fts5yystack = pNew;
+  p->fts5yytos = &p->fts5yystack[idx];
 #ifndef NDEBUG
-    if( fts5yyTraceFILE ){
-      fprintf(fts5yyTraceFILE,"%sStack grows from %d to %d entries.\n",
-              fts5yyTracePrompt, p->fts5yystksz, newSize);
-    }
-#endif
-    p->fts5yystksz = newSize;
+  if( fts5yyTraceFILE ){
+    fprintf(fts5yyTraceFILE,"%sStack grows from %d to %d entries.\n",
+            fts5yyTracePrompt, oldSize, newSize);
   }
-  return pNew==0;
+#endif
+  p->fts5yystackEnd = &p->fts5yystack[newSize-1];
+  return 0;
 }
+#endif /* fts5YYGROWABLESTACK */
+
+#if !fts5YYGROWABLESTACK
+/* For builds that do no have a growable stack, fts5yyGrowStack always
+** returns an error.
+*/
+# define fts5yyGrowStack(X) 1
 #endif
 
 /* Datatype of the argument to the memory allocated passed as the
@@ -231511,24 +233506,14 @@ static void sqlite3Fts5ParserInit(void *fts5yypRawParser sqlite3Fts5ParserCTX_PD
 #ifdef fts5YYTRACKMAXSTACKDEPTH
   fts5yypParser->fts5yyhwm = 0;
 #endif
-#if fts5YYSTACKDEPTH<=0
-  fts5yypParser->fts5yytos = NULL;
-  fts5yypParser->fts5yystack = NULL;
-  fts5yypParser->fts5yystksz = 0;
-  if( fts5yyGrowStack(fts5yypParser) ){
-    fts5yypParser->fts5yystack = &fts5yypParser->fts5yystk0;
-    fts5yypParser->fts5yystksz = 1;
-  }
-#endif
+  fts5yypParser->fts5yystack = fts5yypParser->fts5yystk0;
+  fts5yypParser->fts5yystackEnd = &fts5yypParser->fts5yystack[fts5YYSTACKDEPTH-1];
 #ifndef fts5YYNOERRORRECOVERY
   fts5yypParser->fts5yyerrcnt = -1;
 #endif
   fts5yypParser->fts5yytos = fts5yypParser->fts5yystack;
   fts5yypParser->fts5yystack[0].stateno = 0;
   fts5yypParser->fts5yystack[0].major = 0;
-#if fts5YYSTACKDEPTH>0
-  fts5yypParser->fts5yystackEnd = &fts5yypParser->fts5yystack[fts5YYSTACKDEPTH-1];
-#endif
 }
 
 #ifndef sqlite3Fts5Parser_ENGINEALWAYSONSTACK
@@ -231642,9 +233627,26 @@ static void fts5yy_pop_parser_stack(fts5yyParser *pParser){
 */
 static void sqlite3Fts5ParserFinalize(void *p){
   fts5yyParser *pParser = (fts5yyParser*)p;
-  while( pParser->fts5yytos>pParser->fts5yystack ) fts5yy_pop_parser_stack(pParser);
-#if fts5YYSTACKDEPTH<=0
-  if( pParser->fts5yystack!=&pParser->fts5yystk0 ) free(pParser->fts5yystack);
+
+  /* In-lined version of calling fts5yy_pop_parser_stack() for each
+  ** element left in the stack */
+  fts5yyStackEntry *fts5yytos = pParser->fts5yytos;
+  while( fts5yytos>pParser->fts5yystack ){
+#ifndef NDEBUG
+    if( fts5yyTraceFILE ){
+      fprintf(fts5yyTraceFILE,"%sPopping %s\n",
+        fts5yyTracePrompt,
+        fts5yyTokenName[fts5yytos->major]);
+    }
+#endif
+    if( fts5yytos->major>=fts5YY_MIN_DSTRCTR ){
+      fts5yy_destructor(pParser, fts5yytos->major, &fts5yytos->minor);
+    }
+    fts5yytos--;
+  }
+
+#if fts5YYGROWABLESTACK
+  if( pParser->fts5yystack!=pParser->fts5yystk0 ) fts5YYFREE(pParser->fts5yystack);
 #endif
 }
 
@@ -231871,25 +233873,19 @@ static void fts5yy_shift(
     assert( fts5yypParser->fts5yyhwm == (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack) );
   }
 #endif
-#if fts5YYSTACKDEPTH>0
-  if( fts5yypParser->fts5yytos>fts5yypParser->fts5yystackEnd ){
-    fts5yypParser->fts5yytos--;
-    fts5yyStackOverflow(fts5yypParser);
-    return;
-  }
-#else
-  if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5yypParser->fts5yystksz] ){
+  fts5yytos = fts5yypParser->fts5yytos;
+  if( fts5yytos>fts5yypParser->fts5yystackEnd ){
     if( fts5yyGrowStack(fts5yypParser) ){
       fts5yypParser->fts5yytos--;
       fts5yyStackOverflow(fts5yypParser);
       return;
     }
+    fts5yytos = fts5yypParser->fts5yytos;
+    assert( fts5yytos <= fts5yypParser->fts5yystackEnd );
   }
-#endif
   if( fts5yyNewState > fts5YY_MAX_SHIFT ){
     fts5yyNewState += fts5YY_MIN_REDUCE - fts5YY_MIN_SHIFTREDUCE;
   }
-  fts5yytos = fts5yypParser->fts5yytos;
   fts5yytos->stateno = fts5yyNewState;
   fts5yytos->major = fts5yyMajor;
   fts5yytos->minor.fts5yy0 = fts5yyMinor;
@@ -232326,19 +234322,12 @@ static void sqlite3Fts5Parser(
                   (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack));
         }
 #endif
-#if fts5YYSTACKDEPTH>0
         if( fts5yypParser->fts5yytos>=fts5yypParser->fts5yystackEnd ){
-          fts5yyStackOverflow(fts5yypParser);
-          break;
-        }
-#else
-        if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5yypParser->fts5yystksz-1] ){
           if( fts5yyGrowStack(fts5yypParser) ){
             fts5yyStackOverflow(fts5yypParser);
             break;
           }
         }
-#endif
       }
       fts5yyact = fts5yy_reduce(fts5yypParser,fts5yyruleno,fts5yymajor,fts5yyminor sqlite3Fts5ParserCTX_PARAM);
     }else if( fts5yyact <= fts5YY_MAX_SHIFTREDUCE ){
@@ -245377,23 +247366,26 @@ static void fts5IterSetOutputsTokendata(Fts5Iter *pIter){
 static void fts5TokendataIterNext(Fts5Iter *pIter, int bFrom, i64 iFrom){
   int ii;
   Fts5TokenDataIter *pT = pIter->pTokenDataIter;
+  Fts5Index *pIndex = pIter->pIndex;
 
   for(ii=0; ii<pT->nIter; ii++){
     Fts5Iter *p = pT->apIter[ii];
     if( p->base.bEof==0
      && (p->base.iRowid==pIter->base.iRowid || (bFrom && p->base.iRowid<iFrom))
     ){
-      fts5MultiIterNext(p->pIndex, p, bFrom, iFrom);
+      fts5MultiIterNext(pIndex, p, bFrom, iFrom);
       while( bFrom && p->base.bEof==0
           && p->base.iRowid<iFrom
-          && p->pIndex->rc==SQLITE_OK
+          && pIndex->rc==SQLITE_OK
       ){
-        fts5MultiIterNext(p->pIndex, p, 0, 0);
+        fts5MultiIterNext(pIndex, p, 0, 0);
       }
     }
   }
 
-  fts5IterSetOutputsTokendata(pIter);
+  if( pIndex->rc==SQLITE_OK ){
+    fts5IterSetOutputsTokendata(pIter);
+  }
 }
 
 /*
@@ -250547,7 +252539,7 @@ static void fts5SourceIdFunc(
 ){
   assert( nArg==0 );
   UNUSED_PARAM2(nArg, apUnused);
-  sqlite3_result_text(pCtx, "fts5: 2024-01-30 16:01:20 e876e51a0ed5c5b3126f52e532044363a014bc594cfefa87ffb5b82257cc467a", -1, SQLITE_TRANSIENT);
+  sqlite3_result_text(pCtx, "fts5: 2024-05-23 13:25:27 96c92aba00c8375bc32fafcdf12429c58bd8aabfcadab6683e35bbb9cdebf19e", -1, SQLITE_TRANSIENT);
 }
 
 /*
@@ -250586,6 +252578,7 @@ static int fts5IntegrityMethod(
   if( (rc&0xff)==SQLITE_CORRUPT ){
     *pzErr = sqlite3_mprintf("malformed inverted index for FTS5 table %s.%s",
                 zSchema, zTabname);
+     rc = (*pzErr) ? SQLITE_OK : SQLITE_NOMEM;
   }else if( rc!=SQLITE_OK ){
     *pzErr = sqlite3_mprintf("unable to validate the inverted index for"
                              " FTS5 table %s.%s: %s",
@@ -250593,7 +252586,7 @@ static int fts5IntegrityMethod(
   }
   sqlite3Fts5IndexCloseReader(pTab->p.pIndex);
 
-  return SQLITE_OK;
+  return rc;
 }
 
 static int fts5Init(sqlite3 *db){
diff --git a/contrib/sqlite3/sqlite3.h b/contrib/sqlite3/sqlite3.h
index 4fdfde004ebe..57df8dcf2027 100644
--- a/contrib/sqlite3/sqlite3.h
+++ b/contrib/sqlite3/sqlite3.h
@@ -146,9 +146,9 @@ extern "C" {
 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
 ** [sqlite_version()] and [sqlite_source_id()].
 */
-#define SQLITE_VERSION        "3.45.1"
-#define SQLITE_VERSION_NUMBER 3045001
-#define SQLITE_SOURCE_ID      "2024-01-30 16:01:20 e876e51a0ed5c5b3126f52e532044363a014bc594cfefa87ffb5b82257cc467a"
+#define SQLITE_VERSION        "3.46.0"
+#define SQLITE_VERSION_NUMBER 3046000
+#define SQLITE_SOURCE_ID      "2024-05-23 13:25:27 96c92aba00c8375bc32fafcdf12429c58bd8aabfcadab6683e35bbb9cdebf19e"
 
 /*
 ** CAPI3REF: Run-Time Library Version Numbers
@@ -420,6 +420,8 @@ typedef int (*sqlite3_callback)(void*,int,char**, char**);
 **      the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
 ** <li> The application must not modify the SQL statement text passed into
 **      the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
+** <li> The application must not dereference the arrays or string pointers
+**       passed as the 3rd and 4th callback parameters after it returns.
 ** </ul>
 */
 SQLITE_API int sqlite3_exec(
@@ -762,11 +764,11 @@ struct sqlite3_file {
 ** </ul>
 ** xLock() upgrades the database file lock.  In other words, xLock() moves the
 ** database file lock in the direction NONE toward EXCLUSIVE. The argument to
-** xLock() is always on of SHARED, RESERVED, PENDING, or EXCLUSIVE, never
+** xLock() is always one of SHARED, RESERVED, PENDING, or EXCLUSIVE, never
 ** SQLITE_LOCK_NONE.  If the database file lock is already at or above the
 ** requested lock, then the call to xLock() is a no-op.
 ** xUnlock() downgrades the database file lock to either SHARED or NONE.
-*  If the lock is already at or below the requested lock state, then the call
+** If the lock is already at or below the requested lock state, then the call
 ** to xUnlock() is a no-op.
 ** The xCheckReservedLock() method checks whether any database connection,
 ** either in this process or in some other process, is holding a RESERVED,
@@ -2141,6 +2143,22 @@ struct sqlite3_mem_methods {
 ** configuration setting is never used, then the default maximum is determined
 ** by the [SQLITE_MEMDB_DEFAULT_MAXSIZE] compile-time option.  If that
 ** compile-time option is not set, then the default maximum is 1073741824.
+**
+** [[SQLITE_CONFIG_ROWID_IN_VIEW]]
+** <dt>SQLITE_CONFIG_ROWID_IN_VIEW
+** <dd>The SQLITE_CONFIG_ROWID_IN_VIEW option enables or disables the ability
+** for VIEWs to have a ROWID.  The capability can only be enabled if SQLite is
+** compiled with -DSQLITE_ALLOW_ROWID_IN_VIEW, in which case the capability
+** defaults to on.  This configuration option queries the current setting or
+** changes the setting to off or on.  The argument is a pointer to an integer.
+** If that integer initially holds a value of 1, then the ability for VIEWs to
+** have ROWIDs is activated.  If the integer initially holds zero, then the
+** ability is deactivated.  Any other initial value for the integer leaves the
+** setting unchanged.  After changes, if any, the integer is written with
+** a 1 or 0, if the ability for VIEWs to have ROWIDs is on or off.  If SQLite
+** is compiled without -DSQLITE_ALLOW_ROWID_IN_VIEW (which is the usual and
+** recommended case) then the integer is always filled with zero, regardless
+** if its initial value.
 ** </dl>
 */
 #define SQLITE_CONFIG_SINGLETHREAD         1  /* nil */
@@ -2172,6 +2190,7 @@ struct sqlite3_mem_methods {
 #define SQLITE_CONFIG_SMALL_MALLOC        27  /* boolean */
 #define SQLITE_CONFIG_SORTERREF_SIZE      28  /* int nByte */
 #define SQLITE_CONFIG_MEMDB_MAXSIZE       29  /* sqlite3_int64 */
+#define SQLITE_CONFIG_ROWID_IN_VIEW       30  /* int* */
 
 /*
 ** CAPI3REF: Database Connection Configuration Options
@@ -3286,8 +3305,8 @@ SQLITE_API int sqlite3_set_authorizer(
 #define SQLITE_RECURSIVE            33   /* NULL            NULL            */
 
 /*
-** CAPI3REF: Tracing And Profiling Functions
-** METHOD: sqlite3
+** CAPI3REF: Deprecated Tracing And Profiling Functions
+** DEPRECATED
 **
 ** These routines are deprecated. Use the [sqlite3_trace_v2()] interface
 ** instead of the routines described here.
@@ -6868,6 +6887,12 @@ SQLITE_API int sqlite3_autovacuum_pages(
 ** The exceptions defined in this paragraph might change in a future
 ** release of SQLite.
 **
+** Whether the update hook is invoked before or after the
+** corresponding change is currently unspecified and may differ
+** depending on the type of change. Do not rely on the order of the
+** hook call with regards to the final result of the operation which
+** triggers the hook.
+**
 ** The update hook implementation must not do anything that will modify
 ** the database connection that invoked the update hook.  Any actions
 ** to modify the database connection must be deferred until after the
@@ -8338,7 +8363,7 @@ SQLITE_API int sqlite3_test_control(int op, ...);
 ** The sqlite3_keyword_count() interface returns the number of distinct
 ** keywords understood by SQLite.
 **
-** The sqlite3_keyword_name(N,Z,L) interface finds the N-th keyword and
+** The sqlite3_keyword_name(N,Z,L) interface finds the 0-based N-th keyword and
 ** makes *Z point to that keyword expressed as UTF8 and writes the number
 ** of bytes in the keyword into *L.  The string that *Z points to is not
 ** zero-terminated.  The sqlite3_keyword_name(N,Z,L) routine returns
@@ -9917,24 +9942,45 @@ SQLITE_API const char *sqlite3_vtab_collation(sqlite3_index_info*,int);
 ** <li value="2"><p>
 ** ^(If the sqlite3_vtab_distinct() interface returns 2, that means
 ** that the query planner does not need the rows returned in any particular
-** order, as long as rows with the same values in all "aOrderBy" columns
-** are adjacent.)^  ^(Furthermore, only a single row for each particular
-** combination of values in the columns identified by the "aOrderBy" field
-** needs to be returned.)^  ^It is always ok for two or more rows with the same
-** values in all "aOrderBy" columns to be returned, as long as all such rows
-** are adjacent.  ^The virtual table may, if it chooses, omit extra rows
-** that have the same value for all columns identified by "aOrderBy".
-** ^However omitting the extra rows is optional.
+** order, as long as rows with the same values in all columns identified
+** by "aOrderBy" are adjacent.)^  ^(Furthermore, when two or more rows
+** contain the same values for all columns identified by "colUsed", all but
+** one such row may optionally be omitted from the result.)^
+** The virtual table is not required to omit rows that are duplicates
+** over the "colUsed" columns, but if the virtual table can do that without
+** too much extra effort, it could potentially help the query to run faster.
 ** This mode is used for a DISTINCT query.
 ** <li value="3"><p>
-** ^(If the sqlite3_vtab_distinct() interface returns 3, that means
-** that the query planner needs only distinct rows but it does need the
-** rows to be sorted.)^ ^The virtual table implementation is free to omit
-** rows that are identical in all aOrderBy columns, if it wants to, but
-** it is not required to omit any rows.  This mode is used for queries
+** ^(If the sqlite3_vtab_distinct() interface returns 3, that means the
+** virtual table must return rows in the order defined by "aOrderBy" as
+** if the sqlite3_vtab_distinct() interface had returned 0.  However if
+** two or more rows in the result have the same values for all columns
+** identified by "colUsed", then all but one such row may optionally be
+** omitted.)^  Like when the return value is 2, the virtual table
+** is not required to omit rows that are duplicates over the "colUsed"
+** columns, but if the virtual table can do that without
+** too much extra effort, it could potentially help the query to run faster.
+** This mode is used for queries
 ** that have both DISTINCT and ORDER BY clauses.
 ** </ol>
 **
+** <p>The following table summarizes the conditions under which the
+** virtual table is allowed to set the "orderByConsumed" flag based on
+** the value returned by sqlite3_vtab_distinct().  This table is a
+** restatement of the previous four paragraphs:
+**
+** <table border=1 cellspacing=0 cellpadding=10 width="90%">
+** <tr>
+** <td valign="top">sqlite3_vtab_distinct() return value
+** <td valign="top">Rows are returned in aOrderBy order
+** <td valign="top">Rows with the same value in all aOrderBy columns are adjacent
+** <td valign="top">Duplicates over all colUsed columns may be omitted
+** <tr><td>0<td>yes<td>yes<td>no
+** <tr><td>1<td>no<td>yes<td>no
+** <tr><td>2<td>no<td>yes<td>yes
+** <tr><td>3<td>yes<td>yes<td>yes
+** </table>
+**
 ** ^For the purposes of comparing virtual table output values to see if the
 ** values are same value for sorting purposes, two NULL values are considered
 ** to be the same.  In other words, the comparison operator is "IS"
@@ -11979,6 +12025,30 @@ SQLITE_API int sqlite3changegroup_schema(sqlite3_changegroup*, sqlite3*, const c
 */
 SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData);
 
+/*
+** CAPI3REF: Add A Single Change To A Changegroup
+** METHOD: sqlite3_changegroup
+**
+** This function adds the single change currently indicated by the iterator
+** passed as the second argument to the changegroup object. The rules for
+** adding the change are just as described for [sqlite3changegroup_add()].
+**
+** If the change is successfully added to the changegroup, SQLITE_OK is
+** returned. Otherwise, an SQLite error code is returned.
+**
+** The iterator must point to a valid entry when this function is called.
+** If it does not, SQLITE_ERROR is returned and no change is added to the
+** changegroup. Additionally, the iterator must not have been opened with
+** the SQLITE_CHANGESETAPPLY_INVERT flag. In this case SQLITE_ERROR is also
+** returned.
+*/
+SQLITE_API int sqlite3changegroup_add_change(
+  sqlite3_changegroup*,
+  sqlite3_changeset_iter*
+);
+
+
+
 /*
 ** CAPI3REF: Obtain A Composite Changeset From A Changegroup
 ** METHOD: sqlite3_changegroup
@@ -12783,8 +12853,8 @@ struct Fts5PhraseIter {
 ** EXTENSION API FUNCTIONS
 **
 ** xUserData(pFts):
-**   Return a copy of the context pointer the extension function was
-**   registered with.
+**   Return a copy of the pUserData pointer passed to the xCreateFunction()
+**   API when the extension function was registered.
 **
 ** xColumnTotalSize(pFts, iCol, pnToken):
 **   If parameter iCol is less than zero, set output variable *pnToken
diff --git a/contrib/sqlite3/sqlite3rc.h b/contrib/sqlite3/sqlite3rc.h
index 561c3e00aeef..eb16b8fffb92 100644
--- a/contrib/sqlite3/sqlite3rc.h
+++ b/contrib/sqlite3/sqlite3rc.h
@@ -1,3 +1,3 @@
 #ifndef SQLITE_RESOURCE_VERSION
-#define SQLITE_RESOURCE_VERSION 3,45,1
+#define SQLITE_RESOURCE_VERSION 3,46,0
 #endif
diff --git a/contrib/sqlite3/tea/configure b/contrib/sqlite3/tea/configure
index 8bd47a5e0187..011ef2101151 100755
--- a/contrib/sqlite3/tea/configure
+++ b/contrib/sqlite3/tea/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.71 for sqlite 3.45.1.
+# Generated by GNU Autoconf 2.71 for sqlite 3.46.0.
 #
 #
 # Copyright (C) 1992-1996, 1998-2017, 2020-2021 Free Software Foundation,
@@ -608,8 +608,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='sqlite'
 PACKAGE_TARNAME='sqlite'
-PACKAGE_VERSION='3.45.1'
-PACKAGE_STRING='sqlite 3.45.1'
+PACKAGE_VERSION='3.46.0'
+PACKAGE_STRING='sqlite 3.46.0'
 PACKAGE_BUGREPORT=''
 PACKAGE_URL=''
 
@@ -1331,7 +1331,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures sqlite 3.45.1 to adapt to many kinds of systems.
+\`configure' configures sqlite 3.46.0 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1393,7 +1393,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of sqlite 3.45.1:";;
+     short | recursive ) echo "Configuration of sqlite 3.46.0:";;
    esac
   cat <<\_ACEOF
 
@@ -1496,7 +1496,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-sqlite configure 3.45.1
+sqlite configure 3.46.0
 generated by GNU Autoconf 2.71
 
 Copyright (C) 2021 Free Software Foundation, Inc.
@@ -1795,7 +1795,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by sqlite $as_me 3.45.1, which was
+It was created by sqlite $as_me 3.46.0, which was
 generated by GNU Autoconf 2.71.  Invocation command line was
 
   $ $0$ac_configure_args_raw
@@ -9560,7 +9560,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by sqlite $as_me 3.45.1, which was
+This file was extended by sqlite $as_me 3.46.0, which was
 generated by GNU Autoconf 2.71.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -9615,7 +9615,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config='$ac_cs_config_escaped'
 ac_cs_version="\\
-sqlite config.status 3.45.1
+sqlite config.status 3.46.0
 configured by $0, generated by GNU Autoconf 2.71,
   with options \\"\$ac_cs_config\\"
 
diff --git a/contrib/sqlite3/tea/configure.ac b/contrib/sqlite3/tea/configure.ac
index 740bd9749d3d..f188f22039ba 100644
--- a/contrib/sqlite3/tea/configure.ac
+++ b/contrib/sqlite3/tea/configure.ac
@@ -19,7 +19,7 @@ dnl	to configure the system for the local environment.
 # so that we create the export library with the dll.
 #-----------------------------------------------------------------------
 
-AC_INIT([sqlite],[3.45.1])
+AC_INIT([sqlite],[3.46.0])
 
 #--------------------------------------------------------------------
 # Call TEA_INIT as the first TEA_ macro to set up initial vars.
diff --git a/crypto/openssh/log.c b/crypto/openssh/log.c
index 9fc1a2e2eaf6..436c75630181 100644
--- a/crypto/openssh/log.c
+++ b/crypto/openssh/log.c
@@ -451,12 +451,14 @@ void
 sshsigdie(const char *file, const char *func, int line, int showfunc,
     LogLevel level, const char *suffix, const char *fmt, ...)
 {
+#if 0
 	va_list args;
 
 	va_start(args, fmt);
 	sshlogv(file, func, line, showfunc, SYSLOG_LEVEL_FATAL,
 	    suffix, fmt, args);
 	va_end(args);
+#endif
 	_exit(1);
 }
 
diff --git a/crypto/openssh/version.h b/crypto/openssh/version.h
index cfbb749c0d04..836b5650b247 100644
--- a/crypto/openssh/version.h
+++ b/crypto/openssh/version.h
@@ -5,4 +5,4 @@
 #define SSH_PORTABLE	"p1"
 #define SSH_RELEASE	SSH_VERSION SSH_PORTABLE
 
-#define SSH_VERSION_FREEBSD	"FreeBSD-20240318"
+#define SSH_VERSION_FREEBSD	"FreeBSD-20240701"
diff --git a/crypto/openssl/CHANGES.md b/crypto/openssl/CHANGES.md
index bd876eb89dd4..19e0fd6e25a5 100644
--- a/crypto/openssl/CHANGES.md
+++ b/crypto/openssl/CHANGES.md
@@ -28,6 +28,72 @@ breaking changes, and mappings for the large list of deprecated functions.
 
 [Migration guide]: https://github.com/openssl/openssl/tree/master/doc/man7/migration_guide.pod
 
+### Changes between 3.0.13 and 3.0.14 [4 Jun 2024]
+
+ * Fixed potential use after free after SSL_free_buffers() is called.
+
+   The SSL_free_buffers function is used to free the internal OpenSSL
+   buffer used when processing an incoming record from the network.
+   The call is only expected to succeed if the buffer is not currently
+   in use. However, two scenarios have been identified where the buffer
+   is freed even when still in use.
+
+   The first scenario occurs where a record header has been received
+   from the network and processed by OpenSSL, but the full record body
+   has not yet arrived. In this case calling SSL_free_buffers will succeed
+   even though a record has only been partially processed and the buffer
+   is still in use.
+
+   The second scenario occurs where a full record containing application
+   data has been received and processed by OpenSSL but the application has
+   only read part of this data. Again a call to SSL_free_buffers will
+   succeed even though the buffer is still in use.
+
+   ([CVE-2024-4741])
+
+   *Matt Caswell*
+
+ * Fixed an issue where checking excessively long DSA keys or parameters may
+   be very slow.
+
+   Applications that use the functions EVP_PKEY_param_check() or
+   EVP_PKEY_public_check() to check a DSA public key or DSA parameters may
+   experience long delays. Where the key or parameters that are being checked
+   have been obtained from an untrusted source this may lead to a Denial of
+   Service.
+
+   To resolve this issue DSA keys larger than OPENSSL_DSA_MAX_MODULUS_BITS
+   will now fail the check immediately with a DSA_R_MODULUS_TOO_LARGE error
+   reason.
+
+   ([CVE-2024-4603])
+
+   *Tomáš Mráz*
+
+ * Fixed an issue where some non-default TLS server configurations can cause
+   unbounded memory growth when processing TLSv1.3 sessions. An attacker may
+   exploit certain server configurations to trigger unbounded memory growth that
+   would lead to a Denial of Service
+
+   This problem can occur in TLSv1.3 if the non-default SSL_OP_NO_TICKET option
+   is being used (but not if early_data is also configured and the default
+   anti-replay protection is in use). In this case, under certain conditions,
+   the session cache can get into an incorrect state and it will fail to flush
+   properly as it fills. The session cache will continue to grow in an unbounded
+   manner. A malicious client could deliberately create the scenario for this
+   failure to force a Denial of Service. It may also happen by accident in
+   normal operation.
+
+   ([CVE-2024-2511])
+
+   *Matt Caswell*
+
+ * New atexit configuration switch, which controls whether the OPENSSL_cleanup
+   is registered when libcrypto is unloaded. This can be used on platforms
+   where using atexit() from shared libraries causes crashes on exit.
+
+   *Randall S. Becker*
+
 ### Changes between 3.0.12 and 3.0.13 [30 Jan 2024]
 
  * A file in PKCS12 format can contain certificates and keys and may come from
@@ -19824,6 +19890,9 @@ ndif
 
 <!-- Links -->
 
+[CVE-2024-4741]: https://www.openssl.org/news/vulnerabilities.html#CVE-2024-4741
+[CVE-2024-4603]: https://www.openssl.org/news/vulnerabilities.html#CVE-2024-4603
+[CVE-2024-2511]: https://www.openssl.org/news/vulnerabilities.html#CVE-2024-2511
 [CVE-2024-0727]: https://www.openssl.org/news/vulnerabilities.html#CVE-2024-0727
 [CVE-2023-6237]: https://www.openssl.org/news/vulnerabilities.html#CVE-2023-6237
 [CVE-2023-6129]: https://www.openssl.org/news/vulnerabilities.html#CVE-2023-6129
diff --git a/crypto/openssl/CONTRIBUTING.md b/crypto/openssl/CONTRIBUTING.md
index 15490fd9f620..fec6616e21fe 100644
--- a/crypto/openssl/CONTRIBUTING.md
+++ b/crypto/openssl/CONTRIBUTING.md
@@ -9,7 +9,7 @@ Development is done on GitHub in the [openssl/openssl] repository.
 
   [openssl/openssl]: <https://github.com/openssl/openssl>
 
-To request new a feature, ask a question, or report a bug,
+To request a new feature, ask a question, or report a bug,
 please open an [issue on GitHub](https://github.com/openssl/openssl/issues).
 
 To submit a patch or implement a new feature, please open a
@@ -67,7 +67,8 @@ guidelines:
     often. We do not accept merge commits, you will have to remove them
     (usually by rebasing) before it will be acceptable.
 
- 4. Code provided should follow our [coding style] and compile without warnings.
+ 4. Code provided should follow our [coding style] and [documentation policy]
+    and compile without warnings.
     There is a [Perl tool](util/check-format.pl) that helps
     finding code formatting mistakes and other coding style nits.
     Where `gcc` or `clang` is available, you should use the
@@ -77,6 +78,7 @@ guidelines:
     whenever a PR is created or updated by committers.
 
     [coding style]: https://www.openssl.org/policies/technical/coding-style.html
+    [documentation policy]: https://openssl.org/policies/technical/documentation-policy.html
 
  5. When at all possible, code contributions should include tests. These can
     either be added to an existing test, or completely new.  Please see
diff --git a/crypto/openssl/Configurations/10-main.conf b/crypto/openssl/Configurations/10-main.conf
index ff8af7146318..1155d9859c56 100644
--- a/crypto/openssl/Configurations/10-main.conf
+++ b/crypto/openssl/Configurations/10-main.conf
@@ -784,7 +784,14 @@ my %targets = (
         asm_arch         => 'aarch64',
         perlasm_scheme   => "linux64",
     },
-
+    "linux-arm64ilp32-clang" => {  # clang config abi by --target
+        inherit_from     => [ "linux-generic32" ],
+        CC               => "clang",
+        CXX              => "clang++",
+        bn_ops           => "SIXTY_FOUR_BIT RC4_CHAR",
+        asm_arch         => 'aarch64',
+        perlasm_scheme   => "linux64",
+    },
     "linux-mips32" => {
         # Configure script adds minimally required -march for assembly
         # support, if no -march was specified at command line.
diff --git a/crypto/openssl/Configurations/15-ios.conf b/crypto/openssl/Configurations/15-ios.conf
index 54d37f63f445..81e3d68bc7f0 100644
--- a/crypto/openssl/Configurations/15-ios.conf
+++ b/crypto/openssl/Configurations/15-ios.conf
@@ -49,16 +49,16 @@ my %targets = (
 #
     "iphoneos-cross" => {
         inherit_from     => [ "ios-common" ],
-        cflags           => add("-isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK) -fno-common"),
+        cflags           => add("-isysroot \"\$(CROSS_TOP)/SDKs/\$(CROSS_SDK)\" -fno-common"),
     },
     "ios-cross" => {
         inherit_from     => [ "ios-xcrun" ],
         CC               => "cc",
-        cflags           => add("-isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK)"),
+        cflags           => add("-isysroot \"\$(CROSS_TOP)/SDKs/\$(CROSS_SDK)\""),
     },
     "ios64-cross" => {
         inherit_from     => [ "ios64-xcrun" ],
         CC               => "cc",
-        cflags           => add("-isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK)"),
+        cflags           => add("-isysroot \"\$(CROSS_TOP)/SDKs/\$(CROSS_SDK)\""),
     },
 );
diff --git a/crypto/openssl/Configurations/unix-Makefile.tmpl b/crypto/openssl/Configurations/unix-Makefile.tmpl
index 3754595d38b5..644540397de5 100644
--- a/crypto/openssl/Configurations/unix-Makefile.tmpl
+++ b/crypto/openssl/Configurations/unix-Makefile.tmpl
@@ -21,7 +21,7 @@
      sub dependmagic {
          my $target = shift;
 
-         return "$target: build_generated\n\t\$(MAKE) depend && \$(MAKE) _$target\n_$target";
+         return "$target: build_generated\n\t\"\$(MAKE)\" depend && \"\$(MAKE)\" _$target\n_$target";
      }
 
      our $COLUMNS = $ENV{COLUMNS};
@@ -527,7 +527,7 @@ all: build_sw build_docs
 
 test: tests
 {- dependmagic('tests'); -}: build_programs_nodep build_modules_nodep link-utils
-	$(MAKE) run_tests
+	"$(MAKE)" run_tests
 run_tests: FORCE
 	@ : {- output_off() if $disabled{tests}; "" -}
 	( SRCTOP=$(SRCDIR) \
@@ -542,7 +542,7 @@ run_tests: FORCE
 
 list-tests:
 	@ : {- output_off() if $disabled{tests}; "" -}
-	$(MAKE) run_tests TESTS=list
+	"$(MAKE)" run_tests TESTS=list
 	@ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
 	@echo "Tests are not supported with your chosen Configure options"
 	@ : {- output_on() if !$disabled{tests}; "" -}
@@ -1193,12 +1193,12 @@ providers/fips.module.sources.new: configdata.pm
 	  cd sources-tmp \
 	  && $$srcdir/Configure --banner=Configured enable-fips -O0 \
 	  && ./configdata.pm --query 'get_sources("providers/fips")' > sources1 \
-	  && $(MAKE) -sj 4 build_generated providers/fips.so \
+	  && "$(MAKE)" -sj 4 build_generated providers/fips.so \
 	  && find . -name '*.d' | xargs cat > dep1 \
-          && $(MAKE) distclean \
+          && "$(MAKE)" distclean \
 	  && $$srcdir/Configure --banner=Configured enable-fips no-asm -O0 \
 	  && ./configdata.pm --query 'get_sources("providers/fips")' > sources2 \
-	  && $(MAKE) -sj 4 build_generated providers/fips.so \
+	  && "$(MAKE)" -sj 4 build_generated providers/fips.so \
 	  && find . -name '*.d' | xargs cat > dep2 \
 	  && cat sources1 sources2 \
 	     | grep -v ' : \\$$' | grep -v util/providers.num \
@@ -1332,7 +1332,7 @@ ordinals: build_generated
                 $(SSLHEADERS)
 
 test_ordinals:
-	$(MAKE) run_tests TESTS=test_ordinals
+	"$(MAKE)" run_tests TESTS=test_ordinals
 
 tags TAGS: FORCE
 	rm -f TAGS tags
diff --git a/crypto/openssl/Configure b/crypto/openssl/Configure
index 84cc4094644a..40c03ad0af32 100755
--- a/crypto/openssl/Configure
+++ b/crypto/openssl/Configure
@@ -1,6 +1,6 @@
 #! /usr/bin/env perl
 # -*- mode: perl; -*-
-# Copyright 2016-2023 The OpenSSL Project Authors. All Rights Reserved.
+# Copyright 2016-2024 The OpenSSL Project Authors. All Rights Reserved.
 #
 # Licensed under the Apache License 2.0 (the "License").  You may not use
 # this file except in compliance with the License.  You can obtain a copy
@@ -405,6 +405,7 @@ my @disablables = (
     "asan",
     "asm",
     "async",
+    "atexit",
     "autoalginit",
     "autoerrinit",
     "autoload-config",
diff --git a/crypto/openssl/INSTALL.md b/crypto/openssl/INSTALL.md
index fef408e9d1e3..c0dae491c94d 100644
--- a/crypto/openssl/INSTALL.md
+++ b/crypto/openssl/INSTALL.md
@@ -480,7 +480,7 @@ Setting the FIPS HMAC key
 
 As part of its self-test validation, the FIPS module must verify itself
 by performing a SHA-256 HMAC computation on itself. The default key is
-the SHA256 value of "the holy handgrenade of antioch" and is sufficient
+the SHA256 value of "holy hand grenade of antioch" and is sufficient
 for meeting the FIPS requirements.
 
 To change the key to a different value, use this flag. The value should
@@ -546,6 +546,13 @@ be used even with this option.
 
 Do not build support for async operations.
 
+### no-atexit
+
+Do not use `atexit()` in libcrypto builds.
+
+`atexit()` has varied semantics between platforms and can cause SIGSEGV in some
+circumstances. This option disables the atexit registration of OPENSSL_cleanup.
+
 ### no-autoalginit
 
 Don't automatically load all supported ciphers and digests.
diff --git a/crypto/openssl/NEWS.md b/crypto/openssl/NEWS.md
index d9a48b157eb1..fb231bcd8459 100644
--- a/crypto/openssl/NEWS.md
+++ b/crypto/openssl/NEWS.md
@@ -18,6 +18,18 @@ OpenSSL Releases
 OpenSSL 3.0
 -----------
 
+### Major changes between OpenSSL 3.0.13 and OpenSSL 3.0.14 [4 Jun 2024]
+
+  * Fixed potential use after free after SSL_free_buffers() is called
+    ([CVE-2024-4741])
+
+  * Fixed an issue where checking excessively long DSA keys or parameters may
+    be very slow
+    ([CVE-2024-4603])
+
+  * Fixed unbounded memory growth with session handling in TLSv1.3
+    ([CVE-2024-2511])
+
 ### Major changes between OpenSSL 3.0.12 and OpenSSL 3.0.13 [30 Jan 2024]
 
   * Fixed PKCS12 Decoding crashes
@@ -1470,6 +1482,9 @@ OpenSSL 0.9.x
 
 <!-- Links -->
 
+[CVE-2024-4741]: https://www.openssl.org/news/vulnerabilities.html#CVE-2024-4741
+[CVE-2024-4603]: https://www.openssl.org/news/vulnerabilities.html#CVE-2024-4603
+[CVE-2024-2511]: https://www.openssl.org/news/vulnerabilities.html#CVE-2024-2511
 [CVE-2024-0727]: https://www.openssl.org/news/vulnerabilities.html#CVE-2024-0727
 [CVE-2023-6237]: https://www.openssl.org/news/vulnerabilities.html#CVE-2023-6237
 [CVE-2023-6129]: https://www.openssl.org/news/vulnerabilities.html#CVE-2023-6129
diff --git a/crypto/openssl/NOTES-NONSTOP.md b/crypto/openssl/NOTES-NONSTOP.md
index 68438b998884..ab13de7d3a76 100644
--- a/crypto/openssl/NOTES-NONSTOP.md
+++ b/crypto/openssl/NOTES-NONSTOP.md
@@ -56,7 +56,10 @@ relating to `atexit()` processing when a shared library is unloaded and when
 the program terminates. This limitation applies to all OpenSSL shared library
 components.
 
-A resolution to this situation is under investigation.
+It is possible to configure the build with `no-atexit` to avoid the SIGSEGV.
+Preferably, you can explicitly call `OPENSSL_cleanup()` from your application.
+It is not mandatory as it just deallocates various global data structures
+OpenSSL allocated.
 
 About Prefix and OpenSSLDir
 ---------------------------
diff --git a/crypto/openssl/VERSION.dat b/crypto/openssl/VERSION.dat
index 3ee1a6f829f4..5de9bf3d01ba 100644
--- a/crypto/openssl/VERSION.dat
+++ b/crypto/openssl/VERSION.dat
@@ -1,7 +1,7 @@
 MAJOR=3
 MINOR=0
-PATCH=13
+PATCH=14
 PRE_RELEASE_TAG=
 BUILD_METADATA=
-RELEASE_DATE="30 Jan 2024"
+RELEASE_DATE="4 Jun 2024"
 SHLIB_VERSION=3
diff --git a/crypto/openssl/apps/lib/s_cb.c b/crypto/openssl/apps/lib/s_cb.c
index f2ddd94c3de4..7881c1667626 100644
--- a/crypto/openssl/apps/lib/s_cb.c
+++ b/crypto/openssl/apps/lib/s_cb.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -1318,7 +1318,8 @@ int ssl_load_stores(SSL_CTX *ctx,
         if (vfyCAstore != NULL && !X509_STORE_load_store(vfy, vfyCAstore))
             goto err;
         add_crls_store(vfy, crls);
-        SSL_CTX_set1_verify_cert_store(ctx, vfy);
+        if (SSL_CTX_set1_verify_cert_store(ctx, vfy) == 0)
+            goto err;
         if (crl_download)
             store_setup_crl_download(vfy);
     }
@@ -1332,7 +1333,8 @@ int ssl_load_stores(SSL_CTX *ctx,
             goto err;
         if (chCAstore != NULL && !X509_STORE_load_store(ch, chCAstore))
             goto err;
-        SSL_CTX_set1_chain_cert_store(ctx, ch);
+        if (SSL_CTX_set1_chain_cert_store(ctx, ch) == 0)
+            goto err;
     }
     rv = 1;
  err:
diff --git a/crypto/openssl/apps/list.c b/crypto/openssl/apps/list.c
index 0fcbcbb083cb..7d3136a8a161 100644
--- a/crypto/openssl/apps/list.c
+++ b/crypto/openssl/apps/list.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -1230,6 +1230,7 @@ static void list_provider_info(void)
     }
 
     if (OSSL_PROVIDER_do_all(NULL, &collect_providers, providers) != 1) {
+        sk_OSSL_PROVIDER_free(providers);
         BIO_printf(bio_err, "ERROR: Memory allocation\n");
         return;
     }
diff --git a/crypto/openssl/apps/ocsp.c b/crypto/openssl/apps/ocsp.c
index 821e224c6ce4..fb3105da5526 100644
--- a/crypto/openssl/apps/ocsp.c
+++ b/crypto/openssl/apps/ocsp.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2001-2022 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2001-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -11,7 +11,7 @@
 
 #ifdef OPENSSL_SYS_VMS
   /* So fd_set and friends get properly defined on OpenVMS */
-# define _XOPEN_SOURCE_EXTENDED
+# define _XOPEN_SOURCE_EXTENDED 1
 #endif
 
 #include <stdio.h>
diff --git a/crypto/openssl/apps/pkcs12.c b/crypto/openssl/apps/pkcs12.c
index b442d358f8b7..ab78903ee9cd 100644
--- a/crypto/openssl/apps/pkcs12.c
+++ b/crypto/openssl/apps/pkcs12.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2022 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1999-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -712,9 +712,6 @@ int pkcs12_main(int argc, char **argv)
     in = bio_open_default(infile, 'r', FORMAT_PKCS12);
     if (in == NULL)
         goto end;
-    out = bio_open_owner(outfile, FORMAT_PEM, private);
-    if (out == NULL)
-        goto end;
 
     p12 = PKCS12_init_ex(NID_pkcs7_data, app_get0_libctx(), app_get0_propq());
     if (p12 == NULL) {
@@ -814,6 +811,11 @@ int pkcs12_main(int argc, char **argv)
 
  dump:
     assert(private);
+
+    out = bio_open_owner(outfile, FORMAT_PEM, private);
+    if (out == NULL)
+        goto end;
+
     if (!dump_certs_keys_p12(out, p12, cpass, -1, options, passout, enc)) {
         BIO_printf(bio_err, "Error outputting keys and certificates\n");
         ERR_print_errors(bio_err);
@@ -855,7 +857,11 @@ int dump_certs_keys_p12(BIO *out, const PKCS12 *p12, const char *pass,
         } else if (bagnid == NID_pkcs7_encrypted) {
             if (options & INFO) {
                 BIO_printf(bio_err, "PKCS7 Encrypted data: ");
-                alg_print(p7->d.encrypted->enc_data->algorithm);
+                if (p7->d.encrypted == NULL) {
+                    BIO_printf(bio_err, "<no data>\n");
+                } else {
+                    alg_print(p7->d.encrypted->enc_data->algorithm);
+                }
             }
             bags = PKCS12_unpack_p7encdata(p7, pass, passlen);
         } else {
diff --git a/crypto/openssl/apps/req.c b/crypto/openssl/apps/req.c
index c7d4c7822cda..2fc53d4bfcfa 100644
--- a/crypto/openssl/apps/req.c
+++ b/crypto/openssl/apps/req.c
@@ -569,7 +569,7 @@ int req_main(int argc, char **argv)
         X509V3_CTX ctx;
 
         X509V3_set_ctx_test(&ctx);
-        X509V3_set_nconf(&ctx, addext_conf);
+        X509V3_set_nconf(&ctx, req_conf);
         if (!X509V3_EXT_add_nconf(addext_conf, &ctx, "default", NULL)) {
             BIO_printf(bio_err, "Error checking extensions defined using -addext\n");
             goto end;
diff --git a/crypto/openssl/apps/speed.c b/crypto/openssl/apps/speed.c
index 1113d775b8ab..d8e2c70e6128 100644
--- a/crypto/openssl/apps/speed.c
+++ b/crypto/openssl/apps/speed.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved.
  * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
@@ -727,8 +727,12 @@ static int EVP_Update_loop(void *args)
     unsigned char *buf = tempargs->buf;
     EVP_CIPHER_CTX *ctx = tempargs->ctx;
     int outl, count, rc;
+    unsigned char faketag[16] = { 0xcc };
 
     if (decrypt) {
+        if (EVP_CIPHER_get_flags(EVP_CIPHER_CTX_get0_cipher(ctx)) & EVP_CIPH_FLAG_AEAD_CIPHER) {
+            (void)EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, sizeof(faketag), faketag);
+        }
         for (count = 0; COND(c[D_EVP][testnum]); count++) {
             rc = EVP_DecryptUpdate(ctx, buf, &outl, buf, lengths[testnum]);
             if (rc != 1) {
diff --git a/crypto/openssl/apps/ts.c b/crypto/openssl/apps/ts.c
index 57292e187cd2..01b73f380428 100644
--- a/crypto/openssl/apps/ts.c
+++ b/crypto/openssl/apps/ts.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006-2022 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2006-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -535,15 +535,18 @@ static int create_digest(BIO *input, const char *digest, const EVP_MD *md,
 
         *md_value = OPENSSL_hexstr2buf(digest, &digest_len);
         if (*md_value == NULL || md_value_len != digest_len) {
-            OPENSSL_free(*md_value);
-            *md_value = NULL;
             BIO_printf(bio_err, "bad digest, %d bytes "
                        "must be specified\n", md_value_len);
-            return 0;
+            goto err;
         }
     }
     rv = md_value_len;
  err:
+    if (rv <= 0) {
+        OPENSSL_free(*md_value);
+        *md_value = NULL;
+        rv = 0;
+    }
     EVP_MD_CTX_free(md_ctx);
     return rv;
 }
diff --git a/crypto/openssl/crypto/aes/build.info b/crypto/openssl/crypto/aes/build.info
index b250903fa6e2..271015e35e1b 100644
--- a/crypto/openssl/crypto/aes/build.info
+++ b/crypto/openssl/crypto/aes/build.info
@@ -76,7 +76,7 @@ DEFINE[../../providers/libdefault.a]=$AESDEF
 # already gets everything that the static libcrypto.a has, and doesn't need it
 # added again.
 IF[{- !$disabled{module} && !$disabled{shared} -}]
-  DEFINE[../providers/liblegacy.a]=$AESDEF
+  DEFINE[../../providers/liblegacy.a]=$AESDEF
 ENDIF
 
 GENERATE[aes-ia64.s]=asm/aes-ia64.S
diff --git a/crypto/openssl/crypto/bio/bio_lib.c b/crypto/openssl/crypto/bio/bio_lib.c
index c86b9ac198ca..245a75afa1b8 100644
--- a/crypto/openssl/crypto/bio/bio_lib.c
+++ b/crypto/openssl/crypto/bio/bio_lib.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -869,8 +869,12 @@ static int bio_wait(BIO *bio, time_t max_time, unsigned int nap_milliseconds)
         return 1;
 
 #ifndef OPENSSL_NO_SOCK
-    if (BIO_get_fd(bio, &fd) > 0 && fd < FD_SETSIZE)
-        return BIO_socket_wait(fd, BIO_should_read(bio), max_time);
+    if (BIO_get_fd(bio, &fd) > 0) {
+        int ret = BIO_socket_wait(fd, BIO_should_read(bio), max_time);
+
+        if (ret != -1)
+            return ret;
+    }
 #endif
     /* fall back to polling since no sockets are available */
 
diff --git a/crypto/openssl/crypto/bio/bio_sock.c b/crypto/openssl/crypto/bio/bio_sock.c
index 476cbcc5cef1..12e6a68e3a25 100644
--- a/crypto/openssl/crypto/bio/bio_sock.c
+++ b/crypto/openssl/crypto/bio/bio_sock.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -396,7 +396,11 @@ int BIO_socket_wait(int fd, int for_read, time_t max_time)
     struct timeval tv;
     time_t now;
 
+#ifdef _WIN32
+    if ((SOCKET)fd == INVALID_SOCKET)
+#else
     if (fd < 0 || fd >= FD_SETSIZE)
+#endif
         return -1;
     if (max_time == 0)
         return 1;
diff --git a/crypto/openssl/crypto/bn/bn_lib.c b/crypto/openssl/crypto/bn/bn_lib.c
index cf1bfe8ab085..9677a603cb2d 100644
--- a/crypto/openssl/crypto/bn/bn_lib.c
+++ b/crypto/openssl/crypto/bn/bn_lib.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -618,14 +618,29 @@ int BN_ucmp(const BIGNUM *a, const BIGNUM *b)
     int i;
     BN_ULONG t1, t2, *ap, *bp;
 
+    ap = a->d;
+    bp = b->d;
+
+    if (BN_get_flags(a, BN_FLG_CONSTTIME)
+            && a->top == b->top) {
+        int res = 0;
+
+        for (i = 0; i < b->top; i++) {
+            res = constant_time_select_int(constant_time_lt_bn(ap[i], bp[i]),
+                                           -1, res);
+            res = constant_time_select_int(constant_time_lt_bn(bp[i], ap[i]),
+                                           1, res);
+        }
+        return res;
+    }
+
     bn_check_top(a);
     bn_check_top(b);
 
     i = a->top - b->top;
     if (i != 0)
         return i;
-    ap = a->d;
-    bp = b->d;
+
     for (i = a->top - 1; i >= 0; i--) {
         t1 = ap[i];
         t2 = bp[i];
@@ -737,11 +752,10 @@ int BN_is_bit_set(const BIGNUM *a, int n)
     return (int)(((a->d[i]) >> j) & ((BN_ULONG)1));
 }
 
-int BN_mask_bits(BIGNUM *a, int n)
+int ossl_bn_mask_bits_fixed_top(BIGNUM *a, int n)
 {
     int b, w;
 
-    bn_check_top(a);
     if (n < 0)
         return 0;
 
@@ -755,10 +769,21 @@ int BN_mask_bits(BIGNUM *a, int n)
         a->top = w + 1;
         a->d[w] &= ~(BN_MASK2 << b);
     }
-    bn_correct_top(a);
+    a->flags |= BN_FLG_FIXED_TOP;
     return 1;
 }
 
+int BN_mask_bits(BIGNUM *a, int n)
+{
+    int ret;
+
+    bn_check_top(a);
+    ret = ossl_bn_mask_bits_fixed_top(a, n);
+    if (ret)
+        bn_correct_top(a);
+    return ret;
+}
+
 void BN_set_negative(BIGNUM *a, int b)
 {
     if (b && !BN_is_zero(a))
@@ -935,6 +960,22 @@ int BN_is_word(const BIGNUM *a, const BN_ULONG w)
     return BN_abs_is_word(a, w) && (!w || !a->neg);
 }
 
+int ossl_bn_is_word_fixed_top(const BIGNUM *a, BN_ULONG w)
+{
+    int res, i;
+    const BN_ULONG *ap = a->d;
+
+    if (a->neg || a->top == 0)
+        return 0;
+
+    res = constant_time_select_int(constant_time_eq_bn(ap[0], w), 1, 0);
+
+    for (i = 1; i < a->top; i++)
+        res = constant_time_select_int(constant_time_is_zero_bn(ap[i]),
+                                       res, 0);
+    return res;
+}
+
 int BN_is_odd(const BIGNUM *a)
 {
     return (a->top > 0) && (a->d[0] & 1);
diff --git a/crypto/openssl/crypto/bn/bn_rand.c b/crypto/openssl/crypto/bn/bn_rand.c
index 2ca426ff76ed..ba0970b1f87d 100644
--- a/crypto/openssl/crypto/bn/bn_rand.c
+++ b/crypto/openssl/crypto/bn/bn_rand.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -186,8 +186,8 @@ static int bnrand_range(BNRAND_FLAG flag, BIGNUM *r, const BIGNUM *range,
     } else {
         do {
             /* range = 11..._2  or  range = 101..._2 */
-            if (!bnrand(flag, r, n, BN_RAND_TOP_ANY, BN_RAND_BOTTOM_ANY, 0,
-                        ctx))
+            if (!bnrand(flag, r, n, BN_RAND_TOP_ANY, BN_RAND_BOTTOM_ANY,
+                        strength, ctx))
                 return 0;
 
             if (!--count) {
@@ -240,17 +240,63 @@ int BN_pseudo_rand_range(BIGNUM *r, const BIGNUM *range)
 # endif
 #endif
 
+int ossl_bn_priv_rand_range_fixed_top(BIGNUM *r, const BIGNUM *range,
+                                      unsigned int strength, BN_CTX *ctx)
+{
+    int n;
+    int count = 100;
+
+    if (r == NULL) {
+        ERR_raise(ERR_LIB_BN, ERR_R_PASSED_NULL_PARAMETER);
+        return 0;
+    }
+
+    if (range->neg || BN_is_zero(range)) {
+        ERR_raise(ERR_LIB_BN, BN_R_INVALID_RANGE);
+        return 0;
+    }
+
+    n = BN_num_bits(range);     /* n > 0 */
+
+    /* BN_is_bit_set(range, n - 1) always holds */
+
+    if (n == 1) {
+        BN_zero(r);
+    } else {
+        BN_set_flags(r, BN_FLG_CONSTTIME);
+        do {
+            if (!bnrand(PRIVATE, r, n + 1, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ANY,
+                        strength, ctx))
+                return 0;
+
+            if (!--count) {
+                ERR_raise(ERR_LIB_BN, BN_R_TOO_MANY_ITERATIONS);
+                return 0;
+            }
+            ossl_bn_mask_bits_fixed_top(r, n);
+        }
+        while (BN_ucmp(r, range) >= 0);
+#ifdef BN_DEBUG
+        /* With BN_DEBUG on a fixed top number cannot be returned */
+        bn_correct_top(r);
+#endif
+    }
+
+    return 1;
+}
+
 /*
- * BN_generate_dsa_nonce generates a random number 0 <= out < range. Unlike
- * BN_rand_range, it also includes the contents of |priv| and |message| in
- * the generation so that an RNG failure isn't fatal as long as |priv|
+ * ossl_bn_gen_dsa_nonce_fixed_top generates a random number 0 <= out < range.
+ * Unlike BN_rand_range, it also includes the contents of |priv| and |message|
+ * in the generation so that an RNG failure isn't fatal as long as |priv|
  * remains secret. This is intended for use in DSA and ECDSA where an RNG
  * weakness leads directly to private key exposure unless this function is
  * used.
  */
-int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range,
-                          const BIGNUM *priv, const unsigned char *message,
-                          size_t message_len, BN_CTX *ctx)
+int ossl_bn_gen_dsa_nonce_fixed_top(BIGNUM *out, const BIGNUM *range,
+                                    const BIGNUM *priv,
+                                    const unsigned char *message,
+                                    size_t message_len, BN_CTX *ctx)
 {
     EVP_MD_CTX *mdctx = EVP_MD_CTX_new();
     /*
@@ -260,20 +306,24 @@ int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range,
     unsigned char random_bytes[64];
     unsigned char digest[SHA512_DIGEST_LENGTH];
     unsigned done, todo;
-    /* We generate |range|+8 bytes of random output. */
-    const unsigned num_k_bytes = BN_num_bytes(range) + 8;
+    /* We generate |range|+1 bytes of random output. */
+    const unsigned num_k_bytes = BN_num_bytes(range) + 1;
     unsigned char private_bytes[96];
     unsigned char *k_bytes = NULL;
+    const int max_n = 64;           /* Pr(failure to generate) < 2^max_n */
+    int n;
     int ret = 0;
     EVP_MD *md = NULL;
     OSSL_LIB_CTX *libctx = ossl_bn_get_libctx(ctx);
 
     if (mdctx == NULL)
-        goto err;
+        goto end;
 
     k_bytes = OPENSSL_malloc(num_k_bytes);
     if (k_bytes == NULL)
-        goto err;
+        goto end;
+    /* Ensure top byte is set to avoid non-constant time in bin2bn */
+    k_bytes[0] = 0xff;
 
     /* We copy |priv| into a local buffer to avoid exposing its length. */
     if (BN_bn2binpad(priv, private_bytes, sizeof(private_bytes)) < 0) {
@@ -283,41 +333,60 @@ int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range,
          * length of the private key.
          */
         ERR_raise(ERR_LIB_BN, BN_R_PRIVATE_KEY_TOO_LARGE);
-        goto err;
+        goto end;
     }
 
     md = EVP_MD_fetch(libctx, "SHA512", NULL);
     if (md == NULL) {
         ERR_raise(ERR_LIB_BN, BN_R_NO_SUITABLE_DIGEST);
-        goto err;
-    }
-    for (done = 0; done < num_k_bytes;) {
-        if (RAND_priv_bytes_ex(libctx, random_bytes, sizeof(random_bytes), 0) <= 0)
-            goto err;
-
-        if (!EVP_DigestInit_ex(mdctx, md, NULL)
-                || !EVP_DigestUpdate(mdctx, &done, sizeof(done))
-                || !EVP_DigestUpdate(mdctx, private_bytes,
-                                     sizeof(private_bytes))
-                || !EVP_DigestUpdate(mdctx, message, message_len)
-                || !EVP_DigestUpdate(mdctx, random_bytes, sizeof(random_bytes))
-                || !EVP_DigestFinal_ex(mdctx, digest, NULL))
-            goto err;
-
-        todo = num_k_bytes - done;
-        if (todo > SHA512_DIGEST_LENGTH)
-            todo = SHA512_DIGEST_LENGTH;
-        memcpy(k_bytes + done, digest, todo);
-        done += todo;
+        goto end;
     }
+    for (n = 0; n < max_n; n++) {
+        unsigned char i = 0;
+
+        for (done = 1; done < num_k_bytes;) {
+            if (RAND_priv_bytes_ex(libctx, random_bytes, sizeof(random_bytes),
+                                   0) <= 0)
+                goto end;
+
+            if (!EVP_DigestInit_ex(mdctx, md, NULL)
+                    || !EVP_DigestUpdate(mdctx, &i, sizeof(i))
+                    || !EVP_DigestUpdate(mdctx, private_bytes,
+                                         sizeof(private_bytes))
+                    || !EVP_DigestUpdate(mdctx, message, message_len)
+                    || !EVP_DigestUpdate(mdctx, random_bytes,
+                                         sizeof(random_bytes))
+                    || !EVP_DigestFinal_ex(mdctx, digest, NULL))
+                goto end;
+
+            todo = num_k_bytes - done;
+            if (todo > SHA512_DIGEST_LENGTH)
+                todo = SHA512_DIGEST_LENGTH;
+            memcpy(k_bytes + done, digest, todo);
+            done += todo;
+            ++i;
+        }
 
-    if (!BN_bin2bn(k_bytes, num_k_bytes, out))
-        goto err;
-    if (BN_mod(out, out, range, ctx) != 1)
-        goto err;
-    ret = 1;
+        if (!BN_bin2bn(k_bytes, num_k_bytes, out))
+            goto end;
 
- err:
+        /* Clear out the top bits and rejection filter into range */
+        BN_set_flags(out, BN_FLG_CONSTTIME);
+        ossl_bn_mask_bits_fixed_top(out, BN_num_bits(range));
+
+        if (BN_ucmp(out, range) < 0) {
+            ret = 1;
+#ifdef BN_DEBUG
+            /* With BN_DEBUG on a fixed top number cannot be returned */
+            bn_correct_top(out);
+#endif
+            goto end;
+        }
+    }
+    /* Failed to generate anything */
+    ERR_raise(ERR_LIB_BN, ERR_R_INTERNAL_ERROR);
+
+ end:
     EVP_MD_CTX_free(mdctx);
     EVP_MD_free(md);
     OPENSSL_clear_free(k_bytes, num_k_bytes);
@@ -326,3 +395,20 @@ int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range,
     OPENSSL_cleanse(private_bytes, sizeof(private_bytes));
     return ret;
 }
+
+int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range,
+                          const BIGNUM *priv, const unsigned char *message,
+                          size_t message_len, BN_CTX *ctx)
+{
+    int ret;
+
+    ret = ossl_bn_gen_dsa_nonce_fixed_top(out, range, priv, message,
+                                          message_len, ctx);
+    /*
+     * This call makes the BN_generate_dsa_nonce non-const-time, thus we
+     * do not use it internally. But fixed_top BNs currently cannot be returned
+     * from public API calls.
+     */
+    bn_correct_top(out);
+    return ret;
+}
diff --git a/crypto/openssl/crypto/bn/bn_shift.c b/crypto/openssl/crypto/bn/bn_shift.c
index 8fcb04324e6d..d67331f1f634 100644
--- a/crypto/openssl/crypto/bn/bn_shift.c
+++ b/crypto/openssl/crypto/bn/bn_shift.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -156,6 +156,9 @@ int BN_rshift(BIGNUM *r, const BIGNUM *a, int n)
         return 0;
     }
 
+    bn_check_top(r);
+    bn_check_top(a);
+
     ret = bn_rshift_fixed_top(r, a, n);
 
     bn_correct_top(r);
@@ -177,9 +180,6 @@ int bn_rshift_fixed_top(BIGNUM *r, const BIGNUM *a, int n)
     BN_ULONG *t, *f;
     BN_ULONG l, m, mask;
 
-    bn_check_top(r);
-    bn_check_top(a);
-
     assert(n >= 0);
 
     nw = n / BN_BITS2;
diff --git a/crypto/openssl/crypto/dsa/dsa_check.c b/crypto/openssl/crypto/dsa/dsa_check.c
index fb0e9129a295..801b932d8724 100644
--- a/crypto/openssl/crypto/dsa/dsa_check.c
+++ b/crypto/openssl/crypto/dsa/dsa_check.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -19,8 +19,34 @@
 #include "dsa_local.h"
 #include "crypto/dsa.h"
 
+static int dsa_precheck_params(const DSA *dsa, int *ret)
+{
+    if (dsa->params.p == NULL || dsa->params.q == NULL) {
+        ERR_raise(ERR_LIB_DSA, DSA_R_BAD_FFC_PARAMETERS);
+        *ret = FFC_CHECK_INVALID_PQ;
+        return 0;
+    }
+
+    if (BN_num_bits(dsa->params.p) > OPENSSL_DSA_MAX_MODULUS_BITS) {
+        ERR_raise(ERR_LIB_DSA, DSA_R_MODULUS_TOO_LARGE);
+        *ret = FFC_CHECK_INVALID_PQ;
+        return 0;
+    }
+
+    if (BN_num_bits(dsa->params.q) >= BN_num_bits(dsa->params.p)) {
+        ERR_raise(ERR_LIB_DSA, DSA_R_BAD_Q_VALUE);
+        *ret = FFC_CHECK_INVALID_PQ;
+        return 0;
+    }
+
+    return 1;
+}
+
 int ossl_dsa_check_params(const DSA *dsa, int checktype, int *ret)
 {
+    if (!dsa_precheck_params(dsa, ret))
+        return 0;
+
     if (checktype == OSSL_KEYMGMT_VALIDATE_QUICK_CHECK)
         return ossl_ffc_params_simple_validate(dsa->libctx, &dsa->params,
                                                FFC_PARAM_TYPE_DSA, ret);
@@ -39,6 +65,9 @@ int ossl_dsa_check_params(const DSA *dsa, int checktype, int *ret)
  */
 int ossl_dsa_check_pub_key(const DSA *dsa, const BIGNUM *pub_key, int *ret)
 {
+    if (!dsa_precheck_params(dsa, ret))
+        return 0;
+
     return ossl_ffc_validate_public_key(&dsa->params, pub_key, ret)
            && *ret == 0;
 }
@@ -50,6 +79,9 @@ int ossl_dsa_check_pub_key(const DSA *dsa, const BIGNUM *pub_key, int *ret)
  */
 int ossl_dsa_check_pub_key_partial(const DSA *dsa, const BIGNUM *pub_key, int *ret)
 {
+    if (!dsa_precheck_params(dsa, ret))
+        return 0;
+
     return ossl_ffc_validate_public_key_partial(&dsa->params, pub_key, ret)
            && *ret == 0;
 }
@@ -58,8 +90,10 @@ int ossl_dsa_check_priv_key(const DSA *dsa, const BIGNUM *priv_key, int *ret)
 {
     *ret = 0;
 
-    return (dsa->params.q != NULL
-            && ossl_ffc_validate_private_key(dsa->params.q, priv_key, ret));
+    if (!dsa_precheck_params(dsa, ret))
+        return 0;
+
+    return ossl_ffc_validate_private_key(dsa->params.q, priv_key, ret);
 }
 
 /*
@@ -72,8 +106,10 @@ int ossl_dsa_check_pairwise(const DSA *dsa)
     BN_CTX *ctx = NULL;
     BIGNUM *pub_key = NULL;
 
-    if (dsa->params.p == NULL
-        || dsa->params.g == NULL
+    if (!dsa_precheck_params(dsa, &ret))
+        return 0;
+
+    if (dsa->params.g == NULL
         || dsa->priv_key == NULL
         || dsa->pub_key == NULL)
         return 0;
diff --git a/crypto/openssl/crypto/dsa/dsa_ossl.c b/crypto/openssl/crypto/dsa/dsa_ossl.c
index 8fd66a950e37..0c18b78f7633 100644
--- a/crypto/openssl/crypto/dsa/dsa_ossl.c
+++ b/crypto/openssl/crypto/dsa/dsa_ossl.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -262,12 +262,13 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in,
              * We calculate k from SHA512(private_key + H(message) + random).
              * This protects the private key from a weak PRNG.
              */
-            if (!BN_generate_dsa_nonce(k, dsa->params.q, dsa->priv_key, dgst,
-                                       dlen, ctx))
+            if (!ossl_bn_gen_dsa_nonce_fixed_top(k, dsa->params.q,
+                                                 dsa->priv_key, dgst,
+                                                 dlen, ctx))
                 goto err;
-        } else if (!BN_priv_rand_range_ex(k, dsa->params.q, 0, ctx))
+        } else if (!ossl_bn_priv_rand_range_fixed_top(k, dsa->params.q, 0, ctx))
             goto err;
-    } while (BN_is_zero(k));
+    } while (ossl_bn_is_word_fixed_top(k, 0));
 
     BN_set_flags(k, BN_FLG_CONSTTIME);
     BN_set_flags(l, BN_FLG_CONSTTIME);
diff --git a/crypto/openssl/crypto/dsa/dsa_sign.c b/crypto/openssl/crypto/dsa/dsa_sign.c
index ddfbfa18af15..91d334ea533a 100644
--- a/crypto/openssl/crypto/dsa/dsa_sign.c
+++ b/crypto/openssl/crypto/dsa/dsa_sign.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -156,6 +156,11 @@ int ossl_dsa_sign_int(int type, const unsigned char *dgst, int dlen,
 {
     DSA_SIG *s;
 
+    if (sig == NULL) {
+        *siglen = DSA_size(dsa);
+        return 1;
+    }
+
     /* legacy case uses the method table */
     if (dsa->libctx == NULL || dsa->meth != DSA_get_default_method())
         s = DSA_do_sign(dgst, dlen, dsa);
@@ -165,7 +170,7 @@ int ossl_dsa_sign_int(int type, const unsigned char *dgst, int dlen,
         *siglen = 0;
         return 0;
     }
-    *siglen = i2d_DSA_SIG(s, sig != NULL ? &sig : NULL);
+    *siglen = i2d_DSA_SIG(s, &sig);
     DSA_SIG_free(s);
     return 1;
 }
diff --git a/crypto/openssl/crypto/ec/build.info b/crypto/openssl/crypto/ec/build.info
index a511e887a9ba..6dd98e9f4f17 100644
--- a/crypto/openssl/crypto/ec/build.info
+++ b/crypto/openssl/crypto/ec/build.info
@@ -77,7 +77,7 @@ DEFINE[../../providers/libdefault.a]=$ECDEF
 # Otherwise, it already gets everything that the static libcrypto.a
 # has, and doesn't need it added again.
 IF[{- !$disabled{module} && !$disabled{shared} -}]
-  DEFINE[../providers/liblegacy.a]=$ECDEF
+  DEFINE[../../providers/liblegacy.a]=$ECDEF
 ENDIF
 
 GENERATE[ecp_nistz256-x86.S]=asm/ecp_nistz256-x86.pl
diff --git a/crypto/openssl/crypto/ec/curve448/arch_64/f_impl64.c b/crypto/openssl/crypto/ec/curve448/arch_64/f_impl64.c
index 8f7a7dd391bd..dfe75b8fc5ca 100644
--- a/crypto/openssl/crypto/ec/curve448/arch_64/f_impl64.c
+++ b/crypto/openssl/crypto/ec/curve448/arch_64/f_impl64.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017-2022 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2017-2024 The OpenSSL Project Authors. All Rights Reserved.
  * Copyright 2014 Cryptography Research, Inc.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
@@ -45,9 +45,9 @@ void gf_mul(gf_s * RESTRICT cs, const gf as, const gf bs)
             accum0 += widemul(a[j + 4], b[i - j + 4]);
         }
         for (; j < 4; j++) {
-            accum2 += widemul(a[j], b[i - j + 8]);
-            accum1 += widemul(aa[j], bbb[i - j + 4]);
-            accum0 += widemul(a[j + 4], bb[i - j + 4]);
+            accum2 += widemul(a[j], b[i + 8 - j]);
+            accum1 += widemul(aa[j], bbb[i + 4 - j]);
+            accum0 += widemul(a[j + 4], bb[i + 4 - j]);
         }
 
         accum1 -= accum2;
diff --git a/crypto/openssl/crypto/ec/ecdsa_ossl.c b/crypto/openssl/crypto/ec/ecdsa_ossl.c
index 0bf4635e2f97..4b54a30cf9bc 100644
--- a/crypto/openssl/crypto/ec/ecdsa_ossl.c
+++ b/crypto/openssl/crypto/ec/ecdsa_ossl.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2023 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2002-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -70,6 +70,11 @@ int ossl_ecdsa_sign(int type, const unsigned char *dgst, int dlen,
 {
     ECDSA_SIG *s;
 
+    if (sig == NULL && (kinv == NULL || r == NULL)) {
+        *siglen = ECDSA_size(eckey);
+        return 1;
+    }
+
     s = ECDSA_do_sign_ex(dgst, dlen, kinv, r, eckey);
     if (s == NULL) {
         *siglen = 0;
@@ -140,18 +145,18 @@ static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in,
         /* get random k */
         do {
             if (dgst != NULL) {
-                if (!BN_generate_dsa_nonce(k, order, priv_key,
-                                           dgst, dlen, ctx)) {
+                if (!ossl_bn_gen_dsa_nonce_fixed_top(k, order, priv_key,
+                                                     dgst, dlen, ctx)) {
                     ERR_raise(ERR_LIB_EC, EC_R_RANDOM_NUMBER_GENERATION_FAILED);
                     goto err;
                 }
             } else {
-                if (!BN_priv_rand_range_ex(k, order, 0, ctx)) {
+                if (!ossl_bn_priv_rand_range_fixed_top(k, order, 0, ctx)) {
                     ERR_raise(ERR_LIB_EC, EC_R_RANDOM_NUMBER_GENERATION_FAILED);
                     goto err;
                 }
             }
-        } while (BN_is_zero(k));
+        } while (ossl_bn_is_word_fixed_top(k, 0));
 
         /* compute r the x-coordinate of generator * k */
         if (!EC_POINT_mul(group, tmp_point, k, NULL, NULL, ctx)) {
diff --git a/crypto/openssl/crypto/encode_decode/encoder_lib.c b/crypto/openssl/crypto/encode_decode/encoder_lib.c
index 7a55c7ab9a27..a88332b79d52 100644
--- a/crypto/openssl/crypto/encode_decode/encoder_lib.c
+++ b/crypto/openssl/crypto/encode_decode/encoder_lib.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2019-2022 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2019-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -59,6 +59,11 @@ int OSSL_ENCODER_to_bio(OSSL_ENCODER_CTX *ctx, BIO *out)
         return 0;
     }
 
+    if (ctx->cleanup == NULL || ctx->construct == NULL) {
+        ERR_raise(ERR_LIB_OSSL_ENCODER, ERR_R_INIT_FAIL);
+        return 0;
+    }
+
     return encoder_process(&data) > 0;
 }
 
diff --git a/crypto/openssl/crypto/engine/eng_pkey.c b/crypto/openssl/crypto/engine/eng_pkey.c
index f84fcde46016..d18d837e625c 100644
--- a/crypto/openssl/crypto/engine/eng_pkey.c
+++ b/crypto/openssl/crypto/engine/eng_pkey.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2001-2023 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2001-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -79,48 +79,6 @@ EVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id,
         ERR_raise(ERR_LIB_ENGINE, ENGINE_R_FAILED_LOADING_PRIVATE_KEY);
         return NULL;
     }
-    /* We enforce check for legacy key */
-    switch (EVP_PKEY_get_id(pkey)) {
-    case EVP_PKEY_RSA:
-        {
-        RSA *rsa = EVP_PKEY_get1_RSA(pkey);
-        EVP_PKEY_set1_RSA(pkey, rsa);
-        RSA_free(rsa);
-        }
-        break;
-#  ifndef OPENSSL_NO_EC
-    case EVP_PKEY_SM2:
-    case EVP_PKEY_EC:
-        {
-        EC_KEY *ec = EVP_PKEY_get1_EC_KEY(pkey);
-        EVP_PKEY_set1_EC_KEY(pkey, ec);
-        EC_KEY_free(ec);
-        }
-        break;
-#  endif
-#  ifndef OPENSSL_NO_DSA
-    case EVP_PKEY_DSA:
-        {
-        DSA *dsa = EVP_PKEY_get1_DSA(pkey);
-        EVP_PKEY_set1_DSA(pkey, dsa);
-        DSA_free(dsa);
-        }
-        break;
-#endif
-#  ifndef OPENSSL_NO_DH
-    case EVP_PKEY_DH:
-        {
-        DH *dh = EVP_PKEY_get1_DH(pkey);
-        EVP_PKEY_set1_DH(pkey, dh);
-        DH_free(dh);
-        }
-        break;
-#endif
-    default:
-        /*Do nothing */
-        break;
-    }
-
     return pkey;
 }
 
diff --git a/crypto/openssl/crypto/err/openssl.ec b/crypto/openssl/crypto/err/openssl.ec
index 3612c195f09f..f3802a05b5c3 100644
--- a/crypto/openssl/crypto/err/openssl.ec
+++ b/crypto/openssl/crypto/err/openssl.ec
@@ -76,6 +76,6 @@ R SSL_R_TLSV1_CERTIFICATE_UNOBTAINABLE          1111
 R SSL_R_TLSV1_UNRECOGNIZED_NAME                 1112
 R SSL_R_TLSV1_BAD_CERTIFICATE_STATUS_RESPONSE   1113
 R SSL_R_TLSV1_BAD_CERTIFICATE_HASH_VALUE        1114
-R TLS1_AD_UNKNOWN_PSK_IDENTITY                  1115
+R SSL_R_TLSV1_ALERT_UNKNOWN_PSK_IDENTITY        1115
 R SSL_R_TLSV13_ALERT_CERTIFICATE_REQUIRED       1116
-R TLS1_AD_NO_APPLICATION_PROTOCOL               1120
+R SSL_R_TLSV1_ALERT_NO_APPLICATION_PROTOCOL     1120
diff --git a/crypto/openssl/crypto/ess/ess_lib.c b/crypto/openssl/crypto/ess/ess_lib.c
index 65444d383ff4..cd42f951f7b8 100644
--- a/crypto/openssl/crypto/ess/ess_lib.c
+++ b/crypto/openssl/crypto/ess/ess_lib.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2019-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -293,7 +293,7 @@ int OSSL_ESS_check_signing_certs(const ESS_SIGNING_CERT *ss,
     int i, ret;
 
     if (require_signing_cert && ss == NULL && ssv2 == NULL) {
-        ERR_raise(ERR_LIB_CMS, ESS_R_MISSING_SIGNING_CERTIFICATE_ATTRIBUTE);
+        ERR_raise(ERR_LIB_ESS, ESS_R_MISSING_SIGNING_CERTIFICATE_ATTRIBUTE);
         return -1;
     }
     if (n_v1 == 0 || n_v2 == 0) {
diff --git a/crypto/openssl/crypto/evp/keymgmt_lib.c b/crypto/openssl/crypto/evp/keymgmt_lib.c
index 8369d9578cbd..9512cc9cf0f7 100644
--- a/crypto/openssl/crypto/evp/keymgmt_lib.c
+++ b/crypto/openssl/crypto/evp/keymgmt_lib.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2019-2022 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2019-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -243,10 +243,15 @@ OP_CACHE_ELEM *evp_keymgmt_util_find_operation_cache(EVP_PKEY *pk,
     /*
      * A comparison and sk_P_CACHE_ELEM_find() are avoided to not cause
      * problems when we've only a read lock.
+     * A keymgmt is a match if the |keymgmt| pointers are identical or if the
+     * provider and the name ID match
      */
     for (i = 0; i < end; i++) {
         p = sk_OP_CACHE_ELEM_value(pk->operation_cache, i);
-        if (keymgmt == p->keymgmt && (p->selection & selection) == selection)
+        if ((p->selection & selection) == selection
+                && (keymgmt == p->keymgmt
+                    || (keymgmt->name_id == p->keymgmt->name_id
+                        && keymgmt->prov == p->keymgmt->prov)))
             return p;
     }
     return NULL;
diff --git a/crypto/openssl/crypto/evp/p_lib.c b/crypto/openssl/crypto/evp/p_lib.c
index 04b148a91218..6ff7eb7e02cf 100644
--- a/crypto/openssl/crypto/evp/p_lib.c
+++ b/crypto/openssl/crypto/evp/p_lib.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -1902,7 +1902,15 @@ void *evp_pkey_export_to_provider(EVP_PKEY *pk, OSSL_LIB_CTX *libctx,
              * If |tmp_keymgmt| is present in the operation cache, it means
              * that export doesn't need to be redone.  In that case, we take
              * token copies of the cached pointers, to have token success
-             * values to return.
+             * values to return. It is possible (e.g. in a no-cached-fetch
+             * build), for op->keymgmt to be a different pointer to tmp_keymgmt
+             * even though the name/provider must be the same. In other words
+             * the keymgmt instance may be different but still equivalent, i.e.
+             * same algorithm/provider instance - but we make the simplifying
+             * assumption that the keydata can be used with either keymgmt
+             * instance. Not doing so introduces significant complexity and
+             * probably requires refactoring - since we would have to ripple
+             * the change in keymgmt instance up the call chain.
              */
             if (op != NULL && op->keymgmt != NULL) {
                 keydata = op->keydata;
diff --git a/crypto/openssl/crypto/evp/pmeth_lib.c b/crypto/openssl/crypto/evp/pmeth_lib.c
index ba1971ce461d..cffd88725c85 100644
--- a/crypto/openssl/crypto/evp/pmeth_lib.c
+++ b/crypto/openssl/crypto/evp/pmeth_lib.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006-2023 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2006-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -1028,6 +1028,71 @@ static int evp_pkey_ctx_set1_octet_string(EVP_PKEY_CTX *ctx, int fallback,
     return EVP_PKEY_CTX_set_params(ctx, octet_string_params);
 }
 
+static int evp_pkey_ctx_add1_octet_string(EVP_PKEY_CTX *ctx, int fallback,
+                                          const char *param, int op, int ctrl,
+                                          const unsigned char *data,
+                                          int datalen)
+{
+    OSSL_PARAM os_params[2];
+    unsigned char *info = NULL;
+    size_t info_len = 0;
+    size_t info_alloc = 0;
+    int ret = 0;
+
+    if (ctx == NULL || (ctx->operation & op) == 0) {
+        ERR_raise(ERR_LIB_EVP, EVP_R_COMMAND_NOT_SUPPORTED);
+        /* Uses the same return values as EVP_PKEY_CTX_ctrl */
+        return -2;
+    }
+
+    /* Code below to be removed when legacy support is dropped. */
+    if (fallback)
+        return EVP_PKEY_CTX_ctrl(ctx, -1, op, ctrl, datalen, (void *)(data));
+    /* end of legacy support */
+
+    if (datalen < 0) {
+        ERR_raise(ERR_LIB_EVP, EVP_R_INVALID_LENGTH);
+        return 0;
+    } else if (datalen == 0) {
+        return 1;
+    }
+
+    /* Get the original value length */
+    os_params[0] = OSSL_PARAM_construct_octet_string(param, NULL, 0);
+    os_params[1] = OSSL_PARAM_construct_end();
+
+    if (!EVP_PKEY_CTX_get_params(ctx, os_params))
+        return 0;
+
+    /* Older provider that doesn't support getting this parameter */
+    if (os_params[0].return_size == OSSL_PARAM_UNMODIFIED)
+        return evp_pkey_ctx_set1_octet_string(ctx, fallback, param, op, ctrl, data, datalen);
+
+    info_alloc = os_params[0].return_size + datalen;
+    if (info_alloc == 0)
+        return 0;
+    info = OPENSSL_zalloc(info_alloc);
+    if (info == NULL)
+        return 0;
+    info_len = os_params[0].return_size;
+
+    os_params[0] = OSSL_PARAM_construct_octet_string(param, info, info_alloc);
+
+    /* if we have data, then go get it */
+    if (info_len > 0) {
+        if (!EVP_PKEY_CTX_get_params(ctx, os_params))
+            goto error;
+    }
+
+    /* Copy the input data */
+    memcpy(&info[info_len], data, datalen);
+    ret = EVP_PKEY_CTX_set_params(ctx, os_params);
+
+ error:
+    OPENSSL_clear_free(info, info_alloc);
+    return ret;
+}
+
 int EVP_PKEY_CTX_set1_tls1_prf_secret(EVP_PKEY_CTX *ctx,
                                       const unsigned char *sec, int seclen)
 {
@@ -1078,7 +1143,7 @@ int EVP_PKEY_CTX_set1_hkdf_key(EVP_PKEY_CTX *ctx,
 int EVP_PKEY_CTX_add1_hkdf_info(EVP_PKEY_CTX *ctx,
                                       const unsigned char *info, int infolen)
 {
-    return evp_pkey_ctx_set1_octet_string(ctx, ctx->op.kex.algctx == NULL,
+    return evp_pkey_ctx_add1_octet_string(ctx, ctx->op.kex.algctx == NULL,
                                           OSSL_KDF_PARAM_INFO,
                                           EVP_PKEY_OP_DERIVE,
                                           EVP_PKEY_CTRL_HKDF_INFO,
diff --git a/crypto/openssl/crypto/evp/signature.c b/crypto/openssl/crypto/evp/signature.c
index fb269b3bfd07..8adf254d5eec 100644
--- a/crypto/openssl/crypto/evp/signature.c
+++ b/crypto/openssl/crypto/evp/signature.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006-2022 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2006-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -403,8 +403,8 @@ static int evp_pkey_signature_init(EVP_PKEY_CTX *ctx, int operation,
     int iter;
 
     if (ctx == NULL) {
-        ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
-        return -2;
+        ERR_raise(ERR_LIB_EVP, ERR_R_PASSED_NULL_PARAMETER);
+        return -1;
     }
 
     evp_pkey_ctx_free_old_ops(ctx);
@@ -634,8 +634,8 @@ int EVP_PKEY_sign(EVP_PKEY_CTX *ctx,
     int ret;
 
     if (ctx == NULL) {
-        ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
-        return -2;
+        ERR_raise(ERR_LIB_EVP, ERR_R_PASSED_NULL_PARAMETER);
+        return -1;
     }
 
     if (ctx->operation != EVP_PKEY_OP_SIGN) {
@@ -646,6 +646,11 @@ int EVP_PKEY_sign(EVP_PKEY_CTX *ctx,
     if (ctx->op.sig.algctx == NULL)
         goto legacy;
 
+    if (ctx->op.sig.signature->sign == NULL) {
+        ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
+        return -2;
+    }
+
     ret = ctx->op.sig.signature->sign(ctx->op.sig.algctx, sig, siglen,
                                       (sig == NULL) ? 0 : *siglen, tbs, tbslen);
 
@@ -678,8 +683,8 @@ int EVP_PKEY_verify(EVP_PKEY_CTX *ctx,
     int ret;
 
     if (ctx == NULL) {
-        ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
-        return -2;
+        ERR_raise(ERR_LIB_EVP, ERR_R_PASSED_NULL_PARAMETER);
+        return -1;
     }
 
     if (ctx->operation != EVP_PKEY_OP_VERIFY) {
@@ -690,6 +695,11 @@ int EVP_PKEY_verify(EVP_PKEY_CTX *ctx,
     if (ctx->op.sig.algctx == NULL)
         goto legacy;
 
+    if (ctx->op.sig.signature->verify == NULL) {
+        ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
+        return -2;
+    }
+
     ret = ctx->op.sig.signature->verify(ctx->op.sig.algctx, sig, siglen,
                                         tbs, tbslen);
 
@@ -721,8 +731,8 @@ int EVP_PKEY_verify_recover(EVP_PKEY_CTX *ctx,
     int ret;
 
     if (ctx == NULL) {
-        ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
-        return -2;
+        ERR_raise(ERR_LIB_EVP, ERR_R_PASSED_NULL_PARAMETER);
+        return -1;
     }
 
     if (ctx->operation != EVP_PKEY_OP_VERIFYRECOVER) {
@@ -733,6 +743,11 @@ int EVP_PKEY_verify_recover(EVP_PKEY_CTX *ctx,
     if (ctx->op.sig.algctx == NULL)
         goto legacy;
 
+    if (ctx->op.sig.signature->verify_recover == NULL) {
+        ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
+        return -2;
+    }
+
     ret = ctx->op.sig.signature->verify_recover(ctx->op.sig.algctx, rout,
                                                 routlen,
                                                 (rout == NULL ? 0 : *routlen),
diff --git a/crypto/openssl/crypto/init.c b/crypto/openssl/crypto/init.c
index cacf637c89f8..659a660eeced 100644
--- a/crypto/openssl/crypto/init.c
+++ b/crypto/openssl/crypto/init.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016-2022 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2016-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -97,17 +97,19 @@ static int win32atexit(void)
 
 DEFINE_RUN_ONCE_STATIC(ossl_init_register_atexit)
 {
-#ifdef OPENSSL_INIT_DEBUG
+#ifndef OPENSSL_NO_ATEXIT
+# ifdef OPENSSL_INIT_DEBUG
     fprintf(stderr, "OPENSSL_INIT: ossl_init_register_atexit()\n");
-#endif
-#ifndef OPENSSL_SYS_UEFI
-# if defined(_WIN32) && !defined(__BORLANDC__)
+# endif
+# ifndef OPENSSL_SYS_UEFI
+#  if defined(_WIN32) && !defined(__BORLANDC__)
     /* We use _onexit() in preference because it gets called on DLL unload */
     if (_onexit(win32atexit) == NULL)
         return 0;
-# else
+#  else
     if (atexit(OPENSSL_cleanup) != 0)
         return 0;
+#  endif
 # endif
 #endif
 
diff --git a/crypto/openssl/crypto/o_str.c b/crypto/openssl/crypto/o_str.c
index 7fa487dd5fcd..c631f8aff26a 100644
--- a/crypto/openssl/crypto/o_str.c
+++ b/crypto/openssl/crypto/o_str.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2003-2022 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2003-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -251,7 +251,7 @@ static int buf2hexstr_sep(char *str, size_t str_n, size_t *strlength,
     *q = CH_ZERO;
 
 #ifdef CHARSET_EBCDIC
-    ebcdic2ascii(str, str, q - str - 1);
+    ebcdic2ascii(str, str, q - str);
 #endif
     return 1;
 }
diff --git a/crypto/openssl/crypto/property/property_parse.c b/crypto/openssl/crypto/property/property_parse.c
index 19ea39a786eb..45c798f1b50b 100644
--- a/crypto/openssl/crypto/property/property_parse.c
+++ b/crypto/openssl/crypto/property/property_parse.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2019-2023 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2019-2024 The OpenSSL Project Authors. All Rights Reserved.
  * Copyright (c) 2019, Oracle and/or its affiliates.  All rights reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
@@ -14,6 +14,7 @@
 #include <openssl/err.h>
 #include "internal/propertyerr.h"
 #include "internal/property.h"
+#include "internal/numbers.h"
 #include "crypto/ctype.h"
 #include "internal/nelem.h"
 #include "property_local.h"
diff --git a/crypto/openssl/crypto/provider_core.c b/crypto/openssl/crypto/provider_core.c
index 4cadb6a9f02e..cb4233eb52fd 100644
--- a/crypto/openssl/crypto/provider_core.c
+++ b/crypto/openssl/crypto/provider_core.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2019-2023 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2019-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -567,8 +567,15 @@ OSSL_PROVIDER *ossl_provider_new(OSSL_LIB_CTX *libctx, const char *name,
     }
 
     /* provider_new() generates an error, so no need here */
-    if ((prov = provider_new(name, template.init, template.parameters)) == NULL)
+    prov = provider_new(name, template.init, template.parameters);
+
+    if (prov == NULL)
+        return NULL;
+
+    if (!ossl_provider_set_module_path(prov, template.path)) {
+        ossl_provider_free(prov);
         return NULL;
+    }
 
     prov->libctx = libctx;
 #ifndef FIPS_MODULE
diff --git a/crypto/openssl/crypto/sha/build.info b/crypto/openssl/crypto/sha/build.info
index d61f7de9b6bd..186ec13cc82a 100644
--- a/crypto/openssl/crypto/sha/build.info
+++ b/crypto/openssl/crypto/sha/build.info
@@ -88,7 +88,7 @@ DEFINE[../../providers/libdefault.a]=$SHA1DEF $KECCAK1600DEF
 # linked with libcrypto.  Otherwise, it already gets everything that
 # the static libcrypto.a has, and doesn't need it added again.
 IF[{- !$disabled{module} && !$disabled{shared} -}]
-  DEFINE[../providers/liblegacy.a]=$SHA1DEF $KECCAK1600DEF
+  DEFINE[../../providers/liblegacy.a]=$SHA1DEF $KECCAK1600DEF
 ENDIF
 
 GENERATE[sha1-586.S]=asm/sha1-586.pl
diff --git a/crypto/openssl/crypto/sm2/sm2_crypt.c b/crypto/openssl/crypto/sm2/sm2_crypt.c
index 5318c6199f68..ff8171e39280 100644
--- a/crypto/openssl/crypto/sm2/sm2_crypt.c
+++ b/crypto/openssl/crypto/sm2/sm2_crypt.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017-2021 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2017-2024 The OpenSSL Project Authors. All Rights Reserved.
  * Copyright 2017 Ribose Inc. All Rights Reserved.
  * Ported from Ribose contributions from Botan.
  *
@@ -67,6 +67,18 @@ static size_t ec_field_size(const EC_GROUP *group)
     return field_size;
 }
 
+static int is_all_zeros(const unsigned char *msg, size_t msglen)
+{
+    unsigned char re = 0;
+    size_t i;
+
+    for (i = 0; i < msglen; i++) {
+        re |= msg[i];
+    }
+
+    return re == 0 ? 1 : 0;
+}
+
 int ossl_sm2_plaintext_size(const unsigned char *ct, size_t ct_size,
                             size_t *pt_size)
 {
@@ -179,6 +191,13 @@ int ossl_sm2_encrypt(const EC_KEY *key,
 
     memset(ciphertext_buf, 0, *ciphertext_len);
 
+    msg_mask = OPENSSL_zalloc(msg_len);
+    if (msg_mask == NULL) {
+       ERR_raise(ERR_LIB_SM2, ERR_R_MALLOC_FAILURE);
+       goto done;
+    }
+
+again:
     if (!BN_priv_rand_range_ex(k, order, 0, ctx)) {
         ERR_raise(ERR_LIB_SM2, ERR_R_INTERNAL_ERROR);
         goto done;
@@ -198,12 +217,6 @@ int ossl_sm2_encrypt(const EC_KEY *key,
         goto done;
     }
 
-    msg_mask = OPENSSL_zalloc(msg_len);
-    if (msg_mask == NULL) {
-       ERR_raise(ERR_LIB_SM2, ERR_R_MALLOC_FAILURE);
-       goto done;
-   }
-
     /* X9.63 with no salt happens to match the KDF used in SM2 */
     if (!ossl_ecdh_kdf_X9_63(msg_mask, msg_len, x2y2, 2 * field_size, NULL, 0,
                              digest, libctx, propq)) {
@@ -211,6 +224,11 @@ int ossl_sm2_encrypt(const EC_KEY *key,
         goto done;
     }
 
+    if (is_all_zeros(msg_mask, msg_len)) {
+        memset(x2y2, 0, 2 * field_size);
+        goto again;
+    }
+
     for (i = 0; i != msg_len; ++i)
         msg_mask[i] ^= msg[i];
 
@@ -364,6 +382,11 @@ int ossl_sm2_decrypt(const EC_KEY *key,
         goto done;
     }
 
+    if (is_all_zeros(msg_mask, msg_len)) {
+        ERR_raise(ERR_LIB_SM2, SM2_R_INVALID_ENCODING);
+        goto done;
+    }
+
     for (i = 0; i != msg_len; ++i)
         ptext_buf[i] = C2[i] ^ msg_mask[i];
 
diff --git a/crypto/openssl/crypto/sm2/sm2_sign.c b/crypto/openssl/crypto/sm2/sm2_sign.c
index ff5be9b73e9f..71ccfcfc4c3d 100644
--- a/crypto/openssl/crypto/sm2/sm2_sign.c
+++ b/crypto/openssl/crypto/sm2/sm2_sign.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017-2023 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2017-2024 The OpenSSL Project Authors. All Rights Reserved.
  * Copyright 2017 Ribose Inc. All Rights Reserved.
  * Ported from Ribose contributions from Botan.
  *
@@ -29,6 +29,7 @@ int ossl_sm2_compute_z_digest(uint8_t *out,
 {
     int rc = 0;
     const EC_GROUP *group = EC_KEY_get0_group(key);
+    const EC_POINT *pubkey = EC_KEY_get0_public_key(key);
     BN_CTX *ctx = NULL;
     EVP_MD_CTX *hash = NULL;
     BIGNUM *p = NULL;
@@ -43,6 +44,12 @@ int ossl_sm2_compute_z_digest(uint8_t *out,
     uint16_t entl = 0;
     uint8_t e_byte = 0;
 
+    /* SM2 Signatures require a public key, check for it */
+    if (pubkey == NULL) {
+        ERR_raise(ERR_LIB_SM2, ERR_R_PASSED_NULL_PARAMETER);
+        goto done;
+    }
+
     hash = EVP_MD_CTX_new();
     ctx = BN_CTX_new_ex(ossl_ec_key_get_libctx(key));
     if (hash == NULL || ctx == NULL) {
@@ -118,7 +125,7 @@ int ossl_sm2_compute_z_digest(uint8_t *out,
             || BN_bn2binpad(yG, buf, p_bytes) < 0
             || !EVP_DigestUpdate(hash, buf, p_bytes)
             || !EC_POINT_get_affine_coordinates(group,
-                                                EC_KEY_get0_public_key(key),
+                                                pubkey,
                                                 xA, yA, ctx)
             || BN_bn2binpad(xA, buf, p_bytes) < 0
             || !EVP_DigestUpdate(hash, buf, p_bytes)
@@ -442,6 +449,11 @@ int ossl_sm2_internal_sign(const unsigned char *dgst, int dgstlen,
     int sigleni;
     int ret = -1;
 
+    if (sig == NULL) {
+        ERR_raise(ERR_LIB_SM2, ERR_R_PASSED_NULL_PARAMETER);
+        goto done;
+    }
+
     e = BN_bin2bn(dgst, dgstlen, NULL);
     if (e == NULL) {
        ERR_raise(ERR_LIB_SM2, ERR_R_BN_LIB);
@@ -454,7 +466,7 @@ int ossl_sm2_internal_sign(const unsigned char *dgst, int dgstlen,
         goto done;
     }
 
-    sigleni = i2d_ECDSA_SIG(s, sig != NULL ? &sig : NULL);
+    sigleni = i2d_ECDSA_SIG(s, &sig);
     if (sigleni < 0) {
        ERR_raise(ERR_LIB_SM2, ERR_R_INTERNAL_ERROR);
        goto done;
diff --git a/crypto/openssl/crypto/x509/v3_addr.c b/crypto/openssl/crypto/x509/v3_addr.c
index 4930f3312422..20f3d2ba70de 100644
--- a/crypto/openssl/crypto/x509/v3_addr.c
+++ b/crypto/openssl/crypto/x509/v3_addr.c
@@ -397,11 +397,11 @@ static int make_addressPrefix(IPAddressOrRange **result, unsigned char *addr,
                               const int prefixlen, const int afilen)
 {
     int bytelen = (prefixlen + 7) / 8, bitlen = prefixlen % 8;
-    IPAddressOrRange *aor = IPAddressOrRange_new();
+    IPAddressOrRange *aor;
 
     if (prefixlen < 0 || prefixlen > (afilen * 8))
         return 0;
-    if (aor == NULL)
+    if ((aor = IPAddressOrRange_new()) == NULL)
         return 0;
     aor->type = IPAddressOrRange_addressPrefix;
     if (aor->u.addressPrefix == NULL &&
diff --git a/crypto/openssl/demos/digest/EVP_MD_demo.c b/crypto/openssl/demos/digest/EVP_MD_demo.c
index 99589bd3446b..79e585d0ba4f 100644
--- a/crypto/openssl/demos/digest/EVP_MD_demo.c
+++ b/crypto/openssl/demos/digest/EVP_MD_demo.c
@@ -1,5 +1,5 @@
 /*-
- * Copyright 2021 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2021-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -83,7 +83,7 @@ int demonstrate_digest(void)
     const char *option_properties = NULL;
     EVP_MD *message_digest = NULL;
     EVP_MD_CTX *digest_context = NULL;
-    unsigned int digest_length;
+    int digest_length;
     unsigned char *digest_value = NULL;
     int j;
 
diff --git a/crypto/openssl/demos/digest/EVP_MD_stdin.c b/crypto/openssl/demos/digest/EVP_MD_stdin.c
index 71a3d325a364..47e6b523857c 100644
--- a/crypto/openssl/demos/digest/EVP_MD_stdin.c
+++ b/crypto/openssl/demos/digest/EVP_MD_stdin.c
@@ -1,5 +1,5 @@
 /*-
- * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2019-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -38,7 +38,7 @@ int demonstrate_digest(BIO *input)
     const char * option_properties = NULL;
     EVP_MD *message_digest = NULL;
     EVP_MD_CTX *digest_context = NULL;
-    unsigned int digest_length;
+    int digest_length;
     unsigned char *digest_value = NULL;
     unsigned char buffer[512];
     int ii;
diff --git a/crypto/openssl/doc/fingerprints.txt b/crypto/openssl/doc/fingerprints.txt
index 9a26f7c66722..9613cbac9848 100644
--- a/crypto/openssl/doc/fingerprints.txt
+++ b/crypto/openssl/doc/fingerprints.txt
@@ -15,6 +15,9 @@ currently in use to sign OpenSSL distributions:
 OpenSSL OMC:
 EFC0 A467 D613 CB83 C7ED 6D30 D894 E2CE 8B3D 79F5
 
+OpenSSL:
+BA54 73A2 B058 7B07 FB27 CF2D 2160 94DF D0CB 81EF
+
 Richard Levitte:
 7953 AC1F BC3D C8B3 B292 393E D5E9 E43F 7DF9 EE8C
 
diff --git a/crypto/openssl/doc/internal/man3/OPTIONS.pod b/crypto/openssl/doc/internal/man3/OPTIONS.pod
index 90593ca46f6f..dbdd39a2ee64 100644
--- a/crypto/openssl/doc/internal/man3/OPTIONS.pod
+++ b/crypto/openssl/doc/internal/man3/OPTIONS.pod
@@ -155,7 +155,7 @@ on multiple lines; each entry should use B<OPT_MORE_STR>, like this:
         {OPT_MORE_STR, 0, 0,
          "This flag is not really needed on Unix systems"},
         {OPT_MORE_STR, 0, 0,
-         "(Unix and descendents for ths win!)"}
+         "(Unix and descendents for the win!)"}
 
 Each subsequent line will be indented the correct amount.
 
@@ -333,7 +333,7 @@ things very differently.
 
 =head1 COPYRIGHT
 
-Copyright 2021 The OpenSSL Project Authors. All Rights Reserved.
+Copyright 2021-2024 The OpenSSL Project Authors. All Rights Reserved.
 
 Licensed under the Apache License 2.0 (the "License").  You may not use this
 file except in compliance with the License.  You can obtain a copy in the file
diff --git a/crypto/openssl/doc/internal/man3/ossl_method_construct.pod b/crypto/openssl/doc/internal/man3/ossl_method_construct.pod
index 3683798b06b4..422d7a5b6850 100644
--- a/crypto/openssl/doc/internal/man3/ossl_method_construct.pod
+++ b/crypto/openssl/doc/internal/man3/ossl_method_construct.pod
@@ -93,7 +93,7 @@ This default store should be stored in the library context I<libctx>.
 The method to be looked up should be identified with data found in I<data>
 (which is the I<mcm_data> that was passed to ossl_construct_method()).
 In other words, the ossl_method_construct() caller is entirely responsible
-for ensuring the necesssary data is made available.
+for ensuring the necessary data is made available.
 
 Optionally, I<prov> may be given as a search criterion, to narrow down the
 search of a method belonging to just one provider.
@@ -148,7 +148,7 @@ This functionality was added to OpenSSL 3.0.
 
 =head1 COPYRIGHT
 
-Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
+Copyright 2019-2024 The OpenSSL Project Authors. All Rights Reserved.
 
 Licensed under the Apache License 2.0 (the "License").  You may not use this
 file except in compliance with the License.  You can obtain a copy in the file
diff --git a/crypto/openssl/doc/internal/man3/ossl_provider_new.pod b/crypto/openssl/doc/internal/man3/ossl_provider_new.pod
index 8bd5594c484c..193472462b38 100644
--- a/crypto/openssl/doc/internal/man3/ossl_provider_new.pod
+++ b/crypto/openssl/doc/internal/man3/ossl_provider_new.pod
@@ -297,7 +297,7 @@ in a bitstring that's internal to I<provider>.
 
 ossl_provider_test_operation_bit() checks if the bit operation I<bitnum>
 is set (1) or not (0) in the internal I<provider> bitstring, and sets
-I<*result> to 1 or 0 accorddingly.
+I<*result> to 1 or 0 accordingly.
 
 ossl_provider_init_as_child() stores in the library context I<ctx> references to
 the necessary upcalls for managing child providers. The I<handle> and I<in>
@@ -390,7 +390,7 @@ The functions described here were all added in OpenSSL 3.0.
 
 =head1 COPYRIGHT
 
-Copyright 2019-2022 The OpenSSL Project Authors. All Rights Reserved.
+Copyright 2019-2024 The OpenSSL Project Authors. All Rights Reserved.
 
 Licensed under the Apache License 2.0 (the "License").  You may not use
 this file except in compliance with the License.  You can obtain a copy
diff --git a/crypto/openssl/doc/internal/man3/ossl_random_add_conf_module.pod b/crypto/openssl/doc/internal/man3/ossl_random_add_conf_module.pod
index 6d4f5810dcdd..a3c1285fe01b 100644
--- a/crypto/openssl/doc/internal/man3/ossl_random_add_conf_module.pod
+++ b/crypto/openssl/doc/internal/man3/ossl_random_add_conf_module.pod
@@ -15,7 +15,7 @@ ossl_random_add_conf_module - internal random configuration module
 
 ossl_random_add_conf_module() adds the random configuration module
 for providers.
-This allows the type and parameters of the stardard setup of random number
+This allows the type and parameters of the standard setup of random number
 generators to be configured with an OpenSSL L<config(5)> file.
 
 =head1 RETURN VALUES
@@ -32,7 +32,7 @@ The functions described here were all added in OpenSSL 3.0.
 
 =head1 COPYRIGHT
 
-Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
+Copyright 2020-2024 The OpenSSL Project Authors. All Rights Reserved.
 
 Licensed under the Apache License 2.0 (the "License").  You may not use
 this file except in compliance with the License.  You can obtain a copy
diff --git a/crypto/openssl/doc/internal/man7/EVP_PKEY.pod b/crypto/openssl/doc/internal/man7/EVP_PKEY.pod
index cc738b9c28eb..3dc10fa4104c 100644
--- a/crypto/openssl/doc/internal/man7/EVP_PKEY.pod
+++ b/crypto/openssl/doc/internal/man7/EVP_PKEY.pod
@@ -19,7 +19,7 @@ private/public key pairs, but has had other uses as well.
 
 =for comment "uses" could as well be "abuses"...
 
-The private/public key pair that an B<EVP_PKEY> contains is refered to
+The private/public key pair that an B<EVP_PKEY> contains is referred to
 as its "internal key" or "origin" (the reason for "origin" is
 explained further down, in L</Export cache for provider operations>),
 and it can take one of the following forms:
@@ -202,7 +202,7 @@ L<provider-keymgmt(7)>
 
 =head1 COPYRIGHT
 
-Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved.
+Copyright 2020-2024 The OpenSSL Project Authors. All Rights Reserved.
 
 Licensed under the Apache License 2.0 (the "License").  You may not use
 this file except in compliance with the License.  You can obtain a copy
diff --git a/crypto/openssl/doc/man1/openssl-crl.pod.in b/crypto/openssl/doc/man1/openssl-crl.pod.in
index 7e15f6445a6f..5ace18f5807f 100644
--- a/crypto/openssl/doc/man1/openssl-crl.pod.in
+++ b/crypto/openssl/doc/man1/openssl-crl.pod.in
@@ -95,6 +95,9 @@ Print out the CRL in text form.
 
 Verify the signature in the CRL.
 
+This option is implicitly enabled if any of B<-CApath>, B<-CAfile>
+or B<-CAstore> is specified.
+
 =item B<-noout>
 
 Don't output the encoded version of the CRL.
@@ -162,7 +165,7 @@ L<ossl_store-file(7)>
 
 =head1 COPYRIGHT
 
-Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
+Copyright 2000-2024 The OpenSSL Project Authors. All Rights Reserved.
 
 Licensed under the Apache License 2.0 (the "License").  You may not use
 this file except in compliance with the License.  You can obtain a copy
diff --git a/crypto/openssl/doc/man1/openssl-mac.pod.in b/crypto/openssl/doc/man1/openssl-mac.pod.in
index 563974799109..5ed979697381 100644
--- a/crypto/openssl/doc/man1/openssl-mac.pod.in
+++ b/crypto/openssl/doc/man1/openssl-mac.pod.in
@@ -123,26 +123,31 @@ To see the list of supported MAC's use the command C<openssl list
 
 =head1 EXAMPLES
 
-To create a hex-encoded HMAC-SHA1 MAC of a file and write to stdout: \
+To create a hex-encoded HMAC-SHA1 MAC of a file and write to stdout:
+
  openssl mac -digest SHA1 \
          -macopt hexkey:000102030405060708090A0B0C0D0E0F10111213 \
          -in msg.bin HMAC
 
-To create a SipHash MAC from a file with a binary file output: \
+To create a SipHash MAC from a file with a binary file output:
+
  openssl mac -macopt hexkey:000102030405060708090A0B0C0D0E0F \
          -in msg.bin -out out.bin -binary SipHash
 
-To create a hex-encoded CMAC-AES-128-CBC MAC from a file:\
+To create a hex-encoded CMAC-AES-128-CBC MAC from a file:
+
  openssl mac -cipher AES-128-CBC \
          -macopt hexkey:77A77FAF290C1FA30C683DF16BA7A77B \
          -in msg.bin CMAC
 
 To create a hex-encoded KMAC128 MAC from a file with a Customisation String
-'Tag' and output length of 16: \
+'Tag' and output length of 16:
+
  openssl mac -macopt custom:Tag -macopt hexkey:40414243444546 \
          -macopt size:16 -in msg.bin KMAC128
 
-To create a hex-encoded GMAC-AES-128-GCM with a IV from a file: \
+To create a hex-encoded GMAC-AES-128-GCM with a IV from a file:
+
  openssl mac -cipher AES-128-GCM -macopt hexiv:E0E00F19FED7BA0136A797F3 \
          -macopt hexkey:77A77FAF290C1FA30C683DF16BA7A77B -in msg.bin GMAC
 
@@ -165,7 +170,7 @@ L<EVP_MAC-Poly1305(7)>
 
 =head1 COPYRIGHT
 
-Copyright 2018-2022 The OpenSSL Project Authors. All Rights Reserved.
+Copyright 2018-2024 The OpenSSL Project Authors. All Rights Reserved.
 
 Licensed under the Apache License 2.0 (the "License").  You may not use
 this file except in compliance with the License.  You can obtain a copy
diff --git a/crypto/openssl/doc/man1/openssl-req.pod.in b/crypto/openssl/doc/man1/openssl-req.pod.in
index 31fd71418773..a56f548de8ee 100644
--- a/crypto/openssl/doc/man1/openssl-req.pod.in
+++ b/crypto/openssl/doc/man1/openssl-req.pod.in
@@ -472,16 +472,29 @@ any digest that has been set.
 =item B<string_mask>
 
 This option masks out the use of certain string types in certain
-fields. Most users will not need to change this option.
+fields. Most users will not need to change this option. It can be set to
+several values:
 
-It can be set to several values B<default> which is also the default
-option uses PrintableStrings, T61Strings and BMPStrings if the
-B<pkix> value is used then only PrintableStrings and BMPStrings will
-be used. This follows the PKIX recommendation in RFC2459. If the
-B<utf8only> option is used then only UTF8Strings will be used: this
-is the PKIX recommendation in RFC2459 after 2003. Finally the B<nombstr>
-option just uses PrintableStrings and T61Strings: certain software has
-problems with BMPStrings and UTF8Strings: in particular Netscape.
+=over 4
+
+=item B<utf8only>
+- only UTF8Strings are used (this is the default value)
+
+=item B<pkix>
+- any string type except T61Strings
+
+=item B<nombstr>
+- any string type except BMPStrings and UTF8Strings
+
+=item B<default>
+- any kind of string type
+
+=back
+
+Note that B<utf8only> is the PKIX recommendation in RFC2459 after 2003, and the
+default B<string_mask>; B<default> is not the default option. The B<nombstr>
+value is a workaround for some software that has problems with variable-sized
+BMPStrings and UTF8Strings.
 
 =item B<req_extensions>
 
@@ -765,7 +778,7 @@ The <-nodes> option was deprecated in OpenSSL 3.0, too; use B<-noenc> instead.
 
 =head1 COPYRIGHT
 
-Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
+Copyright 2000-2024 The OpenSSL Project Authors. All Rights Reserved.
 
 Licensed under the Apache License 2.0 (the "License").  You may not use
 this file except in compliance with the License.  You can obtain a copy
diff --git a/crypto/openssl/doc/man1/openssl-smime.pod.in b/crypto/openssl/doc/man1/openssl-smime.pod.in
index e438c866c383..0b5dbb5df8f7 100644
--- a/crypto/openssl/doc/man1/openssl-smime.pod.in
+++ b/crypto/openssl/doc/man1/openssl-smime.pod.in
@@ -195,14 +195,14 @@ Don't try to verify the signatures on the message.
 
 =item B<-nocerts>
 
-When signing a message the signer's certificate is normally included
-with this option it is excluded. This will reduce the size of the
-signed message but the verifier must have a copy of the signers certificate
+When signing a message, the signer's certificate is normally included.
+With this option it is excluded. This will reduce the size of the
+signed message, but the verifier must have a copy of the signers certificate
 available locally (passed using the B<-certfile> option for example).
 
 =item B<-noattr>
 
-Normally when a message is signed a set of attributes are included which
+Normally, when a message is signed, a set of attributes are included which
 include the signing time and supported symmetric algorithms. With this
 option they are not included.
 
@@ -243,14 +243,6 @@ used multiple times if more than one signer is required. If a message is being
 verified then the signers certificates will be written to this file if the
 verification was successful.
 
-=item B<-nocerts>
-
-Don't include signers certificate when signing.
-
-=item B<-noattr>
-
-Don't include any signed attributes when signing.
-
 =item B<-recip> I<file>
 
 The recipients certificate when decrypting a message. This certificate
@@ -482,7 +474,7 @@ The B<-engine> option was deprecated in OpenSSL 3.0.
 
 =head1 COPYRIGHT
 
-Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
+Copyright 2000-2024 The OpenSSL Project Authors. All Rights Reserved.
 
 Licensed under the Apache License 2.0 (the "License").  You may not use
 this file except in compliance with the License.  You can obtain a copy
diff --git a/crypto/openssl/doc/man1/openssl-storeutl.pod.in b/crypto/openssl/doc/man1/openssl-storeutl.pod.in
index 26d5ee28e647..2b619d7c356e 100644
--- a/crypto/openssl/doc/man1/openssl-storeutl.pod.in
+++ b/crypto/openssl/doc/man1/openssl-storeutl.pod.in
@@ -79,6 +79,9 @@ returned.
 Note that all options must be given before the I<uri> argument.
 Otherwise they are ignored.
 
+Note I<-keys> selects exclusively private keys, there is no selector for public
+keys only.
+
 =item B<-subject> I<arg>
 
 Search for an object having the subject name I<arg>.
@@ -137,7 +140,7 @@ The B<-engine> option was deprecated in OpenSSL 3.0.
 
 =head1 COPYRIGHT
 
-Copyright 2016-2023 The OpenSSL Project Authors. All Rights Reserved.
+Copyright 2016-2024 The OpenSSL Project Authors. All Rights Reserved.
 
 Licensed under the Apache License 2.0 (the "License").  You may not use
 this file except in compliance with the License.  You can obtain a copy
diff --git a/crypto/openssl/doc/man1/openssl-ts.pod.in b/crypto/openssl/doc/man1/openssl-ts.pod.in
index 3e7f7c4be94b..5f4895b34d6c 100644
--- a/crypto/openssl/doc/man1/openssl-ts.pod.in
+++ b/crypto/openssl/doc/man1/openssl-ts.pod.in
@@ -163,9 +163,9 @@ use its own default policy. (Optional)
 =item B<-no_nonce>
 
 No nonce is specified in the request if this option is
-given. Otherwise a 64 bit long pseudo-random none is
-included in the request. It is recommended to use nonce to
-protect against replay-attacks. (Optional)
+given. Otherwise, a 64-bit long pseudo-random nonce is
+included in the request. It is recommended to use a nonce to
+protect against replay attacks. (Optional)
 
 =item B<-cert>
 
@@ -652,7 +652,7 @@ L<ossl_store-file(7)>
 
 =head1 COPYRIGHT
 
-Copyright 2006-2023 The OpenSSL Project Authors. All Rights Reserved.
+Copyright 2006-2024 The OpenSSL Project Authors. All Rights Reserved.
 
 Licensed under the Apache License 2.0 (the "License").  You may not use
 this file except in compliance with the License.  You can obtain a copy
diff --git a/crypto/openssl/doc/man3/DEFINE_STACK_OF.pod b/crypto/openssl/doc/man3/DEFINE_STACK_OF.pod
index 0775214fb5d7..3ebd473afcb2 100644
--- a/crypto/openssl/doc/man3/DEFINE_STACK_OF.pod
+++ b/crypto/openssl/doc/man3/DEFINE_STACK_OF.pod
@@ -41,8 +41,8 @@ OPENSSL_sk_unshift, OPENSSL_sk_value, OPENSSL_sk_zero
  STACK_OF(TYPE) *sk_TYPE_new(sk_TYPE_compfunc compare);
  STACK_OF(TYPE) *sk_TYPE_new_null(void);
  int sk_TYPE_reserve(STACK_OF(TYPE) *sk, int n);
- void sk_TYPE_free(const STACK_OF(TYPE) *sk);
- void sk_TYPE_zero(const STACK_OF(TYPE) *sk);
+ void sk_TYPE_free(STACK_OF(TYPE) *sk);
+ void sk_TYPE_zero(STACK_OF(TYPE) *sk);
  TYPE *sk_TYPE_delete(STACK_OF(TYPE) *sk, int i);
  TYPE *sk_TYPE_delete_ptr(STACK_OF(TYPE) *sk, TYPE *ptr);
  int sk_TYPE_push(STACK_OF(TYPE) *sk, const TYPE *ptr);
@@ -297,7 +297,7 @@ B<sk_I<TYPE>_reserve>() and B<sk_I<TYPE>_new_reserve>() were added in OpenSSL
 
 =head1 COPYRIGHT
 
-Copyright 2000-2022 The OpenSSL Project Authors. All Rights Reserved.
+Copyright 2000-2024 The OpenSSL Project Authors. All Rights Reserved.
 
 Licensed under the Apache License 2.0 (the "License").  You may not use
 this file except in compliance with the License.  You can obtain a copy
diff --git a/crypto/openssl/doc/man3/EVP_DigestInit.pod b/crypto/openssl/doc/man3/EVP_DigestInit.pod
index 1953df3c5e8d..d7202c538172 100644
--- a/crypto/openssl/doc/man3/EVP_DigestInit.pod
+++ b/crypto/openssl/doc/man3/EVP_DigestInit.pod
@@ -483,7 +483,7 @@ EVP_MD_CTX_get_params() can be used with the following OSSL_PARAM keys:
 
 =over 4
 
-=item "micalg" (B<OSSL_PARAM_DIGEST_KEY_MICALG>) <UTF8 string>.
+=item "micalg" (B<OSSL_DIGEST_PARAM_MICALG>) <UTF8 string>.
 
 Gets the digest Message Integrity Check algorithm string. This is used when
 creating S/MIME multipart/signed messages, as specified in RFC 3851.
@@ -784,7 +784,7 @@ in OpenSSL 3.0.
 
 =head1 COPYRIGHT
 
-Copyright 2000-2023 The OpenSSL Project Authors. All Rights Reserved.
+Copyright 2000-2024 The OpenSSL Project Authors. All Rights Reserved.
 
 Licensed under the Apache License 2.0 (the "License").  You may not use
 this file except in compliance with the License.  You can obtain a copy
diff --git a/crypto/openssl/doc/man3/EVP_KDF.pod b/crypto/openssl/doc/man3/EVP_KDF.pod
index 31d61b2a3df0..9447651a340e 100644
--- a/crypto/openssl/doc/man3/EVP_KDF.pod
+++ b/crypto/openssl/doc/man3/EVP_KDF.pod
@@ -20,7 +20,7 @@ EVP_KDF_CTX_gettable_params, EVP_KDF_CTX_settable_params - EVP KDF routines
  typedef struct evp_kdf_st EVP_KDF;
  typedef struct evp_kdf_ctx_st EVP_KDF_CTX;
 
- EVP_KDF_CTX *EVP_KDF_CTX_new(const EVP_KDF *kdf);
+ EVP_KDF_CTX *EVP_KDF_CTX_new(EVP_KDF *kdf);
  const EVP_KDF *EVP_KDF_CTX_kdf(EVP_KDF_CTX *ctx);
  void EVP_KDF_CTX_free(EVP_KDF_CTX *ctx);
  EVP_KDF_CTX *EVP_KDF_CTX_dup(const EVP_KDF_CTX *src);
@@ -304,7 +304,7 @@ This functionality was added in OpenSSL 3.0.
 
 =head1 COPYRIGHT
 
-Copyright 2019-2023 The OpenSSL Project Authors. All Rights Reserved.
+Copyright 2019-2024 The OpenSSL Project Authors. All Rights Reserved.
 
 Licensed under the Apache License 2.0 (the "License").  You may not use
 this file except in compliance with the License.  You can obtain a copy
diff --git a/crypto/openssl/doc/man3/EVP_PKEY_CTX_set_params.pod b/crypto/openssl/doc/man3/EVP_PKEY_CTX_set_params.pod
index c02151654c3a..8947648ccbe6 100644
--- a/crypto/openssl/doc/man3/EVP_PKEY_CTX_set_params.pod
+++ b/crypto/openssl/doc/man3/EVP_PKEY_CTX_set_params.pod
@@ -23,7 +23,9 @@ The EVP_PKEY_CTX_get_params() and EVP_PKEY_CTX_set_params() functions allow
 transfer of arbitrary key parameters to and from providers.
 Not all parameters may be supported by all providers.
 See L<OSSL_PROVIDER(3)> for more information on providers.
-See L<OSSL_PARAM(3)> for more information on parameters.
+The I<params> field is a pointer to a list of B<OSSL_PARAM> structures,
+terminated with a L<OSSL_PARAM_END(3)> struct.
+See L<OSSL_PARAM(3)> for information about passing parameters.
 These functions must only be called after the EVP_PKEY_CTX has been initialised
 for use in an operation.
 These methods replace the EVP_PKEY_CTX_ctrl() mechanism. (EVP_PKEY_CTX_ctrl now
@@ -84,7 +86,7 @@ All functions were added in OpenSSL 3.0.
 
 =head1 COPYRIGHT
 
-Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved.
+Copyright 2020-2024 The OpenSSL Project Authors. All Rights Reserved.
 
 Licensed under the Apache License 2.0 (the "License").  You may not use
 this file except in compliance with the License.  You can obtain a copy
diff --git a/crypto/openssl/doc/man3/EVP_PKEY_check.pod b/crypto/openssl/doc/man3/EVP_PKEY_check.pod
index a16fdbbd508f..04751f0bd5c7 100644
--- a/crypto/openssl/doc/man3/EVP_PKEY_check.pod
+++ b/crypto/openssl/doc/man3/EVP_PKEY_check.pod
@@ -61,6 +61,11 @@ It is not necessary to call these functions after locally calling an approved ke
 generation method, but may be required for assurance purposes when receiving
 keys from a third party.
 
+The EVP_PKEY_pairwise_check() and EVP_PKEY_private_check() might not be bounded
+by any key size limits as private keys are not expected to be supplied by
+attackers. For that reason they might take an unbounded time if run on
+arbitrarily large keys.
+
 =head1 RETURN VALUES
 
 All functions return 1 for success or others for failure.
@@ -86,7 +91,7 @@ EVP_PKEY_private_check() and EVP_PKEY_pairwise_check() were added in OpenSSL 3.0
 
 =head1 COPYRIGHT
 
-Copyright 2006-2022 The OpenSSL Project Authors. All Rights Reserved.
+Copyright 2006-2024 The OpenSSL Project Authors. All Rights Reserved.
 
 Licensed under the Apache License 2.0 (the "License").  You may not use
 this file except in compliance with the License.  You can obtain a copy
diff --git a/crypto/openssl/doc/man3/SSL_CIPHER_get_name.pod b/crypto/openssl/doc/man3/SSL_CIPHER_get_name.pod
index e22a85a06370..09b7280bdd58 100644
--- a/crypto/openssl/doc/man3/SSL_CIPHER_get_name.pod
+++ b/crypto/openssl/doc/man3/SSL_CIPHER_get_name.pod
@@ -109,7 +109,7 @@ cipher B<c>.
 
 SSL_CIPHER_description() returns a textual description of the cipher used
 into the buffer B<buf> of length B<len> provided.  If B<buf> is provided, it
-must be at least 128 bytes, otherwise a buffer will be allocated using
+must be at least 128 bytes. If B<buf> is NULL it will be allocated using
 OPENSSL_malloc().  If the provided buffer is too small, or the allocation fails,
 B<NULL> is returned.
 
@@ -203,7 +203,7 @@ The OPENSSL_cipher_name() function was added in OpenSSL 1.1.1.
 
 =head1 COPYRIGHT
 
-Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
+Copyright 2000-2024 The OpenSSL Project Authors. All Rights Reserved.
 
 Licensed under the Apache License 2.0 (the "License").  You may not use
 this file except in compliance with the License.  You can obtain a copy
diff --git a/crypto/openssl/doc/man3/SSL_CTX_set_cert_store.pod b/crypto/openssl/doc/man3/SSL_CTX_set_cert_store.pod
index f1fef9e649cd..246f413136b6 100644
--- a/crypto/openssl/doc/man3/SSL_CTX_set_cert_store.pod
+++ b/crypto/openssl/doc/man3/SSL_CTX_set_cert_store.pod
@@ -16,7 +16,9 @@ SSL_CTX_set_cert_store, SSL_CTX_set1_cert_store, SSL_CTX_get_cert_store - manipu
 
 SSL_CTX_set_cert_store() sets/replaces the certificate verification storage
 of B<ctx> to/with B<store>. If another X509_STORE object is currently
-set in B<ctx>, it will be X509_STORE_free()ed.
+set in B<ctx>, it will be X509_STORE_free()ed. SSL_CTX_set_cert_store() will
+take ownership of the B<store>, i.e., the call C<X509_STORE_free(store)> is no
+longer needed.
 
 SSL_CTX_set1_cert_store() sets/replaces the certificate verification storage
 of B<ctx> to/with B<store>. The B<store>'s reference count is incremented.
@@ -79,7 +81,7 @@ L<SSL_CTX_set_verify(3)>
 
 =head1 COPYRIGHT
 
-Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved.
+Copyright 2001-2024 The OpenSSL Project Authors. All Rights Reserved.
 
 Licensed under the Apache License 2.0 (the "License").  You may not use
 this file except in compliance with the License.  You can obtain a copy
diff --git a/crypto/openssl/doc/man3/SSL_CTX_set_verify.pod b/crypto/openssl/doc/man3/SSL_CTX_set_verify.pod
index 9d4abac30eba..346aa8452974 100644
--- a/crypto/openssl/doc/man3/SSL_CTX_set_verify.pod
+++ b/crypto/openssl/doc/man3/SSL_CTX_set_verify.pod
@@ -144,6 +144,9 @@ B<Client mode:> ignored (see BUGS)
 
 If the B<mode> is SSL_VERIFY_NONE none of the other flags may be set.
 
+If verification flags are not modified explicitly by C<SSL_CTX_set_verify()>
+or C<SSL_set_verify()>, the default value will be SSL_VERIFY_NONE.
+
 The actual verification procedure is performed either using the built-in
 verification procedure or using another application provided verification
 function set with
@@ -363,7 +366,7 @@ and SSL_set_post_handshake_auth() functions were added in OpenSSL 1.1.1.
 
 =head1 COPYRIGHT
 
-Copyright 2000-2022 The OpenSSL Project Authors. All Rights Reserved.
+Copyright 2000-2024 The OpenSSL Project Authors. All Rights Reserved.
 
 Licensed under the Apache License 2.0 (the "License").  You may not use
 this file except in compliance with the License.  You can obtain a copy
diff --git a/crypto/openssl/doc/man3/SSL_CTX_use_certificate.pod b/crypto/openssl/doc/man3/SSL_CTX_use_certificate.pod
index ca1827dada8a..dd6f831b8658 100644
--- a/crypto/openssl/doc/man3/SSL_CTX_use_certificate.pod
+++ b/crypto/openssl/doc/man3/SSL_CTX_use_certificate.pod
@@ -68,7 +68,7 @@ SSL_use_certificate() loads B<x> into B<ssl>. The rest of the
 certificates needed to form the complete certificate chain can be
 specified using the
 L<SSL_CTX_add_extra_chain_cert(3)>
-function.
+function. On success the reference counter of the B<x> is incremented.
 
 SSL_CTX_use_certificate_ASN1() loads the ASN1 encoded certificate from
 the memory location B<d> (with length B<len>) into B<ctx>,
@@ -97,6 +97,7 @@ to the certificate an error is returned. To change a [certificate/private-key]
 pair, the new certificate needs to be set first with SSL_use_certificate() or
 SSL_CTX_use_certificate() before setting the private key with
 SSL_CTX_use_PrivateKey() or SSL_use_PrivateKey().
+On success the reference counter of the B<pkey>/B<rsa> is incremented.
 
 SSL_CTX_use_cert_and_key() and SSL_use_cert_and_key() assign the X.509
 certificate B<x>, private key B<key>, and certificate B<chain> onto the
@@ -195,7 +196,7 @@ L<SSL_CTX_add_extra_chain_cert(3)>
 
 =head1 COPYRIGHT
 
-Copyright 2000-2022 The OpenSSL Project Authors. All Rights Reserved.
+Copyright 2000-2024 The OpenSSL Project Authors. All Rights Reserved.
 
 Licensed under the Apache License 2.0 (the "License").  You may not use
 this file except in compliance with the License.  You can obtain a copy
diff --git a/crypto/openssl/doc/man3/SSL_load_client_CA_file.pod b/crypto/openssl/doc/man3/SSL_load_client_CA_file.pod
index 988c7e893407..08a6c15e46d9 100644
--- a/crypto/openssl/doc/man3/SSL_load_client_CA_file.pod
+++ b/crypto/openssl/doc/man3/SSL_load_client_CA_file.pod
@@ -54,7 +54,8 @@ it is not limited to CA certificates.
 
 =head1 RETURN VALUES
 
-The following return values can occur:
+The following return values can occur for SSL_load_client_CA_file_ex(), and
+SSL_load_client_CA_file():
 
 =over 4
 
@@ -68,6 +69,21 @@ Pointer to the subject names of the successfully read certificates.
 
 =back
 
+The following return values can occur for SSL_add_file_cert_subjects_to_stack(),
+SSL_add_dir_cert_subjects_to_stack(), and SSL_add_store_cert_subjects_to_stack():
+
+=over 4
+
+=item 0 (Failure)
+
+The operation failed.
+
+=item 1 (Success)
+
+The operation succeeded.
+
+=back
+
 =head1 EXAMPLES
 
 Load names of CAs from file and use it as a client CA list:
@@ -96,7 +112,7 @@ were added in OpenSSL 3.0.
 
 =head1 COPYRIGHT
 
-Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
+Copyright 2000-2024 The OpenSSL Project Authors. All Rights Reserved.
 
 Licensed under the Apache License 2.0 (the "License").  You may not use
 this file except in compliance with the License.  You can obtain a copy
diff --git a/crypto/openssl/doc/man7/EVP_PKEY-SM2.pod b/crypto/openssl/doc/man7/EVP_PKEY-SM2.pod
index 8bdc506cec21..28a0e995d5d1 100644
--- a/crypto/openssl/doc/man7/EVP_PKEY-SM2.pod
+++ b/crypto/openssl/doc/man7/EVP_PKEY-SM2.pod
@@ -38,6 +38,9 @@ Getter that returns the default digest name.
 B<SM2> signatures can be generated by using the 'DigestSign' series of APIs, for
 instance, EVP_DigestSignInit(), EVP_DigestSignUpdate() and EVP_DigestSignFinal().
 Ditto for the verification process by calling the 'DigestVerify' series of APIs.
+Note that the SM2 algorithm requires the presence of the public key for signatures,
+as such the B<OSSL_PKEY_PARAM_PUB_KEY> option must be set on any key used in signature
+generation.
 
 Before computing an B<SM2> signature, an B<EVP_PKEY_CTX> needs to be created,
 and an B<SM2> ID must be set for it, like this:
@@ -84,7 +87,7 @@ L<EVP_MD_CTX_set_pkey_ctx(3)>
 
 =head1 COPYRIGHT
 
-Copyright 2018-2021 The OpenSSL Project Authors. All Rights Reserved.
+Copyright 2018-2024 The OpenSSL Project Authors. All Rights Reserved.
 
 Licensed under the Apache License 2.0 (the "License").  You may not use
 this file except in compliance with the License.  You can obtain a copy
diff --git a/crypto/openssl/doc/man7/migration_guide.pod b/crypto/openssl/doc/man7/migration_guide.pod
index 61641324a7fc..e5ab29b95370 100644
--- a/crypto/openssl/doc/man7/migration_guide.pod
+++ b/crypto/openssl/doc/man7/migration_guide.pod
@@ -136,6 +136,14 @@ To ensure the future compatibility, the engines should be turned to providers.
 To prefer the provider-based hardware offload, you can specify the default
 properties to prefer your provider.
 
+Setting engine-based or application-based default low-level crypto method such
+as B<RSA_METHOD> or B<EC_KEY_METHOD> is still possible and keys inside the
+default provider will use the engine-based implementation for the crypto
+operations. However B<EVP_PKEY>s created by decoding by using B<OSSL_DECODER>,
+B<PEM_> or B<d2i_> APIs will be provider-based. To create a fully legacy
+B<EVP_PKEY>s L<EVP_PKEY_set1_RSA(3)>, L<EVP_PKEY_set1_EC_KEY(3)> or similar
+functions must be used.
+
 =head3 Versioning Scheme
 
 The OpenSSL versioning scheme has changed with the OpenSSL 3.0 release. The new
@@ -1298,7 +1306,7 @@ d2i_DSAPrivateKey_bio(), d2i_DSAPrivateKey_fp(), d2i_DSA_PUBKEY(),
 d2i_DSA_PUBKEY_bio(), d2i_DSA_PUBKEY_fp(), d2i_DSAPublicKey(),
 d2i_ECParameters(), d2i_ECPrivateKey(), d2i_ECPrivateKey_bio(),
 d2i_ECPrivateKey_fp(), d2i_EC_PUBKEY(), d2i_EC_PUBKEY_bio(),
-d2i_EC_PUBKEY_fp(), o2i_ECPublicKey(), d2i_RSAPrivateKey(),
+d2i_EC_PUBKEY_fp(), d2i_RSAPrivateKey(),
 d2i_RSAPrivateKey_bio(), d2i_RSAPrivateKey_fp(), d2i_RSA_PUBKEY(),
 d2i_RSA_PUBKEY_bio(), d2i_RSA_PUBKEY_fp(), d2i_RSAPublicKey(),
 d2i_RSAPublicKey_bio(), d2i_RSAPublicKey_fp()
@@ -1307,6 +1315,13 @@ See L</Deprecated i2d and d2i functions for low-level key types>
 
 =item *
 
+o2i_ECPublicKey()
+
+Use L<EVP_PKEY_set1_encoded_public_key(3)>.
+See L</Deprecated low-level key parameter setters>
+
+=item *
+
 DES_crypt(), DES_fcrypt(), DES_encrypt1(), DES_encrypt2(), DES_encrypt3(),
 DES_decrypt3(), DES_ede3_cbc_encrypt(), DES_ede3_cfb64_encrypt(),
 DES_ede3_cfb_encrypt(),DES_ede3_ofb64_encrypt(),
@@ -1857,13 +1872,20 @@ and L<d2i_RSAPrivateKey(3)/Migration>
 
 i2d_ECParameters(), i2d_ECPrivateKey(), i2d_ECPrivateKey_bio(),
 i2d_ECPrivateKey_fp(), i2d_EC_PUBKEY(), i2d_EC_PUBKEY_bio(),
-i2d_EC_PUBKEY_fp(), i2o_ECPublicKey()
+i2d_EC_PUBKEY_fp()
 
 See L</Deprecated low-level key reading and writing functions>
 and L<d2i_RSAPrivateKey(3)/Migration>
 
 =item *
 
+i2o_ECPublicKey()
+
+Use L<EVP_PKEY_get1_encoded_public_key(3)>.
+See L</Deprecated low-level key parameter getters>
+
+=item *
+
 i2d_RSAPrivateKey(), i2d_RSAPrivateKey_bio(), i2d_RSAPrivateKey_fp(),
 i2d_RSA_PUBKEY(), i2d_RSA_PUBKEY_bio(), i2d_RSA_PUBKEY_fp(),
 i2d_RSAPublicKey(), i2d_RSAPublicKey_bio(), i2d_RSAPublicKey_fp()
@@ -2462,7 +2484,7 @@ The migration guide was created for OpenSSL 3.0.
 
 =head1 COPYRIGHT
 
-Copyright 2021-2023 The OpenSSL Project Authors. All Rights Reserved.
+Copyright 2021-2024 The OpenSSL Project Authors. All Rights Reserved.
 
 Licensed under the Apache License 2.0 (the "License").  You may not use
 this file except in compliance with the License.  You can obtain a copy
diff --git a/crypto/openssl/e_os.h b/crypto/openssl/e_os.h
index db05b7f8150f..72eab92eeb4b 100644
--- a/crypto/openssl/e_os.h
+++ b/crypto/openssl/e_os.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -296,20 +296,18 @@ static ossl_inline void ossl_sleep(unsigned long millis)
     ts.tv_sec = (long int) (millis / 1000);
     ts.tv_nsec = (long int) (millis % 1000) * 1000000ul;
     nanosleep(&ts, NULL);
-# elif defined(__TANDEM)
-#  if !defined(_REENTRANT)
+# elif defined(__TANDEM) && !defined(_REENTRANT)
 #   include <cextdecs.h(PROCESS_DELAY_)>
+
     /* HPNS does not support usleep for non threaded apps */
     PROCESS_DELAY_(millis * 1000);
-#  elif defined(_SPT_MODEL_)
-#   include <spthread.h>
-#   include <spt_extensions.h>
-    usleep(millis * 1000);
-#  else
-    usleep(millis * 1000);
-#  endif
 # else
-    usleep(millis * 1000);
+    unsigned int s = (unsigned int)(millis / 1000);
+    unsigned int us = (unsigned int)((millis % 1000) * 1000);
+
+    if (s > 0)
+        sleep(s);
+    usleep(us);
 # endif
 }
 #elif defined(_WIN32)
diff --git a/crypto/openssl/engines/e_afalg.c b/crypto/openssl/engines/e_afalg.c
index 2c08cbb28dde..ec4e21c582c8 100644
--- a/crypto/openssl/engines/e_afalg.c
+++ b/crypto/openssl/engines/e_afalg.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2016-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -811,8 +811,10 @@ static int bind_helper(ENGINE *e, const char *id)
     if (!afalg_chk_platform())
         return 0;
 
-    if (!bind_afalg(e))
+    if (!bind_afalg(e)) {
+        afalg_destroy(e);
         return 0;
+    }
     return 1;
 }
 
diff --git a/crypto/openssl/engines/e_dasync.c b/crypto/openssl/engines/e_dasync.c
index 7974106ae219..329d618f5552 100644
--- a/crypto/openssl/engines/e_dasync.c
+++ b/crypto/openssl/engines/e_dasync.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2015-2021 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2015-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -985,7 +985,7 @@ static int dasync_rsa_decrypt(EVP_PKEY_CTX *ctx, unsigned char *out,
                              size_t inlen);
 
     if (pdecrypt == NULL)
-        EVP_PKEY_meth_get_encrypt(dasync_rsa_orig, NULL, &pdecrypt);
+        EVP_PKEY_meth_get_decrypt(dasync_rsa_orig, NULL, &pdecrypt);
     return pdecrypt(ctx, out, outlen, in, inlen);
 }
 
diff --git a/crypto/openssl/fuzz/asn1.c b/crypto/openssl/fuzz/asn1.c
index ee602a08a3d9..f7a019774b9d 100644
--- a/crypto/openssl/fuzz/asn1.c
+++ b/crypto/openssl/fuzz/asn1.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016-2022 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2016-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -312,10 +312,16 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
         ASN1_VALUE *o = ASN1_item_d2i(NULL, &b, len, i);
 
         if (o != NULL) {
-            BIO *bio = BIO_new(BIO_s_null());
-            if (bio != NULL) {
-                ASN1_item_print(bio, o, 4, i, pctx);
-                BIO_free(bio);
+            /*
+             * Don't print excessively long output to prevent spurious fuzzer
+             * timeouts.
+             */
+            if (b - buf < 10000) {
+                BIO *bio = BIO_new(BIO_s_null());
+                if (bio != NULL) {
+                    ASN1_item_print(bio, o, 4, i, pctx);
+                    BIO_free(bio);
+                }
             }
             if (ASN1_item_i2d(o, &der, i) > 0) {
                 OPENSSL_free(der);
diff --git a/crypto/openssl/include/crypto/bn.h b/crypto/openssl/include/crypto/bn.h
index fd1c09d997de..4cc23bd146fe 100644
--- a/crypto/openssl/include/crypto/bn.h
+++ b/crypto/openssl/include/crypto/bn.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2014-2023 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2014-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -87,6 +87,14 @@ int bn_lshift_fixed_top(BIGNUM *r, const BIGNUM *a, int n);
 int bn_rshift_fixed_top(BIGNUM *r, const BIGNUM *a, int n);
 int bn_div_fixed_top(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,
                      const BIGNUM *d, BN_CTX *ctx);
+int ossl_bn_mask_bits_fixed_top(BIGNUM *a, int n);
+int ossl_bn_is_word_fixed_top(const BIGNUM *a, BN_ULONG w);
+int ossl_bn_priv_rand_range_fixed_top(BIGNUM *r, const BIGNUM *range,
+                                      unsigned int strength, BN_CTX *ctx);
+int ossl_bn_gen_dsa_nonce_fixed_top(BIGNUM *out, const BIGNUM *range,
+                                    const BIGNUM *priv,
+                                    const unsigned char *message,
+                                    size_t message_len, BN_CTX *ctx);
 
 #define BN_PRIMETEST_COMPOSITE                    0
 #define BN_PRIMETEST_COMPOSITE_WITH_FACTOR        1
diff --git a/crypto/openssl/include/internal/constant_time.h b/crypto/openssl/include/internal/constant_time.h
index 0ed6f823c11e..2b49afe1ea2a 100644
--- a/crypto/openssl/include/internal/constant_time.h
+++ b/crypto/openssl/include/internal/constant_time.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2014-2021 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2014-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -140,6 +140,29 @@ static ossl_inline uint64_t constant_time_lt_64(uint64_t a, uint64_t b)
     return constant_time_msb_64(a ^ ((a ^ b) | ((a - b) ^ b)));
 }
 
+#ifdef BN_ULONG
+static ossl_inline BN_ULONG constant_time_msb_bn(BN_ULONG a)
+{
+    return 0 - (a >> (sizeof(a) * 8 - 1));
+}
+
+static ossl_inline BN_ULONG constant_time_lt_bn(BN_ULONG a, BN_ULONG b)
+{
+    return constant_time_msb_bn(a ^ ((a ^ b) | ((a - b) ^ b)));
+}
+
+static ossl_inline BN_ULONG constant_time_is_zero_bn(BN_ULONG a)
+{
+    return constant_time_msb_bn(~a & (a - 1));
+}
+
+static ossl_inline BN_ULONG constant_time_eq_bn(BN_ULONG a,
+                                                BN_ULONG b)
+{
+    return constant_time_is_zero_bn(a ^ b);
+}
+#endif
+
 static ossl_inline unsigned int constant_time_ge(unsigned int a,
                                                  unsigned int b)
 {
diff --git a/crypto/openssl/include/openssl/opensslv.h b/crypto/openssl/include/openssl/opensslv.h
index 012d77ee8bd0..537144b32e97 100644
--- a/crypto/openssl/include/openssl/opensslv.h
+++ b/crypto/openssl/include/openssl/opensslv.h
@@ -29,7 +29,7 @@ extern "C" {
  */
 # define OPENSSL_VERSION_MAJOR  3
 # define OPENSSL_VERSION_MINOR  0
-# define OPENSSL_VERSION_PATCH  13
+# define OPENSSL_VERSION_PATCH  14
 
 /*
  * Additional version information
@@ -74,21 +74,21 @@ extern "C" {
  * longer variant with OPENSSL_VERSION_PRE_RELEASE_STR and
  * OPENSSL_VERSION_BUILD_METADATA_STR appended.
  */
-# define OPENSSL_VERSION_STR "3.0.13"
-# define OPENSSL_FULL_VERSION_STR "3.0.13"
+# define OPENSSL_VERSION_STR "3.0.14"
+# define OPENSSL_FULL_VERSION_STR "3.0.14"
 
 /*
  * SECTION 3: ADDITIONAL METADATA
  *
  * These strings are defined separately to allow them to be parsable.
  */
-# define OPENSSL_RELEASE_DATE "30 Jan 2024"
+# define OPENSSL_RELEASE_DATE "4 Jun 2024"
 
 /*
  * SECTION 4: BACKWARD COMPATIBILITY
  */
 
-# define OPENSSL_VERSION_TEXT "OpenSSL 3.0.13 30 Jan 2024"
+# define OPENSSL_VERSION_TEXT "OpenSSL 3.0.14 4 Jun 2024"
 
 /* Synthesize OPENSSL_VERSION_NUMBER with the layout 0xMNN00PPSL */
 # ifdef OPENSSL_VERSION_PRE_RELEASE
diff --git a/crypto/openssl/include/openssl/sslerr.h b/crypto/openssl/include/openssl/sslerr.h
index b156fc2ffd7b..1e36405e32c0 100644
--- a/crypto/openssl/include/openssl/sslerr.h
+++ b/crypto/openssl/include/openssl/sslerr.h
@@ -1,6 +1,6 @@
 /*
  * Generated by util/mkerr.pl DO NOT EDIT
- * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -283,10 +283,12 @@
 # define SSL_R_TLSV1_ALERT_INAPPROPRIATE_FALLBACK         1086
 # define SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY          1071
 # define SSL_R_TLSV1_ALERT_INTERNAL_ERROR                 1080
+# define SSL_R_TLSV1_ALERT_NO_APPLICATION_PROTOCOL        1120
 # define SSL_R_TLSV1_ALERT_NO_RENEGOTIATION               1100
 # define SSL_R_TLSV1_ALERT_PROTOCOL_VERSION               1070
 # define SSL_R_TLSV1_ALERT_RECORD_OVERFLOW                1022
 # define SSL_R_TLSV1_ALERT_UNKNOWN_CA                     1048
+# define SSL_R_TLSV1_ALERT_UNKNOWN_PSK_IDENTITY           1115
 # define SSL_R_TLSV1_ALERT_USER_CANCELLED                 1090
 # define SSL_R_TLSV1_BAD_CERTIFICATE_HASH_VALUE           1114
 # define SSL_R_TLSV1_BAD_CERTIFICATE_STATUS_RESPONSE      1113
diff --git a/crypto/openssl/os-dep/Apple/PrivacyInfo.xcprivacy b/crypto/openssl/os-dep/Apple/PrivacyInfo.xcprivacy
new file mode 100644
index 000000000000..285dd5bebae8
--- /dev/null
+++ b/crypto/openssl/os-dep/Apple/PrivacyInfo.xcprivacy
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>NSPrivacyAccessedAPITypes</key>
+	<array>
+		<dict>
+			<key>NSPrivacyAccessedAPIType</key>
+			<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
+			<key>NSPrivacyAccessedAPITypeReasons</key>
+			<array>
+				<string>C617.1</string>
+			</array>
+		</dict>
+	</array>
+	<key>NSPrivacyCollectedDataTypes</key>
+	<array/>
+	<key>NSPrivacyTrackingDomains</key>
+	<array/>
+	<key>NSPrivacyTracking</key>
+	<false/>
+</dict>
+</plist>
diff --git a/crypto/openssl/providers/fips-sources.checksums b/crypto/openssl/providers/fips-sources.checksums
index c45b03060675..1a6e37329763 100644
--- a/crypto/openssl/providers/fips-sources.checksums
+++ b/crypto/openssl/providers/fips-sources.checksums
@@ -4,71 +4,71 @@ c049a936d74100fcced225f575d46662792a6a0039777d2d4df0cf61eff90a68  crypto/aes/aes
 c1e674d08683a25bc053f6233f73a0d0b3a90aafe591ff57b702c7da1582e4a5  crypto/aes/aes_local.h
 a2466f18da5847c7d9fbced17524633c10ce024671a72f53f9c9c55b9b9923dd  crypto/aes/aes_misc.c
 6979c133f76f4623e62e6e970deae70fa025e713a72b71aead5a048d49e47f6f  crypto/aes/asm/aes-586.pl
-92be9ff608331a432e95247a8f4fb9e46897d0cb76f2b6db809b61d44287964a  crypto/aes/asm/aes-armv4.pl
-953897f86e2de9fa27ef411155ab3aed133af94885f1507e76449c142da78656  crypto/aes/asm/aes-c64xplus.pl
+2eef5f20f1410b48bdaaafa24ded24f56f34c4ca79db1d38fa6bf1b3b19535bf  crypto/aes/asm/aes-armv4.pl
+38c2cf8ed3910efd89d8721e1b0763a8fde073b91f6529d251165a0496ef9555  crypto/aes/asm/aes-c64xplus.pl
 00196f01f5218ad731e6a058d406078f7228a9756d9d73f51c0d0c2a68f885af  crypto/aes/asm/aes-ia64.S
-88b6f8396cd9d86004743d5c3b0f72b7b8c3d5a2b00b0bbb761ba91ae5a7cdc8  crypto/aes/asm/aes-mips.pl
-7ff9c96ef3d591d45d776fa4b244601ea0d9328e289aeab1e1b92436ce7d02ad  crypto/aes/asm/aes-parisc.pl
-f1244cdeadcb4e48f35bc5df19d4cfaf07e0086ad951b84f07ff6966501faa5b  crypto/aes/asm/aes-ppc.pl
-ecbfe826f4c514810c3ee20e265f4f621149694c298554b2682e5de4f029f14f  crypto/aes/asm/aes-s390x.pl
-ee4e8cacef972942d2a89c1a83c984df9cad87c61a54383403c5c4864c403ba1  crypto/aes/asm/aes-sparcv9.pl
-2b3b9ac56bf54334d053857a24bdb08592151e8a7a60b89b8195846b7f8ee7b5  crypto/aes/asm/aes-x86_64.pl
-c56c324667b67d726e040d70379efba5b270e2937f403c1b5979018b836903c7  crypto/aes/asm/aesfx-sparcv9.pl
-14359dc32b7f4e5c08227fb9ac8f9232c1287399463b233fec4a2ab0c19f68d1  crypto/aes/asm/aesni-mb-x86_64.pl
-2fe016e8098d1c959b6199ce98e91dfed9a3a543d6b068daf88d4c4c402701ec  crypto/aes/asm/aesni-sha1-x86_64.pl
-1d3acabadedb88d1327eeb76201ea9b3f4814f44898018ffae6c73e3f400b89b  crypto/aes/asm/aesni-sha256-x86_64.pl
+b4ef595194fe1692e1ab2b561f385da01b277cf004902e8fc99e8ac5389bbd35  crypto/aes/asm/aes-mips.pl
+123c4498c94040b70708fdd911cb08c6411b020b4cf3eb761d6fa22c583c3e6f  crypto/aes/asm/aes-parisc.pl
+7a7f2f90791415ef4ffc1ba2a6f6b6fe994bfe0e03d3bf9dab6e428e6874695c  crypto/aes/asm/aes-ppc.pl
+d139e5ad69560fd0ffd8aa2e72304e463650cea4c657be7a90e0d1eb782d580a  crypto/aes/asm/aes-s390x.pl
+133ba35d77002abcd430414749c4e98c4a319630da898e45ff8dbc5800176df1  crypto/aes/asm/aes-sparcv9.pl
+c98690249d490d23e6fee84f672f1463ffc029427110a4329244a59e4e4aaed8  crypto/aes/asm/aes-x86_64.pl
+7ec99947b47e56595f0b085b8bda0b3113112f694e78b1f71b63ecd1f0fa2c67  crypto/aes/asm/aesfx-sparcv9.pl
+ab94a27e533e164bcf09898a6f6019f43609d51a3b374cf75482dcf2914d464e  crypto/aes/asm/aesni-mb-x86_64.pl
+74939261340a0056eb9333fff1c843c8758b9f93de3d94650cd6d2899c6790d8  crypto/aes/asm/aesni-sha1-x86_64.pl
+ce91f0893a2a35fdf4c024ccb0fd8329b30fdbd955f0ae011ab948101ee14951  crypto/aes/asm/aesni-sha256-x86_64.pl
 4ff74d4e629a88ef5a9e3d3f5b340fc0a4793d16d7cc7f1b70da62512a856248  crypto/aes/asm/aesni-x86.pl
-c7c6694480bb5319690f94826139a93f5c460ebea6dba101b520a76cb956ec93  crypto/aes/asm/aesni-x86_64.pl
-f3a8f3c960c0f47aaa8fc2633d18b14e7c7feeccc536b0115a08bc58333122b6  crypto/aes/asm/aesp8-ppc.pl
-e397a5781893e97dd90a5a52049633be12a43f379ec5751bca2a6350c39444c8  crypto/aes/asm/aest4-sparcv9.pl
-e3955352a92d56905d63e68937e4758f13190a14a10a3dcb1e5c641c49913c0c  crypto/aes/asm/aesv8-armx.pl
-5e8005fdb6641df465bdda20c3476f7176e6bcd63d5073044a0c02a327c7f172  crypto/aes/asm/bsaes-armv7.pl
-0726a2c4c15c27a12b2f7d5e16863df4a1b1daa7b7d9b728f621b2b224d290e6  crypto/aes/asm/bsaes-x86_64.pl
-1ff94d6bf6c8ae4809f64657eb89260fe3cb22137f649d3c73f72cb190258196  crypto/aes/asm/vpaes-armv8.pl
-c3541865cd02d81101cdbab4877ed82772e6980d2c677b9008b38fa1b26d36d4  crypto/aes/asm/vpaes-ppc.pl
+30103cfe3b29d06b34feff48a927e0fa649e9109d35a3db64b09cfeb15426fa2  crypto/aes/asm/aesni-x86_64.pl
+67c73dbf78b5f3c8a436800dc43bf122cd1f0c4fefab357359edaae4fbb27e8e  crypto/aes/asm/aesp8-ppc.pl
+a5807ed92ec8a16d123061487c385bf1f65e50878cee95c8e8096844454129f8  crypto/aes/asm/aest4-sparcv9.pl
+d34cf129a8c63e2b77a74117ed4440a4f35408dabd90e21e70eae92d208fa516  crypto/aes/asm/aesv8-armx.pl
+a0b578b7d2787c91013547df07dfa73d8d7a420446dd624c66f7c55159817eb2  crypto/aes/asm/bsaes-armv7.pl
+34accd08242a6bf4a751105f89b0c4de2cd7e54320753587815647abff7124de  crypto/aes/asm/bsaes-x86_64.pl
+d9bc047db9b2f54f27fe0d6e2ede9239b4a1f57a14bf89fa3cfba6b836599386  crypto/aes/asm/vpaes-armv8.pl
+516421b1a321b842f879ad69e7b82ae3e1f3efc8288c83bb34d6577996e85787  crypto/aes/asm/vpaes-ppc.pl
 3ec24185750a995377516bc2fb2eae8b1c52094c6fff093bff591837fc12d6c3  crypto/aes/asm/vpaes-x86.pl
-060bb6620f50af9afecdf97df051b45b9a50be9daf343dfec1cbb29693ce00a4  crypto/aes/asm/vpaes-x86_64.pl
-2bc67270155e2d6c7da87d9070e005ee79cea18311004907edfd6a078003532a  crypto/alphacpuid.pl
-0255a480b78bdcc71f76676f496962a9828eb900f53b7be13be96ae3f67fe6db  crypto/arm64cpuid.pl
+47bedbe6a04254eede121e71f11a657b1f1940aee1916bbfc04fa9fb8454f9b8  crypto/aes/asm/vpaes-x86_64.pl
+1c9a2a0e8cee4a1283c74b2e306f46f79890f6d236394de2a80d1994fd411d1d  crypto/alphacpuid.pl
+7a37cadacdbecb50304228dfcb087ad7fbb6e31f6ab69c52dd161e79afb2f9ca  crypto/arm64cpuid.pl
 e0daf54f72dd8fd1bc537d93f34e2a6a887a9ed6027bb33e15a327ef5ff37a42  crypto/armcap.c
-a43f2c1eef16146943745f684f2add7d186924932a47abf7fb0760cba02804e6  crypto/armv4cpuid.pl
+24cc7611225df0e20e414c14e80516c36d48bf99659946e85a876d8757356686  crypto/armv4cpuid.pl
 16739d54200fb81ca7835b5814f965022a2ab41589c7787e2697e3ea72d4fafa  crypto/asn1_dsa.c
-819c9fd2b0cae9aab81c3cbd1815c2e22949d75f132f649b5883812d0bbaa39a  crypto/bn/asm/alpha-mont.pl
-0070595128b250b9ebdebe48ce53d2d27ca16ec4f7c6c8bd169ab2e4a913b2d1  crypto/bn/asm/armv4-gf2m.pl
-8c1c53a725b8a4f92b8a353bfeeb393be94198df41c912e3270f9e654417b250  crypto/bn/asm/armv4-mont.pl
-8d6192337fedb0012764229d600634f8357c3b74fd38bcbfe8b86ddc6ca96ea2  crypto/bn/asm/armv8-mont.pl
+155eff9d747eed808398cfa2af4b276dfc1f9aac8a0f9d801b314ab3f2bf5b56  crypto/bn/asm/alpha-mont.pl
+894cc71b2d783e4e1b54dbef45e9e9280165a2c43981ebdd03282f0e90914928  crypto/bn/asm/armv4-gf2m.pl
+0d2e31dc9cdce02c619adfc9ac720ccf7171384e76a84cdf0e686a805dd7006e  crypto/bn/asm/armv4-mont.pl
+d7df31176f725c1ae7241fee8f681fdcf2ab9eb4d3cc6c80d49c2248ae40a56a  crypto/bn/asm/armv8-mont.pl
 cb4ad7b7461fcb8e2a0d52881158d0211b79544842d4eae36fc566869a2d62c8  crypto/bn/asm/bn-586.pl
-636da7e2a66272a81f9c99e90b36c6f132ad6236c739e8b9f2e7315f30b72edd  crypto/bn/asm/c64xplus-gf2m.pl
+10fb73a6cc1bc064ebdcf6d7fe3c7407ea1c28b0d65ad0123046f8b1518fa75a  crypto/bn/asm/c64xplus-gf2m.pl
 c86664fb974362ee52a454c83c2c4b23fd5b7d64b3c9e23ef1e0dfd130a46ee5  crypto/bn/asm/co-586.pl
-199b9b100f194a2a128c14f2a71be5a04d50d069666d90ca5b69baee1318ccb7  crypto/bn/asm/ia64-mont.pl
+b88190d748056e6a64988bf1a3d19efc4c292e3d338a65f4505cf769a2041077  crypto/bn/asm/ia64-mont.pl
 a511aafbf76647a0c83705d4491c898a5584d300aa449fa6166c8803372946eb  crypto/bn/asm/ia64.S
-687c5d6606fdfd0e242005972d15db74a9cbac2b8a9a54a56fcb1e99d3880ff3  crypto/bn/asm/mips-mont.pl
-8aca83d2ec45a40af15e59cff1ac2dc33737a3d25f0a0b74d401fa778a5c5eb8  crypto/bn/asm/mips.pl
-b27ec5181e387e812925bb26823b830f49d7a6e4971b6d11ea583f5632a1504b  crypto/bn/asm/parisc-mont.pl
-9973523b361db963eea4938a7a8a3adc692e1a4e1aec4fa1f1e57dc93da37921  crypto/bn/asm/ppc-mont.pl
-59cd27e1e10c4984b7fb684b27f491e7634473b1bcff197a07e0ca653124aa9a  crypto/bn/asm/ppc.pl
+fee42cabeeb87cdf0fa0a6ff3698b2fe98a8a47d10a756052df572097161a8b9  crypto/bn/asm/mips-mont.pl
+b197a8e1be79b8c21f8d26b34b9a282ca42ec4bcd1f3212fde3889747082a1f7  crypto/bn/asm/mips.pl
+13df09cee06a21669137294f92e5c31b4bf05a8035be6800c1cb4403d7cd8290  crypto/bn/asm/parisc-mont.pl
+25c96e545b4981d45557eb14ea5c83aa2d6375ae0df806cb6e6ded2f59ddfed3  crypto/bn/asm/ppc-mont.pl
+1c057083546fa1a3bb1b9819dc5110f5a3b11b7bf5a2fb275012323bd7412403  crypto/bn/asm/ppc.pl
 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855  crypto/bn/asm/ppc64-mont-fixed.pl
-a25be64867ab837d93855af232e2bfa71b85b2c6f00e35e620fdc5618187fb6f  crypto/bn/asm/ppc64-mont.pl
-231579e532443665020d4d522d9f11713d9c5d5c814b95b434b0f65452e16de4  crypto/bn/asm/rsaz-avx2.pl
-1657600d320ea549b527b2d878a7658533d60d26eeb38f42ea470fc612f9bb53  crypto/bn/asm/rsaz-avx512.pl
-31e84dc905b13e38850071528d3abbfcaf8910bbc8b46f38d19c2b386a5f838e  crypto/bn/asm/rsaz-x86_64.pl
-30fedf48dfc5fec1c2044b6c226dd9fc42a92522cc589797a23a79d452bdd2cf  crypto/bn/asm/s390x-gf2m.pl
-590388d69d7ac3a0e9af4014792f4f0fdb9552719e8fb48ebc7e5dfca2a491d4  crypto/bn/asm/s390x-mont.pl
+fe9278a2504fb40257637a4718081775c29c4eb81f87a8528e5c85f8d0c6281a  crypto/bn/asm/ppc64-mont.pl
+94b2d5cf0faf2efddeb5fb7c575dabc35c1791715cc9299d59a01d9f96cb2d6f  crypto/bn/asm/rsaz-avx2.pl
+cd0861a565231f67252e172420f6914fe47a324b35916c29f6304491447fe84c  crypto/bn/asm/rsaz-avx512.pl
+c19c717d87dd1ba74f138af05c044c05f5d025e26323637f46ba54a8c871a378  crypto/bn/asm/rsaz-x86_64.pl
+ae26becda9f6d30e9edde8bb89c251a0c40a9a6c879c4cdaec273d8c09af9cd6  crypto/bn/asm/s390x-gf2m.pl
+2700337ef133d6688047a1a8e1c671db06016aae777679923ce2b301896762cf  crypto/bn/asm/s390x-mont.pl
 aa02597f3dc09cfbc190aedb75711859ba0f3efff87067ebfba1ec78ebee40d7  crypto/bn/asm/s390x.S
-2f7cbc2c3d93b1bbc4953dda38b9ae0ab3a0a8331a0418d94d9b286183736c9e  crypto/bn/asm/sparct4-mont.pl
+87d49e83a7df467097fdfc577aa206be9ee622c40fcbbbe5133b35d9783b7816  crypto/bn/asm/sparct4-mont.pl
 ca21a9ccbc54e19fb7c2e6cdf286ce7cb08b0fba960c777c6edce5c57ccc2101  crypto/bn/asm/sparcv8.S
 fbc93c8dbbecefe66086f58fe9719ed87b13b2cdc61454a10e841228296fecef  crypto/bn/asm/sparcv8plus.S
-127832c1e3d298aad805236776488f5f8836b6a0fdbce3f6b42678163df3909f  crypto/bn/asm/sparcv9-gf2m.pl
-1622f04a8918724ac0e8804baf285fdafa0eeaaecc36c7facd459d0ff13a8cac  crypto/bn/asm/sparcv9-mont.pl
-b69083f78b4b4f7097de4462d16649532fb82c453a82cdd9cc1393122661d6e2  crypto/bn/asm/sparcv9a-mont.pl
+2ec1497fa06826f7bc574239e425dd8dda0d4a2743e1fe87669ede900291fcb6  crypto/bn/asm/sparcv9-gf2m.pl
+1f490fe184c7a51b2d0646a59e69aa659bfe51270ad21594951b8d7b785bac38  crypto/bn/asm/sparcv9-mont.pl
+277dcb7faa1913b25fd43946c50039bcdd45cb643fd9ddeedd6c207cefa4dd50  crypto/bn/asm/sparcv9a-mont.pl
 d404375a21d33396824a3da212d6646d4f3150dd141ee4b4a250aefae3482efb  crypto/bn/asm/via-mont.pl
-d24f3e97239c8eed5efc721521b025b7256c15e67a54ea6b5c4cf8f7cd0f89ea  crypto/bn/asm/vis3-mont.pl
+d632edf9b9bab7d2cd2d616512a98d15cf4b3ebba7a8e7b83650d654ceb52ecb  crypto/bn/asm/vis3-mont.pl
 89278854f44d95be916516609ce6f79dcd346bab52574b9b6336a9952aa94bee  crypto/bn/asm/x86-gf2m.pl
 90d4ae234c08267adce9ed38d56e0edc223f7480cb9605f5d7399d0b3914c6be  crypto/bn/asm/x86-mont.pl
 d444ca73875e97e0ea88b20e4c02f2fcf3850e8b9311e3b67a2d04fe2796d543  crypto/bn/asm/x86_64-gcc.c
-709ddee92e9222ee0ed27bfb90db556e85e2d302e4a9131afa25fdc14c4d858f  crypto/bn/asm/x86_64-gf2m.pl
-da7f7780d27eed164797e5334cd45b35d9c113e86afaca051463aef9a8fd787c  crypto/bn/asm/x86_64-mont.pl
-259fb8d7f40c0dba46920b1f169d5b37de03b0fda645463d19e3ae2b56de851d  crypto/bn/asm/x86_64-mont5.pl
+a5481ca55d94dc7ebdc93173610d38ae2569cea1fe9b5180debe0ab94e455ce1  crypto/bn/asm/x86_64-gf2m.pl
+d8cc080824a72774cb3343a3d50ddf8f41a5b8321203d4c9a764762b62498b96  crypto/bn/asm/x86_64-mont.pl
+03788cb685268e6a50ddfa742ea1fe937570c9b86f2ebc88ee35f3304f67c045  crypto/bn/asm/x86_64-mont5.pl
 0ea8185a037a2951bb3d1e590bbbdeac305176d5e618f3e43a04c09733a9de34  crypto/bn/bn_add.c
 759c2b9df808b3562fe8b0c7778dbadbf35f261e14fc2d5090d18c35b4181760  crypto/bn/bn_asm.c
 14bd5a35c05fcf454854b92fb30b356d7ac618c1eb699dd798f6ad2936d1f5ee  crypto/bn/bn_blind.c
@@ -83,7 +83,7 @@ baba7c8ae95af6aa36bc9f4be3a2eed33d500451e568ca4bfc6bc7cb48d4f7ea  crypto/bn/bn_g
 5fbb1ab8463cd5544a1d95cf7996b6387ae634984a42256b7a21482ce3ac30a2  crypto/bn/bn_gf2m.c
 081e8a6abc23599307dab3b1a92113a65e0bf8717cbc40c970c7469350bc4581  crypto/bn/bn_intern.c
 602ed46fbfe12c899dfb7d9d99ff0dbfff96b454fce3cd02817f3e2488dd9192  crypto/bn/bn_kron.c
-bf73a1788a92142963177fb698bc518af9981bbf0ad9784701fbb2462ca10607  crypto/bn/bn_lib.c
+81a4afc27dd1e90c4bfa81c8d385214ce8a2b5884537752944a71ebebd91f4b0  crypto/bn/bn_lib.c
 d5beb9fbac2ff5dc3ccbdfa4d1aabca7225c778cff4e3b05b6d6c63e182637f5  crypto/bn/bn_local.h
 96f98cdf50087c5b567c31bf2581728623206d79b3f97f5a0c5fdaa0009e6e3c  crypto/bn/bn_mod.c
 f60f3d49b183b04bcdf9b82f7c961b8c1bcb00e68a2c1166fe9edd95a783356e  crypto/bn/bn_mont.c
@@ -92,10 +92,10 @@ f60f3d49b183b04bcdf9b82f7c961b8c1bcb00e68a2c1166fe9edd95a783356e  crypto/bn/bn_m
 b3677b73ac29aab660c9a549f7af154ca14347fac5cffd43b153a75211f1373f  crypto/bn/bn_nist.c
 c6760a724d696b7209f0a71f8483fabcf4f081f7e93e2628284c32ef78f69365  crypto/bn/bn_prime.c
 c56ad3073108a0de21c5820a48beae2bccdbf5aa8075ec21738878222eb9adc3  crypto/bn/bn_prime.h
-628419eabdb88b265823e43a7a1c88fdfecef79771180836f6089050dc9eadb1  crypto/bn/bn_rand.c
+71186d5bd40d467a919e6449d8aa23d13df88e0c85765d1a165f3eeec6bd33a7  crypto/bn/bn_rand.c
 4df8f204c8a06de2b4395be613ca0b9943613c523586e2005876d5c7bb891c75  crypto/bn/bn_recp.c
 a5c5c9f99961a5a7f22a3dcdce964c8a330f822be17f08652223a20fed747d0a  crypto/bn/bn_rsa_fips186_4.c
-704b0b4723e5c9e9bae5f3e35f9ae8ae8dca3383929e954de9e5169845abfdb2  crypto/bn/bn_shift.c
+6889866bca4673bccb8adf870859a867757ccd3c8ad4652675615afff710add3  crypto/bn/bn_shift.c
 622e90766b29e0d25f46474429aebda8eba2246835b9e85dc26da7cdbd49334f  crypto/bn/bn_sqr.c
 42c8ce944c889abcfcf089d0ad2744b7587696d8d7785efa91b3f7ec53dc062a  crypto/bn/bn_sqrt.c
 24e62baa56e02f2db6454e10168b7c7fa7638db9221b9acda1803d43f38f36e0  crypto/bn/bn_word.c
@@ -104,7 +104,7 @@ c4d64da1cdc732ea918fccd6a7bb2746b03365dd26f7ba1e74e08c307ca4c58e  crypto/bn/rsaz
 5b82cb8dbf3087c2e671871cb0a92e4039223a51af533a2ee996f3bfd47453a7  crypto/bn/rsaz_exp_x2.c
 834db8ff36006e5cb53e09ca6c44290124bd23692f4341ea6563b66fcade4cea  crypto/bsearch.c
 c39334b70e1394e43f378ae8d31b6e6dc125e4d9181e6536d38e649c4eaadb75  crypto/buffer/buffer.c
-5f43844b5d8665de9ab895f93599150a327d73ec2674bbf7d7c512d30163022d  crypto/c64xpluscpuid.pl
+d2bfdfd96b182741d2d51f91478ffcc48491b0da44662bc1c32bc506b3eef1ba  crypto/c64xpluscpuid.pl
 0e1a41a2d81b5765bca3df448f60bf1fad91e485fe89dd65a7300ffc419e316d  crypto/cmac/cmac.c
 ff9be205d6d7ff00b0e64508f0eb8d9ec0415fbabc0948d26e308212b3f7b2d8  crypto/context.c
 c309d81ea991ddf5be4337afad2fd132169f7443c76f863349d3f3c82f3374e4  crypto/core_algorithm.c
@@ -130,28 +130,28 @@ b0c248efc7dad48eaceb939a18cb2592cbfe5b02dd406592e5e590645488b153  crypto/dh/dh_k
 92345c259ea2a8c09e6d6b069d0942bd6ca4642231580f3e8148ae7a832a1115  crypto/dh/dh_lib.c
 8300775d88db0a1aa26a77eb49d6c4f7252e7fee69e1440de4c40edadc9da044  crypto/dh/dh_local.h
 bbcf4fc3067ac462a27d7277973180b7dc140df9262a686c7fbe4318ca01f7b8  crypto/dsa/dsa_backend.c
-d7e0d87494e3b3f0898a56785a219e87a2ce14416393ec32d8c0b5f539c7bdbf  crypto/dsa/dsa_check.c
+786d6c65ced7ee4e25f5dd7c3150259ec95b6aa321a7590d905757b8139f8230  crypto/dsa/dsa_check.c
 ae727bf6319eb57e682de35d75ea357921987953b3688365c710e7fba51c7c58  crypto/dsa/dsa_gen.c
 b1de1624e590dbf76f76953802ff162cc8de7c5e2eaba897313c866424d6902b  crypto/dsa/dsa_key.c
 9f4837c5abe53613a2dc1c5db81d073d4f42bd28b6a2d1e93a2b350d8e25d52a  crypto/dsa/dsa_lib.c
 f4d52d3897219786c6046bf76abb2f174655c584caa50272bf5d281720df5022  crypto/dsa/dsa_local.h
-c5c252f205482a71efeabe226d51a1c541a6ba2dfa9b8b8a70901087a9dc1667  crypto/dsa/dsa_ossl.c
-d612fd05ff98816ba6cf37f84c0e31443ad9d840ed587a7ab2066027da390325  crypto/dsa/dsa_sign.c
+196dc024873e413d92672c3a9b6c062ed6269250b0da6d41c0da1c03cfec9ef8  crypto/dsa/dsa_ossl.c
+9f501a59c09fc3cb3caafaff25abd44397a94d1062950a4d62e855d2c8986b5a  crypto/dsa/dsa_sign.c
 53fa10cc87ac63e35df661882852dc46ae68e6fee83b842f1aeefe00b8900ee1  crypto/dsa/dsa_vrf.c
-d9722ad8c6b6e209865a921f3cda831d09bf54a55cacd1edd9802edb6559190a  crypto/ec/asm/ecp_nistp521-ppc64.pl
-78ad06b88fcc8689a3a846b82f9ee01546e5734acd1bccf2494e523b71dc74d1  crypto/ec/asm/ecp_nistz256-armv4.pl
-4617351d2de4d0b2abfd358c58050cee00702d0b4c1acca09312ec870e351c7d  crypto/ec/asm/ecp_nistz256-armv8.pl
-3715ddd921425f3018741037f01455ed26a840ace08691a800708170a66cf4d2  crypto/ec/asm/ecp_nistz256-ppc64.pl
-cfe7e75a2fddc87a7251684469a8808b9da82b2f5725eafad5806920f89932bd  crypto/ec/asm/ecp_nistz256-sparcv9.pl
+786779d7014bc04846832f80638743784a3850c7ee36e4a8062fe8eb7ac31c9b  crypto/ec/asm/ecp_nistp521-ppc64.pl
+2e3056ea14fab8b306b0281d6a6f4317a6e86dbf652a79ade726e716cd79bb1e  crypto/ec/asm/ecp_nistz256-armv4.pl
+a02edef19d22c5aba196080942111ab0172fc2ebe6d6c40db2beb6a1a2d885c6  crypto/ec/asm/ecp_nistz256-armv8.pl
+729729f8233c95138158f4647b33a36cf175e707ce29563db0eedc811f324ec0  crypto/ec/asm/ecp_nistz256-ppc64.pl
+78a5b172f7c13ae8ac622439ffb9d99b240dbb4bbda3f5c88d1533ae74a445ad  crypto/ec/asm/ecp_nistz256-sparcv9.pl
 922725c4761cfa567af6ed9ecab04f2c7729ae2595f2fc0fa46dc67879dc87b0  crypto/ec/asm/ecp_nistz256-x86.pl
-ac327475c7ec828d11aa05628b4e3b81ec3b1400f30fe7bec01daf3cf71f2dc9  crypto/ec/asm/ecp_nistz256-x86_64.pl
-cc727533130f5f1a29229929b3d4e8454585d647be25d6344f3c6a0240998368  crypto/ec/asm/x25519-ppc64.pl
-ee897e230964511baa0d1bf95fb938312407a40a88ebe01476879c2763e5f732  crypto/ec/asm/x25519-x86_64.pl
+19ba01af58788e2873ebc1d5b503a76604bec0b9b6296fa794946e141fc945a4  crypto/ec/asm/ecp_nistz256-x86_64.pl
+e806141073aa3792e2748f6feeee6d3017124b3bc6059a9eca0d53a2f5785346  crypto/ec/asm/x25519-ppc64.pl
+a397592dc9fdb13016311db6184b4a3a4f2e198aacb03528f770f30ea4966cc4  crypto/ec/asm/x25519-x86_64.pl
 340336e01aa04fcde9bfd56536f90c9bc0ad56a002b6cfa321a1e421f1e93ceb  crypto/ec/curve25519.c
 9a95ec8366154bb20aeb24f4767a8cbb9953ca0380708eb2f39caca6078cd59e  crypto/ec/curve448/arch_32/f_impl32.c
 063dac1e4a9573c47532123e9e03e3532a7473cc3e146521ba9ec6f486ddf3b1  crypto/ec/curve448/arch_64/arch_intrinsics.h
 43423b7ee85a5c740c1d81499ee06f4a17732c7731a598e7429d5e402ee77cf4  crypto/ec/curve448/arch_64/f_impl.h
-1689097ae10e4982a8cbe50c2f6eddb03c83436f331f0b67edb98d6b58adc962  crypto/ec/curve448/arch_64/f_impl64.c
+012d4a9c8aed4a66cd3a3eef17d4b4d8f3c6f384449cd057bd292b98e072a283  crypto/ec/curve448/arch_64/f_impl64.c
 9b408ec0d43f3b6d714ef5963147e2c2abaddc88633db7dd759193d3c56ed727  crypto/ec/curve448/curve448.c
 3c12d90e3fdd59b5d32d63186f1a6f15c75eb73f5035b844a2054356a9459780  crypto/ec/curve448/curve448_local.h
 178fb9863c33174b633c2e7607160b1bedb506d66cc06d53382d87431441f306  crypto/ec/curve448/curve448_tables.c
@@ -178,7 +178,7 @@ fa901b996eb0e460359cd470843bdb03af7a77a2f1136c5e1d30daef70f3e4d2  crypto/ec/ec_m
 129c6b42417bfcf582f4a959cfd65433e6f85b158274f4fa38f9c62615ac9166  crypto/ec/ec_oct.c
 c7fba2f2c33f67dafa23caef8c3abd12f5336274a9a07d412b83be0366969ee6  crypto/ec/ecdh_kdf.c
 b2cf8f052a5716137da7b0e857ed7a5df5fb513b6d14534199a05e32f2b5a866  crypto/ec/ecdh_ossl.c
-099f7836a31643c58bda3829090ea81fe3d5acaa4c6f7b145d8355a4293d0ccc  crypto/ec/ecdsa_ossl.c
+031f99c746ac746c1d4f243dd71c8246b502ff00c1d7ca29f7ca024f0e37e14a  crypto/ec/ecdsa_ossl.c
 b6baa42b16e8df69a12e0ab101033100cddc808ec2682ba1574373e6ec86ae93  crypto/ec/ecdsa_sign.c
 f686cea8c8a3259d95c1e6142813d9da47b6d624c62f26c7e4a16d5607cddb35  crypto/ec/ecdsa_vrf.c
 141cfc1459214555b623517a054a9e8d5e4065a11301237b7247be2c6f397a0a  crypto/ec/ecp_mont.c
@@ -203,7 +203,7 @@ ca8c6cfd30efd53f2e5d1f19bcf09a3a3d0dff6d8947c3943d07a3f4b354aa86  crypto/evp/exc
 9e25042581b73e295c059c6217f3ecf809134d518eb79b1b67f34e3ca9145677  crypto/evp/kdf_lib.c
 1d72f5506984df1df8606e8c7045f041cf517223e2e1b50c4da8ba8bf1c6c186  crypto/evp/kdf_meth.c
 5179624b8e03615dc9caedc9ec16d094fa081495613dd552d71c2c39475bcd83  crypto/evp/kem.c
-5016dd7ef8b4cf7e9ea8465c18d1daa4c8808cb589261cf236058ee75bc868d7  crypto/evp/keymgmt_lib.c
+5cf3e490bf917bd37ae70313d126ae4720432fbec518e4a45e8fa886d5e1689a  crypto/evp/keymgmt_lib.c
 46ffdc73f8a7fc314dc8988f2751a6e9f9784719f4f162dc4be2450b65b55261  crypto/evp/keymgmt_meth.c
 e1a052839b8b70dca20dbac1282d61abd1c415bf4fb6afb56b811e8770d8a2e1  crypto/evp/m_sigver.c
 4290c95f63b43688a8da57690d122add5161a6811f9753da1444d28f46739961  crypto/evp/mac_lib.c
@@ -212,7 +212,7 @@ e7e8eb5683cd3fbd409df888020dc353b65ac291361829cc4131d5bc86c9fcb3  crypto/evp/mac
 3b4228b92eebd04616ecc3ee58684095313dd5ffd1b43cf698a7d6c202cb4622  crypto/evp/pmeth_check.c
 1f0e9e94e9b0ad322956521b438b78d44cfcd8eb974e8921d05f9e21ba1c05cf  crypto/evp/pmeth_gn.c
 76511fba789089a50ef87774817a5482c33633a76a94ecf7b6e8eb915585575d  crypto/evp/pmeth_lib.c
-4b2dbddf0f9ceed34c3822347138be754fb194febca1c21c46bcc3a5cce33674  crypto/evp/signature.c
+53058617c153a7676e7ca18c98c23df867a93087d67935907076f3c5bd65c15e  crypto/evp/signature.c
 f2acfb82aac20251d05a9c252cc6c282bd44e43feac4ac2e0faf68b9a38aef57  crypto/ex_data.c
 1c8389c5d49616d491978f0f2b2a54ba82d805ec41c8f75c67853216953cf46a  crypto/ffc/ffc_backend.c
 a12af33e605315cdddd6d759e70cd9632f0f33682b9aa7103ed1ecd354fc7e55  crypto/ffc/ffc_dh.c
@@ -228,19 +228,19 @@ f897493b50f4e9dd4cacb2a7accda6683c10ece602641874cdff1dac7128a751  crypto/initthr
 7290d8d7ec31a98b17618f218d4f27b393501c7606c814a43db8af1975ad1d10  crypto/lhash/lhash.c
 5d49ce00fc06df1b64cbc139ef45c71e0faf08a33f966bc608c82d574521a49e  crypto/lhash/lhash_local.h
 f866aafae928db1b439ac950dc90744a2397dfe222672fe68b3798396190c8b0  crypto/mem_clr.c
-e14f48d4112c0efe3826b4aa390cc24045a85298cc551ec7f3f36ac4236d7d81  crypto/modes/asm/aes-gcm-armv8_64.pl
-1d686af304f94743038f916125effcb51790c025f3165d8d37b526bbeee781f0  crypto/modes/asm/aesni-gcm-x86_64.pl
-c2e874a8deb418b5d8c935b2e256370566a5150e040c9fa008cdb5b463c26904  crypto/modes/asm/ghash-alpha.pl
-6bc7d63569c73d7020ede481f2de05221ac92403c7cc11e7263ada7644f6aa9b  crypto/modes/asm/ghash-armv4.pl
-097975df63370de7ebea012d17de14fc1f361fb83acf03b432a99ae7d5bceb24  crypto/modes/asm/ghash-c64xplus.pl
-fdde3bc48b37790c6e0006014da71e7a831bbb4fdbfcda2d01dbe0ceb0ba88fa  crypto/modes/asm/ghash-ia64.pl
-e472d73d06933667a51a0af973479993eed333c71b43af03095450acb36dbeb4  crypto/modes/asm/ghash-parisc.pl
-6fb4332ac88113a20915ad4de1931ef88b0114b5379b16e1d967820e1229fbb0  crypto/modes/asm/ghash-s390x.pl
-6af1a05981e1d41e4dea51e58938360e3abc4a4f58e179908242466d032b1a8a  crypto/modes/asm/ghash-sparcv9.pl
+78a20112586dbce2b8b6e509a0f46f6a36f2a4acf53c3f3511daf7932a71c391  crypto/modes/asm/aes-gcm-armv8_64.pl
+e482f02932d77d61142548ca4f3c8d5709d88ec14ab84723d82331444c0f57da  crypto/modes/asm/aesni-gcm-x86_64.pl
+8fdcb4313fa3a6e541a697525856b9527a06ddf4c794f9393e843f86d67f543c  crypto/modes/asm/ghash-alpha.pl
+ace8c376b394439301cecaf468d2a9a8adae21eff1d43191cefbf6765023452d  crypto/modes/asm/ghash-armv4.pl
+c22f4945e7de3bd7bfef73447f09983e40a3e4dd0938244d902a1c44c98a8467  crypto/modes/asm/ghash-c64xplus.pl
+315a76491cdba48c88df6549c9efd96b50515400810b185a568b7a871681e03d  crypto/modes/asm/ghash-ia64.pl
+25e9f494fcb6eb636c04af2f322736fae8aa339037e199332c96b8c9c3a50afa  crypto/modes/asm/ghash-parisc.pl
+f22d5fa646b4fc2db008b6b05ec07c8790d3ad5485d2b10218fd11d0e81030ba  crypto/modes/asm/ghash-s390x.pl
+de97107e0c19ff9dd4069f0761eccb00e0b3ced345e1f119ab3b918dd2f9c5f6  crypto/modes/asm/ghash-sparcv9.pl
 26f55a57e77f774d17dfba93d757f78edfa3a03f68a71ffa37ccf3bfc468b1e2  crypto/modes/asm/ghash-x86.pl
-72744131007d2389c09665a59a862f5f6bb61b64bd3456e9b400985cb56586b8  crypto/modes/asm/ghash-x86_64.pl
-a4e9f2e496bd9362b17a1b5989aa4682647cefcff6117f0607122a9e11a9dfd9  crypto/modes/asm/ghashp8-ppc.pl
-69a13f423ca74c22543900c14aef4a848e3bc75504b65d2f51c6903aebcc17a7  crypto/modes/asm/ghashv8-armx.pl
+2a0d23a644083e46745c7cb1ca79de393af9336a2e8eab7c85ffeb3b7b1a286f  crypto/modes/asm/ghash-x86_64.pl
+b407d9fc6ea65fe1a05edc2d139298d78391f3c165314fa6d56dd375b8e453cd  crypto/modes/asm/ghashp8-ppc.pl
+d8436f6dc43a18d49b1a16999ecb513ccf4483f418f75edc01ce68e777c614a9  crypto/modes/asm/ghashv8-armx.pl
 65112dfe63cd59487e7bdb1706b44acfcf48ecede12cc3ae51daa5b661f41f06  crypto/modes/cbc128.c
 1611e73dc1e01b5c2201f51756a7405b7673aa0bb872e2957d1ec80c3530486f  crypto/modes/ccm128.c
 d8c2f256532a4b94db6d03aea5cb609cccc938069f644b2fc77c5015648d148d  crypto/modes/cfb128.c
@@ -249,7 +249,7 @@ af1c034152d82b29cb7c938c8516cfd136b62bac0908c1d40eb50790d23b288c  crypto/modes/c
 bdf25257b15eca206be4d950d2dd807ca5f058f91f54edbd7a0d312ed83eef8e  crypto/modes/ofb128.c
 e55a816c356b2d526bc6e40c8b81afa02576e4d44c7d7b6bbe444fb8b01aad41  crypto/modes/wrap128.c
 608a04f387be2a509b4d4ad414b7015ab833e56b85020e692e193160f36883a2  crypto/modes/xts128.c
-8aa2504f84a0637b5122f0c963c9d82773ba248bad972ab92be7169995d162b5  crypto/o_str.c
+fecd75b0e1646fb18eeb6b1f528015296157a9bcf97191d0f32b9619aa4f0ffb  crypto/o_str.c
 8ddbbdf43131c10dcd4428aef0eff2b1e98b0410accada0fad41a4925868beef  crypto/packet.c
 c698d5166d091d6bb6e9df3c211fe1cc916fd43a26ec844f28f547cd708f9c55  crypto/param_build.c
 2a0f272dd553b698e8c6fa57962694ebd6064cb03fe26a60df529205568d315d  crypto/param_build_set.c
@@ -257,14 +257,14 @@ c698d5166d091d6bb6e9df3c211fe1cc916fd43a26ec844f28f547cd708f9c55  crypto/param_b
 4fda13f6af05d80b0ab89ec4f5813c274a21a9b4565be958a02d006236cef05c  crypto/params_dup.c
 b6cbfc8791b31587f32a3f9e4c117549793528ebddc34a361bad1ad8cf8d4c42  crypto/params_from_text.c
 97cb7414dc2f165d5849ee3b46cdfff0afb067729435d9c01a747e0ca41e230c  crypto/ppccap.c
-3ca43596a7528dec8ff9d1a3cd0d68b62640f84b1d6a8b5e4842cfd0be1133ad  crypto/ppccpuid.pl
+826a78afb376cbf1e87f12a2a67eef2ee47059a0fd3f9cba7ce7f035e34f8052  crypto/ppccpuid.pl
 b4d34272a0bd1fbe6562022bf7ea6259b6a5a021a48222d415be47ef5ef2a905  crypto/property/defn_cache.c
 3c4ade2fed4605e374d85ec1134a98da34e7124f89f44b81a754e8cfe81f14ba  crypto/property/property.c
 66da4f28d408133fb544b14aeb9ad4913e7c5c67e2826e53f0dc5bf4d8fada26  crypto/property/property_local.h
-37dba5e1f8a2f8cb8a69e491d52386359c9d08a3c7e43ac1c7a989b72b71593c  crypto/property/property_parse.c
+b0b382ce829192d2537561cfb0fb5c7afb04305f321f7b3c91441b4ba99b9c92  crypto/property/property_parse.c
 a7cefda6a117550e2c76e0f307565ce1e11640b11ba10c80e469a837fd1212a3  crypto/property/property_query.c
 065698c8d88a5facc0cbc02a3bd0c642c94687a8c5dd79901c942138b406067d  crypto/property/property_string.c
-0b38639ffc696d6037ace06cc0169bb5c411ee1c6bacc1fa18b3abd82000e69f  crypto/provider_core.c
+dcc44eba5d01dc248c37ec7b394d48660627c0fa4933d2b93993e1f2ac4b71da  crypto/provider_core.c
 d0af10d4091b2032aac1b7db80f8c2e14fa7176592716b25b9437ab6b53c0a89  crypto/provider_local.h
 5ba2e1c74ddcd0453d02e32612299d1eef18eff8493a7606c15d0dc3738ad1d9  crypto/provider_predefined.c
 a5a4472636b8b0095ad8d4acd37e275ad79da1a67ecff7b7b5c3e46c9ebc65b7  crypto/rand/rand_lib.c
@@ -288,50 +288,50 @@ f01af62704dbf9457e2669c3e7c1d4d740f0388faa49df93611b987a8aa2bf11  crypto/rsa/rsa
 3aba73dacebb046faf8d09dc279149b52c629004b524ec33e6d81c8ad0bc31a8  crypto/rsa/rsa_sp800_56b_gen.c
 1c1c2aeeb18bf1d69e8f134315b7e50d8f43d30eb1aa5bf42983eec9136a2fdc  crypto/rsa/rsa_x931.c
 0acbebed48f6242d595c21e3c1ad69da0daa960d62062e8970209deda144f337  crypto/s390xcap.c
-22205848cfb55116ebf999dced8331b575886a609ce29e6886e6267b2310c337  crypto/s390xcpuid.pl
+370d98549d4d98e04b60677b319b85904259359bd9401dd5385aa728278e6626  crypto/s390xcpuid.pl
 5fa59240ca885cbc0c1cd026934b226d44fc9c3fdf0c2e7e3a7bd7f4963ca2e5  crypto/self_test_core.c
-05c533fde7fdba0c76103e97d881b7224c8427451b453e2f6413552996063e31  crypto/sha/asm/keccak1600-armv4.pl
-ca3b2b654f9a8c4bc2fa2538c1f19d17acd4a6b9e0df6a4b81df04efa697e67e  crypto/sha/asm/keccak1600-armv8.pl
-12b7acce2fba0bc0e1ca07842ec84be6a022f141c86e077abb42c864af1d8d9c  crypto/sha/asm/keccak1600-avx2.pl
-faf0cccb685d5abc807e08db194f847c67b940da2fc3c235c210dc31d73a5334  crypto/sha/asm/keccak1600-avx512.pl
-be1e7dd9998e3f31cfa6e1b17bc198aeec584a8b76820e38f71d51b05f8a9f2a  crypto/sha/asm/keccak1600-avx512vl.pl
-33bdcc6f7668460c3bdf779633e43bfad62b937042a73acb007b462fc5b0a034  crypto/sha/asm/keccak1600-c64x.pl
+58a1a8aeb45421954fa0e4bc87157addb96d086ac4e6aade47da96523cecaa74  crypto/sha/asm/keccak1600-armv4.pl
+d6df6cfdd4e2fee52dc16fd31c91768c45c48c22700c486406d70ecb37e8a8bb  crypto/sha/asm/keccak1600-armv8.pl
+81bfb4484d68a3a3e1d704855f76356090867fe10a75db7707b6f7364e8ee8da  crypto/sha/asm/keccak1600-avx2.pl
+b7bb35d51d439abbf3810454ccb9bfb5a51e2111eaf389fb95796ad6220a61a0  crypto/sha/asm/keccak1600-avx512.pl
+37365dcc576f99006132271968bab990e2bebdab7f4168c726bd449a2fa51c6a  crypto/sha/asm/keccak1600-avx512vl.pl
+2767ae2f379a7a3d0c6dd1471d4d90dd896545b456cb6efd6c230df29e511d70  crypto/sha/asm/keccak1600-c64x.pl
 09fc831dd39bd90a701e9b16d9e9987cc215252a22e1e0355f5da6c495fca35a  crypto/sha/asm/keccak1600-mmx.pl
-ce4a58129e5ee3ac4c9dfec5ecc010440570ebf7bf869e3e9977f2121a64b27a  crypto/sha/asm/keccak1600-ppc64.pl
-a859fc8cb073b2d0012a93f3155a75fb6eb677441462b0de4f8cf8df1445e970  crypto/sha/asm/keccak1600-s390x.pl
-618dcd4891b4064d3b8aa6dcd74bea7ef55f4962a64957b05a05448f6e3e0f17  crypto/sha/asm/keccak1600-x86_64.pl
-831b8b02ab25d78ba6300ce960d96c13439bfba5844e13061e19c4e25cbacc3d  crypto/sha/asm/keccak1600p8-ppc.pl
+485dcc50a51705b86c6dc47e6f58d092fec05dfbfcdf4f2785e4235c67cfe742  crypto/sha/asm/keccak1600-ppc64.pl
+49535b60a1a981059a2a9636fdeeab22942d2a15e775b1ec9b5af8937a46aa76  crypto/sha/asm/keccak1600-s390x.pl
+093751655b460d33b2fa6aa4d63a86e902f7f20b2d2a02ed948b78e5698c0dd5  crypto/sha/asm/keccak1600-x86_64.pl
+e0a4a1df82716053a3f01ec0b096c735a0e3c4f6c9d9ec6b2006b37aaac64448  crypto/sha/asm/keccak1600p8-ppc.pl
 75d832db9bf0e98e7a5c522169060a6dd276c5118cfb297fc3f1111f55cd4007  crypto/sha/asm/sha1-586.pl
-c96e87d4f5311cd73bbdf499acc03418588be12426d878e157dd67e0099e0219  crypto/sha/asm/sha1-alpha.pl
-4ba6d1c7f12fe76bf39babea966f0a4b7f8769e0c0510cbfc2c46a65dd62d45c  crypto/sha/asm/sha1-armv4-large.pl
-efc69cb0d867b7fac6b3fa8985c343d1f984d552bc8e75bbbbace0adf9ee5f15  crypto/sha/asm/sha1-armv8.pl
-11d332b4e058e9fa418d6633316d2e9f9bf520a08b2d933e877bdf38b2edefcf  crypto/sha/asm/sha1-c64xplus.pl
-32ff0e701a7b8f25bcfe8477b20795de54f536527bd87d3ce694fd9aaae356d4  crypto/sha/asm/sha1-ia64.pl
-471c27efca685b2a82ad7fefe329ca54172df9f49b9785da6d706b913b75e693  crypto/sha/asm/sha1-mb-x86_64.pl
-0f5c63cf09e950d1b488935ab3b5562e3e9d5cd1a563fb88a41e3dae90a35e6d  crypto/sha/asm/sha1-mips.pl
-b5ffd7b6dbb04c05de7efa2945adb67ea845e7e61a3bf163a532f7b6acdf4267  crypto/sha/asm/sha1-parisc.pl
-482cd23ca6ec38d6f62b90c68f9f20643579c50f2c0fbb0dab1c10a0e35efe77  crypto/sha/asm/sha1-ppc.pl
-28cf69efd53d7a5a8c32e0f8db32c193f41b91faf44f5f59944334bc3f5aa337  crypto/sha/asm/sha1-s390x.pl
-7fd355b412ddfa1c510e0ba3284f75b1c0d621b6db2ecb1d2a935d5cdb706628  crypto/sha/asm/sha1-sparcv9.pl
-24554e68b0e7b7db7b635ff149549015f623ca0bcd9ae90439586a2076f6ae80  crypto/sha/asm/sha1-sparcv9a.pl
-74d197cdd72400cabbff7e173f72c8976723081508b095dc995e8cd1abf3daa6  crypto/sha/asm/sha1-thumb.pl
-a59a86293e28f5600609dc8af2b39c5285580ae8636520990b000eeeb67bb889  crypto/sha/asm/sha1-x86_64.pl
+8d937771993f04407f5fdcca8ca8565f9f8a4d9c9a8f7bfd4e9f9121dd0450bb  crypto/sha/asm/sha1-alpha.pl
+ab7ecd62896324393b1fd9020515b9c0d2b9cc34d559f2efafa35affc9a1485d  crypto/sha/asm/sha1-armv4-large.pl
+0acc4e40f793d4d2b960af2baaecc91176ba6742ddd62dca0c33ddc838c58772  crypto/sha/asm/sha1-armv8.pl
+c36f51761e7f59bdd0f61230297fb802542ac5d2d1c6d2b1096ed937131bd583  crypto/sha/asm/sha1-c64xplus.pl
+4ab7c9153b085274a579b388ddff97a4ac7e11585e01811ca95b93a3ec786605  crypto/sha/asm/sha1-ia64.pl
+7a392c5ef7dc19c39d67c7080e0c5214e7a80572c85c022be7e7d4378a5f740d  crypto/sha/asm/sha1-mb-x86_64.pl
+c0fea5a0d32001263c8bcf7fc0757aa68c6a7377f20fef8d28708e1b81de5dec  crypto/sha/asm/sha1-mips.pl
+f11b75a54c5f42aa3a052de8091bfba47d7cac01920b2fe0ddcb637d4c9d0eb9  crypto/sha/asm/sha1-parisc.pl
+d46ef3fc166271a83144d90985034e2c514bd1020b84ec0fe5427ad593bfeb74  crypto/sha/asm/sha1-ppc.pl
+a48c7d9403fe99fbd4daec60e96eb22058da766ab9e606d084a63613962851a2  crypto/sha/asm/sha1-s390x.pl
+0e2951e0574c64ee055ffddf16ceefdec00823107d60362976605f139ad8ae68  crypto/sha/asm/sha1-sparcv9.pl
+5da48400d4fae85e205e95a2fa368e7bf525e51e274b1dd680dfb48645426c85  crypto/sha/asm/sha1-sparcv9a.pl
+04b73c902d36c28b5a7eab47cb85f743eb9c648ed5936f64f655524a1010a1b5  crypto/sha/asm/sha1-thumb.pl
+f36d7ec7464c932230585a754b91f13cea4cde5a381fc9f798d959256d07910e  crypto/sha/asm/sha1-x86_64.pl
 c099059ef107f548ea2c2bab64a4eb8c277070ce6d74c4d32bb9808dc19c5fa3  crypto/sha/asm/sha256-586.pl
-b9cee5c5a283f61f601d2dba68a7a76e7aba10bfafffc1a5c4987f9c0aa6f87d  crypto/sha/asm/sha256-armv4.pl
-93ddc97651ee3e779144a3c6b3e46a1bc4aa81e75cd7b9df068a2aef8743d25f  crypto/sha/asm/sha256-c64xplus.pl
-8be5c5d69733ecb16774aa8410b4bcb3623a9f060d2be103d8aa67bf6e4c5843  crypto/sha/asm/sha256-mb-x86_64.pl
+3a8cf38dd398a7ab1d9c6701fa61c428b07c4431a0041ed3a2ddf937897825c1  crypto/sha/asm/sha256-armv4.pl
+c394bb5b0ff05595a9e6848b6602a0f29f73a79fc006593740f3ca645ad9d316  crypto/sha/asm/sha256-c64xplus.pl
+f33af8e2e2f57b7b63b8c8b35722d7d11ca6ef1f73fb6c4ccebdd3e86912f4b1  crypto/sha/asm/sha256-mb-x86_64.pl
 dd82e1311703abb019975fc7b61fb87d67e1ed916dddd065aced051e851114b9  crypto/sha/asm/sha512-586.pl
-8d84164f3cfd53290c0c14bb5655510b7a9238857866328c0604d64b4e76fe21  crypto/sha/asm/sha512-armv4.pl
-dadacb6d66b160913bffb4e1a6c3e5f7be6509b26e2c099701d8d3fdb92c1be0  crypto/sha/asm/sha512-armv8.pl
-6f548a088feae3b6faa179653ba449df9d3f5cda1e0561e5b5f120b32274d1eb  crypto/sha/asm/sha512-c64xplus.pl
-9fa54fbc34fd881f4b344374b9b4f8fb15b641424be7af9a31c71af89ae5d577  crypto/sha/asm/sha512-ia64.pl
-fb06844e7c3b014a58dccc8ec6020c71843cfdc5be08288bc7d204f0a840c474  crypto/sha/asm/sha512-mips.pl
-11548f06d213947104a80898e000218ec0d6ff3f6913f6582de498476482ce9f  crypto/sha/asm/sha512-parisc.pl
-7c0c490ce6bb11a228853aecad5e164ce84e5bdabb8a6658ae7184782076c7d3  crypto/sha/asm/sha512-ppc.pl
-38e0455fd6a2b93a7a5385379ca92bc6526585ca1eb4af365fac4c78f7285c72  crypto/sha/asm/sha512-s390x.pl
-0611845c52091b0208dd41f22ddef9dd1e68d3d92fa4c4360738b840a6314de6  crypto/sha/asm/sha512-sparcv9.pl
-f64d16c1e5c3fa4a7969de494a8372127502171a517c14be7a1e3a43a7308699  crypto/sha/asm/sha512-x86_64.pl
-8725cabb8d695c576619f19283b034074a3fa0f1c0be952a9dbe9793be15b907  crypto/sha/asm/sha512p8-ppc.pl
+1f9ba79b1d591b7aa37b62382422cb025f5b45784d26cc5790c05cf4eb52b792  crypto/sha/asm/sha512-armv4.pl
+8136196fce18b736f671a4b4945cd4aa4ab25a28c90c6fc9ab31ff771e8e0d9f  crypto/sha/asm/sha512-armv8.pl
+5b6796a9978b69fd78ee2ff1adc5cf35d44cad8194a38d1c2aba2023012cf252  crypto/sha/asm/sha512-c64xplus.pl
+e8df660671ba61aa2e8f51358baf5d8ca913093e2ee1a40c9cb46d9c2c0851f6  crypto/sha/asm/sha512-ia64.pl
+525f253ef8051bfb0e344ac2e40688ce359a42707fe360d23a03f522cc88c81a  crypto/sha/asm/sha512-mips.pl
+3c3e03529d8514467f8d77c01978348636bb339315feb8041fbde7640565001e  crypto/sha/asm/sha512-parisc.pl
+952ef1b10e8bbe3f638cc798b91ab9c5b47b66ed8fe94647b1beec9874f2e71e  crypto/sha/asm/sha512-ppc.pl
+193a0ea240264b29dd68a425f604a6da4b18e28838dcf909dd7e711af880f782  crypto/sha/asm/sha512-s390x.pl
+dcb466a1e5938fb64ecb38b0533602192d61334da864ee8dfdcfa12d3cdfa273  crypto/sha/asm/sha512-sparcv9.pl
+bb6503967a58b767a3e73441cfabc77f15c8ac747f377e276d4aa63d05f2c3c4  crypto/sha/asm/sha512-x86_64.pl
+68d2f3b2dccb978ee42640f4fb4d2eae6b74d071017a3eedd9e7cb77762817dc  crypto/sha/asm/sha512p8-ppc.pl
 57f6cf54b1b5d2cac7a8f622b7b6bd1878f360fff3fa0f02352061c24162ebbb  crypto/sha/keccak1600.c
 306cacd3f86e5cacaca74c58ef862516515e5c0cafaff48636d537fd84f1c2fb  crypto/sha/sha1dgst.c
 4d8cf04f5806611e7586aab47fb28165ec1afb00168e2c9876bb36cb5c29bf8b  crypto/sha/sha256.c
@@ -346,12 +346,12 @@ c50c584c55e56347bb43aca4b796b5344d70daece3061f586b79c871c21f5d1a  crypto/sparse_
 a41ae93a755e2ec89b3cb5b4932e2b508fdda92ace2e025a2650a6da0e9e972c  crypto/threads_none.c
 3729e2bd36f945808b578e0d89fac0fcb3114e4fc9381614bcbd8a9869991716  crypto/threads_pthread.c
 88423960f0414f6fd41fba4f4c67f9f7260c2741e4788adcd52493e895ec8027  crypto/threads_win.c
-fd6c27cf7c6b5449b17f2b725f4203c4c10207f1973db09fd41571efe5de08fd  crypto/x86_64cpuid.pl
+af0af59fe2cb8668a96751f343232d7faa3e7a937beb2bda09ed74fe60b9cb5f  crypto/x86_64cpuid.pl
 bbec287bb9bf35379885f8f8998b7fd9e8fc22efee9e1b299109af0f33a7ee16  crypto/x86cpuid.pl
-0a9c484f640d96e918921f57f592e82e99ccdbe35d3138d64b10c7af839e9a07  e_os.h
+acbb841170d4d3eb91d969be1c0e4973b1babfd5fcd76440b0628f509f82fd76  e_os.h
 6f353dc7c8c4d8f24f7ffbf920668ccb224ebb5810805a7c80d96770cd858005  include/crypto/aes_platform.h
 8c6f308c1ca774e6127e325c3b80511dbcdc99631f032694d8db53a5c02364ee  include/crypto/asn1_dsa.h
-8ce1b35c6924555ef316c7c51d6c27656869e6da7f513f45b7a7051579e3e54d  include/crypto/bn.h
+f6b01cff254311e973361190011cb6aa4d24b3a8c92f54e5191b7e2f669b8745  include/crypto/bn.h
 1c46818354d42bd1b1c4e5fdae9e019814936e775fd8c918ca49959c2a6416df  include/crypto/bn_conf.h.in
 7a43a4898fcc8446065e6c99249bcc14e475716e8c1d40d50408c0ab179520e6  include/crypto/bn_dh.h
 e69b2b20fb415e24b970941c84a62b752b5d0175bc68126e467f7cc970495504  include/crypto/cryptlib.h
@@ -373,7 +373,7 @@ f326212c978576c5346c89ae0336c2428594494b54054f6045b1f1038bfbc004  include/crypto
 7676b02824b2d68df6bddeb251e9b8a8fa2e35a95dad9a7ebeca53f9ab8d2dad  include/crypto/sparse_array.h
 7ad02c7de77304c3b298deeb038ab2550cf8b2bce03021994477c6c43dbcf86e  include/crypto/types.h
 782a83d4e489fd865e2768a20bfa31e78c2071fd0ceeb9eb077276ae2bcc6590  include/internal/bio.h
-92aacb3e49288f91b44f97e41933e88fe455706e1dd21a365683c2ab545db131  include/internal/constant_time.h
+8e984890c7c62cdd6356963f034831831f7167c65096cb4d23bc765d84d2c598  include/internal/constant_time.h
 c5bb97f654984130c8b44c09a52395bce0b22985d5dbc9c4d9377d86283f11f8  include/internal/core.h
 0b572801dfb8a41cc239e3439f8097a0ad11bbdf5d54811d10ceba3175cf2f17  include/internal/cryptlib.h
 9571cfd3d5666749084b354a6d65adee443deeb5713a58c098c7b03bc69dbc63  include/internal/deprecated.h
@@ -495,7 +495,7 @@ eec462d685dd3b4764b076a3c18ecd9dd254350a0b78ddc2f8a60587829e1ce3  providers/comm
 5b94312727ca33e4f5c038f4caaae8417bf584cfde22df83d91f3c55c30c81ee  providers/common/securitycheck.c
 527eda471e26763a5fcf123b2d290234d5c836de7b8ef6eef2166ef439919d82  providers/common/securitycheck_fips.c
 abd5997bc33b681a4ab275978b92aebca0806a4a3f0c2f41dacf11b3b6f4e101  providers/fips/fips_entry.c
-0f761a26c8fa6ad8d5a15c817afe1741352b21769b2164a2eb7dd50e1f6fe04f  providers/fips/fipsprov.c
+4a5ed1059ea6c5ef8d4b2a074b3da332443468852f58c18555f67f5d6d98606a  providers/fips/fipsprov.c
 5d24ba30f9cc7ca48546fb85dc285bd68590f3a604a0bd471bcb0c2a61169591  providers/fips/self_test.c
 f822a03138e8b83ccaa910b89d72f31691da6778bf6638181f993ec7ae1167e3  providers/fips/self_test.h
 d3c95c9c6cc4e3b1a5e4b2bfb2ae735a4109d763bcda7b1e9b8f9eb253f79820  providers/fips/self_test_data.inc
@@ -546,8 +546,8 @@ de342d04be6af69037922d5c97bdc40c0c27f6740636e72786a765d0d8ad9173  providers/impl
 b5f94d597df72ca58486c59b2a70b4057d13f09528f861ed41a84b7125b54a82  providers/implementations/exchange/dh_exch.c
 9c46dc0d859875fcc0bc3d61a7b610cd3520b1bf63718775c1124f54a1fe5f24  providers/implementations/exchange/ecdh_exch.c
 9bf87b8429398a6465c7e9f749a33b84974303a458736b56f3359b30726d3969  providers/implementations/exchange/ecx_exch.c
-0cc02005660c5c340660123decac838c59b7460ef1003d9d50edc604cfd8e375  providers/implementations/exchange/kdf_exch.c
-a0d1c1d49557d32497877b2d549d2a7a7729a550306275bfe6ddcefca0d8fc80  providers/implementations/include/prov/ciphercommon.h
+4692ea3852bf5763db576359bd793fc1ec3bcd0ca42fc906991d7ec4cced7b2a  providers/implementations/exchange/kdf_exch.c
+996f1397f61b9eab1e31b5d06bccd9ac958dbd5982fd41fdb263ee889b84275c  providers/implementations/include/prov/ciphercommon.h
 a9f5de1623221f327245957ec1dfd66a1914bff25adf4bcb81213c7955d19382  providers/implementations/include/prov/ciphercommon_aead.h
 dd07797d61988fd4124cfb920616df672938da80649fac5977bfd061c981edc5  providers/implementations/include/prov/ciphercommon_ccm.h
 0c1e99d70155402a790e4de65923228c8df8ad970741caccfe8b513837457d7f  providers/implementations/include/prov/ciphercommon_gcm.h
@@ -557,7 +557,7 @@ b9a61ce951c1904d8315b1bb26c0ab0aaadb47e71d4ead5df0a891608c728c4b  providers/impl
 c95ce5498e724b9b3d58e3c2f4723e7e3e4beb07f9bea9422e43182cbadb43af  providers/implementations/include/prov/macsignature.h
 29d1a112b799e1f45fdf8bcee8361c2ed67428c250c1cdf408a9fbb7ebf4cce1  providers/implementations/include/prov/names.h
 2187713b446d8b6d24ee986748b941ac3e24292c71e07ff9fb53a33021decdda  providers/implementations/include/prov/seeding.h
-4e71ffd329f1715d14b54e14036b4b2618deb2fd81675287ce5eeb6c76a31d54  providers/implementations/kdfs/hkdf.c
+d376c58489ae36fbece94bb88939845ced04a2a0bdd55d6a3562e45a56577ae1  providers/implementations/kdfs/hkdf.c
 a62e3af09f5af84dcf36f951ba4ac90ca1694adaf3747126186020b155f94186  providers/implementations/kdfs/kbkdf.c
 e0644e727aacfea4da3cf2c4d2602d7ef0626ebb760b6467432ffd54d5fbb24d  providers/implementations/kdfs/pbkdf2.c
 c0778565abff112c0c5257329a7750ec4605e62f26cc36851fa1fbee6e03c70c  providers/implementations/kdfs/pbkdf2.h
@@ -580,11 +580,11 @@ e69aa06f8f3c6f5a26702b9f44a844b8589b99dc0ee590953a29e8b9ef10acbe  providers/impl
 895c8dc7235b9ad5ff893be0293cbc245a5455e8850195ac7d446646e4ea71d0  providers/implementations/macs/hmac_prov.c
 8640b63fd8325aaf8f7128d6cc448d9af448a65bf51a8978075467d33a67944e  providers/implementations/macs/kmac_prov.c
 bf30274dd6b528ae913984775bd8f29c6c48c0ef06d464d0f738217727b7aa5c  providers/implementations/rands/crngt.c
-9d23df7f99beec7392c9d4ed813407050bc2d150098888fe802e2c9705fc33fa  providers/implementations/rands/drbg.c
-bb5f8161a80d0d1a7ee919af2b167972b00afd62e326252ca6aa93101f315f19  providers/implementations/rands/drbg_ctr.c
-a05adc3f6d9d6f948e5ead75f0522ed3164cb5b2d301169242f3cb97c4a7fac3  providers/implementations/rands/drbg_hash.c
-0876dfae991028c569631938946e458e6829cacf4cfb673d2b144ae50a3160bb  providers/implementations/rands/drbg_hmac.c
-fc43558964bdf12442d3f6ab6cc3e6849f7adb42f4d0123a1279819befcf71cb  providers/implementations/rands/drbg_local.h
+f9457255fc57ef5739aa2584e535195e38cc947e31fd044d28d64c28c8a946ce  providers/implementations/rands/drbg.c
+7e8fa6333845778474ed1313a66867512512372c9397f699a8f68fa6d5fc05fa  providers/implementations/rands/drbg_ctr.c
+8337994f4bc95e421d6d2833bb4481ad9d84deb3913d0faec6e1791ea372a793  providers/implementations/rands/drbg_hash.c
+1f040090f596f88cb64d6eb89109a8b75e66caee113708fb59335ad2547027fc  providers/implementations/rands/drbg_hmac.c
+7a1b8516f891f25f3dc07ffe0455200f20d3a1f0345a917f00c7d9afe900bb0a  providers/implementations/rands/drbg_local.h
 04339b66c10017229ef368cb48077f58a252ebfda9ab12b9f919e4149b1036ed  providers/implementations/rands/test_rng.c
 cafb9e6f54ad15889fcebddac6df61336bff7d78936f7de3bb5aab8aee5728d2  providers/implementations/signature/dsa_sig.c
 a30dc6308de0ca33406e7ce909f3bcf7580fb84d863b0976b275839f866258df  providers/implementations/signature/ecdsa_sig.c
diff --git a/crypto/openssl/providers/fips.checksum b/crypto/openssl/providers/fips.checksum
index 8fe82e025706..7b84d2271d3a 100644
--- a/crypto/openssl/providers/fips.checksum
+++ b/crypto/openssl/providers/fips.checksum
@@ -1 +1 @@
-9597c676c418928e2ba5075a6352a7d5b398e64db622b577822391424300ed43  providers/fips-sources.checksums
+4e1960f3d68410e8daf1893c9133ba9840912974ec65f885054c46b6bbeff5cd  providers/fips-sources.checksums
diff --git a/crypto/openssl/providers/fips/fipsprov.c b/crypto/openssl/providers/fips/fipsprov.c
index 6a88039423d9..3889dcd88a71 100644
--- a/crypto/openssl/providers/fips/fipsprov.c
+++ b/crypto/openssl/providers/fips/fipsprov.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2019-2022 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2019-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -655,6 +655,8 @@ int OSSL_provider_init_int(const OSSL_CORE_HANDLE *handle,
         }
     }
 
+    OPENSSL_cpuid_setup();
+
     /*  Create a context. */
     if ((*provctx = ossl_prov_ctx_new()) == NULL
         || (libctx = OSSL_LIB_CTX_new()) == NULL) {
diff --git a/crypto/openssl/providers/implementations/exchange/kdf_exch.c b/crypto/openssl/providers/implementations/exchange/kdf_exch.c
index 527a866c3d8d..148a3c422a8f 100644
--- a/crypto/openssl/providers/implementations/exchange/kdf_exch.c
+++ b/crypto/openssl/providers/implementations/exchange/kdf_exch.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2020-2022 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2020-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -28,9 +28,13 @@ static OSSL_FUNC_keyexch_derive_fn kdf_derive;
 static OSSL_FUNC_keyexch_freectx_fn kdf_freectx;
 static OSSL_FUNC_keyexch_dupctx_fn kdf_dupctx;
 static OSSL_FUNC_keyexch_set_ctx_params_fn kdf_set_ctx_params;
+static OSSL_FUNC_keyexch_get_ctx_params_fn kdf_get_ctx_params;
 static OSSL_FUNC_keyexch_settable_ctx_params_fn kdf_tls1_prf_settable_ctx_params;
 static OSSL_FUNC_keyexch_settable_ctx_params_fn kdf_hkdf_settable_ctx_params;
 static OSSL_FUNC_keyexch_settable_ctx_params_fn kdf_scrypt_settable_ctx_params;
+static OSSL_FUNC_keyexch_gettable_ctx_params_fn kdf_tls1_prf_gettable_ctx_params;
+static OSSL_FUNC_keyexch_gettable_ctx_params_fn kdf_hkdf_gettable_ctx_params;
+static OSSL_FUNC_keyexch_gettable_ctx_params_fn kdf_scrypt_gettable_ctx_params;
 
 typedef struct {
     void *provctx;
@@ -169,6 +173,13 @@ static int kdf_set_ctx_params(void *vpkdfctx, const OSSL_PARAM params[])
     return EVP_KDF_CTX_set_params(pkdfctx->kdfctx, params);
 }
 
+static int kdf_get_ctx_params(void *vpkdfctx, OSSL_PARAM params[])
+{
+    PROV_KDF_CTX *pkdfctx = (PROV_KDF_CTX *)vpkdfctx;
+
+    return EVP_KDF_CTX_get_params(pkdfctx->kdfctx, params);
+}
+
 static const OSSL_PARAM *kdf_settable_ctx_params(ossl_unused void *vpkdfctx,
                                                  void *provctx,
                                                  const char *kdfname)
@@ -197,6 +208,34 @@ KDF_SETTABLE_CTX_PARAMS(tls1_prf, "TLS1-PRF")
 KDF_SETTABLE_CTX_PARAMS(hkdf, "HKDF")
 KDF_SETTABLE_CTX_PARAMS(scrypt, "SCRYPT")
 
+static const OSSL_PARAM *kdf_gettable_ctx_params(ossl_unused void *vpkdfctx,
+                                                 void *provctx,
+                                                 const char *kdfname)
+{
+    EVP_KDF *kdf = EVP_KDF_fetch(PROV_LIBCTX_OF(provctx), kdfname,
+                                 NULL);
+    const OSSL_PARAM *params;
+
+    if (kdf == NULL)
+        return NULL;
+
+    params = EVP_KDF_gettable_ctx_params(kdf);
+    EVP_KDF_free(kdf);
+
+    return params;
+}
+
+#define KDF_GETTABLE_CTX_PARAMS(funcname, kdfname) \
+    static const OSSL_PARAM *kdf_##funcname##_gettable_ctx_params(void *vpkdfctx, \
+                                                                  void *provctx) \
+    { \
+        return kdf_gettable_ctx_params(vpkdfctx, provctx, kdfname); \
+    }
+
+KDF_GETTABLE_CTX_PARAMS(tls1_prf, "TLS1-PRF")
+KDF_GETTABLE_CTX_PARAMS(hkdf, "HKDF")
+KDF_GETTABLE_CTX_PARAMS(scrypt, "SCRYPT")
+
 #define KDF_KEYEXCH_FUNCTIONS(funcname) \
     const OSSL_DISPATCH ossl_kdf_##funcname##_keyexch_functions[] = { \
         { OSSL_FUNC_KEYEXCH_NEWCTX, (void (*)(void))kdf_##funcname##_newctx }, \
@@ -205,8 +244,11 @@ KDF_SETTABLE_CTX_PARAMS(scrypt, "SCRYPT")
         { OSSL_FUNC_KEYEXCH_FREECTX, (void (*)(void))kdf_freectx }, \
         { OSSL_FUNC_KEYEXCH_DUPCTX, (void (*)(void))kdf_dupctx }, \
         { OSSL_FUNC_KEYEXCH_SET_CTX_PARAMS, (void (*)(void))kdf_set_ctx_params }, \
+        { OSSL_FUNC_KEYEXCH_GET_CTX_PARAMS, (void (*)(void))kdf_get_ctx_params }, \
         { OSSL_FUNC_KEYEXCH_SETTABLE_CTX_PARAMS, \
         (void (*)(void))kdf_##funcname##_settable_ctx_params }, \
+        { OSSL_FUNC_KEYEXCH_GETTABLE_CTX_PARAMS, \
+        (void (*)(void))kdf_##funcname##_gettable_ctx_params }, \
         { 0, NULL } \
     };
 
diff --git a/crypto/openssl/providers/implementations/include/prov/ciphercommon.h b/crypto/openssl/providers/implementations/include/prov/ciphercommon.h
index 383b759304d4..aacd49707f84 100644
--- a/crypto/openssl/providers/implementations/include/prov/ciphercommon.h
+++ b/crypto/openssl/providers/implementations/include/prov/ciphercommon.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2019-2022 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2019-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -42,6 +42,13 @@ typedef int (PROV_CIPHER_HW_FN)(PROV_CIPHER_CTX *dat, unsigned char *out,
 #define PROV_CIPHER_FLAG_INVERSE_CIPHER   0x0200
 
 struct prov_cipher_ctx_st {
+    /* place buffer at the beginning for memory alignment */
+    /* The original value of the iv */
+    unsigned char oiv[GENERIC_BLOCK_SIZE];
+    /* Buffer of partial blocks processed via update calls */
+    unsigned char buf[GENERIC_BLOCK_SIZE];
+    unsigned char iv[GENERIC_BLOCK_SIZE];
+
     block128_f block;
     union {
         cbc128_f cbc;
@@ -83,12 +90,6 @@ struct prov_cipher_ctx_st {
      * manage partial blocks themselves.
      */
     unsigned int num;
-
-    /* The original value of the iv */
-    unsigned char oiv[GENERIC_BLOCK_SIZE];
-    /* Buffer of partial blocks processed via update calls */
-    unsigned char buf[GENERIC_BLOCK_SIZE];
-    unsigned char iv[GENERIC_BLOCK_SIZE];
     const PROV_CIPHER_HW *hw; /* hardware specific functions */
     const void *ks; /* Pointer to algorithm specific key data */
     OSSL_LIB_CTX *libctx;
diff --git a/crypto/openssl/providers/implementations/kdfs/hkdf.c b/crypto/openssl/providers/implementations/kdfs/hkdf.c
index 25819ea23977..3db8b43891a0 100644
--- a/crypto/openssl/providers/implementations/kdfs/hkdf.c
+++ b/crypto/openssl/providers/implementations/kdfs/hkdf.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016-2023 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2016-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -340,6 +340,13 @@ static int kdf_hkdf_get_ctx_params(void *vctx, OSSL_PARAM params[])
             return 0;
         return OSSL_PARAM_set_size_t(p, sz);
     }
+    if ((p = OSSL_PARAM_locate(params, OSSL_KDF_PARAM_INFO)) != NULL) {
+        if (ctx->info == NULL || ctx->info_len == 0) {
+            p->return_size = 0;
+            return 1;
+        }
+        return OSSL_PARAM_set_octet_string(p, ctx->info, ctx->info_len);
+    }
     return -2;
 }
 
@@ -348,6 +355,7 @@ static const OSSL_PARAM *kdf_hkdf_gettable_ctx_params(ossl_unused void *ctx,
 {
     static const OSSL_PARAM known_gettable_ctx_params[] = {
         OSSL_PARAM_size_t(OSSL_KDF_PARAM_SIZE, NULL),
+        OSSL_PARAM_octet_string(OSSL_KDF_PARAM_INFO, NULL, 0),
         OSSL_PARAM_END
     };
     return known_gettable_ctx_params;
diff --git a/crypto/openssl/providers/implementations/rands/drbg.c b/crypto/openssl/providers/implementations/rands/drbg.c
index e30836c53cab..41ff2a8e33f6 100644
--- a/crypto/openssl/providers/implementations/rands/drbg.c
+++ b/crypto/openssl/providers/implementations/rands/drbg.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011-2023 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2011-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -765,6 +765,7 @@ int ossl_drbg_enable_locking(void *vctx)
 PROV_DRBG *ossl_rand_drbg_new
     (void *provctx, void *parent, const OSSL_DISPATCH *p_dispatch,
      int (*dnew)(PROV_DRBG *ctx),
+     void (*dfree)(void *vctx),
      int (*instantiate)(PROV_DRBG *drbg,
                         const unsigned char *entropy, size_t entropylen,
                         const unsigned char *nonce, size_t noncelen,
@@ -844,7 +845,7 @@ PROV_DRBG *ossl_rand_drbg_new
     return drbg;
 
  err:
-    ossl_rand_drbg_free(drbg);
+    dfree(drbg);
     return NULL;
 }
 
diff --git a/crypto/openssl/providers/implementations/rands/drbg_ctr.c b/crypto/openssl/providers/implementations/rands/drbg_ctr.c
index 451113c4d162..21fdce640816 100644
--- a/crypto/openssl/providers/implementations/rands/drbg_ctr.c
+++ b/crypto/openssl/providers/implementations/rands/drbg_ctr.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011-2022 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2011-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -581,7 +581,7 @@ static int drbg_ctr_init(PROV_DRBG *drbg)
     EVP_CIPHER_CTX_free(ctr->ctx_ecb);
     EVP_CIPHER_CTX_free(ctr->ctx_ctr);
     ctr->ctx_ecb = ctr->ctx_ctr = NULL;
-    return 0;    
+    return 0;
 }
 
 static int drbg_ctr_new(PROV_DRBG *drbg)
@@ -602,7 +602,8 @@ static int drbg_ctr_new(PROV_DRBG *drbg)
 static void *drbg_ctr_new_wrapper(void *provctx, void *parent,
                                    const OSSL_DISPATCH *parent_dispatch)
 {
-    return ossl_rand_drbg_new(provctx, parent, parent_dispatch, &drbg_ctr_new,
+    return ossl_rand_drbg_new(provctx, parent, parent_dispatch,
+                              &drbg_ctr_new, &drbg_ctr_free,
                               &drbg_ctr_instantiate, &drbg_ctr_uninstantiate,
                               &drbg_ctr_reseed, &drbg_ctr_generate);
 }
diff --git a/crypto/openssl/providers/implementations/rands/drbg_hash.c b/crypto/openssl/providers/implementations/rands/drbg_hash.c
index 6deb0a29256b..de9375793d5a 100644
--- a/crypto/openssl/providers/implementations/rands/drbg_hash.c
+++ b/crypto/openssl/providers/implementations/rands/drbg_hash.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011-2021 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2011-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -410,7 +410,8 @@ static int drbg_hash_new(PROV_DRBG *ctx)
 static void *drbg_hash_new_wrapper(void *provctx, void *parent,
                                    const OSSL_DISPATCH *parent_dispatch)
 {
-    return ossl_rand_drbg_new(provctx, parent, parent_dispatch, &drbg_hash_new,
+    return ossl_rand_drbg_new(provctx, parent, parent_dispatch,
+                              &drbg_hash_new, &drbg_hash_free,
                               &drbg_hash_instantiate, &drbg_hash_uninstantiate,
                               &drbg_hash_reseed, &drbg_hash_generate);
 }
diff --git a/crypto/openssl/providers/implementations/rands/drbg_hmac.c b/crypto/openssl/providers/implementations/rands/drbg_hmac.c
index e68465a78cd9..4eb78de0653d 100644
--- a/crypto/openssl/providers/implementations/rands/drbg_hmac.c
+++ b/crypto/openssl/providers/implementations/rands/drbg_hmac.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011-2021 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2011-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -296,7 +296,8 @@ static int drbg_hmac_new(PROV_DRBG *drbg)
 static void *drbg_hmac_new_wrapper(void *provctx, void *parent,
                                    const OSSL_DISPATCH *parent_dispatch)
 {
-    return ossl_rand_drbg_new(provctx, parent, parent_dispatch, &drbg_hmac_new,
+    return ossl_rand_drbg_new(provctx, parent, parent_dispatch,
+                              &drbg_hmac_new, &drbg_hmac_free,
                               &drbg_hmac_instantiate, &drbg_hmac_uninstantiate,
                               &drbg_hmac_reseed, &drbg_hmac_generate);
 }
diff --git a/crypto/openssl/providers/implementations/rands/drbg_local.h b/crypto/openssl/providers/implementations/rands/drbg_local.h
index 8bc5df89c236..2f3aacdea871 100644
--- a/crypto/openssl/providers/implementations/rands/drbg_local.h
+++ b/crypto/openssl/providers/implementations/rands/drbg_local.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -181,6 +181,7 @@ struct prov_drbg_st {
 PROV_DRBG *ossl_rand_drbg_new
     (void *provctx, void *parent, const OSSL_DISPATCH *parent_dispatch,
      int (*dnew)(PROV_DRBG *ctx),
+     void (*dfree)(void *vctx),
      int (*instantiate)(PROV_DRBG *drbg,
                         const unsigned char *entropy, size_t entropylen,
                         const unsigned char *nonce, size_t noncelen,
diff --git a/crypto/openssl/ssl/record/rec_layer_s3.c b/crypto/openssl/ssl/record/rec_layer_s3.c
index 4bcffcc41e36..779e998bb6ee 100644
--- a/crypto/openssl/ssl/record/rec_layer_s3.c
+++ b/crypto/openssl/ssl/record/rec_layer_s3.c
@@ -81,6 +81,15 @@ int RECORD_LAYER_read_pending(const RECORD_LAYER *rl)
     return SSL3_BUFFER_get_left(&rl->rbuf) != 0;
 }
 
+int RECORD_LAYER_data_present(const RECORD_LAYER *rl)
+{
+    if (rl->rstate == SSL_ST_READ_BODY)
+        return 1;
+    if (RECORD_LAYER_processed_read_pending(rl))
+        return 1;
+    return 0;
+}
+
 /* Checks if we have decrypted unread record data pending */
 int RECORD_LAYER_processed_read_pending(const RECORD_LAYER *rl)
 {
@@ -221,6 +230,12 @@ int ssl3_read_n(SSL *s, size_t n, size_t max, int extend, int clearold,
         /* ... now we can act as if 'extend' was set */
     }
 
+    if (!ossl_assert(s->rlayer.packet != NULL)) {
+        /* does not happen */
+        SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
+        return -1;
+    }
+
     len = s->rlayer.packet_length;
     pkt = rb->buf + align;
     /*
diff --git a/crypto/openssl/ssl/record/record.h b/crypto/openssl/ssl/record/record.h
index 234656bf9394..a2db6aa88e14 100644
--- a/crypto/openssl/ssl/record/record.h
+++ b/crypto/openssl/ssl/record/record.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -205,6 +205,7 @@ void RECORD_LAYER_release(RECORD_LAYER *rl);
 int RECORD_LAYER_read_pending(const RECORD_LAYER *rl);
 int RECORD_LAYER_processed_read_pending(const RECORD_LAYER *rl);
 int RECORD_LAYER_write_pending(const RECORD_LAYER *rl);
+int RECORD_LAYER_data_present(const RECORD_LAYER *rl);
 void RECORD_LAYER_reset_read_sequence(RECORD_LAYER *rl);
 void RECORD_LAYER_reset_write_sequence(RECORD_LAYER *rl);
 int RECORD_LAYER_is_sslv2_record(RECORD_LAYER *rl);
diff --git a/crypto/openssl/ssl/record/ssl3_buffer.c b/crypto/openssl/ssl/record/ssl3_buffer.c
index 97b0c26ced81..e769235fe0de 100644
--- a/crypto/openssl/ssl/record/ssl3_buffer.c
+++ b/crypto/openssl/ssl/record/ssl3_buffer.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -191,5 +191,7 @@ int ssl3_release_read_buffer(SSL *s)
         OPENSSL_cleanse(b->buf, b->len);
     OPENSSL_free(b->buf);
     b->buf = NULL;
+    s->rlayer.packet = NULL;
+    s->rlayer.packet_length = 0;
     return 1;
 }
diff --git a/crypto/openssl/ssl/ssl_err.c b/crypto/openssl/ssl/ssl_err.c
index 41898844ff97..75be692e0007 100644
--- a/crypto/openssl/ssl/ssl_err.c
+++ b/crypto/openssl/ssl/ssl_err.c
@@ -1,6 +1,6 @@
 /*
  * Generated by util/mkerr.pl DO NOT EDIT
- * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -457,6 +457,8 @@ static const ERR_STRING_DATA SSL_str_reasons[] = {
     "tlsv1 alert insufficient security"},
     {ERR_PACK(ERR_LIB_SSL, 0, SSL_R_TLSV1_ALERT_INTERNAL_ERROR),
     "tlsv1 alert internal error"},
+    {ERR_PACK(ERR_LIB_SSL, 0, SSL_R_TLSV1_ALERT_NO_APPLICATION_PROTOCOL),
+    "tlsv1 alert no application protocol"},
     {ERR_PACK(ERR_LIB_SSL, 0, SSL_R_TLSV1_ALERT_NO_RENEGOTIATION),
     "tlsv1 alert no renegotiation"},
     {ERR_PACK(ERR_LIB_SSL, 0, SSL_R_TLSV1_ALERT_PROTOCOL_VERSION),
@@ -465,6 +467,8 @@ static const ERR_STRING_DATA SSL_str_reasons[] = {
     "tlsv1 alert record overflow"},
     {ERR_PACK(ERR_LIB_SSL, 0, SSL_R_TLSV1_ALERT_UNKNOWN_CA),
     "tlsv1 alert unknown ca"},
+    {ERR_PACK(ERR_LIB_SSL, 0, SSL_R_TLSV1_ALERT_UNKNOWN_PSK_IDENTITY),
+    "tlsv1 alert unknown psk identity"},
     {ERR_PACK(ERR_LIB_SSL, 0, SSL_R_TLSV1_ALERT_USER_CANCELLED),
     "tlsv1 alert user cancelled"},
     {ERR_PACK(ERR_LIB_SSL, 0, SSL_R_TLSV1_BAD_CERTIFICATE_HASH_VALUE),
diff --git a/crypto/openssl/ssl/ssl_lib.c b/crypto/openssl/ssl/ssl_lib.c
index 2c8479eb5fc6..cb4e006ea7a3 100644
--- a/crypto/openssl/ssl/ssl_lib.c
+++ b/crypto/openssl/ssl/ssl_lib.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved.
  * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
  * Copyright 2005 Nokia. All rights reserved.
  *
@@ -3736,9 +3736,10 @@ void ssl_update_cache(SSL *s, int mode)
 
     /*
      * If the session_id_length is 0, we are not supposed to cache it, and it
-     * would be rather hard to do anyway :-)
+     * would be rather hard to do anyway :-). Also if the session has already
+     * been marked as not_resumable we should not cache it for later reuse.
      */
-    if (s->session->session_id_length == 0)
+    if (s->session->session_id_length == 0 || s->session->not_resumable)
         return;
 
     /*
@@ -5491,6 +5492,9 @@ int SSL_free_buffers(SSL *ssl)
     if (RECORD_LAYER_read_pending(rl) || RECORD_LAYER_write_pending(rl))
         return 0;
 
+    if (RECORD_LAYER_data_present(rl))
+        return 0;
+
     RECORD_LAYER_release(rl);
     return 1;
 }
diff --git a/crypto/openssl/ssl/ssl_sess.c b/crypto/openssl/ssl/ssl_sess.c
index d836b33ed0e8..56854fc89023 100644
--- a/crypto/openssl/ssl/ssl_sess.c
+++ b/crypto/openssl/ssl/ssl_sess.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved.
  * Copyright 2005 Nokia. All rights reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
@@ -152,16 +152,11 @@ SSL_SESSION *SSL_SESSION_new(void)
     return ss;
 }
 
-SSL_SESSION *SSL_SESSION_dup(const SSL_SESSION *src)
-{
-    return ssl_session_dup(src, 1);
-}
-
 /*
  * Create a new SSL_SESSION and duplicate the contents of |src| into it. If
  * ticket == 0 then no ticket information is duplicated, otherwise it is.
  */
-SSL_SESSION *ssl_session_dup(const SSL_SESSION *src, int ticket)
+static SSL_SESSION *ssl_session_dup_intern(const SSL_SESSION *src, int ticket)
 {
     SSL_SESSION *dest;
 
@@ -285,6 +280,27 @@ SSL_SESSION *ssl_session_dup(const SSL_SESSION *src, int ticket)
     return NULL;
 }
 
+SSL_SESSION *SSL_SESSION_dup(const SSL_SESSION *src)
+{
+    return ssl_session_dup_intern(src, 1);
+}
+
+/*
+ * Used internally when duplicating a session which might be already shared.
+ * We will have resumed the original session. Subsequently we might have marked
+ * it as non-resumable (e.g. in another thread) - but this copy should be ok to
+ * resume from.
+ */
+SSL_SESSION *ssl_session_dup(const SSL_SESSION *src, int ticket)
+{
+    SSL_SESSION *sess = ssl_session_dup_intern(src, ticket);
+
+    if (sess != NULL)
+        sess->not_resumable = 0;
+
+    return sess;
+}
+
 const unsigned char *SSL_SESSION_get_id(const SSL_SESSION *s, unsigned int *len)
 {
     if (len)
@@ -515,6 +531,12 @@ SSL_SESSION *lookup_sess_in_cache(SSL *s, const unsigned char *sess_id,
         ret = s->session_ctx->get_session_cb(s, sess_id, sess_id_len, &copy);
 
         if (ret != NULL) {
+            if (ret->not_resumable) {
+                /* If its not resumable then ignore this session */
+                if (!copy)
+                    SSL_SESSION_free(ret);
+                return NULL;
+            }
             ssl_tsan_counter(s->session_ctx,
                              &s->session_ctx->stats.sess_cb_hit);
 
diff --git a/crypto/openssl/ssl/statem/statem_srvr.c b/crypto/openssl/ssl/statem/statem_srvr.c
index a9e67f9d32a7..df7c868eff71 100644
--- a/crypto/openssl/ssl/statem/statem_srvr.c
+++ b/crypto/openssl/ssl/statem/statem_srvr.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved.
  * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
  * Copyright 2005 Nokia. All rights reserved.
  *
@@ -2338,9 +2338,8 @@ int tls_construct_server_hello(SSL *s, WPACKET *pkt)
      * so the following won't overwrite an ID that we're supposed
      * to send back.
      */
-    if (s->session->not_resumable ||
-        (!(s->ctx->session_cache_mode & SSL_SESS_CACHE_SERVER)
-         && !s->hit))
+    if (!(s->ctx->session_cache_mode & SSL_SESS_CACHE_SERVER)
+            && !s->hit)
         s->session->session_id_length = 0;
 
     if (usetls13) {
@@ -3135,7 +3134,7 @@ static int tls_process_cke_gost(SSL *s, PACKET *pkt)
     }
     if (EVP_PKEY_decrypt_init(pkey_ctx) <= 0) {
         SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
-        return 0;
+        goto err;
     }
     /*
      * If client certificate is present and is of the same type, maybe
diff --git a/crypto/openssl/ssl/t1_lib.c b/crypto/openssl/ssl/t1_lib.c
index 8be00a4f3405..673e2f0f0248 100644
--- a/crypto/openssl/ssl/t1_lib.c
+++ b/crypto/openssl/ssl/t1_lib.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -734,7 +734,8 @@ static int gid_cb(const char *elem, int len, void *arg)
         return 0;
     if (garg->gidcnt == garg->gidmax) {
         uint16_t *tmp =
-            OPENSSL_realloc(garg->gid_arr, garg->gidmax + GROUPLIST_INCREMENT);
+            OPENSSL_realloc(garg->gid_arr,
+                            (garg->gidmax + GROUPLIST_INCREMENT) * sizeof(*garg->gid_arr));
         if (tmp == NULL)
             return 0;
         garg->gidmax += GROUPLIST_INCREMENT;
diff --git a/crypto/openssl/test/bad_dtls_test.c b/crypto/openssl/test/bad_dtls_test.c
index e6ee1ea09f6d..dc3d4bc0d750 100644
--- a/crypto/openssl/test/bad_dtls_test.c
+++ b/crypto/openssl/test/bad_dtls_test.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016-2022 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2016-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -503,7 +503,6 @@ static int test_bad_dtls(void)
     if (!TEST_ptr(con)
             || !TEST_true(SSL_set_session(con, sess)))
         goto end;
-    SSL_SESSION_free(sess);
 
     rbio = BIO_new(BIO_s_mem());
     wbio = BIO_new(BIO_s_mem());
@@ -591,6 +590,7 @@ static int test_bad_dtls(void)
     testresult = 1;
 
  end:
+    SSL_SESSION_free(sess);
     BIO_free(rbio);
     BIO_free(wbio);
     SSL_free(con);
diff --git a/crypto/openssl/test/build.info b/crypto/openssl/test/build.info
index 416c2270771a..25ab0430b731 100644
--- a/crypto/openssl/test/build.info
+++ b/crypto/openssl/test/build.info
@@ -874,6 +874,7 @@ IF[{- !$disabled{tests} -}]
   ENDIF
   IF[{- $disabled{module} || !$target{dso_scheme} -}]
     DEFINE[provider_test]=NO_PROVIDER_MODULE
+    DEFINE[prov_config_test]=NO_PROVIDER_MODULE
     DEFINE[provider_internal_test]=NO_PROVIDER_MODULE
   ENDIF
   DEPEND[]=provider_internal_test.cnf
diff --git a/crypto/openssl/test/cmp_hdr_test.c b/crypto/openssl/test/cmp_hdr_test.c
index ed49a0bb6199..e2bd210118d8 100644
--- a/crypto/openssl/test/cmp_hdr_test.c
+++ b/crypto/openssl/test/cmp_hdr_test.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2007-2023 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2007-2024 The OpenSSL Project Authors. All Rights Reserved.
  * Copyright Nokia 2007-2019
  * Copyright Siemens AG 2015-2019
  *
@@ -71,25 +71,30 @@ static int test_HDR_set_get_pvno(void)
 
 static int execute_HDR_get0_senderNonce_test(CMP_HDR_TEST_FIXTURE *fixture)
 {
+    int res = 0;
     X509_NAME *sender = X509_NAME_new();
     ASN1_OCTET_STRING *sn;
 
     if (!TEST_ptr(sender))
-        return 0;
+        goto err;
 
     X509_NAME_ADD(sender, "CN", "A common sender name");
     if (!TEST_int_eq(OSSL_CMP_CTX_set1_subjectName(fixture->cmp_ctx, sender),
                      1))
-        return 0;
+        goto err;
     if (!TEST_int_eq(ossl_cmp_hdr_init(fixture->cmp_ctx, fixture->hdr),
                      1))
-        return 0;
+        goto err;
     sn = ossl_cmp_hdr_get0_senderNonce(fixture->hdr);
     if (!TEST_int_eq(ASN1_OCTET_STRING_cmp(fixture->cmp_ctx->senderNonce, sn),
                      0))
-        return 0;
+        goto err;
+
+    res = 1;
+err:
     X509_NAME_free(sender);
-    return 1;
+
+    return res;
 }
 
 static int test_HDR_get0_senderNonce(void)
@@ -102,23 +107,28 @@ static int test_HDR_get0_senderNonce(void)
 
 static int execute_HDR_set1_sender_test(CMP_HDR_TEST_FIXTURE *fixture)
 {
+    int res = 0;
     X509_NAME *x509name = X509_NAME_new();
 
     if (!TEST_ptr(x509name))
-        return 0;
+        goto err;
 
     X509_NAME_ADD(x509name, "CN", "A common sender name");
     if (!TEST_int_eq(ossl_cmp_hdr_set1_sender(fixture->hdr, x509name), 1))
-        return 0;
+        goto err;
+
     if (!TEST_int_eq(fixture->hdr->sender->type, GEN_DIRNAME))
-        return 0;
+        goto err;
 
     if (!TEST_int_eq(X509_NAME_cmp(fixture->hdr->sender->d.directoryName,
                                    x509name), 0))
-        return 0;
+        goto err;
 
+    res = 1;
+err:
     X509_NAME_free(x509name);
-    return 1;
+
+    return res;
 }
 
 static int test_HDR_set1_sender(void)
@@ -131,24 +141,28 @@ static int test_HDR_set1_sender(void)
 
 static int execute_HDR_set1_recipient_test(CMP_HDR_TEST_FIXTURE *fixture)
 {
+    int res = 0;
     X509_NAME *x509name = X509_NAME_new();
 
     if (!TEST_ptr(x509name))
-        return 0;
+        goto err;
 
     X509_NAME_ADD(x509name, "CN", "A common recipient name");
     if (!TEST_int_eq(ossl_cmp_hdr_set1_recipient(fixture->hdr, x509name), 1))
-        return 0;
+        goto err;
 
     if (!TEST_int_eq(fixture->hdr->recipient->type, GEN_DIRNAME))
-        return 0;
+        goto err;
 
     if (!TEST_int_eq(X509_NAME_cmp(fixture->hdr->recipient->d.directoryName,
                                    x509name), 0))
-        return 0;
+        goto err;
 
+    res = 1;
+err:
     X509_NAME_free(x509name);
-    return 1;
+
+    return res;
 }
 
 static int test_HDR_set1_recipient(void)
@@ -203,7 +217,7 @@ static int execute_HDR_set1_senderKID_test(CMP_HDR_TEST_FIXTURE *fixture)
     int res = 0;
 
     if (!TEST_ptr(senderKID))
-        return 0;
+        goto err;
 
     if (!TEST_int_eq(ASN1_OCTET_STRING_set(senderKID, rand_data,
                                            sizeof(rand_data)), 1))
@@ -265,7 +279,7 @@ static int execute_HDR_push1_freeText_test(CMP_HDR_TEST_FIXTURE *fixture)
     int res = 0;
 
     if (!TEST_ptr(text))
-        return 0;
+        goto err;
 
     if (!ASN1_STRING_set(text, "A free text", -1))
         goto err;
@@ -280,6 +294,7 @@ static int execute_HDR_push1_freeText_test(CMP_HDR_TEST_FIXTURE *fixture)
     res = 1;
  err:
     ASN1_UTF8STRING_free(text);
+
     return res;
 }
 
diff --git a/crypto/openssl/test/ct_test.c b/crypto/openssl/test/ct_test.c
index 26d5bc108450..ff253414f806 100644
--- a/crypto/openssl/test/ct_test.c
+++ b/crypto/openssl/test/ct_test.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016-2022 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2016-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -450,13 +450,18 @@ static int test_encode_tls_sct(void)
 
     fixture->sct_list = sk_SCT_new_null();
     if (fixture->sct_list == NULL)
-	    return 0;
+    {
+        tear_down(fixture);
+        return 0;
+    }
 
     if (!TEST_ptr(sct = SCT_new_from_base64(SCT_VERSION_V1, log_id,
                                             CT_LOG_ENTRY_TYPE_X509, timestamp,
                                             extensions, signature)))
-
+    {
+        tear_down(fixture);
         return 0;
+    }
 
     sk_SCT_push(fixture->sct_list, sct);
     fixture->sct_dir = ct_dir;
diff --git a/crypto/openssl/test/dsatest.c b/crypto/openssl/test/dsatest.c
index 5fa83020f87a..b849105d33d8 100644
--- a/crypto/openssl/test/dsatest.c
+++ b/crypto/openssl/test/dsatest.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -332,6 +332,7 @@ static int test_dsa_sig_infinite_loop(void)
     BIGNUM *p = NULL, *q = NULL, *g = NULL, *priv = NULL, *pub = NULL, *priv2 = NULL;
     BIGNUM *badq = NULL, *badpriv = NULL;
     const unsigned char msg[] = { 0x00 };
+    unsigned int signature_len0;
     unsigned int signature_len;
     unsigned char signature[64];
 
@@ -375,10 +376,13 @@ static int test_dsa_sig_infinite_loop(void)
         goto err;
 
     /* Test passing signature as NULL */
-    if (!TEST_true(DSA_sign(0, msg, sizeof(msg), NULL, &signature_len, dsa)))
+    if (!TEST_true(DSA_sign(0, msg, sizeof(msg), NULL, &signature_len0, dsa))
+        || !TEST_int_gt(signature_len0, 0))
         goto err;
 
-    if (!TEST_true(DSA_sign(0, msg, sizeof(msg), signature, &signature_len, dsa)))
+    if (!TEST_true(DSA_sign(0, msg, sizeof(msg), signature, &signature_len, dsa))
+        || !TEST_int_gt(signature_len, 0)
+        || !TEST_int_le(signature_len, signature_len0))
         goto err;
 
     /* Test using a private key of zero fails - this causes an infinite loop without the retry test */
diff --git a/crypto/openssl/test/ecdsatest.c b/crypto/openssl/test/ecdsatest.c
index 33a52eb1b562..0ddbf6690dca 100644
--- a/crypto/openssl/test/ecdsatest.c
+++ b/crypto/openssl/test/ecdsatest.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2023 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2002-2024 The OpenSSL Project Authors. All Rights Reserved.
  * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
@@ -350,15 +350,39 @@ static int test_builtin_as_sm2(int n)
 static int test_ecdsa_sig_NULL(void)
 {
     int ret;
+    unsigned int siglen0;
     unsigned int siglen;
     unsigned char dgst[128] = { 0 };
     EC_KEY *eckey = NULL;
+    unsigned char *sig = NULL;
+    BIGNUM *kinv = NULL, *rp = NULL;
 
     ret = TEST_ptr(eckey = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1))
           && TEST_int_eq(EC_KEY_generate_key(eckey), 1)
-          && TEST_int_eq(ECDSA_sign(0, dgst, sizeof(dgst), NULL, &siglen, eckey), 1)
-          && TEST_int_gt(siglen, 0);
+          && TEST_int_eq(ECDSA_sign(0, dgst, sizeof(dgst), NULL, &siglen0,
+                                    eckey), 1)
+          && TEST_int_gt(siglen0, 0)
+          && TEST_ptr(sig = OPENSSL_malloc(siglen0))
+          && TEST_int_eq(ECDSA_sign(0, dgst, sizeof(dgst), sig, &siglen,
+                                    eckey), 1)
+          && TEST_int_gt(siglen, 0)
+          && TEST_int_le(siglen, siglen0)
+          && TEST_int_eq(ECDSA_verify(0, dgst, sizeof(dgst), sig, siglen,
+                                      eckey), 1)
+          && TEST_int_eq(ECDSA_sign_setup(eckey, NULL, &kinv, &rp), 1)
+          && TEST_int_eq(ECDSA_sign_ex(0, dgst, sizeof(dgst), NULL, &siglen,
+                                       kinv, rp, eckey), 1)
+          && TEST_int_gt(siglen, 0)
+          && TEST_int_le(siglen, siglen0)
+          && TEST_int_eq(ECDSA_sign_ex(0, dgst, sizeof(dgst), sig, &siglen0,
+                                       kinv, rp, eckey), 1)
+          && TEST_int_eq(siglen, siglen0)
+          && TEST_int_eq(ECDSA_verify(0, dgst, sizeof(dgst), sig, siglen,
+                                      eckey), 1);
     EC_KEY_free(eckey);
+    OPENSSL_free(sig);
+    BN_free(kinv);
+    BN_free(rp);
     return ret;
 }
 
diff --git a/crypto/openssl/test/ecstresstest.c b/crypto/openssl/test/ecstresstest.c
index 22d46c50da2c..237def095c7e 100644
--- a/crypto/openssl/test/ecstresstest.c
+++ b/crypto/openssl/test/ecstresstest.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017-2021 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2017-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -79,7 +79,7 @@ static int test_curve(void)
             || !TEST_ptr(point = EC_POINT_dup(EC_GROUP_get0_generator(group),
                                               group))
             || !TEST_ptr(result = walk_curve(group, point, num_repeats)))
-        return 0;
+        goto err;
 
     if (print_mode) {
         BN_print(bio_out, result);
diff --git a/crypto/openssl/test/evp_extra_test.c b/crypto/openssl/test/evp_extra_test.c
index 6b484f8711ce..7e97e2d34d5d 100644
--- a/crypto/openssl/test/evp_extra_test.c
+++ b/crypto/openssl/test/evp_extra_test.c
@@ -1100,7 +1100,7 @@ static int test_EC_priv_only_legacy(void)
         goto err;
     eckey = NULL;
 
-    while (dup_pk == NULL) {
+    for (;;) {
         ret = 0;
         ctx = EVP_MD_CTX_new();
         if (!TEST_ptr(ctx))
@@ -1116,6 +1116,9 @@ static int test_EC_priv_only_legacy(void)
         EVP_MD_CTX_free(ctx);
         ctx = NULL;
 
+        if (dup_pk != NULL)
+            break;
+
         if (!TEST_ptr(dup_pk = EVP_PKEY_dup(pkey)))
             goto err;
         /* EVP_PKEY_eq() returns -2 with missing public keys */
@@ -1125,6 +1128,7 @@ static int test_EC_priv_only_legacy(void)
         if (!ret)
             goto err;
     }
+    ret = 1;
 
  err:
     EVP_MD_CTX_free(ctx);
@@ -2583,6 +2587,47 @@ static int test_emptyikm_HKDF(void)
     return ret;
 }
 
+static int test_empty_salt_info_HKDF(void)
+{
+    EVP_PKEY_CTX *pctx;
+    unsigned char out[20];
+    size_t outlen;
+    int ret = 0;
+    unsigned char salt[] = "";
+    unsigned char key[] = "012345678901234567890123456789";
+    unsigned char info[] = "";
+    const unsigned char expected[] = {
+	0x67, 0x12, 0xf9, 0x27, 0x8a, 0x8a, 0x3a, 0x8f, 0x7d, 0x2c, 0xa3, 0x6a,
+	0xaa, 0xe9, 0xb3, 0xb9, 0x52, 0x5f, 0xe0, 0x06,
+    };
+    size_t expectedlen = sizeof(expected);
+
+    if (!TEST_ptr(pctx = EVP_PKEY_CTX_new_from_name(testctx, "HKDF", testpropq)))
+        goto done;
+
+    outlen = sizeof(out);
+    memset(out, 0, outlen);
+
+    if (!TEST_int_gt(EVP_PKEY_derive_init(pctx), 0)
+            || !TEST_int_gt(EVP_PKEY_CTX_set_hkdf_md(pctx, EVP_sha256()), 0)
+            || !TEST_int_gt(EVP_PKEY_CTX_set1_hkdf_salt(pctx, salt,
+                                                        sizeof(salt) - 1), 0)
+            || !TEST_int_gt(EVP_PKEY_CTX_set1_hkdf_key(pctx, key,
+                                                       sizeof(key) - 1), 0)
+            || !TEST_int_gt(EVP_PKEY_CTX_add1_hkdf_info(pctx, info,
+                                                        sizeof(info) - 1), 0)
+            || !TEST_int_gt(EVP_PKEY_derive(pctx, out, &outlen), 0)
+            || !TEST_mem_eq(out, outlen, expected, expectedlen))
+        goto done;
+
+    ret = 1;
+
+ done:
+    EVP_PKEY_CTX_free(pctx);
+
+    return ret;
+}
+
 #ifndef OPENSSL_NO_EC
 static int test_X509_PUBKEY_inplace(void)
 {
@@ -5381,6 +5426,7 @@ int setup_tests(void)
 #endif
     ADD_TEST(test_HKDF);
     ADD_TEST(test_emptyikm_HKDF);
+    ADD_TEST(test_empty_salt_info_HKDF);
 #ifndef OPENSSL_NO_EC
     ADD_TEST(test_X509_PUBKEY_inplace);
     ADD_TEST(test_X509_PUBKEY_dup);
diff --git a/crypto/openssl/test/evp_pkey_provided_test.c b/crypto/openssl/test/evp_pkey_provided_test.c
index 27f90e42a7c1..688a8c1c5e55 100644
--- a/crypto/openssl/test/evp_pkey_provided_test.c
+++ b/crypto/openssl/test/evp_pkey_provided_test.c
@@ -389,7 +389,7 @@ static int test_fromdata_rsa(void)
                                           fromdata_params), 1))
         goto err;
 
-    while (dup_pk == NULL) {
+    for (;;) {
         ret = 0;
         if (!TEST_int_eq(EVP_PKEY_get_bits(pk), 32)
             || !TEST_int_eq(EVP_PKEY_get_security_bits(pk), 8)
@@ -417,7 +417,10 @@ static int test_fromdata_rsa(void)
         ret = test_print_key_using_pem("RSA", pk)
               && test_print_key_using_encoder("RSA", pk);
 
-        if (!ret || !TEST_ptr(dup_pk = EVP_PKEY_dup(pk)))
+        if (!ret || dup_pk != NULL)
+            break;
+
+        if (!TEST_ptr(dup_pk = EVP_PKEY_dup(pk)))
             goto err;
         ret = ret && TEST_int_eq(EVP_PKEY_eq(pk, dup_pk), 1);
         EVP_PKEY_free(pk);
@@ -602,7 +605,7 @@ static int test_fromdata_dh_named_group(void)
                                                       &len)))
         goto err;
 
-    while (dup_pk == NULL) {
+    for (;;) {
         ret = 0;
         if (!TEST_int_eq(EVP_PKEY_get_bits(pk), 2048)
             || !TEST_int_eq(EVP_PKEY_get_security_bits(pk), 112)
@@ -682,7 +685,10 @@ static int test_fromdata_dh_named_group(void)
         ret = test_print_key_using_pem("DH", pk)
               && test_print_key_using_encoder("DH", pk);
 
-        if (!ret || !TEST_ptr(dup_pk = EVP_PKEY_dup(pk)))
+        if (!ret || dup_pk != NULL)
+            break;
+
+        if (!TEST_ptr(dup_pk = EVP_PKEY_dup(pk)))
             goto err;
         ret = ret && TEST_int_eq(EVP_PKEY_eq(pk, dup_pk), 1);
         EVP_PKEY_free(pk);
@@ -783,7 +789,7 @@ static int test_fromdata_dh_fips186_4(void)
                                           fromdata_params), 1))
         goto err;
 
-    while (dup_pk == NULL) {
+    for (;;) {
         ret = 0;
         if (!TEST_int_eq(EVP_PKEY_get_bits(pk), 2048)
             || !TEST_int_eq(EVP_PKEY_get_security_bits(pk), 112)
@@ -857,7 +863,10 @@ static int test_fromdata_dh_fips186_4(void)
         ret = test_print_key_using_pem("DH", pk)
               && test_print_key_using_encoder("DH", pk);
 
-        if (!ret || !TEST_ptr(dup_pk = EVP_PKEY_dup(pk)))
+        if (!ret || dup_pk != NULL)
+            break;
+
+        if (!TEST_ptr(dup_pk = EVP_PKEY_dup(pk)))
             goto err;
         ret = ret && TEST_int_eq(EVP_PKEY_eq(pk, dup_pk), 1);
         EVP_PKEY_free(pk);
@@ -1090,7 +1099,7 @@ static int test_fromdata_ecx(int tst)
                                           fromdata_params), 1))
         goto err;
 
-    while (dup_pk == NULL) {
+    for (;;) {
         ret = 0;
         if (!TEST_int_eq(EVP_PKEY_get_bits(pk), bits)
             || !TEST_int_eq(EVP_PKEY_get_security_bits(pk), security_bits)
@@ -1145,7 +1154,10 @@ static int test_fromdata_ecx(int tst)
             ret = test_print_key_using_pem(alg, pk)
                   && test_print_key_using_encoder(alg, pk);
 
-        if (!ret || !TEST_ptr(dup_pk = EVP_PKEY_dup(pk)))
+        if (!ret || dup_pk != NULL)
+            break;
+
+        if (!TEST_ptr(dup_pk = EVP_PKEY_dup(pk)))
             goto err;
         ret = ret && TEST_int_eq(EVP_PKEY_eq(pk, dup_pk), 1);
         EVP_PKEY_free(pk);
@@ -1262,7 +1274,7 @@ static int test_fromdata_ec(void)
                                           fromdata_params), 1))
         goto err;
 
-    while (dup_pk == NULL) {
+    for (;;) {
         ret = 0;
         if (!TEST_int_eq(EVP_PKEY_get_bits(pk), 256)
             || !TEST_int_eq(EVP_PKEY_get_security_bits(pk), 128)
@@ -1301,6 +1313,15 @@ static int test_fromdata_ec(void)
             || !TEST_BN_eq(group_b, b))
             goto err;
 
+        EC_GROUP_free(group);
+        group = NULL;
+        BN_free(group_p);
+        group_p = NULL;
+        BN_free(group_a);
+        group_a = NULL;
+        BN_free(group_b);
+        group_b = NULL;
+
         if (!EVP_PKEY_get_utf8_string_param(pk, OSSL_PKEY_PARAM_GROUP_NAME,
                                             out_curve_name,
                                             sizeof(out_curve_name),
@@ -1329,7 +1350,10 @@ static int test_fromdata_ec(void)
         ret = test_print_key_using_pem(alg, pk)
               && test_print_key_using_encoder(alg, pk);
 
-        if (!ret || !TEST_ptr(dup_pk = EVP_PKEY_dup(pk)))
+        if (!ret || dup_pk != NULL)
+            break;
+
+        if (!TEST_ptr(dup_pk = EVP_PKEY_dup(pk)))
             goto err;
         ret = ret && TEST_int_eq(EVP_PKEY_eq(pk, dup_pk), 1);
         EVP_PKEY_free(pk);
@@ -1575,7 +1599,7 @@ static int test_fromdata_dsa_fips186_4(void)
                                           fromdata_params), 1))
         goto err;
 
-    while (dup_pk == NULL) {
+    for (;;) {
         ret = 0;
         if (!TEST_int_eq(EVP_PKEY_get_bits(pk), 2048)
             || !TEST_int_eq(EVP_PKEY_get_security_bits(pk), 112)
@@ -1624,12 +1648,12 @@ static int test_fromdata_dsa_fips186_4(void)
                                                  &pcounter_out))
             || !TEST_int_eq(pcounter, pcounter_out))
             goto err;
-        BN_free(p);
-        p = NULL;
-        BN_free(q);
-        q = NULL;
-        BN_free(g);
-        g = NULL;
+        BN_free(p_out);
+        p_out = NULL;
+        BN_free(q_out);
+        q_out = NULL;
+        BN_free(g_out);
+        g_out = NULL;
         BN_free(j_out);
         j_out = NULL;
         BN_free(pub_out);
@@ -1657,7 +1681,10 @@ static int test_fromdata_dsa_fips186_4(void)
         ret = test_print_key_using_pem("DSA", pk)
               && test_print_key_using_encoder("DSA", pk);
 
-        if (!ret || !TEST_ptr(dup_pk = EVP_PKEY_dup(pk)))
+        if (!ret || dup_pk != NULL)
+            break;
+
+        if (!TEST_ptr(dup_pk = EVP_PKEY_dup(pk)))
             goto err;
         ret = ret && TEST_int_eq(EVP_PKEY_eq(pk, dup_pk), 1);
         EVP_PKEY_free(pk);
diff --git a/crypto/openssl/test/evp_test.c b/crypto/openssl/test/evp_test.c
index 782841a69258..2701040dabe7 100644
--- a/crypto/openssl/test/evp_test.c
+++ b/crypto/openssl/test/evp_test.c
@@ -2773,30 +2773,33 @@ static int kdf_test_ctrl(EVP_TEST *t, EVP_KDF_CTX *kctx,
     if (!TEST_ptr(name = OPENSSL_strdup(value)))
         return 0;
     p = strchr(name, ':');
-    if (p != NULL)
+    if (p == NULL)
+        p = "";
+    else
         *p++ = '\0';
 
     rv = OSSL_PARAM_allocate_from_text(kdata->p, defs, name, p,
-                                       p != NULL ? strlen(p) : 0, NULL);
+                                       strlen(p), NULL);
     *++kdata->p = OSSL_PARAM_construct_end();
     if (!rv) {
         t->err = "KDF_PARAM_ERROR";
         OPENSSL_free(name);
         return 0;
     }
-    if (p != NULL && strcmp(name, "digest") == 0) {
+    if (strcmp(name, "digest") == 0) {
         if (is_digest_disabled(p)) {
             TEST_info("skipping, '%s' is disabled", p);
             t->skip = 1;
         }
     }
-    if (p != NULL
-        && (strcmp(name, "cipher") == 0
-            || strcmp(name, "cekalg") == 0)
+
+    if ((strcmp(name, "cipher") == 0
+        || strcmp(name, "cekalg") == 0)
         && is_cipher_disabled(p)) {
         TEST_info("skipping, '%s' is disabled", p);
         t->skip = 1;
     }
+
     OPENSSL_free(name);
     return 1;
 }
diff --git a/crypto/openssl/test/helpers/ssltestlib.c b/crypto/openssl/test/helpers/ssltestlib.c
index ef4a6177aa7d..b0ef7d719c53 100644
--- a/crypto/openssl/test/helpers/ssltestlib.c
+++ b/crypto/openssl/test/helpers/ssltestlib.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016-2023 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2016-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -7,8 +7,17 @@
  * https://www.openssl.org/source/license.html
  */
 
+/*
+ * We need access to the deprecated low level ENGINE APIs for legacy purposes
+ * when the deprecated calls are not hidden
+ */
+#ifndef OPENSSL_NO_DEPRECATED_3_0
+# define OPENSSL_SUPPRESS_DEPRECATED
+#endif
+
 #include <string.h>
 
+#include <openssl/engine.h>
 #include "internal/nelem.h"
 #include "ssltestlib.h"
 #include "../testutil.h"
@@ -1182,3 +1191,27 @@ void shutdown_ssl_connection(SSL *serverssl, SSL *clientssl)
     SSL_free(serverssl);
     SSL_free(clientssl);
 }
+
+ENGINE *load_dasync(void)
+{
+#if !defined(OPENSSL_NO_TLS1_2) && !defined(OPENSSL_NO_DYNAMIC_ENGINE)
+    ENGINE *e;
+
+    if (!TEST_ptr(e = ENGINE_by_id("dasync")))
+        return NULL;
+
+    if (!TEST_true(ENGINE_init(e))) {
+        ENGINE_free(e);
+        return NULL;
+    }
+
+    if (!TEST_true(ENGINE_register_ciphers(e))) {
+        ENGINE_free(e);
+        return NULL;
+    }
+
+    return e;
+#else
+    return NULL;
+#endif
+}
diff --git a/crypto/openssl/test/helpers/ssltestlib.h b/crypto/openssl/test/helpers/ssltestlib.h
index 8e9daa5601d3..0fbca34afa75 100644
--- a/crypto/openssl/test/helpers/ssltestlib.h
+++ b/crypto/openssl/test/helpers/ssltestlib.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016-2023 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2016-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -59,4 +59,5 @@ typedef struct mempacket_st MEMPACKET;
 
 DEFINE_STACK_OF(MEMPACKET)
 
+ENGINE *load_dasync(void);
 #endif /* OSSL_TEST_SSLTESTLIB_H */
diff --git a/crypto/openssl/test/keymgmt_internal_test.c b/crypto/openssl/test/keymgmt_internal_test.c
index ce2e458f8c31..8d5aa22dab3e 100644
--- a/crypto/openssl/test/keymgmt_internal_test.c
+++ b/crypto/openssl/test/keymgmt_internal_test.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2019-2022 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2019-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -224,7 +224,7 @@ static int test_pass_rsa(FIXTURE *fixture)
         || !TEST_ptr_ne(km1, km2))
         goto err;
 
-    while (dup_pk == NULL) {
+    for (;;) {
         ret = 0;
         km = km3;
         /* Check that we can't export an RSA key into an RSA-PSS keymanager */
@@ -255,7 +255,11 @@ static int test_pass_rsa(FIXTURE *fixture)
         }
 
         ret = (ret == OSSL_NELEM(expected));
-        if (!ret || !TEST_ptr(dup_pk = EVP_PKEY_dup(pk)))
+
+        if (!ret || dup_pk != NULL)
+            break;
+
+        if (!TEST_ptr(dup_pk = EVP_PKEY_dup(pk)))
             goto err;
 
         ret = TEST_int_eq(EVP_PKEY_eq(pk, dup_pk), 1);
diff --git a/crypto/openssl/test/pathed.cnf b/crypto/openssl/test/pathed.cnf
new file mode 100644
index 000000000000..07bdc1fdb209
--- /dev/null
+++ b/crypto/openssl/test/pathed.cnf
@@ -0,0 +1,22 @@
+openssl_conf = openssl_init
+
+# Comment out the next line to ignore configuration errors
+config_diagnostics = 1
+
+[openssl_init]
+providers = provider_sect
+
+[provider_sect]
+default = default_sect
+legacy  = legacy_sect
+test    = test_sect
+
+[test_sect]
+module = ../test/p_test.so
+activate = false
+
+[default_sect]
+activate = true
+
+[legacy_sect]
+activate = false
diff --git a/crypto/openssl/test/pkey_meth_kdf_test.c b/crypto/openssl/test/pkey_meth_kdf_test.c
index f816d24fb56f..ad58adf48261 100644
--- a/crypto/openssl/test/pkey_meth_kdf_test.c
+++ b/crypto/openssl/test/pkey_meth_kdf_test.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2017-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -16,7 +16,7 @@
 #include <openssl/kdf.h>
 #include "testutil.h"
 
-static int test_kdf_tls1_prf(void)
+static int test_kdf_tls1_prf(int index)
 {
     int ret = 0;
     EVP_PKEY_CTX *pctx;
@@ -40,10 +40,23 @@ static int test_kdf_tls1_prf(void)
         TEST_error("EVP_PKEY_CTX_set1_tls1_prf_secret");
         goto err;
     }
-    if (EVP_PKEY_CTX_add1_tls1_prf_seed(pctx,
-                                        (unsigned char *)"seed", 4) <= 0) {
-        TEST_error("EVP_PKEY_CTX_add1_tls1_prf_seed");
-        goto err;
+    if (index == 0) {
+        if (EVP_PKEY_CTX_add1_tls1_prf_seed(pctx,
+                                            (unsigned char *)"seed", 4) <= 0) {
+            TEST_error("EVP_PKEY_CTX_add1_tls1_prf_seed");
+            goto err;
+        }
+    } else {
+        if (EVP_PKEY_CTX_add1_tls1_prf_seed(pctx,
+                                            (unsigned char *)"se", 2) <= 0) {
+            TEST_error("EVP_PKEY_CTX_add1_tls1_prf_seed");
+            goto err;
+        }
+        if (EVP_PKEY_CTX_add1_tls1_prf_seed(pctx,
+                                            (unsigned char *)"ed", 2) <= 0) {
+            TEST_error("EVP_PKEY_CTX_add1_tls1_prf_seed");
+            goto err;
+        }
     }
     if (EVP_PKEY_derive(pctx, out, &outlen) <= 0) {
         TEST_error("EVP_PKEY_derive");
@@ -65,7 +78,7 @@ static int test_kdf_tls1_prf(void)
     return ret;
 }
 
-static int test_kdf_hkdf(void)
+static int test_kdf_hkdf(int index)
 {
     int ret = 0;
     EVP_PKEY_CTX *pctx;
@@ -94,10 +107,23 @@ static int test_kdf_hkdf(void)
         TEST_error("EVP_PKEY_CTX_set1_hkdf_key");
         goto err;
     }
-    if (EVP_PKEY_CTX_add1_hkdf_info(pctx, (const unsigned char *)"label", 5)
+    if (index == 0) {
+        if (EVP_PKEY_CTX_add1_hkdf_info(pctx, (const unsigned char *)"label", 5)
             <= 0) {
-        TEST_error("EVP_PKEY_CTX_set1_hkdf_info");
-        goto err;
+            TEST_error("EVP_PKEY_CTX_add1_hkdf_info");
+            goto err;
+        }
+    } else {
+        if (EVP_PKEY_CTX_add1_hkdf_info(pctx, (const unsigned char *)"lab", 3)
+            <= 0) {
+            TEST_error("EVP_PKEY_CTX_add1_hkdf_info");
+            goto err;
+        }
+        if (EVP_PKEY_CTX_add1_hkdf_info(pctx, (const unsigned char *)"el", 2)
+            <= 0) {
+            TEST_error("EVP_PKEY_CTX_add1_hkdf_info");
+            goto err;
+        }
     }
     if (EVP_PKEY_derive(pctx, out, &outlen) <= 0) {
         TEST_error("EVP_PKEY_derive");
@@ -195,8 +221,13 @@ static int test_kdf_scrypt(void)
 
 int setup_tests(void)
 {
-    ADD_TEST(test_kdf_tls1_prf);
-    ADD_TEST(test_kdf_hkdf);
+    int tests = 1;
+
+    if (fips_provider_version_ge(NULL, 3, 3, 1))
+        tests = 2;
+
+    ADD_ALL_TESTS(test_kdf_tls1_prf, tests);
+    ADD_ALL_TESTS(test_kdf_hkdf, tests);
 #ifndef OPENSSL_NO_SCRYPT
     ADD_TEST(test_kdf_scrypt);
 #endif
diff --git a/crypto/openssl/test/prov_config_test.c b/crypto/openssl/test/prov_config_test.c
index b44ec78d8d24..f93d8d62be6a 100644
--- a/crypto/openssl/test/prov_config_test.c
+++ b/crypto/openssl/test/prov_config_test.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2021 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2021-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -7,12 +7,14 @@
  * https://www.openssl.org/source/license.html
  */
 
+#include <sys/stat.h>
 #include <openssl/evp.h>
 #include <openssl/conf.h>
 #include "testutil.h"
 
 static char *configfile = NULL;
 static char *recurseconfigfile = NULL;
+static char *pathedconfig = NULL;
 
 /*
  * Test to make sure there are no leaks or failures from loading the config
@@ -70,6 +72,54 @@ static int test_recursive_config(void)
     return testresult;
 }
 
+#define P_TEST_PATH "/../test/p_test.so"
+static int test_path_config(void)
+{
+    OSSL_LIB_CTX *ctx = NULL;
+    OSSL_PROVIDER *prov;
+    int testresult = 0;
+    struct stat sbuf;
+    char *module_path = getenv("OPENSSL_MODULES");
+    char *full_path = NULL;
+    int rc;
+
+    if (!TEST_ptr(module_path))
+        return 0;
+
+    full_path = OPENSSL_zalloc(strlen(module_path) + strlen(P_TEST_PATH) + 1);
+    if (!TEST_ptr(full_path))
+        return 0;
+
+    strcpy(full_path, module_path);
+    full_path = strcat(full_path, P_TEST_PATH);
+    TEST_info("full path is %s", full_path);
+    rc = stat(full_path, &sbuf);
+    OPENSSL_free(full_path);
+    if (rc == -1)
+        return TEST_skip("Skipping modulepath test as provider not present");
+
+    if (!TEST_ptr(pathedconfig))
+        return 0;
+
+    ctx = OSSL_LIB_CTX_new();
+    if (!TEST_ptr(ctx))
+        return 0;
+
+    if (!TEST_true(OSSL_LIB_CTX_load_config(ctx, pathedconfig)))
+        goto err;
+
+    /* attempt to manually load the test provider */
+    if (!TEST_ptr(prov = OSSL_PROVIDER_load(ctx, "test")))
+        goto err;
+
+    OSSL_PROVIDER_unload(prov);
+
+    testresult = 1;
+ err:
+    OSSL_LIB_CTX_free(ctx);
+    return testresult;
+}
+
 OPT_TEST_DECLARE_USAGE("configfile\n")
 
 int setup_tests(void)
@@ -85,7 +135,11 @@ int setup_tests(void)
     if (!TEST_ptr(recurseconfigfile = test_get_argument(1)))
         return 0;
 
+    if (!TEST_ptr(pathedconfig = test_get_argument(2)))
+        return 0;
+
     ADD_TEST(test_recursive_config);
     ADD_TEST(test_double_config);
+    ADD_TEST(test_path_config);
     return 1;
 }
diff --git a/crypto/openssl/test/recipes/15-test_dsaparam_data/invalid/p10240_q256_too_big.pem b/crypto/openssl/test/recipes/15-test_dsaparam_data/invalid/p10240_q256_too_big.pem
new file mode 100644
index 000000000000..e85e2953b7a2
--- /dev/null
+++ b/crypto/openssl/test/recipes/15-test_dsaparam_data/invalid/p10240_q256_too_big.pem
@@ -0,0 +1,57 @@
+-----BEGIN DSA PARAMETERS-----
+MIIKLAKCBQEAym47LzPFZdbz16WvjczLKuzLtsP8yRk/exxL4bBthJhP1qOwctja
+p1586SF7gDxCMn7yWVEYdfRbFefGoq0gj1XOE917XqlbnkmZhMgxut2KbNJo/xil
+XNFUjGvKs3F413U9rAodC8f07cWHP1iTcWL+vPe6u2yilKWYYfnLWHQH+Z6aPrrF
+x/R08LI6DZ6nEsIo+hxaQnEtx+iqNTJC6Q1RIjWDqxQkFVTkJ0Y7miRDXmRdneWk
+oLrMZRpaXr5l5tSjEghh1pBgJcdyOv0lh4dlDy/alAiqE2Qlb667yHl6A9dDPlpW
+dAntpffy4LwOxfbuEhISvKjjQoBwIvYE4TBPqL0Q6bC6HgQ4+tqd9b44pQjdIQjb
+Xcjc6azheITSnPEex3OdKtKoQeRq01qCeLBpMXu1c+CTf4ApKArZvT3vZSg0hM1O
+pR71bRZrEEegDj0LH2HCgI5W6H3blOS9A0kUTddCoQXr2lsVdiPtRbPKH1gcd9FQ
+P8cGrvbakpTiC0dCczOMDaCteM1QNILlkM7ZoV6VghsKvDnFPxFsiIr5GgjasXP5
+hhbn3g7sDoq1LiTEo+IKQY28pBWx7etSOSRuXW/spnvCkivZla7lSEGljoy9QlQ2
+UZmsEQI9G3YyzgpxHvKZBK1CiZVTywdYKTZ4TYCxvqzhYhjv2bqbpjI12HRFLojB
+koyEmMSp53lldCzp158PrIanqSp2rksMR8SmmCL3FwfAp2OjqFMEglG9DT8x0WaN
+TLSkjGC6t2csMte7WyU1ekNoFDKfMjDSAz0+xIx21DEmZtYqFOg1DNPK1xYLS0pl
+RSMRRkJVN2mk/G7/1oxlB8Wb9wgi3GKUqqCYT11SnBjzq0NdoJ3E4GMedp5Lx3AZ
+4mFuRPUd4iV86tE0XDSHSFE7Y3ZkrOjD7Q/26/L53L/UH5z4HW6CHP5os7QERJjg
+c1S3x87wXWo9QXbB9b2xmf+c+aWwAAr1cviw38tru58jF3/IGyduj9H8claKQqBG
+cIOUF4aNe1hK2K3ArAOApUxr4KE+tCvrltRfiTmVFip0g9Jt1CPY3Zu7Bd4Z2ZkE
+DtSztpwa49HrWF5E9xpquvBL2U8jQ68E7Xd8Wp4orI/TIChriamBmdkgRz3H2LvN
+Ozb6+hsnEGrz3sp2RVAToSqA9ysa6nHZdfufPNtMEbQdO/k1ehmGRb0ljBRsO6b2
+rsG2eYuC8tg8eCrIkua0TGRI7g6a4K32AJdzaX6NsISaaIW+OYJuoDSscvD3oOg8
+PPEhU+zM7xJskTA+jxvPlikKx8V7MNHOCQECldJlUBwzJvqp40JvwfnDsF+8VYwd
+UaiieR3pzMzyTjpReXRmZbnRPusRcsVzxb2OhB79wmuy4UPjjQBX+7eD0rs8xxvW
+5a5q1Cjq4AvbwmmcA/wDrHDOjcbD/zodad2O1QtBWa/R4xyWea4zKsflgACE1zY9
+wW2br7+YQFekcrXkkkEzgxd6zxv8KVEDpXRZjmAM1cI5LvkoN64To4GedN8Qe/G7
+R9SZh9gnS17PTP64hK+aYqhFafMdu87q/+qLfxaSux727qE5hiW01u4nnWhACf9s
+xuOozowKqxZxkolMIyZv6Lddwy1Zv5qjCyd0DvM/1skpXWkb9kfabYC+OhjsjVhs
+0Ktfs6a5B3eixiw5x94hhIcTEcS4hmvhGUL72FiTca6ZeSERTKmNBy8CIQC9/ZUN
+uU/V5JTcnYyUGHzm7+XcZBjyGBagBj9rCmW3SQKCBQAJ/k9rb39f1cO+/3XDEMjy
+9bIEXSuS48g5RAc1UGd5nrrBQwuDxGWFyz0yvAY7LgyidZuJS21+MAp9EY7AOMmx
+TDttifNaBJYt4GZ8of166PcqTKkHQwq5uBpxeSDv/ZE8YbYfaCtLTcUC8KlO+l36
+gjJHSkdkflSsGy1yObSNDQDfVAAwQs//TjDMnuEtvlNXZllsTvFFBceXVETn10K2
+ZMmdSIJNfLnjReUKEN6PfeGqv7F4xoyGwUybEfRE4u5RmXrqCODaIjY3SNMrOq8B
+R3Ata/cCozsM1jIdIW2z+OybDJH+BYsYm2nkSZQjZS6javTYClLrntEKG/hAQwL8
+F16YLOQXpHhgiAaWnTZzANtLppB2+5qCVy5ElzKongOwT8JTjTFXOaRnqe/ngm9W
+SSbrxfDaoWUOyK9XD8Cydzpv3n4Y8nWNGayi7/yAFCU36Ri040ufgv/TZLuKacnl
++3ga3ZUpRlSigzx0kb1+KjTSWeQ8vE/psdWjvBukVEbzdUauMLyRLo/6znSVvvPX
+UGhviThE5uhrsUg+wEPFINriSHfF7JDKVhDcJnLBdaXvfN52pkF/naLBF5Rt3Gvq
+fjCxjx0Sy9Lag1hDN4dor7dzuO7wmwOS01DJW1PtNLuuH0Bbqh1kYSaQkmyXBZWX
+qo8K3nkoDM0niOtJJubOhTNrGmSaZpNXkK3Mcy9rBbdvEs5O0Jmqaax/eOdU0Yot
+B3lX+3ddOseT2ZEFjzObqTtkWuFBeBxuYNcRTsu3qMdIBsEb8URQdsTtjoIja2fK
+hreVgjK36GW70KXEl8V/vq5qjQulmqkBEjmilcDuiREKqQuyeagUOnhQaBplqVco
+4xznh5DMBMRbpGb5lHxKv4cPNi+uNAJ5i98zWUM1JRt6aXnRCuWcll1z8fRZ+5kD
+vK9FaZU3VRMK/eknEG49cGr8OuJ6ZRSaC+tKwV1y+amkSZpKPWnk2bUnQI3ApJv3
+k1e1EToeECpMUkLMDgNbpKBoz4nqMEvAAlYgw9xKNbLlQlahqTVEAmaJHh4yDMDy
+i7IZ9Wrn47IGoR7s3cvhDHUpRPeW4nsmgzj+tf5EAxemI61STZJTTWo0iaPGJxct
+9nhOOhw1I38Mvm4vkAbFH7YJ0B6QrjjYL2MbOTp5JiIh4vdOeWwNo9/y4ffyaN5+
+ADpxuuIAmcbdr6GPOhkOFFixRJa0B2eP1i032HESlLs8RB9oYtdTXdXQotnIgJGd
+Y8tSKOa1zjzeLHn3AVpRZTUW++/BxmApV3GKIeG8fsUjg/df0QRrBcdC/1uccdaG
+KKlAOwlywVn5jUlwHkTmDiTM9w5AqVVGHZ2b+4ZgQW8jnPKN0SrKf6U555D+zp7E
+x4uXoE8ojN9y8m8UKf0cTLnujH2XgZorjPfuMOt5VZEhQFMS2QaljSeni5CJJ8gk
+XtztNqfBlAtWR4V5iAHeQOfIB2YaOy8GESda89tyKraKeaez41VblpTVHTeq9IIF
+YB4cQA2PfuNaGVRGLMAgT3Dvl+mxxxeJyxnGAiUcETU/jJJt9QombiuszBlYGQ5d
+ELOSm/eQSRARV9zNSt5jaQlMSjMBqenIEM09BzYqa7jDwqoztFxNdO8bcuQPuKwa
+4z3bBZ1yYm63WFdNbQqqGEwc0OYmqg1raJ0zltgHyjFyw8IGu4g/wETs+nVQcH7D
+vKuje86bePD6kD/LH3wmkA==
+-----END DSA PARAMETERS-----
diff --git a/crypto/openssl/test/recipes/25-test_req.t b/crypto/openssl/test/recipes/25-test_req.t
index fe02d29c634f..932635f4b2c1 100644
--- a/crypto/openssl/test/recipes/25-test_req.t
+++ b/crypto/openssl/test/recipes/25-test_req.t
@@ -15,7 +15,7 @@ use OpenSSL::Test qw/:DEFAULT srctop_file/;
 
 setup("test_req");
 
-plan tests => 49;
+plan tests => 50;
 
 require_ok(srctop_file('test', 'recipes', 'tconversion.pl'));
 
@@ -53,6 +53,7 @@ ok(!run(app([@addext_args, "-addext", $val, "-addext", $val2])));
 ok(!run(app([@addext_args, "-addext", $val, "-addext", $val3])));
 ok(!run(app([@addext_args, "-addext", $val2, "-addext", $val3])));
 ok(run(app([@addext_args, "-addext", "SXNetID=1:one, 2:two, 3:three"])));
+ok(run(app([@addext_args, "-addext", "subjectAltName=dirName:dirname_sec"])));
 
 # If a CSR is provided with neither of -key or -CA/-CAkey, this should fail.
 ok(!run(app(["openssl", "req", "-x509",
diff --git a/crypto/openssl/test/recipes/30-test_prov_config.t b/crypto/openssl/test/recipes/30-test_prov_config.t
index 7f6350fd84e1..1ef8736209c6 100644
--- a/crypto/openssl/test/recipes/30-test_prov_config.t
+++ b/crypto/openssl/test/recipes/30-test_prov_config.t
@@ -1,5 +1,5 @@
 #! /usr/bin/env perl
-# Copyright 2021 The OpenSSL Project Authors. All Rights Reserved.
+# Copyright 2021-2024 The OpenSSL Project Authors. All Rights Reserved.
 #
 # Licensed under the Apache License 2.0 (the "License").  You may not use
 # this file except in compliance with the License.  You can obtain a copy
@@ -23,13 +23,15 @@ my $no_fips = disabled('fips') || ($ENV{NO_FIPS} // 0);
 plan tests => 2;
 
 ok(run(test(["prov_config_test", srctop_file("test", "default.cnf"),
-                                 srctop_file("test", "recursive.cnf")])),
+                                 srctop_file("test", "recursive.cnf"),
+                                 srctop_file("test", "pathed.cnf")])),
     "running prov_config_test default.cnf");
 
 SKIP: {
     skip "Skipping FIPS test in this build", 1 if $no_fips;
 
     ok(run(test(["prov_config_test", srctop_file("test", "fips.cnf"),
-                                     srctop_file("test", "recursive.cnf")])),
+                                     srctop_file("test", "recursive.cnf"),
+                                     srctop_file("test", "pathed.cnf")])),
        "running prov_config_test fips.cnf");
 }
diff --git a/crypto/openssl/test/recipes/80-test_pkcs12.t b/crypto/openssl/test/recipes/80-test_pkcs12.t
index 4c5bb5744b8c..de26cbdca4dc 100644
--- a/crypto/openssl/test/recipes/80-test_pkcs12.t
+++ b/crypto/openssl/test/recipes/80-test_pkcs12.t
@@ -54,7 +54,7 @@ if (eval { require Win32::API; 1; }) {
 }
 $ENV{OPENSSL_WIN32_UTF8}=1;
 
-plan tests => 17;
+plan tests => 20;
 
 # Test different PKCS#12 formats
 ok(run(test(["pkcs12_format_test"])), "test pkcs12 formats");
@@ -162,11 +162,23 @@ with({ exit_checker => sub { return shift == 1; } },
                     "-nomacver"])),
            "test bad pkcs12 file 1 (nomacver)");
 
+        ok(run(app(["openssl", "pkcs12", "-in", $bad1, "-password", "pass:",
+                    "-info"])),
+           "test bad pkcs12 file 1 (info)");
+
         ok(run(app(["openssl", "pkcs12", "-in", $bad2, "-password", "pass:"])),
            "test bad pkcs12 file 2");
 
+        ok(run(app(["openssl", "pkcs12", "-in", $bad2, "-password", "pass:",
+                    "-info"])),
+           "test bad pkcs12 file 2 (info)");
+
         ok(run(app(["openssl", "pkcs12", "-in", $bad3, "-password", "pass:"])),
            "test bad pkcs12 file 3");
+
+        ok(run(app(["openssl", "pkcs12", "-in", $bad3, "-password", "pass:",
+                    "-info"])),
+           "test bad pkcs12 file 3 (info)");
      });
 
 SetConsoleOutputCP($savedcp) if (defined($savedcp));
diff --git a/crypto/openssl/test/recipes/90-test_shlibload.t b/crypto/openssl/test/recipes/90-test_shlibload.t
index 8f691dee38e8..67afff607e04 100644
--- a/crypto/openssl/test/recipes/90-test_shlibload.t
+++ b/crypto/openssl/test/recipes/90-test_shlibload.t
@@ -1,5 +1,5 @@
 #! /usr/bin/env perl
-# Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved.
+# Copyright 2016-2024 The OpenSSL Project Authors. All Rights Reserved.
 #
 # Licensed under the Apache License 2.0 (the "License").  You may not use
 # this file except in compliance with the License.  You can obtain a copy
@@ -23,6 +23,7 @@ plan skip_all => "Test is disabled on AIX" if config('target') =~ m|^aix|;
 plan skip_all => "Test is disabled on NonStop" if config('target') =~ m|^nonstop|;
 plan skip_all => "Test only supported in a dso build" if disabled("dso");
 plan skip_all => "Test is disabled in an address sanitizer build" unless disabled("asan");
+plan skip_all => "Test is disabled in no-atexit build" if disabled("atexit");
 
 plan tests => 10;
 
diff --git a/crypto/openssl/test/sm2_internal_test.c b/crypto/openssl/test/sm2_internal_test.c
index 4899d5e21313..bd0bf0efa74d 100644
--- a/crypto/openssl/test/sm2_internal_test.c
+++ b/crypto/openssl/test/sm2_internal_test.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017-2021 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2017-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -305,7 +305,8 @@ static int test_sm2_sign(const EC_GROUP *group,
                          const char *message,
                          const char *k_hex,
                          const char *r_hex,
-                         const char *s_hex)
+                         const char *s_hex,
+                         int omit_pubkey)
 {
     const size_t msg_len = strlen(message);
     int ok = 0;
@@ -327,11 +328,13 @@ static int test_sm2_sign(const EC_GROUP *group,
             || !TEST_true(EC_KEY_set_private_key(key, priv)))
         goto done;
 
-    pt = EC_POINT_new(group);
-    if (!TEST_ptr(pt)
-            || !TEST_true(EC_POINT_mul(group, pt, priv, NULL, NULL, NULL))
-            || !TEST_true(EC_KEY_set_public_key(key, pt)))
-        goto done;
+    if (omit_pubkey == 0) {
+        pt = EC_POINT_new(group);
+        if (!TEST_ptr(pt)
+                || !TEST_true(EC_POINT_mul(group, pt, priv, NULL, NULL, NULL))
+                || !TEST_true(EC_KEY_set_public_key(key, pt)))
+            goto done;
+    }
 
     start_fake_rand(k_hex);
     sig = ossl_sm2_do_sign(key, EVP_sm3(), (const uint8_t *)userid,
@@ -392,7 +395,25 @@ static int sm2_sig_test(void)
                         "006CB28D99385C175C94F94E934817663FC176D925DD72B727260DBAAE1FB2F96F"
                         "007c47811054c6f99613a578eb8453706ccb96384fe7df5c171671e760bfa8be3a",
                         "40F1EC59F793D9F49E09DCEF49130D4194F79FB1EED2CAA55BACDB49C4E755D1",
-                        "6FC6DAC32C5D5CF10C77DFB20F7C2EB667A457872FB09EC56327A67EC7DEEBE7")))
+                        "6FC6DAC32C5D5CF10C77DFB20F7C2EB667A457872FB09EC56327A67EC7DEEBE7", 0)))
+        goto done;
+
+    /* Make sure we fail if we omit the public portion of the key */
+    if (!TEST_false(test_sm2_sign(
+                     test_group,
+                     /* the default ID specified in GM/T 0009-2012 (Sec. 10).*/
+                     SM2_DEFAULT_USERID,
+                     /* privkey */
+                     "3945208F7B2144B13F36E38AC6D39F95889393692860B51A42FB81EF4DF7C5B8",
+                     /* plaintext message */
+                     "message digest",
+                     /* ephemeral nonce k */
+                     "59276E27D506861A16680F3AD9C02DCCEF3CC1FA3CDBE4CE6D54B80DEAC1BC21",
+                     /* expected signature, */
+                     /* signature R, 0x20 bytes */
+                     "F5A03B0648D2C4630EEAC513E1BB81A15944DA3827D5B74143AC7EACEEE720B3",
+                     /* signature S, 0x20 bytes */
+                     "B1B6AA29DF212FD8763182BC0D421CA1BB9038FD1F7F42D4840B69C485BBC1AA", 1)))
         goto done;
 
     testresult = 1;
diff --git a/crypto/openssl/test/ssl-tests/14-curves.cnf.in b/crypto/openssl/test/ssl-tests/14-curves.cnf.in
index 1e003bace0b7..33201df281f7 100644
--- a/crypto/openssl/test/ssl-tests/14-curves.cnf.in
+++ b/crypto/openssl/test/ssl-tests/14-curves.cnf.in
@@ -12,8 +12,11 @@ use OpenSSL::Test::Utils qw(anydisabled);
 
 our $fips_mode;
 
-my @curves = ("prime256v1", "secp384r1", "secp521r1", "X25519",
-              "X448");
+my @curves = ("prime256v1", "secp384r1", "secp521r1");
+
+my @curves_no_fips = ("X25519", "X448");
+
+push @curves, @curves_no_fips if !$fips_mode;
 
 #Curves *only* suitable for use in TLSv1.3
 my @curves_tls_1_3 = ("ffdhe2048", "ffdhe3072", "ffdhe4096", "ffdhe6144",
diff --git a/crypto/openssl/test/ssl-tests/20-cert-select.cnf b/crypto/openssl/test/ssl-tests/20-cert-select.cnf
index 79dcd4c8f4e2..6888d538ba35 100644
--- a/crypto/openssl/test/ssl-tests/20-cert-select.cnf
+++ b/crypto/openssl/test/ssl-tests/20-cert-select.cnf
@@ -19,12 +19,12 @@ test-13 = 13-Suite B P-256 Hash Algorithm Selection
 test-14 = 14-Suite B P-384 Hash Algorithm Selection
 test-15 = 15-Ed25519 CipherString and Signature Algorithm Selection
 test-16 = 16-Ed448 CipherString and Signature Algorithm Selection
-test-17 = 17-Ed25519 CipherString and Curves Selection
-test-18 = 18-Ed448 CipherString and Curves Selection
-test-19 = 19-TLS 1.2 Ed25519 Client Auth
-test-20 = 20-TLS 1.2 Ed448 Client Auth
-test-21 = 21-ECDSA Signature Algorithm Selection SHA1
-test-22 = 22-ECDSA with brainpool
+test-17 = 17-TLS 1.2 Ed25519 Client Auth
+test-18 = 18-TLS 1.2 Ed448 Client Auth
+test-19 = 19-ECDSA Signature Algorithm Selection SHA1
+test-20 = 20-ECDSA with brainpool
+test-21 = 21-Ed25519 CipherString and Curves Selection
+test-22 = 22-Ed448 CipherString and Curves Selection
 test-23 = 23-RSA-PSS Certificate CipherString Selection
 test-24 = 24-RSA-PSS Certificate Legacy Signature Algorithm Selection
 test-25 = 25-RSA-PSS Certificate Unified Signature Algorithm Selection
@@ -602,91 +602,21 @@ ExpectedServerSignType = Ed448
 
 # ===========================================================
 
-[17-Ed25519 CipherString and Curves Selection]
-ssl_conf = 17-Ed25519 CipherString and Curves Selection-ssl
+[17-TLS 1.2 Ed25519 Client Auth]
+ssl_conf = 17-TLS 1.2 Ed25519 Client Auth-ssl
 
-[17-Ed25519 CipherString and Curves Selection-ssl]
-server = 17-Ed25519 CipherString and Curves Selection-server
-client = 17-Ed25519 CipherString and Curves Selection-client
+[17-TLS 1.2 Ed25519 Client Auth-ssl]
+server = 17-TLS 1.2 Ed25519 Client Auth-server
+client = 17-TLS 1.2 Ed25519 Client Auth-client
 
-[17-Ed25519 CipherString and Curves Selection-server]
-Certificate = ${ENV::TEST_CERTS_DIR}/servercert.pem
-CipherString = DEFAULT
-ECDSA.Certificate = ${ENV::TEST_CERTS_DIR}/server-ecdsa-cert.pem
-ECDSA.PrivateKey = ${ENV::TEST_CERTS_DIR}/server-ecdsa-key.pem
-Ed25519.Certificate = ${ENV::TEST_CERTS_DIR}/server-ed25519-cert.pem
-Ed25519.PrivateKey = ${ENV::TEST_CERTS_DIR}/server-ed25519-key.pem
-Ed448.Certificate = ${ENV::TEST_CERTS_DIR}/server-ed448-cert.pem
-Ed448.PrivateKey = ${ENV::TEST_CERTS_DIR}/server-ed448-key.pem
-MaxProtocol = TLSv1.2
-PrivateKey = ${ENV::TEST_CERTS_DIR}/serverkey.pem
-
-[17-Ed25519 CipherString and Curves Selection-client]
-CipherString = aECDSA
-Curves = X25519
-MaxProtocol = TLSv1.2
-SignatureAlgorithms = ECDSA+SHA256:ed25519
-VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem
-VerifyMode = Peer
-
-[test-17]
-ExpectedResult = Success
-ExpectedServerCertType = Ed25519
-ExpectedServerSignType = Ed25519
-
-
-# ===========================================================
-
-[18-Ed448 CipherString and Curves Selection]
-ssl_conf = 18-Ed448 CipherString and Curves Selection-ssl
-
-[18-Ed448 CipherString and Curves Selection-ssl]
-server = 18-Ed448 CipherString and Curves Selection-server
-client = 18-Ed448 CipherString and Curves Selection-client
-
-[18-Ed448 CipherString and Curves Selection-server]
-Certificate = ${ENV::TEST_CERTS_DIR}/servercert.pem
-CipherString = DEFAULT
-ECDSA.Certificate = ${ENV::TEST_CERTS_DIR}/server-ecdsa-cert.pem
-ECDSA.PrivateKey = ${ENV::TEST_CERTS_DIR}/server-ecdsa-key.pem
-Ed25519.Certificate = ${ENV::TEST_CERTS_DIR}/server-ed25519-cert.pem
-Ed25519.PrivateKey = ${ENV::TEST_CERTS_DIR}/server-ed25519-key.pem
-Ed448.Certificate = ${ENV::TEST_CERTS_DIR}/server-ed448-cert.pem
-Ed448.PrivateKey = ${ENV::TEST_CERTS_DIR}/server-ed448-key.pem
-MaxProtocol = TLSv1.2
-PrivateKey = ${ENV::TEST_CERTS_DIR}/serverkey.pem
-
-[18-Ed448 CipherString and Curves Selection-client]
-CipherString = aECDSA
-Curves = X448
-MaxProtocol = TLSv1.2
-SignatureAlgorithms = ECDSA+SHA256:ed448
-VerifyCAFile = ${ENV::TEST_CERTS_DIR}/root-ed448-cert.pem
-VerifyMode = Peer
-
-[test-18]
-ExpectedResult = Success
-ExpectedServerCertType = Ed448
-ExpectedServerSignType = Ed448
-
-
-# ===========================================================
-
-[19-TLS 1.2 Ed25519 Client Auth]
-ssl_conf = 19-TLS 1.2 Ed25519 Client Auth-ssl
-
-[19-TLS 1.2 Ed25519 Client Auth-ssl]
-server = 19-TLS 1.2 Ed25519 Client Auth-server
-client = 19-TLS 1.2 Ed25519 Client Auth-client
-
-[19-TLS 1.2 Ed25519 Client Auth-server]
+[17-TLS 1.2 Ed25519 Client Auth-server]
 Certificate = ${ENV::TEST_CERTS_DIR}/servercert.pem
 CipherString = DEFAULT
 PrivateKey = ${ENV::TEST_CERTS_DIR}/serverkey.pem
 VerifyCAFile = ${ENV::TEST_CERTS_DIR}/root-cert.pem
 VerifyMode = Require
 
-[19-TLS 1.2 Ed25519 Client Auth-client]
+[17-TLS 1.2 Ed25519 Client Auth-client]
 CipherString = DEFAULT
 Ed25519.Certificate = ${ENV::TEST_CERTS_DIR}/client-ed25519-cert.pem
 Ed25519.PrivateKey = ${ENV::TEST_CERTS_DIR}/client-ed25519-key.pem
@@ -695,7 +625,7 @@ MinProtocol = TLSv1.2
 VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem
 VerifyMode = Peer
 
-[test-19]
+[test-17]
 ExpectedClientCertType = Ed25519
 ExpectedClientSignType = Ed25519
 ExpectedResult = Success
@@ -703,21 +633,21 @@ ExpectedResult = Success
 
 # ===========================================================
 
-[20-TLS 1.2 Ed448 Client Auth]
-ssl_conf = 20-TLS 1.2 Ed448 Client Auth-ssl
+[18-TLS 1.2 Ed448 Client Auth]
+ssl_conf = 18-TLS 1.2 Ed448 Client Auth-ssl
 
-[20-TLS 1.2 Ed448 Client Auth-ssl]
-server = 20-TLS 1.2 Ed448 Client Auth-server
-client = 20-TLS 1.2 Ed448 Client Auth-client
+[18-TLS 1.2 Ed448 Client Auth-ssl]
+server = 18-TLS 1.2 Ed448 Client Auth-server
+client = 18-TLS 1.2 Ed448 Client Auth-client
 
-[20-TLS 1.2 Ed448 Client Auth-server]
+[18-TLS 1.2 Ed448 Client Auth-server]
 Certificate = ${ENV::TEST_CERTS_DIR}/servercert.pem
 CipherString = DEFAULT
 PrivateKey = ${ENV::TEST_CERTS_DIR}/serverkey.pem
 VerifyCAFile = ${ENV::TEST_CERTS_DIR}/root-cert.pem
 VerifyMode = Require
 
-[20-TLS 1.2 Ed448 Client Auth-client]
+[18-TLS 1.2 Ed448 Client Auth-client]
 CipherString = DEFAULT
 Ed448.Certificate = ${ENV::TEST_CERTS_DIR}/client-ed448-cert.pem
 Ed448.PrivateKey = ${ENV::TEST_CERTS_DIR}/client-ed448-key.pem
@@ -726,7 +656,7 @@ MinProtocol = TLSv1.2
 VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem
 VerifyMode = Peer
 
-[test-20]
+[test-18]
 ExpectedClientCertType = Ed448
 ExpectedClientSignType = Ed448
 ExpectedResult = Success
@@ -734,14 +664,14 @@ ExpectedResult = Success
 
 # ===========================================================
 
-[21-ECDSA Signature Algorithm Selection SHA1]
-ssl_conf = 21-ECDSA Signature Algorithm Selection SHA1-ssl
+[19-ECDSA Signature Algorithm Selection SHA1]
+ssl_conf = 19-ECDSA Signature Algorithm Selection SHA1-ssl
 
-[21-ECDSA Signature Algorithm Selection SHA1-ssl]
-server = 21-ECDSA Signature Algorithm Selection SHA1-server
-client = 21-ECDSA Signature Algorithm Selection SHA1-client
+[19-ECDSA Signature Algorithm Selection SHA1-ssl]
+server = 19-ECDSA Signature Algorithm Selection SHA1-server
+client = 19-ECDSA Signature Algorithm Selection SHA1-client
 
-[21-ECDSA Signature Algorithm Selection SHA1-server]
+[19-ECDSA Signature Algorithm Selection SHA1-server]
 Certificate = ${ENV::TEST_CERTS_DIR}/servercert.pem
 CipherString = DEFAULT:@SECLEVEL=0
 ECDSA.Certificate = ${ENV::TEST_CERTS_DIR}/server-ecdsa-cert.pem
@@ -753,13 +683,13 @@ Ed448.PrivateKey = ${ENV::TEST_CERTS_DIR}/server-ed448-key.pem
 MaxProtocol = TLSv1.2
 PrivateKey = ${ENV::TEST_CERTS_DIR}/serverkey.pem
 
-[21-ECDSA Signature Algorithm Selection SHA1-client]
+[19-ECDSA Signature Algorithm Selection SHA1-client]
 CipherString = DEFAULT:@SECLEVEL=0
 SignatureAlgorithms = ECDSA+SHA1
 VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem
 VerifyMode = Peer
 
-[test-21]
+[test-19]
 ExpectedResult = Success
 ExpectedServerCertType = P-256
 ExpectedServerSignHash = SHA1
@@ -768,20 +698,20 @@ ExpectedServerSignType = EC
 
 # ===========================================================
 
-[22-ECDSA with brainpool]
-ssl_conf = 22-ECDSA with brainpool-ssl
+[20-ECDSA with brainpool]
+ssl_conf = 20-ECDSA with brainpool-ssl
 
-[22-ECDSA with brainpool-ssl]
-server = 22-ECDSA with brainpool-server
-client = 22-ECDSA with brainpool-client
+[20-ECDSA with brainpool-ssl]
+server = 20-ECDSA with brainpool-server
+client = 20-ECDSA with brainpool-client
 
-[22-ECDSA with brainpool-server]
+[20-ECDSA with brainpool-server]
 Certificate = ${ENV::TEST_CERTS_DIR}/server-ecdsa-brainpoolP256r1-cert.pem
 CipherString = DEFAULT
 Groups = brainpoolP256r1
 PrivateKey = ${ENV::TEST_CERTS_DIR}/server-ecdsa-brainpoolP256r1-key.pem
 
-[22-ECDSA with brainpool-client]
+[20-ECDSA with brainpool-client]
 CipherString = aECDSA
 Groups = brainpoolP256r1
 MaxProtocol = TLSv1.2
@@ -789,13 +719,83 @@ RequestCAFile = ${ENV::TEST_CERTS_DIR}/root-cert.pem
 VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem
 VerifyMode = Peer
 
-[test-22]
+[test-20]
 ExpectedResult = Success
 ExpectedServerCANames = empty
 ExpectedServerCertType = brainpoolP256r1
 ExpectedServerSignType = EC
 
 
+# ===========================================================
+
+[21-Ed25519 CipherString and Curves Selection]
+ssl_conf = 21-Ed25519 CipherString and Curves Selection-ssl
+
+[21-Ed25519 CipherString and Curves Selection-ssl]
+server = 21-Ed25519 CipherString and Curves Selection-server
+client = 21-Ed25519 CipherString and Curves Selection-client
+
+[21-Ed25519 CipherString and Curves Selection-server]
+Certificate = ${ENV::TEST_CERTS_DIR}/servercert.pem
+CipherString = DEFAULT
+ECDSA.Certificate = ${ENV::TEST_CERTS_DIR}/server-ecdsa-cert.pem
+ECDSA.PrivateKey = ${ENV::TEST_CERTS_DIR}/server-ecdsa-key.pem
+Ed25519.Certificate = ${ENV::TEST_CERTS_DIR}/server-ed25519-cert.pem
+Ed25519.PrivateKey = ${ENV::TEST_CERTS_DIR}/server-ed25519-key.pem
+Ed448.Certificate = ${ENV::TEST_CERTS_DIR}/server-ed448-cert.pem
+Ed448.PrivateKey = ${ENV::TEST_CERTS_DIR}/server-ed448-key.pem
+MaxProtocol = TLSv1.2
+PrivateKey = ${ENV::TEST_CERTS_DIR}/serverkey.pem
+
+[21-Ed25519 CipherString and Curves Selection-client]
+CipherString = aECDSA
+Curves = X25519
+MaxProtocol = TLSv1.2
+SignatureAlgorithms = ECDSA+SHA256:ed25519
+VerifyCAFile = ${ENV::TEST_CERTS_DIR}/rootcert.pem
+VerifyMode = Peer
+
+[test-21]
+ExpectedResult = Success
+ExpectedServerCertType = Ed25519
+ExpectedServerSignType = Ed25519
+
+
+# ===========================================================
+
+[22-Ed448 CipherString and Curves Selection]
+ssl_conf = 22-Ed448 CipherString and Curves Selection-ssl
+
+[22-Ed448 CipherString and Curves Selection-ssl]
+server = 22-Ed448 CipherString and Curves Selection-server
+client = 22-Ed448 CipherString and Curves Selection-client
+
+[22-Ed448 CipherString and Curves Selection-server]
+Certificate = ${ENV::TEST_CERTS_DIR}/servercert.pem
+CipherString = DEFAULT
+ECDSA.Certificate = ${ENV::TEST_CERTS_DIR}/server-ecdsa-cert.pem
+ECDSA.PrivateKey = ${ENV::TEST_CERTS_DIR}/server-ecdsa-key.pem
+Ed25519.Certificate = ${ENV::TEST_CERTS_DIR}/server-ed25519-cert.pem
+Ed25519.PrivateKey = ${ENV::TEST_CERTS_DIR}/server-ed25519-key.pem
+Ed448.Certificate = ${ENV::TEST_CERTS_DIR}/server-ed448-cert.pem
+Ed448.PrivateKey = ${ENV::TEST_CERTS_DIR}/server-ed448-key.pem
+MaxProtocol = TLSv1.2
+PrivateKey = ${ENV::TEST_CERTS_DIR}/serverkey.pem
+
+[22-Ed448 CipherString and Curves Selection-client]
+CipherString = aECDSA
+Curves = X448
+MaxProtocol = TLSv1.2
+SignatureAlgorithms = ECDSA+SHA256:ed448
+VerifyCAFile = ${ENV::TEST_CERTS_DIR}/root-ed448-cert.pem
+VerifyMode = Peer
+
+[test-22]
+ExpectedResult = Success
+ExpectedServerCertType = Ed448
+ExpectedServerSignType = Ed448
+
+
 # ===========================================================
 
 [23-RSA-PSS Certificate CipherString Selection]
diff --git a/crypto/openssl/test/ssl-tests/20-cert-select.cnf.in b/crypto/openssl/test/ssl-tests/20-cert-select.cnf.in
index 30cde592c6d0..435932c4c181 100644
--- a/crypto/openssl/test/ssl-tests/20-cert-select.cnf.in
+++ b/crypto/openssl/test/ssl-tests/20-cert-select.cnf.in
@@ -328,41 +328,6 @@ our @tests = (
             "ExpectedResult" => "Success"
         },
     },
-    {
-        name => "Ed25519 CipherString and Curves Selection",
-        server => $server,
-        client => {
-            "CipherString" => "aECDSA",
-            "MaxProtocol" => "TLSv1.2",
-            "SignatureAlgorithms" => "ECDSA+SHA256:ed25519",
-            # Excluding P-256 from the supported curves list means server
-            # certificate should be Ed25519 and not P-256
-            "Curves" => "X25519"
-        },
-        test   => {
-            "ExpectedServerCertType" =>, "Ed25519",
-            "ExpectedServerSignType" =>, "Ed25519",
-            "ExpectedResult" => "Success"
-        },
-    },
-    {
-        name => "Ed448 CipherString and Curves Selection",
-        server => $server,
-        client => {
-            "CipherString" => "aECDSA",
-            "MaxProtocol" => "TLSv1.2",
-            "SignatureAlgorithms" => "ECDSA+SHA256:ed448",
-            "VerifyCAFile" => test_pem("root-ed448-cert.pem"),
-            # Excluding P-256 from the supported curves list means server
-            # certificate should be Ed25519 and not P-256
-            "Curves" => "X448"
-        },
-        test   => {
-            "ExpectedServerCertType" =>, "Ed448",
-            "ExpectedServerSignType" =>, "Ed448",
-            "ExpectedResult" => "Success"
-        },
-    },
     {
         name => "TLS 1.2 Ed25519 Client Auth",
         server => {
@@ -446,6 +411,41 @@ my @tests_non_fips = (
             "ExpectedResult" => "Success"
         },
     },
+    {
+        name => "Ed25519 CipherString and Curves Selection",
+        server => $server,
+        client => {
+            "CipherString" => "aECDSA",
+            "MaxProtocol" => "TLSv1.2",
+            "SignatureAlgorithms" => "ECDSA+SHA256:ed25519",
+            # Excluding P-256 from the supported curves list means server
+            # certificate should be Ed25519 and not P-256
+            "Curves" => "X25519"
+        },
+        test   => {
+            "ExpectedServerCertType" =>, "Ed25519",
+            "ExpectedServerSignType" =>, "Ed25519",
+            "ExpectedResult" => "Success"
+        },
+    },
+    {
+        name => "Ed448 CipherString and Curves Selection",
+        server => $server,
+        client => {
+            "CipherString" => "aECDSA",
+            "MaxProtocol" => "TLSv1.2",
+            "SignatureAlgorithms" => "ECDSA+SHA256:ed448",
+            "VerifyCAFile" => test_pem("root-ed448-cert.pem"),
+            # Excluding P-256 from the supported curves list means server
+            # certificate should be Ed25519 and not P-256
+            "Curves" => "X448"
+        },
+        test   => {
+            "ExpectedServerCertType" =>, "Ed448",
+            "ExpectedServerSignType" =>, "Ed448",
+            "ExpectedResult" => "Success"
+        },
+    },
 );
 
 my @tests_pss = (
diff --git a/crypto/openssl/test/ssl-tests/28-seclevel.cnf.in b/crypto/openssl/test/ssl-tests/28-seclevel.cnf.in
index 945f4599d10e..3b97ac68eb3a 100644
--- a/crypto/openssl/test/ssl-tests/28-seclevel.cnf.in
+++ b/crypto/openssl/test/ssl-tests/28-seclevel.cnf.in
@@ -1,5 +1,5 @@
 # -*- mode: perl; -*-
-# Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved.
+# Copyright 2016-2024 The OpenSSL Project Authors. All Rights Reserved.
 #
 # Licensed under the Apache License 2.0 (the "License").  You may not use
 # this file except in compliance with the License.  You can obtain a copy
@@ -56,7 +56,10 @@ our @tests_ec = (
         client => { "CipherString" => "DEFAULT:\@SECLEVEL=5",
                     "VerifyCAFile" => test_pem("root-ed448-cert.pem") },
         test   => { "ExpectedResult" => "ServerFail" },
-    },
+    }
+);
+
+our @tests_ec_non_fips = (
     {
         name => "SECLEVEL 3 with P-384 key, X25519 ECDHE",
         server => { "CipherString" => "DEFAULT:\@SECLEVEL=3",
@@ -81,5 +84,6 @@ our @tests_tls1_2 = (
     },
 );
 
+push @tests_ec, @tests_ec_non_fips unless $fips_mode;
 push @tests, @tests_ec unless disabled("ec");
 push @tests, @tests_tls1_2 unless disabled("tls1_2") || disabled("ec");
diff --git a/crypto/openssl/test/sslapitest.c b/crypto/openssl/test/sslapitest.c
index e0274f12f7cc..2b1c2fded322 100644
--- a/crypto/openssl/test/sslapitest.c
+++ b/crypto/openssl/test/sslapitest.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016-2023 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2016-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -2402,7 +2402,6 @@ static int test_session_wo_ca_names(void)
 #endif
 }
 
-
 #ifndef OSSL_NO_USABLE_TLS1_3
 static SSL_SESSION *sesscache[6];
 static int do_cache;
@@ -3490,6 +3489,25 @@ static int setupearly_data_test(SSL_CTX **cctx, SSL_CTX **sctx, SSL **clientssl,
     return 1;
 }
 
+static int check_early_data_timeout(time_t timer)
+{
+    int res = 0;
+
+    /*
+     * Early data is time sensitive. We have an approx 8 second allowance
+     * between writing the early data and reading it. If we exceed that time
+     * then this test will fail. This can sometimes (rarely) occur in normal CI
+     * operation. We can try and detect this and just ignore the result of this
+     * test if it has taken too long. We assume anything over 7 seconds is too
+     * long
+     */
+    timer = time(NULL) - timer;
+    if (timer >= 7)
+        res = TEST_skip("Test took too long, ignoring result");
+
+    return res;
+}
+
 static int test_early_data_read_write(int idx)
 {
     SSL_CTX *cctx = NULL, *sctx = NULL;
@@ -3499,6 +3517,7 @@ static int test_early_data_read_write(int idx)
     unsigned char buf[20], data[1024];
     size_t readbytes, written, eoedlen, rawread, rawwritten;
     BIO *rbio;
+    time_t timer;
 
     if (!TEST_true(setupearly_data_test(&cctx, &sctx, &clientssl,
                                         &serverssl, &sess, idx,
@@ -3506,13 +3525,20 @@ static int test_early_data_read_write(int idx)
         goto end;
 
     /* Write and read some early data */
+    timer = time(NULL);
     if (!TEST_true(SSL_write_early_data(clientssl, MSG1, strlen(MSG1),
                                         &written))
-            || !TEST_size_t_eq(written, strlen(MSG1))
-            || !TEST_int_eq(SSL_read_early_data(serverssl, buf,
-                                                sizeof(buf), &readbytes),
-                            SSL_READ_EARLY_DATA_SUCCESS)
-            || !TEST_mem_eq(MSG1, readbytes, buf, strlen(MSG1))
+            || !TEST_size_t_eq(written, strlen(MSG1)))
+        goto end;
+
+    if (!TEST_int_eq(SSL_read_early_data(serverssl, buf, sizeof(buf),
+                                         &readbytes),
+                     SSL_READ_EARLY_DATA_SUCCESS)) {
+        testresult = check_early_data_timeout(timer);
+        goto end;
+    }
+
+    if (!TEST_mem_eq(MSG1, readbytes, buf, strlen(MSG1))
             || !TEST_int_eq(SSL_get_early_data_status(serverssl),
                             SSL_EARLY_DATA_ACCEPTED))
         goto end;
@@ -3729,6 +3755,7 @@ static int test_early_data_replay_int(int idx, int usecb, int confopt)
     SSL_SESSION *sess = NULL;
     size_t readbytes, written;
     unsigned char buf[20];
+    time_t timer;
 
     allow_ed_cb_called = 0;
 
@@ -3783,6 +3810,7 @@ static int test_early_data_replay_int(int idx, int usecb, int confopt)
         goto end;
 
     /* Write and read some early data */
+    timer = time(NULL);
     if (!TEST_true(SSL_write_early_data(clientssl, MSG1, strlen(MSG1),
                                         &written))
             || !TEST_size_t_eq(written, strlen(MSG1)))
@@ -3803,8 +3831,11 @@ static int test_early_data_replay_int(int idx, int usecb, int confopt)
         /* In this case the callback decides to accept the early data */
         if (!TEST_int_eq(SSL_read_early_data(serverssl, buf, sizeof(buf),
                                              &readbytes),
-                         SSL_READ_EARLY_DATA_SUCCESS)
-                || !TEST_mem_eq(MSG1, strlen(MSG1), buf, readbytes)
+                         SSL_READ_EARLY_DATA_SUCCESS)) {
+            testresult = check_early_data_timeout(timer);
+            goto end;
+        }
+        if (!TEST_mem_eq(MSG1, strlen(MSG1), buf, readbytes)
                    /*
                     * Server will have sent its flight so client can now send
                     * end of early data and complete its half of the handshake
@@ -4321,13 +4352,19 @@ static int test_early_data_psk(int idx)
                 || !TEST_int_eq(ERR_GET_REASON(ERR_get_error()), err))
             goto end;
     } else {
+        time_t timer = time(NULL);
+
         if (!TEST_true(SSL_write_early_data(clientssl, MSG1, strlen(MSG1),
                                             &written)))
             goto end;
 
         if (!TEST_int_eq(SSL_read_early_data(serverssl, buf, sizeof(buf),
-                                             &readbytes), readearlyres)
-                || (readearlyres == SSL_READ_EARLY_DATA_SUCCESS
+                                             &readbytes), readearlyres)) {
+            testresult = check_early_data_timeout(timer);
+            goto end;
+        }
+
+        if ((readearlyres == SSL_READ_EARLY_DATA_SUCCESS
                     && !TEST_mem_eq(buf, readbytes, MSG1, strlen(MSG1)))
                 || !TEST_int_eq(SSL_get_early_data_status(serverssl), edstatus)
                 || !TEST_int_eq(SSL_connect(clientssl), connectres))
@@ -4365,6 +4402,7 @@ static int test_early_data_psk_with_all_ciphers(int idx)
     unsigned char buf[20];
     size_t readbytes, written;
     const SSL_CIPHER *cipher;
+    time_t timer;
     const char *cipher_str[] = {
         TLS1_3_RFC_AES_128_GCM_SHA256,
         TLS1_3_RFC_AES_256_GCM_SHA384,
@@ -4416,14 +4454,19 @@ static int test_early_data_psk_with_all_ciphers(int idx)
         goto end;
 
     SSL_set_connect_state(clientssl);
+    timer = time(NULL);
     if (!TEST_true(SSL_write_early_data(clientssl, MSG1, strlen(MSG1),
                                         &written)))
         goto end;
 
     if (!TEST_int_eq(SSL_read_early_data(serverssl, buf, sizeof(buf),
                                          &readbytes),
-                                         SSL_READ_EARLY_DATA_SUCCESS)
-            || !TEST_mem_eq(buf, readbytes, MSG1, strlen(MSG1))
+                                         SSL_READ_EARLY_DATA_SUCCESS)) {
+        testresult = check_early_data_timeout(timer);
+        goto end;
+    }
+
+    if (!TEST_mem_eq(buf, readbytes, MSG1, strlen(MSG1))
             || !TEST_int_eq(SSL_get_early_data_status(serverssl),
                                                       SSL_EARLY_DATA_ACCEPTED)
             || !TEST_int_eq(SSL_connect(clientssl), 1)
@@ -4864,10 +4907,14 @@ static int test_key_exchange(int idx)
             kexch_name0 = "secp521r1";
             break;
         case 4:
+            if (is_fips)
+                return TEST_skip("X25519 might not be supported by fips provider.");
             kexch_alg = NID_X25519;
             kexch_name0 = "x25519";
             break;
         case 5:
+            if (is_fips)
+                return TEST_skip("X448 might not be supported by fips provider.");
             kexch_alg = NID_X448;
             kexch_name0 = "x448";
             break;
@@ -5082,6 +5129,9 @@ static int test_negotiated_group(int idx)
     else
         expectednid = kexch_alg;
 
+    if (is_fips && (kexch_alg == NID_X25519 || kexch_alg == NID_X448))
+        return TEST_skip("X25519 and X448 might not be available in fips provider.");
+
     if (!istls13)
         max_version = TLS1_2_VERSION;
 
@@ -7467,6 +7517,7 @@ static int test_info_callback(int tst)
         SSL_SESSION *sess = NULL;
         size_t written, readbytes;
         unsigned char buf[80];
+        time_t timer;
 
         /* early_data tests */
         if (!TEST_true(setupearly_data_test(&cctx, &sctx, &clientssl,
@@ -7481,13 +7532,20 @@ static int test_info_callback(int tst)
                               sslapi_info_callback);
 
         /* Write and read some early data and then complete the connection */
+        timer = time(NULL);
         if (!TEST_true(SSL_write_early_data(clientssl, MSG1, strlen(MSG1),
                                             &written))
-                || !TEST_size_t_eq(written, strlen(MSG1))
-                || !TEST_int_eq(SSL_read_early_data(serverssl, buf,
-                                                    sizeof(buf), &readbytes),
-                                SSL_READ_EARLY_DATA_SUCCESS)
-                || !TEST_mem_eq(MSG1, readbytes, buf, strlen(MSG1))
+                || !TEST_size_t_eq(written, strlen(MSG1)))
+            goto end;
+
+        if (!TEST_int_eq(SSL_read_early_data(serverssl, buf,
+                                             sizeof(buf), &readbytes),
+                         SSL_READ_EARLY_DATA_SUCCESS)) {
+            testresult = check_early_data_timeout(timer);
+            goto end;
+        }
+
+        if (!TEST_mem_eq(MSG1, readbytes, buf, strlen(MSG1))
                 || !TEST_int_eq(SSL_get_early_data_status(serverssl),
                                 SSL_EARLY_DATA_ACCEPTED)
                 || !TEST_true(create_ssl_connection(serverssl, clientssl,
@@ -8954,6 +9012,126 @@ static int test_session_timeout(int test)
     return testresult;
 }
 
+/*
+ * Test that a session cache overflow works as expected
+ * Test 0: TLSv1.3, timeout on new session later than old session
+ * Test 1: TLSv1.2, timeout on new session later than old session
+ * Test 2: TLSv1.3, timeout on new session earlier than old session
+ * Test 3: TLSv1.2, timeout on new session earlier than old session
+ */
+#if !defined(OSSL_NO_USABLE_TLS1_3) || !defined(OPENSSL_NO_TLS1_2)
+static int test_session_cache_overflow(int idx)
+{
+    SSL_CTX *sctx = NULL, *cctx = NULL;
+    SSL *serverssl = NULL, *clientssl = NULL;
+    int testresult = 0;
+    SSL_SESSION *sess = NULL;
+
+#ifdef OSSL_NO_USABLE_TLS1_3
+    /* If no TLSv1.3 available then do nothing in this case */
+    if (idx % 2 == 0)
+        return TEST_skip("No TLSv1.3 available");
+#endif
+#ifdef OPENSSL_NO_TLS1_2
+    /* If no TLSv1.2 available then do nothing in this case */
+    if (idx % 2 == 1)
+        return TEST_skip("No TLSv1.2 available");
+#endif
+
+    if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
+                                       TLS_client_method(), TLS1_VERSION,
+                                       (idx % 2 == 0) ? TLS1_3_VERSION
+                                                      : TLS1_2_VERSION,
+                                       &sctx, &cctx, cert, privkey))
+            || !TEST_true(SSL_CTX_set_options(sctx, SSL_OP_NO_TICKET)))
+        goto end;
+
+    SSL_CTX_sess_set_get_cb(sctx, get_session_cb);
+    get_sess_val = NULL;
+
+    SSL_CTX_sess_set_cache_size(sctx, 1);
+
+    if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
+                                      NULL, NULL)))
+        goto end;
+
+    if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE)))
+        goto end;
+
+    if (idx > 1) {
+        sess = SSL_get_session(serverssl);
+        if (!TEST_ptr(sess))
+            goto end;
+
+        /*
+         * Cause this session to have a longer timeout than the next session to
+         * be added.
+         */
+        if (!TEST_true(SSL_SESSION_set_timeout(sess, LONG_MAX / 2))) {
+            sess = NULL;
+            goto end;
+        }
+        sess = NULL;
+    }
+
+    SSL_shutdown(serverssl);
+    SSL_shutdown(clientssl);
+    SSL_free(serverssl);
+    SSL_free(clientssl);
+    serverssl = clientssl = NULL;
+
+    /*
+     * Session cache size is 1 and we already populated the cache with a session
+     * so the next connection should cause an overflow.
+     */
+
+    if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
+                                      NULL, NULL)))
+        goto end;
+
+    if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE)))
+        goto end;
+
+    /*
+     * The session we just negotiated may have been already removed from the
+     * internal cache - but we will return it anyway from our external cache.
+     */
+    get_sess_val = SSL_get_session(serverssl);
+    if (!TEST_ptr(get_sess_val))
+        goto end;
+    sess = SSL_get1_session(clientssl);
+    if (!TEST_ptr(sess))
+        goto end;
+
+    SSL_shutdown(serverssl);
+    SSL_shutdown(clientssl);
+    SSL_free(serverssl);
+    SSL_free(clientssl);
+    serverssl = clientssl = NULL;
+
+    if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
+                                      NULL, NULL)))
+        goto end;
+
+    if (!TEST_true(SSL_set_session(clientssl, sess)))
+        goto end;
+
+    if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE)))
+        goto end;
+
+    testresult = 1;
+
+ end:
+    SSL_free(serverssl);
+    SSL_free(clientssl);
+    SSL_CTX_free(sctx);
+    SSL_CTX_free(cctx);
+    SSL_SESSION_free(sess);
+
+    return testresult;
+}
+#endif /* !defined(OSSL_NO_USABLE_TLS1_3) || !defined(OPENSSL_NO_TLS1_2) */
+
 /*
  * Test 0: Client sets servername and server acknowledges it (TLSv1.2)
  * Test 1: Client sets servername and server does not acknowledge it (TLSv1.2)
@@ -9269,20 +9447,11 @@ static int test_pluggable_group(int idx)
     OSSL_PROVIDER *tlsprov = OSSL_PROVIDER_load(libctx, "tls-provider");
     /* Check that we are not impacted by a provider without any groups */
     OSSL_PROVIDER *legacyprov = OSSL_PROVIDER_load(libctx, "legacy");
-    const char *group_name = idx == 0 ? "xorgroup" : "xorkemgroup";
+    const char *group_name = idx == 0 ? "xorkemgroup" : "xorgroup";
 
     if (!TEST_ptr(tlsprov))
         goto end;
 
-    if (legacyprov == NULL) {
-        /*
-         * In this case we assume we've been built with "no-legacy" and skip
-         * this test (there is no OPENSSL_NO_LEGACY)
-         */
-        testresult = 1;
-        goto end;
-    }
-
     if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
                                        TLS_client_method(),
                                        TLS1_3_VERSION,
@@ -9292,7 +9461,9 @@ static int test_pluggable_group(int idx)
                                              NULL, NULL)))
         goto end;
 
-    if (!TEST_true(SSL_set1_groups_list(serverssl, group_name))
+    /* ensure GROUPLIST_INCREMENT (=40) logic triggers: */
+    if (!TEST_true(SSL_set1_groups_list(serverssl, "xorgroup:xorkemgroup:dummy1:dummy2:dummy3:dummy4:dummy5:dummy6:dummy7:dummy8:dummy9:dummy10:dummy11:dummy12:dummy13:dummy14:dummy15:dummy16:dummy17:dummy18:dummy19:dummy20:dummy21:dummy22:dummy23:dummy24:dummy25:dummy26:dummy27:dummy28:dummy29:dummy30:dummy31:dummy32:dummy33:dummy34:dummy35:dummy36:dummy37:dummy38:dummy39:dummy40:dummy41:dummy42:dummy43"))
+    /* removing a single algorithm from the list makes the test pass */
             || !TEST_true(SSL_set1_groups_list(clientssl, group_name)))
         goto end;
 
@@ -10128,27 +10299,6 @@ static int test_load_dhfile(void)
 }
 
 #if !defined(OPENSSL_NO_TLS1_2) && !defined(OPENSSL_NO_DYNAMIC_ENGINE)
-
-static ENGINE *load_dasync(void)
-{
-    ENGINE *e;
-
-    if (!TEST_ptr(e = ENGINE_by_id("dasync")))
-        return NULL;
-
-    if (!TEST_true(ENGINE_init(e))) {
-        ENGINE_free(e);
-        return NULL;
-    }
-
-    if (!TEST_true(ENGINE_register_ciphers(e))) {
-        ENGINE_free(e);
-        return NULL;
-    }
-
-    return e;
-}
-
 /*
  * Test TLSv1.2 with a pipeline capable cipher. TLSv1.3 and DTLS do not
  * support this yet. The only pipeline capable cipher that we have is in the
@@ -10443,6 +10593,178 @@ static int test_handshake_retry(int idx)
     return testresult;
 }
 
+struct resume_servername_cb_data {
+    int i;
+    SSL_CTX *cctx;
+    SSL_CTX *sctx;
+    SSL_SESSION *sess;
+    int recurse;
+};
+
+/*
+ * Servername callback. We use it here to run another complete handshake using
+ * the same session - and mark the session as not_resuamble at the end
+ */
+static int resume_servername_cb(SSL *s, int *ad, void *arg)
+{
+    struct resume_servername_cb_data *cbdata = arg;
+    SSL *serverssl = NULL, *clientssl = NULL;
+    int ret = SSL_TLSEXT_ERR_ALERT_FATAL;
+
+    if (cbdata->recurse)
+        return SSL_TLSEXT_ERR_ALERT_FATAL;
+
+    if ((cbdata->i % 3) != 1)
+        return SSL_TLSEXT_ERR_OK;
+
+    cbdata->recurse = 1;
+
+    if (!TEST_true(create_ssl_objects(cbdata->sctx, cbdata->cctx, &serverssl,
+                                      &clientssl, NULL, NULL))
+            || !TEST_true(SSL_set_session(clientssl, cbdata->sess)))
+        goto end;
+
+    ERR_set_mark();
+    /*
+     * We expect this to fail - because the servername cb will fail. This will
+     * mark the session as not_resumable.
+     */
+    if (!TEST_false(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE))) {
+        ERR_clear_last_mark();
+        goto end;
+    }
+    ERR_pop_to_mark();
+
+    ret = SSL_TLSEXT_ERR_OK;
+ end:
+    SSL_free(serverssl);
+    SSL_free(clientssl);
+    cbdata->recurse = 0;
+    return ret;
+}
+
+/*
+ * Test multiple resumptions and cache size handling
+ * Test 0: TLSv1.3 (max_early_data set)
+ * Test 1: TLSv1.3 (SSL_OP_NO_TICKET set)
+ * Test 2: TLSv1.3 (max_early_data and SSL_OP_NO_TICKET set)
+ * Test 3: TLSv1.3 (SSL_OP_NO_TICKET, simultaneous resumes)
+ * Test 4: TLSv1.2
+ */
+static int test_multi_resume(int idx)
+{
+    SSL_CTX *sctx = NULL, *cctx = NULL;
+    SSL *serverssl = NULL, *clientssl = NULL;
+    SSL_SESSION *sess = NULL;
+    int max_version = TLS1_3_VERSION;
+    int i, testresult = 0;
+    struct resume_servername_cb_data cbdata;
+
+#if defined(OPENSSL_NO_TLS1_2)
+    if (idx == 4)
+        return TEST_skip("TLSv1.2 is disabled in this build");
+#else
+    if (idx == 4)
+        max_version = TLS1_2_VERSION;
+#endif
+#if defined(OSSL_NO_USABLE_TLS1_3)
+    if (idx != 4)
+        return TEST_skip("No usable TLSv1.3 in this build");
+#endif
+
+    if (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(),
+                                       TLS_client_method(), TLS1_VERSION,
+                                       max_version, &sctx, &cctx, cert,
+                                       privkey)))
+        goto end;
+
+    /*
+     * TLSv1.3 only uses a session cache if either max_early_data > 0 (used for
+     * replay protection), or if SSL_OP_NO_TICKET is in use
+     */
+    if (idx == 0 || idx == 2)  {
+        if (!TEST_true(SSL_CTX_set_max_early_data(sctx, 1024)))
+            goto end;
+    }
+    if (idx == 1 || idx == 2 || idx == 3)
+        SSL_CTX_set_options(sctx, SSL_OP_NO_TICKET);
+
+    SSL_CTX_sess_set_cache_size(sctx, 5);
+
+    if (idx == 3) {
+        SSL_CTX_set_tlsext_servername_callback(sctx, resume_servername_cb);
+        SSL_CTX_set_tlsext_servername_arg(sctx, &cbdata);
+        cbdata.cctx = cctx;
+        cbdata.sctx = sctx;
+        cbdata.recurse = 0;
+    }
+
+    for (i = 0; i < 30; i++) {
+        if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
+                                                NULL, NULL))
+                || !TEST_true(SSL_set_session(clientssl, sess)))
+            goto end;
+
+        /*
+         * Check simultaneous resumes. We pause the connection part way through
+         * the handshake by (mis)using the servername_cb. The pause occurs after
+         * session resumption has already occurred, but before any session
+         * tickets have been issued. While paused we run another complete
+         * handshake resuming the same session.
+         */
+        if (idx == 3) {
+            cbdata.i = i;
+            cbdata.sess = sess;
+        }
+
+        /*
+         * Recreate a bug where dynamically changing the max_early_data value
+         * can cause sessions in the session cache which cannot be deleted.
+         */
+        if ((idx == 0 || idx == 2) && (i % 3) == 2)
+            SSL_set_max_early_data(serverssl, 0);
+
+        if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE)))
+            goto end;
+
+        if (sess == NULL || (idx == 0 && (i % 3) == 2)) {
+            if (!TEST_false(SSL_session_reused(clientssl)))
+                goto end;
+        } else {
+            if (!TEST_true(SSL_session_reused(clientssl)))
+                goto end;
+        }
+        SSL_SESSION_free(sess);
+
+        /* Do a full handshake, followed by two resumptions */
+        if ((i % 3) == 2) {
+            sess = NULL;
+        } else {
+            if (!TEST_ptr((sess = SSL_get1_session(clientssl))))
+                goto end;
+        }
+
+        SSL_shutdown(clientssl);
+        SSL_shutdown(serverssl);
+        SSL_free(serverssl);
+        SSL_free(clientssl);
+        serverssl = clientssl = NULL;
+    }
+
+    /* We should never exceed the session cache size limit */
+    if (!TEST_long_le(SSL_CTX_sess_number(sctx), 5))
+        goto end;
+
+    testresult = 1;
+ end:
+    SSL_free(serverssl);
+    SSL_free(clientssl);
+    SSL_CTX_free(sctx);
+    SSL_CTX_free(cctx);
+    SSL_SESSION_free(sess);
+    return testresult;
+}
+
 OPT_TEST_DECLARE_USAGE("certfile privkeyfile srpvfile tmpfile provider config dhfile\n")
 
 int setup_tests(void)
@@ -10707,6 +11029,9 @@ int setup_tests(void)
     ADD_TEST(test_set_verify_cert_store_ssl_ctx);
     ADD_TEST(test_set_verify_cert_store_ssl);
     ADD_ALL_TESTS(test_session_timeout, 1);
+#if !defined(OSSL_NO_USABLE_TLS1_3) || !defined(OPENSSL_NO_TLS1_2)
+    ADD_ALL_TESTS(test_session_cache_overflow, 4);
+#endif
     ADD_TEST(test_load_dhfile);
 #if !defined(OPENSSL_NO_TLS1_2) && !defined(OSSL_NO_USABLE_TLS1_3)
     ADD_ALL_TESTS(test_serverinfo_custom, 4);
@@ -10715,6 +11040,7 @@ int setup_tests(void)
     ADD_ALL_TESTS(test_pipelining, 7);
 #endif
     ADD_ALL_TESTS(test_handshake_retry, 16);
+    ADD_ALL_TESTS(test_multi_resume, 5);
     return 1;
 
  err:
diff --git a/crypto/openssl/test/sslbuffertest.c b/crypto/openssl/test/sslbuffertest.c
index 3c3e69d61da8..f313151f686f 100644
--- a/crypto/openssl/test/sslbuffertest.c
+++ b/crypto/openssl/test/sslbuffertest.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2016-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -8,10 +8,19 @@
  * or in the file LICENSE in the source distribution.
  */
 
+/*
+ * We need access to the deprecated low level Engine APIs for legacy purposes
+ * when the deprecated calls are not hidden
+ */
+#ifndef OPENSSL_NO_DEPRECATED_3_0
+# define OPENSSL_SUPPRESS_DEPRECATED
+#endif
+
 #include <string.h>
 #include <openssl/ssl.h>
 #include <openssl/bio.h>
 #include <openssl/err.h>
+#include <openssl/engine.h>
 
 #include "internal/packet.h"
 
@@ -150,6 +159,166 @@ static int test_func(int test)
     return result;
 }
 
+/*
+ * Test that attempting to free the buffers at points where they cannot be freed
+ * works as expected
+ * Test 0: Attempt to free buffers after a full record has been processed, but
+ *         the application has only performed a partial read
+ * Test 1: Attempt to free buffers after only a partial record header has been
+ *         received
+ * Test 2: Attempt to free buffers after a full record header but no record body
+ * Test 3: Attempt to free buffers after a full record hedaer and partial record
+ *         body
+ * Test 4-7: We repeat tests 0-3 but including data from a second pipelined
+ *           record
+ */
+static int test_free_buffers(int test)
+{
+    int result = 0;
+    SSL *serverssl = NULL, *clientssl = NULL;
+    const char testdata[] = "Test data";
+    char buf[120];
+    size_t written, readbytes;
+    int i, pipeline = test > 3;
+    ENGINE *e = NULL;
+
+    if (pipeline) {
+        e = load_dasync();
+        if (e == NULL)
+            goto end;
+        test -= 4;
+    }
+
+    if (!TEST_true(create_ssl_objects(serverctx, clientctx, &serverssl,
+                                      &clientssl, NULL, NULL)))
+        goto end;
+
+    if (pipeline) {
+        if (!TEST_true(SSL_set_cipher_list(serverssl, "AES128-SHA"))
+                || !TEST_true(SSL_set_max_proto_version(serverssl,
+                                                        TLS1_2_VERSION))
+                || !TEST_true(SSL_set_max_pipelines(serverssl, 2)))
+            goto end;
+    }
+
+    if (!TEST_true(create_ssl_connection(serverssl, clientssl,
+                                         SSL_ERROR_NONE)))
+        goto end;
+
+    /*
+     * For the non-pipeline case we write one record. For pipelining we write
+     * two records.
+     */
+    for (i = 0; i <= pipeline; i++) {
+        if (!TEST_true(SSL_write_ex(clientssl, testdata, strlen(testdata),
+                                    &written)))
+            goto end;
+    }
+
+    if (test == 0) {
+        size_t readlen = 1;
+
+        /*
+         * Deliberately only read the first byte - so the remaining bytes are
+         * still buffered. In the pipelining case we read as far as the first
+         * byte from the second record.
+         */
+        if (pipeline)
+            readlen += strlen(testdata);
+
+        if (!TEST_true(SSL_read_ex(serverssl, buf, readlen, &readbytes))
+                || !TEST_size_t_eq(readlen, readbytes))
+            goto end;
+    } else {
+        BIO *tmp;
+        size_t partial_len;
+
+        /* Remove all the data that is pending for read by the server */
+        tmp = SSL_get_rbio(serverssl);
+        if (!TEST_true(BIO_read_ex(tmp, buf, sizeof(buf), &readbytes))
+                || !TEST_size_t_lt(readbytes, sizeof(buf))
+                || !TEST_size_t_gt(readbytes, SSL3_RT_HEADER_LENGTH))
+            goto end;
+
+        switch(test) {
+        case 1:
+            partial_len = SSL3_RT_HEADER_LENGTH - 1;
+            break;
+        case 2:
+            partial_len = SSL3_RT_HEADER_LENGTH;
+            break;
+        case 3:
+            partial_len = readbytes - 1;
+            break;
+        default:
+            TEST_error("Invalid test index");
+            goto end;
+        }
+
+        if (pipeline) {
+            /* We happen to know the first record is 57 bytes long */
+            const size_t first_rec_len = 57;
+
+            if (test != 3)
+                partial_len += first_rec_len;
+
+            /*
+             * Sanity check. If we got the record len right then this should
+             * never fail.
+             */
+            if (!TEST_int_eq(buf[first_rec_len], SSL3_RT_APPLICATION_DATA))
+                goto end;
+        }
+
+        /*
+         * Put back just the partial record (plus the whole initial record in
+         * the pipelining case)
+         */
+        if (!TEST_true(BIO_write_ex(tmp, buf, partial_len, &written)))
+            goto end;
+
+        if (pipeline) {
+            /*
+             * Attempt a read. This should pass but only return data from the
+             * first record. Only a partial record is available for the second
+             * record.
+             */
+            if (!TEST_true(SSL_read_ex(serverssl, buf, sizeof(buf),
+                                        &readbytes))
+                    || !TEST_size_t_eq(readbytes, strlen(testdata)))
+                goto end;
+        } else {
+            /*
+            * Attempt a read. This should fail because only a partial record is
+            * available.
+            */
+            if (!TEST_false(SSL_read_ex(serverssl, buf, sizeof(buf),
+                                        &readbytes)))
+                goto end;
+        }
+    }
+
+    /*
+     * Attempting to free the buffers at this point should fail because they are
+     * still in use
+     */
+    if (!TEST_false(SSL_free_buffers(serverssl)))
+        goto end;
+
+    result = 1;
+ end:
+    SSL_free(clientssl);
+    SSL_free(serverssl);
+#ifndef OPENSSL_NO_DYNAMIC_ENGINE
+    if (e != NULL) {
+        ENGINE_unregister_ciphers(e);
+        ENGINE_finish(e);
+        ENGINE_free(e);
+    }
+#endif
+    return result;
+}
+
 OPT_TEST_DECLARE_USAGE("certfile privkeyfile\n")
 
 int setup_tests(void)
@@ -173,6 +342,11 @@ int setup_tests(void)
     }
 
     ADD_ALL_TESTS(test_func, 9);
+#if !defined(OPENSSL_NO_TLS1_2) && !defined(OPENSSL_NO_DYNAMIC_ENGINE)
+    ADD_ALL_TESTS(test_free_buffers, 8);
+#else
+    ADD_ALL_TESTS(test_free_buffers, 4);
+#endif
     return 1;
 }
 
diff --git a/crypto/openssl/test/test.cnf b/crypto/openssl/test/test.cnf
index 8b2f92ad8e24..8f68982a9fa1 100644
--- a/crypto/openssl/test/test.cnf
+++ b/crypto/openssl/test/test.cnf
@@ -72,3 +72,9 @@ commonName			= CN field
 commonName_value		= Eric Young
 emailAddress			= email field
 emailAddress_value		= eay@mincom.oz.au
+
+[ dirname_sec ]
+C  = UK
+O  = My Organization
+OU = My Unit
+CN = My Name
diff --git a/crypto/openssl/test/tls-provider.c b/crypto/openssl/test/tls-provider.c
index 5c44b6812e81..7375792c3125 100644
--- a/crypto/openssl/test/tls-provider.c
+++ b/crypto/openssl/test/tls-provider.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2019-2022 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2019-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -185,6 +185,8 @@ static int tls_prov_get_capabilities(void *provctx, const char *capability,
     }
 
     /* Register our 2 groups */
+    OPENSSL_assert(xor_group.group_id >= 65024
+                   && xor_group.group_id < 65279 - NUM_DUMMY_GROUPS);
     ret = cb(xor_group_params, arg);
     ret &= cb(xor_kemgroup_params, arg);
 
@@ -196,6 +198,7 @@ static int tls_prov_get_capabilities(void *provctx, const char *capability,
 
     for (i = 0; i < NUM_DUMMY_GROUPS; i++) {
         OSSL_PARAM dummygroup[OSSL_NELEM(xor_group_params)];
+        unsigned int dummygroup_id;
 
         memcpy(dummygroup, xor_group_params, sizeof(xor_group_params));
 
@@ -210,6 +213,9 @@ static int tls_prov_get_capabilities(void *provctx, const char *capability,
         }
         dummygroup[0].data = dummy_group_names[i];
         dummygroup[0].data_size = strlen(dummy_group_names[i]) + 1;
+        /* assign unique group IDs also to dummy groups for registration */
+        dummygroup_id = 65279 - NUM_DUMMY_GROUPS + i;
+        dummygroup[3].data = (unsigned char*)&dummygroup_id;
         ret &= cb(dummygroup, arg);
     }
 
@@ -817,9 +823,10 @@ unsigned int randomize_tls_group_id(OSSL_LIB_CTX *libctx)
         return 0;
     /*
      * Ensure group_id is within the IANA Reserved for private use range
-     * (65024-65279)
+     * (65024-65279).
+     * Carve out NUM_DUMMY_GROUPS ids for properly registering those.
      */
-    group_id %= 65279 - 65024;
+    group_id %= 65279 - NUM_DUMMY_GROUPS - 65024;
     group_id += 65024;
 
     /* Ensure we did not already issue this group_id */
diff --git a/crypto/openssl/test/v3ext.c b/crypto/openssl/test/v3ext.c
index 88034db27155..9305a3010bf8 100644
--- a/crypto/openssl/test/v3ext.c
+++ b/crypto/openssl/test/v3ext.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016-2022 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2016-2024 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -269,17 +269,20 @@ static int test_addr_fam_len(void)
         goto end;
     if (!ASN1_OCTET_STRING_set(f1->addressFamily, key, keylen))
         goto end;
+
+    /* Push and transfer memory ownership to stack */
     if (!sk_IPAddressFamily_push(addr, f1))
         goto end;
+    f1 = NULL;
 
     /* Shouldn't be able to canonize this as the len is > 3*/
     if (!TEST_false(X509v3_addr_canonize(addr)))
         goto end;
 
-    /* Create a well formed IPAddressFamily */
-    f1 = sk_IPAddressFamily_pop(addr);
-    IPAddressFamily_free(f1);
+    /* Pop and free the new stack element */
+    IPAddressFamily_free(sk_IPAddressFamily_pop(addr));
 
+    /* Create a well-formed IPAddressFamily */
     key[0] = (afi >> 8) & 0xFF;
     key[1] = afi & 0xFF;
     key[2] = 0x1;
@@ -297,8 +300,11 @@ static int test_addr_fam_len(void)
 
     /* Mark this as inheritance so we skip some of the is_canonize checks */
     f1->ipAddressChoice->type = IPAddressChoice_inherit;
+
+    /* Push and transfer memory ownership to stack */
     if (!sk_IPAddressFamily_push(addr, f1))
         goto end;
+    f1 = NULL;
 
     /* Should be able to canonize now */
     if (!TEST_true(X509v3_addr_canonize(addr)))
@@ -306,7 +312,10 @@ static int test_addr_fam_len(void)
 
     testresult = 1;
   end:
+    /* Free stack and any memory owned by detached element */
+    IPAddressFamily_free(f1);
     sk_IPAddressFamily_pop_free(addr, IPAddressFamily_free);
+
     ASN1_OCTET_STRING_free(ip1);
     ASN1_OCTET_STRING_free(ip2);
     return testresult;
diff --git a/etc/Makefile b/etc/Makefile
index ddef82f64510..bd6d692e5316 100644
--- a/etc/Makefile
+++ b/etc/Makefile
@@ -88,10 +88,6 @@ distribution:
 .if ${MK_SENDMAIL} != "no"
 	cd ${.CURDIR}/mail; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
 		-T "package=sendmail" ${ETCMAIL_SENDMAIL} ${DESTDIR}/etc/mail
-.endif
-.if ${MK_LOCATE} != "no"
-	${INSTALL} -o nobody -g ${BINGRP} -m 644 -T "package=runtime"\
-	    /dev/null ${DESTDIR}/var/db/locate.database
 .endif
 	cd ${.CURDIR}/..; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \
 		-T "package=runtime" ${FREEBSD} ${DESTDIR}/
diff --git a/lib/clang/include/VCSVersion.inc b/lib/clang/include/VCSVersion.inc
index c4bb0df4e3a5..941c98e43c9a 100644
--- a/lib/clang/include/VCSVersion.inc
+++ b/lib/clang/include/VCSVersion.inc
@@ -1,8 +1,8 @@
-#define LLVM_REVISION "llvmorg-18.1.5-0-g617a15a9eac9"
+#define LLVM_REVISION "llvmorg-18.1.6-0-g1118c2e05e67"
 #define LLVM_REPOSITORY "https://github.com/llvm/llvm-project.git"
 
-#define CLANG_REVISION "llvmorg-18.1.5-0-g617a15a9eac9"
+#define CLANG_REVISION "llvmorg-18.1.6-0-g1118c2e05e67"
 #define CLANG_REPOSITORY "https://github.com/llvm/llvm-project.git"
 
-#define LLDB_REVISION "llvmorg-18.1.5-0-g617a15a9eac9"
+#define LLDB_REVISION "llvmorg-18.1.6-0-g1118c2e05e67"
 #define LLDB_REPOSITORY "https://github.com/llvm/llvm-project.git"
diff --git a/lib/clang/include/clang/Basic/Version.inc b/lib/clang/include/clang/Basic/Version.inc
index c243016c5f73..405ee341dfcd 100644
--- a/lib/clang/include/clang/Basic/Version.inc
+++ b/lib/clang/include/clang/Basic/Version.inc
@@ -1,8 +1,8 @@
-#define	CLANG_VERSION			18.1.5
-#define	CLANG_VERSION_STRING		"18.1.5"
+#define	CLANG_VERSION			18.1.6
+#define	CLANG_VERSION_STRING		"18.1.6"
 #define	CLANG_VERSION_MAJOR		18
 #define	CLANG_VERSION_MAJOR_STRING	"18"
 #define	CLANG_VERSION_MINOR		1
-#define	CLANG_VERSION_PATCHLEVEL	5
+#define	CLANG_VERSION_PATCHLEVEL	6
 
 #define	CLANG_VENDOR			"FreeBSD "
diff --git a/lib/clang/include/lld/Common/Version.inc b/lib/clang/include/lld/Common/Version.inc
index 4079a361ce8d..20f5fbe6e124 100644
--- a/lib/clang/include/lld/Common/Version.inc
+++ b/lib/clang/include/lld/Common/Version.inc
@@ -1,4 +1,4 @@
 // Local identifier in __FreeBSD_version style
 #define LLD_FREEBSD_VERSION 1400006
 
-#define LLD_VERSION_STRING "18.1.5 (FreeBSD llvmorg-18.1.5-0-g617a15a9eac9-" __XSTRING(LLD_FREEBSD_VERSION) ")"
+#define LLD_VERSION_STRING "18.1.6 (FreeBSD llvmorg-18.1.6-0-g1118c2e05e67-" __XSTRING(LLD_FREEBSD_VERSION) ")"
diff --git a/lib/clang/include/lldb/Version/Version.inc b/lib/clang/include/lldb/Version/Version.inc
index 0e86bd2e01ba..c693f099ccff 100644
--- a/lib/clang/include/lldb/Version/Version.inc
+++ b/lib/clang/include/lldb/Version/Version.inc
@@ -1,6 +1,6 @@
-#define LLDB_VERSION 18.1.5
-#define LLDB_VERSION_STRING "18.1.5"
+#define LLDB_VERSION 18.1.6
+#define LLDB_VERSION_STRING "18.1.6"
 #define LLDB_VERSION_MAJOR 18
 #define LLDB_VERSION_MINOR 1
-#define LLDB_VERSION_PATCH 5
+#define LLDB_VERSION_PATCH 6
 /* #undef LLDB_FULL_VERSION_STRING */
diff --git a/lib/clang/include/llvm/Config/config.h b/lib/clang/include/llvm/Config/config.h
index 0760c0b17a87..65e903427a83 100644
--- a/lib/clang/include/llvm/Config/config.h
+++ b/lib/clang/include/llvm/Config/config.h
@@ -344,10 +344,10 @@
 #define PACKAGE_NAME "LLVM"
 
 /* Define to the full name and version of this package. */
-#define PACKAGE_STRING "LLVM 18.1.5"
+#define PACKAGE_STRING "LLVM 18.1.6"
 
 /* Define to the version of this package. */
-#define PACKAGE_VERSION "18.1.5"
+#define PACKAGE_VERSION "18.1.6"
 
 /* Define to the vendor of this package. */
 /* #undef PACKAGE_VENDOR */
diff --git a/lib/clang/include/llvm/Config/llvm-config.h b/lib/clang/include/llvm/Config/llvm-config.h
index 049529efdd7f..372a69017f79 100644
--- a/lib/clang/include/llvm/Config/llvm-config.h
+++ b/lib/clang/include/llvm/Config/llvm-config.h
@@ -176,10 +176,10 @@
 #define LLVM_VERSION_MINOR 1
 
 /* Patch version of the LLVM API */
-#define LLVM_VERSION_PATCH 5
+#define LLVM_VERSION_PATCH 6
 
 /* LLVM version string */
-#define LLVM_VERSION_STRING "18.1.5"
+#define LLVM_VERSION_STRING "18.1.6"
 
 /* Whether LLVM records statistics for use with GetStatistics(),
  * PrintStatistics() or PrintStatisticsJSON()
diff --git a/lib/clang/include/llvm/Support/VCSRevision.h b/lib/clang/include/llvm/Support/VCSRevision.h
index 433b2b53b8fe..9c8ecebe02de 100644
--- a/lib/clang/include/llvm/Support/VCSRevision.h
+++ b/lib/clang/include/llvm/Support/VCSRevision.h
@@ -1,2 +1,2 @@
-#define LLVM_REVISION "llvmorg-18.1.5-0-g617a15a9eac9"
+#define LLVM_REVISION "llvmorg-18.1.6-0-g1118c2e05e67"
 #define LLVM_REPOSITORY "https://github.com/llvm/llvm-project.git"
diff --git a/lib/libarchive/Makefile.inc b/lib/libarchive/Makefile.inc
index 153f96b12165..755a39ec01e8 100644
--- a/lib/libarchive/Makefile.inc
+++ b/lib/libarchive/Makefile.inc
@@ -4,7 +4,8 @@
 
 LIBADD=	z bz2 lzma bsdxml zstd
 CFLAGS+=	-DHAVE_BZLIB_H=1 -DHAVE_LIBLZMA=1 -DHAVE_LZMA_H=1 \
-		-DHAVE_ZSTD_H=1 -DHAVE_LIBZSTD=1 -DHAVE_ZSTD_compressStream=1
+		-DHAVE_ZSTD_H=1 -DHAVE_LIBZSTD=1 -DHAVE_ZSTD_compressStream=1 \
+		-DHAVE_SYSCONF=1
 CFLAGS+=	-DPLATFORM_CONFIG_H=\"${.CURDIR}/config_freebsd.h\"
 
 .if ${MK_OPENSSL} != "no"
diff --git a/lib/libc/capability/Symbol.map b/lib/libc/capability/Symbol.map
index 0deff024a046..8bf11670a5a8 100644
--- a/lib/libc/capability/Symbol.map
+++ b/lib/libc/capability/Symbol.map
@@ -8,3 +8,7 @@ FBSD_1.3 {
 	cap_rights_remove;
 	__cap_rights_set;
 };
+
+FBSD_1.8 {
+	cap_rights_is_empty;
+};
diff --git a/lib/libc/capability/cap_rights_init.3 b/lib/libc/capability/cap_rights_init.3
index 80b522820097..98b50f653f2c 100644
--- a/lib/libc/capability/cap_rights_init.3
+++ b/lib/libc/capability/cap_rights_init.3
@@ -25,7 +25,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd May 5, 2020
+.Dd November 25, 2023
 .Dt CAP_RIGHTS_INIT 3
 .Os
 .Sh NAME
@@ -33,6 +33,7 @@
 .Nm cap_rights_set ,
 .Nm cap_rights_clear ,
 .Nm cap_rights_is_set ,
+.Nm cap_rights_is_empty ,
 .Nm cap_rights_is_valid ,
 .Nm cap_rights_merge ,
 .Nm cap_rights_remove ,
@@ -51,6 +52,8 @@
 .Ft bool
 .Fn cap_rights_is_set "const cap_rights_t *rights" "..."
 .Ft bool
+.Fn cap_rights_is_empty "const cap_rights_t *rights"
+.Ft bool
 .Fn cap_rights_is_valid "const cap_rights_t *rights"
 .Ft cap_rights_t *
 .Fn cap_rights_merge "cap_rights_t *dst" "const cap_rights_t *src"
@@ -118,6 +121,12 @@ function checks if all the given capability rights are set for the given
 structure.
 .Pp
 The
+.Fn cap_rights_is_empty
+function checks if the
+.Fa rights
+structure is empty.
+.Pp
+The
 .Fn cap_rights_is_valid
 function verifies if the given
 .Vt cap_rights_t
@@ -182,6 +191,14 @@ if all the given capability rights are set in the
 argument.
 .Pp
 The
+.Fn cap_rights_is_empty
+function returns
+.Va true
+if none of the capability rights are set in the
+.Fa rights
+structure.
+.Pp
+The
 .Fn cap_rights_is_valid
 function performs various checks to see if the given
 .Vt cap_rights_t
diff --git a/lib/libc/rpc/Symbol.map b/lib/libc/rpc/Symbol.map
index 5bf364f28d81..e4fecb83ec66 100644
--- a/lib/libc/rpc/Symbol.map
+++ b/lib/libc/rpc/Symbol.map
@@ -8,37 +8,6 @@ FBSD_1.0 {
 	xdr_desargs;
 	xdr_desresp;
 
-	/* From yp_xdr.c (generated by rpcgen - include/rpcsvc/yp.x) */
-	xdr_domainname;
-	xdr_keydat;
-	xdr_mapname;
-	xdr_peername;
-	xdr_valdat;
-	xdr_ypbind_binding;
-	xdr_ypbind_resp;
-	xdr_ypbind_resptype;
-	xdr_ypbind_setdom;
-	xdr_ypmap_parms;
-	xdr_ypmaplist;
-	xdr_yppush_status;
-	xdr_yppushresp_xfr;
-	xdr_ypreq_key;
-	xdr_ypreq_nokey;
-	xdr_ypreq_xfr;
-	xdr_ypreqtype;
-	xdr_yprequest;
-	xdr_ypresp_all;
-	xdr_ypresp_key_val;
-	xdr_ypresp_maplist;
-	xdr_ypresp_master;
-	xdr_ypresp_order;
-	xdr_ypresp_val;
-	xdr_ypresp_xfr;
-	xdr_ypresponse;
-	xdr_ypresptype;
-	xdr_ypstat;
-	xdr_ypxfrstat;
-
 	authdes_seccreate;
 	authdes_pk_seccreate;
 	authnone_create;
diff --git a/lib/libc/yp/Symbol.map b/lib/libc/yp/Symbol.map
index fff2b2e60e39..f50beed7be31 100644
--- a/lib/libc/yp/Symbol.map
+++ b/lib/libc/yp/Symbol.map
@@ -18,4 +18,36 @@ FBSD_1.0 {
 	yperr_string;
 	ypprot_err;
 	_yp_check;
+
+	/* From yp_xdr.c (generated by rpcgen - include/rpcsvc/yp.x) */
+	xdr_domainname;
+	xdr_keydat;
+	xdr_mapname;
+	xdr_peername;
+	xdr_valdat;
+	xdr_ypbind_binding;
+	xdr_ypbind_resp;
+	xdr_ypbind_resptype;
+	xdr_ypbind_setdom;
+	xdr_ypmap_parms;
+	xdr_ypmaplist;
+	xdr_yppush_status;
+	xdr_yppushresp_xfr;
+	xdr_ypreq_key;
+	xdr_ypreq_nokey;
+	xdr_ypreq_xfr;
+	xdr_ypreqtype;
+	xdr_yprequest;
+	xdr_ypresp_all;
+	xdr_ypresp_key_val;
+	xdr_ypresp_maplist;
+	xdr_ypresp_master;
+	xdr_ypresp_order;
+	xdr_ypresp_val;
+	xdr_ypresp_xfr;
+	xdr_ypresponse;
+	xdr_ypresptype;
+	xdr_ypstat;
+	xdr_ypxfrstat;
+
 };
diff --git a/lib/libcapsicum/capsicum_helpers.h b/lib/libcapsicum/capsicum_helpers.h
index f137ec1806f9..a6c696aa9a8e 100644
--- a/lib/libcapsicum/capsicum_helpers.h
+++ b/lib/libcapsicum/capsicum_helpers.h
@@ -133,8 +133,17 @@ caph_limit_stdio(void)
 static __inline void
 caph_cache_tzdata(void)
 {
+	time_t delta;
 
 	tzset();
+
+	/*
+	 * The tzset() function does not cache all time zones.
+	 * Some functions, such as gmtime(), require a GMT time zone.
+	 * The only way to cache them is to call the function directly.
+	 */
+	delta = 0;
+	(void)gmtime(&delta);
 }
 
 static __inline void
diff --git a/lib/libcompat/Makefile b/lib/libcompat/Makefile
index 7c99556e7513..e30e120c3d41 100644
--- a/lib/libcompat/Makefile
+++ b/lib/libcompat/Makefile
@@ -7,12 +7,7 @@ NO_PIC=
 
 WARNS?=	0
 
-.PATH:	${.CURDIR}/4.1 ${.CURDIR}/4.3 ${.CURDIR}/4.4
-
-# compat 4.1 sources
-SRCS+=	ftime.c
-
-MAN+=	4.1/ftime.3
+.PATH:	${.CURDIR}/4.3 ${.CURDIR}/4.4
 
 # compat 4.3 sources
 SRCS+=	re_comp.c rexec.c
diff --git a/lib/libpam/modules/pam_xdg/pam_xdg.c b/lib/libpam/modules/pam_xdg/pam_xdg.c
index 4d586a21566a..2c80f0a0332f 100644
--- a/lib/libpam/modules/pam_xdg/pam_xdg.c
+++ b/lib/libpam/modules/pam_xdg/pam_xdg.c
@@ -67,7 +67,7 @@ _pam_xdg_open(pam_handle_t *pamh, int flags __unused,
 
 	/* Get user info */
 	rv = pam_get_item(pamh, PAM_USER, (const void **)&user);
-	if (rv != PAM_SUCCESS) {
+	if (rv != PAM_SUCCESS || user == NULL) {
 		PAM_VERBOSE_ERROR("Can't get user information");
 		goto out;
 	}
@@ -221,7 +221,7 @@ _pam_xdg_close(pam_handle_t *pamh __unused, int flags __unused,
 
 	/* Get user info */
 	rv = pam_get_item(pamh, PAM_USER, (const void **)&user);
-	if (rv != PAM_SUCCESS) {
+	if (rv != PAM_SUCCESS || user == NULL) {
 		PAM_VERBOSE_ERROR("Can't get user information");
 		goto out;
 	}
diff --git a/lib/libusbhid/usbhid.h b/lib/libusbhid/usbhid.h
index 15d4f1613746..637fb3d846f7 100644
--- a/lib/libusbhid/usbhid.h
+++ b/lib/libusbhid/usbhid.h
@@ -29,6 +29,9 @@
  *
  */
 
+#ifndef _USBHID_H_
+#define _USBHID_H_
+
 #include <stdint.h>
 
 typedef struct report_desc *report_desc_t;
@@ -111,3 +114,5 @@ int hid_set_report(int fd, enum hid_kind k,
     unsigned char *data, unsigned int size);
 
 __END_DECLS
+
+#endif /* !_USBHID_H_ */
diff --git a/lib/libutil/Makefile b/lib/libutil/Makefile
index 889a81747c82..5bce5c158958 100644
--- a/lib/libutil/Makefile
+++ b/lib/libutil/Makefile
@@ -12,7 +12,7 @@ LIB=	util
 SHLIB_MAJOR= 9
 
 SRCS=	_secure_path.c auth.c cpuset.c expand_number.c flopen.c fparseln.c \
-	getlocalbase.c  gr_util.c \
+	ftime.c getlocalbase.c gr_util.c \
 	hexdump.c humanize_number.c kinfo_getfile.c \
 	kinfo_getallproc.c kinfo_getproc.c kinfo_getvmmap.c \
 	kinfo_getvmobject.c kld.c \
@@ -30,8 +30,8 @@ CFLAGS+= -DINET6
 
 CFLAGS+= -I${.CURDIR} -I${SRCTOP}/lib/libc/gen/
 
-MAN+=	cpuset.3 expand_number.3 flopen.3 fparseln.3 getlocalbase.3 hexdump.3 \
-	humanize_number.3 kinfo_getallproc.3 kinfo_getfile.3 \
+MAN+=	cpuset.3 expand_number.3 flopen.3 fparseln.3 ftime.3 getlocalbase.3 \
+	hexdump.3 humanize_number.3 kinfo_getallproc.3 kinfo_getfile.3 \
 	kinfo_getproc.3 kinfo_getvmmap.3 kinfo_getvmobject.3 kld.3 \
 	login_auth.3 login_cap.3 \
 	login_class.3 login_ok.3 login_times.3 login_tty.3 pidfile.3 \
diff --git a/lib/libcompat/4.1/ftime.3 b/lib/libutil/ftime.3
similarity index 98%
rename from lib/libcompat/4.1/ftime.3
rename to lib/libutil/ftime.3
index 48eb465aed31..dbed25317115 100644
--- a/lib/libcompat/4.1/ftime.3
+++ b/lib/libutil/ftime.3
@@ -27,14 +27,14 @@
 .\"
 .\"     @(#)ftime.3	8.1 (Berkeley) 6/4/93
 .\"
-.Dd August 4, 2018
+.Dd May 28, 2024
 .Dt FTIME 3
 .Os
 .Sh NAME
 .Nm ftime
 .Nd get date and time
 .Sh LIBRARY
-.Lb libcompat
+.Lb libuitl
 .Sh SYNOPSIS
 .In sys/types.h
 .In sys/timeb.h
diff --git a/lib/libcompat/4.1/ftime.c b/lib/libutil/ftime.c
similarity index 99%
rename from lib/libcompat/4.1/ftime.c
rename to lib/libutil/ftime.c
index 5ea57bca40fd..b31fca907883 100644
--- a/lib/libcompat/4.1/ftime.c
+++ b/lib/libutil/ftime.c
@@ -33,6 +33,8 @@
 #include <sys/cdefs.h>
 #include <sys/types.h>
 #include <sys/time.h>
+
+#define _IN_LIBUITL
 #include <sys/timeb.h>
 
 int
diff --git a/lib/msun/man/erf.3 b/lib/msun/man/erf.3
index e0771863cca1..8d66017ed11c 100644
--- a/lib/msun/man/erf.3
+++ b/lib/msun/man/erf.3
@@ -25,9 +25,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\"     from: @(#)erf.3	6.4 (Berkeley) 4/20/91
-.\"
-.Dd July 13, 2014
+.Dd June 23, 2024
 .Dt ERF 3
 .Os
 .Sh NAME
@@ -88,6 +86,17 @@ subtracts the result of the error function
 from 1.0.
 .Sh SEE ALSO
 .Xr math 3
+.Sh STANDARDS
+The
+.Fn erf ,
+.Fn erff ,
+.Fn erfl ,
+.Fn erfc ,
+.Fn erfcf
+and
+.Fn erfcl
+functions conform to
+.St -isoC-99 .
 .Sh HISTORY
 The
 .Fn erf
diff --git a/lib/ncurses/config.mk b/lib/ncurses/config.mk
index 8a3e7d0ffa59..50f333a547c9 100644
--- a/lib/ncurses/config.mk
+++ b/lib/ncurses/config.mk
@@ -3,8 +3,8 @@
 
 NCURSES_DIR=	${SRCTOP}/contrib/ncurses
 NCURSES_MAJOR=	6
-NCURSES_MINOR=	2
-NCURSES_PATCH=	20210220
+NCURSES_MINOR=	5
+NCURSES_PATCH=	20240407
 
 TINFO_OBJDIR?=	${.OBJDIR:H}/tinfo
 
diff --git a/lib/ncurses/tinfo/Makefile b/lib/ncurses/tinfo/Makefile
index c1ea75d3aacd..b202a40a1cc3 100644
--- a/lib/ncurses/tinfo/Makefile
+++ b/lib/ncurses/tinfo/Makefile
@@ -54,6 +54,8 @@ HAVE_TERMIO_H=		0
 HAVE_VSSCANF=		1
 HAVE_STDINT_H=		1
 HEADER_STDBOOL=		1
+HAVE_STDNORETURN_H=	0
+ENABLE_SIGWINCH=	1
 # XXX amd64 1L and int
 ONEUL=			1U
 TYPEOF_CHTYPE=		uint32_t
@@ -332,6 +334,7 @@ curses.head: curses.h.in
 	    -e "/@BROKEN_LINKER@/s%%${BROKEN_LINKER}%" \
 	    -e "/@HAVE_VSSCANF@/s%%${HAVE_VSSCANF}%" \
 	    -e "/@HAVE_STDINT_H@/s%%${HAVE_STDINT_H}%" \
+	    -e "/@HAVE_STDNORETURN_H@/s%%${HAVE_STDNORETURN_H}%" \
 	    -e "/@NCURSES_CH_T@/s%%${NCURSES_CH_T}%" \
 	    -e "/@NCURSES_CONST@/s%%${NCURSES_CONST}%" \
 	    -e "/@NCURSES_EXT_COLORS@/s%%${NCURSES_EXT_COLORS}%" \
@@ -342,6 +345,7 @@ curses.head: curses.h.in
 	    -e "/@NCURSES_MBSTATE_T@/s%%${NCURSES_MBSTATE_T}%" \
 	    -e "/@NCURSES_MINOR@/s%%${NCURSES_MINOR}%" \
 	    -e "/@NCURSES_MOUSE_VERSION@/s%%${NCURSES_MOUSE_VERSION}%" \
+	    -e "/@NCURSES_XNAMES@/s%%${NCURSES_XNAMES}%" \
 	    -e "/@NCURSES_OK_WCHAR_T@/s%%${NCURSES_OK_WCHAR_T}%" \
 	    -e "/@NCURSES_OPAQUE@/s%%${NCURSES_OPAQUE}%" \
 	    -e "/@NCURSES_OPAQUE_FORM@/s%%${NCURSES_OPAQUE_FORM}%" \
@@ -367,6 +371,7 @@ curses.head: curses.h.in
 	    -e "s%@cf_cv_enable_lp64@%${ENABLE_LP64}%g" \
 	    -e "s%@cf_cv_enable_opaque@%${ENABLE_OPAQUE}%g" \
 	    -e "s%@cf_cv_enable_reentrant@%${ENABLE_REENTRANT}%g" \
+	    -e "s%@cf_cv_enable_sigwinch@%${ENABLE_SIGWINCH}%g" \
 	    -e "s%@cf_cv_header_stdbool_h@%${HEADER_STDBOOL}%g" \
 	    -e "s%@cf_cv_type_of_bool@%${TYPE_OF_BOOL}%g" \
 	    -e "s%@cf_cv_typeof_chtype@%${TYPEOF_CHTYPE}%g" \
diff --git a/lib/ncurses/tinfo/ncurses_cfg.h b/lib/ncurses/tinfo/ncurses_cfg.h
index 556938aaa586..33890f300310 100644
--- a/lib/ncurses/tinfo/ncurses_cfg.h
+++ b/lib/ncurses/tinfo/ncurses_cfg.h
@@ -47,35 +47,47 @@
  *	https://invisible-island.net/autoconf/
  *	ftp://ftp.invisible-island.net/autoconf/
  */
-
-
 #ifndef NC_CONFIG_H
 #define NC_CONFIG_H
 
 #define PACKAGE "ncurses"
-#define NCURSES_VERSION "6.2"
-#define NCURSES_PATCHDATE 20210220
+#define NCURSES_VERSION "6.5"
+#define NCURSES_PATCHDATE 20240427
 #define SYSTEM_NAME "FreeBSD"
 #if 0
 #include <stdlib.h>
 #endif
 #define HAVE_LONG_FILE_NAMES 1
 #define MIXEDCASE_FILENAMES 1
-#ifdef __FreeBSD__
+#define STDC_HEADERS 1
+#define USE_GETCAP 1
+#define USE_BSD_TPUTS 1
+#define HAVE_BSD_CGETENT 1
+#define HAVE_SYS_TYPES_H 1
+#define HAVE_SYS_STAT_H 1
+#define HAVE_STDLIB_H 1
+#define HAVE_STRING_H 1
+#define HAVE_MEMORY_H 1
+#define HAVE_STRINGS_H 1
+#define HAVE_INTTYPES_H 1
+#define HAVE_STDINT_H 1
+#define HAVE_UNISTD_H 1
+#define HAVE_DIRENT_H 1
 #define USE_SYSMOUSE 1
-#endif
 #define TERMINFO_DIRS "/usr/share/terminfo:/usr/local/share/terminfo:/usr/local/share/site-terminfo"
 #define TERMINFO "/usr/share/terminfo"
 #define HAVE_BIG_CORE 1
 #define TERMPATH "/etc/termcap:/usr/share/misc/termcap"
-#define USE_GETCAP 1
+#define USE_HOME_TERMINFO 1
+#define USE_ROOT_ENVIRON 1
+#define USE_ROOT_ACCESS 1
+#define USE_SETUID_ENVIRON 1
 #define HAVE_UNISTD_H 1
 #define HAVE_REMOVE 1
 #define HAVE_UNLINK 1
 #define HAVE_LINK 1
 #define HAVE_SYMLINK 1
 #define USE_LINKS 1
-#define BSD_TPUTS 1
 #define HAVE_LANGINFO_CODESET 1
 #define USE_WIDEC_SUPPORT 1
 #define NCURSES_WIDECHAR 1
@@ -84,6 +96,7 @@
 #define HAVE_PUTWC 1
 #define HAVE_BTOWC 1
 #define HAVE_WCTOB 1
+#define HAVE_WMEMCHR 1
 #define HAVE_MBTOWC 1
 #define HAVE_WCTOMB 1
 #define HAVE_MBLEN 1
@@ -95,16 +108,7 @@
 #define HAVE_MBSTOWCS 1
 #define NEED_WCHAR_H 1
 #define HAVE_FSEEKO 1
-#define STDC_HEADERS 1
-#define HAVE_SYS_TYPES_H 1
-#define HAVE_SYS_STAT_H 1
-#define HAVE_STDLIB_H 1
-#define HAVE_STRING_H 1
-#define HAVE_MEMORY_H 1
-#define HAVE_STRINGS_H 1
-#define HAVE_INTTYPES_H 1
-#define HAVE_STDINT_H 1
-#define HAVE_UNISTD_H 1
+#define RGB_PATH "no"
 #define SIZEOF_SIGNED_CHAR 1
 #define NCURSES_EXT_FUNCS 1
 #define HAVE_ASSUME_DEFAULT_COLORS 1
@@ -114,7 +118,6 @@
 #define HAVE_RESIZE_TERM 1
 #define HAVE_TERM_ENTRY_H 1
 #define HAVE_USE_DEFAULT_COLORS 1
-#define HAVE_USE_EXTENDED_NAMES 1
 #define HAVE_USE_SCREEN 1
 #define HAVE_USE_WINDOW 1
 #define HAVE_WRESIZE 1
@@ -127,10 +130,10 @@
 #define NCURSES_EXT_PUTWIN 1
 #define NCURSES_NO_PADDING 1
 #define USE_SIGWINCH 1
+#define NCURSES_XNAMES 1
 #define NCURSES_WRAP_PREFIX "_nc_"
 #define USE_ASSUMED_COLOR 1
 #define USE_HASHMAP 1
-#define USE_COLORFGBG 1
 #define GCC_SCANF 1
 #define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
 #define GCC_PRINTF 1
@@ -138,9 +141,7 @@
 #define GCC_UNUSED __attribute__((unused))
 #define GCC_NORETURN __attribute__((noreturn))
 #define HAVE_NC_ALLOC_H 1
-#define HAVE_GETTIMEOFDAY 1
-#define STDC_HEADERS 1
-#define HAVE_DIRENT_H 1
+#define HAVE_MATH_FUNCS 1
 #define TIME_WITH_SYS_TIME 1
 #define HAVE_REGEX_H_FUNCS 1
 #define HAVE_FCNTL_H 1
@@ -149,13 +150,13 @@
 #define HAVE_LOCALE_H 1
 #define HAVE_MATH_H 1
 #define HAVE_POLL_H 1
+#define HAVE_SYS_AUXV_H 1
 #define HAVE_SYS_IOCTL_H 1
 #define HAVE_SYS_PARAM_H 1
 #define HAVE_SYS_POLL_H 1
 #define HAVE_SYS_SELECT_H 1
 #define HAVE_SYS_TIME_H 1
 #define HAVE_SYS_TIMES_H 1
-#define HAVE_TTYENT_H 1
 #define HAVE_UNISTD_H 1
 #define HAVE_WCTYPE_H 1
 #define HAVE_UNISTD_H 1
@@ -169,20 +170,20 @@
 #define HAVE_SYS_TIME_SELECT 1
 #define SIG_ATOMIC_T volatile sig_atomic_t
 #define HAVE_ERRNO 1
+#define HAVE_CLOCK_GETTIME 1
+#define HAVE_FPATHCONF 1
 #define HAVE_GETCWD 1
 #define HAVE_GETEGID 1
 #define HAVE_GETEUID 1
 #define HAVE_GETOPT 1
-#define HAVE_GETTTYNAM 1
+#define HAVE_GETUID 1
 #define HAVE_ISSETUGID 1
 #define HAVE_LOCALECONV 1
 #define HAVE_POLL 1
-#define HAVE_PUTENV 1
 #define HAVE_REMOVE 1
 #define HAVE_SELECT 1
 #define HAVE_SETBUF 1
 #define HAVE_SETBUFFER 1
-#define HAVE_SETENV 1
 #define HAVE_SETVBUF 1
 #define HAVE_SIGACTION 1
 #define HAVE_SIGVEC 1
@@ -194,7 +195,8 @@
 #define HAVE_TIMES 1
 #define HAVE_TSEARCH 1
 #define HAVE_VSNPRINTF 1
-#define HAVE_BSD_CGETENT 1
+#define HAVE_PATH_TTYS 1
+#define HAVE_GETTTYNAM 1
 #define HAVE_ISASCII 1
 #define HAVE_NANOSLEEP 1
 #define HAVE_TERMIOS_H 1
@@ -206,6 +208,7 @@
 #define HAVE_MKSTEMP 1
 #define HAVE_SIZECHANGE 1
 #define HAVE_WORKING_POLL 1
+#define HAVE_CONSISTENT_MB_LEN_MAX 1
 #define HAVE_VA_COPY 1
 #define HAVE_UNISTD_H 1
 #define HAVE_FORK 1
@@ -219,6 +222,7 @@
 #define HAVE_IOSTREAM 1
 #define IOSTREAM_NAMESPACE 1
 #define SIZEOF_BOOL 1
+#define CPP_HAS_OVERRIDE 1
 #define CPP_HAS_STATIC_CAST 1
 #define SIZEOF_WCHAR_T 4
 #define HAVE_SLK_COLOR 1
@@ -229,9 +233,8 @@
 #define HAVE_FORM_H 1
 #define HAVE_LIBFORM 1
 #define NCURSES_PATHSEP ':'
-#define NCURSES_VERSION_STRING "6.2.20210220"
+#define NCURSES_VERSION_STRING "6.5.20240427"
 #define NCURSES_OSPEED_COMPAT 1
-#define HAVE_CURSES_DATA_BOOLNAMES 1
 
 #include <ncurses_def.h>
 
diff --git a/libexec/nuageinit/nuage.lua b/libexec/nuageinit/nuage.lua
index 55486ae2b122..ca70c778791b 100644
--- a/libexec/nuageinit/nuage.lua
+++ b/libexec/nuageinit/nuage.lua
@@ -72,7 +72,12 @@ local function adduser(pwd)
 		warnmsg("Argument should be a table")
 		return nil
 	end
-	local f = io.popen("getent passwd "..pwd.name)
+	local root = os.getenv("NUAGE_FAKE_ROOTDIR")
+	local cmd = "pw "
+	if root then
+		cmd = cmd .. "-R " .. root .. " "
+	end
+	local f = io.popen(cmd .. " usershow " ..pwd.name .. " -7 2>/dev/null")
 	local pwdstr = f:read("*a")
 	f:close()
 	if pwdstr:len() ~= 0 then
@@ -109,8 +114,7 @@ local function adduser(pwd)
 		precmd = "echo "..pwd.plain_text_passwd .. "| "
 		postcmd = " -H 0 "
 	end
-	local root = os.getenv("NUAGE_FAKE_ROOTDIR")
-	local cmd = precmd .. "pw "
+	cmd = precmd .. "pw "
 	if root then
 		cmd = cmd .. "-R " .. root .. " "
 	end
@@ -140,7 +144,12 @@ local function addgroup(grp)
 		warnmsg("Argument should be a table")
 		return false
 	end
-	local f = io.popen("getent group "..grp.name)
+	local root = os.getenv("NUAGE_FAKE_ROOTDIR")
+	local cmd = "pw "
+	if root then
+		cmd = cmd .. "-R " .. root .. " "
+	end
+	local f = io.popen(cmd .. " groupshow " ..grp.name .. " 2>/dev/null")
 	local grpstr = f:read("*a")
 	f:close()
 	if grpstr:len() ~= 0 then
@@ -151,8 +160,7 @@ local function addgroup(grp)
 		local list = splitlist(grp.members)
 		extraargs = " -M " .. table.concat(list, ',')
 	end
-	local root = os.getenv("NUAGE_FAKE_ROOTDIR")
-	local cmd = "pw "
+	cmd = "pw "
 	if root then
 		cmd = cmd .. "-R " .. root .. " "
 	end
@@ -169,6 +177,10 @@ end
 local function addsshkey(homedir, key)
 	local chownak = false
 	local chowndotssh = false
+	local root = os.getenv("NUAGE_FAKE_ROOTDIR")
+	if root then
+		homedir = root .. "/" .. homedir
+	end
 	local ak_path = homedir .. "/.ssh/authorized_keys"
 	local dotssh_path = homedir .. "/.ssh"
 	local dirattrs = lfs.attributes(ak_path)
diff --git a/libexec/nuageinit/tests/nuageinit.sh b/libexec/nuageinit/tests/nuageinit.sh
index 926233bcf66d..42c95e1b2abd 100644
--- a/libexec/nuageinit/tests/nuageinit.sh
+++ b/libexec/nuageinit/tests/nuageinit.sh
@@ -173,16 +173,17 @@ EOF
 config2_pubkeys_body()
 {
 	here=$(pwd)
+	export NUAGE_FAKE_ROOTDIR=$(pwd)
 	if [ $(id -u) -ne 0 ]; then
 		atf_skip "root required"
 	fi
 	mkdir -p media/nuageinit
-	cat > media/nuageinit/meta_data.json << EOF
-{
-   "public_keys": {
-       "mykey": "ssh-rsa AAAAB3NzaC1y...== Generated by Nova"
-   },
-}
+	touch media/nuageinit/meta_data.json
+	cat > media/nuageinit/user-data << EOF
+#cloud-config
+
+ssh_authorized_keys:
+  - "ssh-rsa AAAAB3NzaC1y...== Generated by Nova"
 EOF
 	mkdir -p etc
 	cat > etc/master.passwd <<EOF
@@ -194,7 +195,6 @@ EOF
 wheel:*:0:root
 users:*:1:
 EOF
-	export NUAGE_FAKE_ROOTDIR=$(pwd)
 	atf_check /usr/libexec/nuageinit ${here}/media/nuageinit config-2
 	atf_check -o inline:"ssh-rsa AAAAB3NzaC1y...== Generated by Nova\n" cat home/freebsd/.ssh/authorized_keys
 }
diff --git a/libexec/rc/rc.conf b/libexec/rc/rc.conf
index 7f9e67981eec..a7b149bb0cd4 100644
--- a/libexec/rc/rc.conf
+++ b/libexec/rc/rc.conf
@@ -61,8 +61,8 @@ varmfs_flags="-S"	# Extra mount options for the mfs /var
 mfs_type="auto"		# "md", "tmpfs", "auto" to prefer tmpfs with md as fallback
 populate_var="AUTO"	# Set to YES to always (re)populate /var, NO to never
 cleanvar_enable="YES" 	# Clean the /var directory
-var_run_enable="NO" 	# Save/restore /var/run structure at shutdown/reboot
-var_run_autosave="NO" 	# Only restore /var/run structure at shutdown/reboot
+var_run_enable="YES" 	# Save/restore /var/run structure at shutdown/reboot
+var_run_autosave="YES" 	# Only restore /var/run structure at shutdown/reboot
 			# The user is expected to issue service var_run save to
 			# manually save the /var/run mtree
 var_run_mtree="/var/db/mtree/BSD.var-run.mtree"
diff --git a/libexec/rc/rc.d/devd b/libexec/rc/rc.d/devd
index 43fb9d5928dd..fe19abd817b4 100755
--- a/libexec/rc/rc.d/devd
+++ b/libexec/rc/rc.d/devd
@@ -14,7 +14,8 @@ desc="Device state change daemon"
 rcvar="devd_enable"
 command="/sbin/${name}"
 
-start_precmd=${name}_prestart
+devd_offcmd=devd_off
+start_precmd=find_pidfile
 stop_precmd=find_pidfile
 
 find_pidfile()
@@ -26,10 +27,8 @@ find_pidfile()
 	fi
 }
 
-devd_prestart()
+devd_off()
 {
-	find_pidfile
-
 	# If devd is disabled, turn it off in the kernel to avoid unnecessary
 	# memory usage.
 	if ! checkyesno ${rcvar}; then
diff --git a/libexec/rc/rc.d/var_run b/libexec/rc/rc.d/var_run
index daff06ce1a3f..bf8f0cb737b4 100755
--- a/libexec/rc/rc.d/var_run
+++ b/libexec/rc/rc.d/var_run
@@ -17,11 +17,6 @@ stop_cmd="_var_run_stop"
 
 load_rc_config $name
 
-# Set defaults
-: ${var_run_enable:="NO"}
-: ${var_run_mtree:="/var/db/mtree/BSD.var-run.mtree"}
-: ${var_run_autosave:="YES"}
-
 _var_run_load() {
 	test -f ${var_run_mtree} &&
 		mtree -U -i -q -f ${var_run_mtree} -p /var/run > /dev/null
diff --git a/libexec/rc/rc.subr b/libexec/rc/rc.subr
index 332718dc6f2c..05d46f74e598 100644
--- a/libexec/rc/rc.subr
+++ b/libexec/rc/rc.subr
@@ -816,6 +816,9 @@ startmsg()
 #
 #	${name}_limits	n	limits(1) to apply to ${command}.
 #
+#	${name}_offcmd	n	If set, run during start
+#				if a service is not enabled.
+#
 #	${rc_arg}_cmd	n	If set, use this as the method when invoked;
 #				Otherwise, use default command (see below)
 #
@@ -1051,13 +1054,13 @@ run_rc_command()
 		    -a "$rc_arg" != "describe" -a "$rc_arg" != "status" ] ||
 		    [ -n "${rcvar}" -a "$rc_arg" = "stop" -a -z "${rc_pid}" ]; then
 			if ! checkyesno ${rcvar}; then
-				if [ -n "${rc_quiet}" ]; then
-					return 0
-				fi
+			    [ "$rc_arg" = "start" ] && _run_rc_offcmd
+			    if [ -z "${rc_quiet}" ]; then
 				echo -n "Cannot '${rc_arg}' $name. Set ${rcvar} to "
 				echo -n "YES in /etc/rc.conf or use 'one${rc_arg}' "
 				echo "instead of '${rc_arg}'."
-				return 0
+			    fi
+			    return 0
 			fi
 		fi
 
@@ -1347,10 +1350,25 @@ $_cpusetcmd $command $rc_flags $command_args"
 #
 #	name	       R/W
 #	------------------
+#	_offcmd		R
 #	_precmd		R
 #	_postcmd	R
 #	_return		W
 #
+_run_rc_offcmd()
+{
+	eval _offcmd=\$${name}_offcmd
+	if [ -n "$_offcmd" ]; then
+		if [ -n "$_env" ]; then
+			eval "export -- $_env"
+		fi
+		debug "run_rc_command: ${name}_offcmd: $_offcmd $rc_extra_args"
+		eval "$_offcmd $rc_extra_args"
+		_return=$?
+	fi
+	return 0
+}
+
 _run_rc_precmd()
 {
 	check_required_before "$rc_arg" || return 1
diff --git a/libexec/tftpd/tftpd.c b/libexec/tftpd/tftpd.c
index 00c1257ce548..cef8d0278a55 100644
--- a/libexec/tftpd/tftpd.c
+++ b/libexec/tftpd/tftpd.c
@@ -692,28 +692,27 @@ find_next_name(char *filename, int *fd)
 int
 validate_access(int peer, char **filep, int mode)
 {
-	struct stat stbuf;
-	int	fd;
-	int	error;
-	struct dirlist *dirp;
 	static char pathname[MAXPATHLEN];
+	struct stat sb;
+	struct dirlist *dirp;
 	char *filename = *filep;
+	int	err, fd;
 
 	/*
 	 * Prevent tricksters from getting around the directory restrictions
 	 */
-	if (strstr(filename, "/../"))
+	if (strncmp(filename, "../", 3) == 0 ||
+	    strstr(filename, "/../") != NULL)
 		return (EACCESS);
 
 	if (*filename == '/') {
 		/*
-		 * Allow the request if it's in one of the approved locations.
-		 * Special case: check the null prefix ("/") by looking
-		 * for length = 1 and relying on the arg. processing that
-		 * it's a /.
+		 * Absolute file name: allow the request if it's in one of the
+		 * approved locations.
 		 */
 		for (dirp = dirs; dirp->name != NULL; dirp++) {
 			if (dirp->len == 1)
+				/* Only "/" can have len 1 */
 				break;
 			if (strncmp(filename, dirp->name, dirp->len) == 0 &&
 			    filename[dirp->len] == '/')
@@ -722,30 +721,20 @@ validate_access(int peer, char **filep, int mode)
 		/* If directory list is empty, allow access to any file */
 		if (dirp->name == NULL && dirp != dirs)
 			return (EACCESS);
-		if (stat(filename, &stbuf) < 0)
+		if (stat(filename, &sb) != 0)
 			return (errno == ENOENT ? ENOTFOUND : EACCESS);
-		if ((stbuf.st_mode & S_IFMT) != S_IFREG)
+		if (!S_ISREG(sb.st_mode))
 			return (ENOTFOUND);
 		if (mode == RRQ) {
-			if ((stbuf.st_mode & S_IROTH) == 0)
+			if ((sb.st_mode & S_IROTH) == 0)
 				return (EACCESS);
 		} else {
-			if (check_woth && ((stbuf.st_mode & S_IWOTH) == 0))
+			if (check_woth && (sb.st_mode & S_IWOTH) == 0)
 				return (EACCESS);
 		}
 	} else {
-		int err;
-
 		/*
 		 * Relative file name: search the approved locations for it.
-		 * Don't allow write requests that avoid directory
-		 * restrictions.
-		 */
-
-		if (!strncmp(filename, "../", 3))
-			return (EACCESS);
-
-		/*
 		 * If the file exists in one of the directories and isn't
 		 * readable, continue looking. However, change the error code
 		 * to give an indication that the file exists.
@@ -753,18 +742,20 @@ validate_access(int peer, char **filep, int mode)
 		err = ENOTFOUND;
 		for (dirp = dirs; dirp->name != NULL; dirp++) {
 			snprintf(pathname, sizeof(pathname), "%s/%s",
-				dirp->name, filename);
-			if (stat(pathname, &stbuf) == 0 &&
-			    (stbuf.st_mode & S_IFMT) == S_IFREG) {
-				if (mode == RRQ) {
-					if ((stbuf.st_mode & S_IROTH) != 0)
-						break;
-				} else {
-					if (!check_woth || ((stbuf.st_mode & S_IWOTH) != 0))
-						break;
-				}
-				err = EACCESS;
+			    dirp->name, filename);
+			if (stat(pathname, &sb) != 0)
+				continue;
+			if (!S_ISREG(sb.st_mode))
+				continue;
+			err = EACCESS;
+			if (mode == RRQ) {
+				if ((sb.st_mode & S_IROTH) == 0)
+					continue;
+			} else {
+				if (check_woth && (sb.st_mode & S_IWOTH) == 0)
+					continue;
 			}
+			break;
 		}
 		if (dirp->name != NULL)
 			*filep = filename = pathname;
@@ -778,27 +769,27 @@ validate_access(int peer, char **filep, int mode)
 	 * This option is handled here because it (might) require(s) the
 	 * size of the file.
 	 */
-	option_tsize(peer, NULL, mode, &stbuf);
+	option_tsize(peer, NULL, mode, &sb);
 
-	if (mode == RRQ)
+	if (mode == RRQ) {
 		fd = open(filename, O_RDONLY);
-	else {
-		if (create_new) {
-			if (increase_name) {
-				error = find_next_name(filename, &fd);
-				if (error > 0)
-					return (error + 100);
-			} else
-				fd = open(filename,
-				    O_WRONLY | O_TRUNC | O_CREAT,
-				    S_IRUSR | S_IWUSR | S_IRGRP |
-				    S_IWGRP | S_IROTH | S_IWOTH );
-		} else
-			fd = open(filename, O_WRONLY | O_TRUNC);
+	} else if (create_new) {
+		if (increase_name) {
+			err = find_next_name(filename, &fd);
+			if (err > 0)
+				return (err + 100);
+		} else {
+			fd = open(filename,
+			    O_WRONLY | O_TRUNC | O_CREAT,
+			    S_IRUSR | S_IWUSR | S_IRGRP |
+			    S_IWGRP | S_IROTH | S_IWOTH );
+		}
+	} else {
+		fd = open(filename, O_WRONLY | O_TRUNC);
 	}
 	if (fd < 0)
 		return (errno + 100);
-	file = fdopen(fd, (mode == RRQ)? "r":"w");
+	file = fdopen(fd, mode == RRQ ? "r" : "w");
 	if (file == NULL) {
 		close(fd);
 		return (errno + 100);
diff --git a/release/Makefile b/release/Makefile
index ba9499ac5a3f..32e59a1a5c90 100644
--- a/release/Makefile
+++ b/release/Makefile
@@ -14,6 +14,7 @@
 #  install: Invokes the release-install and vm-install targets
 #  release-install: Copies all release installation media into ${DESTDIR}
 #  vm-install: Copies all virtual machine images into ${DESTDIR}
+#  cloud-install: Copies non-uploaded cloud images into ${DESTDIR}
 #
 # Variables affecting the build process:
 #  WORLDDIR: location of src tree -- must have built world and default kernel
@@ -329,7 +330,7 @@ real-release:
 	${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} obj
 	${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${RELEASE_TARGETS}
 
-install:	release-install vm-install
+install:	release-install vm-install .WAIT cloud-install
 
 release-install:
 .if defined(DESTDIR) && !empty(DESTDIR)
diff --git a/release/Makefile.mirrors b/release/Makefile.mirrors
index 591fd85b29ea..1888f86d3002 100644
--- a/release/Makefile.mirrors
+++ b/release/Makefile.mirrors
@@ -53,6 +53,11 @@ STAGE_TARGETS+=		vm-images-stage
 VM_DIR=			${TLD}/VM-IMAGES/${REVISION}-${BRANCH}/${TARGET_ARCH}
 .endif
 
+.if defined(WITH_CLOUDWARE) && !empty(WITH_CLOUDWARE)
+STAGE_TARGETS+=		ci-images-stage
+CI_DIR=			${TLD}/CI-IMAGES/${REVISION}-${BRANCH}/${TARGET_ARCH}
+.endif
+
 CLEANFILES+=		${STAGE_TARGETS}
 CHECKSUM_FILES?=	SHA512 SHA256
 SNAP_SUFFIX!=		echo ${_SNAP_SUFFIX:S,^-,,1} | tr -d ' '
@@ -204,6 +209,24 @@ vm-images-stage:
 		${OSRELEASE}-${FS}.${VMFORMAT}.xz
 .  endfor
 . endfor
+. if defined(WITH_CLOUDWARE) && !empty(WITH_CLOUDWARE)
+.  for CW in ${CLOUDWARE}
+.   if ${CW} == BASIC-CLOUDINIT
+.    for VMFORMAT in ${${CW}_FORMAT}
+.     for FS in ${${CW}_FSLIST}
+	cd ${RELEASEDIR}/vmimages && \
+		mv ${OSRELEASE}-${CW}.${FS}.${VMFORMAT}.xz \
+		${OSRELEASE}-${CW}-${SNAP_SUFFIX}.${FS}.${VMFORMAT}.xz
+	cp -p ${RELEASEDIR}/vmimages/${OSRELEASE}-${CW}-${SNAP_SUFFIX}.${FS}.${VMFORMAT}.xz \
+		${VM_DIR}/${BUILDDATE}/${OSRELEASE}-${CW}-${SNAP_SUFFIX}.${FS}.${VMFORMAT}.xz
+	cd ${VM_DIR}/Latest && \
+		ln -s ../${BUILDDATE}/${OSRELEASE}-${CW}-${SNAP_SUFFIX}.${FS}.${VMFORMAT}.xz \
+		${OSRELEASE}-${CW}.${FS}.${VMFORMAT}.xz
+.     endfor
+.    endfor
+.   endif
+.  endfor
+. endif
 	cd ${RELEASEDIR}/vmimages && rm -f CHECKSUM.*
 . for CHECKSUM in ${CHECKSUM_FILES}
 	cd ${RELEASEDIR}/vmimages && \
@@ -227,11 +250,88 @@ vm-images-stage:
 		${VM_DIR}/Latest/${OSRELEASE}-${FS}.${VMFORMAT}.xz
 .  endfor
 . endfor
+. if defined(WITH_CLOUDWARE) && !empty(WITH_CLOUDWARE)
+.  for CW in ${CLOUDWARE}
+.   if ${CW} == BASIC-CLOUDINIT
+.    for VMFORMAT in ${${CW}_FORMAT}
+.     for FS in ${${CW}_FSLIST}
+	cp -p ${RELEASEDIR}/vmimages/${OSRELEASE}-${CW}.${FS}.${VMFORMAT}.xz \
+		${VM_DIR}/Latest/${OSRELEASE}-${CW}.${FS}.${VMFORMAT}.xz
+.     endfor
+.    endfor
+.   endif
+.  endfor
+. endif
 . for CHECKSUM in ${CHECKSUM_FILES}
 	cp -p ${RELEASEDIR}/vmimages/CHECKSUM.${CHECKSUM} \
 		${VM_DIR}/Latest/CHECKSUM.${CHECKSUM}
 . endfor
 .endif
 
+ci-images-stage:
+	mkdir -p ${CI_DIR}
+.if defined(SNAPSHOT) && !empty(SNAPSHOT)
+. if exists(${CI_DIR}/Latest)
+	rm -rf ${CI_DIR}/Latest
+. endif
+	mkdir -p ${CI_DIR}/Latest
+	mkdir -p ${CI_DIR}/${BUILDDATE}
+. for CW in ${CLOUDWARE}
+.  if ${CW} == BASIC-CI
+.   for VMFORMAT in ${${CW}_FORMAT}
+.    for FS in ${${CW}_FSLIST}
+	cd ${RELEASEDIR}/ciimages && \
+		mv ${OSRELEASE}-${CW}-${FS}.${VMFORMAT}.xz \
+		${OSRELEASE}-${CW}-${SNAP_SUFFIX}.${FS}.${VMFORMAT}.xz
+	cp -p ${RELEASEDIR}/ciimages/${OSRELEASE}-${CW}-${SNAP_SUFFIX}.${FS}.${VMFORMAT}.xz \
+		${CI_DIR}/${BUILDDATE}/${OSRELEASE}-${CW}-${SNAP_SUFFIX}.${FS}.${VMFORMAT}.xz
+	cd ${CI_DIR}/Latest && \
+		ln -s ../${BUILDDATE}/${OSRELEASE}-${CW}-${SNAP_SUFFIX}.${FS}.${VMFORMAT}.xz \
+		${OSRELEASE}-${CW}.${FS}.${VMFORMAT}.xz
+.    endfor
+	cd ${RELEASEDIR}/ciimages && \
+		mv ${OSRELEASE}-${CW}.${VMFORMAT}.xz \
+		${OSRELEASE}-${CW}-${SNAP_SUFFIX}.${VMFORMAT}.xz
+	cp -p ${RELEASEDIR}/ciimages/${OSRELEASE}-${CW}-${SNAP_SUFFIX}.${VMFORMAT}.xz \
+		${CI_DIR}/${BUILDDATE}/${OSRELEASE}-${CW}-${SNAP_SUFFIX}.${VMFORMAT}.xz
+	cd ${CI_DIR}/Latest && \
+		ln -s ../${BUILDDATE}/${OSRELEASE}-${CW}-${SNAP_SUFFIX}.${VMFORMAT}.xz \
+		${OSRELEASE}-${CW}.${VMFORMAT}.xz
+.   endfor
+.  endif
+. endfor
+	cd ${RELEASEDIR}/ciimages && rm -f CHECKSUM.*
+. for CHECKSUM in ${CHECKSUM_FILES}
+	cd ${RELEASEDIR}/ciimages && \
+		${CHECKSUM:tl} ${OSRELEASE}* > CHECKSUM.${CHECKSUM}-${SNAP_SUFFIX}
+	cp -p ${RELEASEDIR}/ciimages/CHECKSUM.${CHECKSUM}-${SNAP_SUFFIX} \
+		${CI_DIR}/${BUILDDATE}/CHECKSUM.${CHECKSUM}-${SNAP_SUFFIX}
+	cd ${CI_DIR}/Latest && \
+		ln -s ../${BUILDDATE}/CHECKSUM.${CHECKSUM}-${SNAP_SUFFIX} \
+		CHECKSUM.${CHECKSUM}
+. endfor
+.else # not snapshot
+. if exists(${CI_DIR}/Latest)
+	rm -rf ${CI_DIR}/Latest
+. endif
+	mkdir -p ${CI_DIR}/Latest
+. for CW in ${CLOUDWARE}
+.  if ${CW} == BASIC-CI
+.   for VMFORMAT in ${${CW}_FORMAT}
+.    for FS in ${${CW}_FSLIST}
+	cp -p ${RELEASEDIR}/ciimages/${OSRELEASE}-${CW}-${FS}.${VMFORMAT}.xz \
+		${CI_DIR}/Latest/${OSRELEASE}-${CW}.${FS}.${VMFORMAT}.xz
+.    endfor
+	cp -p ${RELEASEDIR}/ciimages/${OSRELEASE}-${CW}.${VMFORMAT}.xz \
+		${CI_DIR}/Latest/${OSRELEASE}-${CW}.${VMFORMAT}.xz
+.   endfor
+.  endif
+. endfor
+. for CHECKSUM in ${CHECKSUM_FILES}
+	cp -p ${RELEASEDIR}/ciimages/CHECKSUM.${CHECKSUM} \
+		${CI_DIR}/Latest/CHECKSUM.${CHECKSUM}
+. endfor
+.endif
+
 ftp-stage:	remove-old-bits ${STAGE_TARGETS}
 
diff --git a/release/Makefile.vm b/release/Makefile.vm
index 95d48490c353..71a4392b6b0c 100644
--- a/release/Makefile.vm
+++ b/release/Makefile.vm
@@ -223,6 +223,48 @@ vm-install:
 		${DESTDIR}/vmimages/CHECKSUM.SHA256
 .endif
 
+cloud-install-BASIC-CI:
+	mkdir -p ${DESTDIR}/ciimages
+.for _FS in ${BASIC-CI_FSLIST}
+. for _FMT in ${BASIC-CI_FORMAT}
+	cp -p ${.OBJDIR}/${BASIC-CI${_FS:tu}${_FMT:tu}IMAGE} \
+		${DESTDIR}/ciimages/${OSRELEASE}-BASIC-CI-${_FS}.${_FMT}
+	${XZ_CMD} ${DESTDIR}/ciimages/${OSRELEASE}-BASIC-CI-${_FS}.${_FMT}
+. endfor
+.endfor
+.for _FMT in ${BASIC-CI_FORMAT}
+	ln -f ${DESTDIR}/ciimages/${OSRELEASE}-BASIC-CI-${VMFS}.${_FMT}.xz \
+		${DESTDIR}/ciimages/${OSRELEASE}-BASIC-CI.${_FMT}.xz
+.endfor
+	cd ${DESTDIR}/ciimages && sha512 ${OSRELEASE}* > \
+		${DESTDIR}/ciimages/CHECKSUM.SHA512
+	cd ${DESTDIR}/ciimages && sha256 ${OSRELEASE}* > \
+		${DESTDIR}/ciimages/CHECKSUM.SHA256
+
+cloud-install-BASIC-CLOUDINIT:
+	mkdir -p ${DESTDIR}/vmimages
+.for _FS in ${BASIC-CLOUDINIT_FSLIST}
+. for _FMT in ${BASIC-CLOUDINIT_FORMAT}
+	cp -p ${.OBJDIR}/${BASIC-CLOUDINIT${_FS:tu}${_FMT:tu}IMAGE} \
+		${DESTDIR}/vmimages/${OSRELEASE}-BASIC-CLOUDINIT.${_FS}.${_FMT}
+	${XZ_CMD} ${DESTDIR}/vmimages/${OSRELEASE}-BASIC-CLOUDINIT.${_FS}.${_FMT}
+. endfor
+.endfor
+	cd ${DESTDIR}/vmimages && sha512 ${OSRELEASE}* > \
+		${DESTDIR}/vmimages/CHECKSUM.SHA512
+	cd ${DESTDIR}/vmimages && sha256 ${OSRELEASE}* > \
+		${DESTDIR}/vmimages/CHECKSUM.SHA256
+
+CLOUD_INSTALL_TGTS=
+.if defined(WITH_CLOUDWARE) && !empty(WITH_CLOUDWARE)
+. for _CW in ${CLOUDWARE}
+.  if target(cloud-install-${_CW})
+CLOUD_INSTALL_TGTS+=	cloud-install-${_CW}
+.  endif
+. endfor
+.endif
+cloud-install:	${CLOUD_INSTALL_TGTS}
+
 .if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES)
 vm-release:	${VMTARGETS}
 .else
diff --git a/release/release.sh b/release/release.sh
index 3c68f89c2cc3..cee0fbd5643d 100755
--- a/release/release.sh
+++ b/release/release.sh
@@ -337,7 +337,7 @@ chroot_build_release() {
 		fi
 		if [ -z "${VMSIZE}" ]; then
 			VMSIZE="$(eval chroot ${CHROOTDIR} \
-				make -C /usr/src/release -V VMSIZE)"
+				make -C /usr/src/release ${ARCH_FLAGS} -V VMSIZE)"
 		fi
 		RELEASE_RMAKEFLAGS="${RELEASE_RMAKEFLAGS} \
 			VMFORMATS=\"${VMFORMATS}\" VMSIZE=${VMSIZE}"
diff --git a/release/tools/ec2.conf b/release/tools/ec2.conf
index ce09ab0d2367..989e8a05a318 100644
--- a/release/tools/ec2.conf
+++ b/release/tools/ec2.conf
@@ -10,12 +10,12 @@ export VM_EXTRA_PACKAGES="${VM_EXTRA_PACKAGES} ebsnvme-id amazon-ssm-agent"
 # Services which should be enabled by default in rc.conf(5).
 export VM_RC_LIST="dev_aws_disk ntpd"
 
-# Build with a 4.9 GB partition; the growfs rc.d script will expand
+# Build with a 5.9 GB partition; the growfs rc.d script will expand
 # the partition to fill the root disk after the EC2 instance is launched.
 # Note that if this is set to <N>G, we will end up with an <N+1> GB disk
 # image since VMSIZE is the size of the filesystem partition, not the disk
 # which it resides within.
-export VMSIZE=5000m
+export VMSIZE=6000m
 
 # No swap space; it doesn't make sense to provision any as part of the disk
 # image when we could be launching onto a system with anywhere between 0.5
diff --git a/sbin/camcontrol/camcontrol.8 b/sbin/camcontrol/camcontrol.8
index 065dfbe8a1b4..9d2eec87e0e0 100644
--- a/sbin/camcontrol/camcontrol.8
+++ b/sbin/camcontrol/camcontrol.8
@@ -2330,7 +2330,7 @@ For the Report Zones command, specify a subset of zones to report.
 .It all
 Report all zones.
 This is the default.
-.It emtpy
+.It empty
 Report only empty zones.
 .It imp_open
 Report zones that are implicitly open.
diff --git a/sbin/devd/Makefile b/sbin/devd/Makefile
index f1a5f12ac478..20490c954031 100644
--- a/sbin/devd/Makefile
+++ b/sbin/devd/Makefile
@@ -11,6 +11,11 @@ DEVDDIR=	/etc/devd
 DEVD+=	asus.conf
 .endif
 
+CONFGROUPS+=		AUTOFS
+AUTOFSDIR=		${DEVDDIR}
+AUTOFS+=		autofs.conf
+AUTOFSPACKAGE=		autofs
+
 CONFGROUPS+=		DHCLIENT
 DHCLIENTDIR=		${DEVDDIR}
 DHCLIENT+=		dhclient.conf
diff --git a/sbin/devd/autofs.conf b/sbin/devd/autofs.conf
new file mode 100644
index 000000000000..a06ca7295d38
--- /dev/null
+++ b/sbin/devd/autofs.conf
@@ -0,0 +1,9 @@
+#
+# autofs(5) specific devd events
+
+# Discard autofs caches, useful for the -media special map.
+notify 100 {
+	match "system" "GEOM";
+	match "subsystem" "DEV";
+	action "/usr/sbin/automount -c";
+};
diff --git a/sbin/devd/devd.conf b/sbin/devd/devd.conf
index ea8421e76d61..50dbf19ffd4a 100644
--- a/sbin/devd/devd.conf
+++ b/sbin/devd/devd.conf
@@ -159,13 +159,6 @@ notify 0 {
 	action			"service postgresql restart";
 };
 
-# Discard autofs caches, useful for the -media special map.
-notify 100 {
-	match "system" "GEOM";
-	match "subsystem" "DEV";
-	action "/usr/sbin/automount -c";
-};
-
 # Handle userland coredumps.
 # This commented out handler makes it possible to run an
 # automated debugging session after the core dump is generated.
diff --git a/sbin/ifconfig/af_inet.c b/sbin/ifconfig/af_inet.c
index 5e3084165b33..e21956cfc4fd 100644
--- a/sbin/ifconfig/af_inet.c
+++ b/sbin/ifconfig/af_inet.c
@@ -440,7 +440,7 @@ in_exec_nl(if_ctx *ctx, unsigned long action, void *data)
 static void
 in_setdefaultmask_nl(void)
 {
-        struct in_px *px = sintab_nl[ADDR];
+	struct in_px *px = sintab_nl[ADDR];
 
 	in_addr_t i = ntohl(px->addr.s_addr);
 
@@ -451,11 +451,11 @@ in_setdefaultmask_nl(void)
 	 * we should return an error rather than warning.
 	 */
 	if (IN_CLASSA(i))
-		px->plen = IN_CLASSA_NSHIFT;
+		px->plen = 32 - IN_CLASSA_NSHIFT;
 	else if (IN_CLASSB(i))
-		px->plen = IN_CLASSB_NSHIFT;
+		px->plen = 32 - IN_CLASSB_NSHIFT;
 	else
-		px->plen = IN_CLASSC_NSHIFT;
+		px->plen = 32 - IN_CLASSC_NSHIFT;
 	px->maskset = true;
 }
 #endif
diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8
index fa463ad8af5d..259be41bf94b 100644
--- a/sbin/ifconfig/ifconfig.8
+++ b/sbin/ifconfig/ifconfig.8
@@ -1,3 +1,6 @@
+.\"-
+.\" SPDX-License-Identifier: BSD-3-Clause
+.\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
 .\"
@@ -25,9 +28,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\"     From: @(#)ifconfig.8	8.3 (Berkeley) 1/5/94
-.\"
-.Dd May 12, 2024
+.Dd June 6, 2024
 .Dt IFCONFIG 8
 .Os
 .Sh NAME
@@ -216,11 +217,10 @@ Shortcut notation for
 Exclude members of the specified
 .Ar groupname
 from the output.
-.Ar groupname .
 .Pp
-Only one option
+Only one
 .Fl G
-should be specified as later override previous ones
+option should be specified as later ones override earlier ones.
 .Ar groupname
 may contain shell patterns in which case it should be quoted.
 .Pp
@@ -246,9 +246,9 @@ lists names of interfaces belonging to
 .Ar groupname .
 Any other flags and arguments are ignored in this case.
 .Pp
-Only one option
+Only one
 .Fl g
-should be specified as later override previous ones
+option should be specified as later ones override earlier ones.
 .Ar groupname
 may contain shell patterns in which case it should be quoted.
 .Pp
diff --git a/sbin/mdconfig/tests/mdconfig_test.sh b/sbin/mdconfig/tests/mdconfig_test.sh
index 9aaf724206b1..655b7fd63b40 100755
--- a/sbin/mdconfig/tests/mdconfig_test.sh
+++ b/sbin/mdconfig/tests/mdconfig_test.sh
@@ -291,7 +291,7 @@ attach_size_rounddown_body()
 	    -x "mdconfig -r -u ${md#md} -s ${ms2}b"
 	check_diskinfo "$md" 16384 2 $ss
 }
-attach_size_rounddown()
+attach_size_rounddown_cleanup()
 {
 	cleanup_common
 }
diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c
index d5541571a135..621d97d6c555 100644
--- a/sbin/pfctl/pfctl.c
+++ b/sbin/pfctl/pfctl.c
@@ -98,7 +98,7 @@ void	 pfctl_print_eth_rule_counters(struct pfctl_eth_rule *, int);
 void	 pfctl_print_rule_counters(struct pfctl_rule *, int);
 int	 pfctl_show_eth_rules(int, char *, int, enum pfctl_show, char *, int, int);
 int	 pfctl_show_rules(int, char *, int, enum pfctl_show, char *, int, int);
-int	 pfctl_show_nat(int, char *, int, char *, int);
+int	 pfctl_show_nat(int, char *, int, char *, int, int);
 int	 pfctl_show_src_nodes(int, int);
 int	 pfctl_show_states(int, const char *, int);
 int	 pfctl_show_status(int, int);
@@ -1398,7 +1398,8 @@ pfctl_show_rules(int dev, char *path, int opts, enum pfctl_show format,
 }
 
 int
-pfctl_show_nat(int dev, char *path, int opts, char *anchorname, int depth)
+pfctl_show_nat(int dev, char *path, int opts, char *anchorname, int depth,
+    int wildcard)
 {
 	struct pfctl_rules_info ri;
 	struct pfctl_rule rule;
@@ -1406,14 +1407,65 @@ pfctl_show_nat(int dev, char *path, int opts, char *anchorname, int depth)
 	u_int32_t nr;
 	static int nattype[3] = { PF_NAT, PF_RDR, PF_BINAT };
 	int i, dotitle = opts & PF_OPT_SHOWALL;
-	int brace, ret;
+	int ret;
 	int len = strlen(path);
-	char *p;
+	char *npath, *p;
 
-	if (path[0])
-		snprintf(&path[len], MAXPATHLEN - len, "/%s", anchorname);
-	else
-		snprintf(&path[len], MAXPATHLEN - len, "%s", anchorname);
+	/*
+	 * Truncate a trailing / and * on an anchorname before searching for
+	 * the ruleset, this is syntactic sugar that doesn't actually make it
+	 * to the kernel.
+	 */
+	if ((p = strrchr(anchorname, '/')) != NULL &&
+	    p[1] == '*' && p[2] == '\0') {
+		p[0] = '\0';
+	}
+
+	if (anchorname[0] == '/') {
+		if ((npath = calloc(1, MAXPATHLEN)) == NULL)
+			errx(1, "pfctl_rules: calloc");
+		snprintf(npath, MAXPATHLEN, "%s", anchorname);
+	} else {
+		if (path[0])
+			snprintf(&path[len], MAXPATHLEN - len, "/%s", anchorname);
+		else
+			snprintf(&path[len], MAXPATHLEN - len, "%s", anchorname);
+		npath = path;
+	}
+
+	/*
+	 * If this anchor was called with a wildcard path, go through
+	 * the rulesets in the anchor rather than the rules.
+	 */
+	if (wildcard && (opts & PF_OPT_RECURSE)) {
+		struct pfioc_ruleset     prs;
+		u_int32_t                mnr, nr;
+		memset(&prs, 0, sizeof(prs));
+		memcpy(prs.path, npath, sizeof(prs.path));
+		if (ioctl(dev, DIOCGETRULESETS, &prs)) {
+			if (errno == EINVAL)
+				fprintf(stderr, "NAT anchor '%s' "
+				    "not found.\n", anchorname);
+			else
+				err(1, "DIOCGETRULESETS");
+		}
+		mnr = prs.nr;
+
+		pfctl_print_rule_counters(&rule, opts);
+		for (nr = 0; nr < mnr; ++nr) {
+			prs.nr = nr;
+			if (ioctl(dev, DIOCGETRULESET, &prs))
+				err(1, "DIOCGETRULESET");
+			INDENT(depth, !(opts & PF_OPT_VERBOSE));
+			printf("nat-anchor \"%s\" all {\n", prs.name);
+			pfctl_show_nat(dev, npath, opts,
+			    prs.name, depth + 1, 0);
+			INDENT(depth, !(opts & PF_OPT_VERBOSE));
+			printf("}\n");
+		}
+		path[len] = '\0';
+		return (0);
+	}
 
 	for (i = 0; i < 3; i++) {
 		ret = pfctl_get_rules_info(dev, &ri, nattype[i], path);
@@ -1422,7 +1474,6 @@ pfctl_show_nat(int dev, char *path, int opts, char *anchorname, int depth)
 			return (-1);
 		}
 		for (nr = 0; nr < ri.nr; ++nr) {
-			brace = 0;
 			INDENT(depth, !(opts & PF_OPT_VERBOSE));
 
 			if (pfctl_get_rule(dev, nr, ri.ticket, path,
@@ -1434,35 +1485,25 @@ pfctl_show_nat(int dev, char *path, int opts, char *anchorname, int depth)
 			    ri.ticket, nattype[i], path) != 0)
 				return (-1);
 
-			if (anchor_call[0] &&
-			   ((((p = strrchr(anchor_call, '_')) != NULL) &&
-			   (p == anchor_call ||
-			   *(--p) == '/')) || (opts & PF_OPT_RECURSE))) {
-				brace++;
-				if ((p = strrchr(anchor_call, '/')) !=
-				    NULL)
-					p++;
-				else
-					p = &anchor_call[0];
-			} else
-				p = &anchor_call[0];
-
 			if (dotitle) {
 				pfctl_print_title("TRANSLATION RULES:");
 				dotitle = 0;
 			}
 			print_rule(&rule, anchor_call,
 			    opts & PF_OPT_VERBOSE2, opts & PF_OPT_NUMERIC);
-			if (brace)
+			if (anchor_call[0] &&
+			    (((p = strrchr(anchor_call, '/')) ?
+			      p[1] == '_' : anchor_call[0] == '_') ||
+			     opts & PF_OPT_RECURSE)) {
 				printf(" {\n");
-			else
-				printf("\n");
-			pfctl_print_rule_counters(&rule, opts);
-			pfctl_clear_pool(&rule.rpool);
-			if (brace) {
-				pfctl_show_nat(dev, path, opts, p, depth + 1);
+				pfctl_print_rule_counters(&rule, opts);
+				pfctl_show_nat(dev, npath, opts, anchor_call,
+				    depth + 1, rule.anchor_wildcard);
 				INDENT(depth, !(opts & PF_OPT_VERBOSE));
 				printf("}\n");
+			} else {
+				printf("\n");
+				pfctl_print_rule_counters(&rule, opts);
 			}
 		}
 	}
@@ -3058,7 +3099,7 @@ main(int argc, char *argv[])
 			break;
 		case 'n':
 			pfctl_load_fingerprints(dev, opts);
-			pfctl_show_nat(dev, path, opts, anchorname, 0);
+			pfctl_show_nat(dev, path, opts, anchorname, 0, 0);
 			break;
 		case 'q':
 			pfctl_show_altq(dev, ifaceopt, opts,
@@ -3093,7 +3134,7 @@ main(int argc, char *argv[])
 			pfctl_show_eth_rules(dev, path, opts, 0, anchorname, 0,
 			    0);
 
-			pfctl_show_nat(dev, path, opts, anchorname, 0);
+			pfctl_show_nat(dev, path, opts, anchorname, 0, 0);
 			pfctl_show_rules(dev, path, opts, 0, anchorname, 0, 0);
 			pfctl_show_altq(dev, ifaceopt, opts, 0);
 			pfctl_show_states(dev, ifaceopt, opts);
diff --git a/secure/lib/libcrypto/Makefile.inc b/secure/lib/libcrypto/Makefile.inc
index de24bfb1038a..d95f08e27256 100644
--- a/secure/lib/libcrypto/Makefile.inc
+++ b/secure/lib/libcrypto/Makefile.inc
@@ -2,8 +2,8 @@
 .include <bsd.own.mk>
 
 # OpenSSL version used for manual page generation
-OPENSSL_VER=	3.0.13
-OPENSSL_DATE=	2024-02-02
+OPENSSL_VER=	3.0.14
+OPENSSL_DATE=	2024-06-04
 
 LCRYPTO_SRC=	${SRCTOP}/crypto/openssl
 LCRYPTO_DOC=	${LCRYPTO_SRC}/doc
diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile
index 10ae7f3cef19..aa55108d8b4e 100644
--- a/share/man/man4/Makefile
+++ b/share/man/man4/Makefile
@@ -289,6 +289,7 @@ MAN=	aac.4 \
 	mac_biba.4 \
 	mac_bsdextended.4 \
 	mac_ddb.4 \
+	mac_do.4 \
 	mac_ifoff.4 \
 	mac_ipacl.4 \
 	mac_lomac.4 \
diff --git a/share/man/man4/enc.4 b/share/man/man4/enc.4
index 87ff46878266..86f14d2bf290 100644
--- a/share/man/man4/enc.4
+++ b/share/man/man4/enc.4
@@ -126,7 +126,7 @@ The special value 0x4 can be configured in the
 .Ar ipsec_bpf_mask
 and packets will be also captured after firewall processing.
 .Sh EXAMPLES
-To see the packets the processed via
+To see the packets processed via
 .Xr ipsec 4 ,
 adjust the
 .Xr sysctl 8
diff --git a/share/man/man4/iicsmb.4 b/share/man/man4/iicsmb.4
index b6f5e39ce5cc..ffa38000659f 100644
--- a/share/man/man4/iicsmb.4
+++ b/share/man/man4/iicsmb.4
@@ -1,5 +1,7 @@
-.\" Copyright (c) 1998, Nicolas Souchu
-.\" All rights reserved.
+.\"-
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
+.\" Copyright (c) 1998, Nicolas Souchu. All rights reserved.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
 .\" modification, are permitted provided that the following conditions
@@ -27,7 +29,7 @@
 .Os
 .Sh NAME
 .Nm iicsmb
-.Nd I2C to SMB bridge
+.Nd I2C to SMBus bridge
 .Sh SYNOPSIS
 .Cd "device iicsmb"
 .Pp
diff --git a/share/man/man4/mac_do.4 b/share/man/man4/mac_do.4
new file mode 100644
index 000000000000..ce9f8cf25a4a
--- /dev/null
+++ b/share/man/man4/mac_do.4
@@ -0,0 +1,78 @@
+.\"-
+.\" Copyright (c) 2024 Baptiste Daroussin <bapt@FreeBSD.org>
+.\"
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
+.Dd May 22, 2024
+.Dt MAC_DO 4
+.Os
+.Sh NAME
+.Nm mac_do
+.Nd "policy allowing user to execute program as another user"
+.Sh SYNOPSIS
+To compile the
+.Nm
+policy into your kernel, place the following lines
+in your kernel configruation file:
+.Bd -ragged -offset indent
+.Cd "options MAC"
+.Cd "options MAC_DO"
+.Ed
+.Sh DESCRIPTION
+The
+.Nm
+policy grants users the ability to run processs as other users
+according to predefined rules.
+.Pp
+The exact set of kernel privileges granted are:
+.Bl -inset -compact -offset indent
+.It Dv PRIV_CRED_SETGROUPS
+.It Dv PRIV_CRED_SETUID
+.El
+.Pp
+The following
+.Xr sysctl 8
+MIBs are available:
+.Bl -tag -width indent
+.It Va security.mac.do.enabled
+Enable the
+.Nm
+policy.
+(Default: 1).
+.It Va security.mac.do.rules
+The set of rules.
+.El
+.Pp
+The rules consist of a list of elements separated by
+.So , Sc .
+Each element is of the form
+.Sm off
+.Do
+.Op Cm uid | Cm gid
+.Li =
+.Ar fid
+.Li :
+.Ar tid
+.Dc
+.Sm on .
+Where
+.Ar fid
+is the uid or gid of the user or group the rule applies to, and
+.Ar tid
+is the uid of the targetted user.
+Two special forms are accepted for
+.Ar tid :
+.Va any
+or
+.Va * ,
+which allow to target any user.
+.Sh EXAMPLES
+The following rule:
+.Pp
+.Dl security.mac.do.rules=uid=1001:80,gid=0:any
+.Pp
+means the user with the uid 1001 can execute processes as user with uid 80,
+all the users which belongs to the group gid 0 can execute processes as any user.
+.Sh SEE ALSO
+.Xr mac 4 ,
+.Xr mdo 1
diff --git a/share/man/man4/smb.4 b/share/man/man4/smb.4
index d2a1c3b9a618..bec89d8cb05f 100644
--- a/share/man/man4/smb.4
+++ b/share/man/man4/smb.4
@@ -29,7 +29,7 @@
 .Os
 .Sh NAME
 .Nm smb
-.Nd SMB generic I/O device driver
+.Nd System Management Bus (SMBus) generic I/O device driver
 .Sh SYNOPSIS
 .Cd "device smb"
 .Sh DESCRIPTION
diff --git a/share/man/man4/sndstat.4 b/share/man/man4/sndstat.4
index ba130dacaecb..f638fc6834fe 100644
--- a/share/man/man4/sndstat.4
+++ b/share/man/man4/sndstat.4
@@ -29,7 +29,7 @@
 .\"
 .\" Note: The date here should be updated whenever a non-trivial
 .\" change is made to the manual page.
-.Dd April 15, 2021
+.Dd June 5, 2024
 .Dt SNDSTAT 4
 .Os
 .Sh NAME
@@ -60,25 +60,55 @@ struct sndstioc_nv_arg {
 Here is an example of an nvlist object with explanations of the common fields:
 .Bd -literal -offset indent
 dsps (NVLIST ARRAY): 1
-    from_user (BOOL): FALSE
-    nameunit (STRING): [pcm0]
-    devnode (STRING): [dsp0]
-    desc (STRING): [Generic (0x8086) (Analog Line-out)]
-    pchan (NUMBER): 1 (1) (0x1)
-    rchan (NUMBER): 0 (0) (0x0)
-    info_play (NVLIST):
-        min_rate (NUMBER): 48000 (48000) (0xbb80)
-        max_rate (NUMBER): 48000 (48000) (0xbb80)
-        formats (NUMBER): 16 (16) (0x10)
-        min_chn (NUMBER): 2 (2) (0x2)
-        max_chn (NUMBER): 2 (2) (0x2)
-    provider_info (NVLIST):
-        unit (NUMBER): 0 (0) (0x0)
-        bitperfect (BOOL): FALSE
-        pvchan (NUMBER): 1 (1) (0x1)
-        rvchan (NUMBER): 0 (0) (0x0)
-    provider (STRING): [sound(4)]
-    ,
+	from_user (BOOL): FALSE
+	nameunit (STRING): [pcm0]
+	devnode (STRING): [dsp0]
+	desc (STRING): [Generic (0x8086) (Analog Line-out)]
+	pchan (NUMBER): 1
+	rchan (NUMBER): 0
+	info_play (NVLIST):
+		min_rate (NUMBER): 48000
+		max_rate (NUMBER): 48000
+		formats (NUMBER): 16
+		min_chn (NUMBER): 2
+		max_chn (NUMBER): 2
+	provider_info (NVLIST):
+		unit (NUMBER): 0
+		bitperfect (BOOL): FALSE
+		pvchan (NUMBER): 1
+		rvchan (NUMBER): 0
+		channel_info (NVLIST_ARRAY): 1
+			name (STRING): pcm0:virtual_play:dsp0.vp0
+			parentchan (STRING): pcm0:play:dsp0.p0
+			unit (NUMBER): 1
+			latency (NUMBER): 2
+			rate (NUMBER): 48000
+			format (NUMBER): 0x201000
+			pid (NUMBER): 1234
+			comm (STRING): mpv
+			interrupts (NUMBER): 0
+			feedcount (NUMBER): 0
+			xruns (NUMBER): 0
+			left_volume (NUMBER): 45
+			right_volume (NUMBER): 45
+			hwbuf_fmt (NUMBER): 0x200010
+			hwbuf_size (NUMBER): 0
+			hwbuf_blksz (NUMBER): 0
+			hwbuf_blkcnt (NUMBER): 0
+			hwbuf_free (NUMBER): 0
+			hwbuf_ready (NUMBER): 0
+			swbuf_fmt (NUMBER): 0x201000
+			swbuf_size (NUMBER): 16384
+			swbuf_blksz (NUMBER): 2048
+			swbuf_blkcnt (NUMBER): 8
+			swbuf_free (NUMBER): 16384
+			swbuf_ready (NUMBER): 0
+			feederchain (STRING):
+				[userland ->
+				feeder_root(0x00201000) ->
+				feeder_format(0x00201000 -> 0x00200010) ->
+				feeder_volume(0x00200010) -> hardware]
+	provider (STRING): [sound(4)]
 .Ed
 .Bl -tag -width ".Dv provider_info"
 .It Dv from_user
@@ -133,6 +163,76 @@ Provider-specific fields.
 This field may not exist if the PCM audio device is not provided by in-kernel
 interface.
 This field will not exist if the provider field is an empty string.
+For the
+.Xr sound 4
+provider, there are a number of name/value pairs inside this field:
+.Bl -tag -width ".Dv channel_info"
+.It Dv unit
+Sound card unit.
+.It Dv bitperfect
+Whether the sound card has bit-perfect mode enabled.
+.It Dv pvchan
+Number of playback virtual channels.
+.It Dv rvchan
+Number of recording virtual channels.
+.It Dv channel_info
+Channel information.
+There are a number of name/value pairs inside this field:
+.Bl -tag -width ".Dv hwbuf_blkcnt"
+.It Dv name
+Channel name.
+.It Dv parenchan
+Parent channel name (e.g., in the case of virtual channels).
+.It Dv unit
+Channel unit.
+.It Dv latency
+Latency.
+.It Dv rate
+Sampling rate.
+.It Dv format
+Sampling format.
+.It Dv pid
+PID of the process consuming the channel.
+.It Dv comm
+Name of the process consuming the channel.
+.It Dv interrupts
+Number of interrupts since the channel has been opened.
+.It Dv xruns
+Number of overruns/underruns, depending on channel direction.
+.It Dv feedcount
+Number of read/written bytes since the channel has been opened.
+.It Dv left_volume
+Left volume.
+.It Dv right_volume
+Right volume.
+.It Dv hwbuf_format
+Hardware buffer format.
+.It Dv hwbuf_size
+Hardware buffer size.
+.It Dv hwbuf_blksz
+Hardware buffer block size.
+.It Dv hwbuf_blkcnt
+Hardware buffer block count.
+.It Dv hwbuf_free
+Free space in hardware buffer (in bytes).
+.It Dv hwbuf_ready
+Number of bytes ready to be read/written from hardware buffer.
+.It Dv swbuf_format
+Software buffer format.
+.It Dv swbuf_size
+Software buffer size.
+.It Dv swbuf_blksz
+Software buffer block size.
+.It Dv swbuf_blkcnt
+Software buffer block count.
+.It Dv swbuf_free
+Free space in software buffer (in bytes).
+.It Dv swbuf_ready
+Number of bytes ready to be read/written from software buffer.
+.It Dv feederchain
+Channel feeder chain.
+.El
+.El
 .It Dv provider
 A string specifying the provider of the PCm audio device.
 .El
diff --git a/share/man/man4/vt.4 b/share/man/man4/vt.4
index 2876d1ca8d84..81eafb6fae6a 100644
--- a/share/man/man4/vt.4
+++ b/share/man/man4/vt.4
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd May 8, 2023
+.Dd May 24, 2024
 .Dt "VT" 4
 .Os
 .Sh NAME
@@ -219,6 +219,11 @@ The
 kernel uses
 .Nm
 when this value is not set.
+Note that
+.Ql sc
+is not compatible with
+.Xr UEFI 8
+boot.
 .It Va kern.vt.color. Ns Ar colornum Ns Va .rgb
 Set this value to override default palette entry for color
 .Pa colornum
diff --git a/share/man/man5/nsmb.conf.5 b/share/man/man5/nsmb.conf.5
index 1a09743874e5..0da10343ed77 100644
--- a/share/man/man5/nsmb.conf.5
+++ b/share/man/man5/nsmb.conf.5
@@ -1,3 +1,6 @@
+.\"-
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
 .\" Copyright (c) 2003
 .\" Originally written by Sergey A. Osokin
 .\" Rewritten by Tom Rhodes
@@ -28,9 +31,7 @@
 .Os
 .Sh NAME
 .Nm nsmb.conf
-.Nd configuration file for
-.Tn SMB
-requests
+.Nd configuration file for server message block (SMB1/CIFS) requests
 .Sh DESCRIPTION
 The
 .Nm
diff --git a/share/man/man5/procfs.5 b/share/man/man5/procfs.5
index d055faadf2c0..253fe5670969 100644
--- a/share/man/man5/procfs.5
+++ b/share/man/man5/procfs.5
@@ -1,7 +1,7 @@
 .\" Written by Garrett Wollman
 .\" This file is in the public domain.
 .\"
-.Dd April 10, 2023
+.Dd June 23, 2024
 .Dt PROCFS 5
 .Os
 .Sh NAME
@@ -229,11 +229,11 @@ comma separated.
 .It
 the wait channel message
 .It
-the process credentials consisting of
-the effective user id
-and the list of groups (whose first member
-is the effective group id)
-all comma separated.
+the process effective UID
+.It
+the process real UID
+.It
+group list, starting with the effective GID, comma-separated
 .It
 the hostname of the jail in which the process runs, or
 .Ql -
diff --git a/share/man/man5/rc.conf.5 b/share/man/man5/rc.conf.5
index a76cb1a04e0a..5a8e4e2c1c5b 100644
--- a/share/man/man5/rc.conf.5
+++ b/share/man/man5/rc.conf.5
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd September 18, 2023
+.Dd May 18, 2024
 .Dt RC.CONF 5
 .Os
 .Sh NAME
@@ -334,10 +334,6 @@ A whitespace-separated list of kernel modules to load right after
 the local disks are mounted, without any
 .Pa .ko
 extension or path.
-Loading modules at this point in the boot process is
-much faster than doing it via
-.Pa /boot/loader.conf
-for those modules not necessary for mounting local disks.
 .It Va kldxref_enable
 .Pq Vt bool
 Set to
diff --git a/share/man/man7/build.7 b/share/man/man7/build.7
index 6846b38c99a6..79c05f5ab63a 100644
--- a/share/man/man7/build.7
+++ b/share/man/man7/build.7
@@ -1,3 +1,6 @@
+.\"-
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
 .\" Copyright (c) 2000
 .\"	Mike W. Meyer
 .\"
@@ -22,12 +25,14 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd August 1, 2023
+.Dd June 4, 2024
 .Dt BUILD 7
 .Os
 .Sh NAME
 .Nm build
-.Nd General instructions on how to build the system
+.Nd general instructions on how to build the
+.Fx
+system
 .Sh DESCRIPTION
 The sources for the
 .Fx
@@ -884,18 +889,14 @@ method of updating your system from the latest sources, please see the
 section in
 .Pa src/UPDATING .
 .Pp
-The following sequence of commands can be used to cross-build the
-system for the armv6 architecture on an amd64 host:
+The following sequence of commands can be used to cross-build the system for
+the arm64 (aarch64) architecture on a different host architecture, such as
+amd64:
 .Bd -literal -offset indent
 cd /usr/src
-make TARGET_ARCH=armv6 buildworld buildkernel
-make TARGET_ARCH=armv6 DESTDIR=/clients/arm installworld installkernel
+make TARGET=arm64 buildworld buildkernel
+make TARGET=arm64 DESTDIR=/clients/arm64 installworld installkernel
 .Ed
-.Sh HISTORY
-The
-.Nm
-manpage first appeared in
-.Fx 4.3 .
 .Sh SEE ALSO
 .Xr cc 1 ,
 .Xr install 1 ,
@@ -903,6 +904,7 @@ manpage first appeared in
 .Xr make.conf 5 ,
 .Xr src.conf 5 ,
 .Xr arch 7 ,
+.Xr development 7 ,
 .Xr pkg 7 ,
 .Xr ports 7 ,
 .Xr release 7 ,
@@ -911,5 +913,10 @@ manpage first appeared in
 .Xr etcupdate 8 ,
 .Xr reboot 8 ,
 .Xr shutdown 8
+.Sh HISTORY
+The
+.Nm
+manpage first appeared in
+.Fx 4.3 .
 .Sh AUTHORS
 .An Mike W. Meyer Aq Mt mwm@mired.org
diff --git a/share/man/man7/simd.7 b/share/man/man7/simd.7
index fd9485524aef..877bc77adf4b 100644
--- a/share/man/man7/simd.7
+++ b/share/man/man7/simd.7
@@ -24,7 +24,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE
 .
-.Dd December 6, 2023
+.Dd June 7, 2024
 .Dt SIMD 7
 .Os
 .Sh NAME
@@ -55,33 +55,33 @@ Enhanced functions are present for the following architectures:
 .It    bcopy             Ta            Ta    S   Ta    S      Ta    S    Ta    SV
 .It    bzero             Ta            Ta    S   Ta    S      Ta    S
 .It    div               Ta            Ta        Ta    S      Ta    S
-.It    index             Ta    S       Ta        Ta    S1
+.It    index             Ta    A       Ta        Ta    S1
 .It    ldiv              Ta            Ta        Ta    S      Ta    S
 .It    lldiv             Ta            Ta        Ta    S
-.It    memchr            Ta    S       Ta        Ta    S1
-.It    memcmp            Ta    S       Ta    S   Ta    S1     Ta    S
+.It    memchr            Ta    A       Ta        Ta    S1
+.It    memcmp            Ta    A       Ta    S   Ta    S1     Ta    S
 .It    memccpy           Ta            Ta        Ta    S1
 .It    memcpy            Ta    S       Ta    S   Ta    S      Ta    S    Ta    SV
 .It    memmove           Ta    S       Ta    S   Ta    S      Ta    S    Ta    SV
-.It    memrchr           Ta            Ta        Ta    S1
-.It    memset            Ta    S       Ta    S   Ta    S      Ta    S
-.It    rindex            Ta    S       Ta        Ta    S1     Ta    S
-.It    stpcpy            Ta    S       Ta        Ta    S1
+.It    memrchr           Ta    A       Ta        Ta    S1
+.It    memset            Ta    A       Ta    S   Ta    S      Ta    S
+.It    rindex            Ta    A       Ta        Ta    S1     Ta    S
+.It    stpcpy            Ta    A       Ta        Ta    S1
 .It    stpncpy           Ta            Ta        Ta    S1
 .It    strcat            Ta            Ta        Ta    S1     Ta    S
-.It    strchr            Ta    S       Ta        Ta    S1     Ta    S
-.It    strchrnul         Ta    S       Ta        Ta    S1
+.It    strchr            Ta    A       Ta        Ta    S1     Ta    S
+.It    strchrnul         Ta    A       Ta        Ta    S1
 .It    strcmp            Ta    S       Ta    S   Ta    S1     Ta    S
-.It    strcpy            Ta    S       Ta        Ta    S1     Ta    S    Ta    S2
+.It    strcpy            Ta    A       Ta        Ta    S1     Ta    S    Ta    S2
 .It    strcspn           Ta            Ta        Ta    S2
 .It    strlcat           Ta            Ta        Ta    S1
 .It    strlcpy           Ta            Ta        Ta    S1
-.It    strlen            Ta    S       Ta    S   Ta    S1
+.It    strlen            Ta    A       Ta    S   Ta    S1
 .It    strncat           Ta            Ta        Ta    S1
 .It    strncmp           Ta    S       Ta    S   Ta    S1     Ta    S
 .It    strncpy           Ta            Ta        Ta    S1     Ta         Ta    S2
-.It    strnlen           Ta    S       Ta        Ta    S1
-.It    strrchr           Ta    S       Ta        Ta    S1     Ta    S
+.It    strnlen           Ta    A       Ta        Ta    S1
+.It    strrchr           Ta    A       Ta        Ta    S1     Ta    S
 .It    strpbrk           Ta            Ta        Ta    S2
 .It    strsep            Ta            Ta        Ta    S2
 .It    strspn            Ta            Ta        Ta    S2
@@ -100,7 +100,8 @@ Enhanced functions are present for the following architectures:
 or PowerPC\ 2.05,
 .Sy 3 Ns :\ x86-64-v3,
 .Sy 4 Ns :\ x86-64-v4,
-.Sy V Ns :\ PowerPC\ VSX.
+.Sy V Ns :\ PowerPC\ VSX,
+.Sy A Ns :\ Arm\ ASIMD (NEON).
 .
 .Sh ENVIRONMENT
 .Bl -tag
diff --git a/share/man/man8/rc.subr.8 b/share/man/man8/rc.subr.8
index 3e3ff8c8d1e1..a32347a09eb2 100644
--- a/share/man/man8/rc.subr.8
+++ b/share/man/man8/rc.subr.8
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd August 16, 2022
+.Dd June 18, 2024
 .Dt RC.SUBR 8
 .Os
 .Sh NAME
@@ -631,6 +631,8 @@ Login class to use with
 .Va ${name}_limits .
 Defaults to
 .Dq Li daemon .
+.It Va ${name}_offcmd
+Shell commands to run during start if a service is not enabled.
 .It Va ${name}_oomprotect
 .Xr protect 1
 .Va command
diff --git a/share/man/man9/vfs_getopt.9 b/share/man/man9/vfs_getopt.9
index 0e68655f540f..ff0f027314c7 100644
--- a/share/man/man9/vfs_getopt.9
+++ b/share/man/man9/vfs_getopt.9
@@ -24,7 +24,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
 .\" DAMAGE.
 .\"
-.Dd July 31, 2011
+.Dd May 19, 2024
 .Dt VFS_GETOPT 9
 .Os
 .Sh NAME
@@ -46,7 +46,7 @@
 .Fa "struct vfsoptlist *opts" "const char *name" "void **buf" "int *len"
 .Fc
 .Ft "char *"
-.Fn vfs_getops "struct vfsoptlist *opts" "const char *name" "int *error"
+.Fn vfs_getopts "struct vfsoptlist *opts" "const char *name" "int *error"
 .Ft int
 .Fo vfs_flagopt
 .Fa "struct vfsoptlist *opts" "const char *name" "uint64_t *flags" "uint64_t flag"
@@ -177,7 +177,7 @@ function returns 0 if the option was found; otherwise,
 is returned.
 .Pp
 The
-.Fn vfs_getops
+.Fn vfs_getopts
 function returns the specified option if it is found, and is
 .Dv NUL
 terminated.
diff --git a/share/mk/bsd.progs.mk b/share/mk/bsd.progs.mk
index 946c44f76570..2c8baa02b9e6 100644
--- a/share/mk/bsd.progs.mk
+++ b/share/mk/bsd.progs.mk
@@ -154,6 +154,7 @@ $p.$t: .PHONY .MAKE ${_PROGS_COMMON_OBJS}
 	    NO_SUBDIR=1 ${MAKE} -f ${MAKEFILE} _RECURSING_PROGS=t \
 	    ${_PROG_MK.${t}} PROG=$p ${x.$p} ${@:E})
 .endfor
+.ORDER: installdirs $p.install
 .endfor
 
 # Depend main pseudo targets on all PROG.pseudo targets too.
diff --git a/stand/efi/loader/Makefile b/stand/efi/loader/Makefile
index b3395bdfdf53..809ed7c02e4d 100644
--- a/stand/efi/loader/Makefile
+++ b/stand/efi/loader/Makefile
@@ -2,6 +2,7 @@
 LOADER_NET_SUPPORT?=	yes
 LOADER_MSDOS_SUPPORT?=	yes
 LOADER_UFS_SUPPORT?=	yes
+LOADER_USBDBC_SUPPORT?=	yes
 LOADER_CD9660_SUPPORT?=	no
 LOADER_EXT2FS_SUPPORT?=	no
 
@@ -23,7 +24,16 @@ SRCS=	autoload.c \
 	self_reloc.c \
 	vers.c \
 	gfx_fb.c \
-	8x16.c
+	8x16.c 
+
+.if ${LOADER_USBDBC_SUPPORT} != "no"
+.PATH:		${SRCTOP}/sys/dev/usb/controller
+SRCS+=		xhci_dbc.c \
+		xhci_dbc_command.c \
+		xhci_dbc_cons.c \
+		xhci_dbc_dma.c \
+		pci.c
+.endif
 
 CFLAGS+=	-I${.CURDIR}/../loader
 .if ${MK_LOADER_ZFS} != "no"
diff --git a/stand/efi/loader/conf.c b/stand/efi/loader/conf.c
index 3bc74ea6354c..25d02f499763 100644
--- a/stand/efi/loader/conf.c
+++ b/stand/efi/loader/conf.c
@@ -78,6 +78,7 @@ struct netif_driver *netif_drivers[] = {
 
 extern struct console efi_console;
 extern struct console eficom;
+extern struct console udb_console;
 #if defined(__aarch64__) && __FreeBSD_version < 1500000
 /* Hack for backward compatibility -- but only for a while */
 extern struct console comconsole;
@@ -91,6 +92,7 @@ extern struct console spinconsole;
 struct console *consoles[] = {
 	&efi_console,
 	&eficom,
+	&udb_console,
 #if defined(__aarch64__) && __FreeBSD_version < 1500000
 	&comconsole,
 #endif
diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c
index e4d62f2e940c..8241d4d1a89a 100644
--- a/stand/efi/loader/main.c
+++ b/stand/efi/loader/main.c
@@ -59,6 +59,12 @@
 #include "efizfs.h"
 #include "framebuffer.h"
 
+#include "xhci_dbc_cons.h"
+#include <dev/usb/controller/xhci_private.h>
+#include <dev/usb/controller/xhci_dbc.h>
+#include "xhci_dbc_dma.h"
+#include "xhci_dbc_command.h"
+
 #include "platform/acfreebsd.h"
 #include "acconfig.h"
 #define ACPI_SYSTEM_XFACE
@@ -1750,3 +1756,74 @@ command_netserver(int argc, char *argv[])
 
 COMMAND_SET(netserver, "netserver", "change or display netserver URI",
     command_netserver);
+
+static int
+command_udb_info(int argc, char *argv[])
+{
+
+	udb_info();
+
+	return (CMD_OK);
+}
+COMMAND_SET(udb_info, "udb_info", "USB DbC configuration info",
+    command_udb_info);
+
+static int
+command_udb_send(int argc, char *argv[])
+{
+	size_t len;
+	size_t i;
+
+	if (argc != 2) {
+		printf("argument required\n");
+		return (CMD_ERROR);
+	}
+	printf("Sending '%s\\r\\n'...\n", argv[1]);
+	len = strlen(argv[1]);
+	for (i = 0; i < len; i++)
+		udb_console.c_out((u_int)argv[1][i]);
+	udb_console.c_out('\r'); 
+	udb_console.c_out('\n'); 
+	return (CMD_OK);
+}
+COMMAND_SET(udb_send, "udb_send", "USB DbC send string test",
+    command_udb_send);
+
+static int
+command_udb_recv(int argc, char *argv[])
+{
+	int buf[1024];
+	int i, j;
+	int c;
+
+	printf("Receiving...\n");
+	i = 0;
+	while (udb_console.c_ready() && i < sizeof(buf)) {
+		c = udb_console.c_in();
+		if (c != -1)
+			buf[i++] = c;
+	}
+	if (i != 0) {
+		printf("[");
+		for (j = 0; j < i; j++)
+			printf("%c(%02x) ", (char)buf[j], (char)buf[j]);
+		printf("]\n");
+	}
+
+	return (CMD_OK);
+}
+COMMAND_SET(udb_recv, "udb_recv", "USB DbC recv test",
+    command_udb_recv);
+
+static int
+command_udb_probe(int argc, char *argv[])
+{
+	udb_console.c_probe(&udb_console);
+	if ((udb_console.c_flags & (C_PRESENTIN | C_PRESENTOUT)) !=
+	    (C_PRESENTIN | C_PRESENTOUT))
+		return (CMD_ERROR);
+
+	return (udb_console.c_init(0));
+}
+COMMAND_SET(udb_probe, "udb_probe", "USB DbC probe",
+    command_udb_probe);
diff --git a/stand/efi/loader/pci.c b/stand/efi/loader/pci.c
new file mode 100644
index 000000000000..d7ac11f94fe1
--- /dev/null
+++ b/stand/efi/loader/pci.c
@@ -0,0 +1,77 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2019-2024 Hiroki Sato <hrs@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+#include <sys/param.h>
+#include <dev/pci/pcireg.h>
+
+#include "pci.h"
+
+static inline volatile uint32_t ind(volatile uint32_t);
+static inline void outd(volatile uint32_t, volatile uint32_t);
+
+static inline volatile uint32_t
+ind(volatile uint32_t port)
+{
+	uint32_t val;
+
+	__asm volatile(
+	    "xorq %%rax, %%rax\n\t"
+	    "movq %1, %%rdx\n\t"
+	    "inl %%dx, %%eax\n\t"
+	    : "=a"(val)
+	    : "g"((uint64_t)port));
+	return (val);
+}
+
+static inline void
+outd(volatile uint32_t port, volatile uint32_t val)
+{
+
+	__asm volatile(
+	    "movq %0, %%rdx\n\t"
+	    "movq %1, %%rax\n\t"
+	    "outl %%eax, %%dx\n\t"
+	    :
+	    : "g"((uint64_t)port), "g"((uint64_t)val));
+}
+
+volatile uint32_t
+pci_read_config(volatile uint32_t sc_ca, volatile uint32_t reg)
+{
+
+	outd(PCIR_IO_COMMAND_ADDRESS, sc_ca | (reg << 2));
+	return (ind(PCIR_IO_COMMAND_DATA));
+}
+
+void
+pci_write_config(volatile uint32_t sc_ca, volatile uint32_t reg,
+    volatile uint32_t val)
+{
+
+	outd(PCIR_IO_COMMAND_ADDRESS, sc_ca | (reg << 2));
+	outd(PCIR_IO_COMMAND_DATA, val);
+}
diff --git a/stand/efi/loader/pci.h b/stand/efi/loader/pci.h
new file mode 100644
index 000000000000..a834ef4801c4
--- /dev/null
+++ b/stand/efi/loader/pci.h
@@ -0,0 +1,50 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2019-2024 Hiroki Sato <hrs@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+#include <sys/param.h>
+
+#define	PCIR_IO_COMMAND_ADDRESS	0x0cf8
+#define	PCIR_IO_CA_ENABLE	(1UL << 31)
+#define	PCIR_IO_CA_BUS_GET(x)	(((x) >> 16) & 0xff)
+#define	PCIR_IO_CA_BUS_SET(x)	(((x) & 0xff) << 16)
+#define	PCIR_IO_CA_DEV_GET(x)	(((x) >> 11) & 0x1f)
+#define	PCIR_IO_CA_DEV_SET(x)	(((x) & 0x1f) << 11)
+#define	PCIR_IO_CA_FUN_GET(x)	(((x) >> 8)  & 0x07)
+#define	PCIR_IO_CA_FUN_SET(x)	(((x) & 0x07) << 8)
+#define	PCIR_IO_COMMAND_DATA	0x0cfc
+#define	PCIR_CA_CLASS	0x02	/* 0x04h in octect */
+#define	PCIR_CA_HEADER	0x03	/* 0x08h in octect */
+#define	PCIR_CA_BAR_LO	0x04	/* 0x10h in octect */
+#define	PCIR_CA_BAR_HI	0x05	/* 0x14h in octect */
+
+struct pciid {
+	uint16_t vendor;
+	uint16_t device;
+};
+
+volatile uint32_t pci_read_config(volatile uint32_t, volatile uint32_t);
+void pci_write_config(volatile uint32_t, volatile uint32_t, volatile uint32_t);
diff --git a/stand/efi/loader/xhci_dbc_command.c b/stand/efi/loader/xhci_dbc_command.c
new file mode 100644
index 000000000000..e99f20935f70
--- /dev/null
+++ b/stand/efi/loader/xhci_dbc_command.c
@@ -0,0 +1,51 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2019-2024 Hiroki Sato <hrs@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+#include <sys/param.h>
+
+#include <efi.h>
+#include <efilib.h>	/* printf */
+#include <dev/usb/controller/xhci_private.h>
+#include <dev/usb/controller/xhcireg.h>
+#include <dev/usb/controller/xhci_dbc.h>
+#include <dev/usb/controller/xhci_dbc_private.h>
+
+#include "xhci_dbc_cons.h"	/* udb_sc */
+#include "xhci_dbc_command.h"
+
+void
+udb_info(void)
+{
+	struct xhci_debug_softc *sc = udb_sc;
+	if (sc == NULL)
+		return;
+	printf("USB DbC INFO (softc = %p):\n", sc);
+	if (sc->sc_dbc_off == 0)
+		return;
+
+	udb_dump_info(sc);
+}
diff --git a/stand/efi/loader/xhci_dbc_command.h b/stand/efi/loader/xhci_dbc_command.h
new file mode 100644
index 000000000000..e0687cd7c98e
--- /dev/null
+++ b/stand/efi/loader/xhci_dbc_command.h
@@ -0,0 +1,28 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2019-2024 Hiroki Sato <hrs@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+void udb_info(void);
diff --git a/stand/efi/loader/xhci_dbc_cons.c b/stand/efi/loader/xhci_dbc_cons.c
new file mode 100644
index 000000000000..21c95f9079d6
--- /dev/null
+++ b/stand/efi/loader/xhci_dbc_cons.c
@@ -0,0 +1,244 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2019-2024 Hiroki Sato <hrs@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+#include <sys/param.h>
+#include <dev/pci/pcireg.h>
+#include <dev/usb/controller/xhcireg.h>
+
+#include <bootstrap.h>
+#include <efi.h>
+#include <efilib.h>
+
+#include "pci.h"
+#include "xhci_dbc_cons.h"
+#include "xhci_dbc_pci.h"
+#include "xhci_dbc_dma.h"	/* udb_init_dma() */
+#include <dev/usb/controller/xhci_private.h>
+#include <dev/usb/controller/xhci_dbc.h>
+#include <dev/usb/controller/xhci_dbc_private.h>
+
+static void udbc_probe(struct console *);
+static int udbc_getc(void);
+static void udbc_putc(int);
+static int udbc_ischar(void);
+static int udbc_init(int);
+struct console udb_console = {
+	.c_name = "udbc",
+	.c_desc = "USB DbC serial port",
+	.c_flags = 0,
+	.c_probe = udbc_probe,
+	.c_init = udbc_init,
+	.c_out = udbc_putc,
+	.c_in = udbc_getc,
+	.c_ready = udbc_ischar
+};
+
+struct xhci_debug_softc *udb_sc;
+
+static void
+udbc_probe(struct console *cons)
+{
+	struct xhci_debug_softc *sc;
+	EFI_STATUS status;
+	EFI_HANDLE *h0, *h;
+	EFI_PCI_IO_PROTOCOL *pciio;
+	UINTN hlen;
+	uint32_t devfn;
+	char buf[32];
+	int i, error;
+	int found;
+
+	h0 = h = NULL;
+	if (udb_sc != NULL)
+		return;
+
+	/* Get PCI I/O handle. */
+	hlen = 0;
+	status = BS->LocateHandle(ByProtocol, &pciio_guid, NULL, &hlen, NULL);
+	DEBUG_PRINTF("%s: LocateHandle1 = %lx\n", __func__, status);
+	if (status != EFI_BUFFER_TOO_SMALL)
+		goto error;
+	h0 = malloc(hlen);
+	status = BS->LocateHandle(ByProtocol, &pciio_guid, NULL, &hlen, h0);
+	DEBUG_PRINTF("%s: LocateHandle2 = %lu\n", __func__, status);
+	if (status != EFI_SUCCESS)
+		goto error;
+	hlen /= sizeof(EFI_HANDLE);
+
+	/* Look up vendor IDs. */
+	found = 0;
+	for (h = h0; h < h0 + hlen; h++) {
+		UINT32 dev_ven;
+
+		status = OpenProtocolByHandle(*h, &pciio_guid,
+		    (void **)&pciio);
+		if (status != EFI_SUCCESS)
+			continue;
+		status = pciio->Pci.Read(pciio, EfiPciIoWidthUint32,
+		    PCIR_DEVVENDOR, 1, &dev_ven);
+		if (status != EFI_SUCCESS) {
+			BS->CloseProtocol(h, &pciio_guid, IH, NULL);
+			continue;
+		}
+		DEBUG_PRINTF("%s: dev_ven = %08x\n", __func__, dev_ven);
+		for (i = 0; i < nitems(ids); i++) {
+			if (dev_ven ==
+			    ((ids[i].device << 16) | ids[i].vendor)) {
+				found = 1;
+				break;
+			}
+		}
+	}
+	if (found == 0)
+		goto error;
+
+	sc = udb_sc_malloc(sizeof(*sc), h, pciio);
+	if (sc == NULL)
+		return;
+	udb_sc = sc;
+	sc->sc_cons = cons;
+
+	h0 = NULL;
+	for (devfn = 0; devfn < 256; devfn++) {
+		uint32_t sc_ca;
+		uint32_t header_type;
+		uint32_t class;
+
+		sc_ca = 0;
+		sc_ca |= PCIR_IO_CA_ENABLE;
+		sc_ca |= PCIR_IO_CA_DEV_SET(devfn >> 3);
+		sc_ca |= PCIR_IO_CA_FUN_SET(devfn);
+
+		header_type =
+		    (pci_read_config(sc_ca, PCIR_CA_HEADER) >> 16) & 0xff;
+
+		if (header_type != PCIM_HDRTYPE_NORMAL &&
+		    header_type != PCIM_MFDEV)
+			continue;
+		class = pci_read_config(sc_ca, PCIR_CA_CLASS) >> 8;
+		if (class == XHC_CLASSC) {
+			sc->sc_ca = sc_ca;
+			break;
+		}
+	}
+	if (sc->sc_ca == 0) {
+		DEBUG_PRINTF("%s: Compatible xHC not found.\n", __func__);
+		goto error;
+	}
+	if (!xhci_debug_probe(sc))
+		goto error;
+
+	xhci_debug_disable(sc);
+	cons->c_flags = C_PRESENTIN | C_PRESENTOUT;
+
+	xhci_debug_update_state(sc);
+	if (sc->sc_init == false) {
+		error = xhci_debug_init_dma(sc);
+		if (error) {
+			DEBUG_PRINTF("USB DbC DMA configuration error\n");
+			goto error;
+		}
+		error = xhci_debug_init_ring(sc);
+		if (error) {
+			DEBUG_PRINTF("USB DbC TRB ring configuration error\n");
+			goto error;
+		}
+		sc->sc_init = true;
+	}
+	xhci_debug_enable(sc);
+	xhci_debug_update_state(sc);
+
+	return;
+error:
+	free(h0);
+	free(sc);
+	sc = NULL;
+	return;
+}
+
+static int
+udbc_init(int arg)
+{
+	struct xhci_debug_softc *sc = udb_sc;
+	int error;
+
+	if (sc == NULL) {		/* allocated in c_probe */
+		DEBUG_PRINTF("USB DbC not found\n");
+		return (CMD_ERROR);
+	}
+	if (sc->sc_dbc_off == 0) {	/* set in c_probe */
+		DEBUG_PRINTF("USB DbC register not found\n");
+		return (CMD_ERROR);
+	}
+	xhci_debug_enable(sc);
+	xhci_debug_event_dequeue(sc);
+
+	return (CMD_OK);
+}
+
+static void
+udbc_putc(int c0)
+{
+	struct xhci_debug_softc *sc = udb_sc;
+	u_char c = (0xff & c0);
+
+	if (sc == NULL)
+		return;
+	if (!work_enqueue(&sc->udb_oring, &c, sizeof(c)))
+		return;
+	xhci_debug_bulk_transfer(sc, &sc->udb_oring);
+}
+
+static int
+udbc_getc(void)
+{
+	struct xhci_debug_softc *sc = udb_sc;
+
+	if (sc == NULL)
+		return (-1);
+
+	/* Use udbc_ischar() to receive data */
+	return (udbc_ischar() ? work_dequeue(&sc->udb_iring) : -1);
+}
+
+static int
+udbc_ischar(void)
+{
+	struct xhci_debug_softc *sc = udb_sc;
+	struct xhci_debug_ring *iring;
+
+	if (sc == NULL)
+		return (0);
+	if (!UDB_WORK_RING_EMPTY(iring))
+		return (1);
+	
+	iring = &sc->udb_iring;
+	xhci_debug_bulk_transfer(sc, iring);
+	xhci_debug_event_dequeue(sc);
+
+	return (!UDB_WORK_RING_EMPTY(iring));
+}
diff --git a/stand/efi/loader/xhci_dbc_cons.h b/stand/efi/loader/xhci_dbc_cons.h
new file mode 100644
index 000000000000..d9c9886b8c47
--- /dev/null
+++ b/stand/efi/loader/xhci_dbc_cons.h
@@ -0,0 +1,29 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2019-2024 Hiroki Sato <hrs@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+extern struct console udb_console;
+extern struct xhci_debug_softc *udb_sc;
diff --git a/stand/efi/loader/xhci_dbc_dma.c b/stand/efi/loader/xhci_dbc_dma.c
new file mode 100644
index 000000000000..c7c8d97a342d
--- /dev/null
+++ b/stand/efi/loader/xhci_dbc_dma.c
@@ -0,0 +1,346 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2019-2024 Hiroki Sato <hrs@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+#include <sys/param.h>
+#include <dev/pci/pcireg.h>
+#include <dev/usb/controller/xhcireg.h>
+
+#include <assert.h>
+
+#include <bootstrap.h>
+#include <efi.h>
+#include <efilib.h>
+
+#include "pci.h"
+#include "xhci_dbc_pci.h"
+#include <dev/usb/controller/xhci_private.h>
+#include <dev/usb/controller/xhci_dbc.h>
+#include <dev/usb/controller/xhci_dbc_private.h>
+
+#include "xhci_dbc_dma.h"
+
+EFI_GUID pciio_guid = EFI_PCI_IO_PROTOCOL_GUID;
+
+static void *udb_alloc_dma(struct xhci_debug_softc *, uint64_t);
+static void udb_free_dma(struct xhci_debug_softc *, VOID *);
+static uint64_t v2p(struct xhci_debug_softc *, void *);
+
+uint64_t
+v2p(struct xhci_debug_softc *sc, void *virt)
+{
+	UINTN i;
+	UINTN p;
+	UINTN offset;
+	UINTN needed;
+	UINTN mapped;
+	struct dma *dma;
+	EFI_PCI_IO_PROTOCOL *pci;
+	EFI_STATUS status;
+	EFI_PHYSICAL_ADDRESS paddr;
+	VOID *mapping;
+
+	dma = NULL;
+	pci = sc->sc_efi_pciio;
+	for (i = 0; i < DMA_DESC_CAP; i++) {
+		dma = &sc->dma_desc[i];
+
+		DEBUG_V_PRINTF("%s: dma_desc[%lu].cpu_addr = %p\n", __func__,
+		    i, dma->cpu_addr);
+		for (p = 0; p < dma->pages; p++) {
+			UINTN addr = (UINTN)dma->cpu_addr + (p * PAGE_SIZE);
+
+			DEBUG_V_PRINTF("%s: check addr: %lu = %lu + %lu * %u\n",
+			    __func__, addr, (UINTN)dma->cpu_addr, p, PAGE_SIZE);
+			if ((UINTN)virt == addr) {
+				offset = addr - (UINTN)dma->cpu_addr;
+				goto found;
+			}
+		}
+		dma = NULL;
+	}
+	if (dma == NULL) {
+		DEBUG_PRINTF("CPU addr %p not found in DMA descriptor\n", virt);
+		return 0;
+	}
+
+found:
+#if 0
+	DEBUG_PRINTF("%s: found, i = %lu, dma->paddr = %lu, offset = %lu\n",
+	    __func__, i, dma->paddr, offset);
+#endif
+	if (dma->paddr && dma->mapping)
+		return (dma->paddr + offset);
+
+	needed = dma->pages << EFI_PAGE_SHIFT;
+	mapped = needed;
+	status = pci->Map(pci, EfiPciIoOperationBusMasterCommonBuffer,
+	    (void *)virt, &mapped, &paddr, &mapping);
+	if (EFI_ERROR(status) || mapped != needed) {
+		DEBUG_PRINTF("pci->Map failed: rc: 0x%lx, mapped: %lu, needed: %lu\n",
+		    status, mapped, needed);
+		return (0);
+	}
+	dma->paddr = paddr;
+	dma->mapping = mapping;
+
+	if ((const void *)paddr != virt) {
+		DEBUG_PRINTF("Non-identity DMA mapping: dma: 0x%lx cpu: %p\n",
+		    paddr, virt);
+	}
+
+	return (paddr);
+}
+
+struct xhci_debug_softc *
+udb_sc_malloc(size_t len, EFI_HANDLE *h, EFI_PCI_IO_PROTOCOL *pciio)
+{
+	struct xhci_debug_softc *sc;
+	EFI_STATUS status;
+	VOID *addr;
+	int pages;
+
+	sc = NULL;
+	pages = sizeof(*sc) / PAGE_SIZE + 1;
+	status = pciio->AllocateBuffer(pciio,
+	    AllocateAnyPages,
+	    EfiRuntimeServicesData,
+	    sizeof(*sc) / PAGE_SIZE + 1,
+	    &addr,
+	    EFI_PCI_IO_ATTRIBUTE_MEMORY_CACHED);
+	if (EFI_ERROR(status)) {
+		DEBUG_PRINTF("%s: AllocateBuffer failed: 0x%lx\n",
+		    __func__, status);
+		return (NULL);
+	}
+	memset(addr, 0, sizeof(*sc));
+	sc = (struct xhci_debug_softc *)addr;
+
+	sc->dma_desc[0].pages = pages;
+	sc->dma_desc[0].cpu_addr = addr;
+	sc->sc_efi_pciio = pciio;
+	sc->sc_efi_hand = h;
+	sc->dma_allocated = false;
+	sc->sc_init = false;
+
+	return (sc);
+}
+
+int
+xhci_debug_init_dma(struct xhci_debug_softc *sc)
+{
+	struct xhci_debug_softc *sc_udb;
+	char buf[1024];
+#define	ALLOC_DMA(p, type, order)				\
+	do { 							\
+		p = (type)udb_alloc_dma(sc, order); 		\
+		if (p == NULL) { 				\
+			xhci_debug_uninit_dma(sc);		\
+			return (1);				\
+		}						\
+	} while (0)
+
+	if (sc->dma_allocated)
+		return (0);
+
+	/* Export softc */
+	snprintf(buf, sizeof(buf), "%p", (void *)(uintptr_t)v2p(sc, sc));
+	buf[sizeof(buf) - 1] = '\0';
+	setenv("hw.usb.xhci.dbc.softc.paddr", buf, 1);
+	snprintf(buf, sizeof(buf), "%zu", sizeof(*sc));
+	buf[sizeof(buf) - 1] = '\0';
+	setenv("hw.usb.xhci.dbc.softc.len", buf, 1);
+
+	ALLOC_DMA(sc->udb_ctx, struct xhci_debug_ctx *, 0);
+	ALLOC_DMA(sc->udb_erst, struct xhci_event_ring_seg *, 0);
+	ALLOC_DMA(sc->udb_ering.trb, struct xhci_trb *, UDB_TRB_RING_ORDER);
+	ALLOC_DMA(sc->udb_iring.trb, struct xhci_trb *, UDB_TRB_RING_ORDER);
+	ALLOC_DMA(sc->udb_oring.trb, struct xhci_trb *, UDB_TRB_RING_ORDER);
+	ALLOC_DMA(sc->udb_iring.work.buf, uint8_t *, UDB_WORK_RING_ORDER);
+	ALLOC_DMA(sc->udb_oring.work.buf, uint8_t *, UDB_WORK_RING_ORDER);
+	ALLOC_DMA(sc->udb_str, char *, 0);
+
+	/* Export CTX, ERST, and STR */
+#define	SETADDR(n, len) do { \
+		sc->udb_##n##_paddr = (uintptr_t)v2p(sc, sc->udb_##n); \
+		snprintf(buf, sizeof(buf), "%p", \
+		    (void *)v2p(sc, sc->udb_##n)); \
+		buf[sizeof(buf) - 1] = '\0'; \
+		setenv("hw.usb.xhci.dbc." #n ".paddr", buf, 1); \
+		snprintf(buf, sizeof(buf), "%lu", \
+		    (uint64_t)len); \
+		buf[sizeof(buf) - 1] = '\0'; \
+		setenv("hw.usb.xhci.dbc." #n ".len", buf, 1); \
+	} while (0)
+	SETADDR(ctx, PAGE_SIZE);
+	SETADDR(erst, PAGE_SIZE);
+	SETADDR(str, PAGE_SIZE);
+
+	/* Export TRB rings. */
+#define	SETADDR_RING(n, paddr, trb, len) do { \
+		sc->udb_##paddr = (uintptr_t)v2p(sc, sc->udb_##trb); \
+		snprintf(buf, sizeof(buf), "%p", (void *)sc->udb_##paddr); \
+		buf[sizeof(buf) - 1] = '\0'; \
+		setenv("hw.usb.xhci.dbc." #paddr, buf, 1); \
+		snprintf(buf, sizeof(buf), "%lu", (uint64_t)len); \
+		buf[sizeof(buf) - 1] = '\0'; \
+		setenv("hw.usb.xhci.dbc." #n ".len", buf, 1); \
+	} while (0)
+	
+	SETADDR_RING(ering, ering.paddr, ering.trb,
+	    PAGE_SIZE * (1UL << UDB_TRB_RING_ORDER));
+	SETADDR_RING(iring, iring.paddr, iring.trb,
+	    PAGE_SIZE * (1UL << UDB_TRB_RING_ORDER));
+	SETADDR_RING(oring, oring.paddr, oring.trb,
+	    PAGE_SIZE * (1UL << UDB_TRB_RING_ORDER));
+	SETADDR_RING(iring.work, iring.work.paddr, iring.work.buf,
+	    PAGE_SIZE * (1UL << UDB_WORK_RING_ORDER));
+	SETADDR_RING(oring.work, oring.work.paddr, oring.work.buf,
+	    PAGE_SIZE * (1UL << UDB_WORK_RING_ORDER));
+
+	sc->dma_allocated = true;
+
+	return (0);
+#undef	ALLOC_DMA
+}
+
+static void *
+udb_alloc_dma(struct xhci_debug_softc *sc, uint64_t order)
+{
+	struct dma *dma;
+	EFI_STATUS status;
+	VOID *addr;
+	UINTN pages = 1UL << order;
+	UINTN i;
+
+	for (i = 0; i < DMA_DESC_CAP; i++) {
+		dma = &sc->dma_desc[i];
+		if (dma->cpu_addr == NULL)
+			break;
+	}
+	if (i == DMA_DESC_CAP) {
+		DEBUG_PRINTF("%s: Out of DMA descriptor\n", __func__);
+		return (NULL);
+	}
+	status = sc->sc_efi_pciio->AllocateBuffer(sc->sc_efi_pciio,
+	    AllocateAnyPages,
+	    EfiRuntimeServicesData,
+	    pages,
+	    &addr,
+	    EFI_PCI_IO_ATTRIBUTE_MEMORY_CACHED);
+	if (EFI_ERROR(status)) {
+		DEBUG_PRINTF("%s: AllocateBuffer failed: 0x%lx\n",
+		    __func__, status);
+		return (NULL);
+	}
+
+	dma->pages = pages;
+	dma->cpu_addr = addr;
+	DEBUG_PRINTF("%s: i = %lu, cpu_addr = %p, pages = %lu\n", __func__,
+	    i, dma->cpu_addr, pages);
+
+	return (addr);
+}
+
+static void
+udb_free_dma(struct xhci_debug_softc *sc, VOID *addr)
+{
+	struct dma *dma;
+	EFI_STATUS status;
+	UINTN i;
+
+	for (i = 0; i < DMA_DESC_CAP; i++) {
+		dma = &sc->dma_desc[i];
+		if (dma->cpu_addr == addr)
+			break;
+	}
+	if (i == DMA_DESC_CAP)
+		return;
+	if (dma->mapping) {
+		status = sc->sc_efi_pciio->Unmap(sc->sc_efi_pciio,
+		    dma->mapping);
+		if (EFI_ERROR(status)) {
+			DEBUG_PRINTF("%s: Unmap failed: 0x%lx\n",
+			    __func__, status);
+			return;
+		}
+	}
+	status = sc->sc_efi_pciio->FreeBuffer(sc->sc_efi_pciio, dma->pages,
+	    addr);
+	if (EFI_ERROR(status)) {
+		DEBUG_PRINTF("%s: FreeBuffer failed: 0x%lx\n",
+		    __func__, status);
+		return;
+	}
+	memset(&dma, 0, sizeof(*dma));
+}
+
+void
+xhci_debug_uninit_dma(struct xhci_debug_softc *sc)
+{
+	udb_free_dma(sc, sc->udb_ctx);
+	udb_free_dma(sc, sc->udb_erst);
+	udb_free_dma(sc, sc->udb_ering.trb);
+	udb_free_dma(sc, sc->udb_oring.trb);
+	udb_free_dma(sc, sc->udb_iring.trb);
+	udb_free_dma(sc, sc->udb_oring.work.buf);
+	udb_free_dma(sc, sc->udb_iring.work.buf);
+
+	sc->dma_allocated = false;
+}
+
+int
+xhci_debug_pci_mmio_init(struct xhci_debug_softc *sc)
+{
+	volatile uint32_t barl;	/* volatile is required. */
+	volatile uint32_t barh;	/* volatile is required. */
+
+	/* Parse the BAR and map the registers */
+	barl = pci_read_config(sc->sc_ca, PCIR_CA_BAR_LO);
+	barh = pci_read_config(sc->sc_ca, PCIR_CA_BAR_HI);
+
+	if ((barl & 0x1) != 0 || ((barl & 0x6) >> 1) != 2) {
+		DEBUG_PRINTF("%s: BAR must be 64-bit.\n", __func__);
+		return (0);
+	}
+
+	pci_write_config(sc->sc_ca, PCIR_CA_BAR_LO, 0xffffffff);
+	sc->sc_mmio_size =
+	    ~(pci_read_config(sc->sc_ca, PCIR_CA_BAR_LO) & 0xfffffff0) + 1;
+	pci_write_config(sc->sc_ca, PCIR_CA_BAR_LO, barl);
+
+	/* XXX: This assumes 64-bit. */
+	sc->sc_mmio_phys =
+	    (uintptr_t)(((uint64_t)barl & 0xfffffff0) | ((uint64_t)barh << 32));
+	sc->sc_mmio = (void *)sc->sc_mmio_phys;
+	sc->sc_capa_off = 0;
+
+	if (sc->sc_mmio == NULL) {
+		DEBUG_PRINTF("%s: mmio_phys is NULL.\n", __func__);
+		return (0);
+	}
+	return (1);
+}
diff --git a/stand/efi/loader/xhci_dbc_dma.h b/stand/efi/loader/xhci_dbc_dma.h
new file mode 100644
index 000000000000..c4cfa256ce75
--- /dev/null
+++ b/stand/efi/loader/xhci_dbc_dma.h
@@ -0,0 +1,35 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2019-2024 Hiroki Sato <hrs@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+int xhci_debug_init_dma(struct xhci_debug_softc *);
+void xhci_debug_uninit_dma(struct xhci_debug_softc *);
+int xhci_debug_pci_mmio_init(struct xhci_debug_softc *);
+
+struct xhci_debug_softc *udb_sc_malloc(size_t, EFI_HANDLE *,
+    EFI_PCI_IO_PROTOCOL *);
+
+extern EFI_GUID pciio_guid;
diff --git a/stand/efi/loader/xhci_dbc_pci.h b/stand/efi/loader/xhci_dbc_pci.h
new file mode 100644
index 000000000000..44bdf44d4287
--- /dev/null
+++ b/stand/efi/loader/xhci_dbc_pci.h
@@ -0,0 +1,125 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2019-2024 Hiroki Sato <hrs@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+/* Supported xHC PCI configurations */
+#define XHC_CLASSC		0x0c0330ULL
+#define XHC_VEN_INTEL		0x8086ULL
+
+#define	XHC_DEV_COMET_LAKE_LP	0x02edULL
+#define	XHC_DEV_COMET_LAKE	0x06edULL
+#define	XHC_DEV_N2000		0x0f35ULL
+#define	XHC_DEV_C3000		0x19d0ULL
+#define	XHC_DEV_C210		0x1e31ULL
+#define	XHC_DEV_E8000		0x22b5ULL
+#define	XHC_DEV_PUMA		0x2bb5ULL
+#define	XHC_DEV_CELERON		0x31a8ULL
+#define	XHC_DEV_ICE_LAKE	0x34edULL
+#define	XHC_DEV_TIGER_LAKE_H	0x43edULL
+#define	XHC_DEV_N3350		0x5aa8ULL
+#define	XHC_DEV_C220		0x8c31ULL
+#define	XHC_DEV_NINE		0x8cb1ULL
+#define	XHC_DEV_C610		0x8d31ULL
+#define	XHC_DEV_EIGHT		0x9c31ULL
+#define	XHC_DEV_WILDCAT_POINT	0x9cb1ULL
+#define	XHC_DEV_SUNRISE_POINT	0x9d2fULL
+#define	XHC_DEV_CANNON_POINT	0x9dedULL
+#define	XHC_DEV_SILVER		0x31a8ULL
+#define	XHC_DEV_TIGER_LAKE	0xa0edULL
+#define	XHC_DEV_C230		0xa12fULL
+#define	XHC_DEV_C620		0xa1afULL
+#define	XHC_DEV_Z370		0xa2afULL
+#define	XHC_DEV_CANNON_LAKE	0xa36dULL
+
+#define XHC_VEN_AMD		0x1022ULL
+
+#define	XHC_DEV_KERNCZ		0x145cULL
+#define	XHC_DEV_STARSHIP	0x148cULL
+#define	XHC_DEV_MATISSE		0x149cULL
+#define	XHC_DEV_X399		0x43baULL
+#define	XHC_DEV_X370		0x43b9ULL
+#define	XHC_DEV_B350		0x43bbULL
+#define	XHC_DEV_400		0x43d5ULL
+#define	XHC_DEV_FCH_1		0x7812ULL
+#define	XHC_DEV_FCH_2		0x7814ULL
+#define	XHC_DEV_FCH_3		0x7914ULL
+
+#define XHC_VEN_VMWARE		0x15adULL
+#define	XHC_DEV_VMWARE_1	0x0778ULL
+#define	XHC_DEV_VMWARE_2	0x0779ULL
+
+#define XHC_VEN_ASMEDIA		0x1b21ULL
+#define XHC_DEV_ASM1042		0x1042ULL
+#define XHC_DEV_ASM1042A	0x1142ULL
+#define XHC_DEV_ASM1143		0x1343ULL
+#define XHC_DEV_ASM3242		0x3242ULL
+
+static struct pciid ids[] = {
+	{ XHC_VEN_INTEL, XHC_DEV_COMET_LAKE_LP },
+	{ XHC_VEN_INTEL, XHC_DEV_COMET_LAKE },
+	{ XHC_VEN_INTEL, XHC_DEV_N2000 },
+	{ XHC_VEN_INTEL, XHC_DEV_C3000 },
+	{ XHC_VEN_INTEL, XHC_DEV_C210 },
+	{ XHC_VEN_INTEL, XHC_DEV_E8000 },
+	{ XHC_VEN_INTEL, XHC_DEV_PUMA },
+	{ XHC_VEN_INTEL, XHC_DEV_CELERON },
+	{ XHC_VEN_INTEL, XHC_DEV_ICE_LAKE },
+	{ XHC_VEN_INTEL, XHC_DEV_TIGER_LAKE_H },
+	{ XHC_VEN_INTEL, XHC_DEV_N3350 },
+	{ XHC_VEN_INTEL, XHC_DEV_C220 },
+	{ XHC_VEN_INTEL, XHC_DEV_NINE },
+	{ XHC_VEN_INTEL, XHC_DEV_C610 },
+	{ XHC_VEN_INTEL, XHC_DEV_EIGHT },
+	{ XHC_VEN_INTEL, XHC_DEV_WILDCAT_POINT },
+	{ XHC_VEN_INTEL, XHC_DEV_SUNRISE_POINT },
+	{ XHC_VEN_INTEL, XHC_DEV_CANNON_POINT },
+	{ XHC_VEN_INTEL, XHC_DEV_SILVER },
+	{ XHC_VEN_INTEL, XHC_DEV_TIGER_LAKE },
+	{ XHC_VEN_INTEL, XHC_DEV_C230 },
+	{ XHC_VEN_INTEL, XHC_DEV_C620 },
+	{ XHC_VEN_INTEL, XHC_DEV_Z370 },
+	{ XHC_VEN_INTEL, XHC_DEV_CANNON_LAKE },
+
+	{ XHC_VEN_AMD, XHC_DEV_KERNCZ },
+	{ XHC_VEN_AMD, XHC_DEV_STARSHIP },
+	{ XHC_VEN_AMD, XHC_DEV_MATISSE },
+	{ XHC_VEN_AMD, XHC_DEV_X399 },
+	{ XHC_VEN_AMD, XHC_DEV_X370 },
+	{ XHC_VEN_AMD, XHC_DEV_B350 },
+	{ XHC_VEN_AMD, XHC_DEV_400 },
+	{ XHC_VEN_AMD, XHC_DEV_FCH_1 },
+	{ XHC_VEN_AMD, XHC_DEV_FCH_2 },
+	{ XHC_VEN_AMD, XHC_DEV_FCH_3 },
+
+	{ XHC_VEN_VMWARE, XHC_DEV_VMWARE_1 },
+	{ XHC_VEN_VMWARE, XHC_DEV_VMWARE_2 },
+
+	{ XHC_VEN_ASMEDIA, XHC_DEV_ASM1042 },
+	{ XHC_VEN_ASMEDIA, XHC_DEV_ASM1042A },
+	{ XHC_VEN_ASMEDIA, XHC_DEV_ASM1143 },
+	{ XHC_VEN_ASMEDIA, XHC_DEV_ASM3242 },
+	{ 0, 0 }
+};
diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c
index ea440f46a12f..b1909909f201 100644
--- a/sys/amd64/amd64/machdep.c
+++ b/sys/amd64/amd64/machdep.c
@@ -866,6 +866,12 @@ getmemsize(caddr_t kmdp, u_int64_t first)
 	u_long physmem_start, physmem_tunable, memtest;
 	pt_entry_t *pte;
 	quad_t dcons_addr, dcons_size;
+	quad_t xhci_dbc_ering_addr, xhci_dbc_ering_len;
+	quad_t xhci_dbc_iring_addr, xhci_dbc_iring_len;
+	quad_t xhci_dbc_oring_addr, xhci_dbc_oring_len;
+	quad_t xhci_dbc_iring_work_addr, xhci_dbc_iring_work_len;
+	quad_t xhci_dbc_oring_work_addr, xhci_dbc_oring_work_len;
+	quad_t xhci_dbc_softc_addr, xhci_dbc_softc_len;
 	int page_counter;
 
 	TSENTER();
@@ -970,6 +976,24 @@ getmemsize(caddr_t kmdp, u_int64_t first)
 	    getenv_quad("dcons.size", &dcons_size) == 0)
 		dcons_addr = 0;
 
+	/*
+	 * Get XHCI DbC TRB ring addresses
+	 */
+	getenv_quad("hw.usb.xhci.dbc.ering.paddr", &xhci_dbc_ering_addr);
+	getenv_quad("hw.usb.xhci.dbc.ering.len", &xhci_dbc_ering_len);
+	getenv_quad("hw.usb.xhci.dbc.iring.paddr", &xhci_dbc_iring_addr);
+	getenv_quad("hw.usb.xhci.dbc.iring.len", &xhci_dbc_iring_len);
+	getenv_quad("hw.usb.xhci.dbc.oring.paddr", &xhci_dbc_oring_addr);
+	getenv_quad("hw.usb.xhci.dbc.oring.len", &xhci_dbc_oring_len);
+
+	getenv_quad("hw.usb.xhci.dbc.oring.work.paddr", &xhci_dbc_oring_work_addr);
+	getenv_quad("hw.usb.xhci.dbc.oring.work.len", &xhci_dbc_oring_work_len);
+
+	getenv_quad("hw.usb.xhci.dbc.iring.work.paddr", &xhci_dbc_iring_work_addr);
+	getenv_quad("hw.usb.xhci.dbc.iring.work.len", &xhci_dbc_iring_work_len);
+	getenv_quad("hw.usb.xhci.dbc.softc.paddr", &xhci_dbc_softc_addr);
+	getenv_quad("hw.usb.xhci.dbc.softc.len", &xhci_dbc_softc_len);
+
 	/*
 	 * physmap is in bytes, so when converting to page boundaries,
 	 * round up the start address and round down the end address.
@@ -1001,6 +1025,16 @@ getmemsize(caddr_t kmdp, u_int64_t first)
 			    && pa >= trunc_page(dcons_addr)
 			    && pa < dcons_addr + dcons_size)
 				goto do_dump_avail;
+#define	BLOCKOUT(addr, len) do { \
+	if (addr > 0 && pa >= trunc_page(addr) && pa < addr + len) \
+		goto do_dump_avail; \
+	} while (0)
+			BLOCKOUT(xhci_dbc_ering_addr, xhci_dbc_ering_len);
+			BLOCKOUT(xhci_dbc_iring_addr, xhci_dbc_iring_len);
+			BLOCKOUT(xhci_dbc_oring_addr, xhci_dbc_oring_len);
+			BLOCKOUT(xhci_dbc_iring_work_addr, xhci_dbc_iring_work_len);
+			BLOCKOUT(xhci_dbc_oring_work_addr, xhci_dbc_oring_work_len);
+			BLOCKOUT(xhci_dbc_softc_addr, xhci_dbc_softc_len);
 
 			page_bad = FALSE;
 			if (memtest == 0)
diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c
index d506ffada4b9..91737637b714 100644
--- a/sys/amd64/amd64/mp_machdep.c
+++ b/sys/amd64/amd64/mp_machdep.c
@@ -102,13 +102,16 @@ void *bootpcpu;
 
 extern u_int mptramp_la57;
 extern u_int mptramp_nx;
-
+smp_targeted_tlb_shootdown_t smp_targeted_tlb_shootdown = &smp_targeted_tlb_shootdown_native;
 /*
  * Local data and functions.
  */
 
 static int start_ap(int apic_id, vm_paddr_t boot_address);
 
+void
+smp_targeted_tlb_shootdown_native(pmap_t pmap, vm_offset_t addr1, vm_offset_t addr2,
+    smp_invl_cb_t curcpu_cb, enum invl_op_codes op);
 /*
  * Initialize the IPI handlers and start up the AP's.
  */
@@ -497,24 +500,6 @@ start_ap(int apic_id, vm_paddr_t boot_address)
  * Flush the TLB on other CPU's
  */
 
-/*
- * Invalidation request.  PCPU pc_smp_tlb_op uses u_int instead of the
- * enum to avoid both namespace and ABI issues (with enums).
- */
-enum invl_op_codes {
-      INVL_OP_TLB		= 1,
-      INVL_OP_TLB_INVPCID	= 2,
-      INVL_OP_TLB_INVPCID_PTI	= 3,
-      INVL_OP_TLB_PCID		= 4,
-      INVL_OP_PGRNG		= 5,
-      INVL_OP_PGRNG_INVPCID	= 6,
-      INVL_OP_PGRNG_PCID	= 7,
-      INVL_OP_PG		= 8,
-      INVL_OP_PG_INVPCID	= 9,
-      INVL_OP_PG_PCID		= 10,
-      INVL_OP_CACHE		= 11,
-};
-
 /*
  * These variables are initialized at startup to reflect how each of
  * the different kinds of invalidations should be performed on the
@@ -600,8 +585,8 @@ invl_scoreboard_slot(u_int cpu)
  * Function must be called with the thread pinned, and it unpins on
  * completion.
  */
-static void
-smp_targeted_tlb_shootdown(pmap_t pmap, vm_offset_t addr1, vm_offset_t addr2,
+void
+smp_targeted_tlb_shootdown_native(pmap_t pmap, vm_offset_t addr1, vm_offset_t addr2,
     smp_invl_cb_t curcpu_cb, enum invl_op_codes op)
 {
 	cpuset_t mask;
diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c
index 233069d37bfb..d6e9713f215a 100644
--- a/sys/amd64/amd64/pmap.c
+++ b/sys/amd64/amd64/pmap.c
@@ -1611,8 +1611,8 @@ nkpt_init(vm_paddr_t addr)
 	 * Secondly, device memory mapped as part of setting up the low-
 	 * level console(s) is taken from KVA, starting at virtual_avail.
 	 * This is because cninit() is called after pmap_bootstrap() but
-	 * before vm_init() and pmap_init(). 20MB for a frame buffer is
-	 * not uncommon.
+	 * before vm_mem_init() and pmap_init(). 20MB for a frame buffer
+	 * is not uncommon.
 	 */
 	pt_pages += 32;		/* 64MB additional slop. */
 #endif
@@ -2451,7 +2451,8 @@ pmap_init_pv_table(void)
 
 /*
  *	Initialize the pmap module.
- *	Called by vm_init, to initialize any structures that the pmap
+ *
+ *	Called by vm_mem_init(), to initialize any structures that the pmap
  *	system needs to map virtual memory.
  */
 void
diff --git a/sys/amd64/conf/GENERIC b/sys/amd64/conf/GENERIC
index ab1c3856051b..38212dec294f 100644
--- a/sys/amd64/conf/GENERIC
+++ b/sys/amd64/conf/GENERIC
@@ -380,3 +380,6 @@ device		uinput			# install /dev/uinput cdev
 options 	HID_DEBUG		# enable debug msgs
 device		hid			# Generic HID support
 options 	IICHID_SAMPLING		# Workaround missing GPIO INTR support
+
+options		GDB
+options		DDB
diff --git a/sys/amd64/include/pmap.h b/sys/amd64/include/pmap.h
index bf531ab6ae56..506b28562bcc 100644
--- a/sys/amd64/include/pmap.h
+++ b/sys/amd64/include/pmap.h
@@ -545,6 +545,33 @@ pmap_get_pcid(pmap_t pmap)
 }
 #endif /* sys/pcpu.h */
 
+/*
+ * Invalidation request.  PCPU pc_smp_tlb_op uses u_int instead of the
+ * enum to avoid both namespace and ABI issues (with enums).
+ */
+enum invl_op_codes {
+	INVL_OP_TLB               = 1,
+	INVL_OP_TLB_INVPCID       = 2,
+	INVL_OP_TLB_INVPCID_PTI   = 3,
+	INVL_OP_TLB_PCID          = 4,
+	INVL_OP_PGRNG             = 5,
+	INVL_OP_PGRNG_INVPCID     = 6,
+	INVL_OP_PGRNG_PCID        = 7,
+	INVL_OP_PG                = 8,
+	INVL_OP_PG_INVPCID        = 9,
+	INVL_OP_PG_PCID           = 10,
+	INVL_OP_CACHE             = 11,
+};
+
+typedef void (*smp_invl_local_cb_t)(struct pmap *, vm_offset_t addr1,
+    vm_offset_t addr2);
+typedef void (*smp_targeted_tlb_shootdown_t)(pmap_t, vm_offset_t, vm_offset_t,
+    smp_invl_local_cb_t, enum invl_op_codes);
+
+void smp_targeted_tlb_shootdown_native(pmap_t, vm_offset_t, vm_offset_t,
+    smp_invl_local_cb_t, enum invl_op_codes);
+extern smp_targeted_tlb_shootdown_t smp_targeted_tlb_shootdown;
+
 #endif /* _KERNEL */
 
 /* Return various clipped indexes for a given VA */
diff --git a/sys/amd64/include/vmm.h b/sys/amd64/include/vmm.h
index 7d5d13678122..368c3a6cb95b 100644
--- a/sys/amd64/include/vmm.h
+++ b/sys/amd64/include/vmm.h
@@ -144,6 +144,8 @@ enum x2apic_state {
     (SPECNAMELEN - VM_MAX_PREFIXLEN - VM_MAX_SUFFIXLEN - 1)
 
 #ifdef _KERNEL
+#include <sys/kassert.h>
+
 CTASSERT(VM_MAX_NAMELEN >= VM_MIN_NAMELEN);
 
 struct vm;
diff --git a/sys/arm/allwinner/if_emac.c b/sys/arm/allwinner/if_emac.c
index e0826cb6584a..bfd6e68ddc37 100644
--- a/sys/arm/allwinner/if_emac.c
+++ b/sys/arm/allwinner/if_emac.c
@@ -941,11 +941,6 @@ emac_attach(device_t dev)
 	emac_reset(sc);
 
 	ifp = sc->emac_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "unable to allocate ifp\n");
-		error = ENOSPC;
-		goto fail;
-	}
 	if_setsoftc(ifp, sc);
 
 	/* Setup MII */
diff --git a/sys/arm/arm/pmap-v6.c b/sys/arm/arm/pmap-v6.c
index 92e992a4b25e..5cccb44a48f2 100644
--- a/sys/arm/arm/pmap-v6.c
+++ b/sys/arm/arm/pmap-v6.c
@@ -1707,8 +1707,9 @@ pmap_pt2pg_init(pmap_t pmap, vm_offset_t va, vm_page_t m)
 
 /*
  *  Initialize the pmap module.
- *  Called by vm_init, to initialize any structures that the pmap
- *  system needs to map virtual memory.
+ *
+ *  Called by vm_mem_init(), to initialize any structures that the pmap system
+ *  needs to map virtual memory.
  */
 void
 pmap_init(void)
diff --git a/sys/arm/nvidia/tegra_ahci.c b/sys/arm/nvidia/tegra_ahci.c
index 4f44a09b4a76..b2ca1f9e496b 100644
--- a/sys/arm/nvidia/tegra_ahci.c
+++ b/sys/arm/nvidia/tegra_ahci.c
@@ -651,7 +651,7 @@ tegra_ahci_probe(device_t dev)
 	if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data)
 		return (ENXIO);
 
-	device_set_desc_copy(dev, "AHCI SATA controller");
+	device_set_desc(dev, "AHCI SATA controller");
 	return (BUS_PROBE_DEFAULT);
 }
 
diff --git a/sys/arm/ti/am335x/am335x_dmtimer.c b/sys/arm/ti/am335x/am335x_dmtimer.c
index e576a11fe70e..341ec07466fc 100644
--- a/sys/arm/ti/am335x/am335x_dmtimer.c
+++ b/sys/arm/ti/am335x/am335x_dmtimer.c
@@ -249,7 +249,6 @@ am335x_dmtimer_tc_init(struct am335x_dmtimer_softc *sc)
 static int
 am335x_dmtimer_probe(device_t dev)
 {
-	char strbuf[32];
 	int tmr_num;
 	uint64_t rev_address;
 
@@ -277,8 +276,7 @@ am335x_dmtimer_probe(device_t dev)
 			return (ENXIO);
 	}
 
-	snprintf(strbuf, sizeof(strbuf), "AM335x DMTimer%d", tmr_num);
-	device_set_desc_copy(dev, strbuf);
+	device_set_descf("AM335x DMTimer%d", tmr_num);
 
 	return(BUS_PROBE_DEFAULT);
 }
diff --git a/sys/arm/ti/am335x/am335x_dmtpps.c b/sys/arm/ti/am335x/am335x_dmtpps.c
index 23b930741c2a..21b7c847f9dd 100644
--- a/sys/arm/ti/am335x/am335x_dmtpps.c
+++ b/sys/arm/ti/am335x/am335x_dmtpps.c
@@ -383,7 +383,6 @@ static struct cdevsw dmtpps_cdevsw = {
 static int
 dmtpps_probe(device_t dev)
 {
-	char strbuf[64];
 	int tmr_num;
 	uint64_t rev_address;
 
@@ -435,9 +434,7 @@ dmtpps_probe(device_t dev)
 	if (dmtpps_tmr_num != tmr_num)
 		return (ENXIO);
 
-	snprintf(strbuf, sizeof(strbuf), "AM335x PPS-Capture DMTimer%d",
-	    tmr_num);
-	device_set_desc_copy(dev, strbuf);
+	device_set_descf(dev, "AM335x PPS-Capture DMTimer%d", tmr_num);
 
 	return(BUS_PROBE_DEFAULT);
 }
diff --git a/sys/arm/ti/cpsw/if_cpsw.c b/sys/arm/ti/cpsw/if_cpsw.c
index 223d24019cb8..8cb748cfc119 100644
--- a/sys/arm/ti/cpsw/if_cpsw.c
+++ b/sys/arm/ti/cpsw/if_cpsw.c
@@ -1025,11 +1025,6 @@ cpswp_attach(device_t dev)
 
 	/* Allocate network interface */
 	ifp = sc->ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		cpswp_detach(dev);
-		return (ENXIO);
-	}
-
 	if_initname(ifp, device_get_name(sc->dev), sc->unit);
 	if_setsoftc(ifp, sc);
 	if_setflags(ifp, IFF_SIMPLEX | IFF_MULTICAST | IFF_BROADCAST);
diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c
index b372295d5d43..a5d037d7b71c 100644
--- a/sys/arm64/arm64/pmap.c
+++ b/sys/arm64/arm64/pmap.c
@@ -1536,7 +1536,8 @@ pmap_init_pv_table(void)
 
 /*
  *	Initialize the pmap module.
- *	Called by vm_init, to initialize any structures that the pmap
+ *
+ *	Called by vm_mem_init(), to initialize any structures that the pmap
  *	system needs to map virtual memory.
  */
 void
diff --git a/sys/arm64/broadcom/genet/if_genet.c b/sys/arm64/broadcom/genet/if_genet.c
index 40fc096208c6..8fb46a7552f1 100644
--- a/sys/arm64/broadcom/genet/if_genet.c
+++ b/sys/arm64/broadcom/genet/if_genet.c
@@ -1070,6 +1070,10 @@ gen_encap(struct gen_softc *sc, struct mbuf **mp)
 	GEN_ASSERT_LOCKED(sc);
 
 	q = &sc->tx_queue[DEF_TXQUEUE];
+	if (q->queued == q->nentries) {
+		/* tx_queue is full */
+		return (ENOBUFS);
+	}
 
 	m = *mp;
 
diff --git a/sys/arm64/cavium/thunder_pcie_pem.c b/sys/arm64/cavium/thunder_pcie_pem.c
index a1bd54d9744d..2841486c1442 100644
--- a/sys/arm64/cavium/thunder_pcie_pem.c
+++ b/sys/arm64/cavium/thunder_pcie_pem.c
@@ -735,7 +735,7 @@ thunder_pem_probe(device_t dev)
 
 	if ((pci_vendor_id == THUNDER_PEM_VENDOR_ID) &&
 	    (pci_device_id == THUNDER_PEM_DEVICE_ID)) {
-		device_set_desc_copy(dev, THUNDER_PEM_DESC);
+		device_set_desc(dev, THUNDER_PEM_DESC);
 		return (0);
 	}
 
diff --git a/sys/arm64/include/pmap.h b/sys/arm64/include/pmap.h
index 4b4d47ccc7af..a250b5a20420 100644
--- a/sys/arm64/include/pmap.h
+++ b/sys/arm64/include/pmap.h
@@ -69,16 +69,6 @@ struct md_page {
 	vm_memattr_t		pv_memattr;
 };
 
-/*
- * This structure is used to hold a virtual<->physical address
- * association and is used mostly by bootstrap code
- */
-struct pv_addr {
-	SLIST_ENTRY(pv_addr) pv_list;
-	vm_offset_t	pv_va;
-	vm_paddr_t	pv_pa;
-};
-
 enum pmap_stage {
 	PM_INVALID,
 	PM_STAGE1,
diff --git a/sys/arm64/include/vmparam.h b/sys/arm64/include/vmparam.h
index fee8e01f72c4..b37bd823878d 100644
--- a/sys/arm64/include/vmparam.h
+++ b/sys/arm64/include/vmparam.h
@@ -273,7 +273,6 @@
 extern vm_paddr_t dmap_phys_base;
 extern vm_paddr_t dmap_phys_max;
 extern vm_offset_t dmap_max_addr;
-extern vm_offset_t vm_max_kernel_address;
 
 #endif
 
diff --git a/sys/arm64/rockchip/rk_pinctrl.c b/sys/arm64/rockchip/rk_pinctrl.c
index 7a47e3b9d468..02017258dbe2 100644
--- a/sys/arm64/rockchip/rk_pinctrl.c
+++ b/sys/arm64/rockchip/rk_pinctrl.c
@@ -1142,9 +1142,9 @@ rk_pinctrl_configure_pin(struct rk_pinctrl_softc *sc, uint32_t *pindata)
 {
 	phandle_t pin_conf;
 	struct syscon *syscon;
-	uint32_t bank, subbank, pin, function, bias;
+	uint32_t bank, subbank, pin, function;
 	uint32_t bit, mask, reg, drive;
-	int i, rv;
+	int i, rv, bias;
 
 	bank = pindata[0];
 	pin = pindata[1];
diff --git a/sys/cddl/boot/zfs/zfsimpl.h b/sys/cddl/boot/zfs/zfsimpl.h
index fcaf407bcb75..0ce38384abbf 100644
--- a/sys/cddl/boot/zfs/zfsimpl.h
+++ b/sys/cddl/boot/zfs/zfsimpl.h
@@ -1465,7 +1465,10 @@ typedef struct dsl_dataset_phys {
 	uint64_t ds_guid;
 	uint64_t ds_flags;
 	blkptr_t ds_bp;
-	uint64_t ds_pad[8]; /* pad out to 320 bytes for good measure */
+	uint64_t ds_next_clones_obj;	/* DMU_OT_DSL_CLONES */
+	uint64_t ds_props_obj;		/* DMU_OT_DSL_PROPS for snaps */
+	uint64_t ds_userrefs_obj;	/* DMU_OT_USERREFS */
+	uint64_t ds_pad[5]; /* pad out to 320 bytes for good measure */
 } dsl_dataset_phys_t;
 
 typedef struct dsl_deadlist_phys {
diff --git a/sys/cddl/dev/dtrace/dtrace_cddl.h b/sys/cddl/dev/dtrace/dtrace_cddl.h
index 95317955c102..42a4721fbb90 100644
--- a/sys/cddl/dev/dtrace/dtrace_cddl.h
+++ b/sys/cddl/dev/dtrace/dtrace_cddl.h
@@ -25,8 +25,6 @@
 
 #include <sys/proc.h>
 
-#define LOCK_LEVEL	10
-
 /*
  * Kernel DTrace extension to 'struct proc' for FreeBSD.
  */
diff --git a/sys/compat/freebsd32/freebsd32_sysent.c b/sys/compat/freebsd32/freebsd32_sysent.c
index ecde86d07965..df4ec684ccb1 100644
--- a/sys/compat/freebsd32/freebsd32_sysent.c
+++ b/sys/compat/freebsd32/freebsd32_sysent.c
@@ -127,7 +127,7 @@ struct sysent freebsd32_sysent[] = {
 	{ .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT },			/* 63 = obsolete ogetkerninfo */
 	{ compat(0,getpagesize), .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC },	/* 64 = old getpagesize */
 	{ .sy_narg = AS(msync_args), .sy_call = (sy_call_t *)sys_msync, .sy_auevent = AUE_MSYNC, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC },	/* 65 = msync */
-	{ .sy_narg = 0, .sy_call = (sy_call_t *)sys_vfork, .sy_auevent = AUE_VFORK, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC },	/* 66 = vfork */
+	{ .sy_narg = 0, .sy_call = (sy_call_t *)sys_vfork, .sy_auevent = AUE_VFORK, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC },	/* 66 = vfork */
 	{ .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT },			/* 67 = obsolete vread */
 	{ .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT },			/* 68 = obsolete vwrite */
 	{ .sy_narg = AS(sbrk_args), .sy_call = (sy_call_t *)sys_sbrk, .sy_auevent = AUE_SBRK, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC },	/* 69 = sbrk */
@@ -312,7 +312,7 @@ struct sysent freebsd32_sysent[] = {
 	{ .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT },			/* 248 = ntp_gettime */
 	{ .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT },			/* 249 = reserved for local use */
 	{ .sy_narg = AS(minherit_args), .sy_call = (sy_call_t *)sys_minherit, .sy_auevent = AUE_MINHERIT, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC },	/* 250 = minherit */
-	{ .sy_narg = AS(rfork_args), .sy_call = (sy_call_t *)sys_rfork, .sy_auevent = AUE_RFORK, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC },	/* 251 = rfork */
+	{ .sy_narg = AS(rfork_args), .sy_call = (sy_call_t *)sys_rfork, .sy_auevent = AUE_RFORK, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC },	/* 251 = rfork */
 	{ .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT },			/* 252 = obsolete openbsd_poll */
 	{ .sy_narg = 0, .sy_call = (sy_call_t *)sys_issetugid, .sy_auevent = AUE_ISSETUGID, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC },	/* 253 = issetugid */
 	{ .sy_narg = AS(lchown_args), .sy_call = (sy_call_t *)sys_lchown, .sy_auevent = AUE_LCHOWN, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC },	/* 254 = lchown */
diff --git a/sys/compat/linux/linux_sysctl.c b/sys/compat/linux/linux_sysctl.c
index 65c64a7ba563..97341c051af7 100644
--- a/sys/compat/linux/linux_sysctl.c
+++ b/sys/compat/linux/linux_sysctl.c
@@ -74,7 +74,7 @@ LIN_SDT_PROBE_DEFINE1(sysctl, linux_sysctl, unsupported_sysctl, "char *");
 
 #ifdef LINUX_LEGACY_SYSCALLS
 static int
-handle_string(struct l___sysctl_args *la, char *value)
+handle_string(struct l___sysctl_args *la, const char *value)
 {
 	int error;
 
diff --git a/sys/compat/linuxkpi/common/include/linux/aperture.h b/sys/compat/linuxkpi/common/include/linux/aperture.h
new file mode 100644
index 000000000000..e0387ed0225d
--- /dev/null
+++ b/sys/compat/linuxkpi/common/include/linux/aperture.h
@@ -0,0 +1,58 @@
+/* SPDX-License-Identifier: MIT */
+
+#ifndef _LINUX_APERTURE_H_
+#define _LINUX_APERTURE_H_
+
+#include <linux/types.h>
+
+#define	CONFIG_APERTURE_HELPERS
+
+struct pci_dev;
+struct platform_device;
+
+#if defined(CONFIG_APERTURE_HELPERS)
+int devm_aperture_acquire_for_platform_device(struct platform_device *pdev,
+					      resource_size_t base,
+					      resource_size_t size);
+
+int aperture_remove_conflicting_devices(resource_size_t base, resource_size_t size,
+					bool primary, const char *name);
+
+int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev, const char *name);
+#else
+static inline int devm_aperture_acquire_for_platform_device(struct platform_device *pdev,
+							    resource_size_t base,
+							    resource_size_t size)
+{
+	return 0;
+}
+
+static inline int aperture_remove_conflicting_devices(resource_size_t base, resource_size_t size,
+						      bool primary, const char *name)
+{
+	return 0;
+}
+
+static inline int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev, const char *name)
+{
+	return 0;
+}
+#endif
+
+/**
+ * aperture_remove_all_conflicting_devices - remove all existing framebuffers
+ * @primary: also kick vga16fb if present; only relevant for VGA devices
+ * @name: a descriptive name of the requesting driver
+ *
+ * This function removes all graphics device drivers. Use this function on systems
+ * that can have their framebuffer located anywhere in memory.
+ *
+ * Returns:
+ * 0 on success, or a negative errno code otherwise
+ */
+static inline int aperture_remove_all_conflicting_devices(bool primary, const char *name)
+{
+	return aperture_remove_conflicting_devices(0, (resource_size_t)-1, primary, name);
+}
+
+#endif
diff --git a/sys/compat/linuxkpi/common/include/linux/bitfield.h b/sys/compat/linuxkpi/common/include/linux/bitfield.h
index a2020d247489..8a91b0663f37 100644
--- a/sys/compat/linuxkpi/common/include/linux/bitfield.h
+++ b/sys/compat/linuxkpi/common/include/linux/bitfield.h
@@ -1,7 +1,7 @@
 /*-
  * SPDX-License-Identifier: BSD-2-Clause
  *
- * Copyright (c) 2020 The FreeBSD Foundation
+ * Copyright (c) 2020-2024 The FreeBSD Foundation
  *
  * This software was developed by Björn Zeeb under sponsorship from
  * the FreeBSD Foundation.
@@ -131,6 +131,10 @@ _uX_replace_bits(8)
 #define	FIELD_PREP(_mask, _value)					\
 	(((typeof(_mask))(_value) << __bf_shf(_mask)) & (_mask))
 
+/* Likely would need extra sanity checks compared to FIELD_PREP()? */
+#define	FIELD_PREP_CONST(_mask, _value)					\
+	(((typeof(_mask))(_value) << __bf_shf(_mask)) & (_mask))
+
 #define	FIELD_GET(_mask, _value)					\
 	((typeof(_mask))(((_value) & (_mask)) >> __bf_shf(_mask)))
 
diff --git a/sys/compat/linuxkpi/common/include/linux/gfp.h b/sys/compat/linuxkpi/common/include/linux/gfp.h
index 2fcc0dc05f29..e5dd2e44b0fa 100644
--- a/sys/compat/linuxkpi/common/include/linux/gfp.h
+++ b/sys/compat/linuxkpi/common/include/linux/gfp.h
@@ -90,15 +90,15 @@ struct page_frag_cache {
  *
  * NOTE: This function only works for pages allocated by the kernel.
  */
-extern void *linux_page_address(struct page *);
+void *linux_page_address(struct page *);
 
 #define	page_address(page) linux_page_address(page)
 
 /*
  * Page management for unmapped pages:
  */
-extern struct page *linux_alloc_pages(gfp_t flags, unsigned int order);
-extern void linux_free_pages(struct page *page, unsigned int order);
+struct page *linux_alloc_pages(gfp_t flags, unsigned int order);
+void linux_free_pages(struct page *page, unsigned int order);
 void *linuxkpi_page_frag_alloc(struct page_frag_cache *, size_t, gfp_t);
 void linuxkpi_page_frag_free(void *);
 void linuxkpi__page_frag_cache_drain(struct page *, size_t);
@@ -147,8 +147,8 @@ dev_alloc_pages(unsigned int order)
 /*
  * Page management for mapped pages:
  */
-extern vm_offset_t linux_alloc_kmem(gfp_t flags, unsigned int order);
-extern void linux_free_kmem(vm_offset_t, unsigned int order);
+vm_offset_t linux_alloc_kmem(gfp_t flags, unsigned int order);
+void linux_free_kmem(vm_offset_t, unsigned int order);
 
 static inline vm_offset_t
 get_zeroed_page(gfp_t flags)
diff --git a/sys/compat/linuxkpi/common/include/linux/ieee80211.h b/sys/compat/linuxkpi/common/include/linux/ieee80211.h
index 2000e7480ff8..aa1a0a4f3c5f 100644
--- a/sys/compat/linuxkpi/common/include/linux/ieee80211.h
+++ b/sys/compat/linuxkpi/common/include/linux/ieee80211.h
@@ -254,20 +254,20 @@ enum ieee80211_ac_numbers {
 #define	IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL	0xf
 
 
-/* XXX net80211 calls these IEEE80211_HTCAP_* */
-#define	IEEE80211_HT_CAP_LDPC_CODING		0x0001	/* IEEE80211_HTCAP_LDPC */
-#define	IEEE80211_HT_CAP_SUP_WIDTH_20_40	0x0002	/* IEEE80211_HTCAP_CHWIDTH40 */
-#define	IEEE80211_HT_CAP_SM_PS			0x000c	/* IEEE80211_HTCAP_SMPS */
+/* Define the LinuxKPI names directly to the net80211 ones. */
+#define	IEEE80211_HT_CAP_LDPC_CODING		IEEE80211_HTCAP_LDPC
+#define	IEEE80211_HT_CAP_SUP_WIDTH_20_40	IEEE80211_HTCAP_CHWIDTH40
+#define	IEEE80211_HT_CAP_SM_PS			IEEE80211_HTCAP_SMPS
 #define	IEEE80211_HT_CAP_SM_PS_SHIFT		2
-#define	IEEE80211_HT_CAP_GRN_FLD		0x0010	/* IEEE80211_HTCAP_GREENFIELD */
-#define	IEEE80211_HT_CAP_SGI_20			0x0020	/* IEEE80211_HTCAP_SHORTGI20 */
-#define	IEEE80211_HT_CAP_SGI_40			0x0040	/* IEEE80211_HTCAP_SHORTGI40 */
-#define	IEEE80211_HT_CAP_TX_STBC		0x0080	/* IEEE80211_HTCAP_TXSTBC */
-#define	IEEE80211_HT_CAP_RX_STBC		0x0100	/* IEEE80211_HTCAP_RXSTBC */
-#define	IEEE80211_HT_CAP_RX_STBC_SHIFT		8	/* IEEE80211_HTCAP_RXSTBC_S */
-#define	IEEE80211_HT_CAP_MAX_AMSDU		0x0800	/* IEEE80211_HTCAP_MAXAMSDU */
-#define	IEEE80211_HT_CAP_DSSSCCK40		0x1000	/* IEEE80211_HTCAP_DSSSCCK40 */
-#define	IEEE80211_HT_CAP_LSIG_TXOP_PROT		0x8000	/* IEEE80211_HTCAP_LSIGTXOPPROT */
+#define	IEEE80211_HT_CAP_GRN_FLD		IEEE80211_HTCAP_GREENFIELD
+#define	IEEE80211_HT_CAP_SGI_20			IEEE80211_HTCAP_SHORTGI20
+#define	IEEE80211_HT_CAP_SGI_40			IEEE80211_HTCAP_SHORTGI40
+#define	IEEE80211_HT_CAP_TX_STBC		IEEE80211_HTCAP_TXSTBC
+#define	IEEE80211_HT_CAP_RX_STBC		IEEE80211_HTCAP_RXSTBC
+#define	IEEE80211_HT_CAP_RX_STBC_SHIFT		IEEE80211_HTCAP_RXSTBC_S
+#define	IEEE80211_HT_CAP_MAX_AMSDU		IEEE80211_HTCAP_MAXAMSDU
+#define	IEEE80211_HT_CAP_DSSSCCK40		IEEE80211_HTCAP_DSSSCCK40
+#define	IEEE80211_HT_CAP_LSIG_TXOP_PROT		IEEE80211_HTCAP_LSIGTXOPPROT
 
 #define	IEEE80211_HT_MCS_TX_DEFINED		0x0001
 #define	IEEE80211_HT_MCS_TX_RX_DIFF		0x0002
diff --git a/sys/compat/linuxkpi/common/include/linux/kref.h b/sys/compat/linuxkpi/common/include/linux/kref.h
index 47d61c9ee316..b2fba468f7df 100644
--- a/sys/compat/linuxkpi/common/include/linux/kref.h
+++ b/sys/compat/linuxkpi/common/include/linux/kref.h
@@ -41,8 +41,7 @@
 #include <asm/atomic.h>
 
 struct kref {
-	/* XXX In Linux this is a refcount_t */
-	atomic_t refcount;
+	refcount_t refcount;
 };
 
 static inline void
diff --git a/sys/compat/linuxkpi/common/include/linux/pm.h b/sys/compat/linuxkpi/common/include/linux/pm.h
index 871c7b587864..c8d943027909 100644
--- a/sys/compat/linuxkpi/common/include/linux/pm.h
+++ b/sys/compat/linuxkpi/common/include/linux/pm.h
@@ -1,7 +1,7 @@
 /*-
  * SPDX-License-Identifier: BSD-2-Clause
  *
- * Copyright (c) 2020 The FreeBSD Foundation
+ * Copyright (c) 2020-2024 The FreeBSD Foundation
  *
  * This software was developed by Björn Zeeb under sponsorship from
  * the FreeBSD Foundation.
@@ -58,25 +58,26 @@ struct dev_pm_info {
     IS_ENABLED(CONFIG_PM_SLEEP) ? (_p) : NULL
 
 #ifdef CONFIG_PM_SLEEP
+#define	__SET_PM_OPS(_suspendfunc, _resumefunc)			\
+	.suspend	= _suspendfunc,				\
+	.resume		= _resumefunc,				\
+	.freeze		= _suspendfunc,				\
+	.thaw		= _resumefunc,				\
+	.poweroff	= _suspendfunc,				\
+	.restore	= _resumefunc,				\
+
 #define	SIMPLE_DEV_PM_OPS(_name, _suspendfunc, _resumefunc)	\
 const struct dev_pm_ops _name = {				\
-	.suspend	= _suspendfunc,		\
-	.resume		= _resumefunc,		\
-	.freeze		= _suspendfunc,		\
-	.thaw		= _resumefunc,		\
-	.poweroff	= _suspendfunc,		\
-	.restore	= _resumefunc,		\
+	__SET_PM_OPS(_suspendfunc, _resumefunc)			\
 }
 
 #define	DEFINE_SIMPLE_DEV_PM_OPS(_name, _suspendfunc, _resumefunc) \
 const struct dev_pm_ops _name = {				\
-	.suspend	= _suspendfunc,		\
-	.resume		= _resumefunc,		\
-	.freeze		= _suspendfunc,		\
-	.thaw		= _resumefunc,		\
-	.poweroff	= _suspendfunc,		\
-	.restore	= _resumefunc,		\
+	__SET_PM_OPS(_suspendfunc, _resumefunc)			\
 }
+
+#define	SET_SYSTEM_SLEEP_PM_OPS(_suspendfunc, _resumefunc)	\
+	__SET_PM_OPS(_suspendfunc, _resumefunc)
 #else
 #define	SIMPLE_DEV_PM_OPS(_name, _suspendfunc, _resumefunc)	\
 const struct dev_pm_ops _name = {				\
@@ -86,6 +87,9 @@ const struct dev_pm_ops _name = {				\
 }
 #endif
 
+bool linuxkpi_device_can_wakeup(struct device *);
+#define	device_can_wakeup(_dev)		linuxkpi_device_can_wakeup(_dev)
+
 static inline void
 pm_wakeup_event(struct device *dev __unused, unsigned int x __unused)
 {
diff --git a/sys/compat/linuxkpi/common/include/linux/refcount.h b/sys/compat/linuxkpi/common/include/linux/refcount.h
index 61947485945d..02a7eda3f4a9 100644
--- a/sys/compat/linuxkpi/common/include/linux/refcount.h
+++ b/sys/compat/linuxkpi/common/include/linux/refcount.h
@@ -31,58 +31,51 @@
 
 #include <linux/atomic.h>
 
-struct refcount_linux {
-	atomic_t value;
-};
-typedef struct refcount_linux refcount_t;
+typedef atomic_t refcount_t;
 
 static inline void
 refcount_set(refcount_t *ref, unsigned int i)
 {
-	atomic_set(&ref->value, i);
+	atomic_set(ref, i);
 }
 
 static inline void
 refcount_inc(refcount_t *ref)
 {
-	atomic_inc(&ref->value);
+	atomic_inc(ref);
 }
 
 static inline bool
 refcount_inc_not_zero(refcount_t *ref)
 {
-	return (atomic_inc_not_zero(&ref->value));
+	return (atomic_inc_not_zero(ref));
 }
 
 static inline void
 refcount_dec(refcount_t *ref)
 {
-	atomic_dec(&ref->value);
+	atomic_dec(ref);
 }
 
 static inline unsigned int
 refcount_read(refcount_t *ref)
 {
-	return atomic_read(&ref->value);
+	return atomic_read(ref);
 }
 
 static inline bool
 refcount_dec_and_lock_irqsave(refcount_t *ref, spinlock_t *lock,
     unsigned long *flags)
 {
-	if (atomic_dec_and_test(&ref->value) == true) {
+	if (atomic_dec_and_test(ref) == true) {
 		spin_lock_irqsave(lock, flags);
 		return (true);
 	}
 	return (false);
 }
 
-/*
- * struct kref uses atomic_t and not refcount_t so
- * we differ from Linux here.
- */
 static inline bool
-refcount_dec_and_test(atomic_t *r)
+refcount_dec_and_test(refcount_t *r)
 {
 
 	return (atomic_dec_and_test(r));
diff --git a/sys/compat/linuxkpi/common/include/linux/rwlock.h b/sys/compat/linuxkpi/common/include/linux/rwlock.h
index 8c1ee36ac4de..3030ec89ff1e 100644
--- a/sys/compat/linuxkpi/common/include/linux/rwlock.h
+++ b/sys/compat/linuxkpi/common/include/linux/rwlock.h
@@ -34,14 +34,12 @@
 #include <sys/rwlock.h>
 #include <sys/libkern.h>
 
-typedef struct {
-	struct rwlock rw;
-} rwlock_t;
+typedef struct rwlock rwlock_t;
 
-#define	read_lock(_l)		rw_rlock(&(_l)->rw)
-#define	write_lock(_l)		rw_wlock(&(_l)->rw)
-#define	read_unlock(_l)		rw_runlock(&(_l)->rw)
-#define	write_unlock(_l)	rw_wunlock(&(_l)->rw)
+#define	read_lock(_l)		rw_rlock(_l)
+#define	write_lock(_l)		rw_wlock(_l)
+#define	read_unlock(_l)		rw_runlock(_l)
+#define	write_unlock(_l)	rw_wunlock(_l)
 #define	read_lock_irq(lock)	read_lock((lock))
 #define	read_unlock_irq(lock)	read_unlock((lock))
 #define	write_lock_irq(lock)	write_lock((lock))
@@ -54,13 +52,6 @@ typedef struct {
     do { read_unlock(lock); } while (0)
 #define	write_unlock_irqrestore(lock, flags)				\
     do { write_unlock(lock); } while (0)
-
-static inline void
-rwlock_init(rwlock_t *lock)
-{
-
-	memset(&lock->rw, 0, sizeof(lock->rw));
-	rw_init_flags(&lock->rw, "lnxrw", RW_NOWITNESS);
-}
+#define	rwlock_init(_l)	rw_init_flags(_l, "lnxrw", RW_NOWITNESS | RW_NEW)
 
 #endif	/* _LINUXKPI_LINUX_RWLOCK_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/spinlock.h b/sys/compat/linuxkpi/common/include/linux/spinlock.h
index 4bc1e2a2d431..2992e41c9c02 100644
--- a/sys/compat/linuxkpi/common/include/linux/spinlock.h
+++ b/sys/compat/linuxkpi/common/include/linux/spinlock.h
@@ -41,9 +41,7 @@
 #include <linux/bottom_half.h>
 #include <linux/lockdep.h>
 
-typedef struct {
-	struct mtx m;
-} spinlock_t;
+typedef struct mtx spinlock_t;
 
 /*
  * By defining CONFIG_SPIN_SKIP LinuxKPI spinlocks and asserts will be
@@ -59,7 +57,7 @@ typedef struct {
 #define	spin_lock(_l) do {			\
 	if (SPIN_SKIP())			\
 		break;				\
-	mtx_lock(&(_l)->m);			\
+	mtx_lock(_l);				\
 	local_bh_disable();			\
 } while (0)
 
@@ -76,7 +74,7 @@ typedef struct {
 	if (SPIN_SKIP())			\
 		break;				\
 	local_bh_enable();			\
-	mtx_unlock(&(_l)->m);			\
+	mtx_unlock(_l);				\
 } while (0)
 
 #define	spin_unlock_bh(_l) do {			\
@@ -93,7 +91,7 @@ typedef struct {
 	if (SPIN_SKIP()) {			\
 		__ret = 1;			\
 	} else {				\
-		__ret = mtx_trylock(&(_l)->m);	\
+		__ret = mtx_trylock(_l);	\
 		if (likely(__ret != 0))		\
 			local_bh_disable();	\
 	}					\
@@ -111,7 +109,7 @@ typedef struct {
 #define	spin_lock_nested(_l, _n) do {		\
 	if (SPIN_SKIP())			\
 		break;				\
-	mtx_lock_flags(&(_l)->m, MTX_DUPOK);	\
+	mtx_lock_flags(_l, MTX_DUPOK);		\
 	local_bh_disable();			\
 } while (0)
 
@@ -141,31 +139,19 @@ typedef struct {
 #define	_spin_lock_name(...)		__spin_lock_name(__VA_ARGS__)
 #define	spin_lock_name(name)		_spin_lock_name(name, __FILE__, __LINE__)
 
-#define	spin_lock_init(lock)	linux_spin_lock_init(lock, spin_lock_name("lnxspin"))
+#define	spin_lock_init(lock)	mtx_init(lock, spin_lock_name("lnxspin"), \
+				  NULL, MTX_DEF | MTX_NOWITNESS | MTX_NEW)
 
-static inline void
-linux_spin_lock_init(spinlock_t *lock, const char *name)
-{
-
-	memset(lock, 0, sizeof(*lock));
-	mtx_init(&lock->m, name, NULL, MTX_DEF | MTX_NOWITNESS);
-}
-
-static inline void
-spin_lock_destroy(spinlock_t *lock)
-{
-
-       mtx_destroy(&lock->m);
-}
+#define	spin_lock_destroy(_l)	mtx_destroy(_l)
 
 #define	DEFINE_SPINLOCK(lock)					\
 	spinlock_t lock;					\
-	MTX_SYSINIT(lock, &(lock).m, spin_lock_name("lnxspin"), MTX_DEF)
+	MTX_SYSINIT(lock, &lock, spin_lock_name("lnxspin"), MTX_DEF)
 
 #define	assert_spin_locked(_l) do {		\
 	if (SPIN_SKIP())			\
 		break;				\
-	mtx_assert(&(_l)->m, MA_OWNED);		\
+	mtx_assert(_l, MA_OWNED);		\
 } while (0)
 
 #define	atomic_dec_and_lock_irqsave(cnt, lock, flags) \
diff --git a/sys/compat/linuxkpi/common/include/linux/string.h b/sys/compat/linuxkpi/common/include/linux/string.h
index 06dcdbd97663..9302c95e8636 100644
--- a/sys/compat/linuxkpi/common/include/linux/string.h
+++ b/sys/compat/linuxkpi/common/include/linux/string.h
@@ -97,6 +97,18 @@ kmemdup(const void *src, size_t len, gfp_t gfp)
 	return (dst);
 }
 
+/* See slab.h for kvmalloc/kvfree(). */
+static inline void *
+kvmemdup(const void *src, size_t len, gfp_t gfp)
+{
+	void *dst;
+
+	dst = kvmalloc(len, gfp);
+	if (dst != NULL)
+		memcpy(dst, src, len);
+	return (dst);
+}
+
 static inline char *
 strndup_user(const char __user *ustr, long n)
 {
diff --git a/sys/compat/linuxkpi/common/include/linux/wait.h b/sys/compat/linuxkpi/common/include/linux/wait.h
index d50003d44955..b815050b6faa 100644
--- a/sys/compat/linuxkpi/common/include/linux/wait.h
+++ b/sys/compat/linuxkpi/common/include/linux/wait.h
@@ -113,7 +113,7 @@ extern wait_queue_func_t default_wake_function;
 	MTX_SYSINIT(name, &(name).lock.m, spin_lock_name("wqhead"), MTX_DEF)
 
 #define	init_waitqueue_head(wqh) do {					\
-	mtx_init(&(wqh)->lock.m, spin_lock_name("wqhead"),		\
+	mtx_init(&(wqh)->lock, spin_lock_name("wqhead"),		\
 	    NULL, MTX_DEF | MTX_NEW | MTX_NOWITNESS);			\
 	INIT_LIST_HEAD(&(wqh)->task_list);				\
 } while (0)
diff --git a/sys/compat/linuxkpi/common/include/net/mac80211.h b/sys/compat/linuxkpi/common/include/net/mac80211.h
index fc9d7829dae3..6a477ae5c32a 100644
--- a/sys/compat/linuxkpi/common/include/net/mac80211.h
+++ b/sys/compat/linuxkpi/common/include/net/mac80211.h
@@ -1253,7 +1253,7 @@ ieee80211_hw_restart_disconnect(struct ieee80211_vif *vif)
 	    (_link = rcu_dereference((_vif)->link_conf[_linkid])) )
 
 #define	for_each_sta_active_link(_vif, _sta, _linksta, _linkid)		\
-    for (_linkid = 0; _linkid < nitems((_vif)->link_conf); _linkid++)	\
+    for (_linkid = 0; _linkid < nitems((_sta)->link); _linkid++)	\
 	if ( ((_vif)->active_links == 0 /* no MLO */ ||			\
 	    ((_vif)->active_links & BIT(_linkid)) != 0) &&		\
 	    (_linksta = link_sta_dereference_protected((_sta), (_linkid))) )
diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c
index 758db287d613..ca8db481347e 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -146,6 +146,7 @@ const struct cfg80211_ops linuxkpi_mac80211cfgops = {
 static struct lkpi_sta *lkpi_find_lsta_by_ni(struct lkpi_vif *,
     struct ieee80211_node *);
 #endif
+static void lkpi_80211_txq_tx_one(struct lkpi_sta *, struct mbuf *);
 static void lkpi_80211_txq_task(void *, int);
 static void lkpi_80211_lhw_rxq_task(void *, int);
 static void lkpi_ieee80211_free_skb_mbuf(void *);
@@ -994,33 +995,37 @@ lkpi_hw_conf_idle(struct ieee80211_hw *hw, bool new)
 	}
 }
 
-static void
+static enum ieee80211_bss_changed
 lkpi_disassoc(struct ieee80211_sta *sta, struct ieee80211_vif *vif,
     struct lkpi_hw *lhw)
 {
+	enum ieee80211_bss_changed changed;
+
+	changed = 0;
 	sta->aid = 0;
 	if (vif->cfg.assoc) {
-		struct ieee80211_hw *hw;
-		enum ieee80211_bss_changed changed;
 
 		lhw->update_mc = true;
 		lkpi_update_mcast_filter(lhw->ic, true);
 
-		changed = 0;
 		vif->cfg.assoc = false;
 		vif->cfg.aid = 0;
 		changed |= BSS_CHANGED_ASSOC;
-		/*
-		 * This will remove the sta from firmware for iwlwifi.
-		 * So confusing that they use state and flags and ... ^%$%#%$^.
-		 */
 		IMPROVE();
-		hw = LHW_TO_HW(lhw);
-		lkpi_80211_mo_bss_info_changed(hw, vif, &vif->bss_conf,
-		    changed);
 
-		lkpi_hw_conf_idle(hw, true);
+		/*
+		 * Executing the bss_info_changed(BSS_CHANGED_ASSOC) with
+		 * assoc = false right away here will remove the sta from
+		 * firmware for iwlwifi.
+		 * We no longer do this but only return the BSS_CHNAGED value.
+		 * The caller is responsible for removing the sta gong to
+		 * IEEE80211_STA_NOTEXIST and then executing the
+		 * bss_info_changed() update.
+		 * See lkpi_sta_run_to_init() for more detailed comment.
+		 */
 	}
+
+	return (changed);
 }
 
 static void
@@ -1058,6 +1063,51 @@ lkpi_wake_tx_queues(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
 	}
 }
 
+/*
+ * On the way down from RUN -> ASSOC -> AUTH we may send a DISASSOC or DEAUTH
+ * packet.  The problem is that the state machine functions tend to hold the
+ * LHW lock which will prevent lkpi_80211_txq_tx_one() from sending the packet.
+ * We call this after dropping the ic lock and before acquiring the LHW lock.
+ * we make sure no further packets are queued and if they are queued the task
+ * will finish or be cancelled.  At the end if a packet is left we manually
+ * send it.  scan_to_auth() would re-enable sending if the lsta would be
+ * re-used.
+ */
+static void
+lkpi_80211_flush_tx(struct lkpi_hw *lhw, struct lkpi_sta *lsta)
+{
+	struct mbufq mq;
+	struct mbuf *m;
+	int len;
+
+	LKPI_80211_LHW_UNLOCK_ASSERT(lhw);
+
+	/* Do not accept any new packets until scan_to_auth or lsta_free(). */
+	LKPI_80211_LSTA_TXQ_LOCK(lsta);
+	lsta->txq_ready = false;
+	LKPI_80211_LSTA_TXQ_UNLOCK(lsta);
+
+	while (taskqueue_cancel(taskqueue_thread, &lsta->txq_task, NULL) != 0)
+		taskqueue_drain(taskqueue_thread, &lsta->txq_task);
+
+	LKPI_80211_LSTA_TXQ_LOCK(lsta);
+	len = mbufq_len(&lsta->txq);
+	if (len <= 0) {
+		LKPI_80211_LSTA_TXQ_UNLOCK(lsta);
+		return;
+	}
+
+	mbufq_init(&mq, IFQ_MAXLEN);
+	mbufq_concat(&mq, &lsta->txq);
+	LKPI_80211_LSTA_TXQ_UNLOCK(lsta);
+
+	m = mbufq_dequeue(&mq);
+	while (m != NULL) {
+		lkpi_80211_txq_tx_one(lsta, m);
+		m = mbufq_dequeue(&mq);
+	}
+}
+
 /* -------------------------------------------------------------------------- */
 
 static int
@@ -1075,7 +1125,7 @@ lkpi_sta_scan_to_auth(struct ieee80211vap *vap, enum ieee80211_state nstate, int
 {
 	struct linuxkpi_ieee80211_channel *chan;
 	struct lkpi_chanctx *lchanctx;
-	struct ieee80211_chanctx_conf *conf;
+	struct ieee80211_chanctx_conf *chanctx_conf;
 	struct lkpi_hw *lhw;
 	struct ieee80211_hw *hw;
 	struct lkpi_vif *lvif;
@@ -1141,54 +1191,54 @@ lkpi_sta_scan_to_auth(struct ieee80211vap *vap, enum ieee80211_state nstate, int
 
 	/* Add chanctx (or if exists, change it). */
 	if (vif->chanctx_conf != NULL) {
-		conf = vif->chanctx_conf;
-		lchanctx = CHANCTX_CONF_TO_LCHANCTX(conf);
+		chanctx_conf = vif->chanctx_conf;
+		lchanctx = CHANCTX_CONF_TO_LCHANCTX(chanctx_conf);
 		IMPROVE("diff changes for changed, working on live copy, rcu");
 	} else {
 		/* Keep separate alloc as in Linux this is rcu managed? */
 		lchanctx = malloc(sizeof(*lchanctx) + hw->chanctx_data_size,
 		    M_LKPI80211, M_WAITOK | M_ZERO);
-		conf = &lchanctx->conf;
+		chanctx_conf = &lchanctx->chanctx_conf;
 	}
 
-	conf->rx_chains_dynamic = 1;
-	conf->rx_chains_static = 1;
-	conf->radar_enabled =
+	chanctx_conf->rx_chains_dynamic = 1;
+	chanctx_conf->rx_chains_static = 1;
+	chanctx_conf->radar_enabled =
 	    (chan->flags & IEEE80211_CHAN_RADAR) ? true : false;
-	conf->def.chan = chan;
-	conf->def.width = NL80211_CHAN_WIDTH_20_NOHT;
-	conf->def.center_freq1 = chan->center_freq;
-	conf->def.center_freq2 = 0;
+	chanctx_conf->def.chan = chan;
+	chanctx_conf->def.width = NL80211_CHAN_WIDTH_20_NOHT;
+	chanctx_conf->def.center_freq1 = chan->center_freq;
+	chanctx_conf->def.center_freq2 = 0;
 	IMPROVE("Check vht_cap from band not just chan?");
 	KASSERT(ni->ni_chan != NULL && ni->ni_chan != IEEE80211_CHAN_ANYC,
 	   ("%s:%d: ni %p ni_chan %p\n", __func__, __LINE__, ni, ni->ni_chan));
 #ifdef LKPI_80211_HT
 	if (IEEE80211_IS_CHAN_HT(ni->ni_chan)) {
 		if (IEEE80211_IS_CHAN_HT40(ni->ni_chan)) {
-			conf->def.width = NL80211_CHAN_WIDTH_40;
+			chanctx_conf->def.width = NL80211_CHAN_WIDTH_40;
 		} else
-			conf->def.width = NL80211_CHAN_WIDTH_20;
+			chanctx_conf->def.width = NL80211_CHAN_WIDTH_20;
 	}
 #endif
 #ifdef LKPI_80211_VHT
 	if (IEEE80211_IS_CHAN_VHT(ni->ni_chan)) {
 #ifdef __notyet__
 		if (IEEE80211_IS_CHAN_VHT80P80(ni->ni_chan)) {
-			conf->def.width = NL80211_CHAN_WIDTH_80P80;
-			conf->def.center_freq2 = 0;	/* XXX */
+			chanctx_conf->def.width = NL80211_CHAN_WIDTH_80P80;
+			chanctx_conf->def.center_freq2 = 0;	/* XXX */
 		} else
 #endif
 		if (IEEE80211_IS_CHAN_VHT160(ni->ni_chan))
-			conf->def.width = NL80211_CHAN_WIDTH_160;
+			chanctx_conf->def.width = NL80211_CHAN_WIDTH_160;
 		else if (IEEE80211_IS_CHAN_VHT80(ni->ni_chan))
-			conf->def.width = NL80211_CHAN_WIDTH_80;
+			chanctx_conf->def.width = NL80211_CHAN_WIDTH_80;
 	}
 #endif
 	/* Responder ... */
-	conf->min_def.chan = chan;
-	conf->min_def.width = NL80211_CHAN_WIDTH_20_NOHT;
-	conf->min_def.center_freq1 = chan->center_freq;
-	conf->min_def.center_freq2 = 0;
+	chanctx_conf->min_def.chan = chan;
+	chanctx_conf->min_def.width = NL80211_CHAN_WIDTH_20_NOHT;
+	chanctx_conf->min_def.center_freq1 = chan->center_freq;
+	chanctx_conf->min_def.center_freq2 = 0;
 	IMPROVE("currently 20_NOHT min_def only");
 
 	/* Set bss info (bss_info_changed). */
@@ -1214,14 +1264,14 @@ lkpi_sta_scan_to_auth(struct ieee80211vap *vap, enum ieee80211_state nstate, int
 		changed |= IEEE80211_CHANCTX_CHANGE_RADAR;
 		changed |= IEEE80211_CHANCTX_CHANGE_RX_CHAINS;
 		changed |= IEEE80211_CHANCTX_CHANGE_WIDTH;
-		lkpi_80211_mo_change_chanctx(hw, conf, changed);
+		lkpi_80211_mo_change_chanctx(hw, chanctx_conf, changed);
 	} else {
-		error = lkpi_80211_mo_add_chanctx(hw, conf);
+		error = lkpi_80211_mo_add_chanctx(hw, chanctx_conf);
 		if (error == 0 || error == EOPNOTSUPP) {
-			vif->bss_conf.chandef.chan = conf->def.chan;
-			vif->bss_conf.chandef.width = conf->def.width;
+			vif->bss_conf.chandef.chan = chanctx_conf->def.chan;
+			vif->bss_conf.chandef.width = chanctx_conf->def.width;
 			vif->bss_conf.chandef.center_freq1 =
-			    conf->def.center_freq1;
+			    chanctx_conf->def.center_freq1;
 #ifdef LKPI_80211_HT
 			if (vif->bss_conf.chandef.width == NL80211_CHAN_WIDTH_40) {
 				/* Note: it is 10 not 20. */
@@ -1232,26 +1282,26 @@ lkpi_sta_scan_to_auth(struct ieee80211vap *vap, enum ieee80211_state nstate, int
 			}
 #endif
 			vif->bss_conf.chandef.center_freq2 =
-			    conf->def.center_freq2;
+			    chanctx_conf->def.center_freq2;
 		} else {
 			ic_printf(vap->iv_ic, "%s:%d: mo_add_chanctx "
 			    "failed: %d\n", __func__, __LINE__, error);
 			goto out;
 		}
 
-		vif->bss_conf.chanctx_conf = conf;
+		vif->bss_conf.chanctx_conf = chanctx_conf;
 
 		/* Assign vif chanctx. */
 		if (error == 0)
 			error = lkpi_80211_mo_assign_vif_chanctx(hw, vif,
-			    &vif->bss_conf, conf);
+			    &vif->bss_conf, chanctx_conf);
 		if (error == EOPNOTSUPP)
 			error = 0;
 		if (error != 0) {
 			ic_printf(vap->iv_ic, "%s:%d: mo_assign_vif_chanctx "
 			    "failed: %d\n", __func__, __LINE__, error);
-			lkpi_80211_mo_remove_chanctx(hw, conf);
-			lchanctx = CHANCTX_CONF_TO_LCHANCTX(conf);
+			lkpi_80211_mo_remove_chanctx(hw, chanctx_conf);
+			lchanctx = CHANCTX_CONF_TO_LCHANCTX(chanctx_conf);
 			free(lchanctx, M_LKPI80211);
 			goto out;
 		}
@@ -1271,26 +1321,15 @@ lkpi_sta_scan_to_auth(struct ieee80211vap *vap, enum ieee80211_state nstate, int
 	    __func__, ni, ni->ni_drv_data));
 	lsta = ni->ni_drv_data;
 
-	LKPI_80211_LVIF_LOCK(lvif);
-	/* Re-check given (*iv_update_bss) could have happened. */
-	/* XXX-BZ KASSERT later? or deal as error? */
-	if (lvif->lvif_bss_synched || lvif->lvif_bss != NULL)
-		ic_printf(vap->iv_ic, "%s:%d: lvif %p vap %p iv_bss %p lvif_bss %p "
-		    "lvif_bss->ni %p synched %d, ni %p lsta %p\n", __func__, __LINE__,
-		    lvif, vap, vap->iv_bss, lvif->lvif_bss,
-		    (lvif->lvif_bss != NULL) ? lvif->lvif_bss->ni : NULL,
-		    lvif->lvif_bss_synched, ni, lsta);
-
 	/*
-	 * Reference the ni for this cache of lsta/ni on lvif->lvif_bss
-	 * essentially out lsta version of the iv_bss.
-	 * Do NOT use iv_bss here anymore as that may have diverged from our
-	 * function local ni already and would lead to inconsistencies.
+	 * Make sure in case the sta did not change and we re-add it,
+	 * that we can tx again.
 	 */
-	ieee80211_ref_node(ni);
-	lvif->lvif_bss = lsta;
-	lvif->lvif_bss_synched = true;
+	LKPI_80211_LSTA_TXQ_LOCK(lsta);
+	lsta->txq_ready = true;
+	LKPI_80211_LSTA_TXQ_UNLOCK(lsta);
 
+	LKPI_80211_LVIF_LOCK(lvif);
 	/* Insert the [l]sta into the list of known stations. */
 	TAILQ_INSERT_TAIL(&lvif->lsta_head, lsta, lsta_entry);
 	LKPI_80211_LVIF_UNLOCK(lvif);
@@ -1339,11 +1378,56 @@ lkpi_sta_scan_to_auth(struct ieee80211vap *vap, enum ieee80211_state nstate, int
 	 * (ideally we'd do that on a callback for something else ...)
 	 */
 
+	LKPI_80211_LHW_UNLOCK(lhw);
+	IEEE80211_LOCK(vap->iv_ic);
+
+	LKPI_80211_LVIF_LOCK(lvif);
+	/* Re-check given (*iv_update_bss) could have happened while we were unlocked. */
+	if (lvif->lvif_bss_synched || lvif->lvif_bss != NULL ||
+	    lsta->ni != vap->iv_bss)
+		ic_printf(vap->iv_ic, "%s:%d: lvif %p vap %p iv_bss %p lvif_bss %p "
+		    "lvif_bss->ni %p synched %d, ni %p lsta %p\n", __func__, __LINE__,
+		    lvif, vap, vap->iv_bss, lvif->lvif_bss,
+		    (lvif->lvif_bss != NULL) ? lvif->lvif_bss->ni : NULL,
+		    lvif->lvif_bss_synched, ni, lsta);
+
+	/*
+	 * Reference the "ni" for caching the lsta/ni in lvif->lvif_bss.
+	 * Given we cache lsta we use lsta->ni instead of ni here (even though
+	 * lsta->ni == ni) to be distinct from the rest of the code where we do
+	 * assume that ni == vap->iv_bss which it may or may not be.
+	 * So do NOT use iv_bss here anymore as that may have diverged from our
+	 * function local ni already while ic was unlocked and would lead to
+	 * inconsistencies.  Go and see if we lost a race and do not update
+	 * lvif_bss_synched in that case.
+	 */
+	ieee80211_ref_node(lsta->ni);
+	lvif->lvif_bss = lsta;
+	if (lsta->ni == vap->iv_bss) {
+		lvif->lvif_bss_synched = true;
+	} else {
+		/* Set to un-synched no matter what. */
+		lvif->lvif_bss_synched = false;
+		/*
+		 * We do not error as someone has to take us down.
+		 * If we are followed by a 2nd, new net80211::join1() going to
+		 * AUTH lkpi_sta_a_to_a() will error, lkpi_sta_auth_to_{scan,init}()
+		 * will take the lvif->lvif_bss node down eventually.
+		 * What happens with the vap->iv_bss node will entirely be up
+		 * to net80211 as we never used the node beyond alloc()/free()
+		 * and we do not hold an extra reference for that anymore given
+		 * ni : lsta == 1:1.
+		 */
+	}
+	LKPI_80211_LVIF_UNLOCK(lvif);
+	goto out_relocked;
+
 out:
 	LKPI_80211_LHW_UNLOCK(lhw);
 	IEEE80211_LOCK(vap->iv_ic);
+out_relocked:
 	/*
-	 * Release the reference that keop the ni stable locally
+	 * Release the reference that kept the ni stable locally
 	 * during the work of this function.
 	 */
 	if (ni != NULL)
@@ -1397,7 +1481,7 @@ lkpi_sta_auth_to_scan(struct ieee80211vap *vap, enum ieee80211_state nstate, int
 	lkpi_80211_mo_flush(hw, vif,  nitems(sta->txq), true);
 
 	/* Wake tx queues to get packet(s) out. */
-	lkpi_wake_tx_queues(hw, sta, true, true);
+	lkpi_wake_tx_queues(hw, sta, false, true);
 
 	/* flush, no drop */
 	lkpi_80211_mo_flush(hw, vif,  nitems(sta->txq), false);
@@ -1453,16 +1537,18 @@ lkpi_sta_auth_to_scan(struct ieee80211vap *vap, enum ieee80211_state nstate, int
 	/* Take the chan ctx down. */
 	if (vif->chanctx_conf != NULL) {
 		struct lkpi_chanctx *lchanctx;
-		struct ieee80211_chanctx_conf *conf;
+		struct ieee80211_chanctx_conf *chanctx_conf;
 
-		conf = vif->chanctx_conf;
+		chanctx_conf = vif->chanctx_conf;
 		/* Remove vif context. */
 		lkpi_80211_mo_unassign_vif_chanctx(hw, vif, &vif->bss_conf, &vif->chanctx_conf);
 		/* NB: vif->chanctx_conf is NULL now. */
 
+		lkpi_hw_conf_idle(hw, true);
+
 		/* Remove chan ctx. */
-		lkpi_80211_mo_remove_chanctx(hw, conf);
-		lchanctx = CHANCTX_CONF_TO_LCHANCTX(conf);
+		lkpi_80211_mo_remove_chanctx(hw, chanctx_conf);
+		lchanctx = CHANCTX_CONF_TO_LCHANCTX(chanctx_conf);
 		free(lchanctx, M_LKPI80211);
 	}
 
@@ -1553,7 +1639,7 @@ lkpi_sta_auth_to_assoc(struct ieee80211vap *vap, enum ieee80211_state nstate, in
 	}
 
 	/* Wake tx queue to get packet out. */
-	lkpi_wake_tx_queues(hw, LSTA_TO_STA(lsta), true, true);
+	lkpi_wake_tx_queues(hw, LSTA_TO_STA(lsta), false, true);
 
 	/*
 	 * <twiddle> .. we end up in "assoc_to_run"
@@ -1697,7 +1783,7 @@ _lkpi_sta_assoc_to_down(struct ieee80211vap *vap, enum ieee80211_state nstate, i
 	LKPI_80211_LHW_UNLOCK(lhw);
 	IEEE80211_LOCK(vap->iv_ic);
 
-	/* Call iv_newstate first so we get potential DISASSOC packet out. */
+	/* Call iv_newstate first so we get potential DEAUTH packet out. */
 	error = lvif->iv_newstate(vap, nstate, arg);
 	if (error != 0) {
 		ic_printf(vap->iv_ic, "%s:%d: iv_newstate(%p, %d, %d) "
@@ -1706,12 +1792,16 @@ _lkpi_sta_assoc_to_down(struct ieee80211vap *vap, enum ieee80211_state nstate, i
 	}
 
 	IEEE80211_UNLOCK(vap->iv_ic);
+
+	/* Ensure the packets get out. */
+	lkpi_80211_flush_tx(lhw, lsta);
+
 	LKPI_80211_LHW_LOCK(lhw);
 
 	lkpi_lsta_dump(lsta, ni, __func__, __LINE__);
 
 	/* Wake tx queues to get packet(s) out. */
-	lkpi_wake_tx_queues(hw, sta, true, true);
+	lkpi_wake_tx_queues(hw, sta, false, true);
 
 	/* flush, no drop */
 	lkpi_80211_mo_flush(hw, vif,  nitems(sta->txq), false);
@@ -1743,16 +1833,11 @@ _lkpi_sta_assoc_to_down(struct ieee80211vap *vap, enum ieee80211_state nstate, i
 		goto out;
 	}
 
-	lkpi_lsta_dump(lsta, ni, __func__, __LINE__);
+	/* See comment in lkpi_sta_run_to_init(). */
+	bss_changed = 0;
+	bss_changed |= lkpi_disassoc(sta, vif, lhw);
 
-	/* Update bss info (bss_info_changed) (assoc, aid, ..). */
-	/*
-	 * We need to do this now, before sta changes to IEEE80211_STA_NOTEXIST
-	 * as otherwise drivers (iwlwifi at least) will silently not remove
-	 * the sta from the firmware and when we will add a new one trigger
-	 * a fw assert.
-	 */
-	lkpi_disassoc(sta, vif, lhw);
+	lkpi_lsta_dump(lsta, ni, __func__, __LINE__);
 
 	/* Adjust sta and change state (from NONE) to NOTEXIST. */
 	KASSERT(lsta != NULL, ("%s: ni %p lsta is NULL\n", __func__, ni));
@@ -1769,7 +1854,6 @@ _lkpi_sta_assoc_to_down(struct ieee80211vap *vap, enum ieee80211_state nstate, i
 	lkpi_lsta_dump(lsta, ni, __func__, __LINE__);	/* sta no longer save to use. */
 
 	IMPROVE("Any bss_info changes to announce?");
-	bss_changed = 0;
 	vif->bss_conf.qos = 0;
 	bss_changed |= BSS_CHANGED_QOS;
 	vif->cfg.ssid_len = 0;
@@ -1795,16 +1879,18 @@ _lkpi_sta_assoc_to_down(struct ieee80211vap *vap, enum ieee80211_state nstate, i
 	/* Take the chan ctx down. */
 	if (vif->chanctx_conf != NULL) {
 		struct lkpi_chanctx *lchanctx;
-		struct ieee80211_chanctx_conf *conf;
+		struct ieee80211_chanctx_conf *chanctx_conf;
 
-		conf = vif->chanctx_conf;
+		chanctx_conf = vif->chanctx_conf;
 		/* Remove vif context. */
 		lkpi_80211_mo_unassign_vif_chanctx(hw, vif, &vif->bss_conf, &vif->chanctx_conf);
 		/* NB: vif->chanctx_conf is NULL now. */
 
+		lkpi_hw_conf_idle(hw, true);
+
 		/* Remove chan ctx. */
-		lkpi_80211_mo_remove_chanctx(hw, conf);
-		lchanctx = CHANCTX_CONF_TO_LCHANCTX(conf);
+		lkpi_80211_mo_remove_chanctx(hw, chanctx_conf);
+		lchanctx = CHANCTX_CONF_TO_LCHANCTX(chanctx_conf);
 		free(lchanctx, M_LKPI80211);
 	}
 
@@ -2093,12 +2179,16 @@ lkpi_sta_run_to_assoc(struct ieee80211vap *vap, enum ieee80211_state nstate, int
 	}
 
 	IEEE80211_UNLOCK(vap->iv_ic);
+
+	/* Ensure the packets get out. */
+	lkpi_80211_flush_tx(lhw, lsta);
+
 	LKPI_80211_LHW_LOCK(lhw);
 
 	lkpi_lsta_dump(lsta, ni, __func__, __LINE__);
 
 	/* Wake tx queues to get packet(s) out. */
-	lkpi_wake_tx_queues(hw, sta, true, true);
+	lkpi_wake_tx_queues(hw, sta, false, true);
 
 	/* flush, no drop */
 	lkpi_80211_mo_flush(hw, vif,  nitems(sta->txq), false);
@@ -2227,12 +2317,16 @@ lkpi_sta_run_to_init(struct ieee80211vap *vap, enum ieee80211_state nstate, int
 	}
 
 	IEEE80211_UNLOCK(vap->iv_ic);
+
+	/* Ensure the packets get out. */
+	lkpi_80211_flush_tx(lhw, lsta);
+
 	LKPI_80211_LHW_LOCK(lhw);
 
 	lkpi_lsta_dump(lsta, ni, __func__, __LINE__);
 
 	/* Wake tx queues to get packet(s) out. */
-	lkpi_wake_tx_queues(hw, sta, true, true);
+	lkpi_wake_tx_queues(hw, sta, false, true);
 
 	/* flush, no drop */
 	lkpi_80211_mo_flush(hw, vif,  nitems(sta->txq), false);
@@ -2290,14 +2384,33 @@ lkpi_sta_run_to_init(struct ieee80211vap *vap, enum ieee80211_state nstate, int
 		goto out;
 	}
 
-	lkpi_lsta_dump(lsta, ni, __func__, __LINE__);
-
-	/* Update bss info (bss_info_changed) (assoc, aid, ..). */
+	bss_changed = 0;
 	/*
+	 * Start updating bss info (bss_info_changed) (assoc, aid, ..).
+	 *
 	 * One would expect this to happen when going off AUTHORIZED.
-	 * See comment there; removes the sta from fw.
+	 * See comment there; removes the sta from fw if not careful
+	 * (bss_info_changed() change is executed right away).
+	 *
+	 * We need to do this now, before sta changes to IEEE80211_STA_NOTEXIST
+	 * as otherwise drivers (iwlwifi at least) will silently not remove
+	 * the sta from the firmware and when we will add a new one trigger
+	 * a fw assert.
+	 *
+	 * The order which works best so far avoiding early removal or silent
+	 * non-removal seems to be (for iwlwifi::mld-mac80211.c cases;
+	 * the iwlwifi:mac80211.c case still to be tested):
+	 * 1) lkpi_disassoc(): set vif->cfg.assoc = false (aid=0 side effect here)
+	 * 2) call the last sta_state update -> IEEE80211_STA_NOTEXIST
+	 *    (removes the sta given assoc is false)
+	 * 3) add the remaining BSS_CHANGED changes and call bss_info_changed()
+	 * 4) call unassign_vif_chanctx
+	 * 5) call lkpi_hw_conf_idle
+	 * 6) call remove_chanctx
 	 */
-	lkpi_disassoc(sta, vif, lhw);
+	bss_changed |= lkpi_disassoc(sta, vif, lhw);
+
+	lkpi_lsta_dump(lsta, ni, __func__, __LINE__);
 
 	/* Adjust sta and change state (from NONE) to NOTEXIST. */
 	KASSERT(lsta != NULL, ("%s: ni %p lsta is NULL\n", __func__, ni));
@@ -2311,15 +2424,19 @@ lkpi_sta_run_to_init(struct ieee80211vap *vap, enum ieee80211_state nstate, int
 		goto out;
 	}
 
+	lkpi_lsta_remove(lsta, lvif);
+
 	lkpi_lsta_dump(lsta, ni, __func__, __LINE__);	/* sta no longer save to use. */
 
 	IMPROVE("Any bss_info changes to announce?");
-	bss_changed = 0;
 	vif->bss_conf.qos = 0;
 	bss_changed |= BSS_CHANGED_QOS;
 	vif->cfg.ssid_len = 0;
 	memset(vif->cfg.ssid, '\0', sizeof(vif->cfg.ssid));
 	bss_changed |= BSS_CHANGED_BSSID;
+	vif->bss_conf.use_short_preamble = false;
+	vif->bss_conf.qos = false;
+	/* XXX BSS_CHANGED_???? */
 	lkpi_80211_mo_bss_info_changed(hw, vif, &vif->bss_conf, bss_changed);
 
 	LKPI_80211_LVIF_LOCK(lvif);
@@ -2327,7 +2444,6 @@ lkpi_sta_run_to_init(struct ieee80211vap *vap, enum ieee80211_state nstate, int
 	lvif->lvif_bss = NULL;
 	lvif->lvif_bss_synched = false;
 	LKPI_80211_LVIF_UNLOCK(lvif);
-	lkpi_lsta_remove(lsta, lvif);
 	/*
 	 * The very last release the reference on the ni for the ni/lsta on
 	 * lvif->lvif_bss.  Upon return from this both ni and lsta are invalid
@@ -2340,16 +2456,18 @@ lkpi_sta_run_to_init(struct ieee80211vap *vap, enum ieee80211_state nstate, int
 	/* Take the chan ctx down. */
 	if (vif->chanctx_conf != NULL) {
 		struct lkpi_chanctx *lchanctx;
-		struct ieee80211_chanctx_conf *conf;
+		struct ieee80211_chanctx_conf *chanctx_conf;
 
-		conf = vif->chanctx_conf;
+		chanctx_conf = vif->chanctx_conf;
 		/* Remove vif context. */
 		lkpi_80211_mo_unassign_vif_chanctx(hw, vif, &vif->bss_conf, &vif->chanctx_conf);
 		/* NB: vif->chanctx_conf is NULL now. */
 
+		lkpi_hw_conf_idle(hw, true);
+
 		/* Remove chan ctx. */
-		lkpi_80211_mo_remove_chanctx(hw, conf);
-		lchanctx = CHANCTX_CONF_TO_LCHANCTX(conf);
+		lkpi_80211_mo_remove_chanctx(hw, chanctx_conf);
+		lchanctx = CHANCTX_CONF_TO_LCHANCTX(chanctx_conf);
 		free(lchanctx, M_LKPI80211);
 	}
 
@@ -3544,7 +3662,7 @@ lkpi_ic_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
 
 	lsta = ni->ni_drv_data;
 	LKPI_80211_LSTA_TXQ_LOCK(lsta);
-	if (!lsta->txq_ready) {
+	if (!lsta->added_to_drv || !lsta->txq_ready) {
 		LKPI_80211_LSTA_TXQ_UNLOCK(lsta);
 		/*
 		 * Free the mbuf (do NOT release ni ref for the m_pkthdr.rcvif!
@@ -3744,7 +3862,9 @@ lkpi_80211_txq_tx_one(struct lkpi_sta *lsta, struct mbuf *m)
 		    ltxq->txq.tid, ac, skb->priority, skb->qmap);
 #endif
 	LKPI_80211_LTXQ_UNLOCK(ltxq);
+	LKPI_80211_LHW_LOCK(lhw);
 	lkpi_80211_mo_wake_tx_queue(hw, &ltxq->txq);
+	LKPI_80211_LHW_UNLOCK(lhw);
 	return;
 
 ops_tx:
@@ -3757,7 +3877,9 @@ lkpi_80211_txq_tx_one(struct lkpi_sta *lsta, struct mbuf *m)
 #endif
 	memset(&control, 0, sizeof(control));
 	control.sta = sta;
+	LKPI_80211_LHW_LOCK(lhw);
 	lkpi_80211_mo_tx(hw, &control, skb);
+	LKPI_80211_LHW_UNLOCK(lhw);
 }
 
 static void
@@ -3766,6 +3888,7 @@ lkpi_80211_txq_task(void *ctx, int pending)
 	struct lkpi_sta *lsta;
 	struct mbufq mq;
 	struct mbuf *m;
+	bool shall_tx;
 
 	lsta = ctx;
 
@@ -3781,9 +3904,19 @@ lkpi_80211_txq_task(void *ctx, int pending)
 	LKPI_80211_LSTA_TXQ_LOCK(lsta);
 	/*
 	 * Do not re-check lsta->txq_ready here; we may have a pending
-	 * disassoc frame still.
+	 * disassoc/deauth frame still.  On the contrary if txq_ready is
+	 * false we do not have a valid sta anymore in the firmware so no
+	 * point to try to TX.
+	 * We also use txq_ready as a semaphore and will drain the txq manually
+	 * if needed on our way towards SCAN/INIT in the state machine.
+	 */
+	shall_tx = lsta->added_to_drv && lsta->txq_ready;
+	if (__predict_true(shall_tx))
+		mbufq_concat(&mq, &lsta->txq);
+	/*
+	 * else a state change will push the packets out manually or
+	 * lkpi_lsta_free() will drain the lsta->txq and free the mbufs.
 	 */
-	mbufq_concat(&mq, &lsta->txq);
 	LKPI_80211_LSTA_TXQ_UNLOCK(lsta);
 
 	m = mbufq_dequeue(&mq);
@@ -4745,7 +4878,7 @@ linuxkpi_ieee80211_iterate_chan_contexts(struct ieee80211_hw *hw,
 		if (!lchanctx->added_to_drv)
 			continue;
 
-		iterfunc(hw, &lchanctx->conf, arg);
+		iterfunc(hw, &lchanctx->chanctx_conf, arg);
 	}
 	LKPI_80211_LHW_LVIF_UNLOCK(lhw);
 }
@@ -5025,6 +5158,7 @@ linuxkpi_ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb,
 		goto err;
 	}
 
+	lsta = NULL;
 	if (sta != NULL) {
 		lsta = STA_TO_LSTA(sta);
 		ni = ieee80211_ref_node(lsta->ni);
diff --git a/sys/compat/linuxkpi/common/src/linux_80211.h b/sys/compat/linuxkpi/common/src/linux_80211.h
index b0156a5ade3f..a48cf719c693 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.h
+++ b/sys/compat/linuxkpi/common/src/linux_80211.h
@@ -267,12 +267,12 @@ struct lkpi_hw {	/* name it mac80211_sc? */
 
 struct lkpi_chanctx {
 	bool				added_to_drv;	/* Managed by MO */
-	struct ieee80211_chanctx_conf	conf __aligned(CACHE_LINE_SIZE);
+	struct ieee80211_chanctx_conf	chanctx_conf __aligned(CACHE_LINE_SIZE);
 };
 #define	LCHANCTX_TO_CHANCTX_CONF(_lchanctx)		\
-    (&(_lchanctx)->conf)
+    (&(_lchanctx)->chanctx_conf)
 #define	CHANCTX_CONF_TO_LCHANCTX(_conf)			\
-    container_of(_conf, struct lkpi_chanctx, conf)
+    container_of(_conf, struct lkpi_chanctx, chanctx_conf)
 
 struct lkpi_wiphy {
 	const struct cfg80211_ops	*ops;
diff --git a/sys/compat/linuxkpi/common/src/linux_aperture.c b/sys/compat/linuxkpi/common/src/linux_aperture.c
new file mode 100644
index 000000000000..15a56839fa9c
--- /dev/null
+++ b/sys/compat/linuxkpi/common/src/linux_aperture.c
@@ -0,0 +1,365 @@
+// SPDX-License-Identifier: MIT
+
+#include <linux/aperture.h>
+#include <linux/device.h>
+#include <linux/list.h>
+#include <linux/mutex.h>
+#include <linux/pci.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/sysfb.h>
+#include <linux/types.h>
+#include <linux/vgaarb.h>
+
+#include <video/vga.h>
+
+/**
+ * DOC: overview
+ *
+ * A graphics device might be supported by different drivers, but only one
+ * driver can be active at any given time. Many systems load a generic
+ * graphics drivers, such as EFI-GOP or VESA, early during the boot process.
+ * During later boot stages, they replace the generic driver with a dedicated,
+ * hardware-specific driver. To take over the device the dedicated driver
+ * first has to remove the generic driver. Aperture functions manage
+ * ownership of framebuffer memory and hand-over between drivers.
+ *
+ * Graphics drivers should call aperture_remove_conflicting_devices()
+ * at the top of their probe function. The function removes any generic
+ * driver that is currently associated with the given framebuffer memory.
+ * An example for a graphics device on the platform bus is shown below.
+ *
+ * .. code-block:: c
+ *
+ *	static int example_probe(struct platform_device *pdev)
+ *	{
+ *		struct resource *mem;
+ *		resource_size_t base, size;
+ *		int ret;
+ *
+ *		mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ *		if (!mem)
+ *			return -ENODEV;
+ *		base = mem->start;
+ *		size = resource_size(mem);
+ *
+ *		ret = aperture_remove_conflicting_devices(base, size, false, "example");
+ *		if (ret)
+ *			return ret;
+ *
+ *		// Initialize the hardware
+ *		...
+ *
+ *		return 0;
+ *	}
+ *
+ *	static const struct platform_driver example_driver = {
+ *		.probe = example_probe,
+ *		...
+ *	};
+ *
+ * The given example reads the platform device's I/O-memory range from the
+ * device instance. An active framebuffer will be located within this range.
+ * The call to aperture_remove_conflicting_devices() releases drivers that
+ * have previously claimed ownership of the range and are currently driving
+ * output on the framebuffer. If successful, the new driver can take over
+ * the device.
+ *
+ * While the given example uses a platform device, the aperture helpers work
+ * with every bus that has an addressable framebuffer. In the case of PCI,
+ * device drivers can also call aperture_remove_conflicting_pci_devices() and
+ * let the function detect the apertures automatically. Device drivers without
+ * knowledge of the framebuffer's location can call
+ * aperture_remove_all_conflicting_devices(), which removes all known devices.
+ *
+ * Drivers that are susceptible to being removed by other drivers, such as
+ * generic EFI or VESA drivers, have to register themselves as owners of their
+ * framebuffer apertures. Ownership of the framebuffer memory is achieved
+ * by calling devm_aperture_acquire_for_platform_device(). If successful, the
+ * driveris the owner of the framebuffer range. The function fails if the
+ * framebuffer is already owned by another driver. See below for an example.
+ *
+ * .. code-block:: c
+ *
+ *	static int generic_probe(struct platform_device *pdev)
+ *	{
+ *		struct resource *mem;
+ *		resource_size_t base, size;
+ *
+ *		mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ *		if (!mem)
+ *			return -ENODEV;
+ *		base = mem->start;
+ *		size = resource_size(mem);
+ *
+ *		ret = devm_aperture_acquire_for_platform_device(pdev, base, size);
+ *		if (ret)
+ *			return ret;
+ *
+ *		// Initialize the hardware
+ *		...
+ *
+ *		return 0;
+ *	}
+ *
+ *	static int generic_remove(struct platform_device *)
+ *	{
+ *		// Hot-unplug the device
+ *		...
+ *
+ *		return 0;
+ *	}
+ *
+ *	static const struct platform_driver generic_driver = {
+ *		.probe = generic_probe,
+ *		.remove = generic_remove,
+ *		...
+ *	};
+ *
+ * The similar to the previous example, the generic driver claims ownership
+ * of the framebuffer memory from its probe function. This will fail if the
+ * memory range, or parts of it, is already owned by another driver.
+ *
+ * If successful, the generic driver is now subject to forced removal by
+ * another driver. This only works for platform drivers that support hot
+ * unplugging. When a driver calls aperture_remove_conflicting_devices()
+ * et al for the registered framebuffer range, the aperture helpers call
+ * platform_device_unregister() and the generic driver unloads itself. The
+ * generic driver also has to provide a remove function to make this work.
+ * Once hot unplugged fro mhardware, it may not access the device's
+ * registers, framebuffer memory, ROM, etc afterwards.
+ */
+
+struct aperture_range {
+	struct device *dev;
+	resource_size_t base;
+	resource_size_t size;
+	struct list_head lh;
+	void (*detach)(struct device *dev);
+};
+
+static LIST_HEAD(apertures);
+static DEFINE_MUTEX(apertures_lock);
+
+static bool overlap(resource_size_t base1, resource_size_t end1,
+		    resource_size_t base2, resource_size_t end2)
+{
+	return (base1 < end2) && (end1 > base2);
+}
+
+static void devm_aperture_acquire_release(void *data)
+{
+	struct aperture_range *ap = data;
+	bool detached = !ap->dev;
+
+	if (detached)
+		return;
+
+	mutex_lock(&apertures_lock);
+	list_del(&ap->lh);
+	mutex_unlock(&apertures_lock);
+}
+
+static int devm_aperture_acquire(struct device *dev,
+				 resource_size_t base, resource_size_t size,
+				 void (*detach)(struct device *))
+{
+	size_t end = base + size;
+	struct list_head *pos;
+	struct aperture_range *ap;
+
+	mutex_lock(&apertures_lock);
+
+	list_for_each(pos, &apertures) {
+		ap = container_of(pos, struct aperture_range, lh);
+		if (overlap(base, end, ap->base, ap->base + ap->size)) {
+			mutex_unlock(&apertures_lock);
+			return -EBUSY;
+		}
+	}
+
+	ap = devm_kzalloc(dev, sizeof(*ap), GFP_KERNEL);
+	if (!ap) {
+		mutex_unlock(&apertures_lock);
+		return -ENOMEM;
+	}
+
+	ap->dev = dev;
+	ap->base = base;
+	ap->size = size;
+	ap->detach = detach;
+	INIT_LIST_HEAD(&ap->lh);
+
+	list_add(&ap->lh, &apertures);
+
+	mutex_unlock(&apertures_lock);
+
+	return devm_add_action_or_reset(dev, devm_aperture_acquire_release, ap);
+}
+
+static void aperture_detach_platform_device(struct device *dev)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+
+	/*
+	 * Remove the device from the device hierarchy. This is the right thing
+	 * to do for firmware-based DRM drivers, such as EFI, VESA or VGA. After
+	 * the new driver takes over the hardware, the firmware device's state
+	 * will be lost.
+	 *
+	 * For non-platform devices, a new callback would be required.
+	 *
+	 * If the aperture helpers ever need to handle native drivers, this call
+	 * would only have to unplug the DRM device, so that the hardware device
+	 * stays around after detachment.
+	 */
+	platform_device_unregister(pdev);
+}
+
+/**
+ * devm_aperture_acquire_for_platform_device - Acquires ownership of an aperture
+ *                                             on behalf of a platform device.
+ * @pdev:	the platform device to own the aperture
+ * @base:	the aperture's byte offset in physical memory
+ * @size:	the aperture size in bytes
+ *
+ * Installs the given device as the new owner of the aperture. The function
+ * expects the aperture to be provided by a platform device. If another
+ * driver takes over ownership of the aperture, aperture helpers will then
+ * unregister the platform device automatically. All acquired apertures are
+ * released automatically when the underlying device goes away.
+ *
+ * The function fails if the aperture, or parts of it, is currently
+ * owned by another device. To evict current owners, callers should use
+ * remove_conflicting_devices() et al. before calling this function.
+ *
+ * Returns:
+ * 0 on success, or a negative errno value otherwise.
+ */
+int devm_aperture_acquire_for_platform_device(struct platform_device *pdev,
+					      resource_size_t base,
+					      resource_size_t size)
+{
+	return devm_aperture_acquire(&pdev->dev, base, size, aperture_detach_platform_device);
+}
+EXPORT_SYMBOL(devm_aperture_acquire_for_platform_device);
+
+static void aperture_detach_devices(resource_size_t base, resource_size_t size)
+{
+	resource_size_t end = base + size;
+	struct list_head *pos, *n;
+
+	mutex_lock(&apertures_lock);
+
+	list_for_each_safe(pos, n, &apertures) {
+		struct aperture_range *ap = container_of(pos, struct aperture_range, lh);
+		struct device *dev = ap->dev;
+
+		if (WARN_ON_ONCE(!dev))
+			continue;
+
+		if (!overlap(base, end, ap->base, ap->base + ap->size))
+			continue;
+
+		ap->dev = NULL; /* detach from device */
+		list_del(&ap->lh);
+
+		ap->detach(dev);
+	}
+
+	mutex_unlock(&apertures_lock);
+}
+
+/**
+ * aperture_remove_conflicting_devices - remove devices in the given range
+ * @base: the aperture's base address in physical memory
+ * @size: aperture size in bytes
+ * @primary: also kick vga16fb if present; only relevant for VGA devices
+ * @name: a descriptive name of the requesting driver
+ *
+ * This function removes devices that own apertures within @base and @size.
+ *
+ * Returns:
+ * 0 on success, or a negative errno code otherwise
+ */
+int aperture_remove_conflicting_devices(resource_size_t base, resource_size_t size,
+					bool primary, const char *name)
+{
+	/*
+	 * If a driver asked to unregister a platform device registered by
+	 * sysfb, then can be assumed that this is a driver for a display
+	 * that is set up by the system firmware and has a generic driver.
+	 *
+	 * Drivers for devices that don't have a generic driver will never
+	 * ask for this, so let's assume that a real driver for the display
+	 * was already probed and prevent sysfb to register devices later.
+	 */
+#ifdef __linux__
+	sysfb_disable();
+#endif
+
+	aperture_detach_devices(base, size);
+
+	/*
+	 * If this is the primary adapter, there could be a VGA device
+	 * that consumes the VGA framebuffer I/O range. Remove this device
+	 * as well.
+	 */
+	if (primary)
+		aperture_detach_devices(VGA_FB_PHYS_BASE, VGA_FB_PHYS_SIZE);
+
+	return 0;
+}
+EXPORT_SYMBOL(aperture_remove_conflicting_devices);
+
+/**
+ * aperture_remove_conflicting_pci_devices - remove existing framebuffers for PCI devices
+ * @pdev: PCI device
+ * @name: a descriptive name of the requesting driver
+ *
+ * This function removes devices that own apertures within any of @pdev's
+ * memory bars. The function assumes that PCI device with shadowed ROM
+ * drives a primary display and therefore kicks out vga16fb as well.
+ *
+ * Returns:
+ * 0 on success, or a negative errno code otherwise
+ */
+int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev, const char *name)
+{
+	bool primary = false;
+	resource_size_t base, size;
+	int bar, ret;
+
+#ifdef CONFIG_X86
+#ifdef __linux__
+	primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
+#elif defined(__FreeBSD__)
+	primary = NULL;
+#endif
+#endif
+
+	for (bar = 0; bar < PCI_STD_NUM_BARS; ++bar) {
+		if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM))
+			continue;
+
+		base = pci_resource_start(pdev, bar);
+		size = pci_resource_len(pdev, bar);
+		ret = aperture_remove_conflicting_devices(base, size, primary, name);
+		if (ret)
+			return ret;
+	}
+
+	/*
+	 * WARNING: Apparently we must kick fbdev drivers before vgacon,
+	 * otherwise the vga fbdev driver falls over.
+	 */
+#ifdef __linux__
+	ret = vga_remove_vgacon(pdev);
+	if (ret)
+		return ret;
+#endif
+
+	return 0;
+
+}
+EXPORT_SYMBOL(aperture_remove_conflicting_pci_devices);
diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c
index 36ed7b84cc94..894e233042e3 100644
--- a/sys/compat/linuxkpi/common/src/linux_compat.c
+++ b/sys/compat/linuxkpi/common/src/linux_compat.c
@@ -382,9 +382,9 @@ linux_kq_assert_lock(void *arg, int what)
 	spinlock_t *s = arg;
 
 	if (what == LA_LOCKED)
-		mtx_assert(&s->m, MA_OWNED);
+		mtx_assert(s, MA_OWNED);
 	else
-		mtx_assert(&s->m, MA_NOTOWNED);
+		mtx_assert(s, MA_NOTOWNED);
 #endif
 }
 
@@ -1094,7 +1094,7 @@ linux_file_kqfilter_read_event(struct knote *kn, long hint)
 {
 	struct linux_file *filp = kn->kn_hook;
 
-	mtx_assert(&filp->f_kqlock.m, MA_OWNED);
+	mtx_assert(&filp->f_kqlock, MA_OWNED);
 
 	return ((filp->f_kqflags & LINUX_KQ_FLAG_NEED_READ) ? 1 : 0);
 }
@@ -1104,7 +1104,7 @@ linux_file_kqfilter_write_event(struct knote *kn, long hint)
 {
 	struct linux_file *filp = kn->kn_hook;
 
-	mtx_assert(&filp->f_kqlock.m, MA_OWNED);
+	mtx_assert(&filp->f_kqlock, MA_OWNED);
 
 	return ((filp->f_kqflags & LINUX_KQ_FLAG_NEED_WRITE) ? 1 : 0);
 }
@@ -2592,6 +2592,24 @@ io_mapping_create_wc(resource_size_t base, unsigned long size)
 	return (io_mapping_init_wc(mapping, base, size));
 }
 
+/* We likely want a linuxkpi_device.c at some point. */
+bool
+device_can_wakeup(struct device *dev)
+{
+
+	if (dev == NULL)
+		return (false);
+	/*
+	 * XXX-BZ iwlwifi queries it as part of enabling WoWLAN.
+	 * Normally this would be based on a bool in dev->power.XXX.
+	 * Check such as PCI PCIM_PCAP_*PME.  We have no way to enable this yet.
+	 * We may get away by directly calling into bsddev for as long as
+	 * we can assume PCI only avoiding changing struct device breaking KBI.
+	 */
+	pr_debug("%s:%d: not enabled; see comment.\n", __func__, __LINE__);
+	return (false);
+}
+
 #if defined(__i386__) || defined(__amd64__)
 bool linux_cpu_has_clflush;
 struct cpuinfo_x86 boot_cpu_data;
diff --git a/sys/compat/linuxkpi/common/src/linux_hdmi.c b/sys/compat/linuxkpi/common/src/linux_hdmi.c
index 172616306506..947be761dfa4 100644
--- a/sys/compat/linuxkpi/common/src/linux_hdmi.c
+++ b/sys/compat/linuxkpi/common/src/linux_hdmi.c
@@ -21,12 +21,6 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#ifdef __FreeBSD__
-#include <sys/cdefs.h>
-#include <sys/param.h>
-#include <sys/module.h>
-#endif
-
 #include <linux/bitops.h>
 #include <linux/bug.h>
 #include <linux/errno.h>
@@ -1915,7 +1909,3 @@ int hdmi_infoframe_unpack(union hdmi_infoframe *frame,
 	return ret;
 }
 EXPORT_SYMBOL(hdmi_infoframe_unpack);
-
-
-MODULE_VERSION(linuxkpi_hdmi, 1);
-MODULE_DEPEND(linuxkpi_hdmi, linuxkpi, 1, 1, 1);
diff --git a/sys/compat/linuxkpi/common/src/linux_idr.c b/sys/compat/linuxkpi/common/src/linux_idr.c
index 657d85606f50..b80f8c168d45 100644
--- a/sys/compat/linuxkpi/common/src/linux_idr.c
+++ b/sys/compat/linuxkpi/common/src/linux_idr.c
@@ -70,7 +70,7 @@ idr_preload_dequeue_locked(struct linux_idr_cache *lic)
 	struct idr_layer *retval;
 
 	/* check if wrong thread is trying to dequeue */
-	if (mtx_owned(&lic->lock.m) == 0)
+	if (mtx_owned(&lic->lock) == 0)
 		return (NULL);
 
 	retval = lic->head;
diff --git a/sys/compat/linuxkpi/common/src/linuxkpi_hdmikmod.c b/sys/compat/linuxkpi/common/src/linuxkpi_hdmikmod.c
new file mode 100644
index 000000000000..b0d4c013a6f3
--- /dev/null
+++ b/sys/compat/linuxkpi/common/src/linuxkpi_hdmikmod.c
@@ -0,0 +1,7 @@
+/* Public domain. */
+
+#include <sys/param.h>
+#include <sys/module.h>
+
+MODULE_VERSION(linuxkpi_hdmi, 1);
+MODULE_DEPEND(linuxkpi_hdmi, linuxkpi, 1, 1, 1);
diff --git a/sys/compat/linuxkpi/common/src/linuxkpi_videokmod.c b/sys/compat/linuxkpi/common/src/linuxkpi_videokmod.c
new file mode 100644
index 000000000000..8881adc0d657
--- /dev/null
+++ b/sys/compat/linuxkpi/common/src/linuxkpi_videokmod.c
@@ -0,0 +1,7 @@
+/* Public domain. */
+
+#include <sys/param.h>
+#include <sys/module.h>
+
+MODULE_VERSION(linuxkpi_video, 1);
+MODULE_DEPEND(linuxkpi_video, linuxkpi, 1, 1, 1);
diff --git a/sys/conf/NOTES b/sys/conf/NOTES
index c6434d1ea85d..1acd044c7025 100644
--- a/sys/conf/NOTES
+++ b/sys/conf/NOTES
@@ -2446,6 +2446,8 @@ device		u3g
 device		uark
 # USB support for Belkin F5U103 and compatible serial adapters
 device		ubsa
+# USB support for XHCI USB DbC.GP serial device
+device		udbc
 # USB support for serial adapters based on the FT8U100AX and FT8U232AM
 device		uftdi
 # USB support for some Windows CE based serial communication.
diff --git a/sys/conf/files b/sys/conf/files
index 7d3c44893e09..4ec0b9e09de4 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -1322,11 +1322,14 @@ dev/bhnd/siba/siba_bhndb.c		optional siba bhnd bhndb
 dev/bhnd/siba/siba_erom.c		optional siba bhnd
 dev/bhnd/siba/siba_subr.c		optional siba bhnd
 #
-dev/bnxt/bnxt_hwrm.c		optional bnxt iflib pci
-dev/bnxt/bnxt_mgmt.c		optional bnxt iflib pci
-dev/bnxt/bnxt_sysctl.c		optional bnxt iflib pci
-dev/bnxt/bnxt_txrx.c		optional bnxt iflib pci
-dev/bnxt/if_bnxt.c		optional bnxt iflib pci
+dev/bnxt/bnxt_en/bnxt_auxbus_compat.c	optional bnxt iflib pci compile-with "${BNXT_C}"
+dev/bnxt/bnxt_en/bnxt_dcb.c		optional bnxt iflib pci compile-with "${BNXT_C}"
+dev/bnxt/bnxt_en/bnxt_hwrm.c		optional bnxt iflib pci compile-with "${BNXT_C}"
+dev/bnxt/bnxt_en/bnxt_mgmt.c		optional bnxt iflib pci compile-with "${BNXT_C}"
+dev/bnxt/bnxt_en/bnxt_sysctl.c		optional bnxt iflib pci compile-with "${BNXT_C}"
+dev/bnxt/bnxt_en/bnxt_txrx.c		optional bnxt iflib pci compile-with "${BNXT_C}"
+dev/bnxt/bnxt_en/bnxt_ulp.c		optional bnxt iflib pci compile-with "${BNXT_C}"
+dev/bnxt/bnxt_en/if_bnxt.c		optional bnxt iflib pci compile-with "${BNXT_C}"
 dev/bwi/bwimac.c		optional bwi
 dev/bwi/bwiphy.c		optional bwi
 dev/bwi/bwirf.c			optional bwi
@@ -3204,8 +3207,7 @@ dev/usb/controller/uhci.c		optional uhci
 dev/usb/controller/uhci_pci.c		optional uhci pci
 dev/usb/controller/xhci.c		optional xhci
 dev/usb/controller/xhci_pci.c		optional xhci pci
-dev/usb/controller/saf1761_otg.c	optional saf1761otg
-dev/usb/controller/saf1761_otg_fdt.c	optional saf1761otg fdt
+dev/usb/controller/xhci_dbc.c		optional xhci pci
 dev/usb/controller/uss820dci.c		optional uss820dci
 dev/usb/controller/usb_controller.c	optional usb
 #
@@ -3313,6 +3315,7 @@ dev/usb/serial/ubsa.c		optional ubsa
 dev/usb/serial/ubser.c		optional ubser
 dev/usb/serial/uchcom.c		optional uchcom
 dev/usb/serial/ucycom.c		optional ucycom
+dev/usb/serial/udbc.c		optional udbc
 dev/usb/serial/ufoma.c		optional ufoma
 dev/usb/serial/uftdi.c		optional uftdi
 dev/usb/serial/ugensa.c		optional ugensa
@@ -3327,10 +3330,10 @@ dev/usb/serial/uslcom.c		optional uslcom
 dev/usb/serial/uvisor.c		optional uvisor
 dev/usb/serial/uvscom.c		optional uvscom
 dev/usb/serial/usb_serial.c 	optional ucom | u3g | uark | ubsa | ubser | \
-					 uchcom | ucycom | ufoma | uftdi | \
-					 ugensa | uipaq | umcs | umct | \
-					 umodem | umoscom | uplcom | usie | \
-					 uslcom | uvisor | uvscom
+					 uchcom | ucycom | udbc | ufoma | \
+					 uftdi | ugensa | uipaq | umcs | \
+					 umct | umodem | umoscom | uplcom | \
+					 usie | uslcom | uvisor | uvscom
 #
 # USB misc drivers
 #
diff --git a/sys/conf/files.amd64 b/sys/conf/files.amd64
index 8a5e643913a3..1c0592009e93 100644
--- a/sys/conf/files.amd64
+++ b/sys/conf/files.amd64
@@ -133,8 +133,9 @@ dev/enic/vnic_intr.c		optional	enic
 dev/enic/vnic_rq.c		optional	enic
 dev/enic/vnic_wq.c		optional	enic
 dev/ftgpio/ftgpio.c		optional	ftgpio superio
-dev/hyperv/vmbus/amd64/hyperv_machdep.c			optional	hyperv
-dev/hyperv/vmbus/amd64/vmbus_vector.S			optional	hyperv
+dev/hyperv/vmbus/amd64/hyperv_machdep.c		optional	hyperv
+dev/hyperv/vmbus/amd64/vmbus_vector.S		optional	hyperv
+dev/hyperv/vmbus/hyperv_mmu.c			optional	hyperv
 dev/iavf/if_iavf_iflib.c	optional	iavf pci \
 	compile-with "${NORMAL_C} -I$S/dev/iavf"
 dev/iavf/iavf_lib.c		optional	iavf pci \
diff --git a/sys/conf/files.x86 b/sys/conf/files.x86
index 15781eea8fee..445bbf9091ba 100644
--- a/sys/conf/files.x86
+++ b/sys/conf/files.x86
@@ -320,6 +320,7 @@ x86/iommu/intel_intrmap.c	optional	acpi iommu pci
 x86/iommu/intel_qi.c		optional	acpi iommu pci
 x86/iommu/intel_quirks.c	optional	acpi iommu pci
 x86/iommu/intel_utils.c		optional	acpi iommu pci
+x86/iommu/iommu_utils.c		optional	acpi iommu pci
 x86/isa/atrtc.c			standard
 x86/isa/clock.c			standard
 x86/isa/isa.c			optional	isa
diff --git a/sys/conf/kern.pre.mk b/sys/conf/kern.pre.mk
index 567c68e5887e..53b9862f2145 100644
--- a/sys/conf/kern.pre.mk
+++ b/sys/conf/kern.pre.mk
@@ -335,6 +335,10 @@ MLXFW_C=	${OFED_C_NOIMP} \
 		-I${SRCTOP}/sys/contrib/xz-embedded/freebsd \
 		-I${SRCTOP}/sys/contrib/xz-embedded/linux/lib/xz \
 		${.IMPSRC}
+# BNXT Driver
+BNXT_CFLAGS=	-I$S/dev/bnxt/bnxt_en ${OFEDCFLAGS}
+BNXT_C_NOIMP=	${CC} -c -o ${.TARGET} ${BNXT_CFLAGS} ${WERROR}
+BNXT_C=		${BNXT_C_NOIMP} ${.IMPSRC}
 
 GEN_CFILES= $S/$M/$M/genassym.c ${MFILES:T:S/.m$/.c/}
 SYSTEM_CFILES= config.c env.c hints.c vnode_if.c
diff --git a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vfsops.c b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vfsops.c
index a972c720dfdb..9b56d15f1095 100644
--- a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vfsops.c
+++ b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vfsops.c
@@ -100,7 +100,7 @@ static struct zfs_jailparam zfs_jailparam0 = {
 static int zfs_jailparam_slot;
 
 SYSCTL_JAIL_PARAM_SYS_NODE(zfs, CTLFLAG_RW, "Jail ZFS parameters");
-SYSCTL_JAIL_PARAM(_zfs, mount_snapshot, CTLTYPE_INT | CTLFLAG_RW, "I",
+SYSCTL_JAIL_PARAM(_zfs, mount_snapshot, CTLTYPE_INT | CTLFLAG_RW, "B",
 	"Allow mounting snapshots in the .zfs directory for unjailed datasets");
 
 SYSCTL_NODE(_vfs_zfs, OID_AUTO, version, CTLFLAG_RD, 0, "ZFS versions");
diff --git a/sys/contrib/openzfs/module/zfs/dbuf.c b/sys/contrib/openzfs/module/zfs/dbuf.c
index bb921af6d78a..0576da6475b1 100644
--- a/sys/contrib/openzfs/module/zfs/dbuf.c
+++ b/sys/contrib/openzfs/module/zfs/dbuf.c
@@ -2840,6 +2840,7 @@ dmu_buf_fill_done(dmu_buf_t *dbuf, dmu_tx_t *tx, boolean_t failed)
 			failed = B_FALSE;
 		} else if (failed) {
 			VERIFY(!dbuf_undirty(db, tx));
+			arc_buf_destroy(db->db_buf, db);
 			db->db_buf = NULL;
 			dbuf_clear_data(db);
 			DTRACE_SET_STATE(db, "fill failed");
diff --git a/sys/crypto/via/padlock.c b/sys/crypto/via/padlock.c
index b8dae256dbf4..2acdefd75bc6 100644
--- a/sys/crypto/via/padlock.c
+++ b/sys/crypto/via/padlock.c
@@ -80,31 +80,14 @@ padlock_identify(driver_t *drv, device_t parent)
 static int
 padlock_probe(device_t dev)
 {
-	char capp[256];
-
 #if defined(__amd64__) || defined(__i386__)
 	/* If there is no AES support, we has nothing to do here. */
 	if (!(via_feature_xcrypt & VIA_HAS_AES)) {
 		device_printf(dev, "No ACE support.\n");
 		return (EINVAL);
 	}
-	strlcpy(capp, "AES-CBC", sizeof(capp));
-#if 0
-	strlcat(capp, ",AES-EBC", sizeof(capp));
-	strlcat(capp, ",AES-CFB", sizeof(capp));
-	strlcat(capp, ",AES-OFB", sizeof(capp));
-#endif
-	if (via_feature_xcrypt & VIA_HAS_SHA) {
-		strlcat(capp, ",SHA1", sizeof(capp));
-		strlcat(capp, ",SHA256", sizeof(capp));
-	}
-#if 0
-	if (via_feature_xcrypt & VIA_HAS_AESCTR)
-		strlcat(capp, ",AES-CTR", sizeof(capp));
-	if (via_feature_xcrypt & VIA_HAS_MM)
-		strlcat(capp, ",RSA", sizeof(capp));
-#endif
-	device_set_desc_copy(dev, capp);
+	device_set_descf(dev, "AES-CBC%s",
+	    (via_feature_xcrypt & VIA_HAS_SHA) ? ",SHA1,SHA256" : "");
 	return (0);
 #else
 	return (EINVAL);
diff --git a/sys/dev/acpi_support/acpi_asus.c b/sys/dev/acpi_support/acpi_asus.c
index 6e63d8fabab1..b9ba6650d2b7 100644
--- a/sys/dev/acpi_support/acpi_asus.c
+++ b/sys/dev/acpi_support/acpi_asus.c
@@ -43,7 +43,6 @@
 #include <sys/kernel.h>
 #include <sys/module.h>
 #include <sys/bus.h>
-#include <sys/sbuf.h>
 
 #include <contrib/dev/acpica/include/acpi.h>
 #include <contrib/dev/acpica/include/accommon.h>
@@ -535,7 +534,6 @@ acpi_asus_probe(device_t dev)
 {
 	struct acpi_asus_model	*model;
 	struct acpi_asus_softc	*sc;
-	struct sbuf		*sb;
 	ACPI_BUFFER		Buf;
 	ACPI_OBJECT		Arg, *Obj;
 	ACPI_OBJECT_LIST	Args;
@@ -599,24 +597,17 @@ acpi_asus_probe(device_t dev)
 		}
 	}
 
-	sb = sbuf_new_auto();
-	if (sb == NULL)
-		return (ENOMEM);
-
 	/*
 	 * Asus laptops are simply identified by name, easy!
 	 */
 	for (model = acpi_asus_models; model->name != NULL; model++) {
 		if (strncmp(Obj->String.Pointer, model->name, 3) == 0) {
 good:
-			sbuf_printf(sb, "Asus %s Laptop Extras",
-			    Obj->String.Pointer);
-			sbuf_finish(sb);
-
 			sc->model = model;
-			device_set_desc_copy(dev, sbuf_data(sb));
 
-			sbuf_delete(sb);
+			device_set_descf(dev, "Asus %s Laptop Extras",
+			    Obj->String.Pointer);
+
 			AcpiOsFree(Buf.Pointer);
 			return (rv);
 		}
@@ -695,12 +686,9 @@ acpi_asus_probe(device_t dev)
 		}
 	}
 
-	sbuf_printf(sb, "Unsupported Asus laptop: %s\n", Obj->String.Pointer);
-	sbuf_finish(sb);
-
-	device_printf(dev, "%s", sbuf_data(sb));
+	device_printf(dev, "Unsupported Asus laptop: %s\n",
+	    Obj->String.Pointer);
 
-	sbuf_delete(sb);
 	AcpiOsFree(Buf.Pointer);
 
 	return (ENXIO);
diff --git a/sys/dev/acpi_support/acpi_fujitsu.c b/sys/dev/acpi_support/acpi_fujitsu.c
index 2d3c6f17dfe2..1649f74d873c 100644
--- a/sys/dev/acpi_support/acpi_fujitsu.c
+++ b/sys/dev/acpi_support/acpi_fujitsu.c
@@ -222,14 +222,12 @@ static int
 acpi_fujitsu_probe(device_t dev)
 {
 	char *name;
-	char buffer[64];
 	int rv;
 
 	rv =  ACPI_ID_PROBE(device_get_parent(dev), dev, fujitsu_ids, &name);
 	if (acpi_disabled("fujitsu") || rv > 0 || device_get_unit(dev) > 1)
 		return (ENXIO);
-	sprintf(buffer, "Fujitsu Function Hotkeys %s", name);
-	device_set_desc_copy(dev, buffer);
+	device_set_descf(dev, "Fujitsu Function Hotkeys %s", name);
 
 	return (rv);
 }
diff --git a/sys/dev/acpica/acpi_ec.c b/sys/dev/acpica/acpi_ec.c
index d27b7caee9e6..8ee7bc54f304 100644
--- a/sys/dev/acpica/acpi_ec.c
+++ b/sys/dev/acpica/acpi_ec.c
@@ -339,7 +339,6 @@ acpi_ec_probe(device_t dev)
     ACPI_OBJECT *obj;
     ACPI_STATUS status;
     device_t	peer;
-    char	desc[64];
     int		ecdt;
     int		ret, rc;
     struct acpi_ec_params *params;
@@ -444,10 +443,9 @@ acpi_ec_probe(device_t dev)
     ret = rc;
 out:
     if (ret <= 0) {
-	snprintf(desc, sizeof(desc), "Embedded Controller: GPE %#x%s%s",
-		 params->gpe_bit, (params->glk) ? ", GLK" : "",
-		 ecdt ? ", ECDT" : "");
-	device_set_desc_copy(dev, desc);
+	device_set_descf(dev, "Embedded Controller: GPE %#x%s%s",
+			 params->gpe_bit, (params->glk) ? ", GLK" : "",
+			 ecdt ? ", ECDT" : "");
     } else
 	free(params, M_TEMP);
 
diff --git a/sys/dev/acpica/acpi_pci_link.c b/sys/dev/acpica/acpi_pci_link.c
index dac07a07ae7d..d9807876c443 100644
--- a/sys/dev/acpica/acpi_pci_link.c
+++ b/sys/dev/acpica/acpi_pci_link.c
@@ -143,7 +143,7 @@ acpi_short_name(ACPI_HANDLE handle, char *buffer, size_t buflen)
 static int
 acpi_pci_link_probe(device_t dev)
 {
-	char descr[28], name[12];
+	char name[12];
 	int rv;
 
 	/*
@@ -157,10 +157,9 @@ acpi_pci_link_probe(device_t dev)
 	  return (rv);
 
 	if (ACPI_SUCCESS(acpi_short_name(acpi_get_handle(dev), name,
-	    sizeof(name)))) {
-		snprintf(descr, sizeof(descr), "ACPI PCI Link %s", name);
-		device_set_desc_copy(dev, descr);
-	} else
+	    sizeof(name))))
+		device_set_descf(dev, "ACPI PCI Link %s", name);
+	else
 		device_set_desc(dev, "ACPI PCI Link");
 	device_quiet(dev);
 	return (rv);
diff --git a/sys/dev/acpica/acpi_timer.c b/sys/dev/acpica/acpi_timer.c
index 8b362f52047a..e78b4728749a 100644
--- a/sys/dev/acpica/acpi_timer.c
+++ b/sys/dev/acpica/acpi_timer.c
@@ -159,7 +159,6 @@ acpi_timer_identify(driver_t *driver, device_t parent)
 static int
 acpi_timer_probe(device_t dev)
 {
-    char desc[40];
     int i, j, rid, rtype;
 
     ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
@@ -219,10 +218,9 @@ acpi_timer_probe(device_t dev)
     }
     tc_init(&acpi_timer_timecounter);
 
-    sprintf(desc, "%d-bit timer at %u.%06uMHz",
+    device_set_descf(dev, "%d-bit timer at %u.%06uMHz",
 	(AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) != 0 ? 32 : 24,
 	acpi_timer_frequency / 1000000, acpi_timer_frequency % 1000000);
-    device_set_desc_copy(dev, desc);
 
     /* Release the resource, we'll allocate it again during attach. */
     bus_release_resource(dev, rtype, rid, acpi_timer_reg);
diff --git a/sys/dev/ae/if_ae.c b/sys/dev/ae/if_ae.c
index 061f29e91e9c..97b96161dfed 100644
--- a/sys/dev/ae/if_ae.c
+++ b/sys/dev/ae/if_ae.c
@@ -327,12 +327,6 @@ ae_attach(device_t dev)
 		goto fail;
 
 	ifp = sc->ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "could not allocate ifnet structure.\n");
-		error = ENXIO;
-		goto fail;
-	}
-
 	if_setsoftc(ifp, sc);
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 	if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
diff --git a/sys/dev/age/if_age.c b/sys/dev/age/if_age.c
index c302dd6f1965..1a8b4aa6ad3f 100644
--- a/sys/dev/age/if_age.c
+++ b/sys/dev/age/if_age.c
@@ -591,12 +591,6 @@ age_attach(device_t dev)
 	age_get_macaddr(sc);
 
 	ifp = sc->age_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "cannot allocate ifnet structure.\n");
-		error = ENXIO;
-		goto fail;
-	}
-
 	if_setsoftc(ifp, sc);
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 	if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
diff --git a/sys/dev/ahci/ahci.c b/sys/dev/ahci/ahci.c
index 2f0971bddd9b..80cbdefd1e29 100644
--- a/sys/dev/ahci/ahci.c
+++ b/sys/dev/ahci/ahci.c
@@ -767,7 +767,7 @@ static int
 ahci_ch_probe(device_t dev)
 {
 
-	device_set_desc_copy(dev, "AHCI channel");
+	device_set_desc(dev, "AHCI channel");
 	return (BUS_PROBE_DEFAULT);
 }
 
diff --git a/sys/dev/ahci/ahci_generic.c b/sys/dev/ahci/ahci_generic.c
index 90487b4622eb..2d4babb17645 100644
--- a/sys/dev/ahci/ahci_generic.c
+++ b/sys/dev/ahci/ahci_generic.c
@@ -76,7 +76,7 @@ ahci_fdt_probe(device_t dev)
 	if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data)
 		return (ENXIO);
 
-	device_set_desc_copy(dev, "AHCI SATA controller");
+	device_set_desc(dev, "AHCI SATA controller");
 	node = ofw_bus_get_node(dev);
 	ctlr->dma_coherent = OF_hasprop(node, "dma-coherent");
 	return (BUS_PROBE_DEFAULT);
@@ -107,7 +107,7 @@ ahci_acpi_probe(device_t dev)
 	if (pci_get_class(dev) == PCIC_STORAGE &&
 	    pci_get_subclass(dev) == PCIS_STORAGE_SATA &&
 	    pci_get_progif(dev) == PCIP_STORAGE_SATA_AHCI_1_0) {
-		device_set_desc_copy(dev, "AHCI SATA controller");
+		device_set_desc(dev, "AHCI SATA controller");
 		if (ACPI_FAILURE(acpi_GetInteger(h, "_CCA",
 		      &ctlr->dma_coherent)))
 			ctlr->dma_coherent = 0;
diff --git a/sys/dev/ahci/ahci_pci.c b/sys/dev/ahci/ahci_pci.c
index 93a72875b502..3d4a7d7c7400 100644
--- a/sys/dev/ahci/ahci_pci.c
+++ b/sys/dev/ahci/ahci_pci.c
@@ -397,7 +397,6 @@ ahci_pci_ctlr_reset(device_t dev)
 static int
 ahci_probe(device_t dev)
 {
-	char buf[64];
 	int i, valid = 0;
 	uint32_t devid = pci_get_devid(dev);
 	uint8_t revid = pci_get_revid(dev);
@@ -428,22 +427,20 @@ ahci_probe(device_t dev)
 			    (ahci_ids[i].quirks & AHCI_Q_NOFORCE) &&
 			    (pci_read_config(dev, 0xdf, 1) & 0x40) == 0)
 				return (ENXIO);
-			snprintf(buf, sizeof(buf), "%s AHCI SATA controller",
+			device_set_descf(dev, "%s AHCI SATA controller",
 			    ahci_ids[i].name);
-			device_set_desc_copy(dev, buf);
 			return (BUS_PROBE_DEFAULT);
 		}
 	}
 	if (valid != 1)
 		return (ENXIO);
-	device_set_desc_copy(dev, "AHCI SATA controller");
+	device_set_desc(dev, "AHCI SATA controller");
 	return (BUS_PROBE_DEFAULT);
 }
 
 static int
 ahci_ata_probe(device_t dev)
 {
-	char buf[64];
 	int i;
 	uint32_t devid = pci_get_devid(dev);
 	uint8_t revid = pci_get_revid(dev);
@@ -454,13 +451,12 @@ ahci_ata_probe(device_t dev)
 	for (i = 0; ahci_ids[i].id != 0; i++) {
 		if (ahci_ids[i].id == devid &&
 		    ahci_ids[i].rev <= revid) {
-			snprintf(buf, sizeof(buf), "%s AHCI SATA controller",
+			device_set_descf(dev, "%s AHCI SATA controller",
 			    ahci_ids[i].name);
-			device_set_desc_copy(dev, buf);
 			return (BUS_PROBE_DEFAULT);
 		}
 	}
-	device_set_desc_copy(dev, "AHCI SATA controller");
+	device_set_desc(dev, "AHCI SATA controller");
 	return (BUS_PROBE_DEFAULT);
 }
 
diff --git a/sys/dev/ahci/ahciem.c b/sys/dev/ahci/ahciem.c
index eb1f2bdc3924..d9ec64b2d014 100644
--- a/sys/dev/ahci/ahciem.c
+++ b/sys/dev/ahci/ahciem.c
@@ -64,7 +64,7 @@ static int
 ahci_em_probe(device_t dev)
 {
 
-	device_set_desc_copy(dev, "AHCI enclosure management bridge");
+	device_set_desc(dev, "AHCI enclosure management bridge");
 	return (BUS_PROBE_DEFAULT);
 }
 
diff --git a/sys/dev/alc/if_alc.c b/sys/dev/alc/if_alc.c
index 2943be7063b5..c83cd1bf6869 100644
--- a/sys/dev/alc/if_alc.c
+++ b/sys/dev/alc/if_alc.c
@@ -1585,12 +1585,6 @@ alc_attach(device_t dev)
 	alc_get_macaddr(sc);
 
 	ifp = sc->alc_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "cannot allocate ifnet structure.\n");
-		error = ENXIO;
-		goto fail;
-	}
-
 	if_setsoftc(ifp, sc);
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 	if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
diff --git a/sys/dev/ale/if_ale.c b/sys/dev/ale/if_ale.c
index 510a029cd18f..e8e7a55e9b8f 100644
--- a/sys/dev/ale/if_ale.c
+++ b/sys/dev/ale/if_ale.c
@@ -610,12 +610,6 @@ ale_attach(device_t dev)
 	ale_get_macaddr(sc);
 
 	ifp = sc->ale_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "cannot allocate ifnet structure.\n");
-		error = ENXIO;
-		goto fail;
-	}
-
 	if_setsoftc(ifp, sc);
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 	if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
diff --git a/sys/dev/altera/atse/if_atse.c b/sys/dev/altera/atse/if_atse.c
index 923292484207..9e3871cf5779 100644
--- a/sys/dev/altera/atse/if_atse.c
+++ b/sys/dev/altera/atse/if_atse.c
@@ -1372,11 +1372,6 @@ atse_attach(device_t dev)
 
 	/* Setup interface. */
 	ifp = sc->atse_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "if_alloc() failed\n");
-		error = ENOSPC;
-		goto err;
-	}
 	if_setsoftc(ifp, sc);
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 	if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
diff --git a/sys/dev/amdsbwd/amdsbwd.c b/sys/dev/amdsbwd/amdsbwd.c
index b04aa8564ccd..1dfe6c1b11bf 100644
--- a/sys/dev/amdsbwd/amdsbwd.c
+++ b/sys/dev/amdsbwd/amdsbwd.c
@@ -376,7 +376,6 @@ static void
 amdsbwd_probe_fch41(device_t dev, struct resource *pmres, uint32_t *addr)
 {
 	uint8_t	val;
-	char buf[36];
 
 	/*
 	 * Enable decoding of watchdog MMIO address.
@@ -414,9 +413,8 @@ amdsbwd_probe_fch41(device_t dev, struct resource *pmres, uint32_t *addr)
 	amdsbwd_verbose_printf(dev, "AMDFCH41_PM_DECODE_EN3 value = %#04x\n",
 	    val);
 #endif
-	snprintf(buf, sizeof(buf), "%s FCH Rev 41h+ Watchdog Timer",
+	device_set_descf(dev, "%s FCH Rev 41h+ Watchdog Timer",
 	    cpu_vendor_id == CPU_VENDOR_HYGON ? "Hygon" : "AMD");
-	device_set_desc_copy(dev, buf);
 }
 
 static int
diff --git a/sys/dev/amdsmn/amdsmn.c b/sys/dev/amdsmn/amdsmn.c
index 36e3c5a5cae7..5af8d9aca7bd 100644
--- a/sys/dev/amdsmn/amdsmn.c
+++ b/sys/dev/amdsmn/amdsmn.c
@@ -186,7 +186,6 @@ static int
 amdsmn_probe(device_t dev)
 {
 	uint32_t family;
-	char buf[64];
 
 	if (resource_disabled("amdsmn", 0))
 		return (ENXIO);
@@ -203,9 +202,8 @@ amdsmn_probe(device_t dev)
 	default:
 		return (ENXIO);
 	}
-	snprintf(buf, sizeof(buf), "AMD Family %xh System Management Network",
+	device_set_descf(dev, "AMD Family %xh System Management Network",
 	    family);
-	device_set_desc_copy(dev, buf);
 
 	return (BUS_PROBE_GENERIC);
 }
diff --git a/sys/dev/arcmsr/arcmsr.c b/sys/dev/arcmsr/arcmsr.c
index ea37da30db93..6de4372a67ea 100644
--- a/sys/dev/arcmsr/arcmsr.c
+++ b/sys/dev/arcmsr/arcmsr.c
@@ -5238,7 +5238,6 @@ static int arcmsr_probe(device_t dev)
 {
 	u_int32_t id;
 	u_int16_t sub_device_id;
-	static char buf[256];
 	char x_type[]={"unknown"};
 	char *type;
 	int raid6 = 1;
@@ -5313,9 +5312,8 @@ static int arcmsr_probe(device_t dev)
 	}
 	if(type == x_type)
 		return(ENXIO);
-	sprintf(buf, "Areca %s Host Adapter RAID Controller %s\n%s\n",
-		type, raid6 ? "(RAID6 capable)" : "", ARCMSR_DRIVER_VERSION);
-	device_set_desc_copy(dev, buf);
+	device_set_descf(dev, "Areca %s Host Adapter RAID Controller %s\n%s\n",
+	    type, raid6 ? "(RAID6 capable)" : "", ARCMSR_DRIVER_VERSION);
 	return (BUS_PROBE_DEFAULT);
 }
 /*
diff --git a/sys/dev/ata/ata-pci.c b/sys/dev/ata/ata-pci.c
index 767467cef656..71a58a21df39 100644
--- a/sys/dev/ata/ata-pci.c
+++ b/sys/dev/ata/ata-pci.c
@@ -61,7 +61,6 @@ int
 ata_pci_probe(device_t dev)
 {
     struct ata_pci_controller *ctlr = device_get_softc(dev);
-    char buffer[64];
 
     /* is this a storage class device ? */
     if (pci_get_class(dev) != PCIC_STORAGE)
@@ -71,8 +70,7 @@ ata_pci_probe(device_t dev)
     if (pci_get_subclass(dev) != PCIS_STORAGE_IDE)
 	return (ENXIO);
     
-    sprintf(buffer, "%s ATA controller", ata_pcivendor2str(dev));
-    device_set_desc_copy(dev, buffer);
+    device_set_descf(dev, "%s ATA controller", ata_pcivendor2str(dev));
     ctlr->chipinit = ata_generic_chipinit;
 
     /* we are a low priority handler */
@@ -836,12 +834,10 @@ void
 ata_set_desc(device_t dev)
 {
     struct ata_pci_controller *ctlr = device_get_softc(dev);
-    char buffer[128];
 
-    sprintf(buffer, "%s %s %s controller",
+    device_set_descf(dev, "%s %s %s controller",
             ata_pcivendor2str(dev), ctlr->chip->text, 
             ata_mode2str(ctlr->chip->max_dma));
-    device_set_desc_copy(dev, buffer);
 }
 
 const struct ata_chip_id *
diff --git a/sys/dev/ata/chipsets/ata-highpoint.c b/sys/dev/ata/chipsets/ata-highpoint.c
index 7b9619907281..3f7de04659bf 100644
--- a/sys/dev/ata/chipsets/ata-highpoint.c
+++ b/sys/dev/ata/chipsets/ata-highpoint.c
@@ -82,7 +82,7 @@ ata_highpoint_probe(device_t dev)
      { ATA_HPT366, 0x00, HPT_366, HPT_OLD, ATA_UDMA4, "HPT366" },
      { ATA_HPT302, 0x01, HPT_372, 0,       ATA_UDMA6, "HPT302" },
      { 0, 0, 0, 0, 0, 0}};
-    char buffer[64];
+    const char *channel;
 
     if (pci_get_vendor(dev) != ATA_HIGHPOINT_ID)
         return ENXIO;
@@ -90,16 +90,15 @@ ata_highpoint_probe(device_t dev)
     if (!(idx = ata_match_chip(dev, ids)))
 	return ENXIO;
 
-    strcpy(buffer, "HighPoint ");
-    strcat(buffer, idx->text);
+    channel = "";
     if (idx->cfg1 == HPT_374) {
 	if (pci_get_function(dev) == 0)
-	    strcat(buffer, " (channel 0+1)");
-	if (pci_get_function(dev) == 1)
-	    strcat(buffer, " (channel 2+3)");
+	    channel = " (channel 0+1)";
+	else if (pci_get_function(dev) == 1)
+	    channel = " (channel 2+3)";
     }
-    sprintf(buffer, "%s %s controller", buffer, ata_mode2str(idx->max_dma));
-    device_set_desc_copy(dev, buffer);
+    device_set_descf(dev, "Highpoint %s%s %s controller",
+	idx->text, channel, ata_mode2str(idx->max_dma));
     ctlr->chip = idx;
     ctlr->chipinit = ata_highpoint_chipinit;
     return (BUS_PROBE_LOW_PRIORITY);
diff --git a/sys/dev/ata/chipsets/ata-jmicron.c b/sys/dev/ata/chipsets/ata-jmicron.c
index 8d0cc46ac0b2..1a7d3d514454 100644
--- a/sys/dev/ata/chipsets/ata-jmicron.c
+++ b/sys/dev/ata/chipsets/ata-jmicron.c
@@ -73,7 +73,6 @@ ata_jmicron_probe(device_t dev)
      { ATA_JMB368, 0, 0, 1, ATA_UDMA6, "JMB368" },
      { ATA_JMB368_2, 0, 0, 1, ATA_UDMA6, "JMB368" },
      { 0, 0, 0, 0, 0, 0}};
-    char buffer[64];
 
     if (pci_get_vendor(dev) != ATA_JMICRON_ID)
 	return ENXIO;
@@ -81,9 +80,8 @@ ata_jmicron_probe(device_t dev)
     if (!(idx = ata_match_chip(dev, ids)))
         return ENXIO;
 
-    sprintf(buffer, "JMicron %s %s controller",
+    device_set_descf(dev, "JMicron %s %s controller",
 	idx->text, ata_mode2str(idx->max_dma));
-    device_set_desc_copy(dev, buffer);
     ctlr->chip = idx;
     ctlr->chipinit = ata_jmicron_chipinit;
     return (BUS_PROBE_LOW_PRIORITY);
diff --git a/sys/dev/ata/chipsets/ata-promise.c b/sys/dev/ata/chipsets/ata-promise.c
index 94c96d00f9de..c59f23ea66c7 100644
--- a/sys/dev/ata/chipsets/ata-promise.c
+++ b/sys/dev/ata/chipsets/ata-promise.c
@@ -167,7 +167,7 @@ ata_promise_probe(device_t dev)
      { ATA_PDC40719,  0, PR_MIO, PR_SATA2, ATA_SA300, "PDC40719" },
      { ATA_PDC40779,  0, PR_MIO, PR_SATA2, ATA_SA300, "PDC40779" },
      { 0, 0, 0, 0, 0, 0}};
-    char buffer[64];
+    const char *channel;
     uintptr_t devid = 0;
 
     if (pci_get_vendor(dev) != ATA_PROMISE_ID)
@@ -183,10 +183,8 @@ ata_promise_probe(device_t dev)
 	devid == ATA_I960RM) 
 	return ENXIO;
 
-    strcpy(buffer, "Promise ");
-    strcat(buffer, idx->text);
-
     /* if we are on a FastTrak TX4, adjust the interrupt resource */
+    channel = NULL;
     if ((idx->cfg2 & PR_TX4) && pci_get_class(GRANDPARENT(dev))==PCIC_BRIDGE &&
 	!BUS_READ_IVAR(device_get_parent(GRANDPARENT(dev)),
 		       GRANDPARENT(dev), PCI_IVAR_DEVID, &devid) &&
@@ -195,18 +193,18 @@ ata_promise_probe(device_t dev)
 
 	if (pci_get_slot(dev) == 1) {
 	    bus_get_resource(dev, SYS_RES_IRQ, 0, &start, &end);
-	    strcat(buffer, " (channel 0+1)");
+	    channel = " (channel 0+1)";
 	}
 	else if (pci_get_slot(dev) == 2 && start && end) {
 	    bus_set_resource(dev, SYS_RES_IRQ, 0, start, end);
-	    strcat(buffer, " (channel 2+3)");
+	    channel = " (channel 2+3)";
 	}
 	else {
 	    start = end = 0;
 	}
     }
-    sprintf(buffer, "%s %s controller", buffer, ata_mode2str(idx->max_dma));
-    device_set_desc_copy(dev, buffer);
+    device_set_descf(dev, "Promise %s%s %s controller", idx->text,
+	channel == NULL ? "" : channel, ata_mode2str(idx->max_dma));
     ctlr->chip = idx;
     ctlr->chipinit = ata_promise_chipinit;
     return (BUS_PROBE_LOW_PRIORITY);
diff --git a/sys/dev/ata/chipsets/ata-sis.c b/sys/dev/ata/chipsets/ata-sis.c
index 039fe6c06e9e..3cc10291d66d 100644
--- a/sys/dev/ata/chipsets/ata-sis.c
+++ b/sys/dev/ata/chipsets/ata-sis.c
@@ -102,7 +102,6 @@ ata_sis_probe(device_t dev)
      { 0, 0, 0, 0, 0, 0 }};
     static struct ata_chip_id id[] =
     {{ ATA_SISSOUTH, 0x10, 0, 0, 0, "" }, { 0, 0, 0, 0, 0, 0 }};
-    char buffer[64];
     int found = 0;
 
     if (pci_get_class(dev) != PCIC_STORAGE)
@@ -123,8 +122,8 @@ ata_sis_probe(device_t dev)
     	    memcpy(&id[0], idx, sizeof(id[0]));
 	    id[0].cfg1 = SIS_133NEW;
 	    id[0].max_dma = ATA_UDMA6;
-	    sprintf(buffer, "SiS 962/963 %s controller",
-		    ata_mode2str(idx->max_dma));
+	    device_set_descf(dev, "SiS 962/963 %s controller",
+		ata_mode2str(idx->max_dma));
 	}
 	pci_write_config(dev, 0x57, reg57, 1);
     }
@@ -141,17 +140,17 @@ ata_sis_probe(device_t dev)
 		id[0].cfg1 = SIS_100NEW;
 		id[0].max_dma = ATA_UDMA5;
 	    }
-	    sprintf(buffer, "SiS 961 %s controller",ata_mode2str(idx->max_dma));
+	    device_set_descf(dev, "SiS 961 %s controller",
+		ata_mode2str(idx->max_dma));
 	}
 	pci_write_config(dev, 0x4a, reg4a, 1);
     }
     if (!found)
-	sprintf(buffer,"SiS %s %s controller",
-		idx->text, ata_mode2str(idx->max_dma));
+	device_set_descf(dev, "SiS %s %s controller",
+	    idx->text, ata_mode2str(idx->max_dma));
     else
 	idx = &id[0];
 
-    device_set_desc_copy(dev, buffer);
     ctlr->chip = idx;
     ctlr->chipinit = ata_sis_chipinit;
     return (BUS_PROBE_LOW_PRIORITY);
diff --git a/sys/dev/axgbe/if_axgbe.c b/sys/dev/axgbe/if_axgbe.c
index 4641c346bb63..9c6d7d845f2d 100644
--- a/sys/dev/axgbe/if_axgbe.c
+++ b/sys/dev/axgbe/if_axgbe.c
@@ -389,11 +389,6 @@ axgbe_attach(device_t dev)
 	OF_getprop(node, "mac-address", sc->mac_addr, ETHER_ADDR_LEN);
 
 	sc->prv.netdev = ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "Cannot alloc ifnet\n");
-		return (ENXIO);
-	}
-
 	sc->prv.dev = dev;
 	sc->prv.dmat = bus_get_dma_tag(dev);
 	sc->prv.phy.advertising = ADVERTISED_10000baseKR_Full |
diff --git a/sys/dev/bce/if_bce.c b/sys/dev/bce/if_bce.c
index 33158b75486c..226fca16ac28 100644
--- a/sys/dev/bce/if_bce.c
+++ b/sys/dev/bce/if_bce.c
@@ -671,7 +671,6 @@ bce_probe(device_t dev)
 {
 	const struct bce_type *t;
 	struct bce_softc *sc;
-	char *descbuf;
 	u16 vid = 0, did = 0, svid = 0, sdid = 0;
 
 	t = bce_devs;
@@ -695,19 +694,10 @@ bce_probe(device_t dev)
 		if ((vid == t->bce_vid) && (did == t->bce_did) &&
 		    ((svid == t->bce_svid) || (t->bce_svid == PCI_ANY_ID)) &&
 		    ((sdid == t->bce_sdid) || (t->bce_sdid == PCI_ANY_ID))) {
-			descbuf = malloc(BCE_DEVDESC_MAX, M_TEMP, M_NOWAIT);
-
-			if (descbuf == NULL)
-				return(ENOMEM);
-
-			/* Print out the device identity. */
-			snprintf(descbuf, BCE_DEVDESC_MAX, "%s (%c%d)",
+			device_set_descf(dev, "%s (%c%d)",
 			    t->bce_name, (((pci_read_config(dev,
 			    PCIR_REVID, 4) & 0xf0) >> 4) + 'A'),
 			    (pci_read_config(dev, PCIR_REVID, 4) & 0xf));
-
-			device_set_desc_copy(dev, descbuf);
-			free(descbuf, M_TEMP);
 			return(BUS_PROBE_DEFAULT);
 		}
 		t++;
@@ -1361,12 +1351,6 @@ bce_attach(device_t dev)
 
 	/* Allocate an ifnet structure. */
 	ifp = sc->bce_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		BCE_PRINTF("%s(%d): Interface allocation failed!\n",
-		    __FILE__, __LINE__);
-		rc = ENXIO;
-		goto bce_attach_fail;
-	}
 
 	/* Initialize the ifnet interface. */
 	if_setsoftc(ifp, sc);
diff --git a/sys/dev/bfe/if_bfe.c b/sys/dev/bfe/if_bfe.c
index de5c43087fa3..e488300dc944 100644
--- a/sys/dev/bfe/if_bfe.c
+++ b/sys/dev/bfe/if_bfe.c
@@ -478,11 +478,6 @@ bfe_attach(device_t dev)
 
 	/* Set up ifnet structure */
 	ifp = sc->bfe_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "failed to if_alloc()\n");
-		error = ENOSPC;
-		goto fail;
-	}
 	if_setsoftc(ifp, sc);
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 	if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
diff --git a/sys/dev/bge/if_bge.c b/sys/dev/bge/if_bge.c
index a646ed226d3c..e8af6530354f 100644
--- a/sys/dev/bge/if_bge.c
+++ b/sys/dev/bge/if_bge.c
@@ -2699,7 +2699,6 @@ bge_chipid(device_t dev)
 static int
 bge_probe(device_t dev)
 {
-	char buf[96];
 	char model[64];
 	const struct bge_revision *br;
 	const char *pname;
@@ -2727,9 +2726,8 @@ bge_probe(device_t dev)
 				    br != NULL ? br->br_name :
 				    "NetXtreme/NetLink Ethernet Controller");
 			}
-			snprintf(buf, sizeof(buf), "%s, %sASIC rev. %#08x",
+			device_set_descf(dev, "%s, %sASIC rev. %#08x",
 			    model, br != NULL ? "" : "unknown ", id);
-			device_set_desc_copy(dev, buf);
 			return (BUS_PROBE_DEFAULT);
 		}
 		t++;
@@ -3714,11 +3712,6 @@ bge_attach(device_t dev)
 
 	/* Set up ifnet structure */
 	ifp = sc->bge_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(sc->bge_dev, "failed to if_alloc()\n");
-		error = ENXIO;
-		goto fail;
-	}
 	if_setsoftc(ifp, sc);
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 	if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
diff --git a/sys/dev/bhnd/bhnd_subr.c b/sys/dev/bhnd/bhnd_subr.c
index df2474f57659..c29122c38759 100644
--- a/sys/dev/bhnd/bhnd_subr.c
+++ b/sys/dev/bhnd/bhnd_subr.c
@@ -1766,18 +1766,10 @@ void
 bhnd_set_custom_core_desc(device_t dev, const char *dev_name)
 {
 	const char *vendor_name;
-	char *desc;
 
 	vendor_name = bhnd_get_vendor_name(dev);
-	asprintf(&desc, M_BHND, "%s %s, rev %hhu", vendor_name, dev_name,
+	device_set_descf(dev, "%s %s, rev %hhu", vendor_name, dev_name,
 	    bhnd_get_hwrev(dev));
-
-	if (desc != NULL) {
-		device_set_desc_copy(dev, desc);
-		free(desc, M_BHND);
-	} else {
-		device_set_desc(dev, dev_name);
-	}
 }
 
 /**
@@ -1803,7 +1795,6 @@ void
 bhnd_set_default_bus_desc(device_t dev, const struct bhnd_chipid *chip_id)
 {
 	const char	*bus_name;
-	char		*desc;
 	char		 chip_name[BHND_CHIPID_MAX_NAMELEN];
 
 	/* Determine chip type's bus name */
@@ -1828,14 +1819,7 @@ bhnd_set_default_bus_desc(device_t dev, const struct bhnd_chipid *chip_id)
 	     chip_id->chip_id);
 
 	/* Format and set device description */
-	asprintf(&desc, M_BHND, "%s %s", chip_name, bus_name);
-	if (desc != NULL) {
-		device_set_desc_copy(dev, desc);
-		free(desc, M_BHND);
-	} else {
-		device_set_desc(dev, bus_name);
-	}
-
+	device_set_descf(dev, "%s %s", chip_name, bus_name);
 }
 
 /**
diff --git a/sys/dev/bhnd/cores/chipc/bhnd_pmu_chipc.c b/sys/dev/bhnd/cores/chipc/bhnd_pmu_chipc.c
index 95b19d973e26..ce50fcd0ee1f 100644
--- a/sys/dev/bhnd/cores/chipc/bhnd_pmu_chipc.c
+++ b/sys/dev/bhnd/cores/chipc/bhnd_pmu_chipc.c
@@ -62,7 +62,6 @@ bhnd_pmu_chipc_probe(device_t dev)
 	struct chipc_caps	*ccaps;
 	struct chipc_softc	*chipc_sc;
 	device_t		 chipc;
-	char			 desc[34];
 	int			 error;
 	uint32_t		 pcaps;
 	uint8_t			 rev;
@@ -87,8 +86,7 @@ bhnd_pmu_chipc_probe(device_t dev)
 
 	/* Set description */
 	rev = BHND_PMU_GET_BITS(pcaps, BHND_PMU_CAP_REV);
-	snprintf(desc, sizeof(desc), "Broadcom ChipCommon PMU, rev %hhu", rev);
-	device_set_desc_copy(dev, desc);
+	device_set_descf(dev, "Broadcom ChipCommon PMU, rev %hhu", rev);
 
 	return (BUS_PROBE_NOWILDCARD);
 }
diff --git a/sys/dev/bnxt/bnxt.h b/sys/dev/bnxt/bnxt.h
deleted file mode 100644
index 2b5c16e263d7..000000000000
--- a/sys/dev/bnxt/bnxt.h
+++ /dev/null
@@ -1,803 +0,0 @@
-/*-
- * Broadcom NetXtreme-C/E network driver.
- *
- * Copyright (c) 2016 Broadcom, All Rights Reserved.
- * The term Broadcom refers to Broadcom Limited and/or its subsidiaries
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS'
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-#ifndef _BNXT_H
-#define _BNXT_H
-
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <sys/sysctl.h>
-#include <sys/taskqueue.h>
-#include <sys/bitstring.h>
-
-#include <machine/bus.h>
-
-#include <net/ethernet.h>
-#include <net/if.h>
-#include <net/if_var.h>
-#include <net/iflib.h>
-
-#include "hsi_struct_def.h"
-
-/* PCI IDs */
-#define BROADCOM_VENDOR_ID	0x14E4
-
-#define BCM57301	0x16c8
-#define BCM57302	0x16c9
-#define BCM57304	0x16ca
-#define BCM57311	0x16ce
-#define BCM57312	0x16cf
-#define BCM57314	0x16df
-#define BCM57402	0x16d0
-#define BCM57402_NPAR	0x16d4
-#define BCM57404	0x16d1
-#define BCM57404_NPAR	0x16e7
-#define BCM57406	0x16d2
-#define BCM57406_NPAR	0x16e8
-#define BCM57407	0x16d5
-#define BCM57407_NPAR	0x16ea
-#define BCM57407_SFP	0x16e9
-#define BCM57412	0x16d6
-#define BCM57412_NPAR1	0x16de
-#define BCM57412_NPAR2	0x16eb
-#define BCM57414	0x16d7
-#define BCM57414_NPAR1	0x16ec
-#define BCM57414_NPAR2	0x16ed
-#define BCM57416	0x16d8
-#define BCM57416_NPAR1	0x16ee
-#define BCM57416_NPAR2	0x16ef
-#define BCM57416_SFP	0x16e3
-#define BCM57417	0x16d9
-#define BCM57417_NPAR1	0x16c0
-#define BCM57417_NPAR2	0x16cc
-#define BCM57417_SFP	0x16e2
-#define BCM57454	0x1614
-#define BCM58700	0x16cd
-#define BCM57508  	0x1750
-#define BCM57504  	0x1751
-#define BCM57502  	0x1752
-#define NETXTREME_C_VF1	0x16cb
-#define NETXTREME_C_VF2	0x16e1
-#define NETXTREME_C_VF3	0x16e5
-#define NETXTREME_E_VF1	0x16c1
-#define NETXTREME_E_VF2	0x16d3
-#define NETXTREME_E_VF3	0x16dc
-
-/* Maximum numbers of RX and TX descriptors. iflib requires this to be a power
- * of two. The hardware has no particular limitation. */
-#define BNXT_MAX_RXD	((INT32_MAX >> 1) + 1)
-#define BNXT_MAX_TXD	((INT32_MAX >> 1) + 1)
-
-#define CSUM_OFFLOAD		(CSUM_IP_TSO|CSUM_IP6_TSO|CSUM_IP| \
-				 CSUM_IP_UDP|CSUM_IP_TCP|CSUM_IP_SCTP| \
-				 CSUM_IP6_UDP|CSUM_IP6_TCP|CSUM_IP6_SCTP)
-
-#define BNXT_MAX_MTU	9000
-
-#define BNXT_RSS_HASH_TYPE_TCPV4	0
-#define BNXT_RSS_HASH_TYPE_UDPV4	1
-#define BNXT_RSS_HASH_TYPE_IPV4		2
-#define BNXT_RSS_HASH_TYPE_TCPV6	3
-#define BNXT_RSS_HASH_TYPE_UDPV6	4
-#define BNXT_RSS_HASH_TYPE_IPV6		5
-#define BNXT_GET_RSS_PROFILE_ID(rss_hash_type) ((rss_hash_type >> 1) & 0x1F)
-
-#define BNXT_NO_MORE_WOL_FILTERS	0xFFFF
-#define bnxt_wol_supported(softc)	(!((softc)->flags & BNXT_FLAG_VF) && \
-					  ((softc)->flags & BNXT_FLAG_WOL_CAP ))
-
-/* 64-bit doorbell */
-#define DBR_INDEX_MASK                                  0x0000000000ffffffULL
-#define DBR_PI_LO_MASK                                  0xff000000UL
-#define DBR_PI_LO_SFT                                   24
-#define DBR_XID_MASK                                    0x000fffff00000000ULL
-#define DBR_XID_SFT                                     32
-#define DBR_PI_HI_MASK                                  0xf0000000000000ULL
-#define DBR_PI_HI_SFT                                   52
-#define DBR_PATH_L2                                     (0x1ULL << 56)
-#define DBR_VALID                                       (0x1ULL << 58)
-#define DBR_TYPE_SQ                                     (0x0ULL << 60)
-#define DBR_TYPE_RQ                                     (0x1ULL << 60)
-#define DBR_TYPE_SRQ                                    (0x2ULL << 60)
-#define DBR_TYPE_SRQ_ARM                                (0x3ULL << 60)
-#define DBR_TYPE_CQ                                     (0x4ULL << 60)
-#define DBR_TYPE_CQ_ARMSE                               (0x5ULL << 60)
-#define DBR_TYPE_CQ_ARMALL                              (0x6ULL << 60)
-#define DBR_TYPE_CQ_ARMENA                              (0x7ULL << 60)
-#define DBR_TYPE_SRQ_ARMENA                             (0x8ULL << 60)
-#define DBR_TYPE_CQ_CUTOFF_ACK                          (0x9ULL << 60)
-#define DBR_TYPE_NQ                                     (0xaULL << 60)
-#define DBR_TYPE_NQ_ARM                                 (0xbULL << 60)
-#define DBR_TYPE_PUSH_START                             (0xcULL << 60)
-#define DBR_TYPE_PUSH_END                               (0xdULL << 60)
-#define DBR_TYPE_NULL                                   (0xfULL << 60)
-
-#define BNXT_MAX_NUM_QUEUES 32
-
-/* Completion related defines */
-#define CMP_VALID(cmp, v_bit) \
-	((!!(((struct cmpl_base *)(cmp))->info3_v & htole32(CMPL_BASE_V))) == !!(v_bit) )
-
-/* Chip class phase 5 */
-#define BNXT_CHIP_P5(sc) ((softc->flags & BNXT_FLAG_CHIP_P5))
-
-#define DB_PF_OFFSET_P5                                 0x10000
-#define NQ_VALID(cmp, v_bit) \
-	((!!(((nq_cn_t *)(cmp))->v & htole32(NQ_CN_V))) == !!(v_bit) )
-
-#ifndef DIV_ROUND_UP
-#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
-#endif
-#ifndef roundup
-#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
-#endif
-
-#define NEXT_CP_CONS_V(ring, cons, v_bit) do {				    \
-	if (__predict_false(++(cons) == (ring)->ring_size))		    \
-		((cons) = 0, (v_bit) = !v_bit);				    \
-} while (0)
-
-#define RING_NEXT(ring, idx) (__predict_false(idx + 1 == (ring)->ring_size) ? \
-								0 : idx + 1)
-
-#define CMPL_PREFETCH_NEXT(cpr, idx)					    \
-	__builtin_prefetch(&((struct cmpl_base *)(cpr)->ring.vaddr)[((idx) +\
-	    (CACHE_LINE_SIZE / sizeof(struct cmpl_base))) &		    \
-	    ((cpr)->ring.ring_size - 1)])
-
-/* Lock macros */
-#define BNXT_HWRM_LOCK_INIT(_softc, _name) \
-    mtx_init(&(_softc)->hwrm_lock, _name, "BNXT HWRM Lock", MTX_DEF)
-#define BNXT_HWRM_LOCK(_softc)		mtx_lock(&(_softc)->hwrm_lock)
-#define BNXT_HWRM_UNLOCK(_softc)	mtx_unlock(&(_softc)->hwrm_lock)
-#define BNXT_HWRM_LOCK_DESTROY(_softc)	mtx_destroy(&(_softc)->hwrm_lock)
-#define BNXT_HWRM_LOCK_ASSERT(_softc)	mtx_assert(&(_softc)->hwrm_lock,    \
-    MA_OWNED)
-#define BNXT_IS_FLOW_CTRL_CHANGED(link_info)				    \
-	((link_info->last_flow_ctrl.tx != link_info->flow_ctrl.tx) ||       \
-         (link_info->last_flow_ctrl.rx != link_info->flow_ctrl.rx) ||       \
-	 (link_info->last_flow_ctrl.autoneg != link_info->flow_ctrl.autoneg))
-
-/* Chip info */
-#define BNXT_TSO_SIZE	UINT16_MAX
-
-#define min_t(type, x, y) ({                    \
-        type __min1 = (x);                      \
-        type __min2 = (y);                      \
-        __min1 < __min2 ? __min1 : __min2; })
-
-#define max_t(type, x, y) ({                    \
-        type __max1 = (x);                      \
-        type __max2 = (y);                      \
-        __max1 > __max2 ? __max1 : __max2; })
-
-#define clamp_t(type, _x, min, max)     min_t(type, max_t(type, _x, min), max)
-
-#define BNXT_IFMEDIA_ADD(supported, fw_speed, ifm_speed) do {			\
-	if ((supported) & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_ ## fw_speed)	\
-		ifmedia_add(softc->media, IFM_ETHER | (ifm_speed), 0, NULL);	\
-} while(0)
-
-#define BNXT_MIN_FRAME_SIZE	52	/* Frames must be padded to this size for some A0 chips */
-
-extern const char bnxt_driver_version[];
-typedef void (*bnxt_doorbell_tx)(void *, uint16_t idx);
-typedef void (*bnxt_doorbell_rx)(void *, uint16_t idx);
-typedef void (*bnxt_doorbell_rx_cq)(void *, bool);
-typedef void (*bnxt_doorbell_tx_cq)(void *, bool);
-typedef void (*bnxt_doorbell_nq)(void *, bool);
-
-typedef struct bnxt_doorbell_ops {
-        bnxt_doorbell_tx bnxt_db_tx;
-        bnxt_doorbell_rx bnxt_db_rx;
-        bnxt_doorbell_rx_cq bnxt_db_rx_cq;
-        bnxt_doorbell_tx_cq bnxt_db_tx_cq;
-        bnxt_doorbell_nq bnxt_db_nq;
-} bnxt_dooorbell_ops_t;
-/* NVRAM access */
-enum bnxt_nvm_directory_type {
-	BNX_DIR_TYPE_UNUSED = 0,
-	BNX_DIR_TYPE_PKG_LOG = 1,
-	BNX_DIR_TYPE_UPDATE = 2,
-	BNX_DIR_TYPE_CHIMP_PATCH = 3,
-	BNX_DIR_TYPE_BOOTCODE = 4,
-	BNX_DIR_TYPE_VPD = 5,
-	BNX_DIR_TYPE_EXP_ROM_MBA = 6,
-	BNX_DIR_TYPE_AVS = 7,
-	BNX_DIR_TYPE_PCIE = 8,
-	BNX_DIR_TYPE_PORT_MACRO = 9,
-	BNX_DIR_TYPE_APE_FW = 10,
-	BNX_DIR_TYPE_APE_PATCH = 11,
-	BNX_DIR_TYPE_KONG_FW = 12,
-	BNX_DIR_TYPE_KONG_PATCH = 13,
-	BNX_DIR_TYPE_BONO_FW = 14,
-	BNX_DIR_TYPE_BONO_PATCH = 15,
-	BNX_DIR_TYPE_TANG_FW = 16,
-	BNX_DIR_TYPE_TANG_PATCH = 17,
-	BNX_DIR_TYPE_BOOTCODE_2 = 18,
-	BNX_DIR_TYPE_CCM = 19,
-	BNX_DIR_TYPE_PCI_CFG = 20,
-	BNX_DIR_TYPE_TSCF_UCODE = 21,
-	BNX_DIR_TYPE_ISCSI_BOOT = 22,
-	BNX_DIR_TYPE_ISCSI_BOOT_IPV6 = 24,
-	BNX_DIR_TYPE_ISCSI_BOOT_IPV4N6 = 25,
-	BNX_DIR_TYPE_ISCSI_BOOT_CFG6 = 26,
-	BNX_DIR_TYPE_EXT_PHY = 27,
-	BNX_DIR_TYPE_SHARED_CFG = 40,
-	BNX_DIR_TYPE_PORT_CFG = 41,
-	BNX_DIR_TYPE_FUNC_CFG = 42,
-	BNX_DIR_TYPE_MGMT_CFG = 48,
-	BNX_DIR_TYPE_MGMT_DATA = 49,
-	BNX_DIR_TYPE_MGMT_WEB_DATA = 50,
-	BNX_DIR_TYPE_MGMT_WEB_META = 51,
-	BNX_DIR_TYPE_MGMT_EVENT_LOG = 52,
-	BNX_DIR_TYPE_MGMT_AUDIT_LOG = 53
-};
-
-enum bnxnvm_pkglog_field_index {
-	BNX_PKG_LOG_FIELD_IDX_INSTALLED_TIMESTAMP	= 0,
-	BNX_PKG_LOG_FIELD_IDX_PKG_DESCRIPTION		= 1,
-	BNX_PKG_LOG_FIELD_IDX_PKG_VERSION		= 2,
-	BNX_PKG_LOG_FIELD_IDX_PKG_TIMESTAMP		= 3,
-	BNX_PKG_LOG_FIELD_IDX_PKG_CHECKSUM		= 4,
-	BNX_PKG_LOG_FIELD_IDX_INSTALLED_ITEMS		= 5,
-	BNX_PKG_LOG_FIELD_IDX_INSTALLED_MASK		= 6
-};
-
-#define BNX_DIR_ORDINAL_FIRST		0
-#define BNX_DIR_EXT_NONE		0
-
-struct bnxt_bar_info {
-	struct resource		*res;
-	bus_space_tag_t		tag;
-	bus_space_handle_t	handle;
-	bus_size_t		size;
-	int			rid;
-};
-
-struct bnxt_flow_ctrl {
-	bool rx;
-	bool tx;
-	bool autoneg;
-};
-
-struct bnxt_link_info {
-	uint8_t		media_type;
-	uint8_t		transceiver;
-	uint8_t		phy_addr;
-	uint8_t		phy_link_status;
-	uint8_t		wire_speed;
-	uint8_t		loop_back;
-	uint8_t		link_up;
-	uint8_t		last_link_up;
-	uint8_t		duplex;
-	uint8_t		last_duplex;
-	struct bnxt_flow_ctrl   flow_ctrl;
-	struct bnxt_flow_ctrl   last_flow_ctrl;
-	uint8_t		duplex_setting;
-	uint8_t		auto_mode;
-#define PHY_VER_LEN		3
-	uint8_t		phy_ver[PHY_VER_LEN];
-	uint8_t		phy_type;
-	uint16_t	link_speed;
-	uint16_t	support_speeds;
-	uint16_t	auto_link_speeds;
-	uint16_t	auto_link_speed;
-	uint16_t	force_link_speed;
-	uint32_t	preemphasis;
-
-	/* copy of requested setting */
-	uint8_t		autoneg;
-#define BNXT_AUTONEG_SPEED	1
-#define BNXT_AUTONEG_FLOW_CTRL	2
-	uint8_t		req_duplex;
-	uint16_t	req_link_speed;
-};
-
-enum bnxt_cp_type {
-	BNXT_DEFAULT,
-	BNXT_TX,
-	BNXT_RX,
-	BNXT_SHARED
-};
-
-struct bnxt_cos_queue {
-	uint8_t	id;
-	uint8_t	profile;
-};
-
-struct bnxt_func_info {
-	uint32_t	fw_fid;
-	uint8_t		mac_addr[ETHER_ADDR_LEN];
-	uint16_t	max_rsscos_ctxs;
-	uint16_t	max_cp_rings;
-	uint16_t	max_tx_rings;
-	uint16_t	max_rx_rings;
-	uint16_t	max_hw_ring_grps;
-	uint16_t	max_irqs;
-	uint16_t	max_l2_ctxs;
-	uint16_t	max_vnics;
-	uint16_t	max_stat_ctxs;
-};
-
-struct bnxt_pf_info {
-#define BNXT_FIRST_PF_FID	1
-#define BNXT_FIRST_VF_FID	128
-	uint8_t		port_id;
-	uint32_t	first_vf_id;
-	uint16_t	active_vfs;
-	uint16_t	max_vfs;
-	uint32_t	max_encap_records;
-	uint32_t	max_decap_records;
-	uint32_t	max_tx_em_flows;
-	uint32_t	max_tx_wm_flows;
-	uint32_t	max_rx_em_flows;
-	uint32_t	max_rx_wm_flows;
-	unsigned long	*vf_event_bmap;
-	uint16_t	hwrm_cmd_req_pages;
-	void		*hwrm_cmd_req_addr[4];
-	bus_addr_t	hwrm_cmd_req_dma_addr[4];
-};
-
-struct bnxt_vf_info {
-	uint16_t	fw_fid;
-	uint8_t		mac_addr[ETHER_ADDR_LEN];
-	uint16_t	max_rsscos_ctxs;
-	uint16_t	max_cp_rings;
-	uint16_t	max_tx_rings;
-	uint16_t	max_rx_rings;
-	uint16_t	max_hw_ring_grps;
-	uint16_t	max_l2_ctxs;
-	uint16_t	max_irqs;
-	uint16_t	max_vnics;
-	uint16_t	max_stat_ctxs;
-	uint32_t	vlan;
-#define BNXT_VF_QOS		0x1
-#define BNXT_VF_SPOOFCHK	0x2
-#define BNXT_VF_LINK_FORCED	0x4
-#define BNXT_VF_LINK_UP		0x8
-	uint32_t	flags;
-	uint32_t	func_flags; /* func cfg flags */
-	uint32_t	min_tx_rate;
-	uint32_t	max_tx_rate;
-	void		*hwrm_cmd_req_addr;
-	bus_addr_t	hwrm_cmd_req_dma_addr;
-};
-
-#define BNXT_PF(softc)		(!((softc)->flags & BNXT_FLAG_VF))
-#define BNXT_VF(softc)		((softc)->flags & BNXT_FLAG_VF)
-
-struct bnxt_vlan_tag {
-	SLIST_ENTRY(bnxt_vlan_tag) next;
-	uint64_t	filter_id;
-	uint16_t	tag;
-};
-
-struct bnxt_vnic_info {
-	uint16_t	id;
-	uint16_t	def_ring_grp;
-	uint16_t	cos_rule;
-	uint16_t	lb_rule;
-	uint16_t	mru;
-
-	uint32_t	rx_mask;
-	struct iflib_dma_info mc_list;
-	int		mc_list_count;
-#define BNXT_MAX_MC_ADDRS		16
-
-	uint32_t	flags;
-#define BNXT_VNIC_FLAG_DEFAULT		0x01
-#define BNXT_VNIC_FLAG_BD_STALL		0x02
-#define BNXT_VNIC_FLAG_VLAN_STRIP	0x04
-
-	uint64_t	filter_id;
-
-	uint16_t	rss_id;
-	uint32_t	rss_hash_type;
-	uint8_t		rss_hash_key[HW_HASH_KEY_SIZE];
-	struct iflib_dma_info rss_hash_key_tbl;
-	struct iflib_dma_info	rss_grp_tbl;
-	SLIST_HEAD(vlan_head, bnxt_vlan_tag) vlan_tags;
-	struct iflib_dma_info vlan_tag_list;
-};
-
-struct bnxt_grp_info {
-	uint16_t	stats_ctx;
-	uint16_t	grp_id;
-	uint16_t	rx_ring_id;
-	uint16_t	cp_ring_id;
-	uint16_t	ag_ring_id;
-};
-
-struct bnxt_ring {
-	uint64_t		paddr;
-	vm_offset_t		doorbell;
-	caddr_t			vaddr;
-	struct bnxt_softc	*softc;
-	uint32_t		ring_size;	/* Must be a power of two */
-	uint16_t		id;		/* Logical ID */
-	uint16_t		phys_id;
-	uint16_t		idx;
-	struct bnxt_full_tpa_start *tpa_start;
-};
-
-struct bnxt_cp_ring {
-	struct bnxt_ring	ring;
-	struct if_irq		irq;
-	uint32_t		cons;
-	bool			v_bit;		/* Value of valid bit */
-	struct ctx_hw_stats	*stats;
-	uint32_t		stats_ctx_id;
-	uint32_t		last_idx;	/* Used by RX rings only
-						 * set to the last read pidx
-						 */
-	uint64_t 		int_count;
-};
-
-struct bnxt_full_tpa_start {
-	struct rx_tpa_start_cmpl low;
-	struct rx_tpa_start_cmpl_hi high;
-};
-
-/* All the version information for the part */
-#define BNXT_VERSTR_SIZE	(3*3+2+1)	/* ie: "255.255.255\0" */
-#define BNXT_NAME_SIZE		17
-#define FW_VER_STR_LEN          32
-#define BC_HWRM_STR_LEN         21
-struct bnxt_ver_info {
-	uint8_t		hwrm_if_major;
-	uint8_t		hwrm_if_minor;
-	uint8_t		hwrm_if_update;
-	char		hwrm_if_ver[BNXT_VERSTR_SIZE];
-	char		driver_hwrm_if_ver[BNXT_VERSTR_SIZE];
-	char		hwrm_fw_ver[BNXT_VERSTR_SIZE];
-	char		mgmt_fw_ver[BNXT_VERSTR_SIZE];
-	char		netctrl_fw_ver[BNXT_VERSTR_SIZE];
-	char		roce_fw_ver[BNXT_VERSTR_SIZE];
-	char		fw_ver_str[FW_VER_STR_LEN];
-	char		phy_ver[BNXT_VERSTR_SIZE];
-	char		pkg_ver[64];
-
-	char		hwrm_fw_name[BNXT_NAME_SIZE];
-	char		mgmt_fw_name[BNXT_NAME_SIZE];
-	char		netctrl_fw_name[BNXT_NAME_SIZE];
-	char		roce_fw_name[BNXT_NAME_SIZE];
-	char		phy_vendor[BNXT_NAME_SIZE];
-	char		phy_partnumber[BNXT_NAME_SIZE];
-
-	uint16_t	chip_num;
-	uint8_t		chip_rev;
-	uint8_t		chip_metal;
-	uint8_t		chip_bond_id;
-	uint8_t		chip_type;
-
-	uint8_t		hwrm_min_major;
-	uint8_t		hwrm_min_minor;
-	uint8_t		hwrm_min_update;
-
-	struct sysctl_ctx_list	ver_ctx;
-	struct sysctl_oid	*ver_oid;
-};
-
-struct bnxt_nvram_info {
-	uint16_t	mfg_id;
-	uint16_t	device_id;
-	uint32_t	sector_size;
-	uint32_t	size;
-	uint32_t	reserved_size;
-	uint32_t	available_size;
-
-	struct sysctl_ctx_list	nvm_ctx;
-	struct sysctl_oid	*nvm_oid;
-};
-
-struct bnxt_func_qcfg {
-	uint16_t alloc_completion_rings;
-	uint16_t alloc_tx_rings;
-	uint16_t alloc_rx_rings;
-	uint16_t alloc_vnics;
-};
-
-struct bnxt_hw_lro {
-	uint16_t enable;
-	uint16_t is_mode_gro;
-	uint16_t max_agg_segs;
-	uint16_t max_aggs;
-	uint32_t min_agg_len;
-};
-
-/* The hardware supports certain page sizes.  Use the supported page sizes
- * to allocate the rings.
- */
-#if (PAGE_SHIFT < 12)
-#define BNXT_PAGE_SHIFT 12
-#elif (PAGE_SHIFT <= 13)
-#define BNXT_PAGE_SHIFT PAGE_SHIFT
-#elif (PAGE_SHIFT < 16)
-#define BNXT_PAGE_SHIFT 13
-#else
-#define BNXT_PAGE_SHIFT 16
-#endif
-
-#define BNXT_PAGE_SIZE  (1 << BNXT_PAGE_SHIFT)
-
-#define MAX_CTX_PAGES	(BNXT_PAGE_SIZE / 8)
-#define MAX_CTX_TOTAL_PAGES	(MAX_CTX_PAGES * MAX_CTX_PAGES)
-struct bnxt_ring_mem_info {
-        int                     nr_pages;
-        int                     page_size;
-        uint16_t                     flags;
-#define BNXT_RMEM_VALID_PTE_FLAG        1
-#define BNXT_RMEM_RING_PTE_FLAG         2
-#define BNXT_RMEM_USE_FULL_PAGE_FLAG    4
-        uint16_t		depth;
-	uint8_t			init_val;
-        struct iflib_dma_info	*pg_arr;
-        struct iflib_dma_info	pg_tbl;
-        int                     vmem_size;
-        void                    **vmem;
-};
-
-struct bnxt_ctx_pg_info {
-	uint32_t		entries;
-	uint32_t		nr_pages;
-	struct iflib_dma_info   ctx_arr[MAX_CTX_PAGES];
-	struct bnxt_ring_mem_info ring_mem;
-	struct bnxt_ctx_pg_info **ctx_pg_tbl;
-};
-
-struct bnxt_ctx_mem_info {
-	uint32_t	qp_max_entries;
-	uint16_t	qp_min_qp1_entries;
-	uint16_t	qp_max_l2_entries;
-	uint16_t	qp_entry_size;
-	uint16_t	srq_max_l2_entries;
-	uint32_t	srq_max_entries;
-	uint16_t	srq_entry_size;
-	uint16_t	cq_max_l2_entries;
-	uint32_t	cq_max_entries;
-	uint16_t	cq_entry_size;
-	uint16_t	vnic_max_vnic_entries;
-	uint16_t	vnic_max_ring_table_entries;
-	uint16_t	vnic_entry_size;
-	uint32_t	stat_max_entries;
-	uint16_t	stat_entry_size;
-	uint16_t	tqm_entry_size;
-	uint32_t	tqm_min_entries_per_ring;
-	uint32_t	tqm_max_entries_per_ring;
-	uint32_t	mrav_max_entries;
-	uint16_t	mrav_entry_size;
-	uint16_t	tim_entry_size;
-	uint32_t	tim_max_entries;
-	uint8_t		tqm_entries_multiple;
-	uint8_t		ctx_kind_initializer;
-
-	uint32_t	flags;
-	#define BNXT_CTX_FLAG_INITED	0x01
-
-	struct bnxt_ctx_pg_info qp_mem;
-	struct bnxt_ctx_pg_info srq_mem;
-	struct bnxt_ctx_pg_info cq_mem;
-	struct bnxt_ctx_pg_info vnic_mem;
-	struct bnxt_ctx_pg_info stat_mem;
-	struct bnxt_ctx_pg_info mrav_mem;
-	struct bnxt_ctx_pg_info tim_mem;
-	struct bnxt_ctx_pg_info *tqm_mem[9];
-};
-
-struct bnxt_hw_resc {
-        uint16_t     min_rsscos_ctxs;
-        uint16_t     max_rsscos_ctxs;
-        uint16_t     min_cp_rings;
-        uint16_t     max_cp_rings;
-        uint16_t     resv_cp_rings;
-        uint16_t     min_tx_rings;
-        uint16_t     max_tx_rings;
-        uint16_t     resv_tx_rings;
-        uint16_t     max_tx_sch_inputs;
-        uint16_t     min_rx_rings;
-        uint16_t     max_rx_rings;
-        uint16_t     resv_rx_rings;
-        uint16_t     min_hw_ring_grps;
-        uint16_t     max_hw_ring_grps;
-        uint16_t     resv_hw_ring_grps;
-        uint16_t     min_l2_ctxs;
-        uint16_t     max_l2_ctxs;
-        uint16_t     min_vnics;
-        uint16_t     max_vnics;
-        uint16_t     resv_vnics;
-        uint16_t     min_stat_ctxs;
-        uint16_t     max_stat_ctxs;
-        uint16_t     resv_stat_ctxs;
-        uint16_t     max_nqs;
-        uint16_t     max_irqs;
-        uint16_t     resv_irqs;
-};
-
-#define BNXT_LLQ(q_profile)     \
-        ((q_profile) == HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_LOSSLESS_ROCE)
-#define BNXT_CNPQ(q_profile)    \
-        ((q_profile) == HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_LOSSY_ROCE_CNP)
-
-#define BNXT_HWRM_MAX_REQ_LEN		(softc->hwrm_max_req_len)
-
-struct bnxt_softc_list {
-	SLIST_ENTRY(bnxt_softc_list) next;
-	struct bnxt_softc *softc;
-};
-
-struct bnxt_softc {
-	device_t	dev;
-	if_ctx_t	ctx;
-	if_softc_ctx_t	scctx;
-	if_shared_ctx_t	sctx;
-	uint32_t	domain;
-	uint32_t	bus;
-	uint32_t	slot;
-	uint32_t	function;
-	uint32_t	dev_fn;
-	struct ifmedia	*media;
-	struct bnxt_ctx_mem_info *ctx_mem;
-	struct bnxt_hw_resc hw_resc;
-	struct bnxt_softc_list list;
-
-	struct bnxt_bar_info	hwrm_bar;
-	struct bnxt_bar_info	doorbell_bar;
-	struct bnxt_link_info	link_info;
-#define BNXT_FLAG_VF		0x0001
-#define BNXT_FLAG_NPAR		0x0002
-#define BNXT_FLAG_WOL_CAP	0x0004
-#define BNXT_FLAG_SHORT_CMD	0x0008
-#define BNXT_FLAG_FW_CAP_NEW_RM 0x0010
-#define BNXT_FLAG_CHIP_P5 	0x0020
-#define BNXT_FLAG_TPA	 	0x0040
-	uint32_t		flags;
-#define BNXT_STATE_LINK_CHANGE  (0)
-#define BNXT_STATE_MAX		(BNXT_STATE_LINK_CHANGE + 1)
-	bitstr_t 		*state_bv;
-	uint32_t		total_msix;
-
-	struct bnxt_func_info	func;
-	struct bnxt_func_qcfg	fn_qcfg;
-	struct bnxt_pf_info	pf;
-	struct bnxt_vf_info	vf;
-
-	uint16_t		hwrm_cmd_seq;
-	uint32_t		hwrm_cmd_timeo;	/* milliseconds */
-	struct iflib_dma_info	hwrm_cmd_resp;
-	struct iflib_dma_info	hwrm_short_cmd_req_addr;
-	/* Interrupt info for HWRM */
-	struct if_irq		irq;
-	struct mtx		hwrm_lock;
-	uint16_t		hwrm_max_req_len;
-	uint16_t		hwrm_max_ext_req_len;
-	uint32_t		hwrm_spec_code;
-
-#define BNXT_MAX_COS_QUEUE	8
-	uint8_t			max_tc;
-        uint8_t			max_lltc;       /* lossless TCs */
-	struct bnxt_cos_queue	q_info[BNXT_MAX_COS_QUEUE];
-        uint8_t			tc_to_qidx[BNXT_MAX_COS_QUEUE];
-        uint8_t			q_ids[BNXT_MAX_COS_QUEUE];
-        uint8_t			max_q;
-
-	uint64_t		admin_ticks;
-	struct iflib_dma_info	hw_rx_port_stats;
-	struct iflib_dma_info	hw_tx_port_stats;
-	struct rx_port_stats	*rx_port_stats;
-	struct tx_port_stats	*tx_port_stats;
-
-	int			num_cp_rings;
-
-	struct bnxt_cp_ring	*nq_rings;
-
-	struct bnxt_ring	*tx_rings;
-	struct bnxt_cp_ring	*tx_cp_rings;
-	struct iflib_dma_info	tx_stats[BNXT_MAX_NUM_QUEUES];
-	int			ntxqsets;
-
-	struct bnxt_vnic_info	vnic_info;
-	struct bnxt_ring	*ag_rings;
-	struct bnxt_ring	*rx_rings;
-	struct bnxt_cp_ring	*rx_cp_rings;
-	struct bnxt_grp_info	*grp_info;
-	struct iflib_dma_info	rx_stats[BNXT_MAX_NUM_QUEUES];
-	int			nrxqsets;
-	uint16_t		rx_buf_size;
-
-	struct bnxt_cp_ring	def_cp_ring;
-	struct bnxt_cp_ring	def_nq_ring;
-	struct iflib_dma_info	def_cp_ring_mem;
-	struct iflib_dma_info	def_nq_ring_mem;
-	struct grouptask	def_cp_task;
-	struct bnxt_doorbell_ops db_ops;
-
-	struct sysctl_ctx_list	hw_stats;
-	struct sysctl_oid	*hw_stats_oid;
-	struct sysctl_ctx_list	hw_lro_ctx;
-	struct sysctl_oid	*hw_lro_oid;
-	struct sysctl_ctx_list	flow_ctrl_ctx;
-	struct sysctl_oid	*flow_ctrl_oid;
-
-	struct bnxt_ver_info	*ver_info;
-	struct bnxt_nvram_info	*nvm_info;
-	bool wol;
-	bool is_dev_init;
-	struct bnxt_hw_lro	hw_lro;
-	uint8_t wol_filter_id;
-	uint16_t		rx_coal_usecs;
-	uint16_t		rx_coal_usecs_irq;
-	uint16_t               	rx_coal_frames;
-	uint16_t               	rx_coal_frames_irq;
-	uint16_t               	tx_coal_usecs;
-	uint16_t               	tx_coal_usecs_irq;
-	uint16_t               	tx_coal_frames;
-	uint16_t               	tx_coal_frames_irq;
-
-#define BNXT_USEC_TO_COAL_TIMER(x)      ((x) * 25 / 2)
-#define BNXT_DEF_STATS_COAL_TICKS        1000000
-#define BNXT_MIN_STATS_COAL_TICKS         250000
-#define BNXT_MAX_STATS_COAL_TICKS        1000000
-
-};
-
-struct bnxt_filter_info {
-	STAILQ_ENTRY(bnxt_filter_info) next;
-	uint64_t	fw_l2_filter_id;
-#define INVALID_MAC_INDEX ((uint16_t)-1)
-	uint16_t	mac_index;
-
-	/* Filter Characteristics */
-	uint32_t	flags;
-	uint32_t	enables;
-	uint8_t		l2_addr[ETHER_ADDR_LEN];
-	uint8_t		l2_addr_mask[ETHER_ADDR_LEN];
-	uint16_t	l2_ovlan;
-	uint16_t	l2_ovlan_mask;
-	uint16_t	l2_ivlan;
-	uint16_t	l2_ivlan_mask;
-	uint8_t		t_l2_addr[ETHER_ADDR_LEN];
-	uint8_t		t_l2_addr_mask[ETHER_ADDR_LEN];
-	uint16_t	t_l2_ovlan;
-	uint16_t	t_l2_ovlan_mask;
-	uint16_t	t_l2_ivlan;
-	uint16_t	t_l2_ivlan_mask;
-	uint8_t		tunnel_type;
-	uint16_t	mirror_vnic_id;
-	uint32_t	vni;
-	uint8_t		pri_hint;
-	uint64_t	l2_filter_id_hint;
-};
-
-/* Function declarations */
-void bnxt_report_link(struct bnxt_softc *softc);
-bool bnxt_check_hwrm_version(struct bnxt_softc *softc);
-struct bnxt_softc *bnxt_find_dev(uint32_t domain, uint32_t bus, uint32_t dev_fn, char *name);
-
-#endif /* _BNXT_H */
diff --git a/sys/dev/bnxt/bnxt_en/bnxt.h b/sys/dev/bnxt/bnxt_en/bnxt.h
new file mode 100644
index 000000000000..cf4f99077b58
--- /dev/null
+++ b/sys/dev/bnxt/bnxt_en/bnxt.h
@@ -0,0 +1,1314 @@
+/*-
+ * Broadcom NetXtreme-C/E network driver.
+ *
+ * Copyright (c) 2016 Broadcom, All Rights Reserved.
+ * The term Broadcom refers to Broadcom Limited and/or its subsidiaries
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#ifndef _BNXT_H
+#define _BNXT_H
+
+#include <sys/param.h>
+#include <sys/socket.h>
+#include <sys/sysctl.h>
+#include <sys/taskqueue.h>
+#include <sys/bitstring.h>
+
+#include <machine/bus.h>
+
+#include <net/ethernet.h>
+#include <net/if.h>
+#include <net/if_var.h>
+#include <net/iflib.h>
+#include <linux/types.h>
+
+#include "hsi_struct_def.h"
+#include "bnxt_dcb.h"
+#include "bnxt_auxbus_compat.h"
+
+#define DFLT_HWRM_CMD_TIMEOUT		500
+
+/* PCI IDs */
+#define BROADCOM_VENDOR_ID	0x14E4
+
+#define BCM57301	0x16c8
+#define BCM57302	0x16c9
+#define BCM57304	0x16ca
+#define BCM57311	0x16ce
+#define BCM57312	0x16cf
+#define BCM57314	0x16df
+#define BCM57402	0x16d0
+#define BCM57402_NPAR	0x16d4
+#define BCM57404	0x16d1
+#define BCM57404_NPAR	0x16e7
+#define BCM57406	0x16d2
+#define BCM57406_NPAR	0x16e8
+#define BCM57407	0x16d5
+#define BCM57407_NPAR	0x16ea
+#define BCM57407_SFP	0x16e9
+#define BCM57412	0x16d6
+#define BCM57412_NPAR1	0x16de
+#define BCM57412_NPAR2	0x16eb
+#define BCM57414	0x16d7
+#define BCM57414_NPAR1	0x16ec
+#define BCM57414_NPAR2	0x16ed
+#define BCM57416	0x16d8
+#define BCM57416_NPAR1	0x16ee
+#define BCM57416_NPAR2	0x16ef
+#define BCM57416_SFP	0x16e3
+#define BCM57417	0x16d9
+#define BCM57417_NPAR1	0x16c0
+#define BCM57417_NPAR2	0x16cc
+#define BCM57417_SFP	0x16e2
+#define BCM57454	0x1614
+#define BCM58700	0x16cd
+#define BCM57508  	0x1750
+#define BCM57504  	0x1751
+#define BCM57502  	0x1752
+#define NETXTREME_C_VF1	0x16cb
+#define NETXTREME_C_VF2	0x16e1
+#define NETXTREME_C_VF3	0x16e5
+#define NETXTREME_E_VF1	0x16c1
+#define NETXTREME_E_VF2	0x16d3
+#define NETXTREME_E_VF3	0x16dc
+
+#define EVENT_DATA1_RESET_NOTIFY_FATAL(data1)				\
+	(((data1) &							\
+	  HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_MASK) ==\
+	 HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_FW_EXCEPTION_FATAL)
+
+#define BNXT_EVENT_ERROR_REPORT_TYPE(data1)						\
+	(((data1) &									\
+	  HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_MASK)  >>	\
+	 HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_SFT)
+
+#define BNXT_EVENT_INVALID_SIGNAL_DATA(data2)						\
+	(((data2) &									\
+	  HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_INVALID_SIGNAL_EVENT_DATA2_PIN_ID_MASK) >>	\
+	 HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_INVALID_SIGNAL_EVENT_DATA2_PIN_ID_SFT)
+
+#define BNXT_EVENT_DBR_EPOCH(data)										\
+	(((data) & HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DOORBELL_DROP_THRESHOLD_EVENT_DATA1_EPOCH_MASK) >>	\
+	 HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DOORBELL_DROP_THRESHOLD_EVENT_DATA1_EPOCH_SFT)
+
+#define BNXT_EVENT_THERMAL_THRESHOLD_TEMP(data2)						\
+	(((data2) &										\
+	  HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA2_THRESHOLD_TEMP_MASK) >>	\
+	 HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA2_THRESHOLD_TEMP_SFT)
+
+#define EVENT_DATA2_NVM_ERR_ADDR(data2)						\
+	(((data2) &								\
+	  HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_EVENT_DATA2_ERR_ADDR_MASK) >>	\
+	 HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_EVENT_DATA2_ERR_ADDR_SFT)
+
+#define EVENT_DATA1_THERMAL_THRESHOLD_DIR_INCREASING(data1)					\
+	(((data1) &										\
+	  HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_TRANSITION_DIR) ==		\
+	 HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_TRANSITION_DIR_INCREASING)
+
+#define EVENT_DATA1_NVM_ERR_TYPE_WRITE(data1)						\
+	(((data1) &									\
+	  HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_EVENT_DATA1_NVM_ERR_TYPE_MASK) ==	\
+	 HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_EVENT_DATA1_NVM_ERR_TYPE_WRITE)
+
+#define EVENT_DATA1_NVM_ERR_TYPE_ERASE(data1)						\
+	(((data1) &									\
+	  HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_EVENT_DATA1_NVM_ERR_TYPE_MASK) ==	\
+	 HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_EVENT_DATA1_NVM_ERR_TYPE_ERASE)
+
+#define EVENT_DATA1_THERMAL_THRESHOLD_TYPE(data1)			\
+	((data1) & HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_THRESHOLD_TYPE_MASK)
+
+#define BNXT_EVENT_THERMAL_CURRENT_TEMP(data2)				\
+	((data2) & HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA2_CURRENT_TEMP_MASK)
+
+#define EVENT_DATA1_RESET_NOTIFY_FW_ACTIVATION(data1)                   \
+	(((data1) &                                                     \
+	  HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_MASK) ==\
+	HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_FW_ACTIVATION)
+
+#define EVENT_DATA2_RESET_NOTIFY_FW_STATUS_CODE(data2)                  \
+	((data2) &                                                      \
+	HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA2_FW_STATUS_CODE_MASK)
+
+#define EVENT_DATA1_RECOVERY_ENABLED(data1)				\
+	!!((data1) &							\
+	   HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_EVENT_DATA1_FLAGS_RECOVERY_ENABLED)
+
+#define EVENT_DATA1_RECOVERY_MASTER_FUNC(data1)				\
+	!!((data1) &							\
+	   HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_EVENT_DATA1_FLAGS_MASTER_FUNC)
+
+#define INVALID_STATS_CTX_ID     -1
+
+/* Maximum numbers of RX and TX descriptors. iflib requires this to be a power
+ * of two. The hardware has no particular limitation. */
+#define BNXT_MAX_RXD	((INT32_MAX >> 1) + 1)
+#define BNXT_MAX_TXD	((INT32_MAX >> 1) + 1)
+
+#define CSUM_OFFLOAD		(CSUM_IP_TSO|CSUM_IP6_TSO|CSUM_IP| \
+				 CSUM_IP_UDP|CSUM_IP_TCP|CSUM_IP_SCTP| \
+				 CSUM_IP6_UDP|CSUM_IP6_TCP|CSUM_IP6_SCTP)
+
+#define BNXT_MAX_MTU	9600
+
+#define BNXT_RSS_HASH_TYPE_TCPV4	0
+#define BNXT_RSS_HASH_TYPE_UDPV4	1
+#define BNXT_RSS_HASH_TYPE_IPV4		2
+#define BNXT_RSS_HASH_TYPE_TCPV6	3
+#define BNXT_RSS_HASH_TYPE_UDPV6	4
+#define BNXT_RSS_HASH_TYPE_IPV6		5
+#define BNXT_GET_RSS_PROFILE_ID(rss_hash_type) ((rss_hash_type >> 1) & 0x1F)
+
+#define BNXT_NO_MORE_WOL_FILTERS	0xFFFF
+#define bnxt_wol_supported(softc)	(!((softc)->flags & BNXT_FLAG_VF) && \
+					  ((softc)->flags & BNXT_FLAG_WOL_CAP ))
+
+/* 64-bit doorbell */
+#define DBR_INDEX_MASK                                  0x0000000000ffffffULL
+#define DBR_PI_LO_MASK                                  0xff000000UL
+#define DBR_PI_LO_SFT                                   24
+#define DBR_XID_MASK                                    0x000fffff00000000ULL
+#define DBR_XID_SFT                                     32
+#define DBR_PI_HI_MASK                                  0xf0000000000000ULL
+#define DBR_PI_HI_SFT                                   52
+#define DBR_PATH_L2                                     (0x1ULL << 56)
+#define DBR_VALID                                       (0x1ULL << 58)
+#define DBR_TYPE_SQ                                     (0x0ULL << 60)
+#define DBR_TYPE_RQ                                     (0x1ULL << 60)
+#define DBR_TYPE_SRQ                                    (0x2ULL << 60)
+#define DBR_TYPE_SRQ_ARM                                (0x3ULL << 60)
+#define DBR_TYPE_CQ                                     (0x4ULL << 60)
+#define DBR_TYPE_CQ_ARMSE                               (0x5ULL << 60)
+#define DBR_TYPE_CQ_ARMALL                              (0x6ULL << 60)
+#define DBR_TYPE_CQ_ARMENA                              (0x7ULL << 60)
+#define DBR_TYPE_SRQ_ARMENA                             (0x8ULL << 60)
+#define DBR_TYPE_CQ_CUTOFF_ACK                          (0x9ULL << 60)
+#define DBR_TYPE_NQ                                     (0xaULL << 60)
+#define DBR_TYPE_NQ_ARM                                 (0xbULL << 60)
+#define DBR_TYPE_PUSH_START                             (0xcULL << 60)
+#define DBR_TYPE_PUSH_END                               (0xdULL << 60)
+#define DBR_TYPE_NULL                                   (0xfULL << 60)
+
+#define BNXT_MAX_L2_QUEUES				128
+#define BNXT_ROCE_IRQ_COUNT				9
+
+#define BNXT_MAX_NUM_QUEUES (BNXT_MAX_L2_QUEUES + BNXT_ROCE_IRQ_COUNT)
+
+/* Completion related defines */
+#define CMP_VALID(cmp, v_bit) \
+	((!!(((struct cmpl_base *)(cmp))->info3_v & htole32(CMPL_BASE_V))) == !!(v_bit) )
+
+/* Chip class phase 5 */
+#define BNXT_CHIP_P5(sc) ((sc->flags & BNXT_FLAG_CHIP_P5))
+
+#define DB_PF_OFFSET_P5                                 0x10000
+#define DB_VF_OFFSET_P5                                 0x4000
+#define NQ_VALID(cmp, v_bit) \
+	((!!(((nq_cn_t *)(cmp))->v & htole32(NQ_CN_V))) == !!(v_bit) )
+
+#ifndef DIV_ROUND_UP
+#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
+#endif
+#ifndef roundup
+#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
+#endif
+
+#define NEXT_CP_CONS_V(ring, cons, v_bit) do {				    \
+	if (__predict_false(++(cons) == (ring)->ring_size))		    \
+		((cons) = 0, (v_bit) = !v_bit);				    \
+} while (0)
+
+#define RING_NEXT(ring, idx) (__predict_false(idx + 1 == (ring)->ring_size) ? \
+								0 : idx + 1)
+
+#define CMPL_PREFETCH_NEXT(cpr, idx)					    \
+	__builtin_prefetch(&((struct cmpl_base *)(cpr)->ring.vaddr)[((idx) +\
+	    (CACHE_LINE_SIZE / sizeof(struct cmpl_base))) &		    \
+	    ((cpr)->ring.ring_size - 1)])
+
+/* Lock macros */
+#define BNXT_HWRM_LOCK_INIT(_softc, _name) \
+    mtx_init(&(_softc)->hwrm_lock, _name, "BNXT HWRM Lock", MTX_DEF)
+#define BNXT_HWRM_LOCK(_softc)		mtx_lock(&(_softc)->hwrm_lock)
+#define BNXT_HWRM_UNLOCK(_softc)	mtx_unlock(&(_softc)->hwrm_lock)
+#define BNXT_HWRM_LOCK_DESTROY(_softc)	mtx_destroy(&(_softc)->hwrm_lock)
+#define BNXT_HWRM_LOCK_ASSERT(_softc)	mtx_assert(&(_softc)->hwrm_lock,    \
+    MA_OWNED)
+#define BNXT_IS_FLOW_CTRL_CHANGED(link_info)				    \
+	((link_info->last_flow_ctrl.tx != link_info->flow_ctrl.tx) ||       \
+         (link_info->last_flow_ctrl.rx != link_info->flow_ctrl.rx) ||       \
+	 (link_info->last_flow_ctrl.autoneg != link_info->flow_ctrl.autoneg))
+
+/* Chip info */
+#define BNXT_TSO_SIZE	UINT16_MAX
+
+#define min_t(type, x, y) ({                    \
+        type __min1 = (x);                      \
+        type __min2 = (y);                      \
+        __min1 < __min2 ? __min1 : __min2; })
+
+#define max_t(type, x, y) ({                    \
+        type __max1 = (x);                      \
+        type __max2 = (y);                      \
+        __max1 > __max2 ? __max1 : __max2; })
+
+#define clamp_t(type, _x, min, max)     min_t(type, max_t(type, _x, min), max)
+
+#define BNXT_IFMEDIA_ADD(supported, fw_speed, ifm_speed) do {			\
+	if ((supported) & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_ ## fw_speed)	\
+		ifmedia_add(softc->media, IFM_ETHER | (ifm_speed), 0, NULL);	\
+} while(0)
+
+#define BNXT_MIN_FRAME_SIZE	52	/* Frames must be padded to this size for some A0 chips */
+
+#define BNXT_RX_STATS_EXT_OFFSET(counter)		\
+	(offsetof(struct rx_port_stats_ext, counter) / 8)
+
+#define BNXT_RX_STATS_EXT_NUM_LEGACY			\
+	BNXT_RX_STATS_EXT_OFFSET(rx_fec_corrected_blocks)
+
+#define BNXT_TX_STATS_EXT_OFFSET(counter)		\
+	(offsetof(struct tx_port_stats_ext, counter) / 8)
+
+extern const char bnxt_driver_version[];
+typedef void (*bnxt_doorbell_tx)(void *, uint16_t idx);
+typedef void (*bnxt_doorbell_rx)(void *, uint16_t idx);
+typedef void (*bnxt_doorbell_rx_cq)(void *, bool);
+typedef void (*bnxt_doorbell_tx_cq)(void *, bool);
+typedef void (*bnxt_doorbell_nq)(void *, bool);
+
+typedef struct bnxt_doorbell_ops {
+        bnxt_doorbell_tx bnxt_db_tx;
+        bnxt_doorbell_rx bnxt_db_rx;
+        bnxt_doorbell_rx_cq bnxt_db_rx_cq;
+        bnxt_doorbell_tx_cq bnxt_db_tx_cq;
+        bnxt_doorbell_nq bnxt_db_nq;
+} bnxt_dooorbell_ops_t;
+/* NVRAM access */
+enum bnxt_nvm_directory_type {
+	BNX_DIR_TYPE_UNUSED = 0,
+	BNX_DIR_TYPE_PKG_LOG = 1,
+	BNX_DIR_TYPE_UPDATE = 2,
+	BNX_DIR_TYPE_CHIMP_PATCH = 3,
+	BNX_DIR_TYPE_BOOTCODE = 4,
+	BNX_DIR_TYPE_VPD = 5,
+	BNX_DIR_TYPE_EXP_ROM_MBA = 6,
+	BNX_DIR_TYPE_AVS = 7,
+	BNX_DIR_TYPE_PCIE = 8,
+	BNX_DIR_TYPE_PORT_MACRO = 9,
+	BNX_DIR_TYPE_APE_FW = 10,
+	BNX_DIR_TYPE_APE_PATCH = 11,
+	BNX_DIR_TYPE_KONG_FW = 12,
+	BNX_DIR_TYPE_KONG_PATCH = 13,
+	BNX_DIR_TYPE_BONO_FW = 14,
+	BNX_DIR_TYPE_BONO_PATCH = 15,
+	BNX_DIR_TYPE_TANG_FW = 16,
+	BNX_DIR_TYPE_TANG_PATCH = 17,
+	BNX_DIR_TYPE_BOOTCODE_2 = 18,
+	BNX_DIR_TYPE_CCM = 19,
+	BNX_DIR_TYPE_PCI_CFG = 20,
+	BNX_DIR_TYPE_TSCF_UCODE = 21,
+	BNX_DIR_TYPE_ISCSI_BOOT = 22,
+	BNX_DIR_TYPE_ISCSI_BOOT_IPV6 = 24,
+	BNX_DIR_TYPE_ISCSI_BOOT_IPV4N6 = 25,
+	BNX_DIR_TYPE_ISCSI_BOOT_CFG6 = 26,
+	BNX_DIR_TYPE_EXT_PHY = 27,
+	BNX_DIR_TYPE_SHARED_CFG = 40,
+	BNX_DIR_TYPE_PORT_CFG = 41,
+	BNX_DIR_TYPE_FUNC_CFG = 42,
+	BNX_DIR_TYPE_MGMT_CFG = 48,
+	BNX_DIR_TYPE_MGMT_DATA = 49,
+	BNX_DIR_TYPE_MGMT_WEB_DATA = 50,
+	BNX_DIR_TYPE_MGMT_WEB_META = 51,
+	BNX_DIR_TYPE_MGMT_EVENT_LOG = 52,
+	BNX_DIR_TYPE_MGMT_AUDIT_LOG = 53
+};
+
+enum bnxnvm_pkglog_field_index {
+	BNX_PKG_LOG_FIELD_IDX_INSTALLED_TIMESTAMP	= 0,
+	BNX_PKG_LOG_FIELD_IDX_PKG_DESCRIPTION		= 1,
+	BNX_PKG_LOG_FIELD_IDX_PKG_VERSION		= 2,
+	BNX_PKG_LOG_FIELD_IDX_PKG_TIMESTAMP		= 3,
+	BNX_PKG_LOG_FIELD_IDX_PKG_CHECKSUM		= 4,
+	BNX_PKG_LOG_FIELD_IDX_INSTALLED_ITEMS		= 5,
+	BNX_PKG_LOG_FIELD_IDX_INSTALLED_MASK		= 6
+};
+
+#define BNX_DIR_ORDINAL_FIRST		0
+#define BNX_DIR_EXT_NONE		0
+
+struct bnxt_bar_info {
+	struct resource		*res;
+	bus_space_tag_t		tag;
+	bus_space_handle_t	handle;
+	bus_size_t		size;
+	int			rid;
+};
+
+struct bnxt_flow_ctrl {
+	bool rx;
+	bool tx;
+	bool autoneg;
+};
+
+struct bnxt_link_info {
+	uint8_t		media_type;
+	uint8_t		transceiver;
+	uint8_t		phy_addr;
+	uint8_t		phy_link_status;
+	uint8_t		wire_speed;
+	uint8_t		loop_back;
+	uint8_t		link_up;
+	uint8_t		last_link_up;
+	uint8_t		duplex;
+	uint8_t		last_duplex;
+	uint8_t		last_phy_type;
+	struct bnxt_flow_ctrl   flow_ctrl;
+	struct bnxt_flow_ctrl   last_flow_ctrl;
+	uint8_t		duplex_setting;
+	uint8_t		auto_mode;
+#define PHY_VER_LEN		3
+	uint8_t		phy_ver[PHY_VER_LEN];
+	uint8_t		phy_type;
+#define BNXT_PHY_STATE_ENABLED		0
+#define BNXT_PHY_STATE_DISABLED		1
+	uint8_t		phy_state;
+
+	uint16_t	link_speed;
+	uint16_t	support_speeds;
+	uint16_t	support_pam4_speeds;
+	uint16_t	auto_link_speeds;
+	uint16_t	auto_pam4_link_speeds;
+	uint16_t	force_link_speed;
+	uint16_t	force_pam4_link_speed;
+	bool		force_pam4_speed_set_by_user;
+
+	uint16_t	advertising;
+	uint16_t	advertising_pam4;
+
+	uint32_t	preemphasis;
+	uint16_t	support_auto_speeds;
+	uint16_t	support_force_speeds;
+	uint16_t	support_pam4_auto_speeds;
+	uint16_t	support_pam4_force_speeds;
+#define BNXT_SIG_MODE_NRZ	HWRM_PORT_PHY_QCFG_OUTPUT_SIGNAL_MODE_NRZ
+#define BNXT_SIG_MODE_PAM4	HWRM_PORT_PHY_QCFG_OUTPUT_SIGNAL_MODE_PAM4
+	uint8_t		req_signal_mode;
+
+	uint8_t		active_fec_sig_mode;
+	uint8_t		sig_mode;
+
+	/* copy of requested setting */
+	uint8_t		autoneg;
+#define BNXT_AUTONEG_SPEED	1
+#define BNXT_AUTONEG_FLOW_CTRL	2
+	uint8_t		req_duplex;
+	uint16_t	req_link_speed;
+	uint8_t		module_status;
+	struct hwrm_port_phy_qcfg_output    phy_qcfg_resp;
+};
+
+enum bnxt_phy_type {
+	BNXT_MEDIA_CR = 0,
+	BNXT_MEDIA_LR,
+	BNXT_MEDIA_SR,
+	BNXT_MEDIA_KR,
+	BNXT_MEDIA_END
+};
+
+enum bnxt_cp_type {
+	BNXT_DEFAULT,
+	BNXT_TX,
+	BNXT_RX,
+	BNXT_SHARED
+};
+
+struct bnxt_queue_info {
+	uint8_t		queue_id;
+	uint8_t		queue_profile;
+};
+
+struct bnxt_func_info {
+	uint32_t	fw_fid;
+	uint8_t		mac_addr[ETHER_ADDR_LEN];
+	uint16_t	max_rsscos_ctxs;
+	uint16_t	max_cp_rings;
+	uint16_t	max_tx_rings;
+	uint16_t	max_rx_rings;
+	uint16_t	max_hw_ring_grps;
+	uint16_t	max_irqs;
+	uint16_t	max_l2_ctxs;
+	uint16_t	max_vnics;
+	uint16_t	max_stat_ctxs;
+};
+
+struct bnxt_pf_info {
+#define BNXT_FIRST_PF_FID	1
+#define BNXT_FIRST_VF_FID	128
+	uint8_t		port_id;
+	uint32_t	first_vf_id;
+	uint16_t	active_vfs;
+	uint16_t	max_vfs;
+	uint32_t	max_encap_records;
+	uint32_t	max_decap_records;
+	uint32_t	max_tx_em_flows;
+	uint32_t	max_tx_wm_flows;
+	uint32_t	max_rx_em_flows;
+	uint32_t	max_rx_wm_flows;
+	unsigned long	*vf_event_bmap;
+	uint16_t	hwrm_cmd_req_pages;
+	void		*hwrm_cmd_req_addr[4];
+	bus_addr_t	hwrm_cmd_req_dma_addr[4];
+};
+
+struct bnxt_vf_info {
+	uint16_t	fw_fid;
+	uint8_t		mac_addr[ETHER_ADDR_LEN];
+	uint16_t	max_rsscos_ctxs;
+	uint16_t	max_cp_rings;
+	uint16_t	max_tx_rings;
+	uint16_t	max_rx_rings;
+	uint16_t	max_hw_ring_grps;
+	uint16_t	max_l2_ctxs;
+	uint16_t	max_irqs;
+	uint16_t	max_vnics;
+	uint16_t	max_stat_ctxs;
+	uint32_t	vlan;
+#define BNXT_VF_QOS		0x1
+#define BNXT_VF_SPOOFCHK	0x2
+#define BNXT_VF_LINK_FORCED	0x4
+#define BNXT_VF_LINK_UP		0x8
+	uint32_t	flags;
+	uint32_t	func_flags; /* func cfg flags */
+	uint32_t	min_tx_rate;
+	uint32_t	max_tx_rate;
+	void		*hwrm_cmd_req_addr;
+	bus_addr_t	hwrm_cmd_req_dma_addr;
+};
+
+#define BNXT_PF(softc)		(!((softc)->flags & BNXT_FLAG_VF))
+#define BNXT_VF(softc)		((softc)->flags & BNXT_FLAG_VF)
+
+struct bnxt_vlan_tag {
+	SLIST_ENTRY(bnxt_vlan_tag) next;
+	uint64_t	filter_id;
+	uint16_t	tag;
+};
+
+struct bnxt_vnic_info {
+	uint16_t	id;
+	uint16_t	def_ring_grp;
+	uint16_t	cos_rule;
+	uint16_t	lb_rule;
+	uint16_t	mru;
+
+	uint32_t	rx_mask;
+	struct iflib_dma_info mc_list;
+	int		mc_list_count;
+#define BNXT_MAX_MC_ADDRS		16
+
+	uint32_t	flags;
+#define BNXT_VNIC_FLAG_DEFAULT		0x01
+#define BNXT_VNIC_FLAG_BD_STALL		0x02
+#define BNXT_VNIC_FLAG_VLAN_STRIP	0x04
+
+	uint64_t	filter_id;
+
+	uint16_t	rss_id;
+	uint32_t	rss_hash_type;
+	uint8_t		rss_hash_key[HW_HASH_KEY_SIZE];
+	struct iflib_dma_info rss_hash_key_tbl;
+	struct iflib_dma_info	rss_grp_tbl;
+	SLIST_HEAD(vlan_head, bnxt_vlan_tag) vlan_tags;
+	struct iflib_dma_info vlan_tag_list;
+};
+
+struct bnxt_grp_info {
+	uint16_t	stats_ctx;
+	uint16_t	grp_id;
+	uint16_t	rx_ring_id;
+	uint16_t	cp_ring_id;
+	uint16_t	ag_ring_id;
+};
+
+struct bnxt_ring {
+	uint64_t		paddr;
+	vm_offset_t		doorbell;
+	caddr_t			vaddr;
+	struct bnxt_softc	*softc;
+	uint32_t		ring_size;	/* Must be a power of two */
+	uint16_t		id;		/* Logical ID */
+	uint16_t		phys_id;
+	uint16_t		idx;
+	struct bnxt_full_tpa_start *tpa_start;
+};
+
+struct bnxt_cp_ring {
+	struct bnxt_ring	ring;
+	struct if_irq		irq;
+	uint32_t		cons;
+	bool			v_bit;		/* Value of valid bit */
+	struct ctx_hw_stats	*stats;
+	uint32_t		stats_ctx_id;
+	uint32_t		last_idx;	/* Used by RX rings only
+						 * set to the last read pidx
+						 */
+	uint64_t 		int_count;
+};
+
+struct bnxt_full_tpa_start {
+	struct rx_tpa_start_cmpl low;
+	struct rx_tpa_start_cmpl_hi high;
+};
+
+/* All the version information for the part */
+#define BNXT_VERSTR_SIZE	(3*3+2+1)	/* ie: "255.255.255\0" */
+#define BNXT_NAME_SIZE		17
+#define FW_VER_STR_LEN          32
+#define BC_HWRM_STR_LEN         21
+struct bnxt_ver_info {
+	uint8_t		hwrm_if_major;
+	uint8_t		hwrm_if_minor;
+	uint8_t		hwrm_if_update;
+	char		hwrm_if_ver[BNXT_VERSTR_SIZE];
+	char		driver_hwrm_if_ver[BNXT_VERSTR_SIZE];
+	char		mgmt_fw_ver[FW_VER_STR_LEN];
+	char		netctrl_fw_ver[FW_VER_STR_LEN];
+	char		roce_fw_ver[FW_VER_STR_LEN];
+	char		fw_ver_str[FW_VER_STR_LEN];
+	char		phy_ver[BNXT_VERSTR_SIZE];
+	char		pkg_ver[64];
+
+	char		hwrm_fw_name[BNXT_NAME_SIZE];
+	char		mgmt_fw_name[BNXT_NAME_SIZE];
+	char		netctrl_fw_name[BNXT_NAME_SIZE];
+	char		roce_fw_name[BNXT_NAME_SIZE];
+	char		phy_vendor[BNXT_NAME_SIZE];
+	char		phy_partnumber[BNXT_NAME_SIZE];
+
+	uint16_t	chip_num;
+	uint8_t		chip_rev;
+	uint8_t		chip_metal;
+	uint8_t		chip_bond_id;
+	uint8_t		chip_type;
+
+	uint8_t		hwrm_min_major;
+	uint8_t		hwrm_min_minor;
+	uint8_t		hwrm_min_update;
+	uint64_t	fw_ver_code;
+#define BNXT_FW_VER_CODE(maj, min, bld, rsv)			\
+	((uint64_t)(maj) << 48 | (uint64_t)(min) << 32 | (uint64_t)(bld) << 16 | (rsv))
+#define BNXT_FW_MAJ(softc)	((softc)->ver_info->fw_ver_code >> 48)
+#define BNXT_FW_MIN(softc)	(((softc)->ver_info->fw_ver_code >> 32) & 0xffff)
+#define BNXT_FW_BLD(softc)	(((softc)->ver_info->fw_ver_code >> 16) & 0xffff)
+#define BNXT_FW_RSV(softc)	(((softc)->ver_info->fw_ver_code) & 0xffff)
+
+	struct sysctl_ctx_list	ver_ctx;
+	struct sysctl_oid	*ver_oid;
+};
+
+struct bnxt_nvram_info {
+	uint16_t	mfg_id;
+	uint16_t	device_id;
+	uint32_t	sector_size;
+	uint32_t	size;
+	uint32_t	reserved_size;
+	uint32_t	available_size;
+
+	struct sysctl_ctx_list	nvm_ctx;
+	struct sysctl_oid	*nvm_oid;
+};
+
+struct bnxt_func_qcfg {
+	uint16_t alloc_completion_rings;
+	uint16_t alloc_tx_rings;
+	uint16_t alloc_rx_rings;
+	uint16_t alloc_vnics;
+};
+
+struct bnxt_hw_lro {
+	uint16_t enable;
+	uint16_t is_mode_gro;
+	uint16_t max_agg_segs;
+	uint16_t max_aggs;
+	uint32_t min_agg_len;
+};
+
+/* The hardware supports certain page sizes.  Use the supported page sizes
+ * to allocate the rings.
+ */
+#if (PAGE_SHIFT < 12)
+#define BNXT_PAGE_SHIFT 12
+#elif (PAGE_SHIFT <= 13)
+#define BNXT_PAGE_SHIFT PAGE_SHIFT
+#elif (PAGE_SHIFT < 16)
+#define BNXT_PAGE_SHIFT 13
+#else
+#define BNXT_PAGE_SHIFT 16
+#endif
+
+#define BNXT_PAGE_SIZE  (1 << BNXT_PAGE_SHIFT)
+
+#define MAX_CTX_PAGES	(BNXT_PAGE_SIZE / 8)
+#define MAX_CTX_TOTAL_PAGES	(MAX_CTX_PAGES * MAX_CTX_PAGES)
+
+struct bnxt_ring_mem_info {
+	int			nr_pages;
+	int			page_size;
+	uint16_t		flags;
+#define BNXT_RMEM_VALID_PTE_FLAG        1
+#define BNXT_RMEM_RING_PTE_FLAG         2
+#define BNXT_RMEM_USE_FULL_PAGE_FLAG    4
+	uint16_t		depth;
+	struct bnxt_ctx_mem_type	*ctx_mem;
+
+	struct iflib_dma_info	*pg_arr;
+	struct iflib_dma_info	pg_tbl;
+
+	int			vmem_size;
+	void			**vmem;
+};
+
+struct bnxt_ctx_pg_info {
+	uint32_t		entries;
+	uint32_t		nr_pages;
+	struct iflib_dma_info   ctx_arr[MAX_CTX_PAGES];
+	struct bnxt_ring_mem_info ring_mem;
+	struct bnxt_ctx_pg_info **ctx_pg_tbl;
+};
+
+#define BNXT_MAX_TQM_SP_RINGS		1
+#define BNXT_MAX_TQM_FP_LEGACY_RINGS	8
+#define BNXT_MAX_TQM_FP_RINGS		9
+#define BNXT_MAX_TQM_LEGACY_RINGS	\
+	(BNXT_MAX_TQM_SP_RINGS + BNXT_MAX_TQM_FP_LEGACY_RINGS)
+#define BNXT_MAX_TQM_RINGS		\
+	(BNXT_MAX_TQM_SP_RINGS + BNXT_MAX_TQM_FP_RINGS)
+
+#define BNXT_BACKING_STORE_CFG_LEGACY_LEN	256
+#define BNXT_BACKING_STORE_CFG_LEN		\
+	sizeof(struct hwrm_func_backing_store_cfg_input)
+
+#define BNXT_SET_CTX_PAGE_ATTR(attr)					\
+do {									\
+	if (BNXT_PAGE_SIZE == 0x2000)					\
+		attr = HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_SRQ_PG_SIZE_PG_8K;	\
+	else if (BNXT_PAGE_SIZE == 0x10000)				\
+		attr = HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_QPC_PG_SIZE_PG_64K;	\
+	else								\
+		attr = HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_QPC_PG_SIZE_PG_4K;	\
+} while (0)
+
+struct bnxt_ctx_mem_type {
+	u16	type;
+	u16	entry_size;
+	u32	flags;
+#define BNXT_CTX_MEM_TYPE_VALID HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_FLAGS_TYPE_VALID
+	u32	instance_bmap;
+	u8	init_value;
+	u8	entry_multiple;
+	u16	init_offset;
+#define	BNXT_CTX_INIT_INVALID_OFFSET	0xffff
+	u32	max_entries;
+	u32	min_entries;
+	u8	split_entry_cnt;
+#define BNXT_MAX_SPLIT_ENTRY	4
+	union {
+		struct {
+			u32	qp_l2_entries;
+			u32	qp_qp1_entries;
+		};
+		u32	srq_l2_entries;
+		u32	cq_l2_entries;
+		u32	vnic_entries;
+		struct {
+			u32	mrav_av_entries;
+			u32	mrav_num_entries_units;
+		};
+		u32	split[BNXT_MAX_SPLIT_ENTRY];
+	};
+	struct bnxt_ctx_pg_info	*pg_info;
+};
+
+#define BNXT_CTX_QP	HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_QP
+#define BNXT_CTX_SRQ	HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_SRQ
+#define BNXT_CTX_CQ	HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_CQ
+#define BNXT_CTX_VNIC	HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_VNIC
+#define BNXT_CTX_STAT	HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_STAT
+#define BNXT_CTX_STQM	HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_SP_TQM_RING
+#define BNXT_CTX_FTQM	HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_FP_TQM_RING
+#define BNXT_CTX_MRAV	HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_MRAV
+#define BNXT_CTX_TIM	HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_TIM
+#define BNXT_CTX_TKC	HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_TKC
+#define BNXT_CTX_RKC	HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_RKC
+#define BNXT_CTX_MTQM	HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_MP_TQM_RING
+#define BNXT_CTX_SQDBS	HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_SQ_DB_SHADOW
+#define BNXT_CTX_RQDBS	HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_RQ_DB_SHADOW
+#define BNXT_CTX_SRQDBS	HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_SRQ_DB_SHADOW
+#define BNXT_CTX_CQDBS	HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_CQ_DB_SHADOW
+#define BNXT_CTX_QTKC	HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_QUIC_TKC
+#define BNXT_CTX_QRKC	HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_QUIC_RKC
+#define BNXT_CTX_MAX	(BNXT_CTX_TIM + 1)
+
+struct bnxt_ctx_mem_info {
+	u8	tqm_fp_rings_count;
+
+	u32	flags;
+	#define BNXT_CTX_FLAG_INITED	0x01
+	struct bnxt_ctx_mem_type	ctx_arr[BNXT_CTX_MAX];
+};
+
+struct bnxt_hw_resc {
+	uint16_t	min_rsscos_ctxs;
+	uint16_t	max_rsscos_ctxs;
+	uint16_t	min_cp_rings;
+	uint16_t	max_cp_rings;
+	uint16_t	resv_cp_rings;
+	uint16_t	min_tx_rings;
+	uint16_t	max_tx_rings;
+	uint16_t	resv_tx_rings;
+	uint16_t	max_tx_sch_inputs;
+	uint16_t	min_rx_rings;
+	uint16_t	max_rx_rings;
+	uint16_t	resv_rx_rings;
+	uint16_t	min_hw_ring_grps;
+	uint16_t	max_hw_ring_grps;
+	uint16_t	resv_hw_ring_grps;
+	uint16_t	min_l2_ctxs;
+	uint16_t	max_l2_ctxs;
+	uint16_t	min_vnics;
+	uint16_t	max_vnics;
+	uint16_t	resv_vnics;
+	uint16_t	min_stat_ctxs;
+	uint16_t	max_stat_ctxs;
+	uint16_t	resv_stat_ctxs;
+	uint16_t	max_nqs;
+	uint16_t	max_irqs;
+	uint16_t	resv_irqs;
+};
+
+enum bnxt_type_ets {
+	BNXT_TYPE_ETS_TSA = 0,
+	BNXT_TYPE_ETS_PRI2TC,
+	BNXT_TYPE_ETS_TCBW,
+	BNXT_TYPE_ETS_MAX
+};
+
+static const char *const BNXT_ETS_TYPE_STR[] = {
+	"tsa",
+	"pri2tc",
+	"tcbw",
+};
+
+static const char *const BNXT_ETS_HELP_STR[] = {
+	"X is 1 (strict),  0 (ets)",
+	"TC values for pri 0 to 7",
+	"TC BW values for pri 0 to 7, Sum should be 100",
+};
+
+#define BNXT_HWRM_MAX_REQ_LEN		(softc->hwrm_max_req_len)
+
+struct bnxt_softc_list {
+	SLIST_ENTRY(bnxt_softc_list) next;
+	struct bnxt_softc *softc;
+};
+
+#ifndef BIT_ULL
+#define BIT_ULL(nr)		(1ULL << (nr))
+#endif
+
+struct bnxt_aux_dev {
+	struct auxiliary_device aux_dev;
+	struct bnxt_en_dev *edev;
+	int id;
+};
+
+struct bnxt_msix_tbl {
+	uint32_t entry;
+	uint32_t vector;
+};
+
+enum bnxt_health_severity {
+	SEVERITY_NORMAL = 0,
+	SEVERITY_WARNING,
+	SEVERITY_RECOVERABLE,
+	SEVERITY_FATAL,
+};
+
+enum bnxt_health_remedy {
+	REMEDY_DEVLINK_RECOVER,
+	REMEDY_POWER_CYCLE_DEVICE,
+	REMEDY_POWER_CYCLE_HOST,
+	REMEDY_FW_UPDATE,
+	REMEDY_HW_REPLACE,
+};
+
+struct bnxt_fw_health {
+	u32 flags;
+	u32 polling_dsecs;
+	u32 master_func_wait_dsecs;
+	u32 normal_func_wait_dsecs;
+	u32 post_reset_wait_dsecs;
+	u32 post_reset_max_wait_dsecs;
+	u32 regs[4];
+	u32 mapped_regs[4];
+#define BNXT_FW_HEALTH_REG		0
+#define BNXT_FW_HEARTBEAT_REG		1
+#define BNXT_FW_RESET_CNT_REG		2
+#define BNXT_FW_RESET_INPROG_REG	3
+	u32 fw_reset_inprog_reg_mask;
+	u32 last_fw_heartbeat;
+	u32 last_fw_reset_cnt;
+	u8 enabled:1;
+	u8 primary:1;
+	u8 status_reliable:1;
+	u8 resets_reliable:1;
+	u8 tmr_multiplier;
+	u8 tmr_counter;
+	u8 fw_reset_seq_cnt;
+	u32 fw_reset_seq_regs[16];
+	u32 fw_reset_seq_vals[16];
+	u32 fw_reset_seq_delay_msec[16];
+	u32 echo_req_data1;
+	u32 echo_req_data2;
+	struct devlink_health_reporter	*fw_reporter;
+	struct mutex lock;
+	enum bnxt_health_severity severity;
+	enum bnxt_health_remedy remedy;
+	u32 arrests;
+	u32 discoveries;
+	u32 survivals;
+	u32 fatalities;
+	u32 diagnoses;
+};
+
+#define BNXT_FW_HEALTH_REG_TYPE_MASK	3
+#define BNXT_FW_HEALTH_REG_TYPE_CFG	0
+#define BNXT_FW_HEALTH_REG_TYPE_GRC	1
+#define BNXT_FW_HEALTH_REG_TYPE_BAR0	2
+#define BNXT_FW_HEALTH_REG_TYPE_BAR1	3
+
+#define BNXT_FW_HEALTH_REG_TYPE(reg)	((reg) & BNXT_FW_HEALTH_REG_TYPE_MASK)
+#define BNXT_FW_HEALTH_REG_OFF(reg)	((reg) & ~BNXT_FW_HEALTH_REG_TYPE_MASK)
+
+#define BNXT_FW_HEALTH_WIN_BASE		0x3000
+#define BNXT_FW_HEALTH_WIN_MAP_OFF	8
+
+#define BNXT_FW_HEALTH_WIN_OFF(reg)	(BNXT_FW_HEALTH_WIN_BASE +	\
+					 ((reg) & BNXT_GRC_OFFSET_MASK))
+
+#define BNXT_FW_STATUS_HEALTH_MSK	0xffff
+#define BNXT_FW_STATUS_HEALTHY		0x8000
+#define BNXT_FW_STATUS_SHUTDOWN		0x100000
+#define BNXT_FW_STATUS_RECOVERING	0x400000
+
+#define BNXT_FW_IS_HEALTHY(sts)		(((sts) & BNXT_FW_STATUS_HEALTH_MSK) ==\
+					 BNXT_FW_STATUS_HEALTHY)
+
+#define BNXT_FW_IS_BOOTING(sts)		(((sts) & BNXT_FW_STATUS_HEALTH_MSK) < \
+					 BNXT_FW_STATUS_HEALTHY)
+
+#define BNXT_FW_IS_ERR(sts)		(((sts) & BNXT_FW_STATUS_HEALTH_MSK) > \
+					 BNXT_FW_STATUS_HEALTHY)
+
+#define BNXT_FW_IS_RECOVERING(sts)	(BNXT_FW_IS_ERR(sts) &&		       \
+					 ((sts) & BNXT_FW_STATUS_RECOVERING))
+
+#define BNXT_FW_RETRY			5
+#define BNXT_FW_IF_RETRY		10
+#define BNXT_FW_SLOT_RESET_RETRY	4
+
+#define BNXT_GRCPF_REG_CHIMP_COMM		0x0
+#define BNXT_GRCPF_REG_CHIMP_COMM_TRIGGER	0x100
+#define BNXT_GRCPF_REG_WINDOW_BASE_OUT		0x400
+#define BNXT_GRCPF_REG_SYNC_TIME		0x480
+#define BNXT_GRCPF_REG_SYNC_TIME_ADJ		0x488
+#define BNXT_GRCPF_REG_SYNC_TIME_ADJ_PER_MSK	0xffffffUL
+#define BNXT_GRCPF_REG_SYNC_TIME_ADJ_PER_SFT	0
+#define BNXT_GRCPF_REG_SYNC_TIME_ADJ_VAL_MSK	0x1f000000UL
+#define BNXT_GRCPF_REG_SYNC_TIME_ADJ_VAL_SFT	24
+#define BNXT_GRCPF_REG_SYNC_TIME_ADJ_SIGN_MSK	0x20000000UL
+#define BNXT_GRCPF_REG_SYNC_TIME_ADJ_SIGN_SFT	29
+
+#define BNXT_GRC_REG_STATUS_P5			0x520
+
+#define BNXT_GRCPF_REG_KONG_COMM		0xA00
+#define BNXT_GRCPF_REG_KONG_COMM_TRIGGER	0xB00
+
+#define BNXT_CAG_REG_LEGACY_INT_STATUS		0x4014
+#define BNXT_CAG_REG_BASE			0x300000
+
+#define BNXT_GRC_REG_CHIP_NUM			0x48
+#define BNXT_GRC_REG_BASE			0x260000
+
+#define BNXT_TS_REG_TIMESYNC_TS0_LOWER		0x640180c
+#define BNXT_TS_REG_TIMESYNC_TS0_UPPER		0x6401810
+
+#define BNXT_GRC_BASE_MASK			0xfffff000
+#define BNXT_GRC_OFFSET_MASK			0x00000ffc
+struct bnxt_softc {
+	device_t	dev;
+	if_ctx_t	ctx;
+	if_softc_ctx_t	scctx;
+	if_shared_ctx_t	sctx;
+	if_t ifp;
+	uint32_t	domain;
+	uint32_t	bus;
+	uint32_t	slot;
+	uint32_t	function;
+	uint32_t	dev_fn;
+	struct ifmedia	*media;
+	struct bnxt_ctx_mem_info *ctx_mem;
+	struct bnxt_hw_resc hw_resc;
+	struct bnxt_softc_list list;
+
+	struct bnxt_bar_info	hwrm_bar;
+	struct bnxt_bar_info	doorbell_bar;
+	struct bnxt_link_info	link_info;
+#define BNXT_FLAG_VF				0x0001
+#define BNXT_FLAG_NPAR				0x0002
+#define BNXT_FLAG_WOL_CAP			0x0004
+#define BNXT_FLAG_SHORT_CMD			0x0008
+#define BNXT_FLAG_FW_CAP_NEW_RM			0x0010
+#define BNXT_FLAG_CHIP_P5			0x0020
+#define BNXT_FLAG_TPA				0x0040
+#define BNXT_FLAG_FW_CAP_EXT_STATS		0x0080
+#define BNXT_FLAG_MULTI_HOST			0x0100
+#define BNXT_FLAG_MULTI_ROOT			0x0200
+#define BNXT_FLAG_ROCEV1_CAP			0x0400
+#define BNXT_FLAG_ROCEV2_CAP			0x0800
+#define BNXT_FLAG_ROCE_CAP			(BNXT_FLAG_ROCEV1_CAP | BNXT_FLAG_ROCEV2_CAP)
+	uint32_t		flags;
+#define BNXT_STATE_LINK_CHANGE  (0)
+#define BNXT_STATE_MAX		(BNXT_STATE_LINK_CHANGE + 1)
+	bitstr_t 		*state_bv;
+
+	uint32_t		total_irqs;
+	struct bnxt_msix_tbl	*irq_tbl;
+
+	struct bnxt_func_info	func;
+	struct bnxt_func_qcfg	fn_qcfg;
+	struct bnxt_pf_info	pf;
+	struct bnxt_vf_info	vf;
+
+	uint16_t		hwrm_cmd_seq;
+	uint32_t		hwrm_cmd_timeo;	/* milliseconds */
+	struct iflib_dma_info	hwrm_cmd_resp;
+	struct iflib_dma_info	hwrm_short_cmd_req_addr;
+	/* Interrupt info for HWRM */
+	struct if_irq		irq;
+	struct mtx		hwrm_lock;
+	uint16_t		hwrm_max_req_len;
+	uint16_t		hwrm_max_ext_req_len;
+	uint32_t		hwrm_spec_code;
+
+#define BNXT_MAX_QUEUE	8
+	uint8_t			max_tc;
+	uint8_t			max_lltc;
+	struct bnxt_queue_info  tx_q_info[BNXT_MAX_QUEUE];
+	struct bnxt_queue_info  rx_q_info[BNXT_MAX_QUEUE];
+	uint8_t			tc_to_qidx[BNXT_MAX_QUEUE];
+	uint8_t			tx_q_ids[BNXT_MAX_QUEUE];
+	uint8_t			rx_q_ids[BNXT_MAX_QUEUE];
+	uint8_t			tx_max_q;
+	uint8_t			rx_max_q;
+	uint8_t			is_asym_q;
+
+	struct bnxt_ieee_ets	*ieee_ets;
+	struct bnxt_ieee_pfc    *ieee_pfc;
+	uint8_t			dcbx_cap;
+	uint8_t			default_pri;
+	uint8_t			max_dscp_value;
+
+	uint64_t		admin_ticks;
+	struct iflib_dma_info	hw_rx_port_stats;
+	struct iflib_dma_info	hw_tx_port_stats;
+	struct rx_port_stats	*rx_port_stats;
+	struct tx_port_stats	*tx_port_stats;
+
+	struct iflib_dma_info	hw_tx_port_stats_ext;
+	struct iflib_dma_info	hw_rx_port_stats_ext;
+	struct tx_port_stats_ext *tx_port_stats_ext;
+	struct rx_port_stats_ext *rx_port_stats_ext;
+
+	uint16_t		fw_rx_stats_ext_size;
+	uint16_t		fw_tx_stats_ext_size;
+	uint16_t		hw_ring_stats_size;
+
+	uint8_t			tx_pri2cos_idx[8];
+	uint8_t			rx_pri2cos_idx[8];
+	bool			pri2cos_valid;
+
+	uint64_t		tx_bytes_pri[8];
+	uint64_t		tx_packets_pri[8];
+	uint64_t		rx_bytes_pri[8];
+	uint64_t		rx_packets_pri[8];
+
+	uint8_t			port_count;
+	int			num_cp_rings;
+
+	struct bnxt_cp_ring	*nq_rings;
+
+	struct bnxt_ring	*tx_rings;
+	struct bnxt_cp_ring	*tx_cp_rings;
+	struct iflib_dma_info	tx_stats[BNXT_MAX_NUM_QUEUES];
+	int			ntxqsets;
+
+	struct bnxt_vnic_info	vnic_info;
+	struct bnxt_ring	*ag_rings;
+	struct bnxt_ring	*rx_rings;
+	struct bnxt_cp_ring	*rx_cp_rings;
+	struct bnxt_grp_info	*grp_info;
+	struct iflib_dma_info	rx_stats[BNXT_MAX_NUM_QUEUES];
+	int			nrxqsets;
+	uint16_t		rx_buf_size;
+
+	struct bnxt_cp_ring	def_cp_ring;
+	struct bnxt_cp_ring	def_nq_ring;
+	struct iflib_dma_info	def_cp_ring_mem;
+	struct iflib_dma_info	def_nq_ring_mem;
+	struct grouptask	def_cp_task;
+	int			db_size;
+	int			legacy_db_size;
+	struct bnxt_doorbell_ops db_ops;
+
+	struct sysctl_ctx_list	hw_stats;
+	struct sysctl_oid	*hw_stats_oid;
+	struct sysctl_ctx_list	hw_lro_ctx;
+	struct sysctl_oid	*hw_lro_oid;
+	struct sysctl_ctx_list	flow_ctrl_ctx;
+	struct sysctl_oid	*flow_ctrl_oid;
+	struct sysctl_ctx_list	dcb_ctx;
+	struct sysctl_oid	*dcb_oid;
+
+	struct bnxt_ver_info	*ver_info;
+	struct bnxt_nvram_info	*nvm_info;
+	bool wol;
+	bool is_dev_init;
+	struct bnxt_hw_lro	hw_lro;
+	uint8_t wol_filter_id;
+	uint16_t		rx_coal_usecs;
+	uint16_t		rx_coal_usecs_irq;
+	uint16_t               	rx_coal_frames;
+	uint16_t               	rx_coal_frames_irq;
+	uint16_t               	tx_coal_usecs;
+	uint16_t               	tx_coal_usecs_irq;
+	uint16_t               	tx_coal_frames;
+	uint16_t		tx_coal_frames_irq;
+
+#define BNXT_USEC_TO_COAL_TIMER(x)      ((x) * 25 / 2)
+#define BNXT_DEF_STATS_COAL_TICKS        1000000
+#define BNXT_MIN_STATS_COAL_TICKS         250000
+#define BNXT_MAX_STATS_COAL_TICKS        1000000
+
+	uint64_t		fw_cap;
+	#define BNXT_FW_CAP_SHORT_CMD			BIT_ULL(0)
+	#define BNXT_FW_CAP_LLDP_AGENT			BIT_ULL(1)
+	#define BNXT_FW_CAP_DCBX_AGENT			BIT_ULL(2)
+	#define BNXT_FW_CAP_NEW_RM			BIT_ULL(3)
+	#define BNXT_FW_CAP_IF_CHANGE			BIT_ULL(4)
+	#define BNXT_FW_CAP_LINK_ADMIN			BIT_ULL(5)
+	#define BNXT_FW_CAP_VF_RES_MIN_GUARANTEED	BIT_ULL(6)
+	#define BNXT_FW_CAP_KONG_MB_CHNL		BIT_ULL(7)
+	#define BNXT_FW_CAP_ADMIN_MTU			BIT_ULL(8)
+	#define BNXT_FW_CAP_ADMIN_PF			BIT_ULL(9)
+	#define BNXT_FW_CAP_OVS_64BIT_HANDLE		BIT_ULL(10)
+	#define BNXT_FW_CAP_TRUSTED_VF			BIT_ULL(11)
+	#define BNXT_FW_CAP_VF_VNIC_NOTIFY		BIT_ULL(12)
+	#define BNXT_FW_CAP_ERROR_RECOVERY		BIT_ULL(13)
+	#define BNXT_FW_CAP_PKG_VER			BIT_ULL(14)
+	#define BNXT_FW_CAP_CFA_ADV_FLOW		BIT_ULL(15)
+	#define BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V2	BIT_ULL(16)
+	#define BNXT_FW_CAP_PCIE_STATS_SUPPORTED	BIT_ULL(17)
+	#define BNXT_FW_CAP_EXT_STATS_SUPPORTED		BIT_ULL(18)
+	#define BNXT_FW_CAP_SECURE_MODE			BIT_ULL(19)
+	#define BNXT_FW_CAP_ERR_RECOVER_RELOAD		BIT_ULL(20)
+	#define BNXT_FW_CAP_HOT_RESET			BIT_ULL(21)
+	#define BNXT_FW_CAP_CRASHDUMP			BIT_ULL(23)
+	#define BNXT_FW_CAP_VLAN_RX_STRIP		BIT_ULL(24)
+	#define BNXT_FW_CAP_VLAN_TX_INSERT		BIT_ULL(25)
+	#define BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED	BIT_ULL(26)
+	#define BNXT_FW_CAP_CFA_EEM			BIT_ULL(27)
+	#define BNXT_FW_CAP_DBG_QCAPS			BIT_ULL(29)
+	#define BNXT_FW_CAP_RING_MONITOR		BIT_ULL(30)
+	#define BNXT_FW_CAP_ECN_STATS			BIT_ULL(31)
+	#define BNXT_FW_CAP_TRUFLOW			BIT_ULL(32)
+	#define BNXT_FW_CAP_VF_CFG_FOR_PF		BIT_ULL(33)
+	#define BNXT_FW_CAP_PTP_PPS			BIT_ULL(34)
+	#define BNXT_FW_CAP_HOT_RESET_IF		BIT_ULL(35)
+	#define BNXT_FW_CAP_LIVEPATCH			BIT_ULL(36)
+	#define BNXT_FW_CAP_NPAR_1_2			BIT_ULL(37)
+	#define BNXT_FW_CAP_RSS_HASH_TYPE_DELTA		BIT_ULL(38)
+	#define BNXT_FW_CAP_PTP_RTC			BIT_ULL(39)
+	#define	BNXT_FW_CAP_TRUFLOW_EN			BIT_ULL(40)
+	#define BNXT_TRUFLOW_EN(bp)	((bp)->fw_cap & BNXT_FW_CAP_TRUFLOW_EN)
+	#define BNXT_FW_CAP_RX_ALL_PKT_TS		BIT_ULL(41)
+	#define BNXT_FW_CAP_BACKING_STORE_V2		BIT_ULL(42)
+	#define BNXT_FW_CAP_DBR_SUPPORTED		BIT_ULL(43)
+	#define BNXT_FW_CAP_GENERIC_STATS		BIT_ULL(44)
+	#define BNXT_FW_CAP_DBR_PACING_SUPPORTED	BIT_ULL(45)
+	#define BNXT_FW_CAP_PTP_PTM			BIT_ULL(46)
+	#define BNXT_FW_CAP_CFA_NTUPLE_RX_EXT_IP_PROTO	BIT_ULL(47)
+	#define BNXT_FW_CAP_ENABLE_RDMA_SRIOV		BIT_ULL(48)
+	#define BNXT_FW_CAP_RSS_TCAM			BIT_ULL(49)
+	uint32_t		lpi_tmr_lo;
+	uint32_t		lpi_tmr_hi;
+	/* copied from flags and flags2 in hwrm_port_phy_qcaps_output */
+	uint16_t		phy_flags;
+#define BNXT_PHY_FL_EEE_CAP             HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS_EEE_SUPPORTED
+#define BNXT_PHY_FL_EXT_LPBK            HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS_EXTERNAL_LPBK_SUPPORTED
+#define BNXT_PHY_FL_AN_PHY_LPBK         HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS_AUTONEG_LPBK_SUPPORTED
+#define BNXT_PHY_FL_SHARED_PORT_CFG     HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS_SHARED_PHY_CFG_SUPPORTED
+#define BNXT_PHY_FL_PORT_STATS_NO_RESET HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS_CUMULATIVE_COUNTERS_ON_RESET
+#define BNXT_PHY_FL_NO_PHY_LPBK         HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS_LOCAL_LPBK_NOT_SUPPORTED
+#define BNXT_PHY_FL_FW_MANAGED_LKDN     HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS_FW_MANAGED_LINK_DOWN
+#define BNXT_PHY_FL_NO_FCS              HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS_NO_FCS
+#define BNXT_PHY_FL_NO_PAUSE            (HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS2_PAUSE_UNSUPPORTED << 8)
+#define BNXT_PHY_FL_NO_PFC              (HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS2_PFC_UNSUPPORTED << 8)
+#define BNXT_PHY_FL_BANK_SEL            (HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS2_BANK_ADDR_SUPPORTED << 8)
+	struct bnxt_aux_dev     *aux_dev;
+	struct net_device	*net_dev;
+	struct mtx		en_ops_lock;
+	uint8_t			port_partition_type;
+	struct bnxt_en_dev	*edev;
+	unsigned long		state;
+#define BNXT_STATE_OPEN			0
+#define BNXT_STATE_IN_SP_TASK		1
+#define BNXT_STATE_READ_STATS		2
+#define BNXT_STATE_FW_RESET_DET 	3
+#define BNXT_STATE_IN_FW_RESET		4
+#define BNXT_STATE_ABORT_ERR		5
+#define BNXT_STATE_FW_FATAL_COND	6
+#define BNXT_STATE_DRV_REGISTERED	7
+#define BNXT_STATE_PCI_CHANNEL_IO_FROZEN	8
+#define BNXT_STATE_NAPI_DISABLED	9
+#define BNXT_STATE_L2_FILTER_RETRY	10
+#define BNXT_STATE_FW_ACTIVATE		11
+#define BNXT_STATE_RECOVER		12
+#define BNXT_STATE_FW_NON_FATAL_COND	13
+#define BNXT_STATE_FW_ACTIVATE_RESET	14
+#define BNXT_STATE_HALF_OPEN		15
+#define BNXT_NO_FW_ACCESS(bp)		\
+	test_bit(BNXT_STATE_FW_FATAL_COND, &(bp)->state)
+	struct pci_dev			*pdev;
+
+	struct work_struct	sp_task;
+	unsigned long		sp_event;
+#define BNXT_RX_MASK_SP_EVENT		0
+#define BNXT_RX_NTP_FLTR_SP_EVENT	1
+#define BNXT_LINK_CHNG_SP_EVENT		2
+#define BNXT_HWRM_EXEC_FWD_REQ_SP_EVENT	3
+#define BNXT_VXLAN_ADD_PORT_SP_EVENT	4
+#define BNXT_VXLAN_DEL_PORT_SP_EVENT	5
+#define BNXT_RESET_TASK_SP_EVENT	6
+#define BNXT_RST_RING_SP_EVENT		7
+#define BNXT_HWRM_PF_UNLOAD_SP_EVENT	8
+#define BNXT_PERIODIC_STATS_SP_EVENT	9
+#define BNXT_HWRM_PORT_MODULE_SP_EVENT	10
+#define BNXT_RESET_TASK_SILENT_SP_EVENT	11
+#define BNXT_GENEVE_ADD_PORT_SP_EVENT	12
+#define BNXT_GENEVE_DEL_PORT_SP_EVENT	13
+#define BNXT_LINK_SPEED_CHNG_SP_EVENT	14
+#define BNXT_FLOW_STATS_SP_EVENT	15
+#define BNXT_UPDATE_PHY_SP_EVENT	16
+#define BNXT_RING_COAL_NOW_SP_EVENT	17
+#define BNXT_FW_RESET_NOTIFY_SP_EVENT	18
+#define BNXT_FW_EXCEPTION_SP_EVENT	19
+#define BNXT_VF_VNIC_CHANGE_SP_EVENT	20
+#define BNXT_LINK_CFG_CHANGE_SP_EVENT	21
+#define BNXT_PTP_CURRENT_TIME_EVENT	22
+#define BNXT_FW_ECHO_REQUEST_SP_EVENT	23
+#define BNXT_VF_CFG_CHNG_SP_EVENT	24
+
+	struct delayed_work	fw_reset_task;
+	int			fw_reset_state;
+#define BNXT_FW_RESET_STATE_POLL_VF	1
+#define BNXT_FW_RESET_STATE_RESET_FW	2
+#define BNXT_FW_RESET_STATE_ENABLE_DEV	3
+#define BNXT_FW_RESET_STATE_POLL_FW	4
+#define BNXT_FW_RESET_STATE_OPENING	5
+#define BNXT_FW_RESET_STATE_POLL_FW_DOWN	6
+	u16			fw_reset_min_dsecs;
+#define BNXT_DFLT_FW_RST_MIN_DSECS	20
+	u16			fw_reset_max_dsecs;
+#define BNXT_DFLT_FW_RST_MAX_DSECS	60
+	unsigned long		fw_reset_timestamp;
+
+	struct bnxt_fw_health	*fw_health;
+};
+
+struct bnxt_filter_info {
+	STAILQ_ENTRY(bnxt_filter_info) next;
+	uint64_t	fw_l2_filter_id;
+#define INVALID_MAC_INDEX ((uint16_t)-1)
+	uint16_t	mac_index;
+
+	/* Filter Characteristics */
+	uint32_t	flags;
+	uint32_t	enables;
+	uint8_t		l2_addr[ETHER_ADDR_LEN];
+	uint8_t		l2_addr_mask[ETHER_ADDR_LEN];
+	uint16_t	l2_ovlan;
+	uint16_t	l2_ovlan_mask;
+	uint16_t	l2_ivlan;
+	uint16_t	l2_ivlan_mask;
+	uint8_t		t_l2_addr[ETHER_ADDR_LEN];
+	uint8_t		t_l2_addr_mask[ETHER_ADDR_LEN];
+	uint16_t	t_l2_ovlan;
+	uint16_t	t_l2_ovlan_mask;
+	uint16_t	t_l2_ivlan;
+	uint16_t	t_l2_ivlan_mask;
+	uint8_t		tunnel_type;
+	uint16_t	mirror_vnic_id;
+	uint32_t	vni;
+	uint8_t		pri_hint;
+	uint64_t	l2_filter_id_hint;
+};
+
+#define I2C_DEV_ADDR_A0                 0xa0
+#define BNXT_MAX_PHY_I2C_RESP_SIZE      64
+
+/* Function declarations */
+void bnxt_report_link(struct bnxt_softc *softc);
+bool bnxt_check_hwrm_version(struct bnxt_softc *softc);
+struct bnxt_softc *bnxt_find_dev(uint32_t domain, uint32_t bus, uint32_t dev_fn, char *name);
+int bnxt_read_sfp_module_eeprom_info(struct bnxt_softc *bp, uint16_t i2c_addr,
+    uint16_t page_number, uint8_t bank, bool bank_sel_en, uint16_t start_addr,
+    uint16_t data_length, uint8_t *buf);
+void bnxt_dcb_init(struct bnxt_softc *softc);
+void bnxt_dcb_free(struct bnxt_softc *softc);
+uint8_t bnxt_dcb_setdcbx(struct bnxt_softc *softc, uint8_t mode);
+uint8_t bnxt_dcb_getdcbx(struct bnxt_softc *softc);
+int bnxt_dcb_ieee_getets(struct bnxt_softc *softc, struct bnxt_ieee_ets *ets);
+int bnxt_dcb_ieee_setets(struct bnxt_softc *softc, struct bnxt_ieee_ets *ets);
+uint8_t get_phy_type(struct bnxt_softc *softc);
+int bnxt_dcb_ieee_getpfc(struct bnxt_softc *softc, struct bnxt_ieee_pfc *pfc);
+int bnxt_dcb_ieee_setpfc(struct bnxt_softc *softc, struct bnxt_ieee_pfc *pfc);
+int bnxt_dcb_ieee_setapp(struct bnxt_softc *softc, struct bnxt_dcb_app *app);
+int bnxt_dcb_ieee_delapp(struct bnxt_softc *softc, struct bnxt_dcb_app *app);
+int bnxt_dcb_ieee_listapp(struct bnxt_softc *softc, struct bnxt_dcb_app *app, int *num_inputs);
+
+#endif /* _BNXT_H */
diff --git a/sys/dev/bnxt/bnxt_en/bnxt_auxbus_compat.c b/sys/dev/bnxt/bnxt_en/bnxt_auxbus_compat.c
new file mode 100644
index 000000000000..1014d360015a
--- /dev/null
+++ b/sys/dev/bnxt/bnxt_en/bnxt_auxbus_compat.c
@@ -0,0 +1,194 @@
+/*-
+ * Broadcom NetXtreme-C/E network driver.
+ *
+ * Copyright (c) 2024 Broadcom, All Rights Reserved.
+ * The term Broadcom refers to Broadcom Limited and/or its subsidiaries
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <linux/device.h>
+#include <linux/slab.h>
+#include <linux/string.h>
+#include <linux/types.h>
+#include <linux/list.h>
+#include <linux/delay.h>
+
+#include "bnxt_auxbus_compat.h"
+
+static struct list_head bnxt_aux_bus_dev_list = LINUX_LIST_HEAD_INIT(bnxt_aux_bus_dev_list);
+static struct list_head bnxt_aux_bus_drv_list = LINUX_LIST_HEAD_INIT(bnxt_aux_bus_drv_list);
+static DEFINE_MUTEX(bnxt_auxbus_lock);
+
+static const struct auxiliary_device_id *auxiliary_match_id(const struct auxiliary_device_id *id,
+							    const struct auxiliary_device *auxdev)
+{
+	for (; id->name[0]; id++) {
+		const char *p = strrchr(dev_name(&auxdev->dev), '.');
+		int match_size;
+
+		if (!p)
+			continue;
+		match_size = p - dev_name(&auxdev->dev);
+
+		if (strlen(id->name) == match_size &&
+		    !strncmp(dev_name(&auxdev->dev), id->name, match_size))
+			return id;
+	}
+	return NULL;
+}
+
+int auxiliary_device_init(struct auxiliary_device *auxdev)
+{
+	struct device *dev = &auxdev->dev;
+	char *modname = KBUILD_MODNAME;
+	int ret;
+
+	if (!dev->parent) {
+		pr_err("auxiliary_device has a NULL dev->parent\n");
+		return -EINVAL;
+	}
+
+	if (!auxdev->name) {
+		pr_err("auxiliary_device has a NULL name\n");
+		return -EINVAL;
+	}
+
+	ret = dev_set_name(dev, "%s.%s.%d", modname, auxdev->name, auxdev->id);
+	if (ret) {
+		dev_err(dev, "auxiliary device dev_set_name failed: %d\n", ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+int auxiliary_device_add(struct auxiliary_device *auxdev)
+{
+	const struct auxiliary_device_id *id;
+	struct auxiliary_driver *auxdrv = NULL;
+	bool found = true;
+	int ret = 0;
+
+	mutex_lock(&bnxt_auxbus_lock);
+	list_for_each_entry(auxdrv, &bnxt_aux_bus_drv_list, list) {
+		if (auxdrv) {
+			msleep(2 * 1000);
+
+			id = auxiliary_match_id(auxdrv->id_table, auxdev);
+			if (id) {
+				ret = auxdrv->probe(auxdev, id);
+				if (!ret)
+					auxdev->dev.driver = &auxdrv->driver;
+				else
+					found = false;
+				break;
+			}
+		}
+	}
+
+	if (found)
+		list_add_tail(&auxdev->list, &bnxt_aux_bus_dev_list);
+	mutex_unlock(&bnxt_auxbus_lock);
+
+	return ret;
+}
+
+void auxiliary_device_uninit(struct auxiliary_device *auxdev)
+{
+	return;
+}
+
+void auxiliary_device_delete(struct auxiliary_device *auxdev)
+{
+	struct auxiliary_driver *auxdrv;
+
+	mutex_lock(&bnxt_auxbus_lock);
+	list_for_each_entry(auxdrv, &bnxt_aux_bus_drv_list, list) {
+		if (auxdev->dev.driver != &auxdrv->driver)
+			continue;
+		if (auxdrv->remove)
+			auxdrv->remove(auxdev);
+		auxdev->dev.driver = NULL;
+	}
+	list_del(&auxdev->list);
+	mutex_unlock(&bnxt_auxbus_lock);
+}
+
+int auxiliary_driver_register(struct auxiliary_driver *auxdrv)
+{
+	const struct auxiliary_device_id *id;
+	struct auxiliary_device *auxdev;
+	int ret = 0;
+
+	if (WARN_ON(!auxdrv->probe) || WARN_ON(!auxdrv->id_table))
+		return -EINVAL;
+
+	if (auxdrv->name)
+		auxdrv->driver.name = kasprintf(GFP_KERNEL, "%s.%s", KBUILD_MODNAME,
+						auxdrv->name);
+	else
+		auxdrv->driver.name = kasprintf(GFP_KERNEL, "%s", KBUILD_MODNAME);
+	if (!auxdrv->driver.name)
+		return -ENOMEM;
+
+	mutex_lock(&bnxt_auxbus_lock);
+	list_for_each_entry(auxdev, &bnxt_aux_bus_dev_list, list) {
+		if (auxdev->dev.driver)
+			continue;
+
+		id = auxiliary_match_id(auxdrv->id_table, auxdev);
+		if (id) {
+			ret = auxdrv->probe(auxdev, id);
+			if (ret)
+				continue;
+			auxdev->dev.driver = &auxdrv->driver;
+		}
+	}
+	list_add_tail(&auxdrv->list, &bnxt_aux_bus_drv_list);
+	mutex_unlock(&bnxt_auxbus_lock);
+	return 0;
+}
+EXPORT_SYMBOL(auxiliary_driver_register);
+
+void auxiliary_driver_unregister(struct auxiliary_driver *auxdrv)
+{
+	struct auxiliary_device *auxdev;
+
+	/* PF auxiliary devices are added to the list first and then VF devices.
+	 * If we remove PF aux device driver first, it causes failures while
+	 * removing VF driver.
+	 * We need to remove VF auxiliary drivers first, so walk backwards.
+	 */
+	mutex_lock(&bnxt_auxbus_lock);
+	list_for_each_entry_reverse(auxdev, &bnxt_aux_bus_dev_list, list) {
+		if (auxdev->dev.driver != &auxdrv->driver)
+			continue;
+		if (auxdrv->remove)
+			auxdrv->remove(auxdev);
+		auxdev->dev.driver = NULL;
+	}
+	kfree(auxdrv->driver.name);
+	list_del(&auxdrv->list);
+	mutex_unlock(&bnxt_auxbus_lock);
+}
+EXPORT_SYMBOL(auxiliary_driver_unregister);
diff --git a/sys/dev/bnxt/bnxt_en/bnxt_auxbus_compat.h b/sys/dev/bnxt/bnxt_en/bnxt_auxbus_compat.h
new file mode 100644
index 000000000000..1d844a67c928
--- /dev/null
+++ b/sys/dev/bnxt/bnxt_en/bnxt_auxbus_compat.h
@@ -0,0 +1,75 @@
+/*-
+ * Broadcom NetXtreme-C/E network driver.
+ *
+ * Copyright (c) 2024 Broadcom, All Rights Reserved.
+ * The term Broadcom refers to Broadcom Limited and/or its subsidiaries
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _BNXT_AUXILIARY_COMPAT_H_
+#define _BNXT_AUXILIARY_COMPAT_H_
+
+#include <linux/device.h>
+#include <linux/idr.h>
+
+#define KBUILD_MODNAME		"if_bnxt"
+#define AUXILIARY_NAME_SIZE	32
+
+struct auxiliary_device_id {
+	char name[AUXILIARY_NAME_SIZE];
+	uint64_t driver_data;
+};
+
+struct auxiliary_device {
+	struct device dev;
+	const char *name;
+	uint32_t id;
+	struct list_head list;
+};
+
+struct auxiliary_driver {
+	int (*probe)(struct auxiliary_device *auxdev, const struct auxiliary_device_id *id);
+	void (*remove)(struct auxiliary_device *auxdev);
+	const char *name;
+	struct device_driver driver;
+	const struct auxiliary_device_id *id_table;
+	struct list_head list;
+};
+
+int auxiliary_device_init(struct auxiliary_device *auxdev);
+int auxiliary_device_add(struct auxiliary_device *auxdev);
+void auxiliary_device_uninit(struct auxiliary_device *auxdev);
+void auxiliary_device_delete(struct auxiliary_device *auxdev);
+int auxiliary_driver_register(struct auxiliary_driver *auxdrv);
+void auxiliary_driver_unregister(struct auxiliary_driver *auxdrv);
+
+static inline void *auxiliary_get_drvdata(struct auxiliary_device *auxdev)
+{
+	return dev_get_drvdata(&auxdev->dev);
+}
+
+static inline void auxiliary_set_drvdata(struct auxiliary_device *auxdev, void *data)
+{
+	dev_set_drvdata(&auxdev->dev, data);
+}
+#endif /* _BNXT_AUXILIARY_COMPAT_H_ */
diff --git a/sys/dev/bnxt/bnxt_en/bnxt_dcb.c b/sys/dev/bnxt/bnxt_en/bnxt_dcb.c
new file mode 100644
index 000000000000..e1e0581d3c24
--- /dev/null
+++ b/sys/dev/bnxt/bnxt_en/bnxt_dcb.c
@@ -0,0 +1,861 @@
+/*-
+ * Broadcom NetXtreme-C/E network driver.
+ *
+ * Copyright (c) 2024 Broadcom, All Rights Reserved.
+ * The term Broadcom refers to Broadcom Limited and/or its subsidiaries
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/endian.h>
+#include <linux/errno.h>
+#include <linux/bitops.h>
+
+#include "bnxt.h"
+#include "bnxt_hwrm.h"
+#include "bnxt_dcb.h"
+#include "hsi_struct_def.h"
+
+static int
+bnxt_tx_queue_to_tc(struct bnxt_softc *softc, uint8_t queue_id)
+{
+	int i, j;
+
+	for (i = 0; i < softc->max_tc; i++) {
+		if (softc->tx_q_info[i].queue_id == queue_id) {
+			for (j = 0; j < softc->max_tc; j++) {
+				if (softc->tc_to_qidx[j] == i)
+					return j;
+			}
+		}
+	}
+	return -EINVAL;
+}
+
+static int
+bnxt_hwrm_queue_pri2cos_cfg(struct bnxt_softc *softc,
+				       struct bnxt_ieee_ets *ets,
+				       uint32_t path_dir)
+{
+	struct hwrm_queue_pri2cos_cfg_input req = {0};
+	struct bnxt_queue_info *q_info;
+	uint8_t *pri2cos;
+	int i;
+
+	bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_QUEUE_PRI2COS_CFG);
+
+	req.flags = htole32(path_dir | HWRM_QUEUE_PRI2COS_CFG_INPUT_FLAGS_IVLAN);
+	if (path_dir == HWRM_QUEUE_PRI2COS_CFG_INPUT_FLAGS_PATH_BIDIR ||
+	    path_dir == HWRM_QUEUE_PRI2COS_CFG_INPUT_FLAGS_PATH_TX)
+		q_info = softc->tx_q_info;
+	else
+		q_info = softc->rx_q_info;
+	pri2cos = &req.pri0_cos_queue_id;
+	for (i = 0; i < BNXT_IEEE_8021QAZ_MAX_TCS; i++) {
+		uint8_t qidx;
+
+		req.enables |= htole32(HWRM_QUEUE_PRI2COS_CFG_INPUT_ENABLES_PRI0_COS_QUEUE_ID << i);
+
+		qidx = softc->tc_to_qidx[ets->prio_tc[i]];
+		pri2cos[i] = q_info[qidx].queue_id;
+	}
+	return _hwrm_send_message(softc, &req, sizeof(req));
+}
+
+static int
+bnxt_hwrm_queue_pri2cos_qcfg(struct bnxt_softc *softc, struct bnxt_ieee_ets *ets)
+{
+	struct hwrm_queue_pri2cos_qcfg_output *resp =
+		(void *)softc->hwrm_cmd_resp.idi_vaddr;
+	struct hwrm_queue_pri2cos_qcfg_input req = {0};
+	int rc;
+
+	bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_QUEUE_PRI2COS_QCFG);
+
+	req.flags = htole32(HWRM_QUEUE_PRI2COS_QCFG_INPUT_FLAGS_IVLAN);
+	rc = _hwrm_send_message(softc, &req, sizeof(req));
+	if (!rc) {
+		uint8_t *pri2cos = &resp->pri0_cos_queue_id;
+		int i;
+
+		for (i = 0; i < BNXT_IEEE_8021QAZ_MAX_TCS; i++) {
+			uint8_t queue_id = pri2cos[i];
+			int tc;
+
+			tc = bnxt_tx_queue_to_tc(softc, queue_id);
+			if (tc >= 0)
+				ets->prio_tc[i] = tc;
+		}
+	}
+	return rc;
+}
+
+static int
+bnxt_hwrm_queue_cos2bw_cfg(struct bnxt_softc *softc, struct bnxt_ieee_ets *ets,
+				      uint8_t max_tc)
+{
+	struct hwrm_queue_cos2bw_cfg_input req = {0};
+	struct bnxt_cos2bw_cfg cos2bw;
+	void *data;
+	int i;
+
+	bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_QUEUE_COS2BW_CFG);
+
+	for (i = 0; i < max_tc; i++) {
+		uint8_t qidx = softc->tc_to_qidx[i];
+
+		req.enables |=
+			htole32(HWRM_QUEUE_COS2BW_CFG_INPUT_ENABLES_COS_QUEUE_ID0_VALID << qidx);
+
+		memset(&cos2bw, 0, sizeof(cos2bw));
+		cos2bw.queue_id = softc->tx_q_info[qidx].queue_id;
+		if (ets->tc_tsa[i] == BNXT_IEEE_8021QAZ_TSA_STRICT) {
+			cos2bw.tsa =
+				HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_TSA_ASSIGN_SP;
+			cos2bw.pri_lvl = i;
+		} else {
+			cos2bw.tsa =
+				HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_TSA_ASSIGN_ETS;
+			cos2bw.bw_weight = ets->tc_tx_bw[i];
+			/* older firmware requires min_bw to be set to the
+			 * same weight value in percent.
+			 */
+			if (BNXT_FW_MAJ(softc) < 218) {
+				cos2bw.min_bw =
+					htole32((ets->tc_tx_bw[i] * 100) |
+						    BW_VALUE_UNIT_PERCENT1_100);
+			}
+		}
+		data = &req.unused_0 + qidx * (sizeof(cos2bw) - 4);
+		memcpy(data, &cos2bw.queue_id, sizeof(cos2bw) - 4);
+		if (qidx == 0) {
+			req.queue_id0 = cos2bw.queue_id;
+			req.unused_0 = 0;
+		}
+	}
+	return _hwrm_send_message(softc, &req, sizeof(req));
+}
+
+static int
+bnxt_hwrm_queue_cos2bw_qcfg(struct bnxt_softc *softc, struct bnxt_ieee_ets *ets)
+{
+	struct hwrm_queue_cos2bw_qcfg_output *resp =
+		(void *)softc->hwrm_cmd_resp.idi_vaddr;
+	struct hwrm_queue_cos2bw_qcfg_input req = {0};
+	struct bnxt_cos2bw_cfg cos2bw;
+	uint8_t *data;
+	int rc, i;
+
+	bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_QUEUE_COS2BW_QCFG);
+
+	rc = _hwrm_send_message(softc, &req, sizeof(req));
+	if (rc) {
+		return rc;
+	}
+
+	data = &resp->queue_id0 + offsetof(struct bnxt_cos2bw_cfg, queue_id);
+	for (i = 0; i < softc->max_tc; i++, data += sizeof(cos2bw.cfg)) {
+		int tc;
+
+		memcpy(&cos2bw.cfg, data, sizeof(cos2bw.cfg));
+		if (i == 0)
+			cos2bw.queue_id = resp->queue_id0;
+
+		tc = bnxt_tx_queue_to_tc(softc, cos2bw.queue_id);
+		if (tc < 0)
+			continue;
+
+		if (cos2bw.tsa == HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_TSA_ASSIGN_SP) {
+			ets->tc_tsa[tc] = BNXT_IEEE_8021QAZ_TSA_STRICT;
+		} else {
+			ets->tc_tsa[tc] = BNXT_IEEE_8021QAZ_TSA_ETS;
+			ets->tc_tx_bw[tc] = cos2bw.bw_weight;
+		}
+	}
+	return 0;
+}
+
+static int
+bnxt_queue_remap(struct bnxt_softc *softc, unsigned int lltc_mask)
+{
+	unsigned long qmap = 0;
+	int max = softc->max_tc;
+	int i, j, rc;
+
+	/* Assign lossless TCs first */
+	for (i = 0, j = 0; i < max; ) {
+		if (lltc_mask & (1 << i)) {
+			if (BNXT_LLQ(softc->rx_q_info[j].queue_profile)) {
+				softc->tc_to_qidx[i] = j;
+				__set_bit(j, &qmap);
+				i++;
+			}
+			j++;
+			continue;
+		}
+		i++;
+	}
+
+	for (i = 0, j = 0; i < max; i++) {
+		if (lltc_mask & (1 << i))
+			continue;
+		j = find_next_zero_bit(&qmap, max, j);
+		softc->tc_to_qidx[i] = j;
+		__set_bit(j, &qmap);
+		j++;
+	}
+
+	if (softc->ieee_ets) {
+		rc = bnxt_hwrm_queue_cos2bw_cfg(softc, softc->ieee_ets, softc->max_tc);
+		if (rc) {
+			device_printf(softc->dev, "failed to config BW, rc = %d\n", rc);
+			return rc;
+		}
+		rc = bnxt_hwrm_queue_pri2cos_cfg(softc, softc->ieee_ets,
+						 HWRM_QUEUE_PRI2COS_CFG_INPUT_FLAGS_PATH_BIDIR);
+		if (rc) {
+			device_printf(softc->dev, "failed to config prio, rc = %d\n", rc);
+			return rc;
+		}
+	}
+	return 0;
+}
+
+static int
+bnxt_hwrm_queue_pfc_cfg(struct bnxt_softc *softc, struct bnxt_ieee_pfc *pfc)
+{
+	struct hwrm_queue_pfcenable_cfg_input req = {0};
+	struct bnxt_ieee_ets *my_ets = softc->ieee_ets;
+	unsigned int tc_mask = 0, pri_mask = 0;
+	uint8_t i, pri, lltc_count = 0;
+	bool need_q_remap = false;
+
+	if (!my_ets)
+		return -EINVAL;
+
+	for (i = 0; i < softc->max_tc; i++) {
+		for (pri = 0; pri < BNXT_IEEE_8021QAZ_MAX_TCS; pri++) {
+			if ((pfc->pfc_en & (1 << pri)) &&
+			    (my_ets->prio_tc[pri] == i)) {
+				pri_mask |= 1 << pri;
+				tc_mask |= 1 << i;
+			}
+		}
+		if (tc_mask & (1 << i))
+			lltc_count++;
+	}
+
+	if (lltc_count > softc->max_lltc) {
+		device_printf(softc->dev,
+			       "Hardware doesn't support %d lossless queues "
+			       "to configure PFC (cap %d)\n", lltc_count, softc->max_lltc);
+		return -EINVAL;
+	}
+
+	for (i = 0; i < softc->max_tc; i++) {
+		if (tc_mask & (1 << i)) {
+			uint8_t qidx = softc->tc_to_qidx[i];
+
+			if (!BNXT_LLQ(softc->rx_q_info[qidx].queue_profile)) {
+				need_q_remap = true;
+				break;
+			}
+		}
+	}
+
+	if (need_q_remap)
+		bnxt_queue_remap(softc, tc_mask);
+
+	bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_QUEUE_PFCENABLE_CFG);
+
+	req.flags = htole32(pri_mask);
+	return _hwrm_send_message(softc, &req, sizeof(req));
+}
+
+static int
+bnxt_hwrm_queue_pfc_qcfg(struct bnxt_softc *softc, struct bnxt_ieee_pfc *pfc)
+{
+	struct hwrm_queue_pfcenable_qcfg_output *resp =
+		(void *)softc->hwrm_cmd_resp.idi_vaddr;
+	struct hwrm_queue_pfcenable_qcfg_input req = {0};
+	uint8_t pri_mask;
+	int rc;
+
+	bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_QUEUE_PFCENABLE_QCFG);
+
+	rc = _hwrm_send_message(softc, &req, sizeof(req));
+	if (rc) {
+		return rc;
+	}
+
+	pri_mask = le32toh(resp->flags);
+	pfc->pfc_en = pri_mask;
+	return 0;
+}
+
+static int
+bnxt_hwrm_get_dcbx_app(struct bnxt_softc *softc, struct bnxt_dcb_app *app, int *num_inputs)
+{
+	struct hwrm_fw_get_structured_data_input get = {0};
+	struct hwrm_struct_data_dcbx_app *fw_app;
+	struct hwrm_struct_hdr *data;
+	struct iflib_dma_info dma_data;
+	size_t data_len;
+	int rc, n, i;
+
+	if (softc->hwrm_spec_code < 0x10601)
+		return 0;
+
+	bnxt_hwrm_cmd_hdr_init(softc, &get, HWRM_FW_GET_STRUCTURED_DATA);
+
+	n = BNXT_IEEE_8021QAZ_MAX_TCS;
+	data_len = sizeof(*data) + sizeof(*fw_app) * n;
+	rc = iflib_dma_alloc(softc->ctx, data_len, &dma_data,
+			     BUS_DMA_NOWAIT);
+	if (rc)
+		return ENOMEM;
+	get.dest_data_addr = htole64(dma_data.idi_paddr);
+	get.structure_id = htole16(HWRM_STRUCT_HDR_STRUCT_ID_DCBX_APP);
+	get.subtype = htole16(HWRM_STRUCT_DATA_SUBTYPE_HOST_OPERATIONAL);
+	get.count = 0;
+	rc = _hwrm_send_message(softc, &get, sizeof(get));
+	if (rc)
+		goto set_app_exit;
+
+	data = (void *)dma_data.idi_vaddr;
+	fw_app = (struct hwrm_struct_data_dcbx_app *)(data + 1);
+
+	if (data->struct_id != htole16(HWRM_STRUCT_HDR_STRUCT_ID_DCBX_APP)) {
+		rc = -ENODEV;
+		goto set_app_exit;
+	}
+
+	n = data->count;
+	for (i = 0; i < n; i++, fw_app++) {
+		app[*num_inputs].priority = fw_app->priority;
+		app[*num_inputs].protocol = htobe16(fw_app->protocol_id);
+		app[*num_inputs].selector = fw_app->protocol_selector;
+		(*num_inputs)++;
+	}
+
+set_app_exit:
+	iflib_dma_free(&dma_data);
+	return rc;
+}
+
+static int
+bnxt_hwrm_set_dcbx_app(struct bnxt_softc *softc, struct bnxt_dcb_app *app,
+				  bool add)
+{
+	struct hwrm_fw_set_structured_data_input set = {0};
+	struct hwrm_fw_get_structured_data_input get = {0};
+	struct hwrm_struct_data_dcbx_app *fw_app;
+	struct hwrm_struct_hdr *data;
+	struct iflib_dma_info dma_data;
+	size_t data_len;
+	int rc, n, i;
+
+	if (softc->hwrm_spec_code < 0x10601)
+		return 0;
+
+	bnxt_hwrm_cmd_hdr_init(softc, &get, HWRM_FW_GET_STRUCTURED_DATA);
+
+	n = BNXT_IEEE_8021QAZ_MAX_TCS;
+	data_len = sizeof(*data) + sizeof(*fw_app) * n;
+	rc = iflib_dma_alloc(softc->ctx, data_len, &dma_data,
+			     BUS_DMA_NOWAIT);
+	if (rc)
+		return ENOMEM;
+	get.dest_data_addr = htole64(dma_data.idi_paddr);
+	get.structure_id = htole16(HWRM_STRUCT_HDR_STRUCT_ID_DCBX_APP);
+	get.subtype = htole16(HWRM_STRUCT_DATA_SUBTYPE_HOST_OPERATIONAL);
+	get.count = 0;
+	rc = _hwrm_send_message(softc, &get, sizeof(get));
+	if (rc)
+		goto set_app_exit;
+
+	data = (void *)dma_data.idi_vaddr;
+	fw_app = (struct hwrm_struct_data_dcbx_app *)(data + 1);
+
+	if (data->struct_id != htole16(HWRM_STRUCT_HDR_STRUCT_ID_DCBX_APP)) {
+		rc = -ENODEV;
+		goto set_app_exit;
+	}
+
+	n = data->count;
+	for (i = 0; i < n; i++, fw_app++) {
+		if (fw_app->protocol_id == htobe16(app->protocol) &&
+		    fw_app->protocol_selector == app->selector &&
+		    fw_app->priority == app->priority) {
+			if (add)
+				goto set_app_exit;
+			else
+				break;
+		}
+	}
+	if (add) {
+		/* append */
+		n++;
+		fw_app->protocol_id = htobe16(app->protocol);
+		fw_app->protocol_selector = app->selector;
+		fw_app->priority = app->priority;
+		fw_app->valid = 1;
+	} else {
+		size_t len = 0;
+
+		/* not found, nothing to delete */
+		if (n == i)
+			goto set_app_exit;
+
+		len = (n - 1 - i) * sizeof(*fw_app);
+		if (len)
+			memmove(fw_app, fw_app + 1, len);
+		n--;
+		memset(fw_app + n, 0, sizeof(*fw_app));
+	}
+	data->count = n;
+	data->len = htole16(sizeof(*fw_app) * n);
+	data->subtype = htole16(HWRM_STRUCT_DATA_SUBTYPE_HOST_OPERATIONAL);
+
+	bnxt_hwrm_cmd_hdr_init(softc, &set, HWRM_FW_SET_STRUCTURED_DATA);
+
+	set.src_data_addr = htole64(dma_data.idi_paddr);
+	set.data_len = htole16(sizeof(*data) + sizeof(*fw_app) * n);
+	set.hdr_cnt = 1;
+	rc = _hwrm_send_message(softc, &set, sizeof(set));
+
+set_app_exit:
+	iflib_dma_free(&dma_data);
+	return rc;
+}
+
+static int
+bnxt_hwrm_queue_dscp_qcaps(struct bnxt_softc *softc)
+{
+	struct hwrm_queue_dscp_qcaps_output *resp =
+		(void *)softc->hwrm_cmd_resp.idi_vaddr;
+	struct hwrm_queue_dscp_qcaps_input req = {0};
+	int rc;
+
+	softc->max_dscp_value = 0;
+	if (softc->hwrm_spec_code < 0x10800 || BNXT_VF(softc))
+		return 0;
+
+	bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_QUEUE_DSCP_QCAPS);
+
+	rc = _hwrm_send_message(softc, &req, sizeof(req));
+	if (!rc) {
+		softc->max_dscp_value = (1 << resp->num_dscp_bits) - 1;
+		if (softc->max_dscp_value < 0x3f)
+			softc->max_dscp_value = 0;
+	}
+	return rc;
+}
+
+static int
+bnxt_hwrm_queue_dscp2pri_qcfg(struct bnxt_softc *softc, struct bnxt_dcb_app *app, int *num_inputs)
+{
+	struct hwrm_queue_dscp2pri_qcfg_input req = {0};
+	struct hwrm_queue_dscp2pri_qcfg_output *resp =
+		(void *)softc->hwrm_cmd_resp.idi_vaddr;
+	struct bnxt_dscp2pri_entry *dscp2pri;
+	struct iflib_dma_info dma_data;
+	int rc, entry_cnt;
+	int i;
+
+	if (softc->hwrm_spec_code < 0x10800)
+		return 0;
+
+	rc = iflib_dma_alloc(softc->ctx, sizeof(*dscp2pri) * 128, &dma_data,
+			     BUS_DMA_NOWAIT);
+	if (rc)
+		return ENOMEM;
+
+	dscp2pri = (void *)dma_data.idi_vaddr;
+
+	bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_QUEUE_DSCP2PRI_QCFG);
+
+	req.dest_data_addr = htole64(dma_data.idi_paddr);
+	req.dest_data_buffer_size = htole16(sizeof(*dscp2pri) * 64);
+	req.port_id = htole16(softc->pf.port_id);
+	rc = _hwrm_send_message(softc, &req, sizeof(req));
+
+	if (rc)
+		goto end;
+
+	entry_cnt =  le16toh(resp->entry_cnt);
+	for (i = 0; i < entry_cnt; i++) {
+		app[*num_inputs].priority = dscp2pri[i].pri;
+		app[*num_inputs].protocol = dscp2pri[i].dscp;
+		app[*num_inputs].selector = BNXT_IEEE_8021QAZ_APP_SEL_DSCP;
+		(*num_inputs)++;
+	}
+
+end:
+	iflib_dma_free(&dma_data);
+	return rc;
+}
+
+static int
+bnxt_hwrm_queue_dscp2pri_cfg(struct bnxt_softc *softc, struct bnxt_dcb_app *app,
+			     bool add)
+{
+	struct hwrm_queue_dscp2pri_cfg_input req = {0};
+	struct bnxt_dscp2pri_entry *dscp2pri;
+	struct iflib_dma_info dma_data;
+	int rc;
+
+	if (softc->hwrm_spec_code < 0x10800)
+		return 0;
+
+	rc = iflib_dma_alloc(softc->ctx, sizeof(*dscp2pri), &dma_data,
+			     BUS_DMA_NOWAIT);
+	if (rc)
+		return ENOMEM;
+
+	bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_QUEUE_DSCP2PRI_CFG);
+
+	req.src_data_addr = htole64(dma_data.idi_paddr);
+	dscp2pri = (void *)dma_data.idi_vaddr;
+	dscp2pri->dscp = app->protocol;
+	if (add)
+		dscp2pri->mask = 0x3f;
+	else
+		dscp2pri->mask = 0;
+	dscp2pri->pri = app->priority;
+	req.entry_cnt = htole16(1);
+	req.port_id = htole16(softc->pf.port_id);
+	rc = _hwrm_send_message(softc, &req, sizeof(req));
+
+	iflib_dma_free(&dma_data);
+	return rc;
+}
+
+static int
+bnxt_ets_validate(struct bnxt_softc *softc, struct bnxt_ieee_ets *ets, uint8_t *tc)
+{
+	int total_ets_bw = 0;
+	bool zero = false;
+	uint8_t max_tc = 0;
+	int i;
+
+	for (i = 0; i < BNXT_IEEE_8021QAZ_MAX_TCS; i++) {
+		if (ets->prio_tc[i] > softc->max_tc) {
+			device_printf(softc->dev, "priority to TC mapping exceeds TC count %d\n",
+				   ets->prio_tc[i]);
+			return -EINVAL;
+		}
+		if (ets->prio_tc[i] > max_tc)
+			max_tc = ets->prio_tc[i];
+
+		if ((ets->tc_tx_bw[i] || ets->tc_tsa[i]) && i > softc->max_tc)
+			return -EINVAL;
+
+		switch (ets->tc_tsa[i]) {
+		case BNXT_IEEE_8021QAZ_TSA_STRICT:
+			break;
+		case BNXT_IEEE_8021QAZ_TSA_ETS:
+			total_ets_bw += ets->tc_tx_bw[i];
+			zero = zero || !ets->tc_tx_bw[i];
+			break;
+		default:
+			return -ENOTSUPP;
+		}
+	}
+	if (total_ets_bw > 100) {
+		device_printf(softc->dev, "rejecting ETS config exceeding available bandwidth\n");
+		return -EINVAL;
+	}
+	if (zero && total_ets_bw == 100) {
+		device_printf(softc->dev, "rejecting ETS config starving a TC\n");
+		return -EINVAL;
+	}
+
+	if (max_tc >= softc->max_tc)
+		*tc = softc->max_tc;
+	else
+		*tc = max_tc + 1;
+	return 0;
+}
+
+int
+bnxt_dcb_ieee_getets(struct bnxt_softc *softc, struct bnxt_ieee_ets *ets)
+{
+	struct bnxt_ieee_ets *my_ets = softc->ieee_ets;
+	int rc;
+
+	if (!my_ets)
+		return 0;
+
+	rc = bnxt_hwrm_queue_cos2bw_qcfg(softc, my_ets);
+	if (rc)
+		goto error;
+	rc = bnxt_hwrm_queue_pri2cos_qcfg(softc, my_ets);
+	if (rc)
+		goto error;
+
+	if (ets) {
+		ets->cbs = my_ets->cbs;
+		ets->ets_cap = softc->max_tc;
+		memcpy(ets->tc_tx_bw, my_ets->tc_tx_bw, sizeof(ets->tc_tx_bw));
+		memcpy(ets->tc_rx_bw, my_ets->tc_rx_bw, sizeof(ets->tc_rx_bw));
+		memcpy(ets->tc_tsa, my_ets->tc_tsa, sizeof(ets->tc_tsa));
+		memcpy(ets->prio_tc, my_ets->prio_tc, sizeof(ets->prio_tc));
+	}
+	return 0;
+error:
+	return rc;
+}
+
+int
+bnxt_dcb_ieee_setets(struct bnxt_softc *softc, struct bnxt_ieee_ets *ets)
+{
+	uint8_t max_tc = 0;
+	int rc;
+
+	if (!(softc->dcbx_cap & BNXT_DCB_CAP_DCBX_VER_IEEE) ||
+	    !(softc->dcbx_cap & BNXT_DCB_CAP_DCBX_HOST))
+		return -EINVAL;
+
+	rc = bnxt_ets_validate(softc, ets, &max_tc);
+	if (rc)
+		return rc;
+
+	rc = bnxt_hwrm_queue_cos2bw_cfg(softc, ets, max_tc);
+	if (rc)
+		goto error;
+
+	if (!softc->is_asym_q) {
+		rc = bnxt_hwrm_queue_pri2cos_cfg(softc, ets,
+						 HWRM_QUEUE_PRI2COS_CFG_INPUT_FLAGS_PATH_BIDIR);
+		if (rc)
+			goto error;
+	} else {
+		rc = bnxt_hwrm_queue_pri2cos_cfg(softc, ets,
+						 HWRM_QUEUE_PRI2COS_QCFG_INPUT_FLAGS_PATH_TX);
+		if (rc)
+			goto error;
+
+		rc = bnxt_hwrm_queue_pri2cos_cfg(softc, ets,
+						 HWRM_QUEUE_PRI2COS_QCFG_INPUT_FLAGS_PATH_RX);
+		if (rc)
+			goto error;
+	}
+
+	memcpy(softc->ieee_ets, ets, sizeof(*ets));
+	return 0;
+error:
+	return rc;
+}
+
+int
+bnxt_dcb_ieee_getpfc(struct bnxt_softc *softc, struct bnxt_ieee_pfc *pfc)
+{
+	struct bnxt_ieee_pfc *my_pfc = softc->ieee_pfc;
+	int rc;
+
+	if (!my_pfc)
+		return -1;
+
+	pfc->pfc_cap = softc->max_lltc;
+
+	rc = bnxt_hwrm_queue_pfc_qcfg(softc, my_pfc);
+	if (rc)
+		return 0;
+
+	pfc->pfc_en = my_pfc->pfc_en;
+	pfc->mbc = my_pfc->mbc;
+	pfc->delay = my_pfc->delay;
+
+	return 0;
+}
+
+int
+bnxt_dcb_ieee_setpfc(struct bnxt_softc *softc, struct bnxt_ieee_pfc *pfc)
+{
+	struct bnxt_ieee_pfc *my_pfc = softc->ieee_pfc;
+	int rc;
+
+	if (!my_pfc)
+		return -1;
+
+	if (!(softc->dcbx_cap & BNXT_DCB_CAP_DCBX_VER_IEEE) ||
+	    !(softc->dcbx_cap & BNXT_DCB_CAP_DCBX_HOST) ||
+	    (softc->phy_flags & BNXT_PHY_FL_NO_PAUSE))
+		return -EINVAL;
+
+	rc = bnxt_hwrm_queue_pfc_cfg(softc, pfc);
+	if (!rc)
+		memcpy(my_pfc, pfc, sizeof(*my_pfc));
+
+	return rc;
+}
+
+static int
+bnxt_dcb_ieee_dscp_app_prep(struct bnxt_softc *softc, struct bnxt_dcb_app *app)
+{
+	if (app->selector == BNXT_IEEE_8021QAZ_APP_SEL_DSCP) {
+		if (!softc->max_dscp_value)
+			return -ENOTSUPP;
+		if (app->protocol > softc->max_dscp_value)
+			return -EINVAL;
+	}
+	return 0;
+}
+
+int
+bnxt_dcb_ieee_setapp(struct bnxt_softc *softc, struct bnxt_dcb_app *app)
+{
+	int rc;
+
+
+	if (!(softc->dcbx_cap & BNXT_DCB_CAP_DCBX_VER_IEEE) ||
+	    !(softc->dcbx_cap & BNXT_DCB_CAP_DCBX_HOST))
+		return -EINVAL;
+
+	rc = bnxt_dcb_ieee_dscp_app_prep(softc, app);
+	if (rc)
+		return rc;
+
+	if ((app->selector == BNXT_IEEE_8021QAZ_APP_SEL_ETHERTYPE &&
+	     app->protocol == ETH_P_ROCE) ||
+	    (app->selector == BNXT_IEEE_8021QAZ_APP_SEL_DGRAM &&
+	     app->protocol == ROCE_V2_UDP_DPORT))
+		rc = bnxt_hwrm_set_dcbx_app(softc, app, true);
+
+	if (app->selector == BNXT_IEEE_8021QAZ_APP_SEL_DSCP)
+		rc = bnxt_hwrm_queue_dscp2pri_cfg(softc, app, true);
+
+	return rc;
+}
+
+int
+bnxt_dcb_ieee_delapp(struct bnxt_softc *softc, struct bnxt_dcb_app *app)
+{
+	int rc;
+
+	if (!(softc->dcbx_cap & BNXT_DCB_CAP_DCBX_VER_IEEE) ||
+	    !(softc->dcbx_cap & BNXT_DCB_CAP_DCBX_HOST))
+		return -EINVAL;
+
+	rc = bnxt_dcb_ieee_dscp_app_prep(softc, app);
+	if (rc)
+		return rc;
+
+	if ((app->selector == BNXT_IEEE_8021QAZ_APP_SEL_ETHERTYPE &&
+	     app->protocol == ETH_P_ROCE) ||
+	    (app->selector == BNXT_IEEE_8021QAZ_APP_SEL_DGRAM &&
+	     app->protocol == ROCE_V2_UDP_DPORT))
+		rc = bnxt_hwrm_set_dcbx_app(softc, app, false);
+
+	if (app->selector == BNXT_IEEE_8021QAZ_APP_SEL_DSCP)
+		rc = bnxt_hwrm_queue_dscp2pri_cfg(softc, app, false);
+
+	return rc;
+}
+
+int
+bnxt_dcb_ieee_listapp(struct bnxt_softc *softc, struct bnxt_dcb_app *app, int *num_inputs)
+{
+	bnxt_hwrm_get_dcbx_app(softc, app, num_inputs);
+	bnxt_hwrm_queue_dscp2pri_qcfg(softc, app, num_inputs);
+
+	return 0;
+}
+
+uint8_t
+bnxt_dcb_getdcbx(struct bnxt_softc *softc)
+{
+	return softc->dcbx_cap;
+}
+
+uint8_t
+bnxt_dcb_setdcbx(struct bnxt_softc *softc, uint8_t mode)
+{
+	/* All firmware DCBX settings are set in NVRAM */
+	if (softc->dcbx_cap & BNXT_DCB_CAP_DCBX_LLD_MANAGED)
+		return 1;
+
+	/*
+	 * Do't allow editing CAP_DCBX_LLD_MANAGED since it is driven
+	 * based on FUNC_QCFG_OUTPUT_FLAGS_FW_DCBX_AGENT_ENABLED
+	 */
+	if ((softc->dcbx_cap & BNXT_DCB_CAP_DCBX_LLD_MANAGED) !=
+	    (mode & BNXT_DCB_CAP_DCBX_LLD_MANAGED))
+		return 1;
+
+	if (mode & BNXT_DCB_CAP_DCBX_HOST) {
+		if (BNXT_VF(softc) || (softc->fw_cap & BNXT_FW_CAP_LLDP_AGENT))
+			return 1;
+
+		/* only support BNXT_IEEE */
+		if ((mode & BNXT_DCB_CAP_DCBX_VER_CEE) ||
+		    !(mode & BNXT_DCB_CAP_DCBX_VER_IEEE))
+			return 1;
+	}
+
+	if (mode == softc->dcbx_cap)
+		return 0;
+
+	softc->dcbx_cap = mode;
+	return 0;
+}
+
+void
+bnxt_dcb_init(struct bnxt_softc *softc)
+{
+	struct bnxt_ieee_ets ets = {0};
+	struct bnxt_ieee_pfc pfc = {0};
+
+	softc->dcbx_cap = 0;
+
+	if (softc->hwrm_spec_code < 0x10501)
+		return;
+
+	softc->ieee_ets = malloc(sizeof(struct bnxt_ieee_ets), M_DEVBUF, M_NOWAIT | M_ZERO);
+	if (!softc->ieee_ets)
+		return;
+
+	softc->ieee_pfc = malloc(sizeof(struct bnxt_ieee_pfc), M_DEVBUF, M_NOWAIT | M_ZERO);
+	if (!softc->ieee_pfc)
+		return;
+
+	bnxt_hwrm_queue_dscp_qcaps(softc);
+	softc->dcbx_cap = BNXT_DCB_CAP_DCBX_VER_IEEE;
+	if (BNXT_PF(softc) && !(softc->fw_cap & BNXT_FW_CAP_LLDP_AGENT))
+		softc->dcbx_cap |= BNXT_DCB_CAP_DCBX_HOST;
+	else if (softc->fw_cap & BNXT_FW_CAP_DCBX_AGENT)
+		softc->dcbx_cap |= BNXT_DCB_CAP_DCBX_LLD_MANAGED;
+
+	bnxt_dcb_ieee_setets(softc, &ets);
+	bnxt_dcb_ieee_setpfc(softc, &pfc);
+
+}
+
+void
+bnxt_dcb_free(struct bnxt_softc *softc)
+{
+	free(softc->ieee_ets, M_DEVBUF);
+	softc->ieee_ets = NULL;
+	free(softc->ieee_pfc, M_DEVBUF);
+	softc->ieee_pfc = NULL;
+}
diff --git a/sys/dev/bnxt/bnxt_en/bnxt_dcb.h b/sys/dev/bnxt/bnxt_en/bnxt_dcb.h
new file mode 100644
index 000000000000..293f1b85dad5
--- /dev/null
+++ b/sys/dev/bnxt/bnxt_en/bnxt_dcb.h
@@ -0,0 +1,127 @@
+/*-
+ * Broadcom NetXtreme-C/E network driver.
+ *
+ * Copyright (c) 2024 Broadcom, All Rights Reserved.
+ * The term Broadcom refers to Broadcom Limited and/or its subsidiaries
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _BNXT_DCB_H
+#define _BNXT_DCB_H
+
+#define BNXT_IEEE_8021QAZ_MAX_TCS		8
+#define BNXT_IEEE_8021QAZ_TSA_STRICT		0
+#define BNXT_IEEE_8021QAZ_TSA_ETS		2
+#define BNXT_IEEE_8021QAZ_TSA_VENDOR		255
+
+#define BNXT_DCB_CAP_DCBX_HOST			0x01
+#define BNXT_DCB_CAP_DCBX_LLD_MANAGED		0x02
+#define BNXT_DCB_CAP_DCBX_VER_CEE		0x04
+#define BNXT_DCB_CAP_DCBX_VER_IEEE		0x08
+#define BNXT_DCB_CAP_DCBX_STATIC		0x10
+
+#define __struct_group(TAG, NAME, ATTRS, MEMBERS...) \
+	union { \
+		struct { MEMBERS } ATTRS; \
+		struct TAG { MEMBERS } ATTRS NAME; \
+	}
+#define struct_group_attr(NAME, ATTRS, MEMBERS...) \
+	__struct_group(/* no tag */, NAME, ATTRS, MEMBERS)
+
+struct bnxt_cos2bw_cfg {
+	uint8_t			pad[3];
+	struct_group_attr(cfg, __packed,
+		uint8_t			queue_id;
+		uint32_t		min_bw;
+		uint32_t		max_bw;
+#define BW_VALUE_UNIT_PERCENT1_100		(0x1UL << 29)
+		uint8_t			tsa;
+		uint8_t			pri_lvl;
+		uint8_t			bw_weight;
+	);
+	uint8_t			unused;
+};
+
+struct bnxt_dscp2pri_entry {
+	uint8_t	dscp;
+	uint8_t	mask;
+	uint8_t	pri;
+};
+
+struct bnxt_ieee_ets {
+	uint8_t    willing;
+	uint8_t    ets_cap;
+	uint8_t    cbs;
+	uint8_t    tc_tx_bw[BNXT_IEEE_8021QAZ_MAX_TCS];
+	uint8_t    tc_rx_bw[BNXT_IEEE_8021QAZ_MAX_TCS];
+	uint8_t    tc_tsa[BNXT_IEEE_8021QAZ_MAX_TCS];
+	uint8_t    prio_tc[BNXT_IEEE_8021QAZ_MAX_TCS];
+	uint8_t    tc_reco_bw[BNXT_IEEE_8021QAZ_MAX_TCS];
+	uint8_t    tc_reco_tsa[BNXT_IEEE_8021QAZ_MAX_TCS];
+	uint8_t    reco_prio_tc[BNXT_IEEE_8021QAZ_MAX_TCS];
+} __attribute__ ((__packed__));
+
+struct bnxt_ieee_pfc {
+	uint8_t    pfc_cap;
+	uint8_t    pfc_en;
+	uint8_t    mbc;
+	uint16_t   delay;
+	uint64_t   requests[BNXT_IEEE_8021QAZ_MAX_TCS];
+	uint64_t   indications[BNXT_IEEE_8021QAZ_MAX_TCS];
+} __attribute__ ((__packed__));
+
+struct bnxt_dcb_app {
+	uint8_t    selector;
+	uint8_t    priority;
+	uint16_t   protocol;
+} __attribute__ ((__packed__));
+
+struct bnxt_eee {
+	uint32_t   cmd;
+	uint32_t   supported;
+	uint32_t   advertised;
+	uint32_t   lp_advertised;
+	uint32_t   eee_active;
+	uint32_t   eee_enabled;
+	uint32_t   tx_lpi_enabled;
+	uint32_t   tx_lpi_timer;
+	uint32_t   reserved[2];
+} __attribute__ ((__packed__));
+
+#define BNXT_IEEE_8021QAZ_APP_SEL_ETHERTYPE	1
+#define BNXT_IEEE_8021QAZ_APP_SEL_STREAM	2
+#define BNXT_IEEE_8021QAZ_APP_SEL_DGRAM		3
+#define BNXT_IEEE_8021QAZ_APP_SEL_ANY		4
+#define BNXT_IEEE_8021QAZ_APP_SEL_DSCP       	5
+#define ETH_P_ROCE 				0x8915
+#define ROCE_V2_UDP_DPORT 			4791
+
+#define BNXT_LLQ(q_profile)	\
+	((q_profile) == HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_LOSSLESS_ROCE ||	\
+	 (q_profile) == HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_LOSSLESS_NIC)
+#define BNXT_CNPQ(q_profile)	\
+	((q_profile) == HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_LOSSY_ROCE_CNP)
+
+#define HWRM_STRUCT_DATA_SUBTYPE_HOST_OPERATIONAL	0x0300
+
+#endif
diff --git a/sys/dev/bnxt/bnxt_hwrm.c b/sys/dev/bnxt/bnxt_en/bnxt_hwrm.c
similarity index 62%
rename from sys/dev/bnxt/bnxt_hwrm.c
rename to sys/dev/bnxt/bnxt_en/bnxt_hwrm.c
index 88ba185e2c27..9252964900ff 100644
--- a/sys/dev/bnxt/bnxt_hwrm.c
+++ b/sys/dev/bnxt/bnxt_en/bnxt_hwrm.c
@@ -28,6 +28,7 @@
 
 #include <sys/cdefs.h>
 #include <sys/endian.h>
+#include <linux/pci.h>
 
 #include "bnxt.h"
 #include "bnxt_hwrm.h"
@@ -42,13 +43,42 @@ static void	bnxt_hwrm_set_pause_common(struct bnxt_softc *softc,
 		    struct hwrm_port_phy_cfg_input *req);
 static void	bnxt_hwrm_set_eee(struct bnxt_softc *softc,
 		    struct hwrm_port_phy_cfg_input *req);
-static int	_hwrm_send_message(struct bnxt_softc *, void *, uint32_t);
-static int	hwrm_send_message(struct bnxt_softc *, void *, uint32_t);
-static void bnxt_hwrm_cmd_hdr_init(struct bnxt_softc *, void *, uint16_t);
 
 /* NVRam stuff has a five minute timeout */
 #define BNXT_NVM_TIMEO	(5 * 60 * 1000)
 
+#define BNXT_RX_STATS_PRI_ENTRY(counter, n)		\
+	BNXT_RX_STATS_EXT_OFFSET(counter##_cos0)
+
+#define BNXT_TX_STATS_PRI_ENTRY(counter, n)		\
+	 BNXT_TX_STATS_EXT_OFFSET(counter##_cos0)
+
+#define BNXT_RX_STATS_PRI_ENTRIES(counter)		\
+	BNXT_RX_STATS_PRI_ENTRY(counter, 0),		\
+	BNXT_RX_STATS_PRI_ENTRY(counter, 1),		\
+	BNXT_RX_STATS_PRI_ENTRY(counter, 2),		\
+	BNXT_RX_STATS_PRI_ENTRY(counter, 3),		\
+	BNXT_RX_STATS_PRI_ENTRY(counter, 4),		\
+	BNXT_RX_STATS_PRI_ENTRY(counter, 5),		\
+	BNXT_RX_STATS_PRI_ENTRY(counter, 6),		\
+	BNXT_RX_STATS_PRI_ENTRY(counter, 7)
+
+#define BNXT_TX_STATS_PRI_ENTRIES(counter)		\
+	BNXT_TX_STATS_PRI_ENTRY(counter, 0),		\
+	BNXT_TX_STATS_PRI_ENTRY(counter, 1),		\
+	BNXT_TX_STATS_PRI_ENTRY(counter, 2),		\
+	BNXT_TX_STATS_PRI_ENTRY(counter, 3),		\
+	BNXT_TX_STATS_PRI_ENTRY(counter, 4),		\
+	BNXT_TX_STATS_PRI_ENTRY(counter, 5),		\
+	BNXT_TX_STATS_PRI_ENTRY(counter, 6),		\
+	BNXT_TX_STATS_PRI_ENTRY(counter, 7)
+
+
+long bnxt_rx_bytes_pri_arr_base_off[] = {BNXT_RX_STATS_PRI_ENTRIES(rx_bytes)};
+long bnxt_rx_pkts_pri_arr_base_off[] = {BNXT_RX_STATS_PRI_ENTRIES(rx_packets)};
+long bnxt_tx_bytes_pri_arr_base_off[] = {BNXT_TX_STATS_PRI_ENTRIES(tx_bytes)};
+long bnxt_tx_pkts_pri_arr_base_off[] = {BNXT_TX_STATS_PRI_ENTRIES(tx_packets)};
+
 static int
 bnxt_hwrm_err_map(uint16_t err)
 {
@@ -97,7 +127,7 @@ bnxt_free_hwrm_dma_mem(struct bnxt_softc *softc)
 	return;
 }
 
-static void
+void
 bnxt_hwrm_cmd_hdr_init(struct bnxt_softc *softc, void *request,
     uint16_t req_type)
 {
@@ -109,7 +139,7 @@ bnxt_hwrm_cmd_hdr_init(struct bnxt_softc *softc, void *request,
 	req->resp_addr = htole64(softc->hwrm_cmd_resp.idi_paddr);
 }
 
-static int
+int
 _hwrm_send_message(struct bnxt_softc *softc, void *msg, uint32_t msg_len)
 {
 	struct input *req = msg;
@@ -125,6 +155,10 @@ _hwrm_send_message(struct bnxt_softc *softc, void *msg, uint32_t msg_len)
 	req->seq_id = htole16(softc->hwrm_cmd_seq++);
 	memset(resp, 0, PAGE_SIZE);
 
+	if (BNXT_NO_FW_ACCESS(softc) &&
+	    (req->req_type != HWRM_FUNC_RESET && req->req_type != HWRM_VER_GET))
+		return -EINVAL;
+
 	if ((softc->flags & BNXT_FLAG_SHORT_CMD) ||
 	    msg_len > BNXT_HWRM_MAX_REQ_LEN) {
 		void *short_cmd_req = softc->hwrm_short_cmd_req_addr.idi_vaddr;
@@ -222,7 +256,7 @@ _hwrm_send_message(struct bnxt_softc *softc, void *msg, uint32_t msg_len)
 	return 0;
 }
 
-static int
+int
 hwrm_send_message(struct bnxt_softc *softc, void *msg, uint32_t msg_len)
 {
 	int rc;
@@ -234,13 +268,16 @@ hwrm_send_message(struct bnxt_softc *softc, void *msg, uint32_t msg_len)
 }
 
 int
-bnxt_hwrm_queue_qportcfg(struct bnxt_softc *softc)
+bnxt_hwrm_queue_qportcfg(struct bnxt_softc *softc, uint32_t path_dir)
 {
 	int rc = 0;
 	struct hwrm_queue_qportcfg_input req = {0};
 	struct hwrm_queue_qportcfg_output *resp =
 	    (void *)softc->hwrm_cmd_resp.idi_vaddr;
-	uint8_t i, j, *qptr;
+	uint8_t max_tc, max_lltc, *max_q;
+	uint8_t queue_profile, queue_id;
+	struct bnxt_queue_info *q_info;
+	uint8_t i, j, *qptr, *q_ids;
 	bool no_rdma;
 
 	bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_QUEUE_QPORTCFG);
@@ -254,29 +291,56 @@ bnxt_hwrm_queue_qportcfg(struct bnxt_softc *softc)
 		rc = -EINVAL;
 		goto qportcfg_exit;
 	}
-	softc->max_tc = resp->max_configurable_queues;
-	softc->max_lltc = resp->max_configurable_lossless_queues;
-	if (softc->max_tc > BNXT_MAX_COS_QUEUE)
-		softc->max_tc = BNXT_MAX_COS_QUEUE;
 
-	/* Currently no RDMA support */
-	no_rdma = true;
+	if (resp->queue_cfg_info & HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_CFG_INFO_ASYM_CFG) {
+		softc->is_asym_q = true;
+		/* bnxt_init_cosq_names(softc, path_dir); */
+	} else {
+		softc->is_asym_q = false;
+		/* bnxt_free_stats_cosqnames_mem(softc); */
+	}
+
+	max_tc = min_t(uint8_t, resp->max_configurable_queues, BNXT_MAX_QUEUE);
+	max_lltc = resp->max_configurable_lossless_queues;
 
+	/*
+	 * No RDMA support yet.
+	 * no_rdma = !(softc->flags & BNXT_FLAG_ROCE_CAP);
+	 */
+	no_rdma = true;
 	qptr = &resp->queue_id0;
-	for (i = 0, j = 0; i < softc->max_tc; i++) {
-		softc->q_info[j].id = *qptr;
-		softc->q_ids[i] = *qptr++;
-		softc->q_info[j].profile = *qptr++;
+
+	if (path_dir == HWRM_QUEUE_QPORTCFG_INPUT_FLAGS_PATH_TX) {
+		q_info = softc->tx_q_info;
+		q_ids = softc->tx_q_ids;
+		max_q = &softc->tx_max_q;
+	} else {
+		q_info = softc->rx_q_info;
+		q_ids = softc->rx_q_ids;
+		max_q = &softc->rx_max_q;
+	}
+
+	for (i = 0, j = 0; i < max_tc; i++) {
+		queue_id = *qptr;
+		qptr++;
+
+		queue_profile = *qptr;
+		qptr++;
+
+		q_info[j].queue_id = queue_id;
+		q_info[j].queue_profile = queue_profile;
+		q_ids[i] = queue_id;
+
 		softc->tc_to_qidx[j] = j;
-		if (!BNXT_CNPQ(softc->q_info[j].profile) ||
-				(no_rdma && BNXT_PF(softc)))
+
+		if (!BNXT_CNPQ(q_info[j].queue_profile) ||
+		    (no_rdma && BNXT_PF(softc)))
 			j++;
 	}
-	softc->max_q = softc->max_tc;
-	softc->max_tc = max_t(uint32_t, j, 1);
-
-	if (resp->queue_cfg_info & HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_CFG_INFO_ASYM_CFG)
-		softc->max_tc = 1;
+	*max_q = max_tc;
+	max_tc = max_t(uint8_t, j, 1);
+	softc->max_tc = softc->max_tc ? min(softc->max_tc, max_tc) : max_tc;
+	softc->max_lltc = softc->max_lltc ? min(softc->max_lltc, max_lltc) : max_lltc;
 
 	if (softc->max_lltc > softc->max_tc)
 		softc->max_lltc = softc->max_tc;
@@ -286,6 +350,39 @@ bnxt_hwrm_queue_qportcfg(struct bnxt_softc *softc)
 	return rc;
 }
 
+static int bnxt_alloc_all_ctx_pg_info(struct bnxt_softc *softc)
+{
+	struct bnxt_ctx_mem_info *ctx = softc->ctx_mem;
+	u16 type;
+
+	for (type = 0; type < BNXT_CTX_MAX; type++) {
+		struct bnxt_ctx_mem_type *ctxm = &ctx->ctx_arr[type];
+		int n = 1;
+
+		if (!ctxm->max_entries || ctxm->pg_info)
+			continue;
+
+		if (ctxm->instance_bmap)
+			n = hweight32(ctxm->instance_bmap);
+		ctxm->pg_info = kcalloc(n, sizeof(*ctxm->pg_info), GFP_KERNEL);
+		if (!ctxm->pg_info)
+			return -ENOMEM;
+	}
+	return 0;
+}
+
+static void bnxt_init_ctx_initializer(struct bnxt_ctx_mem_type *ctxm,
+				      u8 init_val, u8 init_offset,
+				      bool init_mask_set)
+{
+	ctxm->init_value = init_val;
+	ctxm->init_offset = BNXT_CTX_INIT_INVALID_OFFSET;
+	if (init_mask_set)
+		ctxm->init_offset = init_offset * 4;
+	else
+		ctxm->init_value = 0;
+}
+
 int bnxt_hwrm_func_backing_store_qcaps(struct bnxt_softc *softc)
 {
 	struct hwrm_func_backing_store_qcaps_input req = {0};
@@ -293,63 +390,110 @@ int bnxt_hwrm_func_backing_store_qcaps(struct bnxt_softc *softc)
 	    (void *)softc->hwrm_cmd_resp.idi_vaddr;
 	int rc;
 
-	if (softc->hwrm_spec_code < 0x10902 || BNXT_VF(softc) || softc->ctx_mem)
+	if (softc->hwrm_spec_code < 0x10902 || softc->ctx_mem)
+		return 0;
+
+	if (BNXT_VF(softc))
 		return 0;
 
 	bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_FUNC_BACKING_STORE_QCAPS);
 	BNXT_HWRM_LOCK(softc);
 	rc = _hwrm_send_message(softc, &req, sizeof(req));
 	if (!rc) {
-		struct bnxt_ctx_pg_info *ctx_pg;
+		struct bnxt_ctx_mem_type *ctxm;
 		struct bnxt_ctx_mem_info *ctx;
-		int i;
+		u8 init_val, init_idx = 0;
+		u16 init_mask;
 
-		ctx = malloc(sizeof(*ctx), M_DEVBUF, M_NOWAIT | M_ZERO);
+		ctx = softc->ctx_mem;
 		if (!ctx) {
-			rc = -ENOMEM;
-			goto ctx_err;
+			ctx = malloc(sizeof(*ctx), M_DEVBUF, M_NOWAIT | M_ZERO);
+			if (!ctx) {
+				rc = -ENOMEM;
+				goto ctx_err;
+			}
+			softc->ctx_mem = ctx;
 		}
-		ctx_pg = malloc(sizeof(*ctx_pg) * (softc->max_q + 1),
-				M_DEVBUF, M_NOWAIT | M_ZERO);
-		if (!ctx_pg) {
-			free(ctx, M_DEVBUF);
-			rc = -ENOMEM;
-			goto ctx_err;
+		init_val = resp->ctx_kind_initializer;
+		init_mask = le16_to_cpu(resp->ctx_init_mask);
+
+		ctxm = &ctx->ctx_arr[BNXT_CTX_QP];
+		ctxm->max_entries = le32_to_cpu(resp->qp_max_entries);
+		ctxm->qp_qp1_entries = le16_to_cpu(resp->qp_min_qp1_entries);
+		ctxm->qp_l2_entries = le16_to_cpu(resp->qp_max_l2_entries);
+		ctxm->entry_size = le16_to_cpu(resp->qp_entry_size);
+		bnxt_init_ctx_initializer(ctxm, init_val, resp->qp_init_offset,
+					  (init_mask & (1 << init_idx++)) != 0);
+
+		ctxm = &ctx->ctx_arr[BNXT_CTX_SRQ];
+		ctxm->srq_l2_entries = le16_to_cpu(resp->srq_max_l2_entries);
+		ctxm->max_entries = le32_to_cpu(resp->srq_max_entries);
+		ctxm->entry_size = le16_to_cpu(resp->srq_entry_size);
+		bnxt_init_ctx_initializer(ctxm, init_val, resp->srq_init_offset,
+					  (init_mask & (1 << init_idx++)) != 0);
+
+		ctxm = &ctx->ctx_arr[BNXT_CTX_CQ];
+		ctxm->cq_l2_entries = le16_to_cpu(resp->cq_max_l2_entries);
+		ctxm->max_entries = le32_to_cpu(resp->cq_max_entries);
+		ctxm->entry_size = le16_to_cpu(resp->cq_entry_size);
+		bnxt_init_ctx_initializer(ctxm, init_val, resp->cq_init_offset,
+					  (init_mask & (1 << init_idx++)) != 0);
+
+		ctxm = &ctx->ctx_arr[BNXT_CTX_VNIC];
+		ctxm->vnic_entries = le32_to_cpu(resp->vnic_max_vnic_entries);
+		ctxm->max_entries = ctxm->vnic_entries +
+			le16_to_cpu(resp->vnic_max_ring_table_entries);
+		ctxm->entry_size = le16_to_cpu(resp->vnic_entry_size);
+		bnxt_init_ctx_initializer(ctxm, init_val,
+					  resp->vnic_init_offset,
+					  (init_mask & (1 << init_idx++)) != 0);
+
+		ctxm = &ctx->ctx_arr[BNXT_CTX_STAT];
+		ctxm->max_entries = le32_to_cpu(resp->stat_max_entries);
+		ctxm->entry_size = le16_to_cpu(resp->stat_entry_size);
+		bnxt_init_ctx_initializer(ctxm, init_val,
+					  resp->stat_init_offset,
+					  (init_mask & (1 << init_idx++)) != 0);
+
+		ctxm = &ctx->ctx_arr[BNXT_CTX_STQM];
+		ctxm->entry_size = le16_to_cpu(resp->tqm_entry_size);
+		ctxm->min_entries = le32_to_cpu(resp->tqm_min_entries_per_ring);
+		ctxm->max_entries = le32_to_cpu(resp->tqm_max_entries_per_ring);
+		ctxm->entry_multiple = resp->tqm_entries_multiple;
+		if (!ctxm->entry_multiple)
+			ctxm->entry_multiple = 1;
+
+		memcpy(&ctx->ctx_arr[BNXT_CTX_FTQM], ctxm, sizeof(*ctxm));
+
+		ctxm = &ctx->ctx_arr[BNXT_CTX_MRAV];
+		ctxm->max_entries = le32_to_cpu(resp->mrav_max_entries);
+		ctxm->entry_size = le16_to_cpu(resp->mrav_entry_size);
+		ctxm->mrav_num_entries_units =
+			le16_to_cpu(resp->mrav_num_entries_units);
+		bnxt_init_ctx_initializer(ctxm, init_val,
+					  resp->mrav_init_offset,
+					  (init_mask & (1 << init_idx++)) != 0);
+
+		ctxm = &ctx->ctx_arr[BNXT_CTX_TIM];
+		ctxm->entry_size = le16_to_cpu(resp->tim_entry_size);
+		ctxm->max_entries = le32_to_cpu(resp->tim_max_entries);
+
+		ctx->tqm_fp_rings_count = resp->tqm_fp_rings_count;
+		if (!ctx->tqm_fp_rings_count)
+			ctx->tqm_fp_rings_count = softc->tx_max_q;
+		else if (ctx->tqm_fp_rings_count > BNXT_MAX_TQM_FP_LEGACY_RINGS)
+			ctx->tqm_fp_rings_count = BNXT_MAX_TQM_FP_LEGACY_RINGS;
+		if (ctx->tqm_fp_rings_count == BNXT_MAX_TQM_FP_LEGACY_RINGS &&
+		    softc->hwrm_max_ext_req_len >= BNXT_BACKING_STORE_CFG_LEN) {
+			ctx->tqm_fp_rings_count += resp->tqm_fp_rings_count_ext;
+			if (ctx->tqm_fp_rings_count > BNXT_MAX_TQM_FP_RINGS)
+				ctx->tqm_fp_rings_count = BNXT_MAX_TQM_FP_RINGS;
 		}
-		for (i = 0; i < softc->max_q + 1; i++, ctx_pg++)
-			ctx->tqm_mem[i] = ctx_pg;
-
-		softc->ctx_mem = ctx;
-		ctx->qp_max_entries = le32toh(resp->qp_max_entries);
-		ctx->qp_min_qp1_entries = le16toh(resp->qp_min_qp1_entries);
-		ctx->qp_max_l2_entries = le16toh(resp->qp_max_l2_entries);
-		ctx->qp_entry_size = le16toh(resp->qp_entry_size);
-		ctx->srq_max_l2_entries = le16toh(resp->srq_max_l2_entries);
-		ctx->srq_max_entries = le32toh(resp->srq_max_entries);
-		ctx->srq_entry_size = le16toh(resp->srq_entry_size);
-		ctx->cq_max_l2_entries = le16toh(resp->cq_max_l2_entries);
-		ctx->cq_max_entries = le32toh(resp->cq_max_entries);
-		ctx->cq_entry_size = le16toh(resp->cq_entry_size);
-		ctx->vnic_max_vnic_entries =
-			le16toh(resp->vnic_max_vnic_entries);
-		ctx->vnic_max_ring_table_entries =
-			le16toh(resp->vnic_max_ring_table_entries);
-		ctx->vnic_entry_size = le16toh(resp->vnic_entry_size);
-		ctx->stat_max_entries = le32toh(resp->stat_max_entries);
-		ctx->stat_entry_size = le16toh(resp->stat_entry_size);
-		ctx->tqm_entry_size = le16toh(resp->tqm_entry_size);
-		ctx->tqm_min_entries_per_ring =
-			le32toh(resp->tqm_min_entries_per_ring);
-		ctx->tqm_max_entries_per_ring =
-			le32toh(resp->tqm_max_entries_per_ring);
-		ctx->tqm_entries_multiple = resp->tqm_entries_multiple;
-		if (!ctx->tqm_entries_multiple)
-			ctx->tqm_entries_multiple = 1;
-		ctx->mrav_max_entries = le32toh(resp->mrav_max_entries);
-		ctx->mrav_entry_size = le16toh(resp->mrav_entry_size);
-		ctx->tim_entry_size = le16toh(resp->tim_entry_size);
-		ctx->tim_max_entries = le32toh(resp->tim_max_entries);
-		ctx->ctx_kind_initializer = resp->ctx_kind_initializer;
+		ctxm = &ctx->ctx_arr[BNXT_CTX_FTQM];
+		memcpy(ctxm, &ctx->ctx_arr[BNXT_CTX_STQM], sizeof(*ctxm));
+		ctxm->instance_bmap = (1 << ctx->tqm_fp_rings_count) - 1;
+
+		rc = bnxt_alloc_all_ctx_pg_info(softc);
 	} else {
 		rc = 0;
 	}
@@ -392,150 +536,213 @@ int bnxt_hwrm_func_backing_store_cfg(struct bnxt_softc *softc, uint32_t enables)
 	struct hwrm_func_backing_store_cfg_input req = {0};
 	struct bnxt_ctx_mem_info *ctx = softc->ctx_mem;
 	struct bnxt_ctx_pg_info *ctx_pg;
-	uint32_t *num_entries, req_len = sizeof(req);
-	uint64_t *pg_dir;
-	uint8_t *pg_attr;
-	int i, rc;
-	uint32_t ena;
+	struct bnxt_ctx_mem_type *ctxm;
+	u32 req_len = sizeof(req);
+	__le32 *num_entries;
+	u32 ena, flags = 0;
+	__le64 *pg_dir;
+	u8 *pg_attr;
+	int i;
 
 	if (!ctx)
 		return 0;
 
+	if (req_len > softc->hwrm_max_ext_req_len)
+		req_len = BNXT_BACKING_STORE_CFG_LEGACY_LEN;
+
 	bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_FUNC_BACKING_STORE_CFG);
 	req.enables = htole32(enables);
 
 	if (enables & HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_QP) {
-		ctx_pg = &ctx->qp_mem;
-		req.qp_num_entries = htole32(ctx_pg->entries);
-		req.qp_num_qp1_entries = htole16(ctx->qp_min_qp1_entries);
-		req.qp_num_l2_entries = htole16(ctx->qp_max_l2_entries);
-		req.qp_entry_size = htole16(ctx->qp_entry_size);
+		ctxm = &ctx->ctx_arr[BNXT_CTX_QP];
+		ctx_pg = ctxm->pg_info;
+		req.qp_num_entries = cpu_to_le32(ctx_pg->entries);
+		req.qp_num_qp1_entries = cpu_to_le16(ctxm->qp_qp1_entries);
+		req.qp_num_l2_entries = cpu_to_le16(ctxm->qp_l2_entries);
+		req.qp_entry_size = cpu_to_le16(ctxm->entry_size);
 		bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem,
 				&req.qpc_pg_size_qpc_lvl,
 				&req.qpc_page_dir);
 	}
 	if (enables & HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_SRQ) {
-		ctx_pg = &ctx->srq_mem;
-		req.srq_num_entries = htole32(ctx_pg->entries);
-		req.srq_num_l2_entries = htole16(ctx->srq_max_l2_entries);
-		req.srq_entry_size = htole16(ctx->srq_entry_size);
+		ctxm = &ctx->ctx_arr[BNXT_CTX_SRQ];
+		ctx_pg = ctxm->pg_info;
+		req.srq_num_entries = cpu_to_le32(ctx_pg->entries);
+		req.srq_num_l2_entries = cpu_to_le16(ctxm->srq_l2_entries);
+		req.srq_entry_size = cpu_to_le16(ctxm->entry_size);
 		bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem,
 				&req.srq_pg_size_srq_lvl,
 				&req.srq_page_dir);
 	}
 	if (enables & HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_CQ) {
-		ctx_pg = &ctx->cq_mem;
-		req.cq_num_entries = htole32(ctx_pg->entries);
-		req.cq_num_l2_entries = htole16(ctx->cq_max_l2_entries);
-		req.cq_entry_size = htole16(ctx->cq_entry_size);
-		bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, &req.cq_pg_size_cq_lvl,
+		ctxm = &ctx->ctx_arr[BNXT_CTX_CQ];
+		ctx_pg = ctxm->pg_info;
+		req.cq_num_entries = cpu_to_le32(ctx_pg->entries);
+		req.cq_num_l2_entries = cpu_to_le16(ctxm->cq_l2_entries);
+		req.cq_entry_size = cpu_to_le16(ctxm->entry_size);
+		bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem,
+				      &req.cq_pg_size_cq_lvl,
 				&req.cq_page_dir);
 	}
 	if (enables & HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_MRAV) {
-		ctx_pg = &ctx->mrav_mem;
-		req.mrav_num_entries = htole32(ctx_pg->entries);
-		req.mrav_entry_size = htole16(ctx->mrav_entry_size);
+		ctxm = &ctx->ctx_arr[BNXT_CTX_MRAV];
+		ctx_pg = ctxm->pg_info;
+		req.mrav_num_entries = cpu_to_le32(ctx_pg->entries);
+		if (ctxm->mrav_num_entries_units)
+			flags |=
+			HWRM_FUNC_BACKING_STORE_CFG_INPUT_FLAGS_MRAV_RESERVATION_SPLIT;
+		req.mrav_entry_size = cpu_to_le16(ctxm->entry_size);
 		bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem,
 				&req.mrav_pg_size_mrav_lvl,
 				&req.mrav_page_dir);
 	}
 	if (enables & HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TIM) {
-		ctx_pg = &ctx->tim_mem;
-		req.tim_num_entries = htole32(ctx_pg->entries);
-		req.tim_entry_size = htole16(ctx->tim_entry_size);
+		ctxm = &ctx->ctx_arr[BNXT_CTX_TIM];
+		ctx_pg = ctxm->pg_info;
+		req.tim_num_entries = cpu_to_le32(ctx_pg->entries);
+		req.tim_entry_size = cpu_to_le16(ctxm->entry_size);
 		bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem,
 				&req.tim_pg_size_tim_lvl,
 				&req.tim_page_dir);
 	}
 	if (enables & HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_VNIC) {
-		ctx_pg = &ctx->vnic_mem;
-		req.vnic_num_vnic_entries =
-			htole16(ctx->vnic_max_vnic_entries);
+		ctxm = &ctx->ctx_arr[BNXT_CTX_VNIC];
+		ctx_pg = ctxm->pg_info;
+		req.vnic_num_vnic_entries = cpu_to_le16(ctxm->vnic_entries);
 		req.vnic_num_ring_table_entries =
-			htole16(ctx->vnic_max_ring_table_entries);
-		req.vnic_entry_size = htole16(ctx->vnic_entry_size);
+			cpu_to_le16(ctxm->max_entries - ctxm->vnic_entries);
+		req.vnic_entry_size = cpu_to_le16(ctxm->entry_size);
 		bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem,
 				&req.vnic_pg_size_vnic_lvl,
 				&req.vnic_page_dir);
 	}
 	if (enables & HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_STAT) {
-		ctx_pg = &ctx->stat_mem;
-		req.stat_num_entries = htole32(ctx->stat_max_entries);
-		req.stat_entry_size = htole16(ctx->stat_entry_size);
+		ctxm = &ctx->ctx_arr[BNXT_CTX_STAT];
+		ctx_pg = ctxm->pg_info;
+		req.stat_num_entries = cpu_to_le32(ctxm->max_entries);
+		req.stat_entry_size = cpu_to_le16(ctxm->entry_size);
 		bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem,
 				&req.stat_pg_size_stat_lvl,
 				&req.stat_page_dir);
 	}
+	ctxm = &ctx->ctx_arr[BNXT_CTX_STQM];
 	for (i = 0, num_entries = &req.tqm_sp_num_entries,
 			pg_attr = &req.tqm_sp_pg_size_tqm_sp_lvl,
 			pg_dir = &req.tqm_sp_page_dir,
-			ena = HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_SP;
-			i < 9; i++, num_entries++, pg_attr++, pg_dir++, ena <<= 1) {
+	     ena = HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_SP,
+	     ctx_pg = ctxm->pg_info;
+	     i < BNXT_MAX_TQM_LEGACY_RINGS;
+	     ctx_pg = &ctx->ctx_arr[BNXT_CTX_FTQM].pg_info[i],
+	     i++, num_entries++, pg_attr++, pg_dir++, ena <<= 1) {
 		if (!(enables & ena))
 			continue;
 
-		req.tqm_entry_size = htole16(ctx->tqm_entry_size);
-		ctx_pg = ctx->tqm_mem[i];
-		*num_entries = htole32(ctx_pg->entries);
+		req.tqm_entry_size = cpu_to_le16(ctxm->entry_size);
+		*num_entries = cpu_to_le32(ctx_pg->entries);
 		bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, pg_attr, pg_dir);
 	}
-
-	if (req_len > softc->hwrm_max_ext_req_len)
-		req_len = BNXT_BACKING_STORE_CFG_LEGACY_LEN;
-
-	rc = hwrm_send_message(softc, &req, req_len);
-	if (rc)
-		rc = -EIO;
-	return rc;
+	if (enables & HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_RING8) {
+		pg_attr = &req.tqm_ring8_pg_size_tqm_ring_lvl;
+		pg_dir = &req.tqm_ring8_page_dir;
+		ctx_pg = &ctx->ctx_arr[BNXT_CTX_FTQM].pg_info[8];
+		req.tqm_ring8_num_entries = cpu_to_le32(ctx_pg->entries);
+		bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, pg_attr, pg_dir);
+	}
+	req.flags = cpu_to_le32(flags);
+	return hwrm_send_message(softc, &req, sizeof(req));
 }
 
 int bnxt_hwrm_func_resc_qcaps(struct bnxt_softc *softc, bool all)
 {
-        struct hwrm_func_resource_qcaps_output *resp =
+	struct hwrm_func_resource_qcaps_output *resp =
 	    (void *)softc->hwrm_cmd_resp.idi_vaddr;
-        struct hwrm_func_resource_qcaps_input req = {0};
-        struct bnxt_hw_resc *hw_resc = &softc->hw_resc;
-        int rc;
+	struct hwrm_func_resource_qcaps_input req = {0};
+	struct bnxt_hw_resc *hw_resc = &softc->hw_resc;
+	int rc;
 
-        bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_FUNC_RESOURCE_QCAPS);
-        req.fid = htole16(0xffff);
+	bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_FUNC_RESOURCE_QCAPS);
+	req.fid = htole16(0xffff);
 
 	BNXT_HWRM_LOCK(softc);
-        rc = _hwrm_send_message(softc, &req, sizeof(req));
-        if (rc) {
-                rc = -EIO;
-                goto hwrm_func_resc_qcaps_exit;
-        }
-
-        hw_resc->max_tx_sch_inputs = le16toh(resp->max_tx_scheduler_inputs);
-        if (!all)
-                goto hwrm_func_resc_qcaps_exit;
-
-        hw_resc->min_rsscos_ctxs = le16toh(resp->min_rsscos_ctx);
-        hw_resc->max_rsscos_ctxs = le16toh(resp->max_rsscos_ctx);
-        hw_resc->min_cp_rings = le16toh(resp->min_cmpl_rings);
-        hw_resc->max_cp_rings = le16toh(resp->max_cmpl_rings);
-        hw_resc->min_tx_rings = le16toh(resp->min_tx_rings);
-        hw_resc->max_tx_rings = le16toh(resp->max_tx_rings);
-        hw_resc->min_rx_rings = le16toh(resp->min_rx_rings);
-        hw_resc->max_rx_rings = le16toh(resp->max_rx_rings);
-        hw_resc->min_hw_ring_grps = le16toh(resp->min_hw_ring_grps);
-        hw_resc->max_hw_ring_grps = le16toh(resp->max_hw_ring_grps);
-        hw_resc->min_l2_ctxs = le16toh(resp->min_l2_ctxs);
-        hw_resc->max_l2_ctxs = le16toh(resp->max_l2_ctxs);
-        hw_resc->min_vnics = le16toh(resp->min_vnics);
-        hw_resc->max_vnics = le16toh(resp->max_vnics);
-        hw_resc->min_stat_ctxs = le16toh(resp->min_stat_ctx);
-        hw_resc->max_stat_ctxs = le16toh(resp->max_stat_ctx);
+	rc = _hwrm_send_message(softc, &req, sizeof(req));
+	if (rc) {
+		rc = -EIO;
+		goto hwrm_func_resc_qcaps_exit;
+	}
+
+	hw_resc->max_tx_sch_inputs = le16toh(resp->max_tx_scheduler_inputs);
+	if (!all)
+		goto hwrm_func_resc_qcaps_exit;
+
+	hw_resc->min_rsscos_ctxs = le16toh(resp->min_rsscos_ctx);
+	hw_resc->max_rsscos_ctxs = le16toh(resp->max_rsscos_ctx);
+	hw_resc->min_cp_rings = le16toh(resp->min_cmpl_rings);
+	hw_resc->max_cp_rings = le16toh(resp->max_cmpl_rings);
+	hw_resc->min_tx_rings = le16toh(resp->min_tx_rings);
+	hw_resc->max_tx_rings = le16toh(resp->max_tx_rings);
+	hw_resc->min_rx_rings = le16toh(resp->min_rx_rings);
+	hw_resc->max_rx_rings = le16toh(resp->max_rx_rings);
+	hw_resc->min_hw_ring_grps = le16toh(resp->min_hw_ring_grps);
+	hw_resc->max_hw_ring_grps = le16toh(resp->max_hw_ring_grps);
+	hw_resc->min_l2_ctxs = le16toh(resp->min_l2_ctxs);
+	hw_resc->max_l2_ctxs = le16toh(resp->max_l2_ctxs);
+	hw_resc->min_vnics = le16toh(resp->min_vnics);
+	hw_resc->max_vnics = le16toh(resp->max_vnics);
+	hw_resc->min_stat_ctxs = le16toh(resp->min_stat_ctx);
+	hw_resc->max_stat_ctxs = le16toh(resp->max_stat_ctx);
 
 	if (BNXT_CHIP_P5(softc)) {
-                hw_resc->max_nqs = le16toh(resp->max_msix);
-                hw_resc->max_hw_ring_grps = hw_resc->max_rx_rings;
-        }
+		hw_resc->max_nqs = le16toh(resp->max_msix);
+		hw_resc->max_hw_ring_grps = hw_resc->max_rx_rings;
+	}
 
 hwrm_func_resc_qcaps_exit:
 	BNXT_HWRM_UNLOCK(softc);
-        return rc;
+	return rc;
+}
+
+int bnxt_hwrm_func_backing_store_cfg_v2(struct bnxt_softc *softc,
+					struct bnxt_ctx_mem_type *ctxm,
+					bool last)
+{
+	struct hwrm_func_backing_store_cfg_v2_input req = {0};
+	u32 instance_bmap = ctxm->instance_bmap;
+	int i, j, rc = 0, n = 1;
+	__le32 *p;
+
+	if (!(ctxm->flags & BNXT_CTX_MEM_TYPE_VALID) || !ctxm->pg_info)
+		return 0;
+
+	if (instance_bmap)
+		n = hweight32(ctxm->instance_bmap);
+	else
+		instance_bmap = 1;
+
+	bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_FUNC_BACKING_STORE_CFG_V2);
+
+	req.type = cpu_to_le16(ctxm->type);
+	req.entry_size = cpu_to_le16(ctxm->entry_size);
+	for (i = 0, p = &req.split_entry_0; i < ctxm->split_entry_cnt; i++)
+		p[i] = cpu_to_le32(ctxm->split[i]);
+	for (i = 0, j = 0; j < n && !rc; i++) {
+		struct bnxt_ctx_pg_info *ctx_pg;
+
+		if (!(instance_bmap & (1 << i)))
+			continue;
+		req.instance = cpu_to_le16(i);
+		ctx_pg = &ctxm->pg_info[j++];
+		if (!ctx_pg->entries)
+			continue;
+		req.num_entries = cpu_to_le32(ctx_pg->entries);
+		bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem,
+				      &req.page_size_pbl_level,
+				      &req.page_dir);
+		if (last && j == (n - 1))
+			req.flags =
+				cpu_to_le32(HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_FLAGS_BS_CFG_ALL_DONE);
+		rc = hwrm_send_message(softc, &req, sizeof(req));
+	}
+	return rc;
 }
 
 int
@@ -550,7 +757,7 @@ bnxt_hwrm_passthrough(struct bnxt_softc *softc, void *req, uint32_t req_len,
 	input->resp_addr = htole64(softc->hwrm_cmd_resp.idi_paddr);
 	BNXT_HWRM_LOCK(softc);
 	old_timeo = softc->hwrm_cmd_timeo;
-	if (input->req_type == HWRM_NVM_INSTALL_UPDATE) 
+	if (input->req_type == HWRM_NVM_INSTALL_UPDATE)
 		softc->hwrm_cmd_timeo = BNXT_NVM_TIMEO;
 	else
 		softc->hwrm_cmd_timeo = max(app_timeout, softc->hwrm_cmd_timeo);
@@ -599,8 +806,6 @@ bnxt_hwrm_ver_get(struct bnxt_softc *softc)
 	softc->ver_info->hwrm_if_major = resp->hwrm_intf_maj_8b;
 	softc->ver_info->hwrm_if_minor = resp->hwrm_intf_min_8b;
 	softc->ver_info->hwrm_if_update = resp->hwrm_intf_upd_8b;
-	snprintf(softc->ver_info->hwrm_fw_ver, BNXT_VERSTR_SIZE, "%d.%d.%d",
-	    resp->hwrm_fw_major, resp->hwrm_fw_minor, resp->hwrm_fw_build);
 	strlcpy(softc->ver_info->driver_hwrm_if_ver, HWRM_VERSION_STR,
 	    BNXT_VERSTR_SIZE);
 	strlcpy(softc->ver_info->hwrm_fw_name, resp->hwrm_fw_name,
@@ -622,9 +827,9 @@ bnxt_hwrm_ver_get(struct bnxt_softc *softc)
 		strlcpy(softc->ver_info->mgmt_fw_name, nastr, BNXT_NAME_SIZE);
 	}
 	else {
-		snprintf(softc->ver_info->mgmt_fw_ver, BNXT_VERSTR_SIZE,
-		    "%d.%d.%d", resp->mgmt_fw_major, resp->mgmt_fw_minor,
-		    resp->mgmt_fw_build);
+		snprintf(softc->ver_info->mgmt_fw_ver, FW_VER_STR_LEN,
+		    "%d.%d.%d.%d", resp->mgmt_fw_major, resp->mgmt_fw_minor,
+		    resp->mgmt_fw_build, resp->mgmt_fw_patch);
 		strlcpy(softc->ver_info->mgmt_fw_name, resp->mgmt_fw_name,
 		    BNXT_NAME_SIZE);
 	}
@@ -636,9 +841,9 @@ bnxt_hwrm_ver_get(struct bnxt_softc *softc)
 		    BNXT_NAME_SIZE);
 	}
 	else {
-		snprintf(softc->ver_info->netctrl_fw_ver, BNXT_VERSTR_SIZE,
-		    "%d.%d.%d", resp->netctrl_fw_major, resp->netctrl_fw_minor,
-		    resp->netctrl_fw_build);
+		snprintf(softc->ver_info->netctrl_fw_ver, FW_VER_STR_LEN,
+		    "%d.%d.%d.%d", resp->netctrl_fw_major, resp->netctrl_fw_minor,
+		    resp->netctrl_fw_build, resp->netctrl_fw_patch);
 		strlcpy(softc->ver_info->netctrl_fw_name, resp->netctrl_fw_name,
 		    BNXT_NAME_SIZE);
 	}
@@ -649,8 +854,8 @@ bnxt_hwrm_ver_get(struct bnxt_softc *softc)
 	}
 	else {
 		snprintf(softc->ver_info->roce_fw_ver, BNXT_VERSTR_SIZE,
-		    "%d.%d.%d", resp->roce_fw_major, resp->roce_fw_minor,
-		    resp->roce_fw_build);
+		    "%d.%d.%d.%d", resp->roce_fw_major, resp->roce_fw_minor,
+		    resp->roce_fw_build, resp->roce_fw_patch);
 		strlcpy(softc->ver_info->roce_fw_name, resp->roce_fw_name,
 		    BNXT_NAME_SIZE);
 	}
@@ -669,6 +874,7 @@ bnxt_hwrm_ver_get(struct bnxt_softc *softc)
 		len = BC_HWRM_STR_LEN;
 	}
 
+	softc->ver_info->fw_ver_code = BNXT_FW_VER_CODE(fw_maj, fw_min, fw_bld, fw_rsv);
 	snprintf (softc->ver_info->fw_ver_str, len, "%d.%d.%d.%d",
 			fw_maj, fw_min, fw_bld, fw_rsv);
 
@@ -678,6 +884,7 @@ bnxt_hwrm_ver_get(struct bnxt_softc *softc)
 		snprintf(softc->ver_info->fw_ver_str + fw_ver_len,
 				FW_VER_STR_LEN - fw_ver_len - 1, "/pkg %s",
 				resp->active_pkg_name);
+		softc->fw_cap |= BNXT_FW_CAP_PKG_VER;
 	}
 
 	softc->ver_info->chip_num = le16toh(resp->chip_num);
@@ -690,37 +897,135 @@ bnxt_hwrm_ver_get(struct bnxt_softc *softc)
 		softc->hwrm_max_req_len = le16toh(resp->max_req_win_len);
 		softc->hwrm_max_ext_req_len = le16toh(resp->max_ext_req_len);
 	}
-#define DFLT_HWRM_CMD_TIMEOUT		500
 	softc->hwrm_cmd_timeo = le16toh(resp->def_req_timeout);
 	if (!softc->hwrm_cmd_timeo)
 		softc->hwrm_cmd_timeo = DFLT_HWRM_CMD_TIMEOUT;
-	
+
 	dev_caps_cfg = le32toh(resp->dev_caps_cfg);
 	if ((dev_caps_cfg & HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_SHORT_CMD_SUPPORTED) &&
 	    (dev_caps_cfg & HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_SHORT_CMD_REQUIRED))
 		softc->flags |= BNXT_FLAG_SHORT_CMD;
 
+	if ((dev_caps_cfg & HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_SHORT_CMD_SUPPORTED) &&
+	    (dev_caps_cfg & HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_SHORT_CMD_REQUIRED))
+		softc->fw_cap |= BNXT_FW_CAP_SHORT_CMD;
+
+	if (dev_caps_cfg & HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_KONG_MB_CHNL_SUPPORTED)
+		softc->fw_cap |= BNXT_FW_CAP_KONG_MB_CHNL;
+
+	if (dev_caps_cfg & HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_FLOW_HANDLE_64BIT_SUPPORTED)
+		softc->fw_cap |= BNXT_FW_CAP_OVS_64BIT_HANDLE;
+
+	if (dev_caps_cfg & HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_TRUSTED_VF_SUPPORTED)
+		softc->fw_cap |= BNXT_FW_CAP_TRUSTED_VF;
+
+	if (dev_caps_cfg & HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_CFA_ADV_FLOW_MGNT_SUPPORTED)
+		softc->fw_cap |= BNXT_FW_CAP_CFA_ADV_FLOW;
+
+	if (dev_caps_cfg & HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_CFA_EEM_SUPPORTED)
+		softc->fw_cap |= BNXT_FW_CAP_CFA_EEM;
+
+	if (dev_caps_cfg & HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_CFA_TRUFLOW_SUPPORTED)
+		softc->fw_cap |= BNXT_FW_CAP_TRUFLOW_EN;
+
 fail:
 	BNXT_HWRM_UNLOCK(softc);
 	return rc;
 }
 
-int
-bnxt_hwrm_func_drv_rgtr(struct bnxt_softc *softc)
-{
+static const u16 bnxt_async_events_arr[] = {
+	HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE,
+	HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CHANGE,
+	HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_DRVR_UNLOAD,
+	HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PORT_CONN_NOT_ALLOWED,
+	HWRM_ASYNC_EVENT_CMPL_EVENT_ID_VF_CFG_CHANGE,
+	HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE,
+	HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PORT_PHY_CFG_CHANGE,
+	HWRM_ASYNC_EVENT_CMPL_EVENT_ID_RESET_NOTIFY,
+	HWRM_ASYNC_EVENT_CMPL_EVENT_ID_ERROR_RECOVERY,
+	HWRM_ASYNC_EVENT_CMPL_EVENT_ID_RING_MONITOR_MSG,
+	HWRM_ASYNC_EVENT_CMPL_EVENT_ID_DEFAULT_VNIC_CHANGE,
+	HWRM_ASYNC_EVENT_CMPL_EVENT_ID_DEBUG_NOTIFICATION,
+	HWRM_ASYNC_EVENT_CMPL_EVENT_ID_DEFERRED_RESPONSE,
+	HWRM_ASYNC_EVENT_CMPL_EVENT_ID_ECHO_REQUEST,
+	HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PPS_TIMESTAMP,
+	HWRM_ASYNC_EVENT_CMPL_EVENT_ID_ERROR_REPORT,
+	HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PHC_UPDATE,
+};
+
+int bnxt_hwrm_func_drv_rgtr(struct bnxt_softc *bp, unsigned long *bmap, int bmap_size,
+			    bool async_only)
+{
+	DECLARE_BITMAP(async_events_bmap, 256);
+	u32 *events = (u32 *)async_events_bmap;
+	struct hwrm_func_drv_rgtr_output *resp =
+		(void *)bp->hwrm_cmd_resp.idi_vaddr;
 	struct hwrm_func_drv_rgtr_input req = {0};
+	u32 flags = 0;
+	int rc;
+	int i;
 
-	bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_FUNC_DRV_RGTR);
-
-	req.enables = htole32(HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_VER |
-	    HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_OS_TYPE);
+	bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_DRV_RGTR);
+	req.ver_maj = HWRM_VERSION_MAJOR;
+	req.ver_min = HWRM_VERSION_MINOR;
+	req.ver_upd = HWRM_VERSION_UPDATE;
+
+	req.enables = htole32(HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_OS_TYPE |
+				   HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_VER |
+				   HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_ASYNC_EVENT_FWD);
+
+	if (bp->fw_cap & BNXT_FW_CAP_HOT_RESET)
+		flags |= HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_HOT_RESET_SUPPORT;
+	if (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)
+		flags |= HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_ERROR_RECOVERY_SUPPORT |
+			 HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_MASTER_SUPPORT;
+	if (bp->fw_cap & BNXT_FW_CAP_NPAR_1_2)
+		flags |= HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_NPAR_1_2_SUPPORT;
+	flags |= HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_ASYM_QUEUE_CFG_SUPPORT;
+	req.flags = htole32(flags);
 	req.os_type = htole16(HWRM_FUNC_DRV_RGTR_INPUT_OS_TYPE_FREEBSD);
 
-	req.ver_maj = __FreeBSD_version / 100000;
-	req.ver_min = (__FreeBSD_version / 1000) % 100;
-	req.ver_upd = (__FreeBSD_version / 100) % 10;
+	if (BNXT_PF(bp)) {
+		req.enables |=
+			htole32(HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_VF_REQ_FWD);
+	}
 
-	return hwrm_send_message(softc, &req, sizeof(req));
+	if (bp->fw_cap & BNXT_FW_CAP_OVS_64BIT_HANDLE)
+		req.flags |= cpu_to_le32(HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_FLOW_HANDLE_64BIT_MODE);
+
+	memset(async_events_bmap, 0, sizeof(async_events_bmap));
+	for (i = 0; i < ARRAY_SIZE(bnxt_async_events_arr); i++) {
+		u16 event_id = bnxt_async_events_arr[i];
+
+		if (event_id == HWRM_ASYNC_EVENT_CMPL_EVENT_ID_ERROR_RECOVERY &&
+		    !(bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)) {
+			continue;
+		}
+		__set_bit(bnxt_async_events_arr[i], async_events_bmap);
+	}
+	if (bmap && bmap_size) {
+		for (i = 0; i < bmap_size; i++) {
+			if (test_bit(i, bmap))
+				__set_bit(i, async_events_bmap);
+		}
+	}
+	for (i = 0; i < 8; i++)
+		req.async_event_fwd[i] |= htole32(events[i]);
+
+	if (async_only)
+		req.enables =
+			htole32(HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_ASYNC_EVENT_FWD);
+
+	rc = hwrm_send_message(bp, &req, sizeof(req));
+
+	if (!rc) {
+		if (resp->flags &
+		    le32toh(HWRM_FUNC_DRV_RGTR_OUTPUT_FLAGS_IF_CHANGE_SUPPORTED))
+			bp->fw_cap |= BNXT_FW_CAP_IF_CHANGE;
+	}
+
+
+	return rc;
 }
 
 int
@@ -765,6 +1070,7 @@ bnxt_hwrm_func_qcaps(struct bnxt_softc *softc)
 	struct hwrm_func_qcaps_output *resp =
 	    (void *)softc->hwrm_cmd_resp.idi_vaddr;
 	struct bnxt_func_info *func = &softc->func;
+	uint32_t flags, flags_ext, flags_ext2;
 
 	bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_FUNC_QCAPS);
 	req.fid = htole16(0xffff);
@@ -774,10 +1080,78 @@ bnxt_hwrm_func_qcaps(struct bnxt_softc *softc)
 	if (rc)
 		goto fail;
 
-	if (resp->flags &
-	    htole32(HWRM_FUNC_QCAPS_OUTPUT_FLAGS_WOL_MAGICPKT_SUPPORTED))
+	flags = htole32(resp->flags);
+	if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_WOL_MAGICPKT_SUPPORTED)
 		softc->flags |= BNXT_FLAG_WOL_CAP;
+	if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_STATS_SUPPORTED)
+		softc->flags |= BNXT_FLAG_FW_CAP_EXT_STATS;
 
+	/* Enable RoCE only on Thor devices */
+	if (BNXT_CHIP_P5(softc)) {
+		if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ROCE_V1_SUPPORTED)
+			softc->flags |= BNXT_FLAG_ROCEV1_CAP;
+		if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ROCE_V2_SUPPORTED)
+			softc->flags |= BNXT_FLAG_ROCEV2_CAP;
+	}
+
+	if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_LINK_ADMIN_STATUS_SUPPORTED)
+		softc->fw_cap |= BNXT_FW_CAP_LINK_ADMIN;
+	if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ADMIN_PF_SUPPORTED)
+		softc->fw_cap |= BNXT_FW_CAP_ADMIN_PF;
+	if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_HOT_RESET_CAPABLE)
+		softc->fw_cap |= BNXT_FW_CAP_HOT_RESET;
+	if (flags &  HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ERROR_RECOVERY_CAPABLE)
+		softc->fw_cap |= BNXT_FW_CAP_ERROR_RECOVERY;
+	if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_PCIE_STATS_SUPPORTED)
+		softc->fw_cap |= BNXT_FW_CAP_PCIE_STATS_SUPPORTED;
+	if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_STATS_SUPPORTED)
+		softc->fw_cap |= BNXT_FW_CAP_EXT_STATS_SUPPORTED;
+	if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ERR_RECOVER_RELOAD)
+		softc->fw_cap |= BNXT_FW_CAP_ERR_RECOVER_RELOAD;
+	if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_NOTIFY_VF_DEF_VNIC_CHNG_SUPPORTED)
+		softc->fw_cap |= BNXT_FW_CAP_VF_VNIC_NOTIFY;
+	if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_CRASHDUMP_CMD_SUPPORTED)
+		softc->fw_cap |= BNXT_FW_CAP_CRASHDUMP;
+	if (!(flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_VLAN_ACCELERATION_TX_DISABLED))
+		softc->fw_cap |= BNXT_FW_CAP_VLAN_TX_INSERT;
+	if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_DBG_QCAPS_CMD_SUPPORTED)
+		softc->fw_cap |= BNXT_FW_CAP_DBG_QCAPS;
+
+	flags_ext = htole32(resp->flags_ext);
+	if (flags_ext & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_EXT_HW_STATS_SUPPORTED)
+		softc->fw_cap |= BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED;
+	if (BNXT_PF(softc) && (flags_ext & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_ECN_STATS_SUPPORTED))
+		softc->fw_cap |= BNXT_FW_CAP_ECN_STATS;
+
+	if (flags_ext & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_PTP_PPS_SUPPORTED)
+		softc->fw_cap |= BNXT_FW_CAP_PTP_PPS;
+	if (flags_ext & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_PTP_PTM_SUPPORTED)
+		softc->fw_cap |= BNXT_FW_CAP_PTP_PTM;
+	if (flags_ext & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_PTP_64BIT_RTC_SUPPORTED)
+		softc->fw_cap |= BNXT_FW_CAP_PTP_RTC;
+	if (BNXT_PF(softc) && (flags_ext & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_HOT_RESET_IF_SUPPORT))
+		softc->fw_cap |= BNXT_FW_CAP_HOT_RESET_IF;
+	if (BNXT_PF(softc) && (flags_ext & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_FW_LIVEPATCH_SUPPORTED))
+		softc->fw_cap |= BNXT_FW_CAP_LIVEPATCH;
+	if (flags_ext & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_NPAR_1_2_SUPPORTED)
+		softc->fw_cap |= BNXT_FW_CAP_NPAR_1_2;
+	if (flags_ext & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_BS_V2_SUPPORTED)
+		softc->fw_cap |= BNXT_FW_CAP_BACKING_STORE_V2;
+	if (BNXT_PF(softc) &&
+	    (flags_ext & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_VF_CFG_ASYNC_FOR_PF_SUPPORTED))
+		softc->fw_cap |= BNXT_FW_CAP_VF_CFG_FOR_PF;
+
+	flags_ext2 = htole32(resp->flags_ext2);
+	if (flags_ext2 & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_RX_ALL_PKTS_TIMESTAMPS_SUPPORTED)
+		softc->fw_cap |= BNXT_FW_CAP_RX_ALL_PKT_TS;
+	if (flags_ext2 & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_SW_DBR_DROP_RECOVERY_SUPPORTED)
+		softc->fw_cap |= BNXT_FW_CAP_DBR_SUPPORTED;
+	if (flags_ext2 & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_DBR_PACING_EXT_SUPPORTED ||
+	    flags_ext & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_DBR_PACING_SUPPORTED)
+		softc->fw_cap |= BNXT_FW_CAP_DBR_PACING_SUPPORTED;
+
+	if (flags_ext2 & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_GENERIC_STATS_SUPPORTED)
+		softc->fw_cap |= BNXT_FW_CAP_GENERIC_STATS;
 	func->fw_fid = le16toh(resp->fid);
 	memcpy(func->mac_addr, resp->mac_address, ETHER_ADDR_LEN);
 	func->max_rsscos_ctxs = le16toh(resp->max_rsscos_ctx);
@@ -816,26 +1190,74 @@ bnxt_hwrm_func_qcaps(struct bnxt_softc *softc)
 int
 bnxt_hwrm_func_qcfg(struct bnxt_softc *softc)
 {
-        struct hwrm_func_qcfg_input req = {0};
-        struct hwrm_func_qcfg_output *resp =
-	    (void *)softc->hwrm_cmd_resp.idi_vaddr;
+	struct hwrm_func_qcfg_input req = {0};
+	struct hwrm_func_qcfg_output *resp =
+		(void *)softc->hwrm_cmd_resp.idi_vaddr;
 	struct bnxt_func_qcfg *fn_qcfg = &softc->fn_qcfg;
-        int rc;
+	uint32_t min_db_offset = 0;
+	uint16_t flags;
+	int rc;
 
 	bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_FUNC_QCFG);
-        req.fid = htole16(0xffff);
+	req.fid = htole16(0xffff);
 	BNXT_HWRM_LOCK(softc);
 	rc = _hwrm_send_message(softc, &req, sizeof(req));
-        if (rc)
-		goto fail;
+	if (rc)
+		goto end;
 
 	fn_qcfg->alloc_completion_rings = le16toh(resp->alloc_cmpl_rings);
 	fn_qcfg->alloc_tx_rings = le16toh(resp->alloc_tx_rings);
 	fn_qcfg->alloc_rx_rings = le16toh(resp->alloc_rx_rings);
 	fn_qcfg->alloc_vnics = le16toh(resp->alloc_vnics);
-fail:
+
+	switch (resp->port_partition_type) {
+	case HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_NPAR1_0:
+	case HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_NPAR1_2:
+	case HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_NPAR1_5:
+	case HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_NPAR2_0:
+		softc->port_partition_type = resp->port_partition_type;
+		break;
+	}
+
+	flags = le16toh(resp->flags);
+	if (flags & (HWRM_FUNC_QCFG_OUTPUT_FLAGS_FW_DCBX_AGENT_ENABLED |
+		     HWRM_FUNC_QCFG_OUTPUT_FLAGS_FW_LLDP_AGENT_ENABLED)) {
+		softc->fw_cap |= BNXT_FW_CAP_LLDP_AGENT;
+		if (flags & HWRM_FUNC_QCFG_OUTPUT_FLAGS_FW_DCBX_AGENT_ENABLED)
+			softc->fw_cap |= BNXT_FW_CAP_DCBX_AGENT;
+	}
+	if (BNXT_PF(softc) && (flags & HWRM_FUNC_QCFG_OUTPUT_FLAGS_MULTI_HOST))
+		softc->flags |= BNXT_FLAG_MULTI_HOST;
+	if (BNXT_PF(softc) && (flags & HWRM_FUNC_QCFG_OUTPUT_FLAGS_MULTI_ROOT))
+		softc->flags |= BNXT_FLAG_MULTI_ROOT;
+	if (flags & HWRM_FUNC_QCFG_OUTPUT_FLAGS_SECURE_MODE_ENABLED)
+		softc->fw_cap |= BNXT_FW_CAP_SECURE_MODE;
+	if (flags & HWRM_FUNC_QCFG_OUTPUT_FLAGS_RING_MONITOR_ENABLED)
+		softc->fw_cap |= BNXT_FW_CAP_RING_MONITOR;
+	if (flags & HWRM_FUNC_QCFG_OUTPUT_FLAGS_ENABLE_RDMA_SRIOV)
+		softc->fw_cap |= BNXT_FW_CAP_ENABLE_RDMA_SRIOV;
+
+	if (softc->db_size)
+		goto end;
+
+	softc->legacy_db_size = le16_to_cpu(resp->legacy_l2_db_size_kb) * 1024;
+
+	if (BNXT_CHIP_P5(softc)) {
+		if (BNXT_PF(softc))
+		min_db_offset = DB_PF_OFFSET_P5;
+		else
+			min_db_offset = DB_VF_OFFSET_P5;
+	}
+
+	softc->db_size = roundup2(le16_to_cpu(resp->l2_doorbell_bar_size_kb) *
+			1024, PAGE_SIZE);
+	if (!softc->db_size || softc->db_size > pci_resource_len(softc->pdev, 2) ||
+			softc->db_size <= min_db_offset)
+		softc->db_size = pci_resource_len(softc->pdev, 2);
+
+	end:
 	BNXT_HWRM_UNLOCK(softc);
-        return rc;
+	return rc;
 }
 
 int
@@ -853,20 +1275,40 @@ static void
 bnxt_hwrm_set_link_common(struct bnxt_softc *softc,
     struct hwrm_port_phy_cfg_input *req)
 {
+	struct bnxt_link_info *link_info = &softc->link_info;
 	uint8_t autoneg = softc->link_info.autoneg;
 	uint16_t fw_link_speed = softc->link_info.req_link_speed;
 
 	if (autoneg & BNXT_AUTONEG_SPEED) {
-		req->auto_mode |=
-		    HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_ALL_SPEEDS;
+		uint8_t phy_type = get_phy_type(softc);
+
+		if (phy_type == HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_1G_BASET ||
+		    phy_type == HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASET ||
+		    phy_type == HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASETE) {
+
+			req->auto_mode |= htole32(HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_SPEED_MASK);
+			if (link_info->advertising) {
+				req->enables |= htole32(HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_LINK_SPEED_MASK);
+				req->auto_link_speed_mask = htole16(link_info->advertising);
+			}
+		} else {
+			req->auto_mode |= HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_ALL_SPEEDS;
+		}
 
 		req->enables |=
 		    htole32(HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_MODE);
 		req->flags |=
 		    htole32(HWRM_PORT_PHY_CFG_INPUT_FLAGS_RESTART_AUTONEG);
 	} else {
-		req->force_link_speed = htole16(fw_link_speed);
 		req->flags |= htole32(HWRM_PORT_PHY_CFG_INPUT_FLAGS_FORCE);
+
+		if (link_info->force_pam4_speed_set_by_user) {
+			req->force_pam4_link_speed = htole16(fw_link_speed);
+			req->enables |= htole32(HWRM_PORT_PHY_CFG_INPUT_ENABLES_FORCE_PAM4_LINK_SPEED);
+			link_info->force_pam4_speed_set_by_user = false;
+		} else {
+			req->force_link_speed = htole16(fw_link_speed);
+		}
 	}
 
 	/* tell chimp that the setting takes effect immediately */
@@ -976,21 +1418,14 @@ bnxt_hwrm_set_link_setting(struct bnxt_softc *softc, bool set_pause,
 int
 bnxt_hwrm_vnic_set_hds(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic)
 {
-        struct hwrm_vnic_plcmodes_cfg_input req = {0};
+	struct hwrm_vnic_plcmodes_cfg_input req = {0};
 
 	if (!BNXT_CHIP_P5(softc))
 		return 0;
 
 	bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_VNIC_PLCMODES_CFG);
 
-	/*
-	 * TBD -- Explore these flags
-	 * 	1. VNIC_PLCMODES_CFG_REQ_FLAGS_HDS_IPV4
-	 * 	2. VNIC_PLCMODES_CFG_REQ_FLAGS_HDS_IPV6
-	 * 	3. req.jumbo_thresh
-	 * 	4. req.hds_threshold
-	 */
-        req.flags = htole32(HWRM_VNIC_PLCMODES_CFG_INPUT_FLAGS_JUMBO_PLACEMENT);
+	req.flags = htole32(HWRM_VNIC_PLCMODES_CFG_INPUT_FLAGS_JUMBO_PLACEMENT);
 	req.vnic_id = htole16(vnic->id);
 
 	return hwrm_send_message(softc, &req, sizeof(req));
@@ -1258,48 +1693,48 @@ bnxt_hwrm_ring_alloc(struct bnxt_softc *softc, uint8_t type,
 	req.length = htole32(ring->ring_size);
 
 	switch (type) {
-        case HWRM_RING_ALLOC_INPUT_RING_TYPE_TX:
+	case HWRM_RING_ALLOC_INPUT_RING_TYPE_TX:
 		cp_ring = &softc->tx_cp_rings[idx];
 
-                req.cmpl_ring_id = htole16(cp_ring->ring.phys_id);
+		req.cmpl_ring_id = htole16(cp_ring->ring.phys_id);
 		/* queue_id - what CoS queue the TX ring is associated with */
-                req.queue_id = htole16(softc->q_info[0].id);
+		req.queue_id = htole16(softc->tx_q_info[0].queue_id);
 
-                req.stat_ctx_id = htole32(cp_ring->stats_ctx_id);
+		req.stat_ctx_id = htole32(cp_ring->stats_ctx_id);
 		req.enables |= htole32(
 		    HWRM_RING_ALLOC_INPUT_ENABLES_STAT_CTX_ID_VALID);
-                break;
-        case HWRM_RING_ALLOC_INPUT_RING_TYPE_RX:
+		break;
+	case HWRM_RING_ALLOC_INPUT_RING_TYPE_RX:
 		if (!BNXT_CHIP_P5(softc))
 			break;
 
 		cp_ring = &softc->rx_cp_rings[idx];
 
-                req.stat_ctx_id = htole32(cp_ring->stats_ctx_id);
+		req.stat_ctx_id = htole32(cp_ring->stats_ctx_id);
 		req.rx_buf_size = htole16(softc->rx_buf_size);
-                req.enables |= htole32(
+		req.enables |= htole32(
 			HWRM_RING_ALLOC_INPUT_ENABLES_RX_BUF_SIZE_VALID |
 			HWRM_RING_ALLOC_INPUT_ENABLES_STAT_CTX_ID_VALID);
-                break;
-        case HWRM_RING_ALLOC_INPUT_RING_TYPE_RX_AGG:
+		break;
+	case HWRM_RING_ALLOC_INPUT_RING_TYPE_RX_AGG:
 		if (!BNXT_CHIP_P5(softc)) {
-                        req.ring_type = HWRM_RING_ALLOC_INPUT_RING_TYPE_RX;
+			req.ring_type = HWRM_RING_ALLOC_INPUT_RING_TYPE_RX;
 			break;
-                }
+		}
 
 		cp_ring = &softc->rx_cp_rings[idx];
 
-                req.rx_ring_id = htole16(softc->rx_rings[idx].phys_id);
+		req.rx_ring_id = htole16(softc->rx_rings[idx].phys_id);
 		req.stat_ctx_id = htole32(cp_ring->stats_ctx_id);
 		req.rx_buf_size = htole16(softc->rx_buf_size);
-                req.enables |= htole32(
-                            HWRM_RING_ALLOC_INPUT_ENABLES_RX_RING_ID_VALID |
-                            HWRM_RING_ALLOC_INPUT_ENABLES_RX_BUF_SIZE_VALID |
-			    HWRM_RING_ALLOC_INPUT_ENABLES_STAT_CTX_ID_VALID);
-                break;
-       case HWRM_RING_ALLOC_INPUT_RING_TYPE_L2_CMPL:
+		req.enables |= htole32(
+			HWRM_RING_ALLOC_INPUT_ENABLES_RX_RING_ID_VALID |
+			HWRM_RING_ALLOC_INPUT_ENABLES_RX_BUF_SIZE_VALID |
+			HWRM_RING_ALLOC_INPUT_ENABLES_STAT_CTX_ID_VALID);
+		break;
+	case HWRM_RING_ALLOC_INPUT_RING_TYPE_L2_CMPL:
 		if (!BNXT_CHIP_P5(softc)) {
-                        req.int_mode = HWRM_RING_ALLOC_INPUT_INT_MODE_MSIX;
+			req.int_mode = HWRM_RING_ALLOC_INPUT_INT_MODE_MSIX;
 			break;
 		}
 
@@ -1307,14 +1742,15 @@ bnxt_hwrm_ring_alloc(struct bnxt_softc *softc, uint8_t type,
 		req.nq_ring_id = htole16(softc->nq_rings[idx].ring.phys_id);
 		req.enables |= htole32(
 			HWRM_RING_ALLOC_INPUT_ENABLES_NQ_RING_ID_VALID);
-                break;
-        case HWRM_RING_ALLOC_INPUT_RING_TYPE_NQ:
-                req.int_mode = HWRM_RING_ALLOC_INPUT_INT_MODE_MSIX;
-                break;
-        default:
-                printf("hwrm alloc invalid ring type %d\n", type);
-                return -1;
-        }
+		break;
+	case HWRM_RING_ALLOC_INPUT_RING_TYPE_NQ:
+		req.int_mode = HWRM_RING_ALLOC_INPUT_INT_MODE_MSIX;
+		break;
+	default:
+		device_printf(softc->dev,
+			      "hwrm alloc invalid ring type %d\n", type);
+		return -1;
+	}
 
 	BNXT_HWRM_LOCK(softc);
 	rc = _hwrm_send_message(softc, &req, sizeof(req));
@@ -1407,6 +1843,143 @@ bnxt_hwrm_port_qstats(struct bnxt_softc *softc)
 
 	return rc;
 }
+static int bnxt_hwrm_pri2cos_idx(struct bnxt_softc *softc, uint32_t path_dir)
+{
+	struct hwrm_queue_pri2cos_qcfg_input req = {0};
+	struct hwrm_queue_pri2cos_qcfg_output *resp;
+	uint8_t *pri2cos_idx, *q_ids, max_q;
+	int rc, i, j;
+	uint8_t *pri2cos;
+
+	bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_QUEUE_PRI2COS_QCFG);
+	resp = (void *)softc->hwrm_cmd_resp.idi_vaddr;
+
+	req.flags = htole32(HWRM_QUEUE_PRI2COS_QCFG_INPUT_FLAGS_IVLAN |
+			    path_dir);
+	rc = hwrm_send_message(softc, &req, sizeof(req));
+
+	if (rc)
+		return rc;
+
+	if (path_dir == HWRM_QUEUE_PRI2COS_QCFG_INPUT_FLAGS_PATH_TX) {
+		pri2cos_idx = softc->tx_pri2cos_idx;
+		q_ids = softc->tx_q_ids;
+		max_q = softc->tx_max_q;
+	} else {
+		pri2cos_idx = softc->rx_pri2cos_idx;
+		q_ids = softc->rx_q_ids;
+		max_q = softc->rx_max_q;
+	}
+
+	pri2cos = &resp->pri0_cos_queue_id;
+
+	for (i = 0; i < BNXT_MAX_QUEUE; i++) {
+		uint8_t queue_id = pri2cos[i];
+		uint8_t queue_idx;
+
+		/* Per port queue IDs start from 0, 10, 20, etc */
+		queue_idx = queue_id % 10;
+		if (queue_idx > BNXT_MAX_QUEUE) {
+			softc->pri2cos_valid = false;
+			rc = -EINVAL;
+			return rc;
+		}
+
+		for (j = 0; j < max_q; j++) {
+			if (q_ids[j] == queue_id)
+				pri2cos_idx[i] = queue_idx;
+		}
+	}
+
+	softc->pri2cos_valid = true;
+
+	return rc;
+}
+
+int
+bnxt_hwrm_port_qstats_ext(struct bnxt_softc *softc)
+{
+	struct hwrm_port_qstats_ext_input req = {0};
+	struct hwrm_port_qstats_ext_output *resp;
+	int rc = 0, i;
+	uint32_t tx_stat_size;
+
+	bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_PORT_QSTATS_EXT);
+	resp = (void *)softc->hwrm_cmd_resp.idi_vaddr;
+
+	tx_stat_size = sizeof(struct tx_port_stats_ext);
+	req.port_id = htole16(softc->pf.port_id);
+	req.tx_stat_size = htole16(tx_stat_size);
+	req.rx_stat_size = htole16(sizeof(struct rx_port_stats_ext));
+	req.rx_stat_host_addr = htole64(softc->hw_rx_port_stats_ext.idi_paddr);
+	req.tx_stat_host_addr = htole64(softc->hw_tx_port_stats_ext.idi_paddr);
+
+	rc = hwrm_send_message(softc, &req, sizeof(req));
+
+	if (!rc) {
+		softc->fw_rx_stats_ext_size =
+			le16toh(resp->rx_stat_size) / 8;
+		if (BNXT_FW_MAJ(softc) < 220 &&
+		    softc->fw_rx_stats_ext_size > BNXT_RX_STATS_EXT_NUM_LEGACY)
+			softc->fw_rx_stats_ext_size = BNXT_RX_STATS_EXT_NUM_LEGACY;
+
+		softc->fw_tx_stats_ext_size = tx_stat_size ?
+			le16toh(resp->tx_stat_size) / 8 : 0;
+	} else {
+		softc->fw_rx_stats_ext_size = 0;
+		softc->fw_tx_stats_ext_size = 0;
+	}
+
+	if (softc->fw_tx_stats_ext_size <=
+	    offsetof(struct tx_port_stats_ext, pfc_pri0_tx_duration_us) / 8) {
+		softc->pri2cos_valid = false;
+		return rc;
+	}
+
+	rc = bnxt_hwrm_pri2cos_idx(softc, HWRM_QUEUE_PRI2COS_QCFG_INPUT_FLAGS_PATH_TX);
+	if (rc)
+		return rc;
+
+	if (softc->is_asym_q) {
+		rc = bnxt_hwrm_pri2cos_idx(softc, HWRM_QUEUE_PRI2COS_QCFG_INPUT_FLAGS_PATH_RX);
+		if (rc)
+			return rc;
+	} else {
+		memcpy(softc->rx_pri2cos_idx, softc->tx_pri2cos_idx, sizeof(softc->rx_pri2cos_idx));
+	}
+
+	u64 *rx_port_stats_ext = (u64 *)softc->hw_rx_port_stats_ext.idi_vaddr;
+	u64 *tx_port_stats_ext = (u64 *)softc->hw_tx_port_stats_ext.idi_vaddr;
+
+	if (softc->pri2cos_valid) {
+		for (i = 0; i < 8; i++) {
+			long n = bnxt_rx_bytes_pri_arr_base_off[i] +
+				 softc->rx_pri2cos_idx[i];
+
+			softc->rx_bytes_pri[i] = *(rx_port_stats_ext + n);
+		}
+		for (i = 0; i < 8; i++) {
+			long n = bnxt_rx_pkts_pri_arr_base_off[i] +
+				 softc->rx_pri2cos_idx[i];
+
+			softc->rx_packets_pri[i] = *(rx_port_stats_ext + n);
+		}
+		for (i = 0; i < 8; i++) {
+			long n = bnxt_tx_bytes_pri_arr_base_off[i] +
+				 softc->tx_pri2cos_idx[i];
+
+			softc->tx_bytes_pri[i] = *(tx_port_stats_ext + n);
+		}
+		for (i = 0; i < 8; i++) {
+			long n = bnxt_tx_pkts_pri_arr_base_off[i] +
+				 softc->tx_pri2cos_idx[i];
+
+			softc->tx_packets_pri[i] = *(tx_port_stats_ext + n);
+		}
+	}
+
+	return rc;
+}
 
 int
 bnxt_hwrm_cfa_l2_set_rx_mask(struct bnxt_softc *softc,
@@ -2160,6 +2733,44 @@ bnxt_hwrm_fw_set_time(struct bnxt_softc *softc, uint16_t year, uint8_t month,
 	return hwrm_send_message(softc, &req, sizeof(req));
 }
 
+int bnxt_read_sfp_module_eeprom_info(struct bnxt_softc *softc, uint16_t i2c_addr,
+    uint16_t page_number, uint8_t bank,bool bank_sel_en, uint16_t start_addr,
+    uint16_t data_length, uint8_t *buf)
+{
+	struct hwrm_port_phy_i2c_read_output *output =
+			(void *)softc->hwrm_cmd_resp.idi_vaddr;
+	struct hwrm_port_phy_i2c_read_input req = {0};
+	int rc = 0, byte_offset = 0;
+
+	BNXT_HWRM_LOCK(softc);
+	bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_PORT_PHY_I2C_READ);
+
+	req.i2c_slave_addr = i2c_addr;
+	req.page_number = htole16(page_number);
+	req.port_id = htole16(softc->pf.port_id);
+	do {
+		uint16_t xfer_size;
+
+		xfer_size = min_t(uint16_t, data_length, BNXT_MAX_PHY_I2C_RESP_SIZE);
+		data_length -= xfer_size;
+		req.page_offset = htole16(start_addr + byte_offset);
+		req.data_length = xfer_size;
+		req.bank_number = bank;
+		req.enables = htole32((start_addr + byte_offset ?
+				HWRM_PORT_PHY_I2C_READ_INPUT_ENABLES_PAGE_OFFSET : 0) |
+				(bank_sel_en ?
+				HWRM_PORT_PHY_I2C_READ_INPUT_ENABLES_BANK_NUMBER : 0));
+		rc = hwrm_send_message(softc, &req, sizeof(req));
+		if (!rc)
+			memcpy(buf + byte_offset, output->data, xfer_size);
+		byte_offset += xfer_size;
+	} while (!rc && data_length > 0);
+
+	BNXT_HWRM_UNLOCK(softc);
+
+	return rc;
+}
+
 int
 bnxt_hwrm_port_phy_qcfg(struct bnxt_softc *softc)
 {
@@ -2169,13 +2780,14 @@ bnxt_hwrm_port_phy_qcfg(struct bnxt_softc *softc)
 	    (void *)softc->hwrm_cmd_resp.idi_vaddr;
 	int rc = 0;
 
-	BNXT_HWRM_LOCK(softc);
 	bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_PORT_PHY_QCFG);
 
+	BNXT_HWRM_LOCK(softc);
 	rc = _hwrm_send_message(softc, &req, sizeof(req));
 	if (rc)
 		goto exit;
 
+	memcpy(&link_info->phy_qcfg_resp, resp, sizeof(*resp));
 	link_info->phy_link_status = resp->link;
 	link_info->duplex =  resp->duplex_cfg;
 	link_info->auto_mode = resp->auto_mode;
@@ -2221,7 +2833,7 @@ bnxt_hwrm_port_phy_qcfg(struct bnxt_softc *softc)
 	else
 		link_info->link_speed = 0;
 	link_info->force_link_speed = le16toh(resp->force_link_speed);
-	link_info->auto_link_speed = le16toh(resp->auto_link_speed);
+	link_info->auto_link_speeds = le16toh(resp->auto_link_speed);
 	link_info->support_speeds = le16toh(resp->support_speeds);
 	link_info->auto_link_speeds = le16toh(resp->auto_link_speed_mask);
 	link_info->preemphasis = le32toh(resp->preemphasis);
@@ -2240,6 +2852,82 @@ bnxt_hwrm_port_phy_qcfg(struct bnxt_softc *softc)
 	link_info->transceiver = resp->xcvr_pkg_type;
 	link_info->phy_addr = resp->eee_config_phy_addr &
 	    HWRM_PORT_PHY_QCFG_OUTPUT_PHY_ADDR_MASK;
+	link_info->module_status = resp->module_status;
+	link_info->support_pam4_speeds = le16toh(resp->support_pam4_speeds);
+	link_info->auto_pam4_link_speeds = le16toh(resp->auto_pam4_link_speed_mask);
+	link_info->force_pam4_link_speed = le16toh(resp->force_pam4_link_speed);
+
+	if (softc->hwrm_spec_code >= 0x10504)
+		link_info->active_fec_sig_mode = resp->active_fec_signal_mode;
+
+exit:
+	BNXT_HWRM_UNLOCK(softc);
+	return rc;
+}
+
+static bool
+bnxt_phy_qcaps_no_speed(struct hwrm_port_phy_qcaps_output *resp)
+{
+	if (!resp->supported_speeds_auto_mode &&
+	    !resp->supported_speeds_force_mode &&
+	    !resp->supported_pam4_speeds_auto_mode &&
+	    !resp->supported_pam4_speeds_force_mode)
+		return true;
+
+	return false;
+}
+
+int bnxt_hwrm_phy_qcaps(struct bnxt_softc *softc)
+{
+	struct bnxt_link_info *link_info = &softc->link_info;
+	struct hwrm_port_phy_qcaps_output *resp =
+	    (void *)softc->hwrm_cmd_resp.idi_vaddr;
+	struct hwrm_port_phy_qcaps_input req = {};
+	int rc;
+
+	if (softc->hwrm_spec_code < 0x10201)
+		return 0;
+
+	bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_PORT_PHY_QCAPS);
+
+	BNXT_HWRM_LOCK(softc);
+	rc = _hwrm_send_message(softc, &req, sizeof(req));
+	if (rc)
+		goto exit;
+
+	softc->phy_flags = resp->flags | (resp->flags2 << 8);
+	if (resp->flags & HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS_EEE_SUPPORTED) {
+
+		softc->lpi_tmr_lo = le32toh(resp->tx_lpi_timer_low) &
+					    HWRM_PORT_PHY_QCAPS_OUTPUT_TX_LPI_TIMER_LOW_MASK;
+		softc->lpi_tmr_hi = le32toh(resp->valid_tx_lpi_timer_high) &
+					    HWRM_PORT_PHY_QCAPS_OUTPUT_TX_LPI_TIMER_HIGH_MASK;
+	}
+
+	if (softc->hwrm_spec_code >= 0x10a01) {
+		if (bnxt_phy_qcaps_no_speed(resp)) {
+			link_info->phy_state = BNXT_PHY_STATE_DISABLED;
+			device_printf(softc->dev, "Ethernet link disabled\n");
+		} else if (link_info->phy_state == BNXT_PHY_STATE_DISABLED) {
+			link_info->phy_state = BNXT_PHY_STATE_ENABLED;
+			device_printf(softc->dev, "Ethernet link enabled\n");
+			/* Phy re-enabled, reprobe the speeds */
+			link_info->support_auto_speeds = 0;
+			link_info->support_pam4_auto_speeds = 0;
+		}
+	}
+	if (resp->supported_speeds_auto_mode)
+		link_info->support_auto_speeds =
+			le16toh(resp->supported_speeds_auto_mode);
+	if (resp->supported_speeds_force_mode)
+		link_info->support_force_speeds =
+			le16toh(resp->supported_speeds_force_mode);
+	if (resp->supported_pam4_speeds_auto_mode)
+		link_info->support_pam4_auto_speeds =
+			le16toh(resp->supported_pam4_speeds_auto_mode);
+	if (resp->supported_pam4_speeds_force_mode)
+		link_info->support_pam4_force_speeds =
+			le16toh(resp->supported_pam4_speeds_force_mode);
 
 exit:
 	BNXT_HWRM_UNLOCK(softc);
@@ -2323,120 +3011,72 @@ static void bnxt_hwrm_set_coal_params(struct bnxt_softc *softc, uint32_t max_fra
 
 int bnxt_hwrm_set_coal(struct bnxt_softc *softc)
 {
-        int i, rc = 0;
-        struct hwrm_ring_cmpl_ring_cfg_aggint_params_input req_rx = {0},
-                                                           req_tx = {0}, *req;
-        uint16_t max_buf, max_buf_irq;
-        uint16_t buf_tmr, buf_tmr_irq;
-        uint32_t flags;
+	int i, rc = 0;
+	struct hwrm_ring_cmpl_ring_cfg_aggint_params_input req_rx = {0},
+							   req_tx = {0}, *req;
+	uint16_t max_buf, max_buf_irq;
+	uint16_t buf_tmr, buf_tmr_irq;
+	uint32_t flags;
 
-        bnxt_hwrm_cmd_hdr_init(softc, &req_rx,
-                               HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS);
-        bnxt_hwrm_cmd_hdr_init(softc, &req_tx,
-                               HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS);
+	bnxt_hwrm_cmd_hdr_init(softc, &req_rx,
+			       HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS);
+	bnxt_hwrm_cmd_hdr_init(softc, &req_tx,
+			       HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS);
 
-        /* Each rx completion (2 records) should be DMAed immediately.
-         * DMA 1/4 of the completion buffers at a time.
-         */
-        max_buf = min_t(uint16_t, softc->rx_coal_frames / 4, 2);
-        /* max_buf must not be zero */
-        max_buf = clamp_t(uint16_t, max_buf, 1, 63);
-        max_buf_irq = clamp_t(uint16_t, softc->rx_coal_frames_irq, 1, 63);
-        buf_tmr = BNXT_USEC_TO_COAL_TIMER(softc->rx_coal_usecs);
-        /* buf timer set to 1/4 of interrupt timer */
-        buf_tmr = max_t(uint16_t, buf_tmr / 4, 1);
-        buf_tmr_irq = BNXT_USEC_TO_COAL_TIMER(softc->rx_coal_usecs_irq);
-        buf_tmr_irq = max_t(uint16_t, buf_tmr_irq, 1);
-
-        flags = HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_FLAGS_TIMER_RESET;
-
-        /* RING_IDLE generates more IRQs for lower latency.  Enable it only
-         * if coal_usecs is less than 25 us.
-         */
-        if (softc->rx_coal_usecs < 25)
-                flags |= HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_FLAGS_RING_IDLE;
-
-        bnxt_hwrm_set_coal_params(softc, max_buf_irq << 16 | max_buf,
-                                  buf_tmr_irq << 16 | buf_tmr, flags, &req_rx);
-
-        /* max_buf must not be zero */
-        max_buf = clamp_t(uint16_t, softc->tx_coal_frames, 1, 63);
-        max_buf_irq = clamp_t(uint16_t, softc->tx_coal_frames_irq, 1, 63);
-        buf_tmr = BNXT_USEC_TO_COAL_TIMER(softc->tx_coal_usecs);
-        /* buf timer set to 1/4 of interrupt timer */
-        buf_tmr = max_t(uint16_t, buf_tmr / 4, 1);
-        buf_tmr_irq = BNXT_USEC_TO_COAL_TIMER(softc->tx_coal_usecs_irq);
-        buf_tmr_irq = max_t(uint16_t, buf_tmr_irq, 1);
-        flags = HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_FLAGS_TIMER_RESET;
-        bnxt_hwrm_set_coal_params(softc, max_buf_irq << 16 | max_buf,
-                                  buf_tmr_irq << 16 | buf_tmr, flags, &req_tx);
-
-        for (i = 0; i < softc->nrxqsets; i++) {
+	/* Each rx completion (2 records) should be DMAed immediately.
+	 * DMA 1/4 of the completion buffers at a time.
+	 */
+	max_buf = min_t(uint16_t, softc->rx_coal_frames / 4, 2);
+	/* max_buf must not be zero */
+	max_buf = clamp_t(uint16_t, max_buf, 1, 63);
+	max_buf_irq = clamp_t(uint16_t, softc->rx_coal_frames_irq, 1, 63);
+	buf_tmr = BNXT_USEC_TO_COAL_TIMER(softc->rx_coal_usecs);
+	/* buf timer set to 1/4 of interrupt timer */
+	buf_tmr = max_t(uint16_t, buf_tmr / 4, 1);
+	buf_tmr_irq = BNXT_USEC_TO_COAL_TIMER(softc->rx_coal_usecs_irq);
+	buf_tmr_irq = max_t(uint16_t, buf_tmr_irq, 1);
+
+	flags = HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_FLAGS_TIMER_RESET;
+
+	/* RING_IDLE generates more IRQs for lower latency.  Enable it only
+	 * if coal_usecs is less than 25 us.
+	 */
+	if (softc->rx_coal_usecs < 25)
+		flags |= HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_FLAGS_RING_IDLE;
+
+	bnxt_hwrm_set_coal_params(softc, max_buf_irq << 16 | max_buf,
+				  buf_tmr_irq << 16 | buf_tmr, flags, &req_rx);
+
+	/* max_buf must not be zero */
+	max_buf = clamp_t(uint16_t, softc->tx_coal_frames, 1, 63);
+	max_buf_irq = clamp_t(uint16_t, softc->tx_coal_frames_irq, 1, 63);
+	buf_tmr = BNXT_USEC_TO_COAL_TIMER(softc->tx_coal_usecs);
+	/* buf timer set to 1/4 of interrupt timer */
+	buf_tmr = max_t(uint16_t, buf_tmr / 4, 1);
+	buf_tmr_irq = BNXT_USEC_TO_COAL_TIMER(softc->tx_coal_usecs_irq);
+	buf_tmr_irq = max_t(uint16_t, buf_tmr_irq, 1);
+	flags = HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_FLAGS_TIMER_RESET;
+	bnxt_hwrm_set_coal_params(softc, max_buf_irq << 16 | max_buf,
+				  buf_tmr_irq << 16 | buf_tmr, flags, &req_tx);
+
+	for (i = 0; i < softc->nrxqsets; i++) {
 
 		req = &req_rx;
-                /*
-                 * TBD:
-		 *      Check if Tx also needs to be done
-                 *      So far, Tx processing has been done in softirq contest
-                 *
-		 * req = &req_tx;
-		 */
 		req->ring_id = htole16(softc->grp_info[i].cp_ring_id);
 
-                rc = hwrm_send_message(softc, req, sizeof(*req));
-                if (rc)
-                        break;
-        }
-        return rc;
-}
-
-int bnxt_hwrm_func_rgtr_async_events(struct bnxt_softc *softc, unsigned long *bmap,
-                                     int bmap_size)
-{
-	struct hwrm_func_drv_rgtr_input req = {0};
-	bitstr_t *async_events_bmap;
-	uint32_t *events;
-	int i;
-
-#define BNXT_MAX_NUM_ASYNC_EVENTS 256
-	async_events_bmap = bit_alloc(BNXT_MAX_NUM_ASYNC_EVENTS, M_DEVBUF,
-			M_WAITOK|M_ZERO);
-	events = (uint32_t *)async_events_bmap;
-
-	bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_FUNC_DRV_RGTR);
-
-	req.enables =
-		htole32(HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_ASYNC_EVENT_FWD);
-
-	memset(async_events_bmap, 0, sizeof(BNXT_MAX_NUM_ASYNC_EVENTS / 8));
-
-	bit_set(async_events_bmap, HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE);
-	bit_set(async_events_bmap, HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_DRVR_UNLOAD);
-	bit_set(async_events_bmap, HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PORT_CONN_NOT_ALLOWED);
-	bit_set(async_events_bmap, HWRM_ASYNC_EVENT_CMPL_EVENT_ID_VF_CFG_CHANGE);
-	bit_set(async_events_bmap, HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE);
-
-	if (bmap && bmap_size) {
-		for (i = 0; i < bmap_size; i++) {
-			if (bit_test(bmap, i))
-				bit_set(async_events_bmap, i);
-		}
+		rc = hwrm_send_message(softc, req, sizeof(*req));
+		if (rc)
+			break;
 	}
-
-	for (i = 0; i < 8; i++)
-		req.async_event_fwd[i] |= htole32(events[i]);
-
-	free(async_events_bmap, M_DEVBUF);
-
-	return hwrm_send_message(softc, &req, sizeof(req));
+	return rc;
 }
 
 void bnxt_hwrm_ring_info_get(struct bnxt_softc *softc, uint8_t ring_type,
-                                       uint32_t ring_id,  uint32_t *prod, uint32_t *cons)
+			     uint32_t ring_id, uint32_t *prod, uint32_t *cons)
 {
-        hwrm_dbg_ring_info_get_input_t req = {0};
-        hwrm_dbg_ring_info_get_output_t *resp = (void *)softc->hwrm_cmd_resp.idi_vaddr;
-        int rc = 0;
+	hwrm_dbg_ring_info_get_input_t req = {0};
+	hwrm_dbg_ring_info_get_output_t *resp = (void *)softc->hwrm_cmd_resp.idi_vaddr;
+	int rc = 0;
 
 	*prod = *cons = 0xffffffff;
 	bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_DBG_RING_INFO_GET);
diff --git a/sys/dev/bnxt/bnxt_hwrm.h b/sys/dev/bnxt/bnxt_en/bnxt_hwrm.h
similarity index 88%
rename from sys/dev/bnxt/bnxt_hwrm.h
rename to sys/dev/bnxt/bnxt_en/bnxt_hwrm.h
index e016677707ce..126cad977c82 100644
--- a/sys/dev/bnxt/bnxt_hwrm.h
+++ b/sys/dev/bnxt/bnxt_en/bnxt_hwrm.h
@@ -32,12 +32,15 @@
 
 #define BNXT_PAUSE_TX 	 (HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_TX)
 #define BNXT_PAUSE_RX 	 (HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_RX)
-#define BNXT_AUTO_PAUSE_AUTONEG_PAUSE  				\
-        (HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_PAUSE_AUTONEG_PAUSE)
+#define BNXT_AUTO_PAUSE_AUTONEG_PAUSE				\
+	(HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_PAUSE_AUTONEG_PAUSE)
 #define BNXT_HWRM_SHORT_REQ_LEN	sizeof(struct hwrm_short_input)
 #define BNXT_BACKING_STORE_CFG_LEGACY_LEN       256
+#define SHORT_HWRM_CMD_TIMEOUT			500
 
 /* HWRM Function Prototypes */
+int
+hwrm_send_message(struct bnxt_softc *softc, void *msg, uint32_t msg_len);
 int bnxt_alloc_hwrm_dma_mem(struct bnxt_softc *softc);
 void bnxt_free_hwrm_dma_mem(struct bnxt_softc *softc);
 int bnxt_hwrm_ring_alloc(struct bnxt_softc *softc, uint8_t type,
@@ -45,8 +48,9 @@ int bnxt_hwrm_ring_alloc(struct bnxt_softc *softc, uint8_t type,
 int bnxt_hwrm_ring_free(struct bnxt_softc *softc, uint32_t type,
 		struct bnxt_ring *ring, int cmpl_ring_id);
 int bnxt_hwrm_ver_get(struct bnxt_softc *softc);
-int bnxt_hwrm_queue_qportcfg(struct bnxt_softc *softc);
-int bnxt_hwrm_func_drv_rgtr(struct bnxt_softc *softc);
+int bnxt_hwrm_queue_qportcfg(struct bnxt_softc *softc, uint32_t path_dir);
+int bnxt_hwrm_func_drv_rgtr(struct bnxt_softc *bp, unsigned long *bmap, int bmap_size,
+			    bool async_only);
 int bnxt_hwrm_func_drv_unrgtr(struct bnxt_softc *softc, bool shutdown);
 int bnxt_hwrm_func_qcaps(struct bnxt_softc *softc);
 int bnxt_hwrm_func_qcfg(struct bnxt_softc *softc);
@@ -64,6 +68,7 @@ int bnxt_hwrm_stat_ctx_alloc(struct bnxt_softc *softc, struct bnxt_cp_ring *cpr,
     uint64_t paddr);
 int bnxt_hwrm_stat_ctx_free(struct bnxt_softc *softc, struct bnxt_cp_ring *cpr);
 int bnxt_hwrm_port_qstats(struct bnxt_softc *softc);
+int bnxt_hwrm_port_qstats_ext(struct bnxt_softc *softc);
 int bnxt_hwrm_ring_grp_alloc(struct bnxt_softc *softc,
     struct bnxt_grp_info *grp);
 int bnxt_hwrm_ring_grp_free(struct bnxt_softc *softc, struct bnxt_grp_info *gr);
@@ -115,18 +120,25 @@ int bnxt_hwrm_fw_set_time(struct bnxt_softc *softc, uint16_t year,
     uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second,
     uint16_t millisecond, uint16_t zone);
 int bnxt_hwrm_port_phy_qcfg(struct bnxt_softc *softc);
+int bnxt_hwrm_phy_qcaps(struct bnxt_softc *softc);
 uint16_t bnxt_hwrm_get_wol_fltrs(struct bnxt_softc *softc, uint16_t handle);
 int bnxt_hwrm_alloc_wol_fltr(struct bnxt_softc *softc);
 int bnxt_hwrm_free_wol_fltr(struct bnxt_softc *softc);
 int bnxt_hwrm_set_coal(struct bnxt_softc *softc);
 int bnxt_hwrm_func_rgtr_async_events(struct bnxt_softc *softc, unsigned long *bmap,
-                                     int bmap_size);
+				     int bmap_size);
 int bnxt_hwrm_func_backing_store_qcaps(struct bnxt_softc *softc);
 int bnxt_hwrm_func_backing_store_cfg(struct bnxt_softc *softc, uint32_t);
+int bnxt_hwrm_func_backing_store_cfg_v2(struct bnxt_softc *softc,
+					struct bnxt_ctx_mem_type *ctxm,
+					bool last);
 int bnxt_hwrm_func_resc_qcaps(struct bnxt_softc *softc, bool all);
 int bnxt_hwrm_reserve_pf_rings (struct bnxt_softc *softc);
 void bnxt_hwrm_ring_info_get(struct bnxt_softc *softc, uint8_t ring_type,
-                             uint32_t ring_id,  uint32_t *prod, uint32_t *);
+			     uint32_t ring_id, uint32_t *prod, uint32_t *);
 int bnxt_hwrm_passthrough(struct bnxt_softc *softc, void *req, uint32_t req_len,
 			  void *resp, uint32_t resp_len, uint32_t timeout);
+int	_hwrm_send_message(struct bnxt_softc *, void *, uint32_t);
+int	hwrm_send_message(struct bnxt_softc *, void *, uint32_t);
+void	bnxt_hwrm_cmd_hdr_init(struct bnxt_softc *, void *, uint16_t);
 #endif
diff --git a/sys/dev/bnxt/bnxt_ioctl.h b/sys/dev/bnxt/bnxt_en/bnxt_ioctl.h
similarity index 100%
rename from sys/dev/bnxt/bnxt_ioctl.h
rename to sys/dev/bnxt/bnxt_en/bnxt_ioctl.h
diff --git a/sys/dev/bnxt/bnxt_mgmt.c b/sys/dev/bnxt/bnxt_en/bnxt_mgmt.c
similarity index 85%
rename from sys/dev/bnxt/bnxt_mgmt.c
rename to sys/dev/bnxt/bnxt_en/bnxt_mgmt.c
index 7185fa2f5c0a..2f82580352cb 100644
--- a/sys/dev/bnxt/bnxt_mgmt.c
+++ b/sys/dev/bnxt/bnxt_en/bnxt_mgmt.c
@@ -95,6 +95,70 @@ bnxt_mgmt_loader(struct module *m, int what, void *arg)
 	return (error);
 }
 
+static int
+bnxt_mgmt_process_dcb(struct cdev *dev, u_long cmd, caddr_t data,
+		       int flag, struct thread *td)
+{
+	struct bnxt_softc *softc = NULL;
+	struct bnxt_mgmt_dcb mgmt_dcb = {};
+	void *user_ptr;
+	int ret = 0;
+
+	memcpy(&user_ptr, data, sizeof(user_ptr));
+	if (copyin(user_ptr, &mgmt_dcb, sizeof(mgmt_dcb))) {
+		printf("%s: %s:%d Failed to copy data from user\n",
+			DRIVER_NAME, __FUNCTION__, __LINE__);
+		return -EFAULT;
+	}
+	softc = bnxt_find_dev(mgmt_dcb.hdr.domain, mgmt_dcb.hdr.bus,
+			      mgmt_dcb.hdr.devfn, NULL);
+	if (!softc) {
+		printf("%s: %s:%d unable to find softc reference\n",
+			DRIVER_NAME, __FUNCTION__, __LINE__);
+		return -ENODEV;
+	}
+
+	switch (mgmt_dcb.op) {
+	case BNXT_MGMT_DCB_GET_ETS:
+		bnxt_dcb_ieee_getets(softc, &mgmt_dcb.req.ets);
+		break;
+	case BNXT_MGMT_DCB_SET_ETS:
+		bnxt_dcb_ieee_setets(softc, &mgmt_dcb.req.ets);
+		break;
+	case BNXT_MGMT_DCB_GET_PFC:
+		bnxt_dcb_ieee_getpfc(softc, &mgmt_dcb.req.pfc);
+		break;
+	case BNXT_MGMT_DCB_SET_PFC:
+		bnxt_dcb_ieee_setpfc(softc, &mgmt_dcb.req.pfc);
+		break;
+	case BNXT_MGMT_DCB_SET_APP:
+		bnxt_dcb_ieee_setapp(softc, &mgmt_dcb.req.app_tlv.app[0]);
+		break;
+	case BNXT_MGMT_DCB_DEL_APP:
+		bnxt_dcb_ieee_delapp(softc, &mgmt_dcb.req.app_tlv.app[0]);
+		break;
+	case BNXT_MGMT_DCB_LIST_APP:
+		bnxt_dcb_ieee_listapp(softc, &mgmt_dcb.req.app_tlv.app[0],
+				      &mgmt_dcb.req.app_tlv.num_app);
+		break;
+	default:
+		device_printf(softc->dev, "%s:%d Invalid op 0x%x\n",
+			      __FUNCTION__, __LINE__, mgmt_dcb.op);
+		ret = -EFAULT;
+		goto end;
+	}
+
+	if (copyout(&mgmt_dcb, user_ptr, sizeof(mgmt_dcb))) {
+		device_printf(softc->dev, "%s:%d Failed to copy response to user\n",
+			      __FUNCTION__, __LINE__);
+		ret = -EFAULT;
+		goto end;
+	}
+
+end:
+	return ret;
+}
+
 static int
 bnxt_mgmt_process_hwrm(struct cdev *dev, u_long cmd, caddr_t data,
 		       int flag, struct thread *td)
@@ -345,9 +409,12 @@ bnxt_mgmt_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag,
 		break;
 	case BNXT_MGMT_OPCODE_PASSTHROUGH_HWRM:
 		mtx_lock(&mgmt_lock);
-		ret = bnxt_mgmt_process_hwrm(dev, cmd, data, flag, td); 
+		ret = bnxt_mgmt_process_hwrm(dev, cmd, data, flag, td);
 		mtx_unlock(&mgmt_lock);
 		break;
+	case BNXT_MGMT_OPCODE_DCB_OPS:
+		ret = bnxt_mgmt_process_dcb(dev, cmd, data, flag, td);
+		break;
 	default:
 		printf("%s: Unknown command 0x%lx\n", DRIVER_NAME, cmd);
 		ret = -EINVAL;
diff --git a/sys/dev/bnxt/bnxt_mgmt.h b/sys/dev/bnxt/bnxt_en/bnxt_mgmt.h
similarity index 83%
rename from sys/dev/bnxt/bnxt_mgmt.h
rename to sys/dev/bnxt/bnxt_en/bnxt_mgmt.h
index f130ad386809..8489a223adef 100644
--- a/sys/dev/bnxt/bnxt_mgmt.h
+++ b/sys/dev/bnxt/bnxt_en/bnxt_mgmt.h
@@ -41,6 +41,7 @@
 
 #define	BNXT_MGMT_OPCODE_GET_DEV_INFO		0x80000000
 #define	BNXT_MGMT_OPCODE_PASSTHROUGH_HWRM	0x80000001
+#define	BNXT_MGMT_OPCODE_DCB_OPS		0x80000002
 
 #define BNXT_MGMT_MAX_HWRM_REQ_LENGTH		HWRM_MAX_REQ_LEN
 #define BNXT_MGMT_MAX_HWRM_RESP_LENGTH		(512)
@@ -118,9 +119,31 @@ struct bnxt_mgmt_req_hdr {
 };
 
 struct bnxt_mgmt_req {
-        struct bnxt_mgmt_req_hdr hdr;
-        union {
-            uint64_t hreq;
-        } req;
+	struct bnxt_mgmt_req_hdr hdr;
+	union {
+		uint64_t hreq;
+	} req;
 };
 
+struct bnxt_mgmt_app_tlv {
+	uint32_t num_app;
+	struct bnxt_dcb_app app[128];
+} __attribute__ ((__packed__));
+
+struct bnxt_mgmt_dcb {
+	struct bnxt_mgmt_req_hdr hdr;
+#define BNXT_MGMT_DCB_GET_ETS	0x1
+#define BNXT_MGMT_DCB_SET_ETS	0x2
+#define BNXT_MGMT_DCB_GET_PFC	0x3
+#define BNXT_MGMT_DCB_SET_PFC	0x4
+#define BNXT_MGMT_DCB_SET_APP	0x5
+#define BNXT_MGMT_DCB_DEL_APP	0x6
+#define BNXT_MGMT_DCB_LIST_APP	0x7
+#define BNXT_MGMT_DCB_MAX	BNXT_MGMT_DCB_LIST_APP
+	uint32_t op;
+	union {
+		struct bnxt_ieee_ets ets;
+		struct bnxt_ieee_pfc pfc;
+		struct bnxt_mgmt_app_tlv app_tlv;
+	} req;
+} __attribute__ ((__packed__));
diff --git a/sys/dev/bnxt/bnxt_sysctl.c b/sys/dev/bnxt/bnxt_en/bnxt_sysctl.c
similarity index 54%
rename from sys/dev/bnxt/bnxt_sysctl.c
rename to sys/dev/bnxt/bnxt_en/bnxt_sysctl.c
index 893e56b61099..cf4e995e1aba 100644
--- a/sys/dev/bnxt/bnxt_sysctl.c
+++ b/sys/dev/bnxt/bnxt_en/bnxt_sysctl.c
@@ -29,11 +29,18 @@
 #include <sys/cdefs.h>
 #include <sys/types.h>
 #include <sys/sysctl.h>
+#include <sys/ctype.h>
+#include <linux/delay.h>
 
 #include "bnxt.h"
 #include "bnxt_hwrm.h"
 #include "bnxt_sysctl.h"
 
+DEFINE_MUTEX(tmp_mutex); /* mutex lock for driver */
+extern void bnxt_fw_reset(struct bnxt_softc *bp);
+extern void bnxt_queue_sp_work(struct bnxt_softc *bp);
+extern void
+process_nq(struct bnxt_softc *softc, uint16_t nqid);
 /*
  * We want to create:
  * dev.bnxt.0.hwstats.txq0
@@ -105,6 +112,16 @@ bnxt_init_sysctl_ctx(struct bnxt_softc *softc)
 		return ENOMEM;
 	}
 
+	sysctl_ctx_init(&softc->dcb_ctx);
+	ctx = device_get_sysctl_ctx(softc->dev);
+	softc->dcb_oid = SYSCTL_ADD_NODE(ctx,
+	    SYSCTL_CHILDREN(device_get_sysctl_tree(softc->dev)), OID_AUTO,
+	    "dcb", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "dcb");
+	if (!softc->dcb_oid) {
+		sysctl_ctx_free(&softc->dcb_ctx);
+		return ENOMEM;
+	}
+
 	return 0;
 }
 
@@ -151,6 +168,14 @@ bnxt_free_sysctl_ctx(struct bnxt_softc *softc)
 			softc->flow_ctrl_oid = NULL;
 	}
 
+	if (softc->dcb_oid != NULL) {
+		orc = sysctl_ctx_free(&softc->dcb_ctx);
+		if (orc)
+			rc = orc;
+		else
+			softc->dcb_oid = NULL;
+	}
+
 	return rc;
 }
 
@@ -233,17 +258,17 @@ bnxt_create_port_stats_sysctls(struct bnxt_softc *softc)
 	    &softc->tx_port_stats->tx_512b_1023b_frames,
 	    "Transmitted 512b 1023b frames");
 	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
-	    "tx_1024b_1518_frames", CTLFLAG_RD,
+	    "tx_1024b_1518b_frames", CTLFLAG_RD,
 	    &softc->tx_port_stats->tx_1024b_1518b_frames,
-	    "Transmitted 1024b 1518 frames");
+	    "Transmitted 1024b 1518b frames");
 	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
 	    "tx_good_vlan_frames", CTLFLAG_RD,
 	    &softc->tx_port_stats->tx_good_vlan_frames,
 	    "Transmitted good vlan frames");
 	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
-	    "tx_1519b_2047_frames", CTLFLAG_RD,
+	    "tx_1519b_2047b_frames", CTLFLAG_RD,
 	    &softc->tx_port_stats->tx_1519b_2047b_frames,
-	    "Transmitted 1519b 2047 frames");
+	    "Transmitted 1519b 2047b frames");
 	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
 	    "tx_2048b_4095b_frames", CTLFLAG_RD,
 	    &softc->tx_port_stats->tx_2048b_4095b_frames,
@@ -284,53 +309,9 @@ bnxt_create_port_stats_sysctls(struct bnxt_softc *softc)
 	    "tx_fcs_err_frames", CTLFLAG_RD,
 	    &softc->tx_port_stats->tx_fcs_err_frames,
 	    "Transmitted fcs err frames");
-	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
-	    "tx_control_frames", CTLFLAG_RD,
-	    &softc->tx_port_stats->tx_control_frames,
-	    "Transmitted control frames");
-	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
-	    "tx_oversz_frames", CTLFLAG_RD,
-	    &softc->tx_port_stats->tx_oversz_frames, "Transmitted oversz frames");
-	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
-	    "tx_single_dfrl_frames", CTLFLAG_RD,
-	    &softc->tx_port_stats->tx_single_dfrl_frames,
-	    "Transmitted single dfrl frames");
-	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
-	    "tx_multi_dfrl_frames", CTLFLAG_RD,
-	    &softc->tx_port_stats->tx_multi_dfrl_frames,
-	    "Transmitted multi dfrl frames");
-	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
-	    "tx_single_coll_frames", CTLFLAG_RD,
-	    &softc->tx_port_stats->tx_single_coll_frames,
-	    "Transmitted single coll frames");
-	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
-	    "tx_multi_coll_frames", CTLFLAG_RD,
-	    &softc->tx_port_stats->tx_multi_coll_frames,
-	    "Transmitted multi coll frames");
-	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
-	    "tx_late_coll_frames", CTLFLAG_RD,
-	    &softc->tx_port_stats->tx_late_coll_frames,
-	    "Transmitted late coll frames");
-	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
-	    "tx_excessive_coll_frames", CTLFLAG_RD,
-	    &softc->tx_port_stats->tx_excessive_coll_frames,
-	    "Transmitted excessive coll frames");
-	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
-	    "tx_frag_frames", CTLFLAG_RD,
-	    &softc->tx_port_stats->tx_frag_frames, "Transmitted frag frames");
 	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
 	    "tx_err", CTLFLAG_RD,
 	    &softc->tx_port_stats->tx_err, "Transmitted err");
-	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
-	    "tx_tagged_frames", CTLFLAG_RD,
-	    &softc->tx_port_stats->tx_tagged_frames, "Transmitted tagged frames");
-	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
-	    "tx_dbl_tagged_frames", CTLFLAG_RD,
-	    &softc->tx_port_stats->tx_dbl_tagged_frames,
-	    "Transmitted dbl tagged frames");
-	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
-	    "tx_runt_frames", CTLFLAG_RD,
-	    &softc->tx_port_stats->tx_runt_frames, "Transmitted runt frames");
 	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
 	    "tx_fifo_underruns", CTLFLAG_RD,
 	    &softc->tx_port_stats->tx_fifo_underruns,
@@ -417,7 +398,7 @@ bnxt_create_port_stats_sysctls(struct bnxt_softc *softc)
 	    &softc->rx_port_stats->rx_512b_1023b_frames,
 	    "Received 512b 1023b frames");
 	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
-	    "rx_1024b_1518_frames", CTLFLAG_RD,
+	    "rx_1024b_1518b_frames", CTLFLAG_RD,
 	    &softc->rx_port_stats->rx_1024b_1518b_frames,
 	    "Received 1024b 1518 frames");
 	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
@@ -464,34 +445,10 @@ bnxt_create_port_stats_sysctls(struct bnxt_softc *softc)
 	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
 	    "rx_pfc_frames", CTLFLAG_RD,
 	    &softc->rx_port_stats->rx_pfc_frames, "Received pfc frames");
-	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
-	    "rx_unsupported_opcode_frames", CTLFLAG_RD,
-	    &softc->rx_port_stats->rx_unsupported_opcode_frames,
-	    "Received unsupported opcode frames");
-	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
-	    "rx_unsupported_da_pausepfc_frames", CTLFLAG_RD,
-	    &softc->rx_port_stats->rx_unsupported_da_pausepfc_frames,
-	    "Received unsupported da pausepfc frames");
-	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
-	    "rx_wrong_sa_frames", CTLFLAG_RD,
-	    &softc->rx_port_stats->rx_wrong_sa_frames,
-	    "Received wrong sa frames");
 	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
 	    "rx_align_err_frames", CTLFLAG_RD,
 	    &softc->rx_port_stats->rx_align_err_frames,
 	    "Received align err frames");
-	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
-	    "rx_oor_len_frames", CTLFLAG_RD,
-	    &softc->rx_port_stats->rx_oor_len_frames,
-	    "Received oor len frames");
-	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
-	    "rx_code_err_frames", CTLFLAG_RD,
-	    &softc->rx_port_stats->rx_code_err_frames,
-	    "Received code err frames");
-	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
-	    "rx_false_carrier_frames", CTLFLAG_RD,
-	    &softc->rx_port_stats->rx_false_carrier_frames,
-	    "Received false carrier frames");
 	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
 	    "rx_ovrsz_frames", CTLFLAG_RD,
 	    &softc->rx_port_stats->rx_ovrsz_frames,
@@ -504,14 +461,6 @@ bnxt_create_port_stats_sysctls(struct bnxt_softc *softc)
 	    "rx_mtu_err_frames", CTLFLAG_RD,
 	    &softc->rx_port_stats->rx_mtu_err_frames,
 	    "Received mtu err frames");
-	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
-	    "rx_match_crc_frames", CTLFLAG_RD,
-	    &softc->rx_port_stats->rx_match_crc_frames,
-	    "Received match crc frames");
-	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
-	    "rx_promiscuous_frames", CTLFLAG_RD,
-	    &softc->rx_port_stats->rx_promiscuous_frames,
-	    "Received promiscuous frames");
 	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
 	    "rx_tagged_frames", CTLFLAG_RD,
 	    &softc->rx_port_stats->rx_tagged_frames,
@@ -520,46 +469,10 @@ bnxt_create_port_stats_sysctls(struct bnxt_softc *softc)
 	    "rx_double_tagged_frames", CTLFLAG_RD,
 	    &softc->rx_port_stats->rx_double_tagged_frames,
 	    "Received double tagged frames");
-	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
-	    "rx_trunc_frames", CTLFLAG_RD,
-	    &softc->rx_port_stats->rx_trunc_frames,
-	    "Received trunc frames");
 	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
 	    "rx_good_frames", CTLFLAG_RD,
 	    &softc->rx_port_stats->rx_good_frames,
 	    "Received good frames");
-	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
-	    "rx_pfc_xon2xoff_frames_pri0", CTLFLAG_RD,
-	    &softc->rx_port_stats->rx_pfc_xon2xoff_frames_pri0,
-	    "Received pfc xon2xoff frames pri0");
-	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
-	    "rx_pfc_xon2xoff_frames_pri1", CTLFLAG_RD,
-	    &softc->rx_port_stats->rx_pfc_xon2xoff_frames_pri1,
-	    "Received pfc xon2xoff frames pri1");
-	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
-	    "rx_pfc_xon2xoff_frames_pri2", CTLFLAG_RD,
-	    &softc->rx_port_stats->rx_pfc_xon2xoff_frames_pri2,
-	    "Received pfc xon2xoff frames pri2");
-	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
-	    "rx_pfc_xon2xoff_frames_pri3", CTLFLAG_RD,
-	    &softc->rx_port_stats->rx_pfc_xon2xoff_frames_pri3,
-	    "Received pfc xon2xoff frames pri3");
-	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
-	    "rx_pfc_xon2xoff_frames_pri4", CTLFLAG_RD,
-	    &softc->rx_port_stats->rx_pfc_xon2xoff_frames_pri4,
-	    "Received pfc xon2xoff frames pri4");
-	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
-	    "rx_pfc_xon2xoff_frames_pri5", CTLFLAG_RD,
-	    &softc->rx_port_stats->rx_pfc_xon2xoff_frames_pri5,
-	    "Received pfc xon2xoff frames pri5");
-	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
-	    "rx_pfc_xon2xoff_frames_pri6", CTLFLAG_RD,
-	    &softc->rx_port_stats->rx_pfc_xon2xoff_frames_pri6,
-	    "Received pfc xon2xoff frames pri6");
-	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
-	    "rx_pfc_xon2xoff_frames_pri7", CTLFLAG_RD,
-	    &softc->rx_port_stats->rx_pfc_xon2xoff_frames_pri7,
-	    "Received pfc xon2xoff frames pri7");
 	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
 	    "rx_pfc_ena_frames_pri0", CTLFLAG_RD,
 	    &softc->rx_port_stats->rx_pfc_ena_frames_pri0,
@@ -599,9 +512,6 @@ bnxt_create_port_stats_sysctls(struct bnxt_softc *softc)
 	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
 	    "rx_undrsz_frames", CTLFLAG_RD,
 	    &softc->rx_port_stats->rx_undrsz_frames, "Received undrsz frames");
-	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
-	    "rx_frag_frames", CTLFLAG_RD,
-	    &softc->rx_port_stats->rx_frag_frames, "Received frag frames");
 	SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
 	    "rx_eee_lpi_events", CTLFLAG_RD,
 	    &softc->rx_port_stats->rx_eee_lpi_events, "Received eee lpi events");
@@ -644,6 +554,436 @@ bnxt_create_port_stats_sysctls(struct bnxt_softc *softc)
 	    "rx_stat_err", CTLFLAG_RD,
 	    &softc->rx_port_stats->rx_stat_err, "Received stat err");
 
+	if (BNXT_CHIP_P5(softc) &&
+	    (softc->flags & BNXT_FLAG_FW_CAP_EXT_STATS)) {
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "tx_bytes_cos0", CTLFLAG_RD,
+		    &softc->tx_port_stats_ext->tx_bytes_cos0, "Transmitted bytes count cos0");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "tx_packets_cos0", CTLFLAG_RD,
+		    &softc->tx_port_stats_ext->tx_packets_cos0, "Transmitted packets count cos0");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "tx_bytes_cos1", CTLFLAG_RD,
+		    &softc->tx_port_stats_ext->tx_bytes_cos1, "Transmitted bytes count cos1");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "tx_packets_cos1", CTLFLAG_RD,
+		    &softc->tx_port_stats_ext->tx_packets_cos1, "Transmitted packets count cos1");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "tx_bytes_cos2", CTLFLAG_RD,
+		    &softc->tx_port_stats_ext->tx_bytes_cos2, "Transmitted bytes count cos2");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "tx_packets_cos2", CTLFLAG_RD,
+		    &softc->tx_port_stats_ext->tx_packets_cos2, "Transmitted packets count cos2");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "tx_bytes_cos3", CTLFLAG_RD,
+		    &softc->tx_port_stats_ext->tx_bytes_cos3, "Transmitted bytes count cos3");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "tx_packets_cos3", CTLFLAG_RD,
+		    &softc->tx_port_stats_ext->tx_packets_cos3, "Transmitted packets count cos3");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "tx_bytes_cos4", CTLFLAG_RD,
+		    &softc->tx_port_stats_ext->tx_bytes_cos4, "Transmitted bytes count cos4");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "tx_packets_cos4", CTLFLAG_RD,
+		    &softc->tx_port_stats_ext->tx_packets_cos4, "Transmitted packets count cos4");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "tx_bytes_cos5", CTLFLAG_RD,
+		    &softc->tx_port_stats_ext->tx_bytes_cos5, "Transmitted bytes count cos5");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "tx_packets_cos5", CTLFLAG_RD,
+		    &softc->tx_port_stats_ext->tx_packets_cos5, "Transmitted packets count cos5");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "tx_bytes_cos6", CTLFLAG_RD,
+		    &softc->tx_port_stats_ext->tx_bytes_cos6, "Transmitted bytes count cos6");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "tx_packets_cos6", CTLFLAG_RD,
+		    &softc->tx_port_stats_ext->tx_packets_cos6, "Transmitted packets count cos6");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "tx_bytes_cos7", CTLFLAG_RD,
+		    &softc->tx_port_stats_ext->tx_bytes_cos7, "Transmitted bytes count cos7");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "tx_packets_cos7", CTLFLAG_RD,
+		    &softc->tx_port_stats_ext->tx_packets_cos7, "Transmitted packets count cos7");
+
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "tx_bytes_pri0", CTLFLAG_RD,
+		    &softc->tx_bytes_pri[0], "Transmitted bytes count pri0");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "tx_packets_pri0", CTLFLAG_RD,
+		    &softc->tx_packets_pri[0], "Transmitted packets count pri0");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "tx_bytes_pri1", CTLFLAG_RD,
+		    &softc->tx_bytes_pri[1], "Transmitted bytes count pri1");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "tx_packets_pri1", CTLFLAG_RD,
+		    &softc->tx_packets_pri[1], "Transmitted packets count pri1");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "tx_bytes_pri2", CTLFLAG_RD,
+		    &softc->tx_bytes_pri[2], "Transmitted bytes count pri2");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "tx_packets_pri2", CTLFLAG_RD,
+		    &softc->tx_packets_pri[2], "Transmitted packets count pri2");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "tx_bytes_pri3", CTLFLAG_RD,
+		    &softc->tx_bytes_pri[3], "Transmitted bytes count pri3");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "tx_packets_pri3", CTLFLAG_RD,
+		    &softc->tx_packets_pri[3], "Transmitted packets count pri3");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "tx_bytes_pri4", CTLFLAG_RD,
+		    &softc->tx_bytes_pri[4], "Transmitted bytes count pri4");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "tx_packets_pri4", CTLFLAG_RD,
+		    &softc->tx_packets_pri[4], "Transmitted packets count pri4");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "tx_bytes_pri5", CTLFLAG_RD,
+		    &softc->tx_bytes_pri[5], "Transmitted bytes count pri5");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "tx_packets_pri5", CTLFLAG_RD,
+		    &softc->tx_packets_pri[5], "Transmitted packets count pri5");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "tx_bytes_pri6", CTLFLAG_RD,
+		    &softc->tx_bytes_pri[6], "Transmitted bytes count pri6");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "tx_packets_pri6", CTLFLAG_RD,
+		    &softc->tx_packets_pri[6], "Transmitted packets count pri6");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "tx_bytes_pri7", CTLFLAG_RD,
+		    &softc->tx_bytes_pri[7], "Transmitted bytes count pri7");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "tx_packets_pri7", CTLFLAG_RD,
+		    &softc->tx_packets_pri[7], "Transmitted packets count pri7");
+
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "pfc_pri0_tx_duration_us", CTLFLAG_RD,
+		    &softc->tx_port_stats_ext->pfc_pri0_tx_duration_us, "Time duration between"
+		    "XON to XOFF and XOFF to XON for pri0");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "pfc_pri0_tx_transitions", CTLFLAG_RD,
+		    &softc->tx_port_stats_ext->pfc_pri0_tx_transitions, "Num times transition"
+		    "between XON to XOFF and XOFF to XON for pri0");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "pfc_pri1_tx_duration_us", CTLFLAG_RD,
+		    &softc->tx_port_stats_ext->pfc_pri1_tx_duration_us, "Time duration between"
+		    "XON to XOFF and XOFF to XON for pri1");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "pfc_pri1_tx_transitions", CTLFLAG_RD,
+		    &softc->tx_port_stats_ext->pfc_pri1_tx_transitions, "Num times transition"
+		    "between XON to XOFF and XOFF to XON for pri1");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "pfc_pri2_tx_duration_us", CTLFLAG_RD,
+		    &softc->tx_port_stats_ext->pfc_pri2_tx_duration_us, "Time duration between"
+		    "XON to XOFF and XOFF to XON for pri2");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "pfc_pri2_tx_transitions", CTLFLAG_RD,
+		    &softc->tx_port_stats_ext->pfc_pri2_tx_transitions, "Num times transition"
+		    "between XON to XOFF and XOFF to XON for pri2");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "pfc_pri3_tx_duration_us", CTLFLAG_RD,
+		    &softc->tx_port_stats_ext->pfc_pri3_tx_duration_us, "Time duration between"
+		    "XON to XOFF and XOFF to XON for pri3");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "pfc_pri3_tx_transitions", CTLFLAG_RD,
+		    &softc->tx_port_stats_ext->pfc_pri3_tx_transitions, "Num times transition"
+		    "between XON to XOFF and XOFF to XON for pri3");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "pfc_pri4_tx_duration_us", CTLFLAG_RD,
+		    &softc->tx_port_stats_ext->pfc_pri4_tx_duration_us, "Time duration between"
+		    "XON to XOFF and XOFF to XON for pri4");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "pfc_pri4_tx_transitions", CTLFLAG_RD,
+		    &softc->tx_port_stats_ext->pfc_pri4_tx_transitions, "Num times transition"
+		    "between XON to XOFF and XOFF to XON for pri4");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "pfc_pri5_tx_duration_us", CTLFLAG_RD,
+		    &softc->tx_port_stats_ext->pfc_pri5_tx_duration_us, "Time duration between"
+		    "XON to XOFF and XOFF to XON for pri5");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "pfc_pri5_tx_transitions", CTLFLAG_RD,
+		    &softc->tx_port_stats_ext->pfc_pri5_tx_transitions, "Num times transition"
+		    "between XON to XOFF and XOFF to XON for pri5");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "pfc_pri6_tx_duration_us", CTLFLAG_RD,
+		    &softc->tx_port_stats_ext->pfc_pri6_tx_duration_us, "Time duration between"
+		    "XON to XOFF and XOFF to XON for pri6");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "pfc_pri6_tx_transitions", CTLFLAG_RD,
+		    &softc->tx_port_stats_ext->pfc_pri6_tx_transitions, "Num times transition"
+		    "between XON to XOFF and XOFF to XON for pri6");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "pfc_pri7_tx_duration_us", CTLFLAG_RD,
+		    &softc->tx_port_stats_ext->pfc_pri7_tx_duration_us, "Time duration between"
+		    "XON to XOFF and XOFF to XON for pri7");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "pfc_pri7_tx_transitions", CTLFLAG_RD,
+		    &softc->tx_port_stats_ext->pfc_pri7_tx_transitions, "Num times transition"
+		    "between XON to XOFF and XOFF to XON for pri7");
+
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "link_down_events", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->link_down_events, "Num times link states down");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "continuous_pause_events", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->continuous_pause_events, "Num times pause events");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "resume_pause_events", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->resume_pause_events, "Num times pause events"
+		    "resumes");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "continuous_roce_pause_events", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->continuous_roce_pause_events, "Num times roce"
+		    "pause events");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "resume_roce_pause_events", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->resume_roce_pause_events, "Num times roce pause"
+		    "events resumes");
+
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_bytes_cos0", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_bytes_cos0, "Received bytes count cos0");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_packets_cos0", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_packets_cos0, "Received packets count cos0");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_bytes_cos1", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_bytes_cos1, "Received bytes count cos1");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_packets_cos1", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_packets_cos1, "Received packets count cos1");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_bytes_cos2", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_bytes_cos2, "Received bytes count cos2");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_packets_cos2", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_packets_cos2, "Received packets count cos2");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_bytes_cos3", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_bytes_cos3, "Received bytes count cos3");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_packets_cos3", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_packets_cos3, "Received packets count cos3");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_bytes_cos4", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_bytes_cos4, "Received bytes count cos4");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_packets_cos4", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_packets_cos4, "Received packets count cos4");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_bytes_cos5", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_bytes_cos5, "Received bytes count cos5");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_packets_cos5", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_packets_cos5, "Received packets count cos5");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_bytes_cos6", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_bytes_cos6, "Received bytes count cos6");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_packets_cos6", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_packets_cos6, "Received packets count cos6");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_bytes_cos7", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_bytes_cos7, "Received bytes count cos7");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_packets_cos7", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_packets_cos7, "Received packets count cos7");
+
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_bytes_pri0", CTLFLAG_RD,
+		    &softc->rx_bytes_pri[0], "Received bytes count pri0");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_packets_pri0", CTLFLAG_RD,
+		    &softc->rx_packets_pri[0], "Received packets count pri0");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_bytes_pri1", CTLFLAG_RD,
+		    &softc->rx_bytes_pri[1], "Received bytes count pri1");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_packets_pri1", CTLFLAG_RD,
+		    &softc->rx_packets_pri[1], "Received packets count pri1");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_bytes_pri2", CTLFLAG_RD,
+		    &softc->rx_bytes_pri[2], "Received bytes count pri2");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_packets_pri2", CTLFLAG_RD,
+		    &softc->rx_packets_pri[2], "Received packets count pri2");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_bytes_pri3", CTLFLAG_RD,
+		    &softc->rx_bytes_pri[3], "Received bytes count pri3");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_packets_pri3", CTLFLAG_RD,
+		    &softc->rx_packets_pri[3], "Received packets count pri3");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_bytes_pri4", CTLFLAG_RD,
+		    &softc->rx_bytes_pri[4], "Received bytes count pri4");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_packets_pri4", CTLFLAG_RD,
+		    &softc->rx_packets_pri[4], "Received packets count pri4");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_bytes_pri5", CTLFLAG_RD,
+		    &softc->rx_bytes_pri[5], "Received bytes count pri5");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_packets_pri5", CTLFLAG_RD,
+		    &softc->rx_packets_pri[5], "Received packets count pri5");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_bytes_pri6", CTLFLAG_RD,
+		    &softc->rx_bytes_pri[6], "Received bytes count pri6");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_packets_pri6", CTLFLAG_RD,
+		    &softc->rx_packets_pri[6], "Received packets count pri6");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_bytes_pri7", CTLFLAG_RD,
+		    &softc->rx_bytes_pri[7], "Received bytes count pri7");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_packets_pri7", CTLFLAG_RD,
+		    &softc->rx_packets_pri[7], "Received packets count pri7");
+
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "pfc_pri0_rx_duration_us", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->pfc_pri0_rx_duration_us, "Time duration in receiving"
+		    "between XON to XOFF and XOFF to XON for pri0");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "pfc_pri0_rx_transitions", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->pfc_pri0_rx_transitions, "Num times rx transition"
+		    "between XON to XOFF and XOFF to XON for pri0");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "pfc_pri1_rx_duration_us", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->pfc_pri1_rx_duration_us, "Time duration in receiving"
+		    "between XON to XOFF and XOFF to XON for pri1");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "pfc_pri1_rx_transitions", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->pfc_pri1_rx_transitions, "Num times rx transition"
+		    "between XON to XOFF and XOFF to XON for pri1");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "pfc_pri2_rx_duration_us", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->pfc_pri2_rx_duration_us, "Time duration in receiving"
+		    "between XON to XOFF and XOFF to XON for pri2");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "pfc_pri2_rx_transitions", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->pfc_pri2_rx_transitions, "Num times rx transition"
+		    "between XON to XOFF and XOFF to XON for pri2");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "pfc_pri3_rx_duration_us", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->pfc_pri3_rx_duration_us, "Time duration in receiving"
+		    "between XON to XOFF and XOFF to XON for pri3");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "pfc_pri3_rx_transitions", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->pfc_pri3_rx_transitions, "Num times rx transition"
+		    "between XON to XOFF and XOFF to XON for pri3");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "pfc_pri4_rx_duration_us", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->pfc_pri4_rx_duration_us, "Time duration in receiving"
+		    "between XON to XOFF and XOFF to XON for pri4");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "pfc_pri4_rx_transitions", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->pfc_pri4_rx_transitions, "Num times rx transition"
+		    "between XON to XOFF and XOFF to XON for pri4");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "pfc_pri5_rx_duration_us", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->pfc_pri5_rx_duration_us, "Time duration in receiving"
+		    "between XON to XOFF and XOFF to XON for pri5");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "pfc_pri5_rx_transitions", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->pfc_pri5_rx_transitions, "Num times rx transition"
+		    "between XON to XOFF and XOFF to XON for pri5");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "pfc_pri6_rx_duration_us", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->pfc_pri6_rx_duration_us, "Time duration in receiving"
+		    "between XON to XOFF and XOFF to XON for pri6");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "pfc_pri6_rx_transitions", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->pfc_pri6_rx_transitions, "Num times rx transition"
+		    "between XON to XOFF and XOFF to XON for pri6");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "pfc_pri7_rx_duration_us", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->pfc_pri7_rx_duration_us, "Time duration in receiving"
+		    "between XON to XOFF and XOFF to XON for pri7");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "pfc_pri7_rx_transitions", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->pfc_pri7_rx_transitions, "Num times rx transition"
+		    "between XON to XOFF and XOFF to XON for pri7");
+
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_bits", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_bits, "total number of received bits");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_buffer_passed_threshold", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_buffer_passed_threshold, "num of events port"
+		    "buffer"
+		    "was over 85%");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_pcs_symbol_err", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_pcs_symbol_err, "num of symbol errors wasn't"
+		    "corrected by FEC");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_corrected_bits", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_corrected_bits, "num of bits corrected by FEC");
+
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_discard_bytes_cos0", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_discard_bytes_cos0, "num of rx discard bytes"
+		    "count on cos0");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_discard_packets_cos0", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_discard_packets_cos0, "num of rx discard packets"
+		    "count on cos0");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_discard_bytes_cos1", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_discard_bytes_cos1, "num of rx discard bytes"
+		    "count on cos1");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_discard_packets_cos1", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_discard_packets_cos1, "num of rx discard packets"
+		    "count on cos1");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_discard_bytes_cos2", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_discard_bytes_cos2, "num of rx discard bytes"
+		    "count on cos2");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_discard_packets_cos2", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_discard_packets_cos2, "num of rx discard packets"
+		    "count on cos2");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_discard_bytes_cos3", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_discard_bytes_cos3, "num of rx discard bytes"
+		    "count on cos3");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_discard_packets_cos3", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_discard_packets_cos3, "num of rx discard packets"
+		    "count on cos3");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_discard_bytes_cos4", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_discard_bytes_cos4, "num of rx discard bytes"
+		    "count on cos4");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_discard_packets_cos4", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_discard_packets_cos4, "num of rx discard packets"
+		    "count on cos4");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_discard_bytes_cos5", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_discard_bytes_cos5, "num of rx discard bytes"
+		    "count on cos5");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_discard_packets_cos5", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_discard_packets_cos5, "num of rx discard packets"
+		    "count on cos5");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_discard_bytes_cos6", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_discard_bytes_cos6, "num of rx discard bytes"
+		    "count on cos6");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_discard_packets_cos6", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_discard_packets_cos6, "num of rx discard packets"
+		    "count on cos6");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_discard_bytes_cos7", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_discard_bytes_cos7, "num of rx discard bytes"
+		    "count on cos7");
+		SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+		    "rx_discard_packets_cos7", CTLFLAG_RD,
+		    &softc->rx_port_stats_ext->rx_discard_packets_cos7, "num of rx discard packets"
+		    "count on cos7");
+	}
+
+
 	return 0;
 }
 
@@ -720,6 +1060,39 @@ static char *bnxt_chip_type[] = {
 };
 #define MAX_CHIP_TYPE 3
 
+static char *bnxt_parse_pkglog(int desired_field, uint8_t *data, size_t datalen)
+{
+	char    *retval = NULL;
+	char    *p;
+	char    *value;
+	int     field = 0;
+
+	if (datalen < 1)
+		return NULL;
+	/* null-terminate the log data (removing last '\n'): */
+	data[datalen - 1] = 0;
+	for (p = data; *p != 0; p++) {
+		field = 0;
+		retval = NULL;
+		while (*p != 0 && *p != '\n') {
+			value = p;
+			while (*p != 0 && *p != '\t' && *p != '\n')
+				p++;
+			if (field == desired_field)
+				retval = value;
+			if (*p != '\t')
+				break;
+			*p = 0;
+			field++;
+			p++;
+		}
+		if (*p == 0)
+			break;
+		*p = 0;
+	}
+	return retval;
+}
+
 static int
 bnxt_package_ver_sysctl(SYSCTL_HANDLER_ARGS)
 {
@@ -727,11 +1100,9 @@ bnxt_package_ver_sysctl(SYSCTL_HANDLER_ARGS)
 	struct iflib_dma_info dma_data;
 	char *pkglog = NULL;
 	char *p;
-	char *next;
 	char unk[] = "<unknown>";
 	char *buf = unk;
 	int rc;
-	int field;
 	uint16_t ordinal = BNX_DIR_ORDINAL_FIRST;
 	uint16_t index;
 	uint32_t data_len;
@@ -749,27 +1120,11 @@ bnxt_package_ver_sysctl(SYSCTL_HANDLER_ARGS)
 			    &dma_data);
 			if (rc == 0) {
 				pkglog = dma_data.idi_vaddr;
-				/* NULL terminate (removes last \n) */
-				pkglog[data_len-1] = 0;
-
-				/* Set p = start of last line */
-				p = strrchr(pkglog, '\n');
-				if (p == NULL)
-					p = pkglog;
-
-				/* Now find the correct tab delimited field */
-				for (field = 0, next = p,
-				    p = strsep(&next, "\t");
-				    field <
-				    BNX_PKG_LOG_FIELD_IDX_PKG_VERSION && p;
-				    p = strsep(&next, "\t")) {
-					field++;
-				}
-				if (field == BNX_PKG_LOG_FIELD_IDX_PKG_VERSION)
+				p = bnxt_parse_pkglog(BNX_PKG_LOG_FIELD_IDX_PKG_VERSION, pkglog, data_len);
+				if (p && *p != 0 && isdigit(*p))
 					buf = p;
 			}
-		}
-		else
+		} else
 			dma_data.idi_vaddr = NULL;
 	}
 
@@ -819,9 +1174,6 @@ bnxt_create_ver_sysctls(struct bnxt_softc *softc)
 	SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
 	    "driver_hwrm_if", CTLFLAG_RD, vi->driver_hwrm_if_ver, 0,
 	    "HWRM firmware version");
-	SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
-	    "hwrm_fw", CTLFLAG_RD, vi->hwrm_fw_ver, 0,
-	    "HWRM firmware version");
 	SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
 	    "mgmt_fw", CTLFLAG_RD, vi->mgmt_fw_ver, 0,
 	    "management firmware version");
@@ -1204,6 +1556,46 @@ bnxt_set_coal_tx_frames_irq(SYSCTL_HANDLER_ARGS) {
 	return rc;
 }
 
+static
+void simulate_reset(struct bnxt_softc *bp, char *fwcli_string)
+{
+	struct hwrm_dbg_fw_cli_input req = {0};
+	int rc = 0;
+
+	bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_DBG_FW_CLI);
+	req.cmpl_ring = -1;
+	req.target_id = -1;
+	req.cli_cmd_len = strlen(fwcli_string);
+	req.host_buf_len = 64 * 1024;
+	strcpy((char *)req.cli_cmd, fwcli_string);
+
+	BNXT_HWRM_LOCK(bp);
+	rc = _hwrm_send_message(bp, &req, sizeof(req));
+	if (rc) {
+		device_printf(bp->dev, " Manual FW fault failed, rc:%x\n", rc);
+	}
+	BNXT_HWRM_UNLOCK(bp);
+}
+
+static int
+bnxt_reset_ctrl(SYSCTL_HANDLER_ARGS) {
+	struct bnxt_softc *softc = arg1;
+	int rc = 0;
+	char buf[50] = {0};
+
+	if (softc == NULL)
+		return EBUSY;
+
+	rc = sysctl_handle_string(oidp, buf, sizeof(buf), req);
+	if (rc || req->newptr == NULL)
+		return rc;
+
+	if (BNXT_CHIP_P5(softc))
+		simulate_reset(softc, buf);
+
+	return rc;
+}
+
 int
 bnxt_create_config_sysctls_pre(struct bnxt_softc *softc)
 {
@@ -1228,35 +1620,43 @@ bnxt_create_config_sysctls_pre(struct bnxt_softc *softc)
 	SYSCTL_ADD_CONST_STRING(ctx, children, OID_AUTO, "if_name", CTLFLAG_RD,
 		if_name(iflib_get_ifp(softc->ctx)), "interface name");
 
-        SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_rx_usecs",
-            CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0,
+	SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_rx_usecs",
+	    CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0,
 	    bnxt_set_coal_rx_usecs, "I", "interrupt coalescing Rx Usecs");
-        SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_rx_frames",
-            CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0,
+	SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_rx_frames",
+	    CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0,
 	    bnxt_set_coal_rx_frames, "I", "interrupt coalescing Rx Frames");
-        SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_rx_usecs_irq",
-            CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0,
+	SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_rx_usecs_irq",
+	    CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0,
 	    bnxt_set_coal_rx_usecs_irq, "I",
 	    "interrupt coalescing Rx Usecs IRQ");
-        SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_rx_frames_irq",
-            CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0,
+	SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_rx_frames_irq",
+	    CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0,
 	    bnxt_set_coal_rx_frames_irq, "I",
 	    "interrupt coalescing Rx Frames IRQ");
-        SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_tx_usecs",
-            CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0,
+	SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_tx_usecs",
+	    CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0,
 	    bnxt_set_coal_tx_usecs, "I", "interrupt coalescing Tx Usces");
-        SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_tx_frames",
-            CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0,
-	    bnxt_set_coal_tx_frames, "I", "interrupt coalescing Tx Frames"); 
-        SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_tx_usecs_irq",
-            CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0,
+	SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_tx_frames",
+	    CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0,
+	    bnxt_set_coal_tx_frames, "I", "interrupt coalescing Tx Frames");
+	SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_tx_usecs_irq",
+	    CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0,
 	    bnxt_set_coal_tx_usecs_irq, "I",
-	    "interrupt coalescing Tx Usecs IRQ"); 
-        SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_tx_frames_irq",
-            CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0,
+	    "interrupt coalescing Tx Usecs IRQ");
+	SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_tx_frames_irq",
+	    CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0,
 	    bnxt_set_coal_tx_frames_irq, "I",
 	    "interrupt coalescing Tx Frames IRQ");
-
+	SYSCTL_ADD_U32(ctx, children, OID_AUTO, "flags", CTLFLAG_RD,
+		&softc->flags, 0, "flags");
+	SYSCTL_ADD_U64(ctx, children, OID_AUTO, "fw_cap", CTLFLAG_RD,
+		&softc->fw_cap, 0, "FW caps");
+
+	SYSCTL_ADD_PROC(ctx, children, OID_AUTO,
+	    "reset_ctrl", CTLTYPE_STRING | CTLFLAG_RWTUN, softc,
+	    0, bnxt_reset_ctrl, "A",
+	    "Issue controller reset: 0 / 1");
 	return 0;
 }
 
@@ -1386,6 +1786,377 @@ bnxt_create_hw_lro_sysctls(struct bnxt_softc *softc)
 	return 0;
 }
 
+static int
+bnxt_dcb_dcbx_cap(SYSCTL_HANDLER_ARGS)
+{
+	struct bnxt_softc *softc = arg1;
+	int val;
+	int rc;
+
+	if (softc == NULL)
+		return EBUSY;
+
+	val = bnxt_dcb_getdcbx(softc);
+	rc = sysctl_handle_int(oidp, &val, 0, req);
+	if (rc || !req->newptr)
+		return rc;
+
+	bnxt_dcb_setdcbx(softc, val);
+
+	return rc;
+}
+
+static char
+bnxt_ets_tsa_to_str(struct bnxt_softc *softc, uint32_t tc)
+{
+	switch (softc->ieee_ets->tc_tsa[tc]) {
+	case BNXT_IEEE_8021QAZ_TSA_STRICT:
+		return 's';
+	case BNXT_IEEE_8021QAZ_TSA_ETS:
+		return 'e';
+	default:
+		return 'X';
+
+	}
+}
+
+static uint32_t
+bnxt_ets_str_to_tsa(char tsa_str)
+{
+	switch (tsa_str) {
+	case 's':
+		return BNXT_IEEE_8021QAZ_TSA_STRICT;
+	case 'e':
+		return BNXT_IEEE_8021QAZ_TSA_ETS;
+	default:
+		return -1;
+	}
+}
+
+static int
+bnxt_ets_get_val(struct bnxt_softc *softc, uint32_t type, uint32_t tc)
+{
+	switch (type) {
+	case BNXT_TYPE_ETS_TSA:
+		if (softc->ieee_ets)
+			return softc->ieee_ets->tc_tsa[tc];
+		break;
+	case BNXT_TYPE_ETS_PRI2TC:
+		if (softc->ieee_ets)
+			return softc->ieee_ets->prio_tc[tc];
+		break;
+	case BNXT_TYPE_ETS_TCBW:
+		if (softc->ieee_ets)
+			return softc->ieee_ets->tc_tx_bw[tc];
+		break;
+	default:
+		break;
+	}
+
+	return -1;
+}
+
+static void
+bnxt_pfc_get_string(struct bnxt_softc *softc, char *buf, struct bnxt_ieee_pfc *pfc)
+{
+	uint32_t i;
+	bool found = false;
+
+	for (i = 0; i < BNXT_IEEE_8021QAZ_MAX_TCS; i++) {
+		if (pfc->pfc_en & (1 << i)) {
+			if (found)
+				buf += sprintf(buf, ", ");
+			buf += sprintf(buf, "%d", i);
+			found = true;
+		}
+	}
+
+	if (!found)
+		buf += sprintf(buf, "none");
+}
+
+static char *bnxt_get_tlv_selector_str(uint8_t selector)
+{
+	switch (selector) {
+	case BNXT_IEEE_8021QAZ_APP_SEL_ETHERTYPE:
+		return "Ethertype";
+	case BNXT_IEEE_8021QAZ_APP_SEL_DGRAM:
+		return "UDP or DCCP";
+	case BNXT_IEEE_8021QAZ_APP_SEL_DSCP:
+		return "DSCP";
+	default:
+		return "Unknown";
+	}
+}
+
+static void
+bnxt_app_tlv_get_string(struct bnxt_softc *softc, char *buf,
+			struct bnxt_dcb_app *app, int num)
+{
+	uint32_t i;
+
+	if (!num) {
+		buf += sprintf(buf, " None");
+		return;
+	}
+
+	buf += sprintf(buf, "\n");
+	for (i = 0; i < num; i++) {
+		buf += sprintf(buf, "\tAPP#%0d:\tpri: %d,\tSel: %d,\t%s: %d\n",
+				i,
+				app[i].priority,
+				app[i].selector,
+				bnxt_get_tlv_selector_str(app[i].selector),
+				app[i].protocol);
+	}
+}
+
+static void
+bnxt_ets_get_string(struct bnxt_softc *softc, char *buf)
+{
+	uint32_t type, i;
+
+	type = BNXT_TYPE_ETS_TSA;
+	for (type = 0; type < BNXT_TYPE_ETS_MAX; type++) {
+		for (i = 0; i < BNXT_IEEE_8021QAZ_MAX_TCS; i++) {
+			if (i == 0)
+				buf += sprintf(buf, "%s:", BNXT_ETS_TYPE_STR[type]);
+
+			if (!softc->ieee_ets)
+				buf += sprintf(buf, "x");
+			else if (type == BNXT_TYPE_ETS_TSA)
+				buf += sprintf(buf, "%c", bnxt_ets_tsa_to_str(softc, i));
+			else
+				buf += sprintf(buf, "%d", bnxt_ets_get_val(softc, type, i));
+
+			if (i != BNXT_IEEE_8021QAZ_MAX_TCS - 1)
+				buf += sprintf(buf, ",");
+		}
+		if (type != BNXT_TYPE_ETS_MAX - 1)
+			buf += sprintf(buf, "#");
+	}
+}
+
+static int
+bnxt_dcb_list_app(SYSCTL_HANDLER_ARGS)
+{
+	struct bnxt_dcb_app app[128] = {0};
+	struct bnxt_softc *softc = arg1;
+	int rc, num_inputs = 0;
+	char *buf;
+
+	if (softc == NULL)
+		return EBUSY;
+
+#define BNXT_APP_TLV_STR_LEN	4096
+	buf = malloc(BNXT_APP_TLV_STR_LEN, M_DEVBUF, M_NOWAIT | M_ZERO);
+	if (!buf)
+		return ENOMEM;
+
+	bnxt_dcb_ieee_listapp(softc, app, &num_inputs);
+	bnxt_app_tlv_get_string(softc, buf, app, num_inputs);
+
+	rc = sysctl_handle_string(oidp, buf, BNXT_APP_TLV_STR_LEN, req);
+	if (rc || req->newptr == NULL)
+		goto end;
+
+end:
+	free(buf, M_DEVBUF);
+	return rc;
+}
+
+static int
+bnxt_dcb_del_app(SYSCTL_HANDLER_ARGS)
+{
+	struct bnxt_softc *softc = arg1;
+	struct bnxt_dcb_app app = {0};
+	char buf[256] = {0};
+	int rc, num_inputs;
+
+	if (softc == NULL)
+		return EBUSY;
+
+	rc = sysctl_handle_string(oidp, buf, sizeof(buf), req);
+	if (rc || req->newptr == NULL)
+		return rc;
+
+	num_inputs = sscanf(buf, "%hhu,%hhu,%hd", &app.priority, &app.selector, &app.protocol);
+
+	if (num_inputs != 3) {
+		device_printf(softc->dev,
+			      "Invalid app tlv syntax, inputs = %d\n", num_inputs);
+		return EINVAL;
+	}
+
+	bnxt_dcb_ieee_delapp(softc, &app);
+
+	return rc;
+}
+static int
+bnxt_dcb_set_app(SYSCTL_HANDLER_ARGS)
+{
+	struct bnxt_softc *softc = arg1;
+	struct bnxt_dcb_app app = {0};
+	char buf[256] = {0};
+	int rc, num_inputs;
+
+	if (softc == NULL)
+		return EBUSY;
+
+	rc = sysctl_handle_string(oidp, buf, sizeof(buf), req);
+	if (rc || req->newptr == NULL)
+		return rc;
+
+	num_inputs = sscanf(buf, "%hhu,%hhu,%hd", &app.priority, &app.selector, &app.protocol);
+
+	if (num_inputs != 3) {
+		device_printf(softc->dev,
+			      "Invalid app tlv syntax, inputs = %d\n", num_inputs);
+		return EINVAL;
+	}
+
+	bnxt_dcb_ieee_setapp(softc, &app);
+
+	return rc;
+}
+
+static int
+bnxt_dcb_pfc(SYSCTL_HANDLER_ARGS)
+{
+	struct bnxt_softc *softc = arg1;
+	struct bnxt_ieee_pfc pfc = {0};
+	int rc, i, num_inputs;
+	char buf[256] = {0};
+	int pri_mask = 0;
+	char pri[8];
+
+	if (softc == NULL)
+		return EBUSY;
+
+	rc = bnxt_dcb_ieee_getpfc(softc, &pfc);
+	if (!rc)
+		bnxt_pfc_get_string(softc, buf, &pfc);
+	else
+		sprintf(buf, "## getpfc failed with error %d ##", rc);
+
+	rc = sysctl_handle_string(oidp, buf, sizeof(buf), req);
+	if (rc || req->newptr == NULL)
+		return rc;
+
+	/* Check for 'none' string first */
+	if (sscanf(buf,  "%s", buf) == 1) {
+		if (strncmp(buf, "none", 8) == 0) {
+			goto configure;
+		}
+	}
+	num_inputs = sscanf(buf, "%hhu,%hhu,%hhu,%hhu,%hhu,%hhu,%hhu,%hhu",
+			    &pri[0], &pri[1], &pri[2], &pri[3], &pri[4],
+			    &pri[5], &pri[6], &pri[7]);
+
+	if (num_inputs < 1 || num_inputs > 8) {
+		device_printf(softc->dev,
+			      "Invalid pfc syntax, inputs = %d\n", num_inputs);
+		return EINVAL;
+	}
+
+	for (i = 0; i < num_inputs; i++) {
+		if (pri[i] > 7 || pri[i] < 0) {
+			device_printf(softc->dev,
+				      "Invalid priority %d. Valid priorties are "
+				      "from 0 to 7 and string \"none\".\n", pri[i]);
+			return EINVAL;
+		}
+
+		pri_mask |= (1 << pri[i]) & 0xFF;
+	}
+
+configure:
+	pfc.pfc_en = pri_mask;
+	rc = bnxt_dcb_ieee_setpfc(softc, &pfc);
+	if (rc)
+		device_printf(softc->dev,
+			      "setpfc failed with status %d\n", rc);
+	return rc;
+}
+
+static int
+bnxt_dcb_ets(SYSCTL_HANDLER_ARGS)
+{
+	struct bnxt_softc *softc = arg1;
+	struct bnxt_ieee_ets ets = {0};
+	int rc = 0, i, num_inputs;
+	char buf[256] = {0};
+	char tsa[8];
+
+	if (softc == NULL)
+		return EBUSY;
+
+	rc = bnxt_dcb_ieee_getets(softc, &ets);
+	if (!rc)
+		bnxt_ets_get_string(softc, buf);
+	else
+		sprintf(buf, "## getets failed with error %d ##", rc);
+
+	rc = sysctl_handle_string(oidp, buf, sizeof(buf), req);
+	if (rc || req->newptr == NULL)
+		return rc;
+
+	num_inputs = sscanf(buf,  "tsa:%c,%c,%c,%c,%c,%c,%c,%c#"
+			    "pri2tc:%hhu,%hhu,%hhu,%hhu,%hhu,%hhu,%hhu,%hhu#"
+			    "tcbw:%hhu,%hhu,%hhu,%hhu,%hhu,%hhu,%hhu,%hhu",
+			    &tsa[0], &tsa[1], &tsa[2], &tsa[3], &tsa[4], &tsa[5], &tsa[6], &tsa[7],
+			    &ets.prio_tc[0], &ets.prio_tc[1], &ets.prio_tc[2], &ets.prio_tc[3],
+			    &ets.prio_tc[4], &ets.prio_tc[5], &ets.prio_tc[6], &ets.prio_tc[7],
+			    &ets.tc_tx_bw[0], &ets.tc_tx_bw[1], &ets.tc_tx_bw[2], &ets.tc_tx_bw[3],
+			    &ets.tc_tx_bw[4], &ets.tc_tx_bw[5], &ets.tc_tx_bw[6], &ets.tc_tx_bw[7]);
+
+	if (num_inputs != 24)
+		return EINVAL;
+
+	for ( i= 0; i < 8; i++)
+		ets.tc_tsa[i] = bnxt_ets_str_to_tsa(tsa[i]);
+
+	rc = bnxt_dcb_ieee_setets(softc, &ets);
+
+	return rc;
+}
+
+int
+bnxt_create_dcb_sysctls(struct bnxt_softc *softc)
+{
+	struct sysctl_oid *oid = softc->dcb_oid;
+
+	if (!oid)
+		return ENOMEM;
+
+	SYSCTL_ADD_PROC(&softc->dcb_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
+	    "dcbx_cap", CTLTYPE_INT | CTLFLAG_RWTUN, softc,
+	    0, bnxt_dcb_dcbx_cap, "A",
+	    "Enable or Disable LRO: 0 / 1");
+
+	SYSCTL_ADD_PROC(&softc->dcb_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "ets",
+	    CTLTYPE_STRING | CTLFLAG_RWTUN, softc, 0,
+	    bnxt_dcb_ets, "A", "Enhanced Transmission Selection (ETS)");
+
+	SYSCTL_ADD_PROC(&softc->dcb_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc",
+	    CTLTYPE_STRING | CTLFLAG_RWTUN, softc, 0,
+	    bnxt_dcb_pfc, "A", "Enhanced Transmission Selection (ETS)");
+
+	SYSCTL_ADD_PROC(&softc->dcb_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "set_apptlv",
+	    CTLTYPE_STRING | CTLFLAG_WR, softc, 0,
+	    bnxt_dcb_set_app, "A", "Set App TLV");
+
+	SYSCTL_ADD_PROC(&softc->dcb_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "del_apptlv",
+	    CTLTYPE_STRING | CTLFLAG_WR, softc, 0,
+	    bnxt_dcb_del_app, "A", "Delete App TLV");
+
+	SYSCTL_ADD_PROC(&softc->dcb_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "list_apptlv",
+	    CTLTYPE_STRING | CTLFLAG_RD, softc, 0,
+	    bnxt_dcb_list_app, "A", "List all App TLVs");
+
+	return 0;
+}
+
 int
 bnxt_create_config_sysctls_post(struct bnxt_softc *softc)
 {
diff --git a/sys/dev/bnxt/bnxt_sysctl.h b/sys/dev/bnxt/bnxt_en/bnxt_sysctl.h
similarity index 95%
rename from sys/dev/bnxt/bnxt_sysctl.h
rename to sys/dev/bnxt/bnxt_en/bnxt_sysctl.h
index a2ca3a8a559f..d4c9e908b9c1 100644
--- a/sys/dev/bnxt/bnxt_sysctl.h
+++ b/sys/dev/bnxt/bnxt_en/bnxt_sysctl.h
@@ -40,3 +40,5 @@ int bnxt_create_config_sysctls_pre(struct bnxt_softc *softc);
 int bnxt_create_config_sysctls_post(struct bnxt_softc *softc);
 int bnxt_create_hw_lro_sysctls(struct bnxt_softc *softc);
 int bnxt_create_pause_fc_sysctls(struct bnxt_softc *softc);
+int bnxt_create_dcb_sysctls(struct bnxt_softc *softc);
+int bnxt_create_dcb_ets_sysctls(struct bnxt_softc *softc);
diff --git a/sys/dev/bnxt/bnxt_txrx.c b/sys/dev/bnxt/bnxt_en/bnxt_txrx.c
similarity index 100%
rename from sys/dev/bnxt/bnxt_txrx.c
rename to sys/dev/bnxt/bnxt_en/bnxt_txrx.c
diff --git a/sys/dev/bnxt/bnxt_en/bnxt_ulp.c b/sys/dev/bnxt/bnxt_en/bnxt_ulp.c
new file mode 100644
index 000000000000..17ae916052f4
--- /dev/null
+++ b/sys/dev/bnxt/bnxt_en/bnxt_ulp.c
@@ -0,0 +1,526 @@
+/*-
+ * Broadcom NetXtreme-C/E network driver.
+ *
+ * Copyright (c) 2024 Broadcom, All Rights Reserved.
+ * The term Broadcom refers to Broadcom Limited and/or its subsidiaries
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/interrupt.h>
+#include <linux/pci.h>
+#include <linux/netdevice.h>
+#include <linux/bitops.h>
+#include <linux/delay.h>
+#include <asm/byteorder.h>
+#include <linux/bitmap.h>
+#include <linux/rcupdate.h>
+#include <net/if.h>
+#include <net/if_dl.h>
+#include <net/if_media.h>
+#include <net/if_var.h>
+#include <net/ethernet.h>
+#include <net/iflib.h>
+
+#include "hsi_struct_def.h"
+#include "bnxt.h"
+#include "bnxt_hwrm.h"
+#include "bnxt_ulp.h"
+
+void bnxt_destroy_irq(struct bnxt_softc *softc);
+
+static int bnxt_register_dev(struct bnxt_en_dev *edev, int ulp_id,
+			     struct bnxt_ulp_ops *ulp_ops, void *handle)
+{
+	struct bnxt_softc *bp = edev->softc;
+	struct bnxt_ulp *ulp;
+	int rc = 0;
+
+	if (ulp_id >= BNXT_MAX_ULP)
+		return -EINVAL;
+
+	mtx_lock(&bp->en_ops_lock);
+	ulp = &edev->ulp_tbl[ulp_id];
+	if (rcu_access_pointer(ulp->ulp_ops)) {
+		device_printf(bp->dev, "ulp id %d already registered\n", ulp_id);
+		rc = -EBUSY;
+		goto exit;
+	}
+
+	edev->flags &= ~BNXT_EN_FLAG_ULP_STOPPED;
+	atomic_set(&ulp->ref_count, 0);
+	ulp->handle = handle;
+	rcu_assign_pointer(ulp->ulp_ops, ulp_ops);
+
+	if (ulp_id == BNXT_ROCE_ULP) {
+		if (test_bit(BNXT_STATE_OPEN, &bp->state) && bp->is_dev_init)
+			bnxt_hwrm_vnic_cfg(bp, &bp->vnic_info);
+	}
+
+exit:
+	mtx_unlock(&bp->en_ops_lock);
+	return rc;
+}
+
+static int bnxt_unregister_dev(struct bnxt_en_dev *edev, int ulp_id)
+{
+	struct bnxt_softc *bp = edev->softc;
+	struct bnxt_ulp *ulp;
+	int i = 0;
+
+	if (ulp_id >= BNXT_MAX_ULP)
+		return -EINVAL;
+
+	ulp = &edev->ulp_tbl[ulp_id];
+	if (!rcu_access_pointer(ulp->ulp_ops)) {
+		device_printf(bp->dev, "ulp id %d not registered\n", ulp_id);
+		return -EINVAL;
+	}
+	if (ulp_id == BNXT_ROCE_ULP && ulp->msix_requested)
+		edev->en_ops->bnxt_free_msix(edev, ulp_id);
+
+	mtx_lock(&bp->en_ops_lock);
+	RCU_INIT_POINTER(ulp->ulp_ops, NULL);
+	synchronize_rcu();
+	ulp->max_async_event_id = 0;
+	ulp->async_events_bmap = NULL;
+	while (atomic_read(&ulp->ref_count) != 0 && i < 10) {
+		msleep(100);
+		i++;
+	}
+	mtx_unlock(&bp->en_ops_lock);
+	return 0;
+}
+
+static void bnxt_fill_msix_vecs(struct bnxt_softc *bp, struct bnxt_msix_entry *ent)
+{
+	struct bnxt_en_dev *edev = bp->edev;
+	int num_msix, idx, i;
+
+	num_msix = edev->ulp_tbl[BNXT_ROCE_ULP].msix_requested;
+	idx = edev->ulp_tbl[BNXT_ROCE_ULP].msix_base;
+	for (i = 0; i < num_msix; i++) {
+		ent[i].vector = bp->irq_tbl[idx + i].vector;
+		ent[i].ring_idx = idx + i;
+		if (BNXT_CHIP_P5(bp))
+			ent[i].db_offset = DB_PF_OFFSET_P5;
+		else
+			ent[i].db_offset = (idx + i) * 0x80;
+
+	}
+}
+
+static int bnxt_req_msix_vecs(struct bnxt_en_dev *edev, int ulp_id,
+			      struct bnxt_msix_entry *ent, int num_msix)
+{
+	struct bnxt_softc *bp = edev->softc;
+	int avail_msix, idx;
+
+	if (ulp_id != BNXT_ROCE_ULP)
+		return -EINVAL;
+
+	if (edev->ulp_tbl[ulp_id].msix_requested)
+		return -EAGAIN;
+
+	idx = bp->total_irqs - BNXT_ROCE_IRQ_COUNT;
+	avail_msix = BNXT_ROCE_IRQ_COUNT;
+
+	mtx_lock(&bp->en_ops_lock);
+	edev->ulp_tbl[ulp_id].msix_base = idx;
+	edev->ulp_tbl[ulp_id].msix_requested = avail_msix;
+
+	bnxt_fill_msix_vecs(bp, ent);
+	edev->flags |= BNXT_EN_FLAG_MSIX_REQUESTED;
+	mtx_unlock(&bp->en_ops_lock);
+	return avail_msix;
+}
+
+static int bnxt_free_msix_vecs(struct bnxt_en_dev *edev, int ulp_id)
+{
+	struct bnxt_softc *bp = edev->softc;
+
+	if (ulp_id != BNXT_ROCE_ULP)
+		return -EINVAL;
+
+	if (!(edev->flags & BNXT_EN_FLAG_MSIX_REQUESTED))
+		return 0;
+
+	mtx_lock(&bp->en_ops_lock);
+	edev->ulp_tbl[ulp_id].msix_requested = 0;
+	edev->flags &= ~BNXT_EN_FLAG_MSIX_REQUESTED;
+	if (edev->flags & BNXT_EN_FLAG_ULP_STOPPED)
+		goto stopped;
+
+stopped:
+	mtx_unlock(&bp->en_ops_lock);
+
+	return 0;
+}
+
+int bnxt_get_ulp_msix_num(struct bnxt_softc *bp)
+{
+	if (bnxt_ulp_registered(bp->edev, BNXT_ROCE_ULP)) {
+		struct bnxt_en_dev *edev = bp->edev;
+
+		return edev->ulp_tbl[BNXT_ROCE_ULP].msix_requested;
+	}
+	return 0;
+}
+
+int bnxt_get_ulp_msix_base(struct bnxt_softc *bp)
+{
+	if (bnxt_ulp_registered(bp->edev, BNXT_ROCE_ULP)) {
+		struct bnxt_en_dev *edev = bp->edev;
+
+		if (edev->ulp_tbl[BNXT_ROCE_ULP].msix_requested)
+			return edev->ulp_tbl[BNXT_ROCE_ULP].msix_base;
+	}
+	return 0;
+}
+
+static int bnxt_send_msg(struct bnxt_en_dev *edev, int ulp_id,
+			 struct bnxt_fw_msg *fw_msg)
+{
+	struct bnxt_softc *softc = edev->softc;
+	int rc;
+
+	if ((ulp_id != BNXT_ROCE_ULP) && softc->fw_reset_state)
+		return -EBUSY;
+
+	rc = bnxt_hwrm_passthrough(softc, fw_msg->msg, fw_msg->msg_len, fw_msg->resp,
+				    fw_msg->resp_max_len, fw_msg->timeout);
+	return rc;
+}
+
+static void bnxt_ulp_get(struct bnxt_ulp *ulp)
+{
+	atomic_inc(&ulp->ref_count);
+}
+
+static void bnxt_ulp_put(struct bnxt_ulp *ulp)
+{
+	atomic_dec(&ulp->ref_count);
+}
+
+void bnxt_ulp_stop(struct bnxt_softc *bp)
+{
+	struct bnxt_en_dev *edev = bp->edev;
+	struct bnxt_ulp_ops *ops;
+	int i;
+
+	if (!edev)
+		return;
+
+	edev->flags |= BNXT_EN_FLAG_ULP_STOPPED;
+	edev->en_state = bp->state;
+	for (i = 0; i < BNXT_MAX_ULP; i++) {
+		struct bnxt_ulp *ulp = &edev->ulp_tbl[i];
+
+		ops = ulp->ulp_ops;
+		if (!ops || !ops->ulp_stop)
+			continue;
+		ops->ulp_stop(ulp->handle);
+	}
+}
+
+void bnxt_ulp_start(struct bnxt_softc *bp, int err)
+{
+	struct bnxt_en_dev *edev = bp->edev;
+	struct bnxt_ulp_ops *ops;
+	int i;
+
+	if (!edev)
+		return;
+
+	edev->flags &= ~BNXT_EN_FLAG_ULP_STOPPED;
+	edev->en_state = bp->state;
+
+	if (err)
+		return;
+
+	for (i = 0; i < BNXT_MAX_ULP; i++) {
+		struct bnxt_ulp *ulp = &edev->ulp_tbl[i];
+
+		ops = ulp->ulp_ops;
+		if (!ops || !ops->ulp_start)
+			continue;
+		ops->ulp_start(ulp->handle);
+	}
+}
+
+void bnxt_ulp_sriov_cfg(struct bnxt_softc *bp, int num_vfs)
+{
+	struct bnxt_en_dev *edev = bp->edev;
+	struct bnxt_ulp_ops *ops;
+	int i;
+
+	if (!edev)
+		return;
+
+	for (i = 0; i < BNXT_MAX_ULP; i++) {
+		struct bnxt_ulp *ulp = &edev->ulp_tbl[i];
+
+		rcu_read_lock();
+		ops = rcu_dereference(ulp->ulp_ops);
+		if (!ops || !ops->ulp_sriov_config) {
+			rcu_read_unlock();
+			continue;
+		}
+		bnxt_ulp_get(ulp);
+		rcu_read_unlock();
+		ops->ulp_sriov_config(ulp->handle, num_vfs);
+		bnxt_ulp_put(ulp);
+	}
+}
+
+void bnxt_ulp_shutdown(struct bnxt_softc *bp)
+{
+	struct bnxt_en_dev *edev = bp->edev;
+	struct bnxt_ulp_ops *ops;
+	int i;
+
+	if (!edev)
+		return;
+
+	for (i = 0; i < BNXT_MAX_ULP; i++) {
+		struct bnxt_ulp *ulp = &edev->ulp_tbl[i];
+
+		ops = ulp->ulp_ops;
+		if (!ops || !ops->ulp_shutdown)
+			continue;
+		ops->ulp_shutdown(ulp->handle);
+	}
+}
+
+void bnxt_ulp_irq_stop(struct bnxt_softc *bp)
+{
+	struct bnxt_en_dev *edev = bp->edev;
+	struct bnxt_ulp_ops *ops;
+
+	if (!edev || !(edev->flags & BNXT_EN_FLAG_MSIX_REQUESTED))
+		return;
+
+	if (bnxt_ulp_registered(bp->edev, BNXT_ROCE_ULP)) {
+		struct bnxt_ulp *ulp = &edev->ulp_tbl[BNXT_ROCE_ULP];
+
+		if (!ulp->msix_requested)
+			return;
+
+		ops = ulp->ulp_ops;
+		if (!ops || !ops->ulp_irq_stop)
+			return;
+		ops->ulp_irq_stop(ulp->handle);
+	}
+}
+
+void bnxt_ulp_async_events(struct bnxt_softc *bp, struct hwrm_async_event_cmpl *cmpl)
+{
+	u16 event_id = le16_to_cpu(cmpl->event_id);
+	struct bnxt_en_dev *edev = bp->edev;
+	struct bnxt_ulp_ops *ops;
+	int i;
+
+	if (!edev)
+		return;
+
+	rcu_read_lock();
+	for (i = 0; i < BNXT_MAX_ULP; i++) {
+		struct bnxt_ulp *ulp = &edev->ulp_tbl[i];
+
+		ops = rcu_dereference(ulp->ulp_ops);
+		if (!ops || !ops->ulp_async_notifier)
+			continue;
+		if (!ulp->async_events_bmap ||
+		    event_id > ulp->max_async_event_id)
+			continue;
+
+		/* Read max_async_event_id first before testing the bitmap. */
+		rmb();
+		if (edev->flags & BNXT_EN_FLAG_ULP_STOPPED)
+			continue;
+
+		if (test_bit(event_id, ulp->async_events_bmap))
+			ops->ulp_async_notifier(ulp->handle, cmpl);
+	}
+	rcu_read_unlock();
+}
+
+static int bnxt_register_async_events(struct bnxt_en_dev *edev, int ulp_id,
+				      unsigned long *events_bmap, u16 max_id)
+{
+	struct bnxt_softc *bp = edev->softc;
+	struct bnxt_ulp *ulp;
+
+	if (ulp_id >= BNXT_MAX_ULP)
+		return -EINVAL;
+
+	mtx_lock(&bp->en_ops_lock);
+	ulp = &edev->ulp_tbl[ulp_id];
+	ulp->async_events_bmap = events_bmap;
+	wmb();
+	ulp->max_async_event_id = max_id;
+	bnxt_hwrm_func_drv_rgtr(bp, events_bmap, max_id + 1, true);
+	mtx_unlock(&bp->en_ops_lock);
+	return 0;
+}
+
+void bnxt_destroy_irq(struct bnxt_softc *softc)
+{
+	kfree(softc->irq_tbl);
+}
+
+static int bnxt_populate_irq(struct bnxt_softc *softc)
+{
+	struct resource_list *rl = NULL;
+	struct resource_list_entry *rle = NULL;
+	struct bnxt_msix_tbl *irq_tbl = NULL;
+	struct pci_devinfo *dinfo = NULL;
+	int i;
+
+	softc->total_irqs = softc->scctx->isc_nrxqsets + BNXT_ROCE_IRQ_COUNT;
+	irq_tbl = kzalloc(softc->total_irqs * sizeof(*softc->irq_tbl), GFP_KERNEL);
+
+	if (!irq_tbl) {
+		device_printf(softc->dev, "Failed to allocate IRQ table\n");
+		return -1;
+	}
+	dinfo = device_get_ivars(softc->pdev->dev.bsddev);
+	rl = &dinfo->resources;
+	rle = resource_list_find(rl, SYS_RES_IRQ, 1);
+	softc->pdev->dev.irq_start = rle->start;
+	softc->pdev->dev.irq_end = rle->start + softc->total_irqs;
+
+	for (i = 0; i < softc->total_irqs; i++) {
+		irq_tbl[i].entry = i;
+		irq_tbl[i].vector = softc->pdev->dev.irq_start + i;
+	}
+
+	softc->irq_tbl = irq_tbl;
+
+	return 0;
+}
+
+static const struct bnxt_en_ops bnxt_en_ops_tbl = {
+	.bnxt_register_device	= bnxt_register_dev,
+	.bnxt_unregister_device	= bnxt_unregister_dev,
+	.bnxt_request_msix	= bnxt_req_msix_vecs,
+	.bnxt_free_msix		= bnxt_free_msix_vecs,
+	.bnxt_send_fw_msg	= bnxt_send_msg,
+	.bnxt_register_fw_async_events	= bnxt_register_async_events,
+};
+
+void bnxt_aux_dev_release(struct device *dev)
+{
+	struct bnxt_aux_dev *bnxt_adev =
+		container_of(dev, struct bnxt_aux_dev, aux_dev.dev);
+	struct bnxt_softc *bp = bnxt_adev->edev->softc;
+
+	kfree(bnxt_adev->edev);
+	bnxt_adev->edev = NULL;
+	bp->edev = NULL;
+}
+
+static inline void bnxt_set_edev_info(struct bnxt_en_dev *edev, struct bnxt_softc *bp)
+{
+	edev->en_ops = &bnxt_en_ops_tbl;
+	edev->net = bp->ifp;
+	edev->pdev = bp->pdev;
+	edev->softc = bp;
+	edev->l2_db_size = bp->db_size;
+	mtx_init(&bp->en_ops_lock, "Ethernet ops lock", NULL, MTX_DEF);
+
+	if (bp->flags & BNXT_FLAG_ROCEV1_CAP)
+		edev->flags |= BNXT_EN_FLAG_ROCEV1_CAP;
+	if (bp->flags & BNXT_FLAG_ROCEV2_CAP)
+		edev->flags |= BNXT_EN_FLAG_ROCEV2_CAP;
+	if (bp->is_asym_q)
+		edev->flags |= BNXT_EN_FLAG_ASYM_Q;
+	edev->hwrm_bar = bp->hwrm_bar;
+	edev->port_partition_type = bp->port_partition_type;
+	edev->ulp_version = BNXT_ULP_VERSION;
+}
+
+int bnxt_rdma_aux_device_del(struct bnxt_softc *softc)
+{
+	struct bnxt_aux_dev *bnxt_adev = softc->aux_dev;
+	struct auxiliary_device *adev;
+
+	adev = &bnxt_adev->aux_dev;
+	auxiliary_device_delete(adev);
+	auxiliary_device_uninit(adev);
+	bnxt_destroy_irq(softc);
+
+	return 0;
+}
+
+int bnxt_rdma_aux_device_add(struct bnxt_softc *bp)
+{
+	struct bnxt_aux_dev *bnxt_adev = bp->aux_dev;
+	struct bnxt_en_dev *edev = bnxt_adev->edev;
+	struct auxiliary_device *aux_dev;
+	int ret = -1;
+
+	if (bnxt_populate_irq(bp))
+		return ret;
+
+	device_printf(bp->dev, "V:D:SV:SD %x:%x:%x:%x, irq 0x%x, "
+		      "devfn 0x%x, cla 0x%x, rev 0x%x, msi_en 0x%x\n",
+		      bp->pdev->vendor, bp->pdev->device, bp->pdev->subsystem_vendor,
+		      bp->pdev->subsystem_device, bp->pdev->irq, bp->pdev->devfn,
+		      bp->pdev->class, bp->pdev->revision, bp->pdev->msi_enabled);
+
+	aux_dev = &bnxt_adev->aux_dev;
+	aux_dev->id = bnxt_adev->id;
+	aux_dev->name = "rdma";
+	aux_dev->dev.parent = &bp->pdev->dev;
+	aux_dev->dev.release = bnxt_aux_dev_release;
+
+	if (!edev) {
+		edev = kzalloc(sizeof(*edev), GFP_KERNEL);
+		if (!edev)
+			return -ENOMEM;
+	}
+
+	bnxt_set_edev_info(edev, bp);
+	bnxt_adev->edev = edev;
+	bp->edev = edev;
+
+	ret = auxiliary_device_init(aux_dev);
+	if (ret)
+		goto err_free_edev;
+
+	ret = auxiliary_device_add(aux_dev);
+	if (ret)
+		goto err_dev_uninit;
+
+	return 0;
+err_dev_uninit:
+	auxiliary_device_uninit(aux_dev);
+err_free_edev:
+	kfree(edev);
+	bnxt_adev->edev = NULL;
+	bp->edev = NULL;
+	return ret;
+}
diff --git a/sys/dev/bnxt/bnxt_en/bnxt_ulp.h b/sys/dev/bnxt/bnxt_en/bnxt_ulp.h
new file mode 100644
index 000000000000..0108293046d7
--- /dev/null
+++ b/sys/dev/bnxt/bnxt_en/bnxt_ulp.h
@@ -0,0 +1,161 @@
+/*-
+ * Broadcom NetXtreme-C/E network driver.
+ *
+ * Copyright (c) 2024 Broadcom, All Rights Reserved.
+ * The term Broadcom refers to Broadcom Limited and/or its subsidiaries
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef BNXT_ULP_H
+#define BNXT_ULP_H
+
+#include <linux/rcupdate.h>
+#include "bnxt.h"
+
+#define BNXT_ROCE_ULP	0
+#define BNXT_OTHER_ULP	1
+#define BNXT_MAX_ULP	2
+
+#define BNXT_MIN_ROCE_CP_RINGS	2
+#define BNXT_MIN_ROCE_STAT_CTXS	1
+
+struct hwrm_async_event_cmpl;
+struct bnxt_softc;
+struct bnxt_bar_info;
+
+struct bnxt_msix_entry {
+	uint32_t	vector;
+	uint32_t	ring_idx;
+	uint32_t	db_offset;
+};
+
+struct bnxt_ulp_ops {
+	void (*ulp_async_notifier)(void *, struct hwrm_async_event_cmpl *);
+	void (*ulp_stop)(void *);
+	void (*ulp_start)(void *);
+	void (*ulp_sriov_config)(void *, int);
+	void (*ulp_shutdown)(void *);
+	void (*ulp_irq_stop)(void *);
+	void (*ulp_irq_restart)(void *, struct bnxt_msix_entry *);
+};
+
+struct bnxt_fw_msg {
+	void	*msg;
+	int	msg_len;
+	void	*resp;
+	int	resp_max_len;
+	int	timeout;
+};
+
+struct bnxt_ulp {
+	void		*handle;
+	struct bnxt_ulp_ops __rcu *ulp_ops;
+	unsigned long	*async_events_bmap;
+	u16		max_async_event_id;
+	u16		msix_requested;
+	u16		msix_base;
+	atomic_t	ref_count;
+};
+
+struct bnxt_en_dev {
+	struct ifnet *net;
+	struct pci_dev *pdev;
+	struct bnxt_softc *softc;
+	u32 flags;
+	#define BNXT_EN_FLAG_ROCEV1_CAP		0x1
+	#define BNXT_EN_FLAG_ROCEV2_CAP		0x2
+	#define BNXT_EN_FLAG_ROCE_CAP		(BNXT_EN_FLAG_ROCEV1_CAP | \
+						 BNXT_EN_FLAG_ROCEV2_CAP)
+	#define BNXT_EN_FLAG_MSIX_REQUESTED	0x4
+	#define BNXT_EN_FLAG_ULP_STOPPED	0x8
+	#define BNXT_EN_FLAG_ASYM_Q		0x10
+	#define BNXT_EN_FLAG_MULTI_HOST		0x20
+#define BNXT_EN_ASYM_Q(edev)		((edev)->flags & BNXT_EN_FLAG_ASYM_Q)
+#define BNXT_EN_MH(edev)		((edev)->flags & BNXT_EN_FLAG_MULTI_HOST)
+	const struct bnxt_en_ops	*en_ops;
+	struct bnxt_ulp			ulp_tbl[BNXT_MAX_ULP];
+	int				l2_db_size;	/* Doorbell BAR size in
+							 * bytes mapped by L2
+							 * driver.
+							 */
+	int				l2_db_size_nc;	/* Doorbell BAR size in
+							 * bytes mapped as non-
+							 * cacheable.
+							 */
+	u32				ulp_version;	/* bnxt_re checks the
+							 * ulp_version is correct
+							 * to ensure compatibility
+							 * with bnxt_en.
+							 */
+	#define BNXT_ULP_VERSION	0x695a0008	/* Change this when any interface
+							 * structure or API changes
+							 * between bnxt_en and bnxt_re.
+							 */
+	unsigned long			en_state;
+	void __iomem			*bar0;
+	u16				hw_ring_stats_size;
+	u16				pf_port_id;
+	u8				port_partition_type;
+#define BNXT_EN_NPAR(edev)		((edev)->port_partition_type)
+	u8				port_count;
+	struct bnxt_dbr			*en_dbr;
+	struct bnxt_bar_info		hwrm_bar;
+	u32				espeed;
+};
+
+struct bnxt_en_ops {
+	int (*bnxt_register_device)(struct bnxt_en_dev *, int,
+				    struct bnxt_ulp_ops *, void *);
+	int (*bnxt_unregister_device)(struct bnxt_en_dev *, int);
+	int (*bnxt_request_msix)(struct bnxt_en_dev *, int,
+				 struct bnxt_msix_entry *, int);
+	int (*bnxt_free_msix)(struct bnxt_en_dev *, int);
+	int (*bnxt_send_fw_msg)(struct bnxt_en_dev *, int,
+				struct bnxt_fw_msg *);
+	int (*bnxt_register_fw_async_events)(struct bnxt_en_dev *, int,
+					     unsigned long *, u16);
+	int (*bnxt_dbr_complete)(struct bnxt_en_dev *, int, u32);
+};
+
+static inline bool bnxt_ulp_registered(struct bnxt_en_dev *edev, int ulp_id)
+{
+	if (edev && rcu_access_pointer(edev->ulp_tbl[ulp_id].ulp_ops))
+		return true;
+	return false;
+}
+
+int bnxt_get_ulp_msix_num(struct bnxt_softc *bp);
+int bnxt_get_ulp_msix_base(struct bnxt_softc *bp);
+int bnxt_get_ulp_stat_ctxs(struct bnxt_softc *bp);
+void bnxt_ulp_stop(struct bnxt_softc *bp);
+void bnxt_ulp_start(struct bnxt_softc *bp, int err);
+void bnxt_ulp_sriov_cfg(struct bnxt_softc *bp, int num_vfs);
+void bnxt_ulp_shutdown(struct bnxt_softc *bp);
+void bnxt_ulp_irq_stop(struct bnxt_softc *bp);
+void bnxt_ulp_irq_restart(struct bnxt_softc *bp, int err);
+void bnxt_ulp_async_events(struct bnxt_softc *bp, struct hwrm_async_event_cmpl *cmpl);
+struct bnxt_en_dev *bnxt_ulp_probe(struct net_device *dev);
+void bnxt_aux_dev_release(struct device *dev);
+int bnxt_rdma_aux_device_add(struct bnxt_softc *bp);
+int bnxt_rdma_aux_device_del(struct bnxt_softc *bp);
+#endif
diff --git a/sys/dev/bnxt/convert_hsi.pl b/sys/dev/bnxt/bnxt_en/convert_hsi.pl
similarity index 100%
rename from sys/dev/bnxt/convert_hsi.pl
rename to sys/dev/bnxt/bnxt_en/convert_hsi.pl
diff --git a/sys/dev/bnxt/hsi_struct_def.h b/sys/dev/bnxt/bnxt_en/hsi_struct_def.h
similarity index 65%
rename from sys/dev/bnxt/hsi_struct_def.h
rename to sys/dev/bnxt/bnxt_en/hsi_struct_def.h
index 576e1e9a7ed8..baecfc8f659c 100644
--- a/sys/dev/bnxt/hsi_struct_def.h
+++ b/sys/dev/bnxt/bnxt_en/hsi_struct_def.h
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright (c) 2016 Broadcom, All Rights Reserved.
+ *   Copyright (c) 2024 Broadcom, All Rights Reserved.
  *   The term Broadcom refers to Broadcom Limited and/or its subsidiaries
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -28,8 +28,10 @@
  */
 
 #include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
 /*
- * Copyright(c) 2001-2021, Broadcom. All rights reserved. The
+ * Copyright(c) 2001-2024, Broadcom. All rights reserved. The
  * term Broadcom refers to Broadcom Inc. and/or its subsidiaries.
  * Proprietary and Confidential Information.
  *
@@ -40,8 +42,12 @@
  * DO NOT MODIFY!!! This file is automatically generated.
  */
 
-#ifndef _HSI_STRUCT_DEF_EXTERNAL_H_
-#define _HSI_STRUCT_DEF_EXTERNAL_H_
+#ifndef _HSI_STRUCT_DEF_H_
+#define _HSI_STRUCT_DEF_H_
+
+#if defined(HAVE_STDINT_H)
+#include <stdint.h>
+#endif
 
 /* This is the HWRM command header. */
 /* hwrm_cmd_hdr (size:128b/16B) */
@@ -74,7 +80,7 @@ typedef struct hwrm_cmd_hdr {
 	 * physical address (HPA) or a guest physical address (GPA) and must
 	 * point to a physically contiguous block of memory.
 	 */
-	uint64_t	resp_addr;
+	uint64_t        resp_addr;
 } hwrm_cmd_hdr_t, *phwrm_cmd_hdr_t;
 
 /* This is the HWRM response header. */
@@ -109,6 +115,10 @@ typedef struct hwrm_resp_hdr {
 #define TLV_TYPE_QUERY_ROCE_CC_GEN1		UINT32_C(0x4)
 /* RoCE slow path command to modify CC Gen1 support. */
 #define TLV_TYPE_MODIFY_ROCE_CC_GEN1		UINT32_C(0x5)
+/* RoCE slow path command to query CC Gen2 support. */
+#define TLV_TYPE_QUERY_ROCE_CC_GEN2		UINT32_C(0x6)
+/* RoCE slow path command to modify CC Gen2 support. */
+#define TLV_TYPE_MODIFY_ROCE_CC_GEN2		UINT32_C(0x7)
 /* Engine CKV - The Alias key EC curve and ECC public key information. */
 #define TLV_TYPE_ENGINE_CKV_ALIAS_ECC_PUBLIC_KEY UINT32_C(0x8001)
 /* Engine CKV - Initialization vector. */
@@ -191,14 +201,14 @@ typedef struct tlv {
 
 typedef struct input {
 	/*
-	 * This value indicates what type of request this is.  The format
+	 * This value indicates what type of request this is. The format
 	 * for the rest of the command is determined by this field.
 	 */
 	uint16_t	req_type;
 	/*
 	 * This value indicates the what completion ring the request will
-	 * be optionally completed on.  If the value is -1, then no
-	 * CR completion will be generated.  Any other value must be a
+	 * be optionally completed on. If the value is -1, then no
+	 * CR completion will be generated. Any other value must be a
 	 * valid CR ring_id value for this function.
 	 */
 	uint16_t	cmpl_ring;
@@ -214,7 +224,7 @@ typedef struct input {
 	uint16_t	target_id;
 	/*
 	 * This is the host address where the response will be written
-	 * when the request is complete.  This area must be 16B aligned
+	 * when the request is complete. This area must be 16B aligned
 	 * and must be cleared to zero before the request is made.
 	 */
 	uint64_t	resp_addr;
@@ -236,7 +246,7 @@ typedef struct output {
 	/* This field provides original sequence number of the command. */
 	uint16_t	seq_id;
 	/*
-	 * This field is the length of the response in bytes.  The
+	 * This field is the length of the response in bytes. The
 	 * last byte of the response is a valid flag that will read
 	 * as '1' when the command has been completely written to
 	 * memory.
@@ -372,6 +382,14 @@ typedef struct hwrm_short_input {
 	((x) == 0x85 ? "HWRM_QUEUE_VLANPRI2PRI_CFG": \
 	((x) == 0x86 ? "HWRM_QUEUE_GLOBAL_CFG": \
 	((x) == 0x87 ? "HWRM_QUEUE_GLOBAL_QCFG": \
+	((x) == 0x88 ? "HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG": \
+	((x) == 0x89 ? "HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG": \
+	((x) == 0x8a ? "HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG": \
+	((x) == 0x8b ? "HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG": \
+	((x) == 0x8c ? "HWRM_QUEUE_QCAPS": \
+	((x) == 0x8d ? "HWRM_QUEUE_ADPTV_QOS_RX_TUNING_QCFG": \
+	((x) == 0x8e ? "HWRM_QUEUE_ADPTV_QOS_RX_TUNING_CFG": \
+	((x) == 0x8f ? "HWRM_QUEUE_ADPTV_QOS_TX_TUNING_QCFG": \
 	((x) == 0x90 ? "HWRM_CFA_L2_FILTER_ALLOC": \
 	((x) == 0x91 ? "HWRM_CFA_L2_FILTER_FREE": \
 	((x) == 0x92 ? "HWRM_CFA_L2_FILTER_CFG": \
@@ -390,6 +408,7 @@ typedef struct hwrm_short_input {
 	((x) == 0xa0 ? "HWRM_TUNNEL_DST_PORT_QUERY": \
 	((x) == 0xa1 ? "HWRM_TUNNEL_DST_PORT_ALLOC": \
 	((x) == 0xa2 ? "HWRM_TUNNEL_DST_PORT_FREE": \
+	((x) == 0xa3 ? "HWRM_QUEUE_ADPTV_QOS_TX_TUNING_CFG": \
 	((x) == 0xaf ? "HWRM_STAT_CTX_ENG_QUERY": \
 	((x) == 0xb0 ? "HWRM_STAT_CTX_ALLOC": \
 	((x) == 0xb1 ? "HWRM_STAT_CTX_FREE": \
@@ -433,6 +452,11 @@ typedef struct hwrm_short_input {
 	((x) == 0xd7 ? "HWRM_PORT_SFP_SIDEBAND_QCFG": \
 	((x) == 0xd8 ? "HWRM_FW_STATE_UNQUIESCE": \
 	((x) == 0xd9 ? "HWRM_PORT_DSC_DUMP": \
+	((x) == 0xda ? "HWRM_PORT_EP_TX_QCFG": \
+	((x) == 0xdb ? "HWRM_PORT_EP_TX_CFG": \
+	((x) == 0xdc ? "HWRM_PORT_CFG": \
+	((x) == 0xdd ? "HWRM_PORT_QCFG": \
+	((x) == 0xdf ? "HWRM_PORT_MAC_QCAPS": \
 	((x) == 0xe0 ? "HWRM_TEMP_MONITOR_QUERY": \
 	((x) == 0xe1 ? "HWRM_REG_POWER_QUERY": \
 	((x) == 0xe2 ? "HWRM_CORE_FREQUENCY_QUERY": \
@@ -450,7 +474,7 @@ typedef struct hwrm_short_input {
 	((x) == 0xfa ? "HWRM_CFA_METER_INSTANCE_CFG": \
 	((x) == 0xfd ? "HWRM_CFA_VFR_ALLOC": \
 	((x) == 0xfe ? "HWRM_CFA_VFR_FREE": \
-	"Unknown decode" )))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) : \
+	"Unknown decode" )))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) : \
 	(((x) < 0x180) ? \
 	((x) == 0x100 ? "HWRM_CFA_VF_PAIR_ALLOC": \
 	((x) == 0x101 ? "HWRM_CFA_VF_PAIR_FREE": \
@@ -492,6 +516,9 @@ typedef struct hwrm_short_input {
 	((x) == 0x125 ? "HWRM_CFA_TFLIB": \
 	((x) == 0x126 ? "HWRM_CFA_LAG_GROUP_MEMBER_RGTR": \
 	((x) == 0x127 ? "HWRM_CFA_LAG_GROUP_MEMBER_UNRGTR": \
+	((x) == 0x128 ? "HWRM_CFA_TLS_FILTER_ALLOC": \
+	((x) == 0x129 ? "HWRM_CFA_TLS_FILTER_FREE": \
+	((x) == 0x12a ? "HWRM_CFA_RELEASE_AFM_FUNC": \
 	((x) == 0x12e ? "HWRM_ENGINE_CKV_STATUS": \
 	((x) == 0x12f ? "HWRM_ENGINE_CKV_CKEK_ADD": \
 	((x) == 0x130 ? "HWRM_ENGINE_CKV_CKEK_DELETE": \
@@ -531,7 +558,7 @@ typedef struct hwrm_short_input {
 	((x) == 0x163 ? "HWRM_ENGINE_NQ_FREE": \
 	((x) == 0x164 ? "HWRM_ENGINE_ON_DIE_RQE_CREDITS": \
 	((x) == 0x165 ? "HWRM_ENGINE_FUNC_QCFG": \
-	"Unknown decode" ))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) : \
+	"Unknown decode" )))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) : \
 	(((x) < 0x200) ? \
 	((x) == 0x190 ? "HWRM_FUNC_RESOURCE_QCAPS": \
 	((x) == 0x191 ? "HWRM_FUNC_VF_RESOURCE_CFG": \
@@ -549,7 +576,27 @@ typedef struct hwrm_short_input {
 	((x) == 0x19d ? "HWRM_FUNC_PTP_PIN_CFG": \
 	((x) == 0x19e ? "HWRM_FUNC_PTP_CFG": \
 	((x) == 0x19f ? "HWRM_FUNC_PTP_TS_QUERY": \
-	"Unknown decode" )))))))))))))))) : \
+	((x) == 0x1a0 ? "HWRM_FUNC_PTP_EXT_CFG": \
+	((x) == 0x1a1 ? "HWRM_FUNC_PTP_EXT_QCFG": \
+	((x) == 0x1a2 ? "HWRM_FUNC_KEY_CTX_ALLOC": \
+	((x) == 0x1a3 ? "HWRM_FUNC_BACKING_STORE_CFG_V2": \
+	((x) == 0x1a4 ? "HWRM_FUNC_BACKING_STORE_QCFG_V2": \
+	((x) == 0x1a5 ? "HWRM_FUNC_DBR_PACING_CFG": \
+	((x) == 0x1a6 ? "HWRM_FUNC_DBR_PACING_QCFG": \
+	((x) == 0x1a7 ? "HWRM_FUNC_DBR_PACING_BROADCAST_EVENT": \
+	((x) == 0x1a8 ? "HWRM_FUNC_BACKING_STORE_QCAPS_V2": \
+	((x) == 0x1a9 ? "HWRM_FUNC_DBR_PACING_NQLIST_QUERY": \
+	((x) == 0x1aa ? "HWRM_FUNC_DBR_RECOVERY_COMPLETED": \
+	((x) == 0x1ab ? "HWRM_FUNC_SYNCE_CFG": \
+	((x) == 0x1ac ? "HWRM_FUNC_SYNCE_QCFG": \
+	((x) == 0x1ad ? "HWRM_FUNC_KEY_CTX_FREE": \
+	((x) == 0x1ae ? "HWRM_FUNC_LAG_MODE_CFG": \
+	((x) == 0x1af ? "HWRM_FUNC_LAG_MODE_QCFG": \
+	((x) == 0x1b0 ? "HWRM_FUNC_LAG_CREATE": \
+	((x) == 0x1b1 ? "HWRM_FUNC_LAG_UPDATE": \
+	((x) == 0x1b2 ? "HWRM_FUNC_LAG_FREE": \
+	((x) == 0x1b3 ? "HWRM_FUNC_LAG_QCFG": \
+	"Unknown decode" )))))))))))))))))))))))))))))))))))) : \
 	(((x) < 0x280) ? \
 	((x) == 0x200 ? "HWRM_SELFTEST_QLIST": \
 	((x) == 0x201 ? "HWRM_SELFTEST_EXEC": \
@@ -565,15 +612,33 @@ typedef struct hwrm_short_input {
 	((x) == 0x20b ? "HWRM_MFG_FRU_EEPROM_READ": \
 	((x) == 0x20c ? "HWRM_MFG_SOC_IMAGE": \
 	((x) == 0x20d ? "HWRM_MFG_SOC_QSTATUS": \
-	((x) == 0x20e ? "HWRM_MFG_PARAM_SEEPROM_SYNC": \
-	((x) == 0x20f ? "HWRM_MFG_PARAM_SEEPROM_READ": \
-	((x) == 0x210 ? "HWRM_MFG_PARAM_SEEPROM_HEALTH": \
-	"Unknown decode" ))))))))))))))))) : \
+	((x) == 0x20e ? "HWRM_MFG_PARAM_CRITICAL_DATA_FINALIZE": \
+	((x) == 0x20f ? "HWRM_MFG_PARAM_CRITICAL_DATA_READ": \
+	((x) == 0x210 ? "HWRM_MFG_PARAM_CRITICAL_DATA_HEALTH": \
+	((x) == 0x211 ? "HWRM_MFG_PRVSN_EXPORT_CSR": \
+	((x) == 0x212 ? "HWRM_MFG_PRVSN_IMPORT_CERT": \
+	((x) == 0x213 ? "HWRM_MFG_PRVSN_GET_STATE": \
+	((x) == 0x214 ? "HWRM_MFG_GET_NVM_MEASUREMENT": \
+	((x) == 0x215 ? "HWRM_MFG_PSOC_QSTATUS": \
+	((x) == 0x216 ? "HWRM_MFG_SELFTEST_QLIST": \
+	((x) == 0x217 ? "HWRM_MFG_SELFTEST_EXEC": \
+	((x) == 0x218 ? "HWRM_STAT_GENERIC_QSTATS": \
+	((x) == 0x219 ? "HWRM_MFG_PRVSN_EXPORT_CERT": \
+	((x) == 0x21a ? "HWRM_STAT_DB_ERROR_QSTATS": \
+	((x) == 0x258 ? "HWRM_UDCC_QCAPS": \
+	((x) == 0x259 ? "HWRM_UDCC_CFG": \
+	((x) == 0x25a ? "HWRM_UDCC_QCFG": \
+	((x) == 0x25b ? "HWRM_UDCC_SESSION_CFG": \
+	((x) == 0x25c ? "HWRM_UDCC_SESSION_QCFG": \
+	((x) == 0x25d ? "HWRM_UDCC_SESSION_QUERY": \
+	((x) == 0x25e ? "HWRM_UDCC_COMP_CFG": \
+	((x) == 0x25f ? "HWRM_UDCC_COMP_QCFG": \
+	((x) == 0x260 ? "HWRM_UDCC_COMP_QUERY": \
+	"Unknown decode" )))))))))))))))))))))))))))))))))))) : \
 	(((x) < 0x300) ? \
 	((x) == 0x2bc ? "HWRM_TF": \
 	((x) == 0x2bd ? "HWRM_TF_VERSION_GET": \
 	((x) == 0x2c6 ? "HWRM_TF_SESSION_OPEN": \
-	((x) == 0x2c7 ? "HWRM_TF_SESSION_ATTACH": \
 	((x) == 0x2c8 ? "HWRM_TF_SESSION_REGISTER": \
 	((x) == 0x2c9 ? "HWRM_TF_SESSION_UNREGISTER": \
 	((x) == 0x2ca ? "HWRM_TF_SESSION_CLOSE": \
@@ -583,17 +648,11 @@ typedef struct hwrm_short_input {
 	((x) == 0x2ce ? "HWRM_TF_SESSION_RESC_FREE": \
 	((x) == 0x2cf ? "HWRM_TF_SESSION_RESC_FLUSH": \
 	((x) == 0x2d0 ? "HWRM_TF_SESSION_RESC_INFO": \
+	((x) == 0x2d1 ? "HWRM_TF_SESSION_HOTUP_STATE_SET": \
+	((x) == 0x2d2 ? "HWRM_TF_SESSION_HOTUP_STATE_GET": \
 	((x) == 0x2da ? "HWRM_TF_TBL_TYPE_GET": \
 	((x) == 0x2db ? "HWRM_TF_TBL_TYPE_SET": \
 	((x) == 0x2dc ? "HWRM_TF_TBL_TYPE_BULK_GET": \
-	((x) == 0x2e2 ? "HWRM_TF_CTXT_MEM_ALLOC": \
-	((x) == 0x2e3 ? "HWRM_TF_CTXT_MEM_FREE": \
-	((x) == 0x2e4 ? "HWRM_TF_CTXT_MEM_RGTR": \
-	((x) == 0x2e5 ? "HWRM_TF_CTXT_MEM_UNRGTR": \
-	((x) == 0x2e6 ? "HWRM_TF_EXT_EM_QCAPS": \
-	((x) == 0x2e7 ? "HWRM_TF_EXT_EM_OP": \
-	((x) == 0x2e8 ? "HWRM_TF_EXT_EM_CFG": \
-	((x) == 0x2e9 ? "HWRM_TF_EXT_EM_QCFG": \
 	((x) == 0x2ea ? "HWRM_TF_EM_INSERT": \
 	((x) == 0x2eb ? "HWRM_TF_EM_DELETE": \
 	((x) == 0x2ec ? "HWRM_TF_EM_HASH_INSERT": \
@@ -606,11 +665,51 @@ typedef struct hwrm_short_input {
 	((x) == 0x2fd ? "HWRM_TF_GLOBAL_CFG_GET": \
 	((x) == 0x2fe ? "HWRM_TF_IF_TBL_SET": \
 	((x) == 0x2ff ? "HWRM_TF_IF_TBL_GET": \
-	"Unknown decode" )))))))))))))))))))))))))))))))))))) : \
+	"Unknown decode" ))))))))))))))))))))))))))))) : \
+	(((x) < 0x380) ? \
+	((x) == 0x300 ? "HWRM_TF_RESC_USAGE_SET": \
+	((x) == 0x301 ? "HWRM_TF_RESC_USAGE_QUERY": \
+	((x) == 0x302 ? "HWRM_TF_TBL_TYPE_ALLOC": \
+	((x) == 0x303 ? "HWRM_TF_TBL_TYPE_FREE": \
+	"Unknown decode" )))) : \
+	(((x) < 0x400) ? \
+	((x) == 0x380 ? "HWRM_TFC_TBL_SCOPE_QCAPS": \
+	((x) == 0x381 ? "HWRM_TFC_TBL_SCOPE_ID_ALLOC": \
+	((x) == 0x382 ? "HWRM_TFC_TBL_SCOPE_CONFIG": \
+	((x) == 0x383 ? "HWRM_TFC_TBL_SCOPE_DECONFIG": \
+	((x) == 0x384 ? "HWRM_TFC_TBL_SCOPE_FID_ADD": \
+	((x) == 0x385 ? "HWRM_TFC_TBL_SCOPE_FID_REM": \
+	((x) == 0x386 ? "HWRM_TFC_TBL_SCOPE_POOL_ALLOC": \
+	((x) == 0x387 ? "HWRM_TFC_TBL_SCOPE_POOL_FREE": \
+	((x) == 0x388 ? "HWRM_TFC_SESSION_ID_ALLOC": \
+	((x) == 0x389 ? "HWRM_TFC_SESSION_FID_ADD": \
+	((x) == 0x38a ? "HWRM_TFC_SESSION_FID_REM": \
+	((x) == 0x38b ? "HWRM_TFC_IDENT_ALLOC": \
+	((x) == 0x38c ? "HWRM_TFC_IDENT_FREE": \
+	((x) == 0x38d ? "HWRM_TFC_IDX_TBL_ALLOC": \
+	((x) == 0x38e ? "HWRM_TFC_IDX_TBL_ALLOC_SET": \
+	((x) == 0x38f ? "HWRM_TFC_IDX_TBL_SET": \
+	((x) == 0x390 ? "HWRM_TFC_IDX_TBL_GET": \
+	((x) == 0x391 ? "HWRM_TFC_IDX_TBL_FREE": \
+	((x) == 0x392 ? "HWRM_TFC_GLOBAL_ID_ALLOC": \
+	((x) == 0x393 ? "HWRM_TFC_TCAM_SET": \
+	((x) == 0x394 ? "HWRM_TFC_TCAM_GET": \
+	((x) == 0x395 ? "HWRM_TFC_TCAM_ALLOC": \
+	((x) == 0x396 ? "HWRM_TFC_TCAM_ALLOC_SET": \
+	((x) == 0x397 ? "HWRM_TFC_TCAM_FREE": \
+	((x) == 0x398 ? "HWRM_TFC_IF_TBL_SET": \
+	((x) == 0x399 ? "HWRM_TFC_IF_TBL_GET": \
+	((x) == 0x39a ? "HWRM_TFC_TBL_SCOPE_CONFIG_GET": \
+	((x) == 0x39b ? "HWRM_TFC_RESC_USAGE_QUERY": \
+	((x) == 0x39c ? "HWRM_QUEUE_PFCWD_TIMEOUT_QCAPS": \
+	((x) == 0x39d ? "HWRM_QUEUE_PFCWD_TIMEOUT_CFG": \
+	((x) == 0x39e ? "HWRM_QUEUE_PFCWD_TIMEOUT_QCFG": \
+	"Unknown decode" ))))))))))))))))))))))))))))))) : \
 	(((x) < 0x480) ? \
 	((x) == 0x400 ? "HWRM_SV": \
 	"Unknown decode" ) : \
 	(((x) < 0xff80) ? \
+	((x) == 0xff0f ? "HWRM_DBG_LOG_BUFFER_FLUSH": \
 	((x) == 0xff10 ? "HWRM_DBG_READ_DIRECT": \
 	((x) == 0xff11 ? "HWRM_DBG_READ_INDIRECT": \
 	((x) == 0xff12 ? "HWRM_DBG_WRITE_DIRECT": \
@@ -639,8 +738,11 @@ typedef struct hwrm_short_input {
 	((x) == 0xff29 ? "HWRM_DBG_USEQ_RUN": \
 	((x) == 0xff2a ? "HWRM_DBG_USEQ_DELIVERY_REQ": \
 	((x) == 0xff2b ? "HWRM_DBG_USEQ_RESP_HDR": \
-	"Unknown decode" )))))))))))))))))))))))))))) : \
+	"Unknown decode" ))))))))))))))))))))))))))))) : \
 	(((x) <= 0xffff) ? \
+	((x) == 0xffea ? "HWRM_NVM_GET_VPD_FIELD_INFO": \
+	((x) == 0xffeb ? "HWRM_NVM_SET_VPD_FIELD_INFO": \
+	((x) == 0xffec ? "HWRM_NVM_DEFRAG": \
 	((x) == 0xffed ? "HWRM_NVM_REQ_ARBITRATION": \
 	((x) == 0xffee ? "HWRM_NVM_FACTORY_DEFAULTS": \
 	((x) == 0xffef ? "HWRM_NVM_VALIDATE_OPTION": \
@@ -660,8 +762,8 @@ typedef struct hwrm_short_input {
 	((x) == 0xfffd ? "HWRM_NVM_READ": \
 	((x) == 0xfffe ? "HWRM_NVM_WRITE": \
 	((x) == 0xffff ? "HWRM_NVM_RAW_WRITE_BLK": \
-	"Unknown decode" ))))))))))))))))))) : \
-	"Unknown decode" )))))))))
+	"Unknown decode" )))))))))))))))))))))) : \
+	"Unknown decode" )))))))))))
 
 
 /*
@@ -790,6 +892,14 @@ typedef struct cmd_nums {
 	#define HWRM_QUEUE_VLANPRI2PRI_CFG		UINT32_C(0x85)
 	#define HWRM_QUEUE_GLOBAL_CFG			UINT32_C(0x86)
 	#define HWRM_QUEUE_GLOBAL_QCFG			UINT32_C(0x87)
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG	UINT32_C(0x88)
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG	UINT32_C(0x89)
+	#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG	UINT32_C(0x8a)
+	#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG	UINT32_C(0x8b)
+	#define HWRM_QUEUE_QCAPS			UINT32_C(0x8c)
+	#define HWRM_QUEUE_ADPTV_QOS_RX_TUNING_QCFG	UINT32_C(0x8d)
+	#define HWRM_QUEUE_ADPTV_QOS_RX_TUNING_CFG	UINT32_C(0x8e)
+	#define HWRM_QUEUE_ADPTV_QOS_TX_TUNING_QCFG	UINT32_C(0x8f)
 	#define HWRM_CFA_L2_FILTER_ALLOC		UINT32_C(0x90)
 	#define HWRM_CFA_L2_FILTER_FREE		UINT32_C(0x91)
 	#define HWRM_CFA_L2_FILTER_CFG			UINT32_C(0x92)
@@ -813,6 +923,7 @@ typedef struct cmd_nums {
 	#define HWRM_TUNNEL_DST_PORT_QUERY		UINT32_C(0xa0)
 	#define HWRM_TUNNEL_DST_PORT_ALLOC		UINT32_C(0xa1)
 	#define HWRM_TUNNEL_DST_PORT_FREE		UINT32_C(0xa2)
+	#define HWRM_QUEUE_ADPTV_QOS_TX_TUNING_CFG	UINT32_C(0xa3)
 	#define HWRM_STAT_CTX_ENG_QUERY		UINT32_C(0xaf)
 	#define HWRM_STAT_CTX_ALLOC			UINT32_C(0xb0)
 	#define HWRM_STAT_CTX_FREE			UINT32_C(0xb1)
@@ -864,6 +975,12 @@ typedef struct cmd_nums {
 	#define HWRM_FW_STATE_UNQUIESCE		UINT32_C(0xd8)
 	/* Tells the fw to collect dsc dump on a given port and lane. */
 	#define HWRM_PORT_DSC_DUMP			UINT32_C(0xd9)
+	#define HWRM_PORT_EP_TX_QCFG			UINT32_C(0xda)
+	#define HWRM_PORT_EP_TX_CFG			UINT32_C(0xdb)
+	#define HWRM_PORT_CFG				UINT32_C(0xdc)
+	#define HWRM_PORT_QCFG				UINT32_C(0xdd)
+	/* Queries MAC capabilities for the specified port */
+	#define HWRM_PORT_MAC_QCAPS			UINT32_C(0xdf)
 	#define HWRM_TEMP_MONITOR_QUERY		UINT32_C(0xe0)
 	#define HWRM_REG_POWER_QUERY			UINT32_C(0xe1)
 	#define HWRM_CORE_FREQUENCY_QUERY		UINT32_C(0xe2)
@@ -902,9 +1019,7 @@ typedef struct cmd_nums {
 	#define HWRM_CFA_FLOW_FREE			UINT32_C(0x104)
 	/* Experimental */
 	#define HWRM_CFA_FLOW_FLUSH			UINT32_C(0x105)
-	/* Experimental */
 	#define HWRM_CFA_FLOW_STATS			UINT32_C(0x106)
-	/* Experimental */
 	#define HWRM_CFA_FLOW_INFO			UINT32_C(0x107)
 	/* Experimental */
 	#define HWRM_CFA_DECAP_FILTER_ALLOC		UINT32_C(0x108)
@@ -965,7 +1080,16 @@ typedef struct cmd_nums {
 	#define HWRM_CFA_LAG_GROUP_MEMBER_RGTR		UINT32_C(0x126)
 	/* Experimental */
 	#define HWRM_CFA_LAG_GROUP_MEMBER_UNRGTR	UINT32_C(0x127)
-	/* Engine CKV - Get the current allocation status of keys provisioned in the key vault. */
+	/* Experimental */
+	#define HWRM_CFA_TLS_FILTER_ALLOC		UINT32_C(0x128)
+	/* Experimental */
+	#define HWRM_CFA_TLS_FILTER_FREE		UINT32_C(0x129)
+	/* Release an AFM function for TF control */
+	#define HWRM_CFA_RELEASE_AFM_FUNC		UINT32_C(0x12a)
+	/*
+	 * Engine CKV - Get the current allocation status of keys provisioned in
+	 * the key vault.
+	 */
 	#define HWRM_ENGINE_CKV_STATUS			UINT32_C(0x12e)
 	/* Engine CKV - Add a new CKEK used to encrypt keys. */
 	#define HWRM_ENGINE_CKV_CKEK_ADD		UINT32_C(0x12f)
@@ -1025,7 +1149,10 @@ typedef struct cmd_nums {
 	#define HWRM_ENGINE_STATS_CLEAR		UINT32_C(0x156)
 	/* Engine - Query the statistics accumulator for an Engine. */
 	#define HWRM_ENGINE_STATS_QUERY		UINT32_C(0x157)
-	/* Engine - Query statistics counters for continuous errors from all CDDIP Engines. */
+	/*
+	 * Engine - Query statistics counters for continuous errors from all CDDIP
+	 * Engines.
+	 */
 	#define HWRM_ENGINE_STATS_QUERY_CONTINUOUS_ERROR  UINT32_C(0x158)
 	/* Engine - Allocate an Engine RQ. */
 	#define HWRM_ENGINE_RQ_ALLOC			UINT32_C(0x15e)
@@ -1075,6 +1202,52 @@ typedef struct cmd_nums {
 	#define HWRM_FUNC_PTP_CFG			UINT32_C(0x19e)
 	/* PTP - Queries for PHC timestamps. */
 	#define HWRM_FUNC_PTP_TS_QUERY			UINT32_C(0x19f)
+	/* PTP - Extended PTP configuration. */
+	#define HWRM_FUNC_PTP_EXT_CFG			UINT32_C(0x1a0)
+	/* PTP - Query extended PTP configuration. */
+	#define HWRM_FUNC_PTP_EXT_QCFG			UINT32_C(0x1a1)
+	/* The command is used to allocate KTLS or QUIC key contexts. */
+	#define HWRM_FUNC_KEY_CTX_ALLOC		UINT32_C(0x1a2)
+	/* The is the new API to configure backing stores. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2		UINT32_C(0x1a3)
+	/* The is the new API to query backing store configurations. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2	UINT32_C(0x1a4)
+	/* To support doorbell pacing configuration. */
+	#define HWRM_FUNC_DBR_PACING_CFG		UINT32_C(0x1a5)
+	/* To query doorbell pacing configuration. */
+	#define HWRM_FUNC_DBR_PACING_QCFG		UINT32_C(0x1a6)
+	/*
+	 * To broadcast the doorbell event to the drivers to
+	 * initiate pacing of doorbells.
+	 */
+	#define HWRM_FUNC_DBR_PACING_BROADCAST_EVENT	UINT32_C(0x1a7)
+	/* The is the new API to query backing store capabilities. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2	UINT32_C(0x1a8)
+	/* To query doorbell pacing NQ id list configuration. */
+	#define HWRM_FUNC_DBR_PACING_NQLIST_QUERY	UINT32_C(0x1a9)
+	/*
+	 * To notify the firmware that recovery cycle has been
+	 * completed by host function drivers.
+	 */
+	#define HWRM_FUNC_DBR_RECOVERY_COMPLETED	UINT32_C(0x1aa)
+	/* Configures SyncE configurations. */
+	#define HWRM_FUNC_SYNCE_CFG			UINT32_C(0x1ab)
+	/* Queries SyncE configurations. */
+	#define HWRM_FUNC_SYNCE_QCFG			UINT32_C(0x1ac)
+	/* The command is used to deallocate KTLS or QUIC key contexts. */
+	#define HWRM_FUNC_KEY_CTX_FREE			UINT32_C(0x1ad)
+	/* The command is used to configure link aggr group mode. */
+	#define HWRM_FUNC_LAG_MODE_CFG			UINT32_C(0x1ae)
+	/* The command is used to query link aggr group mode. */
+	#define HWRM_FUNC_LAG_MODE_QCFG		UINT32_C(0x1af)
+	/* The command is used to create a link aggr group. */
+	#define HWRM_FUNC_LAG_CREATE			UINT32_C(0x1b0)
+	/* The command is used to update a link aggr group. */
+	#define HWRM_FUNC_LAG_UPDATE			UINT32_C(0x1b1)
+	/* The command is used to free a link aggr group. */
+	#define HWRM_FUNC_LAG_FREE			UINT32_C(0x1b2)
+	/* The command is used to query a link aggr group. */
+	#define HWRM_FUNC_LAG_QCFG			UINT32_C(0x1b3)
 	/* Experimental */
 	#define HWRM_SELFTEST_QLIST			UINT32_C(0x200)
 	/* Experimental */
@@ -1106,12 +1279,77 @@ typedef struct cmd_nums {
 	#define HWRM_MFG_SOC_IMAGE			UINT32_C(0x20c)
 	/* Retrieves the SoC status and image provisioning information */
 	#define HWRM_MFG_SOC_QSTATUS			UINT32_C(0x20d)
-	/* Tells the fw to program the seeprom memory */
-	#define HWRM_MFG_PARAM_SEEPROM_SYNC		UINT32_C(0x20e)
-	/* Tells the fw to read the seeprom memory */
-	#define HWRM_MFG_PARAM_SEEPROM_READ		UINT32_C(0x20f)
-	/* Tells the fw to get the health of seeprom data */
-	#define HWRM_MFG_PARAM_SEEPROM_HEALTH		UINT32_C(0x210)
+	/* Tells the fw to finalize the critical data (store and lock it) */
+	#define HWRM_MFG_PARAM_CRITICAL_DATA_FINALIZE	UINT32_C(0x20e)
+	/* Tells the fw to read the critical data */
+	#define HWRM_MFG_PARAM_CRITICAL_DATA_READ	UINT32_C(0x20f)
+	/* Tells the fw to get the health of critical data */
+	#define HWRM_MFG_PARAM_CRITICAL_DATA_HEALTH	UINT32_C(0x210)
+	/*
+	 * The command is used for certificate provisioning to export a
+	 * Certificate Signing Request (CSR) from the device.
+	 */
+	#define HWRM_MFG_PRVSN_EXPORT_CSR		UINT32_C(0x211)
+	/*
+	 * The command is used for certificate provisioning to import a
+	 * CA-signed certificate chain to the device.
+	 */
+	#define HWRM_MFG_PRVSN_IMPORT_CERT		UINT32_C(0x212)
+	/*
+	 * The command is used for certificate provisioning to query the
+	 * provisioned state.
+	 */
+	#define HWRM_MFG_PRVSN_GET_STATE		UINT32_C(0x213)
+	/*
+	 * The command is used to get the hash of the NVM configuration that is
+	 * calculated during firmware boot.
+	 */
+	#define HWRM_MFG_GET_NVM_MEASUREMENT		UINT32_C(0x214)
+	/* Retrieves the PSOC status and provisioning information. */
+	#define HWRM_MFG_PSOC_QSTATUS			UINT32_C(0x215)
+	/*
+	 * This command allows manufacturing tool to determine which selftests
+	 * are available to be run.
+	 */
+	#define HWRM_MFG_SELFTEST_QLIST		UINT32_C(0x216)
+	/*
+	 * This command allows manufacturing tool to request which selftests
+	 * to run.
+	 */
+	#define HWRM_MFG_SELFTEST_EXEC			UINT32_C(0x217)
+	/* Queries the generic stats */
+	#define HWRM_STAT_GENERIC_QSTATS		UINT32_C(0x218)
+	/*
+	 * The command is used for certificate provisioning to export a
+	 * certificate chain from the device.
+	 */
+	#define HWRM_MFG_PRVSN_EXPORT_CERT		UINT32_C(0x219)
+	/* Query the statistics for doorbell drops due to various error conditions. */
+	#define HWRM_STAT_DB_ERROR_QSTATS		UINT32_C(0x21a)
+	/*
+	 * This command returns the capabilities related to User Defined
+	 * Congestion Control on a function.
+	 */
+	#define HWRM_UDCC_QCAPS			UINT32_C(0x258)
+	/* This command configures User Defined Congestion Control on a function. */
+	#define HWRM_UDCC_CFG				UINT32_C(0x259)
+	/*
+	 * This command queries the configuration of User Defined Congestion
+	 * Control on a function.
+	 */
+	#define HWRM_UDCC_QCFG				UINT32_C(0x25a)
+	/* This command configures an existing UDCC session. */
+	#define HWRM_UDCC_SESSION_CFG			UINT32_C(0x25b)
+	/* This command queries the configuration of a UDCC session. */
+	#define HWRM_UDCC_SESSION_QCFG			UINT32_C(0x25c)
+	/* This command queries the UDCC session. */
+	#define HWRM_UDCC_SESSION_QUERY		UINT32_C(0x25d)
+	/* This command configures the computation unit. */
+	#define HWRM_UDCC_COMP_CFG			UINT32_C(0x25e)
+	/* This command queries the configuration of the computation unit. */
+	#define HWRM_UDCC_COMP_QCFG			UINT32_C(0x25f)
+	/* This command queries the status and statistics of the computation unit. */
+	#define HWRM_UDCC_COMP_QUERY			UINT32_C(0x260)
 	/* Experimental */
 	#define HWRM_TF				UINT32_C(0x2bc)
 	/* Experimental */
@@ -1119,8 +1357,6 @@ typedef struct cmd_nums {
 	/* Experimental */
 	#define HWRM_TF_SESSION_OPEN			UINT32_C(0x2c6)
 	/* Experimental */
-	#define HWRM_TF_SESSION_ATTACH			UINT32_C(0x2c7)
-	/* Experimental */
 	#define HWRM_TF_SESSION_REGISTER		UINT32_C(0x2c8)
 	/* Experimental */
 	#define HWRM_TF_SESSION_UNREGISTER		UINT32_C(0x2c9)
@@ -1139,28 +1375,16 @@ typedef struct cmd_nums {
 	/* Experimental */
 	#define HWRM_TF_SESSION_RESC_INFO		UINT32_C(0x2d0)
 	/* Experimental */
+	#define HWRM_TF_SESSION_HOTUP_STATE_SET	UINT32_C(0x2d1)
+	/* Experimental */
+	#define HWRM_TF_SESSION_HOTUP_STATE_GET	UINT32_C(0x2d2)
+	/* Experimental */
 	#define HWRM_TF_TBL_TYPE_GET			UINT32_C(0x2da)
 	/* Experimental */
 	#define HWRM_TF_TBL_TYPE_SET			UINT32_C(0x2db)
 	/* Experimental */
 	#define HWRM_TF_TBL_TYPE_BULK_GET		UINT32_C(0x2dc)
 	/* Experimental */
-	#define HWRM_TF_CTXT_MEM_ALLOC			UINT32_C(0x2e2)
-	/* Experimental */
-	#define HWRM_TF_CTXT_MEM_FREE			UINT32_C(0x2e3)
-	/* Experimental */
-	#define HWRM_TF_CTXT_MEM_RGTR			UINT32_C(0x2e4)
-	/* Experimental */
-	#define HWRM_TF_CTXT_MEM_UNRGTR		UINT32_C(0x2e5)
-	/* Experimental */
-	#define HWRM_TF_EXT_EM_QCAPS			UINT32_C(0x2e6)
-	/* Experimental */
-	#define HWRM_TF_EXT_EM_OP			UINT32_C(0x2e7)
-	/* Experimental */
-	#define HWRM_TF_EXT_EM_CFG			UINT32_C(0x2e8)
-	/* Experimental */
-	#define HWRM_TF_EXT_EM_QCFG			UINT32_C(0x2e9)
-	/* Experimental */
 	#define HWRM_TF_EM_INSERT			UINT32_C(0x2ea)
 	/* Experimental */
 	#define HWRM_TF_EM_DELETE			UINT32_C(0x2eb)
@@ -1185,7 +1409,85 @@ typedef struct cmd_nums {
 	/* Experimental */
 	#define HWRM_TF_IF_TBL_GET			UINT32_C(0x2ff)
 	/* Experimental */
+	#define HWRM_TF_RESC_USAGE_SET			UINT32_C(0x300)
+	/* Experimental */
+	#define HWRM_TF_RESC_USAGE_QUERY		UINT32_C(0x301)
+	/* Truflow command to allocate a table */
+	#define HWRM_TF_TBL_TYPE_ALLOC			UINT32_C(0x302)
+	/* Truflow command to free a table */
+	#define HWRM_TF_TBL_TYPE_FREE			UINT32_C(0x303)
+	/* TruFlow command to check firmware table scope capabilities. */
+	#define HWRM_TFC_TBL_SCOPE_QCAPS		UINT32_C(0x380)
+	/* TruFlow command to allocate a table scope ID and create the pools. */
+	#define HWRM_TFC_TBL_SCOPE_ID_ALLOC		UINT32_C(0x381)
+	/* TruFlow command to configure the table scope memory. */
+	#define HWRM_TFC_TBL_SCOPE_CONFIG		UINT32_C(0x382)
+	/* TruFlow command to deconfigure a table scope memory. */
+	#define HWRM_TFC_TBL_SCOPE_DECONFIG		UINT32_C(0x383)
+	/* TruFlow command to add a FID to a table scope. */
+	#define HWRM_TFC_TBL_SCOPE_FID_ADD		UINT32_C(0x384)
+	/* TruFlow command to remove a FID from a table scope. */
+	#define HWRM_TFC_TBL_SCOPE_FID_REM		UINT32_C(0x385)
+	/* DEPRECATED */
+	#define HWRM_TFC_TBL_SCOPE_POOL_ALLOC		UINT32_C(0x386)
+	/* DEPRECATED */
+	#define HWRM_TFC_TBL_SCOPE_POOL_FREE		UINT32_C(0x387)
+	/* Experimental */
+	#define HWRM_TFC_SESSION_ID_ALLOC		UINT32_C(0x388)
+	/* Experimental */
+	#define HWRM_TFC_SESSION_FID_ADD		UINT32_C(0x389)
+	/* Experimental */
+	#define HWRM_TFC_SESSION_FID_REM		UINT32_C(0x38a)
+	/* Experimental */
+	#define HWRM_TFC_IDENT_ALLOC			UINT32_C(0x38b)
+	/* Experimental */
+	#define HWRM_TFC_IDENT_FREE			UINT32_C(0x38c)
+	/* TruFlow command to allocate an index table entry */
+	#define HWRM_TFC_IDX_TBL_ALLOC			UINT32_C(0x38d)
+	/* TruFlow command to allocate and set an index table entry */
+	#define HWRM_TFC_IDX_TBL_ALLOC_SET		UINT32_C(0x38e)
+	/* TruFlow command to set an index table entry */
+	#define HWRM_TFC_IDX_TBL_SET			UINT32_C(0x38f)
+	/* TruFlow command to get an index table entry */
+	#define HWRM_TFC_IDX_TBL_GET			UINT32_C(0x390)
+	/* TruFlow command to free an index table entry */
+	#define HWRM_TFC_IDX_TBL_FREE			UINT32_C(0x391)
+	/* TruFlow command to allocate resources for a global id. */
+	#define HWRM_TFC_GLOBAL_ID_ALLOC		UINT32_C(0x392)
+	/* TruFlow command to set TCAM entry. */
+	#define HWRM_TFC_TCAM_SET			UINT32_C(0x393)
+	/* TruFlow command to get TCAM entry. */
+	#define HWRM_TFC_TCAM_GET			UINT32_C(0x394)
+	/* TruFlow command to allocate a TCAM entry. */
+	#define HWRM_TFC_TCAM_ALLOC			UINT32_C(0x395)
+	/* TruFlow command allocate and set TCAM entry. */
+	#define HWRM_TFC_TCAM_ALLOC_SET		UINT32_C(0x396)
+	/* TruFlow command to free a TCAM entry. */
+	#define HWRM_TFC_TCAM_FREE			UINT32_C(0x397)
+	/* Truflow command to set an interface table entry */
+	#define HWRM_TFC_IF_TBL_SET			UINT32_C(0x398)
+	/* Truflow command to get an interface table entry */
+	#define HWRM_TFC_IF_TBL_GET			UINT32_C(0x399)
+	/* TruFlow command to get configured info about a table scope. */
+	#define HWRM_TFC_TBL_SCOPE_CONFIG_GET		UINT32_C(0x39a)
+	/* TruFlow command to query the resource usage state. */
+	#define HWRM_TFC_RESC_USAGE_QUERY		UINT32_C(0x39b)
+	/*
+	 * This command is used to query the pfc watchdog max configurable
+	 * timeout value.
+	 */
+	#define HWRM_QUEUE_PFCWD_TIMEOUT_QCAPS		UINT32_C(0x39c)
+	/* This command is used to set the PFC watchdog timeout value. */
+	#define HWRM_QUEUE_PFCWD_TIMEOUT_CFG		UINT32_C(0x39d)
+	/*
+	 * This command is used to query the current configured pfc watchdog
+	 * timeout value.
+	 */
+	#define HWRM_QUEUE_PFCWD_TIMEOUT_QCFG		UINT32_C(0x39e)
+	/* Experimental */
 	#define HWRM_SV				UINT32_C(0x400)
+	/* Flush any trace buffer data that has not been sent to the host. */
+	#define HWRM_DBG_LOG_BUFFER_FLUSH		UINT32_C(0xff0f)
 	/* Experimental */
 	#define HWRM_DBG_READ_DIRECT			UINT32_C(0xff10)
 	/* Experimental */
@@ -1241,6 +1543,9 @@ typedef struct cmd_nums {
 	#define HWRM_DBG_USEQ_DELIVERY_REQ		UINT32_C(0xff2a)
 	/* Experimental */
 	#define HWRM_DBG_USEQ_RESP_HDR			UINT32_C(0xff2b)
+	#define HWRM_NVM_GET_VPD_FIELD_INFO		UINT32_C(0xffea)
+	#define HWRM_NVM_SET_VPD_FIELD_INFO		UINT32_C(0xffeb)
+	#define HWRM_NVM_DEFRAG			UINT32_C(0xffec)
 	#define HWRM_NVM_REQ_ARBITRATION		UINT32_C(0xffed)
 	/* Experimental */
 	#define HWRM_NVM_FACTORY_DEFAULTS		UINT32_C(0xffee)
@@ -1335,14 +1640,14 @@ typedef struct ret_codes {
 	#define HWRM_ERR_CODE_NO_FLOW_COUNTER_DURING_ALLOC UINT32_C(0xc)
 	/*
 	 * This error code is only reported by firmware when the registered
-	 * driver instances requested to offloaded a flow but was unable to because
-	 * the requested key's hash collides with the installed keys.
+	 * driver instances requested to offloaded a flow but was unable to
+	 * because the requested key's hash collides with the installed keys.
 	 */
 	#define HWRM_ERR_CODE_KEY_HASH_COLLISION	UINT32_C(0xd)
 	/*
 	 * This error code is only reported by firmware when the registered
-	 * driver instances requested to offloaded a flow but was unable to because
-	 * the same key has already been installed.
+	 * driver instances requested to offloaded a flow but was unable to
+	 * because the same key has already been installed.
 	 */
 	#define HWRM_ERR_CODE_KEY_ALREADY_EXISTS	UINT32_C(0xe)
 	/*
@@ -1351,8 +1656,8 @@ typedef struct ret_codes {
 	 */
 	#define HWRM_ERR_CODE_HWRM_ERROR		UINT32_C(0xf)
 	/*
-	 * Firmware is unable to service the request at the present time. Caller
-	 * may try again later.
+	 * Firmware is unable to service the request at the present time.
+	 * Caller may try again later.
 	 */
 	#define HWRM_ERR_CODE_BUSY			UINT32_C(0x10)
 	/*
@@ -1360,6 +1665,18 @@ typedef struct ret_codes {
 	 * by the host is not allowed due to a secure lock violation.
 	 */
 	#define HWRM_ERR_CODE_RESOURCE_LOCKED		UINT32_C(0x11)
+	/*
+	 * This error code is reported by Firmware when an operation requested
+	 * by a VF cannot be forwarded to the parent PF as required, either
+	 * because the PF is down or otherwise doesn't have an appropriate
+	 * async completion ring or associated forwarding buffers configured.
+	 */
+	#define HWRM_ERR_CODE_PF_UNAVAILABLE		UINT32_C(0x12)
+	/*
+	 * This error code is reported by Firmware when the specific entity
+	 * requested by the host is not present or does not exist.
+	 */
+	#define HWRM_ERR_CODE_ENTITY_NOT_PRESENT	UINT32_C(0x13)
 	/*
 	 * This value indicates that the HWRM response is in TLV format and
 	 * should be interpreted as one or more TLVs starting with the
@@ -1396,7 +1713,9 @@ typedef struct ret_codes {
 	((x) == 0xf ? "HWRM_ERROR": \
 	((x) == 0x10 ? "BUSY": \
 	((x) == 0x11 ? "RESOURCE_LOCKED": \
-	"Unknown decode" )))))))))))))))))) : \
+	((x) == 0x12 ? "PF_UNAVAILABLE": \
+	((x) == 0x13 ? "ENTITY_NOT_PRESENT": \
+	"Unknown decode" )))))))))))))))))))) : \
 	(((x) < 0x8080) ? \
 	((x) == 0x8000 ? "TLV_ENCAPSULATED_RESPONSE": \
 	"Unknown decode" ) : \
@@ -1423,7 +1742,7 @@ typedef struct hwrm_err_output {
 	/* This field provides original sequence number of the command. */
 	uint16_t	seq_id;
 	/*
-	 * This field is the length of the response in bytes.  The
+	 * This field is the length of the response in bytes. The
 	 * last byte of the response is a valid flag that will read
 	 * as '1' when the command has been completely written to
 	 * memory.
@@ -1440,9 +1759,9 @@ typedef struct hwrm_err_output {
 	uint8_t	cmd_err;
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
 	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
@@ -1453,7 +1772,12 @@ typedef struct hwrm_err_output {
  * applicable (All F's). Need to cast it the size of the field if needed.
  */
 #define HWRM_NA_SIGNATURE ((uint32_t)(-1))
-/* hwrm_func_buf_rgtr */
+/*
+ * This is reflecting the size of the PF mailbox and not the maximum
+ * command size for any of the HWRM command structures. To determine
+ * the maximum size of an HWRM command supported by the firmware, see
+ * the max_ext_req_len field in the response of the HWRM_VER_GET command.
+ */
 #define HWRM_MAX_REQ_LEN 128
 /* hwrm_cfa_flow_info */
 #define HWRM_MAX_RESP_LEN 704
@@ -1477,10 +1801,10 @@ typedef struct hwrm_err_output {
 #define HWRM_TARGET_ID_TOOLS 0xFFFD
 #define HWRM_VERSION_MAJOR 1
 #define HWRM_VERSION_MINOR 10
-#define HWRM_VERSION_UPDATE 2
+#define HWRM_VERSION_UPDATE 3
 /* non-zero means beta version */
-#define HWRM_VERSION_RSVD 34
-#define HWRM_VERSION_STR "1.10.2.34"
+#define HWRM_VERSION_RSVD 42
+#define HWRM_VERSION_STR "1.10.3.42"
 
 /****************
  * hwrm_ver_get *
@@ -1696,45 +2020,52 @@ typedef struct hwrm_ver_get_output {
 	/*
 	 * If set to 1, then the KONG host mailbox channel is supported.
 	 * If set to 0, then the KONG host mailbox channel is not supported.
-	 * By default, this flag should be 0 for older version of core firmware.
+	 * By default, this flag should be 0 for older version of core
+	 * firmware.
 	 */
 	#define HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_KONG_MB_CHNL_SUPPORTED		UINT32_C(0x10)
 	/*
-	 * If set to 1, then the 64bit flow handle is supported in addition to the
-	 * legacy 16bit flow handle. If set to 0, then the 64bit flow handle is not
-	 * supported. By default, this flag should be 0 for older version of core firmware.
+	 * If set to 1, then the 64bit flow handle is supported in addition
+	 * to the legacy 16bit flow handle. If set to 0, then the 64bit flow
+	 * handle is not supported. By default, this flag should be 0 for
+	 * older version of core firmware.
 	 */
 	#define HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_FLOW_HANDLE_64BIT_SUPPORTED		UINT32_C(0x20)
 	/*
-	 * If set to 1, then filter type can be provided in filter_alloc or filter_cfg
-	 * filter types like L2 for l2 traffic and ROCE for roce & l2 traffic.
-	 * If set to 0, then filter types not supported.
-	 * By default, this flag should be 0 for older version of core firmware.
+	 * If set to 1, then filter type can be provided in filter_alloc or
+	 * filter_cfg filter types like L2 for l2 traffic and ROCE for roce &
+	 * l2 traffic. If set to 0, then filter types not supported. By
+	 * default, this flag should be 0 for older version of core firmware.
 	 */
 	#define HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_L2_FILTER_TYPES_ROCE_OR_L2_SUPPORTED	UINT32_C(0x40)
 	/*
-	 * If set to 1, firmware is capable to support virtio vSwitch offload model.
-	 * If set to 0, firmware can't supported virtio vSwitch offload model.
-	 * By default, this flag should be 0 for older version of core firmware.
+	 * If set to 1, firmware is capable to support virtio vSwitch offload
+	 * model. If set to 0, firmware can't supported virtio vSwitch
+	 * offload model.
+	 * By default, this flag should be 0 for older version of core
+	 * firmware.
 	 */
 	#define HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_VIRTIO_VSWITCH_OFFLOAD_SUPPORTED	UINT32_C(0x80)
 	/*
 	 * If set to 1, firmware is capable to support trusted VF.
 	 * If set to 0, firmware is not capable to support trusted VF.
-	 * By default, this flag should be 0 for older version of core firmware.
+	 * By default, this flag should be 0 for older version of core
+	 * firmware.
 	 */
 	#define HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_TRUSTED_VF_SUPPORTED			UINT32_C(0x100)
 	/*
 	 * If set to 1, firmware is capable to support flow aging.
 	 * If set to 0, firmware is not capable to support flow aging.
-	 * By default, this flag should be 0 for older version of core firmware.
+	 * By default, this flag should be 0 for older version of core
+	 * firmware. (deprecated)
 	 */
 	#define HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_FLOW_AGING_SUPPORTED			UINT32_C(0x200)
 	/*
-	 * If set to 1, firmware is capable to support advanced flow counters like,
-	 * Meter drop counters and EEM counters.
-	 * If set to 0, firmware is not capable to support advanced flow counters.
-	 * By default, this flag should be 0 for older version of core firmware.
+	 * If set to 1, firmware is capable to support advanced flow counters
+	 * like, Meter drop counters and EEM counters.
+	 * If set to 0, firmware is not capable to support advanced flow
+	 * counters. By default, this flag should be 0 for older version of
+	 * core firmware. (deprecated)
 	 */
 	#define HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_ADV_FLOW_COUNTERS_SUPPORTED		UINT32_C(0x400)
 	/*
@@ -1742,31 +2073,46 @@ typedef struct hwrm_ver_get_output {
 	 * Extended Exact Match(EEM) feature.
 	 * If set to 0, firmware is not capable to support the use of the
 	 * CFA EEM feature.
-	 * By default, this flag should be 0 for older version of core firmware.
+	 * By default, this flag should be 0 for older version of core
+	 * firmware. (deprecated)
 	 */
 	#define HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_CFA_EEM_SUPPORTED			UINT32_C(0x800)
 	/*
-	 * If set to 1, the firmware is able to support advance CFA flow management
-	 * features reported in the HWRM_CFA_FLOW_MGNT_QCAPS.
-	 * If set to 0, then the firmware doesn’t support the advance CFA flow management
-	 * features.
-	 * By default, this flag should be 0 for older version of core firmware.
+	 * If set to 1, the firmware is able to support advance CFA flow
+	 * management features reported in the HWRM_CFA_FLOW_MGNT_QCAPS.
+	 * If set to 0, then the firmware doesn't support the advance CFA
+	 * flow management features.
+	 * By default, this flag should be 0 for older version of core
+	 * firmware.
 	 */
 	#define HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_CFA_ADV_FLOW_MGNT_SUPPORTED		UINT32_C(0x1000)
 	/*
 	 * Deprecated and replaced with cfa_truflow_supported.
 	 * If set to 1, the firmware is able to support TFLIB features.
-	 * If set to 0, then the firmware doesn’t support TFLIB features.
-	 * By default, this flag should be 0 for older version of core firmware.
+	 * If set to 0, then the firmware doesn't support TFLIB features.
+	 * By default, this flag should be 0 for older version of core
+	 * firmware.
 	 */
 	#define HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_CFA_TFLIB_SUPPORTED			UINT32_C(0x2000)
 	/*
 	 * If set to 1, the firmware is able to support TruFlow features.
-	 * If set to 0, then the firmware doesn’t support TruFlow features.
+	 * If set to 0, then the firmware doesn't support TruFlow features.
 	 * By default, this flag should be 0 for older version of
 	 * core firmware.
 	 */
 	#define HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_CFA_TRUFLOW_SUPPORTED			UINT32_C(0x4000)
+	/*
+	 * If set to 1, then firmware supports secure boot.
+	 * If set to 0, then firmware doesn't support secure boot.
+	 */
+	#define HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_SECURE_BOOT_CAPABLE			UINT32_C(0x8000)
+	/*
+	 * If set to 1, then firmware is able to support the secure solution
+	 * feature.
+	 * If set to 0, then firmware does not support the secure solution
+	 * feature.
+	 */
+	#define HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_SECURE_SOC_CAPABLE			UINT32_C(0x10000)
 	/*
 	 * This field represents the major version of RoCE firmware.
 	 * A change in major version represents a major release.
@@ -1819,7 +2165,10 @@ typedef struct hwrm_ver_get_output {
 	uint8_t	chip_metal;
 	/* This field returns the bond id of the chip. */
 	uint8_t	chip_bond_id;
-	/* This value indicates the type of platform used for chip implementation. */
+	/*
+	 * This value indicates the type of platform used for chip
+	 * implementation.
+	 */
 	uint8_t	chip_platform_type;
 	/* ASIC */
 	#define HWRM_VER_GET_OUTPUT_CHIP_PLATFORM_TYPE_ASIC	UINT32_C(0x0)
@@ -1858,7 +2207,7 @@ typedef struct hwrm_ver_get_output {
 	 * backing store not been available.
 	 * For Example, PCIe hot-plug:
 	 *	Hot plug timing is system dependent. It generally takes up to
-	 *	600 miliseconds for firmware to clear DEV_NOT_RDY flag.
+	 *	600 milliseconds for firmware to clear DEV_NOT_RDY flag.
 	 * If set to 0, device is ready to accept all HWRM commands.
 	 */
 	#define HWRM_VER_GET_OUTPUT_FLAGS_DEV_NOT_RDY		UINT32_C(0x1)
@@ -1872,8 +2221,8 @@ typedef struct hwrm_ver_get_output {
 	 * host drivers that it has not completed resource initialization
 	 * required for data path operations. Host drivers should not send
 	 * any HWRM command that requires data path resources. Firmware will
-	 * fail those commands with HWRM_ERR_CODE_BUSY. Host drivers can retry
-	 * those commands once both the flags are cleared.
+	 * fail those commands with HWRM_ERR_CODE_BUSY. Host drivers can
+	 * retry those commands once both the flags are cleared.
 	 * If this flag and dev_not_rdy flag are set to 0, device is ready
 	 * to accept all HWRM commands.
 	 */
@@ -2019,12 +2368,23 @@ typedef struct hwrm_ver_get_output {
 	 * used with the short cmd request format.
 	 */
 	uint16_t	max_ext_req_len;
-	uint8_t	unused_1[5];
+	/*
+	 * This field returns the maximum request timeout value in seconds.
+	 * For backward compatibility, a value of zero should be interpreted
+	 * as the default value of 40 seconds. Drivers should always honor the
+	 * maximum timeout, but are permitted to warn if a longer duration than
+	 * this default is advertised. Values larger than 40 seconds should
+	 * only be used as a stopgap measure to address a device limitation or
+	 * for the purposes of test and debugging. The long term goal is for
+	 * firmware to significantly reduce this value in the passage of time.
+	 */
+	uint16_t	max_req_timeout;
+	uint8_t	unused_1[3];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
 	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
@@ -2341,7 +2701,7 @@ typedef struct cfa_bds_event_collect_cmd_data_msg {
 	uint64_t	host_address;
 } cfa_bds_event_collect_cmd_data_msg_t, *pcfa_bds_event_collect_cmd_data_msg_t;
 
-/* ce_bds_add_data_msg (size:512b/64B) */
+/* ce_bds_add_data_msg (size:576b/72B) */
 
 typedef struct ce_bds_add_data_msg {
 	uint32_t	version_algorithm_kid_opcode;
@@ -2377,9 +2737,8 @@ typedef struct ce_bds_add_data_msg {
 	/*
 	 * Version number of TLS connection. HW will provide registers that
 	 * converts the 4b encoded version number to 16b of actual version
-	 * number in the TLS Header. * Initialized --> By mid-path command *
-	 * Updated --> Never though another mid-path command will result in an
-	 * update.
+	 * number in the TLS Header. This field is initialized/updated by
+	 * this "KTLS crypto add" mid-path command.
 	 */
 	#define CE_BDS_ADD_DATA_MSG_VERSION_MASK		UINT32_C(0xf0000000)
 	#define CE_BDS_ADD_DATA_MSG_VERSION_SFT		28
@@ -2388,18 +2747,15 @@ typedef struct ce_bds_add_data_msg {
 	/* TLS1.3 Version */
 		#define CE_BDS_ADD_DATA_MSG__TLS1_3			(UINT32_C(0x1) << 28)
 		#define CE_BDS_ADD_DATA_MSG__LAST			CE_BDS_ADD_DATA_MSG__TLS1_3
-	/*
-	 * Command Type in the TLS header. HW will provide registers that
-	 * converts the 3b encoded command type to 8b of actual command type in
-	 * the TLS Header. * Initialized --> By mid-path command * Updated -->
-	 * Never though another mid-path command will result in an update
-	 */
-	uint8_t	cmd_type;
-	#define CE_BDS_ADD_DATA_MSG_CMD_TYPE_MASK UINT32_C(0x7)
-	#define CE_BDS_ADD_DATA_MSG_CMD_TYPE_SFT 0
-	/* Application */
-		#define CE_BDS_ADD_DATA_MSG_CMD_TYPE_APP   UINT32_C(0x0)
-		#define CE_BDS_ADD_DATA_MSG_CMD_TYPE_LAST CE_BDS_ADD_DATA_MSG_CMD_TYPE_APP
+	uint8_t	ctx_kind;
+	/* This field selects the context kind for the request. */
+	#define CE_BDS_ADD_DATA_MSG_CTX_KIND_MASK UINT32_C(0x1f)
+	#define CE_BDS_ADD_DATA_MSG_CTX_KIND_SFT  0
+	/* Crypto key transmit context */
+		#define CE_BDS_ADD_DATA_MSG_CTX_KIND_CK_TX  UINT32_C(0x11)
+	/* Crypto key receive context */
+		#define CE_BDS_ADD_DATA_MSG_CTX_KIND_CK_RX  UINT32_C(0x12)
+		#define CE_BDS_ADD_DATA_MSG_CTX_KIND_LAST  CE_BDS_ADD_DATA_MSG_CTX_KIND_CK_RX
 	uint8_t	unused0[3];
 	/*
 	 * Salt is part of the nonce that is used as the Initial Vector (IV) in
@@ -2411,8 +2767,8 @@ typedef struct ce_bds_add_data_msg {
 	 * is zero padded to 12B and then xor'ed with the 4B of salt to generate
 	 * the 12B of IV. This value is initialized by this mid-path command.
 	 */
-	uint32_t	salt;
-	uint32_t	unused1;
+	uint8_t	salt[4];
+	uint8_t	unused1[4];
 	/*
 	 * This field keeps track of the TCP sequence number that is expected as
 	 * the first byte in the next TCP packet. This field is calculated by HW
@@ -2445,19 +2801,24 @@ typedef struct ce_bds_add_data_msg {
 	 * exchanged during the hand-shake protocol by the client-server and
 	 * provided to HW through this mid-path BD.
 	 */
-	uint32_t	session_key[8];
+	uint8_t	session_key[32];
+	/*
+	 * Additional IV that is exchanged as part of sessions setup between
+	 * the two end points. This field is used for TLS1.3 only.
+	 */
+	uint8_t	addl_iv[8];
 } ce_bds_add_data_msg_t, *pce_bds_add_data_msg_t;
 
-/* ce_bds_delete_data_msg (size:64b/8B) */
+/* ce_bds_delete_data_msg (size:32b/4B) */
 
 typedef struct ce_bds_delete_data_msg {
-	uint32_t	kid_opcode;
+	uint32_t	kid_opcode_ctx_kind;
 	/*
 	 * This value selects the operation for the mid-path command for the
 	 * crypto blocks.
 	 */
-	#define CE_BDS_DELETE_DATA_MSG_OPCODE_MASK  UINT32_C(0xf)
-	#define CE_BDS_DELETE_DATA_MSG_OPCODE_SFT   0
+	#define CE_BDS_DELETE_DATA_MSG_OPCODE_MASK	UINT32_C(0xf)
+	#define CE_BDS_DELETE_DATA_MSG_OPCODE_SFT	0
 	/*
 	 * This is the delete command. Using this opcode, the host Driver
 	 * can remove a key context from the CFCK. If context is deleted
@@ -2467,15 +2828,26 @@ typedef struct ce_bds_delete_data_msg {
 	 * receive packets, no crypto operation will be performed,
 	 * payload will be unmodified.
 	 */
-		#define CE_BDS_DELETE_DATA_MSG_OPCODE_DELETE  UINT32_C(0x2)
-		#define CE_BDS_DELETE_DATA_MSG_OPCODE_LAST   CE_BDS_DELETE_DATA_MSG_OPCODE_DELETE
+		#define CE_BDS_DELETE_DATA_MSG_OPCODE_DELETE	UINT32_C(0x2)
+		#define CE_BDS_DELETE_DATA_MSG_OPCODE_LAST	CE_BDS_DELETE_DATA_MSG_OPCODE_DELETE
 	/*
 	 * This field is the Crypto Context ID. The KID is used to store
 	 * information used by the associated kTLS offloaded connection.
 	 */
 	#define CE_BDS_DELETE_DATA_MSG_KID_MASK	UINT32_C(0xfffff0)
 	#define CE_BDS_DELETE_DATA_MSG_KID_SFT	4
-	uint32_t	unused0;
+	/* This field selects the context kind for the request. */
+	#define CE_BDS_DELETE_DATA_MSG_CTX_KIND_MASK   UINT32_C(0x1f000000)
+	#define CE_BDS_DELETE_DATA_MSG_CTX_KIND_SFT	24
+	/* Crypto Key Transmit Context. */
+		#define CE_BDS_DELETE_DATA_MSG_CTX_KIND_CK_TX	(UINT32_C(0x11) << 24)
+	/* Crypto Key Receive Context. */
+		#define CE_BDS_DELETE_DATA_MSG_CTX_KIND_CK_RX	(UINT32_C(0x12) << 24)
+	/* QUIC Key Transmit Context. */
+		#define CE_BDS_DELETE_DATA_MSG_CTX_KIND_QUIC_TX  (UINT32_C(0x14) << 24)
+	/* QUIC Key Receive Context. */
+		#define CE_BDS_DELETE_DATA_MSG_CTX_KIND_QUIC_RX  (UINT32_C(0x15) << 24)
+		#define CE_BDS_DELETE_DATA_MSG_CTX_KIND_LAST	CE_BDS_DELETE_DATA_MSG_CTX_KIND_QUIC_RX
 } ce_bds_delete_data_msg_t, *pce_bds_delete_data_msg_t;
 
 /* ce_bds_resync_resp_ack_msg (size:128b/16B) */
@@ -2579,11 +2951,11 @@ typedef struct crypto_presync_bd_cmd {
 	 * Typically, presync BDs are used for packet retransmissions. Source
 	 * port sends all the packets in order over the network to destination
 	 * port and packets get dropped in the network. The destination port
-	 * will request retranmission of dropped packets and source port driver
-	 * will send presync BD to setup the transmitter appropriately. It will
-	 * provide the start and end TCP sequence number of the data to be
-	 * transmitted. HW keeps two sets of context variable, one for in order
-	 * traffic and one for retransmission traffic. HW is designed to
+	 * will request retransmission of dropped packets and source port
+	 * driver will send presync BD to setup the transmitter appropriately.
+	 * It will provide the start and end TCP sequence number of the data to
+	 * be transmitted. HW keeps two sets of context variable, one for in
+	 * order traffic and one for retransmission traffic. HW is designed to
 	 * transmit everything posted in the presync BD and return to in order
 	 * mode after that. No inorder context variables are updated in the
 	 * process. There is a special case where packets can be dropped
@@ -2596,6 +2968,18 @@ typedef struct crypto_presync_bd_cmd {
 	 * associated with the presync BD.
 	 */
 	#define CRYPTO_PRESYNC_BD_CMD_FLAGS_UPDATE_IN_ORDER_VAR	UINT32_C(0x1)
+	/*
+	 * When packet with an authentication TAG is lost in the network,
+	 * During retransmission Device driver will post the entire record for
+	 * the hardware to recalculate the TAG. Hardware is set to retransmit
+	 * only portions of the record, it does so by looking at the Header
+	 * TCP Sequence Number and Start TCP Sequence Number. However, there
+	 * is a case where the header packet gets dropped in the stack for ex
+	 * BPF packet filter and it is impossible for the Hardware to
+	 * determine if this is a case of full replay for only the TAG
+	 * generation.
+	 */
+	#define CRYPTO_PRESYNC_BD_CMD_FLAGS_FULL_REPLAY_RETRAN	UINT32_C(0x2)
 	uint8_t	unused0;
 	uint16_t	unused1;
 	/*
@@ -2631,7 +3015,7 @@ typedef struct crypto_presync_bd_cmd {
 	uint32_t	end_tcp_seq_num;
 	/*
 	 * For TLS1.2, an explicit nonce is used as part of the IV (concatenated
-	 * with the SALT). For retans packets, this field is extracted from the
+	 * with the SALT). For retrans packets, this field is extracted from the
 	 * TLS record, field right after the TLS Header and stored in the
 	 * context. This field needs to be stored in context as TCP segmentation
 	 * could have split the field into multiple TCP packets. This value is
@@ -2639,7 +3023,7 @@ typedef struct crypto_presync_bd_cmd {
 	 * the first TLS header. When subsequent TLS Headers are detected, the
 	 * value is extracted from packet.
 	 */
-	uint64_t	explicit_nonce;
+	uint8_t	explicit_nonce[8];
 	/*
 	 * This is sequence number for the TLS record in a particular session. In
 	 * TLS1.2, record sequence number is part of the Associated Data (AD) in
@@ -2654,6 +3038,93 @@ typedef struct crypto_presync_bd_cmd {
 	uint64_t	record_seq_num;
 } crypto_presync_bd_cmd_t, *pcrypto_presync_bd_cmd_t;
 
+/* ce_bds_quic_add_data_msg (size:832b/104B) */
+
+typedef struct ce_bds_quic_add_data_msg {
+	uint32_t	ver_algo_kid_opcode;
+	/*
+	 * This value selects the operation for the mid-path command for the
+	 * crypto blocks.
+	 */
+	#define CE_BDS_QUIC_ADD_DATA_MSG_OPCODE_MASK	UINT32_C(0xf)
+	#define CE_BDS_QUIC_ADD_DATA_MSG_OPCODE_SFT	0
+	/*
+	 * This is the add command. Using this opcode, Host Driver can add
+	 * information required for QUIC processing. The information is
+	 * updated in the CFCK context.
+	 */
+		#define CE_BDS_QUIC_ADD_DATA_MSG_OPCODE_ADD		UINT32_C(0x1)
+		#define CE_BDS_QUIC_ADD_DATA_MSG_OPCODE_LAST	CE_BDS_QUIC_ADD_DATA_MSG_OPCODE_ADD
+	/*
+	 * This field is the Crypto Context ID. The KID is used to store
+	 * information used by the associated QUIC offloaded connection.
+	 */
+	#define CE_BDS_QUIC_ADD_DATA_MSG_KID_MASK		UINT32_C(0xfffff0)
+	#define CE_BDS_QUIC_ADD_DATA_MSG_KID_SFT		4
+	/* Algorithm used for encryption and decryption. */
+	#define CE_BDS_QUIC_ADD_DATA_MSG_ALGORITHM_MASK	UINT32_C(0xf000000)
+	#define CE_BDS_QUIC_ADD_DATA_MSG_ALGORITHM_SFT	24
+	/* AES_GCM_128 Algorithm. */
+		#define CE_BDS_QUIC_ADD_DATA_MSG_ALGORITHM_AES_GCM_128  (UINT32_C(0x1) << 24)
+	/* AES_GCM_256 Algorithm. */
+		#define CE_BDS_QUIC_ADD_DATA_MSG_ALGORITHM_AES_GCM_256  (UINT32_C(0x2) << 24)
+	/* Chacha20 Algorithm. */
+		#define CE_BDS_QUIC_ADD_DATA_MSG_ALGORITHM_CHACHA20	(UINT32_C(0x3) << 24)
+		#define CE_BDS_QUIC_ADD_DATA_MSG_ALGORITHM_LAST	CE_BDS_QUIC_ADD_DATA_MSG_ALGORITHM_CHACHA20
+	/* Version number of QUIC connection. */
+	#define CE_BDS_QUIC_ADD_DATA_MSG_VERSION_MASK	UINT32_C(0xf0000000)
+	#define CE_BDS_QUIC_ADD_DATA_MSG_VERSION_SFT	28
+	/* TLS1.2 Version */
+		#define CE_BDS_QUIC_ADD_DATA_MSG__TLS1_2		(UINT32_C(0x0) << 28)
+	/* TLS1.3 Version */
+		#define CE_BDS_QUIC_ADD_DATA_MSG__TLS1_3		(UINT32_C(0x1) << 28)
+	/* DTLS1.2 Version */
+		#define CE_BDS_QUIC_ADD_DATA_MSG__DTLS1_2		(UINT32_C(0x2) << 28)
+	/* DTLS1.2 for RoCE Version */
+		#define CE_BDS_QUIC_ADD_DATA_MSG__DTLS1_2_ROCE	(UINT32_C(0x3) << 28)
+	/* QUIC Version */
+		#define CE_BDS_QUIC_ADD_DATA_MSG__QUIC		(UINT32_C(0x4) << 28)
+		#define CE_BDS_QUIC_ADD_DATA_MSG__LAST		CE_BDS_QUIC_ADD_DATA_MSG__QUIC
+	uint32_t	ctx_kind_dcid_width_key_phase;
+	/* Key phase. */
+	#define CE_BDS_QUIC_ADD_DATA_MSG_KEY_PHASE	UINT32_C(0x1)
+	/* Destination connection ID width. */
+	#define CE_BDS_QUIC_ADD_DATA_MSG_DCID_WIDTH_MASK UINT32_C(0x3e)
+	#define CE_BDS_QUIC_ADD_DATA_MSG_DCID_WIDTH_SFT  1
+	/* This field selects the context kind for the request. */
+	#define CE_BDS_QUIC_ADD_DATA_MSG_CTX_KIND_MASK   UINT32_C(0x7c0)
+	#define CE_BDS_QUIC_ADD_DATA_MSG_CTX_KIND_SFT	6
+	/* QUIC key transmit context */
+		#define CE_BDS_QUIC_ADD_DATA_MSG_CTX_KIND_QUIC_TX  (UINT32_C(0x14) << 6)
+	/* QUIC key receive context */
+		#define CE_BDS_QUIC_ADD_DATA_MSG_CTX_KIND_QUIC_RX  (UINT32_C(0x15) << 6)
+		#define CE_BDS_QUIC_ADD_DATA_MSG_CTX_KIND_LAST	CE_BDS_QUIC_ADD_DATA_MSG_CTX_KIND_QUIC_RX
+	uint64_t	unused_0;
+	/*
+	 * Least-significant 64 bits (of 96) of additional IV that is
+	 * exchanged as part of sessions setup between the two end
+	 * points for QUIC operations.
+	 */
+	uint8_t	quic_iv_lo[8];
+	/*
+	 * Most-significant 32 bits (of 96) of additional IV that is
+	 * exchanged as part of sessions setup between the two end
+	 * points for QUIC operations.
+	 */
+	uint8_t	quic_iv_hi[4];
+	uint32_t	unused_1;
+	/*
+	 * Key used for encrypting or decrypting records. The Key is exchanged
+	 * as part of sessions setup between the two end points through this
+	 * mid-path BD.
+	 */
+	uint8_t	session_key[32];
+	/* Header protection key. */
+	uint8_t	hp_key[32];
+	/* Packet number associated with the QUIC connection. */
+	uint64_t	pkt_number;
+} ce_bds_quic_add_data_msg_t, *pce_bds_quic_add_data_msg_t;
+
 /* bd_base (size:64b/8B) */
 
 typedef struct bd_base {
@@ -2696,6 +3167,12 @@ typedef struct bd_base {
 	 * sync command through the fast path and destined for TCE.
 	 */
 		#define BD_BASE_TYPE_TX_BD_PRESYNC_CMD  UINT32_C(0x9)
+	/*
+	 * Indicates a timed transmit BD. This is a 16b BD that is inserted
+	 * into a packet BD chain immediately after the first BD. It is used
+	 * to control the flow in a timed transmit operation.
+	 */
+		#define BD_BASE_TYPE_TX_BD_TIMEDTX	UINT32_C(0xa)
 	/*
 	 * Indicates that this BD is 32B long and is used for
 	 * normal L2 packet transmission.
@@ -2822,7 +3299,8 @@ typedef struct tx_bd_short {
 	 *
 	 * This value must be valid on all BDs of a packet.
 	 */
-	uint64_t	addr;
+	uint32_t	addr_lo;
+	uint32_t	addr_hi;
 } tx_bd_short_t, *ptx_bd_short_t;
 
 /* tx_bd_long (size:128b/16B) */
@@ -2979,10 +3457,22 @@ typedef struct tx_bd_long_hi {
 	 */
 	#define TX_BD_LONG_LFLAGS_NOCRC		UINT32_C(0x4)
 	/*
-	 * If set to 1, the device will record the time at which the packet
-	 * was actually transmitted at the TX MAC for 2-step time sync.
+	 * This bit, in conjunction with the stamp_1step bit, controls whether
+	 * a TX packet timestamp is collected and the type of timestamp that
+	 * is collected.
 	 *
 	 * This bit must be valid on the first BD of a packet.
+	 *
+	 * Enumerations of the concatenation { stamp, stamp_1step } are
+	 * as follows:
+	 *
+	 * - 2'b00: ts_none - no timestamp
+	 * - 2'b01: ts_ptp_1step - 1-step PTP
+	 * - 2'b10: ts_2cmpl - 2-step PTP timestamp or PA timestamp
+	 * - 2'b11: ts_rsvd - reserved, same behavior as ts_none
+	 * For the ts_2cmpl enumeration, an additional completion is returned.
+	 * This additional completion may carry a 2-step PTP timestamp or a PA
+	 * timestamp, depending on parsing of the transmitted packet.
 	 */
 	#define TX_BD_LONG_LFLAGS_STAMP		UINT32_C(0x8)
 	/*
@@ -2991,15 +3481,15 @@ typedef struct tx_bd_long_hi {
 	 * of the packet associated with this descriptor.
 	 *
 	 * For outer UDP checksum, global outer UDP checksum TE_NIC register
-	 * needs to be enabled. If the global outer UDP checksum TE_NIC register
-	 * bit is set, outer UDP checksum will be calculated for the following
-	 * cases:
-	 * 1. Packets with tcp_udp_chksum flag set to offload checksum for inner
-	 * packet AND the inner packet is TCP/UDP. If the inner packet is ICMP for
-	 * example (non-TCP/UDP), even if the tcp_udp_chksum is set, the outer UDP
-	 * checksum will not be calculated.
-	 * 2. Packets with lso flag set which implies inner TCP checksum calculation
-	 * as part of LSO operation.
+	 * needs to be enabled. If the global outer UDP checksum TE_NIC
+	 * register bit is set, outer UDP checksum will be calculated for
+	 * the following cases:
+	 * 1. Packets with tcp_udp_chksum flag set to offload checksum for
+	 * inner packet AND the inner packet is TCP/UDP. If the inner packet
+	 * is ICMP for example (non-TCP/UDP), even if the tcp_udp_chksum is
+	 * set, the outer UDP checksum will not be calculated.
+	 * 2. Packets with lso flag set which implies inner TCP checksum
+	 * calculation as part of LSO operation.
 	 */
 	#define TX_BD_LONG_LFLAGS_T_IP_CHKSUM	UINT32_C(0x10)
 	/*
@@ -3020,7 +3510,7 @@ typedef struct tx_bd_long_hi {
 	 * 0xffff.
 	 *
 	 * If set to one when LSO is '1', then the IPID will be treated
-	 * as a 15b number and will be wrapped if it exceeds a value 0f
+	 * as a 15b number and will be wrapped if it exceeds a value of
 	 * 0x7fff.
 	 */
 	#define TX_BD_LONG_LFLAGS_IPID_FMT	UINT32_C(0x40)
@@ -3050,6 +3540,11 @@ typedef struct tx_bd_long_hi {
 	 * If set to '1', then the timestamp from the BD is used. If cleared
 	 * to 0, then TWE provides the timestamp.
 	 */
+	/*
+	 * The BD timestamp feature cannot be enabled concurrently with
+	 * cryptography (KTLS), thus lflags.bd_ts_en and lflags.crypto_en
+	 * shall never both be set in a BD.
+	 */
 	#define TX_BD_LONG_LFLAGS_BD_TS_EN	UINT32_C(0x400)
 	/*
 	 * If set to '1', this operation will cause a trace capture in each
@@ -3057,26 +3552,32 @@ typedef struct tx_bd_long_hi {
 	 */
 	#define TX_BD_LONG_LFLAGS_DEBUG_TRACE	UINT32_C(0x800)
 	/*
-	 * If set to '1', the device will record the time at which the packet
-	 * was actually transmitted at the TX MAC for 1-step time sync. This
-	 * bit must be valid on the first BD of a packet.
+	 * This bit, in conjunction with the stamp bit, controls whether a
+	 * TX packet timestamp is collected and the type of timestamp that
+	 * is collected.
+	 *
+	 * See the stamp field for a description of the valid combinations of
+	 * stamp and stamp_1step.
+	 *
+	 * This bit must be valid on the first BD of a packet.
 	 */
 	#define TX_BD_LONG_LFLAGS_STAMP_1STEP	UINT32_C(0x1000)
 	/*
 	 * If set to '1', the controller replaces the Outer-tunnel IP checksum
 	 * field with hardware calculated IP checksum for the IP header of the
 	 * packet associated with this descriptor. For outer UDP checksum, it
-	 * will be the following behavior for all cases independent of settings
-	 * of inner LSO and checksum offload BD flags. If outer UDP checksum
-	 * is 0, then do not update it. If outer UDP checksum is non zero, then
-	 * the hardware should compute and update it.
+	 * will be the following behavior for all cases independent of
+	 * settings of inner LSO and checksum offload BD flags.
+	 * If outer UDP checksum is 0, then do not update it.
+	 * If outer UDP checksum is non zero, then the hardware should
+	 * compute and update it.
 	 */
 	#define TX_BD_LONG_LFLAGS_OT_IP_CHKSUM	UINT32_C(0x2000)
 	/*
-	 * If set to zero when LSO is '1', then the IPID of the Outer-tunnel IP
-	 * header will not be modified during LSO operations. If set to one
-	 * when LSO is '1', then the IPID of the Outer-tunnel IP header will be
-	 * incremented for each subsequent segment of an LSO operation. The
+	 * If set to zero when LSO is '1', then the IPID of the Outer-tunnel
+	 * IP header will not be modified during LSO operations. If set to one
+	 * when LSO is '1', then the IPID of the Outer-tunnel IP header will
+	 * be incremented for each subsequent segment of an LSO operation. The
 	 * flag is ignored if the LSO packet is a normal (non-tunneled) TCP
 	 * packet.
 	 */
@@ -3085,6 +3586,11 @@ typedef struct tx_bd_long_hi {
 	 * If set to '1', When set to 1, KTLS encryption will be enabled for
 	 * the packet.
 	 */
+	/*
+	 * The BD timestamp feature cannot be enabled concurrently with
+	 * cryptography (KTLS), thus lflags.bd_ts_en and lflags.crypto_en
+	 * shall never both be set in a BD.
+	 */
 	#define TX_BD_LONG_LFLAGS_CRYPTO_EN	UINT32_C(0x8000)
 	uint16_t	kid_or_ts_low_hdr_size;
 	/*
@@ -3100,8 +3606,13 @@ typedef struct tx_bd_long_hi {
 	#define TX_BD_LONG_HDR_SIZE_SFT	0
 	/*
 	 * If lflags.bd_ts_en is 1, this is the lower 7 bits of the 24-bit
-	 * timestamp. If lflags.crypto_en is 1, this is the lower 7 bits of the
-	 * 20-bit KID.
+	 * timestamp. If lflags.crypto_en is 1, this is the lower 7 bits of
+	 * the 20-bit KID.
+	 */
+	/*
+	 * The KID value of all-ones is reserved for non-KTLS packets, which
+	 * only implies that this value must not be used when filling this
+	 * field for crypto packets.
 	 */
 	#define TX_BD_LONG_KID_OR_TS_LOW_MASK UINT32_C(0xfe00)
 	#define TX_BD_LONG_KID_OR_TS_LOW_SFT 9
@@ -3120,6 +3631,11 @@ typedef struct tx_bd_long_hi {
 	 * timestamp. If lflags.crypto_en is 1, the least significant 13 bits
 	 * of this field contain the upper 13 bits of the 20-bit KID.
 	 */
+	/*
+	 * The KID value of all-ones is reserved for non-KTLS packets, which
+	 * only implies that this value must not be used when filling this
+	 * field for crypto packets.
+	 */
 	#define TX_BD_LONG_KID_OR_TS_HIGH_MASK UINT32_C(0xffff8000)
 	#define TX_BD_LONG_KID_OR_TS_HIGH_SFT 15
 	/*
@@ -3189,7 +3705,7 @@ typedef struct tx_bd_long_hi {
 	 * - Wh+/SR - this option is not supported.
 	 * - Thor - cfa_meta[15:0] is used for metadata output if en_bd_meta
 	 *   is set in the Lookup Table.
-	 * - SR2 - {4’d0, cfa_meta[27:0]} is used for metadata output if
+	 * - SR2 - {4'd0, cfa_meta[27:0]} is used for metadata output if
 	 *   en_bd_meta is set in the Lookup Table.
 	 */
 		#define TX_BD_LONG_CFA_META_KEY_METADATA_TRANSFER  (UINT32_C(0x2) << 28)
@@ -3197,11 +3713,11 @@ typedef struct tx_bd_long_hi {
 } tx_bd_long_hi_t, *ptx_bd_long_hi_t;
 
 /*
- * This structure is used to inform the NIC of packet data that needs to be
- * transmitted with additional processing that requires extra data such as
- * VLAN insertion plus attached inline data. This BD type may be used to
- * improve latency for small packets needing the additional extended features
- * supported by long BDs.
+ * This structure is used to inform the NIC of packet data that needs to
+ * be transmitted with additional processing that requires extra data
+ * such as VLAN insertion plus attached inline data.
+ * This BD type may be used to improve latency for small packets needing
+ * the additional extended features supported by long BDs.
  */
 /* tx_bd_long_inline (size:256b/32B) */
 
@@ -3266,21 +3782,27 @@ typedef struct tx_bd_long_inline {
 	 *
 	 * This field must be valid on all BDs of a packet.
 	 */
+	/*
+	 * A fatal error will be generated if the value of this field
+	 * does not correspond with the value of flags.bd_cnt. For example, if
+	 * this field carries a value of 20, then bd_cnt must equal 4.
+	 */
 	uint16_t	len;
 	/*
 	 * The opaque data field is passed through to the completion and can be
-	 * used for any data that the driver wants to associate with the transmit
-	 * BD. This field must be valid on the first BD of a packet. If
-	 * completion coalescing is enabled on the TX ring, it is suggested that
-	 * the driver populate the opaque field to indicate the specific TX ring
-	 * with which the completion is associated, then utilize the opaque and
-	 * sq_cons_idx fields in the coalesced completion record to determine
-	 * the specific packets that are to be completed on that ring.
+	 * used for any data that the driver wants to associate with the
+	 * transmit BD. This field must be valid on the first BD of a packet.
+	 * If completion coalescing is enabled on the TX ring, it is suggested
+	 * that the driver populate the opaque field to indicate the specific
+	 * TX ring with which the completion is associated, then utilize the
+	 * opaque and sq_cons_idx fields in the coalesced completion record to
+	 * determine the specific packets that are to be completed on that ring.
 	 *
 	 * This field must be valid on the first BD of a packet.
 	 */
 	uint32_t	opaque;
-	uint64_t	unused1;
+	uint32_t	unused1_lo;
+	uint32_t	unused1_hi;
 	/*
 	 * All bits in this field must be valid on the first BD of a packet.
 	 * Their value on other BDs of the packet is ignored.
@@ -3347,6 +3869,11 @@ typedef struct tx_bd_long_inline {
 	 * If set to '1', then the timestamp from the BD is used. If cleared
 	 * to 0, then TWE provides the timestamp.
 	 */
+	/*
+	 * The BD timestamp feature cannot be enabled concurrently with
+	 * cryptography (KTLS), thus lflags.bd_ts_en and lflags.crypto_en
+	 * shall never both be set in a BD.
+	 */
 	#define TX_BD_LONG_INLINE_LFLAGS_BD_TS_EN	UINT32_C(0x400)
 	/*
 	 * If set to '1', this operation will cause a trace capture in each
@@ -3382,6 +3909,11 @@ typedef struct tx_bd_long_inline {
 	 * If set to '1', When set to 1, KTLS encryption will be enabled for
 	 * the packet.
 	 */
+	/*
+	 * The BD timestamp feature cannot be enabled concurrently with
+	 * cryptography (KTLS), thus lflags.bd_ts_en and lflags.crypto_en
+	 * shall never both be set in a BD.
+	 */
 	#define TX_BD_LONG_INLINE_LFLAGS_CRYPTO_EN	UINT32_C(0x8000)
 	uint8_t	unused2;
 	uint8_t	kid_or_ts_low;
@@ -3391,6 +3923,11 @@ typedef struct tx_bd_long_inline {
 	 * timestamp. If lflags.crypto_en is 1, this is the lower 7 bits of
 	 * the 20-bit KID.
 	 */
+	/*
+	 * The KID value of all-ones is reserved for non-KTLS packets, which
+	 * only implies that this value must not be used when filling this
+	 * field for crypto packets.
+	 */
 	#define TX_BD_LONG_INLINE_KID_OR_TS_LOW_MASK UINT32_C(0xfe)
 	#define TX_BD_LONG_INLINE_KID_OR_TS_LOW_SFT 1
 	uint32_t	kid_or_ts_high;
@@ -3401,6 +3938,11 @@ typedef struct tx_bd_long_inline {
 	 * timestamp. If lflags.crypto_en is 1, the least significant 13 bits
 	 * of this field contain the upper 13 bits of the 20-bit KID.
 	 */
+	/*
+	 * The KID value of all-ones is reserved for non-KTLS packets, which
+	 * only implies that this value must not be used when filling this
+	 * field for crypto packets.
+	 */
 	#define TX_BD_LONG_INLINE_KID_OR_TS_HIGH_MASK UINT32_C(0xffff8000)
 	#define TX_BD_LONG_INLINE_KID_OR_TS_HIGH_SFT 15
 	/*
@@ -3469,7 +4011,7 @@ typedef struct tx_bd_long_inline {
 	 * - Wh+/SR - this option is not supported.
 	 * - Thor - cfa_meta[15:0] is used for metadata output if en_bd_meta
 	 *   is set in the Lookup Table.
-	 * - SR2 - {4’d0, cfa_meta[27:0]} is used for metadata output if
+	 * - SR2 - {4'd0, cfa_meta[27:0]} is used for metadata output if
 	 *   en_bd_meta is set in the Lookup Table.
 	 */
 		#define TX_BD_LONG_INLINE_CFA_META_KEY_METADATA_TRANSFER  (UINT32_C(0x2) << 28)
@@ -3525,6 +4067,11 @@ typedef struct tx_bd_mp_cmd {
 	 * This value defines the length of command field in bytes. The maximum
 	 * value shall be 496.
 	 */
+	/*
+	 * Note that a fatal error will be generated if the value of this field
+	 * does not correspond with the value of flags.bd_cnt. For example, if
+	 * this field carries a value of 20, then bd_cnt must equal 3.
+	 */
 	uint16_t	len;
 	/*
 	 * The opaque data field is pass through to the completion and can be
@@ -3532,7 +4079,8 @@ typedef struct tx_bd_mp_cmd {
 	 * Tx mid-path command.
 	 */
 	uint32_t	opaque;
-	uint64_t	unused1;
+	uint32_t	unused1_lo;
+	uint32_t	unused1_hi;
 } tx_bd_mp_cmd_t, *ptx_bd_mp_cmd_t;
 
 /* tx_bd_presync_cmd (size:128b/16B) */
@@ -3565,6 +4113,11 @@ typedef struct tx_bd_presync_cmd {
 	 * This value defines the length of command field in bytes. The maximum
 	 * value shall be 496.
 	 */
+	/*
+	 * Note that a fatal error will be generated if the value of this field
+	 * does not correspond with the value of flags.bd_cnt. For example, if
+	 * this field carries a value of 20, then bd_cnt must equal 3.
+	 */
 	uint16_t	len;
 	/*
 	 * The opaque data field is pass through to TCE and can be used for
@@ -3587,6 +4140,96 @@ typedef struct tx_bd_presync_cmd {
 	uint32_t	unused_1;
 } tx_bd_presync_cmd_t, *ptx_bd_presync_cmd_t;
 
+/*
+ * This structure is used to send additional information for transmitting
+ * packets using timed transmit scheduling. It must only to be applied as
+ * the second BD of a BD chain that represents a packet. Any subsequent
+ * BDs will follow the timed transmit BD.
+ */
+/* tx_bd_timedtx (size:128b/16B) */
+
+typedef struct tx_bd_timedtx {
+	uint16_t	flags_type;
+	/* This value identifies the type of buffer descriptor. */
+	#define TX_BD_TIMEDTX_TYPE_MASK	UINT32_C(0x3f)
+	#define TX_BD_TIMEDTX_TYPE_SFT		0
+	/*
+	 * Indicates a timed transmit BD. This is a 16b BD that is inserted
+	 * into a packet BD chain immediately after the first BD. It is used
+	 * to control the flow in a timed transmit operation.
+	 */
+		#define TX_BD_TIMEDTX_TYPE_TX_BD_TIMEDTX	UINT32_C(0xa)
+		#define TX_BD_TIMEDTX_TYPE_LAST		TX_BD_TIMEDTX_TYPE_TX_BD_TIMEDTX
+	/* Unless otherwise stated, sub-fields of this field are always valid. */
+	#define TX_BD_TIMEDTX_FLAGS_MASK	UINT32_C(0xffc0)
+	#define TX_BD_TIMEDTX_FLAGS_SFT	6
+	/*
+	 * This value identifies the kind of buffer timed transmit mode that
+	 * is to be enabled for the packet.
+	 */
+	#define TX_BD_TIMEDTX_FLAGS_KIND_MASK	UINT32_C(0x1c0)
+	#define TX_BD_TIMEDTX_FLAGS_KIND_SFT	6
+	/*
+	 * This timed transmit mode indicates that the packet will be
+	 * scheduled and send immediately (or as soon as possible), once
+	 * it is scheduled in the transmitter.
+	 * Note: This mode is similar to regular (non-timed transmit)
+	 * operation. Its main purpose is to cancel pace mode timed
+	 * transmit.
+	 */
+		#define TX_BD_TIMEDTX_FLAGS_KIND_ASAP	(UINT32_C(0x0) << 6)
+	/*
+	 * This timed transmit mode is used to schedule transmission of
+	 * the packet no earlier than the time given in the tx_time
+	 * field of the BD.
+	 * Note: In case subsequent packets don't include a timed transmit
+	 * BD, they will be scheduled subsequently for transmission
+	 * without any timed transmit constraint.
+	 */
+		#define TX_BD_TIMEDTX_FLAGS_KIND_SO_TXTIME   (UINT32_C(0x1) << 6)
+	/*
+	 * This timed transmit mode is used to enable rate control for the
+	 * flow (QP) at a rate as defined by the rate field of this BD.
+	 * Note: In case subsequent, adjacent packets on the same flow
+	 * don't include a timed transmit BD, they will continue to be
+	 * paced by the transmitter at the same rate as given in this BD.
+	 */
+		#define TX_BD_TIMEDTX_FLAGS_KIND_PACE	(UINT32_C(0x2) << 6)
+		#define TX_BD_TIMEDTX_FLAGS_KIND_LAST	TX_BD_TIMEDTX_FLAGS_KIND_PACE
+	/*
+	 * This field exists in all Tx BDs. It doesn't apply to this particular
+	 * BD type since the BD never represents an SGL or inline data; i.e. it
+	 * is only a command. This field must be zero.
+	 */
+	/*
+	 * Note that if this field is not zero, a fatal length error will be
+	 * generated as it will be included in the aggregate of SGE lengths for
+	 * the packet.
+	 */
+	uint16_t	len;
+	/*
+	 * This field represents the rate of the flow (QP) in terms of KB/s.
+	 * This applies to pace mode timed transmit.
+	 */
+	uint32_t	rate;
+	/*
+	 * Applying this rate to a QP will result in this and all subsequent
+	 * packets of the flow being paced at the given rate, until such time
+	 * that the timed transmit mode is either changed or the rate is
+	 * updated in a future packet on the flow.
+	 * This field is applicable only if flags.kind is pace.
+	 */
+	#define TX_BD_TIMEDTX_RATE_VAL_MASK UINT32_C(0x1ffffff)
+	#define TX_BD_TIMEDTX_RATE_VAL_SFT 0
+	/*
+	 * This field represents the nano-second time to transmit the
+	 * corresponding packet using SO_TXTIME mode of timed transmit.
+	 * This field is applicable only if flags.kind is so_txtime.
+	 */
+	uint32_t	tx_time_lo;
+	uint32_t	tx_time_hi;
+} tx_bd_timedtx_t, *ptx_bd_timedtx_t;
+
 /* rx_prod_pkt_bd (size:128b/16B) */
 
 typedef struct rx_prod_pkt_bd {
@@ -3607,11 +4250,22 @@ typedef struct rx_prod_pkt_bd {
 	 * If set to 1, the packet will be placed at the address plus
 	 * 2B. The 2 Bytes of padding will be written as zero.
 	 */
+	/*
+	 * This is intended to be used when the host buffer is
+	 * cache-line aligned to produce packets that are easy to
+	 * parse in host memory while still allowing writes to be cache
+	 * line aligned.
+	 */
 	#define RX_PROD_PKT_BD_FLAGS_SOP_PAD	UINT32_C(0x40)
 	/*
 	 * If set to 1, the packet write will be padded out to the
 	 * nearest cache-line with zero value padding.
 	 */
+	/*
+	 * If receive buffers start/end on cache-line boundaries, this
+	 * feature will ensure that all data writes on the PCI bus
+	 * start/end on cache line boundaries.
+	 */
 	#define RX_PROD_PKT_BD_FLAGS_EOP_PAD	UINT32_C(0x80)
 	/*
 	 * This field has been deprecated. There can be no additional
@@ -3633,6 +4287,10 @@ typedef struct rx_prod_pkt_bd {
 	 * This is the length in Bytes of the host physical buffer where
 	 * data for the packet may be placed in host memory.
 	 */
+	/*
+	 * While this is a Byte resolution value, it is often advantageous
+	 * to ensure that the buffers provided end on a host cache line.
+	 */
 	uint16_t	len;
 	/*
 	 * The opaque data field is pass through to the completion and can be
@@ -3644,6 +4302,10 @@ typedef struct rx_prod_pkt_bd {
 	 * This is the host physical address where data for the packet may
 	 * be placed in host memory.
 	 */
+	/*
+	 * While this is a Byte resolution value, it is often advantageous
+	 * to ensure that the buffers provide start on a host cache line.
+	 */
 	uint64_t	addr;
 } rx_prod_pkt_bd_t, *prx_prod_pkt_bd_t;
 
@@ -3667,6 +4329,10 @@ typedef struct rx_prod_bfr_bd {
 	 * This is the length in Bytes of the host physical buffer where
 	 * data for the packet may be placed in host memory.
 	 */
+	/*
+	 * While this is a Byte resolution value, it is often advantageous
+	 * to ensure that the buffers provided end on a host cache line.
+	 */
 	uint16_t	len;
 	/* This field is not used. */
 	uint32_t	opaque;
@@ -3674,7 +4340,12 @@ typedef struct rx_prod_bfr_bd {
 	 * This is the host physical address where data for the packet may
 	 * be placed in host memory.
 	 */
-	uint64_t	addr;
+	/*
+	 * While this is a Byte resolution value, it is often advantageous
+	 * to ensure that the buffers provide start on a host cache line.
+	 */
+	uint32_t	addr_lo;
+	uint32_t	addr_hi;
 } rx_prod_bfr_bd_t, *prx_prod_bfr_bd_t;
 
 /* rx_prod_agg_bd (size:128b/16B) */
@@ -3697,11 +4368,20 @@ typedef struct rx_prod_agg_bd {
 	 * If set to 1, the packet write will be padded out to the
 	 * nearest cache-line with zero value padding.
 	 */
+	/*
+	 * If receive buffers start/end on cache-line boundaries, this
+	 * feature will ensure that all data writes on the PCI bus
+	 * end on cache line boundaries.
+	 */
 	#define RX_PROD_AGG_BD_FLAGS_EOP_PAD	UINT32_C(0x40)
 	/*
 	 * This is the length in Bytes of the host physical buffer where
 	 * data for the packet may be placed in host memory.
 	 */
+	/*
+	 * While this is a Byte resolution value, it is often advantageous
+	 * to ensure that the buffers provided end on a host cache line.
+	 */
 	uint16_t	len;
 	/*
 	 * The opaque data field is pass through to the completion and can be
@@ -3713,7 +4393,12 @@ typedef struct rx_prod_agg_bd {
 	 * This is the host physical address where data for the packet may
 	 * be placed in host memory.
 	 */
-	uint64_t	addr;
+	/*
+	 * While this is a Byte resolution value, it is often advantageous
+	 * to ensure that the buffers provide start on a host cache line.
+	 */
+	uint32_t	addr_lo;
+	uint32_t	addr_hi;
 } rx_prod_agg_bd_t, *prx_prod_agg_bd_t;
 
 /* cfa_cmpls_cmp_data_msg (size:128b/16B) */
@@ -3724,6 +4409,12 @@ typedef struct cfa_cmpls_cmp_data_msg {
 	 * This field represents the Mid-Path client that generated the
 	 * completion.
 	 */
+	/*
+	 * This field indicates the exact type of the completion. By
+	 * convention, the LSB identifies the length of the record in 16B
+	 * units. Even values indicate 16B records. Odd values indicate 32B
+	 * records.
+	 */
 	#define CFA_CMPLS_CMP_DATA_MSG_TYPE_MASK		UINT32_C(0x3f)
 	#define CFA_CMPLS_CMP_DATA_MSG_TYPE_SFT		0
 	/* Mid Path Short Completion with length = 16B. */
@@ -3823,9 +4514,9 @@ typedef struct cfa_cmpls_cmp_data_msg {
 	 */
 	#define CFA_CMPLS_CMP_DATA_MSG_MP_CLIENT_MASK	UINT32_C(0xf0000000)
 	#define CFA_CMPLS_CMP_DATA_MSG_MP_CLIENT_SFT		28
-	/* TX configrable flow processing block. */
+	/* TX configurable flow processing block. */
 		#define CFA_CMPLS_CMP_DATA_MSG_MP_CLIENT_TE_CFA	(UINT32_C(0x2) << 28)
-	/* RX configrable flow processing block. */
+	/* RX configurable flow processing block. */
 		#define CFA_CMPLS_CMP_DATA_MSG_MP_CLIENT_RE_CFA	(UINT32_C(0x3) << 28)
 		#define CFA_CMPLS_CMP_DATA_MSG_MP_CLIENT_LAST		CFA_CMPLS_CMP_DATA_MSG_MP_CLIENT_RE_CFA
 	/*
@@ -3908,7 +4599,7 @@ typedef struct cfa_dma128b_data_msg {
 /* ce_cmpls_cmp_data_msg (size:128b/16B) */
 
 typedef struct ce_cmpls_cmp_data_msg {
-	uint16_t	status_subtype_type;
+	uint16_t	client_subtype_type;
 	/*
 	 * This field indicates the exact type of the completion. By
 	 * convention, the LSB identifies the length of the record in 16B
@@ -3920,64 +4611,77 @@ typedef struct ce_cmpls_cmp_data_msg {
 	/* Completion of a Mid Path Command. Length = 16B */
 		#define CE_CMPLS_CMP_DATA_MSG_TYPE_MID_PATH_SHORT  UINT32_C(0x1e)
 		#define CE_CMPLS_CMP_DATA_MSG_TYPE_LAST	CE_CMPLS_CMP_DATA_MSG_TYPE_MID_PATH_SHORT
+	#define CE_CMPLS_CMP_DATA_MSG_UNUSED0_MASK	UINT32_C(0xc0)
+	#define CE_CMPLS_CMP_DATA_MSG_UNUSED0_SFT	6
 	/*
 	 * This value indicates the CE sub-type operation that is being
 	 * completed.
 	 */
-	#define CE_CMPLS_CMP_DATA_MSG_SUBTYPE_MASK	UINT32_C(0x3c0)
-	#define CE_CMPLS_CMP_DATA_MSG_SUBTYPE_SFT	6
+	#define CE_CMPLS_CMP_DATA_MSG_SUBTYPE_MASK	UINT32_C(0xf00)
+	#define CE_CMPLS_CMP_DATA_MSG_SUBTYPE_SFT	8
 	/* Completion Response for a Solicited Command. */
-		#define CE_CMPLS_CMP_DATA_MSG_SUBTYPE_SOLICITED	(UINT32_C(0x0) << 6)
+		#define CE_CMPLS_CMP_DATA_MSG_SUBTYPE_SOLICITED	(UINT32_C(0x0) << 8)
 	/* Error Completion (Unsolicited). */
-		#define CE_CMPLS_CMP_DATA_MSG_SUBTYPE_ERR	(UINT32_C(0x1) << 6)
+		#define CE_CMPLS_CMP_DATA_MSG_SUBTYPE_ERR	(UINT32_C(0x1) << 8)
 	/* Re-Sync Completion (Unsolicited) */
-		#define CE_CMPLS_CMP_DATA_MSG_SUBTYPE_RESYNC	(UINT32_C(0x2) << 6)
+		#define CE_CMPLS_CMP_DATA_MSG_SUBTYPE_RESYNC	(UINT32_C(0x2) << 8)
 		#define CE_CMPLS_CMP_DATA_MSG_SUBTYPE_LAST	CE_CMPLS_CMP_DATA_MSG_SUBTYPE_RESYNC
-	/* This value indicates the status for the command. */
-	#define CE_CMPLS_CMP_DATA_MSG_STATUS_MASK	UINT32_C(0x3c00)
-	#define CE_CMPLS_CMP_DATA_MSG_STATUS_SFT	10
-	/* Completed without error. */
-		#define CE_CMPLS_CMP_DATA_MSG_STATUS_OK		(UINT32_C(0x0) << 10)
-	/* CFCK load error. */
-		#define CE_CMPLS_CMP_DATA_MSG_STATUS_CTX_LD_ERR	(UINT32_C(0x1) << 10)
-	/* FID check error. */
-		#define CE_CMPLS_CMP_DATA_MSG_STATUS_FID_CHK_ERR   (UINT32_C(0x2) << 10)
-		#define CE_CMPLS_CMP_DATA_MSG_STATUS_LAST	CE_CMPLS_CMP_DATA_MSG_STATUS_FID_CHK_ERR
-	uint8_t	unused0;
-	uint8_t	mp_clients;
-	#define CE_CMPLS_CMP_DATA_MSG_UNUSED1_MASK   UINT32_C(0xf)
-	#define CE_CMPLS_CMP_DATA_MSG_UNUSED1_SFT	0
 	/*
 	 * This field represents the Mid-Path client that generated the
 	 * completion.
 	 */
-	#define CE_CMPLS_CMP_DATA_MSG_MP_CLIENTS_MASK UINT32_C(0xf0)
-	#define CE_CMPLS_CMP_DATA_MSG_MP_CLIENTS_SFT 4
+	#define CE_CMPLS_CMP_DATA_MSG_MP_CLIENT_MASK	UINT32_C(0xf000)
+	#define CE_CMPLS_CMP_DATA_MSG_MP_CLIENT_SFT	12
 	/* TX crypto engine block. */
-		#define CE_CMPLS_CMP_DATA_MSG_MP_CLIENTS_TCE   (UINT32_C(0x0) << 4)
+		#define CE_CMPLS_CMP_DATA_MSG_MP_CLIENT_TCE	(UINT32_C(0x0) << 12)
 	/* RX crypto engine block. */
-		#define CE_CMPLS_CMP_DATA_MSG_MP_CLIENTS_RCE   (UINT32_C(0x1) << 4)
-		#define CE_CMPLS_CMP_DATA_MSG_MP_CLIENTS_LAST CE_CMPLS_CMP_DATA_MSG_MP_CLIENTS_RCE
+		#define CE_CMPLS_CMP_DATA_MSG_MP_CLIENT_RCE	(UINT32_C(0x1) << 12)
+		#define CE_CMPLS_CMP_DATA_MSG_MP_CLIENT_LAST	CE_CMPLS_CMP_DATA_MSG_MP_CLIENT_RCE
+	uint16_t	status;
+	/* This value indicates the status for the command. */
+	#define CE_CMPLS_CMP_DATA_MSG_STATUS_MASK	UINT32_C(0xf)
+	#define CE_CMPLS_CMP_DATA_MSG_STATUS_SFT	0
+	/* Completed without error. */
+		#define CE_CMPLS_CMP_DATA_MSG_STATUS_OK	UINT32_C(0x0)
+	/* CFCK load error. */
+		#define CE_CMPLS_CMP_DATA_MSG_STATUS_CTX_LD_ERR   UINT32_C(0x1)
+	/* FID check error. */
+		#define CE_CMPLS_CMP_DATA_MSG_STATUS_FID_CHK_ERR  UINT32_C(0x2)
+	/* Context kind / MP version mismatch error. */
+		#define CE_CMPLS_CMP_DATA_MSG_STATUS_CTX_VER_ERR  UINT32_C(0x3)
+	/* Unsupported Destination Connection ID Length. */
+		#define CE_CMPLS_CMP_DATA_MSG_STATUS_DST_ID_ERR   UINT32_C(0x4)
+	/*
+	 * Invalid MP Command [anything other than ADD or DELETE
+	 * triggers this for QUIC].
+	 */
+		#define CE_CMPLS_CMP_DATA_MSG_STATUS_MP_CMD_ERR   UINT32_C(0x5)
+		#define CE_CMPLS_CMP_DATA_MSG_STATUS_LAST	CE_CMPLS_CMP_DATA_MSG_STATUS_MP_CMD_ERR
+	#define CE_CMPLS_CMP_DATA_MSG_UNUSED1_MASK	UINT32_C(0xfff0)
+	#define CE_CMPLS_CMP_DATA_MSG_UNUSED1_SFT	4
 	/*
 	 * This is a copy of the opaque field from the mid path BD of this
 	 * command.
 	 */
 	uint32_t	opaque;
-	/*  */
-	uint32_t	kid_v;
+	uint32_t	v;
 	/*
 	 * This value is written by the NIC such that it will be different
 	 * for each pass through the completion queue. The even passes will
 	 * write 1. The odd passes will write 0.
 	 */
 	#define CE_CMPLS_CMP_DATA_MSG_V	UINT32_C(0x1)
+	#define CE_CMPLS_CMP_DATA_MSG_UNUSED2_MASK UINT32_C(0xfffffffe)
+	#define CE_CMPLS_CMP_DATA_MSG_UNUSED2_SFT 1
+	uint32_t	kid;
 	/*
 	 * This field is the Crypto Context ID. The KID is used to store
 	 * information used by the associated kTLS offloaded connection.
 	 */
-	#define CE_CMPLS_CMP_DATA_MSG_KID_MASK UINT32_C(0x1ffffe)
-	#define CE_CMPLS_CMP_DATA_MSG_KID_SFT 1
-	uint32_t	unused2;
+	#define CE_CMPLS_CMP_DATA_MSG_KID_MASK	UINT32_C(0xfffff)
+	#define CE_CMPLS_CMP_DATA_MSG_KID_SFT	0
+	#define CE_CMPLS_CMP_DATA_MSG_UNUSED3_MASK UINT32_C(0xfff00000)
+	#define CE_CMPLS_CMP_DATA_MSG_UNUSED3_SFT 20
 } ce_cmpls_cmp_data_msg_t, *pce_cmpls_cmp_data_msg_t;
 
 /* cmpl_base (size:128b/16B) */
@@ -4009,10 +4713,10 @@ typedef struct cmpl_base {
 	 */
 		#define CMPL_BASE_TYPE_TX_L2_COAL	UINT32_C(0x2)
 	/*
-	 * TX L2 PTP completion:
-	 * Completion of PTP TX packet. Length = 32B
+	 * TX L2 Packet Timestamp completion:
+	 * Completion of an L2 Packet Timestamp Packet. Length = 16B
 	 */
-		#define CMPL_BASE_TYPE_TX_L2_PTP	UINT32_C(0x3)
+		#define CMPL_BASE_TYPE_TX_L2_PKT_TS	UINT32_C(0x4)
 	/*
 	 * RX L2 TPA Start V2 Completion:
 	 * Completion of and L2 RX packet. Length = 32B
@@ -4027,13 +4731,19 @@ typedef struct cmpl_base {
 	 * and later chips.
 	 */
 		#define CMPL_BASE_TYPE_RX_L2_V2	UINT32_C(0xf)
+	/*
+	 * RX L2 completion:
+	 * This is the compressed version of Rx Completion for performance
+	 * applications. Length = 16B
+	 */
+		#define CMPL_BASE_TYPE_RX_L2_COMPRESS	UINT32_C(0x10)
 	/*
 	 * RX L2 completion:
 	 * Completion of and L2 RX packet. Length = 32B
 	 */
 		#define CMPL_BASE_TYPE_RX_L2		UINT32_C(0x11)
 	/*
-	 * RX Aggregation Buffer completion :
+	 * RX Aggregation Buffer completion:
 	 * Completion of an L2 aggregation buffer in support of
 	 * TPA, HDS, or Jumbo packet completion. Length = 16B
 	 */
@@ -4050,6 +4760,24 @@ typedef struct cmpl_base {
 	 * Length = 32B
 	 */
 		#define CMPL_BASE_TYPE_RX_TPA_END	UINT32_C(0x15)
+	/*
+	 * RX TPA Aggregation Buffer Completion:
+	 * Completion of an L2 aggregation buffer in support of TPA packet
+	 * completion.
+	 * Length = 16B
+	 */
+		#define CMPL_BASE_TYPE_RX_TPA_AGG	UINT32_C(0x16)
+	/*
+	 * RX L2 completion: Completion of and L2 RX packet.
+	 * Length = 32B
+	 */
+		#define CMPL_BASE_TYPE_RX_L2_V3	UINT32_C(0x17)
+	/*
+	 * RX L2 TPA Start completion: Completion at the beginning of a TPA
+	 * operation.
+	 * Length = 32B
+	 */
+		#define CMPL_BASE_TYPE_RX_TPA_START_V3   UINT32_C(0x19)
 	/*
 	 * Statistics Ejection Completion:
 	 * Completion of statistics data ejection buffer.
@@ -4215,7 +4943,7 @@ typedef struct tx_cmpl {
 	 */
 	#define TX_CMPL_ERRORS_INTERNAL_ERROR		UINT32_C(0x200)
 	/*
-	 * When this bit is '1', it was not possible to collect a a timestamp
+	 * When this bit is '1', it was not possible to collect a timestamp
 	 * for a PTP completion, in which case the timestamp_hi and
 	 * timestamp_lo fields are invalid. When this bit is '0' for a PTP
 	 * completion, the timestamp_hi and timestamp_lo fields are valid.
@@ -4361,48 +5089,76 @@ typedef struct tx_cmpl_coal {
 	#define TX_CMPL_COAL_SQ_CONS_IDX_SFT 0
 } tx_cmpl_coal_t, *ptx_cmpl_coal_t;
 
-/* tx_cmpl_ptp (size:128b/16B) */
+/* tx_cmpl_packet_timestamp (size:128b/16B) */
 
-typedef struct tx_cmpl_ptp {
-	uint16_t	flags_type;
+typedef struct tx_cmpl_packet_timestamp {
+	uint16_t	ts_sub_ns_flags_type;
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * This field indicates the exact type of the completion. By
+	 * convention, the LSB identifies the length of the record in 16B
+	 * units. Even values indicate 16B records. Odd values indicate
+	 * 32B records.
 	 */
-	#define TX_CMPL_PTP_TYPE_MASK	UINT32_C(0x3f)
-	#define TX_CMPL_PTP_TYPE_SFT	0
+	#define TX_CMPL_PACKET_TIMESTAMP_TYPE_MASK		UINT32_C(0x3f)
+	#define TX_CMPL_PACKET_TIMESTAMP_TYPE_SFT		0
 	/*
-	 * TX L2 PTP completion:
-	 * Completion of TX packet. Length = 32B
+	 * TX L2 Packet Timestamp completion:
+	 * Completion of an L2 Packet Timestamp Packet. Length = 16B
 	 */
-		#define TX_CMPL_PTP_TYPE_TX_L2_PTP	UINT32_C(0x2)
-		#define TX_CMPL_PTP_TYPE_LAST	TX_CMPL_PTP_TYPE_TX_L2_PTP
-	#define TX_CMPL_PTP_FLAGS_MASK	UINT32_C(0xffc0)
-	#define TX_CMPL_PTP_FLAGS_SFT	6
+		#define TX_CMPL_PACKET_TIMESTAMP_TYPE_TX_L2_PKT_TS	UINT32_C(0x4)
+		#define TX_CMPL_PACKET_TIMESTAMP_TYPE_LAST		TX_CMPL_PACKET_TIMESTAMP_TYPE_TX_L2_PKT_TS
+	#define TX_CMPL_PACKET_TIMESTAMP_FLAGS_MASK		UINT32_C(0xfc0)
+	#define TX_CMPL_PACKET_TIMESTAMP_FLAGS_SFT		6
 	/*
-	 * When this bit is '1', it indicates a packet that has an
-	 * error of some type. Type of error is indicated in
-	 * error_flags.
+	 * When this bit is '1', it indicates a packet that has an error
+	 * of some type. Type of error is indicated in error_flags.
 	 */
-	#define TX_CMPL_PTP_FLAGS_ERROR	UINT32_C(0x40)
+	#define TX_CMPL_PACKET_TIMESTAMP_FLAGS_ERROR		UINT32_C(0x40)
 	/*
-	 * When this bit is '1', it indicates that the packet completed
-	 * was transmitted using the push acceleration data provided
-	 * by the driver. When this bit is '0', it indicates that the
-	 * packet had not push acceleration data written or was executed
-	 * as a normal packet even though push data was provided.
+	 * This field indicates the TX packet timestamp type that is
+	 * represented by a TX Packet Timestamp Completion. Note that
+	 * this field is invalid if the timestamp_invalid_error flag
+	 * is set.
 	 */
-	#define TX_CMPL_PTP_FLAGS_PUSH	UINT32_C(0x80)
-	/* unused1 is 16 b */
-	uint16_t	unused_0;
+	#define TX_CMPL_PACKET_TIMESTAMP_FLAGS_TS_TYPE	UINT32_C(0x80)
+	/* The packet timestamp came from PM. */
+		#define TX_CMPL_PACKET_TIMESTAMP_FLAGS_TS_TYPE_TS_PM	(UINT32_C(0x0) << 7)
+	/* The packet timestamp came from PA. */
+		#define TX_CMPL_PACKET_TIMESTAMP_FLAGS_TS_TYPE_TS_PA	(UINT32_C(0x1) << 7)
+		#define TX_CMPL_PACKET_TIMESTAMP_FLAGS_TS_TYPE_LAST	TX_CMPL_PACKET_TIMESTAMP_FLAGS_TS_TYPE_TS_PA
+	/*
+	 * This flag indicates that the timestamp should have come from PM,
+	 * but came instead from PA because all PM timestamp resources were
+	 * in use. This can occur in the following circumstances:
+	 * 1. The BD specified ts_2cmpl_auto and the packet was a PTP packet
+	 *	but PA could not request a PM timestamp
+	 * 2. The BD specified ts_2cmpl_pm, but PA could not request a PM
+	 *	timestamp
+	 */
+	#define TX_CMPL_PACKET_TIMESTAMP_FLAGS_TS_FALLBACK	UINT32_C(0x100)
+	/*
+	 * For 2-step PTP timestamps, bits[3:0] of this field represent the
+	 * sub-nanosecond portion of the packet timestamp, returned from PM
+	 * for 2-step PTP timestamps. For PA timestamps, this field also
+	 * represents the sub-nanosecond portion of the packet timestamp;
+	 * however, due to synchronization uncertainties, the accuracy of
+	 * PA timestamps is limited to approximately +/- 4 ns. Therefore
+	 * this field is of dubious value for PA timestamps.
+	 */
+	#define TX_CMPL_PACKET_TIMESTAMP_TS_SUB_NS_MASK	UINT32_C(0xf000)
+	#define TX_CMPL_PACKET_TIMESTAMP_TS_SUB_NS_SFT	12
+	/*
+	 * This is bits [47:32] of the nanoseconds portion of the packet
+	 * timestamp, returned from PM for 2-step PTP timestamps or from
+	 * PA for PA timestamps. This field is in units of 2^32 ns.
+	 */
+	uint16_t	ts_ns_mid;
 	/*
 	 * This is a copy of the opaque field from the first TX BD of this
-	 * transmitted packet. Note that, if the packet was described by a short
-	 * CSO or short CSO inline BD, then the 16-bit opaque field from the
-	 * short CSO BD will appear in the bottom 16 bits of this field.
+	 * transmitted packet. Note that, if the packet was described by a
+	 * short CSO or short CSO inline BD, then the 16-bit opaque field
+	 * from the short CSO BD will appear in the bottom 16 bits of this
+	 * field.
 	 */
 	uint32_t	opaque;
 	uint16_t	errors_v;
@@ -4411,93 +5167,90 @@ typedef struct tx_cmpl_ptp {
 	 * for each pass through the completion queue. The even passes
 	 * will write 1. The odd passes will write 0.
 	 */
-	#define TX_CMPL_PTP_V				UINT32_C(0x1)
-	#define TX_CMPL_PTP_ERRORS_MASK			UINT32_C(0xfffe)
-	#define TX_CMPL_PTP_ERRORS_SFT			1
-	/*
-	 * This error indicates that there was some sort of problem
-	 * with the BDs for the packet.
-	 */
-	#define TX_CMPL_PTP_ERRORS_BUFFER_ERROR_MASK		UINT32_C(0xe)
-	#define TX_CMPL_PTP_ERRORS_BUFFER_ERROR_SFT		1
-	/* No error */
-		#define TX_CMPL_PTP_ERRORS_BUFFER_ERROR_NO_ERROR	(UINT32_C(0x0) << 1)
+	#define TX_CMPL_PACKET_TIMESTAMP_V				UINT32_C(0x1)
+	#define TX_CMPL_PACKET_TIMESTAMP_ERRORS_MASK			UINT32_C(0xfffe)
+	#define TX_CMPL_PACKET_TIMESTAMP_ERRORS_SFT			1
 	/*
-	 * Bad Format:
-	 * BDs were not formatted correctly.
+	 * This field was previously used to indicate fatal errors, which
+	 * now result in aborting and bringing down the ring. This field
+	 * is deprecated.
 	 */
-		#define TX_CMPL_PTP_ERRORS_BUFFER_ERROR_BAD_FMT	(UINT32_C(0x2) << 1)
-		#define TX_CMPL_PTP_ERRORS_BUFFER_ERROR_LAST		TX_CMPL_PTP_ERRORS_BUFFER_ERROR_BAD_FMT
+	#define TX_CMPL_PACKET_TIMESTAMP_ERRORS_BUFFER_ERROR_MASK		UINT32_C(0xe)
+	#define TX_CMPL_PACKET_TIMESTAMP_ERRORS_BUFFER_ERROR_SFT		1
+	/* No error. */
+		#define TX_CMPL_PACKET_TIMESTAMP_ERRORS_BUFFER_ERROR_NO_ERROR	(UINT32_C(0x0) << 1)
+	/* Deprecated. */
+		#define TX_CMPL_PACKET_TIMESTAMP_ERRORS_BUFFER_ERROR_BAD_FMT	(UINT32_C(0x2) << 1)
+		#define TX_CMPL_PACKET_TIMESTAMP_ERRORS_BUFFER_ERROR_LAST		TX_CMPL_PACKET_TIMESTAMP_ERRORS_BUFFER_ERROR_BAD_FMT
 	/*
-	 * When this bit is '1', it indicates that the length of
-	 * the packet was zero. No packet was transmitted.
+	 * This error is fatal and results in aborting and bringing down the
+	 * ring, thus is deprecated.
 	 */
-	#define TX_CMPL_PTP_ERRORS_ZERO_LENGTH_PKT		UINT32_C(0x10)
+	#define TX_CMPL_PACKET_TIMESTAMP_ERRORS_ZERO_LENGTH_PKT		UINT32_C(0x10)
 	/*
-	 * When this bit is '1', it indicates that the packet
-	 * was longer than the programmed limit in TDI. No
-	 * packet was transmitted.
+	 * This error is fatal and results in aborting and bringing down the
+	 * ring, thus is deprecated.
 	 */
-	#define TX_CMPL_PTP_ERRORS_EXCESSIVE_BD_LENGTH	UINT32_C(0x20)
+	#define TX_CMPL_PACKET_TIMESTAMP_ERRORS_EXCESSIVE_BD_LENGTH	UINT32_C(0x20)
 	/*
-	 * When this bit is '1', it indicates that one or more of the
-	 * BDs associated with this packet generated a PCI error.
-	 * This probably means the address was not valid.
-	 */
-	#define TX_CMPL_PTP_ERRORS_DMA_ERROR			UINT32_C(0x40)
-	/*
-	 * When this bit is '1', it indicates that the packet was longer
-	 * than indicated by the hint. No packet was transmitted.
+	 * When this bit is '1', it indicates that one or more of the BDs
+	 * associated with this packet generated a PCI error when accessing
+	 * header/payload data from host memory. It most likely indicates
+	 * that the address was not valid. Note that this bit has no meaning
+	 * for the timestamp completion and will always be '0'.
 	 */
-	#define TX_CMPL_PTP_ERRORS_HINT_TOO_SHORT		UINT32_C(0x80)
+	#define TX_CMPL_PACKET_TIMESTAMP_ERRORS_DMA_ERROR			UINT32_C(0x40)
 	/*
-	 * When this bit is '1', it indicates that the packet was
-	 * dropped due to Poison TLP error on one or more of the
-	 * TLPs in the PXP completion.
+	 * This error is fatal and results in aborting and bringing down the
+	 * ring, thus is deprecated.
 	 */
-	#define TX_CMPL_PTP_ERRORS_POISON_TLP_ERROR		UINT32_C(0x100)
+	#define TX_CMPL_PACKET_TIMESTAMP_ERRORS_HINT_TOO_SHORT		UINT32_C(0x80)
 	/*
-	 * When this bit is '1', it indicates that the packet was dropped due
-	 * to a transient internal error in TDC. The packet or LSO can be
-	 * retried and may transmit successfully on a subsequent attempt.
+	 * When this bit is '1', it indicates that the packet was dropped
+	 * due to Poison TLP error on one or more of the TLPs in one or more
+	 * of the associated PXP completion(s) when accessing header/payload
+	 * data from host memory. Note that this bit has no meaning for the
+	 * timestamp completion, and will always be '0'.
 	 */
-	#define TX_CMPL_PTP_ERRORS_INTERNAL_ERROR		UINT32_C(0x200)
+	#define TX_CMPL_PACKET_TIMESTAMP_ERRORS_POISON_TLP_ERROR		UINT32_C(0x100)
 	/*
-	 * When this bit is '1', it was not possible to collect a a timestamp
-	 * for a PTP completion, in which case the timestamp_hi and
-	 * timestamp_lo fields are invalid. When this bit is '0' for a PTP
-	 * completion, the timestamp_hi and timestamp_lo fields are valid.
-	 * RJRN will copy the value of this bit into the field of the same
-	 * name in all TX completions, regardless of whether such
-	 * completions are PTP completions or other TX completions.
-	 */
-	#define TX_CMPL_PTP_ERRORS_TIMESTAMP_INVALID_ERROR	UINT32_C(0x400)
+	 * When this bit is '1', it indicates that the packet was dropped
+	 * due to a transient internal error in TDC. The packet or LSO can
+	 * be retried and may transmit successfully on a subsequent attempt.
+	 * Note that this bit has no meaning for the timestamp completion
+	 * and will always be '0'.
+	 */
+	#define TX_CMPL_PACKET_TIMESTAMP_ERRORS_INTERNAL_ERROR		UINT32_C(0x200)
+	/*
+	 * When this bit is '1', it was not possible to collect a timestamp
+	 * for a timestamp completion, in which case the ts_ns and ts_sub_ns
+	 * fields are invalid. When this bit is '0' in a timestamp
+	 * completion record, the ts_sub_ns, ts_ns_lo, and ts_ns_mid fields
+	 * are valid. Note that this bit has meaning only for the timestamp
+	 * completion. For types other than the timestamp completion, this
+	 * bit will always be '0'.
+	 */
+	#define TX_CMPL_PACKET_TIMESTAMP_ERRORS_TIMESTAMP_INVALID_ERROR	UINT32_C(0x400)
+	/*
+	 * When this bit is '1', it indicates that a Timed Transmit
+	 * SO-TXTIME packet violated the max_ttx_overtime constraint i.e.,
+	 * the time the packet was processed for transmission in TWE was
+	 * later than the time given by (TimedTx_BD.tx_time +
+	 * max_ttx_overtime) and as result, the packet was dropped.
+	 * Note that max_ttx_overtime is a global configuration in TWE.
+	 * Note that this bit has no meaning in a timestamp completion,
+	 * and will always be '0'.
+	 */
+	#define TX_CMPL_PACKET_TIMESTAMP_ERRORS_TTX_OVERTIME_ERROR	UINT32_C(0x800)
 	/* unused2 is 16 b */
-	uint16_t	unused_1;
-	/*
-	 * This is timestamp value (lower 32bits) read from PM for the PTP
-	 * timestamp enabled packet.
-	 */
-	uint32_t	timestamp_lo;
-} tx_cmpl_ptp_t, *ptx_cmpl_ptp_t;
-
-/* tx_cmpl_ptp_hi (size:128b/16B) */
-
-typedef struct tx_cmpl_ptp_hi {
-	/*
-	 * This is timestamp value (lower 32bits) read from PM for the PTP
-	 * timestamp enabled packet.
-	 */
-	uint16_t	timestamp_hi[3];
-	uint16_t	reserved16;
-	uint64_t	v2;
+	uint16_t	unused_2;
 	/*
-	 * This value is written by the NIC such that it will be different for
-	 * each pass through the completion queue.The even passes will write 1.
-	 * The odd passes will write 0
+	 * This is bits [31:0] of the nanoseconds portion of the packet
+	 * timestamp, returned from PM for 2-step PTP timestamp or from
+	 * PA for PA timestamps. This field is in units of ns.
 	 */
-	#define TX_CMPL_PTP_HI_V2	UINT32_C(0x1)
-} tx_cmpl_ptp_hi_t, *ptx_cmpl_ptp_hi_t;
+	uint32_t	ts_ns_lo;
+} tx_cmpl_packet_timestamp_t, *ptx_cmpl_packet_timestamp_t;
 
 /* rx_pkt_cmpl (size:128b/16B) */
 
@@ -4510,7 +5263,7 @@ typedef struct rx_pkt_cmpl {
 	 * records. Odd values indicate 32B
 	 * records.
 	 */
-	#define RX_PKT_CMPL_TYPE_MASK		UINT32_C(0x3f)
+	#define RX_PKT_CMPL_TYPE_MASK			UINT32_C(0x3f)
 	#define RX_PKT_CMPL_TYPE_SFT			0
 	/*
 	 * RX L2 completion:
@@ -4518,38 +5271,41 @@ typedef struct rx_pkt_cmpl {
 	 */
 		#define RX_PKT_CMPL_TYPE_RX_L2			UINT32_C(0x11)
 		#define RX_PKT_CMPL_TYPE_LAST			RX_PKT_CMPL_TYPE_RX_L2
-	#define RX_PKT_CMPL_FLAGS_MASK		UINT32_C(0xffc0)
-	#define RX_PKT_CMPL_FLAGS_SFT		6
+	#define RX_PKT_CMPL_FLAGS_MASK			UINT32_C(0xffc0)
+	#define RX_PKT_CMPL_FLAGS_SFT			6
 	/*
 	 * When this bit is '1', it indicates a packet that has an
 	 * error of some type. Type of error is indicated in
 	 * error_flags.
 	 */
-	#define RX_PKT_CMPL_FLAGS_ERROR		UINT32_C(0x40)
+	#define RX_PKT_CMPL_FLAGS_ERROR			UINT32_C(0x40)
 	/* This field indicates how the packet was placed in the buffer. */
-	#define RX_PKT_CMPL_FLAGS_PLACEMENT_MASK	UINT32_C(0x380)
-	#define RX_PKT_CMPL_FLAGS_PLACEMENT_SFT	7
+	#define RX_PKT_CMPL_FLAGS_PLACEMENT_MASK		UINT32_C(0x380)
+	#define RX_PKT_CMPL_FLAGS_PLACEMENT_SFT		7
 	/*
 	 * Normal:
 	 * Packet was placed using normal algorithm.
 	 */
-		#define RX_PKT_CMPL_FLAGS_PLACEMENT_NORMAL	(UINT32_C(0x0) << 7)
+		#define RX_PKT_CMPL_FLAGS_PLACEMENT_NORMAL		(UINT32_C(0x0) << 7)
 	/*
 	 * Jumbo:
 	 * Packet was placed using jumbo algorithm.
 	 */
-		#define RX_PKT_CMPL_FLAGS_PLACEMENT_JUMBO	(UINT32_C(0x1) << 7)
+		#define RX_PKT_CMPL_FLAGS_PLACEMENT_JUMBO		(UINT32_C(0x1) << 7)
 	/*
 	 * Header/Data Separation:
 	 * Packet was placed using Header/Data separation algorithm.
 	 * The separation location is indicated by the itype field.
 	 */
 		#define RX_PKT_CMPL_FLAGS_PLACEMENT_HDS		(UINT32_C(0x2) << 7)
-		#define RX_PKT_CMPL_FLAGS_PLACEMENT_LAST	RX_PKT_CMPL_FLAGS_PLACEMENT_HDS
+		#define RX_PKT_CMPL_FLAGS_PLACEMENT_LAST		RX_PKT_CMPL_FLAGS_PLACEMENT_HDS
 	/* This bit is '1' if the RSS field in this completion is valid. */
 	#define RX_PKT_CMPL_FLAGS_RSS_VALID		UINT32_C(0x400)
-	/* unused is 1 b */
-	#define RX_PKT_CMPL_FLAGS_UNUSED		UINT32_C(0x800)
+	/*
+	 * This bit is '1' if metadata has been added to the end of the
+	 * packet in host memory.
+	 */
+	#define RX_PKT_CMPL_FLAGS_PKT_METADATA_PRESENT	UINT32_C(0x800)
 	/*
 	 * This value indicates what the inner packet determined for the
 	 * packet was.
@@ -4560,13 +5316,13 @@ typedef struct rx_pkt_cmpl {
 	 * Not Known:
 	 * Indicates that the packet type was not known.
 	 */
-		#define RX_PKT_CMPL_FLAGS_ITYPE_NOT_KNOWN	(UINT32_C(0x0) << 12)
+		#define RX_PKT_CMPL_FLAGS_ITYPE_NOT_KNOWN		(UINT32_C(0x0) << 12)
 	/*
 	 * IP Packet:
 	 * Indicates that the packet was an IP packet, but further
 	 * classification was not possible.
 	 */
-		#define RX_PKT_CMPL_FLAGS_ITYPE_IP		(UINT32_C(0x1) << 12)
+		#define RX_PKT_CMPL_FLAGS_ITYPE_IP			(UINT32_C(0x1) << 12)
 	/*
 	 * TCP Packet:
 	 * Indicates that the packet was IP and TCP.
@@ -4598,14 +5354,14 @@ typedef struct rx_pkt_cmpl {
 	 */
 		#define RX_PKT_CMPL_FLAGS_ITYPE_ICMP		(UINT32_C(0x7) << 12)
 	/*
-	 * PtP packet wo/timestamp:
-	 * Indicates that the packet was recognized as a PtP
+	 * PTP packet wo/timestamp:
+	 * Indicates that the packet was recognized as a PTP
 	 * packet.
 	 */
-		#define RX_PKT_CMPL_FLAGS_ITYPE_PTP_WO_TIMESTAMP   (UINT32_C(0x8) << 12)
+		#define RX_PKT_CMPL_FLAGS_ITYPE_PTP_WO_TIMESTAMP	(UINT32_C(0x8) << 12)
 	/*
-	 * PtP packet w/timestamp:
-	 * Indicates that the packet was recognized as a PtP
+	 * PTP packet w/timestamp:
+	 * Indicates that the packet was recognized as a PTP
 	 * packet and that a timestamp was taken for the packet.
 	 */
 		#define RX_PKT_CMPL_FLAGS_ITYPE_PTP_W_TIMESTAMP	(UINT32_C(0x9) << 12)
@@ -4643,37 +5399,48 @@ typedef struct rx_pkt_cmpl {
 	/*
 	 * This is the RSS hash type for the packet. The value is packed
 	 * {tuple_extrac_op[1:0],rss_profile_id[4:0],tuple_extrac_op[2]}.
-	 *
 	 * The value of tuple_extrac_op provides the information about
 	 * what fields the hash was computed on.
-	 * * 0: The RSS hash was computed over source IP address,
+	 * Note that 4-tuples values listed below are applicable
+	 * for layer 4 protocols supported and enabled for RSS in the hardware,
+	 * HWRM firmware, and drivers. For example, if RSS hash is supported and
+	 * enabled for TCP traffic only, then the values of tuple_extract_op
+	 * corresponding to 4-tuples are only valid for TCP traffic.
+	 */
+	uint8_t	rss_hash_type;
+	/*
+	 * The RSS hash was computed over source IP address,
 	 * destination IP address, source port, and destination port of inner
 	 * IP and TCP or UDP headers. Note: For non-tunneled packets,
 	 * the packet headers are considered inner packet headers for the RSS
 	 * hash computation purpose.
-	 * * 1: The RSS hash was computed over source IP address and destination
+	 */
+	#define RX_PKT_CMPL_RSS_HASH_TYPE_ENUM_0 UINT32_C(0x0)
+	/*
+	 * The RSS hash was computed over source IP address and destination
 	 * IP address of inner IP header. Note: For non-tunneled packets,
 	 * the packet headers are considered inner packet headers for the RSS
 	 * hash computation purpose.
-	 * * 2: The RSS hash was computed over source IP address,
+	 */
+	#define RX_PKT_CMPL_RSS_HASH_TYPE_ENUM_1 UINT32_C(0x1)
+	/*
+	 * The RSS hash was computed over source IP address,
 	 * destination IP address, source port, and destination port of
 	 * IP and TCP or UDP headers of outer tunnel headers.
 	 * Note: For non-tunneled packets, this value is not applicable.
-	 * * 3: The RSS hash was computed over source IP address and
+	 */
+	#define RX_PKT_CMPL_RSS_HASH_TYPE_ENUM_2 UINT32_C(0x2)
+	/*
+	 * The RSS hash was computed over source IP address and
 	 * destination IP address of IP header of outer tunnel headers.
 	 * Note: For non-tunneled packets, this value is not applicable.
-	 *
-	 * Note that 4-tuples values listed above are applicable
-	 * for layer 4 protocols supported and enabled for RSS in the hardware,
-	 * HWRM firmware, and drivers. For example, if RSS hash is supported and
-	 * enabled for TCP traffic only, then the values of tuple_extract_op
-	 * corresponding to 4-tuples are only valid for TCP traffic.
 	 */
-	uint8_t	rss_hash_type;
+	#define RX_PKT_CMPL_RSS_HASH_TYPE_ENUM_3 UINT32_C(0x3)
+	#define RX_PKT_CMPL_RSS_HASH_TYPE_LAST  RX_PKT_CMPL_RSS_HASH_TYPE_ENUM_3
 	/*
-	 * This value indicates the offset in bytes from the beginning of the packet
-	 * where the inner payload starts. This value is valid for TCP, UDP,
-	 * FCoE, and RoCE packets.
+	 * This value indicates the offset in bytes from the beginning of the
+	 * packet where the inner payload starts. This value is valid for TCP,
+	 * UDP, FCoE, and RoCE packets.
 	 *
 	 * A value of zero indicates that header is 256B into the packet.
 	 */
@@ -5108,14 +5875,14 @@ typedef struct rx_pkt_v2_cmpl {
 	 */
 		#define RX_PKT_V2_CMPL_FLAGS_ITYPE_ICMP		(UINT32_C(0x7) << 12)
 	/*
-	 * PtP packet wo/timestamp:
-	 * Indicates that the packet was recognized as a PtP
+	 * PTP packet wo/timestamp:
+	 * Indicates that the packet was recognized as a PTP
 	 * packet.
 	 */
 		#define RX_PKT_V2_CMPL_FLAGS_ITYPE_PTP_WO_TIMESTAMP	(UINT32_C(0x8) << 12)
 	/*
-	 * PtP packet w/timestamp:
-	 * Indicates that the packet was recognized as a PtP
+	 * PTP packet w/timestamp:
+	 * Indicates that the packet was recognized as a PTP
 	 * packet and that a timestamp was taken for the packet.
 	 */
 		#define RX_PKT_V2_CMPL_FLAGS_ITYPE_PTP_W_TIMESTAMP	(UINT32_C(0x9) << 12)
@@ -5153,33 +5920,44 @@ typedef struct rx_pkt_v2_cmpl {
 	/*
 	 * This is the RSS hash type for the packet. The value is packed
 	 * {tuple_extrac_op[1:0],rss_profile_id[4:0],tuple_extrac_op[2]}.
-	 *
 	 * The value of tuple_extrac_op provides the information about
 	 * what fields the hash was computed on.
-	 * * 0: The RSS hash was computed over source IP address,
+	 * Note that 4-tuples values listed below are applicable
+	 * for layer 4 protocols supported and enabled for RSS in the hardware,
+	 * HWRM firmware, and drivers. For example, if RSS hash is supported and
+	 * enabled for TCP traffic only, then the values of tuple_extract_op
+	 * corresponding to 4-tuples are only valid for TCP traffic.
+	 */
+	uint8_t	rss_hash_type;
+	/*
+	 * The RSS hash was computed over source IP address,
 	 * destination IP address, source port, and destination port of inner
 	 * IP and TCP or UDP headers. Note: For non-tunneled packets,
 	 * the packet headers are considered inner packet headers for the RSS
 	 * hash computation purpose.
-	 * * 1: The RSS hash was computed over source IP address and destination
+	 */
+	#define RX_PKT_V2_CMPL_RSS_HASH_TYPE_ENUM_0 UINT32_C(0x0)
+	/*
+	 * The RSS hash was computed over source IP address and destination
 	 * IP address of inner IP header. Note: For non-tunneled packets,
 	 * the packet headers are considered inner packet headers for the RSS
 	 * hash computation purpose.
-	 * * 2: The RSS hash was computed over source IP address,
+	 */
+	#define RX_PKT_V2_CMPL_RSS_HASH_TYPE_ENUM_1 UINT32_C(0x1)
+	/*
+	 * The RSS hash was computed over source IP address,
 	 * destination IP address, source port, and destination port of
 	 * IP and TCP or UDP headers of outer tunnel headers.
 	 * Note: For non-tunneled packets, this value is not applicable.
-	 * * 3: The RSS hash was computed over source IP address and
+	 */
+	#define RX_PKT_V2_CMPL_RSS_HASH_TYPE_ENUM_2 UINT32_C(0x2)
+	/*
+	 * The RSS hash was computed over source IP address and
 	 * destination IP address of IP header of outer tunnel headers.
 	 * Note: For non-tunneled packets, this value is not applicable.
-	 *
-	 * Note that 4-tuples values listed above are applicable
-	 * for layer 4 protocols supported and enabled for RSS in the hardware,
-	 * HWRM firmware, and drivers. For example, if RSS hash is supported and
-	 * enabled for TCP traffic only, then the values of tuple_extract_op
-	 * corresponding to 4-tuples are only valid for TCP traffic.
 	 */
-	uint8_t	rss_hash_type;
+	#define RX_PKT_V2_CMPL_RSS_HASH_TYPE_ENUM_3 UINT32_C(0x3)
+	#define RX_PKT_V2_CMPL_RSS_HASH_TYPE_LAST  RX_PKT_V2_CMPL_RSS_HASH_TYPE_ENUM_3
 	uint16_t	metadata1_payload_offset;
 	/*
 	 * This is data from the CFA as indicated by the meta_format field.
@@ -5261,7 +6039,7 @@ typedef struct rx_pkt_v2_cmpl_hi {
 	 * information:
 	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0], de, vid[11:0]}
 	 * The metadata2 field contains the Tunnel ID
-	 * value, justified to LSB. i
+	 * value, justified to LSB.
 	 * - VXLAN = VNI[23:0] -> VXLAN Network ID
 	 * - Geneve (NGE) = VNI[23:0] a-> Virtual Network Identifier
 	 * - NVGRE = TNI[23:0] -> Tenant Network ID
@@ -5570,13 +6348,9 @@ typedef struct rx_pkt_v2_cmpl_hi {
 	uint32_t	timestamp;
 } rx_pkt_v2_cmpl_hi_t, *prx_pkt_v2_cmpl_hi_t;
 
-/*
- * This TPA completion structure is used on devices where the
- * `hwrm_vnic_qcaps.max_aggs_supported` value is 0.
- */
-/* rx_tpa_start_cmpl (size:128b/16B) */
+/* rx_pkt_v3_cmpl (size:128b/16B) */
 
-typedef struct rx_tpa_start_cmpl {
+typedef struct rx_pkt_v3_cmpl {
 	uint16_t	flags_type;
 	/*
 	 * This field indicates the exact type of the completion.
@@ -5585,76 +6359,129 @@ typedef struct rx_tpa_start_cmpl {
 	 * records. Odd values indicate 32B
 	 * records.
 	 */
-	#define RX_TPA_START_CMPL_TYPE_MASK		UINT32_C(0x3f)
-	#define RX_TPA_START_CMPL_TYPE_SFT		0
+	#define RX_PKT_V3_CMPL_TYPE_MASK			UINT32_C(0x3f)
+	#define RX_PKT_V3_CMPL_TYPE_SFT			0
 	/*
-	 * RX L2 TPA Start Completion:
-	 * Completion at the beginning of a TPA operation.
-	 * Length = 32B
+	 * RX L2 V3 completion:
+	 * Completion of and L2 RX packet. Length = 32B
+	 * This is the new version of the RX_L2 completion used in Thor2
+	 * and later chips.
 	 */
-		#define RX_TPA_START_CMPL_TYPE_RX_TPA_START	UINT32_C(0x13)
-		#define RX_TPA_START_CMPL_TYPE_LAST		RX_TPA_START_CMPL_TYPE_RX_TPA_START
-	#define RX_TPA_START_CMPL_FLAGS_MASK		UINT32_C(0xffc0)
-	#define RX_TPA_START_CMPL_FLAGS_SFT		6
-	/* This bit will always be '0' for TPA start completions. */
-	#define RX_TPA_START_CMPL_FLAGS_ERROR		UINT32_C(0x40)
+		#define RX_PKT_V3_CMPL_TYPE_RX_L2_V3			UINT32_C(0x17)
+		#define RX_PKT_V3_CMPL_TYPE_LAST			RX_PKT_V3_CMPL_TYPE_RX_L2_V3
+	#define RX_PKT_V3_CMPL_FLAGS_MASK			UINT32_C(0xffc0)
+	#define RX_PKT_V3_CMPL_FLAGS_SFT			6
+	/*
+	 * When this bit is '1', it indicates a packet that has an
+	 * error of some type. Type of error is indicated in
+	 * error_flags.
+	 */
+	#define RX_PKT_V3_CMPL_FLAGS_ERROR			UINT32_C(0x40)
 	/* This field indicates how the packet was placed in the buffer. */
-	#define RX_TPA_START_CMPL_FLAGS_PLACEMENT_MASK	UINT32_C(0x380)
-	#define RX_TPA_START_CMPL_FLAGS_PLACEMENT_SFT	7
+	#define RX_PKT_V3_CMPL_FLAGS_PLACEMENT_MASK		UINT32_C(0x380)
+	#define RX_PKT_V3_CMPL_FLAGS_PLACEMENT_SFT		7
+	/*
+	 * Normal:
+	 * Packet was placed using normal algorithm.
+	 */
+		#define RX_PKT_V3_CMPL_FLAGS_PLACEMENT_NORMAL		(UINT32_C(0x0) << 7)
 	/*
 	 * Jumbo:
-	 * TPA Packet was placed using jumbo algorithm. This means
-	 * that the first buffer will be filled with data before
-	 * moving to aggregation buffers. Each aggregation buffer
-	 * will be filled before moving to the next aggregation
-	 * buffer.
+	 * Packet was placed using jumbo algorithm.
 	 */
-		#define RX_TPA_START_CMPL_FLAGS_PLACEMENT_JUMBO	(UINT32_C(0x1) << 7)
+		#define RX_PKT_V3_CMPL_FLAGS_PLACEMENT_JUMBO		(UINT32_C(0x1) << 7)
 	/*
 	 * Header/Data Separation:
 	 * Packet was placed using Header/Data separation algorithm.
 	 * The separation location is indicated by the itype field.
 	 */
-		#define RX_TPA_START_CMPL_FLAGS_PLACEMENT_HDS	(UINT32_C(0x2) << 7)
+		#define RX_PKT_V3_CMPL_FLAGS_PLACEMENT_HDS		(UINT32_C(0x2) << 7)
 	/*
-	 * GRO/Jumbo:
-	 * Packet will be placed using GRO/Jumbo where the first
-	 * packet is filled with data. Subsequent packets will be
-	 * placed such that any one packet does not span two
-	 * aggregation buffers unless it starts at the beginning of
-	 * an aggregation buffer.
+	 * Truncation:
+	 * Packet was placed using truncation algorithm. The
+	 * placed (truncated) length is indicated in the payload_offset
+	 * field. The original length is indicated in the len field.
 	 */
-		#define RX_TPA_START_CMPL_FLAGS_PLACEMENT_GRO_JUMBO   (UINT32_C(0x5) << 7)
+		#define RX_PKT_V3_CMPL_FLAGS_PLACEMENT_TRUNCATION	(UINT32_C(0x3) << 7)
+		#define RX_PKT_V3_CMPL_FLAGS_PLACEMENT_LAST		RX_PKT_V3_CMPL_FLAGS_PLACEMENT_TRUNCATION
+	/* This bit is '1' if the RSS field in this completion is valid. */
+	#define RX_PKT_V3_CMPL_FLAGS_RSS_VALID		UINT32_C(0x400)
 	/*
-	 * GRO/Header-Data Separation:
-	 * Packet will be placed using GRO/HDS where the header
-	 * is in the first packet.
-	 * Payload of each packet will be
-	 * placed such that any one packet does not span two
-	 * aggregation buffers unless it starts at the beginning of
-	 * an aggregation buffer.
+	 * This bit is '1' if metadata has been added to the end of the
+	 * packet in host memory. Metadata starts at the first 32B boundary
+	 * after the end of the packet for regular and jumbo placement.
+	 * It starts at the first 32B boundary after the end of the header
+	 * for HDS placement. The length of the metadata is indicated in the
+	 * metadata itself.
 	 */
-		#define RX_TPA_START_CMPL_FLAGS_PLACEMENT_GRO_HDS	(UINT32_C(0x6) << 7)
-		#define RX_TPA_START_CMPL_FLAGS_PLACEMENT_LAST	RX_TPA_START_CMPL_FLAGS_PLACEMENT_GRO_HDS
-	/* This bit is '1' if the RSS field in this completion is valid. */
-	#define RX_TPA_START_CMPL_FLAGS_RSS_VALID	UINT32_C(0x400)
-	/* unused is 1 b */
-	#define RX_TPA_START_CMPL_FLAGS_UNUSED		UINT32_C(0x800)
+	#define RX_PKT_V3_CMPL_FLAGS_PKT_METADATA_PRESENT	UINT32_C(0x800)
 	/*
 	 * This value indicates what the inner packet determined for the
 	 * packet was.
 	 */
-	#define RX_TPA_START_CMPL_FLAGS_ITYPE_MASK	UINT32_C(0xf000)
-	#define RX_TPA_START_CMPL_FLAGS_ITYPE_SFT	12
+	#define RX_PKT_V3_CMPL_FLAGS_ITYPE_MASK		UINT32_C(0xf000)
+	#define RX_PKT_V3_CMPL_FLAGS_ITYPE_SFT		12
+	/*
+	 * Not Known:
+	 * Indicates that the packet type was not known.
+	 */
+		#define RX_PKT_V3_CMPL_FLAGS_ITYPE_NOT_KNOWN		(UINT32_C(0x0) << 12)
+	/*
+	 * IP Packet:
+	 * Indicates that the packet was an IP packet, but further
+	 * classification was not possible.
+	 */
+		#define RX_PKT_V3_CMPL_FLAGS_ITYPE_IP			(UINT32_C(0x1) << 12)
 	/*
 	 * TCP Packet:
 	 * Indicates that the packet was IP and TCP.
+	 * This indicates that the payload_offset field is valid.
 	 */
-		#define RX_TPA_START_CMPL_FLAGS_ITYPE_TCP		(UINT32_C(0x2) << 12)
-		#define RX_TPA_START_CMPL_FLAGS_ITYPE_LAST	RX_TPA_START_CMPL_FLAGS_ITYPE_TCP
+		#define RX_PKT_V3_CMPL_FLAGS_ITYPE_TCP		(UINT32_C(0x2) << 12)
 	/*
-	 * This value indicates the amount of packet data written to the
-	 * buffer the opaque field in this completion corresponds to.
+	 * UDP Packet:
+	 * Indicates that the packet was IP and UDP.
+	 * This indicates that the payload_offset field is valid.
+	 */
+		#define RX_PKT_V3_CMPL_FLAGS_ITYPE_UDP		(UINT32_C(0x3) << 12)
+	/*
+	 * FCoE Packet:
+	 * Indicates that the packet was recognized as a FCoE.
+	 * This also indicates that the payload_offset field is valid.
+	 */
+		#define RX_PKT_V3_CMPL_FLAGS_ITYPE_FCOE		(UINT32_C(0x4) << 12)
+	/*
+	 * RoCE Packet:
+	 * Indicates that the packet was recognized as a RoCE.
+	 * This also indicates that the payload_offset field is valid.
+	 */
+		#define RX_PKT_V3_CMPL_FLAGS_ITYPE_ROCE		(UINT32_C(0x5) << 12)
+	/*
+	 * ICMP Packet:
+	 * Indicates that the packet was recognized as ICMP.
+	 * This indicates that the payload_offset field is valid.
+	 */
+		#define RX_PKT_V3_CMPL_FLAGS_ITYPE_ICMP		(UINT32_C(0x7) << 12)
+	/*
+	 * PTP packet wo/timestamp:
+	 * Indicates that the packet was recognized as a PTP
+	 * packet.
+	 */
+		#define RX_PKT_V3_CMPL_FLAGS_ITYPE_PTP_WO_TIMESTAMP	(UINT32_C(0x8) << 12)
+	/*
+	 * PTP packet w/timestamp:
+	 * Indicates that the packet was recognized as a PTP
+	 * packet and that a timestamp was taken for the packet.
+	 * The 4b sub-nanosecond portion of the timestamp is in
+	 * the payload_offset field.
+	 */
+		#define RX_PKT_V3_CMPL_FLAGS_ITYPE_PTP_W_TIMESTAMP	(UINT32_C(0x9) << 12)
+		#define RX_PKT_V3_CMPL_FLAGS_ITYPE_LAST		RX_PKT_V3_CMPL_FLAGS_ITYPE_PTP_W_TIMESTAMP
+	/*
+	 * This is the length of the data for the packet stored in the
+	 * buffer(s) identified by the opaque value. This includes
+	 * the packet BD and any associated buffer BDs. This does not include
+	 * the length of any data places in aggregation BDs.
 	 */
 	uint16_t	len;
 	/*
@@ -5662,594 +6489,819 @@ typedef struct rx_tpa_start_cmpl {
 	 * corresponds to.
 	 */
 	uint32_t	opaque;
+	uint16_t	rss_hash_type_agg_bufs_v1;
 	/*
 	 * This value is written by the NIC such that it will be different
 	 * for each pass through the completion queue. The even passes
 	 * will write 1. The odd passes will write 0.
 	 */
-	uint8_t	v1;
+	#define RX_PKT_V3_CMPL_V1		UINT32_C(0x1)
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * This value is the number of aggregation buffers that follow this
+	 * entry in the completion ring that are a part of this packet.
+	 * If the value is zero, then the packet is completely contained
+	 * in the buffer space provided for the packet in the RX ring.
 	 */
-	#define RX_TPA_START_CMPL_V1 UINT32_C(0x1)
-	#define RX_TPA_START_CMPL_LAST RX_TPA_START_CMPL_V1
+	#define RX_PKT_V3_CMPL_AGG_BUFS_MASK	UINT32_C(0x3e)
+	#define RX_PKT_V3_CMPL_AGG_BUFS_SFT	1
+	/* unused1 is 1 b */
+	#define RX_PKT_V3_CMPL_UNUSED1		UINT32_C(0x40)
 	/*
 	 * This is the RSS hash type for the packet. The value is packed
 	 * {tuple_extrac_op[1:0],rss_profile_id[4:0],tuple_extrac_op[2]}.
-	 *
 	 * The value of tuple_extrac_op provides the information about
 	 * what fields the hash was computed on.
-	 * * 0: The RSS hash was computed over source IP address,
-	 * destination IP address, source port, and destination port of inner
-	 * IP and TCP or UDP headers. Note: For non-tunneled packets,
-	 * the packet headers are considered inner packet headers for the RSS
-	 * hash computation purpose.
-	 * * 1: The RSS hash was computed over source IP address and destination
-	 * IP address of inner IP header. Note: For non-tunneled packets,
-	 * the packet headers are considered inner packet headers for the RSS
-	 * hash computation purpose.
-	 * * 2: The RSS hash was computed over source IP address,
+	 * Note that 4-tuples values listed below are applicable
+	 * for layer 4 protocols supported and enabled for RSS in the
+	 * hardware, HWRM firmware, and drivers. For example, if RSS hash
+	 * is supported and enabled for TCP traffic only, then the values of
+	 * tuple_extract_op corresponding to 4-tuples are only valid for
+	 * TCP traffic.
+	 */
+	#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_MASK   UINT32_C(0xff80)
+	#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_SFT	7
+	/*
+	 * The RSS hash was computed over source IP address,
+	 * destination IP address, source port, and destination port of
+	 * inner IP and TCP or UDP headers.
+	 */
+		#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_ENUM_0   (UINT32_C(0x0) << 7)
+	/*
+	 * The RSS hash was computed over source IP address and
+	 * destination IP address of inner IP header.
+	 */
+		#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_ENUM_1   (UINT32_C(0x1) << 7)
+	/*
+	 * The RSS hash was computed over source IP address,
 	 * destination IP address, source port, and destination port of
 	 * IP and TCP or UDP headers of outer tunnel headers.
 	 * Note: For non-tunneled packets, this value is not applicable.
-	 * * 3: The RSS hash was computed over source IP address and
+	 */
+		#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_ENUM_2   (UINT32_C(0x2) << 7)
+	/*
+	 * The RSS hash was computed over source IP address and
 	 * destination IP address of IP header of outer tunnel headers.
 	 * Note: For non-tunneled packets, this value is not applicable.
-	 *
-	 * Note that 4-tuples values listed above are applicable
-	 * for layer 4 protocols supported and enabled for RSS in the hardware,
-	 * HWRM firmware, and drivers. For example, if RSS hash is supported and
-	 * enabled for TCP traffic only, then the values of tuple_extract_op
-	 * corresponding to 4-tuples are only valid for TCP traffic.
 	 */
-	uint8_t	rss_hash_type;
+		#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_ENUM_3   (UINT32_C(0x3) << 7)
 	/*
-	 * This is the aggregation ID that the completion is associated
-	 * with. Use this number to correlate the TPA start completion
-	 * with the TPA end completion.
+	 * The RSS hash was computed over source IP address of the inner
+	 * IP header.
 	 */
-	uint16_t	agg_id;
-	/* unused2 is 9 b */
-	#define RX_TPA_START_CMPL_UNUSED2_MASK UINT32_C(0x1ff)
-	#define RX_TPA_START_CMPL_UNUSED2_SFT 0
+		#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_ENUM_4   (UINT32_C(0x4) << 7)
 	/*
-	 * This is the aggregation ID that the completion is associated
-	 * with. Use this number to correlate the TPA start completion
-	 * with the TPA end completion.
+	 * The RSS hash was computed over destination IP address of the
+	 * inner IP header.
 	 */
-	#define RX_TPA_START_CMPL_AGG_ID_MASK UINT32_C(0xfe00)
-	#define RX_TPA_START_CMPL_AGG_ID_SFT  9
+		#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_ENUM_5   (UINT32_C(0x5) << 7)
+	/*
+	 * The RSS hash was computed over source IP address of the outer
+	 * IP header.
+	 * Note: For non-tunneled packets, this value is not applicable.
+	 */
+		#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_ENUM_6   (UINT32_C(0x6) << 7)
+	/*
+	 * The RSS hash was computed over destination IP address of the
+	 * outer IP header.
+	 * Note: For non-tunneled packets, this value is not applicable.
+	 */
+		#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_ENUM_7   (UINT32_C(0x7) << 7)
+	/*
+	 * The RSS hash was computed over source IP address, destination
+	 * IP address, and flow label of the inner IP header.
+	 * Note: For packets without an inner IPv6 header, this value is not
+	 * this value is not applicable.
+	 */
+		#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_ENUM_8   (UINT32_C(0x8) << 7)
+	/*
+	 * The RSS hash was computed over the flow label of the inner
+	 * IP header.
+	 * Note: For packets without an inner IPv6 header, this value
+	 * is not applicable.
+	 */
+		#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_ENUM_9   (UINT32_C(0x9) << 7)
+	/*
+	 * The RSS hash was computed over source IP address, destination
+	 * IP address, and flow label of the outer IP header.
+	 * Note: For packets without an outer IPv6 header, this value is not
+	 * applicable.
+	 */
+		#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_ENUM_10  (UINT32_C(0xa) << 7)
+	/*
+	 * The RSS hash was computed over the flow label of the outer
+	 * IP header.
+	 * Note: For packets without an outer IPv6 header, this value
+	 * is not applicable.
+	 */
+		#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_ENUM_11  (UINT32_C(0xb) << 7)
+	/* The RSS hash was computed over tunnel context and tunnel ID field. */
+		#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_ENUM_12  (UINT32_C(0xc) << 7)
+	/*
+	 * The RSS hash was computed over tunnel source IP address, tunnel
+	 * destination IP address, and tunnel ID field.
+	 */
+		#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_ENUM_13  (UINT32_C(0xd) << 7)
+	/*
+	 * The RSS hash was computed over tunnel source IP address, tunnel
+	 * destination IP address, tunnel context, and tunnel ID field.
+	 */
+		#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_ENUM_14  (UINT32_C(0xe) << 7)
+		#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_LAST	RX_PKT_V3_CMPL_RSS_HASH_TYPE_ENUM_14
+	uint16_t	metadata1_payload_offset;
+	/*
+	 * If truncation placement is not used, this value indicates the offset
+	 * in bytes from the beginning of the packet where the inner payload
+	 * starts. This value is valid for TCP, UDP, FCoE, and RoCE packets.
+	 * For PTP packets with timestamp (as indicated by the flags_itype
+	 * field), this field contains the 4b sub-nanosecond portion of the
+	 * timestamp.
+	 *
+	 * If truncation placement is used, this value represents the placed
+	 * (truncated) length of the packet.
+	 */
+	#define RX_PKT_V3_CMPL_PAYLOAD_OFFSET_MASK	UINT32_C(0x1ff)
+	#define RX_PKT_V3_CMPL_PAYLOAD_OFFSET_SFT	0
+	/* This is data from the CFA as indicated by the meta_format field. */
+	#define RX_PKT_V3_CMPL_METADATA1_MASK		UINT32_C(0xf000)
+	#define RX_PKT_V3_CMPL_METADATA1_SFT		12
+	/* When meta_format != 0, this value is the VLAN TPID_SEL. */
+	#define RX_PKT_V3_CMPL_METADATA1_TPID_SEL_MASK	UINT32_C(0x7000)
+	#define RX_PKT_V3_CMPL_METADATA1_TPID_SEL_SFT	12
+	/* 0x88a8 */
+		#define RX_PKT_V3_CMPL_METADATA1_TPID_SEL_TPID88A8   (UINT32_C(0x0) << 12)
+	/* 0x8100 */
+		#define RX_PKT_V3_CMPL_METADATA1_TPID_SEL_TPID8100   (UINT32_C(0x1) << 12)
+	/* 0x9100 */
+		#define RX_PKT_V3_CMPL_METADATA1_TPID_SEL_TPID9100   (UINT32_C(0x2) << 12)
+	/* 0x9200 */
+		#define RX_PKT_V3_CMPL_METADATA1_TPID_SEL_TPID9200   (UINT32_C(0x3) << 12)
+	/* 0x9300 */
+		#define RX_PKT_V3_CMPL_METADATA1_TPID_SEL_TPID9300   (UINT32_C(0x4) << 12)
+	/* Value programmed in CFA VLANTPID register. */
+		#define RX_PKT_V3_CMPL_METADATA1_TPID_SEL_TPIDCFG	(UINT32_C(0x5) << 12)
+		#define RX_PKT_V3_CMPL_METADATA1_TPID_SEL_LAST	RX_PKT_V3_CMPL_METADATA1_TPID_SEL_TPIDCFG
+	/* When meta_format != 0, this value is the VLAN valid. */
+	#define RX_PKT_V3_CMPL_METADATA1_VALID		UINT32_C(0x8000)
 	/*
 	 * This value is the RSS hash value calculated for the packet
-	 * based on the mode bits and key value in the VNIC.
+	 * based on the mode bits and key value in the VNIC. When hairpin_en
+	 * is set in VNIC context, this is the lower 32b of the host address
+	 * from the first BD used to place the packet.
 	 */
 	uint32_t	rss_hash;
-} rx_tpa_start_cmpl_t, *prx_tpa_start_cmpl_t;
+} rx_pkt_v3_cmpl_t, *prx_pkt_v3_cmpl_t;
 
-/*
- * Last 16 bytes of rx_tpa_start_cmpl.
- *
- * This TPA completion structure is used on devices where the
- * `hwrm_vnic_qcaps.max_aggs_supported` value is 0.
- */
-/* rx_tpa_start_cmpl_hi (size:128b/16B) */
+/* Last 16 bytes of RX Packet V3 Completion Record */
+/* rx_pkt_v3_cmpl_hi (size:128b/16B) */
 
-typedef struct rx_tpa_start_cmpl_hi {
+typedef struct rx_pkt_v3_cmpl_hi {
 	uint32_t	flags2;
 	/*
-	 * This indicates that the ip checksum was calculated for the
-	 * inner packet and that the sum passed for all segments
-	 * included in the aggregation.
+	 * This indicates that the ip checksum was calculated for the inner
+	 * packet and that the ip_cs_error field indicates if there was an
+	 * error.
 	 */
-	#define RX_TPA_START_CMPL_FLAGS2_IP_CS_CALC	UINT32_C(0x1)
+	#define RX_PKT_V3_CMPL_HI_FLAGS2_IP_CS_CALC		UINT32_C(0x1)
 	/*
-	 * This indicates that the TCP, UDP or ICMP checksum was
-	 * calculated for the inner packet and that the sum passed
-	 * for all segments included in the aggregation.
+	 * This indicates that the TCP, UDP or ICMP checksum was calculated
+	 * for the inner packet and that the l4_cs_error field indicates if
+	 * there was an error.
 	 */
-	#define RX_TPA_START_CMPL_FLAGS2_L4_CS_CALC	UINT32_C(0x2)
+	#define RX_PKT_V3_CMPL_HI_FLAGS2_L4_CS_CALC		UINT32_C(0x2)
 	/*
-	 * This indicates that the ip checksum was calculated for the
-	 * tunnel header and that the sum passed for all segments
-	 * included in the aggregation.
+	 * This indicates that the ip checksum was calculated for the tunnel
+	 * header and that the t_ip_cs_error field indicates if there was an
+	 * error.
 	 */
-	#define RX_TPA_START_CMPL_FLAGS2_T_IP_CS_CALC	UINT32_C(0x4)
+	#define RX_PKT_V3_CMPL_HI_FLAGS2_T_IP_CS_CALC		UINT32_C(0x4)
 	/*
-	 * This indicates that the UDP checksum was
-	 * calculated for the tunnel packet and that the sum passed for
-	 * all segments included in the aggregation.
+	 * This indicates that the UDP checksum was calculated for the tunnel
+	 * packet and that the t_l4_cs_error field indicates if there was an
+	 * error.
 	 */
-	#define RX_TPA_START_CMPL_FLAGS2_T_L4_CS_CALC	UINT32_C(0x8)
+	#define RX_PKT_V3_CMPL_HI_FLAGS2_T_L4_CS_CALC		UINT32_C(0x8)
 	/* This value indicates what format the metadata field is. */
-	#define RX_TPA_START_CMPL_FLAGS2_META_FORMAT_MASK UINT32_C(0xf0)
-	#define RX_TPA_START_CMPL_FLAGS2_META_FORMAT_SFT  4
-	/* No metadata information. Value is zero. */
-		#define RX_TPA_START_CMPL_FLAGS2_META_FORMAT_NONE   (UINT32_C(0x0) << 4)
+	#define RX_PKT_V3_CMPL_HI_FLAGS2_META_FORMAT_MASK	UINT32_C(0xf0)
+	#define RX_PKT_V3_CMPL_HI_FLAGS2_META_FORMAT_SFT		4
+	/* There is no metadata information. Values are zero. */
+		#define RX_PKT_V3_CMPL_HI_FLAGS2_META_FORMAT_NONE		(UINT32_C(0x0) << 4)
 	/*
-	 * The metadata field contains the VLAN tag and TPID value.
-	 * - metadata[11:0] contains the vlan VID value.
-	 * - metadata[12] contains the vlan DE value.
-	 * - metadata[15:13] contains the vlan PRI value.
-	 * - metadata[31:16] contains the vlan TPID value.
+	 * The {metadata1, metadata0} fields contain the vtag
+	 * information: - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0],
+	 * de, vid[11:0]} The metadata2 field contains the table scope
+	 * and action record pointer. - metadata2[25:0] contains the
+	 * action record pointer. - metadata2[31:26] contains the table
+	 * scope.
 	 */
-		#define RX_TPA_START_CMPL_FLAGS2_META_FORMAT_VLAN   (UINT32_C(0x1) << 4)
-		#define RX_TPA_START_CMPL_FLAGS2_META_FORMAT_LAST  RX_TPA_START_CMPL_FLAGS2_META_FORMAT_VLAN
+		#define RX_PKT_V3_CMPL_HI_FLAGS2_META_FORMAT_ACT_REC_PTR	(UINT32_C(0x1) << 4)
+	/*
+	 * The {metadata1, metadata0} fields contain the vtag
+	 * information:
+	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0], de, vid[11:0]}
+	 * The metadata2 field contains the Tunnel ID
+	 * value, justified to LSB.
+	 * - VXLAN = VNI[23:0] -> VXLAN Network ID
+	 * - Geneve (NGE) = VNI[23:0] a-> Virtual Network Identifier
+	 * - NVGRE = TNI[23:0] -> Tenant Network ID
+	 * - GRE = KEY[31:0] -> key field with bit mask. zero if K=0
+	 * - IPv4 = 0 (not populated)
+	 * - IPv6 = Flow Label[19:0]
+	 * - PPPoE = sessionID[15:0]
+	 * - MPLs = Outer label[19:0]
+	 * - UPAR = Selected[31:0] with bit mask
+	 */
+		#define RX_PKT_V3_CMPL_HI_FLAGS2_META_FORMAT_TUNNEL_ID	(UINT32_C(0x2) << 4)
+	/*
+	 * The {metadata1, metadata0} fields contain the vtag
+	 * information:
+	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0],de, vid[11:0]}
+	 * The metadata2 field contains the 32b metadata from the prepended
+	 * header (chdr_data).
+	 */
+		#define RX_PKT_V3_CMPL_HI_FLAGS2_META_FORMAT_CHDR_DATA	(UINT32_C(0x3) << 4)
+	/*
+	 * The {metadata1, metadata0} fields contain the vtag
+	 * information:
+	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0], de, vid[11:0]}
+	 * The metadata2 field contains the outer_l3_offset,
+	 * inner_l2_offset, inner_l3_offset, and inner_l4_size.
+	 * - metadata2[8:0] contains the outer_l3_offset.
+	 * - metadata2[17:9] contains the inner_l2_offset.
+	 * - metadata2[26:18] contains the inner_l3_offset.
+	 * - metadata2[31:27] contains the inner_l4_size.
+	 */
+		#define RX_PKT_V3_CMPL_HI_FLAGS2_META_FORMAT_HDR_OFFSET	(UINT32_C(0x4) << 4)
+		#define RX_PKT_V3_CMPL_HI_FLAGS2_META_FORMAT_LAST		RX_PKT_V3_CMPL_HI_FLAGS2_META_FORMAT_HDR_OFFSET
 	/*
 	 * This field indicates the IP type for the inner-most IP header.
 	 * A value of '0' indicates IPv4. A value of '1' indicates IPv6.
+	 * This value is only valid if itype indicates a packet
+	 * with an IP header.
 	 */
-	#define RX_TPA_START_CMPL_FLAGS2_IP_TYPE	UINT32_C(0x100)
+	#define RX_PKT_V3_CMPL_HI_FLAGS2_IP_TYPE			UINT32_C(0x100)
+	/*
+	 * This indicates that the complete 1's complement checksum was
+	 * calculated for the packet.
+	 */
+	#define RX_PKT_V3_CMPL_HI_FLAGS2_COMPLETE_CHECKSUM_CALC	UINT32_C(0x200)
+	/*
+	 * This field indicates the status of IP and L4 CS calculations done
+	 * by the chip. The format of this field is indicated by the
+	 * cs_all_ok_mode bit.
+	 */
+	#define RX_PKT_V3_CMPL_HI_FLAGS2_T_IP_TYPE		UINT32_C(0x400)
+	/* Indicates that the Tunnel IP type was IPv4 */
+		#define RX_PKT_V3_CMPL_HI_FLAGS2_T_IP_TYPE_IPV4		(UINT32_C(0x0) << 10)
+	/* Indicates that the Tunnel IP type was IPv6 */
+		#define RX_PKT_V3_CMPL_HI_FLAGS2_T_IP_TYPE_IPV6		(UINT32_C(0x1) << 10)
+		#define RX_PKT_V3_CMPL_HI_FLAGS2_T_IP_TYPE_LAST		RX_PKT_V3_CMPL_HI_FLAGS2_T_IP_TYPE_IPV6
+	/*
+	 * This value is the complete 1's complement checksum calculated from
+	 * the start of the outer L3 header to the end of the packet (not
+	 * including the ethernet crc). It is valid when the
+	 * 'complete_checksum_calc' flag is set.
+	 */
+	#define RX_PKT_V3_CMPL_HI_FLAGS2_COMPLETE_CHECKSUM_MASK	UINT32_C(0xffff0000)
+	#define RX_PKT_V3_CMPL_HI_FLAGS2_COMPLETE_CHECKSUM_SFT	16
 	/*
 	 * This is data from the CFA block as indicated by the meta_format
 	 * field.
+	 * - meta_format 0 - none - metadata2 = 0 - not valid/not stripped
+	 * - meta_format 1 - act_rec_ptr - metadata2 = {table_scope[5:0],
+	 *   act_rec_ptr[25:0]}
+	 * - meta_format 2 - tunnel_id - metadata2 = tunnel_id[31:0]
+	 * - meta_format 3 - chdr_data - metadata2 = updated_chdr_data[31:0]
+	 * - meta_format 4 - hdr_offsets - metadata2 = hdr_offsets[31:0]
 	 */
-	uint32_t	metadata;
-	/* When meta_format=1, this value is the VLAN VID. */
-	#define RX_TPA_START_CMPL_METADATA_VID_MASK UINT32_C(0xfff)
-	#define RX_TPA_START_CMPL_METADATA_VID_SFT  0
-	/* When meta_format=1, this value is the VLAN DE. */
-	#define RX_TPA_START_CMPL_METADATA_DE	UINT32_C(0x1000)
-	/* When meta_format=1, this value is the VLAN PRI. */
-	#define RX_TPA_START_CMPL_METADATA_PRI_MASK UINT32_C(0xe000)
-	#define RX_TPA_START_CMPL_METADATA_PRI_SFT  13
-	/* When meta_format=1, this value is the VLAN TPID. */
-	#define RX_TPA_START_CMPL_METADATA_TPID_MASK UINT32_C(0xffff0000)
-	#define RX_TPA_START_CMPL_METADATA_TPID_SFT 16
-	uint16_t	v2;
+	uint32_t	metadata2;
+	uint16_t	errors_v2;
 	/*
 	 * This value is written by the NIC such that it will be different
 	 * for each pass through the completion queue. The even passes
 	 * will write 1. The odd passes will write 0.
 	 */
-	#define RX_TPA_START_CMPL_V2	UINT32_C(0x1)
+	#define RX_PKT_V3_CMPL_HI_V2					UINT32_C(0x1)
+	#define RX_PKT_V3_CMPL_HI_ERRORS_MASK				UINT32_C(0xfffe)
+	#define RX_PKT_V3_CMPL_HI_ERRORS_SFT				1
 	/*
-	 * This field identifies the CFA action rule that was used for this
-	 * packet.
+	 * This error indicates that there was some sort of problem with
+	 * the BDs for the packet that was found after part of the
+	 * packet was already placed. The packet should be treated as
+	 * invalid.
 	 */
-	uint16_t	cfa_code;
+	#define RX_PKT_V3_CMPL_HI_ERRORS_BUFFER_ERROR_MASK		UINT32_C(0xe)
+	#define RX_PKT_V3_CMPL_HI_ERRORS_BUFFER_ERROR_SFT		1
+	/* No buffer error */
+		#define RX_PKT_V3_CMPL_HI_ERRORS_BUFFER_ERROR_NO_BUFFER		(UINT32_C(0x0) << 1)
 	/*
-	 * This is the size in bytes of the inner most L4 header.
-	 * This can be subtracted from the payload_offset to determine
-	 * the start of the inner most L4 header.
+	 * Did Not Fit: Packet did not fit into packet buffer provided.
+	 * For regular placement, this means the packet did not fit in
+	 * the buffer provided. For HDS and jumbo placement, this means
+	 * that the packet could not be placed into 8 physical buffers.
 	 */
-	uint32_t	inner_l4_size_inner_l3_offset_inner_l2_offset_outer_l3_offset;
+		#define RX_PKT_V3_CMPL_HI_ERRORS_BUFFER_ERROR_DID_NOT_FIT		(UINT32_C(0x1) << 1)
 	/*
-	 * This is the offset from the beginning of the packet in bytes for
-	 * the outer L3 header. If there is no outer L3 header, then this
-	 * value is zero.
+	 * Not On Chip: All BDs needed for the packet were not on-chip
+	 * when the packet arrived. For regular placement, this error is
+	 * not valid. For HDS and jumbo placement, this means that not
+	 * enough agg BDs were posted to place the packet.
 	 */
-	#define RX_TPA_START_CMPL_OUTER_L3_OFFSET_MASK UINT32_C(0x1ff)
-	#define RX_TPA_START_CMPL_OUTER_L3_OFFSET_SFT 0
+		#define RX_PKT_V3_CMPL_HI_ERRORS_BUFFER_ERROR_NOT_ON_CHIP		(UINT32_C(0x2) << 1)
 	/*
-	 * This is the offset from the beginning of the packet in bytes for
-	 * the inner most L2 header.
+	 * Bad Format:
+	 * BDs were not formatted correctly.
 	 */
-	#define RX_TPA_START_CMPL_INNER_L2_OFFSET_MASK UINT32_C(0x3fe00)
-	#define RX_TPA_START_CMPL_INNER_L2_OFFSET_SFT 9
+		#define RX_PKT_V3_CMPL_HI_ERRORS_BUFFER_ERROR_BAD_FORMAT		(UINT32_C(0x3) << 1)
 	/*
-	 * This is the offset from the beginning of the packet in bytes for
-	 * the inner most L3 header.
+	 * Flush:
+	 * There was a bad_format error on the previous operation
 	 */
-	#define RX_TPA_START_CMPL_INNER_L3_OFFSET_MASK UINT32_C(0x7fc0000)
-	#define RX_TPA_START_CMPL_INNER_L3_OFFSET_SFT 18
+		#define RX_PKT_V3_CMPL_HI_ERRORS_BUFFER_ERROR_FLUSH		(UINT32_C(0x5) << 1)
+		#define RX_PKT_V3_CMPL_HI_ERRORS_BUFFER_ERROR_LAST		RX_PKT_V3_CMPL_HI_ERRORS_BUFFER_ERROR_FLUSH
+	/* This indicates that there was an error in the IP header checksum. */
+	#define RX_PKT_V3_CMPL_HI_ERRORS_IP_CS_ERROR			UINT32_C(0x10)
 	/*
-	 * This is the size in bytes of the inner most L4 header.
-	 * This can be subtracted from the payload_offset to determine
-	 * the start of the inner most L4 header.
+	 * This indicates that there was an error in the TCP, UDP or ICMP
+	 * checksum.
 	 */
-	#define RX_TPA_START_CMPL_INNER_L4_SIZE_MASK  UINT32_C(0xf8000000)
-	#define RX_TPA_START_CMPL_INNER_L4_SIZE_SFT   27
-} rx_tpa_start_cmpl_hi_t, *prx_tpa_start_cmpl_hi_t;
-
-/*
- * This TPA completion structure is used on devices where the
- * `hwrm_vnic_qcaps.max_aggs_supported` value is 0.
- * RX L2 TPA Start V2 Completion Record (32 bytes split to 2 16-byte
- * struct)
- */
-/* rx_tpa_start_v2_cmpl (size:128b/16B) */
-
-typedef struct rx_tpa_start_v2_cmpl {
-	uint16_t	flags_type;
+	#define RX_PKT_V3_CMPL_HI_ERRORS_L4_CS_ERROR			UINT32_C(0x20)
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * This indicates that there was an error in the tunnel IP header
+	 * checksum.
 	 */
-	#define RX_TPA_START_V2_CMPL_TYPE_MASK			UINT32_C(0x3f)
-	#define RX_TPA_START_V2_CMPL_TYPE_SFT			0
+	#define RX_PKT_V3_CMPL_HI_ERRORS_T_IP_CS_ERROR			UINT32_C(0x40)
+	/* This indicates that there was an error in the tunnel UDP checksum. */
+	#define RX_PKT_V3_CMPL_HI_ERRORS_T_L4_CS_ERROR			UINT32_C(0x80)
 	/*
-	 * RX L2 TPA Start V2 Completion:
-	 * Completion at the beginning of a TPA operation.
-	 * Length = 32B
-	 * This is the new version of the RX_TPA_START completion used
-	 * in SR2 and later chips.
+	 * This indicates that there was a CRC error on either an FCoE
+	 * or RoCE packet. The itype indicates the packet type.
 	 */
-		#define RX_TPA_START_V2_CMPL_TYPE_RX_TPA_START_V2		UINT32_C(0xd)
-		#define RX_TPA_START_V2_CMPL_TYPE_LAST			RX_TPA_START_V2_CMPL_TYPE_RX_TPA_START_V2
-	#define RX_TPA_START_V2_CMPL_FLAGS_MASK			UINT32_C(0xffc0)
-	#define RX_TPA_START_V2_CMPL_FLAGS_SFT			6
+	#define RX_PKT_V3_CMPL_HI_ERRORS_CRC_ERROR			UINT32_C(0x100)
 	/*
-	 * When this bit is '1', it indicates a packet that has an error
-	 * of some type. Type of error is indicated in error_flags.
+	 * This indicates that there was an error in the tunnel portion
+	 * of the packet when this field is non-zero.
 	 */
-	#define RX_TPA_START_V2_CMPL_FLAGS_ERROR			UINT32_C(0x40)
-	/* This field indicates how the packet was placed in the buffer. */
-	#define RX_TPA_START_V2_CMPL_FLAGS_PLACEMENT_MASK		UINT32_C(0x380)
-	#define RX_TPA_START_V2_CMPL_FLAGS_PLACEMENT_SFT		7
+	#define RX_PKT_V3_CMPL_HI_ERRORS_T_PKT_ERROR_MASK		UINT32_C(0xe00)
+	#define RX_PKT_V3_CMPL_HI_ERRORS_T_PKT_ERROR_SFT			9
 	/*
-	 * Jumbo:
-	 * TPA Packet was placed using jumbo algorithm. This means
-	 * that the first buffer will be filled with data before
-	 * moving to aggregation buffers. Each aggregation buffer
-	 * will be filled before moving to the next aggregation
-	 * buffer.
+	 * No additional error occurred on the tunnel portion
+	 * of the packet or the packet does not have a tunnel.
 	 */
-		#define RX_TPA_START_V2_CMPL_FLAGS_PLACEMENT_JUMBO		(UINT32_C(0x1) << 7)
+		#define RX_PKT_V3_CMPL_HI_ERRORS_T_PKT_ERROR_NO_ERROR		(UINT32_C(0x0) << 9)
 	/*
-	 * Header/Data Separation:
-	 * Packet was placed using Header/Data separation algorithm.
-	 * The separation location is indicated by the itype field.
+	 * Indicates that IP header version does not match expectation
+	 * from L2 Ethertype for IPv4 and IPv6 in the tunnel header.
 	 */
-		#define RX_TPA_START_V2_CMPL_FLAGS_PLACEMENT_HDS		(UINT32_C(0x2) << 7)
+		#define RX_PKT_V3_CMPL_HI_ERRORS_T_PKT_ERROR_T_L3_BAD_VERSION	(UINT32_C(0x1) << 9)
 	/*
-	 * IOC/Jumbo:
-	 * Packet will be placed using In-Order Completion/Jumbo where
-	 * the first packet of the aggregation is placed using Jumbo
-	 * Placement. Subsequent packets will be placed such that each
-	 * packet starts at the beginning of an aggregation buffer.
+	 * Indicates that header length is out of range in the tunnel
+	 * header. Valid for IPv4.
 	 */
-		#define RX_TPA_START_V2_CMPL_FLAGS_PLACEMENT_IOC_JUMBO	(UINT32_C(0x4) << 7)
+		#define RX_PKT_V3_CMPL_HI_ERRORS_T_PKT_ERROR_T_L3_BAD_HDR_LEN	(UINT32_C(0x2) << 9)
 	/*
-	 * GRO/Jumbo:
-	 * Packet will be placed using GRO/Jumbo where the first
-	 * packet is filled with data. Subsequent packets will be
-	 * placed such that any one packet does not span two
-	 * aggregation buffers unless it starts at the beginning of
-	 * an aggregation buffer.
+	 * Indicates that physical packet is shorter than that claimed
+	 * by the tunnel l3 header length. Valid for IPv4, or IPv6 tunnel
+	 * packet packets.
 	 */
-		#define RX_TPA_START_V2_CMPL_FLAGS_PLACEMENT_GRO_JUMBO	(UINT32_C(0x5) << 7)
+		#define RX_PKT_V3_CMPL_HI_ERRORS_T_PKT_ERROR_T_IP_TOTAL_ERROR	(UINT32_C(0x3) << 9)
 	/*
-	 * GRO/Header-Data Separation:
-	 * Packet will be placed using GRO/HDS where the header
-	 * is in the first packet.
-	 * Payload of each packet will be
-	 * placed such that any one packet does not span two
-	 * aggregation buffers unless it starts at the beginning of
-	 * an aggregation buffer.
+	 * Indicates that the physical packet is shorter than that claimed
+	 * by the tunnel UDP header length for a tunnel UDP packet that is
+	 * not fragmented.
 	 */
-		#define RX_TPA_START_V2_CMPL_FLAGS_PLACEMENT_GRO_HDS	(UINT32_C(0x6) << 7)
+		#define RX_PKT_V3_CMPL_HI_ERRORS_T_PKT_ERROR_T_UDP_TOTAL_ERROR	(UINT32_C(0x4) << 9)
 	/*
-	 * IOC/Header-Data Separation:
-	 * Packet will be placed using In-Order Completion/HDS where
-	 * the header is in the first packet buffer. Payload of each
-	 * packet will be placed such that each packet starts at the
-	 * beginning of an aggregation buffer.
+	 * Indicates that the IPv4 TTL or IPv6 hop limit check have failed
+	 * (e.g. TTL = 0) in the tunnel header. Valid for IPv4, and IPv6.
 	 */
-		#define RX_TPA_START_V2_CMPL_FLAGS_PLACEMENT_IOC_HDS	(UINT32_C(0x7) << 7)
-		#define RX_TPA_START_V2_CMPL_FLAGS_PLACEMENT_LAST		RX_TPA_START_V2_CMPL_FLAGS_PLACEMENT_IOC_HDS
-	/* This bit is '1' if the RSS field in this completion is valid. */
-	#define RX_TPA_START_V2_CMPL_FLAGS_RSS_VALID		UINT32_C(0x400)
+		#define RX_PKT_V3_CMPL_HI_ERRORS_T_PKT_ERROR_T_L3_BAD_TTL		(UINT32_C(0x5) << 9)
 	/*
-	 * This bit is '1' if metadata has been added to the end of the
-	 * packet in host memory. Metadata starts at the first 32B boundary
-	 * after the end of the packet for regular and jumbo placement. It
-	 * starts at the first 32B boundary after the end of the header for
-	 * HDS placement. The length of the metadata is indicated in the
-	 * metadata itself.
+	 * Indicates that the physical packet is shorter than that claimed
+	 * by the tunnel header length. Valid for GTPv1-U packets.
+	 * header.
 	 */
-	#define RX_TPA_START_V2_CMPL_FLAGS_PKT_METADATA_PRESENT	UINT32_C(0x800)
+		#define RX_PKT_V3_CMPL_HI_ERRORS_T_PKT_ERROR_T_TOTAL_ERROR		(UINT32_C(0x6) << 9)
+		#define RX_PKT_V3_CMPL_HI_ERRORS_T_PKT_ERROR_LAST			RX_PKT_V3_CMPL_HI_ERRORS_T_PKT_ERROR_T_TOTAL_ERROR
+	/*
+	 * This indicates that there was an error in the inner
+	 * portion of the packet when this
+	 * field is non-zero.
+	 */
+	#define RX_PKT_V3_CMPL_HI_ERRORS_PKT_ERROR_MASK			UINT32_C(0xf000)
+	#define RX_PKT_V3_CMPL_HI_ERRORS_PKT_ERROR_SFT			12
+	/*
+	 * No additional error occurred on the tunnel portion
+	 * or the packet of the packet does not have a tunnel.
+	 */
+		#define RX_PKT_V3_CMPL_HI_ERRORS_PKT_ERROR_NO_ERROR		(UINT32_C(0x0) << 12)
+	/*
+	 * Indicates that IP header version does not match
+	 * expectation from L2 Ethertype for IPv4 and IPv6 or that
+	 * option other than VFT was parsed on
+	 * FCoE packet.
+	 */
+		#define RX_PKT_V3_CMPL_HI_ERRORS_PKT_ERROR_L3_BAD_VERSION		(UINT32_C(0x1) << 12)
+	/*
+	 * indicates that header length is out of range. Valid for
+	 * IPv4 and RoCE
+	 */
+		#define RX_PKT_V3_CMPL_HI_ERRORS_PKT_ERROR_L3_BAD_HDR_LEN		(UINT32_C(0x2) << 12)
+	/*
+	 * indicates that the IPv4 TTL or IPv6 hop limit check
+	 * have failed (e.g. TTL = 0). Valid for IPv4, and IPv6
+	 */
+		#define RX_PKT_V3_CMPL_HI_ERRORS_PKT_ERROR_L3_BAD_TTL		(UINT32_C(0x3) << 12)
+	/*
+	 * Indicates that physical packet is shorter than that
+	 * claimed by the l3 header length. Valid for IPv4,
+	 * IPv6 packet or RoCE packets.
+	 */
+		#define RX_PKT_V3_CMPL_HI_ERRORS_PKT_ERROR_IP_TOTAL_ERROR		(UINT32_C(0x4) << 12)
+	/*
+	 * Indicates that the physical packet is shorter than that
+	 * claimed by the UDP header length for a UDP packet that is
+	 * not fragmented.
+	 */
+		#define RX_PKT_V3_CMPL_HI_ERRORS_PKT_ERROR_UDP_TOTAL_ERROR		(UINT32_C(0x5) << 12)
+	/*
+	 * Indicates that TCP header length > IP payload. Valid for
+	 * TCP packets only.
+	 */
+		#define RX_PKT_V3_CMPL_HI_ERRORS_PKT_ERROR_L4_BAD_HDR_LEN		(UINT32_C(0x6) << 12)
+	/* Indicates that TCP header length < 5. Valid for TCP. */
+		#define RX_PKT_V3_CMPL_HI_ERRORS_PKT_ERROR_L4_BAD_HDR_LEN_TOO_SMALL   (UINT32_C(0x7) << 12)
+	/*
+	 * Indicates that TCP option headers result in a TCP header
+	 * size that does not match data offset in TCP header. Valid
+	 * for TCP.
+	 */
+		#define RX_PKT_V3_CMPL_HI_ERRORS_PKT_ERROR_L4_BAD_OPT_LEN		(UINT32_C(0x8) << 12)
+		#define RX_PKT_V3_CMPL_HI_ERRORS_PKT_ERROR_LAST			RX_PKT_V3_CMPL_HI_ERRORS_PKT_ERROR_L4_BAD_OPT_LEN
+	/*
+	 * This is data from the CFA block as indicated by the meta_format
+	 * field.
+	 */
+	uint16_t	metadata0;
+	/* When meta_format=1, this value is the VLAN VID. */
+	#define RX_PKT_V3_CMPL_HI_METADATA0_VID_MASK UINT32_C(0xfff)
+	#define RX_PKT_V3_CMPL_HI_METADATA0_VID_SFT 0
+	/* When meta_format=1, this value is the VLAN DE. */
+	#define RX_PKT_V3_CMPL_HI_METADATA0_DE	UINT32_C(0x1000)
+	/* When meta_format=1, this value is the VLAN PRI. */
+	#define RX_PKT_V3_CMPL_HI_METADATA0_PRI_MASK UINT32_C(0xe000)
+	#define RX_PKT_V3_CMPL_HI_METADATA0_PRI_SFT 13
+	/*
+	 * The timestamp field contains the 32b timestamp for the packet from
+	 * the MAC.
+	 *
+	 * When hairpin_en is set in VNIC context, this is the upper 32b of the
+	 * host address from the first BD used to place the packet.
+	 */
+	uint32_t	timestamp;
+} rx_pkt_v3_cmpl_hi_t, *prx_pkt_v3_cmpl_hi_t;
+
+/* rx_pkt_compress_cmpl (size:128b/16B) */
+
+typedef struct rx_pkt_compress_cmpl {
+	uint16_t	flags_type;
+	/*
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
+	 */
+	#define RX_PKT_COMPRESS_CMPL_TYPE_MASK		UINT32_C(0x3f)
+	#define RX_PKT_COMPRESS_CMPL_TYPE_SFT			0
+	/*
+	 * RX L2 completion:
+	 * This is the compressed version of Rx Completion for performance
+	 * applications. Length = 16B
+	 * This version of the completion record is used in Thor2 and later
+	 * chips.
+	 */
+		#define RX_PKT_COMPRESS_CMPL_TYPE_RX_L2_COMPRESS	UINT32_C(0x10)
+		#define RX_PKT_COMPRESS_CMPL_TYPE_LAST			RX_PKT_COMPRESS_CMPL_TYPE_RX_L2_COMPRESS
+	#define RX_PKT_COMPRESS_CMPL_FLAGS_MASK		UINT32_C(0xffc0)
+	#define RX_PKT_COMPRESS_CMPL_FLAGS_SFT		6
+	/*
+	 * When this bit is '1', it indicates a packet that has an
+	 * error of some type. Type of error is indicated in
+	 * error_flags.
+	 */
+	#define RX_PKT_COMPRESS_CMPL_FLAGS_ERROR		UINT32_C(0x40)
+	/*
+	 * This field indicates the status of IP and L4 CS calculations done
+	 * by the chip. The format of this field is indicated by the
+	 * cs_all_ok_mode bit.
+	 */
+	#define RX_PKT_COMPRESS_CMPL_FLAGS_T_IP_TYPE		UINT32_C(0x100)
+	/* Indicates that the Tunnel IP type was IPv4 */
+		#define RX_PKT_COMPRESS_CMPL_FLAGS_T_IP_TYPE_IPV4	(UINT32_C(0x0) << 8)
+	/* Indicates that the Tunnel IP type was IPv6 */
+		#define RX_PKT_COMPRESS_CMPL_FLAGS_T_IP_TYPE_IPV6	(UINT32_C(0x1) << 8)
+		#define RX_PKT_COMPRESS_CMPL_FLAGS_T_IP_TYPE_LAST	RX_PKT_COMPRESS_CMPL_FLAGS_T_IP_TYPE_IPV6
+	/*
+	 * This field indicates the IP type for the inner-most IP header.
+	 * A value of '0' indicates IPv4. A value of '1' indicates IPv6.
+	 * This value is only valid if itype indicates a packet
+	 * with an IP header.
+	 */
+	#define RX_PKT_COMPRESS_CMPL_FLAGS_IP_TYPE		UINT32_C(0x200)
+	/* This bit is '1' if the RSS field in this completion is valid. */
+	#define RX_PKT_COMPRESS_CMPL_FLAGS_RSS_VALID		UINT32_C(0x400)
 	/*
 	 * This value indicates what the inner packet determined for the
 	 * packet was.
 	 */
-	#define RX_TPA_START_V2_CMPL_FLAGS_ITYPE_MASK		UINT32_C(0xf000)
-	#define RX_TPA_START_V2_CMPL_FLAGS_ITYPE_SFT		12
+	#define RX_PKT_COMPRESS_CMPL_FLAGS_ITYPE_MASK		UINT32_C(0xf000)
+	#define RX_PKT_COMPRESS_CMPL_FLAGS_ITYPE_SFT		12
+	/*
+	 * Not Known:
+	 * Indicates that the packet type was not known.
+	 */
+		#define RX_PKT_COMPRESS_CMPL_FLAGS_ITYPE_NOT_KNOWN	(UINT32_C(0x0) << 12)
+	/*
+	 * IP Packet:
+	 * Indicates that the packet was an IP packet, but further
+	 * classification was not possible.
+	 */
+		#define RX_PKT_COMPRESS_CMPL_FLAGS_ITYPE_IP		(UINT32_C(0x1) << 12)
 	/*
 	 * TCP Packet:
 	 * Indicates that the packet was IP and TCP.
+	 * This indicates that the payload_offset field is valid.
 	 */
-		#define RX_TPA_START_V2_CMPL_FLAGS_ITYPE_TCP		(UINT32_C(0x2) << 12)
-		#define RX_TPA_START_V2_CMPL_FLAGS_ITYPE_LAST		RX_TPA_START_V2_CMPL_FLAGS_ITYPE_TCP
+		#define RX_PKT_COMPRESS_CMPL_FLAGS_ITYPE_TCP		(UINT32_C(0x2) << 12)
 	/*
-	 * This value indicates the amount of packet data written to the
-	 * buffer the opaque field in this completion corresponds to.
+	 * UDP Packet:
+	 * Indicates that the packet was IP and UDP.
+	 * This indicates that the payload_offset field is valid.
+	 */
+		#define RX_PKT_COMPRESS_CMPL_FLAGS_ITYPE_UDP		(UINT32_C(0x3) << 12)
+	/*
+	 * FCoE Packet:
+	 * Indicates that the packet was recognized as a FCoE.
+	 * This also indicates that the payload_offset field is valid.
+	 */
+		#define RX_PKT_COMPRESS_CMPL_FLAGS_ITYPE_FCOE		(UINT32_C(0x4) << 12)
+	/*
+	 * RoCE Packet:
+	 * Indicates that the packet was recognized as a RoCE.
+	 * This also indicates that the payload_offset field is valid.
+	 */
+		#define RX_PKT_COMPRESS_CMPL_FLAGS_ITYPE_ROCE		(UINT32_C(0x5) << 12)
+	/*
+	 * ICMP Packet:
+	 * Indicates that the packet was recognized as ICMP.
+	 * This indicates that the payload_offset field is valid.
+	 */
+		#define RX_PKT_COMPRESS_CMPL_FLAGS_ITYPE_ICMP		(UINT32_C(0x7) << 12)
+	/*
+	 * PTP packet wo/timestamp:
+	 * Indicates that the packet was recognized as a PTP
+	 * packet.
+	 */
+		#define RX_PKT_COMPRESS_CMPL_FLAGS_ITYPE_PTP_WO_TIMESTAMP   (UINT32_C(0x8) << 12)
+	/*
+	 * PTP packet w/timestamp:
+	 * Indicates that the packet was recognized as a PTP
+	 * packet and that a timestamp was taken for the packet.
+	 * The 4b sub-nanosecond portion of the timestamp is in
+	 * the payload_offset field.
+	 */
+		#define RX_PKT_COMPRESS_CMPL_FLAGS_ITYPE_PTP_W_TIMESTAMP	(UINT32_C(0x9) << 12)
+		#define RX_PKT_COMPRESS_CMPL_FLAGS_ITYPE_LAST		RX_PKT_COMPRESS_CMPL_FLAGS_ITYPE_PTP_W_TIMESTAMP
+	/*
+	 * This is the length of the data for the packet stored in the
+	 * buffer(s) identified by the opaque value. This includes
+	 * the packet BD and any associated buffer BDs. This does not include
+	 * the length of any data places in aggregation BDs.
 	 */
 	uint16_t	len;
 	/*
-	 * This is a copy of the opaque field from the RX BD this completion
-	 * corresponds to. If the VNIC is configured to not use an Rx BD for
-	 * the TPA Start completion, then this is a copy of the opaque field
-	 * from the first BD used to place the TPA Start packet.
+	 * This value is the RSS hash value calculated for the packet
+	 * based on the mode bits and key value in the VNIC. When hairpin_en
+	 * is set in VNIC context, this is the lower 32b of the host address
+	 * from the first BD used to place the packet.
 	 */
-	uint32_t	opaque;
+	uint32_t	rss_hash;
+	uint16_t	metadata1_cs_error_calc_v1;
 	/*
 	 * This value is written by the NIC such that it will be different
 	 * for each pass through the completion queue. The even passes
 	 * will write 1. The odd passes will write 0.
 	 */
-	uint8_t	v1;
+	#define RX_PKT_COMPRESS_CMPL_V1				UINT32_C(0x1)
+	/* unused is 3 b */
+	#define RX_PKT_COMPRESS_CMPL_UNUSED_MASK			UINT32_C(0xe)
+	#define RX_PKT_COMPRESS_CMPL_UNUSED_SFT			1
+	#define RX_PKT_COMPRESS_CMPL_CS_ERROR_CALC_MASK		UINT32_C(0xff0)
+	#define RX_PKT_COMPRESS_CMPL_CS_ERROR_CALC_SFT		4
+	/* This indicates that there was an error in the IP header checksum. */
+	#define RX_PKT_COMPRESS_CMPL_CS_ERROR_CALC_IP_CS_ERROR	UINT32_C(0x10)
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * This indicates that there was an error in the TCP, UDP or ICMP
+	 * checksum.
 	 */
-	#define RX_TPA_START_V2_CMPL_V1 UINT32_C(0x1)
-	#define RX_TPA_START_V2_CMPL_LAST RX_TPA_START_V2_CMPL_V1
+	#define RX_PKT_COMPRESS_CMPL_CS_ERROR_CALC_L4_CS_ERROR	UINT32_C(0x20)
 	/*
-	 * This is the RSS hash type for the packet. The value is packed
-	 * {tuple_extrac_op[1:0],rss_profile_id[4:0],tuple_extrac_op[2]}.
-	 *
-	 * The value of tuple_extrac_op provides the information about
-	 * what fields the hash was computed on.
-	 * * 0: The RSS hash was computed over source IP address,
-	 * destination IP address, source port, and destination port of inner
-	 * IP and TCP or UDP headers. Note: For non-tunneled packets,
-	 * the packet headers are considered inner packet headers for the RSS
-	 * hash computation purpose.
-	 * * 1: The RSS hash was computed over source IP address and destination
-	 * IP address of inner IP header. Note: For non-tunneled packets,
-	 * the packet headers are considered inner packet headers for the RSS
-	 * hash computation purpose.
-	 * * 2: The RSS hash was computed over source IP address,
-	 * destination IP address, source port, and destination port of
-	 * IP and TCP or UDP headers of outer tunnel headers.
-	 * Note: For non-tunneled packets, this value is not applicable.
-	 * * 3: The RSS hash was computed over source IP address and
-	 * destination IP address of IP header of outer tunnel headers.
-	 * Note: For non-tunneled packets, this value is not applicable.
-	 *
-	 * Note that 4-tuples values listed above are applicable
-	 * for layer 4 protocols supported and enabled for RSS in the hardware,
-	 * HWRM firmware, and drivers. For example, if RSS hash is supported and
-	 * enabled for TCP traffic only, then the values of tuple_extract_op
-	 * corresponding to 4-tuples are only valid for TCP traffic.
+	 * This indicates that there was an error in the tunnel IP header
+	 * checksum.
 	 */
-	uint8_t	rss_hash_type;
+	#define RX_PKT_COMPRESS_CMPL_CS_ERROR_CALC_T_IP_CS_ERROR	UINT32_C(0x40)
+	/* This indicates that there was an error in the tunnel UDP checksum. */
+	#define RX_PKT_COMPRESS_CMPL_CS_ERROR_CALC_T_L4_CS_ERROR	UINT32_C(0x80)
 	/*
-	 * This is the aggregation ID that the completion is associated
-	 * with. Use this number to correlate the TPA start completion
-	 * with the TPA end completion.
+	 * This indicates that the ip checksum was calculated for the inner
+	 * packet and that the ip_cs_error field indicates if there was an
+	 * error.
 	 */
-	uint16_t	agg_id;
+	#define RX_PKT_COMPRESS_CMPL_CS_ERROR_CALC_IP_CS_CALC	UINT32_C(0x100)
 	/*
-	 * This is the aggregation ID that the completion is associated
-	 * with. Use this number to correlate the TPA start completion
-	 * with the TPA end completion.
+	 * This indicates that the TCP, UDP or ICMP checksum was calculated
+	 * for the inner packet and that the l4_cs_error field indicates if
+	 * there was an error.
 	 */
-	#define RX_TPA_START_V2_CMPL_AGG_ID_MASK		UINT32_C(0xfff)
-	#define RX_TPA_START_V2_CMPL_AGG_ID_SFT		0
-	#define RX_TPA_START_V2_CMPL_METADATA1_MASK		UINT32_C(0xf000)
-	#define RX_TPA_START_V2_CMPL_METADATA1_SFT		12
+	#define RX_PKT_COMPRESS_CMPL_CS_ERROR_CALC_L4_CS_CALC	UINT32_C(0x200)
+	/*
+	 * This indicates that the ip checksum was calculated for the tunnel
+	 * header and that the t_ip_cs_error field indicates if there was an
+	 * error.
+	 */
+	#define RX_PKT_COMPRESS_CMPL_CS_ERROR_CALC_T_IP_CS_CALC	UINT32_C(0x400)
+	/*
+	 * This indicates that the UDP checksum was calculated for the tunnel
+	 * packet and that the t_l4_cs_error field indicates if there was an
+	 * error.
+	 */
+	#define RX_PKT_COMPRESS_CMPL_CS_ERROR_CALC_T_L4_CS_CALC	UINT32_C(0x800)
+	/* This is data from the CFA as indicated by the meta_format field. */
+	#define RX_PKT_COMPRESS_CMPL_METADATA1_MASK		UINT32_C(0xf000)
+	#define RX_PKT_COMPRESS_CMPL_METADATA1_SFT		12
 	/* When meta_format != 0, this value is the VLAN TPID_SEL. */
-	#define RX_TPA_START_V2_CMPL_METADATA1_TPID_SEL_MASK	UINT32_C(0x7000)
-	#define RX_TPA_START_V2_CMPL_METADATA1_TPID_SEL_SFT	12
+	#define RX_PKT_COMPRESS_CMPL_METADATA1_TPID_SEL_MASK	UINT32_C(0x7000)
+	#define RX_PKT_COMPRESS_CMPL_METADATA1_TPID_SEL_SFT	12
 	/* 0x88a8 */
-		#define RX_TPA_START_V2_CMPL_METADATA1_TPID_SEL_TPID88A8   (UINT32_C(0x0) << 12)
+		#define RX_PKT_COMPRESS_CMPL_METADATA1_TPID_SEL_TPID88A8	(UINT32_C(0x0) << 12)
 	/* 0x8100 */
-		#define RX_TPA_START_V2_CMPL_METADATA1_TPID_SEL_TPID8100   (UINT32_C(0x1) << 12)
+		#define RX_PKT_COMPRESS_CMPL_METADATA1_TPID_SEL_TPID8100	(UINT32_C(0x1) << 12)
 	/* 0x9100 */
-		#define RX_TPA_START_V2_CMPL_METADATA1_TPID_SEL_TPID9100   (UINT32_C(0x2) << 12)
+		#define RX_PKT_COMPRESS_CMPL_METADATA1_TPID_SEL_TPID9100	(UINT32_C(0x2) << 12)
 	/* 0x9200 */
-		#define RX_TPA_START_V2_CMPL_METADATA1_TPID_SEL_TPID9200   (UINT32_C(0x3) << 12)
+		#define RX_PKT_COMPRESS_CMPL_METADATA1_TPID_SEL_TPID9200	(UINT32_C(0x3) << 12)
 	/* 0x9300 */
-		#define RX_TPA_START_V2_CMPL_METADATA1_TPID_SEL_TPID9300   (UINT32_C(0x4) << 12)
+		#define RX_PKT_COMPRESS_CMPL_METADATA1_TPID_SEL_TPID9300	(UINT32_C(0x4) << 12)
 	/* Value programmed in CFA VLANTPID register. */
-		#define RX_TPA_START_V2_CMPL_METADATA1_TPID_SEL_TPIDCFG	(UINT32_C(0x5) << 12)
-		#define RX_TPA_START_V2_CMPL_METADATA1_TPID_SEL_LAST	RX_TPA_START_V2_CMPL_METADATA1_TPID_SEL_TPIDCFG
+		#define RX_PKT_COMPRESS_CMPL_METADATA1_TPID_SEL_TPIDCFG	(UINT32_C(0x5) << 12)
+		#define RX_PKT_COMPRESS_CMPL_METADATA1_TPID_SEL_LAST	RX_PKT_COMPRESS_CMPL_METADATA1_TPID_SEL_TPIDCFG
 	/* When meta_format != 0, this value is the VLAN valid. */
-	#define RX_TPA_START_V2_CMPL_METADATA1_VALID		UINT32_C(0x8000)
+	#define RX_PKT_COMPRESS_CMPL_METADATA1_VALID		UINT32_C(0x8000)
+	/* This is data from the CFA as indicated by the meta_format field. */
+	uint16_t	vlanc_tcid;
+	/* When meta_format!=0, this value is the VLAN VID. */
+	#define RX_PKT_COMPRESS_CMPL_VLANC_TCID_VID_MASK UINT32_C(0xfff)
+	#define RX_PKT_COMPRESS_CMPL_VLANC_TCID_VID_SFT 0
+	/* When meta_format!=0, this value is the VLAN DE. */
+	#define RX_PKT_COMPRESS_CMPL_VLANC_TCID_DE	UINT32_C(0x1000)
+	/* When meta_format!=0, this value is the VLAN PRI. */
+	#define RX_PKT_COMPRESS_CMPL_VLANC_TCID_PRI_MASK UINT32_C(0xe000)
+	#define RX_PKT_COMPRESS_CMPL_VLANC_TCID_PRI_SFT 13
+	uint32_t	errors_agg_bufs_opaque;
+	/* Lower 16bits of the Opaque field provided in the Rx BD. */
+	#define RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_OPAQUE_MASK				UINT32_C(0xffff)
+	#define RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_OPAQUE_SFT				0
 	/*
-	 * This value is the RSS hash value calculated for the packet
-	 * based on the mode bits and key value in the VNIC.
-	 * When vee_cmpl_mode is set in VNIC context, this is the lower
-	 * 32b of the host address from the first BD used to place the packet.
+	 * This value is the number of aggregation buffers that follow this
+	 * entry in the completion ring that are a part of this packet.
+	 * If the value is zero, then the packet is completely contained
+	 * in the buffer space provided for the packet in the RX ring.
 	 */
-	uint32_t	rss_hash;
-} rx_tpa_start_v2_cmpl_t, *prx_tpa_start_v2_cmpl_t;
-
-/*
- * Last 16 bytes of RX L2 TPA Start V2 Completion Record
- *
- * This TPA completion structure is used on devices where the
- * `hwrm_vnic_qcaps.max_aggs_supported` value is 0.
- */
-/* rx_tpa_start_v2_cmpl_hi (size:128b/16B) */
-
-typedef struct rx_tpa_start_v2_cmpl_hi {
-	uint32_t	flags2;
-	/* This indicates that the aggregation was done using GRO rules. */
-	#define RX_TPA_START_V2_CMPL_FLAGS2_AGG_GRO			UINT32_C(0x4)
+	#define RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_AGG_BUFS_MASK				UINT32_C(0x1f0000)
+	#define RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_AGG_BUFS_SFT				16
+	#define RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_ERRORS_MASK				UINT32_C(0x1fe00000)
+	#define RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_ERRORS_SFT				21
 	/*
-	 * When this bit is '0', the cs_ok field has the following definition:-
-	 * ip_cs_ok[2:0] = The number of header groups with a valid IP checksum
-	 * in the delivered packet, counted from the outer-most header group to
-	 * the inner-most header group, stopping at the first error. -
-	 * l4_cs_ok[5:3] = The number of header groups with a valid L4 checksum
-	 * in the delivered packet, counted from the outer-most header group to
-	 * the inner-most header group, stopping at the first error. When this
-	 * bit is '1', the cs_ok field has the following definition: -
-	 * hdr_cnt[2:0] = The number of header groups that were parsed by the
-	 * chip and passed in the delivered packet. - ip_cs_all_ok[3] =This bit
-	 * will be '1' if all the parsed header groups with an IP checksum are
-	 * valid. - l4_cs_all_ok[4] = This bit will be '1' if all the parsed
-	 * header groups with an L4 checksum are valid.
+	 * This indicates that there was an error in the inner
+	 * portion of the packet when this
+	 * field is non-zero.
 	 */
-	#define RX_TPA_START_V2_CMPL_FLAGS2_CS_ALL_OK_MODE		UINT32_C(0x8)
-	/* This value indicates what format the metadata field is. */
-	#define RX_TPA_START_V2_CMPL_FLAGS2_META_FORMAT_MASK	UINT32_C(0xf0)
-	#define RX_TPA_START_V2_CMPL_FLAGS2_META_FORMAT_SFT		4
-	/* There is no metadata information. Values are zero. */
-		#define RX_TPA_START_V2_CMPL_FLAGS2_META_FORMAT_NONE		(UINT32_C(0x0) << 4)
+	#define RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_ERRORS_PKT_ERROR_MASK			UINT32_C(0x1e00000)
+	#define RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_ERRORS_PKT_ERROR_SFT			21
 	/*
-	 * The {metadata1, metadata0} fields contain the vtag
-	 * information: - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0],
-	 * de, vid[11:0]} The metadata2 field contains the table scope
-	 * and action record pointer. - metadata2[25:0] contains the
-	 * action record pointer. - metadata2[31:26] contains the table
-	 * scope.
+	 * No additional error occurred on the tunnel portion
+	 * or the packet of the packet does not have a tunnel.
 	 */
-		#define RX_TPA_START_V2_CMPL_FLAGS2_META_FORMAT_ACT_REC_PTR	(UINT32_C(0x1) << 4)
+		#define RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_ERRORS_PKT_ERROR_NO_ERROR		(UINT32_C(0x0) << 21)
 	/*
-	 * The {metadata1, metadata0} fields contain the vtag
-	 * information:
-	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0], de, vid[11:0]}
-	 * The metadata2 field contains the Tunnel ID
-	 * value, justified to LSB. i
-	 * - VXLAN = VNI[23:0] -> VXLAN Network ID
-	 * - Geneve (NGE) = VNI[23:0] a-> Virtual Network Identifier
-	 * - NVGRE = TNI[23:0] -> Tenant Network ID
-	 * - GRE = KEY[31:0] -> key field with bit mask. zero if K=0
-	 * - IPv4 = 0 (not populated)
-	 * - IPv6 = Flow Label[19:0]
-	 * - PPPoE = sessionID[15:0]
-	 * - MPLs = Outer label[19:0]
-	 * - UPAR = Selected[31:0] with bit mask
+	 * Indicates that IP header version does not match
+	 * expectation from L2 Ethertype for IPv4 and IPv6 or that
+	 * option other than VFT was parsed on
+	 * FCoE packet.
 	 */
-		#define RX_TPA_START_V2_CMPL_FLAGS2_META_FORMAT_TUNNEL_ID	(UINT32_C(0x2) << 4)
+		#define RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_ERRORS_PKT_ERROR_L3_BAD_VERSION		(UINT32_C(0x1) << 21)
 	/*
-	 * The {metadata1, metadata0} fields contain the vtag
-	 * information:
-	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0],de, vid[11:0]}
-	 * The metadata2 field contains the 32b metadata from the prepended
-	 * header (chdr_data).
+	 * indicates that header length is out of range. Valid for
+	 * IPv4 and RoCE
 	 */
-		#define RX_TPA_START_V2_CMPL_FLAGS2_META_FORMAT_CHDR_DATA	(UINT32_C(0x3) << 4)
+		#define RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_ERRORS_PKT_ERROR_L3_BAD_HDR_LEN		(UINT32_C(0x2) << 21)
 	/*
-	 * The {metadata1, metadata0} fields contain the vtag
-	 * information:
-	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0], de, vid[11:0]}
-	 * The metadata2 field contains the outer_l3_offset,
-	 * inner_l2_offset, inner_l3_offset, and inner_l4_size.
-	 * - metadata2[8:0] contains the outer_l3_offset.
-	 * - metadata2[17:9] contains the inner_l2_offset.
-	 * - metadata2[26:18] contains the inner_l3_offset.
-	 * - metadata2[31:27] contains the inner_l4_size.
+	 * indicates that the IPv4 TTL or IPv6 hop limit check
+	 * have failed (e.g. TTL = 0). Valid for IPv4, and IPv6
 	 */
-		#define RX_TPA_START_V2_CMPL_FLAGS2_META_FORMAT_HDR_OFFSET	(UINT32_C(0x4) << 4)
-		#define RX_TPA_START_V2_CMPL_FLAGS2_META_FORMAT_LAST		RX_TPA_START_V2_CMPL_FLAGS2_META_FORMAT_HDR_OFFSET
+		#define RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_ERRORS_PKT_ERROR_L3_BAD_TTL		(UINT32_C(0x3) << 21)
 	/*
-	 * This field indicates the IP type for the inner-most IP header.
-	 * A value of '0' indicates IPv4. A value of '1' indicates IPv6.
-	 * This value is only valid if itype indicates a packet
-	 * with an IP header.
+	 * Indicates that physical packet is shorter than that
+	 * claimed by the l3 header length. Valid for IPv4,
+	 * IPv6 packet or RoCE packets.
 	 */
-	#define RX_TPA_START_V2_CMPL_FLAGS2_IP_TYPE			UINT32_C(0x100)
+		#define RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_ERRORS_PKT_ERROR_IP_TOTAL_ERROR		(UINT32_C(0x4) << 21)
 	/*
-	 * This indicates that the complete 1's complement checksum was
-	 * calculated for the packet in the affregation.
+	 * Indicates that the physical packet is shorter than that
+	 * claimed by the UDP header length for a UDP packet that is
+	 * not fragmented.
 	 */
-	#define RX_TPA_START_V2_CMPL_FLAGS2_COMPLETE_CHECKSUM_CALC	UINT32_C(0x200)
+		#define RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_ERRORS_PKT_ERROR_UDP_TOTAL_ERROR		(UINT32_C(0x5) << 21)
 	/*
-	 * This field indicates the status of IP and L4 CS calculations done
-	 * by the chip. The format of this field is indicated by the
-	 * cs_all_ok_mode bit.
-	 * CS status for TPA packets is always valid. This means that "all_ok"
-	 * status will always be set. The ok count status will be set
-	 * appropriately for the packet header, such that all existing CS
-	 * values are ok.
+	 * Indicates that TCP header length > IP payload. Valid for
+	 * TCP packets only.
 	 */
-	#define RX_TPA_START_V2_CMPL_FLAGS2_CS_OK_MASK		UINT32_C(0xfc00)
-	#define RX_TPA_START_V2_CMPL_FLAGS2_CS_OK_SFT		10
+		#define RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_ERRORS_PKT_ERROR_L4_BAD_HDR_LEN		(UINT32_C(0x6) << 21)
+	/* Indicates that TCP header length < 5. Valid for TCP. */
+		#define RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_ERRORS_PKT_ERROR_L4_BAD_HDR_LEN_TOO_SMALL   (UINT32_C(0x7) << 21)
 	/*
-	 * This value is the complete 1's complement checksum calculated from
-	 * the start of the outer L3 header to the end of the packet (not
-	 * including the ethernet crc). It is valid when the
-	 * 'complete_checksum_calc' flag is set. For TPA Start completions,
-	 * the complete checksum is calculated for the first packet in the
-	 * aggregation only.
+	 * Indicates that TCP option headers result in a TCP header
+	 * size that does not match data offset in TCP header. Valid
+	 * for TCP.
 	 */
-	#define RX_TPA_START_V2_CMPL_FLAGS2_COMPLETE_CHECKSUM_MASK	UINT32_C(0xffff0000)
-	#define RX_TPA_START_V2_CMPL_FLAGS2_COMPLETE_CHECKSUM_SFT	16
+		#define RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_ERRORS_PKT_ERROR_L4_BAD_OPT_LEN		(UINT32_C(0x8) << 21)
+		#define RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_ERRORS_PKT_ERROR_LAST			RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_ERRORS_PKT_ERROR_L4_BAD_OPT_LEN
 	/*
-	 * This is data from the CFA block as indicated by the meta_format
-	 * field.
-	 * - meta_format 0 - none - metadata2 = 0 - not valid/not stripped
-	 * - meta_format 1 - act_rec_ptr - metadata2 = {table_scope[5:0],
-	 *   act_rec_ptr[25:0]}
-	 * - meta_format 2 - tunnel_id - metadata2 = tunnel_id[31:0]
-	 * - meta_format 3 - chdr_data - metadata2 = updated_chdr_data[31:0]
-	 * - meta_format 4 - hdr_offsets - metadata2 = hdr_offsets[31:0]
-	 * When vee_cmpl_mode is set in VNIC context, this is the upper 32b
-	 * of the host address from the first BD used to place the packet.
+	 * This indicates that there was an error in the tunnel portion
+	 * of the packet when this field is non-zero.
 	 */
-	uint32_t	metadata2;
-	uint16_t	errors_v2;
+	#define RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_ERRORS_T_PKT_ERROR_MASK		UINT32_C(0xe000000)
+	#define RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_ERRORS_T_PKT_ERROR_SFT			25
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * No additional error occurred on the tunnel portion
+	 * of the packet or the packet does not have a tunnel.
 	 */
-	#define RX_TPA_START_V2_CMPL_V2				UINT32_C(0x1)
-	#define RX_TPA_START_V2_CMPL_ERRORS_MASK			UINT32_C(0xfffe)
-	#define RX_TPA_START_V2_CMPL_ERRORS_SFT			1
+		#define RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_ERRORS_T_PKT_ERROR_NO_ERROR		(UINT32_C(0x0) << 25)
 	/*
-	 * This error indicates that there was some sort of problem with
-	 * the BDs for the packetThe packet should be treated as
-	 * invalid.
+	 * Indicates that IP header version does not match expectation
+	 * from L2 Ethertype for IPv4 and IPv6 in the tunnel header.
 	 */
-	#define RX_TPA_START_V2_CMPL_ERRORS_BUFFER_ERROR_MASK	UINT32_C(0xe)
-	#define RX_TPA_START_V2_CMPL_ERRORS_BUFFER_ERROR_SFT	1
-	/* No buffer error */
-		#define RX_TPA_START_V2_CMPL_ERRORS_BUFFER_ERROR_NO_BUFFER	(UINT32_C(0x0) << 1)
+		#define RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_ERRORS_T_PKT_ERROR_T_L3_BAD_VERSION	(UINT32_C(0x1) << 25)
 	/*
-	 * Did Not Fit:
-	 * Packet did not fit into packet buffer provided. This means
-	 * that the TPA Start packet was too big to be placed into the
-	 * per-packet maximum number of physical buffers configured for
-	 * the VNIC, or that it was too big to be placed into the
-	 * per-aggregation maximum number of physical buffers configured
-	 * for the VNIC. This error only occurs when the VNIC is
-	 * configured for variable size receive buffers.
+	 * Indicates that header length is out of range in the tunnel
+	 * header. Valid for IPv4.
 	 */
-		#define RX_TPA_START_V2_CMPL_ERRORS_BUFFER_ERROR_DID_NOT_FIT   (UINT32_C(0x1) << 1)
+		#define RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_ERRORS_T_PKT_ERROR_T_L3_BAD_HDR_LEN	(UINT32_C(0x2) << 25)
 	/*
-	 * Bad Format:
-	 * BDs were not formatted correctly.
+	 * Indicates that physical packet is shorter than that claimed
+	 * by the tunnel l3 header length. Valid for IPv4, or IPv6 tunnel
+	 * packet packets.
 	 */
-		#define RX_TPA_START_V2_CMPL_ERRORS_BUFFER_ERROR_BAD_FORMAT	(UINT32_C(0x3) << 1)
+		#define RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_ERRORS_T_PKT_ERROR_T_IP_TOTAL_ERROR	(UINT32_C(0x3) << 25)
 	/*
-	 * Flush:
-	 * There was a bad_format error on the previous operation
+	 * Indicates that the physical packet is shorter than that claimed
+	 * by the tunnel UDP header length for a tunnel UDP packet that is
+	 * not fragmented.
 	 */
-		#define RX_TPA_START_V2_CMPL_ERRORS_BUFFER_ERROR_FLUSH	(UINT32_C(0x5) << 1)
-		#define RX_TPA_START_V2_CMPL_ERRORS_BUFFER_ERROR_LAST	RX_TPA_START_V2_CMPL_ERRORS_BUFFER_ERROR_FLUSH
+		#define RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_ERRORS_T_PKT_ERROR_T_UDP_TOTAL_ERROR	(UINT32_C(0x4) << 25)
 	/*
-	 * This is data from the CFA block as indicated by the meta_format
-	 * field.
+	 * Indicates that the IPv4 TTL or IPv6 hop limit check have failed
+	 * (e.g. TTL = 0) in the tunnel header. Valid for IPv4, and IPv6.
 	 */
-	uint16_t	metadata0;
-	/* When meta_format != 0, this value is the VLAN VID. */
-	#define RX_TPA_START_V2_CMPL_METADATA0_VID_MASK UINT32_C(0xfff)
-	#define RX_TPA_START_V2_CMPL_METADATA0_VID_SFT 0
-	/* When meta_format != 0, this value is the VLAN DE. */
-	#define RX_TPA_START_V2_CMPL_METADATA0_DE	UINT32_C(0x1000)
-	/* When meta_format != 0, this value is the VLAN PRI. */
-	#define RX_TPA_START_V2_CMPL_METADATA0_PRI_MASK UINT32_C(0xe000)
-	#define RX_TPA_START_V2_CMPL_METADATA0_PRI_SFT 13
+		#define RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_ERRORS_T_PKT_ERROR_T_L3_BAD_TTL		(UINT32_C(0x5) << 25)
 	/*
-	 * This field contains the outer_l3_offset, inner_l2_offset,
-	 * inner_l3_offset, and inner_l4_size.
-	 *
-	 * hdr_offsets[8:0] contains the outer_l3_offset.
-	 * hdr_offsets[17:9] contains the inner_l2_offset.
-	 * hdr_offsets[26:18] contains the inner_l3_offset.
-	 * hdr_offsets[31:27] contains the inner_l4_size.
+	 * Indicates that the IP checksum failed its check in the tunnel
+	 * header.
 	 */
-	uint32_t	hdr_offsets;
-} rx_tpa_start_v2_cmpl_hi_t, *prx_tpa_start_v2_cmpl_hi_t;
+		#define RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_ERRORS_T_PKT_ERROR_T_IP_CS_ERROR		(UINT32_C(0x6) << 25)
+	/*
+	 * Indicates that the L4 checksum failed its check in the tunnel
+	 * header.
+	 */
+		#define RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_ERRORS_T_PKT_ERROR_T_L4_CS_ERROR		(UINT32_C(0x7) << 25)
+		#define RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_ERRORS_T_PKT_ERROR_LAST			RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_ERRORS_T_PKT_ERROR_T_L4_CS_ERROR
+	/*
+	 * This indicates that there was a CRC error on either an FCoE
+	 * or RoCE packet. The itype indicates the packet type.
+	 */
+	#define RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_ERRORS_CRC_ERROR			UINT32_C(0x10000000)
+	/* unused1 is 3 b */
+	#define RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_UNUSED1_MASK				UINT32_C(0xe0000000)
+	#define RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_UNUSED1_SFT				29
+} rx_pkt_compress_cmpl_t, *prx_pkt_compress_cmpl_t;
 
 /*
  * This TPA completion structure is used on devices where the
  * `hwrm_vnic_qcaps.max_aggs_supported` value is 0.
  */
-/* rx_tpa_end_cmpl (size:128b/16B) */
+/* rx_tpa_start_cmpl (size:128b/16B) */
 
-typedef struct rx_tpa_end_cmpl {
+typedef struct rx_tpa_start_cmpl {
 	uint16_t	flags_type;
 	/*
 	 * This field indicates the exact type of the completion.
@@ -6258,26 +7310,22 @@ typedef struct rx_tpa_end_cmpl {
 	 * records. Odd values indicate 32B
 	 * records.
 	 */
-	#define RX_TPA_END_CMPL_TYPE_MASK			UINT32_C(0x3f)
-	#define RX_TPA_END_CMPL_TYPE_SFT			0
+	#define RX_TPA_START_CMPL_TYPE_MASK		UINT32_C(0x3f)
+	#define RX_TPA_START_CMPL_TYPE_SFT		0
 	/*
-	 * RX L2 TPA End Completion:
-	 * Completion at the end of a TPA operation.
+	 * RX L2 TPA Start Completion:
+	 * Completion at the beginning of a TPA operation.
 	 * Length = 32B
 	 */
-		#define RX_TPA_END_CMPL_TYPE_RX_TPA_END		UINT32_C(0x15)
-		#define RX_TPA_END_CMPL_TYPE_LAST			RX_TPA_END_CMPL_TYPE_RX_TPA_END
-	#define RX_TPA_END_CMPL_FLAGS_MASK			UINT32_C(0xffc0)
-	#define RX_TPA_END_CMPL_FLAGS_SFT			6
-	/*
-	 * When this bit is '1', it indicates a packet that has an
-	 * error of some type. Type of error is indicated in
-	 * error_flags.
-	 */
-	#define RX_TPA_END_CMPL_FLAGS_ERROR			UINT32_C(0x40)
+		#define RX_TPA_START_CMPL_TYPE_RX_TPA_START	UINT32_C(0x13)
+		#define RX_TPA_START_CMPL_TYPE_LAST		RX_TPA_START_CMPL_TYPE_RX_TPA_START
+	#define RX_TPA_START_CMPL_FLAGS_MASK		UINT32_C(0xffc0)
+	#define RX_TPA_START_CMPL_FLAGS_SFT		6
+	/* This bit will always be '0' for TPA start completions. */
+	#define RX_TPA_START_CMPL_FLAGS_ERROR		UINT32_C(0x40)
 	/* This field indicates how the packet was placed in the buffer. */
-	#define RX_TPA_END_CMPL_FLAGS_PLACEMENT_MASK		UINT32_C(0x380)
-	#define RX_TPA_END_CMPL_FLAGS_PLACEMENT_SFT		7
+	#define RX_TPA_START_CMPL_FLAGS_PLACEMENT_MASK	UINT32_C(0x380)
+	#define RX_TPA_START_CMPL_FLAGS_PLACEMENT_SFT	7
 	/*
 	 * Jumbo:
 	 * TPA Packet was placed using jumbo algorithm. This means
@@ -6286,21 +7334,13 @@ typedef struct rx_tpa_end_cmpl {
 	 * will be filled before moving to the next aggregation
 	 * buffer.
 	 */
-		#define RX_TPA_END_CMPL_FLAGS_PLACEMENT_JUMBO		(UINT32_C(0x1) << 7)
+		#define RX_TPA_START_CMPL_FLAGS_PLACEMENT_JUMBO	(UINT32_C(0x1) << 7)
 	/*
 	 * Header/Data Separation:
 	 * Packet was placed using Header/Data separation algorithm.
 	 * The separation location is indicated by the itype field.
 	 */
-		#define RX_TPA_END_CMPL_FLAGS_PLACEMENT_HDS		(UINT32_C(0x2) << 7)
-	/*
-	 * IOC/Jumbo:
-	 * Packet will be placed using In-Order Completion/Jumbo where
-	 * the first packet of the aggregation is placed using Jumbo
-	 * Placement. Subsequent packets will be placed such that each
-	 * packet starts at the beginning of an aggregation buffer.
-	 */
-		#define RX_TPA_END_CMPL_FLAGS_PLACEMENT_IOC_JUMBO	(UINT32_C(0x4) << 7)
+		#define RX_TPA_START_CMPL_FLAGS_PLACEMENT_HDS	(UINT32_C(0x2) << 7)
 	/*
 	 * GRO/Jumbo:
 	 * Packet will be placed using GRO/Jumbo where the first
@@ -6309,7 +7349,7 @@ typedef struct rx_tpa_end_cmpl {
 	 * aggregation buffers unless it starts at the beginning of
 	 * an aggregation buffer.
 	 */
-		#define RX_TPA_END_CMPL_FLAGS_PLACEMENT_GRO_JUMBO	(UINT32_C(0x5) << 7)
+		#define RX_TPA_START_CMPL_FLAGS_PLACEMENT_GRO_JUMBO   (UINT32_C(0x5) << 7)
 	/*
 	 * GRO/Header-Data Separation:
 	 * Packet will be placed using GRO/HDS where the header
@@ -6319,270 +7359,24 @@ typedef struct rx_tpa_end_cmpl {
 	 * aggregation buffers unless it starts at the beginning of
 	 * an aggregation buffer.
 	 */
-		#define RX_TPA_END_CMPL_FLAGS_PLACEMENT_GRO_HDS	(UINT32_C(0x6) << 7)
-	/*
-	 * IOC/Header-Data Separation:
-	 * Packet will be placed using In-Order Completion/HDS where
-	 * the header is in the first packet buffer. Payload of each
-	 * packet will be placed such that each packet starts at the
-	 * beginning of an aggregation buffer.
-	 */
-		#define RX_TPA_END_CMPL_FLAGS_PLACEMENT_IOC_HDS	(UINT32_C(0x7) << 7)
-		#define RX_TPA_END_CMPL_FLAGS_PLACEMENT_LAST		RX_TPA_END_CMPL_FLAGS_PLACEMENT_IOC_HDS
+		#define RX_TPA_START_CMPL_FLAGS_PLACEMENT_GRO_HDS	(UINT32_C(0x6) << 7)
+		#define RX_TPA_START_CMPL_FLAGS_PLACEMENT_LAST	RX_TPA_START_CMPL_FLAGS_PLACEMENT_GRO_HDS
+	/* This bit is '1' if the RSS field in this completion is valid. */
+	#define RX_TPA_START_CMPL_FLAGS_RSS_VALID	UINT32_C(0x400)
 	/* unused is 1 b */
-	#define RX_TPA_END_CMPL_FLAGS_UNUSED			UINT32_C(0x400)
+	#define RX_TPA_START_CMPL_FLAGS_UNUSED		UINT32_C(0x800)
 	/*
-	 * This bit is '1' if metadata has been added to the end of the
-	 * packet in host memory. Metadata starts at the first 32B boundary
-	 * after the end of the packet for regular and jumbo placement.
-	 * It starts at the first 32B boundary after the end of the header
-	 * for HDS placement. The length of the metadata is indicated in the
-	 * metadata itself.
+	 * This value indicates what the inner packet determined for the
+	 * packet was.
 	 */
-	#define RX_TPA_END_CMPL_FLAGS_PKT_METADATA_PRESENT	UINT32_C(0x800)
-	/*
-	 * This value indicates what the inner packet determined for the
-	 * packet was.
-	 * - 2 TCP Packet
-	 *	Indicates that the packet was IP and TCP. This indicates
-	 *	that the ip_cs field is valid and that the tcp_udp_cs
-	 *	field is valid and contains the TCP checksum.
-	 *	This also indicates that the payload_offset field is valid.
-	 */
-	#define RX_TPA_END_CMPL_FLAGS_ITYPE_MASK		UINT32_C(0xf000)
-	#define RX_TPA_END_CMPL_FLAGS_ITYPE_SFT		12
-	/*
-	 * This value is zero for TPA End completions.
-	 * There is no data in the buffer that corresponds to the opaque
-	 * value in this completion.
-	 */
-	uint16_t	len;
-	/*
-	 * This is a copy of the opaque field from the RX BD this completion
-	 * corresponds to.
-	 */
-	uint32_t	opaque;
-	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
-	 */
-	uint8_t	agg_bufs_v1;
-	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
-	 */
-	#define RX_TPA_END_CMPL_V1	UINT32_C(0x1)
-	/*
-	 * This value is the number of aggregation buffers that follow this
-	 * entry in the completion ring that are a part of this aggregation
-	 * packet.
-	 * If the value is zero, then the packet is completely contained
-	 * in the buffer space provided in the aggregation start completion.
-	 */
-	#define RX_TPA_END_CMPL_AGG_BUFS_MASK UINT32_C(0x7e)
-	#define RX_TPA_END_CMPL_AGG_BUFS_SFT 1
-	/* This value is the number of segments in the TPA operation. */
-	uint8_t	tpa_segs;
-	/*
-	 * This value indicates the offset in bytes from the beginning of the packet
-	 * where the inner payload starts. This value is valid for TCP, UDP,
-	 * FCoE, and RoCE packets.
-	 *
-	 * A value of zero indicates an offset of 256 bytes.
-	 */
-	uint8_t	payload_offset;
-	uint8_t	agg_id;
-	/* unused2 is 1 b */
-	#define RX_TPA_END_CMPL_UNUSED2	UINT32_C(0x1)
-	/*
-	 * This is the aggregation ID that the completion is associated
-	 * with. Use this number to correlate the TPA start completion
-	 * with the TPA end completion.
-	 */
-	#define RX_TPA_END_CMPL_AGG_ID_MASK UINT32_C(0xfe)
-	#define RX_TPA_END_CMPL_AGG_ID_SFT  1
-	/*
-	 * For non-GRO packets, this value is the
-	 * timestamp delta between earliest and latest timestamp values for
-	 * TPA packet. If packets were not time stamped, then delta will be
-	 * zero.
-	 *
-	 * For GRO packets, this field is zero except for the following
-	 * sub-fields.
-	 * - tsdelta[31]
-	 *	Timestamp present indication. When '0', no Timestamp
-	 *	option is in the packet. When '1', then a Timestamp
-	 *	option is present in the packet.
-	 */
-	uint32_t	tsdelta;
-} rx_tpa_end_cmpl_t, *prx_tpa_end_cmpl_t;
-
-/*
- * Last 16 bytes of rx_tpa_end_cmpl.
- *
- * This TPA completion structure is used on devices where the
- * `hwrm_vnic_qcaps.max_aggs_supported` value is 0.
- */
-/* rx_tpa_end_cmpl_hi (size:128b/16B) */
-
-typedef struct rx_tpa_end_cmpl_hi {
-	uint32_t	tpa_dup_acks;
-	/*
-	 * This value is the number of duplicate ACKs that have been
-	 * received as part of the TPA operation.
-	 */
-	#define RX_TPA_END_CMPL_TPA_DUP_ACKS_MASK UINT32_C(0xf)
-	#define RX_TPA_END_CMPL_TPA_DUP_ACKS_SFT 0
-	/*
-	 * This value is the valid when TPA completion is active. It
-	 * indicates the length of the longest segment of the TPA operation
-	 * for LRO mode and the length of the first segment in GRO mode.
-	 *
-	 * This value may be used by GRO software to re-construct the original
-	 * packet stream from the TPA packet. This is the length of all
-	 * but the last segment for GRO. In LRO mode this value may be used
-	 * to indicate MSS size to the stack.
-	 */
-	uint16_t	tpa_seg_len;
-	/* unused4 is 16 b */
-	uint16_t	unused3;
-	uint16_t	errors_v2;
-	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
-	 */
-	#define RX_TPA_END_CMPL_V2				UINT32_C(0x1)
-	#define RX_TPA_END_CMPL_ERRORS_MASK			UINT32_C(0xfffe)
-	#define RX_TPA_END_CMPL_ERRORS_SFT			1
-	/*
-	 * This error indicates that there was some sort of problem with
-	 * the BDs for the packet that was found after part of the
-	 * packet was already placed. The packet should be treated as
-	 * invalid.
-	 */
-	#define RX_TPA_END_CMPL_ERRORS_BUFFER_ERROR_MASK	UINT32_C(0xe)
-	#define RX_TPA_END_CMPL_ERRORS_BUFFER_ERROR_SFT	1
-	/*
-	 * This error occurs when there is a fatal HW problem in
-	 * the chip only. It indicates that there were not
-	 * BDs on chip but that there was adequate reservation.
-	 * provided by the TPA block.
-	 */
-		#define RX_TPA_END_CMPL_ERRORS_BUFFER_ERROR_NOT_ON_CHIP   (UINT32_C(0x2) << 1)
-	/*
-	 * This error occurs when TPA block was not configured to
-	 * reserve adequate BDs for TPA operations on this RX
-	 * ring. All data for the TPA operation was not placed.
-	 *
-	 * This error can also be generated when the number of
-	 * segments is not programmed correctly in TPA and the
-	 * 33 total aggregation buffers allowed for the TPA
-	 * operation has been exceeded.
-	 */
-		#define RX_TPA_END_CMPL_ERRORS_BUFFER_ERROR_RSV_ERROR	(UINT32_C(0x4) << 1)
-		#define RX_TPA_END_CMPL_ERRORS_BUFFER_ERROR_LAST	RX_TPA_END_CMPL_ERRORS_BUFFER_ERROR_RSV_ERROR
-	/* unused5 is 16 b */
-	uint16_t	unused_4;
-	/*
-	 * This is the opaque value that was completed for the TPA start
-	 * completion that corresponds to this TPA end completion.
-	 */
-	uint32_t	start_opaque;
-} rx_tpa_end_cmpl_hi_t, *prx_tpa_end_cmpl_hi_t;
-
-/*
- * This TPA completion structure is used on devices where the
- * `hwrm_vnic_qcaps.max_aggs_supported` value is greater than 0.
- */
-/* rx_tpa_v2_start_cmpl (size:128b/16B) */
-
-typedef struct rx_tpa_v2_start_cmpl {
-	uint16_t	flags_type;
-	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
-	 */
-	#define RX_TPA_V2_START_CMPL_TYPE_MASK			UINT32_C(0x3f)
-	#define RX_TPA_V2_START_CMPL_TYPE_SFT			0
-	/*
-	 * RX L2 TPA Start Completion:
-	 * Completion at the beginning of a TPA operation.
-	 * Length = 32B
-	 */
-		#define RX_TPA_V2_START_CMPL_TYPE_RX_TPA_START		UINT32_C(0x13)
-		#define RX_TPA_V2_START_CMPL_TYPE_LAST			RX_TPA_V2_START_CMPL_TYPE_RX_TPA_START
-	#define RX_TPA_V2_START_CMPL_FLAGS_MASK			UINT32_C(0xffc0)
-	#define RX_TPA_V2_START_CMPL_FLAGS_SFT			6
-	/* This bit will always be '0' for TPA start completions. */
-	#define RX_TPA_V2_START_CMPL_FLAGS_ERROR			UINT32_C(0x40)
-	/* This field indicates how the packet was placed in the buffer. */
-	#define RX_TPA_V2_START_CMPL_FLAGS_PLACEMENT_MASK		UINT32_C(0x380)
-	#define RX_TPA_V2_START_CMPL_FLAGS_PLACEMENT_SFT		7
-	/*
-	 * Jumbo:
-	 * TPA Packet was placed using jumbo algorithm. This means
-	 * that the first buffer will be filled with data before
-	 * moving to aggregation buffers. Each aggregation buffer
-	 * will be filled before moving to the next aggregation
-	 * buffer.
-	 */
-		#define RX_TPA_V2_START_CMPL_FLAGS_PLACEMENT_JUMBO		(UINT32_C(0x1) << 7)
-	/*
-	 * Header/Data Separation:
-	 * Packet was placed using Header/Data separation algorithm.
-	 * The separation location is indicated by the itype field.
-	 */
-		#define RX_TPA_V2_START_CMPL_FLAGS_PLACEMENT_HDS		(UINT32_C(0x2) << 7)
-	/*
-	 * GRO/Jumbo:
-	 * Packet will be placed using GRO/Jumbo where the first
-	 * packet is filled with data. Subsequent packets will be
-	 * placed such that any one packet does not span two
-	 * aggregation buffers unless it starts at the beginning of
-	 * an aggregation buffer.
-	 */
-		#define RX_TPA_V2_START_CMPL_FLAGS_PLACEMENT_GRO_JUMBO	(UINT32_C(0x5) << 7)
-	/*
-	 * GRO/Header-Data Separation:
-	 * Packet will be placed using GRO/HDS where the header
-	 * is in the first packet.
-	 * Payload of each packet will be
-	 * placed such that any one packet does not span two
-	 * aggregation buffers unless it starts at the beginning of
-	 * an aggregation buffer.
-	 */
-		#define RX_TPA_V2_START_CMPL_FLAGS_PLACEMENT_GRO_HDS	(UINT32_C(0x6) << 7)
-		#define RX_TPA_V2_START_CMPL_FLAGS_PLACEMENT_LAST		RX_TPA_V2_START_CMPL_FLAGS_PLACEMENT_GRO_HDS
-	/* This bit is '1' if the RSS field in this completion is valid. */
-	#define RX_TPA_V2_START_CMPL_FLAGS_RSS_VALID		UINT32_C(0x400)
-	/*
-	 * For devices that support timestamps, when this bit is cleared the
-	 * `inner_l4_size_inner_l3_offset_inner_l2_offset_outer_l3_offset`
-	 * field contains the 32b timestamp for
-	 * the packet from the MAC. When this bit is set, the
-	 * `inner_l4_size_inner_l3_offset_inner_l2_offset_outer_l3_offset`
-	 * field contains the outer_l3_offset, inner_l2_offset,
-	 * inner_l3_offset, and inner_l4_size.
-	 */
-	#define RX_TPA_V2_START_CMPL_FLAGS_TIMESTAMP_FLD_FORMAT	UINT32_C(0x800)
-	/*
-	 * This value indicates what the inner packet determined for the
-	 * packet was.
-	 */
-	#define RX_TPA_V2_START_CMPL_FLAGS_ITYPE_MASK		UINT32_C(0xf000)
-	#define RX_TPA_V2_START_CMPL_FLAGS_ITYPE_SFT		12
+	#define RX_TPA_START_CMPL_FLAGS_ITYPE_MASK	UINT32_C(0xf000)
+	#define RX_TPA_START_CMPL_FLAGS_ITYPE_SFT	12
 	/*
 	 * TCP Packet:
 	 * Indicates that the packet was IP and TCP.
 	 */
-		#define RX_TPA_V2_START_CMPL_FLAGS_ITYPE_TCP		(UINT32_C(0x2) << 12)
-		#define RX_TPA_V2_START_CMPL_FLAGS_ITYPE_LAST		RX_TPA_V2_START_CMPL_FLAGS_ITYPE_TCP
+		#define RX_TPA_START_CMPL_FLAGS_ITYPE_TCP		(UINT32_C(0x2) << 12)
+		#define RX_TPA_START_CMPL_FLAGS_ITYPE_LAST	RX_TPA_START_CMPL_FLAGS_ITYPE_TCP
 	/*
 	 * This value indicates the amount of packet data written to the
 	 * buffer the opaque field in this completion corresponds to.
@@ -6604,8 +7398,8 @@ typedef struct rx_tpa_v2_start_cmpl {
 	 * for each pass through the completion queue. The even passes
 	 * will write 1. The odd passes will write 0.
 	 */
-	#define RX_TPA_V2_START_CMPL_V1 UINT32_C(0x1)
-	#define RX_TPA_V2_START_CMPL_LAST RX_TPA_V2_START_CMPL_V1
+	#define RX_TPA_START_CMPL_V1 UINT32_C(0x1)
+	#define RX_TPA_START_CMPL_LAST RX_TPA_START_CMPL_V1
 	/*
 	 * This is the RSS hash type for the packet. The value is packed
 	 * {tuple_extrac_op[1:0],rss_profile_id[4:0],tuple_extrac_op[2]}.
@@ -6642,52 +7436,62 @@ typedef struct rx_tpa_v2_start_cmpl {
 	 * with the TPA end completion.
 	 */
 	uint16_t	agg_id;
+	/* unused2 is 9 b */
+	#define RX_TPA_START_CMPL_UNUSED2_MASK UINT32_C(0x1ff)
+	#define RX_TPA_START_CMPL_UNUSED2_SFT 0
+	/*
+	 * This is the aggregation ID that the completion is associated
+	 * with. Use this number to correlate the TPA start completion
+	 * with the TPA end completion.
+	 */
+	#define RX_TPA_START_CMPL_AGG_ID_MASK UINT32_C(0xfe00)
+	#define RX_TPA_START_CMPL_AGG_ID_SFT  9
 	/*
 	 * This value is the RSS hash value calculated for the packet
 	 * based on the mode bits and key value in the VNIC.
 	 */
 	uint32_t	rss_hash;
-} rx_tpa_v2_start_cmpl_t, *prx_tpa_v2_start_cmpl_t;
+} rx_tpa_start_cmpl_t, *prx_tpa_start_cmpl_t;
 
 /*
- * Last 16 bytes of rx_tpa_v2_start_cmpl.
+ * Last 16 bytes of rx_tpa_start_cmpl.
  *
  * This TPA completion structure is used on devices where the
- * `hwrm_vnic_qcaps.max_aggs_supported` value is greater than 0.
+ * `hwrm_vnic_qcaps.max_aggs_supported` value is 0.
  */
-/* rx_tpa_v2_start_cmpl_hi (size:128b/16B) */
+/* rx_tpa_start_cmpl_hi (size:128b/16B) */
 
-typedef struct rx_tpa_v2_start_cmpl_hi {
+typedef struct rx_tpa_start_cmpl_hi {
 	uint32_t	flags2;
 	/*
 	 * This indicates that the ip checksum was calculated for the
 	 * inner packet and that the sum passed for all segments
 	 * included in the aggregation.
 	 */
-	#define RX_TPA_V2_START_CMPL_FLAGS2_IP_CS_CALC		UINT32_C(0x1)
+	#define RX_TPA_START_CMPL_FLAGS2_IP_CS_CALC	UINT32_C(0x1)
 	/*
 	 * This indicates that the TCP, UDP or ICMP checksum was
 	 * calculated for the inner packet and that the sum passed
 	 * for all segments included in the aggregation.
 	 */
-	#define RX_TPA_V2_START_CMPL_FLAGS2_L4_CS_CALC		UINT32_C(0x2)
+	#define RX_TPA_START_CMPL_FLAGS2_L4_CS_CALC	UINT32_C(0x2)
 	/*
 	 * This indicates that the ip checksum was calculated for the
 	 * tunnel header and that the sum passed for all segments
 	 * included in the aggregation.
 	 */
-	#define RX_TPA_V2_START_CMPL_FLAGS2_T_IP_CS_CALC		UINT32_C(0x4)
+	#define RX_TPA_START_CMPL_FLAGS2_T_IP_CS_CALC	UINT32_C(0x4)
 	/*
 	 * This indicates that the UDP checksum was
 	 * calculated for the tunnel packet and that the sum passed for
 	 * all segments included in the aggregation.
 	 */
-	#define RX_TPA_V2_START_CMPL_FLAGS2_T_L4_CS_CALC		UINT32_C(0x8)
+	#define RX_TPA_START_CMPL_FLAGS2_T_L4_CS_CALC	UINT32_C(0x8)
 	/* This value indicates what format the metadata field is. */
-	#define RX_TPA_V2_START_CMPL_FLAGS2_META_FORMAT_MASK	UINT32_C(0xf0)
-	#define RX_TPA_V2_START_CMPL_FLAGS2_META_FORMAT_SFT		4
-	/* No metadata informtaion. Value is zero. */
-		#define RX_TPA_V2_START_CMPL_FLAGS2_META_FORMAT_NONE		(UINT32_C(0x0) << 4)
+	#define RX_TPA_START_CMPL_FLAGS2_META_FORMAT_MASK UINT32_C(0xf0)
+	#define RX_TPA_START_CMPL_FLAGS2_META_FORMAT_SFT  4
+	/* No metadata information. Value is zero. */
+		#define RX_TPA_START_CMPL_FLAGS2_META_FORMAT_NONE   (UINT32_C(0x0) << 4)
 	/*
 	 * The metadata field contains the VLAN tag and TPID value.
 	 * - metadata[11:0] contains the vlan VID value.
@@ -6695,124 +7499,45 @@ typedef struct rx_tpa_v2_start_cmpl_hi {
 	 * - metadata[15:13] contains the vlan PRI value.
 	 * - metadata[31:16] contains the vlan TPID value.
 	 */
-		#define RX_TPA_V2_START_CMPL_FLAGS2_META_FORMAT_VLAN		(UINT32_C(0x1) << 4)
-	/*
-	 * If ext_meta_format is equal to 1, the metadata field
-	 * contains the lower 16b of the tunnel ID value, justified
-	 * to LSB
-	 * - VXLAN = VNI[23:0] -> VXLAN Network ID
-	 * - Geneve (NGE) = VNI[23:0] a-> Virtual Network Identifier.
-	 * - NVGRE = TNI[23:0] -> Tenant Network ID
-	 * - GRE = KEY[31:0 -> key fieled with bit mask. zero if K = 0
-	 * - IPV4 = 0 (not populated)
-	 * - IPV6 = Flow Label[19:0]
-	 * - PPPoE = sessionID[15:0]
-	 * - MPLs = Outer label[19:0]
-	 * - UPAR = Selected[31:0] with bit mask
-	 */
-		#define RX_TPA_V2_START_CMPL_FLAGS2_META_FORMAT_TUNNEL_ID	(UINT32_C(0x2) << 4)
-	/*
-	 * if ext_meta_format is equal to 1, metadata field contains
-	 * 16b metadata from the prepended header (chdr_data).
-	 */
-		#define RX_TPA_V2_START_CMPL_FLAGS2_META_FORMAT_CHDR_DATA	(UINT32_C(0x3) << 4)
-	/*
-	 * If ext_meta_format is equal to 1, the metadata field contains
-	 * the outer_l3_offset, inner_l2_offset, inner_l3_offset and
-	 * inner_l4_size.
-	 * - metadata[8:0] contains the outer_l3_offset.
-	 * - metadata[17:9] contains the inner_l2_offset.
-	 * - metadata[26:18] contains the inner_l3_offset.
-	 * - metadata[31:27] contains the inner_l4_size.
-	 */
-		#define RX_TPA_V2_START_CMPL_FLAGS2_META_FORMAT_HDR_OFFSET	(UINT32_C(0x4) << 4)
-		#define RX_TPA_V2_START_CMPL_FLAGS2_META_FORMAT_LAST		RX_TPA_V2_START_CMPL_FLAGS2_META_FORMAT_HDR_OFFSET
+		#define RX_TPA_START_CMPL_FLAGS2_META_FORMAT_VLAN   (UINT32_C(0x1) << 4)
+		#define RX_TPA_START_CMPL_FLAGS2_META_FORMAT_LAST  RX_TPA_START_CMPL_FLAGS2_META_FORMAT_VLAN
 	/*
 	 * This field indicates the IP type for the inner-most IP header.
 	 * A value of '0' indicates IPv4. A value of '1' indicates IPv6.
 	 */
-	#define RX_TPA_V2_START_CMPL_FLAGS2_IP_TYPE			UINT32_C(0x100)
-	/*
-	 * This indicates that the complete 1's complement checksum was
-	 * calculated for the packet.
-	 */
-	#define RX_TPA_V2_START_CMPL_FLAGS2_COMPLETE_CHECKSUM_CALC	UINT32_C(0x200)
-	/*
-	 * The combination of this value and meta_format indicated what
-	 * format the metadata field is.
-	 */
-	#define RX_TPA_V2_START_CMPL_FLAGS2_EXT_META_FORMAT_MASK	UINT32_C(0xc00)
-	#define RX_TPA_V2_START_CMPL_FLAGS2_EXT_META_FORMAT_SFT	10
-	/*
-	 * This value is the complete 1's complement checksum calculated from
-	 * the start of the outer L3 header to the end of the packet (not
-	 * including the ethernet crc). It is valid when the
-	 * 'complete_checksum_calc' flag is set. For TPA Start completions,
-	 * the complete checksum is calculated for the first packet in the
-	 * aggregation only.
-	 */
-	#define RX_TPA_V2_START_CMPL_FLAGS2_COMPLETE_CHECKSUM_MASK	UINT32_C(0xffff0000)
-	#define RX_TPA_V2_START_CMPL_FLAGS2_COMPLETE_CHECKSUM_SFT	16
+	#define RX_TPA_START_CMPL_FLAGS2_IP_TYPE	UINT32_C(0x100)
 	/*
 	 * This is data from the CFA block as indicated by the meta_format
 	 * field.
 	 */
 	uint32_t	metadata;
-	/* When {ext_meta_format,meta_format}=1, this value is the VLAN VID. */
-	#define RX_TPA_V2_START_CMPL_METADATA_VID_MASK UINT32_C(0xfff)
-	#define RX_TPA_V2_START_CMPL_METADATA_VID_SFT  0
-	/* When {ext_meta_format,meta_format}=1, this value is the VLAN DE. */
-	#define RX_TPA_V2_START_CMPL_METADATA_DE	UINT32_C(0x1000)
-	/* When {ext_meta_format,meta_format}=1, this value is the VLAN PRI. */
-	#define RX_TPA_V2_START_CMPL_METADATA_PRI_MASK UINT32_C(0xe000)
-	#define RX_TPA_V2_START_CMPL_METADATA_PRI_SFT  13
-	/* When {ext_meta_format,meta_format}=1, this value is the VLAN TPID. */
-	#define RX_TPA_V2_START_CMPL_METADATA_TPID_MASK UINT32_C(0xffff0000)
-	#define RX_TPA_V2_START_CMPL_METADATA_TPID_SFT 16
-	uint16_t	errors_v2;
+	/* When meta_format=1, this value is the VLAN VID. */
+	#define RX_TPA_START_CMPL_METADATA_VID_MASK UINT32_C(0xfff)
+	#define RX_TPA_START_CMPL_METADATA_VID_SFT  0
+	/* When meta_format=1, this value is the VLAN DE. */
+	#define RX_TPA_START_CMPL_METADATA_DE	UINT32_C(0x1000)
+	/* When meta_format=1, this value is the VLAN PRI. */
+	#define RX_TPA_START_CMPL_METADATA_PRI_MASK UINT32_C(0xe000)
+	#define RX_TPA_START_CMPL_METADATA_PRI_SFT  13
+	/* When meta_format=1, this value is the VLAN TPID. */
+	#define RX_TPA_START_CMPL_METADATA_TPID_MASK UINT32_C(0xffff0000)
+	#define RX_TPA_START_CMPL_METADATA_TPID_SFT 16
+	uint16_t	v2;
 	/*
 	 * This value is written by the NIC such that it will be different
 	 * for each pass through the completion queue. The even passes
 	 * will write 1. The odd passes will write 0.
 	 */
-	#define RX_TPA_V2_START_CMPL_V2				UINT32_C(0x1)
-	#define RX_TPA_V2_START_CMPL_ERRORS_MASK		UINT32_C(0xfffe)
-	#define RX_TPA_V2_START_CMPL_ERRORS_SFT			1
-	/*
-	 * This error indicates that there was some sort of problem with
-	 * the BDs for the packet that was found after part of the
-	 * packet was already placed. The packet should be treated as
-	 * invalid.
-	 */
-	#define RX_TPA_V2_START_CMPL_ERRORS_BUFFER_ERROR_MASK	UINT32_C(0xe)
-	#define RX_TPA_V2_START_CMPL_ERRORS_BUFFER_ERROR_SFT	1
-	/* No buffer error */
-		#define RX_TPA_V2_START_CMPL_ERRORS_BUFFER_ERROR_NO_BUFFER	(UINT32_C(0x0) << 1)
-	/*
-	 * Bad Format:
-	 * BDs were not formatted correctly.
-	 */
-		#define RX_TPA_V2_START_CMPL_ERRORS_BUFFER_ERROR_BAD_FORMAT   (UINT32_C(0x3) << 1)
-	/*
-	 * Flush:
-	 * There was a bad_format error on the previous operation
-	 */
-		#define RX_TPA_V2_START_CMPL_ERRORS_BUFFER_ERROR_FLUSH	(UINT32_C(0x5) << 1)
-		#define RX_TPA_V2_START_CMPL_ERRORS_BUFFER_ERROR_LAST	RX_TPA_V2_START_CMPL_ERRORS_BUFFER_ERROR_FLUSH
+	#define RX_TPA_START_CMPL_V2	UINT32_C(0x1)
 	/*
 	 * This field identifies the CFA action rule that was used for this
 	 * packet.
 	 */
 	uint16_t	cfa_code;
 	/*
-	 * For devices that support timestamps this field is overridden
-	 * with the timestamp value. When `flags.timestamp_fld_format` is
-	 * cleared, this field contains the 32b timestamp for the packet from the
-	 * MAC.
-	 *
-	 * When `flags.timestamp_fld_format` is set, this field contains the
-	 * outer_l3_offset, inner_l2_offset, inner_l3_offset, and inner_l4_size
-	 * as defined below.
+	 * This is the size in bytes of the inner most L4 header.
+	 * This can be subtracted from the payload_offset to determine
+	 * the start of the inner most L4 header.
 	 */
 	uint32_t	inner_l4_size_inner_l3_offset_inner_l2_offset_outer_l3_offset;
 	/*
@@ -6820,36 +7545,38 @@ typedef struct rx_tpa_v2_start_cmpl_hi {
 	 * the outer L3 header. If there is no outer L3 header, then this
 	 * value is zero.
 	 */
-	#define RX_TPA_V2_START_CMPL_OUTER_L3_OFFSET_MASK UINT32_C(0x1ff)
-	#define RX_TPA_V2_START_CMPL_OUTER_L3_OFFSET_SFT 0
+	#define RX_TPA_START_CMPL_OUTER_L3_OFFSET_MASK UINT32_C(0x1ff)
+	#define RX_TPA_START_CMPL_OUTER_L3_OFFSET_SFT 0
 	/*
 	 * This is the offset from the beginning of the packet in bytes for
 	 * the inner most L2 header.
 	 */
-	#define RX_TPA_V2_START_CMPL_INNER_L2_OFFSET_MASK UINT32_C(0x3fe00)
-	#define RX_TPA_V2_START_CMPL_INNER_L2_OFFSET_SFT 9
+	#define RX_TPA_START_CMPL_INNER_L2_OFFSET_MASK UINT32_C(0x3fe00)
+	#define RX_TPA_START_CMPL_INNER_L2_OFFSET_SFT 9
 	/*
 	 * This is the offset from the beginning of the packet in bytes for
 	 * the inner most L3 header.
 	 */
-	#define RX_TPA_V2_START_CMPL_INNER_L3_OFFSET_MASK UINT32_C(0x7fc0000)
-	#define RX_TPA_V2_START_CMPL_INNER_L3_OFFSET_SFT 18
+	#define RX_TPA_START_CMPL_INNER_L3_OFFSET_MASK UINT32_C(0x7fc0000)
+	#define RX_TPA_START_CMPL_INNER_L3_OFFSET_SFT 18
 	/*
 	 * This is the size in bytes of the inner most L4 header.
 	 * This can be subtracted from the payload_offset to determine
 	 * the start of the inner most L4 header.
 	 */
-	#define RX_TPA_V2_START_CMPL_INNER_L4_SIZE_MASK  UINT32_C(0xf8000000)
-	#define RX_TPA_V2_START_CMPL_INNER_L4_SIZE_SFT   27
-} rx_tpa_v2_start_cmpl_hi_t, *prx_tpa_v2_start_cmpl_hi_t;
+	#define RX_TPA_START_CMPL_INNER_L4_SIZE_MASK  UINT32_C(0xf8000000)
+	#define RX_TPA_START_CMPL_INNER_L4_SIZE_SFT   27
+} rx_tpa_start_cmpl_hi_t, *prx_tpa_start_cmpl_hi_t;
 
 /*
  * This TPA completion structure is used on devices where the
- * `hwrm_vnic_qcaps.max_aggs_supported` value is greater than 0.
+ * `hwrm_vnic_qcaps.max_aggs_supported` value is 0.
+ * RX L2 TPA Start V2 Completion Record (32 bytes split to 2 16-byte
+ * struct)
  */
-/* rx_tpa_v2_end_cmpl (size:128b/16B) */
+/* rx_tpa_start_v2_cmpl (size:128b/16B) */
 
-typedef struct rx_tpa_v2_end_cmpl {
+typedef struct rx_tpa_start_v2_cmpl {
 	uint16_t	flags_type;
 	/*
 	 * This field indicates the exact type of the completion.
@@ -6858,26 +7585,27 @@ typedef struct rx_tpa_v2_end_cmpl {
 	 * records. Odd values indicate 32B
 	 * records.
 	 */
-	#define RX_TPA_V2_END_CMPL_TYPE_MASK			UINT32_C(0x3f)
-	#define RX_TPA_V2_END_CMPL_TYPE_SFT			0
+	#define RX_TPA_START_V2_CMPL_TYPE_MASK			UINT32_C(0x3f)
+	#define RX_TPA_START_V2_CMPL_TYPE_SFT			0
 	/*
-	 * RX L2 TPA End Completion:
-	 * Completion at the end of a TPA operation.
+	 * RX L2 TPA Start V2 Completion:
+	 * Completion at the beginning of a TPA operation.
 	 * Length = 32B
+	 * This is the new version of the RX_TPA_START completion used
+	 * in SR2 and later chips.
 	 */
-		#define RX_TPA_V2_END_CMPL_TYPE_RX_TPA_END		UINT32_C(0x15)
-		#define RX_TPA_V2_END_CMPL_TYPE_LAST			RX_TPA_V2_END_CMPL_TYPE_RX_TPA_END
-	#define RX_TPA_V2_END_CMPL_FLAGS_MASK			UINT32_C(0xffc0)
-	#define RX_TPA_V2_END_CMPL_FLAGS_SFT			6
+		#define RX_TPA_START_V2_CMPL_TYPE_RX_TPA_START_V2		UINT32_C(0xd)
+		#define RX_TPA_START_V2_CMPL_TYPE_LAST			RX_TPA_START_V2_CMPL_TYPE_RX_TPA_START_V2
+	#define RX_TPA_START_V2_CMPL_FLAGS_MASK			UINT32_C(0xffc0)
+	#define RX_TPA_START_V2_CMPL_FLAGS_SFT			6
 	/*
-	 * When this bit is '1', it indicates a packet that has an
-	 * error of some type. Type of error is indicated in
-	 * error_flags.
+	 * When this bit is '1', it indicates a packet that has an error
+	 * of some type. Type of error is indicated in error_flags.
 	 */
-	#define RX_TPA_V2_END_CMPL_FLAGS_ERROR			UINT32_C(0x40)
+	#define RX_TPA_START_V2_CMPL_FLAGS_ERROR			UINT32_C(0x40)
 	/* This field indicates how the packet was placed in the buffer. */
-	#define RX_TPA_V2_END_CMPL_FLAGS_PLACEMENT_MASK		UINT32_C(0x380)
-	#define RX_TPA_V2_END_CMPL_FLAGS_PLACEMENT_SFT		7
+	#define RX_TPA_START_V2_CMPL_FLAGS_PLACEMENT_MASK		UINT32_C(0x380)
+	#define RX_TPA_START_V2_CMPL_FLAGS_PLACEMENT_SFT		7
 	/*
 	 * Jumbo:
 	 * TPA Packet was placed using jumbo algorithm. This means
@@ -6886,13 +7614,21 @@ typedef struct rx_tpa_v2_end_cmpl {
 	 * will be filled before moving to the next aggregation
 	 * buffer.
 	 */
-		#define RX_TPA_V2_END_CMPL_FLAGS_PLACEMENT_JUMBO		(UINT32_C(0x1) << 7)
+		#define RX_TPA_START_V2_CMPL_FLAGS_PLACEMENT_JUMBO		(UINT32_C(0x1) << 7)
 	/*
 	 * Header/Data Separation:
 	 * Packet was placed using Header/Data separation algorithm.
 	 * The separation location is indicated by the itype field.
 	 */
-		#define RX_TPA_V2_END_CMPL_FLAGS_PLACEMENT_HDS		(UINT32_C(0x2) << 7)
+		#define RX_TPA_START_V2_CMPL_FLAGS_PLACEMENT_HDS		(UINT32_C(0x2) << 7)
+	/*
+	 * IOC/Jumbo:
+	 * Packet will be placed using In-Order Completion/Jumbo where
+	 * the first packet of the aggregation is placed using Jumbo
+	 * Placement. Subsequent packets will be placed such that each
+	 * packet starts at the beginning of an aggregation buffer.
+	 */
+		#define RX_TPA_START_V2_CMPL_FLAGS_PLACEMENT_IOC_JUMBO	(UINT32_C(0x4) << 7)
 	/*
 	 * GRO/Jumbo:
 	 * Packet will be placed using GRO/Jumbo where the first
@@ -6901,7 +7637,7 @@ typedef struct rx_tpa_v2_end_cmpl {
 	 * aggregation buffers unless it starts at the beginning of
 	 * an aggregation buffer.
 	 */
-		#define RX_TPA_V2_END_CMPL_FLAGS_PLACEMENT_GRO_JUMBO	(UINT32_C(0x5) << 7)
+		#define RX_TPA_START_V2_CMPL_FLAGS_PLACEMENT_GRO_JUMBO	(UINT32_C(0x5) << 7)
 	/*
 	 * GRO/Header-Data Separation:
 	 * Packet will be placed using GRO/HDS where the header
@@ -6911,7 +7647,7 @@ typedef struct rx_tpa_v2_end_cmpl {
 	 * aggregation buffers unless it starts at the beginning of
 	 * an aggregation buffer.
 	 */
-		#define RX_TPA_V2_END_CMPL_FLAGS_PLACEMENT_GRO_HDS	(UINT32_C(0x6) << 7)
+		#define RX_TPA_START_V2_CMPL_FLAGS_PLACEMENT_GRO_HDS	(UINT32_C(0x6) << 7)
 	/*
 	 * IOC/Header-Data Separation:
 	 * Packet will be placed using In-Order Completion/HDS where
@@ -6919,183 +7655,329 @@ typedef struct rx_tpa_v2_end_cmpl {
 	 * packet will be placed such that each packet starts at the
 	 * beginning of an aggregation buffer.
 	 */
-		#define RX_TPA_V2_END_CMPL_FLAGS_PLACEMENT_IOC_HDS	(UINT32_C(0x7) << 7)
-		#define RX_TPA_V2_END_CMPL_FLAGS_PLACEMENT_LAST		RX_TPA_V2_END_CMPL_FLAGS_PLACEMENT_IOC_HDS
-	/* unused is 1 b */
-	#define RX_TPA_V2_END_CMPL_FLAGS_UNUSED			UINT32_C(0x400)
+		#define RX_TPA_START_V2_CMPL_FLAGS_PLACEMENT_IOC_HDS	(UINT32_C(0x7) << 7)
+		#define RX_TPA_START_V2_CMPL_FLAGS_PLACEMENT_LAST		RX_TPA_START_V2_CMPL_FLAGS_PLACEMENT_IOC_HDS
+	/* This bit is '1' if the RSS field in this completion is valid. */
+	#define RX_TPA_START_V2_CMPL_FLAGS_RSS_VALID		UINT32_C(0x400)
 	/*
 	 * This bit is '1' if metadata has been added to the end of the
 	 * packet in host memory. Metadata starts at the first 32B boundary
-	 * after the end of the packet for regular and jumbo placement.
-	 * It starts at the first 32B boundary after the end of the header
-	 * for HDS placement. The length of the metadata is indicated in the
+	 * after the end of the packet for regular and jumbo placement. It
+	 * starts at the first 32B boundary after the end of the header for
+	 * HDS placement. The length of the metadata is indicated in the
 	 * metadata itself.
 	 */
-	#define RX_TPA_V2_END_CMPL_FLAGS_PKT_METADATA_PRESENT	UINT32_C(0x800)
+	#define RX_TPA_START_V2_CMPL_FLAGS_PKT_METADATA_PRESENT	UINT32_C(0x800)
 	/*
 	 * This value indicates what the inner packet determined for the
 	 * packet was.
-	 * - 2 TCP Packet
-	 *	Indicates that the packet was IP and TCP. This indicates
-	 *	that the ip_cs field is valid and that the tcp_udp_cs
-	 *	field is valid and contains the TCP checksum.
-	 *	This also indicates that the payload_offset field is valid.
 	 */
-	#define RX_TPA_V2_END_CMPL_FLAGS_ITYPE_MASK		UINT32_C(0xf000)
-	#define RX_TPA_V2_END_CMPL_FLAGS_ITYPE_SFT		12
+	#define RX_TPA_START_V2_CMPL_FLAGS_ITYPE_MASK		UINT32_C(0xf000)
+	#define RX_TPA_START_V2_CMPL_FLAGS_ITYPE_SFT		12
 	/*
-	 * This value is zero for TPA End completions.
-	 * There is no data in the buffer that corresponds to the opaque
-	 * value in this completion.
+	 * TCP Packet:
+	 * Indicates that the packet was IP and TCP.
+	 */
+		#define RX_TPA_START_V2_CMPL_FLAGS_ITYPE_TCP		(UINT32_C(0x2) << 12)
+		#define RX_TPA_START_V2_CMPL_FLAGS_ITYPE_LAST		RX_TPA_START_V2_CMPL_FLAGS_ITYPE_TCP
+	/*
+	 * This value indicates the amount of packet data written to the
+	 * buffer the opaque field in this completion corresponds to.
 	 */
 	uint16_t	len;
 	/*
 	 * This is a copy of the opaque field from the RX BD this completion
-	 * corresponds to.
+	 * corresponds to. If the VNIC is configured to not use an Rx BD for
+	 * the TPA Start completion, then this is a copy of the opaque field
+	 * from the first BD used to place the TPA Start packet.
 	 */
 	uint32_t	opaque;
-	uint8_t	v1;
 	/*
 	 * This value is written by the NIC such that it will be different
 	 * for each pass through the completion queue. The even passes
 	 * will write 1. The odd passes will write 0.
 	 */
-	#define RX_TPA_V2_END_CMPL_V1	UINT32_C(0x1)
-	/* This value is the number of segments in the TPA operation. */
-	uint8_t	tpa_segs;
+	uint8_t	v1;
 	/*
-	 * This is the aggregation ID that the completion is associated
-	 * with. Use this number to correlate the TPA start completion
-	 * with the TPA end completion.
-	 */
-	uint16_t	agg_id;
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
+	 */
+	#define RX_TPA_START_V2_CMPL_V1 UINT32_C(0x1)
+	#define RX_TPA_START_V2_CMPL_LAST RX_TPA_START_V2_CMPL_V1
 	/*
-	 * For non-GRO packets, this value is the
-	 * timestamp delta between earliest and latest timestamp values for
-	 * TPA packet. If packets were not time stamped, then delta will be
-	 * zero.
+	 * This is the RSS hash type for the packet. The value is packed
+	 * {tuple_extrac_op[1:0],rss_profile_id[4:0],tuple_extrac_op[2]}.
 	 *
-	 * For GRO packets, this field is zero except for the following
-	 * sub-fields.
-	 * - tsdelta[31]
-	 *	Timestamp present indication. When '0', no Timestamp
-	 *	option is in the packet. When '1', then a Timestamp
-	 *	option is present in the packet.
+	 * The value of tuple_extrac_op provides the information about
+	 * what fields the hash was computed on.
+	 * * 0: The RSS hash was computed over source IP address,
+	 * destination IP address, source port, and destination port of inner
+	 * IP and TCP or UDP headers. Note: For non-tunneled packets,
+	 * the packet headers are considered inner packet headers for the RSS
+	 * hash computation purpose.
+	 * * 1: The RSS hash was computed over source IP address and destination
+	 * IP address of inner IP header. Note: For non-tunneled packets,
+	 * the packet headers are considered inner packet headers for the RSS
+	 * hash computation purpose.
+	 * * 2: The RSS hash was computed over source IP address,
+	 * destination IP address, source port, and destination port of
+	 * IP and TCP or UDP headers of outer tunnel headers.
+	 * Note: For non-tunneled packets, this value is not applicable.
+	 * * 3: The RSS hash was computed over source IP address and
+	 * destination IP address of IP header of outer tunnel headers.
+	 * Note: For non-tunneled packets, this value is not applicable.
+	 *
+	 * Note that 4-tuples values listed above are applicable
+	 * for layer 4 protocols supported and enabled for RSS in the hardware,
+	 * HWRM firmware, and drivers. For example, if RSS hash is supported and
+	 * enabled for TCP traffic only, then the values of tuple_extract_op
+	 * corresponding to 4-tuples are only valid for TCP traffic.
 	 */
-	uint32_t	tsdelta;
-} rx_tpa_v2_end_cmpl_t, *prx_tpa_v2_end_cmpl_t;
+	uint8_t	rss_hash_type;
+	/*
+	 * This is the aggregation ID that the completion is associated
+	 * with. Use this number to correlate the TPA start completion
+	 * with the TPA end completion.
+	 */
+	uint16_t	agg_id;
+	/*
+	 * This is the aggregation ID that the completion is associated
+	 * with. Use this number to correlate the TPA start completion
+	 * with the TPA end completion.
+	 */
+	#define RX_TPA_START_V2_CMPL_AGG_ID_MASK		UINT32_C(0xfff)
+	#define RX_TPA_START_V2_CMPL_AGG_ID_SFT		0
+	#define RX_TPA_START_V2_CMPL_METADATA1_MASK		UINT32_C(0xf000)
+	#define RX_TPA_START_V2_CMPL_METADATA1_SFT		12
+	/* When meta_format != 0, this value is the VLAN TPID_SEL. */
+	#define RX_TPA_START_V2_CMPL_METADATA1_TPID_SEL_MASK	UINT32_C(0x7000)
+	#define RX_TPA_START_V2_CMPL_METADATA1_TPID_SEL_SFT	12
+	/* 0x88a8 */
+		#define RX_TPA_START_V2_CMPL_METADATA1_TPID_SEL_TPID88A8   (UINT32_C(0x0) << 12)
+	/* 0x8100 */
+		#define RX_TPA_START_V2_CMPL_METADATA1_TPID_SEL_TPID8100   (UINT32_C(0x1) << 12)
+	/* 0x9100 */
+		#define RX_TPA_START_V2_CMPL_METADATA1_TPID_SEL_TPID9100   (UINT32_C(0x2) << 12)
+	/* 0x9200 */
+		#define RX_TPA_START_V2_CMPL_METADATA1_TPID_SEL_TPID9200   (UINT32_C(0x3) << 12)
+	/* 0x9300 */
+		#define RX_TPA_START_V2_CMPL_METADATA1_TPID_SEL_TPID9300   (UINT32_C(0x4) << 12)
+	/* Value programmed in CFA VLANTPID register. */
+		#define RX_TPA_START_V2_CMPL_METADATA1_TPID_SEL_TPIDCFG	(UINT32_C(0x5) << 12)
+		#define RX_TPA_START_V2_CMPL_METADATA1_TPID_SEL_LAST	RX_TPA_START_V2_CMPL_METADATA1_TPID_SEL_TPIDCFG
+	/* When meta_format != 0, this value is the VLAN valid. */
+	#define RX_TPA_START_V2_CMPL_METADATA1_VALID		UINT32_C(0x8000)
+	/*
+	 * This value is the RSS hash value calculated for the packet
+	 * based on the mode bits and key value in the VNIC.
+	 * When vee_cmpl_mode is set in VNIC context, this is the lower
+	 * 32b of the host address from the first BD used to place the packet.
+	 */
+	uint32_t	rss_hash;
+} rx_tpa_start_v2_cmpl_t, *prx_tpa_start_v2_cmpl_t;
 
 /*
- * Last 16 bytes of rx_tpa_v2_end_cmpl.
+ * Last 16 bytes of RX L2 TPA Start V2 Completion Record
  *
  * This TPA completion structure is used on devices where the
- * `hwrm_vnic_qcaps.max_aggs_supported` value is greater than 0.
+ * `hwrm_vnic_qcaps.max_aggs_supported` value is 0.
  */
-/* rx_tpa_v2_end_cmpl_hi (size:128b/16B) */
+/* rx_tpa_start_v2_cmpl_hi (size:128b/16B) */
 
-typedef struct rx_tpa_v2_end_cmpl_hi {
+typedef struct rx_tpa_start_v2_cmpl_hi {
+	uint32_t	flags2;
+	/* This indicates that the aggregation was done using GRO rules. */
+	#define RX_TPA_START_V2_CMPL_FLAGS2_AGG_GRO			UINT32_C(0x4)
 	/*
-	 * This value is the number of duplicate ACKs that have been
-	 * received as part of the TPA operation.
+	 * When this bit is '0', the cs_ok field has the following definition:-
+	 * ip_cs_ok[2:0] = The number of header groups with a valid IP checksum
+	 * in the delivered packet, counted from the outer-most header group to
+	 * the inner-most header group, stopping at the first error. -
+	 * l4_cs_ok[5:3] = The number of header groups with a valid L4 checksum
+	 * in the delivered packet, counted from the outer-most header group to
+	 * the inner-most header group, stopping at the first error. When this
+	 * bit is '1', the cs_ok field has the following definition: -
+	 * hdr_cnt[2:0] = The number of header groups that were parsed by the
+	 * chip and passed in the delivered packet. - ip_cs_all_ok[3] =This bit
+	 * will be '1' if all the parsed header groups with an IP checksum are
+	 * valid. - l4_cs_all_ok[4] = This bit will be '1' if all the parsed
+	 * header groups with an L4 checksum are valid.
 	 */
-	uint16_t	tpa_dup_acks;
+	#define RX_TPA_START_V2_CMPL_FLAGS2_CS_ALL_OK_MODE		UINT32_C(0x8)
+	/* This value indicates what format the metadata field is. */
+	#define RX_TPA_START_V2_CMPL_FLAGS2_META_FORMAT_MASK	UINT32_C(0xf0)
+	#define RX_TPA_START_V2_CMPL_FLAGS2_META_FORMAT_SFT		4
+	/* There is no metadata information. Values are zero. */
+		#define RX_TPA_START_V2_CMPL_FLAGS2_META_FORMAT_NONE		(UINT32_C(0x0) << 4)
 	/*
-	 * This value is the number of duplicate ACKs that have been
-	 * received as part of the TPA operation.
+	 * The {metadata1, metadata0} fields contain the vtag
+	 * information: - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0],
+	 * de, vid[11:0]} The metadata2 field contains the table scope
+	 * and action record pointer. - metadata2[25:0] contains the
+	 * action record pointer. - metadata2[31:26] contains the table
+	 * scope.
 	 */
-	#define RX_TPA_V2_END_CMPL_TPA_DUP_ACKS_MASK UINT32_C(0xf)
-	#define RX_TPA_V2_END_CMPL_TPA_DUP_ACKS_SFT 0
+		#define RX_TPA_START_V2_CMPL_FLAGS2_META_FORMAT_ACT_REC_PTR	(UINT32_C(0x1) << 4)
 	/*
-	 * This value indicated the offset in bytes from the beginning of
-	 * the packet where the inner payload starts. This value is valid
-	 * for TCP, UDP, FCoE and RoCE packets
+	 * The {metadata1, metadata0} fields contain the vtag
+	 * information:
+	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0], de, vid[11:0]}
+	 * The metadata2 field contains the Tunnel ID
+	 * value, justified to LSB.
+	 * - VXLAN = VNI[23:0] -> VXLAN Network ID
+	 * - Geneve (NGE) = VNI[23:0] a-> Virtual Network Identifier
+	 * - NVGRE = TNI[23:0] -> Tenant Network ID
+	 * - GRE = KEY[31:0] -> key field with bit mask. zero if K=0
+	 * - IPv4 = 0 (not populated)
+	 * - IPv6 = Flow Label[19:0]
+	 * - PPPoE = sessionID[15:0]
+	 * - MPLs = Outer label[19:0]
+	 * - UPAR = Selected[31:0] with bit mask
 	 */
-	uint8_t	payload_offset;
+		#define RX_TPA_START_V2_CMPL_FLAGS2_META_FORMAT_TUNNEL_ID	(UINT32_C(0x2) << 4)
 	/*
-	 * The value is the total number of aggregation buffers that were
-	 * used in the TPA operation. All TPA aggregation buffer completions
-	 * precede the TPA End completion. If the value is zero, then the
-	 * aggregation is completely contained in the buffer space provided
-	 * in the aggregation start completion.
-	 * Note that the field is simply provided as a cross check.
+	 * The {metadata1, metadata0} fields contain the vtag
+	 * information:
+	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0],de, vid[11:0]}
+	 * The metadata2 field contains the 32b metadata from the prepended
+	 * header (chdr_data).
 	 */
-	uint8_t	tpa_agg_bufs;
+		#define RX_TPA_START_V2_CMPL_FLAGS2_META_FORMAT_CHDR_DATA	(UINT32_C(0x3) << 4)
 	/*
-	 * This value is the valid when TPA completion is active. It
-	 * indicates the length of the longest segment of the TPA operation
-	 * for LRO mode and the length of the first segment in GRO mode.
-	 *
-	 * This value may be used by GRO software to re-construct the original
-	 * packet stream from the TPA packet. This is the length of all
-	 * but the last segment for GRO. In LRO mode this value may be used
-	 * to indicate MSS size to the stack.
+	 * The {metadata1, metadata0} fields contain the vtag
+	 * information:
+	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0], de, vid[11:0]}
+	 * The metadata2 field contains the outer_l3_offset,
+	 * inner_l2_offset, inner_l3_offset, and inner_l4_size.
+	 * - metadata2[8:0] contains the outer_l3_offset.
+	 * - metadata2[17:9] contains the inner_l2_offset.
+	 * - metadata2[26:18] contains the inner_l3_offset.
+	 * - metadata2[31:27] contains the inner_l4_size.
 	 */
-	uint16_t	tpa_seg_len;
-	uint16_t	unused_1;
+		#define RX_TPA_START_V2_CMPL_FLAGS2_META_FORMAT_HDR_OFFSET	(UINT32_C(0x4) << 4)
+		#define RX_TPA_START_V2_CMPL_FLAGS2_META_FORMAT_LAST		RX_TPA_START_V2_CMPL_FLAGS2_META_FORMAT_HDR_OFFSET
+	/*
+	 * This field indicates the IP type for the inner-most IP header.
+	 * A value of '0' indicates IPv4. A value of '1' indicates IPv6.
+	 * This value is only valid if itype indicates a packet
+	 * with an IP header.
+	 */
+	#define RX_TPA_START_V2_CMPL_FLAGS2_IP_TYPE			UINT32_C(0x100)
+	/*
+	 * This indicates that the complete 1's complement checksum was
+	 * calculated for the packet in the aggregation.
+	 */
+	#define RX_TPA_START_V2_CMPL_FLAGS2_COMPLETE_CHECKSUM_CALC	UINT32_C(0x200)
+	/*
+	 * This field indicates the status of IP and L4 CS calculations done
+	 * by the chip. The format of this field is indicated by the
+	 * cs_all_ok_mode bit.
+	 * CS status for TPA packets is always valid. This means that "all_ok"
+	 * status will always be set. The ok count status will be set
+	 * appropriately for the packet header, such that all existing CS
+	 * values are ok.
+	 */
+	#define RX_TPA_START_V2_CMPL_FLAGS2_CS_OK_MASK		UINT32_C(0xfc00)
+	#define RX_TPA_START_V2_CMPL_FLAGS2_CS_OK_SFT		10
+	/*
+	 * This value is the complete 1's complement checksum calculated from
+	 * the start of the outer L3 header to the end of the packet (not
+	 * including the ethernet crc). It is valid when the
+	 * 'complete_checksum_calc' flag is set. For TPA Start completions,
+	 * the complete checksum is calculated for the first packet in the
+	 * aggregation only.
+	 */
+	#define RX_TPA_START_V2_CMPL_FLAGS2_COMPLETE_CHECKSUM_MASK	UINT32_C(0xffff0000)
+	#define RX_TPA_START_V2_CMPL_FLAGS2_COMPLETE_CHECKSUM_SFT	16
+	/*
+	 * This is data from the CFA block as indicated by the meta_format
+	 * field.
+	 * - meta_format 0 - none - metadata2 = 0 - not valid/not stripped
+	 * - meta_format 1 - act_rec_ptr - metadata2 = {table_scope[5:0],
+	 *   act_rec_ptr[25:0]}
+	 * - meta_format 2 - tunnel_id - metadata2 = tunnel_id[31:0]
+	 * - meta_format 3 - chdr_data - metadata2 = updated_chdr_data[31:0]
+	 * - meta_format 4 - hdr_offsets - metadata2 = hdr_offsets[31:0]
+	 * When vee_cmpl_mode is set in VNIC context, this is the upper 32b
+	 * of the host address from the first BD used to place the packet.
+	 */
+	uint32_t	metadata2;
 	uint16_t	errors_v2;
 	/*
 	 * This value is written by the NIC such that it will be different
 	 * for each pass through the completion queue. The even passes
 	 * will write 1. The odd passes will write 0.
 	 */
-	#define RX_TPA_V2_END_CMPL_V2				UINT32_C(0x1)
-	#define RX_TPA_V2_END_CMPL_ERRORS_MASK			UINT32_C(0xfffe)
-	#define RX_TPA_V2_END_CMPL_ERRORS_SFT			1
+	#define RX_TPA_START_V2_CMPL_V2				UINT32_C(0x1)
+	#define RX_TPA_START_V2_CMPL_ERRORS_MASK			UINT32_C(0xfffe)
+	#define RX_TPA_START_V2_CMPL_ERRORS_SFT			1
 	/*
 	 * This error indicates that there was some sort of problem with
-	 * the BDs for the packet that was found after part of the
-	 * packet was already placed. The packet should be treated as
+	 * the BDs for the packetThe packet should be treated as
 	 * invalid.
 	 */
-	#define RX_TPA_V2_END_CMPL_ERRORS_BUFFER_ERROR_MASK	UINT32_C(0xe)
-	#define RX_TPA_V2_END_CMPL_ERRORS_BUFFER_ERROR_SFT	1
+	#define RX_TPA_START_V2_CMPL_ERRORS_BUFFER_ERROR_MASK	UINT32_C(0xe)
+	#define RX_TPA_START_V2_CMPL_ERRORS_BUFFER_ERROR_SFT	1
 	/* No buffer error */
-		#define RX_TPA_V2_END_CMPL_ERRORS_BUFFER_ERROR_NO_BUFFER	(UINT32_C(0x0) << 1)
+		#define RX_TPA_START_V2_CMPL_ERRORS_BUFFER_ERROR_NO_BUFFER	(UINT32_C(0x0) << 1)
 	/*
-	 * This error occurs when there is a fatal HW problem in
-	 * the chip only. It indicates that there were not
-	 * BDs on chip but that there was adequate reservation.
-	 * provided by the TPA block.
+	 * Did Not Fit:
+	 * Packet did not fit into packet buffer provided. This means
+	 * that the TPA Start packet was too big to be placed into the
+	 * per-packet maximum number of physical buffers configured for
+	 * the VNIC, or that it was too big to be placed into the
+	 * per-aggregation maximum number of physical buffers configured
+	 * for the VNIC. This error only occurs when the VNIC is
+	 * configured for variable size receive buffers.
 	 */
-		#define RX_TPA_V2_END_CMPL_ERRORS_BUFFER_ERROR_NOT_ON_CHIP   (UINT32_C(0x2) << 1)
+		#define RX_TPA_START_V2_CMPL_ERRORS_BUFFER_ERROR_DID_NOT_FIT   (UINT32_C(0x1) << 1)
 	/*
 	 * Bad Format:
 	 * BDs were not formatted correctly.
 	 */
-		#define RX_TPA_V2_END_CMPL_ERRORS_BUFFER_ERROR_BAD_FORMAT	(UINT32_C(0x3) << 1)
-	/*
-	 * This error occurs when TPA block was not configured to
-	 * reserve adequate BDs for TPA operations on this RX
-	 * ring. All data for the TPA operation was not placed.
-	 *
-	 * This error can also be generated when the number of
-	 * segments is not programmed correctly in TPA and the
-	 * 33 total aggregation buffers allowed for the TPA
-	 * operation has been exceeded.
-	 */
-		#define RX_TPA_V2_END_CMPL_ERRORS_BUFFER_ERROR_RSV_ERROR	(UINT32_C(0x4) << 1)
+		#define RX_TPA_START_V2_CMPL_ERRORS_BUFFER_ERROR_BAD_FORMAT	(UINT32_C(0x3) << 1)
 	/*
 	 * Flush:
 	 * There was a bad_format error on the previous operation
 	 */
-		#define RX_TPA_V2_END_CMPL_ERRORS_BUFFER_ERROR_FLUSH	(UINT32_C(0x5) << 1)
-		#define RX_TPA_V2_END_CMPL_ERRORS_BUFFER_ERROR_LAST	RX_TPA_V2_END_CMPL_ERRORS_BUFFER_ERROR_FLUSH
-	uint16_t	unused_2;
+		#define RX_TPA_START_V2_CMPL_ERRORS_BUFFER_ERROR_FLUSH	(UINT32_C(0x5) << 1)
+		#define RX_TPA_START_V2_CMPL_ERRORS_BUFFER_ERROR_LAST	RX_TPA_START_V2_CMPL_ERRORS_BUFFER_ERROR_FLUSH
 	/*
-	 * This is the opaque value that was completed for the TPA start
-	 * completion that corresponds to this TPA end completion.
+	 * This is data from the CFA block as indicated by the meta_format
+	 * field.
 	 */
-	uint32_t	start_opaque;
-} rx_tpa_v2_end_cmpl_hi_t, *prx_tpa_v2_end_cmpl_hi_t;
+	uint16_t	metadata0;
+	/* When meta_format != 0, this value is the VLAN VID. */
+	#define RX_TPA_START_V2_CMPL_METADATA0_VID_MASK UINT32_C(0xfff)
+	#define RX_TPA_START_V2_CMPL_METADATA0_VID_SFT 0
+	/* When meta_format != 0, this value is the VLAN DE. */
+	#define RX_TPA_START_V2_CMPL_METADATA0_DE	UINT32_C(0x1000)
+	/* When meta_format != 0, this value is the VLAN PRI. */
+	#define RX_TPA_START_V2_CMPL_METADATA0_PRI_MASK UINT32_C(0xe000)
+	#define RX_TPA_START_V2_CMPL_METADATA0_PRI_SFT 13
+	/*
+	 * This field contains the outer_l3_offset, inner_l2_offset,
+	 * inner_l3_offset, and inner_l4_size.
+	 *
+	 * hdr_offsets[8:0] contains the outer_l3_offset.
+	 * hdr_offsets[17:9] contains the inner_l2_offset.
+	 * hdr_offsets[26:18] contains the inner_l3_offset.
+	 * hdr_offsets[31:27] contains the inner_l4_size.
+	 */
+	uint32_t	hdr_offsets;
+} rx_tpa_start_v2_cmpl_hi_t, *prx_tpa_start_v2_cmpl_hi_t;
 
 /*
  * This TPA completion structure is used on devices where the
- * `hwrm_vnic_qcaps.max_aggs_supported` value is greater than 0.
+ * `hwrm_vnic_qcaps.max_aggs_supported` value is 0.
+ * RX L2 TPA Start V3 Completion Record (32 bytes split to 2 16-byte
+ * struct)
  */
-/* rx_tpa_v2_abuf_cmpl (size:128b/16B) */
+/* rx_tpa_start_v3_cmpl (size:128b/16B) */
 
-typedef struct rx_tpa_v2_abuf_cmpl {
-	uint16_t	type;
+typedef struct rx_tpa_start_v3_cmpl {
+	uint16_t	flags_type;
 	/*
 	 * This field indicates the exact type of the completion.
 	 * By convention, the LSB identifies the length of the
@@ -7103,260 +7985,425 @@ typedef struct rx_tpa_v2_abuf_cmpl {
 	 * records. Odd values indicate 32B
 	 * records.
 	 */
-	#define RX_TPA_V2_ABUF_CMPL_TYPE_MASK	UINT32_C(0x3f)
-	#define RX_TPA_V2_ABUF_CMPL_TYPE_SFT	0
+	#define RX_TPA_START_V3_CMPL_TYPE_MASK			UINT32_C(0x3f)
+	#define RX_TPA_START_V3_CMPL_TYPE_SFT			0
 	/*
-	 * RX TPA Aggregation Buffer completion :
-	 * Completion of an L2 aggregation buffer in support of
-	 * TPA packet completion. Length = 16B
+	 * RX L2 TPA Start V3 completion:
+	 * Completion at the beginning of a TPA operation.
+	 * Length = 32B
+	 * This is the new version of the RX_TPA_START completion used
+	 * in Thor2 and later chips.
 	 */
-		#define RX_TPA_V2_ABUF_CMPL_TYPE_RX_TPA_AGG  UINT32_C(0x16)
-		#define RX_TPA_V2_ABUF_CMPL_TYPE_LAST	RX_TPA_V2_ABUF_CMPL_TYPE_RX_TPA_AGG
+		#define RX_TPA_START_V3_CMPL_TYPE_RX_TPA_START_V3		UINT32_C(0x19)
+		#define RX_TPA_START_V3_CMPL_TYPE_LAST			RX_TPA_START_V3_CMPL_TYPE_RX_TPA_START_V3
+	#define RX_TPA_START_V3_CMPL_FLAGS_MASK			UINT32_C(0xffc0)
+	#define RX_TPA_START_V3_CMPL_FLAGS_SFT			6
 	/*
-	 * This is the length of the data for the packet stored in this
-	 * aggregation buffer identified by the opaque value. This does not
-	 * include the length of any
-	 * data placed in other aggregation BDs or in the packet or buffer
-	 * BDs. This length does not include any space added due to
-	 * hdr_offset register during HDS placement mode.
+	 * When this bit is '1', it indicates a packet that has an error
+	 * of some type. Type of error is indicated in error_flags.
 	 */
-	uint16_t	len;
+	#define RX_TPA_START_V3_CMPL_FLAGS_ERROR			UINT32_C(0x40)
+	/* This field indicates how the packet was placed in the buffer. */
+	#define RX_TPA_START_V3_CMPL_FLAGS_PLACEMENT_MASK		UINT32_C(0x380)
+	#define RX_TPA_START_V3_CMPL_FLAGS_PLACEMENT_SFT		7
 	/*
-	 * This is a copy of the opaque field from the RX BD this aggregation
-	 * buffer corresponds to.
+	 * Jumbo:
+	 * TPA Packet was placed using jumbo algorithm. This means
+	 * that the first buffer will be filled with data before
+	 * moving to aggregation buffers. Each aggregation buffer
+	 * will be filled before moving to the next aggregation
+	 * buffer.
 	 */
-	uint32_t	opaque;
-	uint16_t	v;
+		#define RX_TPA_START_V3_CMPL_FLAGS_PLACEMENT_JUMBO		(UINT32_C(0x1) << 7)
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * Header/Data Separation:
+	 * Packet was placed using Header/Data separation algorithm.
+	 * The separation location is indicated by the itype field.
 	 */
-	#define RX_TPA_V2_ABUF_CMPL_V	UINT32_C(0x1)
+		#define RX_TPA_START_V3_CMPL_FLAGS_PLACEMENT_HDS		(UINT32_C(0x2) << 7)
 	/*
-	 * This is the aggregation ID that the completion is associated with. Use
-	 * this number to correlate the TPA agg completion with the TPA start
-	 * completion and the TPA end completion.
+	 * IOC/Jumbo:
+	 * Packet will be placed using In-Order Completion/Jumbo where
+	 * the first packet of the aggregation is placed using Jumbo
+	 * Placement. Subsequent packets will be placed such that each
+	 * packet starts at the beginning of an aggregation buffer.
 	 */
-	uint16_t	agg_id;
-	uint32_t	unused_1;
-} rx_tpa_v2_abuf_cmpl_t, *prx_tpa_v2_abuf_cmpl_t;
-
-/* rx_abuf_cmpl (size:128b/16B) */
-
-typedef struct rx_abuf_cmpl {
-	uint16_t	type;
+		#define RX_TPA_START_V3_CMPL_FLAGS_PLACEMENT_IOC_JUMBO	(UINT32_C(0x4) << 7)
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * GRO/Jumbo:
+	 * Packet will be placed using GRO/Jumbo where the first
+	 * packet is filled with data. Subsequent packets will be
+	 * placed such that any one packet does not span two
+	 * aggregation buffers unless it starts at the beginning of
+	 * an aggregation buffer.
 	 */
-	#define RX_ABUF_CMPL_TYPE_MASK  UINT32_C(0x3f)
-	#define RX_ABUF_CMPL_TYPE_SFT   0
+		#define RX_TPA_START_V3_CMPL_FLAGS_PLACEMENT_GRO_JUMBO	(UINT32_C(0x5) << 7)
 	/*
-	 * RX Aggregation Buffer completion :
-	 * Completion of an L2 aggregation buffer in support of
-	 * TPA, HDS, or Jumbo packet completion. Length = 16B
+	 * GRO/Header-Data Separation:
+	 * Packet will be placed using GRO/HDS where the header
+	 * is in the first packet.
+	 * Payload of each packet will be
+	 * placed such that any one packet does not span two
+	 * aggregation buffers unless it starts at the beginning of
+	 * an aggregation buffer.
 	 */
-		#define RX_ABUF_CMPL_TYPE_RX_AGG  UINT32_C(0x12)
-		#define RX_ABUF_CMPL_TYPE_LAST   RX_ABUF_CMPL_TYPE_RX_AGG
+		#define RX_TPA_START_V3_CMPL_FLAGS_PLACEMENT_GRO_HDS	(UINT32_C(0x6) << 7)
 	/*
-	 * This is the length of the data for the packet stored in this
-	 * aggregation buffer identified by the opaque value. This does not
-	 * include the length of any
-	 * data placed in other aggregation BDs or in the packet or buffer
-	 * BDs. This length does not include any space added due to
-	 * hdr_offset register during HDS placement mode.
+	 * IOC/Header-Data Separation:
+	 * Packet will be placed using In-Order Completion/HDS where
+	 * the header is in the first packet buffer. Payload of each
+	 * packet will be placed such that each packet starts at the
+	 * beginning of an aggregation buffer.
 	 */
-	uint16_t	len;
+		#define RX_TPA_START_V3_CMPL_FLAGS_PLACEMENT_IOC_HDS	(UINT32_C(0x7) << 7)
+		#define RX_TPA_START_V3_CMPL_FLAGS_PLACEMENT_LAST		RX_TPA_START_V3_CMPL_FLAGS_PLACEMENT_IOC_HDS
+	/* This bit is '1' if the RSS field in this completion is valid. */
+	#define RX_TPA_START_V3_CMPL_FLAGS_RSS_VALID		UINT32_C(0x400)
 	/*
-	 * This is a copy of the opaque field from the RX BD this aggregation
-	 * buffer corresponds to.
+	 * This bit is '1' if metadata has been added to the end of the
+	 * packet in host memory. Metadata starts at the first 32B boundary
+	 * after the end of the packet for regular and jumbo placement. It
+	 * starts at the first 32B boundary after the end of the header for
+	 * HDS placement. The length of the metadata is indicated in the
+	 * metadata itself.
 	 */
-	uint32_t	opaque;
-	uint32_t	v;
+	#define RX_TPA_START_V3_CMPL_FLAGS_PKT_METADATA_PRESENT	UINT32_C(0x800)
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * This value indicates what the inner packet determined for the
+	 * packet was.
 	 */
-	#define RX_ABUF_CMPL_V	UINT32_C(0x1)
-	/* unused3 is 32 b */
-	uint32_t	unused_2;
-} rx_abuf_cmpl_t, *prx_abuf_cmpl_t;
-
-/* VEE FLUSH Completion Record (16 bytes) */
-/* vee_flush (size:128b/16B) */
-
-typedef struct vee_flush {
-	uint32_t	downstream_path_type;
+	#define RX_TPA_START_V3_CMPL_FLAGS_ITYPE_MASK		UINT32_C(0xf000)
+	#define RX_TPA_START_V3_CMPL_FLAGS_ITYPE_SFT		12
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * TCP Packet:
+	 * Indicates that the packet was IP and TCP.
 	 */
-	#define VEE_FLUSH_TYPE_MASK	UINT32_C(0x3f)
-	#define VEE_FLUSH_TYPE_SFT		0
+		#define RX_TPA_START_V3_CMPL_FLAGS_ITYPE_TCP		(UINT32_C(0x2) << 12)
+		#define RX_TPA_START_V3_CMPL_FLAGS_ITYPE_LAST		RX_TPA_START_V3_CMPL_FLAGS_ITYPE_TCP
 	/*
-	 * VEE Flush Completion:
-	 * This completion is inserted manually by the Primate and processed
-	 * by the VEE hardware to ensure that all completions on a VEE
-	 * function have been processed by the VEE hardware before FLR
-	 * process is completed.
+	 * This value indicates the amount of packet data written to the
+	 * buffer the opaque field in this completion corresponds to.
 	 */
-		#define VEE_FLUSH_TYPE_VEE_FLUSH	UINT32_C(0x1c)
-		#define VEE_FLUSH_TYPE_LAST		VEE_FLUSH_TYPE_VEE_FLUSH
-	/* downstream_path is 1 b */
-	#define VEE_FLUSH_DOWNSTREAM_PATH	UINT32_C(0x40)
-	/* This completion is associated with VEE Transmit */
-		#define VEE_FLUSH_DOWNSTREAM_PATH_TX	(UINT32_C(0x0) << 6)
-	/* This completion is associated with VEE Receive */
-		#define VEE_FLUSH_DOWNSTREAM_PATH_RX	(UINT32_C(0x1) << 6)
-		#define VEE_FLUSH_DOWNSTREAM_PATH_LAST VEE_FLUSH_DOWNSTREAM_PATH_RX
+	uint16_t	len;
 	/*
-	 * This is an opaque value that is passed through the completion
-	 * to the VEE handler SW and is used to indicate what VEE VQ or
-	 * function has completed FLR processing.
+	 * This is a copy of the opaque field from the RX BD this completion
+	 * corresponds to. If the VNIC is configured to not use an Rx BD for
+	 * the TPA Start completion, then this is a copy of the opaque field
+	 * from the first BD used to place the TPA Start packet.
 	 */
 	uint32_t	opaque;
-	uint32_t	v;
+	uint16_t	rss_hash_type_v1;
 	/*
 	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes will
-	 * write 1. The odd passes will write 0.
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	#define VEE_FLUSH_V	UINT32_C(0x1)
-	/* unused3 is 32 b */
-	uint32_t	unused_3;
-} vee_flush_t, *pvee_flush_t;
-
-/* eject_cmpl (size:128b/16B) */
-
-typedef struct eject_cmpl {
-	uint16_t	type;
+	#define RX_TPA_START_V3_CMPL_V1		UINT32_C(0x1)
+	/* unused1 is 6 b. */
+	#define RX_TPA_START_V3_CMPL_UNUSED1_MASK	UINT32_C(0x7e)
+	#define RX_TPA_START_V3_CMPL_UNUSED1_SFT	1
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * This is the RSS hash type for the packet. The value is packed
+	 * {tuple_extrac_op[1:0],rss_profile_id[4:0],tuple_extrac_op[2]}.
+	 *
+	 * The value of tuple_extrac_op provides the information about
+	 * what fields the hash was computed on.
+	 * * 0: The RSS hash was computed over source IP address,
+	 * destination IP address, source port, and destination port of inner
+	 * IP and TCP or UDP headers.
+	 * * 1: The RSS hash was computed over source IP address and
+	 * destination IP address of inner IP header.
+	 * * 2: The RSS hash was computed over source IP address,
+	 * destination IP address, source port, and destination port of
+	 * IP and TCP or UDP headers of outer tunnel headers.
+	 * Note: For non-tunneled packets, this value is not applicable.
+	 * * 3: The RSS hash was computed over source IP address and
+	 * destination IP address of IP header of outer tunnel headers.
+	 * Note: For non-tunneled packets, this value is not applicable.
+	 * * 4: The RSS hash was computed over source IP address of the inner
+	 * IP header.
+	 * * 5: The RSS hash was computed over destination IP address of the
+	 * inner IP header.
+	 * * 6: The RSS hash was computed over source IP address of the outer
+	 * IP header. Note: For non-tunneled packets, this value is not
+	 * applicable
+	 * * 7: The RSS hash was computed over destination IP address of the
+	 * outer IP header.
+	 * Note: For non-tunneled packets, this value is not applicable.
+	 * * 8: The RSS hash was computed over source IP address, destination
+	 * IP address, and flow label of the inner IP header.
+	 * Note: For packets without an inner IPv6 header, this value is not
+	 * applicable.
+	 * * 9: The RSS hash was computed over the flow label of the inner
+	 * IP header.
+	 * Note: For packets without an inner IPv6 header, this value
+	 * is not applicable.
+	 * * 10: The RSS hash was computed over source IP address, destination
+	 * IP address, and flow label of the outer IP header.
+	 * Note: For packets without an outer IPv6 header, this value is not
+	 * applicable.
+	 * * 11: The RSS hash was computed over the flow label of the outer
+	 * IP header. Note: For packets without an outer IPv6 header, this
+	 * value is not applicable.
+	 *
+	 * Note that 4-tuples values listed above are applicable
+	 * for layer 4 protocols supported and enabled for RSS in the hardware,
+	 * HWRM firmware, and drivers. For example, if RSS hash is supported
+	 * and enabled for TCP traffic only, then the values of
+	 * tuple_extract_op corresponding to 4-tuples are only valid for TCP
+	 * traffic
 	 */
-	#define EJECT_CMPL_TYPE_MASK	UINT32_C(0x3f)
-	#define EJECT_CMPL_TYPE_SFT	0
+	#define RX_TPA_START_V3_CMPL_RSS_HASH_TYPE_MASK UINT32_C(0xff80)
+	#define RX_TPA_START_V3_CMPL_RSS_HASH_TYPE_SFT 7
 	/*
-	 * Statistics Ejection Completion:
-	 * Completion of statistics data ejection buffer.
-	 * Length = 16B
+	 * This is the aggregation ID that the completion is associated
+	 * with. Use this number to correlate the TPA start completion
+	 * with the TPA end completion.
 	 */
-		#define EJECT_CMPL_TYPE_STAT_EJECT   UINT32_C(0x1a)
-		#define EJECT_CMPL_TYPE_LAST	EJECT_CMPL_TYPE_STAT_EJECT
-	#define EJECT_CMPL_FLAGS_MASK	UINT32_C(0xffc0)
-	#define EJECT_CMPL_FLAGS_SFT	6
+	uint16_t	agg_id;
 	/*
-	 * When this bit is '1', it indicates a packet that has an
-	 * error of some type. Type of error is indicated in
-	 * error_flags.
+	 * This is the aggregation ID that the completion is associated
+	 * with. Use this number to correlate the TPA start completion
+	 * with the TPA end completion.
 	 */
-	#define EJECT_CMPL_FLAGS_ERROR	UINT32_C(0x40)
+	#define RX_TPA_START_V3_CMPL_AGG_ID_MASK		UINT32_C(0xfff)
+	#define RX_TPA_START_V3_CMPL_AGG_ID_SFT		0
+	#define RX_TPA_START_V3_CMPL_METADATA1_MASK		UINT32_C(0xf000)
+	#define RX_TPA_START_V3_CMPL_METADATA1_SFT		12
+	/* When meta_format != 0, this value is the VLAN TPID_SEL. */
+	#define RX_TPA_START_V3_CMPL_METADATA1_TPID_SEL_MASK	UINT32_C(0x7000)
+	#define RX_TPA_START_V3_CMPL_METADATA1_TPID_SEL_SFT	12
+	/* 0x88a8 */
+		#define RX_TPA_START_V3_CMPL_METADATA1_TPID_SEL_TPID88A8   (UINT32_C(0x0) << 12)
+	/* 0x8100 */
+		#define RX_TPA_START_V3_CMPL_METADATA1_TPID_SEL_TPID8100   (UINT32_C(0x1) << 12)
+	/* 0x9100 */
+		#define RX_TPA_START_V3_CMPL_METADATA1_TPID_SEL_TPID9100   (UINT32_C(0x2) << 12)
+	/* 0x9200 */
+		#define RX_TPA_START_V3_CMPL_METADATA1_TPID_SEL_TPID9200   (UINT32_C(0x3) << 12)
+	/* 0x9300 */
+		#define RX_TPA_START_V3_CMPL_METADATA1_TPID_SEL_TPID9300   (UINT32_C(0x4) << 12)
+	/* Value programmed in CFA VLANTPID register. */
+		#define RX_TPA_START_V3_CMPL_METADATA1_TPID_SEL_TPIDCFG	(UINT32_C(0x5) << 12)
+		#define RX_TPA_START_V3_CMPL_METADATA1_TPID_SEL_LAST	RX_TPA_START_V3_CMPL_METADATA1_TPID_SEL_TPIDCFG
+	/* When meta_format != 0, this value is the VLAN valid. */
+	#define RX_TPA_START_V3_CMPL_METADATA1_VALID		UINT32_C(0x8000)
 	/*
-	 * This is the length of the statistics data stored in this
-	 * buffer.
+	 * This value is the RSS hash value calculated for the packet
+	 * based on the mode bits and key value in the VNIC.
+	 * When vee_cmpl_mode is set in VNIC context, this is the lower
+	 * 32b of the host address from the first BD used to place the packet.
 	 */
-	uint16_t	len;
+	uint32_t	rss_hash;
+} rx_tpa_start_v3_cmpl_t, *prx_tpa_start_v3_cmpl_t;
+
+/*
+ * Last 16 bytes of RX L2 TPA Start V3 Completion Record
+ *
+ * This TPA completion structure is used on devices where the
+ * `hwrm_vnic_qcaps.max_aggs_supported` value is 0.
+ */
+/* rx_tpa_start_v3_cmpl_hi (size:128b/16B) */
+
+typedef struct rx_tpa_start_v3_cmpl_hi {
+	uint32_t	flags2;
 	/*
-	 * This is a copy of the opaque field from the RX BD this ejection
-	 * buffer corresponds to.
+	 * This indicates that the ip checksum was calculated for the inner
+	 * packet and that the ip_cs_error field indicates if there was an
+	 * error.
 	 */
-	uint32_t	opaque;
-	uint16_t	v;
+	#define RX_TPA_START_V3_CMPL_FLAGS2_IP_CS_CALC		UINT32_C(0x1)
+	/*
+	 * This indicates that the TCP, UDP or ICMP checksum was calculated
+	 * for the inner packet and that the l4_cs_error field indicates if
+	 * there was an error.
+	 */
+	#define RX_TPA_START_V3_CMPL_FLAGS2_L4_CS_CALC		UINT32_C(0x2)
+	/*
+	 * This indicates that the ip checksum was calculated for the tunnel
+	 * header and that the t_ip_cs_error field indicates if there was an
+	 * error.
+	 */
+	#define RX_TPA_START_V3_CMPL_FLAGS2_T_IP_CS_CALC		UINT32_C(0x4)
+	/*
+	 * This indicates that the UDP checksum was calculated for the tunnel
+	 * packet and that the t_l4_cs_error field indicates if there was an
+	 * error.
+	 */
+	#define RX_TPA_START_V3_CMPL_FLAGS2_T_L4_CS_CALC		UINT32_C(0x8)
+	/* This value indicates what format the metadata field is. */
+	#define RX_TPA_START_V3_CMPL_FLAGS2_META_FORMAT_MASK	UINT32_C(0xf0)
+	#define RX_TPA_START_V3_CMPL_FLAGS2_META_FORMAT_SFT		4
+	/* There is no metadata information. Values are zero. */
+		#define RX_TPA_START_V3_CMPL_FLAGS2_META_FORMAT_NONE		(UINT32_C(0x0) << 4)
+	/*
+	 * The {metadata1, metadata0} fields contain the vtag
+	 * information: - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0],
+	 * de, vid[11:0]} The metadata2 field contains the table scope
+	 * and action record pointer. - metadata2[25:0] contains the
+	 * action record pointer. - metadata2[31:26] contains the table
+	 * scope.
+	 */
+		#define RX_TPA_START_V3_CMPL_FLAGS2_META_FORMAT_ACT_REC_PTR	(UINT32_C(0x1) << 4)
+	/*
+	 * The {metadata1, metadata0} fields contain the vtag
+	 * information:
+	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0], de, vid[11:0]}
+	 * The metadata2 field contains the Tunnel ID
+	 * value, justified to LSB.
+	 * - VXLAN = VNI[23:0] -> VXLAN Network ID
+	 * - Geneve (NGE) = VNI[23:0] a-> Virtual Network Identifier
+	 * - NVGRE = TNI[23:0] -> Tenant Network ID
+	 * - GRE = KEY[31:0] -> key field with bit mask. zero if K=0
+	 * - IPv4 = 0 (not populated)
+	 * - IPv6 = Flow Label[19:0]
+	 * - PPPoE = sessionID[15:0]
+	 * - MPLs = Outer label[19:0]
+	 * - UPAR = Selected[31:0] with bit mask
+	 */
+		#define RX_TPA_START_V3_CMPL_FLAGS2_META_FORMAT_TUNNEL_ID	(UINT32_C(0x2) << 4)
+	/*
+	 * The {metadata1, metadata0} fields contain the vtag
+	 * information:
+	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0],de, vid[11:0]}
+	 * The metadata2 field contains the 32b metadata from the prepended
+	 * header (chdr_data).
+	 */
+		#define RX_TPA_START_V3_CMPL_FLAGS2_META_FORMAT_CHDR_DATA	(UINT32_C(0x3) << 4)
+	/*
+	 * The {metadata1, metadata0} fields contain the vtag
+	 * information:
+	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0], de, vid[11:0]}
+	 * The metadata2 field contains the outer_l3_offset,
+	 * inner_l2_offset, inner_l3_offset, and inner_l4_size.
+	 * - metadata2[8:0] contains the outer_l3_offset.
+	 * - metadata2[17:9] contains the inner_l2_offset.
+	 * - metadata2[26:18] contains the inner_l3_offset.
+	 * - metadata2[31:27] contains the inner_l4_size.
+	 */
+		#define RX_TPA_START_V3_CMPL_FLAGS2_META_FORMAT_HDR_OFFSET	(UINT32_C(0x4) << 4)
+		#define RX_TPA_START_V3_CMPL_FLAGS2_META_FORMAT_LAST		RX_TPA_START_V3_CMPL_FLAGS2_META_FORMAT_HDR_OFFSET
+	/*
+	 * This field indicates the IP type for the inner-most IP header.
+	 * A value of '0' indicates IPv4. A value of '1' indicates IPv6.
+	 * This value is only valid if itype indicates a packet
+	 * with an IP header.
+	 */
+	#define RX_TPA_START_V3_CMPL_FLAGS2_IP_TYPE			UINT32_C(0x100)
+	/*
+	 * This indicates that the complete 1's complement checksum was
+	 * calculated for the packet.
+	 */
+	#define RX_TPA_START_V3_CMPL_FLAGS2_COMPLETE_CHECKSUM_CALC	UINT32_C(0x200)
+	/*
+	 * This field indicates the status of IP and L4 CS calculations done
+	 * by the chip. The format of this field is indicated by the
+	 * cs_all_ok_mode bit.
+	 */
+	#define RX_TPA_START_V3_CMPL_FLAGS2_T_IP_TYPE		UINT32_C(0x400)
+	/* Indicates that the Tunnel IP type was IPv4 */
+		#define RX_TPA_START_V3_CMPL_FLAGS2_T_IP_TYPE_IPV4		(UINT32_C(0x0) << 10)
+	/* Indicates that the Tunnel IP type was IPv6 */
+		#define RX_TPA_START_V3_CMPL_FLAGS2_T_IP_TYPE_IPV6		(UINT32_C(0x1) << 10)
+		#define RX_TPA_START_V3_CMPL_FLAGS2_T_IP_TYPE_LAST		RX_TPA_START_V3_CMPL_FLAGS2_T_IP_TYPE_IPV6
+	/* This indicates that the aggregation was done using GRO rules. */
+	#define RX_TPA_START_V3_CMPL_FLAGS2_AGG_GRO			UINT32_C(0x800)
+	/*
+	 * This value is the complete 1's complement checksum calculated from
+	 * the start of the outer L3 header to the end of the packet (not
+	 * including the ethernet crc). It is valid when the
+	 * 'complete_checksum_calc' flag is set. For TPA Start completions,
+	 * the complete checksum is calculated for the first packet in the
+	 * aggregation only.
+	 */
+	#define RX_TPA_START_V3_CMPL_FLAGS2_COMPLETE_CHECKSUM_MASK	UINT32_C(0xffff0000)
+	#define RX_TPA_START_V3_CMPL_FLAGS2_COMPLETE_CHECKSUM_SFT	16
+	/*
+	 * This is data from the CFA block as indicated by the meta_format
+	 * field.
+	 * - meta_format 0 - none - metadata2 = 0 - not valid/not stripped
+	 * - meta_format 1 - act_rec_ptr - metadata2 = {table_scope[5:0],
+	 *   act_rec_ptr[25:0]}
+	 * - meta_format 2 - tunnel_id - metadata2 = tunnel_id[31:0]
+	 * - meta_format 3 - chdr_data - metadata2 = updated_chdr_data[31:0]
+	 * - meta_format 4 - hdr_offsets - metadata2 = hdr_offsets[31:0]
+	 * When vee_cmpl_mode is set in VNIC context, this is the upper 32b
+	 * of the host address from the first BD used to place the packet.
+	 */
+	uint32_t	metadata2;
+	uint16_t	errors_v2;
 	/*
 	 * This value is written by the NIC such that it will be different
 	 * for each pass through the completion queue. The even passes
 	 * will write 1. The odd passes will write 0.
 	 */
-	#define EJECT_CMPL_V				UINT32_C(0x1)
-	#define EJECT_CMPL_ERRORS_MASK			UINT32_C(0xfffe)
-	#define EJECT_CMPL_ERRORS_SFT			1
+	#define RX_TPA_START_V3_CMPL_V2				UINT32_C(0x1)
+	#define RX_TPA_START_V3_CMPL_ERRORS_MASK			UINT32_C(0xfffe)
+	#define RX_TPA_START_V3_CMPL_ERRORS_SFT			1
 	/*
 	 * This error indicates that there was some sort of problem with
-	 * the BDs for statistics ejection. The statistics ejection should
-	 * be treated as invalid
+	 * the BDs for the packetThe packet should be treated as
+	 * invalid.
 	 */
-	#define EJECT_CMPL_ERRORS_BUFFER_ERROR_MASK	UINT32_C(0xe)
-	#define EJECT_CMPL_ERRORS_BUFFER_ERROR_SFT	1
+	#define RX_TPA_START_V3_CMPL_ERRORS_BUFFER_ERROR_MASK	UINT32_C(0xe)
+	#define RX_TPA_START_V3_CMPL_ERRORS_BUFFER_ERROR_SFT	1
 	/* No buffer error */
-		#define EJECT_CMPL_ERRORS_BUFFER_ERROR_NO_BUFFER	(UINT32_C(0x0) << 1)
+		#define RX_TPA_START_V3_CMPL_ERRORS_BUFFER_ERROR_NO_BUFFER	(UINT32_C(0x0) << 1)
 	/*
 	 * Did Not Fit:
-	 * Statistics did not fit into aggregation buffer provided.
+	 * Packet did not fit into packet buffer provided. This means
+	 * that the TPA Start packet was too big to be placed into the
+	 * per-packet maximum number of physical buffers configured for
+	 * the VNIC, or that it was too big to be placed into the
+	 * per-aggregation maximum number of physical buffers configured
+	 * for the VNIC. This error only occurs when the VNIC is
+	 * configured for variable size receive buffers.
 	 */
-		#define EJECT_CMPL_ERRORS_BUFFER_ERROR_DID_NOT_FIT   (UINT32_C(0x1) << 1)
+		#define RX_TPA_START_V3_CMPL_ERRORS_BUFFER_ERROR_DID_NOT_FIT   (UINT32_C(0x1) << 1)
 	/*
 	 * Bad Format:
 	 * BDs were not formatted correctly.
 	 */
-		#define EJECT_CMPL_ERRORS_BUFFER_ERROR_BAD_FORMAT	(UINT32_C(0x3) << 1)
+		#define RX_TPA_START_V3_CMPL_ERRORS_BUFFER_ERROR_BAD_FORMAT	(UINT32_C(0x3) << 1)
 	/*
 	 * Flush:
 	 * There was a bad_format error on the previous operation
 	 */
-		#define EJECT_CMPL_ERRORS_BUFFER_ERROR_FLUSH	(UINT32_C(0x5) << 1)
-		#define EJECT_CMPL_ERRORS_BUFFER_ERROR_LAST	EJECT_CMPL_ERRORS_BUFFER_ERROR_FLUSH
-	/* reserved16 is 16 b */
-	uint16_t	reserved16;
-	/* unused3 is 32 b */
-	uint32_t	unused_2;
-} eject_cmpl_t, *peject_cmpl_t;
-
-/* hwrm_cmpl (size:128b/16B) */
-
-typedef struct hwrm_cmpl {
-	uint16_t	type;
-	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
-	 */
-	#define HWRM_CMPL_TYPE_MASK	UINT32_C(0x3f)
-	#define HWRM_CMPL_TYPE_SFT	0
+		#define RX_TPA_START_V3_CMPL_ERRORS_BUFFER_ERROR_FLUSH	(UINT32_C(0x5) << 1)
+		#define RX_TPA_START_V3_CMPL_ERRORS_BUFFER_ERROR_LAST	RX_TPA_START_V3_CMPL_ERRORS_BUFFER_ERROR_FLUSH
 	/*
-	 * HWRM Command Completion:
-	 * Completion of an HWRM command.
+	 * This is data from the CFA block as indicated by the meta_format
+	 * field.
 	 */
-		#define HWRM_CMPL_TYPE_HWRM_DONE  UINT32_C(0x20)
-		#define HWRM_CMPL_TYPE_LAST	HWRM_CMPL_TYPE_HWRM_DONE
-	/* This is the sequence_id of the HWRM command that has completed. */
-	uint16_t	sequence_id;
-	/* unused2 is 32 b */
-	uint32_t	unused_1;
-	uint32_t	v;
+	uint16_t	metadata0;
+	/* When meta_format != 0, this value is the VLAN VID. */
+	#define RX_TPA_START_V3_CMPL_METADATA0_VID_MASK UINT32_C(0xfff)
+	#define RX_TPA_START_V3_CMPL_METADATA0_VID_SFT 0
+	/* When meta_format != 0, this value is the VLAN DE. */
+	#define RX_TPA_START_V3_CMPL_METADATA0_DE	UINT32_C(0x1000)
+	/* When meta_format != 0, this value is the VLAN PRI. */
+	#define RX_TPA_START_V3_CMPL_METADATA0_PRI_MASK UINT32_C(0xe000)
+	#define RX_TPA_START_V3_CMPL_METADATA0_PRI_SFT 13
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * This field contains the outer_l3_offset, inner_l2_offset,
+	 * inner_l3_offset, and inner_l4_size.
+	 *
+	 * hdr_offsets[8:0] contains the outer_l3_offset.
+	 * hdr_offsets[17:9] contains the inner_l2_offset.
+	 * hdr_offsets[26:18] contains the inner_l3_offset.
+	 * hdr_offsets[31:27] contains the inner_l4_size.
 	 */
-	#define HWRM_CMPL_V	UINT32_C(0x1)
-	/* unused4 is 32 b */
-	uint32_t	unused_3;
-} hwrm_cmpl_t, *phwrm_cmpl_t;
+	uint32_t	hdr_offsets;
+} rx_tpa_start_v3_cmpl_hi_t, *prx_tpa_start_v3_cmpl_hi_t;
 
-/* hwrm_fwd_req_cmpl (size:128b/16B) */
+/*
+ * This TPA completion structure is used on devices where the
+ * `hwrm_vnic_qcaps.max_aggs_supported` value is 0.
+ */
+/* rx_tpa_end_cmpl (size:128b/16B) */
 
-typedef struct hwrm_fwd_req_cmpl {
-	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
-	 */
-	uint16_t	req_len_type;
+typedef struct rx_tpa_end_cmpl {
+	uint16_t	flags_type;
 	/*
 	 * This field indicates the exact type of the completion.
 	 * By convention, the LSB identifies the length of the
@@ -7364,369 +8411,255 @@ typedef struct hwrm_fwd_req_cmpl {
 	 * records. Odd values indicate 32B
 	 * records.
 	 */
-	#define HWRM_FWD_REQ_CMPL_TYPE_MASK	UINT32_C(0x3f)
-	#define HWRM_FWD_REQ_CMPL_TYPE_SFT	0
-	/* Forwarded HWRM Request */
-		#define HWRM_FWD_REQ_CMPL_TYPE_HWRM_FWD_REQ  UINT32_C(0x22)
-		#define HWRM_FWD_REQ_CMPL_TYPE_LAST	HWRM_FWD_REQ_CMPL_TYPE_HWRM_FWD_REQ
-	/* Length of forwarded request in bytes. */
-	#define HWRM_FWD_REQ_CMPL_REQ_LEN_MASK	UINT32_C(0xffc0)
-	#define HWRM_FWD_REQ_CMPL_REQ_LEN_SFT	6
-	/*
-	 * Source ID of this request.
-	 * Typically used in forwarding requests and responses.
-	 * 0x0 - 0xFFF8 - Used for function ids
-	 * 0xFFF8 - 0xFFFE - Reserved for internal processors
-	 * 0xFFFF - HWRM
-	 */
-	uint16_t	source_id;
-	/* unused1 is 32 b */
-	uint32_t	unused0;
-	/* Address of forwarded request. */
-	uint64_t	req_buf_addr_v;
+	#define RX_TPA_END_CMPL_TYPE_MASK			UINT32_C(0x3f)
+	#define RX_TPA_END_CMPL_TYPE_SFT			0
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * RX L2 TPA End Completion:
+	 * Completion at the end of a TPA operation.
+	 * Length = 32B
 	 */
-	#define HWRM_FWD_REQ_CMPL_V		UINT32_C(0x1)
-	/* Address of forwarded request. */
-	#define HWRM_FWD_REQ_CMPL_REQ_BUF_ADDR_MASK UINT32_C(0xfffffffe)
-	#define HWRM_FWD_REQ_CMPL_REQ_BUF_ADDR_SFT 1
-} hwrm_fwd_req_cmpl_t, *phwrm_fwd_req_cmpl_t;
-
-/* hwrm_fwd_resp_cmpl (size:128b/16B) */
-
-typedef struct hwrm_fwd_resp_cmpl {
-	uint16_t	type;
+		#define RX_TPA_END_CMPL_TYPE_RX_TPA_END		UINT32_C(0x15)
+		#define RX_TPA_END_CMPL_TYPE_LAST			RX_TPA_END_CMPL_TYPE_RX_TPA_END
+	#define RX_TPA_END_CMPL_FLAGS_MASK			UINT32_C(0xffc0)
+	#define RX_TPA_END_CMPL_FLAGS_SFT			6
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * When this bit is '1', it indicates a packet that has an
+	 * error of some type. Type of error is indicated in
+	 * error_flags.
 	 */
-	#define HWRM_FWD_RESP_CMPL_TYPE_MASK	UINT32_C(0x3f)
-	#define HWRM_FWD_RESP_CMPL_TYPE_SFT	0
-	/* Forwarded HWRM Response */
-		#define HWRM_FWD_RESP_CMPL_TYPE_HWRM_FWD_RESP  UINT32_C(0x24)
-		#define HWRM_FWD_RESP_CMPL_TYPE_LAST	HWRM_FWD_RESP_CMPL_TYPE_HWRM_FWD_RESP
+	#define RX_TPA_END_CMPL_FLAGS_ERROR			UINT32_C(0x40)
+	/* This field indicates how the packet was placed in the buffer. */
+	#define RX_TPA_END_CMPL_FLAGS_PLACEMENT_MASK		UINT32_C(0x380)
+	#define RX_TPA_END_CMPL_FLAGS_PLACEMENT_SFT		7
 	/*
-	 * Source ID of this response.
-	 * Typically used in forwarding requests and responses.
-	 * 0x0 - 0xFFF8 - Used for function ids
-	 * 0xFFF8 - 0xFFFE - Reserved for internal processors
-	 * 0xFFFF - HWRM
+	 * Jumbo:
+	 * TPA Packet was placed using jumbo algorithm. This means
+	 * that the first buffer will be filled with data before
+	 * moving to aggregation buffers. Each aggregation buffer
+	 * will be filled before moving to the next aggregation
+	 * buffer.
 	 */
-	uint16_t	source_id;
-	/* Length of forwarded response in bytes. */
-	uint16_t	resp_len;
-	/* unused2 is 16 b */
-	uint16_t	unused_1;
-	/* Address of forwarded request. */
-	uint64_t	resp_buf_addr_v;
+		#define RX_TPA_END_CMPL_FLAGS_PLACEMENT_JUMBO		(UINT32_C(0x1) << 7)
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * Header/Data Separation:
+	 * Packet was placed using Header/Data separation algorithm.
+	 * The separation location is indicated by the itype field.
 	 */
-	#define HWRM_FWD_RESP_CMPL_V		UINT32_C(0x1)
-	/* Address of forwarded request. */
-	#define HWRM_FWD_RESP_CMPL_RESP_BUF_ADDR_MASK UINT32_C(0xfffffffe)
-	#define HWRM_FWD_RESP_CMPL_RESP_BUF_ADDR_SFT 1
-} hwrm_fwd_resp_cmpl_t, *phwrm_fwd_resp_cmpl_t;
-
-/* hwrm_async_event_cmpl (size:128b/16B) */
-
-typedef struct hwrm_async_event_cmpl {
-	uint16_t	type;
+		#define RX_TPA_END_CMPL_FLAGS_PLACEMENT_HDS		(UINT32_C(0x2) << 7)
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * IOC/Jumbo:
+	 * Packet will be placed using In-Order Completion/Jumbo where
+	 * the first packet of the aggregation is placed using Jumbo
+	 * Placement. Subsequent packets will be placed such that each
+	 * packet starts at the beginning of an aggregation buffer.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_TYPE_SFT		0
-	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_TYPE_HWRM_ASYNC_EVENT
-	/* Identifiers of events. */
-	uint16_t	event_id;
-	/* Link status changed */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE	UINT32_C(0x0)
-	/* Link MTU changed */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_MTU_CHANGE		UINT32_C(0x1)
-	/* Link speed changed */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CHANGE	UINT32_C(0x2)
-	/* DCB Configuration changed */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_DCB_CONFIG_CHANGE	UINT32_C(0x3)
-	/* Port connection not allowed */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PORT_CONN_NOT_ALLOWED	UINT32_C(0x4)
-	/* Link speed configuration was not allowed */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CFG_NOT_ALLOWED UINT32_C(0x5)
-	/* Link speed configuration change */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE	UINT32_C(0x6)
-	/* Port PHY configuration change */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PORT_PHY_CFG_CHANGE	UINT32_C(0x7)
-	/* Reset notification to clients */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_RESET_NOTIFY		UINT32_C(0x8)
-	/* Master function selection event */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_ERROR_RECOVERY		UINT32_C(0x9)
+		#define RX_TPA_END_CMPL_FLAGS_PLACEMENT_IOC_JUMBO	(UINT32_C(0x4) << 7)
 	/*
-	 * An event signifying that a ring has been disabled by
-	 * hw due to error.
+	 * GRO/Jumbo:
+	 * Packet will be placed using GRO/Jumbo where the first
+	 * packet is filled with data. Subsequent packets will be
+	 * placed such that any one packet does not span two
+	 * aggregation buffers unless it starts at the beginning of
+	 * an aggregation buffer.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_RING_MONITOR_MSG	UINT32_C(0xa)
-	/* Function driver unloaded */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_FUNC_DRVR_UNLOAD	UINT32_C(0x10)
-	/* Function driver loaded */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_FUNC_DRVR_LOAD		UINT32_C(0x11)
-	/* Function FLR related processing has completed */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_FUNC_FLR_PROC_CMPLT	UINT32_C(0x12)
-	/* PF driver unloaded */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_DRVR_UNLOAD		UINT32_C(0x20)
-	/* PF driver loaded */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_DRVR_LOAD		UINT32_C(0x21)
-	/* VF Function Level Reset (FLR) */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_VF_FLR			UINT32_C(0x30)
-	/* VF MAC Address Change */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_VF_MAC_ADDR_CHANGE	UINT32_C(0x31)
-	/* PF-VF communication channel status change. */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_VF_COMM_STATUS_CHANGE   UINT32_C(0x32)
-	/* VF Configuration Change */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_VF_CFG_CHANGE		UINT32_C(0x33)
-	/* LLFC/PFC Configuration Change */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LLFC_PFC_CHANGE		UINT32_C(0x34)
-	/* Default VNIC Configuration Change */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_DEFAULT_VNIC_CHANGE	UINT32_C(0x35)
-	/* HW flow aged */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_HW_FLOW_AGED		UINT32_C(0x36)
+		#define RX_TPA_END_CMPL_FLAGS_PLACEMENT_GRO_JUMBO	(UINT32_C(0x5) << 7)
 	/*
-	 * A debug notification being posted to the driver. These
-	 * notifications are purely for diagnostic purpose and should not be
-	 * used for functional purpose. The driver is not supposed to act
-	 * on these messages except to log/record it.
+	 * GRO/Header-Data Separation:
+	 * Packet will be placed using GRO/HDS where the header
+	 * is in the first packet.
+	 * Payload of each packet will be
+	 * placed such that any one packet does not span two
+	 * aggregation buffers unless it starts at the beginning of
+	 * an aggregation buffer.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_DEBUG_NOTIFICATION	UINT32_C(0x37)
+		#define RX_TPA_END_CMPL_FLAGS_PLACEMENT_GRO_HDS	(UINT32_C(0x6) << 7)
 	/*
-	 * An EEM flow cached memory flush for all flows request event being
-	 * posted to the PF driver.
+	 * IOC/Header-Data Separation:
+	 * Packet will be placed using In-Order Completion/HDS where
+	 * the header is in the first packet buffer. Payload of each
+	 * packet will be placed such that each packet starts at the
+	 * beginning of an aggregation buffer.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_EEM_CACHE_FLUSH_REQ	UINT32_C(0x38)
+		#define RX_TPA_END_CMPL_FLAGS_PLACEMENT_IOC_HDS	(UINT32_C(0x7) << 7)
+		#define RX_TPA_END_CMPL_FLAGS_PLACEMENT_LAST		RX_TPA_END_CMPL_FLAGS_PLACEMENT_IOC_HDS
+	/* When set, this bit indicates that the timestamp field is valid. */
+	#define RX_TPA_END_CMPL_FLAGS_TIMESTAMP_VALID	UINT32_C(0x400)
 	/*
-	 * An EEM flow cache memory flush completion event being posted to the
-	 * firmware by the PF driver. This is indication that host EEM flush
-	 * has completed by the PF.
+	 * This bit is '1' if metadata has been added to the end of the
+	 * packet in host memory. Metadata starts at the first 32B boundary
+	 * after the end of the packet for regular and jumbo placement.
+	 * It starts at the first 32B boundary after the end of the header
+	 * for HDS placement. The length of the metadata is indicated in the
+	 * metadata itself.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_EEM_CACHE_FLUSH_DONE	UINT32_C(0x39)
+	#define RX_TPA_END_CMPL_FLAGS_PKT_METADATA_PRESENT	UINT32_C(0x800)
 	/*
-	 * A tcp flag action change event being posted to the PF or trusted VF
-	 * driver by the firmware. The PF or trusted VF driver should query
-	 * the firmware for the new TCP flag action update after receiving
-	 * this async event.
+	 * This value indicates what the inner packet determined for the
+	 * packet was.
+	 * - 2 TCP Packet
+	 *	Indicates that the packet was IP and TCP. This indicates
+	 *	that the ip_cs field is valid and that the tcp_udp_cs
+	 *	field is valid and contains the TCP checksum.
+	 *	This also indicates that the payload_offset field is valid.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_TCP_FLAG_ACTION_CHANGE	UINT32_C(0x3a)
+	#define RX_TPA_END_CMPL_FLAGS_ITYPE_MASK		UINT32_C(0xf000)
+	#define RX_TPA_END_CMPL_FLAGS_ITYPE_SFT		12
 	/*
-	 * An EEM flow active event being posted to the PF or trusted VF driver
-	 * by the firmware. The PF or trusted VF driver should update the
-	 * flow's aging timer after receiving this async event.
+	 * This value is zero for TPA End completions.
+	 * There is no data in the buffer that corresponds to the opaque
+	 * value in this completion.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_EEM_FLOW_ACTIVE		UINT32_C(0x3b)
+	uint16_t	len;
 	/*
-	 * A eem cfg change event being posted to the trusted VF driver by the
-	 * firmware if the parent PF EEM configuration changed.
+	 * This is a copy of the opaque field from the RX BD this completion
+	 * corresponds to.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_EEM_CFG_CHANGE		UINT32_C(0x3c)
+	uint32_t	opaque;
 	/*
-	 * Deprecated.
-	 * TFLIB unique default VNIC Configuration Change
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_TFLIB_DEFAULT_VNIC_CHANGE  UINT32_C(0x3d)
+	uint8_t	agg_bufs_v1;
 	/*
-	 * Deprecated.
-	 * TFLIB unique link status changed
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_TFLIB_LINK_STATUS_CHANGE   UINT32_C(0x3e)
+	#define RX_TPA_END_CMPL_V1	UINT32_C(0x1)
 	/*
-	 * An event signifying completion for HWRM_FW_STATE_QUIESCE
-	 * (completion, timeout, or error)
+	 * This value is the number of aggregation buffers that follow this
+	 * entry in the completion ring that are a part of this aggregation
+	 * packet.
+	 * If the value is zero, then the packet is completely contained
+	 * in the buffer space provided in the aggregation start completion.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_QUIESCE_DONE		UINT32_C(0x3f)
+	#define RX_TPA_END_CMPL_AGG_BUFS_MASK UINT32_C(0x7e)
+	#define RX_TPA_END_CMPL_AGG_BUFS_SFT 1
+	/* This value is the number of segments in the TPA operation. */
+	uint8_t	tpa_segs;
 	/*
-	 * An event signifying a HWRM command is in progress and its
-	 * response will be deferred. This event is used on crypto controllers
-	 * only.
+	 * This value indicates the offset in bytes from the beginning of the
+	 * packet where the inner payload starts. This value is valid for TCP,
+	 * UDP, FCoE, and RoCE packets.
+	 *
+	 * A value of zero indicates an offset of 256 bytes.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_DEFERRED_RESPONSE	UINT32_C(0x40)
+	uint8_t	payload_offset;
+	uint8_t	agg_id;
+	/* unused2 is 1 b */
+	#define RX_TPA_END_CMPL_UNUSED2	UINT32_C(0x1)
 	/*
-	 * An event signifying that a PFC WatchDog configuration
-	 * has changed on any port / cos.
+	 * This is the aggregation ID that the completion is associated
+	 * with. Use this number to correlate the TPA start completion
+	 * with the TPA end completion.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PFC_WATCHDOG_CFG_CHANGE	UINT32_C(0x41)
+	#define RX_TPA_END_CMPL_AGG_ID_MASK UINT32_C(0xfe)
+	#define RX_TPA_END_CMPL_AGG_ID_SFT  1
 	/*
-	 * An echo request from the firmware. An echo response is expected by
-	 * the firmware.
+	 * For non-GRO packets, this value is the
+	 * timestamp delta between earliest and latest timestamp values for
+	 * TPA packet. If packets were not time stamped, then delta will be
+	 * zero.
+	 *
+	 * For GRO packets, this field is zero except for the following
+	 * sub-fields.
+	 * - tsdelta[31]
+	 *	Timestamp present indication. When '0', no Timestamp
+	 *	option is in the packet. When '1', then a Timestamp
+	 *	option is present in the packet.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_ECHO_REQUEST		UINT32_C(0x42)
+	uint32_t	tsdelta;
+} rx_tpa_end_cmpl_t, *prx_tpa_end_cmpl_t;
+
+/*
+ * Last 16 bytes of rx_tpa_end_cmpl.
+ *
+ * This TPA completion structure is used on devices where the
+ * `hwrm_vnic_qcaps.max_aggs_supported` value is 0.
+ */
+/* rx_tpa_end_cmpl_hi (size:128b/16B) */
+
+typedef struct rx_tpa_end_cmpl_hi {
+	uint32_t	tpa_dup_acks;
 	/*
-	 * An event from firmware indicating who has been selected as the
-	 * PHC Master. Only the function who is the Master can discipline
-	 * PHC.
+	 * This value is the number of duplicate ACKs that have been
+	 * received as part of the TPA operation.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PHC_MASTER		UINT32_C(0x43)
+	#define RX_TPA_END_CMPL_TPA_DUP_ACKS_MASK UINT32_C(0xf)
+	#define RX_TPA_END_CMPL_TPA_DUP_ACKS_SFT 0
 	/*
-	 * An event from firmware showing the last PPS timestamp that has been
-	 * latched.
+	 * This value is the valid when TPA completion is active. It
+	 * indicates the length of the longest segment of the TPA operation
+	 * for LRO mode and the length of the first segment in GRO mode.
+	 *
+	 * This value may be used by GRO software to re-construct the original
+	 * packet stream from the TPA packet. This is the length of all
+	 * but the last segment for GRO. In LRO mode this value may be used
+	 * to indicate MSS size to the stack.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PPS_TIMESTAMP		UINT32_C(0x44)
-	/* Maximum Registrable event id. */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_MAX_RGTR_EVENT_ID	UINT32_C(0x45)
+	uint16_t	tpa_seg_len;
 	/*
-	 * A trace log message. This contains firmware trace logs string
-	 * embedded in the asynchronous message. This is an experimental
-	 * event, not meant for production use at this time.
+	 * The lower 16b of the timestamp of the last packet added to the
+	 * aggregation. Only valid when flags.timestamp_valid is set.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_FW_TRACE_MSG		UINT32_C(0xfe)
-	/* HWRM Error */
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_HWRM_ERROR		UINT32_C(0xff)
-	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LAST			HWRM_ASYNC_EVENT_CMPL_EVENT_ID_HWRM_ERROR
-	/* Event specific data */
-	uint32_t	event_data2;
-	uint8_t	opaque_v;
+	uint16_t	timestamp_lower;
+	uint16_t	errors_v2;
 	/*
 	 * This value is written by the NIC such that it will be different
 	 * for each pass through the completion queue. The even passes
 	 * will write 1. The odd passes will write 0.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_V	UINT32_C(0x1)
-	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_OPAQUE_SFT 1
-	/* 8-lsb timestamp from POR (100-msec resolution) */
-	uint8_t	timestamp_lo;
-	/* 16-lsb timestamp from POR (100-msec resolution) */
-	uint16_t	timestamp_hi;
-	/* Event specific data */
-	uint32_t	event_data1;
-} hwrm_async_event_cmpl_t, *phwrm_async_event_cmpl_t;
-
-#define GET_EVENT_ID(x) \
-	(((x) < 0x80) ? \
-	((x) == 0x0 ? "LINK_STATUS_CHANGE": \
-	((x) == 0x1 ? "LINK_MTU_CHANGE": \
-	((x) == 0x2 ? "LINK_SPEED_CHANGE": \
-	((x) == 0x3 ? "DCB_CONFIG_CHANGE": \
-	((x) == 0x4 ? "PORT_CONN_NOT_ALLOWED": \
-	((x) == 0x5 ? "LINK_SPEED_CFG_NOT_ALLOWED": \
-	((x) == 0x6 ? "LINK_SPEED_CFG_CHANGE": \
-	((x) == 0x7 ? "PORT_PHY_CFG_CHANGE": \
-	((x) == 0x8 ? "RESET_NOTIFY": \
-	((x) == 0x9 ? "ERROR_RECOVERY": \
-	((x) == 0xa ? "RING_MONITOR_MSG": \
-	((x) == 0x10 ? "FUNC_DRVR_UNLOAD": \
-	((x) == 0x11 ? "FUNC_DRVR_LOAD": \
-	((x) == 0x12 ? "FUNC_FLR_PROC_CMPLT": \
-	((x) == 0x20 ? "PF_DRVR_UNLOAD": \
-	((x) == 0x21 ? "PF_DRVR_LOAD": \
-	((x) == 0x30 ? "VF_FLR": \
-	((x) == 0x31 ? "VF_MAC_ADDR_CHANGE": \
-	((x) == 0x32 ? "PF_VF_COMM_STATUS_CHANGE": \
-	((x) == 0x33 ? "VF_CFG_CHANGE": \
-	((x) == 0x34 ? "LLFC_PFC_CHANGE": \
-	((x) == 0x35 ? "DEFAULT_VNIC_CHANGE": \
-	((x) == 0x36 ? "HW_FLOW_AGED": \
-	((x) == 0x37 ? "DEBUG_NOTIFICATION": \
-	((x) == 0x38 ? "EEM_CACHE_FLUSH_REQ": \
-	((x) == 0x39 ? "EEM_CACHE_FLUSH_DONE": \
-	((x) == 0x3a ? "TCP_FLAG_ACTION_CHANGE": \
-	((x) == 0x3b ? "EEM_FLOW_ACTIVE": \
-	((x) == 0x3c ? "EEM_CFG_CHANGE": \
-	((x) == 0x3d ? "TFLIB_DEFAULT_VNIC_CHANGE": \
-	((x) == 0x3e ? "TFLIB_LINK_STATUS_CHANGE": \
-	((x) == 0x3f ? "QUIESCE_DONE": \
-	((x) == 0x40 ? "DEFERRED_RESPONSE": \
-	((x) == 0x41 ? "PFC_WATCHDOG_CFG_CHANGE": \
-	((x) == 0x42 ? "ECHO_REQUEST": \
-	((x) == 0x43 ? "PHC_MASTER": \
-	((x) == 0x44 ? "PPS_TIMESTAMP": \
-	((x) == 0x45 ? "MAX_RGTR_EVENT_ID": \
-	"Unknown decode" )))))))))))))))))))))))))))))))))))))) : \
-	(((x) < 0x100) ? \
-	((x) == 0xfe ? "FW_TRACE_MSG": \
-	((x) == 0xff ? "HWRM_ERROR": \
-	"Unknown decode" )) : \
-	"Unknown decode" ))
-
-
-/* hwrm_async_event_cmpl_link_status_change (size:128b/16B) */
-
-typedef struct hwrm_async_event_cmpl_link_status_change {
-	uint16_t	type;
+	#define RX_TPA_END_CMPL_V2				UINT32_C(0x1)
+	#define RX_TPA_END_CMPL_ERRORS_MASK			UINT32_C(0xfffe)
+	#define RX_TPA_END_CMPL_ERRORS_SFT			1
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * This error indicates that there was some sort of problem with
+	 * the BDs for the packet that was found after part of the
+	 * packet was already placed. The packet should be treated as
+	 * invalid.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_TYPE_SFT		0
-	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_TYPE_HWRM_ASYNC_EVENT
-	/* Identifiers of events. */
-	uint16_t	event_id;
-	/* Link status changed */
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_EVENT_ID_LINK_STATUS_CHANGE UINT32_C(0x0)
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_EVENT_ID_LAST		HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_EVENT_ID_LINK_STATUS_CHANGE
-	/* Event specific data */
-	uint32_t	event_data2;
-	uint8_t	opaque_v;
+	#define RX_TPA_END_CMPL_ERRORS_BUFFER_ERROR_MASK	UINT32_C(0xe)
+	#define RX_TPA_END_CMPL_ERRORS_BUFFER_ERROR_SFT	1
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * This error occurs when there is a fatal HW problem in
+	 * the chip only. It indicates that there were not
+	 * BDs on chip but that there was adequate reservation.
+	 * provided by the TPA block.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_V	UINT32_C(0x1)
-	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_OPAQUE_SFT 1
-	/* 8-lsb timestamp from POR (100-msec resolution) */
-	uint8_t	timestamp_lo;
-	/* 16-lsb timestamp from POR (100-msec resolution) */
-	uint16_t	timestamp_hi;
-	/* Event specific data */
-	uint32_t	event_data1;
-	/* Indicates link status change */
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_EVENT_DATA1_LINK_CHANGE	UINT32_C(0x1)
+		#define RX_TPA_END_CMPL_ERRORS_BUFFER_ERROR_NOT_ON_CHIP   (UINT32_C(0x2) << 1)
 	/*
-	 * If this bit set to 0, then it indicates that the link
-	 * was up and it went down.
+	 * This error occurs when TPA block was not configured to
+	 * reserve adequate BDs for TPA operations on this RX
+	 * ring. All data for the TPA operation was not placed.
+	 *
+	 * This error can also be generated when the number of
+	 * segments is not programmed correctly in TPA and the
+	 * 33 total aggregation buffers allowed for the TPA
+	 * operation has been exceeded.
 	 */
-		#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_EVENT_DATA1_LINK_CHANGE_DOWN  UINT32_C(0x0)
+		#define RX_TPA_END_CMPL_ERRORS_BUFFER_ERROR_RSV_ERROR	(UINT32_C(0x4) << 1)
+		#define RX_TPA_END_CMPL_ERRORS_BUFFER_ERROR_LAST	RX_TPA_END_CMPL_ERRORS_BUFFER_ERROR_RSV_ERROR
 	/*
-	 * If this bit is set to 1, then it indicates that the link
-	 * was down and it went up.
+	 * The upper 16b of the timestamp of the last packet added to the
+	 * aggregation. Only valid when flags.timestamp_valid is set.
 	 */
-		#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_EVENT_DATA1_LINK_CHANGE_UP	UINT32_C(0x1)
-		#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_EVENT_DATA1_LINK_CHANGE_LAST HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_EVENT_DATA1_LINK_CHANGE_UP
-	/* Indicates the physical port this link status change occur */
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_EVENT_DATA1_PORT_MASK	UINT32_C(0xe)
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_EVENT_DATA1_PORT_SFT	1
-	/* PORT ID */
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_EVENT_DATA1_PORT_ID_MASK	UINT32_C(0xffff0)
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_EVENT_DATA1_PORT_ID_SFT	4
-	/* Indicates the physical function this event occurred on. */
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_EVENT_DATA1_PF_ID_MASK	UINT32_C(0xff00000)
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_EVENT_DATA1_PF_ID_SFT	20
-} hwrm_async_event_cmpl_link_status_change_t, *phwrm_async_event_cmpl_link_status_change_t;
+	uint16_t	timestamp_upper;
+	/*
+	 * This is the opaque value that was completed for the TPA start
+	 * completion that corresponds to this TPA end completion.
+	 */
+	uint32_t	start_opaque;
+} rx_tpa_end_cmpl_hi_t, *prx_tpa_end_cmpl_hi_t;
 
-/* hwrm_async_event_cmpl_link_mtu_change (size:128b/16B) */
+/*
+ * This TPA completion structure is used on devices where the
+ * `hwrm_vnic_qcaps.max_aggs_supported` value is greater than 0.
+ */
+/* rx_tpa_v2_start_cmpl (size:128b/16B) */
 
-typedef struct hwrm_async_event_cmpl_link_mtu_change {
-	uint16_t	type;
+typedef struct rx_tpa_v2_start_cmpl {
+	uint16_t	flags_type;
 	/*
 	 * This field indicates the exact type of the completion.
 	 * By convention, the LSB identifies the length of the
@@ -7734,704 +8667,349 @@ typedef struct hwrm_async_event_cmpl_link_mtu_change {
 	 * records. Odd values indicate 32B
 	 * records.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_MTU_CHANGE_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_MTU_CHANGE_TYPE_SFT		0
-	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_LINK_MTU_CHANGE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_LINK_MTU_CHANGE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_LINK_MTU_CHANGE_TYPE_HWRM_ASYNC_EVENT
-	/* Identifiers of events. */
-	uint16_t	event_id;
-	/* Link MTU changed */
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_MTU_CHANGE_EVENT_ID_LINK_MTU_CHANGE UINT32_C(0x1)
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_MTU_CHANGE_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_LINK_MTU_CHANGE_EVENT_ID_LINK_MTU_CHANGE
-	/* Event specific data */
-	uint32_t	event_data2;
-	uint8_t	opaque_v;
+	#define RX_TPA_V2_START_CMPL_TYPE_MASK			UINT32_C(0x3f)
+	#define RX_TPA_V2_START_CMPL_TYPE_SFT			0
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * RX L2 TPA Start Completion:
+	 * Completion at the beginning of a TPA operation.
+	 * Length = 32B
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_MTU_CHANGE_V	UINT32_C(0x1)
-	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_MTU_CHANGE_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_MTU_CHANGE_OPAQUE_SFT 1
-	/* 8-lsb timestamp from POR (100-msec resolution) */
-	uint8_t	timestamp_lo;
-	/* 16-lsb timestamp from POR (100-msec resolution) */
-	uint16_t	timestamp_hi;
-	/* Event specific data */
-	uint32_t	event_data1;
-	/* The new MTU of the link in bytes. */
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_MTU_CHANGE_EVENT_DATA1_NEW_MTU_MASK UINT32_C(0xffff)
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_MTU_CHANGE_EVENT_DATA1_NEW_MTU_SFT 0
-} hwrm_async_event_cmpl_link_mtu_change_t, *phwrm_async_event_cmpl_link_mtu_change_t;
-
-/* hwrm_async_event_cmpl_link_speed_change (size:128b/16B) */
-
-typedef struct hwrm_async_event_cmpl_link_speed_change {
-	uint16_t	type;
+		#define RX_TPA_V2_START_CMPL_TYPE_RX_TPA_START		UINT32_C(0x13)
+		#define RX_TPA_V2_START_CMPL_TYPE_LAST			RX_TPA_V2_START_CMPL_TYPE_RX_TPA_START
+	#define RX_TPA_V2_START_CMPL_FLAGS_MASK			UINT32_C(0xffc0)
+	#define RX_TPA_V2_START_CMPL_FLAGS_SFT			6
+	/* This bit will always be '0' for TPA start completions. */
+	#define RX_TPA_V2_START_CMPL_FLAGS_ERROR			UINT32_C(0x40)
+	/* This field indicates how the packet was placed in the buffer. */
+	#define RX_TPA_V2_START_CMPL_FLAGS_PLACEMENT_MASK		UINT32_C(0x380)
+	#define RX_TPA_V2_START_CMPL_FLAGS_PLACEMENT_SFT		7
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * Jumbo:
+	 * TPA Packet was placed using jumbo algorithm. This means
+	 * that the first buffer will be filled with data before
+	 * moving to aggregation buffers. Each aggregation buffer
+	 * will be filled before moving to the next aggregation
+	 * buffer.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_TYPE_SFT		0
-	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_TYPE_HWRM_ASYNC_EVENT
-	/* Identifiers of events. */
-	uint16_t	event_id;
-	/* Link speed changed */
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_ID_LINK_SPEED_CHANGE UINT32_C(0x2)
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_ID_LAST		HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_ID_LINK_SPEED_CHANGE
-	/* Event specific data */
-	uint32_t	event_data2;
-	uint8_t	opaque_v;
+		#define RX_TPA_V2_START_CMPL_FLAGS_PLACEMENT_JUMBO		(UINT32_C(0x1) << 7)
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * Header/Data Separation:
+	 * Packet was placed using Header/Data separation algorithm.
+	 * The separation location is indicated by the itype field.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_V	UINT32_C(0x1)
-	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_OPAQUE_SFT 1
-	/* 8-lsb timestamp from POR (100-msec resolution) */
-	uint8_t	timestamp_lo;
-	/* 16-lsb timestamp from POR (100-msec resolution) */
-	uint16_t	timestamp_hi;
-	/* Event specific data */
-	uint32_t	event_data1;
+		#define RX_TPA_V2_START_CMPL_FLAGS_PLACEMENT_HDS		(UINT32_C(0x2) << 7)
 	/*
-	 * When this bit is '1', the link was forced to the
-	 * force_link_speed value.
+	 * GRO/Jumbo:
+	 * Packet will be placed using GRO/Jumbo where the first
+	 * packet is filled with data. Subsequent packets will be
+	 * placed such that any one packet does not span two
+	 * aggregation buffers unless it starts at the beginning of
+	 * an aggregation buffer.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_FORCE			UINT32_C(0x1)
-	/* The new link speed in 100 Mbps units. */
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_MASK UINT32_C(0xfffe)
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_SFT  1
-	/* 100Mb link speed */
-		#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_100MB  (UINT32_C(0x1) << 1)
-	/* 1Gb link speed */
-		#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_1GB	(UINT32_C(0xa) << 1)
-	/* 2Gb link speed */
-		#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_2GB	(UINT32_C(0x14) << 1)
-	/* 25Gb link speed */
-		#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_2_5GB  (UINT32_C(0x19) << 1)
-	/* 10Gb link speed */
-		#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_10GB   (UINT32_C(0x64) << 1)
-	/* 20Mb link speed */
-		#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_20GB   (UINT32_C(0xc8) << 1)
-	/* 25Gb link speed */
-		#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_25GB   (UINT32_C(0xfa) << 1)
-	/* 40Gb link speed */
-		#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_40GB   (UINT32_C(0x190) << 1)
-	/* 50Gb link speed */
-		#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_50GB   (UINT32_C(0x1f4) << 1)
-	/* 100Gb link speed */
-		#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_100GB  (UINT32_C(0x3e8) << 1)
-		#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_LAST  HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_100GB
-	/* PORT ID */
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_PORT_ID_MASK		UINT32_C(0xffff0000)
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_PORT_ID_SFT		16
-} hwrm_async_event_cmpl_link_speed_change_t, *phwrm_async_event_cmpl_link_speed_change_t;
-
-/* hwrm_async_event_cmpl_dcb_config_change (size:128b/16B) */
-
-typedef struct hwrm_async_event_cmpl_dcb_config_change {
-	uint16_t	type;
+		#define RX_TPA_V2_START_CMPL_FLAGS_PLACEMENT_GRO_JUMBO	(UINT32_C(0x5) << 7)
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * GRO/Header-Data Separation:
+	 * Packet will be placed using GRO/HDS where the header
+	 * is in the first packet.
+	 * Payload of each packet will be
+	 * placed such that any one packet does not span two
+	 * aggregation buffers unless it starts at the beginning of
+	 * an aggregation buffer.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_TYPE_SFT		0
-	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_TYPE_HWRM_ASYNC_EVENT
-	/* Identifiers of events. */
-	uint16_t	event_id;
-	/* DCB Configuration changed */
-	#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_ID_DCB_CONFIG_CHANGE UINT32_C(0x3)
-	#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_ID_LAST		HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_ID_DCB_CONFIG_CHANGE
-	/* Event specific data */
-	uint32_t	event_data2;
-	/* ETS configuration change */
-	#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_DATA2_ETS	UINT32_C(0x1)
-	/* PFC configuration change */
-	#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_DATA2_PFC	UINT32_C(0x2)
-	/* APP configuration change */
-	#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_DATA2_APP	UINT32_C(0x4)
-	/* DSCP configuration change */
-	#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_DATA2_DSCP	UINT32_C(0x8)
-	uint8_t	opaque_v;
+		#define RX_TPA_V2_START_CMPL_FLAGS_PLACEMENT_GRO_HDS	(UINT32_C(0x6) << 7)
+		#define RX_TPA_V2_START_CMPL_FLAGS_PLACEMENT_LAST		RX_TPA_V2_START_CMPL_FLAGS_PLACEMENT_GRO_HDS
+	/* This bit is '1' if the RSS field in this completion is valid. */
+	#define RX_TPA_V2_START_CMPL_FLAGS_RSS_VALID		UINT32_C(0x400)
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * For devices that support timestamps, when this bit is cleared the
+	 * `inner_l4_size_inner_l3_offset_inner_l2_offset_outer_l3_offset`
+	 * field contains the 32b timestamp for
+	 * the packet from the MAC. When this bit is set, the
+	 * `inner_l4_size_inner_l3_offset_inner_l2_offset_outer_l3_offset`
+	 * field contains the outer_l3_offset, inner_l2_offset,
+	 * inner_l3_offset, and inner_l4_size.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_V	UINT32_C(0x1)
-	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_OPAQUE_SFT 1
-	/* 8-lsb timestamp from POR (100-msec resolution) */
-	uint8_t	timestamp_lo;
-	/* 16-lsb timestamp from POR (100-msec resolution) */
-	uint16_t	timestamp_hi;
-	/* Event specific data */
-	uint32_t	event_data1;
-	/* PORT ID */
-	#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_DATA1_PORT_ID_MASK		UINT32_C(0xffff)
-	#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_DATA1_PORT_ID_SFT		0
-	/* Priority recommended for RoCE traffic */
-	#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_DATA1_RECOMMEND_ROCE_PRIORITY_MASK UINT32_C(0xff0000)
-	#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_DATA1_RECOMMEND_ROCE_PRIORITY_SFT 16
-	/* none is 255 */
-		#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_DATA1_RECOMMEND_ROCE_PRIORITY_NONE  (UINT32_C(0xff) << 16)
-		#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_DATA1_RECOMMEND_ROCE_PRIORITY_LAST HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_DATA1_RECOMMEND_ROCE_PRIORITY_NONE
-	/* Priority recommended for L2 traffic */
-	#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_DATA1_RECOMMEND_L2_PRIORITY_MASK  UINT32_C(0xff000000)
-	#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_DATA1_RECOMMEND_L2_PRIORITY_SFT   24
-	/* none is 255 */
-		#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_DATA1_RECOMMEND_L2_PRIORITY_NONE	(UINT32_C(0xff) << 24)
-		#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_DATA1_RECOMMEND_L2_PRIORITY_LAST   HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_DATA1_RECOMMEND_L2_PRIORITY_NONE
-} hwrm_async_event_cmpl_dcb_config_change_t, *phwrm_async_event_cmpl_dcb_config_change_t;
-
-/* hwrm_async_event_cmpl_port_conn_not_allowed (size:128b/16B) */
-
-typedef struct hwrm_async_event_cmpl_port_conn_not_allowed {
-	uint16_t	type;
+	#define RX_TPA_V2_START_CMPL_FLAGS_TIMESTAMP_FLD_FORMAT	UINT32_C(0x800)
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * This value indicates what the inner packet determined for the
+	 * packet was.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_TYPE_SFT		0
-	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_TYPE_HWRM_ASYNC_EVENT
-	/* Identifiers of events. */
-	uint16_t	event_id;
-	/* Port connection not allowed */
-	#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_EVENT_ID_PORT_CONN_NOT_ALLOWED UINT32_C(0x4)
-	#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_EVENT_ID_LAST		HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_EVENT_ID_PORT_CONN_NOT_ALLOWED
-	/* Event specific data */
-	uint32_t	event_data2;
-	uint8_t	opaque_v;
+	#define RX_TPA_V2_START_CMPL_FLAGS_ITYPE_MASK		UINT32_C(0xf000)
+	#define RX_TPA_V2_START_CMPL_FLAGS_ITYPE_SFT		12
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * TCP Packet:
+	 * Indicates that the packet was IP and TCP.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_V	UINT32_C(0x1)
-	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_OPAQUE_SFT 1
-	/* 8-lsb timestamp from POR (100-msec resolution) */
-	uint8_t	timestamp_lo;
-	/* 16-lsb timestamp from POR (100-msec resolution) */
-	uint16_t	timestamp_hi;
-	/* Event specific data */
-	uint32_t	event_data1;
-	/* PORT ID */
-	#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_EVENT_DATA1_PORT_ID_MASK		UINT32_C(0xffff)
-	#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_EVENT_DATA1_PORT_ID_SFT		0
+		#define RX_TPA_V2_START_CMPL_FLAGS_ITYPE_TCP		(UINT32_C(0x2) << 12)
+		#define RX_TPA_V2_START_CMPL_FLAGS_ITYPE_LAST		RX_TPA_V2_START_CMPL_FLAGS_ITYPE_TCP
 	/*
-	 * This value indicates the current port level enforcement policy
-	 * for the optics module when there is an optical module mismatch
-	 * and port is not connected.
+	 * This value indicates the amount of packet data written to the
+	 * buffer the opaque field in this completion corresponds to.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_EVENT_DATA1_ENFORCEMENT_POLICY_MASK	UINT32_C(0xff0000)
-	#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_EVENT_DATA1_ENFORCEMENT_POLICY_SFT	16
-	/* No enforcement */
-		#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_EVENT_DATA1_ENFORCEMENT_POLICY_NONE	(UINT32_C(0x0) << 16)
-	/* Disable Transmit side Laser. */
-		#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_EVENT_DATA1_ENFORCEMENT_POLICY_DISABLETX   (UINT32_C(0x1) << 16)
-	/* Raise a warning message. */
-		#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_EVENT_DATA1_ENFORCEMENT_POLICY_WARNINGMSG  (UINT32_C(0x2) << 16)
-	/* Power down the module. */
-		#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_EVENT_DATA1_ENFORCEMENT_POLICY_PWRDOWN	(UINT32_C(0x3) << 16)
-		#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_EVENT_DATA1_ENFORCEMENT_POLICY_LAST	HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_EVENT_DATA1_ENFORCEMENT_POLICY_PWRDOWN
-} hwrm_async_event_cmpl_port_conn_not_allowed_t, *phwrm_async_event_cmpl_port_conn_not_allowed_t;
-
-/* hwrm_async_event_cmpl_link_speed_cfg_not_allowed (size:128b/16B) */
-
-typedef struct hwrm_async_event_cmpl_link_speed_cfg_not_allowed {
-	uint16_t	type;
+	uint16_t	len;
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * This is a copy of the opaque field from the RX BD this completion
+	 * corresponds to.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_NOT_ALLOWED_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_NOT_ALLOWED_TYPE_SFT		0
-	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_NOT_ALLOWED_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_NOT_ALLOWED_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_NOT_ALLOWED_TYPE_HWRM_ASYNC_EVENT
-	/* Identifiers of events. */
-	uint16_t	event_id;
-	/* Link speed configuration was not allowed */
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_NOT_ALLOWED_EVENT_ID_LINK_SPEED_CFG_NOT_ALLOWED UINT32_C(0x5)
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_NOT_ALLOWED_EVENT_ID_LAST			HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_NOT_ALLOWED_EVENT_ID_LINK_SPEED_CFG_NOT_ALLOWED
-	/* Event specific data */
-	uint32_t	event_data2;
-	uint8_t	opaque_v;
+	uint32_t	opaque;
 	/*
 	 * This value is written by the NIC such that it will be different
 	 * for each pass through the completion queue. The even passes
 	 * will write 1. The odd passes will write 0.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_NOT_ALLOWED_V	UINT32_C(0x1)
-	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_NOT_ALLOWED_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_NOT_ALLOWED_OPAQUE_SFT 1
-	/* 8-lsb timestamp from POR (100-msec resolution) */
-	uint8_t	timestamp_lo;
-	/* 16-lsb timestamp from POR (100-msec resolution) */
-	uint16_t	timestamp_hi;
-	/* Event specific data */
-	uint32_t	event_data1;
-	/* PORT ID */
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_NOT_ALLOWED_EVENT_DATA1_PORT_ID_MASK UINT32_C(0xffff)
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_NOT_ALLOWED_EVENT_DATA1_PORT_ID_SFT 0
-} hwrm_async_event_cmpl_link_speed_cfg_not_allowed_t, *phwrm_async_event_cmpl_link_speed_cfg_not_allowed_t;
-
-/* hwrm_async_event_cmpl_link_speed_cfg_change (size:128b/16B) */
-
-typedef struct hwrm_async_event_cmpl_link_speed_cfg_change {
-	uint16_t	type;
-	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
-	 */
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_TYPE_SFT		0
-	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_TYPE_HWRM_ASYNC_EVENT
-	/* Identifiers of events. */
-	uint16_t	event_id;
-	/* Link speed configuration change */
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_EVENT_ID_LINK_SPEED_CFG_CHANGE UINT32_C(0x6)
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_EVENT_ID_LAST		HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_EVENT_ID_LINK_SPEED_CFG_CHANGE
-	/* Event specific data */
-	uint32_t	event_data2;
-	uint8_t	opaque_v;
+	uint8_t	v1;
 	/*
 	 * This value is written by the NIC such that it will be different
 	 * for each pass through the completion queue. The even passes
 	 * will write 1. The odd passes will write 0.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_V	UINT32_C(0x1)
-	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_OPAQUE_SFT 1
-	/* 8-lsb timestamp from POR (100-msec resolution) */
-	uint8_t	timestamp_lo;
-	/* 16-lsb timestamp from POR (100-msec resolution) */
-	uint16_t	timestamp_hi;
-	/* Event specific data */
-	uint32_t	event_data1;
-	/* PORT ID */
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_EVENT_DATA1_PORT_ID_MASK			UINT32_C(0xffff)
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_EVENT_DATA1_PORT_ID_SFT			0
-	/*
-	 * If set to 1, it indicates that the supported link speeds
-	 * configuration on the port has changed.
-	 * If set to 0, then there is no change in supported link speeds
-	 * configuration.
-	 */
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_EVENT_DATA1_SUPPORTED_LINK_SPEEDS_CHANGE	UINT32_C(0x10000)
+	#define RX_TPA_V2_START_CMPL_V1 UINT32_C(0x1)
+	#define RX_TPA_V2_START_CMPL_LAST RX_TPA_V2_START_CMPL_V1
 	/*
-	 * If set to 1, it indicates that the link speed configuration
-	 * on the port has become illegal or invalid.
-	 * If set to 0, then the link speed configuration on the port is
-	 * legal or valid.
+	 * This is the RSS hash type for the packet. The value is packed
+	 * {tuple_extrac_op[1:0],rss_profile_id[4:0],tuple_extrac_op[2]}.
+	 *
+	 * The value of tuple_extrac_op provides the information about
+	 * what fields the hash was computed on.
+	 * * 0: The RSS hash was computed over source IP address,
+	 * destination IP address, source port, and destination port of inner
+	 * IP and TCP or UDP headers. Note: For non-tunneled packets,
+	 * the packet headers are considered inner packet headers for the RSS
+	 * hash computation purpose.
+	 * * 1: The RSS hash was computed over source IP address and destination
+	 * IP address of inner IP header. Note: For non-tunneled packets,
+	 * the packet headers are considered inner packet headers for the RSS
+	 * hash computation purpose.
+	 * * 2: The RSS hash was computed over source IP address,
+	 * destination IP address, source port, and destination port of
+	 * IP and TCP or UDP headers of outer tunnel headers.
+	 * Note: For non-tunneled packets, this value is not applicable.
+	 * * 3: The RSS hash was computed over source IP address and
+	 * destination IP address of IP header of outer tunnel headers.
+	 * Note: For non-tunneled packets, this value is not applicable.
+	 *
+	 * Note that 4-tuples values listed above are applicable
+	 * for layer 4 protocols supported and enabled for RSS in the hardware,
+	 * HWRM firmware, and drivers. For example, if RSS hash is supported and
+	 * enabled for TCP traffic only, then the values of tuple_extract_op
+	 * corresponding to 4-tuples are only valid for TCP traffic.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_EVENT_DATA1_ILLEGAL_LINK_SPEED_CFG	UINT32_C(0x20000)
-} hwrm_async_event_cmpl_link_speed_cfg_change_t, *phwrm_async_event_cmpl_link_speed_cfg_change_t;
-
-/* hwrm_async_event_cmpl_port_phy_cfg_change (size:128b/16B) */
-
-typedef struct hwrm_async_event_cmpl_port_phy_cfg_change {
-	uint16_t	type;
+	uint8_t	rss_hash_type;
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * This is the aggregation ID that the completion is associated
+	 * with. Use this number to correlate the TPA start completion
+	 * with the TPA end completion.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_TYPE_SFT		0
-	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_TYPE_HWRM_ASYNC_EVENT
-	/* Identifiers of events. */
-	uint16_t	event_id;
-	/* Port PHY configuration change */
-	#define HWRM_ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_EVENT_ID_PORT_PHY_CFG_CHANGE UINT32_C(0x7)
-	#define HWRM_ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_EVENT_ID_LAST		HWRM_ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_EVENT_ID_PORT_PHY_CFG_CHANGE
-	/* Event specific data */
-	uint32_t	event_data2;
-	uint8_t	opaque_v;
+	uint16_t	agg_id;
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * This value is the RSS hash value calculated for the packet
+	 * based on the mode bits and key value in the VNIC.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_V	UINT32_C(0x1)
-	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_OPAQUE_SFT 1
-	/* 8-lsb timestamp from POR (100-msec resolution) */
-	uint8_t	timestamp_lo;
-	/* 16-lsb timestamp from POR (100-msec resolution) */
-	uint16_t	timestamp_hi;
-	/* Event specific data */
-	uint32_t	event_data1;
-	/* PORT ID */
-	#define HWRM_ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_EVENT_DATA1_PORT_ID_MASK	UINT32_C(0xffff)
-	#define HWRM_ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_EVENT_DATA1_PORT_ID_SFT	0
+	uint32_t	rss_hash;
+} rx_tpa_v2_start_cmpl_t, *prx_tpa_v2_start_cmpl_t;
+
+/*
+ * Last 16 bytes of rx_tpa_v2_start_cmpl.
+ *
+ * This TPA completion structure is used on devices where the
+ * `hwrm_vnic_qcaps.max_aggs_supported` value is greater than 0.
+ */
+/* rx_tpa_v2_start_cmpl_hi (size:128b/16B) */
+
+typedef struct rx_tpa_v2_start_cmpl_hi {
+	uint32_t	flags2;
 	/*
-	 * If set to 1, it indicates that the FEC
-	 * configuration on the port has changed.
-	 * If set to 0, then there is no change in FEC configuration.
+	 * This indicates that the ip checksum was calculated for the
+	 * inner packet and that the sum passed for all segments
+	 * included in the aggregation.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_EVENT_DATA1_FEC_CFG_CHANGE	UINT32_C(0x10000)
+	#define RX_TPA_V2_START_CMPL_FLAGS2_IP_CS_CALC		UINT32_C(0x1)
 	/*
-	 * If set to 1, it indicates that the EEE configuration
-	 * on the port has changed.
-	 * If set to 0, then there is no change in EEE configuration
-	 * on the port.
+	 * This indicates that the TCP, UDP or ICMP checksum was
+	 * calculated for the inner packet and that the sum passed
+	 * for all segments included in the aggregation.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_EVENT_DATA1_EEE_CFG_CHANGE	UINT32_C(0x20000)
+	#define RX_TPA_V2_START_CMPL_FLAGS2_L4_CS_CALC		UINT32_C(0x2)
 	/*
-	 * If set to 1, it indicates that the pause configuration
-	 * on the PHY has changed.
-	 * If set to 0, then there is no change in the pause
-	 * configuration on the PHY.
+	 * This indicates that the ip checksum was calculated for the
+	 * tunnel header and that the sum passed for all segments
+	 * included in the aggregation.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_EVENT_DATA1_PAUSE_CFG_CHANGE	UINT32_C(0x40000)
-} hwrm_async_event_cmpl_port_phy_cfg_change_t, *phwrm_async_event_cmpl_port_phy_cfg_change_t;
-
-/* hwrm_async_event_cmpl_reset_notify (size:128b/16B) */
-
-typedef struct hwrm_async_event_cmpl_reset_notify {
-	uint16_t	type;
+	#define RX_TPA_V2_START_CMPL_FLAGS2_T_IP_CS_CALC		UINT32_C(0x4)
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * This indicates that the UDP checksum was
+	 * calculated for the tunnel packet and that the sum passed for
+	 * all segments included in the aggregation.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_TYPE_SFT		0
-	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_TYPE_HWRM_ASYNC_EVENT
-	/* Identifiers of events. */
-	uint16_t	event_id;
-	/* Notify clients of imminent reset. */
-	#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_ID_RESET_NOTIFY UINT32_C(0x8)
-	#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_ID_RESET_NOTIFY
-	/* Event specific data. The data is for internal debug use only. */
-	uint32_t	event_data2;
+	#define RX_TPA_V2_START_CMPL_FLAGS2_T_L4_CS_CALC		UINT32_C(0x8)
+	/* This value indicates what format the metadata field is. */
+	#define RX_TPA_V2_START_CMPL_FLAGS2_META_FORMAT_MASK	UINT32_C(0xf0)
+	#define RX_TPA_V2_START_CMPL_FLAGS2_META_FORMAT_SFT		4
+	/* No metadata information. Value is zero. */
+		#define RX_TPA_V2_START_CMPL_FLAGS2_META_FORMAT_NONE		(UINT32_C(0x0) << 4)
 	/*
-	 * These bits indicate the status as being reported by the firmware.
-	 * This value is exactly the same as status code in fw_status register.
-	 * If the status code is equal to 0x8000, then the reset is initiated
-	 * by the Host using the FW_RESET command when the FW is in a healthy
-	 * state. If the status code is not equal to 0x8000, then the reset is
-	 * initiated by the FW to recover from the error or FATAL state.
+	 * The metadata field contains the VLAN tag and TPID value.
+	 * - metadata[11:0] contains the vlan VID value.
+	 * - metadata[12] contains the vlan DE value.
+	 * - metadata[15:13] contains the vlan PRI value.
+	 * - metadata[31:16] contains the vlan TPID value.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA2_FW_STATUS_CODE_MASK UINT32_C(0xffff)
-	#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA2_FW_STATUS_CODE_SFT 0
-	uint8_t	opaque_v;
+		#define RX_TPA_V2_START_CMPL_FLAGS2_META_FORMAT_VLAN		(UINT32_C(0x1) << 4)
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * If ext_meta_format is equal to 1, the metadata field
+	 * contains the lower 16b of the tunnel ID value, justified
+	 * to LSB
+	 * - VXLAN = VNI[23:0] -> VXLAN Network ID
+	 * - Geneve (NGE) = VNI[23:0] a-> Virtual Network Identifier.
+	 * - NVGRE = TNI[23:0] -> Tenant Network ID
+	 * - GRE = KEY[31:0] -> key field with bit mask. Zero if K = 0
+	 * - IPV4 = 0 (not populated)
+	 * - IPV6 = Flow Label[19:0]
+	 * - PPPoE = sessionID[15:0]
+	 * - MPLs = Outer label[19:0]
+	 * - UPAR = Selected[31:0] with bit mask
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_V	UINT32_C(0x1)
-	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_OPAQUE_SFT 1
+		#define RX_TPA_V2_START_CMPL_FLAGS2_META_FORMAT_TUNNEL_ID	(UINT32_C(0x2) << 4)
 	/*
-	 * 8-lsb timestamp (100-msec resolution)
-	 * The Minimum time required for the Firmware readiness after sending this
-	 * notification to the driver instances.
+	 * if ext_meta_format is equal to 1, metadata field contains
+	 * 16b metadata from the prepended header (chdr_data).
 	 */
-	uint8_t	timestamp_lo;
+		#define RX_TPA_V2_START_CMPL_FLAGS2_META_FORMAT_CHDR_DATA	(UINT32_C(0x3) << 4)
 	/*
-	 * 16-lsb timestamp (100-msec resolution)
-	 * The Maximum Firmware Reset bail out value in the order of 100
-	 * milli seconds. The driver instances will use this value to re-initiate the
-	 * registration process again if the core firmware didn’t set the ready
-	 * state bit.
+	 * If ext_meta_format is equal to 1, the metadata field contains
+	 * the outer_l3_offset, inner_l2_offset, inner_l3_offset and
+	 * inner_l4_size.
+	 * - metadata[8:0] contains the outer_l3_offset.
+	 * - metadata[17:9] contains the inner_l2_offset.
+	 * - metadata[26:18] contains the inner_l3_offset.
+	 * - metadata[31:27] contains the inner_l4_size.
 	 */
-	uint16_t	timestamp_hi;
-	/* Event specific data */
-	uint32_t	event_data1;
-	/* Indicates driver action requested */
-	#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_DRIVER_ACTION_MASK		UINT32_C(0xff)
-	#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_DRIVER_ACTION_SFT		0
+		#define RX_TPA_V2_START_CMPL_FLAGS2_META_FORMAT_HDR_OFFSET	(UINT32_C(0x4) << 4)
+		#define RX_TPA_V2_START_CMPL_FLAGS2_META_FORMAT_LAST		RX_TPA_V2_START_CMPL_FLAGS2_META_FORMAT_HDR_OFFSET
 	/*
-	 * If set to 1, it indicates that the l2 client should
-	 * stop sending in band traffic to Nitro.
-	 * if set to 0, there is no change in L2 client behavior.
+	 * This field indicates the IP type for the inner-most IP header.
+	 * A value of '0' indicates IPv4. A value of '1' indicates IPv6.
 	 */
-		#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_DRIVER_ACTION_DRIVER_STOP_TX_QUEUE	UINT32_C(0x1)
+	#define RX_TPA_V2_START_CMPL_FLAGS2_IP_TYPE			UINT32_C(0x100)
 	/*
-	 * If set to 1, it indicates that the L2 client should
-	 * bring down the interface.
-	 * If set to 0, then there is no change in L2 client behavior.
+	 * This indicates that the complete 1's complement checksum was
+	 * calculated for the packet.
 	 */
-		#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_DRIVER_ACTION_DRIVER_IFDOWN	UINT32_C(0x2)
-		#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_DRIVER_ACTION_LAST		HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_DRIVER_ACTION_DRIVER_IFDOWN
-	/* Indicates reason for reset. */
-	#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_MASK			UINT32_C(0xff00)
-	#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_SFT			8
-	/* A management client has requested reset. */
-		#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_MANAGEMENT_RESET_REQUEST  (UINT32_C(0x1) << 8)
-	/* A fatal firmware exception has occurred. */
-		#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_FW_EXCEPTION_FATAL	(UINT32_C(0x2) << 8)
-	/* A non-fatal firmware exception has occurred. */
-		#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_FW_EXCEPTION_NON_FATAL	(UINT32_C(0x3) << 8)
-	/* Fast reset */
-		#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_FAST_RESET		(UINT32_C(0x4) << 8)
-		#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_LAST			HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_FAST_RESET
+	#define RX_TPA_V2_START_CMPL_FLAGS2_COMPLETE_CHECKSUM_CALC	UINT32_C(0x200)
 	/*
-	 * Minimum time before driver should attempt access - units 100ms ticks.
-	 * Range 0-65535
+	 * The combination of this value and meta_format indicated what
+	 * format the metadata field is.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_DELAY_IN_100MS_TICKS_MASK	UINT32_C(0xffff0000)
-	#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_DELAY_IN_100MS_TICKS_SFT		16
-} hwrm_async_event_cmpl_reset_notify_t, *phwrm_async_event_cmpl_reset_notify_t;
-
-/* hwrm_async_event_cmpl_error_recovery (size:128b/16B) */
-
-typedef struct hwrm_async_event_cmpl_error_recovery {
-	uint16_t	type;
+	#define RX_TPA_V2_START_CMPL_FLAGS2_EXT_META_FORMAT_MASK	UINT32_C(0xc00)
+	#define RX_TPA_V2_START_CMPL_FLAGS2_EXT_META_FORMAT_SFT	10
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * This value is the complete 1's complement checksum calculated from
+	 * the start of the outer L3 header to the end of the packet (not
+	 * including the ethernet crc). It is valid when the
+	 * 'complete_checksum_calc' flag is set. For TPA Start completions,
+	 * the complete checksum is calculated for the first packet in the
+	 * aggregation only.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_TYPE_SFT		0
-	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_TYPE_HWRM_ASYNC_EVENT
-	/* Identifiers of events. */
-	uint16_t	event_id;
+	#define RX_TPA_V2_START_CMPL_FLAGS2_COMPLETE_CHECKSUM_MASK	UINT32_C(0xffff0000)
+	#define RX_TPA_V2_START_CMPL_FLAGS2_COMPLETE_CHECKSUM_SFT	16
 	/*
-	 * This async notification message can be used for selecting or
-	 * deselecting master function for error recovery,
-	 * and to communicate to all the functions whether error recovery
-	 * was enabled/disabled.
+	 * This is data from the CFA block as indicated by the meta_format
+	 * field.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_EVENT_ID_ERROR_RECOVERY UINT32_C(0x9)
-	#define HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_EVENT_ID_ERROR_RECOVERY
-	/* Event specific data */
-	uint32_t	event_data2;
-	uint8_t	opaque_v;
+	uint32_t	metadata;
+	/* When {ext_meta_format,meta_format}=1, this value is the VLAN VID. */
+	#define RX_TPA_V2_START_CMPL_METADATA_VID_MASK UINT32_C(0xfff)
+	#define RX_TPA_V2_START_CMPL_METADATA_VID_SFT  0
+	/* When {ext_meta_format,meta_format}=1, this value is the VLAN DE. */
+	#define RX_TPA_V2_START_CMPL_METADATA_DE	UINT32_C(0x1000)
+	/* When {ext_meta_format,meta_format}=1, this value is the VLAN PRI. */
+	#define RX_TPA_V2_START_CMPL_METADATA_PRI_MASK UINT32_C(0xe000)
+	#define RX_TPA_V2_START_CMPL_METADATA_PRI_SFT  13
+	/* When {ext_meta_format,meta_format}=1, this value is the VLAN TPID. */
+	#define RX_TPA_V2_START_CMPL_METADATA_TPID_MASK UINT32_C(0xffff0000)
+	#define RX_TPA_V2_START_CMPL_METADATA_TPID_SFT 16
+	uint16_t	errors_v2;
 	/*
 	 * This value is written by the NIC such that it will be different
 	 * for each pass through the completion queue. The even passes
 	 * will write 1. The odd passes will write 0.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_V	UINT32_C(0x1)
-	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_OPAQUE_SFT 1
-	/* 8-lsb timestamp (100-msec resolution) */
-	uint8_t	timestamp_lo;
-	/* 16-lsb timestamp (100-msec resolution) */
-	uint16_t	timestamp_hi;
-	/* Event specific data */
-	uint32_t	event_data1;
-	/* Indicates driver action requested */
-	#define HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_EVENT_DATA1_FLAGS_MASK		UINT32_C(0xff)
-	#define HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_EVENT_DATA1_FLAGS_SFT		0
+	#define RX_TPA_V2_START_CMPL_V2				UINT32_C(0x1)
+	#define RX_TPA_V2_START_CMPL_ERRORS_MASK		UINT32_C(0xfffe)
+	#define RX_TPA_V2_START_CMPL_ERRORS_SFT			1
 	/*
-	 * If set to 1, this function is selected as Master function.
-	 * This function has responsibility to do 'chip reset' when it
-	 * detects a fatal error. If set to 0, master function functionality
-	 * is disabled on this function.
+	 * This error indicates that there was some sort of problem with
+	 * the BDs for the packet that was found after part of the
+	 * packet was already placed. The packet should be treated as
+	 * invalid.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_EVENT_DATA1_FLAGS_MASTER_FUNC	UINT32_C(0x1)
+	#define RX_TPA_V2_START_CMPL_ERRORS_BUFFER_ERROR_MASK	UINT32_C(0xe)
+	#define RX_TPA_V2_START_CMPL_ERRORS_BUFFER_ERROR_SFT	1
+	/* No buffer error */
+		#define RX_TPA_V2_START_CMPL_ERRORS_BUFFER_ERROR_NO_BUFFER	(UINT32_C(0x0) << 1)
 	/*
-	 * If set to 1, error recovery is enabled.
-	 * If set to 0, error recovery is disabled.
+	 * Bad Format:
+	 * BDs were not formatted correctly.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_EVENT_DATA1_FLAGS_RECOVERY_ENABLED	UINT32_C(0x2)
-} hwrm_async_event_cmpl_error_recovery_t, *phwrm_async_event_cmpl_error_recovery_t;
-
-/* hwrm_async_event_cmpl_ring_monitor_msg (size:128b/16B) */
-
-typedef struct hwrm_async_event_cmpl_ring_monitor_msg {
-	uint16_t	type;
+		#define RX_TPA_V2_START_CMPL_ERRORS_BUFFER_ERROR_BAD_FORMAT   (UINT32_C(0x3) << 1)
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * Flush:
+	 * There was a bad_format error on the previous operation
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_TYPE_SFT		0
-	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_TYPE_HWRM_ASYNC_EVENT
-	/* Identifiers of events. */
-	uint16_t	event_id;
-	/* Ring Monitor Message. */
-	#define HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_EVENT_ID_RING_MONITOR_MSG UINT32_C(0xa)
-	#define HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_EVENT_ID_LAST		HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_EVENT_ID_RING_MONITOR_MSG
-	/* Event specific data */
-	uint32_t	event_data2;
-	/* Type of Ring disabled. */
-	#define HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_EVENT_DATA2_DISABLE_RING_TYPE_MASK UINT32_C(0xff)
-	#define HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_EVENT_DATA2_DISABLE_RING_TYPE_SFT 0
-	/* tx ring disabled. */
-		#define HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_EVENT_DATA2_DISABLE_RING_TYPE_TX	UINT32_C(0x0)
-	/* rx ring disabled. */
-		#define HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_EVENT_DATA2_DISABLE_RING_TYPE_RX	UINT32_C(0x1)
-	/* cmpl ring disabled. */
-		#define HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_EVENT_DATA2_DISABLE_RING_TYPE_CMPL  UINT32_C(0x2)
-		#define HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_EVENT_DATA2_DISABLE_RING_TYPE_LAST HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_EVENT_DATA2_DISABLE_RING_TYPE_CMPL
-	uint8_t	opaque_v;
+		#define RX_TPA_V2_START_CMPL_ERRORS_BUFFER_ERROR_FLUSH	(UINT32_C(0x5) << 1)
+		#define RX_TPA_V2_START_CMPL_ERRORS_BUFFER_ERROR_LAST	RX_TPA_V2_START_CMPL_ERRORS_BUFFER_ERROR_FLUSH
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * This field identifies the CFA action rule that was used for this
+	 * packet.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_V	UINT32_C(0x1)
-	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_OPAQUE_SFT 1
-	/* 8-lsb timestamp from POR (100-msec resolution) */
-	uint8_t	timestamp_lo;
-	/* 16-lsb timestamp from POR (100-msec resolution) */
-	uint16_t	timestamp_hi;
+	uint16_t	cfa_code;
 	/*
-	 * Event specific data. If ring_type_disabled indicates a tx,rx or cmpl
-	 * then this field will indicate the ring id.
+	 * For devices that support timestamps this field is overridden
+	 * with the timestamp value. When `flags.timestamp_fld_format` is
+	 * cleared, this field contains the 32b timestamp for the packet from the
+	 * MAC.
+	 *
+	 * When `flags.timestamp_fld_format` is set, this field contains the
+	 * outer_l3_offset, inner_l2_offset, inner_l3_offset, and inner_l4_size
+	 * as defined below.
 	 */
-	uint32_t	event_data1;
-} hwrm_async_event_cmpl_ring_monitor_msg_t, *phwrm_async_event_cmpl_ring_monitor_msg_t;
-
-/* hwrm_async_event_cmpl_func_drvr_unload (size:128b/16B) */
-
-typedef struct hwrm_async_event_cmpl_func_drvr_unload {
-	uint16_t	type;
+	uint32_t	inner_l4_size_inner_l3_offset_inner_l2_offset_outer_l3_offset;
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * This is the offset from the beginning of the packet in bytes for
+	 * the outer L3 header. If there is no outer L3 header, then this
+	 * value is zero.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_UNLOAD_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_UNLOAD_TYPE_SFT		0
-	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_UNLOAD_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_UNLOAD_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_UNLOAD_TYPE_HWRM_ASYNC_EVENT
-	/* Identifiers of events. */
-	uint16_t	event_id;
-	/* Function driver unloaded */
-	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_UNLOAD_EVENT_ID_FUNC_DRVR_UNLOAD UINT32_C(0x10)
-	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_UNLOAD_EVENT_ID_LAST		HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_UNLOAD_EVENT_ID_FUNC_DRVR_UNLOAD
-	/* Event specific data */
-	uint32_t	event_data2;
-	uint8_t	opaque_v;
+	#define RX_TPA_V2_START_CMPL_OUTER_L3_OFFSET_MASK UINT32_C(0x1ff)
+	#define RX_TPA_V2_START_CMPL_OUTER_L3_OFFSET_SFT 0
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * This is the offset from the beginning of the packet in bytes for
+	 * the inner most L2 header.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_UNLOAD_V	UINT32_C(0x1)
-	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_UNLOAD_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_UNLOAD_OPAQUE_SFT 1
-	/* 8-lsb timestamp from POR (100-msec resolution) */
-	uint8_t	timestamp_lo;
-	/* 16-lsb timestamp from POR (100-msec resolution) */
-	uint16_t	timestamp_hi;
-	/* Event specific data */
-	uint32_t	event_data1;
-	/* Function ID */
-	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_UNLOAD_EVENT_DATA1_FUNC_ID_MASK UINT32_C(0xffff)
-	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_UNLOAD_EVENT_DATA1_FUNC_ID_SFT 0
-} hwrm_async_event_cmpl_func_drvr_unload_t, *phwrm_async_event_cmpl_func_drvr_unload_t;
-
-/* hwrm_async_event_cmpl_func_drvr_load (size:128b/16B) */
-
-typedef struct hwrm_async_event_cmpl_func_drvr_load {
-	uint16_t	type;
+	#define RX_TPA_V2_START_CMPL_INNER_L2_OFFSET_MASK UINT32_C(0x3fe00)
+	#define RX_TPA_V2_START_CMPL_INNER_L2_OFFSET_SFT 9
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * This is the offset from the beginning of the packet in bytes for
+	 * the inner most L3 header.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_LOAD_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_LOAD_TYPE_SFT		0
-	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_LOAD_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_LOAD_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_LOAD_TYPE_HWRM_ASYNC_EVENT
-	/* Identifiers of events. */
-	uint16_t	event_id;
-	/* Function driver loaded */
-	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_LOAD_EVENT_ID_FUNC_DRVR_LOAD UINT32_C(0x11)
-	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_LOAD_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_LOAD_EVENT_ID_FUNC_DRVR_LOAD
-	/* Event specific data */
-	uint32_t	event_data2;
-	uint8_t	opaque_v;
+	#define RX_TPA_V2_START_CMPL_INNER_L3_OFFSET_MASK UINT32_C(0x7fc0000)
+	#define RX_TPA_V2_START_CMPL_INNER_L3_OFFSET_SFT 18
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * This is the size in bytes of the inner most L4 header.
+	 * This can be subtracted from the payload_offset to determine
+	 * the start of the inner most L4 header.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_LOAD_V	UINT32_C(0x1)
-	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_LOAD_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_LOAD_OPAQUE_SFT 1
-	/* 8-lsb timestamp from POR (100-msec resolution) */
-	uint8_t	timestamp_lo;
-	/* 16-lsb timestamp from POR (100-msec resolution) */
-	uint16_t	timestamp_hi;
-	/* Event specific data */
-	uint32_t	event_data1;
-	/* Function ID */
-	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_LOAD_EVENT_DATA1_FUNC_ID_MASK UINT32_C(0xffff)
-	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_LOAD_EVENT_DATA1_FUNC_ID_SFT 0
-} hwrm_async_event_cmpl_func_drvr_load_t, *phwrm_async_event_cmpl_func_drvr_load_t;
+	#define RX_TPA_V2_START_CMPL_INNER_L4_SIZE_MASK  UINT32_C(0xf8000000)
+	#define RX_TPA_V2_START_CMPL_INNER_L4_SIZE_SFT   27
+} rx_tpa_v2_start_cmpl_hi_t, *prx_tpa_v2_start_cmpl_hi_t;
 
-/* hwrm_async_event_cmpl_func_flr_proc_cmplt (size:128b/16B) */
+/*
+ * This TPA completion structure is used on devices where the
+ * `hwrm_vnic_qcaps.max_aggs_supported` value is greater than 0.
+ */
+/* rx_tpa_v2_end_cmpl (size:128b/16B) */
 
-typedef struct hwrm_async_event_cmpl_func_flr_proc_cmplt {
-	uint16_t	type;
+typedef struct rx_tpa_v2_end_cmpl {
+	uint16_t	flags_type;
 	/*
 	 * This field indicates the exact type of the completion.
 	 * By convention, the LSB identifies the length of the
@@ -8439,136 +9017,243 @@ typedef struct hwrm_async_event_cmpl_func_flr_proc_cmplt {
 	 * records. Odd values indicate 32B
 	 * records.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_FUNC_FLR_PROC_CMPLT_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_FUNC_FLR_PROC_CMPLT_TYPE_SFT		0
-	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_FUNC_FLR_PROC_CMPLT_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_FUNC_FLR_PROC_CMPLT_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_FUNC_FLR_PROC_CMPLT_TYPE_HWRM_ASYNC_EVENT
-	/* Identifiers of events. */
-	uint16_t	event_id;
-	/* Function FLR related processing has completed */
-	#define HWRM_ASYNC_EVENT_CMPL_FUNC_FLR_PROC_CMPLT_EVENT_ID_FUNC_FLR_PROC_CMPLT UINT32_C(0x12)
-	#define HWRM_ASYNC_EVENT_CMPL_FUNC_FLR_PROC_CMPLT_EVENT_ID_LAST		HWRM_ASYNC_EVENT_CMPL_FUNC_FLR_PROC_CMPLT_EVENT_ID_FUNC_FLR_PROC_CMPLT
-	/* Event specific data */
-	uint32_t	event_data2;
-	uint8_t	opaque_v;
-	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	#define RX_TPA_V2_END_CMPL_TYPE_MASK			UINT32_C(0x3f)
+	#define RX_TPA_V2_END_CMPL_TYPE_SFT			0
+	/*
+	 * RX L2 TPA End Completion:
+	 * Completion at the end of a TPA operation.
+	 * Length = 32B
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_FUNC_FLR_PROC_CMPLT_V	UINT32_C(0x1)
-	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_FUNC_FLR_PROC_CMPLT_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_FUNC_FLR_PROC_CMPLT_OPAQUE_SFT 1
-	/* 8-lsb timestamp from POR (100-msec resolution) */
-	uint8_t	timestamp_lo;
-	/* 16-lsb timestamp from POR (100-msec resolution) */
-	uint16_t	timestamp_hi;
-	/* Event specific data */
-	uint32_t	event_data1;
-	/* Function ID */
-	#define HWRM_ASYNC_EVENT_CMPL_FUNC_FLR_PROC_CMPLT_EVENT_DATA1_FUNC_ID_MASK UINT32_C(0xffff)
-	#define HWRM_ASYNC_EVENT_CMPL_FUNC_FLR_PROC_CMPLT_EVENT_DATA1_FUNC_ID_SFT 0
-} hwrm_async_event_cmpl_func_flr_proc_cmplt_t, *phwrm_async_event_cmpl_func_flr_proc_cmplt_t;
-
-/* hwrm_async_event_cmpl_pf_drvr_unload (size:128b/16B) */
-
-typedef struct hwrm_async_event_cmpl_pf_drvr_unload {
-	uint16_t	type;
+		#define RX_TPA_V2_END_CMPL_TYPE_RX_TPA_END		UINT32_C(0x15)
+		#define RX_TPA_V2_END_CMPL_TYPE_LAST			RX_TPA_V2_END_CMPL_TYPE_RX_TPA_END
+	#define RX_TPA_V2_END_CMPL_FLAGS_MASK			UINT32_C(0xffc0)
+	#define RX_TPA_V2_END_CMPL_FLAGS_SFT			6
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * When this bit is '1', it indicates a packet that has an
+	 * error of some type. Type of error is indicated in
+	 * error_flags.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_UNLOAD_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_UNLOAD_TYPE_SFT		0
-	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_UNLOAD_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_UNLOAD_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_PF_DRVR_UNLOAD_TYPE_HWRM_ASYNC_EVENT
-	/* Identifiers of events. */
-	uint16_t	event_id;
-	/* PF driver unloaded */
-	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_UNLOAD_EVENT_ID_PF_DRVR_UNLOAD UINT32_C(0x20)
-	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_UNLOAD_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_PF_DRVR_UNLOAD_EVENT_ID_PF_DRVR_UNLOAD
-	/* Event specific data */
-	uint32_t	event_data2;
-	uint8_t	opaque_v;
+	#define RX_TPA_V2_END_CMPL_FLAGS_ERROR			UINT32_C(0x40)
+	/* This field indicates how the packet was placed in the buffer. */
+	#define RX_TPA_V2_END_CMPL_FLAGS_PLACEMENT_MASK		UINT32_C(0x380)
+	#define RX_TPA_V2_END_CMPL_FLAGS_PLACEMENT_SFT		7
+	/*
+	 * Jumbo:
+	 * TPA Packet was placed using jumbo algorithm. This means
+	 * that the first buffer will be filled with data before
+	 * moving to aggregation buffers. Each aggregation buffer
+	 * will be filled before moving to the next aggregation
+	 * buffer.
+	 */
+		#define RX_TPA_V2_END_CMPL_FLAGS_PLACEMENT_JUMBO		(UINT32_C(0x1) << 7)
+	/*
+	 * Header/Data Separation:
+	 * Packet was placed using Header/Data separation algorithm.
+	 * The separation location is indicated by the itype field.
+	 */
+		#define RX_TPA_V2_END_CMPL_FLAGS_PLACEMENT_HDS		(UINT32_C(0x2) << 7)
+	/*
+	 * GRO/Jumbo:
+	 * Packet will be placed using GRO/Jumbo where the first
+	 * packet is filled with data. Subsequent packets will be
+	 * placed such that any one packet does not span two
+	 * aggregation buffers unless it starts at the beginning of
+	 * an aggregation buffer.
+	 */
+		#define RX_TPA_V2_END_CMPL_FLAGS_PLACEMENT_GRO_JUMBO	(UINT32_C(0x5) << 7)
+	/*
+	 * GRO/Header-Data Separation:
+	 * Packet will be placed using GRO/HDS where the header
+	 * is in the first packet.
+	 * Payload of each packet will be
+	 * placed such that any one packet does not span two
+	 * aggregation buffers unless it starts at the beginning of
+	 * an aggregation buffer.
+	 */
+		#define RX_TPA_V2_END_CMPL_FLAGS_PLACEMENT_GRO_HDS	(UINT32_C(0x6) << 7)
+	/*
+	 * IOC/Header-Data Separation:
+	 * Packet will be placed using In-Order Completion/HDS where
+	 * the header is in the first packet buffer. Payload of each
+	 * packet will be placed such that each packet starts at the
+	 * beginning of an aggregation buffer.
+	 */
+		#define RX_TPA_V2_END_CMPL_FLAGS_PLACEMENT_IOC_HDS	(UINT32_C(0x7) << 7)
+		#define RX_TPA_V2_END_CMPL_FLAGS_PLACEMENT_LAST		RX_TPA_V2_END_CMPL_FLAGS_PLACEMENT_IOC_HDS
+	/* unused is 1 b */
+	#define RX_TPA_V2_END_CMPL_FLAGS_UNUSED			UINT32_C(0x400)
+	/*
+	 * This bit is '1' if metadata has been added to the end of the
+	 * packet in host memory. Metadata starts at the first 32B boundary
+	 * after the end of the packet for regular and jumbo placement.
+	 * It starts at the first 32B boundary after the end of the header
+	 * for HDS placement. The length of the metadata is indicated in the
+	 * metadata itself.
+	 */
+	#define RX_TPA_V2_END_CMPL_FLAGS_PKT_METADATA_PRESENT	UINT32_C(0x800)
+	/*
+	 * This value indicates what the inner packet determined for the
+	 * packet was.
+	 * - 2 TCP Packet
+	 *	Indicates that the packet was IP and TCP. This indicates
+	 *	that the ip_cs field is valid and that the tcp_udp_cs
+	 *	field is valid and contains the TCP checksum.
+	 *	This also indicates that the payload_offset field is valid.
+	 */
+	#define RX_TPA_V2_END_CMPL_FLAGS_ITYPE_MASK		UINT32_C(0xf000)
+	#define RX_TPA_V2_END_CMPL_FLAGS_ITYPE_SFT		12
+	/*
+	 * This value is zero for TPA End completions.
+	 * There is no data in the buffer that corresponds to the opaque
+	 * value in this completion.
+	 */
+	uint16_t	len;
+	/*
+	 * This is a copy of the opaque field from the RX BD this completion
+	 * corresponds to.
+	 */
+	uint32_t	opaque;
+	uint8_t	v1;
 	/*
 	 * This value is written by the NIC such that it will be different
 	 * for each pass through the completion queue. The even passes
 	 * will write 1. The odd passes will write 0.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_UNLOAD_V	UINT32_C(0x1)
-	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_UNLOAD_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_UNLOAD_OPAQUE_SFT 1
-	/* 8-lsb timestamp from POR (100-msec resolution) */
-	uint8_t	timestamp_lo;
-	/* 16-lsb timestamp from POR (100-msec resolution) */
-	uint16_t	timestamp_hi;
-	/* Event specific data */
-	uint32_t	event_data1;
-	/* PF ID */
-	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_UNLOAD_EVENT_DATA1_FUNC_ID_MASK UINT32_C(0xffff)
-	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_UNLOAD_EVENT_DATA1_FUNC_ID_SFT 0
-	/* Indicates the physical port this pf belongs to */
-	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_UNLOAD_EVENT_DATA1_PORT_MASK   UINT32_C(0x70000)
-	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_UNLOAD_EVENT_DATA1_PORT_SFT	16
-} hwrm_async_event_cmpl_pf_drvr_unload_t, *phwrm_async_event_cmpl_pf_drvr_unload_t;
+	#define RX_TPA_V2_END_CMPL_V1	UINT32_C(0x1)
+	/* This value is the number of segments in the TPA operation. */
+	uint8_t	tpa_segs;
+	/*
+	 * This is the aggregation ID that the completion is associated
+	 * with. Use this number to correlate the TPA start completion
+	 * with the TPA end completion.
+	 */
+	uint16_t	agg_id;
+	/*
+	 * For non-GRO packets, this value is the
+	 * timestamp delta between earliest and latest timestamp values for
+	 * TPA packet. If packets were not time stamped, then delta will be
+	 * zero.
+	 *
+	 * For GRO packets, this field is zero except for the following
+	 * sub-fields.
+	 * - tsdelta[31]
+	 *	Timestamp present indication. When '0', no Timestamp
+	 *	option is in the packet. When '1', then a Timestamp
+	 *	option is present in the packet.
+	 */
+	uint32_t	tsdelta;
+} rx_tpa_v2_end_cmpl_t, *prx_tpa_v2_end_cmpl_t;
 
-/* hwrm_async_event_cmpl_pf_drvr_load (size:128b/16B) */
+/*
+ * Last 16 bytes of rx_tpa_v2_end_cmpl.
+ *
+ * This TPA completion structure is used on devices where the
+ * `hwrm_vnic_qcaps.max_aggs_supported` value is greater than 0.
+ */
+/* rx_tpa_v2_end_cmpl_hi (size:128b/16B) */
 
-typedef struct hwrm_async_event_cmpl_pf_drvr_load {
-	uint16_t	type;
+typedef struct rx_tpa_v2_end_cmpl_hi {
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * This value is the number of duplicate ACKs that have been
+	 * received as part of the TPA operation.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_LOAD_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_LOAD_TYPE_SFT		0
-	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_LOAD_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_LOAD_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_PF_DRVR_LOAD_TYPE_HWRM_ASYNC_EVENT
-	/* Identifiers of events. */
-	uint16_t	event_id;
-	/* PF driver loaded */
-	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_LOAD_EVENT_ID_PF_DRVR_LOAD UINT32_C(0x21)
-	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_LOAD_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_PF_DRVR_LOAD_EVENT_ID_PF_DRVR_LOAD
-	/* Event specific data */
-	uint32_t	event_data2;
-	uint8_t	opaque_v;
+	uint16_t	tpa_dup_acks;
+	/*
+	 * This value is the number of duplicate ACKs that have been
+	 * received as part of the TPA operation.
+	 */
+	#define RX_TPA_V2_END_CMPL_TPA_DUP_ACKS_MASK UINT32_C(0xf)
+	#define RX_TPA_V2_END_CMPL_TPA_DUP_ACKS_SFT 0
+	/*
+	 * This value indicated the offset in bytes from the beginning of
+	 * the packet where the inner payload starts. This value is valid
+	 * for TCP, UDP, FCoE and RoCE packets
+	 */
+	uint8_t	payload_offset;
+	/*
+	 * The value is the total number of aggregation buffers that were
+	 * used in the TPA operation. All TPA aggregation buffer completions
+	 * precede the TPA End completion. If the value is zero, then the
+	 * aggregation is completely contained in the buffer space provided
+	 * in the aggregation start completion.
+	 * Note that the field is simply provided as a cross check.
+	 */
+	uint8_t	tpa_agg_bufs;
+	/*
+	 * This value is the valid when TPA completion is active. It
+	 * indicates the length of the longest segment of the TPA operation
+	 * for LRO mode and the length of the first segment in GRO mode.
+	 *
+	 * This value may be used by GRO software to re-construct the original
+	 * packet stream from the TPA packet. This is the length of all
+	 * but the last segment for GRO. In LRO mode this value may be used
+	 * to indicate MSS size to the stack.
+	 */
+	uint16_t	tpa_seg_len;
+	uint16_t	unused_1;
+	uint16_t	errors_v2;
 	/*
 	 * This value is written by the NIC such that it will be different
 	 * for each pass through the completion queue. The even passes
 	 * will write 1. The odd passes will write 0.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_LOAD_V	UINT32_C(0x1)
-	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_LOAD_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_LOAD_OPAQUE_SFT 1
-	/* 8-lsb timestamp from POR (100-msec resolution) */
-	uint8_t	timestamp_lo;
-	/* 16-lsb timestamp from POR (100-msec resolution) */
-	uint16_t	timestamp_hi;
-	/* Event specific data */
-	uint32_t	event_data1;
-	/* PF ID */
-	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_LOAD_EVENT_DATA1_FUNC_ID_MASK UINT32_C(0xffff)
-	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_LOAD_EVENT_DATA1_FUNC_ID_SFT 0
-	/* Indicates the physical port this pf belongs to */
-	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_LOAD_EVENT_DATA1_PORT_MASK   UINT32_C(0x70000)
-	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_LOAD_EVENT_DATA1_PORT_SFT	16
-} hwrm_async_event_cmpl_pf_drvr_load_t, *phwrm_async_event_cmpl_pf_drvr_load_t;
+	#define RX_TPA_V2_END_CMPL_V2				UINT32_C(0x1)
+	#define RX_TPA_V2_END_CMPL_ERRORS_MASK			UINT32_C(0xfffe)
+	#define RX_TPA_V2_END_CMPL_ERRORS_SFT			1
+	/*
+	 * This error indicates that there was some sort of problem with
+	 * the BDs for the packet that was found after part of the
+	 * packet was already placed. The packet should be treated as
+	 * invalid.
+	 */
+	#define RX_TPA_V2_END_CMPL_ERRORS_BUFFER_ERROR_MASK	UINT32_C(0xe)
+	#define RX_TPA_V2_END_CMPL_ERRORS_BUFFER_ERROR_SFT	1
+	/* No buffer error */
+		#define RX_TPA_V2_END_CMPL_ERRORS_BUFFER_ERROR_NO_BUFFER	(UINT32_C(0x0) << 1)
+	/*
+	 * This error occurs when there is a fatal HW problem in
+	 * the chip only. It indicates that there were not
+	 * BDs on chip but that there was adequate reservation.
+	 * provided by the TPA block.
+	 */
+		#define RX_TPA_V2_END_CMPL_ERRORS_BUFFER_ERROR_NOT_ON_CHIP   (UINT32_C(0x2) << 1)
+	/*
+	 * Bad Format:
+	 * BDs were not formatted correctly.
+	 */
+		#define RX_TPA_V2_END_CMPL_ERRORS_BUFFER_ERROR_BAD_FORMAT	(UINT32_C(0x3) << 1)
+	/*
+	 * This error occurs when TPA block was not configured to
+	 * reserve adequate BDs for TPA operations on this RX
+	 * ring. All data for the TPA operation was not placed.
+	 *
+	 * This error can also be generated when the number of
+	 * segments is not programmed correctly in TPA and the
+	 * 33 total aggregation buffers allowed for the TPA
+	 * operation has been exceeded.
+	 */
+		#define RX_TPA_V2_END_CMPL_ERRORS_BUFFER_ERROR_RSV_ERROR	(UINT32_C(0x4) << 1)
+	/*
+	 * Flush:
+	 * There was a bad_format error on the previous operation
+	 */
+		#define RX_TPA_V2_END_CMPL_ERRORS_BUFFER_ERROR_FLUSH	(UINT32_C(0x5) << 1)
+		#define RX_TPA_V2_END_CMPL_ERRORS_BUFFER_ERROR_LAST	RX_TPA_V2_END_CMPL_ERRORS_BUFFER_ERROR_FLUSH
+	uint16_t	unused_2;
+	/*
+	 * This is the opaque value that was completed for the TPA start
+	 * completion that corresponds to this TPA end completion.
+	 */
+	uint32_t	start_opaque;
+} rx_tpa_v2_end_cmpl_hi_t, *prx_tpa_v2_end_cmpl_hi_t;
 
-/* hwrm_async_event_cmpl_vf_flr (size:128b/16B) */
+/*
+ * This TPA completion structure is used on devices where the
+ * `hwrm_vnic_qcaps.max_aggs_supported` value is greater than 0.
+ */
+/* rx_tpa_v2_abuf_cmpl (size:128b/16B) */
 
-typedef struct hwrm_async_event_cmpl_vf_flr {
+typedef struct rx_tpa_v2_abuf_cmpl {
 	uint16_t	type;
 	/*
 	 * This field indicates the exact type of the completion.
@@ -8577,45 +9262,48 @@ typedef struct hwrm_async_event_cmpl_vf_flr {
 	 * records. Odd values indicate 32B
 	 * records.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_VF_FLR_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_VF_FLR_TYPE_SFT		0
-	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_VF_FLR_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_VF_FLR_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_VF_FLR_TYPE_HWRM_ASYNC_EVENT
-	/* Identifiers of events. */
-	uint16_t	event_id;
-	/* VF Function Level Reset (FLR) */
-	#define HWRM_ASYNC_EVENT_CMPL_VF_FLR_EVENT_ID_VF_FLR UINT32_C(0x30)
-	#define HWRM_ASYNC_EVENT_CMPL_VF_FLR_EVENT_ID_LAST  HWRM_ASYNC_EVENT_CMPL_VF_FLR_EVENT_ID_VF_FLR
-	/* Event specific data */
-	uint32_t	event_data2;
-	uint8_t	opaque_v;
+	#define RX_TPA_V2_ABUF_CMPL_TYPE_MASK	UINT32_C(0x3f)
+	#define RX_TPA_V2_ABUF_CMPL_TYPE_SFT	0
+	/*
+	 * RX TPA Aggregation Buffer completion:
+	 * Completion of an L2 aggregation buffer in support of
+	 * TPA packet completion. Length = 16B
+	 */
+		#define RX_TPA_V2_ABUF_CMPL_TYPE_RX_TPA_AGG  UINT32_C(0x16)
+		#define RX_TPA_V2_ABUF_CMPL_TYPE_LAST	RX_TPA_V2_ABUF_CMPL_TYPE_RX_TPA_AGG
+	/*
+	 * This is the length of the data for the packet stored in this
+	 * aggregation buffer identified by the opaque value. This does not
+	 * include the length of any
+	 * data placed in other aggregation BDs or in the packet or buffer
+	 * BDs. This length does not include any space added due to
+	 * hdr_offset register during HDS placement mode.
+	 */
+	uint16_t	len;
+	/*
+	 * This is a copy of the opaque field from the RX BD this aggregation
+	 * buffer corresponds to.
+	 */
+	uint32_t	opaque;
+	uint16_t	v;
 	/*
 	 * This value is written by the NIC such that it will be different
 	 * for each pass through the completion queue. The even passes
 	 * will write 1. The odd passes will write 0.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_VF_FLR_V	UINT32_C(0x1)
-	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_VF_FLR_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_VF_FLR_OPAQUE_SFT 1
-	/* 8-lsb timestamp from POR (100-msec resolution) */
-	uint8_t	timestamp_lo;
-	/* 16-lsb timestamp from POR (100-msec resolution) */
-	uint16_t	timestamp_hi;
-	/* Event specific data */
-	uint32_t	event_data1;
-	/* VF ID */
-	#define HWRM_ASYNC_EVENT_CMPL_VF_FLR_EVENT_DATA1_VF_ID_MASK UINT32_C(0xffff)
-	#define HWRM_ASYNC_EVENT_CMPL_VF_FLR_EVENT_DATA1_VF_ID_SFT 0
-	/* Indicates the physical function this event occurred on. */
-	#define HWRM_ASYNC_EVENT_CMPL_VF_FLR_EVENT_DATA1_PF_ID_MASK UINT32_C(0xff0000)
-	#define HWRM_ASYNC_EVENT_CMPL_VF_FLR_EVENT_DATA1_PF_ID_SFT 16
-} hwrm_async_event_cmpl_vf_flr_t, *phwrm_async_event_cmpl_vf_flr_t;
+	#define RX_TPA_V2_ABUF_CMPL_V	UINT32_C(0x1)
+	/*
+	 * This is the aggregation ID that the completion is associated with. Use
+	 * this number to correlate the TPA agg completion with the TPA start
+	 * completion and the TPA end completion.
+	 */
+	uint16_t	agg_id;
+	uint32_t	unused_1;
+} rx_tpa_v2_abuf_cmpl_t, *prx_tpa_v2_abuf_cmpl_t;
 
-/* hwrm_async_event_cmpl_vf_mac_addr_change (size:128b/16B) */
+/* rx_abuf_cmpl (size:128b/16B) */
 
-typedef struct hwrm_async_event_cmpl_vf_mac_addr_change {
+typedef struct rx_abuf_cmpl {
 	uint16_t	type;
 	/*
 	 * This field indicates the exact type of the completion.
@@ -8624,43 +9312,45 @@ typedef struct hwrm_async_event_cmpl_vf_mac_addr_change {
 	 * records. Odd values indicate 32B
 	 * records.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_VF_MAC_ADDR_CHANGE_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_VF_MAC_ADDR_CHANGE_TYPE_SFT		0
-	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_VF_MAC_ADDR_CHANGE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_VF_MAC_ADDR_CHANGE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_VF_MAC_ADDR_CHANGE_TYPE_HWRM_ASYNC_EVENT
-	/* Identifiers of events. */
-	uint16_t	event_id;
-	/* VF MAC Address Change */
-	#define HWRM_ASYNC_EVENT_CMPL_VF_MAC_ADDR_CHANGE_EVENT_ID_VF_MAC_ADDR_CHANGE UINT32_C(0x31)
-	#define HWRM_ASYNC_EVENT_CMPL_VF_MAC_ADDR_CHANGE_EVENT_ID_LAST		HWRM_ASYNC_EVENT_CMPL_VF_MAC_ADDR_CHANGE_EVENT_ID_VF_MAC_ADDR_CHANGE
-	/* Event specific data */
-	uint32_t	event_data2;
-	uint8_t	opaque_v;
+	#define RX_ABUF_CMPL_TYPE_MASK  UINT32_C(0x3f)
+	#define RX_ABUF_CMPL_TYPE_SFT   0
+	/*
+	 * RX Aggregation Buffer completion:
+	 * Completion of an L2 aggregation buffer in support of
+	 * TPA, HDS, or Jumbo packet completion. Length = 16B
+	 */
+		#define RX_ABUF_CMPL_TYPE_RX_AGG  UINT32_C(0x12)
+		#define RX_ABUF_CMPL_TYPE_LAST   RX_ABUF_CMPL_TYPE_RX_AGG
+	/*
+	 * This is the length of the data for the packet stored in this
+	 * aggregation buffer identified by the opaque value. This does not
+	 * include the length of any
+	 * data placed in other aggregation BDs or in the packet or buffer
+	 * BDs. This length does not include any space added due to
+	 * hdr_offset register during HDS placement mode.
+	 */
+	uint16_t	len;
+	/*
+	 * This is a copy of the opaque field from the RX BD this aggregation
+	 * buffer corresponds to.
+	 */
+	uint32_t	opaque;
+	uint32_t	v;
 	/*
 	 * This value is written by the NIC such that it will be different
 	 * for each pass through the completion queue. The even passes
 	 * will write 1. The odd passes will write 0.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_VF_MAC_ADDR_CHANGE_V	UINT32_C(0x1)
-	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_VF_MAC_ADDR_CHANGE_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_VF_MAC_ADDR_CHANGE_OPAQUE_SFT 1
-	/* 8-lsb timestamp from POR (100-msec resolution) */
-	uint8_t	timestamp_lo;
-	/* 16-lsb timestamp from POR (100-msec resolution) */
-	uint16_t	timestamp_hi;
-	/* Event specific data */
-	uint32_t	event_data1;
-	/* VF ID */
-	#define HWRM_ASYNC_EVENT_CMPL_VF_MAC_ADDR_CHANGE_EVENT_DATA1_VF_ID_MASK UINT32_C(0xffff)
-	#define HWRM_ASYNC_EVENT_CMPL_VF_MAC_ADDR_CHANGE_EVENT_DATA1_VF_ID_SFT 0
-} hwrm_async_event_cmpl_vf_mac_addr_change_t, *phwrm_async_event_cmpl_vf_mac_addr_change_t;
+	#define RX_ABUF_CMPL_V	UINT32_C(0x1)
+	/* unused3 is 32 b */
+	uint32_t	unused_2;
+} rx_abuf_cmpl_t, *prx_abuf_cmpl_t;
 
-/* hwrm_async_event_cmpl_pf_vf_comm_status_change (size:128b/16B) */
+/* VEE FLUSH Completion Record (16 bytes) */
+/* vee_flush (size:128b/16B) */
 
-typedef struct hwrm_async_event_cmpl_pf_vf_comm_status_change {
-	uint16_t	type;
+typedef struct vee_flush {
+	uint32_t	downstream_path_type;
 	/*
 	 * This field indicates the exact type of the completion.
 	 * By convention, the LSB identifies the length of the
@@ -8668,46 +9358,44 @@ typedef struct hwrm_async_event_cmpl_pf_vf_comm_status_change {
 	 * records. Odd values indicate 32B
 	 * records.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_PF_VF_COMM_STATUS_CHANGE_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_PF_VF_COMM_STATUS_CHANGE_TYPE_SFT		0
-	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_PF_VF_COMM_STATUS_CHANGE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_PF_VF_COMM_STATUS_CHANGE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_PF_VF_COMM_STATUS_CHANGE_TYPE_HWRM_ASYNC_EVENT
-	/* Identifiers of events. */
-	uint16_t	event_id;
-	/* PF-VF communication channel status change. */
-	#define HWRM_ASYNC_EVENT_CMPL_PF_VF_COMM_STATUS_CHANGE_EVENT_ID_PF_VF_COMM_STATUS_CHANGE UINT32_C(0x32)
-	#define HWRM_ASYNC_EVENT_CMPL_PF_VF_COMM_STATUS_CHANGE_EVENT_ID_LAST			HWRM_ASYNC_EVENT_CMPL_PF_VF_COMM_STATUS_CHANGE_EVENT_ID_PF_VF_COMM_STATUS_CHANGE
-	/* Event specific data */
-	uint32_t	event_data2;
-	uint8_t	opaque_v;
+	#define VEE_FLUSH_TYPE_MASK	UINT32_C(0x3f)
+	#define VEE_FLUSH_TYPE_SFT		0
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * VEE Flush Completion:
+	 * This completion is inserted manually by the Primate and processed
+	 * by the VEE hardware to ensure that all completions on a VEE
+	 * function have been processed by the VEE hardware before FLR
+	 * process is completed.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_PF_VF_COMM_STATUS_CHANGE_V	UINT32_C(0x1)
-	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_PF_VF_COMM_STATUS_CHANGE_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_PF_VF_COMM_STATUS_CHANGE_OPAQUE_SFT 1
-	/* 8-lsb timestamp from POR (100-msec resolution) */
-	uint8_t	timestamp_lo;
-	/* 16-lsb timestamp from POR (100-msec resolution) */
-	uint16_t	timestamp_hi;
-	/* Event specific data */
-	uint32_t	event_data1;
+		#define VEE_FLUSH_TYPE_VEE_FLUSH	UINT32_C(0x1c)
+		#define VEE_FLUSH_TYPE_LAST		VEE_FLUSH_TYPE_VEE_FLUSH
+	/* downstream_path is 1 b */
+	#define VEE_FLUSH_DOWNSTREAM_PATH	UINT32_C(0x40)
+	/* This completion is associated with VEE Transmit */
+		#define VEE_FLUSH_DOWNSTREAM_PATH_TX	(UINT32_C(0x0) << 6)
+	/* This completion is associated with VEE Receive */
+		#define VEE_FLUSH_DOWNSTREAM_PATH_RX	(UINT32_C(0x1) << 6)
+		#define VEE_FLUSH_DOWNSTREAM_PATH_LAST VEE_FLUSH_DOWNSTREAM_PATH_RX
 	/*
-	 * If this bit is set to 1, then it indicates that the PF-VF
-	 * communication was lost and it is established.
-	 * If this bit set to 0, then it indicates that the PF-VF
-	 * communication was established and it is lost.
+	 * This is an opaque value that is passed through the completion
+	 * to the VEE handler SW and is used to indicate what VEE VQ or
+	 * function has completed FLR processing.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_PF_VF_COMM_STATUS_CHANGE_EVENT_DATA1_COMM_ESTABLISHED	UINT32_C(0x1)
-} hwrm_async_event_cmpl_pf_vf_comm_status_change_t, *phwrm_async_event_cmpl_pf_vf_comm_status_change_t;
+	uint32_t	opaque;
+	uint32_t	v;
+	/*
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes will
+	 * write 1. The odd passes will write 0.
+	 */
+	#define VEE_FLUSH_V	UINT32_C(0x1)
+	/* unused3 is 32 b */
+	uint32_t	unused_3;
+} vee_flush_t, *pvee_flush_t;
 
-/* hwrm_async_event_cmpl_vf_cfg_change (size:128b/16B) */
+/* eject_cmpl (size:128b/16B) */
 
-typedef struct hwrm_async_event_cmpl_vf_cfg_change {
+typedef struct eject_cmpl {
 	uint16_t	type;
 	/*
 	 * This field indicates the exact type of the completion.
@@ -8716,84 +9404,76 @@ typedef struct hwrm_async_event_cmpl_vf_cfg_change {
 	 * records. Odd values indicate 32B
 	 * records.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_TYPE_SFT		0
-	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_TYPE_HWRM_ASYNC_EVENT
-	/* Identifiers of events. */
-	uint16_t	event_id;
-	/* VF Configuration Change */
-	#define HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_EVENT_ID_VF_CFG_CHANGE UINT32_C(0x33)
-	#define HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_EVENT_ID_VF_CFG_CHANGE
-	/* Event specific data */
-	uint32_t	event_data2;
+	#define EJECT_CMPL_TYPE_MASK	UINT32_C(0x3f)
+	#define EJECT_CMPL_TYPE_SFT	0
 	/*
-	 * This value indicates the VF ID of the VF whose configuration
-	 * is changing if this async. event is sent to the parent PF.
-	 * The firmware supports sending this to the parent PF if the
-	 * `hwrm_func_qcaps.vf_cfg_async_for_pf_supported` value is 1.
-	 * This value is undefined when the async. event is sent to the
-	 * VF.
+	 * Statistics Ejection Completion:
+	 * Completion of statistics data ejection buffer.
+	 * Length = 16B
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_EVENT_DATA2_VF_ID_MASK UINT32_C(0xffff)
-	#define HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_EVENT_DATA2_VF_ID_SFT 0
-	uint8_t	opaque_v;
+		#define EJECT_CMPL_TYPE_STAT_EJECT   UINT32_C(0x1a)
+		#define EJECT_CMPL_TYPE_LAST	EJECT_CMPL_TYPE_STAT_EJECT
+	#define EJECT_CMPL_FLAGS_MASK	UINT32_C(0xffc0)
+	#define EJECT_CMPL_FLAGS_SFT	6
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * When this bit is '1', it indicates a packet that has an
+	 * error of some type. Type of error is indicated in
+	 * error_flags.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_V	UINT32_C(0x1)
-	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_OPAQUE_SFT 1
-	/* 8-lsb timestamp from POR (100-msec resolution) */
-	uint8_t	timestamp_lo;
-	/* 16-lsb timestamp from POR (100-msec resolution) */
-	uint16_t	timestamp_hi;
+	#define EJECT_CMPL_FLAGS_ERROR	UINT32_C(0x40)
 	/*
-	 * Each flag provided in this field indicates a specific VF
-	 * configuration change. At least one of these flags shall be set to 1
-	 * when an asynchronous event completion of this type is provided
-	 * by the HWRM.
+	 * This is the length of the statistics data stored in this
+	 * buffer.
 	 */
-	uint32_t	event_data1;
+	uint16_t	len;
 	/*
-	 * If this bit is set to 1, then the value of MTU
-	 * was changed on this VF.
-	 * If set to 0, then this bit should be ignored.
+	 * This is a copy of the opaque field from the RX BD this ejection
+	 * buffer corresponds to.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_EVENT_DATA1_MTU_CHANGE		UINT32_C(0x1)
+	uint32_t	opaque;
+	uint16_t	v;
 	/*
-	 * If this bit is set to 1, then the value of MRU
-	 * was changed on this VF.
-	 * If set to 0, then this bit should be ignored.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_EVENT_DATA1_MRU_CHANGE		UINT32_C(0x2)
+	#define EJECT_CMPL_V				UINT32_C(0x1)
+	#define EJECT_CMPL_ERRORS_MASK			UINT32_C(0xfffe)
+	#define EJECT_CMPL_ERRORS_SFT			1
 	/*
-	 * If this bit is set to 1, then the value of default MAC
-	 * address was changed on this VF.
-	 * If set to 0, then this bit should be ignored.
+	 * This error indicates that there was some sort of problem with
+	 * the BDs for statistics ejection. The statistics ejection should
+	 * be treated as invalid
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_EVENT_DATA1_DFLT_MAC_ADDR_CHANGE	UINT32_C(0x4)
+	#define EJECT_CMPL_ERRORS_BUFFER_ERROR_MASK	UINT32_C(0xe)
+	#define EJECT_CMPL_ERRORS_BUFFER_ERROR_SFT	1
+	/* No buffer error */
+		#define EJECT_CMPL_ERRORS_BUFFER_ERROR_NO_BUFFER	(UINT32_C(0x0) << 1)
 	/*
-	 * If this bit is set to 1, then the value of default VLAN
-	 * was changed on this VF.
-	 * If set to 0, then this bit should be ignored.
+	 * Did Not Fit:
+	 * Statistics did not fit into aggregation buffer provided.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_EVENT_DATA1_DFLT_VLAN_CHANGE	UINT32_C(0x8)
+		#define EJECT_CMPL_ERRORS_BUFFER_ERROR_DID_NOT_FIT   (UINT32_C(0x1) << 1)
 	/*
-	 * If this bit is set to 1, then the value of trusted VF enable
-	 * was changed on this VF.
-	 * If set to 0, then this bit should be ignored.
+	 * Bad Format:
+	 * BDs were not formatted correctly.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_EVENT_DATA1_TRUSTED_VF_CFG_CHANGE	UINT32_C(0x10)
-} hwrm_async_event_cmpl_vf_cfg_change_t, *phwrm_async_event_cmpl_vf_cfg_change_t;
+		#define EJECT_CMPL_ERRORS_BUFFER_ERROR_BAD_FORMAT	(UINT32_C(0x3) << 1)
+	/*
+	 * Flush:
+	 * There was a bad_format error on the previous operation
+	 */
+		#define EJECT_CMPL_ERRORS_BUFFER_ERROR_FLUSH	(UINT32_C(0x5) << 1)
+		#define EJECT_CMPL_ERRORS_BUFFER_ERROR_LAST	EJECT_CMPL_ERRORS_BUFFER_ERROR_FLUSH
+	/* reserved16 is 16 b */
+	uint16_t	reserved16;
+	/* unused3 is 32 b */
+	uint32_t	unused_2;
+} eject_cmpl_t, *peject_cmpl_t;
 
-/* hwrm_async_event_cmpl_llfc_pfc_change (size:128b/16B) */
+/* hwrm_cmpl (size:128b/16B) */
 
-typedef struct hwrm_async_event_cmpl_llfc_pfc_change {
+typedef struct hwrm_cmpl {
 	uint16_t	type;
 	/*
 	 * This field indicates the exact type of the completion.
@@ -8802,63 +9482,32 @@ typedef struct hwrm_async_event_cmpl_llfc_pfc_change {
 	 * records. Odd values indicate 32B
 	 * records.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_TYPE_SFT		0
-	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_TYPE_HWRM_ASYNC_EVENT
-	/* unused1 is 10 b */
-	#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_UNUSED1_MASK	UINT32_C(0xffc0)
-	#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_UNUSED1_SFT	6
-	/* Identifiers of events. */
-	uint16_t	event_id;
-	/* LLFC/PFC Configuration Change */
-	#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_EVENT_ID_LLFC_PFC_CHANGE UINT32_C(0x34)
-	#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_EVENT_ID_LLFC_PFC_CHANGE
-	/* Event specific data */
-	uint32_t	event_data2;
-	uint8_t	opaque_v;
+	#define HWRM_CMPL_TYPE_MASK	UINT32_C(0x3f)
+	#define HWRM_CMPL_TYPE_SFT	0
+	/*
+	 * HWRM Command Completion:
+	 * Completion of an HWRM command.
+	 */
+		#define HWRM_CMPL_TYPE_HWRM_DONE  UINT32_C(0x20)
+		#define HWRM_CMPL_TYPE_LAST	HWRM_CMPL_TYPE_HWRM_DONE
+	/* This is the sequence_id of the HWRM command that has completed. */
+	uint16_t	sequence_id;
+	/* unused2 is 32 b */
+	uint32_t	unused_1;
+	uint32_t	v;
 	/*
 	 * This value is written by the NIC such that it will be different
 	 * for each pass through the completion queue. The even passes
 	 * will write 1. The odd passes will write 0.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_V	UINT32_C(0x1)
-	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_OPAQUE_SFT 1
-	/* 8-lsb timestamp from POR (100-msec resolution) */
-	uint8_t	timestamp_lo;
-	/* 16-lsb timestamp from POR (100-msec resolution) */
-	uint16_t	timestamp_hi;
-	/* Event specific data */
-	uint32_t	event_data1;
-	/* Indicates llfc pfc status change */
-	#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_EVENT_DATA1_LLFC_PFC_MASK UINT32_C(0x3)
-	#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_EVENT_DATA1_LLFC_PFC_SFT 0
-	/*
-	 * If this field set to 1, then it indicates that llfc is
-	 * enabled.
-	 */
-		#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_EVENT_DATA1_LLFC_PFC_LLFC  UINT32_C(0x1)
-	/*
-	 * If this field is set to 2, then it indicates that pfc
-	 * is enabled.
-	 */
-		#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_EVENT_DATA1_LLFC_PFC_PFC   UINT32_C(0x2)
-		#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_EVENT_DATA1_LLFC_PFC_LAST HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_EVENT_DATA1_LLFC_PFC_PFC
-	/* Indicates the physical port this llfc pfc change occur */
-	#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_EVENT_DATA1_PORT_MASK	UINT32_C(0x1c)
-	#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_EVENT_DATA1_PORT_SFT	2
-	/* PORT ID */
-	#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_EVENT_DATA1_PORT_ID_MASK UINT32_C(0x1fffe0)
-	#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_EVENT_DATA1_PORT_ID_SFT  5
-} hwrm_async_event_cmpl_llfc_pfc_change_t, *phwrm_async_event_cmpl_llfc_pfc_change_t;
+	#define HWRM_CMPL_V	UINT32_C(0x1)
+	/* unused4 is 32 b */
+	uint32_t	unused_3;
+} hwrm_cmpl_t, *phwrm_cmpl_t;
 
-/* hwrm_async_event_cmpl_default_vnic_change (size:128b/16B) */
+/* hwrm_fwd_req_cmpl (size:128b/16B) */
 
-typedef struct hwrm_async_event_cmpl_default_vnic_change {
-	uint16_t	type;
+typedef struct hwrm_fwd_req_cmpl {
 	/*
 	 * This field indicates the exact type of the completion.
 	 * By convention, the LSB identifies the length of the
@@ -8866,63 +9515,7 @@ typedef struct hwrm_async_event_cmpl_default_vnic_change {
 	 * records. Odd values indicate 32B
 	 * records.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_TYPE_SFT		0
-	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_TYPE_HWRM_ASYNC_EVENT
-	/* unused1 is 10 b */
-	#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_UNUSED1_MASK	UINT32_C(0xffc0)
-	#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_UNUSED1_SFT	6
-	/* Identifiers of events. */
-	uint16_t	event_id;
-	/* Notification of a default vnic allocation or free */
-	#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_EVENT_ID_ALLOC_FREE_NOTIFICATION UINT32_C(0x35)
-	#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_EVENT_ID_LAST		HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_EVENT_ID_ALLOC_FREE_NOTIFICATION
-	/* Event specific data */
-	uint32_t	event_data2;
-	uint8_t	opaque_v;
-	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
-	 */
-	#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_V	UINT32_C(0x1)
-	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_OPAQUE_SFT 1
-	/* 8-lsb timestamp from POR (100-msec resolution) */
-	uint8_t	timestamp_lo;
-	/* 16-lsb timestamp from POR (100-msec resolution) */
-	uint16_t	timestamp_hi;
-	/* Event specific data */
-	uint32_t	event_data1;
-	/* Indicates default vnic configuration change */
-	#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_EVENT_DATA1_DEF_VNIC_STATE_MASK	UINT32_C(0x3)
-	#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_EVENT_DATA1_DEF_VNIC_STATE_SFT	0
-	/*
-	 * If this field is set to 1, then it indicates that
-	 * a default VNIC has been allocate.
-	 */
-		#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_EVENT_DATA1_DEF_VNIC_STATE_DEF_VNIC_ALLOC  UINT32_C(0x1)
-	/*
-	 * If this field is set to 2, then it indicates that
-	 * a default VNIC has been freed.
-	 */
-		#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_EVENT_DATA1_DEF_VNIC_STATE_DEF_VNIC_FREE   UINT32_C(0x2)
-		#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_EVENT_DATA1_DEF_VNIC_STATE_LAST	HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_EVENT_DATA1_DEF_VNIC_STATE_DEF_VNIC_FREE
-	/* Indicates the physical function this event occurred on. */
-	#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_EVENT_DATA1_PF_ID_MASK		UINT32_C(0x3fc)
-	#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_EVENT_DATA1_PF_ID_SFT			2
-	/* Indicates the virtual function this event occurred on */
-	#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_EVENT_DATA1_VF_ID_MASK		UINT32_C(0x3fffc00)
-	#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_EVENT_DATA1_VF_ID_SFT			10
-} hwrm_async_event_cmpl_default_vnic_change_t, *phwrm_async_event_cmpl_default_vnic_change_t;
-
-/* hwrm_async_event_cmpl_hw_flow_aged (size:128b/16B) */
-
-typedef struct hwrm_async_event_cmpl_hw_flow_aged {
-	uint16_t	type;
+	uint16_t	req_len_type;
 	/*
 	 * This field indicates the exact type of the completion.
 	 * By convention, the LSB identifies the length of the
@@ -8930,55 +9523,40 @@ typedef struct hwrm_async_event_cmpl_hw_flow_aged {
 	 * records. Odd values indicate 32B
 	 * records.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_TYPE_SFT		0
-	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_TYPE_HWRM_ASYNC_EVENT
-	/* Identifiers of events. */
-	uint16_t	event_id;
-	/* Notification of a hw flow aged */
-	#define HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_EVENT_ID_HW_FLOW_AGED UINT32_C(0x36)
-	#define HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_EVENT_ID_HW_FLOW_AGED
-	/* Event specific data */
-	uint32_t	event_data2;
-	uint8_t	opaque_v;
+	#define HWRM_FWD_REQ_CMPL_TYPE_MASK	UINT32_C(0x3f)
+	#define HWRM_FWD_REQ_CMPL_TYPE_SFT	0
+	/* Forwarded HWRM Request */
+		#define HWRM_FWD_REQ_CMPL_TYPE_HWRM_FWD_REQ  UINT32_C(0x22)
+		#define HWRM_FWD_REQ_CMPL_TYPE_LAST	HWRM_FWD_REQ_CMPL_TYPE_HWRM_FWD_REQ
+	/* Length of forwarded request in bytes. */
+	#define HWRM_FWD_REQ_CMPL_REQ_LEN_MASK	UINT32_C(0xffc0)
+	#define HWRM_FWD_REQ_CMPL_REQ_LEN_SFT	6
+	/*
+	 * Source ID of this request.
+	 * Typically used in forwarding requests and responses.
+	 * 0x0 - 0xFFF8 - Used for function ids
+	 * 0xFFF8 - 0xFFFE - Reserved for internal processors
+	 * 0xFFFF - HWRM
+	 */
+	uint16_t	source_id;
+	/* unused1 is 32 b */
+	uint32_t	unused0;
+	/* Address of forwarded request. */
+	uint64_t	req_buf_addr_v;
 	/*
 	 * This value is written by the NIC such that it will be different
 	 * for each pass through the completion queue. The even passes
 	 * will write 1. The odd passes will write 0.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_V	UINT32_C(0x1)
-	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_OPAQUE_SFT 1
-	/* 8-lsb timestamp from POR (100-msec resolution) */
-	uint8_t	timestamp_lo;
-	/* 16-lsb timestamp from POR (100-msec resolution) */
-	uint16_t	timestamp_hi;
-	/* Event specific data */
-	uint32_t	event_data1;
-	/* Indicates flow ID this event occurred on. */
-	#define HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_EVENT_DATA1_FLOW_ID_MASK	UINT32_C(0x7fffffff)
-	#define HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_EVENT_DATA1_FLOW_ID_SFT	0
-	/* Indicates flow direction this event occurred on. */
-	#define HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_EVENT_DATA1_FLOW_DIRECTION	UINT32_C(0x80000000)
-	/*
-	 * If this bit set to 0, then it indicates that the aged
-	 * event was rx flow.
-	 */
-		#define HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_EVENT_DATA1_FLOW_DIRECTION_RX	(UINT32_C(0x0) << 31)
-	/*
-	 * If this bit is set to 1, then it indicates that the aged
-	 * event was tx flow.
-	 */
-		#define HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_EVENT_DATA1_FLOW_DIRECTION_TX	(UINT32_C(0x1) << 31)
-		#define HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_EVENT_DATA1_FLOW_DIRECTION_LAST HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_EVENT_DATA1_FLOW_DIRECTION_TX
-} hwrm_async_event_cmpl_hw_flow_aged_t, *phwrm_async_event_cmpl_hw_flow_aged_t;
+	#define HWRM_FWD_REQ_CMPL_V		UINT32_C(0x1)
+	/* Address of forwarded request. */
+	#define HWRM_FWD_REQ_CMPL_REQ_BUF_ADDR_MASK UINT32_C(0xfffffffe)
+	#define HWRM_FWD_REQ_CMPL_REQ_BUF_ADDR_SFT 1
+} hwrm_fwd_req_cmpl_t, *phwrm_fwd_req_cmpl_t;
 
-/* hwrm_async_event_cmpl_eem_cache_flush_req (size:128b/16B) */
+/* hwrm_fwd_resp_cmpl (size:128b/16B) */
 
-typedef struct hwrm_async_event_cmpl_eem_cache_flush_req {
+typedef struct hwrm_fwd_resp_cmpl {
 	uint16_t	type;
 	/*
 	 * This field indicates the exact type of the completion.
@@ -8987,39 +9565,39 @@ typedef struct hwrm_async_event_cmpl_eem_cache_flush_req {
 	 * records. Odd values indicate 32B
 	 * records.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_REQ_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_REQ_TYPE_SFT		0
-	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_REQ_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_REQ_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_REQ_TYPE_HWRM_ASYNC_EVENT
-	/* Identifiers of events. */
-	uint16_t	event_id;
-	/* Notification of a eem_cache_flush request */
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_REQ_EVENT_ID_EEM_CACHE_FLUSH_REQ UINT32_C(0x38)
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_REQ_EVENT_ID_LAST		HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_REQ_EVENT_ID_EEM_CACHE_FLUSH_REQ
-	/* Event specific data */
-	uint32_t	event_data2;
-	uint8_t	opaque_v;
+	#define HWRM_FWD_RESP_CMPL_TYPE_MASK	UINT32_C(0x3f)
+	#define HWRM_FWD_RESP_CMPL_TYPE_SFT	0
+	/* Forwarded HWRM Response */
+		#define HWRM_FWD_RESP_CMPL_TYPE_HWRM_FWD_RESP  UINT32_C(0x24)
+		#define HWRM_FWD_RESP_CMPL_TYPE_LAST	HWRM_FWD_RESP_CMPL_TYPE_HWRM_FWD_RESP
+	/*
+	 * Source ID of this response.
+	 * Typically used in forwarding requests and responses.
+	 * 0x0 - 0xFFF8 - Used for function ids
+	 * 0xFFF8 - 0xFFFE - Reserved for internal processors
+	 * 0xFFFF - HWRM
+	 */
+	uint16_t	source_id;
+	/* Length of forwarded response in bytes. */
+	uint16_t	resp_len;
+	/* unused2 is 16 b */
+	uint16_t	unused_1;
+	/* Address of forwarded request. */
+	uint64_t	resp_buf_addr_v;
 	/*
 	 * This value is written by the NIC such that it will be different
 	 * for each pass through the completion queue. The even passes
 	 * will write 1. The odd passes will write 0.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_REQ_V	UINT32_C(0x1)
-	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_REQ_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_REQ_OPAQUE_SFT 1
-	/* 8-lsb timestamp from POR (100-msec resolution) */
-	uint8_t	timestamp_lo;
-	/* 16-lsb timestamp from POR (100-msec resolution) */
-	uint16_t	timestamp_hi;
-	/* Event specific data */
-	uint32_t	event_data1;
-} hwrm_async_event_cmpl_eem_cache_flush_req_t, *phwrm_async_event_cmpl_eem_cache_flush_req_t;
+	#define HWRM_FWD_RESP_CMPL_V		UINT32_C(0x1)
+	/* Address of forwarded request. */
+	#define HWRM_FWD_RESP_CMPL_RESP_BUF_ADDR_MASK UINT32_C(0xfffffffe)
+	#define HWRM_FWD_RESP_CMPL_RESP_BUF_ADDR_SFT 1
+} hwrm_fwd_resp_cmpl_t, *phwrm_fwd_resp_cmpl_t;
 
-/* hwrm_async_event_cmpl_eem_cache_flush_done (size:128b/16B) */
+/* hwrm_async_event_cmpl (size:128b/16B) */
 
-typedef struct hwrm_async_event_cmpl_eem_cache_flush_done {
+typedef struct hwrm_async_event_cmpl {
 	uint16_t	type;
 	/*
 	 * This field indicates the exact type of the completion.
@@ -9028,19 +9606,202 @@ typedef struct hwrm_async_event_cmpl_eem_cache_flush_done {
 	 * records. Odd values indicate 32B
 	 * records.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_DONE_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_DONE_TYPE_SFT		0
+	#define HWRM_ASYNC_EVENT_CMPL_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_TYPE_SFT		0
 	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_DONE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_DONE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_DONE_TYPE_HWRM_ASYNC_EVENT
+		#define HWRM_ASYNC_EVENT_CMPL_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_TYPE_HWRM_ASYNC_EVENT
 	/* Identifiers of events. */
 	uint16_t	event_id;
+	/* Link status changed */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE		UINT32_C(0x0)
+	/* Link MTU changed */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_MTU_CHANGE		UINT32_C(0x1)
+	/* Link speed changed */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CHANGE		UINT32_C(0x2)
+	/* DCB Configuration changed */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_DCB_CONFIG_CHANGE		UINT32_C(0x3)
+	/* Port connection not allowed */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PORT_CONN_NOT_ALLOWED	UINT32_C(0x4)
+	/* Link speed configuration was not allowed */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CFG_NOT_ALLOWED	UINT32_C(0x5)
+	/* Link speed configuration change */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE	UINT32_C(0x6)
+	/* Port PHY configuration change */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PORT_PHY_CFG_CHANGE		UINT32_C(0x7)
+	/* Reset notification to clients */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_RESET_NOTIFY			UINT32_C(0x8)
+	/* Master function selection event */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_ERROR_RECOVERY		UINT32_C(0x9)
 	/*
-	 * Notification of a host eem_cache_flush has completed. This event
-	 * is generated by the host driver.
+	 * An event signifying that a ring has been disabled by
+	 * hw due to error.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_DONE_EVENT_ID_EEM_CACHE_FLUSH_DONE UINT32_C(0x39)
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_DONE_EVENT_ID_LAST		HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_DONE_EVENT_ID_EEM_CACHE_FLUSH_DONE
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_RING_MONITOR_MSG		UINT32_C(0xa)
+	/* Function driver unloaded */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_FUNC_DRVR_UNLOAD		UINT32_C(0x10)
+	/* Function driver loaded */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_FUNC_DRVR_LOAD		UINT32_C(0x11)
+	/* Function FLR related processing has completed */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_FUNC_FLR_PROC_CMPLT		UINT32_C(0x12)
+	/* PF driver unloaded */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_DRVR_UNLOAD		UINT32_C(0x20)
+	/* PF driver loaded */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_DRVR_LOAD			UINT32_C(0x21)
+	/* VF Function Level Reset (FLR) */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_VF_FLR			UINT32_C(0x30)
+	/* VF MAC Address Change */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_VF_MAC_ADDR_CHANGE		UINT32_C(0x31)
+	/* PF-VF communication channel status change. */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_VF_COMM_STATUS_CHANGE	UINT32_C(0x32)
+	/* VF Configuration Change */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_VF_CFG_CHANGE		UINT32_C(0x33)
+	/* LLFC/PFC Configuration Change */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LLFC_PFC_CHANGE		UINT32_C(0x34)
+	/* Default VNIC Configuration Change */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_DEFAULT_VNIC_CHANGE		UINT32_C(0x35)
+	/* HW flow aged */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_HW_FLOW_AGED			UINT32_C(0x36)
+	/*
+	 * A debug notification being posted to the driver. These
+	 * notifications are purely for diagnostic purpose and should not be
+	 * used for functional purpose. The driver is not supposed to act
+	 * on these messages except to log/record it.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_DEBUG_NOTIFICATION		UINT32_C(0x37)
+	/*
+	 * An EEM flow cached memory flush for all flows request event being
+	 * posted to the PF driver.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_EEM_CACHE_FLUSH_REQ		UINT32_C(0x38)
+	/*
+	 * An EEM flow cache memory flush completion event being posted to the
+	 * firmware by the PF driver. This is indication that host EEM flush
+	 * has completed by the PF.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_EEM_CACHE_FLUSH_DONE		UINT32_C(0x39)
+	/*
+	 * A tcp flag action change event being posted to the PF or trusted VF
+	 * driver by the firmware. The PF or trusted VF driver should query
+	 * the firmware for the new TCP flag action update after receiving
+	 * this async event.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_TCP_FLAG_ACTION_CHANGE	UINT32_C(0x3a)
+	/*
+	 * An EEM flow active event being posted to the PF or trusted VF driver
+	 * by the firmware. The PF or trusted VF driver should update the
+	 * flow's aging timer after receiving this async event.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_EEM_FLOW_ACTIVE		UINT32_C(0x3b)
+	/*
+	 * A eem cfg change event being posted to the trusted VF driver by the
+	 * firmware if the parent PF EEM configuration changed.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_EEM_CFG_CHANGE		UINT32_C(0x3c)
+	/*
+	 * Deprecated.
+	 * TFLIB unique default VNIC Configuration Change
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_TFLIB_DEFAULT_VNIC_CHANGE	UINT32_C(0x3d)
+	/*
+	 * Deprecated.
+	 * TFLIB unique link status changed
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_TFLIB_LINK_STATUS_CHANGE	UINT32_C(0x3e)
+	/*
+	 * An event signifying completion for HWRM_FW_STATE_QUIESCE
+	 * (completion, timeout, or error)
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_QUIESCE_DONE			UINT32_C(0x3f)
+	/*
+	 * An event signifying a HWRM command is in progress and its
+	 * response will be deferred. This event is used on crypto controllers
+	 * only.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_DEFERRED_RESPONSE		UINT32_C(0x40)
+	/*
+	 * An event signifying that a PFC WatchDog configuration
+	 * has changed on any port / cos.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PFC_WATCHDOG_CFG_CHANGE	UINT32_C(0x41)
+	/*
+	 * An echo request from the firmware. An echo response is expected by
+	 * the firmware.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_ECHO_REQUEST			UINT32_C(0x42)
+	/*
+	 * An event from firmware indicating who has been selected as the
+	 * PHC Master or secondary. Also indicates the last time a failover
+	 * happens. Event will also be sent when PHC rolls over.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PHC_UPDATE			UINT32_C(0x43)
+	/*
+	 * An event from firmware showing the last PPS timestamp that has been
+	 * latched.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PPS_TIMESTAMP		UINT32_C(0x44)
+	/*
+	 * An event from firmware indicating that an error has occurred.
+	 * The driver should log the event so that an administrator can be
+	 * aware that a problem has occurred that may need attention.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_ERROR_REPORT			UINT32_C(0x45)
+	/*
+	 * An event from firmware indicating that the programmed pacing
+	 * threshold for the doorbell global FIFO has been crossed. The driver
+	 * needs to take appropriate action to pace the doorbells when this
+	 * event is received from the firmware.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_DOORBELL_PACING_THRESHOLD	UINT32_C(0x46)
+	/*
+	 * An event from firmware indicating that the RSS capabilities have
+	 * changed.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_RSS_CHANGE			UINT32_C(0x47)
+	/*
+	 * An event from firmware indicating that list of nq ids used for
+	 * doorbell pacing DBQ event notification has been updated. The driver
+	 * needs to take appropriate action and retrieve the new list when this
+	 * event is received from the firmware.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_DOORBELL_PACING_NQ_UPDATE	UINT32_C(0x48)
+	/*
+	 * An event from firmware indicating that hardware ran into an error
+	 * while trying to read the host based doorbell copy region. The driver
+	 * needs to take the appropriate action and maintain the corresponding
+	 * doorbell copy region.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_HW_DOORBELL_RECOVERY_READ_ERROR UINT32_C(0x49)
+	/*
+	 * An event from firmware indicating that the XID partition was not
+	 * allocated/freed by the FW successfully for the request that is
+	 * encapsulated in the HWRM_EXEC_FWD_RESP by the PF driver for VF.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_CTX_ERROR			UINT32_C(0x4a)
+	/*
+	 * A UDCC session has been modified in the FW. The session_id can be
+	 * used by the driver to retrieve information related to the UDCC
+	 * session.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_UDCC_SESSION_CHANGE		UINT32_C(0x4b)
+	/*
+	 * Used to notify the host that the firmware has DMA-ed additional
+	 * debug data to the host buffer. This is effectively a producer index
+	 * update. The host driver can utilize this information to determine
+	 * how much of its host buffer has been populated by the firmware.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_DBG_BUF_PRODUCER		UINT32_C(0x4c)
+	/* Maximum Registrable event id. */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_MAX_RGTR_EVENT_ID		UINT32_C(0x4d)
+	/*
+	 * A trace log message. This contains firmware trace logs string
+	 * embedded in the asynchronous message. This is an experimental
+	 * event, not meant for production use at this time.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_FW_TRACE_MSG			UINT32_C(0xfe)
+	/* HWRM Error */
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_HWRM_ERROR			UINT32_C(0xff)
+	#define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LAST			HWRM_ASYNC_EVENT_CMPL_EVENT_ID_HWRM_ERROR
 	/* Event specific data */
 	uint32_t	event_data2;
 	uint8_t	opaque_v;
@@ -9049,42 +9810,95 @@ typedef struct hwrm_async_event_cmpl_eem_cache_flush_done {
 	 * for each pass through the completion queue. The even passes
 	 * will write 1. The odd passes will write 0.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_DONE_V	UINT32_C(0x1)
+	#define HWRM_ASYNC_EVENT_CMPL_V	UINT32_C(0x1)
 	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_DONE_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_DONE_OPAQUE_SFT 1
+	#define HWRM_ASYNC_EVENT_CMPL_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_OPAQUE_SFT 1
 	/* 8-lsb timestamp from POR (100-msec resolution) */
 	uint8_t	timestamp_lo;
 	/* 16-lsb timestamp from POR (100-msec resolution) */
 	uint16_t	timestamp_hi;
 	/* Event specific data */
 	uint32_t	event_data1;
-	/* Indicates function ID that this event occurred on. */
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_DONE_EVENT_DATA1_FID_MASK UINT32_C(0xffff)
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_DONE_EVENT_DATA1_FID_SFT 0
-} hwrm_async_event_cmpl_eem_cache_flush_done_t, *phwrm_async_event_cmpl_eem_cache_flush_done_t;
-
-/* hwrm_async_event_cmpl_tcp_flag_action_change (size:128b/16B) */
+} hwrm_async_event_cmpl_t, *phwrm_async_event_cmpl_t;
 
-typedef struct hwrm_async_event_cmpl_tcp_flag_action_change {
-	uint16_t	type;
-	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
+#define GET_EVENT_ID(x) \
+	(((x) < 0x80) ? \
+	((x) == 0x0 ? "LINK_STATUS_CHANGE": \
+	((x) == 0x1 ? "LINK_MTU_CHANGE": \
+	((x) == 0x2 ? "LINK_SPEED_CHANGE": \
+	((x) == 0x3 ? "DCB_CONFIG_CHANGE": \
+	((x) == 0x4 ? "PORT_CONN_NOT_ALLOWED": \
+	((x) == 0x5 ? "LINK_SPEED_CFG_NOT_ALLOWED": \
+	((x) == 0x6 ? "LINK_SPEED_CFG_CHANGE": \
+	((x) == 0x7 ? "PORT_PHY_CFG_CHANGE": \
+	((x) == 0x8 ? "RESET_NOTIFY": \
+	((x) == 0x9 ? "ERROR_RECOVERY": \
+	((x) == 0xa ? "RING_MONITOR_MSG": \
+	((x) == 0x10 ? "FUNC_DRVR_UNLOAD": \
+	((x) == 0x11 ? "FUNC_DRVR_LOAD": \
+	((x) == 0x12 ? "FUNC_FLR_PROC_CMPLT": \
+	((x) == 0x20 ? "PF_DRVR_UNLOAD": \
+	((x) == 0x21 ? "PF_DRVR_LOAD": \
+	((x) == 0x30 ? "VF_FLR": \
+	((x) == 0x31 ? "VF_MAC_ADDR_CHANGE": \
+	((x) == 0x32 ? "PF_VF_COMM_STATUS_CHANGE": \
+	((x) == 0x33 ? "VF_CFG_CHANGE": \
+	((x) == 0x34 ? "LLFC_PFC_CHANGE": \
+	((x) == 0x35 ? "DEFAULT_VNIC_CHANGE": \
+	((x) == 0x36 ? "HW_FLOW_AGED": \
+	((x) == 0x37 ? "DEBUG_NOTIFICATION": \
+	((x) == 0x38 ? "EEM_CACHE_FLUSH_REQ": \
+	((x) == 0x39 ? "EEM_CACHE_FLUSH_DONE": \
+	((x) == 0x3a ? "TCP_FLAG_ACTION_CHANGE": \
+	((x) == 0x3b ? "EEM_FLOW_ACTIVE": \
+	((x) == 0x3c ? "EEM_CFG_CHANGE": \
+	((x) == 0x3d ? "TFLIB_DEFAULT_VNIC_CHANGE": \
+	((x) == 0x3e ? "TFLIB_LINK_STATUS_CHANGE": \
+	((x) == 0x3f ? "QUIESCE_DONE": \
+	((x) == 0x40 ? "DEFERRED_RESPONSE": \
+	((x) == 0x41 ? "PFC_WATCHDOG_CFG_CHANGE": \
+	((x) == 0x42 ? "ECHO_REQUEST": \
+	((x) == 0x43 ? "PHC_UPDATE": \
+	((x) == 0x44 ? "PPS_TIMESTAMP": \
+	((x) == 0x45 ? "ERROR_REPORT": \
+	((x) == 0x46 ? "DOORBELL_PACING_THRESHOLD": \
+	((x) == 0x47 ? "RSS_CHANGE": \
+	((x) == 0x48 ? "DOORBELL_PACING_NQ_UPDATE": \
+	((x) == 0x49 ? "HW_DOORBELL_RECOVERY_READ_ERROR": \
+	((x) == 0x4a ? "CTX_ERROR": \
+	((x) == 0x4b ? "UDCC_SESSION_CHANGE": \
+	((x) == 0x4c ? "DBG_BUF_PRODUCER": \
+	((x) == 0x4d ? "MAX_RGTR_EVENT_ID": \
+	"Unknown decode" )))))))))))))))))))))))))))))))))))))))))))))) : \
+	(((x) < 0x100) ? \
+	((x) == 0xfe ? "FW_TRACE_MSG": \
+	((x) == 0xff ? "HWRM_ERROR": \
+	"Unknown decode" )) : \
+	"Unknown decode" ))
+
+
+/* hwrm_async_event_cmpl_link_status_change (size:128b/16B) */
+
+typedef struct hwrm_async_event_cmpl_link_status_change {
+	uint16_t	type;
+	/*
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
 	 * records.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_TCP_FLAG_ACTION_CHANGE_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_TCP_FLAG_ACTION_CHANGE_TYPE_SFT		0
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_TYPE_SFT		0
 	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_TCP_FLAG_ACTION_CHANGE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_TCP_FLAG_ACTION_CHANGE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_TCP_FLAG_ACTION_CHANGE_TYPE_HWRM_ASYNC_EVENT
+		#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_TYPE_HWRM_ASYNC_EVENT
 	/* Identifiers of events. */
 	uint16_t	event_id;
-	/* Notification of tcp flag action change */
-	#define HWRM_ASYNC_EVENT_CMPL_TCP_FLAG_ACTION_CHANGE_EVENT_ID_TCP_FLAG_ACTION_CHANGE UINT32_C(0x3a)
-	#define HWRM_ASYNC_EVENT_CMPL_TCP_FLAG_ACTION_CHANGE_EVENT_ID_LAST		HWRM_ASYNC_EVENT_CMPL_TCP_FLAG_ACTION_CHANGE_EVENT_ID_TCP_FLAG_ACTION_CHANGE
+	/* Link status changed */
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_EVENT_ID_LINK_STATUS_CHANGE UINT32_C(0x0)
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_EVENT_ID_LAST		HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_EVENT_ID_LINK_STATUS_CHANGE
 	/* Event specific data */
 	uint32_t	event_data2;
 	uint8_t	opaque_v;
@@ -9093,21 +9907,43 @@ typedef struct hwrm_async_event_cmpl_tcp_flag_action_change {
 	 * for each pass through the completion queue. The even passes
 	 * will write 1. The odd passes will write 0.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_TCP_FLAG_ACTION_CHANGE_V	UINT32_C(0x1)
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_V	UINT32_C(0x1)
 	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_TCP_FLAG_ACTION_CHANGE_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_TCP_FLAG_ACTION_CHANGE_OPAQUE_SFT 1
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_OPAQUE_SFT 1
 	/* 8-lsb timestamp from POR (100-msec resolution) */
 	uint8_t	timestamp_lo;
 	/* 16-lsb timestamp from POR (100-msec resolution) */
 	uint16_t	timestamp_hi;
 	/* Event specific data */
 	uint32_t	event_data1;
-} hwrm_async_event_cmpl_tcp_flag_action_change_t, *phwrm_async_event_cmpl_tcp_flag_action_change_t;
+	/* Indicates link status change */
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_EVENT_DATA1_LINK_CHANGE	UINT32_C(0x1)
+	/*
+	 * If this bit set to 0, then it indicates that the link
+	 * was up and it went down.
+	 */
+		#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_EVENT_DATA1_LINK_CHANGE_DOWN  UINT32_C(0x0)
+	/*
+	 * If this bit is set to 1, then it indicates that the link
+	 * was down and it went up.
+	 */
+		#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_EVENT_DATA1_LINK_CHANGE_UP	UINT32_C(0x1)
+		#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_EVENT_DATA1_LINK_CHANGE_LAST HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_EVENT_DATA1_LINK_CHANGE_UP
+	/* Indicates the physical port this link status change occur */
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_EVENT_DATA1_PORT_MASK	UINT32_C(0xe)
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_EVENT_DATA1_PORT_SFT	1
+	/* PORT ID */
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_EVENT_DATA1_PORT_ID_MASK	UINT32_C(0xffff0)
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_EVENT_DATA1_PORT_ID_SFT	4
+	/* Indicates the physical function this event occurred on. */
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_EVENT_DATA1_PF_ID_MASK	UINT32_C(0xff00000)
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_STATUS_CHANGE_EVENT_DATA1_PF_ID_SFT	20
+} hwrm_async_event_cmpl_link_status_change_t, *phwrm_async_event_cmpl_link_status_change_t;
 
-/* hwrm_async_event_cmpl_eem_flow_active (size:128b/16B) */
+/* hwrm_async_event_cmpl_link_mtu_change (size:128b/16B) */
 
-typedef struct hwrm_async_event_cmpl_eem_flow_active {
+typedef struct hwrm_async_event_cmpl_link_mtu_change {
 	uint16_t	type;
 	/*
 	 * This field indicates the exact type of the completion.
@@ -9116,77 +9952,42 @@ typedef struct hwrm_async_event_cmpl_eem_flow_active {
 	 * records. Odd values indicate 32B
 	 * records.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_TYPE_SFT		0
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_MTU_CHANGE_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_MTU_CHANGE_TYPE_SFT		0
 	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_TYPE_HWRM_ASYNC_EVENT
+		#define HWRM_ASYNC_EVENT_CMPL_LINK_MTU_CHANGE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_LINK_MTU_CHANGE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_LINK_MTU_CHANGE_TYPE_HWRM_ASYNC_EVENT
 	/* Identifiers of events. */
 	uint16_t	event_id;
-	/* Notification of an active eem flow */
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_ID_EEM_FLOW_ACTIVE UINT32_C(0x3b)
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_ID_EEM_FLOW_ACTIVE
+	/* Link MTU changed */
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_MTU_CHANGE_EVENT_ID_LINK_MTU_CHANGE UINT32_C(0x1)
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_MTU_CHANGE_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_LINK_MTU_CHANGE_EVENT_ID_LINK_MTU_CHANGE
 	/* Event specific data */
 	uint32_t	event_data2;
-	/* Indicates the 2nd global id this event occurred on. */
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA2_GLOBAL_ID_2_MASK   UINT32_C(0x3fffffff)
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA2_GLOBAL_ID_2_SFT	0
-	/*
-	 * Indicates flow direction of the flow identified by
-	 * the global_id_2.
-	 */
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA2_FLOW_DIRECTION	UINT32_C(0x40000000)
-	/* If this bit is set to 0, then it indicates that this rx flow. */
-		#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA2_FLOW_DIRECTION_RX	(UINT32_C(0x0) << 30)
-	/* If this bit is set to 1, then it indicates that this tx flow. */
-		#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA2_FLOW_DIRECTION_TX	(UINT32_C(0x1) << 30)
-		#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA2_FLOW_DIRECTION_LAST HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA2_FLOW_DIRECTION_TX
 	uint8_t	opaque_v;
 	/*
 	 * This value is written by the NIC such that it will be different
 	 * for each pass through the completion queue. The even passes
 	 * will write 1. The odd passes will write 0.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_V	UINT32_C(0x1)
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_MTU_CHANGE_V	UINT32_C(0x1)
 	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_OPAQUE_SFT 1
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_MTU_CHANGE_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_MTU_CHANGE_OPAQUE_SFT 1
 	/* 8-lsb timestamp from POR (100-msec resolution) */
 	uint8_t	timestamp_lo;
 	/* 16-lsb timestamp from POR (100-msec resolution) */
 	uint16_t	timestamp_hi;
 	/* Event specific data */
 	uint32_t	event_data1;
-	/* Indicates the 1st global id this event occurred on. */
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA1_GLOBAL_ID_1_MASK   UINT32_C(0x3fffffff)
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA1_GLOBAL_ID_1_SFT	0
-	/*
-	 * Indicates flow direction of the flow identified by the
-	 * global_id_1.
-	 */
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA1_FLOW_DIRECTION	UINT32_C(0x40000000)
-	/* If this bit is set to 0, then it indicates that this is rx flow. */
-		#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA1_FLOW_DIRECTION_RX	(UINT32_C(0x0) << 30)
-	/* If this bit is set to 1, then it indicates that this is tx flow. */
-		#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA1_FLOW_DIRECTION_TX	(UINT32_C(0x1) << 30)
-		#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA1_FLOW_DIRECTION_LAST HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA1_FLOW_DIRECTION_TX
-	/*
-	 * Indicates EEM flow aging mode this event occurred on. If
-	 * this bit is set to 0, the event_data1 is the EEM global
-	 * ID. If this bit is set to 1, the event_data1 is the number
-	 * of global ID in the context memory.
-	 */
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA1_MODE		UINT32_C(0x80000000)
-	/* EEM flow aging mode 0. */
-		#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA1_MODE_0		(UINT32_C(0x0) << 31)
-	/* EEM flow aging mode 1. */
-		#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA1_MODE_1		(UINT32_C(0x1) << 31)
-		#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA1_MODE_LAST	HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA1_MODE_1
-} hwrm_async_event_cmpl_eem_flow_active_t, *phwrm_async_event_cmpl_eem_flow_active_t;
+	/* The new MTU of the link in bytes. */
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_MTU_CHANGE_EVENT_DATA1_NEW_MTU_MASK UINT32_C(0xffff)
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_MTU_CHANGE_EVENT_DATA1_NEW_MTU_SFT 0
+} hwrm_async_event_cmpl_link_mtu_change_t, *phwrm_async_event_cmpl_link_mtu_change_t;
 
-/* hwrm_async_event_cmpl_eem_cfg_change (size:128b/16B) */
+/* hwrm_async_event_cmpl_link_speed_change (size:128b/16B) */
 
-typedef struct hwrm_async_event_cmpl_eem_cfg_change {
+typedef struct hwrm_async_event_cmpl_link_speed_change {
 	uint16_t	type;
 	/*
 	 * This field indicates the exact type of the completion.
@@ -9195,16 +9996,16 @@ typedef struct hwrm_async_event_cmpl_eem_cfg_change {
 	 * records. Odd values indicate 32B
 	 * records.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_CFG_CHANGE_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_CFG_CHANGE_TYPE_SFT		0
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_TYPE_SFT		0
 	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_EEM_CFG_CHANGE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_EEM_CFG_CHANGE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_EEM_CFG_CHANGE_TYPE_HWRM_ASYNC_EVENT
+		#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_TYPE_HWRM_ASYNC_EVENT
 	/* Identifiers of events. */
 	uint16_t	event_id;
-	/* Notification of EEM configuration change */
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_CFG_CHANGE_EVENT_ID_EEM_CFG_CHANGE UINT32_C(0x3c)
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_CFG_CHANGE_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_EEM_CFG_CHANGE_EVENT_ID_EEM_CFG_CHANGE
+	/* Link speed changed */
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_ID_LINK_SPEED_CHANGE UINT32_C(0x2)
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_ID_LAST		HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_ID_LINK_SPEED_CHANGE
 	/* Event specific data */
 	uint32_t	event_data2;
 	uint8_t	opaque_v;
@@ -9213,10 +10014,10 @@ typedef struct hwrm_async_event_cmpl_eem_cfg_change {
 	 * for each pass through the completion queue. The even passes
 	 * will write 1. The odd passes will write 0.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_CFG_CHANGE_V	UINT32_C(0x1)
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_V	UINT32_C(0x1)
 	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_CFG_CHANGE_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_CFG_CHANGE_OPAQUE_SFT 1
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_OPAQUE_SFT 1
 	/* 8-lsb timestamp from POR (100-msec resolution) */
 	uint8_t	timestamp_lo;
 	/* 16-lsb timestamp from POR (100-msec resolution) */
@@ -9224,20 +10025,42 @@ typedef struct hwrm_async_event_cmpl_eem_cfg_change {
 	/* Event specific data */
 	uint32_t	event_data1;
 	/*
-	 * Value of 1 to indicate EEM TX configuration is enabled. Value of
-	 * 0 to indicate the EEM TX configuration is disabled.
-	 */
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_CFG_CHANGE_EVENT_DATA1_EEM_TX_ENABLE	UINT32_C(0x1)
-	/*
-	 * Value of 1 to indicate EEM RX configuration is enabled. Value of 0
-	 * to indicate the EEM RX configuration is disabled.
+	 * When this bit is '1', the link was forced to the
+	 * force_link_speed value.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_EEM_CFG_CHANGE_EVENT_DATA1_EEM_RX_ENABLE	UINT32_C(0x2)
-} hwrm_async_event_cmpl_eem_cfg_change_t, *phwrm_async_event_cmpl_eem_cfg_change_t;
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_FORCE			UINT32_C(0x1)
+	/* The new link speed in 100 Mbps units. */
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_MASK UINT32_C(0xfffe)
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_SFT  1
+	/* 100Mb link speed */
+		#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_100MB  (UINT32_C(0x1) << 1)
+	/* 1Gb link speed */
+		#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_1GB	(UINT32_C(0xa) << 1)
+	/* 2Gb link speed */
+		#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_2GB	(UINT32_C(0x14) << 1)
+	/* 25Gb link speed */
+		#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_2_5GB  (UINT32_C(0x19) << 1)
+	/* 10Gb link speed */
+		#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_10GB   (UINT32_C(0x64) << 1)
+	/* 20Mb link speed */
+		#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_20GB   (UINT32_C(0xc8) << 1)
+	/* 25Gb link speed */
+		#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_25GB   (UINT32_C(0xfa) << 1)
+	/* 40Gb link speed */
+		#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_40GB   (UINT32_C(0x190) << 1)
+	/* 50Gb link speed */
+		#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_50GB   (UINT32_C(0x1f4) << 1)
+	/* 100Gb link speed */
+		#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_100GB  (UINT32_C(0x3e8) << 1)
+		#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_LAST  HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_NEW_LINK_SPEED_100MBPS_100GB
+	/* PORT ID */
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_PORT_ID_MASK		UINT32_C(0xffff0000)
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CHANGE_EVENT_DATA1_PORT_ID_SFT		16
+} hwrm_async_event_cmpl_link_speed_change_t, *phwrm_async_event_cmpl_link_speed_change_t;
 
-/* hwrm_async_event_cmpl_quiesce_done (size:128b/16B) */
+/* hwrm_async_event_cmpl_dcb_config_change (size:128b/16B) */
 
-typedef struct hwrm_async_event_cmpl_quiesce_done {
+typedef struct hwrm_async_event_cmpl_dcb_config_change {
 	uint16_t	type;
 	/*
 	 * This field indicates the exact type of the completion.
@@ -9246,82 +10069,62 @@ typedef struct hwrm_async_event_cmpl_quiesce_done {
 	 * records. Odd values indicate 32B
 	 * records.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_TYPE_SFT		0
+	#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_TYPE_SFT		0
 	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_TYPE_HWRM_ASYNC_EVENT
+		#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_TYPE_HWRM_ASYNC_EVENT
 	/* Identifiers of events. */
 	uint16_t	event_id;
-	/* An event signifying completion of HWRM_FW_STATE_QUIESCE */
-	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_ID_QUIESCE_DONE UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_ID_QUIESCE_DONE
+	/* DCB Configuration changed */
+	#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_ID_DCB_CONFIG_CHANGE UINT32_C(0x3)
+	#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_ID_LAST		HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_ID_DCB_CONFIG_CHANGE
 	/* Event specific data */
 	uint32_t	event_data2;
-	/* Status of HWRM_FW_STATE_QUIESCE completion */
-	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_DATA2_QUIESCE_STATUS_MASK		UINT32_C(0xff)
-	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_DATA2_QUIESCE_STATUS_SFT		0
-	/*
-	 * The quiesce operation started by HWRM_FW_STATE_QUIESCE
-	 * completed successfully.
-	 */
-		#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_DATA2_QUIESCE_STATUS_SUCCESS		UINT32_C(0x0)
-	/*
-	 * The quiesce operation started by HWRM_FW_STATE_QUIESCE timed
-	 * out.
-	 */
-		#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_DATA2_QUIESCE_STATUS_TIMEOUT		UINT32_C(0x1)
-	/*
-	 * The quiesce operation started by HWRM_FW_STATE_QUIESCE
-	 * encountered an error.
-	 */
-		#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_DATA2_QUIESCE_STATUS_ERROR		UINT32_C(0x2)
-		#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_DATA2_QUIESCE_STATUS_LAST		HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_DATA2_QUIESCE_STATUS_ERROR
-	/* opaque is 8 b */
-	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_DATA2_OPAQUE_MASK			UINT32_C(0xff00)
-	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_DATA2_OPAQUE_SFT			8
-	/*
-	 * Additional information about internal hardware state related to
-	 * idle/quiesce state.  QUIESCE may succeed per quiesce_status
-	 * regardless of idle_state_flags.  If QUIESCE fails, the host may
-	 * inspect idle_state_flags to determine whether a retry is warranted.
-	 */
-	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_DATA2_IDLE_STATE_FLAGS_MASK		UINT32_C(0xff0000)
-	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_DATA2_IDLE_STATE_FLAGS_SFT		16
-	/*
-	 * Failure to quiesce is caused by host not updating the NQ consumer
-	 * index.
-	 */
-	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_DATA2_IDLE_STATE_FLAGS_INCOMPLETE_NQ	UINT32_C(0x10000)
-	/* Flag 1 indicating partial non-idle state. */
-	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_DATA2_IDLE_STATE_FLAGS_IDLE_STATUS_1	UINT32_C(0x20000)
-	/* Flag 2 indicating partial non-idle state. */
-	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_DATA2_IDLE_STATE_FLAGS_IDLE_STATUS_2	UINT32_C(0x40000)
-	/* Flag 3 indicating partial non-idle state. */
-	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_DATA2_IDLE_STATE_FLAGS_IDLE_STATUS_3	UINT32_C(0x80000)
+	/* ETS configuration change */
+	#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_DATA2_ETS	UINT32_C(0x1)
+	/* PFC configuration change */
+	#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_DATA2_PFC	UINT32_C(0x2)
+	/* APP configuration change */
+	#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_DATA2_APP	UINT32_C(0x4)
+	/* DSCP configuration change */
+	#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_DATA2_DSCP	UINT32_C(0x8)
 	uint8_t	opaque_v;
 	/*
 	 * This value is written by the NIC such that it will be different
 	 * for each pass through the completion queue. The even passes
 	 * will write 1. The odd passes will write 0.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_V	UINT32_C(0x1)
+	#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_V	UINT32_C(0x1)
 	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_OPAQUE_SFT 1
+	#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_OPAQUE_SFT 1
 	/* 8-lsb timestamp from POR (100-msec resolution) */
 	uint8_t	timestamp_lo;
 	/* 16-lsb timestamp from POR (100-msec resolution) */
 	uint16_t	timestamp_hi;
 	/* Event specific data */
 	uint32_t	event_data1;
-	/* Time stamp for error event */
-	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_DATA1_TIMESTAMP	UINT32_C(0x1)
-} hwrm_async_event_cmpl_quiesce_done_t, *phwrm_async_event_cmpl_quiesce_done_t;
+	/* PORT ID */
+	#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_DATA1_PORT_ID_MASK		UINT32_C(0xffff)
+	#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_DATA1_PORT_ID_SFT		0
+	/* Priority recommended for RoCE traffic */
+	#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_DATA1_RECOMMEND_ROCE_PRIORITY_MASK UINT32_C(0xff0000)
+	#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_DATA1_RECOMMEND_ROCE_PRIORITY_SFT 16
+	/* none is 255 */
+		#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_DATA1_RECOMMEND_ROCE_PRIORITY_NONE  (UINT32_C(0xff) << 16)
+		#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_DATA1_RECOMMEND_ROCE_PRIORITY_LAST HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_DATA1_RECOMMEND_ROCE_PRIORITY_NONE
+	/* Priority recommended for L2 traffic */
+	#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_DATA1_RECOMMEND_L2_PRIORITY_MASK  UINT32_C(0xff000000)
+	#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_DATA1_RECOMMEND_L2_PRIORITY_SFT   24
+	/* none is 255 */
+		#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_DATA1_RECOMMEND_L2_PRIORITY_NONE	(UINT32_C(0xff) << 24)
+		#define HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_DATA1_RECOMMEND_L2_PRIORITY_LAST   HWRM_ASYNC_EVENT_CMPL_DCB_CONFIG_CHANGE_EVENT_DATA1_RECOMMEND_L2_PRIORITY_NONE
+} hwrm_async_event_cmpl_dcb_config_change_t, *phwrm_async_event_cmpl_dcb_config_change_t;
 
-/* hwrm_async_event_cmpl_deferred_response (size:128b/16B) */
+/* hwrm_async_event_cmpl_port_conn_not_allowed (size:128b/16B) */
 
-typedef struct hwrm_async_event_cmpl_deferred_response {
+typedef struct hwrm_async_event_cmpl_port_conn_not_allowed {
 	uint16_t	type;
 	/*
 	 * This field indicates the exact type of the completion.
@@ -9330,51 +10133,58 @@ typedef struct hwrm_async_event_cmpl_deferred_response {
 	 * records. Odd values indicate 32B
 	 * records.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_DEFERRED_RESPONSE_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_DEFERRED_RESPONSE_TYPE_SFT		0
+	#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_TYPE_SFT		0
 	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_DEFERRED_RESPONSE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_DEFERRED_RESPONSE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_DEFERRED_RESPONSE_TYPE_HWRM_ASYNC_EVENT
+		#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_TYPE_HWRM_ASYNC_EVENT
 	/* Identifiers of events. */
 	uint16_t	event_id;
-	/*
-	 * An event signifying a HWRM command is in progress and its
-	 * response will be deferred
-	 */
-	#define HWRM_ASYNC_EVENT_CMPL_DEFERRED_RESPONSE_EVENT_ID_DEFERRED_RESPONSE UINT32_C(0x40)
-	#define HWRM_ASYNC_EVENT_CMPL_DEFERRED_RESPONSE_EVENT_ID_LAST		HWRM_ASYNC_EVENT_CMPL_DEFERRED_RESPONSE_EVENT_ID_DEFERRED_RESPONSE
+	/* Port connection not allowed */
+	#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_EVENT_ID_PORT_CONN_NOT_ALLOWED UINT32_C(0x4)
+	#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_EVENT_ID_LAST		HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_EVENT_ID_PORT_CONN_NOT_ALLOWED
 	/* Event specific data */
 	uint32_t	event_data2;
-	/*
-	 * The PF's mailbox is clear to issue another command.
-	 * A command with this seq_id is still in progress
-	 * and will return a regular HWRM completion when done.
-	 * 'event_data1' field, if non-zero, contains the estimated
-	 * execution time for the command.
-	 */
-	#define HWRM_ASYNC_EVENT_CMPL_DEFERRED_RESPONSE_EVENT_DATA2_SEQ_ID_MASK UINT32_C(0xffff)
-	#define HWRM_ASYNC_EVENT_CMPL_DEFERRED_RESPONSE_EVENT_DATA2_SEQ_ID_SFT 0
 	uint8_t	opaque_v;
 	/*
 	 * This value is written by the NIC such that it will be different
 	 * for each pass through the completion queue. The even passes
 	 * will write 1. The odd passes will write 0.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_DEFERRED_RESPONSE_V	UINT32_C(0x1)
+	#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_V	UINT32_C(0x1)
 	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_DEFERRED_RESPONSE_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_DEFERRED_RESPONSE_OPAQUE_SFT 1
+	#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_OPAQUE_SFT 1
 	/* 8-lsb timestamp from POR (100-msec resolution) */
 	uint8_t	timestamp_lo;
 	/* 16-lsb timestamp from POR (100-msec resolution) */
 	uint16_t	timestamp_hi;
-	/* Estimated remaining time of command execution in ms (if not zero) */
+	/* Event specific data */
 	uint32_t	event_data1;
-} hwrm_async_event_cmpl_deferred_response_t, *phwrm_async_event_cmpl_deferred_response_t;
+	/* PORT ID */
+	#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_EVENT_DATA1_PORT_ID_MASK		UINT32_C(0xffff)
+	#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_EVENT_DATA1_PORT_ID_SFT		0
+	/*
+	 * This value indicates the current port level enforcement policy
+	 * for the optics module when there is an optical module mismatch
+	 * and port is not connected.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_EVENT_DATA1_ENFORCEMENT_POLICY_MASK	UINT32_C(0xff0000)
+	#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_EVENT_DATA1_ENFORCEMENT_POLICY_SFT	16
+	/* No enforcement */
+		#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_EVENT_DATA1_ENFORCEMENT_POLICY_NONE	(UINT32_C(0x0) << 16)
+	/* Disable Transmit side Laser. */
+		#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_EVENT_DATA1_ENFORCEMENT_POLICY_DISABLETX   (UINT32_C(0x1) << 16)
+	/* Raise a warning message. */
+		#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_EVENT_DATA1_ENFORCEMENT_POLICY_WARNINGMSG  (UINT32_C(0x2) << 16)
+	/* Power down the module. */
+		#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_EVENT_DATA1_ENFORCEMENT_POLICY_PWRDOWN	(UINT32_C(0x3) << 16)
+		#define HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_EVENT_DATA1_ENFORCEMENT_POLICY_LAST	HWRM_ASYNC_EVENT_CMPL_PORT_CONN_NOT_ALLOWED_EVENT_DATA1_ENFORCEMENT_POLICY_PWRDOWN
+} hwrm_async_event_cmpl_port_conn_not_allowed_t, *phwrm_async_event_cmpl_port_conn_not_allowed_t;
 
-/* hwrm_async_event_cmpl_pfc_watchdog_cfg_change (size:128b/16B) */
+/* hwrm_async_event_cmpl_link_speed_cfg_not_allowed (size:128b/16B) */
 
-typedef struct hwrm_async_event_cmpl_pfc_watchdog_cfg_change {
+typedef struct hwrm_async_event_cmpl_link_speed_cfg_not_allowed {
 	uint16_t	type;
 	/*
 	 * This field indicates the exact type of the completion.
@@ -9383,16 +10193,16 @@ typedef struct hwrm_async_event_cmpl_pfc_watchdog_cfg_change {
 	 * records. Odd values indicate 32B
 	 * records.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_TYPE_SFT		0
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_NOT_ALLOWED_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_NOT_ALLOWED_TYPE_SFT		0
 	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_TYPE_HWRM_ASYNC_EVENT
+		#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_NOT_ALLOWED_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_NOT_ALLOWED_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_NOT_ALLOWED_TYPE_HWRM_ASYNC_EVENT
 	/* Identifiers of events. */
 	uint16_t	event_id;
-	/* PFC watchdog configuration change for given port/cos */
-	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_EVENT_ID_PFC_WATCHDOG_CFG_CHANGE UINT32_C(0x41)
-	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_EVENT_ID_LAST		HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_EVENT_ID_PFC_WATCHDOG_CFG_CHANGE
+	/* Link speed configuration was not allowed */
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_NOT_ALLOWED_EVENT_ID_LINK_SPEED_CFG_NOT_ALLOWED UINT32_C(0x5)
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_NOT_ALLOWED_EVENT_ID_LAST			HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_NOT_ALLOWED_EVENT_ID_LINK_SPEED_CFG_NOT_ALLOWED
 	/* Event specific data */
 	uint32_t	event_data2;
 	uint8_t	opaque_v;
@@ -9401,46 +10211,24 @@ typedef struct hwrm_async_event_cmpl_pfc_watchdog_cfg_change {
 	 * for each pass through the completion queue. The even passes
 	 * will write 1. The odd passes will write 0.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_V	UINT32_C(0x1)
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_NOT_ALLOWED_V	UINT32_C(0x1)
 	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_OPAQUE_SFT 1
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_NOT_ALLOWED_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_NOT_ALLOWED_OPAQUE_SFT 1
 	/* 8-lsb timestamp from POR (100-msec resolution) */
 	uint8_t	timestamp_lo;
 	/* 16-lsb timestamp from POR (100-msec resolution) */
 	uint16_t	timestamp_hi;
 	/* Event specific data */
 	uint32_t	event_data1;
-	/*
-	 * 1 in bit position X indicates PFC watchdog should
-	 * be on for COSX
-	 */
-	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_EVENT_DATA1_PFC_WD_COS_MASK		UINT32_C(0xff)
-	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_EVENT_DATA1_PFC_WD_COS_SFT		0
-	/* 1 means PFC WD for COS0 is on, 0 - off. */
-	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_EVENT_DATA1_PFC_WD_COS_PFC_WD_COS0	UINT32_C(0x1)
-	/* 1 means PFC WD for COS1 is on, 0 - off. */
-	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_EVENT_DATA1_PFC_WD_COS_PFC_WD_COS1	UINT32_C(0x2)
-	/* 1 means PFC WD for COS2 is on, 0 - off. */
-	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_EVENT_DATA1_PFC_WD_COS_PFC_WD_COS2	UINT32_C(0x4)
-	/* 1 means PFC WD for COS3 is on, 0 - off. */
-	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_EVENT_DATA1_PFC_WD_COS_PFC_WD_COS3	UINT32_C(0x8)
-	/* 1 means PFC WD for COS4 is on, 0 - off. */
-	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_EVENT_DATA1_PFC_WD_COS_PFC_WD_COS4	UINT32_C(0x10)
-	/* 1 means PFC WD for COS5 is on, 0 - off. */
-	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_EVENT_DATA1_PFC_WD_COS_PFC_WD_COS5	UINT32_C(0x20)
-	/* 1 means PFC WD for COS6 is on, 0 - off. */
-	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_EVENT_DATA1_PFC_WD_COS_PFC_WD_COS6	UINT32_C(0x40)
-	/* 1 means PFC WD for COS7 is on, 0 - off. */
-	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_EVENT_DATA1_PFC_WD_COS_PFC_WD_COS7	UINT32_C(0x80)
 	/* PORT ID */
-	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_EVENT_DATA1_PORT_ID_MASK		UINT32_C(0xffff00)
-	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_EVENT_DATA1_PORT_ID_SFT		8
-} hwrm_async_event_cmpl_pfc_watchdog_cfg_change_t, *phwrm_async_event_cmpl_pfc_watchdog_cfg_change_t;
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_NOT_ALLOWED_EVENT_DATA1_PORT_ID_MASK UINT32_C(0xffff)
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_NOT_ALLOWED_EVENT_DATA1_PORT_ID_SFT 0
+} hwrm_async_event_cmpl_link_speed_cfg_not_allowed_t, *phwrm_async_event_cmpl_link_speed_cfg_not_allowed_t;
 
-/* hwrm_async_event_cmpl_echo_request (size:128b/16B) */
+/* hwrm_async_event_cmpl_link_speed_cfg_change (size:128b/16B) */
 
-typedef struct hwrm_async_event_cmpl_echo_request {
+typedef struct hwrm_async_event_cmpl_link_speed_cfg_change {
 	uint16_t	type;
 	/*
 	 * This field indicates the exact type of the completion.
@@ -9449,20 +10237,17 @@ typedef struct hwrm_async_event_cmpl_echo_request {
 	 * records. Odd values indicate 32B
 	 * records.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_ECHO_REQUEST_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_ECHO_REQUEST_TYPE_SFT		0
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_TYPE_SFT		0
 	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_ECHO_REQUEST_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_ECHO_REQUEST_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_ECHO_REQUEST_TYPE_HWRM_ASYNC_EVENT
+		#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_TYPE_HWRM_ASYNC_EVENT
 	/* Identifiers of events. */
 	uint16_t	event_id;
-	/*
-	 * An echo request from the firmware. An echo response is expected by
-	 * the firmware.
-	 */
-	#define HWRM_ASYNC_EVENT_CMPL_ECHO_REQUEST_EVENT_ID_ECHO_REQUEST UINT32_C(0x42)
-	#define HWRM_ASYNC_EVENT_CMPL_ECHO_REQUEST_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_ECHO_REQUEST_EVENT_ID_ECHO_REQUEST
-	/* Event specific data that should be provided in the echo response */
+	/* Link speed configuration change */
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_EVENT_ID_LINK_SPEED_CFG_CHANGE UINT32_C(0x6)
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_EVENT_ID_LAST		HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_EVENT_ID_LINK_SPEED_CFG_CHANGE
+	/* Event specific data */
 	uint32_t	event_data2;
 	uint8_t	opaque_v;
 	/*
@@ -9470,21 +10255,38 @@ typedef struct hwrm_async_event_cmpl_echo_request {
 	 * for each pass through the completion queue. The even passes
 	 * will write 1. The odd passes will write 0.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_ECHO_REQUEST_V	UINT32_C(0x1)
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_V	UINT32_C(0x1)
 	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_ECHO_REQUEST_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_ECHO_REQUEST_OPAQUE_SFT 1
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_OPAQUE_SFT 1
 	/* 8-lsb timestamp from POR (100-msec resolution) */
 	uint8_t	timestamp_lo;
 	/* 16-lsb timestamp from POR (100-msec resolution) */
 	uint16_t	timestamp_hi;
-	/* Event specific data that should be provided in the echo response */
+	/* Event specific data */
 	uint32_t	event_data1;
-} hwrm_async_event_cmpl_echo_request_t, *phwrm_async_event_cmpl_echo_request_t;
+	/* PORT ID */
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_EVENT_DATA1_PORT_ID_MASK			UINT32_C(0xffff)
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_EVENT_DATA1_PORT_ID_SFT			0
+	/*
+	 * If set to 1, it indicates that the supported link speeds
+	 * configuration on the port has changed.
+	 * If set to 0, then there is no change in supported link speeds
+	 * configuration.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_EVENT_DATA1_SUPPORTED_LINK_SPEEDS_CHANGE	UINT32_C(0x10000)
+	/*
+	 * If set to 1, it indicates that the link speed configuration
+	 * on the port has become illegal or invalid.
+	 * If set to 0, then the link speed configuration on the port is
+	 * legal or valid.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_LINK_SPEED_CFG_CHANGE_EVENT_DATA1_ILLEGAL_LINK_SPEED_CFG	UINT32_C(0x20000)
+} hwrm_async_event_cmpl_link_speed_cfg_change_t, *phwrm_async_event_cmpl_link_speed_cfg_change_t;
 
-/* hwrm_async_event_cmpl_phc_master (size:128b/16B) */
+/* hwrm_async_event_cmpl_port_phy_cfg_change (size:128b/16B) */
 
-typedef struct hwrm_async_event_cmpl_phc_master {
+typedef struct hwrm_async_event_cmpl_port_phy_cfg_change {
 	uint16_t	type;
 	/*
 	 * This field indicates the exact type of the completion.
@@ -9493,20 +10295,16 @@ typedef struct hwrm_async_event_cmpl_phc_master {
 	 * records. Odd values indicate 32B
 	 * records.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_PHC_MASTER_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_PHC_MASTER_TYPE_SFT		0
+	#define HWRM_ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_TYPE_SFT		0
 	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_PHC_MASTER_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_PHC_MASTER_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_PHC_MASTER_TYPE_HWRM_ASYNC_EVENT
+		#define HWRM_ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_TYPE_HWRM_ASYNC_EVENT
 	/* Identifiers of events. */
 	uint16_t	event_id;
-	/*
-	 * This async event is used to notify driver of changes
-	 * in PHC master. Only one master function can configure
-	 * PHC.
-	 */
-	#define HWRM_ASYNC_EVENT_CMPL_PHC_MASTER_EVENT_ID_PHC_MASTER UINT32_C(0x43)
-	#define HWRM_ASYNC_EVENT_CMPL_PHC_MASTER_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_PHC_MASTER_EVENT_ID_PHC_MASTER
+	/* Port PHY configuration change */
+	#define HWRM_ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_EVENT_ID_PORT_PHY_CFG_CHANGE UINT32_C(0x7)
+	#define HWRM_ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_EVENT_ID_LAST		HWRM_ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_EVENT_ID_PORT_PHY_CFG_CHANGE
 	/* Event specific data */
 	uint32_t	event_data2;
 	uint8_t	opaque_v;
@@ -9515,43 +10313,44 @@ typedef struct hwrm_async_event_cmpl_phc_master {
 	 * for each pass through the completion queue. The even passes
 	 * will write 1. The odd passes will write 0.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_PHC_MASTER_V	UINT32_C(0x1)
+	#define HWRM_ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_V	UINT32_C(0x1)
 	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_PHC_MASTER_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_PHC_MASTER_OPAQUE_SFT 1
-	/* 8-lsb timestamp (100-msec resolution) */
+	#define HWRM_ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_OPAQUE_SFT 1
+	/* 8-lsb timestamp from POR (100-msec resolution) */
 	uint8_t	timestamp_lo;
-	/* 16-lsb timestamp (100-msec resolution) */
+	/* 16-lsb timestamp from POR (100-msec resolution) */
 	uint16_t	timestamp_hi;
 	/* Event specific data */
 	uint32_t	event_data1;
-	/* Indicates driver action requested */
-	#define HWRM_ASYNC_EVENT_CMPL_PHC_MASTER_EVENT_DATA1_FLAGS_MASK		UINT32_C(0xff)
-	#define HWRM_ASYNC_EVENT_CMPL_PHC_MASTER_EVENT_DATA1_FLAGS_SFT		0
+	/* PORT ID */
+	#define HWRM_ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_EVENT_DATA1_PORT_ID_MASK	UINT32_C(0xffff)
+	#define HWRM_ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_EVENT_DATA1_PORT_ID_SFT	0
 	/*
-	 * If set to 1, this function is selected as Master function.
-	 * A function is selected as PHC master if it's the first one
-	 * that tries to configure PHC.
-	 * If set to 0, this function is not the Master.
-	 * If master_selected is set to 1, driver should prevent PHC
-	 * configuration requests from being sent down. Firmware will
-	 * reject requests from this non-master.
+	 * If set to 1, it indicates that the FEC
+	 * configuration on the port has changed.
+	 * If set to 0, then there is no change in FEC configuration.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_PHC_MASTER_EVENT_DATA1_FLAGS_MASTER_FUNC	UINT32_C(0x1)
+	#define HWRM_ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_EVENT_DATA1_FEC_CFG_CHANGE	UINT32_C(0x10000)
 	/*
-	 * If set to 1, indicates that PHC Master has been selected.
-	 * If set to 0, indicates that PHC Master has not been selected
-	 * yet.
-	 * Since no PHC Master is selected, it indicates to driver that
-	 * any function can send down PHC configuration requests and
-	 * consequently become the PHC Master.
-	 */
-	#define HWRM_ASYNC_EVENT_CMPL_PHC_MASTER_EVENT_DATA1_FLAGS_MASTER_SELECTED	UINT32_C(0x2)
-} hwrm_async_event_cmpl_phc_master_t, *phwrm_async_event_cmpl_phc_master_t;
-
-/* hwrm_async_event_cmpl_pps_timestamp (size:128b/16B) */
+	 * If set to 1, it indicates that the EEE configuration
+	 * on the port has changed.
+	 * If set to 0, then there is no change in EEE configuration
+	 * on the port.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_EVENT_DATA1_EEE_CFG_CHANGE	UINT32_C(0x20000)
+	/*
+	 * If set to 1, it indicates that the pause configuration
+	 * on the PHY has changed.
+	 * If set to 0, then there is no change in the pause
+	 * configuration on the PHY.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_PORT_PHY_CFG_CHANGE_EVENT_DATA1_PAUSE_CFG_CHANGE	UINT32_C(0x40000)
+} hwrm_async_event_cmpl_port_phy_cfg_change_t, *phwrm_async_event_cmpl_port_phy_cfg_change_t;
 
-typedef struct hwrm_async_event_cmpl_pps_timestamp {
+/* hwrm_async_event_cmpl_reset_notify (size:128b/16B) */
+
+typedef struct hwrm_async_event_cmpl_reset_notify {
 	uint16_t	type;
 	/*
 	 * This field indicates the exact type of the completion.
@@ -9560,68 +10359,160 @@ typedef struct hwrm_async_event_cmpl_pps_timestamp {
 	 * records. Odd values indicate 32B
 	 * records.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_TYPE_SFT		0
+	#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_TYPE_SFT		0
 	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_TYPE_HWRM_ASYNC_EVENT
+		#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_TYPE_HWRM_ASYNC_EVENT
 	/* Identifiers of events. */
 	uint16_t	event_id;
+	/* Notify clients of imminent reset. */
+	#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_ID_RESET_NOTIFY UINT32_C(0x8)
+	#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_ID_RESET_NOTIFY
+	/* Event specific data. The data is for internal debug use only. */
+	uint32_t	event_data2;
 	/*
-	 * This async notification message can be used to inform
-	 * driver of the latest PPS timestamp that has been latched.
-	 * When driver enables PPS event, Firmware will generate
-	 * PPS timestamps every second, Firmware informs driver
-	 * of this timestamp through the async event.
+	 * These bits indicate the status as being reported by the firmware.
+	 * This value is exactly the same as status code in fw_status register.
+	 * If the status code is equal to 0x8000, then the reset is initiated
+	 * by the Host using the FW_RESET command when the FW is in a healthy
+	 * state. If the status code is not equal to 0x8000, then the reset is
+	 * initiated by the FW to recover from the error or FATAL state.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_EVENT_ID_PPS_TIMESTAMP UINT32_C(0x44)
-	#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_EVENT_ID_PPS_TIMESTAMP
+	#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA2_FW_STATUS_CODE_MASK UINT32_C(0xffff)
+	#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA2_FW_STATUS_CODE_SFT 0
+	uint8_t	opaque_v;
+	/*
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_OPAQUE_SFT 1
+	/*
+	 * 8-lsb timestamp (100-msec resolution)
+	 * The Minimum time required for the Firmware readiness after sending
+	 * this notification to the driver instances.
+	 */
+	uint8_t	timestamp_lo;
+	/*
+	 * 16-lsb timestamp (100-msec resolution)
+	 * The Maximum Firmware Reset bail out value in the order of 100
+	 * milliseconds. The driver instances will use this value to reinitiate
+	 * the registration process again if the core firmware didn't set the
+	 * state bit.
+	 */
+	uint16_t	timestamp_hi;
 	/* Event specific data */
-	uint32_t	event_data2;
-	/* Indicates the PPS event type */
-	#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_EVENT_DATA2_EVENT_TYPE		UINT32_C(0x1)
-	/* This is an internal event. */
-		#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_EVENT_DATA2_EVENT_TYPE_INTERNAL	UINT32_C(0x0)
-	/* This is an external event. */
-		#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_EVENT_DATA2_EVENT_TYPE_EXTERNAL	UINT32_C(0x1)
-		#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_EVENT_DATA2_EVENT_TYPE_LAST	HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_EVENT_DATA2_EVENT_TYPE_EXTERNAL
+	uint32_t	event_data1;
+	/* Indicates driver action requested */
+	#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_DRIVER_ACTION_MASK		UINT32_C(0xff)
+	#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_DRIVER_ACTION_SFT		0
 	/*
-	 * Indicates the pin number on which the event is
-	 * received.
+	 * If set to 1, it indicates that the l2 client should
+	 * stop sending in band traffic to Nitro.
+	 * if set to 0, there is no change in L2 client behavior.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_EVENT_DATA2_PIN_NUMBER_MASK	UINT32_C(0xe)
-	#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_EVENT_DATA2_PIN_NUMBER_SFT	1
+		#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_DRIVER_ACTION_DRIVER_STOP_TX_QUEUE	UINT32_C(0x1)
 	/*
-	 * Contains bits[47:32] of the upper PPS timestamp.
-	 * Lower 32 bits are in event_data1. Together they
-	 * provide the 48 bit PPS timestamp.
+	 * If set to 1, it indicates that the L2 client should
+	 * bring down the interface.
+	 * If set to 0, then there is no change in L2 client behavior.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_EVENT_DATA2_PPS_TIMESTAMP_UPPER_MASK UINT32_C(0xffff0)
-	#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_EVENT_DATA2_PPS_TIMESTAMP_UPPER_SFT 4
+		#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_DRIVER_ACTION_DRIVER_IFDOWN	UINT32_C(0x2)
+		#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_DRIVER_ACTION_LAST		HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_DRIVER_ACTION_DRIVER_IFDOWN
+	/* Indicates reason for reset. */
+	#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_MASK			UINT32_C(0xff00)
+	#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_SFT			8
+	/* A management client has requested reset. */
+		#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_MANAGEMENT_RESET_REQUEST  (UINT32_C(0x1) << 8)
+	/* A fatal firmware exception has occurred. */
+		#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_FW_EXCEPTION_FATAL	(UINT32_C(0x2) << 8)
+	/* A non-fatal firmware exception has occurred. */
+		#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_FW_EXCEPTION_NON_FATAL	(UINT32_C(0x3) << 8)
+	/* Fast reset */
+		#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_FAST_RESET		(UINT32_C(0x4) << 8)
+	/*
+	 * Reset was a result of a firmware activation. That is, the
+	 * fw_activation flag was set in a FW_RESET operation.
+	 */
+		#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_FW_ACTIVATION		(UINT32_C(0x5) << 8)
+		#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_LAST			HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_FW_ACTIVATION
+	/*
+	 * Minimum time before driver should attempt access - units 100ms
+	 * ticks.
+	 * Range 0-65535
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_DELAY_IN_100MS_TICKS_MASK	UINT32_C(0xffff0000)
+	#define HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_DELAY_IN_100MS_TICKS_SFT		16
+} hwrm_async_event_cmpl_reset_notify_t, *phwrm_async_event_cmpl_reset_notify_t;
+
+/* hwrm_async_event_cmpl_error_recovery (size:128b/16B) */
+
+typedef struct hwrm_async_event_cmpl_error_recovery {
+	uint16_t	type;
+	/*
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
+	/*
+	 * This async notification message can be used for selecting or
+	 * deselecting master function for error recovery,
+	 * and to communicate to all the functions whether error recovery
+	 * was enabled/disabled.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_EVENT_ID_ERROR_RECOVERY UINT32_C(0x9)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_EVENT_ID_ERROR_RECOVERY
+	/* Event specific data */
+	uint32_t	event_data2;
 	uint8_t	opaque_v;
 	/*
 	 * This value is written by the NIC such that it will be different
 	 * for each pass through the completion queue. The even passes
 	 * will write 1. The odd passes will write 0.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_V	UINT32_C(0x1)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_V	UINT32_C(0x1)
 	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_OPAQUE_SFT 1
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_OPAQUE_SFT 1
 	/* 8-lsb timestamp (100-msec resolution) */
 	uint8_t	timestamp_lo;
 	/* 16-lsb timestamp (100-msec resolution) */
 	uint16_t	timestamp_hi;
-	/* Contains the lower 32 bits of the PPS timestamp. */
+	/* Event specific data */
 	uint32_t	event_data1;
-	/* Contains the lower 32 bit PPS timestamp */
-	#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_EVENT_DATA1_PPS_TIMESTAMP_LOWER_MASK UINT32_C(0xffffffff)
-	#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_EVENT_DATA1_PPS_TIMESTAMP_LOWER_SFT 0
-} hwrm_async_event_cmpl_pps_timestamp_t, *phwrm_async_event_cmpl_pps_timestamp_t;
+	/* Indicates driver action requested */
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_EVENT_DATA1_FLAGS_MASK		UINT32_C(0xff)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_EVENT_DATA1_FLAGS_SFT		0
+	/*
+	 * If set to 1, this function is selected as Master function.
+	 * This function has responsibility to do 'chip reset' when it
+	 * detects a fatal error. If set to 0, master function functionality
+	 * is disabled on this function.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_EVENT_DATA1_FLAGS_MASTER_FUNC	UINT32_C(0x1)
+	/*
+	 * If set to 1, error recovery is enabled.
+	 * If set to 0, error recovery is disabled.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_EVENT_DATA1_FLAGS_RECOVERY_ENABLED	UINT32_C(0x2)
+} hwrm_async_event_cmpl_error_recovery_t, *phwrm_async_event_cmpl_error_recovery_t;
 
-/* hwrm_async_event_cmpl_fw_trace_msg (size:128b/16B) */
+/* hwrm_async_event_cmpl_ring_monitor_msg (size:128b/16B) */
 
-typedef struct hwrm_async_event_cmpl_fw_trace_msg {
+typedef struct hwrm_async_event_cmpl_ring_monitor_msg {
 	uint16_t	type;
 	/*
 	 * This field indicates the exact type of the completion.
@@ -9630,83 +10521,52 @@ typedef struct hwrm_async_event_cmpl_fw_trace_msg {
 	 * records. Odd values indicate 32B
 	 * records.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TYPE_SFT		0
+	#define HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_TYPE_SFT		0
 	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TYPE_HWRM_ASYNC_EVENT
+		#define HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_TYPE_HWRM_ASYNC_EVENT
 	/* Identifiers of events. */
 	uint16_t	event_id;
-	/* Firmware trace log message */
-	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_ID_FW_TRACE_MSG UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_ID_FW_TRACE_MSG
-	/* Trace byte 0 to 3 */
+	/* Ring Monitor Message. */
+	#define HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_EVENT_ID_RING_MONITOR_MSG UINT32_C(0xa)
+	#define HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_EVENT_ID_LAST		HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_EVENT_ID_RING_MONITOR_MSG
+	/* Event specific data */
 	uint32_t	event_data2;
-	/* Trace byte0 */
-	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_DATA2_BYTE0_MASK UINT32_C(0xff)
-	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_DATA2_BYTE0_SFT 0
-	/* Trace byte1 */
-	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_DATA2_BYTE1_MASK UINT32_C(0xff00)
-	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_DATA2_BYTE1_SFT 8
-	/* Trace byte2 */
-	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_DATA2_BYTE2_MASK UINT32_C(0xff0000)
-	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_DATA2_BYTE2_SFT 16
-	/* Trace byte3 */
-	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_DATA2_BYTE3_MASK UINT32_C(0xff000000)
-	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_DATA2_BYTE3_SFT 24
+	/* Type of Ring disabled. */
+	#define HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_EVENT_DATA2_DISABLE_RING_TYPE_MASK UINT32_C(0xff)
+	#define HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_EVENT_DATA2_DISABLE_RING_TYPE_SFT 0
+	/* tx ring disabled. */
+		#define HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_EVENT_DATA2_DISABLE_RING_TYPE_TX	UINT32_C(0x0)
+	/* rx ring disabled. */
+		#define HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_EVENT_DATA2_DISABLE_RING_TYPE_RX	UINT32_C(0x1)
+	/* cmpl ring disabled. */
+		#define HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_EVENT_DATA2_DISABLE_RING_TYPE_CMPL  UINT32_C(0x2)
+		#define HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_EVENT_DATA2_DISABLE_RING_TYPE_LAST HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_EVENT_DATA2_DISABLE_RING_TYPE_CMPL
 	uint8_t	opaque_v;
 	/*
 	 * This value is written by the NIC such that it will be different
 	 * for each pass through the completion queue. The even passes
 	 * will write 1. The odd passes will write 0.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_V	UINT32_C(0x1)
+	#define HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_V	UINT32_C(0x1)
 	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_OPAQUE_SFT 1
-	/* Trace flags */
+	#define HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_RING_MONITOR_MSG_OPAQUE_SFT 1
+	/* 8-lsb timestamp from POR (100-msec resolution) */
 	uint8_t	timestamp_lo;
-	/* Indicates if the string is partial or complete. */
-	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TIMESTAMP_LO_STRING		UINT32_C(0x1)
-	/* Complete string */
-		#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TIMESTAMP_LO_STRING_COMPLETE	UINT32_C(0x0)
-	/* Partial string */
-		#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TIMESTAMP_LO_STRING_PARTIAL	UINT32_C(0x1)
-		#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TIMESTAMP_LO_STRING_LAST	HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TIMESTAMP_LO_STRING_PARTIAL
-	/* Indicates the firmware that sent the trace message. */
-	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TIMESTAMP_LO_FIRMWARE	UINT32_C(0x2)
-	/* Primary firmware */
-		#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TIMESTAMP_LO_FIRMWARE_PRIMARY	(UINT32_C(0x0) << 1)
-	/* Secondary firmware */
-		#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TIMESTAMP_LO_FIRMWARE_SECONDARY  (UINT32_C(0x1) << 1)
-		#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TIMESTAMP_LO_FIRMWARE_LAST	HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TIMESTAMP_LO_FIRMWARE_SECONDARY
-	/* Trace byte 4 to 5 */
+	/* 16-lsb timestamp from POR (100-msec resolution) */
 	uint16_t	timestamp_hi;
-	/* Trace byte4 */
-	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TIMESTAMP_HI_BYTE4_MASK UINT32_C(0xff)
-	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TIMESTAMP_HI_BYTE4_SFT 0
-	/* Trace byte5 */
-	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TIMESTAMP_HI_BYTE5_MASK UINT32_C(0xff00)
-	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TIMESTAMP_HI_BYTE5_SFT 8
-	/* Trace byte 6 to 9 */
+	/*
+	 * Event specific data. If ring_type_disabled indicates a tx, rx or cmpl
+	 * then this field will indicate the ring id.
+	 */
 	uint32_t	event_data1;
-	/* Trace byte6 */
-	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_DATA1_BYTE6_MASK UINT32_C(0xff)
-	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_DATA1_BYTE6_SFT 0
-	/* Trace byte7 */
-	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_DATA1_BYTE7_MASK UINT32_C(0xff00)
-	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_DATA1_BYTE7_SFT 8
-	/* Trace byte8 */
-	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_DATA1_BYTE8_MASK UINT32_C(0xff0000)
-	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_DATA1_BYTE8_SFT 16
-	/* Trace byte9 */
-	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_DATA1_BYTE9_MASK UINT32_C(0xff000000)
-	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_DATA1_BYTE9_SFT 24
-} hwrm_async_event_cmpl_fw_trace_msg_t, *phwrm_async_event_cmpl_fw_trace_msg_t;
+} hwrm_async_event_cmpl_ring_monitor_msg_t, *phwrm_async_event_cmpl_ring_monitor_msg_t;
 
-/* hwrm_async_event_cmpl_hwrm_error (size:128b/16B) */
+/* hwrm_async_event_cmpl_func_drvr_unload (size:128b/16B) */
 
-typedef struct hwrm_async_event_cmpl_hwrm_error {
+typedef struct hwrm_async_event_cmpl_func_drvr_unload {
 	uint16_t	type;
 	/*
 	 * This field indicates the exact type of the completion.
@@ -9715,2493 +10575,3592 @@ typedef struct hwrm_async_event_cmpl_hwrm_error {
 	 * records. Odd values indicate 32B
 	 * records.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_TYPE_MASK		UINT32_C(0x3f)
-	#define HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_TYPE_SFT		0
+	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_UNLOAD_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_UNLOAD_TYPE_SFT		0
 	/* HWRM Asynchronous Event Information */
-		#define HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
-		#define HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_TYPE_HWRM_ASYNC_EVENT
+		#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_UNLOAD_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_UNLOAD_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_UNLOAD_TYPE_HWRM_ASYNC_EVENT
 	/* Identifiers of events. */
 	uint16_t	event_id;
-	/* HWRM Error */
-	#define HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_EVENT_ID_HWRM_ERROR UINT32_C(0xff)
-	#define HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_EVENT_ID_HWRM_ERROR
+	/* Function driver unloaded */
+	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_UNLOAD_EVENT_ID_FUNC_DRVR_UNLOAD UINT32_C(0x10)
+	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_UNLOAD_EVENT_ID_LAST		HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_UNLOAD_EVENT_ID_FUNC_DRVR_UNLOAD
 	/* Event specific data */
 	uint32_t	event_data2;
-	/* Severity of HWRM Error */
-	#define HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_EVENT_DATA2_SEVERITY_MASK	UINT32_C(0xff)
-	#define HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_EVENT_DATA2_SEVERITY_SFT	0
-	/* Warning */
-		#define HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_EVENT_DATA2_SEVERITY_WARNING   UINT32_C(0x0)
-	/* Non-fatal Error */
-		#define HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_EVENT_DATA2_SEVERITY_NONFATAL  UINT32_C(0x1)
-	/* Fatal Error */
-		#define HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_EVENT_DATA2_SEVERITY_FATAL	UINT32_C(0x2)
-		#define HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_EVENT_DATA2_SEVERITY_LAST	HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_EVENT_DATA2_SEVERITY_FATAL
 	uint8_t	opaque_v;
 	/*
 	 * This value is written by the NIC such that it will be different
 	 * for each pass through the completion queue. The even passes
 	 * will write 1. The odd passes will write 0.
 	 */
-	#define HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_V	UINT32_C(0x1)
+	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_UNLOAD_V	UINT32_C(0x1)
 	/* opaque is 7 b */
-	#define HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_OPAQUE_MASK UINT32_C(0xfe)
-	#define HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_OPAQUE_SFT 1
+	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_UNLOAD_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_UNLOAD_OPAQUE_SFT 1
 	/* 8-lsb timestamp from POR (100-msec resolution) */
 	uint8_t	timestamp_lo;
 	/* 16-lsb timestamp from POR (100-msec resolution) */
 	uint16_t	timestamp_hi;
 	/* Event specific data */
 	uint32_t	event_data1;
-	/* Time stamp for error event */
-	#define HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_EVENT_DATA1_TIMESTAMP	UINT32_C(0x1)
-} hwrm_async_event_cmpl_hwrm_error_t, *phwrm_async_event_cmpl_hwrm_error_t;
+	/* Function ID */
+	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_UNLOAD_EVENT_DATA1_FUNC_ID_MASK UINT32_C(0xffff)
+	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_UNLOAD_EVENT_DATA1_FUNC_ID_SFT 0
+} hwrm_async_event_cmpl_func_drvr_unload_t, *phwrm_async_event_cmpl_func_drvr_unload_t;
 
-/* metadata_base_msg (size:64b/8B) */
+/* hwrm_async_event_cmpl_func_drvr_load (size:128b/16B) */
 
-typedef struct metadata_base_msg {
-	uint16_t	md_type_link;
-	/* This field classifies the data present in the meta-data. */
-	#define METADATA_BASE_MSG_MD_TYPE_MASK	UINT32_C(0x1f)
-	#define METADATA_BASE_MSG_MD_TYPE_SFT	0
-	/* Meta data fields are not valid */
-		#define METADATA_BASE_MSG_MD_TYPE_NONE	UINT32_C(0x0)
-	/*
-	 * This setting is used when packets are coming in-order. Depending on
-	 * the state of the receive context, the meta-data will carry different
-	 * information.
-	 */
-		#define METADATA_BASE_MSG_MD_TYPE_TLS_INSYNC  UINT32_C(0x1)
+typedef struct hwrm_async_event_cmpl_func_drvr_load {
+	uint16_t	type;
 	/*
-	 * With this setting HW passes the TCP sequence number of the TLS
-	 * record that it is requesting a resync on in the meta data.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-		#define METADATA_BASE_MSG_MD_TYPE_TLS_RESYNC  UINT32_C(0x2)
-		#define METADATA_BASE_MSG_MD_TYPE_LAST	METADATA_BASE_MSG_MD_TYPE_TLS_RESYNC
+	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_LOAD_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_LOAD_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_LOAD_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_LOAD_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_LOAD_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
+	/* Function driver loaded */
+	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_LOAD_EVENT_ID_FUNC_DRVR_LOAD UINT32_C(0x11)
+	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_LOAD_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_LOAD_EVENT_ID_FUNC_DRVR_LOAD
+	/* Event specific data */
+	uint32_t	event_data2;
+	uint8_t	opaque_v;
 	/*
-	 * This field indicates where the next metadata block starts. It is
-	 * counted in 16B units. A value of zero indicates that there is no
-	 * metadata.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	#define METADATA_BASE_MSG_LINK_MASK	UINT32_C(0x1e0)
-	#define METADATA_BASE_MSG_LINK_SFT	5
-	uint16_t	unused0;
-	uint32_t	unused1;
-} metadata_base_msg_t, *pmetadata_base_msg_t;
+	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_LOAD_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_LOAD_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_LOAD_OPAQUE_SFT 1
+	/* 8-lsb timestamp from POR (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp from POR (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data */
+	uint32_t	event_data1;
+	/* Function ID */
+	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_LOAD_EVENT_DATA1_FUNC_ID_MASK UINT32_C(0xffff)
+	#define HWRM_ASYNC_EVENT_CMPL_FUNC_DRVR_LOAD_EVENT_DATA1_FUNC_ID_SFT 0
+} hwrm_async_event_cmpl_func_drvr_load_t, *phwrm_async_event_cmpl_func_drvr_load_t;
 
-/* tls_metadata_base_msg (size:64b/8B) */
+/* hwrm_async_event_cmpl_func_flr_proc_cmplt (size:128b/16B) */
 
-typedef struct tls_metadata_base_msg {
-	uint32_t	md_type_link_flags_kid_lo;
-	/* This field classifies the data present in the meta-data. */
-	#define TLS_METADATA_BASE_MSG_MD_TYPE_MASK		UINT32_C(0x1f)
-	#define TLS_METADATA_BASE_MSG_MD_TYPE_SFT		0
+typedef struct hwrm_async_event_cmpl_func_flr_proc_cmplt {
+	uint16_t	type;
 	/*
-	 * This setting is used when packets are coming in-order. Depending on
-	 * the state of the receive context, the meta-data will carry different
-	 * information.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-		#define TLS_METADATA_BASE_MSG_MD_TYPE_TLS_INSYNC		UINT32_C(0x1)
+	#define HWRM_ASYNC_EVENT_CMPL_FUNC_FLR_PROC_CMPLT_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_FUNC_FLR_PROC_CMPLT_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_FUNC_FLR_PROC_CMPLT_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_FUNC_FLR_PROC_CMPLT_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_FUNC_FLR_PROC_CMPLT_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
+	/* Function FLR related processing has completed */
+	#define HWRM_ASYNC_EVENT_CMPL_FUNC_FLR_PROC_CMPLT_EVENT_ID_FUNC_FLR_PROC_CMPLT UINT32_C(0x12)
+	#define HWRM_ASYNC_EVENT_CMPL_FUNC_FLR_PROC_CMPLT_EVENT_ID_LAST		HWRM_ASYNC_EVENT_CMPL_FUNC_FLR_PROC_CMPLT_EVENT_ID_FUNC_FLR_PROC_CMPLT
+	/* Event specific data */
+	uint32_t	event_data2;
+	uint8_t	opaque_v;
 	/*
-	 * With this setting HW passes the TCP sequence number of the TLS
-	 * record that it is requesting a resync on in the meta data.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-		#define TLS_METADATA_BASE_MSG_MD_TYPE_TLS_RESYNC		UINT32_C(0x2)
-		#define TLS_METADATA_BASE_MSG_MD_TYPE_LAST		TLS_METADATA_BASE_MSG_MD_TYPE_TLS_RESYNC
+	#define HWRM_ASYNC_EVENT_CMPL_FUNC_FLR_PROC_CMPLT_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_FUNC_FLR_PROC_CMPLT_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_FUNC_FLR_PROC_CMPLT_OPAQUE_SFT 1
+	/* 8-lsb timestamp from POR (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp from POR (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data */
+	uint32_t	event_data1;
+	/* Function ID */
+	#define HWRM_ASYNC_EVENT_CMPL_FUNC_FLR_PROC_CMPLT_EVENT_DATA1_FUNC_ID_MASK UINT32_C(0xffff)
+	#define HWRM_ASYNC_EVENT_CMPL_FUNC_FLR_PROC_CMPLT_EVENT_DATA1_FUNC_ID_SFT 0
+} hwrm_async_event_cmpl_func_flr_proc_cmplt_t, *phwrm_async_event_cmpl_func_flr_proc_cmplt_t;
+
+/* hwrm_async_event_cmpl_pf_drvr_unload (size:128b/16B) */
+
+typedef struct hwrm_async_event_cmpl_pf_drvr_unload {
+	uint16_t	type;
 	/*
-	 * This field indicates where the next metadata block starts. It is
-	 * counted in 16B units. A value of zero indicates that there is no
-	 * metadata.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	#define TLS_METADATA_BASE_MSG_LINK_MASK			UINT32_C(0x1e0)
-	#define TLS_METADATA_BASE_MSG_LINK_SFT			5
-	/* These are flags present in the metadata. */
-	#define TLS_METADATA_BASE_MSG_FLAGS_MASK		UINT32_C(0x1fffe00)
-	#define TLS_METADATA_BASE_MSG_FLAGS_SFT			9
+	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_UNLOAD_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_UNLOAD_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_UNLOAD_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_UNLOAD_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_PF_DRVR_UNLOAD_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
+	/* PF driver unloaded */
+	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_UNLOAD_EVENT_ID_PF_DRVR_UNLOAD UINT32_C(0x20)
+	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_UNLOAD_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_PF_DRVR_UNLOAD_EVENT_ID_PF_DRVR_UNLOAD
+	/* Event specific data */
+	uint32_t	event_data2;
+	uint8_t	opaque_v;
 	/*
-	 * A value of 1 implies that the packet was decrypted by HW. Otherwise
-	 * the packet is passed on as it came in on the wire.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	#define TLS_METADATA_BASE_MSG_FLAGS_DECRYPTED		UINT32_C(0x200)
+	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_UNLOAD_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_UNLOAD_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_UNLOAD_OPAQUE_SFT 1
+	/* 8-lsb timestamp from POR (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp from POR (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data */
+	uint32_t	event_data1;
+	/* PF ID */
+	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_UNLOAD_EVENT_DATA1_FUNC_ID_MASK UINT32_C(0xffff)
+	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_UNLOAD_EVENT_DATA1_FUNC_ID_SFT 0
+	/* Indicates the physical port this pf belongs to */
+	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_UNLOAD_EVENT_DATA1_PORT_MASK   UINT32_C(0x70000)
+	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_UNLOAD_EVENT_DATA1_PORT_SFT	16
+} hwrm_async_event_cmpl_pf_drvr_unload_t, *phwrm_async_event_cmpl_pf_drvr_unload_t;
+
+/* hwrm_async_event_cmpl_pf_drvr_load (size:128b/16B) */
+
+typedef struct hwrm_async_event_cmpl_pf_drvr_load {
+	uint16_t	type;
 	/*
-	 * This field indicates the state of the ghash field passed in the
-	 * meta-data.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	#define TLS_METADATA_BASE_MSG_FLAGS_GHASH_MASK		UINT32_C(0xc00)
-	#define TLS_METADATA_BASE_MSG_FLAGS_GHASH_SFT		10
+	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_LOAD_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_LOAD_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_LOAD_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_LOAD_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_PF_DRVR_LOAD_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
+	/* PF driver loaded */
+	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_LOAD_EVENT_ID_PF_DRVR_LOAD UINT32_C(0x21)
+	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_LOAD_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_PF_DRVR_LOAD_EVENT_ID_PF_DRVR_LOAD
+	/* Event specific data */
+	uint32_t	event_data2;
+	uint8_t	opaque_v;
 	/*
-	 * This enumeration states that the ghash is not valid in the
-	 * meta-data.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-		#define TLS_METADATA_BASE_MSG_FLAGS_GHASH_NOT_VALID	(UINT32_C(0x0) << 10)
+	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_LOAD_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_LOAD_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_LOAD_OPAQUE_SFT 1
+	/* 8-lsb timestamp from POR (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp from POR (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data */
+	uint32_t	event_data1;
+	/* PF ID */
+	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_LOAD_EVENT_DATA1_FUNC_ID_MASK UINT32_C(0xffff)
+	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_LOAD_EVENT_DATA1_FUNC_ID_SFT 0
+	/* Indicates the physical port this pf belongs to */
+	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_LOAD_EVENT_DATA1_PORT_MASK   UINT32_C(0x70000)
+	#define HWRM_ASYNC_EVENT_CMPL_PF_DRVR_LOAD_EVENT_DATA1_PORT_SFT	16
+} hwrm_async_event_cmpl_pf_drvr_load_t, *phwrm_async_event_cmpl_pf_drvr_load_t;
+
+/* hwrm_async_event_cmpl_vf_flr (size:128b/16B) */
+
+typedef struct hwrm_async_event_cmpl_vf_flr {
+	uint16_t	type;
 	/*
-	 * This enumeration indicates that this pkt contains the record's
-	 * tag and this pkt was received ooo, the partial_ghash field
-	 * contains the ghash.
-	 */
-		#define TLS_METADATA_BASE_MSG_FLAGS_GHASH_CUR_REC		(UINT32_C(0x1) << 10)
-	/*
-	 * This enumeration indicates that the current record's tag wasn't
-	 * seen and the chip is moving on to the next record, the
-	 * partial_ghash field contains the ghash.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-		#define TLS_METADATA_BASE_MSG_FLAGS_GHASH_PRIOR_REC	(UINT32_C(0x2) << 10)
-		#define TLS_METADATA_BASE_MSG_FLAGS_GHASH_LAST		TLS_METADATA_BASE_MSG_FLAGS_GHASH_PRIOR_REC
-	/* This field indicates the status of tag authentication. */
-	#define TLS_METADATA_BASE_MSG_FLAGS_TAG_AUTH_STATUS_MASK	UINT32_C(0x3000)
-	#define TLS_METADATA_BASE_MSG_FLAGS_TAG_AUTH_STATUS_SFT	12
+	#define HWRM_ASYNC_EVENT_CMPL_VF_FLR_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_VF_FLR_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_VF_FLR_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_VF_FLR_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_VF_FLR_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
+	/* VF Function Level Reset (FLR) */
+	#define HWRM_ASYNC_EVENT_CMPL_VF_FLR_EVENT_ID_VF_FLR UINT32_C(0x30)
+	#define HWRM_ASYNC_EVENT_CMPL_VF_FLR_EVENT_ID_LAST  HWRM_ASYNC_EVENT_CMPL_VF_FLR_EVENT_ID_VF_FLR
+	/* Event specific data */
+	uint32_t	event_data2;
+	uint8_t	opaque_v;
 	/*
-	 * This enumeration is set when there is no tags present in the
-	 * packet.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-		#define TLS_METADATA_BASE_MSG_FLAGS_TAG_AUTH_STATUS_NONE	(UINT32_C(0x0) << 12)
+	#define HWRM_ASYNC_EVENT_CMPL_VF_FLR_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_VF_FLR_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_VF_FLR_OPAQUE_SFT 1
+	/* 8-lsb timestamp from POR (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp from POR (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data */
+	uint32_t	event_data1;
+	/* VF ID */
+	#define HWRM_ASYNC_EVENT_CMPL_VF_FLR_EVENT_DATA1_VF_ID_MASK UINT32_C(0xffff)
+	#define HWRM_ASYNC_EVENT_CMPL_VF_FLR_EVENT_DATA1_VF_ID_SFT 0
+	/* Indicates the physical function this event occurred on. */
+	#define HWRM_ASYNC_EVENT_CMPL_VF_FLR_EVENT_DATA1_PF_ID_MASK UINT32_C(0xff0000)
+	#define HWRM_ASYNC_EVENT_CMPL_VF_FLR_EVENT_DATA1_PF_ID_SFT 16
+} hwrm_async_event_cmpl_vf_flr_t, *phwrm_async_event_cmpl_vf_flr_t;
+
+/* hwrm_async_event_cmpl_vf_mac_addr_change (size:128b/16B) */
+
+typedef struct hwrm_async_event_cmpl_vf_mac_addr_change {
+	uint16_t	type;
 	/*
-	 * This enumeration states that there is at least one tag in the
-	 * packet and every tag is valid.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-		#define TLS_METADATA_BASE_MSG_FLAGS_TAG_AUTH_STATUS_SUCCESS   (UINT32_C(0x1) << 12)
+	#define HWRM_ASYNC_EVENT_CMPL_VF_MAC_ADDR_CHANGE_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_VF_MAC_ADDR_CHANGE_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_VF_MAC_ADDR_CHANGE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_VF_MAC_ADDR_CHANGE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_VF_MAC_ADDR_CHANGE_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
+	/* VF MAC Address Change */
+	#define HWRM_ASYNC_EVENT_CMPL_VF_MAC_ADDR_CHANGE_EVENT_ID_VF_MAC_ADDR_CHANGE UINT32_C(0x31)
+	#define HWRM_ASYNC_EVENT_CMPL_VF_MAC_ADDR_CHANGE_EVENT_ID_LAST		HWRM_ASYNC_EVENT_CMPL_VF_MAC_ADDR_CHANGE_EVENT_ID_VF_MAC_ADDR_CHANGE
+	/* Event specific data */
+	uint32_t	event_data2;
+	uint8_t	opaque_v;
 	/*
-	 * This enumeration states that there is at least one tag in the
-	 * packet and at least one of the tag is invalid. The entire packet
-	 * is sent decrypted to the host.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-		#define TLS_METADATA_BASE_MSG_FLAGS_TAG_AUTH_STATUS_FAILURE   (UINT32_C(0x2) << 12)
-		#define TLS_METADATA_BASE_MSG_FLAGS_TAG_AUTH_STATUS_LAST	TLS_METADATA_BASE_MSG_FLAGS_TAG_AUTH_STATUS_FAILURE
+	#define HWRM_ASYNC_EVENT_CMPL_VF_MAC_ADDR_CHANGE_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_VF_MAC_ADDR_CHANGE_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_VF_MAC_ADDR_CHANGE_OPAQUE_SFT 1
+	/* 8-lsb timestamp from POR (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp from POR (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data */
+	uint32_t	event_data1;
+	/* VF ID */
+	#define HWRM_ASYNC_EVENT_CMPL_VF_MAC_ADDR_CHANGE_EVENT_DATA1_VF_ID_MASK UINT32_C(0xffff)
+	#define HWRM_ASYNC_EVENT_CMPL_VF_MAC_ADDR_CHANGE_EVENT_DATA1_VF_ID_SFT 0
+} hwrm_async_event_cmpl_vf_mac_addr_change_t, *phwrm_async_event_cmpl_vf_mac_addr_change_t;
+
+/* hwrm_async_event_cmpl_pf_vf_comm_status_change (size:128b/16B) */
+
+typedef struct hwrm_async_event_cmpl_pf_vf_comm_status_change {
+	uint16_t	type;
 	/*
-	 * A value of 1 indicates that this packet contains a record that
-	 * starts in the packet and extends beyond the packet.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	#define TLS_METADATA_BASE_MSG_FLAGS_HEADER_FLDS_VALID	UINT32_C(0x4000)
+	#define HWRM_ASYNC_EVENT_CMPL_PF_VF_COMM_STATUS_CHANGE_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_PF_VF_COMM_STATUS_CHANGE_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_PF_VF_COMM_STATUS_CHANGE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_PF_VF_COMM_STATUS_CHANGE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_PF_VF_COMM_STATUS_CHANGE_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
+	/* PF-VF communication channel status change. */
+	#define HWRM_ASYNC_EVENT_CMPL_PF_VF_COMM_STATUS_CHANGE_EVENT_ID_PF_VF_COMM_STATUS_CHANGE UINT32_C(0x32)
+	#define HWRM_ASYNC_EVENT_CMPL_PF_VF_COMM_STATUS_CHANGE_EVENT_ID_LAST			HWRM_ASYNC_EVENT_CMPL_PF_VF_COMM_STATUS_CHANGE_EVENT_ID_PF_VF_COMM_STATUS_CHANGE
+	/* Event specific data */
+	uint32_t	event_data2;
+	uint8_t	opaque_v;
 	/*
-	 * This value indicates the lower 7-bit of the Crypto Key ID
-	 * associated with this operation.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	#define TLS_METADATA_BASE_MSG_KID_LO_MASK		UINT32_C(0xfe000000)
-	#define TLS_METADATA_BASE_MSG_KID_LO_SFT		25
-	uint16_t	kid_hi;
+	#define HWRM_ASYNC_EVENT_CMPL_PF_VF_COMM_STATUS_CHANGE_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_PF_VF_COMM_STATUS_CHANGE_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_PF_VF_COMM_STATUS_CHANGE_OPAQUE_SFT 1
+	/* 8-lsb timestamp from POR (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp from POR (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data */
+	uint32_t	event_data1;
 	/*
-	 * This value indicates the upper 13-bit of the Crypto Key ID
-	 * associated with this operation.
+	 * If this bit is set to 1, then it indicates that the PF-VF
+	 * communication was lost and it is established.
+	 * If this bit set to 0, then it indicates that the PF-VF
+	 * communication was established and it is lost.
 	 */
-	#define TLS_METADATA_BASE_MSG_KID_HI_MASK UINT32_C(0x1fff)
-	#define TLS_METADATA_BASE_MSG_KID_HI_SFT 0
-	uint16_t	unused0;
-} tls_metadata_base_msg_t, *ptls_metadata_base_msg_t;
+	#define HWRM_ASYNC_EVENT_CMPL_PF_VF_COMM_STATUS_CHANGE_EVENT_DATA1_COMM_ESTABLISHED	UINT32_C(0x1)
+} hwrm_async_event_cmpl_pf_vf_comm_status_change_t, *phwrm_async_event_cmpl_pf_vf_comm_status_change_t;
 
-/* tls_metadata_insync_msg (size:192b/24B) */
+/* hwrm_async_event_cmpl_vf_cfg_change (size:128b/16B) */
 
-typedef struct tls_metadata_insync_msg {
-	uint32_t	md_type_link_flags_kid_lo;
-	/* This field classifies the data present in the meta-data. */
-	#define TLS_METADATA_INSYNC_MSG_MD_TYPE_MASK		UINT32_C(0x1f)
-	#define TLS_METADATA_INSYNC_MSG_MD_TYPE_SFT		0
-	/*
-	 * This setting is used when packets are coming in-order. Depending on
-	 * the state of the receive context, the meta-data will carry different
-	 * information.
-	 */
-		#define TLS_METADATA_INSYNC_MSG_MD_TYPE_TLS_INSYNC		UINT32_C(0x1)
-		#define TLS_METADATA_INSYNC_MSG_MD_TYPE_LAST		TLS_METADATA_INSYNC_MSG_MD_TYPE_TLS_INSYNC
-	/*
-	 * This field indicates where the next metadata block starts. It is
-	 * counted in 16B units. A value of zero indicates that there is no
-	 * metadata.
-	 */
-	#define TLS_METADATA_INSYNC_MSG_LINK_MASK			UINT32_C(0x1e0)
-	#define TLS_METADATA_INSYNC_MSG_LINK_SFT			5
-	/* These are flags present in the metadata. */
-	#define TLS_METADATA_INSYNC_MSG_FLAGS_MASK		UINT32_C(0x1fffe00)
-	#define TLS_METADATA_INSYNC_MSG_FLAGS_SFT			9
+typedef struct hwrm_async_event_cmpl_vf_cfg_change {
+	uint16_t	type;
 	/*
-	 * A value of 1 implies that the packet was decrypted by HW. Otherwise
-	 * the packet is passed on as it came in on the wire.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	#define TLS_METADATA_INSYNC_MSG_FLAGS_DECRYPTED		UINT32_C(0x200)
+	#define HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
+	/* VF Configuration Change */
+	#define HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_EVENT_ID_VF_CFG_CHANGE UINT32_C(0x33)
+	#define HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_EVENT_ID_VF_CFG_CHANGE
+	/* Event specific data */
+	uint32_t	event_data2;
 	/*
-	 * This field indicates the state of the ghash field passed in the
-	 * meta-data.
+	 * This value indicates the VF ID of the VF whose configuration
+	 * is changing if this async. event is sent to the parent PF.
+	 * The firmware supports sending this to the parent PF if the
+	 * `hwrm_func_qcaps.vf_cfg_async_for_pf_supported` value is 1.
+	 * This value is undefined when the async. event is sent to the
+	 * VF.
 	 */
-	#define TLS_METADATA_INSYNC_MSG_FLAGS_GHASH_MASK		UINT32_C(0xc00)
-	#define TLS_METADATA_INSYNC_MSG_FLAGS_GHASH_SFT		10
+	#define HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_EVENT_DATA2_VF_ID_MASK UINT32_C(0xffff)
+	#define HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_EVENT_DATA2_VF_ID_SFT 0
+	uint8_t	opaque_v;
 	/*
-	 * This enumeration states that the ghash is not valid in the
-	 * meta-data.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-		#define TLS_METADATA_INSYNC_MSG_FLAGS_GHASH_NOT_VALID	(UINT32_C(0x0) << 10)
+	#define HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_OPAQUE_SFT 1
+	/* 8-lsb timestamp from POR (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp from POR (100-msec resolution) */
+	uint16_t	timestamp_hi;
 	/*
-	 * This enumeration indicates that this pkt contains the record's
-	 * tag and this pkt was received ooo, the partial_ghash field
-	 * contains the ghash.
+	 * Each flag provided in this field indicates a specific VF
+	 * configuration change. At least one of these flags shall be set to 1
+	 * when an asynchronous event completion of this type is provided
+	 * by the HWRM.
 	 */
-		#define TLS_METADATA_INSYNC_MSG_FLAGS_GHASH_CUR_REC		(UINT32_C(0x1) << 10)
+	uint32_t	event_data1;
 	/*
-	 * This enumeration indicates that the current record's tag wasn't
-	 * seen and the chip is moving on to the next record, the
-	 * partial_ghash field contains the ghash.
+	 * If this bit is set to 1, then the value of MTU
+	 * was changed on this VF.
+	 * If set to 0, then this bit should be ignored.
 	 */
-		#define TLS_METADATA_INSYNC_MSG_FLAGS_GHASH_PRIOR_REC	(UINT32_C(0x2) << 10)
-		#define TLS_METADATA_INSYNC_MSG_FLAGS_GHASH_LAST		TLS_METADATA_INSYNC_MSG_FLAGS_GHASH_PRIOR_REC
-	/* This field indicates the status of tag authentication. */
-	#define TLS_METADATA_INSYNC_MSG_FLAGS_TAG_AUTH_STATUS_MASK	UINT32_C(0x3000)
-	#define TLS_METADATA_INSYNC_MSG_FLAGS_TAG_AUTH_STATUS_SFT	12
+	#define HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_EVENT_DATA1_MTU_CHANGE		UINT32_C(0x1)
 	/*
-	 * This enumeration is set when there is no tags present in the
-	 * packet.
+	 * If this bit is set to 1, then the value of MRU
+	 * was changed on this VF.
+	 * If set to 0, then this bit should be ignored.
 	 */
-		#define TLS_METADATA_INSYNC_MSG_FLAGS_TAG_AUTH_STATUS_NONE	(UINT32_C(0x0) << 12)
+	#define HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_EVENT_DATA1_MRU_CHANGE		UINT32_C(0x2)
 	/*
-	 * This enumeration states that there is at least one tag in the
-	 * packet and every tag is valid.
+	 * If this bit is set to 1, then the value of default MAC
+	 * address was changed on this VF.
+	 * If set to 0, then this bit should be ignored.
 	 */
-		#define TLS_METADATA_INSYNC_MSG_FLAGS_TAG_AUTH_STATUS_SUCCESS   (UINT32_C(0x1) << 12)
+	#define HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_EVENT_DATA1_DFLT_MAC_ADDR_CHANGE	UINT32_C(0x4)
 	/*
-	 * This enumeration states that there is at least one tag in the
-	 * packet and at least one of the tag is invalid. The entire packet
-	 * is sent decrypted to the host.
+	 * If this bit is set to 1, then the value of default VLAN
+	 * was changed on this VF.
+	 * If set to 0, then this bit should be ignored.
 	 */
-		#define TLS_METADATA_INSYNC_MSG_FLAGS_TAG_AUTH_STATUS_FAILURE   (UINT32_C(0x2) << 12)
-		#define TLS_METADATA_INSYNC_MSG_FLAGS_TAG_AUTH_STATUS_LAST	TLS_METADATA_INSYNC_MSG_FLAGS_TAG_AUTH_STATUS_FAILURE
+	#define HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_EVENT_DATA1_DFLT_VLAN_CHANGE	UINT32_C(0x8)
 	/*
-	 * A value of 1 indicates that this packet contains a record that
-	 * starts in the packet and extends beyond the packet.
+	 * If this bit is set to 1, then the value of trusted VF enable
+	 * was changed on this VF.
+	 * If set to 0, then this bit should be ignored.
 	 */
-	#define TLS_METADATA_INSYNC_MSG_FLAGS_HEADER_FLDS_VALID	UINT32_C(0x4000)
+	#define HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_EVENT_DATA1_TRUSTED_VF_CFG_CHANGE	UINT32_C(0x10)
 	/*
-	 * This value indicates the lower 7-bit of the Crypto Key ID
-	 * associated with this operation.
+	 * If this bit is set to 1, then the control of VF was relinquished
+	 * back to the firmware flow manager following the function takeover
+	 * by TruFlow.
+	 * If set to 0, then this bit should be ignored.
 	 */
-	#define TLS_METADATA_INSYNC_MSG_KID_LO_MASK		UINT32_C(0xfe000000)
-	#define TLS_METADATA_INSYNC_MSG_KID_LO_SFT		25
-	uint16_t	kid_hi;
+	#define HWRM_ASYNC_EVENT_CMPL_VF_CFG_CHANGE_EVENT_DATA1_TF_OWNERSHIP_RELEASE	UINT32_C(0x20)
+} hwrm_async_event_cmpl_vf_cfg_change_t, *phwrm_async_event_cmpl_vf_cfg_change_t;
+
+/* hwrm_async_event_cmpl_llfc_pfc_change (size:128b/16B) */
+
+typedef struct hwrm_async_event_cmpl_llfc_pfc_change {
+	uint16_t	type;
 	/*
-	 * This value indicates the upper 13-bit of the Crypto Key ID
-	 * associated with this operation.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	#define TLS_METADATA_INSYNC_MSG_KID_HI_MASK UINT32_C(0x1fff)
-	#define TLS_METADATA_INSYNC_MSG_KID_HI_SFT 0
+	#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_TYPE_HWRM_ASYNC_EVENT
+	/* unused1 is 10 b */
+	#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_UNUSED1_MASK	UINT32_C(0xffc0)
+	#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_UNUSED1_SFT	6
+	/* Identifiers of events. */
+	uint16_t	event_id;
+	/* LLFC/PFC Configuration Change */
+	#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_EVENT_ID_LLFC_PFC_CHANGE UINT32_C(0x34)
+	#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_EVENT_ID_LLFC_PFC_CHANGE
+	/* Event specific data */
+	uint32_t	event_data2;
+	uint8_t	opaque_v;
 	/*
-	 * This field is only valid when md_type is set to tls_insync. This field
-	 * indicates the offset within the current TCP packet where the TLS header
-	 * starts. If there are multiple TLS headers in the packet, this provides
-	 * the offset of the last TLS header.
-	 *
-	 * The field is calculated by subtracting TCP sequence number of the first
-	 * byte of the TCP payload of the packet from the TCP sequence number of
-	 * the last TLS header in the packet.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint16_t	tls_header_offset;
+	#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_OPAQUE_SFT 1
+	/* 8-lsb timestamp from POR (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp from POR (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data */
+	uint32_t	event_data1;
+	/* Indicates llfc pfc status change */
+	#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_EVENT_DATA1_LLFC_PFC_MASK UINT32_C(0x3)
+	#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_EVENT_DATA1_LLFC_PFC_SFT 0
 	/*
-	 * This is the sequence Number of the record that was processed by the HW.
-	 * If there are multiple records in a packet, this would be the sequence
-	 * number of the last record.
+	 * If this field set to 1, then it indicates that llfc is
+	 * enabled.
 	 */
-	uint64_t	record_seq_num;
+		#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_EVENT_DATA1_LLFC_PFC_LLFC  UINT32_C(0x1)
 	/*
-	 * This field contains cumulative partial GHASH value of all the packets
-	 * decrypted by the HW associated with a TLS record. This field is valid
-	 * on when packets belonging to have arrived out-of-order and HW could
-	 * not decrypt every packet and authenticate the record. Partial GHASH is
-	 * only sent out with packet having the TAG field.
+	 * If this field is set to 2, then it indicates that pfc
+	 * is enabled.
 	 */
-	uint64_t	partial_ghash;
-} tls_metadata_insync_msg_t, *ptls_metadata_insync_msg_t;
+		#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_EVENT_DATA1_LLFC_PFC_PFC   UINT32_C(0x2)
+		#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_EVENT_DATA1_LLFC_PFC_LAST HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_EVENT_DATA1_LLFC_PFC_PFC
+	/* Indicates the physical port this llfc pfc change occur */
+	#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_EVENT_DATA1_PORT_MASK	UINT32_C(0x1c)
+	#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_EVENT_DATA1_PORT_SFT	2
+	/* PORT ID */
+	#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_EVENT_DATA1_PORT_ID_MASK UINT32_C(0x1fffe0)
+	#define HWRM_ASYNC_EVENT_CMPL_LLFC_PFC_CHANGE_EVENT_DATA1_PORT_ID_SFT  5
+} hwrm_async_event_cmpl_llfc_pfc_change_t, *phwrm_async_event_cmpl_llfc_pfc_change_t;
 
-/* tls_metadata_resync_msg (size:256b/32B) */
+/* hwrm_async_event_cmpl_default_vnic_change (size:128b/16B) */
 
-typedef struct tls_metadata_resync_msg {
-	uint32_t	md_type_link_flags_kid_lo;
-	/* This field classifies the data present in the meta-data. */
-	#define TLS_METADATA_RESYNC_MSG_MD_TYPE_MASK		UINT32_C(0x1f)
-	#define TLS_METADATA_RESYNC_MSG_MD_TYPE_SFT		0
+typedef struct hwrm_async_event_cmpl_default_vnic_change {
+	uint16_t	type;
 	/*
-	 * With this setting HW passes the TCP sequence number of the TLS
-	 * record that it is requesting a resync on in the meta data.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-		#define TLS_METADATA_RESYNC_MSG_MD_TYPE_TLS_RESYNC		UINT32_C(0x2)
-		#define TLS_METADATA_RESYNC_MSG_MD_TYPE_LAST		TLS_METADATA_RESYNC_MSG_MD_TYPE_TLS_RESYNC
+	#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_TYPE_HWRM_ASYNC_EVENT
+	/* unused1 is 10 b */
+	#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_UNUSED1_MASK	UINT32_C(0xffc0)
+	#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_UNUSED1_SFT	6
+	/* Identifiers of events. */
+	uint16_t	event_id;
+	/* Notification of a default vnic allocation or free */
+	#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_EVENT_ID_ALLOC_FREE_NOTIFICATION UINT32_C(0x35)
+	#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_EVENT_ID_LAST		HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_EVENT_ID_ALLOC_FREE_NOTIFICATION
+	/* Event specific data */
+	uint32_t	event_data2;
+	uint8_t	opaque_v;
 	/*
-	 * This field indicates where the next metadata block starts. It is
-	 * counted in 16B units. A value of zero indicates that there is no
-	 * metadata.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	#define TLS_METADATA_RESYNC_MSG_LINK_MASK		UINT32_C(0x1e0)
-	#define TLS_METADATA_RESYNC_MSG_LINK_SFT			5
-	/* These are flags present in the metadata. */
-	#define TLS_METADATA_RESYNC_MSG_FLAGS_MASK		UINT32_C(0x1fffe00)
-	#define TLS_METADATA_RESYNC_MSG_FLAGS_SFT		9
+	#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_OPAQUE_SFT 1
+	/* 8-lsb timestamp from POR (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp from POR (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data */
+	uint32_t	event_data1;
+	/* Indicates default vnic configuration change */
+	#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_EVENT_DATA1_DEF_VNIC_STATE_MASK	UINT32_C(0x3)
+	#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_EVENT_DATA1_DEF_VNIC_STATE_SFT	0
 	/*
-	 * A value of 1 implies that the packet was decrypted by HW. Otherwise
-	 * the packet is passed on as it came in on the wire.
+	 * If this field is set to 1, then it indicates that
+	 * a default VNIC has been allocate.
 	 */
-	#define TLS_METADATA_RESYNC_MSG_FLAGS_DECRYPTED		UINT32_C(0x200)
+		#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_EVENT_DATA1_DEF_VNIC_STATE_DEF_VNIC_ALLOC  UINT32_C(0x1)
 	/*
-	 * This field indicates the state of the ghash field passed in the
-	 * meta-data.
+	 * If this field is set to 2, then it indicates that
+	 * a default VNIC has been freed.
 	 */
-	#define TLS_METADATA_RESYNC_MSG_FLAGS_GHASH_MASK		UINT32_C(0xc00)
-	#define TLS_METADATA_RESYNC_MSG_FLAGS_GHASH_SFT		10
+		#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_EVENT_DATA1_DEF_VNIC_STATE_DEF_VNIC_FREE   UINT32_C(0x2)
+		#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_EVENT_DATA1_DEF_VNIC_STATE_LAST	HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_EVENT_DATA1_DEF_VNIC_STATE_DEF_VNIC_FREE
+	/* Indicates the physical function this event occurred on. */
+	#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_EVENT_DATA1_PF_ID_MASK		UINT32_C(0x3fc)
+	#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_EVENT_DATA1_PF_ID_SFT			2
+	/* Indicates the virtual function this event occurred on */
+	#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_EVENT_DATA1_VF_ID_MASK		UINT32_C(0x3fffc00)
+	#define HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_EVENT_DATA1_VF_ID_SFT			10
+} hwrm_async_event_cmpl_default_vnic_change_t, *phwrm_async_event_cmpl_default_vnic_change_t;
+
+/* hwrm_async_event_cmpl_hw_flow_aged (size:128b/16B) */
+
+typedef struct hwrm_async_event_cmpl_hw_flow_aged {
+	uint16_t	type;
 	/*
-	 * This enumeration states that the ghash is not valid in the
-	 * meta-data.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-		#define TLS_METADATA_RESYNC_MSG_FLAGS_GHASH_NOT_VALID	(UINT32_C(0x0) << 10)
-		#define TLS_METADATA_RESYNC_MSG_FLAGS_GHASH_LAST		TLS_METADATA_RESYNC_MSG_FLAGS_GHASH_NOT_VALID
-	/* This field indicates the status of tag authentication. */
-	#define TLS_METADATA_RESYNC_MSG_FLAGS_TAG_AUTH_STATUS_MASK   UINT32_C(0x3000)
-	#define TLS_METADATA_RESYNC_MSG_FLAGS_TAG_AUTH_STATUS_SFT	12
+	#define HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
+	/* Notification of a hw flow aged */
+	#define HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_EVENT_ID_HW_FLOW_AGED UINT32_C(0x36)
+	#define HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_EVENT_ID_HW_FLOW_AGED
+	/* Event specific data */
+	uint32_t	event_data2;
+	uint8_t	opaque_v;
 	/*
-	 * This enumeration is set when there is no tags present in the
-	 * packet.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-		#define TLS_METADATA_RESYNC_MSG_FLAGS_TAG_AUTH_STATUS_NONE	(UINT32_C(0x0) << 12)
-		#define TLS_METADATA_RESYNC_MSG_FLAGS_TAG_AUTH_STATUS_LAST	TLS_METADATA_RESYNC_MSG_FLAGS_TAG_AUTH_STATUS_NONE
+	#define HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_OPAQUE_SFT 1
+	/* 8-lsb timestamp from POR (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp from POR (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data */
+	uint32_t	event_data1;
+	/* Indicates flow ID this event occurred on. */
+	#define HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_EVENT_DATA1_FLOW_ID_MASK	UINT32_C(0x7fffffff)
+	#define HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_EVENT_DATA1_FLOW_ID_SFT	0
+	/* Indicates flow direction this event occurred on. */
+	#define HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_EVENT_DATA1_FLOW_DIRECTION	UINT32_C(0x80000000)
 	/*
-	 * A value of 1 indicates that this packet contains a record that
-	 * starts in the packet and extends beyond the packet.
+	 * If this bit set to 0, then it indicates that the aged
+	 * event was rx flow.
 	 */
-	#define TLS_METADATA_RESYNC_MSG_FLAGS_HEADER_FLDS_VALID	UINT32_C(0x4000)
+		#define HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_EVENT_DATA1_FLOW_DIRECTION_RX	(UINT32_C(0x0) << 31)
 	/*
-	 * This value indicates the lower 7-bit of the Crypto Key ID
-	 * associated with this operation.
+	 * If this bit is set to 1, then it indicates that the aged
+	 * event was tx flow.
 	 */
-	#define TLS_METADATA_RESYNC_MSG_KID_LO_MASK		UINT32_C(0xfe000000)
-	#define TLS_METADATA_RESYNC_MSG_KID_LO_SFT		25
-	uint16_t	kid_hi;
+		#define HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_EVENT_DATA1_FLOW_DIRECTION_TX	(UINT32_C(0x1) << 31)
+		#define HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_EVENT_DATA1_FLOW_DIRECTION_LAST HWRM_ASYNC_EVENT_CMPL_HW_FLOW_AGED_EVENT_DATA1_FLOW_DIRECTION_TX
+} hwrm_async_event_cmpl_hw_flow_aged_t, *phwrm_async_event_cmpl_hw_flow_aged_t;
+
+/* hwrm_async_event_cmpl_eem_cache_flush_req (size:128b/16B) */
+
+typedef struct hwrm_async_event_cmpl_eem_cache_flush_req {
+	uint16_t	type;
 	/*
-	 * This value indicates the upper 13-bit of the Crypto Key ID
-	 * associated with this operation.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	#define TLS_METADATA_RESYNC_MSG_KID_HI_MASK UINT32_C(0x1fff)
-	#define TLS_METADATA_RESYNC_MSG_KID_HI_SFT 0
-	/* This field is unused in this context. */
-	uint16_t	metadata_0;
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_REQ_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_REQ_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_REQ_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_REQ_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_REQ_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
+	/* Notification of a eem_cache_flush request */
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_REQ_EVENT_ID_EEM_CACHE_FLUSH_REQ UINT32_C(0x38)
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_REQ_EVENT_ID_LAST		HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_REQ_EVENT_ID_EEM_CACHE_FLUSH_REQ
+	/* Event specific data */
+	uint32_t	event_data2;
+	uint8_t	opaque_v;
 	/*
-	 * This field indicates the TCP sequence number of the TLS record that HW
-	 * is requesting a resync on from the Driver. HW will keep a count of the
-	 * TLS records it found after this record (delta_records). Driver will
-	 * provide the TLS Record Sequence Number associated with the record. HW
-	 * will add the delta_records to the Record Sequence Number provided by
-	 * the driver and get back on sync.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint32_t	resync_record_tcp_seq_num;
-	uint32_t	unused0;
-	/* This field is unused in this context. */
-	uint64_t	metadata_2;
-	/* This field is unused in this context. */
-	uint64_t	metadata_3;
-} tls_metadata_resync_msg_t, *ptls_metadata_resync_msg_t;
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_REQ_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_REQ_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_REQ_OPAQUE_SFT 1
+	/* 8-lsb timestamp from POR (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp from POR (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data */
+	uint32_t	event_data1;
+} hwrm_async_event_cmpl_eem_cache_flush_req_t, *phwrm_async_event_cmpl_eem_cache_flush_req_t;
 
-/* tx_doorbell (size:32b/4B) */
+/* hwrm_async_event_cmpl_eem_cache_flush_done (size:128b/16B) */
 
-typedef struct tx_doorbell {
-	uint32_t	key_idx;
+typedef struct hwrm_async_event_cmpl_eem_cache_flush_done {
+	uint16_t	type;
 	/*
-	 * BD Index of next BD that will be used to transmit data
-	 * on the TX ring mapped to this door bell.  NIC may
-	 * read and process all BDs up to, but not including this
-	 * index.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	#define TX_DOORBELL_IDX_MASK UINT32_C(0xffffff)
-	#define TX_DOORBELL_IDX_SFT 0
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_DONE_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_DONE_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_DONE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_DONE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_DONE_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
 	/*
-	 * This value indicates the type of door bell operation
-	 * that is begin requested.   This value is '0' for TX
-	 * door bell operations.
+	 * Notification of a host eem_cache_flush has completed. This event
+	 * is generated by the host driver.
 	 */
-	#define TX_DOORBELL_KEY_MASK UINT32_C(0xf0000000)
-	#define TX_DOORBELL_KEY_SFT 28
-	/* TX Operation */
-		#define TX_DOORBELL_KEY_TX	(UINT32_C(0x0) << 28)
-		#define TX_DOORBELL_KEY_LAST TX_DOORBELL_KEY_TX
-} tx_doorbell_t, *ptx_doorbell_t;
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_DONE_EVENT_ID_EEM_CACHE_FLUSH_DONE UINT32_C(0x39)
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_DONE_EVENT_ID_LAST		HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_DONE_EVENT_ID_EEM_CACHE_FLUSH_DONE
+	/* Event specific data */
+	uint32_t	event_data2;
+	uint8_t	opaque_v;
+	/*
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_DONE_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_DONE_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_DONE_OPAQUE_SFT 1
+	/* 8-lsb timestamp from POR (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp from POR (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data */
+	uint32_t	event_data1;
+	/* Indicates function ID that this event occurred on. */
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_DONE_EVENT_DATA1_FID_MASK UINT32_C(0xffff)
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_CACHE_FLUSH_DONE_EVENT_DATA1_FID_SFT 0
+} hwrm_async_event_cmpl_eem_cache_flush_done_t, *phwrm_async_event_cmpl_eem_cache_flush_done_t;
 
-/* rx_doorbell (size:32b/4B) */
+/* hwrm_async_event_cmpl_tcp_flag_action_change (size:128b/16B) */
 
-typedef struct rx_doorbell {
-	uint32_t	key_idx;
+typedef struct hwrm_async_event_cmpl_tcp_flag_action_change {
+	uint16_t	type;
 	/*
-	 * BD Index of next BD that will be used for an empty receive
-	 * buffer on the RX ring mapped to this door bell.  NIC may
-	 * read and process all BDs up to, but not including this
-	 * index.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	#define RX_DOORBELL_IDX_MASK UINT32_C(0xffffff)
-	#define RX_DOORBELL_IDX_SFT 0
+	#define HWRM_ASYNC_EVENT_CMPL_TCP_FLAG_ACTION_CHANGE_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_TCP_FLAG_ACTION_CHANGE_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_TCP_FLAG_ACTION_CHANGE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_TCP_FLAG_ACTION_CHANGE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_TCP_FLAG_ACTION_CHANGE_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
+	/* Notification of tcp flag action change */
+	#define HWRM_ASYNC_EVENT_CMPL_TCP_FLAG_ACTION_CHANGE_EVENT_ID_TCP_FLAG_ACTION_CHANGE UINT32_C(0x3a)
+	#define HWRM_ASYNC_EVENT_CMPL_TCP_FLAG_ACTION_CHANGE_EVENT_ID_LAST		HWRM_ASYNC_EVENT_CMPL_TCP_FLAG_ACTION_CHANGE_EVENT_ID_TCP_FLAG_ACTION_CHANGE
+	/* Event specific data */
+	uint32_t	event_data2;
+	uint8_t	opaque_v;
 	/*
-	 * This value indicates the type of door bell operation
-	 * that is begin requested.   This value is '1' for RX
-	 * door bell operations.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	#define RX_DOORBELL_KEY_MASK UINT32_C(0xf0000000)
-	#define RX_DOORBELL_KEY_SFT 28
-	/* RX Operation */
-		#define RX_DOORBELL_KEY_RX	(UINT32_C(0x1) << 28)
-		#define RX_DOORBELL_KEY_LAST RX_DOORBELL_KEY_RX
-} rx_doorbell_t, *prx_doorbell_t;
+	#define HWRM_ASYNC_EVENT_CMPL_TCP_FLAG_ACTION_CHANGE_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_TCP_FLAG_ACTION_CHANGE_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_TCP_FLAG_ACTION_CHANGE_OPAQUE_SFT 1
+	/* 8-lsb timestamp from POR (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp from POR (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data */
+	uint32_t	event_data1;
+} hwrm_async_event_cmpl_tcp_flag_action_change_t, *phwrm_async_event_cmpl_tcp_flag_action_change_t;
 
-/* cmpl_doorbell (size:32b/4B) */
+/* hwrm_async_event_cmpl_eem_flow_active (size:128b/16B) */
 
-typedef struct cmpl_doorbell {
-	uint32_t	key_mask_valid_idx;
-	/*
-	 * BD Index of the most recently handed completion record
-	 * on the completion ring mapped to this door bell.
-	 * NIC may
-	 * write this location again with a new completion.
-	 */
-	#define CMPL_DOORBELL_IDX_MASK	UINT32_C(0xffffff)
-	#define CMPL_DOORBELL_IDX_SFT	0
+typedef struct hwrm_async_event_cmpl_eem_flow_active {
+	uint16_t	type;
 	/*
-	 * This indicates if the BDIDX value is valid for this
-	 * update when it is '1'.  When it is '0', the BDIDX
-	 * value should be ignored.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	#define CMPL_DOORBELL_IDX_VALID	UINT32_C(0x4000000)
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
+	/* Notification of an active eem flow */
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_ID_EEM_FLOW_ACTIVE UINT32_C(0x3b)
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_ID_EEM_FLOW_ACTIVE
+	/* Event specific data */
+	uint32_t	event_data2;
+	/* Indicates the 2nd global id this event occurred on. */
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA2_GLOBAL_ID_2_MASK   UINT32_C(0x3fffffff)
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA2_GLOBAL_ID_2_SFT	0
 	/*
-	 * This bit indicates the new interrupt mask state for the
-	 * interrupt associated with the BDIDX.  A '1', means the
-	 * interrupt is to be masked.  A '0' indicates the interrupt
-	 * is to be unmasked.
+	 * Indicates flow direction of the flow identified by
+	 * the global_id_2.
 	 */
-	#define CMPL_DOORBELL_MASK	UINT32_C(0x8000000)
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA2_FLOW_DIRECTION	UINT32_C(0x40000000)
+	/* If this bit is set to 0, then it indicates that this rx flow. */
+		#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA2_FLOW_DIRECTION_RX	(UINT32_C(0x0) << 30)
+	/* If this bit is set to 1, then it indicates that this tx flow. */
+		#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA2_FLOW_DIRECTION_TX	(UINT32_C(0x1) << 30)
+		#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA2_FLOW_DIRECTION_LAST HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA2_FLOW_DIRECTION_TX
+	uint8_t	opaque_v;
 	/*
-	 * This value indicates the type of door bell operation
-	 * that is begin requested.   This value is '2' for CMP
-	 * door bell operations.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	#define CMPL_DOORBELL_KEY_MASK	UINT32_C(0xf0000000)
-	#define CMPL_DOORBELL_KEY_SFT	28
-	/* Completion Operation */
-		#define CMPL_DOORBELL_KEY_CMPL	(UINT32_C(0x2) << 28)
-		#define CMPL_DOORBELL_KEY_LAST	CMPL_DOORBELL_KEY_CMPL
-} cmpl_doorbell_t, *pcmpl_doorbell_t;
-
-/* status_doorbell (size:32b/4B) */
-
-typedef struct status_doorbell {
-	uint32_t	key_idx;
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_OPAQUE_SFT 1
+	/* 8-lsb timestamp from POR (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp from POR (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data */
+	uint32_t	event_data1;
+	/* Indicates the 1st global id this event occurred on. */
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA1_GLOBAL_ID_1_MASK   UINT32_C(0x3fffffff)
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA1_GLOBAL_ID_1_SFT	0
 	/*
-	 * BD Index of the status record for which space is now
-	 * available to the NIC.
+	 * Indicates flow direction of the flow identified by the
+	 * global_id_1.
 	 */
-	#define STATUS_DOORBELL_IDX_MASK UINT32_C(0xffffff)
-	#define STATUS_DOORBELL_IDX_SFT 0
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA1_FLOW_DIRECTION	UINT32_C(0x40000000)
+	/* If this bit is set to 0, then it indicates that this is rx flow. */
+		#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA1_FLOW_DIRECTION_RX	(UINT32_C(0x0) << 30)
+	/* If this bit is set to 1, then it indicates that this is tx flow. */
+		#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA1_FLOW_DIRECTION_TX	(UINT32_C(0x1) << 30)
+		#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA1_FLOW_DIRECTION_LAST HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA1_FLOW_DIRECTION_TX
 	/*
-	 * This value indicates the type of door bell operation
-	 * that is begin requested.   This value is '3' for Status
-	 * door bell operations.
+	 * Indicates EEM flow aging mode this event occurred on. If
+	 * this bit is set to 0, the event_data1 is the EEM global
+	 * ID. If this bit is set to 1, the event_data1 is the number
+	 * of global ID in the context memory.
 	 */
-	#define STATUS_DOORBELL_KEY_MASK UINT32_C(0xf0000000)
-	#define STATUS_DOORBELL_KEY_SFT 28
-	/* Status Operation */
-		#define STATUS_DOORBELL_KEY_STAT  (UINT32_C(0x3) << 28)
-		#define STATUS_DOORBELL_KEY_LAST STATUS_DOORBELL_KEY_STAT
-} status_doorbell_t, *pstatus_doorbell_t;
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA1_MODE		UINT32_C(0x80000000)
+	/* EEM flow aging mode 0. */
+		#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA1_MODE_0		(UINT32_C(0x0) << 31)
+	/* EEM flow aging mode 1. */
+		#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA1_MODE_1		(UINT32_C(0x1) << 31)
+		#define HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA1_MODE_LAST	HWRM_ASYNC_EVENT_CMPL_EEM_FLOW_ACTIVE_EVENT_DATA1_MODE_1
+} hwrm_async_event_cmpl_eem_flow_active_t, *phwrm_async_event_cmpl_eem_flow_active_t;
 
-/* push32_doorbell (size:1024b/128B) */
+/* hwrm_async_event_cmpl_eem_cfg_change (size:128b/16B) */
 
-typedef struct push32_doorbell {
-	uint32_t	key_sz_idx;
+typedef struct hwrm_async_event_cmpl_eem_cfg_change {
+	uint16_t	type;
 	/*
-	 * This is the BD Index of last BD of the push packet
-	 * that will be used to transmit data on the TX ring mapped
-	 * to this door bell.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	#define PUSH32_DOORBELL_IDX_MASK UINT32_C(0xffffff)
-	#define PUSH32_DOORBELL_IDX_SFT 0
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_CFG_CHANGE_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_CFG_CHANGE_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_EEM_CFG_CHANGE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_EEM_CFG_CHANGE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_EEM_CFG_CHANGE_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
+	/* Notification of EEM configuration change */
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_CFG_CHANGE_EVENT_ID_EEM_CFG_CHANGE UINT32_C(0x3c)
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_CFG_CHANGE_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_EEM_CFG_CHANGE_EVENT_ID_EEM_CFG_CHANGE
+	/* Event specific data */
+	uint32_t	event_data2;
+	uint8_t	opaque_v;
 	/*
-	 * This is the number of 16B BDs spaces consumed in the TX
-	 * Ring by the "backup" version of the packet being pushed.
-	 * A value of 1 is invalid since backup must start with a
-	 * long 32B BE.
-	 * A value of 2 indicates just the first 32B BE.
-	 * A value of 3 indicates 32B+16B BD.  etc.
-	 * A value of 0 indicates 16x16B BD spaces are consumed.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	#define PUSH32_DOORBELL_SZ_MASK UINT32_C(0xf000000)
-	#define PUSH32_DOORBELL_SZ_SFT  24
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_CFG_CHANGE_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_CFG_CHANGE_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_CFG_CHANGE_OPAQUE_SFT 1
+	/* 8-lsb timestamp from POR (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp from POR (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data */
+	uint32_t	event_data1;
 	/*
-	 * This value indicates the type of door bell operation
-	 * that is begin requested.   This value is 4 for push
-	 * door bell operations.
+	 * Value of 1 to indicate EEM TX configuration is enabled. Value of
+	 * 0 to indicate the EEM TX configuration is disabled.
 	 */
-	#define PUSH32_DOORBELL_KEY_MASK UINT32_C(0xf0000000)
-	#define PUSH32_DOORBELL_KEY_SFT 28
-	/* Push Operation */
-		#define PUSH32_DOORBELL_KEY_PUSH  (UINT32_C(0x4) << 28)
-		#define PUSH32_DOORBELL_KEY_LAST PUSH32_DOORBELL_KEY_PUSH
-	uint16_t	flags_type;
-	/* This value identifies the type of buffer descriptor. */
-	#define PUSH32_DOORBELL_TYPE_MASK		UINT32_C(0x3f)
-	#define PUSH32_DOORBELL_TYPE_SFT		0
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_CFG_CHANGE_EVENT_DATA1_EEM_TX_ENABLE	UINT32_C(0x1)
 	/*
-	 * Indicates that this BD is 32B long and is used for
-	 * normal L2 packet transmission.
+	 * Value of 1 to indicate EEM RX configuration is enabled. Value of 0
+	 * to indicate the EEM RX configuration is disabled.
 	 */
-		#define PUSH32_DOORBELL_TYPE_TX_BD_LONG	UINT32_C(0x10)
-		#define PUSH32_DOORBELL_TYPE_LAST		PUSH32_DOORBELL_TYPE_TX_BD_LONG
+	#define HWRM_ASYNC_EVENT_CMPL_EEM_CFG_CHANGE_EVENT_DATA1_EEM_RX_ENABLE	UINT32_C(0x2)
+} hwrm_async_event_cmpl_eem_cfg_change_t, *phwrm_async_event_cmpl_eem_cfg_change_t;
+
+/* hwrm_async_event_cmpl_quiesce_done (size:128b/16B) */
+
+typedef struct hwrm_async_event_cmpl_quiesce_done {
+	uint16_t	type;
 	/*
-	 * All bits in this field must be valid on the first BD of a packet.
-	 * Only the packet_end bit must be valid for the remaining BDs
-	 * of a packet.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	#define PUSH32_DOORBELL_FLAGS_MASK	UINT32_C(0xffc0)
-	#define PUSH32_DOORBELL_FLAGS_SFT		6
+	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
+	/* An event signifying completion of HWRM_FW_STATE_QUIESCE */
+	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_ID_QUIESCE_DONE UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_ID_QUIESCE_DONE
+	/* Event specific data */
+	uint32_t	event_data2;
+	/* Status of HWRM_FW_STATE_QUIESCE completion */
+	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_DATA2_QUIESCE_STATUS_MASK		UINT32_C(0xff)
+	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_DATA2_QUIESCE_STATUS_SFT		0
 	/*
-	 * If set to 1, the packet ends with the data in the buffer
-	 * pointed to by this descriptor.  This flag must be
-	 * valid on every BD.
-	 *
-	 *	This bit must be set on all push doorbells.
+	 * The quiesce operation started by HWRM_FW_STATE_QUIESCE
+	 * completed successfully.
 	 */
-	#define PUSH32_DOORBELL_FLAGS_PACKET_END	UINT32_C(0x40)
+		#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_DATA2_QUIESCE_STATUS_SUCCESS		UINT32_C(0x0)
 	/*
-	 * If set to 1, the device will not generate a completion for
-	 * this transmit packet unless there is an error in it's
-	 * processing.
-	 * If this bit
-	 * is set to 0, then the packet will be completed normally.
-	 *
-	 * This bit must be valid only on the first BD of a packet.
+	 * The quiesce operation started by HWRM_FW_STATE_QUIESCE timed
+	 * out.
 	 */
-	#define PUSH32_DOORBELL_FLAGS_NO_CMPL	UINT32_C(0x80)
+		#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_DATA2_QUIESCE_STATUS_TIMEOUT		UINT32_C(0x1)
 	/*
-	 * This value must match the sz field in the first
-	 * 32b of the push operation except that if
-	 * 16x16B BD locations
-	 * are consumed in the ring by this packet, then
-	 * this value must be 16 (not zero).
+	 * The quiesce operation started by HWRM_FW_STATE_QUIESCE
+	 * encountered an error.
 	 */
-	#define PUSH32_DOORBELL_FLAGS_BD_CNT_MASK	UINT32_C(0x1f00)
-	#define PUSH32_DOORBELL_FLAGS_BD_CNT_SFT	8
+		#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_DATA2_QUIESCE_STATUS_ERROR		UINT32_C(0x2)
+		#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_DATA2_QUIESCE_STATUS_LAST		HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_DATA2_QUIESCE_STATUS_ERROR
+	/* opaque is 8 b */
+	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_DATA2_OPAQUE_MASK			UINT32_C(0xff00)
+	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_DATA2_OPAQUE_SFT			8
 	/*
-	 * This value is a hint for the length of the entire packet.
-	 * It is used by the chip to optimize internal processing.
-	 *
-	 * The packet will be dropped if the hint is too short.
-	 *
-	 * This field is valid only on the first BD of a packet.
+	 * Additional information about internal hardware state related to
+	 * idle/quiesce state. QUIESCE may succeed per quiesce_status
+	 * regardless of idle_state_flags. If QUIESCE fails, the host may
+	 * inspect idle_state_flags to determine whether a retry is warranted.
 	 */
-	#define PUSH32_DOORBELL_FLAGS_LHINT_MASK	UINT32_C(0x6000)
-	#define PUSH32_DOORBELL_FLAGS_LHINT_SFT	13
-	/* indicates packet length < 512B */
-		#define PUSH32_DOORBELL_FLAGS_LHINT_LT512	(UINT32_C(0x0) << 13)
-	/* indicates 512 <= packet length < 1KB */
-		#define PUSH32_DOORBELL_FLAGS_LHINT_LT1K	(UINT32_C(0x1) << 13)
-	/* indicates 1KB <= packet length < 2KB */
-		#define PUSH32_DOORBELL_FLAGS_LHINT_LT2K	(UINT32_C(0x2) << 13)
-	/* indicates packet length >= 2KB */
-		#define PUSH32_DOORBELL_FLAGS_LHINT_GTE2K	(UINT32_C(0x3) << 13)
-		#define PUSH32_DOORBELL_FLAGS_LHINT_LAST	PUSH32_DOORBELL_FLAGS_LHINT_GTE2K
+	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_DATA2_IDLE_STATE_FLAGS_MASK		UINT32_C(0xff0000)
+	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_DATA2_IDLE_STATE_FLAGS_SFT		16
 	/*
-	 * If set to 1, the device immediately updates the Send Consumer
-	 * Index after the buffer associated with this descriptor has
-	 * been transferred via DMA to NIC memory from host memory. An
-	 * interrupt may or may not be generated according to the state
-	 * of the interrupt avoidance mechanisms. If this bit
-	 * is set to 0, then the Consumer Index is only updated as soon
-	 * as one of the host interrupt coalescing conditions has been met.
-	 *
-	 * This bit must be valid on the first BD of a packet.
+	 * Failure to quiesce is caused by host not updating the NQ consumer
+	 * index.
 	 */
-	#define PUSH32_DOORBELL_FLAGS_COAL_NOW	UINT32_C(0x8000)
+	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_DATA2_IDLE_STATE_FLAGS_INCOMPLETE_NQ	UINT32_C(0x10000)
+	/* Flag 1 indicating partial non-idle state. */
+	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_DATA2_IDLE_STATE_FLAGS_IDLE_STATUS_1	UINT32_C(0x20000)
+	/* Flag 2 indicating partial non-idle state. */
+	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_DATA2_IDLE_STATE_FLAGS_IDLE_STATUS_2	UINT32_C(0x40000)
+	/* Flag 3 indicating partial non-idle state. */
+	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_DATA2_IDLE_STATE_FLAGS_IDLE_STATUS_3	UINT32_C(0x80000)
+	uint8_t	opaque_v;
 	/*
-	 * This is the length of the host physical buffer this BD describes
-	 * in bytes.
-	 *
-	 * This field must be valid on all BDs of a packet.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint16_t	len;
+	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_OPAQUE_SFT 1
+	/* 8-lsb timestamp from POR (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp from POR (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data */
+	uint32_t	event_data1;
+	/* Time stamp for error event */
+	#define HWRM_ASYNC_EVENT_CMPL_QUIESCE_DONE_EVENT_DATA1_TIMESTAMP	UINT32_C(0x1)
+} hwrm_async_event_cmpl_quiesce_done_t, *phwrm_async_event_cmpl_quiesce_done_t;
+
+/* hwrm_async_event_cmpl_deferred_response (size:128b/16B) */
+
+typedef struct hwrm_async_event_cmpl_deferred_response {
+	uint16_t	type;
 	/*
-	 * The opaque data field is pass through to the completion and can be
-	 * used for any data that the driver wants to associate with the
-	 * transmit BD.
-	 *
-	 * This field must be valid on the first BD of a packet.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint32_t	opaque;
+	#define HWRM_ASYNC_EVENT_CMPL_DEFERRED_RESPONSE_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_DEFERRED_RESPONSE_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_DEFERRED_RESPONSE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_DEFERRED_RESPONSE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_DEFERRED_RESPONSE_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
 	/*
-	 * All bits in this field must be valid on the first BD of a packet.
-	 * Their value on other BDs of the packet will be ignored.
+	 * An event signifying a HWRM command is in progress and its
+	 * response will be deferred
 	 */
-	uint16_t	lflags;
+	#define HWRM_ASYNC_EVENT_CMPL_DEFERRED_RESPONSE_EVENT_ID_DEFERRED_RESPONSE UINT32_C(0x40)
+	#define HWRM_ASYNC_EVENT_CMPL_DEFERRED_RESPONSE_EVENT_ID_LAST		HWRM_ASYNC_EVENT_CMPL_DEFERRED_RESPONSE_EVENT_ID_DEFERRED_RESPONSE
+	/* Event specific data */
+	uint32_t	event_data2;
 	/*
-	 * If set to 1, the controller replaces the TCP/UPD checksum
-	 * fields of normal TCP/UPD checksum, or the inner TCP/UDP
-	 * checksum field of the encapsulated TCP/UDP packets with the
-	 * hardware calculated TCP/UDP checksum for the packet associated
-	 * with this descriptor. The flag is ignored if the LSO flag is set.
-	 *
-	 * This bit must be valid on the first BD of a packet.
+	 * The PF's mailbox is clear to issue another command.
+	 * A command with this seq_id is still in progress
+	 * and will return a regular HWRM completion when done.
+	 * 'event_data1' field, if non-zero, contains the estimated
+	 * execution time for the command.
 	 */
-	#define PUSH32_DOORBELL_LFLAGS_TCP_UDP_CHKSUM	UINT32_C(0x1)
+	#define HWRM_ASYNC_EVENT_CMPL_DEFERRED_RESPONSE_EVENT_DATA2_SEQ_ID_MASK UINT32_C(0xffff)
+	#define HWRM_ASYNC_EVENT_CMPL_DEFERRED_RESPONSE_EVENT_DATA2_SEQ_ID_SFT 0
+	uint8_t	opaque_v;
 	/*
-	 * If set to 1, the controller replaces the IP checksum of the
-	 * normal packets, or the inner IP checksum of the encapsulated
-	 * packets with the hardware calculated IP checksum for the
-	 * packet associated with this descriptor.
-	 *
-	 * This bit must be valid on the first BD of a packet.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	#define PUSH32_DOORBELL_LFLAGS_IP_CHKSUM	UINT32_C(0x2)
+	#define HWRM_ASYNC_EVENT_CMPL_DEFERRED_RESPONSE_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_DEFERRED_RESPONSE_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_DEFERRED_RESPONSE_OPAQUE_SFT 1
+	/* 8-lsb timestamp from POR (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp from POR (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Estimated remaining time of command execution in ms (if not zero) */
+	uint32_t	event_data1;
+} hwrm_async_event_cmpl_deferred_response_t, *phwrm_async_event_cmpl_deferred_response_t;
+
+/* hwrm_async_event_cmpl_pfc_watchdog_cfg_change (size:128b/16B) */
+
+typedef struct hwrm_async_event_cmpl_pfc_watchdog_cfg_change {
+	uint16_t	type;
 	/*
-	 * If set to 1, the controller will not append an Ethernet CRC
-	 * to the end of the frame.
-	 *
-	 * This bit must be valid on the first BD of a packet.
-	 *
-	 * Packet must be 64B or longer when this flag is set.  It is not
-	 * useful to use this bit with any form of TX offload such as
-	 * CSO or LSO.  The intent is that the packet from the host already
-	 * has a valid Ethernet CRC on the packet.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	#define PUSH32_DOORBELL_LFLAGS_NOCRC		UINT32_C(0x4)
+	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
+	/* PFC watchdog configuration change for given port/cos */
+	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_EVENT_ID_PFC_WATCHDOG_CFG_CHANGE UINT32_C(0x41)
+	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_EVENT_ID_LAST		HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_EVENT_ID_PFC_WATCHDOG_CFG_CHANGE
+	/* Event specific data */
+	uint32_t	event_data2;
+	uint8_t	opaque_v;
 	/*
-	 * If set to 1, the device will record the time at which the packet
-	 * was actually transmitted at the TX MAC.
-	 *
-	 * This bit must be valid on the first BD of a packet.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	#define PUSH32_DOORBELL_LFLAGS_STAMP		UINT32_C(0x8)
-	/*
-	 * If set to 1, The controller replaces the tunnel IP checksum
-	 * field with hardware calculated IP checksum for the IP header
-	 * of the packet associated with this descriptor.
-	 *
-	 * For outer UDP checksum, global outer UDP checksum TE_NIC register
-	 * needs to be enabled. If the global outer UDP checksum TE_NIC register
-	 * bit is set, outer UDP checksum will be calculated for the following
-	 * cases:
-	 * 1. Packets with tcp_udp_chksum flag set to offload checksum for inner
-	 * packet AND the inner packet is TCP/UDP. If the inner packet is ICMP for
-	 * example (non-TCP/UDP), even if the tcp_udp_chksum is set, the outer UDP
-	 * checksum will not be calculated.
-	 * 2. Packets with lso flag set which implies inner TCP checksum calculation
-	 * as part of LSO operation.
-	 */
-	#define PUSH32_DOORBELL_LFLAGS_T_IP_CHKSUM	UINT32_C(0x10)
+	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_OPAQUE_SFT 1
+	/* 8-lsb timestamp from POR (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp from POR (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data */
+	uint32_t	event_data1;
 	/*
-	 * If set to 1, the device will treat this packet with LSO(Large
-	 * Send Offload) processing for both normal or encapsulated
-	 * packets, which is a form of TCP segmentation.  When this bit
-	 * is 1, the hdr_size and mss fields must be valid. The driver
-	 * doesn't need to set t_ip_chksum, ip_chksum, and tcp_udp_chksum
-	 * flags since the controller will replace the appropriate
-	 * checksum fields for segmented packets.
-	 *
-	 * When this bit is 1, the hdr_size and mss fields must be valid.
+	 * 1 in bit position X indicates PFC watchdog should
+	 * be on for COSX
 	 */
-	#define PUSH32_DOORBELL_LFLAGS_LSO		UINT32_C(0x20)
+	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_EVENT_DATA1_PFC_WD_COS_MASK		UINT32_C(0xff)
+	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_EVENT_DATA1_PFC_WD_COS_SFT		0
+	/* 1 means PFC WD for COS0 is on, 0 - off. */
+	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_EVENT_DATA1_PFC_WD_COS_PFC_WD_COS0	UINT32_C(0x1)
+	/* 1 means PFC WD for COS1 is on, 0 - off. */
+	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_EVENT_DATA1_PFC_WD_COS_PFC_WD_COS1	UINT32_C(0x2)
+	/* 1 means PFC WD for COS2 is on, 0 - off. */
+	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_EVENT_DATA1_PFC_WD_COS_PFC_WD_COS2	UINT32_C(0x4)
+	/* 1 means PFC WD for COS3 is on, 0 - off. */
+	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_EVENT_DATA1_PFC_WD_COS_PFC_WD_COS3	UINT32_C(0x8)
+	/* 1 means PFC WD for COS4 is on, 0 - off. */
+	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_EVENT_DATA1_PFC_WD_COS_PFC_WD_COS4	UINT32_C(0x10)
+	/* 1 means PFC WD for COS5 is on, 0 - off. */
+	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_EVENT_DATA1_PFC_WD_COS_PFC_WD_COS5	UINT32_C(0x20)
+	/* 1 means PFC WD for COS6 is on, 0 - off. */
+	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_EVENT_DATA1_PFC_WD_COS_PFC_WD_COS6	UINT32_C(0x40)
+	/* 1 means PFC WD for COS7 is on, 0 - off. */
+	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_EVENT_DATA1_PFC_WD_COS_PFC_WD_COS7	UINT32_C(0x80)
+	/* PORT ID */
+	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_EVENT_DATA1_PORT_ID_MASK		UINT32_C(0xffff00)
+	#define HWRM_ASYNC_EVENT_CMPL_PFC_WATCHDOG_CFG_CHANGE_EVENT_DATA1_PORT_ID_SFT		8
+} hwrm_async_event_cmpl_pfc_watchdog_cfg_change_t, *phwrm_async_event_cmpl_pfc_watchdog_cfg_change_t;
+
+/* hwrm_async_event_cmpl_echo_request (size:128b/16B) */
+
+typedef struct hwrm_async_event_cmpl_echo_request {
+	uint16_t	type;
 	/*
-	 * If set to zero when LSO is '1', then the IPID will be treated
-	 * as a 16b number and will be wrapped if it exceeds a value of
-	 * 0xffff.
-	 *
-	 * If set to one when LSO is '1', then the IPID will be treated
-	 * as a 15b number and will be wrapped if it exceeds a value 0f
-	 * 0x7fff.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	#define PUSH32_DOORBELL_LFLAGS_IPID_FMT	UINT32_C(0x40)
+	#define HWRM_ASYNC_EVENT_CMPL_ECHO_REQUEST_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_ECHO_REQUEST_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_ECHO_REQUEST_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_ECHO_REQUEST_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_ECHO_REQUEST_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
 	/*
-	 * If set to zero when LSO is '1', then the IPID of the tunnel
-	 * IP header will not be modified during LSO operations.
-	 *
-	 * If set to one when LSO is '1', then the IPID of the tunnel
-	 * IP header will be incremented for each subsequent segment of an
-	 * LSO operation.
-	 *
-	 * The flag is ignored if the LSO packet is a normal (non-tunneled)
-	 * TCP packet.
+	 * An echo request from the firmware. An echo response is expected by
+	 * the firmware.
 	 */
-	#define PUSH32_DOORBELL_LFLAGS_T_IPID		UINT32_C(0x80)
+	#define HWRM_ASYNC_EVENT_CMPL_ECHO_REQUEST_EVENT_ID_ECHO_REQUEST UINT32_C(0x42)
+	#define HWRM_ASYNC_EVENT_CMPL_ECHO_REQUEST_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_ECHO_REQUEST_EVENT_ID_ECHO_REQUEST
+	/* Event specific data that should be provided in the echo response */
+	uint32_t	event_data2;
+	uint8_t	opaque_v;
 	/*
-	 * If set to '1', then the RoCE ICRC will be appended to the
-	 * packet.  Packet must be a valid RoCE format packet.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	#define PUSH32_DOORBELL_LFLAGS_ROCE_CRC	UINT32_C(0x100)
+	#define HWRM_ASYNC_EVENT_CMPL_ECHO_REQUEST_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_ECHO_REQUEST_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_ECHO_REQUEST_OPAQUE_SFT 1
+	/* 8-lsb timestamp from POR (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp from POR (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data that should be provided in the echo response */
+	uint32_t	event_data1;
+} hwrm_async_event_cmpl_echo_request_t, *phwrm_async_event_cmpl_echo_request_t;
+
+/* hwrm_async_event_cmpl_phc_update (size:128b/16B) */
+
+typedef struct hwrm_async_event_cmpl_phc_update {
+	uint16_t	type;
 	/*
-	 * If set to '1', then the FCoE CRC will be appended to the
-	 * packet.  Packet must be a valid FCoE format packet.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	#define PUSH32_DOORBELL_LFLAGS_FCOE_CRC	UINT32_C(0x200)
-	uint16_t	hdr_size;
+	#define HWRM_ASYNC_EVENT_CMPL_PHC_UPDATE_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_PHC_UPDATE_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_PHC_UPDATE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_PHC_UPDATE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_PHC_UPDATE_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
 	/*
-	 * When LSO is '1', this field must contain the offset of the
-	 * TCP payload from the beginning of the packet in as
-	 * 16b words. In case of encapsulated/tunneling packet, this field
-	 * contains the offset of the inner TCP payload from beginning of the
-	 * packet as 16-bit words.
-	 *
-	 * This value must be valid on the first BD of a packet.
+	 * This async event is used to notify driver of changes
+	 * in PHC master. Only one master function can configure
+	 * PHC.
 	 */
-	#define PUSH32_DOORBELL_HDR_SIZE_MASK UINT32_C(0x1ff)
-	#define PUSH32_DOORBELL_HDR_SIZE_SFT 0
-	uint32_t	mss;
+	#define HWRM_ASYNC_EVENT_CMPL_PHC_UPDATE_EVENT_ID_PHC_UPDATE UINT32_C(0x43)
+	#define HWRM_ASYNC_EVENT_CMPL_PHC_UPDATE_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_PHC_UPDATE_EVENT_ID_PHC_UPDATE
+	/* Event specific data */
+	uint32_t	event_data2;
+	/* This field provides the current master function. */
+	#define HWRM_ASYNC_EVENT_CMPL_PHC_UPDATE_EVENT_DATA2_PHC_MASTER_FID_MASK UINT32_C(0xffff)
+	#define HWRM_ASYNC_EVENT_CMPL_PHC_UPDATE_EVENT_DATA2_PHC_MASTER_FID_SFT 0
+	/* This field provides the current secondary function. */
+	#define HWRM_ASYNC_EVENT_CMPL_PHC_UPDATE_EVENT_DATA2_PHC_SEC_FID_MASK   UINT32_C(0xffff0000)
+	#define HWRM_ASYNC_EVENT_CMPL_PHC_UPDATE_EVENT_DATA2_PHC_SEC_FID_SFT	16
+	uint8_t	opaque_v;
 	/*
-	 * This is the MSS value that will be used to do the LSO processing.
-	 * The value is the length in bytes of the TCP payload for each
-	 * segment generated by the LSO operation.
-	 *
-	 * This value must be valid on the first BD of a packet.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	#define PUSH32_DOORBELL_MSS_MASK UINT32_C(0x7fff)
-	#define PUSH32_DOORBELL_MSS_SFT 0
-	uint16_t	unused_2;
+	#define HWRM_ASYNC_EVENT_CMPL_PHC_UPDATE_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_PHC_UPDATE_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_PHC_UPDATE_OPAQUE_SFT 1
+	/* 8-lsb timestamp (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data */
+	uint32_t	event_data1;
+	/* Indicates to the driver the type of PHC event. */
+	#define HWRM_ASYNC_EVENT_CMPL_PHC_UPDATE_EVENT_DATA1_FLAGS_MASK	UINT32_C(0xf)
+	#define HWRM_ASYNC_EVENT_CMPL_PHC_UPDATE_EVENT_DATA1_FLAGS_SFT	0
 	/*
-	 * This value selects a CFA action to perform on the packet.
-	 * Set this value to zero if no CFA action is desired.
-	 *
-	 * This value must be valid on the first BD of a packet.
+	 * Indicates PHC Master selection event. The master fid is
+	 * specified in event_data2.phc_master_fid.
 	 */
-	uint16_t	cfa_action;
+		#define HWRM_ASYNC_EVENT_CMPL_PHC_UPDATE_EVENT_DATA1_FLAGS_PHC_MASTER	UINT32_C(0x1)
 	/*
-	 * This value is action meta-data that defines CFA edit operations
-	 * that are done in addition to any action editing.
+	 * Indicates PHC Secondary selection event. The secondary fid is
+	 * specified in event_data2.phc_sec_fid.
 	 */
-	uint32_t	cfa_meta;
-	/* When key=1, This is the VLAN tag VID value. */
-	#define PUSH32_DOORBELL_CFA_META_VLAN_VID_MASK	UINT32_C(0xfff)
-	#define PUSH32_DOORBELL_CFA_META_VLAN_VID_SFT	0
-	/* When key=1, This is the VLAN tag DE value. */
-	#define PUSH32_DOORBELL_CFA_META_VLAN_DE	UINT32_C(0x1000)
-	/* When key=1, This is the VLAN tag PRI value. */
-	#define PUSH32_DOORBELL_CFA_META_VLAN_PRI_MASK	UINT32_C(0xe000)
-	#define PUSH32_DOORBELL_CFA_META_VLAN_PRI_SFT	13
-	/* When key=1, This is the VLAN tag TPID select value. */
-	#define PUSH32_DOORBELL_CFA_META_VLAN_TPID_MASK	UINT32_C(0x70000)
-	#define PUSH32_DOORBELL_CFA_META_VLAN_TPID_SFT	16
-	/* 0x88a8 */
-		#define PUSH32_DOORBELL_CFA_META_VLAN_TPID_TPID88A8  (UINT32_C(0x0) << 16)
-	/* 0x8100 */
-		#define PUSH32_DOORBELL_CFA_META_VLAN_TPID_TPID8100  (UINT32_C(0x1) << 16)
-	/* 0x9100 */
-		#define PUSH32_DOORBELL_CFA_META_VLAN_TPID_TPID9100  (UINT32_C(0x2) << 16)
-	/* 0x9200 */
-		#define PUSH32_DOORBELL_CFA_META_VLAN_TPID_TPID9200  (UINT32_C(0x3) << 16)
-	/* 0x9300 */
-		#define PUSH32_DOORBELL_CFA_META_VLAN_TPID_TPID9300  (UINT32_C(0x4) << 16)
-	/* Value programmed in CFA VLANTPID register. */
-		#define PUSH32_DOORBELL_CFA_META_VLAN_TPID_TPIDCFG   (UINT32_C(0x5) << 16)
-		#define PUSH32_DOORBELL_CFA_META_VLAN_TPID_LAST	PUSH32_DOORBELL_CFA_META_VLAN_TPID_TPIDCFG
-	/* When key=1, This is the VLAN tag TPID select value. */
-	#define PUSH32_DOORBELL_CFA_META_VLAN_RESERVED_MASK UINT32_C(0xff80000)
-	#define PUSH32_DOORBELL_CFA_META_VLAN_RESERVED_SFT 19
+		#define HWRM_ASYNC_EVENT_CMPL_PHC_UPDATE_EVENT_DATA1_FLAGS_PHC_SECONDARY   UINT32_C(0x2)
 	/*
-	 * This field identifies the type of edit to be performed
-	 * on the packet.
-	 *
-	 * This value must be valid on the first BD of a packet.
+	 * Indicates PHC failover event. Failover happens from
+	 * event_data2.phc_master_fid to event_data2.phc_sec_fid.
 	 */
-	#define PUSH32_DOORBELL_CFA_META_KEY_MASK	UINT32_C(0xf0000000)
-	#define PUSH32_DOORBELL_CFA_META_KEY_SFT	28
-	/* No editing */
-		#define PUSH32_DOORBELL_CFA_META_KEY_NONE		(UINT32_C(0x0) << 28)
+		#define HWRM_ASYNC_EVENT_CMPL_PHC_UPDATE_EVENT_DATA1_FLAGS_PHC_FAILOVER	UINT32_C(0x3)
 	/*
-	 * - meta[17:16] - TPID select value (0 = 0x8100).
-	 * - meta[15:12] - PRI/DE value.
-	 * - meta[11:0] - VID value.
+	 * Indicates that the 64bit Real time clock upper 16bits
+	 * have been updated due to PHC rollover. The updated
+	 * upper 16bits is in event_data1.phc_time_msb
 	 */
-		#define PUSH32_DOORBELL_CFA_META_KEY_VLAN_TAG	(UINT32_C(0x1) << 28)
-		#define PUSH32_DOORBELL_CFA_META_KEY_LAST	PUSH32_DOORBELL_CFA_META_KEY_VLAN_TAG
+		#define HWRM_ASYNC_EVENT_CMPL_PHC_UPDATE_EVENT_DATA1_FLAGS_PHC_RTC_UPDATE  UINT32_C(0x4)
+		#define HWRM_ASYNC_EVENT_CMPL_PHC_UPDATE_EVENT_DATA1_FLAGS_LAST	HWRM_ASYNC_EVENT_CMPL_PHC_UPDATE_EVENT_DATA1_FLAGS_PHC_RTC_UPDATE
 	/*
-	 * This is the data for the push packet.  If the packet
-	 * data does not fit in the first pass, data writing
-	 * can continue at offset 4 of the doorbell for up to 4 additional
-	 * passes for a total data size of 512B maximum.
+	 * This field provides the upper 16bits of the 64bit real
+	 * time clock.
 	 */
-	uint32_t	data[25];
-} push32_doorbell_t, *ppush32_doorbell_t;
-
-/*******************
- * hwrm_func_reset *
- *******************/
+	#define HWRM_ASYNC_EVENT_CMPL_PHC_UPDATE_EVENT_DATA1_PHC_TIME_MSB_MASK   UINT32_C(0xffff0)
+	#define HWRM_ASYNC_EVENT_CMPL_PHC_UPDATE_EVENT_DATA1_PHC_TIME_MSB_SFT	4
+} hwrm_async_event_cmpl_phc_update_t, *phwrm_async_event_cmpl_phc_update_t;
 
+/* hwrm_async_event_cmpl_pps_timestamp (size:128b/16B) */
 
-/* hwrm_func_reset_input (size:192b/24B) */
-
-typedef struct hwrm_func_reset_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
-	 */
-	uint16_t	cmpl_ring;
+typedef struct hwrm_async_event_cmpl_pps_timestamp {
+	uint16_t	type;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint16_t	seq_id;
+	#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * This async notification message can be used to inform
+	 * driver of the latest PPS timestamp that has been latched.
+	 * When driver enables PPS event, Firmware will generate
+	 * PPS timestamps every second, Firmware informs driver
+	 * of this timestamp through the async event.
 	 */
-	uint16_t	target_id;
+	#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_EVENT_ID_PPS_TIMESTAMP UINT32_C(0x44)
+	#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_EVENT_ID_PPS_TIMESTAMP
+	/* Event specific data */
+	uint32_t	event_data2;
+	/* Indicates the PPS event type */
+	#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_EVENT_DATA2_EVENT_TYPE		UINT32_C(0x1)
+	/* This is an internal event. */
+		#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_EVENT_DATA2_EVENT_TYPE_INTERNAL	UINT32_C(0x0)
+	/* This is an external event. */
+		#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_EVENT_DATA2_EVENT_TYPE_EXTERNAL	UINT32_C(0x1)
+		#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_EVENT_DATA2_EVENT_TYPE_LAST	HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_EVENT_DATA2_EVENT_TYPE_EXTERNAL
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Indicates the pin number on which the event is
+	 * received.
 	 */
-	uint64_t	resp_addr;
-	uint32_t	enables;
+	#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_EVENT_DATA2_PIN_NUMBER_MASK	UINT32_C(0xe)
+	#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_EVENT_DATA2_PIN_NUMBER_SFT	1
 	/*
-	 * This bit must be '1' for the vf_id_valid field to be
-	 * configured.
+	 * Contains bits[47:32] of the upper PPS timestamp.
+	 * Lower 32 bits are in event_data1. Together they
+	 * provide the 48 bit PPS timestamp.
 	 */
-	#define HWRM_FUNC_RESET_INPUT_ENABLES_VF_ID_VALID	UINT32_C(0x1)
+	#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_EVENT_DATA2_PPS_TIMESTAMP_UPPER_MASK UINT32_C(0xffff0)
+	#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_EVENT_DATA2_PPS_TIMESTAMP_UPPER_SFT 4
+	uint8_t	opaque_v;
 	/*
-	 * The ID of the VF that this PF is trying to reset.
-	 * Only the parent PF shall be allowed to reset a child VF.
-	 *
-	 * A parent PF driver shall use this field only when a specific child VF
-	 * is requested to be reset.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint16_t	vf_id;
-	/* This value indicates the level of a function reset. */
-	uint8_t	func_reset_level;
+	#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_OPAQUE_SFT 1
+	/* 8-lsb timestamp (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Contains the lower 32 bits of the PPS timestamp. */
+	uint32_t	event_data1;
+	/* Contains the lower 32 bit PPS timestamp */
+	#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_EVENT_DATA1_PPS_TIMESTAMP_LOWER_MASK UINT32_C(0xffffffff)
+	#define HWRM_ASYNC_EVENT_CMPL_PPS_TIMESTAMP_EVENT_DATA1_PPS_TIMESTAMP_LOWER_SFT 0
+} hwrm_async_event_cmpl_pps_timestamp_t, *phwrm_async_event_cmpl_pps_timestamp_t;
+
+/* hwrm_async_event_cmpl_error_report (size:128b/16B) */
+
+typedef struct hwrm_async_event_cmpl_error_report {
+	uint16_t	type;
 	/*
-	 * Reset the caller function and its children VFs (if any). If no
-	 * children functions exist, then reset the caller function only.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	#define HWRM_FUNC_RESET_INPUT_FUNC_RESET_LEVEL_RESETALL	UINT32_C(0x0)
-	/* Reset the caller function only */
-	#define HWRM_FUNC_RESET_INPUT_FUNC_RESET_LEVEL_RESETME	UINT32_C(0x1)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
 	/*
-	 * Reset all children VFs of the caller function driver if the
-	 * caller is a PF driver.
-	 * It is an error to specify this level by a VF driver.
-	 * It is an error to specify this level by a PF driver with
-	 * no children VFs.
+	 * This async notification message is used to inform
+	 * the driver that an error has occurred which may need
+	 * the attention of the administrator.
 	 */
-	#define HWRM_FUNC_RESET_INPUT_FUNC_RESET_LEVEL_RESETCHILDREN UINT32_C(0x2)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_EVENT_ID_ERROR_REPORT UINT32_C(0x45)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_EVENT_ID_ERROR_REPORT
+	/* Event specific data. */
+	uint32_t	event_data2;
+	uint8_t	opaque_v;
 	/*
-	 * Reset a specific VF of the caller function driver if the caller
-	 * is the parent PF driver.
-	 * It is an error to specify this level by a VF driver.
-	 * It is an error to specify this level by a PF driver that is not
-	 * the parent of the VF that is being requested to reset.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	#define HWRM_FUNC_RESET_INPUT_FUNC_RESET_LEVEL_RESETVF	UINT32_C(0x3)
-	#define HWRM_FUNC_RESET_INPUT_FUNC_RESET_LEVEL_LAST	HWRM_FUNC_RESET_INPUT_FUNC_RESET_LEVEL_RESETVF
-	uint8_t	unused_0;
-} hwrm_func_reset_input_t, *phwrm_func_reset_input_t;
-
-/* hwrm_func_reset_output (size:128b/16B) */
-
-typedef struct hwrm_func_reset_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_OPAQUE_SFT 1
+	/* 8-lsb timestamp (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data */
+	uint32_t	event_data1;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * Indicates the type of error being reported. See section on Error
+	 * Report event error_types for details on each error.
 	 */
-	uint8_t	valid;
-} hwrm_func_reset_output_t, *phwrm_func_reset_output_t;
-
-/********************
- * hwrm_func_getfid *
- ********************/
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_EVENT_DATA1_ERROR_TYPE_MASK UINT32_C(0xff)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_EVENT_DATA1_ERROR_TYPE_SFT 0
+} hwrm_async_event_cmpl_error_report_t, *phwrm_async_event_cmpl_error_report_t;
 
+/* hwrm_async_event_cmpl_doorbell_pacing_threshold (size:128b/16B) */
 
-/* hwrm_func_getfid_input (size:192b/24B) */
-
-typedef struct hwrm_func_getfid_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+typedef struct hwrm_async_event_cmpl_doorbell_pacing_threshold {
+	uint16_t	type;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint16_t	cmpl_ring;
+	#define HWRM_ASYNC_EVENT_CMPL_DOORBELL_PACING_THRESHOLD_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_DOORBELL_PACING_THRESHOLD_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_DOORBELL_PACING_THRESHOLD_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_DOORBELL_PACING_THRESHOLD_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_DOORBELL_PACING_THRESHOLD_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * This async notification message is used to inform the driver
+	 * that the programmable pacing threshold for the doorbell FIFO is
+	 * reached. The driver will take appropriate action to pace the
+	 * doorbells when this async event is received from the firmware.
 	 */
-	uint16_t	seq_id;
+	#define HWRM_ASYNC_EVENT_CMPL_DOORBELL_PACING_THRESHOLD_EVENT_ID_DOORBELL_PACING_THRESHOLD UINT32_C(0x46)
+	#define HWRM_ASYNC_EVENT_CMPL_DOORBELL_PACING_THRESHOLD_EVENT_ID_LAST			HWRM_ASYNC_EVENT_CMPL_DOORBELL_PACING_THRESHOLD_EVENT_ID_DOORBELL_PACING_THRESHOLD
+	/* Event specific data. */
+	uint32_t	event_data2;
+	uint8_t	opaque_v;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint16_t	target_id;
+	#define HWRM_ASYNC_EVENT_CMPL_DOORBELL_PACING_THRESHOLD_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_DOORBELL_PACING_THRESHOLD_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_DOORBELL_PACING_THRESHOLD_OPAQUE_SFT 1
+	/* 8-lsb timestamp (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data */
+	uint32_t	event_data1;
+} hwrm_async_event_cmpl_doorbell_pacing_threshold_t, *phwrm_async_event_cmpl_doorbell_pacing_threshold_t;
+
+/* hwrm_async_event_cmpl_rss_change (size:128b/16B) */
+
+typedef struct hwrm_async_event_cmpl_rss_change {
+	uint16_t	type;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint64_t	resp_addr;
-	uint32_t	enables;
+	#define HWRM_ASYNC_EVENT_CMPL_RSS_CHANGE_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_RSS_CHANGE_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_RSS_CHANGE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_RSS_CHANGE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_RSS_CHANGE_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
 	/*
-	 * This bit must be '1' for the pci_id field to be
-	 * configured.
+	 * This async notification message is used to inform the driver
+	 * that the RSS capabilities have changed. The driver will need
+	 * to query hwrm_vnic_qcaps.
 	 */
-	#define HWRM_FUNC_GETFID_INPUT_ENABLES_PCI_ID	UINT32_C(0x1)
+	#define HWRM_ASYNC_EVENT_CMPL_RSS_CHANGE_EVENT_ID_RSS_CHANGE UINT32_C(0x47)
+	#define HWRM_ASYNC_EVENT_CMPL_RSS_CHANGE_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_RSS_CHANGE_EVENT_ID_RSS_CHANGE
+	/* Event specific data. */
+	uint32_t	event_data2;
+	uint8_t	opaque_v;
 	/*
-	 * This value is the PCI ID of the queried function.
-	 * If ARI is enabled, then it is
-	 * Bus Number (8b):Function Number(8b). Otherwise, it is
-	 * Bus Number (8b):Device Number (5b):Function Number(3b).
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint16_t	pci_id;
-	uint8_t	unused_0[2];
-} hwrm_func_getfid_input_t, *phwrm_func_getfid_input_t;
+	#define HWRM_ASYNC_EVENT_CMPL_RSS_CHANGE_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_RSS_CHANGE_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_RSS_CHANGE_OPAQUE_SFT 1
+	/* 8-lsb timestamp (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data */
+	uint32_t	event_data1;
+} hwrm_async_event_cmpl_rss_change_t, *phwrm_async_event_cmpl_rss_change_t;
 
-/* hwrm_func_getfid_output (size:128b/16B) */
+/* hwrm_async_event_cmpl_doorbell_pacing_nq_update (size:128b/16B) */
 
-typedef struct hwrm_func_getfid_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
+typedef struct hwrm_async_event_cmpl_doorbell_pacing_nq_update {
+	uint16_t	type;
 	/*
-	 * FID value.  This value is used to identify operations on the PCI
-	 * bus as belonging to a particular PCI function.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint16_t	fid;
-	uint8_t	unused_0[5];
+	#define HWRM_ASYNC_EVENT_CMPL_DOORBELL_PACING_NQ_UPDATE_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_DOORBELL_PACING_NQ_UPDATE_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_DOORBELL_PACING_NQ_UPDATE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_DOORBELL_PACING_NQ_UPDATE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_DOORBELL_PACING_NQ_UPDATE_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * An event from firmware indicating that list of nq ids used for
+	 * doorbell pacing DBQ event notification has been updated. The driver
+	 * needs to take appropriate action and retrieve the new list when this
+	 * event is received from the firmware.
 	 */
-	uint8_t	valid;
-} hwrm_func_getfid_output_t, *phwrm_func_getfid_output_t;
-
-/**********************
- * hwrm_func_vf_alloc *
- **********************/
-
+	#define HWRM_ASYNC_EVENT_CMPL_DOORBELL_PACING_NQ_UPDATE_EVENT_ID_DOORBELL_PACING_NQ_UPDATE UINT32_C(0x48)
+	#define HWRM_ASYNC_EVENT_CMPL_DOORBELL_PACING_NQ_UPDATE_EVENT_ID_LAST			HWRM_ASYNC_EVENT_CMPL_DOORBELL_PACING_NQ_UPDATE_EVENT_ID_DOORBELL_PACING_NQ_UPDATE
+	/* Event specific data. */
+	uint32_t	event_data2;
+	uint8_t	opaque_v;
+	/*
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_DOORBELL_PACING_NQ_UPDATE_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_DOORBELL_PACING_NQ_UPDATE_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_DOORBELL_PACING_NQ_UPDATE_OPAQUE_SFT 1
+	/* 8-lsb timestamp (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data */
+	uint32_t	event_data1;
+} hwrm_async_event_cmpl_doorbell_pacing_nq_update_t, *phwrm_async_event_cmpl_doorbell_pacing_nq_update_t;
 
-/* hwrm_func_vf_alloc_input (size:192b/24B) */
+/* hwrm_async_event_cmpl_hw_doorbell_recovery_read_error (size:128b/16B) */
 
-typedef struct hwrm_func_vf_alloc_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+typedef struct hwrm_async_event_cmpl_hw_doorbell_recovery_read_error {
+	uint16_t	type;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint16_t	cmpl_ring;
+	#define HWRM_ASYNC_EVENT_CMPL_HW_DOORBELL_RECOVERY_READ_ERROR_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_HW_DOORBELL_RECOVERY_READ_ERROR_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_HW_DOORBELL_RECOVERY_READ_ERROR_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_HW_DOORBELL_RECOVERY_READ_ERROR_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_HW_DOORBELL_RECOVERY_READ_ERROR_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * This async notification message is used to inform the driver
+	 * that hardware ran into an error while trying to read the host
+	 * based doorbell copy region. The driver will take the appropriate
+	 * action to maintain the corresponding functions doorbell copy
+	 * region in the correct format.
 	 */
-	uint16_t	seq_id;
+	#define HWRM_ASYNC_EVENT_CMPL_HW_DOORBELL_RECOVERY_READ_ERROR_EVENT_ID_HW_DOORBELL_RECOVERY_READ_ERROR UINT32_C(0x49)
+	#define HWRM_ASYNC_EVENT_CMPL_HW_DOORBELL_RECOVERY_READ_ERROR_EVENT_ID_LAST			HWRM_ASYNC_EVENT_CMPL_HW_DOORBELL_RECOVERY_READ_ERROR_EVENT_ID_HW_DOORBELL_RECOVERY_READ_ERROR
+	/* Event specific data. */
+	uint32_t	event_data2;
+	uint8_t	opaque_v;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint16_t	target_id;
+	#define HWRM_ASYNC_EVENT_CMPL_HW_DOORBELL_RECOVERY_READ_ERROR_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_HW_DOORBELL_RECOVERY_READ_ERROR_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_HW_DOORBELL_RECOVERY_READ_ERROR_OPAQUE_SFT 1
+	/* 8-lsb timestamp (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data */
+	uint32_t	event_data1;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Indicates that there is an error while reading the doorbell copy
+	 * regions.
 	 */
-	uint64_t	resp_addr;
-	uint32_t	enables;
+	#define HWRM_ASYNC_EVENT_CMPL_HW_DOORBELL_RECOVERY_READ_ERROR_EVENT_DATA1_READ_ERROR_FLAGS_MASK	UINT32_C(0xf)
+	#define HWRM_ASYNC_EVENT_CMPL_HW_DOORBELL_RECOVERY_READ_ERROR_EVENT_DATA1_READ_ERROR_FLAGS_SFT	0
 	/*
-	 * This bit must be '1' for the first_vf_id field to be
-	 * configured.
+	 * If set to 1, indicates that there is an error while reading the
+	 * SQ doorbell copy region for this function.
 	 */
-	#define HWRM_FUNC_VF_ALLOC_INPUT_ENABLES_FIRST_VF_ID	UINT32_C(0x1)
+	#define HWRM_ASYNC_EVENT_CMPL_HW_DOORBELL_RECOVERY_READ_ERROR_EVENT_DATA1_READ_ERROR_FLAGS_SQ_ERR	UINT32_C(0x1)
 	/*
-	 * This value is used to identify a Virtual Function (VF).
-	 * The scope of VF ID is local within a PF.
+	 * If set to 1, indicates that there is an error while reading the
+	 * RQ doorbell copy region for this function.
 	 */
-	uint16_t	first_vf_id;
-	/* The number of virtual functions requested. */
-	uint16_t	num_vfs;
-} hwrm_func_vf_alloc_input_t, *phwrm_func_vf_alloc_input_t;
-
-/* hwrm_func_vf_alloc_output (size:128b/16B) */
-
-typedef struct hwrm_func_vf_alloc_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* The ID of the first VF allocated. */
-	uint16_t	first_vf_id;
-	uint8_t	unused_0[5];
+	#define HWRM_ASYNC_EVENT_CMPL_HW_DOORBELL_RECOVERY_READ_ERROR_EVENT_DATA1_READ_ERROR_FLAGS_RQ_ERR	UINT32_C(0x2)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * If set to 1, indicates that there is an error while reading the
+	 * SRQ doorbell copy region for this function.
 	 */
-	uint8_t	valid;
-} hwrm_func_vf_alloc_output_t, *phwrm_func_vf_alloc_output_t;
+	#define HWRM_ASYNC_EVENT_CMPL_HW_DOORBELL_RECOVERY_READ_ERROR_EVENT_DATA1_READ_ERROR_FLAGS_SRQ_ERR	UINT32_C(0x4)
+	/*
+	 * If set to 1, indicates that there is an error while reading the
+	 * CQ doorbell copy region for this function.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_HW_DOORBELL_RECOVERY_READ_ERROR_EVENT_DATA1_READ_ERROR_FLAGS_CQ_ERR	UINT32_C(0x8)
+} hwrm_async_event_cmpl_hw_doorbell_recovery_read_error_t, *phwrm_async_event_cmpl_hw_doorbell_recovery_read_error_t;
 
-/*********************
- * hwrm_func_vf_free *
- *********************/
+/* hwrm_async_event_cmpl_ctx_error (size:128b/16B) */
 
+typedef struct hwrm_async_event_cmpl_ctx_error {
+	uint16_t	type;
+	/*
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_CTX_ERROR_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_CTX_ERROR_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_CTX_ERROR_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_CTX_ERROR_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_CTX_ERROR_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
+	/*
+	 * This async notification message is used to inform the PF driver
+	 * that firmware fails to allocate/free the contexts requested. This
+	 * message is only valid in the XID partition scheme. Given the start
+	 * xid and the number of contexts in error, the PF driver will figure
+	 * out the corresponding XID partition(s) in error.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_CTX_ERROR_EVENT_ID_CTX_ERROR UINT32_C(0x4a)
+	#define HWRM_ASYNC_EVENT_CMPL_CTX_ERROR_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_CTX_ERROR_EVENT_ID_CTX_ERROR
+	/* Event specific data */
+	uint32_t	event_data2;
+	/* Context operation code */
+	#define HWRM_ASYNC_EVENT_CMPL_CTX_ERROR_EVENT_DATA2_CTX_OP_CODE	UINT32_C(0x1)
+	/* Context alloc failure */
+		#define HWRM_ASYNC_EVENT_CMPL_CTX_ERROR_EVENT_DATA2_CTX_OP_CODE_ALLOC  UINT32_C(0x0)
+	/* Context free failure */
+		#define HWRM_ASYNC_EVENT_CMPL_CTX_ERROR_EVENT_DATA2_CTX_OP_CODE_FREE   UINT32_C(0x1)
+		#define HWRM_ASYNC_EVENT_CMPL_CTX_ERROR_EVENT_DATA2_CTX_OP_CODE_LAST  HWRM_ASYNC_EVENT_CMPL_CTX_ERROR_EVENT_DATA2_CTX_OP_CODE_FREE
+	/* Number of contexts in error */
+	#define HWRM_ASYNC_EVENT_CMPL_CTX_ERROR_EVENT_DATA2_NUM_CTXS_MASK	UINT32_C(0xfffe)
+	#define HWRM_ASYNC_EVENT_CMPL_CTX_ERROR_EVENT_DATA2_NUM_CTXS_SFT	1
+	/* Function ID which the XID partitions are associated with */
+	#define HWRM_ASYNC_EVENT_CMPL_CTX_ERROR_EVENT_DATA2_FID_MASK	UINT32_C(0xffff0000)
+	#define HWRM_ASYNC_EVENT_CMPL_CTX_ERROR_EVENT_DATA2_FID_SFT	16
+	uint8_t	opaque_v;
+	/*
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_CTX_ERROR_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_CTX_ERROR_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_CTX_ERROR_OPAQUE_SFT 1
+	/* 8-lsb timestamp (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data */
+	uint32_t	event_data1;
+	/* Starting XID that has error */
+	#define HWRM_ASYNC_EVENT_CMPL_CTX_ERROR_EVENT_DATA1_START_XID_MASK UINT32_C(0xffffffff)
+	#define HWRM_ASYNC_EVENT_CMPL_CTX_ERROR_EVENT_DATA1_START_XID_SFT 0
+} hwrm_async_event_cmpl_ctx_error_t, *phwrm_async_event_cmpl_ctx_error_t;
 
-/* hwrm_func_vf_free_input (size:192b/24B) */
+/* hwrm_async_event_udcc_session_change (size:128b/16B) */
 
-typedef struct hwrm_func_vf_free_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+typedef struct hwrm_async_event_udcc_session_change {
+	uint16_t	type;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint16_t	cmpl_ring;
+	#define HWRM_ASYNC_EVENT_UDCC_SESSION_CHANGE_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_UDCC_SESSION_CHANGE_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_UDCC_SESSION_CHANGE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_UDCC_SESSION_CHANGE_TYPE_LAST		HWRM_ASYNC_EVENT_UDCC_SESSION_CHANGE_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * This async notification message is used to inform the PF driver
+	 * that firmware has modified a UDCC session.
 	 */
-	uint16_t	seq_id;
+	#define HWRM_ASYNC_EVENT_UDCC_SESSION_CHANGE_EVENT_ID_UDCC_SESSION_CHANGE UINT32_C(0x4b)
+	#define HWRM_ASYNC_EVENT_UDCC_SESSION_CHANGE_EVENT_ID_LAST		HWRM_ASYNC_EVENT_UDCC_SESSION_CHANGE_EVENT_ID_UDCC_SESSION_CHANGE
+	/* Event specific data */
+	uint32_t	event_data2;
+	/* UDCC Session id operation code */
+	#define HWRM_ASYNC_EVENT_UDCC_SESSION_CHANGE_EVENT_DATA2_SESSION_ID_OP_CODE_MASK   UINT32_C(0xff)
+	#define HWRM_ASYNC_EVENT_UDCC_SESSION_CHANGE_EVENT_DATA2_SESSION_ID_OP_CODE_SFT	0
+	/* session_id has been created */
+		#define HWRM_ASYNC_EVENT_UDCC_SESSION_CHANGE_EVENT_DATA2_SESSION_ID_OP_CODE_CREATED  UINT32_C(0x0)
+	/* session_id has been freed */
+		#define HWRM_ASYNC_EVENT_UDCC_SESSION_CHANGE_EVENT_DATA2_SESSION_ID_OP_CODE_FREED	UINT32_C(0x1)
+		#define HWRM_ASYNC_EVENT_UDCC_SESSION_CHANGE_EVENT_DATA2_SESSION_ID_OP_CODE_LAST	HWRM_ASYNC_EVENT_UDCC_SESSION_CHANGE_EVENT_DATA2_SESSION_ID_OP_CODE_FREED
+	uint8_t	opaque_v;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint16_t	target_id;
+	#define HWRM_ASYNC_EVENT_UDCC_SESSION_CHANGE_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_UDCC_SESSION_CHANGE_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_UDCC_SESSION_CHANGE_OPAQUE_SFT 1
+	/* 8-lsb timestamp (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data */
+	uint32_t	event_data1;
+	/* UDCC session id which was modified */
+	#define HWRM_ASYNC_EVENT_UDCC_SESSION_CHANGE_EVENT_DATA1_UDCC_SESSION_ID_MASK UINT32_C(0xffff)
+	#define HWRM_ASYNC_EVENT_UDCC_SESSION_CHANGE_EVENT_DATA1_UDCC_SESSION_ID_SFT 0
+} hwrm_async_event_udcc_session_change_t, *phwrm_async_event_udcc_session_change_t;
+
+/* hwrm_async_event_cmpl_dbg_buf_producer (size:128b/16B) */
+
+typedef struct hwrm_async_event_cmpl_dbg_buf_producer {
+	uint16_t	type;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint64_t	resp_addr;
-	uint32_t	enables;
+	#define HWRM_ASYNC_EVENT_CMPL_DBG_BUF_PRODUCER_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_DBG_BUF_PRODUCER_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_DBG_BUF_PRODUCER_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_DBG_BUF_PRODUCER_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_DBG_BUF_PRODUCER_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
 	/*
-	 * This bit must be '1' for the first_vf_id field to be
-	 * configured.
+	 * Used to notify the host that the firmware has DMA-ed additional
+	 * debug data to the host buffer. This is effectively a producer index
+	 * update. The host driver can utilize this information to determine
+	 * how much of its host buffer has been populated by the firmware.
 	 */
-	#define HWRM_FUNC_VF_FREE_INPUT_ENABLES_FIRST_VF_ID	UINT32_C(0x1)
+	#define HWRM_ASYNC_EVENT_CMPL_DBG_BUF_PRODUCER_EVENT_ID_DBG_BUF_PRODUCER UINT32_C(0x4c)
+	#define HWRM_ASYNC_EVENT_CMPL_DBG_BUF_PRODUCER_EVENT_ID_LAST		HWRM_ASYNC_EVENT_CMPL_DBG_BUF_PRODUCER_EVENT_ID_DBG_BUF_PRODUCER
+	/* Event specific data */
+	uint32_t	event_data2;
 	/*
-	 * This value is used to identify a Virtual Function (VF).
-	 * The scope of VF ID is local within a PF.
+	 * Specifies the current host buffer offset. Data up to this offset
+	 * has been populated by the firmware. For example, if the firmware
+	 * has DMA-ed 8192 bytes to the host buffer, then this field has a
+	 * value of 8192. This field rolls over to zero once the firmware
+	 * writes the last page of the host buffer
 	 */
-	uint16_t	first_vf_id;
+	#define HWRM_ASYNC_EVENT_CMPL_DBG_BUF_PRODUCER_EVENT_DATA2_CURRENT_BUFFER_OFFSET_MASK UINT32_C(0xffffffff)
+	#define HWRM_ASYNC_EVENT_CMPL_DBG_BUF_PRODUCER_EVENT_DATA2_CURRENT_BUFFER_OFFSET_SFT 0
+	uint8_t	opaque_v;
 	/*
-	 * The number of virtual functions requested.
-	 * 0xFFFF - Cleanup all children of this PF.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint16_t	num_vfs;
-} hwrm_func_vf_free_input_t, *phwrm_func_vf_free_input_t;
+	#define HWRM_ASYNC_EVENT_CMPL_DBG_BUF_PRODUCER_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_DBG_BUF_PRODUCER_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_DBG_BUF_PRODUCER_OPAQUE_SFT 1
+	/* 8-lsb timestamp from POR (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp from POR (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data */
+	uint32_t	event_data1;
+	/* Type of trace buffer that has been updated. */
+	#define HWRM_ASYNC_EVENT_CMPL_DBG_BUF_PRODUCER_EVENT_DATA1_TYPE_MASK	UINT32_C(0xffff)
+	#define HWRM_ASYNC_EVENT_CMPL_DBG_BUF_PRODUCER_EVENT_DATA1_TYPE_SFT		0
+	/* SRT trace. */
+		#define HWRM_ASYNC_EVENT_CMPL_DBG_BUF_PRODUCER_EVENT_DATA1_TYPE_SRT_TRACE	UINT32_C(0x0)
+	/* SRT2 trace. */
+		#define HWRM_ASYNC_EVENT_CMPL_DBG_BUF_PRODUCER_EVENT_DATA1_TYPE_SRT2_TRACE	UINT32_C(0x1)
+	/* CRT trace. */
+		#define HWRM_ASYNC_EVENT_CMPL_DBG_BUF_PRODUCER_EVENT_DATA1_TYPE_CRT_TRACE	UINT32_C(0x2)
+	/* CRT2 trace. */
+		#define HWRM_ASYNC_EVENT_CMPL_DBG_BUF_PRODUCER_EVENT_DATA1_TYPE_CRT2_TRACE	UINT32_C(0x3)
+	/* RIGP0 trace. */
+		#define HWRM_ASYNC_EVENT_CMPL_DBG_BUF_PRODUCER_EVENT_DATA1_TYPE_RIGP0_TRACE	UINT32_C(0x4)
+	/* L2 HWRM trace. */
+		#define HWRM_ASYNC_EVENT_CMPL_DBG_BUF_PRODUCER_EVENT_DATA1_TYPE_L2_HWRM_TRACE	UINT32_C(0x5)
+	/* RoCE HWRM trace. */
+		#define HWRM_ASYNC_EVENT_CMPL_DBG_BUF_PRODUCER_EVENT_DATA1_TYPE_ROCE_HWRM_TRACE  UINT32_C(0x6)
+		#define HWRM_ASYNC_EVENT_CMPL_DBG_BUF_PRODUCER_EVENT_DATA1_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_DBG_BUF_PRODUCER_EVENT_DATA1_TYPE_ROCE_HWRM_TRACE
+} hwrm_async_event_cmpl_dbg_buf_producer_t, *phwrm_async_event_cmpl_dbg_buf_producer_t;
 
-/* hwrm_func_vf_free_output (size:128b/16B) */
+/* hwrm_async_event_cmpl_fw_trace_msg (size:128b/16B) */
 
-typedef struct hwrm_func_vf_free_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+typedef struct hwrm_async_event_cmpl_fw_trace_msg {
+	uint16_t	type;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint8_t	valid;
-} hwrm_func_vf_free_output_t, *phwrm_func_vf_free_output_t;
+	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
+	/* Firmware trace log message */
+	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_ID_FW_TRACE_MSG UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_ID_FW_TRACE_MSG
+	/* Trace byte 0 to 3 */
+	uint32_t	event_data2;
+	/* Trace byte0 */
+	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_DATA2_BYTE0_MASK UINT32_C(0xff)
+	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_DATA2_BYTE0_SFT 0
+	/* Trace byte1 */
+	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_DATA2_BYTE1_MASK UINT32_C(0xff00)
+	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_DATA2_BYTE1_SFT 8
+	/* Trace byte2 */
+	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_DATA2_BYTE2_MASK UINT32_C(0xff0000)
+	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_DATA2_BYTE2_SFT 16
+	/* Trace byte3 */
+	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_DATA2_BYTE3_MASK UINT32_C(0xff000000)
+	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_DATA2_BYTE3_SFT 24
+	uint8_t	opaque_v;
+	/*
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_OPAQUE_SFT 1
+	/* Trace flags */
+	uint8_t	timestamp_lo;
+	/* Indicates if the string is partial or complete. */
+	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TIMESTAMP_LO_STRING		UINT32_C(0x1)
+	/* Complete string */
+		#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TIMESTAMP_LO_STRING_COMPLETE	UINT32_C(0x0)
+	/* Partial string */
+		#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TIMESTAMP_LO_STRING_PARTIAL	UINT32_C(0x1)
+		#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TIMESTAMP_LO_STRING_LAST	HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TIMESTAMP_LO_STRING_PARTIAL
+	/* Indicates the firmware that sent the trace message. */
+	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TIMESTAMP_LO_FIRMWARE	UINT32_C(0x2)
+	/* Primary firmware */
+		#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TIMESTAMP_LO_FIRMWARE_PRIMARY	(UINT32_C(0x0) << 1)
+	/* Secondary firmware */
+		#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TIMESTAMP_LO_FIRMWARE_SECONDARY  (UINT32_C(0x1) << 1)
+		#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TIMESTAMP_LO_FIRMWARE_LAST	HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TIMESTAMP_LO_FIRMWARE_SECONDARY
+	/* Trace byte 4 to 5 */
+	uint16_t	timestamp_hi;
+	/* Trace byte4 */
+	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TIMESTAMP_HI_BYTE4_MASK UINT32_C(0xff)
+	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TIMESTAMP_HI_BYTE4_SFT 0
+	/* Trace byte5 */
+	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TIMESTAMP_HI_BYTE5_MASK UINT32_C(0xff00)
+	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_TIMESTAMP_HI_BYTE5_SFT 8
+	/* Trace byte 6 to 9 */
+	uint32_t	event_data1;
+	/* Trace byte6 */
+	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_DATA1_BYTE6_MASK UINT32_C(0xff)
+	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_DATA1_BYTE6_SFT 0
+	/* Trace byte7 */
+	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_DATA1_BYTE7_MASK UINT32_C(0xff00)
+	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_DATA1_BYTE7_SFT 8
+	/* Trace byte8 */
+	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_DATA1_BYTE8_MASK UINT32_C(0xff0000)
+	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_DATA1_BYTE8_SFT 16
+	/* Trace byte9 */
+	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_DATA1_BYTE9_MASK UINT32_C(0xff000000)
+	#define HWRM_ASYNC_EVENT_CMPL_FW_TRACE_MSG_EVENT_DATA1_BYTE9_SFT 24
+} hwrm_async_event_cmpl_fw_trace_msg_t, *phwrm_async_event_cmpl_fw_trace_msg_t;
 
-/********************
- * hwrm_func_vf_cfg *
- ********************/
+/* hwrm_async_event_cmpl_hwrm_error (size:128b/16B) */
 
+typedef struct hwrm_async_event_cmpl_hwrm_error {
+	uint16_t	type;
+	/*
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
+	/* HWRM Error */
+	#define HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_EVENT_ID_HWRM_ERROR UINT32_C(0xff)
+	#define HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_EVENT_ID_HWRM_ERROR
+	/* Event specific data */
+	uint32_t	event_data2;
+	/* Severity of HWRM Error */
+	#define HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_EVENT_DATA2_SEVERITY_MASK	UINT32_C(0xff)
+	#define HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_EVENT_DATA2_SEVERITY_SFT	0
+	/* Warning */
+		#define HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_EVENT_DATA2_SEVERITY_WARNING   UINT32_C(0x0)
+	/* Non-fatal Error */
+		#define HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_EVENT_DATA2_SEVERITY_NONFATAL  UINT32_C(0x1)
+	/* Fatal Error */
+		#define HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_EVENT_DATA2_SEVERITY_FATAL	UINT32_C(0x2)
+		#define HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_EVENT_DATA2_SEVERITY_LAST	HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_EVENT_DATA2_SEVERITY_FATAL
+	uint8_t	opaque_v;
+	/*
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_OPAQUE_SFT 1
+	/* 8-lsb timestamp from POR (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp from POR (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data */
+	uint32_t	event_data1;
+	/* Time stamp for error event */
+	#define HWRM_ASYNC_EVENT_CMPL_HWRM_ERROR_EVENT_DATA1_TIMESTAMP	UINT32_C(0x1)
+} hwrm_async_event_cmpl_hwrm_error_t, *phwrm_async_event_cmpl_hwrm_error_t;
 
-/* hwrm_func_vf_cfg_input (size:448b/56B) */
+/* hwrm_async_event_cmpl_error_report_base (size:128b/16B) */
 
-typedef struct hwrm_func_vf_cfg_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+typedef struct hwrm_async_event_cmpl_error_report_base {
+	uint16_t	type;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint16_t	cmpl_ring;
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * This async notification message is used to inform
+	 * the driver that an error has occurred which may need
+	 * the attention of the administrator.
 	 */
-	uint16_t	seq_id;
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_ID_ERROR_REPORT UINT32_C(0x45)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_ID_ERROR_REPORT
+	/* Event specific data. */
+	uint32_t	event_data2;
+	uint8_t	opaque_v;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint16_t	target_id;
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_OPAQUE_SFT 1
+	/* 8-lsb timestamp (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data */
+	uint32_t	event_data1;
+	/* Indicates the type of error being reported. */
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_MASK			UINT32_C(0xff)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_SFT			0
+	/* Reserved */
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_RESERVED			UINT32_C(0x0)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * The NIC was subjected to an extended pause storm which caused it
+	 * to disable flow control in order to avoid stalling the Tx path.
 	 */
-	uint64_t	resp_addr;
-	uint32_t	enables;
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_PAUSE_STORM		UINT32_C(0x1)
 	/*
-	 * This bit must be '1' for the mtu field to be
-	 * configured.
+	 * The NIC received an interrupt storm on a TSIO pin being used as
+	 * PPS_IN which caused it to disable the interrupt. The signal
+	 * should be fixed to be a proper 1 PPS signal before re-enabling
+	 * it. The pin number on which this signal was received is stored
+	 * in event_data2 as pin_id.
 	 */
-	#define HWRM_FUNC_VF_CFG_INPUT_ENABLES_MTU		UINT32_C(0x1)
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_INVALID_SIGNAL		UINT32_C(0x2)
 	/*
-	 * This bit must be '1' for the guest_vlan field to be
-	 * configured.
+	 * There was a low level error with an NVM write or erase.
+	 * See nvm_err_type for more details.
 	 */
-	#define HWRM_FUNC_VF_CFG_INPUT_ENABLES_GUEST_VLAN	UINT32_C(0x2)
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_NVM			UINT32_C(0x3)
 	/*
-	 * This bit must be '1' for the async_event_cr field to be
-	 * configured.
+	 * This indicates doorbell drop threshold was hit. When this
+	 * threshold is crossed, it indicates one or more doorbells for
+	 * the function were dropped by hardware.
 	 */
-	#define HWRM_FUNC_VF_CFG_INPUT_ENABLES_ASYNC_EVENT_CR	UINT32_C(0x4)
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_DOORBELL_DROP_THRESHOLD	UINT32_C(0x4)
 	/*
-	 * This bit must be '1' for the dflt_mac_addr field to be
-	 * configured.
+	 * Indicates the NIC's temperature has crossed one of the thermal
+	 * thresholds.
 	 */
-	#define HWRM_FUNC_VF_CFG_INPUT_ENABLES_DFLT_MAC_ADDR	UINT32_C(0x8)
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_THERMAL_THRESHOLD		UINT32_C(0x5)
 	/*
-	 * This bit must be '1' for the num_rsscos_ctxs field to be
-	 * configured.
+	 * Speed change not supported with dual rate transceivers
+	 * on this board.
 	 */
-	#define HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_RSSCOS_CTXS	UINT32_C(0x10)
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_DUAL_DATA_RATE_NOT_SUPPORTED  UINT32_C(0x6)
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_LAST			HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_DUAL_DATA_RATE_NOT_SUPPORTED
+} hwrm_async_event_cmpl_error_report_base_t, *phwrm_async_event_cmpl_error_report_base_t;
+
+#define GET_ERROR_REPORT_TYPE(x) \
+	(((x) < 0x80) ? \
+	((x) == 0x0 ? "RESERVED": \
+	((x) == 0x1 ? "PAUSE_STORM": \
+	((x) == 0x2 ? "INVALID_SIGNAL": \
+	((x) == 0x3 ? "NVM": \
+	((x) == 0x4 ? "DOORBELL_DROP_THRESHOLD": \
+	((x) == 0x5 ? "THERMAL_THRESHOLD": \
+	((x) == 0x6 ? "DUAL_DATA_RATE_NOT_SUPPORTED": \
+	"Unknown decode" ))))))) : \
+	"Unknown decode" )
+
+
+/* hwrm_async_event_cmpl_error_report_pause_storm (size:128b/16B) */
+
+typedef struct hwrm_async_event_cmpl_error_report_pause_storm {
+	uint16_t	type;
 	/*
-	 * This bit must be '1' for the num_cmpl_rings field to be
-	 * configured.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	#define HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_CMPL_RINGS	UINT32_C(0x20)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_PAUSE_STORM_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_PAUSE_STORM_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_PAUSE_STORM_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_PAUSE_STORM_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_PAUSE_STORM_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
 	/*
-	 * This bit must be '1' for the num_tx_rings field to be
-	 * configured.
+	 * This async notification message is used to inform
+	 * the driver that an error has occurred which may need
+	 * the attention of the administrator.
 	 */
-	#define HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_TX_RINGS	UINT32_C(0x40)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_PAUSE_STORM_EVENT_ID_ERROR_REPORT UINT32_C(0x45)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_PAUSE_STORM_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_PAUSE_STORM_EVENT_ID_ERROR_REPORT
+	/* Event specific data. */
+	uint32_t	event_data2;
+	uint8_t	opaque_v;
 	/*
-	 * This bit must be '1' for the num_rx_rings field to be
-	 * configured.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	#define HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_RX_RINGS	UINT32_C(0x80)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_PAUSE_STORM_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_PAUSE_STORM_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_PAUSE_STORM_OPAQUE_SFT 1
+	/* 8-lsb timestamp (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data */
+	uint32_t	event_data1;
+	/* Indicates the type of error being reported. */
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_PAUSE_STORM_EVENT_DATA1_ERROR_TYPE_MASK	UINT32_C(0xff)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_PAUSE_STORM_EVENT_DATA1_ERROR_TYPE_SFT	0
 	/*
-	 * This bit must be '1' for the num_l2_ctxs field to be
-	 * configured.
+	 * The NIC was subjected to an extended pause storm which caused it
+	 * to disable flow control in order to avoid stalling the Tx path.
 	 */
-	#define HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_L2_CTXS	UINT32_C(0x100)
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_PAUSE_STORM_EVENT_DATA1_ERROR_TYPE_PAUSE_STORM  UINT32_C(0x1)
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_PAUSE_STORM_EVENT_DATA1_ERROR_TYPE_LAST	HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_PAUSE_STORM_EVENT_DATA1_ERROR_TYPE_PAUSE_STORM
+} hwrm_async_event_cmpl_error_report_pause_storm_t, *phwrm_async_event_cmpl_error_report_pause_storm_t;
+
+/* hwrm_async_event_cmpl_error_report_invalid_signal (size:128b/16B) */
+
+typedef struct hwrm_async_event_cmpl_error_report_invalid_signal {
+	uint16_t	type;
 	/*
-	 * This bit must be '1' for the num_vnics field to be
-	 * configured.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	#define HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_VNICS		UINT32_C(0x200)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_INVALID_SIGNAL_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_INVALID_SIGNAL_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_INVALID_SIGNAL_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_INVALID_SIGNAL_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_INVALID_SIGNAL_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
 	/*
-	 * This bit must be '1' for the num_stat_ctxs field to be
-	 * configured.
+	 * This async notification message is used to inform
+	 * the driver that an error has occurred which may need
+	 * the attention of the administrator.
 	 */
-	#define HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_STAT_CTXS	UINT32_C(0x400)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_INVALID_SIGNAL_EVENT_ID_ERROR_REPORT UINT32_C(0x45)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_INVALID_SIGNAL_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_INVALID_SIGNAL_EVENT_ID_ERROR_REPORT
+	/* Event specific data. */
+	uint32_t	event_data2;
+	/* Indicates the TSIO pin on which invalid signal is detected. */
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_INVALID_SIGNAL_EVENT_DATA2_PIN_ID_MASK UINT32_C(0xff)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_INVALID_SIGNAL_EVENT_DATA2_PIN_ID_SFT 0
+	uint8_t	opaque_v;
 	/*
-	 * This bit must be '1' for the num_hw_ring_grps field to be
-	 * configured.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	#define HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_HW_RING_GRPS	UINT32_C(0x800)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_INVALID_SIGNAL_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_INVALID_SIGNAL_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_INVALID_SIGNAL_OPAQUE_SFT 1
+	/* 8-lsb timestamp (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data */
+	uint32_t	event_data1;
+	/* Indicates the type of error being reported. */
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_INVALID_SIGNAL_EVENT_DATA1_ERROR_TYPE_MASK	UINT32_C(0xff)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_INVALID_SIGNAL_EVENT_DATA1_ERROR_TYPE_SFT	0
 	/*
-	 * The maximum transmission unit requested on the function.
-	 * The HWRM should make sure that the mtu of
-	 * the function does not exceed the mtu of the physical
-	 * port that this function is associated with.
-	 *
-	 * In addition to requesting mtu per function, it is
-	 * possible to configure mtu per transmit ring.
-	 * By default, the mtu of each transmit ring associated
-	 * with a function is equal to the mtu of the function.
-	 * The HWRM should make sure that the mtu of each transmit
-	 * ring that is assigned to a function has a valid mtu.
+	 * The NIC received an interrupt storm on a TSIO pin being used as
+	 * PPS_IN which caused it to disable the interrupt. The signal
+	 * should be fixed to be a proper 1 PPS signal before re-enabling
+	 * it. The pin number on which this signal was received is stored
+	 * in event_data2 as pin_id.
 	 */
-	uint16_t	mtu;
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_INVALID_SIGNAL_EVENT_DATA1_ERROR_TYPE_INVALID_SIGNAL  UINT32_C(0x2)
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_INVALID_SIGNAL_EVENT_DATA1_ERROR_TYPE_LAST	HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_INVALID_SIGNAL_EVENT_DATA1_ERROR_TYPE_INVALID_SIGNAL
+} hwrm_async_event_cmpl_error_report_invalid_signal_t, *phwrm_async_event_cmpl_error_report_invalid_signal_t;
+
+/* hwrm_async_event_cmpl_error_report_nvm (size:128b/16B) */
+
+typedef struct hwrm_async_event_cmpl_error_report_nvm {
+	uint16_t	type;
 	/*
-	 * The guest VLAN for the function being configured.
-	 * This field's format is same as 802.1Q Tag's
-	 * Tag Control Information (TCI) format that includes both
-	 * Priority Code Point (PCP) and VLAN Identifier (VID).
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint16_t	guest_vlan;
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
 	/*
-	 * ID of the target completion ring for receiving asynchronous
-	 * event completions. If this field is not valid, then the
-	 * HWRM shall use the default completion ring of the function
-	 * that is being configured as the target completion ring for
-	 * providing any asynchronous event completions for that
-	 * function.
-	 * If this field is valid, then the HWRM shall use the
-	 * completion ring identified by this ID as the target
-	 * completion ring for providing any asynchronous event
-	 * completions for the function that is being configured.
+	 * This async notification message is used to inform
+	 * the driver that an error has occurred which may need
+	 * the attention of the administrator.
 	 */
-	uint16_t	async_event_cr;
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_EVENT_ID_ERROR_REPORT UINT32_C(0x45)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_EVENT_ID_ERROR_REPORT
+	/* Event specific data. */
+	uint32_t	event_data2;
+	/* Indicates the address where error was detected */
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_EVENT_DATA2_ERR_ADDR_MASK UINT32_C(0xffffffff)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_EVENT_DATA2_ERR_ADDR_SFT 0
+	uint8_t	opaque_v;
 	/*
-	 * This value is the current MAC address requested by the VF
-	 * driver to be configured on this VF. A value of
-	 * 00-00-00-00-00-00 indicates no MAC address configuration
-	 * is requested by the VF driver.
-	 * The parent PF driver may reject or overwrite this
-	 * MAC address.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint8_t	dflt_mac_addr[6];
-	uint32_t	flags;
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_OPAQUE_SFT 1
+	/* 8-lsb timestamp (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data */
+	uint32_t	event_data1;
+	/* Indicates the type of error being reported. */
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_EVENT_DATA1_ERROR_TYPE_MASK	UINT32_C(0xff)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_EVENT_DATA1_ERROR_TYPE_SFT	0
 	/*
-	 * This bit requests that the firmware test to see if all the assets
-	 * requested in this command (i.e. number of TX rings) are available.
-	 * The firmware will return an error if the requested assets are
-	 * not available. The firwmare will NOT reserve the assets if they
-	 * are available.
+	 * There was a low level error with an NVM operation.
+	 * See nvm_err_type for more details.
 	 */
-	#define HWRM_FUNC_VF_CFG_INPUT_FLAGS_TX_ASSETS_TEST		UINT32_C(0x1)
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_EVENT_DATA1_ERROR_TYPE_NVM_ERROR  UINT32_C(0x3)
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_EVENT_DATA1_ERROR_TYPE_LAST	HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_EVENT_DATA1_ERROR_TYPE_NVM_ERROR
+	/* The specific type of NVM error */
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_EVENT_DATA1_NVM_ERR_TYPE_MASK   UINT32_C(0xff00)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_EVENT_DATA1_NVM_ERR_TYPE_SFT	8
 	/*
-	 * This bit requests that the firmware test to see if all the assets
-	 * requested in this command (i.e. number of RX rings) are available.
-	 * The firmware will return an error if the requested assets are
-	 * not available. The firwmare will NOT reserve the assets if they
-	 * are available.
+	 * There was a low level error with an NVM write operation.
+	 * Verification of written data did not match.
+	 * event_data2 will be the failing address.
 	 */
-	#define HWRM_FUNC_VF_CFG_INPUT_FLAGS_RX_ASSETS_TEST		UINT32_C(0x2)
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_EVENT_DATA1_NVM_ERR_TYPE_WRITE	(UINT32_C(0x1) << 8)
 	/*
-	 * This bit requests that the firmware test to see if all the assets
-	 * requested in this command (i.e. number of CMPL rings) are available.
-	 * The firmware will return an error if the requested assets are
-	 * not available. The firwmare will NOT reserve the assets if they
-	 * are available.
+	 * There was a low level error with an NVM erase operation.
+	 * All the bits were not erased.
+	 * event_data2 will be the failing address.
 	 */
-	#define HWRM_FUNC_VF_CFG_INPUT_FLAGS_CMPL_ASSETS_TEST	UINT32_C(0x4)
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_EVENT_DATA1_NVM_ERR_TYPE_ERASE	(UINT32_C(0x2) << 8)
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_EVENT_DATA1_NVM_ERR_TYPE_LAST	HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_NVM_EVENT_DATA1_NVM_ERR_TYPE_ERASE
+} hwrm_async_event_cmpl_error_report_nvm_t, *phwrm_async_event_cmpl_error_report_nvm_t;
+
+/* hwrm_async_event_cmpl_error_report_doorbell_drop_threshold (size:128b/16B) */
+
+typedef struct hwrm_async_event_cmpl_error_report_doorbell_drop_threshold {
+	uint16_t	type;
 	/*
-	 * This bit requests that the firmware test to see if all the assets
-	 * requested in this command (i.e. number of RSS ctx) are available.
-	 * The firmware will return an error if the requested assets are
-	 * not available. The firwmare will NOT reserve the assets if they
-	 * are available.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	#define HWRM_FUNC_VF_CFG_INPUT_FLAGS_RSSCOS_CTX_ASSETS_TEST	UINT32_C(0x8)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DOORBELL_DROP_THRESHOLD_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DOORBELL_DROP_THRESHOLD_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DOORBELL_DROP_THRESHOLD_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DOORBELL_DROP_THRESHOLD_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DOORBELL_DROP_THRESHOLD_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
 	/*
-	 * This bit requests that the firmware test to see if all the assets
-	 * requested in this command (i.e. number of ring groups) are available.
-	 * The firmware will return an error if the requested assets are
-	 * not available. The firwmare will NOT reserve the assets if they
-	 * are available.
+	 * This async notification message is used to inform
+	 * the driver that an error has occurred which may need
+	 * the attention of the administrator.
 	 */
-	#define HWRM_FUNC_VF_CFG_INPUT_FLAGS_RING_GRP_ASSETS_TEST	UINT32_C(0x10)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DOORBELL_DROP_THRESHOLD_EVENT_ID_ERROR_REPORT UINT32_C(0x45)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DOORBELL_DROP_THRESHOLD_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DOORBELL_DROP_THRESHOLD_EVENT_ID_ERROR_REPORT
+	/* Event specific data. */
+	uint32_t	event_data2;
+	uint8_t	opaque_v;
 	/*
-	 * This bit requests that the firmware test to see if all the assets
-	 * requested in this command (i.e. number of stat ctx) are available.
-	 * The firmware will return an error if the requested assets are
-	 * not available. The firwmare will NOT reserve the assets if they
-	 * are available.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	#define HWRM_FUNC_VF_CFG_INPUT_FLAGS_STAT_CTX_ASSETS_TEST	UINT32_C(0x20)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DOORBELL_DROP_THRESHOLD_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DOORBELL_DROP_THRESHOLD_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DOORBELL_DROP_THRESHOLD_OPAQUE_SFT 1
+	/* 8-lsb timestamp (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data */
+	uint32_t	event_data1;
+	/* Indicates the type of error being reported. */
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DOORBELL_DROP_THRESHOLD_EVENT_DATA1_ERROR_TYPE_MASK		UINT32_C(0xff)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DOORBELL_DROP_THRESHOLD_EVENT_DATA1_ERROR_TYPE_SFT			0
 	/*
-	 * This bit requests that the firmware test to see if all the assets
-	 * requested in this command (i.e. number of VNICs) are available.
-	 * The firmware will return an error if the requested assets are
-	 * not available. The firwmare will NOT reserve the assets if they
-	 * are available.
+	 * This indicates doorbell drop threshold was hit. When this
+	 * threshold is crossed, it indicates one or more doorbells for
+	 * the function were dropped by hardware.
 	 */
-	#define HWRM_FUNC_VF_CFG_INPUT_FLAGS_VNIC_ASSETS_TEST	UINT32_C(0x40)
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DOORBELL_DROP_THRESHOLD_EVENT_DATA1_ERROR_TYPE_DOORBELL_DROP_THRESHOLD  UINT32_C(0x4)
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DOORBELL_DROP_THRESHOLD_EVENT_DATA1_ERROR_TYPE_LAST			HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DOORBELL_DROP_THRESHOLD_EVENT_DATA1_ERROR_TYPE_DOORBELL_DROP_THRESHOLD
 	/*
-	 * This bit requests that the firmware test to see if all the assets
-	 * requested in this command (i.e. number of L2 ctx) are available.
-	 * The firmware will return an error if the requested assets are
-	 * not available. The firwmare will NOT reserve the assets if they
-	 * are available.
+	 * The epoch value to be sent from firmware to the driver to track
+	 * a doorbell recovery cycle.
 	 */
-	#define HWRM_FUNC_VF_CFG_INPUT_FLAGS_L2_CTX_ASSETS_TEST	UINT32_C(0x80)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DOORBELL_DROP_THRESHOLD_EVENT_DATA1_EPOCH_MASK			UINT32_C(0xffffff00)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DOORBELL_DROP_THRESHOLD_EVENT_DATA1_EPOCH_SFT			8
+} hwrm_async_event_cmpl_error_report_doorbell_drop_threshold_t, *phwrm_async_event_cmpl_error_report_doorbell_drop_threshold_t;
+
+/* hwrm_async_event_cmpl_error_report_thermal (size:128b/16B) */
+
+typedef struct hwrm_async_event_cmpl_error_report_thermal {
+	uint16_t	type;
 	/*
-	 * If this bit is set to 1, the VF driver is requesting FW to enable
-	 * PPP TX PUSH feature on all the TX rings specified in the
-	 * num_tx_rings field. By default, the PPP TX push feature is
-	 * disabled for all the TX rings of the VF. This flag is ignored if
-	 * the num_tx_rings field is not specified or the VF doesn't support
-	 * PPP tx push feature.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	#define HWRM_FUNC_VF_CFG_INPUT_FLAGS_PPP_PUSH_MODE_ENABLE	UINT32_C(0x100)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
 	/*
-	 * If this bit is set to 1, the VF driver is requesting FW to disable
-	 * PPP TX PUSH feature on all the TX rings of the VF. This flag is
-	 * ignored if the VF doesn't support PPP tx push feature.
+	 * This async notification message is used to inform
+	 * the driver that an error has occurred which may need
+	 * the attention of the administrator.
 	 */
-	#define HWRM_FUNC_VF_CFG_INPUT_FLAGS_PPP_PUSH_MODE_DISABLE	UINT32_C(0x200)
-	/* The number of RSS/COS contexts requested for the VF. */
-	uint16_t	num_rsscos_ctxs;
-	/* The number of completion rings requested for the VF. */
-	uint16_t	num_cmpl_rings;
-	/* The number of transmit rings requested for the VF. */
-	uint16_t	num_tx_rings;
-	/* The number of receive rings requested for the VF. */
-	uint16_t	num_rx_rings;
-	/* The number of L2 contexts requested for the VF. */
-	uint16_t	num_l2_ctxs;
-	/* The number of vnics requested for the VF. */
-	uint16_t	num_vnics;
-	/* The number of statistic contexts requested for the VF. */
-	uint16_t	num_stat_ctxs;
-	/* The number of HW ring groups requested for the VF. */
-	uint16_t	num_hw_ring_grps;
-	uint8_t	unused_0[4];
-} hwrm_func_vf_cfg_input_t, *phwrm_func_vf_cfg_input_t;
-
-/* hwrm_func_vf_cfg_output (size:128b/16B) */
-
-typedef struct hwrm_func_vf_cfg_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_ID_ERROR_REPORT UINT32_C(0x45)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_ID_ERROR_REPORT
+	/* Event specific data. */
+	uint32_t	event_data2;
+	/* Current temperature. In Celsius */
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA2_CURRENT_TEMP_MASK  UINT32_C(0xff)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA2_CURRENT_TEMP_SFT   0
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * The temperature setting of the threshold that was just crossed.
+	 * In Celsius
 	 */
-	uint8_t	valid;
-} hwrm_func_vf_cfg_output_t, *phwrm_func_vf_cfg_output_t;
-
-/*******************
- * hwrm_func_qcaps *
- *******************/
-
-
-/* hwrm_func_qcaps_input (size:192b/24B) */
-
-typedef struct hwrm_func_qcaps_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA2_THRESHOLD_TEMP_MASK UINT32_C(0xff00)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA2_THRESHOLD_TEMP_SFT 8
+	uint8_t	opaque_v;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint16_t	cmpl_ring;
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_OPAQUE_SFT 1
+	/* 8-lsb timestamp (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data */
+	uint32_t	event_data1;
+	/* Indicates the type of error being reported. */
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_ERROR_TYPE_MASK	UINT32_C(0xff)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_ERROR_TYPE_SFT	0
+	/*
+	 * There was thermal event. The type will be specified in the
+	 * field threshold_type. event_data2 will contain the current
+	 * temperature and the configured value for the threshold that
+	 * was just crossed. The threshold values are lower thresholds,
+	 * so the event will trigger with an active flag when the
+	 * temperature is on an increasing trajectory.
+	 */
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_ERROR_TYPE_THERMAL_EVENT   UINT32_C(0x5)
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_ERROR_TYPE_LAST	HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_ERROR_TYPE_THERMAL_EVENT
+	/* The specific type of thermal threshold error */
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_THRESHOLD_TYPE_MASK	UINT32_C(0x700)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_THRESHOLD_TYPE_SFT	8
+	/* Warning thermal threshold was crossed */
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_THRESHOLD_TYPE_WARN	(UINT32_C(0x0) << 8)
+	/* Critical thermal threshold was crossed */
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_THRESHOLD_TYPE_CRITICAL	(UINT32_C(0x1) << 8)
+	/* Fatal thermal threshold was crossed */
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_THRESHOLD_TYPE_FATAL	(UINT32_C(0x2) << 8)
+	/*
+	 * Thermal shutdown threshold was crossed and a shutdown is
+	 * imminent. This event will not occur if self shutdown
+	 * is disabled.
+	 */
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_THRESHOLD_TYPE_SHUTDOWN	(UINT32_C(0x3) << 8)
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_THRESHOLD_TYPE_LAST	HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_THRESHOLD_TYPE_SHUTDOWN
+	/*
+	 * Indicates if the thermal crossing occurs while the temperature is
+	 * increasing or decreasing.
+	 */
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_TRANSITION_DIR	UINT32_C(0x800)
+	/* Threshold is crossed while the temperature is falling. */
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_TRANSITION_DIR_DECREASING  (UINT32_C(0x0) << 11)
+	/* Threshold is crossed while the temperature is rising. */
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_TRANSITION_DIR_INCREASING  (UINT32_C(0x1) << 11)
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_TRANSITION_DIR_LAST	HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_TRANSITION_DIR_INCREASING
+} hwrm_async_event_cmpl_error_report_thermal_t, *phwrm_async_event_cmpl_error_report_thermal_t;
+
+/* hwrm_async_event_cmpl_error_report_dual_data_rate_not_supported (size:128b/16B) */
+
+typedef struct hwrm_async_event_cmpl_error_report_dual_data_rate_not_supported {
+	uint16_t	type;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint16_t	seq_id;
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DUAL_DATA_RATE_NOT_SUPPORTED_TYPE_MASK		UINT32_C(0x3f)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DUAL_DATA_RATE_NOT_SUPPORTED_TYPE_SFT		0
+	/* HWRM Asynchronous Event Information */
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DUAL_DATA_RATE_NOT_SUPPORTED_TYPE_HWRM_ASYNC_EVENT  UINT32_C(0x2e)
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DUAL_DATA_RATE_NOT_SUPPORTED_TYPE_LAST		HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DUAL_DATA_RATE_NOT_SUPPORTED_TYPE_HWRM_ASYNC_EVENT
+	/* Identifiers of events. */
+	uint16_t	event_id;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * This async notification message is used to inform
+	 * the driver that an error has occurred which may need
+	 * the attention of the administrator.
 	 */
-	uint16_t	target_id;
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DUAL_DATA_RATE_NOT_SUPPORTED_EVENT_ID_ERROR_REPORT UINT32_C(0x45)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DUAL_DATA_RATE_NOT_SUPPORTED_EVENT_ID_LAST	HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DUAL_DATA_RATE_NOT_SUPPORTED_EVENT_ID_ERROR_REPORT
+	/* Event specific data. */
+	uint32_t	event_data2;
+	uint8_t	opaque_v;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint64_t	resp_addr;
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DUAL_DATA_RATE_NOT_SUPPORTED_V	UINT32_C(0x1)
+	/* opaque is 7 b */
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DUAL_DATA_RATE_NOT_SUPPORTED_OPAQUE_MASK UINT32_C(0xfe)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DUAL_DATA_RATE_NOT_SUPPORTED_OPAQUE_SFT 1
+	/* 8-lsb timestamp (100-msec resolution) */
+	uint8_t	timestamp_lo;
+	/* 16-lsb timestamp (100-msec resolution) */
+	uint16_t	timestamp_hi;
+	/* Event specific data */
+	uint32_t	event_data1;
+	/* Indicates the type of error being reported. */
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DUAL_DATA_RATE_NOT_SUPPORTED_EVENT_DATA1_ERROR_TYPE_MASK			UINT32_C(0xff)
+	#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DUAL_DATA_RATE_NOT_SUPPORTED_EVENT_DATA1_ERROR_TYPE_SFT			0
 	/*
-	 * Function ID of the function that is being queried.
-	 * 0xFF... (All Fs) if the query is for the requesting
-	 * function.
-	 * 0xFFFE (REQUESTING_PARENT_FID) This is a special FID
-	 * to be used by a trusted VF to query its parent PF.
+	 * Speed change not supported with dual rate transceivers
+	 * on this board.
 	 */
-	uint16_t	fid;
-	uint8_t	unused_0[6];
-} hwrm_func_qcaps_input_t, *phwrm_func_qcaps_input_t;
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DUAL_DATA_RATE_NOT_SUPPORTED_EVENT_DATA1_ERROR_TYPE_DUAL_DATA_RATE_NOT_SUPPORTED  UINT32_C(0x6)
+		#define HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DUAL_DATA_RATE_NOT_SUPPORTED_EVENT_DATA1_ERROR_TYPE_LAST			HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_DUAL_DATA_RATE_NOT_SUPPORTED_EVENT_DATA1_ERROR_TYPE_DUAL_DATA_RATE_NOT_SUPPORTED
+} hwrm_async_event_cmpl_error_report_dual_data_rate_not_supported_t, *phwrm_async_event_cmpl_error_report_dual_data_rate_not_supported_t;
 
-/* hwrm_func_qcaps_output (size:704b/88B) */
+/* metadata_base_msg (size:64b/8B) */
 
-typedef struct hwrm_func_qcaps_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
+typedef struct metadata_base_msg {
+	uint16_t	md_type_link;
+	/* This field classifies the data present in the meta-data. */
+	#define METADATA_BASE_MSG_MD_TYPE_MASK	UINT32_C(0x1f)
+	#define METADATA_BASE_MSG_MD_TYPE_SFT	0
+	/* Meta data fields are not valid */
+		#define METADATA_BASE_MSG_MD_TYPE_NONE	UINT32_C(0x0)
 	/*
-	 * FID value.  This value is used to identify operations on the PCI
-	 * bus as belonging to a particular PCI function.
+	 * This setting is used when packets are coming in-order. Depending on
+	 * the state of the receive context, the meta-data will carry
+	 * different information.
 	 */
-	uint16_t	fid;
+		#define METADATA_BASE_MSG_MD_TYPE_TLS_INSYNC  UINT32_C(0x1)
 	/*
-	 * Port ID of port that this function is associated with.
-	 * Valid only for the PF.
-	 * 0xFF... (All Fs) if this function is not associated with
-	 * any port.
-	 * 0xFF... (All Fs) if this function is called from a VF.
+	 * With this setting HW passes the TCP sequence number of the TLS
+	 * record that it is requesting a resync on in the meta data.
 	 */
-	uint16_t	port_id;
-	uint32_t	flags;
-	/* If 1, then Push mode is supported on this function. */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_PUSH_MODE_SUPPORTED		UINT32_C(0x1)
+		#define METADATA_BASE_MSG_MD_TYPE_TLS_RESYNC  UINT32_C(0x2)
+	/* This setting is used for QUIC packets. */
+		#define METADATA_BASE_MSG_MD_TYPE_QUIC	UINT32_C(0x3)
 	/*
-	 * If 1, then the global MSI-X auto-masking is enabled for the
-	 * device.
+	 * This setting is used for crypto packets with an unsupported
+	 * protocol.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_GLOBAL_MSIX_AUTOMASKING		UINT32_C(0x2)
+		#define METADATA_BASE_MSG_MD_TYPE_ILLEGAL	UINT32_C(0x1f)
+		#define METADATA_BASE_MSG_MD_TYPE_LAST	METADATA_BASE_MSG_MD_TYPE_ILLEGAL
 	/*
-	 * If 1, then the Precision Time Protocol (PTP) processing
-	 * is supported on this function.
-	 * The HWRM should enable PTP on only a single Physical
-	 * Function (PF) per port.
+	 * This field indicates where the next metadata block starts, relative
+	 * to the current metadata block. It is the offset to the next metadata
+	 * header, counted in 16B units. A value of zero indicates that there is
+	 * no additional metadata, and that the current metadata block is the
+	 * last one.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_PTP_SUPPORTED			UINT32_C(0x4)
+	#define METADATA_BASE_MSG_LINK_MASK	UINT32_C(0x1e0)
+	#define METADATA_BASE_MSG_LINK_SFT	5
+	uint16_t	unused0;
+	uint32_t	unused1;
+} metadata_base_msg_t, *pmetadata_base_msg_t;
+
+/* tls_metadata_base_msg (size:64b/8B) */
+
+typedef struct tls_metadata_base_msg {
+	uint32_t	md_type_link_flags_kid_lo;
+	/* This field classifies the data present in the meta-data. */
+	#define TLS_METADATA_BASE_MSG_MD_TYPE_MASK				UINT32_C(0x1f)
+	#define TLS_METADATA_BASE_MSG_MD_TYPE_SFT				0
 	/*
-	 * If 1, then RDMA over Converged Ethernet (RoCE) v1
-	 * is supported on this function.
+	 * This setting is used when packets are coming in-order. Depending
+	 * on the state of the receive context, the meta-data will carry
+	 * different information.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ROCE_V1_SUPPORTED			UINT32_C(0x8)
+		#define TLS_METADATA_BASE_MSG_MD_TYPE_TLS_INSYNC				UINT32_C(0x1)
 	/*
-	 * If 1, then RDMA over Converged Ethernet (RoCE) v2
-	 * is supported on this function.
+	 * With this setting HW passes the TCP sequence number of the TLS
+	 * record that it is requesting a resync on in the meta data.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ROCE_V2_SUPPORTED			UINT32_C(0x10)
+		#define TLS_METADATA_BASE_MSG_MD_TYPE_TLS_RESYNC				UINT32_C(0x2)
+		#define TLS_METADATA_BASE_MSG_MD_TYPE_LAST				TLS_METADATA_BASE_MSG_MD_TYPE_TLS_RESYNC
 	/*
-	 * If 1, then control and configuration of WoL magic packet
-	 * are supported on this function.
+	 * This field indicates where the next metadata block starts. It is
+	 * counted in 16B units. A value of zero indicates that there is no
+	 * metadata.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_WOL_MAGICPKT_SUPPORTED		UINT32_C(0x20)
+	#define TLS_METADATA_BASE_MSG_LINK_MASK					UINT32_C(0x1e0)
+	#define TLS_METADATA_BASE_MSG_LINK_SFT					5
+	/* These are flags present in the metadata. */
+	#define TLS_METADATA_BASE_MSG_FLAGS_MASK				UINT32_C(0x1fffe00)
+	#define TLS_METADATA_BASE_MSG_FLAGS_SFT					9
 	/*
-	 * If 1, then control and configuration of bitmap pattern
-	 * packet are supported on this function.
+	 * A value of 1 implies that the packet was decrypted by HW. Otherwise
+	 * the packet is passed on as it came in on the wire.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_WOL_BMP_SUPPORTED			UINT32_C(0x40)
+	#define TLS_METADATA_BASE_MSG_FLAGS_DECRYPTED				UINT32_C(0x200)
 	/*
-	 * If set to 1, then the control and configuration of rate limit
-	 * of an allocated TX ring on the queried function is supported.
+	 * This field indicates the state of the ghash field passed in the
+	 * meta-data.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_TX_RING_RL_SUPPORTED		UINT32_C(0x80)
+	#define TLS_METADATA_BASE_MSG_FLAGS_GHASH_MASK				UINT32_C(0xc00)
+	#define TLS_METADATA_BASE_MSG_FLAGS_GHASH_SFT				10
 	/*
-	 * If 1, then control and configuration of minimum and
-	 * maximum bandwidths are supported on the queried function.
+	 * This enumeration states that the ghash is not valid in the
+	 * meta-data.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_TX_BW_CFG_SUPPORTED		UINT32_C(0x100)
+		#define TLS_METADATA_BASE_MSG_FLAGS_GHASH_NOT_VALID			(UINT32_C(0x0) << 10)
 	/*
-	 * If the query is for a VF, then this flag shall be ignored.
-	 * If this query is for a PF and this flag is set to 1,
-	 * then the PF has the capability to set the rate limits
-	 * on the TX rings of its children VFs.
-	 * If this query is for a PF and this flag is set to 0, then
-	 * the PF does not have the capability to set the rate limits
-	 * on the TX rings of its children VFs.
+	 * This enumeration indicates that this pkt contains the record's
+	 * tag and this pkt was received ooo, the partial_ghash field
+	 * contains the ghash.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_VF_TX_RING_RL_SUPPORTED		UINT32_C(0x200)
+		#define TLS_METADATA_BASE_MSG_FLAGS_GHASH_CUR_REC				(UINT32_C(0x1) << 10)
 	/*
-	 * If the query is for a VF, then this flag shall be ignored.
-	 * If this query is for a PF and this flag is set to 1,
-	 * then the PF has the capability to set the minimum and/or
-	 * maximum bandwidths for its children VFs.
-	 * If this query is for a PF and this flag is set to 0, then
-	 * the PF does not have the capability to set the minimum or
-	 * maximum bandwidths for its children VFs.
+	 * This enumeration indicates that the current record's tag wasn't
+	 * seen and the chip is moving on to the next record, the
+	 * partial_ghash field contains the ghash.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_VF_BW_CFG_SUPPORTED		UINT32_C(0x400)
+		#define TLS_METADATA_BASE_MSG_FLAGS_GHASH_PRIOR_REC			(UINT32_C(0x2) << 10)
+		#define TLS_METADATA_BASE_MSG_FLAGS_GHASH_LAST				TLS_METADATA_BASE_MSG_FLAGS_GHASH_PRIOR_REC
+	/* This field indicates the status of tag authentication. */
+	#define TLS_METADATA_BASE_MSG_FLAGS_TAG_AUTH_STATUS_MASK			UINT32_C(0x3000)
+	#define TLS_METADATA_BASE_MSG_FLAGS_TAG_AUTH_STATUS_SFT			12
 	/*
-	 * Standard TX Ring mode is used for the allocation of TX ring
-	 * and underlying scheduling resources that allow bandwidth
-	 * reservation and limit settings on the queried function.
-	 * If set to 1, then standard TX ring mode is supported
-	 * on the queried function.
-	 * If set to 0, then standard TX ring mode is not available
-	 * on the queried function.
+	 * This enumeration is set when HW was not able to authenticate a
+	 * TAG.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_STD_TX_RING_MODE_SUPPORTED		UINT32_C(0x800)
+		#define TLS_METADATA_BASE_MSG_FLAGS_TAG_AUTH_STATUS_NOT_CHECKED		(UINT32_C(0x0) << 12)
 	/*
-	 * If the query is for a VF, then this flag shall be ignored,
-	 * If this query is for a PF and this flag is set to 1,
-	 * then the PF has the capability to detect GENEVE tunnel
-	 * flags.
+	 * This enumeration states that there is at least one tag in the
+	 * packet and every tag is valid.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_GENEVE_TUN_FLAGS_SUPPORTED		UINT32_C(0x1000)
+		#define TLS_METADATA_BASE_MSG_FLAGS_TAG_AUTH_STATUS_SUCCESS		(UINT32_C(0x1) << 12)
 	/*
-	 * If the query is for a VF, then this flag shall be ignored,
-	 * If this query is for a PF and this flag is set to 1,
-	 * then the PF has the capability to detect NVGRE tunnel
-	 * flags.
+	 * This enumeration states that there is at least one tag in the
+	 * packet and at least one of the tag is invalid. The entire packet
+	 * is sent decrypted to the host.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_NVGRE_TUN_FLAGS_SUPPORTED		UINT32_C(0x2000)
+		#define TLS_METADATA_BASE_MSG_FLAGS_TAG_AUTH_STATUS_FAILURE		(UINT32_C(0x2) << 12)
+		#define TLS_METADATA_BASE_MSG_FLAGS_TAG_AUTH_STATUS_LAST			TLS_METADATA_BASE_MSG_FLAGS_TAG_AUTH_STATUS_FAILURE
 	/*
-	 * If the query is for a VF, then this flag shall be ignored,
-	 * If this query is for a PF and this flag is set to 1,
-	 * then the PF has the capability to detect GRE tunnel
-	 * flags.
+	 * A value of 1 indicates that this packet contains a record that
+	 * starts in the packet and extends beyond the packet.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_GRE_TUN_FLAGS_SUPPORTED		UINT32_C(0x4000)
+	#define TLS_METADATA_BASE_MSG_FLAGS_HEADER_FLDS_VALID			UINT32_C(0x4000)
 	/*
-	 * If the query is for a VF, then this flag shall be ignored,
-	 * If this query is for a PF and this flag is set to 1,
-	 * then the PF has the capability to detect MPLS tunnel
-	 * flags.
+	 * A value of 1 indicates that the packet experienced a context load
+	 * error. In this case, the packet is sent to the host without the
+	 * header or payload decrypted and the context is not updated.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_MPLS_TUN_FLAGS_SUPPORTED		UINT32_C(0x8000)
+	#define TLS_METADATA_BASE_MSG_FLAGS_CTX_LOAD_ERR				UINT32_C(0x8000)
+	/* This field indicates the packet operation state. */
+	#define TLS_METADATA_BASE_MSG_FLAGS_PKT_OPERATION_STATE_MASK		UINT32_C(0x70000)
+	#define TLS_METADATA_BASE_MSG_FLAGS_PKT_OPERATION_STATE_SFT		16
+	/* Packet is in order. */
+		#define TLS_METADATA_BASE_MSG_FLAGS_PKT_OPERATION_STATE_IN_ORDER		(UINT32_C(0x0) << 16)
+	/* Packet is out of order, no header loss. */
+		#define TLS_METADATA_BASE_MSG_FLAGS_PKT_OPERATION_STATE_OUT_OF_ORDER	(UINT32_C(0x1) << 16)
+	/* Packet is header search (out of order with header loss). */
+		#define TLS_METADATA_BASE_MSG_FLAGS_PKT_OPERATION_STATE_HEADER_SEARCH	(UINT32_C(0x2) << 16)
+	/* Packet is resync (resync record ongoing). */
+		#define TLS_METADATA_BASE_MSG_FLAGS_PKT_OPERATION_STATE_RESYNC		(UINT32_C(0x3) << 16)
 	/*
-	 * If the query is for a VF, then this flag shall be ignored,
-	 * If this query is for a PF and this flag is set to 1,
-	 * then the PF has the capability to support pcie stats.
+	 * Packet is resync wait (resync record completes, waiting for
+	 * result).
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_PCIE_STATS_SUPPORTED		UINT32_C(0x10000)
+		#define TLS_METADATA_BASE_MSG_FLAGS_PKT_OPERATION_STATE_RESYNC_WAIT	(UINT32_C(0x4) << 16)
 	/*
-	 * If the query is for a VF, then this flag shall be ignored,
-	 * If this query is for a PF and this flag is set to 1,
-	 * then the PF has the capability to adopt the VF's belonging
-	 * to another PF.
+	 * Packet is resync wait for partial tag (waiting for resync record
+	 * tag).
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ADOPTED_PF_SUPPORTED		UINT32_C(0x20000)
+		#define TLS_METADATA_BASE_MSG_FLAGS_PKT_OPERATION_STATE_RESYNC_WAIT_PARTIAL   (UINT32_C(0x5) << 16)
+	/* Packet is resync success (got resync record success). */
+		#define TLS_METADATA_BASE_MSG_FLAGS_PKT_OPERATION_STATE_RESYNC_SUCCESS	(UINT32_C(0x6) << 16)
 	/*
-	 * If the query is for a VF, then this flag shall be ignored,
-	 * If this query is for a PF and this flag is set to 1,
-	 * then the PF has the administrative privilege to configure another PF
+	 * Packet is resync success wait (got midpath ACK, waiting for
+	 * resync record success).
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ADMIN_PF_SUPPORTED			UINT32_C(0x40000)
+		#define TLS_METADATA_BASE_MSG_FLAGS_PKT_OPERATION_STATE_RESYNC_SUCCESS_WAIT   (UINT32_C(0x7) << 16)
+		#define TLS_METADATA_BASE_MSG_FLAGS_PKT_OPERATION_STATE_LAST		TLS_METADATA_BASE_MSG_FLAGS_PKT_OPERATION_STATE_RESYNC_SUCCESS_WAIT
 	/*
-	 * If the query is for a VF, then this flag shall be ignored.
-	 * If this query is for a PF and this flag is set to 1, then
-	 * the PF will know that the firmware has the capability to track
-	 * the virtual link status.
+	 * This value indicates the lower 7-bit of the Crypto Key ID
+	 * associated with this operation.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_LINK_ADMIN_STATUS_SUPPORTED	UINT32_C(0x80000)
+	#define TLS_METADATA_BASE_MSG_KID_LO_MASK				UINT32_C(0xfe000000)
+	#define TLS_METADATA_BASE_MSG_KID_LO_SFT				25
+	uint16_t	kid_hi;
 	/*
-	 * If 1, then this function supports the push mode that uses
-	 * write combine buffers and the long inline tx buffer descriptor.
+	 * This value indicates the upper 13-bit of the Crypto Key ID
+	 * associated with this operation.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_WCB_PUSH_MODE			UINT32_C(0x100000)
+	#define TLS_METADATA_BASE_MSG_KID_HI_MASK UINT32_C(0x1fff)
+	#define TLS_METADATA_BASE_MSG_KID_HI_SFT 0
+	uint16_t	unused0;
+} tls_metadata_base_msg_t, *ptls_metadata_base_msg_t;
+
+/* tls_metadata_insync_msg (size:192b/24B) */
+
+typedef struct tls_metadata_insync_msg {
+	uint32_t	md_type_link_flags_kid_lo;
+	/* This field classifies the data present in the meta-data. */
+	#define TLS_METADATA_INSYNC_MSG_MD_TYPE_MASK				UINT32_C(0x1f)
+	#define TLS_METADATA_INSYNC_MSG_MD_TYPE_SFT				0
 	/*
-	 * If 1, then FW has capability to allocate TX rings dynamically
-	 * in ring alloc even if PF reserved pool is zero.
-	 * This bit will be used only for PFs.
+	 * This setting is used when packets are coming in-order. Depending on
+	 * the state of the receive context, the meta-data will carry
+	 * different information.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_DYNAMIC_TX_RING_ALLOC		UINT32_C(0x200000)
+		#define TLS_METADATA_INSYNC_MSG_MD_TYPE_TLS_INSYNC				UINT32_C(0x1)
+		#define TLS_METADATA_INSYNC_MSG_MD_TYPE_LAST				TLS_METADATA_INSYNC_MSG_MD_TYPE_TLS_INSYNC
 	/*
-	 * When this bit is '1', it indicates that core firmware is
-	 * capable of Hot Reset.
+	 * This field indicates where the next metadata block starts. It is
+	 * counted in 16B units. A value of zero indicates that there is no
+	 * metadata.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_HOT_RESET_CAPABLE			UINT32_C(0x400000)
+	#define TLS_METADATA_INSYNC_MSG_LINK_MASK					UINT32_C(0x1e0)
+	#define TLS_METADATA_INSYNC_MSG_LINK_SFT					5
+	/* These are flags present in the metadata. */
+	#define TLS_METADATA_INSYNC_MSG_FLAGS_MASK				UINT32_C(0x1fffe00)
+	#define TLS_METADATA_INSYNC_MSG_FLAGS_SFT					9
 	/*
-	 * This flag will be set to 1 by the FW if FW supports adapter error
-	 * recovery.
+	 * A value of 1 implies that the packet was decrypted by HW. Otherwise
+	 * the packet is passed on as it came in on the wire.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ERROR_RECOVERY_CAPABLE		UINT32_C(0x800000)
+	#define TLS_METADATA_INSYNC_MSG_FLAGS_DECRYPTED				UINT32_C(0x200)
 	/*
-	 * If the query is for a VF, then this flag shall be ignored.
-	 * If this query is for a PF and this flag is set to 1, then
-	 * the PF has the capability to support extended stats.
+	 * This field indicates the state of the ghash field passed in the
+	 * meta-data.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_STATS_SUPPORTED		UINT32_C(0x1000000)
+	#define TLS_METADATA_INSYNC_MSG_FLAGS_GHASH_MASK				UINT32_C(0xc00)
+	#define TLS_METADATA_INSYNC_MSG_FLAGS_GHASH_SFT				10
 	/*
-	 * If the query is for a VF, then this flag shall be ignored.
-	 * If this query is for a PF and this flag is set to 1, then host
-	 * must initiate reset or reload (or fastboot) the firmware image
-	 * upon detection of device shutdown state.
+	 * This enumeration states that the ghash is not valid in the
+	 * meta-data.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ERR_RECOVER_RELOAD			UINT32_C(0x2000000)
+		#define TLS_METADATA_INSYNC_MSG_FLAGS_GHASH_NOT_VALID			(UINT32_C(0x0) << 10)
 	/*
-	 * If the query is for a VF, then this flag (always set to 0) shall
-	 * be ignored. If this query is for a PF and this flag is set to 1,
-	 * host, when registered for the default vnic change async event,
-	 * receives async notification whenever a default vnic state is
-	 * changed for any of child or adopted VFs.
+	 * This enumeration indicates that this pkt contains the record's
+	 * tag and this pkt was received ooo, the partial_ghash field
+	 * contains the ghash.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_NOTIFY_VF_DEF_VNIC_CHNG_SUPPORTED	UINT32_C(0x4000000)
-	/* If set to 1, then the vlan acceleration for TX is disabled. */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_VLAN_ACCELERATION_TX_DISABLED	UINT32_C(0x8000000)
+		#define TLS_METADATA_INSYNC_MSG_FLAGS_GHASH_CUR_REC				(UINT32_C(0x1) << 10)
 	/*
-	 * When this bit is '1', it indicates that core firmware supports
-	 * DBG_COREDUMP_XXX commands.
+	 * This enumeration indicates that the current record's tag wasn't
+	 * seen and the chip is moving on to the next record, the
+	 * partial_ghash field contains the ghash.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_COREDUMP_CMD_SUPPORTED		UINT32_C(0x10000000)
+		#define TLS_METADATA_INSYNC_MSG_FLAGS_GHASH_PRIOR_REC			(UINT32_C(0x2) << 10)
+		#define TLS_METADATA_INSYNC_MSG_FLAGS_GHASH_LAST				TLS_METADATA_INSYNC_MSG_FLAGS_GHASH_PRIOR_REC
+	/* This field indicates the status of tag authentication. */
+	#define TLS_METADATA_INSYNC_MSG_FLAGS_TAG_AUTH_STATUS_MASK			UINT32_C(0x3000)
+	#define TLS_METADATA_INSYNC_MSG_FLAGS_TAG_AUTH_STATUS_SFT			12
 	/*
-	 * When this bit is '1', it indicates that core firmware supports
-	 * DBG_CRASHDUMP_XXX commands.
+	 * This enumeration is set when HW was not able to authenticate a
+	 * TAG.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_CRASHDUMP_CMD_SUPPORTED		UINT32_C(0x20000000)
+		#define TLS_METADATA_INSYNC_MSG_FLAGS_TAG_AUTH_STATUS_NOT_CHECKED		(UINT32_C(0x0) << 12)
 	/*
-	 * If the query is for a VF, then this flag should be ignored.
-	 * If the query is for a PF and this flag is set to 1, then
-	 * the PF has the capability to support retrieval of
-	 * rx_port_stats_ext_pfc_wd statistics (supported by the PFC
-	 * WatchDog feature) via the hwrm_port_qstats_ext_pfc_wd command.
-	 * If this flag is set to 1, only that (supported) command should
-	 * be used for retrieval of PFC related statistics (rather than
-	 * hwrm_port_qstats_ext command, which could previously be used).
+	 * This enumeration states that there is at least one tag in the
+	 * packet and every tag is valid.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_PFC_WD_STATS_SUPPORTED		UINT32_C(0x40000000)
+		#define TLS_METADATA_INSYNC_MSG_FLAGS_TAG_AUTH_STATUS_SUCCESS		(UINT32_C(0x1) << 12)
 	/*
-	 * When this bit is '1', it indicates that core firmware supports
-	 * DBG_QCAPS command
+	 * This enumeration states that there is at least one tag in the
+	 * packet and at least one of the tag is invalid. The entire packet
+	 * is sent decrypted to the host.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_DBG_QCAPS_CMD_SUPPORTED		UINT32_C(0x80000000)
+		#define TLS_METADATA_INSYNC_MSG_FLAGS_TAG_AUTH_STATUS_FAILURE		(UINT32_C(0x2) << 12)
+		#define TLS_METADATA_INSYNC_MSG_FLAGS_TAG_AUTH_STATUS_LAST			TLS_METADATA_INSYNC_MSG_FLAGS_TAG_AUTH_STATUS_FAILURE
 	/*
-	 * This value is current MAC address configured for this
-	 * function. A value of 00-00-00-00-00-00 indicates no
-	 * MAC address is currently configured.
+	 * A value of 1 indicates that this packet contains a record that
+	 * starts in the packet and extends beyond the packet.
 	 */
-	uint8_t	mac_address[6];
+	#define TLS_METADATA_INSYNC_MSG_FLAGS_HEADER_FLDS_VALID			UINT32_C(0x4000)
 	/*
-	 * The maximum number of RSS/COS contexts that can be
-	 * allocated to the function.
+	 * A value of 1 indicates that the packet experienced a context load
+	 * error. In this case, the packet is sent to the host without the
+	 * header or payload decrypted and the context is not updated.
 	 */
-	uint16_t	max_rsscos_ctx;
+	#define TLS_METADATA_INSYNC_MSG_FLAGS_CTX_LOAD_ERR				UINT32_C(0x8000)
+	/* This field indicates the packet operation state. */
+	#define TLS_METADATA_INSYNC_MSG_FLAGS_PKT_OPERATION_STATE_MASK		UINT32_C(0x70000)
+	#define TLS_METADATA_INSYNC_MSG_FLAGS_PKT_OPERATION_STATE_SFT		16
+	/* Packet is in order. */
+		#define TLS_METADATA_INSYNC_MSG_FLAGS_PKT_OPERATION_STATE_IN_ORDER		(UINT32_C(0x0) << 16)
+	/* Packet is out of order, no header loss. */
+		#define TLS_METADATA_INSYNC_MSG_FLAGS_PKT_OPERATION_STATE_OUT_OF_ORDER	(UINT32_C(0x1) << 16)
+	/* Packet is header search (out of order with header loss). */
+		#define TLS_METADATA_INSYNC_MSG_FLAGS_PKT_OPERATION_STATE_HEADER_SEARCH	(UINT32_C(0x2) << 16)
+	/* Packet is resync (resync record ongoing). */
+		#define TLS_METADATA_INSYNC_MSG_FLAGS_PKT_OPERATION_STATE_RESYNC		(UINT32_C(0x3) << 16)
 	/*
-	 * The maximum number of completion rings that can be
-	 * allocated to the function.
+	 * Packet is resync wait (resync record completes, waiting for
+	 * result).
 	 */
-	uint16_t	max_cmpl_rings;
+		#define TLS_METADATA_INSYNC_MSG_FLAGS_PKT_OPERATION_STATE_RESYNC_WAIT	(UINT32_C(0x4) << 16)
 	/*
-	 * The maximum number of transmit rings that can be
-	 * allocated to the function.
+	 * Packet is resync wait for partial tag (waiting for resync record
+	 * tag).
 	 */
-	uint16_t	max_tx_rings;
+		#define TLS_METADATA_INSYNC_MSG_FLAGS_PKT_OPERATION_STATE_RESYNC_WAIT_PARTIAL   (UINT32_C(0x5) << 16)
+	/* Packet is resync success (got resync record success). */
+		#define TLS_METADATA_INSYNC_MSG_FLAGS_PKT_OPERATION_STATE_RESYNC_SUCCESS	(UINT32_C(0x6) << 16)
 	/*
-	 * The maximum number of receive rings that can be
-	 * allocated to the function.
+	 * Packet is resync success wait (got midpath ACK, waiting for
+	 * resync record success).
 	 */
-	uint16_t	max_rx_rings;
+		#define TLS_METADATA_INSYNC_MSG_FLAGS_PKT_OPERATION_STATE_RESYNC_SUCCESS_WAIT   (UINT32_C(0x7) << 16)
+		#define TLS_METADATA_INSYNC_MSG_FLAGS_PKT_OPERATION_STATE_LAST		TLS_METADATA_INSYNC_MSG_FLAGS_PKT_OPERATION_STATE_RESYNC_SUCCESS_WAIT
 	/*
-	 * The maximum number of L2 contexts that can be
-	 * allocated to the function.
+	 * This value indicates the lower 7-bit of the Crypto Key ID
+	 * associated with this operation.
 	 */
-	uint16_t	max_l2_ctxs;
+	#define TLS_METADATA_INSYNC_MSG_KID_LO_MASK				UINT32_C(0xfe000000)
+	#define TLS_METADATA_INSYNC_MSG_KID_LO_SFT				25
+	uint16_t	kid_hi;
 	/*
-	 * The maximum number of VNICs that can be
-	 * allocated to the function.
+	 * This value indicates the upper 13-bit of the Crypto Key ID
+	 * associated with this operation.
 	 */
-	uint16_t	max_vnics;
+	#define TLS_METADATA_INSYNC_MSG_KID_HI_MASK UINT32_C(0x1fff)
+	#define TLS_METADATA_INSYNC_MSG_KID_HI_SFT 0
 	/*
-	 * The identifier for the first VF enabled on a PF. This
-	 * is valid only on the PF with SR-IOV enabled.
-	 * 0xFF... (All Fs) if this command is called on a PF with
-	 * SR-IOV disabled or on a VF.
+	 * This field is only valid when md_type is set to tls_insync. This
+	 * field indicates the offset within the current TCP packet where the
+	 * TLS header starts. If there are multiple TLS headers in the packet,
+	 * this provides the offset of the last TLS header.
+	 *
+	 * The field is calculated by subtracting TCP sequence number of the
+	 * first byte of the TCP payload of the packet from the TCP sequence
+	 * number of the last TLS header in the packet.
 	 */
-	uint16_t	first_vf_id;
+	uint16_t	tls_header_offset;
 	/*
-	 * The maximum number of VFs that can be
-	 * allocated to the function. This is valid only on the
-	 * PF with SR-IOV enabled. 0xFF... (All Fs) if this
-	 * command is called on a PF with SR-IOV disabled or
-	 * on a VF.
+	 * This is the sequence Number of the record that was processed by the HW.
+	 * If there are multiple records in a packet, this would be the sequence
+	 * number of the last record.
 	 */
-	uint16_t	max_vfs;
+	uint64_t	record_seq_num;
 	/*
-	 * The maximum number of statistic contexts that can be
-	 * allocated to the function.
+	 * This field contains cumulative partial GHASH value of all the packets
+	 * decrypted by the HW associated with a TLS record. This field is valid
+	 * on when packets belonging to have arrived out-of-order and HW could
+	 * not decrypt every packet and authenticate the record. Partial GHASH is
+	 * only sent out with packet having the TAG field.
 	 */
-	uint16_t	max_stat_ctx;
+	uint8_t	partial_ghash[8];
+} tls_metadata_insync_msg_t, *ptls_metadata_insync_msg_t;
+
+/* tls_metadata_resync_msg (size:256b/32B) */
+
+typedef struct tls_metadata_resync_msg {
+	uint32_t	md_type_link_flags_kid_lo;
+	/* This field classifies the data present in the meta-data. */
+	#define TLS_METADATA_RESYNC_MSG_MD_TYPE_MASK				UINT32_C(0x1f)
+	#define TLS_METADATA_RESYNC_MSG_MD_TYPE_SFT				0
 	/*
-	 * The maximum number of Encapsulation records that can be
-	 * offloaded by this function.
+	 * With this setting HW passes the TCP sequence number of the TLS
+	 * record that it is requesting a resync on in the meta data.
 	 */
-	uint32_t	max_encap_records;
+		#define TLS_METADATA_RESYNC_MSG_MD_TYPE_TLS_RESYNC				UINT32_C(0x2)
+		#define TLS_METADATA_RESYNC_MSG_MD_TYPE_LAST				TLS_METADATA_RESYNC_MSG_MD_TYPE_TLS_RESYNC
 	/*
-	 * The maximum number of decapsulation records that can
-	 * be offloaded by this function.
+	 * This field indicates where the next metadata block starts. It is
+	 * counted in 16B units. A value of zero indicates that there is no
+	 * metadata.
 	 */
-	uint32_t	max_decap_records;
+	#define TLS_METADATA_RESYNC_MSG_LINK_MASK					UINT32_C(0x1e0)
+	#define TLS_METADATA_RESYNC_MSG_LINK_SFT					5
+	/* These are flags present in the metadata. */
+	#define TLS_METADATA_RESYNC_MSG_FLAGS_MASK				UINT32_C(0x1fffe00)
+	#define TLS_METADATA_RESYNC_MSG_FLAGS_SFT					9
 	/*
-	 * The maximum number of Exact Match (EM) flows that can be
-	 * offloaded by this function on the TX side.
+	 * A value of 1 implies that the packet was decrypted by HW. Otherwise
+	 * the packet is passed on as it came in on the wire.
 	 */
-	uint32_t	max_tx_em_flows;
+	#define TLS_METADATA_RESYNC_MSG_FLAGS_DECRYPTED				UINT32_C(0x200)
 	/*
-	 * The maximum number of Wildcard Match (WM) flows that can
-	 * be offloaded by this function on the TX side.
+	 * This field indicates the state of the ghash field passed in the
+	 * meta-data.
 	 */
-	uint32_t	max_tx_wm_flows;
+	#define TLS_METADATA_RESYNC_MSG_FLAGS_GHASH_MASK				UINT32_C(0xc00)
+	#define TLS_METADATA_RESYNC_MSG_FLAGS_GHASH_SFT				10
 	/*
-	 * The maximum number of Exact Match (EM) flows that can be
-	 * offloaded by this function on the RX side.
+	 * This enumeration states that the ghash is not valid in the
+	 * meta-data.
 	 */
-	uint32_t	max_rx_em_flows;
+		#define TLS_METADATA_RESYNC_MSG_FLAGS_GHASH_NOT_VALID			(UINT32_C(0x0) << 10)
+		#define TLS_METADATA_RESYNC_MSG_FLAGS_GHASH_LAST				TLS_METADATA_RESYNC_MSG_FLAGS_GHASH_NOT_VALID
+	/* This field indicates the status of tag authentication. */
+	#define TLS_METADATA_RESYNC_MSG_FLAGS_TAG_AUTH_STATUS_MASK			UINT32_C(0x3000)
+	#define TLS_METADATA_RESYNC_MSG_FLAGS_TAG_AUTH_STATUS_SFT			12
 	/*
-	 * The maximum number of Wildcard Match (WM) flows that can
-	 * be offloaded by this function on the RX side.
+	 * This enumeration is set when HW was not able to authenticate a
+	 * TAG.
 	 */
-	uint32_t	max_rx_wm_flows;
+		#define TLS_METADATA_RESYNC_MSG_FLAGS_TAG_AUTH_STATUS_NOT_CHECKED		(UINT32_C(0x0) << 12)
+		#define TLS_METADATA_RESYNC_MSG_FLAGS_TAG_AUTH_STATUS_LAST			TLS_METADATA_RESYNC_MSG_FLAGS_TAG_AUTH_STATUS_NOT_CHECKED
 	/*
-	 * The maximum number of multicast filters that can
-	 * be supported by this function on the RX side.
+	 * A value of 1 indicates that this packet contains a record that
+	 * starts in the packet and extends beyond the packet.
 	 */
-	uint32_t	max_mcast_filters;
+	#define TLS_METADATA_RESYNC_MSG_FLAGS_HEADER_FLDS_VALID			UINT32_C(0x4000)
 	/*
-	 * The maximum value of flow_id that can be supported
-	 * in completion records.
+	 * A value of 1 indicates that the packet experienced a context load
+	 * error. In this case, the packet is sent to the host without the
+	 * header or payload decrypted and the context is not updated.
 	 */
-	uint32_t	max_flow_id;
+	#define TLS_METADATA_RESYNC_MSG_FLAGS_CTX_LOAD_ERR				UINT32_C(0x8000)
+	/* This field indicates the packet operation state. */
+	#define TLS_METADATA_RESYNC_MSG_FLAGS_PKT_OPERATION_STATE_MASK		UINT32_C(0x70000)
+	#define TLS_METADATA_RESYNC_MSG_FLAGS_PKT_OPERATION_STATE_SFT		16
+	/* Packet is in order. */
+		#define TLS_METADATA_RESYNC_MSG_FLAGS_PKT_OPERATION_STATE_IN_ORDER		(UINT32_C(0x0) << 16)
+	/* Packet is out of order, no header loss. */
+		#define TLS_METADATA_RESYNC_MSG_FLAGS_PKT_OPERATION_STATE_OUT_OF_ORDER	(UINT32_C(0x1) << 16)
+	/* Packet is header search (out of order with header loss). */
+		#define TLS_METADATA_RESYNC_MSG_FLAGS_PKT_OPERATION_STATE_HEADER_SEARCH	(UINT32_C(0x2) << 16)
+	/* Packet is resync (resync record ongoing). */
+		#define TLS_METADATA_RESYNC_MSG_FLAGS_PKT_OPERATION_STATE_RESYNC		(UINT32_C(0x3) << 16)
 	/*
-	 * The maximum number of HW ring groups that can be
-	 * supported on this function.
+	 * Packet is resync wait (resync record completes, waiting for
+	 * result).
 	 */
-	uint32_t	max_hw_ring_grps;
+		#define TLS_METADATA_RESYNC_MSG_FLAGS_PKT_OPERATION_STATE_RESYNC_WAIT	(UINT32_C(0x4) << 16)
 	/*
-	 * The maximum number of strict priority transmit rings
-	 * that can be allocated to the function.
-	 * This number indicates the maximum number of TX rings
-	 * that can be assigned strict priorities out of the
-	 * maximum number of TX rings that can be allocated
-	 * (max_tx_rings) to the function.
+	 * Packet is resync wait for partial tag (waiting for resync record
+	 * tag).
 	 */
-	uint16_t	max_sp_tx_rings;
-	uint8_t	unused_0[2];
-	uint32_t	flags_ext;
+		#define TLS_METADATA_RESYNC_MSG_FLAGS_PKT_OPERATION_STATE_RESYNC_WAIT_PARTIAL   (UINT32_C(0x5) << 16)
+	/* Packet is resync success (got resync record success). */
+		#define TLS_METADATA_RESYNC_MSG_FLAGS_PKT_OPERATION_STATE_RESYNC_SUCCESS	(UINT32_C(0x6) << 16)
 	/*
-	 * If 1, the device can be configured to set the ECN bits in the
-	 * IP header of received packets if the receive queue length
-	 * exceeds a given threshold.
+	 * Packet is resync success wait (got midpath ACK, waiting for
+	 * resync record success).
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_ECN_MARK_SUPPORTED			UINT32_C(0x1)
+		#define TLS_METADATA_RESYNC_MSG_FLAGS_PKT_OPERATION_STATE_RESYNC_SUCCESS_WAIT   (UINT32_C(0x7) << 16)
+		#define TLS_METADATA_RESYNC_MSG_FLAGS_PKT_OPERATION_STATE_LAST		TLS_METADATA_RESYNC_MSG_FLAGS_PKT_OPERATION_STATE_RESYNC_SUCCESS_WAIT
 	/*
-	 * If 1, the device can report the number of received packets
-	 * that it marked as having experienced congestion.
+	 * This value indicates the lower 7-bit of the Crypto Key ID
+	 * associated with this operation.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_ECN_STATS_SUPPORTED			UINT32_C(0x2)
+	#define TLS_METADATA_RESYNC_MSG_KID_LO_MASK				UINT32_C(0xfe000000)
+	#define TLS_METADATA_RESYNC_MSG_KID_LO_SFT				25
+	uint16_t	kid_hi;
 	/*
-	 * If 1, the device can report extended hw statistics (including
-	 * additional tpa statistics).
+	 * This value indicates the upper 13-bit of the Crypto Key ID
+	 * associated with this operation.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_EXT_HW_STATS_SUPPORTED		UINT32_C(0x4)
+	#define TLS_METADATA_RESYNC_MSG_KID_HI_MASK UINT32_C(0x1fff)
+	#define TLS_METADATA_RESYNC_MSG_KID_HI_SFT 0
+	/* This field is unused in this context. */
+	uint16_t	metadata_0;
 	/*
-	 * If set to 1, then the core firmware has support to enable/
-	 * disable hot reset support for interface dynamically through
-	 * HWRM_FUNC_CFG.
+	 * This field indicates the TCP sequence number of the TLS record that HW
+	 * is requesting a resync on from the Driver. HW will keep a count of the
+	 * TLS records it found after this record (delta_records). Driver will
+	 * provide the TLS Record Sequence Number associated with the record. HW
+	 * will add the delta_records to the Record Sequence Number provided by
+	 * the driver and get back on sync.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_HOT_RESET_IF_SUPPORT		UINT32_C(0x8)
-	/* If 1, the proxy mode is supported on this function */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_PROXY_MODE_SUPPORT			UINT32_C(0x10)
+	uint32_t	resync_record_tcp_seq_num;
+	uint32_t	unused0;
+	/* This field is unused in this context. */
+	uint64_t	metadata_2;
+	/* This field is unused in this context. */
+	uint64_t	metadata_3;
+} tls_metadata_resync_msg_t, *ptls_metadata_resync_msg_t;
+
+/* tx_doorbell (size:32b/4B) */
+
+typedef struct tx_doorbell {
+	uint32_t	key_idx;
 	/*
-	 * If 1, the tx rings source interface override feature is supported
-	 * on this function.
+	 * BD Index of next BD that will be used to transmit data
+	 * on the TX ring mapped to this door bell. NIC may
+	 * read and process all BDs up to, but not including this
+	 * index.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_TX_PROXY_SRC_INTF_OVERRIDE_SUPPORT	UINT32_C(0x20)
+	#define TX_DOORBELL_IDX_MASK UINT32_C(0xffffff)
+	#define TX_DOORBELL_IDX_SFT 0
 	/*
-	 * If 1, the device supports scheduler queues. SCHQs can be managed
-	 * using RING_SCHQ_ALLOC/CFG/FREE commands.
+	 * This value indicates the type of door bell operation
+	 * that is begin requested. This value is '0' for TX
+	 * door bell operations.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_SCHQ_SUPPORTED			UINT32_C(0x40)
+	#define TX_DOORBELL_KEY_MASK UINT32_C(0xf0000000)
+	#define TX_DOORBELL_KEY_SFT 28
+	/* TX Operation */
+		#define TX_DOORBELL_KEY_TX	(UINT32_C(0x0) << 28)
+		#define TX_DOORBELL_KEY_LAST TX_DOORBELL_KEY_TX
+} tx_doorbell_t, *ptx_doorbell_t;
+
+/* rx_doorbell (size:32b/4B) */
+
+typedef struct rx_doorbell {
+	uint32_t	key_idx;
 	/*
-	 * If set to 1, then this function supports the TX push mode that
-	 * uses ping-pong buffers from the push pages.
+	 * BD Index of next BD that will be used for an empty receive
+	 * buffer on the RX ring mapped to this door bell. NIC may
+	 * read and process all BDs up to, but not including this
+	 * index.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_PPP_PUSH_MODE_SUPPORTED		UINT32_C(0x80)
+	#define RX_DOORBELL_IDX_MASK UINT32_C(0xffffff)
+	#define RX_DOORBELL_IDX_SFT 0
 	/*
-	 * If set to 1, then this function doesn't have the privilege to
-	 * configure the EVB mode of the port it uses.
+	 * This value indicates the type of door bell operation
+	 * that is begin requested. This value is '1' for RX
+	 * door bell operations.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_EVB_MODE_CFG_NOT_SUPPORTED		UINT32_C(0x100)
+	#define RX_DOORBELL_KEY_MASK UINT32_C(0xf0000000)
+	#define RX_DOORBELL_KEY_SFT 28
+	/* RX Operation */
+		#define RX_DOORBELL_KEY_RX	(UINT32_C(0x1) << 28)
+		#define RX_DOORBELL_KEY_LAST RX_DOORBELL_KEY_RX
+} rx_doorbell_t, *prx_doorbell_t;
+
+/* cmpl_doorbell (size:32b/4B) */
+
+typedef struct cmpl_doorbell {
+	uint32_t	key_mask_valid_idx;
 	/*
-	 * If set to 1, then the HW and FW support the SoC packet DMA
-	 * datapath between SoC and NIC. This function can act as the
-	 * HWRM communication transport agent on behalf of the SoC SPD
-	 * software module. This capability is only advertised to the
-	 * SoC PFs.
+	 * BD Index of the most recently handed completion record
+	 * on the completion ring mapped to this door bell.
+	 * NIC may
+	 * write this location again with a new completion.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_SOC_SPD_SUPPORTED			UINT32_C(0x200)
+	#define CMPL_DOORBELL_IDX_MASK	UINT32_C(0xffffff)
+	#define CMPL_DOORBELL_IDX_SFT	0
 	/*
-	 * If set to 1, then this function supports FW_LIVEPATCH for
-	 * firmware livepatch commands.
+	 * This indicates if the BDIDX value is valid for this
+	 * update when it is '1'. When it is '0', the BDIDX
+	 * value should be ignored.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_FW_LIVEPATCH_SUPPORTED		UINT32_C(0x400)
+	#define CMPL_DOORBELL_IDX_VALID	UINT32_C(0x4000000)
 	/*
-	 * When this bit is '1', it indicates that core firmware is
-	 * capable of fast Reset.
+	 * This bit indicates the new interrupt mask state for the
+	 * interrupt associated with the BDIDX. A '1', means the
+	 * interrupt is to be masked. A '0' indicates the interrupt
+	 * is to be unmasked.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_FAST_RESET_CAPABLE			UINT32_C(0x800)
+	#define CMPL_DOORBELL_MASK	UINT32_C(0x8000000)
 	/*
-	 * When this bit is '1', it indicates that firmware and hardware
-	 * are capable of updating tx_metadata via hwrm_ring_cfg command.
+	 * This value indicates the type of door bell operation
+	 * that is begin requested. This value is '2' for CMP
+	 * door bell operations.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_TX_METADATA_CFG_CAPABLE		UINT32_C(0x1000)
+	#define CMPL_DOORBELL_KEY_MASK	UINT32_C(0xf0000000)
+	#define CMPL_DOORBELL_KEY_SFT	28
+	/* Completion Operation */
+		#define CMPL_DOORBELL_KEY_CMPL	(UINT32_C(0x2) << 28)
+		#define CMPL_DOORBELL_KEY_LAST	CMPL_DOORBELL_KEY_CMPL
+} cmpl_doorbell_t, *pcmpl_doorbell_t;
+
+/* status_doorbell (size:32b/4B) */
+
+typedef struct status_doorbell {
+	uint32_t	key_idx;
 	/*
-	 * If set to 1, then the device can report the action
-	 * needed to activate set nvm options.
+	 * BD Index of the status record for which space is now
+	 * available to the NIC.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_NVM_OPTION_ACTION_SUPPORTED		UINT32_C(0x2000)
 	/*
-	 * When this bit is '1', it indicates that the BD metadata feature
-	 * is supported for this function.
+	 * While there is no actual BD associated with the index,
+	 * the similar scheme is being used to communicate to
+	 * the NIC that space is available for status completions.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_BD_METADATA_SUPPORTED		UINT32_C(0x4000)
+	#define STATUS_DOORBELL_IDX_MASK UINT32_C(0xffffff)
+	#define STATUS_DOORBELL_IDX_SFT 0
 	/*
-	 * When this bit is '1', it indicates that the echo request feature
-	 * is supported for this function. If the driver registers for the
-	 * echo request asynchronous event, then the firmware can send an
-	 * unsolicited echo request to the driver and expect an echo
-	 * response.
+	 * This value indicates the type of door bell operation
+	 * that is begin requested. This value is '3' for Status
+	 * door bell operations.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_ECHO_REQUEST_SUPPORTED		UINT32_C(0x8000)
+	#define STATUS_DOORBELL_KEY_MASK UINT32_C(0xf0000000)
+	#define STATUS_DOORBELL_KEY_SFT 28
+	/* Status Operation */
+		#define STATUS_DOORBELL_KEY_STAT  (UINT32_C(0x3) << 28)
+		#define STATUS_DOORBELL_KEY_LAST STATUS_DOORBELL_KEY_STAT
+} status_doorbell_t, *pstatus_doorbell_t;
+
+/* push32_doorbell (size:1024b/128B) */
+
+typedef struct push32_doorbell {
+	uint32_t	key_sz_idx;
 	/*
-	 * When this bit is '1', it indicates that core firmware supports
-	 * NPAR 1.2 on this function.
+	 * This is the BD Index of last BD of the push packet
+	 * that will be used to transmit data on the TX ring mapped
+	 * to this door bell.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_NPAR_1_2_SUPPORTED			UINT32_C(0x10000)
-	/* When this bit is '1', it indicates that PTM feature is supported. */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_PTP_PTM_SUPPORTED			UINT32_C(0x20000)
-	/* When this bit is '1', it indicates that PPS feature is supported. */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_PTP_PPS_SUPPORTED			UINT32_C(0x40000)
+	#define PUSH32_DOORBELL_IDX_MASK UINT32_C(0xffffff)
+	#define PUSH32_DOORBELL_IDX_SFT 0
 	/*
-	 * When this bit is '1', it indicates that VF config. change
-	 * async event is supported on the parent PF if the async.
-	 * event is registered by the PF.
+	 * This is the number of 16B BDs spaces consumed in the TX
+	 * Ring by the "backup" version of the packet being pushed.
+	 * A value of 1 is invalid since backup must start with a
+	 * long 32B BE.
+	 * A value of 2 indicates just the first 32B BE.
+	 * A value of 3 indicates 32B+16B BD. etc.
+	 * A value of 0 indicates 16x16B BD spaces are consumed.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_VF_CFG_ASYNC_FOR_PF_SUPPORTED	UINT32_C(0x80000)
+	#define PUSH32_DOORBELL_SZ_MASK UINT32_C(0xf000000)
+	#define PUSH32_DOORBELL_SZ_SFT  24
 	/*
-	 * When this bit is '1', the NIC supports configuration of
-	 * partition_min_bw and partition_max_bw.
+	 * This value indicates the type of door bell operation
+	 * that is begin requested. This value is 4 for push
+	 * door bell operations.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_PARTITION_BW_SUPPORTED		UINT32_C(0x100000)
+	#define PUSH32_DOORBELL_KEY_MASK UINT32_C(0xf0000000)
+	#define PUSH32_DOORBELL_KEY_SFT 28
+	/* Push Operation */
+		#define PUSH32_DOORBELL_KEY_PUSH  (UINT32_C(0x4) << 28)
+		#define PUSH32_DOORBELL_KEY_LAST PUSH32_DOORBELL_KEY_PUSH
+	uint16_t	flags_type;
+	/* This value identifies the type of buffer descriptor. */
+	#define PUSH32_DOORBELL_TYPE_MASK		UINT32_C(0x3f)
+	#define PUSH32_DOORBELL_TYPE_SFT		0
 	/*
-	 * When this bit is '1', the FW supports configuration of
-	 * PCP and TPID values of the default VLAN.
+	 * Indicates that this BD is 32B long and is used for
+	 * normal L2 packet transmission.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_DFLT_VLAN_TPID_PCP_SUPPORTED	UINT32_C(0x200000)
-	/* When this bit is '1', it indicates that HW and FW support KTLS. */
-	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_KTLS_SUPPORTED			UINT32_C(0x400000)
-	/* The maximum number of SCHQs supported by this device. */
-	uint8_t	max_schqs;
-	uint8_t	mpc_chnls_cap;
+		#define PUSH32_DOORBELL_TYPE_TX_BD_LONG	UINT32_C(0x10)
+		#define PUSH32_DOORBELL_TYPE_LAST		PUSH32_DOORBELL_TYPE_TX_BD_LONG
 	/*
-	 * When this bit is '1', it indicates that HW and firmware
-	 * supports the use of a MPC channel with destination set
-	 * to the TX crypto engine block.
+	 * All bits in this field must be valid on the first BD of a packet.
+	 * Only the packet_end bit must be valid for the remaining BDs
+	 * of a packet.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_MPC_CHNLS_CAP_TCE	UINT32_C(0x1)
+	#define PUSH32_DOORBELL_FLAGS_MASK	UINT32_C(0xffc0)
+	#define PUSH32_DOORBELL_FLAGS_SFT		6
 	/*
-	 * When this bit is '1', it indicates that HW and firmware
-	 * supports the use of a MPC channel with destination set
-	 * to the RX crypto engine block.
+	 * If set to 1, the packet ends with the data in the buffer
+	 * pointed to by this descriptor. This flag must be
+	 * valid on every BD.
+	 *
+	 *	This bit must be set on all push doorbells.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_MPC_CHNLS_CAP_RCE	UINT32_C(0x2)
+	#define PUSH32_DOORBELL_FLAGS_PACKET_END	UINT32_C(0x40)
 	/*
-	 * When this bit is '1', it indicates that HW and firmware
-	 * supports the use of a MPC channel with destination set
-	 * to the TX configurable flow processing block.
+	 * If set to 1, the device will not generate a completion for
+	 * this transmit packet unless there is an error in it's
+	 * processing.
+	 * If this bit
+	 * is set to 0, then the packet will be completed normally.
+	 *
+	 * This bit must be valid only on the first BD of a packet.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_MPC_CHNLS_CAP_TE_CFA	UINT32_C(0x4)
+	#define PUSH32_DOORBELL_FLAGS_NO_CMPL	UINT32_C(0x80)
 	/*
-	 * When this bit is '1', it indicates that HW and firmware
-	 * supports the use of a MPC channel with destination set
-	 * to the RX configurable flow processing block.
+	 * This value must match the sz field in the first
+	 * 32b of the push operation except that if
+	 * 16x16B BD locations
+	 * are consumed in the ring by this packet, then
+	 * this value must be 16 (not zero).
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_MPC_CHNLS_CAP_RE_CFA	UINT32_C(0x8)
+	#define PUSH32_DOORBELL_FLAGS_BD_CNT_MASK	UINT32_C(0x1f00)
+	#define PUSH32_DOORBELL_FLAGS_BD_CNT_SFT	8
 	/*
-	 * When this bit is '1', it indicates that HW and firmware
-	 * supports the use of a MPC channel with destination set
-	 * to the primate processor block.
+	 * This value is a hint for the length of the entire packet.
+	 * It is used by the chip to optimize internal processing.
+	 *
+	 * The packet will be dropped if the hint is too short.
+	 *
+	 * This field is valid only on the first BD of a packet.
 	 */
-	#define HWRM_FUNC_QCAPS_OUTPUT_MPC_CHNLS_CAP_PRIMATE	UINT32_C(0x10)
-	uint8_t	unused_1;
+	#define PUSH32_DOORBELL_FLAGS_LHINT_MASK	UINT32_C(0x6000)
+	#define PUSH32_DOORBELL_FLAGS_LHINT_SFT	13
+	/* indicates packet length < 512B */
+		#define PUSH32_DOORBELL_FLAGS_LHINT_LT512	(UINT32_C(0x0) << 13)
+	/* indicates 512 <= packet length < 1KB */
+		#define PUSH32_DOORBELL_FLAGS_LHINT_LT1K	(UINT32_C(0x1) << 13)
+	/* indicates 1KB <= packet length < 2KB */
+		#define PUSH32_DOORBELL_FLAGS_LHINT_LT2K	(UINT32_C(0x2) << 13)
+	/* indicates packet length >= 2KB */
+		#define PUSH32_DOORBELL_FLAGS_LHINT_GTE2K	(UINT32_C(0x3) << 13)
+		#define PUSH32_DOORBELL_FLAGS_LHINT_LAST	PUSH32_DOORBELL_FLAGS_LHINT_GTE2K
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * If set to 1, the device immediately updates the Send Consumer
+	 * Index after the buffer associated with this descriptor has
+	 * been transferred via DMA to NIC memory from host memory. An
+	 * interrupt may or may not be generated according to the state
+	 * of the interrupt avoidance mechanisms. If this bit
+	 * is set to 0, then the Consumer Index is only updated as soon
+	 * as one of the host interrupt coalescing conditions has been met.
+	 *
+	 * This bit must be valid on the first BD of a packet.
 	 */
-	uint8_t	valid;
-} hwrm_func_qcaps_output_t, *phwrm_func_qcaps_output_t;
-
-/******************
- * hwrm_func_qcfg *
- ******************/
-
-
-/* hwrm_func_qcfg_input (size:192b/24B) */
-
-typedef struct hwrm_func_qcfg_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define PUSH32_DOORBELL_FLAGS_COAL_NOW	UINT32_C(0x8000)
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * This is the length of the host physical buffer this BD describes
+	 * in bytes.
+	 *
+	 * This field must be valid on all BDs of a packet.
 	 */
-	uint16_t	cmpl_ring;
+	uint16_t	len;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * The opaque data field is pass through to the completion and can be
+	 * used for any data that the driver wants to associate with the
+	 * transmit BD.
+	 *
+	 * This field must be valid on the first BD of a packet.
 	 */
-	uint16_t	seq_id;
+	uint32_t	opaque;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * All bits in this field must be valid on the first BD of a packet.
+	 * Their value on other BDs of the packet will be ignored.
 	 */
-	uint16_t	target_id;
+	uint16_t	lflags;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * If set to 1, the controller replaces the TCP/UPD checksum
+	 * fields of normal TCP/UPD checksum, or the inner TCP/UDP
+	 * checksum field of the encapsulated TCP/UDP packets with the
+	 * hardware calculated TCP/UDP checksum for the packet associated
+	 * with this descriptor. The flag is ignored if the LSO flag is set.
+	 *
+	 * This bit must be valid on the first BD of a packet.
 	 */
-	uint64_t	resp_addr;
+	#define PUSH32_DOORBELL_LFLAGS_TCP_UDP_CHKSUM	UINT32_C(0x1)
 	/*
-	 * Function ID of the function that is being queried.
-	 * 0xFF... (All Fs) if the query is for the requesting
-	 * function.
-	 * 0xFFFE (REQUESTING_PARENT_FID) This is a special FID
-	 * to be used by a trusted VF to query its parent PF.
+	 * If set to 1, the controller replaces the IP checksum of the
+	 * normal packets, or the inner IP checksum of the encapsulated
+	 * packets with the hardware calculated IP checksum for the
+	 * packet associated with this descriptor.
+	 *
+	 * This bit must be valid on the first BD of a packet.
 	 */
-	uint16_t	fid;
-	uint8_t	unused_0[6];
-} hwrm_func_qcfg_input_t, *phwrm_func_qcfg_input_t;
-
-/* hwrm_func_qcfg_output (size:832b/104B) */
-
-typedef struct hwrm_func_qcfg_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
+	#define PUSH32_DOORBELL_LFLAGS_IP_CHKSUM	UINT32_C(0x2)
 	/*
-	 * FID value.  This value is used to identify operations on the PCI
-	 * bus as belonging to a particular PCI function.
+	 * If set to 1, the controller will not append an Ethernet CRC
+	 * to the end of the frame.
+	 *
+	 * This bit must be valid on the first BD of a packet.
+	 *
+	 * Packet must be 64B or longer when this flag is set. It is not
+	 * useful to use this bit with any form of TX offload such as
+	 * CSO or LSO. The intent is that the packet from the host already
+	 * has a valid Ethernet CRC on the packet.
 	 */
-	uint16_t	fid;
+	#define PUSH32_DOORBELL_LFLAGS_NOCRC		UINT32_C(0x4)
 	/*
-	 * Port ID of port that this function is associated with.
-	 * 0xFF... (All Fs) if this function is not associated with
-	 * any port.
+	 * If set to 1, the device will record the time at which the packet
+	 * was actually transmitted at the TX MAC.
+	 *
+	 * This bit must be valid on the first BD of a packet.
 	 */
-	uint16_t	port_id;
+	#define PUSH32_DOORBELL_LFLAGS_STAMP		UINT32_C(0x8)
 	/*
-	 * This value is the current VLAN setting for this
-	 * function. The value of 0 for this field indicates
-	 * no priority tagging or VLAN is used.
-	 * This field's format is same as 802.1Q Tag's
-	 * Tag Control Information (TCI) format that includes both
-	 * Priority Code Point (PCP) and VLAN Identifier (VID).
+	 * If set to 1, The controller replaces the tunnel IP checksum
+	 * field with hardware calculated IP checksum for the IP header
+	 * of the packet associated with this descriptor.
+	 *
+	 * For outer UDP checksum, global outer UDP checksum TE_NIC register
+	 * needs to be enabled. If the global outer UDP checksum TE_NIC
+	 * register bit is set, outer UDP checksum will be calculated for the
+	 * following cases:
+	 * 1. Packets with tcp_udp_chksum flag set to offload checksum for
+	 * inner packet AND the inner packet is TCP/UDP. If the inner packet is
+	 * ICMP for example (non-TCP/UDP), even if the tcp_udp_chksum is set,
+	 * the outer UDP checksum will not be calculated.
+	 * 2. Packets with lso flag set which implies inner TCP checksum
+	 * calculation as part of LSO operation.
 	 */
-	uint16_t	vlan;
-	uint16_t	flags;
+	#define PUSH32_DOORBELL_LFLAGS_T_IP_CHKSUM	UINT32_C(0x10)
 	/*
-	 * If 1, then magic packet based Out-Of-Box WoL is enabled on
-	 * the port associated with this function.
+	 * If set to 1, the device will treat this packet with LSO(Large
+	 * Send Offload) processing for both normal or encapsulated
+	 * packets, which is a form of TCP segmentation. When this bit
+	 * is 1, the hdr_size and mss fields must be valid. The driver
+	 * doesn't need to set t_ip_chksum, ip_chksum, and tcp_udp_chksum
+	 * flags since the controller will replace the appropriate
+	 * checksum fields for segmented packets.
+	 *
+	 * When this bit is 1, the hdr_size and mss fields must be valid.
 	 */
-	#define HWRM_FUNC_QCFG_OUTPUT_FLAGS_OOB_WOL_MAGICPKT_ENABLED	UINT32_C(0x1)
+	#define PUSH32_DOORBELL_LFLAGS_LSO		UINT32_C(0x20)
 	/*
-	 * If 1, then bitmap pattern based Out-Of-Box WoL packet is enabled
-	 * on the port associated with this function.
+	 * If set to zero when LSO is '1', then the IPID will be treated
+	 * as a 16b number and will be wrapped if it exceeds a value of
+	 * 0xffff.
+	 *
+	 * If set to one when LSO is '1', then the IPID will be treated
+	 * as a 15b number and will be wrapped if it exceeds a value of
+	 * 0x7fff.
 	 */
-	#define HWRM_FUNC_QCFG_OUTPUT_FLAGS_OOB_WOL_BMP_ENABLED	UINT32_C(0x2)
+	#define PUSH32_DOORBELL_LFLAGS_IPID_FMT	UINT32_C(0x40)
 	/*
-	 * If set to 1, then FW based DCBX agent is enabled and running on
-	 * the port associated with this function.
-	 * If set to 0, then DCBX agent is not running in the firmware.
+	 * If set to zero when LSO is '1', then the IPID of the tunnel
+	 * IP header will not be modified during LSO operations.
+	 *
+	 * If set to one when LSO is '1', then the IPID of the tunnel
+	 * IP header will be incremented for each subsequent segment of an
+	 * LSO operation.
+	 *
+	 * The flag is ignored if the LSO packet is a normal (non-tunneled)
+	 * TCP packet.
 	 */
-	#define HWRM_FUNC_QCFG_OUTPUT_FLAGS_FW_DCBX_AGENT_ENABLED	UINT32_C(0x4)
+	#define PUSH32_DOORBELL_LFLAGS_T_IPID		UINT32_C(0x80)
 	/*
-	 * Standard TX Ring mode is used for the allocation of TX ring
-	 * and underlying scheduling resources that allow bandwidth
-	 * reservation and limit settings on the queried function.
-	 * If set to 1, then standard TX ring mode is enabled
-	 * on the queried function.
-	 * If set to 0, then the standard TX ring mode is disabled
-	 * on the queried function. In this extended TX ring resource
-	 * mode, the minimum and maximum bandwidth settings are not
-	 * supported to allow the allocation of TX rings to span multiple
-	 * scheduler nodes.
+	 * If set to '1', then the RoCE ICRC will be appended to the
+	 * packet. Packet must be a valid RoCE format packet.
 	 */
-	#define HWRM_FUNC_QCFG_OUTPUT_FLAGS_STD_TX_RING_MODE_ENABLED	UINT32_C(0x8)
+	#define PUSH32_DOORBELL_LFLAGS_ROCE_CRC	UINT32_C(0x100)
 	/*
-	 * If set to 1 then FW based LLDP agent is enabled and running on
-	 * the port associated with this function.
-	 * If set to 0 then the LLDP agent is not running in the firmware.
+	 * If set to '1', then the FCoE CRC will be appended to the
+	 * packet. Packet must be a valid FCoE format packet.
 	 */
-	#define HWRM_FUNC_QCFG_OUTPUT_FLAGS_FW_LLDP_AGENT_ENABLED	UINT32_C(0x10)
+	#define PUSH32_DOORBELL_LFLAGS_FCOE_CRC	UINT32_C(0x200)
+	uint16_t	hdr_size;
 	/*
-	 * If set to 1, then multi-host mode is active for this function.
-	 * The NIC is attached to two or more independent host systems
-	 * through two or more PCIe endpoints.
-	 * If set to 0, then multi-host mode is inactive for this function
-	 * or not applicable for this device.
+	 * When LSO is '1', this field must contain the offset of the
+	 * TCP payload from the beginning of the packet in as
+	 * 16b words. In case of encapsulated/tunneling packet, this field
+	 * contains the offset of the inner TCP payload from beginning of the
+	 * packet as 16-bit words.
+	 *
+	 * This value must be valid on the first BD of a packet.
 	 */
-	#define HWRM_FUNC_QCFG_OUTPUT_FLAGS_MULTI_HOST		UINT32_C(0x20)
+	#define PUSH32_DOORBELL_HDR_SIZE_MASK UINT32_C(0x1ff)
+	#define PUSH32_DOORBELL_HDR_SIZE_SFT 0
+	uint32_t	mss;
 	/*
-	 * If the function that is being queried is a PF, then the HWRM shall
-	 * set this field to 0 and the HWRM client shall ignore this field.
-	 * If the function that is being queried is a VF, then the HWRM shall
-	 * set this field to 1 if the queried VF is trusted, otherwise the HWRM
-	 * shall set this field to 0.
+	 * This is the MSS value that will be used to do the LSO processing.
+	 * The value is the length in bytes of the TCP payload for each
+	 * segment generated by the LSO operation.
+	 *
+	 * This value must be valid on the first BD of a packet.
 	 */
-	#define HWRM_FUNC_QCFG_OUTPUT_FLAGS_TRUSTED_VF		UINT32_C(0x40)
+	#define PUSH32_DOORBELL_MSS_MASK UINT32_C(0x7fff)
+	#define PUSH32_DOORBELL_MSS_SFT 0
+	uint16_t	unused_2;
 	/*
-	 * If set to 1, then secure mode is enabled for this function or device.
-	 * If set to 0, then secure mode is disabled (or normal mode) for this
-	 * function or device.
+	 * This value selects a CFA action to perform on the packet.
+	 * Set this value to zero if no CFA action is desired.
+	 *
+	 * This value must be valid on the first BD of a packet.
 	 */
-	#define HWRM_FUNC_QCFG_OUTPUT_FLAGS_SECURE_MODE_ENABLED	UINT32_C(0x80)
+	uint16_t	cfa_action;
 	/*
-	 * If set to 1, then this PF is enabled with a preboot driver that
-	 * requires access to the legacy L2 ring model and legacy 32b
-	 * doorbells. If set to 0, then this PF is not allowed to use
-	 * the legacy L2 rings. This feature is not allowed on VFs and
-	 * is only relevant for devices that require a context backing
-	 * store.
+	 * This value is action meta-data that defines CFA edit operations
+	 * that are done in addition to any action editing.
 	 */
-	#define HWRM_FUNC_QCFG_OUTPUT_FLAGS_PREBOOT_LEGACY_L2_RINGS	UINT32_C(0x100)
+	uint32_t	cfa_meta;
+	/* When key=1, This is the VLAN tag VID value. */
+	#define PUSH32_DOORBELL_CFA_META_VLAN_VID_MASK	UINT32_C(0xfff)
+	#define PUSH32_DOORBELL_CFA_META_VLAN_VID_SFT	0
+	/* When key=1, This is the VLAN tag DE value. */
+	#define PUSH32_DOORBELL_CFA_META_VLAN_DE	UINT32_C(0x1000)
+	/* When key=1, This is the VLAN tag PRI value. */
+	#define PUSH32_DOORBELL_CFA_META_VLAN_PRI_MASK	UINT32_C(0xe000)
+	#define PUSH32_DOORBELL_CFA_META_VLAN_PRI_SFT	13
+	/* When key=1, This is the VLAN tag TPID select value. */
+	#define PUSH32_DOORBELL_CFA_META_VLAN_TPID_MASK	UINT32_C(0x70000)
+	#define PUSH32_DOORBELL_CFA_META_VLAN_TPID_SFT	16
+	/* 0x88a8 */
+		#define PUSH32_DOORBELL_CFA_META_VLAN_TPID_TPID88A8  (UINT32_C(0x0) << 16)
+	/* 0x8100 */
+		#define PUSH32_DOORBELL_CFA_META_VLAN_TPID_TPID8100  (UINT32_C(0x1) << 16)
+	/* 0x9100 */
+		#define PUSH32_DOORBELL_CFA_META_VLAN_TPID_TPID9100  (UINT32_C(0x2) << 16)
+	/* 0x9200 */
+		#define PUSH32_DOORBELL_CFA_META_VLAN_TPID_TPID9200  (UINT32_C(0x3) << 16)
+	/* 0x9300 */
+		#define PUSH32_DOORBELL_CFA_META_VLAN_TPID_TPID9300  (UINT32_C(0x4) << 16)
+	/* Value programmed in CFA VLANTPID register. */
+		#define PUSH32_DOORBELL_CFA_META_VLAN_TPID_TPIDCFG   (UINT32_C(0x5) << 16)
+		#define PUSH32_DOORBELL_CFA_META_VLAN_TPID_LAST	PUSH32_DOORBELL_CFA_META_VLAN_TPID_TPIDCFG
+	/* When key=1, This is the VLAN tag TPID select value. */
+	#define PUSH32_DOORBELL_CFA_META_VLAN_RESERVED_MASK UINT32_C(0xff80000)
+	#define PUSH32_DOORBELL_CFA_META_VLAN_RESERVED_SFT 19
 	/*
-	 * If set to 1, then the firmware and all currently registered driver
-	 * instances support hot reset. The hot reset support will be updated
-	 * dynamically based on the driver interface advertisement.
-	 * If set to 0, then the adapter is not currently able to initiate
-	 * hot reset.
+	 * This field identifies the type of edit to be performed
+	 * on the packet.
+	 *
+	 * This value must be valid on the first BD of a packet.
 	 */
-	#define HWRM_FUNC_QCFG_OUTPUT_FLAGS_HOT_RESET_ALLOWED		UINT32_C(0x200)
+	#define PUSH32_DOORBELL_CFA_META_KEY_MASK	UINT32_C(0xf0000000)
+	#define PUSH32_DOORBELL_CFA_META_KEY_SFT	28
+	/* No editing */
+		#define PUSH32_DOORBELL_CFA_META_KEY_NONE		(UINT32_C(0x0) << 28)
 	/*
-	 * If set to 1, then the PPP tx push mode is enabled for all the
-	 * reserved TX rings of this function. If set to 0, then PPP tx push
-	 * mode is disabled for all the reserved TX rings of this function.
+	 * - meta[17:16] - TPID select value (0 = 0x8100).
+	 * - meta[15:12] - PRI/DE value.
+	 * - meta[11:0] - VID value.
 	 */
-	#define HWRM_FUNC_QCFG_OUTPUT_FLAGS_PPP_PUSH_MODE_ENABLED	UINT32_C(0x400)
+		#define PUSH32_DOORBELL_CFA_META_KEY_VLAN_TAG	(UINT32_C(0x1) << 28)
+		#define PUSH32_DOORBELL_CFA_META_KEY_LAST	PUSH32_DOORBELL_CFA_META_KEY_VLAN_TAG
 	/*
-	 * If set to 1, then the firmware will notify driver using async
-	 * event when a ring is disabled due to a Hardware error.
+	 * This is the data for the push packet. If the packet
+	 * data does not fit in the first pass, data writing
+	 * can continue at offset 4 of the doorbell for up to 4 additional
+	 * passes for a total data size of 512B maximum.
 	 */
-	#define HWRM_FUNC_QCFG_OUTPUT_FLAGS_RING_MONITOR_ENABLED	UINT32_C(0x800)
+	uint32_t	data[25];
+} push32_doorbell_t, *ppush32_doorbell_t;
+
+/*******************
+ * hwrm_func_reset *
+ *******************/
+
+
+/* hwrm_func_reset_input (size:192b/24B) */
+
+typedef struct hwrm_func_reset_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * If set to 1, then the firmware and all currently registered driver
-	 * instances support fast reset. The fast reset support will be
-	 * updated dynamically based on the driver interface advertisement.
-	 * If set to 0, then the adapter is not currently able to initiate
-	 * fast reset.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define HWRM_FUNC_QCFG_OUTPUT_FLAGS_FAST_RESET_ALLOWED	UINT32_C(0x1000)
+	uint16_t	cmpl_ring;
 	/*
-	 * If set to 1, then multi-root mode is active for this function.
-	 * The NIC is attached to a single host with a single operating
-	 * system, but through two or more PCIe endpoints.
-	 * If set to 0, then multi-root mode is inactive for this function
-	 * or not applicable for this device.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define HWRM_FUNC_QCFG_OUTPUT_FLAGS_MULTI_ROOT		UINT32_C(0x2000)
+	uint16_t	seq_id;
 	/*
-	 * This value is current MAC address configured for this
-	 * function. A value of 00-00-00-00-00-00 indicates no
-	 * MAC address is currently configured.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint8_t	mac_address[6];
+	uint16_t	target_id;
 	/*
-	 * This value is current PCI ID of this
-	 * function. If ARI is enabled, then it is
-	 * Bus Number (8b):Function Number(8b). Otherwise, it is
-	 * Bus Number (8b):Device Number (4b):Function Number(4b).
-	 * If multi-host mode is active, the 4 lsb will indicate
-	 * the PF index for this function.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint16_t	pci_id;
+	uint64_t	resp_addr;
+	uint32_t	enables;
 	/*
-	 * The number of RSS/COS contexts currently
-	 * allocated to the function.
+	 * This bit must be '1' for the vf_id_valid field to be
+	 * configured.
 	 */
-	uint16_t	alloc_rsscos_ctx;
+	#define HWRM_FUNC_RESET_INPUT_ENABLES_VF_ID_VALID	UINT32_C(0x1)
 	/*
-	 * The number of completion rings currently allocated to
-	 * the function. This does not include the rings allocated
-	 * to any children functions if any.
+	 * The ID of the VF that this PF is trying to reset.
+	 * Only the parent PF shall be allowed to reset a child VF.
+	 *
+	 * A parent PF driver shall use this field only when a specific child
+	 * VF is requested to be reset.
 	 */
-	uint16_t	alloc_cmpl_rings;
+	uint16_t	vf_id;
+	/* This value indicates the level of a function reset. */
+	uint8_t	func_reset_level;
 	/*
-	 * The number of transmit rings currently allocated to
-	 * the function. This does not include the rings allocated
-	 * to any children functions if any.
+	 * Reset the caller function and its children VFs (if any). If no
+	 * children functions exist, then reset the caller function only.
 	 */
-	uint16_t	alloc_tx_rings;
+	#define HWRM_FUNC_RESET_INPUT_FUNC_RESET_LEVEL_RESETALL	UINT32_C(0x0)
+	/* Reset the caller function only */
+	#define HWRM_FUNC_RESET_INPUT_FUNC_RESET_LEVEL_RESETME	UINT32_C(0x1)
 	/*
-	 * The number of receive rings currently allocated to
-	 * the function. This does not include the rings allocated
-	 * to any children functions if any.
+	 * Reset all children VFs of the caller function driver if the
+	 * caller is a PF driver.
+	 * It is an error to specify this level by a VF driver.
+	 * It is an error to specify this level by a PF driver with
+	 * no children VFs.
 	 */
-	uint16_t	alloc_rx_rings;
-	/* The allocated number of L2 contexts to the function. */
-	uint16_t	alloc_l2_ctx;
-	/* The allocated number of vnics to the function. */
-	uint16_t	alloc_vnics;
+	#define HWRM_FUNC_RESET_INPUT_FUNC_RESET_LEVEL_RESETCHILDREN UINT32_C(0x2)
 	/*
-	 * The maximum transmission unit of the function.
-	 * If the reported mtu value is non-zero then it will used for the
-	 * rings allocated on this function. otherwise the default
-	 * value is used if ring MTU is not specified.
+	 * Reset a specific VF of the caller function driver if the caller
+	 * is the parent PF driver.
+	 * It is an error to specify this level by a VF driver.
+	 * It is an error to specify this level by a PF driver that is not
+	 * the parent of the VF that is being requested to reset.
 	 */
-	uint16_t	mtu;
+	#define HWRM_FUNC_RESET_INPUT_FUNC_RESET_LEVEL_RESETVF	UINT32_C(0x3)
+	#define HWRM_FUNC_RESET_INPUT_FUNC_RESET_LEVEL_LAST	HWRM_FUNC_RESET_INPUT_FUNC_RESET_LEVEL_RESETVF
+	uint8_t	unused_0;
+} hwrm_func_reset_input_t, *phwrm_func_reset_input_t;
+
+/* hwrm_func_reset_output (size:128b/16B) */
+
+typedef struct hwrm_func_reset_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
 	/*
-	 * The maximum receive unit of the function.
-	 * For vnics allocated on this function, this default
-	 * value is used if vnic MRU is not specified.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	uint16_t	mru;
-	/* The statistics context assigned to a function. */
-	uint16_t	stat_ctx_id;
+	uint8_t	valid;
+} hwrm_func_reset_output_t, *phwrm_func_reset_output_t;
+
+/********************
+ * hwrm_func_getfid *
+ ********************/
+
+
+/* hwrm_func_getfid_input (size:192b/24B) */
+
+typedef struct hwrm_func_getfid_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * The HWRM shall return Unknown value for this field
-	 * when this command is used to query VF's configuration.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint8_t	port_partition_type;
-	/* Single physical function */
-	#define HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_SPF	UINT32_C(0x0)
-	/* Multiple physical functions */
-	#define HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_MPFS	UINT32_C(0x1)
-	/* Network Partitioning 1.0 */
-	#define HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_NPAR1_0 UINT32_C(0x2)
-	/* Network Partitioning 1.5 */
-	#define HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_NPAR1_5 UINT32_C(0x3)
-	/* Network Partitioning 2.0 */
-	#define HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_NPAR2_0 UINT32_C(0x4)
-	/* Network Partitioning 1.2 */
-	#define HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_NPAR1_2 UINT32_C(0x5)
-	/* Unknown */
-	#define HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_UNKNOWN UINT32_C(0xff)
-	#define HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_LAST   HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_UNKNOWN
+	uint16_t	cmpl_ring;
 	/*
-	 * This field will indicate number of physical functions on this port_partition.
-	 * HWRM shall return unavail (i.e. value of 0) for this field
-	 * when this command is used to query VF's configuration or
-	 * from older firmware that doesn't support this field.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint8_t	port_pf_cnt;
-	/* number of PFs is not available */
-	#define HWRM_FUNC_QCFG_OUTPUT_PORT_PF_CNT_UNAVAIL UINT32_C(0x0)
-	#define HWRM_FUNC_QCFG_OUTPUT_PORT_PF_CNT_LAST   HWRM_FUNC_QCFG_OUTPUT_PORT_PF_CNT_UNAVAIL
+	uint16_t	seq_id;
 	/*
-	 * The default VNIC ID assigned to a function that is
-	 * being queried.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint16_t	dflt_vnic_id;
-	uint16_t	max_mtu_configured;
+	uint16_t	target_id;
 	/*
-	 * Minimum guaranteed transmit bandwidth for this function. When
-	 * specified for a PF, does not affect traffic from the PF's child VFs.
-	 * A value of 0 indicates the minimum bandwidth is not configured.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint32_t	min_bw;
-	/* The bandwidth value. */
-	#define HWRM_FUNC_QCFG_OUTPUT_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_FUNC_QCFG_OUTPUT_MIN_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_FUNC_QCFG_OUTPUT_MIN_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_FUNC_QCFG_OUTPUT_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_FUNC_QCFG_OUTPUT_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_FUNC_QCFG_OUTPUT_MIN_BW_SCALE_LAST		HWRM_FUNC_QCFG_OUTPUT_MIN_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_FUNC_QCFG_OUTPUT_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_FUNC_QCFG_OUTPUT_MIN_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_FUNC_QCFG_OUTPUT_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_FUNC_QCFG_OUTPUT_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_FUNC_QCFG_OUTPUT_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_FUNC_QCFG_OUTPUT_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of link bandwidth. */
-		#define HWRM_FUNC_QCFG_OUTPUT_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_FUNC_QCFG_OUTPUT_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_FUNC_QCFG_OUTPUT_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_FUNC_QCFG_OUTPUT_MIN_BW_BW_VALUE_UNIT_INVALID
+	uint64_t	resp_addr;
+	uint32_t	enables;
 	/*
-	 * Maximum transmit rate for this function. When specified for a PF,
-	 * does not affect traffic from the PF's child VFs.
-	 * A value of 0 indicates that the maximum bandwidth is not configured.
+	 * This bit must be '1' for the pci_id field to be
+	 * configured.
 	 */
-	uint32_t	max_bw;
-	/* The bandwidth value. */
-	#define HWRM_FUNC_QCFG_OUTPUT_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_FUNC_QCFG_OUTPUT_MAX_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_FUNC_QCFG_OUTPUT_MAX_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_FUNC_QCFG_OUTPUT_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_FUNC_QCFG_OUTPUT_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_FUNC_QCFG_OUTPUT_MAX_BW_SCALE_LAST		HWRM_FUNC_QCFG_OUTPUT_MAX_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_FUNC_QCFG_OUTPUT_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_FUNC_QCFG_OUTPUT_MAX_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_FUNC_QCFG_OUTPUT_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_FUNC_QCFG_OUTPUT_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_FUNC_QCFG_OUTPUT_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_FUNC_QCFG_OUTPUT_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of link bandwidth. */
-		#define HWRM_FUNC_QCFG_OUTPUT_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_FUNC_QCFG_OUTPUT_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_FUNC_QCFG_OUTPUT_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_FUNC_QCFG_OUTPUT_MAX_BW_BW_VALUE_UNIT_INVALID
+	#define HWRM_FUNC_GETFID_INPUT_ENABLES_PCI_ID	UINT32_C(0x1)
 	/*
-	 * This value indicates the Edge virtual bridge mode for the
-	 * domain that this function belongs to.
+	 * This value is the PCI ID of the queried function.
+	 * If ARI is enabled, then it is
+	 * Bus Number (8b):Function Number(8b). Otherwise, it is
+	 * Bus Number (8b):Device Number (5b):Function Number(3b).
 	 */
-	uint8_t	evb_mode;
-	/* No Edge Virtual Bridging (EVB) */
-	#define HWRM_FUNC_QCFG_OUTPUT_EVB_MODE_NO_EVB UINT32_C(0x0)
-	/* Virtual Ethernet Bridge (VEB) */
-	#define HWRM_FUNC_QCFG_OUTPUT_EVB_MODE_VEB	UINT32_C(0x1)
-	/* Virtual Ethernet Port Aggregator (VEPA) */
-	#define HWRM_FUNC_QCFG_OUTPUT_EVB_MODE_VEPA   UINT32_C(0x2)
-	#define HWRM_FUNC_QCFG_OUTPUT_EVB_MODE_LAST  HWRM_FUNC_QCFG_OUTPUT_EVB_MODE_VEPA
-	uint8_t	options;
+	uint16_t	pci_id;
+	uint8_t	unused_0[2];
+} hwrm_func_getfid_input_t, *phwrm_func_getfid_input_t;
+
+/* hwrm_func_getfid_output (size:128b/16B) */
+
+typedef struct hwrm_func_getfid_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
 	/*
-	 * This value indicates the PCIE device cache line size.
-	 * The cache line size allows the DMA writes to terminate and
-	 * start at the cache boundary.
+	 * FID value. This value is used to identify operations on the PCI
+	 * bus as belonging to a particular PCI function.
 	 */
-	#define HWRM_FUNC_QCFG_OUTPUT_OPTIONS_CACHE_LINESIZE_MASK	UINT32_C(0x3)
-	#define HWRM_FUNC_QCFG_OUTPUT_OPTIONS_CACHE_LINESIZE_SFT	0
-	/* Cache Line Size 64 bytes */
-		#define HWRM_FUNC_QCFG_OUTPUT_OPTIONS_CACHE_LINESIZE_SIZE_64	UINT32_C(0x0)
-	/* Cache Line Size 128 bytes */
-		#define HWRM_FUNC_QCFG_OUTPUT_OPTIONS_CACHE_LINESIZE_SIZE_128	UINT32_C(0x1)
-		#define HWRM_FUNC_QCFG_OUTPUT_OPTIONS_CACHE_LINESIZE_LAST	HWRM_FUNC_QCFG_OUTPUT_OPTIONS_CACHE_LINESIZE_SIZE_128
-	/* This value is the virtual link admin state setting. */
-	#define HWRM_FUNC_QCFG_OUTPUT_OPTIONS_LINK_ADMIN_STATE_MASK	UINT32_C(0xc)
-	#define HWRM_FUNC_QCFG_OUTPUT_OPTIONS_LINK_ADMIN_STATE_SFT	2
-	/* Admin link state is in forced down mode. */
-		#define HWRM_FUNC_QCFG_OUTPUT_OPTIONS_LINK_ADMIN_STATE_FORCED_DOWN  (UINT32_C(0x0) << 2)
-	/* Admin link state is in forced up mode. */
-		#define HWRM_FUNC_QCFG_OUTPUT_OPTIONS_LINK_ADMIN_STATE_FORCED_UP	(UINT32_C(0x1) << 2)
-	/* Admin link state is in auto mode  - follows the physical link state. */
-		#define HWRM_FUNC_QCFG_OUTPUT_OPTIONS_LINK_ADMIN_STATE_AUTO	(UINT32_C(0x2) << 2)
-		#define HWRM_FUNC_QCFG_OUTPUT_OPTIONS_LINK_ADMIN_STATE_LAST	HWRM_FUNC_QCFG_OUTPUT_OPTIONS_LINK_ADMIN_STATE_AUTO
-	/* Reserved for future. */
-	#define HWRM_FUNC_QCFG_OUTPUT_OPTIONS_RSVD_MASK		UINT32_C(0xf0)
-	#define HWRM_FUNC_QCFG_OUTPUT_OPTIONS_RSVD_SFT			4
+	uint16_t	fid;
+	uint8_t	unused_0[5];
 	/*
-	 * The number of VFs that are allocated to the function.
-	 * This is valid only on the PF with SR-IOV enabled.
-	 * 0xFF... (All Fs) if this command is called on a PF with
-	 * SR-IOV disabled or on a VF.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	uint16_t	alloc_vfs;
+	uint8_t	valid;
+} hwrm_func_getfid_output_t, *phwrm_func_getfid_output_t;
+
+/**********************
+ * hwrm_func_vf_alloc *
+ **********************/
+
+
+/* hwrm_func_vf_alloc_input (size:192b/24B) */
+
+typedef struct hwrm_func_vf_alloc_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * The number of allocated multicast filters for this
-	 * function on the RX side.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint32_t	alloc_mcast_filters;
+	uint16_t	cmpl_ring;
 	/*
-	 * The number of allocated HW ring groups for this
-	 * function.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint32_t	alloc_hw_ring_grps;
+	uint16_t	seq_id;
 	/*
-	 * The number of strict priority transmit rings out of
-	 * currently allocated TX rings to the function
-	 * (alloc_tx_rings).
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint16_t	alloc_sp_tx_rings;
+	uint16_t	target_id;
 	/*
-	 * The number of statistics contexts
-	 * currently reserved for the function.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint16_t	alloc_stat_ctx;
+	uint64_t	resp_addr;
+	uint32_t	enables;
 	/*
-	 * This field specifies how many NQs are reserved for the PF.
-	 * Remaining NQs that belong to the PF are available for VFs.
-	 * Once a PF has created VFs, it cannot change how many NQs are
-	 * reserved for itself (since the NQs must be contiguous in HW).
+	 * This bit must be '1' for the first_vf_id field to be
+	 * configured.
 	 */
-	uint16_t	alloc_msix;
+	#define HWRM_FUNC_VF_ALLOC_INPUT_ENABLES_FIRST_VF_ID	UINT32_C(0x1)
 	/*
-	 * The number of registered VF’s associated with the PF. This field
-	 * should be ignored when the request received on the VF interface.
-	 * This field will be updated on the PF interface to initiate
-	 * the unregister request on PF in the HOT Reset Process.
+	 * This value is used to identify a Virtual Function (VF).
+	 * The scope of VF ID is local within a PF.
 	 */
-	uint16_t	registered_vfs;
+	uint16_t	first_vf_id;
+	/* The number of virtual functions requested. */
+	uint16_t	num_vfs;
+} hwrm_func_vf_alloc_input_t, *phwrm_func_vf_alloc_input_t;
+
+/* hwrm_func_vf_alloc_output (size:128b/16B) */
+
+typedef struct hwrm_func_vf_alloc_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* The ID of the first VF allocated. */
+	uint16_t	first_vf_id;
+	uint8_t	unused_0[5];
 	/*
-	 * The size of the doorbell BAR in KBytes reserved for L2 including
-	 * any area that is shared between L2 and RoCE.  The L2 driver
-	 * should only map the L2 portion of the doorbell BAR.  Any rounding
-	 * of the BAR size to the native CPU page size should be performed
-	 * by the driver.  If the value is zero, no special partitioning
-	 * of the doorbell BAR between L2 and RoCE is required.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	uint16_t	l2_doorbell_bar_size_kb;
-	uint8_t	unused_1;
+	uint8_t	valid;
+} hwrm_func_vf_alloc_output_t, *phwrm_func_vf_alloc_output_t;
+
+/*********************
+ * hwrm_func_vf_free *
+ *********************/
+
+
+/* hwrm_func_vf_free_input (size:192b/24B) */
+
+typedef struct hwrm_func_vf_free_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * For backward compatibility this field must be set to 1.
-	 * Older drivers might look for this field to be 1 before
-	 * processing the message.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint8_t	always_1;
+	uint16_t	cmpl_ring;
 	/*
-	 * This GRC address location is used by the Host driver interfaces to poll
-	 * the adapter ready state to re-initiate the registration process again
-	 * after receiving the RESET Notify event.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint32_t	reset_addr_poll;
+	uint16_t	seq_id;
 	/*
-	 * This field specifies legacy L2 doorbell size in KBytes. Drivers should use
-	 * this value to find out the doorbell page offset from the BAR.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint16_t	legacy_l2_db_size_kb;
-	uint16_t	svif_info;
+	uint16_t	target_id;
 	/*
-	 * This field specifies the source virtual interface of the function being
-	 * queried. Drivers can use this to program svif field in the L2 context
-	 * table
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define HWRM_FUNC_QCFG_OUTPUT_SVIF_INFO_SVIF_MASK	UINT32_C(0x7fff)
-	#define HWRM_FUNC_QCFG_OUTPUT_SVIF_INFO_SVIF_SFT	0
-	/* This field specifies whether svif is valid or not */
-	#define HWRM_FUNC_QCFG_OUTPUT_SVIF_INFO_SVIF_VALID	UINT32_C(0x8000)
-	uint8_t	mpc_chnls;
+	uint64_t	resp_addr;
+	uint32_t	enables;
 	/*
-	 * When this bit is '1', it indicates that a MPC channel with
-	 * destination set to the TX crypto engine block is enabled.
+	 * This bit must be '1' for the first_vf_id field to be
+	 * configured.
 	 */
-	#define HWRM_FUNC_QCFG_OUTPUT_MPC_CHNLS_TCE_ENABLED	UINT32_C(0x1)
+	#define HWRM_FUNC_VF_FREE_INPUT_ENABLES_FIRST_VF_ID	UINT32_C(0x1)
 	/*
-	 * When this bit is '1', it indicates that a MPC channel with
-	 * destination set to the RX crypto engine block is enabled.
-	 */
-	#define HWRM_FUNC_QCFG_OUTPUT_MPC_CHNLS_RCE_ENABLED	UINT32_C(0x2)
-	/*
-	 * When this bit is '1', it indicates that a MPC channel with
-	 * destination set to the TX configurable flow processing block is
-	 * enabled.
-	 */
-	#define HWRM_FUNC_QCFG_OUTPUT_MPC_CHNLS_TE_CFA_ENABLED	UINT32_C(0x4)
-	/*
-	 * When this bit is '1', it indicates that a MPC channel with
-	 * destination set to the RX configurable flow processing block is
-	 * enabled.
-	 */
-	#define HWRM_FUNC_QCFG_OUTPUT_MPC_CHNLS_RE_CFA_ENABLED	UINT32_C(0x8)
-	/*
-	 * When this bit is '1', it indicates that a MPC channel with
-	 * destination set to the primate processor block is enabled.
-	 */
-	#define HWRM_FUNC_QCFG_OUTPUT_MPC_CHNLS_PRIMATE_ENABLED	UINT32_C(0x10)
-	uint8_t	unused_2[3];
-	/*
-	 * Minimum guaranteed bandwidth for the network partition made up
-	 * of the caller physical function and all its child virtual
-	 * functions. The rate is specified as a percentage of the bandwidth
-	 * of the link the partition is associated with. A value of 0
-	 * indicates that no minimum bandwidth is configured.
-	 * The format of this field is defined to match min_bw, even though
-	 * the partition minimum rate is always specified as a percentage.
-	 */
-	uint32_t	partition_min_bw;
-	/* The bandwidth value. */
-	#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MIN_BW_BW_VALUE_SFT		0
-	/*
-	 * The granularity of the value (bits or bytes). Firmware never sets
-	 * this field.
-	 */
-	#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MIN_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MIN_BW_SCALE_LAST		HWRM_FUNC_QCFG_OUTPUT_PARTITION_MIN_BW_SCALE_BYTES
-	/* Always percentage of link bandwidth. */
-	#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MIN_BW_BW_VALUE_UNIT_SFT	29
-	/* Bandwidth value is in hundredths of a percent of link bandwidth. */
-		#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-		#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_FUNC_QCFG_OUTPUT_PARTITION_MIN_BW_BW_VALUE_UNIT_PERCENT1_100
-	/*
-	 * The maximum bandwidth that may be used by the network partition
-	 * made up of the caller physical function and all its child virtual
-	 * functions. The rate is specified as a percentage of the bandwidth
-	 * of the link the partition is associated with. A value of 0
-	 * indicates that no maximum bandwidth is configured.
-	 * The format of this field is defined to match max_bw, even though
-	 * the partition bandwidth must be specified as a percentage.
+	 * This value is used to identify a Virtual Function (VF).
+	 * The scope of VF ID is local within a PF.
 	 */
-	uint32_t	partition_max_bw;
-	/* The bandwidth value. */
-	#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MAX_BW_BW_VALUE_SFT		0
+	uint16_t	first_vf_id;
 	/*
-	 * The granularity of the value (bits or bytes). Firmware never sets
-	 * this field.
+	 * The number of virtual functions requested.
+	 * 0xFFFF - Cleanup all children of this PF.
 	 */
-	#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MAX_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MAX_BW_SCALE_LAST		HWRM_FUNC_QCFG_OUTPUT_PARTITION_MAX_BW_SCALE_BYTES
-	/* Always a percentage of link bandwidth. */
-	#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MAX_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in hundredths of a percent of link bandwidth. */
-		#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-		#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_FUNC_QCFG_OUTPUT_PARTITION_MAX_BW_BW_VALUE_UNIT_PERCENT1_100
-	uint8_t	unused_3[3];
+	uint16_t	num_vfs;
+} hwrm_func_vf_free_input_t, *phwrm_func_vf_free_input_t;
+
+/* hwrm_func_vf_free_output (size:128b/16B) */
+
+typedef struct hwrm_func_vf_free_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
 	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_func_qcfg_output_t, *phwrm_func_qcfg_output_t;
+} hwrm_func_vf_free_output_t, *phwrm_func_vf_free_output_t;
 
-/*****************
- * hwrm_func_cfg *
- *****************/
+/********************
+ * hwrm_func_vf_cfg *
+ ********************/
 
 
-/* hwrm_func_cfg_input (size:832b/104B) */
+/* hwrm_func_vf_cfg_input (size:576b/72B) */
 
-typedef struct hwrm_func_cfg_input {
+typedef struct hwrm_func_vf_cfg_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -12230,1117 +14189,1157 @@ typedef struct hwrm_func_cfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
+	uint32_t	enables;
 	/*
-	 * Function ID of the function that is being
+	 * This bit must be '1' for the mtu field to be
 	 * configured.
-	 * If set to 0xFF... (All Fs), then the the configuration is
-	 * for the requesting function.
 	 */
-	uint16_t	fid;
+	#define HWRM_FUNC_VF_CFG_INPUT_ENABLES_MTU			UINT32_C(0x1)
 	/*
-	 * This field specifies how many NQs will be reserved for the PF.
-	 * Remaining NQs that belong to the PF become available for VFs.
-	 * Once a PF has created VFs, it cannot change how many NQs are
-	 * reserved for itself (since the NQs must be contiguous in HW).
+	 * This bit must be '1' for the guest_vlan field to be
+	 * configured.
 	 */
-	uint16_t	num_msix;
-	uint32_t	flags;
+	#define HWRM_FUNC_VF_CFG_INPUT_ENABLES_GUEST_VLAN		UINT32_C(0x2)
 	/*
-	 * When this bit is '1', the function is disabled with
-	 * source MAC address check.
-	 * This is an anti-spoofing check. If this flag is set,
-	 * then the function shall be configured to disallow
-	 * transmission of frames with the source MAC address that
-	 * is configured for this function.
+	 * This bit must be '1' for the async_event_cr field to be
+	 * configured.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_FLAGS_SRC_MAC_ADDR_CHECK_DISABLE	UINT32_C(0x1)
+	#define HWRM_FUNC_VF_CFG_INPUT_ENABLES_ASYNC_EVENT_CR	UINT32_C(0x4)
 	/*
-	 * When this bit is '1', the function is enabled with
-	 * source MAC address check.
-	 * This is an anti-spoofing check. If this flag is set,
-	 * then the function shall be configured to allow
-	 * transmission of frames with the source MAC address that
-	 * is configured for this function.
+	 * This bit must be '1' for the dflt_mac_addr field to be
+	 * configured.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_FLAGS_SRC_MAC_ADDR_CHECK_ENABLE	UINT32_C(0x2)
-	/* reserved. */
-	#define HWRM_FUNC_CFG_INPUT_FLAGS_RSVD_MASK			UINT32_C(0x1fc)
-	#define HWRM_FUNC_CFG_INPUT_FLAGS_RSVD_SFT			2
+	#define HWRM_FUNC_VF_CFG_INPUT_ENABLES_DFLT_MAC_ADDR		UINT32_C(0x8)
 	/*
-	 * Standard TX Ring mode is used for the allocation of TX ring
-	 * and underlying scheduling resources that allow bandwidth
-	 * reservation and limit settings on the queried function.
-	 * If set to 1, then standard TX ring mode is requested to be
-	 * enabled on the function being configured.
+	 * This bit must be '1' for the num_rsscos_ctxs field to be
+	 * configured.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_FLAGS_STD_TX_RING_MODE_ENABLE	UINT32_C(0x200)
+	#define HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_RSSCOS_CTXS	UINT32_C(0x10)
 	/*
-	 * Standard TX Ring mode is used for the allocation of TX ring
-	 * and underlying scheduling resources that allow bandwidth
-	 * reservation and limit settings on the queried function.
-	 * If set to 1, then the standard TX ring mode is requested to
-	 * be disabled on the function being configured. In this extended
-	 * TX ring resource mode, the minimum and maximum bandwidth settings
-	 * are not supported to allow the allocation of TX rings to
-	 * span multiple scheduler nodes.
+	 * This bit must be '1' for the num_cmpl_rings field to be
+	 * configured.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_FLAGS_STD_TX_RING_MODE_DISABLE	UINT32_C(0x400)
+	#define HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_CMPL_RINGS	UINT32_C(0x20)
 	/*
-	 * If this bit is set, virtual mac address configured
-	 * in this command will be persistent over warm boot.
+	 * This bit must be '1' for the num_tx_rings field to be
+	 * configured.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_FLAGS_VIRT_MAC_PERSIST		UINT32_C(0x800)
+	#define HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_TX_RINGS		UINT32_C(0x40)
 	/*
-	 * This bit only applies to the VF. If this bit is set, the statistic
-	 * context counters will not be cleared when the statistic context is freed
-	 * or a function reset is called on VF. This bit will be cleared when the PF
-	 * is unloaded or a function reset is called on the PF.
+	 * This bit must be '1' for the num_rx_rings field to be
+	 * configured.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_FLAGS_NO_AUTOCLEAR_STATISTIC	UINT32_C(0x1000)
+	#define HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_RX_RINGS		UINT32_C(0x80)
+	/*
+	 * This bit must be '1' for the num_l2_ctxs field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_L2_CTXS		UINT32_C(0x100)
+	/*
+	 * This bit must be '1' for the num_vnics field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_VNICS		UINT32_C(0x200)
+	/*
+	 * This bit must be '1' for the num_stat_ctxs field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_STAT_CTXS		UINT32_C(0x400)
+	/*
+	 * This bit must be '1' for the num_hw_ring_grps field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_HW_RING_GRPS	UINT32_C(0x800)
+	/*
+	 * This bit must be '1' for the num_ktls_tx_key_ctxs field to
+	 * be configured.
+	 */
+	#define HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_KTLS_TX_KEY_CTXS	UINT32_C(0x1000)
+	/*
+	 * This bit must be '1' for the num_ktls_rx_key_ctxs field to
+	 * be configured.
+	 */
+	#define HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_KTLS_RX_KEY_CTXS	UINT32_C(0x2000)
+	/*
+	 * This bit must be '1' for the num_quic_tx_key_ctxs field to
+	 * be configured.
+	 */
+	#define HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_QUIC_TX_KEY_CTXS	UINT32_C(0x4000)
+	/*
+	 * This bit must be '1' for the num_quic_rx_key_ctxs field to
+	 * be configured.
+	 */
+	#define HWRM_FUNC_VF_CFG_INPUT_ENABLES_NUM_QUIC_RX_KEY_CTXS	UINT32_C(0x8000)
+	/*
+	 * The maximum transmission unit requested on the function.
+	 * The HWRM should make sure that the mtu of
+	 * the function does not exceed the mtu of the physical
+	 * port that this function is associated with.
+	 *
+	 * In addition to requesting mtu per function, it is
+	 * possible to configure mtu per transmit ring.
+	 * By default, the mtu of each transmit ring associated
+	 * with a function is equal to the mtu of the function.
+	 * The HWRM should make sure that the mtu of each transmit
+	 * ring that is assigned to a function has a valid mtu.
+	 */
+	uint16_t	mtu;
+	/*
+	 * The guest VLAN for the function being configured.
+	 * This field's format is same as 802.1Q Tag's
+	 * Tag Control Information (TCI) format that includes both
+	 * Priority Code Point (PCP) and VLAN Identifier (VID).
+	 */
+	uint16_t	guest_vlan;
+	/*
+	 * ID of the target completion ring for receiving asynchronous
+	 * event completions. If this field is not valid, then the
+	 * HWRM shall use the default completion ring of the function
+	 * that is being configured as the target completion ring for
+	 * providing any asynchronous event completions for that
+	 * function.
+	 * If this field is valid, then the HWRM shall use the
+	 * completion ring identified by this ID as the target
+	 * completion ring for providing any asynchronous event
+	 * completions for the function that is being configured.
+	 */
+	uint16_t	async_event_cr;
+	/*
+	 * This value is the current MAC address requested by the VF
+	 * driver to be configured on this VF. A value of
+	 * 00-00-00-00-00-00 indicates no MAC address configuration
+	 * is requested by the VF driver.
+	 * The parent PF driver may reject or overwrite this
+	 * MAC address.
+	 */
+	uint8_t	dflt_mac_addr[6];
+	uint32_t	flags;
 	/*
 	 * This bit requests that the firmware test to see if all the assets
 	 * requested in this command (i.e. number of TX rings) are available.
 	 * The firmware will return an error if the requested assets are
-	 * not available. The firwmare will NOT reserve the assets if they
+	 * not available. The firmware will NOT reserve the assets if they
 	 * are available.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_FLAGS_TX_ASSETS_TEST		UINT32_C(0x2000)
+	#define HWRM_FUNC_VF_CFG_INPUT_FLAGS_TX_ASSETS_TEST		UINT32_C(0x1)
 	/*
 	 * This bit requests that the firmware test to see if all the assets
 	 * requested in this command (i.e. number of RX rings) are available.
 	 * The firmware will return an error if the requested assets are
-	 * not available. The firwmare will NOT reserve the assets if they
+	 * not available. The firmware will NOT reserve the assets if they
 	 * are available.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_FLAGS_RX_ASSETS_TEST		UINT32_C(0x4000)
+	#define HWRM_FUNC_VF_CFG_INPUT_FLAGS_RX_ASSETS_TEST		UINT32_C(0x2)
 	/*
 	 * This bit requests that the firmware test to see if all the assets
-	 * requested in this command (i.e. number of CMPL rings) are available.
-	 * The firmware will return an error if the requested assets are
-	 * not available. The firwmare will NOT reserve the assets if they
-	 * are available.
+	 * requested in this command (i.e. number of CMPL rings) are
+	 * available. The firmware will return an error if the requested
+	 * assets are not available. The firmware will NOT reserve the assets
+	 * if they are available.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_FLAGS_CMPL_ASSETS_TEST		UINT32_C(0x8000)
+	#define HWRM_FUNC_VF_CFG_INPUT_FLAGS_CMPL_ASSETS_TEST	UINT32_C(0x4)
 	/*
 	 * This bit requests that the firmware test to see if all the assets
 	 * requested in this command (i.e. number of RSS ctx) are available.
 	 * The firmware will return an error if the requested assets are
-	 * not available. The firwmare will NOT reserve the assets if they
+	 * not available. The firmware will NOT reserve the assets if they
 	 * are available.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_FLAGS_RSSCOS_CTX_ASSETS_TEST	UINT32_C(0x10000)
+	#define HWRM_FUNC_VF_CFG_INPUT_FLAGS_RSSCOS_CTX_ASSETS_TEST	UINT32_C(0x8)
 	/*
 	 * This bit requests that the firmware test to see if all the assets
-	 * requested in this command (i.e. number of ring groups) are available.
-	 * The firmware will return an error if the requested assets are
-	 * not available. The firwmare will NOT reserve the assets if they
-	 * are available.
+	 * requested in this command (i.e. number of ring groups) are
+	 * available. The firmware will return an error if the requested
+	 * assets are not available. The firmware will NOT reserve the assets
+	 * if they are available.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_FLAGS_RING_GRP_ASSETS_TEST	UINT32_C(0x20000)
+	#define HWRM_FUNC_VF_CFG_INPUT_FLAGS_RING_GRP_ASSETS_TEST	UINT32_C(0x10)
 	/*
 	 * This bit requests that the firmware test to see if all the assets
 	 * requested in this command (i.e. number of stat ctx) are available.
 	 * The firmware will return an error if the requested assets are
-	 * not available. The firwmare will NOT reserve the assets if they
+	 * not available. The firmware will NOT reserve the assets if they
 	 * are available.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_FLAGS_STAT_CTX_ASSETS_TEST	UINT32_C(0x40000)
+	#define HWRM_FUNC_VF_CFG_INPUT_FLAGS_STAT_CTX_ASSETS_TEST	UINT32_C(0x20)
 	/*
 	 * This bit requests that the firmware test to see if all the assets
 	 * requested in this command (i.e. number of VNICs) are available.
 	 * The firmware will return an error if the requested assets are
-	 * not available. The firwmare will NOT reserve the assets if they
+	 * not available. The firmware will NOT reserve the assets if they
 	 * are available.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_FLAGS_VNIC_ASSETS_TEST		UINT32_C(0x80000)
+	#define HWRM_FUNC_VF_CFG_INPUT_FLAGS_VNIC_ASSETS_TEST	UINT32_C(0x40)
 	/*
 	 * This bit requests that the firmware test to see if all the assets
 	 * requested in this command (i.e. number of L2 ctx) are available.
 	 * The firmware will return an error if the requested assets are
-	 * not available. The firwmare will NOT reserve the assets if they
+	 * not available. The firmware will NOT reserve the assets if they
 	 * are available.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_FLAGS_L2_CTX_ASSETS_TEST		UINT32_C(0x100000)
+	#define HWRM_FUNC_VF_CFG_INPUT_FLAGS_L2_CTX_ASSETS_TEST	UINT32_C(0x80)
 	/*
-	 * This configuration change can be initiated by a PF driver. This
-	 * configuration request shall be targeted to a VF. From local host
-	 * resident HWRM clients, only the parent PF driver shall be allowed
-	 * to initiate this change on one of its children VFs. If this bit is
-	 * set to 1, then the VF that is being configured is requested to be
-	 * trusted.
+	 * If this bit is set to 1, the VF driver is requesting FW to enable
+	 * PPP TX PUSH feature on all the TX rings specified in the
+	 * num_tx_rings field. By default, the PPP TX push feature is
+	 * disabled for all the TX rings of the VF. This flag is ignored if
+	 * the num_tx_rings field is not specified or the VF doesn't support
+	 * PPP tx push feature.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_FLAGS_TRUSTED_VF_ENABLE		UINT32_C(0x200000)
+	#define HWRM_FUNC_VF_CFG_INPUT_FLAGS_PPP_PUSH_MODE_ENABLE	UINT32_C(0x100)
 	/*
-	 * When this bit it set, even if PF reserved pool size is zero,
-	 * FW will allow driver to create TX rings in ring alloc,
-	 * by reserving TX ring, S3 node dynamically.
+	 * If this bit is set to 1, the VF driver is requesting FW to disable
+	 * PPP TX PUSH feature on all the TX rings of the VF. This flag is
+	 * ignored if the VF doesn't support PPP tx push feature.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_FLAGS_DYNAMIC_TX_RING_ALLOC	UINT32_C(0x400000)
+	#define HWRM_FUNC_VF_CFG_INPUT_FLAGS_PPP_PUSH_MODE_DISABLE	UINT32_C(0x200)
+	/* The number of RSS/COS contexts requested for the VF. */
+	uint16_t	num_rsscos_ctxs;
+	/* The number of completion rings requested for the VF. */
+	uint16_t	num_cmpl_rings;
+	/* The number of transmit rings requested for the VF. */
+	uint16_t	num_tx_rings;
+	/* The number of receive rings requested for the VF. */
+	uint16_t	num_rx_rings;
+	/* The number of L2 contexts requested for the VF. */
+	uint16_t	num_l2_ctxs;
+	/* The number of vnics requested for the VF. */
+	uint16_t	num_vnics;
+	/* The number of statistic contexts requested for the VF. */
+	uint16_t	num_stat_ctxs;
+	/* The number of HW ring groups requested for the VF. */
+	uint16_t	num_hw_ring_grps;
+	/* Number of KTLS Tx Key Contexts requested. */
+	uint32_t	num_ktls_tx_key_ctxs;
+	/* Number of KTLS Rx Key Contexts requested. */
+	uint32_t	num_ktls_rx_key_ctxs;
+	/* The number of MSI-X vectors requested for the VF. */
+	uint16_t	num_msix;
+	uint8_t	unused[2];
+	/* Number of QUIC Tx Key Contexts requested. */
+	uint32_t	num_quic_tx_key_ctxs;
+	/* Number of QUIC Rx Key Contexts requested. */
+	uint32_t	num_quic_rx_key_ctxs;
+} hwrm_func_vf_cfg_input_t, *phwrm_func_vf_cfg_input_t;
+
+/* hwrm_func_vf_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_func_vf_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
 	/*
-	 * This bit requests that the firmware test to see if all the assets
-	 * requested in this command (i.e. number of NQ rings) are available.
-	 * The firmware will return an error if the requested assets are
-	 * not available. The firwmare will NOT reserve the assets if they
-	 * are available.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_FLAGS_NQ_ASSETS_TEST		UINT32_C(0x800000)
+	uint8_t	valid;
+} hwrm_func_vf_cfg_output_t, *phwrm_func_vf_cfg_output_t;
+
+/*******************
+ * hwrm_func_qcaps *
+ *******************/
+
+
+/* hwrm_func_qcaps_input (size:192b/24B) */
+
+typedef struct hwrm_func_qcaps_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * This configuration change can be initiated by a PF driver. This
-	 * configuration request shall be targeted to a VF. From local host
-	 * resident HWRM clients, only the parent PF driver shall be allowed
-	 * to initiate this change on one of its children VFs. If this bit is
-	 * set to 1, then the VF that is being configured is requested to be
-	 * untrusted.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_FLAGS_TRUSTED_VF_DISABLE		UINT32_C(0x1000000)
+	uint16_t	cmpl_ring;
 	/*
-	 * This bit is used by preboot drivers on a PF that require access
-	 * to the legacy L2 ring model and legacy 32b doorbells. This
-	 * feature is not allowed on VFs and is only relevant for devices
-	 * that require a context backing store.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_FLAGS_PREBOOT_LEGACY_L2_RINGS	UINT32_C(0x2000000)
+	uint16_t	seq_id;
 	/*
-	 * If this bit is set to 0, then the interface does not support hot
-	 * reset capability which it advertised with the hot_reset_support
-	 * flag in HWRM_FUNC_DRV_RGTR. If any of the function has set this
-	 * flag to 0, adapter cannot do the hot reset. In this state, if the
-	 * firmware receives a hot reset request, firmware must fail the
-	 * request. If this bit is set to 1, then interface is renabling the
-	 * hot reset capability.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define HWRM_FUNC_CFG_INPUT_FLAGS_HOT_RESET_IF_EN_DIS		UINT32_C(0x4000000)
+	uint16_t	target_id;
 	/*
-	 * If this bit is set to 1, the PF driver is requesting FW
-	 * to enable PPP TX PUSH feature on all the TX rings specified in
-	 * the num_tx_rings field. By default, the PPP TX push feature is
-	 * disabled for all the TX rings of the function. This flag is
-	 * ignored if num_tx_rings field is not specified or the function
-	 * doesn't support PPP tx push feature.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_FLAGS_PPP_PUSH_MODE_ENABLE	UINT32_C(0x8000000)
+	uint64_t	resp_addr;
 	/*
-	 * If this bit is set to 1, the PF driver is requesting FW
-	 * to disable PPP TX PUSH feature on all the TX rings specified in
-	 * the num_tx_rings field. This flag is ignored if num_tx_rings
-	 * field is not specified or the function doesn't support PPP tx
-	 * push feature.
+	 * Function ID of the function that is being queried.
+	 * 0xFF... (All Fs) if the query is for the requesting
+	 * function.
+	 * 0xFFFE (REQUESTING_PARENT_FID) This is a special FID
+	 * to be used by a trusted VF to query its parent PF.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_FLAGS_PPP_PUSH_MODE_DISABLE	UINT32_C(0x10000000)
+	uint16_t	fid;
+	uint8_t	unused_0[6];
+} hwrm_func_qcaps_input_t, *phwrm_func_qcaps_input_t;
+
+/* hwrm_func_qcaps_output (size:1088b/136B) */
+
+typedef struct hwrm_func_qcaps_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
 	/*
-	 * If this bit is set to 1, the driver is requesting FW to enable
-	 * the BD_METADATA feature for this function. The FW returns error
-	 * on this request if the TX_METADATA is enabled for this function.
+	 * FID value. This value is used to identify operations on the PCI
+	 * bus as belonging to a particular PCI function.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_FLAGS_BD_METADATA_ENABLE		UINT32_C(0x20000000)
+	uint16_t	fid;
 	/*
-	 * If this bit is set to 1, the driver is requesting FW to disable
-	 * the BD_METADATA feature for this function. The FW returns error
-	 * on this request if the TX_METADATA is enabled for this function.
+	 * Port ID of port that this function is associated with.
+	 * Valid only for the PF.
+	 * 0xFF... (All Fs) if this function is not associated with
+	 * any port.
+	 * 0xFF... (All Fs) if this function is called from a VF.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_FLAGS_BD_METADATA_DISABLE		UINT32_C(0x40000000)
-	uint32_t	enables;
+	uint16_t	port_id;
+	uint32_t	flags;
+	/* If 1, then Push mode is supported on this function. */
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_PUSH_MODE_SUPPORTED		UINT32_C(0x1)
 	/*
-	 * This bit must be '1' for the mtu field to be
-	 * configured.
+	 * If 1, then the global MSI-X auto-masking is enabled for the
+	 * device.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_ENABLES_MTU			UINT32_C(0x1)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_GLOBAL_MSIX_AUTOMASKING		UINT32_C(0x2)
 	/*
-	 * This bit must be '1' for the mru field to be
-	 * configured.
+	 * If 1, then the Precision Time Protocol (PTP) processing
+	 * is supported on this function.
+	 * The HWRM should enable PTP on only a single Physical
+	 * Function (PF) per port.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_ENABLES_MRU			UINT32_C(0x2)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_PTP_SUPPORTED			UINT32_C(0x4)
 	/*
-	 * This bit must be '1' for the num_rsscos_ctxs field to be
-	 * configured.
+	 * If 1, then RDMA over Converged Ethernet (RoCE) v1
+	 * is supported on this function.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_ENABLES_NUM_RSSCOS_CTXS	UINT32_C(0x4)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ROCE_V1_SUPPORTED			UINT32_C(0x8)
 	/*
-	 * This bit must be '1' for the num_cmpl_rings field to be
-	 * configured.
+	 * If 1, then RDMA over Converged Ethernet (RoCE) v2
+	 * is supported on this function.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_ENABLES_NUM_CMPL_RINGS	UINT32_C(0x8)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ROCE_V2_SUPPORTED			UINT32_C(0x10)
 	/*
-	 * This bit must be '1' for the num_tx_rings field to be
-	 * configured.
+	 * If 1, then control and configuration of WoL magic packet
+	 * are supported on this function.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_ENABLES_NUM_TX_RINGS		UINT32_C(0x10)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_WOL_MAGICPKT_SUPPORTED		UINT32_C(0x20)
 	/*
-	 * This bit must be '1' for the num_rx_rings field to be
-	 * configured.
+	 * If 1, then control and configuration of bitmap pattern
+	 * packet are supported on this function.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_ENABLES_NUM_RX_RINGS		UINT32_C(0x20)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_WOL_BMP_SUPPORTED			UINT32_C(0x40)
 	/*
-	 * This bit must be '1' for the num_l2_ctxs field to be
-	 * configured.
+	 * If set to 1, then the control and configuration of rate limit
+	 * of an allocated TX ring on the queried function is supported.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_ENABLES_NUM_L2_CTXS		UINT32_C(0x40)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_TX_RING_RL_SUPPORTED		UINT32_C(0x80)
 	/*
-	 * This bit must be '1' for the num_vnics field to be
-	 * configured.
+	 * If 1, then control and configuration of minimum and
+	 * maximum bandwidths are supported on the queried function.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_ENABLES_NUM_VNICS		UINT32_C(0x80)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_TX_BW_CFG_SUPPORTED		UINT32_C(0x100)
 	/*
-	 * This bit must be '1' for the num_stat_ctxs field to be
-	 * configured.
+	 * If the query is for a VF, then this flag shall be ignored.
+	 * If this query is for a PF and this flag is set to 1,
+	 * then the PF has the capability to set the rate limits
+	 * on the TX rings of its children VFs.
+	 * If this query is for a PF and this flag is set to 0, then
+	 * the PF does not have the capability to set the rate limits
+	 * on the TX rings of its children VFs.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_ENABLES_NUM_STAT_CTXS		UINT32_C(0x100)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_VF_TX_RING_RL_SUPPORTED		UINT32_C(0x200)
 	/*
-	 * This bit must be '1' for the dflt_mac_addr field to be
-	 * configured.
+	 * If the query is for a VF, then this flag shall be ignored.
+	 * If this query is for a PF and this flag is set to 1,
+	 * then the PF has the capability to set the minimum and/or
+	 * maximum bandwidths for its children VFs.
+	 * If this query is for a PF and this flag is set to 0, then
+	 * the PF does not have the capability to set the minimum or
+	 * maximum bandwidths for its children VFs.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_ENABLES_DFLT_MAC_ADDR		UINT32_C(0x200)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_VF_BW_CFG_SUPPORTED		UINT32_C(0x400)
 	/*
-	 * This bit must be '1' for the dflt_vlan field to be
-	 * configured.
-	 */
-	#define HWRM_FUNC_CFG_INPUT_ENABLES_DFLT_VLAN		UINT32_C(0x400)
+	 * Standard TX Ring mode is used for the allocation of TX ring
+	 * and underlying scheduling resources that allow bandwidth
+	 * reservation and limit settings on the queried function.
+	 * If set to 1, then standard TX ring mode is supported
+	 * on the queried function.
+	 * If set to 0, then standard TX ring mode is not available
+	 * on the queried function.
+	 */
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_STD_TX_RING_MODE_SUPPORTED		UINT32_C(0x800)
 	/*
-	 * This bit must be '1' for the dflt_ip_addr field to be
-	 * configured.
+	 * If the query is for a VF, then this flag shall be ignored,
+	 * If this query is for a PF and this flag is set to 1,
+	 * then the PF has the capability to detect GENEVE tunnel
+	 * flags.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_ENABLES_DFLT_IP_ADDR		UINT32_C(0x800)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_GENEVE_TUN_FLAGS_SUPPORTED		UINT32_C(0x1000)
 	/*
-	 * This bit must be '1' for the min_bw field to be
-	 * configured.
+	 * If the query is for a VF, then this flag shall be ignored,
+	 * If this query is for a PF and this flag is set to 1,
+	 * then the PF has the capability to detect NVGRE tunnel
+	 * flags.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_ENABLES_MIN_BW		UINT32_C(0x1000)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_NVGRE_TUN_FLAGS_SUPPORTED		UINT32_C(0x2000)
 	/*
-	 * This bit must be '1' for the max_bw field to be
-	 * configured.
+	 * If the query is for a VF, then this flag shall be ignored,
+	 * If this query is for a PF and this flag is set to 1,
+	 * then the PF has the capability to detect GRE tunnel
+	 * flags.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_ENABLES_MAX_BW		UINT32_C(0x2000)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_GRE_TUN_FLAGS_SUPPORTED		UINT32_C(0x4000)
 	/*
-	 * This bit must be '1' for the async_event_cr field to be
-	 * configured.
+	 * If the query is for a VF, then this flag shall be ignored,
+	 * If this query is for a PF and this flag is set to 1,
+	 * then the PF has the capability to detect MPLS tunnel
+	 * flags.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_ENABLES_ASYNC_EVENT_CR	UINT32_C(0x4000)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_MPLS_TUN_FLAGS_SUPPORTED		UINT32_C(0x8000)
 	/*
-	 * This bit must be '1' for the vlan_antispoof_mode field to be
-	 * configured.
+	 * If the query is for a VF, then this flag shall be ignored,
+	 * If this query is for a PF and this flag is set to 1,
+	 * then the PF has the capability to support pcie stats.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_ENABLES_VLAN_ANTISPOOF_MODE	UINT32_C(0x8000)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_PCIE_STATS_SUPPORTED		UINT32_C(0x10000)
 	/*
-	 * This bit must be '1' for the allowed_vlan_pris field to be
-	 * configured.
+	 * If the query is for a VF, then this flag shall be ignored,
+	 * If this query is for a PF and this flag is set to 1,
+	 * then the PF has the capability to adopt the VF's belonging
+	 * to another PF.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_ENABLES_ALLOWED_VLAN_PRIS	UINT32_C(0x10000)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ADOPTED_PF_SUPPORTED		UINT32_C(0x20000)
 	/*
-	 * This bit must be '1' for the evb_mode field to be
-	 * configured.
+	 * If the query is for a VF, then this flag shall be ignored,
+	 * If this query is for a PF and this flag is set to 1,
+	 * then the PF has the administrative privilege to configure another
+	 * PF.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_ENABLES_EVB_MODE		UINT32_C(0x20000)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ADMIN_PF_SUPPORTED			UINT32_C(0x40000)
 	/*
-	 * This bit must be '1' for the num_mcast_filters field to be
-	 * configured.
+	 * If the query is for a VF, then this flag shall be ignored.
+	 * If this query is for a PF and this flag is set to 1, then
+	 * the PF will know that the firmware has the capability to track
+	 * the virtual link status.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_ENABLES_NUM_MCAST_FILTERS	UINT32_C(0x40000)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_LINK_ADMIN_STATUS_SUPPORTED	UINT32_C(0x80000)
 	/*
-	 * This bit must be '1' for the num_hw_ring_grps field to be
-	 * configured.
+	 * If 1, then this function supports the push mode that uses
+	 * write combine buffers and the long inline tx buffer descriptor.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_ENABLES_NUM_HW_RING_GRPS	UINT32_C(0x80000)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_WCB_PUSH_MODE			UINT32_C(0x100000)
 	/*
-	 * This bit must be '1' for the cache_linesize field to be
-	 * configured.
+	 * If 1, then FW has capability to allocate TX rings dynamically
+	 * in ring alloc even if PF reserved pool is zero.
+	 * This bit will be used only for PFs.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_ENABLES_CACHE_LINESIZE	UINT32_C(0x100000)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_DYNAMIC_TX_RING_ALLOC		UINT32_C(0x200000)
 	/*
-	 * This bit must be '1' for the num_msix field to be
-	 * configured.
+	 * When this bit is '1', it indicates that core firmware is
+	 * capable of Hot Reset.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_ENABLES_NUM_MSIX		UINT32_C(0x200000)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_HOT_RESET_CAPABLE			UINT32_C(0x400000)
 	/*
-	 * This bit must be '1' for the link admin state field to be
-	 * configured.
+	 * This flag will be set to 1 by the FW if FW supports adapter error
+	 * recovery.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_ENABLES_ADMIN_LINK_STATE	UINT32_C(0x400000)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ERROR_RECOVERY_CAPABLE		UINT32_C(0x800000)
 	/*
-	 * This bit must be '1' for the hot_reset_if_en_dis field to be
-	 * configured.
+	 * If the query is for a VF, then this flag shall be ignored.
+	 * If this query is for a PF and this flag is set to 1, then
+	 * the PF has the capability to support extended stats.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_ENABLES_HOT_RESET_IF_SUPPORT	UINT32_C(0x800000)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_STATS_SUPPORTED		UINT32_C(0x1000000)
 	/*
-	 * This bit must be '1' for the schq_id field to be
-	 * configured.
+	 * If the query is for a VF, then this flag shall be ignored.
+	 * If this query is for a PF and this flag is set to 1, then host
+	 * must initiate reset or reload (or fastboot) the firmware image
+	 * upon detection of device shutdown state.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_ENABLES_SCHQ_ID		UINT32_C(0x1000000)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ERR_RECOVER_RELOAD			UINT32_C(0x2000000)
 	/*
-	 * This bit must be '1' for the mpc_chnls field to be
-	 * configured.
+	 * If the query is for a VF, then this flag (always set to 0) shall
+	 * be ignored. If this query is for a PF and this flag is set to 1,
+	 * host, when registered for the default vnic change async event,
+	 * receives async notification whenever a default vnic state is
+	 * changed for any of child or adopted VFs.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_ENABLES_MPC_CHNLS		UINT32_C(0x2000000)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_NOTIFY_VF_DEF_VNIC_CHNG_SUPPORTED	UINT32_C(0x4000000)
+	/* If set to 1, then the vlan acceleration for TX is disabled. */
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_VLAN_ACCELERATION_TX_DISABLED	UINT32_C(0x8000000)
 	/*
-	 * This bit must be '1' for the partition_min_bw field to be
-	 * configured.
+	 * When this bit is '1', it indicates that core firmware supports
+	 * DBG_COREDUMP_XXX commands.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_ENABLES_PARTITION_MIN_BW	UINT32_C(0x4000000)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_COREDUMP_CMD_SUPPORTED		UINT32_C(0x10000000)
 	/*
-	 * This bit must be '1' for the partition_max_bw field to be
-	 * configured.
+	 * When this bit is '1', it indicates that core firmware supports
+	 * DBG_CRASHDUMP_XXX commands.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_ENABLES_PARTITION_MAX_BW	UINT32_C(0x8000000)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_CRASHDUMP_CMD_SUPPORTED		UINT32_C(0x20000000)
 	/*
-	 * This bit must be '1' for the tpid field to be
-	 * configured. This bit is only valid when dflt_vlan enable
-	 * bit is set.
+	 * If the query is for a VF, then this flag should be ignored.
+	 * If the query is for a PF and this flag is set to 1, then
+	 * the PF has the capability to support retrieval of
+	 * rx_port_stats_ext_pfc_wd statistics (supported by the PFC
+	 * WatchDog feature) via the hwrm_port_qstats_ext_pfc_wd command.
+	 * If this flag is set to 1, only that (supported) command should
+	 * be used for retrieval of PFC related statistics (rather than
+	 * hwrm_port_qstats_ext command, which could previously be used).
 	 */
-	#define HWRM_FUNC_CFG_INPUT_ENABLES_TPID			UINT32_C(0x10000000)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_PFC_WD_STATS_SUPPORTED		UINT32_C(0x40000000)
 	/*
-	 * The maximum transmission unit of the function.
-	 * The HWRM should make sure that the mtu of
-	 * the function does not exceed the mtu of the physical
-	 * port that this function is associated with.
-	 *
-	 * In addition to configuring mtu per function, it is
-	 * possible to configure mtu per transmit ring.
-	 * By default, the mtu of each transmit ring associated
-	 * with a function is equal to the mtu of the function.
-	 * The HWRM should make sure that the mtu of each transmit
-	 * ring that is assigned to a function has a valid mtu.
+	 * When this bit is '1', it indicates that core firmware supports
+	 * DBG_QCAPS command
 	 */
-	uint16_t	mtu;
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_DBG_QCAPS_CMD_SUPPORTED		UINT32_C(0x80000000)
 	/*
-	 * The maximum receive unit of the function.
-	 * The HWRM should make sure that the mru of
-	 * the function does not exceed the mru of the physical
-	 * port that this function is associated with.
-	 *
-	 * In addition to configuring mru per function, it is
-	 * possible to configure mru per vnic.
-	 * By default, the mru of each vnic associated
-	 * with a function is equal to the mru of the function.
-	 * The HWRM should make sure that the mru of each vnic
-	 * that is assigned to a function has a valid mru.
+	 * This value is current MAC address configured for this
+	 * function. A value of 00-00-00-00-00-00 indicates no
+	 * MAC address is currently configured.
 	 */
-	uint16_t	mru;
+	uint8_t	mac_address[6];
 	/*
-	 * The number of RSS/COS contexts requested for the
-	 * function.
+	 * The maximum number of RSS/COS contexts that can be
+	 * allocated to the function.
 	 */
-	uint16_t	num_rsscos_ctxs;
+	uint16_t	max_rsscos_ctx;
 	/*
-	 * The number of completion rings requested for the
-	 * function. This does not include the rings allocated
-	 * to any children functions if any.
+	 * The maximum number of completion rings that can be
+	 * allocated to the function.
 	 */
-	uint16_t	num_cmpl_rings;
+	uint16_t	max_cmpl_rings;
 	/*
-	 * The number of transmit rings requested for the function.
-	 * This does not include the rings allocated to any
-	 * children functions if any.
+	 * The maximum number of transmit rings that can be
+	 * allocated to the function.
 	 */
-	uint16_t	num_tx_rings;
+	uint16_t	max_tx_rings;
 	/*
-	 * The number of receive rings requested for the function.
-	 * This does not include the rings allocated
-	 * to any children functions if any.
+	 * The maximum number of receive rings that can be
+	 * allocated to the function.
 	 */
-	uint16_t	num_rx_rings;
-	/* The requested number of L2 contexts for the function. */
-	uint16_t	num_l2_ctxs;
-	/* The requested number of vnics for the function. */
-	uint16_t	num_vnics;
-	/* The requested number of statistic contexts for the function. */
-	uint16_t	num_stat_ctxs;
+	uint16_t	max_rx_rings;
 	/*
-	 * The number of HW ring groups that should
-	 * be reserved for this function.
+	 * The maximum number of L2 contexts that can be
+	 * allocated to the function.
 	 */
-	uint16_t	num_hw_ring_grps;
-	/* The default MAC address for the function being configured. */
-	uint8_t	dflt_mac_addr[6];
+	uint16_t	max_l2_ctxs;
 	/*
-	 * The default VLAN for the function being configured.
-	 * This field's format is same as 802.1Q Tag's
-	 * Tag Control Information (TCI) format that includes both
-	 * Priority Code Point (PCP) and VLAN Identifier (VID).
+	 * The maximum number of VNICs that can be
+	 * allocated to the function.
 	 */
-	uint16_t	dflt_vlan;
+	uint16_t	max_vnics;
 	/*
-	 * The default IP address for the function being configured.
-	 * This address is only used in enabling source property check.
+	 * The identifier for the first VF enabled on a PF. This
+	 * is valid only on the PF with SR-IOV enabled.
+	 * 0xFF... (All Fs) if this command is called on a PF with
+	 * SR-IOV disabled or on a VF.
 	 */
-	uint32_t	dflt_ip_addr[4];
+	uint16_t	first_vf_id;
 	/*
-	 * Minimum guaranteed transmit bandwidth for this function. When
-	 * specified for a PF, does not affect traffic from the PF's child VFs.
-	 * A value of 0 indicates the minimum bandwidth is not configured.
+	 * The maximum number of VFs that can be
+	 * allocated to the function. This is valid only on the
+	 * PF with SR-IOV enabled. 0xFF... (All Fs) if this
+	 * command is called on a PF with SR-IOV disabled or
+	 * on a VF.
 	 */
-	uint32_t	min_bw;
-	/* The bandwidth value. */
-	#define HWRM_FUNC_CFG_INPUT_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_FUNC_CFG_INPUT_MIN_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_FUNC_CFG_INPUT_MIN_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_FUNC_CFG_INPUT_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_FUNC_CFG_INPUT_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_FUNC_CFG_INPUT_MIN_BW_SCALE_LAST		HWRM_FUNC_CFG_INPUT_MIN_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_FUNC_CFG_INPUT_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_FUNC_CFG_INPUT_MIN_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_FUNC_CFG_INPUT_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_FUNC_CFG_INPUT_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_FUNC_CFG_INPUT_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_FUNC_CFG_INPUT_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_FUNC_CFG_INPUT_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_FUNC_CFG_INPUT_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_FUNC_CFG_INPUT_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_FUNC_CFG_INPUT_MIN_BW_BW_VALUE_UNIT_INVALID
+	uint16_t	max_vfs;
 	/*
-	 * Maximum transmit rate for this function. When specified for a PF,
-	 * does not affect traffic from the PF's child VFs.
-	 * A value of 0 indicates that the maximum bandwidth is not configured.
+	 * The maximum number of statistic contexts that can be
+	 * allocated to the function.
 	 */
-	uint32_t	max_bw;
-	/* The bandwidth value. */
-	#define HWRM_FUNC_CFG_INPUT_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_FUNC_CFG_INPUT_MAX_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_FUNC_CFG_INPUT_MAX_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_FUNC_CFG_INPUT_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_FUNC_CFG_INPUT_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_FUNC_CFG_INPUT_MAX_BW_SCALE_LAST		HWRM_FUNC_CFG_INPUT_MAX_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_FUNC_CFG_INPUT_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_FUNC_CFG_INPUT_MAX_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_FUNC_CFG_INPUT_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_FUNC_CFG_INPUT_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_FUNC_CFG_INPUT_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_FUNC_CFG_INPUT_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_FUNC_CFG_INPUT_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_FUNC_CFG_INPUT_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_FUNC_CFG_INPUT_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_FUNC_CFG_INPUT_MAX_BW_BW_VALUE_UNIT_INVALID
+	uint16_t	max_stat_ctx;
 	/*
-	 * ID of the target completion ring for receiving asynchronous
-	 * event completions. If this field is not valid, then the
-	 * HWRM shall use the default completion ring of the function
-	 * that is being configured as the target completion ring for
-	 * providing any asynchronous event completions for that
-	 * function.
-	 * If this field is valid, then the HWRM shall use the
-	 * completion ring identified by this ID as the target
-	 * completion ring for providing any asynchronous event
-	 * completions for the function that is being configured.
+	 * The maximum number of Encapsulation records that can be
+	 * offloaded by this function.
 	 */
-	uint16_t	async_event_cr;
-	/* VLAN Anti-spoofing mode. */
-	uint8_t	vlan_antispoof_mode;
-	/* No VLAN anti-spoofing checks are enabled */
-	#define HWRM_FUNC_CFG_INPUT_VLAN_ANTISPOOF_MODE_NOCHECK		UINT32_C(0x0)
-	/* Validate VLAN against the configured VLAN(s) */
-	#define HWRM_FUNC_CFG_INPUT_VLAN_ANTISPOOF_MODE_VALIDATE_VLAN	UINT32_C(0x1)
-	/* Insert VLAN if it does not exist, otherwise discard */
-	#define HWRM_FUNC_CFG_INPUT_VLAN_ANTISPOOF_MODE_INSERT_IF_VLANDNE	UINT32_C(0x2)
-	/* Insert VLAN if it does not exist, override VLAN if it exists */
-	#define HWRM_FUNC_CFG_INPUT_VLAN_ANTISPOOF_MODE_INSERT_OR_OVERRIDE_VLAN UINT32_C(0x3)
-	#define HWRM_FUNC_CFG_INPUT_VLAN_ANTISPOOF_MODE_LAST		HWRM_FUNC_CFG_INPUT_VLAN_ANTISPOOF_MODE_INSERT_OR_OVERRIDE_VLAN
+	uint32_t	max_encap_records;
 	/*
-	 * This bit field defines VLAN PRIs that are allowed on
-	 * this function.
-	 * If nth bit is set, then VLAN PRI n is allowed on this
-	 * function.
+	 * The maximum number of decapsulation records that can
+	 * be offloaded by this function.
 	 */
-	uint8_t	allowed_vlan_pris;
+	uint32_t	max_decap_records;
 	/*
-	 * The evb_mode is configured on a per port basis. The default evb_mode
-	 * is configured based on the NVM EVB mode setting upon firmware
-	 * initialization. The HWRM allows a PF driver to change EVB mode for a
-	 * port used by the PF only when one of the following conditions is
-	 * satisfied.
-	 * 1. The current operating mode is single function mode.
-	 *	(ie. one PF per port)
-	 * 2. For SmartNIC, any one of the PAXC PFs is permitted to change the
-	 *	EVB mode of the port used by the PAXC PF. None of the X86 PFs
-	 *	should have privileges.
-	 * The HWRM doesn't permit any PFs to change the underlying EVB mode
-	 * when running as MHB or NPAR mode in performance NIC configuration.
-	 * The HWRM doesn't permit a VF driver to change the EVB mode.
-	 * Once the HWRM determines a function doesn't meet the conditions
-	 * to configure the EVB mode, it sets the evb_mode_cfg_not_supported
-	 * flag in HWRM_FUNC_QCAPS command response for the function.
-	 * The HWRM takes into account the switching of EVB mode from one to
-	 * another and reconfigure hardware resources as reqiured. The
-	 * switching from VEB to VEPA mode requires the disabling of the
-	 * loopback traffic. Additionally, source knockouts are handled
-	 * differently in VEB and VEPA modes.
+	 * The maximum number of Exact Match (EM) flows that can be
+	 * offloaded by this function on the TX side.
 	 */
-	uint8_t	evb_mode;
-	/* No Edge Virtual Bridging (EVB) */
-	#define HWRM_FUNC_CFG_INPUT_EVB_MODE_NO_EVB UINT32_C(0x0)
-	/* Virtual Ethernet Bridge (VEB) */
-	#define HWRM_FUNC_CFG_INPUT_EVB_MODE_VEB	UINT32_C(0x1)
-	/* Virtual Ethernet Port Aggregator (VEPA) */
-	#define HWRM_FUNC_CFG_INPUT_EVB_MODE_VEPA   UINT32_C(0x2)
-	#define HWRM_FUNC_CFG_INPUT_EVB_MODE_LAST  HWRM_FUNC_CFG_INPUT_EVB_MODE_VEPA
-	uint8_t	options;
+	uint32_t	max_tx_em_flows;
 	/*
-	 * This value indicates the PCIE device cache line size.
-	 * The cache line size allows the DMA writes to terminate and
-	 * start at the cache boundary.
+	 * The maximum number of Wildcard Match (WM) flows that can
+	 * be offloaded by this function on the TX side.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_OPTIONS_CACHE_LINESIZE_MASK	UINT32_C(0x3)
-	#define HWRM_FUNC_CFG_INPUT_OPTIONS_CACHE_LINESIZE_SFT	0
-	/* Cache Line Size 64 bytes */
-		#define HWRM_FUNC_CFG_INPUT_OPTIONS_CACHE_LINESIZE_SIZE_64	UINT32_C(0x0)
-	/* Cache Line Size 128 bytes */
-		#define HWRM_FUNC_CFG_INPUT_OPTIONS_CACHE_LINESIZE_SIZE_128	UINT32_C(0x1)
-		#define HWRM_FUNC_CFG_INPUT_OPTIONS_CACHE_LINESIZE_LAST	HWRM_FUNC_CFG_INPUT_OPTIONS_CACHE_LINESIZE_SIZE_128
-	/* This value is the virtual link admin state setting. */
-	#define HWRM_FUNC_CFG_INPUT_OPTIONS_LINK_ADMIN_STATE_MASK	UINT32_C(0xc)
-	#define HWRM_FUNC_CFG_INPUT_OPTIONS_LINK_ADMIN_STATE_SFT	2
-	/* Admin state is forced down. */
-		#define HWRM_FUNC_CFG_INPUT_OPTIONS_LINK_ADMIN_STATE_FORCED_DOWN  (UINT32_C(0x0) << 2)
-	/* Admin state is forced up. */
-		#define HWRM_FUNC_CFG_INPUT_OPTIONS_LINK_ADMIN_STATE_FORCED_UP	(UINT32_C(0x1) << 2)
-	/* Admin state is in auto mode - is to follow the physical link state. */
-		#define HWRM_FUNC_CFG_INPUT_OPTIONS_LINK_ADMIN_STATE_AUTO	(UINT32_C(0x2) << 2)
-		#define HWRM_FUNC_CFG_INPUT_OPTIONS_LINK_ADMIN_STATE_LAST	HWRM_FUNC_CFG_INPUT_OPTIONS_LINK_ADMIN_STATE_AUTO
-	/* Reserved for future. */
-	#define HWRM_FUNC_CFG_INPUT_OPTIONS_RSVD_MASK		UINT32_C(0xf0)
-	#define HWRM_FUNC_CFG_INPUT_OPTIONS_RSVD_SFT			4
+	uint32_t	max_tx_wm_flows;
 	/*
-	 * The number of multicast filters that should
-	 * be reserved for this function on the RX side.
+	 * The maximum number of Exact Match (EM) flows that can be
+	 * offloaded by this function on the RX side.
 	 */
-	uint16_t	num_mcast_filters;
-	/* Used by a PF driver to associate a SCHQ with a VF. */
-	uint16_t	schq_id;
-	uint16_t	mpc_chnls;
+	uint32_t	max_rx_em_flows;
 	/*
-	 * When this bit is '1', the caller requests to enable a MPC
-	 * channel with destination to the TX crypto engine block.
-	 * When this bit is ‘0’, this flag has no effect.
+	 * The maximum number of Wildcard Match (WM) flows that can
+	 * be offloaded by this function on the RX side.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_MPC_CHNLS_TCE_ENABLE	UINT32_C(0x1)
+	uint32_t	max_rx_wm_flows;
 	/*
-	 * When this bit is '1', the caller requests to disable a MPC
-	 * channel with destination to the TX crypto engine block.
-	 * When this bit is ‘0’, this flag has no effect.
+	 * The maximum number of multicast filters that can
+	 * be supported by this function on the RX side.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_MPC_CHNLS_TCE_DISABLE	UINT32_C(0x2)
+	uint32_t	max_mcast_filters;
 	/*
-	 * When this bit is '1', the caller requests to enable a MPC
-	 * channel with destination to the RX crypto engine block.
-	 * When this bit is ‘0’, this flag has no effect.
+	 * The maximum value of flow_id that can be supported
+	 * in completion records.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_MPC_CHNLS_RCE_ENABLE	UINT32_C(0x4)
+	uint32_t	max_flow_id;
 	/*
-	 * When this bit is '1', the caller requests to disable a MPC
-	 * channel with destination to the RX crypto engine block.
-	 * When this bit is ‘0’, this flag has no effect.
+	 * The maximum number of HW ring groups that can be
+	 * supported on this function.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_MPC_CHNLS_RCE_DISABLE	UINT32_C(0x8)
+	uint32_t	max_hw_ring_grps;
 	/*
-	 * When this bit is '1', the caller requests to enable a MPC
-	 * channel with destination to the TX configurable flow processing
-	 * block. When this bit is ‘0’, this flag has no effect.
+	 * The maximum number of strict priority transmit rings
+	 * that can be allocated to the function.
+	 * This number indicates the maximum number of TX rings
+	 * that can be assigned strict priorities out of the
+	 * maximum number of TX rings that can be allocated
+	 * (max_tx_rings) to the function.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_MPC_CHNLS_TE_CFA_ENABLE	UINT32_C(0x10)
+	uint16_t	max_sp_tx_rings;
 	/*
-	 * When this bit is '1', the caller requests to disable a MPC
-	 * channel with destination to the TX configurable flow processing
-	 * block block. When this bit is ‘0’, this flag has no effect.
+	 * The maximum number of MSI-X vectors that may be allocated across
+	 * all VFs for the function. This is valid only on the PF with SR-IOV
+	 * enabled. Returns zero if this command is called on a PF with
+	 * SR-IOV disabled or on a VF.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_MPC_CHNLS_TE_CFA_DISABLE	UINT32_C(0x20)
+	uint16_t	max_msix_vfs;
+	uint32_t	flags_ext;
 	/*
-	 * When this bit is '1', the caller requests to enable a MPC
-	 * channel with destination to the RX configurable flow processing
-	 * block. When this bit is ‘0’, this flag has no effect.
+	 * If 1, the device can be configured to set the ECN bits in the
+	 * IP header of received packets if the receive queue length
+	 * exceeds a given threshold.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_MPC_CHNLS_RE_CFA_ENABLE	UINT32_C(0x40)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_ECN_MARK_SUPPORTED			UINT32_C(0x1)
 	/*
-	 * When this bit is '1', the caller requests to disable a MPC
-	 * channel with destination to the RX configurable flow processing
-	 * block block. When this bit is ‘0’, this flag has no effect.
+	 * If 1, the device can report the number of received packets
+	 * that it marked as having experienced congestion.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_MPC_CHNLS_RE_CFA_DISABLE	UINT32_C(0x80)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_ECN_STATS_SUPPORTED			UINT32_C(0x2)
 	/*
-	 * When this bit is '1', the caller requests to enable a MPC
-	 * channel with destination to the primate processor block.
-	 * When this bit is ‘0’, this flag has no effect.
+	 * If 1, the device can report extended hw statistics (including
+	 * additional tpa statistics).
 	 */
-	#define HWRM_FUNC_CFG_INPUT_MPC_CHNLS_PRIMATE_ENABLE	UINT32_C(0x100)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_EXT_HW_STATS_SUPPORTED			UINT32_C(0x4)
 	/*
-	 * When this bit is '1', the caller requests to disable a MPC
-	 * channel with destination to the primate processor block.
-	 * When this bit is ‘0’, this flag has no effect.
+	 * If set to 1, then the core firmware has support to enable/
+	 * disable hot reset support for interface dynamically through
+	 * HWRM_FUNC_CFG.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_MPC_CHNLS_PRIMATE_DISABLE	UINT32_C(0x200)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_HOT_RESET_IF_SUPPORT			UINT32_C(0x8)
+	/* If 1, the proxy mode is supported on this function */
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_PROXY_MODE_SUPPORT			UINT32_C(0x10)
 	/*
-	 * Minimum guaranteed bandwidth for the network partition made up
-	 * of the caller physical function and all its child virtual
-	 * functions. The rate is specified as a percentage of the bandwidth
-	 * of the link the partition is associated with. A value of 0
-	 * indicates that no minimum bandwidth is configured. The sum of the
-	 * minimum bandwidths for all partitions on a link must not exceed
-	 * 100%.
-	 * The format of this field is defined to match min_bw, even though
-	 * it does not allow all the options for min_bw at this time.
+	 * If 1, the tx rings source interface override feature is supported
+	 * on this function.
 	 */
-	uint32_t	partition_min_bw;
-	/* The bandwidth value. */
-	#define HWRM_FUNC_CFG_INPUT_PARTITION_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_FUNC_CFG_INPUT_PARTITION_MIN_BW_BW_VALUE_SFT		0
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_TX_PROXY_SRC_INTF_OVERRIDE_SUPPORT	UINT32_C(0x20)
 	/*
-	 * The granularity of the value (bits or bytes). Firmware ignores
-	 * this field.
+	 * If 1, the device supports scheduler queues. SCHQs can be managed
+	 * using RING_SCHQ_ALLOC/CFG/FREE commands.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_PARTITION_MIN_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_FUNC_CFG_INPUT_PARTITION_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_FUNC_CFG_INPUT_PARTITION_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_FUNC_CFG_INPUT_PARTITION_MIN_BW_SCALE_LAST		HWRM_FUNC_CFG_INPUT_PARTITION_MIN_BW_SCALE_BYTES
-	/* Bandwidth units. Must be set to percent1_100. */
-	#define HWRM_FUNC_CFG_INPUT_PARTITION_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_FUNC_CFG_INPUT_PARTITION_MIN_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in hundredths of a percent of link bandwidth. */
-		#define HWRM_FUNC_CFG_INPUT_PARTITION_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-		#define HWRM_FUNC_CFG_INPUT_PARTITION_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_FUNC_CFG_INPUT_PARTITION_MIN_BW_BW_VALUE_UNIT_PERCENT1_100
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_SCHQ_SUPPORTED				UINT32_C(0x40)
 	/*
-	 * The maximum bandwidth that may be used by the network partition
-	 * made up of the caller physical function and all its child virtual
-	 * functions. The rate is specified as a percentage of the bandwidth
-	 * of the link the partition is associated with. A value of 0
-	 * indicates that no maximum bandwidth is configured.
-	 * The format of this field is defined to match max_bw, even though it
-	 * does not allow all the options for max_bw at this time.
+	 * If set to 1, then this function supports the TX push mode that
+	 * uses ping-pong buffers from the push pages.
 	 */
-	uint32_t	partition_max_bw;
-	/* The bandwidth value. */
-	#define HWRM_FUNC_CFG_INPUT_PARTITION_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_FUNC_CFG_INPUT_PARTITION_MAX_BW_BW_VALUE_SFT		0
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_PPP_PUSH_MODE_SUPPORTED			UINT32_C(0x80)
 	/*
-	 * The granularity of the value (bits or bytes). Firmware ignores
-	 * this field.
+	 * If set to 1, then this function doesn't have the privilege to
+	 * configure the EVB mode of the port it uses.
 	 */
-	#define HWRM_FUNC_CFG_INPUT_PARTITION_MAX_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_FUNC_CFG_INPUT_PARTITION_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_FUNC_CFG_INPUT_PARTITION_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_FUNC_CFG_INPUT_PARTITION_MAX_BW_SCALE_LAST		HWRM_FUNC_CFG_INPUT_PARTITION_MAX_BW_SCALE_BYTES
-	/* Bandwidth units. Must be set to percent1_100. */
-	#define HWRM_FUNC_CFG_INPUT_PARTITION_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_FUNC_CFG_INPUT_PARTITION_MAX_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in hundredths of a percent of link bandwidth. */
-		#define HWRM_FUNC_CFG_INPUT_PARTITION_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-		#define HWRM_FUNC_CFG_INPUT_PARTITION_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_FUNC_CFG_INPUT_PARTITION_MAX_BW_BW_VALUE_UNIT_PERCENT1_100
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_EVB_MODE_CFG_NOT_SUPPORTED		UINT32_C(0x100)
 	/*
-	 * The TPID for the function for which default VLAN
-	 * is configured. If the dflt_vlan is not specified
-	 * with the TPID, FW returns error. If the TPID is
-	 * not specified with dflt_vlan, the default TPID of
-	 * 0x8100 will be used. This field is specified in
-	 * network byte order.
+	 * If set to 1, then the HW and FW support the SoC packet DMA
+	 * datapath between SoC and NIC. This function can act as the
+	 * HWRM communication transport agent on behalf of the SoC SPD
+	 * software module. This capability is only advertised to the
+	 * SoC PFs.
 	 */
-	uint16_t	tpid;
-	uint8_t	unused_0[2];
-} hwrm_func_cfg_input_t, *phwrm_func_cfg_input_t;
-
-/* hwrm_func_cfg_output (size:128b/16B) */
-
-typedef struct hwrm_func_cfg_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_SOC_SPD_SUPPORTED			UINT32_C(0x200)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * If set to 1, then this function supports FW_LIVEPATCH for
+	 * firmware livepatch commands.
 	 */
-	uint8_t	valid;
-} hwrm_func_cfg_output_t, *phwrm_func_cfg_output_t;
-
-/********************
- * hwrm_func_qstats *
- ********************/
-
-
-/* hwrm_func_qstats_input (size:192b/24B) */
-
-typedef struct hwrm_func_qstats_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_FW_LIVEPATCH_SUPPORTED			UINT32_C(0x400)
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * When this bit is '1', it indicates that core firmware is
+	 * capable of fast Reset.
 	 */
-	uint16_t	cmpl_ring;
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_FAST_RESET_CAPABLE			UINT32_C(0x800)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * When this bit is '1', it indicates that firmware and hardware
+	 * are capable of updating tx_metadata via hwrm_ring_cfg command.
 	 */
-	uint16_t	seq_id;
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_TX_METADATA_CFG_CAPABLE			UINT32_C(0x1000)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * If set to 1, then the device can report the action
+	 * needed to activate set nvm options.
 	 */
-	uint16_t	target_id;
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_NVM_OPTION_ACTION_SUPPORTED		UINT32_C(0x2000)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * When this bit is '1', it indicates that the BD metadata feature
+	 * is supported for this function.
 	 */
-	uint64_t	resp_addr;
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_BD_METADATA_SUPPORTED			UINT32_C(0x4000)
 	/*
-	 * Function ID of the function that is being queried.
-	 * 0xFF... (All Fs) if the query is for the requesting
-	 * function.
-	 * A privileged PF can query for other function's statistics.
+	 * When this bit is '1', it indicates that the echo request feature
+	 * is supported for this function. If the driver registers for the
+	 * echo request asynchronous event, then the firmware can send an
+	 * unsolicited echo request to the driver and expect an echo
+	 * response.
 	 */
-	uint16_t	fid;
-	/* This flags indicates the type of statistics request. */
-	uint8_t	flags;
-	/* This value is not used to avoid backward compatibility issues. */
-	#define HWRM_FUNC_QSTATS_INPUT_FLAGS_UNUSED	UINT32_C(0x0)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_ECHO_REQUEST_SUPPORTED			UINT32_C(0x8000)
 	/*
-	 * flags should be set to 1 when request is for only RoCE statistics.
-	 * This will be honored only if the caller_fid is a privileged PF.
-	 * In all other cases FID and caller_fid should be the same.
+	 * When this bit is '1', it indicates that core firmware supports
+	 * NPAR 1.2 on this function.
 	 */
-	#define HWRM_FUNC_QSTATS_INPUT_FLAGS_ROCE_ONLY	UINT32_C(0x1)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_NPAR_1_2_SUPPORTED			UINT32_C(0x10000)
+	/* When this bit is '1', it indicates that PTM feature is supported. */
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_PTP_PTM_SUPPORTED			UINT32_C(0x20000)
+	/* When this bit is '1', it indicates that PPS feature is supported. */
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_PTP_PPS_SUPPORTED			UINT32_C(0x40000)
 	/*
-	 * flags should be set to 2 when request is for the counter mask,
-	 * representing the width of each of the stats counters, rather
-	 * than counters themselves.
+	 * When this bit is '1', it indicates that VF config. change
+	 * async event is supported on the parent PF if the async.
+	 * event is registered by the PF.
 	 */
-	#define HWRM_FUNC_QSTATS_INPUT_FLAGS_COUNTER_MASK UINT32_C(0x2)
-	#define HWRM_FUNC_QSTATS_INPUT_FLAGS_LAST	HWRM_FUNC_QSTATS_INPUT_FLAGS_COUNTER_MASK
-	uint8_t	unused_0[5];
-} hwrm_func_qstats_input_t, *phwrm_func_qstats_input_t;
-
-/* hwrm_func_qstats_output (size:1408b/176B) */
-
-typedef struct hwrm_func_qstats_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Number of transmitted unicast packets on the function. */
-	uint64_t	tx_ucast_pkts;
-	/* Number of transmitted multicast packets on the function. */
-	uint64_t	tx_mcast_pkts;
-	/* Number of transmitted broadcast packets on the function. */
-	uint64_t	tx_bcast_pkts;
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_VF_CFG_ASYNC_FOR_PF_SUPPORTED		UINT32_C(0x80000)
 	/*
-	 * Number of transmitted packets that were discarded due to
-	 * internal NIC resource problems.  For transmit, this
-	 * can only happen if TMP is configured to allow dropping
-	 * in HOL blocking conditions, which is not a normal
-	 * configuration.
+	 * When this bit is '1', the NIC supports configuration of
+	 * partition_min_bw and partition_max_bw. Configuration of a
+	 * minimum guaranteed bandwidth is only supported if the
+	 * min_bw_supported flag is also set.
 	 */
-	uint64_t	tx_discard_pkts;
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_PARTITION_BW_SUPPORTED			UINT32_C(0x100000)
 	/*
-	 * Number of dropped packets on transmit path on the function.
-	 * These are packets that have been marked for drop by
-	 * the TE CFA block or are packets that exceeded the
-	 * transmit MTU limit for the function.
+	 * When this bit is '1', the FW supports configuration of
+	 * PCP and TPID values of the default VLAN.
 	 */
-	uint64_t	tx_drop_pkts;
-	/* Number of transmitted bytes for unicast traffic on the function. */
-	uint64_t	tx_ucast_bytes;
-	/* Number of transmitted bytes for multicast traffic on the function. */
-	uint64_t	tx_mcast_bytes;
-	/* Number of transmitted bytes for broadcast traffic on the function. */
-	uint64_t	tx_bcast_bytes;
-	/* Number of received unicast packets on the function. */
-	uint64_t	rx_ucast_pkts;
-	/* Number of received multicast packets on the function. */
-	uint64_t	rx_mcast_pkts;
-	/* Number of received broadcast packets on the function. */
-	uint64_t	rx_bcast_pkts;
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_DFLT_VLAN_TPID_PCP_SUPPORTED		UINT32_C(0x200000)
+	/* When this bit is '1', it indicates that HW and FW support KTLS. */
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_KTLS_SUPPORTED				UINT32_C(0x400000)
 	/*
-	 * Number of received packets that were discarded on the function
-	 * due to resource limitations.  This can happen for 3 reasons.
-	 * # The BD used for the packet has a bad format.
-	 * # There were no BDs available in the ring for the packet.
-	 * # There were no BDs available on-chip for the packet.
+	 * When this bit is '1', the firmware supports HWRM_PORT_EP_TX_CFG
+	 * and HWRM_PORT_EP_TX_QCFG for endpoint rate control, and additions
+	 * to HWRM_QUEUE_GLOBAL_CFG and HWRM_QUEUE_GLOBAL_QCFG for receive
+	 * rate control. Configuration of a minimum guaranteed bandwidth
+	 * is only supported if the min_bw_supported flag is also set.
 	 */
-	uint64_t	rx_discard_pkts;
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_EP_RATE_CONTROL				UINT32_C(0x800000)
 	/*
-	 * Number of dropped packets on received path on the function.
-	 * These are packets that have been marked for drop by the
-	 * RE CFA.
+	 * When this bit is '1', the firmware supports enforcement of
+	 * minimum guaranteed bandwidth. A minimum guaranteed bandwidth
+	 * could be configured for a partition or for an endpoint. Firmware
+	 * only sets this flag if one or both of the ep_rate_control and
+	 * partition_bw_supported flags are set.
 	 */
-	uint64_t	rx_drop_pkts;
-	/* Number of received bytes for unicast traffic on the function. */
-	uint64_t	rx_ucast_bytes;
-	/* Number of received bytes for multicast traffic on the function. */
-	uint64_t	rx_mcast_bytes;
-	/* Number of received bytes for broadcast traffic on the function. */
-	uint64_t	rx_bcast_bytes;
-	/* Number of aggregated unicast packets on the function. */
-	uint64_t	rx_agg_pkts;
-	/* Number of aggregated unicast bytes on the function. */
-	uint64_t	rx_agg_bytes;
-	/* Number of aggregation events on the function. */
-	uint64_t	rx_agg_events;
-	/* Number of aborted aggregations on the function. */
-	uint64_t	rx_agg_aborts;
-	uint8_t	unused_0[7];
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_MIN_BW_SUPPORTED				UINT32_C(0x1000000)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When this bit is '1', HW supports TX coalesced completion
+	 * records.
 	 */
-	uint8_t	valid;
-} hwrm_func_qstats_output_t, *phwrm_func_qstats_output_t;
-
-/************************
- * hwrm_func_qstats_ext *
- ************************/
-
-
-/* hwrm_func_qstats_ext_input (size:256b/32B) */
-
-typedef struct hwrm_func_qstats_ext_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_TX_COAL_CMPL_CAP				UINT32_C(0x2000000)
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * When this bit is '1', it indicates the FW has full support
+	 * for all backing store types with the BACKING_STORE_CFG/QCFG
+	 * V2 APIs.
 	 */
-	uint16_t	cmpl_ring;
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_BS_V2_SUPPORTED				UINT32_C(0x4000000)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * When this bit is '1', it indicates the FW forces to use the
+	 * BACKING_STORE_CFG/QCFG V2 APIs.
 	 */
-	uint16_t	seq_id;
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_BS_V2_REQUIRED				UINT32_C(0x8000000)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * When this bit is '1', it indicates that FW will support a single
+	 * 64bit real time clock for PTP.
 	 */
-	uint16_t	target_id;
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_PTP_64BIT_RTC_SUPPORTED			UINT32_C(0x10000000)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * When this bit is '1', it indicates the FW is capable of
+	 * supporting Doorbell Pacing.
 	 */
-	uint64_t	resp_addr;
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_DBR_PACING_SUPPORTED			UINT32_C(0x20000000)
 	/*
-	 * Function ID of the function that is being queried.
-	 * 0xFF... (All Fs) if the query is for the requesting
-	 * function.
-	 * A privileged PF can query for other function's statistics.
+	 * When this bit is '1', it indicates the FW is capable of
+	 * supporting HW based doorbell drop recovery.
 	 */
-	uint16_t	fid;
-	/* This flags indicates the type of statistics request. */
-	uint8_t	flags;
-	/* This value is not used to avoid backward compatibility issues. */
-	#define HWRM_FUNC_QSTATS_EXT_INPUT_FLAGS_UNUSED	UINT32_C(0x0)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_HW_DBR_DROP_RECOV_SUPPORTED		UINT32_C(0x40000000)
 	/*
-	 * flags should be set to 1 when request is for only RoCE statistics.
-	 * This will be honored only if the caller_fid is a privileged PF.
-	 * In all other cases FID and caller_fid should be the same.
+	 * When this bit is '1', it indicates the driver can disable the CQ
+	 * overflow detection and can also skip the index updates for CQ.
 	 */
-	#define HWRM_FUNC_QSTATS_EXT_INPUT_FLAGS_ROCE_ONLY	UINT32_C(0x1)
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_DISABLE_CQ_OVERFLOW_DETECTION_SUPPORTED	UINT32_C(0x80000000)
+	/* The maximum number of SCHQs supported by this device. */
+	uint8_t	max_schqs;
+	uint8_t	mpc_chnls_cap;
 	/*
-	 * flags should be set to 2 when request is for the counter mask
-	 * representing the width of each of the stats counters, rather
-	 * than counters themselves.
+	 * When this bit is '1', it indicates that HW and firmware
+	 * supports the use of a MPC channel with destination set
+	 * to the TX crypto engine block.
 	 */
-	#define HWRM_FUNC_QSTATS_EXT_INPUT_FLAGS_COUNTER_MASK UINT32_C(0x2)
-	#define HWRM_FUNC_QSTATS_EXT_INPUT_FLAGS_LAST	HWRM_FUNC_QSTATS_EXT_INPUT_FLAGS_COUNTER_MASK
-	uint8_t	unused_0[1];
-	uint32_t	enables;
+	#define HWRM_FUNC_QCAPS_OUTPUT_MPC_CHNLS_CAP_TCE	UINT32_C(0x1)
 	/*
-	 * This bit must be '1' for the schq_id and traffic_class fields to
-	 * be configured.
+	 * When this bit is '1', it indicates that HW and firmware
+	 * supports the use of a MPC channel with destination set
+	 * to the RX crypto engine block.
 	 */
-	#define HWRM_FUNC_QSTATS_EXT_INPUT_ENABLES_SCHQ_ID	UINT32_C(0x1)
-	/* Specifies the SCHQ for which to gather statistics */
-	uint16_t	schq_id;
+	#define HWRM_FUNC_QCAPS_OUTPUT_MPC_CHNLS_CAP_RCE	UINT32_C(0x2)
 	/*
-	 * Specifies the traffic class for which to gather statistics. Valid
-	 * values are 0 through (max_configurable_queues - 1), where
-	 * max_configurable_queues is in the response of HWRM_QUEUE_QPORTCFG
+	 * When this bit is '1', it indicates that HW and firmware
+	 * supports the use of a MPC channel with destination set
+	 * to the TX configurable flow processing block.
 	 */
-	uint16_t	traffic_class;
-	uint8_t	unused_1[4];
-} hwrm_func_qstats_ext_input_t, *phwrm_func_qstats_ext_input_t;
-
-/* hwrm_func_qstats_ext_output (size:1536b/192B) */
-
-typedef struct hwrm_func_qstats_ext_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Number of received unicast packets */
-	uint64_t	rx_ucast_pkts;
-	/* Number of received multicast packets */
-	uint64_t	rx_mcast_pkts;
-	/* Number of received broadcast packets */
-	uint64_t	rx_bcast_pkts;
-	/* Number of discarded packets on received path */
-	uint64_t	rx_discard_pkts;
-	/* Number of packets on receive path with error */
-	uint64_t	rx_error_pkts;
-	/* Number of received bytes for unicast traffic */
-	uint64_t	rx_ucast_bytes;
-	/* Number of received bytes for multicast traffic */
-	uint64_t	rx_mcast_bytes;
-	/* Number of received bytes for broadcast traffic */
-	uint64_t	rx_bcast_bytes;
-	/* Number of transmitted unicast packets */
-	uint64_t	tx_ucast_pkts;
-	/* Number of transmitted multicast packets */
-	uint64_t	tx_mcast_pkts;
-	/* Number of transmitted broadcast packets */
-	uint64_t	tx_bcast_pkts;
-	/* Number of packets on transmit path with error */
-	uint64_t	tx_error_pkts;
-	/* Number of discarded packets on transmit path */
-	uint64_t	tx_discard_pkts;
-	/* Number of transmitted bytes for unicast traffic */
-	uint64_t	tx_ucast_bytes;
-	/* Number of transmitted bytes for multicast traffic */
-	uint64_t	tx_mcast_bytes;
-	/* Number of transmitted bytes for broadcast traffic */
-	uint64_t	tx_bcast_bytes;
-	/* Number of TPA eligible packets */
-	uint64_t	rx_tpa_eligible_pkt;
-	/* Number of TPA eligible bytes */
-	uint64_t	rx_tpa_eligible_bytes;
-	/* Number of TPA packets */
-	uint64_t	rx_tpa_pkt;
-	/* Number of TPA bytes */
-	uint64_t	rx_tpa_bytes;
-	/* Number of TPA errors */
-	uint64_t	rx_tpa_errors;
-	/* Number of TPA errors */
-	uint64_t	rx_tpa_events;
-	uint8_t	unused_0[7];
+	#define HWRM_FUNC_QCAPS_OUTPUT_MPC_CHNLS_CAP_TE_CFA	UINT32_C(0x4)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When this bit is '1', it indicates that HW and firmware
+	 * supports the use of a MPC channel with destination set
+	 * to the RX configurable flow processing block.
 	 */
-	uint8_t	valid;
-} hwrm_func_qstats_ext_output_t, *phwrm_func_qstats_ext_output_t;
-
-/***********************
- * hwrm_func_clr_stats *
- ***********************/
-
-
-/* hwrm_func_clr_stats_input (size:192b/24B) */
-
-typedef struct hwrm_func_clr_stats_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define HWRM_FUNC_QCAPS_OUTPUT_MPC_CHNLS_CAP_RE_CFA	UINT32_C(0x8)
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * When this bit is '1', it indicates that HW and firmware
+	 * supports the use of a MPC channel with destination set
+	 * to the primate processor block.
 	 */
-	uint16_t	cmpl_ring;
+	#define HWRM_FUNC_QCAPS_OUTPUT_MPC_CHNLS_CAP_PRIMATE	UINT32_C(0x10)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Maximum number of Key Contexts supported per HWRM
+	 * function call for allocating Key Contexts.
 	 */
-	uint16_t	seq_id;
+	uint16_t	max_key_ctxs_alloc;
+	uint32_t	flags_ext2;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * When this bit is '1', it indicates that FW will support
+	 * timestamping on all RX packets, not just PTP type packets.
 	 */
-	uint16_t	target_id;
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_RX_ALL_PKTS_TIMESTAMPS_SUPPORTED	UINT32_C(0x1)
+	/* When this bit is '1', it indicates that HW and FW support QUIC. */
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_QUIC_SUPPORTED			UINT32_C(0x2)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * When this bit is '1', it indicates that KDNet mode is
+	 * supported on the port for this function. This bit is
+	 * never set for a VF.
 	 */
-	uint64_t	resp_addr;
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_KDNET_SUPPORTED			UINT32_C(0x4)
 	/*
-	 * Function ID of the function.
-	 * 0xFF... (All Fs) if the query is for the requesting
-	 * function.
+	 * When this bit is '1', it indicates the FW is capable of
+	 * supporting Enhanced Doorbell Pacing.
 	 */
-	uint16_t	fid;
-	uint8_t	unused_0[6];
-} hwrm_func_clr_stats_input_t, *phwrm_func_clr_stats_input_t;
-
-/* hwrm_func_clr_stats_output (size:128b/16B) */
-
-typedef struct hwrm_func_clr_stats_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_DBR_PACING_EXT_SUPPORTED		UINT32_C(0x8)
+	/*
+	 * When this bit is '1', it indicates that FW is capable of
+	 * supporting software based doorbell drop recovery.
+	 */
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_SW_DBR_DROP_RECOVERY_SUPPORTED	UINT32_C(0x10)
+	/*
+	 * When this bit is '1', it indicates the FW supports collection
+	 * and query of the generic statistics.
+	 */
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_GENERIC_STATS_SUPPORTED		UINT32_C(0x20)
+	/*
+	 * When this bit is '1', it indicates that the HW is capable of
+	 * supporting UDP GSO on the function.
+	 */
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_UDP_GSO_SUPPORTED			UINT32_C(0x40)
+	/*
+	 * When this bit is '1', it indicates that SyncE feature is
+	 * supported.
+	 */
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_SYNCE_SUPPORTED			UINT32_C(0x80)
+	/*
+	 * When this bit is '1', it indicates the FW is capable of
+	 * supporting doorbell pacing version 0. As doorbell pacing
+	 * notification from hardware for Thor2 is completely different
+	 * from Thor1, this flag is used to differentiate the doorbell
+	 * pacing notification between Thor1 and Thor2. Thor1 uses
+	 * dbr_pacing_supported and dbr_pacing_ext_supported flags for
+	 * doorbell pacing whereas Thor2 uses dbr_pacing_v0_supported flag.
+	 * These flags will never be set at the same time for Thor2.
+	 * Based on this flag, host drivers assume doorbell pacing is needed
+	 * for Thor2.
+	 */
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_DBR_PACING_V0_SUPPORTED		UINT32_C(0x100)
+	/*
+	 * When this bit is '1', it indicates that the HW supports
+	 * two-completion TX packet timestamp feature, a second completion
+	 * carrying packet TX timestamp in addition to the standard
+	 * completion returned for packets. Host driver should not use
+	 * HWRM port timestamp query (HWRM_PORT_TS_QUERY) command for
+	 * TX timestamp read when two-completion timestamp feature is
+	 * supported.
+	 */
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_TX_PKT_TS_CMPL_SUPPORTED		UINT32_C(0x200)
+	/*
+	 * When this bit is '1', it indicates that the hardware based
+	 * link aggregation group (L2 and RoCE) feature is supported.
+	 * This LAG feature is only supported on the THOR2 or newer NIC
+	 * with multiple ports.
+	 */
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_HW_LAG_SUPPORTED			UINT32_C(0x400)
+	/*
+	 * When this bit is '1', it indicates all contexts can be stored
+	 * on chip instead of using host based backing store memory.
+	 */
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_ON_CHIP_CTX_SUPPORTED		UINT32_C(0x800)
+	/*
+	 * When this bit is '1', it indicates that the HW supports
+	 * using a steering tag in the memory transactions targeting
+	 * L2 or RoCE ring resources.
+	 * Steering Tags are system-specific values that must follow the
+	 * encoding requirements of the hardware platform. On devices that
+	 * support steering to multiple address domains, a value of 0 in
+	 * bit 0 of the steering tag specifies the address is associated
+	 * with the SOC address space, and a value of 1 indicates the
+	 * address is associated with the host address space.
+	 */
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_STEERING_TAG_SUPPORTED		UINT32_C(0x1000)
+	/*
+	 * When this bit is '1', it indicates that driver can enable
+	 * support for an enhanced VF scale.
+	 */
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_ENHANCED_VF_SCALE_SUPPORTED	UINT32_C(0x2000)
+	/*
+	 * When this bit is '1', it indicates that FW is capable of
+	 * supporting partition based XID management for KTLS/QUIC
+	 * Tx/Rx Key Context types.
+	 */
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_KEY_XID_PARTITION_SUPPORTED	UINT32_C(0x4000)
+	/*
+	 * This bit is only valid on the condition that both
+	 * 'ktls_supported' and 'quic_supported' flags are set. When this
+	 * bit is valid, it conveys information below:
+	 * 1. If it is set to '1', it indicates that the firmware allows the
+	 *	driver to run KTLS and QUIC concurrently;
+	 * 2. If it is cleared to '0', it indicates that the driver has to
+	 *	make sure all crypto connections on all functions are of the
+	 *	same type, i.e., either KTLS or QUIC.
+	 */
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_CONCURRENT_KTLS_QUIC_SUPPORTED	UINT32_C(0x8000)
+	/*
+	 * When this bit is '1', it indicates that the device supports
+	 * setting a cross TC cap on a scheduler queue.
+	 */
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_SCHQ_CROSS_TC_CAP_SUPPORTED	UINT32_C(0x10000)
+	/*
+	 * When this bit is '1', it indicates that the device supports
+	 * setting a per TC cap on a scheduler queue.
+	 */
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_SCHQ_PER_TC_CAP_SUPPORTED		UINT32_C(0x20000)
+	/*
+	 * When this bit is '1', it indicates that the device supports
+	 * setting a per TC reservation on a scheduler queues.
+	 */
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_SCHQ_PER_TC_RESERVATION_SUPPORTED	UINT32_C(0x40000)
+	/*
+	 * When this bit is '1', it indicates that firmware supports query
+	 * for statistics related to invalid doorbell errors and drops.
+	 */
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_DB_ERROR_STATS_SUPPORTED		UINT32_C(0x80000)
+	/*
+	 * When this bit is '1', it indicates that the device supports
+	 * VF RoCE resource management.
+	 */
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_ROCE_VF_RESOURCE_MGMT_SUPPORTED	UINT32_C(0x100000)
+	/*
+	 * When this bit is '1', it indicates that the device supports
+	 * UDCC management.
+	 */
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_UDCC_SUPPORTED			UINT32_C(0x200000)
+	/*
+	 * When this bit is '1', it indicates that the device supports Timed
+	 * Transmit TxTime scheduling; this is applicable to L2 flows only.
+	 * It is expected that host software assigns each packet a transmit
+	 * time and posts packets for transmit in time order. NIC hardware
+	 * transmits the packet at time assigned by software.
+	 */
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_TIMED_TX_SO_TXTIME_SUPPORTED	UINT32_C(0x400000)
+	/*
+	 * This bit indicates the method used for the advertisement of the
+	 * max resource limit for the PF and its VFs.
+	 * When this bit is '1', it indicates that the maximum resource
+	 * limits for both RoCE and L2 are software defined. These limits
+	 * are queried using the HWRM backing store qcaps v1
+	 * and v2(max_num_entries). For RoCE, the resource limits are
+	 * derived from nvm options. For L2, the resources will continue
+	 * to use FW enforced SW limits based on chip config and per PF
+	 * function NVM resource parameters.
+	 * If this bit is '0', the FW will use to legacy behavior.
+	 * For RoCE, the maximum resource values supported by the chip will
+	 * be returned. For L2, the maximum resource values returned will
+	 * be the FW enforced SW limits based on chip config and per PF
+	 * function NVM resource parameters.
+	 */
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_SW_MAX_RESOURCE_LIMITS_SUPPORTED	UINT32_C(0x800000)
+	/*
+	 * When this bit is '1', it indicates that the device supports
+	 * migrating ingress NIC flows to Truflow.
+	 */
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_TF_INGRESS_NIC_FLOW_SUPPORTED	UINT32_C(0x1000000)
+	/*
+	 * When this bit is '1', it indicates that the Firmware supports
+	 * query and clear of the port loopback statistics.
+	 */
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_LPBK_STATS_SUPPORTED		UINT32_C(0x2000000)
+	uint16_t	tunnel_disable_flag;
+	/*
+	 * When this bit is '1', it indicates that the VXLAN parsing
+	 * is disabled in hardware
+	 */
+	#define HWRM_FUNC_QCAPS_OUTPUT_TUNNEL_DISABLE_FLAG_DISABLE_VXLAN	UINT32_C(0x1)
+	/*
+	 * When this bit is '1', it indicates that the NGE parsing
+	 * is disabled in hardware
+	 */
+	#define HWRM_FUNC_QCAPS_OUTPUT_TUNNEL_DISABLE_FLAG_DISABLE_NGE	UINT32_C(0x2)
+	/*
+	 * When this bit is '1', it indicates that the NVGRE parsing
+	 * is disabled in hardware
+	 */
+	#define HWRM_FUNC_QCAPS_OUTPUT_TUNNEL_DISABLE_FLAG_DISABLE_NVGRE	UINT32_C(0x4)
+	/*
+	 * When this bit is '1', it indicates that the L2GRE parsing
+	 * is disabled in hardware
+	 */
+	#define HWRM_FUNC_QCAPS_OUTPUT_TUNNEL_DISABLE_FLAG_DISABLE_L2GRE	UINT32_C(0x8)
+	/*
+	 * When this bit is '1', it indicates that the GRE parsing
+	 * is disabled in hardware
+	 */
+	#define HWRM_FUNC_QCAPS_OUTPUT_TUNNEL_DISABLE_FLAG_DISABLE_GRE	UINT32_C(0x10)
+	/*
+	 * When this bit is '1', it indicates that the IPINIP parsing
+	 * is disabled in hardware
+	 */
+	#define HWRM_FUNC_QCAPS_OUTPUT_TUNNEL_DISABLE_FLAG_DISABLE_IPINIP	UINT32_C(0x20)
+	/*
+	 * When this bit is '1', it indicates that the MPLS parsing
+	 * is disabled in hardware
+	 */
+	#define HWRM_FUNC_QCAPS_OUTPUT_TUNNEL_DISABLE_FLAG_DISABLE_MPLS	UINT32_C(0x40)
+	/*
+	 * When this bit is '1', it indicates that the PPPOE parsing
+	 * is disabled in hardware
+	 */
+	#define HWRM_FUNC_QCAPS_OUTPUT_TUNNEL_DISABLE_FLAG_DISABLE_PPPOE	UINT32_C(0x80)
+	uint16_t	xid_partition_cap;
+	/*
+	 * When this bit is '1', it indicates that FW is capable of
+	 * supporting partition based XID management for Tx crypto
+	 * key contexts.
+	 */
+	#define HWRM_FUNC_QCAPS_OUTPUT_XID_PARTITION_CAP_TX_CK	UINT32_C(0x1)
+	/*
+	 * When this bit is '1', it indicates that FW is capable of
+	 * supporting partition based XID management for Rx crypto
+	 * key contexts.
+	 */
+	#define HWRM_FUNC_QCAPS_OUTPUT_XID_PARTITION_CAP_RX_CK	UINT32_C(0x2)
+	/*
+	 * This value uniquely identifies the hardware NIC used by the
+	 * function. The value returned will be the same for all functions.
+	 * A value of 00-00-00-00-00-00-00-00 indicates no device serial number
+	 * is currently configured. This is the same value that is returned by
+	 * PCIe Capability Device Serial Number.
+	 */
+	uint8_t	device_serial_number[8];
+	/*
+	 * This field is only valid in the XID partition mode. It indicates
+	 * the number contexts per partition.
+	 */
+	uint16_t	ctxs_per_partition;
+	uint8_t	unused_2[2];
+	/*
+	 * The maximum number of address vectors that may be allocated across
+	 * all VFs for the function. This is valid only on the PF with VF RoCE
+	 * (SR-IOV) enabled. Returns zero if this command is called on a PF
+	 * with VF RoCE (SR-IOV) disabled or on a VF.
+	 */
+	uint32_t	roce_vf_max_av;
+	/*
+	 * The maximum number of completion queues that may be allocated across
+	 * all VFs for the function. This is valid only on the PF with VF RoCE
+	 * (SR-IOV) enabled. Returns zero if this command is called on a PF
+	 * with VF RoCE (SR-IOV) disabled or on a VF.
+	 */
+	uint32_t	roce_vf_max_cq;
+	/*
+	 * The maximum number of memory regions plus memory windows that may be
+	 * allocated across all VFs for the function. This is valid only on the
+	 * PF with VF RoCE (SR-IOV) enabled. Returns zero if this command is
+	 * called on a PF with VF RoCE (SR-IOV) disabled or on a VF.
+	 */
+	uint32_t	roce_vf_max_mrw;
+	/*
+	 * The maximum number of queue pairs that may be allocated across
+	 * all VFs for the function. This is valid only on the PF with VF RoCE
+	 * (SR-IOV) enabled. Returns zero if this command is called on a PF
+	 * with VF RoCE (SR-IOV) disabled or on a VF.
+	 */
+	uint32_t	roce_vf_max_qp;
+	/*
+	 * The maximum number of shared receive queues that may be allocated
+	 * across all VFs for the function. This is valid only on the PF with
+	 * VF RoCE (SR-IOV) enabled. Returns zero if this command is called on
+	 * a PF with VF RoCE (SR-IOV) disabled or on a VF.
+	 */
+	uint32_t	roce_vf_max_srq;
+	/*
+	 * The maximum number of GIDs that may be allocated across all VFs for
+	 * the function. This is valid only on the PF with VF RoCE (SR-IOV)
+	 * enabled. Returns zero if this command is called on a PF with VF RoCE
+	 * (SR-IOV) disabled or on a VF.
+	 */
+	uint32_t	roce_vf_max_gid;
+	uint8_t	unused_3[3];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_func_clr_stats_output_t, *phwrm_func_clr_stats_output_t;
+} hwrm_func_qcaps_output_t, *phwrm_func_qcaps_output_t;
 
-/**************************
- * hwrm_func_vf_resc_free *
- **************************/
+/******************
+ * hwrm_func_qcfg *
+ ******************/
 
 
-/* hwrm_func_vf_resc_free_input (size:192b/24B) */
+/* hwrm_func_qcfg_input (size:192b/24B) */
 
-typedef struct hwrm_func_vf_resc_free_input {
+typedef struct hwrm_func_qcfg_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -13370,16 +15369,19 @@ typedef struct hwrm_func_vf_resc_free_input {
 	 */
 	uint64_t	resp_addr;
 	/*
-	 * This value is used to identify a Virtual Function (VF).
-	 * The scope of VF ID is local within a PF.
+	 * Function ID of the function that is being queried.
+	 * 0xFF... (All Fs) if the query is for the requesting
+	 * function.
+	 * 0xFFFE (REQUESTING_PARENT_FID) This is a special FID
+	 * to be used by a trusted VF to query its parent PF.
 	 */
-	uint16_t	vf_id;
+	uint16_t	fid;
 	uint8_t	unused_0[6];
-} hwrm_func_vf_resc_free_input_t, *phwrm_func_vf_resc_free_input_t;
+} hwrm_func_qcfg_input_t, *phwrm_func_qcfg_input_t;
 
-/* hwrm_func_vf_resc_free_output (size:128b/16B) */
+/* hwrm_func_qcfg_output (size:1280b/160B) */
 
-typedef struct hwrm_func_vf_resc_free_output {
+typedef struct hwrm_func_qcfg_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -13388,788 +15390,674 @@ typedef struct hwrm_func_vf_resc_free_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * FID value. This value is used to identify operations on the PCI
+	 * bus as belonging to a particular PCI function.
 	 */
-	uint8_t	valid;
-} hwrm_func_vf_resc_free_output_t, *phwrm_func_vf_resc_free_output_t;
-
-/**********************
- * hwrm_func_drv_rgtr *
- **********************/
-
-
-/* hwrm_func_drv_rgtr_input (size:896b/112B) */
-
-typedef struct hwrm_func_drv_rgtr_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	uint16_t	fid;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * Port ID of port that this function is associated with.
+	 * 0xFF... (All Fs) if this function is not associated with
+	 * any port.
 	 */
-	uint16_t	cmpl_ring;
+	uint16_t	port_id;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * This value is the current VLAN setting for this
+	 * function. The value of 0 for this field indicates
+	 * no priority tagging or VLAN is used.
+	 * This field's format is same as 802.1Q Tag's
+	 * Tag Control Information (TCI) format that includes both
+	 * Priority Code Point (PCP) and VLAN Identifier (VID).
 	 */
-	uint16_t	seq_id;
+	uint16_t	vlan;
+	uint16_t	flags;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * If 1, then magic packet based Out-Of-Box WoL is enabled on
+	 * the port associated with this function.
 	 */
-	uint16_t	target_id;
+	#define HWRM_FUNC_QCFG_OUTPUT_FLAGS_OOB_WOL_MAGICPKT_ENABLED	UINT32_C(0x1)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * If 1, then bitmap pattern based Out-Of-Box WoL packet is enabled
+	 * on the port associated with this function.
 	 */
-	uint64_t	resp_addr;
-	uint32_t	flags;
+	#define HWRM_FUNC_QCFG_OUTPUT_FLAGS_OOB_WOL_BMP_ENABLED	UINT32_C(0x2)
 	/*
-	 * When this bit is '1', the function driver is requesting
-	 * all requests from its children VF drivers to be
-	 * forwarded to itself.
-	 * This flag can only be set by the PF driver.
-	 * If a VF driver sets this flag, it should be ignored
-	 * by the HWRM.
+	 * If set to 1, then FW based DCBX agent is enabled and running on
+	 * the port associated with this function.
+	 * If set to 0, then DCBX agent is not running in the firmware.
 	 */
-	#define HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_FWD_ALL_MODE		UINT32_C(0x1)
+	#define HWRM_FUNC_QCFG_OUTPUT_FLAGS_FW_DCBX_AGENT_ENABLED	UINT32_C(0x4)
 	/*
-	 * When this bit is '1', the function is requesting none of
-	 * the requests from its children VF drivers to be
-	 * forwarded to itself.
-	 * This flag can only be set by the PF driver.
-	 * If a VF driver sets this flag, it should be ignored
-	 * by the HWRM.
+	 * Standard TX Ring mode is used for the allocation of TX ring
+	 * and underlying scheduling resources that allow bandwidth
+	 * reservation and limit settings on the queried function.
+	 * If set to 1, then standard TX ring mode is enabled
+	 * on the queried function.
+	 * If set to 0, then the standard TX ring mode is disabled
+	 * on the queried function. In this extended TX ring resource
+	 * mode, the minimum and maximum bandwidth settings are not
+	 * supported to allow the allocation of TX rings to span multiple
+	 * scheduler nodes.
 	 */
-	#define HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_FWD_NONE_MODE		UINT32_C(0x2)
+	#define HWRM_FUNC_QCFG_OUTPUT_FLAGS_STD_TX_RING_MODE_ENABLED	UINT32_C(0x8)
 	/*
-	 * When this bit is '1', then ver_maj_8b, ver_min_8b, ver_upd_8b
-	 * fields shall be ignored and ver_maj, ver_min, ver_upd
-	 * and ver_patch shall be used for the driver version information.
-	 * When this bit is '0', then ver_maj_8b, ver_min_8b, ver_upd_8b
-	 * fields shall be used for the driver version information and
-	 * ver_maj, ver_min, ver_upd and ver_patch shall be ignored.
+	 * If set to 1 then FW based LLDP agent is enabled and running on
+	 * the port associated with this function.
+	 * If set to 0 then the LLDP agent is not running in the firmware.
 	 */
-	#define HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_16BIT_VER_MODE		UINT32_C(0x4)
+	#define HWRM_FUNC_QCFG_OUTPUT_FLAGS_FW_LLDP_AGENT_ENABLED	UINT32_C(0x10)
 	/*
-	 * When this bit is '1', the function is indicating support of
-	 * 64bit flow handle.  The firmware that only supports 64bit flow
-	 * handle should check this bit before allowing processing of
-	 * HWRM_CFA_FLOW_XXX commands from the requesting function as firmware
-	 * with 64bit flow handle support can only be compatible with drivers
-	 * that support 64bit flow handle. The legacy drivers that don't support
-	 * 64bit flow handle won't be able to use HWRM_CFA_FLOW_XXX commands when
-	 * running with new firmware that only supports 64bit flow handle. The new
-	 * firmware support 64bit flow handle returns HWRM_ERR_CODE_CMD_NOT_SUPPORTED
-	 * status to the legacy driver when encounters these commands.
+	 * If set to 1, then multi-host mode is active for this function.
+	 * The NIC is attached to two or more independent host systems
+	 * through two or more PCIe endpoints.
+	 * If set to 0, then multi-host mode is inactive for this function
+	 * or not applicable for this device.
 	 */
-	#define HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_FLOW_HANDLE_64BIT_MODE	UINT32_C(0x8)
+	#define HWRM_FUNC_QCFG_OUTPUT_FLAGS_MULTI_HOST		UINT32_C(0x20)
 	/*
-	 * When this bit is '1', the function is indicating support of
-	 * Hot Reset. The driver interface will destroy the resources,
-	 * unregister the function and register again up on receiving
-	 * the RESET_NOTIFY Async notification from the core firmware.
-	 * The core firmware will this use flag and trigger the Hot Reset
-	 * process only if all the registered driver instances are capable
-	 * of this support.
+	 * If the function that is being queried is a PF, then the HWRM shall
+	 * set this field to 0 and the HWRM client shall ignore this field.
+	 * If the function that is being queried is a VF, then the HWRM shall
+	 * set this field to 1 if the queried VF is trusted, otherwise the
+	 * HWRM shall set this field to 0.
 	 */
-	#define HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_HOT_RESET_SUPPORT	UINT32_C(0x10)
+	#define HWRM_FUNC_QCFG_OUTPUT_FLAGS_TRUSTED_VF		UINT32_C(0x40)
 	/*
-	 * When this bit is 1, the function is indicating the support of the
-	 * error recovery capability. Error recovery support will be used by
-	 * firmware only if all the driver instances support error recovery
-	 * process. By setting this bit, driver is indicating support for
-	 * corresponding async event completion message. These will be
-	 * delivered to the driver even if they did not register for it.
-	 * If supported, after receiving reset notify async event with fatal
-	 * flag set in event data1, then all the drivers have to tear down
-	 * their resources without sending any HWRM commands to FW.
+	 * If set to 1, then secure mode is enabled for this function or
+	 * device. If set to 0, then secure mode is disabled (or normal mode)
+	 * for this function or device.
 	 */
-	#define HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_ERROR_RECOVERY_SUPPORT	UINT32_C(0x20)
+	#define HWRM_FUNC_QCFG_OUTPUT_FLAGS_SECURE_MODE_ENABLED	UINT32_C(0x80)
 	/*
-	 * When this bit is 1, the function is indicating the support of the
-	 * Master capability. The Firmware will use this capability to select the
-	 * Master function. The master function will be used to initiate
-	 * designated functionality like error recovery etc… If none of the
-	 * registered PF’s or trusted VF’s indicate this support, then
-	 * firmware will select the 1st registered PF as Master capable instance.
+	 * If set to 1, then this PF is enabled with a preboot driver that
+	 * requires access to the legacy L2 ring model and legacy 32b
+	 * doorbells. If set to 0, then this PF is not allowed to use
+	 * the legacy L2 rings. This feature is not allowed on VFs and
+	 * is only relevant for devices that require a context backing
+	 * store.
 	 */
-	#define HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_MASTER_SUPPORT		UINT32_C(0x40)
+	#define HWRM_FUNC_QCFG_OUTPUT_FLAGS_PREBOOT_LEGACY_L2_RINGS	UINT32_C(0x100)
 	/*
-	 * When this bit is 1, the function is indicating the support of the
-	 * fast reset capability. Fast reset support will be used by
-	 * firmware only if all the driver instances support fast reset
-	 * process. By setting this bit, driver is indicating support for
-	 * corresponding async event completion message. These will be
-	 * delivered to the driver even if they did not register for it.
-	 * If supported, after receiving reset notify async event with fast
-	 * reset flag set in event data1, then all the drivers have to tear
-	 * down their resources without sending any HWRM commands to FW.
+	 * If set to 1, then the firmware and all currently registered driver
+	 * instances support hot reset. The hot reset support will be updated
+	 * dynamically based on the driver interface advertisement.
+	 * If set to 0, then the adapter is not currently able to initiate
+	 * hot reset.
 	 */
-	#define HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_FAST_RESET_SUPPORT	UINT32_C(0x80)
-	uint32_t	enables;
+	#define HWRM_FUNC_QCFG_OUTPUT_FLAGS_HOT_RESET_ALLOWED		UINT32_C(0x200)
 	/*
-	 * This bit must be '1' for the os_type field to be
-	 * configured.
+	 * If set to 1, then the PPP tx push mode is enabled for all the
+	 * reserved TX rings of this function. If set to 0, then PPP tx push
+	 * mode is disabled for all the reserved TX rings of this function.
 	 */
-	#define HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_OS_TYPE		UINT32_C(0x1)
+	#define HWRM_FUNC_QCFG_OUTPUT_FLAGS_PPP_PUSH_MODE_ENABLED	UINT32_C(0x400)
 	/*
-	 * This bit must be '1' for the ver field to be
-	 * configured.
+	 * If set to 1, then the firmware will notify driver using async
+	 * event when a ring is disabled due to a Hardware error.
 	 */
-	#define HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_VER		UINT32_C(0x2)
+	#define HWRM_FUNC_QCFG_OUTPUT_FLAGS_RING_MONITOR_ENABLED	UINT32_C(0x800)
 	/*
-	 * This bit must be '1' for the timestamp field to be
-	 * configured.
+	 * If set to 1, then the firmware and all currently registered driver
+	 * instances support fast reset. The fast reset support will be
+	 * updated dynamically based on the driver interface advertisement.
+	 * If set to 0, then the adapter is not currently able to initiate
+	 * fast reset.
 	 */
-	#define HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_TIMESTAMP	UINT32_C(0x4)
+	#define HWRM_FUNC_QCFG_OUTPUT_FLAGS_FAST_RESET_ALLOWED	UINT32_C(0x1000)
 	/*
-	 * This bit must be '1' for the vf_req_fwd field to be
-	 * configured.
+	 * If set to 1, then multi-root mode is active for this function.
+	 * The NIC is attached to a single host with a single operating
+	 * system, but through two or more PCIe endpoints.
+	 * If set to 0, then multi-root mode is inactive for this function
+	 * or not applicable for this device.
 	 */
-	#define HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_VF_REQ_FWD	UINT32_C(0x8)
+	#define HWRM_FUNC_QCFG_OUTPUT_FLAGS_MULTI_ROOT		UINT32_C(0x2000)
 	/*
-	 * This bit must be '1' for the async_event_fwd field to be
-	 * configured.
+	 * This flag indicates RDMA support for child VFS of
+	 * a physical function.
+	 * If set to 1, RoCE is supported on all child VFs.
+	 * If set to 0, RoCE is disabled on all child VFs.
 	 */
-	#define HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_ASYNC_EVENT_FWD	UINT32_C(0x10)
-	/* This value indicates the type of OS.  The values are based on CIM_OperatingSystem.mof file as published by the DMTF. */
-	uint16_t	os_type;
-	/* Unknown */
-	#define HWRM_FUNC_DRV_RGTR_INPUT_OS_TYPE_UNKNOWN   UINT32_C(0x0)
-	/* Other OS not listed below. */
-	#define HWRM_FUNC_DRV_RGTR_INPUT_OS_TYPE_OTHER	UINT32_C(0x1)
-	/* MSDOS OS. */
-	#define HWRM_FUNC_DRV_RGTR_INPUT_OS_TYPE_MSDOS	UINT32_C(0xe)
-	/* Windows OS. */
-	#define HWRM_FUNC_DRV_RGTR_INPUT_OS_TYPE_WINDOWS   UINT32_C(0x12)
-	/* Solaris OS. */
-	#define HWRM_FUNC_DRV_RGTR_INPUT_OS_TYPE_SOLARIS   UINT32_C(0x1d)
-	/* Linux OS. */
-	#define HWRM_FUNC_DRV_RGTR_INPUT_OS_TYPE_LINUX	UINT32_C(0x24)
-	/* FreeBSD OS. */
-	#define HWRM_FUNC_DRV_RGTR_INPUT_OS_TYPE_FREEBSD   UINT32_C(0x2a)
-	/* VMware ESXi OS. */
-	#define HWRM_FUNC_DRV_RGTR_INPUT_OS_TYPE_ESXI	UINT32_C(0x68)
-	/* Microsoft Windows 8 64-bit OS. */
-	#define HWRM_FUNC_DRV_RGTR_INPUT_OS_TYPE_WIN864	UINT32_C(0x73)
-	/* Microsoft Windows Server 2012 R2 OS. */
-	#define HWRM_FUNC_DRV_RGTR_INPUT_OS_TYPE_WIN2012R2 UINT32_C(0x74)
-	/* UEFI driver. */
-	#define HWRM_FUNC_DRV_RGTR_INPUT_OS_TYPE_UEFI	UINT32_C(0x8000)
-	#define HWRM_FUNC_DRV_RGTR_INPUT_OS_TYPE_LAST	HWRM_FUNC_DRV_RGTR_INPUT_OS_TYPE_UEFI
-	/* This is the 8bit major version of the driver. */
-	uint8_t	ver_maj_8b;
-	/* This is the 8bit minor version of the driver. */
-	uint8_t	ver_min_8b;
-	/* This is the 8bit update version of the driver. */
-	uint8_t	ver_upd_8b;
-	uint8_t	unused_0[3];
+	#define HWRM_FUNC_QCFG_OUTPUT_FLAGS_ENABLE_RDMA_SRIOV		UINT32_C(0x4000)
 	/*
-	 * This is a 32-bit timestamp provided by the driver for
-	 * keep alive.
-	 * The timestamp is in multiples of 1ms.
+	 * When set to 1, indicates the field roce_vnic_id in the structure
+	 * is valid. If this bit is 0, the driver should not use the
+	 * 'roce_vnic_id' field.
 	 */
-	uint32_t	timestamp;
-	uint8_t	unused_1[4];
+	#define HWRM_FUNC_QCFG_OUTPUT_FLAGS_ROCE_VNIC_ID_VALID	UINT32_C(0x8000)
 	/*
-	 * This is a 256-bit bit mask provided by the PF driver for
-	 * letting the HWRM know what commands issued by the VF driver
-	 * to the HWRM should be forwarded to the PF driver.
-	 * Nth bit refers to the Nth req_type.
-	 *
-	 * Setting Nth bit to 1 indicates that requests from the
-	 * VF driver with req_type equal to N shall be forwarded to
-	 * the parent PF driver.
-	 *
-	 * This field is not valid for the VF driver.
+	 * This value is current MAC address configured for this
+	 * function. A value of 00-00-00-00-00-00 indicates no
+	 * MAC address is currently configured.
 	 */
-	uint32_t	vf_req_fwd[8];
+	uint8_t	mac_address[6];
 	/*
-	 * This is a 256-bit bit mask provided by the function driver
-	 * (PF or VF driver) to indicate the list of asynchronous event
-	 * completions to be forwarded.
-	 *
-	 * Nth bit refers to the Nth event_id.
-	 *
-	 * Setting Nth bit to 1 by the function driver shall result in
-	 * the HWRM forwarding asynchronous event completion with
-	 * event_id equal to N.
-	 *
-	 * If all bits are set to 0 (value of 0), then the HWRM shall
-	 * not forward any asynchronous event completion to this
-	 * function driver.
+	 * This value is current PCI ID of this
+	 * function. If ARI is enabled, then it is
+	 * Bus Number (8b):Function Number(8b). Otherwise, it is
+	 * Bus Number (8b):Device Number (4b):Function Number(4b).
+	 * If multi-host mode is active, the 4 lsb will indicate
+	 * the PF index for this function.
 	 */
-	uint32_t	async_event_fwd[8];
-	/* This is the 16bit major version of the driver. */
-	uint16_t	ver_maj;
-	/* This is the 16bit minor version of the driver. */
-	uint16_t	ver_min;
-	/* This is the 16bit update version of the driver. */
-	uint16_t	ver_upd;
-	/* This is the 16bit patch version of the driver. */
-	uint16_t	ver_patch;
-} hwrm_func_drv_rgtr_input_t, *phwrm_func_drv_rgtr_input_t;
-
-/* hwrm_func_drv_rgtr_output (size:128b/16B) */
-
-typedef struct hwrm_func_drv_rgtr_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint32_t	flags;
+	uint16_t	pci_id;
 	/*
-	 * When this bit is '1', it indicates that the
-	 * HWRM_FUNC_DRV_IF_CHANGE call is supported.
+	 * The number of RSS/COS contexts currently
+	 * allocated to the function.
 	 */
-	#define HWRM_FUNC_DRV_RGTR_OUTPUT_FLAGS_IF_CHANGE_SUPPORTED	UINT32_C(0x1)
-	uint8_t	unused_0[3];
+	uint16_t	alloc_rsscos_ctx;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * The number of completion rings currently allocated to
+	 * the function. This does not include the rings allocated
+	 * to any children functions if any.
 	 */
-	uint8_t	valid;
-} hwrm_func_drv_rgtr_output_t, *phwrm_func_drv_rgtr_output_t;
-
-/************************
- * hwrm_func_drv_unrgtr *
- ************************/
-
-
-/* hwrm_func_drv_unrgtr_input (size:192b/24B) */
-
-typedef struct hwrm_func_drv_unrgtr_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	uint16_t	alloc_cmpl_rings;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * The number of transmit rings currently allocated to
+	 * the function. This does not include the rings allocated
+	 * to any children functions if any.
 	 */
-	uint16_t	cmpl_ring;
+	uint16_t	alloc_tx_rings;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * The number of receive rings currently allocated to
+	 * the function. This does not include the rings allocated
+	 * to any children functions if any.
 	 */
-	uint16_t	seq_id;
+	uint16_t	alloc_rx_rings;
+	/* The allocated number of L2 contexts to the function. */
+	uint16_t	alloc_l2_ctx;
+	/* The allocated number of vnics to the function. */
+	uint16_t	alloc_vnics;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * The maximum transmission unit of the function
+	 * configured by the admin pf.
+	 * If the reported mtu value is non-zero then it will be used for the
+	 * rings allocated on this function, otherwise the default
+	 * value is used if ring MTU is not specified.
+	 * The driver cannot use any MTU bigger than this value
+	 * if it is non-zero.
 	 */
-	uint16_t	target_id;
+	uint16_t	admin_mtu;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * The maximum receive unit of the function.
+	 * For vnics allocated on this function, this default
+	 * value is used if vnic MRU is not specified.
 	 */
-	uint64_t	resp_addr;
-	uint32_t	flags;
+	uint16_t	mru;
+	/* The statistics context assigned to a function. */
+	uint16_t	stat_ctx_id;
 	/*
-	 * When this bit is '1', the function driver is notifying
-	 * the HWRM to prepare for the shutdown.
+	 * The HWRM shall return Unknown value for this field
+	 * when this command is used to query VF's configuration.
 	 */
-	#define HWRM_FUNC_DRV_UNRGTR_INPUT_FLAGS_PREPARE_FOR_SHUTDOWN	UINT32_C(0x1)
-	uint8_t	unused_0[4];
-} hwrm_func_drv_unrgtr_input_t, *phwrm_func_drv_unrgtr_input_t;
-
-/* hwrm_func_drv_unrgtr_output (size:128b/16B) */
-
-typedef struct hwrm_func_drv_unrgtr_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	uint8_t	port_partition_type;
+	/* Single physical function */
+	#define HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_SPF	UINT32_C(0x0)
+	/* Multiple physical functions */
+	#define HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_MPFS	UINT32_C(0x1)
+	/* Network Partitioning 1.0 */
+	#define HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_NPAR1_0 UINT32_C(0x2)
+	/* Network Partitioning 1.5 */
+	#define HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_NPAR1_5 UINT32_C(0x3)
+	/* Network Partitioning 2.0 */
+	#define HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_NPAR2_0 UINT32_C(0x4)
+	/* Network Partitioning 1.2 */
+	#define HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_NPAR1_2 UINT32_C(0x5)
+	/* Unknown */
+	#define HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_UNKNOWN UINT32_C(0xff)
+	#define HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_LAST   HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_UNKNOWN
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * This field will indicate number of physical functions on this
+	 * port_partition. HWRM shall return unavail (i.e. value of 0) for this
+	 * field when this command is used to query VF's configuration or from
+	 * older firmware that doesn't support this field.
 	 */
-	uint8_t	valid;
-} hwrm_func_drv_unrgtr_output_t, *phwrm_func_drv_unrgtr_output_t;
-
-/**********************
- * hwrm_func_buf_rgtr *
- **********************/
-
-
-/* hwrm_func_buf_rgtr_input (size:1024b/128B) */
-
-typedef struct hwrm_func_buf_rgtr_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	uint8_t	port_pf_cnt;
+	/* number of PFs is not available */
+	#define HWRM_FUNC_QCFG_OUTPUT_PORT_PF_CNT_UNAVAIL UINT32_C(0x0)
+	#define HWRM_FUNC_QCFG_OUTPUT_PORT_PF_CNT_LAST   HWRM_FUNC_QCFG_OUTPUT_PORT_PF_CNT_UNAVAIL
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * The default VNIC ID assigned to a function that is
+	 * being queried.
 	 */
-	uint16_t	cmpl_ring;
+	uint16_t	dflt_vnic_id;
+	uint16_t	max_mtu_configured;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Minimum guaranteed transmit bandwidth for this function. When
+	 * specified for a PF, does not affect traffic from the PF's child VFs.
+	 * A value of 0 indicates the minimum bandwidth is not configured.
 	 */
-	uint16_t	seq_id;
+	uint32_t	min_bw;
+	/* The bandwidth value. */
+	#define HWRM_FUNC_QCFG_OUTPUT_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_FUNC_QCFG_OUTPUT_MIN_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_FUNC_QCFG_OUTPUT_MIN_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_FUNC_QCFG_OUTPUT_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_FUNC_QCFG_OUTPUT_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_FUNC_QCFG_OUTPUT_MIN_BW_SCALE_LAST		HWRM_FUNC_QCFG_OUTPUT_MIN_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_FUNC_QCFG_OUTPUT_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_FUNC_QCFG_OUTPUT_MIN_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_FUNC_QCFG_OUTPUT_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_FUNC_QCFG_OUTPUT_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_FUNC_QCFG_OUTPUT_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_FUNC_QCFG_OUTPUT_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of link bandwidth. */
+		#define HWRM_FUNC_QCFG_OUTPUT_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_FUNC_QCFG_OUTPUT_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_FUNC_QCFG_OUTPUT_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_FUNC_QCFG_OUTPUT_MIN_BW_BW_VALUE_UNIT_INVALID
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Maximum transmit rate for this function. When specified for a PF,
+	 * does not affect traffic from the PF's child VFs.
+	 * A value of 0 indicates that the maximum bandwidth is not configured.
 	 */
-	uint16_t	target_id;
+	uint32_t	max_bw;
+	/* The bandwidth value. */
+	#define HWRM_FUNC_QCFG_OUTPUT_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_FUNC_QCFG_OUTPUT_MAX_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_FUNC_QCFG_OUTPUT_MAX_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_FUNC_QCFG_OUTPUT_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_FUNC_QCFG_OUTPUT_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_FUNC_QCFG_OUTPUT_MAX_BW_SCALE_LAST		HWRM_FUNC_QCFG_OUTPUT_MAX_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_FUNC_QCFG_OUTPUT_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_FUNC_QCFG_OUTPUT_MAX_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_FUNC_QCFG_OUTPUT_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_FUNC_QCFG_OUTPUT_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_FUNC_QCFG_OUTPUT_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_FUNC_QCFG_OUTPUT_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of link bandwidth. */
+		#define HWRM_FUNC_QCFG_OUTPUT_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_FUNC_QCFG_OUTPUT_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_FUNC_QCFG_OUTPUT_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_FUNC_QCFG_OUTPUT_MAX_BW_BW_VALUE_UNIT_INVALID
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * This value indicates the Edge virtual bridge mode for the
+	 * domain that this function belongs to.
 	 */
-	uint64_t	resp_addr;
-	uint32_t	enables;
+	uint8_t	evb_mode;
+	/* No Edge Virtual Bridging (EVB) */
+	#define HWRM_FUNC_QCFG_OUTPUT_EVB_MODE_NO_EVB UINT32_C(0x0)
+	/* Virtual Ethernet Bridge (VEB) */
+	#define HWRM_FUNC_QCFG_OUTPUT_EVB_MODE_VEB	UINT32_C(0x1)
+	/* Virtual Ethernet Port Aggregator (VEPA) */
+	#define HWRM_FUNC_QCFG_OUTPUT_EVB_MODE_VEPA   UINT32_C(0x2)
+	#define HWRM_FUNC_QCFG_OUTPUT_EVB_MODE_LAST  HWRM_FUNC_QCFG_OUTPUT_EVB_MODE_VEPA
+	uint8_t	options;
 	/*
-	 * This bit must be '1' for the vf_id field to be
-	 * configured.
+	 * This value indicates the PCIE device cache line size.
+	 * The cache line size allows the DMA writes to terminate and
+	 * start at the cache boundary.
 	 */
-	#define HWRM_FUNC_BUF_RGTR_INPUT_ENABLES_VF_ID		UINT32_C(0x1)
+	#define HWRM_FUNC_QCFG_OUTPUT_OPTIONS_CACHE_LINESIZE_MASK	UINT32_C(0x3)
+	#define HWRM_FUNC_QCFG_OUTPUT_OPTIONS_CACHE_LINESIZE_SFT	0
+	/* Cache Line Size 64 bytes */
+		#define HWRM_FUNC_QCFG_OUTPUT_OPTIONS_CACHE_LINESIZE_SIZE_64	UINT32_C(0x0)
+	/* Cache Line Size 128 bytes */
+		#define HWRM_FUNC_QCFG_OUTPUT_OPTIONS_CACHE_LINESIZE_SIZE_128	UINT32_C(0x1)
+		#define HWRM_FUNC_QCFG_OUTPUT_OPTIONS_CACHE_LINESIZE_LAST	HWRM_FUNC_QCFG_OUTPUT_OPTIONS_CACHE_LINESIZE_SIZE_128
+	/* This value is the virtual link admin state setting. */
+	#define HWRM_FUNC_QCFG_OUTPUT_OPTIONS_LINK_ADMIN_STATE_MASK	UINT32_C(0xc)
+	#define HWRM_FUNC_QCFG_OUTPUT_OPTIONS_LINK_ADMIN_STATE_SFT	2
+	/* Admin link state is in forced down mode. */
+		#define HWRM_FUNC_QCFG_OUTPUT_OPTIONS_LINK_ADMIN_STATE_FORCED_DOWN  (UINT32_C(0x0) << 2)
+	/* Admin link state is in forced up mode. */
+		#define HWRM_FUNC_QCFG_OUTPUT_OPTIONS_LINK_ADMIN_STATE_FORCED_UP	(UINT32_C(0x1) << 2)
 	/*
-	 * This bit must be '1' for the err_buf_addr field to be
-	 * configured.
+	 * Admin link state is in auto mode - follows the physical link
+	 * state.
 	 */
-	#define HWRM_FUNC_BUF_RGTR_INPUT_ENABLES_ERR_BUF_ADDR	UINT32_C(0x2)
+		#define HWRM_FUNC_QCFG_OUTPUT_OPTIONS_LINK_ADMIN_STATE_AUTO	(UINT32_C(0x2) << 2)
+		#define HWRM_FUNC_QCFG_OUTPUT_OPTIONS_LINK_ADMIN_STATE_LAST	HWRM_FUNC_QCFG_OUTPUT_OPTIONS_LINK_ADMIN_STATE_AUTO
+	/* Reserved for future. */
+	#define HWRM_FUNC_QCFG_OUTPUT_OPTIONS_RSVD_MASK		UINT32_C(0xf0)
+	#define HWRM_FUNC_QCFG_OUTPUT_OPTIONS_RSVD_SFT			4
 	/*
-	 * This value is used to identify a Virtual Function (VF).
-	 * The scope of VF ID is local within a PF.
+	 * The number of VFs that are allocated to the function.
+	 * This is valid only on the PF with SR-IOV enabled.
+	 * 0xFF... (All Fs) if this command is called on a PF with
+	 * SR-IOV disabled or on a VF.
 	 */
-	uint16_t	vf_id;
+	uint16_t	alloc_vfs;
 	/*
-	 * This field represents the number of pages used for request
-	 * buffer(s).
+	 * The number of allocated multicast filters for this
+	 * function on the RX side.
 	 */
-	uint16_t	req_buf_num_pages;
+	uint32_t	alloc_mcast_filters;
 	/*
-	 * This field represents the page size used for request
-	 * buffer(s).
+	 * The number of allocated HW ring groups for this
+	 * function.
 	 */
-	uint16_t	req_buf_page_size;
-	/* 16 bytes */
-	#define HWRM_FUNC_BUF_RGTR_INPUT_REQ_BUF_PAGE_SIZE_16B UINT32_C(0x4)
-	/* 4 Kbytes */
-	#define HWRM_FUNC_BUF_RGTR_INPUT_REQ_BUF_PAGE_SIZE_4K  UINT32_C(0xc)
-	/* 8 Kbytes */
-	#define HWRM_FUNC_BUF_RGTR_INPUT_REQ_BUF_PAGE_SIZE_8K  UINT32_C(0xd)
-	/* 64 Kbytes */
-	#define HWRM_FUNC_BUF_RGTR_INPUT_REQ_BUF_PAGE_SIZE_64K UINT32_C(0x10)
-	/* 2 Mbytes */
-	#define HWRM_FUNC_BUF_RGTR_INPUT_REQ_BUF_PAGE_SIZE_2M  UINT32_C(0x15)
-	/* 4 Mbytes */
-	#define HWRM_FUNC_BUF_RGTR_INPUT_REQ_BUF_PAGE_SIZE_4M  UINT32_C(0x16)
-	/* 1 Gbytes */
-	#define HWRM_FUNC_BUF_RGTR_INPUT_REQ_BUF_PAGE_SIZE_1G  UINT32_C(0x1e)
-	#define HWRM_FUNC_BUF_RGTR_INPUT_REQ_BUF_PAGE_SIZE_LAST HWRM_FUNC_BUF_RGTR_INPUT_REQ_BUF_PAGE_SIZE_1G
-	/* The length of the request buffer per VF in bytes. */
-	uint16_t	req_buf_len;
-	/* The length of the response buffer in bytes. */
-	uint16_t	resp_buf_len;
-	uint8_t	unused_0[2];
-	/* This field represents the page address of page #0. */
-	uint64_t	req_buf_page_addr0;
-	/* This field represents the page address of page #1. */
-	uint64_t	req_buf_page_addr1;
-	/* This field represents the page address of page #2. */
-	uint64_t	req_buf_page_addr2;
-	/* This field represents the page address of page #3. */
-	uint64_t	req_buf_page_addr3;
-	/* This field represents the page address of page #4. */
-	uint64_t	req_buf_page_addr4;
-	/* This field represents the page address of page #5. */
-	uint64_t	req_buf_page_addr5;
-	/* This field represents the page address of page #6. */
-	uint64_t	req_buf_page_addr6;
-	/* This field represents the page address of page #7. */
-	uint64_t	req_buf_page_addr7;
-	/* This field represents the page address of page #8. */
-	uint64_t	req_buf_page_addr8;
-	/* This field represents the page address of page #9. */
-	uint64_t	req_buf_page_addr9;
+	uint32_t	alloc_hw_ring_grps;
 	/*
-	 * This field is used to receive the error reporting from
-	 * the chipset. Only applicable for PFs.
+	 * The number of strict priority transmit rings out of
+	 * currently allocated TX rings to the function
+	 * (alloc_tx_rings).
 	 */
-	uint64_t	error_buf_addr;
+	uint16_t	alloc_sp_tx_rings;
 	/*
-	 * This field is used to receive the response forwarded by the
-	 * HWRM.
+	 * The number of statistics contexts
+	 * currently reserved for the function.
 	 */
-	uint64_t	resp_buf_addr;
-} hwrm_func_buf_rgtr_input_t, *phwrm_func_buf_rgtr_input_t;
-
-/* hwrm_func_buf_rgtr_output (size:128b/16B) */
-
-typedef struct hwrm_func_buf_rgtr_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	uint16_t	alloc_stat_ctx;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * This field specifies how many NQs are reserved for the PF.
+	 * Remaining NQs that belong to the PF are available for VFs.
+	 * Once a PF has created VFs, it cannot change how many NQs are
+	 * reserved for itself (since the NQs must be contiguous in HW).
 	 */
-	uint8_t	valid;
-} hwrm_func_buf_rgtr_output_t, *phwrm_func_buf_rgtr_output_t;
-
-/************************
- * hwrm_func_buf_unrgtr *
- ************************/
-
-
-/* hwrm_func_buf_unrgtr_input (size:192b/24B) */
-
-typedef struct hwrm_func_buf_unrgtr_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	uint16_t	alloc_msix;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * The number of registered VF's associated with the PF. This field
+	 * should be ignored when the request received on the VF interface.
+	 * This field will be updated on the PF interface to initiate
+	 * the unregister request on PF in the HOT Reset Process.
 	 */
-	uint16_t	cmpl_ring;
+	uint16_t	registered_vfs;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * The size of the doorbell BAR in KBytes reserved for L2 including
+	 * any area that is shared between L2 and RoCE. The L2 driver
+	 * should only map the L2 portion of the doorbell BAR. Any rounding
+	 * of the BAR size to the native CPU page size should be performed
+	 * by the driver. If the value is zero, no special partitioning
+	 * of the doorbell BAR between L2 and RoCE is required.
 	 */
-	uint16_t	seq_id;
+	uint16_t	l2_doorbell_bar_size_kb;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * A bitmask indicating the active endpoints. Each bit represents a
+	 * specific endpoint, with bit 0 indicating EP 0 and bit 3 indicating
+	 * EP 3. For example:
+	 * - a single root system would return 0x1
+	 * - a 2x8 system (where EPs 0 and 2 are active) would return 0x5
+	 * - a 4x4 system (where EPs 0-3 are active) would return 0xF
 	 */
-	uint16_t	target_id;
+	uint8_t	active_endpoints;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * For backward compatibility this field must be set to 1.
+	 * Older drivers might look for this field to be 1 before
+	 * processing the message.
 	 */
-	uint64_t	resp_addr;
-	uint32_t	enables;
+	uint8_t	always_1;
 	/*
-	 * This bit must be '1' for the vf_id field to be
-	 * configured.
+	 * This GRC address location is used by the Host driver interfaces to
+	 * poll the adapter ready state to re-initiate the registration process
+	 * again after receiving the RESET Notify event.
 	 */
-	#define HWRM_FUNC_BUF_UNRGTR_INPUT_ENABLES_VF_ID	UINT32_C(0x1)
+	uint32_t	reset_addr_poll;
 	/*
-	 * This value is used to identify a Virtual Function (VF).
-	 * The scope of VF ID is local within a PF.
+	 * This field specifies legacy L2 doorbell size in KBytes. Drivers
+	 * should use this value to find out the doorbell page offset from the
+	 * BAR.
 	 */
-	uint16_t	vf_id;
-	uint8_t	unused_0[2];
-} hwrm_func_buf_unrgtr_input_t, *phwrm_func_buf_unrgtr_input_t;
-
-/* hwrm_func_buf_unrgtr_output (size:128b/16B) */
-
-typedef struct hwrm_func_buf_unrgtr_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	uint16_t	legacy_l2_db_size_kb;
+	uint16_t	svif_info;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * This field specifies the source virtual interface of the function
+	 * being queried. Drivers can use this to program svif field in the
+	 * L2 context table
 	 */
-	uint8_t	valid;
-} hwrm_func_buf_unrgtr_output_t, *phwrm_func_buf_unrgtr_output_t;
-
-/**********************
- * hwrm_func_drv_qver *
- **********************/
-
-
-/* hwrm_func_drv_qver_input (size:192b/24B) */
-
-typedef struct hwrm_func_drv_qver_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define HWRM_FUNC_QCFG_OUTPUT_SVIF_INFO_SVIF_MASK	UINT32_C(0x7fff)
+	#define HWRM_FUNC_QCFG_OUTPUT_SVIF_INFO_SVIF_SFT	0
+	/* This field specifies whether svif is valid or not */
+	#define HWRM_FUNC_QCFG_OUTPUT_SVIF_INFO_SVIF_VALID	UINT32_C(0x8000)
+	uint8_t	mpc_chnls;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * When this bit is '1', it indicates that a MPC channel with
+	 * destination set to the TX crypto engine block is enabled.
 	 */
-	uint16_t	cmpl_ring;
+	#define HWRM_FUNC_QCFG_OUTPUT_MPC_CHNLS_TCE_ENABLED	UINT32_C(0x1)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * When this bit is '1', it indicates that a MPC channel with
+	 * destination set to the RX crypto engine block is enabled.
 	 */
-	uint16_t	seq_id;
+	#define HWRM_FUNC_QCFG_OUTPUT_MPC_CHNLS_RCE_ENABLED	UINT32_C(0x2)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * When this bit is '1', it indicates that a MPC channel with
+	 * destination set to the TX configurable flow processing block is
+	 * enabled.
 	 */
-	uint16_t	target_id;
+	#define HWRM_FUNC_QCFG_OUTPUT_MPC_CHNLS_TE_CFA_ENABLED	UINT32_C(0x4)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * When this bit is '1', it indicates that a MPC channel with
+	 * destination set to the RX configurable flow processing block is
+	 * enabled.
 	 */
-	uint64_t	resp_addr;
-	/* Reserved for future use. */
-	uint32_t	reserved;
+	#define HWRM_FUNC_QCFG_OUTPUT_MPC_CHNLS_RE_CFA_ENABLED	UINT32_C(0x8)
 	/*
-	 * Function ID of the function that is being queried.
-	 * 0xFF... (All Fs) if the query is for the requesting
-	 * function.
+	 * When this bit is '1', it indicates that a MPC channel with
+	 * destination set to the primate processor block is enabled.
 	 */
-	uint16_t	fid;
-	uint8_t	unused_0[2];
-} hwrm_func_drv_qver_input_t, *phwrm_func_drv_qver_input_t;
-
-/* hwrm_func_drv_qver_output (size:256b/32B) */
-
-typedef struct hwrm_func_drv_qver_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* This value indicates the type of OS.  The values are based on CIM_OperatingSystem.mof file as published by the DMTF. */
-	uint16_t	os_type;
-	/* Unknown */
-	#define HWRM_FUNC_DRV_QVER_OUTPUT_OS_TYPE_UNKNOWN   UINT32_C(0x0)
-	/* Other OS not listed below. */
-	#define HWRM_FUNC_DRV_QVER_OUTPUT_OS_TYPE_OTHER	UINT32_C(0x1)
-	/* MSDOS OS. */
-	#define HWRM_FUNC_DRV_QVER_OUTPUT_OS_TYPE_MSDOS	UINT32_C(0xe)
-	/* Windows OS. */
-	#define HWRM_FUNC_DRV_QVER_OUTPUT_OS_TYPE_WINDOWS   UINT32_C(0x12)
-	/* Solaris OS. */
-	#define HWRM_FUNC_DRV_QVER_OUTPUT_OS_TYPE_SOLARIS   UINT32_C(0x1d)
-	/* Linux OS. */
-	#define HWRM_FUNC_DRV_QVER_OUTPUT_OS_TYPE_LINUX	UINT32_C(0x24)
-	/* FreeBSD OS. */
-	#define HWRM_FUNC_DRV_QVER_OUTPUT_OS_TYPE_FREEBSD   UINT32_C(0x2a)
-	/* VMware ESXi OS. */
-	#define HWRM_FUNC_DRV_QVER_OUTPUT_OS_TYPE_ESXI	UINT32_C(0x68)
-	/* Microsoft Windows 8 64-bit OS. */
-	#define HWRM_FUNC_DRV_QVER_OUTPUT_OS_TYPE_WIN864	UINT32_C(0x73)
-	/* Microsoft Windows Server 2012 R2 OS. */
-	#define HWRM_FUNC_DRV_QVER_OUTPUT_OS_TYPE_WIN2012R2 UINT32_C(0x74)
-	/* UEFI driver. */
-	#define HWRM_FUNC_DRV_QVER_OUTPUT_OS_TYPE_UEFI	UINT32_C(0x8000)
-	#define HWRM_FUNC_DRV_QVER_OUTPUT_OS_TYPE_LAST	HWRM_FUNC_DRV_QVER_OUTPUT_OS_TYPE_UEFI
-	/* This is the 8bit major version of the driver. */
-	uint8_t	ver_maj_8b;
-	/* This is the 8bit minor version of the driver. */
-	uint8_t	ver_min_8b;
-	/* This is the 8bit update version of the driver. */
-	uint8_t	ver_upd_8b;
-	uint8_t	unused_0[3];
-	/* This is the 16bit major version of the driver. */
-	uint16_t	ver_maj;
-	/* This is the 16bit minor version of the driver. */
-	uint16_t	ver_min;
-	/* This is the 16bit update version of the driver. */
-	uint16_t	ver_upd;
-	/* This is the 16bit patch version of the driver. */
-	uint16_t	ver_patch;
-	uint8_t	unused_1[7];
+	#define HWRM_FUNC_QCFG_OUTPUT_MPC_CHNLS_PRIMATE_ENABLED	UINT32_C(0x10)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * Configured doorbell page size for this function.
+	 * This field is valid for PF only.
+	 */
+	uint8_t	db_page_size;
+	/* DB page size is 4KB. */
+	#define HWRM_FUNC_QCFG_OUTPUT_DB_PAGE_SIZE_4KB   UINT32_C(0x0)
+	/* DB page size is 8KB. */
+	#define HWRM_FUNC_QCFG_OUTPUT_DB_PAGE_SIZE_8KB   UINT32_C(0x1)
+	/* DB page size is 16KB. */
+	#define HWRM_FUNC_QCFG_OUTPUT_DB_PAGE_SIZE_16KB  UINT32_C(0x2)
+	/* DB page size is 32KB. */
+	#define HWRM_FUNC_QCFG_OUTPUT_DB_PAGE_SIZE_32KB  UINT32_C(0x3)
+	/* DB page size is 64KB. */
+	#define HWRM_FUNC_QCFG_OUTPUT_DB_PAGE_SIZE_64KB  UINT32_C(0x4)
+	/* DB page size is 128KB. */
+	#define HWRM_FUNC_QCFG_OUTPUT_DB_PAGE_SIZE_128KB UINT32_C(0x5)
+	/* DB page size is 256KB. */
+	#define HWRM_FUNC_QCFG_OUTPUT_DB_PAGE_SIZE_256KB UINT32_C(0x6)
+	/* DB page size is 512KB. */
+	#define HWRM_FUNC_QCFG_OUTPUT_DB_PAGE_SIZE_512KB UINT32_C(0x7)
+	/* DB page size is 1MB. */
+	#define HWRM_FUNC_QCFG_OUTPUT_DB_PAGE_SIZE_1MB   UINT32_C(0x8)
+	/* DB page size is 2MB. */
+	#define HWRM_FUNC_QCFG_OUTPUT_DB_PAGE_SIZE_2MB   UINT32_C(0x9)
+	/* DB page size is 4MB. */
+	#define HWRM_FUNC_QCFG_OUTPUT_DB_PAGE_SIZE_4MB   UINT32_C(0xa)
+	#define HWRM_FUNC_QCFG_OUTPUT_DB_PAGE_SIZE_LAST HWRM_FUNC_QCFG_OUTPUT_DB_PAGE_SIZE_4MB
+	/*
+	 * RoCE VNIC ID for the function. If the function does not have a valid
+	 * RoCE vnic id, then the roce_vnic_id_valid bit in flags is set to 0.
+	 */
+	uint16_t	roce_vnic_id;
+	/*
+	 * Minimum guaranteed bandwidth for the network partition made up
+	 * of the caller physical function and all its child virtual
+	 * functions. The rate is specified as a percentage of the bandwidth
+	 * of the link the partition is associated with. A value of 0
+	 * indicates that no minimum bandwidth is configured.
+	 * The format of this field is defined to match min_bw, even though
+	 * the partition minimum rate is always specified as a percentage.
 	 */
-	uint8_t	valid;
-} hwrm_func_drv_qver_output_t, *phwrm_func_drv_qver_output_t;
-
-/****************************
- * hwrm_func_resource_qcaps *
- ****************************/
-
-
-/* hwrm_func_resource_qcaps_input (size:192b/24B) */
-
-typedef struct hwrm_func_resource_qcaps_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	uint32_t	partition_min_bw;
+	/* The bandwidth value. */
+	#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MIN_BW_BW_VALUE_SFT		0
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * The granularity of the value (bits or bytes). Firmware never sets
+	 * this field.
 	 */
-	uint16_t	cmpl_ring;
+	#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MIN_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MIN_BW_SCALE_LAST		HWRM_FUNC_QCFG_OUTPUT_PARTITION_MIN_BW_SCALE_BYTES
+	/* Always percentage of link bandwidth. */
+	#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MIN_BW_BW_VALUE_UNIT_SFT	29
+	/* Bandwidth value is in hundredths of a percent of link bandwidth. */
+		#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+		#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_FUNC_QCFG_OUTPUT_PARTITION_MIN_BW_BW_VALUE_UNIT_PERCENT1_100
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * The maximum bandwidth that may be used by the network partition
+	 * made up of the caller physical function and all its child virtual
+	 * functions. The rate is specified as a percentage of the bandwidth
+	 * of the link the partition is associated with. A value of 0
+	 * indicates that no maximum bandwidth is configured.
+	 * The format of this field is defined to match max_bw, even though
+	 * the partition bandwidth must be specified as a percentage.
 	 */
-	uint16_t	seq_id;
+	uint32_t	partition_max_bw;
+	/* The bandwidth value. */
+	#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MAX_BW_BW_VALUE_SFT		0
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * The granularity of the value (bits or bytes). Firmware never sets
+	 * this field.
 	 */
-	uint16_t	target_id;
+	#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MAX_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MAX_BW_SCALE_LAST		HWRM_FUNC_QCFG_OUTPUT_PARTITION_MAX_BW_SCALE_BYTES
+	/* Always a percentage of link bandwidth. */
+	#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MAX_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in hundredths of a percent of link bandwidth. */
+		#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+		#define HWRM_FUNC_QCFG_OUTPUT_PARTITION_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_FUNC_QCFG_OUTPUT_PARTITION_MAX_BW_BW_VALUE_UNIT_PERCENT1_100
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * The maximum transmission unit of the function
+	 * configured by the host pf/vf.
+	 * If the reported mtu value is non-zero then it will be used for the
+	 * rings allocated on this function, otherwise the default
+	 * value is used if ring MTU is not specified.
 	 */
-	uint64_t	resp_addr;
+	uint16_t	host_mtu;
+	uint8_t	unused_3[2];
+	uint8_t	unused_4[2];
 	/*
-	 * Function ID of the function that is being queried.
-	 * 0xFF... (All Fs) if the query is for the requesting
-	 * function.
+	 * KDNet mode for the port for this function. If a VF, KDNet
+	 * mode is always disabled.
 	 */
-	uint16_t	fid;
-	uint8_t	unused_0[6];
-} hwrm_func_resource_qcaps_input_t, *phwrm_func_resource_qcaps_input_t;
-
-/* hwrm_func_resource_qcaps_output (size:448b/56B) */
-
-typedef struct hwrm_func_resource_qcaps_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Maximum guaranteed number of VFs supported by PF. Not applicable for VFs. */
-	uint16_t	max_vfs;
-	/* Maximum guaranteed number of MSI-X vectors supported by function */
-	uint16_t	max_msix;
-	/* Hint of strategy to be used by PF driver to reserve resources for its VF */
-	uint16_t	vf_reservation_strategy;
-	/* The PF driver should evenly divide its remaining resources among all VFs. */
-	#define HWRM_FUNC_RESOURCE_QCAPS_OUTPUT_VF_RESERVATION_STRATEGY_MAXIMAL	UINT32_C(0x0)
-	/* The PF driver should only reserve minimal resources for each VF. */
-	#define HWRM_FUNC_RESOURCE_QCAPS_OUTPUT_VF_RESERVATION_STRATEGY_MINIMAL	UINT32_C(0x1)
+	uint8_t	port_kdnet_mode;
+	/* KDNet mode is not enabled on the port for this function. */
+	#define HWRM_FUNC_QCFG_OUTPUT_PORT_KDNET_MODE_DISABLED UINT32_C(0x0)
+	/* KDNet mode is enabled on the port for this function. */
+	#define HWRM_FUNC_QCFG_OUTPUT_PORT_KDNET_MODE_ENABLED  UINT32_C(0x1)
+	#define HWRM_FUNC_QCFG_OUTPUT_PORT_KDNET_MODE_LAST	HWRM_FUNC_QCFG_OUTPUT_PORT_KDNET_MODE_ENABLED
 	/*
-	 * The PF driver should not reserve any resources for each VF until the
-	 * the VF interface is brought up.
+	 * If KDNet mode is enabled, the PCI function number of the
+	 * KDNet partition.
 	 */
-	#define HWRM_FUNC_RESOURCE_QCAPS_OUTPUT_VF_RESERVATION_STRATEGY_MINIMAL_STATIC UINT32_C(0x2)
-	#define HWRM_FUNC_RESOURCE_QCAPS_OUTPUT_VF_RESERVATION_STRATEGY_LAST	HWRM_FUNC_RESOURCE_QCAPS_OUTPUT_VF_RESERVATION_STRATEGY_MINIMAL_STATIC
-	/* Minimum guaranteed number of RSS/COS contexts */
-	uint16_t	min_rsscos_ctx;
-	/* Maximum non-guaranteed number of RSS/COS contexts */
-	uint16_t	max_rsscos_ctx;
-	/* Minimum guaranteed number of completion rings */
-	uint16_t	min_cmpl_rings;
-	/* Maximum non-guaranteed number of completion rings */
-	uint16_t	max_cmpl_rings;
-	/* Minimum guaranteed number of transmit rings */
-	uint16_t	min_tx_rings;
-	/* Maximum non-guaranteed number of transmit rings */
-	uint16_t	max_tx_rings;
-	/* Minimum guaranteed number of receive rings */
-	uint16_t	min_rx_rings;
-	/* Maximum non-guaranteed number of receive rings */
-	uint16_t	max_rx_rings;
-	/* Minimum guaranteed number of L2 contexts */
-	uint16_t	min_l2_ctxs;
-	/* Maximum non-guaranteed number of L2 contexts */
-	uint16_t	max_l2_ctxs;
-	/* Minimum guaranteed number of VNICs */
-	uint16_t	min_vnics;
-	/* Maximum non-guaranteed number of VNICs */
-	uint16_t	max_vnics;
-	/* Minimum guaranteed number of statistic contexts */
-	uint16_t	min_stat_ctx;
-	/* Maximum non-guaranteed number of statistic contexts */
-	uint16_t	max_stat_ctx;
-	/* Minimum guaranteed number of ring groups */
-	uint16_t	min_hw_ring_grps;
-	/* Maximum non-guaranteed number of ring groups */
-	uint16_t	max_hw_ring_grps;
+	uint8_t	kdnet_pcie_function;
 	/*
-	 * Maximum number of inputs into the transmit scheduler for this function.
-	 * The number of TX rings assigned to the function cannot exceed this value.
+	 * Function ID of the KDNET function on this port. If the
+	 * KDNET partition does not exist and the FW supports this
+	 * feature, 0xffff will be returned.
 	 */
-	uint16_t	max_tx_scheduler_inputs;
-	uint16_t	flags;
+	uint16_t	port_kdnet_fid;
+	uint8_t	unused_5[2];
+	/* Number of KTLS Tx Key Contexts allocated. */
+	uint32_t	num_ktls_tx_key_ctxs;
+	/* Number of KTLS Rx Key Contexts allocated. */
+	uint32_t	num_ktls_rx_key_ctxs;
 	/*
-	 * When this bit is '1', it indicates that VF_RESOURCE_CFG supports
-	 * feature to reserve all minimum resources when minimum >= 1, otherwise
-	 * returns an error.
+	 * The LAG idx of this function. The lag_id is per port and the
+	 * valid lag_id is from 0 to 7, if there is no valid lag_id,
+	 * 0xff will be returned.
+	 * This HW lag id is used for Truflow programming only.
 	 */
-	#define HWRM_FUNC_RESOURCE_QCAPS_OUTPUT_FLAGS_MIN_GUARANTEED	UINT32_C(0x1)
-	uint8_t	unused_0[5];
+	uint8_t	lag_id;
+	/* Partition interface for this function. */
+	uint8_t	parif;
+	/*
+	 * The LAG ID of a hardware link aggregation group (LAG) whose
+	 * member ports include the port of this function. The LAG was
+	 * previously created using HWRM_FUNC_LAG_CREATE. If the port of this
+	 * function is not a member of any LAG, the fw_lag_id will be 0xff.
+	 */
+	uint8_t	fw_lag_id;
+	uint8_t	unused_6;
+	/* Number of QUIC Tx Key Contexts allocated. */
+	uint32_t	num_quic_tx_key_ctxs;
+	/* Number of QUIC Rx Key Contexts allocated. */
+	uint32_t	num_quic_rx_key_ctxs;
+	/*
+	 * Number of AVs per VF. Only valid for PF. This field is ignored
+	 * when the flag, l2_vf_resource_mgmt, is not set in RoCE
+	 * initialize_fw.
+	 */
+	uint32_t	roce_max_av_per_vf;
+	/*
+	 * Number of CQs per VF. Only valid for PF. This field is ignored when
+	 * the flag, l2_vf_resource_mgmt, is not set in RoCE initialize_fw.
+	 */
+	uint32_t	roce_max_cq_per_vf;
+	/*
+	 * Number of MR/MWs per VF. Only valid for PF. This field is ignored
+	 * when the flag, l2_vf_resource_mgmt, is not set in RoCE
+	 * initialize_fw.
+	 */
+	uint32_t	roce_max_mrw_per_vf;
+	/*
+	 * Number of QPs per VF. Only valid for PF. This field is ignored when
+	 * the flag, l2_vf_resource_mgmt, is not set in RoCE initialize_fw.
+	 */
+	uint32_t	roce_max_qp_per_vf;
+	/*
+	 * Number of SRQs per VF. Only valid for PF. This field is ignored
+	 * when the flag, l2_vf_resource_mgmt, is not set in RoCE
+	 * initialize_fw.
+	 */
+	uint32_t	roce_max_srq_per_vf;
+	/*
+	 * Number of GIDs per VF. Only valid for PF. This field is ignored
+	 * when the flag, l2_vf_resource_mgmt, is not set in RoCE
+	 * initialize_fw.
+	 */
+	uint32_t	roce_max_gid_per_vf;
+	/*
+	 * Bitmap of context types that have XID partition enabled.
+	 * Only valid for PF.
+	 */
+	uint16_t	xid_partition_cfg;
+	/*
+	 * When this bit is '1', it indicates that driver enables XID
+	 * partition on Tx crypto key contexts.
+	 */
+	#define HWRM_FUNC_QCFG_OUTPUT_XID_PARTITION_CFG_TX_CK	UINT32_C(0x1)
+	/*
+	 * When this bit is '1', it indicates that driver enables XID
+	 * partition on Rx crypto key contexts.
+	 */
+	#define HWRM_FUNC_QCFG_OUTPUT_XID_PARTITION_CFG_RX_CK	UINT32_C(0x2)
+	uint8_t	unused_7;
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
 	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_func_resource_qcaps_output_t, *phwrm_func_resource_qcaps_output_t;
+} hwrm_func_qcfg_output_t, *phwrm_func_qcfg_output_t;
 
-/*****************************
- * hwrm_func_vf_resource_cfg *
- *****************************/
+/*****************
+ * hwrm_func_cfg *
+ *****************/
 
 
-/* hwrm_func_vf_resource_cfg_input (size:448b/56B) */
+/* hwrm_func_cfg_input (size:1280b/160B) */
 
-typedef struct hwrm_func_vf_resource_cfg_input {
+typedef struct hwrm_func_cfg_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -14198,1407 +16086,1035 @@ typedef struct hwrm_func_vf_resource_cfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* VF ID that is being configured by PF */
-	uint16_t	vf_id;
-	/* Maximum guaranteed number of MSI-X vectors for the function */
-	uint16_t	max_msix;
-	/* Minimum guaranteed number of RSS/COS contexts */
-	uint16_t	min_rsscos_ctx;
-	/* Maximum non-guaranteed number of RSS/COS contexts */
-	uint16_t	max_rsscos_ctx;
-	/* Minimum guaranteed number of completion rings */
-	uint16_t	min_cmpl_rings;
-	/* Maximum non-guaranteed number of completion rings */
-	uint16_t	max_cmpl_rings;
-	/* Minimum guaranteed number of transmit rings */
-	uint16_t	min_tx_rings;
-	/* Maximum non-guaranteed number of transmit rings */
-	uint16_t	max_tx_rings;
-	/* Minimum guaranteed number of receive rings */
-	uint16_t	min_rx_rings;
-	/* Maximum non-guaranteed number of receive rings */
-	uint16_t	max_rx_rings;
-	/* Minimum guaranteed number of L2 contexts */
-	uint16_t	min_l2_ctxs;
-	/* Maximum non-guaranteed number of L2 contexts */
-	uint16_t	max_l2_ctxs;
-	/* Minimum guaranteed number of VNICs */
-	uint16_t	min_vnics;
-	/* Maximum non-guaranteed number of VNICs */
-	uint16_t	max_vnics;
-	/* Minimum guaranteed number of statistic contexts */
-	uint16_t	min_stat_ctx;
-	/* Maximum non-guaranteed number of statistic contexts */
-	uint16_t	max_stat_ctx;
-	/* Minimum guaranteed number of ring groups */
-	uint16_t	min_hw_ring_grps;
-	/* Maximum non-guaranteed number of ring groups */
-	uint16_t	max_hw_ring_grps;
-	uint16_t	flags;
 	/*
-	 * If this bit is set, all minimum resources requested should be
-	 * reserved if minimum >= 1, otherwise return error. In case of
-	 * error, keep all existing reservations before the call.
+	 * Function ID of the function that is being
+	 * configured.
+	 * If set to 0xFF... (All Fs), then the configuration is
+	 * for the requesting function.
 	 */
-	#define HWRM_FUNC_VF_RESOURCE_CFG_INPUT_FLAGS_MIN_GUARANTEED	UINT32_C(0x1)
-	uint8_t	unused_0[2];
-} hwrm_func_vf_resource_cfg_input_t, *phwrm_func_vf_resource_cfg_input_t;
-
-/* hwrm_func_vf_resource_cfg_output (size:256b/32B) */
-
-typedef struct hwrm_func_vf_resource_cfg_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Reserved number of RSS/COS contexts */
-	uint16_t	reserved_rsscos_ctx;
-	/* Reserved number of completion rings */
-	uint16_t	reserved_cmpl_rings;
-	/* Reserved number of transmit rings */
-	uint16_t	reserved_tx_rings;
-	/* Reserved number of receive rings */
-	uint16_t	reserved_rx_rings;
-	/* Reserved number of L2 contexts */
-	uint16_t	reserved_l2_ctxs;
-	/* Reserved number of VNICs */
-	uint16_t	reserved_vnics;
-	/* Reserved number of statistic contexts */
-	uint16_t	reserved_stat_ctx;
-	/* Reserved number of ring groups */
-	uint16_t	reserved_hw_ring_grps;
-	uint8_t	unused_0[7];
+	uint16_t	fid;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * This field specifies how many NQs will be reserved for the PF.
+	 * Remaining NQs that belong to the PF become available for VFs.
+	 * Once a PF has created VFs, it cannot change how many NQs are
+	 * reserved for itself (since the NQs must be contiguous in HW).
 	 */
-	uint8_t	valid;
-} hwrm_func_vf_resource_cfg_output_t, *phwrm_func_vf_resource_cfg_output_t;
-
-/*********************************
- * hwrm_func_backing_store_qcaps *
- *********************************/
-
-
-/* hwrm_func_backing_store_qcaps_input (size:128b/16B) */
-
-typedef struct hwrm_func_backing_store_qcaps_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	uint16_t	num_msix;
+	uint32_t	flags;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * When this bit is '1', the function is disabled with
+	 * source MAC address check.
+	 * This is an anti-spoofing check. If this flag is set,
+	 * then the function shall be configured to disallow
+	 * transmission of frames with the source MAC address that
+	 * is configured for this function.
 	 */
-	uint16_t	cmpl_ring;
+	#define HWRM_FUNC_CFG_INPUT_FLAGS_SRC_MAC_ADDR_CHECK_DISABLE	UINT32_C(0x1)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * When this bit is '1', the function is enabled with
+	 * source MAC address check.
+	 * This is an anti-spoofing check. If this flag is set,
+	 * then the function shall be configured to allow
+	 * transmission of frames with the source MAC address that
+	 * is configured for this function.
 	 */
-	uint16_t	seq_id;
+	#define HWRM_FUNC_CFG_INPUT_FLAGS_SRC_MAC_ADDR_CHECK_ENABLE	UINT32_C(0x2)
+	/* reserved. */
+	#define HWRM_FUNC_CFG_INPUT_FLAGS_RSVD_MASK			UINT32_C(0x1fc)
+	#define HWRM_FUNC_CFG_INPUT_FLAGS_RSVD_SFT			2
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Standard TX Ring mode is used for the allocation of TX ring
+	 * and underlying scheduling resources that allow bandwidth
+	 * reservation and limit settings on the queried function.
+	 * If set to 1, then standard TX ring mode is requested to be
+	 * enabled on the function being configured.
 	 */
-	uint16_t	target_id;
+	#define HWRM_FUNC_CFG_INPUT_FLAGS_STD_TX_RING_MODE_ENABLE	UINT32_C(0x200)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Standard TX Ring mode is used for the allocation of TX ring
+	 * and underlying scheduling resources that allow bandwidth
+	 * reservation and limit settings on the queried function.
+	 * If set to 1, then the standard TX ring mode is requested to
+	 * be disabled on the function being configured. In this extended
+	 * TX ring resource mode, the minimum and maximum bandwidth settings
+	 * are not supported to allow the allocation of TX rings to
+	 * span multiple scheduler nodes.
 	 */
-	uint64_t	resp_addr;
-} hwrm_func_backing_store_qcaps_input_t, *phwrm_func_backing_store_qcaps_input_t;
-
-/* hwrm_func_backing_store_qcaps_output (size:832b/104B) */
-
-typedef struct hwrm_func_backing_store_qcaps_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Maximum number of QP context entries supported for this function. */
-	uint32_t	qp_max_entries;
+	#define HWRM_FUNC_CFG_INPUT_FLAGS_STD_TX_RING_MODE_DISABLE	UINT32_C(0x400)
 	/*
-	 * Minimum number of QP context entries that are needed to be reserved
-	 * for QP1 for the PF and its VFs. PF drivers must allocate at least
-	 * this many QP context entries, even if RoCE will not be used.
+	 * If this bit is set, virtual mac address configured
+	 * in this command will be persistent over warm boot.
 	 */
-	uint16_t	qp_min_qp1_entries;
-	/* Maximum number of QP context entries that can be used for L2. */
-	uint16_t	qp_max_l2_entries;
-	/* Number of bytes that must be allocated for each context entry. */
-	uint16_t	qp_entry_size;
-	/* Maximum number of SRQ context entries that can be used for L2. */
-	uint16_t	srq_max_l2_entries;
-	/* Maximum number of SRQ context entries supported for this function. */
-	uint32_t	srq_max_entries;
-	/* Number of bytes that must be allocated for each context entry. */
-	uint16_t	srq_entry_size;
-	/* Maximum number of CQ context entries that can be used for L2. */
-	uint16_t	cq_max_l2_entries;
-	/* Maximum number of CQ context entries supported for this function. */
-	uint32_t	cq_max_entries;
-	/* Number of bytes that must be allocated for each context entry. */
-	uint16_t	cq_entry_size;
-	/* Maximum number of VNIC context entries supported for this function. */
-	uint16_t	vnic_max_vnic_entries;
-	/* Maximum number of Ring table context entries supported for this function. */
-	uint16_t	vnic_max_ring_table_entries;
-	/* Number of bytes that must be allocated for each context entry. */
-	uint16_t	vnic_entry_size;
-	/* Maximum number of statistic context entries supported for this function. */
-	uint32_t	stat_max_entries;
-	/* Number of bytes that must be allocated for each context entry. */
-	uint16_t	stat_entry_size;
-	/* Number of bytes that must be allocated for each context entry. */
-	uint16_t	tqm_entry_size;
-	/* Minimum number of TQM context entries required per ring. */
-	uint32_t	tqm_min_entries_per_ring;
+	#define HWRM_FUNC_CFG_INPUT_FLAGS_VIRT_MAC_PERSIST		UINT32_C(0x800)
 	/*
-	 * Maximum number of TQM context entries supported per ring. This is
-	 * actually a recommended TQM queue size based on worst case usage of
-	 * the TQM queue.
-	 *
-	 * TQM fastpath rings should be sized large enough to accommodate the
-	 * maximum number of QPs (either L2 or RoCE, or both if shared)
-	 * that can be enqueued to the TQM ring.
-	 *
-	 * TQM slowpath rings should be sized as follows:
-	 *
-	 * num_entries = num_vnics + num_l2_tx_rings + 2 * num_roce_qps + tqm_min_size
-	 *
-	 * Where:
-	 *   num_vnics is the number of VNICs allocated in the VNIC backing store
-	 *   num_l2_tx_rings is the number of L2 rings in the QP backing store
-	 *   num_roce_qps is the number of RoCE QPs in the QP backing store
-	 *   tqm_min_size is tqm_min_entries_per_ring reported by
-	 *	HWRM_FUNC_BACKING_STORE_QCAPS
-	 *
-	 * Note that TQM ring sizes cannot be extended while the system is
-	 * operational. If a PF driver needs to extend a TQM ring, it needs
-	 * to reset the function (e.g. HWRM_FUNC_RESET) and then reallocate
-	 * the backing store.
+	 * This bit only applies to the VF. If this bit is set, the statistic
+	 * context counters will not be cleared when the statistic context is
+	 * freed or a function reset is called on VF. This bit will be
+	 * cleared when the PF is unloaded or a function reset is called on
+	 * the PF.
 	 */
-	uint32_t	tqm_max_entries_per_ring;
+	#define HWRM_FUNC_CFG_INPUT_FLAGS_NO_AUTOCLEAR_STATISTIC	UINT32_C(0x1000)
 	/*
-	 * Maximum number of MR plus AV context entries supported for this
-	 * function.
+	 * This bit requests that the firmware test to see if all the assets
+	 * requested in this command (i.e. number of TX rings) are available.
+	 * The firmware will return an error if the requested assets are
+	 * not available. The firmware will NOT reserve the assets if they
+	 * are available.
 	 */
-	uint32_t	mrav_max_entries;
-	/* Number of bytes that must be allocated for each context entry. */
-	uint16_t	mrav_entry_size;
-	/* Number of bytes that must be allocated for each context entry. */
-	uint16_t	tim_entry_size;
-	/* Maximum number of Timer context entries supported for this function. */
-	uint32_t	tim_max_entries;
+	#define HWRM_FUNC_CFG_INPUT_FLAGS_TX_ASSETS_TEST		UINT32_C(0x2000)
 	/*
-	 * When this field is zero, the 32b `mrav_num_entries` field in the
-	 * `backing_store_cfg` and `backing_store_qcfg` commands represents
-	 * the total number of MR plus AV entries allowed in the MR/AV backing
-	 * store PBL.
-	 *
-	 * When this field is non-zero, the 32b `mrav_num_entries` field in
-	 * the `backing_store_cfg` and `backing_store_qcfg` commands is
-	 * logically divided into two 16b fields. Bits `[31:16]` represents
-	 * the `mr_num_entries` and bits `[15:0]` represents `av_num_entries`.
-	 * Both of these values are represented in a unit granularity
-	 * specified by this field. For example, if this field is 16 and
-	 * `mrav_num_entries` is `0x02000100`, then the number of MR entries
-	 * is 8192 and the number of AV entries is 4096.
+	 * This bit requests that the firmware test to see if all the assets
+	 * requested in this command (i.e. number of RX rings) are available.
+	 * The firmware will return an error if the requested assets are
+	 * not available. The firmware will NOT reserve the assets if they
+	 * are available.
 	 */
-	uint16_t	mrav_num_entries_units;
+	#define HWRM_FUNC_CFG_INPUT_FLAGS_RX_ASSETS_TEST		UINT32_C(0x4000)
 	/*
-	 * The number of entries specified for any TQM ring must be a
-	 * multiple of this value to prevent any resource allocation
-	 * limitations.
+	 * This bit requests that the firmware test to see if all the assets
+	 * requested in this command (i.e. number of CMPL rings) are
+	 * available. The firmware will return an error if the requested
+	 * assets are not available. The firmware will NOT reserve the assets
+	 * if they are available.
 	 */
-	uint8_t	tqm_entries_multiple;
+	#define HWRM_FUNC_CFG_INPUT_FLAGS_CMPL_ASSETS_TEST		UINT32_C(0x8000)
 	/*
-	 * Initializer to be used by drivers
-	 * to initialize context memory to ensure
-	 * context subsystem flags an error for an attack
-	 * before the first time context load.
+	 * This bit requests that the firmware test to see if all the assets
+	 * requested in this command (i.e. number of RSS ctx) are available.
+	 * The firmware will return an error if the requested assets are
+	 * not available. The firmware will NOT reserve the assets if they
+	 * are available.
 	 */
-	uint8_t	ctx_kind_initializer;
+	#define HWRM_FUNC_CFG_INPUT_FLAGS_RSSCOS_CTX_ASSETS_TEST	UINT32_C(0x10000)
 	/*
-	 * Specifies which context kinds need to be initialized with the
-	 * ctx_kind_initializer.
+	 * This bit requests that the firmware test to see if all the assets
+	 * requested in this command (i.e. number of ring groups) are
+	 * available. The firmware will return an error if the requested
+	 * assets are not available. The firmware will NOT reserve the assets
+	 * if they are available.
 	 */
-	uint16_t	ctx_init_mask;
+	#define HWRM_FUNC_CFG_INPUT_FLAGS_RING_GRP_ASSETS_TEST	UINT32_C(0x20000)
 	/*
-	 * If this bit is '1' then this context type should be initialized
-	 * with the ctx_kind_initializer at the specified offset.
+	 * This bit requests that the firmware test to see if all the assets
+	 * requested in this command (i.e. number of stat ctx) are available.
+	 * The firmware will return an error if the requested assets are
+	 * not available. The firmware will NOT reserve the assets if they
+	 * are available.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_QCAPS_OUTPUT_CTX_INIT_MASK_QP	UINT32_C(0x1)
+	#define HWRM_FUNC_CFG_INPUT_FLAGS_STAT_CTX_ASSETS_TEST	UINT32_C(0x40000)
 	/*
-	 * If this bit is '1' then this context type should be initialized
-	 * with the ctx_kind_initializer at the specified offset.
+	 * This bit requests that the firmware test to see if all the assets
+	 * requested in this command (i.e. number of VNICs) are available.
+	 * The firmware will return an error if the requested assets are
+	 * not available. The firmware will NOT reserve the assets if they
+	 * are available.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_QCAPS_OUTPUT_CTX_INIT_MASK_SRQ	UINT32_C(0x2)
+	#define HWRM_FUNC_CFG_INPUT_FLAGS_VNIC_ASSETS_TEST		UINT32_C(0x80000)
 	/*
-	 * If this bit is '1' then this context type should be initialized
-	 * with the ctx_kind_initializer at the specified offset.
+	 * This bit requests that the firmware test to see if all the assets
+	 * requested in this command (i.e. number of L2 ctx) are available.
+	 * The firmware will return an error if the requested assets are
+	 * not available. The firmware will NOT reserve the assets if they
+	 * are available.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_QCAPS_OUTPUT_CTX_INIT_MASK_CQ	UINT32_C(0x4)
+	#define HWRM_FUNC_CFG_INPUT_FLAGS_L2_CTX_ASSETS_TEST		UINT32_C(0x100000)
 	/*
-	 * If this bit is '1' then this context type should be initialized
-	 * with the ctx_kind_initializer at the specified offset.
+	 * This configuration change can be initiated by a PF driver. This
+	 * configuration request shall be targeted to a VF. From local host
+	 * resident HWRM clients, only the parent PF driver shall be allowed
+	 * to initiate this change on one of its children VFs. If this bit is
+	 * set to 1, then the VF that is being configured is requested to be
+	 * trusted.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_QCAPS_OUTPUT_CTX_INIT_MASK_VNIC	UINT32_C(0x8)
+	#define HWRM_FUNC_CFG_INPUT_FLAGS_TRUSTED_VF_ENABLE		UINT32_C(0x200000)
 	/*
-	 * If this bit is '1' then this context type should be initialized
-	 * with the ctx_kind_initializer at the specified offset.
+	 * When this bit it set, even if PF reserved pool size is zero,
+	 * FW will allow driver to create TX rings in ring alloc,
+	 * by reserving TX ring, S3 node dynamically.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_QCAPS_OUTPUT_CTX_INIT_MASK_STAT	UINT32_C(0x10)
+	#define HWRM_FUNC_CFG_INPUT_FLAGS_DYNAMIC_TX_RING_ALLOC	UINT32_C(0x400000)
 	/*
-	 * If this bit is '1' then this context type should be initialized
-	 * with the ctx_kind_initializer at the specified offset.
+	 * This bit requests that the firmware test to see if all the assets
+	 * requested in this command (i.e. number of NQ rings) are available.
+	 * The firmware will return an error if the requested assets are
+	 * not available. The firmware will NOT reserve the assets if they
+	 * are available.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_QCAPS_OUTPUT_CTX_INIT_MASK_MRAV	UINT32_C(0x20)
+	#define HWRM_FUNC_CFG_INPUT_FLAGS_NQ_ASSETS_TEST		UINT32_C(0x800000)
 	/*
-	 * If this bit is '1' then the Tx KTLS context type should be
-	 * initialized with the ctx_kind_initializer at the specified offset.
+	 * This configuration change can be initiated by a PF driver. This
+	 * configuration request shall be targeted to a VF. From local host
+	 * resident HWRM clients, only the parent PF driver shall be allowed
+	 * to initiate this change on one of its children VFs. If this bit is
+	 * set to 1, then the VF that is being configured is requested to be
+	 * untrusted.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_QCAPS_OUTPUT_CTX_INIT_MASK_TKC	UINT32_C(0x40)
+	#define HWRM_FUNC_CFG_INPUT_FLAGS_TRUSTED_VF_DISABLE		UINT32_C(0x1000000)
 	/*
-	 * If this bit is '1' then the Rx KTLS context type should be
-	 * initialized with the ctx_kind_initializer at the specified offset.
+	 * This bit is used by preboot drivers on a PF that require access
+	 * to the legacy L2 ring model and legacy 32b doorbells. This
+	 * feature is not allowed on VFs and is only relevant for devices
+	 * that require a context backing store.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_QCAPS_OUTPUT_CTX_INIT_MASK_RKC	UINT32_C(0x80)
+	#define HWRM_FUNC_CFG_INPUT_FLAGS_PREBOOT_LEGACY_L2_RINGS	UINT32_C(0x2000000)
 	/*
-	 * Specifies the doubleword offset of ctx_kind_initializer for this
-	 * context type.
+	 * If this bit is set to 0, then the interface does not support hot
+	 * reset capability which it advertised with the hot_reset_support
+	 * flag in HWRM_FUNC_DRV_RGTR. If any of the function has set this
+	 * flag to 0, adapter cannot do the hot reset. In this state, if the
+	 * firmware receives a hot reset request, firmware must fail the
+	 * request. If this bit is set to 1, then interface is renabling the
+	 * hot reset capability.
 	 */
-	uint8_t	qp_init_offset;
+	#define HWRM_FUNC_CFG_INPUT_FLAGS_HOT_RESET_IF_EN_DIS		UINT32_C(0x4000000)
 	/*
-	 * Specifies the doubleword offset of ctx_kind_initializer for this
-	 * context type.
+	 * If this bit is set to 1, the PF driver is requesting FW
+	 * to enable PPP TX PUSH feature on all the TX rings specified in
+	 * the num_tx_rings field. By default, the PPP TX push feature is
+	 * disabled for all the TX rings of the function. This flag is
+	 * ignored if num_tx_rings field is not specified or the function
+	 * doesn't support PPP tx push feature.
 	 */
-	uint8_t	srq_init_offset;
+	#define HWRM_FUNC_CFG_INPUT_FLAGS_PPP_PUSH_MODE_ENABLE	UINT32_C(0x8000000)
 	/*
-	 * Specifies the doubleword offset of ctx_kind_initializer for this
-	 * context type.
+	 * If this bit is set to 1, the PF driver is requesting FW
+	 * to disable PPP TX PUSH feature on all the TX rings specified in
+	 * the num_tx_rings field. This flag is ignored if num_tx_rings
+	 * field is not specified or the function doesn't support PPP tx
+	 * push feature.
 	 */
-	uint8_t	cq_init_offset;
+	#define HWRM_FUNC_CFG_INPUT_FLAGS_PPP_PUSH_MODE_DISABLE	UINT32_C(0x10000000)
 	/*
-	 * Specifies the doubleword offset of ctx_kind_initializer for this
-	 * context type.
+	 * If this bit is set to 1, the driver is requesting FW to enable
+	 * the BD_METADATA feature for this function. The FW returns error
+	 * on this request if the TX_METADATA is enabled for this function.
 	 */
-	uint8_t	vnic_init_offset;
+	#define HWRM_FUNC_CFG_INPUT_FLAGS_BD_METADATA_ENABLE		UINT32_C(0x20000000)
 	/*
-	 * Count of TQM fastpath rings to be used for allocating backing store.
-	 * Backing store configuration must be specified for each TQM ring from
-	 * this count in `backing_store_cfg`.
-	 * Only first 8 TQM FP rings will be advertised with this field.
+	 * If this bit is set to 1, the driver is requesting FW to disable
+	 * the BD_METADATA feature for this function. The FW returns error
+	 * on this request if the TX_METADATA is enabled for this function.
 	 */
-	uint8_t	tqm_fp_rings_count;
+	#define HWRM_FUNC_CFG_INPUT_FLAGS_BD_METADATA_DISABLE		UINT32_C(0x40000000)
+	uint32_t	enables;
 	/*
-	 * Specifies the doubleword offset of ctx_kind_initializer for this
-	 * context type.
+	 * This bit must be '1' for the admin_mtu field to be
+	 * configured.
 	 */
-	uint8_t	stat_init_offset;
+	#define HWRM_FUNC_CFG_INPUT_ENABLES_ADMIN_MTU		UINT32_C(0x1)
 	/*
-	 * Specifies the doubleword offset of ctx_kind_initializer for this
-	 * context type.
+	 * This bit must be '1' for the mru field to be
+	 * configured.
 	 */
-	uint8_t	mrav_init_offset;
+	#define HWRM_FUNC_CFG_INPUT_ENABLES_MRU			UINT32_C(0x2)
 	/*
-	 * Count of TQM extended fastpath rings to be used for allocating
-	 * backing store beyond 8 rings(rings 9,10,11)
-	 * Backing store configuration must be specified for each TQM ring from
-	 * this count in `backing_store_cfg`.
+	 * This bit must be '1' for the num_rsscos_ctxs field to be
+	 * configured.
 	 */
-	uint8_t	tqm_fp_rings_count_ext;
+	#define HWRM_FUNC_CFG_INPUT_ENABLES_NUM_RSSCOS_CTXS	UINT32_C(0x4)
 	/*
-	 * Specifies the doubleword offset of ctx_kind_initializer for Tx
-	 * KTLS context type.
+	 * This bit must be '1' for the num_cmpl_rings field to be
+	 * configured.
 	 */
-	uint8_t	tkc_init_offset;
+	#define HWRM_FUNC_CFG_INPUT_ENABLES_NUM_CMPL_RINGS	UINT32_C(0x8)
 	/*
-	 * Specifies the doubleword offset of ctx_kind_initializer for Rx
-	 * KTLS context type.
+	 * This bit must be '1' for the num_tx_rings field to be
+	 * configured.
 	 */
-	uint8_t	rkc_init_offset;
-	/* Tx KTLS context entry size in bytes. */
-	uint16_t	tkc_entry_size;
-	/* Rx KTLS context entry size in bytes. */
-	uint16_t	rkc_entry_size;
+	#define HWRM_FUNC_CFG_INPUT_ENABLES_NUM_TX_RINGS		UINT32_C(0x10)
 	/*
-	 * Maximum number of Tx KTLS context entries supported for this
-	 * function.
+	 * This bit must be '1' for the num_rx_rings field to be
+	 * configured.
 	 */
-	uint32_t	tkc_max_entries;
+	#define HWRM_FUNC_CFG_INPUT_ENABLES_NUM_RX_RINGS		UINT32_C(0x20)
 	/*
-	 * Maximum number of Rx KTLS context entries supported for this
-	 * function.
+	 * This bit must be '1' for the num_l2_ctxs field to be
+	 * configured.
 	 */
-	uint32_t	rkc_max_entries;
-	/* Reserved for future. */
-	uint8_t	rsvd[7];
+	#define HWRM_FUNC_CFG_INPUT_ENABLES_NUM_L2_CTXS		UINT32_C(0x40)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * This bit must be '1' for the num_vnics field to be
+	 * configured.
 	 */
-	uint8_t	valid;
-} hwrm_func_backing_store_qcaps_output_t, *phwrm_func_backing_store_qcaps_output_t;
-
-/* tqm_fp_ring_cfg (size:128b/16B) */
-
-typedef struct tqm_fp_ring_cfg {
-	/* TQM ring page size and level. */
-	uint8_t	tqm_ring_pg_size_tqm_ring_lvl;
-	/* TQM ring PBL indirect levels. */
-	#define TQM_FP_RING_CFG_TQM_RING_CFG_TQM_RING_LVL_MASK	UINT32_C(0xf)
-	#define TQM_FP_RING_CFG_TQM_RING_CFG_TQM_RING_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define TQM_FP_RING_CFG_TQM_RING_CFG_TQM_RING_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define TQM_FP_RING_CFG_TQM_RING_CFG_TQM_RING_LVL_LVL_1	UINT32_C(0x1)
+	#define HWRM_FUNC_CFG_INPUT_ENABLES_NUM_VNICS		UINT32_C(0x80)
 	/*
-	 * PBL pointer points to PDE table with each entry pointing to
-	 * PTE tables.
+	 * This bit must be '1' for the num_stat_ctxs field to be
+	 * configured.
 	 */
-		#define TQM_FP_RING_CFG_TQM_RING_CFG_TQM_RING_LVL_LVL_2	UINT32_C(0x2)
-		#define TQM_FP_RING_CFG_TQM_RING_CFG_TQM_RING_LVL_LAST	TQM_FP_RING_CFG_TQM_RING_CFG_TQM_RING_LVL_LVL_2
-	/* TQM ring page size. */
-	#define TQM_FP_RING_CFG_TQM_RING_CFG_TQM_RING_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define TQM_FP_RING_CFG_TQM_RING_CFG_TQM_RING_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define TQM_FP_RING_CFG_TQM_RING_CFG_TQM_RING_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define TQM_FP_RING_CFG_TQM_RING_CFG_TQM_RING_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define TQM_FP_RING_CFG_TQM_RING_CFG_TQM_RING_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define TQM_FP_RING_CFG_TQM_RING_CFG_TQM_RING_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define TQM_FP_RING_CFG_TQM_RING_CFG_TQM_RING_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define TQM_FP_RING_CFG_TQM_RING_CFG_TQM_RING_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define TQM_FP_RING_CFG_TQM_RING_CFG_TQM_RING_PG_SIZE_LAST   TQM_FP_RING_CFG_TQM_RING_CFG_TQM_RING_PG_SIZE_PG_1G
-	uint8_t	unused[3];
-	/* Number of TQM ring entries. */
-	uint32_t	tqm_ring_num_entries;
-	/* TQM ring page directory. */
-	uint64_t	tqm_ring_page_dir;
-} tqm_fp_ring_cfg_t, *ptqm_fp_ring_cfg_t;
-
-/*******************************
- * hwrm_func_backing_store_cfg *
- *******************************/
-
-
-/* hwrm_func_backing_store_cfg_input (size:2688b/336B) */
-
-typedef struct hwrm_func_backing_store_cfg_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define HWRM_FUNC_CFG_INPUT_ENABLES_NUM_STAT_CTXS		UINT32_C(0x100)
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * This bit must be '1' for the dflt_mac_addr field to be
+	 * configured.
 	 */
-	uint16_t	cmpl_ring;
+	#define HWRM_FUNC_CFG_INPUT_ENABLES_DFLT_MAC_ADDR		UINT32_C(0x200)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * This bit must be '1' for the dflt_vlan field to be
+	 * configured.
 	 */
-	uint16_t	seq_id;
+	#define HWRM_FUNC_CFG_INPUT_ENABLES_DFLT_VLAN		UINT32_C(0x400)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * This bit must be '1' for the dflt_ip_addr field to be
+	 * configured.
 	 */
-	uint16_t	target_id;
+	#define HWRM_FUNC_CFG_INPUT_ENABLES_DFLT_IP_ADDR		UINT32_C(0x800)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * This bit must be '1' for the min_bw field to be
+	 * configured.
 	 */
-	uint64_t	resp_addr;
-	uint32_t	flags;
+	#define HWRM_FUNC_CFG_INPUT_ENABLES_MIN_BW		UINT32_C(0x1000)
 	/*
-	 * When set, the firmware only uses on-chip resources and does not
-	 * expect any backing store to be provided by the host driver. This
-	 * mode provides minimal L2 functionality (e.g. limited L2 resources,
-	 * no RoCE).
+	 * This bit must be '1' for the max_bw field to be
+	 * configured.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_FLAGS_PREBOOT_MODE		UINT32_C(0x1)
+	#define HWRM_FUNC_CFG_INPUT_ENABLES_MAX_BW		UINT32_C(0x2000)
 	/*
-	 * When set, the 32b `mrav_num_entries` field is logically divided
-	 * into two 16b fields, `mr_num_entries` and `av_num_entries`.
+	 * This bit must be '1' for the async_event_cr field to be
+	 * configured.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_FLAGS_MRAV_RESERVATION_SPLIT	UINT32_C(0x2)
-	uint32_t	enables;
+	#define HWRM_FUNC_CFG_INPUT_ENABLES_ASYNC_EVENT_CR	UINT32_C(0x4000)
 	/*
-	 * This bit must be '1' for the qp fields to be
+	 * This bit must be '1' for the vlan_antispoof_mode field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_QP		UINT32_C(0x1)
+	#define HWRM_FUNC_CFG_INPUT_ENABLES_VLAN_ANTISPOOF_MODE	UINT32_C(0x8000)
 	/*
-	 * This bit must be '1' for the srq fields to be
+	 * This bit must be '1' for the allowed_vlan_pris field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_SRQ		UINT32_C(0x2)
+	#define HWRM_FUNC_CFG_INPUT_ENABLES_ALLOWED_VLAN_PRIS	UINT32_C(0x10000)
 	/*
-	 * This bit must be '1' for the cq fields to be
+	 * This bit must be '1' for the evb_mode field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_CQ		UINT32_C(0x4)
+	#define HWRM_FUNC_CFG_INPUT_ENABLES_EVB_MODE		UINT32_C(0x20000)
 	/*
-	 * This bit must be '1' for the vnic fields to be
+	 * This bit must be '1' for the num_mcast_filters field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_VNIC	UINT32_C(0x8)
+	#define HWRM_FUNC_CFG_INPUT_ENABLES_NUM_MCAST_FILTERS	UINT32_C(0x40000)
 	/*
-	 * This bit must be '1' for the stat fields to be
+	 * This bit must be '1' for the num_hw_ring_grps field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_STAT	UINT32_C(0x10)
+	#define HWRM_FUNC_CFG_INPUT_ENABLES_NUM_HW_RING_GRPS	UINT32_C(0x80000)
 	/*
-	 * This bit must be '1' for the tqm_sp fields to be
+	 * This bit must be '1' for the cache_linesize field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_SP	UINT32_C(0x20)
+	#define HWRM_FUNC_CFG_INPUT_ENABLES_CACHE_LINESIZE	UINT32_C(0x100000)
 	/*
-	 * This bit must be '1' for the tqm_ring0 fields to be
+	 * This bit must be '1' for the num_msix field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_RING0	UINT32_C(0x40)
+	#define HWRM_FUNC_CFG_INPUT_ENABLES_NUM_MSIX		UINT32_C(0x200000)
 	/*
-	 * This bit must be '1' for the tqm_ring1 fields to be
+	 * This bit must be '1' for the link admin state field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_RING1	UINT32_C(0x80)
+	#define HWRM_FUNC_CFG_INPUT_ENABLES_ADMIN_LINK_STATE	UINT32_C(0x400000)
 	/*
-	 * This bit must be '1' for the tqm_ring2 fields to be
+	 * This bit must be '1' for the hot_reset_if_en_dis field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_RING2	UINT32_C(0x100)
+	#define HWRM_FUNC_CFG_INPUT_ENABLES_HOT_RESET_IF_SUPPORT	UINT32_C(0x800000)
 	/*
-	 * This bit must be '1' for the tqm_ring3 fields to be
+	 * This bit must be '1' for the schq_id field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_RING3	UINT32_C(0x200)
+	#define HWRM_FUNC_CFG_INPUT_ENABLES_SCHQ_ID		UINT32_C(0x1000000)
 	/*
-	 * This bit must be '1' for the tqm_ring4 fields to be
+	 * This bit must be '1' for the mpc_chnls field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_RING4	UINT32_C(0x400)
+	#define HWRM_FUNC_CFG_INPUT_ENABLES_MPC_CHNLS		UINT32_C(0x2000000)
 	/*
-	 * This bit must be '1' for the tqm_ring5 fields to be
+	 * This bit must be '1' for the partition_min_bw field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_RING5	UINT32_C(0x800)
+	#define HWRM_FUNC_CFG_INPUT_ENABLES_PARTITION_MIN_BW	UINT32_C(0x4000000)
 	/*
-	 * This bit must be '1' for the tqm_ring6 fields to be
+	 * This bit must be '1' for the partition_max_bw field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_RING6	UINT32_C(0x1000)
+	#define HWRM_FUNC_CFG_INPUT_ENABLES_PARTITION_MAX_BW	UINT32_C(0x8000000)
 	/*
-	 * This bit must be '1' for the tqm_ring7 fields to be
+	 * This bit must be '1' for the tpid field to be
+	 * configured. This bit is only valid when dflt_vlan enable
+	 * bit is set.
+	 */
+	#define HWRM_FUNC_CFG_INPUT_ENABLES_TPID			UINT32_C(0x10000000)
+	/*
+	 * This bit must be '1' for the host_mtu field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_RING7	UINT32_C(0x2000)
+	#define HWRM_FUNC_CFG_INPUT_ENABLES_HOST_MTU		UINT32_C(0x20000000)
 	/*
-	 * This bit must be '1' for the mrav fields to be
+	 * This bit must be '1' for the num_ktls_tx_key_ctxs field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_MRAV	UINT32_C(0x4000)
+	#define HWRM_FUNC_CFG_INPUT_ENABLES_KTLS_TX_KEY_CTXS	UINT32_C(0x40000000)
 	/*
-	 * This bit must be '1' for the tim fields to be
+	 * This bit must be '1' for the num_ktls_rx_key_ctxs field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TIM		UINT32_C(0x8000)
+	#define HWRM_FUNC_CFG_INPUT_ENABLES_KTLS_RX_KEY_CTXS	UINT32_C(0x80000000)
 	/*
-	 * This bit must be '1' for the tqm_ring8 fields to be
+	 * This field can be used by the admin PF to configure
+	 * mtu of foster PFs.
+	 * The maximum transmission unit of the function.
+	 * The HWRM should make sure that the mtu of
+	 * the function does not exceed the mtu of the physical
+	 * port that this function is associated with.
+	 *
+	 * In addition to configuring mtu per function, it is
+	 * possible to configure mtu per transmit ring.
+	 * By default, the mtu of each transmit ring associated
+	 * with a function is equal to the mtu of the function.
+	 * The HWRM should make sure that the mtu of each transmit
+	 * ring that is assigned to a function has a valid mtu.
+	 */
+	uint16_t	admin_mtu;
+	/*
+	 * The maximum receive unit of the function.
+	 * The HWRM should make sure that the mru of
+	 * the function does not exceed the mru of the physical
+	 * port that this function is associated with.
+	 *
+	 * In addition to configuring mru per function, it is
+	 * possible to configure mru per vnic.
+	 * By default, the mru of each vnic associated
+	 * with a function is equal to the mru of the function.
+	 * The HWRM should make sure that the mru of each vnic
+	 * that is assigned to a function has a valid mru.
+	 */
+	uint16_t	mru;
+	/*
+	 * The number of RSS/COS contexts requested for the
+	 * function.
+	 */
+	uint16_t	num_rsscos_ctxs;
+	/*
+	 * The number of completion rings requested for the
+	 * function. This does not include the rings allocated
+	 * to any children functions if any.
+	 */
+	uint16_t	num_cmpl_rings;
+	/*
+	 * The number of transmit rings requested for the function.
+	 * This does not include the rings allocated to any
+	 * children functions if any.
+	 */
+	uint16_t	num_tx_rings;
+	/*
+	 * The number of receive rings requested for the function.
+	 * This does not include the rings allocated
+	 * to any children functions if any.
+	 */
+	uint16_t	num_rx_rings;
+	/* The requested number of L2 contexts for the function. */
+	uint16_t	num_l2_ctxs;
+	/* The requested number of vnics for the function. */
+	uint16_t	num_vnics;
+	/* The requested number of statistic contexts for the function. */
+	uint16_t	num_stat_ctxs;
+	/*
+	 * The number of HW ring groups that should
+	 * be reserved for this function.
+	 */
+	uint16_t	num_hw_ring_grps;
+	/* The default MAC address for the function being configured. */
+	uint8_t	dflt_mac_addr[6];
+	/*
+	 * The default VLAN for the function being configured.
+	 * This field's format is same as 802.1Q Tag's
+	 * Tag Control Information (TCI) format that includes both
+	 * Priority Code Point (PCP) and VLAN Identifier (VID).
+	 */
+	uint16_t	dflt_vlan;
+	/*
+	 * The default IP address for the function being configured.
+	 * This address is only used in enabling source property check.
+	 */
+	uint32_t	dflt_ip_addr[4];
+	/*
+	 * Minimum guaranteed transmit bandwidth for this function. When
+	 * specified for a PF, does not affect traffic from the PF's child VFs.
+	 * A value of 0 indicates the minimum bandwidth is not configured.
+	 */
+	uint32_t	min_bw;
+	/* The bandwidth value. */
+	#define HWRM_FUNC_CFG_INPUT_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_FUNC_CFG_INPUT_MIN_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_FUNC_CFG_INPUT_MIN_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_FUNC_CFG_INPUT_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_FUNC_CFG_INPUT_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_FUNC_CFG_INPUT_MIN_BW_SCALE_LAST		HWRM_FUNC_CFG_INPUT_MIN_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_FUNC_CFG_INPUT_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_FUNC_CFG_INPUT_MIN_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_FUNC_CFG_INPUT_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_FUNC_CFG_INPUT_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_FUNC_CFG_INPUT_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_FUNC_CFG_INPUT_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_FUNC_CFG_INPUT_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_FUNC_CFG_INPUT_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_FUNC_CFG_INPUT_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_FUNC_CFG_INPUT_MIN_BW_BW_VALUE_UNIT_INVALID
+	/*
+	 * Maximum transmit rate for this function. When specified for a PF,
+	 * does not affect traffic from the PF's child VFs.
+	 * A value of 0 indicates that the maximum bandwidth is not configured.
+	 */
+	uint32_t	max_bw;
+	/* The bandwidth value. */
+	#define HWRM_FUNC_CFG_INPUT_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_FUNC_CFG_INPUT_MAX_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_FUNC_CFG_INPUT_MAX_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_FUNC_CFG_INPUT_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_FUNC_CFG_INPUT_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_FUNC_CFG_INPUT_MAX_BW_SCALE_LAST		HWRM_FUNC_CFG_INPUT_MAX_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_FUNC_CFG_INPUT_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_FUNC_CFG_INPUT_MAX_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_FUNC_CFG_INPUT_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_FUNC_CFG_INPUT_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_FUNC_CFG_INPUT_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_FUNC_CFG_INPUT_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_FUNC_CFG_INPUT_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_FUNC_CFG_INPUT_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_FUNC_CFG_INPUT_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_FUNC_CFG_INPUT_MAX_BW_BW_VALUE_UNIT_INVALID
+	/*
+	 * ID of the target completion ring for receiving asynchronous
+	 * event completions. If this field is not valid, then the
+	 * HWRM shall use the default completion ring of the function
+	 * that is being configured as the target completion ring for
+	 * providing any asynchronous event completions for that
+	 * function.
+	 * If this field is valid, then the HWRM shall use the
+	 * completion ring identified by this ID as the target
+	 * completion ring for providing any asynchronous event
+	 * completions for the function that is being configured.
+	 */
+	uint16_t	async_event_cr;
+	/* VLAN Anti-spoofing mode. */
+	uint8_t	vlan_antispoof_mode;
+	/* No VLAN anti-spoofing checks are enabled */
+	#define HWRM_FUNC_CFG_INPUT_VLAN_ANTISPOOF_MODE_NOCHECK		UINT32_C(0x0)
+	/* Validate VLAN against the configured VLAN(s) */
+	#define HWRM_FUNC_CFG_INPUT_VLAN_ANTISPOOF_MODE_VALIDATE_VLAN	UINT32_C(0x1)
+	/* Insert VLAN if it does not exist, otherwise discard */
+	#define HWRM_FUNC_CFG_INPUT_VLAN_ANTISPOOF_MODE_INSERT_IF_VLANDNE	UINT32_C(0x2)
+	/* Insert VLAN if it does not exist, override VLAN if it exists */
+	#define HWRM_FUNC_CFG_INPUT_VLAN_ANTISPOOF_MODE_INSERT_OR_OVERRIDE_VLAN UINT32_C(0x3)
+	#define HWRM_FUNC_CFG_INPUT_VLAN_ANTISPOOF_MODE_LAST		HWRM_FUNC_CFG_INPUT_VLAN_ANTISPOOF_MODE_INSERT_OR_OVERRIDE_VLAN
+	/*
+	 * This bit field defines VLAN PRIs that are allowed on
+	 * this function.
+	 * If nth bit is set, then VLAN PRI n is allowed on this
+	 * function.
+	 */
+	uint8_t	allowed_vlan_pris;
+	/*
+	 * The evb_mode is configured on a per port basis. The default evb_mode
+	 * is configured based on the NVM EVB mode setting upon firmware
+	 * initialization. The HWRM allows a PF driver to change EVB mode for a
+	 * port used by the PF only when one of the following conditions is
+	 * satisfied.
+	 * 1. The current operating mode is single function mode.
+	 *	(ie. one PF per port)
+	 * 2. For SmartNIC, any one of the PAXC PFs is permitted to change the
+	 *	EVB mode of the port used by the PAXC PF. None of the X86 PFs
+	 *	should have privileges.
+	 * The HWRM doesn't permit any PFs to change the underlying EVB mode
+	 * when running as MHB or NPAR mode in performance NIC configuration.
+	 * The HWRM doesn't permit a VF driver to change the EVB mode.
+	 * Once the HWRM determines a function doesn't meet the conditions
+	 * to configure the EVB mode, it sets the evb_mode_cfg_not_supported
+	 * flag in HWRM_FUNC_QCAPS command response for the function.
+	 * The HWRM takes into account the switching of EVB mode from one to
+	 * another and reconfigure hardware resources as required. The
+	 * switching from VEB to VEPA mode requires the disabling of the
+	 * loopback traffic. Additionally, source knockouts are handled
+	 * differently in VEB and VEPA modes.
+	 */
+	uint8_t	evb_mode;
+	/* No Edge Virtual Bridging (EVB) */
+	#define HWRM_FUNC_CFG_INPUT_EVB_MODE_NO_EVB UINT32_C(0x0)
+	/* Virtual Ethernet Bridge (VEB) */
+	#define HWRM_FUNC_CFG_INPUT_EVB_MODE_VEB	UINT32_C(0x1)
+	/* Virtual Ethernet Port Aggregator (VEPA) */
+	#define HWRM_FUNC_CFG_INPUT_EVB_MODE_VEPA   UINT32_C(0x2)
+	#define HWRM_FUNC_CFG_INPUT_EVB_MODE_LAST  HWRM_FUNC_CFG_INPUT_EVB_MODE_VEPA
+	uint8_t	options;
+	/*
+	 * This value indicates the PCIE device cache line size.
+	 * The cache line size allows the DMA writes to terminate and
+	 * start at the cache boundary.
+	 */
+	#define HWRM_FUNC_CFG_INPUT_OPTIONS_CACHE_LINESIZE_MASK	UINT32_C(0x3)
+	#define HWRM_FUNC_CFG_INPUT_OPTIONS_CACHE_LINESIZE_SFT	0
+	/* Cache Line Size 64 bytes */
+		#define HWRM_FUNC_CFG_INPUT_OPTIONS_CACHE_LINESIZE_SIZE_64	UINT32_C(0x0)
+	/* Cache Line Size 128 bytes */
+		#define HWRM_FUNC_CFG_INPUT_OPTIONS_CACHE_LINESIZE_SIZE_128	UINT32_C(0x1)
+		#define HWRM_FUNC_CFG_INPUT_OPTIONS_CACHE_LINESIZE_LAST	HWRM_FUNC_CFG_INPUT_OPTIONS_CACHE_LINESIZE_SIZE_128
+	/* This value is the virtual link admin state setting. */
+	#define HWRM_FUNC_CFG_INPUT_OPTIONS_LINK_ADMIN_STATE_MASK	UINT32_C(0xc)
+	#define HWRM_FUNC_CFG_INPUT_OPTIONS_LINK_ADMIN_STATE_SFT	2
+	/* Admin state is forced down. */
+		#define HWRM_FUNC_CFG_INPUT_OPTIONS_LINK_ADMIN_STATE_FORCED_DOWN  (UINT32_C(0x0) << 2)
+	/* Admin state is forced up. */
+		#define HWRM_FUNC_CFG_INPUT_OPTIONS_LINK_ADMIN_STATE_FORCED_UP	(UINT32_C(0x1) << 2)
+	/*
+	 * Admin state is in auto mode - is to follow the physical link
+	 * state.
+	 */
+		#define HWRM_FUNC_CFG_INPUT_OPTIONS_LINK_ADMIN_STATE_AUTO	(UINT32_C(0x2) << 2)
+		#define HWRM_FUNC_CFG_INPUT_OPTIONS_LINK_ADMIN_STATE_LAST	HWRM_FUNC_CFG_INPUT_OPTIONS_LINK_ADMIN_STATE_AUTO
+	/* Reserved for future. */
+	#define HWRM_FUNC_CFG_INPUT_OPTIONS_RSVD_MASK		UINT32_C(0xf0)
+	#define HWRM_FUNC_CFG_INPUT_OPTIONS_RSVD_SFT			4
+	/*
+	 * The number of multicast filters that should
+	 * be reserved for this function on the RX side.
+	 */
+	uint16_t	num_mcast_filters;
+	/* Used by a PF driver to associate a SCHQ with a VF. */
+	uint16_t	schq_id;
+	uint16_t	mpc_chnls;
+	/*
+	 * When this bit is '1', the caller requests to enable a MPC
+	 * channel with destination to the TX crypto engine block.
+	 * When this bit is '0', this flag has no effect.
+	 */
+	#define HWRM_FUNC_CFG_INPUT_MPC_CHNLS_TCE_ENABLE	UINT32_C(0x1)
+	/*
+	 * When this bit is '1', the caller requests to disable a MPC
+	 * channel with destination to the TX crypto engine block.
+	 * When this bit is '0', this flag has no effect.
+	 */
+	#define HWRM_FUNC_CFG_INPUT_MPC_CHNLS_TCE_DISABLE	UINT32_C(0x2)
+	/*
+	 * When this bit is '1', the caller requests to enable a MPC
+	 * channel with destination to the RX crypto engine block.
+	 * When this bit is '0', this flag has no effect.
+	 */
+	#define HWRM_FUNC_CFG_INPUT_MPC_CHNLS_RCE_ENABLE	UINT32_C(0x4)
+	/*
+	 * When this bit is '1', the caller requests to disable a MPC
+	 * channel with destination to the RX crypto engine block.
+	 * When this bit is '0', this flag has no effect.
+	 */
+	#define HWRM_FUNC_CFG_INPUT_MPC_CHNLS_RCE_DISABLE	UINT32_C(0x8)
+	/*
+	 * When this bit is '1', the caller requests to enable a MPC
+	 * channel with destination to the TX configurable flow processing
+	 * block. When this bit is '0', this flag has no effect.
+	 */
+	#define HWRM_FUNC_CFG_INPUT_MPC_CHNLS_TE_CFA_ENABLE	UINT32_C(0x10)
+	/*
+	 * When this bit is '1', the caller requests to disable a MPC
+	 * channel with destination to the TX configurable flow processing
+	 * block. When this bit is '0', this flag has no effect.
+	 */
+	#define HWRM_FUNC_CFG_INPUT_MPC_CHNLS_TE_CFA_DISABLE	UINT32_C(0x20)
+	/*
+	 * When this bit is '1', the caller requests to enable a MPC
+	 * channel with destination to the RX configurable flow processing
+	 * block. When this bit is '0', this flag has no effect.
+	 */
+	#define HWRM_FUNC_CFG_INPUT_MPC_CHNLS_RE_CFA_ENABLE	UINT32_C(0x40)
+	/*
+	 * When this bit is '1', the caller requests to disable a MPC
+	 * channel with destination to the RX configurable flow processing
+	 * block. When this bit is '0', this flag has no effect.
+	 */
+	#define HWRM_FUNC_CFG_INPUT_MPC_CHNLS_RE_CFA_DISABLE	UINT32_C(0x80)
+	/*
+	 * When this bit is '1', the caller requests to enable a MPC
+	 * channel with destination to the primate processor block.
+	 * When this bit is '0', this flag has no effect.
+	 */
+	#define HWRM_FUNC_CFG_INPUT_MPC_CHNLS_PRIMATE_ENABLE	UINT32_C(0x100)
+	/*
+	 * When this bit is '1', the caller requests to disable a MPC
+	 * channel with destination to the primate processor block.
+	 * When this bit is '0', this flag has no effect.
+	 */
+	#define HWRM_FUNC_CFG_INPUT_MPC_CHNLS_PRIMATE_DISABLE	UINT32_C(0x200)
+	/*
+	 * Minimum guaranteed bandwidth for the network partition made up
+	 * of the caller physical function and all its child virtual
+	 * functions. The rate is specified as a percentage of the bandwidth
+	 * of the link the partition is associated with. A value of 0
+	 * indicates that no minimum bandwidth is configured. The sum of the
+	 * minimum bandwidths for all partitions on a link must not exceed
+	 * 100%.
+	 * The format of this field is defined to match min_bw, even though
+	 * it does not allow all the options for min_bw at this time.
+	 */
+	uint32_t	partition_min_bw;
+	/* The bandwidth value. */
+	#define HWRM_FUNC_CFG_INPUT_PARTITION_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_FUNC_CFG_INPUT_PARTITION_MIN_BW_BW_VALUE_SFT		0
+	/*
+	 * The granularity of the value (bits or bytes). Firmware ignores
+	 * this field.
+	 */
+	#define HWRM_FUNC_CFG_INPUT_PARTITION_MIN_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_FUNC_CFG_INPUT_PARTITION_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_FUNC_CFG_INPUT_PARTITION_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_FUNC_CFG_INPUT_PARTITION_MIN_BW_SCALE_LAST		HWRM_FUNC_CFG_INPUT_PARTITION_MIN_BW_SCALE_BYTES
+	/* Bandwidth units. Must be set to percent1_100. */
+	#define HWRM_FUNC_CFG_INPUT_PARTITION_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_FUNC_CFG_INPUT_PARTITION_MIN_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in hundredths of a percent of link bandwidth. */
+		#define HWRM_FUNC_CFG_INPUT_PARTITION_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+		#define HWRM_FUNC_CFG_INPUT_PARTITION_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_FUNC_CFG_INPUT_PARTITION_MIN_BW_BW_VALUE_UNIT_PERCENT1_100
+	/*
+	 * The maximum bandwidth that may be used by the network partition
+	 * made up of the caller physical function and all its child virtual
+	 * functions. The rate is specified as a percentage of the bandwidth
+	 * of the link the partition is associated with. A value of 0
+	 * indicates that no maximum bandwidth is configured.
+	 * The format of this field is defined to match max_bw, even though it
+	 * does not allow all the options for max_bw at this time.
+	 */
+	uint32_t	partition_max_bw;
+	/* The bandwidth value. */
+	#define HWRM_FUNC_CFG_INPUT_PARTITION_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_FUNC_CFG_INPUT_PARTITION_MAX_BW_BW_VALUE_SFT		0
+	/*
+	 * The granularity of the value (bits or bytes). Firmware ignores
+	 * this field.
+	 */
+	#define HWRM_FUNC_CFG_INPUT_PARTITION_MAX_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_FUNC_CFG_INPUT_PARTITION_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_FUNC_CFG_INPUT_PARTITION_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_FUNC_CFG_INPUT_PARTITION_MAX_BW_SCALE_LAST		HWRM_FUNC_CFG_INPUT_PARTITION_MAX_BW_SCALE_BYTES
+	/* Bandwidth units. Must be set to percent1_100. */
+	#define HWRM_FUNC_CFG_INPUT_PARTITION_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_FUNC_CFG_INPUT_PARTITION_MAX_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in hundredths of a percent of link bandwidth. */
+		#define HWRM_FUNC_CFG_INPUT_PARTITION_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+		#define HWRM_FUNC_CFG_INPUT_PARTITION_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_FUNC_CFG_INPUT_PARTITION_MAX_BW_BW_VALUE_UNIT_PERCENT1_100
+	/*
+	 * The TPID for the function for which default VLAN
+	 * is configured. If the dflt_vlan is not specified
+	 * with the TPID, FW returns error. If the TPID is
+	 * not specified with dflt_vlan, the default TPID of
+	 * 0x8100 will be used. This field is specified in
+	 * network byte order.
+	 */
+	uint16_t	tpid;
+	/*
+	 * This field can be used by the host PF to configure
+	 * mtu value.
+	 * The maximum transmission unit of the function.
+	 * The HWRM should make sure that the mtu of
+	 * the function does not exceed the mtu of the physical
+	 * port that this function is associated with.
+	 *
+	 * In addition to configuring mtu per function, it is
+	 * possible to configure mtu per transmit ring.
+	 * By default, the mtu of each transmit ring associated
+	 * with a function is equal to the mtu of the function.
+	 * The HWRM should make sure that the mtu of each transmit
+	 * ring that is assigned to a function has a valid mtu.
+	 */
+	uint16_t	host_mtu;
+	uint32_t	flags2;
+	/*
+	 * If this bit is set to 1, the driver is requesting the firmware
+	 * to see if the assets (i.e., the number of KTLS key contexts)
+	 * requested in this command are available. The firmware will return
+	 * an error if the requested assets are not available. The firmware
+	 * will NOT reserve the assets if they are available.
+	 */
+	#define HWRM_FUNC_CFG_INPUT_FLAGS2_KTLS_KEY_CTX_ASSETS_TEST	UINT32_C(0x1)
+	/*
+	 * If this bit is set to 1, the driver is requesting the firmware
+	 * to see if the assets (i.e., the number of QUIC key contexts)
+	 * requested in this command are available. The firmware will return
+	 * an error if the requested assets are not available. The firmware
+	 * will NOT reserve the assets if they are available.
+	 */
+	#define HWRM_FUNC_CFG_INPUT_FLAGS2_QUIC_KEY_CTX_ASSETS_TEST	UINT32_C(0x2)
+	uint32_t	enables2;
+	/*
+	 * This bit must be '1' for the kdnet_mode field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_RING8	UINT32_C(0x10000)
+	#define HWRM_FUNC_CFG_INPUT_ENABLES2_KDNET		UINT32_C(0x1)
 	/*
-	 * This bit must be '1' for the tqm_ring9 fields to be
+	 * This bit must be '1' for the db_page_size field to be
+	 * configured. Legacy controller core FW may silently ignore
+	 * the db_page_size programming request through this command.
+	 */
+	#define HWRM_FUNC_CFG_INPUT_ENABLES2_DB_PAGE_SIZE		UINT32_C(0x2)
+	/*
+	 * This bit must be '1' for the num_quic_tx_key_ctxs field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_RING9	UINT32_C(0x20000)
+	#define HWRM_FUNC_CFG_INPUT_ENABLES2_QUIC_TX_KEY_CTXS	UINT32_C(0x4)
 	/*
-	 * This bit must be '1' for the tqm_ring10 fields to be
+	 * This bit must be '1' for the num_quic_rx_key_ctxs field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_RING10	UINT32_C(0x40000)
+	#define HWRM_FUNC_CFG_INPUT_ENABLES2_QUIC_RX_KEY_CTXS	UINT32_C(0x8)
 	/*
-	 * This bit must be '1' for the Tx KTLS context
-	 * fields to be configured.
+	 * This bit must be '1' for the roce_max_av_per_vf field to be
+	 * configured.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TKC		UINT32_C(0x80000)
+	#define HWRM_FUNC_CFG_INPUT_ENABLES2_ROCE_MAX_AV_PER_VF	UINT32_C(0x10)
 	/*
-	 * This bit must be '1' for the Rx KTLS context
-	 * fields to be configured.
+	 * This bit must be '1' for the roce_max_cq_per_vf field to be
+	 * configured. Only valid for PF.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_RKC		UINT32_C(0x100000)
-	/* QPC page size and level. */
-	uint8_t	qpc_pg_size_qpc_lvl;
-	/* QPC PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_LVL_LVL_2
-	/* QPC page size. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_PG_SIZE_PG_1G
-	/* SRQ page size and level. */
-	uint8_t	srq_pg_size_srq_lvl;
-	/* SRQ PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_SRQ_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_SRQ_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_SRQ_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_SRQ_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_SRQ_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_SRQ_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_SRQ_LVL_LVL_2
-	/* SRQ page size. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_SRQ_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_SRQ_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_SRQ_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_SRQ_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_SRQ_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_SRQ_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_SRQ_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_SRQ_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_SRQ_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_SRQ_PG_SIZE_PG_1G
-	/* CQ page size and level. */
-	uint8_t	cq_pg_size_cq_lvl;
-	/* CQ PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_CQ_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_CQ_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_CQ_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_CQ_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_CQ_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_CQ_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_CQ_LVL_LVL_2
-	/* CQ page size. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_CQ_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_CQ_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_CQ_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_CQ_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_CQ_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_CQ_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_CQ_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_CQ_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_CQ_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_CQ_PG_SIZE_PG_1G
-	/* VNIC page size and level. */
-	uint8_t	vnic_pg_size_vnic_lvl;
-	/* VNIC PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_VNIC_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_VNIC_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_VNIC_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_VNIC_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_VNIC_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_VNIC_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_VNIC_LVL_LVL_2
-	/* VNIC page size. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_VNIC_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_VNIC_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_VNIC_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_VNIC_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_VNIC_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_VNIC_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_VNIC_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_VNIC_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_VNIC_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_VNIC_PG_SIZE_PG_1G
-	/* Stat page size and level. */
-	uint8_t	stat_pg_size_stat_lvl;
-	/* Stat PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_STAT_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_STAT_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_STAT_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_STAT_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_STAT_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_STAT_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_STAT_LVL_LVL_2
-	/* Stat page size. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_STAT_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_STAT_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_STAT_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_STAT_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_STAT_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_STAT_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_STAT_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_STAT_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_STAT_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_STAT_PG_SIZE_PG_1G
-	/* TQM slow path page size and level. */
-	uint8_t	tqm_sp_pg_size_tqm_sp_lvl;
-	/* TQM slow path PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_SP_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_SP_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_SP_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_SP_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_SP_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_SP_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_SP_LVL_LVL_2
-	/* TQM slow path page size. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_SP_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_SP_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_SP_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_SP_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_SP_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_SP_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_SP_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_SP_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_SP_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_SP_PG_SIZE_PG_1G
-	/* TQM ring 0 page size and level. */
-	uint8_t	tqm_ring0_pg_size_tqm_ring0_lvl;
-	/* TQM ring 0 PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING0_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING0_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING0_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING0_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING0_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING0_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING0_LVL_LVL_2
-	/* TQM ring 0 page size. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING0_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING0_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING0_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING0_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING0_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING0_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING0_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING0_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING0_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING0_PG_SIZE_PG_1G
-	/* TQM ring 1 page size and level. */
-	uint8_t	tqm_ring1_pg_size_tqm_ring1_lvl;
-	/* TQM ring 1 PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING1_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING1_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING1_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING1_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING1_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING1_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING1_LVL_LVL_2
-	/* TQM ring 1 page size. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING1_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING1_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING1_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING1_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING1_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING1_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING1_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING1_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING1_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING1_PG_SIZE_PG_1G
-	/* TQM ring 2 page size and level. */
-	uint8_t	tqm_ring2_pg_size_tqm_ring2_lvl;
-	/* TQM ring 2 PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING2_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING2_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING2_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING2_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING2_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING2_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING2_LVL_LVL_2
-	/* TQM ring 2 page size. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING2_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING2_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING2_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING2_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING2_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING2_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING2_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING2_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING2_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING2_PG_SIZE_PG_1G
-	/* TQM ring 3 page size and level. */
-	uint8_t	tqm_ring3_pg_size_tqm_ring3_lvl;
-	/* TQM ring 3 PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING3_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING3_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING3_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING3_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING3_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING3_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING3_LVL_LVL_2
-	/* TQM ring 3 page size. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING3_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING3_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING3_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING3_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING3_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING3_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING3_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING3_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING3_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING3_PG_SIZE_PG_1G
-	/* TQM ring 4 page size and level. */
-	uint8_t	tqm_ring4_pg_size_tqm_ring4_lvl;
-	/* TQM ring 4 PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING4_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING4_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING4_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING4_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING4_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING4_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING4_LVL_LVL_2
-	/* TQM ring 4 page size. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING4_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING4_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING4_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING4_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING4_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING4_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING4_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING4_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING4_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING4_PG_SIZE_PG_1G
-	/* TQM ring 5 page size and level. */
-	uint8_t	tqm_ring5_pg_size_tqm_ring5_lvl;
-	/* TQM ring 5 PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING5_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING5_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING5_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING5_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING5_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING5_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING5_LVL_LVL_2
-	/* TQM ring 5 page size. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING5_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING5_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING5_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING5_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING5_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING5_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING5_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING5_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING5_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING5_PG_SIZE_PG_1G
-	/* TQM ring 6 page size and level. */
-	uint8_t	tqm_ring6_pg_size_tqm_ring6_lvl;
-	/* TQM ring 6 PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING6_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING6_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING6_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING6_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING6_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING6_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING6_LVL_LVL_2
-	/* TQM ring 6 page size. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING6_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING6_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING6_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING6_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING6_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING6_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING6_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING6_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING6_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING6_PG_SIZE_PG_1G
-	/* TQM ring 7 page size and level. */
-	uint8_t	tqm_ring7_pg_size_tqm_ring7_lvl;
-	/* TQM ring 7 PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING7_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING7_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING7_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING7_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING7_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING7_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING7_LVL_LVL_2
-	/* TQM ring 7 page size. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING7_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING7_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING7_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING7_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING7_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING7_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING7_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING7_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING7_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING7_PG_SIZE_PG_1G
-	/* MR/AV page size and level. */
-	uint8_t	mrav_pg_size_mrav_lvl;
-	/* MR/AV PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_MRAV_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_MRAV_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_MRAV_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_MRAV_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_MRAV_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_MRAV_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_MRAV_LVL_LVL_2
-	/* MR/AV page size. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_MRAV_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_MRAV_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_MRAV_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_MRAV_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_MRAV_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_MRAV_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_MRAV_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_MRAV_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_MRAV_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_MRAV_PG_SIZE_PG_1G
-	/* Timer page size and level. */
-	uint8_t	tim_pg_size_tim_lvl;
-	/* Timer PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TIM_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TIM_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TIM_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TIM_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TIM_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TIM_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_TIM_LVL_LVL_2
-	/* Timer page size. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TIM_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TIM_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TIM_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TIM_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TIM_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TIM_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TIM_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TIM_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TIM_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_TIM_PG_SIZE_PG_1G
-	/* QP page directory. */
-	uint64_t	qpc_page_dir;
-	/* SRQ page directory. */
-	uint64_t	srq_page_dir;
-	/* CQ page directory. */
-	uint64_t	cq_page_dir;
-	/* VNIC page directory. */
-	uint64_t	vnic_page_dir;
-	/* Stat page directory. */
-	uint64_t	stat_page_dir;
-	/* TQM slowpath page directory. */
-	uint64_t	tqm_sp_page_dir;
-	/* TQM ring 0 page directory. */
-	uint64_t	tqm_ring0_page_dir;
-	/* TQM ring 1 page directory. */
-	uint64_t	tqm_ring1_page_dir;
-	/* TQM ring 2 page directory. */
-	uint64_t	tqm_ring2_page_dir;
-	/* TQM ring 3 page directory. */
-	uint64_t	tqm_ring3_page_dir;
-	/* TQM ring 4 page directory. */
-	uint64_t	tqm_ring4_page_dir;
-	/* TQM ring 5 page directory. */
-	uint64_t	tqm_ring5_page_dir;
-	/* TQM ring 6 page directory. */
-	uint64_t	tqm_ring6_page_dir;
-	/* TQM ring 7 page directory. */
-	uint64_t	tqm_ring7_page_dir;
-	/* MR/AV page directory. */
-	uint64_t	mrav_page_dir;
-	/* Timer page directory. */
-	uint64_t	tim_page_dir;
-	/* Number of QPs. */
-	uint32_t	qp_num_entries;
-	/* Number of SRQs. */
-	uint32_t	srq_num_entries;
-	/* Number of CQs. */
-	uint32_t	cq_num_entries;
-	/* Number of Stats. */
-	uint32_t	stat_num_entries;
+	#define HWRM_FUNC_CFG_INPUT_ENABLES2_ROCE_MAX_CQ_PER_VF	UINT32_C(0x20)
 	/*
-	 * Number of TQM slowpath entries.
-	 *
-	 * TQM slowpath rings should be sized as follows:
-	 *
-	 * num_entries = num_vnics + num_l2_tx_rings + 2 * num_roce_qps + tqm_min_size
-	 *
-	 * Where:
-	 *   num_vnics is the number of VNICs allocated in the VNIC backing store
-	 *   num_l2_tx_rings is the number of L2 rings in the QP backing store
-	 *   num_roce_qps is the number of RoCE QPs in the QP backing store
-	 *   tqm_min_size is tqm_min_entries_per_ring reported by
-	 *	HWRM_FUNC_BACKING_STORE_QCAPS
-	 *
-	 * Note that TQM ring sizes cannot be extended while the system is
-	 * operational. If a PF driver needs to extend a TQM ring, it needs
-	 * to reset the function (e.g. HWRM_FUNC_RESET) and then reallocate
-	 * the backing store.
+	 * This bit must be '1' for the roce_max_mrw_per_vf field to be
+	 * configured. Only valid for PF.
 	 */
-	uint32_t	tqm_sp_num_entries;
+	#define HWRM_FUNC_CFG_INPUT_ENABLES2_ROCE_MAX_MRW_PER_VF	UINT32_C(0x40)
 	/*
-	 * Number of TQM ring 0 entries.
-	 *
-	 * TQM fastpath rings should be sized large enough to accommodate the
-	 * maximum number of QPs (either L2 or RoCE, or both if shared)
-	 * that can be enqueued to the TQM ring.
-	 *
-	 * Note that TQM ring sizes cannot be extended while the system is
-	 * operational. If a PF driver needs to extend a TQM ring, it needs
-	 * to reset the function (e.g. HWRM_FUNC_RESET) and then reallocate
-	 * the backing store.
+	 * This bit must be '1' for the roce_max_qp_per_vf field to be
+	 * configured.
 	 */
-	uint32_t	tqm_ring0_num_entries;
+	#define HWRM_FUNC_CFG_INPUT_ENABLES2_ROCE_MAX_QP_PER_VF	UINT32_C(0x80)
+	/*
+	 * This bit must be '1' for the roce_max_srq_per_vf field to be
+	 * configured. Only valid for PF.
+	 */
+	#define HWRM_FUNC_CFG_INPUT_ENABLES2_ROCE_MAX_SRQ_PER_VF	UINT32_C(0x100)
+	/*
+	 * This bit must be '1' for the roce_max_gid_per_vf field to be
+	 * configured. Only valid for PF.
+	 */
+	#define HWRM_FUNC_CFG_INPUT_ENABLES2_ROCE_MAX_GID_PER_VF	UINT32_C(0x200)
+	/*
+	 * This bit must be '1' for the xid_partition_cfg field to be
+	 * configured. Only valid for PF.
+	 */
+	#define HWRM_FUNC_CFG_INPUT_ENABLES2_XID_PARTITION_CFG	UINT32_C(0x400)
+	/*
+	 * KDNet mode for the port for this function. If NPAR is
+	 * also configured on this port, it takes precedence. KDNet
+	 * mode is ignored for a VF.
+	 */
+	uint8_t	port_kdnet_mode;
+	/* KDNet mode is not enabled. */
+	#define HWRM_FUNC_CFG_INPUT_PORT_KDNET_MODE_DISABLED UINT32_C(0x0)
+	/* KDNet mode enabled. */
+	#define HWRM_FUNC_CFG_INPUT_PORT_KDNET_MODE_ENABLED  UINT32_C(0x1)
+	#define HWRM_FUNC_CFG_INPUT_PORT_KDNET_MODE_LAST	HWRM_FUNC_CFG_INPUT_PORT_KDNET_MODE_ENABLED
+	/*
+	 * This field can be used by the PF driver to configure the doorbell
+	 * page size. L2 driver can use different pages to ring the doorbell
+	 * for L2 push operation. The doorbell page size should be configured
+	 * to match the native CPU page size for proper RoCE and L2 doorbell
+	 * operations. This value supersedes the older method of configuring
+	 * the doorbell page size by the RoCE driver using the command queue
+	 * method. The default is 4K.
+	 */
+	uint8_t	db_page_size;
+	/* DB page size is 4KB. */
+	#define HWRM_FUNC_CFG_INPUT_DB_PAGE_SIZE_4KB   UINT32_C(0x0)
+	/* DB page size is 8KB. */
+	#define HWRM_FUNC_CFG_INPUT_DB_PAGE_SIZE_8KB   UINT32_C(0x1)
+	/* DB page size is 16KB. */
+	#define HWRM_FUNC_CFG_INPUT_DB_PAGE_SIZE_16KB  UINT32_C(0x2)
+	/* DB page size is 32KB. */
+	#define HWRM_FUNC_CFG_INPUT_DB_PAGE_SIZE_32KB  UINT32_C(0x3)
+	/* DB page size is 64KB. */
+	#define HWRM_FUNC_CFG_INPUT_DB_PAGE_SIZE_64KB  UINT32_C(0x4)
+	/* DB page size is 128KB. */
+	#define HWRM_FUNC_CFG_INPUT_DB_PAGE_SIZE_128KB UINT32_C(0x5)
+	/* DB page size is 256KB. */
+	#define HWRM_FUNC_CFG_INPUT_DB_PAGE_SIZE_256KB UINT32_C(0x6)
+	/* DB page size is 512KB. */
+	#define HWRM_FUNC_CFG_INPUT_DB_PAGE_SIZE_512KB UINT32_C(0x7)
+	/* DB page size is 1MB. */
+	#define HWRM_FUNC_CFG_INPUT_DB_PAGE_SIZE_1MB   UINT32_C(0x8)
+	/* DB page size is 2MB. */
+	#define HWRM_FUNC_CFG_INPUT_DB_PAGE_SIZE_2MB   UINT32_C(0x9)
+	/* DB page size is 4MB. */
+	#define HWRM_FUNC_CFG_INPUT_DB_PAGE_SIZE_4MB   UINT32_C(0xa)
+	#define HWRM_FUNC_CFG_INPUT_DB_PAGE_SIZE_LAST HWRM_FUNC_CFG_INPUT_DB_PAGE_SIZE_4MB
+	uint8_t	unused_1[2];
+	/* Number of KTLS Tx Key Contexts requested. */
+	uint32_t	num_ktls_tx_key_ctxs;
+	/* Number of KTLS Rx Key Contexts requested. */
+	uint32_t	num_ktls_rx_key_ctxs;
+	/* Number of QUIC Tx Key Contexts requested. */
+	uint32_t	num_quic_tx_key_ctxs;
+	/* Number of QUIC Rx Key Contexts requested. */
+	uint32_t	num_quic_rx_key_ctxs;
+	/* Number of AVs per VF. Only valid for PF. */
+	uint32_t	roce_max_av_per_vf;
+	/* Number of CQs per VF. Only valid for PF. */
+	uint32_t	roce_max_cq_per_vf;
+	/* Number of MR/MWs per VF. Only valid for PF. */
+	uint32_t	roce_max_mrw_per_vf;
+	/* Number of QPs per VF. Only valid for PF. */
+	uint32_t	roce_max_qp_per_vf;
+	/* Number of SRQs per VF. Only valid for PF. */
+	uint32_t	roce_max_srq_per_vf;
+	/* Number of GIDs per VF. Only valid for PF. */
+	uint32_t	roce_max_gid_per_vf;
+	/*
+	 * Bitmap of context types that have XID partition enabled.
+	 * Only valid for PF.
+	 */
+	uint16_t	xid_partition_cfg;
+	/*
+	 * When this bit is '1', it indicates that driver enables XID
+	 * partition on Tx crypto key contexts.
+	 */
+	#define HWRM_FUNC_CFG_INPUT_XID_PARTITION_CFG_TX_CK	UINT32_C(0x1)
+	/*
+	 * When this bit is '1', it indicates that driver enables XID
+	 * partition on Rx crypto key contexts.
+	 */
+	#define HWRM_FUNC_CFG_INPUT_XID_PARTITION_CFG_RX_CK	UINT32_C(0x2)
+	uint16_t	unused_2;
+} hwrm_func_cfg_input_t, *phwrm_func_cfg_input_t;
+
+/* hwrm_func_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_func_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
 	/*
-	 * Number of TQM ring 1 entries.
-	 *
-	 * TQM fastpath rings should be sized large enough to accommodate the
-	 * maximum number of QPs (either L2 or RoCE, or both if shared)
-	 * that can be enqueued to the TQM ring.
-	 *
-	 * Note that TQM ring sizes cannot be extended while the system is
-	 * operational. If a PF driver needs to extend a TQM ring, it needs
-	 * to reset the function (e.g. HWRM_FUNC_RESET) and then reallocate
-	 * the backing store.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	uint32_t	tqm_ring1_num_entries;
+	uint8_t	valid;
+} hwrm_func_cfg_output_t, *phwrm_func_cfg_output_t;
+
+/* hwrm_func_cfg_cmd_err (size:64b/8B) */
+
+typedef struct hwrm_func_cfg_cmd_err {
+	/* command specific error codes for the cmd_err field in hwrm_err_output */
+	uint8_t	code;
+	/* Unknown error. */
+	#define HWRM_FUNC_CFG_CMD_ERR_CODE_UNKNOWN			UINT32_C(0x0)
+	/* The partition minimum bandwidth is out of range. */
+	#define HWRM_FUNC_CFG_CMD_ERR_CODE_PARTITION_MIN_BW_RANGE	UINT32_C(0x1)
+	/* The minimum bandwidth is more than the maximum bandwidth. */
+	#define HWRM_FUNC_CFG_CMD_ERR_CODE_PARTITION_MIN_MORE_THAN_MAX  UINT32_C(0x2)
+	/*
+	 * The NIC does not support enforcement of a minimum guaranteed
+	 * bandwidth for a partition.
+	 */
+	#define HWRM_FUNC_CFG_CMD_ERR_CODE_PARTITION_MIN_BW_UNSUPPORTED UINT32_C(0x3)
+	/* Partition bandwidths must be specified as a percentage. */
+	#define HWRM_FUNC_CFG_CMD_ERR_CODE_PARTITION_BW_PERCENT	UINT32_C(0x4)
+	#define HWRM_FUNC_CFG_CMD_ERR_CODE_LAST			HWRM_FUNC_CFG_CMD_ERR_CODE_PARTITION_BW_PERCENT
+	uint8_t	unused_0[7];
+} hwrm_func_cfg_cmd_err_t, *phwrm_func_cfg_cmd_err_t;
+
+/********************
+ * hwrm_func_qstats *
+ ********************/
+
+
+/* hwrm_func_qstats_input (size:192b/24B) */
+
+typedef struct hwrm_func_qstats_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * Number of TQM ring 2 entries.
-	 *
-	 * TQM fastpath rings should be sized large enough to accommodate the
-	 * maximum number of QPs (either L2 or RoCE, or both if shared)
-	 * that can be enqueued to the TQM ring.
-	 *
-	 * Note that TQM ring sizes cannot be extended while the system is
-	 * operational. If a PF driver needs to extend a TQM ring, it needs
-	 * to reset the function (e.g. HWRM_FUNC_RESET) and then reallocate
-	 * the backing store.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint32_t	tqm_ring2_num_entries;
+	uint16_t	cmpl_ring;
 	/*
-	 * Number of TQM ring 3 entries.
-	 *
-	 * TQM fastpath rings should be sized large enough to accommodate the
-	 * maximum number of QPs (either L2 or RoCE, or both if shared)
-	 * that can be enqueued to the TQM ring.
-	 *
-	 * Note that TQM ring sizes cannot be extended while the system is
-	 * operational. If a PF driver needs to extend a TQM ring, it needs
-	 * to reset the function (e.g. HWRM_FUNC_RESET) and then reallocate
-	 * the backing store.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint32_t	tqm_ring3_num_entries;
+	uint16_t	seq_id;
 	/*
-	 * Number of TQM ring 4 entries.
-	 *
-	 * TQM fastpath rings should be sized large enough to accommodate the
-	 * maximum number of QPs (either L2 or RoCE, or both if shared)
-	 * that can be enqueued to the TQM ring.
-	 *
-	 * Note that TQM ring sizes cannot be extended while the system is
-	 * operational. If a PF driver needs to extend a TQM ring, it needs
-	 * to reset the function (e.g. HWRM_FUNC_RESET) and then reallocate
-	 * the backing store.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint32_t	tqm_ring4_num_entries;
+	uint16_t	target_id;
 	/*
-	 * Number of TQM ring 5 entries.
-	 *
-	 * TQM fastpath rings should be sized large enough to accommodate the
-	 * maximum number of QPs (either L2 or RoCE, or both if shared)
-	 * that can be enqueued to the TQM ring.
-	 *
-	 * Note that TQM ring sizes cannot be extended while the system is
-	 * operational. If a PF driver needs to extend a TQM ring, it needs
-	 * to reset the function (e.g. HWRM_FUNC_RESET) and then reallocate
-	 * the backing store.
-	 */
-	uint32_t	tqm_ring5_num_entries;
-	/*
-	 * Number of TQM ring 6 entries.
-	 *
-	 * TQM fastpath rings should be sized large enough to accommodate the
-	 * maximum number of QPs (either L2 or RoCE, or both if shared)
-	 * that can be enqueued to the TQM ring.
-	 *
-	 * Note that TQM ring sizes cannot be extended while the system is
-	 * operational. If a PF driver needs to extend a TQM ring, it needs
-	 * to reset the function (e.g. HWRM_FUNC_RESET) and then reallocate
-	 * the backing store.
-	 */
-	uint32_t	tqm_ring6_num_entries;
-	/*
-	 * Number of TQM ring 7 entries.
-	 *
-	 * TQM fastpath rings should be sized large enough to accommodate the
-	 * maximum number of QPs (either L2 or RoCE, or both if shared)
-	 * that can be enqueued to the TQM ring.
-	 *
-	 * Note that TQM ring sizes cannot be extended while the system is
-	 * operational. If a PF driver needs to extend a TQM ring, it needs
-	 * to reset the function (e.g. HWRM_FUNC_RESET) and then reallocate
-	 * the backing store.
-	 */
-	uint32_t	tqm_ring7_num_entries;
-	/*
-	 * If the MR/AV split reservation flag is not set, then this field
-	 * represents the total number of MR plus AV entries. For versions
-	 * of firmware that support the split reservation, when it is not
-	 * specified half of the entries will be reserved for MRs and the
-	 * other half for AVs.
-	 *
-	 * If the MR/AV split reservation flag is set, then this
-	 * field is logically divided into two 16b fields. Bits `[31:16]`
-	 * represents the `mr_num_entries` and bits `[15:0]` represents
-	 * `av_num_entries`. The granularity of these values is defined by
-	 * the `mrav_num_entries_unit` field returned by the
-	 * `backing_store_qcaps` command.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint32_t	mrav_num_entries;
-	/* Number of Timer entries. */
-	uint32_t	tim_num_entries;
-	/* Number of entries to reserve for QP1 */
-	uint16_t	qp_num_qp1_entries;
-	/* Number of entries to reserve for L2 */
-	uint16_t	qp_num_l2_entries;
-	/* Number of bytes that have been allocated for each context entry. */
-	uint16_t	qp_entry_size;
-	/* Number of entries to reserve for L2 */
-	uint16_t	srq_num_l2_entries;
-	/* Number of bytes that have been allocated for each context entry. */
-	uint16_t	srq_entry_size;
-	/* Number of entries to reserve for L2 */
-	uint16_t	cq_num_l2_entries;
-	/* Number of bytes that have been allocated for each context entry. */
-	uint16_t	cq_entry_size;
-	/* Number of entries to reserve for VNIC entries */
-	uint16_t	vnic_num_vnic_entries;
-	/* Number of entries to reserve for Ring table entries */
-	uint16_t	vnic_num_ring_table_entries;
-	/* Number of bytes that have been allocated for each context entry. */
-	uint16_t	vnic_entry_size;
-	/* Number of bytes that have been allocated for each context entry. */
-	uint16_t	stat_entry_size;
-	/* Number of bytes that have been allocated for each context entry. */
-	uint16_t	tqm_entry_size;
-	/* Number of bytes that have been allocated for each context entry. */
-	uint16_t	mrav_entry_size;
-	/* Number of bytes that have been allocated for each context entry. */
-	uint16_t	tim_entry_size;
-	/* TQM ring page size and level. */
-	uint8_t	tqm_ring8_pg_size_tqm_ring_lvl;
-	/* TQM ring PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING8_TQM_RING_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING8_TQM_RING_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING8_TQM_RING_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING8_TQM_RING_LVL_LVL_1	UINT32_C(0x1)
+	uint64_t	resp_addr;
 	/*
-	 * PBL pointer points to PDE table with each entry pointing to
-	 * PTE tables.
+	 * Function ID of the function that is being queried.
+	 * 0xFF... (All Fs) if the query is for the requesting
+	 * function.
+	 * A privileged PF can query for other function's statistics.
 	 */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING8_TQM_RING_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING8_TQM_RING_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING8_TQM_RING_LVL_LVL_2
-	/* TQM ring page size. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING8_TQM_RING_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING8_TQM_RING_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING8_TQM_RING_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING8_TQM_RING_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING8_TQM_RING_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING8_TQM_RING_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING8_TQM_RING_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING8_TQM_RING_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING8_TQM_RING_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING8_TQM_RING_PG_SIZE_PG_1G
-	uint8_t	ring8_unused[3];
-	/* Number of TQM ring entries. */
-	uint32_t	tqm_ring8_num_entries;
-	/* TQM ring page directory. */
-	uint64_t	tqm_ring8_page_dir;
-	/* TQM ring page size and level. */
-	uint8_t	tqm_ring9_pg_size_tqm_ring_lvl;
-	/* TQM ring PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING9_TQM_RING_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING9_TQM_RING_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING9_TQM_RING_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING9_TQM_RING_LVL_LVL_1	UINT32_C(0x1)
+	uint16_t	fid;
+	uint8_t	flags;
 	/*
-	 * PBL pointer points to PDE table with each entry pointing to
-	 * PTE tables.
+	 * This bit should be set to 1 when request is for only RoCE
+	 * statistics. This will be honored only if the caller_fid is
+	 * a privileged PF. In all other cases FID and caller_fid should
+	 * be the same.
 	 */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING9_TQM_RING_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING9_TQM_RING_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING9_TQM_RING_LVL_LVL_2
-	/* TQM ring page size. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING9_TQM_RING_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING9_TQM_RING_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING9_TQM_RING_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING9_TQM_RING_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING9_TQM_RING_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING9_TQM_RING_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING9_TQM_RING_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING9_TQM_RING_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING9_TQM_RING_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING9_TQM_RING_PG_SIZE_PG_1G
-	uint8_t	ring9_unused[3];
-	/* Number of TQM ring entries. */
-	uint32_t	tqm_ring9_num_entries;
-	/* TQM ring page directory. */
-	uint64_t	tqm_ring9_page_dir;
-	/* TQM ring page size and level. */
-	uint8_t	tqm_ring10_pg_size_tqm_ring_lvl;
-	/* TQM ring PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING10_TQM_RING_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING10_TQM_RING_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING10_TQM_RING_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING10_TQM_RING_LVL_LVL_1	UINT32_C(0x1)
+	#define HWRM_FUNC_QSTATS_INPUT_FLAGS_ROCE_ONLY	UINT32_C(0x1)
 	/*
-	 * PBL pointer points to PDE table with each entry pointing to
-	 * PTE tables.
+	 * This bit should be set to 1 when request is for the counter mask,
+	 * representing the width of each of the stats counters, rather
+	 * than counters themselves.
 	 */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING10_TQM_RING_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING10_TQM_RING_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING10_TQM_RING_LVL_LVL_2
-	/* TQM ring page size. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING10_TQM_RING_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING10_TQM_RING_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING10_TQM_RING_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING10_TQM_RING_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING10_TQM_RING_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING10_TQM_RING_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING10_TQM_RING_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING10_TQM_RING_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING10_TQM_RING_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING10_TQM_RING_PG_SIZE_PG_1G
-	uint8_t	ring10_unused[3];
-	/* Number of TQM ring entries. */
-	uint32_t	tqm_ring10_num_entries;
-	/* TQM ring page directory. */
-	uint64_t	tqm_ring10_page_dir;
-	/* Number of Tx KTLS context entries allocated. */
-	uint32_t	tkc_num_entries;
-	/* Number of Rx KTLS context entries allocated. */
-	uint32_t	rkc_num_entries;
-	/* Tx KTLS context page directory. */
-	uint64_t	tkc_page_dir;
-	/* Rx KTLS context page directory. */
-	uint64_t	rkc_page_dir;
-	/* Number of bytes allocated for each Tx KTLS context entry. */
-	uint16_t	tkc_entry_size;
-	/* Number of bytes allocated for each Rx KTLS context entry. */
-	uint16_t	rkc_entry_size;
-	/* Tx KTLS context page size and level. */
-	uint8_t	tkc_pg_size_tkc_lvl;
-	/* Tx KTLS context PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TKC_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TKC_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TKC_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TKC_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TKC_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TKC_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_TKC_LVL_LVL_2
-	/* Tx KTLS context page size. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TKC_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TKC_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TKC_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TKC_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TKC_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TKC_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TKC_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TKC_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TKC_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_TKC_PG_SIZE_PG_1G
-	/* Rx KTLS context page size and level. */
-	uint8_t	rkc_pg_size_tkc_lvl;
-	/* Rx KTLS context PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RKC_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RKC_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RKC_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RKC_LVL_LVL_1	UINT32_C(0x1)
+	#define HWRM_FUNC_QSTATS_INPUT_FLAGS_COUNTER_MASK	UINT32_C(0x2)
 	/*
-	 * PBL pointer points to PDE table with each entry pointing to
-	 * PTE tables.
+	 * This bit should be set to 1 when request is for only L2
+	 * statistics. This will be honored only if the caller_fid is
+	 * a privileged PF. In all other cases FID and caller_fid should
+	 * be the same.
 	 */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RKC_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RKC_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_RKC_LVL_LVL_2
-	/* Rx KTLS context page size. */
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RKC_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RKC_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RKC_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RKC_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RKC_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RKC_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RKC_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RKC_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RKC_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_RKC_PG_SIZE_PG_1G
-	/* Reserved for future. */
-	uint8_t	rsvd[2];
-} hwrm_func_backing_store_cfg_input_t, *phwrm_func_backing_store_cfg_input_t;
+	#define HWRM_FUNC_QSTATS_INPUT_FLAGS_L2_ONLY	UINT32_C(0x4)
+	uint8_t	unused_0[5];
+} hwrm_func_qstats_input_t, *phwrm_func_qstats_input_t;
 
-/* hwrm_func_backing_store_cfg_output (size:128b/16B) */
+/* hwrm_func_qstats_output (size:1408b/176B) */
 
-typedef struct hwrm_func_backing_store_cfg_output {
+typedef struct hwrm_func_qstats_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -15607,25 +17123,97 @@ typedef struct hwrm_func_backing_store_cfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	/* Number of transmitted unicast packets on the function. */
+	uint64_t	tx_ucast_pkts;
+	/* Number of transmitted multicast packets on the function. */
+	uint64_t	tx_mcast_pkts;
+	/* Number of transmitted broadcast packets on the function. */
+	uint64_t	tx_bcast_pkts;
+	/*
+	 * Number of transmitted packets that were discarded due to
+	 * internal NIC resource problems. For transmit, this
+	 * can only happen if TMP is configured to allow dropping
+	 * in HOL blocking conditions, which is not a normal
+	 * configuration.
+	 */
+	uint64_t	tx_discard_pkts;
+	/*
+	 * Number of dropped packets on transmit path on the function.
+	 * These are packets that have been marked for drop by
+	 * the TE CFA block or are packets that exceeded the
+	 * transmit MTU limit for the function.
+	 */
+	uint64_t	tx_drop_pkts;
+	/* Number of transmitted bytes for unicast traffic on the function. */
+	uint64_t	tx_ucast_bytes;
+	/* Number of transmitted bytes for multicast traffic on the function. */
+	uint64_t	tx_mcast_bytes;
+	/* Number of transmitted bytes for broadcast traffic on the function. */
+	uint64_t	tx_bcast_bytes;
+	/* Number of received unicast packets on the function. */
+	uint64_t	rx_ucast_pkts;
+	/* Number of received multicast packets on the function. */
+	uint64_t	rx_mcast_pkts;
+	/* Number of received broadcast packets on the function. */
+	uint64_t	rx_bcast_pkts;
+	/*
+	 * Number of received packets that were discarded on the function
+	 * due to resource limitations. This can happen for 3 reasons.
+	 * # The BD used for the packet has a bad format.
+	 * # There were no BDs available in the ring for the packet.
+	 * # There were no BDs available on-chip for the packet.
+	 */
+	uint64_t	rx_discard_pkts;
+	/*
+	 * Number of dropped packets on received path on the function.
+	 * These are packets that have been marked for drop by the
+	 * RE CFA.
+	 */
+	uint64_t	rx_drop_pkts;
+	/* Number of received bytes for unicast traffic on the function. */
+	uint64_t	rx_ucast_bytes;
+	/* Number of received bytes for multicast traffic on the function. */
+	uint64_t	rx_mcast_bytes;
+	/* Number of received bytes for broadcast traffic on the function. */
+	uint64_t	rx_bcast_bytes;
+	/* Number of aggregated unicast packets on the function. */
+	uint64_t	rx_agg_pkts;
+	/* Number of aggregated unicast bytes on the function. */
+	uint64_t	rx_agg_bytes;
+	/* Number of aggregation events on the function. */
+	uint64_t	rx_agg_events;
+	/* Number of aborted aggregations on the function. */
+	uint64_t	rx_agg_aborts;
+	/*
+	 * This field is the sequence of the statistics of a function being
+	 * cleared. Firmware starts the sequence from zero. It increments
+	 * the sequence number every time the statistics of the function
+	 * are cleared, which can be triggered by a clear statistics request
+	 * or by freeing all statistics contexts of the function. If a user
+	 * is interested in knowing if the statistics have been cleared
+	 * since the last query, it can keep track of this sequence number
+	 * between queries.
+	 */
+	uint8_t	clear_seq;
+	uint8_t	unused_0[6];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
 	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_func_backing_store_cfg_output_t, *phwrm_func_backing_store_cfg_output_t;
+} hwrm_func_qstats_output_t, *phwrm_func_qstats_output_t;
 
-/********************************
- * hwrm_func_backing_store_qcfg *
- ********************************/
+/************************
+ * hwrm_func_qstats_ext *
+ ************************/
 
 
-/* hwrm_func_backing_store_qcfg_input (size:128b/16B) */
+/* hwrm_func_qstats_ext_input (size:256b/32B) */
 
-typedef struct hwrm_func_backing_store_qcfg_input {
+typedef struct hwrm_func_qstats_ext_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -15654,11 +17242,48 @@ typedef struct hwrm_func_backing_store_qcfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-} hwrm_func_backing_store_qcfg_input_t, *phwrm_func_backing_store_qcfg_input_t;
+	/*
+	 * Function ID of the function that is being queried.
+	 * 0xFF... (All Fs) if the query is for the requesting
+	 * function.
+	 * A privileged PF can query for other function's statistics.
+	 */
+	uint16_t	fid;
+	uint8_t	flags;
+	/*
+	 * This bit should be set to 1 when request is for only RoCE
+	 * statistics. This will be honored only if the caller_fid is
+	 * a privileged PF. In all other cases FID and caller_fid should
+	 * be the same.
+	 */
+	#define HWRM_FUNC_QSTATS_EXT_INPUT_FLAGS_ROCE_ONLY	UINT32_C(0x1)
+	/*
+	 * This bit should be set to 1 when request is for the counter mask
+	 * representing the width of each of the stats counters, rather
+	 * than counters themselves.
+	 */
+	#define HWRM_FUNC_QSTATS_EXT_INPUT_FLAGS_COUNTER_MASK	UINT32_C(0x2)
+	uint8_t	unused_0[1];
+	uint32_t	enables;
+	/*
+	 * This bit must be '1' for the schq_id and traffic_class fields to
+	 * be configured.
+	 */
+	#define HWRM_FUNC_QSTATS_EXT_INPUT_ENABLES_SCHQ_ID	UINT32_C(0x1)
+	/* Specifies the SCHQ for which to gather statistics */
+	uint16_t	schq_id;
+	/*
+	 * Specifies the traffic class for which to gather statistics. Valid
+	 * values are 0 through (max_configurable_queues - 1), where
+	 * max_configurable_queues is in the response of HWRM_QUEUE_QPORTCFG
+	 */
+	uint16_t	traffic_class;
+	uint8_t	unused_1[4];
+} hwrm_func_qstats_ext_input_t, *phwrm_func_qstats_ext_input_t;
 
-/* hwrm_func_backing_store_qcfg_output (size:2496b/312B) */
+/* hwrm_func_qstats_ext_output (size:1536b/192B) */
 
-typedef struct hwrm_func_backing_store_qcfg_output {
+typedef struct hwrm_func_qstats_ext_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -15667,585 +17292,26407 @@ typedef struct hwrm_func_backing_store_qcfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint32_t	flags;
+	/* Number of received unicast packets */
+	uint64_t	rx_ucast_pkts;
+	/* Number of received multicast packets */
+	uint64_t	rx_mcast_pkts;
+	/* Number of received broadcast packets */
+	uint64_t	rx_bcast_pkts;
+	/* Number of discarded packets on received path */
+	uint64_t	rx_discard_pkts;
+	/* Number of packets on receive path with error */
+	uint64_t	rx_error_pkts;
+	/* Number of received bytes for unicast traffic */
+	uint64_t	rx_ucast_bytes;
+	/* Number of received bytes for multicast traffic */
+	uint64_t	rx_mcast_bytes;
+	/* Number of received bytes for broadcast traffic */
+	uint64_t	rx_bcast_bytes;
+	/* Number of transmitted unicast packets */
+	uint64_t	tx_ucast_pkts;
+	/* Number of transmitted multicast packets */
+	uint64_t	tx_mcast_pkts;
+	/* Number of transmitted broadcast packets */
+	uint64_t	tx_bcast_pkts;
+	/* Number of packets on transmit path with error */
+	uint64_t	tx_error_pkts;
+	/* Number of discarded packets on transmit path */
+	uint64_t	tx_discard_pkts;
+	/* Number of transmitted bytes for unicast traffic */
+	uint64_t	tx_ucast_bytes;
+	/* Number of transmitted bytes for multicast traffic */
+	uint64_t	tx_mcast_bytes;
+	/* Number of transmitted bytes for broadcast traffic */
+	uint64_t	tx_bcast_bytes;
+	/* Number of TPA eligible packets */
+	uint64_t	rx_tpa_eligible_pkt;
+	/* Number of TPA eligible bytes */
+	uint64_t	rx_tpa_eligible_bytes;
+	/* Number of TPA packets */
+	uint64_t	rx_tpa_pkt;
+	/* Number of TPA bytes */
+	uint64_t	rx_tpa_bytes;
+	/* Number of TPA errors */
+	uint64_t	rx_tpa_errors;
+	/* Number of TPA errors */
+	uint64_t	rx_tpa_events;
+	uint8_t	unused_0[7];
 	/*
-	 * When set, the firmware only uses on-chip resources and does not
-	 * expect any backing store to be provided by the host driver. This
-	 * mode provides minimal L2 functionality (e.g. limited L2 resources,
-	 * no RoCE).
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_FLAGS_PREBOOT_MODE		UINT32_C(0x1)
+	uint8_t	valid;
+} hwrm_func_qstats_ext_output_t, *phwrm_func_qstats_ext_output_t;
+
+/***********************
+ * hwrm_func_clr_stats *
+ ***********************/
+
+
+/* hwrm_func_clr_stats_input (size:192b/24B) */
+
+typedef struct hwrm_func_clr_stats_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * When set, the 32b `mrav_num_entries` field is logically divided
-	 * into two 16b fields, `mr_num_entries` and `av_num_entries`.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_FLAGS_MRAV_RESERVATION_SPLIT	UINT32_C(0x2)
-	uint32_t	enables;
+	uint16_t	cmpl_ring;
 	/*
-	 * This bit must be '1' for the qp fields to be
-	 * configured.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_QP		UINT32_C(0x1)
+	uint16_t	seq_id;
 	/*
-	 * This bit must be '1' for the srq fields to be
-	 * configured.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_SRQ		UINT32_C(0x2)
+	uint16_t	target_id;
 	/*
-	 * This bit must be '1' for the cq fields to be
-	 * configured.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_CQ		UINT32_C(0x4)
+	uint64_t	resp_addr;
 	/*
-	 * This bit must be '1' for the vnic fields to be
-	 * configured.
+	 * Function ID of the function.
+	 * 0xFF... (All Fs) if the query is for the requesting
+	 * function.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_VNIC	UINT32_C(0x8)
+	uint16_t	fid;
+	uint8_t	unused_0[6];
+} hwrm_func_clr_stats_input_t, *phwrm_func_clr_stats_input_t;
+
+/* hwrm_func_clr_stats_output (size:128b/16B) */
+
+typedef struct hwrm_func_clr_stats_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
 	/*
-	 * This bit must be '1' for the stat fields to be
-	 * configured.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_STAT	UINT32_C(0x10)
-	/*
-	 * This bit must be '1' for the tqm_sp fields to be
-	 * configured.
+	uint8_t	valid;
+} hwrm_func_clr_stats_output_t, *phwrm_func_clr_stats_output_t;
+
+/**************************
+ * hwrm_func_vf_resc_free *
+ **************************/
+
+
+/* hwrm_func_vf_resc_free_input (size:192b/24B) */
+
+typedef struct hwrm_func_vf_resc_free_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_TQM_SP	UINT32_C(0x20)
+	uint16_t	cmpl_ring;
 	/*
-	 * This bit must be '1' for the tqm_ring0 fields to be
-	 * configured.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_TQM_RING0	UINT32_C(0x40)
+	uint16_t	seq_id;
 	/*
-	 * This bit must be '1' for the tqm_ring1 fields to be
-	 * configured.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_TQM_RING1	UINT32_C(0x80)
+	uint16_t	target_id;
 	/*
-	 * This bit must be '1' for the tqm_ring2 fields to be
-	 * configured.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_TQM_RING2	UINT32_C(0x100)
+	uint64_t	resp_addr;
 	/*
-	 * This bit must be '1' for the tqm_ring3 fields to be
-	 * configured.
+	 * This value is used to identify a Virtual Function (VF).
+	 * The scope of VF ID is local within a PF.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_TQM_RING3	UINT32_C(0x200)
+	uint16_t	vf_id;
+	uint8_t	unused_0[6];
+} hwrm_func_vf_resc_free_input_t, *phwrm_func_vf_resc_free_input_t;
+
+/* hwrm_func_vf_resc_free_output (size:128b/16B) */
+
+typedef struct hwrm_func_vf_resc_free_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
 	/*
-	 * This bit must be '1' for the tqm_ring4 fields to be
-	 * configured.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_TQM_RING4	UINT32_C(0x400)
+	uint8_t	valid;
+} hwrm_func_vf_resc_free_output_t, *phwrm_func_vf_resc_free_output_t;
+
+/**********************
+ * hwrm_func_drv_rgtr *
+ **********************/
+
+
+/* hwrm_func_drv_rgtr_input (size:896b/112B) */
+
+typedef struct hwrm_func_drv_rgtr_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * This bit must be '1' for the tqm_ring5 fields to be
-	 * configured.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_TQM_RING5	UINT32_C(0x800)
+	uint16_t	cmpl_ring;
 	/*
-	 * This bit must be '1' for the tqm_ring6 fields to be
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	flags;
+	/*
+	 * When this bit is '1', the function driver is requesting
+	 * all requests from its children VF drivers to be
+	 * forwarded to itself.
+	 * This flag can only be set by the PF driver.
+	 * If a VF driver sets this flag, it should be ignored
+	 * by the HWRM.
+	 */
+	#define HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_FWD_ALL_MODE			UINT32_C(0x1)
+	/*
+	 * When this bit is '1', the function is requesting none of
+	 * the requests from its children VF drivers to be
+	 * forwarded to itself.
+	 * This flag can only be set by the PF driver.
+	 * If a VF driver sets this flag, it should be ignored
+	 * by the HWRM.
+	 */
+	#define HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_FWD_NONE_MODE			UINT32_C(0x2)
+	/*
+	 * When this bit is '1', then ver_maj_8b, ver_min_8b, ver_upd_8b
+	 * fields shall be ignored and ver_maj, ver_min, ver_upd
+	 * and ver_patch shall be used for the driver version information.
+	 * When this bit is '0', then ver_maj_8b, ver_min_8b, ver_upd_8b
+	 * fields shall be used for the driver version information and
+	 * ver_maj, ver_min, ver_upd and ver_patch shall be ignored.
+	 */
+	#define HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_16BIT_VER_MODE		UINT32_C(0x4)
+	/*
+	 * When this bit is '1', the function is indicating support of
+	 * 64bit flow handle. The firmware that only supports 64bit flow
+	 * handle should check this bit before allowing processing of
+	 * HWRM_CFA_FLOW_XXX commands from the requesting function as
+	 * firmware with 64bit flow handle support can only be compatible
+	 * with drivers that support 64bit flow handle. The legacy drivers
+	 * that don't support 64bit flow handle won't be able to use
+	 * HWRM_CFA_FLOW_XXX commands when running with new firmware that
+	 * only supports 64bit flow handle. The new firmware support 64bit
+	 * flow handle returns HWRM_ERR_CODE_CMD_NOT_SUPPORTED
+	 * status to the legacy driver when encounters these commands.
+	 */
+	#define HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_FLOW_HANDLE_64BIT_MODE	UINT32_C(0x8)
+	/*
+	 * When this bit is '1', the function is indicating support of
+	 * Hot Reset. The driver interface will destroy the resources,
+	 * unregister the function and register again up on receiving
+	 * the RESET_NOTIFY Async notification from the core firmware.
+	 * The core firmware will this use flag and trigger the Hot Reset
+	 * process only if all the registered driver instances are capable
+	 * of this support.
+	 */
+	#define HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_HOT_RESET_SUPPORT		UINT32_C(0x10)
+	/*
+	 * When this bit is 1, the function is indicating the support of the
+	 * error recovery capability. Error recovery support will be used by
+	 * firmware only if all the driver instances support error recovery
+	 * process. By setting this bit, driver is indicating support for
+	 * corresponding async event completion message. These will be
+	 * delivered to the driver even if they did not register for it.
+	 * If supported, after receiving reset notify async event with fatal
+	 * flag set in event data1, then all the drivers have to tear down
+	 * their resources without sending any HWRM commands to FW.
+	 */
+	#define HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_ERROR_RECOVERY_SUPPORT	UINT32_C(0x20)
+	/*
+	 * When this bit is 1, the function is indicating the support of the
+	 * Master capability. The Firmware will use this capability to select
+	 * the Master function. The master function will be used to initiate
+	 * designated functionality like error recovery etc. If none of the
+	 * registered PF's or trusted VF's indicate this support, then
+	 * firmware will select the 1st registered PF as Master capable
+	 * instance.
+	 */
+	#define HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_MASTER_SUPPORT		UINT32_C(0x40)
+	/*
+	 * When this bit is 1, the function is indicating the support of the
+	 * fast reset capability. Fast reset support will be used by
+	 * firmware only if all the driver instances support fast reset
+	 * process. By setting this bit, driver is indicating support for
+	 * corresponding async event completion message. These will be
+	 * delivered to the driver even if they did not register for it.
+	 * If supported, after receiving reset notify async event with fast
+	 * reset flag set in event data1, then all the drivers have to tear
+	 * down their resources without sending any HWRM commands to FW.
+	 */
+	#define HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_FAST_RESET_SUPPORT		UINT32_C(0x80)
+	/*
+	 * When this bit is 1, the function's driver is indicating the
+	 * support of handling the vnic_rss_cfg's INVALID_PARAM error
+	 * returned by firmware. Firmware returns error, if host driver
+	 * configures the invalid hash_types bit combination for a given
+	 * IP version.
+	 */
+	#define HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_RSS_STRICT_HASH_TYPE_SUPPORT	UINT32_C(0x100)
+	/*
+	 * When this bit is 1, the function's driver is indicating the
+	 * support of handling the NPAR 1.2 feature where the s-tag may be
+	 * a value other than 0x8100 or 0x88a8.
+	 */
+	#define HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_NPAR_1_2_SUPPORT		UINT32_C(0x200)
+	/*
+	 * When this bit is 1, the function's driver is indicating the
+	 * support for asymmetric queue configuration, such that queue
+	 * ids and service profiles on TX side are not the same as the
+	 * corresponding queue configuration on the RX side
+	 */
+	#define HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_ASYM_QUEUE_CFG_SUPPORT	UINT32_C(0x400)
+	/*
+	 * When this bit is 1, the function's driver is indicating to the
+	 * firmware that the Ingress NIC flows will be programmed by the
+	 * TruFlow application and the firmware flow manager should reject
+	 * flow-create commands that programs ingress lookup flows for this
+	 * function.
+	 */
+	#define HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_TF_INGRESS_NIC_FLOW_MODE	UINT32_C(0x800)
+	uint32_t	enables;
+	/*
+	 * This bit must be '1' for the os_type field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_TQM_RING6	UINT32_C(0x1000)
+	#define HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_OS_TYPE		UINT32_C(0x1)
 	/*
-	 * This bit must be '1' for the tqm_ring7 fields to be
+	 * This bit must be '1' for the ver field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_TQM_RING7	UINT32_C(0x2000)
+	#define HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_VER		UINT32_C(0x2)
 	/*
-	 * This bit must be '1' for the mrav fields to be
+	 * This bit must be '1' for the timestamp field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_MRAV	UINT32_C(0x4000)
+	#define HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_TIMESTAMP	UINT32_C(0x4)
 	/*
-	 * This bit must be '1' for the tim fields to be
+	 * This bit must be '1' for the vf_req_fwd field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_TIM		UINT32_C(0x8000)
+	#define HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_VF_REQ_FWD	UINT32_C(0x8)
 	/*
-	 * This bit must be '1' for the tqm_ring8 fields to be
+	 * This bit must be '1' for the async_event_fwd field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_TQM_RING8	UINT32_C(0x10000)
+	#define HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_ASYNC_EVENT_FWD	UINT32_C(0x10)
 	/*
-	 * This bit must be '1' for the tqm_ring9 fields to be
+	 * This value indicates the type of OS. The values are based on
+	 * CIM_OperatingSystem.mof file as published by the DMTF.
+	 */
+	uint16_t	os_type;
+	/* Unknown */
+	#define HWRM_FUNC_DRV_RGTR_INPUT_OS_TYPE_UNKNOWN   UINT32_C(0x0)
+	/* Other OS not listed below. */
+	#define HWRM_FUNC_DRV_RGTR_INPUT_OS_TYPE_OTHER	UINT32_C(0x1)
+	/* MSDOS OS. */
+	#define HWRM_FUNC_DRV_RGTR_INPUT_OS_TYPE_MSDOS	UINT32_C(0xe)
+	/* Windows OS. */
+	#define HWRM_FUNC_DRV_RGTR_INPUT_OS_TYPE_WINDOWS   UINT32_C(0x12)
+	/* Solaris OS. */
+	#define HWRM_FUNC_DRV_RGTR_INPUT_OS_TYPE_SOLARIS   UINT32_C(0x1d)
+	/* Linux OS. */
+	#define HWRM_FUNC_DRV_RGTR_INPUT_OS_TYPE_LINUX	UINT32_C(0x24)
+	/* FreeBSD OS. */
+	#define HWRM_FUNC_DRV_RGTR_INPUT_OS_TYPE_FREEBSD   UINT32_C(0x2a)
+	/* VMware ESXi OS. */
+	#define HWRM_FUNC_DRV_RGTR_INPUT_OS_TYPE_ESXI	UINT32_C(0x68)
+	/* Microsoft Windows 8 64-bit OS. */
+	#define HWRM_FUNC_DRV_RGTR_INPUT_OS_TYPE_WIN864	UINT32_C(0x73)
+	/* Microsoft Windows Server 2012 R2 OS. */
+	#define HWRM_FUNC_DRV_RGTR_INPUT_OS_TYPE_WIN2012R2 UINT32_C(0x74)
+	/* UEFI driver. */
+	#define HWRM_FUNC_DRV_RGTR_INPUT_OS_TYPE_UEFI	UINT32_C(0x8000)
+	#define HWRM_FUNC_DRV_RGTR_INPUT_OS_TYPE_LAST	HWRM_FUNC_DRV_RGTR_INPUT_OS_TYPE_UEFI
+	/* This is the 8bit major version of the driver. */
+	uint8_t	ver_maj_8b;
+	/* This is the 8bit minor version of the driver. */
+	uint8_t	ver_min_8b;
+	/* This is the 8bit update version of the driver. */
+	uint8_t	ver_upd_8b;
+	uint8_t	unused_0[3];
+	/*
+	 * This is a 32-bit timestamp provided by the driver for
+	 * keep alive.
+	 * The timestamp is in multiples of 1ms.
+	 */
+	uint32_t	timestamp;
+	uint8_t	unused_1[4];
+	/*
+	 * This is a 256-bit bit mask provided by the PF driver for
+	 * letting the HWRM know what commands issued by the VF driver
+	 * to the HWRM should be forwarded to the PF driver.
+	 * Nth bit refers to the Nth req_type.
+	 *
+	 * Setting Nth bit to 1 indicates that requests from the
+	 * VF driver with req_type equal to N shall be forwarded to
+	 * the parent PF driver.
+	 *
+	 * This field is not valid for the VF driver.
+	 */
+	uint32_t	vf_req_fwd[8];
+	/*
+	 * This is a 256-bit bit mask provided by the function driver
+	 * (PF or VF driver) to indicate the list of asynchronous event
+	 * completions to be forwarded.
+	 *
+	 * Nth bit refers to the Nth event_id.
+	 *
+	 * Setting Nth bit to 1 by the function driver shall result in
+	 * the HWRM forwarding asynchronous event completion with
+	 * event_id equal to N.
+	 *
+	 * If all bits are set to 0 (value of 0), then the HWRM shall
+	 * not forward any asynchronous event completion to this
+	 * function driver.
+	 */
+	uint32_t	async_event_fwd[8];
+	/* This is the 16bit major version of the driver. */
+	uint16_t	ver_maj;
+	/* This is the 16bit minor version of the driver. */
+	uint16_t	ver_min;
+	/* This is the 16bit update version of the driver. */
+	uint16_t	ver_upd;
+	/* This is the 16bit patch version of the driver. */
+	uint16_t	ver_patch;
+} hwrm_func_drv_rgtr_input_t, *phwrm_func_drv_rgtr_input_t;
+
+/* hwrm_func_drv_rgtr_output (size:128b/16B) */
+
+typedef struct hwrm_func_drv_rgtr_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint32_t	flags;
+	/*
+	 * When this bit is '1', it indicates that the
+	 * HWRM_FUNC_DRV_IF_CHANGE call is supported.
+	 */
+	#define HWRM_FUNC_DRV_RGTR_OUTPUT_FLAGS_IF_CHANGE_SUPPORTED	UINT32_C(0x1)
+	uint8_t	unused_0[3];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_drv_rgtr_output_t, *phwrm_func_drv_rgtr_output_t;
+
+/************************
+ * hwrm_func_drv_unrgtr *
+ ************************/
+
+
+/* hwrm_func_drv_unrgtr_input (size:192b/24B) */
+
+typedef struct hwrm_func_drv_unrgtr_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	flags;
+	/*
+	 * When this bit is '1', the function driver is notifying
+	 * the HWRM to prepare for the shutdown.
+	 */
+	#define HWRM_FUNC_DRV_UNRGTR_INPUT_FLAGS_PREPARE_FOR_SHUTDOWN	UINT32_C(0x1)
+	uint8_t	unused_0[4];
+} hwrm_func_drv_unrgtr_input_t, *phwrm_func_drv_unrgtr_input_t;
+
+/* hwrm_func_drv_unrgtr_output (size:128b/16B) */
+
+typedef struct hwrm_func_drv_unrgtr_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_drv_unrgtr_output_t, *phwrm_func_drv_unrgtr_output_t;
+
+/**********************
+ * hwrm_func_buf_rgtr *
+ **********************/
+
+
+/* hwrm_func_buf_rgtr_input (size:1024b/128B) */
+
+typedef struct hwrm_func_buf_rgtr_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	enables;
+	/*
+	 * This bit must be '1' for the vf_id field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_TQM_RING9	UINT32_C(0x20000)
+	#define HWRM_FUNC_BUF_RGTR_INPUT_ENABLES_VF_ID		UINT32_C(0x1)
 	/*
-	 * This bit must be '1' for the tqm_ring10 fields to be
+	 * This bit must be '1' for the err_buf_addr field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_TQM_RING10	UINT32_C(0x40000)
+	#define HWRM_FUNC_BUF_RGTR_INPUT_ENABLES_ERR_BUF_ADDR	UINT32_C(0x2)
 	/*
-	 * This bit must be '1' for the Tx KTLS context
-	 * fields to be configured.
+	 * This value is used to identify a Virtual Function (VF).
+	 * The scope of VF ID is local within a PF.
 	 */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_TKC		UINT32_C(0x80000)
+	uint16_t	vf_id;
 	/*
-	 * This bit must be '1' for the Rx KTLS context
-	 * fields to be configured.
+	 * This field represents the number of pages used for request
+	 * buffer(s).
 	 */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_RKC		UINT32_C(0x100000)
-	/* QPC page size and level. */
-	uint8_t	qpc_pg_size_qpc_lvl;
-	/* QPC PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_QPC_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_QPC_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_QPC_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_QPC_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_QPC_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_QPC_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_QPC_LVL_LVL_2
-	/* QPC page size. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_QPC_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_QPC_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_QPC_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_QPC_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_QPC_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_QPC_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_QPC_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_QPC_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_QPC_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_QPC_PG_SIZE_PG_1G
-	/* SRQ page size and level. */
-	uint8_t	srq_pg_size_srq_lvl;
-	/* SRQ PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_SRQ_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_SRQ_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_SRQ_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_SRQ_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_SRQ_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_SRQ_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_SRQ_LVL_LVL_2
-	/* SRQ page size. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_SRQ_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_SRQ_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_SRQ_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_SRQ_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_SRQ_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_SRQ_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_SRQ_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_SRQ_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_SRQ_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_SRQ_PG_SIZE_PG_1G
-	/* CQ page size and level. */
-	uint8_t	cq_pg_size_cq_lvl;
-	/* CQ PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_CQ_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_CQ_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_CQ_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_CQ_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_CQ_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_CQ_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_CQ_LVL_LVL_2
-	/* CQ page size. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_CQ_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_CQ_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_CQ_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_CQ_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	uint16_t	req_buf_num_pages;
+	/*
+	 * This field represents the page size used for request
+	 * buffer(s).
+	 */
+	uint16_t	req_buf_page_size;
+	/* 16 bytes */
+	#define HWRM_FUNC_BUF_RGTR_INPUT_REQ_BUF_PAGE_SIZE_16B UINT32_C(0x4)
+	/* 4 Kbytes */
+	#define HWRM_FUNC_BUF_RGTR_INPUT_REQ_BUF_PAGE_SIZE_4K  UINT32_C(0xc)
+	/* 8 Kbytes */
+	#define HWRM_FUNC_BUF_RGTR_INPUT_REQ_BUF_PAGE_SIZE_8K  UINT32_C(0xd)
+	/* 64 Kbytes */
+	#define HWRM_FUNC_BUF_RGTR_INPUT_REQ_BUF_PAGE_SIZE_64K UINT32_C(0x10)
+	/* 2 Mbytes */
+	#define HWRM_FUNC_BUF_RGTR_INPUT_REQ_BUF_PAGE_SIZE_2M  UINT32_C(0x15)
+	/* 4 Mbytes */
+	#define HWRM_FUNC_BUF_RGTR_INPUT_REQ_BUF_PAGE_SIZE_4M  UINT32_C(0x16)
+	/* 1 Gbytes */
+	#define HWRM_FUNC_BUF_RGTR_INPUT_REQ_BUF_PAGE_SIZE_1G  UINT32_C(0x1e)
+	#define HWRM_FUNC_BUF_RGTR_INPUT_REQ_BUF_PAGE_SIZE_LAST HWRM_FUNC_BUF_RGTR_INPUT_REQ_BUF_PAGE_SIZE_1G
+	/* The length of the request buffer per VF in bytes. */
+	uint16_t	req_buf_len;
+	/* The length of the response buffer in bytes. */
+	uint16_t	resp_buf_len;
+	uint8_t	unused_0[2];
+	/* This field represents the page address of page #0. */
+	uint64_t	req_buf_page_addr0;
+	/* This field represents the page address of page #1. */
+	uint64_t	req_buf_page_addr1;
+	/* This field represents the page address of page #2. */
+	uint64_t	req_buf_page_addr2;
+	/* This field represents the page address of page #3. */
+	uint64_t	req_buf_page_addr3;
+	/* This field represents the page address of page #4. */
+	uint64_t	req_buf_page_addr4;
+	/* This field represents the page address of page #5. */
+	uint64_t	req_buf_page_addr5;
+	/* This field represents the page address of page #6. */
+	uint64_t	req_buf_page_addr6;
+	/* This field represents the page address of page #7. */
+	uint64_t	req_buf_page_addr7;
+	/* This field represents the page address of page #8. */
+	uint64_t	req_buf_page_addr8;
+	/* This field represents the page address of page #9. */
+	uint64_t	req_buf_page_addr9;
+	/*
+	 * This field is used to receive the error reporting from
+	 * the chipset. Only applicable for PFs.
+	 */
+	uint64_t	error_buf_addr;
+	/*
+	 * This field is used to receive the response forwarded by the
+	 * HWRM.
+	 */
+	uint64_t	resp_buf_addr;
+} hwrm_func_buf_rgtr_input_t, *phwrm_func_buf_rgtr_input_t;
+
+/* hwrm_func_buf_rgtr_output (size:128b/16B) */
+
+typedef struct hwrm_func_buf_rgtr_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_buf_rgtr_output_t, *phwrm_func_buf_rgtr_output_t;
+
+/************************
+ * hwrm_func_buf_unrgtr *
+ ************************/
+
+
+/* hwrm_func_buf_unrgtr_input (size:192b/24B) */
+
+typedef struct hwrm_func_buf_unrgtr_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	enables;
+	/*
+	 * This bit must be '1' for the vf_id field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BUF_UNRGTR_INPUT_ENABLES_VF_ID	UINT32_C(0x1)
+	/*
+	 * This value is used to identify a Virtual Function (VF).
+	 * The scope of VF ID is local within a PF.
+	 */
+	uint16_t	vf_id;
+	uint8_t	unused_0[2];
+} hwrm_func_buf_unrgtr_input_t, *phwrm_func_buf_unrgtr_input_t;
+
+/* hwrm_func_buf_unrgtr_output (size:128b/16B) */
+
+typedef struct hwrm_func_buf_unrgtr_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_buf_unrgtr_output_t, *phwrm_func_buf_unrgtr_output_t;
+
+/**********************
+ * hwrm_func_drv_qver *
+ **********************/
+
+
+/* hwrm_func_drv_qver_input (size:192b/24B) */
+
+typedef struct hwrm_func_drv_qver_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Reserved for future use. */
+	uint32_t	reserved;
+	/*
+	 * Function ID of the function that is being queried.
+	 * 0xFF... (All Fs) if the query is for the requesting
+	 * function.
+	 */
+	uint16_t	fid;
+	/*
+	 * This field is used to indicate the driver type.
+	 * L2 or RoCE
+	 */
+	uint8_t	driver_type;
+	/* L2 driver version */
+	#define HWRM_FUNC_DRV_QVER_INPUT_DRIVER_TYPE_L2   UINT32_C(0x0)
+	/* RoCE driver version */
+	#define HWRM_FUNC_DRV_QVER_INPUT_DRIVER_TYPE_ROCE UINT32_C(0x1)
+	#define HWRM_FUNC_DRV_QVER_INPUT_DRIVER_TYPE_LAST HWRM_FUNC_DRV_QVER_INPUT_DRIVER_TYPE_ROCE
+	uint8_t	unused_0;
+} hwrm_func_drv_qver_input_t, *phwrm_func_drv_qver_input_t;
+
+/* hwrm_func_drv_qver_output (size:256b/32B) */
+
+typedef struct hwrm_func_drv_qver_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/*
+	 * This value indicates the type of OS. The values are based on
+	 * CIM_OperatingSystem.mof file as published by the DMTF.
+	 */
+	uint16_t	os_type;
+	/* Unknown */
+	#define HWRM_FUNC_DRV_QVER_OUTPUT_OS_TYPE_UNKNOWN   UINT32_C(0x0)
+	/* Other OS not listed below. */
+	#define HWRM_FUNC_DRV_QVER_OUTPUT_OS_TYPE_OTHER	UINT32_C(0x1)
+	/* MSDOS OS. */
+	#define HWRM_FUNC_DRV_QVER_OUTPUT_OS_TYPE_MSDOS	UINT32_C(0xe)
+	/* Windows OS. */
+	#define HWRM_FUNC_DRV_QVER_OUTPUT_OS_TYPE_WINDOWS   UINT32_C(0x12)
+	/* Solaris OS. */
+	#define HWRM_FUNC_DRV_QVER_OUTPUT_OS_TYPE_SOLARIS   UINT32_C(0x1d)
+	/* Linux OS. */
+	#define HWRM_FUNC_DRV_QVER_OUTPUT_OS_TYPE_LINUX	UINT32_C(0x24)
+	/* FreeBSD OS. */
+	#define HWRM_FUNC_DRV_QVER_OUTPUT_OS_TYPE_FREEBSD   UINT32_C(0x2a)
+	/* VMware ESXi OS. */
+	#define HWRM_FUNC_DRV_QVER_OUTPUT_OS_TYPE_ESXI	UINT32_C(0x68)
+	/* Microsoft Windows 8 64-bit OS. */
+	#define HWRM_FUNC_DRV_QVER_OUTPUT_OS_TYPE_WIN864	UINT32_C(0x73)
+	/* Microsoft Windows Server 2012 R2 OS. */
+	#define HWRM_FUNC_DRV_QVER_OUTPUT_OS_TYPE_WIN2012R2 UINT32_C(0x74)
+	/* UEFI driver. */
+	#define HWRM_FUNC_DRV_QVER_OUTPUT_OS_TYPE_UEFI	UINT32_C(0x8000)
+	#define HWRM_FUNC_DRV_QVER_OUTPUT_OS_TYPE_LAST	HWRM_FUNC_DRV_QVER_OUTPUT_OS_TYPE_UEFI
+	/* This is the 8bit major version of the driver. */
+	uint8_t	ver_maj_8b;
+	/* This is the 8bit minor version of the driver. */
+	uint8_t	ver_min_8b;
+	/* This is the 8bit update version of the driver. */
+	uint8_t	ver_upd_8b;
+	uint8_t	unused_0[3];
+	/* This is the 16bit major version of the driver. */
+	uint16_t	ver_maj;
+	/* This is the 16bit minor version of the driver. */
+	uint16_t	ver_min;
+	/* This is the 16bit update version of the driver. */
+	uint16_t	ver_upd;
+	/* This is the 16bit patch version of the driver. */
+	uint16_t	ver_patch;
+	uint8_t	unused_1[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_drv_qver_output_t, *phwrm_func_drv_qver_output_t;
+
+/****************************
+ * hwrm_func_resource_qcaps *
+ ****************************/
+
+
+/* hwrm_func_resource_qcaps_input (size:192b/24B) */
+
+typedef struct hwrm_func_resource_qcaps_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/*
+	 * Function ID of the function that is being queried.
+	 * 0xFF... (All Fs) if the query is for the requesting
+	 * function.
+	 */
+	uint16_t	fid;
+	uint8_t	unused_0[6];
+} hwrm_func_resource_qcaps_input_t, *phwrm_func_resource_qcaps_input_t;
+
+/* hwrm_func_resource_qcaps_output (size:704b/88B) */
+
+typedef struct hwrm_func_resource_qcaps_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/*
+	 * Maximum guaranteed number of VFs supported by PF. Not applicable for
+	 * VFs.
+	 */
+	uint16_t	max_vfs;
+	/* Maximum guaranteed number of MSI-X vectors supported by function. */
+	uint16_t	max_msix;
+	/*
+	 * Hint of strategy to be used by PF driver to reserve resources for
+	 * its VF.
+	 */
+	uint16_t	vf_reservation_strategy;
+	/*
+	 * The PF driver should evenly divide its remaining resources among
+	 * all VFs.
+	 */
+	#define HWRM_FUNC_RESOURCE_QCAPS_OUTPUT_VF_RESERVATION_STRATEGY_MAXIMAL	UINT32_C(0x0)
+	/* The PF driver should only reserve minimal resources for each VF. */
+	#define HWRM_FUNC_RESOURCE_QCAPS_OUTPUT_VF_RESERVATION_STRATEGY_MINIMAL	UINT32_C(0x1)
+	/*
+	 * The PF driver should not reserve any resources for each VF until
+	 * the VF interface is brought up.
+	 */
+	#define HWRM_FUNC_RESOURCE_QCAPS_OUTPUT_VF_RESERVATION_STRATEGY_MINIMAL_STATIC UINT32_C(0x2)
+	#define HWRM_FUNC_RESOURCE_QCAPS_OUTPUT_VF_RESERVATION_STRATEGY_LAST	HWRM_FUNC_RESOURCE_QCAPS_OUTPUT_VF_RESERVATION_STRATEGY_MINIMAL_STATIC
+	/* Minimum guaranteed number of RSS/COS contexts. */
+	uint16_t	min_rsscos_ctx;
+	/* Maximum non-guaranteed number of RSS/COS contexts */
+	uint16_t	max_rsscos_ctx;
+	/* Minimum guaranteed number of completion rings */
+	uint16_t	min_cmpl_rings;
+	/* Maximum non-guaranteed number of completion rings */
+	uint16_t	max_cmpl_rings;
+	/* Minimum guaranteed number of transmit rings */
+	uint16_t	min_tx_rings;
+	/* Maximum non-guaranteed number of transmit rings */
+	uint16_t	max_tx_rings;
+	/* Minimum guaranteed number of receive rings */
+	uint16_t	min_rx_rings;
+	/* Maximum non-guaranteed number of receive rings */
+	uint16_t	max_rx_rings;
+	/* Minimum guaranteed number of L2 contexts */
+	uint16_t	min_l2_ctxs;
+	/* Maximum non-guaranteed number of L2 contexts */
+	uint16_t	max_l2_ctxs;
+	/* Minimum guaranteed number of VNICs */
+	uint16_t	min_vnics;
+	/* Maximum non-guaranteed number of VNICs */
+	uint16_t	max_vnics;
+	/* Minimum guaranteed number of statistic contexts */
+	uint16_t	min_stat_ctx;
+	/* Maximum non-guaranteed number of statistic contexts */
+	uint16_t	max_stat_ctx;
+	/* Minimum guaranteed number of ring groups */
+	uint16_t	min_hw_ring_grps;
+	/* Maximum non-guaranteed number of ring groups */
+	uint16_t	max_hw_ring_grps;
+	/*
+	 * Maximum number of inputs into the transmit scheduler for this
+	 * function. The number of TX rings assigned to the function cannot
+	 * exceed this value.
+	 */
+	uint16_t	max_tx_scheduler_inputs;
+	uint16_t	flags;
+	/*
+	 * When this bit is '1', it indicates that VF_RESOURCE_CFG supports
+	 * feature to reserve all minimum resources when minimum >= 1,
+	 * otherwise returns an error.
+	 */
+	#define HWRM_FUNC_RESOURCE_QCAPS_OUTPUT_FLAGS_MIN_GUARANTEED	UINT32_C(0x1)
+	/* Minimum guaranteed number of MSI-X vectors supported by function */
+	uint16_t	min_msix;
+	/* Minimum guaranteed number of KTLS Tx Key Contexts */
+	uint32_t	min_ktls_tx_key_ctxs;
+	/* Maximum non-guaranteed number of KTLS Tx Key Contexts */
+	uint32_t	max_ktls_tx_key_ctxs;
+	/* Minimum guaranteed number of KTLS Rx Key Contexts */
+	uint32_t	min_ktls_rx_key_ctxs;
+	/* Maximum non-guaranteed number of KTLS Rx Key Contexts */
+	uint32_t	max_ktls_rx_key_ctxs;
+	/* Minimum guaranteed number of QUIC Tx Key Contexts */
+	uint32_t	min_quic_tx_key_ctxs;
+	/* Maximum non-guaranteed number of QUIC Tx Key Contexts */
+	uint32_t	max_quic_tx_key_ctxs;
+	/* Minimum guaranteed number of QUIC Rx Key Contexts */
+	uint32_t	min_quic_rx_key_ctxs;
+	/* Maximum non-guaranteed number of QUIC Rx Key Contexts */
+	uint32_t	max_quic_rx_key_ctxs;
+	uint8_t	unused_0[3];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_resource_qcaps_output_t, *phwrm_func_resource_qcaps_output_t;
+
+/*****************************
+ * hwrm_func_vf_resource_cfg *
+ *****************************/
+
+
+/* hwrm_func_vf_resource_cfg_input (size:704b/88B) */
+
+typedef struct hwrm_func_vf_resource_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* VF ID that is being configured by PF */
+	uint16_t	vf_id;
+	/* Maximum guaranteed number of MSI-X vectors for the function */
+	uint16_t	max_msix;
+	/* Minimum guaranteed number of RSS/COS contexts */
+	uint16_t	min_rsscos_ctx;
+	/* Maximum non-guaranteed number of RSS/COS contexts */
+	uint16_t	max_rsscos_ctx;
+	/* Minimum guaranteed number of completion rings */
+	uint16_t	min_cmpl_rings;
+	/* Maximum non-guaranteed number of completion rings */
+	uint16_t	max_cmpl_rings;
+	/* Minimum guaranteed number of transmit rings */
+	uint16_t	min_tx_rings;
+	/* Maximum non-guaranteed number of transmit rings */
+	uint16_t	max_tx_rings;
+	/* Minimum guaranteed number of receive rings */
+	uint16_t	min_rx_rings;
+	/* Maximum non-guaranteed number of receive rings */
+	uint16_t	max_rx_rings;
+	/* Minimum guaranteed number of L2 contexts */
+	uint16_t	min_l2_ctxs;
+	/* Maximum non-guaranteed number of L2 contexts */
+	uint16_t	max_l2_ctxs;
+	/* Minimum guaranteed number of VNICs */
+	uint16_t	min_vnics;
+	/* Maximum non-guaranteed number of VNICs */
+	uint16_t	max_vnics;
+	/* Minimum guaranteed number of statistic contexts */
+	uint16_t	min_stat_ctx;
+	/* Maximum non-guaranteed number of statistic contexts */
+	uint16_t	max_stat_ctx;
+	/* Minimum guaranteed number of ring groups */
+	uint16_t	min_hw_ring_grps;
+	/* Maximum non-guaranteed number of ring groups */
+	uint16_t	max_hw_ring_grps;
+	uint16_t	flags;
+	/*
+	 * If this bit is set, all minimum resources requested should be
+	 * reserved if minimum >= 1, otherwise return error. In case of
+	 * error, keep all existing reservations before the call.
+	 */
+	#define HWRM_FUNC_VF_RESOURCE_CFG_INPUT_FLAGS_MIN_GUARANTEED	UINT32_C(0x1)
+	/* Minimum guaranteed number of MSI-X vectors for the function */
+	uint16_t	min_msix;
+	/* Minimum guaranteed number of KTLS Tx Key Contexts */
+	uint32_t	min_ktls_tx_key_ctxs;
+	/* Maximum non-guaranteed number of KTLS Tx Key Contexts */
+	uint32_t	max_ktls_tx_key_ctxs;
+	/* Minimum guaranteed number of KTLS Rx Key Contexts */
+	uint32_t	min_ktls_rx_key_ctxs;
+	/* Maximum non-guaranteed number of KTLS Rx Key Contexts */
+	uint32_t	max_ktls_rx_key_ctxs;
+	/* Minimum guaranteed number of QUIC Tx Key Contexts */
+	uint32_t	min_quic_tx_key_ctxs;
+	/* Maximum non-guaranteed number of QUIC Tx Key Contexts */
+	uint32_t	max_quic_tx_key_ctxs;
+	/* Minimum guaranteed number of QUIC Rx Key Contexts */
+	uint32_t	min_quic_rx_key_ctxs;
+	/* Maximum non-guaranteed number of QUIC Rx Key Contexts */
+	uint32_t	max_quic_rx_key_ctxs;
+} hwrm_func_vf_resource_cfg_input_t, *phwrm_func_vf_resource_cfg_input_t;
+
+/* hwrm_func_vf_resource_cfg_output (size:384b/48B) */
+
+typedef struct hwrm_func_vf_resource_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Reserved number of RSS/COS contexts */
+	uint16_t	reserved_rsscos_ctx;
+	/* Reserved number of completion rings */
+	uint16_t	reserved_cmpl_rings;
+	/* Reserved number of transmit rings */
+	uint16_t	reserved_tx_rings;
+	/* Reserved number of receive rings */
+	uint16_t	reserved_rx_rings;
+	/* Reserved number of L2 contexts */
+	uint16_t	reserved_l2_ctxs;
+	/* Reserved number of VNICs */
+	uint16_t	reserved_vnics;
+	/* Reserved number of statistic contexts */
+	uint16_t	reserved_stat_ctx;
+	/* Reserved number of ring groups */
+	uint16_t	reserved_hw_ring_grps;
+	/* Actual number of KTLS Tx Key Contexts reserved */
+	uint32_t	reserved_ktls_tx_key_ctxs;
+	/* Actual number of KTLS Rx Key Contexts reserved */
+	uint32_t	reserved_ktls_rx_key_ctxs;
+	/* Actual number of QUIC Tx Key Contexts reserved */
+	uint32_t	reserved_quic_tx_key_ctxs;
+	/* Actual number of QUIC Rx Key Contexts reserved */
+	uint32_t	reserved_quic_rx_key_ctxs;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_vf_resource_cfg_output_t, *phwrm_func_vf_resource_cfg_output_t;
+
+/*********************************
+ * hwrm_func_backing_store_qcaps *
+ *********************************/
+
+
+/* hwrm_func_backing_store_qcaps_input (size:128b/16B) */
+
+typedef struct hwrm_func_backing_store_qcaps_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+} hwrm_func_backing_store_qcaps_input_t, *phwrm_func_backing_store_qcaps_input_t;
+
+/* hwrm_func_backing_store_qcaps_output (size:832b/104B) */
+
+typedef struct hwrm_func_backing_store_qcaps_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Maximum number of QP context entries supported for this function. */
+	uint32_t	qp_max_entries;
+	/*
+	 * Minimum number of QP context entries that are needed to be reserved
+	 * for QP1 for the PF and its VFs. PF drivers must allocate at least
+	 * this many QP context entries, even if RoCE will not be used.
+	 */
+	uint16_t	qp_min_qp1_entries;
+	/*
+	 * Maximum number of QP context entries that can be used for L2 and
+	 * mid-path.
+	 */
+	uint16_t	qp_max_l2_entries;
+	/* Number of bytes that must be allocated for each context entry. */
+	uint16_t	qp_entry_size;
+	/* Maximum number of SRQ context entries that can be used for L2. */
+	uint16_t	srq_max_l2_entries;
+	/* Maximum number of SRQ context entries supported for this function. */
+	uint32_t	srq_max_entries;
+	/* Number of bytes that must be allocated for each context entry. */
+	uint16_t	srq_entry_size;
+	/* Maximum number of CQ context entries that can be used for L2. */
+	uint16_t	cq_max_l2_entries;
+	/* Maximum number of CQ context entries supported for this function. */
+	uint32_t	cq_max_entries;
+	/* Number of bytes that must be allocated for each context entry. */
+	uint16_t	cq_entry_size;
+	/* Maximum number of VNIC context entries supported for this function. */
+	uint16_t	vnic_max_vnic_entries;
+	/*
+	 * Maximum number of Ring table context entries supported for this
+	 * function.
+	 */
+	uint16_t	vnic_max_ring_table_entries;
+	/* Number of bytes that must be allocated for each context entry. */
+	uint16_t	vnic_entry_size;
+	/*
+	 * Maximum number of statistic context entries supported for this
+	 * function.
+	 */
+	uint32_t	stat_max_entries;
+	/* Number of bytes that must be allocated for each context entry. */
+	uint16_t	stat_entry_size;
+	/* Number of bytes that must be allocated for each context entry. */
+	uint16_t	tqm_entry_size;
+	/* Minimum number of TQM context entries required per ring. */
+	uint32_t	tqm_min_entries_per_ring;
+	/*
+	 * Maximum number of TQM context entries supported per ring. This is
+	 * actually a recommended TQM queue size based on worst case usage of
+	 * the TQM queue.
+	 *
+	 * TQM fastpath rings should be sized large enough to accommodate the
+	 * maximum number of QPs (either L2 or RoCE, or both if shared)
+	 * that can be enqueued to the TQM ring.
+	 *
+	 * TQM slowpath rings should be sized as follows:
+	 *
+	 * num_entries = num_vnics + num_l2_tx_rings + 2 * num_roce_qps + tqm_min_size
+	 *
+	 * Where:
+	 *   num_vnics is the number of VNICs allocated in the VNIC backing
+	 *   store
+	 *   num_l2_tx_rings is the number of L2 rings in the QP backing store
+	 *   num_roce_qps is the number of RoCE QPs in the QP backing store
+	 *   tqm_min_size is tqm_min_entries_per_ring reported by
+	 *	HWRM_FUNC_BACKING_STORE_QCAPS
+	 *
+	 * Note that TQM ring sizes cannot be extended while the system is
+	 * operational. If a PF driver needs to extend a TQM ring, it needs
+	 * to reset the function (e.g. HWRM_FUNC_RESET) and then reallocate
+	 * the backing store.
+	 */
+	uint32_t	tqm_max_entries_per_ring;
+	/*
+	 * Maximum number of MR plus AV context entries supported for this
+	 * function.
+	 */
+	uint32_t	mrav_max_entries;
+	/* Number of bytes that must be allocated for each context entry. */
+	uint16_t	mrav_entry_size;
+	/* Number of bytes that must be allocated for each context entry. */
+	uint16_t	tim_entry_size;
+	/* Maximum number of Timer context entries supported for this function. */
+	uint32_t	tim_max_entries;
+	/*
+	 * When this field is zero, the 32b `mrav_num_entries` field in the
+	 * `backing_store_cfg` and `backing_store_qcfg` commands represents
+	 * the total number of MR plus AV entries allowed in the MR/AV backing
+	 * store PBL.
+	 *
+	 * When this field is non-zero, the 32b `mrav_num_entries` field in
+	 * the `backing_store_cfg` and `backing_store_qcfg` commands is
+	 * logically divided into two 16b fields. Bits `[31:16]` represents
+	 * the `mr_num_entries` and bits `[15:0]` represents `av_num_entries`.
+	 * Both of these values are represented in a unit granularity
+	 * specified by this field. For example, if this field is 16 and
+	 * `mrav_num_entries` is `0x02000100`, then the number of MR entries
+	 * is 8192 and the number of AV entries is 4096.
+	 */
+	uint16_t	mrav_num_entries_units;
+	/*
+	 * The number of entries specified for any TQM ring must be a
+	 * multiple of this value to prevent any resource allocation
+	 * limitations.
+	 */
+	uint8_t	tqm_entries_multiple;
+	/*
+	 * Initializer to be used by drivers
+	 * to initialize context memory to ensure
+	 * context subsystem flags an error for an attack
+	 * before the first time context load.
+	 */
+	uint8_t	ctx_kind_initializer;
+	/*
+	 * Specifies which context kinds need to be initialized with the
+	 * ctx_kind_initializer.
+	 */
+	uint16_t	ctx_init_mask;
+	/*
+	 * If this bit is '1' then this context type should be initialized
+	 * with the ctx_kind_initializer at the specified offset.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_OUTPUT_CTX_INIT_MASK_QP	UINT32_C(0x1)
+	/*
+	 * If this bit is '1' then this context type should be initialized
+	 * with the ctx_kind_initializer at the specified offset.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_OUTPUT_CTX_INIT_MASK_SRQ	UINT32_C(0x2)
+	/*
+	 * If this bit is '1' then this context type should be initialized
+	 * with the ctx_kind_initializer at the specified offset.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_OUTPUT_CTX_INIT_MASK_CQ	UINT32_C(0x4)
+	/*
+	 * If this bit is '1' then this context type should be initialized
+	 * with the ctx_kind_initializer at the specified offset.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_OUTPUT_CTX_INIT_MASK_VNIC	UINT32_C(0x8)
+	/*
+	 * If this bit is '1' then this context type should be initialized
+	 * with the ctx_kind_initializer at the specified offset.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_OUTPUT_CTX_INIT_MASK_STAT	UINT32_C(0x10)
+	/*
+	 * If this bit is '1' then this context type should be initialized
+	 * with the ctx_kind_initializer at the specified offset.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_OUTPUT_CTX_INIT_MASK_MRAV	UINT32_C(0x20)
+	/*
+	 * If this bit is '1' then the Tx KTLS context type should be
+	 * initialized with the ctx_kind_initializer at the specified offset.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_OUTPUT_CTX_INIT_MASK_TKC	UINT32_C(0x40)
+	/*
+	 * If this bit is '1' then the Rx KTLS context type should be
+	 * initialized with the ctx_kind_initializer at the specified offset.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_OUTPUT_CTX_INIT_MASK_RKC	UINT32_C(0x80)
+	/*
+	 * Specifies the doubleword offset of ctx_kind_initializer for this
+	 * context type.
+	 */
+	uint8_t	qp_init_offset;
+	/*
+	 * Specifies the doubleword offset of ctx_kind_initializer for this
+	 * context type.
+	 */
+	uint8_t	srq_init_offset;
+	/*
+	 * Specifies the doubleword offset of ctx_kind_initializer for this
+	 * context type.
+	 */
+	uint8_t	cq_init_offset;
+	/*
+	 * Specifies the doubleword offset of ctx_kind_initializer for this
+	 * context type.
+	 */
+	uint8_t	vnic_init_offset;
+	/*
+	 * Count of TQM fastpath rings to be used for allocating backing store.
+	 * Backing store configuration must be specified for each TQM ring from
+	 * this count in `backing_store_cfg`.
+	 * Only first 8 TQM FP rings will be advertised with this field.
+	 */
+	uint8_t	tqm_fp_rings_count;
+	/*
+	 * Specifies the doubleword offset of ctx_kind_initializer for this
+	 * context type.
+	 */
+	uint8_t	stat_init_offset;
+	/*
+	 * Specifies the doubleword offset of ctx_kind_initializer for this
+	 * context type.
+	 */
+	uint8_t	mrav_init_offset;
+	/*
+	 * Count of TQM extended fastpath rings to be used for allocating
+	 * backing store beyond 8 rings(rings 9,10,11)
+	 * Backing store configuration must be specified for each TQM ring from
+	 * this count in `backing_store_cfg`.
+	 */
+	uint8_t	tqm_fp_rings_count_ext;
+	/*
+	 * Specifies the doubleword offset of ctx_kind_initializer for Tx
+	 * KTLS context type.
+	 */
+	uint8_t	tkc_init_offset;
+	/*
+	 * Specifies the doubleword offset of ctx_kind_initializer for Rx
+	 * KTLS context type.
+	 */
+	uint8_t	rkc_init_offset;
+	/* Tx KTLS context entry size in bytes. */
+	uint16_t	tkc_entry_size;
+	/* Rx KTLS context entry size in bytes. */
+	uint16_t	rkc_entry_size;
+	/*
+	 * Maximum number of Tx KTLS context entries supported for this
+	 * function.
+	 */
+	uint32_t	tkc_max_entries;
+	/*
+	 * Maximum number of Rx KTLS context entries supported for this
+	 * function.
+	 */
+	uint32_t	rkc_max_entries;
+	/*
+	 * Additional number of RoCE QP context entries required for this
+	 * function to support fast QP destroy feature.
+	 */
+	uint16_t	fast_qpmd_qp_num_entries;
+	/* Reserved for future. */
+	uint8_t	rsvd1[5];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_backing_store_qcaps_output_t, *phwrm_func_backing_store_qcaps_output_t;
+
+/* tqm_fp_ring_cfg (size:128b/16B) */
+
+typedef struct tqm_fp_ring_cfg {
+	/* TQM ring page size and level. */
+	uint8_t	tqm_ring_pg_size_tqm_ring_lvl;
+	/* TQM ring PBL indirect levels. */
+	#define TQM_FP_RING_CFG_TQM_RING_CFG_TQM_RING_LVL_MASK	UINT32_C(0xf)
+	#define TQM_FP_RING_CFG_TQM_RING_CFG_TQM_RING_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define TQM_FP_RING_CFG_TQM_RING_CFG_TQM_RING_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define TQM_FP_RING_CFG_TQM_RING_CFG_TQM_RING_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to
+	 * PTE tables.
+	 */
+		#define TQM_FP_RING_CFG_TQM_RING_CFG_TQM_RING_LVL_LVL_2	UINT32_C(0x2)
+		#define TQM_FP_RING_CFG_TQM_RING_CFG_TQM_RING_LVL_LAST	TQM_FP_RING_CFG_TQM_RING_CFG_TQM_RING_LVL_LVL_2
+	/* TQM ring page size. */
+	#define TQM_FP_RING_CFG_TQM_RING_CFG_TQM_RING_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define TQM_FP_RING_CFG_TQM_RING_CFG_TQM_RING_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define TQM_FP_RING_CFG_TQM_RING_CFG_TQM_RING_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define TQM_FP_RING_CFG_TQM_RING_CFG_TQM_RING_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define TQM_FP_RING_CFG_TQM_RING_CFG_TQM_RING_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define TQM_FP_RING_CFG_TQM_RING_CFG_TQM_RING_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define TQM_FP_RING_CFG_TQM_RING_CFG_TQM_RING_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define TQM_FP_RING_CFG_TQM_RING_CFG_TQM_RING_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define TQM_FP_RING_CFG_TQM_RING_CFG_TQM_RING_PG_SIZE_LAST   TQM_FP_RING_CFG_TQM_RING_CFG_TQM_RING_PG_SIZE_PG_1G
+	uint8_t	unused[3];
+	/* Number of TQM ring entries. */
+	uint32_t	tqm_ring_num_entries;
+	/* TQM ring page directory. */
+	uint64_t	tqm_ring_page_dir;
+} tqm_fp_ring_cfg_t, *ptqm_fp_ring_cfg_t;
+
+/*******************************
+ * hwrm_func_backing_store_cfg *
+ *******************************/
+
+
+/* hwrm_func_backing_store_cfg_input (size:2688b/336B) */
+
+typedef struct hwrm_func_backing_store_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	flags;
+	/*
+	 * When set, the firmware only uses on-chip resources and does not
+	 * expect any backing store to be provided by the host driver. This
+	 * mode provides minimal L2 functionality (e.g. limited L2 resources,
+	 * no RoCE).
+	 */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_FLAGS_PREBOOT_MODE		UINT32_C(0x1)
+	/*
+	 * When set, the 32b `mrav_num_entries` field is logically divided
+	 * into two 16b fields, `mr_num_entries` and `av_num_entries`.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_FLAGS_MRAV_RESERVATION_SPLIT	UINT32_C(0x2)
+	uint32_t	enables;
+	/*
+	 * This bit must be '1' for the qp fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_QP		UINT32_C(0x1)
+	/*
+	 * This bit must be '1' for the srq fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_SRQ		UINT32_C(0x2)
+	/*
+	 * This bit must be '1' for the cq fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_CQ		UINT32_C(0x4)
+	/*
+	 * This bit must be '1' for the vnic fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_VNIC		UINT32_C(0x8)
+	/*
+	 * This bit must be '1' for the stat fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_STAT		UINT32_C(0x10)
+	/*
+	 * This bit must be '1' for the tqm_sp fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_SP	UINT32_C(0x20)
+	/*
+	 * This bit must be '1' for the tqm_ring0 fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_RING0	UINT32_C(0x40)
+	/*
+	 * This bit must be '1' for the tqm_ring1 fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_RING1	UINT32_C(0x80)
+	/*
+	 * This bit must be '1' for the tqm_ring2 fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_RING2	UINT32_C(0x100)
+	/*
+	 * This bit must be '1' for the tqm_ring3 fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_RING3	UINT32_C(0x200)
+	/*
+	 * This bit must be '1' for the tqm_ring4 fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_RING4	UINT32_C(0x400)
+	/*
+	 * This bit must be '1' for the tqm_ring5 fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_RING5	UINT32_C(0x800)
+	/*
+	 * This bit must be '1' for the tqm_ring6 fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_RING6	UINT32_C(0x1000)
+	/*
+	 * This bit must be '1' for the tqm_ring7 fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_RING7	UINT32_C(0x2000)
+	/*
+	 * This bit must be '1' for the mrav fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_MRAV		UINT32_C(0x4000)
+	/*
+	 * This bit must be '1' for the tim fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TIM		UINT32_C(0x8000)
+	/*
+	 * This bit must be '1' for the tqm_ring8 fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_RING8	UINT32_C(0x10000)
+	/*
+	 * This bit must be '1' for the tqm_ring9 fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_RING9	UINT32_C(0x20000)
+	/*
+	 * This bit must be '1' for the tqm_ring10 fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_RING10	UINT32_C(0x40000)
+	/*
+	 * This bit must be '1' for the Tx KTLS context
+	 * fields to be configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TKC		UINT32_C(0x80000)
+	/*
+	 * This bit must be '1' for the Rx KTLS context
+	 * fields to be configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_RKC		UINT32_C(0x100000)
+	/*
+	 * This bit must be '1' for the number of QPs reserved for fast
+	 * qp modify destroy feature to be configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_QP_FAST_QPMD	UINT32_C(0x200000)
+	/* QPC page size and level. */
+	uint8_t	qpc_pg_size_qpc_lvl;
+	/* QPC PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_LVL_LVL_2
+	/* QPC page size. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_QPC_PG_SIZE_PG_1G
+	/* SRQ page size and level. */
+	uint8_t	srq_pg_size_srq_lvl;
+	/* SRQ PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_SRQ_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_SRQ_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_SRQ_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_SRQ_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_SRQ_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_SRQ_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_SRQ_LVL_LVL_2
+	/* SRQ page size. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_SRQ_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_SRQ_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_SRQ_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_SRQ_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_SRQ_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_SRQ_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_SRQ_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_SRQ_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_SRQ_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_SRQ_PG_SIZE_PG_1G
+	/* CQ page size and level. */
+	uint8_t	cq_pg_size_cq_lvl;
+	/* CQ PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_CQ_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_CQ_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_CQ_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_CQ_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_CQ_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_CQ_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_CQ_LVL_LVL_2
+	/* CQ page size. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_CQ_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_CQ_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_CQ_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_CQ_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_CQ_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_CQ_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_CQ_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_CQ_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_CQ_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_CQ_PG_SIZE_PG_1G
+	/* VNIC page size and level. */
+	uint8_t	vnic_pg_size_vnic_lvl;
+	/* VNIC PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_VNIC_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_VNIC_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_VNIC_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_VNIC_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_VNIC_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_VNIC_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_VNIC_LVL_LVL_2
+	/* VNIC page size. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_VNIC_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_VNIC_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_VNIC_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_VNIC_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_VNIC_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_VNIC_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_VNIC_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_VNIC_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_VNIC_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_VNIC_PG_SIZE_PG_1G
+	/* Stat page size and level. */
+	uint8_t	stat_pg_size_stat_lvl;
+	/* Stat PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_STAT_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_STAT_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_STAT_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_STAT_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_STAT_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_STAT_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_STAT_LVL_LVL_2
+	/* Stat page size. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_STAT_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_STAT_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_STAT_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_STAT_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_STAT_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_STAT_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_STAT_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_STAT_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_STAT_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_STAT_PG_SIZE_PG_1G
+	/* TQM slow path page size and level. */
+	uint8_t	tqm_sp_pg_size_tqm_sp_lvl;
+	/* TQM slow path PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_SP_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_SP_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_SP_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_SP_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_SP_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_SP_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_SP_LVL_LVL_2
+	/* TQM slow path page size. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_SP_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_SP_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_SP_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_SP_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_SP_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_SP_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_SP_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_SP_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_SP_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_SP_PG_SIZE_PG_1G
+	/* TQM ring 0 page size and level. */
+	uint8_t	tqm_ring0_pg_size_tqm_ring0_lvl;
+	/* TQM ring 0 PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING0_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING0_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING0_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING0_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING0_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING0_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING0_LVL_LVL_2
+	/* TQM ring 0 page size. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING0_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING0_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING0_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING0_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING0_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING0_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING0_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING0_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING0_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING0_PG_SIZE_PG_1G
+	/* TQM ring 1 page size and level. */
+	uint8_t	tqm_ring1_pg_size_tqm_ring1_lvl;
+	/* TQM ring 1 PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING1_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING1_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING1_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING1_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING1_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING1_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING1_LVL_LVL_2
+	/* TQM ring 1 page size. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING1_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING1_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING1_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING1_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING1_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING1_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING1_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING1_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING1_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING1_PG_SIZE_PG_1G
+	/* TQM ring 2 page size and level. */
+	uint8_t	tqm_ring2_pg_size_tqm_ring2_lvl;
+	/* TQM ring 2 PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING2_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING2_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING2_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING2_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING2_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING2_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING2_LVL_LVL_2
+	/* TQM ring 2 page size. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING2_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING2_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING2_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING2_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING2_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING2_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING2_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING2_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING2_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING2_PG_SIZE_PG_1G
+	/* TQM ring 3 page size and level. */
+	uint8_t	tqm_ring3_pg_size_tqm_ring3_lvl;
+	/* TQM ring 3 PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING3_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING3_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING3_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING3_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING3_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING3_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING3_LVL_LVL_2
+	/* TQM ring 3 page size. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING3_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING3_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING3_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING3_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING3_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING3_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING3_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING3_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING3_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING3_PG_SIZE_PG_1G
+	/* TQM ring 4 page size and level. */
+	uint8_t	tqm_ring4_pg_size_tqm_ring4_lvl;
+	/* TQM ring 4 PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING4_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING4_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING4_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING4_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING4_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING4_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING4_LVL_LVL_2
+	/* TQM ring 4 page size. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING4_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING4_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING4_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING4_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING4_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING4_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING4_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING4_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING4_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING4_PG_SIZE_PG_1G
+	/* TQM ring 5 page size and level. */
+	uint8_t	tqm_ring5_pg_size_tqm_ring5_lvl;
+	/* TQM ring 5 PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING5_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING5_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING5_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING5_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING5_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING5_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING5_LVL_LVL_2
+	/* TQM ring 5 page size. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING5_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING5_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING5_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING5_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING5_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING5_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING5_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING5_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING5_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING5_PG_SIZE_PG_1G
+	/* TQM ring 6 page size and level. */
+	uint8_t	tqm_ring6_pg_size_tqm_ring6_lvl;
+	/* TQM ring 6 PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING6_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING6_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING6_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING6_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING6_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING6_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING6_LVL_LVL_2
+	/* TQM ring 6 page size. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING6_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING6_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING6_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING6_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING6_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING6_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING6_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING6_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING6_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING6_PG_SIZE_PG_1G
+	/* TQM ring 7 page size and level. */
+	uint8_t	tqm_ring7_pg_size_tqm_ring7_lvl;
+	/* TQM ring 7 PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING7_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING7_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING7_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING7_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING7_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING7_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING7_LVL_LVL_2
+	/* TQM ring 7 page size. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING7_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING7_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING7_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING7_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING7_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING7_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING7_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING7_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING7_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_TQM_RING7_PG_SIZE_PG_1G
+	/* MR/AV page size and level. */
+	uint8_t	mrav_pg_size_mrav_lvl;
+	/* MR/AV PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_MRAV_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_MRAV_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_MRAV_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_MRAV_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_MRAV_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_MRAV_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_MRAV_LVL_LVL_2
+	/* MR/AV page size. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_MRAV_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_MRAV_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_MRAV_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_MRAV_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_MRAV_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_MRAV_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_MRAV_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_MRAV_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_MRAV_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_MRAV_PG_SIZE_PG_1G
+	/* Timer page size and level. */
+	uint8_t	tim_pg_size_tim_lvl;
+	/* Timer PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TIM_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TIM_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TIM_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TIM_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TIM_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TIM_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_TIM_LVL_LVL_2
+	/* Timer page size. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TIM_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TIM_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TIM_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TIM_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TIM_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TIM_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TIM_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TIM_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TIM_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_TIM_PG_SIZE_PG_1G
+	/* QP page directory. */
+	uint64_t	qpc_page_dir;
+	/* SRQ page directory. */
+	uint64_t	srq_page_dir;
+	/* CQ page directory. */
+	uint64_t	cq_page_dir;
+	/* VNIC page directory. */
+	uint64_t	vnic_page_dir;
+	/* Stat page directory. */
+	uint64_t	stat_page_dir;
+	/* TQM slowpath page directory. */
+	uint64_t	tqm_sp_page_dir;
+	/* TQM ring 0 page directory. */
+	uint64_t	tqm_ring0_page_dir;
+	/* TQM ring 1 page directory. */
+	uint64_t	tqm_ring1_page_dir;
+	/* TQM ring 2 page directory. */
+	uint64_t	tqm_ring2_page_dir;
+	/* TQM ring 3 page directory. */
+	uint64_t	tqm_ring3_page_dir;
+	/* TQM ring 4 page directory. */
+	uint64_t	tqm_ring4_page_dir;
+	/* TQM ring 5 page directory. */
+	uint64_t	tqm_ring5_page_dir;
+	/* TQM ring 6 page directory. */
+	uint64_t	tqm_ring6_page_dir;
+	/* TQM ring 7 page directory. */
+	uint64_t	tqm_ring7_page_dir;
+	/* MR/AV page directory. */
+	uint64_t	mrav_page_dir;
+	/* Timer page directory. */
+	uint64_t	tim_page_dir;
+	/* Number of QPs. */
+	uint32_t	qp_num_entries;
+	/* Number of SRQs. */
+	uint32_t	srq_num_entries;
+	/* Number of CQs. */
+	uint32_t	cq_num_entries;
+	/* Number of Stats. */
+	uint32_t	stat_num_entries;
+	/*
+	 * Number of TQM slowpath entries.
+	 *
+	 * TQM slowpath rings should be sized as follows:
+	 *
+	 * num_entries = num_vnics + num_l2_tx_rings + 2 * num_roce_qps + tqm_min_size
+	 *
+	 * Where:
+	 *   num_vnics is the number of VNICs allocated in the VNIC backing
+	 *   store num_l2_tx_rings is the number of L2 rings in the QP backing
+	 *   store num_roce_qps is the number of RoCE QPs in the QP backing
+	 *   store tqm_min_size is tqm_min_entries_per_ring reported by
+	 *   HWRM_FUNC_BACKING_STORE_QCAPS
+	 *
+	 * Note that TQM ring sizes cannot be extended while the system is
+	 * operational. If a PF driver needs to extend a TQM ring, it needs
+	 * to reset the function (e.g. HWRM_FUNC_RESET) and then reallocate
+	 * the backing store.
+	 */
+	uint32_t	tqm_sp_num_entries;
+	/*
+	 * Number of TQM ring 0 entries.
+	 *
+	 * TQM fastpath rings should be sized large enough to accommodate the
+	 * maximum number of QPs (either L2 or RoCE, or both if shared)
+	 * that can be enqueued to the TQM ring.
+	 *
+	 * Note that TQM ring sizes cannot be extended while the system is
+	 * operational. If a PF driver needs to extend a TQM ring, it needs
+	 * to reset the function (e.g. HWRM_FUNC_RESET) and then reallocate
+	 * the backing store.
+	 */
+	uint32_t	tqm_ring0_num_entries;
+	/*
+	 * Number of TQM ring 1 entries.
+	 *
+	 * TQM fastpath rings should be sized large enough to accommodate the
+	 * maximum number of QPs (either L2 or RoCE, or both if shared)
+	 * that can be enqueued to the TQM ring.
+	 *
+	 * Note that TQM ring sizes cannot be extended while the system is
+	 * operational. If a PF driver needs to extend a TQM ring, it needs
+	 * to reset the function (e.g. HWRM_FUNC_RESET) and then reallocate
+	 * the backing store.
+	 */
+	uint32_t	tqm_ring1_num_entries;
+	/*
+	 * Number of TQM ring 2 entries.
+	 *
+	 * TQM fastpath rings should be sized large enough to accommodate the
+	 * maximum number of QPs (either L2 or RoCE, or both if shared)
+	 * that can be enqueued to the TQM ring.
+	 *
+	 * Note that TQM ring sizes cannot be extended while the system is
+	 * operational. If a PF driver needs to extend a TQM ring, it needs
+	 * to reset the function (e.g. HWRM_FUNC_RESET) and then reallocate
+	 * the backing store.
+	 */
+	uint32_t	tqm_ring2_num_entries;
+	/*
+	 * Number of TQM ring 3 entries.
+	 *
+	 * TQM fastpath rings should be sized large enough to accommodate the
+	 * maximum number of QPs (either L2 or RoCE, or both if shared)
+	 * that can be enqueued to the TQM ring.
+	 *
+	 * Note that TQM ring sizes cannot be extended while the system is
+	 * operational. If a PF driver needs to extend a TQM ring, it needs
+	 * to reset the function (e.g. HWRM_FUNC_RESET) and then reallocate
+	 * the backing store.
+	 */
+	uint32_t	tqm_ring3_num_entries;
+	/*
+	 * Number of TQM ring 4 entries.
+	 *
+	 * TQM fastpath rings should be sized large enough to accommodate the
+	 * maximum number of QPs (either L2 or RoCE, or both if shared)
+	 * that can be enqueued to the TQM ring.
+	 *
+	 * Note that TQM ring sizes cannot be extended while the system is
+	 * operational. If a PF driver needs to extend a TQM ring, it needs
+	 * to reset the function (e.g. HWRM_FUNC_RESET) and then reallocate
+	 * the backing store.
+	 */
+	uint32_t	tqm_ring4_num_entries;
+	/*
+	 * Number of TQM ring 5 entries.
+	 *
+	 * TQM fastpath rings should be sized large enough to accommodate the
+	 * maximum number of QPs (either L2 or RoCE, or both if shared)
+	 * that can be enqueued to the TQM ring.
+	 *
+	 * Note that TQM ring sizes cannot be extended while the system is
+	 * operational. If a PF driver needs to extend a TQM ring, it needs
+	 * to reset the function (e.g. HWRM_FUNC_RESET) and then reallocate
+	 * the backing store.
+	 */
+	uint32_t	tqm_ring5_num_entries;
+	/*
+	 * Number of TQM ring 6 entries.
+	 *
+	 * TQM fastpath rings should be sized large enough to accommodate the
+	 * maximum number of QPs (either L2 or RoCE, or both if shared)
+	 * that can be enqueued to the TQM ring.
+	 *
+	 * Note that TQM ring sizes cannot be extended while the system is
+	 * operational. If a PF driver needs to extend a TQM ring, it needs
+	 * to reset the function (e.g. HWRM_FUNC_RESET) and then reallocate
+	 * the backing store.
+	 */
+	uint32_t	tqm_ring6_num_entries;
+	/*
+	 * Number of TQM ring 7 entries.
+	 *
+	 * TQM fastpath rings should be sized large enough to accommodate the
+	 * maximum number of QPs (either L2 or RoCE, or both if shared)
+	 * that can be enqueued to the TQM ring.
+	 *
+	 * Note that TQM ring sizes cannot be extended while the system is
+	 * operational. If a PF driver needs to extend a TQM ring, it needs
+	 * to reset the function (e.g. HWRM_FUNC_RESET) and then reallocate
+	 * the backing store.
+	 */
+	uint32_t	tqm_ring7_num_entries;
+	/*
+	 * If the MR/AV split reservation flag is not set, then this field
+	 * represents the total number of MR plus AV entries. For versions
+	 * of firmware that support the split reservation, when it is not
+	 * specified half of the entries will be reserved for MRs and the
+	 * other half for AVs.
+	 *
+	 * If the MR/AV split reservation flag is set, then this
+	 * field is logically divided into two 16b fields. Bits `[31:16]`
+	 * represents the `mr_num_entries` and bits `[15:0]` represents
+	 * `av_num_entries`. The granularity of these values is defined by
+	 * the `mrav_num_entries_unit` field returned by the
+	 * `backing_store_qcaps` command.
+	 */
+	uint32_t	mrav_num_entries;
+	/* Number of Timer entries. */
+	uint32_t	tim_num_entries;
+	/* Number of entries to reserve for QP1 */
+	uint16_t	qp_num_qp1_entries;
+	/* Number of entries to reserve for L2 */
+	uint16_t	qp_num_l2_entries;
+	/* Number of bytes that have been allocated for each context entry. */
+	uint16_t	qp_entry_size;
+	/* Number of entries to reserve for L2 */
+	uint16_t	srq_num_l2_entries;
+	/* Number of bytes that have been allocated for each context entry. */
+	uint16_t	srq_entry_size;
+	/* Number of entries to reserve for L2 */
+	uint16_t	cq_num_l2_entries;
+	/* Number of bytes that have been allocated for each context entry. */
+	uint16_t	cq_entry_size;
+	/* Number of entries to reserve for VNIC entries */
+	uint16_t	vnic_num_vnic_entries;
+	/* Number of entries to reserve for Ring table entries */
+	uint16_t	vnic_num_ring_table_entries;
+	/* Number of bytes that have been allocated for each context entry. */
+	uint16_t	vnic_entry_size;
+	/* Number of bytes that have been allocated for each context entry. */
+	uint16_t	stat_entry_size;
+	/* Number of bytes that have been allocated for each context entry. */
+	uint16_t	tqm_entry_size;
+	/* Number of bytes that have been allocated for each context entry. */
+	uint16_t	mrav_entry_size;
+	/* Number of bytes that have been allocated for each context entry. */
+	uint16_t	tim_entry_size;
+	/* TQM ring page size and level. */
+	uint8_t	tqm_ring8_pg_size_tqm_ring_lvl;
+	/* TQM ring PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING8_TQM_RING_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING8_TQM_RING_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING8_TQM_RING_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING8_TQM_RING_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to
+	 * PTE tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING8_TQM_RING_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING8_TQM_RING_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING8_TQM_RING_LVL_LVL_2
+	/* TQM ring page size. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING8_TQM_RING_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING8_TQM_RING_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING8_TQM_RING_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING8_TQM_RING_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING8_TQM_RING_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING8_TQM_RING_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING8_TQM_RING_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING8_TQM_RING_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING8_TQM_RING_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING8_TQM_RING_PG_SIZE_PG_1G
+	uint8_t	ring8_unused[3];
+	/* Number of TQM ring entries. */
+	uint32_t	tqm_ring8_num_entries;
+	/* TQM ring page directory. */
+	uint64_t	tqm_ring8_page_dir;
+	/* TQM ring page size and level. */
+	uint8_t	tqm_ring9_pg_size_tqm_ring_lvl;
+	/* TQM ring PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING9_TQM_RING_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING9_TQM_RING_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING9_TQM_RING_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING9_TQM_RING_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to
+	 * PTE tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING9_TQM_RING_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING9_TQM_RING_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING9_TQM_RING_LVL_LVL_2
+	/* TQM ring page size. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING9_TQM_RING_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING9_TQM_RING_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING9_TQM_RING_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING9_TQM_RING_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING9_TQM_RING_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING9_TQM_RING_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING9_TQM_RING_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING9_TQM_RING_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING9_TQM_RING_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING9_TQM_RING_PG_SIZE_PG_1G
+	uint8_t	ring9_unused[3];
+	/* Number of TQM ring entries. */
+	uint32_t	tqm_ring9_num_entries;
+	/* TQM ring page directory. */
+	uint64_t	tqm_ring9_page_dir;
+	/* TQM ring page size and level. */
+	uint8_t	tqm_ring10_pg_size_tqm_ring_lvl;
+	/* TQM ring PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING10_TQM_RING_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING10_TQM_RING_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING10_TQM_RING_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING10_TQM_RING_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to
+	 * PTE tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING10_TQM_RING_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING10_TQM_RING_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING10_TQM_RING_LVL_LVL_2
+	/* TQM ring page size. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING10_TQM_RING_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING10_TQM_RING_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING10_TQM_RING_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING10_TQM_RING_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING10_TQM_RING_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING10_TQM_RING_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING10_TQM_RING_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING10_TQM_RING_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING10_TQM_RING_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_RING10_TQM_RING_PG_SIZE_PG_1G
+	uint8_t	ring10_unused[3];
+	/* Number of TQM ring entries. */
+	uint32_t	tqm_ring10_num_entries;
+	/* TQM ring page directory. */
+	uint64_t	tqm_ring10_page_dir;
+	/* Number of Tx KTLS context entries allocated. */
+	uint32_t	tkc_num_entries;
+	/* Number of Rx KTLS context entries allocated. */
+	uint32_t	rkc_num_entries;
+	/* Tx KTLS context page directory. */
+	uint64_t	tkc_page_dir;
+	/* Rx KTLS context page directory. */
+	uint64_t	rkc_page_dir;
+	/* Number of bytes allocated for each Tx KTLS context entry. */
+	uint16_t	tkc_entry_size;
+	/* Number of bytes allocated for each Rx KTLS context entry. */
+	uint16_t	rkc_entry_size;
+	/* Tx KTLS context page size and level. */
+	uint8_t	tkc_pg_size_tkc_lvl;
+	/* Tx KTLS context PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TKC_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TKC_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TKC_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TKC_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TKC_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TKC_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_TKC_LVL_LVL_2
+	/* Tx KTLS context page size. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TKC_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TKC_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TKC_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TKC_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TKC_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TKC_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TKC_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TKC_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_TKC_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_TKC_PG_SIZE_PG_1G
+	/* Rx KTLS context page size and level. */
+	uint8_t	rkc_pg_size_rkc_lvl;
+	/* Rx KTLS context PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RKC_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RKC_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RKC_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RKC_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to
+	 * PTE tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RKC_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RKC_LVL_LAST	HWRM_FUNC_BACKING_STORE_CFG_INPUT_RKC_LVL_LVL_2
+	/* Rx KTLS context page size. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RKC_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RKC_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RKC_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RKC_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RKC_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RKC_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RKC_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RKC_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_RKC_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_INPUT_RKC_PG_SIZE_PG_1G
+	/*
+	 * Number of RoCE QP context entries reserved for this
+	 * function to support fast QP modify destroy feature.
+	 */
+	uint16_t	qp_num_fast_qpmd_entries;
+} hwrm_func_backing_store_cfg_input_t, *phwrm_func_backing_store_cfg_input_t;
+
+/* hwrm_func_backing_store_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_func_backing_store_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_backing_store_cfg_output_t, *phwrm_func_backing_store_cfg_output_t;
+
+/********************************
+ * hwrm_func_backing_store_qcfg *
+ ********************************/
+
+
+/* hwrm_func_backing_store_qcfg_input (size:128b/16B) */
+
+typedef struct hwrm_func_backing_store_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+} hwrm_func_backing_store_qcfg_input_t, *phwrm_func_backing_store_qcfg_input_t;
+
+/* hwrm_func_backing_store_qcfg_output (size:2496b/312B) */
+
+typedef struct hwrm_func_backing_store_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint32_t	flags;
+	/*
+	 * When set, the firmware only uses on-chip resources and does not
+	 * expect any backing store to be provided by the host driver. This
+	 * mode provides minimal L2 functionality (e.g. limited L2 resources,
+	 * no RoCE).
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_FLAGS_PREBOOT_MODE		UINT32_C(0x1)
+	/*
+	 * When set, the 32b `mrav_num_entries` field is logically divided
+	 * into two 16b fields, `mr_num_entries` and `av_num_entries`.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_FLAGS_MRAV_RESERVATION_SPLIT	UINT32_C(0x2)
+	uint32_t	enables;
+	/*
+	 * This bit must be '1' for the qp fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_QP		UINT32_C(0x1)
+	/*
+	 * This bit must be '1' for the srq fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_SRQ		UINT32_C(0x2)
+	/*
+	 * This bit must be '1' for the cq fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_CQ		UINT32_C(0x4)
+	/*
+	 * This bit must be '1' for the vnic fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_VNIC		UINT32_C(0x8)
+	/*
+	 * This bit must be '1' for the stat fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_STAT		UINT32_C(0x10)
+	/*
+	 * This bit must be '1' for the tqm_sp fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_TQM_SP	UINT32_C(0x20)
+	/*
+	 * This bit must be '1' for the tqm_ring0 fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_TQM_RING0	UINT32_C(0x40)
+	/*
+	 * This bit must be '1' for the tqm_ring1 fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_TQM_RING1	UINT32_C(0x80)
+	/*
+	 * This bit must be '1' for the tqm_ring2 fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_TQM_RING2	UINT32_C(0x100)
+	/*
+	 * This bit must be '1' for the tqm_ring3 fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_TQM_RING3	UINT32_C(0x200)
+	/*
+	 * This bit must be '1' for the tqm_ring4 fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_TQM_RING4	UINT32_C(0x400)
+	/*
+	 * This bit must be '1' for the tqm_ring5 fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_TQM_RING5	UINT32_C(0x800)
+	/*
+	 * This bit must be '1' for the tqm_ring6 fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_TQM_RING6	UINT32_C(0x1000)
+	/*
+	 * This bit must be '1' for the tqm_ring7 fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_TQM_RING7	UINT32_C(0x2000)
+	/*
+	 * This bit must be '1' for the mrav fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_MRAV		UINT32_C(0x4000)
+	/*
+	 * This bit must be '1' for the tim fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_TIM		UINT32_C(0x8000)
+	/*
+	 * This bit must be '1' for the tqm_ring8 fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_TQM_RING8	UINT32_C(0x10000)
+	/*
+	 * This bit must be '1' for the tqm_ring9 fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_TQM_RING9	UINT32_C(0x20000)
+	/*
+	 * This bit must be '1' for the tqm_ring10 fields to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_TQM_RING10	UINT32_C(0x40000)
+	/*
+	 * This bit must be '1' for the Tx KTLS context
+	 * fields to be configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_TKC		UINT32_C(0x80000)
+	/*
+	 * This bit must be '1' for the Rx KTLS context
+	 * fields to be configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_RKC		UINT32_C(0x100000)
+	/*
+	 * This bit must be '1' for the number of QPs reserved for fast
+	 * qp modify destroy feature to be configured.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_ENABLES_QP_FAST_QPMD	UINT32_C(0x200000)
+	/* QPC page size and level. */
+	uint8_t	qpc_pg_size_qpc_lvl;
+	/* QPC PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_QPC_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_QPC_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_QPC_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_QPC_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_QPC_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_QPC_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_QPC_LVL_LVL_2
+	/* QPC page size. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_QPC_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_QPC_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_QPC_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_QPC_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_QPC_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_QPC_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_QPC_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_QPC_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_QPC_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_QPC_PG_SIZE_PG_1G
+	/* SRQ page size and level. */
+	uint8_t	srq_pg_size_srq_lvl;
+	/* SRQ PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_SRQ_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_SRQ_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_SRQ_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_SRQ_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_SRQ_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_SRQ_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_SRQ_LVL_LVL_2
+	/* SRQ page size. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_SRQ_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_SRQ_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_SRQ_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_SRQ_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_SRQ_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_SRQ_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_SRQ_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_SRQ_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_SRQ_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_SRQ_PG_SIZE_PG_1G
+	/* CQ page size and level. */
+	uint8_t	cq_pg_size_cq_lvl;
+	/* CQ PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_CQ_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_CQ_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_CQ_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_CQ_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_CQ_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_CQ_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_CQ_LVL_LVL_2
+	/* CQ page size. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_CQ_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_CQ_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_CQ_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_CQ_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_CQ_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_CQ_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_CQ_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_CQ_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_CQ_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_CQ_PG_SIZE_PG_1G
+	/* VNIC page size and level. */
+	uint8_t	vnic_pg_size_vnic_lvl;
+	/* VNIC PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_VNIC_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_VNIC_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_VNIC_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_VNIC_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_VNIC_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_VNIC_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_VNIC_LVL_LVL_2
+	/* VNIC page size. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_VNIC_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_VNIC_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_VNIC_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_VNIC_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_VNIC_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_VNIC_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_VNIC_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_VNIC_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_VNIC_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_VNIC_PG_SIZE_PG_1G
+	/* Stat page size and level. */
+	uint8_t	stat_pg_size_stat_lvl;
+	/* Stat PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_STAT_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_STAT_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_STAT_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_STAT_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_STAT_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_STAT_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_STAT_LVL_LVL_2
+	/* Stat page size. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_STAT_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_STAT_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_STAT_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_STAT_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_STAT_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_STAT_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_STAT_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_STAT_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_STAT_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_STAT_PG_SIZE_PG_1G
+	/* TQM slow path page size and level. */
+	uint8_t	tqm_sp_pg_size_tqm_sp_lvl;
+	/* TQM slow path PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_SP_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_SP_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_SP_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_SP_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_SP_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_SP_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_SP_LVL_LVL_2
+	/* TQM slow path page size. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_SP_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_SP_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_SP_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_SP_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_SP_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_SP_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_SP_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_SP_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_SP_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_SP_PG_SIZE_PG_1G
+	/* TQM ring 0 page size and level. */
+	uint8_t	tqm_ring0_pg_size_tqm_ring0_lvl;
+	/* TQM ring 0 PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING0_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING0_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING0_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING0_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING0_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING0_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING0_LVL_LVL_2
+	/* TQM ring 0 page size. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING0_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING0_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING0_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING0_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING0_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING0_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING0_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING0_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING0_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING0_PG_SIZE_PG_1G
+	/* TQM ring 1 page size and level. */
+	uint8_t	tqm_ring1_pg_size_tqm_ring1_lvl;
+	/* TQM ring 1 PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING1_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING1_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING1_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING1_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING1_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING1_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING1_LVL_LVL_2
+	/* TQM ring 1 page size. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING1_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING1_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING1_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING1_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING1_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING1_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING1_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING1_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING1_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING1_PG_SIZE_PG_1G
+	/* TQM ring 2 page size and level. */
+	uint8_t	tqm_ring2_pg_size_tqm_ring2_lvl;
+	/* TQM ring 2 PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING2_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING2_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING2_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING2_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING2_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING2_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING2_LVL_LVL_2
+	/* TQM ring 2 page size. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING2_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING2_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING2_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING2_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING2_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING2_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING2_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING2_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING2_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING2_PG_SIZE_PG_1G
+	/* TQM ring 3 page size and level. */
+	uint8_t	tqm_ring3_pg_size_tqm_ring3_lvl;
+	/* TQM ring 3 PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING3_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING3_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING3_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING3_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING3_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING3_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING3_LVL_LVL_2
+	/* TQM ring 3 page size. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING3_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING3_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING3_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING3_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING3_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING3_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING3_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING3_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING3_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING3_PG_SIZE_PG_1G
+	/* TQM ring 4 page size and level. */
+	uint8_t	tqm_ring4_pg_size_tqm_ring4_lvl;
+	/* TQM ring 4 PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING4_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING4_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING4_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING4_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING4_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING4_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING4_LVL_LVL_2
+	/* TQM ring 4 page size. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING4_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING4_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING4_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING4_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING4_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING4_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING4_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING4_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING4_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING4_PG_SIZE_PG_1G
+	/* TQM ring 5 page size and level. */
+	uint8_t	tqm_ring5_pg_size_tqm_ring5_lvl;
+	/* TQM ring 5 PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING5_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING5_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING5_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING5_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING5_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING5_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING5_LVL_LVL_2
+	/* TQM ring 5 page size. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING5_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING5_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING5_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING5_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING5_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING5_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING5_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING5_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING5_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING5_PG_SIZE_PG_1G
+	/* TQM ring 6 page size and level. */
+	uint8_t	tqm_ring6_pg_size_tqm_ring6_lvl;
+	/* TQM ring 6 PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING6_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING6_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING6_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING6_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING6_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING6_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING6_LVL_LVL_2
+	/* TQM ring 6 page size. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING6_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING6_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING6_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING6_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING6_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING6_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING6_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING6_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING6_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING6_PG_SIZE_PG_1G
+	/* TQM ring 7 page size and level. */
+	uint8_t	tqm_ring7_pg_size_tqm_ring7_lvl;
+	/* TQM ring 7 PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING7_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING7_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING7_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING7_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING7_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING7_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING7_LVL_LVL_2
+	/* TQM ring 7 page size. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING7_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING7_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING7_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING7_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING7_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING7_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING7_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING7_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING7_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING7_PG_SIZE_PG_1G
+	/* MR/AV page size and level. */
+	uint8_t	mrav_pg_size_mrav_lvl;
+	/* MR/AV PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_MRAV_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_MRAV_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_MRAV_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_MRAV_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_MRAV_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_MRAV_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_MRAV_LVL_LVL_2
+	/* MR/AV page size. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_MRAV_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_MRAV_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_MRAV_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_MRAV_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_MRAV_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_MRAV_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_MRAV_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_MRAV_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_MRAV_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_MRAV_PG_SIZE_PG_1G
+	/* Timer page size and level. */
+	uint8_t	tim_pg_size_tim_lvl;
+	/* Timer PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TIM_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TIM_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TIM_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TIM_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TIM_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TIM_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TIM_LVL_LVL_2
+	/* Timer page size. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TIM_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TIM_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TIM_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TIM_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TIM_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TIM_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TIM_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TIM_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TIM_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TIM_PG_SIZE_PG_1G
+	/* QP page directory. */
+	uint64_t	qpc_page_dir;
+	/* SRQ page directory. */
+	uint64_t	srq_page_dir;
+	/* CQ page directory. */
+	uint64_t	cq_page_dir;
+	/* VNIC page directory. */
+	uint64_t	vnic_page_dir;
+	/* Stat page directory. */
+	uint64_t	stat_page_dir;
+	/* TQM slowpath page directory. */
+	uint64_t	tqm_sp_page_dir;
+	/* TQM ring 0 page directory. */
+	uint64_t	tqm_ring0_page_dir;
+	/* TQM ring 1 page directory. */
+	uint64_t	tqm_ring1_page_dir;
+	/* TQM ring 2 page directory. */
+	uint64_t	tqm_ring2_page_dir;
+	/* TQM ring 3 page directory. */
+	uint64_t	tqm_ring3_page_dir;
+	/* TQM ring 4 page directory. */
+	uint64_t	tqm_ring4_page_dir;
+	/* TQM ring 5 page directory. */
+	uint64_t	tqm_ring5_page_dir;
+	/* TQM ring 6 page directory. */
+	uint64_t	tqm_ring6_page_dir;
+	/* TQM ring 7 page directory. */
+	uint64_t	tqm_ring7_page_dir;
+	/* MR/AV page directory. */
+	uint64_t	mrav_page_dir;
+	/* Timer page directory. */
+	uint64_t	tim_page_dir;
+	/* Number of entries to reserve for QP1 */
+	uint16_t	qp_num_qp1_entries;
+	/* Number of entries to reserve for L2 */
+	uint16_t	qp_num_l2_entries;
+	/* Number of QPs. */
+	uint32_t	qp_num_entries;
+	/* Number of SRQs. */
+	uint32_t	srq_num_entries;
+	/* Number of entries to reserve for L2 */
+	uint16_t	srq_num_l2_entries;
+	/* Number of entries to reserve for L2 */
+	uint16_t	cq_num_l2_entries;
+	/* Number of CQs. */
+	uint32_t	cq_num_entries;
+	/* Number of entries to reserve for VNIC entries */
+	uint16_t	vnic_num_vnic_entries;
+	/* Number of entries to reserve for Ring table entries */
+	uint16_t	vnic_num_ring_table_entries;
+	/* Number of Stats. */
+	uint32_t	stat_num_entries;
+	/* Number of TQM slowpath entries. */
+	uint32_t	tqm_sp_num_entries;
+	/* Number of TQM ring 0 entries. */
+	uint32_t	tqm_ring0_num_entries;
+	/* Number of TQM ring 1 entries. */
+	uint32_t	tqm_ring1_num_entries;
+	/* Number of TQM ring 2 entries. */
+	uint32_t	tqm_ring2_num_entries;
+	/* Number of TQM ring 3 entries. */
+	uint32_t	tqm_ring3_num_entries;
+	/* Number of TQM ring 4 entries. */
+	uint32_t	tqm_ring4_num_entries;
+	/* Number of TQM ring 5 entries. */
+	uint32_t	tqm_ring5_num_entries;
+	/* Number of TQM ring 6 entries. */
+	uint32_t	tqm_ring6_num_entries;
+	/* Number of TQM ring 7 entries. */
+	uint32_t	tqm_ring7_num_entries;
+	/*
+	 * If the MR/AV split reservation flag is not set, then this field
+	 * represents the total number of MR plus AV entries. For versions
+	 * of firmware that support the split reservation, when it is not
+	 * specified half of the entries will be reserved for MRs and the
+	 * other half for AVs.
+	 *
+	 * If the MR/AV split reservation flag is set, then this
+	 * field is logically divided into two 16b fields. Bits `[31:16]`
+	 * represents the `mr_num_entries` and bits `[15:0]` represents
+	 * `av_num_entries`. The granularity of these values is defined by
+	 * the `mrav_num_entries_unit` field returned by the
+	 * `backing_store_qcaps` command.
+	 */
+	uint32_t	mrav_num_entries;
+	/* Number of Timer entries. */
+	uint32_t	tim_num_entries;
+	/* TQM ring page size and level. */
+	uint8_t	tqm_ring8_pg_size_tqm_ring_lvl;
+	/* TQM ring PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING8_TQM_RING_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING8_TQM_RING_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING8_TQM_RING_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING8_TQM_RING_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to
+	 * PTE tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING8_TQM_RING_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING8_TQM_RING_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING8_TQM_RING_LVL_LVL_2
+	/* TQM ring page size. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING8_TQM_RING_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING8_TQM_RING_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING8_TQM_RING_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING8_TQM_RING_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
 	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_CQ_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING8_TQM_RING_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
 	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_CQ_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING8_TQM_RING_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
 	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_CQ_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING8_TQM_RING_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
 	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_CQ_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_CQ_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_CQ_PG_SIZE_PG_1G
-	/* VNIC page size and level. */
-	uint8_t	vnic_pg_size_vnic_lvl;
-	/* VNIC PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_VNIC_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_VNIC_LVL_SFT	0
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING8_TQM_RING_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING8_TQM_RING_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING8_TQM_RING_PG_SIZE_PG_1G
+	uint8_t	ring8_unused[3];
+	/* Number of TQM ring entries. */
+	uint32_t	tqm_ring8_num_entries;
+	/* TQM ring page directory. */
+	uint64_t	tqm_ring8_page_dir;
+	/* TQM ring page size and level. */
+	uint8_t	tqm_ring9_pg_size_tqm_ring_lvl;
+	/* TQM ring PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING9_TQM_RING_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING9_TQM_RING_LVL_SFT	0
 	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_VNIC_LVL_LVL_0	UINT32_C(0x0)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING9_TQM_RING_LVL_LVL_0	UINT32_C(0x0)
 	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_VNIC_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_VNIC_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_VNIC_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_VNIC_LVL_LVL_2
-	/* VNIC page size. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_VNIC_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_VNIC_PG_SIZE_SFT   4
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING9_TQM_RING_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to
+	 * PTE tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING9_TQM_RING_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING9_TQM_RING_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING9_TQM_RING_LVL_LVL_2
+	/* TQM ring page size. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING9_TQM_RING_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING9_TQM_RING_PG_SIZE_SFT   4
 	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_VNIC_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING9_TQM_RING_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
 	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_VNIC_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING9_TQM_RING_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
 	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_VNIC_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING9_TQM_RING_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
 	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_VNIC_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING9_TQM_RING_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
 	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_VNIC_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING9_TQM_RING_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
 	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_VNIC_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_VNIC_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_VNIC_PG_SIZE_PG_1G
-	/* Stat page size and level. */
-	uint8_t	stat_pg_size_stat_lvl;
-	/* Stat PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_STAT_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_STAT_LVL_SFT	0
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING9_TQM_RING_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING9_TQM_RING_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING9_TQM_RING_PG_SIZE_PG_1G
+	uint8_t	ring9_unused[3];
+	/* Number of TQM ring entries. */
+	uint32_t	tqm_ring9_num_entries;
+	/* TQM ring page directory. */
+	uint64_t	tqm_ring9_page_dir;
+	/* TQM ring page size and level. */
+	uint8_t	tqm_ring10_pg_size_tqm_ring_lvl;
+	/* TQM ring PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING10_TQM_RING_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING10_TQM_RING_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING10_TQM_RING_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING10_TQM_RING_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to
+	 * PTE tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING10_TQM_RING_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING10_TQM_RING_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING10_TQM_RING_LVL_LVL_2
+	/* TQM ring page size. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING10_TQM_RING_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING10_TQM_RING_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING10_TQM_RING_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING10_TQM_RING_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING10_TQM_RING_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING10_TQM_RING_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING10_TQM_RING_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING10_TQM_RING_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING10_TQM_RING_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING10_TQM_RING_PG_SIZE_PG_1G
+	uint8_t	ring10_unused[3];
+	/* Number of TQM ring entries. */
+	uint32_t	tqm_ring10_num_entries;
+	/* TQM ring page directory. */
+	uint64_t	tqm_ring10_page_dir;
+	/* Number of Tx KTLS context entries. */
+	uint32_t	tkc_num_entries;
+	/* Number of Rx KTLS context entries. */
+	uint32_t	rkc_num_entries;
+	/* Tx KTLS context page directory. */
+	uint64_t	tkc_page_dir;
+	/* Rx KTLS context page directory. */
+	uint64_t	rkc_page_dir;
+	/* Tx KTLS context page size and level. */
+	uint8_t	tkc_pg_size_tkc_lvl;
+	/* Tx KTLS context PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TKC_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TKC_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TKC_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TKC_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to
+	 * PTE tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TKC_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TKC_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TKC_LVL_LVL_2
+	/* Tx KTLS context page size. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TKC_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TKC_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TKC_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TKC_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TKC_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TKC_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TKC_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TKC_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TKC_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TKC_PG_SIZE_PG_1G
+	/* Rx KTLS context page size and level. */
+	uint8_t	rkc_pg_size_rkc_lvl;
+	/* Rx KTLS context PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RKC_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RKC_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RKC_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RKC_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to
+	 * PTE tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RKC_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RKC_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RKC_LVL_LVL_2
+	/* Rx KTLS context page size. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RKC_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RKC_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RKC_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RKC_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RKC_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RKC_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RKC_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RKC_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RKC_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RKC_PG_SIZE_PG_1G
+	/*
+	 * Number of RoCE QP context entries required for this
+	 * function to support fast QP modify destroy feature.
+	 */
+	uint16_t	qp_num_fast_qpmd_entries;
+	uint8_t	unused_1[3];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as 1
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_backing_store_qcfg_output_t, *phwrm_func_backing_store_qcfg_output_t;
+
+/****************************
+ * hwrm_error_recovery_qcfg *
+ ****************************/
+
+
+/* hwrm_error_recovery_qcfg_input (size:192b/24B) */
+
+typedef struct hwrm_error_recovery_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint8_t	unused_0[8];
+} hwrm_error_recovery_qcfg_input_t, *phwrm_error_recovery_qcfg_input_t;
+
+/* hwrm_error_recovery_qcfg_output (size:1664b/208B) */
+
+typedef struct hwrm_error_recovery_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint32_t	flags;
+	/*
+	 * When this flag is set to 1, error recovery will be initiated
+	 * through master function driver.
+	 */
+	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FLAGS_HOST	UINT32_C(0x1)
+	/*
+	 * When this flag is set to 1, error recovery will be performed
+	 * through Co processor.
+	 */
+	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FLAGS_CO_CPU	UINT32_C(0x2)
+	/*
+	 * Driver Polling frequency. This value is in units of 100msec.
+	 * Typical value would be 10 to indicate 1sec.
+	 * Drivers can poll FW health status, Heartbeat, reset_counter with
+	 * this frequency.
+	 */
+	uint32_t	driver_polling_freq;
+	/*
+	 * This value is in units of 100msec.
+	 * Typical value would be 30 to indicate 3sec.
+	 * Master function wait period from detecting a fatal error to
+	 * initiating reset. In this time period Master PF expects every
+	 * active driver will detect fatal error.
+	 */
+	uint32_t	master_func_wait_period;
+	/*
+	 * This value is in units of 100msec.
+	 * Typical value would be 50 to indicate 5sec.
+	 * Normal function wait period from fatal error detection to
+	 * polling FW health status. In this time period, drivers should not
+	 * do any PCIe MMIO transaction and should not send any HWRM commands.
+	 */
+	uint32_t	normal_func_wait_period;
+	/*
+	 * This value is in units of 100msec.
+	 * Typical value would be 20 to indicate 2sec.
+	 * This field indicates that, master function wait period after chip
+	 * reset. After this time, master function should reinitialize with
+	 * FW.
+	 */
+	uint32_t	master_func_wait_period_after_reset;
+	/*
+	 * This value is in units of 100msec.
+	 * Typical value would be 60 to indicate 6sec.
+	 * This field is applicable to both master and normal functions.
+	 * Even after chip reset, if FW status not changed to ready,
+	 * then all the functions can poll for this much time and bailout.
+	 */
+	uint32_t	max_bailout_time_after_reset;
+	/*
+	 * FW health status register.
+	 * Lower 2 bits indicates address space location and upper 30 bits
+	 * indicates upper 30bits of the register address.
+	 * A value of 0xFFFF-FFFF indicates this register does not exist.
+	 */
+	uint32_t	fw_health_status_reg;
+	/* Lower 2 bits indicates address space location. */
+	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEALTH_STATUS_REG_ADDR_SPACE_MASK	UINT32_C(0x3)
+	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEALTH_STATUS_REG_ADDR_SPACE_SFT	0
+	/*
+	 * If value is 0, this register is located in PCIe config space.
+	 * Drivers have to map appropriate window to access this
+	 * register.
+	 */
+		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEALTH_STATUS_REG_ADDR_SPACE_PCIE_CFG  UINT32_C(0x0)
+	/*
+	 * If value is 1, this register is located in GRC address space.
+	 * Drivers have to map appropriate window to access this
+	 * register.
+	 */
+		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEALTH_STATUS_REG_ADDR_SPACE_GRC	UINT32_C(0x1)
+	/*
+	 * If value is 2, this register is located in first BAR address
+	 * space. Drivers have to map appropriate window to access this
+	 * register.
+	 */
+		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEALTH_STATUS_REG_ADDR_SPACE_BAR0	UINT32_C(0x2)
+	/*
+	 * If value is 3, this register is located in second BAR address
+	 * space. Drivers have to map appropriate window to access this
+	 * Drivers have to map appropriate window to access this
+	 * register.
+	 */
+		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEALTH_STATUS_REG_ADDR_SPACE_BAR1	UINT32_C(0x3)
+		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEALTH_STATUS_REG_ADDR_SPACE_LAST	HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEALTH_STATUS_REG_ADDR_SPACE_BAR1
+	/* Upper 30bits of the register address. */
+	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEALTH_STATUS_REG_ADDR_MASK	UINT32_C(0xfffffffc)
+	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEALTH_STATUS_REG_ADDR_SFT	2
+	/*
+	 * FW HeartBeat register.
+	 * Lower 2 bits indicates address space location and upper 30 bits
+	 * indicates actual address.
+	 * A value of 0xFFFF-FFFF indicates this register does not exist.
+	 */
+	uint32_t	fw_heartbeat_reg;
+	/* Lower 2 bits indicates address space location. */
+	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEARTBEAT_REG_ADDR_SPACE_MASK	UINT32_C(0x3)
+	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEARTBEAT_REG_ADDR_SPACE_SFT	0
+	/*
+	 * If value is 0, this register is located in PCIe config space.
+	 * Drivers have to map appropriate window to access this
+	 * register.
+	 */
+		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEARTBEAT_REG_ADDR_SPACE_PCIE_CFG  UINT32_C(0x0)
+	/*
+	 * If value is 1, this register is located in GRC address space.
+	 * Drivers have to map appropriate window to access this
+	 * register.
+	 */
+		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEARTBEAT_REG_ADDR_SPACE_GRC	UINT32_C(0x1)
+	/*
+	 * If value is 2, this register is located in first BAR address
+	 * space. Drivers have to map appropriate window to access this
+	 * register.
+	 */
+		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEARTBEAT_REG_ADDR_SPACE_BAR0	UINT32_C(0x2)
+	/*
+	 * If value is 3, this register is located in second BAR address
+	 * space. Drivers have to map appropriate window to access this
+	 * register.
+	 */
+		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEARTBEAT_REG_ADDR_SPACE_BAR1	UINT32_C(0x3)
+		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEARTBEAT_REG_ADDR_SPACE_LAST	HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEARTBEAT_REG_ADDR_SPACE_BAR1
+	/* Upper 30bits of the register address. */
+	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEARTBEAT_REG_ADDR_MASK	UINT32_C(0xfffffffc)
+	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEARTBEAT_REG_ADDR_SFT	2
+	/*
+	 * FW reset counter.
+	 * Lower 2 bits indicates address space location and upper 30 bits
+	 * indicates actual address.
+	 * A value of 0xFFFF-FFFF indicates this register does not exist.
+	 */
+	uint32_t	fw_reset_cnt_reg;
+	/* Lower 2 bits indicates address space location. */
+	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_RESET_CNT_REG_ADDR_SPACE_MASK	UINT32_C(0x3)
+	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_RESET_CNT_REG_ADDR_SPACE_SFT	0
+	/*
+	 * If value is 0, this register is located in PCIe config space.
+	 * Drivers have to map appropriate window to access this
+	 * register.
+	 */
+		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_RESET_CNT_REG_ADDR_SPACE_PCIE_CFG  UINT32_C(0x0)
+	/*
+	 * If value is 1, this register is located in GRC address space.
+	 * Drivers have to map appropriate window to access this
+	 * register.
+	 */
+		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_RESET_CNT_REG_ADDR_SPACE_GRC	UINT32_C(0x1)
+	/*
+	 * If value is 2, this register is located in first BAR address
+	 * space. Drivers have to map appropriate window to access this
+	 * register.
+	 */
+		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_RESET_CNT_REG_ADDR_SPACE_BAR0	UINT32_C(0x2)
+	/*
+	 * If value is 3, this register is located in second BAR address
+	 * space. Drivers have to map appropriate window to access this
+	 * register.
+	 */
+		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_RESET_CNT_REG_ADDR_SPACE_BAR1	UINT32_C(0x3)
+		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_RESET_CNT_REG_ADDR_SPACE_LAST	HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_RESET_CNT_REG_ADDR_SPACE_BAR1
+	/* Upper 30bits of the register address. */
+	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_RESET_CNT_REG_ADDR_MASK	UINT32_C(0xfffffffc)
+	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_RESET_CNT_REG_ADDR_SFT	2
+	/*
+	 * Reset Inprogress Register address for PFs.
+	 * Lower 2 bits indicates address space location and upper 30 bits
+	 * indicates actual address.
+	 * A value of 0xFFFF-FFFF indicates this register does not exist.
+	 */
+	uint32_t	reset_inprogress_reg;
+	/* Lower 2 bits indicates address space location. */
+	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_INPROGRESS_REG_ADDR_SPACE_MASK	UINT32_C(0x3)
+	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_INPROGRESS_REG_ADDR_SPACE_SFT	0
+	/*
+	 * If value is 0, this register is located in PCIe config space.
+	 * Drivers have to map appropriate window to access this
+	 * register.
+	 */
+		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_INPROGRESS_REG_ADDR_SPACE_PCIE_CFG  UINT32_C(0x0)
+	/*
+	 * If value is 1, this register is located in GRC address space.
+	 * Drivers have to map appropriate window to access this
+	 * register.
+	 */
+		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_INPROGRESS_REG_ADDR_SPACE_GRC	UINT32_C(0x1)
+	/*
+	 * If value is 2, this register is located in first BAR address
+	 * space. Drivers have to map appropriate window to access this
+	 * register.
+	 */
+		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_INPROGRESS_REG_ADDR_SPACE_BAR0	UINT32_C(0x2)
+	/*
+	 * If value is 3, this register is located in second BAR address
+	 * space. Drivers have to map appropriate window to access this
+	 * register.
+	 */
+		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_INPROGRESS_REG_ADDR_SPACE_BAR1	UINT32_C(0x3)
+		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_INPROGRESS_REG_ADDR_SPACE_LAST	HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_INPROGRESS_REG_ADDR_SPACE_BAR1
+	/* Upper 30bits of the register address. */
+	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_INPROGRESS_REG_ADDR_MASK	UINT32_C(0xfffffffc)
+	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_INPROGRESS_REG_ADDR_SFT	2
+	/* This field indicates the mask value for reset_inprogress_reg. */
+	uint32_t	reset_inprogress_reg_mask;
+	uint8_t	unused_0[3];
+	/*
+	 * Array of registers and value count to reset the Chip
+	 * Each array count has reset_reg, reset_reg_val, delay_after_reset
+	 * in TLV format. Depending upon Chip type, number of reset registers
+	 * will vary. Drivers have to write reset_reg_val in the reset_reg
+	 * location in the same sequence in order to recover from a fatal
+	 * error.
+	 */
+	uint8_t	reg_array_cnt;
+	/*
+	 * Reset register.
+	 * Lower 2 bits indicates address space location and upper 30 bits
+	 * indicates actual address.
+	 * A value of 0xFFFF-FFFF indicates this register does not exist.
+	 */
+	uint32_t	reset_reg[16];
+	/* Lower 2 bits indicates address space location. */
+	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_REG_ADDR_SPACE_MASK	UINT32_C(0x3)
+	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_REG_ADDR_SPACE_SFT	0
+	/*
+	 * If value is 0, this register is located in PCIe config space.
+	 * Drivers have to map appropriate window to access this
+	 * register.
+	 */
+		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_REG_ADDR_SPACE_PCIE_CFG  UINT32_C(0x0)
+	/*
+	 * If value is 1, this register is located in GRC address space.
+	 * Drivers have to map appropriate window to access this
+	 * register.
+	 */
+		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_REG_ADDR_SPACE_GRC	UINT32_C(0x1)
+	/*
+	 * If value is 2, this register is located in first BAR address
+	 * space. Drivers have to map appropriate window to access this
+	 * register.
+	 */
+		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_REG_ADDR_SPACE_BAR0	UINT32_C(0x2)
+	/*
+	 * If value is 3, this register is located in second BAR address
+	 * space. Drivers have to map appropriate window to access this
+	 * register.
+	 */
+		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_REG_ADDR_SPACE_BAR1	UINT32_C(0x3)
+		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_REG_ADDR_SPACE_LAST	HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_REG_ADDR_SPACE_BAR1
+	/* Upper 30bits of the register address. */
+	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_REG_ADDR_MASK	UINT32_C(0xfffffffc)
+	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_REG_ADDR_SFT	2
+	/* Value to be written in reset_reg to reset the controller. */
+	uint32_t	reset_reg_val[16];
+	/*
+	 * This value is in units of 1msec.
+	 * Typical value would be 10 to indicate 10msec.
+	 * Some of the operations like Core reset require delay before
+	 * accessing PCIE MMIO register space.
+	 * If this value is non-zero, drivers have to wait for
+	 * this much time after writing reset_reg_val in reset_reg.
+	 */
+	uint8_t	delay_after_reset[16];
+	/*
+	 * Error recovery counter.
+	 * Lower 2 bits indicates address space location and upper 30 bits
+	 * indicates actual address.
+	 * A value of 0xFFFF-FFFF indicates this register does not exist.
+	 */
+	uint32_t	err_recovery_cnt_reg;
+	/* Lower 2 bits indicates address space location. */
+	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_ERR_RECOVERY_CNT_REG_ADDR_SPACE_MASK	UINT32_C(0x3)
+	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_ERR_RECOVERY_CNT_REG_ADDR_SPACE_SFT	0
+	/*
+	 * If value is 0, this register is located in PCIe config space.
+	 * Drivers have to map appropriate window to access this
+	 * register.
+	 */
+		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_ERR_RECOVERY_CNT_REG_ADDR_SPACE_PCIE_CFG  UINT32_C(0x0)
+	/*
+	 * If value is 1, this register is located in GRC address space.
+	 * Drivers have to map appropriate window to access this
+	 * register.
+	 */
+		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_ERR_RECOVERY_CNT_REG_ADDR_SPACE_GRC	UINT32_C(0x1)
+	/*
+	 * If value is 2, this register is located in first BAR address
+	 * space. Drivers have to map appropriate window to access this
+	 * register.
+	 */
+		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_ERR_RECOVERY_CNT_REG_ADDR_SPACE_BAR0	UINT32_C(0x2)
+	/*
+	 * If value is 3, this register is located in second BAR address
+	 * space. Drivers have to map appropriate window to access this
+	 * register.
+	 */
+		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_ERR_RECOVERY_CNT_REG_ADDR_SPACE_BAR1	UINT32_C(0x3)
+		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_ERR_RECOVERY_CNT_REG_ADDR_SPACE_LAST	HWRM_ERROR_RECOVERY_QCFG_OUTPUT_ERR_RECOVERY_CNT_REG_ADDR_SPACE_BAR1
+	/* Upper 30bits of the register address. */
+	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_ERR_RECOVERY_CNT_REG_ADDR_MASK	UINT32_C(0xfffffffc)
+	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_ERR_RECOVERY_CNT_REG_ADDR_SFT	2
+	uint8_t	unused_1[3];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
+	 */
+	uint8_t	valid;
+} hwrm_error_recovery_qcfg_output_t, *phwrm_error_recovery_qcfg_output_t;
+
+/***************************
+ * hwrm_func_echo_response *
+ ***************************/
+
+
+/* hwrm_func_echo_response_input (size:192b/24B) */
+
+typedef struct hwrm_func_echo_response_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	event_data1;
+	uint32_t	event_data2;
+} hwrm_func_echo_response_input_t, *phwrm_func_echo_response_input_t;
+
+/* hwrm_func_echo_response_output (size:128b/16B) */
+
+typedef struct hwrm_func_echo_response_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_echo_response_output_t, *phwrm_func_echo_response_output_t;
+
+/**************************
+ * hwrm_func_ptp_pin_qcfg *
+ **************************/
+
+
+/* hwrm_func_ptp_pin_qcfg_input (size:192b/24B) */
+
+typedef struct hwrm_func_ptp_pin_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint8_t	unused_0[8];
+} hwrm_func_ptp_pin_qcfg_input_t, *phwrm_func_ptp_pin_qcfg_input_t;
+
+/* hwrm_func_ptp_pin_qcfg_output (size:128b/16B) */
+
+typedef struct hwrm_func_ptp_pin_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/*
+	 * The number of TSIO pins that are configured on this board
+	 * Up to 4 pins can be returned in the response.
+	 */
+	uint8_t	num_pins;
+	/* Pin state */
+	uint8_t	state;
+	/*
+	 * When this bit is '1', TSIO pin 0 is enabled.
+	 * When this bit is '0', TSIO pin 0 is disabled.
+	 */
+	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_STATE_PIN0_ENABLED	UINT32_C(0x1)
+	/*
+	 * When this bit is '1', TSIO pin 1 is enabled.
+	 * When this bit is '0', TSIO pin 1 is disabled.
+	 */
+	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_STATE_PIN1_ENABLED	UINT32_C(0x2)
+	/*
+	 * When this bit is '1', TSIO pin 2 is enabled.
+	 * When this bit is '0', TSIO pin 2 is disabled.
+	 */
+	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_STATE_PIN2_ENABLED	UINT32_C(0x4)
+	/*
+	 * When this bit is '1', TSIO pin 3 is enabled.
+	 * When this bit is '0', TSIO pin 3 is disabled.
+	 */
+	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_STATE_PIN3_ENABLED	UINT32_C(0x8)
+	/* Type of function for Pin #0. */
+	uint8_t	pin0_usage;
+	/* No function is configured. */
+	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN0_USAGE_NONE	UINT32_C(0x0)
+	/* PPS IN is configured. */
+	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN0_USAGE_PPS_IN   UINT32_C(0x1)
+	/* PPS OUT is configured. */
+	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN0_USAGE_PPS_OUT  UINT32_C(0x2)
+	/* SYNC IN is configured. */
+	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN0_USAGE_SYNC_IN  UINT32_C(0x3)
+	/* SYNC OUT is configured. */
+	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN0_USAGE_SYNC_OUT UINT32_C(0x4)
+	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN0_USAGE_LAST	HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN0_USAGE_SYNC_OUT
+	/* Type of function for Pin #1. */
+	uint8_t	pin1_usage;
+	/* No function is configured. */
+	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN1_USAGE_NONE	UINT32_C(0x0)
+	/* PPS IN is configured. */
+	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN1_USAGE_PPS_IN   UINT32_C(0x1)
+	/* PPS OUT is configured. */
+	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN1_USAGE_PPS_OUT  UINT32_C(0x2)
+	/* SYNC IN is configured. */
+	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN1_USAGE_SYNC_IN  UINT32_C(0x3)
+	/* SYNC OUT is configured. */
+	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN1_USAGE_SYNC_OUT UINT32_C(0x4)
+	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN1_USAGE_LAST	HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN1_USAGE_SYNC_OUT
+	/* Type of function for Pin #2. */
+	uint8_t	pin2_usage;
+	/* No function is configured. */
+	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN2_USAGE_NONE			UINT32_C(0x0)
+	/* PPS IN is configured. */
+	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN2_USAGE_PPS_IN			UINT32_C(0x1)
+	/* PPS OUT is configured. */
+	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN2_USAGE_PPS_OUT		UINT32_C(0x2)
+	/* SYNC IN is configured. */
+	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN2_USAGE_SYNC_IN		UINT32_C(0x3)
+	/* SYNC OUT is configured. */
+	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN2_USAGE_SYNC_OUT		UINT32_C(0x4)
+	/* SYNCE primary clock OUT is configured. */
+	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN2_USAGE_SYNCE_PRIMARY_CLOCK_OUT   UINT32_C(0x5)
+	/* SYNCE secondary clock OUT is configured. */
+	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN2_USAGE_SYNCE_SECONDARY_CLOCK_OUT UINT32_C(0x6)
+	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN2_USAGE_LAST			HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN2_USAGE_SYNCE_SECONDARY_CLOCK_OUT
+	/* Type of function for Pin #3. */
+	uint8_t	pin3_usage;
+	/* No function is configured. */
+	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN3_USAGE_NONE			UINT32_C(0x0)
+	/* PPS IN is configured. */
+	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN3_USAGE_PPS_IN			UINT32_C(0x1)
+	/* PPS OUT is configured. */
+	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN3_USAGE_PPS_OUT		UINT32_C(0x2)
+	/* SYNC IN is configured. */
+	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN3_USAGE_SYNC_IN		UINT32_C(0x3)
+	/* SYNC OUT is configured. */
+	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN3_USAGE_SYNC_OUT		UINT32_C(0x4)
+	/* SYNCE primary clock OUT is configured. */
+	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN3_USAGE_SYNCE_PRIMARY_CLOCK_OUT   UINT32_C(0x5)
+	/* SYNCE secondary OUT is configured. */
+	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN3_USAGE_SYNCE_SECONDARY_CLOCK_OUT UINT32_C(0x6)
+	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN3_USAGE_LAST			HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN3_USAGE_SYNCE_SECONDARY_CLOCK_OUT
+	uint8_t	unused_0;
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_ptp_pin_qcfg_output_t, *phwrm_func_ptp_pin_qcfg_output_t;
+
+/*************************
+ * hwrm_func_ptp_pin_cfg *
+ *************************/
+
+
+/* hwrm_func_ptp_pin_cfg_input (size:256b/32B) */
+
+typedef struct hwrm_func_ptp_pin_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	enables;
+	/*
+	 * This bit must be '1' for the pin0_state field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_ENABLES_PIN0_STATE	UINT32_C(0x1)
+	/*
+	 * This bit must be '1' for the pin0_usage field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_ENABLES_PIN0_USAGE	UINT32_C(0x2)
+	/*
+	 * This bit must be '1' for the pin1_state field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_ENABLES_PIN1_STATE	UINT32_C(0x4)
+	/*
+	 * This bit must be '1' for the pin1_usage field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_ENABLES_PIN1_USAGE	UINT32_C(0x8)
+	/*
+	 * This bit must be '1' for the pin2_state field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_ENABLES_PIN2_STATE	UINT32_C(0x10)
+	/*
+	 * This bit must be '1' for the pin2_usage field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_ENABLES_PIN2_USAGE	UINT32_C(0x20)
+	/*
+	 * This bit must be '1' for the pin3_state field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_ENABLES_PIN3_STATE	UINT32_C(0x40)
+	/*
+	 * This bit must be '1' for the pin3_usage field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_ENABLES_PIN3_USAGE	UINT32_C(0x80)
+	/* Enable or disable functionality of Pin #0. */
+	uint8_t	pin0_state;
+	/* Disabled */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN0_STATE_DISABLED UINT32_C(0x0)
+	/* Enabled */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN0_STATE_ENABLED  UINT32_C(0x1)
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN0_STATE_LAST	HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN0_STATE_ENABLED
+	/* Configure function for TSIO pin#0. */
+	uint8_t	pin0_usage;
+	/* No function is configured. */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN0_USAGE_NONE	UINT32_C(0x0)
+	/* PPS IN is configured. */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN0_USAGE_PPS_IN   UINT32_C(0x1)
+	/* PPS OUT is configured. */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN0_USAGE_PPS_OUT  UINT32_C(0x2)
+	/* SYNC IN is configured. */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN0_USAGE_SYNC_IN  UINT32_C(0x3)
+	/* SYNC OUT is configured. */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN0_USAGE_SYNC_OUT UINT32_C(0x4)
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN0_USAGE_LAST	HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN0_USAGE_SYNC_OUT
+	/* Enable or disable functionality of Pin #1. */
+	uint8_t	pin1_state;
+	/* Disabled */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN1_STATE_DISABLED UINT32_C(0x0)
+	/* Enabled */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN1_STATE_ENABLED  UINT32_C(0x1)
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN1_STATE_LAST	HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN1_STATE_ENABLED
+	/* Configure function for TSIO pin#1. */
+	uint8_t	pin1_usage;
+	/* No function is configured. */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN1_USAGE_NONE	UINT32_C(0x0)
+	/* PPS IN is configured. */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN1_USAGE_PPS_IN   UINT32_C(0x1)
+	/* PPS OUT is configured. */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN1_USAGE_PPS_OUT  UINT32_C(0x2)
+	/* SYNC IN is configured. */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN1_USAGE_SYNC_IN  UINT32_C(0x3)
+	/* SYNC OUT is configured. */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN1_USAGE_SYNC_OUT UINT32_C(0x4)
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN1_USAGE_LAST	HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN1_USAGE_SYNC_OUT
+	/* Enable or disable functionality of Pin #2. */
+	uint8_t	pin2_state;
+	/* Disabled */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN2_STATE_DISABLED UINT32_C(0x0)
+	/* Enabled */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN2_STATE_ENABLED  UINT32_C(0x1)
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN2_STATE_LAST	HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN2_STATE_ENABLED
+	/* Configure function for TSIO pin#2. */
+	uint8_t	pin2_usage;
+	/* No function is configured. */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN2_USAGE_NONE			UINT32_C(0x0)
+	/* PPS IN is configured. */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN2_USAGE_PPS_IN			UINT32_C(0x1)
+	/* PPS OUT is configured. */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN2_USAGE_PPS_OUT		UINT32_C(0x2)
+	/* SYNC IN is configured. */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN2_USAGE_SYNC_IN		UINT32_C(0x3)
+	/* SYNC OUT is configured. */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN2_USAGE_SYNC_OUT		UINT32_C(0x4)
+	/* SYNCE primary clock OUT is configured. */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN2_USAGE_SYNCE_PRIMARY_CLOCK_OUT   UINT32_C(0x5)
+	/* SYNCE secondary clock OUT is configured. */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN2_USAGE_SYNCE_SECONDARY_CLOCK_OUT UINT32_C(0x6)
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN2_USAGE_LAST			HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN2_USAGE_SYNCE_SECONDARY_CLOCK_OUT
+	/* Enable or disable functionality of Pin #3. */
+	uint8_t	pin3_state;
+	/* Disabled */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN3_STATE_DISABLED UINT32_C(0x0)
+	/* Enabled */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN3_STATE_ENABLED  UINT32_C(0x1)
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN3_STATE_LAST	HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN3_STATE_ENABLED
+	/* Configure function for TSIO pin#3. */
+	uint8_t	pin3_usage;
+	/* No function is configured. */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN3_USAGE_NONE			UINT32_C(0x0)
+	/* PPS IN is configured. */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN3_USAGE_PPS_IN			UINT32_C(0x1)
+	/* PPS OUT is configured. */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN3_USAGE_PPS_OUT		UINT32_C(0x2)
+	/* SYNC IN is configured. */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN3_USAGE_SYNC_IN		UINT32_C(0x3)
+	/* SYNC OUT is configured. */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN3_USAGE_SYNC_OUT		UINT32_C(0x4)
+	/* SYNCE primary clock OUT is configured. */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN3_USAGE_SYNCE_PRIMARY_CLOCK_OUT   UINT32_C(0x5)
+	/* SYNCE secondary clock OUT is configured. */
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN3_USAGE_SYNCE_SECONDARY_CLOCK_OUT UINT32_C(0x6)
+	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN3_USAGE_LAST			HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN3_USAGE_SYNCE_SECONDARY_CLOCK_OUT
+	uint8_t	unused_0[4];
+} hwrm_func_ptp_pin_cfg_input_t, *phwrm_func_ptp_pin_cfg_input_t;
+
+/* hwrm_func_ptp_pin_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_func_ptp_pin_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_ptp_pin_cfg_output_t, *phwrm_func_ptp_pin_cfg_output_t;
+
+/*********************
+ * hwrm_func_ptp_cfg *
+ *********************/
+
+
+/* hwrm_func_ptp_cfg_input (size:384b/48B) */
+
+typedef struct hwrm_func_ptp_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint16_t	enables;
+	/*
+	 * This bit must be '1' for the ptp_pps_event field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_PTP_CFG_INPUT_ENABLES_PTP_PPS_EVENT		UINT32_C(0x1)
+	/*
+	 * This bit must be '1' for the ptp_freq_adj_dll_source field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_PTP_CFG_INPUT_ENABLES_PTP_FREQ_ADJ_DLL_SOURCE	UINT32_C(0x2)
+	/*
+	 * This bit must be '1' for the ptp_freq_adj_dll_phase field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_PTP_CFG_INPUT_ENABLES_PTP_FREQ_ADJ_DLL_PHASE	UINT32_C(0x4)
+	/*
+	 * This bit must be '1' for the ptp_freq_adj_ext_period field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_PTP_CFG_INPUT_ENABLES_PTP_FREQ_ADJ_EXT_PERIOD	UINT32_C(0x8)
+	/*
+	 * This bit must be '1' for the ptp_freq_adj_ext_up field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_PTP_CFG_INPUT_ENABLES_PTP_FREQ_ADJ_EXT_UP	UINT32_C(0x10)
+	/*
+	 * This bit must be '1' for the ptp_freq_adj_ext_phase field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_PTP_CFG_INPUT_ENABLES_PTP_FREQ_ADJ_EXT_PHASE	UINT32_C(0x20)
+	/* This bit must be '1' for ptp_set_time field to be configured. */
+	#define HWRM_FUNC_PTP_CFG_INPUT_ENABLES_PTP_SET_TIME		UINT32_C(0x40)
+	/* This field is used to enable interrupt for a specific PPS event. */
+	uint8_t	ptp_pps_event;
+	/*
+	 * When this bit is set to '1', interrupt is enabled for internal
+	 * PPS event. Latches timestamp on PPS_OUT TSIO Pin. If user does
+	 * not configure PPS_OUT on a TSIO pin, then firmware will allocate
+	 * PPS_OUT to an unallocated pin.
+	 */
+	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_PPS_EVENT_INTERNAL	UINT32_C(0x1)
+	/*
+	 * When this bit is set to '1', interrupt is enabled for external
+	 * PPS event. Latches timestamp on PPS_IN TSIO pin.
+	 */
+	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_PPS_EVENT_EXTERNAL	UINT32_C(0x2)
+	/*
+	 * This field is used to set the source signal used to discipline
+	 * PHC (PTP Hardware Clock)
+	 */
+	uint8_t	ptp_freq_adj_dll_source;
+	/* No source is selected. Use servo to discipline PHC */
+	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_SOURCE_NONE	UINT32_C(0x0)
+	/* TSIO Pin #0 is selected as source signal. */
+	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_SOURCE_TSIO_0  UINT32_C(0x1)
+	/* TSIO Pin #1 is selected as source signal. */
+	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_SOURCE_TSIO_1  UINT32_C(0x2)
+	/* TSIO Pin #2 is selected as source signal. */
+	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_SOURCE_TSIO_2  UINT32_C(0x3)
+	/* TSIO Pin #3 is selected as source signal. */
+	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_SOURCE_TSIO_3  UINT32_C(0x4)
+	/* Port #0 is selected as source signal. */
+	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_SOURCE_PORT_0  UINT32_C(0x5)
+	/* Port #1 is selected as source signal. */
+	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_SOURCE_PORT_1  UINT32_C(0x6)
+	/* Port #2 is selected as source signal. */
+	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_SOURCE_PORT_2  UINT32_C(0x7)
+	/* Port #3 is selected as source signal. */
+	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_SOURCE_PORT_3  UINT32_C(0x8)
+	/* Invalid signal. */
+	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_SOURCE_INVALID UINT32_C(0xff)
+	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_SOURCE_LAST   HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_SOURCE_INVALID
+	/*
+	 * This field is used to provide phase adjustment for DLL
+	 * used to discipline PHC (PTP Hardware clock)
+	 */
+	uint8_t	ptp_freq_adj_dll_phase;
+	/* No Phase adjustment. */
+	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_PHASE_NONE UINT32_C(0x0)
+	/* 4Khz sync in frequency. */
+	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_PHASE_4K   UINT32_C(0x1)
+	/* 8Khz sync in frequency. */
+	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_PHASE_8K   UINT32_C(0x2)
+	/* 10Mhz sync in frequency. */
+	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_PHASE_10M  UINT32_C(0x3)
+	/* 25Mhz sync in frequency. */
+	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_PHASE_25M  UINT32_C(0x4)
+	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_PHASE_LAST HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_PHASE_25M
+	uint8_t	unused_0[3];
+	/*
+	 * Period in nanoseconds (ns) for external signal
+	 * input.
+	 */
+	uint32_t	ptp_freq_adj_ext_period;
+	/*
+	 * Up time in nanoseconds (ns) of the duty cycle
+	 * of the external signal. This value should be
+	 * less than ptp_freq_adj_ext_period.
+	 */
+	uint32_t	ptp_freq_adj_ext_up;
+	/*
+	 * Phase value is provided. This field provides the
+	 * least significant 32 bits of the phase input. The
+	 * most significant 16 bits come from
+	 * ptp_freq_adj_ext_phase_upper field. Setting this
+	 * field requires setting ptp_freq_adj_ext_period
+	 * field as well to identify the external signal
+	 * pin.
+	 */
+	uint32_t	ptp_freq_adj_ext_phase_lower;
+	/*
+	 * Phase value is provided. The lower 16 bits of this field is used
+	 * with the 32 bit value from ptp_freq_adj_ext_phase_lower
+	 * to provide a 48 bit value input for Phase.
+	 */
+	uint32_t	ptp_freq_adj_ext_phase_upper;
+	/*
+	 * Allows driver to set the full 64bit time in FW. The upper 16 bits
+	 * will be stored in FW and the lower 48bits will be programmed in
+	 * PHC. Firmware will send a broadcast async event to all functions
+	 * to indicate the programmed upper 16 bits.
+	 */
+	uint64_t	ptp_set_time;
+} hwrm_func_ptp_cfg_input_t, *phwrm_func_ptp_cfg_input_t;
+
+/* hwrm_func_ptp_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_func_ptp_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_ptp_cfg_output_t, *phwrm_func_ptp_cfg_output_t;
+
+/**************************
+ * hwrm_func_ptp_ts_query *
+ **************************/
+
+
+/* hwrm_func_ptp_ts_query_input (size:192b/24B) */
+
+typedef struct hwrm_func_ptp_ts_query_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	flags;
+	/* If set, the response includes PPS event timestamps */
+	#define HWRM_FUNC_PTP_TS_QUERY_INPUT_FLAGS_PPS_TIME	UINT32_C(0x1)
+	/* If set, the response includes PTM timestamps */
+	#define HWRM_FUNC_PTP_TS_QUERY_INPUT_FLAGS_PTM_TIME	UINT32_C(0x2)
+	uint8_t	unused_0[4];
+} hwrm_func_ptp_ts_query_input_t, *phwrm_func_ptp_ts_query_input_t;
+
+/* hwrm_func_ptp_ts_query_output (size:320b/40B) */
+
+typedef struct hwrm_func_ptp_ts_query_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Timestamp value of last PPS event latched. */
+	uint64_t	pps_event_ts;
+	/*
+	 * PHC timestamp value when PTM responseD request is received
+	 * at downstream port (t4'). This is a 48 bit timestamp in nanoseconds.
+	 */
+	uint64_t	ptm_local_ts;
+	/*
+	 * PTM System timestamp value corresponding to t4' at
+	 * root complex (T4'). Together with ptm_local_ts, these
+	 * two timestamps provide the cross-trigger timestamps.
+	 * Driver can directly use these values for cross-trigger.
+	 * This is a 48 bit timestamp in nanoseconds.
+	 */
+	uint64_t	ptm_system_ts;
+	/*
+	 * PTM Link delay. This is the time taken at root complex (RC)
+	 * between receiving PTM request and sending PTM response to
+	 * downstream port. This is a 32 bit value in nanoseconds.
+	 */
+	uint32_t	ptm_link_delay;
+	uint8_t	unused_0[3];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_ptp_ts_query_output_t, *phwrm_func_ptp_ts_query_output_t;
+
+/*************************
+ * hwrm_func_ptp_ext_cfg *
+ *************************/
+
+
+/* hwrm_func_ptp_ext_cfg_input (size:256b/32B) */
+
+typedef struct hwrm_func_ptp_ext_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint16_t	enables;
+	/*
+	 * This bit must be '1' for the phc_master_fid field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_PTP_EXT_CFG_INPUT_ENABLES_PHC_MASTER_FID	UINT32_C(0x1)
+	/*
+	 * This bit must be '1' for the phc_sec_fid field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_PTP_EXT_CFG_INPUT_ENABLES_PHC_SEC_FID	UINT32_C(0x2)
+	/*
+	 * This bit must be '1' for the phc_sec_mode field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_PTP_EXT_CFG_INPUT_ENABLES_PHC_SEC_MODE	UINT32_C(0x4)
+	/*
+	 * This bit must be '1' for the failover_timer field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_PTP_EXT_CFG_INPUT_ENABLES_FAILOVER_TIMER	UINT32_C(0x8)
+	/*
+	 * This field is used to configure the Master function. Only this
+	 * function can modify or condition the PHC. Only driver calls from
+	 * this function are allowed to adjust frequency of PHC or configure
+	 * PPS functionality.
+	 * If driver does not specify this FID, then firmware will auto select
+	 * the first function that makes the call to modify PHC as the Master.
+	 */
+	uint16_t	phc_master_fid;
+	/*
+	 * This field is used to configure the secondary function. This
+	 * function becomes the Master function in case of failover from
+	 * Master function.
+	 * If driver does not specify this FID, firmware will auto select
+	 * the last non-master function to make a call to condition PHC as
+	 * secondary.
+	 */
+	uint16_t	phc_sec_fid;
+	/*
+	 * This field is used to configure conditions under which a function
+	 * can become a secondary function.
+	 */
+	uint8_t	phc_sec_mode;
+	/*
+	 * Immediately failover to the current secondary function. If there
+	 * is no secondary function available, failover does not happen.
+	 */
+	#define HWRM_FUNC_PTP_EXT_CFG_INPUT_PHC_SEC_MODE_SWITCH  UINT32_C(0x0)
+	/*
+	 * All functions (PF and VF) can be used during auto selection
+	 * of a secondary function. This is not used in case of admin
+	 * configured secondary function.
+	 */
+	#define HWRM_FUNC_PTP_EXT_CFG_INPUT_PHC_SEC_MODE_ALL	UINT32_C(0x1)
+	/*
+	 * Only PF's can be selected as a secondary function during auto
+	 * selection. This is not used in case of admin configured secondary
+	 * function.
+	 */
+	#define HWRM_FUNC_PTP_EXT_CFG_INPUT_PHC_SEC_MODE_PF_ONLY UINT32_C(0x2)
+	#define HWRM_FUNC_PTP_EXT_CFG_INPUT_PHC_SEC_MODE_LAST   HWRM_FUNC_PTP_EXT_CFG_INPUT_PHC_SEC_MODE_PF_ONLY
+	uint8_t	unused_0;
+	/*
+	 * This field indicates the failover time is milliseconds. If the
+	 * timeout expires, firmware will failover PTP configurability from
+	 * current master to secondary fid.
+	 * 0 - Failover timer is automatically selected based on the last
+	 * adjFreq() call. If adjFreq() is not called for 3 * (last interval)
+	 * the failover kicks in. For example, if last interval between
+	 * adjFreq() calls was 2 seconds and the next adjFreq() is not made for
+	 * at least 6 seconds, then secondary takes over as master to condition
+	 * PHC. Firmware rounds up the failover timer to be a multiple of 250
+	 * ms. Firmware checks every 250 ms to see if timer expired.
+	 * 0xFFFFFFFF - If driver specifies this value, then failover never
+	 * happens. Admin or auto selected Master will always be used for
+	 * conditioning PHC.
+	 * X - If driver specifies any other value, this is admin indicated
+	 * failover timeout. If no adjFreq() call is made within this timeout
+	 * value, then failover happens. This value should be a multiple of
+	 * 250 ms. Firmware checks every 250 ms to see if timer expired.
+	 */
+	uint32_t	failover_timer;
+	uint8_t	unused_1[4];
+} hwrm_func_ptp_ext_cfg_input_t, *phwrm_func_ptp_ext_cfg_input_t;
+
+/* hwrm_func_ptp_ext_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_func_ptp_ext_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_ptp_ext_cfg_output_t, *phwrm_func_ptp_ext_cfg_output_t;
+
+/**************************
+ * hwrm_func_ptp_ext_qcfg *
+ **************************/
+
+
+/* hwrm_func_ptp_ext_qcfg_input (size:192b/24B) */
+
+typedef struct hwrm_func_ptp_ext_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint8_t	unused_0[8];
+} hwrm_func_ptp_ext_qcfg_input_t, *phwrm_func_ptp_ext_qcfg_input_t;
+
+/* hwrm_func_ptp_ext_qcfg_output (size:256b/32B) */
+
+typedef struct hwrm_func_ptp_ext_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/*
+	 * Firmware returns the current PHC master function. This function
+	 * could either be admin selected or auto selected.
+	 */
+	uint16_t	phc_master_fid;
+	/*
+	 * Firmware returns the current PHC secondary function. This function
+	 * could either be admin selected or auto selected.
+	 */
+	uint16_t	phc_sec_fid;
+	/*
+	 * Firmware returns the last non-master/non-secondary function to
+	 * make a call to condition PHC.
+	 */
+	uint16_t	phc_active_fid0;
+	/*
+	 * Firmware returns the second last non-master/non-secondary function
+	 * to make a call to condition PHC.
+	 */
+	uint16_t	phc_active_fid1;
+	/*
+	 * Timestamp indicating the last time a failover happened. The master
+	 * and secondary functions in the failover event is indicated in the
+	 * next two fields.
+	 */
+	uint32_t	last_failover_event;
+	/*
+	 * Last failover happened from this function. This was the master
+	 * function at the time of failover.
+	 */
+	uint16_t	from_fid;
+	/*
+	 * Last failover happened to this function. This was the secondary
+	 * function at the time of failover.
+	 */
+	uint16_t	to_fid;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_ptp_ext_qcfg_output_t, *phwrm_func_ptp_ext_qcfg_output_t;
+
+/***************************
+ * hwrm_func_key_ctx_alloc *
+ ***************************/
+
+
+/* hwrm_func_key_ctx_alloc_input (size:384b/48B) */
+
+typedef struct hwrm_func_key_ctx_alloc_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Function ID. */
+	uint16_t	fid;
+	/*
+	 * Number of Key Contexts to be allocated.
+	 * When running in the XID partition mode, if the call is made by
+	 * a VF driver, this field specifies the number of XIDs requested
+	 * by the VF driver. The XID partitions are managed by the PF
+	 * driver in XID partition mode and the VF command will be
+	 * redirected to the PF driver. The PF driver may reduce this
+	 * number if it cannot allocate a big enough block of XID
+	 * partitions to satisfy the request.
+	 * This field must not exceed the maximum batch size specified in
+	 * the max_key_ctxs_alloc field of the HWRM_FUNC_QCAPS response,
+	 * must not be zero, and must be integer multiples of the
+	 * partition size specified in the ctxs_per_partition field of
+	 * the HWRM_FUNC_QCAPS response.
+	 */
+	uint16_t	num_key_ctxs;
+	/*
+	 * DMA buffer size in bytes. This field in invalid in the XID
+	 * partition mode.
+	 */
+	uint32_t	dma_bufr_size_bytes;
+	/* Key Context type. */
+	uint8_t	key_ctx_type;
+	/* KTLS Tx Key Context type. */
+	#define HWRM_FUNC_KEY_CTX_ALLOC_INPUT_KEY_CTX_TYPE_TX	UINT32_C(0x0)
+	/* KTLS Rx Key Context type. */
+	#define HWRM_FUNC_KEY_CTX_ALLOC_INPUT_KEY_CTX_TYPE_RX	UINT32_C(0x1)
+	/* QUIC Tx Key Context type. */
+	#define HWRM_FUNC_KEY_CTX_ALLOC_INPUT_KEY_CTX_TYPE_QUIC_TX UINT32_C(0x2)
+	/* QUIC Rx Key Context type. */
+	#define HWRM_FUNC_KEY_CTX_ALLOC_INPUT_KEY_CTX_TYPE_QUIC_RX UINT32_C(0x3)
+	#define HWRM_FUNC_KEY_CTX_ALLOC_INPUT_KEY_CTX_TYPE_LAST   HWRM_FUNC_KEY_CTX_ALLOC_INPUT_KEY_CTX_TYPE_QUIC_RX
+	uint8_t	unused_0[7];
+	/*
+	 * Host DMA address to send back KTLS context IDs. This field is
+	 * invalid in the XID partition mode.
+	 */
+	uint64_t	host_dma_addr;
+	/*
+	 * This field is only used by the PF driver that manages the XID
+	 * partitions. This field specifies the starting XID of one or
+	 * more contiguous XID partitions allocated by the PF driver.
+	 * This field is not used by the VF driver.
+	 * If the call is successful, this starting XID value will be
+	 * returned in the partition_start_xid field of the response.
+	 */
+	uint32_t	partition_start_xid;
+	uint8_t	unused_1[4];
+} hwrm_func_key_ctx_alloc_input_t, *phwrm_func_key_ctx_alloc_input_t;
+
+/* hwrm_func_key_ctx_alloc_output (size:192b/24B) */
+
+typedef struct hwrm_func_key_ctx_alloc_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Number of Key Contexts that have been allocated. */
+	uint16_t	num_key_ctxs_allocated;
+	/* Control flags. */
+	uint8_t	flags;
+	/*
+	 * When set, it indicates that all key contexts allocated by this
+	 * command are contiguous. As a result, the driver has to read the
+	 * start context ID from the first entry of the DMA data buffer
+	 * and figures out the end context ID by 'start context ID +
+	 * num_key_ctxs_allocated - 1'. In XID partition mode,
+	 * this bit should always be set.
+	 */
+	#define HWRM_FUNC_KEY_CTX_ALLOC_OUTPUT_FLAGS_KEY_CTXS_CONTIGUOUS	UINT32_C(0x1)
+	uint8_t	unused_0;
+	/*
+	 * This field is only valid in the XID partition mode. It indicates
+	 * the starting XID that has been allocated.
+	 */
+	uint32_t	partition_start_xid;
+	uint8_t	unused_1[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_key_ctx_alloc_output_t, *phwrm_func_key_ctx_alloc_output_t;
+
+/**************************
+ * hwrm_func_key_ctx_free *
+ **************************/
+
+
+/* hwrm_func_key_ctx_free_input (size:256b/32B) */
+
+typedef struct hwrm_func_key_ctx_free_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Function ID. */
+	uint16_t	fid;
+	/* Key Context type. */
+	uint8_t	key_ctx_type;
+	/* KTLS Tx Key Context type. */
+	#define HWRM_FUNC_KEY_CTX_FREE_INPUT_KEY_CTX_TYPE_TX	UINT32_C(0x0)
+	/* KTLS Rx Key Context type. */
+	#define HWRM_FUNC_KEY_CTX_FREE_INPUT_KEY_CTX_TYPE_RX	UINT32_C(0x1)
+	/* QUIC Tx Key Context type. */
+	#define HWRM_FUNC_KEY_CTX_FREE_INPUT_KEY_CTX_TYPE_QUIC_TX UINT32_C(0x2)
+	/* QUIC Rx Key Context type. */
+	#define HWRM_FUNC_KEY_CTX_FREE_INPUT_KEY_CTX_TYPE_QUIC_RX UINT32_C(0x3)
+	#define HWRM_FUNC_KEY_CTX_FREE_INPUT_KEY_CTX_TYPE_LAST   HWRM_FUNC_KEY_CTX_FREE_INPUT_KEY_CTX_TYPE_QUIC_RX
+	uint8_t	unused_0;
+	/* Starting XID of the partition that needs to be freed. */
+	uint32_t	partition_start_xid;
+	/*
+	 * Number of entries to be freed.
+	 * When running in the XID partition mode, this field is only
+	 * used by the PF driver that manages the XID partitions.
+	 * The PF driver specifies the number of XIDs to be freed and
+	 * this number is always equal to the number of XIDs previously
+	 * allocated successfully using HWRM_FUNC_KEY_CTX_ALLOC.
+	 * This field is not used by the VF driver.
+	 */
+	uint16_t	num_entries;
+	uint8_t	unused_1[6];
+} hwrm_func_key_ctx_free_input_t, *phwrm_func_key_ctx_free_input_t;
+
+/* hwrm_func_key_ctx_free_output (size:128b/16B) */
+
+typedef struct hwrm_func_key_ctx_free_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	rsvd0[7];
+	/*
+	 * This field is used in Output records to indicate that the
+	 * output is completely written to RAM. This field should be
+	 * read as '1' to indicate that the output has been completely
+	 * written. When writing a command completion or response to
+	 * an internal processor, the order of writes has to be such
+	 * that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_key_ctx_free_output_t, *phwrm_func_key_ctx_free_output_t;
+
+/**********************************
+ * hwrm_func_backing_store_cfg_v2 *
+ **********************************/
+
+
+/* hwrm_func_backing_store_cfg_v2_input (size:448b/56B) */
+
+typedef struct hwrm_func_backing_store_cfg_v2_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Type of backing store to be configured. */
+	uint16_t	type;
+	/* Queue pair. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_QP		UINT32_C(0x0)
+	/* Shared receive queue. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_SRQ		UINT32_C(0x1)
+	/* Completion queue. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_CQ		UINT32_C(0x2)
+	/* Virtual NIC. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_VNIC		UINT32_C(0x3)
+	/* Statistic context. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_STAT		UINT32_C(0x4)
+	/* Slow-path TQM ring. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_SP_TQM_RING	UINT32_C(0x5)
+	/* Fast-path TQM ring. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_FP_TQM_RING	UINT32_C(0x6)
+	/* Memory Region and Memory Address Vector Context. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_MRAV		UINT32_C(0xe)
+	/* TIM. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_TIM		UINT32_C(0xf)
+	/* Tx crypto key. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_TX_CK	UINT32_C(0x13)
+	/* Rx crypto key. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_RX_CK	UINT32_C(0x14)
+	/* Mid-path TQM ring. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_MP_TQM_RING	UINT32_C(0x15)
+	/* SQ Doorbell shadow region. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_SQ_DB_SHADOW	UINT32_C(0x16)
+	/* RQ Doorbell shadow region. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_RQ_DB_SHADOW	UINT32_C(0x17)
+	/* SRQ Doorbell shadow region. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_SRQ_DB_SHADOW   UINT32_C(0x18)
+	/* CQ Doorbell shadow region. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_CQ_DB_SHADOW	UINT32_C(0x19)
+	/* CFA table scope context. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_TBL_SCOPE	UINT32_C(0x1c)
+	/* XID partition context. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_XID_PARTITION   UINT32_C(0x1d)
+	/* SRT trace. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_SRT_TRACE	UINT32_C(0x1e)
+	/* SRT2 trace. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_SRT2_TRACE	UINT32_C(0x1f)
+	/* CRT trace. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_CRT_TRACE	UINT32_C(0x20)
+	/* CRT2 trace. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_CRT2_TRACE	UINT32_C(0x21)
+	/* RIGP0 trace. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_RIGP0_TRACE	UINT32_C(0x22)
+	/* L2 HWRM trace. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_L2_HWRM_TRACE   UINT32_C(0x23)
+	/* RoCE HWRM trace. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_ROCE_HWRM_TRACE UINT32_C(0x24)
+	/* Invalid type. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_INVALID	UINT32_C(0xffff)
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_LAST	HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_TYPE_INVALID
+	/*
+	 * Instance of the backing store type. It is zero-based,
+	 * which means "0" indicates the first instance. For backing
+	 * stores with single instance only, leave this field to 0.
+	 * 1. If the backing store type is MPC TQM ring, use the following
+	 *	instance value to map to MPC clients:
+	 *	TCE (0), RCE (1), TE_CFA(2), RE_CFA (3), PRIMATE(4)
+	 * 2. If the backing store type is TBL_SCOPE, use the following
+	 *	instance value to map to table scope regions:
+	 *	RE_CFA_LKUP (0), RE_CFA_ACT (1), TE_CFA_LKUP(2), TE_CFA_ACT (3)
+	 * 3. If the backing store type is XID partition, use the following
+	 *	instance value to map to context types:
+	 *	TX_CK (0), RX_CK (1)
+	 */
+	uint16_t	instance;
+	/* Control flags. */
+	uint32_t	flags;
+	/*
+	 * When set, the firmware only uses on-chip resources and
+	 * does not expect any backing store to be provided by the
+	 * host driver. This mode provides minimal L2 functionality
+	 * (e.g. limited L2 resources, no RoCE).
+	 */
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_FLAGS_PREBOOT_MODE	UINT32_C(0x1)
+	/*
+	 * When set, the driver indicates that the backing store type
+	 * to be configured in this command is the last one to do for
+	 * the associated PF. That means all backing store type
+	 * configurations are done for the corresponding PF after this
+	 * command. As a result, the firmware has to do the necessary
+	 * post configurations.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_FLAGS_BS_CFG_ALL_DONE	UINT32_C(0x2)
+	/*
+	 * When set, the driver indicates extending the size of the specific
+	 * backing store type instead of configuring the corresponding PBLs.
+	 * The size specified in the command will be the new size to be
+	 * configured. The operation is only valid when the specific backing
+	 * store has been configured before. Otherwise, the firmware will
+	 * return an error. The driver needs to zero out the 'entry_size',
+	 * 'flags', 'page_dir', and 'page_size_pbl_level' fields, and the
+	 * firmware will ignore these inputs. Further, the firmware expects
+	 * the 'num_entries' and any valid split entries to be no less than
+	 * the initial value that has been configured. If not, it will
+	 * return an error code.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_FLAGS_BS_EXTEND	UINT32_C(0x4)
+	/* Page directory. */
+	uint64_t	page_dir;
+	/* Number of entries */
+	uint32_t	num_entries;
+	/* Number of bytes allocated for each entry */
+	uint16_t	entry_size;
+	/* Page size and pbl level. */
+	uint8_t	page_size_pbl_level;
+	/* PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_PBL_LEVEL_MASK  UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_PBL_LEVEL_SFT   0
 	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_STAT_LVL_LVL_0	UINT32_C(0x0)
+		#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_PBL_LEVEL_LVL_0   UINT32_C(0x0)
 	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_STAT_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_STAT_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_STAT_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_STAT_LVL_LVL_2
-	/* Stat page size. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_STAT_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_STAT_PG_SIZE_SFT   4
+		#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_PBL_LEVEL_LVL_1   UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to
+	 * PTE tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_PBL_LEVEL_LVL_2   UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_PBL_LEVEL_LAST   HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_PBL_LEVEL_LVL_2
+	/* Page size. */
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_PAGE_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_PAGE_SIZE_SFT   4
 	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_STAT_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+		#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_PAGE_SIZE_PG_4K   (UINT32_C(0x0) << 4)
 	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_STAT_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+		#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_PAGE_SIZE_PG_8K   (UINT32_C(0x1) << 4)
 	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_STAT_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+		#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_PAGE_SIZE_PG_64K  (UINT32_C(0x2) << 4)
 	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_STAT_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+		#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_PAGE_SIZE_PG_2M   (UINT32_C(0x3) << 4)
 	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_STAT_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+		#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_PAGE_SIZE_PG_8M   (UINT32_C(0x4) << 4)
 	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_STAT_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_STAT_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_STAT_PG_SIZE_PG_1G
-	/* TQM slow path page size and level. */
-	uint8_t	tqm_sp_pg_size_tqm_sp_lvl;
-	/* TQM slow path PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_SP_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_SP_LVL_SFT	0
+		#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_PAGE_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_PAGE_SIZE_LAST   HWRM_FUNC_BACKING_STORE_CFG_V2_INPUT_PAGE_SIZE_PG_1G
+	/*
+	 * This field counts how many split entries contain valid data.
+	 * Below is the table that maps the count value:
+	 * | Count |			Indication			|
+	 * | ----- | -------------------------------------------------- |
+	 * |   0   | None of the split entries has valid data.	|
+	 * |   1   | Only "split_entry_0" contains valid data.	|
+	 * |   2   | Only "split_entry_0" and "1" have valid data.	|
+	 * |   3   | Only "split_entry_0", "1" and "2" have valid data. |
+	 * |   4   | All four split entries have valid data.		|
+	 */
+	uint8_t	subtype_valid_cnt;
+	/*
+	 * Split entry #0. Note that the four split entries (as a group)
+	 * must be cast to a type-specific data structure first before
+	 * accessing it! Below is the table that maps a backing store
+	 * type to the associated split entry casting data structure.
+	 * | Type |	Split Entry Casting Data Structure	|
+	 * | ---- | -------------------------------------------------- |
+	 * | QPC  |		qpc_split_entries			|
+	 * | SRQ  |		srq_split_entries			|
+	 * | CQ   |		cq_split_entries			|
+	 * | VINC |		vnic_split_entries			|
+	 * | MRAV |		mrav_split_entries			|
+	 * | TS   |		ts_split_entries			|
+	 * | CK   |		ck_split_entries			|
+	 */
+	uint32_t	split_entry_0;
+	/* Split entry #1. */
+	uint32_t	split_entry_1;
+	/* Split entry #2. */
+	uint32_t	split_entry_2;
+	/* Split entry #3. */
+	uint32_t	split_entry_3;
+} hwrm_func_backing_store_cfg_v2_input_t, *phwrm_func_backing_store_cfg_v2_input_t;
+
+/* hwrm_func_backing_store_cfg_v2_output (size:128b/16B) */
+
+typedef struct hwrm_func_backing_store_cfg_v2_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	rsvd0[7];
+	/*
+	 * This field is used in Output records to indicate that the
+	 * output is completely written to RAM. This field should be
+	 * read as '1' to indicate that the output has been completely
+	 * written. When writing a command completion or response to
+	 * an internal processor, the order of writes has to be such
+	 * that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_backing_store_cfg_v2_output_t, *phwrm_func_backing_store_cfg_v2_output_t;
+
+/***********************************
+ * hwrm_func_backing_store_qcfg_v2 *
+ ***********************************/
+
+
+/* hwrm_func_backing_store_qcfg_v2_input (size:192b/24B) */
+
+typedef struct hwrm_func_backing_store_qcfg_v2_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Type of backing store to be configured. */
+	uint16_t	type;
+	/* Queue pair. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_INPUT_TYPE_QP		UINT32_C(0x0)
+	/* Shared receive queue. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_INPUT_TYPE_SRQ		UINT32_C(0x1)
+	/* Completion queue. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_INPUT_TYPE_CQ		UINT32_C(0x2)
+	/* Virtual NIC. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_INPUT_TYPE_VNIC		UINT32_C(0x3)
+	/* Statistic context. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_INPUT_TYPE_STAT		UINT32_C(0x4)
+	/* Slow-path TQM ring. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_INPUT_TYPE_SP_TQM_RING	UINT32_C(0x5)
+	/* Fast-path TQM ring. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_INPUT_TYPE_FP_TQM_RING	UINT32_C(0x6)
+	/* Memory Region and Memory Address Vector Context. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_INPUT_TYPE_MRAV		UINT32_C(0xe)
+	/* TIM. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_INPUT_TYPE_TIM		UINT32_C(0xf)
+	/* Tx crypto key. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_INPUT_TYPE_TX_CK		UINT32_C(0x13)
+	/* Rx crypto key. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_INPUT_TYPE_RX_CK		UINT32_C(0x14)
+	/* Mid-path TQM ring. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_INPUT_TYPE_MP_TQM_RING	UINT32_C(0x15)
+	/* SQ Doorbell shadow region. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_INPUT_TYPE_SQ_DB_SHADOW	UINT32_C(0x16)
+	/* RQ Doorbell shadow region. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_INPUT_TYPE_RQ_DB_SHADOW	UINT32_C(0x17)
+	/* SRQ Doorbell shadow region. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_INPUT_TYPE_SRQ_DB_SHADOW	UINT32_C(0x18)
+	/* CQ Doorbell shadow region. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_INPUT_TYPE_CQ_DB_SHADOW	UINT32_C(0x19)
+	/* CFA table scope context. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_INPUT_TYPE_TBL_SCOPE	UINT32_C(0x1c)
+	/* VF XID partition in-use table. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_INPUT_TYPE_XID_PARTITION_TABLE UINT32_C(0x1d)
+	/* SRT trace. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_INPUT_TYPE_SRT_TRACE	UINT32_C(0x1e)
+	/* SRT2 trace. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_INPUT_TYPE_SRT2_TRACE	UINT32_C(0x1f)
+	/* CRT trace. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_INPUT_TYPE_CRT_TRACE	UINT32_C(0x20)
+	/* CRT2 trace. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_INPUT_TYPE_CRT2_TRACE	UINT32_C(0x21)
+	/* RIGP0 trace. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_INPUT_TYPE_RIGP0_TRACE	UINT32_C(0x22)
+	/* L2 HWRM trace. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_INPUT_TYPE_L2_HWRM_TRACE	UINT32_C(0x23)
+	/* RoCE HWRM trace. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_INPUT_TYPE_ROCE_HWRM_TRACE	UINT32_C(0x24)
+	/* Invalid type. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_INPUT_TYPE_INVALID		UINT32_C(0xffff)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_INPUT_TYPE_LAST		HWRM_FUNC_BACKING_STORE_QCFG_V2_INPUT_TYPE_INVALID
+	/*
+	 * Instance of the backing store type. It is zero-based,
+	 * which means "0" indicates the first instance. For backing
+	 * stores with single instance only, leave this field to 0.
+	 * 1. If the backing store type is MPC TQM ring, use the following
+	 *	instance value to map to MPC clients:
+	 *	TCE (0), RCE (1), TE_CFA(2), RE_CFA (3), PRIMATE(4)
+	 * 2. If the backing store type is TBL_SCOPE, use the following
+	 *	instance value to map to table scope regions:
+	 *	RE_CFA_LKUP (0), RE_CFA_ACT (1), TE_CFA_LKUP(2), TE_CFA_ACT (3)
+	 * 3. If the backing store type is XID partition, use the following
+	 *	instance value to map to context types:
+	 *	TX_CK (0), RX_CK (1)
+	 */
+	uint16_t	instance;
+	uint8_t	rsvd[4];
+} hwrm_func_backing_store_qcfg_v2_input_t, *phwrm_func_backing_store_qcfg_v2_input_t;
+
+/* hwrm_func_backing_store_qcfg_v2_output (size:448b/56B) */
+
+typedef struct hwrm_func_backing_store_qcfg_v2_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Type of backing store to be configured. */
+	uint16_t	type;
+	/* Queue pair. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_TYPE_QP		UINT32_C(0x0)
+	/* Shared receive queue. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_TYPE_SRQ		UINT32_C(0x1)
+	/* Completion queue. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_TYPE_CQ		UINT32_C(0x2)
+	/* Virtual NIC. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_TYPE_VNIC		UINT32_C(0x3)
+	/* Statistic context. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_TYPE_STAT		UINT32_C(0x4)
+	/* Slow-path TQM ring. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_TYPE_SP_TQM_RING	UINT32_C(0x5)
+	/* Fast-path TQM ring. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_TYPE_FP_TQM_RING	UINT32_C(0x6)
+	/* Memory Region and Memory Address Vector Context. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_TYPE_MRAV		UINT32_C(0xe)
+	/* TIM. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_TYPE_TIM		UINT32_C(0xf)
+	/* Tx crypto key. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_TYPE_TX_CK	UINT32_C(0x13)
+	/* Rx crypto key. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_TYPE_RX_CK	UINT32_C(0x14)
+	/* Mid-path TQM ring. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_TYPE_MP_TQM_RING	UINT32_C(0x15)
+	/* CFA table scope context. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_TYPE_TBL_SCOPE	UINT32_C(0x1c)
+	/* XID partition context. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_TYPE_XID_PARTITION   UINT32_C(0x1d)
+	/* SRT trace. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_TYPE_SRT_TRACE	UINT32_C(0x1e)
+	/* SRT2 trace. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_TYPE_SRT2_TRACE	UINT32_C(0x1f)
+	/* CRT trace. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_TYPE_CRT_TRACE	UINT32_C(0x20)
+	/* CRT2 trace. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_TYPE_CRT2_TRACE	UINT32_C(0x21)
+	/* RIGP0 trace. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_TYPE_RIGP0_TRACE	UINT32_C(0x22)
+	/* L2 HWRM trace. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_TYPE_L2_HWRM_TRACE   UINT32_C(0x23)
+	/* RoCE HWRM trace. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_TYPE_ROCE_HWRM_TRACE UINT32_C(0x24)
+	/* Invalid type. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_TYPE_INVALID	UINT32_C(0xffff)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_TYPE_LAST	HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_TYPE_INVALID
+	/*
+	 * Instance of the backing store type. It is zero-based,
+	 * which means "0" indicates the first instance. For backing
+	 * stores with single instance only, leave this field to 0.
+	 * 1. If the backing store type is MPC TQM ring, use the following
+	 *	instance value to map to MPC clients:
+	 *	TCE (0), RCE (1), TE_CFA(2), RE_CFA (3), PRIMATE(4)
+	 * 2. If the backing store type is TBL_SCOPE, use the following
+	 *	instance value to map to table scope regions:
+	 *	RE_CFA_LKUP (0), RE_CFA_ACT (1), TE_CFA_LKUP(2), TE_CFA_ACT (3)
+	 * 3. If the backing store type is XID partition, use the following
+	 *	instance value to map to context types:
+	 *	TX_CK (0), RX_CK (1)
+	 */
+	uint16_t	instance;
+	/* Control flags. */
+	uint32_t	flags;
+	/* Page directory. */
+	uint64_t	page_dir;
+	/* Number of entries */
+	uint32_t	num_entries;
+	/* Page size and pbl level. */
+	uint8_t	page_size_pbl_level;
+	/* PBL indirect levels. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_PBL_LEVEL_MASK  UINT32_C(0xf)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_PBL_LEVEL_SFT   0
 	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_SP_LVL_LVL_0	UINT32_C(0x0)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_PBL_LEVEL_LVL_0   UINT32_C(0x0)
 	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_SP_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_SP_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_SP_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_SP_LVL_LVL_2
-	/* TQM slow path page size. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_SP_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_SP_PG_SIZE_SFT   4
+		#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_PBL_LEVEL_LVL_1   UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to
+	 * PTE tables.
+	 */
+		#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_PBL_LEVEL_LVL_2   UINT32_C(0x2)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_PBL_LEVEL_LAST   HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_PBL_LEVEL_LVL_2
+	/* Page size. */
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_PAGE_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_PAGE_SIZE_SFT   4
 	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_SP_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_PAGE_SIZE_PG_4K   (UINT32_C(0x0) << 4)
 	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_SP_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_PAGE_SIZE_PG_8K   (UINT32_C(0x1) << 4)
 	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_SP_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_PAGE_SIZE_PG_64K  (UINT32_C(0x2) << 4)
 	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_SP_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_PAGE_SIZE_PG_2M   (UINT32_C(0x3) << 4)
 	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_SP_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_PAGE_SIZE_PG_8M   (UINT32_C(0x4) << 4)
 	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_SP_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_SP_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_SP_PG_SIZE_PG_1G
+		#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_PAGE_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_PAGE_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_V2_OUTPUT_PAGE_SIZE_PG_1G
+	/*
+	 * This field counts how many split entries contain valid data.
+	 * Below is the table that maps the count value:
+	 * | count |			Indication			|
+	 * | ----- | -------------------------------------------------- |
+	 * |   0   | None of the split entries has valid data.	|
+	 * |   1   | Only "split_entry_0" contains valid data.	|
+	 * |   2   | Only "split_entry_0" and "1" have valid data.	|
+	 * |   3   | Only "split_entry_0", "1" and "2" have valid data. |
+	 * |   4   | All four split entries have valid data.		|
+	 */
+	uint8_t	subtype_valid_cnt;
+	uint8_t	rsvd[2];
+	/*
+	 * Split entry #0. Note that the four split entries (as a group)
+	 * must be cast to a type-specific data structure first before
+	 * accessing it! Below is the table that maps a backing store
+	 * type to the associated split entry casting data structure.
+	 * | Type |	Split Entry Casting Data Structure	|
+	 * | ---- | -------------------------------------------------- |
+	 * | QPC  |		qpc_split_entries			|
+	 * | SRQ  |		srq_split_entries			|
+	 * | CQ   |		cq_split_entries			|
+	 * | VINC |		vnic_split_entries			|
+	 * | MRAV |		mrav_split_entries			|
+	 * | TS   |		ts_split_entries			|
+	 * | CK   |		ck_split_entries			|
+	 */
+	uint32_t	split_entry_0;
+	/* Split entry #1. */
+	uint32_t	split_entry_1;
+	/* Split entry #2. */
+	uint32_t	split_entry_2;
+	/* Split entry #3. */
+	uint32_t	split_entry_3;
+	uint8_t	rsvd2[7];
+	/*
+	 * This field is used in Output records to indicate that the
+	 * output is completely written to RAM. This field should be
+	 * read as '1' to indicate that the output has been completely
+	 * written. When writing a command completion or response to
+	 * an internal processor, the order of writes has to be such
+	 * that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_backing_store_qcfg_v2_output_t, *phwrm_func_backing_store_qcfg_v2_output_t;
+
+/* Common structure to cast QPC split entries. This casting is required in the following HWRM command inputs/outputs if the backing store type is QPC. 1. hwrm_func_backing_store_cfg_v2_input 2. hwrm_func_backing_store_qcfg_v2_output 3. hwrm_func_backing_store_qcaps_v2_output */
+/* qpc_split_entries (size:128b/16B) */
+
+typedef struct qpc_split_entries {
+	/* Number of L2 QP backing store entries. */
+	uint32_t	qp_num_l2_entries;
+	/* Number of QP1 entries. */
+	uint32_t	qp_num_qp1_entries;
+	/*
+	 * Number of RoCE QP context entries required for this
+	 * function to support fast QP modify destroy feature.
+	 */
+	uint32_t	qp_num_fast_qpmd_entries;
+	uint32_t	rsvd;
+} qpc_split_entries_t, *pqpc_split_entries_t;
+
+/* Common structure to cast SRQ split entries. This casting is required in the following HWRM command inputs/outputs if the backing store type is SRQ. 1. hwrm_func_backing_store_cfg_v2_input 2. hwrm_func_backing_store_qcfg_v2_output 3. hwrm_func_backing_store_qcaps_v2_output */
+/* srq_split_entries (size:128b/16B) */
+
+typedef struct srq_split_entries {
+	/* Number of L2 SRQ backing store entries. */
+	uint32_t	srq_num_l2_entries;
+	uint32_t	rsvd;
+	uint64_t	rsvd2;
+} srq_split_entries_t, *psrq_split_entries_t;
+
+/* Common structure to cast CQ split entries. This casting is required in the following HWRM command inputs/outputs if the backing store type is CQ. 1. hwrm_func_backing_store_cfg_v2_input 2. hwrm_func_backing_store_qcfg_v2_output 3. hwrm_func_backing_store_qcaps_v2_output */
+/* cq_split_entries (size:128b/16B) */
+
+typedef struct cq_split_entries {
+	/* Number of L2 CQ backing store entries. */
+	uint32_t	cq_num_l2_entries;
+	uint32_t	rsvd;
+	uint64_t	rsvd2;
+} cq_split_entries_t, *pcq_split_entries_t;
+
+/* Common structure to cast VNIC split entries. This casting is required in the following HWRM command inputs/outputs if the backing store type is VNIC. 1. hwrm_func_backing_store_cfg_v2_input 2. hwrm_func_backing_store_qcfg_v2_output 3. hwrm_func_backing_store_qcaps_v2_output */
+/* vnic_split_entries (size:128b/16B) */
+
+typedef struct vnic_split_entries {
+	/* Number of VNIC backing store entries. */
+	uint32_t	vnic_num_vnic_entries;
+	uint32_t	rsvd;
+	uint64_t	rsvd2;
+} vnic_split_entries_t, *pvnic_split_entries_t;
+
+/* Common structure to cast MRAV split entries. This casting is required in the following HWRM command inputs/outputs if the backing store type is MRAV. 1. hwrm_func_backing_store_cfg_v2_input 2. hwrm_func_backing_store_qcfg_v2_output 3. hwrm_func_backing_store_qcaps_v2_output */
+/* mrav_split_entries (size:128b/16B) */
+
+typedef struct mrav_split_entries {
+	/* Number of AV backing store entries. */
+	uint32_t	mrav_num_av_entries;
+	uint32_t	rsvd;
+	uint64_t	rsvd2;
+} mrav_split_entries_t, *pmrav_split_entries_t;
+
+/* Common structure to cast TBL_SCOPE split entries. This casting is required in the following HWRM command inputs/outputs if the backing store type is TBL_SCOPE. 1. hwrm_func_backing_store_cfg_v2_input 2. hwrm_func_backing_store_qcfg_v2_output 3. hwrm_func_backing_store_qcaps_v2_output */
+/* ts_split_entries (size:128b/16B) */
+
+typedef struct ts_split_entries {
+	/* Max number of TBL_SCOPE region entries (QCAPS). */
+	uint32_t	region_num_entries;
+	/* tsid to configure (CFG). */
+	uint8_t	tsid;
+	/*
+	 * Lkup static bucket count (power of 2).
+	 * Array is indexed by enum cfa_dir
+	 */
+	uint8_t	lkup_static_bkt_cnt_exp[2];
+	uint8_t	rsvd;
+	uint64_t	rsvd2;
+} ts_split_entries_t, *pts_split_entries_t;
+
+/* Common structure to cast crypto key split entries. This casting is required in the following HWRM command inputs/outputs if the backing store type is TX_CK or RX_CK. 1. hwrm_func_backing_store_cfg_v2_input 2. hwrm_func_backing_store_qcfg_v2_output 3. hwrm_func_backing_store_qcaps_v2_output */
+/* ck_split_entries (size:128b/16B) */
+
+typedef struct ck_split_entries {
+	/*
+	 * Number of QUIC backing store entries. That means the number of KTLS
+	 * backing store entries is the difference between this number and the
+	 * total number of crypto key entries.
+	 */
+	uint32_t	num_quic_entries;
+	uint32_t	rsvd;
+	uint64_t	rsvd2;
+} ck_split_entries_t, *pck_split_entries_t;
+
+/************************************
+ * hwrm_func_backing_store_qcaps_v2 *
+ ************************************/
+
+
+/* hwrm_func_backing_store_qcaps_v2_input (size:192b/24B) */
+
+typedef struct hwrm_func_backing_store_qcaps_v2_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Type of backing store to be queried. */
+	uint16_t	type;
+	/* Queue pair. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_INPUT_TYPE_QP		UINT32_C(0x0)
+	/* Shared receive queue. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_INPUT_TYPE_SRQ		UINT32_C(0x1)
+	/* Completion queue. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_INPUT_TYPE_CQ		UINT32_C(0x2)
+	/* Virtual NIC. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_INPUT_TYPE_VNIC		UINT32_C(0x3)
+	/* Statistic context. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_INPUT_TYPE_STAT		UINT32_C(0x4)
+	/* Slow-path TQM ring. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_INPUT_TYPE_SP_TQM_RING	UINT32_C(0x5)
+	/* Fast-path TQM ring. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_INPUT_TYPE_FP_TQM_RING	UINT32_C(0x6)
+	/* Memory Region and Memory Address Vector Context. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_INPUT_TYPE_MRAV		UINT32_C(0xe)
+	/* TIM. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_INPUT_TYPE_TIM		UINT32_C(0xf)
+	/* Tx crypto key. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_INPUT_TYPE_TX_CK	UINT32_C(0x13)
+	/* Rx crypto key. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_INPUT_TYPE_RX_CK	UINT32_C(0x14)
+	/* Mid-path TQM ring. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_INPUT_TYPE_MP_TQM_RING	UINT32_C(0x15)
+	/* SQ Doorbell shadow region. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_INPUT_TYPE_SQ_DB_SHADOW	UINT32_C(0x16)
+	/* RQ Doorbell shadow region. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_INPUT_TYPE_RQ_DB_SHADOW	UINT32_C(0x17)
+	/* SRQ Doorbell shadow region. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_INPUT_TYPE_SRQ_DB_SHADOW   UINT32_C(0x18)
+	/* CQ Doorbell shadow region. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_INPUT_TYPE_CQ_DB_SHADOW	UINT32_C(0x19)
+	/* CFA table scope context. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_INPUT_TYPE_TBL_SCOPE	UINT32_C(0x1c)
+	/* XID partition context. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_INPUT_TYPE_XID_PARTITION   UINT32_C(0x1d)
+	/* SRT trace. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_INPUT_TYPE_SRT_TRACE	UINT32_C(0x1e)
+	/* SRT2 trace. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_INPUT_TYPE_SRT2_TRACE	UINT32_C(0x1f)
+	/* CRT trace. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_INPUT_TYPE_CRT_TRACE	UINT32_C(0x20)
+	/* CRT2 trace. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_INPUT_TYPE_CRT2_TRACE	UINT32_C(0x21)
+	/* RIGP0 trace. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_INPUT_TYPE_RIGP0_TRACE	UINT32_C(0x22)
+	/* L2 HWRM trace. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_INPUT_TYPE_L2_HWRM_TRACE   UINT32_C(0x23)
+	/* RoCE HWRM trace. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_INPUT_TYPE_ROCE_HWRM_TRACE UINT32_C(0x24)
+	/* Invalid type. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_INPUT_TYPE_INVALID	UINT32_C(0xffff)
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_INPUT_TYPE_LAST	HWRM_FUNC_BACKING_STORE_QCAPS_V2_INPUT_TYPE_INVALID
+	uint8_t	rsvd[6];
+} hwrm_func_backing_store_qcaps_v2_input_t, *phwrm_func_backing_store_qcaps_v2_input_t;
+
+/* hwrm_func_backing_store_qcaps_v2_output (size:448b/56B) */
+
+typedef struct hwrm_func_backing_store_qcaps_v2_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Type of backing store to be queried. */
+	uint16_t	type;
+	/* Queue pair. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_TYPE_QP		UINT32_C(0x0)
+	/* Shared receive queue. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_TYPE_SRQ		UINT32_C(0x1)
+	/* Completion queue. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_TYPE_CQ		UINT32_C(0x2)
+	/* Virtual NIC. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_TYPE_VNIC		UINT32_C(0x3)
+	/* Statistic context. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_TYPE_STAT		UINT32_C(0x4)
+	/* Slow-path TQM ring. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_TYPE_SP_TQM_RING	UINT32_C(0x5)
+	/* Fast-path TQM ring. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_TYPE_FP_TQM_RING	UINT32_C(0x6)
+	/* Memory Region and Memory Address Vector Context. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_TYPE_MRAV		UINT32_C(0xe)
+	/* TIM. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_TYPE_TIM		UINT32_C(0xf)
+	/* Tx crypto key. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_TYPE_TX_CK	UINT32_C(0x13)
+	/* Rx crypto key. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_TYPE_RX_CK	UINT32_C(0x14)
+	/* Mid-path TQM ring. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_TYPE_MP_TQM_RING	UINT32_C(0x15)
+	/* SQ Doorbell shadow region. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_TYPE_SQ_DB_SHADOW	UINT32_C(0x16)
+	/* RQ Doorbell shadow region. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_TYPE_RQ_DB_SHADOW	UINT32_C(0x17)
+	/* SRQ Doorbell shadow region. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_TYPE_SRQ_DB_SHADOW   UINT32_C(0x18)
+	/* CQ Doorbell shadow region. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_TYPE_CQ_DB_SHADOW	UINT32_C(0x19)
+	/* CFA table scope context. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_TYPE_TBL_SCOPE	UINT32_C(0x1c)
+	/* XID partition context. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_TYPE_XID_PARTITION   UINT32_C(0x1d)
+	/* SRT trace. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_TYPE_SRT_TRACE	UINT32_C(0x1e)
+	/* SRT2 trace. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_TYPE_SRT2_TRACE	UINT32_C(0x1f)
+	/* CRT trace. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_TYPE_CRT_TRACE	UINT32_C(0x20)
+	/* CRT2 trace. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_TYPE_CRT2_TRACE	UINT32_C(0x21)
+	/* RIGP0 trace. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_TYPE_RIGP0_TRACE	UINT32_C(0x22)
+	/* L2 HWRM trace. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_TYPE_L2_HWRM_TRACE   UINT32_C(0x23)
+	/* RoCE HWRM trace. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_TYPE_ROCE_HWRM_TRACE UINT32_C(0x24)
+	/* Invalid type. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_TYPE_INVALID	UINT32_C(0xffff)
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_TYPE_LAST	HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_TYPE_INVALID
+	/* Number of bytes per backing store entry. */
+	uint16_t	entry_size;
+	/* Control flags. */
+	uint32_t	flags;
+	/*
+	 * When set, it indicates the context type should be initialized
+	 * with the 'ctx_init_value' at the specified offset.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_FLAGS_ENABLE_CTX_KIND_INIT		UINT32_C(0x1)
+	/* When set, it indicates the context type is valid. */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_FLAGS_TYPE_VALID			UINT32_C(0x2)
+	/*
+	 * When set, it indicates the region for this type is not a regular
+	 * context memory but a driver managed memory that is created,
+	 * initialized and managed by the driver.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_FLAGS_DRIVER_MANAGED_MEMORY	UINT32_C(0x4)
+	/*
+	 * When set, it indicates the support of the following capability
+	 * that is specific to the QP type:
+	 * - For 2-port adapters, the ability to extend the RoCE QP
+	 *   entries configured on a PF, during some network events such as
+	 *   Link Down. These additional entries count is included in the
+	 *   advertised 'max_num_entries'.
+	 * - The count of RoCE QP entries, derived from 'max_num_entries'
+	 *   (max_num_entries - qp_num_qp1_entries - qp_num_l2_entries -
+	 *   qp_num_fast_qpmd_entries, note qp_num_fast_qpmd_entries is
+	 *   always zero when QPs are pseudo-statically allocated), includes
+	 *   the count of QPs that can be migrated from the other PF (e.g.,
+	 *   during network link down). Therefore, during normal operation
+	 *   when both PFs are active, the supported number of RoCE QPs for
+	 *   each of the PF is half of the advertised value.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_FLAGS_ROCE_QP_PSEUDO_STATIC_ALLOC	UINT32_C(0x8)
+	/*
+	 * Bit map of the valid instances associated with the
+	 * backing store type.
+	 * 1. If the backing store type is MPC TQM ring, use the following
+	 *	bits to map to MPC clients:
+	 *	TCE (0), RCE (1), TE_CFA(2), RE_CFA (3), PRIMATE(4)
+	 * 2. If the backing store type is TBL_SCOPE, use the following
+	 *	bits to map to table scope regions:
+	 *	RE_CFA_LKUP (0), RE_CFA_ACT (1), TE_CFA_LKUP(2), TE_CFA_ACT (3)
+	 * 3. If the backing store type is VF XID partition in-use table, use
+	 *	the following bits to map to context types:
+	 *	TX_CK (0), RX_CK (1)
+	 */
+	uint32_t	instance_bit_map;
+	/*
+	 * Initializer to be used by drivers to initialize context memory
+	 * to ensure context subsystem flags an error for an attack before
+	 * the first time context load.
+	 */
+	uint8_t	ctx_init_value;
+	/*
+	 * Specifies the doubleword offset of ctx_init_value for this
+	 * context type.
+	 */
+	uint8_t	ctx_init_offset;
+	/*
+	 * Some backing store types, e.g., TQM rings, require the number
+	 * of entries to be a multiple of this value to prevent any
+	 * resource allocation limitations. If not applicable, leave
+	 * this field with "0".
+	 */
+	uint8_t	entry_multiple;
+	uint8_t	rsvd;
+	/* Maximum number of backing store entries supported for this type. */
+	uint32_t	max_num_entries;
+	/*
+	 * Minimum number of backing store entries required for this type.
+	 * This field is only valid for some backing store types, e.g.,
+	 * TQM rings. If not applicable, leave this field with "0".
+	 */
+	uint32_t	min_num_entries;
+	/*
+	 * Next valid backing store type. If current type queried is already
+	 * the last valid type, firmware must set this field to invalid type.
+	 */
+	uint16_t	next_valid_type;
+	/*
+	 * This field counts how many split entries contain valid data.
+	 * Below is the table that maps the count value:
+	 * | count |			Indication			|
+	 * | ----- | -------------------------------------------------- |
+	 * |   0   | None of the split entries has valid data.	|
+	 * |   1   | Only "split_entry_0" contains valid data.	|
+	 * |   2   | Only "split_entry_0" and "1" have valid data.	|
+	 * |   3   | Only "split_entry_0", "1" and "2" have valid data. |
+	 * |   4   | All four split entries have valid data.		|
+	 */
+	uint8_t	subtype_valid_cnt;
+	/*
+	 * Bitmap that indicates if each of the 'split_entry' denotes an
+	 * exact count (i.e., min = max). When the exact count bit is set,
+	 * it indicates the exact number of entries as advertised has to be
+	 * configured. The 'split_entry' to be set to contain exact count by
+	 * this bitmap needs to be a valid split entry specified by
+	 * 'subtype_valid_cnt'.
+	 */
+	uint8_t	exact_cnt_bit_map;
+	/*
+	 * When this bit is '1', it indicates 'split_entry_0' contains
+	 * an exact count.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_EXACT_CNT_BIT_MAP_SPLIT_ENTRY_0_EXACT	UINT32_C(0x1)
+	/*
+	 * When this bit is '1', it indicates 'split_entry_1' contains
+	 * an exact count.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_EXACT_CNT_BIT_MAP_SPLIT_ENTRY_1_EXACT	UINT32_C(0x2)
+	/*
+	 * When this bit is '1', it indicates 'split_entry_2' contains
+	 * an exact count.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_EXACT_CNT_BIT_MAP_SPLIT_ENTRY_2_EXACT	UINT32_C(0x4)
+	/*
+	 * When this bit is '1', it indicates 'split_entry_3' contains
+	 * an exact count.
+	 */
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_EXACT_CNT_BIT_MAP_SPLIT_ENTRY_3_EXACT	UINT32_C(0x8)
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_EXACT_CNT_BIT_MAP_UNUSED_MASK		UINT32_C(0xf0)
+	#define HWRM_FUNC_BACKING_STORE_QCAPS_V2_OUTPUT_EXACT_CNT_BIT_MAP_UNUSED_SFT		4
+	/*
+	 * Split entry #0. Note that the four split entries (as a group)
+	 * must be cast to a type-specific data structure first before
+	 * accessing it! Below is the table that maps a backing store
+	 * type to the associated split entry casting data structure.
+	 * | Type |	Split Entry Casting Data Structure	|
+	 * | ---- | -------------------------------------------------- |
+	 * | QPC  |		qpc_split_entries			|
+	 * | SRQ  |		srq_split_entries			|
+	 * | CQ   |		cq_split_entries			|
+	 * | VINC |		vnic_split_entries			|
+	 * | MRAV |		mrav_split_entries			|
+	 * | TS   |		ts_split_entries			|
+	 */
+	uint32_t	split_entry_0;
+	/* Split entry #1. */
+	uint32_t	split_entry_1;
+	/* Split entry #2. */
+	uint32_t	split_entry_2;
+	/* Split entry #3. */
+	uint32_t	split_entry_3;
+	uint8_t	rsvd3[3];
+	/*
+	 * This field is used in Output records to indicate that the
+	 * output is completely written to RAM. This field should be
+	 * read as '1' to indicate that the output has been completely
+	 * written. When writing a command completion or response to
+	 * an internal processor, the order of writes has to be such
+	 * that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_backing_store_qcaps_v2_output_t, *phwrm_func_backing_store_qcaps_v2_output_t;
+
+/****************************
+ * hwrm_func_dbr_pacing_cfg *
+ ****************************/
+
+
+/* hwrm_func_dbr_pacing_cfg_input (size:320b/40B) */
+
+typedef struct hwrm_func_dbr_pacing_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint8_t	flags;
+	/*
+	 * This bit must be '1' to enable DBR NQ events. The NQ ID to
+	 * receive the events must be specified in the primary_nq_id
+	 * field.
+	 */
+	#define HWRM_FUNC_DBR_PACING_CFG_INPUT_FLAGS_DBR_NQ_EVENT_ENABLE	UINT32_C(0x1)
+	/* This bit must be '1' to disable DBR NQ events. */
+	#define HWRM_FUNC_DBR_PACING_CFG_INPUT_FLAGS_DBR_NQ_EVENT_DISABLE	UINT32_C(0x2)
+	uint8_t	unused_0[7];
+	uint32_t	enables;
+	/*
+	 * This bit must be '1' for the primary_nq_id field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_DBR_PACING_CFG_INPUT_ENABLES_PRIMARY_NQ_ID_VALID	UINT32_C(0x1)
+	/*
+	 * This bit must be '1' for the pacing_threshold field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_DBR_PACING_CFG_INPUT_ENABLES_PACING_THRESHOLD_VALID	UINT32_C(0x2)
+	/*
+	 * Specify primary function's NQ ID to receive the doorbell pacing
+	 * threshold crossing events.
+	 */
+	uint32_t	primary_nq_id;
+	/*
+	 * Specify pacing threshold value, as a percentage of the max
+	 * doorbell FIFO depth. The range is 1 to 36.
+	 */
+	uint32_t	pacing_threshold;
+	uint8_t	unused_1[4];
+} hwrm_func_dbr_pacing_cfg_input_t, *phwrm_func_dbr_pacing_cfg_input_t;
+
+/* hwrm_func_dbr_pacing_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_func_dbr_pacing_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_dbr_pacing_cfg_output_t, *phwrm_func_dbr_pacing_cfg_output_t;
+
+/*****************************
+ * hwrm_func_dbr_pacing_qcfg *
+ *****************************/
+
+
+/* hwrm_func_dbr_pacing_qcfg_input (size:128b/16B) */
+
+typedef struct hwrm_func_dbr_pacing_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+} hwrm_func_dbr_pacing_qcfg_input_t, *phwrm_func_dbr_pacing_qcfg_input_t;
+
+/* hwrm_func_dbr_pacing_qcfg_output (size:512b/64B) */
+
+typedef struct hwrm_func_dbr_pacing_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	flags;
+	/* When this bit is '1', it indicates DBR NQ events are enabled. */
+	#define HWRM_FUNC_DBR_PACING_QCFG_OUTPUT_FLAGS_DBR_NQ_EVENT_ENABLED	UINT32_C(0x1)
+	uint8_t	unused_0[7];
+	/*
+	 * The Doorbell global FIFO occupancy register. This field should be
+	 * used by the driver and user library in the doorbell pacing
+	 * algorithm. Lower 2 bits indicates address space location and upper
+	 * 30 bits indicates upper 30bits of the register address. A value of
+	 * 0xFFFF-FFFF indicates this register does not exist.
+	 */
+	uint32_t	dbr_stat_db_fifo_reg;
+	/* Lower 2 bits indicates address space location. */
+	#define HWRM_FUNC_DBR_PACING_QCFG_OUTPUT_DBR_STAT_DB_FIFO_REG_ADDR_SPACE_MASK	UINT32_C(0x3)
+	#define HWRM_FUNC_DBR_PACING_QCFG_OUTPUT_DBR_STAT_DB_FIFO_REG_ADDR_SPACE_SFT	0
+	/*
+	 * If value is 0, this register is located in PCIe config space.
+	 * Drivers have to map appropriate window to access this
+	 * register.
+	 */
+		#define HWRM_FUNC_DBR_PACING_QCFG_OUTPUT_DBR_STAT_DB_FIFO_REG_ADDR_SPACE_PCIE_CFG  UINT32_C(0x0)
+	/*
+	 * If value is 1, this register is located in GRC address space.
+	 * Drivers have to map appropriate window to access this
+	 * register.
+	 */
+		#define HWRM_FUNC_DBR_PACING_QCFG_OUTPUT_DBR_STAT_DB_FIFO_REG_ADDR_SPACE_GRC	UINT32_C(0x1)
+	/*
+	 * If value is 2, this register is located in first BAR address
+	 * space. Drivers have to map appropriate window to access this
+	 * register.
+	 */
+		#define HWRM_FUNC_DBR_PACING_QCFG_OUTPUT_DBR_STAT_DB_FIFO_REG_ADDR_SPACE_BAR0	UINT32_C(0x2)
+	/*
+	 * If value is 3, this register is located in second BAR address
+	 * space. Drivers have to map appropriate window to access this
+	 * Drivers have to map appropriate window to access this
+	 * register.
+	 */
+		#define HWRM_FUNC_DBR_PACING_QCFG_OUTPUT_DBR_STAT_DB_FIFO_REG_ADDR_SPACE_BAR1	UINT32_C(0x3)
+		#define HWRM_FUNC_DBR_PACING_QCFG_OUTPUT_DBR_STAT_DB_FIFO_REG_ADDR_SPACE_LAST	HWRM_FUNC_DBR_PACING_QCFG_OUTPUT_DBR_STAT_DB_FIFO_REG_ADDR_SPACE_BAR1
+	/* Upper 30bits of the register address. */
+	#define HWRM_FUNC_DBR_PACING_QCFG_OUTPUT_DBR_STAT_DB_FIFO_REG_ADDR_MASK	UINT32_C(0xfffffffc)
+	#define HWRM_FUNC_DBR_PACING_QCFG_OUTPUT_DBR_STAT_DB_FIFO_REG_ADDR_SFT	2
+	/*
+	 * This field indicates the mask value for dbr_stat_db_fifo_reg
+	 * to get the high watermark for doorbell FIFO.
+	 */
+	uint32_t	dbr_stat_db_fifo_reg_watermark_mask;
+	/*
+	 * This field indicates the shift value for dbr_stat_db_fifo_reg
+	 * to get the high watermark for doorbell FIFO.
+	 */
+	uint8_t	dbr_stat_db_fifo_reg_watermark_shift;
+	uint8_t	unused_1[3];
+	/*
+	 * This field indicates the mask value for dbr_stat_db_fifo_reg
+	 * to get the amount of room left for doorbell FIFO.
+	 */
+	uint32_t	dbr_stat_db_fifo_reg_fifo_room_mask;
+	/*
+	 * This field indicates the shift value for dbr_stat_db_fifo_reg
+	 * to get the amount of room left for doorbell FIFO.
+	 */
+	uint8_t	dbr_stat_db_fifo_reg_fifo_room_shift;
+	uint8_t	unused_2[3];
+	/*
+	 * DBR_REG_AEQ_ARM register. This field should be used by the driver
+	 * to rearm the interrupt for regeneration of a notification to the
+	 * host from the hardware when the global doorbell occupancy threshold
+	 * is above the threshold value. Lower 2 bits indicates address space
+	 * location and upper 30 bits indicates upper 30bits of the register
+	 * address. A value of 0xFFFF-FFFF indicates this register does not
+	 * exist.
+	 */
+	uint32_t	dbr_throttling_aeq_arm_reg;
+	/* Lower 2 bits indicates address space location. */
+	#define HWRM_FUNC_DBR_PACING_QCFG_OUTPUT_DBR_THROTTLING_AEQ_ARM_REG_ADDR_SPACE_MASK	UINT32_C(0x3)
+	#define HWRM_FUNC_DBR_PACING_QCFG_OUTPUT_DBR_THROTTLING_AEQ_ARM_REG_ADDR_SPACE_SFT	0
+	/*
+	 * If value is 0, this register is located in PCIe config space.
+	 * Drivers have to map appropriate window to access this
+	 * register.
+	 */
+		#define HWRM_FUNC_DBR_PACING_QCFG_OUTPUT_DBR_THROTTLING_AEQ_ARM_REG_ADDR_SPACE_PCIE_CFG  UINT32_C(0x0)
+	/*
+	 * If value is 1, this register is located in GRC address space.
+	 * Drivers have to map appropriate window to access this
+	 * register.
+	 */
+		#define HWRM_FUNC_DBR_PACING_QCFG_OUTPUT_DBR_THROTTLING_AEQ_ARM_REG_ADDR_SPACE_GRC	UINT32_C(0x1)
+	/*
+	 * If value is 2, this register is located in first BAR address
+	 * space. Drivers have to map appropriate window to access this
+	 * register.
+	 */
+		#define HWRM_FUNC_DBR_PACING_QCFG_OUTPUT_DBR_THROTTLING_AEQ_ARM_REG_ADDR_SPACE_BAR0	UINT32_C(0x2)
+	/*
+	 * If value is 3, this register is located in second BAR address
+	 * space. Drivers have to map appropriate window to access this
+	 * Drivers have to map appropriate window to access this
+	 * register.
+	 */
+		#define HWRM_FUNC_DBR_PACING_QCFG_OUTPUT_DBR_THROTTLING_AEQ_ARM_REG_ADDR_SPACE_BAR1	UINT32_C(0x3)
+		#define HWRM_FUNC_DBR_PACING_QCFG_OUTPUT_DBR_THROTTLING_AEQ_ARM_REG_ADDR_SPACE_LAST	HWRM_FUNC_DBR_PACING_QCFG_OUTPUT_DBR_THROTTLING_AEQ_ARM_REG_ADDR_SPACE_BAR1
+	/* Upper 30bits of the register address. */
+	#define HWRM_FUNC_DBR_PACING_QCFG_OUTPUT_DBR_THROTTLING_AEQ_ARM_REG_ADDR_MASK	UINT32_C(0xfffffffc)
+	#define HWRM_FUNC_DBR_PACING_QCFG_OUTPUT_DBR_THROTTLING_AEQ_ARM_REG_ADDR_SFT	2
+	/*
+	 * This field indicates the value to be written for
+	 * dbr_throttling_aeq_arm_reg register.
+	 */
+	uint8_t	dbr_throttling_aeq_arm_reg_val;
+	uint8_t	unused_3[3];
+	/* This field indicates the maximum depth of the doorbell FIFO. */
+	uint32_t	dbr_stat_db_max_fifo_depth;
+	/*
+	 * Specifies primary function's NQ ID.
+	 * A value of 0xFFFF FFFF indicates NQ ID is invalid.
+	 */
+	uint32_t	primary_nq_id;
+	/*
+	 * Specifies the pacing threshold value, as a percentage of the
+	 * max doorbell FIFO depth. The range is 1 to 100.
+	 */
+	uint32_t	pacing_threshold;
+	uint8_t	unused_4[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_dbr_pacing_qcfg_output_t, *phwrm_func_dbr_pacing_qcfg_output_t;
+
+/****************************************
+ * hwrm_func_dbr_pacing_broadcast_event *
+ ****************************************/
+
+
+/* hwrm_func_dbr_pacing_broadcast_event_input (size:128b/16B) */
+
+typedef struct hwrm_func_dbr_pacing_broadcast_event_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+} hwrm_func_dbr_pacing_broadcast_event_input_t, *phwrm_func_dbr_pacing_broadcast_event_input_t;
+
+/* hwrm_func_dbr_pacing_broadcast_event_output (size:128b/16B) */
+
+typedef struct hwrm_func_dbr_pacing_broadcast_event_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_dbr_pacing_broadcast_event_output_t, *phwrm_func_dbr_pacing_broadcast_event_output_t;
+
+/*************************************
+ * hwrm_func_dbr_pacing_nqlist_query *
+ *************************************/
+
+
+/* hwrm_func_dbr_pacing_nqlist_query_input (size:128b/16B) */
+
+typedef struct hwrm_func_dbr_pacing_nqlist_query_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+} hwrm_func_dbr_pacing_nqlist_query_input_t, *phwrm_func_dbr_pacing_nqlist_query_input_t;
+
+/* hwrm_func_dbr_pacing_nqlist_query_output (size:384b/48B) */
+
+typedef struct hwrm_func_dbr_pacing_nqlist_query_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* ID of an NQ ring allocated for DBR pacing notifications. */
+	uint16_t	nq_ring_id0;
+	/* ID of an NQ ring allocated for DBR pacing notifications. */
+	uint16_t	nq_ring_id1;
+	/* ID of an NQ ring allocated for DBR pacing notifications. */
+	uint16_t	nq_ring_id2;
+	/* ID of an NQ ring allocated for DBR pacing notifications. */
+	uint16_t	nq_ring_id3;
+	/* ID of an NQ ring allocated for DBR pacing notifications. */
+	uint16_t	nq_ring_id4;
+	/* ID of an NQ ring allocated for DBR pacing notifications. */
+	uint16_t	nq_ring_id5;
+	/* ID of an NQ ring allocated for DBR pacing notifications. */
+	uint16_t	nq_ring_id6;
+	/* ID of an NQ ring allocated for DBR pacing notifications. */
+	uint16_t	nq_ring_id7;
+	/* ID of an NQ ring allocated for DBR pacing notifications. */
+	uint16_t	nq_ring_id8;
+	/* ID of an NQ ring allocated for DBR pacing notifications. */
+	uint16_t	nq_ring_id9;
+	/* ID of an NQ ring allocated for DBR pacing notifications. */
+	uint16_t	nq_ring_id10;
+	/* ID of an NQ ring allocated for DBR pacing notifications. */
+	uint16_t	nq_ring_id11;
+	/* ID of an NQ ring allocated for DBR pacing notifications. */
+	uint16_t	nq_ring_id12;
+	/* ID of an NQ ring allocated for DBR pacing notifications. */
+	uint16_t	nq_ring_id13;
+	/* ID of an NQ ring allocated for DBR pacing notifications. */
+	uint16_t	nq_ring_id14;
+	/* ID of an NQ ring allocated for DBR pacing notifications. */
+	uint16_t	nq_ring_id15;
+	/* Number of consecutive NQ ring IDs populated in the response. */
+	uint32_t	num_nqs;
+	uint8_t	unused_0[3];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_dbr_pacing_nqlist_query_output_t, *phwrm_func_dbr_pacing_nqlist_query_output_t;
+
+/************************************
+ * hwrm_func_dbr_recovery_completed *
+ ************************************/
+
+
+/* hwrm_func_dbr_recovery_completed_input (size:192b/24B) */
+
+typedef struct hwrm_func_dbr_recovery_completed_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/*
+	 * Specifies the epoch value with the one that was specified by the
+	 * firmware in the error_report_doorbell_drop_threshold async event
+	 * corresponding to the specific recovery cycle.
+	 */
+	uint32_t	epoch;
+	/* The epoch value. */
+	#define HWRM_FUNC_DBR_RECOVERY_COMPLETED_INPUT_EPOCH_VALUE_MASK UINT32_C(0xffffff)
+	#define HWRM_FUNC_DBR_RECOVERY_COMPLETED_INPUT_EPOCH_VALUE_SFT 0
+	uint8_t	unused_0[4];
+} hwrm_func_dbr_recovery_completed_input_t, *phwrm_func_dbr_recovery_completed_input_t;
+
+/* hwrm_func_dbr_recovery_completed_output (size:128b/16B) */
+
+typedef struct hwrm_func_dbr_recovery_completed_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_dbr_recovery_completed_output_t, *phwrm_func_dbr_recovery_completed_output_t;
+
+/***********************
+ * hwrm_func_synce_cfg *
+ ***********************/
+
+
+/* hwrm_func_synce_cfg_input (size:192b/24B) */
+
+typedef struct hwrm_func_synce_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint8_t	enables;
+	/*
+	 * This bit must be '1' for the freq_profile field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_SYNCE_CFG_INPUT_ENABLES_FREQ_PROFILE	UINT32_C(0x1)
+	/*
+	 * This bit must be '1' for the primary_clock_state field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_SYNCE_CFG_INPUT_ENABLES_PRIMARY_CLOCK	UINT32_C(0x2)
+	/*
+	 * This bit must be '1' for the secondary_clock_state field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_SYNCE_CFG_INPUT_ENABLES_SECONDARY_CLOCK	UINT32_C(0x4)
+	/* Frequency profile for SyncE recovered clock. */
+	uint8_t	freq_profile;
+	/* Invalid frequency profile */
+	#define HWRM_FUNC_SYNCE_CFG_INPUT_FREQ_PROFILE_INVALID UINT32_C(0x0)
+	/* 25MHz SyncE clock profile */
+	#define HWRM_FUNC_SYNCE_CFG_INPUT_FREQ_PROFILE_25MHZ   UINT32_C(0x1)
+	#define HWRM_FUNC_SYNCE_CFG_INPUT_FREQ_PROFILE_LAST   HWRM_FUNC_SYNCE_CFG_INPUT_FREQ_PROFILE_25MHZ
+	/*
+	 * Enable or disable primary clock for PF/port, overriding previous
+	 * primary clock setting.
+	 */
+	uint8_t	primary_clock_state;
+	/* Disable clock */
+	#define HWRM_FUNC_SYNCE_CFG_INPUT_PRIMARY_CLOCK_STATE_DISABLE UINT32_C(0x0)
+	/* Enable clock */
+	#define HWRM_FUNC_SYNCE_CFG_INPUT_PRIMARY_CLOCK_STATE_ENABLE  UINT32_C(0x1)
+	#define HWRM_FUNC_SYNCE_CFG_INPUT_PRIMARY_CLOCK_STATE_LAST   HWRM_FUNC_SYNCE_CFG_INPUT_PRIMARY_CLOCK_STATE_ENABLE
+	/*
+	 * Enable or disable secondary clock for PF/port, overriding previous
+	 * secondary clock setting.
+	 */
+	uint8_t	secondary_clock_state;
+	/* Clock disabled */
+	#define HWRM_FUNC_SYNCE_CFG_INPUT_SECONDARY_CLOCK_STATE_DISABLE UINT32_C(0x0)
+	/* Clock enabled */
+	#define HWRM_FUNC_SYNCE_CFG_INPUT_SECONDARY_CLOCK_STATE_ENABLE  UINT32_C(0x1)
+	#define HWRM_FUNC_SYNCE_CFG_INPUT_SECONDARY_CLOCK_STATE_LAST   HWRM_FUNC_SYNCE_CFG_INPUT_SECONDARY_CLOCK_STATE_ENABLE
+	uint8_t	unused_0[4];
+} hwrm_func_synce_cfg_input_t, *phwrm_func_synce_cfg_input_t;
+
+/* hwrm_func_synce_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_func_synce_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_synce_cfg_output_t, *phwrm_func_synce_cfg_output_t;
+
+/************************
+ * hwrm_func_synce_qcfg *
+ ************************/
+
+
+/* hwrm_func_synce_qcfg_input (size:192b/24B) */
+
+typedef struct hwrm_func_synce_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint8_t	unused_0[8];
+} hwrm_func_synce_qcfg_input_t, *phwrm_func_synce_qcfg_input_t;
+
+/* hwrm_func_synce_qcfg_output (size:128b/16B) */
+
+typedef struct hwrm_func_synce_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Frequency profile for SyncE recovered clock. */
+	uint8_t	freq_profile;
+	/* Invalid frequency profile */
+	#define HWRM_FUNC_SYNCE_QCFG_OUTPUT_FREQ_PROFILE_INVALID UINT32_C(0x0)
+	/* 25MHz SyncE clock profile */
+	#define HWRM_FUNC_SYNCE_QCFG_OUTPUT_FREQ_PROFILE_25MHZ   UINT32_C(0x1)
+	#define HWRM_FUNC_SYNCE_QCFG_OUTPUT_FREQ_PROFILE_LAST   HWRM_FUNC_SYNCE_QCFG_OUTPUT_FREQ_PROFILE_25MHZ
+	/* SyncE recovered clock state */
+	uint8_t	state;
+	/*
+	 * When this bit is '1', primary clock is enabled for this PF/port.
+	 * When this bit is '0', primary clock is disabled for this PF/port.
+	 */
+	#define HWRM_FUNC_SYNCE_QCFG_OUTPUT_STATE_PRIMARY_CLOCK_ENABLED	UINT32_C(0x1)
+	/*
+	 * When this bit is '1', secondary clock is enabled for this
+	 * PF/port.
+	 * When this bit is '0', secondary clock is disabled for this
+	 * PF/port.
+	 */
+	#define HWRM_FUNC_SYNCE_QCFG_OUTPUT_STATE_SECONDARY_CLOCK_ENABLED	UINT32_C(0x2)
+	uint8_t	unused_0[5];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_synce_qcfg_output_t, *phwrm_func_synce_qcfg_output_t;
+
+/************************
+ * hwrm_func_lag_create *
+ ************************/
+
+
+/* hwrm_func_lag_create_input (size:192b/24B) */
+
+typedef struct hwrm_func_lag_create_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint8_t	enables;
+	/*
+	 * This bit must be '1' for the active_port_map field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_LAG_CREATE_INPUT_ENABLES_ACTIVE_PORT_MAP	UINT32_C(0x1)
+	/*
+	 * This bit must be '1' for the member_port_map field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_LAG_CREATE_INPUT_ENABLES_MEMBER_PORT_MAP	UINT32_C(0x2)
+	/* This bit must be '1' for the aggr_mode field to be configured. */
+	#define HWRM_FUNC_LAG_CREATE_INPUT_ENABLES_AGGR_MODE	UINT32_C(0x4)
+	/* rsvd1 is 5 b */
+	#define HWRM_FUNC_LAG_CREATE_INPUT_ENABLES_RSVD1_MASK	UINT32_C(0xf8)
+	#define HWRM_FUNC_LAG_CREATE_INPUT_ENABLES_RSVD1_SFT	3
+	/*
+	 * This is the bitmap of all active ports in the LAG. Each bit
+	 * represents a front panel port of the device. Ports are numbered
+	 * from 0 to n - 1 on a device with n ports. The number of front panel
+	 * ports is specified in the port_cnt field of the HWRM_PORT_PHY_QCAPS
+	 * response. The active_port_map must always be a subset of the
+	 * member_port_map. An active port is eligible to send and receive
+	 * traffic.
+	 *
+	 * If the LAG mode is active-backup, only one port can be an active
+	 * port at a given time. All other ports in the member_port_map that
+	 * are not the active port are backup port. When the active port
+	 * fails, another member port takes over to become the active port.
+	 * The driver should use HWRM_FUNC_LAG_UPDATE to update
+	 * the active_port_map by only setting the port bit of the new active
+	 * port.
+	 *
+	 * In active-active, balance_xor or 802_3_ad mode, all member ports
+	 * can be active ports. If the driver determines that an active
+	 * port is down or unable to function, it should use
+	 * HWRM_FUNC_LAG_UPDATE to update the active_port_map by clearing
+	 * the port bit that has failed.
+	 */
+	uint8_t	active_port_map;
+	/* If this bit is set to '1', the port0 is a lag active port. */
+	#define HWRM_FUNC_LAG_CREATE_INPUT_ACTIVE_PORT_MAP_PORT_0	UINT32_C(0x1)
+	/* If this bit is set to '1', the port1 is a lag active port. */
+	#define HWRM_FUNC_LAG_CREATE_INPUT_ACTIVE_PORT_MAP_PORT_1	UINT32_C(0x2)
+	/* If this bit is set to '1', the port2 is a lag active port. */
+	#define HWRM_FUNC_LAG_CREATE_INPUT_ACTIVE_PORT_MAP_PORT_2	UINT32_C(0x4)
+	/* If this bit is set to '1', the port3 is a lag active port. */
+	#define HWRM_FUNC_LAG_CREATE_INPUT_ACTIVE_PORT_MAP_PORT_3	UINT32_C(0x8)
+	/* rsvd3 is 4 b */
+	#define HWRM_FUNC_LAG_CREATE_INPUT_ACTIVE_PORT_MAP_RSVD3_MASK UINT32_C(0xf0)
+	#define HWRM_FUNC_LAG_CREATE_INPUT_ACTIVE_PORT_MAP_RSVD3_SFT  4
+	/*
+	 * This is the bitmap of all member ports in the LAG. Each bit
+	 * represents a front panel port of the device. Ports are numbered
+	 * from 0 to n - 1 on a device with n ports. The number of front panel
+	 * ports is specified in the port_cnt field of the HWRM_PORT_PHY_QCAPS
+	 * response. There must be at least 2 ports in the member ports and
+	 * each must not be a member of another LAG. Note that on a 4-port
+	 * device, there can be either 2 ports or 4 ports in the member ports.
+	 * Using 3 member ports is not supported.
+	 */
+	uint8_t	member_port_map;
+	/* If this bit is set to '1', the port0 is a lag member port. */
+	#define HWRM_FUNC_LAG_CREATE_INPUT_MEMBER_PORT_MAP_PORT_0	UINT32_C(0x1)
+	/* If this bit is set to '1', the port1 is a lag member port. */
+	#define HWRM_FUNC_LAG_CREATE_INPUT_MEMBER_PORT_MAP_PORT_1	UINT32_C(0x2)
+	/* If this bit is set to '1', the port2 is a lag member port. */
+	#define HWRM_FUNC_LAG_CREATE_INPUT_MEMBER_PORT_MAP_PORT_2	UINT32_C(0x4)
+	/* If this bit is set to '1', the port3 is a lag member port. */
+	#define HWRM_FUNC_LAG_CREATE_INPUT_MEMBER_PORT_MAP_PORT_3	UINT32_C(0x8)
+	/* rsvd4 is 4 b */
+	#define HWRM_FUNC_LAG_CREATE_INPUT_MEMBER_PORT_MAP_RSVD4_MASK UINT32_C(0xf0)
+	#define HWRM_FUNC_LAG_CREATE_INPUT_MEMBER_PORT_MAP_RSVD4_SFT  4
+	/* Link aggregation mode being used. */
+	uint8_t	link_aggr_mode;
+	/* active active mode. */
+	#define HWRM_FUNC_LAG_CREATE_INPUT_AGGR_MODE_ACTIVE_ACTIVE UINT32_C(0x1)
+	/* active backup mode. */
+	#define HWRM_FUNC_LAG_CREATE_INPUT_AGGR_MODE_ACTIVE_BACKUP UINT32_C(0x2)
+	/* Balance XOR mode. */
+	#define HWRM_FUNC_LAG_CREATE_INPUT_AGGR_MODE_BALANCE_XOR   UINT32_C(0x3)
+	/* 802.3AD mode. */
+	#define HWRM_FUNC_LAG_CREATE_INPUT_AGGR_MODE_802_3_AD	UINT32_C(0x4)
+	#define HWRM_FUNC_LAG_CREATE_INPUT_AGGR_MODE_LAST	HWRM_FUNC_LAG_CREATE_INPUT_AGGR_MODE_802_3_AD
+	uint8_t	unused_0[4];
+} hwrm_func_lag_create_input_t, *phwrm_func_lag_create_input_t;
+
+/* hwrm_func_lag_create_output (size:128b/16B) */
+
+typedef struct hwrm_func_lag_create_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/*
+	 * LAG ID of the created LAG. This LAG ID will also be returned
+	 * in the HWRM_FUNC_QCFG response of all member ports.
+	 */
+	uint8_t	fw_lag_id;
+	uint8_t	unused_0[6];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_lag_create_output_t, *phwrm_func_lag_create_output_t;
+
+/************************
+ * hwrm_func_lag_update *
+ ************************/
+
+
+/* hwrm_func_lag_update_input (size:192b/24B) */
+
+typedef struct hwrm_func_lag_update_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Link aggregation group ID of the LAG to be updated. */
+	uint8_t	fw_lag_id;
+	uint8_t	enables;
+	/*
+	 * This bit must be '1' for the active_port_map field to be
+	 * updated.
+	 */
+	#define HWRM_FUNC_LAG_UPDATE_INPUT_ENABLES_ACTIVE_PORT_MAP	UINT32_C(0x1)
+	/*
+	 * This bit must be '1' for the member_port_map field to be
+	 * updated.
+	 */
+	#define HWRM_FUNC_LAG_UPDATE_INPUT_ENABLES_MEMBER_PORT_MAP	UINT32_C(0x2)
+	/* This bit must be '1' for the aggr_mode field to be updated. */
+	#define HWRM_FUNC_LAG_UPDATE_INPUT_ENABLES_AGGR_MODE	UINT32_C(0x4)
+	/* rsvd1 is 5 b */
+	#define HWRM_FUNC_LAG_UPDATE_INPUT_ENABLES_RSVD1_MASK	UINT32_C(0xf8)
+	#define HWRM_FUNC_LAG_UPDATE_INPUT_ENABLES_RSVD1_SFT	3
+	/*
+	 * This is the bitmap of all active ports in the LAG. Each bit
+	 * represents a front panel port of the device. Ports are numbered
+	 * from 0 to n - 1 on a device with n ports. The number of front panel
+	 * ports is specified in the port_cnt field of the HWRM_PORT_PHY_QCAPS
+	 * response. The active_port_map must always be a subset of the
+	 * member_port_map. An active port is eligible to send and receive
+	 * traffic.
+	 *
+	 * If the LAG mode is active-backup, only one port can be an active
+	 * port at a given time. All other ports in the member_port_map that
+	 * are not the active port are backup port. When the active port
+	 * fails, another member port takes over to become the active port.
+	 * The driver should use HWRM_FUNC_LAG_UPDATE to update
+	 * the active_port_map by only setting the port bit of the new active
+	 * port.
+	 *
+	 * In active-active, balance_xor or 802_3_ad mode, all member ports
+	 * can be active ports. If the driver determines that an active
+	 * port is down or unable to function, it should use
+	 * HWRM_FUNC_LAG_UPDATE to update the active_port_map by clearing
+	 * the port bit that has failed.
+	 */
+	uint8_t	active_port_map;
+	/* If this bit is set to '1', the port0 is a lag active port. */
+	#define HWRM_FUNC_LAG_UPDATE_INPUT_ACTIVE_PORT_MAP_PORT_0	UINT32_C(0x1)
+	/* If this bit is set to '1', the port1 is a lag active port. */
+	#define HWRM_FUNC_LAG_UPDATE_INPUT_ACTIVE_PORT_MAP_PORT_1	UINT32_C(0x2)
+	/* If this bit is set to '1', the port2 is a lag active port. */
+	#define HWRM_FUNC_LAG_UPDATE_INPUT_ACTIVE_PORT_MAP_PORT_2	UINT32_C(0x4)
+	/* If this bit is set to '1', the port3 is a lag active port. */
+	#define HWRM_FUNC_LAG_UPDATE_INPUT_ACTIVE_PORT_MAP_PORT_3	UINT32_C(0x8)
+	/* rsvd3 is 4 b */
+	#define HWRM_FUNC_LAG_UPDATE_INPUT_ACTIVE_PORT_MAP_RSVD3_MASK UINT32_C(0xf0)
+	#define HWRM_FUNC_LAG_UPDATE_INPUT_ACTIVE_PORT_MAP_RSVD3_SFT  4
+	/*
+	 * This is the bitmap of all member ports in the LAG. Each bit
+	 * represents a front panel port of the device. Ports are numbered
+	 * from 0 to n - 1 on a device with n ports. The number of front panel
+	 * ports is specified in the port_cnt field of the HWRM_PORT_PHY_QCAPS
+	 * response. There must be at least 2 ports in the member ports and
+	 * each must not be a member of another LAG. Note that on a 4-port
+	 * device, there can be either 2 ports or 4 ports in the member ports.
+	 * Using 3 member ports is not supported.
+	 */
+	uint8_t	member_port_map;
+	/* If this bit is set to '1', the port0 is a lag member port. */
+	#define HWRM_FUNC_LAG_UPDATE_INPUT_MEMBER_PORT_MAP_PORT_0	UINT32_C(0x1)
+	/* If this bit is set to '1', the port1 is a lag member port. */
+	#define HWRM_FUNC_LAG_UPDATE_INPUT_MEMBER_PORT_MAP_PORT_1	UINT32_C(0x2)
+	/* If this bit is set to '1', the port2 is a lag member port. */
+	#define HWRM_FUNC_LAG_UPDATE_INPUT_MEMBER_PORT_MAP_PORT_2	UINT32_C(0x4)
+	/* If this bit is set to '1', the port3 is a lag member port. */
+	#define HWRM_FUNC_LAG_UPDATE_INPUT_MEMBER_PORT_MAP_PORT_3	UINT32_C(0x8)
+	/* rsvd4 is 4 b */
+	#define HWRM_FUNC_LAG_UPDATE_INPUT_MEMBER_PORT_MAP_RSVD4_MASK UINT32_C(0xf0)
+	#define HWRM_FUNC_LAG_UPDATE_INPUT_MEMBER_PORT_MAP_RSVD4_SFT  4
+	/* Link aggregation mode being used. */
+	uint8_t	link_aggr_mode;
+	/* active active mode. */
+	#define HWRM_FUNC_LAG_UPDATE_INPUT_AGGR_MODE_ACTIVE_ACTIVE UINT32_C(0x1)
+	/* active backup mode. */
+	#define HWRM_FUNC_LAG_UPDATE_INPUT_AGGR_MODE_ACTIVE_BACKUP UINT32_C(0x2)
+	/* Balance XOR mode. */
+	#define HWRM_FUNC_LAG_UPDATE_INPUT_AGGR_MODE_BALANCE_XOR   UINT32_C(0x3)
+	/* 802.3AD mode. */
+	#define HWRM_FUNC_LAG_UPDATE_INPUT_AGGR_MODE_802_3_AD	UINT32_C(0x4)
+	#define HWRM_FUNC_LAG_UPDATE_INPUT_AGGR_MODE_LAST	HWRM_FUNC_LAG_UPDATE_INPUT_AGGR_MODE_802_3_AD
+	uint8_t	unused_0[3];
+} hwrm_func_lag_update_input_t, *phwrm_func_lag_update_input_t;
+
+/* hwrm_func_lag_update_output (size:128b/16B) */
+
+typedef struct hwrm_func_lag_update_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_lag_update_output_t, *phwrm_func_lag_update_output_t;
+
+/**********************
+ * hwrm_func_lag_free *
+ **********************/
+
+
+/* hwrm_func_lag_free_input (size:192b/24B) */
+
+typedef struct hwrm_func_lag_free_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Link aggregation group ID of the LAG to be freed. */
+	uint8_t	fw_lag_id;
+	uint8_t	unused_0[7];
+} hwrm_func_lag_free_input_t, *phwrm_func_lag_free_input_t;
+
+/* hwrm_func_lag_free_output (size:128b/16B) */
+
+typedef struct hwrm_func_lag_free_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_lag_free_output_t, *phwrm_func_lag_free_output_t;
+
+/**********************
+ * hwrm_func_lag_qcfg *
+ **********************/
+
+
+/* hwrm_func_lag_qcfg_input (size:192b/24B) */
+
+typedef struct hwrm_func_lag_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Link aggregation group ID of the LAG to be queried. */
+	uint8_t	fw_lag_id;
+	uint8_t	unused_0[7];
+} hwrm_func_lag_qcfg_input_t, *phwrm_func_lag_qcfg_input_t;
+
+/* hwrm_func_lag_qcfg_output (size:128b/16B) */
+
+typedef struct hwrm_func_lag_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/*
+	 * This is the bitmap of all active ports in the LAG. Each bit
+	 * represents a front panel port of the device. Ports are numbered
+	 * from 0 to n - 1 on a device with n ports. The number of front panel
+	 * ports is specified in the port_cnt field of the HWRM_PORT_PHY_QCAPS
+	 * response. The active_port_map must always be a subset of the
+	 * member_port_map. An active port is eligible to send and receive
+	 * traffic.
+	 *
+	 * If the LAG mode is active-backup, only one port can be an active
+	 * port at a given time. All other ports in the member_port_map that
+	 * are not the active port are backup port. When the active port
+	 * fails, another member port takes over to become the active port.
+	 * The driver should use HWRM_FUNC_LAG_UPDATE to update
+	 * the active_port_map by only setting the port bit of the new active
+	 * port.
+	 *
+	 * In active-active, balance_xor or 802_3_ad mode, all member ports
+	 * can be active ports. If the driver determines that an active
+	 * port is down or unable to function, it should use
+	 * HWRM_FUNC_LAG_UPDATE to update the active_port_map by clearing
+	 * the port bit that has failed.
+	 */
+	uint8_t	active_port_map;
+	/* If this bit is set to '1', the port0 is a lag active port. */
+	#define HWRM_FUNC_LAG_QCFG_OUTPUT_ACTIVE_PORT_MAP_PORT_0	UINT32_C(0x1)
+	/* If this bit is set to '1', the port1 is a lag active port. */
+	#define HWRM_FUNC_LAG_QCFG_OUTPUT_ACTIVE_PORT_MAP_PORT_1	UINT32_C(0x2)
+	/* If this bit is set to '1', the port2 is a lag active port. */
+	#define HWRM_FUNC_LAG_QCFG_OUTPUT_ACTIVE_PORT_MAP_PORT_2	UINT32_C(0x4)
+	/* If this bit is set to '1', the port3 is a lag active port. */
+	#define HWRM_FUNC_LAG_QCFG_OUTPUT_ACTIVE_PORT_MAP_PORT_3	UINT32_C(0x8)
+	/* rsvd3 is 4 b */
+	#define HWRM_FUNC_LAG_QCFG_OUTPUT_ACTIVE_PORT_MAP_RSVD3_MASK UINT32_C(0xf0)
+	#define HWRM_FUNC_LAG_QCFG_OUTPUT_ACTIVE_PORT_MAP_RSVD3_SFT  4
+	/*
+	 * This is the bitmap of all member ports in the LAG. Each bit
+	 * represents a front panel port of the device. Ports are numbered
+	 * from 0 to n - 1 on a device with n ports. The number of front panel
+	 * ports is specified in the port_cnt field of the HWRM_PORT_PHY_QCAPS
+	 * response. There must be at least 2 ports in the member ports and
+	 * each must not be a member of another LAG. Note that on a 4-port
+	 * device, there can be either 2 ports or 4 ports in the member ports.
+	 * Using 3 member ports is not supported.
+	 */
+	uint8_t	member_port_map;
+	/* If this bit is set to '1', the port0 is a lag member port. */
+	#define HWRM_FUNC_LAG_QCFG_OUTPUT_MEMBER_PORT_MAP_PORT_0	UINT32_C(0x1)
+	/* If this bit is set to '1', the port1 is a lag member port. */
+	#define HWRM_FUNC_LAG_QCFG_OUTPUT_MEMBER_PORT_MAP_PORT_1	UINT32_C(0x2)
+	/* If this bit is set to '1', the port2 is a lag member port. */
+	#define HWRM_FUNC_LAG_QCFG_OUTPUT_MEMBER_PORT_MAP_PORT_2	UINT32_C(0x4)
+	/* If this bit is set to '1', the port3 is a lag member port. */
+	#define HWRM_FUNC_LAG_QCFG_OUTPUT_MEMBER_PORT_MAP_PORT_3	UINT32_C(0x8)
+	/* rsvd4 is 4 b */
+	#define HWRM_FUNC_LAG_QCFG_OUTPUT_MEMBER_PORT_MAP_RSVD4_MASK UINT32_C(0xf0)
+	#define HWRM_FUNC_LAG_QCFG_OUTPUT_MEMBER_PORT_MAP_RSVD4_SFT  4
+	/* Link aggregation mode being used. */
+	uint8_t	link_aggr_mode;
+	/* active active mode. */
+	#define HWRM_FUNC_LAG_QCFG_OUTPUT_AGGR_MODE_ACTIVE_ACTIVE UINT32_C(0x1)
+	/* active backup mode. */
+	#define HWRM_FUNC_LAG_QCFG_OUTPUT_AGGR_MODE_ACTIVE_BACKUP UINT32_C(0x2)
+	/* Balance XOR mode. */
+	#define HWRM_FUNC_LAG_QCFG_OUTPUT_AGGR_MODE_BALANCE_XOR   UINT32_C(0x3)
+	/* 802.3AD mode. */
+	#define HWRM_FUNC_LAG_QCFG_OUTPUT_AGGR_MODE_802_3_AD	UINT32_C(0x4)
+	#define HWRM_FUNC_LAG_QCFG_OUTPUT_AGGR_MODE_LAST	HWRM_FUNC_LAG_QCFG_OUTPUT_AGGR_MODE_802_3_AD
+	uint8_t	unused_0[4];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_lag_qcfg_output_t, *phwrm_func_lag_qcfg_output_t;
+
+/**************************
+ * hwrm_func_lag_mode_cfg *
+ **************************/
+
+
+/* hwrm_func_lag_mode_cfg_input (size:192b/24B) */
+
+typedef struct hwrm_func_lag_mode_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint8_t	enables;
+	/*
+	 * This bit must be '1' for the link aggregation enable or
+	 * disable flags to be configured.
+	 */
+	#define HWRM_FUNC_LAG_MODE_CFG_INPUT_ENABLES_FLAGS		UINT32_C(0x1)
+	/*
+	 * This bit must be '1' for the active_port_map field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_LAG_MODE_CFG_INPUT_ENABLES_ACTIVE_PORT_MAP	UINT32_C(0x2)
+	/*
+	 * This bit must be '1' for the member_port_map field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_LAG_MODE_CFG_INPUT_ENABLES_MEMBER_PORT_MAP	UINT32_C(0x4)
+	/* This bit must be '1' for the aggr_mode field to be configured. */
+	#define HWRM_FUNC_LAG_MODE_CFG_INPUT_ENABLES_AGGR_MODE	UINT32_C(0x8)
+	/* This bit must be '1' for the lag id field to be configured. */
+	#define HWRM_FUNC_LAG_MODE_CFG_INPUT_ENABLES_LAG_ID		UINT32_C(0x10)
+	/* rsvd1 is 3 b */
+	#define HWRM_FUNC_LAG_MODE_CFG_INPUT_ENABLES_RSVD1_MASK	UINT32_C(0xe0)
+	#define HWRM_FUNC_LAG_MODE_CFG_INPUT_ENABLES_RSVD1_SFT	5
+	uint8_t	flags;
+	/*
+	 * If this bit is set to 1, the driver is requesting FW to disable
+	 * link aggregation feature during run time.
+	 */
+	#define HWRM_FUNC_LAG_MODE_CFG_INPUT_FLAGS_AGGR_DISABLE	UINT32_C(0x1)
+	/*
+	 * If this bit is set to 1, the driver is requesting FW to enable
+	 * link aggregation feature during run time.
+	 */
+	#define HWRM_FUNC_LAG_MODE_CFG_INPUT_FLAGS_AGGR_ENABLE	UINT32_C(0x2)
+	/* rsvd2 is 6 b */
+	#define HWRM_FUNC_LAG_MODE_CFG_INPUT_FLAGS_RSVD2_MASK	UINT32_C(0xfc)
+	#define HWRM_FUNC_LAG_MODE_CFG_INPUT_FLAGS_RSVD2_SFT	2
+	/*
+	 * This is the bitmap of all active ports in the LAG. Each bit
+	 * represents a front panel port of the device starting from port 0.
+	 * The number of front panel ports is specified in the port_cnt field
+	 * of the HWRM_PORT_PHY_QCAPS response.
+	 * The term "active port" is one of member ports which is eligible to
+	 * send or receive the traffic.
+	 * In the active-backup mode, only one member port is active port at
+	 * any given time. If the active port fails, another member port
+	 * automatically takes over the active role to ensure continuous
+	 * network connectivity.
+	 * In the active-active, balance_xor or 802_3_ad mode, all member ports
+	 * could be active port, if link status on one port is down, driver
+	 * needs to send the NIC a new active-port bitmap with marking this
+	 * port as not active port.
+	 * The PORT_2 and PORT_3 are only valid if the NIC has four front
+	 * panel ports.
+	 */
+	uint8_t	active_port_map;
+	/* If this bit is set to '1', the port0 is a lag active port. */
+	#define HWRM_FUNC_LAG_MODE_CFG_INPUT_ACTIVE_PORT_MAP_PORT_0	UINT32_C(0x1)
+	/* If this bit is set to '1', the port1 is a lag active port. */
+	#define HWRM_FUNC_LAG_MODE_CFG_INPUT_ACTIVE_PORT_MAP_PORT_1	UINT32_C(0x2)
+	/* If this bit is set to '1', the port2 is a lag active port. */
+	#define HWRM_FUNC_LAG_MODE_CFG_INPUT_ACTIVE_PORT_MAP_PORT_2	UINT32_C(0x4)
+	/* If this bit is set to '1', the port3 is a lag active port. */
+	#define HWRM_FUNC_LAG_MODE_CFG_INPUT_ACTIVE_PORT_MAP_PORT_3	UINT32_C(0x8)
+	/* rsvd3 is 4 b */
+	#define HWRM_FUNC_LAG_MODE_CFG_INPUT_ACTIVE_PORT_MAP_RSVD3_MASK UINT32_C(0xf0)
+	#define HWRM_FUNC_LAG_MODE_CFG_INPUT_ACTIVE_PORT_MAP_RSVD3_SFT  4
+	/*
+	 * This is the bitmap of all member ports in the LAG. Each bit
+	 * represents a front panel port of the device starting from port 0.
+	 * The number of front panel ports is specified in the port_cnt field
+	 * of the HWRM_PORT_PHY_QCAPS response.
+	 * The term "member port" refers to a front panel port that is added to
+	 * the bond group as a slave device. These member ports are combined to
+	 * create a logical bond interface.
+	 * For a 4-port NIC, the LAG member port combination can consist of
+	 * either two ports or four ports. However, it is important to note
+	 * that the case with three ports in the same lag group is not
+	 * supported.
+	 * The PORT_2 and PORT_3 are only valid if the NIC has four front
+	 * panel ports. There could be a case to use multiple LAG groups,
+	 * for example, if the NIC has four front panel ports, the lag feature
+	 * can use up to two LAG groups, with two ports assigned to each group.
+	 */
+	uint8_t	member_port_map;
+	/* If this bit is set to '1', the port0 is a lag member port. */
+	#define HWRM_FUNC_LAG_MODE_CFG_INPUT_MEMBER_PORT_MAP_PORT_0	UINT32_C(0x1)
+	/* If this bit is set to '1', the port1 is a lag member port. */
+	#define HWRM_FUNC_LAG_MODE_CFG_INPUT_MEMBER_PORT_MAP_PORT_1	UINT32_C(0x2)
+	/* If this bit is set to '1', the port2 is a lag member port. */
+	#define HWRM_FUNC_LAG_MODE_CFG_INPUT_MEMBER_PORT_MAP_PORT_2	UINT32_C(0x4)
+	/* If this bit is set to '1', the port3 is a lag member port. */
+	#define HWRM_FUNC_LAG_MODE_CFG_INPUT_MEMBER_PORT_MAP_PORT_3	UINT32_C(0x8)
+	/* rsvd4 is 4 b */
+	#define HWRM_FUNC_LAG_MODE_CFG_INPUT_MEMBER_PORT_MAP_RSVD4_MASK UINT32_C(0xf0)
+	#define HWRM_FUNC_LAG_MODE_CFG_INPUT_MEMBER_PORT_MAP_RSVD4_SFT  4
+	/* Link aggregation mode being used. */
+	uint8_t	link_aggr_mode;
+	/* active active mode. */
+	#define HWRM_FUNC_LAG_MODE_CFG_INPUT_AGGR_MODE_ACTIVE_ACTIVE UINT32_C(0x1)
+	/* active backup mode. */
+	#define HWRM_FUNC_LAG_MODE_CFG_INPUT_AGGR_MODE_ACTIVE_BACKUP UINT32_C(0x2)
+	/* Balance XOR mode. */
+	#define HWRM_FUNC_LAG_MODE_CFG_INPUT_AGGR_MODE_BALANCE_XOR   UINT32_C(0x3)
+	/* 802.3AD mode. */
+	#define HWRM_FUNC_LAG_MODE_CFG_INPUT_AGGR_MODE_802_3_AD	UINT32_C(0x4)
+	#define HWRM_FUNC_LAG_MODE_CFG_INPUT_AGGR_MODE_LAST	HWRM_FUNC_LAG_MODE_CFG_INPUT_AGGR_MODE_802_3_AD
+	/* Link aggregation group idx being used. */
+	uint8_t	lag_id;
+	uint8_t	unused_0[2];
+} hwrm_func_lag_mode_cfg_input_t, *phwrm_func_lag_mode_cfg_input_t;
+
+/* hwrm_func_lag_mode_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_func_lag_mode_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Link aggregation group idx being used. */
+	uint8_t	lag_id;
+	uint8_t	unused_0[6];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_lag_mode_cfg_output_t, *phwrm_func_lag_mode_cfg_output_t;
+
+/***************************
+ * hwrm_func_lag_mode_qcfg *
+ ***************************/
+
+
+/* hwrm_func_lag_mode_qcfg_input (size:192b/24B) */
+
+typedef struct hwrm_func_lag_mode_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint8_t	unused_0[8];
+} hwrm_func_lag_mode_qcfg_input_t, *phwrm_func_lag_mode_qcfg_input_t;
+
+/* hwrm_func_lag_mode_qcfg_output (size:128b/16B) */
+
+typedef struct hwrm_func_lag_mode_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	aggr_enabled;
+	/*
+	 * This flag is used to query whether link aggregation is enabled
+	 * or disabled during run time.
+	 */
+	#define HWRM_FUNC_LAG_MODE_QCFG_OUTPUT_AGGR_ENABLED	UINT32_C(0x1)
+	/* rsvd1 is 7 b */
+	#define HWRM_FUNC_LAG_MODE_QCFG_OUTPUT_RSVD1_MASK	UINT32_C(0xfe)
+	#define HWRM_FUNC_LAG_MODE_QCFG_OUTPUT_RSVD1_SFT	1
+	/*
+	 * This is the bitmap of all active ports in the LAG. Each bit
+	 * represents a front panel port of the device starting from port 0.
+	 * The number of front panel ports is specified in the port_cnt field
+	 * of the HWRM_PORT_PHY_QCAPS response.
+	 * The term "active port" is one of member ports which is eligible to
+	 * send or receive the traffic.
+	 * In the active-backup mode, only one member port is active port at
+	 * any given time. If the active port fails, another member port
+	 * automatically takes over the active role to ensure continuous
+	 * network connectivity.
+	 * In the active-active, balance_xor or 802_3_ad mode, all member ports
+	 * could be active port, if link status on one port is down, driver
+	 * needs to send the NIC a new active-port bitmap with marking this
+	 * port as not active port.
+	 * The PORT_2 and PORT_3 are only valid if the NIC has four front
+	 * panel ports.
+	 */
+	uint8_t	active_port_map;
+	/* If this bit is set to '1', the port0 is a lag active port. */
+	#define HWRM_FUNC_LAG_MODE_QCFG_OUTPUT_ACTIVE_PORT_MAP_PORT_0	UINT32_C(0x1)
+	/* If this bit is set to '1', the port1 is a lag active port. */
+	#define HWRM_FUNC_LAG_MODE_QCFG_OUTPUT_ACTIVE_PORT_MAP_PORT_1	UINT32_C(0x2)
+	/* If this bit is set to '1', the port2 is a lag active port. */
+	#define HWRM_FUNC_LAG_MODE_QCFG_OUTPUT_ACTIVE_PORT_MAP_PORT_2	UINT32_C(0x4)
+	/* If this bit is set to '1', the port3 is a lag active port. */
+	#define HWRM_FUNC_LAG_MODE_QCFG_OUTPUT_ACTIVE_PORT_MAP_PORT_3	UINT32_C(0x8)
+	/* rsvd2 is 4 b */
+	#define HWRM_FUNC_LAG_MODE_QCFG_OUTPUT_ACTIVE_PORT_MAP_RSVD2_MASK UINT32_C(0xf0)
+	#define HWRM_FUNC_LAG_MODE_QCFG_OUTPUT_ACTIVE_PORT_MAP_RSVD2_SFT  4
+	/*
+	 * This is the bitmap of all member ports in the LAG. Each bit
+	 * represents a front panel port of the device starting from port 0.
+	 * The number of front panel ports is specified in the port_cnt field
+	 * of the HWRM_PORT_PHY_QCAPS response.
+	 * The term "member port" refers to a front panel port that is added to
+	 * the bond group as a slave device. These member ports are combined to
+	 * create a logical bond interface.
+	 * For a 4-port NIC, the LAG member port combination can consist of
+	 * either two ports or four ports. However, it is important to note
+	 * that the case with three ports in the same lag group is not
+	 * supported.
+	 * The PORT_2 and PORT_3 are only valid if the NIC has four front
+	 * panel ports. There could be a case to use multiple LAG groups,
+	 * for example, if the NIC has four front panel ports, the lag feature
+	 * can use up to two LAG groups, with two ports assigned to each group.
+	 */
+	uint8_t	member_port_map;
+	/* If this bit is set to '1', the port0 is a lag member port. */
+	#define HWRM_FUNC_LAG_MODE_QCFG_OUTPUT_MEMBER_PORT_MAP_PORT_0	UINT32_C(0x1)
+	/* If this bit is set to '1', the port1 is a lag member port. */
+	#define HWRM_FUNC_LAG_MODE_QCFG_OUTPUT_MEMBER_PORT_MAP_PORT_1	UINT32_C(0x2)
+	/* If this bit is set to '1', the port2 is a lag member port. */
+	#define HWRM_FUNC_LAG_MODE_QCFG_OUTPUT_MEMBER_PORT_MAP_PORT_2	UINT32_C(0x4)
+	/* If this bit is set to '1', the port3 is a lag member port. */
+	#define HWRM_FUNC_LAG_MODE_QCFG_OUTPUT_MEMBER_PORT_MAP_PORT_3	UINT32_C(0x8)
+	/* rsvd3 is 4 b */
+	#define HWRM_FUNC_LAG_MODE_QCFG_OUTPUT_MEMBER_PORT_MAP_RSVD3_MASK UINT32_C(0xf0)
+	#define HWRM_FUNC_LAG_MODE_QCFG_OUTPUT_MEMBER_PORT_MAP_RSVD3_SFT  4
+	/* Link aggregation mode being used. */
+	uint8_t	link_aggr_mode;
+	/* active active mode. */
+	#define HWRM_FUNC_LAG_MODE_QCFG_OUTPUT_AGGR_MODE_ACTIVE_ACTIVE UINT32_C(0x1)
+	/* active backup mode. */
+	#define HWRM_FUNC_LAG_MODE_QCFG_OUTPUT_AGGR_MODE_ACTIVE_BACKUP UINT32_C(0x2)
+	/* Balance XOR mode. */
+	#define HWRM_FUNC_LAG_MODE_QCFG_OUTPUT_AGGR_MODE_BALANCE_XOR   UINT32_C(0x3)
+	/* 802.3AD mode. */
+	#define HWRM_FUNC_LAG_MODE_QCFG_OUTPUT_AGGR_MODE_802_3_AD	UINT32_C(0x4)
+	#define HWRM_FUNC_LAG_MODE_QCFG_OUTPUT_AGGR_MODE_LAST	HWRM_FUNC_LAG_MODE_QCFG_OUTPUT_AGGR_MODE_802_3_AD
+	uint8_t	unused_0[3];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_lag_mode_qcfg_output_t, *phwrm_func_lag_mode_qcfg_output_t;
+
+/***********************
+ * hwrm_func_vlan_qcfg *
+ ***********************/
+
+
+/* hwrm_func_vlan_qcfg_input (size:192b/24B) */
+
+typedef struct hwrm_func_vlan_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/*
+	 * Function ID of the function that is being
+	 * configured.
+	 * If set to 0xFF... (All Fs), then the configuration is
+	 * for the requesting function.
+	 */
+	uint16_t	fid;
+	uint8_t	unused_0[6];
+} hwrm_func_vlan_qcfg_input_t, *phwrm_func_vlan_qcfg_input_t;
+
+/* hwrm_func_vlan_qcfg_output (size:320b/40B) */
+
+typedef struct hwrm_func_vlan_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint64_t	unused_0;
+	/* S-TAG VLAN identifier configured for the function. */
+	uint16_t	stag_vid;
+	/* S-TAG PCP value configured for the function. */
+	uint8_t	stag_pcp;
+	uint8_t	unused_1;
+	/*
+	 * S-TAG TPID value configured for the function. This field is
+	 * specified in network byte order.
+	 */
+	uint16_t	stag_tpid;
+	/* C-TAG VLAN identifier configured for the function. */
+	uint16_t	ctag_vid;
+	/* C-TAG PCP value configured for the function. */
+	uint8_t	ctag_pcp;
+	uint8_t	unused_2;
+	/*
+	 * C-TAG TPID value configured for the function. This field is
+	 * specified in network byte order.
+	 */
+	uint16_t	ctag_tpid;
+	/* Future use. */
+	uint32_t	rsvd2;
+	/* Future use. */
+	uint32_t	rsvd3;
+	uint8_t	unused_3[3];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_vlan_qcfg_output_t, *phwrm_func_vlan_qcfg_output_t;
+
+/**********************
+ * hwrm_func_vlan_cfg *
+ **********************/
+
+
+/* hwrm_func_vlan_cfg_input (size:384b/48B) */
+
+typedef struct hwrm_func_vlan_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/*
+	 * Function ID of the function that is being
+	 * configured.
+	 * If set to 0xFF... (All Fs), then the configuration is
+	 * for the requesting function.
+	 */
+	uint16_t	fid;
+	uint8_t	unused_0[2];
+	uint32_t	enables;
+	/*
+	 * This bit must be '1' for the stag_vid field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_VLAN_CFG_INPUT_ENABLES_STAG_VID	UINT32_C(0x1)
+	/*
+	 * This bit must be '1' for the ctag_vid field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_VLAN_CFG_INPUT_ENABLES_CTAG_VID	UINT32_C(0x2)
+	/*
+	 * This bit must be '1' for the stag_pcp field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_VLAN_CFG_INPUT_ENABLES_STAG_PCP	UINT32_C(0x4)
+	/*
+	 * This bit must be '1' for the ctag_pcp field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_VLAN_CFG_INPUT_ENABLES_CTAG_PCP	UINT32_C(0x8)
+	/*
+	 * This bit must be '1' for the stag_tpid field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_VLAN_CFG_INPUT_ENABLES_STAG_TPID	UINT32_C(0x10)
+	/*
+	 * This bit must be '1' for the ctag_tpid field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_VLAN_CFG_INPUT_ENABLES_CTAG_TPID	UINT32_C(0x20)
+	/* S-TAG VLAN identifier configured for the function. */
+	uint16_t	stag_vid;
+	/* S-TAG PCP value configured for the function. */
+	uint8_t	stag_pcp;
+	uint8_t	unused_1;
+	/*
+	 * S-TAG TPID value configured for the function. This field is
+	 * specified in network byte order.
+	 */
+	uint16_t	stag_tpid;
+	/* C-TAG VLAN identifier configured for the function. */
+	uint16_t	ctag_vid;
+	/* C-TAG PCP value configured for the function. */
+	uint8_t	ctag_pcp;
+	uint8_t	unused_2;
+	/*
+	 * C-TAG TPID value configured for the function. This field is
+	 * specified in network byte order.
+	 */
+	uint16_t	ctag_tpid;
+	/* Future use. */
+	uint32_t	rsvd1;
+	/* Future use. */
+	uint32_t	rsvd2;
+	uint8_t	unused_3[4];
+} hwrm_func_vlan_cfg_input_t, *phwrm_func_vlan_cfg_input_t;
+
+/* hwrm_func_vlan_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_func_vlan_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_vlan_cfg_output_t, *phwrm_func_vlan_cfg_output_t;
+
+/*******************************
+ * hwrm_func_vf_vnic_ids_query *
+ *******************************/
+
+
+/* hwrm_func_vf_vnic_ids_query_input (size:256b/32B) */
+
+typedef struct hwrm_func_vf_vnic_ids_query_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/*
+	 * This value is used to identify a Virtual Function (VF).
+	 * The scope of VF ID is local within a PF.
+	 */
+	uint16_t	vf_id;
+	uint8_t	unused_0[2];
+	/* Max number of vnic ids in vnic id table */
+	uint32_t	max_vnic_id_cnt;
+	/* This is the address for VF VNIC ID table */
+	uint64_t	vnic_id_tbl_addr;
+} hwrm_func_vf_vnic_ids_query_input_t, *phwrm_func_vf_vnic_ids_query_input_t;
+
+/* hwrm_func_vf_vnic_ids_query_output (size:128b/16B) */
+
+typedef struct hwrm_func_vf_vnic_ids_query_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/*
+	 * Actual number of vnic ids
+	 *
+	 * Each VNIC ID is written as a 32-bit number.
+	 */
+	uint32_t	vnic_id_cnt;
+	uint8_t	unused_0[3];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_vf_vnic_ids_query_output_t, *phwrm_func_vf_vnic_ids_query_output_t;
+
+/***********************
+ * hwrm_func_vf_bw_cfg *
+ ***********************/
+
+
+/* hwrm_func_vf_bw_cfg_input (size:960b/120B) */
+
+typedef struct hwrm_func_vf_bw_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/*
+	 * The number of VF functions that are being configured.
+	 * The cmd space allows up to 50 VFs' BW to be configured with one cmd.
+	 */
+	uint16_t	num_vfs;
+	uint16_t	unused[3];
+	/* These 16-bit fields contain the VF fid and the rate scale percentage. */
+	uint16_t	vfn[48];
+	/* The physical VF id the adjustment will be made to. */
+	#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_VFID_MASK	UINT32_C(0xfff)
+	#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_VFID_SFT	0
+	/*
+	 * This field configures the rate scale percentage of the VF as specified
+	 * by the physical VF id.
+	 */
+	#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_MASK	UINT32_C(0xf000)
+	#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_SFT	12
+	/* 0% of the max tx rate */
+		#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_PCT_0	(UINT32_C(0x0) << 12)
+	/* 6.66% of the max tx rate */
+		#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_PCT_6_66   (UINT32_C(0x1) << 12)
+	/* 13.33% of the max tx rate */
+		#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_PCT_13_33  (UINT32_C(0x2) << 12)
+	/* 20% of the max tx rate */
+		#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_PCT_20	(UINT32_C(0x3) << 12)
+	/* 26.66% of the max tx rate */
+		#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_PCT_26_66  (UINT32_C(0x4) << 12)
+	/* 33% of the max tx rate */
+		#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_PCT_33_33  (UINT32_C(0x5) << 12)
+	/* 40% of the max tx rate */
+		#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_PCT_40	(UINT32_C(0x6) << 12)
+	/* 46.66% of the max tx rate */
+		#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_PCT_46_66  (UINT32_C(0x7) << 12)
+	/* 53.33% of the max tx rate */
+		#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_PCT_53_33  (UINT32_C(0x8) << 12)
+	/* 60% of the max tx rate */
+		#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_PCT_60	(UINT32_C(0x9) << 12)
+	/* 66.66% of the max tx rate */
+		#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_PCT_66_66  (UINT32_C(0xa) << 12)
+	/* 53.33% of the max tx rate */
+		#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_PCT_73_33  (UINT32_C(0xb) << 12)
+	/* 80% of the max tx rate */
+		#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_PCT_80	(UINT32_C(0xc) << 12)
+	/* 86.66% of the max tx rate */
+		#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_PCT_86_66  (UINT32_C(0xd) << 12)
+	/* 93.33% of the max tx rate */
+		#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_PCT_93_33  (UINT32_C(0xe) << 12)
+	/* 100% of the max tx rate */
+		#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_PCT_100	(UINT32_C(0xf) << 12)
+		#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_LAST	HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_PCT_100
+} hwrm_func_vf_bw_cfg_input_t, *phwrm_func_vf_bw_cfg_input_t;
+
+/* hwrm_func_vf_bw_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_func_vf_bw_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_vf_bw_cfg_output_t, *phwrm_func_vf_bw_cfg_output_t;
+
+/************************
+ * hwrm_func_vf_bw_qcfg *
+ ************************/
+
+
+/* hwrm_func_vf_bw_qcfg_input (size:960b/120B) */
+
+typedef struct hwrm_func_vf_bw_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/*
+	 * The number of VF functions that are being queried.
+	 * The inline response space allows the host to query up to 50 VFs'
+	 * rate scale percentage
+	 */
+	uint16_t	num_vfs;
+	uint16_t	unused[3];
+	/* These 16-bit fields contain the VF fid */
+	uint16_t	vfn[48];
+	/* The physical VF id of interest */
+	#define HWRM_FUNC_VF_BW_QCFG_INPUT_VFN_VFID_MASK UINT32_C(0xfff)
+	#define HWRM_FUNC_VF_BW_QCFG_INPUT_VFN_VFID_SFT 0
+} hwrm_func_vf_bw_qcfg_input_t, *phwrm_func_vf_bw_qcfg_input_t;
+
+/* hwrm_func_vf_bw_qcfg_output (size:960b/120B) */
+
+typedef struct hwrm_func_vf_bw_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/*
+	 * The number of VF functions that are being queried.
+	 * The inline response space allows the host to query up to 50 VFs'
+	 * rate scale percentage.
+	 */
+	uint16_t	num_vfs;
+	uint16_t	unused[3];
+	/* These 16-bit fields contain the VF fid and the rate scale percentage. */
+	uint16_t	vfn[48];
+	/* The physical VF id the adjustment will be made to. */
+	#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_VFID_MASK	UINT32_C(0xfff)
+	#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_VFID_SFT	0
+	/*
+	 * This field configures the rate scale percentage of the VF as specified
+	 * by the physical VF id.
+	 */
+	#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_MASK	UINT32_C(0xf000)
+	#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_SFT	12
+	/* 0% of the max tx rate */
+		#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_PCT_0	(UINT32_C(0x0) << 12)
+	/* 6.66% of the max tx rate */
+		#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_PCT_6_66   (UINT32_C(0x1) << 12)
+	/* 13.33% of the max tx rate */
+		#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_PCT_13_33  (UINT32_C(0x2) << 12)
+	/* 20% of the max tx rate */
+		#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_PCT_20	(UINT32_C(0x3) << 12)
+	/* 26.66% of the max tx rate */
+		#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_PCT_26_66  (UINT32_C(0x4) << 12)
+	/* 33% of the max tx rate */
+		#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_PCT_33_33  (UINT32_C(0x5) << 12)
+	/* 40% of the max tx rate */
+		#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_PCT_40	(UINT32_C(0x6) << 12)
+	/* 46.66% of the max tx rate */
+		#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_PCT_46_66  (UINT32_C(0x7) << 12)
+	/* 53.33% of the max tx rate */
+		#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_PCT_53_33  (UINT32_C(0x8) << 12)
+	/* 60% of the max tx rate */
+		#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_PCT_60	(UINT32_C(0x9) << 12)
+	/* 66.66% of the max tx rate */
+		#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_PCT_66_66  (UINT32_C(0xa) << 12)
+	/* 53.33% of the max tx rate */
+		#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_PCT_73_33  (UINT32_C(0xb) << 12)
+	/* 80% of the max tx rate */
+		#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_PCT_80	(UINT32_C(0xc) << 12)
+	/* 86.66% of the max tx rate */
+		#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_PCT_86_66  (UINT32_C(0xd) << 12)
+	/* 93.33% of the max tx rate */
+		#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_PCT_93_33  (UINT32_C(0xe) << 12)
+	/* 100% of the max tx rate */
+		#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_PCT_100	(UINT32_C(0xf) << 12)
+		#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_LAST	HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_PCT_100
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_vf_bw_qcfg_output_t, *phwrm_func_vf_bw_qcfg_output_t;
+
+/***************************
+ * hwrm_func_drv_if_change *
+ ***************************/
+
+
+/* hwrm_func_drv_if_change_input (size:192b/24B) */
+
+typedef struct hwrm_func_drv_if_change_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	flags;
+	/*
+	 * When this bit is '1', the function driver is indicating
+	 * that the IF state is changing to UP state. The call should
+	 * be made at the beginning of the driver's open call before
+	 * resources are allocated. After making the call, the driver
+	 * should check the response to see if any resources may have
+	 * changed (see the response below). If the driver fails
+	 * the open call, the driver should make this call again with
+	 * this bit cleared to indicate that the IF state is not UP.
+	 * During the driver's close call when the IF state is changing
+	 * to DOWN, the driver should make this call with the bit cleared
+	 * after all resources have been freed.
+	 */
+	#define HWRM_FUNC_DRV_IF_CHANGE_INPUT_FLAGS_UP	UINT32_C(0x1)
+	uint32_t	unused;
+} hwrm_func_drv_if_change_input_t, *phwrm_func_drv_if_change_input_t;
+
+/* hwrm_func_drv_if_change_output (size:128b/16B) */
+
+typedef struct hwrm_func_drv_if_change_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint32_t	flags;
+	/*
+	 * When this bit is '1', it indicates that the resources reserved
+	 * for this function may have changed. The driver should check
+	 * resource capabilities and reserve resources again before
+	 * allocating resources.
+	 */
+	#define HWRM_FUNC_DRV_IF_CHANGE_OUTPUT_FLAGS_RESC_CHANGE	UINT32_C(0x1)
+	/*
+	 * When this bit is '1', it indicates that the firmware got changed /
+	 * reset. The driver should do complete re-initialization when that
+	 * bit is set.
+	 */
+	#define HWRM_FUNC_DRV_IF_CHANGE_OUTPUT_FLAGS_HOT_FW_RESET_DONE	UINT32_C(0x2)
+	/*
+	 * When this bit is '1', it indicates that capabilities
+	 * for this function may have changed. The driver should
+	 * query for changes to capabilities.
+	 * The CAPS_CHANGE bit will only be set when it is safe for the
+	 * driver to completely re-initialize all resources for the function
+	 * including any children VFs.
+	 */
+	#define HWRM_FUNC_DRV_IF_CHANGE_OUTPUT_FLAGS_CAPS_CHANGE	UINT32_C(0x4)
+	uint8_t	unused_0[3];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_drv_if_change_output_t, *phwrm_func_drv_if_change_output_t;
+
+/*******************************
+ * hwrm_func_host_pf_ids_query *
+ *******************************/
+
+
+/* hwrm_func_host_pf_ids_query_input (size:192b/24B) */
+
+typedef struct hwrm_func_host_pf_ids_query_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint8_t	host;
+	/*
+	 * # If this bit is set to '1', the query will contain PF(s)
+	 * belongs to SOC host.
+	 */
+	#define HWRM_FUNC_HOST_PF_IDS_QUERY_INPUT_HOST_SOC	UINT32_C(0x1)
+	/*
+	 * # If this bit is set to '1', the query will contain PF(s)
+	 * belongs to EP0 host.
+	 */
+	#define HWRM_FUNC_HOST_PF_IDS_QUERY_INPUT_HOST_EP_0	UINT32_C(0x2)
+	/*
+	 * # If this bit is set to '1', the query will contain PF(s)
+	 * belongs to EP1 host.
+	 */
+	#define HWRM_FUNC_HOST_PF_IDS_QUERY_INPUT_HOST_EP_1	UINT32_C(0x4)
+	/*
+	 * # If this bit is set to '1', the query will contain PF(s)
+	 * belongs to EP2 host.
+	 */
+	#define HWRM_FUNC_HOST_PF_IDS_QUERY_INPUT_HOST_EP_2	UINT32_C(0x8)
+	/*
+	 * # If this bit is set to '1', the query will contain PF(s)
+	 * belongs to EP3 host.
+	 */
+	#define HWRM_FUNC_HOST_PF_IDS_QUERY_INPUT_HOST_EP_3	UINT32_C(0x10)
+	/*
+	 * This provides a filter of what PF(s) will be returned in the
+	 * query..
+	 */
+	uint8_t	filter;
+	/*
+	 * all available PF(s) belong to the host(s) (defined in the
+	 * host field). This includes the hidden PFs.
+	 */
+	#define HWRM_FUNC_HOST_PF_IDS_QUERY_INPUT_FILTER_ALL  UINT32_C(0x0)
+	/*
+	 * all available PF(s) belong to the host(s) (defined in the
+	 * host field) that is available for L2 traffic.
+	 */
+	#define HWRM_FUNC_HOST_PF_IDS_QUERY_INPUT_FILTER_L2   UINT32_C(0x1)
+	/*
+	 * all available PF(s) belong to the host(s) (defined in the
+	 * host field) that is available for ROCE traffic.
+	 */
+	#define HWRM_FUNC_HOST_PF_IDS_QUERY_INPUT_FILTER_ROCE UINT32_C(0x2)
+	#define HWRM_FUNC_HOST_PF_IDS_QUERY_INPUT_FILTER_LAST HWRM_FUNC_HOST_PF_IDS_QUERY_INPUT_FILTER_ROCE
+	uint8_t	unused_1[6];
+} hwrm_func_host_pf_ids_query_input_t, *phwrm_func_host_pf_ids_query_input_t;
+
+/* hwrm_func_host_pf_ids_query_output (size:128b/16B) */
+
+typedef struct hwrm_func_host_pf_ids_query_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* This provides the first PF ID of the device. */
+	uint16_t	first_pf_id;
+	uint16_t	pf_ordinal_mask;
+	/*
+	 * When this bit is '1', it indicates first PF belongs to one of
+	 * the hosts defined in the input request.
+	 */
+	#define HWRM_FUNC_HOST_PF_IDS_QUERY_OUTPUT_PF_ORDINAL_MASK_FUNC_0	UINT32_C(0x1)
+	/*
+	 * When this bit is '1', it indicates 2nd PF belongs to one of the
+	 * hosts defined in the input request.
+	 */
+	#define HWRM_FUNC_HOST_PF_IDS_QUERY_OUTPUT_PF_ORDINAL_MASK_FUNC_1	UINT32_C(0x2)
+	/*
+	 * When this bit is '1', it indicates 3rd PF belongs to one of the
+	 * hosts defined in the input request.
+	 */
+	#define HWRM_FUNC_HOST_PF_IDS_QUERY_OUTPUT_PF_ORDINAL_MASK_FUNC_2	UINT32_C(0x4)
+	/*
+	 * When this bit is '1', it indicates 4th PF belongs to one of the
+	 * hosts defined in the input request.
+	 */
+	#define HWRM_FUNC_HOST_PF_IDS_QUERY_OUTPUT_PF_ORDINAL_MASK_FUNC_3	UINT32_C(0x8)
+	/*
+	 * When this bit is '1', it indicates 5th PF belongs to one of the
+	 * hosts defined in the input request.
+	 */
+	#define HWRM_FUNC_HOST_PF_IDS_QUERY_OUTPUT_PF_ORDINAL_MASK_FUNC_4	UINT32_C(0x10)
+	/*
+	 * When this bit is '1', it indicates 6th PF belongs to one of the
+	 * hosts defined in the input request.
+	 */
+	#define HWRM_FUNC_HOST_PF_IDS_QUERY_OUTPUT_PF_ORDINAL_MASK_FUNC_5	UINT32_C(0x20)
+	/*
+	 * When this bit is '1', it indicates 7th PF belongs to one of the
+	 * hosts defined in the input request.
+	 */
+	#define HWRM_FUNC_HOST_PF_IDS_QUERY_OUTPUT_PF_ORDINAL_MASK_FUNC_6	UINT32_C(0x40)
+	/*
+	 * When this bit is '1', it indicates 8th PF belongs to one of the
+	 * hosts defined in the input request.
+	 */
+	#define HWRM_FUNC_HOST_PF_IDS_QUERY_OUTPUT_PF_ORDINAL_MASK_FUNC_7	UINT32_C(0x80)
+	/*
+	 * When this bit is '1', it indicates 9th PF belongs to one of the
+	 * hosts defined in the input request.
+	 */
+	#define HWRM_FUNC_HOST_PF_IDS_QUERY_OUTPUT_PF_ORDINAL_MASK_FUNC_8	UINT32_C(0x100)
+	/*
+	 * When this bit is '1', it indicates 10th PF belongs to one of the
+	 * hosts defined in the input request.
+	 */
+	#define HWRM_FUNC_HOST_PF_IDS_QUERY_OUTPUT_PF_ORDINAL_MASK_FUNC_9	UINT32_C(0x200)
+	/*
+	 * When this bit is '1', it indicates 11th PF belongs to one of the
+	 * hosts defined in the input request.
+	 */
+	#define HWRM_FUNC_HOST_PF_IDS_QUERY_OUTPUT_PF_ORDINAL_MASK_FUNC_10	UINT32_C(0x400)
+	/*
+	 * When this bit is '1', it indicates 12th PF belongs to one of the
+	 * hosts defined in the input request.
+	 */
+	#define HWRM_FUNC_HOST_PF_IDS_QUERY_OUTPUT_PF_ORDINAL_MASK_FUNC_11	UINT32_C(0x800)
+	/*
+	 * When this bit is '1', it indicates 13th PF belongs to one of the
+	 * hosts defined in the input request.
+	 */
+	#define HWRM_FUNC_HOST_PF_IDS_QUERY_OUTPUT_PF_ORDINAL_MASK_FUNC_12	UINT32_C(0x1000)
+	/*
+	 * When this bit is '1', it indicates 14th PF belongs to one of the
+	 * hosts defined in the input request.
+	 */
+	#define HWRM_FUNC_HOST_PF_IDS_QUERY_OUTPUT_PF_ORDINAL_MASK_FUNC_13	UINT32_C(0x2000)
+	/*
+	 * When this bit is '1', it indicates 15th PF belongs to one of the
+	 * hosts defined in the input request.
+	 */
+	#define HWRM_FUNC_HOST_PF_IDS_QUERY_OUTPUT_PF_ORDINAL_MASK_FUNC_14	UINT32_C(0x4000)
+	/*
+	 * When this bit is '1', it indicates 16th PF belongs to one of the
+	 * hosts defined in the input request.
+	 */
+	#define HWRM_FUNC_HOST_PF_IDS_QUERY_OUTPUT_PF_ORDINAL_MASK_FUNC_15	UINT32_C(0x8000)
+	uint8_t	unused_1[3];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_host_pf_ids_query_output_t, *phwrm_func_host_pf_ids_query_output_t;
+
+/*********************
+ * hwrm_func_spd_cfg *
+ *********************/
+
+
+/* hwrm_func_spd_cfg_input (size:384b/48B) */
+
+typedef struct hwrm_func_spd_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	flags;
+	/* Set this bit is '1' to enable the SPD datapath forwarding. */
+	#define HWRM_FUNC_SPD_CFG_INPUT_FLAGS_FWD_ENABLE	UINT32_C(0x1)
+	/* Set this bit is '1' to disable the SPD datapath forwarding. */
+	#define HWRM_FUNC_SPD_CFG_INPUT_FLAGS_FWD_DISABLE	UINT32_C(0x2)
+	/*
+	 * Set this bit is '1' to enable the SPD datapath checksum
+	 * feature.
+	 */
+	#define HWRM_FUNC_SPD_CFG_INPUT_FLAGS_CSUM_ENABLE	UINT32_C(0x4)
+	/*
+	 * Set this bit is '1' to disable the SPD datapath checksum
+	 * feature.
+	 */
+	#define HWRM_FUNC_SPD_CFG_INPUT_FLAGS_CSUM_DISABLE	UINT32_C(0x8)
+	/*
+	 * Set this bit is '1' to enable the SPD datapath debug
+	 * feature.
+	 */
+	#define HWRM_FUNC_SPD_CFG_INPUT_FLAGS_DBG_ENABLE	UINT32_C(0x10)
+	/*
+	 * Set this bit is '1' to disable the SPD datapath debug
+	 * feature.
+	 */
+	#define HWRM_FUNC_SPD_CFG_INPUT_FLAGS_DBG_DISABLE	UINT32_C(0x20)
+	uint32_t	enables;
+	/*
+	 * This bit must be '1' for the ethertype field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_SPD_CFG_INPUT_ENABLES_ETHERTYPE		UINT32_C(0x1)
+	/*
+	 * This bit must be '1' for the hash_mode_flags field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_SPD_CFG_INPUT_ENABLES_HASH_MODE_FLAGS	UINT32_C(0x2)
+	/*
+	 * This bit must be '1' for the hash_type field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_SPD_CFG_INPUT_ENABLES_HASH_TYPE		UINT32_C(0x4)
+	/*
+	 * This bit must be '1' for the ring_tbl_addr field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_SPD_CFG_INPUT_ENABLES_RING_TBL_ADDR	UINT32_C(0x8)
+	/*
+	 * This bit must be '1' for the hash_key_tbl_addr field to be
+	 * configured.
+	 */
+	#define HWRM_FUNC_SPD_CFG_INPUT_ENABLES_HASH_KEY_TBL_ADDR	UINT32_C(0x10)
+	/*
+	 * Ethertype value used in the encapsulated SPD packet header.
+	 * The user must choose a value that is not conflicting with
+	 * publicly defined ethertype values. By default, the ethertype
+	 * value of 0xffff is used if there is no user specified value.
+	 */
+	uint16_t	ethertype;
+	/* Flags to specify different RSS hash modes. */
+	uint8_t	hash_mode_flags;
+	/*
+	 * When this bit is '1', it indicates using current RSS
+	 * hash mode setting configured in the device.
+	 */
+	#define HWRM_FUNC_SPD_CFG_INPUT_HASH_MODE_FLAGS_DEFAULT	UINT32_C(0x1)
+	/*
+	 * When this bit is '1', it indicates requesting support of
+	 * RSS hashing over innermost 4 tuples {l3.src, l3.dest,
+	 * l4.src, l4.dest} for tunnel packets. For none-tunnel
+	 * packets, the RSS hash is computed over the normal
+	 * src/dest l3 and src/dest l4 headers.
+	 */
+	#define HWRM_FUNC_SPD_CFG_INPUT_HASH_MODE_FLAGS_INNERMOST_4	UINT32_C(0x2)
+	/*
+	 * When this bit is '1', it indicates requesting support of
+	 * RSS hashing over innermost 2 tuples {l3.src, l3.dest} for
+	 * tunnel packets. For none-tunnel packets, the RSS hash is
+	 * computed over the normal src/dest l3 headers.
+	 */
+	#define HWRM_FUNC_SPD_CFG_INPUT_HASH_MODE_FLAGS_INNERMOST_2	UINT32_C(0x4)
+	/*
+	 * When this bit is '1', it indicates requesting support of
+	 * RSS hashing over outermost 4 tuples {t_l3.src, t_l3.dest,
+	 * t_l4.src, t_l4.dest} for tunnel packets. For none-tunnel
+	 * packets, the RSS hash is computed over the normal
+	 * src/dest l3 and src/dest l4 headers.
+	 */
+	#define HWRM_FUNC_SPD_CFG_INPUT_HASH_MODE_FLAGS_OUTERMOST_4	UINT32_C(0x8)
+	/*
+	 * When this bit is '1', it indicates requesting support of
+	 * RSS hashing over outermost 2 tuples {t_l3.src, t_l3.dest} for
+	 * tunnel packets. For none-tunnel packets, the RSS hash is
+	 * computed over the normal src/dest l3 headers.
+	 */
+	#define HWRM_FUNC_SPD_CFG_INPUT_HASH_MODE_FLAGS_OUTERMOST_2	UINT32_C(0x10)
+	uint8_t	unused_1;
+	uint32_t	hash_type;
+	/*
+	 * When this bit is '1', the RSS hash shall be computed
+	 * over source and destination IPv4 addresses of IPv4
+	 * packets.
+	 */
+	#define HWRM_FUNC_SPD_CFG_INPUT_HASH_TYPE_IPV4	UINT32_C(0x1)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed
+	 * over source/destination IPv4 addresses and
+	 * source/destination ports of TCP/IPv4 packets.
+	 */
+	#define HWRM_FUNC_SPD_CFG_INPUT_HASH_TYPE_TCP_IPV4	UINT32_C(0x2)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed
+	 * over source/destination IPv4 addresses and
+	 * source/destination ports of UDP/IPv4 packets.
+	 */
+	#define HWRM_FUNC_SPD_CFG_INPUT_HASH_TYPE_UDP_IPV4	UINT32_C(0x4)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed
+	 * over source and destination IPv4 addresses of IPv6
+	 * packets.
+	 */
+	#define HWRM_FUNC_SPD_CFG_INPUT_HASH_TYPE_IPV6	UINT32_C(0x8)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed
+	 * over source/destination IPv6 addresses and
+	 * source/destination ports of TCP/IPv6 packets.
+	 */
+	#define HWRM_FUNC_SPD_CFG_INPUT_HASH_TYPE_TCP_IPV6	UINT32_C(0x10)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed
+	 * over source/destination IPv6 addresses and
+	 * source/destination ports of UDP/IPv6 packets.
+	 */
+	#define HWRM_FUNC_SPD_CFG_INPUT_HASH_TYPE_UDP_IPV6	UINT32_C(0x20)
+	/* This is the address for rss ring group table */
+	uint64_t	ring_grp_tbl_addr;
+	/* This is the address for rss hash key table */
+	uint64_t	hash_key_tbl_addr;
+} hwrm_func_spd_cfg_input_t, *phwrm_func_spd_cfg_input_t;
+
+/* hwrm_func_spd_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_func_spd_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_spd_cfg_output_t, *phwrm_func_spd_cfg_output_t;
+
+/**********************
+ * hwrm_func_spd_qcfg *
+ **********************/
+
+
+/* hwrm_func_spd_qcfg_input (size:128b/16B) */
+
+typedef struct hwrm_func_spd_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+} hwrm_func_spd_qcfg_input_t, *phwrm_func_spd_qcfg_input_t;
+
+/* hwrm_func_spd_qcfg_output (size:512b/64B) */
+
+typedef struct hwrm_func_spd_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint32_t	flags;
+	/*
+	 * The SPD datapath forwarding is currently enabled when this
+	 * flag is set to '1'.
+	 */
+	#define HWRM_FUNC_SPD_QCFG_OUTPUT_FLAGS_FWD_ENABLED	UINT32_C(0x1)
+	/*
+	 * The SPD datapath checksum feature is currently enabled when
+	 * this flag is set to '1'.
+	 */
+	#define HWRM_FUNC_SPD_QCFG_OUTPUT_FLAGS_CSUM_ENABLED	UINT32_C(0x2)
+	/*
+	 * The SPD datapath debug feature is currently enabled when
+	 * this flag is set to '1'.
+	 */
+	#define HWRM_FUNC_SPD_QCFG_OUTPUT_FLAGS_DBG_ENABLED	UINT32_C(0x4)
+	uint32_t	hash_type;
+	/*
+	 * When this bit is '1', the RSS hash shall be computed
+	 * over source and destination IPv4 addresses of IPv4
+	 * packets.
+	 */
+	#define HWRM_FUNC_SPD_QCFG_OUTPUT_HASH_TYPE_IPV4	UINT32_C(0x1)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed
+	 * over source/destination IPv4 addresses and
+	 * source/destination ports of TCP/IPv4 packets.
+	 */
+	#define HWRM_FUNC_SPD_QCFG_OUTPUT_HASH_TYPE_TCP_IPV4	UINT32_C(0x2)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed
+	 * over source/destination IPv4 addresses and
+	 * source/destination ports of UDP/IPv4 packets.
+	 */
+	#define HWRM_FUNC_SPD_QCFG_OUTPUT_HASH_TYPE_UDP_IPV4	UINT32_C(0x4)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed
+	 * over source and destination IPv4 addresses of IPv6
+	 * packets.
+	 */
+	#define HWRM_FUNC_SPD_QCFG_OUTPUT_HASH_TYPE_IPV6	UINT32_C(0x8)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed
+	 * over source/destination IPv6 addresses and
+	 * source/destination ports of TCP/IPv6 packets.
+	 */
+	#define HWRM_FUNC_SPD_QCFG_OUTPUT_HASH_TYPE_TCP_IPV6	UINT32_C(0x10)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed
+	 * over source/destination IPv6 addresses and
+	 * source/destination ports of UDP/IPv6 packets.
+	 */
+	#define HWRM_FUNC_SPD_QCFG_OUTPUT_HASH_TYPE_UDP_IPV6	UINT32_C(0x20)
+	/* This is the value of rss hash key */
+	uint32_t	hash_key[10];
+	/* Flags to specify different RSS hash modes. */
+	uint8_t	hash_mode_flags;
+	/*
+	 * When this bit is '1', it indicates using current RSS
+	 * hash mode setting configured in the device.
+	 */
+	#define HWRM_FUNC_SPD_QCFG_OUTPUT_HASH_MODE_FLAGS_DEFAULT	UINT32_C(0x1)
+	/*
+	 * When this bit is '1', it indicates requesting support of
+	 * RSS hashing over innermost 4 tuples {l3.src, l3.dest,
+	 * l4.src, l4.dest} for tunnel packets. For none-tunnel
+	 * packets, the RSS hash is computed over the normal
+	 * src/dest l3 and src/dest l4 headers.
+	 */
+	#define HWRM_FUNC_SPD_QCFG_OUTPUT_HASH_MODE_FLAGS_INNERMOST_4	UINT32_C(0x2)
+	/*
+	 * When this bit is '1', it indicates requesting support of
+	 * RSS hashing over innermost 2 tuples {l3.src, l3.dest} for
+	 * tunnel packets. For none-tunnel packets, the RSS hash is
+	 * computed over the normal src/dest l3 headers.
+	 */
+	#define HWRM_FUNC_SPD_QCFG_OUTPUT_HASH_MODE_FLAGS_INNERMOST_2	UINT32_C(0x4)
+	/*
+	 * When this bit is '1', it indicates requesting support of
+	 * RSS hashing over outermost 4 tuples {t_l3.src, t_l3.dest,
+	 * t_l4.src, t_l4.dest} for tunnel packets. For none-tunnel
+	 * packets, the RSS hash is computed over the normal
+	 * src/dest l3 and src/dest l4 headers.
+	 */
+	#define HWRM_FUNC_SPD_QCFG_OUTPUT_HASH_MODE_FLAGS_OUTERMOST_4	UINT32_C(0x8)
+	/*
+	 * When this bit is '1', it indicates requesting support of
+	 * RSS hashing over outermost 2 tuples {t_l3.src, t_l3.dest} for
+	 * tunnel packets. For none-tunnel packets, the RSS hash is
+	 * computed over the normal src/dest l3 headers.
+	 */
+	#define HWRM_FUNC_SPD_QCFG_OUTPUT_HASH_MODE_FLAGS_OUTERMOST_2	UINT32_C(0x10)
+	uint8_t	unused_1;
+	/*
+	 * Ethertype value used in the encapsulated SPD packet header.
+	 * The user must choose a value that is not conflicting with
+	 * publicly defined ethertype values. By default, the ethertype
+	 * value of 0xffff is used if there is no user specified value.
+	 */
+	uint16_t	ethertype;
+	uint8_t	unused_2[3];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_func_spd_qcfg_output_t, *phwrm_func_spd_qcfg_output_t;
+
+/*********************
+ * hwrm_port_phy_cfg *
+ *********************/
+
+
+/* hwrm_port_phy_cfg_input (size:512b/64B) */
+
+typedef struct hwrm_port_phy_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	flags;
+	/*
+	 * When this bit is set to '1', the PHY for the port shall
+	 * be reset.
+	 *
+	 * # If this bit is set to 1, then the HWRM shall reset the
+	 * PHY after applying PHY configuration changes specified
+	 * in this command.
+	 * # In order to guarantee that PHY configuration changes
+	 * specified in this command take effect, the HWRM
+	 * client should set this flag to 1.
+	 * # If this bit is not set to 1, then the HWRM may reset
+	 * the PHY depending on the current PHY configuration and
+	 * settings specified in this command.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_RESET_PHY		UINT32_C(0x1)
+	/* deprecated bit. Do not use!!! */
+	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_DEPRECATED		UINT32_C(0x2)
+	/*
+	 * When this bit is set to '1', and the force_pam4_link_speed
+	 * bit in the 'enables' field is '0', the link shall be forced
+	 * to the force_link_speed value.
+	 *
+	 * When this bit is set to '1', and the force_pam4_link_speed
+	 * bit in the 'enables' field is '1', the link shall be forced
+	 * to the force_pam4_link_speed value.
+	 *
+	 * When this bit is set to '1', the HWRM client should
+	 * not enable any of the auto negotiation related
+	 * fields represented by auto_XXX fields in this command.
+	 * When this bit is set to '1' and the HWRM client has
+	 * enabled a auto_XXX field in this command, then the
+	 * HWRM shall ignore the enabled auto_XXX field.
+	 *
+	 * When this bit is set to zero, the link
+	 * shall be allowed to autoneg.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_FORCE			UINT32_C(0x4)
+	/*
+	 * When this bit is set to '1', the auto-negotiation process
+	 * shall be restarted on the link.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_RESTART_AUTONEG		UINT32_C(0x8)
+	/*
+	 * When this bit is set to '1', Energy Efficient Ethernet
+	 * (EEE) is requested to be enabled on this link.
+	 * If EEE is not supported on this port, then this flag
+	 * shall be ignored by the HWRM.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_EEE_ENABLE		UINT32_C(0x10)
+	/*
+	 * When this bit is set to '1', Energy Efficient Ethernet
+	 * (EEE) is requested to be disabled on this link.
+	 * If EEE is not supported on this port, then this flag
+	 * shall be ignored by the HWRM.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_EEE_DISABLE		UINT32_C(0x20)
+	/*
+	 * When this bit is set to '1' and EEE is enabled on this
+	 * link, then TX LPI is requested to be enabled on the link.
+	 * If EEE is not supported on this port, then this flag
+	 * shall be ignored by the HWRM.
+	 * If EEE is disabled on this port, then this flag shall be
+	 * ignored by the HWRM.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_EEE_TX_LPI_ENABLE	UINT32_C(0x40)
+	/*
+	 * When this bit is set to '1' and EEE is enabled on this
+	 * link, then TX LPI is requested to be disabled on the link.
+	 * If EEE is not supported on this port, then this flag
+	 * shall be ignored by the HWRM.
+	 * If EEE is disabled on this port, then this flag shall be
+	 * ignored by the HWRM.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_EEE_TX_LPI_DISABLE	UINT32_C(0x80)
+	/*
+	 * When set to 1, then the HWRM shall enable FEC autonegotiation
+	 * on this port if supported. When enabled, at least one of the
+	 * FEC modes must be advertised by enabling the fec_clause_74_enable,
+	 * fec_clause_91_enable, fec_rs544_1xn_enable, fec_rs544_ieee_enable,
+	 * fec_rs272_1xn_enable, or fec_rs272_ieee_enable flag. If none
+	 * of the FEC mode is currently enabled, the HWRM shall choose
+	 * a default advertisement setting.
+	 * The default advertisement setting can be queried by calling
+	 * hwrm_port_phy_qcfg. Note that the link speed must be
+	 * in autonegotiation mode for FEC autonegotiation to take effect.
+	 * When set to 0, then this flag shall be ignored.
+	 * If FEC autonegotiation is not supported, then the HWRM shall
+	 * ignore this flag.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_FEC_AUTONEG_ENABLE	UINT32_C(0x100)
+	/*
+	 * When set to 1, then the HWRM shall disable FEC autonegotiation
+	 * on this port and use forced FEC mode. In forced FEC mode, one
+	 * or more FEC forced settings under the same clause can be set.
+	 * When set to 0, then this flag shall be ignored.
+	 * If FEC autonegotiation is not supported, then the HWRM shall
+	 * ignore this flag.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_FEC_AUTONEG_DISABLE	UINT32_C(0x200)
+	/*
+	 * When set to 1, then the HWRM shall enable FEC CLAUSE 74 (Fire
+	 * Code) on this port if supported, by advertising FEC CLAUSE 74 if
+	 * FEC autonegotiation is enabled or force enabled otherwise.
+	 * When set to 0, then this flag shall be ignored.
+	 * If FEC CLAUSE 74 is not supported, then the HWRM shall ignore this
+	 * flag.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_FEC_CLAUSE74_ENABLE	UINT32_C(0x400)
+	/*
+	 * When set to 1, then the HWRM shall disable FEC CLAUSE 74 (Fire
+	 * Code) on this port if supported, by not advertising FEC CLAUSE 74
+	 * if FEC autonegotiation is enabled or force disabled otherwise.
+	 * When set to 0, then this flag shall be ignored.
+	 * If FEC CLAUSE 74 is not supported, then the HWRM shall ignore this
+	 * flag.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_FEC_CLAUSE74_DISABLE	UINT32_C(0x800)
+	/*
+	 * When set to 1, then the HWRM shall enable FEC CLAUSE 91
+	 * (Reed Solomon RS(528,514) for NRZ) on this port if supported,
+	 * by advertising FEC RS(528,514) if FEC autonegotiation is enabled
+	 * or force enabled otherwise. In forced FEC mode, this flag
+	 * will only take effect if the speed is NRZ. Additional
+	 * RS544 or RS272 flags (also under clause 91) may be set for PAM4
+	 * in forced FEC mode.
+	 * When set to 0, then this flag shall be ignored.
+	 * If FEC RS(528,514) is not supported, then the HWRM shall ignore
+	 * this flag.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_FEC_CLAUSE91_ENABLE	UINT32_C(0x1000)
+	/*
+	 * When set to 1, then the HWRM shall disable FEC CLAUSE 91
+	 * (Reed Solomon RS(528,514) for NRZ) on this port if supported, by
+	 * not advertising RS(528,514) if FEC autonegotiation is enabled or
+	 * force disabled otherwise. When set to 0, then this flag shall be
+	 * ignored. If FEC RS(528,514) is not supported, then the HWRM
+	 * shall ignore this flag.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_FEC_CLAUSE91_DISABLE	UINT32_C(0x2000)
+	/*
+	 * When this bit is set to '1', the link shall be forced to
+	 * be taken down.
+	 *
+	 * # When this bit is set to '1", all other
+	 * command input settings related to the link speed shall
+	 * be ignored.
+	 * Once the link state is forced down, it can be
+	 * explicitly cleared from that state by setting this flag
+	 * to '0'.
+	 * # If this flag is set to '0', then the link shall be
+	 * cleared from forced down state if the link is in forced
+	 * down state.
+	 * There may be conditions (e.g. out-of-band or sideband
+	 * configuration changes for the link) outside the scope
+	 * of the HWRM implementation that may clear forced down
+	 * link state.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_FORCE_LINK_DWN		UINT32_C(0x4000)
+	/*
+	 * When set to 1, then the HWRM shall enable FEC RS544_1XN
+	 * on this port if supported, by advertising FEC RS544_1XN if
+	 * FEC autonegotiation is enabled or force enabled otherwise.
+	 * In forced mode, this flag will only take effect if the speed is
+	 * PAM4. If this flag and fec_rs544_ieee_enable are set, the
+	 * HWRM shall choose one of the RS544 modes.
+	 * When set to 0, then this flag shall be ignored.
+	 * If FEC RS544_1XN is not supported, then the HWRM shall ignore this
+	 * flag.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_FEC_RS544_1XN_ENABLE	UINT32_C(0x8000)
+	/*
+	 * When set to 1, then the HWRM shall disable FEC RS544_1XN
+	 * on this port if supported, by not advertising FEC RS544_1XN if
+	 * FEC autonegotiation is enabled or force disabled otherwise.
+	 * When set to 0, then this flag shall be ignored.
+	 * If FEC RS544_1XN is not supported, then the HWRM shall ignore
+	 * this flag.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_FEC_RS544_1XN_DISABLE	UINT32_C(0x10000)
+	/*
+	 * When set to 1, then the HWRM shall enable FEC RS(544,514)
+	 * on this port if supported, by advertising FEC RS(544,514) if
+	 * FEC autonegotiation is enabled or force enabled otherwise.
+	 * In forced mode, this flag will only take effect if the speed is
+	 * PAM4. If this flag and fec_rs544_1xn_enable are set, the
+	 * HWRM shall choose one of the RS544 modes.
+	 * When set to 0, then this flag shall be ignored.
+	 * If FEC RS(544,514) is not supported, then the HWRM shall ignore
+	 * this flag.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_FEC_RS544_IEEE_ENABLE	UINT32_C(0x20000)
+	/*
+	 * When set to 1, then the HWRM shall disable FEC RS(544,514)
+	 * on this port if supported, by not advertising FEC RS(544,514) if
+	 * FEC autonegotiation is enabled or force disabled otherwise.
+	 * When set to 0, then this flag shall be ignored.
+	 * If FEC RS(544,514) is not supported, then the HWRM shall ignore
+	 * this flag.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_FEC_RS544_IEEE_DISABLE	UINT32_C(0x40000)
+	/*
+	 * When set to 1, then the HWRM shall enable FEC RS272_1XN
+	 * on this port if supported, by advertising FEC RS272_1XN if
+	 * FEC autonegotiation is enabled or force enabled otherwise.
+	 * In forced mode, this flag will only take effect if the speed is
+	 * PAM4. If this flag and fec_rs272_ieee_enable are set, the
+	 * HWRM shall choose one of the RS272 modes. Note that RS272
+	 * and RS544 modes cannot be set at the same time in forced FEC mode.
+	 * When set to 0, then this flag shall be ignored.
+	 * If FEC RS272_1XN is not supported, then the HWRM shall ignore this
+	 * flag.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_FEC_RS272_1XN_ENABLE	UINT32_C(0x80000)
+	/*
+	 * When set to 1, then the HWRM shall disable FEC RS272_1XN
+	 * on this port if supported, by not advertising FEC RS272_1XN if
+	 * FEC autonegotiation is enabled or force disabled otherwise.
+	 * When set to 0, then this flag shall be ignored.
+	 * If FEC RS272_1XN is not supported, then the HWRM shall ignore
+	 * this flag.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_FEC_RS272_1XN_DISABLE	UINT32_C(0x100000)
+	/*
+	 * When set to 1, then the HWRM shall enable FEC RS(272,257)
+	 * on this port if supported, by advertising FEC RS(272,257) if
+	 * FEC autonegotiation is enabled or force enabled otherwise.
+	 * In forced mode, this flag will only take effect if the speed is
+	 * PAM4. If this flag and fec_rs272_1xn_enable are set, the
+	 * HWRM shall choose one of the RS272 modes. Note that RS272
+	 * and RS544 modes cannot be set at the same time in forced FEC mode.
+	 * When set to 0, then this flag shall be ignored.
+	 * If FEC RS(272,257) is not supported, then the HWRM shall ignore
+	 * this flag.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_FEC_RS272_IEEE_ENABLE	UINT32_C(0x200000)
+	/*
+	 * When set to 1, then the HWRM shall disable FEC RS(272,257)
+	 * on this port if supported, by not advertising FEC RS(272,257) if
+	 * FEC autonegotiation is enabled or force disabled otherwise.
+	 * When set to 0, then this flag shall be ignored.
+	 * If FEC RS(272,257) is not supported, then the HWRM shall ignore
+	 * this flag.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_FEC_RS272_IEEE_DISABLE	UINT32_C(0x400000)
+	uint32_t	enables;
+	/*
+	 * This bit must be '1' for the auto_mode field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_MODE			UINT32_C(0x1)
+	/*
+	 * This bit must be '1' for the auto_duplex field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_DUPLEX		UINT32_C(0x2)
+	/*
+	 * This bit must be '1' for the auto_pause field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_PAUSE			UINT32_C(0x4)
+	/*
+	 * This bit must be '1' for the auto_link_speed field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_LINK_SPEED		UINT32_C(0x8)
+	/*
+	 * This bit must be '1' for the auto_link_speed_mask field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_LINK_SPEED_MASK	UINT32_C(0x10)
+	/*
+	 * This bit must be '1' for the wirespeed field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_ENABLES_WIRESPEED			UINT32_C(0x20)
+	/*
+	 * This bit must be '1' for the lpbk field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_ENABLES_LPBK			UINT32_C(0x40)
+	/*
+	 * This bit must be '1' for the preemphasis field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_ENABLES_PREEMPHASIS		UINT32_C(0x80)
+	/*
+	 * This bit must be '1' for the force_pause field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_ENABLES_FORCE_PAUSE		UINT32_C(0x100)
+	/*
+	 * This bit must be '1' for the eee_link_speed_mask field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_ENABLES_EEE_LINK_SPEED_MASK	UINT32_C(0x200)
+	/*
+	 * This bit must be '1' for the tx_lpi_timer field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_ENABLES_TX_LPI_TIMER		UINT32_C(0x400)
+	/*
+	 * This bit must be '1' for the force_pam4_link_speed field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_ENABLES_FORCE_PAM4_LINK_SPEED	UINT32_C(0x800)
+	/*
+	 * This bit must be '1' for the auto_pam4_link_speed_mask field to
+	 * be configured.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_PAM4_LINK_SPEED_MASK	UINT32_C(0x1000)
+	/*
+	 * This bit must be '1' for the force_link_speeds2 field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_ENABLES_FORCE_LINK_SPEEDS2		UINT32_C(0x2000)
+	/*
+	 * This bit must be '1' for the auto_link_speeds2_mask field to
+	 * be configured.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_LINK_SPEEDS2_MASK	UINT32_C(0x4000)
+	/* Port ID of port that is to be configured. */
+	uint16_t	port_id;
+	/*
+	 * This is the speed that will be used if the force
+	 * bit is '1'. If unsupported speed is selected, an error
+	 * will be generated.
+	 */
+	uint16_t	force_link_speed;
+	/* 100Mb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_100MB UINT32_C(0x1)
+	/* 1Gb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_1GB   UINT32_C(0xa)
+	/* 2Gb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_2GB   UINT32_C(0x14)
+	/* 25Gb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_2_5GB UINT32_C(0x19)
+	/* 10Gb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_10GB  UINT32_C(0x64)
+	/* 20Mb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_20GB  UINT32_C(0xc8)
+	/* 25Gb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_25GB  UINT32_C(0xfa)
+	/* 40Gb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_40GB  UINT32_C(0x190)
+	/* 50Gb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_50GB  UINT32_C(0x1f4)
+	/* 100Gb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_100GB UINT32_C(0x3e8)
+	/* 10Mb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_10MB  UINT32_C(0xffff)
+	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_LAST HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_10MB
+	/*
+	 * This value is used to identify what autoneg mode is
+	 * used when the link speed is not being forced.
+	 */
+	uint8_t	auto_mode;
+	/* Disable autoneg or autoneg disabled. No speeds are selected. */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_NONE	UINT32_C(0x0)
+	/* Select all possible speeds for autoneg mode. */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_ALL_SPEEDS   UINT32_C(0x1)
+	/*
+	 * Select only the auto_link_speed speed for autoneg mode. This mode
+	 * has been DEPRECATED. An HWRM client should not use this mode.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_ONE_SPEED	UINT32_C(0x2)
+	/*
+	 * Select the auto_link_speed or any speed below that speed for
+	 * autoneg. This mode has been DEPRECATED. An HWRM client should not
+	 * use this mode.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_ONE_OR_BELOW UINT32_C(0x3)
+	/*
+	 * Select the speeds based on the corresponding link speed mask
+	 * values that are provided. The included speeds are specified in the
+	 * auto_link_speed and auto_pam4_link_speed fields.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_SPEED_MASK   UINT32_C(0x4)
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_LAST	HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_SPEED_MASK
+	/*
+	 * This is the duplex setting that will be used if the autoneg_mode
+	 * is "one_speed" or "one_or_below".
+	 */
+	uint8_t	auto_duplex;
+	/* Half Duplex will be requested. */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_HALF UINT32_C(0x0)
+	/* Full duplex will be requested. */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_FULL UINT32_C(0x1)
+	/* Both Half and Full duplex will be requested. */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_BOTH UINT32_C(0x2)
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_LAST HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_BOTH
+	/*
+	 * This value is used to configure the pause that will be
+	 * used for autonegotiation.
+	 * Add text on the usage of auto_pause and force_pause.
+	 */
+	uint8_t	auto_pause;
+	/*
+	 * When this bit is '1', Generation of tx pause messages
+	 * has been requested. Disabled otherwise.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_PAUSE_TX		UINT32_C(0x1)
+	/*
+	 * When this bit is '1', Reception of rx pause messages
+	 * has been requested. Disabled otherwise.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_PAUSE_RX		UINT32_C(0x2)
+	/*
+	 * When set to 1, the advertisement of pause is enabled.
+	 *
+	 * # When the auto_mode is not set to none and this flag is
+	 * set to 1, then the auto_pause bits on this port are being
+	 * advertised and autoneg pause results are being interpreted.
+	 * # When the auto_mode is not set to none and this
+	 * flag is set to 0, the pause is forced as indicated in
+	 * force_pause, and also advertised as auto_pause bits, but
+	 * the autoneg results are not interpreted since the pause
+	 * configuration is being forced.
+	 * # When the auto_mode is set to none and this flag is set to
+	 * 1, auto_pause bits should be ignored and should be set to 0.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_PAUSE_AUTONEG_PAUSE	UINT32_C(0x4)
+	/*
+	 * This field is only used by management firmware to communicate with
+	 * core firmware regarding phy_port_cfg.
+	 * It mainly used to notify core firmware that management firmware is
+	 * using port for NCSI over RMII communication or not.
+	 */
+	uint8_t	mgmt_flag;
+	/*
+	 * Bit denoting if management firmware is using the link for
+	 * NCSI over RMII communication.
+	 * When set to 1, management firmware is no longer using the given
+	 * port.
+	 * When set to 0, management firmware is using the given port.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_MGMT_FLAG_LINK_RELEASE	UINT32_C(0x1)
+	/*
+	 * Validity bit, set to 1 to indicate other bits in mgmt_flags are
+	 * valid.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_MGMT_FLAG_MGMT_VALID	UINT32_C(0x80)
+	/*
+	 * This is the speed that will be used if the autoneg_mode
+	 * is "one_speed" or "one_or_below". If an unsupported speed
+	 * is selected, an error will be generated.
+	 */
+	uint16_t	auto_link_speed;
+	/* 100Mb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_100MB UINT32_C(0x1)
+	/* 1Gb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_1GB   UINT32_C(0xa)
+	/* 2Gb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_2GB   UINT32_C(0x14)
+	/* 25Gb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_2_5GB UINT32_C(0x19)
+	/* 10Gb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_10GB  UINT32_C(0x64)
+	/* 20Mb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_20GB  UINT32_C(0xc8)
+	/* 25Gb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_25GB  UINT32_C(0xfa)
+	/* 40Gb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_40GB  UINT32_C(0x190)
+	/* 50Gb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_50GB  UINT32_C(0x1f4)
+	/* 100Gb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_100GB UINT32_C(0x3e8)
+	/* 10Mb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_10MB  UINT32_C(0xffff)
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_LAST HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_10MB
+	/*
+	 * This is a mask of link speeds that will be used if
+	 * autoneg_mode is "mask". If unsupported speed is enabled
+	 * an error will be generated.
+	 */
+	uint16_t	auto_link_speed_mask;
+	/* 100Mb link speed (Half-duplex) */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_100MBHD	UINT32_C(0x1)
+	/* 100Mb link speed (Full-duplex) */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_100MB	UINT32_C(0x2)
+	/* 1Gb link speed (Half-duplex) */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_1GBHD	UINT32_C(0x4)
+	/* 1Gb link speed (Full-duplex) */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_1GB	UINT32_C(0x8)
+	/* 2Gb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_2GB	UINT32_C(0x10)
+	/* 25Gb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_2_5GB	UINT32_C(0x20)
+	/* 10Gb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_10GB	UINT32_C(0x40)
+	/* 20Gb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_20GB	UINT32_C(0x80)
+	/* 25Gb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_25GB	UINT32_C(0x100)
+	/* 40Gb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_40GB	UINT32_C(0x200)
+	/* 50Gb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_50GB	UINT32_C(0x400)
+	/* 100Gb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_100GB	UINT32_C(0x800)
+	/* 10Mb link speed (Half-duplex) */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_10MBHD	UINT32_C(0x1000)
+	/* 10Mb link speed (Full-duplex) */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_10MB	UINT32_C(0x2000)
+	/* This value controls the wirespeed feature. */
+	uint8_t	wirespeed;
+	/* Wirespeed feature is disabled. */
+	#define HWRM_PORT_PHY_CFG_INPUT_WIRESPEED_OFF UINT32_C(0x0)
+	/* Wirespeed feature is enabled. */
+	#define HWRM_PORT_PHY_CFG_INPUT_WIRESPEED_ON  UINT32_C(0x1)
+	#define HWRM_PORT_PHY_CFG_INPUT_WIRESPEED_LAST HWRM_PORT_PHY_CFG_INPUT_WIRESPEED_ON
+	/* This value controls the loopback setting for the PHY. */
+	uint8_t	lpbk;
+	/* No loopback is selected. Normal operation. */
+	#define HWRM_PORT_PHY_CFG_INPUT_LPBK_NONE	UINT32_C(0x0)
+	/*
+	 * The HW will be configured with local loopback such that
+	 * host data is sent back to the host without modification.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_LPBK_LOCAL	UINT32_C(0x1)
+	/*
+	 * The HW will be configured with remote loopback such that
+	 * port logic will send packets back out the transmitter that
+	 * are received.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_LPBK_REMOTE   UINT32_C(0x2)
+	/*
+	 * The HW will be configured with external loopback such that
+	 * host data is sent on the transmitter and based on the external
+	 * loopback connection the data will be received without
+	 * modification.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_LPBK_EXTERNAL UINT32_C(0x3)
+	#define HWRM_PORT_PHY_CFG_INPUT_LPBK_LAST	HWRM_PORT_PHY_CFG_INPUT_LPBK_EXTERNAL
+	/*
+	 * This value is used to configure the pause that will be
+	 * used for force mode.
+	 */
+	uint8_t	force_pause;
+	/*
+	 * When this bit is '1', Generation of tx pause messages
+	 * is supported. Disabled otherwise.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_PAUSE_TX	UINT32_C(0x1)
+	/*
+	 * When this bit is '1', Reception of rx pause messages
+	 * is supported. Disabled otherwise.
+	 */
+	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_PAUSE_RX	UINT32_C(0x2)
+	uint8_t	unused_1;
+	/*
+	 * This value controls the pre-emphasis to be used for the
+	 * link. Driver should not set this value (use
+	 * enable.preemphasis = 0) unless driver is sure of setting.
+	 * Normally HWRM FW will determine proper pre-emphasis.
+	 */
+	uint32_t	preemphasis;
+	/*
+	 * Setting for link speed mask that is used to
+	 * advertise speeds during autonegotiation when EEE is enabled.
+	 * This field is valid only when EEE is enabled.
+	 * The speeds specified in this field shall be a subset of
+	 * speeds specified in auto_link_speed_mask.
+	 * If EEE is enabled,then at least one speed shall be provided
+	 * in this mask.
+	 */
+	uint16_t	eee_link_speed_mask;
+	/* Reserved */
+	#define HWRM_PORT_PHY_CFG_INPUT_EEE_LINK_SPEED_MASK_RSVD1	UINT32_C(0x1)
+	/* 100Mb link speed (Full-duplex) */
+	#define HWRM_PORT_PHY_CFG_INPUT_EEE_LINK_SPEED_MASK_100MB	UINT32_C(0x2)
+	/* Reserved */
+	#define HWRM_PORT_PHY_CFG_INPUT_EEE_LINK_SPEED_MASK_RSVD2	UINT32_C(0x4)
+	/* 1Gb link speed (Full-duplex) */
+	#define HWRM_PORT_PHY_CFG_INPUT_EEE_LINK_SPEED_MASK_1GB	UINT32_C(0x8)
+	/* Reserved */
+	#define HWRM_PORT_PHY_CFG_INPUT_EEE_LINK_SPEED_MASK_RSVD3	UINT32_C(0x10)
+	/* Reserved */
+	#define HWRM_PORT_PHY_CFG_INPUT_EEE_LINK_SPEED_MASK_RSVD4	UINT32_C(0x20)
+	/* 10Gb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_EEE_LINK_SPEED_MASK_10GB	UINT32_C(0x40)
+	/*
+	 * This is the speed that will be used if the force and force_pam4
+	 * bits are '1'. If unsupported speed is selected, an error
+	 * will be generated.
+	 */
+	uint16_t	force_pam4_link_speed;
+	/* 50Gb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_PAM4_LINK_SPEED_50GB  UINT32_C(0x1f4)
+	/* 100Gb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_PAM4_LINK_SPEED_100GB UINT32_C(0x3e8)
+	/* 200Gb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_PAM4_LINK_SPEED_200GB UINT32_C(0x7d0)
+	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_PAM4_LINK_SPEED_LAST HWRM_PORT_PHY_CFG_INPUT_FORCE_PAM4_LINK_SPEED_200GB
+	/*
+	 * Requested setting of TX LPI timer in microseconds.
+	 * This field is valid only when EEE is enabled and TX LPI is
+	 * enabled.
+	 */
+	uint32_t	tx_lpi_timer;
+	#define HWRM_PORT_PHY_CFG_INPUT_TX_LPI_TIMER_MASK UINT32_C(0xffffff)
+	#define HWRM_PORT_PHY_CFG_INPUT_TX_LPI_TIMER_SFT 0
+	/* This field specifies which PAM4 speeds are enabled for auto mode. */
+	uint16_t	auto_link_pam4_speed_mask;
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_PAM4_SPEED_MASK_50G	UINT32_C(0x1)
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_PAM4_SPEED_MASK_100G	UINT32_C(0x2)
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_PAM4_SPEED_MASK_200G	UINT32_C(0x4)
+	/*
+	 * This is the speed that will be used if the force_link_speeds2
+	 * bit is '1'. If unsupported speed is selected, an error
+	 * will be generated.
+	 */
+	uint16_t	force_link_speeds2;
+	/* 1Gb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEEDS2_1GB		UINT32_C(0xa)
+	/* 10Gb (NRZ: 10G per lane, 1 lane) link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEEDS2_10GB	UINT32_C(0x64)
+	/* 25Gb (NRZ: 25G per lane, 1 lane) link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEEDS2_25GB	UINT32_C(0xfa)
+	/* 40Gb (NRZ: 10G per lane, 4 lanes) link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEEDS2_40GB	UINT32_C(0x190)
+	/* 50Gb (NRZ: 25G per lane, 2 lanes) link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEEDS2_50GB	UINT32_C(0x1f4)
+	/* 100Gb (NRZ: 25G per lane, 4 lanes) link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEEDS2_100GB	UINT32_C(0x3e8)
+	/* 50Gb (PAM4-56: 50G per lane, 1 lane) link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEEDS2_50GB_PAM4_56   UINT32_C(0x1f5)
+	/* 100Gb (PAM4-56: 50G per lane, 2 lanes) link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEEDS2_100GB_PAM4_56  UINT32_C(0x3e9)
+	/* 200Gb (PAM4-56: 50G per lane, 4 lanes) link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEEDS2_200GB_PAM4_56  UINT32_C(0x7d1)
+	/* 400Gb (PAM4-56: 50G per lane, 8 lanes) link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEEDS2_400GB_PAM4_56  UINT32_C(0xfa1)
+	/* 100Gb (PAM4-112: 100G per lane, 1 lane) link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEEDS2_100GB_PAM4_112 UINT32_C(0x3ea)
+	/* 200Gb (PAM4-112: 100G per lane, 2 lanes) link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEEDS2_200GB_PAM4_112 UINT32_C(0x7d2)
+	/* 400Gb (PAM4-112: 100G per lane, 4 lanes) link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEEDS2_400GB_PAM4_112 UINT32_C(0xfa2)
+	/* 800Gb (PAM4-112: 100G per lane, 8 lanes) link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEEDS2_800GB_PAM4_112 UINT32_C(0x1f42)
+	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEEDS2_LAST	HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEEDS2_800GB_PAM4_112
+	/*
+	 * This is a mask of link speeds that will be used if
+	 * auto_link_speeds2_mask bit in the "enables" field is 1.
+	 * If unsupported speed is enabled an error will be generated.
+	 */
+	uint16_t	auto_link_speeds2_mask;
+	/* 1Gb link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEEDS2_MASK_1GB		UINT32_C(0x1)
+	/* 10Gb (NRZ: 10G per lane, 1 lane) link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEEDS2_MASK_10GB		UINT32_C(0x2)
+	/* 25Gb (NRZ: 25G per lane, 1 lane) link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEEDS2_MASK_25GB		UINT32_C(0x4)
+	/* 40Gb (NRZ: 10G per lane, 4 lanes) link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEEDS2_MASK_40GB		UINT32_C(0x8)
+	/* 50Gb (NRZ: 25G per lane, 2 lanes) link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEEDS2_MASK_50GB		UINT32_C(0x10)
+	/* 100Gb (NRZ: 25G per lane, 4 lanes) link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEEDS2_MASK_100GB		UINT32_C(0x20)
+	/* 50Gb (PAM4-56: 50G per lane, 1 lane) link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEEDS2_MASK_50GB_PAM4_56	UINT32_C(0x40)
+	/* 100Gb (PAM4-56: 50G per lane, 2 lanes) link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEEDS2_MASK_100GB_PAM4_56	UINT32_C(0x80)
+	/* 200Gb (PAM4-56: 50G per lane, 4 lanes) link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEEDS2_MASK_200GB_PAM4_56	UINT32_C(0x100)
+	/* 400Gb (PAM4-56: 50G per lane, 8 lanes) link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEEDS2_MASK_400GB_PAM4_56	UINT32_C(0x200)
+	/* 100Gb (PAM4-112: 100G per lane, 1 lane) link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEEDS2_MASK_100GB_PAM4_112	UINT32_C(0x400)
+	/* 200Gb (PAM4-112: 100G per lane, 2 lanes) link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEEDS2_MASK_200GB_PAM4_112	UINT32_C(0x800)
+	/* 400Gb (PAM4-112: 100G per lane, 4 lanes) link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEEDS2_MASK_400GB_PAM4_112	UINT32_C(0x1000)
+	/* 800Gb (PAM4-112: 100G per lane, 8 lanes) link speed */
+	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEEDS2_MASK_800GB_PAM4_112	UINT32_C(0x2000)
+	uint8_t	unused_2[6];
+} hwrm_port_phy_cfg_input_t, *phwrm_port_phy_cfg_input_t;
+
+/* hwrm_port_phy_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_port_phy_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_port_phy_cfg_output_t, *phwrm_port_phy_cfg_output_t;
+
+/* hwrm_port_phy_cfg_cmd_err (size:64b/8B) */
+
+typedef struct hwrm_port_phy_cfg_cmd_err {
+	/*
+	 * command specific error codes that goes to
+	 * the cmd_err field in Common HWRM Error Response.
+	 */
+	uint8_t	code;
+	/* Unknown error */
+	#define HWRM_PORT_PHY_CFG_CMD_ERR_CODE_UNKNOWN	UINT32_C(0x0)
+	/* Unable to complete operation due to invalid speed */
+	#define HWRM_PORT_PHY_CFG_CMD_ERR_CODE_ILLEGAL_SPEED UINT32_C(0x1)
+	/*
+	 * retry the command since the phy is not ready.
+	 * retry count is returned in opaque_0.
+	 * This is only valid for the first command and
+	 * this value will not change for successive calls.
+	 * but if a 0 is returned at any time then this should
+	 * be treated as an un recoverable failure,
+	 *
+	 * retry interval in milliseconds is returned in opaque_1.
+	 * This specifies the time that user should wait before
+	 * issuing the next port_phy_cfg command.
+	 */
+	#define HWRM_PORT_PHY_CFG_CMD_ERR_CODE_RETRY	UINT32_C(0x2)
+	#define HWRM_PORT_PHY_CFG_CMD_ERR_CODE_LAST	HWRM_PORT_PHY_CFG_CMD_ERR_CODE_RETRY
+	uint8_t	unused_0[7];
+} hwrm_port_phy_cfg_cmd_err_t, *phwrm_port_phy_cfg_cmd_err_t;
+
+/**********************
+ * hwrm_port_phy_qcfg *
+ **********************/
+
+
+/* hwrm_port_phy_qcfg_input (size:192b/24B) */
+
+typedef struct hwrm_port_phy_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Port ID of port that is to be queried. */
+	uint16_t	port_id;
+	uint8_t	unused_0[6];
+} hwrm_port_phy_qcfg_input_t, *phwrm_port_phy_qcfg_input_t;
+
+/* hwrm_port_phy_qcfg_output (size:832b/104B) */
+
+typedef struct hwrm_port_phy_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* This value indicates the current link status. */
+	uint8_t	link;
+	/* There is no link or cable detected. */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_NO_LINK UINT32_C(0x0)
+	/* There is no link, but a cable has been detected. */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SIGNAL  UINT32_C(0x1)
+	/* There is a link. */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_LINK	UINT32_C(0x2)
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_LAST   HWRM_PORT_PHY_QCFG_OUTPUT_LINK_LINK
+	uint8_t	active_fec_signal_mode;
+	/*
+	 * This value indicates the current link signaling mode of the
+	 * connection.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_SIGNAL_MODE_MASK		UINT32_C(0xf)
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_SIGNAL_MODE_SFT		0
+	/* NRZ signaling */
+		#define HWRM_PORT_PHY_QCFG_OUTPUT_SIGNAL_MODE_NRZ		UINT32_C(0x0)
+	/* PAM4-56 signaling */
+		#define HWRM_PORT_PHY_QCFG_OUTPUT_SIGNAL_MODE_PAM4		UINT32_C(0x1)
+	/* PAM4-112 signaling */
+		#define HWRM_PORT_PHY_QCFG_OUTPUT_SIGNAL_MODE_PAM4_112		UINT32_C(0x2)
+		#define HWRM_PORT_PHY_QCFG_OUTPUT_SIGNAL_MODE_LAST		HWRM_PORT_PHY_QCFG_OUTPUT_SIGNAL_MODE_PAM4_112
+	/* This value indicates the current active FEC mode. */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_ACTIVE_FEC_MASK		UINT32_C(0xf0)
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_ACTIVE_FEC_SFT		4
+	/* No active FEC */
+		#define HWRM_PORT_PHY_QCFG_OUTPUT_ACTIVE_FEC_FEC_NONE_ACTIVE	(UINT32_C(0x0) << 4)
+	/* FEC CLAUSE 74 (Fire Code) active, autonegotiated or forced. */
+		#define HWRM_PORT_PHY_QCFG_OUTPUT_ACTIVE_FEC_FEC_CLAUSE74_ACTIVE	(UINT32_C(0x1) << 4)
+	/* FEC CLAUSE 91 RS(528,514) active, autonegotiated or forced. */
+		#define HWRM_PORT_PHY_QCFG_OUTPUT_ACTIVE_FEC_FEC_CLAUSE91_ACTIVE	(UINT32_C(0x2) << 4)
+	/* FEC RS544_1XN active, autonegotiated or forced. */
+		#define HWRM_PORT_PHY_QCFG_OUTPUT_ACTIVE_FEC_FEC_RS544_1XN_ACTIVE   (UINT32_C(0x3) << 4)
+	/* FEC RS(544,528) active, autonegotiated or forced. */
+		#define HWRM_PORT_PHY_QCFG_OUTPUT_ACTIVE_FEC_FEC_RS544_IEEE_ACTIVE  (UINT32_C(0x4) << 4)
+	/* FEC RS272_1XN active, autonegotiated or forced. */
+		#define HWRM_PORT_PHY_QCFG_OUTPUT_ACTIVE_FEC_FEC_RS272_1XN_ACTIVE   (UINT32_C(0x5) << 4)
+	/* FEC RS(272,257) active, autonegotiated or forced. */
+		#define HWRM_PORT_PHY_QCFG_OUTPUT_ACTIVE_FEC_FEC_RS272_IEEE_ACTIVE  (UINT32_C(0x6) << 4)
+		#define HWRM_PORT_PHY_QCFG_OUTPUT_ACTIVE_FEC_LAST		HWRM_PORT_PHY_QCFG_OUTPUT_ACTIVE_FEC_FEC_RS272_IEEE_ACTIVE
+	/*
+	 * This value indicates the current link speed of the connection.
+	 * The signal_mode field indicates if the link is using
+	 * NRZ or PAM4 signaling.
+	 */
+	uint16_t	link_speed;
+	/* 100Mb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_100MB UINT32_C(0x1)
+	/* 1Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_1GB   UINT32_C(0xa)
+	/* 2Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_2GB   UINT32_C(0x14)
+	/* 25Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_2_5GB UINT32_C(0x19)
+	/* 10Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_10GB  UINT32_C(0x64)
+	/* 20Mb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_20GB  UINT32_C(0xc8)
+	/* 25Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_25GB  UINT32_C(0xfa)
+	/* 40Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_40GB  UINT32_C(0x190)
+	/* 50Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_50GB  UINT32_C(0x1f4)
+	/* 100Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_100GB UINT32_C(0x3e8)
+	/* 200Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_200GB UINT32_C(0x7d0)
+	/* 400Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_400GB UINT32_C(0xfa0)
+	/* 800Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_800GB UINT32_C(0x1f40)
+	/* 10Mb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_10MB  UINT32_C(0xffff)
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_LAST HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_10MB
+	/*
+	 * This value is indicates the duplex of the current
+	 * configuration.
+	 */
+	uint8_t	duplex_cfg;
+	/* Half Duplex connection. */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_DUPLEX_CFG_HALF UINT32_C(0x0)
+	/* Full duplex connection. */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_DUPLEX_CFG_FULL UINT32_C(0x1)
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_DUPLEX_CFG_LAST HWRM_PORT_PHY_QCFG_OUTPUT_DUPLEX_CFG_FULL
+	/*
+	 * This value is used to indicate the current
+	 * pause configuration. When autoneg is enabled, this value
+	 * represents the autoneg results of pause configuration.
+	 */
+	uint8_t	pause;
+	/*
+	 * When this bit is '1', Generation of tx pause messages
+	 * is supported. Disabled otherwise.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_TX	UINT32_C(0x1)
+	/*
+	 * When this bit is '1', Reception of rx pause messages
+	 * is supported. Disabled otherwise.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_RX	UINT32_C(0x2)
+	/*
+	 * The supported speeds for the port. This is a bit mask.
+	 * For each speed that is supported, the corresponding
+	 * bit will be set to '1'.
+	 */
+	uint16_t	support_speeds;
+	/* 100Mb link speed (Half-duplex) */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_100MBHD	UINT32_C(0x1)
+	/* 100Mb link speed (Full-duplex) */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_100MB	UINT32_C(0x2)
+	/* 1Gb link speed (Half-duplex) */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_1GBHD	UINT32_C(0x4)
+	/* 1Gb link speed (Full-duplex) */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_1GB	UINT32_C(0x8)
+	/* 2Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_2GB	UINT32_C(0x10)
+	/* 25Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_2_5GB	UINT32_C(0x20)
+	/* 10Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_10GB	UINT32_C(0x40)
+	/* 20Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_20GB	UINT32_C(0x80)
+	/* 25Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_25GB	UINT32_C(0x100)
+	/* 40Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_40GB	UINT32_C(0x200)
+	/* 50Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_50GB	UINT32_C(0x400)
+	/* 100Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_100GB	UINT32_C(0x800)
+	/* 10Mb link speed (Half-duplex) */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_10MBHD	UINT32_C(0x1000)
+	/* 10Mb link speed (Full-duplex) */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_10MB	UINT32_C(0x2000)
+	/*
+	 * Current setting of forced link speed.
+	 * When the link speed is not being forced, this
+	 * value shall be set to 0.
+	 */
+	uint16_t	force_link_speed;
+	/* 100Mb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEED_100MB UINT32_C(0x1)
+	/* 1Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEED_1GB   UINT32_C(0xa)
+	/* 2Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEED_2GB   UINT32_C(0x14)
+	/* 25Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEED_2_5GB UINT32_C(0x19)
+	/* 10Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEED_10GB  UINT32_C(0x64)
+	/* 20Mb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEED_20GB  UINT32_C(0xc8)
+	/* 25Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEED_25GB  UINT32_C(0xfa)
+	/* 40Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEED_40GB  UINT32_C(0x190)
+	/* 50Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEED_50GB  UINT32_C(0x1f4)
+	/* 100Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEED_100GB UINT32_C(0x3e8)
+	/* 10Mb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEED_10MB  UINT32_C(0xffff)
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEED_LAST HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEED_10MB
+	/* Current setting of auto negotiation mode. */
+	uint8_t	auto_mode;
+	/* Disable autoneg or autoneg disabled. No speeds are selected. */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_MODE_NONE	UINT32_C(0x0)
+	/* Select all possible speeds for autoneg mode. */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_MODE_ALL_SPEEDS   UINT32_C(0x1)
+	/*
+	 * Select only the auto_link_speed speed for autoneg mode. This mode
+	 * has been DEPRECATED. An HWRM client should not use this mode.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_MODE_ONE_SPEED	UINT32_C(0x2)
+	/*
+	 * Select the auto_link_speed or any speed below that speed for
+	 * autoneg. This mode has been DEPRECATED. An HWRM client should not
+	 * use this mode.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_MODE_ONE_OR_BELOW UINT32_C(0x3)
+	/*
+	 * Select the speeds based on the corresponding link speed mask value
+	 * that is provided.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_MODE_SPEED_MASK   UINT32_C(0x4)
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_MODE_LAST	HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_MODE_SPEED_MASK
+	/*
+	 * Current setting of pause autonegotiation.
+	 * Move autoneg_pause flag here.
+	 */
+	uint8_t	auto_pause;
+	/*
+	 * When this bit is '1', Generation of tx pause messages
+	 * has been requested. Disabled otherwise.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_PAUSE_TX		UINT32_C(0x1)
+	/*
+	 * When this bit is '1', Reception of rx pause messages
+	 * has been requested. Disabled otherwise.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_PAUSE_RX		UINT32_C(0x2)
+	/*
+	 * When set to 1, the advertisement of pause is enabled.
+	 *
+	 * # When the auto_mode is not set to none and this flag is
+	 * set to 1, then the auto_pause bits on this port are being
+	 * advertised and autoneg pause results are being interpreted.
+	 * # When the auto_mode is not set to none and this
+	 * flag is set to 0, the pause is forced as indicated in
+	 * force_pause, and also advertised as auto_pause bits, but
+	 * the autoneg results are not interpreted since the pause
+	 * configuration is being forced.
+	 * # When the auto_mode is set to none and this flag is set to
+	 * 1, auto_pause bits should be ignored and should be set to 0.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_PAUSE_AUTONEG_PAUSE	UINT32_C(0x4)
+	/*
+	 * Current setting for auto_link_speed. This field is only
+	 * valid when auto_mode is set to "one_speed" or "one_or_below".
+	 */
+	uint16_t	auto_link_speed;
+	/* 100Mb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_100MB UINT32_C(0x1)
+	/* 1Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_1GB   UINT32_C(0xa)
+	/* 2Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_2GB   UINT32_C(0x14)
+	/* 25Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_2_5GB UINT32_C(0x19)
+	/* 10Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_10GB  UINT32_C(0x64)
+	/* 20Mb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_20GB  UINT32_C(0xc8)
+	/* 25Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_25GB  UINT32_C(0xfa)
+	/* 40Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_40GB  UINT32_C(0x190)
+	/* 50Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_50GB  UINT32_C(0x1f4)
+	/* 100Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_100GB UINT32_C(0x3e8)
+	/* 10Mb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_10MB  UINT32_C(0xffff)
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_LAST HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_10MB
+	/*
+	 * Current setting for auto_link_speed_mask that is used to
+	 * advertise speeds during autonegotiation.
+	 * This field is only valid when auto_mode is set to "mask".
+	 * The speeds specified in this field shall be a subset of
+	 * supported speeds on this port.
+	 */
+	uint16_t	auto_link_speed_mask;
+	/* 100Mb link speed (Half-duplex) */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_MASK_100MBHD	UINT32_C(0x1)
+	/* 100Mb link speed (Full-duplex) */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_MASK_100MB	UINT32_C(0x2)
+	/* 1Gb link speed (Half-duplex) */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_MASK_1GBHD	UINT32_C(0x4)
+	/* 1Gb link speed (Full-duplex) */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_MASK_1GB	UINT32_C(0x8)
+	/* 2Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_MASK_2GB	UINT32_C(0x10)
+	/* 25Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_MASK_2_5GB	UINT32_C(0x20)
+	/* 10Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_MASK_10GB	UINT32_C(0x40)
+	/* 20Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_MASK_20GB	UINT32_C(0x80)
+	/* 25Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_MASK_25GB	UINT32_C(0x100)
+	/* 40Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_MASK_40GB	UINT32_C(0x200)
+	/* 50Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_MASK_50GB	UINT32_C(0x400)
+	/* 100Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_MASK_100GB	UINT32_C(0x800)
+	/* 10Mb link speed (Half-duplex) */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_MASK_10MBHD	UINT32_C(0x1000)
+	/* 10Mb link speed (Full-duplex) */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_MASK_10MB	UINT32_C(0x2000)
+	/* Current setting for wirespeed. */
+	uint8_t	wirespeed;
+	/* Wirespeed feature is disabled. */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_WIRESPEED_OFF UINT32_C(0x0)
+	/* Wirespeed feature is enabled. */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_WIRESPEED_ON  UINT32_C(0x1)
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_WIRESPEED_LAST HWRM_PORT_PHY_QCFG_OUTPUT_WIRESPEED_ON
+	/* Current setting for loopback. */
+	uint8_t	lpbk;
+	/* No loopback is selected. Normal operation. */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LPBK_NONE	UINT32_C(0x0)
+	/*
+	 * The HW will be configured with local loopback such that
+	 * host data is sent back to the host without modification.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LPBK_LOCAL	UINT32_C(0x1)
+	/*
+	 * The HW will be configured with remote loopback such that
+	 * port logic will send packets back out the transmitter that
+	 * are received.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LPBK_REMOTE   UINT32_C(0x2)
+	/*
+	 * The HW will be configured with external loopback such that
+	 * host data is sent on the transmitter and based on the external
+	 * loopback connection the data will be received without
+	 * modification.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LPBK_EXTERNAL UINT32_C(0x3)
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LPBK_LAST	HWRM_PORT_PHY_QCFG_OUTPUT_LPBK_EXTERNAL
+	/*
+	 * Current setting of forced pause.
+	 * When the pause configuration is not being forced, then
+	 * this value shall be set to 0.
+	 */
+	uint8_t	force_pause;
+	/*
+	 * When this bit is '1', Generation of tx pause messages
+	 * is supported. Disabled otherwise.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_PAUSE_TX	UINT32_C(0x1)
+	/*
+	 * When this bit is '1', Reception of rx pause messages
+	 * is supported. Disabled otherwise.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_PAUSE_RX	UINT32_C(0x2)
+	/*
+	 * This value indicates the current status of the optics module on
+	 * this port.
+	 */
+	uint8_t	module_status;
+	/* Module is inserted and accepted */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_MODULE_STATUS_NONE	UINT32_C(0x0)
+	/* Module is rejected and transmit side Laser is disabled. */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_MODULE_STATUS_DISABLETX	UINT32_C(0x1)
+	/* Module mismatch warning. */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_MODULE_STATUS_WARNINGMSG	UINT32_C(0x2)
+	/* Module is rejected and powered down. */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_MODULE_STATUS_PWRDOWN	UINT32_C(0x3)
+	/* Module is not inserted. */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_MODULE_STATUS_NOTINSERTED   UINT32_C(0x4)
+	/* Module is powered down because of over current fault. */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_MODULE_STATUS_CURRENTFAULT  UINT32_C(0x5)
+	/* Module status is not applicable. */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_MODULE_STATUS_NOTAPPLICABLE UINT32_C(0xff)
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_MODULE_STATUS_LAST	HWRM_PORT_PHY_QCFG_OUTPUT_MODULE_STATUS_NOTAPPLICABLE
+	/* Current setting for preemphasis. */
+	uint32_t	preemphasis;
+	/* This field represents the major version of the PHY. */
+	uint8_t	phy_maj;
+	/* This field represents the minor version of the PHY. */
+	uint8_t	phy_min;
+	/* This field represents the build version of the PHY. */
+	uint8_t	phy_bld;
+	/* This value represents a PHY type. */
+	uint8_t	phy_type;
+	/* Unknown */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_UNKNOWN	UINT32_C(0x0)
+	/* BASE-CR */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASECR	UINT32_C(0x1)
+	/* BASE-KR4 (Deprecated) */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR4	UINT32_C(0x2)
+	/* BASE-LR */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASELR	UINT32_C(0x3)
+	/* BASE-SR */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASESR	UINT32_C(0x4)
+	/* BASE-KR2 (Deprecated) */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR2	UINT32_C(0x5)
+	/* BASE-KX */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKX	UINT32_C(0x6)
+	/* BASE-KR */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR	UINT32_C(0x7)
+	/* BASE-T */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASET		UINT32_C(0x8)
+	/* EEE capable BASE-T */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASETE	UINT32_C(0x9)
+	/* SGMII connected external PHY */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_SGMIIEXTPHY	UINT32_C(0xa)
+	/* 25G_BASECR_CA_L */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_25G_BASECR_CA_L  UINT32_C(0xb)
+	/* 25G_BASECR_CA_S */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_25G_BASECR_CA_S  UINT32_C(0xc)
+	/* 25G_BASECR_CA_N */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_25G_BASECR_CA_N  UINT32_C(0xd)
+	/* 25G_BASESR */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_25G_BASESR	UINT32_C(0xe)
+	/* 100G_BASECR4 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_100G_BASECR4	UINT32_C(0xf)
+	/* 100G_BASESR4 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_100G_BASESR4	UINT32_C(0x10)
+	/* 100G_BASELR4 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_100G_BASELR4	UINT32_C(0x11)
+	/* 100G_BASEER4 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_100G_BASEER4	UINT32_C(0x12)
+	/* 100G_BASESR10 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_100G_BASESR10	UINT32_C(0x13)
+	/* 40G_BASECR4 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_40G_BASECR4	UINT32_C(0x14)
+	/* 40G_BASESR4 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_40G_BASESR4	UINT32_C(0x15)
+	/* 40G_BASELR4 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_40G_BASELR4	UINT32_C(0x16)
+	/* 40G_BASEER4 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_40G_BASEER4	UINT32_C(0x17)
+	/* 40G_ACTIVE_CABLE */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_40G_ACTIVE_CABLE UINT32_C(0x18)
+	/* 1G_baseT */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_1G_BASET	UINT32_C(0x19)
+	/* 1G_baseSX */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_1G_BASESX	UINT32_C(0x1a)
+	/* 1G_baseCX */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_1G_BASECX	UINT32_C(0x1b)
+	/* 200G_BASECR4 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_200G_BASECR4	UINT32_C(0x1c)
+	/* 200G_BASESR4 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_200G_BASESR4	UINT32_C(0x1d)
+	/* 200G_BASELR4 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_200G_BASELR4	UINT32_C(0x1e)
+	/* 200G_BASEER4 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_200G_BASEER4	UINT32_C(0x1f)
+	/* 50G_BASECR */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_50G_BASECR	UINT32_C(0x20)
+	/* 50G_BASESR */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_50G_BASESR	UINT32_C(0x21)
+	/* 50G_BASELR */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_50G_BASELR	UINT32_C(0x22)
+	/* 50G_BASEER */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_50G_BASEER	UINT32_C(0x23)
+	/* 100G_BASECR2 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_100G_BASECR2	UINT32_C(0x24)
+	/* 100G_BASESR2 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_100G_BASESR2	UINT32_C(0x25)
+	/* 100G_BASELR2 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_100G_BASELR2	UINT32_C(0x26)
+	/* 100G_BASEER2 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_100G_BASEER2	UINT32_C(0x27)
+	/* 400G_BASECR */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_100G_BASECR	UINT32_C(0x28)
+	/* 100G_BASESR */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_100G_BASESR	UINT32_C(0x29)
+	/* 100G_BASELR */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_100G_BASELR	UINT32_C(0x2a)
+	/* 100G_BASEER */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_100G_BASEER	UINT32_C(0x2b)
+	/* 200G_BASECR2 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_200G_BASECR2	UINT32_C(0x2c)
+	/* 200G_BASESR2 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_200G_BASESR2	UINT32_C(0x2d)
+	/* 200G_BASELR2 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_200G_BASELR2	UINT32_C(0x2e)
+	/* 200G_BASEER2 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_200G_BASEER2	UINT32_C(0x2f)
+	/* 400G_BASECR8 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_400G_BASECR8	UINT32_C(0x30)
+	/* 200G_BASESR8 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_400G_BASESR8	UINT32_C(0x31)
+	/* 400G_BASELR8 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_400G_BASELR8	UINT32_C(0x32)
+	/* 400G_BASEER8 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_400G_BASEER8	UINT32_C(0x33)
+	/* 400G_BASECR4 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_400G_BASECR4	UINT32_C(0x34)
+	/* 400G_BASESR4 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_400G_BASESR4	UINT32_C(0x35)
+	/* 400G_BASELR4 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_400G_BASELR4	UINT32_C(0x36)
+	/* 400G_BASEER4 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_400G_BASEER4	UINT32_C(0x37)
+	/* 800G_BASECR8 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_800G_BASECR8	UINT32_C(0x38)
+	/* 800G_BASESR8 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_800G_BASESR8	UINT32_C(0x39)
+	/* 800G_BASELR8 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_800G_BASELR8	UINT32_C(0x3a)
+	/* 800G_BASEER8 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_800G_BASEER8	UINT32_C(0x3b)
+	/* 800G_BASEFR8 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_800G_BASEFR8	UINT32_C(0x3c)
+	/* 800G_BASEDR8 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_800G_BASEDR8	UINT32_C(0x3d)
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_LAST		HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_800G_BASEDR8
+	/* This value represents a media type. */
+	uint8_t	media_type;
+	/* Unknown */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_MEDIA_TYPE_UNKNOWN UINT32_C(0x0)
+	/* Twisted Pair */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_MEDIA_TYPE_TP	UINT32_C(0x1)
+	/* Direct Attached Copper */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_MEDIA_TYPE_DAC	UINT32_C(0x2)
+	/* Fiber */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_MEDIA_TYPE_FIBRE   UINT32_C(0x3)
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_MEDIA_TYPE_LAST   HWRM_PORT_PHY_QCFG_OUTPUT_MEDIA_TYPE_FIBRE
+	/* This value represents a transceiver type. */
+	uint8_t	xcvr_pkg_type;
+	/* PHY and MAC are in the same package */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_PKG_TYPE_XCVR_INTERNAL UINT32_C(0x1)
+	/* PHY and MAC are in different packages */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_PKG_TYPE_XCVR_EXTERNAL UINT32_C(0x2)
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_PKG_TYPE_LAST	HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_PKG_TYPE_XCVR_EXTERNAL
+	uint8_t	eee_config_phy_addr;
+	/* This field represents PHY address. */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_ADDR_MASK		UINT32_C(0x1f)
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_ADDR_SFT		0
+	/*
+	 * This field represents flags related to EEE configuration.
+	 * These EEE configuration flags are valid only when the
+	 * auto_mode is not set to none (in other words autonegotiation
+	 * is enabled).
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_EEE_CONFIG_MASK		UINT32_C(0xe0)
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_EEE_CONFIG_SFT		5
+	/*
+	 * When set to 1, Energy Efficient Ethernet (EEE) mode is
+	 * enabled. Speeds for autoneg with EEE mode enabled are based on
+	 * eee_link_speed_mask.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_EEE_CONFIG_EEE_ENABLED	UINT32_C(0x20)
+	/*
+	 * This flag is valid only when eee_enabled is set to 1.
+	 *
+	 * # If eee_enabled is set to 0, then EEE mode is disabled
+	 * and this flag shall be ignored.
+	 * # If eee_enabled is set to 1 and this flag is set to 1,
+	 * then Energy Efficient Ethernet (EEE) mode is enabled
+	 * and in use.
+	 * # If eee_enabled is set to 1 and this flag is set to 0,
+	 * then Energy Efficient Ethernet (EEE) mode is enabled
+	 * but is currently not in use.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_EEE_CONFIG_EEE_ACTIVE	UINT32_C(0x40)
+	/*
+	 * This flag is valid only when eee_enabled is set to 1.
+	 *
+	 * # If eee_enabled is set to 0, then EEE mode is disabled
+	 * and this flag shall be ignored.
+	 * # If eee_enabled is set to 1 and this flag is set to 1,
+	 * then Energy Efficient Ethernet (EEE) mode is enabled
+	 * and TX LPI is enabled.
+	 * # If eee_enabled is set to 1 and this flag is set to 0,
+	 * then Energy Efficient Ethernet (EEE) mode is enabled
+	 * but TX LPI is disabled.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_EEE_CONFIG_EEE_TX_LPI	UINT32_C(0x80)
+	/*
+	 * When set to 1, the parallel detection is used to determine
+	 * the speed of the link partner.
+	 *
+	 * Parallel detection is used when a autonegotiation capable
+	 * device is connected to a link partner that is not capable
+	 * of autonegotiation.
+	 */
+	uint8_t	parallel_detect;
+	/*
+	 * When set to 1, the parallel detection is used to determine
+	 * the speed of the link partner.
+	 *
+	 * Parallel detection is used when a autonegotiation capable
+	 * device is connected to a link partner that is not capable
+	 * of autonegotiation.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_PARALLEL_DETECT	UINT32_C(0x1)
+	/*
+	 * The advertised speeds for the port by the link partner.
+	 * Each advertised speed will be set to '1'.
+	 */
+	uint16_t	link_partner_adv_speeds;
+	/* 100Mb link speed (Half-duplex) */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_SPEEDS_100MBHD	UINT32_C(0x1)
+	/* 100Mb link speed (Full-duplex) */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_SPEEDS_100MB	UINT32_C(0x2)
+	/* 1Gb link speed (Half-duplex) */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_SPEEDS_1GBHD	UINT32_C(0x4)
+	/* 1Gb link speed (Full-duplex) */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_SPEEDS_1GB	UINT32_C(0x8)
+	/* 2Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_SPEEDS_2GB	UINT32_C(0x10)
+	/* 25Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_SPEEDS_2_5GB	UINT32_C(0x20)
+	/* 10Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_SPEEDS_10GB	UINT32_C(0x40)
+	/* 20Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_SPEEDS_20GB	UINT32_C(0x80)
+	/* 25Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_SPEEDS_25GB	UINT32_C(0x100)
+	/* 40Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_SPEEDS_40GB	UINT32_C(0x200)
+	/* 50Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_SPEEDS_50GB	UINT32_C(0x400)
+	/* 100Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_SPEEDS_100GB	UINT32_C(0x800)
+	/* 10Mb link speed (Half-duplex) */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_SPEEDS_10MBHD	UINT32_C(0x1000)
+	/* 10Mb link speed (Full-duplex) */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_SPEEDS_10MB	UINT32_C(0x2000)
+	/*
+	 * The advertised autoneg for the port by the link partner.
+	 * This field is deprecated and should be set to 0.
+	 */
+	uint8_t	link_partner_adv_auto_mode;
+	/* Disable autoneg or autoneg disabled. No speeds are selected. */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_AUTO_MODE_NONE	UINT32_C(0x0)
+	/* Select all possible speeds for autoneg mode. */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_AUTO_MODE_ALL_SPEEDS   UINT32_C(0x1)
+	/*
+	 * Select only the auto_link_speed speed for autoneg mode. This mode
+	 * has been DEPRECATED. An HWRM client should not use this mode.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_AUTO_MODE_ONE_SPEED	UINT32_C(0x2)
+	/*
+	 * Select the auto_link_speed or any speed below that speed for
+	 * autoneg. This mode has been DEPRECATED. An HWRM client should not
+	 * use this mode.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_AUTO_MODE_ONE_OR_BELOW UINT32_C(0x3)
+	/*
+	 * Select the speeds based on the corresponding link speed mask value
+	 * that is provided.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_AUTO_MODE_SPEED_MASK   UINT32_C(0x4)
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_AUTO_MODE_LAST	HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_AUTO_MODE_SPEED_MASK
+	/* The advertised pause settings on the port by the link partner. */
+	uint8_t	link_partner_adv_pause;
+	/*
+	 * When this bit is '1', Generation of tx pause messages
+	 * is supported. Disabled otherwise.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_PAUSE_TX	UINT32_C(0x1)
+	/*
+	 * When this bit is '1', Reception of rx pause messages
+	 * is supported. Disabled otherwise.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_PAUSE_RX	UINT32_C(0x2)
+	/*
+	 * Current setting for link speed mask that is used to
+	 * advertise speeds during autonegotiation when EEE is enabled.
+	 * This field is valid only when eee_enabled flags is set to 1.
+	 * The speeds specified in this field shall be a subset of
+	 * speeds specified in auto_link_speed_mask.
+	 */
+	uint16_t	adv_eee_link_speed_mask;
+	/* Reserved */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_ADV_EEE_LINK_SPEED_MASK_RSVD1	UINT32_C(0x1)
+	/* 100Mb link speed (Full-duplex) */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_ADV_EEE_LINK_SPEED_MASK_100MB	UINT32_C(0x2)
+	/* Reserved */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_ADV_EEE_LINK_SPEED_MASK_RSVD2	UINT32_C(0x4)
+	/* 1Gb link speed (Full-duplex) */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_ADV_EEE_LINK_SPEED_MASK_1GB	UINT32_C(0x8)
+	/* Reserved */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_ADV_EEE_LINK_SPEED_MASK_RSVD3	UINT32_C(0x10)
+	/* Reserved */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_ADV_EEE_LINK_SPEED_MASK_RSVD4	UINT32_C(0x20)
+	/* 10Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_ADV_EEE_LINK_SPEED_MASK_10GB	UINT32_C(0x40)
+	/*
+	 * Current setting for link speed mask that is advertised by
+	 * the link partner when EEE is enabled.
+	 * This field is valid only when eee_enabled flags is set to 1.
+	 */
+	uint16_t	link_partner_adv_eee_link_speed_mask;
+	/* Reserved */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_EEE_LINK_SPEED_MASK_RSVD1	UINT32_C(0x1)
+	/* 100Mb link speed (Full-duplex) */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_EEE_LINK_SPEED_MASK_100MB	UINT32_C(0x2)
+	/* Reserved */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_EEE_LINK_SPEED_MASK_RSVD2	UINT32_C(0x4)
+	/* 1Gb link speed (Full-duplex) */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_EEE_LINK_SPEED_MASK_1GB	UINT32_C(0x8)
+	/* Reserved */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_EEE_LINK_SPEED_MASK_RSVD3	UINT32_C(0x10)
+	/* Reserved */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_EEE_LINK_SPEED_MASK_RSVD4	UINT32_C(0x20)
+	/* 10Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_EEE_LINK_SPEED_MASK_10GB	UINT32_C(0x40)
+	uint32_t	xcvr_identifier_type_tx_lpi_timer;
+	/*
+	 * Current setting of TX LPI timer in microseconds.
+	 * This field is valid only when_eee_enabled flag is set to 1
+	 * and tx_lpi_enabled is set to 1.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_TX_LPI_TIMER_MASK		UINT32_C(0xffffff)
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_TX_LPI_TIMER_SFT		0
+	/* This value represents transceiver identifier type. */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_IDENTIFIER_TYPE_MASK	UINT32_C(0xff000000)
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_IDENTIFIER_TYPE_SFT	24
+	/* Unknown */
+		#define HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_IDENTIFIER_TYPE_UNKNOWN   (UINT32_C(0x0) << 24)
+	/* SFP/SFP+/SFP28 */
+		#define HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_IDENTIFIER_TYPE_SFP	(UINT32_C(0x3) << 24)
+	/* QSFP+ */
+		#define HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_IDENTIFIER_TYPE_QSFP	(UINT32_C(0xc) << 24)
+	/* QSFP+ */
+		#define HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_IDENTIFIER_TYPE_QSFPPLUS  (UINT32_C(0xd) << 24)
+	/* QSFP28/QSFP56 or later */
+		#define HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_IDENTIFIER_TYPE_QSFP28	(UINT32_C(0x11) << 24)
+	/* QSFP-DD */
+		#define HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_IDENTIFIER_TYPE_QSFPDD	(UINT32_C(0x18) << 24)
+	/* QSFP112 */
+		#define HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_IDENTIFIER_TYPE_QSFP112   (UINT32_C(0x1e) << 24)
+	/* SFP-DD CMIS */
+		#define HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_IDENTIFIER_TYPE_SFPDD	(UINT32_C(0x1f) << 24)
+	/* SFP CMIS */
+		#define HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_IDENTIFIER_TYPE_CSFP	(UINT32_C(0x20) << 24)
+		#define HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_IDENTIFIER_TYPE_LAST	HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_IDENTIFIER_TYPE_CSFP
+	/*
+	 * This value represents the current configuration of
+	 * Forward Error Correction (FEC) on the port.
+	 */
+	uint16_t	fec_cfg;
+	/*
+	 * When set to 1, then FEC is not supported on this port. If this
+	 * flag is set to 1, then all other FEC configuration flags shall be
+	 * ignored. When set to 0, then FEC is supported as indicated by
+	 * other configuration flags.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FEC_CFG_FEC_NONE_SUPPORTED	UINT32_C(0x1)
+	/*
+	 * When set to 1, then FEC autonegotiation is supported on this port.
+	 * When set to 0, then FEC autonegotiation is not supported on this
+	 * port.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FEC_CFG_FEC_AUTONEG_SUPPORTED	UINT32_C(0x2)
+	/*
+	 * When set to 1, then FEC autonegotiation is enabled on this port.
+	 * When set to 0, then FEC autonegotiation is disabled if supported.
+	 * This flag should be ignored if FEC autonegotiation is not
+	 * supported on this port.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FEC_CFG_FEC_AUTONEG_ENABLED	UINT32_C(0x4)
+	/*
+	 * When set to 1, then FEC CLAUSE 74 (Fire Code) is supported on this
+	 * port. When set to 0, then FEC CLAUSE 74 (Fire Code) is not
+	 * supported on this port.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FEC_CFG_FEC_CLAUSE74_SUPPORTED	UINT32_C(0x8)
+	/*
+	 * When set to 1, then FEC CLAUSE 74 (Fire Code) is enabled on this
+	 * port. This means that FEC CLAUSE 74 is either advertised if
+	 * FEC autonegotiation is enabled or FEC CLAUSE 74 is force enabled.
+	 * When set to 0, then FEC CLAUSE 74 (Fire Code) is disabled if
+	 * supported. This flag should be ignored if FEC CLAUSE 74 is not
+	 * supported on this port.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FEC_CFG_FEC_CLAUSE74_ENABLED	UINT32_C(0x10)
+	/*
+	 * When set to 1, then FEC CLAUSE 91 (Reed Solomon RS(528,514) for
+	 * NRZ) is supported on this port.
+	 * When set to 0, then FEC RS(528,418) is not supported on this port.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FEC_CFG_FEC_CLAUSE91_SUPPORTED	UINT32_C(0x20)
+	/*
+	 * When set to 1, then FEC CLAUSE 91 (Reed Solomon RS(528,514) for
+	 * NRZ) is enabled on this port. This means that FEC RS(528,514) is
+	 * either advertised if FEC autonegotiation is enabled or FEC
+	 * RS(528,514) is force enabled. When set to 0, then FEC RS(528,514)
+	 * is disabled if supported.
+	 * This flag should be ignored if FEC CLAUSE 91 is not supported on
+	 * this port.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FEC_CFG_FEC_CLAUSE91_ENABLED	UINT32_C(0x40)
+	/*
+	 * When set to 1, then FEC RS544_1XN is supported on this port.
+	 * When set to 0, then FEC RS544_1XN is not supported on this port.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FEC_CFG_FEC_RS544_1XN_SUPPORTED	UINT32_C(0x80)
+	/*
+	 * When set to 1, then RS544_1XN is enabled on this
+	 * port. This means that FEC RS544_1XN is either advertised if
+	 * FEC autonegotiation is enabled or FEC RS544_1XN is force enabled.
+	 * When set to 0, then FEC RS544_1XN is disabled if supported.
+	 * This flag should be ignored if FEC RS544_1XN is not supported on
+	 * this port.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FEC_CFG_FEC_RS544_1XN_ENABLED	UINT32_C(0x100)
+	/*
+	 * When set to 1, then FEC RS(544,514) is supported on this port.
+	 * When set to 0, then FEC RS(544,514) is not supported on this port.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FEC_CFG_FEC_RS544_IEEE_SUPPORTED	UINT32_C(0x200)
+	/*
+	 * When set to 1, then RS(544,514) is enabled on this
+	 * port. This means that FEC RS(544,514) is either advertised if
+	 * FEC autonegotiation is enabled or FEC RS(544,514) is force
+	 * enabled. When set to 0, then FEC RS(544,514) is disabled if
+	 * supported. This flag should be ignored if FEC RS(544,514) is not
+	 * supported on this port.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FEC_CFG_FEC_RS544_IEEE_ENABLED	UINT32_C(0x400)
+	/*
+	 * When set to 1, then FEC RS272_1XN is supported on this port.
+	 * When set to 0, then FEC RS272_1XN is not supported on this port.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FEC_CFG_FEC_RS272_1XN_SUPPORTED	UINT32_C(0x800)
+	/*
+	 * When set to 1, then RS272_1XN is enabled on this
+	 * port. This means that FEC RS272_1XN is either advertised if
+	 * FEC autonegotiation is enabled or FEC RS272_1XN is force
+	 * enabled. When set to 0, then FEC RS272_1XN is disabled if
+	 * supported.
+	 * This flag should be ignored if FEC RS272_1XN is not supported on
+	 * this port.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FEC_CFG_FEC_RS272_1XN_ENABLED	UINT32_C(0x1000)
+	/*
+	 * When set to 1, then FEC RS(272,514) is supported on this port.
+	 * When set to 0, then FEC RS(272,514) is not supported on this port.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FEC_CFG_FEC_RS272_IEEE_SUPPORTED	UINT32_C(0x2000)
+	/*
+	 * When set to 1, then RS(272,257) is enabled on this
+	 * port. This means that FEC RS(272,257) is either advertised if
+	 * FEC autonegotiation is enabled or FEC RS(272,257) is force
+	 * enabled. When set to 0, then FEC RS(272,257) is disabled if
+	 * supported.
+	 * This flag should be ignored if FEC RS(272,257) is not supported on
+	 * this port.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FEC_CFG_FEC_RS272_IEEE_ENABLED	UINT32_C(0x4000)
+	/*
+	 * This value is indicates the duplex of the current
+	 * connection state.
+	 */
+	uint8_t	duplex_state;
+	/* Half Duplex connection. */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_DUPLEX_STATE_HALF UINT32_C(0x0)
+	/* Full duplex connection. */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_DUPLEX_STATE_FULL UINT32_C(0x1)
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_DUPLEX_STATE_LAST HWRM_PORT_PHY_QCFG_OUTPUT_DUPLEX_STATE_FULL
+	/* Option flags fields. */
+	uint8_t	option_flags;
+	/* When this bit is '1', Media auto detect is enabled. */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_OPTION_FLAGS_MEDIA_AUTO_DETECT	UINT32_C(0x1)
+	/*
+	 * When this bit is '1', active_fec_signal_mode can be
+	 * trusted.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_OPTION_FLAGS_SIGNAL_MODE_KNOWN	UINT32_C(0x2)
+	/*
+	 * When this bit is '1', speeds2 fields are used to get
+	 * speed details.
+	 */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_OPTION_FLAGS_SPEEDS2_SUPPORTED	UINT32_C(0x4)
+	/*
+	 * Up to 16 bytes of null padded ASCII string representing
+	 * PHY vendor.
+	 * If the string is set to null, then the vendor name is not
+	 * available.
+	 */
+	char	phy_vendor_name[16];
+	/*
+	 * Up to 16 bytes of null padded ASCII string that
+	 * identifies vendor specific part number of the PHY.
+	 * If the string is set to null, then the vendor specific
+	 * part number is not available.
+	 */
+	char	phy_vendor_partnumber[16];
+	/*
+	 * The supported PAM4 speeds for the port. This is a bit mask.
+	 * For each speed that is supported, the corresponding
+	 * bit will be set to '1'.
+	 */
+	uint16_t	support_pam4_speeds;
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_PAM4_SPEEDS_50G	UINT32_C(0x1)
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_PAM4_SPEEDS_100G	UINT32_C(0x2)
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_PAM4_SPEEDS_200G	UINT32_C(0x4)
+	/*
+	 * Current setting of forced PAM4 link speed.
+	 * When the link speed is not being forced, this
+	 * value shall be set to 0.
+	 */
+	uint16_t	force_pam4_link_speed;
+	/* 50Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_PAM4_LINK_SPEED_50GB  UINT32_C(0x1f4)
+	/* 100Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_PAM4_LINK_SPEED_100GB UINT32_C(0x3e8)
+	/* 200Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_PAM4_LINK_SPEED_200GB UINT32_C(0x7d0)
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_PAM4_LINK_SPEED_LAST HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_PAM4_LINK_SPEED_200GB
+	/*
+	 * Current setting for auto_pam4_link_speed_mask that is used to
+	 * advertise speeds during autonegotiation.
+	 * This field is only valid when auto_mode is set to "mask".
+	 * The speeds specified in this field shall be a subset of
+	 * supported speeds on this port.
+	 */
+	uint16_t	auto_pam4_link_speed_mask;
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_PAM4_LINK_SPEED_MASK_50G	UINT32_C(0x1)
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_PAM4_LINK_SPEED_MASK_100G	UINT32_C(0x2)
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_PAM4_LINK_SPEED_MASK_200G	UINT32_C(0x4)
+	/*
+	 * The advertised PAM4 speeds for the port by the link partner.
+	 * Each advertised speed will be set to '1'.
+	 */
+	uint8_t	link_partner_pam4_adv_speeds;
+	/* 50Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_PAM4_ADV_SPEEDS_50GB	UINT32_C(0x1)
+	/* 100Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_PAM4_ADV_SPEEDS_100GB	UINT32_C(0x2)
+	/* 200Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_PAM4_ADV_SPEEDS_200GB	UINT32_C(0x4)
+	/*
+	 * This field is used to indicate the reasons for link down.
+	 * This field is set to 0, if the link down reason is unknown.
+	 */
+	uint8_t	link_down_reason;
+	/* Remote fault */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_DOWN_REASON_RF	UINT32_C(0x1)
+	/*
+	 * The supported speeds for the port. This is a bit mask.
+	 * For each speed that is supported, the corresponding
+	 * bit will be set to '1'. This is valid only if speeds2_supported
+	 * is set in option_flags
+	 */
+	uint16_t	support_speeds2;
+	/* 1Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS2_1GB		UINT32_C(0x1)
+	/* 10Gb (NRZ: 10G per lane, 1 lane) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS2_10GB		UINT32_C(0x2)
+	/* 25Gb (NRZ: 25G per lane, 1 lane) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS2_25GB		UINT32_C(0x4)
+	/* 40Gb (NRZ: 10G per lane, 4 lanes) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS2_40GB		UINT32_C(0x8)
+	/* 50Gb (NRZ: 25G per lane, 2 lanes) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS2_50GB		UINT32_C(0x10)
+	/* 100Gb (NRZ: 25G per lane, 4 lanes) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS2_100GB		UINT32_C(0x20)
+	/* 50Gb (PAM4-56: 50G per lane, 1 lane) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS2_50GB_PAM4_56	UINT32_C(0x40)
+	/* 100Gb (PAM4-56: 50G per lane, 2 lanes) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS2_100GB_PAM4_56	UINT32_C(0x80)
+	/* 200Gb (PAM4-56: 50G per lane, 4 lanes) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS2_200GB_PAM4_56	UINT32_C(0x100)
+	/* 400Gb (PAM4-56: 50G per lane, 8 lanes) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS2_400GB_PAM4_56	UINT32_C(0x200)
+	/* 100Gb (PAM4-112: 100G per lane, 1 lane) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS2_100GB_PAM4_112	UINT32_C(0x400)
+	/* 200Gb (PAM4-112: 100G per lane, 2 lanes) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS2_200GB_PAM4_112	UINT32_C(0x800)
+	/* 400Gb (PAM4-112: 100G per lane, 4 lanes) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS2_400GB_PAM4_112	UINT32_C(0x1000)
+	/* 800Gb (PAM4-112: 100G per lane, 8 lanes) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS2_800GB_PAM4_112	UINT32_C(0x2000)
+	/*
+	 * Current setting of forced link speed. When the link speed is not
+	 * being forced, this value shall be set to 0.
+	 * This field is valid only if speeds2_supported is set in
+	 * option_flags.
+	 */
+	uint16_t	force_link_speeds2;
+	/* 1Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEEDS2_1GB		UINT32_C(0xa)
+	/* 10Gb (NRZ: 10G per lane, 1 lane) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEEDS2_10GB	UINT32_C(0x64)
+	/* 25Gb (NRZ: 25G per lane, 1 lane) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEEDS2_25GB	UINT32_C(0xfa)
+	/* 40Gb (NRZ: 10G per lane, 4 lanes) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEEDS2_40GB	UINT32_C(0x190)
+	/* 50Gb (NRZ: 25G per lane, 2 lanes) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEEDS2_50GB	UINT32_C(0x1f4)
+	/* 100Gb (NRZ: 25G per lane, 4 lanes) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEEDS2_100GB	UINT32_C(0x3e8)
+	/* 50Gb (PAM4-56: 50G per lane, 1 lane) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEEDS2_50GB_PAM4_56   UINT32_C(0x1f5)
+	/* 100Gb (PAM4-56: 50G per lane, 2 lanes) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEEDS2_100GB_PAM4_56  UINT32_C(0x3e9)
+	/* 200Gb (PAM4-56: 50G per lane, 4 lanes) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEEDS2_200GB_PAM4_56  UINT32_C(0x7d1)
+	/* 400Gb (PAM4-56: 50G per lane, 8 lanes) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEEDS2_400GB_PAM4_56  UINT32_C(0xfa1)
+	/* 100Gb (PAM4-112: 100G per lane, 1 lane) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEEDS2_100GB_PAM4_112 UINT32_C(0x3ea)
+	/* 200Gb (PAM4-112: 100G per lane, 2 lanes) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEEDS2_200GB_PAM4_112 UINT32_C(0x7d2)
+	/* 400Gb (PAM4-112: 100G per lane, 4 lanes) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEEDS2_400GB_PAM4_112 UINT32_C(0xfa2)
+	/* 800Gb (PAM4-112: 100G per lane, 8 lanes) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEEDS2_800GB_PAM4_112 UINT32_C(0x1f42)
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEEDS2_LAST	HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEEDS2_800GB_PAM4_112
+	/*
+	 * Current setting of auto_link speed_mask that is used to advertise
+	 * speeds during autonegotiation.
+	 * This field is only valid when auto_mode is set to "mask".
+	 * and if speeds2_supported is set in option_flags
+	 * The speeds specified in this field shall be a subset of
+	 * supported speeds on this port.
+	 */
+	uint16_t	auto_link_speeds2;
+	/* 1Gb link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEEDS2_1GB		UINT32_C(0x1)
+	/* 10Gb (NRZ: 10G per lane, 1 lane) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEEDS2_10GB		UINT32_C(0x2)
+	/* 25Gb (NRZ: 25G per lane, 1 lane) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEEDS2_25GB		UINT32_C(0x4)
+	/* 40Gb (NRZ: 10G per lane, 4 lanes) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEEDS2_40GB		UINT32_C(0x8)
+	/* 50Gb (NRZ: 25G per lane, 2 lanes) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEEDS2_50GB		UINT32_C(0x10)
+	/* 100Gb (NRZ: 25G per lane, 4 lanes) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEEDS2_100GB		UINT32_C(0x20)
+	/* 50Gb (PAM4-56: 50G per lane, 1 lane) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEEDS2_50GB_PAM4_56	UINT32_C(0x40)
+	/* 100Gb (PAM4-56: 50G per lane, 2 lanes) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEEDS2_100GB_PAM4_56	UINT32_C(0x80)
+	/* 200Gb (PAM4-56: 50G per lane, 4 lanes) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEEDS2_200GB_PAM4_56	UINT32_C(0x100)
+	/* 400Gb (PAM4-56: 50G per lane, 8 lanes) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEEDS2_400GB_PAM4_56	UINT32_C(0x200)
+	/* 100Gb (PAM4-112: 100G per lane, 1 lane) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEEDS2_100GB_PAM4_112	UINT32_C(0x400)
+	/* 200Gb (PAM4-112: 100G per lane, 2 lanes) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEEDS2_200GB_PAM4_112	UINT32_C(0x800)
+	/* 400Gb (PAM4-112: 100G per lane, 4 lanes) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEEDS2_400GB_PAM4_112	UINT32_C(0x1000)
+	/* 800Gb (PAM4-112: 100G per lane, 8 lanes) link speed */
+	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEEDS2_800GB_PAM4_112	UINT32_C(0x2000)
+	/*
+	 * This field is indicate the number of lanes used to transfer
+	 * data. If the link is down, the value is zero.
+	 * This is valid only if speeds2_supported is set in option_flags.
+	 */
+	uint8_t	active_lanes;
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_port_phy_qcfg_output_t, *phwrm_port_phy_qcfg_output_t;
+
+/*********************
+ * hwrm_port_mac_cfg *
+ *********************/
+
+
+/* hwrm_port_mac_cfg_input (size:448b/56B) */
+
+typedef struct hwrm_port_mac_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/*
+	 * In this field, there are a number of CoS mappings related flags
+	 * that are used to configure CoS mappings and their corresponding
+	 * priorities in the hardware.
+	 * For the priorities of CoS mappings, the HWRM uses the following
+	 * priority order (high to low) by default:
+	 * # vlan pri
+	 * # ip_dscp
+	 * # tunnel_vlan_pri
+	 * # default cos
+	 *
+	 * A subset of CoS mappings can be enabled.
+	 * If a priority is not specified for an enabled CoS mapping, the
+	 * priority will be assigned in the above order for the enabled CoS
+	 * mappings. For example, if vlan_pri and ip_dscp CoS mappings are
+	 * enabled and their priorities are not specified, the following
+	 * priority order (high to low) will be used by the HWRM:
+	 * # vlan_pri
+	 * # ip_dscp
+	 * # default cos
+	 *
+	 * vlan_pri CoS mapping together with default CoS with lower priority
+	 * are enabled by default by the HWRM.
+	 */
+	uint32_t	flags;
+	/*
+	 * When this bit is '1', this command will configure
+	 * the MAC to match the current link state of the PHY.
+	 * If the link is not established on the PHY, then this
+	 * bit has no effect.
+	 */
+	#define HWRM_PORT_MAC_CFG_INPUT_FLAGS_MATCH_LINK			UINT32_C(0x1)
+	/*
+	 * When this bit is set to '1', the inner VLAN PRI to CoS mapping
+	 * is requested to be enabled.
+	 */
+	#define HWRM_PORT_MAC_CFG_INPUT_FLAGS_VLAN_PRI2COS_ENABLE	UINT32_C(0x2)
+	/*
+	 * When this bit is set to '1', tunnel VLAN PRI field to
+	 * CoS mapping is requested to be enabled.
+	 */
+	#define HWRM_PORT_MAC_CFG_INPUT_FLAGS_TUNNEL_PRI2COS_ENABLE	UINT32_C(0x4)
+	/*
+	 * When this bit is set to '1', the IP DSCP to CoS mapping is
+	 * requested to be enabled.
+	 */
+	#define HWRM_PORT_MAC_CFG_INPUT_FLAGS_IP_DSCP2COS_ENABLE		UINT32_C(0x8)
+	/*
+	 * When this bit is '1', the HWRM is requested to
+	 * enable timestamp capture capability on the receive side
+	 * of this port.
+	 */
+	#define HWRM_PORT_MAC_CFG_INPUT_FLAGS_PTP_RX_TS_CAPTURE_ENABLE	UINT32_C(0x10)
+	/*
+	 * When this bit is '1', the HWRM is requested to
+	 * disable timestamp capture capability on the receive side
+	 * of this port.
+	 */
+	#define HWRM_PORT_MAC_CFG_INPUT_FLAGS_PTP_RX_TS_CAPTURE_DISABLE	UINT32_C(0x20)
+	/*
+	 * When this bit is '1', the HWRM is requested to
+	 * enable timestamp capture capability on the transmit side
+	 * of this port.
+	 */
+	#define HWRM_PORT_MAC_CFG_INPUT_FLAGS_PTP_TX_TS_CAPTURE_ENABLE	UINT32_C(0x40)
+	/*
+	 * When this bit is '1', the HWRM is requested to
+	 * disable timestamp capture capability on the transmit side
+	 * of this port.
+	 */
+	#define HWRM_PORT_MAC_CFG_INPUT_FLAGS_PTP_TX_TS_CAPTURE_DISABLE	UINT32_C(0x80)
+	/*
+	 * When this bit is '1', the Out-Of-Box WoL is requested to
+	 * be enabled on this port.
+	 */
+	#define HWRM_PORT_MAC_CFG_INPUT_FLAGS_OOB_WOL_ENABLE		UINT32_C(0x100)
+	/*
+	 * When this bit is '1', the Out-Of-Box WoL is requested to
+	 * be disabled on this port.
+	 */
+	#define HWRM_PORT_MAC_CFG_INPUT_FLAGS_OOB_WOL_DISABLE		UINT32_C(0x200)
+	/*
+	 * When this bit is set to '1', the inner VLAN PRI to CoS mapping
+	 * is requested to be disabled.
+	 */
+	#define HWRM_PORT_MAC_CFG_INPUT_FLAGS_VLAN_PRI2COS_DISABLE	UINT32_C(0x400)
+	/*
+	 * When this bit is set to '1', tunnel VLAN PRI field to
+	 * CoS mapping is requested to be disabled.
+	 */
+	#define HWRM_PORT_MAC_CFG_INPUT_FLAGS_TUNNEL_PRI2COS_DISABLE	UINT32_C(0x800)
+	/*
+	 * When this bit is set to '1', the IP DSCP to CoS mapping is
+	 * requested to be disabled.
+	 */
+	#define HWRM_PORT_MAC_CFG_INPUT_FLAGS_IP_DSCP2COS_DISABLE	UINT32_C(0x1000)
+	/*
+	 * When this bit is set to '1', and the ptp_tx_ts_capture_enable
+	 * bit is set, then the device uses one step Tx timestamping.
+	 * This bit is temporary and used for experimental purposes.
+	 */
+	#define HWRM_PORT_MAC_CFG_INPUT_FLAGS_PTP_ONE_STEP_TX_TS		UINT32_C(0x2000)
+	/*
+	 * When this bit is '1', the controller is requested to enable
+	 * timestamp capture capability on all packets (not just PTP)
+	 * of the receive side of this port.
+	 */
+	#define HWRM_PORT_MAC_CFG_INPUT_FLAGS_ALL_RX_TS_CAPTURE_ENABLE	UINT32_C(0x4000)
+	/*
+	 * When this bit is '1', the controller is requested to disable
+	 * timestamp capture capability on all packets (not just PTP)
+	 * of the receive side of this port.
+	 */
+	#define HWRM_PORT_MAC_CFG_INPUT_FLAGS_ALL_RX_TS_CAPTURE_DISABLE	UINT32_C(0x8000)
+	uint32_t	enables;
+	/*
+	 * This bit must be '1' for the ipg field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_MAC_CFG_INPUT_ENABLES_IPG				UINT32_C(0x1)
+	/*
+	 * This bit must be '1' for the lpbk field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_MAC_CFG_INPUT_ENABLES_LPBK			UINT32_C(0x2)
+	/*
+	 * This bit must be '1' for the vlan_pri2cos_map_pri field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_MAC_CFG_INPUT_ENABLES_VLAN_PRI2COS_MAP_PRI	UINT32_C(0x4)
+	/*
+	 * This bit must be '1' for the tunnel_pri2cos_map_pri field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_MAC_CFG_INPUT_ENABLES_TUNNEL_PRI2COS_MAP_PRI	UINT32_C(0x10)
+	/*
+	 * This bit must be '1' for the dscp2cos_map_pri field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_MAC_CFG_INPUT_ENABLES_DSCP2COS_MAP_PRI		UINT32_C(0x20)
+	/*
+	 * This bit must be '1' for the rx_ts_capture_ptp_msg_type field to
+	 * be configured.
+	 */
+	#define HWRM_PORT_MAC_CFG_INPUT_ENABLES_RX_TS_CAPTURE_PTP_MSG_TYPE	UINT32_C(0x40)
+	/*
+	 * This bit must be '1' for the tx_ts_capture_ptp_msg_type field to
+	 * be configured.
+	 */
+	#define HWRM_PORT_MAC_CFG_INPUT_ENABLES_TX_TS_CAPTURE_PTP_MSG_TYPE	UINT32_C(0x80)
+	/*
+	 * This bit must be '1' for the cos_field_cfg field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_MAC_CFG_INPUT_ENABLES_COS_FIELD_CFG		UINT32_C(0x100)
+	/*
+	 * This bit must be '1' for the ptp_freq_adj_ppb field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_MAC_CFG_INPUT_ENABLES_PTP_FREQ_ADJ_PPB		UINT32_C(0x200)
+	/*
+	 * This bit must be '1' for the ptp_adj_phase field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_MAC_CFG_INPUT_ENABLES_PTP_ADJ_PHASE		UINT32_C(0x400)
+	/*
+	 * This bit must be '1' for the ptp_load_control field to
+	 * be configured.
+	 */
+	#define HWRM_PORT_MAC_CFG_INPUT_ENABLES_PTP_LOAD_CONTROL		UINT32_C(0x800)
+	/* Port ID of port that is to be configured. */
+	uint16_t	port_id;
+	/*
+	 * This value is used to configure the minimum IPG that will
+	 * be sent between packets by this port.
+	 */
+	uint8_t	ipg;
+	/* This value controls the loopback setting for the MAC. */
+	uint8_t	lpbk;
+	/* No loopback is selected. Normal operation. */
+	#define HWRM_PORT_MAC_CFG_INPUT_LPBK_NONE   UINT32_C(0x0)
+	/*
+	 * The HW will be configured with local loopback such that
+	 * host data is sent back to the host without modification.
+	 */
+	#define HWRM_PORT_MAC_CFG_INPUT_LPBK_LOCAL  UINT32_C(0x1)
+	/*
+	 * The HW will be configured with remote loopback such that
+	 * port logic will send packets back out the transmitter that
+	 * are received.
+	 */
+	#define HWRM_PORT_MAC_CFG_INPUT_LPBK_REMOTE UINT32_C(0x2)
+	#define HWRM_PORT_MAC_CFG_INPUT_LPBK_LAST  HWRM_PORT_MAC_CFG_INPUT_LPBK_REMOTE
+	/*
+	 * This value controls the priority setting of VLAN PRI to CoS
+	 * mapping based on VLAN Tags of inner packet headers of
+	 * tunneled packets or packet headers of non-tunneled packets.
+	 *
+	 * # Each XXX_pri variable shall have a unique priority value
+	 * when it is being specified.
+	 * # When comparing priorities of mappings, higher value
+	 * indicates higher priority.
+	 * For example, a value of 0-3 is returned where 0 is being
+	 * the lowest priority and 3 is being the highest priority.
+	 */
+	uint8_t	vlan_pri2cos_map_pri;
+	/* Reserved field. */
+	uint8_t	reserved1;
+	/*
+	 * This value controls the priority setting of VLAN PRI to CoS
+	 * mapping based on VLAN Tags of tunneled header.
+	 * This mapping only applies when tunneled headers
+	 * are present.
+	 *
+	 * # Each XXX_pri variable shall have a unique priority value
+	 * when it is being specified.
+	 * # When comparing priorities of mappings, higher value
+	 * indicates higher priority.
+	 * For example, a value of 0-3 is returned where 0 is being
+	 * the lowest priority and 3 is being the highest priority.
+	 */
+	uint8_t	tunnel_pri2cos_map_pri;
+	/*
+	 * This value controls the priority setting of IP DSCP to CoS
+	 * mapping based on inner IP header of tunneled packets or
+	 * IP header of non-tunneled packets.
+	 *
+	 * # Each XXX_pri variable shall have a unique priority value
+	 * when it is being specified.
+	 * # When comparing priorities of mappings, higher value
+	 * indicates higher priority.
+	 * For example, a value of 0-3 is returned where 0 is being
+	 * the lowest priority and 3 is being the highest priority.
+	 */
+	uint8_t	dscp2pri_map_pri;
+	/*
+	 * This is a 16-bit bit mask that is used to request a
+	 * specific configuration of time stamp capture of PTP messages
+	 * on the receive side of this port.
+	 * This field shall be ignored if the ptp_rx_ts_capture_enable
+	 * flag is not set in this command.
+	 * Otherwise, if bit 'i' is set, then the HWRM is being
+	 * requested to configure the receive side of the port to
+	 * capture the time stamp of every received PTP message
+	 * with messageType field value set to i.
+	 */
+	uint16_t	rx_ts_capture_ptp_msg_type;
+	/*
+	 * This is a 16-bit bit mask that is used to request a
+	 * specific configuration of time stamp capture of PTP messages
+	 * on the transmit side of this port.
+	 * This field shall be ignored if the ptp_tx_ts_capture_enable
+	 * flag is not set in this command.
+	 * Otherwise, if bit 'i' is set, then the HWRM is being
+	 * requested to configure the transmit side of the port to
+	 * capture the time stamp of every transmitted PTP message
+	 * with messageType field value set to i.
+	 */
+	uint16_t	tx_ts_capture_ptp_msg_type;
+	/* Configuration of CoS fields. */
+	uint8_t	cos_field_cfg;
+	/* Reserved */
+	#define HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_RSVD1			UINT32_C(0x1)
+	/*
+	 * This field is used to specify selection of VLAN PRI value
+	 * based on whether one or two VLAN Tags are present in
+	 * the inner packet headers of tunneled packets or
+	 * non-tunneled packets.
+	 * This field is valid only if inner VLAN PRI to CoS mapping
+	 * is enabled.
+	 * If VLAN PRI to CoS mapping is not enabled, then this
+	 * field shall be ignored.
+	 */
+	#define HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_VLAN_PRI_SEL_MASK	UINT32_C(0x6)
+	#define HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_VLAN_PRI_SEL_SFT	1
+	/*
+	 * Select inner VLAN PRI when 1 or 2 VLAN Tags are
+	 * present in the inner packet headers
+	 */
+		#define HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_VLAN_PRI_SEL_INNERMOST	(UINT32_C(0x0) << 1)
+	/*
+	 * Select outer VLAN Tag PRI when 2 VLAN Tags are
+	 * present in the inner packet headers.
+	 * No VLAN PRI shall be selected for this configuration
+	 * if only one VLAN Tag is present in the inner
+	 * packet headers.
+	 */
+		#define HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_VLAN_PRI_SEL_OUTER	(UINT32_C(0x1) << 1)
+	/*
+	 * Select outermost VLAN PRI when 1 or 2 VLAN Tags
+	 * are present in the inner packet headers
+	 */
+		#define HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_VLAN_PRI_SEL_OUTERMOST	(UINT32_C(0x2) << 1)
+	/* Unspecified */
+		#define HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_VLAN_PRI_SEL_UNSPECIFIED	(UINT32_C(0x3) << 1)
+		#define HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_VLAN_PRI_SEL_LAST	HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_VLAN_PRI_SEL_UNSPECIFIED
+	/*
+	 * This field is used to specify selection of tunnel VLAN
+	 * PRI value based on whether one or two VLAN Tags are
+	 * present in tunnel headers.
+	 * This field is valid only if tunnel VLAN PRI to CoS mapping
+	 * is enabled.
+	 * If tunnel VLAN PRI to CoS mapping is not enabled, then this
+	 * field shall be ignored.
+	 */
+	#define HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_T_VLAN_PRI_SEL_MASK	UINT32_C(0x18)
+	#define HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_T_VLAN_PRI_SEL_SFT	3
+	/*
+	 * Select inner VLAN PRI when 1 or 2 VLAN Tags are
+	 * present in the tunnel packet headers
+	 */
+		#define HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_T_VLAN_PRI_SEL_INNERMOST	(UINT32_C(0x0) << 3)
+	/*
+	 * Select outer VLAN Tag PRI when 2 VLAN Tags are
+	 * present in the tunnel packet headers.
+	 * No tunnel VLAN PRI shall be selected for this
+	 * configuration if only one VLAN Tag is present in
+	 * the tunnel packet headers.
+	 */
+		#define HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_T_VLAN_PRI_SEL_OUTER	(UINT32_C(0x1) << 3)
+	/*
+	 * Select outermost VLAN PRI when 1 or 2 VLAN Tags
+	 * are present in the tunnel packet headers
+	 */
+		#define HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_T_VLAN_PRI_SEL_OUTERMOST	(UINT32_C(0x2) << 3)
+	/* Unspecified */
+		#define HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_T_VLAN_PRI_SEL_UNSPECIFIED  (UINT32_C(0x3) << 3)
+		#define HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_T_VLAN_PRI_SEL_LAST	HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_T_VLAN_PRI_SEL_UNSPECIFIED
+	/*
+	 * This field shall be used to provide default CoS value
+	 * that has been configured on this port.
+	 * This field is valid only if default CoS mapping
+	 * is enabled.
+	 * If default CoS mapping is not enabled, then this
+	 * field shall be ignored.
+	 */
+	#define HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_DEFAULT_COS_MASK	UINT32_C(0xe0)
+	#define HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_DEFAULT_COS_SFT	5
+	uint8_t	unused_0[3];
+	/*
+	 * This signed field specifies by how much to adjust the frequency
+	 * of sync timer updates (measured in parts per billion).
+	 */
+	int32_t	ptp_freq_adj_ppb;
+	uint8_t	unused_1[3];
+	/*
+	 * This value controls how PTP configuration like freq_adj and
+	 * phase are loaded in the hardware block.
+	 */
+	uint8_t	ptp_load_control;
+	/* PTP configuration is not loaded in hardware. */
+	#define HWRM_PORT_MAC_CFG_INPUT_PTP_LOAD_CONTROL_NONE	UINT32_C(0x0)
+	/*
+	 * PTP configuration will be loaded immediately in the hardware
+	 * block. By default, it will always be immediate.
+	 */
+	#define HWRM_PORT_MAC_CFG_INPUT_PTP_LOAD_CONTROL_IMMEDIATE UINT32_C(0x1)
+	/*
+	 * PTP configuration will loaded at the next Pulse per second (PPS)
+	 * event in the hardware block.
+	 */
+	#define HWRM_PORT_MAC_CFG_INPUT_PTP_LOAD_CONTROL_PPS_EVENT UINT32_C(0x2)
+	#define HWRM_PORT_MAC_CFG_INPUT_PTP_LOAD_CONTROL_LAST	HWRM_PORT_MAC_CFG_INPUT_PTP_LOAD_CONTROL_PPS_EVENT
+	/*
+	 * This unsigned field specifies the phase offset to be applied
+	 * to the PHC (PTP Hardware Clock). This field is specified in
+	 * nanoseconds.
+	 */
+	int64_t	ptp_adj_phase;
+} hwrm_port_mac_cfg_input_t, *phwrm_port_mac_cfg_input_t;
+
+/* hwrm_port_mac_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_port_mac_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/*
+	 * This is the configured maximum length of Ethernet packet
+	 * payload that is allowed to be received on the port.
+	 * This value does not include the number of bytes used by
+	 * Ethernet header and trailer (CRC).
+	 */
+	uint16_t	mru;
+	/*
+	 * This is the configured maximum length of Ethernet packet
+	 * payload that is allowed to be transmitted on the port.
+	 * This value does not include the number of bytes used by
+	 * Ethernet header and trailer (CRC).
+	 */
+	uint16_t	mtu;
+	/* Current configuration of the IPG value. */
+	uint8_t	ipg;
+	/* Current value of the loopback value. */
+	uint8_t	lpbk;
+	/* No loopback is selected. Normal operation. */
+	#define HWRM_PORT_MAC_CFG_OUTPUT_LPBK_NONE   UINT32_C(0x0)
+	/*
+	 * The HW will be configured with local loopback such that
+	 * host data is sent back to the host without modification.
+	 */
+	#define HWRM_PORT_MAC_CFG_OUTPUT_LPBK_LOCAL  UINT32_C(0x1)
+	/*
+	 * The HW will be configured with remote loopback such that
+	 * port logic will send packets back out the transmitter that
+	 * are received.
+	 */
+	#define HWRM_PORT_MAC_CFG_OUTPUT_LPBK_REMOTE UINT32_C(0x2)
+	#define HWRM_PORT_MAC_CFG_OUTPUT_LPBK_LAST  HWRM_PORT_MAC_CFG_OUTPUT_LPBK_REMOTE
+	uint8_t	unused_0;
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_port_mac_cfg_output_t, *phwrm_port_mac_cfg_output_t;
+
+/**********************
+ * hwrm_port_mac_qcfg *
+ **********************/
+
+
+/* hwrm_port_mac_qcfg_input (size:192b/24B) */
+
+typedef struct hwrm_port_mac_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Port ID of port that is to be configured. */
+	uint16_t	port_id;
+	uint8_t	unused_0[6];
+} hwrm_port_mac_qcfg_input_t, *phwrm_port_mac_qcfg_input_t;
+
+/* hwrm_port_mac_qcfg_output (size:256b/32B) */
+
+typedef struct hwrm_port_mac_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/*
+	 * This is the configured maximum length of Ethernet packet
+	 * payload that is allowed to be received on the port.
+	 * This value does not include the number of bytes used by the
+	 * Ethernet header and trailer (CRC).
+	 */
+	uint16_t	mru;
+	/*
+	 * This is the configured maximum length of Ethernet packet
+	 * payload that is allowed to be transmitted on the port.
+	 * This value does not include the number of bytes used by the
+	 * Ethernet header and trailer (CRC).
+	 */
+	uint16_t	mtu;
+	/*
+	 * The minimum IPG that will
+	 * be sent between packets by this port.
+	 */
+	uint8_t	ipg;
+	/* The loopback setting for the MAC. */
+	uint8_t	lpbk;
+	/* No loopback is selected. Normal operation. */
+	#define HWRM_PORT_MAC_QCFG_OUTPUT_LPBK_NONE   UINT32_C(0x0)
+	/*
+	 * The HW will be configured with local loopback such that
+	 * host data is sent back to the host without modification.
+	 */
+	#define HWRM_PORT_MAC_QCFG_OUTPUT_LPBK_LOCAL  UINT32_C(0x1)
+	/*
+	 * The HW will be configured with remote loopback such that
+	 * port logic will send packets back out the transmitter that
+	 * are received.
+	 */
+	#define HWRM_PORT_MAC_QCFG_OUTPUT_LPBK_REMOTE UINT32_C(0x2)
+	#define HWRM_PORT_MAC_QCFG_OUTPUT_LPBK_LAST  HWRM_PORT_MAC_QCFG_OUTPUT_LPBK_REMOTE
+	/*
+	 * Priority setting for VLAN PRI to CoS mapping.
+	 * # Each XXX_pri variable shall have a unique priority value
+	 * when it is being used.
+	 * # When comparing priorities of mappings, higher value
+	 * indicates higher priority.
+	 * For example, a value of 0-3 is returned where 0 is being
+	 * the lowest priority and 3 is being the highest priority.
+	 * # If the corresponding CoS mapping is not enabled, then this
+	 * field should be ignored.
+	 * # This value indicates the normalized priority value retained
+	 * in the HWRM.
+	 */
+	uint8_t	vlan_pri2cos_map_pri;
+	/*
+	 * In this field, a number of CoS mappings related flags
+	 * are used to indicate configured CoS mappings.
+	 */
+	uint8_t	flags;
+	/*
+	 * When this bit is set to '1', the inner VLAN PRI to CoS mapping
+	 * is enabled.
+	 */
+	#define HWRM_PORT_MAC_QCFG_OUTPUT_FLAGS_VLAN_PRI2COS_ENABLE	UINT32_C(0x1)
+	/*
+	 * When this bit is set to '1', tunnel VLAN PRI field to
+	 * CoS mapping is enabled.
+	 */
+	#define HWRM_PORT_MAC_QCFG_OUTPUT_FLAGS_TUNNEL_PRI2COS_ENABLE	UINT32_C(0x2)
+	/*
+	 * When this bit is set to '1', the IP DSCP to CoS mapping is
+	 * enabled.
+	 */
+	#define HWRM_PORT_MAC_QCFG_OUTPUT_FLAGS_IP_DSCP2COS_ENABLE	UINT32_C(0x4)
+	/*
+	 * When this bit is '1', the Out-Of-Box WoL is enabled on this
+	 * port.
+	 */
+	#define HWRM_PORT_MAC_QCFG_OUTPUT_FLAGS_OOB_WOL_ENABLE		UINT32_C(0x8)
+	/* When this bit is '1', PTP is enabled for RX on this port. */
+	#define HWRM_PORT_MAC_QCFG_OUTPUT_FLAGS_PTP_RX_TS_CAPTURE_ENABLE	UINT32_C(0x10)
+	/* When this bit is '1', PTP is enabled for TX on this port. */
+	#define HWRM_PORT_MAC_QCFG_OUTPUT_FLAGS_PTP_TX_TS_CAPTURE_ENABLE	UINT32_C(0x20)
+	/*
+	 * Priority setting for tunnel VLAN PRI to CoS mapping.
+	 * # Each XXX_pri variable shall have a unique priority value
+	 * when it is being used.
+	 * # When comparing priorities of mappings, higher value
+	 * indicates higher priority.
+	 * For example, a value of 0-3 is returned where 0 is being
+	 * the lowest priority and 3 is being the highest priority.
+	 * # If the corresponding CoS mapping is not enabled, then this
+	 * field should be ignored.
+	 * # This value indicates the normalized priority value retained
+	 * in the HWRM.
+	 */
+	uint8_t	tunnel_pri2cos_map_pri;
+	/*
+	 * Priority setting for DSCP to PRI mapping.
+	 * # Each XXX_pri variable shall have a unique priority value
+	 * when it is being used.
+	 * # When comparing priorities of mappings, higher value
+	 * indicates higher priority.
+	 * For example, a value of 0-3 is returned where 0 is being
+	 * the lowest priority and 3 is being the highest priority.
+	 * # If the corresponding CoS mapping is not enabled, then this
+	 * field should be ignored.
+	 * # This value indicates the normalized priority value retained
+	 * in the HWRM.
+	 */
+	uint8_t	dscp2pri_map_pri;
+	/*
+	 * This is a 16-bit bit mask that represents the
+	 * current configuration of time stamp capture of PTP messages
+	 * on the receive side of this port.
+	 * If bit 'i' is set, then the receive side of the port
+	 * is configured to capture the time stamp of every
+	 * received PTP message with messageType field value set
+	 * to i.
+	 * If all bits are set to 0 (i.e. field value set 0),
+	 * then the receive side of the port is not configured
+	 * to capture timestamp for PTP messages.
+	 * If all bits are set to 1, then the receive side of the
+	 * port is configured to capture timestamp for all PTP
+	 * messages.
+	 */
+	uint16_t	rx_ts_capture_ptp_msg_type;
+	/*
+	 * This is a 16-bit bit mask that represents the
+	 * current configuration of time stamp capture of PTP messages
+	 * on the transmit side of this port.
+	 * If bit 'i' is set, then the transmit side of the port
+	 * is configured to capture the time stamp of every
+	 * received PTP message with messageType field value set
+	 * to i.
+	 * If all bits are set to 0 (i.e. field value set 0),
+	 * then the transmit side of the port is not configured
+	 * to capture timestamp for PTP messages.
+	 * If all bits are set to 1, then the transmit side of the
+	 * port is configured to capture timestamp for all PTP
+	 * messages.
+	 */
+	uint16_t	tx_ts_capture_ptp_msg_type;
+	/* Configuration of CoS fields. */
+	uint8_t	cos_field_cfg;
+	/* Reserved */
+	#define HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_RSVD			UINT32_C(0x1)
+	/*
+	 * This field is used for selecting VLAN PRI value
+	 * based on whether one or two VLAN Tags are present in
+	 * the inner packet headers of tunneled packets or
+	 * non-tunneled packets.
+	 */
+	#define HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_VLAN_PRI_SEL_MASK	UINT32_C(0x6)
+	#define HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_VLAN_PRI_SEL_SFT	1
+	/*
+	 * Select inner VLAN PRI when 1 or 2 VLAN Tags are
+	 * present in the inner packet headers
+	 */
+		#define HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_VLAN_PRI_SEL_INNERMOST	(UINT32_C(0x0) << 1)
+	/*
+	 * Select outer VLAN Tag PRI when 2 VLAN Tags are
+	 * present in the inner packet headers.
+	 * No VLAN PRI is selected for this configuration
+	 * if only one VLAN Tag is present in the inner
+	 * packet headers.
+	 */
+		#define HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_VLAN_PRI_SEL_OUTER	(UINT32_C(0x1) << 1)
+	/*
+	 * Select outermost VLAN PRI when 1 or 2 VLAN Tags
+	 * are present in the inner packet headers
+	 */
+		#define HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_VLAN_PRI_SEL_OUTERMOST	(UINT32_C(0x2) << 1)
+	/* Unspecified */
+		#define HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_VLAN_PRI_SEL_UNSPECIFIED	(UINT32_C(0x3) << 1)
+		#define HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_VLAN_PRI_SEL_LAST	HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_VLAN_PRI_SEL_UNSPECIFIED
+	/*
+	 * This field is used for selecting tunnel VLAN PRI value
+	 * based on whether one or two VLAN Tags are present in
+	 * the tunnel headers of tunneled packets. This selection
+	 * does not apply to non-tunneled packets.
+	 */
+	#define HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_T_VLAN_PRI_SEL_MASK	UINT32_C(0x18)
+	#define HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_T_VLAN_PRI_SEL_SFT	3
+	/*
+	 * Select inner VLAN PRI when 1 or 2 VLAN Tags are
+	 * present in the tunnel packet headers
+	 */
+		#define HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_T_VLAN_PRI_SEL_INNERMOST	(UINT32_C(0x0) << 3)
+	/*
+	 * Select outer VLAN Tag PRI when 2 VLAN Tags are
+	 * present in the tunnel packet headers.
+	 * No VLAN PRI is selected for this configuration
+	 * if only one VLAN Tag is present in the tunnel
+	 * packet headers.
+	 */
+		#define HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_T_VLAN_PRI_SEL_OUTER	(UINT32_C(0x1) << 3)
+	/*
+	 * Select outermost VLAN PRI when 1 or 2 VLAN Tags
+	 * are present in the tunnel packet headers
+	 */
+		#define HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_T_VLAN_PRI_SEL_OUTERMOST	(UINT32_C(0x2) << 3)
+	/* Unspecified */
+		#define HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_T_VLAN_PRI_SEL_UNSPECIFIED  (UINT32_C(0x3) << 3)
+		#define HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_T_VLAN_PRI_SEL_LAST	HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_T_VLAN_PRI_SEL_UNSPECIFIED
+	/*
+	 * This field is used to provide default CoS value that
+	 * has been configured on this port.
+	 */
+	#define HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_DEFAULT_COS_MASK	UINT32_C(0xe0)
+	#define HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_DEFAULT_COS_SFT	5
+	uint8_t	unused_1;
+	uint16_t	port_svif_info;
+	/*
+	 * This field specifies the source virtual interface of the port
+	 * being queried. Drivers can use this to program port svif field in
+	 * the L2 context table.
+	 */
+	#define HWRM_PORT_MAC_QCFG_OUTPUT_PORT_SVIF_INFO_PORT_SVIF_MASK	UINT32_C(0x7fff)
+	#define HWRM_PORT_MAC_QCFG_OUTPUT_PORT_SVIF_INFO_PORT_SVIF_SFT	0
+	/* This field specifies whether port_svif is valid or not */
+	#define HWRM_PORT_MAC_QCFG_OUTPUT_PORT_SVIF_INFO_PORT_SVIF_VALID	UINT32_C(0x8000)
+	/*
+	 * This field indicates the configured load control for PTP
+	 * time of day (TOD) block.
+	 */
+	uint8_t	ptp_load_control;
+	/* Indicates the current load control is none. */
+	#define HWRM_PORT_MAC_QCFG_OUTPUT_PTP_LOAD_CONTROL_NONE	UINT32_C(0x0)
+	/* Indicates the current load control is immediate. */
+	#define HWRM_PORT_MAC_QCFG_OUTPUT_PTP_LOAD_CONTROL_IMMEDIATE UINT32_C(0x1)
+	/*
+	 * Indicates current load control is at next Pulse per Second (PPS)
+	 * event.
+	 */
+	#define HWRM_PORT_MAC_QCFG_OUTPUT_PTP_LOAD_CONTROL_PPS_EVENT UINT32_C(0x2)
+	#define HWRM_PORT_MAC_QCFG_OUTPUT_PTP_LOAD_CONTROL_LAST	HWRM_PORT_MAC_QCFG_OUTPUT_PTP_LOAD_CONTROL_PPS_EVENT
+	uint8_t	unused_2[4];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_port_mac_qcfg_output_t, *phwrm_port_mac_qcfg_output_t;
+
+/**************************
+ * hwrm_port_mac_ptp_qcfg *
+ **************************/
+
+
+/* hwrm_port_mac_ptp_qcfg_input (size:192b/24B) */
+
+typedef struct hwrm_port_mac_ptp_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Port ID of port that is being queried. */
+	uint16_t	port_id;
+	uint8_t	unused_0[6];
+} hwrm_port_mac_ptp_qcfg_input_t, *phwrm_port_mac_ptp_qcfg_input_t;
+
+/* hwrm_port_mac_ptp_qcfg_output (size:704b/88B) */
+
+typedef struct hwrm_port_mac_ptp_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/*
+	 * In this field, a number of PTP related flags
+	 * are used to indicate configured PTP capabilities.
+	 */
+	uint8_t	flags;
+	/*
+	 * When this bit is set to '1', the PTP related registers are
+	 * directly accessible by the host.
+	 */
+	#define HWRM_PORT_MAC_PTP_QCFG_OUTPUT_FLAGS_DIRECT_ACCESS			UINT32_C(0x1)
+	/*
+	 * When this bit is set to '1', the device supports one-step
+	 * Tx timestamping.
+	 */
+	#define HWRM_PORT_MAC_PTP_QCFG_OUTPUT_FLAGS_ONE_STEP_TX_TS			UINT32_C(0x4)
+	/*
+	 * When this bit is set to '1', the PTP information is accessible
+	 * via HWRM commands.
+	 */
+	#define HWRM_PORT_MAC_PTP_QCFG_OUTPUT_FLAGS_HWRM_ACCESS			UINT32_C(0x8)
+	/*
+	 * When this bit is set to '1', two specific registers for current
+	 * time (ts_ref_clock_reg_lower and ts_ref_clock_reg_upper) are
+	 * directly accessible by the host.
+	 */
+	#define HWRM_PORT_MAC_PTP_QCFG_OUTPUT_FLAGS_PARTIAL_DIRECT_ACCESS_REF_CLOCK	UINT32_C(0x10)
+	/*
+	 * When this bit is set to '1', it indicates that driver has
+	 * configured 64bit RTC.
+	 */
+	#define HWRM_PORT_MAC_PTP_QCFG_OUTPUT_FLAGS_RTC_CONFIGURED			UINT32_C(0x20)
+	/*
+	 * When this bit is set to '1', it indicates that current time
+	 * exposed to driver is 64bit.
+	 */
+	#define HWRM_PORT_MAC_PTP_QCFG_OUTPUT_FLAGS_64B_PHC_TIME			UINT32_C(0x40)
+	uint8_t	unused_0[3];
+	/*
+	 * Offset of the PTP register for the lower 32 bits of timestamp
+	 * for RX.
+	 */
+	uint32_t	rx_ts_reg_off_lower;
+	/*
+	 * Offset of the PTP register for the upper 32 bits of timestamp
+	 * for RX.
+	 */
+	uint32_t	rx_ts_reg_off_upper;
+	/* Offset of the PTP register for the sequence ID for RX. */
+	uint32_t	rx_ts_reg_off_seq_id;
+	/* Offset of the first PTP source ID for RX. */
+	uint32_t	rx_ts_reg_off_src_id_0;
+	/* Offset of the second PTP source ID for RX. */
+	uint32_t	rx_ts_reg_off_src_id_1;
+	/* Offset of the third PTP source ID for RX. */
+	uint32_t	rx_ts_reg_off_src_id_2;
+	/* Offset of the domain ID for RX. */
+	uint32_t	rx_ts_reg_off_domain_id;
+	/* Offset of the PTP FIFO register for RX. */
+	uint32_t	rx_ts_reg_off_fifo;
+	/* Offset of the PTP advance FIFO register for RX. */
+	uint32_t	rx_ts_reg_off_fifo_adv;
+	/* PTP timestamp granularity for RX. */
+	uint32_t	rx_ts_reg_off_granularity;
+	/*
+	 * Offset of the PTP register for the lower 32 bits of timestamp
+	 * for TX.
+	 */
+	uint32_t	tx_ts_reg_off_lower;
+	/*
+	 * Offset of the PTP register for the upper 32 bits of timestamp
+	 * for TX.
+	 */
+	uint32_t	tx_ts_reg_off_upper;
+	/* Offset of the PTP register for the sequence ID for TX. */
+	uint32_t	tx_ts_reg_off_seq_id;
+	/* Offset of the PTP FIFO register for TX. */
+	uint32_t	tx_ts_reg_off_fifo;
+	/* PTP timestamp granularity for TX. */
+	uint32_t	tx_ts_reg_off_granularity;
+	/* Offset of register to get lower 32 bits of current time. */
+	uint32_t	ts_ref_clock_reg_lower;
+	/* Offset of register to get upper 32 bits of current time. */
+	uint32_t	ts_ref_clock_reg_upper;
+	uint8_t	unused_1[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_port_mac_ptp_qcfg_output_t, *phwrm_port_mac_ptp_qcfg_output_t;
+
+/* Port Tx Statistics Format */
+/* tx_port_stats (size:3264b/408B) */
+
+typedef struct tx_port_stats {
+	/* Total Number of 64 Bytes frames transmitted */
+	uint64_t	tx_64b_frames;
+	/* Total Number of 65-127 Bytes frames transmitted */
+	uint64_t	tx_65b_127b_frames;
+	/* Total Number of 128-255 Bytes frames transmitted */
+	uint64_t	tx_128b_255b_frames;
+	/* Total Number of 256-511 Bytes frames transmitted */
+	uint64_t	tx_256b_511b_frames;
+	/* Total Number of 512-1023 Bytes frames transmitted */
+	uint64_t	tx_512b_1023b_frames;
+	/* Total Number of 1024-1518 Bytes frames transmitted */
+	uint64_t	tx_1024b_1518b_frames;
+	/*
+	 * Total Number of each good VLAN (excludes FCS errors)
+	 * frame transmitted which is 1519 to 1522 bytes in length
+	 * inclusive (excluding framing bits but including FCS bytes).
+	 */
+	uint64_t	tx_good_vlan_frames;
+	/* Total Number of 1519-2047 Bytes frames transmitted */
+	uint64_t	tx_1519b_2047b_frames;
+	/* Total Number of 2048-4095 Bytes frames transmitted */
+	uint64_t	tx_2048b_4095b_frames;
+	/* Total Number of 4096-9216 Bytes frames transmitted */
+	uint64_t	tx_4096b_9216b_frames;
+	/* Total Number of 9217-16383 Bytes frames transmitted */
+	uint64_t	tx_9217b_16383b_frames;
+	/* Total Number of good frames transmitted */
+	uint64_t	tx_good_frames;
+	/* Total Number of frames transmitted */
+	uint64_t	tx_total_frames;
+	/* Total number of unicast frames transmitted */
+	uint64_t	tx_ucast_frames;
+	/* Total number of multicast frames transmitted */
+	uint64_t	tx_mcast_frames;
+	/* Total number of broadcast frames transmitted */
+	uint64_t	tx_bcast_frames;
+	/* Total number of PAUSE control frames transmitted */
+	uint64_t	tx_pause_frames;
+	/*
+	 * Total number of PFC/per-priority PAUSE
+	 * control frames transmitted
+	 */
+	uint64_t	tx_pfc_frames;
+	/* Total number of jabber frames transmitted */
+	uint64_t	tx_jabber_frames;
+	/* Total number of frames transmitted with FCS error */
+	uint64_t	tx_fcs_err_frames;
+	/* Total number of control frames transmitted */
+	uint64_t	tx_control_frames;
+	/* Total number of over-sized frames transmitted */
+	uint64_t	tx_oversz_frames;
+	/* Total number of frames with single deferral */
+	uint64_t	tx_single_dfrl_frames;
+	/* Total number of frames with multiple deferrals */
+	uint64_t	tx_multi_dfrl_frames;
+	/* Total number of frames with single collision */
+	uint64_t	tx_single_coll_frames;
+	/* Total number of frames with multiple collisions */
+	uint64_t	tx_multi_coll_frames;
+	/* Total number of frames with late collisions */
+	uint64_t	tx_late_coll_frames;
+	/* Total number of frames with excessive collisions */
+	uint64_t	tx_excessive_coll_frames;
+	/* Total number of fragmented frames transmitted */
+	uint64_t	tx_frag_frames;
+	/* Total number of transmit errors */
+	uint64_t	tx_err;
+	/* Total number of single VLAN tagged frames transmitted */
+	uint64_t	tx_tagged_frames;
+	/* Total number of double VLAN tagged frames transmitted */
+	uint64_t	tx_dbl_tagged_frames;
+	/* Total number of runt frames transmitted */
+	uint64_t	tx_runt_frames;
+	/* Total number of TX FIFO under runs */
+	uint64_t	tx_fifo_underruns;
+	/*
+	 * Total number of PFC frames with PFC enabled bit for
+	 * Pri 0 transmitted
+	 */
+	uint64_t	tx_pfc_ena_frames_pri0;
+	/*
+	 * Total number of PFC frames with PFC enabled bit for
+	 * Pri 1 transmitted
+	 */
+	uint64_t	tx_pfc_ena_frames_pri1;
+	/*
+	 * Total number of PFC frames with PFC enabled bit for
+	 * Pri 2 transmitted
+	 */
+	uint64_t	tx_pfc_ena_frames_pri2;
+	/*
+	 * Total number of PFC frames with PFC enabled bit for
+	 * Pri 3 transmitted
+	 */
+	uint64_t	tx_pfc_ena_frames_pri3;
+	/*
+	 * Total number of PFC frames with PFC enabled bit for
+	 * Pri 4 transmitted
+	 */
+	uint64_t	tx_pfc_ena_frames_pri4;
+	/*
+	 * Total number of PFC frames with PFC enabled bit for
+	 * Pri 5 transmitted
+	 */
+	uint64_t	tx_pfc_ena_frames_pri5;
+	/*
+	 * Total number of PFC frames with PFC enabled bit for
+	 * Pri 6 transmitted
+	 */
+	uint64_t	tx_pfc_ena_frames_pri6;
+	/*
+	 * Total number of PFC frames with PFC enabled bit for
+	 * Pri 7 transmitted
+	 */
+	uint64_t	tx_pfc_ena_frames_pri7;
+	/* Total number of EEE LPI Events on TX */
+	uint64_t	tx_eee_lpi_events;
+	/* EEE LPI Duration Counter on TX */
+	uint64_t	tx_eee_lpi_duration;
+	/*
+	 * Total number of Link Level Flow Control (LLFC) messages
+	 * transmitted
+	 */
+	uint64_t	tx_llfc_logical_msgs;
+	/* Total number of HCFC messages transmitted */
+	uint64_t	tx_hcfc_msgs;
+	/* Total number of TX collisions */
+	uint64_t	tx_total_collisions;
+	/* Total number of transmitted bytes */
+	uint64_t	tx_bytes;
+	/* Total number of end-to-end HOL frames */
+	uint64_t	tx_xthol_frames;
+	/* Total Tx Drops per Port reported by STATS block */
+	uint64_t	tx_stat_discard;
+	/* Total Tx Error Drops per Port reported by STATS block */
+	uint64_t	tx_stat_error;
+} tx_port_stats_t, *ptx_port_stats_t;
+
+/* Port Rx Statistics Format */
+/* rx_port_stats (size:4224b/528B) */
+
+typedef struct rx_port_stats {
+	/* Total Number of 64 Bytes frames received */
+	uint64_t	rx_64b_frames;
+	/* Total Number of 65-127 Bytes frames received */
+	uint64_t	rx_65b_127b_frames;
+	/* Total Number of 128-255 Bytes frames received */
+	uint64_t	rx_128b_255b_frames;
+	/* Total Number of 256-511 Bytes frames received */
+	uint64_t	rx_256b_511b_frames;
+	/* Total Number of 512-1023 Bytes frames received */
+	uint64_t	rx_512b_1023b_frames;
+	/* Total Number of 1024-1518 Bytes frames received */
+	uint64_t	rx_1024b_1518b_frames;
+	/*
+	 * Total Number of each good VLAN (excludes FCS errors)
+	 * frame received which is 1519 to 1522 bytes in length
+	 * inclusive (excluding framing bits but including FCS bytes).
+	 */
+	uint64_t	rx_good_vlan_frames;
+	/* Total Number of 1519-2047 Bytes frames received */
+	uint64_t	rx_1519b_2047b_frames;
+	/* Total Number of 2048-4095 Bytes frames received */
+	uint64_t	rx_2048b_4095b_frames;
+	/* Total Number of 4096-9216 Bytes frames received */
+	uint64_t	rx_4096b_9216b_frames;
+	/* Total Number of 9217-16383 Bytes frames received */
+	uint64_t	rx_9217b_16383b_frames;
+	/* Total number of frames received */
+	uint64_t	rx_total_frames;
+	/* Total number of unicast frames received */
+	uint64_t	rx_ucast_frames;
+	/* Total number of multicast frames received */
+	uint64_t	rx_mcast_frames;
+	/* Total number of broadcast frames received */
+	uint64_t	rx_bcast_frames;
+	/* Total number of received frames with FCS error */
+	uint64_t	rx_fcs_err_frames;
+	/* Total number of control frames received */
+	uint64_t	rx_ctrl_frames;
+	/* Total number of PAUSE frames received */
+	uint64_t	rx_pause_frames;
+	/* Total number of PFC frames received */
+	uint64_t	rx_pfc_frames;
+	/*
+	 * Total number of frames received with an unsupported
+	 * opcode
+	 */
+	uint64_t	rx_unsupported_opcode_frames;
+	/*
+	 * Total number of frames received with an unsupported
+	 * DA for pause and PFC
+	 */
+	uint64_t	rx_unsupported_da_pausepfc_frames;
+	/* Total number of frames received with an unsupported SA */
+	uint64_t	rx_wrong_sa_frames;
+	/* Total number of received packets with alignment error */
+	uint64_t	rx_align_err_frames;
+	/* Total number of received frames with out-of-range length */
+	uint64_t	rx_oor_len_frames;
+	/* Total number of received frames with error termination */
+	uint64_t	rx_code_err_frames;
+	/*
+	 * Total number of received frames with a false carrier is
+	 * detected during idle, as defined by RX_ER samples active
+	 * and RXD is 0xE. The event is reported along with the
+	 * statistics generated on the next received frame. Only
+	 * one false carrier condition can be detected and logged
+	 * between frames.
+	 *
+	 * Carrier event, valid for 10M/100M speed modes only.
+	 */
+	uint64_t	rx_false_carrier_frames;
+	/* Total number of over-sized frames received */
+	uint64_t	rx_ovrsz_frames;
+	/* Total number of jabber packets received */
+	uint64_t	rx_jbr_frames;
+	/* Total number of received frames with MTU error */
+	uint64_t	rx_mtu_err_frames;
+	/* Total number of received frames with CRC match */
+	uint64_t	rx_match_crc_frames;
+	/* Total number of frames received promiscuously */
+	uint64_t	rx_promiscuous_frames;
+	/*
+	 * Total number of received frames with one or two VLAN
+	 * tags
+	 */
+	uint64_t	rx_tagged_frames;
+	/* Total number of received frames with two VLAN tags */
+	uint64_t	rx_double_tagged_frames;
+	/* Total number of truncated frames received */
+	uint64_t	rx_trunc_frames;
+	/* Total number of good frames (without errors) received */
+	uint64_t	rx_good_frames;
+	/*
+	 * Total number of received PFC frames with transition from
+	 * XON to XOFF on Pri 0
+	 */
+	uint64_t	rx_pfc_xon2xoff_frames_pri0;
+	/*
+	 * Total number of received PFC frames with transition from
+	 * XON to XOFF on Pri 1
+	 */
+	uint64_t	rx_pfc_xon2xoff_frames_pri1;
+	/*
+	 * Total number of received PFC frames with transition from
+	 * XON to XOFF on Pri 2
+	 */
+	uint64_t	rx_pfc_xon2xoff_frames_pri2;
+	/*
+	 * Total number of received PFC frames with transition from
+	 * XON to XOFF on Pri 3
+	 */
+	uint64_t	rx_pfc_xon2xoff_frames_pri3;
+	/*
+	 * Total number of received PFC frames with transition from
+	 * XON to XOFF on Pri 4
+	 */
+	uint64_t	rx_pfc_xon2xoff_frames_pri4;
+	/*
+	 * Total number of received PFC frames with transition from
+	 * XON to XOFF on Pri 5
+	 */
+	uint64_t	rx_pfc_xon2xoff_frames_pri5;
+	/*
+	 * Total number of received PFC frames with transition from
+	 * XON to XOFF on Pri 6
+	 */
+	uint64_t	rx_pfc_xon2xoff_frames_pri6;
+	/*
+	 * Total number of received PFC frames with transition from
+	 * XON to XOFF on Pri 7
+	 */
+	uint64_t	rx_pfc_xon2xoff_frames_pri7;
+	/*
+	 * Total number of received PFC frames with PFC enabled
+	 * bit for Pri 0
+	 */
+	uint64_t	rx_pfc_ena_frames_pri0;
+	/*
+	 * Total number of received PFC frames with PFC enabled
+	 * bit for Pri 1
+	 */
+	uint64_t	rx_pfc_ena_frames_pri1;
+	/*
+	 * Total number of received PFC frames with PFC enabled
+	 * bit for Pri 2
+	 */
+	uint64_t	rx_pfc_ena_frames_pri2;
+	/*
+	 * Total number of received PFC frames with PFC enabled
+	 * bit for Pri 3
+	 */
+	uint64_t	rx_pfc_ena_frames_pri3;
+	/*
+	 * Total number of received PFC frames with PFC enabled
+	 * bit for Pri 4
+	 */
+	uint64_t	rx_pfc_ena_frames_pri4;
+	/*
+	 * Total number of received PFC frames with PFC enabled
+	 * bit for Pri 5
+	 */
+	uint64_t	rx_pfc_ena_frames_pri5;
+	/*
+	 * Total number of received PFC frames with PFC enabled
+	 * bit for Pri 6
+	 */
+	uint64_t	rx_pfc_ena_frames_pri6;
+	/*
+	 * Total number of received PFC frames with PFC enabled
+	 * bit for Pri 7
+	 */
+	uint64_t	rx_pfc_ena_frames_pri7;
+	/* Total Number of frames received with SCH CRC error */
+	uint64_t	rx_sch_crc_err_frames;
+	/* Total Number of under-sized frames received */
+	uint64_t	rx_undrsz_frames;
+	/* Total Number of fragmented frames received */
+	uint64_t	rx_frag_frames;
+	/* Total number of RX EEE LPI Events */
+	uint64_t	rx_eee_lpi_events;
+	/* EEE LPI Duration Counter on RX */
+	uint64_t	rx_eee_lpi_duration;
+	/*
+	 * Total number of physical type Link Level Flow Control
+	 * (LLFC) messages received
+	 */
+	uint64_t	rx_llfc_physical_msgs;
+	/*
+	 * Total number of logical type Link Level Flow Control
+	 * (LLFC) messages received
+	 */
+	uint64_t	rx_llfc_logical_msgs;
+	/*
+	 * Total number of logical type Link Level Flow Control
+	 * (LLFC) messages received with CRC error
+	 */
+	uint64_t	rx_llfc_msgs_with_crc_err;
+	/* Total number of HCFC messages received */
+	uint64_t	rx_hcfc_msgs;
+	/* Total number of HCFC messages received with CRC error */
+	uint64_t	rx_hcfc_msgs_with_crc_err;
+	/* Total number of received bytes */
+	uint64_t	rx_bytes;
+	/* Total number of bytes received in runt frames */
+	uint64_t	rx_runt_bytes;
+	/* Total number of runt frames received */
+	uint64_t	rx_runt_frames;
+	/* Total Rx Discards per Port reported by STATS block */
+	uint64_t	rx_stat_discard;
+	uint64_t	rx_stat_err;
+} rx_port_stats_t, *prx_port_stats_t;
+
+/********************
+ * hwrm_port_qstats *
+ ********************/
+
+
+/* hwrm_port_qstats_input (size:320b/40B) */
+
+typedef struct hwrm_port_qstats_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Port ID of port that is being queried. */
+	uint16_t	port_id;
+	uint8_t	flags;
+	/*
+	 * This bit is set to 1 when request is for a counter mask,
+	 * representing the width of each of the stats counters, rather
+	 * than counters themselves.
+	 */
+	#define HWRM_PORT_QSTATS_INPUT_FLAGS_COUNTER_MASK	UINT32_C(0x1)
+	uint8_t	unused_0[5];
+	/*
+	 * This is the host address where
+	 * Tx port statistics will be stored
+	 */
+	uint64_t	tx_stat_host_addr;
+	/*
+	 * This is the host address where
+	 * Rx port statistics will be stored
+	 */
+	uint64_t	rx_stat_host_addr;
+} hwrm_port_qstats_input_t, *phwrm_port_qstats_input_t;
+
+/* hwrm_port_qstats_output (size:128b/16B) */
+
+typedef struct hwrm_port_qstats_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* The size of TX port statistics block in bytes. */
+	uint16_t	tx_stat_size;
+	/* The size of RX port statistics block in bytes. */
+	uint16_t	rx_stat_size;
+	uint8_t	unused_0[3];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_port_qstats_output_t, *phwrm_port_qstats_output_t;
+
+/* Port Tx Statistics extended Format */
+/* tx_port_stats_ext (size:2048b/256B) */
+
+typedef struct tx_port_stats_ext {
+	/* Total number of tx bytes count on cos queue 0 */
+	uint64_t	tx_bytes_cos0;
+	/* Total number of tx bytes count on cos queue 1 */
+	uint64_t	tx_bytes_cos1;
+	/* Total number of tx bytes count on cos queue 2 */
+	uint64_t	tx_bytes_cos2;
+	/* Total number of tx bytes count on cos queue 3 */
+	uint64_t	tx_bytes_cos3;
+	/* Total number of tx bytes count on cos queue 4 */
+	uint64_t	tx_bytes_cos4;
+	/* Total number of tx bytes count on cos queue 5 */
+	uint64_t	tx_bytes_cos5;
+	/* Total number of tx bytes count on cos queue 6 */
+	uint64_t	tx_bytes_cos6;
+	/* Total number of tx bytes count on cos queue 7 */
+	uint64_t	tx_bytes_cos7;
+	/* Total number of tx packets count on cos queue 0 */
+	uint64_t	tx_packets_cos0;
+	/* Total number of tx packets count on cos queue 1 */
+	uint64_t	tx_packets_cos1;
+	/* Total number of tx packets count on cos queue 2 */
+	uint64_t	tx_packets_cos2;
+	/* Total number of tx packets count on cos queue 3 */
+	uint64_t	tx_packets_cos3;
+	/* Total number of tx packets count on cos queue 4 */
+	uint64_t	tx_packets_cos4;
+	/* Total number of tx packets count on cos queue 5 */
+	uint64_t	tx_packets_cos5;
+	/* Total number of tx packets count on cos queue 6 */
+	uint64_t	tx_packets_cos6;
+	/* Total number of tx packets count on cos queue 7 */
+	uint64_t	tx_packets_cos7;
+	/* time duration between transmitting a XON -> XOFF and a subsequent XOFF -> XON for priority 0 */
+	uint64_t	pfc_pri0_tx_duration_us;
+	/* Number of times, a XON -> XOFF and XOFF -> XON transitions occur for priority 0 */
+	uint64_t	pfc_pri0_tx_transitions;
+	/* time duration between transmitting a XON -> XOFF and a subsequent XOFF -> XON for priority 1 */
+	uint64_t	pfc_pri1_tx_duration_us;
+	/* Number of times, a XON -> XOFF and XOFF -> XON transitions occur for priority 1 */
+	uint64_t	pfc_pri1_tx_transitions;
+	/* time duration between transmitting a XON -> XOFF and a subsequent XOFF -> XON for priority 2 */
+	uint64_t	pfc_pri2_tx_duration_us;
+	/* Number of times, a XON -> XOFF and XOFF -> XON transitions occur for priority 2 */
+	uint64_t	pfc_pri2_tx_transitions;
+	/* time duration between transmitting a XON -> XOFF and a subsequent XOFF -> XON for priority 3 */
+	uint64_t	pfc_pri3_tx_duration_us;
+	/* Number of times, a XON -> XOFF and XOFF -> XON transitions occur for priority 3 */
+	uint64_t	pfc_pri3_tx_transitions;
+	/* time duration between transmitting a XON -> XOFF and a subsequent XOFF -> XON for priority 4 */
+	uint64_t	pfc_pri4_tx_duration_us;
+	/* Number of times, a XON -> XOFF and XOFF -> XON transitions occur for priority 4 */
+	uint64_t	pfc_pri4_tx_transitions;
+	/* time duration between transmitting a XON -> XOFF and a subsequent XOFF -> XON for priority 5 */
+	uint64_t	pfc_pri5_tx_duration_us;
+	/* Number of times, a XON -> XOFF and XOFF -> XON transitions occur for priority 5 */
+	uint64_t	pfc_pri5_tx_transitions;
+	/* time duration between transmitting a XON -> XOFF and a subsequent XOFF -> XON for priority 6 */
+	uint64_t	pfc_pri6_tx_duration_us;
+	/* Number of times, a XON -> XOFF and XOFF -> XON transitions occur for priority 6 */
+	uint64_t	pfc_pri6_tx_transitions;
+	/* time duration between transmitting a XON -> XOFF and a subsequent XOFF -> XON for priority 7 */
+	uint64_t	pfc_pri7_tx_duration_us;
+	/* Number of times, a XON -> XOFF and XOFF -> XON transitions occur for priority 7 */
+	uint64_t	pfc_pri7_tx_transitions;
+} tx_port_stats_ext_t, *ptx_port_stats_ext_t;
+
+/* Port Rx Statistics extended Format */
+/* rx_port_stats_ext (size:3904b/488B) */
+
+typedef struct rx_port_stats_ext {
+	/* Number of times link state changed to down */
+	uint64_t	link_down_events;
+	/* Number of times the idle rings with pause bit are found */
+	uint64_t	continuous_pause_events;
+	/* Number of times the active rings pause bit resumed back */
+	uint64_t	resume_pause_events;
+	/* Number of times, the ROCE cos queue PFC is disabled to avoid pause flood/burst */
+	uint64_t	continuous_roce_pause_events;
+	/* Number of times, the ROCE cos queue PFC is enabled back */
+	uint64_t	resume_roce_pause_events;
+	/* Total number of rx bytes count on cos queue 0 */
+	uint64_t	rx_bytes_cos0;
+	/* Total number of rx bytes count on cos queue 1 */
+	uint64_t	rx_bytes_cos1;
+	/* Total number of rx bytes count on cos queue 2 */
+	uint64_t	rx_bytes_cos2;
+	/* Total number of rx bytes count on cos queue 3 */
+	uint64_t	rx_bytes_cos3;
+	/* Total number of rx bytes count on cos queue 4 */
+	uint64_t	rx_bytes_cos4;
+	/* Total number of rx bytes count on cos queue 5 */
+	uint64_t	rx_bytes_cos5;
+	/* Total number of rx bytes count on cos queue 6 */
+	uint64_t	rx_bytes_cos6;
+	/* Total number of rx bytes count on cos queue 7 */
+	uint64_t	rx_bytes_cos7;
+	/* Total number of rx packets count on cos queue 0 */
+	uint64_t	rx_packets_cos0;
+	/* Total number of rx packets count on cos queue 1 */
+	uint64_t	rx_packets_cos1;
+	/* Total number of rx packets count on cos queue 2 */
+	uint64_t	rx_packets_cos2;
+	/* Total number of rx packets count on cos queue 3 */
+	uint64_t	rx_packets_cos3;
+	/* Total number of rx packets count on cos queue 4 */
+	uint64_t	rx_packets_cos4;
+	/* Total number of rx packets count on cos queue 5 */
+	uint64_t	rx_packets_cos5;
+	/* Total number of rx packets count on cos queue 6 */
+	uint64_t	rx_packets_cos6;
+	/* Total number of rx packets count on cos queue 7 */
+	uint64_t	rx_packets_cos7;
+	/* time duration receiving a XON -> XOFF and a subsequent XOFF -> XON for priority 0 */
+	uint64_t	pfc_pri0_rx_duration_us;
+	/* Number of times, a XON -> XOFF and XOFF -> XON transitions occur for priority 0 */
+	uint64_t	pfc_pri0_rx_transitions;
+	/* time duration receiving a XON -> XOFF and a subsequent XOFF -> XON for priority 1 */
+	uint64_t	pfc_pri1_rx_duration_us;
+	/* Number of times, a XON -> XOFF and XOFF -> XON transitions occur for priority 1 */
+	uint64_t	pfc_pri1_rx_transitions;
+	/* time duration receiving a XON -> XOFF and a subsequent XOFF -> XON for priority 2 */
+	uint64_t	pfc_pri2_rx_duration_us;
+	/* Number of times, a XON -> XOFF and XOFF -> XON transitions occur for priority 2 */
+	uint64_t	pfc_pri2_rx_transitions;
+	/* time duration receiving a XON -> XOFF and a subsequent XOFF -> XON for priority 3 */
+	uint64_t	pfc_pri3_rx_duration_us;
+	/* Number of times, a XON -> XOFF and XOFF -> XON transitions occur for priority 3 */
+	uint64_t	pfc_pri3_rx_transitions;
+	/* time duration receiving a XON -> XOFF and a subsequent XOFF -> XON for priority 4 */
+	uint64_t	pfc_pri4_rx_duration_us;
+	/* Number of times, a XON -> XOFF and XOFF -> XON transitions occur for priority 4 */
+	uint64_t	pfc_pri4_rx_transitions;
+	/* time duration receiving a XON -> XOFF and a subsequent XOFF -> XON for priority 5 */
+	uint64_t	pfc_pri5_rx_duration_us;
+	/* Number of times, a XON -> XOFF and XOFF -> XON transitions occur for priority 5 */
+	uint64_t	pfc_pri5_rx_transitions;
+	/* time duration receiving a XON -> XOFF and a subsequent XOFF -> XON for priority 6 */
+	uint64_t	pfc_pri6_rx_duration_us;
+	/* Number of times, a XON -> XOFF and XOFF -> XON transitions occur for priority 6 */
+	uint64_t	pfc_pri6_rx_transitions;
+	/* time duration receiving a XON -> XOFF and a subsequent XOFF -> XON for priority 7 */
+	uint64_t	pfc_pri7_rx_duration_us;
+	/* Number of times, a XON -> XOFF and XOFF -> XON transitions occur for priority 7 */
+	uint64_t	pfc_pri7_rx_transitions;
+	/* Total number of received bits */
+	uint64_t	rx_bits;
+	/* The number of events where the port receive buffer was over 85% full */
+	uint64_t	rx_buffer_passed_threshold;
+	/*
+	 * The number of symbol errors that wasn't corrected by FEC correction
+	 * algorithm
+	 */
+	uint64_t	rx_pcs_symbol_err;
+	/* The number of corrected bits on the port according to active FEC */
+	uint64_t	rx_corrected_bits;
+	/* Total number of rx discard bytes count on cos queue 0 */
+	uint64_t	rx_discard_bytes_cos0;
+	/* Total number of rx discard bytes count on cos queue 1 */
+	uint64_t	rx_discard_bytes_cos1;
+	/* Total number of rx discard bytes count on cos queue 2 */
+	uint64_t	rx_discard_bytes_cos2;
+	/* Total number of rx discard bytes count on cos queue 3 */
+	uint64_t	rx_discard_bytes_cos3;
+	/* Total number of rx discard bytes count on cos queue 4 */
+	uint64_t	rx_discard_bytes_cos4;
+	/* Total number of rx discard bytes count on cos queue 5 */
+	uint64_t	rx_discard_bytes_cos5;
+	/* Total number of rx discard bytes count on cos queue 6 */
+	uint64_t	rx_discard_bytes_cos6;
+	/* Total number of rx discard bytes count on cos queue 7 */
+	uint64_t	rx_discard_bytes_cos7;
+	/* Total number of rx discard packets count on cos queue 0 */
+	uint64_t	rx_discard_packets_cos0;
+	/* Total number of rx discard packets count on cos queue 1 */
+	uint64_t	rx_discard_packets_cos1;
+	/* Total number of rx discard packets count on cos queue 2 */
+	uint64_t	rx_discard_packets_cos2;
+	/* Total number of rx discard packets count on cos queue 3 */
+	uint64_t	rx_discard_packets_cos3;
+	/* Total number of rx discard packets count on cos queue 4 */
+	uint64_t	rx_discard_packets_cos4;
+	/* Total number of rx discard packets count on cos queue 5 */
+	uint64_t	rx_discard_packets_cos5;
+	/* Total number of rx discard packets count on cos queue 6 */
+	uint64_t	rx_discard_packets_cos6;
+	/* Total number of rx discard packets count on cos queue 7 */
+	uint64_t	rx_discard_packets_cos7;
+	/* Total number of FEC blocks corrected by the FEC function in the PHY */
+	uint64_t	rx_fec_corrected_blocks;
+	/*
+	 * Total number of FEC blocks determined to be uncorrectable by the
+	 * FEC function in the PHY
+	 */
+	uint64_t	rx_fec_uncorrectable_blocks;
+	/*
+	 * Total number of packets that are dropped due to not matching
+	 * any RX filter rules. This value is zero on the non supported
+	 * controllers. This counter is per controller, Firmware reports the
+	 * same value on active ports. This counter does not include the
+	 * packet discards because of no available buffers.
+	 */
+	uint64_t	rx_filter_miss;
+	/*
+	 * This field represents the number of FEC symbol errors by counting
+	 * once for each 10-bit symbol corrected by FEC block.
+	 * rx_fec_corrected_blocks will be incremented if all symbol errors in a
+	 * codeword gets corrected.
+	 */
+	uint64_t	rx_fec_symbol_err;
+} rx_port_stats_ext_t, *prx_port_stats_ext_t;
+
+/*
+ * Port Rx Statistics extended PFC WatchDog Format.
+ * StormDetect and StormRevert event determination is based
+ * on an integration period and a percentage threshold.
+ * StormDetect event - when percentage of XOFF frames received
+ * within an integration period exceeds the configured threshold.
+ * StormRevert event - when percentage of XON frames received
+ * within an integration period exceeds the configured threshold.
+ * Actual number of XOFF/XON frames for the events to be triggered
+ * depends on both configured integration period and sampling rate.
+ * The statistics in this structure represent counts of specified
+ * events from the moment the feature (PFC WatchDog) is enabled via
+ * hwrm_queue_pfc_enable_cfg call.
+ */
+/* rx_port_stats_ext_pfc_wd (size:5120b/640B) */
+
+typedef struct rx_port_stats_ext_pfc_wd {
+	/*
+	 * Total number of PFC WatchDog StormDetect events detected
+	 * for Pri 0
+	 */
+	uint64_t	rx_pfc_watchdog_storms_detected_pri0;
+	/*
+	 * Total number of PFC WatchDog StormDetect events detected
+	 * for Pri 1
+	 */
+	uint64_t	rx_pfc_watchdog_storms_detected_pri1;
+	/*
+	 * Total number of PFC WatchDog StormDetect events detected
+	 * for Pri 2
+	 */
+	uint64_t	rx_pfc_watchdog_storms_detected_pri2;
+	/*
+	 * Total number of PFC WatchDog StormDetect events detected
+	 * for Pri 3
+	 */
+	uint64_t	rx_pfc_watchdog_storms_detected_pri3;
+	/*
+	 * Total number of PFC WatchDog StormDetect events detected
+	 * for Pri 4
+	 */
+	uint64_t	rx_pfc_watchdog_storms_detected_pri4;
+	/*
+	 * Total number of PFC WatchDog StormDetect events detected
+	 * for Pri 5
+	 */
+	uint64_t	rx_pfc_watchdog_storms_detected_pri5;
+	/*
+	 * Total number of PFC WatchDog StormDetect events detected
+	 * for Pri 6
+	 */
+	uint64_t	rx_pfc_watchdog_storms_detected_pri6;
+	/*
+	 * Total number of PFC WatchDog StormDetect events detected
+	 * for Pri 7
+	 */
+	uint64_t	rx_pfc_watchdog_storms_detected_pri7;
+	/*
+	 * Total number of PFC WatchDog StormRevert events detected
+	 * for Pri 0
+	 */
+	uint64_t	rx_pfc_watchdog_storms_reverted_pri0;
+	/*
+	 * Total number of PFC WatchDog StormRevert events detected
+	 * for Pri 1
+	 */
+	uint64_t	rx_pfc_watchdog_storms_reverted_pri1;
+	/*
+	 * Total number of PFC WatchDog StormRevert events detected
+	 * for Pri 2
+	 */
+	uint64_t	rx_pfc_watchdog_storms_reverted_pri2;
+	/*
+	 * Total number of PFC WatchDog StormRevert events detected
+	 * for Pri 3
+	 */
+	uint64_t	rx_pfc_watchdog_storms_reverted_pri3;
+	/*
+	 * Total number of PFC WatchDog StormRevert events detected
+	 * for Pri 4
+	 */
+	uint64_t	rx_pfc_watchdog_storms_reverted_pri4;
+	/*
+	 * Total number of PFC WatchDog StormRevert events detected
+	 * for Pri 5
+	 */
+	uint64_t	rx_pfc_watchdog_storms_reverted_pri5;
+	/*
+	 * Total number of PFC WatchDog StormRevert events detected
+	 * for Pri 6
+	 */
+	uint64_t	rx_pfc_watchdog_storms_reverted_pri6;
+	/*
+	 * Total number of PFC WatchDog StormRevert events detected
+	 * for Pri 7
+	 */
+	uint64_t	rx_pfc_watchdog_storms_reverted_pri7;
+	/*
+	 * Total number of packets received during PFC watchdog storm
+	 * for pri 0
+	 */
+	uint64_t	rx_pfc_watchdog_storms_rx_packets_pri0;
+	/*
+	 * Total number of packets received during PFC watchdog storm
+	 * for pri 1
+	 */
+	uint64_t	rx_pfc_watchdog_storms_rx_packets_pri1;
+	/*
+	 * Total number of packets received during PFC watchdog storm
+	 *  for pri 2
+	 */
+	uint64_t	rx_pfc_watchdog_storms_rx_packets_pri2;
+	/*
+	 * Total number of packets received during PFC watchdog storm
+	 *  for pri 3
+	 */
+	uint64_t	rx_pfc_watchdog_storms_rx_packets_pri3;
+	/*
+	 * Total number of packets received during PFC watchdog storm
+	 *  for pri 4
+	 */
+	uint64_t	rx_pfc_watchdog_storms_rx_packets_pri4;
+	/*
+	 * Total number of packets received during PFC watchdog storm
+	 *  for pri 5
+	 */
+	uint64_t	rx_pfc_watchdog_storms_rx_packets_pri5;
+	/*
+	 * Total number of packets received during PFC watchdog storm
+	 *  for pri 6
+	 */
+	uint64_t	rx_pfc_watchdog_storms_rx_packets_pri6;
+	/*
+	 * Total number of packets received during PFC watchdog storm
+	 *  for pri 7
+	 */
+	uint64_t	rx_pfc_watchdog_storms_rx_packets_pri7;
+	/*
+	 * Total number of bytes received during PFC watchdog storm
+	 * for pri 0
+	 */
+	uint64_t	rx_pfc_watchdog_storms_rx_bytes_pri0;
+	/*
+	 * Total number of bytes received during PFC watchdog storm
+	 * for pri 1
+	 */
+	uint64_t	rx_pfc_watchdog_storms_rx_bytes_pri1;
+	/*
+	 * Total number of bytes received during PFC watchdog storm
+	 *  for pri 2
+	 */
+	uint64_t	rx_pfc_watchdog_storms_rx_bytes_pri2;
+	/*
+	 * Total number of bytes received during PFC watchdog storm
+	 *  for pri 3
+	 */
+	uint64_t	rx_pfc_watchdog_storms_rx_bytes_pri3;
+	/*
+	 * Total number of bytes received during PFC watchdog storm
+	 *  for pri 4
+	 */
+	uint64_t	rx_pfc_watchdog_storms_rx_bytes_pri4;
+	/*
+	 * Total number of bytes received during PFC watchdog storm
+	 *  for pri 5
+	 */
+	uint64_t	rx_pfc_watchdog_storms_rx_bytes_pri5;
+	/*
+	 * Total number of bytes received during PFC watchdog storm
+	 *  for pri 6
+	 */
+	uint64_t	rx_pfc_watchdog_storms_rx_bytes_pri6;
+	/*
+	 * Total number of bytes received during PFC watchdog storm
+	 *  for pri 7
+	 */
+	uint64_t	rx_pfc_watchdog_storms_rx_bytes_pri7;
+	/*
+	 * Total number of packets dropped on rx during PFC watchdog storm
+	 * for pri 0
+	 */
+	uint64_t	rx_pfc_watchdog_storms_rx_packets_dropped_pri0;
+	/*
+	 * Total number of packets dropped on rx during PFC watchdog storm
+	 * for pri 1
+	 */
+	uint64_t	rx_pfc_watchdog_storms_rx_packets_dropped_pri1;
+	/*
+	 * Total number of packets dropped on rx during PFC watchdog storm
+	 *  for pri 2
+	 */
+	uint64_t	rx_pfc_watchdog_storms_rx_packets_dropped_pri2;
+	/*
+	 * Total number of packets dropped on rx during PFC watchdog storm
+	 *  for pri 3
+	 */
+	uint64_t	rx_pfc_watchdog_storms_rx_packets_dropped_pri3;
+	/*
+	 * Total number of packets dropped on rx during PFC watchdog storm
+	 *  for pri 4
+	 */
+	uint64_t	rx_pfc_watchdog_storms_rx_packets_dropped_pri4;
+	/*
+	 * Total number of packets dropped on rx during PFC watchdog storm
+	 *  for pri 5
+	 */
+	uint64_t	rx_pfc_watchdog_storms_rx_packets_dropped_pri5;
+	/*
+	 * Total number of packets dropped on rx during PFC watchdog storm
+	 *  for pri 6
+	 */
+	uint64_t	rx_pfc_watchdog_storms_rx_packets_dropped_pri6;
+	/*
+	 * Total number of packets dropped on rx during PFC watchdog storm
+	 *  for pri 7
+	 */
+	uint64_t	rx_pfc_watchdog_storms_rx_packets_dropped_pri7;
+	/*
+	 * Total number of bytes dropped on rx during PFC watchdog storm
+	 * for pri 0
+	 */
+	uint64_t	rx_pfc_watchdog_storms_rx_bytes_dropped_pri0;
+	/*
+	 * Total number of bytes dropped on rx during PFC watchdog storm
+	 * for pri 1
+	 */
+	uint64_t	rx_pfc_watchdog_storms_rx_bytes_dropped_pri1;
+	/*
+	 * Total number of bytes dropped on rx during PFC watchdog storm
+	 *  for pri 2
+	 */
+	uint64_t	rx_pfc_watchdog_storms_rx_bytes_dropped_pri2;
+	/*
+	 * Total number of bytes dropped on rx during PFC watchdog storm
+	 *  for pri 3
+	 */
+	uint64_t	rx_pfc_watchdog_storms_rx_bytes_dropped_pri3;
+	/*
+	 * Total number of bytes dropped on rx during PFC watchdog storm
+	 *  for pri 4
+	 */
+	uint64_t	rx_pfc_watchdog_storms_rx_bytes_dropped_pri4;
+	/*
+	 * Total number of bytes dropped on rx during PFC watchdog storm
+	 *  for pri 5
+	 */
+	uint64_t	rx_pfc_watchdog_storms_rx_bytes_dropped_pri5;
+	/*
+	 * Total number of bytes dropped on rx during PFC watchdog storm
+	 *  for pri 6
+	 */
+	uint64_t	rx_pfc_watchdog_storms_rx_bytes_dropped_pri6;
+	/*
+	 * Total number of bytes dropped on rx during PFC watchdog storm
+	 *  for pri 7
+	 */
+	uint64_t	rx_pfc_watchdog_storms_rx_bytes_dropped_pri7;
+	/*
+	 * Number of packets received during last PFC watchdog storm
+	 * for pri 0
+	 */
+	uint64_t	rx_pfc_watchdog_last_storm_rx_packets_pri0;
+	/*
+	 * Number of packets received during last PFC watchdog storm
+	 * for pri 1
+	 */
+	uint64_t	rx_pfc_watchdog_last_storm_rx_packets_pri1;
+	/*
+	 * Number of packets received during last PFC watchdog storm
+	 *  for pri 2
+	 */
+	uint64_t	rx_pfc_watchdog_last_storm_rx_packets_pri2;
+	/*
+	 * Number of packets received during last PFC watchdog storm
+	 *  for pri 3
+	 */
+	uint64_t	rx_pfc_watchdog_last_storm_rx_packets_pri3;
+	/*
+	 * Number of packets received during last PFC watchdog storm
+	 *  for pri 4
+	 */
+	uint64_t	rx_pfc_watchdog_last_storm_rx_packets_pri4;
+	/*
+	 * Number of packets received during last PFC watchdog storm
+	 *  for pri 5
+	 */
+	uint64_t	rx_pfc_watchdog_last_storm_rx_packets_pri5;
+	/*
+	 * Number of packets received during last PFC watchdog storm
+	 *  for pri 6
+	 */
+	uint64_t	rx_pfc_watchdog_last_storm_rx_packets_pri6;
+	/*
+	 * Number of packets received during last PFC watchdog storm
+	 *  for pri 7
+	 */
+	uint64_t	rx_pfc_watchdog_last_storm_rx_packets_pri7;
+	/*
+	 * Number of bytes received during last PFC watchdog storm
+	 * for pri 0
+	 */
+	uint64_t	rx_pfc_watchdog_last_storm_rx_bytes_pri0;
+	/*
+	 * Number of bytes received during last PFC watchdog storm
+	 * for pri 1
+	 */
+	uint64_t	rx_pfc_watchdog_last_storm_rx_bytes_pri1;
+	/*
+	 * Number of bytes received during last PFC watchdog storm
+	 *  for pri 2
+	 */
+	uint64_t	rx_pfc_watchdog_last_storm_rx_bytes_pri2;
+	/*
+	 * Number of bytes received during last PFC watchdog storm
+	 *  for pri 3
+	 */
+	uint64_t	rx_pfc_watchdog_last_storm_rx_bytes_pri3;
+	/*
+	 * Number of bytes received during last PFC watchdog storm
+	 *  for pri 4
+	 */
+	uint64_t	rx_pfc_watchdog_last_storm_rx_bytes_pri4;
+	/*
+	 * Number of bytes received during last PFC watchdog storm
+	 *  for pri 5
+	 */
+	uint64_t	rx_pfc_watchdog_last_storm_rx_bytes_pri5;
+	/*
+	 * Number of bytes received during last PFC watchdog storm
+	 *  for pri 6
+	 */
+	uint64_t	rx_pfc_watchdog_last_storm_rx_bytes_pri6;
+	/*
+	 * Number of bytes received during last PFC watchdog storm
+	 *  for pri 7
+	 */
+	uint64_t	rx_pfc_watchdog_last_storm_rx_bytes_pri7;
+	/*
+	 * Number of packets dropped on rx during last PFC watchdog storm
+	 * for pri 0
+	 */
+	uint64_t	rx_pfc_watchdog_last_storm_rx_packets_dropped_pri0;
+	/*
+	 * Number of packets dropped on rx during last PFC watchdog storm
+	 * for pri 1
+	 */
+	uint64_t	rx_pfc_watchdog_last_storm_rx_packets_dropped_pri1;
+	/*
+	 * Number of packets dropped on rx during last PFC watchdog storm
+	 *  for pri 2
+	 */
+	uint64_t	rx_pfc_watchdog_last_storm_rx_packets_dropped_pri2;
+	/*
+	 * Number of packets dropped on rx during last PFC watchdog storm
+	 *  for pri 3
+	 */
+	uint64_t	rx_pfc_watchdog_last_storm_rx_packets_dropped_pri3;
+	/*
+	 * Number of packets dropped on rx during last PFC watchdog storm
+	 *  for pri 4
+	 */
+	uint64_t	rx_pfc_watchdog_last_storm_rx_packets_dropped_pri4;
+	/*
+	 * Number of packets dropped on rx during last PFC watchdog storm
+	 *  for pri 5
+	 */
+	uint64_t	rx_pfc_watchdog_last_storm_rx_packets_dropped_pri5;
+	/*
+	 * Number of packets dropped on rx during last PFC watchdog storm
+	 *  for pri 6
+	 */
+	uint64_t	rx_pfc_watchdog_last_storm_rx_packets_dropped_pri6;
+	/*
+	 * Number of packets dropped on rx during last PFC watchdog storm
+	 *  for pri 7
+	 */
+	uint64_t	rx_pfc_watchdog_last_storm_rx_packets_dropped_pri7;
+	/*
+	 * Total number of bytes dropped on rx during PFC watchdog storm
+	 * for pri 0
+	 */
+	uint64_t	rx_pfc_watchdog_last_storm_rx_bytes_dropped_pri0;
+	/*
+	 * Number of bytes dropped on rx during last PFC watchdog storm
+	 * for pri 1
+	 */
+	uint64_t	rx_pfc_watchdog_last_storm_rx_bytes_dropped_pri1;
+	/*
+	 * Number of bytes dropped on rx during last PFC watchdog storm
+	 *  for pri 2
+	 */
+	uint64_t	rx_pfc_watchdog_last_storm_rx_bytes_dropped_pri2;
+	/*
+	 * Number of bytes dropped on rx during last PFC watchdog storm
+	 *  for pri 3
+	 */
+	uint64_t	rx_pfc_watchdog_last_storm_rx_bytes_dropped_pri3;
+	/*
+	 * Number of bytes dropped on rx during last PFC watchdog storm
+	 *  for pri 4
+	 */
+	uint64_t	rx_pfc_watchdog_last_storm_rx_bytes_dropped_pri4;
+	/*
+	 * Number of bytes dropped on rx during last PFC watchdog storm
+	 *  for pri 5
+	 */
+	uint64_t	rx_pfc_watchdog_last_storm_rx_bytes_dropped_pri5;
+	/*
+	 * Number of bytes dropped on rx during last PFC watchdog storm
+	 *  for pri 6
+	 */
+	uint64_t	rx_pfc_watchdog_last_storm_rx_bytes_dropped_pri6;
+	/*
+	 * Number of bytes dropped on rx during last PFC watchdog storm
+	 *  for pri 7
+	 */
+	uint64_t	rx_pfc_watchdog_last_storm_rx_bytes_dropped_pri7;
+} rx_port_stats_ext_pfc_wd_t, *prx_port_stats_ext_pfc_wd_t;
+
+/************************
+ * hwrm_port_qstats_ext *
+ ************************/
+
+
+/* hwrm_port_qstats_ext_input (size:320b/40B) */
+
+typedef struct hwrm_port_qstats_ext_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Port ID of port that is being queried. */
+	uint16_t	port_id;
+	/*
+	 * The size of TX port extended
+	 * statistics block in bytes.
+	 */
+	uint16_t	tx_stat_size;
+	/*
+	 * The size of RX port extended
+	 * statistics block in bytes
+	 */
+	uint16_t	rx_stat_size;
+	uint8_t	flags;
+	/*
+	 * This bit is set to 1 when request is for the counter mask,
+	 * representing width of each of the stats counters, rather than
+	 * counters themselves.
+	 */
+	#define HWRM_PORT_QSTATS_EXT_INPUT_FLAGS_COUNTER_MASK	UINT32_C(0x1)
+	uint8_t	unused_0;
+	/*
+	 * This is the host address where
+	 * Tx port statistics will be stored
+	 */
+	uint64_t	tx_stat_host_addr;
+	/*
+	 * This is the host address where
+	 * Rx port statistics will be stored
+	 */
+	uint64_t	rx_stat_host_addr;
+} hwrm_port_qstats_ext_input_t, *phwrm_port_qstats_ext_input_t;
+
+/* hwrm_port_qstats_ext_output (size:128b/16B) */
+
+typedef struct hwrm_port_qstats_ext_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* The size of TX port statistics block in bytes. */
+	uint16_t	tx_stat_size;
+	/* The size of RX port statistics block in bytes. */
+	uint16_t	rx_stat_size;
+	/* Total number of active cos queues available. */
+	uint16_t	total_active_cos_queues;
+	uint8_t	flags;
+	/*
+	 * If set to 1, then this field indicates that clear
+	 * roce specific counters is supported.
+	 */
+	#define HWRM_PORT_QSTATS_EXT_OUTPUT_FLAGS_CLEAR_ROCE_COUNTERS_SUPPORTED	UINT32_C(0x1)
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_port_qstats_ext_output_t, *phwrm_port_qstats_ext_output_t;
+
+/*******************************
+ * hwrm_port_qstats_ext_pfc_wd *
+ *******************************/
+
+
+/* hwrm_port_qstats_ext_pfc_wd_input (size:256b/32B) */
+
+typedef struct hwrm_port_qstats_ext_pfc_wd_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Port ID of port that is being queried. */
+	uint16_t	port_id;
+	/*
+	 * The size of rx_port_stats_ext_pfc_wd
+	 * block in bytes
+	 */
+	uint16_t	pfc_wd_stat_size;
+	uint8_t	unused_0[4];
+	/*
+	 * This is the host address where
+	 * rx_port_stats_ext_pfc_wd will be stored
+	 */
+	uint64_t	pfc_wd_stat_host_addr;
+} hwrm_port_qstats_ext_pfc_wd_input_t, *phwrm_port_qstats_ext_pfc_wd_input_t;
+
+/* hwrm_port_qstats_ext_pfc_wd_output (size:128b/16B) */
+
+typedef struct hwrm_port_qstats_ext_pfc_wd_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/*
+	 * The size of rx_port_stats_ext_pfc_wd
+	 * statistics block in bytes.
+	 */
+	uint16_t	pfc_wd_stat_size;
+	uint8_t	unused_0[5];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_port_qstats_ext_pfc_wd_output_t, *phwrm_port_qstats_ext_pfc_wd_output_t;
+
+/*************************
+ * hwrm_port_lpbk_qstats *
+ *************************/
+
+
+/* hwrm_port_lpbk_qstats_input (size:256b/32B) */
+
+typedef struct hwrm_port_lpbk_qstats_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/*
+	 * The size of the loopback statistics buffer passed in the
+	 * loopback_stat_host_addr in bytes.
+	 * Firmware will not exceed this size when it DMAs the
+	 * statistics structure to the host. The actual DMA size
+	 * will be returned in the response.
+	 */
+	uint16_t	lpbk_stat_size;
+	uint8_t	flags;
+	/*
+	 * This bit is set to 1 when request is for a counter mask,
+	 * representing the width of each of the stats counters, rather
+	 * than counters themselves.
+	 */
+	#define HWRM_PORT_LPBK_QSTATS_INPUT_FLAGS_COUNTER_MASK	UINT32_C(0x1)
+	uint8_t	unused_0[5];
+	/*
+	 * This is the host address where
+	 * loopback statistics will be stored
+	 */
+	uint64_t	lpbk_stat_host_addr;
+} hwrm_port_lpbk_qstats_input_t, *phwrm_port_lpbk_qstats_input_t;
+
+/* hwrm_port_lpbk_qstats_output (size:128b/16B) */
+
+typedef struct hwrm_port_lpbk_qstats_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/*
+	 * The size of the loopback statistics block in bytes DMA'ed by the
+	 * firmware. Note that this size will never exceed the lpbk_stat_size
+	 * field passed in by the driver in the hwrm_port_lpbk_qstats_input
+	 * structure.
+	 */
+	uint16_t	lpbk_stat_size;
+	uint8_t	unused_0[5];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
+	 */
+	uint8_t	valid;
+} hwrm_port_lpbk_qstats_output_t, *phwrm_port_lpbk_qstats_output_t;
+
+/* Loopback Port Statistic Format */
+/* port_lpbk_stats (size:640b/80B) */
+
+typedef struct port_lpbk_stats {
+	/* Number of transmitted unicast frames */
+	uint64_t	lpbk_ucast_frames;
+	/* Number of transmitted multicast frames */
+	uint64_t	lpbk_mcast_frames;
+	/* Number of transmitted broadcast frames */
+	uint64_t	lpbk_bcast_frames;
+	/* Number of transmitted bytes for unicast traffic */
+	uint64_t	lpbk_ucast_bytes;
+	/* Number of transmitted bytes for multicast traffic */
+	uint64_t	lpbk_mcast_bytes;
+	/* Number of transmitted bytes for broadcast traffic */
+	uint64_t	lpbk_bcast_bytes;
+	/* Number of dropped tx packets */
+	uint64_t	lpbk_tx_discards;
+	/* Number of error dropped tx packets */
+	uint64_t	lpbk_tx_errors;
+	/* Number of dropped rx packets */
+	uint64_t	lpbk_rx_discards;
+	/* Number of error dropped rx packets */
+	uint64_t	lpbk_rx_errors;
+} port_lpbk_stats_t, *pport_lpbk_stats_t;
+
+/************************
+ * hwrm_port_ecn_qstats *
+ ************************/
+
+
+/* hwrm_port_ecn_qstats_input (size:256b/32B) */
+
+typedef struct hwrm_port_ecn_qstats_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/*
+	 * Port ID of port that is being queried. Unused if NIC is in
+	 * multi-host mode.
+	 */
+	uint16_t	port_id;
+	/*
+	 * Size of the DMA buffer the caller has allocated for the firmware to
+	 * write into.
+	 */
+	uint16_t	ecn_stat_buf_size;
+	uint8_t	flags;
+	/*
+	 * This bit is set to 1 when request is for a counter mask,
+	 * representing the width of each of the stats counters, rather
+	 * than counters themselves.
+	 */
+	#define HWRM_PORT_ECN_QSTATS_INPUT_FLAGS_COUNTER_MASK	UINT32_C(0x1)
+	uint8_t	unused_0[3];
+	/*
+	 * This is the host address where
+	 * ECN port statistics will be stored
+	 */
+	uint64_t	ecn_stat_host_addr;
+} hwrm_port_ecn_qstats_input_t, *phwrm_port_ecn_qstats_input_t;
+
+/* hwrm_port_ecn_qstats_output (size:128b/16B) */
+
+typedef struct hwrm_port_ecn_qstats_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Number of bytes of stats the firmware wrote to the DMA buffer. */
+	uint16_t	ecn_stat_buf_size;
+	/*
+	 * Bitmask that indicates which CoS queues have ECN marking enabled.
+	 * Bit i corresponds to CoS queue i.
+	 */
+	uint8_t	mark_en;
+	uint8_t	unused_0[4];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_port_ecn_qstats_output_t, *phwrm_port_ecn_qstats_output_t;
+
+/* ECN mark statistics format */
+/* port_stats_ecn (size:512b/64B) */
+
+typedef struct port_stats_ecn {
+	/*
+	 * Number of packets marked in CoS queue 0.
+	 * Or, if the driver requested counter masks, a mask to indicate the size
+	 * of the counter.
+	 */
+	uint64_t	mark_cnt_cos0;
+	/*
+	 * Number of packets marked in CoS queue 1.
+	 * Or, if the driver requested counter masks, a mask to indicate the size
+	 * of the counter.
+	 */
+	uint64_t	mark_cnt_cos1;
+	/*
+	 * Number of packets marked in CoS queue 2.
+	 * Or, if the driver requested counter masks, a mask to indicate the size
+	 * of the counter.
+	 */
+	uint64_t	mark_cnt_cos2;
+	/*
+	 * Number of packets marked in CoS queue 3.
+	 * Or, if the driver requested counter masks, a mask to indicate the size
+	 * of the counter.
+	 */
+	uint64_t	mark_cnt_cos3;
+	/*
+	 * Number of packets marked in CoS queue 4.
+	 * Or, if the driver requested counter masks, a mask to indicate the size
+	 * of the counter.
+	 */
+	uint64_t	mark_cnt_cos4;
+	/*
+	 * Number of packets marked in CoS queue 5.
+	 * Or, if the driver requested counter masks, a mask to indicate the size
+	 * of the counter.
+	 */
+	uint64_t	mark_cnt_cos5;
+	/*
+	 * Number of packets marked in CoS queue 6.
+	 * Or, if the driver requested counter masks, a mask to indicate the size
+	 * of the counter.
+	 */
+	uint64_t	mark_cnt_cos6;
+	/*
+	 * Number of packets marked in CoS queue 7.
+	 * Or, if the driver requested counter masks, a mask to indicate the size
+	 * of the counter.
+	 */
+	uint64_t	mark_cnt_cos7;
+} port_stats_ecn_t, *pport_stats_ecn_t;
+
+/***********************
+ * hwrm_port_clr_stats *
+ ***********************/
+
+
+/* hwrm_port_clr_stats_input (size:192b/24B) */
+
+typedef struct hwrm_port_clr_stats_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Port ID of port that is being queried. */
+	uint16_t	port_id;
+	uint8_t	flags;
+	/*
+	 * If set to 1, then this field indicates clear the following RoCE
+	 * specific counters.
+	 * RoCE associated TX/RX cos counters
+	 * CNP associated TX/RX cos counters
+	 * RoCE/CNP specific TX/RX flow counters
+	 * Firmware will determine the RoCE/CNP cos queue based on qos
+	 * profile.
+	 * This flag is honored only when RoCE is enabled on that port.
+	 */
+	#define HWRM_PORT_CLR_STATS_INPUT_FLAGS_ROCE_COUNTERS	UINT32_C(0x1)
+	uint8_t	unused_0[5];
+} hwrm_port_clr_stats_input_t, *phwrm_port_clr_stats_input_t;
+
+/* hwrm_port_clr_stats_output (size:128b/16B) */
+
+typedef struct hwrm_port_clr_stats_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_port_clr_stats_output_t, *phwrm_port_clr_stats_output_t;
+
+/****************************
+ * hwrm_port_lpbk_clr_stats *
+ ****************************/
+
+
+/* hwrm_port_lpbk_clr_stats_input (size:192b/24B) */
+
+typedef struct hwrm_port_lpbk_clr_stats_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Port ID of port that is to be queried. */
+	uint16_t	port_id;
+	uint8_t	unused_0[6];
+} hwrm_port_lpbk_clr_stats_input_t, *phwrm_port_lpbk_clr_stats_input_t;
+
+/* hwrm_port_lpbk_clr_stats_output (size:128b/16B) */
+
+typedef struct hwrm_port_lpbk_clr_stats_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_port_lpbk_clr_stats_output_t, *phwrm_port_lpbk_clr_stats_output_t;
+
+/**********************
+ * hwrm_port_ts_query *
+ **********************/
+
+
+/* hwrm_port_ts_query_input (size:320b/40B) */
+
+typedef struct hwrm_port_ts_query_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	flags;
+	/*
+	 * Enumeration denoting the RX, TX type of the resource.
+	 * This enumeration is used for resources that are similar for both
+	 * TX and RX paths of the chip.
+	 */
+	#define HWRM_PORT_TS_QUERY_INPUT_FLAGS_PATH		UINT32_C(0x1)
+	/* tx path */
+		#define HWRM_PORT_TS_QUERY_INPUT_FLAGS_PATH_TX		UINT32_C(0x0)
+	/* rx path */
+		#define HWRM_PORT_TS_QUERY_INPUT_FLAGS_PATH_RX		UINT32_C(0x1)
+		#define HWRM_PORT_TS_QUERY_INPUT_FLAGS_PATH_LAST	HWRM_PORT_TS_QUERY_INPUT_FLAGS_PATH_RX
+	/*
+	 * If set, the response includes the current value of the free
+	 * running timer.
+	 */
+	#define HWRM_PORT_TS_QUERY_INPUT_FLAGS_CURRENT_TIME	UINT32_C(0x2)
+	/* Port ID of port that is being queried. */
+	uint16_t	port_id;
+	uint8_t	unused_0[2];
+	uint16_t	enables;
+	/*
+	 * This bit must be '1' for the ts_req_timeout field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_TS_QUERY_INPUT_ENABLES_TS_REQ_TIMEOUT	UINT32_C(0x1)
+	/*
+	 * This bit must be '1' for the ptp_seq_id field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_TS_QUERY_INPUT_ENABLES_PTP_SEQ_ID	UINT32_C(0x2)
+	/*
+	 * This bit must be '1' for the ptp_hdr_offset field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_TS_QUERY_INPUT_ENABLES_PTP_HDR_OFFSET	UINT32_C(0x4)
+	/*
+	 * Specifies the timeout in microseconds. If this is specified,
+	 * firmware will keep checking for a matching timestamp packet
+	 * till the timeout is exhausted. User can specify a max timeout
+	 * of 65535 microseconds. Firmware will return HWRM_ERR_CODE_BUSY
+	 * if a matching timestamp is not found. Firmware will return
+	 * HWRM_ERROR_CODE_FAIL if we are unable to read timestamps
+	 * from FIFO.
+	 */
+	uint16_t	ts_req_timeout;
+	/*
+	 * Specifies the sequence ID of the PTP timestamp packet we
+	 * are interested in. When this is specified, firmware will
+	 * only return the timestamp of the packet which matches this
+	 * sequence ID.
+	 */
+	uint32_t	ptp_seq_id;
+	/*
+	 * Specifies the PTP header offset of the PTP packet for which
+	 * the timestamp is requested.
+	 */
+	uint16_t	ptp_hdr_offset;
+	uint8_t	unused_1[6];
+} hwrm_port_ts_query_input_t, *phwrm_port_ts_query_input_t;
+
+/* hwrm_port_ts_query_output (size:192b/24B) */
+
+typedef struct hwrm_port_ts_query_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/*
+	 * Timestamp value of PTP message captured, or current value of
+	 * free running timer.
+	 */
+	uint64_t	ptp_msg_ts;
+	/* Sequence ID of the PTP message captured. */
+	uint16_t	ptp_msg_seqid;
+	uint8_t	unused_0[5];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_port_ts_query_output_t, *phwrm_port_ts_query_output_t;
+
+/***********************
+ * hwrm_port_phy_qcaps *
+ ***********************/
+
+
+/* hwrm_port_phy_qcaps_input (size:192b/24B) */
+
+typedef struct hwrm_port_phy_qcaps_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Port ID of port that is being queried. */
+	uint16_t	port_id;
+	uint8_t	unused_0[6];
+} hwrm_port_phy_qcaps_input_t, *phwrm_port_phy_qcaps_input_t;
+
+/* hwrm_port_phy_qcaps_output (size:320b/40B) */
+
+typedef struct hwrm_port_phy_qcaps_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* PHY capability flags */
+	uint8_t	flags;
+	/*
+	 * If set to 1, then this field indicates that the
+	 * link is capable of supporting EEE.
+	 */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS_EEE_SUPPORTED			UINT32_C(0x1)
+	/*
+	 * If set to 1, then this field indicates that the
+	 * PHY is capable of supporting external loopback.
+	 */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS_EXTERNAL_LPBK_SUPPORTED	UINT32_C(0x2)
+	/*
+	 * If set to 1, then this field indicates that the
+	 * PHY is capable of supporting loopback in autoneg mode.
+	 */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS_AUTONEG_LPBK_SUPPORTED	UINT32_C(0x4)
+	/*
+	 * Indicates if the configuration of shared PHY settings is
+	 * supported. In cases where a physical port is shared by multiple
+	 * functions (e.g. NPAR, multihost, etc), the configuration of PHY
+	 * settings may not be allowed. Callers to HWRM_PORT_PHY_CFG will
+	 * get an HWRM_ERR_CODE_RESOURCE_ACCESS_DENIED error in this case.
+	 */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS_SHARED_PHY_CFG_SUPPORTED	UINT32_C(0x8)
+	/*
+	 * If set to 1, it indicates that the port counters and extended
+	 * port counters will not reset when the firmware shuts down or
+	 * resets the PHY. These counters will only be reset during power
+	 * cycle or by calling HWRM_PORT_CLR_STATS.
+	 * If set to 0, the state of the counters is unspecified when
+	 * firmware shuts down or resets the PHY.
+	 */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS_CUMULATIVE_COUNTERS_ON_RESET	UINT32_C(0x10)
+	/*
+	 * If set to 1, then this field indicates that the
+	 * local loopback is not supported on this controller.
+	 */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS_LOCAL_LPBK_NOT_SUPPORTED	UINT32_C(0x20)
+	/*
+	 * If set to 1, then this field indicates that the
+	 * PHY/Link down policy during PF shutdown is totally
+	 * controlled by the firmware. It can shutdown the link
+	 * even when there are active VFs associated with the PF.
+	 * Host PF driver can send HWRM_PHY_CFG command to bring
+	 * down the PHY even when the port is shared between VFs
+	 * and PFs.
+	 */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS_FW_MANAGED_LINK_DOWN		UINT32_C(0x40)
+	/*
+	 * If set to 1, this field indicates that the FCS may
+	 * be disabled for a given packet via the transmit
+	 * buffer descriptor.
+	 */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS_NO_FCS			UINT32_C(0x80)
+	/* Number of front panel ports for this device. */
+	uint8_t	port_cnt;
+	/* Not supported or unknown */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_PORT_CNT_UNKNOWN UINT32_C(0x0)
+	/* single port device */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_PORT_CNT_1	UINT32_C(0x1)
+	/* 2-port device */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_PORT_CNT_2	UINT32_C(0x2)
+	/* 3-port device */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_PORT_CNT_3	UINT32_C(0x3)
+	/* 4-port device */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_PORT_CNT_4	UINT32_C(0x4)
+	/* 12-port device */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_PORT_CNT_12	UINT32_C(0xc)
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_PORT_CNT_LAST   HWRM_PORT_PHY_QCAPS_OUTPUT_PORT_CNT_12
+	/*
+	 * This is a bit mask to indicate what speeds are supported
+	 * as forced speeds on this link.
+	 * For each speed that can be forced on this link, the
+	 * corresponding mask bit shall be set to '1'.
+	 */
+	uint16_t	supported_speeds_force_mode;
+	/* 100Mb link speed (Half-duplex) */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_FORCE_MODE_100MBHD	UINT32_C(0x1)
+	/* 100Mb link speed (Full-duplex) */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_FORCE_MODE_100MB	UINT32_C(0x2)
+	/* 1Gb link speed (Half-duplex) */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_FORCE_MODE_1GBHD	UINT32_C(0x4)
+	/* 1Gb link speed (Full-duplex) */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_FORCE_MODE_1GB	UINT32_C(0x8)
+	/* 2Gb link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_FORCE_MODE_2GB	UINT32_C(0x10)
+	/* 25Gb link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_FORCE_MODE_2_5GB	UINT32_C(0x20)
+	/* 10Gb link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_FORCE_MODE_10GB	UINT32_C(0x40)
+	/* 20Gb link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_FORCE_MODE_20GB	UINT32_C(0x80)
+	/* 25Gb link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_FORCE_MODE_25GB	UINT32_C(0x100)
+	/* 40Gb link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_FORCE_MODE_40GB	UINT32_C(0x200)
+	/* 50Gb link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_FORCE_MODE_50GB	UINT32_C(0x400)
+	/* 100Gb link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_FORCE_MODE_100GB	UINT32_C(0x800)
+	/* 10Mb link speed (Half-duplex) */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_FORCE_MODE_10MBHD	UINT32_C(0x1000)
+	/* 10Mb link speed (Full-duplex) */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_FORCE_MODE_10MB	UINT32_C(0x2000)
+	/*
+	 * This is a bit mask to indicate what speeds are supported
+	 * for autonegotiation on this link.
+	 * For each speed that can be autonegotiated on this link, the
+	 * corresponding mask bit shall be set to '1'.
+	 */
+	uint16_t	supported_speeds_auto_mode;
+	/* 100Mb link speed (Half-duplex) */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_AUTO_MODE_100MBHD	UINT32_C(0x1)
+	/* 100Mb link speed (Full-duplex) */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_AUTO_MODE_100MB	UINT32_C(0x2)
+	/* 1Gb link speed (Half-duplex) */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_AUTO_MODE_1GBHD	UINT32_C(0x4)
+	/* 1Gb link speed (Full-duplex) */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_AUTO_MODE_1GB	UINT32_C(0x8)
+	/* 2Gb link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_AUTO_MODE_2GB	UINT32_C(0x10)
+	/* 25Gb link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_AUTO_MODE_2_5GB	UINT32_C(0x20)
+	/* 10Gb link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_AUTO_MODE_10GB	UINT32_C(0x40)
+	/* 20Gb link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_AUTO_MODE_20GB	UINT32_C(0x80)
+	/* 25Gb link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_AUTO_MODE_25GB	UINT32_C(0x100)
+	/* 40Gb link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_AUTO_MODE_40GB	UINT32_C(0x200)
+	/* 50Gb link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_AUTO_MODE_50GB	UINT32_C(0x400)
+	/* 100Gb link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_AUTO_MODE_100GB	UINT32_C(0x800)
+	/* 10Mb link speed (Half-duplex) */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_AUTO_MODE_10MBHD	UINT32_C(0x1000)
+	/* 10Mb link speed (Full-duplex) */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_AUTO_MODE_10MB	UINT32_C(0x2000)
+	/*
+	 * This is a bit mask to indicate what speeds are supported
+	 * for EEE on this link.
+	 * For each speed that can be autonegotiated when EEE is enabled
+	 * on this link, the corresponding mask bit shall be set to '1'.
+	 * This field is only valid when the eee_supported is set to '1'.
+	 */
+	uint16_t	supported_speeds_eee_mode;
+	/* Reserved */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_EEE_MODE_RSVD1	UINT32_C(0x1)
+	/* 100Mb link speed (Full-duplex) */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_EEE_MODE_100MB	UINT32_C(0x2)
+	/* Reserved */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_EEE_MODE_RSVD2	UINT32_C(0x4)
+	/* 1Gb link speed (Full-duplex) */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_EEE_MODE_1GB	UINT32_C(0x8)
+	/* Reserved */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_EEE_MODE_RSVD3	UINT32_C(0x10)
+	/* Reserved */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_EEE_MODE_RSVD4	UINT32_C(0x20)
+	/* 10Gb link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_EEE_MODE_10GB	UINT32_C(0x40)
+	uint32_t	tx_lpi_timer_low;
+	/*
+	 * The lowest value of TX LPI timer that can be set on this link
+	 * when EEE is enabled. This value is in microseconds.
+	 * This field is valid only when_eee_supported is set to '1'.
+	 */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_TX_LPI_TIMER_LOW_MASK UINT32_C(0xffffff)
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_TX_LPI_TIMER_LOW_SFT 0
+	/*
+	 * Reserved field. The HWRM shall set this field to 0.
+	 * An HWRM client shall ignore this field.
+	 */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_RSVD2_MASK	UINT32_C(0xff000000)
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_RSVD2_SFT		24
+	uint32_t	valid_tx_lpi_timer_high;
+	/*
+	 * The highest value of TX LPI timer that can be set on this link
+	 * when EEE is enabled. This value is in microseconds.
+	 * This field is valid only when_eee_supported is set to '1'.
+	 */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_TX_LPI_TIMER_HIGH_MASK UINT32_C(0xffffff)
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_TX_LPI_TIMER_HIGH_SFT 0
+	/*
+	 * Reserved field. The HWRM shall set this field to 0.
+	 * An HWRM client shall ignore this field.
+	 */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_RSVD_MASK		UINT32_C(0xff000000)
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_RSVD_SFT		24
+	/*
+	 * This field is used to advertise which PAM4 speeds are supported
+	 * in auto mode.
+	 */
+	uint16_t	supported_pam4_speeds_auto_mode;
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_PAM4_SPEEDS_AUTO_MODE_50G	UINT32_C(0x1)
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_PAM4_SPEEDS_AUTO_MODE_100G	UINT32_C(0x2)
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_PAM4_SPEEDS_AUTO_MODE_200G	UINT32_C(0x4)
+	/*
+	 * This field is used to advertise which PAM4 speeds are supported
+	 * in forced mode.
+	 */
+	uint16_t	supported_pam4_speeds_force_mode;
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_PAM4_SPEEDS_FORCE_MODE_50G	UINT32_C(0x1)
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_PAM4_SPEEDS_FORCE_MODE_100G	UINT32_C(0x2)
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_PAM4_SPEEDS_FORCE_MODE_200G	UINT32_C(0x4)
+	/* More PHY capability flags */
+	uint16_t	flags2;
+	/*
+	 * If set to 1, then this field indicates that
+	 * 802.3x flow control is not supported.
+	 */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS2_PAUSE_UNSUPPORTED	UINT32_C(0x1)
+	/*
+	 * If set to 1, then this field indicates that
+	 * priority-based flow control is not supported.
+	 */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS2_PFC_UNSUPPORTED		UINT32_C(0x2)
+	/*
+	 * If set to 1, then this field indicates that
+	 * bank based addressing is supported in firmware.
+	 */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS2_BANK_ADDR_SUPPORTED	UINT32_C(0x4)
+	/*
+	 * If set to 1, then this field indicates that
+	 * supported_speed2 field is to be used in lieu of all
+	 * supported_speed variants.
+	 */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS2_SPEEDS2_SUPPORTED	UINT32_C(0x8)
+	/*
+	 * If set to 1, then this field indicates that
+	 * the device does not support remote loopback.
+	 */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS2_REMOTE_LPBK_UNSUPPORTED	UINT32_C(0x10)
+	/*
+	 * Number of internal ports for this device. This field allows the FW
+	 * to advertise how many internal ports are present. Manufacturing
+	 * tools uses this to determine how many internal ports should have
+	 * the PRBS test run on them. This field always return 0 unless NVM
+	 * option "HPTN_MODE" is set to 1.
+	 */
+	uint8_t	internal_port_cnt;
+	uint8_t	unused_0;
+	/*
+	 * This is a bit mask to indicate what speeds are supported
+	 * as forced speeds on this link.
+	 * For each speed that can be forced on this link, the
+	 * corresponding mask bit shall be set to '1'.
+	 * This field is valid only if speeds2_supported bit is set in flags2
+	 */
+	uint16_t	supported_speeds2_force_mode;
+	/* 1Gb link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS2_FORCE_MODE_1GB		UINT32_C(0x1)
+	/* 10Gb (NRZ: 10G per lane, 1 lane) link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS2_FORCE_MODE_10GB		UINT32_C(0x2)
+	/* 25Gb (NRZ: 25G per lane, 1 lane) link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS2_FORCE_MODE_25GB		UINT32_C(0x4)
+	/* 40Gb (NRZ: 10G per lane, 4 lanes) link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS2_FORCE_MODE_40GB		UINT32_C(0x8)
+	/* 50Gb (NRZ: 25G per lane, 2 lanes) link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS2_FORCE_MODE_50GB		UINT32_C(0x10)
+	/* 100Gb (NRZ: 25G per lane, 4 lanes) link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS2_FORCE_MODE_100GB		UINT32_C(0x20)
+	/* 50Gb (PAM4-56: 50G per lane, 1 lane) link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS2_FORCE_MODE_50GB_PAM4_56	UINT32_C(0x40)
+	/* 100Gb (PAM4-56: 50G per lane, 2 lanes) link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS2_FORCE_MODE_100GB_PAM4_56	UINT32_C(0x80)
+	/* 200Gb (PAM4-56: 50G per lane, 4 lanes) link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS2_FORCE_MODE_200GB_PAM4_56	UINT32_C(0x100)
+	/* 400Gb (PAM4-56: 50G per lane, 8 lanes) link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS2_FORCE_MODE_400GB_PAM4_56	UINT32_C(0x200)
+	/* 100Gb (PAM4-112: 100G per lane, 1 lane) link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS2_FORCE_MODE_100GB_PAM4_112	UINT32_C(0x400)
+	/* 200Gb (PAM4-112: 100G per lane, 2 lanes) link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS2_FORCE_MODE_200GB_PAM4_112	UINT32_C(0x800)
+	/* 400Gb (PAM4-112: 100G per lane, 4 lanes) link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS2_FORCE_MODE_400GB_PAM4_112	UINT32_C(0x1000)
+	/* 800Gb (PAM4-112: 100G per lane, 8 lanes) link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS2_FORCE_MODE_800GB_PAM4_112	UINT32_C(0x2000)
+	/*
+	 * This is a bit mask to indicate what speeds are supported
+	 * for autonegotiation on this link.
+	 * For each speed that can be autonegotiated on this link, the
+	 * corresponding mask bit shall be set to '1'.
+	 * This field is valid only if speeds2_supported bit is set in flags2
+	 */
+	uint16_t	supported_speeds2_auto_mode;
+	/* 1Gb link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS2_AUTO_MODE_1GB		UINT32_C(0x1)
+	/* 10Gb (NRZ: 10G per lane, 1 lane) link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS2_AUTO_MODE_10GB		UINT32_C(0x2)
+	/* 25Gb (NRZ: 25G per lane, 1 lane) link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS2_AUTO_MODE_25GB		UINT32_C(0x4)
+	/* 40Gb (NRZ: 10G per lane, 4 lanes) link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS2_AUTO_MODE_40GB		UINT32_C(0x8)
+	/* 50Gb (NRZ: 25G per lane, 2 lanes) link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS2_AUTO_MODE_50GB		UINT32_C(0x10)
+	/* 100Gb (NRZ: 25G per lane, 4 lanes) link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS2_AUTO_MODE_100GB		UINT32_C(0x20)
+	/* 50Gb (PAM4-56: 50G per lane, 1 lane) link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS2_AUTO_MODE_50GB_PAM4_56	UINT32_C(0x40)
+	/* 100Gb (PAM4-56: 50G per lane, 2 lanes) link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS2_AUTO_MODE_100GB_PAM4_56	UINT32_C(0x80)
+	/* 200Gb (PAM4-56: 50G per lane, 4 lanes) link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS2_AUTO_MODE_200GB_PAM4_56	UINT32_C(0x100)
+	/* 400Gb (PAM4-56: 50G per lane, 8 lanes) link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS2_AUTO_MODE_400GB_PAM4_56	UINT32_C(0x200)
+	/* 100Gb (PAM4-112: 100G per lane, 1 lane) link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS2_AUTO_MODE_100GB_PAM4_112	UINT32_C(0x400)
+	/* 200Gb (PAM4-112: 100G per lane, 2 lanes) link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS2_AUTO_MODE_200GB_PAM4_112	UINT32_C(0x800)
+	/* 400Gb (PAM4-112: 100G per lane, 4 lanes) link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS2_AUTO_MODE_400GB_PAM4_112	UINT32_C(0x1000)
+	/* 800Gb (PAM4-112: 100G per lane, 8 lanes) link speed */
+	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS2_AUTO_MODE_800GB_PAM4_112	UINT32_C(0x2000)
+	uint8_t	unused_1[3];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_port_phy_qcaps_output_t, *phwrm_port_phy_qcaps_output_t;
+
+/***************************
+ * hwrm_port_phy_i2c_write *
+ ***************************/
+
+
+/* hwrm_port_phy_i2c_write_input (size:832b/104B) */
+
+typedef struct hwrm_port_phy_i2c_write_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	flags;
+	uint32_t	enables;
+	/*
+	 * This bit must be '1' for the page_offset field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_PHY_I2C_WRITE_INPUT_ENABLES_PAGE_OFFSET	UINT32_C(0x1)
+	/*
+	 * This bit must be '1' for the bank_number field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_PHY_I2C_WRITE_INPUT_ENABLES_BANK_NUMBER	UINT32_C(0x2)
+	/* Port ID of port. */
+	uint16_t	port_id;
+	/* 8-bit I2C slave address. */
+	uint8_t	i2c_slave_addr;
+	/* The bank number of the page that is being accessed over I2C. */
+	uint8_t	bank_number;
+	/* The page number that is being accessed over I2C. */
+	uint16_t	page_number;
+	/* Offset within the page that is being accessed over I2C. */
+	uint16_t	page_offset;
+	/*
+	 * Length of data to write, in bytes starting at the offset
+	 * specified above. If the offset is not specified, then
+	 * the data shall be written from the beginning of the page.
+	 */
+	uint8_t	data_length;
+	uint8_t	unused_1[7];
+	/* Up to 64B of data. */
+	uint32_t	data[16];
+} hwrm_port_phy_i2c_write_input_t, *phwrm_port_phy_i2c_write_input_t;
+
+/* hwrm_port_phy_i2c_write_output (size:128b/16B) */
+
+typedef struct hwrm_port_phy_i2c_write_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_port_phy_i2c_write_output_t, *phwrm_port_phy_i2c_write_output_t;
+
+/**************************
+ * hwrm_port_phy_i2c_read *
+ **************************/
+
+
+/* hwrm_port_phy_i2c_read_input (size:320b/40B) */
+
+typedef struct hwrm_port_phy_i2c_read_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	flags;
+	uint32_t	enables;
+	/*
+	 * This bit must be '1' for the page_offset field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_PHY_I2C_READ_INPUT_ENABLES_PAGE_OFFSET	UINT32_C(0x1)
+	/*
+	 * This bit must be '1' for the bank_number field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_PHY_I2C_READ_INPUT_ENABLES_BANK_NUMBER	UINT32_C(0x2)
+	/* Port ID of port. */
+	uint16_t	port_id;
+	/* 8-bit I2C slave address. */
+	uint8_t	i2c_slave_addr;
+	/* The bank number of the page that is being accessed over I2C. */
+	uint8_t	bank_number;
+	/* The page number that is being accessed over I2C. */
+	uint16_t	page_number;
+	/* Offset within the page that is being accessed over I2C. */
+	uint16_t	page_offset;
+	/*
+	 * Length of data to read, in bytes starting at the offset
+	 * specified above. If the offset is not specified, then
+	 * the data shall be read from the beginning of the page.
+	 */
+	uint8_t	data_length;
+	uint8_t	unused_1[7];
+} hwrm_port_phy_i2c_read_input_t, *phwrm_port_phy_i2c_read_input_t;
+
+/* hwrm_port_phy_i2c_read_output (size:640b/80B) */
+
+typedef struct hwrm_port_phy_i2c_read_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Up to 64B of data. */
+	uint32_t	data[16];
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_port_phy_i2c_read_output_t, *phwrm_port_phy_i2c_read_output_t;
+
+/****************************
+ * hwrm_port_phy_mdio_write *
+ ****************************/
+
+
+/* hwrm_port_phy_mdio_write_input (size:320b/40B) */
+
+typedef struct hwrm_port_phy_mdio_write_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Reserved for future use. */
+	uint64_t	unused_0;
+	/* Port ID of port. */
+	uint16_t	port_id;
+	/* If phy_address is 0xFF, port_id will be used to derive phy_addr. */
+	uint8_t	phy_addr;
+	/* 8-bit device address. */
+	uint8_t	dev_addr;
+	/* 16-bit register address. */
+	uint16_t	reg_addr;
+	/* 16-bit register data. */
+	uint16_t	reg_data;
+	/*
+	 * When this bit is set to 1 a Clause 45 mdio access is done.
+	 * when this bit is set to 0 a Clause 22 mdio access is done.
+	 */
+	uint8_t	cl45_mdio;
+	/*  */
+	uint8_t	unused_1[7];
+} hwrm_port_phy_mdio_write_input_t, *phwrm_port_phy_mdio_write_input_t;
+
+/* hwrm_port_phy_mdio_write_output (size:128b/16B) */
+
+typedef struct hwrm_port_phy_mdio_write_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_port_phy_mdio_write_output_t, *phwrm_port_phy_mdio_write_output_t;
+
+/***************************
+ * hwrm_port_phy_mdio_read *
+ ***************************/
+
+
+/* hwrm_port_phy_mdio_read_input (size:256b/32B) */
+
+typedef struct hwrm_port_phy_mdio_read_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Reserved for future use. */
+	uint64_t	unused_0;
+	/* Port ID of port. */
+	uint16_t	port_id;
+	/* If phy_address is 0xFF, port_id will be used to derive phy_addr. */
+	uint8_t	phy_addr;
+	/* 8-bit device address. */
+	uint8_t	dev_addr;
+	/* 16-bit register address. */
+	uint16_t	reg_addr;
+	/*
+	 * When this bit is set to 1 a Clause 45 mdio access is done.
+	 * when this bit is set to 0 a Clause 22 mdio access is done.
+	 */
+	uint8_t	cl45_mdio;
+	/*  */
+	uint8_t	unused_1;
+} hwrm_port_phy_mdio_read_input_t, *phwrm_port_phy_mdio_read_input_t;
+
+/* hwrm_port_phy_mdio_read_output (size:128b/16B) */
+
+typedef struct hwrm_port_phy_mdio_read_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* 16-bit register data. */
+	uint16_t	reg_data;
+	uint8_t	unused_0[5];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_port_phy_mdio_read_output_t, *phwrm_port_phy_mdio_read_output_t;
+
+/*********************
+ * hwrm_port_led_cfg *
+ *********************/
+
+
+/* hwrm_port_led_cfg_input (size:512b/64B) */
+
+typedef struct hwrm_port_led_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	enables;
+	/*
+	 * This bit must be '1' for the led0_id field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED0_ID		UINT32_C(0x1)
+	/*
+	 * This bit must be '1' for the led0_state field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED0_STATE	UINT32_C(0x2)
+	/*
+	 * This bit must be '1' for the led0_color field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED0_COLOR	UINT32_C(0x4)
+	/*
+	 * This bit must be '1' for the led0_blink_on field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED0_BLINK_ON	UINT32_C(0x8)
+	/*
+	 * This bit must be '1' for the led0_blink_off field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED0_BLINK_OFF	UINT32_C(0x10)
+	/*
+	 * This bit must be '1' for the led0_group_id field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED0_GROUP_ID	UINT32_C(0x20)
+	/*
+	 * This bit must be '1' for the led1_id field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED1_ID		UINT32_C(0x40)
+	/*
+	 * This bit must be '1' for the led1_state field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED1_STATE	UINT32_C(0x80)
+	/*
+	 * This bit must be '1' for the led1_color field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED1_COLOR	UINT32_C(0x100)
+	/*
+	 * This bit must be '1' for the led1_blink_on field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED1_BLINK_ON	UINT32_C(0x200)
+	/*
+	 * This bit must be '1' for the led1_blink_off field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED1_BLINK_OFF	UINT32_C(0x400)
+	/*
+	 * This bit must be '1' for the led1_group_id field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED1_GROUP_ID	UINT32_C(0x800)
+	/*
+	 * This bit must be '1' for the led2_id field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED2_ID		UINT32_C(0x1000)
+	/*
+	 * This bit must be '1' for the led2_state field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED2_STATE	UINT32_C(0x2000)
+	/*
+	 * This bit must be '1' for the led2_color field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED2_COLOR	UINT32_C(0x4000)
+	/*
+	 * This bit must be '1' for the led2_blink_on field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED2_BLINK_ON	UINT32_C(0x8000)
+	/*
+	 * This bit must be '1' for the led2_blink_off field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED2_BLINK_OFF	UINT32_C(0x10000)
+	/*
+	 * This bit must be '1' for the led2_group_id field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED2_GROUP_ID	UINT32_C(0x20000)
+	/*
+	 * This bit must be '1' for the led3_id field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED3_ID		UINT32_C(0x40000)
+	/*
+	 * This bit must be '1' for the led3_state field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED3_STATE	UINT32_C(0x80000)
+	/*
+	 * This bit must be '1' for the led3_color field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED3_COLOR	UINT32_C(0x100000)
+	/*
+	 * This bit must be '1' for the led3_blink_on field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED3_BLINK_ON	UINT32_C(0x200000)
+	/*
+	 * This bit must be '1' for the led3_blink_off field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED3_BLINK_OFF	UINT32_C(0x400000)
+	/*
+	 * This bit must be '1' for the led3_group_id field to be
+	 * configured.
+	 */
+	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED3_GROUP_ID	UINT32_C(0x800000)
+	/* Port ID of port whose LEDs are configured. */
+	uint16_t	port_id;
+	/*
+	 * The number of LEDs that are being configured.
+	 * Up to 4 LEDs can be configured with this command.
+	 */
+	uint8_t	num_leds;
+	/* Reserved field. */
+	uint8_t	rsvd;
+	/* An identifier for the LED #0. */
+	uint8_t	led0_id;
+	/* The requested state of the LED #0. */
+	uint8_t	led0_state;
+	/* Default state of the LED */
+	#define HWRM_PORT_LED_CFG_INPUT_LED0_STATE_DEFAULT  UINT32_C(0x0)
+	/* Off */
+	#define HWRM_PORT_LED_CFG_INPUT_LED0_STATE_OFF	UINT32_C(0x1)
+	/* On */
+	#define HWRM_PORT_LED_CFG_INPUT_LED0_STATE_ON	UINT32_C(0x2)
+	/* Blink */
+	#define HWRM_PORT_LED_CFG_INPUT_LED0_STATE_BLINK	UINT32_C(0x3)
+	/* Blink Alternately */
+	#define HWRM_PORT_LED_CFG_INPUT_LED0_STATE_BLINKALT UINT32_C(0x4)
+	#define HWRM_PORT_LED_CFG_INPUT_LED0_STATE_LAST	HWRM_PORT_LED_CFG_INPUT_LED0_STATE_BLINKALT
+	/* The requested color of LED #0. */
+	uint8_t	led0_color;
+	/* Default */
+	#define HWRM_PORT_LED_CFG_INPUT_LED0_COLOR_DEFAULT	UINT32_C(0x0)
+	/* Amber */
+	#define HWRM_PORT_LED_CFG_INPUT_LED0_COLOR_AMBER	UINT32_C(0x1)
+	/* Green */
+	#define HWRM_PORT_LED_CFG_INPUT_LED0_COLOR_GREEN	UINT32_C(0x2)
+	/* Green or Amber */
+	#define HWRM_PORT_LED_CFG_INPUT_LED0_COLOR_GREENAMBER UINT32_C(0x3)
+	#define HWRM_PORT_LED_CFG_INPUT_LED0_COLOR_LAST	HWRM_PORT_LED_CFG_INPUT_LED0_COLOR_GREENAMBER
+	uint8_t	unused_0;
+	/*
+	 * If the LED #0 state is "blink" or "blinkalt", then
+	 * this field represents the requested time in milliseconds
+	 * to keep LED on between cycles.
+	 */
+	uint16_t	led0_blink_on;
+	/*
+	 * If the LED #0 state is "blink" or "blinkalt", then
+	 * this field represents the requested time in milliseconds
+	 * to keep LED off between cycles.
+	 */
+	uint16_t	led0_blink_off;
+	/*
+	 * An identifier for the group of LEDs that LED #0 belongs
+	 * to.
+	 * If set to 0, then the LED #0 shall not be grouped and
+	 * shall be treated as an individual resource.
+	 * For all other non-zero values of this field, LED #0 shall
+	 * be grouped together with the LEDs with the same group ID
+	 * value.
+	 */
+	uint8_t	led0_group_id;
+	/* Reserved field. */
+	uint8_t	rsvd0;
+	/* An identifier for the LED #1. */
+	uint8_t	led1_id;
+	/* The requested state of the LED #1. */
+	uint8_t	led1_state;
+	/* Default state of the LED */
+	#define HWRM_PORT_LED_CFG_INPUT_LED1_STATE_DEFAULT  UINT32_C(0x0)
+	/* Off */
+	#define HWRM_PORT_LED_CFG_INPUT_LED1_STATE_OFF	UINT32_C(0x1)
+	/* On */
+	#define HWRM_PORT_LED_CFG_INPUT_LED1_STATE_ON	UINT32_C(0x2)
+	/* Blink */
+	#define HWRM_PORT_LED_CFG_INPUT_LED1_STATE_BLINK	UINT32_C(0x3)
+	/* Blink Alternately */
+	#define HWRM_PORT_LED_CFG_INPUT_LED1_STATE_BLINKALT UINT32_C(0x4)
+	#define HWRM_PORT_LED_CFG_INPUT_LED1_STATE_LAST	HWRM_PORT_LED_CFG_INPUT_LED1_STATE_BLINKALT
+	/* The requested color of LED #1. */
+	uint8_t	led1_color;
+	/* Default */
+	#define HWRM_PORT_LED_CFG_INPUT_LED1_COLOR_DEFAULT	UINT32_C(0x0)
+	/* Amber */
+	#define HWRM_PORT_LED_CFG_INPUT_LED1_COLOR_AMBER	UINT32_C(0x1)
+	/* Green */
+	#define HWRM_PORT_LED_CFG_INPUT_LED1_COLOR_GREEN	UINT32_C(0x2)
+	/* Green or Amber */
+	#define HWRM_PORT_LED_CFG_INPUT_LED1_COLOR_GREENAMBER UINT32_C(0x3)
+	#define HWRM_PORT_LED_CFG_INPUT_LED1_COLOR_LAST	HWRM_PORT_LED_CFG_INPUT_LED1_COLOR_GREENAMBER
+	uint8_t	unused_1;
+	/*
+	 * If the LED #1 state is "blink" or "blinkalt", then
+	 * this field represents the requested time in milliseconds
+	 * to keep LED on between cycles.
+	 */
+	uint16_t	led1_blink_on;
+	/*
+	 * If the LED #1 state is "blink" or "blinkalt", then
+	 * this field represents the requested time in milliseconds
+	 * to keep LED off between cycles.
+	 */
+	uint16_t	led1_blink_off;
+	/*
+	 * An identifier for the group of LEDs that LED #1 belongs
+	 * to.
+	 * If set to 0, then the LED #1 shall not be grouped and
+	 * shall be treated as an individual resource.
+	 * For all other non-zero values of this field, LED #1 shall
+	 * be grouped together with the LEDs with the same group ID
+	 * value.
+	 */
+	uint8_t	led1_group_id;
+	/* Reserved field. */
+	uint8_t	rsvd1;
+	/* An identifier for the LED #2. */
+	uint8_t	led2_id;
+	/* The requested state of the LED #2. */
+	uint8_t	led2_state;
+	/* Default state of the LED */
+	#define HWRM_PORT_LED_CFG_INPUT_LED2_STATE_DEFAULT  UINT32_C(0x0)
+	/* Off */
+	#define HWRM_PORT_LED_CFG_INPUT_LED2_STATE_OFF	UINT32_C(0x1)
+	/* On */
+	#define HWRM_PORT_LED_CFG_INPUT_LED2_STATE_ON	UINT32_C(0x2)
+	/* Blink */
+	#define HWRM_PORT_LED_CFG_INPUT_LED2_STATE_BLINK	UINT32_C(0x3)
+	/* Blink Alternately */
+	#define HWRM_PORT_LED_CFG_INPUT_LED2_STATE_BLINKALT UINT32_C(0x4)
+	#define HWRM_PORT_LED_CFG_INPUT_LED2_STATE_LAST	HWRM_PORT_LED_CFG_INPUT_LED2_STATE_BLINKALT
+	/* The requested color of LED #2. */
+	uint8_t	led2_color;
+	/* Default */
+	#define HWRM_PORT_LED_CFG_INPUT_LED2_COLOR_DEFAULT	UINT32_C(0x0)
+	/* Amber */
+	#define HWRM_PORT_LED_CFG_INPUT_LED2_COLOR_AMBER	UINT32_C(0x1)
+	/* Green */
+	#define HWRM_PORT_LED_CFG_INPUT_LED2_COLOR_GREEN	UINT32_C(0x2)
+	/* Green or Amber */
+	#define HWRM_PORT_LED_CFG_INPUT_LED2_COLOR_GREENAMBER UINT32_C(0x3)
+	#define HWRM_PORT_LED_CFG_INPUT_LED2_COLOR_LAST	HWRM_PORT_LED_CFG_INPUT_LED2_COLOR_GREENAMBER
+	uint8_t	unused_2;
+	/*
+	 * If the LED #2 state is "blink" or "blinkalt", then
+	 * this field represents the requested time in milliseconds
+	 * to keep LED on between cycles.
+	 */
+	uint16_t	led2_blink_on;
+	/*
+	 * If the LED #2 state is "blink" or "blinkalt", then
+	 * this field represents the requested time in milliseconds
+	 * to keep LED off between cycles.
+	 */
+	uint16_t	led2_blink_off;
+	/*
+	 * An identifier for the group of LEDs that LED #2 belongs
+	 * to.
+	 * If set to 0, then the LED #2 shall not be grouped and
+	 * shall be treated as an individual resource.
+	 * For all other non-zero values of this field, LED #2 shall
+	 * be grouped together with the LEDs with the same group ID
+	 * value.
+	 */
+	uint8_t	led2_group_id;
+	/* Reserved field. */
+	uint8_t	rsvd2;
+	/* An identifier for the LED #3. */
+	uint8_t	led3_id;
+	/* The requested state of the LED #3. */
+	uint8_t	led3_state;
+	/* Default state of the LED */
+	#define HWRM_PORT_LED_CFG_INPUT_LED3_STATE_DEFAULT  UINT32_C(0x0)
+	/* Off */
+	#define HWRM_PORT_LED_CFG_INPUT_LED3_STATE_OFF	UINT32_C(0x1)
+	/* On */
+	#define HWRM_PORT_LED_CFG_INPUT_LED3_STATE_ON	UINT32_C(0x2)
+	/* Blink */
+	#define HWRM_PORT_LED_CFG_INPUT_LED3_STATE_BLINK	UINT32_C(0x3)
+	/* Blink Alternately */
+	#define HWRM_PORT_LED_CFG_INPUT_LED3_STATE_BLINKALT UINT32_C(0x4)
+	#define HWRM_PORT_LED_CFG_INPUT_LED3_STATE_LAST	HWRM_PORT_LED_CFG_INPUT_LED3_STATE_BLINKALT
+	/* The requested color of LED #3. */
+	uint8_t	led3_color;
+	/* Default */
+	#define HWRM_PORT_LED_CFG_INPUT_LED3_COLOR_DEFAULT	UINT32_C(0x0)
+	/* Amber */
+	#define HWRM_PORT_LED_CFG_INPUT_LED3_COLOR_AMBER	UINT32_C(0x1)
+	/* Green */
+	#define HWRM_PORT_LED_CFG_INPUT_LED3_COLOR_GREEN	UINT32_C(0x2)
+	/* Green or Amber */
+	#define HWRM_PORT_LED_CFG_INPUT_LED3_COLOR_GREENAMBER UINT32_C(0x3)
+	#define HWRM_PORT_LED_CFG_INPUT_LED3_COLOR_LAST	HWRM_PORT_LED_CFG_INPUT_LED3_COLOR_GREENAMBER
+	uint8_t	unused_3;
+	/*
+	 * If the LED #3 state is "blink" or "blinkalt", then
+	 * this field represents the requested time in milliseconds
+	 * to keep LED on between cycles.
+	 */
+	uint16_t	led3_blink_on;
+	/*
+	 * If the LED #3 state is "blink" or "blinkalt", then
+	 * this field represents the requested time in milliseconds
+	 * to keep LED off between cycles.
+	 */
+	uint16_t	led3_blink_off;
+	/*
+	 * An identifier for the group of LEDs that LED #3 belongs
+	 * to.
+	 * If set to 0, then the LED #3 shall not be grouped and
+	 * shall be treated as an individual resource.
+	 * For all other non-zero values of this field, LED #3 shall
+	 * be grouped together with the LEDs with the same group ID
+	 * value.
+	 */
+	uint8_t	led3_group_id;
+	/* Reserved field. */
+	uint8_t	rsvd3;
+} hwrm_port_led_cfg_input_t, *phwrm_port_led_cfg_input_t;
+
+/* hwrm_port_led_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_port_led_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_port_led_cfg_output_t, *phwrm_port_led_cfg_output_t;
+
+/**********************
+ * hwrm_port_led_qcfg *
+ **********************/
+
+
+/* hwrm_port_led_qcfg_input (size:192b/24B) */
+
+typedef struct hwrm_port_led_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Port ID of port whose LED configuration is being queried. */
+	uint16_t	port_id;
+	uint8_t	unused_0[6];
+} hwrm_port_led_qcfg_input_t, *phwrm_port_led_qcfg_input_t;
+
+/* hwrm_port_led_qcfg_output (size:448b/56B) */
+
+typedef struct hwrm_port_led_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/*
+	 * The number of LEDs that are configured on this port.
+	 * Up to 4 LEDs can be returned in the response.
+	 */
+	uint8_t	num_leds;
+	/* An identifier for the LED #0. */
+	uint8_t	led0_id;
+	/* The type of LED #0. */
+	uint8_t	led0_type;
+	/* Speed LED */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED0_TYPE_SPEED	UINT32_C(0x0)
+	/* Activity LED */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED0_TYPE_ACTIVITY UINT32_C(0x1)
+	/* Invalid */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED0_TYPE_INVALID  UINT32_C(0xff)
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED0_TYPE_LAST	HWRM_PORT_LED_QCFG_OUTPUT_LED0_TYPE_INVALID
+	/* The current state of the LED #0. */
+	uint8_t	led0_state;
+	/* Default state of the LED */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED0_STATE_DEFAULT  UINT32_C(0x0)
+	/* Off */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED0_STATE_OFF	UINT32_C(0x1)
+	/* On */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED0_STATE_ON	UINT32_C(0x2)
+	/* Blink */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED0_STATE_BLINK	UINT32_C(0x3)
+	/* Blink Alternately */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED0_STATE_BLINKALT UINT32_C(0x4)
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED0_STATE_LAST	HWRM_PORT_LED_QCFG_OUTPUT_LED0_STATE_BLINKALT
+	/* The color of LED #0. */
+	uint8_t	led0_color;
+	/* Default */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED0_COLOR_DEFAULT	UINT32_C(0x0)
+	/* Amber */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED0_COLOR_AMBER	UINT32_C(0x1)
+	/* Green */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED0_COLOR_GREEN	UINT32_C(0x2)
+	/* Green or Amber */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED0_COLOR_GREENAMBER UINT32_C(0x3)
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED0_COLOR_LAST	HWRM_PORT_LED_QCFG_OUTPUT_LED0_COLOR_GREENAMBER
+	uint8_t	unused_0;
+	/*
+	 * If the LED #0 state is "blink" or "blinkalt", then
+	 * this field represents the requested time in milliseconds
+	 * to keep LED on between cycles.
+	 */
+	uint16_t	led0_blink_on;
+	/*
+	 * If the LED #0 state is "blink" or "blinkalt", then
+	 * this field represents the requested time in milliseconds
+	 * to keep LED off between cycles.
+	 */
+	uint16_t	led0_blink_off;
+	/*
+	 * An identifier for the group of LEDs that LED #0 belongs
+	 * to.
+	 * If set to 0, then the LED #0 is not grouped.
+	 * For all other non-zero values of this field, LED #0 is
+	 * grouped together with the LEDs with the same group ID
+	 * value.
+	 */
+	uint8_t	led0_group_id;
+	/* An identifier for the LED #1. */
+	uint8_t	led1_id;
+	/* The type of LED #1. */
+	uint8_t	led1_type;
+	/* Speed LED */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED1_TYPE_SPEED	UINT32_C(0x0)
+	/* Activity LED */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED1_TYPE_ACTIVITY UINT32_C(0x1)
+	/* Invalid */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED1_TYPE_INVALID  UINT32_C(0xff)
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED1_TYPE_LAST	HWRM_PORT_LED_QCFG_OUTPUT_LED1_TYPE_INVALID
+	/* The current state of the LED #1. */
+	uint8_t	led1_state;
+	/* Default state of the LED */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED1_STATE_DEFAULT  UINT32_C(0x0)
+	/* Off */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED1_STATE_OFF	UINT32_C(0x1)
+	/* On */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED1_STATE_ON	UINT32_C(0x2)
+	/* Blink */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED1_STATE_BLINK	UINT32_C(0x3)
+	/* Blink Alternately */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED1_STATE_BLINKALT UINT32_C(0x4)
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED1_STATE_LAST	HWRM_PORT_LED_QCFG_OUTPUT_LED1_STATE_BLINKALT
+	/* The color of LED #1. */
+	uint8_t	led1_color;
+	/* Default */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED1_COLOR_DEFAULT	UINT32_C(0x0)
+	/* Amber */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED1_COLOR_AMBER	UINT32_C(0x1)
+	/* Green */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED1_COLOR_GREEN	UINT32_C(0x2)
+	/* Green or Amber */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED1_COLOR_GREENAMBER UINT32_C(0x3)
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED1_COLOR_LAST	HWRM_PORT_LED_QCFG_OUTPUT_LED1_COLOR_GREENAMBER
+	uint8_t	unused_1;
+	/*
+	 * If the LED #1 state is "blink" or "blinkalt", then
+	 * this field represents the requested time in milliseconds
+	 * to keep LED on between cycles.
+	 */
+	uint16_t	led1_blink_on;
+	/*
+	 * If the LED #1 state is "blink" or "blinkalt", then
+	 * this field represents the requested time in milliseconds
+	 * to keep LED off between cycles.
+	 */
+	uint16_t	led1_blink_off;
+	/*
+	 * An identifier for the group of LEDs that LED #1 belongs
+	 * to.
+	 * If set to 0, then the LED #1 is not grouped.
+	 * For all other non-zero values of this field, LED #1 is
+	 * grouped together with the LEDs with the same group ID
+	 * value.
+	 */
+	uint8_t	led1_group_id;
+	/* An identifier for the LED #2. */
+	uint8_t	led2_id;
+	/* The type of LED #2. */
+	uint8_t	led2_type;
+	/* Speed LED */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED2_TYPE_SPEED	UINT32_C(0x0)
+	/* Activity LED */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED2_TYPE_ACTIVITY UINT32_C(0x1)
+	/* Invalid */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED2_TYPE_INVALID  UINT32_C(0xff)
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED2_TYPE_LAST	HWRM_PORT_LED_QCFG_OUTPUT_LED2_TYPE_INVALID
+	/* The current state of the LED #2. */
+	uint8_t	led2_state;
+	/* Default state of the LED */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED2_STATE_DEFAULT  UINT32_C(0x0)
+	/* Off */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED2_STATE_OFF	UINT32_C(0x1)
+	/* On */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED2_STATE_ON	UINT32_C(0x2)
+	/* Blink */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED2_STATE_BLINK	UINT32_C(0x3)
+	/* Blink Alternately */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED2_STATE_BLINKALT UINT32_C(0x4)
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED2_STATE_LAST	HWRM_PORT_LED_QCFG_OUTPUT_LED2_STATE_BLINKALT
+	/* The color of LED #2. */
+	uint8_t	led2_color;
+	/* Default */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED2_COLOR_DEFAULT	UINT32_C(0x0)
+	/* Amber */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED2_COLOR_AMBER	UINT32_C(0x1)
+	/* Green */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED2_COLOR_GREEN	UINT32_C(0x2)
+	/* Green or Amber */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED2_COLOR_GREENAMBER UINT32_C(0x3)
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED2_COLOR_LAST	HWRM_PORT_LED_QCFG_OUTPUT_LED2_COLOR_GREENAMBER
+	uint8_t	unused_2;
+	/*
+	 * If the LED #2 state is "blink" or "blinkalt", then
+	 * this field represents the requested time in milliseconds
+	 * to keep LED on between cycles.
+	 */
+	uint16_t	led2_blink_on;
+	/*
+	 * If the LED #2 state is "blink" or "blinkalt", then
+	 * this field represents the requested time in milliseconds
+	 * to keep LED off between cycles.
+	 */
+	uint16_t	led2_blink_off;
+	/*
+	 * An identifier for the group of LEDs that LED #2 belongs
+	 * to.
+	 * If set to 0, then the LED #2 is not grouped.
+	 * For all other non-zero values of this field, LED #2 is
+	 * grouped together with the LEDs with the same group ID
+	 * value.
+	 */
+	uint8_t	led2_group_id;
+	/* An identifier for the LED #3. */
+	uint8_t	led3_id;
+	/* The type of LED #3. */
+	uint8_t	led3_type;
+	/* Speed LED */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED3_TYPE_SPEED	UINT32_C(0x0)
+	/* Activity LED */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED3_TYPE_ACTIVITY UINT32_C(0x1)
+	/* Invalid */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED3_TYPE_INVALID  UINT32_C(0xff)
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED3_TYPE_LAST	HWRM_PORT_LED_QCFG_OUTPUT_LED3_TYPE_INVALID
+	/* The current state of the LED #3. */
+	uint8_t	led3_state;
+	/* Default state of the LED */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED3_STATE_DEFAULT  UINT32_C(0x0)
+	/* Off */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED3_STATE_OFF	UINT32_C(0x1)
+	/* On */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED3_STATE_ON	UINT32_C(0x2)
+	/* Blink */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED3_STATE_BLINK	UINT32_C(0x3)
+	/* Blink Alternately */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED3_STATE_BLINKALT UINT32_C(0x4)
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED3_STATE_LAST	HWRM_PORT_LED_QCFG_OUTPUT_LED3_STATE_BLINKALT
+	/* The color of LED #3. */
+	uint8_t	led3_color;
+	/* Default */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED3_COLOR_DEFAULT	UINT32_C(0x0)
+	/* Amber */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED3_COLOR_AMBER	UINT32_C(0x1)
+	/* Green */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED3_COLOR_GREEN	UINT32_C(0x2)
+	/* Green or Amber */
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED3_COLOR_GREENAMBER UINT32_C(0x3)
+	#define HWRM_PORT_LED_QCFG_OUTPUT_LED3_COLOR_LAST	HWRM_PORT_LED_QCFG_OUTPUT_LED3_COLOR_GREENAMBER
+	uint8_t	unused_3;
+	/*
+	 * If the LED #3 state is "blink" or "blinkalt", then
+	 * this field represents the requested time in milliseconds
+	 * to keep LED on between cycles.
+	 */
+	uint16_t	led3_blink_on;
+	/*
+	 * If the LED #3 state is "blink" or "blinkalt", then
+	 * this field represents the requested time in milliseconds
+	 * to keep LED off between cycles.
+	 */
+	uint16_t	led3_blink_off;
+	/*
+	 * An identifier for the group of LEDs that LED #3 belongs
+	 * to.
+	 * If set to 0, then the LED #3 is not grouped.
+	 * For all other non-zero values of this field, LED #3 is
+	 * grouped together with the LEDs with the same group ID
+	 * value.
+	 */
+	uint8_t	led3_group_id;
+	uint8_t	unused_4[6];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_port_led_qcfg_output_t, *phwrm_port_led_qcfg_output_t;
+
+/***********************
+ * hwrm_port_led_qcaps *
+ ***********************/
+
+
+/* hwrm_port_led_qcaps_input (size:192b/24B) */
+
+typedef struct hwrm_port_led_qcaps_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Port ID of port whose LED configuration is being queried. */
+	uint16_t	port_id;
+	uint8_t	unused_0[6];
+} hwrm_port_led_qcaps_input_t, *phwrm_port_led_qcaps_input_t;
+
+/* hwrm_port_led_qcaps_output (size:384b/48B) */
+
+typedef struct hwrm_port_led_qcaps_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/*
+	 * The number of LEDs that are configured on this port.
+	 * Up to 4 LEDs can be returned in the response.
+	 */
+	uint8_t	num_leds;
+	/* Reserved for future use. */
+	uint8_t	unused[3];
+	/* An identifier for the LED #0. */
+	uint8_t	led0_id;
+	/* The type of LED #0. */
+	uint8_t	led0_type;
+	/* Speed LED */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED0_TYPE_SPEED	UINT32_C(0x0)
+	/* Activity LED */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED0_TYPE_ACTIVITY UINT32_C(0x1)
+	/* Invalid */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED0_TYPE_INVALID  UINT32_C(0xff)
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED0_TYPE_LAST	HWRM_PORT_LED_QCAPS_OUTPUT_LED0_TYPE_INVALID
+	/*
+	 * An identifier for the group of LEDs that LED #0 belongs
+	 * to.
+	 * If set to 0, then the LED #0 cannot be grouped.
+	 * For all other non-zero values of this field, LED #0 is
+	 * grouped together with the LEDs with the same group ID
+	 * value.
+	 */
+	uint8_t	led0_group_id;
+	uint8_t	unused_0;
+	/* The states supported by LED #0. */
+	uint16_t	led0_state_caps;
+	/*
+	 * If set to 1, this LED is enabled.
+	 * If set to 0, this LED is disabled.
+	 */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED0_STATE_CAPS_ENABLED		UINT32_C(0x1)
+	/*
+	 * If set to 1, off state is supported on this LED.
+	 * If set to 0, off state is not supported on this LED.
+	 */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED0_STATE_CAPS_OFF_SUPPORTED	UINT32_C(0x2)
+	/*
+	 * If set to 1, on state is supported on this LED.
+	 * If set to 0, on state is not supported on this LED.
+	 */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED0_STATE_CAPS_ON_SUPPORTED		UINT32_C(0x4)
+	/*
+	 * If set to 1, blink state is supported on this LED.
+	 * If set to 0, blink state is not supported on this LED.
+	 */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED0_STATE_CAPS_BLINK_SUPPORTED	UINT32_C(0x8)
+	/*
+	 * If set to 1, blink_alt state is supported on this LED.
+	 * If set to 0, blink_alt state is not supported on this LED.
+	 */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED0_STATE_CAPS_BLINK_ALT_SUPPORTED	UINT32_C(0x10)
+	/* The colors supported by LED #0. */
+	uint16_t	led0_color_caps;
+	/* reserved. */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED0_COLOR_CAPS_RSVD		UINT32_C(0x1)
+	/*
+	 * If set to 1, Amber color is supported on this LED.
+	 * If set to 0, Amber color is not supported on this LED.
+	 */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED0_COLOR_CAPS_AMBER_SUPPORTED	UINT32_C(0x2)
+	/*
+	 * If set to 1, Green color is supported on this LED.
+	 * If set to 0, Green color is not supported on this LED.
+	 */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED0_COLOR_CAPS_GREEN_SUPPORTED	UINT32_C(0x4)
+	/* An identifier for the LED #1. */
+	uint8_t	led1_id;
+	/* The type of LED #1. */
+	uint8_t	led1_type;
+	/* Speed LED */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED1_TYPE_SPEED	UINT32_C(0x0)
+	/* Activity LED */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED1_TYPE_ACTIVITY UINT32_C(0x1)
+	/* Invalid */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED1_TYPE_INVALID  UINT32_C(0xff)
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED1_TYPE_LAST	HWRM_PORT_LED_QCAPS_OUTPUT_LED1_TYPE_INVALID
+	/*
+	 * An identifier for the group of LEDs that LED #1 belongs
+	 * to.
+	 * If set to 0, then the LED #0 cannot be grouped.
+	 * For all other non-zero values of this field, LED #0 is
+	 * grouped together with the LEDs with the same group ID
+	 * value.
+	 */
+	uint8_t	led1_group_id;
+	uint8_t	unused_1;
+	/* The states supported by LED #1. */
+	uint16_t	led1_state_caps;
+	/*
+	 * If set to 1, this LED is enabled.
+	 * If set to 0, this LED is disabled.
+	 */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED1_STATE_CAPS_ENABLED		UINT32_C(0x1)
+	/*
+	 * If set to 1, off state is supported on this LED.
+	 * If set to 0, off state is not supported on this LED.
+	 */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED1_STATE_CAPS_OFF_SUPPORTED	UINT32_C(0x2)
+	/*
+	 * If set to 1, on state is supported on this LED.
+	 * If set to 0, on state is not supported on this LED.
+	 */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED1_STATE_CAPS_ON_SUPPORTED		UINT32_C(0x4)
+	/*
+	 * If set to 1, blink state is supported on this LED.
+	 * If set to 0, blink state is not supported on this LED.
+	 */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED1_STATE_CAPS_BLINK_SUPPORTED	UINT32_C(0x8)
+	/*
+	 * If set to 1, blink_alt state is supported on this LED.
+	 * If set to 0, blink_alt state is not supported on this LED.
+	 */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED1_STATE_CAPS_BLINK_ALT_SUPPORTED	UINT32_C(0x10)
+	/* The colors supported by LED #1. */
+	uint16_t	led1_color_caps;
+	/* reserved. */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED1_COLOR_CAPS_RSVD		UINT32_C(0x1)
+	/*
+	 * If set to 1, Amber color is supported on this LED.
+	 * If set to 0, Amber color is not supported on this LED.
+	 */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED1_COLOR_CAPS_AMBER_SUPPORTED	UINT32_C(0x2)
+	/*
+	 * If set to 1, Green color is supported on this LED.
+	 * If set to 0, Green color is not supported on this LED.
+	 */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED1_COLOR_CAPS_GREEN_SUPPORTED	UINT32_C(0x4)
+	/* An identifier for the LED #2. */
+	uint8_t	led2_id;
+	/* The type of LED #2. */
+	uint8_t	led2_type;
+	/* Speed LED */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED2_TYPE_SPEED	UINT32_C(0x0)
+	/* Activity LED */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED2_TYPE_ACTIVITY UINT32_C(0x1)
+	/* Invalid */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED2_TYPE_INVALID  UINT32_C(0xff)
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED2_TYPE_LAST	HWRM_PORT_LED_QCAPS_OUTPUT_LED2_TYPE_INVALID
+	/*
+	 * An identifier for the group of LEDs that LED #0 belongs
+	 * to.
+	 * If set to 0, then the LED #0 cannot be grouped.
+	 * For all other non-zero values of this field, LED #0 is
+	 * grouped together with the LEDs with the same group ID
+	 * value.
+	 */
+	uint8_t	led2_group_id;
+	uint8_t	unused_2;
+	/* The states supported by LED #2. */
+	uint16_t	led2_state_caps;
+	/*
+	 * If set to 1, this LED is enabled.
+	 * If set to 0, this LED is disabled.
+	 */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED2_STATE_CAPS_ENABLED		UINT32_C(0x1)
+	/*
+	 * If set to 1, off state is supported on this LED.
+	 * If set to 0, off state is not supported on this LED.
+	 */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED2_STATE_CAPS_OFF_SUPPORTED	UINT32_C(0x2)
+	/*
+	 * If set to 1, on state is supported on this LED.
+	 * If set to 0, on state is not supported on this LED.
+	 */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED2_STATE_CAPS_ON_SUPPORTED		UINT32_C(0x4)
+	/*
+	 * If set to 1, blink state is supported on this LED.
+	 * If set to 0, blink state is not supported on this LED.
+	 */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED2_STATE_CAPS_BLINK_SUPPORTED	UINT32_C(0x8)
+	/*
+	 * If set to 1, blink_alt state is supported on this LED.
+	 * If set to 0, blink_alt state is not supported on this LED.
+	 */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED2_STATE_CAPS_BLINK_ALT_SUPPORTED	UINT32_C(0x10)
+	/* The colors supported by LED #2. */
+	uint16_t	led2_color_caps;
+	/* reserved. */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED2_COLOR_CAPS_RSVD		UINT32_C(0x1)
+	/*
+	 * If set to 1, Amber color is supported on this LED.
+	 * If set to 0, Amber color is not supported on this LED.
+	 */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED2_COLOR_CAPS_AMBER_SUPPORTED	UINT32_C(0x2)
+	/*
+	 * If set to 1, Green color is supported on this LED.
+	 * If set to 0, Green color is not supported on this LED.
+	 */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED2_COLOR_CAPS_GREEN_SUPPORTED	UINT32_C(0x4)
+	/* An identifier for the LED #3. */
+	uint8_t	led3_id;
+	/* The type of LED #3. */
+	uint8_t	led3_type;
+	/* Speed LED */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED3_TYPE_SPEED	UINT32_C(0x0)
+	/* Activity LED */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED3_TYPE_ACTIVITY UINT32_C(0x1)
+	/* Invalid */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED3_TYPE_INVALID  UINT32_C(0xff)
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED3_TYPE_LAST	HWRM_PORT_LED_QCAPS_OUTPUT_LED3_TYPE_INVALID
+	/*
+	 * An identifier for the group of LEDs that LED #3 belongs
+	 * to.
+	 * If set to 0, then the LED #0 cannot be grouped.
+	 * For all other non-zero values of this field, LED #0 is
+	 * grouped together with the LEDs with the same group ID
+	 * value.
+	 */
+	uint8_t	led3_group_id;
+	uint8_t	unused_3;
+	/* The states supported by LED #3. */
+	uint16_t	led3_state_caps;
+	/*
+	 * If set to 1, this LED is enabled.
+	 * If set to 0, this LED is disabled.
+	 */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED3_STATE_CAPS_ENABLED		UINT32_C(0x1)
+	/*
+	 * If set to 1, off state is supported on this LED.
+	 * If set to 0, off state is not supported on this LED.
+	 */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED3_STATE_CAPS_OFF_SUPPORTED	UINT32_C(0x2)
+	/*
+	 * If set to 1, on state is supported on this LED.
+	 * If set to 0, on state is not supported on this LED.
+	 */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED3_STATE_CAPS_ON_SUPPORTED		UINT32_C(0x4)
+	/*
+	 * If set to 1, blink state is supported on this LED.
+	 * If set to 0, blink state is not supported on this LED.
+	 */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED3_STATE_CAPS_BLINK_SUPPORTED	UINT32_C(0x8)
+	/*
+	 * If set to 1, blink_alt state is supported on this LED.
+	 * If set to 0, blink_alt state is not supported on this LED.
+	 */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED3_STATE_CAPS_BLINK_ALT_SUPPORTED	UINT32_C(0x10)
+	/* The colors supported by LED #3. */
+	uint16_t	led3_color_caps;
+	/* reserved. */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED3_COLOR_CAPS_RSVD		UINT32_C(0x1)
+	/*
+	 * If set to 1, Amber color is supported on this LED.
+	 * If set to 0, Amber color is not supported on this LED.
+	 */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED3_COLOR_CAPS_AMBER_SUPPORTED	UINT32_C(0x2)
+	/*
+	 * If set to 1, Green color is supported on this LED.
+	 * If set to 0, Green color is not supported on this LED.
+	 */
+	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED3_COLOR_CAPS_GREEN_SUPPORTED	UINT32_C(0x4)
+	uint8_t	unused_4[3];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_port_led_qcaps_output_t, *phwrm_port_led_qcaps_output_t;
+
+/***********************
+ * hwrm_port_prbs_test *
+ ***********************/
+
+
+/* hwrm_port_prbs_test_input (size:384b/48B) */
+
+typedef struct hwrm_port_prbs_test_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Host address data is to DMA'd to. */
+	uint64_t	resp_data_addr;
+	/*
+	 * Size of the buffer pointed to by resp_data_addr. The firmware may
+	 * use this entire buffer or less than the entire buffer, but never
+	 * more.
+	 */
+	uint16_t	data_len;
+	uint16_t	flags;
+	/*
+	 * If set, the port_id field should be interpreted as an internal
+	 * port. The internal port id range is returned in port_phy_qcaps
+	 * response internal_port_cnt field.
+	 */
+	#define HWRM_PORT_PRBS_TEST_INPUT_FLAGS_INTERNAL	UINT32_C(0x1)
+	uint32_t	unused_1;
+	/* Port ID of port where PRBS test to be run. */
+	uint16_t	port_id;
+	/* Polynomial selection for PRBS test. */
+	uint16_t	poly;
+	/* PRBS7 */
+	#define HWRM_PORT_PRBS_TEST_INPUT_POLY_PRBS7   UINT32_C(0x0)
+	/* PRBS9 */
+	#define HWRM_PORT_PRBS_TEST_INPUT_POLY_PRBS9   UINT32_C(0x1)
+	/* PRBS11 */
+	#define HWRM_PORT_PRBS_TEST_INPUT_POLY_PRBS11  UINT32_C(0x2)
+	/* PRBS15 */
+	#define HWRM_PORT_PRBS_TEST_INPUT_POLY_PRBS15  UINT32_C(0x3)
+	/* PRBS23 */
+	#define HWRM_PORT_PRBS_TEST_INPUT_POLY_PRBS23  UINT32_C(0x4)
+	/* PRBS31 */
+	#define HWRM_PORT_PRBS_TEST_INPUT_POLY_PRBS31  UINT32_C(0x5)
+	/* PRBS58 */
+	#define HWRM_PORT_PRBS_TEST_INPUT_POLY_PRBS58  UINT32_C(0x6)
+	/* PRBS49 */
+	#define HWRM_PORT_PRBS_TEST_INPUT_POLY_PRBS49  UINT32_C(0x7)
+	/* PRBS10 */
+	#define HWRM_PORT_PRBS_TEST_INPUT_POLY_PRBS10  UINT32_C(0x8)
+	/* PRBS20 */
+	#define HWRM_PORT_PRBS_TEST_INPUT_POLY_PRBS20  UINT32_C(0x9)
+	/* PRBS13 */
+	#define HWRM_PORT_PRBS_TEST_INPUT_POLY_PRBS13  UINT32_C(0xa)
+	/* Invalid */
+	#define HWRM_PORT_PRBS_TEST_INPUT_POLY_INVALID UINT32_C(0xff)
+	#define HWRM_PORT_PRBS_TEST_INPUT_POLY_LAST   HWRM_PORT_PRBS_TEST_INPUT_POLY_INVALID
+	/*
+	 * Configuration bits for PRBS test.
+	 * Use enable bit to start/stop test.
+	 * Use tx/rx lane map bits to run test on specific lanes,
+	 * if set to 0 test will be run on all lanes.
+	 */
+	uint16_t	prbs_config;
+	/*
+	 * Set 0 to stop test currently in progress
+	 * Set 1 to start test with configuration provided.
+	 */
+	#define HWRM_PORT_PRBS_TEST_INPUT_PRBS_CONFIG_START_STOP		UINT32_C(0x1)
+	/*
+	 * If set to 1, tx_lane_map bitmap should have lane bits set.
+	 * If set to 0, test will be run on all lanes for this port.
+	 */
+	#define HWRM_PORT_PRBS_TEST_INPUT_PRBS_CONFIG_TX_LANE_MAP_VALID	UINT32_C(0x2)
+	/*
+	 * If set to 1, rx_lane_map bitmap should have lane bits set.
+	 * If set to 0, test will be run on all lanes for this port.
+	 */
+	#define HWRM_PORT_PRBS_TEST_INPUT_PRBS_CONFIG_RX_LANE_MAP_VALID	UINT32_C(0x4)
+	/* If set to 1, FEC stat t-code 0-7 registers are enabled. */
+	#define HWRM_PORT_PRBS_TEST_INPUT_PRBS_CONFIG_FEC_STAT_T0_T7	UINT32_C(0x8)
+	/*
+	 * If set to 1, FEC stat t-code 8-15 registers are enabled.
+	 * If fec_stat_t0_t7 is set, fec_stat_t8_t15 field will be ignored.
+	 */
+	#define HWRM_PORT_PRBS_TEST_INPUT_PRBS_CONFIG_FEC_STAT_T8_T15	UINT32_C(0x10)
+	/* Duration in seconds to run the PRBS test. */
+	uint16_t	timeout;
+	/*
+	 * If tx_lane_map_valid is set to 1, this field is a bitmap
+	 * of tx lanes to run PRBS test. bit0 = lane0,
+	 * bit1 = lane1 ..bit31 = lane31
+	 */
+	uint32_t	tx_lane_map;
+	/*
+	 * If rx_lane_map_valid is set to 1, this field is a bitmap
+	 * of rx lanes to run PRBS test. bit0 = lane0,
+	 * bit1 = lane1 ..bit31 = lane31
+	 */
+	uint32_t	rx_lane_map;
+} hwrm_port_prbs_test_input_t, *phwrm_port_prbs_test_input_t;
+
+/* hwrm_port_prbs_test_output (size:128b/16B) */
+
+typedef struct hwrm_port_prbs_test_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Total length of stored data. */
+	uint16_t	total_data_len;
+	/* This field is used in Output records to indicate the output format */
+	uint8_t	ber_format;
+	/* BER_FORMAT_PRBS */
+	#define HWRM_PORT_PRBS_TEST_OUTPUT_BER_FORMAT_PRBS UINT32_C(0x0)
+	/* BER_FORMAT_FEC */
+	#define HWRM_PORT_PRBS_TEST_OUTPUT_BER_FORMAT_FEC  UINT32_C(0x1)
+	#define HWRM_PORT_PRBS_TEST_OUTPUT_BER_FORMAT_LAST HWRM_PORT_PRBS_TEST_OUTPUT_BER_FORMAT_FEC
+	uint8_t	unused_0;
+	uint8_t	unused_1[3];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_port_prbs_test_output_t, *phwrm_port_prbs_test_output_t;
+
+/**********************
+ * hwrm_port_dsc_dump *
+ **********************/
+
+
+/* hwrm_port_dsc_dump_input (size:320b/40B) */
+
+typedef struct hwrm_port_dsc_dump_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Host address where response diagnostic data is returned. */
+	uint64_t	resp_data_addr;
+	/*
+	 * Size of the host buffer pointed to by resp_data_addr. The firmware
+	 * may use this entire buffer or less than the entire buffer, but
+	 * never more.
+	 */
+	uint16_t	data_len;
+	uint16_t	unused_0;
+	/*
+	 * Ignored by the start command.
+	 * In legacy buffer mode, this is ignored. The transfer starts
+	 * at buffer offset zero and must be transferred in one command.
+	 * In big buffer mode, this is the offset into the NIC buffer for
+	 * the current retrieve command to start.
+	 */
+	uint32_t	data_offset;
+	/* Port ID of port where dsc dump to be collected. */
+	uint16_t	port_id;
+	/* Diag level specified by the user */
+	uint16_t	diag_level;
+	/* SRDS_DIAG_LANE */
+	#define HWRM_PORT_DSC_DUMP_INPUT_DIAG_LEVEL_SRDS_DIAG_LANE	UINT32_C(0x0)
+	/* SRDS_DIAG_CORE */
+	#define HWRM_PORT_DSC_DUMP_INPUT_DIAG_LEVEL_SRDS_DIAG_CORE	UINT32_C(0x1)
+	/* SRDS_DIAG_EVENT */
+	#define HWRM_PORT_DSC_DUMP_INPUT_DIAG_LEVEL_SRDS_DIAG_EVENT	UINT32_C(0x2)
+	/* SRDS_DIAG_EYE */
+	#define HWRM_PORT_DSC_DUMP_INPUT_DIAG_LEVEL_SRDS_DIAG_EYE	UINT32_C(0x3)
+	/* SRDS_DIAG_REG_CORE */
+	#define HWRM_PORT_DSC_DUMP_INPUT_DIAG_LEVEL_SRDS_DIAG_REG_CORE   UINT32_C(0x4)
+	/* SRDS_DIAG_REG_LANE */
+	#define HWRM_PORT_DSC_DUMP_INPUT_DIAG_LEVEL_SRDS_DIAG_REG_LANE   UINT32_C(0x5)
+	/* SRDS_DIAG_UC_CORE */
+	#define HWRM_PORT_DSC_DUMP_INPUT_DIAG_LEVEL_SRDS_DIAG_UC_CORE	UINT32_C(0x6)
+	/* SRDS_DIAG_UC_LANE */
+	#define HWRM_PORT_DSC_DUMP_INPUT_DIAG_LEVEL_SRDS_DIAG_UC_LANE	UINT32_C(0x7)
+	/* SRDS_DIAG_LANE_DEBUG */
+	#define HWRM_PORT_DSC_DUMP_INPUT_DIAG_LEVEL_SRDS_DIAG_LANE_DEBUG UINT32_C(0x8)
+	/* SRDS_DIAG_BER_VERT */
+	#define HWRM_PORT_DSC_DUMP_INPUT_DIAG_LEVEL_SRDS_DIAG_BER_VERT   UINT32_C(0x9)
+	/* SRDS_DIAG_BER_HORZ */
+	#define HWRM_PORT_DSC_DUMP_INPUT_DIAG_LEVEL_SRDS_DIAG_BER_HORZ   UINT32_C(0xa)
+	/* SRDS_DIAG_EVENT_SAFE */
+	#define HWRM_PORT_DSC_DUMP_INPUT_DIAG_LEVEL_SRDS_DIAG_EVENT_SAFE UINT32_C(0xb)
+	/* SRDS_DIAG_TIMESTAMP */
+	#define HWRM_PORT_DSC_DUMP_INPUT_DIAG_LEVEL_SRDS_DIAG_TIMESTAMP  UINT32_C(0xc)
+	#define HWRM_PORT_DSC_DUMP_INPUT_DIAG_LEVEL_LAST		HWRM_PORT_DSC_DUMP_INPUT_DIAG_LEVEL_SRDS_DIAG_TIMESTAMP
+	/*
+	 * This field is the lane number on which to collect the dsc dump.
+	 * If this is 0xFFFF, the dsc dump will be collected for all lanes,
+	 * if the hardware and firmware support this feature.
+	 */
+	uint16_t	lane_number;
+	/* Configuration bits. */
+	uint16_t	dsc_dump_config;
+	/*
+	 * Set 0 to retrieve the dsc dump
+	 * Set 1 to start the dsc dump
+	 * Some configuration parameter for the dscdump report are
+	 * set by the start request, and can not be modified until the
+	 * retrieve operation is complete, on the next start.
+	 */
+	#define HWRM_PORT_DSC_DUMP_INPUT_DSC_DUMP_CONFIG_START_RETRIEVE	UINT32_C(0x1)
+	/*
+	 * Set 0 to limit the report size to 65535 bytes.
+	 * Set 1 to allow a larger buffer size.
+	 * This can only be set 1 in the start operation.
+	 * If this is set 0 in the start operation, the firmware will
+	 * assume it needs to only expose up to 65535 bytes of the report,
+	 * and only allow a single retrieve operation to retrieve the
+	 * entire report. This mode will truncate longer reports.
+	 * If this is set 1 in the start operation, the firmware will
+	 * report the full size of the report (up to the firmware's limit),
+	 * permit retrieve operations to hold the buffer using the config
+	 * defer_close, and honour the data_offset value so later data
+	 * in the report can be retrieved.
+	 */
+	#define HWRM_PORT_DSC_DUMP_INPUT_DSC_DUMP_CONFIG_BIG_BUFFER	UINT32_C(0x2)
+	/*
+	 * Set 0 on the last 'retrieve' to release the firmware buffer
+	 * Set 1 on the other 'retrieve' to hold the firmware buffer
+	 * This only affects retrieve operations.
+	 * In big_buffer mode, this allows the driver or tool to tell
+	 * the firmware to keep the report around, as it intends to read
+	 * more of it in. The final read must set this to zero, to tell
+	 * the firmware the report buffer can be released.
+	 * This only works if the start request specified big_buffer as
+	 * one; it is ignored otherwise.
+	 */
+	#define HWRM_PORT_DSC_DUMP_INPUT_DSC_DUMP_CONFIG_DEFER_CLOSE	UINT32_C(0x4)
+} hwrm_port_dsc_dump_input_t, *phwrm_port_dsc_dump_input_t;
+
+/* hwrm_port_dsc_dump_output (size:128b/16B) */
+
+typedef struct hwrm_port_dsc_dump_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/*
+	 * Total length of stored data; if big_buffer is one, this
+	 * only contains the lower 16 bits of the total length.
+	 * In legacy buffer mode, this is zero in the 'start' response.
+	 * In big buffer mode, this has the size of the report even
+	 * in the 'start' response.
+	 * In both modes, this contains the number of bytes written
+	 * to the host in 'retrieve' responses.
+	 */
+	uint16_t	total_data_len;
+	/*
+	 * The upper 16 bits of the total length of stored data.
+	 * In legacy buffer mode, this will always be zero.
+	 * In big buffer mode, this will be populated even in the
+	 * 'start' response.
+	 * This is always zero for 'retrieve' responses.
+	 */
+	uint16_t	total_data_len_high;
+	uint8_t	unused_1[2];
+	/* Result information bits. */
+	uint8_t	flags;
+	/*
+	 * Set according to the start request's input big_buffer.
+	 * If this is zero, it indicates the function is acting per
+	 * legacy behaviour -- it will report a buffer size up to almost
+	 * 64KiB, and allow only one retrieval request before releasing
+	 * the firmware buffer containing the report (total_data_len_high
+	 * will be zero). The request's data_offset field and defer_close
+	 * and use_offset config flags are ignored.
+	 * If this is one, it indicates support for (and request of)
+	 * support for larger reports. The full 32b report size (up to the
+	 * firmware buffer limit) is provided by the start response in
+	 * total_data_len (low 16b) and total_data_len_high (high 16b),
+	 * and retrieve requests may keep the buffer using the defer_close
+	 * flag, and retrieve the later parts of the report using the
+	 * data_offset field.
+	 */
+	#define HWRM_PORT_DSC_DUMP_OUTPUT_FLAGS_BIG_BUFFER	UINT32_C(0x1)
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_port_dsc_dump_output_t, *phwrm_port_dsc_dump_output_t;
+
+/******************************
+ * hwrm_port_sfp_sideband_cfg *
+ ******************************/
+
+
+/* hwrm_port_sfp_sideband_cfg_input (size:256b/32B) */
+
+typedef struct hwrm_port_sfp_sideband_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Port ID of port that is to be queried. */
+	uint16_t	port_id;
+	uint8_t	unused_0[6];
+	/*
+	 * This bitfield is used to specify which bits from the 'flags'
+	 * fields are being configured by the caller.
+	 */
+	uint32_t	enables;
+	/* This bit must be '1' for rs0 to be configured. */
+	#define HWRM_PORT_SFP_SIDEBAND_CFG_INPUT_ENABLES_RS0	UINT32_C(0x1)
+	/* This bit must be '1' for rs1 to be configured. */
+	#define HWRM_PORT_SFP_SIDEBAND_CFG_INPUT_ENABLES_RS1	UINT32_C(0x2)
+	/* This bit must be '1' for tx_disable to be configured. */
+	#define HWRM_PORT_SFP_SIDEBAND_CFG_INPUT_ENABLES_TX_DIS	UINT32_C(0x4)
+	/*
+	 * This bit must be '1' for mod_sel to be configured.
+	 * Valid only on QSFP modules
+	 */
+	#define HWRM_PORT_SFP_SIDEBAND_CFG_INPUT_ENABLES_MOD_SEL	UINT32_C(0x8)
+	/* This bit must be '1' for reset_l to be configured. */
+	#define HWRM_PORT_SFP_SIDEBAND_CFG_INPUT_ENABLES_RESET_L	UINT32_C(0x10)
+	/* This bit must be '1' for lp_mode to be configured. */
+	#define HWRM_PORT_SFP_SIDEBAND_CFG_INPUT_ENABLES_LP_MODE	UINT32_C(0x20)
+	/* This bit must be '1' for pwr_disable to be configured. */
+	#define HWRM_PORT_SFP_SIDEBAND_CFG_INPUT_ENABLES_PWR_DIS	UINT32_C(0x40)
+	/*
+	 * Only bits that have corresponding bits in the 'enables'
+	 * bitfield are processed by the firmware, all other bits
+	 * of 'flags' are ignored.
+	 */
+	uint32_t	flags;
+	/*
+	 * This bit along with rs1 configures the current speed of the dual
+	 * rate module. If these pins are GNDed then the speed can be changed
+	 * by directly writing to EEPROM.
+	 */
+	#define HWRM_PORT_SFP_SIDEBAND_CFG_INPUT_FLAGS_RS0	UINT32_C(0x1)
+	/*
+	 * This bit along with rs0 configures the current speed of the dual
+	 * rate module. If these pins are GNDed then the speed can be changed
+	 * by directly writing to EEPROM.
+	 */
+	#define HWRM_PORT_SFP_SIDEBAND_CFG_INPUT_FLAGS_RS1	UINT32_C(0x2)
+	/*
+	 * When this bit is set to '1', tx_disable is set.
+	 * On a 1G BASE-T module, if this bit is set,
+	 * module PHY registers will not be accessible.
+	 */
+	#define HWRM_PORT_SFP_SIDEBAND_CFG_INPUT_FLAGS_TX_DIS	UINT32_C(0x4)
+	/*
+	 * When this bit is set to '1', this module is selected.
+	 * Valid only on QSFP modules
+	 */
+	#define HWRM_PORT_SFP_SIDEBAND_CFG_INPUT_FLAGS_MOD_SEL	UINT32_C(0x8)
+	/*
+	 * If reset_l is set to 0, Module will be taken out of reset
+	 * and other signals will be set to their requested state once
+	 * the module is out of reset.
+	 * Valid only on QSFP modules
+	 */
+	#define HWRM_PORT_SFP_SIDEBAND_CFG_INPUT_FLAGS_RESET_L	UINT32_C(0x10)
+	/*
+	 * When this bit is set to '1', the module will be configured
+	 * in low power mode.
+	 * Valid only on QSFP modules
+	 */
+	#define HWRM_PORT_SFP_SIDEBAND_CFG_INPUT_FLAGS_LP_MODE	UINT32_C(0x20)
+	/* When this bit is set to '1', the module will be powered down. */
+	#define HWRM_PORT_SFP_SIDEBAND_CFG_INPUT_FLAGS_PWR_DIS	UINT32_C(0x40)
+} hwrm_port_sfp_sideband_cfg_input_t, *phwrm_port_sfp_sideband_cfg_input_t;
+
+/* hwrm_port_sfp_sideband_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_port_sfp_sideband_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_port_sfp_sideband_cfg_output_t, *phwrm_port_sfp_sideband_cfg_output_t;
+
+/*******************************
+ * hwrm_port_sfp_sideband_qcfg *
+ *******************************/
+
+
+/* hwrm_port_sfp_sideband_qcfg_input (size:192b/24B) */
+
+typedef struct hwrm_port_sfp_sideband_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Port ID of port that is to be queried. */
+	uint16_t	port_id;
+	uint8_t	unused_0[6];
+} hwrm_port_sfp_sideband_qcfg_input_t, *phwrm_port_sfp_sideband_qcfg_input_t;
+
+/* hwrm_port_sfp_sideband_qcfg_output (size:192b/24B) */
+
+typedef struct hwrm_port_sfp_sideband_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/*
+	 * Bitmask indicating which sideband signals are valid.
+	 * This is based on the board and nvm cfg that is present on the board.
+	 */
+	uint32_t	supported_mask;
+	uint32_t	sideband_signals;
+	/* When this bit is set to '1', the Module is absent. */
+	#define HWRM_PORT_SFP_SIDEBAND_QCFG_OUTPUT_SIDEBAND_SIGNALS_MOD_ABS	UINT32_C(0x1)
+	/*
+	 * When this bit is set to '1', there is no valid signal on RX.
+	 * This signal is a filtered version of Signal Detect.
+	 */
+	#define HWRM_PORT_SFP_SIDEBAND_QCFG_OUTPUT_SIDEBAND_SIGNALS_RX_LOS	UINT32_C(0x2)
+	/*
+	 * This bit along with rs1 indicates the current speed of the dual
+	 * rate module.If these pins are grounded then the speed can be
+	 * changed by directly writing to EEPROM.
+	 */
+	#define HWRM_PORT_SFP_SIDEBAND_QCFG_OUTPUT_SIDEBAND_SIGNALS_RS0	UINT32_C(0x4)
+	/*
+	 * This bit along with rs0 indicates the current speed of the dual
+	 * rate module.If these pins are grounded then the speed can be
+	 * changed by directly writing to EEPROM.
+	 */
+	#define HWRM_PORT_SFP_SIDEBAND_QCFG_OUTPUT_SIDEBAND_SIGNALS_RS1	UINT32_C(0x8)
+	/*
+	 * When this bit is set to '1', tx_disable is set.
+	 * On a 1G BASE-T module, if this bit is set, module PHY
+	 * registers will not be accessible.
+	 */
+	#define HWRM_PORT_SFP_SIDEBAND_QCFG_OUTPUT_SIDEBAND_SIGNALS_TX_DIS	UINT32_C(0x10)
+	/* When this bit is set to '1', tx_fault is set. */
+	#define HWRM_PORT_SFP_SIDEBAND_QCFG_OUTPUT_SIDEBAND_SIGNALS_TX_FAULT	UINT32_C(0x20)
+	/*
+	 * When this bit is set to '1', module is selected.
+	 * Valid only on QSFP modules
+	 */
+	#define HWRM_PORT_SFP_SIDEBAND_QCFG_OUTPUT_SIDEBAND_SIGNALS_MOD_SEL	UINT32_C(0x40)
+	/*
+	 * When this bit is set to '0', the module is held in reset.
+	 * if reset_l is set to 1,first module is taken out of reset
+	 * and other signals will be set to their requested state.
+	 * Valid only on QSFP modules.
+	 */
+	#define HWRM_PORT_SFP_SIDEBAND_QCFG_OUTPUT_SIDEBAND_SIGNALS_RESET_L	UINT32_C(0x80)
+	/*
+	 * When this bit is set to '1', the module is in low power mode.
+	 * Valid only on QSFP modules
+	 */
+	#define HWRM_PORT_SFP_SIDEBAND_QCFG_OUTPUT_SIDEBAND_SIGNALS_LP_MODE	UINT32_C(0x100)
+	/* When this bit is set to '1', module is in power down state. */
+	#define HWRM_PORT_SFP_SIDEBAND_QCFG_OUTPUT_SIDEBAND_SIGNALS_PWR_DIS	UINT32_C(0x200)
+	uint8_t	unused[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_port_sfp_sideband_qcfg_output_t, *phwrm_port_sfp_sideband_qcfg_output_t;
+
+/**********************************
+ * hwrm_port_phy_mdio_bus_acquire *
+ **********************************/
+
+
+/* hwrm_port_phy_mdio_bus_acquire_input (size:192b/24B) */
+
+typedef struct hwrm_port_phy_mdio_bus_acquire_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Port ID of the port. */
+	uint16_t	port_id;
+	/*
+	 * client_id of the client requesting BUS access.
+	 * Any value from 0x10 to 0xFFFF can be used.
+	 * Client should make sure that the returned client_id
+	 * in response matches the client_id in request.
+	 * 0-0xF are reserved for internal use.
+	 */
+	uint16_t	client_id;
+	/*
+	 * Timeout in milliseconds, MDIO BUS will be released automatically
+	 * after this time, if another mdio acquire command is not received
+	 * within the timeout window from the same client.
+	 * A 0xFFFF will hold the bus until this bus is released.
+	 */
+	uint16_t	mdio_bus_timeout;
+	uint8_t	unused_0[2];
+} hwrm_port_phy_mdio_bus_acquire_input_t, *phwrm_port_phy_mdio_bus_acquire_input_t;
+
+/* hwrm_port_phy_mdio_bus_acquire_output (size:128b/16B) */
+
+typedef struct hwrm_port_phy_mdio_bus_acquire_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint16_t	unused_0;
+	/*
+	 * client_id of the module holding the BUS.
+	 * 0-0xF are reserved for internal use.
+	 */
+	uint16_t	client_id;
+	uint8_t	unused_1[3];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_port_phy_mdio_bus_acquire_output_t, *phwrm_port_phy_mdio_bus_acquire_output_t;
+
+/**********************************
+ * hwrm_port_phy_mdio_bus_release *
+ **********************************/
+
+
+/* hwrm_port_phy_mdio_bus_release_input (size:192b/24B) */
+
+typedef struct hwrm_port_phy_mdio_bus_release_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Port ID of the port. */
+	uint16_t	port_id;
+	/*
+	 * client_id of the client requesting BUS release.
+	 * A client should not release any other clients BUS.
+	 */
+	uint16_t	client_id;
+	uint8_t	unused_0[4];
+} hwrm_port_phy_mdio_bus_release_input_t, *phwrm_port_phy_mdio_bus_release_input_t;
+
+/* hwrm_port_phy_mdio_bus_release_output (size:128b/16B) */
+
+typedef struct hwrm_port_phy_mdio_bus_release_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint16_t	unused_0;
+	/* The BUS is released if client_id matches the client_id in request. */
+	uint16_t	clients_id;
+	uint8_t	unused_1[3];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_port_phy_mdio_bus_release_output_t, *phwrm_port_phy_mdio_bus_release_output_t;
+
+/************************
+ * hwrm_port_tx_fir_cfg *
+ ************************/
+
+
+/* hwrm_port_tx_fir_cfg_input (size:320b/40B) */
+
+typedef struct hwrm_port_tx_fir_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Modulation types of TX FIR: NRZ, PAM4. */
+	uint8_t	mod_type;
+	/* For NRZ */
+	#define HWRM_PORT_TX_FIR_CFG_INPUT_MOD_TYPE_NRZ	UINT32_C(0x0)
+	/* For PAM4 */
+	#define HWRM_PORT_TX_FIR_CFG_INPUT_MOD_TYPE_PAM4	UINT32_C(0x1)
+	/* For Optical NRZ */
+	#define HWRM_PORT_TX_FIR_CFG_INPUT_MOD_TYPE_C2M_NRZ	UINT32_C(0x2)
+	/* For Optical PAM4 */
+	#define HWRM_PORT_TX_FIR_CFG_INPUT_MOD_TYPE_C2M_PAM4	UINT32_C(0x3)
+	/* For DAC PAM4 112G */
+	#define HWRM_PORT_TX_FIR_CFG_INPUT_MOD_TYPE_PAM4_112	UINT32_C(0x4)
+	/* For Optical PAM4 112G */
+	#define HWRM_PORT_TX_FIR_CFG_INPUT_MOD_TYPE_C2M_PAM4_112G UINT32_C(0x5)
+	/* For LPO PAM4 112G */
+	#define HWRM_PORT_TX_FIR_CFG_INPUT_MOD_TYPE_LPO_PAM4_112G UINT32_C(0x6)
+	#define HWRM_PORT_TX_FIR_CFG_INPUT_MOD_TYPE_LAST	HWRM_PORT_TX_FIR_CFG_INPUT_MOD_TYPE_LPO_PAM4_112G
+	/* The lane mask of the lane TX FIR will be configured. */
+	uint8_t	lane_mask;
+	uint8_t	unused_0[2];
+	/* Value1 of TX FIR, required for NRZ or PAM4. */
+	uint32_t	txfir_val_1;
+	/* Value2 of TX FIR, required for NRZ or PAM4. */
+	uint32_t	txfir_val_2;
+	/* Value3 of TX FIR, required for PAM4. */
+	uint32_t	txfir_val_3;
+	/* Value4 of TX FIR, required for PAM4. */
+	uint32_t	txfir_val_4;
+	uint8_t	unused_1[4];
+} hwrm_port_tx_fir_cfg_input_t, *phwrm_port_tx_fir_cfg_input_t;
+
+/* hwrm_port_tx_fir_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_port_tx_fir_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_port_tx_fir_cfg_output_t, *phwrm_port_tx_fir_cfg_output_t;
+
+/*************************
+ * hwrm_port_tx_fir_qcfg *
+ *************************/
+
+
+/* hwrm_port_tx_fir_qcfg_input (size:192b/24B) */
+
+typedef struct hwrm_port_tx_fir_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Modulation types of TX FIR: NRZ, PAM4. */
+	uint8_t	mod_type;
+	/* For NRZ */
+	#define HWRM_PORT_TX_FIR_QCFG_INPUT_MOD_TYPE_NRZ	UINT32_C(0x0)
+	/* For PAM4 56G */
+	#define HWRM_PORT_TX_FIR_QCFG_INPUT_MOD_TYPE_PAM4	UINT32_C(0x1)
+	/* For Optical NRZ */
+	#define HWRM_PORT_TX_FIR_QCFG_INPUT_MOD_TYPE_C2M_NRZ	UINT32_C(0x2)
+	/* For Optical PAM4 56G */
+	#define HWRM_PORT_TX_FIR_QCFG_INPUT_MOD_TYPE_C2M_PAM4	UINT32_C(0x3)
+	/* For DAC PAM4 112G */
+	#define HWRM_PORT_TX_FIR_QCFG_INPUT_MOD_TYPE_PAM4_112	UINT32_C(0x4)
+	/* For Optical PAM4 112G */
+	#define HWRM_PORT_TX_FIR_QCFG_INPUT_MOD_TYPE_C2M_PAM4_112 UINT32_C(0x5)
+	/* For LPO PAM4 112G */
+	#define HWRM_PORT_TX_FIR_QCFG_INPUT_MOD_TYPE_LPO_PAM4_112 UINT32_C(0x6)
+	#define HWRM_PORT_TX_FIR_QCFG_INPUT_MOD_TYPE_LAST	HWRM_PORT_TX_FIR_QCFG_INPUT_MOD_TYPE_LPO_PAM4_112
+	/* The ID of the lane TX FIR will be queried. */
+	uint8_t	lane_id;
+	uint8_t	unused[6];
+} hwrm_port_tx_fir_qcfg_input_t, *phwrm_port_tx_fir_qcfg_input_t;
+
+/* hwrm_port_tx_fir_qcfg_output (size:256b/32B) */
+
+typedef struct hwrm_port_tx_fir_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Value1 of TX FIR, required for NRZ or PAM4. */
+	uint32_t	txfir_val_1;
+	/* Value2 of TX FIR, required for NRZ or PAM4. */
+	uint32_t	txfir_val_2;
+	/* Value3 of TX FIR, required for PAM4. */
+	uint32_t	txfir_val_3;
+	/* Value4 of TX FIR, required for PAM4. */
+	uint32_t	txfir_val_4;
+	uint8_t	unused[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_port_tx_fir_qcfg_output_t, *phwrm_port_tx_fir_qcfg_output_t;
+
+/***********************
+ * hwrm_port_ep_tx_cfg *
+ ***********************/
+
+
+/* hwrm_port_ep_tx_cfg_input (size:256b/32B) */
+
+typedef struct hwrm_port_ep_tx_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint16_t	enables;
+	/* When this bit is '1', the value in the ep0_min_bw field is valid. */
+	#define HWRM_PORT_EP_TX_CFG_INPUT_ENABLES_EP0_MIN_BW	UINT32_C(0x1)
+	/* When this bit is '1', the value in the ep0_max_bw field is valid. */
+	#define HWRM_PORT_EP_TX_CFG_INPUT_ENABLES_EP0_MAX_BW	UINT32_C(0x2)
+	/* When this bit is '1', the value in the ep1_min_bw field is valid. */
+	#define HWRM_PORT_EP_TX_CFG_INPUT_ENABLES_EP1_MIN_BW	UINT32_C(0x4)
+	/* When this bit is '1', the value in the ep1_max_bw field is valid. */
+	#define HWRM_PORT_EP_TX_CFG_INPUT_ENABLES_EP1_MAX_BW	UINT32_C(0x8)
+	/* When this bit is '1', the value in the ep2_min_bw field is valid. */
+	#define HWRM_PORT_EP_TX_CFG_INPUT_ENABLES_EP2_MIN_BW	UINT32_C(0x10)
+	/* When this bit is '1', the value in the ep2_max_bw field is valid. */
+	#define HWRM_PORT_EP_TX_CFG_INPUT_ENABLES_EP2_MAX_BW	UINT32_C(0x20)
+	/* When this bit is '1', the value in the ep3_min_bw field is valid. */
+	#define HWRM_PORT_EP_TX_CFG_INPUT_ENABLES_EP3_MIN_BW	UINT32_C(0x40)
+	/* When this bit is '1', the value in the ep3_max_bw field is valid. */
+	#define HWRM_PORT_EP_TX_CFG_INPUT_ENABLES_EP3_MAX_BW	UINT32_C(0x80)
+	/* A port index, from 0 to the number of front panel ports, minus 1. */
+	uint8_t	port_id;
+	uint8_t	unused;
+	/*
+	 * Specifies a minimum guaranteed bandwidth, as a percentage of the
+	 * port bandwidth, for the set of PFs and VFs on PCIe endpoint 0 for
+	 * the specified port. The range is 0 to 100. A value of 0 indicates no
+	 * minimum rate. The endpoint's min_bw must be less than or equal to
+	 * max_bw. The sum of all configured minimum bandwidths for a port must
+	 * be less than or equal to 100.
+	 */
+	uint8_t	ep0_min_bw;
+	/*
+	 * Specifies the maximum portion of the port's bandwidth that the set
+	 * of PFs and VFs on PCIe endpoint 0 may use. The value is a percentage
+	 * of the link bandwidth, from 0 to 100. A value of 0 indicates no
+	 * maximum rate.
+	 */
+	uint8_t	ep0_max_bw;
+	/*
+	 * Specifies a minimum guaranteed bandwidth, as a percentage of the
+	 * port bandwidth, for the set of PFs and VFs on PCIe endpoint 1 for
+	 * the specified port. The range is 0 to 100. A value of 0 indicates no
+	 * minimum rate. The endpoint's min_bw must be less than or equal to
+	 * max_bw. The sum of all configured minimum bandwidths for a port must
+	 * be less than or equal to 100.
+	 */
+	uint8_t	ep1_min_bw;
+	/*
+	 * Specifies the maximum portion of the port's bandwidth that the set
+	 * of PFs and VFs on PCIe endpoint 1 may use. The value is a percentage
+	 * of the link bandwidth, from 0 to 100. A value of 0 indicates no
+	 * maximum rate.
+	 */
+	uint8_t	ep1_max_bw;
+	/*
+	 * Specifies a minimum guaranteed bandwidth, as a percentage of the
+	 * port bandwidth, for the set of PFs and VFs on PCIe endpoint 2 for
+	 * the specified port. The range is 0 to 100. A value of 0 indicates no
+	 * minimum rate. The endpoint's min_bw must be less than or equal to
+	 * max_bw. The sum of all configured minimum bandwidths for a port must
+	 * be less than or equal to 100.
+	 */
+	uint8_t	ep2_min_bw;
+	/*
+	 * Specifies the maximum portion of the port's bandwidth that the set
+	 * of PFs and VFs on PCIe endpoint 2 may use. The value is a percentage
+	 * of the link bandwidth, from 0 to 100. A value of 0 indicates no
+	 * maximum rate.
+	 */
+	uint8_t	ep2_max_bw;
+	/*
+	 * Specifies a minimum guaranteed bandwidth, as a percentage of the
+	 * port bandwidth, for the set of PFs and VFs on PCIe endpoint 3 for
+	 * the specified port. The range is 0 to 100. A value of 0 indicates no
+	 * minimum rate. The endpoint's min_bw must be less than or equal to
+	 * max_bw. The sum of all configured minimum bandwidths for a port must
+	 * be less than or equal to 100.
+	 */
+	uint8_t	ep3_min_bw;
+	/*
+	 * Specifies the maximum portion of the port's bandwidth that the set
+	 * of PFs and VFs on PCIe endpoint 3 may use. The value is a percentage
+	 * of the link bandwidth, from 0 to 100. A value of 0 indicates no
+	 * maximum rate.
+	 */
+	uint8_t	ep3_max_bw;
+	uint8_t	unused_1[4];
+} hwrm_port_ep_tx_cfg_input_t, *phwrm_port_ep_tx_cfg_input_t;
+
+/* hwrm_port_ep_tx_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_port_ep_tx_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
+	 */
+	uint8_t	valid;
+} hwrm_port_ep_tx_cfg_output_t, *phwrm_port_ep_tx_cfg_output_t;
+
+/* hwrm_port_ep_tx_cfg_cmd_err (size:64b/8B) */
+
+typedef struct hwrm_port_ep_tx_cfg_cmd_err {
+	/*
+	 * command specific error codes for the cmd_err field in
+	 * hwrm_err_output
+	 */
+	uint8_t	code;
+	/* Unknown error. */
+	#define HWRM_PORT_EP_TX_CFG_CMD_ERR_CODE_UNKNOWN		UINT32_C(0x0)
+	/* The port ID is invalid */
+	#define HWRM_PORT_EP_TX_CFG_CMD_ERR_CODE_PORT_ID_INVALID	UINT32_C(0x1)
+	/* One of the PCIe endpoints configured is not active. */
+	#define HWRM_PORT_EP_TX_CFG_CMD_ERR_CODE_EP_INACTIVE	UINT32_C(0x2)
+	/* A minimum bandwidth is out of range. */
+	#define HWRM_PORT_EP_TX_CFG_CMD_ERR_CODE_MIN_BW_RANGE	UINT32_C(0x3)
+	/*
+	 * One endpoint's minimum bandwidth is more than its maximum
+	 * bandwidth.
+	 */
+	#define HWRM_PORT_EP_TX_CFG_CMD_ERR_CODE_MIN_MORE_THAN_MAX  UINT32_C(0x4)
+	/* The sum of the minimum bandwidths on the port is more than 100%. */
+	#define HWRM_PORT_EP_TX_CFG_CMD_ERR_CODE_MIN_BW_SUM	UINT32_C(0x5)
+	/*
+	 * The NIC does not support enforcement of a minimum guaranteed
+	 * bandwidth for an endpoint.
+	 */
+	#define HWRM_PORT_EP_TX_CFG_CMD_ERR_CODE_MIN_BW_UNSUPPORTED UINT32_C(0x6)
+	#define HWRM_PORT_EP_TX_CFG_CMD_ERR_CODE_LAST		HWRM_PORT_EP_TX_CFG_CMD_ERR_CODE_MIN_BW_UNSUPPORTED
+	uint8_t	unused_0[7];
+} hwrm_port_ep_tx_cfg_cmd_err_t, *phwrm_port_ep_tx_cfg_cmd_err_t;
+
+/************************
+ * hwrm_port_ep_tx_qcfg *
+ ************************/
+
+
+/* hwrm_port_ep_tx_qcfg_input (size:192b/24B) */
+
+typedef struct hwrm_port_ep_tx_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* The port whose endpoint rate limits are queried. */
+	uint8_t	port_id;
+	uint8_t	unused[7];
+} hwrm_port_ep_tx_qcfg_input_t, *phwrm_port_ep_tx_qcfg_input_t;
+
+/* hwrm_port_ep_tx_qcfg_output (size:192b/24B) */
+
+typedef struct hwrm_port_ep_tx_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/*
+	 * Specifies a minimum guaranteed bandwidth, as a percentage of the
+	 * port bandwidth, for the set of PFs and VFs on PCIe endpoint 0 for
+	 * the specified port. The range is 0 to 100. A value of 0 indicates no
+	 * minimum rate. The endpoint's min_bw must be less than or equal to
+	 * max_bw. The sum of all configured minimum bandwidths for a port must
+	 * be less than or equal to 100.
+	 */
+	uint8_t	ep0_min_bw;
+	/*
+	 * Specifies the maximum portion of the port's bandwidth that the set
+	 * of PFs and VFs on PCIe endpoint 0 may use. The value is a percentage
+	 * of the link bandwidth, from 0 to 100. A value of 0 indicates no
+	 * maximum rate.
+	 */
+	uint8_t	ep0_max_bw;
+	/*
+	 * Specifies a minimum guaranteed bandwidth, as a percentage of the
+	 * port bandwidth, for the set of PFs and VFs on PCIe endpoint 1 for
+	 * the specified port. The range is 0 to 100. A value of 0 indicates no
+	 * minimum rate. The endpoint's min_bw must be less than or equal to
+	 * max_bw. The sum of all configured minimum bandwidths for a port must
+	 * be less than or equal to 100.
+	 */
+	uint8_t	ep1_min_bw;
+	/*
+	 * Specifies the maximum portion of the port's bandwidth that the set
+	 * of PFs and VFs on PCIe endpoint 1 may use. The value is a percentage
+	 * of the link bandwidth, from 0 to 100. A value of 0 indicates no
+	 * maximum rate.
+	 */
+	uint8_t	ep1_max_bw;
+	/*
+	 * Specifies a minimum guaranteed bandwidth, as a percentage of the
+	 * port bandwidth, for the set of PFs and VFs on PCIe endpoint 2 for
+	 * the specified port. The range is 0 to 100. A value of 0 indicates no
+	 * minimum rate. The endpoint's min_bw must be less than or equal to
+	 * max_bw. The sum of all configured minimum bandwidths for a port must
+	 * be less than or equal to 100.
+	 */
+	uint8_t	ep2_min_bw;
+	/*
+	 * Specifies the maximum portion of the port's bandwidth that the set
+	 * of PFs and VFs on PCIe endpoint 2 may use. The value is a percentage
+	 * of the link bandwidth, from 0 to 100. A value of 0 indicates no
+	 * maximum rate.
+	 */
+	uint8_t	ep2_max_bw;
+	/*
+	 * Specifies a minimum guaranteed bandwidth, as a percentage of the
+	 * port bandwidth, for the set of PFs and VFs on PCIe endpoint 3 for
+	 * the specified port. The range is 0 to 100. A value of 0 indicates no
+	 * minimum rate. The endpoint's min_bw must be less than or equal to
+	 * max_bw. The sum of all configured minimum bandwidths for a port must
+	 * be less than or equal to 100.
+	 */
+	uint8_t	ep3_min_bw;
+	/*
+	 * Specifies the maximum portion of the port's bandwidth that the set
+	 * of PFs and VFs on PCIe endpoint 3 may use. The value is a percentage
+	 * of the link bandwidth, from 0 to 100. A value of 0 indicates no
+	 * maximum rate.
+	 */
+	uint8_t	ep3_max_bw;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
+	 */
+	uint8_t	valid;
+} hwrm_port_ep_tx_qcfg_output_t, *phwrm_port_ep_tx_qcfg_output_t;
+
+/*****************
+ * hwrm_port_cfg *
+ *****************/
+
+
+/* hwrm_port_cfg_input (size:256b/32B) */
+
+typedef struct hwrm_port_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	flags;
+	uint32_t	enables;
+	/*
+	 * This bit must be '1' for the tx_rate_limit field to
+	 * be configured.
+	 */
+	#define HWRM_PORT_CFG_INPUT_ENABLES_TX_RATE_LIMIT	UINT32_C(0x1)
+	/* Port ID of port that is to be configured. */
+	uint16_t	port_id;
+	uint16_t	unused_0;
+	/*
+	 * Requested setting of TX rate limit in Mbps.
+	 * tx_rate_limit = 0 will cancel the rate limit if any.
+	 * This field is valid only when tx_rate_limit bit in 'enables'
+	 * field is '1'.
+	 */
+	uint32_t	tx_rate_limit;
+} hwrm_port_cfg_input_t, *phwrm_port_cfg_input_t;
+
+/* hwrm_port_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_port_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_port_cfg_output_t, *phwrm_port_cfg_output_t;
+
+/******************
+ * hwrm_port_qcfg *
+ ******************/
+
+
+/* hwrm_port_qcfg_input (size:192b/24B) */
+
+typedef struct hwrm_port_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Port ID of port that is to be queried. */
+	uint16_t	port_id;
+	uint8_t	unused_0[6];
+} hwrm_port_qcfg_input_t, *phwrm_port_qcfg_input_t;
+
+/* hwrm_port_qcfg_output (size:192b/24B) */
+
+typedef struct hwrm_port_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint32_t	supported;
+	/*
+	 * If set to '1', then this bit indicates that TX rate limit
+	 * could be configured via hwrm_port_cfg command.
+	 */
+	#define HWRM_PORT_QCFG_OUTPUT_SUPPORTED_TX_RATE_LIMIT	UINT32_C(0x1)
+	uint32_t	enabled;
+	/*
+	 * If set to '1', then this bit indicates that TX rate limit
+	 * is enabled and could be found in tx_rate_limit field.
+	 */
+	#define HWRM_PORT_QCFG_OUTPUT_ENABLED_TX_RATE_LIMIT	UINT32_C(0x1)
+	/*
+	 * Current setting of TX rate limit in Mbps.
+	 * This field is valid only when tx_rate_limit bit in 'enabled'
+	 * field is '1'.
+	 */
+	uint32_t	tx_rate_limit;
+	uint8_t	unused_0[3];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_port_qcfg_output_t, *phwrm_port_qcfg_output_t;
+
+/***********************
+ * hwrm_port_mac_qcaps *
+ ***********************/
+
+
+/* hwrm_port_mac_qcaps_input (size:192b/24B) */
+
+typedef struct hwrm_port_mac_qcaps_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Port ID of port that is being queried. */
+	uint16_t	port_id;
+	uint8_t	unused_0[6];
+} hwrm_port_mac_qcaps_input_t, *phwrm_port_mac_qcaps_input_t;
+
+/* hwrm_port_mac_qcaps_output (size:128b/16B) */
+
+typedef struct hwrm_port_mac_qcaps_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* MAC capability flags */
+	uint8_t	flags;
+	/*
+	 * If set to 1, then this field indicates that the
+	 * MAC does not support local loopback.
+	 */
+	#define HWRM_PORT_MAC_QCAPS_OUTPUT_FLAGS_LOCAL_LPBK_NOT_SUPPORTED	UINT32_C(0x1)
+	/*
+	 * If set to 1, then this field indicates that the
+	 * MAC is capable of supporting remote loopback.
+	 */
+	#define HWRM_PORT_MAC_QCAPS_OUTPUT_FLAGS_REMOTE_LPBK_SUPPORTED	UINT32_C(0x2)
+	uint8_t	unused_0[6];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_port_mac_qcaps_output_t, *phwrm_port_mac_qcaps_output_t;
+
+/***********************
+ * hwrm_queue_qportcfg *
+ ***********************/
+
+
+/* hwrm_queue_qportcfg_input (size:192b/24B) */
+
+typedef struct hwrm_queue_qportcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	flags;
+	/*
+	 * Enumeration denoting the RX, TX type of the resource.
+	 * This enumeration is used for resources that are similar for both
+	 * TX and RX paths of the chip.
+	 */
+	#define HWRM_QUEUE_QPORTCFG_INPUT_FLAGS_PATH	UINT32_C(0x1)
+	/* tx path */
+		#define HWRM_QUEUE_QPORTCFG_INPUT_FLAGS_PATH_TX	UINT32_C(0x0)
+	/* rx path */
+		#define HWRM_QUEUE_QPORTCFG_INPUT_FLAGS_PATH_RX	UINT32_C(0x1)
+		#define HWRM_QUEUE_QPORTCFG_INPUT_FLAGS_PATH_LAST HWRM_QUEUE_QPORTCFG_INPUT_FLAGS_PATH_RX
+	/*
+	 * Port ID of port for which the queue configuration is being
+	 * queried. This field is only required when sent by IPC.
+	 */
+	uint16_t	port_id;
+	/*
+	 * Drivers will set this capability when it can use
+	 * queue_idx_service_profile to map the queues to application.
+	 */
+	uint8_t	drv_qmap_cap;
+	/* disabled */
+	#define HWRM_QUEUE_QPORTCFG_INPUT_DRV_QMAP_CAP_DISABLED UINT32_C(0x0)
+	/* enabled */
+	#define HWRM_QUEUE_QPORTCFG_INPUT_DRV_QMAP_CAP_ENABLED  UINT32_C(0x1)
+	#define HWRM_QUEUE_QPORTCFG_INPUT_DRV_QMAP_CAP_LAST	HWRM_QUEUE_QPORTCFG_INPUT_DRV_QMAP_CAP_ENABLED
+	uint8_t	unused_0;
+} hwrm_queue_qportcfg_input_t, *phwrm_queue_qportcfg_input_t;
+
+/* hwrm_queue_qportcfg_output (size:1344b/168B) */
+
+typedef struct hwrm_queue_qportcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/*
+	 * The maximum number of queues that can be configured on this
+	 * port.
+	 * Valid values range from 1 through 8.
+	 */
+	uint8_t	max_configurable_queues;
+	/*
+	 * The maximum number of lossless queues that can be configured
+	 * on this port.
+	 * Valid values range from 0 through 8.
+	 */
+	uint8_t	max_configurable_lossless_queues;
+	/*
+	 * Bitmask indicating which queues can be configured by the
+	 * hwrm_queue_cfg command.
+	 *
+	 * Each bit represents a specific queue where bit 0 represents
+	 * queue 0 and bit 7 represents queue 7.
+	 * # A value of 0 indicates that the queue is not configurable
+	 * by the hwrm_queue_cfg command.
+	 * # A value of 1 indicates that the queue is configurable.
+	 * # A hwrm_queue_cfg command shall return error when trying to
+	 * configure a queue not configurable.
+	 */
+	uint8_t	queue_cfg_allowed;
+	/* Information about queue configuration. */
+	uint8_t	queue_cfg_info;
+	/*
+	 * If this flag is set to '1', then the queues are
+	 * configured asymmetrically on TX and RX sides.
+	 * If this flag is set to '0', then the queues are
+	 * configured symmetrically on TX and RX sides. For
+	 * symmetric configuration, the queue configuration
+	 * including queue ids and service profiles on the
+	 * TX side is the same as the corresponding queue
+	 * configuration on the RX side.
+	 */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_CFG_INFO_ASYM_CFG		UINT32_C(0x1)
+	/*
+	 * If this flag is set to '1', then service_profile will carry
+	 * either lossy/lossless type and the new service_profile_type
+	 * field will be used to determine if the queue is for L2/ROCE/CNP.
+	 */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_CFG_INFO_USE_PROFILE_TYPE	UINT32_C(0x2)
+	/*
+	 * Bitmask indicating which queues can be configured by the
+	 * hwrm_queue_pfcenable_cfg command.
+	 *
+	 * Each bit represents a specific priority where bit 0 represents
+	 * priority 0 and bit 7 represents priority 7.
+	 * # A value of 0 indicates that the priority is not configurable by
+	 * the hwrm_queue_pfcenable_cfg command.
+	 * # A value of 1 indicates that the priority is configurable.
+	 * # A hwrm_queue_pfcenable_cfg command shall return error when
+	 * trying to configure a priority that is not configurable.
+	 */
+	uint8_t	queue_pfcenable_cfg_allowed;
+	/*
+	 * Bitmask indicating which queues can be configured by the
+	 * hwrm_queue_pri2cos_cfg command.
+	 *
+	 * Each bit represents a specific queue where bit 0 represents
+	 * queue 0 and bit 7 represents queue 7.
+	 * # A value of 0 indicates that the queue is not configurable
+	 * by the hwrm_queue_pri2cos_cfg command.
+	 * # A value of 1 indicates that the queue is configurable.
+	 * # A hwrm_queue_pri2cos_cfg command shall return error when
+	 * trying to configure a queue that is not configurable.
+	 */
+	uint8_t	queue_pri2cos_cfg_allowed;
+	/*
+	 * Bitmask indicating which queues can be configured by the
+	 * hwrm_queue_pri2cos_cfg command.
+	 *
+	 * Each bit represents a specific queue where bit 0 represents
+	 * queue 0 and bit 7 represents queue 7.
+	 * # A value of 0 indicates that the queue is not configurable
+	 * by the hwrm_queue_pri2cos_cfg command.
+	 * # A value of 1 indicates that the queue is configurable.
+	 * # A hwrm_queue_pri2cos_cfg command shall return error when
+	 * trying to configure a queue not configurable.
+	 */
+	uint8_t	queue_cos2bw_cfg_allowed;
+	/*
+	 * ID of CoS Queue 0.
+	 * FF - Invalid id
+	 *
+	 * # This ID can be used on any subsequent call to an hwrm command
+	 * that takes a queue id.
+	 * # IDs must always be queried by this command before any use
+	 * by the driver or software.
+	 * # The CoS queue index is obtained by applying modulo 10 to the
+	 * CoS queue ID. Valid CoS queue indexes are in the range of 0 to 7.
+	 * The CoS queue index is used to reference port statistics for the
+	 * CoS queue.
+	 * # A value of 0xff indicates that the queue is not available.
+	 * # Available queues may not be in sequential order.
+	 */
+	uint8_t	queue_id0;
+	/* This value specifies service profile kind for CoS queue */
+	uint8_t	queue_id0_service_profile;
+	/* Lossy (best-effort) */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_LOSSY	UINT32_C(0x0)
+	/* Lossless */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_LOSSLESS	UINT32_C(0x1)
+	/* Lossless RoCE (deprecated) */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_LOSSLESS_ROCE  UINT32_C(0x1)
+	/* Lossy RoCE CNP (deprecated) */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_LOSSY_ROCE_CNP UINT32_C(0x2)
+	/* Lossless NIC (deprecated) */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_LOSSLESS_NIC   UINT32_C(0x3)
+	/* Set to 0xFF... (All Fs) if there is no service profile specified */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_UNKNOWN	UINT32_C(0xff)
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_LAST	HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_UNKNOWN
+	/*
+	 * ID of CoS Queue 1.
+	 * FF - Invalid id
+	 *
+	 * # This ID can be used on any subsequent call to an hwrm command
+	 * that takes a queue id.
+	 * # IDs must always be queried by this command before any use
+	 * by the driver or software.
+	 * # The CoS queue index is obtained by applying modulo 10 to the
+	 * CoS queue ID. Valid CoS queue indexes are in the range of 0 to 7.
+	 * The CoS queue index is used to reference port statistics for the
+	 * CoS queue.
+	 * # A value of 0xff indicates that the queue is not available.
+	 * # Available queues may not be in sequential order.
+	 */
+	uint8_t	queue_id1;
+	/* This value specifies service profile kind for CoS queue */
+	uint8_t	queue_id1_service_profile;
+	/* Lossy (best-effort) */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID1_SERVICE_PROFILE_LOSSY	UINT32_C(0x0)
+	/* Lossless */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID1_SERVICE_PROFILE_LOSSLESS	UINT32_C(0x1)
+	/* Lossless RoCE (deprecated) */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID1_SERVICE_PROFILE_LOSSLESS_ROCE  UINT32_C(0x1)
+	/* Lossy RoCE CNP (deprecated) */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID1_SERVICE_PROFILE_LOSSY_ROCE_CNP UINT32_C(0x2)
+	/* Lossless NIC (deprecated) */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID1_SERVICE_PROFILE_LOSSLESS_NIC   UINT32_C(0x3)
+	/* Set to 0xFF... (All Fs) if there is no service profile specified */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID1_SERVICE_PROFILE_UNKNOWN	UINT32_C(0xff)
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID1_SERVICE_PROFILE_LAST	HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID1_SERVICE_PROFILE_UNKNOWN
+	/*
+	 * ID of CoS Queue 2.
+	 * FF - Invalid id
+	 *
+	 * # This ID can be used on any subsequent call to an hwrm command
+	 * that takes a queue id.
+	 * # IDs must always be queried by this command before any use
+	 * by the driver or software.
+	 * # The CoS queue index is obtained by applying modulo 10 to the
+	 * CoS queue ID. Valid CoS queue indexes are in the range of 0 to 7.
+	 * The CoS queue index is used to reference port statistics for the
+	 * CoS queue.
+	 * # A value of 0xff indicates that the queue is not available.
+	 * # Available queues may not be in sequential order.
+	 */
+	uint8_t	queue_id2;
+	/* This value specifies service profile kind for CoS queue */
+	uint8_t	queue_id2_service_profile;
+	/* Lossy (best-effort) */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID2_SERVICE_PROFILE_LOSSY	UINT32_C(0x0)
+	/* Lossless */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID2_SERVICE_PROFILE_LOSSLESS	UINT32_C(0x1)
+	/* Lossless RoCE (deprecated) */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID2_SERVICE_PROFILE_LOSSLESS_ROCE  UINT32_C(0x1)
+	/* Lossy RoCE CNP (deprecated) */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID2_SERVICE_PROFILE_LOSSY_ROCE_CNP UINT32_C(0x2)
+	/* Lossless NIC (deprecated) */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID2_SERVICE_PROFILE_LOSSLESS_NIC   UINT32_C(0x3)
+	/* Set to 0xFF... (All Fs) if there is no service profile specified */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID2_SERVICE_PROFILE_UNKNOWN	UINT32_C(0xff)
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID2_SERVICE_PROFILE_LAST	HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID2_SERVICE_PROFILE_UNKNOWN
+	/*
+	 * ID of CoS Queue 3.
+	 * FF - Invalid id
+	 *
+	 * # This ID can be used on any subsequent call to an hwrm command
+	 * that takes a queue id.
+	 * # IDs must always be queried by this command before any use
+	 * by the driver or software.
+	 * # The CoS queue index is obtained by applying modulo 10 to the
+	 * CoS queue ID. Valid CoS queue indexes are in the range of 0 to 7.
+	 * The CoS queue index is used to reference port statistics for the
+	 * CoS queue.
+	 * # A value of 0xff indicates that the queue is not available.
+	 * # Available queues may not be in sequential order.
+	 */
+	uint8_t	queue_id3;
+	/* This value specifies service profile kind for CoS queue */
+	uint8_t	queue_id3_service_profile;
+	/* Lossy (best-effort) */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID3_SERVICE_PROFILE_LOSSY	UINT32_C(0x0)
+	/* Lossless */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID3_SERVICE_PROFILE_LOSSLESS	UINT32_C(0x1)
+	/* Lossless RoCE (deprecated) */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID3_SERVICE_PROFILE_LOSSLESS_ROCE  UINT32_C(0x1)
+	/* Lossy RoCE CNP (deprecated) */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID3_SERVICE_PROFILE_LOSSY_ROCE_CNP UINT32_C(0x2)
+	/* Lossless NIC (deprecated) */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID3_SERVICE_PROFILE_LOSSLESS_NIC   UINT32_C(0x3)
+	/* Set to 0xFF... (All Fs) if there is no service profile specified */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID3_SERVICE_PROFILE_UNKNOWN	UINT32_C(0xff)
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID3_SERVICE_PROFILE_LAST	HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID3_SERVICE_PROFILE_UNKNOWN
+	/*
+	 * ID of CoS Queue 4.
+	 * FF - Invalid id
+	 *
+	 * # This ID can be used on any subsequent call to an hwrm command
+	 * that takes a queue id.
+	 * # IDs must always be queried by this command before any use
+	 * by the driver or software.
+	 * # The CoS queue index is obtained by applying modulo 10 to the
+	 * CoS queue ID. Valid CoS queue indexes are in the range of 0 to 7.
+	 * The CoS queue index is used to reference port statistics for the
+	 * CoS queue.
+	 * # A value of 0xff indicates that the queue is not available.
+	 * # Available queues may not be in sequential order.
+	 */
+	uint8_t	queue_id4;
+	/* This value specifies service profile kind for CoS queue */
+	uint8_t	queue_id4_service_profile;
+	/* Lossy (best-effort) */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID4_SERVICE_PROFILE_LOSSY	UINT32_C(0x0)
+	/* Lossless */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID4_SERVICE_PROFILE_LOSSLESS	UINT32_C(0x1)
+	/* Lossless RoCE (deprecated) */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID4_SERVICE_PROFILE_LOSSLESS_ROCE  UINT32_C(0x1)
+	/* Lossy RoCE CNP (deprecated) */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID4_SERVICE_PROFILE_LOSSY_ROCE_CNP UINT32_C(0x2)
+	/* Lossless NIC (deprecated) */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID4_SERVICE_PROFILE_LOSSLESS_NIC   UINT32_C(0x3)
+	/* Set to 0xFF... (All Fs) if there is no service profile specified */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID4_SERVICE_PROFILE_UNKNOWN	UINT32_C(0xff)
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID4_SERVICE_PROFILE_LAST	HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID4_SERVICE_PROFILE_UNKNOWN
+	/*
+	 * ID of CoS Queue 5.
+	 * FF - Invalid id
+	 *
+	 * # This ID can be used on any subsequent call to an hwrm command
+	 * that takes a queue id.
+	 * # IDs must always be queried by this command before any use
+	 * by the driver or software.
+	 * # The CoS queue index is obtained by applying modulo 10 to the
+	 * CoS queue ID. Valid CoS queue indexes are in the range of 0 to 7.
+	 * The CoS queue index is used to reference port statistics for the
+	 * CoS queue.
+	 * # A value of 0xff indicates that the queue is not available.
+	 * # Available queues may not be in sequential order.
+	 */
+	uint8_t	queue_id5;
+	/* This value specifies service profile kind for CoS queue */
+	uint8_t	queue_id5_service_profile;
+	/* Lossy (best-effort) */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID5_SERVICE_PROFILE_LOSSY	UINT32_C(0x0)
+	/* Lossless */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID5_SERVICE_PROFILE_LOSSLESS	UINT32_C(0x1)
+	/* Lossless RoCE (deprecated) */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID5_SERVICE_PROFILE_LOSSLESS_ROCE  UINT32_C(0x1)
+	/* Lossy RoCE CNP (deprecated) */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID5_SERVICE_PROFILE_LOSSY_ROCE_CNP UINT32_C(0x2)
+	/* Lossless NIC (deprecated) */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID5_SERVICE_PROFILE_LOSSLESS_NIC   UINT32_C(0x3)
+	/* Set to 0xFF... (All Fs) if there is no service profile specified */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID5_SERVICE_PROFILE_UNKNOWN	UINT32_C(0xff)
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID5_SERVICE_PROFILE_LAST	HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID5_SERVICE_PROFILE_UNKNOWN
+	/*
+	 * ID of CoS Queue 6.
+	 * FF - Invalid id
+	 *
+	 * # This ID can be used on any subsequent call to an hwrm command
+	 * that takes a queue id.
+	 * # IDs must always be queried by this command before any use
+	 * by the driver or software.
+	 * # The CoS queue index is obtained by applying modulo 10 to the
+	 * CoS queue ID. Valid CoS queue indexes are in the range of 0 to 7.
+	 * The CoS queue index is used to reference port statistics for the
+	 * CoS queue.
+	 * # A value of 0xff indicates that the queue is not available.
+	 * # Available queues may not be in sequential order.
+	 */
+	uint8_t	queue_id6;
+	/* This value specifies service profile kind for CoS queue */
+	uint8_t	queue_id6_service_profile;
+	/* Lossy (best-effort) */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID6_SERVICE_PROFILE_LOSSY	UINT32_C(0x0)
+	/* Lossless */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID6_SERVICE_PROFILE_LOSSLESS	UINT32_C(0x1)
+	/* Lossless RoCE (deprecated) */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID6_SERVICE_PROFILE_LOSSLESS_ROCE  UINT32_C(0x1)
+	/* Lossy RoCE CNP (deprecated) */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID6_SERVICE_PROFILE_LOSSY_ROCE_CNP UINT32_C(0x2)
+	/* Lossless NIC (deprecated) */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID6_SERVICE_PROFILE_LOSSLESS_NIC   UINT32_C(0x3)
+	/* Set to 0xFF... (All Fs) if there is no service profile specified */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID6_SERVICE_PROFILE_UNKNOWN	UINT32_C(0xff)
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID6_SERVICE_PROFILE_LAST	HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID6_SERVICE_PROFILE_UNKNOWN
+	/*
+	 * ID of CoS Queue 7.
+	 * FF - Invalid id
+	 *
+	 * # This ID can be used on any subsequent call to an hwrm command
+	 * that takes a queue id.
+	 * # IDs must always be queried by this command before any use
+	 * by the driver or software.
+	 * # The CoS queue index is obtained by applying modulo 10 to the
+	 * CoS queue ID. Valid CoS queue indexes are in the range of 0 to 7.
+	 * The CoS queue index is used to reference port statistics for the
+	 * CoS queue.
+	 * # A value of 0xff indicates that the queue is not available.
+	 * # Available queues may not be in sequential order.
+	 */
+	uint8_t	queue_id7;
+	/* This value specifies service profile kind for CoS queue */
+	uint8_t	queue_id7_service_profile;
+	/* Lossy (best-effort) */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID7_SERVICE_PROFILE_LOSSY	UINT32_C(0x0)
+	/* Lossless */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID7_SERVICE_PROFILE_LOSSLESS	UINT32_C(0x1)
+	/* Lossless RoCE (deprecated) */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID7_SERVICE_PROFILE_LOSSLESS_ROCE  UINT32_C(0x1)
+	/* Lossy RoCE CNP (deprecated) */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID7_SERVICE_PROFILE_LOSSY_ROCE_CNP UINT32_C(0x2)
+	/* Lossless NIC (deprecated) */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID7_SERVICE_PROFILE_LOSSLESS_NIC   UINT32_C(0x3)
+	/* Set to 0xFF... (All Fs) if there is no service profile specified */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID7_SERVICE_PROFILE_UNKNOWN	UINT32_C(0xff)
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID7_SERVICE_PROFILE_LAST	HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID7_SERVICE_PROFILE_UNKNOWN
+	/*
+	 * This value specifies traffic type for the service profile. We can
+	 * have a TC mapped to multiple traffic types. For example shared
+	 * CoS Q for CNP and NIC will have both cnp and nic bits set (0x6).
+	 * A value of zero is considered as invalid.
+	 */
+	uint8_t	queue_id0_service_profile_type;
+	/* Recommended to be used for RoCE traffic only. */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_TYPE_ROCE	UINT32_C(0x1)
+	/* Recommended to be used for NIC/L2 traffic only. */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_TYPE_NIC	UINT32_C(0x2)
+	/* Recommended to be used for CNP traffic only. */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_TYPE_CNP	UINT32_C(0x4)
+	/*
+	 * Up to 16 bytes of null padded ASCII string describing this queue.
+	 * The queue name includes a CoS queue index and, in some cases, text
+	 * that distinguishes the queue from other queues in the group.
+	 */
+	char	qid0_name[16];
+	/* Up to 16 bytes of null padded ASCII string describing this queue. */
+	char	qid1_name[16];
+	/* Up to 16 bytes of null padded ASCII string describing this queue. */
+	char	qid2_name[16];
+	/* Up to 16 bytes of null padded ASCII string describing this queue. */
+	char	qid3_name[16];
+	/* Up to 16 bytes of null padded ASCII string describing this queue. */
+	char	qid4_name[16];
+	/* Up to 16 bytes of null padded ASCII string describing this queue. */
+	char	qid5_name[16];
+	/* Up to 16 bytes of null padded ASCII string describing this queue. */
+	char	qid6_name[16];
+	/* Up to 16 bytes of null padded ASCII string describing this queue. */
+	char	qid7_name[16];
+	/*
+	 * This value specifies traffic type for the service profile. We can
+	 * have a TC mapped to multiple traffic types. For example shared
+	 * CoS Q for CNP and NIC will have both cnp and nic bits set (0x6).
+	 * A value of zero is considered as invalid.
+	 */
+	uint8_t	queue_id1_service_profile_type;
+	/* Recommended to be used for RoCE traffic only. */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID1_SERVICE_PROFILE_TYPE_ROCE	UINT32_C(0x1)
+	/* Recommended to be used for NIC/L2 traffic only. */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID1_SERVICE_PROFILE_TYPE_NIC	UINT32_C(0x2)
+	/* Recommended to be used for CNP traffic only. */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID1_SERVICE_PROFILE_TYPE_CNP	UINT32_C(0x4)
+	/*
+	 * This value specifies traffic type for the service profile. We can
+	 * have a TC mapped to multiple traffic types. For example shared
+	 * CoS Q for CNP and NIC will have both cnp and nic bits set (0x6).
+	 * A value of zero is considered as invalid.
+	 */
+	uint8_t	queue_id2_service_profile_type;
+	/* Recommended to be used for RoCE traffic only. */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID2_SERVICE_PROFILE_TYPE_ROCE	UINT32_C(0x1)
+	/* Recommended to be used for NIC/L2 traffic only. */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID2_SERVICE_PROFILE_TYPE_NIC	UINT32_C(0x2)
+	/* Recommended to be used for CNP traffic only. */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID2_SERVICE_PROFILE_TYPE_CNP	UINT32_C(0x4)
+	/*
+	 * This value specifies traffic type for the service profile. We can
+	 * have a TC mapped to multiple traffic types. For example shared
+	 * CoS Q for CNP and NIC will have both cnp and nic bits set (0x6).
+	 * A value of zero is considered as invalid.
+	 */
+	uint8_t	queue_id3_service_profile_type;
+	/* Recommended to be used for RoCE traffic only. */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID3_SERVICE_PROFILE_TYPE_ROCE	UINT32_C(0x1)
+	/* Recommended to be used for NIC/L2 traffic only. */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID3_SERVICE_PROFILE_TYPE_NIC	UINT32_C(0x2)
+	/* Recommended to be used for CNP traffic only. */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID3_SERVICE_PROFILE_TYPE_CNP	UINT32_C(0x4)
+	/*
+	 * This value specifies traffic type for the service profile. We can
+	 * have a TC mapped to multiple traffic types. For example shared
+	 * CoS Q for CNP and NIC will have both cnp and nic bits set (0x6).
+	 * A value of zero is considered as invalid.
+	 */
+	uint8_t	queue_id4_service_profile_type;
+	/* Recommended to be used for RoCE traffic only. */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID4_SERVICE_PROFILE_TYPE_ROCE	UINT32_C(0x1)
+	/* Recommended to be used for NIC/L2 traffic only. */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID4_SERVICE_PROFILE_TYPE_NIC	UINT32_C(0x2)
+	/* Recommended to be used for CNP traffic only. */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID4_SERVICE_PROFILE_TYPE_CNP	UINT32_C(0x4)
+	/*
+	 * This value specifies traffic type for the service profile. We can
+	 * have a TC mapped to multiple traffic types. For example shared
+	 * CoS Q for CNP and NIC will have both cnp and nic bits set (0x6).
+	 * A value of zero is considered as invalid.
+	 */
+	uint8_t	queue_id5_service_profile_type;
+	/* Recommended to be used for RoCE traffic only. */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID5_SERVICE_PROFILE_TYPE_ROCE	UINT32_C(0x1)
+	/* Recommended to be used for NIC/L2 traffic only. */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID5_SERVICE_PROFILE_TYPE_NIC	UINT32_C(0x2)
+	/* Recommended to be used for CNP traffic only. */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID5_SERVICE_PROFILE_TYPE_CNP	UINT32_C(0x4)
+	/*
+	 * This value specifies traffic type for the service profile. We can
+	 * have a TC mapped to multiple traffic types. For example shared
+	 * CoS Q for CNP and NIC will have both cnp and nic bits set (0x6).
+	 * A value of zero is considered as invalid.
+	 */
+	uint8_t	queue_id6_service_profile_type;
+	/* Recommended to be used for RoCE traffic only. */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID6_SERVICE_PROFILE_TYPE_ROCE	UINT32_C(0x1)
+	/* Recommended to be used for NIC/L2 traffic only. */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID6_SERVICE_PROFILE_TYPE_NIC	UINT32_C(0x2)
+	/* Recommended to be used for CNP traffic only. */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID6_SERVICE_PROFILE_TYPE_CNP	UINT32_C(0x4)
+	/*
+	 * This value specifies traffic type for the service profile. We can
+	 * have a TC mapped to multiple traffic types. For example shared
+	 * CoS Q for CNP and NIC will have both cnp and nic bits set (0x6).
+	 * A value of zero is considered as invalid.
+	 */
+	uint8_t	queue_id7_service_profile_type;
+	/* Recommended to be used for RoCE traffic only. */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID7_SERVICE_PROFILE_TYPE_ROCE	UINT32_C(0x1)
+	/* Recommended to be used for NIC/L2 traffic only. */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID7_SERVICE_PROFILE_TYPE_NIC	UINT32_C(0x2)
+	/* Recommended to be used for CNP traffic only. */
+	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID7_SERVICE_PROFILE_TYPE_CNP	UINT32_C(0x4)
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_queue_qportcfg_output_t, *phwrm_queue_qportcfg_output_t;
+
+/*******************
+ * hwrm_queue_qcfg *
+ *******************/
+
+
+/* hwrm_queue_qcfg_input (size:192b/24B) */
+
+typedef struct hwrm_queue_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	flags;
+	/*
+	 * Enumeration denoting the RX, TX type of the resource.
+	 * This enumeration is used for resources that are similar for both
+	 * TX and RX paths of the chip.
+	 */
+	#define HWRM_QUEUE_QCFG_INPUT_FLAGS_PATH	UINT32_C(0x1)
+	/* tx path */
+		#define HWRM_QUEUE_QCFG_INPUT_FLAGS_PATH_TX	UINT32_C(0x0)
+	/* rx path */
+		#define HWRM_QUEUE_QCFG_INPUT_FLAGS_PATH_RX	UINT32_C(0x1)
+		#define HWRM_QUEUE_QCFG_INPUT_FLAGS_PATH_LAST HWRM_QUEUE_QCFG_INPUT_FLAGS_PATH_RX
+	/* Queue ID of the queue. */
+	uint32_t	queue_id;
+} hwrm_queue_qcfg_input_t, *phwrm_queue_qcfg_input_t;
+
+/* hwrm_queue_qcfg_output (size:128b/16B) */
+
+typedef struct hwrm_queue_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/*
+	 * This value is the estimate packet length used in the
+	 * TX arbiter.
+	 */
+	uint32_t	queue_len;
+	/* This value is applicable to CoS queues only. */
+	uint8_t	service_profile;
+	/* Lossy (best-effort) */
+	#define HWRM_QUEUE_QCFG_OUTPUT_SERVICE_PROFILE_LOSSY	UINT32_C(0x0)
+	/* Lossless */
+	#define HWRM_QUEUE_QCFG_OUTPUT_SERVICE_PROFILE_LOSSLESS UINT32_C(0x1)
+	/* Set to 0xFF... (All Fs) if there is no service profile specified */
+	#define HWRM_QUEUE_QCFG_OUTPUT_SERVICE_PROFILE_UNKNOWN  UINT32_C(0xff)
+	#define HWRM_QUEUE_QCFG_OUTPUT_SERVICE_PROFILE_LAST	HWRM_QUEUE_QCFG_OUTPUT_SERVICE_PROFILE_UNKNOWN
+	/* Information about queue configuration. */
+	uint8_t	queue_cfg_info;
+	/*
+	 * If this flag is set to '1', then the queue is
+	 * configured asymmetrically on TX and RX sides.
+	 * If this flag is set to '0', then this queue is
+	 * configured symmetrically on TX and RX sides.
+	 */
+	#define HWRM_QUEUE_QCFG_OUTPUT_QUEUE_CFG_INFO_ASYM_CFG	UINT32_C(0x1)
+	uint8_t	unused_0;
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_queue_qcfg_output_t, *phwrm_queue_qcfg_output_t;
+
+/******************
+ * hwrm_queue_cfg *
+ ******************/
+
+
+/* hwrm_queue_cfg_input (size:320b/40B) */
+
+typedef struct hwrm_queue_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	flags;
+	/*
+	 * Enumeration denoting the RX, TX, or both directions applicable to
+	 * the resource. This enumeration is used for resources that are
+	 * similar for both TX and RX paths of the chip.
+	 */
+	#define HWRM_QUEUE_CFG_INPUT_FLAGS_PATH_MASK UINT32_C(0x3)
+	#define HWRM_QUEUE_CFG_INPUT_FLAGS_PATH_SFT  0
+	/* tx path */
+		#define HWRM_QUEUE_CFG_INPUT_FLAGS_PATH_TX	UINT32_C(0x0)
+	/* rx path */
+		#define HWRM_QUEUE_CFG_INPUT_FLAGS_PATH_RX	UINT32_C(0x1)
+	/* Bi-directional (Symmetrically applicable to TX and RX paths) */
+		#define HWRM_QUEUE_CFG_INPUT_FLAGS_PATH_BIDIR  UINT32_C(0x2)
+		#define HWRM_QUEUE_CFG_INPUT_FLAGS_PATH_LAST  HWRM_QUEUE_CFG_INPUT_FLAGS_PATH_BIDIR
+	uint32_t	enables;
+	/*
+	 * This bit must be '1' for the dflt_len field to be
+	 * configured.
+	 */
+	#define HWRM_QUEUE_CFG_INPUT_ENABLES_DFLT_LEN		UINT32_C(0x1)
+	/*
+	 * This bit must be '1' for the service_profile field to be
+	 * configured.
+	 */
+	#define HWRM_QUEUE_CFG_INPUT_ENABLES_SERVICE_PROFILE	UINT32_C(0x2)
+	/* Queue ID of queue that is to be configured by this function. */
+	uint32_t	queue_id;
+	/*
+	 * This value is a the estimate packet length used in the
+	 * TX arbiter.
+	 * Set to 0xFF... (All Fs) to not adjust this value.
+	 */
+	uint32_t	dflt_len;
+	/* This value is applicable to CoS queues only. */
+	uint8_t	service_profile;
+	/* Lossy (best-effort) */
+	#define HWRM_QUEUE_CFG_INPUT_SERVICE_PROFILE_LOSSY	UINT32_C(0x0)
+	/* Lossless */
+	#define HWRM_QUEUE_CFG_INPUT_SERVICE_PROFILE_LOSSLESS UINT32_C(0x1)
+	/* Set to 0xFF... (All Fs) if there is no service profile specified */
+	#define HWRM_QUEUE_CFG_INPUT_SERVICE_PROFILE_UNKNOWN  UINT32_C(0xff)
+	#define HWRM_QUEUE_CFG_INPUT_SERVICE_PROFILE_LAST	HWRM_QUEUE_CFG_INPUT_SERVICE_PROFILE_UNKNOWN
+	uint8_t	unused_0[7];
+} hwrm_queue_cfg_input_t, *phwrm_queue_cfg_input_t;
+
+/* hwrm_queue_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_queue_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_queue_cfg_output_t, *phwrm_queue_cfg_output_t;
+
+/*****************************
+ * hwrm_queue_pfcenable_qcfg *
+ *****************************/
+
+
+/* hwrm_queue_pfcenable_qcfg_input (size:192b/24B) */
+
+typedef struct hwrm_queue_pfcenable_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/*
+	 * Port ID of port for which the table is being configured.
+	 * The HWRM needs to check whether this function is allowed
+	 * to configure pri2cos mapping on this port.
+	 */
+	uint16_t	port_id;
+	uint8_t	unused_0[6];
+} hwrm_queue_pfcenable_qcfg_input_t, *phwrm_queue_pfcenable_qcfg_input_t;
+
+/* hwrm_queue_pfcenable_qcfg_output (size:128b/16B) */
+
+typedef struct hwrm_queue_pfcenable_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint32_t	flags;
+	/* If set to 1, then PFC is enabled on PRI 0. */
+	#define HWRM_QUEUE_PFCENABLE_QCFG_OUTPUT_FLAGS_PRI0_PFC_ENABLED		UINT32_C(0x1)
+	/* If set to 1, then PFC is enabled on PRI 1. */
+	#define HWRM_QUEUE_PFCENABLE_QCFG_OUTPUT_FLAGS_PRI1_PFC_ENABLED		UINT32_C(0x2)
+	/* If set to 1, then PFC is enabled on PRI 2. */
+	#define HWRM_QUEUE_PFCENABLE_QCFG_OUTPUT_FLAGS_PRI2_PFC_ENABLED		UINT32_C(0x4)
+	/* If set to 1, then PFC is enabled on PRI 3. */
+	#define HWRM_QUEUE_PFCENABLE_QCFG_OUTPUT_FLAGS_PRI3_PFC_ENABLED		UINT32_C(0x8)
+	/* If set to 1, then PFC is enabled on PRI 4. */
+	#define HWRM_QUEUE_PFCENABLE_QCFG_OUTPUT_FLAGS_PRI4_PFC_ENABLED		UINT32_C(0x10)
+	/* If set to 1, then PFC is enabled on PRI 5. */
+	#define HWRM_QUEUE_PFCENABLE_QCFG_OUTPUT_FLAGS_PRI5_PFC_ENABLED		UINT32_C(0x20)
+	/* If set to 1, then PFC is enabled on PRI 6. */
+	#define HWRM_QUEUE_PFCENABLE_QCFG_OUTPUT_FLAGS_PRI6_PFC_ENABLED		UINT32_C(0x40)
+	/* If set to 1, then PFC is enabled on PRI 7. */
+	#define HWRM_QUEUE_PFCENABLE_QCFG_OUTPUT_FLAGS_PRI7_PFC_ENABLED		UINT32_C(0x80)
+	/* If set to 1, then PFC WatchDog is requested to be enabled on PRI0. */
+	#define HWRM_QUEUE_PFCENABLE_QCFG_OUTPUT_FLAGS_PRI0_PFC_WATCHDOG_ENABLED	UINT32_C(0x100)
+	/* If set to 1, then PFC WatchDog is requested to be enabled on PRI1. */
+	#define HWRM_QUEUE_PFCENABLE_QCFG_OUTPUT_FLAGS_PRI1_PFC_WATCHDOG_ENABLED	UINT32_C(0x200)
+	/* If set to 1, then PFC WatchDog is requested to be enabled on PRI2. */
+	#define HWRM_QUEUE_PFCENABLE_QCFG_OUTPUT_FLAGS_PRI2_PFC_WATCHDOG_ENABLED	UINT32_C(0x400)
+	/* If set to 1, then PFC WatchDog is requested to be enabled on PRI3. */
+	#define HWRM_QUEUE_PFCENABLE_QCFG_OUTPUT_FLAGS_PRI3_PFC_WATCHDOG_ENABLED	UINT32_C(0x800)
+	/* If set to 1, then PFC WatchDog is requested to be enabled on PRI4. */
+	#define HWRM_QUEUE_PFCENABLE_QCFG_OUTPUT_FLAGS_PRI4_PFC_WATCHDOG_ENABLED	UINT32_C(0x1000)
+	/* If set to 1, then PFC WatchDog is requested to be enabled on PRI5. */
+	#define HWRM_QUEUE_PFCENABLE_QCFG_OUTPUT_FLAGS_PRI5_PFC_WATCHDOG_ENABLED	UINT32_C(0x2000)
+	/* If set to 1, then PFC WatchDog is requested to be enabled on PRI6. */
+	#define HWRM_QUEUE_PFCENABLE_QCFG_OUTPUT_FLAGS_PRI6_PFC_WATCHDOG_ENABLED	UINT32_C(0x4000)
+	/* If set to 1, then PFC WatchDog is requested to be enabled on PRI7. */
+	#define HWRM_QUEUE_PFCENABLE_QCFG_OUTPUT_FLAGS_PRI7_PFC_WATCHDOG_ENABLED	UINT32_C(0x8000)
+	uint8_t	unused_0[3];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_queue_pfcenable_qcfg_output_t, *phwrm_queue_pfcenable_qcfg_output_t;
+
+/****************************
+ * hwrm_queue_pfcenable_cfg *
+ ****************************/
+
+
+/* hwrm_queue_pfcenable_cfg_input (size:192b/24B) */
+
+typedef struct hwrm_queue_pfcenable_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	flags;
+	/* If set to 1, then PFC is requested to be enabled on PRI 0. */
+	#define HWRM_QUEUE_PFCENABLE_CFG_INPUT_FLAGS_PRI0_PFC_ENABLED		UINT32_C(0x1)
+	/* If set to 1, then PFC is requested to be enabled on PRI 1. */
+	#define HWRM_QUEUE_PFCENABLE_CFG_INPUT_FLAGS_PRI1_PFC_ENABLED		UINT32_C(0x2)
+	/* If set to 1, then PFC is requested to be enabled on PRI 2. */
+	#define HWRM_QUEUE_PFCENABLE_CFG_INPUT_FLAGS_PRI2_PFC_ENABLED		UINT32_C(0x4)
+	/* If set to 1, then PFC is requested to be enabled on PRI 3. */
+	#define HWRM_QUEUE_PFCENABLE_CFG_INPUT_FLAGS_PRI3_PFC_ENABLED		UINT32_C(0x8)
+	/* If set to 1, then PFC is requested to be enabled on PRI 4. */
+	#define HWRM_QUEUE_PFCENABLE_CFG_INPUT_FLAGS_PRI4_PFC_ENABLED		UINT32_C(0x10)
+	/* If set to 1, then PFC is requested to be enabled on PRI 5. */
+	#define HWRM_QUEUE_PFCENABLE_CFG_INPUT_FLAGS_PRI5_PFC_ENABLED		UINT32_C(0x20)
+	/* If set to 1, then PFC is requested to be enabled on PRI 6. */
+	#define HWRM_QUEUE_PFCENABLE_CFG_INPUT_FLAGS_PRI6_PFC_ENABLED		UINT32_C(0x40)
+	/* If set to 1, then PFC is requested to be enabled on PRI 7. */
+	#define HWRM_QUEUE_PFCENABLE_CFG_INPUT_FLAGS_PRI7_PFC_ENABLED		UINT32_C(0x80)
+	/* If set to 1, then PFC WatchDog is requested to be enabled on PRI0. */
+	#define HWRM_QUEUE_PFCENABLE_CFG_INPUT_FLAGS_PRI0_PFC_WATCHDOG_ENABLED	UINT32_C(0x100)
+	/* If set to 1, then PFC WatchDog is requested to be enabled on PRI1. */
+	#define HWRM_QUEUE_PFCENABLE_CFG_INPUT_FLAGS_PRI1_PFC_WATCHDOG_ENABLED	UINT32_C(0x200)
+	/* If set to 1, then PFC WatchDog is requested to be enabled on PRI2. */
+	#define HWRM_QUEUE_PFCENABLE_CFG_INPUT_FLAGS_PRI2_PFC_WATCHDOG_ENABLED	UINT32_C(0x400)
+	/* If set to 1, then PFC WatchDog is requested to be enabled on PRI3. */
+	#define HWRM_QUEUE_PFCENABLE_CFG_INPUT_FLAGS_PRI3_PFC_WATCHDOG_ENABLED	UINT32_C(0x800)
+	/* If set to 1, then PFC WatchDog is requested to be enabled on PRI4. */
+	#define HWRM_QUEUE_PFCENABLE_CFG_INPUT_FLAGS_PRI4_PFC_WATCHDOG_ENABLED	UINT32_C(0x1000)
+	/* If set to 1, then PFC WatchDog is requested to be enabled on PRI5. */
+	#define HWRM_QUEUE_PFCENABLE_CFG_INPUT_FLAGS_PRI5_PFC_WATCHDOG_ENABLED	UINT32_C(0x2000)
+	/* If set to 1, then PFC WatchDog is requested to be enabled on PRI6. */
+	#define HWRM_QUEUE_PFCENABLE_CFG_INPUT_FLAGS_PRI6_PFC_WATCHDOG_ENABLED	UINT32_C(0x4000)
+	/* If set to 1, then PFC WatchDog is requested to be enabled on PRI7. */
+	#define HWRM_QUEUE_PFCENABLE_CFG_INPUT_FLAGS_PRI7_PFC_WATCHDOG_ENABLED	UINT32_C(0x8000)
+	/*
+	 * Port ID of port for which the table is being configured.
+	 * The HWRM needs to check whether this function is allowed
+	 * to configure pri2cos mapping on this port.
+	 */
+	uint16_t	port_id;
+	uint8_t	unused_0[2];
+} hwrm_queue_pfcenable_cfg_input_t, *phwrm_queue_pfcenable_cfg_input_t;
+
+/* hwrm_queue_pfcenable_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_queue_pfcenable_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_queue_pfcenable_cfg_output_t, *phwrm_queue_pfcenable_cfg_output_t;
+
+/***************************
+ * hwrm_queue_pri2cos_qcfg *
+ ***************************/
+
+
+/* hwrm_queue_pri2cos_qcfg_input (size:192b/24B) */
+
+typedef struct hwrm_queue_pri2cos_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	flags;
+	/*
+	 * Enumeration denoting the RX, TX type of the resource.
+	 * This enumeration is used for resources that are similar for both
+	 * TX and RX paths of the chip.
+	 */
+	#define HWRM_QUEUE_PRI2COS_QCFG_INPUT_FLAGS_PATH	UINT32_C(0x1)
+	/* tx path */
+		#define HWRM_QUEUE_PRI2COS_QCFG_INPUT_FLAGS_PATH_TX	UINT32_C(0x0)
+	/* rx path */
+		#define HWRM_QUEUE_PRI2COS_QCFG_INPUT_FLAGS_PATH_RX	UINT32_C(0x1)
+		#define HWRM_QUEUE_PRI2COS_QCFG_INPUT_FLAGS_PATH_LAST  HWRM_QUEUE_PRI2COS_QCFG_INPUT_FLAGS_PATH_RX
+	/*
+	 * When this bit is set to '0', the query is
+	 * for PRI from tunnel headers.
+	 * When this bit is set to '1', the query is
+	 * for PRI from inner packet headers.
+	 */
+	#define HWRM_QUEUE_PRI2COS_QCFG_INPUT_FLAGS_IVLAN	UINT32_C(0x2)
+	/*
+	 * Port ID of port for which the table is being configured.
+	 * The HWRM needs to check whether this function is allowed
+	 * to configure pri2cos mapping on this port.
+	 */
+	uint8_t	port_id;
+	uint8_t	unused_0[3];
+} hwrm_queue_pri2cos_qcfg_input_t, *phwrm_queue_pri2cos_qcfg_input_t;
+
+/* hwrm_queue_pri2cos_qcfg_output (size:192b/24B) */
+
+typedef struct hwrm_queue_pri2cos_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/*
+	 * CoS Queue assigned to priority 0. This value can only
+	 * be changed before traffic has started.
+	 * A value of 0xff indicates that no CoS queue is assigned to the
+	 * specified priority.
+	 */
+	uint8_t	pri0_cos_queue_id;
+	/*
+	 * CoS Queue assigned to priority 1. This value can only
+	 * be changed before traffic has started.
+	 * A value of 0xff indicates that no CoS queue is assigned to the
+	 * specified priority.
+	 */
+	uint8_t	pri1_cos_queue_id;
+	/*
+	 * CoS Queue assigned to priority 2. This value can only
+	 * be changed before traffic has started.
+	 * A value of 0xff indicates that no CoS queue is assigned to the
+	 * specified priority.
+	 */
+	uint8_t	pri2_cos_queue_id;
+	/*
+	 * CoS Queue assigned to priority 3. This value can only
+	 * be changed before traffic has started.
+	 * A value of 0xff indicates that no CoS queue is assigned to the
+	 * specified priority.
+	 */
+	uint8_t	pri3_cos_queue_id;
+	/*
+	 * CoS Queue assigned to priority 4. This value can only
+	 * be changed before traffic has started.
+	 * A value of 0xff indicates that no CoS queue is assigned to the
+	 * specified priority.
+	 */
+	uint8_t	pri4_cos_queue_id;
+	/*
+	 * CoS Queue assigned to priority 5. This value can only
+	 * be changed before traffic has started.
+	 * A value of 0xff indicates that no CoS queue is assigned to the
+	 * specified priority.
+	 */
+	uint8_t	pri5_cos_queue_id;
+	/*
+	 * CoS Queue assigned to priority 6. This value can only
+	 * be changed before traffic has started.
+	 * A value of 0xff indicates that no CoS queue is assigned to the
+	 * specified priority.
+	 */
+	uint8_t	pri6_cos_queue_id;
+	/*
+	 * CoS Queue assigned to priority 7. This value can only
+	 * be changed before traffic has started.
+	 * A value of 0xff indicates that no CoS queue is assigned to the
+	 * specified priority.
+	 */
+	uint8_t	pri7_cos_queue_id;
+	/* Information about queue configuration. */
+	uint8_t	queue_cfg_info;
+	/*
+	 * If this flag is set to '1', then the PRI to CoS
+	 * configuration is asymmetric on TX and RX sides.
+	 * If this flag is set to '0', then PRI to CoS configuration
+	 * is symmetric on TX and RX sides.
+	 */
+	#define HWRM_QUEUE_PRI2COS_QCFG_OUTPUT_QUEUE_CFG_INFO_ASYM_CFG	UINT32_C(0x1)
+	uint8_t	unused_0[6];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_queue_pri2cos_qcfg_output_t, *phwrm_queue_pri2cos_qcfg_output_t;
+
+/**************************
+ * hwrm_queue_pri2cos_cfg *
+ **************************/
+
+
+/* hwrm_queue_pri2cos_cfg_input (size:320b/40B) */
+
+typedef struct hwrm_queue_pri2cos_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	flags;
+	/*
+	 * Enumeration denoting the RX, TX, or both directions applicable to
+	 * the resource. This enumeration is used for resources that are
+	 * similar for both TX and RX paths of the chip.
+	 */
+	#define HWRM_QUEUE_PRI2COS_CFG_INPUT_FLAGS_PATH_MASK UINT32_C(0x3)
+	#define HWRM_QUEUE_PRI2COS_CFG_INPUT_FLAGS_PATH_SFT  0
+	/* tx path */
+		#define HWRM_QUEUE_PRI2COS_CFG_INPUT_FLAGS_PATH_TX	UINT32_C(0x0)
+	/* rx path */
+		#define HWRM_QUEUE_PRI2COS_CFG_INPUT_FLAGS_PATH_RX	UINT32_C(0x1)
+	/* Bi-directional (Symmetrically applicable to TX and RX paths) */
+		#define HWRM_QUEUE_PRI2COS_CFG_INPUT_FLAGS_PATH_BIDIR  UINT32_C(0x2)
+		#define HWRM_QUEUE_PRI2COS_CFG_INPUT_FLAGS_PATH_LAST  HWRM_QUEUE_PRI2COS_CFG_INPUT_FLAGS_PATH_BIDIR
+	/*
+	 * When this bit is set to '0', the mapping is requested
+	 * for PRI from tunnel headers.
+	 * When this bit is set to '1', the mapping is requested
+	 * for PRI from inner packet headers.
+	 */
+	#define HWRM_QUEUE_PRI2COS_CFG_INPUT_FLAGS_IVLAN	UINT32_C(0x4)
+	uint32_t	enables;
+	/*
+	 * This bit must be '1' for the pri0_cos_queue_id field to be
+	 * configured.
+	 */
+	#define HWRM_QUEUE_PRI2COS_CFG_INPUT_ENABLES_PRI0_COS_QUEUE_ID	UINT32_C(0x1)
+	/*
+	 * This bit must be '1' for the pri1_cos_queue_id field to be
+	 * configured.
+	 */
+	#define HWRM_QUEUE_PRI2COS_CFG_INPUT_ENABLES_PRI1_COS_QUEUE_ID	UINT32_C(0x2)
+	/*
+	 * This bit must be '1' for the pri2_cos_queue_id field to be
+	 * configured.
+	 */
+	#define HWRM_QUEUE_PRI2COS_CFG_INPUT_ENABLES_PRI2_COS_QUEUE_ID	UINT32_C(0x4)
+	/*
+	 * This bit must be '1' for the pri3_cos_queue_id field to be
+	 * configured.
+	 */
+	#define HWRM_QUEUE_PRI2COS_CFG_INPUT_ENABLES_PRI3_COS_QUEUE_ID	UINT32_C(0x8)
+	/*
+	 * This bit must be '1' for the pri4_cos_queue_id field to be
+	 * configured.
+	 */
+	#define HWRM_QUEUE_PRI2COS_CFG_INPUT_ENABLES_PRI4_COS_QUEUE_ID	UINT32_C(0x10)
+	/*
+	 * This bit must be '1' for the pri5_cos_queue_id field to be
+	 * configured.
+	 */
+	#define HWRM_QUEUE_PRI2COS_CFG_INPUT_ENABLES_PRI5_COS_QUEUE_ID	UINT32_C(0x20)
+	/*
+	 * This bit must be '1' for the pri6_cos_queue_id field to be
+	 * configured.
+	 */
+	#define HWRM_QUEUE_PRI2COS_CFG_INPUT_ENABLES_PRI6_COS_QUEUE_ID	UINT32_C(0x40)
+	/*
+	 * This bit must be '1' for the pri7_cos_queue_id field to be
+	 * configured.
+	 */
+	#define HWRM_QUEUE_PRI2COS_CFG_INPUT_ENABLES_PRI7_COS_QUEUE_ID	UINT32_C(0x80)
+	/*
+	 * Port ID of port for which the table is being configured.
+	 * The HWRM needs to check whether this function is allowed
+	 * to configure pri2cos mapping on this port.
+	 */
+	uint8_t	port_id;
+	/*
+	 * CoS Queue assigned to priority 0. This value can only
+	 * be changed before traffic has started.
+	 */
+	uint8_t	pri0_cos_queue_id;
+	/*
+	 * CoS Queue assigned to priority 1. This value can only
+	 * be changed before traffic has started.
+	 */
+	uint8_t	pri1_cos_queue_id;
+	/*
+	 * CoS Queue assigned to priority 2. This value can only
+	 * be changed before traffic has started.
+	 */
+	uint8_t	pri2_cos_queue_id;
+	/*
+	 * CoS Queue assigned to priority 3. This value can only
+	 * be changed before traffic has started.
+	 */
+	uint8_t	pri3_cos_queue_id;
+	/*
+	 * CoS Queue assigned to priority 4. This value can only
+	 * be changed before traffic has started.
+	 */
+	uint8_t	pri4_cos_queue_id;
+	/*
+	 * CoS Queue assigned to priority 5. This value can only
+	 * be changed before traffic has started.
+	 */
+	uint8_t	pri5_cos_queue_id;
+	/*
+	 * CoS Queue assigned to priority 6. This value can only
+	 * be changed before traffic has started.
+	 */
+	uint8_t	pri6_cos_queue_id;
+	/*
+	 * CoS Queue assigned to priority 7. This value can only
+	 * be changed before traffic has started.
+	 */
+	uint8_t	pri7_cos_queue_id;
+	uint8_t	unused_0[7];
+} hwrm_queue_pri2cos_cfg_input_t, *phwrm_queue_pri2cos_cfg_input_t;
+
+/* hwrm_queue_pri2cos_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_queue_pri2cos_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_queue_pri2cos_cfg_output_t, *phwrm_queue_pri2cos_cfg_output_t;
+
+/**************************
+ * hwrm_queue_cos2bw_qcfg *
+ **************************/
+
+
+/* hwrm_queue_cos2bw_qcfg_input (size:192b/24B) */
+
+typedef struct hwrm_queue_cos2bw_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/*
+	 * Port ID of port for which the table is being configured.
+	 * The HWRM needs to check whether this function is allowed
+	 * to configure TC BW assignment on this port.
+	 */
+	uint16_t	port_id;
+	uint8_t	unused_0[6];
+} hwrm_queue_cos2bw_qcfg_input_t, *phwrm_queue_cos2bw_qcfg_input_t;
+
+/* hwrm_queue_cos2bw_qcfg_output (size:896b/112B) */
+
+typedef struct hwrm_queue_cos2bw_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* ID of CoS Queue 0. */
+	uint8_t	queue_id0;
+	uint8_t	unused_0;
+	uint16_t	unused_1;
+	/*
+	 * Minimum BW allocated to CoS Queue.
+	 * The HWRM will translate this value into byte counter and
+	 * time interval used for this COS inside the device.
+	 */
+	uint32_t	queue_id0_min_bw;
+	/* The bandwidth value. */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MIN_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MIN_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MIN_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MIN_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_INVALID
+	/*
+	 * Maximum BW allocated to CoS Queue.
+	 * The HWRM will translate this value into byte counter and
+	 * time interval used for this COS inside the device.
+	 */
+	uint32_t	queue_id0_max_bw;
+	/* The bandwidth value. */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MAX_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MAX_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MAX_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MAX_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_INVALID
+	/* Transmission Selection Algorithm (TSA) for CoS Queue. */
+	uint8_t	queue_id0_tsa_assign;
+	/* Strict Priority */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_TSA_ASSIGN_SP		UINT32_C(0x0)
+	/* Enhanced Transmission Selection */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_TSA_ASSIGN_ETS		UINT32_C(0x1)
+	/* reserved. */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_TSA_ASSIGN_RESERVED_FIRST UINT32_C(0x2)
+	/* reserved. */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_TSA_ASSIGN_RESERVED_LAST  UINT32_C(0xff)
+	/*
+	 * Priority level for strict priority. Valid only when the
+	 * tsa_assign is 0 - Strict Priority (SP)
+	 * 0..7 - Valid values.
+	 * 8..255 - Reserved.
+	 */
+	uint8_t	queue_id0_pri_lvl;
+	/*
+	 * Weight used to allocate remaining BW for this COS after
+	 * servicing guaranteed bandwidths for all COS.
+	 */
+	uint8_t	queue_id0_bw_weight;
+	/* ID of CoS Queue 1. */
+	uint8_t	queue_id1;
+	/*
+	 * Minimum BW allocated to CoS Queue.
+	 * The HWRM will translate this value into byte counter and
+	 * time interval used for this COS inside the device.
+	 */
+	uint32_t	queue_id1_min_bw;
+	/* The bandwidth value. */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MIN_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MIN_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MIN_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MIN_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_INVALID
+	/*
+	 * Maximum BW allocated to CoS queue.
+	 * The HWRM will translate this value into byte counter and
+	 * time interval used for this COS inside the device.
+	 */
+	uint32_t	queue_id1_max_bw;
+	/* The bandwidth value. */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MAX_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MAX_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MAX_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MAX_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_INVALID
+	/* Transmission Selection Algorithm (TSA) for CoS Queue. */
+	uint8_t	queue_id1_tsa_assign;
+	/* Strict Priority */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_TSA_ASSIGN_SP		UINT32_C(0x0)
+	/* Enhanced Transmission Selection */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_TSA_ASSIGN_ETS		UINT32_C(0x1)
+	/* reserved. */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_TSA_ASSIGN_RESERVED_FIRST UINT32_C(0x2)
+	/* reserved. */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_TSA_ASSIGN_RESERVED_LAST  UINT32_C(0xff)
+	/*
+	 * Priority level for strict priority. Valid only when the
+	 * tsa_assign is 0 - Strict Priority (SP)
+	 * 0..7 - Valid values.
+	 * 8..255 - Reserved.
+	 */
+	uint8_t	queue_id1_pri_lvl;
+	/*
+	 * Weight used to allocate remaining BW for this COS after
+	 * servicing guaranteed bandwidths for all COS.
+	 */
+	uint8_t	queue_id1_bw_weight;
+	/* ID of CoS Queue 2. */
+	uint8_t	queue_id2;
+	/*
+	 * Minimum BW allocated to CoS Queue.
+	 * The HWRM will translate this value into byte counter and
+	 * time interval used for this COS inside the device.
+	 */
+	uint32_t	queue_id2_min_bw;
+	/* The bandwidth value. */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MIN_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MIN_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MIN_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MIN_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_INVALID
+	/*
+	 * Maximum BW allocated to CoS queue.
+	 * The HWRM will translate this value into byte counter and
+	 * time interval used for this COS inside the device.
+	 */
+	uint32_t	queue_id2_max_bw;
+	/* The bandwidth value. */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MAX_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MAX_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MAX_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MAX_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_INVALID
+	/* Transmission Selection Algorithm (TSA) for CoS Queue. */
+	uint8_t	queue_id2_tsa_assign;
+	/* Strict Priority */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_TSA_ASSIGN_SP		UINT32_C(0x0)
+	/* Enhanced Transmission Selection */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_TSA_ASSIGN_ETS		UINT32_C(0x1)
+	/* reserved. */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_TSA_ASSIGN_RESERVED_FIRST UINT32_C(0x2)
+	/* reserved. */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_TSA_ASSIGN_RESERVED_LAST  UINT32_C(0xff)
+	/*
+	 * Priority level for strict priority. Valid only when the
+	 * tsa_assign is 0 - Strict Priority (SP)
+	 * 0..7 - Valid values.
+	 * 8..255 - Reserved.
+	 */
+	uint8_t	queue_id2_pri_lvl;
+	/*
+	 * Weight used to allocate remaining BW for this COS after
+	 * servicing guaranteed bandwidths for all COS.
+	 */
+	uint8_t	queue_id2_bw_weight;
+	/* ID of CoS Queue 3. */
+	uint8_t	queue_id3;
+	/*
+	 * Minimum BW allocated to CoS Queue.
+	 * The HWRM will translate this value into byte counter and
+	 * time interval used for this COS inside the device.
+	 */
+	uint32_t	queue_id3_min_bw;
+	/* The bandwidth value. */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MIN_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MIN_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MIN_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MIN_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_INVALID
+	/*
+	 * Maximum BW allocated to CoS queue.
+	 * The HWRM will translate this value into byte counter and
+	 * time interval used for this COS inside the device.
+	 */
+	uint32_t	queue_id3_max_bw;
+	/* The bandwidth value. */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MAX_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MAX_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MAX_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MAX_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_INVALID
+	/* Transmission Selection Algorithm (TSA) for CoS Queue. */
+	uint8_t	queue_id3_tsa_assign;
+	/* Strict Priority */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_TSA_ASSIGN_SP		UINT32_C(0x0)
+	/* Enhanced Transmission Selection */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_TSA_ASSIGN_ETS		UINT32_C(0x1)
+	/* reserved. */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_TSA_ASSIGN_RESERVED_FIRST UINT32_C(0x2)
+	/* reserved. */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_TSA_ASSIGN_RESERVED_LAST  UINT32_C(0xff)
+	/*
+	 * Priority level for strict priority. Valid only when the
+	 * tsa_assign is 0 - Strict Priority (SP)
+	 * 0..7 - Valid values.
+	 * 8..255 - Reserved.
+	 */
+	uint8_t	queue_id3_pri_lvl;
+	/*
+	 * Weight used to allocate remaining BW for this COS after
+	 * servicing guaranteed bandwidths for all COS.
+	 */
+	uint8_t	queue_id3_bw_weight;
+	/* ID of CoS Queue 4. */
+	uint8_t	queue_id4;
+	/*
+	 * Minimum BW allocated to CoS Queue.
+	 * The HWRM will translate this value into byte counter and
+	 * time interval used for this COS inside the device.
+	 */
+	uint32_t	queue_id4_min_bw;
+	/* The bandwidth value. */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MIN_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MIN_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MIN_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MIN_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_INVALID
+	/*
+	 * Maximum BW allocated to CoS queue.
+	 * The HWRM will translate this value into byte counter and
+	 * time interval used for this COS inside the device.
+	 */
+	uint32_t	queue_id4_max_bw;
+	/* The bandwidth value. */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MAX_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MAX_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MAX_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MAX_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_INVALID
+	/* Transmission Selection Algorithm (TSA) for CoS Queue. */
+	uint8_t	queue_id4_tsa_assign;
+	/* Strict Priority */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_TSA_ASSIGN_SP		UINT32_C(0x0)
+	/* Enhanced Transmission Selection */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_TSA_ASSIGN_ETS		UINT32_C(0x1)
+	/* reserved. */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_TSA_ASSIGN_RESERVED_FIRST UINT32_C(0x2)
+	/* reserved. */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_TSA_ASSIGN_RESERVED_LAST  UINT32_C(0xff)
+	/*
+	 * Priority level for strict priority. Valid only when the
+	 * tsa_assign is 0 - Strict Priority (SP)
+	 * 0..7 - Valid values.
+	 * 8..255 - Reserved.
+	 */
+	uint8_t	queue_id4_pri_lvl;
+	/*
+	 * Weight used to allocate remaining BW for this COS after
+	 * servicing guaranteed bandwidths for all COS.
+	 */
+	uint8_t	queue_id4_bw_weight;
+	/* ID of CoS Queue 5. */
+	uint8_t	queue_id5;
+	/*
+	 * Minimum BW allocated to CoS Queue.
+	 * The HWRM will translate this value into byte counter and
+	 * time interval used for this COS inside the device.
+	 */
+	uint32_t	queue_id5_min_bw;
+	/* The bandwidth value. */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MIN_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MIN_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MIN_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MIN_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_INVALID
+	/*
+	 * Maximum BW allocated to CoS queue.
+	 * The HWRM will translate this value into byte counter and
+	 * time interval used for this COS inside the device.
+	 */
+	uint32_t	queue_id5_max_bw;
+	/* The bandwidth value. */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MAX_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MAX_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MAX_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MAX_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_INVALID
+	/* Transmission Selection Algorithm (TSA) for CoS Queue. */
+	uint8_t	queue_id5_tsa_assign;
+	/* Strict Priority */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_TSA_ASSIGN_SP		UINT32_C(0x0)
+	/* Enhanced Transmission Selection */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_TSA_ASSIGN_ETS		UINT32_C(0x1)
+	/* reserved. */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_TSA_ASSIGN_RESERVED_FIRST UINT32_C(0x2)
+	/* reserved. */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_TSA_ASSIGN_RESERVED_LAST  UINT32_C(0xff)
+	/*
+	 * Priority level for strict priority. Valid only when the
+	 * tsa_assign is 0 - Strict Priority (SP)
+	 * 0..7 - Valid values.
+	 * 8..255 - Reserved.
+	 */
+	uint8_t	queue_id5_pri_lvl;
+	/*
+	 * Weight used to allocate remaining BW for this COS after
+	 * servicing guaranteed bandwidths for all COS.
+	 */
+	uint8_t	queue_id5_bw_weight;
+	/* ID of CoS Queue 6. */
+	uint8_t	queue_id6;
+	/*
+	 * Minimum BW allocated to CoS Queue.
+	 * The HWRM will translate this value into byte counter and
+	 * time interval used for this COS inside the device.
+	 */
+	uint32_t	queue_id6_min_bw;
+	/* The bandwidth value. */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MIN_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MIN_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MIN_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MIN_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_INVALID
+	/*
+	 * Maximum BW allocated to CoS queue.
+	 * The HWRM will translate this value into byte counter and
+	 * time interval used for this COS inside the device.
+	 */
+	uint32_t	queue_id6_max_bw;
+	/* The bandwidth value. */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MAX_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MAX_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MAX_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MAX_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_INVALID
+	/* Transmission Selection Algorithm (TSA) for CoS Queue. */
+	uint8_t	queue_id6_tsa_assign;
+	/* Strict Priority */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_TSA_ASSIGN_SP		UINT32_C(0x0)
+	/* Enhanced Transmission Selection */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_TSA_ASSIGN_ETS		UINT32_C(0x1)
+	/* reserved. */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_TSA_ASSIGN_RESERVED_FIRST UINT32_C(0x2)
+	/* reserved. */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_TSA_ASSIGN_RESERVED_LAST  UINT32_C(0xff)
+	/*
+	 * Priority level for strict priority. Valid only when the
+	 * tsa_assign is 0 - Strict Priority (SP)
+	 * 0..7 - Valid values.
+	 * 8..255 - Reserved.
+	 */
+	uint8_t	queue_id6_pri_lvl;
+	/*
+	 * Weight used to allocate remaining BW for this COS after
+	 * servicing guaranteed bandwidths for all COS.
+	 */
+	uint8_t	queue_id6_bw_weight;
+	/* ID of CoS Queue 7. */
+	uint8_t	queue_id7;
+	/*
+	 * Minimum BW allocated to CoS Queue.
+	 * The HWRM will translate this value into byte counter and
+	 * time interval used for this COS inside the device.
+	 */
+	uint32_t	queue_id7_min_bw;
+	/* The bandwidth value. */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MIN_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MIN_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MIN_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MIN_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_INVALID
+	/*
+	 * Maximum BW allocated to CoS queue.
+	 * The HWRM will translate this value into byte counter and
+	 * time interval used for this COS inside the device.
+	 */
+	uint32_t	queue_id7_max_bw;
+	/* The bandwidth value. */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MAX_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MAX_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MAX_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MAX_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_INVALID
+	/* Transmission Selection Algorithm (TSA) for CoS Queue. */
+	uint8_t	queue_id7_tsa_assign;
+	/* Strict Priority */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_TSA_ASSIGN_SP		UINT32_C(0x0)
+	/* Enhanced Transmission Selection */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_TSA_ASSIGN_ETS		UINT32_C(0x1)
+	/* reserved. */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_TSA_ASSIGN_RESERVED_FIRST UINT32_C(0x2)
+	/* reserved. */
+	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_TSA_ASSIGN_RESERVED_LAST  UINT32_C(0xff)
+	/*
+	 * Priority level for strict priority. Valid only when the
+	 * tsa_assign is 0 - Strict Priority (SP)
+	 * 0..7 - Valid values.
+	 * 8..255 - Reserved.
+	 */
+	uint8_t	queue_id7_pri_lvl;
+	/*
+	 * Weight used to allocate remaining BW for this COS after
+	 * servicing guaranteed bandwidths for all COS.
+	 */
+	uint8_t	queue_id7_bw_weight;
+	uint8_t	unused_2[4];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_queue_cos2bw_qcfg_output_t, *phwrm_queue_cos2bw_qcfg_output_t;
+
+/*************************
+ * hwrm_queue_cos2bw_cfg *
+ *************************/
+
+
+/* hwrm_queue_cos2bw_cfg_input (size:1024b/128B) */
+
+typedef struct hwrm_queue_cos2bw_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	flags;
+	uint32_t	enables;
+	/*
+	 * If this bit is set to 1, then all queue_id0 related
+	 * parameters in this command are valid.
+	 */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_ENABLES_COS_QUEUE_ID0_VALID	UINT32_C(0x1)
+	/*
+	 * If this bit is set to 1, then all queue_id1 related
+	 * parameters in this command are valid.
+	 */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_ENABLES_COS_QUEUE_ID1_VALID	UINT32_C(0x2)
+	/*
+	 * If this bit is set to 1, then all queue_id2 related
+	 * parameters in this command are valid.
+	 */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_ENABLES_COS_QUEUE_ID2_VALID	UINT32_C(0x4)
+	/*
+	 * If this bit is set to 1, then all queue_id3 related
+	 * parameters in this command are valid.
+	 */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_ENABLES_COS_QUEUE_ID3_VALID	UINT32_C(0x8)
+	/*
+	 * If this bit is set to 1, then all queue_id4 related
+	 * parameters in this command are valid.
+	 */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_ENABLES_COS_QUEUE_ID4_VALID	UINT32_C(0x10)
+	/*
+	 * If this bit is set to 1, then all queue_id5 related
+	 * parameters in this command are valid.
+	 */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_ENABLES_COS_QUEUE_ID5_VALID	UINT32_C(0x20)
+	/*
+	 * If this bit is set to 1, then all queue_id6 related
+	 * parameters in this command are valid.
+	 */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_ENABLES_COS_QUEUE_ID6_VALID	UINT32_C(0x40)
+	/*
+	 * If this bit is set to 1, then all queue_id7 related
+	 * parameters in this command are valid.
+	 */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_ENABLES_COS_QUEUE_ID7_VALID	UINT32_C(0x80)
+	/*
+	 * Port ID of port for which the table is being configured.
+	 * The HWRM needs to check whether this function is allowed
+	 * to configure TC BW assignment on this port.
+	 */
+	uint16_t	port_id;
+	/* ID of CoS Queue 0. */
+	uint8_t	queue_id0;
+	uint8_t	unused_0;
+	/*
+	 * Minimum BW allocated to CoS Queue.
+	 * The HWRM will translate this value into byte counter and
+	 * time interval used for this COS inside the device.
+	 */
+	uint32_t	queue_id0_min_bw;
+	/* The bandwidth value. */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MIN_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MIN_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MIN_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MIN_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_INVALID
+	/*
+	 * Maximum BW allocated to CoS Queue.
+	 * The HWRM will translate this value into byte counter and
+	 * time interval used for this COS inside the device.
+	 */
+	uint32_t	queue_id0_max_bw;
+	/* The bandwidth value. */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MAX_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MAX_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MAX_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MAX_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_INVALID
+	/* Transmission Selection Algorithm (TSA) for CoS Queue. */
+	uint8_t	queue_id0_tsa_assign;
+	/* Strict Priority */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_TSA_ASSIGN_SP		UINT32_C(0x0)
+	/* Enhanced Transmission Selection */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_TSA_ASSIGN_ETS		UINT32_C(0x1)
+	/* reserved. */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_TSA_ASSIGN_RESERVED_FIRST UINT32_C(0x2)
+	/* reserved. */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_TSA_ASSIGN_RESERVED_LAST  UINT32_C(0xff)
+	/*
+	 * Priority level for strict priority. Valid only when the
+	 * tsa_assign is 0 - Strict Priority (SP)
+	 * 0..7 - Valid values.
+	 * 8..255 - Reserved.
+	 */
+	uint8_t	queue_id0_pri_lvl;
+	/*
+	 * Weight used to allocate remaining BW for this COS after
+	 * servicing guaranteed bandwidths for all COS.
+	 */
+	uint8_t	queue_id0_bw_weight;
+	/* ID of CoS Queue 1. */
+	uint8_t	queue_id1;
+	/*
+	 * Minimum BW allocated to CoS Queue.
+	 * The HWRM will translate this value into byte counter and
+	 * time interval used for this COS inside the device.
+	 */
+	uint32_t	queue_id1_min_bw;
+	/* The bandwidth value. */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MIN_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MIN_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MIN_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MIN_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_INVALID
+	/*
+	 * Maximum BW allocated to CoS queue.
+	 * The HWRM will translate this value into byte counter and
+	 * time interval used for this COS inside the device.
+	 */
+	uint32_t	queue_id1_max_bw;
+	/* The bandwidth value. */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MAX_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MAX_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MAX_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MAX_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_INVALID
+	/* Transmission Selection Algorithm (TSA) for CoS Queue. */
+	uint8_t	queue_id1_tsa_assign;
+	/* Strict Priority */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_TSA_ASSIGN_SP		UINT32_C(0x0)
+	/* Enhanced Transmission Selection */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_TSA_ASSIGN_ETS		UINT32_C(0x1)
+	/* reserved. */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_TSA_ASSIGN_RESERVED_FIRST UINT32_C(0x2)
+	/* reserved. */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_TSA_ASSIGN_RESERVED_LAST  UINT32_C(0xff)
+	/*
+	 * Priority level for strict priority. Valid only when the
+	 * tsa_assign is 0 - Strict Priority (SP)
+	 * 0..7 - Valid values.
+	 * 8..255 - Reserved.
+	 */
+	uint8_t	queue_id1_pri_lvl;
+	/*
+	 * Weight used to allocate remaining BW for this COS after
+	 * servicing guaranteed bandwidths for all COS.
+	 */
+	uint8_t	queue_id1_bw_weight;
+	/* ID of CoS Queue 2. */
+	uint8_t	queue_id2;
+	/*
+	 * Minimum BW allocated to CoS Queue.
+	 * The HWRM will translate this value into byte counter and
+	 * time interval used for this COS inside the device.
+	 */
+	uint32_t	queue_id2_min_bw;
+	/* The bandwidth value. */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MIN_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MIN_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MIN_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MIN_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_INVALID
+	/*
+	 * Maximum BW allocated to CoS queue.
+	 * The HWRM will translate this value into byte counter and
+	 * time interval used for this COS inside the device.
+	 */
+	uint32_t	queue_id2_max_bw;
+	/* The bandwidth value. */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MAX_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MAX_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MAX_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MAX_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_INVALID
+	/* Transmission Selection Algorithm (TSA) for CoS Queue. */
+	uint8_t	queue_id2_tsa_assign;
+	/* Strict Priority */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_TSA_ASSIGN_SP		UINT32_C(0x0)
+	/* Enhanced Transmission Selection */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_TSA_ASSIGN_ETS		UINT32_C(0x1)
+	/* reserved. */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_TSA_ASSIGN_RESERVED_FIRST UINT32_C(0x2)
+	/* reserved. */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_TSA_ASSIGN_RESERVED_LAST  UINT32_C(0xff)
+	/*
+	 * Priority level for strict priority. Valid only when the
+	 * tsa_assign is 0 - Strict Priority (SP)
+	 * 0..7 - Valid values.
+	 * 8..255 - Reserved.
+	 */
+	uint8_t	queue_id2_pri_lvl;
+	/*
+	 * Weight used to allocate remaining BW for this COS after
+	 * servicing guaranteed bandwidths for all COS.
+	 */
+	uint8_t	queue_id2_bw_weight;
+	/* ID of CoS Queue 3. */
+	uint8_t	queue_id3;
+	/*
+	 * Minimum BW allocated to CoS Queue.
+	 * The HWRM will translate this value into byte counter and
+	 * time interval used for this COS inside the device.
+	 */
+	uint32_t	queue_id3_min_bw;
+	/* The bandwidth value. */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MIN_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MIN_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MIN_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MIN_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_INVALID
+	/*
+	 * Maximum BW allocated to CoS queue.
+	 * The HWRM will translate this value into byte counter and
+	 * time interval used for this COS inside the device.
+	 */
+	uint32_t	queue_id3_max_bw;
+	/* The bandwidth value. */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MAX_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MAX_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MAX_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MAX_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_INVALID
+	/* Transmission Selection Algorithm (TSA) for CoS Queue. */
+	uint8_t	queue_id3_tsa_assign;
+	/* Strict Priority */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_TSA_ASSIGN_SP		UINT32_C(0x0)
+	/* Enhanced Transmission Selection */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_TSA_ASSIGN_ETS		UINT32_C(0x1)
+	/* reserved. */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_TSA_ASSIGN_RESERVED_FIRST UINT32_C(0x2)
+	/* reserved. */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_TSA_ASSIGN_RESERVED_LAST  UINT32_C(0xff)
+	/*
+	 * Priority level for strict priority. Valid only when the
+	 * tsa_assign is 0 - Strict Priority (SP)
+	 * 0..7 - Valid values.
+	 * 8..255 - Reserved.
+	 */
+	uint8_t	queue_id3_pri_lvl;
+	/*
+	 * Weight used to allocate remaining BW for this COS after
+	 * servicing guaranteed bandwidths for all COS.
+	 */
+	uint8_t	queue_id3_bw_weight;
+	/* ID of CoS Queue 4. */
+	uint8_t	queue_id4;
+	/*
+	 * Minimum BW allocated to CoS Queue.
+	 * The HWRM will translate this value into byte counter and
+	 * time interval used for this COS inside the device.
+	 */
+	uint32_t	queue_id4_min_bw;
+	/* The bandwidth value. */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MIN_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MIN_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MIN_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MIN_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_INVALID
+	/*
+	 * Maximum BW allocated to CoS queue.
+	 * The HWRM will translate this value into byte counter and
+	 * time interval used for this COS inside the device.
+	 */
+	uint32_t	queue_id4_max_bw;
+	/* The bandwidth value. */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MAX_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MAX_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MAX_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MAX_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_INVALID
+	/* Transmission Selection Algorithm (TSA) for CoS Queue. */
+	uint8_t	queue_id4_tsa_assign;
+	/* Strict Priority */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_TSA_ASSIGN_SP		UINT32_C(0x0)
+	/* Enhanced Transmission Selection */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_TSA_ASSIGN_ETS		UINT32_C(0x1)
+	/* reserved. */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_TSA_ASSIGN_RESERVED_FIRST UINT32_C(0x2)
+	/* reserved. */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_TSA_ASSIGN_RESERVED_LAST  UINT32_C(0xff)
+	/*
+	 * Priority level for strict priority. Valid only when the
+	 * tsa_assign is 0 - Strict Priority (SP)
+	 * 0..7 - Valid values.
+	 * 8..255 - Reserved.
+	 */
+	uint8_t	queue_id4_pri_lvl;
+	/*
+	 * Weight used to allocate remaining BW for this COS after
+	 * servicing guaranteed bandwidths for all COS.
+	 */
+	uint8_t	queue_id4_bw_weight;
+	/* ID of CoS Queue 5. */
+	uint8_t	queue_id5;
+	/*
+	 * Minimum BW allocated to CoS Queue.
+	 * The HWRM will translate this value into byte counter and
+	 * time interval used for this COS inside the device.
+	 */
+	uint32_t	queue_id5_min_bw;
+	/* The bandwidth value. */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MIN_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MIN_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MIN_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MIN_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_INVALID
+	/*
+	 * Maximum BW allocated to CoS queue.
+	 * The HWRM will translate this value into byte counter and
+	 * time interval used for this COS inside the device.
+	 */
+	uint32_t	queue_id5_max_bw;
+	/* The bandwidth value. */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MAX_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MAX_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MAX_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MAX_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_INVALID
+	/* Transmission Selection Algorithm (TSA) for CoS Queue. */
+	uint8_t	queue_id5_tsa_assign;
+	/* Strict Priority */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_TSA_ASSIGN_SP		UINT32_C(0x0)
+	/* Enhanced Transmission Selection */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_TSA_ASSIGN_ETS		UINT32_C(0x1)
+	/* reserved. */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_TSA_ASSIGN_RESERVED_FIRST UINT32_C(0x2)
+	/* reserved. */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_TSA_ASSIGN_RESERVED_LAST  UINT32_C(0xff)
+	/*
+	 * Priority level for strict priority. Valid only when the
+	 * tsa_assign is 0 - Strict Priority (SP)
+	 * 0..7 - Valid values.
+	 * 8..255 - Reserved.
+	 */
+	uint8_t	queue_id5_pri_lvl;
+	/*
+	 * Weight used to allocate remaining BW for this COS after
+	 * servicing guaranteed bandwidths for all COS.
+	 */
+	uint8_t	queue_id5_bw_weight;
+	/* ID of CoS Queue 6. */
+	uint8_t	queue_id6;
+	/*
+	 * Minimum BW allocated to CoS Queue.
+	 * The HWRM will translate this value into byte counter and
+	 * time interval used for this COS inside the device.
+	 */
+	uint32_t	queue_id6_min_bw;
+	/* The bandwidth value. */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MIN_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MIN_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MIN_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MIN_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_INVALID
+	/*
+	 * Maximum BW allocated to CoS queue.
+	 * The HWRM will translate this value into byte counter and
+	 * time interval used for this COS inside the device.
+	 */
+	uint32_t	queue_id6_max_bw;
+	/* The bandwidth value. */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MAX_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MAX_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MAX_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MAX_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_INVALID
+	/* Transmission Selection Algorithm (TSA) for CoS Queue. */
+	uint8_t	queue_id6_tsa_assign;
+	/* Strict Priority */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_TSA_ASSIGN_SP		UINT32_C(0x0)
+	/* Enhanced Transmission Selection */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_TSA_ASSIGN_ETS		UINT32_C(0x1)
+	/* reserved. */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_TSA_ASSIGN_RESERVED_FIRST UINT32_C(0x2)
+	/* reserved. */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_TSA_ASSIGN_RESERVED_LAST  UINT32_C(0xff)
+	/*
+	 * Priority level for strict priority. Valid only when the
+	 * tsa_assign is 0 - Strict Priority (SP)
+	 * 0..7 - Valid values.
+	 * 8..255 - Reserved.
+	 */
+	uint8_t	queue_id6_pri_lvl;
+	/*
+	 * Weight used to allocate remaining BW for this COS after
+	 * servicing guaranteed bandwidths for all COS.
+	 */
+	uint8_t	queue_id6_bw_weight;
+	/* ID of CoS Queue 7. */
+	uint8_t	queue_id7;
+	/*
+	 * Minimum BW allocated to CoS Queue.
+	 * The HWRM will translate this value into byte counter and
+	 * time interval used for this COS inside the device.
+	 */
+	uint32_t	queue_id7_min_bw;
+	/* The bandwidth value. */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MIN_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MIN_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MIN_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MIN_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_INVALID
+	/*
+	 * Maximum BW allocated to CoS queue.
+	 * The HWRM will translate this value into byte counter and
+	 * time interval used for this COS inside the device.
+	 */
+	uint32_t	queue_id7_max_bw;
+	/* The bandwidth value. */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MAX_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MAX_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MAX_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MAX_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_INVALID
+	/* Transmission Selection Algorithm (TSA) for CoS Queue. */
+	uint8_t	queue_id7_tsa_assign;
+	/* Strict Priority */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_TSA_ASSIGN_SP		UINT32_C(0x0)
+	/* Enhanced Transmission Selection */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_TSA_ASSIGN_ETS		UINT32_C(0x1)
+	/* reserved. */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_TSA_ASSIGN_RESERVED_FIRST UINT32_C(0x2)
+	/* reserved. */
+	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_TSA_ASSIGN_RESERVED_LAST  UINT32_C(0xff)
+	/*
+	 * Priority level for strict priority. Valid only when the
+	 * tsa_assign is 0 - Strict Priority (SP)
+	 * 0..7 - Valid values.
+	 * 8..255 - Reserved.
+	 */
+	uint8_t	queue_id7_pri_lvl;
+	/*
+	 * Weight used to allocate remaining BW for this COS after
+	 * servicing guaranteed bandwidths for all COS.
+	 */
+	uint8_t	queue_id7_bw_weight;
+	uint8_t	unused_1[5];
+} hwrm_queue_cos2bw_cfg_input_t, *phwrm_queue_cos2bw_cfg_input_t;
+
+/* hwrm_queue_cos2bw_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_queue_cos2bw_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_queue_cos2bw_cfg_output_t, *phwrm_queue_cos2bw_cfg_output_t;
+
+/*************************
+ * hwrm_queue_dscp_qcaps *
+ *************************/
+
+
+/* hwrm_queue_dscp_qcaps_input (size:192b/24B) */
+
+typedef struct hwrm_queue_dscp_qcaps_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/*
+	 * Port ID of port for which the table is being configured.
+	 * The HWRM needs to check whether this function is allowed
+	 * to configure pri2cos mapping on this port.
+	 */
+	uint8_t	port_id;
+	uint8_t	unused_0[7];
+} hwrm_queue_dscp_qcaps_input_t, *phwrm_queue_dscp_qcaps_input_t;
+
+/* hwrm_queue_dscp_qcaps_output (size:128b/16B) */
+
+typedef struct hwrm_queue_dscp_qcaps_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* The number of bits provided by the hardware for the DSCP value. */
+	uint8_t	num_dscp_bits;
+	uint8_t	unused_0;
+	/* Max number of DSCP-MASK-PRI entries supported. */
+	uint16_t	max_entries;
+	uint8_t	unused_1[3];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_queue_dscp_qcaps_output_t, *phwrm_queue_dscp_qcaps_output_t;
+
+/****************************
+ * hwrm_queue_dscp2pri_qcfg *
+ ****************************/
+
+
+/* hwrm_queue_dscp2pri_qcfg_input (size:256b/32B) */
+
+typedef struct hwrm_queue_dscp2pri_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/*
+	 * This is the host address where the 24-bits DSCP-MASK-PRI
+	 * tuple(s) will be copied to.
+	 */
+	uint64_t	dest_data_addr;
+	/*
+	 * Port ID of port for which the table is being configured.
+	 * The HWRM needs to check whether this function is allowed
+	 * to configure pri2cos mapping on this port.
+	 */
+	uint8_t	port_id;
+	uint8_t	unused_0;
+	/* Size of the buffer pointed to by dest_data_addr. */
+	uint16_t	dest_data_buffer_size;
+	uint8_t	unused_1[4];
+} hwrm_queue_dscp2pri_qcfg_input_t, *phwrm_queue_dscp2pri_qcfg_input_t;
+
+/* hwrm_queue_dscp2pri_qcfg_output (size:128b/16B) */
+
+typedef struct hwrm_queue_dscp2pri_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/*
+	 * A count of the number of DSCP-MASK-PRI tuple(s) pointed to
+	 * by the dest_data_addr.
+	 */
+	uint16_t	entry_cnt;
+	/*
+	 * This is the default PRI which un-initialized DSCP values are
+	 * mapped to.
+	 */
+	uint8_t	default_pri;
+	uint8_t	unused_0[4];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_queue_dscp2pri_qcfg_output_t, *phwrm_queue_dscp2pri_qcfg_output_t;
+
+/***************************
+ * hwrm_queue_dscp2pri_cfg *
+ ***************************/
+
+
+/* hwrm_queue_dscp2pri_cfg_input (size:320b/40B) */
+
+typedef struct hwrm_queue_dscp2pri_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/*
+	 * This is the host address where the 24-bits DSCP-MASK-PRI tuple
+	 * will be copied from. A non-zero mask "adds" a tuple, while
+	 * a mask equal to 0 triggers the firmware to remove a tuple.
+	 * Only tuples with unique DSCP values are stored. On chips
+	 * prior to Thor a mask can be 0 - 0x3f, while on Thor it can
+	 * be 0 or 0x3f.
+	 */
+	uint64_t	src_data_addr;
+	uint32_t	flags;
+	/* use_hw_default_pri is 1 b */
+	#define HWRM_QUEUE_DSCP2PRI_CFG_INPUT_FLAGS_USE_HW_DEFAULT_PRI	UINT32_C(0x1)
+	uint32_t	enables;
+	/*
+	 * This bit must be '1' for the default_pri field to be
+	 * configured.
+	 */
+	#define HWRM_QUEUE_DSCP2PRI_CFG_INPUT_ENABLES_DEFAULT_PRI	UINT32_C(0x1)
+	/*
+	 * Port ID of port for which the table is being configured.
+	 * The HWRM needs to check whether this function is allowed
+	 * to configure pri2cos mapping on this port.
+	 */
+	uint8_t	port_id;
+	/*
+	 * This is the default PRI which un-initialized DSCP values will be
+	 * mapped to.
+	 */
+	uint8_t	default_pri;
+	/*
+	 * A count of the number of DSCP-MASK-PRI tuple(s) in the data pointed
+	 * to by src_data_addr.
+	 */
+	uint16_t	entry_cnt;
+	uint8_t	unused_0[4];
+} hwrm_queue_dscp2pri_cfg_input_t, *phwrm_queue_dscp2pri_cfg_input_t;
+
+/* hwrm_queue_dscp2pri_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_queue_dscp2pri_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_queue_dscp2pri_cfg_output_t, *phwrm_queue_dscp2pri_cfg_output_t;
+
+/*************************
+ * hwrm_queue_mpls_qcaps *
+ *************************/
+
+
+/* hwrm_queue_mpls_qcaps_input (size:192b/24B) */
+
+typedef struct hwrm_queue_mpls_qcaps_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/*
+	 * Port ID of port for which the table is being configured.
+	 * The HWRM needs to check whether this function is allowed
+	 * to configure MPLS TC(EXP) to pri mapping on this port.
+	 */
+	uint8_t	port_id;
+	uint8_t	unused_0[7];
+} hwrm_queue_mpls_qcaps_input_t, *phwrm_queue_mpls_qcaps_input_t;
+
+/* hwrm_queue_mpls_qcaps_output (size:128b/16B) */
+
+typedef struct hwrm_queue_mpls_qcaps_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/*
+	 * Bitmask indicating which queues can be configured by the
+	 * hwrm_queue_mplstc2pri_cfg command.
+	 *
+	 * Each bit represents a specific pri where bit 0 represents
+	 * pri 0 and bit 7 represents pri 7.
+	 * # A value of 0 indicates that the pri is not configurable
+	 * by the hwrm_queue_mplstc2pri_cfg command.
+	 * # A value of 1 indicates that the pri is configurable.
+	 * # A hwrm_queue_mplstc2pri_cfg command shall return error when
+	 * trying to configure a pri that is not configurable.
+	 */
+	uint8_t	queue_mplstc2pri_cfg_allowed;
+	/*
+	 * This is the default PRI which un-initialized MPLS values will be
+	 * mapped to.
+	 */
+	uint8_t	hw_default_pri;
+	uint8_t	unused_0[5];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_queue_mpls_qcaps_output_t, *phwrm_queue_mpls_qcaps_output_t;
+
+/******************************
+ * hwrm_queue_mplstc2pri_qcfg *
+ ******************************/
+
+
+/* hwrm_queue_mplstc2pri_qcfg_input (size:192b/24B) */
+
+typedef struct hwrm_queue_mplstc2pri_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/*
+	 * Port ID of port for which the table is being configured.
+	 * The HWRM needs to check whether this function is allowed
+	 * to configure MPLS TC(EXP) to pri mapping on this port.
+	 */
+	uint8_t	port_id;
+	uint8_t	unused_0[7];
+} hwrm_queue_mplstc2pri_qcfg_input_t, *phwrm_queue_mplstc2pri_qcfg_input_t;
+
+/* hwrm_queue_mplstc2pri_qcfg_output (size:192b/24B) */
+
+typedef struct hwrm_queue_mplstc2pri_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/*
+	 * pri assigned to MPLS TC(EXP) 0. This value can only be changed
+	 * before traffic has started.
+	 * A value of 0xff indicates that no pri is assigned to the
+	 * MPLS TC(EXP) 0.
+	 */
+	uint8_t	tc0_pri_queue_id;
+	/*
+	 * pri assigned to MPLS TC(EXP) 1. This value can only be changed
+	 * before traffic has started.
+	 * A value of 0xff indicates that no pri is assigned to the
+	 * MPLS TC(EXP) 1.
+	 */
+	uint8_t	tc1_pri_queue_id;
+	/*
+	 * pri assigned to MPLS TC(EXP) 2. This value can only be changed
+	 * before traffic has started.
+	 * A value of 0xff indicates that no pri is assigned to the
+	 * MPLS TC(EXP) 2.
+	 */
+	uint8_t	tc2_pri_queue_id;
+	/*
+	 * pri assigned to MPLS TC(EXP) 3. This value can only be changed
+	 * before traffic has started.
+	 * A value of 0xff indicates that no pri is assigned to the
+	 * MPLS TC(EXP) 3.
+	 */
+	uint8_t	tc3_pri_queue_id;
+	/*
+	 * pri assigned to MPLS TC(EXP) 4. This value can only be changed
+	 * before traffic has started.
+	 * A value of 0xff indicates that no pri is assigned to the
+	 * MPLS TC(EXP) 4.
+	 */
+	uint8_t	tc4_pri_queue_id;
+	/*
+	 * pri assigned to MPLS TC(EXP) 5. This value can only be changed
+	 * before traffic has started.
+	 * A value of 0xff indicates that no pri is assigned to the
+	 * MPLS TC(EXP) 5.
+	 */
+	uint8_t	tc5_pri_queue_id;
+	/*
+	 * pri assigned to MPLS TC(EXP) 6. This value can only
+	 * be changed before traffic has started.
+	 * A value of 0xff indicates that no pri is assigned to the
+	 * MPLS TC(EXP) 6.
+	 */
+	uint8_t	tc6_pri_queue_id;
+	/*
+	 * pri assigned to MPLS TC(EXP) 7. This value can only
+	 * be changed before traffic has started.
+	 * A value of 0xff indicates that no pri is assigned to the
+	 * MPLS TC(EXP) 7.
+	 */
+	uint8_t	tc7_pri_queue_id;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_queue_mplstc2pri_qcfg_output_t, *phwrm_queue_mplstc2pri_qcfg_output_t;
+
+/*****************************
+ * hwrm_queue_mplstc2pri_cfg *
+ *****************************/
+
+
+/* hwrm_queue_mplstc2pri_cfg_input (size:256b/32B) */
+
+typedef struct hwrm_queue_mplstc2pri_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	enables;
+	/*
+	 * This bit must be '1' for the mplstc0_pri_queue_id field to be
+	 * configured.
+	 */
+	#define HWRM_QUEUE_MPLSTC2PRI_CFG_INPUT_ENABLES_TC0_PRI_QUEUE_ID	UINT32_C(0x1)
+	/*
+	 * This bit must be '1' for the mplstc1_pri_queue_id field to be
+	 * configured.
+	 */
+	#define HWRM_QUEUE_MPLSTC2PRI_CFG_INPUT_ENABLES_TC1_PRI_QUEUE_ID	UINT32_C(0x2)
+	/*
+	 * This bit must be '1' for the mplstc2_pri_queue_id field to be
+	 * configured.
+	 */
+	#define HWRM_QUEUE_MPLSTC2PRI_CFG_INPUT_ENABLES_TC2_PRI_QUEUE_ID	UINT32_C(0x4)
+	/*
+	 * This bit must be '1' for the mplstc3_pri_queue_id field to be
+	 * configured.
+	 */
+	#define HWRM_QUEUE_MPLSTC2PRI_CFG_INPUT_ENABLES_TC3_PRI_QUEUE_ID	UINT32_C(0x8)
+	/*
+	 * This bit must be '1' for the mplstc4_pri_queue_id field to be
+	 * configured.
+	 */
+	#define HWRM_QUEUE_MPLSTC2PRI_CFG_INPUT_ENABLES_TC4_PRI_QUEUE_ID	UINT32_C(0x10)
+	/*
+	 * This bit must be '1' for the mplstc5_pri_queue_id field to be
+	 * configured.
+	 */
+	#define HWRM_QUEUE_MPLSTC2PRI_CFG_INPUT_ENABLES_TC5_PRI_QUEUE_ID	UINT32_C(0x20)
+	/*
+	 * This bit must be '1' for the mplstc6_pri_queue_id field to be
+	 * configured.
+	 */
+	#define HWRM_QUEUE_MPLSTC2PRI_CFG_INPUT_ENABLES_TC6_PRI_QUEUE_ID	UINT32_C(0x40)
+	/*
+	 * This bit must be '1' for the mplstc7_pri_queue_id field to be
+	 * configured.
+	 */
+	#define HWRM_QUEUE_MPLSTC2PRI_CFG_INPUT_ENABLES_TC7_PRI_QUEUE_ID	UINT32_C(0x80)
+	/*
+	 * Port ID of port for which the table is being configured.
+	 * The HWRM needs to check whether this function is allowed
+	 * to configure MPLS TC(EXP)to pri mapping on this port.
+	 */
+	uint8_t	port_id;
+	uint8_t	unused_0[3];
+	/*
+	 * pri assigned to MPLS TC(EXP) 0. This value can only
+	 * be changed before traffic has started.
+	 */
+	uint8_t	tc0_pri_queue_id;
+	/*
+	 * pri assigned to MPLS TC(EXP) 1. This value can only
+	 * be changed before traffic has started.
+	 */
+	uint8_t	tc1_pri_queue_id;
+	/*
+	 * pri assigned to MPLS TC(EXP) 2. This value can only
+	 * be changed before traffic has started.
+	 */
+	uint8_t	tc2_pri_queue_id;
+	/*
+	 * pri assigned to MPLS TC(EXP) 3. This value can only
+	 * be changed before traffic has started.
+	 */
+	uint8_t	tc3_pri_queue_id;
+	/*
+	 * pri assigned to MPLS TC(EXP) 4. This value can only
+	 * be changed before traffic has started.
+	 */
+	uint8_t	tc4_pri_queue_id;
+	/*
+	 * pri assigned to MPLS TC(EXP) 5. This value can only
+	 * be changed before traffic has started.
+	 */
+	uint8_t	tc5_pri_queue_id;
+	/*
+	 * pri assigned to MPLS TC(EXP) 6. This value can only
+	 * be changed before traffic has started.
+	 */
+	uint8_t	tc6_pri_queue_id;
+	/*
+	 * pri assigned to MPLS TC(EXP) 7. This value can only
+	 * be changed before traffic has started.
+	 */
+	uint8_t	tc7_pri_queue_id;
+} hwrm_queue_mplstc2pri_cfg_input_t, *phwrm_queue_mplstc2pri_cfg_input_t;
+
+/* hwrm_queue_mplstc2pri_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_queue_mplstc2pri_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_queue_mplstc2pri_cfg_output_t, *phwrm_queue_mplstc2pri_cfg_output_t;
+
+/****************************
+ * hwrm_queue_vlanpri_qcaps *
+ ****************************/
+
+
+/* hwrm_queue_vlanpri_qcaps_input (size:192b/24B) */
+
+typedef struct hwrm_queue_vlanpri_qcaps_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/*
+	 * Port ID of port for which the table is being configured.
+	 * The HWRM needs to check whether this function is allowed
+	 * to configure VLAN priority to user priority mapping on this port.
+	 */
+	uint8_t	port_id;
+	uint8_t	unused_0[7];
+} hwrm_queue_vlanpri_qcaps_input_t, *phwrm_queue_vlanpri_qcaps_input_t;
+
+/* hwrm_queue_vlanpri_qcaps_output (size:128b/16B) */
+
+typedef struct hwrm_queue_vlanpri_qcaps_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/*
+	 * This is the default user priority which all VLAN priority values
+	 * are mapped to if there is no VLAN priority to user priority mapping.
+	 */
+	uint8_t	hw_default_pri;
+	uint8_t	unused_0[6];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_queue_vlanpri_qcaps_output_t, *phwrm_queue_vlanpri_qcaps_output_t;
+
+/*******************************
+ * hwrm_queue_vlanpri2pri_qcfg *
+ *******************************/
+
+
+/* hwrm_queue_vlanpri2pri_qcfg_input (size:192b/24B) */
+
+typedef struct hwrm_queue_vlanpri2pri_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/*
+	 * Port ID of port for which the table is being configured.
+	 * The HWRM needs to check whether this function is allowed
+	 * to configure VLAN priority to user priority mapping on this port.
+	 */
+	uint8_t	port_id;
+	uint8_t	unused_0[7];
+} hwrm_queue_vlanpri2pri_qcfg_input_t, *phwrm_queue_vlanpri2pri_qcfg_input_t;
+
+/* hwrm_queue_vlanpri2pri_qcfg_output (size:192b/24B) */
+
+typedef struct hwrm_queue_vlanpri2pri_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/*
+	 * User priority assigned to VLAN priority 0. A value of 0xff
+	 * indicates that no user priority is assigned. The default user
+	 * priority will be used.
+	 */
+	uint8_t	vlanpri0_user_pri_id;
+	/*
+	 * User priority assigned to VLAN priority 1. A value of 0xff
+	 * indicates that no user priority is assigned. The default user
+	 * priority will be used.
+	 */
+	uint8_t	vlanpri1_user_pri_id;
+	/*
+	 * User priority assigned to VLAN priority 2. A value of 0xff
+	 * indicates that no user priority is assigned. The default user
+	 * priority will be used.
+	 */
+	uint8_t	vlanpri2_user_pri_id;
+	/*
+	 * User priority assigned to VLAN priority 3. A value of 0xff
+	 * indicates that no user priority is assigned. The default user
+	 * priority will be used.
+	 */
+	uint8_t	vlanpri3_user_pri_id;
+	/*
+	 * User priority assigned to VLAN priority 4. A value of 0xff
+	 * indicates that no user priority is assigned. The default user
+	 * priority will be used.
+	 */
+	uint8_t	vlanpri4_user_pri_id;
+	/*
+	 * User priority assigned to VLAN priority 5. A value of 0xff
+	 * indicates that no user priority is assigned. The default user
+	 * priority will be used.
+	 */
+	uint8_t	vlanpri5_user_pri_id;
+	/*
+	 * User priority assigned to VLAN priority 6. A value of 0xff
+	 * indicates that no user priority is assigned. The default user
+	 * priority will be used.
+	 */
+	uint8_t	vlanpri6_user_pri_id;
+	/*
+	 * User priority assigned to VLAN priority 7. A value of 0xff
+	 * indicates that no user priority is assigned. The default user
+	 * priority will be used.
+	 */
+	uint8_t	vlanpri7_user_pri_id;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_queue_vlanpri2pri_qcfg_output_t, *phwrm_queue_vlanpri2pri_qcfg_output_t;
+
+/******************************
+ * hwrm_queue_vlanpri2pri_cfg *
+ ******************************/
+
+
+/* hwrm_queue_vlanpri2pri_cfg_input (size:256b/32B) */
+
+typedef struct hwrm_queue_vlanpri2pri_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	enables;
+	/*
+	 * This bit must be '1' for the vlanpri0_user_pri_id field to be
+	 * configured.
+	 */
+	#define HWRM_QUEUE_VLANPRI2PRI_CFG_INPUT_ENABLES_VLANPRI0_USER_PRI_ID	UINT32_C(0x1)
+	/*
+	 * This bit must be '1' for the vlanpri1_user_pri_id field to be
+	 * configured.
+	 */
+	#define HWRM_QUEUE_VLANPRI2PRI_CFG_INPUT_ENABLES_VLANPRI1_USER_PRI_ID	UINT32_C(0x2)
+	/*
+	 * This bit must be '1' for the vlanpri2_user_pri_id field to be
+	 * configured.
+	 */
+	#define HWRM_QUEUE_VLANPRI2PRI_CFG_INPUT_ENABLES_VLANPRI2_USER_PRI_ID	UINT32_C(0x4)
+	/*
+	 * This bit must be '1' for the vlanpri3_user_pri_id field to be
+	 * configured.
+	 */
+	#define HWRM_QUEUE_VLANPRI2PRI_CFG_INPUT_ENABLES_VLANPRI3_USER_PRI_ID	UINT32_C(0x8)
+	/*
+	 * This bit must be '1' for the vlanpri4_user_pri_id field to be
+	 * configured.
+	 */
+	#define HWRM_QUEUE_VLANPRI2PRI_CFG_INPUT_ENABLES_VLANPRI4_USER_PRI_ID	UINT32_C(0x10)
+	/*
+	 * This bit must be '1' for the vlanpri5_user_pri_id field to be
+	 * configured.
+	 */
+	#define HWRM_QUEUE_VLANPRI2PRI_CFG_INPUT_ENABLES_VLANPRI5_USER_PRI_ID	UINT32_C(0x20)
+	/*
+	 * This bit must be '1' for the vlanpri6_user_pri_id field to be
+	 * configured.
+	 */
+	#define HWRM_QUEUE_VLANPRI2PRI_CFG_INPUT_ENABLES_VLANPRI6_USER_PRI_ID	UINT32_C(0x40)
+	/*
+	 * This bit must be '1' for the vlanpri7_user_pri_id field to be
+	 * configured.
+	 */
+	#define HWRM_QUEUE_VLANPRI2PRI_CFG_INPUT_ENABLES_VLANPRI7_USER_PRI_ID	UINT32_C(0x80)
+	/*
+	 * Port ID of port for which the table is being configured.
+	 * The HWRM needs to check whether this function is allowed
+	 * to configure VLAN priority to user priority mapping on this port.
+	 */
+	uint8_t	port_id;
+	uint8_t	unused_0[3];
+	/*
+	 * User priority assigned to VLAN priority 0. This value can only
+	 * be changed before traffic has started.
+	 */
+	uint8_t	vlanpri0_user_pri_id;
+	/*
+	 * User priority assigned to VLAN priority 1. This value can only
+	 * be changed before traffic has started.
+	 */
+	uint8_t	vlanpri1_user_pri_id;
+	/*
+	 * User priority assigned to VLAN priority 2. This value can only
+	 * be changed before traffic has started.
+	 */
+	uint8_t	vlanpri2_user_pri_id;
+	/*
+	 * User priority assigned to VLAN priority 3. This value can only
+	 * be changed before traffic has started.
+	 */
+	uint8_t	vlanpri3_user_pri_id;
+	/*
+	 * User priority assigned to VLAN priority 4. This value can only
+	 * be changed before traffic has started.
+	 */
+	uint8_t	vlanpri4_user_pri_id;
+	/*
+	 * User priority assigned to VLAN priority 5. This value can only
+	 * be changed before traffic has started.
+	 */
+	uint8_t	vlanpri5_user_pri_id;
+	/*
+	 * User priority assigned to VLAN priority 6. This value can only
+	 * be changed before traffic has started.
+	 */
+	uint8_t	vlanpri6_user_pri_id;
+	/*
+	 * User priority assigned to VLAN priority 7. This value can only
+	 * be changed before traffic has started.
+	 */
+	uint8_t	vlanpri7_user_pri_id;
+} hwrm_queue_vlanpri2pri_cfg_input_t, *phwrm_queue_vlanpri2pri_cfg_input_t;
+
+/* hwrm_queue_vlanpri2pri_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_queue_vlanpri2pri_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_queue_vlanpri2pri_cfg_output_t, *phwrm_queue_vlanpri2pri_cfg_output_t;
+
+/*************************
+ * hwrm_queue_global_cfg *
+ *************************/
+
+
+/* hwrm_queue_global_cfg_input (size:192b/24B) */
+
+typedef struct hwrm_queue_global_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/*
+	 * Configuration mode for rx cos queues, configuring whether they
+	 * use one shared buffer pool (across ports or PCIe endpoints) or
+	 * independent per port or per endpoint buffer pools.
+	 */
+	uint8_t	mode;
+	/* One shared buffer pool to be used by all RX CoS queues */
+	#define HWRM_QUEUE_GLOBAL_CFG_INPUT_MODE_SHARED	UINT32_C(0x0)
+	/*
+	 * Each port or PCIe endpoint to use an independent buffer pool
+	 * for its RX CoS queues
+	 */
+	#define HWRM_QUEUE_GLOBAL_CFG_INPUT_MODE_INDEPENDENT UINT32_C(0x1)
+	#define HWRM_QUEUE_GLOBAL_CFG_INPUT_MODE_LAST	HWRM_QUEUE_GLOBAL_CFG_INPUT_MODE_INDEPENDENT
+	uint8_t	unused_0;
+	uint16_t	enables;
+	/* This bit must be '1' when the mode field is configured. */
+	#define HWRM_QUEUE_GLOBAL_CFG_INPUT_ENABLES_MODE	UINT32_C(0x1)
+	/*
+	 * This bit must be '1' when the maximum bandwidth for queue group 0
+	 * (g0_max_bw) is configured.
+	 */
+	#define HWRM_QUEUE_GLOBAL_CFG_INPUT_ENABLES_G0_MAX_BW	UINT32_C(0x2)
+	/*
+	 * This bit must be '1' when the maximum bandwidth for queue group 1
+	 * (g1_max_bw) is configured.
+	 */
+	#define HWRM_QUEUE_GLOBAL_CFG_INPUT_ENABLES_G1_MAX_BW	UINT32_C(0x4)
+	/*
+	 * This bit must be '1' when the maximum bandwidth for queue group 2
+	 * (g2_max_bw) is configured.
+	 */
+	#define HWRM_QUEUE_GLOBAL_CFG_INPUT_ENABLES_G2_MAX_BW	UINT32_C(0x8)
+	/*
+	 * This bit must be '1' when the maximum bandwidth for queue group 3
+	 * (g3_max_bw) is configured.
+	 */
+	#define HWRM_QUEUE_GLOBAL_CFG_INPUT_ENABLES_G3_MAX_BW	UINT32_C(0x10)
+	/*
+	 * Specifies the maximum receive rate, as a percentage of total link
+	 * bandwidth, of the receive traffic through queue group 0. A value
+	 * of 0 indicates no rate limit.
+	 *
+	 * A queue group is a set of queues, one per traffic class. In
+	 * single-host mode, each panel port has its own queue group, and thus,
+	 * this rate limit shapes the traffic received on a port, in this case,
+	 * through port 0. In multi-root or multi-host mode, each PCIe endpoint
+	 * on the NIC has its own queue group. In these cases, the rate limit
+	 * shapes the traffic sent to the host through one of the PCIe
+	 * endpoints, in this case endpoint 0.
+	 */
+	uint8_t	g0_max_bw;
+	/*
+	 * Specifies the maximum rate of the traffic through receive CoS queue
+	 * group 1 (for port 1 or PCIe endpoint 1). The rate is a percentage of
+	 * total link bandwidth (the sum of the bandwidths of all links). A
+	 * value of 0 indicates no rate limit.
+	 */
+	uint8_t	g1_max_bw;
+	/*
+	 * Specifies the maximum rate of the traffic through receive CoS queue
+	 * group 2 (for port 2 or PCIe endpoint 2). The rate is a percentage of
+	 * total link bandwidth (the sum of the bandwidths of all links). A
+	 * value of 0 indicates no rate limit.
+	 */
+	uint8_t	g2_max_bw;
+	/*
+	 * Specifies the maximum receive rate, in Mbps, of the receive traffic
+	 * through queue group 3 (for port 3 or PCIe endpoint 3). A value of 0
+	 * indicates no rate limit.
+	 */
+	uint8_t	g3_max_bw;
+} hwrm_queue_global_cfg_input_t, *phwrm_queue_global_cfg_input_t;
+
+/* hwrm_queue_global_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_queue_global_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_queue_global_cfg_output_t, *phwrm_queue_global_cfg_output_t;
+
+/**************************
+ * hwrm_queue_global_qcfg *
+ **************************/
+
+
+/* hwrm_queue_global_qcfg_input (size:128b/16B) */
+
+typedef struct hwrm_queue_global_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+} hwrm_queue_global_qcfg_input_t, *phwrm_queue_global_qcfg_input_t;
+
+/* hwrm_queue_global_qcfg_output (size:320b/40B) */
+
+typedef struct hwrm_queue_global_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Port or PCIe endpoint id to be mapped for buffer pool 0. */
+	uint8_t	buffer_pool_id0_map;
+	/* Port or PCIe endpoint id to be mapped for buffer pool 1. */
+	uint8_t	buffer_pool_id1_map;
+	/* Port or PCIe endpoint id to be mapped for buffer pool 2. */
+	uint8_t	buffer_pool_id2_map;
+	/* Port or PCIe endpoint id to be mapped for buffer pool 3. */
+	uint8_t	buffer_pool_id3_map;
+	/* Size of buffer pool 0 (KBytes). */
+	uint32_t	buffer_pool_id0_size;
+	/* Size of buffer pool 1 (KBytes). */
+	uint32_t	buffer_pool_id1_size;
+	/* Size of buffer pool 2 (KBytes). */
+	uint32_t	buffer_pool_id2_size;
+	/* Size of buffer pool 3 (KBytes). */
+	uint32_t	buffer_pool_id3_size;
+	uint16_t	flags;
+	/*
+	 * Enumeration denoting whether the rx buffer pool mapping is
+	 * per port or per PCIe endpoint
+	 */
+	#define HWRM_QUEUE_GLOBAL_QCFG_OUTPUT_FLAGS_MAPPING			UINT32_C(0x1)
+	/*
+	 * The buffer_pool_id[0-3]_map field represents mapping of rx
+	 * buffer pools to a port.
+	 */
+		#define HWRM_QUEUE_GLOBAL_QCFG_OUTPUT_FLAGS_MAPPING_MAPPING_PER_PORT	UINT32_C(0x0)
+	/*
+	 * The buffer_pool_id[0-3]_map field represents mapping of rx
+	 * buffer pools to a PCIe endpoint.
+	 */
+		#define HWRM_QUEUE_GLOBAL_QCFG_OUTPUT_FLAGS_MAPPING_MAPPING_PER_ENDPOINT  UINT32_C(0x1)
+		#define HWRM_QUEUE_GLOBAL_QCFG_OUTPUT_FLAGS_MAPPING_LAST		HWRM_QUEUE_GLOBAL_QCFG_OUTPUT_FLAGS_MAPPING_MAPPING_PER_ENDPOINT
+	/*
+	 * Configuration mode for rx cos queues, configuring whether they
+	 * use one shared buffer pool (across ports or PCIe endpoints) or
+	 * independent per port or per endpoint buffer pools.
+	 */
+	uint8_t	mode;
+	/* One shared buffer pool to be used by all RX CoS queues */
+	#define HWRM_QUEUE_GLOBAL_QCFG_OUTPUT_MODE_SHARED	UINT32_C(0x0)
+	/*
+	 * Each port or PCIe endpoint to use an independent buffer pool
+	 * for its RX CoS queues
+	 */
+	#define HWRM_QUEUE_GLOBAL_QCFG_OUTPUT_MODE_INDEPENDENT UINT32_C(0x1)
+	#define HWRM_QUEUE_GLOBAL_QCFG_OUTPUT_MODE_LAST	HWRM_QUEUE_GLOBAL_QCFG_OUTPUT_MODE_INDEPENDENT
+	uint8_t	unused_0;
+	/*
+	 * Reports the rate limit applied to traffic through receive CoS queue
+	 * group 0. The rate limit is a percentage of total link bandwidth. A
+	 * value of 0 indicates no rate limit.
+	 *
+	 * A queue group is a set of queues, one per traffic class. In
+	 * single-host mode, each panel port has its own queue group, and thus,
+	 * this rate limit shapes the traffic received on a port, in this case,
+	 * through port 0. In multi-root or multi-host mode, each PCIe endpoint
+	 * on the NIC has its own queue group. In these cases, the rate limit
+	 * shapes the traffic sent to the host through one of the PCIe
+	 * endpoints, in this case endpoint 0.
+	 */
+	uint8_t	g0_max_bw;
+	/*
+	 * Reports the rate limit applied to traffic through receive CoS queue
+	 * group 1 (for port 1 or PCIe endpoint 1). The rate limit is a
+	 * percentage of total link bandwidth. A value of 0 indicates no rate
+	 * limit.
+	 */
+	uint8_t	g1_max_bw;
+	/*
+	 * Reports the rate limit applied to traffic through receive CoS queue
+	 * group 2 (for port 2 or PCIe endpoint 2). The rate limit is a
+	 * percentage of total link bandwidth. A value of 0 indicates no rate
+	 * limit.
+	 */
+	uint8_t	g2_max_bw;
+	/*
+	 * Reports the rate limit applied to traffic through receive CoS queue
+	 * group 3 (for port 3 or PCIe endpoint 3). The rate limit is a
+	 * percentage of total link bandwidth. A value of 0 indicates no rate
+	 * limit.
+	 */
+	uint8_t	g3_max_bw;
+	uint8_t	unused_1[3];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_queue_global_qcfg_output_t, *phwrm_queue_global_qcfg_output_t;
+
+/****************************************
+ * hwrm_queue_adptv_qos_rx_feature_qcfg *
+ ****************************************/
+
+
+/* hwrm_queue_adptv_qos_rx_feature_qcfg_input (size:128b/16B) */
+
+typedef struct hwrm_queue_adptv_qos_rx_feature_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+} hwrm_queue_adptv_qos_rx_feature_qcfg_input_t, *phwrm_queue_adptv_qos_rx_feature_qcfg_input_t;
+
+/* hwrm_queue_adptv_qos_rx_feature_qcfg_output (size:128b/16B) */
+
+typedef struct hwrm_queue_adptv_qos_rx_feature_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/*
+	 * Bitmask indicating which RX CoS queues are enabled or disabled.
+	 *
+	 * Each bit represents a specific queue where bit 0 represents
+	 * queue 0 and bit 7 represents queue 7.
+	 * A value of 0 indicates that the queue is not enabled.
+	 * A value of 1 indicates that the queue is enabled.
+	 */
+	uint8_t	queue_enable;
+	/* If set to 1, then the queue is enabled. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID0_ENABLE	UINT32_C(0x1)
+	/* Queue is disabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID0_ENABLE_DISABLED  UINT32_C(0x0)
+	/* Queue is enabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID0_ENABLE_ENABLED   UINT32_C(0x1)
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID0_ENABLE_LAST	HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID0_ENABLE_ENABLED
+	/* If set to 1, then the queue is enabled. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID1_ENABLE	UINT32_C(0x2)
+	/* Queue is disabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID1_ENABLE_DISABLED  (UINT32_C(0x0) << 1)
+	/* Queue is enabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID1_ENABLE_ENABLED   (UINT32_C(0x1) << 1)
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID1_ENABLE_LAST	HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID1_ENABLE_ENABLED
+	/* If set to 1, then the queue is enabled. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID2_ENABLE	UINT32_C(0x4)
+	/* Queue is disabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID2_ENABLE_DISABLED  (UINT32_C(0x0) << 2)
+	/* Queue is enabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID2_ENABLE_ENABLED   (UINT32_C(0x1) << 2)
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID2_ENABLE_LAST	HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID2_ENABLE_ENABLED
+	/* If set to 1, then the queue is enabled. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID3_ENABLE	UINT32_C(0x8)
+	/* Queue is disabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID3_ENABLE_DISABLED  (UINT32_C(0x0) << 3)
+	/* Queue is enabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID3_ENABLE_ENABLED   (UINT32_C(0x1) << 3)
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID3_ENABLE_LAST	HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID3_ENABLE_ENABLED
+	/* If set to 1, then the queue is enabled. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID4_ENABLE	UINT32_C(0x10)
+	/* Queue is disabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID4_ENABLE_DISABLED  (UINT32_C(0x0) << 4)
+	/* Queue is enabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID4_ENABLE_ENABLED   (UINT32_C(0x1) << 4)
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID4_ENABLE_LAST	HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID4_ENABLE_ENABLED
+	/* If set to 1, then the queue is enabled. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID5_ENABLE	UINT32_C(0x20)
+	/* Queue is disabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID5_ENABLE_DISABLED  (UINT32_C(0x0) << 5)
+	/* Queue is enabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID5_ENABLE_ENABLED   (UINT32_C(0x1) << 5)
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID5_ENABLE_LAST	HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID5_ENABLE_ENABLED
+	/* If set to 1, then the queue is enabled. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID6_ENABLE	UINT32_C(0x40)
+	/* Queue is disabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID6_ENABLE_DISABLED  (UINT32_C(0x0) << 6)
+	/* Queue is enabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID6_ENABLE_ENABLED   (UINT32_C(0x1) << 6)
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID6_ENABLE_LAST	HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID6_ENABLE_ENABLED
+	/* If set to 1, then the queue is enabled. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID7_ENABLE	UINT32_C(0x80)
+	/* Queue is disabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID7_ENABLE_DISABLED  (UINT32_C(0x0) << 7)
+	/* Queue is enabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID7_ENABLE_ENABLED   (UINT32_C(0x1) << 7)
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID7_ENABLE_LAST	HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID7_ENABLE_ENABLED
+	/*
+	 * Bitmask indicating which CoS queues are lossy or lossless.
+	 * This setting is kept same across Rx and Tx directions, despite
+	 * the name mentioning only Rx. Each bit represents a specific queue
+	 * where bit 0 represents queue 0 and bit 7 represents queue 7.
+	 * A value of 0 indicates that the queue is lossy.
+	 * A value of 1 indicates that the queue is lossless.
+	 */
+	uint8_t	queue_mode;
+	/* If set to 0, then the queue is lossy, else lossless. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID0_MODE	UINT32_C(0x1)
+	/* Lossy (best-effort). */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID0_MODE_LOSSY	UINT32_C(0x0)
+	/* Lossless. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID0_MODE_LOSSLESS  UINT32_C(0x1)
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID0_MODE_LAST	HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID0_MODE_LOSSLESS
+	/* If set to 0, then the queue is lossy, else lossless. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID1_MODE	UINT32_C(0x2)
+	/* Lossy (best-effort). */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID1_MODE_LOSSY	(UINT32_C(0x0) << 1)
+	/* Lossless. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID1_MODE_LOSSLESS  (UINT32_C(0x1) << 1)
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID1_MODE_LAST	HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID1_MODE_LOSSLESS
+	/* If set to 0, then the queue is lossy, else lossless. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID2_MODE	UINT32_C(0x4)
+	/* Lossy (best-effort). */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID2_MODE_LOSSY	(UINT32_C(0x0) << 2)
+	/* Lossless. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID2_MODE_LOSSLESS  (UINT32_C(0x1) << 2)
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID2_MODE_LAST	HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID2_MODE_LOSSLESS
+	/* If set to 0, then the queue is lossy, else lossless. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID3_MODE	UINT32_C(0x8)
+	/* Lossy (best-effort). */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID3_MODE_LOSSY	(UINT32_C(0x0) << 3)
+	/* Lossless. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID3_MODE_LOSSLESS  (UINT32_C(0x1) << 3)
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID3_MODE_LAST	HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID3_MODE_LOSSLESS
+	/* If set to 0, then the queue is lossy, else lossless. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID4_MODE	UINT32_C(0x10)
+	/* Lossy (best-effort). */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID4_MODE_LOSSY	(UINT32_C(0x0) << 4)
+	/* Lossless. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID4_MODE_LOSSLESS  (UINT32_C(0x1) << 4)
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID4_MODE_LAST	HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID4_MODE_LOSSLESS
+	/* If set to 0, then the queue is lossy, else lossless. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID5_MODE	UINT32_C(0x20)
+	/* Lossy (best-effort). */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID5_MODE_LOSSY	(UINT32_C(0x0) << 5)
+	/* Lossless. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID5_MODE_LOSSLESS  (UINT32_C(0x1) << 5)
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID5_MODE_LAST	HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID5_MODE_LOSSLESS
+	/* If set to 0, then the queue is lossy, else lossless. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID6_MODE	UINT32_C(0x40)
+	/* Lossy (best-effort). */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID6_MODE_LOSSY	(UINT32_C(0x0) << 6)
+	/* Lossless. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID6_MODE_LOSSLESS  (UINT32_C(0x1) << 6)
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID6_MODE_LAST	HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID6_MODE_LOSSLESS
+	/* If set to 0, then the queue is lossy, else lossless. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID7_MODE	UINT32_C(0x80)
+	/* Lossy (best-effort). */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID7_MODE_LOSSY	(UINT32_C(0x0) << 7)
+	/* Lossless. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID7_MODE_LOSSLESS  (UINT32_C(0x1) << 7)
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID7_MODE_LAST	HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_QCFG_OUTPUT_QUEUE_MODE_QID7_MODE_LOSSLESS
+	uint8_t	unused_0[5];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_queue_adptv_qos_rx_feature_qcfg_output_t, *phwrm_queue_adptv_qos_rx_feature_qcfg_output_t;
+
+/***************************************
+ * hwrm_queue_adptv_qos_rx_feature_cfg *
+ ***************************************/
+
+
+/* hwrm_queue_adptv_qos_rx_feature_cfg_input (size:192b/24B) */
+
+typedef struct hwrm_queue_adptv_qos_rx_feature_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	enables;
+	/* This bit must be '1' for the queue_enable field to be configured. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_ENABLES_QUEUE_ENABLE	UINT32_C(0x1)
+	/* This bit must be '1' for the queue_mode field to be configured. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_ENABLES_QUEUE_MODE	UINT32_C(0x2)
+	/*
+	 * Bitmask indicating which RX CoS queues are enabled or disabled.
+	 *
+	 * Each bit represents a specific queue where bit 0 represents
+	 * queue 0 and bit 7 represents queue 7.
+	 * A value of 0 indicates that the queue is not enabled.
+	 * A value of 1 indicates that the queue is enabled.
+	 */
+	uint8_t	queue_enable;
+	/* If set to 1, then the queue is enabled. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID0_ENABLE	UINT32_C(0x1)
+	/* Queue is disabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID0_ENABLE_DISABLED  UINT32_C(0x0)
+	/* Queue is enabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID0_ENABLE_ENABLED   UINT32_C(0x1)
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID0_ENABLE_LAST	HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID0_ENABLE_ENABLED
+	/* If set to 1, then the queue is enabled. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID1_ENABLE	UINT32_C(0x2)
+	/* Queue is disabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID1_ENABLE_DISABLED  (UINT32_C(0x0) << 1)
+	/* Queue is enabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID1_ENABLE_ENABLED   (UINT32_C(0x1) << 1)
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID1_ENABLE_LAST	HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID1_ENABLE_ENABLED
+	/* If set to 1, then the queue is enabled. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID2_ENABLE	UINT32_C(0x4)
+	/* Queue is disabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID2_ENABLE_DISABLED  (UINT32_C(0x0) << 2)
+	/* Queue is enabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID2_ENABLE_ENABLED   (UINT32_C(0x1) << 2)
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID2_ENABLE_LAST	HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID2_ENABLE_ENABLED
+	/* If set to 1, then the queue is enabled. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID3_ENABLE	UINT32_C(0x8)
+	/* Queue is disabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID3_ENABLE_DISABLED  (UINT32_C(0x0) << 3)
+	/* Queue is enabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID3_ENABLE_ENABLED   (UINT32_C(0x1) << 3)
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID3_ENABLE_LAST	HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID3_ENABLE_ENABLED
+	/* If set to 1, then the queue is enabled. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID4_ENABLE	UINT32_C(0x10)
+	/* Queue is disabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID4_ENABLE_DISABLED  (UINT32_C(0x0) << 4)
+	/* Queue is enabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID4_ENABLE_ENABLED   (UINT32_C(0x1) << 4)
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID4_ENABLE_LAST	HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID4_ENABLE_ENABLED
+	/* If set to 1, then the queue is enabled. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID5_ENABLE	UINT32_C(0x20)
+	/* Queue is disabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID5_ENABLE_DISABLED  (UINT32_C(0x0) << 5)
+	/* Queue is enabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID5_ENABLE_ENABLED   (UINT32_C(0x1) << 5)
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID5_ENABLE_LAST	HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID5_ENABLE_ENABLED
+	/* If set to 1, then the queue is enabled. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID6_ENABLE	UINT32_C(0x40)
+	/* Queue is disabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID6_ENABLE_DISABLED  (UINT32_C(0x0) << 6)
+	/* Queue is enabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID6_ENABLE_ENABLED   (UINT32_C(0x1) << 6)
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID6_ENABLE_LAST	HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID6_ENABLE_ENABLED
+	/* If set to 1, then the queue is enabled. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID7_ENABLE	UINT32_C(0x80)
+	/* Queue is disabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID7_ENABLE_DISABLED  (UINT32_C(0x0) << 7)
+	/* Queue is enabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID7_ENABLE_ENABLED   (UINT32_C(0x1) << 7)
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID7_ENABLE_LAST	HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID7_ENABLE_ENABLED
+	/*
+	 * Bitmask indicating which CoS queues are lossy or lossless.
+	 * This setting is kept symmetric (or same) across Tx and Rx.
+	 * Each bit represents a specific queue where bit 0 represents
+	 * queue 0 and bit 7 represents queue 7.
+	 * A value of 0 indicates that the queue is lossy.
+	 * A value of 1 indicates that the queue is lossless.
+	 */
+	uint8_t	queue_mode;
+	/* If set to 0, then the queue is lossy, else lossless. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID0_MODE	UINT32_C(0x1)
+	/* Lossy (best-effort). */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID0_MODE_LOSSY	UINT32_C(0x0)
+	/* Lossless. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID0_MODE_LOSSLESS  UINT32_C(0x1)
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID0_MODE_LAST	HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID0_MODE_LOSSLESS
+	/* If set to 0, then the queue is lossy, else lossless. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID1_MODE	UINT32_C(0x2)
+	/* Lossy (best-effort). */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID1_MODE_LOSSY	(UINT32_C(0x0) << 1)
+	/* Lossless. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID1_MODE_LOSSLESS  (UINT32_C(0x1) << 1)
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID1_MODE_LAST	HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID1_MODE_LOSSLESS
+	/* If set to 0, then the queue is lossy, else lossless. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID2_MODE	UINT32_C(0x4)
+	/* Lossy (best-effort). */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID2_MODE_LOSSY	(UINT32_C(0x0) << 2)
+	/* Lossless. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID2_MODE_LOSSLESS  (UINT32_C(0x1) << 2)
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID2_MODE_LAST	HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID2_MODE_LOSSLESS
+	/* If set to 0, then the queue is lossy, else lossless. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID3_MODE	UINT32_C(0x8)
+	/* Lossy (best-effort). */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID3_MODE_LOSSY	(UINT32_C(0x0) << 3)
+	/* Lossless. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID3_MODE_LOSSLESS  (UINT32_C(0x1) << 3)
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID3_MODE_LAST	HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID3_MODE_LOSSLESS
+	/* If set to 0, then the queue is lossy, else lossless. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID4_MODE	UINT32_C(0x10)
+	/* Lossy (best-effort). */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID4_MODE_LOSSY	(UINT32_C(0x0) << 4)
+	/* Lossless. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID4_MODE_LOSSLESS  (UINT32_C(0x1) << 4)
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID4_MODE_LAST	HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID4_MODE_LOSSLESS
+	/* If set to 0, then the queue is lossy, else lossless. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID5_MODE	UINT32_C(0x20)
+	/* Lossy (best-effort). */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID5_MODE_LOSSY	(UINT32_C(0x0) << 5)
+	/* Lossless. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID5_MODE_LOSSLESS  (UINT32_C(0x1) << 5)
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID5_MODE_LAST	HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID5_MODE_LOSSLESS
+	/* If set to 0, then the queue is lossy, else lossless. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID6_MODE	UINT32_C(0x40)
+	/* Lossy (best-effort). */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID6_MODE_LOSSY	(UINT32_C(0x0) << 6)
+	/* Lossless. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID6_MODE_LOSSLESS  (UINT32_C(0x1) << 6)
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID6_MODE_LAST	HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID6_MODE_LOSSLESS
+	/* If set to 0, then the queue is lossy, else lossless. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID7_MODE	UINT32_C(0x80)
+	/* Lossy (best-effort). */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID7_MODE_LOSSY	(UINT32_C(0x0) << 7)
+	/* Lossless. */
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID7_MODE_LOSSLESS  (UINT32_C(0x1) << 7)
+		#define HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID7_MODE_LAST	HWRM_QUEUE_ADPTV_QOS_RX_FEATURE_CFG_INPUT_QUEUE_MODE_QID7_MODE_LOSSLESS
+	uint8_t	unused_0[2];
+} hwrm_queue_adptv_qos_rx_feature_cfg_input_t, *phwrm_queue_adptv_qos_rx_feature_cfg_input_t;
+
+/* hwrm_queue_adptv_qos_rx_feature_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_queue_adptv_qos_rx_feature_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_queue_adptv_qos_rx_feature_cfg_output_t, *phwrm_queue_adptv_qos_rx_feature_cfg_output_t;
+
+/****************************************
+ * hwrm_queue_adptv_qos_tx_feature_qcfg *
+ ****************************************/
+
+
+/* hwrm_queue_adptv_qos_tx_feature_qcfg_input (size:128b/16B) */
+
+typedef struct hwrm_queue_adptv_qos_tx_feature_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+} hwrm_queue_adptv_qos_tx_feature_qcfg_input_t, *phwrm_queue_adptv_qos_tx_feature_qcfg_input_t;
+
+/* hwrm_queue_adptv_qos_tx_feature_qcfg_output (size:128b/16B) */
+
+typedef struct hwrm_queue_adptv_qos_tx_feature_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/*
+	 * Bitmask indicating which TX CoS queues are enabled or disabled.
+	 *
+	 * Each bit represents a specific queue where bit 0 represents
+	 * queue 0 and bit 7 represents queue 7.
+	 * A value of 0 indicates that the queue is not enabled.
+	 * A value of 1 indicates that the queue is enabled.
+	 */
+	uint8_t	queue_enable;
+	/* If set to 1, then the queue is enabled. */
+	#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID0_ENABLE	UINT32_C(0x1)
+	/* Queue is disabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID0_ENABLE_DISABLED  UINT32_C(0x0)
+	/* Queue is enabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID0_ENABLE_ENABLED   UINT32_C(0x1)
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID0_ENABLE_LAST	HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID0_ENABLE_ENABLED
+	/* If set to 1, then the queue is enabled. */
+	#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID1_ENABLE	UINT32_C(0x2)
+	/* Queue is disabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID1_ENABLE_DISABLED  (UINT32_C(0x0) << 1)
+	/* Queue is enabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID1_ENABLE_ENABLED   (UINT32_C(0x1) << 1)
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID1_ENABLE_LAST	HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID1_ENABLE_ENABLED
+	/* If set to 1, then the queue is enabled. */
+	#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID2_ENABLE	UINT32_C(0x4)
+	/* Queue is disabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID2_ENABLE_DISABLED  (UINT32_C(0x0) << 2)
+	/* Queue is enabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID2_ENABLE_ENABLED   (UINT32_C(0x1) << 2)
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID2_ENABLE_LAST	HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID2_ENABLE_ENABLED
+	/* If set to 1, then the queue is enabled. */
+	#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID3_ENABLE	UINT32_C(0x8)
+	/* Queue is disabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID3_ENABLE_DISABLED  (UINT32_C(0x0) << 3)
+	/* Queue is enabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID3_ENABLE_ENABLED   (UINT32_C(0x1) << 3)
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID3_ENABLE_LAST	HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID3_ENABLE_ENABLED
+	/* If set to 1, then the queue is enabled. */
+	#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID4_ENABLE	UINT32_C(0x10)
+	/* Queue is disabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID4_ENABLE_DISABLED  (UINT32_C(0x0) << 4)
+	/* Queue is enabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID4_ENABLE_ENABLED   (UINT32_C(0x1) << 4)
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID4_ENABLE_LAST	HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID4_ENABLE_ENABLED
+	/* If set to 1, then the queue is enabled. */
+	#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID5_ENABLE	UINT32_C(0x20)
+	/* Queue is disabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID5_ENABLE_DISABLED  (UINT32_C(0x0) << 5)
+	/* Queue is enabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID5_ENABLE_ENABLED   (UINT32_C(0x1) << 5)
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID5_ENABLE_LAST	HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID5_ENABLE_ENABLED
+	/* If set to 1, then the queue is enabled. */
+	#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID6_ENABLE	UINT32_C(0x40)
+	/* Queue is disabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID6_ENABLE_DISABLED  (UINT32_C(0x0) << 6)
+	/* Queue is enabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID6_ENABLE_ENABLED   (UINT32_C(0x1) << 6)
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID6_ENABLE_LAST	HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID6_ENABLE_ENABLED
+	/* If set to 1, then the queue is enabled. */
+	#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID7_ENABLE	UINT32_C(0x80)
+	/* Queue is disabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID7_ENABLE_DISABLED  (UINT32_C(0x0) << 7)
+	/* Queue is enabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID7_ENABLE_ENABLED   (UINT32_C(0x1) << 7)
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID7_ENABLE_LAST	HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_QCFG_OUTPUT_QUEUE_ENABLE_QID7_ENABLE_ENABLED
+	uint8_t	unused_0[6];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_queue_adptv_qos_tx_feature_qcfg_output_t, *phwrm_queue_adptv_qos_tx_feature_qcfg_output_t;
+
+/***************************************
+ * hwrm_queue_adptv_qos_tx_feature_cfg *
+ ***************************************/
+
+
+/* hwrm_queue_adptv_qos_tx_feature_cfg_input (size:192b/24B) */
+
+typedef struct hwrm_queue_adptv_qos_tx_feature_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	enables;
+	/* This bit must be '1' for the queue_enable field to be configured. */
+	#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_ENABLES_QUEUE_ENABLE	UINT32_C(0x1)
+	/*
+	 * Bitmask indicating which TX CoS queues are enabled or disabled.
+	 *
+	 * Each bit represents a specific queue where bit 0 represents
+	 * queue 0 and bit 7 represents queue 7.
+	 * A value of 0 indicates that the queue is not enabled.
+	 * A value of 1 indicates that the queue is enabled.
+	 */
+	uint8_t	queue_enable;
+	/* If set to 1, then the queue is enabled. */
+	#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID0_ENABLE	UINT32_C(0x1)
+	/* Queue is disabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID0_ENABLE_DISABLED  UINT32_C(0x0)
+	/* Queue is enabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID0_ENABLE_ENABLED   UINT32_C(0x1)
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID0_ENABLE_LAST	HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID0_ENABLE_ENABLED
+	/* If set to 1, then the queue is enabled. */
+	#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID1_ENABLE	UINT32_C(0x2)
+	/* Queue is disabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID1_ENABLE_DISABLED  (UINT32_C(0x0) << 1)
+	/* Queue is enabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID1_ENABLE_ENABLED   (UINT32_C(0x1) << 1)
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID1_ENABLE_LAST	HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID1_ENABLE_ENABLED
+	/* If set to 1, then the queue is enabled. */
+	#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID2_ENABLE	UINT32_C(0x4)
+	/* Queue is disabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID2_ENABLE_DISABLED  (UINT32_C(0x0) << 2)
+	/* Queue is enabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID2_ENABLE_ENABLED   (UINT32_C(0x1) << 2)
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID2_ENABLE_LAST	HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID2_ENABLE_ENABLED
+	/* If set to 1, then the queue is enabled. */
+	#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID3_ENABLE	UINT32_C(0x8)
+	/* Queue is disabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID3_ENABLE_DISABLED  (UINT32_C(0x0) << 3)
+	/* Queue is enabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID3_ENABLE_ENABLED   (UINT32_C(0x1) << 3)
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID3_ENABLE_LAST	HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID3_ENABLE_ENABLED
+	/* If set to 1, then the queue is enabled. */
+	#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID4_ENABLE	UINT32_C(0x10)
+	/* Queue is disabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID4_ENABLE_DISABLED  (UINT32_C(0x0) << 4)
+	/* Queue is enabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID4_ENABLE_ENABLED   (UINT32_C(0x1) << 4)
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID4_ENABLE_LAST	HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID4_ENABLE_ENABLED
+	/* If set to 1, then the queue is enabled. */
+	#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID5_ENABLE	UINT32_C(0x20)
+	/* Queue is disabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID5_ENABLE_DISABLED  (UINT32_C(0x0) << 5)
+	/* Queue is enabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID5_ENABLE_ENABLED   (UINT32_C(0x1) << 5)
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID5_ENABLE_LAST	HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID5_ENABLE_ENABLED
+	/* If set to 1, then the queue is enabled. */
+	#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID6_ENABLE	UINT32_C(0x40)
+	/* Queue is disabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID6_ENABLE_DISABLED  (UINT32_C(0x0) << 6)
+	/* Queue is enabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID6_ENABLE_ENABLED   (UINT32_C(0x1) << 6)
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID6_ENABLE_LAST	HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID6_ENABLE_ENABLED
+	/* If set to 1, then the queue is enabled. */
+	#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID7_ENABLE	UINT32_C(0x80)
+	/* Queue is disabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID7_ENABLE_DISABLED  (UINT32_C(0x0) << 7)
+	/* Queue is enabled. */
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID7_ENABLE_ENABLED   (UINT32_C(0x1) << 7)
+		#define HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID7_ENABLE_LAST	HWRM_QUEUE_ADPTV_QOS_TX_FEATURE_CFG_INPUT_QUEUE_ENABLE_QID7_ENABLE_ENABLED
+	uint8_t	unused_0[3];
+} hwrm_queue_adptv_qos_tx_feature_cfg_input_t, *phwrm_queue_adptv_qos_tx_feature_cfg_input_t;
+
+/* hwrm_queue_adptv_qos_tx_feature_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_queue_adptv_qos_tx_feature_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_queue_adptv_qos_tx_feature_cfg_output_t, *phwrm_queue_adptv_qos_tx_feature_cfg_output_t;
+
+/********************
+ * hwrm_queue_qcaps *
+ ********************/
+
+
+/* hwrm_queue_qcaps_input (size:128b/16B) */
+
+typedef struct hwrm_queue_qcaps_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+} hwrm_queue_qcaps_input_t, *phwrm_queue_qcaps_input_t;
+
+/* hwrm_queue_qcaps_output (size:256b/32B) */
+
+typedef struct hwrm_queue_qcaps_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Adaptive QoS RX feature parameter capability flags. */
+	uint32_t	rx_feature_params;
+	/*
+	 * When this bit is '1' the capability to configure queue_enable
+	 * is supported.
+	 * If set to '0', then the capability to configure queue_enable
+	 * is not supported.
+	 */
+	#define HWRM_QUEUE_QCAPS_OUTPUT_RX_FEATURE_PARAMS_QUEUE_ENABLE_CAP	UINT32_C(0x1)
+	/*
+	 * When this bit is '1' the capability to configure queue_mode
+	 * is supported.
+	 * If set to '0', then the capability to configure queue_mode
+	 * is not supported.
+	 */
+	#define HWRM_QUEUE_QCAPS_OUTPUT_RX_FEATURE_PARAMS_QUEUE_MODE_CAP	UINT32_C(0x2)
+	/* Adaptive QoS TX feature parameter capability flags. */
+	uint32_t	tx_feature_params;
+	/*
+	 * When this bit is '1' the capability to configure queue_enable
+	 * is supported.
+	 * If set to '0', then the capability to configure queue_enable
+	 * is not supported.
+	 */
+	#define HWRM_QUEUE_QCAPS_OUTPUT_TX_FEATURE_PARAMS_QUEUE_ENABLE_CAP	UINT32_C(0x1)
+	/*
+	 * The maximum number of queues that can be configured on this device.
+	 * Valid values range from 1 through 8.
+	 */
+	uint8_t	max_configurable_queues;
+	uint8_t	unused_0[3];
+	/* Adaptive QoS RX tuning parameter capability flags. */
+	uint32_t	rx_tuning_params;
+	/*
+	 * When this bit is '1' the capability to configure the option
+	 * is supported.
+	 * If set to '0', then the capability to configure the option
+	 * is not supported.
+	 */
+	#define HWRM_QUEUE_QCAPS_OUTPUT_RX_TUNING_PARAMS_WFQ_COST_CAP			UINT32_C(0x1)
+	/*
+	 * When this bit is '1' the capability to configure the option
+	 * is supported.
+	 * If set to '0', then the capability to configure the option
+	 * is not supported.
+	 */
+	#define HWRM_QUEUE_QCAPS_OUTPUT_RX_TUNING_PARAMS_WFQ_UPPER_FACTOR_CAP		UINT32_C(0x2)
+	/*
+	 * When this bit is '1' the capability to configure the option
+	 * is supported.
+	 * If set to '0', then the capability to configure the option
+	 * is not supported.
+	 */
+	#define HWRM_QUEUE_QCAPS_OUTPUT_RX_TUNING_PARAMS_HYST_WINDOW_SIZE_FACTOR_CAP	UINT32_C(0x4)
+	/*
+	 * When this bit is '1' the capability to configure the option
+	 * is supported.
+	 * If set to '0', then the capability to configure the option
+	 * is not supported.
+	 */
+	#define HWRM_QUEUE_QCAPS_OUTPUT_RX_TUNING_PARAMS_PCIE_BW_EFF_CAP		UINT32_C(0x8)
+	/*
+	 * When this bit is '1' the capability to configure the option
+	 * is supported.
+	 * If set to '0', then the capability to configure the option
+	 * is not supported.
+	 */
+	#define HWRM_QUEUE_QCAPS_OUTPUT_RX_TUNING_PARAMS_XOFF_HEADROOM_FACTOR_CAP	UINT32_C(0x10)
+	/*
+	 * When this bit is '1' the capability to configure the option
+	 * is supported.
+	 * If set to '0', then the capability to configure the option
+	 * is not supported.
+	 */
+	#define HWRM_QUEUE_QCAPS_OUTPUT_RX_TUNING_PARAMS_L2_MIN_LATENCY_CAP		UINT32_C(0x20)
+	/*
+	 * When this bit is '1' the capability to configure the option
+	 * is supported.
+	 * If set to '0', then the capability to configure the option
+	 * is not supported.
+	 */
+	#define HWRM_QUEUE_QCAPS_OUTPUT_RX_TUNING_PARAMS_L2_MAX_LATENCY_CAP		UINT32_C(0x40)
+	/*
+	 * When this bit is '1' the capability to configure the option
+	 * is supported.
+	 * If set to '0', then the capability to configure the option
+	 * is not supported.
+	 */
+	#define HWRM_QUEUE_QCAPS_OUTPUT_RX_TUNING_PARAMS_ROCE_MIN_LATENCY_CAP		UINT32_C(0x80)
+	/*
+	 * When this bit is '1' the capability to configure the option
+	 * is supported.
+	 * If set to '0', then the capability to configure the option
+	 * is not supported.
+	 */
+	#define HWRM_QUEUE_QCAPS_OUTPUT_RX_TUNING_PARAMS_ROCE_MAX_LATENCY_CAP		UINT32_C(0x100)
+	/*
+	 * When this bit is '1' the capability to configure the option
+	 * is supported.
+	 * If set to '0', then the capability to configure the option
+	 * is not supported.
+	 */
+	#define HWRM_QUEUE_QCAPS_OUTPUT_RX_TUNING_PARAMS_L2_PIPE_COS_LATENCY_CAP	UINT32_C(0x200)
+	/*
+	 * When this bit is '1' the capability to configure the option
+	 * is supported.
+	 * If set to '0', then the capability to configure the option
+	 * is not supported.
+	 */
+	#define HWRM_QUEUE_QCAPS_OUTPUT_RX_TUNING_PARAMS_ROCE_PIPE_COS_LATENCY_CAP	UINT32_C(0x400)
+	/*
+	 * When this bit is '1' the capability to configure the option
+	 * is supported.
+	 * If set to '0', then the capability to configure the option
+	 * is not supported.
+	 */
+	#define HWRM_QUEUE_QCAPS_OUTPUT_RX_TUNING_PARAMS_COS_SHARED_MIN_RATIO_CAP	UINT32_C(0x800)
+	/*
+	 * When this bit is '1' the capability to configure the option
+	 * is supported.
+	 * If set to '0', then the capability to configure the option
+	 * is not supported.
+	 */
+	#define HWRM_QUEUE_QCAPS_OUTPUT_RX_TUNING_PARAMS_RSVD_CELLS_LIMIT_RATIO_CAP	UINT32_C(0x1000)
+	/*
+	 * When this bit is '1' the capability to configure the option
+	 * is supported.
+	 * If set to '0', then the capability to configure the option
+	 * is not supported.
+	 */
+	#define HWRM_QUEUE_QCAPS_OUTPUT_RX_TUNING_PARAMS_SHAPER_REFILL_TIMER_CAP	UINT32_C(0x2000)
+	/* Adaptive QoS TX tuning parameter capability flags. */
+	uint32_t	tx_tuning_params;
+	/*
+	 * When this bit is '1' the capability to configure the option
+	 * is supported.
+	 * If set to '0', then the capability to configure the option
+	 * is not supported.
+	 */
+	#define HWRM_QUEUE_QCAPS_OUTPUT_TX_TUNING_PARAMS_WFQ_COST_CAP			UINT32_C(0x1)
+	/*
+	 * When this bit is '1' the capability to configure the option
+	 * is supported.
+	 * If set to '0', then the capability to configure the option
+	 * is not supported.
+	 */
+	#define HWRM_QUEUE_QCAPS_OUTPUT_TX_TUNING_PARAMS_WFQ_UPPER_FACTOR_CAP		UINT32_C(0x2)
+	/*
+	 * When this bit is '1' the capability to configure the option
+	 * is supported.
+	 * If set to '0', then the capability to configure the option
+	 * is not supported.
+	 */
+	#define HWRM_QUEUE_QCAPS_OUTPUT_TX_TUNING_PARAMS_HYST_WINDOW_SIZE_FACTOR_CAP	UINT32_C(0x4)
+	/*
+	 * When this bit is '1' the capability to configure the option
+	 * is supported.
+	 * If set to '0', then the capability to configure the option
+	 * is not supported.
+	 */
+	#define HWRM_QUEUE_QCAPS_OUTPUT_TX_TUNING_PARAMS_RSVD_CELLS_LIMIT_RATIO_CAP	UINT32_C(0x8)
+	/*
+	 * When this bit is '1' the capability to configure the option
+	 * is supported.
+	 * If set to '0', then the capability to configure the option
+	 * is not supported.
+	 */
+	#define HWRM_QUEUE_QCAPS_OUTPUT_TX_TUNING_PARAMS_L2_MIN_LATENCY_CAP		UINT32_C(0x10)
+	/*
+	 * When this bit is '1' the capability to configure the option
+	 * is supported.
+	 * If set to '0', then the capability to configure the option
+	 * is not supported.
+	 */
+	#define HWRM_QUEUE_QCAPS_OUTPUT_TX_TUNING_PARAMS_L2_MAX_LATENCY_CAP		UINT32_C(0x20)
+	/*
+	 * When this bit is '1' the capability to configure the option
+	 * is supported.
+	 * If set to '0', then the capability to configure the option
+	 * is not supported.
+	 */
+	#define HWRM_QUEUE_QCAPS_OUTPUT_TX_TUNING_PARAMS_ROCE_MIN_LATENCY_CAP		UINT32_C(0x40)
+	/*
+	 * When this bit is '1' the capability to configure the option
+	 * is supported.
+	 * If set to '0', then the capability to configure the option
+	 * is not supported.
+	 */
+	#define HWRM_QUEUE_QCAPS_OUTPUT_TX_TUNING_PARAMS_ROCE_MAX_LATENCY_CAP		UINT32_C(0x80)
+	/*
+	 * When this bit is '1' the capability to configure the option
+	 * is supported.
+	 * If set to '0', then the capability to configure the option
+	 * is not supported.
+	 */
+	#define HWRM_QUEUE_QCAPS_OUTPUT_TX_TUNING_PARAMS_MAX_TBM_CELLS_PRERESERVED_CAP	UINT32_C(0x100)
+	/*
+	 * When this bit is '1' the capability to configure the option
+	 * is supported.
+	 * If set to '0', then the capability to configure the option
+	 * is not supported.
+	 */
+	#define HWRM_QUEUE_QCAPS_OUTPUT_TX_TUNING_PARAMS_SHAPER_REFILL_TIMER_CAP	UINT32_C(0x200)
+	uint8_t	unused_1[3];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_queue_qcaps_output_t, *phwrm_queue_qcaps_output_t;
+
+/***************************************
+ * hwrm_queue_adptv_qos_rx_tuning_qcfg *
+ ***************************************/
+
+
+/* hwrm_queue_adptv_qos_rx_tuning_qcfg_input (size:128b/16B) */
+
+typedef struct hwrm_queue_adptv_qos_rx_tuning_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+} hwrm_queue_adptv_qos_rx_tuning_qcfg_input_t, *phwrm_queue_adptv_qos_rx_tuning_qcfg_input_t;
+
+/* hwrm_queue_adptv_qos_rx_tuning_qcfg_output (size:576b/72B) */
+
+typedef struct hwrm_queue_adptv_qos_rx_tuning_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Indicates max credit as required by hardware. */
+	uint32_t	wfq_cost;
+	/*
+	 * Specifies a factor that determines the upper bound for each
+	 * cos_wfq_credit_weight.
+	 */
+	uint32_t	wfq_upper_factor;
+	/*
+	 * The algorithm multiplies this factor by the MRU size to compute the
+	 * hysteresis window size which in turn is used in deassert
+	 * threshold calculations.
+	 */
+	uint32_t	hyst_window_size_factor;
+	/*
+	 * Specifies PCIe BW efficiency in the range of 0-100%. System
+	 * characterization determines the value of this parameter. A value of
+	 * less than 100% accounts for internal PCIe over-subscription. The
+	 * algorithm uses this parameter to determine the PCIe BW available
+	 * for transferring received packets to the host.
+	 */
+	uint32_t	pcie_bw_eff;
+	/* Scales the number of cells for xoff. */
+	uint32_t	xoff_headroom_factor;
+	/*
+	 * It is used to calculate the number of reserved cells for cos queues
+	 * configured for L2. Its value is derived from system
+	 * characterization.
+	 */
+	uint32_t	l2_min_latency;
+	/*
+	 * It is used to calculate the number of shared cells for cos queues
+	 * configured for L2. Its value is derived from system
+	 * characterization.
+	 */
+	uint32_t	l2_max_latency;
+	/*
+	 * It is used to calculate the number of reserved cells for cos queues
+	 * configured for RoCE. Its value is derived from system
+	 * characterization.
+	 */
+	uint32_t	roce_min_latency;
+	/*
+	 * It is used to calculate the number of shared cells for cos queues
+	 * configured for RoCE. Its value is derived from system
+	 * characterization.
+	 */
+	uint32_t	roce_max_latency;
+	/*
+	 * The algorithm uses this parameter to calculate the number of cells
+	 * to be excluded from the total buffer pool to account for the
+	 * latency of pipeline post RE_DEC to PCIe block. Its value is derived
+	 * from system characterization.
+	 */
+	uint32_t	l2_pipe_cos_latency;
+	/*
+	 * The algorithm uses this parameter to calculate the number of cells
+	 * to be excluded from the total buffer pool to account for the
+	 * latency of pipeline post RE_DEC to PCIe block. Its value is derived
+	 * from system characterization.
+	 */
+	uint32_t	roce_pipe_cos_latency;
+	/* Sets the minimum number of shared cells each cos queue can have. */
+	uint32_t	cos_shared_min_ratio;
+	/*
+	 * The parameter limits the total reserved cells. If the computed
+	 * total reserved cells becomes larger than rsvd_cells_limit_ratio x
+	 * port_cells_avail, then the reserved cells are set to the limit
+	 * value. Its range of values is 0-50%.
+	 */
+	uint32_t	rsvd_cells_limit_ratio;
+	/*
+	 * This parameter is used to compute the time interval for
+	 * replenishing the shaper credit buckets for all RX cos queues.
+	 */
+	uint32_t	shaper_refill_timer;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_queue_adptv_qos_rx_tuning_qcfg_output_t, *phwrm_queue_adptv_qos_rx_tuning_qcfg_output_t;
+
+/**************************************
+ * hwrm_queue_adptv_qos_rx_tuning_cfg *
+ **************************************/
+
+
+/* hwrm_queue_adptv_qos_rx_tuning_cfg_input (size:640b/80B) */
+
+typedef struct hwrm_queue_adptv_qos_rx_tuning_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	enables;
+	/* This bit must be '1' for the option to be configured. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_TUNING_CFG_INPUT_ENABLES_WFQ_COST			UINT32_C(0x1)
+	/* This bit must be '1' for the option to be configured. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_TUNING_CFG_INPUT_ENABLES_WFQ_UPPER_FACTOR		UINT32_C(0x2)
+	/* This bit must be '1' for the option to be configured. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_TUNING_CFG_INPUT_ENABLES_HYST_WINDOW_SIZE_FACTOR	UINT32_C(0x4)
+	/* This bit must be '1' for the option to be configured. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_TUNING_CFG_INPUT_ENABLES_PCIE_BW_EFF		UINT32_C(0x8)
+	/* This bit must be '1' for the option to be configured. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_TUNING_CFG_INPUT_ENABLES_XOFF_HEADROOM_FACTOR	UINT32_C(0x10)
+	/* This bit must be '1' for the option to be configured. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_TUNING_CFG_INPUT_ENABLES_L2_MIN_LATENCY		UINT32_C(0x20)
+	/* This bit must be '1' for the option to be configured. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_TUNING_CFG_INPUT_ENABLES_L2_MAX_LATENCY		UINT32_C(0x40)
+	/* This bit must be '1' for the option to be configured. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_TUNING_CFG_INPUT_ENABLES_ROCE_MIN_LATENCY		UINT32_C(0x80)
+	/* This bit must be '1' for the option to be configured. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_TUNING_CFG_INPUT_ENABLES_ROCE_MAX_LATENCY		UINT32_C(0x100)
+	/* This bit must be '1' for the option to be configured. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_TUNING_CFG_INPUT_ENABLES_L2_PIPE_COS_LATENCY	UINT32_C(0x200)
+	/* This bit must be '1' for the option to be configured. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_TUNING_CFG_INPUT_ENABLES_ROCE_PIPE_COS_LATENCY	UINT32_C(0x400)
+	/* This bit must be '1' for the option to be configured. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_TUNING_CFG_INPUT_ENABLES_COS_SHARED_MIN_RATIO	UINT32_C(0x800)
+	/* This bit must be '1' for the option to be configured. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_TUNING_CFG_INPUT_ENABLES_RSVD_CELLS_LIMIT_RATIO	UINT32_C(0x1000)
+	/* This bit must be '1' for the option to be configured. */
+	#define HWRM_QUEUE_ADPTV_QOS_RX_TUNING_CFG_INPUT_ENABLES_SHAPER_REFILL_TIMER	UINT32_C(0x2000)
+	/* Indicates max credit as required by hardware. */
+	uint32_t	wfq_cost;
+	/*
+	 * Specifies a factor that determines the upper bound for each
+	 * cos_wfq_credit_weight.
+	 */
+	uint32_t	wfq_upper_factor;
+	/*
+	 * The algorithm multiplies this factor by the MRU size to compute the
+	 * hysteresis window size which in turn is used in deassert
+	 * threshold calculations.
+	 */
+	uint32_t	hyst_window_size_factor;
+	/*
+	 * Specifies PCIe BW efficiency in the range of 0-100%. System
+	 * characterization determines the value of this parameter. A value of
+	 * less than 100% accounts for internal PCIe over-subscription. The
+	 * algorithm uses this parameter to determine the PCIe BW available
+	 * for transferring received packets to the host.
+	 */
+	uint32_t	pcie_bw_eff;
+	/* Scales the number of cells for xoff. */
+	uint32_t	xoff_headroom_factor;
+	/*
+	 * It is used to calculate the number of reserved cells for cos queues
+	 * configured for L2. Its value is derived from system
+	 * characterization.
+	 */
+	uint32_t	l2_min_latency;
+	/*
+	 * It is used to calculate the number of shared cells for cos queues
+	 * configured for L2. Its value is derived from system
+	 * characterization.
+	 */
+	uint32_t	l2_max_latency;
+	/*
+	 * It is used to calculate the number of reserved cells for cos queues
+	 * configured for RoCE. Its value is derived from system
+	 * characterization.
+	 */
+	uint32_t	roce_min_latency;
+	/*
+	 * It is used to calculate the number of shared cells for cos queues
+	 * configured for RoCE. Its value is derived from system
+	 * characterization.
+	 */
+	uint32_t	roce_max_latency;
+	/*
+	 * The algorithm uses this parameter to calculate the number of cells
+	 * to be excluded from the total buffer pool to account for the
+	 * latency of pipeline post RE_DEC to PCIe block. Its value is derived
+	 * from system characterization.
+	 */
+	uint32_t	l2_pipe_cos_latency;
+	/*
+	 * The algorithm uses this parameter to calculate the number of cells
+	 * to be excluded from the total buffer pool to account for the
+	 * latency of pipeline post RE_DEC to PCIe block. Its value is derived
+	 * from system characterization.
+	 */
+	uint32_t	roce_pipe_cos_latency;
+	/* Sets the minimum number of shared cells each cos queue can have. */
+	uint32_t	cos_shared_min_ratio;
+	/*
+	 * The parameter limits the total reserved cells. If the computed
+	 * total reserved cells becomes larger than rsvd_cells_limit_ratio x
+	 * port_cells_avail, then the reserved cells are set to the limit
+	 * value. Its range of values is 0-50%.
+	 */
+	uint32_t	rsvd_cells_limit_ratio;
+	/*
+	 * This parameter is used to compute the time interval for
+	 * replenishing the shaper credit buckets for all RX cos queues.
+	 */
+	uint32_t	shaper_refill_timer;
+	uint8_t	unused_0[4];
+} hwrm_queue_adptv_qos_rx_tuning_cfg_input_t, *phwrm_queue_adptv_qos_rx_tuning_cfg_input_t;
+
+/* hwrm_queue_adptv_qos_rx_tuning_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_queue_adptv_qos_rx_tuning_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_queue_adptv_qos_rx_tuning_cfg_output_t, *phwrm_queue_adptv_qos_rx_tuning_cfg_output_t;
+
+/***************************************
+ * hwrm_queue_adptv_qos_tx_tuning_qcfg *
+ ***************************************/
+
+
+/* hwrm_queue_adptv_qos_tx_tuning_qcfg_input (size:128b/16B) */
+
+typedef struct hwrm_queue_adptv_qos_tx_tuning_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+} hwrm_queue_adptv_qos_tx_tuning_qcfg_input_t, *phwrm_queue_adptv_qos_tx_tuning_qcfg_input_t;
+
+/* hwrm_queue_adptv_qos_tx_tuning_qcfg_output (size:448b/56B) */
+
+typedef struct hwrm_queue_adptv_qos_tx_tuning_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Indicates max credit as required by hardware. */
+	uint32_t	wfq_cost;
+	/*
+	 * Specifies a factor that determines the upper bound for each
+	 * cos_wfq_credit_weight.
+	 */
+	uint32_t	wfq_upper_factor;
+	/*
+	 * The algorithm multiplies this factor by the MRU size to compute the
+	 * hysteresis window size which in turn is used in deassert
+	 * threshold calculations.
+	 */
+	uint32_t	hyst_window_size_factor;
+	/*
+	 * The parameter limits the total reserved cells. If the computed
+	 * total reserved cells becomes larger than rsvd_cells_limit_ratio x
+	 * port_cells_avail, then the reserved cells are set to the limit
+	 * value. Its range of values is 0-50%.
+	 */
+	uint32_t	rsvd_cells_limit_ratio;
+	/*
+	 * It is used to calculate the number of reserved cells for cos queues
+	 * configured for L2. Its value is derived from system
+	 * characterization.
+	 */
+	uint32_t	l2_min_latency;
+	/*
+	 * It is used to calculate the number of shared cells for cos queues
+	 * configured for L2. Its value is derived from system
+	 * characterization.
+	 */
+	uint32_t	l2_max_latency;
+	/*
+	 * It is used to calculate the number of reserved cells for cos queues
+	 * configured for RoCE. Its value is derived from system
+	 * characterization.
+	 */
+	uint32_t	roce_min_latency;
+	/*
+	 * It is used to calculate the number of shared cells for cos queues
+	 * configured for RoCE. Its value is derived from system
+	 * characterization.
+	 */
+	uint32_t	roce_max_latency;
+	/* Specifies the number of reserved cells TRP requires per cos queue. */
+	uint32_t	max_tbm_cells_prereserved;
+	/*
+	 * This parameter is used to compute the time interval for
+	 * replenishing the shaper credit buckets for all TX cos queues.
+	 */
+	uint32_t	shaper_refill_timer;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_queue_adptv_qos_tx_tuning_qcfg_output_t, *phwrm_queue_adptv_qos_tx_tuning_qcfg_output_t;
+
+/**************************************
+ * hwrm_queue_adptv_qos_tx_tuning_cfg *
+ **************************************/
+
+
+/* hwrm_queue_adptv_qos_tx_tuning_cfg_input (size:512b/64B) */
+
+typedef struct hwrm_queue_adptv_qos_tx_tuning_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	enables;
+	/* This bit must be '1' for the option to be configured. */
+	#define HWRM_QUEUE_ADPTV_QOS_TX_TUNING_CFG_INPUT_ENABLES_WFQ_COST			UINT32_C(0x1)
+	/* This bit must be '1' for the option to be configured. */
+	#define HWRM_QUEUE_ADPTV_QOS_TX_TUNING_CFG_INPUT_ENABLES_WFQ_UPPER_FACTOR		UINT32_C(0x2)
+	/* This bit must be '1' for the option to be configured. */
+	#define HWRM_QUEUE_ADPTV_QOS_TX_TUNING_CFG_INPUT_ENABLES_HYST_WINDOW_SIZE_FACTOR	UINT32_C(0x4)
+	/* This bit must be '1' for the option to be configured. */
+	#define HWRM_QUEUE_ADPTV_QOS_TX_TUNING_CFG_INPUT_ENABLES_RSVD_CELLS_LIMIT_RATIO	UINT32_C(0x8)
+	/* This bit must be '1' for the option to be configured. */
+	#define HWRM_QUEUE_ADPTV_QOS_TX_TUNING_CFG_INPUT_ENABLES_L2_MIN_LATENCY		UINT32_C(0x10)
+	/* This bit must be '1' for the option to be configured. */
+	#define HWRM_QUEUE_ADPTV_QOS_TX_TUNING_CFG_INPUT_ENABLES_L2_MAX_LATENCY		UINT32_C(0x20)
+	/* This bit must be '1' for the option to be configured. */
+	#define HWRM_QUEUE_ADPTV_QOS_TX_TUNING_CFG_INPUT_ENABLES_ROCE_MIN_LATENCY		UINT32_C(0x40)
+	/* This bit must be '1' for the option to be configured. */
+	#define HWRM_QUEUE_ADPTV_QOS_TX_TUNING_CFG_INPUT_ENABLES_ROCE_MAX_LATENCY		UINT32_C(0x80)
+	/* This bit must be '1' for the option to be configured. */
+	#define HWRM_QUEUE_ADPTV_QOS_TX_TUNING_CFG_INPUT_ENABLES_MAX_TBM_CELLS_PRERESERVED	UINT32_C(0x100)
+	/* This bit must be '1' for the option to be configured. */
+	#define HWRM_QUEUE_ADPTV_QOS_TX_TUNING_CFG_INPUT_ENABLES_SHAPER_REFILL_TIMER	UINT32_C(0x200)
+	/* Indicates max credit as required by hardware. */
+	uint32_t	wfq_cost;
+	/*
+	 * Specifies a factor that determines the upper bound for each
+	 * cos_wfq_credit_weight.
+	 */
+	uint32_t	wfq_upper_factor;
+	/*
+	 * The algorithm multiplies this factor by the MRU size to compute the
+	 * hysteresis window size which in turn is used in deassert
+	 * threshold calculations.
+	 */
+	uint32_t	hyst_window_size_factor;
+	/*
+	 * The parameter limits the total reserved cells. If the computed
+	 * total reserved cells becomes larger than rsvd_cells_limit_ratio x
+	 * port_cells_avail, then the reserved cells are set to the limit
+	 * value. Its range of values is 0-50%.
+	 */
+	uint32_t	rsvd_cells_limit_ratio;
+	/*
+	 * It is used to calculate the number of reserved cells for cos queues
+	 * configured for L2. Its value is derived from system
+	 * characterization.
+	 */
+	uint32_t	l2_min_latency;
+	/*
+	 * It is used to calculate the number of shared cells for cos queues
+	 * configured for L2. Its value is derived from system
+	 * characterization.
+	 */
+	uint32_t	l2_max_latency;
+	/*
+	 * It is used to calculate the number of reserved cells for cos queues
+	 * configured for RoCE. Its value is derived from system
+	 * characterization.
+	 */
+	uint32_t	roce_min_latency;
+	/*
+	 * It is used to calculate the number of shared cells for cos queues
+	 * configured for RoCE. Its value is derived from system
+	 * characterization.
+	 */
+	uint32_t	roce_max_latency;
+	/* Specifies the number of reserved cells TRP requires per cos queue. */
+	uint32_t	max_tbm_cells_prereserved;
+	/*
+	 * This parameter is used to compute the time interval for
+	 * replenishing the shaper credit buckets for all TX cos queues.
+	 */
+	uint32_t	shaper_refill_timer;
+	uint8_t	unused_0[4];
+} hwrm_queue_adptv_qos_tx_tuning_cfg_input_t, *phwrm_queue_adptv_qos_tx_tuning_cfg_input_t;
+
+/* hwrm_queue_adptv_qos_tx_tuning_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_queue_adptv_qos_tx_tuning_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_queue_adptv_qos_tx_tuning_cfg_output_t, *phwrm_queue_adptv_qos_tx_tuning_cfg_output_t;
+
+/**********************************
+ * hwrm_queue_pfcwd_timeout_qcaps *
+ **********************************/
+
+
+/* hwrm_queue_pfcwd_timeout_qcaps_input (size:128b/16B) */
+
+typedef struct hwrm_queue_pfcwd_timeout_qcaps_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+} hwrm_queue_pfcwd_timeout_qcaps_input_t, *phwrm_queue_pfcwd_timeout_qcaps_input_t;
+
+/* hwrm_queue_pfcwd_timeout_qcaps_output (size:128b/16B) */
+
+typedef struct hwrm_queue_pfcwd_timeout_qcaps_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Max configurable pfc watchdog timeout value in msec. */
+	uint32_t	max_pfcwd_timeout;
+	uint8_t	unused_0[3];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_queue_pfcwd_timeout_qcaps_output_t, *phwrm_queue_pfcwd_timeout_qcaps_output_t;
+
+/********************************
+ * hwrm_queue_pfcwd_timeout_cfg *
+ ********************************/
+
+
+/* hwrm_queue_pfcwd_timeout_cfg_input (size:192b/24B) */
+
+typedef struct hwrm_queue_pfcwd_timeout_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* pfc watchdog timeout value in msec. */
+	uint32_t	pfcwd_timeout_value;
+	uint8_t	unused_0[4];
+} hwrm_queue_pfcwd_timeout_cfg_input_t, *phwrm_queue_pfcwd_timeout_cfg_input_t;
+
+/* hwrm_queue_pfcwd_timeout_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_queue_pfcwd_timeout_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_queue_pfcwd_timeout_cfg_output_t, *phwrm_queue_pfcwd_timeout_cfg_output_t;
+
+/*********************************
+ * hwrm_queue_pfcwd_timeout_qcfg *
+ *********************************/
+
+
+/* hwrm_queue_pfcwd_timeout_qcfg_input (size:128b/16B) */
+
+typedef struct hwrm_queue_pfcwd_timeout_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+} hwrm_queue_pfcwd_timeout_qcfg_input_t, *phwrm_queue_pfcwd_timeout_qcfg_input_t;
+
+/* hwrm_queue_pfcwd_timeout_qcfg_output (size:128b/16B) */
+
+typedef struct hwrm_queue_pfcwd_timeout_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Current configured pfc watchdog timeout value in msec. */
+	uint32_t	pfcwd_timeout_value;
+	uint8_t	unused_0[3];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_queue_pfcwd_timeout_qcfg_output_t, *phwrm_queue_pfcwd_timeout_qcfg_output_t;
+
+/*******************
+ * hwrm_vnic_alloc *
+ *******************/
+
+
+/* hwrm_vnic_alloc_input (size:192b/24B) */
+
+typedef struct hwrm_vnic_alloc_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	flags;
+	/*
+	 * When this bit is '1', this VNIC is requested to
+	 * be the default VNIC for this function.
+	 */
+	#define HWRM_VNIC_ALLOC_INPUT_FLAGS_DEFAULT		UINT32_C(0x1)
+	/*
+	 * When this bit is '1', proxy VEE PF is requesting
+	 * allocation of a default VNIC on behalf of virtio-net
+	 * function given in virtio_net_fid field.
+	 */
+	#define HWRM_VNIC_ALLOC_INPUT_FLAGS_VIRTIO_NET_FID_VALID	UINT32_C(0x2)
+	/*
+	 * Virtio-net function's FID.
+	 * This virtio-net function is requesting allocation of default
+	 * VNIC through proxy VEE PF.
+	 */
+	uint16_t	virtio_net_fid;
+	uint8_t	unused_0[2];
+} hwrm_vnic_alloc_input_t, *phwrm_vnic_alloc_input_t;
+
+/* hwrm_vnic_alloc_output (size:128b/16B) */
+
+typedef struct hwrm_vnic_alloc_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Logical vnic ID */
+	uint32_t	vnic_id;
+	uint8_t	unused_0[3];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_vnic_alloc_output_t, *phwrm_vnic_alloc_output_t;
+
+/********************
+ * hwrm_vnic_update *
+ ********************/
+
+
+/* hwrm_vnic_update_input (size:256b/32B) */
+
+typedef struct hwrm_vnic_update_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Logical vnic ID */
+	uint32_t	vnic_id;
+	uint32_t	enables;
+	/*
+	 * This bit must be '1' for the vnic_state field to be
+	 * configured.
+	 */
+	#define HWRM_VNIC_UPDATE_INPUT_ENABLES_VNIC_STATE_VALID		UINT32_C(0x1)
+	/*
+	 * This bit must be '1' for the mru field to be
+	 * configured.
+	 */
+	#define HWRM_VNIC_UPDATE_INPUT_ENABLES_MRU_VALID			UINT32_C(0x2)
+	/*
+	 * This bit must be '1' for the metadata_format_type field to be
+	 * configured.
+	 */
+	#define HWRM_VNIC_UPDATE_INPUT_ENABLES_METADATA_FORMAT_TYPE_VALID	UINT32_C(0x4)
+	/*
+	 * This will update the context variable with the same name if
+	 * the corresponding enable is set.
+	 */
+	uint8_t	vnic_state;
+	/* Normal operation state for the VNIC. */
+	#define HWRM_VNIC_UPDATE_INPUT_VNIC_STATE_NORMAL UINT32_C(0x0)
+	/* All packets are dropped in this state. */
+	#define HWRM_VNIC_UPDATE_INPUT_VNIC_STATE_DROP   UINT32_C(0x1)
+	#define HWRM_VNIC_UPDATE_INPUT_VNIC_STATE_LAST  HWRM_VNIC_UPDATE_INPUT_VNIC_STATE_DROP
+	/*
+	 * The metadata format type used in all the RX packet completions
+	 * going through this VNIC. This value is product specific. Refer to
+	 * the L2 HSI completion ring structures for the detailed
+	 * descriptions. For Thor and Thor2, it corresponds to 'meta_format'
+	 * in 'rx_pkt_cmpl_hi' and 'rx_pkt_v3_cmpl_hi', respectively.
+	 */
+	uint8_t	metadata_format_type;
+	#define HWRM_VNIC_UPDATE_INPUT_METADATA_FORMAT_TYPE_0 UINT32_C(0x0)
+	#define HWRM_VNIC_UPDATE_INPUT_METADATA_FORMAT_TYPE_1 UINT32_C(0x1)
+	#define HWRM_VNIC_UPDATE_INPUT_METADATA_FORMAT_TYPE_2 UINT32_C(0x2)
+	#define HWRM_VNIC_UPDATE_INPUT_METADATA_FORMAT_TYPE_3 UINT32_C(0x3)
+	#define HWRM_VNIC_UPDATE_INPUT_METADATA_FORMAT_TYPE_4 UINT32_C(0x4)
+	#define HWRM_VNIC_UPDATE_INPUT_METADATA_FORMAT_TYPE_LAST HWRM_VNIC_UPDATE_INPUT_METADATA_FORMAT_TYPE_4
+	/*
+	 * The maximum receive unit of the vnic.
+	 * Each vnic is associated with a function.
+	 * The vnic mru value overwrites the mru setting of the
+	 * associated function.
+	 * The HWRM shall make sure that vnic mru does not exceed
+	 * the mru of the port the function is associated with.
+	 */
+	uint16_t	mru;
+	uint8_t	unused_1[4];
+} hwrm_vnic_update_input_t, *phwrm_vnic_update_input_t;
+
+/* hwrm_vnic_update_output (size:128b/16B) */
+
+typedef struct hwrm_vnic_update_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
+	 */
+	uint8_t	valid;
+} hwrm_vnic_update_output_t, *phwrm_vnic_update_output_t;
+
+/******************
+ * hwrm_vnic_free *
+ ******************/
+
+
+/* hwrm_vnic_free_input (size:192b/24B) */
+
+typedef struct hwrm_vnic_free_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Logical vnic ID */
+	uint32_t	vnic_id;
+	uint8_t	unused_0[4];
+} hwrm_vnic_free_input_t, *phwrm_vnic_free_input_t;
+
+/* hwrm_vnic_free_output (size:128b/16B) */
+
+typedef struct hwrm_vnic_free_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_vnic_free_output_t, *phwrm_vnic_free_output_t;
+
+/*****************
+ * hwrm_vnic_cfg *
+ *****************/
+
+
+/* hwrm_vnic_cfg_input (size:384b/48B) */
+
+typedef struct hwrm_vnic_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	flags;
+	/*
+	 * When this bit is '1', the VNIC is requested to
+	 * be the default VNIC for the function.
+	 */
+	#define HWRM_VNIC_CFG_INPUT_FLAGS_DEFAULT				UINT32_C(0x1)
+	/*
+	 * When this bit is '1', the VNIC is being configured to
+	 * strip VLAN in the RX path.
+	 * If set to '0', then VLAN stripping is disabled on
+	 * this VNIC.
+	 */
+	#define HWRM_VNIC_CFG_INPUT_FLAGS_VLAN_STRIP_MODE			UINT32_C(0x2)
+	/*
+	 * When this bit is '1', the VNIC is being configured to
+	 * buffer receive packets in the hardware until the host
+	 * posts new receive buffers.
+	 * If set to '0', then bd_stall is being configured to be
+	 * disabled on this VNIC.
+	 */
+	#define HWRM_VNIC_CFG_INPUT_FLAGS_BD_STALL_MODE			UINT32_C(0x4)
+	/*
+	 * When this bit is '1', the VNIC is being configured to
+	 * receive both RoCE and non-RoCE traffic.
+	 * If set to '0', then this VNIC is not configured to be
+	 * operating in dual VNIC mode.
+	 */
+	#define HWRM_VNIC_CFG_INPUT_FLAGS_ROCE_DUAL_VNIC_MODE		UINT32_C(0x8)
+	/*
+	 * When this flag is set to '1', the VNIC is requested to
+	 * be configured to receive only RoCE traffic.
+	 * If this flag is set to '0', then this flag shall be
+	 * ignored by the HWRM.
+	 * If roce_dual_vnic_mode flag is set to '1'
+	 * or roce_mirroring_capable_vnic_mode flag to 1,
+	 * then the HWRM client shall not set this flag to '1'.
+	 */
+	#define HWRM_VNIC_CFG_INPUT_FLAGS_ROCE_ONLY_VNIC_MODE		UINT32_C(0x10)
+	/*
+	 * When a VNIC uses one destination ring group for certain
+	 * application (e.g. Receive Flow Steering) where
+	 * exact match is used to direct packets to a VNIC with one
+	 * destination ring group only, there is no need to configure
+	 * RSS indirection table for that VNIC as only one destination
+	 * ring group is used.
+	 *
+	 * This flag is used to enable a mode where
+	 * RSS is enabled in the VNIC using a RSS context
+	 * for computing RSS hash but the RSS indirection table is
+	 * not configured using hwrm_vnic_rss_cfg.
+	 *
+	 * If this mode is enabled, then the driver should not program
+	 * RSS indirection table for the RSS context that is used for
+	 * computing RSS hash only.
+	 */
+	#define HWRM_VNIC_CFG_INPUT_FLAGS_RSS_DFLT_CR_MODE			UINT32_C(0x20)
+	/*
+	 * When this bit is '1', the VNIC is being configured to
+	 * receive both RoCE and non-RoCE traffic, but forward only the
+	 * RoCE traffic further. Also, RoCE traffic can be mirrored to
+	 * L2 driver.
+	 */
+	#define HWRM_VNIC_CFG_INPUT_FLAGS_ROCE_MIRRORING_CAPABLE_VNIC_MODE	UINT32_C(0x40)
+	/*
+	 * When this bit is '1' it enables ring selection using the incoming
+	 * spif and lcos for the packet.
+	 */
+	#define HWRM_VNIC_CFG_INPUT_FLAGS_PORTCOS_MAPPING_MODE		UINT32_C(0x80)
+	uint32_t	enables;
+	/*
+	 * This bit must be '1' for the dflt_ring_grp field to be
+	 * configured.
+	 */
+	#define HWRM_VNIC_CFG_INPUT_ENABLES_DFLT_RING_GRP		UINT32_C(0x1)
+	/*
+	 * This bit must be '1' for the rss_rule field to be
+	 * configured.
+	 */
+	#define HWRM_VNIC_CFG_INPUT_ENABLES_RSS_RULE		UINT32_C(0x2)
+	/*
+	 * This bit must be '1' for the cos_rule field to be
+	 * configured.
+	 */
+	#define HWRM_VNIC_CFG_INPUT_ENABLES_COS_RULE		UINT32_C(0x4)
+	/*
+	 * This bit must be '1' for the lb_rule field to be
+	 * configured.
+	 */
+	#define HWRM_VNIC_CFG_INPUT_ENABLES_LB_RULE		UINT32_C(0x8)
+	/*
+	 * This bit must be '1' for the mru field to be
+	 * configured.
+	 */
+	#define HWRM_VNIC_CFG_INPUT_ENABLES_MRU			UINT32_C(0x10)
+	/*
+	 * This bit must be '1' for the default_rx_ring_id field to be
+	 * configured.
+	 */
+	#define HWRM_VNIC_CFG_INPUT_ENABLES_DEFAULT_RX_RING_ID	UINT32_C(0x20)
+	/*
+	 * This bit must be '1' for the default_cmpl_ring_id field to be
+	 * configured.
+	 */
+	#define HWRM_VNIC_CFG_INPUT_ENABLES_DEFAULT_CMPL_RING_ID	UINT32_C(0x40)
+	/* This bit must be '1' for the queue_id field to be configured. */
+	#define HWRM_VNIC_CFG_INPUT_ENABLES_QUEUE_ID		UINT32_C(0x80)
+	/*
+	 * This bit must be '1' for the rx_csum_v2_mode field to be
+	 * configured.
+	 */
+	#define HWRM_VNIC_CFG_INPUT_ENABLES_RX_CSUM_V2_MODE	UINT32_C(0x100)
+	/* This bit must be '1' for the l2_cqe_mode field to be configured. */
+	#define HWRM_VNIC_CFG_INPUT_ENABLES_L2_CQE_MODE		UINT32_C(0x200)
+	/* Logical vnic ID */
+	uint16_t	vnic_id;
+	/*
+	 * Default Completion ring for the VNIC. This ring will
+	 * be chosen if packet does not match any RSS rules and if
+	 * there is no COS rule.
+	 */
+	uint16_t	dflt_ring_grp;
+	/*
+	 * RSS ID for RSS rule/table structure. 0xFF... (All Fs) if
+	 * there is no RSS rule.
+	 */
+	uint16_t	rss_rule;
+	/*
+	 * RSS ID for COS rule/table structure. 0xFF... (All Fs) if
+	 * there is no COS rule.
+	 */
+	uint16_t	cos_rule;
+	/*
+	 * RSS ID for load balancing rule/table structure.
+	 * 0xFF... (All Fs) if there is no LB rule.
+	 */
+	uint16_t	lb_rule;
+	/*
+	 * The maximum receive unit of the vnic.
+	 * Each vnic is associated with a function.
+	 * The vnic mru value overwrites the mru setting of the
+	 * associated function.
+	 * The HWRM shall make sure that vnic mru does not exceed
+	 * the mru of the port the function is associated with.
+	 */
+	uint16_t	mru;
+	/*
+	 * Default Rx ring for the VNIC. This ring will
+	 * be chosen if packet does not match any RSS rules.
+	 * The aggregation ring associated with the Rx ring is
+	 * implied based on the Rx ring specified when the
+	 * aggregation ring was allocated.
+	 */
+	uint16_t	default_rx_ring_id;
+	/*
+	 * Default completion ring for the VNIC. This ring will
+	 * be chosen if packet does not match any RSS rules.
+	 */
+	uint16_t	default_cmpl_ring_id;
+	/*
+	 * When specified, only incoming packets classified to the specified
+	 * CoS queue ID will be arriving on this VNIC. Packet priority to CoS
+	 * mapping rules can be specified using HWRM_QUEUE_PRI2COS_CFG. In this
+	 * mode, ntuple filters with VNIC destination specified are invalid
+	 * since they conflict with the CoS to VNIC steering rules in this
+	 * mode.
+	 *
+	 * If this field is not specified, packet to VNIC steering will be
+	 * subject to the standard L2 filter rules and any additional ntuple
+	 * filter rules with destination VNIC specified.
+	 */
+	uint16_t	queue_id;
+	/*
+	 * If the device supports the RX V2 and RX TPA start V2 completion
+	 * records as indicated by the HWRM_VNIC_QCAPS command, this field is
+	 * used to specify the two RX checksum modes supported by these
+	 * completion records.
+	 */
+	uint8_t	rx_csum_v2_mode;
+	/*
+	 * When configured with this checksum mode, the number of header
+	 * groups in the delivered packet with a valid IP checksum and
+	 * the number of header groups in the delivered packet with a valid
+	 * L4 checksum are reported. Valid checksums are counted from the
+	 * outermost header group to the innermost header group, stopping at
+	 * the first error. This is the default checksum mode supported if
+	 * the driver doesn't explicitly configure the RX checksum mode.
+	 */
+	#define HWRM_VNIC_CFG_INPUT_RX_CSUM_V2_MODE_DEFAULT UINT32_C(0x0)
+	/*
+	 * When configured with this checksum mode, the checksum status is
+	 * reported using 'all ok' mode. In the RX completion record, one
+	 * bit indicates if the IP checksum is valid for all the parsed
+	 * header groups with an IP checksum. Another bit indicates if the
+	 * L4 checksum is valid for all the parsed header groups with an L4
+	 * checksum. The number of header groups that were parsed by the
+	 * chip and passed in the delivered packet is also reported.
+	 */
+	#define HWRM_VNIC_CFG_INPUT_RX_CSUM_V2_MODE_ALL_OK  UINT32_C(0x1)
+	/*
+	 * Any rx_csum_v2_mode value larger than or equal to this is not
+	 * valid
+	 */
+	#define HWRM_VNIC_CFG_INPUT_RX_CSUM_V2_MODE_MAX	UINT32_C(0x2)
+	#define HWRM_VNIC_CFG_INPUT_RX_CSUM_V2_MODE_LAST   HWRM_VNIC_CFG_INPUT_RX_CSUM_V2_MODE_MAX
+	/*
+	 * If the device supports different L2 RX CQE modes, as indicated by
+	 * the HWRM_VNIC_QCAPS command, this field is used to configure the
+	 * CQE mode.
+	 */
+	uint8_t	l2_cqe_mode;
+	/*
+	 * When configured with this cqe mode, A normal (32B) CQE
+	 * will be generated. This is the default mode.
+	 */
+	#define HWRM_VNIC_CFG_INPUT_L2_CQE_MODE_DEFAULT	UINT32_C(0x0)
+	/*
+	 * When configured with this cqe mode, A compressed (16B) CQE
+	 * will be generated. In this mode TPA and HDS are not supported.
+	 * Host drivers should not configure the TPA and HDS along with
+	 * compressed mode, per VNIC. FW returns error, if host drivers
+	 * try to configure the VNIC with compressed mode and (TPA or HDS).
+	 * The compressed completion does not include PTP data. Host
+	 * drivers should not use this mode to receive the PTP data.
+	 */
+	#define HWRM_VNIC_CFG_INPUT_L2_CQE_MODE_COMPRESSED UINT32_C(0x1)
+	/*
+	 * When configured with this cqe mode, HW generates either a 32B
+	 * completion or a 16B completion depending on use case within a
+	 * VNIC. For ex. a simple L2 packet could use the compressed form
+	 * while a PTP packet on the same VNIC would use the 32B form.
+	 */
+	#define HWRM_VNIC_CFG_INPUT_L2_CQE_MODE_MIXED	UINT32_C(0x2)
+	#define HWRM_VNIC_CFG_INPUT_L2_CQE_MODE_LAST	HWRM_VNIC_CFG_INPUT_L2_CQE_MODE_MIXED
+	uint8_t	unused0[4];
+} hwrm_vnic_cfg_input_t, *phwrm_vnic_cfg_input_t;
+
+/* hwrm_vnic_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_vnic_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_vnic_cfg_output_t, *phwrm_vnic_cfg_output_t;
+
+/******************
+ * hwrm_vnic_qcfg *
+ ******************/
+
+
+/* hwrm_vnic_qcfg_input (size:256b/32B) */
+
+typedef struct hwrm_vnic_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	enables;
+	/*
+	 * This bit must be '1' for the vf_id_valid field to be
+	 * configured.
+	 */
+	#define HWRM_VNIC_QCFG_INPUT_ENABLES_VF_ID_VALID	UINT32_C(0x1)
+	/* Logical vnic ID */
+	uint32_t	vnic_id;
+	/* ID of Virtual Function whose VNIC resource is being queried. */
+	uint16_t	vf_id;
+	uint8_t	unused_0[6];
+} hwrm_vnic_qcfg_input_t, *phwrm_vnic_qcfg_input_t;
+
+/* hwrm_vnic_qcfg_output (size:256b/32B) */
+
+typedef struct hwrm_vnic_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Default Completion ring for the VNIC. */
+	uint16_t	dflt_ring_grp;
+	/*
+	 * RSS ID for RSS rule/table structure. 0xFF... (All Fs) if
+	 * there is no RSS rule.
+	 */
+	uint16_t	rss_rule;
+	/*
+	 * RSS ID for COS rule/table structure. 0xFF... (All Fs) if
+	 * there is no COS rule.
+	 */
+	uint16_t	cos_rule;
+	/*
+	 * RSS ID for load balancing rule/table structure.
+	 * 0xFF... (All Fs) if there is no LB rule.
+	 */
+	uint16_t	lb_rule;
+	/* The maximum receive unit of the vnic. */
+	uint16_t	mru;
+	uint8_t	unused_0[2];
+	uint32_t	flags;
+	/*
+	 * When this bit is '1', the VNIC is the default VNIC for
+	 * the function.
+	 */
+	#define HWRM_VNIC_QCFG_OUTPUT_FLAGS_DEFAULT				UINT32_C(0x1)
+	/*
+	 * When this bit is '1', the VNIC is configured to
+	 * strip VLAN in the RX path.
+	 * If set to '0', then VLAN stripping is disabled on
+	 * this VNIC.
+	 */
+	#define HWRM_VNIC_QCFG_OUTPUT_FLAGS_VLAN_STRIP_MODE			UINT32_C(0x2)
+	/*
+	 * When this bit is '1', the VNIC is configured to
+	 * buffer receive packets in the hardware until the host
+	 * posts new receive buffers.
+	 * If set to '0', then bd_stall is disabled on
+	 * this VNIC.
+	 */
+	#define HWRM_VNIC_QCFG_OUTPUT_FLAGS_BD_STALL_MODE			UINT32_C(0x4)
+	/*
+	 * When this bit is '1', the VNIC is configured to
+	 * receive both RoCE and non-RoCE traffic.
+	 * If set to '0', then this VNIC is not configured to
+	 * operate in dual VNIC mode.
+	 */
+	#define HWRM_VNIC_QCFG_OUTPUT_FLAGS_ROCE_DUAL_VNIC_MODE		UINT32_C(0x8)
+	/*
+	 * When this flag is set to '1', the VNIC is configured to
+	 * receive only RoCE traffic.
+	 * When this flag is set to '0', the VNIC is not configured
+	 * to receive only RoCE traffic.
+	 * If roce_dual_vnic_mode flag and this flag both are set
+	 * to '1', then it is an invalid configuration of the
+	 * VNIC. The HWRM should not allow that type of
+	 * mis-configuration by HWRM clients.
+	 */
+	#define HWRM_VNIC_QCFG_OUTPUT_FLAGS_ROCE_ONLY_VNIC_MODE		UINT32_C(0x10)
+	/*
+	 * When a VNIC uses one destination ring group for certain
+	 * application (e.g. Receive Flow Steering) where
+	 * exact match is used to direct packets to a VNIC with one
+	 * destination ring group only, there is no need to configure
+	 * RSS indirection table for that VNIC as only one destination
+	 * ring group is used.
+	 *
+	 * When this bit is set to '1', then the VNIC is enabled in a
+	 * mode where RSS is enabled in the VNIC using a RSS context
+	 * for computing RSS hash but the RSS indirection table is
+	 * not configured.
+	 */
+	#define HWRM_VNIC_QCFG_OUTPUT_FLAGS_RSS_DFLT_CR_MODE			UINT32_C(0x20)
+	/*
+	 * When this bit is '1', the VNIC is configured to
+	 * receive both RoCE and non-RoCE traffic, but forward only
+	 * RoCE traffic further. Also RoCE traffic can be mirrored to
+	 * L2 driver.
+	 */
+	#define HWRM_VNIC_QCFG_OUTPUT_FLAGS_ROCE_MIRRORING_CAPABLE_VNIC_MODE	UINT32_C(0x40)
+	/*
+	 * When this bit is '0', VNIC is in normal operation state.
+	 * When this bit is '1', VNIC drops all the received packets.
+	 */
+	#define HWRM_VNIC_QCFG_OUTPUT_FLAGS_OPERATION_STATE			UINT32_C(0x80)
+	/* When this bit is '1' it indicates port cos_mapping_mode enabled. */
+	#define HWRM_VNIC_QCFG_OUTPUT_FLAGS_PORTCOS_MAPPING_MODE		UINT32_C(0x100)
+	/*
+	 * When returned with a valid CoS Queue id, the CoS Queue/VNIC
+	 * association is valid. Otherwise it will return 0xFFFF to indicate no
+	 * VNIC/CoS queue association.
+	 */
+	uint16_t	queue_id;
+	/*
+	 * If the device supports the RX V2 and RX TPA start V2 completion
+	 * records as indicated by the HWRM_VNIC_QCAPS command, this field is
+	 * used to specify the current RX checksum mode configured for all the
+	 * RX rings of a VNIC.
+	 */
+	uint8_t	rx_csum_v2_mode;
+	/*
+	 * This value indicates that the VNIC is configured to use the
+	 * default RX checksum mode for all the rings associated with this
+	 * VNIC.
+	 */
+	#define HWRM_VNIC_QCFG_OUTPUT_RX_CSUM_V2_MODE_DEFAULT UINT32_C(0x0)
+	/*
+	 * This value indicates that the VNIC is configured to use the RX
+	 * checksum 'all_ok' mode for all the rings associated with this
+	 * VNIC.
+	 */
+	#define HWRM_VNIC_QCFG_OUTPUT_RX_CSUM_V2_MODE_ALL_OK  UINT32_C(0x1)
+	/*
+	 * Any rx_csum_v2_mode value larger than or equal to this is not
+	 * valid
+	 */
+	#define HWRM_VNIC_QCFG_OUTPUT_RX_CSUM_V2_MODE_MAX	UINT32_C(0x2)
+	#define HWRM_VNIC_QCFG_OUTPUT_RX_CSUM_V2_MODE_LAST   HWRM_VNIC_QCFG_OUTPUT_RX_CSUM_V2_MODE_MAX
+	/*
+	 * If the device supports different L2 RX CQE modes, as indicated by
+	 * the HWRM_VNIC_QCAPS command, this field is used to convey the
+	 * configured CQE mode.
+	 */
+	uint8_t	l2_cqe_mode;
+	/*
+	 * This value indicates that the VNIC is configured with normal
+	 * (32B) CQE mode.
+	 */
+	#define HWRM_VNIC_QCFG_OUTPUT_L2_CQE_MODE_DEFAULT	UINT32_C(0x0)
+	/*
+	 * This value indicates that the VNIC is configured with compressed
+	 * (16B) CQE mode.
+	 */
+	#define HWRM_VNIC_QCFG_OUTPUT_L2_CQE_MODE_COMPRESSED UINT32_C(0x1)
+	/*
+	 * This value indicates that the VNIC is configured with mixed
+	 * CQE mode. HW generates either a 32B completion or a 16B
+	 * completion depending on use case within a VNIC.
+	 */
+	#define HWRM_VNIC_QCFG_OUTPUT_L2_CQE_MODE_MIXED	UINT32_C(0x2)
+	#define HWRM_VNIC_QCFG_OUTPUT_L2_CQE_MODE_LAST	HWRM_VNIC_QCFG_OUTPUT_L2_CQE_MODE_MIXED
+	/*
+	 * This field conveys the metadata format type that has been
+	 * configured. This value is product specific. Refer to the L2 HSI
+	 * completion ring structures for the detailed descriptions. For Thor
+	 * and Thor2, it corresponds to 'meta_format' in 'rx_pkt_cmpl_hi' and
+	 * 'rx_pkt_v3_cmpl_hi', respectively.
+	 */
+	uint8_t	metadata_format_type;
+	#define HWRM_VNIC_QCFG_OUTPUT_METADATA_FORMAT_TYPE_0 UINT32_C(0x0)
+	#define HWRM_VNIC_QCFG_OUTPUT_METADATA_FORMAT_TYPE_1 UINT32_C(0x1)
+	#define HWRM_VNIC_QCFG_OUTPUT_METADATA_FORMAT_TYPE_2 UINT32_C(0x2)
+	#define HWRM_VNIC_QCFG_OUTPUT_METADATA_FORMAT_TYPE_3 UINT32_C(0x3)
+	#define HWRM_VNIC_QCFG_OUTPUT_METADATA_FORMAT_TYPE_4 UINT32_C(0x4)
+	#define HWRM_VNIC_QCFG_OUTPUT_METADATA_FORMAT_TYPE_LAST HWRM_VNIC_QCFG_OUTPUT_METADATA_FORMAT_TYPE_4
+	/* This field conveys the VNIC operation state. */
+	uint8_t	vnic_state;
+	/* Normal operation state. */
+	#define HWRM_VNIC_QCFG_OUTPUT_VNIC_STATE_NORMAL UINT32_C(0x0)
+	/* Drop all packets. */
+	#define HWRM_VNIC_QCFG_OUTPUT_VNIC_STATE_DROP   UINT32_C(0x1)
+	#define HWRM_VNIC_QCFG_OUTPUT_VNIC_STATE_LAST  HWRM_VNIC_QCFG_OUTPUT_VNIC_STATE_DROP
+	uint8_t	unused_1;
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_vnic_qcfg_output_t, *phwrm_vnic_qcfg_output_t;
+
+/*******************
+ * hwrm_vnic_qcaps *
+ *******************/
+
+
+/* hwrm_vnic_qcaps_input (size:192b/24B) */
+
+typedef struct hwrm_vnic_qcaps_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	enables;
+	uint8_t	unused_0[4];
+} hwrm_vnic_qcaps_input_t, *phwrm_vnic_qcaps_input_t;
+
+/* hwrm_vnic_qcaps_output (size:192b/24B) */
+
+typedef struct hwrm_vnic_qcaps_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* The maximum receive unit that is settable on a vnic. */
+	uint16_t	mru;
+	uint8_t	unused_0[2];
+	uint32_t	flags;
+	/* Unused. */
+	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_UNUSED				UINT32_C(0x1)
+	/*
+	 * When this bit is '1', the capability of stripping VLAN in
+	 * the RX path is supported on VNIC(s).
+	 * If set to '0', then VLAN stripping capability is
+	 * not supported on VNIC(s).
+	 */
+	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_VLAN_STRIP_CAP			UINT32_C(0x2)
+	/*
+	 * When this bit is '1', the capability to buffer receive
+	 * packets in the hardware until the host posts new receive buffers
+	 * is supported on VNIC(s).
+	 * If set to '0', then bd_stall capability is not supported
+	 * on VNIC(s).
+	 */
+	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_BD_STALL_CAP				UINT32_C(0x4)
+	/*
+	 * When this bit is '1', the capability to
+	 * receive both RoCE and non-RoCE traffic on VNIC(s) is
+	 * supported.
+	 * If set to '0', then the capability to receive
+	 * both RoCE and non-RoCE traffic on VNIC(s) is
+	 * not supported.
+	 */
+	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_ROCE_DUAL_VNIC_CAP			UINT32_C(0x8)
+	/*
+	 * When this bit is set to '1', the capability to configure
+	 * a VNIC to receive only RoCE traffic is supported.
+	 * When this flag is set to '0', the VNIC capability to
+	 * configure to receive only RoCE traffic is not supported.
+	 */
+	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_ROCE_ONLY_VNIC_CAP			UINT32_C(0x10)
+	/*
+	 * When this bit is set to '1', then the capability to enable
+	 * a VNIC in a mode where RSS context without configuring
+	 * RSS indirection table is supported (for RSS hash computation).
+	 * When this bit is set to '0', then a VNIC can not be configured
+	 * with a mode to enable RSS context without configuring RSS
+	 * indirection table.
+	 */
+	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_RSS_DFLT_CR_CAP			UINT32_C(0x20)
+	/*
+	 * When this bit is '1', the capability to
+	 * mirror the RoCE traffic is supported.
+	 * If set to '0', then the capability to mirror the
+	 * RoCE traffic is not supported.
+	 */
+	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_ROCE_MIRRORING_CAPABLE_VNIC_CAP	UINT32_C(0x40)
+	/*
+	 * When this bit is '1', the outermost RSS hashing capability
+	 * is supported. If set to '0', then the outermost RSS hashing
+	 * capability is not supported.
+	 */
+	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_OUTERMOST_RSS_CAP			UINT32_C(0x80)
+	/*
+	 * When this bit is '1', it indicates that firmware supports the
+	 * ability to steer incoming packets from one CoS queue to one
+	 * VNIC. This optional feature can then be enabled
+	 * using HWRM_VNIC_CFG on any VNIC. This feature is only
+	 * available when NVM option 'enable_cos_classification' is set
+	 * to 1. If set to '0', firmware does not support this feature.
+	 */
+	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_COS_ASSIGNMENT_CAP			UINT32_C(0x100)
+	/*
+	 * When this bit is '1', it indicates that HW and firmware supports
+	 * the use of RX V2 and RX TPA start V2 completion records for all
+	 * the RX rings of a VNIC. Once set, this feature is mandatory to
+	 * be used for the RX rings of the VNIC. Additionally, two new RX
+	 * checksum features supported by these completion records can be
+	 * configured using the HWRM_VNIC_CFG on a VNIC. If set to '0', the
+	 * HW and the firmware does not support this feature.
+	 */
+	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_RX_CMPL_V2_CAP			UINT32_C(0x200)
+	/*
+	 * When this bit is '1', it indicates that HW and firmware support
+	 * vnic state change. Host drivers can change the vnic state using
+	 * HWRM_VNIC_UPDATE. If set to '0', the HW and firmware do not
+	 * support this feature.
+	 */
+	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_VNIC_STATE_CAP			UINT32_C(0x400)
+	/*
+	 * When this bit is '1', it indicates that firmware supports
+	 * virtio-net functions default VNIC allocation using
+	 * HWRM_VNIC_ALLOC.
+	 * This capability is available only on Proxy VEE PF. If set to '0',
+	 * firmware does not support this feature.
+	 */
+	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_VIRTIO_NET_VNIC_ALLOC_CAP		UINT32_C(0x800)
+	/*
+	 * When this bit is set '1', then the capability to configure the
+	 * metadata format in the RX completion is supported for the VNIC.
+	 * When this bit is set to '0', then the capability to configure
+	 * the metadata format in the RX completion is not supported for
+	 * the VNIC.
+	 */
+	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_METADATA_FORMAT_CAP			UINT32_C(0x1000)
+	/*
+	 * When this bit is set '1', it indicates that firmware returns
+	 * INVALID_PARAM error, if host drivers choose invalid hash type
+	 * bit combinations in vnic_rss_cfg.
+	 */
+	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_RSS_STRICT_HASH_TYPE_CAP		UINT32_C(0x2000)
+	/*
+	 * When this bit is set '1', it indicates that firmware supports
+	 * the hash_type include and exclude flags in hwrm_vnic_rss_cfg.
+	 */
+	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_RSS_HASH_TYPE_DELTA_CAP		UINT32_C(0x4000)
+	/*
+	 * When this bit is '1', it indicates that HW is capable of using
+	 * Toeplitz algorithm. This mode uses Toeplitz algorithm and
+	 * provided Toeplitz hash key to hash the packets according to the
+	 * configured hash type and hash mode. The Toeplitz hash results and
+	 * the provided Toeplitz RSS indirection table are used to determine
+	 * the RSS rings.
+	 */
+	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_RING_SELECT_MODE_TOEPLITZ_CAP	UINT32_C(0x8000)
+	/*
+	 * When this bit is '1', it indicates that HW is capable of using
+	 * XOR algorithm. This mode uses 'XOR' algorithm to hash the packets
+	 * according to the configured hash type and hash mode. The XOR
+	 * hash results and the provided XOR RSS indirection table are
+	 * used to determine the RSS rings. Host drivers provided hash key
+	 * is not honored in this mode.
+	 */
+	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_RING_SELECT_MODE_XOR_CAP		UINT32_C(0x10000)
+	/*
+	 * When this bit is '1', it indicates that HW is capable of using
+	 * checksum algorithm. In this mode, HW uses inner packets checksum
+	 * algorithm to distribute the packets across the rings and Toeplitz
+	 * algorithm to calculate the hash to convey it in the RX
+	 * completions. Host drivers should provide Toeplitz hash key.
+	 * As HW uses innermost packets checksum to distribute the packets
+	 * across the rings, host drivers can't convey hash mode to choose
+	 * outer headers to calculate Toeplitz hash. FW will fail such
+	 * configuration.
+	 */
+	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_RING_SELECT_MODE_TOEPLITZ_CHKSM_CAP	UINT32_C(0x20000)
+	/*
+	 * When this bit is '1' HW supports hash calculation
+	 * based on IPV6 flow labels.
+	 */
+	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_RSS_IPV6_FLOW_LABEL_CAP		UINT32_C(0x40000)
+	/*
+	 * When this bit is '1', it indicates that HW and firmware supports
+	 * the use of RX V3 and RX TPA start V3 completion records for all
+	 * the RX rings of a VNIC. Once set, this feature is mandatory to
+	 * be used for the RX rings of the VNIC. If set to '0', the
+	 * HW and the firmware does not support this feature.
+	 */
+	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_RX_CMPL_V3_CAP			UINT32_C(0x80000)
+	/*
+	 * When this bit is '1' HW supports different RX CQE record types.
+	 * Host drivers can choose the mode based on their application
+	 * requirements like performance, TPA, HDS and PTP.
+	 */
+	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_L2_CQE_MODE_CAP			UINT32_C(0x100000)
+	/*
+	 * When this bit is '1' HW supports hash calculation
+	 * based on IPv4 IPSEC AH SPI field.
+	 */
+	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_RSS_IPSEC_AH_SPI_IPV4_CAP		UINT32_C(0x200000)
+	/*
+	 * When this bit is '1' HW supports hash calculation
+	 * based on IPv4 IPSEC ESP SPI field.
+	 */
+	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_RSS_IPSEC_ESP_SPI_IPV4_CAP		UINT32_C(0x400000)
+	/*
+	 * When this bit is '1' HW supports hash calculation
+	 * based on IPv6 IPSEC AH SPI field.
+	 */
+	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_RSS_IPSEC_AH_SPI_IPV6_CAP		UINT32_C(0x800000)
+	/*
+	 * When this bit is '1' HW supports hash calculation
+	 * based on IPv6 IPSEC ESP SPI field.
+	 */
+	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_RSS_IPSEC_ESP_SPI_IPV6_CAP		UINT32_C(0x1000000)
+	/*
+	 * When outermost_rss_cap is '1' and this bit is '1', the outermost
+	 * RSS hash mode may be set on a PF or trusted VF.
+	 * When outermost_rss_cap is '1' and this bit is '0', the outermost
+	 * RSS hash mode may be set on a PF.
+	 */
+	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_OUTERMOST_RSS_TRUSTED_VF_CAP		UINT32_C(0x2000000)
+	/*
+	 * When this bit is '1' it indicates HW is capable of enabling ring
+	 * selection using the incoming spif and lcos for the packet.
+	 */
+	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_PORTCOS_MAPPING_MODE			UINT32_C(0x4000000)
+	/*
+	 * When this bit is '1', it indicates controller enabled
+	 * RSS profile TCAM mode.
+	 */
+	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_RSS_PROF_TCAM_MODE_ENABLED		UINT32_C(0x8000000)
+	/* When this bit is '1' FW supports VNIC hash mode. */
+	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_VNIC_RSS_HASH_MODE_CAP		UINT32_C(0x10000000)
+	/* When this bit is set to '1', hardware supports tunnel TPA. */
+	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_HW_TUNNEL_TPA_CAP			UINT32_C(0x20000000)
+	/*
+	 * This field advertises the maximum concurrent TPA aggregations
+	 * supported by the VNIC on new devices that support TPA v2 or v3.
+	 * '0' means that both the TPA v2 and v3 are not supported.
+	 */
+	uint16_t	max_aggs_supported;
+	uint8_t	unused_1[5];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_vnic_qcaps_output_t, *phwrm_vnic_qcaps_output_t;
+
+/*********************
+ * hwrm_vnic_tpa_cfg *
+ *********************/
+
+
+/* hwrm_vnic_tpa_cfg_input (size:384b/48B) */
+
+typedef struct hwrm_vnic_tpa_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	flags;
+	/*
+	 * When this bit is '1', the VNIC shall be configured to
+	 * perform transparent packet aggregation (TPA) of
+	 * non-tunneled TCP packets.
+	 */
+	#define HWRM_VNIC_TPA_CFG_INPUT_FLAGS_TPA			UINT32_C(0x1)
+	/*
+	 * When this bit is '1', the VNIC shall be configured to
+	 * perform transparent packet aggregation (TPA) of
+	 * tunneled TCP packets.
+	 */
+	#define HWRM_VNIC_TPA_CFG_INPUT_FLAGS_ENCAP_TPA		UINT32_C(0x2)
+	/*
+	 * When this bit is '1', the VNIC shall be configured to
+	 * perform transparent packet aggregation (TPA) according
+	 * to Windows Receive Segment Coalescing (RSC) rules.
+	 */
+	#define HWRM_VNIC_TPA_CFG_INPUT_FLAGS_RSC_WND_UPDATE		UINT32_C(0x4)
+	/*
+	 * When this bit is '1', the VNIC shall be configured to
+	 * perform transparent packet aggregation (TPA) according
+	 * to Linux Generic Receive Offload (GRO) rules.
+	 */
+	#define HWRM_VNIC_TPA_CFG_INPUT_FLAGS_GRO			UINT32_C(0x8)
+	/*
+	 * When this bit is '1', the VNIC shall be configured to
+	 * perform transparent packet aggregation (TPA) for TCP
+	 * packets with IP ECN set to non-zero.
+	 */
+	#define HWRM_VNIC_TPA_CFG_INPUT_FLAGS_AGG_WITH_ECN		UINT32_C(0x10)
+	/*
+	 * When this bit is '1', the VNIC shall be configured to
+	 * perform transparent packet aggregation (TPA) for
+	 * GRE tunneled TCP packets only if all packets have the
+	 * same GRE sequence.
+	 */
+	#define HWRM_VNIC_TPA_CFG_INPUT_FLAGS_AGG_WITH_SAME_GRE_SEQ	UINT32_C(0x20)
+	/*
+	 * When this bit is '1' and the GRO mode is enabled,
+	 * the VNIC shall be configured to
+	 * perform transparent packet aggregation (TPA) for
+	 * TCP/IPv4 packets with consecutively increasing IPIDs.
+	 * In other words, the last packet that is being
+	 * aggregated to an already existing aggregation context
+	 * shall have IPID 1 more than the IPID of the last packet
+	 * that was aggregated in that aggregation context.
+	 */
+	#define HWRM_VNIC_TPA_CFG_INPUT_FLAGS_GRO_IPID_CHECK		UINT32_C(0x40)
+	/*
+	 * When this bit is '1' and the GRO mode is enabled,
+	 * the VNIC shall be configured to
+	 * perform transparent packet aggregation (TPA) for
+	 * TCP packets with the same TTL (IPv4) or Hop limit (IPv6)
+	 * value.
+	 */
+	#define HWRM_VNIC_TPA_CFG_INPUT_FLAGS_GRO_TTL_CHECK		UINT32_C(0x80)
+	/*
+	 * When this bit is '1' and the GRO mode is enabled,
+	 * the VNIC shall DMA payload data using GRO rules.
+	 * When this bit is '0', the VNIC shall DMA payload data
+	 * using the more efficient LRO rules of filling all
+	 * aggregation buffers.
+	 */
+	#define HWRM_VNIC_TPA_CFG_INPUT_FLAGS_AGG_PACK_AS_GRO	UINT32_C(0x100)
+	uint32_t	enables;
+	/*
+	 * This bit must be '1' for the max_agg_segs field to be
+	 * configured.
+	 */
+	#define HWRM_VNIC_TPA_CFG_INPUT_ENABLES_MAX_AGG_SEGS	UINT32_C(0x1)
+	/*
+	 * This bit must be '1' for the max_aggs field to be
+	 * configured.
+	 */
+	#define HWRM_VNIC_TPA_CFG_INPUT_ENABLES_MAX_AGGS	UINT32_C(0x2)
+	/*
+	 * This bit must be '1' for the max_agg_timer field to be
+	 * configured.
+	 */
+	#define HWRM_VNIC_TPA_CFG_INPUT_ENABLES_MAX_AGG_TIMER	UINT32_C(0x4)
+	/* deprecated bit. Do not use!!! */
+	#define HWRM_VNIC_TPA_CFG_INPUT_ENABLES_MIN_AGG_LEN	UINT32_C(0x8)
+	/*
+	 * This bit must be '1' for the tnl_tpa_en_bitmap field to be
+	 * configured.
+	 */
+	#define HWRM_VNIC_TPA_CFG_INPUT_ENABLES_TNL_TPA_EN	UINT32_C(0x10)
+	/* Logical vnic ID */
+	uint16_t	vnic_id;
+	/*
+	 * This is the maximum number of TCP segments that can
+	 * be aggregated (unit is Log2). Max value is 31. On new
+	 * devices supporting TPA v2, the unit is multiples of 4 and
+	 * valid values are > 0 and <= 63.
+	 */
+	uint16_t	max_agg_segs;
+	/* 1 segment */
+	#define HWRM_VNIC_TPA_CFG_INPUT_MAX_AGG_SEGS_1   UINT32_C(0x0)
+	/* 2 segments */
+	#define HWRM_VNIC_TPA_CFG_INPUT_MAX_AGG_SEGS_2   UINT32_C(0x1)
+	/* 4 segments */
+	#define HWRM_VNIC_TPA_CFG_INPUT_MAX_AGG_SEGS_4   UINT32_C(0x2)
+	/* 8 segments */
+	#define HWRM_VNIC_TPA_CFG_INPUT_MAX_AGG_SEGS_8   UINT32_C(0x3)
+	/* Any segment size larger than this is not valid */
+	#define HWRM_VNIC_TPA_CFG_INPUT_MAX_AGG_SEGS_MAX UINT32_C(0x1f)
+	#define HWRM_VNIC_TPA_CFG_INPUT_MAX_AGG_SEGS_LAST HWRM_VNIC_TPA_CFG_INPUT_MAX_AGG_SEGS_MAX
+	/*
+	 * This is the maximum number of aggregations this VNIC is
+	 * allowed (unit is Log2). Max value is 7. On new devices
+	 * supporting TPA v2, this is in unit of 1 and must be > 0
+	 * and <= max_aggs_supported in the hwrm_vnic_qcaps response
+	 * to enable TPA v2.
+	 */
+	uint16_t	max_aggs;
+	/* 1 aggregation */
+	#define HWRM_VNIC_TPA_CFG_INPUT_MAX_AGGS_1   UINT32_C(0x0)
+	/* 2 aggregations */
+	#define HWRM_VNIC_TPA_CFG_INPUT_MAX_AGGS_2   UINT32_C(0x1)
+	/* 4 aggregations */
+	#define HWRM_VNIC_TPA_CFG_INPUT_MAX_AGGS_4   UINT32_C(0x2)
+	/* 8 aggregations */
+	#define HWRM_VNIC_TPA_CFG_INPUT_MAX_AGGS_8   UINT32_C(0x3)
+	/* 16 aggregations */
+	#define HWRM_VNIC_TPA_CFG_INPUT_MAX_AGGS_16  UINT32_C(0x4)
+	/* Any aggregation size larger than this is not valid */
+	#define HWRM_VNIC_TPA_CFG_INPUT_MAX_AGGS_MAX UINT32_C(0x7)
+	#define HWRM_VNIC_TPA_CFG_INPUT_MAX_AGGS_LAST HWRM_VNIC_TPA_CFG_INPUT_MAX_AGGS_MAX
+	uint8_t	unused_0[2];
+	/*
+	 * This is the maximum amount of time allowed for
+	 * an aggregation context to complete after it was initiated.
+	 */
+	uint32_t	max_agg_timer;
+	/*
+	 * This is the minimum amount of payload length required to
+	 * start an aggregation context. This field is deprecated and
+	 * should be set to 0. The minimum length is set by firmware
+	 * and can be queried using hwrm_vnic_tpa_qcfg.
+	 */
+	uint32_t	min_agg_len;
+	/*
+	 * If the device supports hardware tunnel TPA feature, as indicated by
+	 * the HWRM_VNIC_QCAPS command, this field is used to configure the
+	 * tunnel types to be enabled. Each bit corresponds to a specific
+	 * tunnel type. If a bit is set to '1', then the associated tunnel
+	 * type is enabled; otherwise, it is disabled.
+	 */
+	uint32_t	tnl_tpa_en_bitmap;
+	/*
+	 * When this bit is '1', enable VXLAN encapsulated packets for
+	 * aggregation.
+	 */
+	#define HWRM_VNIC_TPA_CFG_INPUT_TNL_TPA_EN_BITMAP_VXLAN	UINT32_C(0x1)
+	/*
+	 * When this bit is set to '1', enable GENEVE encapsulated packets
+	 * for aggregation.
+	 */
+	#define HWRM_VNIC_TPA_CFG_INPUT_TNL_TPA_EN_BITMAP_GENEVE	UINT32_C(0x2)
+	/*
+	 * When this bit is set to '1', enable NVGRE encapsulated packets
+	 * for aggregation..
+	 */
+	#define HWRM_VNIC_TPA_CFG_INPUT_TNL_TPA_EN_BITMAP_NVGRE	UINT32_C(0x4)
+	/*
+	 * When this bit is set to '1', enable GRE encapsulated packets
+	 * for aggregation..
+	 */
+	#define HWRM_VNIC_TPA_CFG_INPUT_TNL_TPA_EN_BITMAP_GRE		UINT32_C(0x8)
+	/*
+	 * When this bit is set to '1', enable IPV4 encapsulated packets
+	 * for aggregation..
+	 */
+	#define HWRM_VNIC_TPA_CFG_INPUT_TNL_TPA_EN_BITMAP_IPV4		UINT32_C(0x10)
+	/*
+	 * When this bit is set to '1', enable IPV6 encapsulated packets
+	 * for aggregation..
+	 */
+	#define HWRM_VNIC_TPA_CFG_INPUT_TNL_TPA_EN_BITMAP_IPV6		UINT32_C(0x20)
+	/*
+	 * When this bit is '1', enable VXLAN_GPE encapsulated packets for
+	 * aggregation.
+	 */
+	#define HWRM_VNIC_TPA_CFG_INPUT_TNL_TPA_EN_BITMAP_VXLAN_GPE	UINT32_C(0x40)
+	/*
+	 * When this bit is '1', enable VXLAN_CUSTOMER1 encapsulated packets
+	 * for aggregation.
+	 */
+	#define HWRM_VNIC_TPA_CFG_INPUT_TNL_TPA_EN_BITMAP_VXLAN_CUST1	UINT32_C(0x80)
+	/*
+	 * When this bit is '1', enable GRE_CUSTOMER1 encapsulated packets
+	 * for aggregation.
+	 */
+	#define HWRM_VNIC_TPA_CFG_INPUT_TNL_TPA_EN_BITMAP_GRE_CUST1	UINT32_C(0x100)
+	/*
+	 * When this bit is '1', enable UPAR1 encapsulated packets for
+	 * aggregation.
+	 */
+	#define HWRM_VNIC_TPA_CFG_INPUT_TNL_TPA_EN_BITMAP_UPAR1	UINT32_C(0x200)
+	/*
+	 * When this bit is '1', enable UPAR2 encapsulated packets for
+	 * aggregation.
+	 */
+	#define HWRM_VNIC_TPA_CFG_INPUT_TNL_TPA_EN_BITMAP_UPAR2	UINT32_C(0x400)
+	/*
+	 * When this bit is '1', enable UPAR3 encapsulated packets for
+	 * aggregation.
+	 */
+	#define HWRM_VNIC_TPA_CFG_INPUT_TNL_TPA_EN_BITMAP_UPAR3	UINT32_C(0x800)
+	/*
+	 * When this bit is '1', enable UPAR4 encapsulated packets for
+	 * aggregation.
+	 */
+	#define HWRM_VNIC_TPA_CFG_INPUT_TNL_TPA_EN_BITMAP_UPAR4	UINT32_C(0x1000)
+	/*
+	 * When this bit is '1', enable UPAR5 encapsulated packets for
+	 * aggregation.
+	 */
+	#define HWRM_VNIC_TPA_CFG_INPUT_TNL_TPA_EN_BITMAP_UPAR5	UINT32_C(0x2000)
+	/*
+	 * When this bit is '1', enable UPAR6 encapsulated packets for
+	 * aggregation.
+	 */
+	#define HWRM_VNIC_TPA_CFG_INPUT_TNL_TPA_EN_BITMAP_UPAR6	UINT32_C(0x4000)
+	/*
+	 * When this bit is '1', enable UPAR7 encapsulated packets for
+	 * aggregation.
+	 */
+	#define HWRM_VNIC_TPA_CFG_INPUT_TNL_TPA_EN_BITMAP_UPAR7	UINT32_C(0x8000)
+	/*
+	 * When this bit is '1', enable UPAR8 encapsulated packets for
+	 * aggregation.
+	 */
+	#define HWRM_VNIC_TPA_CFG_INPUT_TNL_TPA_EN_BITMAP_UPAR8	UINT32_C(0x10000)
+	uint8_t	unused_1[4];
+} hwrm_vnic_tpa_cfg_input_t, *phwrm_vnic_tpa_cfg_input_t;
+
+/* hwrm_vnic_tpa_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_vnic_tpa_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_vnic_tpa_cfg_output_t, *phwrm_vnic_tpa_cfg_output_t;
+
+/**********************
+ * hwrm_vnic_tpa_qcfg *
+ **********************/
+
+
+/* hwrm_vnic_tpa_qcfg_input (size:192b/24B) */
+
+typedef struct hwrm_vnic_tpa_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Logical vnic ID */
+	uint16_t	vnic_id;
+	uint8_t	unused_0[6];
+} hwrm_vnic_tpa_qcfg_input_t, *phwrm_vnic_tpa_qcfg_input_t;
+
+/* hwrm_vnic_tpa_qcfg_output (size:256b/32B) */
+
+typedef struct hwrm_vnic_tpa_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint32_t	flags;
+	/*
+	 * When this bit is '1', the VNIC is configured to
+	 * perform transparent packet aggregation (TPA) of
+	 * non-tunneled TCP packets.
+	 */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_FLAGS_TPA			UINT32_C(0x1)
+	/*
+	 * When this bit is '1', the VNIC is configured to
+	 * perform transparent packet aggregation (TPA) of
+	 * tunneled TCP packets.
+	 */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_FLAGS_ENCAP_TPA		UINT32_C(0x2)
+	/*
+	 * When this bit is '1', the VNIC is configured to
+	 * perform transparent packet aggregation (TPA) according
+	 * to Windows Receive Segment Coalescing (RSC) rules.
+	 */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_FLAGS_RSC_WND_UPDATE		UINT32_C(0x4)
+	/*
+	 * When this bit is '1', the VNIC is configured to
+	 * perform transparent packet aggregation (TPA) according
+	 * to Linux Generic Receive Offload (GRO) rules.
+	 */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_FLAGS_GRO			UINT32_C(0x8)
+	/*
+	 * When this bit is '1', the VNIC is configured to
+	 * perform transparent packet aggregation (TPA) for TCP
+	 * packets with IP ECN set to non-zero.
+	 */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_FLAGS_AGG_WITH_ECN		UINT32_C(0x10)
+	/*
+	 * When this bit is '1', the VNIC is configured to
+	 * perform transparent packet aggregation (TPA) for
+	 * GRE tunneled TCP packets only if all packets have the
+	 * same GRE sequence.
+	 */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_FLAGS_AGG_WITH_SAME_GRE_SEQ	UINT32_C(0x20)
+	/*
+	 * When this bit is '1' and the GRO mode is enabled,
+	 * the VNIC is configured to
+	 * perform transparent packet aggregation (TPA) for
+	 * TCP/IPv4 packets with consecutively increasing IPIDs.
+	 * In other words, the last packet that is being
+	 * aggregated to an already existing aggregation context
+	 * shall have IPID 1 more than the IPID of the last packet
+	 * that was aggregated in that aggregation context.
+	 */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_FLAGS_GRO_IPID_CHECK		UINT32_C(0x40)
+	/*
+	 * When this bit is '1' and the GRO mode is enabled,
+	 * the VNIC is configured to
+	 * perform transparent packet aggregation (TPA) for
+	 * TCP packets with the same TTL (IPv4) or Hop limit (IPv6)
+	 * value.
+	 */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_FLAGS_GRO_TTL_CHECK		UINT32_C(0x80)
+	/*
+	 * This is the maximum number of TCP segments that can
+	 * be aggregated (unit is Log2). Max value is 31.
+	 */
+	uint16_t	max_agg_segs;
+	/* 1 segment */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_MAX_AGG_SEGS_1   UINT32_C(0x0)
+	/* 2 segments */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_MAX_AGG_SEGS_2   UINT32_C(0x1)
+	/* 4 segments */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_MAX_AGG_SEGS_4   UINT32_C(0x2)
+	/* 8 segments */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_MAX_AGG_SEGS_8   UINT32_C(0x3)
+	/* Any segment size larger than this is not valid */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_MAX_AGG_SEGS_MAX UINT32_C(0x1f)
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_MAX_AGG_SEGS_LAST HWRM_VNIC_TPA_QCFG_OUTPUT_MAX_AGG_SEGS_MAX
+	/*
+	 * This is the maximum number of aggregations this VNIC is
+	 * allowed (unit is Log2). Max value is 7
+	 */
+	uint16_t	max_aggs;
+	/* 1 aggregation */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_MAX_AGGS_1   UINT32_C(0x0)
+	/* 2 aggregations */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_MAX_AGGS_2   UINT32_C(0x1)
+	/* 4 aggregations */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_MAX_AGGS_4   UINT32_C(0x2)
+	/* 8 aggregations */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_MAX_AGGS_8   UINT32_C(0x3)
+	/* 16 aggregations */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_MAX_AGGS_16  UINT32_C(0x4)
+	/* Any aggregation size larger than this is not valid */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_MAX_AGGS_MAX UINT32_C(0x7)
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_MAX_AGGS_LAST HWRM_VNIC_TPA_QCFG_OUTPUT_MAX_AGGS_MAX
+	/*
+	 * This is the maximum amount of time allowed for
+	 * an aggregation context to complete after it was initiated.
+	 */
+	uint32_t	max_agg_timer;
+	/*
+	 * This is the minimum amount of payload length required to
+	 * start an aggregation context.
+	 */
+	uint32_t	min_agg_len;
+	/*
+	 * If the device supports hardware tunnel TPA feature, as indicated by
+	 * the HWRM_VNIC_QCAPS command, this field conveys the bitmap of the
+	 * tunnel types that have been configured. Each bit corresponds to a
+	 * specific tunnel type. If a bit is set to '1', then the associated
+	 * tunnel type is enabled; otherwise, it is disabled.
+	 */
+	uint32_t	tnl_tpa_en_bitmap;
+	/*
+	 * When this bit is '1', enable VXLAN encapsulated packets for
+	 * aggregation.
+	 */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_TNL_TPA_EN_BITMAP_VXLAN	UINT32_C(0x1)
+	/*
+	 * When this bit is set to '1', enable GENEVE encapsulated packets
+	 * for aggregation.
+	 */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_TNL_TPA_EN_BITMAP_GENEVE	UINT32_C(0x2)
+	/*
+	 * When this bit is set to '1', enable NVGRE encapsulated packets
+	 * for aggregation..
+	 */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_TNL_TPA_EN_BITMAP_NVGRE	UINT32_C(0x4)
+	/*
+	 * When this bit is set to '1', enable GRE encapsulated packets
+	 * for aggregation..
+	 */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_TNL_TPA_EN_BITMAP_GRE		UINT32_C(0x8)
+	/*
+	 * When this bit is set to '1', enable IPV4 encapsulated packets
+	 * for aggregation..
+	 */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_TNL_TPA_EN_BITMAP_IPV4		UINT32_C(0x10)
+	/*
+	 * When this bit is set to '1', enable IPV6 encapsulated packets
+	 * for aggregation..
+	 */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_TNL_TPA_EN_BITMAP_IPV6		UINT32_C(0x20)
+	/*
+	 * When this bit is '1', enable VXLAN_GPE encapsulated packets for
+	 * aggregation.
+	 */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_TNL_TPA_EN_BITMAP_VXLAN_GPE	UINT32_C(0x40)
+	/*
+	 * When this bit is '1', enable VXLAN_CUSTOMER1 encapsulated packets
+	 * for aggregation.
+	 */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_TNL_TPA_EN_BITMAP_VXLAN_CUST1	UINT32_C(0x80)
+	/*
+	 * When this bit is '1', enable GRE_CUSTOMER1 encapsulated packets
+	 * for aggregation.
+	 */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_TNL_TPA_EN_BITMAP_GRE_CUST1	UINT32_C(0x100)
+	/*
+	 * When this bit is '1', enable UPAR1 encapsulated packets for
+	 * aggregation.
+	 */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_TNL_TPA_EN_BITMAP_UPAR1	UINT32_C(0x200)
+	/*
+	 * When this bit is '1', enable UPAR2 encapsulated packets for
+	 * aggregation.
+	 */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_TNL_TPA_EN_BITMAP_UPAR2	UINT32_C(0x400)
+	/*
+	 * When this bit is '1', enable UPAR3 encapsulated packets for
+	 * aggregation.
+	 */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_TNL_TPA_EN_BITMAP_UPAR3	UINT32_C(0x800)
+	/*
+	 * When this bit is '1', enable UPAR4 encapsulated packets for
+	 * aggregation.
+	 */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_TNL_TPA_EN_BITMAP_UPAR4	UINT32_C(0x1000)
+	/*
+	 * When this bit is '1', enable UPAR5 encapsulated packets for
+	 * aggregation.
+	 */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_TNL_TPA_EN_BITMAP_UPAR5	UINT32_C(0x2000)
+	/*
+	 * When this bit is '1', enable UPAR6 encapsulated packets for
+	 * aggregation.
+	 */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_TNL_TPA_EN_BITMAP_UPAR6	UINT32_C(0x4000)
+	/*
+	 * When this bit is '1', enable UPAR7 encapsulated packets for
+	 * aggregation.
+	 */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_TNL_TPA_EN_BITMAP_UPAR7	UINT32_C(0x8000)
+	/*
+	 * When this bit is '1', enable UPAR8 encapsulated packets for
+	 * aggregation.
+	 */
+	#define HWRM_VNIC_TPA_QCFG_OUTPUT_TNL_TPA_EN_BITMAP_UPAR8	UINT32_C(0x10000)
+	uint8_t	unused_0[3];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_vnic_tpa_qcfg_output_t, *phwrm_vnic_tpa_qcfg_output_t;
+
+/*********************
+ * hwrm_vnic_rss_cfg *
+ *********************/
+
+
+/* hwrm_vnic_rss_cfg_input (size:384b/48B) */
+
+typedef struct hwrm_vnic_rss_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	hash_type;
+	/*
+	 * When this bit is '1', the RSS hash shall be computed
+	 * over source and destination IPv4 addresses of IPv4
+	 * packets.
+	 */
+	#define HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV4		UINT32_C(0x1)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed
+	 * over source/destination IPv4 addresses and
+	 * source/destination ports of TCP/IPv4 packets.
+	 */
+	#define HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV4		UINT32_C(0x2)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed
+	 * over source/destination IPv4 addresses and
+	 * source/destination ports of UDP/IPv4 packets.
+	 */
+	#define HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_UDP_IPV4		UINT32_C(0x4)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed
+	 * over source and destination IPv6 addresses of IPv6
+	 * packets.
+	 */
+	#define HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV6		UINT32_C(0x8)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed
+	 * over source/destination IPv6 addresses and
+	 * source/destination ports of TCP/IPv6 packets.
+	 */
+	#define HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV6		UINT32_C(0x10)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed
+	 * over source/destination IPv6 addresses and
+	 * source/destination ports of UDP/IPv6 packets.
+	 */
+	#define HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_UDP_IPV6		UINT32_C(0x20)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed
+	 * over source, destination IPv6 addresses and flow label of IPv6
+	 * packets. Hash type ipv6 and ipv6_flow_label are mutually
+	 * exclusive. HW does not include the flow_label in hash
+	 * calculation for the packets that are matching tcp_ipv6 and
+	 * udp_ipv6 hash types. Host drivers should set this bit based on
+	 * rss_ipv6_flow_label_cap.
+	 */
+	#define HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV6_FLOW_LABEL	UINT32_C(0x40)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed over
+	 * source/destination IPv4 addresses and IPSEC AH SPI field of IPSEC
+	 * AH/IPv4 packets. Host drivers should set this bit based on
+	 * rss_ipsec_ah_spi_ipv4_cap.
+	 */
+	#define HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_AH_SPI_IPV4	UINT32_C(0x80)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed over
+	 * source/destination IPv4 addresses and IPSEC ESP SPI field of IPSEC
+	 * ESP/IPv4 packets. Host drivers should set this bit based on
+	 * rss_ipsec_esp_spi_ipv4_cap.
+	 */
+	#define HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_ESP_SPI_IPV4	UINT32_C(0x100)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed over
+	 * source/destination IPv6 addresses and IPSEC AH SPI field of IPSEC
+	 * AH/IPv6 packets. Host drivers should set this bit based on
+	 * rss_ipsec_ah_spi_ipv6_cap.
+	 */
+	#define HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_AH_SPI_IPV6	UINT32_C(0x200)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed over
+	 * source/destination IPv6 addresses and IPSEC ESP SPI field of IPSEC
+	 * ESP/IPv6 packets. Host drivers should set this bit based on
+	 * rss_ipsec_esp_spi_ipv6_cap.
+	 */
+	#define HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_ESP_SPI_IPV6	UINT32_C(0x400)
+	/* VNIC ID of VNIC associated with RSS table being configured. */
+	uint16_t	vnic_id;
+	/*
+	 * Specifies which VNIC ring table pair to configure.
+	 * Valid values range from 0 to 7.
+	 */
+	uint8_t	ring_table_pair_index;
+	/*
+	 * Flags to specify different RSS hash modes. Global RSS hash mode is
+	 * indicated when vnic_id and rss_ctx_idx fields are set to value of
+	 * 0xffff. Only PF can initiate global RSS hash mode setting changes.
+	 * VNIC RSS hash mode is indicated with valid vnic_id and rss_ctx_idx,
+	 * if FW is VNIC_RSS_HASH_MODE capable. FW configures the mode based
+	 * on first come first serve order. Global RSS hash mode and VNIC RSS
+	 * hash modes are mutually exclusive. FW returns invalid error
+	 * if FW receives conflicting requests. To change the current hash
+	 * mode, the mode associated drivers need to be unloaded and apply
+	 * the new configuration.
+	 */
+	uint8_t	hash_mode_flags;
+	/*
+	 * When this bit is '1' and FW is VNIC_RSS_HASH_MODE capable,
+	 * innermost_4 and innermost_2 hash modes are used to configure
+	 * the tuple mode. When this bit is '1' and FW is not
+	 * VNIC_RSS_HASH_MODE capable, It indicates using current RSS hash
+	 * mode setting configured in the device otherwise.
+	 */
+	#define HWRM_VNIC_RSS_CFG_INPUT_HASH_MODE_FLAGS_DEFAULT	UINT32_C(0x1)
+	/*
+	 * When this bit is '1', it indicates requesting support of
+	 * RSS hashing over innermost 4 tuples {l3.src, l3.dest,
+	 * l4.src, l4.dest} for tunnel packets. For none-tunnel
+	 * packets, the RSS hash is computed over the normal
+	 * src/dest l3 and src/dest l4 headers.
+	 */
+	#define HWRM_VNIC_RSS_CFG_INPUT_HASH_MODE_FLAGS_INNERMOST_4	UINT32_C(0x2)
+	/*
+	 * When this bit is '1', it indicates requesting support of
+	 * RSS hashing over innermost 2 tuples {l3.src, l3.dest} for
+	 * tunnel packets. For none-tunnel packets, the RSS hash is
+	 * computed over the normal src/dest l3 headers.
+	 */
+	#define HWRM_VNIC_RSS_CFG_INPUT_HASH_MODE_FLAGS_INNERMOST_2	UINT32_C(0x4)
+	/*
+	 * When this bit is '1', it indicates requesting support of
+	 * RSS hashing over outermost 4 tuples {t_l3.src, t_l3.dest,
+	 * t_l4.src, t_l4.dest} for tunnel packets. For none-tunnel
+	 * packets, the RSS hash is computed over the normal
+	 * src/dest l3 and src/dest l4 headers.
+	 */
+	#define HWRM_VNIC_RSS_CFG_INPUT_HASH_MODE_FLAGS_OUTERMOST_4	UINT32_C(0x8)
+	/*
+	 * When this bit is '1', it indicates requesting support of
+	 * RSS hashing over outermost 2 tuples {t_l3.src, t_l3.dest} for
+	 * tunnel packets. For none-tunnel packets, the RSS hash is
+	 * computed over the normal src/dest l3 headers.
+	 */
+	#define HWRM_VNIC_RSS_CFG_INPUT_HASH_MODE_FLAGS_OUTERMOST_2	UINT32_C(0x10)
+	/* This is the address for rss ring group table */
+	uint64_t	ring_grp_tbl_addr;
+	/* This is the address for rss hash key table */
+	uint64_t	hash_key_tbl_addr;
+	/* Index to the rss indirection table. */
+	uint16_t	rss_ctx_idx;
+	uint8_t	flags;
+	/*
+	 * When this bit is '1', it indicates that the hash_type field is
+	 * interpreted as a change relative the current configuration. Each
+	 * '1' bit in hash_type represents a header to add to the current
+	 * hash. Zeroes designate the hash_type state bits that should remain
+	 * unchanged, if possible. If this constraint on the existing state
+	 * cannot be satisfied, then the implementation should preference
+	 * adding other headers so as to honor the request to add the
+	 * specified headers. It is an error to set this flag concurrently
+	 * with hash_type_exclude.
+	 */
+	#define HWRM_VNIC_RSS_CFG_INPUT_FLAGS_HASH_TYPE_INCLUDE		UINT32_C(0x1)
+	/*
+	 * When this bit is '1', it indicates that the hash_type field is
+	 * interpreted as a change relative the current configuration. Each
+	 * '1' bit in hash_type represents a header to remove from the
+	 * current hash. Zeroes designate the hash_type state bits that
+	 * should remain unchanged, if possible. If this constraint on the
+	 * existing state cannot be satisfied, then the implementation should
+	 * preference removing other headers so as to honor the request to
+	 * remove the specified headers. It is an error to set this flag
+	 * concurrently with hash_type_include.
+	 */
+	#define HWRM_VNIC_RSS_CFG_INPUT_FLAGS_HASH_TYPE_EXCLUDE		UINT32_C(0x2)
+	/*
+	 * When this bit is '1', it indicates that the support of setting
+	 * ipsec hash_types by the host drivers.
+	 */
+	#define HWRM_VNIC_RSS_CFG_INPUT_FLAGS_IPSEC_HASH_TYPE_CFG_SUPPORT	UINT32_C(0x4)
+	uint8_t	ring_select_mode;
+	/*
+	 * In this mode, HW uses Toeplitz algorithm and provided Toeplitz
+	 * hash key to hash the packets according to the configured hash
+	 * type and hash mode. The Toeplitz hash results and the provided
+	 * Toeplitz RSS indirection table are used to determine the RSS
+	 * rings.
+	 */
+	#define HWRM_VNIC_RSS_CFG_INPUT_RING_SELECT_MODE_TOEPLITZ	UINT32_C(0x0)
+	/*
+	 * In this mode, HW uses XOR algorithm to hash the packets according
+	 * to the configured hash type and hash mode. The XOR hash results
+	 * and the provided XOR RSS indirection table are used to determine
+	 * the RSS rings. Host drivers provided hash key is not honored in
+	 * this mode.
+	 */
+	#define HWRM_VNIC_RSS_CFG_INPUT_RING_SELECT_MODE_XOR		UINT32_C(0x1)
+	/*
+	 * In this mode, HW uses inner packets checksum algorithm to
+	 * distribute the packets across the rings and Toeplitz algorithm
+	 * to calculate the hash to convey it in the RX completions. Host
+	 * drivers should provide Toeplitz hash key. As HW uses innermost
+	 * packets checksum to distribute the packets across the rings,
+	 * host drivers can't convey hash mode to choose outer headers to
+	 * calculate Toeplitz hash. FW will fail such configuration.
+	 */
+	#define HWRM_VNIC_RSS_CFG_INPUT_RING_SELECT_MODE_TOEPLITZ_CHECKSUM UINT32_C(0x2)
+	#define HWRM_VNIC_RSS_CFG_INPUT_RING_SELECT_MODE_LAST		HWRM_VNIC_RSS_CFG_INPUT_RING_SELECT_MODE_TOEPLITZ_CHECKSUM
+	uint8_t	unused_1[4];
+} hwrm_vnic_rss_cfg_input_t, *phwrm_vnic_rss_cfg_input_t;
+
+/* hwrm_vnic_rss_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_vnic_rss_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_vnic_rss_cfg_output_t, *phwrm_vnic_rss_cfg_output_t;
+
+/* hwrm_vnic_rss_cfg_cmd_err (size:64b/8B) */
+
+typedef struct hwrm_vnic_rss_cfg_cmd_err {
+	/*
+	 * command specific error codes that goes to
+	 * the cmd_err field in Common HWRM Error Response.
+	 */
+	uint8_t	code;
+	/* Unknown error */
+	#define HWRM_VNIC_RSS_CFG_CMD_ERR_CODE_UNKNOWN		UINT32_C(0x0)
+	/*
+	 * Unable to change global RSS mode to outer due to all active
+	 * interfaces are not ready to support outer RSS hashing.
+	 */
+	#define HWRM_VNIC_RSS_CFG_CMD_ERR_CODE_INTERFACE_NOT_READY UINT32_C(0x1)
+	#define HWRM_VNIC_RSS_CFG_CMD_ERR_CODE_LAST		HWRM_VNIC_RSS_CFG_CMD_ERR_CODE_INTERFACE_NOT_READY
+	uint8_t	unused_0[7];
+} hwrm_vnic_rss_cfg_cmd_err_t, *phwrm_vnic_rss_cfg_cmd_err_t;
+
+/**********************
+ * hwrm_vnic_rss_qcfg *
+ **********************/
+
+
+/* hwrm_vnic_rss_qcfg_input (size:192b/24B) */
+
+typedef struct hwrm_vnic_rss_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/*
+	 * Index to the rss indirection table. This field is used as a lookup
+	 * for chips before Thor - i.e. Cumulus and Whitney.
+	 */
+	uint16_t	rss_ctx_idx;
+	/*
+	 * VNIC ID of VNIC associated with RSS table being queried. This field
+	 * is used as a lookup for Thor and later chips.
+	 */
+	uint16_t	vnic_id;
+	uint8_t	unused_0[4];
+} hwrm_vnic_rss_qcfg_input_t, *phwrm_vnic_rss_qcfg_input_t;
+
+/* hwrm_vnic_rss_qcfg_output (size:512b/64B) */
+
+typedef struct hwrm_vnic_rss_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint32_t	hash_type;
+	/*
+	 * When this bit is '1', the RSS hash shall be computed
+	 * over source and destination IPv4 addresses of IPv4
+	 * packets.
+	 */
+	#define HWRM_VNIC_RSS_QCFG_OUTPUT_HASH_TYPE_IPV4		UINT32_C(0x1)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed
+	 * over source/destination IPv4 addresses and
+	 * source/destination ports of TCP/IPv4 packets.
+	 */
+	#define HWRM_VNIC_RSS_QCFG_OUTPUT_HASH_TYPE_TCP_IPV4		UINT32_C(0x2)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed
+	 * over source/destination IPv4 addresses and
+	 * source/destination ports of UDP/IPv4 packets.
+	 */
+	#define HWRM_VNIC_RSS_QCFG_OUTPUT_HASH_TYPE_UDP_IPV4		UINT32_C(0x4)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed
+	 * over source and destination IPv6 addresses of IPv6
+	 * packets.
+	 */
+	#define HWRM_VNIC_RSS_QCFG_OUTPUT_HASH_TYPE_IPV6		UINT32_C(0x8)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed
+	 * over source/destination IPv6 addresses and
+	 * source/destination ports of TCP/IPv6 packets.
+	 */
+	#define HWRM_VNIC_RSS_QCFG_OUTPUT_HASH_TYPE_TCP_IPV6		UINT32_C(0x10)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed
+	 * over source/destination IPv6 addresses and
+	 * source/destination ports of UDP/IPv6 packets.
+	 */
+	#define HWRM_VNIC_RSS_QCFG_OUTPUT_HASH_TYPE_UDP_IPV6		UINT32_C(0x20)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed
+	 * over source, destination IPv6 addresses and flow label of IPv6
+	 * packets. Hash type ipv6 and ipv6_flow_label are mutually
+	 * exclusive. HW does not include the flow_label in hash
+	 * calculation for the packets that are matching tcp_ipv6 and
+	 * udp_ipv6 hash types. This bit will be '0' if
+	 * rss_ipv6_flow_label_cap is '0'.
+	 */
+	#define HWRM_VNIC_RSS_QCFG_OUTPUT_HASH_TYPE_IPV6_FLOW_LABEL	UINT32_C(0x40)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed over
+	 * source/destination IPv4 addresses and IPSEC AH SPI field of IPSEC
+	 * AH/IPv4 packets. This bit will be '0' if rss_ipsec_ah_spi_ipv4_cap
+	 * is '0'.
+	 */
+	#define HWRM_VNIC_RSS_QCFG_OUTPUT_HASH_TYPE_AH_SPI_IPV4	UINT32_C(0x80)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed over
+	 * source/destination IPv4 addresses and IPSEC ESP SPI field of IPSEC
+	 * ESP/IPv4 packets. This bit will be '0' if
+	 * rss_ipsec_esp_spi_ipv4_cap is '0'.
+	 */
+	#define HWRM_VNIC_RSS_QCFG_OUTPUT_HASH_TYPE_ESP_SPI_IPV4	UINT32_C(0x100)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed over
+	 * source/destination IPv6 addresses and IPSEC AH SPI field of IPSEC
+	 * AH/IPv6 packets. This bit will be '0' if
+	 * rss_ipsec_ah_spi_ipv6_cap is '0'.
+	 */
+	#define HWRM_VNIC_RSS_QCFG_OUTPUT_HASH_TYPE_AH_SPI_IPV6	UINT32_C(0x200)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed over
+	 * source/destination IPv6 addresses and IPSEC ESP SPI field of IPSEC
+	 * ESP/IPv6 packets. This bit will be '0' if
+	 * rss_ipsec_esp_spi_ipv6_cap is '0'.
+	 */
+	#define HWRM_VNIC_RSS_QCFG_OUTPUT_HASH_TYPE_ESP_SPI_IPV6	UINT32_C(0x400)
+	uint8_t	unused_0[4];
+	/* This is the value of rss hash key */
+	uint32_t	hash_key[10];
+	/*
+	 * Flags to specify different RSS hash modes. Setting rss_ctx_idx to
+	 * the value of 0xffff implies a global RSS configuration query.
+	 * hash_mode_flags are only valid for global RSS configuration query.
+	 * Only the PF can initiate a global RSS configuration query.
+	 * The query request fails if any VNIC is configured with hash mode
+	 * and rss_ctx_idx is 0xffff.
+	 */
+	uint8_t	hash_mode_flags;
+	/*
+	 * When this bit is '1' and FW is VNIC_RSS_HASH_MODE capable,
+	 * it indicates VNIC's configured RSS hash mode.
+	 * When this bit is '1' and FW is not VNIC_RSS_HASH_MODE capable,
+	 * It indicates using current RSS hash mode setting configured in the
+	 * device.
+	 */
+	#define HWRM_VNIC_RSS_QCFG_OUTPUT_HASH_MODE_FLAGS_DEFAULT	UINT32_C(0x1)
+	/*
+	 * When this bit is '1', it indicates requesting support of
+	 * RSS hashing over innermost 4 tuples {l3.src, l3.dest,
+	 * l4.src, l4.dest} for tunnel packets. For none-tunnel
+	 * packets, the RSS hash is computed over the normal
+	 * src/dest l3 and src/dest l4 headers.
+	 */
+	#define HWRM_VNIC_RSS_QCFG_OUTPUT_HASH_MODE_FLAGS_INNERMOST_4	UINT32_C(0x2)
+	/*
+	 * When this bit is '1', it indicates requesting support of
+	 * RSS hashing over innermost 2 tuples {l3.src, l3.dest} for
+	 * tunnel packets. For none-tunnel packets, the RSS hash is
+	 * computed over the normal src/dest l3 headers.
+	 */
+	#define HWRM_VNIC_RSS_QCFG_OUTPUT_HASH_MODE_FLAGS_INNERMOST_2	UINT32_C(0x4)
+	/*
+	 * When this bit is '1', it indicates requesting support of
+	 * RSS hashing over outermost 4 tuples {t_l3.src, t_l3.dest,
+	 * t_l4.src, t_l4.dest} for tunnel packets. For none-tunnel
+	 * packets, the RSS hash is computed over the normal
+	 * src/dest l3 and src/dest l4 headers.
+	 */
+	#define HWRM_VNIC_RSS_QCFG_OUTPUT_HASH_MODE_FLAGS_OUTERMOST_4	UINT32_C(0x8)
+	/*
+	 * When this bit is '1', it indicates requesting support of
+	 * RSS hashing over outermost 2 tuples {t_l3.src, t_l3.dest} for
+	 * tunnel packets. For none-tunnel packets, the RSS hash is
+	 * computed over the normal src/dest l3 headers.
+	 */
+	#define HWRM_VNIC_RSS_QCFG_OUTPUT_HASH_MODE_FLAGS_OUTERMOST_2	UINT32_C(0x10)
+	uint8_t	ring_select_mode;
+	/*
+	 * In this mode, HW uses Toeplitz algorithm and provided Toeplitz
+	 * hash key to hash the packets according to the configured hash
+	 * type and hash mode. The Toeplitz hash results and the provided
+	 * Toeplitz RSS indirection table are used to determine the RSS
+	 * rings.
+	 */
+	#define HWRM_VNIC_RSS_QCFG_OUTPUT_RING_SELECT_MODE_TOEPLITZ	UINT32_C(0x0)
+	/*
+	 * In this mode, HW uses XOR algorithm to hash the packets according
+	 * to the configured hash type and hash mode. The XOR hash results
+	 * and the provided XOR RSS indirection table are used to determine
+	 * the RSS rings. Host drivers provided hash key is not honored in
+	 * this mode.
+	 */
+	#define HWRM_VNIC_RSS_QCFG_OUTPUT_RING_SELECT_MODE_XOR		UINT32_C(0x1)
+	/*
+	 * In this mode, HW uses inner packets checksum algorithm to
+	 * distribute the packets across the rings and Toeplitz algorithm
+	 * to calculate the hash to convey it in the RX completions. Host
+	 * drivers should provide Toeplitz hash key. As HW uses innermost
+	 * packets checksum to distribute the packets across the rings,
+	 * host drivers can't convey hash mode to choose outer headers to
+	 * calculate Toeplitz hash. FW will fail such configuration.
+	 */
+	#define HWRM_VNIC_RSS_QCFG_OUTPUT_RING_SELECT_MODE_TOEPLITZ_CHECKSUM UINT32_C(0x2)
+	#define HWRM_VNIC_RSS_QCFG_OUTPUT_RING_SELECT_MODE_LAST		HWRM_VNIC_RSS_QCFG_OUTPUT_RING_SELECT_MODE_TOEPLITZ_CHECKSUM
+	uint8_t	unused_1[5];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_vnic_rss_qcfg_output_t, *phwrm_vnic_rss_qcfg_output_t;
+
+/**************************
+ * hwrm_vnic_plcmodes_cfg *
+ **************************/
+
+
+/* hwrm_vnic_plcmodes_cfg_input (size:320b/40B) */
+
+typedef struct hwrm_vnic_plcmodes_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	flags;
+	/*
+	 * When this bit is '1', the VNIC shall be configured to
+	 * use regular placement algorithm.
+	 * By default, the regular placement algorithm shall be
+	 * enabled on the VNIC.
+	 */
+	#define HWRM_VNIC_PLCMODES_CFG_INPUT_FLAGS_REGULAR_PLACEMENT	UINT32_C(0x1)
+	/*
+	 * When this bit is '1', the VNIC shall be configured
+	 * use the jumbo placement algorithm.
+	 */
+	#define HWRM_VNIC_PLCMODES_CFG_INPUT_FLAGS_JUMBO_PLACEMENT	UINT32_C(0x2)
+	/*
+	 * When this bit is '1', the VNIC shall be configured
+	 * to enable Header-Data split for IPv4 packets according
+	 * to the following rules:
+	 * # If the packet is identified as TCP/IPv4, then the
+	 * packet is split at the beginning of the TCP payload.
+	 * # If the packet is identified as UDP/IPv4, then the
+	 * packet is split at the beginning of UDP payload.
+	 * # If the packet is identified as non-TCP and non-UDP
+	 * IPv4 packet, then the packet is split at the beginning
+	 * of the upper layer protocol header carried in the IPv4
+	 * packet.
+	 */
+	#define HWRM_VNIC_PLCMODES_CFG_INPUT_FLAGS_HDS_IPV4		UINT32_C(0x4)
+	/*
+	 * When this bit is '1', the VNIC shall be configured
+	 * to enable Header-Data split for IPv6 packets according
+	 * to the following rules:
+	 * # If the packet is identified as TCP/IPv6, then the
+	 * packet is split at the beginning of the TCP payload.
+	 * # If the packet is identified as UDP/IPv6, then the
+	 * packet is split at the beginning of UDP payload.
+	 * # If the packet is identified as non-TCP and non-UDP
+	 * IPv6 packet, then the packet is split at the beginning
+	 * of the upper layer protocol header carried in the IPv6
+	 * packet.
+	 */
+	#define HWRM_VNIC_PLCMODES_CFG_INPUT_FLAGS_HDS_IPV6		UINT32_C(0x8)
+	/*
+	 * When this bit is '1', the VNIC shall be configured
+	 * to enable Header-Data split for FCoE packets at the
+	 * beginning of FC payload.
+	 */
+	#define HWRM_VNIC_PLCMODES_CFG_INPUT_FLAGS_HDS_FCOE		UINT32_C(0x10)
+	/*
+	 * When this bit is '1', the VNIC shall be configured
+	 * to enable Header-Data split for RoCE packets at the
+	 * beginning of RoCE payload (after BTH/GRH headers).
+	 */
+	#define HWRM_VNIC_PLCMODES_CFG_INPUT_FLAGS_HDS_ROCE		UINT32_C(0x20)
+	/*
+	 * When this bit is '1', the VNIC shall be configured use the virtio
+	 * placement algorithm. This feature can only be configured when
+	 * proxy mode is supported on the function.
+	 */
+	#define HWRM_VNIC_PLCMODES_CFG_INPUT_FLAGS_VIRTIO_PLACEMENT	UINT32_C(0x40)
+	uint32_t	enables;
+	/*
+	 * This bit must be '1' for the jumbo_thresh_valid field to be
+	 * configured.
+	 */
+	#define HWRM_VNIC_PLCMODES_CFG_INPUT_ENABLES_JUMBO_THRESH_VALID	UINT32_C(0x1)
+	/*
+	 * This bit must be '1' for the hds_offset_valid field to be
+	 * configured.
+	 */
+	#define HWRM_VNIC_PLCMODES_CFG_INPUT_ENABLES_HDS_OFFSET_VALID	UINT32_C(0x2)
+	/*
+	 * This bit must be '1' for the hds_threshold_valid field to be
+	 * configured.
+	 */
+	#define HWRM_VNIC_PLCMODES_CFG_INPUT_ENABLES_HDS_THRESHOLD_VALID	UINT32_C(0x4)
+	/*
+	 * This bit must be '1' for the max_bds_valid field to be
+	 * configured.
+	 */
+	#define HWRM_VNIC_PLCMODES_CFG_INPUT_ENABLES_MAX_BDS_VALID	UINT32_C(0x8)
+	/* Logical vnic ID */
+	uint32_t	vnic_id;
+	/*
+	 * When jumbo placement algorithm is enabled, this value
+	 * is used to determine the threshold for jumbo placement.
+	 * Packets with length larger than this value will be
+	 * placed according to the jumbo placement algorithm.
+	 */
+	uint16_t	jumbo_thresh;
+	/*
+	 * This value is used to determine the offset into
+	 * packet buffer where the split data (payload) will be
+	 * placed according to one of HDS placement algorithm.
+	 *
+	 * The lengths of packet buffers provided for split data
+	 * shall be larger than this value.
+	 */
+	uint16_t	hds_offset;
+	/*
+	 * When one of the HDS placement algorithm is enabled, this
+	 * value is used to determine the threshold for HDS
+	 * placement.
+	 * Packets with length larger than this value will be
+	 * placed according to the HDS placement algorithm.
+	 * This value shall be in multiple of 4 bytes.
+	 */
+	uint16_t	hds_threshold;
+	/*
+	 * When virtio placement algorithm is enabled, this
+	 * value is used to determine the maximum number of BDs
+	 * that can be used to place an Rx Packet.
+	 * If an incoming packet does not fit in the buffers described
+	 * by the max BDs, the packet will be dropped and an error
+	 * will be reported in the completion. Valid values for this
+	 * field are between 1 and 8. If the VNIC uses header-data-
+	 * separation and/or TPA with buffer spanning enabled, valid
+	 * values for this field are between 2 and 8.
+	 * This feature can only be configured when proxy mode is
+	 * supported on the function.
+	 */
+	uint16_t	max_bds;
+	uint8_t	unused_0[4];
+} hwrm_vnic_plcmodes_cfg_input_t, *phwrm_vnic_plcmodes_cfg_input_t;
+
+/* hwrm_vnic_plcmodes_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_vnic_plcmodes_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
+	 */
+	uint8_t	valid;
+} hwrm_vnic_plcmodes_cfg_output_t, *phwrm_vnic_plcmodes_cfg_output_t;
+
+/***************************
+ * hwrm_vnic_plcmodes_qcfg *
+ ***************************/
+
+
+/* hwrm_vnic_plcmodes_qcfg_input (size:192b/24B) */
+
+typedef struct hwrm_vnic_plcmodes_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Logical vnic ID */
+	uint32_t	vnic_id;
+	uint8_t	unused_0[4];
+} hwrm_vnic_plcmodes_qcfg_input_t, *phwrm_vnic_plcmodes_qcfg_input_t;
+
+/* hwrm_vnic_plcmodes_qcfg_output (size:192b/24B) */
+
+typedef struct hwrm_vnic_plcmodes_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint32_t	flags;
+	/*
+	 * When this bit is '1', the VNIC is configured to
+	 * use regular placement algorithm.
+	 */
+	#define HWRM_VNIC_PLCMODES_QCFG_OUTPUT_FLAGS_REGULAR_PLACEMENT	UINT32_C(0x1)
+	/*
+	 * When this bit is '1', the VNIC is configured to
+	 * use the jumbo placement algorithm.
+	 */
+	#define HWRM_VNIC_PLCMODES_QCFG_OUTPUT_FLAGS_JUMBO_PLACEMENT	UINT32_C(0x2)
+	/*
+	 * When this bit is '1', the VNIC is configured
+	 * to enable Header-Data split for IPv4 packets.
+	 */
+	#define HWRM_VNIC_PLCMODES_QCFG_OUTPUT_FLAGS_HDS_IPV4		UINT32_C(0x4)
+	/*
+	 * When this bit is '1', the VNIC is configured
+	 * to enable Header-Data split for IPv6 packets.
+	 */
+	#define HWRM_VNIC_PLCMODES_QCFG_OUTPUT_FLAGS_HDS_IPV6		UINT32_C(0x8)
+	/*
+	 * When this bit is '1', the VNIC is configured
+	 * to enable Header-Data split for FCoE packets.
+	 */
+	#define HWRM_VNIC_PLCMODES_QCFG_OUTPUT_FLAGS_HDS_FCOE		UINT32_C(0x10)
+	/*
+	 * When this bit is '1', the VNIC is configured
+	 * to enable Header-Data split for RoCE packets.
+	 */
+	#define HWRM_VNIC_PLCMODES_QCFG_OUTPUT_FLAGS_HDS_ROCE		UINT32_C(0x20)
+	/*
+	 * When this bit is '1', the VNIC is configured
+	 * to be the default VNIC of the requesting function.
+	 */
+	#define HWRM_VNIC_PLCMODES_QCFG_OUTPUT_FLAGS_DFLT_VNIC		UINT32_C(0x40)
+	/*
+	 * When this bit is '1', the VNIC is configured to use the virtio
+	 * placement algorithm. This feature can only be configured when
+	 * proxy mode is supported on the function.
+	 */
+	#define HWRM_VNIC_PLCMODES_QCFG_OUTPUT_FLAGS_VIRTIO_PLACEMENT	UINT32_C(0x80)
+	/*
+	 * When jumbo placement algorithm is enabled, this value
+	 * is used to determine the threshold for jumbo placement.
+	 * Packets with length larger than this value will be
+	 * placed according to the jumbo placement algorithm.
+	 */
+	uint16_t	jumbo_thresh;
+	/*
+	 * This value is used to determine the offset into
+	 * packet buffer where the split data (payload) will be
+	 * placed according to one of HDS placement algorithm.
+	 *
+	 * The lengths of packet buffers provided for split data
+	 * shall be larger than this value.
+	 */
+	uint16_t	hds_offset;
+	/*
+	 * When one of the HDS placement algorithm is enabled, this
+	 * value is used to determine the threshold for HDS
+	 * placement.
+	 * Packets with length larger than this value will be
+	 * placed according to the HDS placement algorithm.
+	 * This value shall be in multiple of 4 bytes.
+	 */
+	uint16_t	hds_threshold;
+	/*
+	 * When virtio placement algorithm is enabled, this
+	 * value is used to determine the maximum number of BDs
+	 * that can be used to place an Rx Packet.
+	 * If an incoming packet does not fit in the buffers described
+	 * by the max BDs, the packet will be dropped and an error
+	 * will be reported in the completion. Valid values for this
+	 * field are between 1 and 8. If the VNIC uses header-data-
+	 * separation and/or TPA with buffer spanning enabled, valid
+	 * values for this field are between 2 and 8.
+	 * This feature can only be configured when proxy mode is supported
+	 * on the function
+	 */
+	uint16_t	max_bds;
+	uint8_t	unused_0[3];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
+	 */
+	uint8_t	valid;
+} hwrm_vnic_plcmodes_qcfg_output_t, *phwrm_vnic_plcmodes_qcfg_output_t;
+
+/**********************************
+ * hwrm_vnic_rss_cos_lb_ctx_alloc *
+ **********************************/
+
+
+/* hwrm_vnic_rss_cos_lb_ctx_alloc_input (size:128b/16B) */
+
+typedef struct hwrm_vnic_rss_cos_lb_ctx_alloc_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+} hwrm_vnic_rss_cos_lb_ctx_alloc_input_t, *phwrm_vnic_rss_cos_lb_ctx_alloc_input_t;
+
+/* hwrm_vnic_rss_cos_lb_ctx_alloc_output (size:128b/16B) */
+
+typedef struct hwrm_vnic_rss_cos_lb_ctx_alloc_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* rss_cos_lb_ctx_id is 16 b */
+	uint16_t	rss_cos_lb_ctx_id;
+	uint8_t	unused_0[5];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_vnic_rss_cos_lb_ctx_alloc_output_t, *phwrm_vnic_rss_cos_lb_ctx_alloc_output_t;
+
+/*********************************
+ * hwrm_vnic_rss_cos_lb_ctx_free *
+ *********************************/
+
+
+/* hwrm_vnic_rss_cos_lb_ctx_free_input (size:192b/24B) */
+
+typedef struct hwrm_vnic_rss_cos_lb_ctx_free_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* rss_cos_lb_ctx_id is 16 b */
+	uint16_t	rss_cos_lb_ctx_id;
+	uint8_t	unused_0[6];
+} hwrm_vnic_rss_cos_lb_ctx_free_input_t, *phwrm_vnic_rss_cos_lb_ctx_free_input_t;
+
+/* hwrm_vnic_rss_cos_lb_ctx_free_output (size:128b/16B) */
+
+typedef struct hwrm_vnic_rss_cos_lb_ctx_free_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_vnic_rss_cos_lb_ctx_free_output_t, *phwrm_vnic_rss_cos_lb_ctx_free_output_t;
+
+/*******************
+ * hwrm_ring_alloc *
+ *******************/
+
+
+/* hwrm_ring_alloc_input (size:704b/88B) */
+
+typedef struct hwrm_ring_alloc_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	enables;
+	/*
+	 * This bit must be '1' for the ring_arb_cfg field to be
+	 * configured.
+	 */
+	#define HWRM_RING_ALLOC_INPUT_ENABLES_RING_ARB_CFG	UINT32_C(0x2)
+	/*
+	 * This bit must be '1' for the stat_ctx_id_valid field to be
+	 * configured.
+	 */
+	#define HWRM_RING_ALLOC_INPUT_ENABLES_STAT_CTX_ID_VALID	UINT32_C(0x8)
+	/*
+	 * This bit must be '1' for the max_bw_valid field to be
+	 * configured.
+	 */
+	#define HWRM_RING_ALLOC_INPUT_ENABLES_MAX_BW_VALID	UINT32_C(0x20)
+	/*
+	 * This bit must be '1' for the rx_ring_id field to be
+	 * configured.
+	 */
+	#define HWRM_RING_ALLOC_INPUT_ENABLES_RX_RING_ID_VALID	UINT32_C(0x40)
+	/*
+	 * This bit must be '1' for the nq_ring_id field to be
+	 * configured.
+	 */
+	#define HWRM_RING_ALLOC_INPUT_ENABLES_NQ_RING_ID_VALID	UINT32_C(0x80)
+	/*
+	 * This bit must be '1' for the rx_buf_size field to be
+	 * configured.
+	 */
+	#define HWRM_RING_ALLOC_INPUT_ENABLES_RX_BUF_SIZE_VALID	UINT32_C(0x100)
+	/*
+	 * This bit must be '1' for the schq_id field to be
+	 * configured.
+	 */
+	#define HWRM_RING_ALLOC_INPUT_ENABLES_SCHQ_ID		UINT32_C(0x200)
+	/*
+	 * This bit must be '1' for the mpc_chnls_type field to be
+	 * configured.
+	 */
+	#define HWRM_RING_ALLOC_INPUT_ENABLES_MPC_CHNLS_TYPE	UINT32_C(0x400)
+	/*
+	 * This bit must be '1' for the steering_tag field to be
+	 * configured.
+	 */
+	#define HWRM_RING_ALLOC_INPUT_ENABLES_STEERING_TAG_VALID	UINT32_C(0x800)
+	/* Ring Type. */
+	uint8_t	ring_type;
+	/* L2 Completion Ring (CR) */
+	#define HWRM_RING_ALLOC_INPUT_RING_TYPE_L2_CMPL   UINT32_C(0x0)
+	/* TX Ring (TR) */
+	#define HWRM_RING_ALLOC_INPUT_RING_TYPE_TX	UINT32_C(0x1)
+	/* RX Ring (RR) */
+	#define HWRM_RING_ALLOC_INPUT_RING_TYPE_RX	UINT32_C(0x2)
+	/* RoCE Notification Completion Ring (ROCE_CR) */
+	#define HWRM_RING_ALLOC_INPUT_RING_TYPE_ROCE_CMPL UINT32_C(0x3)
+	/* RX Aggregation Ring */
+	#define HWRM_RING_ALLOC_INPUT_RING_TYPE_RX_AGG	UINT32_C(0x4)
+	/* Notification Queue */
+	#define HWRM_RING_ALLOC_INPUT_RING_TYPE_NQ	UINT32_C(0x5)
+	#define HWRM_RING_ALLOC_INPUT_RING_TYPE_LAST	HWRM_RING_ALLOC_INPUT_RING_TYPE_NQ
+	/*
+	 * This field controls the number of packets transmitted before a TX
+	 * completion is generated. Non-zero values for the field are only
+	 * valid if HWRM_FUNC_QCAPS indicates that the TX coalesced completion
+	 * records capability is supported.
+	 */
+	uint8_t	cmpl_coal_cnt;
+	/* Generates a legacy TX completion on every packet. */
+	#define HWRM_RING_ALLOC_INPUT_CMPL_COAL_CNT_COAL_OFF UINT32_C(0x0)
+	/* Generates a TX coalesced completion for up to 4 TX packets. */
+	#define HWRM_RING_ALLOC_INPUT_CMPL_COAL_CNT_COAL_4   UINT32_C(0x1)
+	/* Generates a TX coalesced completion for up to 8 TX packets. */
+	#define HWRM_RING_ALLOC_INPUT_CMPL_COAL_CNT_COAL_8   UINT32_C(0x2)
+	/* Generates a TX coalesced completion for up to 12 TX packets. */
+	#define HWRM_RING_ALLOC_INPUT_CMPL_COAL_CNT_COAL_12  UINT32_C(0x3)
+	/* Generates a TX coalesced completion for up to 16 TX packets. */
+	#define HWRM_RING_ALLOC_INPUT_CMPL_COAL_CNT_COAL_16  UINT32_C(0x4)
+	/* Generates a TX coalesced completion for up to 24 TX packets. */
+	#define HWRM_RING_ALLOC_INPUT_CMPL_COAL_CNT_COAL_24  UINT32_C(0x5)
+	/* Generates a TX coalesced completion for up to 32 TX packets. */
+	#define HWRM_RING_ALLOC_INPUT_CMPL_COAL_CNT_COAL_32  UINT32_C(0x6)
+	/* Generates a TX coalesced completion for up to 48 TX packets. */
+	#define HWRM_RING_ALLOC_INPUT_CMPL_COAL_CNT_COAL_48  UINT32_C(0x7)
+	/* Generates a TX coalesced completion for up to 64 TX packets. */
+	#define HWRM_RING_ALLOC_INPUT_CMPL_COAL_CNT_COAL_64  UINT32_C(0x8)
+	/* Generates a TX coalesced completion for up to 96 TX packets. */
+	#define HWRM_RING_ALLOC_INPUT_CMPL_COAL_CNT_COAL_96  UINT32_C(0x9)
+	/* Generates a TX coalesced completion for up to 128 TX packets. */
+	#define HWRM_RING_ALLOC_INPUT_CMPL_COAL_CNT_COAL_128 UINT32_C(0xa)
+	/* Generates a TX coalesced completion for up to 192 TX packets. */
+	#define HWRM_RING_ALLOC_INPUT_CMPL_COAL_CNT_COAL_192 UINT32_C(0xb)
+	/* Generates a TX coalesced completion for up to 256 TX packets. */
+	#define HWRM_RING_ALLOC_INPUT_CMPL_COAL_CNT_COAL_256 UINT32_C(0xc)
+	/* Generates a TX coalesced completion for up to 320 TX packets. */
+	#define HWRM_RING_ALLOC_INPUT_CMPL_COAL_CNT_COAL_320 UINT32_C(0xd)
+	/* Generates a TX coalesced completion for up to 384 TX packets. */
+	#define HWRM_RING_ALLOC_INPUT_CMPL_COAL_CNT_COAL_384 UINT32_C(0xe)
+	/* Generates a TX coalesced completion up to the last packet. (Maximum coalescing). */
+	#define HWRM_RING_ALLOC_INPUT_CMPL_COAL_CNT_COAL_MAX UINT32_C(0xf)
+	#define HWRM_RING_ALLOC_INPUT_CMPL_COAL_CNT_LAST	HWRM_RING_ALLOC_INPUT_CMPL_COAL_CNT_COAL_MAX
+	/* Ring allocation flags. */
+	uint16_t	flags;
+	/*
+	 * For Rx rings, the incoming packet data can be placed at either
+	 * a 0B or 2B offset from the start of the Rx packet buffer. When
+	 * '1', the received packet will be padded with 2B of zeros at the
+	 * front of the packet. Note that this flag is only used for
+	 * Rx rings and is ignored for all other rings included Rx
+	 * Aggregation rings.
+	 */
+	#define HWRM_RING_ALLOC_INPUT_FLAGS_RX_SOP_PAD			UINT32_C(0x1)
+	/*
+	 * When the HW Doorbell Drop Recovery feature is enabled,
+	 * HW can flag false CQ overflow when CQ consumer index
+	 * doorbells are dropped when there really wasn't any overflow.
+	 * The CQE values could have already been processed by the driver,
+	 * but HW doesn't know about this because of the doorbell drop.
+	 * To avoid false detection of CQ overflow events,
+	 * it is recommended that CQ overflow detection is disabled
+	 * by the driver when HW based doorbell recovery is enabled.
+	 */
+	#define HWRM_RING_ALLOC_INPUT_FLAGS_DISABLE_CQ_OVERFLOW_DETECTION	UINT32_C(0x2)
+	/*
+	 * Used with enhanced Doorbell Pacing feature, when set to '1'
+	 * this flag indicates that the NQ id that's allocated should be
+	 * used for DBR pacing notifications.
+	 */
+	#define HWRM_RING_ALLOC_INPUT_FLAGS_NQ_DBR_PACING			UINT32_C(0x4)
+	/*
+	 * Host driver should set this flag bit to '1' to enable
+	 * two-completion TX packet timestamp feature. By enabling this
+	 * per QP flag and enabling stamp bit in TX BD lflags, host drivers
+	 * expect two completions, one for regular TX completion and the
+	 * other completion with timestamp. For a QP with both completion
+	 * coalescing and timestamp completion features enabled, completion
+	 * coalescing takes place on regular TX completions. The timestamp
+	 * completions are not coalesced and a separate timestamp completion
+	 * is generated for each packet with stamp bit set in the TX BD
+	 * lflags.
+	 */
+	#define HWRM_RING_ALLOC_INPUT_FLAGS_TX_PKT_TS_CMPL_ENABLE		UINT32_C(0x8)
+	/*
+	 * This value is a pointer to the page table for the
+	 * Ring.
+	 */
+	uint64_t	page_tbl_addr;
+	/* First Byte Offset of the first entry in the first page. */
+	uint32_t	fbo;
+	/*
+	 * Actual page size in 2^page_size. The supported range is increments
+	 * in powers of 2 from 16 bytes to 1GB.
+	 * - 4 = 16 B
+	 *	Page size is 16 B.
+	 * - 12 = 4 KB
+	 *	Page size is 4 KB.
+	 * - 13 = 8 KB
+	 *	Page size is 8 KB.
+	 * - 16 = 64 KB
+	 *	Page size is 64 KB.
+	 * - 21 = 2 MB
+	 *	Page size is 2 MB.
+	 * - 22 = 4 MB
+	 *	Page size is 4 MB.
+	 * - 30 = 1 GB
+	 *	Page size is 1 GB.
+	 */
+	uint8_t	page_size;
+	/*
+	 * This value indicates the depth of page table.
+	 * For this version of the specification, value other than 0 or
+	 * 1 shall be considered as an invalid value.
+	 * When the page_tbl_depth = 0, then it is treated as a
+	 * special case with the following.
+	 * 1. FBO and page size fields are not valid.
+	 * 2. page_tbl_addr is the physical address of the first
+	 *	element of the ring.
+	 */
+	uint8_t	page_tbl_depth;
+	/* Used by a PF driver to associate a SCHQ with one of its TX rings. */
+	uint16_t	schq_id;
+	/*
+	 * Number of 16B units in the ring. Minimum size for
+	 * a ring is 16 16B entries.
+	 */
+	uint32_t	length;
+	/*
+	 * Logical ring number for the ring to be allocated.
+	 * This value determines the position in the doorbell
+	 * area where the update to the ring will be made.
+	 *
+	 * For completion rings, this value is also the MSI-X
+	 * vector number for the function the completion ring is
+	 * associated with.
+	 */
+	uint16_t	logical_id;
+	/*
+	 * This field is used only when ring_type is a TX ring.
+	 * This value indicates what completion ring the TX ring
+	 * is associated with.
+	 */
+	uint16_t	cmpl_ring_id;
+	/*
+	 * This field is used only when ring_type is a TX ring.
+	 * This value indicates what CoS queue the TX ring
+	 * is associated with.
+	 */
+	uint16_t	queue_id;
+	/*
+	 * When allocating a Rx ring or Rx aggregation ring, this field
+	 * specifies the size of the buffer descriptors posted to the ring.
+	 */
+	uint16_t	rx_buf_size;
+	/*
+	 * When allocating an Rx aggregation ring, this field
+	 * specifies the associated Rx ring ID.
+	 */
+	uint16_t	rx_ring_id;
+	/*
+	 * When allocating a completion ring, this field
+	 * specifies the associated NQ ring ID.
+	 */
+	uint16_t	nq_ring_id;
+	/*
+	 * This field is used only when ring_type is a TX ring.
+	 * This field is used to configure arbitration related
+	 * parameters for a TX ring.
+	 */
+	uint16_t	ring_arb_cfg;
+	/* Arbitration policy used for the ring. */
+	#define HWRM_RING_ALLOC_INPUT_RING_ARB_CFG_ARB_POLICY_MASK	UINT32_C(0xf)
+	#define HWRM_RING_ALLOC_INPUT_RING_ARB_CFG_ARB_POLICY_SFT	0
+	/*
+	 * Use strict priority for the TX ring.
+	 * Priority value is specified in arb_policy_param
+	 */
+		#define HWRM_RING_ALLOC_INPUT_RING_ARB_CFG_ARB_POLICY_SP	UINT32_C(0x1)
+	/*
+	 * Use weighted fair queue arbitration for the TX ring.
+	 * Weight is specified in arb_policy_param
+	 */
+		#define HWRM_RING_ALLOC_INPUT_RING_ARB_CFG_ARB_POLICY_WFQ	UINT32_C(0x2)
+		#define HWRM_RING_ALLOC_INPUT_RING_ARB_CFG_ARB_POLICY_LAST	HWRM_RING_ALLOC_INPUT_RING_ARB_CFG_ARB_POLICY_WFQ
+	/* Reserved field. */
+	#define HWRM_RING_ALLOC_INPUT_RING_ARB_CFG_RSVD_MASK		UINT32_C(0xf0)
+	#define HWRM_RING_ALLOC_INPUT_RING_ARB_CFG_RSVD_SFT		4
+	/*
+	 * Arbitration policy specific parameter.
+	 * # For strict priority arbitration policy, this field
+	 * represents a priority value. If set to 0, then the priority
+	 * is not specified and the HWRM is allowed to select
+	 * any priority for this TX ring.
+	 * # For weighted fair queue arbitration policy, this field
+	 * represents a weight value. If set to 0, then the weight
+	 * is not specified and the HWRM is allowed to select
+	 * any weight for this TX ring.
+	 */
+	#define HWRM_RING_ALLOC_INPUT_RING_ARB_CFG_ARB_POLICY_PARAM_MASK UINT32_C(0xff00)
+	#define HWRM_RING_ALLOC_INPUT_RING_ARB_CFG_ARB_POLICY_PARAM_SFT 8
+	/* Steering tag to use for memory transactions. */
+	uint16_t	steering_tag;
+	/*
+	 * This field is reserved for the future use.
+	 * It shall be set to 0.
+	 */
+	uint32_t	reserved3;
+	/*
+	 * This field is used only when ring_type is a TX ring.
+	 * This input indicates what statistics context this ring
+	 * should be associated with.
+	 */
+	uint32_t	stat_ctx_id;
+	/*
+	 * This field is reserved for the future use.
+	 * It shall be set to 0.
+	 */
+	uint32_t	reserved4;
+	/*
+	 * This field is used only when ring_type is a TX ring
+	 * to specify maximum BW allocated to the TX ring.
+	 * The HWRM will translate this value into byte counter and
+	 * time interval used for this ring inside the device.
+	 */
+	uint32_t	max_bw;
+	/* The bandwidth value. */
+	#define HWRM_RING_ALLOC_INPUT_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_RING_ALLOC_INPUT_MAX_BW_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_RING_ALLOC_INPUT_MAX_BW_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_RING_ALLOC_INPUT_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_RING_ALLOC_INPUT_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_RING_ALLOC_INPUT_MAX_BW_SCALE_LAST		HWRM_RING_ALLOC_INPUT_MAX_BW_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_RING_ALLOC_INPUT_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_RING_ALLOC_INPUT_MAX_BW_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_RING_ALLOC_INPUT_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_RING_ALLOC_INPUT_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_RING_ALLOC_INPUT_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_RING_ALLOC_INPUT_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_RING_ALLOC_INPUT_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_RING_ALLOC_INPUT_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_RING_ALLOC_INPUT_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_RING_ALLOC_INPUT_MAX_BW_BW_VALUE_UNIT_INVALID
+	/*
+	 * This field is used only when ring_type is a Completion ring.
+	 * This value indicates what interrupt mode should be used
+	 * on this completion ring.
+	 * Note: In the legacy interrupt mode, no more than 16
+	 * completion rings are allowed.
+	 */
+	uint8_t	int_mode;
+	/* Legacy INTA (deprecated) */
+	#define HWRM_RING_ALLOC_INPUT_INT_MODE_LEGACY UINT32_C(0x0)
+	/* Reserved */
+	#define HWRM_RING_ALLOC_INPUT_INT_MODE_RSVD   UINT32_C(0x1)
+	/* MSI-X */
+	#define HWRM_RING_ALLOC_INPUT_INT_MODE_MSIX   UINT32_C(0x2)
+	/* No Interrupt - Polled mode */
+	#define HWRM_RING_ALLOC_INPUT_INT_MODE_POLL   UINT32_C(0x3)
+	#define HWRM_RING_ALLOC_INPUT_INT_MODE_LAST  HWRM_RING_ALLOC_INPUT_INT_MODE_POLL
+	/* Midpath channel type */
+	uint8_t	mpc_chnls_type;
+	/*
+	 * Indicate the TX ring alloc MPC channel type is a MPC channel
+	 * with destination to the TX crypto engine block.
+	 */
+	#define HWRM_RING_ALLOC_INPUT_MPC_CHNLS_TYPE_TCE	UINT32_C(0x0)
+	/*
+	 * Indicate the RX ring alloc MPC channel type is a MPC channel
+	 * with destination to the RX crypto engine block.
+	 */
+	#define HWRM_RING_ALLOC_INPUT_MPC_CHNLS_TYPE_RCE	UINT32_C(0x1)
+	/*
+	 * Indicate the RX ring alloc MPC channel type is a MPC channel
+	 * with destination to the TX configurable flow processing block.
+	 */
+	#define HWRM_RING_ALLOC_INPUT_MPC_CHNLS_TYPE_TE_CFA  UINT32_C(0x2)
+	/*
+	 * Indicate the RX ring alloc MPC channel type is a MPC channel
+	 * with destination to the RX configurable flow processing block.
+	 */
+	#define HWRM_RING_ALLOC_INPUT_MPC_CHNLS_TYPE_RE_CFA  UINT32_C(0x3)
+	/*
+	 * Indicate the RX ring alloc MPC channel type is a MPC channel
+	 * with destination to the primate processor block.
+	 */
+	#define HWRM_RING_ALLOC_INPUT_MPC_CHNLS_TYPE_PRIMATE UINT32_C(0x4)
+	#define HWRM_RING_ALLOC_INPUT_MPC_CHNLS_TYPE_LAST   HWRM_RING_ALLOC_INPUT_MPC_CHNLS_TYPE_PRIMATE
+	uint8_t	unused_4[2];
+	/*
+	 * The cq_handle is specified when allocating a completion ring. For
+	 * devices that support NQs, this cq_handle will be included in the
+	 * NQE to specify which CQ should be read to retrieve the completion
+	 * record.
+	 */
+	uint64_t	cq_handle;
+} hwrm_ring_alloc_input_t, *phwrm_ring_alloc_input_t;
+
+/* hwrm_ring_alloc_output (size:128b/16B) */
+
+typedef struct hwrm_ring_alloc_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/*
+	 * Physical number of ring allocated.
+	 * This value shall be unique for a ring type.
+	 */
+	uint16_t	ring_id;
+	/* Logical number of ring allocated. */
+	uint16_t	logical_ring_id;
+	/*
+	 * This field will tell whether to use ping or pong buffer
+	 * for first push operation.
+	 */
+	uint8_t	push_buffer_index;
+	/* Start push from ping buffer index */
+	#define HWRM_RING_ALLOC_OUTPUT_PUSH_BUFFER_INDEX_PING_BUFFER UINT32_C(0x0)
+	/* Start push from pong buffer index */
+	#define HWRM_RING_ALLOC_OUTPUT_PUSH_BUFFER_INDEX_PONG_BUFFER UINT32_C(0x1)
+	#define HWRM_RING_ALLOC_OUTPUT_PUSH_BUFFER_INDEX_LAST	HWRM_RING_ALLOC_OUTPUT_PUSH_BUFFER_INDEX_PONG_BUFFER
+	uint8_t	unused_0[2];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_ring_alloc_output_t, *phwrm_ring_alloc_output_t;
+
+/******************
+ * hwrm_ring_free *
+ ******************/
+
+
+/* hwrm_ring_free_input (size:256b/32B) */
+
+typedef struct hwrm_ring_free_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Ring Type. */
+	uint8_t	ring_type;
+	/* L2 Completion Ring (CR) */
+	#define HWRM_RING_FREE_INPUT_RING_TYPE_L2_CMPL   UINT32_C(0x0)
+	/* TX Ring (TR) */
+	#define HWRM_RING_FREE_INPUT_RING_TYPE_TX	UINT32_C(0x1)
+	/* RX Ring (RR) */
+	#define HWRM_RING_FREE_INPUT_RING_TYPE_RX	UINT32_C(0x2)
+	/* RoCE Notification Completion Ring (ROCE_CR) */
+	#define HWRM_RING_FREE_INPUT_RING_TYPE_ROCE_CMPL UINT32_C(0x3)
+	/* RX Aggregation Ring */
+	#define HWRM_RING_FREE_INPUT_RING_TYPE_RX_AGG	UINT32_C(0x4)
+	/* Notification Queue */
+	#define HWRM_RING_FREE_INPUT_RING_TYPE_NQ	UINT32_C(0x5)
+	#define HWRM_RING_FREE_INPUT_RING_TYPE_LAST	HWRM_RING_FREE_INPUT_RING_TYPE_NQ
+	uint8_t	flags;
+	/*
+	 * If this bit is set to '1', ring_id in this command belongs to
+	 * virtio function. prod_idx in this command corresponds to doorbell
+	 * producer index. opaque field in this command needs to be inserted
+	 * by firmware in VEE_FLUSH completion record.
+	 * Firmware will poll the corresponding ring context to reach the
+	 * given producer index before sending successful response. It will
+	 * finish the completion using VEE_FLUSH completion record.
+	 *
+	 * If this bit is '0', firmware will not treat ring_id as virtio
+	 * ring and ignore prod_idx, opaque fields.
+	 *
+	 * This feature is not applicable for L2 or RoCE.
+	 */
+	#define HWRM_RING_FREE_INPUT_FLAGS_VIRTIO_RING_VALID UINT32_C(0x1)
+	#define HWRM_RING_FREE_INPUT_FLAGS_LAST		HWRM_RING_FREE_INPUT_FLAGS_VIRTIO_RING_VALID
+	/* Physical number of ring allocated. */
+	uint16_t	ring_id;
+	/*
+	 * Ring BD producer index posted by the virtio block.
+	 * This field is valid if virtio_ring_valid flag is set.
+	 */
+	uint32_t	prod_idx;
+	/*
+	 * User defined opaque field to be inserted into VEE_FLUSH completion
+	 * record. This field is valid if virtio_ring_valid flag is set.
+	 */
+	uint32_t	opaque;
+	uint32_t	unused_1;
+} hwrm_ring_free_input_t, *phwrm_ring_free_input_t;
+
+/* hwrm_ring_free_output (size:128b/16B) */
+
+typedef struct hwrm_ring_free_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_ring_free_output_t, *phwrm_ring_free_output_t;
+
+/*******************
+ * hwrm_ring_reset *
+ *******************/
+
+
+/* hwrm_ring_reset_input (size:192b/24B) */
+
+typedef struct hwrm_ring_reset_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Ring Type. */
+	uint8_t	ring_type;
+	/* L2 Completion Ring (CR) */
+	#define HWRM_RING_RESET_INPUT_RING_TYPE_L2_CMPL	UINT32_C(0x0)
+	/* TX Ring (TR) */
+	#define HWRM_RING_RESET_INPUT_RING_TYPE_TX	UINT32_C(0x1)
+	/* RX Ring (RR) */
+	#define HWRM_RING_RESET_INPUT_RING_TYPE_RX	UINT32_C(0x2)
+	/* RoCE Notification Completion Ring (ROCE_CR) */
+	#define HWRM_RING_RESET_INPUT_RING_TYPE_ROCE_CMPL   UINT32_C(0x3)
+	/*
+	 * Rx Ring Group. This is to reset rx and aggregation in an atomic
+	 * operation. Completion ring associated with this ring group is
+	 * not reset.
+	 */
+	#define HWRM_RING_RESET_INPUT_RING_TYPE_RX_RING_GRP UINT32_C(0x6)
+	#define HWRM_RING_RESET_INPUT_RING_TYPE_LAST	HWRM_RING_RESET_INPUT_RING_TYPE_RX_RING_GRP
+	uint8_t	unused_0;
+	/*
+	 * Physical number of the ring. When ring type is rx_ring_grp, ring id
+	 * actually refers to ring group id.
+	 */
+	uint16_t	ring_id;
+	uint8_t	unused_1[4];
+} hwrm_ring_reset_input_t, *phwrm_ring_reset_input_t;
+
+/* hwrm_ring_reset_output (size:128b/16B) */
+
+typedef struct hwrm_ring_reset_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/*
+	 * This field will tell whether to use ping or pong buffer
+	 * for first push operation.
+	 */
+	uint8_t	push_buffer_index;
+	/* Start push from ping buffer index */
+	#define HWRM_RING_RESET_OUTPUT_PUSH_BUFFER_INDEX_PING_BUFFER UINT32_C(0x0)
+	/* Start push from pong buffer index */
+	#define HWRM_RING_RESET_OUTPUT_PUSH_BUFFER_INDEX_PONG_BUFFER UINT32_C(0x1)
+	#define HWRM_RING_RESET_OUTPUT_PUSH_BUFFER_INDEX_LAST	HWRM_RING_RESET_OUTPUT_PUSH_BUFFER_INDEX_PONG_BUFFER
+	uint8_t	unused_0[3];
+	/* Position of consumer index after ring reset completes. */
+	uint8_t	consumer_idx[3];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_ring_reset_output_t, *phwrm_ring_reset_output_t;
+
+/*****************
+ * hwrm_ring_cfg *
+ *****************/
+
+
+/* hwrm_ring_cfg_input (size:320b/40B) */
+
+typedef struct hwrm_ring_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Ring Type. */
+	uint8_t	ring_type;
+	/* TX Ring (TR) */
+	#define HWRM_RING_CFG_INPUT_RING_TYPE_TX UINT32_C(0x1)
+	/* RX Ring (RR) */
+	#define HWRM_RING_CFG_INPUT_RING_TYPE_RX UINT32_C(0x2)
+	#define HWRM_RING_CFG_INPUT_RING_TYPE_LAST HWRM_RING_CFG_INPUT_RING_TYPE_RX
+	uint8_t	unused_0;
+	/* Physical number of the ring. */
+	uint16_t	ring_id;
+	/* Ring config enable bits. */
+	uint16_t	enables;
+	/*
+	 * For Rx rings, the incoming packet data can be placed at either
+	 * a 0B, 2B, 10B or 12B offset from the start of the Rx packet
+	 * buffer.
+	 * When '1', the received packet will be padded with 2B, 10B or 12B
+	 * of zeros at the front of the packet. The exact offset is specified
+	 * by rx_sop_pad_bytes parameter.
+	 * When '0', the received packet will not be padded.
+	 * Note that this flag is only used for Rx rings and is ignored
+	 * for all other rings included Rx Aggregation rings.
+	 */
+	#define HWRM_RING_CFG_INPUT_ENABLES_RX_SOP_PAD_ENABLE		UINT32_C(0x1)
+	/*
+	 * Proxy mode enable, for Tx, Rx and Rx aggregation rings only.
+	 * When rings are allocated, the PCI function on which driver issues
+	 * HWRM_RING_CFG command is assumed to own the rings. Hardware takes
+	 * the buffer descriptors (BDs) from those rings is assumed to issue
+	 * packet payload DMA using same PCI function. When proxy mode is
+	 * enabled, hardware can perform payload DMA using another PCI
+	 * function on same or different host.
+	 * When set to '0', the PCI function on which driver issues
+	 * HWRM_RING_CFG command is used for host payload DMA operation.
+	 * When set to '1', the host PCI function specified by proxy_fid is
+	 * used for host payload DMA operation.
+	 */
+	#define HWRM_RING_CFG_INPUT_ENABLES_PROXY_MODE_ENABLE		UINT32_C(0x2)
+	/*
+	 * Tx ring packet source interface override, for Tx rings only.
+	 * When TX rings are allocated, the PCI function on which driver
+	 * issues HWRM_RING_CFG is assumed to be source interface of
+	 * packets sent from TX ring.
+	 * When set to '1', the host PCI function specified by proxy_fid
+	 * is used as source interface of the transmitted packets.
+	 */
+	#define HWRM_RING_CFG_INPUT_ENABLES_TX_PROXY_SRC_INTF_OVERRIDE	UINT32_C(0x4)
+	/* The schq_id field is valid */
+	#define HWRM_RING_CFG_INPUT_ENABLES_SCHQ_ID			UINT32_C(0x8)
+	/* Update completion ring ID associated with Tx or Rx ring. */
+	#define HWRM_RING_CFG_INPUT_ENABLES_CMPL_RING_ID_UPDATE		UINT32_C(0x10)
+	/*
+	 * When set to '1', metadata value provided by tx_metadata
+	 * field in this command is inserted in the lb_header_metadata
+	 * QP context field. When set to '0', no change done to metadata.
+	 * Firmware rejects the tx ring metadata programming with
+	 * HWRM_ERR_CODE_UNSUPPORTED error if the per function CFA BD
+	 * metadata feature is not disabled.
+	 */
+	#define HWRM_RING_CFG_INPUT_ENABLES_TX_METADATA			UINT32_C(0x20)
+	/*
+	 * Proxy function FID value.
+	 * This value is only used when either proxy_mode_enable flag or
+	 * tx_proxy_svif_override is set to '1'.
+	 * When proxy_mode_enable is set to '1', it identifies a host PCI
+	 * function used for host payload DMA operations.
+	 * When tx_proxy_src_intf is set to '1', it identifies a host PCI
+	 * function as source interface for all transmitted packets from
+	 * the TX ring.
+	 */
+	uint16_t	proxy_fid;
+	/*
+	 * Identifies the new scheduler queue (SCHQ) to associate with the
+	 * ring. Only valid for Tx rings.
+	 * A value of zero indicates that the Tx ring should be associated
+	 * with the default scheduler queue (SCHQ).
+	 */
+	uint16_t	schq_id;
+	/*
+	 * This field is valid for TX or Rx rings. This value identifies the
+	 * new completion ring ID to associate with the TX or Rx ring.
+	 */
+	uint16_t	cmpl_ring_id;
+	/*
+	 * Rx SOP padding amount in bytes.
+	 * This value is only used when rx_sop_pad_enable flag is set to '1'.
+	 */
+	uint8_t	rx_sop_pad_bytes;
+	uint8_t	unused_1[3];
+	/*
+	 * When tx_metadata enable bit is set, value specified in this field
+	 * is copied to lb_header_metadata in the QP context.
+	 */
+	uint32_t	tx_metadata;
+	uint8_t	unused_2[4];
+} hwrm_ring_cfg_input_t, *phwrm_ring_cfg_input_t;
+
+/* hwrm_ring_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_ring_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
+	 */
+	uint8_t	valid;
+} hwrm_ring_cfg_output_t, *phwrm_ring_cfg_output_t;
+
+/******************
+ * hwrm_ring_qcfg *
+ ******************/
+
+
+/* hwrm_ring_qcfg_input (size:192b/24B) */
+
+typedef struct hwrm_ring_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Ring Type. */
+	uint8_t	ring_type;
+	/* TX Ring (TR) */
+	#define HWRM_RING_QCFG_INPUT_RING_TYPE_TX UINT32_C(0x1)
+	/* RX Ring (RR) */
+	#define HWRM_RING_QCFG_INPUT_RING_TYPE_RX UINT32_C(0x2)
+	#define HWRM_RING_QCFG_INPUT_RING_TYPE_LAST HWRM_RING_QCFG_INPUT_RING_TYPE_RX
+	uint8_t	unused_0[5];
+	/* Physical number of the ring. */
+	uint16_t	ring_id;
+} hwrm_ring_qcfg_input_t, *phwrm_ring_qcfg_input_t;
+
+/* hwrm_ring_qcfg_output (size:256b/32B) */
+
+typedef struct hwrm_ring_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Ring config enable bits. */
+	uint16_t	enables;
+	/*
+	 * For Rx rings, the incoming packet data can be placed at either
+	 * a 0B, 2B, 10B or 12B offset from the start of the Rx packet
+	 * buffer.
+	 * When '1', the received packet will be padded with 2B, 10B or 12B
+	 * of zeros at the front of the packet. The exact offset is specified
+	 * by rx_sop_pad_bytes parameter.
+	 * When '0', the received packet will not be padded.
+	 * Note that this flag is only used for Rx rings and is ignored
+	 * for all other rings included Rx Aggregation rings.
+	 */
+	#define HWRM_RING_QCFG_OUTPUT_ENABLES_RX_SOP_PAD_ENABLE		UINT32_C(0x1)
+	/*
+	 * Proxy mode enable, for Tx, Rx and Rx aggregation rings only.
+	 * When rings are allocated, the PCI function on which driver issues
+	 * HWRM_RING_CFG command is assumed to own the rings. Hardware takes
+	 * the buffer descriptors (BDs) from those rings is assumed to issue
+	 * packet payload DMA using same PCI function. When proxy mode is
+	 * enabled, hardware can perform payload DMA using another PCI
+	 * function on same or different host.
+	 * When set to '0', the PCI function on which driver issues
+	 * HWRM_RING_CFG command is used for host payload DMA operation.
+	 * When set to '1', the host PCI function specified by proxy_fid is
+	 * used for host payload DMA operation.
+	 */
+	#define HWRM_RING_QCFG_OUTPUT_ENABLES_PROXY_MODE_ENABLE		UINT32_C(0x2)
+	/*
+	 * Tx ring packet source interface override, for Tx rings only.
+	 * When TX rings are allocated, the PCI function on which driver
+	 * issues HWRM_RING_CFG is assumed to be source interface of
+	 * packets sent from TX ring.
+	 * When set to '1', the host PCI function specified by proxy_fid is
+	 * used as source interface of the transmitted packets.
+	 */
+	#define HWRM_RING_QCFG_OUTPUT_ENABLES_TX_PROXY_SRC_INTF_OVERRIDE	UINT32_C(0x4)
+	/*
+	 * Proxy function FID value.
+	 * This value is only used when either proxy_mode_enable flag or
+	 * tx_proxy_svif_override is set to '1'.
+	 * When proxy_mode_enable is set to '1', it identifies a host PCI
+	 * function used for host payload DMA operations.
+	 * When tx_proxy_src_intf is set to '1', it identifies a host PCI
+	 * function as source interface for all transmitted packets from the TX
+	 * ring.
+	 */
+	uint16_t	proxy_fid;
+	/*
+	 * Identifies the new scheduler queue (SCHQ) to associate with the
+	 * ring. Only valid for Tx rings.
+	 * A value of zero indicates that the Tx ring should be associated with
+	 * the default scheduler queue (SCHQ).
+	 */
+	uint16_t	schq_id;
+	/*
+	 * This field is used when ring_type is a TX or Rx ring.
+	 * This value indicates what completion ring the TX or Rx ring
+	 * is associated with.
+	 */
+	uint16_t	cmpl_ring_id;
+	/*
+	 * Rx SOP padding amount in bytes.
+	 * This value is only used when rx_sop_pad_enable flag is set to '1'.
+	 */
+	uint8_t	rx_sop_pad_bytes;
+	uint8_t	unused_0[3];
+	/* lb_header_metadata in the QP context is copied to this field. */
+	uint32_t	tx_metadata;
+	uint8_t	unused_1[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
+	 */
+	uint8_t	valid;
+} hwrm_ring_qcfg_output_t, *phwrm_ring_qcfg_output_t;
+
+/**************************
+ * hwrm_ring_aggint_qcaps *
+ **************************/
+
+
+/* hwrm_ring_aggint_qcaps_input (size:128b/16B) */
+
+typedef struct hwrm_ring_aggint_qcaps_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+} hwrm_ring_aggint_qcaps_input_t, *phwrm_ring_aggint_qcaps_input_t;
+
+/* hwrm_ring_aggint_qcaps_output (size:384b/48B) */
+
+typedef struct hwrm_ring_aggint_qcaps_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint32_t	cmpl_params;
+	/*
+	 * When this bit is set to '1', int_lat_tmr_min can be configured
+	 * on completion rings.
+	 */
+	#define HWRM_RING_AGGINT_QCAPS_OUTPUT_CMPL_PARAMS_INT_LAT_TMR_MIN		UINT32_C(0x1)
+	/*
+	 * When this bit is set to '1', int_lat_tmr_max can be configured
+	 * on completion rings.
+	 */
+	#define HWRM_RING_AGGINT_QCAPS_OUTPUT_CMPL_PARAMS_INT_LAT_TMR_MAX		UINT32_C(0x2)
+	/*
+	 * When this bit is set to '1', timer_reset can be enabled
+	 * on completion rings.
+	 */
+	#define HWRM_RING_AGGINT_QCAPS_OUTPUT_CMPL_PARAMS_TIMER_RESET			UINT32_C(0x4)
+	/*
+	 * When this bit is set to '1', ring_idle can be enabled
+	 * on completion rings.
+	 */
+	#define HWRM_RING_AGGINT_QCAPS_OUTPUT_CMPL_PARAMS_RING_IDLE			UINT32_C(0x8)
+	/*
+	 * When this bit is set to '1', num_cmpl_dma_aggr can be configured
+	 * on completion rings.
+	 */
+	#define HWRM_RING_AGGINT_QCAPS_OUTPUT_CMPL_PARAMS_NUM_CMPL_DMA_AGGR		UINT32_C(0x10)
+	/*
+	 * When this bit is set to '1', num_cmpl_dma_aggr_during_int can be
+	 * configured on completion rings.
+	 */
+	#define HWRM_RING_AGGINT_QCAPS_OUTPUT_CMPL_PARAMS_NUM_CMPL_DMA_AGGR_DURING_INT	UINT32_C(0x20)
+	/*
+	 * When this bit is set to '1', cmpl_aggr_dma_tmr can be configured
+	 * on completion rings.
+	 */
+	#define HWRM_RING_AGGINT_QCAPS_OUTPUT_CMPL_PARAMS_CMPL_AGGR_DMA_TMR		UINT32_C(0x40)
+	/*
+	 * When this bit is set to '1', cmpl_aggr_dma_tmr_during_int can be
+	 * configured on completion rings.
+	 */
+	#define HWRM_RING_AGGINT_QCAPS_OUTPUT_CMPL_PARAMS_CMPL_AGGR_DMA_TMR_DURING_INT	UINT32_C(0x80)
+	/*
+	 * When this bit is set to '1', num_cmpl_aggr_int can be configured
+	 * on completion rings.
+	 */
+	#define HWRM_RING_AGGINT_QCAPS_OUTPUT_CMPL_PARAMS_NUM_CMPL_AGGR_INT		UINT32_C(0x100)
+	uint32_t	nq_params;
+	/*
+	 * When this bit is set to '1', int_lat_tmr_min can be configured
+	 * on notification queues.
+	 */
+	#define HWRM_RING_AGGINT_QCAPS_OUTPUT_NQ_PARAMS_INT_LAT_TMR_MIN	UINT32_C(0x1)
+	/* Minimum value for num_cmpl_dma_aggr */
+	uint16_t	num_cmpl_dma_aggr_min;
+	/* Maximum value for num_cmpl_dma_aggr */
+	uint16_t	num_cmpl_dma_aggr_max;
+	/* Minimum value for num_cmpl_dma_aggr_during_int */
+	uint16_t	num_cmpl_dma_aggr_during_int_min;
+	/* Maximum value for num_cmpl_dma_aggr_during_int */
+	uint16_t	num_cmpl_dma_aggr_during_int_max;
+	/* Minimum value for cmpl_aggr_dma_tmr */
+	uint16_t	cmpl_aggr_dma_tmr_min;
+	/* Maximum value for cmpl_aggr_dma_tmr */
+	uint16_t	cmpl_aggr_dma_tmr_max;
+	/* Minimum value for cmpl_aggr_dma_tmr_during_int */
+	uint16_t	cmpl_aggr_dma_tmr_during_int_min;
+	/* Maximum value for cmpl_aggr_dma_tmr_during_int */
+	uint16_t	cmpl_aggr_dma_tmr_during_int_max;
+	/* Minimum value for int_lat_tmr_min */
+	uint16_t	int_lat_tmr_min_min;
+	/* Maximum value for int_lat_tmr_min */
+	uint16_t	int_lat_tmr_min_max;
+	/* Minimum value for int_lat_tmr_max */
+	uint16_t	int_lat_tmr_max_min;
+	/* Maximum value for int_lat_tmr_max */
+	uint16_t	int_lat_tmr_max_max;
+	/* Minimum value for num_cmpl_aggr_int */
+	uint16_t	num_cmpl_aggr_int_min;
+	/* Maximum value for num_cmpl_aggr_int */
+	uint16_t	num_cmpl_aggr_int_max;
+	/* The units for timer parameters, in nanoseconds. */
+	uint16_t	timer_units;
+	uint8_t	unused_0[1];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_ring_aggint_qcaps_output_t, *phwrm_ring_aggint_qcaps_output_t;
+
+/**************************************
+ * hwrm_ring_cmpl_ring_qaggint_params *
+ **************************************/
+
+
+/* hwrm_ring_cmpl_ring_qaggint_params_input (size:192b/24B) */
+
+typedef struct hwrm_ring_cmpl_ring_qaggint_params_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Physical number of completion ring. */
+	uint16_t	ring_id;
+	uint16_t	flags;
+	#define HWRM_RING_CMPL_RING_QAGGINT_PARAMS_INPUT_FLAGS_UNUSED_0_MASK UINT32_C(0x3)
+	#define HWRM_RING_CMPL_RING_QAGGINT_PARAMS_INPUT_FLAGS_UNUSED_0_SFT 0
+	/*
+	 * Set this flag to 1 when querying parameters on a notification
+	 * queue. Set this flag to 0 when querying parameters on a
+	 * completion queue or completion ring.
+	 */
+	#define HWRM_RING_CMPL_RING_QAGGINT_PARAMS_INPUT_FLAGS_IS_NQ	UINT32_C(0x4)
+	uint8_t	unused_0[4];
+} hwrm_ring_cmpl_ring_qaggint_params_input_t, *phwrm_ring_cmpl_ring_qaggint_params_input_t;
+
+/* hwrm_ring_cmpl_ring_qaggint_params_output (size:256b/32B) */
+
+typedef struct hwrm_ring_cmpl_ring_qaggint_params_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint16_t	flags;
+	/*
+	 * When this bit is set to '1', interrupt max
+	 * timer is reset whenever a completion is received.
+	 */
+	#define HWRM_RING_CMPL_RING_QAGGINT_PARAMS_OUTPUT_FLAGS_TIMER_RESET	UINT32_C(0x1)
+	/*
+	 * When this bit is set to '1', ring idle mode
+	 * aggregation will be enabled.
+	 */
+	#define HWRM_RING_CMPL_RING_QAGGINT_PARAMS_OUTPUT_FLAGS_RING_IDLE	UINT32_C(0x2)
+	/*
+	 * Number of completions to aggregate before DMA
+	 * during the normal mode.
+	 */
+	uint16_t	num_cmpl_dma_aggr;
+	/*
+	 * Number of completions to aggregate before DMA
+	 * during the interrupt mode.
+	 */
+	uint16_t	num_cmpl_dma_aggr_during_int;
+	/*
+	 * Timer used to aggregate completions before
+	 * DMA during the normal mode (not in interrupt mode).
+	 */
+	uint16_t	cmpl_aggr_dma_tmr;
+	/*
+	 * Timer used to aggregate completions before
+	 * DMA when in interrupt mode.
+	 */
+	uint16_t	cmpl_aggr_dma_tmr_during_int;
+	/* Minimum time between two interrupts. */
+	uint16_t	int_lat_tmr_min;
+	/*
+	 * Maximum wait time spent aggregating
+	 * completions before signaling the interrupt after the
+	 * interrupt is enabled.
+	 */
+	uint16_t	int_lat_tmr_max;
+	/*
+	 * Minimum number of completions aggregated before signaling
+	 * an interrupt.
+	 */
+	uint16_t	num_cmpl_aggr_int;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_ring_cmpl_ring_qaggint_params_output_t, *phwrm_ring_cmpl_ring_qaggint_params_output_t;
+
+/*****************************************
+ * hwrm_ring_cmpl_ring_cfg_aggint_params *
+ *****************************************/
+
+
+/* hwrm_ring_cmpl_ring_cfg_aggint_params_input (size:320b/40B) */
+
+typedef struct hwrm_ring_cmpl_ring_cfg_aggint_params_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Physical number of completion ring. */
+	uint16_t	ring_id;
+	uint16_t	flags;
+	/*
+	 * When this bit is set to '1', interrupt latency max
+	 * timer is reset whenever a completion is received.
+	 */
+	#define HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_FLAGS_TIMER_RESET	UINT32_C(0x1)
+	/*
+	 * When this bit is set to '1', ring idle mode
+	 * aggregation will be enabled.
+	 */
+	#define HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_FLAGS_RING_IDLE	UINT32_C(0x2)
+	/*
+	 * Set this flag to 1 when configuring parameters on a
+	 * notification queue. Set this flag to 0 when configuring
+	 * parameters on a completion queue or completion ring.
+	 */
+	#define HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_FLAGS_IS_NQ	UINT32_C(0x4)
+	/*
+	 * Number of completions to aggregate before DMA
+	 * during the normal mode.
+	 */
+	uint16_t	num_cmpl_dma_aggr;
+	/*
+	 * Number of completions to aggregate before DMA
+	 * during the interrupt mode.
+	 */
+	uint16_t	num_cmpl_dma_aggr_during_int;
+	/*
+	 * Timer used to aggregate completions before
+	 * DMA during the normal mode (not in interrupt mode).
+	 */
+	uint16_t	cmpl_aggr_dma_tmr;
+	/*
+	 * Timer used to aggregate completions before
+	 * DMA while in interrupt mode.
+	 */
+	uint16_t	cmpl_aggr_dma_tmr_during_int;
+	/* Minimum time between two interrupts. */
+	uint16_t	int_lat_tmr_min;
+	/*
+	 * Maximum wait time spent aggregating
+	 * completions before signaling the interrupt after the
+	 * interrupt is enabled.
+	 */
+	uint16_t	int_lat_tmr_max;
+	/*
+	 * Minimum number of completions aggregated before signaling
+	 * an interrupt.
+	 */
+	uint16_t	num_cmpl_aggr_int;
+	/*
+	 * Bitfield that indicates which parameters are to be applied. Only
+	 * required when configuring devices with notification queues, and
+	 * used in that case to set certain parameters on completion queues
+	 * and others on notification queues.
+	 */
+	uint16_t	enables;
+	/*
+	 * This bit must be '1' for the num_cmpl_dma_aggr field to be
+	 * configured.
+	 */
+	#define HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_ENABLES_NUM_CMPL_DMA_AGGR		UINT32_C(0x1)
+	/*
+	 * This bit must be '1' for the num_cmpl_dma_aggr_during_int field to
+	 * be configured.
+	 */
+	#define HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_ENABLES_NUM_CMPL_DMA_AGGR_DURING_INT	UINT32_C(0x2)
+	/*
+	 * This bit must be '1' for the cmpl_aggr_dma_tmr field to be
+	 * configured.
+	 */
+	#define HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_ENABLES_CMPL_AGGR_DMA_TMR		UINT32_C(0x4)
+	/*
+	 * This bit must be '1' for the int_lat_tmr_min field to be
+	 * configured.
+	 */
+	#define HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_ENABLES_INT_LAT_TMR_MIN		UINT32_C(0x8)
+	/*
+	 * This bit must be '1' for the int_lat_tmr_max field to be
+	 * configured.
+	 */
+	#define HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_ENABLES_INT_LAT_TMR_MAX		UINT32_C(0x10)
+	/*
+	 * This bit must be '1' for the num_cmpl_aggr_int field to be
+	 * configured.
+	 */
+	#define HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_ENABLES_NUM_CMPL_AGGR_INT		UINT32_C(0x20)
+	uint8_t	unused_0[4];
+} hwrm_ring_cmpl_ring_cfg_aggint_params_input_t, *phwrm_ring_cmpl_ring_cfg_aggint_params_input_t;
+
+/* hwrm_ring_cmpl_ring_cfg_aggint_params_output (size:128b/16B) */
+
+typedef struct hwrm_ring_cmpl_ring_cfg_aggint_params_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_ring_cmpl_ring_cfg_aggint_params_output_t, *phwrm_ring_cmpl_ring_cfg_aggint_params_output_t;
+
+/***********************
+ * hwrm_ring_grp_alloc *
+ ***********************/
+
+
+/* hwrm_ring_grp_alloc_input (size:192b/24B) */
+
+typedef struct hwrm_ring_grp_alloc_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/*
+	 * This value identifies the CR associated with the ring
+	 * group.
+	 */
+	uint16_t	cr;
+	/*
+	 * This value identifies the main RR associated with the ring
+	 * group.
+	 */
+	uint16_t	rr;
+	/*
+	 * This value identifies the aggregation RR associated with
+	 * the ring group. If this value is 0xFF... (All Fs), then no
+	 * Aggregation ring will be set.
+	 */
+	uint16_t	ar;
+	/*
+	 * This value identifies the statistics context associated
+	 * with the ring group.
+	 */
+	uint16_t	sc;
+} hwrm_ring_grp_alloc_input_t, *phwrm_ring_grp_alloc_input_t;
+
+/* hwrm_ring_grp_alloc_output (size:128b/16B) */
+
+typedef struct hwrm_ring_grp_alloc_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/*
+	 * This is the ring group ID value. Use this value to program
+	 * the default ring group for the VNIC or as table entries
+	 * in an RSS/COS context.
+	 */
+	uint32_t	ring_group_id;
+	uint8_t	unused_0[3];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_ring_grp_alloc_output_t, *phwrm_ring_grp_alloc_output_t;
+
+/**********************
+ * hwrm_ring_grp_free *
+ **********************/
+
+
+/* hwrm_ring_grp_free_input (size:192b/24B) */
+
+typedef struct hwrm_ring_grp_free_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* This is the ring group ID value. */
+	uint32_t	ring_group_id;
+	uint8_t	unused_0[4];
+} hwrm_ring_grp_free_input_t, *phwrm_ring_grp_free_input_t;
+
+/* hwrm_ring_grp_free_output (size:128b/16B) */
+
+typedef struct hwrm_ring_grp_free_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_ring_grp_free_output_t, *phwrm_ring_grp_free_output_t;
+
+/************************
+ * hwrm_ring_schq_alloc *
+ ************************/
+
+
+/* hwrm_ring_schq_alloc_input (size:1088b/136B) */
+
+typedef struct hwrm_ring_schq_alloc_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	enables;
+	/*
+	 * This bit must be '1' for the tqm_ring0 fields to be
+	 * configured.
+	 */
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_ENABLES_TQM_RING0	UINT32_C(0x1)
+	/*
+	 * This bit must be '1' for the tqm_ring1 fields to be
+	 * configured.
+	 */
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_ENABLES_TQM_RING1	UINT32_C(0x2)
+	/*
+	 * This bit must be '1' for the tqm_ring2 fields to be
+	 * configured.
+	 */
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_ENABLES_TQM_RING2	UINT32_C(0x4)
+	/*
+	 * This bit must be '1' for the tqm_ring3 fields to be
+	 * configured.
+	 */
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_ENABLES_TQM_RING3	UINT32_C(0x8)
+	/*
+	 * This bit must be '1' for the tqm_ring4 fields to be
+	 * configured.
+	 */
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_ENABLES_TQM_RING4	UINT32_C(0x10)
+	/*
+	 * This bit must be '1' for the tqm_ring5 fields to be
+	 * configured.
+	 */
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_ENABLES_TQM_RING5	UINT32_C(0x20)
+	/*
+	 * This bit must be '1' for the tqm_ring6 fields to be
+	 * configured.
+	 */
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_ENABLES_TQM_RING6	UINT32_C(0x40)
+	/*
+	 * This bit must be '1' for the tqm_ring7 fields to be
+	 * configured.
+	 */
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_ENABLES_TQM_RING7	UINT32_C(0x80)
+	/* Reserved for future use. */
+	uint32_t	reserved;
 	/* TQM ring 0 page size and level. */
 	uint8_t	tqm_ring0_pg_size_tqm_ring0_lvl;
 	/* TQM ring 0 PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING0_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING0_LVL_SFT	0
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING0_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING0_LVL_SFT	0
 	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING0_LVL_LVL_0	UINT32_C(0x0)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING0_LVL_LVL_0	UINT32_C(0x0)
 	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING0_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING0_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING0_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING0_LVL_LVL_2
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING0_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING0_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING0_LVL_LAST	HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING0_LVL_LVL_2
 	/* TQM ring 0 page size. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING0_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING0_PG_SIZE_SFT   4
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING0_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING0_PG_SIZE_SFT   4
 	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING0_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING0_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
 	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING0_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING0_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
 	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING0_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING0_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
 	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING0_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING0_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
 	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING0_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING0_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
 	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING0_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING0_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING0_PG_SIZE_PG_1G
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING0_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING0_PG_SIZE_LAST   HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING0_PG_SIZE_PG_1G
 	/* TQM ring 1 page size and level. */
 	uint8_t	tqm_ring1_pg_size_tqm_ring1_lvl;
 	/* TQM ring 1 PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING1_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING1_LVL_SFT	0
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING1_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING1_LVL_SFT	0
 	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING1_LVL_LVL_0	UINT32_C(0x0)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING1_LVL_LVL_0	UINT32_C(0x0)
 	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING1_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING1_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING1_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING1_LVL_LVL_2
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING1_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING1_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING1_LVL_LAST	HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING1_LVL_LVL_2
 	/* TQM ring 1 page size. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING1_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING1_PG_SIZE_SFT   4
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING1_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING1_PG_SIZE_SFT   4
 	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING1_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING1_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
 	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING1_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING1_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
 	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING1_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING1_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
 	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING1_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING1_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
 	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING1_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING1_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
 	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING1_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING1_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING1_PG_SIZE_PG_1G
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING1_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING1_PG_SIZE_LAST   HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING1_PG_SIZE_PG_1G
 	/* TQM ring 2 page size and level. */
 	uint8_t	tqm_ring2_pg_size_tqm_ring2_lvl;
 	/* TQM ring 2 PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING2_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING2_LVL_SFT	0
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING2_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING2_LVL_SFT	0
 	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING2_LVL_LVL_0	UINT32_C(0x0)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING2_LVL_LVL_0	UINT32_C(0x0)
 	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING2_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING2_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING2_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING2_LVL_LVL_2
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING2_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING2_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING2_LVL_LAST	HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING2_LVL_LVL_2
 	/* TQM ring 2 page size. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING2_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING2_PG_SIZE_SFT   4
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING2_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING2_PG_SIZE_SFT   4
 	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING2_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING2_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
 	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING2_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING2_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
 	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING2_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING2_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
 	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING2_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING2_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
 	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING2_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING2_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
 	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING2_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING2_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING2_PG_SIZE_PG_1G
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING2_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING2_PG_SIZE_LAST   HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING2_PG_SIZE_PG_1G
 	/* TQM ring 3 page size and level. */
 	uint8_t	tqm_ring3_pg_size_tqm_ring3_lvl;
 	/* TQM ring 3 PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING3_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING3_LVL_SFT	0
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING3_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING3_LVL_SFT	0
 	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING3_LVL_LVL_0	UINT32_C(0x0)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING3_LVL_LVL_0	UINT32_C(0x0)
 	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING3_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING3_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING3_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING3_LVL_LVL_2
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING3_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING3_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING3_LVL_LAST	HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING3_LVL_LVL_2
 	/* TQM ring 3 page size. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING3_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING3_PG_SIZE_SFT   4
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING3_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING3_PG_SIZE_SFT   4
 	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING3_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING3_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
 	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING3_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING3_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
 	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING3_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING3_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
 	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING3_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING3_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
 	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING3_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING3_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
 	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING3_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING3_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING3_PG_SIZE_PG_1G
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING3_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING3_PG_SIZE_LAST   HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING3_PG_SIZE_PG_1G
 	/* TQM ring 4 page size and level. */
 	uint8_t	tqm_ring4_pg_size_tqm_ring4_lvl;
 	/* TQM ring 4 PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING4_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING4_LVL_SFT	0
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING4_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING4_LVL_SFT	0
 	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING4_LVL_LVL_0	UINT32_C(0x0)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING4_LVL_LVL_0	UINT32_C(0x0)
 	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING4_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING4_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING4_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING4_LVL_LVL_2
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING4_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING4_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING4_LVL_LAST	HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING4_LVL_LVL_2
 	/* TQM ring 4 page size. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING4_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING4_PG_SIZE_SFT   4
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING4_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING4_PG_SIZE_SFT   4
 	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING4_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING4_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
 	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING4_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING4_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
 	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING4_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING4_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
 	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING4_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING4_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
 	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING4_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING4_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
 	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING4_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING4_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING4_PG_SIZE_PG_1G
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING4_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING4_PG_SIZE_LAST   HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING4_PG_SIZE_PG_1G
 	/* TQM ring 5 page size and level. */
 	uint8_t	tqm_ring5_pg_size_tqm_ring5_lvl;
 	/* TQM ring 5 PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING5_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING5_LVL_SFT	0
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING5_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING5_LVL_SFT	0
 	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING5_LVL_LVL_0	UINT32_C(0x0)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING5_LVL_LVL_0	UINT32_C(0x0)
 	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING5_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING5_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING5_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING5_LVL_LVL_2
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING5_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING5_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING5_LVL_LAST	HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING5_LVL_LVL_2
 	/* TQM ring 5 page size. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING5_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING5_PG_SIZE_SFT   4
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING5_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING5_PG_SIZE_SFT   4
 	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING5_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING5_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
 	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING5_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING5_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
 	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING5_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING5_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
 	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING5_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING5_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
 	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING5_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING5_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
 	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING5_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING5_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING5_PG_SIZE_PG_1G
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING5_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING5_PG_SIZE_LAST   HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING5_PG_SIZE_PG_1G
 	/* TQM ring 6 page size and level. */
 	uint8_t	tqm_ring6_pg_size_tqm_ring6_lvl;
 	/* TQM ring 6 PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING6_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING6_LVL_SFT	0
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING6_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING6_LVL_SFT	0
 	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING6_LVL_LVL_0	UINT32_C(0x0)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING6_LVL_LVL_0	UINT32_C(0x0)
 	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING6_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING6_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING6_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING6_LVL_LVL_2
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING6_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING6_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING6_LVL_LAST	HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING6_LVL_LVL_2
 	/* TQM ring 6 page size. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING6_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING6_PG_SIZE_SFT   4
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING6_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING6_PG_SIZE_SFT   4
 	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING6_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING6_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
 	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING6_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING6_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
 	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING6_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING6_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
 	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING6_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING6_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
 	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING6_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING6_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
 	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING6_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING6_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING6_PG_SIZE_PG_1G
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING6_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING6_PG_SIZE_LAST   HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING6_PG_SIZE_PG_1G
 	/* TQM ring 7 page size and level. */
 	uint8_t	tqm_ring7_pg_size_tqm_ring7_lvl;
 	/* TQM ring 7 PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING7_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING7_LVL_SFT	0
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING7_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING7_LVL_SFT	0
 	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING7_LVL_LVL_0	UINT32_C(0x0)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING7_LVL_LVL_0	UINT32_C(0x0)
 	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING7_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING7_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING7_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING7_LVL_LVL_2
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING7_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING7_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING7_LVL_LAST	HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING7_LVL_LVL_2
 	/* TQM ring 7 page size. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING7_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING7_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING7_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING7_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING7_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING7_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING7_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING7_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING7_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TQM_RING7_PG_SIZE_PG_1G
-	/* MR/AV page size and level. */
-	uint8_t	mrav_pg_size_mrav_lvl;
-	/* MR/AV PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_MRAV_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_MRAV_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_MRAV_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_MRAV_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_MRAV_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_MRAV_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_MRAV_LVL_LVL_2
-	/* MR/AV page size. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_MRAV_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_MRAV_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_MRAV_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_MRAV_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_MRAV_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_MRAV_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_MRAV_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_MRAV_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_MRAV_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_MRAV_PG_SIZE_PG_1G
-	/* Timer page size and level. */
-	uint8_t	tim_pg_size_tim_lvl;
-	/* Timer PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TIM_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TIM_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TIM_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TIM_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TIM_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TIM_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TIM_LVL_LVL_2
-	/* Timer page size. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TIM_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TIM_PG_SIZE_SFT   4
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING7_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING7_PG_SIZE_SFT   4
 	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TIM_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING7_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
 	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TIM_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING7_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
 	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TIM_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING7_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
 	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TIM_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING7_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
 	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TIM_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING7_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
 	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TIM_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TIM_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TIM_PG_SIZE_PG_1G
-	/* QP page directory. */
-	uint64_t	qpc_page_dir;
-	/* SRQ page directory. */
-	uint64_t	srq_page_dir;
-	/* CQ page directory. */
-	uint64_t	cq_page_dir;
-	/* VNIC page directory. */
-	uint64_t	vnic_page_dir;
-	/* Stat page directory. */
-	uint64_t	stat_page_dir;
-	/* TQM slowpath page directory. */
-	uint64_t	tqm_sp_page_dir;
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING7_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING7_PG_SIZE_LAST   HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING7_PG_SIZE_PG_1G
 	/* TQM ring 0 page directory. */
 	uint64_t	tqm_ring0_page_dir;
 	/* TQM ring 1 page directory. */
@@ -16262,263 +43709,810 @@ typedef struct hwrm_func_backing_store_qcfg_output {
 	uint64_t	tqm_ring6_page_dir;
 	/* TQM ring 7 page directory. */
 	uint64_t	tqm_ring7_page_dir;
-	/* MR/AV page directory. */
-	uint64_t	mrav_page_dir;
-	/* Timer page directory. */
-	uint64_t	tim_page_dir;
-	/* Number of entries to reserve for QP1 */
-	uint16_t	qp_num_qp1_entries;
-	/* Number of entries to reserve for L2 */
-	uint16_t	qp_num_l2_entries;
-	/* Number of QPs. */
-	uint32_t	qp_num_entries;
-	/* Number of SRQs. */
-	uint32_t	srq_num_entries;
-	/* Number of entries to reserve for L2 */
-	uint16_t	srq_num_l2_entries;
-	/* Number of entries to reserve for L2 */
-	uint16_t	cq_num_l2_entries;
-	/* Number of CQs. */
-	uint32_t	cq_num_entries;
-	/* Number of entries to reserve for VNIC entries */
-	uint16_t	vnic_num_vnic_entries;
-	/* Number of entries to reserve for Ring table entries */
-	uint16_t	vnic_num_ring_table_entries;
-	/* Number of Stats. */
-	uint32_t	stat_num_entries;
-	/* Number of TQM slowpath entries. */
-	uint32_t	tqm_sp_num_entries;
-	/* Number of TQM ring 0 entries. */
+	/*
+	 * Number of TQM ring 0 entries.
+	 *
+	 * TQM fastpath rings should be sized large enough to accommodate the
+	 * maximum number of QPs (either L2 or RoCE, or both if shared)
+	 * that can be enqueued to the TQM ring.
+	 *
+	 * Note that TQM ring sizes cannot be extended while the system is
+	 * operational. If a PF driver needs to extend a TQM ring, it needs
+	 * to delete the SCHQ and then reallocate it.
+	 */
 	uint32_t	tqm_ring0_num_entries;
-	/* Number of TQM ring 1 entries. */
+	/*
+	 * Number of TQM ring 1 entries.
+	 *
+	 * TQM fastpath rings should be sized large enough to accommodate the
+	 * maximum number of QPs (either L2 or RoCE, or both if shared)
+	 * that can be enqueued to the TQM ring.
+	 *
+	 * Note that TQM ring sizes cannot be extended while the system is
+	 * operational. If a PF driver needs to extend a TQM ring, it needs
+	 * to delete the SCHQ and then reallocate it.
+	 */
 	uint32_t	tqm_ring1_num_entries;
-	/* Number of TQM ring 2 entries. */
+	/*
+	 * Number of TQM ring 2 entries.
+	 *
+	 * TQM fastpath rings should be sized large enough to accommodate the
+	 * maximum number of QPs (either L2 or RoCE, or both if shared)
+	 * that can be enqueued to the TQM ring.
+	 *
+	 * Note that TQM ring sizes cannot be extended while the system is
+	 * operational. If a PF driver needs to extend a TQM ring, it needs
+	 * to delete the SCHQ and then reallocate it.
+	 */
 	uint32_t	tqm_ring2_num_entries;
-	/* Number of TQM ring 3 entries. */
+	/*
+	 * Number of TQM ring 3 entries.
+	 *
+	 * TQM fastpath rings should be sized large enough to accommodate the
+	 * maximum number of QPs (either L2 or RoCE, or both if shared)
+	 * that can be enqueued to the TQM ring.
+	 *
+	 * Note that TQM ring sizes cannot be extended while the system is
+	 * operational. If a PF driver needs to extend a TQM ring, it needs
+	 * to delete the SCHQ and then reallocate it.
+	 */
 	uint32_t	tqm_ring3_num_entries;
-	/* Number of TQM ring 4 entries. */
+	/*
+	 * Number of TQM ring 4 entries.
+	 *
+	 * TQM fastpath rings should be sized large enough to accommodate the
+	 * maximum number of QPs (either L2 or RoCE, or both if shared)
+	 * that can be enqueued to the TQM ring.
+	 *
+	 * Note that TQM ring sizes cannot be extended while the system is
+	 * operational. If a PF driver needs to extend a TQM ring, it needs
+	 * to delete the SCHQ and then reallocate it.
+	 */
 	uint32_t	tqm_ring4_num_entries;
-	/* Number of TQM ring 5 entries. */
+	/*
+	 * Number of TQM ring 5 entries.
+	 *
+	 * TQM fastpath rings should be sized large enough to accommodate the
+	 * maximum number of QPs (either L2 or RoCE, or both if shared)
+	 * that can be enqueued to the TQM ring.
+	 *
+	 * Note that TQM ring sizes cannot be extended while the system is
+	 * operational. If a PF driver needs to extend a TQM ring, it needs
+	 * to delete the SCHQ and then reallocate it.
+	 */
 	uint32_t	tqm_ring5_num_entries;
-	/* Number of TQM ring 6 entries. */
+	/*
+	 * Number of TQM ring 6 entries.
+	 *
+	 * TQM fastpath rings should be sized large enough to accommodate the
+	 * maximum number of QPs (either L2 or RoCE, or both if shared)
+	 * that can be enqueued to the TQM ring.
+	 *
+	 * Note that TQM ring sizes cannot be extended while the system is
+	 * operational. If a PF driver needs to extend a TQM ring, it needs
+	 * to delete the SCHQ and then reallocate it.
+	 */
 	uint32_t	tqm_ring6_num_entries;
-	/* Number of TQM ring 7 entries. */
+	/*
+	 * Number of TQM ring 7 entries.
+	 *
+	 * TQM fastpath rings should be sized large enough to accommodate the
+	 * maximum number of QPs (either L2 or RoCE, or both if shared)
+	 * that can be enqueued to the TQM ring.
+	 *
+	 * Note that TQM ring sizes cannot be extended while the system is
+	 * operational. If a PF driver needs to extend a TQM ring, it needs
+	 * to delete the SCHQ and then reallocate it.
+	 */
 	uint32_t	tqm_ring7_num_entries;
+	/* Number of bytes that have been allocated for each context entry. */
+	uint16_t	tqm_entry_size;
+	uint8_t	unused_0[6];
+} hwrm_ring_schq_alloc_input_t, *phwrm_ring_schq_alloc_input_t;
+
+/* hwrm_ring_schq_alloc_output (size:128b/16B) */
+
+typedef struct hwrm_ring_schq_alloc_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/*
+	 * This is an identifier for the SCHQ to be used in other HWRM commands
+	 * that need to reference this SCHQ. This value is greater than zero
+	 * (i.e. a schq_id of zero references the default SCHQ).
+	 */
+	uint16_t	schq_id;
+	uint8_t	unused_0[5];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_ring_schq_alloc_output_t, *phwrm_ring_schq_alloc_output_t;
+
+/**********************
+ * hwrm_ring_schq_cfg *
+ **********************/
+
+
+/* hwrm_ring_schq_cfg_input (size:768b/96B) */
+
+typedef struct hwrm_ring_schq_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/*
+	 * Identifies the SCHQ being configured. A schq_id of zero refers to
+	 * the default SCHQ.
+	 */
+	uint16_t	schq_id;
+	/*
+	 * This field is an 8 bit bitmap that indicates which TCs are enabled
+	 * in this SCHQ. Bit 0 represents traffic class 0 and bit 7 represents
+	 * traffic class 7.
+	 */
+	uint8_t	tc_enabled;
+	uint8_t	unused_0;
+	uint32_t	flags;
+	/* The tc_max_bw array and the max_bw parameters are valid */
+	#define HWRM_RING_SCHQ_CFG_INPUT_FLAGS_TC_MAX_BW_ENABLED	UINT32_C(0x1)
+	/* The tc_bw_reservation array is valid */
+	#define HWRM_RING_SCHQ_CFG_INPUT_FLAGS_TC_RESERVATION_ENABLED	UINT32_C(0x2)
+	/* Maximum bandwidth of the traffic class, specified in Mbps. */
+	uint32_t	max_bw_tc0;
+	/* Maximum bandwidth of the traffic class, specified in Mbps. */
+	uint32_t	max_bw_tc1;
+	/* Maximum bandwidth of the traffic class, specified in Mbps. */
+	uint32_t	max_bw_tc2;
+	/* Maximum bandwidth of the traffic class, specified in Mbps. */
+	uint32_t	max_bw_tc3;
+	/* Maximum bandwidth of the traffic class, specified in Mbps. */
+	uint32_t	max_bw_tc4;
+	/* Maximum bandwidth of the traffic class, specified in Mbps. */
+	uint32_t	max_bw_tc5;
+	/* Maximum bandwidth of the traffic class, specified in Mbps. */
+	uint32_t	max_bw_tc6;
+	/* Maximum bandwidth of the traffic class, specified in Mbps. */
+	uint32_t	max_bw_tc7;
+	/*
+	 * Bandwidth reservation for the traffic class, specified in percent.
+	 * A value of zero signifies that traffic belonging to this class
+	 * shares the bandwidth reservation for the same traffic class of
+	 * the default SCHQ.
+	 */
+	uint32_t	tc_bw_reservation0;
+	/*
+	 * Bandwidth reservation for the traffic class, specified in percent.
+	 * A value of zero signifies that traffic belonging to this class
+	 * shares the bandwidth reservation for the same traffic class of
+	 * the default SCHQ.
+	 */
+	uint32_t	tc_bw_reservation1;
+	/*
+	 * Bandwidth reservation for the traffic class, specified in percent.
+	 * A value of zero signifies that traffic belonging to this class
+	 * shares the bandwidth reservation for the same traffic class of
+	 * the default SCHQ.
+	 */
+	uint32_t	tc_bw_reservation2;
+	/*
+	 * Bandwidth reservation for the traffic class, specified in percent.
+	 * A value of zero signifies that traffic belonging to this class
+	 * shares the bandwidth reservation for the same traffic class of
+	 * the default SCHQ.
+	 */
+	uint32_t	tc_bw_reservation3;
+	/*
+	 * Bandwidth reservation for the traffic class, specified in percent.
+	 * A value of zero signifies that traffic belonging to this class
+	 * shares the bandwidth reservation for the same traffic class of
+	 * the default SCHQ.
+	 */
+	uint32_t	tc_bw_reservation4;
+	/*
+	 * Bandwidth reservation for the traffic class, specified in percent.
+	 * A value of zero signifies that traffic belonging to this class
+	 * shares the bandwidth reservation for the same traffic class of
+	 * the default SCHQ.
+	 */
+	uint32_t	tc_bw_reservation5;
+	/*
+	 * Bandwidth reservation for the traffic class, specified in percent.
+	 * A value of zero signifies that traffic belonging to this class
+	 * shares the bandwidth reservation for the same traffic class of
+	 * the default SCHQ.
+	 */
+	uint32_t	tc_bw_reservation6;
+	/*
+	 * Bandwidth reservation for the traffic class, specified in percent.
+	 * A value of zero signifies that traffic belonging to this class
+	 * shares the bandwidth reservation for the same traffic class of
+	 * the default SCHQ.
+	 */
+	uint32_t	tc_bw_reservation7;
+	/*
+	 * Indicates the max bandwidth for all enabled traffic classes in
+	 * this SCHQ, specified in Mbps.
+	 */
+	uint32_t	max_bw;
+	uint8_t	unused_1[4];
+} hwrm_ring_schq_cfg_input_t, *phwrm_ring_schq_cfg_input_t;
+
+/* hwrm_ring_schq_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_ring_schq_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_ring_schq_cfg_output_t, *phwrm_ring_schq_cfg_output_t;
+
+/***********************
+ * hwrm_ring_schq_free *
+ ***********************/
+
+
+/* hwrm_ring_schq_free_input (size:192b/24B) */
+
+typedef struct hwrm_ring_schq_free_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Identifies the SCHQ being freed. */
+	uint16_t	schq_id;
+	uint8_t	unused_0[6];
+} hwrm_ring_schq_free_input_t, *phwrm_ring_schq_free_input_t;
+
+/* hwrm_ring_schq_free_output (size:128b/16B) */
+
+typedef struct hwrm_ring_schq_free_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_ring_schq_free_output_t, *phwrm_ring_schq_free_output_t;
+
+/*
+ * special reserved flow ID to identify per function default
+ * flows for vSwitch offload
+ */
+#define DEFAULT_FLOW_ID 0xFFFFFFFFUL
+/*
+ * special reserved flow ID to identify per function RoCEv1
+ * flows
+ */
+#define ROCEV1_FLOW_ID 0xFFFFFFFEUL
+/*
+ * special reserved flow ID to identify per function RoCEv2
+ * flows
+ */
+#define ROCEV2_FLOW_ID 0xFFFFFFFDUL
+/*
+ * special reserved flow ID to identify per function RoCEv2
+ * CNP flows
+ */
+#define ROCEV2_CNP_FLOW_ID 0xFFFFFFFCUL
+
+/****************************
+ * hwrm_cfa_l2_filter_alloc *
+ ****************************/
+
+
+/* hwrm_cfa_l2_filter_alloc_input (size:768b/96B) */
+
+typedef struct hwrm_cfa_l2_filter_alloc_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * If the MR/AV split reservation flag is not set, then this field
-	 * represents the total number of MR plus AV entries. For versions
-	 * of firmware that support the split reservation, when it is not
-	 * specified half of the entries will be reserved for MRs and the
-	 * other half for AVs.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	flags;
+	/*
+	 * Enumeration denoting the RX, TX type of the resource.
+	 * This enumeration is used for resources that are similar for both
+	 * TX and RX paths of the chip.
+	 */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_PATH		UINT32_C(0x1)
+	/* tx path */
+		#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_PATH_TX		UINT32_C(0x0)
+	/* rx path */
+		#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_PATH_RX		UINT32_C(0x1)
+		#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_PATH_LAST	HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_PATH_RX
+	/*
+	 * Setting of this flag indicates the applicability to the loopback
+	 * path.
+	 */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_LOOPBACK	UINT32_C(0x2)
+	/*
+	 * Setting of this flag indicates drop action. If this flag is not
+	 * set, then it should be considered accept action.
+	 */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_DROP		UINT32_C(0x4)
+	/*
+	 * If this flag is set, all t_l2_* fields are invalid
+	 * and they should not be specified.
+	 * If this flag is set, then l2_* fields refer to
+	 * fields of outermost L2 header.
+	 */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_OUTERMOST	UINT32_C(0x8)
+	/*
+	 * Enumeration denoting NO_ROCE_L2 to support old drivers.
+	 * New driver L2 for only L2 traffic, ROCE for roce and l2 traffic
+	 */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_TRAFFIC_MASK	UINT32_C(0x30)
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_TRAFFIC_SFT	4
+	/* To support old drivers */
+		#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_TRAFFIC_NO_ROCE_L2  (UINT32_C(0x0) << 4)
+	/* Only L2 traffic */
+		#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_TRAFFIC_L2	(UINT32_C(0x1) << 4)
+	/* Roce & L2 traffic */
+		#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_TRAFFIC_ROCE	(UINT32_C(0x2) << 4)
+		#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_TRAFFIC_LAST	HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_TRAFFIC_ROCE
+	/*
+	 * Setting of this flag indicates that no XDP filter is created with
+	 * L2 filter.
+	 * 0 - legacy behavior, XDP filter is created with L2 filter
+	 * 1 - XDP filter won't be created with L2 filter
+	 */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_XDP_DISABLE	UINT32_C(0x40)
+	/*
+	 * Setting this flag to 1 indicate the L2 fields in this command
+	 * pertain to source fields. Setting this flag to 0 indicate the
+	 * L2 fields in this command pertain to the destination fields
+	 * and this is the default/legacy behavior.
+	 */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_SOURCE_VALID	UINT32_C(0x80)
+	uint32_t	enables;
+	/*
+	 * This bit must be '1' for the l2_addr field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR		UINT32_C(0x1)
+	/*
+	 * This bit must be '1' for the l2_addr_mask field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR_MASK	UINT32_C(0x2)
+	/*
+	 * This bit must be '1' for the l2_ovlan field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_OVLAN		UINT32_C(0x4)
+	/*
+	 * This bit must be '1' for the l2_ovlan_mask field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_OVLAN_MASK	UINT32_C(0x8)
+	/*
+	 * This bit must be '1' for the l2_ivlan field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_IVLAN		UINT32_C(0x10)
+	/*
+	 * This bit must be '1' for the l2_ivlan_mask field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_IVLAN_MASK	UINT32_C(0x20)
+	/*
+	 * This bit must be '1' for the t_l2_addr field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_T_L2_ADDR	UINT32_C(0x40)
+	/*
+	 * This bit must be '1' for the t_l2_addr_mask field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_T_L2_ADDR_MASK	UINT32_C(0x80)
+	/*
+	 * This bit must be '1' for the t_l2_ovlan field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_T_L2_OVLAN	UINT32_C(0x100)
+	/*
+	 * This bit must be '1' for the t_l2_ovlan_mask field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_T_L2_OVLAN_MASK	UINT32_C(0x200)
+	/*
+	 * This bit must be '1' for the t_l2_ivlan field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_T_L2_IVLAN	UINT32_C(0x400)
+	/*
+	 * This bit must be '1' for the t_l2_ivlan_mask field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_T_L2_IVLAN_MASK	UINT32_C(0x800)
+	/*
+	 * This bit must be '1' for the src_type field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_SRC_TYPE		UINT32_C(0x1000)
+	/*
+	 * This bit must be '1' for the src_id field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_SRC_ID		UINT32_C(0x2000)
+	/*
+	 * This bit must be '1' for the tunnel_type field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_TUNNEL_TYPE	UINT32_C(0x4000)
+	/*
+	 * This bit must be '1' for the dst_id field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_DST_ID		UINT32_C(0x8000)
+	/*
+	 * This bit must be '1' for the mirror_vnic_id field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_MIRROR_VNIC_ID	UINT32_C(0x10000)
+	/*
+	 * This bit must be '1' for the num_vlans field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_NUM_VLANS	UINT32_C(0x20000)
+	/*
+	 * This bit must be '1' for the t_num_vlans field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_T_NUM_VLANS	UINT32_C(0x40000)
+	/*
+	 * This value sets the match value for the L2 MAC address.
+	 * Destination MAC address for RX path.
+	 * Source MAC address for TX path.
+	 */
+	uint8_t	l2_addr[6];
+	/* This value sets the match value for the number of VLANs. */
+	uint8_t	num_vlans;
+	/*
+	 * This value sets the match value for the number of VLANs
+	 * in the tunnel headers.
+	 */
+	uint8_t	t_num_vlans;
+	/*
+	 * This value sets the mask value for the L2 address.
+	 * A value of 0 will mask the corresponding bit from
+	 * compare.
+	 */
+	uint8_t	l2_addr_mask[6];
+	/* This value sets VLAN ID value for outer VLAN. */
+	uint16_t	l2_ovlan;
+	/*
+	 * This value sets the mask value for the ovlan id.
+	 * A value of 0 will mask the corresponding bit from
+	 * compare.
+	 */
+	uint16_t	l2_ovlan_mask;
+	/* This value sets VLAN ID value for inner VLAN. */
+	uint16_t	l2_ivlan;
+	/*
+	 * This value sets the mask value for the ivlan id.
+	 * A value of 0 will mask the corresponding bit from
+	 * compare.
+	 */
+	uint16_t	l2_ivlan_mask;
+	uint8_t	unused_1[2];
+	/*
+	 * This value sets the match value for the tunnel
+	 * L2 MAC address.
+	 * Destination MAC address for RX path.
+	 * Source MAC address for TX path.
+	 */
+	uint8_t	t_l2_addr[6];
+	uint8_t	unused_2[2];
+	/*
+	 * This value sets the mask value for the tunnel L2
+	 * address.
+	 * A value of 0 will mask the corresponding bit from
+	 * compare.
+	 */
+	uint8_t	t_l2_addr_mask[6];
+	/* This value sets VLAN ID value for tunnel outer VLAN. */
+	uint16_t	t_l2_ovlan;
+	/*
+	 * This value sets the mask value for the tunnel ovlan id.
+	 * A value of 0 will mask the corresponding bit from
+	 * compare.
+	 */
+	uint16_t	t_l2_ovlan_mask;
+	/* This value sets VLAN ID value for tunnel inner VLAN. */
+	uint16_t	t_l2_ivlan;
+	/*
+	 * This value sets the mask value for the tunnel ivlan id.
+	 * A value of 0 will mask the corresponding bit from
+	 * compare.
+	 */
+	uint16_t	t_l2_ivlan_mask;
+	/* This value identifies the type of source of the packet. */
+	uint8_t	src_type;
+	/* Network port */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_SRC_TYPE_NPORT UINT32_C(0x0)
+	/* Physical function */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_SRC_TYPE_PF	UINT32_C(0x1)
+	/* Virtual function */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_SRC_TYPE_VF	UINT32_C(0x2)
+	/* Virtual NIC of a function */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_SRC_TYPE_VNIC  UINT32_C(0x3)
+	/* Embedded processor for CFA management */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_SRC_TYPE_KONG  UINT32_C(0x4)
+	/* Embedded processor for OOB management */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_SRC_TYPE_APE   UINT32_C(0x5)
+	/* Embedded processor for RoCE */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_SRC_TYPE_BONO  UINT32_C(0x6)
+	/* Embedded processor for network proxy functions */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_SRC_TYPE_TANG  UINT32_C(0x7)
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_SRC_TYPE_LAST HWRM_CFA_L2_FILTER_ALLOC_INPUT_SRC_TYPE_TANG
+	uint8_t	unused_3;
+	/*
+	 * This value is the id of the source.
+	 * For a network port, it represents port_id.
+	 * For a physical function, it represents fid.
+	 * For a virtual function, it represents vf_id.
+	 * For a vnic, it represents vnic_id.
+	 * For embedded processors, this id is not valid.
 	 *
-	 * If the MR/AV split reservation flag is set, then this
-	 * field is logically divided into two 16b fields. Bits `[31:16]`
-	 * represents the `mr_num_entries` and bits `[15:0]` represents
-	 * `av_num_entries`. The granularity of these values is defined by
-	 * the `mrav_num_entries_unit` field returned by the
-	 * `backing_store_qcaps` command.
+	 * Notes:
+	 * 1. The function ID is implied if it src_id is
+	 *	not provided for a src_type that is either
 	 */
-	uint32_t	mrav_num_entries;
-	/* Number of Timer entries. */
-	uint32_t	tim_num_entries;
-	/* TQM ring page size and level. */
-	uint8_t	tqm_ring8_pg_size_tqm_ring_lvl;
-	/* TQM ring PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING8_TQM_RING_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING8_TQM_RING_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING8_TQM_RING_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING8_TQM_RING_LVL_LVL_1	UINT32_C(0x1)
+	uint32_t	src_id;
+	/* Tunnel Type. */
+	uint8_t	tunnel_type;
+	/* Non-tunnel */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_TUNNEL_TYPE_NONTUNNEL	UINT32_C(0x0)
+	/* Virtual eXtensible Local Area Network (VXLAN) */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_TUNNEL_TYPE_VXLAN	UINT32_C(0x1)
+	/* Network Virtualization Generic Routing Encapsulation (NVGRE) */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_TUNNEL_TYPE_NVGRE	UINT32_C(0x2)
+	/* Generic Routing Encapsulation (GRE) inside Ethernet payload */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_TUNNEL_TYPE_L2GRE	UINT32_C(0x3)
+	/* IP in IP */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_TUNNEL_TYPE_IPIP	UINT32_C(0x4)
+	/* Generic Network Virtualization Encapsulation (Geneve) */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_TUNNEL_TYPE_GENEVE	UINT32_C(0x5)
+	/* Multi-Protocol Label Switching (MPLS) */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_TUNNEL_TYPE_MPLS	UINT32_C(0x6)
+	/* Stateless Transport Tunnel (STT) */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_TUNNEL_TYPE_STT	UINT32_C(0x7)
+	/* Generic Routing Encapsulation (GRE) inside IP datagram payload */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_TUNNEL_TYPE_IPGRE	UINT32_C(0x8)
+	/* IPV4 over virtual eXtensible Local Area Network (IPV4oVXLAN) */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_V4	UINT32_C(0x9)
 	/*
-	 * PBL pointer points to PDE table with each entry pointing to
-	 * PTE tables.
+	 * Enhance Generic Routing Encapsulation (GRE version 1) inside IP
+	 * datagram payload
 	 */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING8_TQM_RING_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING8_TQM_RING_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING8_TQM_RING_LVL_LVL_2
-	/* TQM ring page size. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING8_TQM_RING_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING8_TQM_RING_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING8_TQM_RING_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING8_TQM_RING_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING8_TQM_RING_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING8_TQM_RING_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING8_TQM_RING_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING8_TQM_RING_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING8_TQM_RING_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING8_TQM_RING_PG_SIZE_PG_1G
-	uint8_t	ring8_unused[3];
-	/* Number of TQM ring entries. */
-	uint32_t	tqm_ring8_num_entries;
-	/* TQM ring page directory. */
-	uint64_t	tqm_ring8_page_dir;
-	/* TQM ring page size and level. */
-	uint8_t	tqm_ring9_pg_size_tqm_ring_lvl;
-	/* TQM ring PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING9_TQM_RING_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING9_TQM_RING_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING9_TQM_RING_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING9_TQM_RING_LVL_LVL_1	UINT32_C(0x1)
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_TUNNEL_TYPE_IPGRE_V1	UINT32_C(0xa)
+	/* Use fixed layer 2 ether type of 0xFFFF */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_TUNNEL_TYPE_L2_ETYPE	UINT32_C(0xb)
 	/*
-	 * PBL pointer points to PDE table with each entry pointing to
-	 * PTE tables.
+	 * IPV6 over virtual eXtensible Local Area Network with GPE header
+	 * (IPV6oVXLANGPE)
 	 */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING9_TQM_RING_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING9_TQM_RING_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING9_TQM_RING_LVL_LVL_2
-	/* TQM ring page size. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING9_TQM_RING_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING9_TQM_RING_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING9_TQM_RING_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING9_TQM_RING_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING9_TQM_RING_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING9_TQM_RING_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING9_TQM_RING_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING9_TQM_RING_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING9_TQM_RING_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING9_TQM_RING_PG_SIZE_PG_1G
-	uint8_t	ring9_unused[3];
-	/* Number of TQM ring entries. */
-	uint32_t	tqm_ring9_num_entries;
-	/* TQM ring page directory. */
-	uint64_t	tqm_ring9_page_dir;
-	/* TQM ring page size and level. */
-	uint8_t	tqm_ring10_pg_size_tqm_ring_lvl;
-	/* TQM ring PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING10_TQM_RING_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING10_TQM_RING_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING10_TQM_RING_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING10_TQM_RING_LVL_LVL_1	UINT32_C(0x1)
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_GPE_V6 UINT32_C(0xc)
+	/* Generic Protocol Extension for VXLAN (VXLAN-GPE) */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_GPE	UINT32_C(0x10)
+	/* Any tunneled traffic */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_TUNNEL_TYPE_ANYTUNNEL	UINT32_C(0xff)
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_TUNNEL_TYPE_LAST	HWRM_CFA_L2_FILTER_ALLOC_INPUT_TUNNEL_TYPE_ANYTUNNEL
+	uint8_t	unused_4;
 	/*
-	 * PBL pointer points to PDE table with each entry pointing to
-	 * PTE tables.
+	 * If set, this value shall represent the
+	 * Logical VNIC ID of the destination VNIC for the RX
+	 * path and network port id of the destination port for
+	 * the TX path.
 	 */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING10_TQM_RING_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING10_TQM_RING_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING10_TQM_RING_LVL_LVL_2
-	/* TQM ring page size. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING10_TQM_RING_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING10_TQM_RING_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING10_TQM_RING_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING10_TQM_RING_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING10_TQM_RING_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING10_TQM_RING_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING10_TQM_RING_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING10_TQM_RING_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING10_TQM_RING_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RING10_TQM_RING_PG_SIZE_PG_1G
-	uint8_t	ring10_unused[3];
-	/* Number of TQM ring entries. */
-	uint32_t	tqm_ring10_num_entries;
-	/* TQM ring page directory. */
-	uint64_t	tqm_ring10_page_dir;
-	/* Number of Tx KTLS context entries. */
-	uint32_t	tkc_num_entries;
-	/* Number of Rx KTLS context entries. */
-	uint32_t	rkc_num_entries;
-	/* Tx KTLS context page directory. */
-	uint64_t	tkc_page_dir;
-	/* Rx KTLS context page directory. */
-	uint64_t	rkc_page_dir;
-	/* Tx KTLS context page size and level. */
-	uint8_t	tkc_pg_size_tkc_lvl;
-	/* Tx KTLS context PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TKC_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TKC_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TKC_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TKC_LVL_LVL_1	UINT32_C(0x1)
+	uint16_t	dst_id;
+	/*
+	 * Logical VNIC ID of the VNIC where traffic is
+	 * mirrored.
+	 */
+	uint16_t	mirror_vnic_id;
+	/*
+	 * This hint is provided to help in placing
+	 * the filter in the filter table.
+	 */
+	uint8_t	pri_hint;
+	/* No preference */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_PRI_HINT_NO_PREFER	UINT32_C(0x0)
+	/* Above the given filter */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_PRI_HINT_ABOVE_FILTER UINT32_C(0x1)
+	/* Below the given filter */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_PRI_HINT_BELOW_FILTER UINT32_C(0x2)
+	/* As high as possible */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_PRI_HINT_MAX	UINT32_C(0x3)
+	/* As low as possible */
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_PRI_HINT_MIN	UINT32_C(0x4)
+	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_PRI_HINT_LAST	HWRM_CFA_L2_FILTER_ALLOC_INPUT_PRI_HINT_MIN
+	uint8_t	unused_5;
+	uint32_t	unused_6;
+	/*
+	 * This is the ID of the filter that goes along with
+	 * the pri_hint.
+	 *
+	 * This field is valid only for the following values.
+	 * 1 - Above the given filter
+	 * 2 - Below the given filter
+	 */
+	uint64_t	l2_filter_id_hint;
+} hwrm_cfa_l2_filter_alloc_input_t, *phwrm_cfa_l2_filter_alloc_input_t;
+
+/* hwrm_cfa_l2_filter_alloc_output (size:192b/24B) */
+
+typedef struct hwrm_cfa_l2_filter_alloc_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
 	/*
-	 * PBL pointer points to PDE table with each entry pointing to
-	 * PTE tables.
+	 * This value identifies a set of CFA data structures used for an L2
+	 * context.
 	 */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TKC_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TKC_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TKC_LVL_LVL_2
-	/* Tx KTLS context page size. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TKC_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TKC_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TKC_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TKC_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TKC_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TKC_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TKC_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TKC_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TKC_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_TKC_PG_SIZE_PG_1G
-	/* Rx KTLS context page size and level. */
-	uint8_t	rkc_pg_size_tkc_lvl;
-	/* Rx KTLS context PBL indirect levels. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RKC_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RKC_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RKC_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RKC_LVL_LVL_1	UINT32_C(0x1)
+	uint64_t	l2_filter_id;
 	/*
-	 * PBL pointer points to PDE table with each entry pointing to
-	 * PTE tables.
+	 * The flow id value in bit 0-29 is the actual ID of the flow
+	 * associated with this filter and it shall be used to match
+	 * and associate the flow identifier returned in completion
+	 * records. A value of 0xFFFFFFFF in the 32-bit flow_id field
+	 * shall indicate no valid flow id.
 	 */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RKC_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RKC_LVL_LAST	HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RKC_LVL_LVL_2
-	/* Rx KTLS context page size. */
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RKC_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RKC_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RKC_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RKC_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RKC_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RKC_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RKC_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RKC_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RKC_PG_SIZE_LAST   HWRM_FUNC_BACKING_STORE_QCFG_OUTPUT_RKC_PG_SIZE_PG_1G
-	uint8_t	unused_1[5];
+	uint32_t	flow_id;
+	/* Indicate the flow id value. */
+	#define HWRM_CFA_L2_FILTER_ALLOC_OUTPUT_FLOW_ID_VALUE_MASK UINT32_C(0x3fffffff)
+	#define HWRM_CFA_L2_FILTER_ALLOC_OUTPUT_FLOW_ID_VALUE_SFT 0
+	/* Indicate type of the flow. */
+	#define HWRM_CFA_L2_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE	UINT32_C(0x40000000)
+	/*
+	 * If this bit set to 0, then it indicates that the flow is
+	 * internal flow.
+	 */
+		#define HWRM_CFA_L2_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE_INT	(UINT32_C(0x0) << 30)
+	/*
+	 * If this bit is set to 1, then it indicates that the flow is
+	 * external flow.
+	 */
+		#define HWRM_CFA_L2_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE_EXT	(UINT32_C(0x1) << 30)
+		#define HWRM_CFA_L2_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE_LAST  HWRM_CFA_L2_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE_EXT
+	/* Indicate the flow direction. */
+	#define HWRM_CFA_L2_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR	UINT32_C(0x80000000)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_CFA_L2_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR_RX	(UINT32_C(0x0) << 31)
+	/* If this bit is set to 1, then it indicates that tx flow. */
+		#define HWRM_CFA_L2_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR_TX	(UINT32_C(0x1) << 31)
+		#define HWRM_CFA_L2_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR_LAST   HWRM_CFA_L2_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR_TX
+	uint8_t	unused_0[3];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as 1
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
 	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field
-	 * is written last.
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_func_backing_store_qcfg_output_t, *phwrm_func_backing_store_qcfg_output_t;
+} hwrm_cfa_l2_filter_alloc_output_t, *phwrm_cfa_l2_filter_alloc_output_t;
 
-/****************************
- * hwrm_error_recovery_qcfg *
- ****************************/
+/***************************
+ * hwrm_cfa_l2_filter_free *
+ ***************************/
 
 
-/* hwrm_error_recovery_qcfg_input (size:192b/24B) */
+/* hwrm_cfa_l2_filter_free_input (size:192b/24B) */
 
-typedef struct hwrm_error_recovery_qcfg_input {
+typedef struct hwrm_cfa_l2_filter_free_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -16547,12 +44541,16 @@ typedef struct hwrm_error_recovery_qcfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint8_t	unused_0[8];
-} hwrm_error_recovery_qcfg_input_t, *phwrm_error_recovery_qcfg_input_t;
+	/*
+	 * This value identifies a set of CFA data structures used for an L2
+	 * context.
+	 */
+	uint64_t	l2_filter_id;
+} hwrm_cfa_l2_filter_free_input_t, *phwrm_cfa_l2_filter_free_input_t;
 
-/* hwrm_error_recovery_qcfg_output (size:1664b/208B) */
+/* hwrm_cfa_l2_filter_free_output (size:128b/16B) */
 
-typedef struct hwrm_error_recovery_qcfg_output {
+typedef struct hwrm_cfa_l2_filter_free_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -16561,328 +44559,451 @@ typedef struct hwrm_error_recovery_qcfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint32_t	flags;
+	uint8_t	unused_0[7];
 	/*
-	 * When this flag is set to 1, error recovery will be initiated
-	 * through master function driver.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FLAGS_HOST	UINT32_C(0x1)
+	uint8_t	valid;
+} hwrm_cfa_l2_filter_free_output_t, *phwrm_cfa_l2_filter_free_output_t;
+
+/**************************
+ * hwrm_cfa_l2_filter_cfg *
+ **************************/
+
+
+/* hwrm_cfa_l2_filter_cfg_input (size:384b/48B) */
+
+typedef struct hwrm_cfa_l2_filter_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * When this flag is set to 1, error recovery will be performed
-	 * through Co processor.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FLAGS_CO_CPU	UINT32_C(0x2)
+	uint16_t	cmpl_ring;
 	/*
-	 * Driver Polling frequency. This value is in units of 100msec.
-	 * Typical value would be 10 to indicate 1sec.
-	 * Drivers can poll FW health status, Heartbeat, reset_counter with
-	 * this frequency.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint32_t	driver_polling_freq;
+	uint16_t	seq_id;
 	/*
-	 * This value is in units of 100msec.
-	 * Typical value would be 30 to indicate 3sec.
-	 * Master function wait period from detecting a fatal error to
-	 * initiating reset. In this time period Master PF expects every
-	 * active driver will detect fatal error.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint32_t	master_func_wait_period;
+	uint16_t	target_id;
 	/*
-	 * This value is in units of 100msec.
-	 * Typical value would be 50 to indicate 5sec.
-	 * Normal function wait period from fatal error detection to
-	 * polling FW health status. In this time period, drivers should not
-	 * do any PCIe MMIO transaction and should not send any HWRM commands.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint32_t	normal_func_wait_period;
+	uint64_t	resp_addr;
+	uint32_t	flags;
 	/*
-	 * This value is in units of 100msec.
-	 * Typical value would be 20 to indicate 2sec.
-	 * This field indicates that, master function wait period after chip
-	 * reset. After this time, master function should reinitialize with
-	 * FW.
+	 * Enumeration denoting the RX, TX type of the resource.
+	 * This enumeration is used for resources that are similar for both
+	 * TX and RX paths of the chip.
 	 */
-	uint32_t	master_func_wait_period_after_reset;
+	#define HWRM_CFA_L2_FILTER_CFG_INPUT_FLAGS_PATH		UINT32_C(0x1)
+	/* tx path */
+		#define HWRM_CFA_L2_FILTER_CFG_INPUT_FLAGS_PATH_TX		UINT32_C(0x0)
+	/* rx path */
+		#define HWRM_CFA_L2_FILTER_CFG_INPUT_FLAGS_PATH_RX		UINT32_C(0x1)
+		#define HWRM_CFA_L2_FILTER_CFG_INPUT_FLAGS_PATH_LAST		HWRM_CFA_L2_FILTER_CFG_INPUT_FLAGS_PATH_RX
 	/*
-	 * This value is in units of 100msec.
-	 * Typical value would be 60 to indicate 6sec.
-	 * This field is applicable to both master and normal functions.
-	 * Even after chip reset, if FW status not changed to ready,
-	 * then all the functions can poll for this much time and bailout.
+	 * Setting of this flag indicates drop action. If this flag is not
+	 * set, then it should be considered accept action.
 	 */
-	uint32_t	max_bailout_time_after_reset;
+	#define HWRM_CFA_L2_FILTER_CFG_INPUT_FLAGS_DROP		UINT32_C(0x2)
 	/*
-	 * FW health status register.
-	 * Lower 2 bits indicates address space location and upper 30 bits
-	 * indicates upper 30bits of the register address.
-	 * A value of 0xFFFF-FFFF indicates this register does not exist.
+	 * Enumeration denoting NO_ROCE_L2 to support old drivers.
+	 * New driver L2 for only L2 traffic, ROCE for roce and l2 traffic
 	 */
-	uint32_t	fw_health_status_reg;
-	/* Lower 2 bits indicates address space location. */
-	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEALTH_STATUS_REG_ADDR_SPACE_MASK	UINT32_C(0x3)
-	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEALTH_STATUS_REG_ADDR_SPACE_SFT	0
+	#define HWRM_CFA_L2_FILTER_CFG_INPUT_FLAGS_TRAFFIC_MASK	UINT32_C(0xc)
+	#define HWRM_CFA_L2_FILTER_CFG_INPUT_FLAGS_TRAFFIC_SFT	2
+	/* To support old drivers */
+		#define HWRM_CFA_L2_FILTER_CFG_INPUT_FLAGS_TRAFFIC_NO_ROCE_L2	(UINT32_C(0x0) << 2)
+	/* Only L2 traffic */
+		#define HWRM_CFA_L2_FILTER_CFG_INPUT_FLAGS_TRAFFIC_L2		(UINT32_C(0x1) << 2)
+	/* Roce & L2 traffic */
+		#define HWRM_CFA_L2_FILTER_CFG_INPUT_FLAGS_TRAFFIC_ROCE	(UINT32_C(0x2) << 2)
+		#define HWRM_CFA_L2_FILTER_CFG_INPUT_FLAGS_TRAFFIC_LAST	HWRM_CFA_L2_FILTER_CFG_INPUT_FLAGS_TRAFFIC_ROCE
 	/*
-	 * If value is 0, this register is located in PCIe config space.
-	 * Drivers have to map appropriate window to access this
-	 * register.
+	 * Enumeration denoting how the L2 Context TCAM remap operation is
+	 * updated.
+	 */
+	#define HWRM_CFA_L2_FILTER_CFG_INPUT_FLAGS_REMAP_OP_MASK	UINT32_C(0x30)
+	#define HWRM_CFA_L2_FILTER_CFG_INPUT_FLAGS_REMAP_OP_SFT	4
+	/* No change to remap opcode */
+		#define HWRM_CFA_L2_FILTER_CFG_INPUT_FLAGS_REMAP_OP_NO_UPDATE	(UINT32_C(0x0) << 4)
+	/* Bypass CFA Lookup */
+		#define HWRM_CFA_L2_FILTER_CFG_INPUT_FLAGS_REMAP_OP_BYPASS_LKUP  (UINT32_C(0x1) << 4)
+	/* Enable CFA Lookup */
+		#define HWRM_CFA_L2_FILTER_CFG_INPUT_FLAGS_REMAP_OP_ENABLE_LKUP  (UINT32_C(0x2) << 4)
+		#define HWRM_CFA_L2_FILTER_CFG_INPUT_FLAGS_REMAP_OP_LAST	HWRM_CFA_L2_FILTER_CFG_INPUT_FLAGS_REMAP_OP_ENABLE_LKUP
+	uint32_t	enables;
+	/*
+	 * This bit must be '1' for the dst_id field to be
+	 * configured.
 	 */
-		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEALTH_STATUS_REG_ADDR_SPACE_PCIE_CFG  UINT32_C(0x0)
+	#define HWRM_CFA_L2_FILTER_CFG_INPUT_ENABLES_DST_ID		UINT32_C(0x1)
 	/*
-	 * If value is 1, this register is located in GRC address space.
-	 * Drivers have to map appropriate window to access this
-	 * register.
+	 * This bit must be '1' for the new_mirror_vnic_id field to be
+	 * configured.
 	 */
-		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEALTH_STATUS_REG_ADDR_SPACE_GRC	UINT32_C(0x1)
+	#define HWRM_CFA_L2_FILTER_CFG_INPUT_ENABLES_NEW_MIRROR_VNIC_ID	UINT32_C(0x2)
 	/*
-	 * If value is 2, this register is located in first BAR address
-	 * space. Drivers have to map appropriate window to access this
-	 * register.
+	 * This bit must be '1' for the prof_func field to be configured in
+	 * the remap entry.
 	 */
-		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEALTH_STATUS_REG_ADDR_SPACE_BAR0	UINT32_C(0x2)
+	#define HWRM_CFA_L2_FILTER_CFG_INPUT_ENABLES_PROF_FUNC		UINT32_C(0x4)
 	/*
-	 * If value is 3, this register is located in second BAR address
-	 * space. Drivers have to map appropriate window to access this
-	 * Drivers have to map appropriate window to access this
-	 * register.
+	 * This bit must be '1' for the l2_context_id field to be configured
+	 * in the remap entry.
 	 */
-		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEALTH_STATUS_REG_ADDR_SPACE_BAR1	UINT32_C(0x3)
-		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEALTH_STATUS_REG_ADDR_SPACE_LAST	HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEALTH_STATUS_REG_ADDR_SPACE_BAR1
-	/* Upper 30bits of the register address. */
-	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEALTH_STATUS_REG_ADDR_MASK	UINT32_C(0xfffffffc)
-	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEALTH_STATUS_REG_ADDR_SFT	2
+	#define HWRM_CFA_L2_FILTER_CFG_INPUT_ENABLES_L2_CONTEXT_ID	UINT32_C(0x8)
 	/*
-	 * FW HeartBeat register.
-	 * Lower 2 bits indicates address space location and upper 30 bits
-	 * indicates actual address.
-	 * A value of 0xFFFF-FFFF indicates this register does not exist.
+	 * This value identifies a set of CFA data structures used for an L2
+	 * context.
 	 */
-	uint32_t	fw_heartbeat_reg;
-	/* Lower 2 bits indicates address space location. */
-	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEARTBEAT_REG_ADDR_SPACE_MASK	UINT32_C(0x3)
-	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEARTBEAT_REG_ADDR_SPACE_SFT	0
+	uint64_t	l2_filter_id;
 	/*
-	 * If value is 0, this register is located in PCIe config space.
-	 * Drivers have to map appropriate window to access this
-	 * register.
+	 * If set, this value shall represent the
+	 * Logical VNIC ID of the destination VNIC for the RX
+	 * path and network port id of the destination port for
+	 * the TX path.
 	 */
-		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEARTBEAT_REG_ADDR_SPACE_PCIE_CFG  UINT32_C(0x0)
+	uint32_t	dst_id;
 	/*
-	 * If value is 1, this register is located in GRC address space.
-	 * Drivers have to map appropriate window to access this
-	 * register.
+	 * New Logical VNIC ID of the VNIC where traffic is
+	 * mirrored.
 	 */
-		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEARTBEAT_REG_ADDR_SPACE_GRC	UINT32_C(0x1)
+	uint32_t	new_mirror_vnic_id;
 	/*
-	 * If value is 2, this register is located in first BAR address
-	 * space. Drivers have to map appropriate window to access this
-	 * register.
+	 * Profile function value to be programmed into the L2 context entry's
+	 * remap. This will be used by the host application to program the CFA
+	 * Profile TCAM entry for further classification.
 	 */
-		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEARTBEAT_REG_ADDR_SPACE_BAR0	UINT32_C(0x2)
+	uint32_t	prof_func;
 	/*
-	 * If value is 3, this register is located in second BAR address
-	 * space. Drivers have to map appropriate window to access this
-	 * register.
+	 * L2 context ID value to be programmed into the L2 context entry's
+	 * remap. This will be used by the host application to program the CFA
+	 * Lookup entry for further classification.
 	 */
-		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEARTBEAT_REG_ADDR_SPACE_BAR1	UINT32_C(0x3)
-		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEARTBEAT_REG_ADDR_SPACE_LAST	HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEARTBEAT_REG_ADDR_SPACE_BAR1
-	/* Upper 30bits of the register address. */
-	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEARTBEAT_REG_ADDR_MASK	UINT32_C(0xfffffffc)
-	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_HEARTBEAT_REG_ADDR_SFT	2
+	uint32_t	l2_context_id;
+} hwrm_cfa_l2_filter_cfg_input_t, *phwrm_cfa_l2_filter_cfg_input_t;
+
+/* hwrm_cfa_l2_filter_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_cfa_l2_filter_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
 	/*
-	 * FW reset counter.
-	 * Lower 2 bits indicates address space location and upper 30 bits
-	 * indicates actual address.
-	 * A value of 0xFFFF-FFFF indicates this register does not exist.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	uint32_t	fw_reset_cnt_reg;
-	/* Lower 2 bits indicates address space location. */
-	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_RESET_CNT_REG_ADDR_SPACE_MASK	UINT32_C(0x3)
-	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_RESET_CNT_REG_ADDR_SPACE_SFT	0
+	uint8_t	valid;
+} hwrm_cfa_l2_filter_cfg_output_t, *phwrm_cfa_l2_filter_cfg_output_t;
+
+/***************************
+ * hwrm_cfa_l2_set_rx_mask *
+ ***************************/
+
+
+/* hwrm_cfa_l2_set_rx_mask_input (size:448b/56B) */
+
+typedef struct hwrm_cfa_l2_set_rx_mask_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * If value is 0, this register is located in PCIe config space.
-	 * Drivers have to map appropriate window to access this
-	 * register.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_RESET_CNT_REG_ADDR_SPACE_PCIE_CFG  UINT32_C(0x0)
+	uint16_t	cmpl_ring;
 	/*
-	 * If value is 1, this register is located in GRC address space.
-	 * Drivers have to map appropriate window to access this
-	 * register.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_RESET_CNT_REG_ADDR_SPACE_GRC	UINT32_C(0x1)
+	uint16_t	seq_id;
 	/*
-	 * If value is 2, this register is located in first BAR address
-	 * space. Drivers have to map appropriate window to access this
-	 * register.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_RESET_CNT_REG_ADDR_SPACE_BAR0	UINT32_C(0x2)
+	uint16_t	target_id;
 	/*
-	 * If value is 3, this register is located in second BAR address
-	 * space. Drivers have to map appropriate window to access this
-	 * register.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_RESET_CNT_REG_ADDR_SPACE_BAR1	UINT32_C(0x3)
-		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_RESET_CNT_REG_ADDR_SPACE_LAST	HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_RESET_CNT_REG_ADDR_SPACE_BAR1
-	/* Upper 30bits of the register address. */
-	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_RESET_CNT_REG_ADDR_MASK	UINT32_C(0xfffffffc)
-	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FW_RESET_CNT_REG_ADDR_SFT	2
+	uint64_t	resp_addr;
+	/* VNIC ID */
+	uint32_t	vnic_id;
+	uint32_t	mask;
 	/*
-	 * Reset Inprogress Register address for PFs.
-	 * Lower 2 bits indicates address space location and upper 30 bits
-	 * indicates actual address.
-	 * A value of 0xFFFF-FFFF indicates this register does not exist.
+	 * When this bit is '1', the function is requested to accept
+	 * multi-cast packets specified by the multicast addr table.
 	 */
-	uint32_t	reset_inprogress_reg;
-	/* Lower 2 bits indicates address space location. */
-	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_INPROGRESS_REG_ADDR_SPACE_MASK	UINT32_C(0x3)
-	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_INPROGRESS_REG_ADDR_SPACE_SFT	0
+	#define HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_MCAST		UINT32_C(0x2)
 	/*
-	 * If value is 0, this register is located in PCIe config space.
-	 * Drivers have to map appropriate window to access this
-	 * register.
+	 * When this bit is '1', the function is requested to accept
+	 * all multi-cast packets.
 	 */
-		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_INPROGRESS_REG_ADDR_SPACE_PCIE_CFG  UINT32_C(0x0)
+	#define HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_ALL_MCAST	UINT32_C(0x4)
 	/*
-	 * If value is 1, this register is located in GRC address space.
-	 * Drivers have to map appropriate window to access this
-	 * register.
+	 * When this bit is '1', the function is requested to accept
+	 * broadcast packets.
 	 */
-		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_INPROGRESS_REG_ADDR_SPACE_GRC	UINT32_C(0x1)
+	#define HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_BCAST		UINT32_C(0x8)
 	/*
-	 * If value is 2, this register is located in first BAR address
-	 * space. Drivers have to map appropriate window to access this
-	 * register.
+	 * When this bit is '1', the function is requested to be
+	 * put in the promiscuous mode.
+	 *
+	 * The HWRM should accept any function to set up
+	 * promiscuous mode.
+	 *
+	 * The HWRM shall follow the semantics below for the
+	 * promiscuous mode support.
+	 * # When partitioning is not enabled on a port
+	 * (i.e. single PF on the port), then the PF shall
+	 * be allowed to be in the promiscuous mode. When the
+	 * PF is in the promiscuous mode, then it shall
+	 * receive all host bound traffic on that port.
+	 * # When partitioning is enabled on a port
+	 * (i.e. multiple PFs per port) and a PF on that
+	 * port is in the promiscuous mode, then the PF
+	 * receives all traffic within that partition as
+	 * identified by a unique identifier for the
+	 * PF (e.g. S-Tag). If a unique outer VLAN
+	 * for the PF is specified, then the setting of
+	 * promiscuous mode on that PF shall result in the
+	 * PF receiving all host bound traffic with matching
+	 * outer VLAN.
+	 * # A VF shall can be set in the promiscuous mode.
+	 * In the promiscuous mode, the VF does not receive any
+	 * traffic unless a unique outer VLAN for the
+	 * VF is specified. If a unique outer VLAN
+	 * for the VF is specified, then the setting of
+	 * promiscuous mode on that VF shall result in the
+	 * VF receiving all host bound traffic with the
+	 * matching outer VLAN.
+	 * # The HWRM shall allow the setting of promiscuous
+	 * mode on a function independently from the
+	 * promiscuous mode settings on other functions.
 	 */
-		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_INPROGRESS_REG_ADDR_SPACE_BAR0	UINT32_C(0x2)
+	#define HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_PROMISCUOUS	UINT32_C(0x10)
 	/*
-	 * If value is 3, this register is located in second BAR address
-	 * space. Drivers have to map appropriate window to access this
-	 * register.
+	 * If this flag is set, the corresponding RX
+	 * filters shall be set up to cover multicast/broadcast
+	 * filters for the outermost Layer 2 destination MAC
+	 * address field.
 	 */
-		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_INPROGRESS_REG_ADDR_SPACE_BAR1	UINT32_C(0x3)
-		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_INPROGRESS_REG_ADDR_SPACE_LAST	HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_INPROGRESS_REG_ADDR_SPACE_BAR1
-	/* Upper 30bits of the register address. */
-	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_INPROGRESS_REG_ADDR_MASK	UINT32_C(0xfffffffc)
-	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_INPROGRESS_REG_ADDR_SFT	2
-	/* This field indicates the mask value for reset_inprogress_reg. */
-	uint32_t	reset_inprogress_reg_mask;
-	uint8_t	unused_0[3];
+	#define HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_OUTERMOST	UINT32_C(0x20)
 	/*
-	 * Array of registers and value count to reset the Chip
-	 * Each array count has reset_reg, reset_reg_val, delay_after_reset
-	 * in TLV format. Depending upon Chip type, number of reset registers
-	 * will vary. Drivers have to write reset_reg_val in the reset_reg
-	 * location in the same sequence in order to recover from a fatal
-	 * error.
+	 * If this flag is set, the corresponding RX
+	 * filters shall be set up to cover multicast/broadcast
+	 * filters for the VLAN-tagged packets that match the
+	 * TPID and VID fields of VLAN tags in the VLAN tag
+	 * table specified in this command.
 	 */
-	uint8_t	reg_array_cnt;
+	#define HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_VLANONLY		UINT32_C(0x40)
 	/*
-	 * Reset register.
-	 * Lower 2 bits indicates address space location and upper 30 bits
-	 * indicates actual address.
-	 * A value of 0xFFFF-FFFF indicates this register does not exist.
+	 * If this flag is set, the corresponding RX
+	 * filters shall be set up to cover multicast/broadcast
+	 * filters for non-VLAN tagged packets and VLAN-tagged
+	 * packets that match the TPID and VID fields of VLAN
+	 * tags in the VLAN tag table specified in this command.
 	 */
-	uint32_t	reset_reg[16];
-	/* Lower 2 bits indicates address space location. */
-	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_REG_ADDR_SPACE_MASK	UINT32_C(0x3)
-	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_REG_ADDR_SPACE_SFT	0
+	#define HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_VLAN_NONVLAN	UINT32_C(0x80)
+	/*
+	 * If this flag is set, the corresponding RX
+	 * filters shall be set up to cover multicast/broadcast
+	 * filters for non-VLAN tagged packets and VLAN-tagged
+	 * packets matching any VLAN tag.
+	 *
+	 * If this flag is set, then the HWRM shall ignore
+	 * VLAN tags specified in vlan_tag_tbl.
+	 *
+	 * If none of vlanonly, vlan_nonvlan, and anyvlan_nonvlan
+	 * flags is set, then the HWRM shall ignore
+	 * VLAN tags specified in vlan_tag_tbl.
+	 *
+	 * The HWRM client shall set at most one flag out of
+	 * vlanonly, vlan_nonvlan, and anyvlan_nonvlan.
+	 */
+	#define HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_ANYVLAN_NONVLAN	UINT32_C(0x100)
+	/* This is the address for mcast address tbl. */
+	uint64_t	mc_tbl_addr;
+	/*
+	 * This value indicates how many entries in mc_tbl are valid.
+	 * Each entry is 6 bytes.
+	 */
+	uint32_t	num_mc_entries;
+	uint8_t	unused_0[4];
 	/*
-	 * If value is 0, this register is located in PCIe config space.
-	 * Drivers have to map appropriate window to access this
-	 * register.
+	 * This is the address for VLAN tag table.
+	 * Each VLAN entry in the table is 4 bytes of a VLAN tag
+	 * including TPID, PCP, DEI, and VID fields in network byte
+	 * order.
 	 */
-		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_REG_ADDR_SPACE_PCIE_CFG  UINT32_C(0x0)
+	uint64_t	vlan_tag_tbl_addr;
 	/*
-	 * If value is 1, this register is located in GRC address space.
-	 * Drivers have to map appropriate window to access this
-	 * register.
+	 * This value indicates how many entries in vlan_tag_tbl are
+	 * valid. Each entry is 4 bytes.
 	 */
-		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_REG_ADDR_SPACE_GRC	UINT32_C(0x1)
+	uint32_t	num_vlan_tags;
+	uint8_t	unused_1[4];
+} hwrm_cfa_l2_set_rx_mask_input_t, *phwrm_cfa_l2_set_rx_mask_input_t;
+
+/* hwrm_cfa_l2_set_rx_mask_output (size:128b/16B) */
+
+typedef struct hwrm_cfa_l2_set_rx_mask_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
 	/*
-	 * If value is 2, this register is located in first BAR address
-	 * space. Drivers have to map appropriate window to access this
-	 * register.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_REG_ADDR_SPACE_BAR0	UINT32_C(0x2)
+	uint8_t	valid;
+} hwrm_cfa_l2_set_rx_mask_output_t, *phwrm_cfa_l2_set_rx_mask_output_t;
+
+/* hwrm_cfa_l2_set_rx_mask_cmd_err (size:64b/8B) */
+
+typedef struct hwrm_cfa_l2_set_rx_mask_cmd_err {
 	/*
-	 * If value is 3, this register is located in second BAR address
-	 * space. Drivers have to map appropriate window to access this
-	 * register.
+	 * command specific error codes that goes to
+	 * the cmd_err field in Common HWRM Error Response.
 	 */
-		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_REG_ADDR_SPACE_BAR1	UINT32_C(0x3)
-		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_REG_ADDR_SPACE_LAST	HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_REG_ADDR_SPACE_BAR1
-	/* Upper 30bits of the register address. */
-	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_REG_ADDR_MASK	UINT32_C(0xfffffffc)
-	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_RESET_REG_ADDR_SFT	2
-	/* Value to be written in reset_reg to reset the controller. */
-	uint32_t	reset_reg_val[16];
+	uint8_t	code;
+	/* Unknown error */
+	#define HWRM_CFA_L2_SET_RX_MASK_CMD_ERR_CODE_UNKNOWN			UINT32_C(0x0)
+	/* Unable to complete operation due to conflict with Ntuple Filter */
+	#define HWRM_CFA_L2_SET_RX_MASK_CMD_ERR_CODE_NTUPLE_FILTER_CONFLICT_ERR UINT32_C(0x1)
+	#define HWRM_CFA_L2_SET_RX_MASK_CMD_ERR_CODE_LAST			HWRM_CFA_L2_SET_RX_MASK_CMD_ERR_CODE_NTUPLE_FILTER_CONFLICT_ERR
+	uint8_t	unused_0[7];
+} hwrm_cfa_l2_set_rx_mask_cmd_err_t, *phwrm_cfa_l2_set_rx_mask_cmd_err_t;
+
+/*******************************
+ * hwrm_cfa_vlan_antispoof_cfg *
+ *******************************/
+
+
+/* hwrm_cfa_vlan_antispoof_cfg_input (size:256b/32B) */
+
+typedef struct hwrm_cfa_vlan_antispoof_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * This value is in units of 1msec.
-	 * Typical value would be 10 to indicate 10msec.
-	 * Some of the operations like Core reset require delay before
-	 * accessing PCIE MMIO register space.
-	 * If this value is non-zero, drivers have to wait for
-	 * this much time after writing reset_reg_val in reset_reg.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint8_t	delay_after_reset[16];
+	uint16_t	cmpl_ring;
 	/*
-	 * Error recovery counter.
-	 * Lower 2 bits indicates address space location and upper 30 bits
-	 * indicates actual address.
-	 * A value of 0xFFFF-FFFF indicates this register does not exist.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint32_t	err_recovery_cnt_reg;
-	/* Lower 2 bits indicates address space location. */
-	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_ERR_RECOVERY_CNT_REG_ADDR_SPACE_MASK	UINT32_C(0x3)
-	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_ERR_RECOVERY_CNT_REG_ADDR_SPACE_SFT	0
+	uint16_t	seq_id;
 	/*
-	 * If value is 0, this register is located in PCIe config space.
-	 * Drivers have to map appropriate window to access this
-	 * register.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_ERR_RECOVERY_CNT_REG_ADDR_SPACE_PCIE_CFG  UINT32_C(0x0)
+	uint16_t	target_id;
 	/*
-	 * If value is 1, this register is located in GRC address space.
-	 * Drivers have to map appropriate window to access this
-	 * register.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_ERR_RECOVERY_CNT_REG_ADDR_SPACE_GRC	UINT32_C(0x1)
+	uint64_t	resp_addr;
 	/*
-	 * If value is 2, this register is located in first BAR address
-	 * space. Drivers have to map appropriate window to access this
-	 * register.
+	 * Function ID of the function that is being configured.
+	 * Only valid for a VF FID configured by the PF.
 	 */
-		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_ERR_RECOVERY_CNT_REG_ADDR_SPACE_BAR0	UINT32_C(0x2)
+	uint16_t	fid;
+	uint8_t	unused_0[2];
+	/* Number of VLAN entries in the vlan_tag_mask_tbl. */
+	uint32_t	num_vlan_entries;
 	/*
-	 * If value is 3, this register is located in second BAR address
-	 * space. Drivers have to map appropriate window to access this
-	 * register.
+	 * The vlan_tag_mask_tbl_addr is the DMA address of the VLAN
+	 * antispoof table. Each table entry contains the 16-bit TPID
+	 * (0x8100 or 0x88a8 only), 16-bit VLAN ID, and a 16-bit mask,
+	 * all in network order to match hwrm_cfa_l2_set_rx_mask.
+	 * For an individual VLAN entry, the mask value should be 0xfff
+	 * for the 12-bit VLAN ID.
 	 */
-		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_ERR_RECOVERY_CNT_REG_ADDR_SPACE_BAR1	UINT32_C(0x3)
-		#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_ERR_RECOVERY_CNT_REG_ADDR_SPACE_LAST	HWRM_ERROR_RECOVERY_QCFG_OUTPUT_ERR_RECOVERY_CNT_REG_ADDR_SPACE_BAR1
-	/* Upper 30bits of the register address. */
-	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_ERR_RECOVERY_CNT_REG_ADDR_MASK	UINT32_C(0xfffffffc)
-	#define HWRM_ERROR_RECOVERY_QCFG_OUTPUT_ERR_RECOVERY_CNT_REG_ADDR_SFT	2
-	uint8_t	unused_1[3];
+	uint64_t	vlan_tag_mask_tbl_addr;
+} hwrm_cfa_vlan_antispoof_cfg_input_t, *phwrm_cfa_vlan_antispoof_cfg_input_t;
+
+/* hwrm_cfa_vlan_antispoof_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_cfa_vlan_antispoof_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
 	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field
-	 * is written last.
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_error_recovery_qcfg_output_t, *phwrm_error_recovery_qcfg_output_t;
+} hwrm_cfa_vlan_antispoof_cfg_output_t, *phwrm_cfa_vlan_antispoof_cfg_output_t;
 
-/***************************
- * hwrm_func_echo_response *
- ***************************/
+/********************************
+ * hwrm_cfa_vlan_antispoof_qcfg *
+ ********************************/
 
 
-/* hwrm_func_echo_response_input (size:192b/24B) */
+/* hwrm_cfa_vlan_antispoof_qcfg_input (size:256b/32B) */
 
-typedef struct hwrm_func_echo_response_input {
+typedef struct hwrm_cfa_vlan_antispoof_qcfg_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -16911,13 +45032,31 @@ typedef struct hwrm_func_echo_response_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	event_data1;
-	uint32_t	event_data2;
-} hwrm_func_echo_response_input_t, *phwrm_func_echo_response_input_t;
+	/*
+	 * Function ID of the function that is being queried.
+	 * Only valid for a VF FID queried by the PF.
+	 */
+	uint16_t	fid;
+	uint8_t	unused_0[2];
+	/*
+	 * Maximum number of VLAN entries the firmware is allowed to DMA
+	 * to vlan_tag_mask_tbl.
+	 */
+	uint32_t	max_vlan_entries;
+	/*
+	 * The vlan_tag_mask_tbl_addr is the DMA address of the VLAN
+	 * antispoof table to which firmware will DMA to. Each table
+	 * entry will contain the 16-bit TPID (0x8100 or 0x88a8 only),
+	 * 16-bit VLAN ID, and a 16-bit mask, all in network order to
+	 * match hwrm_cfa_l2_set_rx_mask. For an individual VLAN entry,
+	 * the mask value should be 0xfff for the 12-bit VLAN ID.
+	 */
+	uint64_t	vlan_tag_mask_tbl_addr;
+} hwrm_cfa_vlan_antispoof_qcfg_input_t, *phwrm_cfa_vlan_antispoof_qcfg_input_t;
 
-/* hwrm_func_echo_response_output (size:128b/16B) */
+/* hwrm_cfa_vlan_antispoof_qcfg_output (size:128b/16B) */
 
-typedef struct hwrm_func_echo_response_output {
+typedef struct hwrm_cfa_vlan_antispoof_qcfg_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -16926,25 +45065,28 @@ typedef struct hwrm_func_echo_response_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	/* Number of valid entries DMAd by firmware to vlan_tag_mask_tbl. */
+	uint32_t	num_vlan_entries;
+	uint8_t	unused_0[3];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_func_echo_response_output_t, *phwrm_func_echo_response_output_t;
+} hwrm_cfa_vlan_antispoof_qcfg_output_t, *phwrm_cfa_vlan_antispoof_qcfg_output_t;
 
-/**************************
- * hwrm_func_ptp_pin_qcfg *
- **************************/
+/********************************
+ * hwrm_cfa_tunnel_filter_alloc *
+ ********************************/
 
 
-/* hwrm_func_ptp_pin_qcfg_input (size:192b/24B) */
+/* hwrm_cfa_tunnel_filter_alloc_input (size:704b/88B) */
 
-typedef struct hwrm_func_ptp_pin_qcfg_input {
+typedef struct hwrm_cfa_tunnel_filter_alloc_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -16973,12 +45115,202 @@ typedef struct hwrm_func_ptp_pin_qcfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint8_t	unused_0[8];
-} hwrm_func_ptp_pin_qcfg_input_t, *phwrm_func_ptp_pin_qcfg_input_t;
+	uint32_t	flags;
+	/*
+	 * Setting of this flag indicates the applicability to the loopback
+	 * path.
+	 */
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_FLAGS_LOOPBACK	UINT32_C(0x1)
+	uint32_t	enables;
+	/*
+	 * This bit must be '1' for the l2_filter_id field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_ENABLES_L2_FILTER_ID	UINT32_C(0x1)
+	/*
+	 * This bit must be '1' for the l2_addr field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR		UINT32_C(0x2)
+	/*
+	 * This bit must be '1' for the l2_ivlan field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_ENABLES_L2_IVLAN	UINT32_C(0x4)
+	/*
+	 * This bit must be '1' for the l3_addr field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_ENABLES_L3_ADDR		UINT32_C(0x8)
+	/*
+	 * This bit must be '1' for the l3_addr_type field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_ENABLES_L3_ADDR_TYPE	UINT32_C(0x10)
+	/*
+	 * This bit must be '1' for the t_l3_addr_type field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_ENABLES_T_L3_ADDR_TYPE	UINT32_C(0x20)
+	/*
+	 * This bit must be '1' for the t_l3_addr field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_ENABLES_T_L3_ADDR	UINT32_C(0x40)
+	/*
+	 * This bit must be '1' for the tunnel_type field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_ENABLES_TUNNEL_TYPE	UINT32_C(0x80)
+	/*
+	 * This bit must be '1' for the vni field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_ENABLES_VNI		UINT32_C(0x100)
+	/*
+	 * This bit must be '1' for the dst_vnic_id field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_ENABLES_DST_VNIC_ID	UINT32_C(0x200)
+	/*
+	 * This bit must be '1' for the mirror_vnic_id field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_ENABLES_MIRROR_VNIC_ID	UINT32_C(0x400)
+	/*
+	 * This value identifies a set of CFA data structures used for an L2
+	 * context.
+	 */
+	uint64_t	l2_filter_id;
+	/*
+	 * This value sets the match value for the inner L2
+	 * MAC address.
+	 * Destination MAC address for RX path.
+	 * Source MAC address for TX path.
+	 */
+	uint8_t	l2_addr[6];
+	/*
+	 * This value sets VLAN ID value for inner VLAN.
+	 * Only 12-bits of VLAN ID are used in setting the filter.
+	 */
+	uint16_t	l2_ivlan;
+	/*
+	 * The value of inner destination IP address to be used in filtering.
+	 * For IPv4, first four bytes represent the IP address.
+	 */
+	uint32_t	l3_addr[4];
+	/*
+	 * The value of tunnel destination IP address to be used in filtering.
+	 * For IPv4, first four bytes represent the IP address.
+	 */
+	uint32_t	t_l3_addr[4];
+	/*
+	 * This value indicates the type of inner IP address.
+	 * 4 - IPv4
+	 * 6 - IPv6
+	 * All others are invalid.
+	 */
+	uint8_t	l3_addr_type;
+	/*
+	 * This value indicates the type of tunnel IP address.
+	 * 4 - IPv4
+	 * 6 - IPv6
+	 * All others are invalid.
+	 */
+	uint8_t	t_l3_addr_type;
+	/* Tunnel Type. */
+	uint8_t	tunnel_type;
+	/* Non-tunnel */
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_TYPE_NONTUNNEL	UINT32_C(0x0)
+	/* Virtual eXtensible Local Area Network (VXLAN) */
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_TYPE_VXLAN	UINT32_C(0x1)
+	/* Network Virtualization Generic Routing Encapsulation (NVGRE) */
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_TYPE_NVGRE	UINT32_C(0x2)
+	/* Generic Routing Encapsulation (GRE) inside Ethernet payload */
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_TYPE_L2GRE	UINT32_C(0x3)
+	/* IP in IP */
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_TYPE_IPIP	UINT32_C(0x4)
+	/* Generic Network Virtualization Encapsulation (Geneve) */
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_TYPE_GENEVE	UINT32_C(0x5)
+	/* Multi-Protocol Label Switching (MPLS) */
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_TYPE_MPLS	UINT32_C(0x6)
+	/* Stateless Transport Tunnel (STT) */
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_TYPE_STT	UINT32_C(0x7)
+	/* Generic Routing Encapsulation (GRE) inside IP datagram payload */
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_TYPE_IPGRE	UINT32_C(0x8)
+	/* IPV4 over virtual eXtensible Local Area Network (IPV4oVXLAN) */
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_V4	UINT32_C(0x9)
+	/*
+	 * Enhance Generic Routing Encapsulation (GRE version 1) inside IP
+	 * datagram payload
+	 */
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_TYPE_IPGRE_V1	UINT32_C(0xa)
+	/* Use fixed layer 2 ether type of 0xFFFF */
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_TYPE_L2_ETYPE	UINT32_C(0xb)
+	/*
+	 * IPV6 over virtual eXtensible Local Area Network with GPE header
+	 * (IPV6oVXLANGPE)
+	 */
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_GPE_V6 UINT32_C(0xc)
+	/* Generic Protocol Extension for VXLAN (VXLAN-GPE) */
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_GPE	UINT32_C(0x10)
+	/* Any tunneled traffic */
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_TYPE_ANYTUNNEL	UINT32_C(0xff)
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_TYPE_LAST	HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_TYPE_ANYTUNNEL
+	/*
+	 * tunnel_flags allows the user to indicate the tunnel tag detection
+	 * for the tunnel type specified in tunnel_type.
+	 */
+	uint8_t	tunnel_flags;
+	/*
+	 * If the tunnel_type is geneve, then this bit indicates if we
+	 * need to match the geneve OAM packet.
+	 * If the tunnel_type is nvgre or gre, then this bit indicates if
+	 * we need to detect checksum present bit in geneve header.
+	 * If the tunnel_type is mpls, then this bit indicates if we need
+	 * to match mpls packet with explicit IPV4/IPV6 null header.
+	 */
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_FLAGS_TUN_FLAGS_OAM_CHECKSUM_EXPLHDR	UINT32_C(0x1)
+	/*
+	 * If the tunnel_type is geneve, then this bit indicates if we
+	 * need to detect the critical option bit set in the oam packet.
+	 * If the tunnel_type is nvgre or gre, then this bit indicates
+	 * if we need to match nvgre packets with key present bit set in
+	 * gre header.
+	 * If the tunnel_type is mpls, then this bit indicates if we
+	 * need to match mpls packet with S bit from inner/second label.
+	 */
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_FLAGS_TUN_FLAGS_CRITICAL_OPT_S1	UINT32_C(0x2)
+	/*
+	 * If the tunnel_type is geneve, then this bit indicates if we
+	 * need to match geneve packet with extended header bit set in
+	 * geneve header.
+	 * If the tunnel_type is nvgre or gre, then this bit indicates
+	 * if we need to match nvgre packets with sequence number
+	 * present bit set in gre header.
+	 * If the tunnel_type is mpls, then this bit indicates if we
+	 * need to match mpls packet with S bit from out/first label.
+	 */
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_FLAGS_TUN_FLAGS_EXTHDR_SEQNUM_S0	UINT32_C(0x4)
+	/*
+	 * Virtual Network Identifier (VNI). Only valid with
+	 * tunnel_types VXLAN, NVGRE, and Geneve.
+	 * Only lower 24-bits of VNI field are used
+	 * in setting up the filter.
+	 */
+	uint32_t	vni;
+	/* Logical VNIC ID of the destination VNIC. */
+	uint32_t	dst_vnic_id;
+	/*
+	 * Logical VNIC ID of the VNIC where traffic is
+	 * mirrored.
+	 */
+	uint32_t	mirror_vnic_id;
+} hwrm_cfa_tunnel_filter_alloc_input_t, *phwrm_cfa_tunnel_filter_alloc_input_t;
 
-/* hwrm_func_ptp_pin_qcfg_output (size:128b/16B) */
+/* hwrm_cfa_tunnel_filter_alloc_output (size:192b/24B) */
 
-typedef struct hwrm_func_ptp_pin_qcfg_output {
+typedef struct hwrm_cfa_tunnel_filter_alloc_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -16987,104 +45319,59 @@ typedef struct hwrm_func_ptp_pin_qcfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
+	/* This value is an opaque id into CFA data structures. */
+	uint64_t	tunnel_filter_id;
 	/*
-	 * The number of TSIO pins that are configured on this board
-	 * Up to 4 pins can be returned in the response.
-	 */
-	uint8_t	num_pins;
-	/* Pin state */
-	uint8_t	state;
-	/*
-	 * When this bit is '1', TSIO pin 0 is enabled.
-	 * When this bit is '0', TSIO pin 0 is disabled.
-	 */
-	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_STATE_PIN0_ENABLED	UINT32_C(0x1)
-	/*
-	 * When this bit is '1', TSIO pin 1 is enabled.
-	 * When this bit is '0', TSIO pin 1 is disabled.
+	 * The flow id value in bit 0-29 is the actual ID of the flow
+	 * associated with this filter and it shall be used to match
+	 * and associate the flow identifier returned in completion
+	 * records. A value of 0xFFFFFFFF in the 32-bit flow_id field
+	 * shall indicate no valid flow id.
 	 */
-	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_STATE_PIN1_ENABLED	UINT32_C(0x2)
+	uint32_t	flow_id;
+	/* Indicate the flow id value. */
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_OUTPUT_FLOW_ID_VALUE_MASK UINT32_C(0x3fffffff)
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_OUTPUT_FLOW_ID_VALUE_SFT 0
+	/* Indicate type of the flow. */
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE	UINT32_C(0x40000000)
 	/*
-	 * When this bit is '1', TSIO pin 2 is enabled.
-	 * When this bit is '0', TSIO pin 2 is disabled.
+	 * If this bit set to 0, then it indicates that the flow is
+	 * internal flow.
 	 */
-	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_STATE_PIN2_ENABLED	UINT32_C(0x4)
+		#define HWRM_CFA_TUNNEL_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE_INT	(UINT32_C(0x0) << 30)
 	/*
-	 * When this bit is '1', TSIO pin 3 is enabled.
-	 * When this bit is '0', TSIO pin 3 is disabled.
+	 * If this bit is set to 1, then it indicates that the flow is
+	 * external flow.
 	 */
-	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_STATE_PIN3_ENABLED	UINT32_C(0x8)
-	/* Type of function for Pin #0. */
-	uint8_t	pin0_usage;
-	/* No function is configured. */
-	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN0_USAGE_NONE	UINT32_C(0x0)
-	/* PPS IN is configured. */
-	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN0_USAGE_PPS_IN   UINT32_C(0x1)
-	/* PPS OUT is configured. */
-	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN0_USAGE_PPS_OUT  UINT32_C(0x2)
-	/* SYNC IN is configured. */
-	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN0_USAGE_SYNC_IN  UINT32_C(0x3)
-	/* SYNC OUT is configured. */
-	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN0_USAGE_SYNC_OUT UINT32_C(0x4)
-	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN0_USAGE_LAST	HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN0_USAGE_SYNC_OUT
-	/* Type of function for Pin #1. */
-	uint8_t	pin1_usage;
-	/* No function is configured. */
-	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN1_USAGE_NONE	UINT32_C(0x0)
-	/* PPS IN is configured. */
-	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN1_USAGE_PPS_IN   UINT32_C(0x1)
-	/* PPS OUT is configured. */
-	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN1_USAGE_PPS_OUT  UINT32_C(0x2)
-	/* SYNC IN is configured. */
-	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN1_USAGE_SYNC_IN  UINT32_C(0x3)
-	/* SYNC OUT is configured. */
-	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN1_USAGE_SYNC_OUT UINT32_C(0x4)
-	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN1_USAGE_LAST	HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN1_USAGE_SYNC_OUT
-	/* Type of function for Pin #2. */
-	uint8_t	pin2_usage;
-	/* No function is configured. */
-	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN2_USAGE_NONE	UINT32_C(0x0)
-	/* PPS IN is configured. */
-	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN2_USAGE_PPS_IN   UINT32_C(0x1)
-	/* PPS OUT is configured. */
-	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN2_USAGE_PPS_OUT  UINT32_C(0x2)
-	/* SYNC IN is configured. */
-	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN2_USAGE_SYNC_IN  UINT32_C(0x3)
-	/* SYNC OUT is configured. */
-	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN2_USAGE_SYNC_OUT UINT32_C(0x4)
-	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN2_USAGE_LAST	HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN2_USAGE_SYNC_OUT
-	/* Type of function for Pin #3. */
-	uint8_t	pin3_usage;
-	/* No function is configured. */
-	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN3_USAGE_NONE	UINT32_C(0x0)
-	/* PPS IN is configured. */
-	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN3_USAGE_PPS_IN   UINT32_C(0x1)
-	/* PPS OUT is configured. */
-	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN3_USAGE_PPS_OUT  UINT32_C(0x2)
-	/* SYNC IN is configured. */
-	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN3_USAGE_SYNC_IN  UINT32_C(0x3)
-	/* SYNC OUT is configured. */
-	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN3_USAGE_SYNC_OUT UINT32_C(0x4)
-	#define HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN3_USAGE_LAST	HWRM_FUNC_PTP_PIN_QCFG_OUTPUT_PIN3_USAGE_SYNC_OUT
-	uint8_t	unused_0;
+		#define HWRM_CFA_TUNNEL_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE_EXT	(UINT32_C(0x1) << 30)
+		#define HWRM_CFA_TUNNEL_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE_LAST  HWRM_CFA_TUNNEL_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE_EXT
+	/* Indicate the flow direction. */
+	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR	UINT32_C(0x80000000)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_CFA_TUNNEL_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR_RX	(UINT32_C(0x0) << 31)
+	/* If this bit is set to 1, then it indicates that tx flow. */
+		#define HWRM_CFA_TUNNEL_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR_TX	(UINT32_C(0x1) << 31)
+		#define HWRM_CFA_TUNNEL_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR_LAST   HWRM_CFA_TUNNEL_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR_TX
+	uint8_t	unused_0[3];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_func_ptp_pin_qcfg_output_t, *phwrm_func_ptp_pin_qcfg_output_t;
+} hwrm_cfa_tunnel_filter_alloc_output_t, *phwrm_cfa_tunnel_filter_alloc_output_t;
 
-/*************************
- * hwrm_func_ptp_pin_cfg *
- *************************/
+/*******************************
+ * hwrm_cfa_tunnel_filter_free *
+ *******************************/
 
 
-/* hwrm_func_ptp_pin_cfg_input (size:256b/32B) */
+/* hwrm_cfa_tunnel_filter_free_input (size:192b/24B) */
 
-typedef struct hwrm_func_ptp_pin_cfg_input {
+typedef struct hwrm_cfa_tunnel_filter_free_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -17113,133 +45400,123 @@ typedef struct hwrm_func_ptp_pin_cfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	enables;
+	/* This value is an opaque id into CFA data structures. */
+	uint64_t	tunnel_filter_id;
+} hwrm_cfa_tunnel_filter_free_input_t, *phwrm_cfa_tunnel_filter_free_input_t;
+
+/* hwrm_cfa_tunnel_filter_free_output (size:128b/16B) */
+
+typedef struct hwrm_cfa_tunnel_filter_free_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
 	/*
-	 * This bit must be '1' for the pin0_state field to be
-	 * configured.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_ENABLES_PIN0_STATE	UINT32_C(0x1)
+	uint8_t	valid;
+} hwrm_cfa_tunnel_filter_free_output_t, *phwrm_cfa_tunnel_filter_free_output_t;
+
+/***************************************
+ * hwrm_cfa_redirect_tunnel_type_alloc *
+ ***************************************/
+
+
+/* hwrm_cfa_redirect_tunnel_type_alloc_input (size:192b/24B) */
+
+typedef struct hwrm_cfa_redirect_tunnel_type_alloc_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * This bit must be '1' for the pin0_usage field to be
-	 * configured.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_ENABLES_PIN0_USAGE	UINT32_C(0x2)
+	uint16_t	cmpl_ring;
 	/*
-	 * This bit must be '1' for the pin1_state field to be
-	 * configured.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_ENABLES_PIN1_STATE	UINT32_C(0x4)
+	uint16_t	seq_id;
 	/*
-	 * This bit must be '1' for the pin1_usage field to be
-	 * configured.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_ENABLES_PIN1_USAGE	UINT32_C(0x8)
+	uint16_t	target_id;
 	/*
-	 * This bit must be '1' for the pin2_state field to be
-	 * configured.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_ENABLES_PIN2_STATE	UINT32_C(0x10)
+	uint64_t	resp_addr;
+	/* The destination function id, to whom the traffic is redirected. */
+	uint16_t	dest_fid;
+	/* Tunnel Type. */
+	uint8_t	tunnel_type;
+	/* Non-tunnel */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_TUNNEL_TYPE_NONTUNNEL	UINT32_C(0x0)
+	/* Virtual eXtensible Local Area Network (VXLAN) */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_TUNNEL_TYPE_VXLAN	UINT32_C(0x1)
+	/* Network Virtualization Generic Routing Encapsulation (NVGRE) */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_TUNNEL_TYPE_NVGRE	UINT32_C(0x2)
+	/* Generic Routing Encapsulation (GRE) inside Ethernet payload */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_TUNNEL_TYPE_L2GRE	UINT32_C(0x3)
+	/* IP in IP */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_TUNNEL_TYPE_IPIP	UINT32_C(0x4)
+	/* Generic Network Virtualization Encapsulation (Geneve) */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_TUNNEL_TYPE_GENEVE	UINT32_C(0x5)
+	/* Multi-Protocol Label Switching (MPLS) */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_TUNNEL_TYPE_MPLS	UINT32_C(0x6)
+	/* Stateless Transport Tunnel (STT) */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_TUNNEL_TYPE_STT	UINT32_C(0x7)
+	/* Generic Routing Encapsulation (GRE) inside IP datagram payload */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_TUNNEL_TYPE_IPGRE	UINT32_C(0x8)
+	/* IPV4 over virtual eXtensible Local Area Network (IPV4oVXLAN) */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_V4	UINT32_C(0x9)
 	/*
-	 * This bit must be '1' for the pin2_usage field to be
-	 * configured.
+	 * Enhance Generic Routing Encapsulation (GRE version 1) inside IP
+	 * datagram payload
 	 */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_ENABLES_PIN2_USAGE	UINT32_C(0x20)
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_TUNNEL_TYPE_IPGRE_V1	UINT32_C(0xa)
+	/* Use fixed layer 2 ether type of 0xFFFF */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_TUNNEL_TYPE_L2_ETYPE	UINT32_C(0xb)
 	/*
-	 * This bit must be '1' for the pin3_state field to be
-	 * configured.
+	 * IPV6 over virtual eXtensible Local Area Network with GPE header
+	 * (IPV6oVXLANGPE)
 	 */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_ENABLES_PIN3_STATE	UINT32_C(0x40)
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_GPE_V6 UINT32_C(0xc)
+	/* Generic Protocol Extension for VXLAN (VXLAN-GPE) */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_GPE	UINT32_C(0x10)
+	/* Any tunneled traffic */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_TUNNEL_TYPE_ANYTUNNEL	UINT32_C(0xff)
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_TUNNEL_TYPE_LAST	HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_TUNNEL_TYPE_ANYTUNNEL
+	/* Tunnel alloc flags. */
+	uint8_t	flags;
 	/*
-	 * This bit must be '1' for the pin3_usage field to be
-	 * configured.
+	 * Setting of this flag indicates modify existing redirect tunnel
+	 * to new destination function ID.
 	 */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_ENABLES_PIN3_USAGE	UINT32_C(0x80)
-	/* Enable or disable functionality of Pin #0. */
-	uint8_t	pin0_state;
-	/* Disabled */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN0_STATE_DISABLED UINT32_C(0x0)
-	/* Enabled */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN0_STATE_ENABLED  UINT32_C(0x1)
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN0_STATE_LAST	HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN0_STATE_ENABLED
-	/* Configure function for TSIO pin#0. */
-	uint8_t	pin0_usage;
-	/* No function is configured. */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN0_USAGE_NONE	UINT32_C(0x0)
-	/* PPS IN is configured. */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN0_USAGE_PPS_IN   UINT32_C(0x1)
-	/* PPS OUT is configured. */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN0_USAGE_PPS_OUT  UINT32_C(0x2)
-	/* SYNC IN is configured. */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN0_USAGE_SYNC_IN  UINT32_C(0x3)
-	/* SYNC OUT is configured. */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN0_USAGE_SYNC_OUT UINT32_C(0x4)
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN0_USAGE_LAST	HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN0_USAGE_SYNC_OUT
-	/* Enable or disable functionality of Pin #1. */
-	uint8_t	pin1_state;
-	/* Disabled */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN1_STATE_DISABLED UINT32_C(0x0)
-	/* Enabled */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN1_STATE_ENABLED  UINT32_C(0x1)
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN1_STATE_LAST	HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN1_STATE_ENABLED
-	/* Configure function for TSIO pin#1. */
-	uint8_t	pin1_usage;
-	/* No function is configured. */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN1_USAGE_NONE	UINT32_C(0x0)
-	/* PPS IN is configured. */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN1_USAGE_PPS_IN   UINT32_C(0x1)
-	/* PPS OUT is configured. */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN1_USAGE_PPS_OUT  UINT32_C(0x2)
-	/* SYNC IN is configured. */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN1_USAGE_SYNC_IN  UINT32_C(0x3)
-	/* SYNC OUT is configured. */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN1_USAGE_SYNC_OUT UINT32_C(0x4)
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN1_USAGE_LAST	HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN1_USAGE_SYNC_OUT
-	/* Enable or disable functionality of Pin #2. */
-	uint8_t	pin2_state;
-	/* Disabled */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN2_STATE_DISABLED UINT32_C(0x0)
-	/* Enabled */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN2_STATE_ENABLED  UINT32_C(0x1)
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN2_STATE_LAST	HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN2_STATE_ENABLED
-	/* Configure function for TSIO pin#2. */
-	uint8_t	pin2_usage;
-	/* No function is configured. */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN2_USAGE_NONE	UINT32_C(0x0)
-	/* PPS IN is configured. */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN2_USAGE_PPS_IN   UINT32_C(0x1)
-	/* PPS OUT is configured. */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN2_USAGE_PPS_OUT  UINT32_C(0x2)
-	/* SYNC IN is configured. */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN2_USAGE_SYNC_IN  UINT32_C(0x3)
-	/* SYNC OUT is configured. */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN2_USAGE_SYNC_OUT UINT32_C(0x4)
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN2_USAGE_LAST	HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN2_USAGE_SYNC_OUT
-	/* Enable or disable functionality of Pin #3. */
-	uint8_t	pin3_state;
-	/* Disabled */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN3_STATE_DISABLED UINT32_C(0x0)
-	/* Enabled */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN3_STATE_ENABLED  UINT32_C(0x1)
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN3_STATE_LAST	HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN3_STATE_ENABLED
-	/* Configure function for TSIO pin#3. */
-	uint8_t	pin3_usage;
-	/* No function is configured. */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN3_USAGE_NONE	UINT32_C(0x0)
-	/* PPS IN is configured. */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN3_USAGE_PPS_IN   UINT32_C(0x1)
-	/* PPS OUT is configured. */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN3_USAGE_PPS_OUT  UINT32_C(0x2)
-	/* SYNC IN is configured. */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN3_USAGE_SYNC_IN  UINT32_C(0x3)
-	/* SYNC OUT is configured. */
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN3_USAGE_SYNC_OUT UINT32_C(0x4)
-	#define HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN3_USAGE_LAST	HWRM_FUNC_PTP_PIN_CFG_INPUT_PIN3_USAGE_SYNC_OUT
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_FLAGS_MODIFY_DST	UINT32_C(0x1)
 	uint8_t	unused_0[4];
-} hwrm_func_ptp_pin_cfg_input_t, *phwrm_func_ptp_pin_cfg_input_t;
+} hwrm_cfa_redirect_tunnel_type_alloc_input_t, *phwrm_cfa_redirect_tunnel_type_alloc_input_t;
 
-/* hwrm_func_ptp_pin_cfg_output (size:128b/16B) */
+/* hwrm_cfa_redirect_tunnel_type_alloc_output (size:128b/16B) */
 
-typedef struct hwrm_func_ptp_pin_cfg_output {
+typedef struct hwrm_cfa_redirect_tunnel_type_alloc_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -17251,22 +45528,23 @@ typedef struct hwrm_func_ptp_pin_cfg_output {
 	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_func_ptp_pin_cfg_output_t, *phwrm_func_ptp_pin_cfg_output_t;
+} hwrm_cfa_redirect_tunnel_type_alloc_output_t, *phwrm_cfa_redirect_tunnel_type_alloc_output_t;
 
-/*********************
- * hwrm_func_ptp_cfg *
- *********************/
+/**************************************
+ * hwrm_cfa_redirect_tunnel_type_free *
+ **************************************/
 
 
-/* hwrm_func_ptp_cfg_input (size:320b/40B) */
+/* hwrm_cfa_redirect_tunnel_type_free_input (size:192b/24B) */
 
-typedef struct hwrm_func_ptp_cfg_input {
+typedef struct hwrm_cfa_redirect_tunnel_type_free_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -17295,119 +45573,156 @@ typedef struct hwrm_func_ptp_cfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint16_t	enables;
-	/*
-	 * This bit must be '1' for the ptp_pps_event field to be
-	 * configured.
-	 */
-	#define HWRM_FUNC_PTP_CFG_INPUT_ENABLES_PTP_PPS_EVENT		UINT32_C(0x1)
-	/*
-	 * This bit must be '1' for the ptp_freq_adj_dll_source field to be
-	 * configured.
-	 */
-	#define HWRM_FUNC_PTP_CFG_INPUT_ENABLES_PTP_FREQ_ADJ_DLL_SOURCE	UINT32_C(0x2)
-	/*
-	 * This bit must be '1' for the ptp_freq_adj_dll_phase field to be
-	 * configured.
-	 */
-	#define HWRM_FUNC_PTP_CFG_INPUT_ENABLES_PTP_FREQ_ADJ_DLL_PHASE	UINT32_C(0x4)
-	/*
-	 * This bit must be '1' for the ptp_freq_adj_ext_period field to be
-	 * configured.
-	 */
-	#define HWRM_FUNC_PTP_CFG_INPUT_ENABLES_PTP_FREQ_ADJ_EXT_PERIOD	UINT32_C(0x8)
-	/*
-	 * This bit must be '1' for the ptp_freq_adj_ext_up field to be
-	 * configured.
-	 */
-	#define HWRM_FUNC_PTP_CFG_INPUT_ENABLES_PTP_FREQ_ADJ_EXT_UP	UINT32_C(0x10)
+	/* The destination function id, to whom the traffic is redirected. */
+	uint16_t	dest_fid;
+	/* Tunnel Type. */
+	uint8_t	tunnel_type;
+	/* Non-tunnel */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE_INPUT_TUNNEL_TYPE_NONTUNNEL	UINT32_C(0x0)
+	/* Virtual eXtensible Local Area Network (VXLAN) */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE_INPUT_TUNNEL_TYPE_VXLAN	UINT32_C(0x1)
+	/* Network Virtualization Generic Routing Encapsulation (NVGRE) */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE_INPUT_TUNNEL_TYPE_NVGRE	UINT32_C(0x2)
+	/* Generic Routing Encapsulation (GRE) inside Ethernet payload */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE_INPUT_TUNNEL_TYPE_L2GRE	UINT32_C(0x3)
+	/* IP in IP */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE_INPUT_TUNNEL_TYPE_IPIP	UINT32_C(0x4)
+	/* Generic Network Virtualization Encapsulation (Geneve) */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE_INPUT_TUNNEL_TYPE_GENEVE	UINT32_C(0x5)
+	/* Multi-Protocol Label Switching (MPLS) */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE_INPUT_TUNNEL_TYPE_MPLS	UINT32_C(0x6)
+	/* Stateless Transport Tunnel (STT) */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE_INPUT_TUNNEL_TYPE_STT	UINT32_C(0x7)
+	/* Generic Routing Encapsulation (GRE) inside IP datagram payload */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE_INPUT_TUNNEL_TYPE_IPGRE	UINT32_C(0x8)
+	/* IPV4 over virtual eXtensible Local Area Network (IPV4oVXLAN) */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE_INPUT_TUNNEL_TYPE_VXLAN_V4	UINT32_C(0x9)
 	/*
-	 * This bit must be '1' for the ptp_freq_adj_ext_phase field to be
-	 * configured.
+	 * Enhance Generic Routing Encapsulation (GRE version 1) inside IP
+	 * datagram payload
 	 */
-	#define HWRM_FUNC_PTP_CFG_INPUT_ENABLES_PTP_FREQ_ADJ_EXT_PHASE	UINT32_C(0x20)
-	/* This field is used to enable interrupt for a specific PPS event. */
-	uint8_t	ptp_pps_event;
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE_INPUT_TUNNEL_TYPE_IPGRE_V1	UINT32_C(0xa)
+	/* Use fixed layer 2 ether type of 0xFFFF */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE_INPUT_TUNNEL_TYPE_L2_ETYPE	UINT32_C(0xb)
 	/*
-	 * When this bit is set to '1', interrupt is enabled for internal
-	 * PPS event. Latches timestamp on PPS_OUT TSIO Pin. If user does
-	 * not configure PPS_OUT on a TSIO pin, then firmware will allocate
-	 * PPS_OUT to an unallocated pin.
+	 * IPV6 over virtual eXtensible Local Area Network with GPE header
+	 * (IPV6oVXLANGPE)
 	 */
-	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_PPS_EVENT_INTERNAL	UINT32_C(0x1)
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE_INPUT_TUNNEL_TYPE_VXLAN_GPE_V6 UINT32_C(0xc)
+	/* Generic Protocol Extension for VXLAN (VXLAN-GPE) */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE_INPUT_TUNNEL_TYPE_VXLAN_GPE	UINT32_C(0x10)
+	/* Any tunneled traffic */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE_INPUT_TUNNEL_TYPE_ANYTUNNEL	UINT32_C(0xff)
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE_INPUT_TUNNEL_TYPE_LAST	HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE_INPUT_TUNNEL_TYPE_ANYTUNNEL
+	uint8_t	unused_0[5];
+} hwrm_cfa_redirect_tunnel_type_free_input_t, *phwrm_cfa_redirect_tunnel_type_free_input_t;
+
+/* hwrm_cfa_redirect_tunnel_type_free_output (size:128b/16B) */
+
+typedef struct hwrm_cfa_redirect_tunnel_type_free_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
 	/*
-	 * When this bit is set to '1', interrupt is enabled for external
-	 * PPS event. Latches timestamp on PPS_IN TSIO pin.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_PPS_EVENT_EXTERNAL	UINT32_C(0x2)
+	uint8_t	valid;
+} hwrm_cfa_redirect_tunnel_type_free_output_t, *phwrm_cfa_redirect_tunnel_type_free_output_t;
+
+/**************************************
+ * hwrm_cfa_redirect_tunnel_type_info *
+ **************************************/
+
+
+/* hwrm_cfa_redirect_tunnel_type_info_input (size:192b/24B) */
+
+typedef struct hwrm_cfa_redirect_tunnel_type_info_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * This field is used to set the source signal used to discipline
-	 * PHC (PTP Hardware Clock)
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint8_t	ptp_freq_adj_dll_source;
-	/* No source is selected. Use servo to discipline PHC */
-	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_SOURCE_NONE	UINT32_C(0x0)
-	/* TSIO Pin #0 is selected as source signal. */
-	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_SOURCE_TSIO_0  UINT32_C(0x1)
-	/* TSIO Pin #1 is selected as source signal. */
-	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_SOURCE_TSIO_1  UINT32_C(0x2)
-	/* TSIO Pin #2 is selected as source signal. */
-	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_SOURCE_TSIO_2  UINT32_C(0x3)
-	/* TSIO Pin #3 is selected as source signal. */
-	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_SOURCE_TSIO_3  UINT32_C(0x4)
-	/* Port #0 is selected as source signal. */
-	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_SOURCE_PORT_0  UINT32_C(0x5)
-	/* Port #1 is selected as source signal. */
-	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_SOURCE_PORT_1  UINT32_C(0x6)
-	/* Port #2 is selected as source signal. */
-	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_SOURCE_PORT_2  UINT32_C(0x7)
-	/* Port #3 is selected as source signal. */
-	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_SOURCE_PORT_3  UINT32_C(0x8)
-	/* Invalid signal. */
-	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_SOURCE_INVALID UINT32_C(0xff)
-	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_SOURCE_LAST   HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_SOURCE_INVALID
+	uint16_t	cmpl_ring;
 	/*
-	 * This field is used to provide phase adjustment for DLL
-	 * used to discipline PHC (PTP Hardware clock)
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint8_t	ptp_freq_adj_dll_phase;
-	/* No Phase adjustment. */
-	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_PHASE_NONE UINT32_C(0x0)
-	/* 4Khz sync in frequency. */
-	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_PHASE_4K   UINT32_C(0x1)
-	/* 8Khz sync in frequency. */
-	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_PHASE_8K   UINT32_C(0x2)
-	/* 10Mhz sync in frequency. */
-	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_PHASE_10M  UINT32_C(0x3)
-	#define HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_PHASE_LAST HWRM_FUNC_PTP_CFG_INPUT_PTP_FREQ_ADJ_DLL_PHASE_10M
-	uint8_t	unused_0[3];
+	uint16_t	seq_id;
 	/*
-	 * Period in nanoseconds (ns) for external signal
-	 * input.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint32_t	ptp_freq_adj_ext_period;
+	uint16_t	target_id;
 	/*
-	 * Up time in nanoseconds (ns) of the duty cycle
-	 * of the external signal. This value should be
-	 * less than ptp_freq_adj_ext_period.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint32_t	ptp_freq_adj_ext_up;
+	uint64_t	resp_addr;
+	/* The source function id. */
+	uint16_t	src_fid;
+	/* Tunnel Type. */
+	uint8_t	tunnel_type;
+	/* Non-tunnel */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO_INPUT_TUNNEL_TYPE_NONTUNNEL	UINT32_C(0x0)
+	/* Virtual eXtensible Local Area Network (VXLAN) */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO_INPUT_TUNNEL_TYPE_VXLAN	UINT32_C(0x1)
+	/* Network Virtualization Generic Routing Encapsulation (NVGRE) */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO_INPUT_TUNNEL_TYPE_NVGRE	UINT32_C(0x2)
+	/* Generic Routing Encapsulation (GRE) inside Ethernet payload */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO_INPUT_TUNNEL_TYPE_L2GRE	UINT32_C(0x3)
+	/* IP in IP */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO_INPUT_TUNNEL_TYPE_IPIP	UINT32_C(0x4)
+	/* Generic Network Virtualization Encapsulation (Geneve) */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO_INPUT_TUNNEL_TYPE_GENEVE	UINT32_C(0x5)
+	/* Multi-Protocol Label Switching (MPLS) */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO_INPUT_TUNNEL_TYPE_MPLS	UINT32_C(0x6)
+	/* Stateless Transport Tunnel (STT) */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO_INPUT_TUNNEL_TYPE_STT	UINT32_C(0x7)
+	/* Generic Routing Encapsulation (GRE) inside IP datagram payload */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO_INPUT_TUNNEL_TYPE_IPGRE	UINT32_C(0x8)
+	/* IPV4 over virtual eXtensible Local Area Network (IPV4oVXLAN) */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO_INPUT_TUNNEL_TYPE_VXLAN_V4	UINT32_C(0x9)
 	/*
-	 * Phase value is provided. Lower 16 bits of the
-	 * field are used for Phase input.
+	 * Enhance Generic Routing Encapsulation (GRE version 1) inside IP
+	 * datagram payload
 	 */
-	uint32_t	ptp_freq_adj_ext_phase_lower;
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO_INPUT_TUNNEL_TYPE_IPGRE_V1	UINT32_C(0xa)
+	/* Use fixed layer 2 ether type of 0xFFFF */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO_INPUT_TUNNEL_TYPE_L2_ETYPE	UINT32_C(0xb)
 	/*
-	 * Phase value is provided. This 32 bit field is used
-	 * with the 16 bit value from ptp_freq_adj_ext_phase_lower
-	 * to provide a 48 bit value input for Phase.
+	 * IPV6 over virtual eXtensible Local Area Network with GPE header
+	 * (IPV6oVXLANGPE)
 	 */
-	uint32_t	ptp_freq_adj_ext_phase_upper;
-} hwrm_func_ptp_cfg_input_t, *phwrm_func_ptp_cfg_input_t;
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO_INPUT_TUNNEL_TYPE_VXLAN_GPE_V6 UINT32_C(0xc)
+	/* Generic Protocol Extension for VXLAN (VXLAN-GPE) */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO_INPUT_TUNNEL_TYPE_VXLAN_GPE	UINT32_C(0x10)
+	/* Any tunneled traffic */
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO_INPUT_TUNNEL_TYPE_ANYTUNNEL	UINT32_C(0xff)
+	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO_INPUT_TUNNEL_TYPE_LAST	HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO_INPUT_TUNNEL_TYPE_ANYTUNNEL
+	uint8_t	unused_0[5];
+} hwrm_cfa_redirect_tunnel_type_info_input_t, *phwrm_cfa_redirect_tunnel_type_info_input_t;
 
-/* hwrm_func_ptp_cfg_output (size:128b/16B) */
+/* hwrm_cfa_redirect_tunnel_type_info_output (size:128b/16B) */
 
-typedef struct hwrm_func_ptp_cfg_output {
+typedef struct hwrm_cfa_redirect_tunnel_type_info_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -17416,25 +45731,133 @@ typedef struct hwrm_func_ptp_cfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	/* The destination function id, to whom the traffic is redirected. */
+	uint16_t	dest_fid;
+	uint8_t	unused_0[5];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
+	 */
+	uint8_t	valid;
+} hwrm_cfa_redirect_tunnel_type_info_output_t, *phwrm_cfa_redirect_tunnel_type_info_output_t;
+
+/* hwrm_vxlan_ipv4_hdr (size:128b/16B) */
+
+typedef struct hwrm_vxlan_ipv4_hdr {
+	/* IPv4 version and header length. */
+	uint8_t	ver_hlen;
+	/* IPv4 header length */
+	#define HWRM_VXLAN_IPV4_HDR_VER_HLEN_HEADER_LENGTH_MASK UINT32_C(0xf)
+	#define HWRM_VXLAN_IPV4_HDR_VER_HLEN_HEADER_LENGTH_SFT 0
+	/* Version */
+	#define HWRM_VXLAN_IPV4_HDR_VER_HLEN_VERSION_MASK	UINT32_C(0xf0)
+	#define HWRM_VXLAN_IPV4_HDR_VER_HLEN_VERSION_SFT	4
+	/* IPv4 type of service. */
+	uint8_t	tos;
+	/* IPv4 identification. */
+	uint16_t	ip_id;
+	/* IPv4 flags and offset. */
+	uint16_t	flags_frag_offset;
+	/* IPv4 TTL. */
+	uint8_t	ttl;
+	/* IPv4 protocol. */
+	uint8_t	protocol;
+	/* IPv4 source address. */
+	uint32_t	src_ip_addr;
+	/* IPv4 destination address. */
+	uint32_t	dest_ip_addr;
+} hwrm_vxlan_ipv4_hdr_t, *phwrm_vxlan_ipv4_hdr_t;
+
+/* hwrm_vxlan_ipv6_hdr (size:320b/40B) */
+
+typedef struct hwrm_vxlan_ipv6_hdr {
+	/* IPv6 version, traffic class and flow label. */
+	uint32_t	ver_tc_flow_label;
+	/* IPv6 version shift */
+	#define HWRM_VXLAN_IPV6_HDR_VER_TC_FLOW_LABEL_VER_SFT	UINT32_C(0x1c)
+	/* IPv6 version mask */
+	#define HWRM_VXLAN_IPV6_HDR_VER_TC_FLOW_LABEL_VER_MASK	UINT32_C(0xf0000000)
+	/* IPv6 TC shift */
+	#define HWRM_VXLAN_IPV6_HDR_VER_TC_FLOW_LABEL_TC_SFT	UINT32_C(0x14)
+	/* IPv6 TC mask */
+	#define HWRM_VXLAN_IPV6_HDR_VER_TC_FLOW_LABEL_TC_MASK	UINT32_C(0xff00000)
+	/* IPv6 flow label shift */
+	#define HWRM_VXLAN_IPV6_HDR_VER_TC_FLOW_LABEL_FLOW_LABEL_SFT  UINT32_C(0x0)
+	/* IPv6 flow label mask */
+	#define HWRM_VXLAN_IPV6_HDR_VER_TC_FLOW_LABEL_FLOW_LABEL_MASK UINT32_C(0xfffff)
+	#define HWRM_VXLAN_IPV6_HDR_VER_TC_FLOW_LABEL_LAST	HWRM_VXLAN_IPV6_HDR_VER_TC_FLOW_LABEL_FLOW_LABEL_MASK
+	/* IPv6 payload length. */
+	uint16_t	payload_len;
+	/* IPv6 next header. */
+	uint8_t	next_hdr;
+	/* IPv6 TTL. */
+	uint8_t	ttl;
+	/* IPv6 source address. */
+	uint32_t	src_ip_addr[4];
+	/* IPv6 destination address. */
+	uint32_t	dest_ip_addr[4];
+} hwrm_vxlan_ipv6_hdr_t, *phwrm_vxlan_ipv6_hdr_t;
+
+/* hwrm_cfa_encap_data_vxlan (size:640b/80B) */
+
+typedef struct hwrm_cfa_encap_data_vxlan {
+	/* Source MAC address. */
+	uint8_t	src_mac_addr[6];
+	/* reserved. */
+	uint16_t	unused_0;
+	/* Destination MAC address. */
+	uint8_t	dst_mac_addr[6];
+	/* Number of VLAN tags. */
+	uint8_t	num_vlan_tags;
+	/* reserved. */
+	uint8_t	unused_1;
+	/* Outer VLAN TPID. */
+	uint16_t	ovlan_tpid;
+	/* Outer VLAN TCI. */
+	uint16_t	ovlan_tci;
+	/* Inner VLAN TPID. */
+	uint16_t	ivlan_tpid;
+	/* Inner VLAN TCI. */
+	uint16_t	ivlan_tci;
+	/* L3 header fields. */
+	uint32_t	l3[10];
+	/* IP version mask. */
+	#define HWRM_CFA_ENCAP_DATA_VXLAN_L3_VER_MASK UINT32_C(0xf)
+	/* IP version 4. */
+	#define HWRM_CFA_ENCAP_DATA_VXLAN_L3_VER_IPV4 UINT32_C(0x4)
+	/* IP version 6. */
+	#define HWRM_CFA_ENCAP_DATA_VXLAN_L3_VER_IPV6 UINT32_C(0x6)
+	#define HWRM_CFA_ENCAP_DATA_VXLAN_L3_LAST	HWRM_CFA_ENCAP_DATA_VXLAN_L3_VER_IPV6
+	/* UDP source port. */
+	uint16_t	src_port;
+	/* UDP destination port. */
+	uint16_t	dst_port;
+	/* VXLAN Network Identifier. */
+	uint32_t	vni;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * 3 bytes VXLAN header reserve fields from 1st dword of the VXLAN
+	 * header.
 	 */
-	uint8_t	valid;
-} hwrm_func_ptp_cfg_output_t, *phwrm_func_ptp_cfg_output_t;
+	uint8_t	hdr_rsvd0[3];
+	/* 1 byte VXLAN header reserve field from 2nd dword of the VXLAN header. */
+	uint8_t	hdr_rsvd1;
+	/* VXLAN header flags field. */
+	uint8_t	hdr_flags;
+	uint8_t	unused[3];
+} hwrm_cfa_encap_data_vxlan_t, *phwrm_cfa_encap_data_vxlan_t;
 
-/**************************
- * hwrm_func_ptp_ts_query *
- **************************/
+/*******************************
+ * hwrm_cfa_encap_record_alloc *
+ *******************************/
 
 
-/* hwrm_func_ptp_ts_query_input (size:192b/24B) */
+/* hwrm_cfa_encap_record_alloc_input (size:832b/104B) */
 
-typedef struct hwrm_func_ptp_ts_query_input {
+typedef struct hwrm_cfa_encap_record_alloc_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -17464,16 +45887,60 @@ typedef struct hwrm_func_ptp_ts_query_input {
 	 */
 	uint64_t	resp_addr;
 	uint32_t	flags;
-	/* If set, the response includes PPS event timestamps */
-	#define HWRM_FUNC_PTP_TS_QUERY_INPUT_FLAGS_PPS_TIME	UINT32_C(0x1)
-	/* If set, the response includes PTM timestamps */
-	#define HWRM_FUNC_PTP_TS_QUERY_INPUT_FLAGS_PTM_TIME	UINT32_C(0x2)
-	uint8_t	unused_0[4];
-} hwrm_func_ptp_ts_query_input_t, *phwrm_func_ptp_ts_query_input_t;
+	/*
+	 * Setting of this flag indicates the applicability to the loopback
+	 * path.
+	 */
+	#define HWRM_CFA_ENCAP_RECORD_ALLOC_INPUT_FLAGS_LOOPBACK	UINT32_C(0x1)
+	/*
+	 * Setting of this flag indicates this encap record is external
+	 * encap record. Resetting of this flag indicates this flag is
+	 * internal encap record and this is the default setting.
+	 */
+	#define HWRM_CFA_ENCAP_RECORD_ALLOC_INPUT_FLAGS_EXTERNAL	UINT32_C(0x2)
+	/* Encapsulation Type. */
+	uint8_t	encap_type;
+	/* Virtual eXtensible Local Area Network (VXLAN) */
+	#define HWRM_CFA_ENCAP_RECORD_ALLOC_INPUT_ENCAP_TYPE_VXLAN	UINT32_C(0x1)
+	/* Network Virtualization Generic Routing Encapsulation (NVGRE) */
+	#define HWRM_CFA_ENCAP_RECORD_ALLOC_INPUT_ENCAP_TYPE_NVGRE	UINT32_C(0x2)
+	/* Generic Routing Encapsulation (GRE) after inside Ethernet payload */
+	#define HWRM_CFA_ENCAP_RECORD_ALLOC_INPUT_ENCAP_TYPE_L2GRE	UINT32_C(0x3)
+	/* IP in IP */
+	#define HWRM_CFA_ENCAP_RECORD_ALLOC_INPUT_ENCAP_TYPE_IPIP	UINT32_C(0x4)
+	/* Generic Network Virtualization Encapsulation (Geneve) */
+	#define HWRM_CFA_ENCAP_RECORD_ALLOC_INPUT_ENCAP_TYPE_GENEVE	UINT32_C(0x5)
+	/* Multi-Protocol Label Switching (MPLS) */
+	#define HWRM_CFA_ENCAP_RECORD_ALLOC_INPUT_ENCAP_TYPE_MPLS	UINT32_C(0x6)
+	/* VLAN */
+	#define HWRM_CFA_ENCAP_RECORD_ALLOC_INPUT_ENCAP_TYPE_VLAN	UINT32_C(0x7)
+	/* Generic Routing Encapsulation (GRE) inside IP datagram payload */
+	#define HWRM_CFA_ENCAP_RECORD_ALLOC_INPUT_ENCAP_TYPE_IPGRE	UINT32_C(0x8)
+	/* IPV4 over virtual eXtensible Local Area Network (IPV4oVXLAN) */
+	#define HWRM_CFA_ENCAP_RECORD_ALLOC_INPUT_ENCAP_TYPE_VXLAN_V4	UINT32_C(0x9)
+	/*
+	 * Enhance Generic Routing Encapsulation (GRE version 1) inside IP
+	 * datagram payload
+	 */
+	#define HWRM_CFA_ENCAP_RECORD_ALLOC_INPUT_ENCAP_TYPE_IPGRE_V1	UINT32_C(0xa)
+	/* Use fixed layer 2 ether type of 0xFFFF */
+	#define HWRM_CFA_ENCAP_RECORD_ALLOC_INPUT_ENCAP_TYPE_L2_ETYPE	UINT32_C(0xb)
+	/*
+	 * IPV6 over virtual eXtensible Local Area Network with GPE header
+	 * (IPV6oVXLANGPE)
+	 */
+	#define HWRM_CFA_ENCAP_RECORD_ALLOC_INPUT_ENCAP_TYPE_VXLAN_GPE_V6 UINT32_C(0xc)
+	/* Generic Protocol Extension for VXLAN (VXLAN-GPE) */
+	#define HWRM_CFA_ENCAP_RECORD_ALLOC_INPUT_ENCAP_TYPE_VXLAN_GPE	UINT32_C(0x10)
+	#define HWRM_CFA_ENCAP_RECORD_ALLOC_INPUT_ENCAP_TYPE_LAST	HWRM_CFA_ENCAP_RECORD_ALLOC_INPUT_ENCAP_TYPE_VXLAN_GPE
+	uint8_t	unused_0[3];
+	/* This value is encap data used for the given encap type. */
+	uint32_t	encap_data[20];
+} hwrm_cfa_encap_record_alloc_input_t, *phwrm_cfa_encap_record_alloc_input_t;
 
-/* hwrm_func_ptp_ts_query_output (size:320b/40B) */
+/* hwrm_cfa_encap_record_alloc_output (size:128b/16B) */
 
-typedef struct hwrm_func_ptp_ts_query_output {
+typedef struct hwrm_cfa_encap_record_alloc_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -17482,33 +45949,28 @@ typedef struct hwrm_func_ptp_ts_query_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* Timestamp value of last PPS event latched. */
-	uint64_t	pps_event_ts;
-	/* PTM local timestamp value. */
-	uint64_t	ptm_res_local_ts;
-	/* PTM Master timestamp value. */
-	uint64_t	ptm_pmstr_ts;
-	/* PTM Master propagation delay */
-	uint32_t	ptm_mstr_prop_dly;
+	/* This value is an opaque id into CFA data structures. */
+	uint32_t	encap_record_id;
 	uint8_t	unused_0[3];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_func_ptp_ts_query_output_t, *phwrm_func_ptp_ts_query_output_t;
+} hwrm_cfa_encap_record_alloc_output_t, *phwrm_cfa_encap_record_alloc_output_t;
 
-/***********************
- * hwrm_func_vlan_qcfg *
- ***********************/
+/******************************
+ * hwrm_cfa_encap_record_free *
+ ******************************/
 
 
-/* hwrm_func_vlan_qcfg_input (size:192b/24B) */
+/* hwrm_cfa_encap_record_free_input (size:192b/24B) */
 
-typedef struct hwrm_func_vlan_qcfg_input {
+typedef struct hwrm_cfa_encap_record_free_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -17537,19 +45999,14 @@ typedef struct hwrm_func_vlan_qcfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/*
-	 * Function ID of the function that is being
-	 * configured.
-	 * If set to 0xFF... (All Fs), then the configuration is
-	 * for the requesting function.
-	 */
-	uint16_t	fid;
-	uint8_t	unused_0[6];
-} hwrm_func_vlan_qcfg_input_t, *phwrm_func_vlan_qcfg_input_t;
+	/* This value is an opaque id into CFA data structures. */
+	uint32_t	encap_record_id;
+	uint8_t	unused_0[4];
+} hwrm_cfa_encap_record_free_input_t, *phwrm_cfa_encap_record_free_input_t;
 
-/* hwrm_func_vlan_qcfg_output (size:320b/40B) */
+/* hwrm_cfa_encap_record_free_output (size:128b/16B) */
 
-typedef struct hwrm_func_vlan_qcfg_output {
+typedef struct hwrm_cfa_encap_record_free_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -17558,50 +46015,26 @@ typedef struct hwrm_func_vlan_qcfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint64_t	unused_0;
-	/* S-TAG VLAN identifier configured for the function. */
-	uint16_t	stag_vid;
-	/* S-TAG PCP value configured for the function. */
-	uint8_t	stag_pcp;
-	uint8_t	unused_1;
-	/*
-	 * S-TAG TPID value configured for the function. This field is specified in
-	 * network byte order.
-	 */
-	uint16_t	stag_tpid;
-	/* C-TAG VLAN identifier configured for the function. */
-	uint16_t	ctag_vid;
-	/* C-TAG PCP value configured for the function. */
-	uint8_t	ctag_pcp;
-	uint8_t	unused_2;
-	/*
-	 * C-TAG TPID value configured for the function. This field is specified in
-	 * network byte order.
-	 */
-	uint16_t	ctag_tpid;
-	/* Future use. */
-	uint32_t	rsvd2;
-	/* Future use. */
-	uint32_t	rsvd3;
-	uint8_t	unused_3[3];
+	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_func_vlan_qcfg_output_t, *phwrm_func_vlan_qcfg_output_t;
+} hwrm_cfa_encap_record_free_output_t, *phwrm_cfa_encap_record_free_output_t;
 
-/**********************
- * hwrm_func_vlan_cfg *
- **********************/
+/********************************
+ * hwrm_cfa_ntuple_filter_alloc *
+ ********************************/
 
 
-/* hwrm_func_vlan_cfg_input (size:384b/48B) */
+/* hwrm_cfa_ntuple_filter_alloc_input (size:1024b/128B) */
 
-typedef struct hwrm_func_vlan_cfg_input {
+typedef struct hwrm_cfa_ntuple_filter_alloc_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -17630,145 +46063,328 @@ typedef struct hwrm_func_vlan_cfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
+	uint32_t	flags;
 	/*
-	 * Function ID of the function that is being
-	 * configured.
-	 * If set to 0xFF... (All Fs), then the configuration is
-	 * for the requesting function.
+	 * Setting of this flag indicates the applicability to the loopback
+	 * path.
 	 */
-	uint16_t	fid;
-	uint8_t	unused_0[2];
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_FLAGS_LOOPBACK		UINT32_C(0x1)
+	/*
+	 * Setting of this flag indicates drop action. If this flag is not
+	 * set, then it should be considered accept action.
+	 */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_FLAGS_DROP		UINT32_C(0x2)
+	/*
+	 * Setting of this flag indicates that a meter is expected to be
+	 * attached to this flow. This hint can be used when choosing the
+	 * action record format required for the flow.
+	 */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_FLAGS_METER		UINT32_C(0x4)
+	/*
+	 * Setting of this flag indicates that the dst_id field contains
+	 * function ID. If this is not set it indicates dest_id is VNIC
+	 * or VPORT.
+	 */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_FLAGS_DEST_FID		UINT32_C(0x8)
+	/*
+	 * Setting of this flag indicates match on arp reply when ethertype
+	 * is 0x0806. If this is not set it indicates no specific arp opcode
+	 * matching.
+	 */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_FLAGS_ARP_REPLY		UINT32_C(0x10)
+	/*
+	 * Setting of this flag indicates that the dst_id field contains RFS
+	 * ring table index. If this is not set it indicates dst_id is VNIC
+	 * or VPORT or function ID. Note dest_fid and dest_rfs_ring_idx
+	 * can't be set at the same time. Updated drivers should pass ring
+	 * idx in the rfs_ring_tbl_idx field if the firmware indicates
+	 * support for the new field in the HWRM_CFA_ADV_FLOW_MGMT_QCAPS
+	 * response.
+	 */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_FLAGS_DEST_RFS_RING_IDX	UINT32_C(0x20)
+	/*
+	 * Setting of this flag indicates that when the ntuple filter is
+	 * created, the L2 context should not be used in the filter. This
+	 * allows packet from different L2 contexts to match and be directed
+	 * to the same destination.
+	 */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_FLAGS_NO_L2_CONTEXT	UINT32_C(0x40)
 	uint32_t	enables;
 	/*
-	 * This bit must be '1' for the stag_vid field to be
+	 * This bit must be '1' for the l2_filter_id field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_VLAN_CFG_INPUT_ENABLES_STAG_VID	UINT32_C(0x1)
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_L2_FILTER_ID	UINT32_C(0x1)
 	/*
-	 * This bit must be '1' for the ctag_vid field to be
+	 * This bit must be '1' for the ethertype field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_VLAN_CFG_INPUT_ENABLES_CTAG_VID	UINT32_C(0x2)
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_ETHERTYPE		UINT32_C(0x2)
 	/*
-	 * This bit must be '1' for the stag_pcp field to be
+	 * This bit must be '1' for the tunnel_type field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_VLAN_CFG_INPUT_ENABLES_STAG_PCP	UINT32_C(0x4)
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_TUNNEL_TYPE	UINT32_C(0x4)
 	/*
-	 * This bit must be '1' for the ctag_pcp field to be
+	 * This bit must be '1' for the src_macaddr field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_VLAN_CFG_INPUT_ENABLES_CTAG_PCP	UINT32_C(0x8)
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_SRC_MACADDR	UINT32_C(0x8)
 	/*
-	 * This bit must be '1' for the stag_tpid field to be
+	 * This bit must be '1' for the ipaddr_type field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_VLAN_CFG_INPUT_ENABLES_STAG_TPID	UINT32_C(0x10)
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_IPADDR_TYPE	UINT32_C(0x10)
 	/*
-	 * This bit must be '1' for the ctag_tpid field to be
+	 * This bit must be '1' for the src_ipaddr field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_VLAN_CFG_INPUT_ENABLES_CTAG_TPID	UINT32_C(0x20)
-	/* S-TAG VLAN identifier configured for the function. */
-	uint16_t	stag_vid;
-	/* S-TAG PCP value configured for the function. */
-	uint8_t	stag_pcp;
-	uint8_t	unused_1;
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_SRC_IPADDR	UINT32_C(0x20)
 	/*
-	 * S-TAG TPID value configured for the function. This field is specified in
-	 * network byte order.
+	 * This bit must be '1' for the src_ipaddr_mask field to be
+	 * configured.
 	 */
-	uint16_t	stag_tpid;
-	/* C-TAG VLAN identifier configured for the function. */
-	uint16_t	ctag_vid;
-	/* C-TAG PCP value configured for the function. */
-	uint8_t	ctag_pcp;
-	uint8_t	unused_2;
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_SRC_IPADDR_MASK	UINT32_C(0x40)
 	/*
-	 * C-TAG TPID value configured for the function. This field is specified in
-	 * network byte order.
+	 * This bit must be '1' for the dst_ipaddr field to be
+	 * configured.
 	 */
-	uint16_t	ctag_tpid;
-	/* Future use. */
-	uint32_t	rsvd1;
-	/* Future use. */
-	uint32_t	rsvd2;
-	uint8_t	unused_3[4];
-} hwrm_func_vlan_cfg_input_t, *phwrm_func_vlan_cfg_input_t;
-
-/* hwrm_func_vlan_cfg_output (size:128b/16B) */
-
-typedef struct hwrm_func_vlan_cfg_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_DST_IPADDR	UINT32_C(0x80)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * This bit must be '1' for the dst_ipaddr_mask field to be
+	 * configured.
 	 */
-	uint8_t	valid;
-} hwrm_func_vlan_cfg_output_t, *phwrm_func_vlan_cfg_output_t;
-
-/*******************************
- * hwrm_func_vf_vnic_ids_query *
- *******************************/
-
-
-/* hwrm_func_vf_vnic_ids_query_input (size:256b/32B) */
-
-typedef struct hwrm_func_vf_vnic_ids_query_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_DST_IPADDR_MASK	UINT32_C(0x100)
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * This bit must be '1' for the ip_protocol field to be
+	 * configured.
 	 */
-	uint16_t	cmpl_ring;
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_IP_PROTOCOL	UINT32_C(0x200)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * This bit must be '1' for the src_port field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_SRC_PORT		UINT32_C(0x400)
+	/*
+	 * This bit must be '1' for the src_port_mask field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_SRC_PORT_MASK	UINT32_C(0x800)
+	/*
+	 * This bit must be '1' for the dst_port field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_DST_PORT		UINT32_C(0x1000)
+	/*
+	 * This bit must be '1' for the dst_port_mask field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_DST_PORT_MASK	UINT32_C(0x2000)
+	/*
+	 * This bit must be '1' for the pri_hint field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_PRI_HINT		UINT32_C(0x4000)
+	/*
+	 * This bit must be '1' for the ntuple_filter_id field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_NTUPLE_FILTER_ID	UINT32_C(0x8000)
+	/*
+	 * This bit must be '1' for the dst_id field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_DST_ID		UINT32_C(0x10000)
+	/* This flag is deprecated. */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_MIRROR_VNIC_ID	UINT32_C(0x20000)
+	/*
+	 * This bit must be '1' for the dst_macaddr field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_DST_MACADDR	UINT32_C(0x40000)
+	/*
+	 * This bit must be '1' for the rfs_ring_tbl_idx field to
+	 * be configured.
+	 */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_RFS_RING_TBL_IDX	UINT32_C(0x80000)
+	/*
+	 * This value identifies a set of CFA data structures used for an L2
+	 * context.
+	 */
+	uint64_t	l2_filter_id;
+	/*
+	 * This value indicates the source MAC address in
+	 * the Ethernet header.
+	 */
+	uint8_t	src_macaddr[6];
+	/* This value indicates the ethertype in the Ethernet header. */
+	uint16_t	ethertype;
+	/*
+	 * This value indicates the type of IP address.
+	 * 4 - IPv4
+	 * 6 - IPv6
+	 * All others are invalid.
+	 */
+	uint8_t	ip_addr_type;
+	/* invalid */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_IP_ADDR_TYPE_UNKNOWN UINT32_C(0x0)
+	/* IPv4 */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_IP_ADDR_TYPE_IPV4	UINT32_C(0x4)
+	/* IPv6 */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_IP_ADDR_TYPE_IPV6	UINT32_C(0x6)
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_IP_ADDR_TYPE_LAST   HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_IP_ADDR_TYPE_IPV6
+	/*
+	 * The value of protocol field in IP header.
+	 * Applies to UDP and TCP traffic.
+	 * 6 - TCP
+	 * 17 - UDP
+	 * 1 - ICMP
+	 * 58 - ICMPV6
+	 * 255 - RSVD
+	 */
+	uint8_t	ip_protocol;
+	/* invalid */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_IP_PROTOCOL_UNKNOWN UINT32_C(0x0)
+	/* TCP */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_IP_PROTOCOL_TCP	UINT32_C(0x6)
+	/* UDP */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_IP_PROTOCOL_UDP	UINT32_C(0x11)
+	/* ICMP */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_IP_PROTOCOL_ICMP	UINT32_C(0x1)
+	/* ICMPV6 */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_IP_PROTOCOL_ICMPV6  UINT32_C(0x3a)
+	/* RSVD */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_IP_PROTOCOL_RSVD	UINT32_C(0xff)
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_IP_PROTOCOL_LAST   HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_IP_PROTOCOL_RSVD
+	/*
+	 * If set, this value shall represent the
+	 * Logical VNIC ID of the destination VNIC for the RX
+	 * path and network port id of the destination port for
+	 * the TX path.
+	 */
+	uint16_t	dst_id;
+	/*
+	 * If set, this value shall represent the ring table
+	 * index for receive flow steering. Note that this offset
+	 * was formerly used for the mirror_vnic_id field, which
+	 * is no longer supported.
+	 */
+	uint16_t	rfs_ring_tbl_idx;
+	/*
+	 * This value indicates the tunnel type for this filter.
+	 * If this field is not specified, then the filter shall
+	 * apply to both non-tunneled and tunneled packets.
+	 * If this field conflicts with the tunnel_type specified
+	 * in the l2_filter_id, then the HWRM shall return an
+	 * error for this command.
+	 */
+	uint8_t	tunnel_type;
+	/* Non-tunnel */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_TUNNEL_TYPE_NONTUNNEL	UINT32_C(0x0)
+	/* Virtual eXtensible Local Area Network (VXLAN) */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_TUNNEL_TYPE_VXLAN	UINT32_C(0x1)
+	/* Network Virtualization Generic Routing Encapsulation (NVGRE) */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_TUNNEL_TYPE_NVGRE	UINT32_C(0x2)
+	/* Generic Routing Encapsulation (GRE) inside Ethernet payload */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_TUNNEL_TYPE_L2GRE	UINT32_C(0x3)
+	/* IP in IP */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_TUNNEL_TYPE_IPIP	UINT32_C(0x4)
+	/* Generic Network Virtualization Encapsulation (Geneve) */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_TUNNEL_TYPE_GENEVE	UINT32_C(0x5)
+	/* Multi-Protocol Label Switching (MPLS) */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_TUNNEL_TYPE_MPLS	UINT32_C(0x6)
+	/* Stateless Transport Tunnel (STT) */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_TUNNEL_TYPE_STT	UINT32_C(0x7)
+	/* Generic Routing Encapsulation (GRE) inside IP datagram payload */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_TUNNEL_TYPE_IPGRE	UINT32_C(0x8)
+	/* IPV4 over virtual eXtensible Local Area Network (IPV4oVXLAN) */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_V4	UINT32_C(0x9)
+	/*
+	 * Enhance Generic Routing Encapsulation (GRE version 1) inside IP
+	 * datagram payload
+	 */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_TUNNEL_TYPE_IPGRE_V1	UINT32_C(0xa)
+	/* Use fixed layer 2 ether type of 0xFFFF */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_TUNNEL_TYPE_L2_ETYPE	UINT32_C(0xb)
+	/*
+	 * IPV6 over virtual eXtensible Local Area Network with GPE header
+	 * (IPV6oVXLANGPE)
+	 */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_GPE_V6 UINT32_C(0xc)
+	/* Generic Protocol Extension for VXLAN (VXLAN-GPE) */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_GPE	UINT32_C(0x10)
+	/* Any tunneled traffic */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_TUNNEL_TYPE_ANYTUNNEL	UINT32_C(0xff)
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_TUNNEL_TYPE_LAST	HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_TUNNEL_TYPE_ANYTUNNEL
+	/*
+	 * This hint is provided to help in placing
+	 * the filter in the filter table.
+	 */
+	uint8_t	pri_hint;
+	/* No preference */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_PRI_HINT_NO_PREFER UINT32_C(0x0)
+	/* Above the given filter */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_PRI_HINT_ABOVE	UINT32_C(0x1)
+	/* Below the given filter */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_PRI_HINT_BELOW	UINT32_C(0x2)
+	/* As high as possible */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_PRI_HINT_HIGHEST   UINT32_C(0x3)
+	/* As low as possible */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_PRI_HINT_LOWEST	UINT32_C(0x4)
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_PRI_HINT_LAST	HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_PRI_HINT_LOWEST
+	/*
+	 * The value of source IP address to be used in filtering.
+	 * For IPv4, first four bytes represent the IP address.
+	 */
+	uint32_t	src_ipaddr[4];
+	/*
+	 * The value of source IP address mask to be used in
+	 * filtering.
+	 * For IPv4, first four bytes represent the IP address mask.
+	 */
+	uint32_t	src_ipaddr_mask[4];
+	/*
+	 * The value of destination IP address to be used in filtering.
+	 * For IPv4, first four bytes represent the IP address.
+	 */
+	uint32_t	dst_ipaddr[4];
+	/*
+	 * The value of destination IP address mask to be used in
+	 * filtering.
+	 * For IPv4, first four bytes represent the IP address mask.
+	 */
+	uint32_t	dst_ipaddr_mask[4];
+	/*
+	 * The value of source port to be used in filtering.
+	 * Applies to UDP and TCP traffic.
+	 */
+	uint16_t	src_port;
+	/*
+	 * The value of source port mask to be used in filtering.
+	 * Applies to UDP and TCP traffic.
 	 */
-	uint16_t	seq_id;
+	uint16_t	src_port_mask;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * The value of destination port to be used in filtering.
+	 * Applies to UDP and TCP traffic.
 	 */
-	uint16_t	target_id;
+	uint16_t	dst_port;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * The value of destination port mask to be used in
+	 * filtering.
+	 * Applies to UDP and TCP traffic.
 	 */
-	uint64_t	resp_addr;
+	uint16_t	dst_port_mask;
 	/*
-	 * This value is used to identify a Virtual Function (VF).
-	 * The scope of VF ID is local within a PF.
+	 * This is the ID of the filter that goes along with
+	 * the pri_hint.
 	 */
-	uint16_t	vf_id;
-	uint8_t	unused_0[2];
-	/* Max number of vnic ids in vnic id table */
-	uint32_t	max_vnic_id_cnt;
-	/* This is the address for VF VNIC ID table */
-	uint64_t	vnic_id_tbl_addr;
-} hwrm_func_vf_vnic_ids_query_input_t, *phwrm_func_vf_vnic_ids_query_input_t;
+	uint64_t	ntuple_filter_id_hint;
+} hwrm_cfa_ntuple_filter_alloc_input_t, *phwrm_cfa_ntuple_filter_alloc_input_t;
 
-/* hwrm_func_vf_vnic_ids_query_output (size:128b/16B) */
+/* hwrm_cfa_ntuple_filter_alloc_output (size:192b/24B) */
 
-typedef struct hwrm_func_vf_vnic_ids_query_output {
+typedef struct hwrm_cfa_ntuple_filter_alloc_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -17777,31 +46393,75 @@ typedef struct hwrm_func_vf_vnic_ids_query_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
+	/* This value is an opaque id into CFA data structures. */
+	uint64_t	ntuple_filter_id;
 	/*
-	 * Actual number of vnic ids
-	 *
-	 * Each VNIC ID is written as a 32-bit number.
+	 * The flow id value in bit 0-29 is the actual ID of the flow
+	 * associated with this filter and it shall be used to match
+	 * and associate the flow identifier returned in completion
+	 * records. A value of 0xFFFFFFFF in the 32-bit flow_id field
+	 * shall indicate no valid flow id.
 	 */
-	uint32_t	vnic_id_cnt;
+	uint32_t	flow_id;
+	/* Indicate the flow id value. */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_OUTPUT_FLOW_ID_VALUE_MASK UINT32_C(0x3fffffff)
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_OUTPUT_FLOW_ID_VALUE_SFT 0
+	/* Indicate type of the flow. */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE	UINT32_C(0x40000000)
+	/*
+	 * If this bit set to 0, then it indicates that the flow is
+	 * internal flow.
+	 */
+		#define HWRM_CFA_NTUPLE_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE_INT	(UINT32_C(0x0) << 30)
+	/*
+	 * If this bit is set to 1, then it indicates that the flow is
+	 * external flow.
+	 */
+		#define HWRM_CFA_NTUPLE_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE_EXT	(UINT32_C(0x1) << 30)
+		#define HWRM_CFA_NTUPLE_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE_LAST  HWRM_CFA_NTUPLE_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE_EXT
+	/* Indicate the flow direction. */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR	UINT32_C(0x80000000)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_CFA_NTUPLE_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR_RX	(UINT32_C(0x0) << 31)
+	/* If this bit is set to 1, then it indicates that tx flow. */
+		#define HWRM_CFA_NTUPLE_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR_TX	(UINT32_C(0x1) << 31)
+		#define HWRM_CFA_NTUPLE_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR_LAST   HWRM_CFA_NTUPLE_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR_TX
 	uint8_t	unused_0[3];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_func_vf_vnic_ids_query_output_t, *phwrm_func_vf_vnic_ids_query_output_t;
+} hwrm_cfa_ntuple_filter_alloc_output_t, *phwrm_cfa_ntuple_filter_alloc_output_t;
 
-/***********************
- * hwrm_func_vf_bw_cfg *
- ***********************/
+/* hwrm_cfa_ntuple_filter_alloc_cmd_err (size:64b/8B) */
+
+typedef struct hwrm_cfa_ntuple_filter_alloc_cmd_err {
+	/*
+	 * command specific error codes that goes to
+	 * the cmd_err field in Common HWRM Error Response.
+	 */
+	uint8_t	code;
+	/* Unknown error */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_CMD_ERR_CODE_UNKNOWN		UINT32_C(0x0)
+	/* Unable to complete operation due to conflict with Rx Mask VLAN */
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_CMD_ERR_CODE_RX_MASK_VLAN_CONFLICT_ERR UINT32_C(0x1)
+	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_CMD_ERR_CODE_LAST			HWRM_CFA_NTUPLE_FILTER_ALLOC_CMD_ERR_CODE_RX_MASK_VLAN_CONFLICT_ERR
+	uint8_t	unused_0[7];
+} hwrm_cfa_ntuple_filter_alloc_cmd_err_t, *phwrm_cfa_ntuple_filter_alloc_cmd_err_t;
+
+/*******************************
+ * hwrm_cfa_ntuple_filter_free *
+ *******************************/
 
 
-/* hwrm_func_vf_bw_cfg_input (size:960b/120B) */
+/* hwrm_cfa_ntuple_filter_free_input (size:192b/24B) */
 
-typedef struct hwrm_func_vf_bw_cfg_input {
+typedef struct hwrm_cfa_ntuple_filter_free_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -17830,61 +46490,13 @@ typedef struct hwrm_func_vf_bw_cfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/*
-	 * The number of VF functions that are being configured.
-	 * The cmd space allows up to 50 VFs' BW to be configured with one cmd.
-	 */
-	uint16_t	num_vfs;
-	uint16_t	unused[3];
-	/* These 16-bit fields contain the VF fid and the rate scale percentage. */
-	uint16_t	vfn[48];
-	/* The physical VF id the adjustment will be made to. */
-	#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_VFID_MASK	UINT32_C(0xfff)
-	#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_VFID_SFT	0
-	/*
-	 * This field configures the rate scale percentage of the VF as specified
-	 * by the physical VF id.
-	 */
-	#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_MASK	UINT32_C(0xf000)
-	#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_SFT	12
-	/* 0% of the max tx rate */
-		#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_PCT_0	(UINT32_C(0x0) << 12)
-	/* 6.66% of the max tx rate */
-		#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_PCT_6_66   (UINT32_C(0x1) << 12)
-	/* 13.33% of the max tx rate */
-		#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_PCT_13_33  (UINT32_C(0x2) << 12)
-	/* 20% of the max tx rate */
-		#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_PCT_20	(UINT32_C(0x3) << 12)
-	/* 26.66% of the max tx rate */
-		#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_PCT_26_66  (UINT32_C(0x4) << 12)
-	/* 33% of the max tx rate */
-		#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_PCT_33_33  (UINT32_C(0x5) << 12)
-	/* 40% of the max tx rate */
-		#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_PCT_40	(UINT32_C(0x6) << 12)
-	/* 46.66% of the max tx rate */
-		#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_PCT_46_66  (UINT32_C(0x7) << 12)
-	/* 53.33% of the max tx rate */
-		#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_PCT_53_33  (UINT32_C(0x8) << 12)
-	/* 60% of the max tx rate */
-		#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_PCT_60	(UINT32_C(0x9) << 12)
-	/* 66.66% of the max tx rate */
-		#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_PCT_66_66  (UINT32_C(0xa) << 12)
-	/* 53.33% of the max tx rate */
-		#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_PCT_73_33  (UINT32_C(0xb) << 12)
-	/* 80% of the max tx rate */
-		#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_PCT_80	(UINT32_C(0xc) << 12)
-	/* 86.66% of the max tx rate */
-		#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_PCT_86_66  (UINT32_C(0xd) << 12)
-	/* 93.33% of the max tx rate */
-		#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_PCT_93_33  (UINT32_C(0xe) << 12)
-	/* 100% of the max tx rate */
-		#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_PCT_100	(UINT32_C(0xf) << 12)
-		#define HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_LAST	HWRM_FUNC_VF_BW_CFG_INPUT_VFN_RATE_PCT_100
-} hwrm_func_vf_bw_cfg_input_t, *phwrm_func_vf_bw_cfg_input_t;
+	/* This value is an opaque id into CFA data structures. */
+	uint64_t	ntuple_filter_id;
+} hwrm_cfa_ntuple_filter_free_input_t, *phwrm_cfa_ntuple_filter_free_input_t;
 
-/* hwrm_func_vf_bw_cfg_output (size:128b/16B) */
+/* hwrm_cfa_ntuple_filter_free_output (size:128b/16B) */
 
-typedef struct hwrm_func_vf_bw_cfg_output {
+typedef struct hwrm_cfa_ntuple_filter_free_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -17896,22 +46508,23 @@ typedef struct hwrm_func_vf_bw_cfg_output {
 	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_func_vf_bw_cfg_output_t, *phwrm_func_vf_bw_cfg_output_t;
+} hwrm_cfa_ntuple_filter_free_output_t, *phwrm_cfa_ntuple_filter_free_output_t;
 
-/************************
- * hwrm_func_vf_bw_qcfg *
- ************************/
+/******************************
+ * hwrm_cfa_ntuple_filter_cfg *
+ ******************************/
 
 
-/* hwrm_func_vf_bw_qcfg_input (size:960b/120B) */
+/* hwrm_cfa_ntuple_filter_cfg_input (size:384b/48B) */
 
-typedef struct hwrm_func_vf_bw_qcfg_input {
+typedef struct hwrm_cfa_ntuple_filter_cfg_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -17940,150 +46553,75 @@ typedef struct hwrm_func_vf_bw_qcfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
+	uint32_t	enables;
 	/*
-	 * The number of VF functions that are being queried.
-	 * The inline response space allows the host to query up to 50 VFs'
-	 * rate scale percentage
+	 * This bit must be '1' for the new_dst_id field to be
+	 * configured.
 	 */
-	uint16_t	num_vfs;
-	uint16_t	unused[3];
-	/* These 16-bit fields contain the VF fid */
-	uint16_t	vfn[48];
-	/* The physical VF id of interest */
-	#define HWRM_FUNC_VF_BW_QCFG_INPUT_VFN_VFID_MASK UINT32_C(0xfff)
-	#define HWRM_FUNC_VF_BW_QCFG_INPUT_VFN_VFID_SFT 0
-} hwrm_func_vf_bw_qcfg_input_t, *phwrm_func_vf_bw_qcfg_input_t;
-
-/* hwrm_func_vf_bw_qcfg_output (size:960b/120B) */
-
-typedef struct hwrm_func_vf_bw_qcfg_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
+	#define HWRM_CFA_NTUPLE_FILTER_CFG_INPUT_ENABLES_NEW_DST_ID		UINT32_C(0x1)
 	/*
-	 * The number of VF functions that are being queried.
-	 * The inline response space allows the host to query up to 50 VFs' rate
-	 * scale percentage
+	 * This bit must be '1' for the new_mirror_vnic_id field to be
+	 * configured.
 	 */
-	uint16_t	num_vfs;
-	uint16_t	unused[3];
-	/* These 16-bit fields contain the VF fid and the rate scale percentage. */
-	uint16_t	vfn[48];
-	/* The physical VF id the adjustment will be made to. */
-	#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_VFID_MASK	UINT32_C(0xfff)
-	#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_VFID_SFT	0
+	#define HWRM_CFA_NTUPLE_FILTER_CFG_INPUT_ENABLES_NEW_MIRROR_VNIC_ID	UINT32_C(0x2)
 	/*
-	 * This field configures the rate scale percentage of the VF as specified
-	 * by the physical VF id.
+	 * This bit must be '1' for the new_meter_instance_id field to be
+	 * configured.
 	 */
-	#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_MASK	UINT32_C(0xf000)
-	#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_SFT	12
-	/* 0% of the max tx rate */
-		#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_PCT_0	(UINT32_C(0x0) << 12)
-	/* 6.66% of the max tx rate */
-		#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_PCT_6_66   (UINT32_C(0x1) << 12)
-	/* 13.33% of the max tx rate */
-		#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_PCT_13_33  (UINT32_C(0x2) << 12)
-	/* 20% of the max tx rate */
-		#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_PCT_20	(UINT32_C(0x3) << 12)
-	/* 26.66% of the max tx rate */
-		#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_PCT_26_66  (UINT32_C(0x4) << 12)
-	/* 33% of the max tx rate */
-		#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_PCT_33_33  (UINT32_C(0x5) << 12)
-	/* 40% of the max tx rate */
-		#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_PCT_40	(UINT32_C(0x6) << 12)
-	/* 46.66% of the max tx rate */
-		#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_PCT_46_66  (UINT32_C(0x7) << 12)
-	/* 53.33% of the max tx rate */
-		#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_PCT_53_33  (UINT32_C(0x8) << 12)
-	/* 60% of the max tx rate */
-		#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_PCT_60	(UINT32_C(0x9) << 12)
-	/* 66.66% of the max tx rate */
-		#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_PCT_66_66  (UINT32_C(0xa) << 12)
-	/* 53.33% of the max tx rate */
-		#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_PCT_73_33  (UINT32_C(0xb) << 12)
-	/* 80% of the max tx rate */
-		#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_PCT_80	(UINT32_C(0xc) << 12)
-	/* 86.66% of the max tx rate */
-		#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_PCT_86_66  (UINT32_C(0xd) << 12)
-	/* 93.33% of the max tx rate */
-		#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_PCT_93_33  (UINT32_C(0xe) << 12)
-	/* 100% of the max tx rate */
-		#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_PCT_100	(UINT32_C(0xf) << 12)
-		#define HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_LAST	HWRM_FUNC_VF_BW_QCFG_OUTPUT_VFN_RATE_PCT_100
-	uint8_t	unused_0[7];
+	#define HWRM_CFA_NTUPLE_FILTER_CFG_INPUT_ENABLES_NEW_METER_INSTANCE_ID	UINT32_C(0x4)
+	uint32_t	flags;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * Setting this bit to 1 indicates that dest_id field contains FID.
+	 * Setting this to 0 indicates that dest_id field contains VNIC or
+	 * VPORT.
 	 */
-	uint8_t	valid;
-} hwrm_func_vf_bw_qcfg_output_t, *phwrm_func_vf_bw_qcfg_output_t;
-
-/***************************
- * hwrm_func_drv_if_change *
- ***************************/
-
-
-/* hwrm_func_drv_if_change_input (size:192b/24B) */
-
-typedef struct hwrm_func_drv_if_change_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define HWRM_CFA_NTUPLE_FILTER_CFG_INPUT_FLAGS_DEST_FID		UINT32_C(0x1)
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * Setting of this flag indicates that the new_dst_id field contains
+	 * RFS ring table index. If this is not set it indicates new_dst_id
+	 * is VNIC or VPORT or function ID. Note dest_fid and
+	 * dest_rfs_ring_idx can't be set at the same time.
 	 */
-	uint16_t	cmpl_ring;
+	#define HWRM_CFA_NTUPLE_FILTER_CFG_INPUT_FLAGS_DEST_RFS_RING_IDX	UINT32_C(0x2)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Setting of this flag indicates that when the ntuple filter is
+	 * created, the L2 context should not be used in the filter. This
+	 * allows packet from different L2 contexts to match and be directed
+	 * to the same destination.
 	 */
-	uint16_t	seq_id;
+	#define HWRM_CFA_NTUPLE_FILTER_CFG_INPUT_FLAGS_NO_L2_CONTEXT	UINT32_C(0x4)
+	/* This value is an opaque id into CFA data structures. */
+	uint64_t	ntuple_filter_id;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * If set, this value shall represent the new
+	 * Logical VNIC ID of the destination VNIC for the RX
+	 * path and new network port id of the destination port for
+	 * the TX path.
 	 */
-	uint16_t	target_id;
+	uint32_t	new_dst_id;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * New Logical VNIC ID of the VNIC where traffic is
+	 * mirrored.
 	 */
-	uint64_t	resp_addr;
-	uint32_t	flags;
+	uint32_t	new_mirror_vnic_id;
 	/*
-	 * When this bit is '1', the function driver is indicating
-	 * that the IF state is changing to UP state.  The call should
-	 * be made at the beginning of the driver's open call before
-	 * resources are allocated.  After making the call, the driver
-	 * should check the response to see if any resources may have
-	 * changed (see the response below).  If the driver fails
-	 * the open call, the driver should make this call again with
-	 * this bit cleared to indicate that the IF state is not UP.
-	 * During the driver's close call when the IF state is changing
-	 * to DOWN, the driver should make this call with the bit cleared
-	 * after all resources have been freed.
+	 * New meter to attach to the flow. Specifying the
+	 * invalid instance ID is used to remove any existing
+	 * meter from the flow.
 	 */
-	#define HWRM_FUNC_DRV_IF_CHANGE_INPUT_FLAGS_UP	UINT32_C(0x1)
-	uint32_t	unused;
-} hwrm_func_drv_if_change_input_t, *phwrm_func_drv_if_change_input_t;
+	uint16_t	new_meter_instance_id;
+	/*
+	 * A value of 0xfff is considered invalid and implies the
+	 * instance is not configured.
+	 */
+	#define HWRM_CFA_NTUPLE_FILTER_CFG_INPUT_NEW_METER_INSTANCE_ID_INVALID UINT32_C(0xffff)
+	#define HWRM_CFA_NTUPLE_FILTER_CFG_INPUT_NEW_METER_INSTANCE_ID_LAST   HWRM_CFA_NTUPLE_FILTER_CFG_INPUT_NEW_METER_INSTANCE_ID_INVALID
+	uint8_t	unused_1[6];
+} hwrm_cfa_ntuple_filter_cfg_input_t, *phwrm_cfa_ntuple_filter_cfg_input_t;
 
-/* hwrm_func_drv_if_change_output (size:128b/16B) */
+/* hwrm_cfa_ntuple_filter_cfg_output (size:128b/16B) */
 
-typedef struct hwrm_func_drv_if_change_output {
+typedef struct hwrm_cfa_ntuple_filter_cfg_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -18092,38 +46630,26 @@ typedef struct hwrm_func_drv_if_change_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint32_t	flags;
-	/*
-	 * When this bit is '1', it indicates that the resources reserved
-	 * for this function may have changed.  The driver should check
-	 * resource capabilities and reserve resources again before
-	 * allocating resources.
-	 */
-	#define HWRM_FUNC_DRV_IF_CHANGE_OUTPUT_FLAGS_RESC_CHANGE	UINT32_C(0x1)
-	/*
-	 * When this bit is '1', it indicates that the firmware got changed / reset.
-	 * The driver should do complete re-initialization when that bit is set.
-	 */
-	#define HWRM_FUNC_DRV_IF_CHANGE_OUTPUT_FLAGS_HOT_FW_RESET_DONE	UINT32_C(0x2)
-	uint8_t	unused_0[3];
+	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_func_drv_if_change_output_t, *phwrm_func_drv_if_change_output_t;
+} hwrm_cfa_ntuple_filter_cfg_output_t, *phwrm_cfa_ntuple_filter_cfg_output_t;
 
-/*******************************
- * hwrm_func_host_pf_ids_query *
- *******************************/
+/**************************
+ * hwrm_cfa_em_flow_alloc *
+ **************************/
 
 
-/* hwrm_func_host_pf_ids_query_input (size:192b/24B) */
+/* hwrm_cfa_em_flow_alloc_input (size:896b/112B) */
 
-typedef struct hwrm_func_host_pf_ids_query_input {
+typedef struct hwrm_cfa_em_flow_alloc_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -18152,339 +46678,293 @@ typedef struct hwrm_func_host_pf_ids_query_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint8_t	host;
-	/*
-	 * # If this bit is set to '1', the query will contain PF(s)
-	 * belongs to SOC host.
-	 */
-	#define HWRM_FUNC_HOST_PF_IDS_QUERY_INPUT_HOST_SOC	UINT32_C(0x1)
-	/*
-	 * # If this bit is set to '1', the query will contain PF(s)
-	 * belongs to EP0 host.
-	 */
-	#define HWRM_FUNC_HOST_PF_IDS_QUERY_INPUT_HOST_EP_0	UINT32_C(0x2)
-	/*
-	 * # If this bit is set to '1', the query will contain PF(s)
-	 * belongs to EP1 host.
-	 */
-	#define HWRM_FUNC_HOST_PF_IDS_QUERY_INPUT_HOST_EP_1	UINT32_C(0x4)
-	/*
-	 * # If this bit is set to '1', the query will contain PF(s)
-	 * belongs to EP2 host.
-	 */
-	#define HWRM_FUNC_HOST_PF_IDS_QUERY_INPUT_HOST_EP_2	UINT32_C(0x8)
-	/*
-	 * # If this bit is set to '1', the query will contain PF(s)
-	 * belongs to EP3 host.
-	 */
-	#define HWRM_FUNC_HOST_PF_IDS_QUERY_INPUT_HOST_EP_3	UINT32_C(0x10)
-	/*
-	 * This provides a filter of what PF(s) will be returned in the
-	 * query..
-	 */
-	uint8_t	filter;
-	/*
-	 * all available PF(s) belong to the host(s) (defined in the
-	 * host field). This includes the hidden PFs.
-	 */
-	#define HWRM_FUNC_HOST_PF_IDS_QUERY_INPUT_FILTER_ALL  UINT32_C(0x0)
-	/*
-	 * all available PF(s) belong to the host(s) (defined in the
-	 * host field) that is available for L2 traffic.
-	 */
-	#define HWRM_FUNC_HOST_PF_IDS_QUERY_INPUT_FILTER_L2   UINT32_C(0x1)
-	/*
-	 * all available PF(s) belong to the host(s) (defined in the
-	 * host field) that is available for ROCE traffic.
-	 */
-	#define HWRM_FUNC_HOST_PF_IDS_QUERY_INPUT_FILTER_ROCE UINT32_C(0x2)
-	#define HWRM_FUNC_HOST_PF_IDS_QUERY_INPUT_FILTER_LAST HWRM_FUNC_HOST_PF_IDS_QUERY_INPUT_FILTER_ROCE
-	uint8_t	unused_1[6];
-} hwrm_func_host_pf_ids_query_input_t, *phwrm_func_host_pf_ids_query_input_t;
-
-/* hwrm_func_host_pf_ids_query_output (size:128b/16B) */
-
-typedef struct hwrm_func_host_pf_ids_query_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* This provides the first PF ID of the device. */
-	uint16_t	first_pf_id;
-	uint16_t	pf_ordinal_mask;
-	/*
-	 * When this bit is '1', it indicates first PF belongs to one of
-	 * the hosts defined in the input request.
-	 */
-	#define HWRM_FUNC_HOST_PF_IDS_QUERY_OUTPUT_PF_ORDINAL_MASK_FUNC_0	UINT32_C(0x1)
-	/*
-	 * When this bit is '1', it indicates 2nd PF belongs to one of the
-	 * hosts defined in the input request.
-	 */
-	#define HWRM_FUNC_HOST_PF_IDS_QUERY_OUTPUT_PF_ORDINAL_MASK_FUNC_1	UINT32_C(0x2)
-	/*
-	 * When this bit is '1', it indicates 3rd PF belongs to one of the
-	 * hosts defined in the input request.
-	 */
-	#define HWRM_FUNC_HOST_PF_IDS_QUERY_OUTPUT_PF_ORDINAL_MASK_FUNC_2	UINT32_C(0x4)
-	/*
-	 * When this bit is '1', it indicates 4th PF belongs to one of the
-	 * hosts defined in the input request.
-	 */
-	#define HWRM_FUNC_HOST_PF_IDS_QUERY_OUTPUT_PF_ORDINAL_MASK_FUNC_3	UINT32_C(0x8)
-	/*
-	 * When this bit is '1', it indicates 5th PF belongs to one of the
-	 * hosts defined in the input request.
-	 */
-	#define HWRM_FUNC_HOST_PF_IDS_QUERY_OUTPUT_PF_ORDINAL_MASK_FUNC_4	UINT32_C(0x10)
+	uint32_t	flags;
 	/*
-	 * When this bit is '1', it indicates 6th PF belongs to one of the
-	 * hosts defined in the input request.
+	 * Enumeration denoting the RX, TX type of the resource.
+	 * This enumeration is used for resources that are similar for both
+	 * TX and RX paths of the chip.
 	 */
-	#define HWRM_FUNC_HOST_PF_IDS_QUERY_OUTPUT_PF_ORDINAL_MASK_FUNC_5	UINT32_C(0x20)
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_FLAGS_PATH	UINT32_C(0x1)
+	/* tx path */
+		#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_FLAGS_PATH_TX	UINT32_C(0x0)
+	/* rx path */
+		#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_FLAGS_PATH_RX	UINT32_C(0x1)
+		#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_FLAGS_PATH_LAST	HWRM_CFA_EM_FLOW_ALLOC_INPUT_FLAGS_PATH_RX
 	/*
-	 * When this bit is '1', it indicates 7th PF belongs to one of the
-	 * hosts defined in the input request.
+	 * Setting of this flag indicates enabling of a byte counter for a
+	 * given flow.
 	 */
-	#define HWRM_FUNC_HOST_PF_IDS_QUERY_OUTPUT_PF_ORDINAL_MASK_FUNC_6	UINT32_C(0x40)
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_FLAGS_BYTE_CTR	UINT32_C(0x2)
 	/*
-	 * When this bit is '1', it indicates 8th PF belongs to one of the
-	 * hosts defined in the input request.
+	 * Setting of this flag indicates enabling of a packet counter for a
+	 * given flow.
 	 */
-	#define HWRM_FUNC_HOST_PF_IDS_QUERY_OUTPUT_PF_ORDINAL_MASK_FUNC_7	UINT32_C(0x80)
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_FLAGS_PKT_CTR	UINT32_C(0x4)
 	/*
-	 * When this bit is '1', it indicates 9th PF belongs to one of the
-	 * hosts defined in the input request.
+	 * Setting of this flag indicates de-capsulation action for the
+	 * given flow.
 	 */
-	#define HWRM_FUNC_HOST_PF_IDS_QUERY_OUTPUT_PF_ORDINAL_MASK_FUNC_8	UINT32_C(0x100)
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_FLAGS_DECAP	UINT32_C(0x8)
 	/*
-	 * When this bit is '1', it indicates 10th PF belongs to one of the
-	 * hosts defined in the input request.
+	 * Setting of this flag indicates encapsulation action for the
+	 * given flow.
 	 */
-	#define HWRM_FUNC_HOST_PF_IDS_QUERY_OUTPUT_PF_ORDINAL_MASK_FUNC_9	UINT32_C(0x200)
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_FLAGS_ENCAP	UINT32_C(0x10)
 	/*
-	 * When this bit is '1', it indicates 11th PF belongs to one of the
-	 * hosts defined in the input request.
+	 * Setting of this flag indicates drop action. If this flag is not
+	 * set, then it should be considered accept action.
 	 */
-	#define HWRM_FUNC_HOST_PF_IDS_QUERY_OUTPUT_PF_ORDINAL_MASK_FUNC_10	UINT32_C(0x400)
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_FLAGS_DROP	UINT32_C(0x20)
 	/*
-	 * When this bit is '1', it indicates 12th PF belongs to one of the
-	 * hosts defined in the input request.
+	 * Setting of this flag indicates that a meter is expected to be
+	 * attached to this flow. This hint can be used when choosing the
+	 * action record format required for the flow.
 	 */
-	#define HWRM_FUNC_HOST_PF_IDS_QUERY_OUTPUT_PF_ORDINAL_MASK_FUNC_11	UINT32_C(0x800)
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_FLAGS_METER	UINT32_C(0x40)
+	uint32_t	enables;
 	/*
-	 * When this bit is '1', it indicates 13th PF belongs to one of the
-	 * hosts defined in the input request.
+	 * This bit must be '1' for the l2_filter_id field to be
+	 * configured.
 	 */
-	#define HWRM_FUNC_HOST_PF_IDS_QUERY_OUTPUT_PF_ORDINAL_MASK_FUNC_12	UINT32_C(0x1000)
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_L2_FILTER_ID	UINT32_C(0x1)
 	/*
-	 * When this bit is '1', it indicates 14th PF belongs to one of the
-	 * hosts defined in the input request.
+	 * This bit must be '1' for the tunnel_type field to be
+	 * configured.
 	 */
-	#define HWRM_FUNC_HOST_PF_IDS_QUERY_OUTPUT_PF_ORDINAL_MASK_FUNC_13	UINT32_C(0x2000)
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_TUNNEL_TYPE	UINT32_C(0x2)
 	/*
-	 * When this bit is '1', it indicates 15th PF belongs to one of the
-	 * hosts defined in the input request.
+	 * This bit must be '1' for the tunnel_id field to be
+	 * configured.
 	 */
-	#define HWRM_FUNC_HOST_PF_IDS_QUERY_OUTPUT_PF_ORDINAL_MASK_FUNC_14	UINT32_C(0x4000)
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_TUNNEL_ID		UINT32_C(0x4)
 	/*
-	 * When this bit is '1', it indicates 16th PF belongs to one of the
-	 * hosts defined in the input request.
+	 * This bit must be '1' for the src_macaddr field to be
+	 * configured.
 	 */
-	#define HWRM_FUNC_HOST_PF_IDS_QUERY_OUTPUT_PF_ORDINAL_MASK_FUNC_15	UINT32_C(0x8000)
-	uint8_t	unused_1[3];
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_SRC_MACADDR	UINT32_C(0x8)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * This bit must be '1' for the dst_macaddr field to be
+	 * configured.
 	 */
-	uint8_t	valid;
-} hwrm_func_host_pf_ids_query_output_t, *phwrm_func_host_pf_ids_query_output_t;
-
-/*********************
- * hwrm_func_spd_cfg *
- *********************/
-
-
-/* hwrm_func_spd_cfg_input (size:384b/48B) */
-
-typedef struct hwrm_func_spd_cfg_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_DST_MACADDR	UINT32_C(0x10)
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * This bit must be '1' for the ovlan_vid field to be
+	 * configured.
 	 */
-	uint16_t	cmpl_ring;
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_OVLAN_VID		UINT32_C(0x20)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * This bit must be '1' for the ivlan_vid field to be
+	 * configured.
 	 */
-	uint16_t	seq_id;
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_IVLAN_VID		UINT32_C(0x40)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * This bit must be '1' for the ethertype field to be
+	 * configured.
 	 */
-	uint16_t	target_id;
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_ETHERTYPE		UINT32_C(0x80)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * This bit must be '1' for the src_ipaddr field to be
+	 * configured.
 	 */
-	uint64_t	resp_addr;
-	uint32_t	flags;
-	/* Set this bit is '1' to enable the SPD datapath forwarding. */
-	#define HWRM_FUNC_SPD_CFG_INPUT_FLAGS_FWD_ENABLE	UINT32_C(0x1)
-	/* Set this bit is '1' to disable the SPD datapath forwarding. */
-	#define HWRM_FUNC_SPD_CFG_INPUT_FLAGS_FWD_DISABLE	UINT32_C(0x2)
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_SRC_IPADDR		UINT32_C(0x100)
 	/*
-	 * Set this bit is '1' to enable the SPD datapath checksum
-	 * feature.
+	 * This bit must be '1' for the dst_ipaddr field to be
+	 * configured.
 	 */
-	#define HWRM_FUNC_SPD_CFG_INPUT_FLAGS_CSUM_ENABLE	UINT32_C(0x4)
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_DST_IPADDR		UINT32_C(0x200)
 	/*
-	 * Set this bit is '1' to disable the SPD datapath checksum
-	 * feature.
+	 * This bit must be '1' for the ipaddr_type field to be
+	 * configured.
 	 */
-	#define HWRM_FUNC_SPD_CFG_INPUT_FLAGS_CSUM_DISABLE	UINT32_C(0x8)
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_IPADDR_TYPE	UINT32_C(0x400)
 	/*
-	 * Set this bit is '1' to enable the SPD datapath debug
-	 * feature.
+	 * This bit must be '1' for the ip_protocol field to be
+	 * configured.
 	 */
-	#define HWRM_FUNC_SPD_CFG_INPUT_FLAGS_DBG_ENABLE	UINT32_C(0x10)
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_IP_PROTOCOL	UINT32_C(0x800)
 	/*
-	 * Set this bit is '1' to disable the SPD datapath debug
-	 * feature.
+	 * This bit must be '1' for the src_port field to be
+	 * configured.
 	 */
-	#define HWRM_FUNC_SPD_CFG_INPUT_FLAGS_DBG_DISABLE	UINT32_C(0x20)
-	uint32_t	enables;
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_SRC_PORT		UINT32_C(0x1000)
 	/*
-	 * This bit must be '1' for the ethertype field to be
+	 * This bit must be '1' for the dst_port field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_SPD_CFG_INPUT_ENABLES_ETHERTYPE		UINT32_C(0x1)
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_DST_PORT		UINT32_C(0x2000)
 	/*
-	 * This bit must be '1' for the hash_mode_flags field to be
+	 * This bit must be '1' for the dst_id field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_SPD_CFG_INPUT_ENABLES_HASH_MODE_FLAGS	UINT32_C(0x2)
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_DST_ID		UINT32_C(0x4000)
 	/*
-	 * This bit must be '1' for the hash_type field to be
+	 * This bit must be '1' for the mirror_vnic_id field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_SPD_CFG_INPUT_ENABLES_HASH_TYPE		UINT32_C(0x4)
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_MIRROR_VNIC_ID	UINT32_C(0x8000)
 	/*
-	 * This bit must be '1' for the ring_tbl_addr field to be
+	 * This bit must be '1' for the encap_record_id field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_SPD_CFG_INPUT_ENABLES_RING_TBL_ADDR	UINT32_C(0x8)
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_ENCAP_RECORD_ID	UINT32_C(0x10000)
 	/*
-	 * This bit must be '1' for the hash_key_tbl_addr field to be
+	 * This bit must be '1' for the meter_instance_id field to be
 	 * configured.
 	 */
-	#define HWRM_FUNC_SPD_CFG_INPUT_ENABLES_HASH_KEY_TBL_ADDR	UINT32_C(0x10)
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_METER_INSTANCE_ID	UINT32_C(0x20000)
 	/*
-	 * Ethertype value used in the encapsulated SPD packet header.
-	 * The user must chooose a value that is not conflicting with
-	 * publicly defined ethertype values. By default, the ethertype
-	 * value of 0xffff is used if there is no user specified value.
+	 * This value identifies a set of CFA data structures used for an L2
+	 * context.
 	 */
-	uint16_t	ethertype;
-	/* Flags to specify different RSS hash modes. */
-	uint8_t	hash_mode_flags;
+	uint64_t	l2_filter_id;
+	/* Tunnel Type. */
+	uint8_t	tunnel_type;
+	/* Non-tunnel */
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_TUNNEL_TYPE_NONTUNNEL	UINT32_C(0x0)
+	/* Virtual eXtensible Local Area Network (VXLAN) */
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_TUNNEL_TYPE_VXLAN	UINT32_C(0x1)
+	/* Network Virtualization Generic Routing Encapsulation (NVGRE) */
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_TUNNEL_TYPE_NVGRE	UINT32_C(0x2)
+	/* Generic Routing Encapsulation (GRE) inside Ethernet payload */
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_TUNNEL_TYPE_L2GRE	UINT32_C(0x3)
+	/* IP in IP */
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_TUNNEL_TYPE_IPIP	UINT32_C(0x4)
+	/* Generic Network Virtualization Encapsulation (Geneve) */
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_TUNNEL_TYPE_GENEVE	UINT32_C(0x5)
+	/* Multi-Protocol Label Switching (MPLS) */
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_TUNNEL_TYPE_MPLS	UINT32_C(0x6)
+	/* Stateless Transport Tunnel (STT) */
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_TUNNEL_TYPE_STT	UINT32_C(0x7)
+	/* Generic Routing Encapsulation (GRE) inside IP datagram payload */
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_TUNNEL_TYPE_IPGRE	UINT32_C(0x8)
+	/* IPV4 over virtual eXtensible Local Area Network (IPV4oVXLAN) */
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_V4	UINT32_C(0x9)
 	/*
-	 * When this bit is '1', it indicates using current RSS
-	 * hash mode setting configured in the device.
+	 * Enhance Generic Routing Encapsulation (GRE version 1) inside IP
+	 * datagram payload
 	 */
-	#define HWRM_FUNC_SPD_CFG_INPUT_HASH_MODE_FLAGS_DEFAULT	UINT32_C(0x1)
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_TUNNEL_TYPE_IPGRE_V1	UINT32_C(0xa)
+	/* Use fixed layer 2 ether type of 0xFFFF */
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_TUNNEL_TYPE_L2_ETYPE	UINT32_C(0xb)
 	/*
-	 * When this bit is '1', it indicates requesting support of
-	 * RSS hashing over innermost 4 tuples {l3.src, l3.dest,
-	 * l4.src, l4.dest} for tunnel packets. For none-tunnel
-	 * packets, the RSS hash is computed over the normal
-	 * src/dest l3 and src/dest l4 headers.
+	 * IPV6 over virtual eXtensible Local Area Network with GPE header
+	 * (IPV6oVXLANGPE)
 	 */
-	#define HWRM_FUNC_SPD_CFG_INPUT_HASH_MODE_FLAGS_INNERMOST_4	UINT32_C(0x2)
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_GPE_V6 UINT32_C(0xc)
+	/* Generic Protocol Extension for VXLAN (VXLAN-GPE) */
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_GPE	UINT32_C(0x10)
+	/* Any tunneled traffic */
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_TUNNEL_TYPE_ANYTUNNEL	UINT32_C(0xff)
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_TUNNEL_TYPE_LAST	HWRM_CFA_EM_FLOW_ALLOC_INPUT_TUNNEL_TYPE_ANYTUNNEL
+	uint8_t	unused_0[3];
 	/*
-	 * When this bit is '1', it indicates requesting support of
-	 * RSS hashing over innermost 2 tuples {l3.src, l3.dest} for
-	 * tunnel packets. For none-tunnel packets, the RSS hash is
-	 * computed over the normal src/dest l3 headers.
+	 * Tunnel identifier.
+	 * Virtual Network Identifier (VNI). Only valid with
+	 * tunnel_types VXLAN, NVGRE, and Geneve.
+	 * Only lower 24-bits of VNI field are used
+	 * in setting up the filter.
 	 */
-	#define HWRM_FUNC_SPD_CFG_INPUT_HASH_MODE_FLAGS_INNERMOST_2	UINT32_C(0x4)
+	uint32_t	tunnel_id;
 	/*
-	 * When this bit is '1', it indicates requesting support of
-	 * RSS hashing over outermost 4 tuples {t_l3.src, t_l3.dest,
-	 * t_l4.src, t_l4.dest} for tunnel packets. For none-tunnel
-	 * packets, the RSS hash is computed over the normal
-	 * src/dest l3 and src/dest l4 headers.
+	 * This value indicates the source MAC address in
+	 * the Ethernet header.
 	 */
-	#define HWRM_FUNC_SPD_CFG_INPUT_HASH_MODE_FLAGS_OUTERMOST_4	UINT32_C(0x8)
+	uint8_t	src_macaddr[6];
+	/* The meter instance to attach to the flow. */
+	uint16_t	meter_instance_id;
 	/*
-	 * When this bit is '1', it indicates requesting support of
-	 * RSS hashing over outermost 2 tuples {t_l3.src, t_l3.dest} for
-	 * tunnel packets. For none-tunnel packets, the RSS hash is
-	 * computed over the normal src/dest l3 headers.
+	 * A value of 0xfff is considered invalid and implies the
+	 * instance is not configured.
 	 */
-	#define HWRM_FUNC_SPD_CFG_INPUT_HASH_MODE_FLAGS_OUTERMOST_2	UINT32_C(0x10)
-	uint8_t	unused_1;
-	uint32_t	hash_type;
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_METER_INSTANCE_ID_INVALID UINT32_C(0xffff)
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_METER_INSTANCE_ID_LAST   HWRM_CFA_EM_FLOW_ALLOC_INPUT_METER_INSTANCE_ID_INVALID
 	/*
-	 * When this bit is '1', the RSS hash shall be computed
-	 * over source and destination IPv4 addresses of IPv4
-	 * packets.
+	 * This value indicates the destination MAC address in
+	 * the Ethernet header.
 	 */
-	#define HWRM_FUNC_SPD_CFG_INPUT_HASH_TYPE_IPV4	UINT32_C(0x1)
+	uint8_t	dst_macaddr[6];
 	/*
-	 * When this bit is '1', the RSS hash shall be computed
-	 * over source/destination IPv4 addresses and
-	 * source/destination ports of TCP/IPv4 packets.
+	 * This value indicates the VLAN ID of the outer VLAN tag
+	 * in the Ethernet header.
 	 */
-	#define HWRM_FUNC_SPD_CFG_INPUT_HASH_TYPE_TCP_IPV4	UINT32_C(0x2)
+	uint16_t	ovlan_vid;
 	/*
-	 * When this bit is '1', the RSS hash shall be computed
-	 * over source/destination IPv4 addresses and
-	 * source/destination ports of UDP/IPv4 packets.
+	 * This value indicates the VLAN ID of the inner VLAN tag
+	 * in the Ethernet header.
 	 */
-	#define HWRM_FUNC_SPD_CFG_INPUT_HASH_TYPE_UDP_IPV4	UINT32_C(0x4)
+	uint16_t	ivlan_vid;
+	/* This value indicates the ethertype in the Ethernet header. */
+	uint16_t	ethertype;
 	/*
-	 * When this bit is '1', the RSS hash shall be computed
-	 * over source and destination IPv4 addresses of IPv6
-	 * packets.
+	 * This value indicates the type of IP address.
+	 * 4 - IPv4
+	 * 6 - IPv6
+	 * All others are invalid.
 	 */
-	#define HWRM_FUNC_SPD_CFG_INPUT_HASH_TYPE_IPV6	UINT32_C(0x8)
+	uint8_t	ip_addr_type;
+	/* invalid */
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_IP_ADDR_TYPE_UNKNOWN UINT32_C(0x0)
+	/* IPv4 */
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_IP_ADDR_TYPE_IPV4	UINT32_C(0x4)
+	/* IPv6 */
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_IP_ADDR_TYPE_IPV6	UINT32_C(0x6)
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_IP_ADDR_TYPE_LAST   HWRM_CFA_EM_FLOW_ALLOC_INPUT_IP_ADDR_TYPE_IPV6
 	/*
-	 * When this bit is '1', the RSS hash shall be computed
-	 * over source/destination IPv6 addresses and
-	 * source/destination ports of TCP/IPv6 packets.
+	 * The value of protocol field in IP header.
+	 * Applies to UDP and TCP traffic.
+	 * 6 - TCP
+	 * 17 - UDP
 	 */
-	#define HWRM_FUNC_SPD_CFG_INPUT_HASH_TYPE_TCP_IPV6	UINT32_C(0x10)
+	uint8_t	ip_protocol;
+	/* invalid */
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_IP_PROTOCOL_UNKNOWN UINT32_C(0x0)
+	/* TCP */
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_IP_PROTOCOL_TCP	UINT32_C(0x6)
+	/* UDP */
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_IP_PROTOCOL_UDP	UINT32_C(0x11)
+	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_IP_PROTOCOL_LAST   HWRM_CFA_EM_FLOW_ALLOC_INPUT_IP_PROTOCOL_UDP
+	uint8_t	unused_1[2];
 	/*
-	 * When this bit is '1', the RSS hash shall be computed
-	 * over source/destination IPv6 addresses and
-	 * source/destination ports of UDP/IPv6 packets.
+	 * The value of source IP address to be used in filtering.
+	 * For IPv4, first four bytes represent the IP address.
 	 */
-	#define HWRM_FUNC_SPD_CFG_INPUT_HASH_TYPE_UDP_IPV6	UINT32_C(0x20)
-	/* This is the address for rss ring group table */
-	uint64_t	ring_grp_tbl_addr;
-	/* This is the address for rss hash key table */
-	uint64_t	hash_key_tbl_addr;
-} hwrm_func_spd_cfg_input_t, *phwrm_func_spd_cfg_input_t;
+	uint32_t	src_ipaddr[4];
+	/*
+	 * big_endian = True
+	 *	The value of destination IP address to be used in filtering.
+	 *	For IPv4, first four bytes represent the IP address.
+	 */
+	uint32_t	dst_ipaddr[4];
+	/*
+	 * The value of source port to be used in filtering.
+	 * Applies to UDP and TCP traffic.
+	 */
+	uint16_t	src_port;
+	/*
+	 * The value of destination port to be used in filtering.
+	 * Applies to UDP and TCP traffic.
+	 */
+	uint16_t	dst_port;
+	/*
+	 * If set, this value shall represent the
+	 * Logical VNIC ID of the destination VNIC for the RX
+	 * path and network port id of the destination port for
+	 * the TX path.
+	 */
+	uint16_t	dst_id;
+	/*
+	 * Logical VNIC ID of the VNIC where traffic is
+	 * mirrored.
+	 */
+	uint16_t	mirror_vnic_id;
+	/* Logical ID of the encapsulation record. */
+	uint32_t	encap_record_id;
+	uint8_t	unused_2[4];
+} hwrm_cfa_em_flow_alloc_input_t, *phwrm_cfa_em_flow_alloc_input_t;
 
-/* hwrm_func_spd_cfg_output (size:128b/16B) */
+/* hwrm_cfa_em_flow_alloc_output (size:192b/24B) */
 
-typedef struct hwrm_func_spd_cfg_output {
+typedef struct hwrm_cfa_em_flow_alloc_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -18493,25 +46973,59 @@ typedef struct hwrm_func_spd_cfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	/* This value is an opaque id into CFA data structures. */
+	uint64_t	em_filter_id;
+	/*
+	 * The flow id value in bit 0-29 is the actual ID of the flow
+	 * associated with this filter and it shall be used to match
+	 * and associate the flow identifier returned in completion
+	 * records. A value of 0xFFFFFFFF in the 32-bit flow_id field
+	 * shall indicate no valid flow id.
+	 */
+	uint32_t	flow_id;
+	/* Indicate the flow id value. */
+	#define HWRM_CFA_EM_FLOW_ALLOC_OUTPUT_FLOW_ID_VALUE_MASK UINT32_C(0x3fffffff)
+	#define HWRM_CFA_EM_FLOW_ALLOC_OUTPUT_FLOW_ID_VALUE_SFT 0
+	/* Indicate type of the flow. */
+	#define HWRM_CFA_EM_FLOW_ALLOC_OUTPUT_FLOW_ID_TYPE	UINT32_C(0x40000000)
+	/*
+	 * If this bit set to 0, then it indicates that the flow is
+	 * internal flow.
+	 */
+		#define HWRM_CFA_EM_FLOW_ALLOC_OUTPUT_FLOW_ID_TYPE_INT	(UINT32_C(0x0) << 30)
+	/*
+	 * If this bit is set to 1, then it indicates that the flow is
+	 * external flow.
+	 */
+		#define HWRM_CFA_EM_FLOW_ALLOC_OUTPUT_FLOW_ID_TYPE_EXT	(UINT32_C(0x1) << 30)
+		#define HWRM_CFA_EM_FLOW_ALLOC_OUTPUT_FLOW_ID_TYPE_LAST  HWRM_CFA_EM_FLOW_ALLOC_OUTPUT_FLOW_ID_TYPE_EXT
+	/* Indicate the flow direction. */
+	#define HWRM_CFA_EM_FLOW_ALLOC_OUTPUT_FLOW_ID_DIR	UINT32_C(0x80000000)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_CFA_EM_FLOW_ALLOC_OUTPUT_FLOW_ID_DIR_RX	(UINT32_C(0x0) << 31)
+	/* If this bit is set to 1, then it indicates that tx flow. */
+		#define HWRM_CFA_EM_FLOW_ALLOC_OUTPUT_FLOW_ID_DIR_TX	(UINT32_C(0x1) << 31)
+		#define HWRM_CFA_EM_FLOW_ALLOC_OUTPUT_FLOW_ID_DIR_LAST   HWRM_CFA_EM_FLOW_ALLOC_OUTPUT_FLOW_ID_DIR_TX
+	uint8_t	unused_0[3];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_func_spd_cfg_output_t, *phwrm_func_spd_cfg_output_t;
+} hwrm_cfa_em_flow_alloc_output_t, *phwrm_cfa_em_flow_alloc_output_t;
 
-/**********************
- * hwrm_func_spd_qcfg *
- **********************/
+/*************************
+ * hwrm_cfa_em_flow_free *
+ *************************/
 
 
-/* hwrm_func_spd_qcfg_input (size:128b/16B) */
+/* hwrm_cfa_em_flow_free_input (size:192b/24B) */
 
-typedef struct hwrm_func_spd_qcfg_input {
+typedef struct hwrm_cfa_em_flow_free_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -18540,11 +47054,13 @@ typedef struct hwrm_func_spd_qcfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-} hwrm_func_spd_qcfg_input_t, *phwrm_func_spd_qcfg_input_t;
+	/* This value is an opaque id into CFA data structures. */
+	uint64_t	em_filter_id;
+} hwrm_cfa_em_flow_free_input_t, *phwrm_cfa_em_flow_free_input_t;
 
-/* hwrm_func_spd_qcfg_output (size:512b/64B) */
+/* hwrm_cfa_em_flow_free_output (size:128b/16B) */
 
-typedef struct hwrm_func_spd_qcfg_output {
+typedef struct hwrm_cfa_em_flow_free_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -18553,125 +47069,131 @@ typedef struct hwrm_func_spd_qcfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint32_t	flags;
-	/*
-	 * The SPD datapath forwarding is currently enabled when this
-	 * flag is set to '1'.
-	 */
-	#define HWRM_FUNC_SPD_QCFG_OUTPUT_FLAGS_FWD_ENABLED	UINT32_C(0x1)
-	/*
-	 * The SPD datapath checksum feature is currently enabled when
-	 * this flag is set to '1'.
-	 */
-	#define HWRM_FUNC_SPD_QCFG_OUTPUT_FLAGS_CSUM_ENABLED	UINT32_C(0x2)
-	/*
-	 * The SPD datapath debug feature is currently enabled when
-	 * this flag is set to '1'.
-	 */
-	#define HWRM_FUNC_SPD_QCFG_OUTPUT_FLAGS_DBG_ENABLED	UINT32_C(0x4)
-	uint32_t	hash_type;
+	uint8_t	unused_0[7];
 	/*
-	 * When this bit is '1', the RSS hash shall be computed
-	 * over source and destination IPv4 addresses of IPv4
-	 * packets.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	#define HWRM_FUNC_SPD_QCFG_OUTPUT_HASH_TYPE_IPV4	UINT32_C(0x1)
+	uint8_t	valid;
+} hwrm_cfa_em_flow_free_output_t, *phwrm_cfa_em_flow_free_output_t;
+
+/************************
+ * hwrm_cfa_em_flow_cfg *
+ ************************/
+
+
+/* hwrm_cfa_em_flow_cfg_input (size:384b/48B) */
+
+typedef struct hwrm_cfa_em_flow_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * When this bit is '1', the RSS hash shall be computed
-	 * over source/destination IPv4 addresses and
-	 * source/destination ports of TCP/IPv4 packets.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define HWRM_FUNC_SPD_QCFG_OUTPUT_HASH_TYPE_TCP_IPV4	UINT32_C(0x2)
+	uint16_t	cmpl_ring;
 	/*
-	 * When this bit is '1', the RSS hash shall be computed
-	 * over source/destination IPv4 addresses and
-	 * source/destination ports of UDP/IPv4 packets.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define HWRM_FUNC_SPD_QCFG_OUTPUT_HASH_TYPE_UDP_IPV4	UINT32_C(0x4)
+	uint16_t	seq_id;
 	/*
-	 * When this bit is '1', the RSS hash shall be computed
-	 * over source and destination IPv4 addresses of IPv6
-	 * packets.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define HWRM_FUNC_SPD_QCFG_OUTPUT_HASH_TYPE_IPV6	UINT32_C(0x8)
+	uint16_t	target_id;
 	/*
-	 * When this bit is '1', the RSS hash shall be computed
-	 * over source/destination IPv6 addresses and
-	 * source/destination ports of TCP/IPv6 packets.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define HWRM_FUNC_SPD_QCFG_OUTPUT_HASH_TYPE_TCP_IPV6	UINT32_C(0x10)
+	uint64_t	resp_addr;
+	uint32_t	enables;
 	/*
-	 * When this bit is '1', the RSS hash shall be computed
-	 * over source/destination IPv6 addresses and
-	 * source/destination ports of UDP/IPv6 packets.
+	 * This bit must be '1' for the new_dst_id field to be
+	 * configured.
 	 */
-	#define HWRM_FUNC_SPD_QCFG_OUTPUT_HASH_TYPE_UDP_IPV6	UINT32_C(0x20)
-	/* This is the value of rss hash key */
-	uint32_t	hash_key[10];
-	/* Flags to specify different RSS hash modes. */
-	uint8_t	hash_mode_flags;
+	#define HWRM_CFA_EM_FLOW_CFG_INPUT_ENABLES_NEW_DST_ID		UINT32_C(0x1)
 	/*
-	 * When this bit is '1', it indicates using current RSS
-	 * hash mode setting configured in the device.
+	 * This bit must be '1' for the new_mirror_vnic_id field to be
+	 * configured.
 	 */
-	#define HWRM_FUNC_SPD_QCFG_OUTPUT_HASH_MODE_FLAGS_DEFAULT	UINT32_C(0x1)
+	#define HWRM_CFA_EM_FLOW_CFG_INPUT_ENABLES_NEW_MIRROR_VNIC_ID	UINT32_C(0x2)
 	/*
-	 * When this bit is '1', it indicates requesting support of
-	 * RSS hashing over innermost 4 tuples {l3.src, l3.dest,
-	 * l4.src, l4.dest} for tunnel packets. For none-tunnel
-	 * packets, the RSS hash is computed over the normal
-	 * src/dest l3 and src/dest l4 headers.
+	 * This bit must be '1' for the new_meter_instance_id field to be
+	 * configured.
 	 */
-	#define HWRM_FUNC_SPD_QCFG_OUTPUT_HASH_MODE_FLAGS_INNERMOST_4	UINT32_C(0x2)
+	#define HWRM_CFA_EM_FLOW_CFG_INPUT_ENABLES_NEW_METER_INSTANCE_ID	UINT32_C(0x4)
+	uint8_t	unused_0[4];
+	/* This value is an opaque id into CFA data structures. */
+	uint64_t	em_filter_id;
 	/*
-	 * When this bit is '1', it indicates requesting support of
-	 * RSS hashing over innermost 2 tuples {l3.src, l3.dest} for
-	 * tunnel packets. For none-tunnel packets, the RSS hash is
-	 * computed over the normal src/dest l3 headers.
+	 * If set, this value shall represent the new
+	 * Logical VNIC ID of the destination VNIC for the RX
+	 * path and network port id of the destination port for
+	 * the TX path.
 	 */
-	#define HWRM_FUNC_SPD_QCFG_OUTPUT_HASH_MODE_FLAGS_INNERMOST_2	UINT32_C(0x4)
+	uint32_t	new_dst_id;
 	/*
-	 * When this bit is '1', it indicates requesting support of
-	 * RSS hashing over outermost 4 tuples {t_l3.src, t_l3.dest,
-	 * t_l4.src, t_l4.dest} for tunnel packets. For none-tunnel
-	 * packets, the RSS hash is computed over the normal
-	 * src/dest l3 and src/dest l4 headers.
+	 * New Logical VNIC ID of the VNIC where traffic is
+	 * mirrored.
 	 */
-	#define HWRM_FUNC_SPD_QCFG_OUTPUT_HASH_MODE_FLAGS_OUTERMOST_4	UINT32_C(0x8)
+	uint32_t	new_mirror_vnic_id;
 	/*
-	 * When this bit is '1', it indicates requesting support of
-	 * RSS hashing over outermost 2 tuples {t_l3.src, t_l3.dest} for
-	 * tunnel packets. For none-tunnel packets, the RSS hash is
-	 * computed over the normal src/dest l3 headers.
+	 * New meter to attach to the flow. Specifying the
+	 * invalid instance ID is used to remove any existing
+	 * meter from the flow.
 	 */
-	#define HWRM_FUNC_SPD_QCFG_OUTPUT_HASH_MODE_FLAGS_OUTERMOST_2	UINT32_C(0x10)
-	uint8_t	unused_1;
+	uint16_t	new_meter_instance_id;
 	/*
-	 * Ethertype value used in the encapsulated SPD packet header.
-	 * The user must chooose a value that is not conflicting with
-	 * publicly defined ethertype values. By default, the ethertype
-	 * value of 0xffff is used if there is no user specified value.
+	 * A value of 0xfff is considered invalid and implies the
+	 * instance is not configured.
 	 */
-	uint16_t	ethertype;
-	uint8_t	unused_2[3];
+	#define HWRM_CFA_EM_FLOW_CFG_INPUT_NEW_METER_INSTANCE_ID_INVALID UINT32_C(0xffff)
+	#define HWRM_CFA_EM_FLOW_CFG_INPUT_NEW_METER_INSTANCE_ID_LAST   HWRM_CFA_EM_FLOW_CFG_INPUT_NEW_METER_INSTANCE_ID_INVALID
+	uint8_t	unused_1[6];
+} hwrm_cfa_em_flow_cfg_input_t, *phwrm_cfa_em_flow_cfg_input_t;
+
+/* hwrm_cfa_em_flow_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_cfa_em_flow_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_func_spd_qcfg_output_t, *phwrm_func_spd_qcfg_output_t;
+} hwrm_cfa_em_flow_cfg_output_t, *phwrm_cfa_em_flow_cfg_output_t;
 
-/*********************
- * hwrm_port_phy_cfg *
- *********************/
+/************************
+ * hwrm_cfa_meter_qcaps *
+ ************************/
 
 
-/* hwrm_port_phy_cfg_input (size:448b/56B) */
+/* hwrm_cfa_meter_qcaps_input (size:128b/16B) */
 
-typedef struct hwrm_port_phy_cfg_input {
+typedef struct hwrm_cfa_meter_qcaps_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -18700,589 +47222,567 @@ typedef struct hwrm_port_phy_cfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
+} hwrm_cfa_meter_qcaps_input_t, *phwrm_cfa_meter_qcaps_input_t;
+
+/* hwrm_cfa_meter_qcaps_output (size:320b/40B) */
+
+typedef struct hwrm_cfa_meter_qcaps_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
 	uint32_t	flags;
 	/*
-	 * When this bit is set to '1', the PHY for the port shall
-	 * be reset.
-	 *
-	 * # If this bit is set to 1, then the HWRM shall reset the
-	 * PHY after applying PHY configuration changes specified
-	 * in this command.
-	 * # In order to guarantee that PHY configuration changes
-	 * specified in this command take effect, the HWRM
-	 * client should set this flag to 1.
-	 * # If this bit is not set to 1, then the HWRM may reset
-	 * the PHY depending on the current PHY configuration and
-	 * settings specified in this command.
-	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_RESET_PHY		UINT32_C(0x1)
-	/* deprecated bit.  Do not use!!! */
-	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_DEPRECATED		UINT32_C(0x2)
-	/*
-	 * When this bit is set to '1', and the force_pam4_link_speed
-	 * bit in the 'enables' field is '0', the link shall be forced
-	 * to the force_link_speed value.
-	 *
-	 * When this bit is set to '1', and the force_pam4_link_speed
-	 * bit in the 'enables' field is '1', the link shall be forced
-	 * to the force_pam4_link_speed value.
-	 *
-	 * When this bit is set to '1', the HWRM client should
-	 * not enable any of the auto negotiation related
-	 * fields represented by auto_XXX fields in this command.
-	 * When this bit is set to '1' and the HWRM client has
-	 * enabled a auto_XXX field in this command, then the
-	 * HWRM shall ignore the enabled auto_XXX field.
-	 *
-	 * When this bit is set to zero, the link
-	 * shall be allowed to autoneg.
-	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_FORCE			UINT32_C(0x4)
-	/*
-	 * When this bit is set to '1', the auto-negotiation process
-	 * shall be restarted on the link.
-	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_RESTART_AUTONEG		UINT32_C(0x8)
-	/*
-	 * When this bit is set to '1', Energy Efficient Ethernet
-	 * (EEE) is requested to be enabled on this link.
-	 * If EEE is not supported on this port, then this flag
-	 * shall be ignored by the HWRM.
-	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_EEE_ENABLE		UINT32_C(0x10)
-	/*
-	 * When this bit is set to '1', Energy Efficient Ethernet
-	 * (EEE) is requested to be disabled on this link.
-	 * If EEE is not supported on this port, then this flag
-	 * shall be ignored by the HWRM.
-	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_EEE_DISABLE		UINT32_C(0x20)
-	/*
-	 * When this bit is set to '1' and EEE is enabled on this
-	 * link, then TX LPI is requested to be enabled on the link.
-	 * If EEE is not supported on this port, then this flag
-	 * shall be ignored by the HWRM.
-	 * If EEE is disabled on this port, then this flag shall be
-	 * ignored by the HWRM.
-	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_EEE_TX_LPI_ENABLE	UINT32_C(0x40)
-	/*
-	 * When this bit is set to '1' and EEE is enabled on this
-	 * link, then TX LPI is requested to be disabled on the link.
-	 * If EEE is not supported on this port, then this flag
-	 * shall be ignored by the HWRM.
-	 * If EEE is disabled on this port, then this flag shall be
-	 * ignored by the HWRM.
-	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_EEE_TX_LPI_DISABLE	UINT32_C(0x80)
-	/*
-	 * When set to 1, then the HWRM shall enable FEC autonegotitation
-	 * on this port if supported.  When enabled, at least one of the
-	 * FEC modes must be advertised by enabling the fec_clause_74_enable,
-	 * fec_clause_91_enable, fec_rs544_1xn_enable, fec_rs544_ieee_enable,
-	 * fec_rs272_1xn_enable, or fec_rs272_ieee_enable flag.  If none
-	 * of the FEC mode is currently enabled, the HWRM shall choose
-	 * a default advertisement setting.
-	 * The default advertisement setting can be queried by calling
-	 * hwrm_port_phy_qcfg.  Note that the link speed must be
-	 * in autonegotiation mode for FEC autonegotiation to take effect.
-	 * When set to 0, then this flag shall be ignored.
-	 * If FEC autonegotiation is not supported, then the HWRM shall ignore this
-	 * flag.
-	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_FEC_AUTONEG_ENABLE	UINT32_C(0x100)
-	/*
-	 * When set to 1, then the HWRM shall disable FEC autonegotiation
-	 * on this port and use forced FEC mode.  In forced FEC mode, one
-	 * or more FEC forced settings under the same clause can be set.
-	 * When set to 0, then this flag shall be ignored.
-	 * If FEC autonegotiation is not supported, then the HWRM shall ignore this
-	 * flag.
-	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_FEC_AUTONEG_DISABLE	UINT32_C(0x200)
-	/*
-	 * When set to 1, then the HWRM shall enable FEC CLAUSE 74 (Fire Code)
-	 * on this port if supported, by advertising FEC CLAUSE 74 if
-	 * FEC autonegotiation is enabled or force enabled otherwise.
-	 * When set to 0, then this flag shall be ignored.
-	 * If FEC CLAUSE 74 is not supported, then the HWRM shall ignore this
-	 * flag.
-	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_FEC_CLAUSE74_ENABLE	UINT32_C(0x400)
-	/*
-	 * When set to 1, then the HWRM shall disable FEC CLAUSE 74 (Fire Code)
-	 * on this port if supported, by not advertising FEC CLAUSE 74 if
-	 * FEC autonegotiation is enabled or force disabled otherwise.
-	 * When set to 0, then this flag shall be ignored.
-	 * If FEC CLAUSE 74 is not supported, then the HWRM shall ignore this
-	 * flag.
-	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_FEC_CLAUSE74_DISABLE	UINT32_C(0x800)
-	/*
-	 * When set to 1, then the HWRM shall enable FEC CLAUSE 91
-	 * (Reed Solomon RS(528,514) for NRZ) on this port if supported,
-	 * by advertising FEC RS(528,514) if FEC autonegotiation is enabled
-	 * or force enabled otherwise.  In forced FEC mode, this flag
-	 * will only take effect if the speed is NRZ.  Additional
-	 * RS544 or RS272 flags (also under clause 91) may be set for PAM4
-	 * in forced FEC mode.
-	 * When set to 0, then this flag shall be ignored.
-	 * If FEC RS(528,514) is not supported, then the HWRM shall ignore
-	 * this flag.
-	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_FEC_CLAUSE91_ENABLE	UINT32_C(0x1000)
-	/*
-	 * When set to 1, then the HWRM shall disable FEC CLAUSE 91
-	 * (Reed Solomon RS(528,514) for NRZ) on this port if supported, by
-	 * not advertising RS(528,514) if FEC autonegotiation is enabled or
-	 * force disabled otherwise.  When set to 0, then this flag shall be
-	 * ignored.  If FEC RS(528,514) is not supported, then the HWRM
-	 * shall ignore this flag.
-	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_FEC_CLAUSE91_DISABLE	UINT32_C(0x2000)
-	/*
-	 * When this bit is set to '1', the link shall be forced to
-	 * be taken down.
-	 *
-	 * # When this bit is set to '1", all other
-	 * command input settings related to the link speed shall
-	 * be ignored.
-	 * Once the link state is forced down, it can be
-	 * explicitly cleared from that state by setting this flag
-	 * to '0'.
-	 * # If this flag is set to '0', then the link shall be
-	 * cleared from forced down state if the link is in forced
-	 * down state.
-	 * There may be conditions (e.g. out-of-band or sideband
-	 * configuration changes for the link) outside the scope
-	 * of the HWRM implementation that may clear forced down
-	 * link state.
-	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_FORCE_LINK_DWN		UINT32_C(0x4000)
-	/*
-	 * When set to 1, then the HWRM shall enable FEC RS544_1XN
-	 * on this port if supported, by advertising FEC RS544_1XN if
-	 * FEC autonegotiation is enabled or force enabled otherwise.
-	 * In forced mode, this flag will only take effect if the speed is
-	 * PAM4.  If this flag and fec_rs544_ieee_enable are set, the
-	 * HWRM shall choose one of the RS544 modes.
-	 * When set to 0, then this flag shall be ignored.
-	 * If FEC RS544_1XN is not supported, then the HWRM shall ignore this
-	 * flag.
-	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_FEC_RS544_1XN_ENABLE	UINT32_C(0x8000)
-	/*
-	 * When set to 1, then the HWRM shall disable FEC RS544_1XN
-	 * on this port if supported, by not advertising FEC RS544_1XN if
-	 * FEC autonegotiation is enabled or force disabled otherwise.
-	 * When set to 0, then this flag shall be ignored.
-	 * If FEC RS544_1XN  is not supported, then the HWRM shall ignore this
-	 * flag.
-	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_FEC_RS544_1XN_DISABLE	UINT32_C(0x10000)
-	/*
-	 * When set to 1, then the HWRM shall enable FEC RS(544,514)
-	 * on this port if supported, by advertising FEC RS(544,514) if
-	 * FEC autonegotiation is enabled or force enabled otherwise.
-	 * In forced mode, this flag will only take effect if the speed is
-	 * PAM4.  If this flag and fec_rs544_1xn_enable are set, the
-	 * HWRM shall choose one of the RS544 modes.
-	 * When set to 0, then this flag shall be ignored.
-	 * If FEC RS(544,514) is not supported, then the HWRM shall ignore
-	 * this flag.
-	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_FEC_RS544_IEEE_ENABLE	UINT32_C(0x20000)
-	/*
-	 * When set to 1, then the HWRM shall disable FEC RS(544,514)
-	 * on this port if supported, by not advertising FEC RS(544,514) if
-	 * FEC autonegotiation is enabled or force disabled otherwise.
-	 * When set to 0, then this flag shall be ignored.
-	 * If FEC RS(544,514) is not supported, then the HWRM shall ignore
-	 * this flag.
-	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_FEC_RS544_IEEE_DISABLE	UINT32_C(0x40000)
-	/*
-	 * When set to 1, then the HWRM shall enable FEC RS272_1XN
-	 * on this port if supported, by advertising FEC RS272_1XN if
-	 * FEC autonegotiation is enabled or force enabled otherwise.
-	 * In forced mode, this flag will only take effect if the speed is
-	 * PAM4.  If this flag and fec_rs272_ieee_enable are set, the
-	 * HWRM shall choose one of the RS272 modes.  Note that RS272
-	 * and RS544 modes cannot be set at the same time in forced FEC mode.
-	 * When set to 0, then this flag shall be ignored.
-	 * If FEC RS272_1XN is not supported, then the HWRM shall ignore this
-	 * flag.
-	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_FEC_RS272_1XN_ENABLE	UINT32_C(0x80000)
-	/*
-	 * When set to 1, then the HWRM shall disable FEC RS272_1XN
-	 * on this port if supported, by not advertising FEC RS272_1XN if
-	 * FEC autonegotiation is enabled or force disabled otherwise.
-	 * When set to 0, then this flag shall be ignored.
-	 * If FEC RS272_1XN is not supported, then the HWRM shall ignore
-	 * this flag.
-	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_FEC_RS272_1XN_DISABLE	UINT32_C(0x100000)
-	/*
-	 * When set to 1, then the HWRM shall enable FEC RS(272,257)
-	 * on this port if supported, by advertising FEC RS(272,257) if
-	 * FEC autonegotiation is enabled or force enabled otherwise.
-	 * In forced mode, this flag will only take effect if the speed is
-	 * PAM4.  If this flag and fec_rs272_1xn_enable are set, the
-	 * HWRM shall choose one of the RS272 modes.  Note that RS272
-	 * and RS544 modes cannot be set at the same time in forced FEC mode.
-	 * When set to 0, then this flag shall be ignored.
-	 * If FEC RS(272,257) is not supported, then the HWRM shall ignore
-	 * this flag.
-	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_FEC_RS272_IEEE_ENABLE	UINT32_C(0x200000)
-	/*
-	 * When set to 1, then the HWRM shall disable FEC RS(272,257)
-	 * on this port if supported, by not advertising FEC RS(272,257) if
-	 * FEC autonegotiation is enabled or force disabled otherwise.
-	 * When set to 0, then this flag shall be ignored.
-	 * If FEC RS(272,257) is not supported, then the HWRM shall ignore
-	 * this flag.
+	 * Enumeration denoting the clock at which the Meter is running
+	 * with. This enumeration is used for resources that are similar
+	 * for both TX and RX paths of the chip.
 	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_FLAGS_FEC_RS272_IEEE_DISABLE	UINT32_C(0x400000)
-	uint32_t	enables;
+	#define HWRM_CFA_METER_QCAPS_OUTPUT_FLAGS_CLOCK_MASK  UINT32_C(0xf)
+	#define HWRM_CFA_METER_QCAPS_OUTPUT_FLAGS_CLOCK_SFT   0
+	/* 375 MHz */
+		#define HWRM_CFA_METER_QCAPS_OUTPUT_FLAGS_CLOCK_375MHZ  UINT32_C(0x0)
+	/* 625 MHz */
+		#define HWRM_CFA_METER_QCAPS_OUTPUT_FLAGS_CLOCK_625MHZ  UINT32_C(0x1)
+		#define HWRM_CFA_METER_QCAPS_OUTPUT_FLAGS_CLOCK_LAST   HWRM_CFA_METER_QCAPS_OUTPUT_FLAGS_CLOCK_625MHZ
+	uint8_t	unused_0[4];
 	/*
-	 * This bit must be '1' for the auto_mode field to be
-	 * configured.
+	 * The minimum guaranteed number of tx meter profiles supported
+	 * for this function.
 	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_MODE			UINT32_C(0x1)
+	uint16_t	min_tx_profile;
 	/*
-	 * This bit must be '1' for the auto_duplex field to be
-	 * configured.
+	 * The maximum non-guaranteed number of tx meter profiles supported
+	 * for this function.
 	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_DUPLEX		UINT32_C(0x2)
+	uint16_t	max_tx_profile;
 	/*
-	 * This bit must be '1' for the auto_pause field to be
-	 * configured.
+	 * The minimum guaranteed number of rx meter profiles supported
+	 * for this function.
 	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_PAUSE			UINT32_C(0x4)
+	uint16_t	min_rx_profile;
 	/*
-	 * This bit must be '1' for the auto_link_speed field to be
-	 * configured.
+	 * The maximum non-guaranteed number of rx meter profiles supported
+	 * for this function.
 	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_LINK_SPEED		UINT32_C(0x8)
+	uint16_t	max_rx_profile;
 	/*
-	 * This bit must be '1' for the auto_link_speed_mask field to be
-	 * configured.
+	 * The minimum guaranteed number of tx meter instances supported
+	 * for this function.
 	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_LINK_SPEED_MASK	UINT32_C(0x10)
+	uint16_t	min_tx_instance;
 	/*
-	 * This bit must be '1' for the wirespeed field to be
-	 * configured.
+	 * The maximum non-guaranteed number of tx meter instances supported
+	 * for this function.
 	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_ENABLES_WIRESPEED			UINT32_C(0x20)
+	uint16_t	max_tx_instance;
 	/*
-	 * This bit must be '1' for the lpbk field to be
-	 * configured.
+	 * The minimum guaranteed number of rx meter instances supported
+	 * for this function.
 	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_ENABLES_LPBK			UINT32_C(0x40)
+	uint16_t	min_rx_instance;
 	/*
-	 * This bit must be '1' for the preemphasis field to be
-	 * configured.
+	 * The maximum non-guaranteed number of rx meter instances supported
+	 * for this function.
 	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_ENABLES_PREEMPHASIS		UINT32_C(0x80)
+	uint16_t	max_rx_instance;
+	uint8_t	unused_1[7];
 	/*
-	 * This bit must be '1' for the force_pause field to be
-	 * configured.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_ENABLES_FORCE_PAUSE		UINT32_C(0x100)
+	uint8_t	valid;
+} hwrm_cfa_meter_qcaps_output_t, *phwrm_cfa_meter_qcaps_output_t;
+
+/********************************
+ * hwrm_cfa_meter_profile_alloc *
+ ********************************/
+
+
+/* hwrm_cfa_meter_profile_alloc_input (size:320b/40B) */
+
+typedef struct hwrm_cfa_meter_profile_alloc_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * This bit must be '1' for the eee_link_speed_mask field to be
-	 * configured.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_ENABLES_EEE_LINK_SPEED_MASK	UINT32_C(0x200)
+	uint16_t	cmpl_ring;
 	/*
-	 * This bit must be '1' for the tx_lpi_timer field to be
-	 * configured.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_ENABLES_TX_LPI_TIMER		UINT32_C(0x400)
+	uint16_t	seq_id;
 	/*
-	 * This bit must be '1' for the force_pam4_link_speed field to be
-	 * configured.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_ENABLES_FORCE_PAM4_LINK_SPEED	UINT32_C(0x800)
+	uint16_t	target_id;
 	/*
-	 * This bit must be '1' for the auto_pam4_link_speed_mask field to
-	 * be configured.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_PAM4_LINK_SPEED_MASK	UINT32_C(0x1000)
-	/* Port ID of port that is to be configured. */
-	uint16_t	port_id;
+	uint64_t	resp_addr;
+	uint8_t	flags;
 	/*
-	 * This is the speed that will be used if the force
-	 * bit is '1'.  If unsupported speed is selected, an error
-	 * will be generated.
+	 * Enumeration denoting the RX, TX type of the resource.
+	 * This enumeration is used for resources that are similar for both
+	 * TX and RX paths of the chip.
 	 */
-	uint16_t	force_link_speed;
-	/* 100Mb link speed */
-	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_100MB UINT32_C(0x1)
-	/* 1Gb link speed */
-	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_1GB   UINT32_C(0xa)
-	/* 2Gb link speed */
-	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_2GB   UINT32_C(0x14)
-	/* 25Gb link speed */
-	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_2_5GB UINT32_C(0x19)
-	/* 10Gb link speed */
-	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_10GB  UINT32_C(0x64)
-	/* 20Mb link speed */
-	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_20GB  UINT32_C(0xc8)
-	/* 25Gb link speed */
-	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_25GB  UINT32_C(0xfa)
-	/* 40Gb link speed */
-	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_40GB  UINT32_C(0x190)
-	/* 50Gb link speed */
-	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_50GB  UINT32_C(0x1f4)
-	/* 100Gb link speed */
-	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_100GB UINT32_C(0x3e8)
-	/* 10Mb link speed */
-	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_10MB  UINT32_C(0xffff)
-	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_LAST HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_10MB
+	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_FLAGS_PATH	UINT32_C(0x1)
+	/* tx path */
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_FLAGS_PATH_TX	UINT32_C(0x0)
+	/* rx path */
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_FLAGS_PATH_RX	UINT32_C(0x1)
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_FLAGS_PATH_LAST HWRM_CFA_METER_PROFILE_ALLOC_INPUT_FLAGS_PATH_RX
+	/* The meter algorithm type. */
+	uint8_t	meter_type;
+	/* RFC 2697 (srTCM) */
+	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_METER_TYPE_RFC2697 UINT32_C(0x0)
+	/* RFC 2698 (trTCM) */
+	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_METER_TYPE_RFC2698 UINT32_C(0x1)
+	/* RFC 4115 (trTCM) */
+	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_METER_TYPE_RFC4115 UINT32_C(0x2)
+	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_METER_TYPE_LAST   HWRM_CFA_METER_PROFILE_ALLOC_INPUT_METER_TYPE_RFC4115
 	/*
-	 * This value is used to identify what autoneg mode is
-	 * used when the link speed is not being forced.
+	 * This field is reserved for the future use.
+	 * It shall be set to 0.
 	 */
-	uint8_t	auto_mode;
-	/* Disable autoneg or autoneg disabled. No speeds are selected. */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_NONE	UINT32_C(0x0)
-	/* Select all possible speeds for autoneg mode. */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_ALL_SPEEDS   UINT32_C(0x1)
+	uint16_t	reserved1;
 	/*
-	 * Select only the auto_link_speed speed for autoneg mode. This mode has
-	 * been DEPRECATED. An HWRM client should not use this mode.
+	 * This field is reserved for the future use.
+	 * It shall be set to 0.
 	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_ONE_SPEED	UINT32_C(0x2)
+	uint32_t	reserved2;
+	/* A meter rate specified in bytes-per-second. */
+	uint32_t	commit_rate;
+	/* The bandwidth value. */
+	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_RATE_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_RATE_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_RATE_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_RATE_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_RATE_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_RATE_SCALE_LAST		HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_RATE_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_RATE_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_RATE_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_RATE_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_RATE_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_RATE_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_RATE_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_RATE_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Raw value */
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_RATE_BW_VALUE_UNIT_RAW	(UINT32_C(0x7) << 29)
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_RATE_BW_VALUE_UNIT_LAST	HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_RATE_BW_VALUE_UNIT_RAW
+	/* A meter burst size specified in bytes. */
+	uint32_t	commit_burst;
+	/* The bandwidth value. */
+	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_BURST_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_BURST_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_BURST_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_BURST_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_BURST_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_BURST_SCALE_LAST		HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_BURST_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_BURST_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_BURST_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_BURST_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_BURST_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_BURST_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_BURST_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_BURST_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid value */
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_BURST_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_BURST_BW_VALUE_UNIT_LAST	HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_BURST_BW_VALUE_UNIT_INVALID
+	/* A meter rate specified in bytes-per-second. */
+	uint32_t	excess_peak_rate;
+	/* The bandwidth value. */
+	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_RATE_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_RATE_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_RATE_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_RATE_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_RATE_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_RATE_SCALE_LAST		HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_RATE_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Raw unit */
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_RAW	(UINT32_C(0x7) << 29)
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_LAST	HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_RAW
+	/* A meter burst size specified in bytes. */
+	uint32_t	excess_peak_burst;
+	/* The bandwidth value. */
+	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_BURST_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_BURST_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_BURST_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_BURST_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_BURST_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_BURST_SCALE_LAST		HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_BURST_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_LAST	HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_INVALID
+} hwrm_cfa_meter_profile_alloc_input_t, *phwrm_cfa_meter_profile_alloc_input_t;
+
+/* hwrm_cfa_meter_profile_alloc_output (size:128b/16B) */
+
+typedef struct hwrm_cfa_meter_profile_alloc_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* This value identifies a meter profile in CFA. */
+	uint16_t	meter_profile_id;
 	/*
-	 * Select the auto_link_speed or any speed below that speed for autoneg.
-	 * This mode has been DEPRECATED. An HWRM client should not use this mode.
+	 * A value of 0xfff is considered invalid and implies the
+	 * profile is not configured.
 	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_ONE_OR_BELOW UINT32_C(0x3)
+	#define HWRM_CFA_METER_PROFILE_ALLOC_OUTPUT_METER_PROFILE_ID_INVALID UINT32_C(0xffff)
+	#define HWRM_CFA_METER_PROFILE_ALLOC_OUTPUT_METER_PROFILE_ID_LAST   HWRM_CFA_METER_PROFILE_ALLOC_OUTPUT_METER_PROFILE_ID_INVALID
+	uint8_t	unused_0[5];
 	/*
-	 * Select the speeds based on the corresponding link speed mask values
-	 * that are provided. The included speeds are specified in the
-	 * auto_link_speed and auto_pam4_link_speed fields.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_SPEED_MASK   UINT32_C(0x4)
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_LAST	HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_SPEED_MASK
+	uint8_t	valid;
+} hwrm_cfa_meter_profile_alloc_output_t, *phwrm_cfa_meter_profile_alloc_output_t;
+
+/*******************************
+ * hwrm_cfa_meter_profile_free *
+ *******************************/
+
+
+/* hwrm_cfa_meter_profile_free_input (size:192b/24B) */
+
+typedef struct hwrm_cfa_meter_profile_free_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * This is the duplex setting that will be used if the autoneg_mode
-	 * is "one_speed" or "one_or_below".
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint8_t	auto_duplex;
-	/* Half Duplex will be requested. */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_HALF UINT32_C(0x0)
-	/* Full duplex will be requested. */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_FULL UINT32_C(0x1)
-	/* Both Half and Full dupex will be requested. */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_BOTH UINT32_C(0x2)
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_LAST HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_BOTH
+	uint16_t	cmpl_ring;
 	/*
-	 * This value is used to configure the pause that will be
-	 * used for autonegotiation.
-	 * Add text on the usage of auto_pause and force_pause.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint8_t	auto_pause;
+	uint16_t	seq_id;
 	/*
-	 * When this bit is '1', Generation of tx pause messages
-	 * has been requested. Disabled otherwise.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_PAUSE_TX		UINT32_C(0x1)
+	uint16_t	target_id;
 	/*
-	 * When this bit is '1', Reception of rx pause messages
-	 * has been requested. Disabled otherwise.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_PAUSE_RX		UINT32_C(0x2)
+	uint64_t	resp_addr;
+	uint8_t	flags;
 	/*
-	 * When set to 1, the advertisement of pause is enabled.
-	 *
-	 * # When the auto_mode is not set to none and this flag is
-	 * set to 1, then the auto_pause bits on this port are being
-	 * advertised and autoneg pause results are being interpreted.
-	 * # When the auto_mode is not set to none and this
-	 * flag is set to 0, the pause is forced as indicated in
-	 * force_pause, and also advertised as auto_pause bits, but
-	 * the autoneg results are not interpreted since the pause
-	 * configuration is being forced.
-	 * # When the auto_mode is set to none and this flag is set to
-	 * 1, auto_pause bits should be ignored and should be set to 0.
+	 * Enumeration denoting the RX, TX type of the resource.
+	 * This enumeration is used for resources that are similar for both
+	 * TX and RX paths of the chip.
 	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_PAUSE_AUTONEG_PAUSE	UINT32_C(0x4)
+	#define HWRM_CFA_METER_PROFILE_FREE_INPUT_FLAGS_PATH	UINT32_C(0x1)
+	/* tx path */
+		#define HWRM_CFA_METER_PROFILE_FREE_INPUT_FLAGS_PATH_TX	UINT32_C(0x0)
+	/* rx path */
+		#define HWRM_CFA_METER_PROFILE_FREE_INPUT_FLAGS_PATH_RX	UINT32_C(0x1)
+		#define HWRM_CFA_METER_PROFILE_FREE_INPUT_FLAGS_PATH_LAST HWRM_CFA_METER_PROFILE_FREE_INPUT_FLAGS_PATH_RX
 	uint8_t	unused_0;
+	/* This value identifies a meter profile in CFA. */
+	uint16_t	meter_profile_id;
 	/*
-	 * This is the speed that will be used if the autoneg_mode
-	 * is "one_speed" or "one_or_below".  If an unsupported speed
-	 * is selected, an error will be generated.
-	 */
-	uint16_t	auto_link_speed;
-	/* 100Mb link speed */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_100MB UINT32_C(0x1)
-	/* 1Gb link speed */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_1GB   UINT32_C(0xa)
-	/* 2Gb link speed */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_2GB   UINT32_C(0x14)
-	/* 25Gb link speed */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_2_5GB UINT32_C(0x19)
-	/* 10Gb link speed */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_10GB  UINT32_C(0x64)
-	/* 20Mb link speed */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_20GB  UINT32_C(0xc8)
-	/* 25Gb link speed */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_25GB  UINT32_C(0xfa)
-	/* 40Gb link speed */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_40GB  UINT32_C(0x190)
-	/* 50Gb link speed */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_50GB  UINT32_C(0x1f4)
-	/* 100Gb link speed */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_100GB UINT32_C(0x3e8)
-	/* 10Mb link speed */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_10MB  UINT32_C(0xffff)
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_LAST HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_10MB
-	/*
-	 * This is a mask of link speeds that will be used if
-	 * autoneg_mode is "mask".  If unsupported speed is enabled
-	 * an error will be generated.
-	 */
-	uint16_t	auto_link_speed_mask;
-	/* 100Mb link speed (Half-duplex) */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_100MBHD	UINT32_C(0x1)
-	/* 100Mb link speed (Full-duplex) */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_100MB	UINT32_C(0x2)
-	/* 1Gb link speed (Half-duplex) */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_1GBHD	UINT32_C(0x4)
-	/* 1Gb link speed (Full-duplex) */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_1GB	UINT32_C(0x8)
-	/* 2Gb link speed */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_2GB	UINT32_C(0x10)
-	/* 25Gb link speed */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_2_5GB	UINT32_C(0x20)
-	/* 10Gb link speed */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_10GB	UINT32_C(0x40)
-	/* 20Gb link speed */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_20GB	UINT32_C(0x80)
-	/* 25Gb link speed */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_25GB	UINT32_C(0x100)
-	/* 40Gb link speed */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_40GB	UINT32_C(0x200)
-	/* 50Gb link speed */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_50GB	UINT32_C(0x400)
-	/* 100Gb link speed */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_100GB	UINT32_C(0x800)
-	/* 10Mb link speed (Half-duplex) */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_10MBHD	UINT32_C(0x1000)
-	/* 10Mb link speed (Full-duplex) */
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_10MB	UINT32_C(0x2000)
-	/* This value controls the wirespeed feature. */
-	uint8_t	wirespeed;
-	/* Wirespeed feature is disabled. */
-	#define HWRM_PORT_PHY_CFG_INPUT_WIRESPEED_OFF UINT32_C(0x0)
-	/* Wirespeed feature is enabled. */
-	#define HWRM_PORT_PHY_CFG_INPUT_WIRESPEED_ON  UINT32_C(0x1)
-	#define HWRM_PORT_PHY_CFG_INPUT_WIRESPEED_LAST HWRM_PORT_PHY_CFG_INPUT_WIRESPEED_ON
-	/* This value controls the loopback setting for the PHY. */
-	uint8_t	lpbk;
-	/* No loopback is selected.  Normal operation. */
-	#define HWRM_PORT_PHY_CFG_INPUT_LPBK_NONE	UINT32_C(0x0)
-	/*
-	 * The HW will be configured with local loopback such that
-	 * host data is sent back to the host without modification.
-	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_LPBK_LOCAL	UINT32_C(0x1)
-	/*
-	 * The HW will be configured with remote loopback such that
-	 * port logic will send packets back out the transmitter that
-	 * are received.
+	 * A value of 0xfff is considered invalid and implies the
+	 * profile is not configured.
 	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_LPBK_REMOTE   UINT32_C(0x2)
+	#define HWRM_CFA_METER_PROFILE_FREE_INPUT_METER_PROFILE_ID_INVALID UINT32_C(0xffff)
+	#define HWRM_CFA_METER_PROFILE_FREE_INPUT_METER_PROFILE_ID_LAST   HWRM_CFA_METER_PROFILE_FREE_INPUT_METER_PROFILE_ID_INVALID
+	uint8_t	unused_1[4];
+} hwrm_cfa_meter_profile_free_input_t, *phwrm_cfa_meter_profile_free_input_t;
+
+/* hwrm_cfa_meter_profile_free_output (size:128b/16B) */
+
+typedef struct hwrm_cfa_meter_profile_free_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
 	/*
-	 * The HW will be configured with external loopback such that
-	 * host data is sent on the transmitter and based on the external
-	 * loopback connection the data will be received without modification.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_LPBK_EXTERNAL UINT32_C(0x3)
-	#define HWRM_PORT_PHY_CFG_INPUT_LPBK_LAST	HWRM_PORT_PHY_CFG_INPUT_LPBK_EXTERNAL
+	uint8_t	valid;
+} hwrm_cfa_meter_profile_free_output_t, *phwrm_cfa_meter_profile_free_output_t;
+
+/******************************
+ * hwrm_cfa_meter_profile_cfg *
+ ******************************/
+
+
+/* hwrm_cfa_meter_profile_cfg_input (size:320b/40B) */
+
+typedef struct hwrm_cfa_meter_profile_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * This value is used to configure the pause that will be
-	 * used for force mode.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint8_t	force_pause;
+	uint16_t	cmpl_ring;
 	/*
-	 * When this bit is '1', Generation of tx pause messages
-	 * is supported. Disabled otherwise.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_PAUSE_TX	UINT32_C(0x1)
+	uint16_t	seq_id;
 	/*
-	 * When this bit is '1', Reception of rx pause messages
-	 * is supported. Disabled otherwise.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_PAUSE_RX	UINT32_C(0x2)
-	uint8_t	unused_1;
+	uint16_t	target_id;
 	/*
-	 * This value controls the pre-emphasis to be used for the
-	 * link.  Driver should not set this value (use
-	 * enable.preemphasis = 0) unless driver is sure of setting.
-	 * Normally HWRM FW will determine proper pre-emphasis.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint32_t	preemphasis;
+	uint64_t	resp_addr;
+	uint8_t	flags;
 	/*
-	 * Setting for link speed mask that is used to
-	 * advertise speeds during autonegotiation when EEE is enabled.
-	 * This field is valid only when EEE is enabled.
-	 * The speeds specified in this field shall be a subset of
-	 * speeds specified in auto_link_speed_mask.
-	 * If EEE is enabled,then at least one speed shall be provided
-	 * in this mask.
+	 * Enumeration denoting the RX, TX type of the resource.
+	 * This enumeration is used for resources that are similar for both
+	 * TX and RX paths of the chip.
 	 */
-	uint16_t	eee_link_speed_mask;
-	/* Reserved */
-	#define HWRM_PORT_PHY_CFG_INPUT_EEE_LINK_SPEED_MASK_RSVD1	UINT32_C(0x1)
-	/* 100Mb link speed (Full-duplex) */
-	#define HWRM_PORT_PHY_CFG_INPUT_EEE_LINK_SPEED_MASK_100MB	UINT32_C(0x2)
-	/* Reserved */
-	#define HWRM_PORT_PHY_CFG_INPUT_EEE_LINK_SPEED_MASK_RSVD2	UINT32_C(0x4)
-	/* 1Gb link speed (Full-duplex) */
-	#define HWRM_PORT_PHY_CFG_INPUT_EEE_LINK_SPEED_MASK_1GB	UINT32_C(0x8)
-	/* Reserved */
-	#define HWRM_PORT_PHY_CFG_INPUT_EEE_LINK_SPEED_MASK_RSVD3	UINT32_C(0x10)
-	/* Reserved */
-	#define HWRM_PORT_PHY_CFG_INPUT_EEE_LINK_SPEED_MASK_RSVD4	UINT32_C(0x20)
-	/* 10Gb link speed */
-	#define HWRM_PORT_PHY_CFG_INPUT_EEE_LINK_SPEED_MASK_10GB	UINT32_C(0x40)
+	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_FLAGS_PATH	UINT32_C(0x1)
+	/* tx path */
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_FLAGS_PATH_TX	UINT32_C(0x0)
+	/* rx path */
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_FLAGS_PATH_RX	UINT32_C(0x1)
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_FLAGS_PATH_LAST HWRM_CFA_METER_PROFILE_CFG_INPUT_FLAGS_PATH_RX
+	/* The meter algorithm type. */
+	uint8_t	meter_type;
+	/* RFC 2697 (srTCM) */
+	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_METER_TYPE_RFC2697 UINT32_C(0x0)
+	/* RFC 2698 (trTCM) */
+	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_METER_TYPE_RFC2698 UINT32_C(0x1)
+	/* RFC 4115 (trTCM) */
+	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_METER_TYPE_RFC4115 UINT32_C(0x2)
+	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_METER_TYPE_LAST   HWRM_CFA_METER_PROFILE_CFG_INPUT_METER_TYPE_RFC4115
+	/* This value identifies a meter profile in CFA. */
+	uint16_t	meter_profile_id;
 	/*
-	 * This is the speed that will be used if the force and force_pam4
-	 * bits are '1'.  If unsupported speed is selected, an error
-	 * will be generated.
+	 * A value of 0xfff is considered invalid and implies the
+	 * profile is not configured.
 	 */
-	uint16_t	force_pam4_link_speed;
-	/* 50Gb link speed */
-	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_PAM4_LINK_SPEED_50GB  UINT32_C(0x1f4)
-	/* 100Gb link speed */
-	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_PAM4_LINK_SPEED_100GB UINT32_C(0x3e8)
-	/* 200Gb link speed */
-	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_PAM4_LINK_SPEED_200GB UINT32_C(0x7d0)
-	#define HWRM_PORT_PHY_CFG_INPUT_FORCE_PAM4_LINK_SPEED_LAST HWRM_PORT_PHY_CFG_INPUT_FORCE_PAM4_LINK_SPEED_200GB
+	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_METER_PROFILE_ID_INVALID UINT32_C(0xffff)
+	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_METER_PROFILE_ID_LAST   HWRM_CFA_METER_PROFILE_CFG_INPUT_METER_PROFILE_ID_INVALID
 	/*
-	 * Requested setting of TX LPI timer in microseconds.
-	 * This field is valid only when EEE is enabled and TX LPI is
-	 * enabled.
+	 * This field is reserved for the future use.
+	 * It shall be set to 0.
 	 */
-	uint32_t	tx_lpi_timer;
-	#define HWRM_PORT_PHY_CFG_INPUT_TX_LPI_TIMER_MASK UINT32_C(0xffffff)
-	#define HWRM_PORT_PHY_CFG_INPUT_TX_LPI_TIMER_SFT 0
-	/* This field specifies which PAM4 speeds are enabled for auto mode. */
-	uint16_t	auto_link_pam4_speed_mask;
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_PAM4_SPEED_MASK_50G	UINT32_C(0x1)
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_PAM4_SPEED_MASK_100G	UINT32_C(0x2)
-	#define HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_PAM4_SPEED_MASK_200G	UINT32_C(0x4)
-	uint8_t	unused_2[2];
-} hwrm_port_phy_cfg_input_t, *phwrm_port_phy_cfg_input_t;
+	uint32_t	reserved;
+	/* A meter rate specified in bytes-per-second. */
+	uint32_t	commit_rate;
+	/* The bandwidth value. */
+	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_RATE_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_RATE_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_RATE_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_RATE_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_RATE_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_RATE_SCALE_LAST		HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_RATE_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_RATE_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_RATE_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_RATE_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_RATE_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_RATE_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_RATE_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_RATE_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Raw value */
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_RATE_BW_VALUE_UNIT_RAW	(UINT32_C(0x7) << 29)
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_RATE_BW_VALUE_UNIT_LAST	HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_RATE_BW_VALUE_UNIT_RAW
+	/* A meter burst size specified in bytes. */
+	uint32_t	commit_burst;
+	/* The bandwidth value. */
+	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_BURST_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_BURST_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_BURST_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_BURST_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_BURST_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_BURST_SCALE_LAST		HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_BURST_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_BURST_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_BURST_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_BURST_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_BURST_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_BURST_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_BURST_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_BURST_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid value */
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_BURST_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_BURST_BW_VALUE_UNIT_LAST	HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_BURST_BW_VALUE_UNIT_INVALID
+	/* A meter rate specified in bytes-per-second. */
+	uint32_t	excess_peak_rate;
+	/* The bandwidth value. */
+	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_RATE_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_RATE_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_RATE_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_RATE_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_RATE_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_RATE_SCALE_LAST		HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_RATE_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Raw unit */
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_RAW	(UINT32_C(0x7) << 29)
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_LAST	HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_RAW
+	/* A meter burst size specified in bytes. */
+	uint32_t	excess_peak_burst;
+	/* The bandwidth value. */
+	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_BURST_BW_VALUE_MASK		UINT32_C(0xfffffff)
+	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_BURST_BW_VALUE_SFT		0
+	/* The granularity of the value (bits or bytes). */
+	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_BURST_SCALE			UINT32_C(0x10000000)
+	/* Value is in bits. */
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_BURST_SCALE_BITS		(UINT32_C(0x0) << 28)
+	/* Value is in bytes. */
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_BURST_SCALE_BYTES		(UINT32_C(0x1) << 28)
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_BURST_SCALE_LAST		HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_BURST_SCALE_BYTES
+	/* bw_value_unit is 3 b */
+	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
+	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_SFT	29
+	/* Value is in Mb or MB (base 10). */
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
+	/* Value is in Kb or KB (base 10). */
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
+	/* Value is in bits or bytes. */
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
+	/* Value is in Gb or GB (base 10). */
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
+	/* Value is in 1/100th of a percentage of total bandwidth. */
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
+	/* Invalid unit */
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
+		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_LAST	HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_INVALID
+} hwrm_cfa_meter_profile_cfg_input_t, *phwrm_cfa_meter_profile_cfg_input_t;
 
-/* hwrm_port_phy_cfg_output (size:128b/16B) */
+/* hwrm_cfa_meter_profile_cfg_output (size:128b/16B) */
 
-typedef struct hwrm_port_phy_cfg_output {
+typedef struct hwrm_cfa_meter_profile_cfg_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -19294,51 +47794,23 @@ typedef struct hwrm_port_phy_cfg_output {
 	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_port_phy_cfg_output_t, *phwrm_port_phy_cfg_output_t;
-
-/* hwrm_port_phy_cfg_cmd_err (size:64b/8B) */
-
-typedef struct hwrm_port_phy_cfg_cmd_err {
-	/*
-	 * command specific error codes that goes to
-	 * the cmd_err field in Common HWRM Error Response.
-	 */
-	uint8_t	code;
-	/* Unknown error */
-	#define HWRM_PORT_PHY_CFG_CMD_ERR_CODE_UNKNOWN	UINT32_C(0x0)
-	/* Unable to complete operation due to invalid speed */
-	#define HWRM_PORT_PHY_CFG_CMD_ERR_CODE_ILLEGAL_SPEED UINT32_C(0x1)
-	/*
-	 * retry the command since the phy is not ready.
-	 * retry count is returned in opaque_0.
-	 * This is only valid for the first command and
-	 * this value will not change for successive calls.
-	 * but if a 0 is returned at any time then this should
-	 * be treated as an un recoverable failure,
-	 *
-	 * retry interval in milli seconds is returned in opaque_1.
-	 * This specifies the time that user should wait before
-	 * issuing the next port_phy_cfg command.
-	 */
-	#define HWRM_PORT_PHY_CFG_CMD_ERR_CODE_RETRY	UINT32_C(0x2)
-	#define HWRM_PORT_PHY_CFG_CMD_ERR_CODE_LAST	HWRM_PORT_PHY_CFG_CMD_ERR_CODE_RETRY
-	uint8_t	unused_0[7];
-} hwrm_port_phy_cfg_cmd_err_t, *phwrm_port_phy_cfg_cmd_err_t;
-
-/**********************
- * hwrm_port_phy_qcfg *
- **********************/
+} hwrm_cfa_meter_profile_cfg_output_t, *phwrm_cfa_meter_profile_cfg_output_t;
 
+/*********************************
+ * hwrm_cfa_meter_instance_alloc *
+ *********************************/
 
-/* hwrm_port_phy_qcfg_input (size:192b/24B) */
 
-typedef struct hwrm_port_phy_qcfg_input {
+/* hwrm_cfa_meter_instance_alloc_input (size:192b/24B) */
+
+typedef struct hwrm_cfa_meter_instance_alloc_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -19367,14 +47839,33 @@ typedef struct hwrm_port_phy_qcfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Port ID of port that is to be queried. */
-	uint16_t	port_id;
-	uint8_t	unused_0[6];
-} hwrm_port_phy_qcfg_input_t, *phwrm_port_phy_qcfg_input_t;
+	uint8_t	flags;
+	/*
+	 * Enumeration denoting the RX, TX type of the resource.
+	 * This enumeration is used for resources that are similar for both
+	 * TX and RX paths of the chip.
+	 */
+	#define HWRM_CFA_METER_INSTANCE_ALLOC_INPUT_FLAGS_PATH	UINT32_C(0x1)
+	/* tx path */
+		#define HWRM_CFA_METER_INSTANCE_ALLOC_INPUT_FLAGS_PATH_TX	UINT32_C(0x0)
+	/* rx path */
+		#define HWRM_CFA_METER_INSTANCE_ALLOC_INPUT_FLAGS_PATH_RX	UINT32_C(0x1)
+		#define HWRM_CFA_METER_INSTANCE_ALLOC_INPUT_FLAGS_PATH_LAST HWRM_CFA_METER_INSTANCE_ALLOC_INPUT_FLAGS_PATH_RX
+	uint8_t	unused_0;
+	/* This value identifies a meter profile in CFA. */
+	uint16_t	meter_profile_id;
+	/*
+	 * A value of 0xffff is considered invalid and implies the
+	 * profile is not configured.
+	 */
+	#define HWRM_CFA_METER_INSTANCE_ALLOC_INPUT_METER_PROFILE_ID_INVALID UINT32_C(0xffff)
+	#define HWRM_CFA_METER_INSTANCE_ALLOC_INPUT_METER_PROFILE_ID_LAST   HWRM_CFA_METER_INSTANCE_ALLOC_INPUT_METER_PROFILE_ID_INVALID
+	uint8_t	unused_1[4];
+} hwrm_cfa_meter_instance_alloc_input_t, *phwrm_cfa_meter_instance_alloc_input_t;
 
-/* hwrm_port_phy_qcfg_output (size:768b/96B) */
+/* hwrm_cfa_meter_instance_alloc_output (size:128b/16B) */
 
-typedef struct hwrm_port_phy_qcfg_output {
+typedef struct hwrm_cfa_meter_instance_alloc_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -19383,833 +47874,503 @@ typedef struct hwrm_port_phy_qcfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* This value indicates the current link status. */
-	uint8_t	link;
-	/* There is no link or cable detected. */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_NO_LINK UINT32_C(0x0)
-	/* There is no link, but a cable has been detected. */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SIGNAL  UINT32_C(0x1)
-	/* There is a link. */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_LINK	UINT32_C(0x2)
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_LAST   HWRM_PORT_PHY_QCFG_OUTPUT_LINK_LINK
-	uint8_t	active_fec_signal_mode;
-	/*
-	 * This value indicates the current link signaling mode of the
-	 * connection.
-	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_SIGNAL_MODE_MASK		UINT32_C(0xf)
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_SIGNAL_MODE_SFT		0
-	/* NRZ signaling */
-		#define HWRM_PORT_PHY_QCFG_OUTPUT_SIGNAL_MODE_NRZ		UINT32_C(0x0)
-	/* PAM4 signaling */
-		#define HWRM_PORT_PHY_QCFG_OUTPUT_SIGNAL_MODE_PAM4		UINT32_C(0x1)
-		#define HWRM_PORT_PHY_QCFG_OUTPUT_SIGNAL_MODE_LAST		HWRM_PORT_PHY_QCFG_OUTPUT_SIGNAL_MODE_PAM4
-	/* This value indicates the current active FEC mode. */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_ACTIVE_FEC_MASK		UINT32_C(0xf0)
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_ACTIVE_FEC_SFT		4
-	/* No active FEC */
-		#define HWRM_PORT_PHY_QCFG_OUTPUT_ACTIVE_FEC_FEC_NONE_ACTIVE	(UINT32_C(0x0) << 4)
-	/* FEC CLAUSE 74 (Fire Code) active, autonegotiated or forced. */
-		#define HWRM_PORT_PHY_QCFG_OUTPUT_ACTIVE_FEC_FEC_CLAUSE74_ACTIVE	(UINT32_C(0x1) << 4)
-	/* FEC CLAUSE 91 RS(528,514) active, autonegoatiated or forced. */
-		#define HWRM_PORT_PHY_QCFG_OUTPUT_ACTIVE_FEC_FEC_CLAUSE91_ACTIVE	(UINT32_C(0x2) << 4)
-	/* FEC RS544_1XN active, autonegoatiated or forced. */
-		#define HWRM_PORT_PHY_QCFG_OUTPUT_ACTIVE_FEC_FEC_RS544_1XN_ACTIVE   (UINT32_C(0x3) << 4)
-	/* FEC RS(544,528) active, autonegoatiated or forced. */
-		#define HWRM_PORT_PHY_QCFG_OUTPUT_ACTIVE_FEC_FEC_RS544_IEEE_ACTIVE  (UINT32_C(0x4) << 4)
-	/* FEC RS272_1XN active, autonegotiated or forced. */
-		#define HWRM_PORT_PHY_QCFG_OUTPUT_ACTIVE_FEC_FEC_RS272_1XN_ACTIVE   (UINT32_C(0x5) << 4)
-	/* FEC RS(272,257) active, autonegoatiated or forced. */
-		#define HWRM_PORT_PHY_QCFG_OUTPUT_ACTIVE_FEC_FEC_RS272_IEEE_ACTIVE  (UINT32_C(0x6) << 4)
-		#define HWRM_PORT_PHY_QCFG_OUTPUT_ACTIVE_FEC_LAST		HWRM_PORT_PHY_QCFG_OUTPUT_ACTIVE_FEC_FEC_RS272_IEEE_ACTIVE
-	/*
-	 * This value indicates the current link speed of the connection.
-	 * The signal_mode field indicates if the link is using
-	 * NRZ or PAM4 signaling.
-	 */
-	uint16_t	link_speed;
-	/* 100Mb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_100MB UINT32_C(0x1)
-	/* 1Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_1GB   UINT32_C(0xa)
-	/* 2Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_2GB   UINT32_C(0x14)
-	/* 25Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_2_5GB UINT32_C(0x19)
-	/* 10Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_10GB  UINT32_C(0x64)
-	/* 20Mb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_20GB  UINT32_C(0xc8)
-	/* 25Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_25GB  UINT32_C(0xfa)
-	/* 40Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_40GB  UINT32_C(0x190)
-	/* 50Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_50GB  UINT32_C(0x1f4)
-	/* 100Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_100GB UINT32_C(0x3e8)
-	/* 200Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_200GB UINT32_C(0x7d0)
-	/* 10Mb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_10MB  UINT32_C(0xffff)
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_LAST HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_10MB
-	/*
-	 * This value is indicates the duplex of the current
-	 * configuration.
-	 */
-	uint8_t	duplex_cfg;
-	/* Half Duplex connection. */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_DUPLEX_CFG_HALF UINT32_C(0x0)
-	/* Full duplex connection. */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_DUPLEX_CFG_FULL UINT32_C(0x1)
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_DUPLEX_CFG_LAST HWRM_PORT_PHY_QCFG_OUTPUT_DUPLEX_CFG_FULL
-	/*
-	 * This value is used to indicate the current
-	 * pause configuration. When autoneg is enabled, this value
-	 * represents the autoneg results of pause configuration.
-	 */
-	uint8_t	pause;
-	/*
-	 * When this bit is '1', Generation of tx pause messages
-	 * is supported. Disabled otherwise.
-	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_TX	UINT32_C(0x1)
-	/*
-	 * When this bit is '1', Reception of rx pause messages
-	 * is supported. Disabled otherwise.
-	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_RX	UINT32_C(0x2)
-	/*
-	 * The supported speeds for the port. This is a bit mask.
-	 * For each speed that is supported, the corresponding
-	 * bit will be set to '1'.
-	 */
-	uint16_t	support_speeds;
-	/* 100Mb link speed (Half-duplex) */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_100MBHD	UINT32_C(0x1)
-	/* 100Mb link speed (Full-duplex) */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_100MB	UINT32_C(0x2)
-	/* 1Gb link speed (Half-duplex) */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_1GBHD	UINT32_C(0x4)
-	/* 1Gb link speed (Full-duplex) */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_1GB	UINT32_C(0x8)
-	/* 2Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_2GB	UINT32_C(0x10)
-	/* 25Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_2_5GB	UINT32_C(0x20)
-	/* 10Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_10GB	UINT32_C(0x40)
-	/* 20Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_20GB	UINT32_C(0x80)
-	/* 25Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_25GB	UINT32_C(0x100)
-	/* 40Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_40GB	UINT32_C(0x200)
-	/* 50Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_50GB	UINT32_C(0x400)
-	/* 100Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_100GB	UINT32_C(0x800)
-	/* 10Mb link speed (Half-duplex) */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_10MBHD	UINT32_C(0x1000)
-	/* 10Mb link speed (Full-duplex) */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_10MB	UINT32_C(0x2000)
-	/*
-	 * Current setting of forced link speed.
-	 * When the link speed is not being forced, this
-	 * value shall be set to 0.
-	 */
-	uint16_t	force_link_speed;
-	/* 100Mb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEED_100MB UINT32_C(0x1)
-	/* 1Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEED_1GB   UINT32_C(0xa)
-	/* 2Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEED_2GB   UINT32_C(0x14)
-	/* 25Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEED_2_5GB UINT32_C(0x19)
-	/* 10Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEED_10GB  UINT32_C(0x64)
-	/* 20Mb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEED_20GB  UINT32_C(0xc8)
-	/* 25Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEED_25GB  UINT32_C(0xfa)
-	/* 40Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEED_40GB  UINT32_C(0x190)
-	/* 50Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEED_50GB  UINT32_C(0x1f4)
-	/* 100Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEED_100GB UINT32_C(0x3e8)
-	/* 10Mb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEED_10MB  UINT32_C(0xffff)
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEED_LAST HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_LINK_SPEED_10MB
-	/* Current setting of auto negotiation mode. */
-	uint8_t	auto_mode;
-	/* Disable autoneg or autoneg disabled. No speeds are selected. */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_MODE_NONE	UINT32_C(0x0)
-	/* Select all possible speeds for autoneg mode. */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_MODE_ALL_SPEEDS   UINT32_C(0x1)
-	/*
-	 * Select only the auto_link_speed speed for autoneg mode. This mode has
-	 * been DEPRECATED. An HWRM client should not use this mode.
-	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_MODE_ONE_SPEED	UINT32_C(0x2)
-	/*
-	 * Select the auto_link_speed or any speed below that speed for autoneg.
-	 * This mode has been DEPRECATED. An HWRM client should not use this mode.
-	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_MODE_ONE_OR_BELOW UINT32_C(0x3)
-	/*
-	 * Select the speeds based on the corresponding link speed mask value
-	 * that is provided.
-	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_MODE_SPEED_MASK   UINT32_C(0x4)
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_MODE_LAST	HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_MODE_SPEED_MASK
-	/*
-	 * Current setting of pause autonegotiation.
-	 * Move autoneg_pause flag here.
-	 */
-	uint8_t	auto_pause;
-	/*
-	 * When this bit is '1', Generation of tx pause messages
-	 * has been requested. Disabled otherwise.
-	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_PAUSE_TX		UINT32_C(0x1)
-	/*
-	 * When this bit is '1', Reception of rx pause messages
-	 * has been requested. Disabled otherwise.
-	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_PAUSE_RX		UINT32_C(0x2)
+	/* This value identifies a meter instance in CFA. */
+	uint16_t	meter_instance_id;
 	/*
-	 * When set to 1, the advertisement of pause is enabled.
-	 *
-	 * # When the auto_mode is not set to none and this flag is
-	 * set to 1, then the auto_pause bits on this port are being
-	 * advertised and autoneg pause results are being interpreted.
-	 * # When the auto_mode is not set to none and this
-	 * flag is set to 0, the pause is forced as indicated in
-	 * force_pause, and also advertised as auto_pause bits, but
-	 * the autoneg results are not interpreted since the pause
-	 * configuration is being forced.
-	 * # When the auto_mode is set to none and this flag is set to
-	 * 1, auto_pause bits should be ignored and should be set to 0.
+	 * A value of 0xffff is considered invalid and implies the
+	 * instance is not configured.
 	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_PAUSE_AUTONEG_PAUSE	UINT32_C(0x4)
+	#define HWRM_CFA_METER_INSTANCE_ALLOC_OUTPUT_METER_INSTANCE_ID_INVALID UINT32_C(0xffff)
+	#define HWRM_CFA_METER_INSTANCE_ALLOC_OUTPUT_METER_INSTANCE_ID_LAST   HWRM_CFA_METER_INSTANCE_ALLOC_OUTPUT_METER_INSTANCE_ID_INVALID
+	uint8_t	unused_0[5];
 	/*
-	 * Current setting for auto_link_speed. This field is only
-	 * valid when auto_mode is set to "one_speed" or "one_or_below".
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	uint16_t	auto_link_speed;
-	/* 100Mb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_100MB UINT32_C(0x1)
-	/* 1Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_1GB   UINT32_C(0xa)
-	/* 2Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_2GB   UINT32_C(0x14)
-	/* 25Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_2_5GB UINT32_C(0x19)
-	/* 10Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_10GB  UINT32_C(0x64)
-	/* 20Mb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_20GB  UINT32_C(0xc8)
-	/* 25Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_25GB  UINT32_C(0xfa)
-	/* 40Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_40GB  UINT32_C(0x190)
-	/* 50Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_50GB  UINT32_C(0x1f4)
-	/* 100Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_100GB UINT32_C(0x3e8)
-	/* 10Mb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_10MB  UINT32_C(0xffff)
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_LAST HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_10MB
+	uint8_t	valid;
+} hwrm_cfa_meter_instance_alloc_output_t, *phwrm_cfa_meter_instance_alloc_output_t;
+
+/*******************************
+ * hwrm_cfa_meter_instance_cfg *
+ *******************************/
+
+
+/* hwrm_cfa_meter_instance_cfg_input (size:192b/24B) */
+
+typedef struct hwrm_cfa_meter_instance_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * Current setting for auto_link_speed_mask that is used to
-	 * advertise speeds during autonegotiation.
-	 * This field is only valid when auto_mode is set to "mask".
-	 * The speeds specified in this field shall be a subset of
-	 * supported speeds on this port.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint16_t	auto_link_speed_mask;
-	/* 100Mb link speed (Half-duplex) */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_MASK_100MBHD	UINT32_C(0x1)
-	/* 100Mb link speed (Full-duplex) */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_MASK_100MB	UINT32_C(0x2)
-	/* 1Gb link speed (Half-duplex) */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_MASK_1GBHD	UINT32_C(0x4)
-	/* 1Gb link speed (Full-duplex) */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_MASK_1GB	UINT32_C(0x8)
-	/* 2Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_MASK_2GB	UINT32_C(0x10)
-	/* 25Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_MASK_2_5GB	UINT32_C(0x20)
-	/* 10Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_MASK_10GB	UINT32_C(0x40)
-	/* 20Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_MASK_20GB	UINT32_C(0x80)
-	/* 25Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_MASK_25GB	UINT32_C(0x100)
-	/* 40Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_MASK_40GB	UINT32_C(0x200)
-	/* 50Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_MASK_50GB	UINT32_C(0x400)
-	/* 100Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_MASK_100GB	UINT32_C(0x800)
-	/* 10Mb link speed (Half-duplex) */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_MASK_10MBHD	UINT32_C(0x1000)
-	/* 10Mb link speed (Full-duplex) */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_LINK_SPEED_MASK_10MB	UINT32_C(0x2000)
-	/* Current setting for wirespeed. */
-	uint8_t	wirespeed;
-	/* Wirespeed feature is disabled. */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_WIRESPEED_OFF UINT32_C(0x0)
-	/* Wirespeed feature is enabled. */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_WIRESPEED_ON  UINT32_C(0x1)
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_WIRESPEED_LAST HWRM_PORT_PHY_QCFG_OUTPUT_WIRESPEED_ON
-	/* Current setting for loopback. */
-	uint8_t	lpbk;
-	/* No loopback is selected.  Normal operation. */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LPBK_NONE	UINT32_C(0x0)
+	uint16_t	cmpl_ring;
 	/*
-	 * The HW will be configured with local loopback such that
-	 * host data is sent back to the host without modification.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LPBK_LOCAL	UINT32_C(0x1)
+	uint16_t	seq_id;
 	/*
-	 * The HW will be configured with remote loopback such that
-	 * port logic will send packets back out the transmitter that
-	 * are received.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LPBK_REMOTE   UINT32_C(0x2)
+	uint16_t	target_id;
 	/*
-	 * The HW will be configured with external loopback such that
-	 * host data is sent on the transmitter and based on the external
-	 * loopback connection the data will be received without modification.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LPBK_EXTERNAL UINT32_C(0x3)
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LPBK_LAST	HWRM_PORT_PHY_QCFG_OUTPUT_LPBK_EXTERNAL
+	uint64_t	resp_addr;
+	uint8_t	flags;
 	/*
-	 * Current setting of forced pause.
-	 * When the pause configuration is not being forced, then
-	 * this value shall be set to 0.
+	 * Enumeration denoting the RX, TX type of the resource.
+	 * This enumeration is used for resources that are similar for both
+	 * TX and RX paths of the chip.
 	 */
-	uint8_t	force_pause;
+	#define HWRM_CFA_METER_INSTANCE_CFG_INPUT_FLAGS_PATH	UINT32_C(0x1)
+	/* tx path */
+		#define HWRM_CFA_METER_INSTANCE_CFG_INPUT_FLAGS_PATH_TX	UINT32_C(0x0)
+	/* rx path */
+		#define HWRM_CFA_METER_INSTANCE_CFG_INPUT_FLAGS_PATH_RX	UINT32_C(0x1)
+		#define HWRM_CFA_METER_INSTANCE_CFG_INPUT_FLAGS_PATH_LAST HWRM_CFA_METER_INSTANCE_CFG_INPUT_FLAGS_PATH_RX
+	uint8_t	unused_0;
 	/*
-	 * When this bit is '1', Generation of tx pause messages
-	 * is supported. Disabled otherwise.
+	 * This value identifies a new meter profile to be associated with
+	 * the meter instance specified in this command.
 	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_PAUSE_TX	UINT32_C(0x1)
+	uint16_t	meter_profile_id;
 	/*
-	 * When this bit is '1', Reception of rx pause messages
-	 * is supported. Disabled otherwise.
+	 * A value of 0xffff is considered invalid and implies the
+	 * profile is not configured.
 	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_PAUSE_RX	UINT32_C(0x2)
+	#define HWRM_CFA_METER_INSTANCE_CFG_INPUT_METER_PROFILE_ID_INVALID UINT32_C(0xffff)
+	#define HWRM_CFA_METER_INSTANCE_CFG_INPUT_METER_PROFILE_ID_LAST   HWRM_CFA_METER_INSTANCE_CFG_INPUT_METER_PROFILE_ID_INVALID
 	/*
-	 * This value indicates the current status of the optics module on
-	 * this port.
+	 * This value identifies the ID of a meter instance that needs to be
+	 * updated with a new meter profile specified in this command.
 	 */
-	uint8_t	module_status;
-	/* Module is inserted and accepted */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_MODULE_STATUS_NONE	UINT32_C(0x0)
-	/* Module is rejected and transmit side Laser is disabled. */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_MODULE_STATUS_DISABLETX	UINT32_C(0x1)
-	/* Module mismatch warning. */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_MODULE_STATUS_WARNINGMSG	UINT32_C(0x2)
-	/* Module is rejected and powered down. */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_MODULE_STATUS_PWRDOWN	UINT32_C(0x3)
-	/* Module is not inserted. */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_MODULE_STATUS_NOTINSERTED   UINT32_C(0x4)
-	/* Module is powered down because of over current fault. */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_MODULE_STATUS_CURRENTFAULT  UINT32_C(0x5)
-	/* Module status is not applicable. */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_MODULE_STATUS_NOTAPPLICABLE UINT32_C(0xff)
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_MODULE_STATUS_LAST	HWRM_PORT_PHY_QCFG_OUTPUT_MODULE_STATUS_NOTAPPLICABLE
-	/* Current setting for preemphasis. */
-	uint32_t	preemphasis;
-	/* This field represents the major version of the PHY. */
-	uint8_t	phy_maj;
-	/* This field represents the minor version of the PHY. */
-	uint8_t	phy_min;
-	/* This field represents the build version of the PHY. */
-	uint8_t	phy_bld;
-	/* This value represents a PHY type. */
-	uint8_t	phy_type;
-	/* Unknown */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_UNKNOWN	UINT32_C(0x0)
-	/* BASE-CR */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASECR	UINT32_C(0x1)
-	/* BASE-KR4 (Deprecated) */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR4	UINT32_C(0x2)
-	/* BASE-LR */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASELR	UINT32_C(0x3)
-	/* BASE-SR */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASESR	UINT32_C(0x4)
-	/* BASE-KR2 (Deprecated) */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR2	UINT32_C(0x5)
-	/* BASE-KX */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKX	UINT32_C(0x6)
-	/* BASE-KR */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR	UINT32_C(0x7)
-	/* BASE-T */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASET		UINT32_C(0x8)
-	/* EEE capable BASE-T */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASETE	UINT32_C(0x9)
-	/* SGMII connected external PHY */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_SGMIIEXTPHY	UINT32_C(0xa)
-	/* 25G_BASECR_CA_L */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_25G_BASECR_CA_L  UINT32_C(0xb)
-	/* 25G_BASECR_CA_S */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_25G_BASECR_CA_S  UINT32_C(0xc)
-	/* 25G_BASECR_CA_N */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_25G_BASECR_CA_N  UINT32_C(0xd)
-	/* 25G_BASESR */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_25G_BASESR	UINT32_C(0xe)
-	/* 100G_BASECR4 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_100G_BASECR4	UINT32_C(0xf)
-	/* 100G_BASESR4 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_100G_BASESR4	UINT32_C(0x10)
-	/* 100G_BASELR4 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_100G_BASELR4	UINT32_C(0x11)
-	/* 100G_BASEER4 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_100G_BASEER4	UINT32_C(0x12)
-	/* 100G_BASESR10 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_100G_BASESR10	UINT32_C(0x13)
-	/* 40G_BASECR4 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_40G_BASECR4	UINT32_C(0x14)
-	/* 40G_BASESR4 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_40G_BASESR4	UINT32_C(0x15)
-	/* 40G_BASELR4 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_40G_BASELR4	UINT32_C(0x16)
-	/* 40G_BASEER4 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_40G_BASEER4	UINT32_C(0x17)
-	/* 40G_ACTIVE_CABLE */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_40G_ACTIVE_CABLE UINT32_C(0x18)
-	/* 1G_baseT */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_1G_BASET	UINT32_C(0x19)
-	/* 1G_baseSX */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_1G_BASESX	UINT32_C(0x1a)
-	/* 1G_baseCX */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_1G_BASECX	UINT32_C(0x1b)
-	/* 100G_BASECR4 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_200G_BASECR4	UINT32_C(0x1c)
-	/* 100G_BASESR4 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_200G_BASESR4	UINT32_C(0x1d)
-	/* 100G_BASELR4 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_200G_BASELR4	UINT32_C(0x1e)
-	/* 100G_BASEER4 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_200G_BASEER4	UINT32_C(0x1f)
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_LAST		HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_200G_BASEER4
-	/* This value represents a media type. */
-	uint8_t	media_type;
-	/* Unknown */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_MEDIA_TYPE_UNKNOWN UINT32_C(0x0)
-	/* Twisted Pair */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_MEDIA_TYPE_TP	UINT32_C(0x1)
-	/* Direct Attached Copper */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_MEDIA_TYPE_DAC	UINT32_C(0x2)
-	/* Fiber */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_MEDIA_TYPE_FIBRE   UINT32_C(0x3)
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_MEDIA_TYPE_LAST   HWRM_PORT_PHY_QCFG_OUTPUT_MEDIA_TYPE_FIBRE
-	/* This value represents a transceiver type. */
-	uint8_t	xcvr_pkg_type;
-	/* PHY and MAC are in the same package */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_PKG_TYPE_XCVR_INTERNAL UINT32_C(0x1)
-	/* PHY and MAC are in different packages */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_PKG_TYPE_XCVR_EXTERNAL UINT32_C(0x2)
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_PKG_TYPE_LAST	HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_PKG_TYPE_XCVR_EXTERNAL
-	uint8_t	eee_config_phy_addr;
-	/* This field represents PHY address. */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_ADDR_MASK		UINT32_C(0x1f)
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PHY_ADDR_SFT		0
+	uint16_t	meter_instance_id;
+	uint8_t	unused_1[2];
+} hwrm_cfa_meter_instance_cfg_input_t, *phwrm_cfa_meter_instance_cfg_input_t;
+
+/* hwrm_cfa_meter_instance_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_cfa_meter_instance_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
 	/*
-	 * This field represents flags related to EEE configuration.
-	 * These EEE configuration flags are valid only when the
-	 * auto_mode is not set to none (in other words autonegotiation
-	 * is enabled).
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_EEE_CONFIG_MASK		UINT32_C(0xe0)
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_EEE_CONFIG_SFT		5
+	uint8_t	valid;
+} hwrm_cfa_meter_instance_cfg_output_t, *phwrm_cfa_meter_instance_cfg_output_t;
+
+/********************************
+ * hwrm_cfa_meter_instance_free *
+ ********************************/
+
+
+/* hwrm_cfa_meter_instance_free_input (size:192b/24B) */
+
+typedef struct hwrm_cfa_meter_instance_free_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * When set to 1, Energy Efficient Ethernet (EEE) mode is enabled.
-	 * Speeds for autoneg with EEE mode enabled
-	 * are based on eee_link_speed_mask.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_EEE_CONFIG_EEE_ENABLED	UINT32_C(0x20)
+	uint16_t	cmpl_ring;
 	/*
-	 * This flag is valid only when eee_enabled is set to 1.
-	 *
-	 * # If eee_enabled is set to 0, then EEE mode is disabled
-	 * and this flag shall be ignored.
-	 * # If eee_enabled is set to 1 and this flag is set to 1,
-	 * then Energy Efficient Ethernet (EEE) mode is enabled
-	 * and in use.
-	 * # If eee_enabled is set to 1 and this flag is set to 0,
-	 * then Energy Efficient Ethernet (EEE) mode is enabled
-	 * but is currently not in use.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_EEE_CONFIG_EEE_ACTIVE	UINT32_C(0x40)
+	uint16_t	seq_id;
 	/*
-	 * This flag is valid only when eee_enabled is set to 1.
-	 *
-	 * # If eee_enabled is set to 0, then EEE mode is disabled
-	 * and this flag shall be ignored.
-	 * # If eee_enabled is set to 1 and this flag is set to 1,
-	 * then Energy Efficient Ethernet (EEE) mode is enabled
-	 * and TX LPI is enabled.
-	 * # If eee_enabled is set to 1 and this flag is set to 0,
-	 * then Energy Efficient Ethernet (EEE) mode is enabled
-	 * but TX LPI is disabled.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_EEE_CONFIG_EEE_TX_LPI	UINT32_C(0x80)
+	uint16_t	target_id;
 	/*
-	 * When set to 1, the parallel detection is used to determine
-	 * the speed of the link partner.
-	 *
-	 * Parallel detection is used when a autonegotiation capable
-	 * device is connected to a link parter that is not capable
-	 * of autonegotiation.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint8_t	parallel_detect;
+	uint64_t	resp_addr;
+	uint8_t	flags;
 	/*
-	 * When set to 1, the parallel detection is used to determine
-	 * the speed of the link partner.
-	 *
-	 * Parallel detection is used when a autonegotiation capable
-	 * device is connected to a link parter that is not capable
-	 * of autonegotiation.
+	 * Enumeration denoting the RX, TX type of the resource.
+	 * This enumeration is used for resources that are similar for both
+	 * TX and RX paths of the chip.
 	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_PARALLEL_DETECT	UINT32_C(0x1)
+	#define HWRM_CFA_METER_INSTANCE_FREE_INPUT_FLAGS_PATH	UINT32_C(0x1)
+	/* tx path */
+		#define HWRM_CFA_METER_INSTANCE_FREE_INPUT_FLAGS_PATH_TX	UINT32_C(0x0)
+	/* rx path */
+		#define HWRM_CFA_METER_INSTANCE_FREE_INPUT_FLAGS_PATH_RX	UINT32_C(0x1)
+		#define HWRM_CFA_METER_INSTANCE_FREE_INPUT_FLAGS_PATH_LAST HWRM_CFA_METER_INSTANCE_FREE_INPUT_FLAGS_PATH_RX
+	uint8_t	unused_0;
+	/* This value identifies a meter instance in CFA. */
+	uint16_t	meter_instance_id;
 	/*
-	 * The advertised speeds for the port by the link partner.
-	 * Each advertised speed will be set to '1'.
+	 * A value of 0xfff is considered invalid and implies the
+	 * instance is not configured.
 	 */
-	uint16_t	link_partner_adv_speeds;
-	/* 100Mb link speed (Half-duplex) */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_SPEEDS_100MBHD	UINT32_C(0x1)
-	/* 100Mb link speed (Full-duplex) */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_SPEEDS_100MB	UINT32_C(0x2)
-	/* 1Gb link speed (Half-duplex) */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_SPEEDS_1GBHD	UINT32_C(0x4)
-	/* 1Gb link speed (Full-duplex) */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_SPEEDS_1GB	UINT32_C(0x8)
-	/* 2Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_SPEEDS_2GB	UINT32_C(0x10)
-	/* 25Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_SPEEDS_2_5GB	UINT32_C(0x20)
-	/* 10Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_SPEEDS_10GB	UINT32_C(0x40)
-	/* 20Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_SPEEDS_20GB	UINT32_C(0x80)
-	/* 25Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_SPEEDS_25GB	UINT32_C(0x100)
-	/* 40Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_SPEEDS_40GB	UINT32_C(0x200)
-	/* 50Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_SPEEDS_50GB	UINT32_C(0x400)
-	/* 100Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_SPEEDS_100GB	UINT32_C(0x800)
-	/* 10Mb link speed (Half-duplex) */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_SPEEDS_10MBHD	UINT32_C(0x1000)
-	/* 10Mb link speed (Full-duplex) */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_SPEEDS_10MB	UINT32_C(0x2000)
+	#define HWRM_CFA_METER_INSTANCE_FREE_INPUT_METER_INSTANCE_ID_INVALID UINT32_C(0xffff)
+	#define HWRM_CFA_METER_INSTANCE_FREE_INPUT_METER_INSTANCE_ID_LAST   HWRM_CFA_METER_INSTANCE_FREE_INPUT_METER_INSTANCE_ID_INVALID
+	uint8_t	unused_1[4];
+} hwrm_cfa_meter_instance_free_input_t, *phwrm_cfa_meter_instance_free_input_t;
+
+/* hwrm_cfa_meter_instance_free_output (size:128b/16B) */
+
+typedef struct hwrm_cfa_meter_instance_free_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
 	/*
-	 * The advertised autoneg for the port by the link partner.
-	 * This field is deprecated and should be set to 0.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	uint8_t	link_partner_adv_auto_mode;
-	/* Disable autoneg or autoneg disabled. No speeds are selected. */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_AUTO_MODE_NONE	UINT32_C(0x0)
-	/* Select all possible speeds for autoneg mode. */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_AUTO_MODE_ALL_SPEEDS   UINT32_C(0x1)
+	uint8_t	valid;
+} hwrm_cfa_meter_instance_free_output_t, *phwrm_cfa_meter_instance_free_output_t;
+
+/*******************************
+ * hwrm_cfa_decap_filter_alloc *
+ *******************************/
+
+
+/* hwrm_cfa_decap_filter_alloc_input (size:832b/104B) */
+
+typedef struct hwrm_cfa_decap_filter_alloc_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * Select only the auto_link_speed speed for autoneg mode. This mode has
-	 * been DEPRECATED. An HWRM client should not use this mode.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_AUTO_MODE_ONE_SPEED	UINT32_C(0x2)
+	uint16_t	cmpl_ring;
 	/*
-	 * Select the auto_link_speed or any speed below that speed for autoneg.
-	 * This mode has been DEPRECATED. An HWRM client should not use this mode.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_AUTO_MODE_ONE_OR_BELOW UINT32_C(0x3)
+	uint16_t	seq_id;
 	/*
-	 * Select the speeds based on the corresponding link speed mask value
-	 * that is provided.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_AUTO_MODE_SPEED_MASK   UINT32_C(0x4)
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_AUTO_MODE_LAST	HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_AUTO_MODE_SPEED_MASK
-	/* The advertised pause settings on the port by the link partner. */
-	uint8_t	link_partner_adv_pause;
+	uint16_t	target_id;
 	/*
-	 * When this bit is '1', Generation of tx pause messages
-	 * is supported. Disabled otherwise.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_PAUSE_TX	UINT32_C(0x1)
+	uint64_t	resp_addr;
+	uint32_t	flags;
+	/* ovs_tunnel is 1 b */
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_FLAGS_OVS_TUNNEL	UINT32_C(0x1)
+	uint32_t	enables;
 	/*
-	 * When this bit is '1', Reception of rx pause messages
-	 * is supported. Disabled otherwise.
+	 * This bit must be '1' for the tunnel_type field to be
+	 * configured.
 	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_PAUSE_RX	UINT32_C(0x2)
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_ENABLES_TUNNEL_TYPE	UINT32_C(0x1)
 	/*
-	 * Current setting for link speed mask that is used to
-	 * advertise speeds during autonegotiation when EEE is enabled.
-	 * This field is valid only when eee_enabled flags is set to 1.
-	 * The speeds specified in this field shall be a subset of
-	 * speeds specified in auto_link_speed_mask.
+	 * This bit must be '1' for the tunnel_id field to be
+	 * configured.
 	 */
-	uint16_t	adv_eee_link_speed_mask;
-	/* Reserved */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_ADV_EEE_LINK_SPEED_MASK_RSVD1	UINT32_C(0x1)
-	/* 100Mb link speed (Full-duplex) */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_ADV_EEE_LINK_SPEED_MASK_100MB	UINT32_C(0x2)
-	/* Reserved */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_ADV_EEE_LINK_SPEED_MASK_RSVD2	UINT32_C(0x4)
-	/* 1Gb link speed (Full-duplex) */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_ADV_EEE_LINK_SPEED_MASK_1GB	UINT32_C(0x8)
-	/* Reserved */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_ADV_EEE_LINK_SPEED_MASK_RSVD3	UINT32_C(0x10)
-	/* Reserved */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_ADV_EEE_LINK_SPEED_MASK_RSVD4	UINT32_C(0x20)
-	/* 10Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_ADV_EEE_LINK_SPEED_MASK_10GB	UINT32_C(0x40)
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_ENABLES_TUNNEL_ID	UINT32_C(0x2)
 	/*
-	 * Current setting for link speed mask that is advertised by
-	 * the link partner when EEE is enabled.
-	 * This field is valid only when eee_enabled flags is set to 1.
+	 * This bit must be '1' for the src_macaddr field to be
+	 * configured.
 	 */
-	uint16_t	link_partner_adv_eee_link_speed_mask;
-	/* Reserved */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_EEE_LINK_SPEED_MASK_RSVD1	UINT32_C(0x1)
-	/* 100Mb link speed (Full-duplex) */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_EEE_LINK_SPEED_MASK_100MB	UINT32_C(0x2)
-	/* Reserved */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_EEE_LINK_SPEED_MASK_RSVD2	UINT32_C(0x4)
-	/* 1Gb link speed (Full-duplex) */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_EEE_LINK_SPEED_MASK_1GB	UINT32_C(0x8)
-	/* Reserved */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_EEE_LINK_SPEED_MASK_RSVD3	UINT32_C(0x10)
-	/* Reserved */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_EEE_LINK_SPEED_MASK_RSVD4	UINT32_C(0x20)
-	/* 10Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_ADV_EEE_LINK_SPEED_MASK_10GB	UINT32_C(0x40)
-	uint32_t	xcvr_identifier_type_tx_lpi_timer;
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_ENABLES_SRC_MACADDR	UINT32_C(0x4)
 	/*
-	 * Current setting of TX LPI timer in microseconds.
-	 * This field is valid only when_eee_enabled flag is set to 1
-	 * and tx_lpi_enabled is set to 1.
+	 * This bit must be '1' for the dst_macaddr field to be
+	 * configured.
 	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_TX_LPI_TIMER_MASK		UINT32_C(0xffffff)
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_TX_LPI_TIMER_SFT		0
-	/* This value represents transceiver identifier type. */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_IDENTIFIER_TYPE_MASK	UINT32_C(0xff000000)
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_IDENTIFIER_TYPE_SFT	24
-	/* Unknown */
-		#define HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_IDENTIFIER_TYPE_UNKNOWN   (UINT32_C(0x0) << 24)
-	/* SFP/SFP+/SFP28 */
-		#define HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_IDENTIFIER_TYPE_SFP	(UINT32_C(0x3) << 24)
-	/* QSFP+ */
-		#define HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_IDENTIFIER_TYPE_QSFP	(UINT32_C(0xc) << 24)
-	/* QSFP+ */
-		#define HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_IDENTIFIER_TYPE_QSFPPLUS  (UINT32_C(0xd) << 24)
-	/* QSFP28 */
-		#define HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_IDENTIFIER_TYPE_QSFP28	(UINT32_C(0x11) << 24)
-		#define HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_IDENTIFIER_TYPE_LAST	HWRM_PORT_PHY_QCFG_OUTPUT_XCVR_IDENTIFIER_TYPE_QSFP28
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_ENABLES_DST_MACADDR	UINT32_C(0x8)
 	/*
-	 * This value represents the current configuration of
-	 * Forward Error Correction (FEC) on the port.
+	 * This bit must be '1' for the ovlan_vid field to be
+	 * configured.
 	 */
-	uint16_t	fec_cfg;
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_ENABLES_OVLAN_VID	UINT32_C(0x10)
 	/*
-	 * When set to 1, then FEC is not supported on this port. If this flag
-	 * is set to 1, then all other FEC configuration flags shall be ignored.
-	 * When set to 0, then FEC is supported as indicated by other
-	 * configuration flags.
+	 * This bit must be '1' for the ivlan_vid field to be
+	 * configured.
 	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_FEC_CFG_FEC_NONE_SUPPORTED	UINT32_C(0x1)
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_ENABLES_IVLAN_VID	UINT32_C(0x20)
 	/*
-	 * When set to 1, then FEC autonegotiation is supported on this port.
-	 * When set to 0, then FEC autonegotiation is not supported on this port.
+	 * This bit must be '1' for the t_ovlan_vid field to be
+	 * configured.
 	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_FEC_CFG_FEC_AUTONEG_SUPPORTED	UINT32_C(0x2)
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_ENABLES_T_OVLAN_VID	UINT32_C(0x40)
 	/*
-	 * When set to 1, then FEC autonegotiation is enabled on this port.
-	 * When set to 0, then FEC autonegotiation is disabled if supported.
-	 * This flag should be ignored if FEC autonegotiation is not supported on this port.
+	 * This bit must be '1' for the t_ivlan_vid field to be
+	 * configured.
 	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_FEC_CFG_FEC_AUTONEG_ENABLED	UINT32_C(0x4)
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_ENABLES_T_IVLAN_VID	UINT32_C(0x80)
 	/*
-	 * When set to 1, then FEC CLAUSE 74 (Fire Code) is supported on this port.
-	 * When set to 0, then FEC CLAUSE 74 (Fire Code) is not supported on this port.
+	 * This bit must be '1' for the ethertype field to be
+	 * configured.
 	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_FEC_CFG_FEC_CLAUSE74_SUPPORTED	UINT32_C(0x8)
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_ENABLES_ETHERTYPE	UINT32_C(0x100)
 	/*
-	 * When set to 1, then FEC CLAUSE 74 (Fire Code) is enabled on this
-	 * port. This means that FEC CLAUSE 74 is either advertised if
-	 * FEC autonegotiation is enabled or FEC CLAUSE 74 is force enabled.
-	 * When set to 0, then FEC CLAUSE 74 (Fire Code) is disabled if supported.
-	 * This flag should be ignored if FEC CLAUSE 74 is not supported on this port.
+	 * This bit must be '1' for the src_ipaddr field to be
+	 * configured.
 	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_FEC_CFG_FEC_CLAUSE74_ENABLED	UINT32_C(0x10)
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_ENABLES_SRC_IPADDR	UINT32_C(0x200)
 	/*
-	 * When set to 1, then FEC CLAUSE 91 (Reed Solomon RS(528,514) for
-	 * NRZ) is supported on this port.
-	 * When set to 0, then FEC RS(528,418) is not supported on this port.
+	 * This bit must be '1' for the dst_ipaddr field to be
+	 * configured.
 	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_FEC_CFG_FEC_CLAUSE91_SUPPORTED	UINT32_C(0x20)
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_ENABLES_DST_IPADDR	UINT32_C(0x400)
 	/*
-	 * When set to 1, then FEC CLAUSE 91 (Reed Solomon RS(528,514) for
-	 * NRZ) is enabled on this port. This means that FEC RS(528,514) is
-	 * either advertised if FEC autonegotiation is enabled or FEC
-	 * RS(528,514) is force enabled.  When set to 0, then FEC RS(528,514)
-	 * is disabled if supported.
-	 * This flag should be ignored if FEC CLAUSE 91 is not supported on this port.
+	 * This bit must be '1' for the ipaddr_type field to be
+	 * configured.
 	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_FEC_CFG_FEC_CLAUSE91_ENABLED	UINT32_C(0x40)
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_ENABLES_IPADDR_TYPE	UINT32_C(0x800)
 	/*
-	 * When set to 1, then FEC RS544_1XN is supported on this port.
-	 * When set to 0, then FEC RS544_1XN is not supported on this port.
+	 * This bit must be '1' for the ip_protocol field to be
+	 * configured.
 	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_FEC_CFG_FEC_RS544_1XN_SUPPORTED	UINT32_C(0x80)
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_ENABLES_IP_PROTOCOL	UINT32_C(0x1000)
 	/*
-	 * When set to 1, then RS544_1XN is enabled on this
-	 * port. This means that FEC RS544_1XN is either advertised if
-	 * FEC autonegotiation is enabled or FEC RS544_1XN is force enabled.
-	 * When set to 0, then FEC RS544_1XN is disabled if supported.
-	 * This flag should be ignored if FEC RS544_1XN is not supported on this port.
+	 * This bit must be '1' for the src_port field to be
+	 * configured.
 	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_FEC_CFG_FEC_RS544_1XN_ENABLED	UINT32_C(0x100)
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_ENABLES_SRC_PORT	UINT32_C(0x2000)
 	/*
-	 * When set to 1, then FEC RS(544,514) is supported on this port.
-	 * When set to 0, then FEC RS(544,514) is not supported on this port.
+	 * This bit must be '1' for the dst_port field to be
+	 * configured.
 	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_FEC_CFG_FEC_RS544_IEEE_SUPPORTED	UINT32_C(0x200)
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_ENABLES_DST_PORT	UINT32_C(0x4000)
 	/*
-	 * When set to 1, then RS(544,514) is enabled on this
-	 * port. This means that FEC RS(544,514) is either advertised if
-	 * FEC autonegotiation is enabled or FEC RS(544,514) is force
-	 * enabled.  When set to 0, then FEC RS(544,514) is disabled if supported.
-	 * This flag should be ignored if FEC RS(544,514) is not supported on this port.
+	 * This bit must be '1' for the dst_id field to be
+	 * configured.
 	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_FEC_CFG_FEC_RS544_IEEE_ENABLED	UINT32_C(0x400)
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_ENABLES_DST_ID		UINT32_C(0x8000)
 	/*
-	 * When set to 1, then FEC RS272_1XN is supported on this port.
-	 * When set to 0, then FEC RS272_1XN is not supported on this port.
+	 * This bit must be '1' for the mirror_vnic_id field to be
+	 * configured.
 	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_FEC_CFG_FEC_RS272_1XN_SUPPORTED	UINT32_C(0x800)
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_ENABLES_MIRROR_VNIC_ID	UINT32_C(0x10000)
 	/*
-	 * When set to 1, then RS272_1XN is enabled on this
-	 * port. This means that FEC RS272_1XN is either advertised if
-	 * FEC autonegotiation is enabled or FEC RS272_1XN is force
-	 * enabled.  When set to 0, then FEC RS272_1XN is disabled if supported.
-	 * This flag should be ignored if FEC RS272_1XN is not supported on this port.
+	 * Tunnel identifier.
+	 * Virtual Network Identifier (VNI). Only valid with
+	 * tunnel_types VXLAN, NVGRE, and Geneve.
+	 * Only lower 24-bits of VNI field are used
+	 * in setting up the filter.
 	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_FEC_CFG_FEC_RS272_1XN_ENABLED	UINT32_C(0x1000)
+	uint32_t	tunnel_id;
+	/* Tunnel Type. */
+	uint8_t	tunnel_type;
+	/* Non-tunnel */
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_TUNNEL_TYPE_NONTUNNEL	UINT32_C(0x0)
+	/* Virtual eXtensible Local Area Network (VXLAN) */
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_TUNNEL_TYPE_VXLAN	UINT32_C(0x1)
+	/* Network Virtualization Generic Routing Encapsulation (NVGRE) */
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_TUNNEL_TYPE_NVGRE	UINT32_C(0x2)
+	/* Generic Routing Encapsulation (GRE) inside Ethernet payload */
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_TUNNEL_TYPE_L2GRE	UINT32_C(0x3)
+	/* IP in IP */
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_TUNNEL_TYPE_IPIP	UINT32_C(0x4)
+	/* Generic Network Virtualization Encapsulation (Geneve) */
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_TUNNEL_TYPE_GENEVE	UINT32_C(0x5)
+	/* Multi-Protocol Label Switching (MPLS) */
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_TUNNEL_TYPE_MPLS	UINT32_C(0x6)
+	/* Stateless Transport Tunnel (STT) */
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_TUNNEL_TYPE_STT	UINT32_C(0x7)
+	/* Generic Routing Encapsulation (GRE) inside IP datagram payload */
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_TUNNEL_TYPE_IPGRE	UINT32_C(0x8)
+	/* IPV4 over virtual eXtensible Local Area Network (IPV4oVXLAN) */
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_V4	UINT32_C(0x9)
 	/*
-	 * When set to 1, then FEC RS(272,514) is supported on this port.
-	 * When set to 0, then FEC RS(272,514) is not supported on this port.
+	 * Enhance Generic Routing Encapsulation (GRE version 1) inside IP
+	 * datagram payload
 	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_FEC_CFG_FEC_RS272_IEEE_SUPPORTED	UINT32_C(0x2000)
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_TUNNEL_TYPE_IPGRE_V1	UINT32_C(0xa)
+	/* Use fixed layer 2 ether type of 0xFFFF */
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_TUNNEL_TYPE_L2_ETYPE	UINT32_C(0xb)
 	/*
-	 * When set to 1, then RS(272,257) is enabled on this
-	 * port. This means that FEC RS(272,257) is either advertised if
-	 * FEC autonegotiation is enabled or FEC RS(272,257) is force
-	 * enabled.  When set to 0, then FEC RS(272,257) is disabled if supported.
-	 * This flag should be ignored if FEC RS(272,257) is not supported on this port.
+	 * IPV6 over virtual eXtensible Local Area Network with GPE header
+	 * (IPV6oVXLANGPE)
 	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_FEC_CFG_FEC_RS272_IEEE_ENABLED	UINT32_C(0x4000)
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_GPE_V6 UINT32_C(0xc)
+	/* Generic Protocol Extension for VXLAN (VXLAN-GPE) */
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_GPE	UINT32_C(0x10)
+	/* Any tunneled traffic */
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_TUNNEL_TYPE_ANYTUNNEL	UINT32_C(0xff)
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_TUNNEL_TYPE_LAST	HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_TUNNEL_TYPE_ANYTUNNEL
+	uint8_t	unused_0;
+	uint16_t	unused_1;
 	/*
-	 * This value is indicates the duplex of the current
-	 * connection state.
+	 * This value indicates the source MAC address in
+	 * the Ethernet header.
 	 */
-	uint8_t	duplex_state;
-	/* Half Duplex connection. */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_DUPLEX_STATE_HALF UINT32_C(0x0)
-	/* Full duplex connection. */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_DUPLEX_STATE_FULL UINT32_C(0x1)
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_DUPLEX_STATE_LAST HWRM_PORT_PHY_QCFG_OUTPUT_DUPLEX_STATE_FULL
-	/* Option flags fields. */
-	uint8_t	option_flags;
-	/* When this bit is '1', Media auto detect is enabled. */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_OPTION_FLAGS_MEDIA_AUTO_DETECT	UINT32_C(0x1)
+	uint8_t	src_macaddr[6];
+	uint8_t	unused_2[2];
 	/*
-	 * When this bit is '1', active_fec_signal_mode can be
-	 * trusted.
+	 * This value indicates the destination MAC address in
+	 * the Ethernet header.
 	 */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_OPTION_FLAGS_SIGNAL_MODE_KNOWN	UINT32_C(0x2)
+	uint8_t	dst_macaddr[6];
 	/*
-	 * Up to 16 bytes of null padded ASCII string representing
-	 * PHY vendor.
-	 * If the string is set to null, then the vendor name is not
-	 * available.
+	 * This value indicates the VLAN ID of the outer VLAN tag
+	 * in the Ethernet header.
 	 */
-	char	phy_vendor_name[16];
+	uint16_t	ovlan_vid;
 	/*
-	 * Up to 16 bytes of null padded ASCII string that
-	 * identifies vendor specific part number of the PHY.
-	 * If the string is set to null, then the vendor specific
-	 * part number is not available.
+	 * This value indicates the VLAN ID of the inner VLAN tag
+	 * in the Ethernet header.
 	 */
-	char	phy_vendor_partnumber[16];
+	uint16_t	ivlan_vid;
 	/*
-	 * The supported PAM4 speeds for the port. This is a bit mask.
-	 * For each speed that is supported, the corresponding
-	 * bit will be set to '1'.
+	 * This value indicates the VLAN ID of the outer VLAN tag
+	 * in the tunnel Ethernet header.
 	 */
-	uint16_t	support_pam4_speeds;
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_PAM4_SPEEDS_50G	UINT32_C(0x1)
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_PAM4_SPEEDS_100G	UINT32_C(0x2)
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_PAM4_SPEEDS_200G	UINT32_C(0x4)
+	uint16_t	t_ovlan_vid;
+	/*
+	 * This value indicates the VLAN ID of the inner VLAN tag
+	 * in the tunnel Ethernet header.
+	 */
+	uint16_t	t_ivlan_vid;
+	/* This value indicates the ethertype in the Ethernet header. */
+	uint16_t	ethertype;
+	/*
+	 * This value indicates the type of IP address.
+	 * 4 - IPv4
+	 * 6 - IPv6
+	 * All others are invalid.
+	 */
+	uint8_t	ip_addr_type;
+	/* invalid */
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_IP_ADDR_TYPE_UNKNOWN UINT32_C(0x0)
+	/* IPv4 */
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_IP_ADDR_TYPE_IPV4	UINT32_C(0x4)
+	/* IPv6 */
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_IP_ADDR_TYPE_IPV6	UINT32_C(0x6)
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_IP_ADDR_TYPE_LAST   HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_IP_ADDR_TYPE_IPV6
+	/*
+	 * The value of protocol field in IP header.
+	 * Applies to UDP and TCP traffic.
+	 * 6 - TCP
+	 * 17 - UDP
+	 */
+	uint8_t	ip_protocol;
+	/* invalid */
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_IP_PROTOCOL_UNKNOWN UINT32_C(0x0)
+	/* TCP */
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_IP_PROTOCOL_TCP	UINT32_C(0x6)
+	/* UDP */
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_IP_PROTOCOL_UDP	UINT32_C(0x11)
+	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_IP_PROTOCOL_LAST   HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_IP_PROTOCOL_UDP
+	uint16_t	unused_3;
+	uint32_t	unused_4;
+	/*
+	 * The value of source IP address to be used in filtering.
+	 * For IPv4, first four bytes represent the IP address.
+	 */
+	uint32_t	src_ipaddr[4];
+	/*
+	 * The value of destination IP address to be used in filtering.
+	 * For IPv4, first four bytes represent the IP address.
+	 */
+	uint32_t	dst_ipaddr[4];
+	/*
+	 * The value of source port to be used in filtering.
+	 * Applies to UDP and TCP traffic.
+	 */
+	uint16_t	src_port;
 	/*
-	 * Current setting of forced PAM4 link speed.
-	 * When the link speed is not being forced, this
-	 * value shall be set to 0.
+	 * The value of destination port to be used in filtering.
+	 * Applies to UDP and TCP traffic.
 	 */
-	uint16_t	force_pam4_link_speed;
-	/* 50Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_PAM4_LINK_SPEED_50GB  UINT32_C(0x1f4)
-	/* 100Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_PAM4_LINK_SPEED_100GB UINT32_C(0x3e8)
-	/* 200Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_PAM4_LINK_SPEED_200GB UINT32_C(0x7d0)
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_PAM4_LINK_SPEED_LAST HWRM_PORT_PHY_QCFG_OUTPUT_FORCE_PAM4_LINK_SPEED_200GB
+	uint16_t	dst_port;
 	/*
-	 * Current setting for auto_pam4_link_speed_mask that is used to
-	 * advertise speeds during autonegotiation.
-	 * This field is only valid when auto_mode is set to "mask".
-	 * The speeds specified in this field shall be a subset of
-	 * supported speeds on this port.
+	 * If set, this value shall represent the
+	 * Logical VNIC ID of the destination VNIC for the RX
+	 * path.
 	 */
-	uint16_t	auto_pam4_link_speed_mask;
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_PAM4_LINK_SPEED_MASK_50G	UINT32_C(0x1)
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_PAM4_LINK_SPEED_MASK_100G	UINT32_C(0x2)
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_PAM4_LINK_SPEED_MASK_200G	UINT32_C(0x4)
+	uint16_t	dst_id;
 	/*
-	 * The advertised PAM4 speeds for the port by the link partner.
-	 * Each advertised speed will be set to '1'.
+	 * If set, this value shall represent the L2 context that matches the
+	 * L2 information of the decap filter.
 	 */
-	uint8_t	link_partner_pam4_adv_speeds;
-	/* 50Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_PAM4_ADV_SPEEDS_50GB	UINT32_C(0x1)
-	/* 100Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_PAM4_ADV_SPEEDS_100GB	UINT32_C(0x2)
-	/* 200Gb link speed */
-	#define HWRM_PORT_PHY_QCFG_OUTPUT_LINK_PARTNER_PAM4_ADV_SPEEDS_200GB	UINT32_C(0x4)
+	uint16_t	l2_ctxt_ref_id;
+} hwrm_cfa_decap_filter_alloc_input_t, *phwrm_cfa_decap_filter_alloc_input_t;
+
+/* hwrm_cfa_decap_filter_alloc_output (size:128b/16B) */
+
+typedef struct hwrm_cfa_decap_filter_alloc_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* This value is an opaque id into CFA data structures. */
+	uint32_t	decap_filter_id;
+	uint8_t	unused_0[3];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_port_phy_qcfg_output_t, *phwrm_port_phy_qcfg_output_t;
+} hwrm_cfa_decap_filter_alloc_output_t, *phwrm_cfa_decap_filter_alloc_output_t;
 
-/*********************
- * hwrm_port_mac_cfg *
- *********************/
+/******************************
+ * hwrm_cfa_decap_filter_free *
+ ******************************/
 
 
-/* hwrm_port_mac_cfg_input (size:384b/48B) */
+/* hwrm_cfa_decap_filter_free_input (size:192b/24B) */
 
-typedef struct hwrm_port_mac_cfg_input {
+typedef struct hwrm_cfa_decap_filter_free_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -20238,334 +48399,291 @@ typedef struct hwrm_port_mac_cfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
+	/* This value is an opaque id into CFA data structures. */
+	uint32_t	decap_filter_id;
+	uint8_t	unused_0[4];
+} hwrm_cfa_decap_filter_free_input_t, *phwrm_cfa_decap_filter_free_input_t;
+
+/* hwrm_cfa_decap_filter_free_output (size:128b/16B) */
+
+typedef struct hwrm_cfa_decap_filter_free_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
 	/*
-	 * In this field, there are a number of CoS mappings related flags
-	 * that are used to configure CoS mappings and their corresponding
-	 * priorities in the hardware.
-	 * For the priorities of CoS mappings, the HWRM uses the following
-	 * priority order (high to low) by default:
-	 * # vlan pri
-	 * # ip_dscp
-	 * # tunnel_vlan_pri
-	 * # default cos
-	 *
-	 * A subset of CoS mappings can be enabled.
-	 * If a priority is not specified for an enabled CoS mapping, the
-	 * priority will be assigned in the above order for the enabled CoS
-	 * mappings. For example, if vlan_pri and ip_dscp CoS mappings are
-	 * enabled and their priorities are not specified, the following
-	 * priority order (high to low) will be used by the HWRM:
-	 * # vlan_pri
-	 * # ip_dscp
-	 * # default cos
-	 *
-	 * vlan_pri CoS mapping together with default CoS with lower priority
-	 * are enabled by default by the HWRM.
-	 */
-	uint32_t	flags;
-	/*
-	 * When this bit is '1', this command will configure
-	 * the MAC to match the current link state of the PHY.
-	 * If the link is not established on the PHY, then this
-	 * bit has no effect.
-	 */
-	#define HWRM_PORT_MAC_CFG_INPUT_FLAGS_MATCH_LINK			UINT32_C(0x1)
-	/*
-	 * When this bit is set to '1', the inner VLAN PRI to CoS mapping
-	 * is requested to be enabled.
-	 */
-	#define HWRM_PORT_MAC_CFG_INPUT_FLAGS_VLAN_PRI2COS_ENABLE	UINT32_C(0x2)
-	/*
-	 * When this bit is set to '1', tunnel VLAN PRI field to
-	 * CoS mapping is requested to be enabled.
-	 */
-	#define HWRM_PORT_MAC_CFG_INPUT_FLAGS_TUNNEL_PRI2COS_ENABLE	UINT32_C(0x4)
-	/*
-	 * When this bit is set to '1', the IP DSCP to CoS mapping is
-	 * requested to be enabled.
-	 */
-	#define HWRM_PORT_MAC_CFG_INPUT_FLAGS_IP_DSCP2COS_ENABLE		UINT32_C(0x8)
-	/*
-	 * When this bit is '1', the HWRM is requested to
-	 * enable timestamp capture capability on the receive side
-	 * of this port.
-	 */
-	#define HWRM_PORT_MAC_CFG_INPUT_FLAGS_PTP_RX_TS_CAPTURE_ENABLE	UINT32_C(0x10)
-	/*
-	 * When this bit is '1', the HWRM is requested to
-	 * disable timestamp capture capability on the receive side
-	 * of this port.
-	 */
-	#define HWRM_PORT_MAC_CFG_INPUT_FLAGS_PTP_RX_TS_CAPTURE_DISABLE	UINT32_C(0x20)
-	/*
-	 * When this bit is '1', the HWRM is requested to
-	 * enable timestamp capture capability on the transmit side
-	 * of this port.
-	 */
-	#define HWRM_PORT_MAC_CFG_INPUT_FLAGS_PTP_TX_TS_CAPTURE_ENABLE	UINT32_C(0x40)
-	/*
-	 * When this bit is '1', the HWRM is requested to
-	 * disable timestamp capture capability on the transmit side
-	 * of this port.
-	 */
-	#define HWRM_PORT_MAC_CFG_INPUT_FLAGS_PTP_TX_TS_CAPTURE_DISABLE	UINT32_C(0x80)
-	/*
-	 * When this bit is '1', the Out-Of-Box WoL is requested to
-	 * be enabled on this port.
-	 */
-	#define HWRM_PORT_MAC_CFG_INPUT_FLAGS_OOB_WOL_ENABLE		UINT32_C(0x100)
-	/*
-	 * When this bit is '1', the Out-Of-Box WoL is requested to
-	 * be disabled on this port.
-	 */
-	#define HWRM_PORT_MAC_CFG_INPUT_FLAGS_OOB_WOL_DISABLE		UINT32_C(0x200)
-	/*
-	 * When this bit is set to '1', the inner VLAN PRI to CoS mapping
-	 * is requested to be disabled.
-	 */
-	#define HWRM_PORT_MAC_CFG_INPUT_FLAGS_VLAN_PRI2COS_DISABLE	UINT32_C(0x400)
-	/*
-	 * When this bit is set to '1', tunnel VLAN PRI field to
-	 * CoS mapping is requested to be disabled.
-	 */
-	#define HWRM_PORT_MAC_CFG_INPUT_FLAGS_TUNNEL_PRI2COS_DISABLE	UINT32_C(0x800)
-	/*
-	 * When this bit is set to '1', the IP DSCP to CoS mapping is
-	 * requested to be disabled.
-	 */
-	#define HWRM_PORT_MAC_CFG_INPUT_FLAGS_IP_DSCP2COS_DISABLE	UINT32_C(0x1000)
-	/*
-	 * When this bit is set to '1', and the ptp_tx_ts_capture_enable
-	 * bit is set, then the device uses one step Tx timestamping.
-	 * This bit is temporary and used for experimental purposes.
-	 */
-	#define HWRM_PORT_MAC_CFG_INPUT_FLAGS_PTP_ONE_STEP_TX_TS		UINT32_C(0x2000)
-	uint32_t	enables;
-	/*
-	 * This bit must be '1' for the ipg field to be
-	 * configured.
-	 */
-	#define HWRM_PORT_MAC_CFG_INPUT_ENABLES_IPG				UINT32_C(0x1)
-	/*
-	 * This bit must be '1' for the lpbk field to be
-	 * configured.
-	 */
-	#define HWRM_PORT_MAC_CFG_INPUT_ENABLES_LPBK			UINT32_C(0x2)
-	/*
-	 * This bit must be '1' for the vlan_pri2cos_map_pri field to be
-	 * configured.
-	 */
-	#define HWRM_PORT_MAC_CFG_INPUT_ENABLES_VLAN_PRI2COS_MAP_PRI	UINT32_C(0x4)
-	/*
-	 * This bit must be '1' for the tunnel_pri2cos_map_pri field to be
-	 * configured.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	#define HWRM_PORT_MAC_CFG_INPUT_ENABLES_TUNNEL_PRI2COS_MAP_PRI	UINT32_C(0x10)
+	uint8_t	valid;
+} hwrm_cfa_decap_filter_free_output_t, *phwrm_cfa_decap_filter_free_output_t;
+
+/***********************
+ * hwrm_cfa_flow_alloc *
+ ***********************/
+
+
+/* hwrm_cfa_flow_alloc_input (size:1024b/128B) */
+
+typedef struct hwrm_cfa_flow_alloc_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * This bit must be '1' for the dscp2cos_map_pri field to be
-	 * configured.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define HWRM_PORT_MAC_CFG_INPUT_ENABLES_DSCP2COS_MAP_PRI		UINT32_C(0x20)
+	uint16_t	cmpl_ring;
 	/*
-	 * This bit must be '1' for the rx_ts_capture_ptp_msg_type field to be
-	 * configured.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define HWRM_PORT_MAC_CFG_INPUT_ENABLES_RX_TS_CAPTURE_PTP_MSG_TYPE	UINT32_C(0x40)
+	uint16_t	seq_id;
 	/*
-	 * This bit must be '1' for the tx_ts_capture_ptp_msg_type field to be
-	 * configured.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define HWRM_PORT_MAC_CFG_INPUT_ENABLES_TX_TS_CAPTURE_PTP_MSG_TYPE	UINT32_C(0x80)
+	uint16_t	target_id;
 	/*
-	 * This bit must be '1' for the cos_field_cfg field to be
-	 * configured.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define HWRM_PORT_MAC_CFG_INPUT_ENABLES_COS_FIELD_CFG		UINT32_C(0x100)
+	uint64_t	resp_addr;
+	uint16_t	flags;
+	/* tunnel is 1 b */
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_TUNNEL		UINT32_C(0x1)
+	/* num_vlan is 2 b */
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_NUM_VLAN_MASK	UINT32_C(0x6)
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_NUM_VLAN_SFT	1
+	/* no tags */
+		#define HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_NUM_VLAN_NONE		(UINT32_C(0x0) << 1)
+	/* 1 tag */
+		#define HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_NUM_VLAN_ONE		(UINT32_C(0x1) << 1)
+	/* 2 tags */
+		#define HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_NUM_VLAN_TWO		(UINT32_C(0x2) << 1)
+		#define HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_NUM_VLAN_LAST	HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_NUM_VLAN_TWO
+	/* Enumeration denoting the Flow Type. */
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_FLOWTYPE_MASK	UINT32_C(0x38)
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_FLOWTYPE_SFT	3
+	/* L2 flow */
+		#define HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_FLOWTYPE_L2		(UINT32_C(0x0) << 3)
+	/* IPV4 flow */
+		#define HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_FLOWTYPE_IPV4		(UINT32_C(0x1) << 3)
+	/* IPV6 flow */
+		#define HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_FLOWTYPE_IPV6		(UINT32_C(0x2) << 3)
+		#define HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_FLOWTYPE_LAST	HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_FLOWTYPE_IPV6
 	/*
-	 * This bit must be '1' for the ptp_freq_adj_ppb field to be
-	 * configured.
+	 * when set to 1, indicates TX flow offload for function specified
+	 * in src_fid and the dst_fid should be set to invalid value. To
+	 * indicate a VM to VM flow, both of the path_tx and path_rx flags
+	 * need to be set. For virtio vSwitch offload case, the src_fid and
+	 * dst_fid is set to the same fid value. For the SRIOV vSwitch
+	 * offload case, the src_fid and dst_fid must be set to the same VF
+	 * FID belong to the children VFs of the same PF to indicate VM to
+	 * VM flow.
 	 */
-	#define HWRM_PORT_MAC_CFG_INPUT_ENABLES_PTP_FREQ_ADJ_PPB		UINT32_C(0x200)
-	/* Port ID of port that is to be configured. */
-	uint16_t	port_id;
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_PATH_TX		UINT32_C(0x40)
 	/*
-	 * This value is used to configure the minimum IPG that will
-	 * be sent between packets by this port.
+	 * when set to 1, indicates RX flow offload for function specified
+	 * in dst_fid and the src_fid should be set to invalid value.
 	 */
-	uint8_t	ipg;
-	/* This value controls the loopback setting for the MAC. */
-	uint8_t	lpbk;
-	/* No loopback is selected.  Normal operation. */
-	#define HWRM_PORT_MAC_CFG_INPUT_LPBK_NONE   UINT32_C(0x0)
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_PATH_RX		UINT32_C(0x80)
 	/*
-	 * The HW will be configured with local loopback such that
-	 * host data is sent back to the host without modification.
+	 * Set to 1 to indicate matching of VXLAN VNI from the custom vxlan
+	 * header is required and the VXLAN VNI value is stored in the first
+	 * 24 bits of the dmac field. This flag is only valid when the flow
+	 * direction is RX.
 	 */
-	#define HWRM_PORT_MAC_CFG_INPUT_LPBK_LOCAL  UINT32_C(0x1)
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_MATCH_VXLAN_IP_VNI	UINT32_C(0x100)
 	/*
-	 * The HW will be configured with remote loopback such that
-	 * port logic will send packets back out the transmitter that
-	 * are received.
+	 * Set to 1 to indicate vhost_id is specified in the outer_vlan_tci
+	 * field.
 	 */
-	#define HWRM_PORT_MAC_CFG_INPUT_LPBK_REMOTE UINT32_C(0x2)
-	#define HWRM_PORT_MAC_CFG_INPUT_LPBK_LAST  HWRM_PORT_MAC_CFG_INPUT_LPBK_REMOTE
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_VHOST_ID_USE_VLAN	UINT32_C(0x200)
 	/*
-	 * This value controls the priority setting of VLAN PRI to CoS
-	 * mapping based on VLAN Tags of inner packet headers of
-	 * tunneled packets or packet headers of non-tunneled packets.
-	 *
-	 * # Each XXX_pri variable shall have a unique priority value
-	 * when it is being specified.
-	 * # When comparing priorities of mappings, higher value
-	 * indicates higher priority.
-	 * For example, a value of 0-3 is returned where 0 is being
-	 * the lowest priority and 3 is being the highest priority.
+	 * Tx Flow: vf fid.
+	 * Rx Flow: pf fid.
 	 */
-	uint8_t	vlan_pri2cos_map_pri;
-	/* Reserved field. */
-	uint8_t	reserved1;
+	uint16_t	src_fid;
+	/* Tunnel handle valid when tunnel flag is set. */
+	uint32_t	tunnel_handle;
+	uint16_t	action_flags;
 	/*
-	 * This value controls the priority setting of VLAN PRI to CoS
-	 * mapping based on VLAN Tags of tunneled header.
-	 * This mapping only applies when tunneled headers
-	 * are present.
-	 *
-	 * # Each XXX_pri variable shall have a unique priority value
-	 * when it is being specified.
-	 * # When comparing priorities of mappings, higher value
-	 * indicates higher priority.
-	 * For example, a value of 0-3 is returned where 0 is being
-	 * the lowest priority and 3 is being the highest priority.
+	 * Setting of this flag indicates drop action. If this flag is not
+	 * set, then it should be considered accept action.
 	 */
-	uint8_t	tunnel_pri2cos_map_pri;
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_ACTION_FLAGS_FWD			UINT32_C(0x1)
+	/* recycle is 1 b */
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_ACTION_FLAGS_RECYCLE		UINT32_C(0x2)
 	/*
-	 * This value controls the priority setting of IP DSCP to CoS
-	 * mapping based on inner IP header of tunneled packets or
-	 * IP header of non-tunneled packets.
-	 *
-	 * # Each XXX_pri variable shall have a unique priority value
-	 * when it is being specified.
-	 * # When comparing priorities of mappings, higher value
-	 * indicates higher priority.
-	 * For example, a value of 0-3 is returned where 0 is being
-	 * the lowest priority and 3 is being the highest priority.
+	 * Setting of this flag indicates drop action. If this flag is not
+	 * set, then it should be considered accept action.
 	 */
-	uint8_t	dscp2pri_map_pri;
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_ACTION_FLAGS_DROP			UINT32_C(0x4)
+	/* meter is 1 b */
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_ACTION_FLAGS_METER			UINT32_C(0x8)
+	/* tunnel is 1 b */
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_ACTION_FLAGS_TUNNEL			UINT32_C(0x10)
+	/* nat_src is 1 b */
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_ACTION_FLAGS_NAT_SRC		UINT32_C(0x20)
+	/* nat_dest is 1 b */
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_ACTION_FLAGS_NAT_DEST		UINT32_C(0x40)
+	/* nat_ipv4_address is 1 b */
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_ACTION_FLAGS_NAT_IPV4_ADDRESS	UINT32_C(0x80)
+	/* l2_header_rewrite is 1 b */
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_ACTION_FLAGS_L2_HEADER_REWRITE	UINT32_C(0x100)
+	/* ttl_decrement is 1 b */
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_ACTION_FLAGS_TTL_DECREMENT		UINT32_C(0x200)
 	/*
-	 * This is a 16-bit bit mask that is used to request a
-	 * specific configuration of time stamp capture of PTP messages
-	 * on the receive side of this port.
-	 * This field shall be ignored if the ptp_rx_ts_capture_enable
-	 * flag is not set in this command.
-	 * Otherwise, if bit 'i' is set, then the HWRM is being
-	 * requested to configure the receive side of the port to
-	 * capture the time stamp of every received PTP message
-	 * with messageType field value set to i.
+	 * If set to 1 and flow direction is TX, it indicates decap of L2
+	 * header and encap of tunnel header. If set to 1 and flow direction
+	 * is RX, it indicates decap of tunnel header and encap L2 header.
+	 * The type of tunnel is specified in the tunnel_type field.
 	 */
-	uint16_t	rx_ts_capture_ptp_msg_type;
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_ACTION_FLAGS_TUNNEL_IP		UINT32_C(0x400)
+	/* If set to 1, flow aging is enabled for this flow. */
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_ACTION_FLAGS_FLOW_AGING_ENABLED	UINT32_C(0x800)
 	/*
-	 * This is a 16-bit bit mask that is used to request a
-	 * specific configuration of time stamp capture of PTP messages
-	 * on the transmit side of this port.
-	 * This field shall be ignored if the ptp_tx_ts_capture_enable
-	 * flag is not set in this command.
-	 * Otherwise, if bit 'i' is set, then the HWRM is being
-	 * requested to configure the transmit side of the port to
-	 * capture the time stamp of every transmitted PTP message
-	 * with messageType field value set to i.
+	 * If set to 1 an attempt will be made to try to offload this flow
+	 * to the most optimal flow table resource. If set to 0, the flow
+	 * will be placed to the default flow table resource.
 	 */
-	uint16_t	tx_ts_capture_ptp_msg_type;
-	/* Configuration of CoS fields. */
-	uint8_t	cos_field_cfg;
-	/* Reserved */
-	#define HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_RSVD1			UINT32_C(0x1)
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_ACTION_FLAGS_PRI_HINT		UINT32_C(0x1000)
 	/*
-	 * This field is used to specify selection of VLAN PRI value
-	 * based on whether one or two VLAN Tags are present in
-	 * the inner packet headers of tunneled packets or
-	 * non-tunneled packets.
-	 * This field is valid only if inner VLAN PRI to CoS mapping
-	 * is enabled.
-	 * If VLAN PRI to CoS mapping is not enabled, then this
-	 * field shall be ignored.
+	 * If set to 1 there will be no attempt to allocate an on-chip try
+	 * to offload this flow. If set to 0, which will keep compatibility
+	 * with the older drivers, will cause the FW to attempt to allocate
+	 * an on-chip flow counter for the newly created flow. This will
+	 * keep the existing behavior with EM flows which always had an
+	 * associated flow counter.
 	 */
-	#define HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_VLAN_PRI_SEL_MASK	UINT32_C(0x6)
-	#define HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_VLAN_PRI_SEL_SFT	1
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_ACTION_FLAGS_NO_FLOW_COUNTER_ALLOC	UINT32_C(0x2000)
 	/*
-	 * Select inner VLAN PRI when 1 or 2 VLAN Tags are
-	 * present in the inner packet headers
+	 * Tx Flow: pf or vf fid.
+	 * Rx Flow: vf fid.
 	 */
-		#define HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_VLAN_PRI_SEL_INNERMOST	(UINT32_C(0x0) << 1)
+	uint16_t	dst_fid;
+	/* VLAN tpid, valid when push_vlan flag is set. */
+	uint16_t	l2_rewrite_vlan_tpid;
+	/* VLAN tci, valid when push_vlan flag is set. */
+	uint16_t	l2_rewrite_vlan_tci;
+	/* Meter id, valid when meter flag is set. */
+	uint16_t	act_meter_id;
+	/* Flow with the same l2 context tcam key. */
+	uint16_t	ref_flow_handle;
+	/* This value sets the match value for the ethertype. */
+	uint16_t	ethertype;
+	/* valid when num tags is 1 or 2. */
+	uint16_t	outer_vlan_tci;
+	/* This value sets the match value for the Destination MAC address. */
+	uint16_t	dmac[3];
+	/* valid when num tags is 2. */
+	uint16_t	inner_vlan_tci;
+	/* This value sets the match value for the Source MAC address. */
+	uint16_t	smac[3];
+	/* The bit length of destination IP address mask. */
+	uint8_t	ip_dst_mask_len;
+	/* The bit length of source IP address mask. */
+	uint8_t	ip_src_mask_len;
+	/* The value of destination IPv4/IPv6 address. */
+	uint32_t	ip_dst[4];
+	/* The source IPv4/IPv6 address. */
+	uint32_t	ip_src[4];
 	/*
-	 * Select outer VLAN Tag PRI when 2 VLAN Tags are
-	 * present in the inner packet headers.
-	 * No VLAN PRI shall be selected for this configuration
-	 * if only one VLAN Tag is present in the inner
-	 * packet headers.
+	 * The value of source port.
+	 * Applies to UDP and TCP traffic.
 	 */
-		#define HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_VLAN_PRI_SEL_OUTER	(UINT32_C(0x1) << 1)
+	uint16_t	l4_src_port;
 	/*
-	 * Select outermost VLAN PRI when 1 or 2 VLAN Tags
-	 * are present in the inner packet headers
+	 * The value of source port mask.
+	 * Applies to UDP and TCP traffic.
 	 */
-		#define HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_VLAN_PRI_SEL_OUTERMOST	(UINT32_C(0x2) << 1)
-	/* Unspecified */
-		#define HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_VLAN_PRI_SEL_UNSPECIFIED	(UINT32_C(0x3) << 1)
-		#define HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_VLAN_PRI_SEL_LAST	HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_VLAN_PRI_SEL_UNSPECIFIED
+	uint16_t	l4_src_port_mask;
 	/*
-	 * This field is used to specify selection of tunnel VLAN
-	 * PRI value based on whether one or two VLAN Tags are
-	 * present in tunnel headers.
-	 * This field is valid only if tunnel VLAN PRI to CoS mapping
-	 * is enabled.
-	 * If tunnel VLAN PRI to CoS mapping is not enabled, then this
-	 * field shall be ignored.
+	 * The value of destination port.
+	 * Applies to UDP and TCP traffic.
 	 */
-	#define HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_T_VLAN_PRI_SEL_MASK	UINT32_C(0x18)
-	#define HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_T_VLAN_PRI_SEL_SFT	3
+	uint16_t	l4_dst_port;
 	/*
-	 * Select inner VLAN PRI when 1 or 2 VLAN Tags are
-	 * present in the tunnel packet headers
+	 * The value of destination port mask.
+	 * Applies to UDP and TCP traffic.
 	 */
-		#define HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_T_VLAN_PRI_SEL_INNERMOST	(UINT32_C(0x0) << 3)
+	uint16_t	l4_dst_port_mask;
 	/*
-	 * Select outer VLAN Tag PRI when 2 VLAN Tags are
-	 * present in the tunnel packet headers.
-	 * No tunnel VLAN PRI shall be selected for this
-	 * configuration if only one VLAN Tag is present in
-	 * the tunnel packet headers.
+	 * NAT IPv4/6 address based on address type flag.
+	 * 0 values are ignored.
 	 */
-		#define HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_T_VLAN_PRI_SEL_OUTER	(UINT32_C(0x1) << 3)
+	uint32_t	nat_ip_address[4];
+	/* L2 header re-write Destination MAC address. */
+	uint16_t	l2_rewrite_dmac[3];
 	/*
-	 * Select outermost VLAN PRI when 1 or 2 VLAN Tags
-	 * are present in the tunnel packet headers
+	 * The NAT source/destination port based on direction flag.
+	 * Applies to UDP and TCP traffic.
+	 * 0 values are ignored.
 	 */
-		#define HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_T_VLAN_PRI_SEL_OUTERMOST	(UINT32_C(0x2) << 3)
-	/* Unspecified */
-		#define HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_T_VLAN_PRI_SEL_UNSPECIFIED  (UINT32_C(0x3) << 3)
-		#define HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_T_VLAN_PRI_SEL_LAST	HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_T_VLAN_PRI_SEL_UNSPECIFIED
+	uint16_t	nat_port;
+	/* L2 header re-write Source MAC address. */
+	uint16_t	l2_rewrite_smac[3];
+	/* The value of ip protocol. */
+	uint8_t	ip_proto;
+	/* Tunnel Type. */
+	uint8_t	tunnel_type;
+	/* Non-tunnel */
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_TUNNEL_TYPE_NONTUNNEL	UINT32_C(0x0)
+	/* Virtual eXtensible Local Area Network (VXLAN) */
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_TUNNEL_TYPE_VXLAN	UINT32_C(0x1)
+	/* Network Virtualization Generic Routing Encapsulation (NVGRE) */
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_TUNNEL_TYPE_NVGRE	UINT32_C(0x2)
+	/* Generic Routing Encapsulation (GRE) inside Ethernet payload */
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_TUNNEL_TYPE_L2GRE	UINT32_C(0x3)
+	/* IP in IP */
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_TUNNEL_TYPE_IPIP	UINT32_C(0x4)
+	/* Generic Network Virtualization Encapsulation (Geneve) */
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_TUNNEL_TYPE_GENEVE	UINT32_C(0x5)
+	/* Multi-Protocol Label Switching (MPLS) */
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_TUNNEL_TYPE_MPLS	UINT32_C(0x6)
+	/* Stateless Transport Tunnel (STT) */
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_TUNNEL_TYPE_STT	UINT32_C(0x7)
+	/* Generic Routing Encapsulation (GRE) inside IP datagram payload */
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_TUNNEL_TYPE_IPGRE	UINT32_C(0x8)
+	/* IPV4 over virtual eXtensible Local Area Network (IPV4oVXLAN) */
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_V4	UINT32_C(0x9)
 	/*
-	 * This field shall be used to provide default CoS value
-	 * that has been configured on this port.
-	 * This field is valid only if default CoS mapping
-	 * is enabled.
-	 * If default CoS mapping is not enabled, then this
-	 * field shall be ignored.
+	 * Enhance Generic Routing Encapsulation (GRE version 1) inside IP
+	 * datagram payload
 	 */
-	#define HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_DEFAULT_COS_MASK	UINT32_C(0xe0)
-	#define HWRM_PORT_MAC_CFG_INPUT_COS_FIELD_CFG_DEFAULT_COS_SFT	5
-	uint8_t	unused_0[3];
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_TUNNEL_TYPE_IPGRE_V1	UINT32_C(0xa)
+	/* Use fixed layer 2 ether type of 0xFFFF */
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_TUNNEL_TYPE_L2_ETYPE	UINT32_C(0xb)
 	/*
-	 * This signed field specifies by how much to adjust the frequency
-	 * of sync timer updates (measured in parts per billion).
+	 * IPV6 over virtual eXtensible Local Area Network with GPE header
+	 * (IPV6oVXLANGPE)
 	 */
-	int32_t	ptp_freq_adj_ppb;
-	uint8_t	unused_1[4];
-} hwrm_port_mac_cfg_input_t, *phwrm_port_mac_cfg_input_t;
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_GPE_V6 UINT32_C(0xc)
+	/* Generic Protocol Extension for VXLAN (VXLAN-GPE) */
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_GPE	UINT32_C(0x10)
+	/* Any tunneled traffic */
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_TUNNEL_TYPE_ANYTUNNEL	UINT32_C(0xff)
+	#define HWRM_CFA_FLOW_ALLOC_INPUT_TUNNEL_TYPE_LAST	HWRM_CFA_FLOW_ALLOC_INPUT_TUNNEL_TYPE_ANYTUNNEL
+} hwrm_cfa_flow_alloc_input_t, *phwrm_cfa_flow_alloc_input_t;
 
-/* hwrm_port_mac_cfg_output (size:128b/16B) */
+/* hwrm_cfa_flow_alloc_output (size:256b/32B) */
 
-typedef struct hwrm_port_mac_cfg_output {
+typedef struct hwrm_cfa_flow_alloc_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -20574,57 +48692,91 @@ typedef struct hwrm_port_mac_cfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
+	/* Flow record index. */
+	uint16_t	flow_handle;
+	uint8_t	unused_0[2];
 	/*
-	 * This is the configured maximum length of Ethernet packet
-	 * payload that is allowed to be received on the port.
-	 * This value does not include the number of bytes used by
-	 * Ethernet header and trailer (CRC).
-	 */
-	uint16_t	mru;
-	/*
-	 * This is the configured maximum length of Ethernet packet
-	 * payload that is allowed to be transmitted on the port.
-	 * This value does not include the number of bytes used by
-	 * Ethernet header and trailer (CRC).
+	 * The flow id value in bit 0-29 is the actual ID of the flow
+	 * associated with this filter and it shall be used to match
+	 * and associate the flow identifier returned in completion
+	 * records. A value of 0xFFFFFFFF in the 32-bit flow_id field
+	 * shall indicate no valid flow id.
 	 */
-	uint16_t	mtu;
-	/* Current configuration of the IPG value. */
-	uint8_t	ipg;
-	/* Current value of the loopback value. */
-	uint8_t	lpbk;
-	/* No loopback is selected.  Normal operation. */
-	#define HWRM_PORT_MAC_CFG_OUTPUT_LPBK_NONE   UINT32_C(0x0)
+	uint32_t	flow_id;
+	/* Indicate the flow id value. */
+	#define HWRM_CFA_FLOW_ALLOC_OUTPUT_FLOW_ID_VALUE_MASK UINT32_C(0x3fffffff)
+	#define HWRM_CFA_FLOW_ALLOC_OUTPUT_FLOW_ID_VALUE_SFT 0
+	/* Indicate type of the flow. */
+	#define HWRM_CFA_FLOW_ALLOC_OUTPUT_FLOW_ID_TYPE	UINT32_C(0x40000000)
 	/*
-	 * The HW will be configured with local loopback such that
-	 * host data is sent back to the host without modification.
+	 * If this bit set to 0, then it indicates that the flow is
+	 * internal flow.
 	 */
-	#define HWRM_PORT_MAC_CFG_OUTPUT_LPBK_LOCAL  UINT32_C(0x1)
+		#define HWRM_CFA_FLOW_ALLOC_OUTPUT_FLOW_ID_TYPE_INT	(UINT32_C(0x0) << 30)
 	/*
-	 * The HW will be configured with remote loopback such that
-	 * port logic will send packets back out the transmitter that
-	 * are received.
+	 * If this bit is set to 1, then it indicates that the flow is
+	 * external flow.
 	 */
-	#define HWRM_PORT_MAC_CFG_OUTPUT_LPBK_REMOTE UINT32_C(0x2)
-	#define HWRM_PORT_MAC_CFG_OUTPUT_LPBK_LAST  HWRM_PORT_MAC_CFG_OUTPUT_LPBK_REMOTE
-	uint8_t	unused_0;
+		#define HWRM_CFA_FLOW_ALLOC_OUTPUT_FLOW_ID_TYPE_EXT	(UINT32_C(0x1) << 30)
+		#define HWRM_CFA_FLOW_ALLOC_OUTPUT_FLOW_ID_TYPE_LAST  HWRM_CFA_FLOW_ALLOC_OUTPUT_FLOW_ID_TYPE_EXT
+	/* Indicate the flow direction. */
+	#define HWRM_CFA_FLOW_ALLOC_OUTPUT_FLOW_ID_DIR	UINT32_C(0x80000000)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_CFA_FLOW_ALLOC_OUTPUT_FLOW_ID_DIR_RX	(UINT32_C(0x0) << 31)
+	/* If this bit is set to 1, then it indicates that tx flow. */
+		#define HWRM_CFA_FLOW_ALLOC_OUTPUT_FLOW_ID_DIR_TX	(UINT32_C(0x1) << 31)
+		#define HWRM_CFA_FLOW_ALLOC_OUTPUT_FLOW_ID_DIR_LAST   HWRM_CFA_FLOW_ALLOC_OUTPUT_FLOW_ID_DIR_TX
+	/* This value identifies a set of CFA data structures used for a flow. */
+	uint64_t	ext_flow_handle;
+	uint32_t	flow_counter_id;
+	uint8_t	unused_1[3];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_port_mac_cfg_output_t, *phwrm_port_mac_cfg_output_t;
+} hwrm_cfa_flow_alloc_output_t, *phwrm_cfa_flow_alloc_output_t;
+
+/* hwrm_cfa_flow_alloc_cmd_err (size:64b/8B) */
+
+typedef struct hwrm_cfa_flow_alloc_cmd_err {
+	/*
+	 * command specific error codes that goes to
+	 * the cmd_err field in Common HWRM Error Response.
+	 */
+	uint8_t	code;
+	/* Unknown error */
+	#define HWRM_CFA_FLOW_ALLOC_CMD_ERR_CODE_UNKNOWN	UINT32_C(0x0)
+	/* No more L2 Context TCAM */
+	#define HWRM_CFA_FLOW_ALLOC_CMD_ERR_CODE_L2_CONTEXT_TCAM UINT32_C(0x1)
+	/* No more action records */
+	#define HWRM_CFA_FLOW_ALLOC_CMD_ERR_CODE_ACTION_RECORD   UINT32_C(0x2)
+	/* No more flow counters */
+	#define HWRM_CFA_FLOW_ALLOC_CMD_ERR_CODE_FLOW_COUNTER	UINT32_C(0x3)
+	/* No more wild-card TCAM */
+	#define HWRM_CFA_FLOW_ALLOC_CMD_ERR_CODE_WILD_CARD_TCAM  UINT32_C(0x4)
+	/* Hash collision in exact match tables */
+	#define HWRM_CFA_FLOW_ALLOC_CMD_ERR_CODE_HASH_COLLISION  UINT32_C(0x5)
+	/* Key is already installed */
+	#define HWRM_CFA_FLOW_ALLOC_CMD_ERR_CODE_KEY_EXISTS	UINT32_C(0x6)
+	/* Flow Context DB is out of resource */
+	#define HWRM_CFA_FLOW_ALLOC_CMD_ERR_CODE_FLOW_CTXT_DB	UINT32_C(0x7)
+	#define HWRM_CFA_FLOW_ALLOC_CMD_ERR_CODE_LAST	HWRM_CFA_FLOW_ALLOC_CMD_ERR_CODE_FLOW_CTXT_DB
+	uint8_t	unused_0[7];
+} hwrm_cfa_flow_alloc_cmd_err_t, *phwrm_cfa_flow_alloc_cmd_err_t;
 
 /**********************
- * hwrm_port_mac_qcfg *
+ * hwrm_cfa_flow_free *
  **********************/
 
 
-/* hwrm_port_mac_qcfg_input (size:192b/24B) */
+/* hwrm_cfa_flow_free_input (size:256b/32B) */
 
-typedef struct hwrm_port_mac_qcfg_input {
+typedef struct hwrm_cfa_flow_free_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -20653,14 +48805,18 @@ typedef struct hwrm_port_mac_qcfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Port ID of port that is to be configured. */
-	uint16_t	port_id;
-	uint8_t	unused_0[6];
-} hwrm_port_mac_qcfg_input_t, *phwrm_port_mac_qcfg_input_t;
+	/* Flow record index. */
+	uint16_t	flow_handle;
+	uint16_t	unused_0;
+	/* Flow counter id to be freed. */
+	uint32_t	flow_counter_id;
+	/* This value identifies a set of CFA data structures used for a flow. */
+	uint64_t	ext_flow_handle;
+} hwrm_cfa_flow_free_input_t, *phwrm_cfa_flow_free_input_t;
 
-/* hwrm_port_mac_qcfg_output (size:256b/32B) */
+/* hwrm_cfa_flow_free_output (size:256b/32B) */
 
-typedef struct hwrm_port_mac_qcfg_output {
+typedef struct hwrm_cfa_flow_free_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -20669,242 +48825,249 @@ typedef struct hwrm_port_mac_qcfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
+	/* packet is 64 b */
+	uint64_t	packet;
+	/* byte is 64 b */
+	uint64_t	byte;
+	uint8_t	unused_0[7];
 	/*
-	 * This is the configured maximum length of Ethernet packet
-	 * payload that is allowed to be received on the port.
-	 * This value does not include the number of bytes used by the
-	 * Ethernet header and trailer (CRC).
-	 */
-	uint16_t	mru;
-	/*
-	 * This is the configured maximum length of Ethernet packet
-	 * payload that is allowed to be transmitted on the port.
-	 * This value does not include the number of bytes used by the
-	 * Ethernet header and trailer (CRC).
-	 */
-	uint16_t	mtu;
-	/*
-	 * The minimum IPG that will
-	 * be sent between packets by this port.
-	 */
-	uint8_t	ipg;
-	/* The loopback setting for the MAC. */
-	uint8_t	lpbk;
-	/* No loopback is selected.  Normal operation. */
-	#define HWRM_PORT_MAC_QCFG_OUTPUT_LPBK_NONE   UINT32_C(0x0)
-	/*
-	 * The HW will be configured with local loopback such that
-	 * host data is sent back to the host without modification.
-	 */
-	#define HWRM_PORT_MAC_QCFG_OUTPUT_LPBK_LOCAL  UINT32_C(0x1)
-	/*
-	 * The HW will be configured with remote loopback such that
-	 * port logic will send packets back out the transmitter that
-	 * are received.
-	 */
-	#define HWRM_PORT_MAC_QCFG_OUTPUT_LPBK_REMOTE UINT32_C(0x2)
-	#define HWRM_PORT_MAC_QCFG_OUTPUT_LPBK_LAST  HWRM_PORT_MAC_QCFG_OUTPUT_LPBK_REMOTE
-	/*
-	 * Priority setting for VLAN PRI to CoS mapping.
-	 * # Each XXX_pri variable shall have a unique priority value
-	 * when it is being used.
-	 * # When comparing priorities of mappings, higher value
-	 * indicates higher priority.
-	 * For example, a value of 0-3 is returned where 0 is being
-	 * the lowest priority and 3 is being the highest priority.
-	 * # If the correspoding CoS mapping is not enabled, then this
-	 * field should be ignored.
-	 * # This value indicates the normalized priority value retained
-	 * in the HWRM.
-	 */
-	uint8_t	vlan_pri2cos_map_pri;
-	/*
-	 * In this field, a number of CoS mappings related flags
-	 * are used to indicate configured CoS mappings.
-	 */
-	uint8_t	flags;
-	/*
-	 * When this bit is set to '1', the inner VLAN PRI to CoS mapping
-	 * is enabled.
-	 */
-	#define HWRM_PORT_MAC_QCFG_OUTPUT_FLAGS_VLAN_PRI2COS_ENABLE	UINT32_C(0x1)
-	/*
-	 * When this bit is set to '1', tunnel VLAN PRI field to
-	 * CoS mapping is enabled.
-	 */
-	#define HWRM_PORT_MAC_QCFG_OUTPUT_FLAGS_TUNNEL_PRI2COS_ENABLE	UINT32_C(0x2)
-	/*
-	 * When this bit is set to '1', the IP DSCP to CoS mapping is
-	 * enabled.
-	 */
-	#define HWRM_PORT_MAC_QCFG_OUTPUT_FLAGS_IP_DSCP2COS_ENABLE	UINT32_C(0x4)
-	/*
-	 * When this bit is '1', the Out-Of-Box WoL is enabled on this
-	 * port.
-	 */
-	#define HWRM_PORT_MAC_QCFG_OUTPUT_FLAGS_OOB_WOL_ENABLE		UINT32_C(0x8)
-	/* When this bit is '1', PTP is enabled for RX on this port. */
-	#define HWRM_PORT_MAC_QCFG_OUTPUT_FLAGS_PTP_RX_TS_CAPTURE_ENABLE	UINT32_C(0x10)
-	/* When this bit is '1', PTP is enabled for TX on this port. */
-	#define HWRM_PORT_MAC_QCFG_OUTPUT_FLAGS_PTP_TX_TS_CAPTURE_ENABLE	UINT32_C(0x20)
-	/*
-	 * Priority setting for tunnel VLAN PRI to CoS mapping.
-	 * # Each XXX_pri variable shall have a unique priority value
-	 * when it is being used.
-	 * # When comparing priorities of mappings, higher value
-	 * indicates higher priority.
-	 * For example, a value of 0-3 is returned where 0 is being
-	 * the lowest priority and 3 is being the highest priority.
-	 * # If the correspoding CoS mapping is not enabled, then this
-	 * field should be ignored.
-	 * # This value indicates the normalized priority value retained
-	 * in the HWRM.
-	 */
-	uint8_t	tunnel_pri2cos_map_pri;
-	/*
-	 * Priority setting for DSCP to PRI mapping.
-	 * # Each XXX_pri variable shall have a unique priority value
-	 * when it is being used.
-	 * # When comparing priorities of mappings, higher value
-	 * indicates higher priority.
-	 * For example, a value of 0-3 is returned where 0 is being
-	 * the lowest priority and 3 is being the highest priority.
-	 * # If the correspoding CoS mapping is not enabled, then this
-	 * field should be ignored.
-	 * # This value indicates the normalized priority value retained
-	 * in the HWRM.
-	 */
-	uint8_t	dscp2pri_map_pri;
-	/*
-	 * This is a 16-bit bit mask that represents the
-	 * current configuration of time stamp capture of PTP messages
-	 * on the receive side of this port.
-	 * If bit 'i' is set, then the receive side of the port
-	 * is configured to capture the time stamp of every
-	 * received PTP message with messageType field value set
-	 * to i.
-	 * If all bits are set to 0 (i.e. field value set 0),
-	 * then the receive side of the port is not configured
-	 * to capture timestamp for PTP messages.
-	 * If all bits are set to 1, then the receive side of the
-	 * port is configured to capture timestamp for all PTP
-	 * messages.
-	 */
-	uint16_t	rx_ts_capture_ptp_msg_type;
-	/*
-	 * This is a 16-bit bit mask that represents the
-	 * current configuration of time stamp capture of PTP messages
-	 * on the transmit side of this port.
-	 * If bit 'i' is set, then the transmit side of the port
-	 * is configured to capture the time stamp of every
-	 * received PTP message with messageType field value set
-	 * to i.
-	 * If all bits are set to 0 (i.e. field value set 0),
-	 * then the transmit side of the port is not configured
-	 * to capture timestamp for PTP messages.
-	 * If all bits are set to 1, then the transmit side of the
-	 * port is configured to capture timestamp for all PTP
-	 * messages.
-	 */
-	uint16_t	tx_ts_capture_ptp_msg_type;
-	/* Configuration of CoS fields. */
-	uint8_t	cos_field_cfg;
-	/* Reserved */
-	#define HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_RSVD			UINT32_C(0x1)
-	/*
-	 * This field is used for selecting VLAN PRI value
-	 * based on whether one or two VLAN Tags are present in
-	 * the inner packet headers of tunneled packets or
-	 * non-tunneled packets.
-	 */
-	#define HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_VLAN_PRI_SEL_MASK	UINT32_C(0x6)
-	#define HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_VLAN_PRI_SEL_SFT	1
-	/*
-	 * Select inner VLAN PRI when 1 or 2 VLAN Tags are
-	 * present in the inner packet headers
-	 */
-		#define HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_VLAN_PRI_SEL_INNERMOST	(UINT32_C(0x0) << 1)
-	/*
-	 * Select outer VLAN Tag PRI when 2 VLAN Tags are
-	 * present in the inner packet headers.
-	 * No VLAN PRI is selected for this configuration
-	 * if only one VLAN Tag is present in the inner
-	 * packet headers.
-	 */
-		#define HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_VLAN_PRI_SEL_OUTER	(UINT32_C(0x1) << 1)
-	/*
-	 * Select outermost VLAN PRI when 1 or 2 VLAN Tags
-	 * are present in the inner packet headers
-	 */
-		#define HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_VLAN_PRI_SEL_OUTERMOST	(UINT32_C(0x2) << 1)
-	/* Unspecified */
-		#define HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_VLAN_PRI_SEL_UNSPECIFIED	(UINT32_C(0x3) << 1)
-		#define HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_VLAN_PRI_SEL_LAST	HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_VLAN_PRI_SEL_UNSPECIFIED
-	/*
-	 * This field is used for selecting tunnel VLAN PRI value
-	 * based on whether one or two VLAN Tags are present in
-	 * the tunnel headers of tunneled packets. This selection
-	 * does not apply to non-tunneled packets.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	#define HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_T_VLAN_PRI_SEL_MASK	UINT32_C(0x18)
-	#define HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_T_VLAN_PRI_SEL_SFT	3
+	uint8_t	valid;
+} hwrm_cfa_flow_free_output_t, *phwrm_cfa_flow_free_output_t;
+
+/* hwrm_cfa_flow_action_data (size:960b/120B) */
+
+typedef struct hwrm_cfa_flow_action_data {
+	uint16_t	action_flags;
+	/* Setting of this flag indicates accept action. */
+	#define HWRM_CFA_FLOW_ACTION_DATA_ACTION_FLAGS_FWD			UINT32_C(0x1)
+	/* Setting of this flag indicates recycle action. */
+	#define HWRM_CFA_FLOW_ACTION_DATA_ACTION_FLAGS_RECYCLE		UINT32_C(0x2)
+	/* Setting of this flag indicates drop action. */
+	#define HWRM_CFA_FLOW_ACTION_DATA_ACTION_FLAGS_DROP		UINT32_C(0x4)
+	/* Setting of this flag indicates meter action. */
+	#define HWRM_CFA_FLOW_ACTION_DATA_ACTION_FLAGS_METER		UINT32_C(0x8)
+	/* Setting of this flag indicates tunnel action. */
+	#define HWRM_CFA_FLOW_ACTION_DATA_ACTION_FLAGS_TUNNEL		UINT32_C(0x10)
 	/*
-	 * Select inner VLAN PRI when 1 or 2 VLAN Tags are
-	 * present in the tunnel packet headers
+	 * If set to 1 and flow direction is TX, it indicates decap of L2
+	 * header and encap of tunnel header. If set to 1 and flow direction
+	 * is RX, it indicates decap of tunnel header and encap L2 header.
 	 */
-		#define HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_T_VLAN_PRI_SEL_INNERMOST	(UINT32_C(0x0) << 3)
+	#define HWRM_CFA_FLOW_ACTION_DATA_ACTION_FLAGS_TUNNEL_IP		UINT32_C(0x20)
+	/* Setting of this flag indicates ttl decrement action. */
+	#define HWRM_CFA_FLOW_ACTION_DATA_ACTION_FLAGS_TTL_DECREMENT	UINT32_C(0x40)
+	/* If set to 1, flow aging is enabled for this flow. */
+	#define HWRM_CFA_FLOW_ACTION_DATA_ACTION_FLAGS_FLOW_AGING_ENABLED	UINT32_C(0x80)
+	/* Setting of this flag indicates encap action. */
+	#define HWRM_CFA_FLOW_ACTION_DATA_ACTION_FLAGS_ENCAP		UINT32_C(0x100)
+	/* Setting of this flag indicates decap action. */
+	#define HWRM_CFA_FLOW_ACTION_DATA_ACTION_FLAGS_DECAP		UINT32_C(0x200)
+	/* Meter id. */
+	uint16_t	act_meter_id;
+	/* VNIC id. */
+	uint16_t	vnic_id;
+	/* vport number. */
+	uint16_t	vport_id;
+	/* The NAT source/destination. */
+	uint16_t	nat_port;
+	uint16_t	unused_0[3];
+	/* NAT IPv4/IPv6 address. */
+	uint32_t	nat_ip_address[4];
+	/* Encapsulation Type. */
+	uint8_t	encap_type;
+	/* Virtual eXtensible Local Area Network (VXLAN) */
+	#define HWRM_CFA_FLOW_ACTION_DATA_ENCAP_TYPE_VXLAN	UINT32_C(0x1)
+	/* Network Virtualization Generic Routing Encapsulation (NVGRE) */
+	#define HWRM_CFA_FLOW_ACTION_DATA_ENCAP_TYPE_NVGRE	UINT32_C(0x2)
+	/* Generic Routing Encapsulation (GRE) after inside Ethernet payload */
+	#define HWRM_CFA_FLOW_ACTION_DATA_ENCAP_TYPE_L2GRE	UINT32_C(0x3)
+	/* IP in IP */
+	#define HWRM_CFA_FLOW_ACTION_DATA_ENCAP_TYPE_IPIP	UINT32_C(0x4)
+	/* Generic Network Virtualization Encapsulation (Geneve) */
+	#define HWRM_CFA_FLOW_ACTION_DATA_ENCAP_TYPE_GENEVE	UINT32_C(0x5)
+	/* Multi-Protocol Label Switching (MPLS) */
+	#define HWRM_CFA_FLOW_ACTION_DATA_ENCAP_TYPE_MPLS	UINT32_C(0x6)
+	/* VLAN */
+	#define HWRM_CFA_FLOW_ACTION_DATA_ENCAP_TYPE_VLAN	UINT32_C(0x7)
+	/* Generic Routing Encapsulation (GRE) inside IP datagram payload */
+	#define HWRM_CFA_FLOW_ACTION_DATA_ENCAP_TYPE_IPGRE	UINT32_C(0x8)
+	/* IPV4 over virtual eXtensible Local Area Network (IPV4oVXLAN) */
+	#define HWRM_CFA_FLOW_ACTION_DATA_ENCAP_TYPE_VXLAN_V4	UINT32_C(0x9)
 	/*
-	 * Select outer VLAN Tag PRI when 2 VLAN Tags are
-	 * present in the tunnel packet headers.
-	 * No VLAN PRI is selected for this configuration
-	 * if only one VLAN Tag is present in the tunnel
-	 * packet headers.
+	 * Enhance Generic Routing Encapsulation (GRE version 1) inside IP
+	 * datagram payload
 	 */
-		#define HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_T_VLAN_PRI_SEL_OUTER	(UINT32_C(0x1) << 3)
+	#define HWRM_CFA_FLOW_ACTION_DATA_ENCAP_TYPE_IPGRE_V1	UINT32_C(0xa)
+	/* Use fixed layer 2 ether type of 0xFFFF */
+	#define HWRM_CFA_FLOW_ACTION_DATA_ENCAP_TYPE_L2_ETYPE	UINT32_C(0xb)
 	/*
-	 * Select outermost VLAN PRI when 1 or 2 VLAN Tags
-	 * are present in the tunnel packet headers
+	 * IPV6 over virtual eXtensible Local Area Network with GPE header
+	 * (IPV6oVXLANGPE)
 	 */
-		#define HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_T_VLAN_PRI_SEL_OUTERMOST	(UINT32_C(0x2) << 3)
-	/* Unspecified */
-		#define HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_T_VLAN_PRI_SEL_UNSPECIFIED  (UINT32_C(0x3) << 3)
-		#define HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_T_VLAN_PRI_SEL_LAST	HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_T_VLAN_PRI_SEL_UNSPECIFIED
+	#define HWRM_CFA_FLOW_ACTION_DATA_ENCAP_TYPE_VXLAN_GPE_V6 UINT32_C(0xc)
+	/* Generic Protocol Extension for VXLAN (VXLAN-GPE) */
+	#define HWRM_CFA_FLOW_ACTION_DATA_ENCAP_TYPE_VXLAN_GPE	UINT32_C(0x10)
+	#define HWRM_CFA_FLOW_ACTION_DATA_ENCAP_TYPE_LAST	HWRM_CFA_FLOW_ACTION_DATA_ENCAP_TYPE_VXLAN_GPE
+	uint8_t	unused[7];
+	/* This value is encap data for the associated encap type. */
+	uint32_t	encap_data[20];
+} hwrm_cfa_flow_action_data_t, *phwrm_cfa_flow_action_data_t;
+
+/* hwrm_cfa_flow_tunnel_hdr_data (size:64b/8B) */
+
+typedef struct hwrm_cfa_flow_tunnel_hdr_data {
+	/* Tunnel Type. */
+	uint8_t	tunnel_type;
+	/* Non-tunnel */
+	#define HWRM_CFA_FLOW_TUNNEL_HDR_DATA_TUNNEL_TYPE_NONTUNNEL	UINT32_C(0x0)
+	/* Virtual eXtensible Local Area Network (VXLAN) */
+	#define HWRM_CFA_FLOW_TUNNEL_HDR_DATA_TUNNEL_TYPE_VXLAN	UINT32_C(0x1)
+	/* Network Virtualization Generic Routing Encapsulation (NVGRE) */
+	#define HWRM_CFA_FLOW_TUNNEL_HDR_DATA_TUNNEL_TYPE_NVGRE	UINT32_C(0x2)
+	/* Generic Routing Encapsulation (GRE) inside Ethernet payload */
+	#define HWRM_CFA_FLOW_TUNNEL_HDR_DATA_TUNNEL_TYPE_L2GRE	UINT32_C(0x3)
+	/* IP in IP */
+	#define HWRM_CFA_FLOW_TUNNEL_HDR_DATA_TUNNEL_TYPE_IPIP	UINT32_C(0x4)
+	/* Generic Network Virtualization Encapsulation (Geneve) */
+	#define HWRM_CFA_FLOW_TUNNEL_HDR_DATA_TUNNEL_TYPE_GENEVE	UINT32_C(0x5)
+	/* Multi-Protocol Label Switching (MPLS) */
+	#define HWRM_CFA_FLOW_TUNNEL_HDR_DATA_TUNNEL_TYPE_MPLS	UINT32_C(0x6)
+	/* Stateless Transport Tunnel (STT) */
+	#define HWRM_CFA_FLOW_TUNNEL_HDR_DATA_TUNNEL_TYPE_STT	UINT32_C(0x7)
+	/* Generic Routing Encapsulation (GRE) inside IP datagram payload */
+	#define HWRM_CFA_FLOW_TUNNEL_HDR_DATA_TUNNEL_TYPE_IPGRE	UINT32_C(0x8)
+	/* IPV4 over virtual eXtensible Local Area Network (IPV4oVXLAN) */
+	#define HWRM_CFA_FLOW_TUNNEL_HDR_DATA_TUNNEL_TYPE_VXLAN_V4	UINT32_C(0x9)
 	/*
-	 * This field is used to provide default CoS value that
-	 * has been configured on this port.
+	 * Enhance Generic Routing Encapsulation (GRE version 1) inside IP
+	 * datagram payload
 	 */
-	#define HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_DEFAULT_COS_MASK	UINT32_C(0xe0)
-	#define HWRM_PORT_MAC_QCFG_OUTPUT_COS_FIELD_CFG_DEFAULT_COS_SFT	5
-	uint8_t	unused_1;
-	uint16_t	port_svif_info;
+	#define HWRM_CFA_FLOW_TUNNEL_HDR_DATA_TUNNEL_TYPE_IPGRE_V1	UINT32_C(0xa)
+	/* Use fixed layer 2 ether type of 0xFFFF */
+	#define HWRM_CFA_FLOW_TUNNEL_HDR_DATA_TUNNEL_TYPE_L2_ETYPE	UINT32_C(0xb)
 	/*
-	 * This field specifies the source virtual interface of the port being
-	 * queried. Drivers can use this to program port svif field in the
-	 * L2 context table
+	 * IPV6 over virtual eXtensible Local Area Network with GPE header
+	 * (IPV6oVXLANGPE)
 	 */
-	#define HWRM_PORT_MAC_QCFG_OUTPUT_PORT_SVIF_INFO_PORT_SVIF_MASK	UINT32_C(0x7fff)
-	#define HWRM_PORT_MAC_QCFG_OUTPUT_PORT_SVIF_INFO_PORT_SVIF_SFT	0
-	/* This field specifies whether port_svif is valid or not */
-	#define HWRM_PORT_MAC_QCFG_OUTPUT_PORT_SVIF_INFO_PORT_SVIF_VALID	UINT32_C(0x8000)
-	uint8_t	unused_2[5];
+	#define HWRM_CFA_FLOW_TUNNEL_HDR_DATA_TUNNEL_TYPE_VXLAN_GPE_V6 UINT32_C(0xc)
+	/* Generic Protocol Extension for VXLAN (VXLAN-GPE) */
+	#define HWRM_CFA_FLOW_TUNNEL_HDR_DATA_TUNNEL_TYPE_VXLAN_GPE	UINT32_C(0x10)
+	/* Any tunneled traffic */
+	#define HWRM_CFA_FLOW_TUNNEL_HDR_DATA_TUNNEL_TYPE_ANYTUNNEL	UINT32_C(0xff)
+	#define HWRM_CFA_FLOW_TUNNEL_HDR_DATA_TUNNEL_TYPE_LAST	HWRM_CFA_FLOW_TUNNEL_HDR_DATA_TUNNEL_TYPE_ANYTUNNEL
+	uint8_t	unused[3];
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * Tunnel identifier.
+	 * Virtual Network Identifier (VNI).
 	 */
-	uint8_t	valid;
-} hwrm_port_mac_qcfg_output_t, *phwrm_port_mac_qcfg_output_t;
+	uint32_t	tunnel_id;
+} hwrm_cfa_flow_tunnel_hdr_data_t, *phwrm_cfa_flow_tunnel_hdr_data_t;
 
-/**************************
- * hwrm_port_mac_ptp_qcfg *
- **************************/
+/* hwrm_cfa_flow_l4_key_data (size:64b/8B) */
 
+typedef struct hwrm_cfa_flow_l4_key_data {
+	/* The value of source port. */
+	uint16_t	l4_src_port;
+	/* The value of destination port. */
+	uint16_t	l4_dst_port;
+	uint32_t	unused;
+} hwrm_cfa_flow_l4_key_data_t, *phwrm_cfa_flow_l4_key_data_t;
 
-/* hwrm_port_mac_ptp_qcfg_input (size:192b/24B) */
+/* hwrm_cfa_flow_l3_key_data (size:512b/64B) */
 
-typedef struct hwrm_port_mac_ptp_qcfg_input {
+typedef struct hwrm_cfa_flow_l3_key_data {
+	/* The value of ip protocol. */
+	uint8_t	ip_protocol;
+	uint8_t	unused_0[7];
+	/* The value of destination IPv4/IPv6 address. */
+	uint32_t	ip_dst[4];
+	/* The source IPv4/IPv6 address. */
+	uint32_t	ip_src[4];
+	/* NAT IPv4/IPv6 address. */
+	uint32_t	nat_ip_address[4];
+	uint64_t	unused;
+} hwrm_cfa_flow_l3_key_data_t, *phwrm_cfa_flow_l3_key_data_t;
+
+/* hwrm_cfa_flow_l2_key_data (size:448b/56B) */
+
+typedef struct hwrm_cfa_flow_l2_key_data {
+	/* Destination MAC address. */
+	uint16_t	dmac[3];
+	uint16_t	unused_0;
+	/* Source MAC address. */
+	uint16_t	smac[3];
+	uint16_t	unused_1;
+	/* L2 header re-write Destination MAC address. */
+	uint16_t	l2_rewrite_dmac[3];
+	uint16_t	unused_2;
+	/* L2 header re-write Source MAC address. */
+	uint16_t	l2_rewrite_smac[3];
+	/* Ethertype. */
+	uint16_t	ethertype;
+	/* Number of VLAN tags. */
+	uint16_t	num_vlan_tags;
+	/* VLAN tpid. */
+	uint16_t	l2_rewrite_vlan_tpid;
+	/* VLAN tci. */
+	uint16_t	l2_rewrite_vlan_tci;
+	uint8_t	unused_3[2];
+	/* Outer VLAN TPID. */
+	uint16_t	ovlan_tpid;
+	/* Outer VLAN TCI. */
+	uint16_t	ovlan_tci;
+	/* Inner VLAN TPID. */
+	uint16_t	ivlan_tpid;
+	/* Inner VLAN TCI. */
+	uint16_t	ivlan_tci;
+	uint8_t	unused[8];
+} hwrm_cfa_flow_l2_key_data_t, *phwrm_cfa_flow_l2_key_data_t;
+
+/* hwrm_cfa_flow_key_data (size:4160b/520B) */
+
+typedef struct hwrm_cfa_flow_key_data {
+	/* Flow associated tunnel L2 header key info. */
+	uint32_t	t_l2_key_data[14];
+	/* Flow associated tunnel L2 header mask info. */
+	uint32_t	t_l2_key_mask[14];
+	/* Flow associated tunnel L3 header key info. */
+	uint32_t	t_l3_key_data[16];
+	/* Flow associated tunnel L3 header mask info. */
+	uint32_t	t_l3_key_mask[16];
+	/* Flow associated tunnel L4 header key info. */
+	uint64_t	t_l4_key_data;
+	/* Flow associated tunnel L4 header mask info. */
+	uint64_t	t_l4_key_mask;
+	/* Flow associated tunnel header info. */
+	uint64_t	tunnel_hdr;
+	/* Flow associated L2 header key info. */
+	uint32_t	l2_key_data[14];
+	/* Flow associated L2 header mask info. */
+	uint32_t	l2_key_mask[14];
+	/* Flow associated L3 header key info. */
+	uint32_t	l3_key_data[16];
+	/* Flow associated L3 header mask info. */
+	uint32_t	l3_key_mask[16];
+	/* Flow associated L4 header key info. */
+	uint64_t	l4_key_data;
+	/* Flow associated L4 header mask info. */
+	uint64_t	l4_key_mask;
+} hwrm_cfa_flow_key_data_t, *phwrm_cfa_flow_key_data_t;
+
+/**********************
+ * hwrm_cfa_flow_info *
+ **********************/
+
+
+/* hwrm_cfa_flow_info_input (size:256b/32B) */
+
+typedef struct hwrm_cfa_flow_info_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -20933,14 +49096,37 @@ typedef struct hwrm_port_mac_ptp_qcfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Port ID of port that is being queried. */
-	uint16_t	port_id;
+	/* Flow record index. */
+	uint16_t	flow_handle;
+	/* Max flow handle */
+	#define HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_MAX_MASK	UINT32_C(0xfff)
+	/* CNP flow handle */
+	#define HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_CNP_CNT	UINT32_C(0x1000)
+	/* RoCEv1 flow handle */
+	#define HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_ROCEV1_CNT	UINT32_C(0x2000)
+	/* NIC flow handle */
+	#define HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_NIC_TX	UINT32_C(0x3000)
+	/* RoCEv2 flow handle */
+	#define HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_ROCEV2_CNT	UINT32_C(0x4000)
+	/* Direction rx = 1 */
+	#define HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_DIR_RX	UINT32_C(0x8000)
+	/* CNP flow handle */
+	#define HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_CNP_CNT_RX	UINT32_C(0x9000)
+	/* RoCEv1 flow handle */
+	#define HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_ROCEV1_CNT_RX UINT32_C(0xa000)
+	/* NIC flow handle */
+	#define HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_NIC_RX	UINT32_C(0xb000)
+	/* RoCEv2 flow handle */
+	#define HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_ROCEV2_CNT_RX UINT32_C(0xc000)
+	#define HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_LAST	HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_ROCEV2_CNT_RX
 	uint8_t	unused_0[6];
-} hwrm_port_mac_ptp_qcfg_input_t, *phwrm_port_mac_ptp_qcfg_input_t;
+	/* This value identifies a set of CFA data structures used for a flow. */
+	uint64_t	ext_flow_handle;
+} hwrm_cfa_flow_info_input_t, *phwrm_cfa_flow_info_input_t;
 
-/* hwrm_port_mac_ptp_qcfg_output (size:640b/80B) */
+/* hwrm_cfa_flow_info_output (size:5632b/704B) */
 
-typedef struct hwrm_port_mac_ptp_qcfg_output {
+typedef struct hwrm_cfa_flow_info_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -20949,434 +49135,387 @@ typedef struct hwrm_port_mac_ptp_qcfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/*
-	 * In this field, a number of PTP related flags
-	 * are used to indicate configured PTP capabilities.
-	 */
 	uint8_t	flags;
-	/*
-	 * When this bit is set to '1', the PTP related registers are
-	 * directly accessible by the host.
-	 */
-	#define HWRM_PORT_MAC_PTP_QCFG_OUTPUT_FLAGS_DIRECT_ACCESS	UINT32_C(0x1)
-	/*
-	 * When this bit is set to '1', the device supports one-step
-	 * Tx timestamping.
-	 */
-	#define HWRM_PORT_MAC_PTP_QCFG_OUTPUT_FLAGS_ONE_STEP_TX_TS	UINT32_C(0x4)
-	/*
-	 * When this bit is set to '1', the PTP information is accessible
-	 * via HWRM commands.
-	 */
-	#define HWRM_PORT_MAC_PTP_QCFG_OUTPUT_FLAGS_HWRM_ACCESS	UINT32_C(0x8)
-	uint8_t	unused_0[3];
-	/* Offset of the PTP register for the lower 32 bits of timestamp for RX. */
-	uint32_t	rx_ts_reg_off_lower;
-	/* Offset of the PTP register for the upper 32 bits of timestamp for RX. */
-	uint32_t	rx_ts_reg_off_upper;
-	/* Offset of the PTP register for the sequence ID for RX. */
-	uint32_t	rx_ts_reg_off_seq_id;
-	/* Offset of the first PTP source ID for RX. */
-	uint32_t	rx_ts_reg_off_src_id_0;
-	/* Offset of the second PTP source ID for RX. */
-	uint32_t	rx_ts_reg_off_src_id_1;
-	/* Offset of the third PTP source ID for RX. */
-	uint32_t	rx_ts_reg_off_src_id_2;
-	/* Offset of the domain ID for RX. */
-	uint32_t	rx_ts_reg_off_domain_id;
-	/* Offset of the PTP FIFO register for RX. */
-	uint32_t	rx_ts_reg_off_fifo;
-	/* Offset of the PTP advance FIFO register for RX. */
-	uint32_t	rx_ts_reg_off_fifo_adv;
-	/* PTP timestamp granularity for RX. */
-	uint32_t	rx_ts_reg_off_granularity;
-	/* Offset of the PTP register for the lower 32 bits of timestamp for TX. */
-	uint32_t	tx_ts_reg_off_lower;
-	/* Offset of the PTP register for the upper 32 bits of timestamp for TX. */
-	uint32_t	tx_ts_reg_off_upper;
-	/* Offset of the PTP register for the sequence ID for TX. */
-	uint32_t	tx_ts_reg_off_seq_id;
-	/* Offset of the PTP FIFO register for TX. */
-	uint32_t	tx_ts_reg_off_fifo;
-	/* PTP timestamp granularity for TX. */
-	uint32_t	tx_ts_reg_off_granularity;
+	/* When set to 1, indicates the configuration is the TX flow. */
+	#define HWRM_CFA_FLOW_INFO_OUTPUT_FLAGS_PATH_TX	UINT32_C(0x1)
+	/* When set to 1, indicates the configuration is the RX flow. */
+	#define HWRM_CFA_FLOW_INFO_OUTPUT_FLAGS_PATH_RX	UINT32_C(0x2)
+	/* profile is 8 b */
+	uint8_t	profile;
+	/* src_fid is 16 b */
+	uint16_t	src_fid;
+	/* dst_fid is 16 b */
+	uint16_t	dst_fid;
+	/* l2_ctxt_id is 16 b */
+	uint16_t	l2_ctxt_id;
+	/* em_info is 64 b */
+	uint64_t	em_info;
+	/* tcam_info is 64 b */
+	uint64_t	tcam_info;
+	/* vfp_tcam_info is 64 b */
+	uint64_t	vfp_tcam_info;
+	/* ar_id is 16 b */
+	uint16_t	ar_id;
+	/* flow_handle is 16 b */
+	uint16_t	flow_handle;
+	/* tunnel_handle is 32 b */
+	uint32_t	tunnel_handle;
+	/* The flow aging timer for the flow, the unit is 100 milliseconds */
+	uint16_t	flow_timer;
+	uint8_t	unused_0[6];
+	/* Flow associated L2, L3 and L4 headers info. */
+	uint32_t	flow_key_data[130];
+	/* Flow associated action record info. */
+	uint32_t	flow_action_info[30];
 	uint8_t	unused_1[7];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_port_mac_ptp_qcfg_output_t, *phwrm_port_mac_ptp_qcfg_output_t;
+} hwrm_cfa_flow_info_output_t, *phwrm_cfa_flow_info_output_t;
 
-/* Port Tx Statistics Format */
-/* tx_port_stats (size:3264b/408B) */
+/***********************
+ * hwrm_cfa_flow_flush *
+ ***********************/
 
-typedef struct tx_port_stats {
-	/* Total Number of 64 Bytes frames transmitted */
-	uint64_t	tx_64b_frames;
-	/* Total Number of 65-127 Bytes frames transmitted */
-	uint64_t	tx_65b_127b_frames;
-	/* Total Number of 128-255 Bytes frames transmitted */
-	uint64_t	tx_128b_255b_frames;
-	/* Total Number of 256-511 Bytes frames transmitted */
-	uint64_t	tx_256b_511b_frames;
-	/* Total Number of 512-1023 Bytes frames transmitted */
-	uint64_t	tx_512b_1023b_frames;
-	/* Total Number of 1024-1518 Bytes frames transmitted */
-	uint64_t	tx_1024b_1518b_frames;
-	/*
-	 * Total Number of each good VLAN (exludes FCS errors)
-	 * frame transmitted which is 1519 to 1522 bytes in length
-	 * inclusive (excluding framing bits but including FCS bytes).
-	 */
-	uint64_t	tx_good_vlan_frames;
-	/* Total Number of 1519-2047 Bytes frames transmitted */
-	uint64_t	tx_1519b_2047b_frames;
-	/* Total Number of 2048-4095 Bytes frames transmitted */
-	uint64_t	tx_2048b_4095b_frames;
-	/* Total Number of 4096-9216 Bytes frames transmitted */
-	uint64_t	tx_4096b_9216b_frames;
-	/* Total Number of 9217-16383 Bytes frames transmitted */
-	uint64_t	tx_9217b_16383b_frames;
-	/* Total Number of good frames transmitted */
-	uint64_t	tx_good_frames;
-	/* Total Number of frames transmitted */
-	uint64_t	tx_total_frames;
-	/* Total number of unicast frames transmitted */
-	uint64_t	tx_ucast_frames;
-	/* Total number of multicast frames transmitted */
-	uint64_t	tx_mcast_frames;
-	/* Total number of broadcast frames transmitted */
-	uint64_t	tx_bcast_frames;
-	/* Total number of PAUSE control frames transmitted */
-	uint64_t	tx_pause_frames;
-	/*
-	 * Total number of PFC/per-priority PAUSE
-	 * control frames transmitted
-	 */
-	uint64_t	tx_pfc_frames;
-	/* Total number of jabber frames transmitted */
-	uint64_t	tx_jabber_frames;
-	/* Total number of frames transmitted with FCS error */
-	uint64_t	tx_fcs_err_frames;
-	/* Total number of control frames transmitted */
-	uint64_t	tx_control_frames;
-	/* Total number of over-sized frames transmitted */
-	uint64_t	tx_oversz_frames;
-	/* Total number of frames with single deferral */
-	uint64_t	tx_single_dfrl_frames;
-	/* Total number of frames with multiple deferrals */
-	uint64_t	tx_multi_dfrl_frames;
-	/* Total number of frames with single collision */
-	uint64_t	tx_single_coll_frames;
-	/* Total number of frames with multiple collisions */
-	uint64_t	tx_multi_coll_frames;
-	/* Total number of frames with late collisions */
-	uint64_t	tx_late_coll_frames;
-	/* Total number of frames with excessive collisions */
-	uint64_t	tx_excessive_coll_frames;
-	/* Total number of fragmented frames transmitted */
-	uint64_t	tx_frag_frames;
-	/* Total number of transmit errors */
-	uint64_t	tx_err;
-	/* Total number of single VLAN tagged frames transmitted */
-	uint64_t	tx_tagged_frames;
-	/* Total number of double VLAN tagged frames transmitted */
-	uint64_t	tx_dbl_tagged_frames;
-	/* Total number of runt frames transmitted */
-	uint64_t	tx_runt_frames;
-	/* Total number of TX FIFO under runs */
-	uint64_t	tx_fifo_underruns;
-	/*
-	 * Total number of PFC frames with PFC enabled bit for
-	 * Pri 0 transmitted
-	 */
-	uint64_t	tx_pfc_ena_frames_pri0;
-	/*
-	 * Total number of PFC frames with PFC enabled bit for
-	 * Pri 1 transmitted
-	 */
-	uint64_t	tx_pfc_ena_frames_pri1;
-	/*
-	 * Total number of PFC frames with PFC enabled bit for
-	 * Pri 2 transmitted
-	 */
-	uint64_t	tx_pfc_ena_frames_pri2;
-	/*
-	 * Total number of PFC frames with PFC enabled bit for
-	 * Pri 3 transmitted
-	 */
-	uint64_t	tx_pfc_ena_frames_pri3;
-	/*
-	 * Total number of PFC frames with PFC enabled bit for
-	 * Pri 4 transmitted
-	 */
-	uint64_t	tx_pfc_ena_frames_pri4;
-	/*
-	 * Total number of PFC frames with PFC enabled bit for
-	 * Pri 5 transmitted
-	 */
-	uint64_t	tx_pfc_ena_frames_pri5;
+
+/* hwrm_cfa_flow_flush_input (size:256b/32B) */
+
+typedef struct hwrm_cfa_flow_flush_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * Total number of PFC frames with PFC enabled bit for
-	 * Pri 6 transmitted
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint64_t	tx_pfc_ena_frames_pri6;
+	uint16_t	cmpl_ring;
 	/*
-	 * Total number of PFC frames with PFC enabled bit for
-	 * Pri 7 transmitted
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint64_t	tx_pfc_ena_frames_pri7;
-	/* Total number of EEE LPI Events on TX */
-	uint64_t	tx_eee_lpi_events;
-	/* EEE LPI Duration Counter on TX */
-	uint64_t	tx_eee_lpi_duration;
+	uint16_t	seq_id;
 	/*
-	 * Total number of Link Level Flow Control (LLFC) messages
-	 * transmitted
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint64_t	tx_llfc_logical_msgs;
-	/* Total number of HCFC messages transmitted */
-	uint64_t	tx_hcfc_msgs;
-	/* Total number of TX collisions */
-	uint64_t	tx_total_collisions;
-	/* Total number of transmitted bytes */
-	uint64_t	tx_bytes;
-	/* Total number of end-to-end HOL frames */
-	uint64_t	tx_xthol_frames;
-	/* Total Tx Drops per Port reported by STATS block */
-	uint64_t	tx_stat_discard;
-	/* Total Tx Error Drops per Port reported by STATS block */
-	uint64_t	tx_stat_error;
-} tx_port_stats_t, *ptx_port_stats_t;
-
-/* Port Rx Statistics Format */
-/* rx_port_stats (size:4224b/528B) */
-
-typedef struct rx_port_stats {
-	/* Total Number of 64 Bytes frames received */
-	uint64_t	rx_64b_frames;
-	/* Total Number of 65-127 Bytes frames received */
-	uint64_t	rx_65b_127b_frames;
-	/* Total Number of 128-255 Bytes frames received */
-	uint64_t	rx_128b_255b_frames;
-	/* Total Number of 256-511 Bytes frames received */
-	uint64_t	rx_256b_511b_frames;
-	/* Total Number of 512-1023 Bytes frames received */
-	uint64_t	rx_512b_1023b_frames;
-	/* Total Number of 1024-1518 Bytes frames received */
-	uint64_t	rx_1024b_1518b_frames;
+	uint16_t	target_id;
 	/*
-	 * Total Number of each good VLAN (exludes FCS errors)
-	 * frame received which is 1519 to 1522 bytes in length
-	 * inclusive (excluding framing bits but including FCS bytes).
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint64_t	rx_good_vlan_frames;
-	/* Total Number of 1519-2047 Bytes frames received */
-	uint64_t	rx_1519b_2047b_frames;
-	/* Total Number of 2048-4095 Bytes frames received */
-	uint64_t	rx_2048b_4095b_frames;
-	/* Total Number of 4096-9216 Bytes frames received */
-	uint64_t	rx_4096b_9216b_frames;
-	/* Total Number of 9217-16383 Bytes frames received */
-	uint64_t	rx_9217b_16383b_frames;
-	/* Total number of frames received */
-	uint64_t	rx_total_frames;
-	/* Total number of unicast frames received */
-	uint64_t	rx_ucast_frames;
-	/* Total number of multicast frames received */
-	uint64_t	rx_mcast_frames;
-	/* Total number of broadcast frames received */
-	uint64_t	rx_bcast_frames;
-	/* Total number of received frames with FCS error */
-	uint64_t	rx_fcs_err_frames;
-	/* Total number of control frames received */
-	uint64_t	rx_ctrl_frames;
-	/* Total number of PAUSE frames received */
-	uint64_t	rx_pause_frames;
-	/* Total number of PFC frames received */
-	uint64_t	rx_pfc_frames;
+	uint64_t	resp_addr;
+	/* flags is 32 b */
+	uint32_t	flags;
 	/*
-	 * Total number of frames received with an unsupported
-	 * opcode
+	 * Set to 1 to indicate the page size, page layers, and
+	 * flow_handle_table_dma_addr fields are valid. The flow flush
+	 * operation should only flush the flows from the flow table
+	 * specified. This flag is set to 0 by older driver. For older
+	 * firmware, setting this flag has no effect.
 	 */
-	uint64_t	rx_unsupported_opcode_frames;
+	#define HWRM_CFA_FLOW_FLUSH_INPUT_FLAGS_FLOW_TABLE_VALID			UINT32_C(0x1)
 	/*
-	 * Total number of frames received with an unsupported
-	 * DA for pause and PFC
+	 * Set to 1 to indicate flow flush operation to cleanup all the
+	 * flows, meters, CFA context memory tables etc. This flag is set to
+	 * 0 by older driver. For older firmware, setting this flag has no
+	 * effect.
 	 */
-	uint64_t	rx_unsupported_da_pausepfc_frames;
-	/* Total number of frames received with an unsupported SA */
-	uint64_t	rx_wrong_sa_frames;
-	/* Total number of received packets with alignment error */
-	uint64_t	rx_align_err_frames;
-	/* Total number of received frames with out-of-range length */
-	uint64_t	rx_oor_len_frames;
-	/* Total number of received frames with error termination */
-	uint64_t	rx_code_err_frames;
+	#define HWRM_CFA_FLOW_FLUSH_INPUT_FLAGS_FLOW_RESET_ALL			UINT32_C(0x2)
 	/*
-	 * Total number of received frames with a false carrier is
-	 * detected during idle, as defined by RX_ER samples active
-	 * and RXD is 0xE. The event is reported along with the
-	 * statistics generated on the next received frame. Only
-	 * one false carrier condition can be detected and logged
-	 * between frames.
-	 *
-	 * Carrier event, valid for 10M/100M speed modes only.
+	 * Set to 1 to indicate flow flush operation to cleanup all the
+	 * flows by the caller. This flag is set to 0 by older driver. For
+	 * older firmware, setting this flag has no effect.
 	 */
-	uint64_t	rx_false_carrier_frames;
-	/* Total number of over-sized frames received */
-	uint64_t	rx_ovrsz_frames;
-	/* Total number of jabber packets received */
-	uint64_t	rx_jbr_frames;
-	/* Total number of received frames with MTU error */
-	uint64_t	rx_mtu_err_frames;
-	/* Total number of received frames with CRC match */
-	uint64_t	rx_match_crc_frames;
-	/* Total number of frames received promiscuously */
-	uint64_t	rx_promiscuous_frames;
+	#define HWRM_CFA_FLOW_FLUSH_INPUT_FLAGS_FLOW_RESET_PORT			UINT32_C(0x4)
 	/*
-	 * Total number of received frames with one or two VLAN
-	 * tags
+	 * Set to 1 to indicate the flow counter IDs are included in the
+	 * flow table.
 	 */
-	uint64_t	rx_tagged_frames;
-	/* Total number of received frames with two VLAN tags */
-	uint64_t	rx_double_tagged_frames;
-	/* Total number of truncated frames received */
-	uint64_t	rx_trunc_frames;
-	/* Total number of good frames (without errors) received */
-	uint64_t	rx_good_frames;
+	#define HWRM_CFA_FLOW_FLUSH_INPUT_FLAGS_FLOW_HANDLE_INCL_FC		UINT32_C(0x8000000)
 	/*
-	 * Total number of received PFC frames with transition from
-	 * XON to XOFF on Pri 0
+	 * This specifies the size of flow handle entries provided by the
+	 * driver in the flow table specified below. Only two flow handle
+	 * size enums are defined.
 	 */
-	uint64_t	rx_pfc_xon2xoff_frames_pri0;
-	/*
-	 * Total number of received PFC frames with transition from
-	 * XON to XOFF on Pri 1
+	#define HWRM_CFA_FLOW_FLUSH_INPUT_FLAGS_FLOW_HANDLE_ENTRY_SIZE_MASK	UINT32_C(0xc0000000)
+	#define HWRM_CFA_FLOW_FLUSH_INPUT_FLAGS_FLOW_HANDLE_ENTRY_SIZE_SFT	30
+	/* The flow handle is 16bit */
+		#define HWRM_CFA_FLOW_FLUSH_INPUT_FLAGS_FLOW_HANDLE_ENTRY_SIZE_FLOW_HND_16BIT  (UINT32_C(0x0) << 30)
+	/* The flow handle is 64bit */
+		#define HWRM_CFA_FLOW_FLUSH_INPUT_FLAGS_FLOW_HANDLE_ENTRY_SIZE_FLOW_HND_64BIT  (UINT32_C(0x1) << 30)
+		#define HWRM_CFA_FLOW_FLUSH_INPUT_FLAGS_FLOW_HANDLE_ENTRY_SIZE_LAST	HWRM_CFA_FLOW_FLUSH_INPUT_FLAGS_FLOW_HANDLE_ENTRY_SIZE_FLOW_HND_64BIT
+	/* Specify page size of the flow table memory. */
+	uint8_t	page_size;
+	/* The page size is 4K */
+	#define HWRM_CFA_FLOW_FLUSH_INPUT_PAGE_SIZE_4K   UINT32_C(0x0)
+	/* The page size is 8K */
+	#define HWRM_CFA_FLOW_FLUSH_INPUT_PAGE_SIZE_8K   UINT32_C(0x1)
+	/* The page size is 64K */
+	#define HWRM_CFA_FLOW_FLUSH_INPUT_PAGE_SIZE_64K  UINT32_C(0x4)
+	/* The page size is 256K */
+	#define HWRM_CFA_FLOW_FLUSH_INPUT_PAGE_SIZE_256K UINT32_C(0x6)
+	/* The page size is 1M */
+	#define HWRM_CFA_FLOW_FLUSH_INPUT_PAGE_SIZE_1M   UINT32_C(0x8)
+	/* The page size is 2M */
+	#define HWRM_CFA_FLOW_FLUSH_INPUT_PAGE_SIZE_2M   UINT32_C(0x9)
+	/* The page size is 4M */
+	#define HWRM_CFA_FLOW_FLUSH_INPUT_PAGE_SIZE_4M   UINT32_C(0xa)
+	/* The page size is 1G */
+	#define HWRM_CFA_FLOW_FLUSH_INPUT_PAGE_SIZE_1G   UINT32_C(0x12)
+	#define HWRM_CFA_FLOW_FLUSH_INPUT_PAGE_SIZE_LAST HWRM_CFA_FLOW_FLUSH_INPUT_PAGE_SIZE_1G
+	/* FLow table memory indirect levels. */
+	uint8_t	page_level;
+	/* PBL pointer is physical start address. */
+	#define HWRM_CFA_FLOW_FLUSH_INPUT_PAGE_LEVEL_LVL_0 UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+	#define HWRM_CFA_FLOW_FLUSH_INPUT_PAGE_LEVEL_LVL_1 UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
 	 */
-	uint64_t	rx_pfc_xon2xoff_frames_pri1;
+	#define HWRM_CFA_FLOW_FLUSH_INPUT_PAGE_LEVEL_LVL_2 UINT32_C(0x2)
+	#define HWRM_CFA_FLOW_FLUSH_INPUT_PAGE_LEVEL_LAST HWRM_CFA_FLOW_FLUSH_INPUT_PAGE_LEVEL_LVL_2
+	/* number of flows in the flow table */
+	uint16_t	num_flows;
+	/* Pointer to the PBL, or PDL depending on number of levels */
+	uint64_t	page_dir;
+} hwrm_cfa_flow_flush_input_t, *phwrm_cfa_flow_flush_input_t;
+
+/* hwrm_cfa_flow_flush_output (size:128b/16B) */
+
+typedef struct hwrm_cfa_flow_flush_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
 	/*
-	 * Total number of received PFC frames with transition from
-	 * XON to XOFF on Pri 2
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	uint64_t	rx_pfc_xon2xoff_frames_pri2;
+	uint8_t	valid;
+} hwrm_cfa_flow_flush_output_t, *phwrm_cfa_flow_flush_output_t;
+
+/***********************
+ * hwrm_cfa_flow_stats *
+ ***********************/
+
+
+/* hwrm_cfa_flow_stats_input (size:640b/80B) */
+
+typedef struct hwrm_cfa_flow_stats_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * Total number of received PFC frames with transition from
-	 * XON to XOFF on Pri 3
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint64_t	rx_pfc_xon2xoff_frames_pri3;
+	uint16_t	cmpl_ring;
 	/*
-	 * Total number of received PFC frames with transition from
-	 * XON to XOFF on Pri 4
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint64_t	rx_pfc_xon2xoff_frames_pri4;
+	uint16_t	seq_id;
 	/*
-	 * Total number of received PFC frames with transition from
-	 * XON to XOFF on Pri 5
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint64_t	rx_pfc_xon2xoff_frames_pri5;
+	uint16_t	target_id;
 	/*
-	 * Total number of received PFC frames with transition from
-	 * XON to XOFF on Pri 6
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint64_t	rx_pfc_xon2xoff_frames_pri6;
+	uint64_t	resp_addr;
+	/* Number of valid flows in this command. */
+	uint16_t	num_flows;
 	/*
-	 * Total number of received PFC frames with transition from
-	 * XON to XOFF on Pri 7
+	 * Flow handle.
+	 * For a listing of applicable flow_handle_0 values, see enumeration
+	 * in hwrm_cfa_flow_info_input.
 	 */
-	uint64_t	rx_pfc_xon2xoff_frames_pri7;
+	uint16_t	flow_handle_0;
 	/*
-	 * Total number of received PFC frames with PFC enabled
-	 * bit for Pri 0
+	 * Flow handle.
+	 * For a listing of applicable flow_handle_1 values, see enumeration
+	 * in hwrm_cfa_flow_info_input.
 	 */
-	uint64_t	rx_pfc_ena_frames_pri0;
+	uint16_t	flow_handle_1;
 	/*
-	 * Total number of received PFC frames with PFC enabled
-	 * bit for Pri 1
+	 * Flow handle.
+	 * For a listing of applicable flow_handle_2 values, see enumeration
+	 * in hwrm_cfa_flow_info_input.
 	 */
-	uint64_t	rx_pfc_ena_frames_pri1;
+	uint16_t	flow_handle_2;
 	/*
-	 * Total number of received PFC frames with PFC enabled
-	 * bit for Pri 2
+	 * Flow handle.
+	 * For a listing of applicable flow_handle_3 values, see enumeration
+	 * in hwrm_cfa_flow_info_input.
 	 */
-	uint64_t	rx_pfc_ena_frames_pri2;
+	uint16_t	flow_handle_3;
 	/*
-	 * Total number of received PFC frames with PFC enabled
-	 * bit for Pri 3
+	 * Flow handle.
+	 * For a listing of applicable flow_handle_4 values, see enumeration
+	 * in hwrm_cfa_flow_info_input.
 	 */
-	uint64_t	rx_pfc_ena_frames_pri3;
+	uint16_t	flow_handle_4;
 	/*
-	 * Total number of received PFC frames with PFC enabled
-	 * bit for Pri 4
+	 * Flow handle.
+	 * For a listing of applicable flow_handle_5 values, see enumeration
+	 * in hwrm_cfa_flow_info_input.
 	 */
-	uint64_t	rx_pfc_ena_frames_pri4;
+	uint16_t	flow_handle_5;
 	/*
-	 * Total number of received PFC frames with PFC enabled
-	 * bit for Pri 5
+	 * Flow handle.
+	 * For a listing of applicable flow_handle_6 values, see enumeration
+	 * in hwrm_cfa_flow_info_input.
 	 */
-	uint64_t	rx_pfc_ena_frames_pri5;
+	uint16_t	flow_handle_6;
 	/*
-	 * Total number of received PFC frames with PFC enabled
-	 * bit for Pri 6
+	 * Flow handle.
+	 * For a listing of applicable flow_handle_7 values, see enumeration
+	 * in hwrm_cfa_flow_info_input.
 	 */
-	uint64_t	rx_pfc_ena_frames_pri6;
+	uint16_t	flow_handle_7;
 	/*
-	 * Total number of received PFC frames with PFC enabled
-	 * bit for Pri 7
+	 * Flow handle.
+	 * For a listing of applicable flow_handle_8 values, see enumeration
+	 * in hwrm_cfa_flow_info_input.
 	 */
-	uint64_t	rx_pfc_ena_frames_pri7;
-	/* Total Number of frames received with SCH CRC error */
-	uint64_t	rx_sch_crc_err_frames;
-	/* Total Number of under-sized frames received */
-	uint64_t	rx_undrsz_frames;
-	/* Total Number of fragmented frames received */
-	uint64_t	rx_frag_frames;
-	/* Total number of RX EEE LPI Events */
-	uint64_t	rx_eee_lpi_events;
-	/* EEE LPI Duration Counter on RX */
-	uint64_t	rx_eee_lpi_duration;
+	uint16_t	flow_handle_8;
 	/*
-	 * Total number of physical type Link Level Flow Control
-	 * (LLFC) messages received
+	 * Flow handle.
+	 * For a listing of applicable flow_handle_9 values, see enumeration
+	 * in hwrm_cfa_flow_info_input.
 	 */
-	uint64_t	rx_llfc_physical_msgs;
+	uint16_t	flow_handle_9;
+	uint8_t	unused_0[2];
+	/* Flow ID of a flow. */
+	uint32_t	flow_id_0;
+	/* Flow ID of a flow. */
+	uint32_t	flow_id_1;
+	/* Flow ID of a flow. */
+	uint32_t	flow_id_2;
+	/* Flow ID of a flow. */
+	uint32_t	flow_id_3;
+	/* Flow ID of a flow. */
+	uint32_t	flow_id_4;
+	/* Flow ID of a flow. */
+	uint32_t	flow_id_5;
+	/* Flow ID of a flow. */
+	uint32_t	flow_id_6;
+	/* Flow ID of a flow. */
+	uint32_t	flow_id_7;
+	/* Flow ID of a flow. */
+	uint32_t	flow_id_8;
+	/* Flow ID of a flow. */
+	uint32_t	flow_id_9;
+} hwrm_cfa_flow_stats_input_t, *phwrm_cfa_flow_stats_input_t;
+
+/* hwrm_cfa_flow_stats_output (size:1408b/176B) */
+
+typedef struct hwrm_cfa_flow_stats_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* packet_0 is 64 b */
+	uint64_t	packet_0;
+	/* packet_1 is 64 b */
+	uint64_t	packet_1;
+	/* packet_2 is 64 b */
+	uint64_t	packet_2;
+	/* packet_3 is 64 b */
+	uint64_t	packet_3;
+	/* packet_4 is 64 b */
+	uint64_t	packet_4;
+	/* packet_5 is 64 b */
+	uint64_t	packet_5;
+	/* packet_6 is 64 b */
+	uint64_t	packet_6;
+	/* packet_7 is 64 b */
+	uint64_t	packet_7;
+	/* packet_8 is 64 b */
+	uint64_t	packet_8;
+	/* packet_9 is 64 b */
+	uint64_t	packet_9;
+	/* byte_0 is 64 b */
+	uint64_t	byte_0;
+	/* byte_1 is 64 b */
+	uint64_t	byte_1;
+	/* byte_2 is 64 b */
+	uint64_t	byte_2;
+	/* byte_3 is 64 b */
+	uint64_t	byte_3;
+	/* byte_4 is 64 b */
+	uint64_t	byte_4;
+	/* byte_5 is 64 b */
+	uint64_t	byte_5;
+	/* byte_6 is 64 b */
+	uint64_t	byte_6;
+	/* byte_7 is 64 b */
+	uint64_t	byte_7;
+	/* byte_8 is 64 b */
+	uint64_t	byte_8;
+	/* byte_9 is 64 b */
+	uint64_t	byte_9;
 	/*
-	 * Total number of logical type Link Level Flow Control
-	 * (LLFC) messages received
+	 * If a flow has been hit, the bit representing the flow will be 1.
+	 * Likewise, if a flow has not, the bit representing the flow
+	 * will be 0. Mapping will match flow numbers where bitX is for flowX
+	 * (ex: bit 0 is flow0). This only applies for NIC flows. Upon
+	 * reading of the flow, the bit will be cleared for the flow and only
+	 * set again when traffic is received by the flow.
 	 */
-	uint64_t	rx_llfc_logical_msgs;
+	uint16_t	flow_hits;
+	uint8_t	unused_0[5];
 	/*
-	 * Total number of logical type Link Level Flow Control
-	 * (LLFC) messages received with CRC error
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	uint64_t	rx_llfc_msgs_with_crc_err;
-	/* Total number of HCFC messages received */
-	uint64_t	rx_hcfc_msgs;
-	/* Total number of HCFC messages received with CRC error */
-	uint64_t	rx_hcfc_msgs_with_crc_err;
-	/* Total number of received bytes */
-	uint64_t	rx_bytes;
-	/* Total number of bytes received in runt frames */
-	uint64_t	rx_runt_bytes;
-	/* Total number of runt frames received */
-	uint64_t	rx_runt_frames;
-	/* Total Rx Discards per Port reported by STATS block */
-	uint64_t	rx_stat_discard;
-	uint64_t	rx_stat_err;
-} rx_port_stats_t, *prx_port_stats_t;
+	uint8_t	valid;
+} hwrm_cfa_flow_stats_output_t, *phwrm_cfa_flow_stats_output_t;
 
-/********************
- * hwrm_port_qstats *
- ********************/
+/***********************************
+ * hwrm_cfa_flow_aging_timer_reset *
+ ***********************************/
 
 
-/* hwrm_port_qstats_input (size:320b/40B) */
+/* hwrm_cfa_flow_aging_timer_reset_input (size:256b/32B) */
 
-typedef struct hwrm_port_qstats_input {
+typedef struct hwrm_cfa_flow_aging_timer_reset_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -21405,34 +49544,21 @@ typedef struct hwrm_port_qstats_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Port ID of port that is being queried. */
-	uint16_t	port_id;
-	uint8_t	flags;
-	/* This value is not used to avoid backward compatibility issues. */
-	#define HWRM_PORT_QSTATS_INPUT_FLAGS_UNUSED	UINT32_C(0x0)
-	/*
-	 * This bit is set to 1 when request is for a counter mask,
-	 * representing the width of each of the stats counters, rather
-	 * than counters themselves.
-	 */
-	#define HWRM_PORT_QSTATS_INPUT_FLAGS_COUNTER_MASK UINT32_C(0x1)
-	#define HWRM_PORT_QSTATS_INPUT_FLAGS_LAST	HWRM_PORT_QSTATS_INPUT_FLAGS_COUNTER_MASK
-	uint8_t	unused_0[5];
-	/*
-	 * This is the host address where
-	 * Tx port statistics will be stored
-	 */
-	uint64_t	tx_stat_host_addr;
+	/* Flow record index. */
+	uint16_t	flow_handle;
+	uint8_t	unused_0[2];
 	/*
-	 * This is the host address where
-	 * Rx port statistics will be stored
+	 * New flow timer value for the flow specified in the ext_flow_handle.
+	 * The flow timer unit is 100ms.
 	 */
-	uint64_t	rx_stat_host_addr;
-} hwrm_port_qstats_input_t, *phwrm_port_qstats_input_t;
+	uint32_t	flow_timer;
+	/* This value identifies a set of CFA data structures used for a flow. */
+	uint64_t	ext_flow_handle;
+} hwrm_cfa_flow_aging_timer_reset_input_t, *phwrm_cfa_flow_aging_timer_reset_input_t;
 
-/* hwrm_port_qstats_output (size:128b/16B) */
+/* hwrm_cfa_flow_aging_timer_reset_output (size:128b/16B) */
 
-typedef struct hwrm_port_qstats_output {
+typedef struct hwrm_cfa_flow_aging_timer_reset_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -21441,641 +49567,845 @@ typedef struct hwrm_port_qstats_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* The size of TX port statistics block in bytes. */
-	uint16_t	tx_stat_size;
-	/* The size of RX port statistics block in bytes. */
-	uint16_t	rx_stat_size;
-	uint8_t	unused_0[3];
+	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_port_qstats_output_t, *phwrm_port_qstats_output_t;
+} hwrm_cfa_flow_aging_timer_reset_output_t, *phwrm_cfa_flow_aging_timer_reset_output_t;
 
-/* Port Tx Statistics extended Format */
-/* tx_port_stats_ext (size:2048b/256B) */
+/***************************
+ * hwrm_cfa_flow_aging_cfg *
+ ***************************/
 
-typedef struct tx_port_stats_ext {
-	/* Total number of tx bytes count on cos queue 0 */
-	uint64_t	tx_bytes_cos0;
-	/* Total number of tx bytes count on cos queue 1 */
-	uint64_t	tx_bytes_cos1;
-	/* Total number of tx bytes count on cos queue 2 */
-	uint64_t	tx_bytes_cos2;
-	/* Total number of tx bytes count on cos queue 3 */
-	uint64_t	tx_bytes_cos3;
-	/* Total number of tx bytes count on cos queue 4 */
-	uint64_t	tx_bytes_cos4;
-	/* Total number of tx bytes count on cos queue 5 */
-	uint64_t	tx_bytes_cos5;
-	/* Total number of tx bytes count on cos queue 6 */
-	uint64_t	tx_bytes_cos6;
-	/* Total number of tx bytes count on cos queue 7 */
-	uint64_t	tx_bytes_cos7;
-	/* Total number of tx packets count on cos queue 0 */
-	uint64_t	tx_packets_cos0;
-	/* Total number of tx packets count on cos queue 1 */
-	uint64_t	tx_packets_cos1;
-	/* Total number of tx packets count on cos queue 2 */
-	uint64_t	tx_packets_cos2;
-	/* Total number of tx packets count on cos queue 3 */
-	uint64_t	tx_packets_cos3;
-	/* Total number of tx packets count on cos queue 4 */
-	uint64_t	tx_packets_cos4;
-	/* Total number of tx packets count on cos queue 5 */
-	uint64_t	tx_packets_cos5;
-	/* Total number of tx packets count on cos queue 6 */
-	uint64_t	tx_packets_cos6;
-	/* Total number of tx packets count on cos queue 7 */
-	uint64_t	tx_packets_cos7;
-	/* time duration between transmitting a XON -> XOFF and a subsequent XOFF -> XON for priority 0 */
-	uint64_t	pfc_pri0_tx_duration_us;
-	/* Number of times, a XON -> XOFF and XOFF -> XON transitions occur for priority 0 */
-	uint64_t	pfc_pri0_tx_transitions;
-	/* time duration between transmitting a XON -> XOFF and a subsequent XOFF -> XON for priority 1 */
-	uint64_t	pfc_pri1_tx_duration_us;
-	/* Number of times, a XON -> XOFF and XOFF -> XON transitions occur for priority 1 */
-	uint64_t	pfc_pri1_tx_transitions;
-	/* time duration between transmitting a XON -> XOFF and a subsequent XOFF -> XON for priority 2 */
-	uint64_t	pfc_pri2_tx_duration_us;
-	/* Number of times, a XON -> XOFF and XOFF -> XON transitions occur for priority 2 */
-	uint64_t	pfc_pri2_tx_transitions;
-	/* time duration between transmitting a XON -> XOFF and a subsequent XOFF -> XON for priority 3 */
-	uint64_t	pfc_pri3_tx_duration_us;
-	/* Number of times, a XON -> XOFF and XOFF -> XON transitions occur for priority 3 */
-	uint64_t	pfc_pri3_tx_transitions;
-	/* time duration between transmitting a XON -> XOFF and a subsequent XOFF -> XON for priority 4 */
-	uint64_t	pfc_pri4_tx_duration_us;
-	/* Number of times, a XON -> XOFF and XOFF -> XON transitions occur for priority 4 */
-	uint64_t	pfc_pri4_tx_transitions;
-	/* time duration between transmitting a XON -> XOFF and a subsequent XOFF -> XON for priority 5 */
-	uint64_t	pfc_pri5_tx_duration_us;
-	/* Number of times, a XON -> XOFF and XOFF -> XON transitions occur for priority 5 */
-	uint64_t	pfc_pri5_tx_transitions;
-	/* time duration between transmitting a XON -> XOFF and a subsequent XOFF -> XON for priority 6 */
-	uint64_t	pfc_pri6_tx_duration_us;
-	/* Number of times, a XON -> XOFF and XOFF -> XON transitions occur for priority 6 */
-	uint64_t	pfc_pri6_tx_transitions;
-	/* time duration between transmitting a XON -> XOFF and a subsequent XOFF -> XON for priority 7 */
-	uint64_t	pfc_pri7_tx_duration_us;
-	/* Number of times, a XON -> XOFF and XOFF -> XON transitions occur for priority 7 */
-	uint64_t	pfc_pri7_tx_transitions;
-} tx_port_stats_ext_t, *ptx_port_stats_ext_t;
 
-/* Port Rx Statistics extended Format */
-/* rx_port_stats_ext (size:3648b/456B) */
+/* hwrm_cfa_flow_aging_cfg_input (size:384b/48B) */
 
-typedef struct rx_port_stats_ext {
-	/* Number of times link state changed to down */
-	uint64_t	link_down_events;
-	/* Number of times the idle rings with pause bit are found */
-	uint64_t	continuous_pause_events;
-	/* Number of times the active rings pause bit resumed back */
-	uint64_t	resume_pause_events;
-	/* Number of times, the ROCE cos queue PFC is disabled to avoid pause flood/burst */
-	uint64_t	continuous_roce_pause_events;
-	/* Number of times, the ROCE cos queue PFC is enabled back */
-	uint64_t	resume_roce_pause_events;
-	/* Total number of rx bytes count on cos queue 0 */
-	uint64_t	rx_bytes_cos0;
-	/* Total number of rx bytes count on cos queue 1 */
-	uint64_t	rx_bytes_cos1;
-	/* Total number of rx bytes count on cos queue 2 */
-	uint64_t	rx_bytes_cos2;
-	/* Total number of rx bytes count on cos queue 3 */
-	uint64_t	rx_bytes_cos3;
-	/* Total number of rx bytes count on cos queue 4 */
-	uint64_t	rx_bytes_cos4;
-	/* Total number of rx bytes count on cos queue 5 */
-	uint64_t	rx_bytes_cos5;
-	/* Total number of rx bytes count on cos queue 6 */
-	uint64_t	rx_bytes_cos6;
-	/* Total number of rx bytes count on cos queue 7 */
-	uint64_t	rx_bytes_cos7;
-	/* Total number of rx packets count on cos queue 0 */
-	uint64_t	rx_packets_cos0;
-	/* Total number of rx packets count on cos queue 1 */
-	uint64_t	rx_packets_cos1;
-	/* Total number of rx packets count on cos queue 2 */
-	uint64_t	rx_packets_cos2;
-	/* Total number of rx packets count on cos queue 3 */
-	uint64_t	rx_packets_cos3;
-	/* Total number of rx packets count on cos queue 4 */
-	uint64_t	rx_packets_cos4;
-	/* Total number of rx packets count on cos queue 5 */
-	uint64_t	rx_packets_cos5;
-	/* Total number of rx packets count on cos queue 6 */
-	uint64_t	rx_packets_cos6;
-	/* Total number of rx packets count on cos queue 7 */
-	uint64_t	rx_packets_cos7;
-	/* time duration receiving a XON -> XOFF and a subsequent XOFF -> XON for priority 0 */
-	uint64_t	pfc_pri0_rx_duration_us;
-	/* Number of times, a XON -> XOFF and XOFF -> XON transitions occur for priority 0 */
-	uint64_t	pfc_pri0_rx_transitions;
-	/* time duration receiving a XON -> XOFF and a subsequent XOFF -> XON for priority 1 */
-	uint64_t	pfc_pri1_rx_duration_us;
-	/* Number of times, a XON -> XOFF and XOFF -> XON transitions occur for priority 1 */
-	uint64_t	pfc_pri1_rx_transitions;
-	/* time duration receiving a XON -> XOFF and a subsequent XOFF -> XON for priority 2 */
-	uint64_t	pfc_pri2_rx_duration_us;
-	/* Number of times, a XON -> XOFF and XOFF -> XON transitions occur for priority 2 */
-	uint64_t	pfc_pri2_rx_transitions;
-	/* time duration receiving a XON -> XOFF and a subsequent XOFF -> XON for priority 3 */
-	uint64_t	pfc_pri3_rx_duration_us;
-	/* Number of times, a XON -> XOFF and XOFF -> XON transitions occur for priority 3 */
-	uint64_t	pfc_pri3_rx_transitions;
-	/* time duration receiving a XON -> XOFF and a subsequent XOFF -> XON for priority 4 */
-	uint64_t	pfc_pri4_rx_duration_us;
-	/* Number of times, a XON -> XOFF and XOFF -> XON transitions occur for priority 4 */
-	uint64_t	pfc_pri4_rx_transitions;
-	/* time duration receiving a XON -> XOFF and a subsequent XOFF -> XON for priority 5 */
-	uint64_t	pfc_pri5_rx_duration_us;
-	/* Number of times, a XON -> XOFF and XOFF -> XON transitions occur for priority 5 */
-	uint64_t	pfc_pri5_rx_transitions;
-	/* time duration receiving a XON -> XOFF and a subsequent XOFF -> XON for priority 6 */
-	uint64_t	pfc_pri6_rx_duration_us;
-	/* Number of times, a XON -> XOFF and XOFF -> XON transitions occur for priority 6 */
-	uint64_t	pfc_pri6_rx_transitions;
-	/* time duration receiving a XON -> XOFF and a subsequent XOFF -> XON for priority 7 */
-	uint64_t	pfc_pri7_rx_duration_us;
-	/* Number of times, a XON -> XOFF and XOFF -> XON transitions occur for priority 7 */
-	uint64_t	pfc_pri7_rx_transitions;
-	/* Total number of received bits */
-	uint64_t	rx_bits;
-	/* The number of events where the port receive buffer was over 85% full */
-	uint64_t	rx_buffer_passed_threshold;
+typedef struct hwrm_cfa_flow_aging_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * The number of symbol errors that wasn't corrected by FEC correction
-	 * alogirithm
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint64_t	rx_pcs_symbol_err;
-	/* The number of corrected bits on the port according to active FEC */
-	uint64_t	rx_corrected_bits;
-	/* Total number of rx discard bytes count on cos queue 0 */
-	uint64_t	rx_discard_bytes_cos0;
-	/* Total number of rx discard bytes count on cos queue 1 */
-	uint64_t	rx_discard_bytes_cos1;
-	/* Total number of rx discard bytes count on cos queue 2 */
-	uint64_t	rx_discard_bytes_cos2;
-	/* Total number of rx discard bytes count on cos queue 3 */
-	uint64_t	rx_discard_bytes_cos3;
-	/* Total number of rx discard bytes count on cos queue 4 */
-	uint64_t	rx_discard_bytes_cos4;
-	/* Total number of rx discard bytes count on cos queue 5 */
-	uint64_t	rx_discard_bytes_cos5;
-	/* Total number of rx discard bytes count on cos queue 6 */
-	uint64_t	rx_discard_bytes_cos6;
-	/* Total number of rx discard bytes count on cos queue 7 */
-	uint64_t	rx_discard_bytes_cos7;
-	/* Total number of rx discard packets count on cos queue 0 */
-	uint64_t	rx_discard_packets_cos0;
-	/* Total number of rx discard packets count on cos queue 1 */
-	uint64_t	rx_discard_packets_cos1;
-	/* Total number of rx discard packets count on cos queue 2 */
-	uint64_t	rx_discard_packets_cos2;
-	/* Total number of rx discard packets count on cos queue 3 */
-	uint64_t	rx_discard_packets_cos3;
-	/* Total number of rx discard packets count on cos queue 4 */
-	uint64_t	rx_discard_packets_cos4;
-	/* Total number of rx discard packets count on cos queue 5 */
-	uint64_t	rx_discard_packets_cos5;
-	/* Total number of rx discard packets count on cos queue 6 */
-	uint64_t	rx_discard_packets_cos6;
-	/* Total number of rx discard packets count on cos queue 7 */
-	uint64_t	rx_discard_packets_cos7;
-} rx_port_stats_ext_t, *prx_port_stats_ext_t;
-
-/*
- * Port Rx Statistics extended PFC WatchDog Format.
- * StormDetect and StormRevert event determination is based
- * on an integration period and a percentage threshold.
- * StormDetect event - when percentage of XOFF frames received
- * within an integration period exceeds the configured threshold.
- * StormRevert event - when percentage of XON frames received
- * within an integration period exceeds the configured threshold.
- * Actual number of XOFF/XON frames for the events to be triggered
- * depends on both configured integration period and sampling rate.
- * The statistics in this structure represent counts of specified
- * events from the moment the feature (PFC WatchDog) is enabled via
- * hwrm_queue_pfc_enable_cfg call.
- */
-/* rx_port_stats_ext_pfc_wd (size:5120b/640B) */
-
-typedef struct rx_port_stats_ext_pfc_wd {
+	uint16_t	cmpl_ring;
 	/*
-	 * Total number of PFC WatchDog StormDetect events detected
-	 * for Pri 0
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_detected_pri0;
+	uint16_t	seq_id;
 	/*
-	 * Total number of PFC WatchDog StormDetect events detected
-	 * for Pri 1
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint64_t	rx_pfc_watchdog_storms_detected_pri1;
+	uint16_t	target_id;
 	/*
-	 * Total number of PFC WatchDog StormDetect events detected
-	 * for Pri 2
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_detected_pri2;
+	uint64_t	resp_addr;
+	/* The bit field to enable per flow aging configuration. */
+	uint16_t	enables;
 	/*
-	 * Total number of PFC WatchDog StormDetect events detected
-	 * for Pri 3
+	 * This bit must be '1' for the tcp flow timer field to be
+	 * configured
 	 */
-	uint64_t	rx_pfc_watchdog_storms_detected_pri3;
+	#define HWRM_CFA_FLOW_AGING_CFG_INPUT_ENABLES_TCP_FLOW_TIMER	UINT32_C(0x1)
 	/*
-	 * Total number of PFC WatchDog StormDetect events detected
-	 * for Pri 4
+	 * This bit must be '1' for the tcp finish timer field to be
+	 * configured
 	 */
-	uint64_t	rx_pfc_watchdog_storms_detected_pri4;
+	#define HWRM_CFA_FLOW_AGING_CFG_INPUT_ENABLES_TCP_FIN_TIMER	UINT32_C(0x2)
 	/*
-	 * Total number of PFC WatchDog StormDetect events detected
-	 * for Pri 5
+	 * This bit must be '1' for the udp flow timer field to be
+	 * configured
 	 */
-	uint64_t	rx_pfc_watchdog_storms_detected_pri5;
+	#define HWRM_CFA_FLOW_AGING_CFG_INPUT_ENABLES_UDP_FLOW_TIMER	UINT32_C(0x4)
 	/*
-	 * Total number of PFC WatchDog StormDetect events detected
-	 * for Pri 6
+	 * This bit must be '1' for the eem dma interval field to be
+	 * configured
 	 */
-	uint64_t	rx_pfc_watchdog_storms_detected_pri6;
+	#define HWRM_CFA_FLOW_AGING_CFG_INPUT_ENABLES_EEM_DMA_INTERVAL	UINT32_C(0x8)
 	/*
-	 * Total number of PFC WatchDog StormDetect events detected
-	 * for Pri 7
+	 * This bit must be '1' for the eem notice interval field to be
+	 * configured
 	 */
-	uint64_t	rx_pfc_watchdog_storms_detected_pri7;
+	#define HWRM_CFA_FLOW_AGING_CFG_INPUT_ENABLES_EEM_NOTICE_INTERVAL	UINT32_C(0x10)
 	/*
-	 * Total number of PFC WatchDog StormRevert events detected
-	 * for Pri 0
+	 * This bit must be '1' for the eem context memory maximum entries
+	 * field to be configured
 	 */
-	uint64_t	rx_pfc_watchdog_storms_reverted_pri0;
+	#define HWRM_CFA_FLOW_AGING_CFG_INPUT_ENABLES_EEM_CTX_MAX_ENTRIES	UINT32_C(0x20)
 	/*
-	 * Total number of PFC WatchDog StormRevert events detected
-	 * for Pri 1
+	 * This bit must be '1' for the eem context memory ID field to be
+	 * configured
 	 */
-	uint64_t	rx_pfc_watchdog_storms_reverted_pri1;
+	#define HWRM_CFA_FLOW_AGING_CFG_INPUT_ENABLES_EEM_CTX_ID		UINT32_C(0x40)
 	/*
-	 * Total number of PFC WatchDog StormRevert events detected
-	 * for Pri 2
+	 * This bit must be '1' for the eem context memory type field to be
+	 * configured
 	 */
-	uint64_t	rx_pfc_watchdog_storms_reverted_pri2;
+	#define HWRM_CFA_FLOW_AGING_CFG_INPUT_ENABLES_EEM_CTX_MEM_TYPE	UINT32_C(0x80)
+	uint8_t	flags;
+	/* Enumeration denoting the RX, TX type of the resource. */
+	#define HWRM_CFA_FLOW_AGING_CFG_INPUT_FLAGS_PATH	UINT32_C(0x1)
+	/* tx path */
+		#define HWRM_CFA_FLOW_AGING_CFG_INPUT_FLAGS_PATH_TX	UINT32_C(0x0)
+	/* rx path */
+		#define HWRM_CFA_FLOW_AGING_CFG_INPUT_FLAGS_PATH_RX	UINT32_C(0x1)
+		#define HWRM_CFA_FLOW_AGING_CFG_INPUT_FLAGS_PATH_LAST   HWRM_CFA_FLOW_AGING_CFG_INPUT_FLAGS_PATH_RX
 	/*
-	 * Total number of PFC WatchDog StormRevert events detected
-	 * for Pri 3
+	 * Enumeration denoting the enable, disable eem flow aging
+	 * configuration.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_reverted_pri3;
+	#define HWRM_CFA_FLOW_AGING_CFG_INPUT_FLAGS_EEM	UINT32_C(0x2)
+	/* tx path */
+		#define HWRM_CFA_FLOW_AGING_CFG_INPUT_FLAGS_EEM_DISABLE  (UINT32_C(0x0) << 1)
+	/* rx path */
+		#define HWRM_CFA_FLOW_AGING_CFG_INPUT_FLAGS_EEM_ENABLE   (UINT32_C(0x1) << 1)
+		#define HWRM_CFA_FLOW_AGING_CFG_INPUT_FLAGS_EEM_LAST	HWRM_CFA_FLOW_AGING_CFG_INPUT_FLAGS_EEM_ENABLE
+	uint8_t	unused_0;
 	/*
-	 * Total number of PFC WatchDog StormRevert events detected
-	 * for Pri 4
+	 * The flow aging timer for all TCP flows, the unit is 100
+	 * milliseconds.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_reverted_pri4;
+	uint32_t	tcp_flow_timer;
 	/*
-	 * Total number of PFC WatchDog StormRevert events detected
-	 * for Pri 5
+	 * The TCP finished timer for all TCP flows, the unit is 100
+	 * milliseconds.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_reverted_pri5;
+	uint32_t	tcp_fin_timer;
 	/*
-	 * Total number of PFC WatchDog StormRevert events detected
-	 * for Pri 6
+	 * The flow aging timer for all UDP flows, the unit is 100
+	 * milliseconds.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_reverted_pri6;
+	uint32_t	udp_flow_timer;
 	/*
-	 * Total number of PFC WatchDog StormRevert events detected
-	 * for Pri 7
+	 * The interval to dma eem ejection data to host memory, the unit is
+	 * milliseconds.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_reverted_pri7;
+	uint16_t	eem_dma_interval;
 	/*
-	 * Total number of packets received during PFC watchdog storm
-	 * for pri 0
+	 * The interval to notify driver to read the eem ejection data, the
+	 * unit is milliseconds.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_rx_packets_pri0;
+	uint16_t	eem_notice_interval;
+	/* The maximum entries number in the eem context memory. */
+	uint32_t	eem_ctx_max_entries;
+	/* The context memory ID for eem flow aging. */
+	uint16_t	eem_ctx_id;
+	uint16_t	eem_ctx_mem_type;
 	/*
-	 * Total number of packets received during PFC watchdog storm
-	 * for pri 1
+	 * The content of context memory is eem ejection data, the size of
+	 * each entry is 4 bytes.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_rx_packets_pri1;
+	#define HWRM_CFA_FLOW_AGING_CFG_INPUT_EEM_CTX_MEM_TYPE_EJECTION_DATA UINT32_C(0x0)
+	#define HWRM_CFA_FLOW_AGING_CFG_INPUT_EEM_CTX_MEM_TYPE_LAST	HWRM_CFA_FLOW_AGING_CFG_INPUT_EEM_CTX_MEM_TYPE_EJECTION_DATA
+	uint8_t	unused_1[4];
+} hwrm_cfa_flow_aging_cfg_input_t, *phwrm_cfa_flow_aging_cfg_input_t;
+
+/* hwrm_cfa_flow_aging_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_cfa_flow_aging_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
 	/*
-	 * Total number of packets received during PFC watchdog storm
-	 *  for pri 2
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_rx_packets_pri2;
+	uint8_t	valid;
+} hwrm_cfa_flow_aging_cfg_output_t, *phwrm_cfa_flow_aging_cfg_output_t;
+
+/****************************
+ * hwrm_cfa_flow_aging_qcfg *
+ ****************************/
+
+
+/* hwrm_cfa_flow_aging_qcfg_input (size:192b/24B) */
+
+typedef struct hwrm_cfa_flow_aging_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * Total number of packets received during PFC watchdog storm
-	 *  for pri 3
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_rx_packets_pri3;
+	uint16_t	cmpl_ring;
 	/*
-	 * Total number of packets received during PFC watchdog storm
-	 *  for pri 4
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_rx_packets_pri4;
+	uint16_t	seq_id;
 	/*
-	 * Total number of packets received during PFC watchdog storm
-	 *  for pri 5
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint64_t	rx_pfc_watchdog_storms_rx_packets_pri5;
+	uint16_t	target_id;
 	/*
-	 * Total number of packets received during PFC watchdog storm
-	 *  for pri 6
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_rx_packets_pri6;
+	uint64_t	resp_addr;
 	/*
-	 * Total number of packets received during PFC watchdog storm
-	 *  for pri 7
+	 * The direction for the flow aging configuration, 1 is rx path, 2 is
+	 * tx path.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_rx_packets_pri7;
+	uint8_t	flags;
+	/* Enumeration denoting the RX, TX type of the resource. */
+	#define HWRM_CFA_FLOW_AGING_QCFG_INPUT_FLAGS_PATH	UINT32_C(0x1)
+	/* tx path */
+		#define HWRM_CFA_FLOW_AGING_QCFG_INPUT_FLAGS_PATH_TX	UINT32_C(0x0)
+	/* rx path */
+		#define HWRM_CFA_FLOW_AGING_QCFG_INPUT_FLAGS_PATH_RX	UINT32_C(0x1)
+		#define HWRM_CFA_FLOW_AGING_QCFG_INPUT_FLAGS_PATH_LAST HWRM_CFA_FLOW_AGING_QCFG_INPUT_FLAGS_PATH_RX
+	uint8_t	unused_0[7];
+} hwrm_cfa_flow_aging_qcfg_input_t, *phwrm_cfa_flow_aging_qcfg_input_t;
+
+/* hwrm_cfa_flow_aging_qcfg_output (size:320b/40B) */
+
+typedef struct hwrm_cfa_flow_aging_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
 	/*
-	 * Total number of bytes received during PFC watchdog storm
-	 * for pri 0
+	 * The current flow aging timer for all TCP flows, the unit is 100
+	 * millisecond.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_rx_bytes_pri0;
+	uint32_t	tcp_flow_timer;
 	/*
-	 * Total number of bytes received during PFC watchdog storm
-	 * for pri 1
+	 * The current TCP finished timer for all TCP flows, the unit is 100
+	 * millisecond.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_rx_bytes_pri1;
+	uint32_t	tcp_fin_timer;
 	/*
-	 * Total number of bytes received during PFC watchdog storm
-	 *  for pri 2
+	 * The current flow aging timer for all UDP flows, the unit is 100
+	 * millisecond.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_rx_bytes_pri2;
+	uint32_t	udp_flow_timer;
 	/*
-	 * Total number of bytes received during PFC watchdog storm
-	 *  for pri 3
+	 * The interval to dma eem ejection data to host memory, the unit is
+	 * milliseconds.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_rx_bytes_pri3;
+	uint16_t	eem_dma_interval;
 	/*
-	 * Total number of bytes received during PFC watchdog storm
-	 *  for pri 4
+	 * The interval to notify driver to read the eem ejection data, the
+	 * unit is milliseconds.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_rx_bytes_pri4;
+	uint16_t	eem_notice_interval;
+	/* The maximum entries number in the eem context memory. */
+	uint32_t	eem_ctx_max_entries;
+	/* The context memory ID for eem flow aging. */
+	uint16_t	eem_ctx_id;
+	/* The context memory type for eem flow aging. */
+	uint16_t	eem_ctx_mem_type;
+	uint8_t	unused_0[7];
 	/*
-	 * Total number of bytes received during PFC watchdog storm
-	 *  for pri 5
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_rx_bytes_pri5;
+	uint8_t	valid;
+} hwrm_cfa_flow_aging_qcfg_output_t, *phwrm_cfa_flow_aging_qcfg_output_t;
+
+/*****************************
+ * hwrm_cfa_flow_aging_qcaps *
+ *****************************/
+
+
+/* hwrm_cfa_flow_aging_qcaps_input (size:192b/24B) */
+
+typedef struct hwrm_cfa_flow_aging_qcaps_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * Total number of bytes received during PFC watchdog storm
-	 *  for pri 6
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_rx_bytes_pri6;
+	uint16_t	cmpl_ring;
 	/*
-	 * Total number of bytes received during PFC watchdog storm
-	 *  for pri 7
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_rx_bytes_pri7;
+	uint16_t	seq_id;
 	/*
-	 * Total number of packets dropped on rx during PFC watchdog storm
-	 * for pri 0
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint64_t	rx_pfc_watchdog_storms_rx_packets_dropped_pri0;
+	uint16_t	target_id;
 	/*
-	 * Total number of packets dropped on rx during PFC watchdog storm
-	 * for pri 1
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_rx_packets_dropped_pri1;
+	uint64_t	resp_addr;
 	/*
-	 * Total number of packets dropped on rx during PFC watchdog storm
-	 *  for pri 2
+	 * The direction for the flow aging configuration, 1 is rx path, 2 is
+	 * tx path.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_rx_packets_dropped_pri2;
+	uint8_t	flags;
+	/* Enumeration denoting the RX, TX type of the resource. */
+	#define HWRM_CFA_FLOW_AGING_QCAPS_INPUT_FLAGS_PATH	UINT32_C(0x1)
+	/* tx path */
+		#define HWRM_CFA_FLOW_AGING_QCAPS_INPUT_FLAGS_PATH_TX	UINT32_C(0x0)
+	/* rx path */
+		#define HWRM_CFA_FLOW_AGING_QCAPS_INPUT_FLAGS_PATH_RX	UINT32_C(0x1)
+		#define HWRM_CFA_FLOW_AGING_QCAPS_INPUT_FLAGS_PATH_LAST HWRM_CFA_FLOW_AGING_QCAPS_INPUT_FLAGS_PATH_RX
+	uint8_t	unused_0[7];
+} hwrm_cfa_flow_aging_qcaps_input_t, *phwrm_cfa_flow_aging_qcaps_input_t;
+
+/* hwrm_cfa_flow_aging_qcaps_output (size:256b/32B) */
+
+typedef struct hwrm_cfa_flow_aging_qcaps_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
 	/*
-	 * Total number of packets dropped on rx during PFC watchdog storm
-	 *  for pri 3
+	 * The maximum flow aging timer for all TCP flows, the unit is 100
+	 * millisecond.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_rx_packets_dropped_pri3;
+	uint32_t	max_tcp_flow_timer;
 	/*
-	 * Total number of packets dropped on rx during PFC watchdog storm
-	 *  for pri 4
+	 * The maximum TCP finished timer for all TCP flows, the unit is 100
+	 * millisecond.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_rx_packets_dropped_pri4;
+	uint32_t	max_tcp_fin_timer;
 	/*
-	 * Total number of packets dropped on rx during PFC watchdog storm
-	 *  for pri 5
+	 * The maximum flow aging timer for all UDP flows, the unit is 100
+	 * millisecond.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_rx_packets_dropped_pri5;
+	uint32_t	max_udp_flow_timer;
+	/* The maximum aging flows that HW can support. */
+	uint32_t	max_aging_flows;
+	uint8_t	unused_0[7];
 	/*
-	 * Total number of packets dropped on rx during PFC watchdog storm
-	 *  for pri 6
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_rx_packets_dropped_pri6;
+	uint8_t	valid;
+} hwrm_cfa_flow_aging_qcaps_output_t, *phwrm_cfa_flow_aging_qcaps_output_t;
+
+/**********************************
+ * hwrm_cfa_tcp_flag_process_qcfg *
+ **********************************/
+
+
+/* hwrm_cfa_tcp_flag_process_qcfg_input (size:128b/16B) */
+
+typedef struct hwrm_cfa_tcp_flag_process_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * Total number of packets dropped on rx during PFC watchdog storm
-	 *  for pri 7
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_rx_packets_dropped_pri7;
+	uint16_t	cmpl_ring;
 	/*
-	 * Total number of bytes dropped on rx during PFC watchdog storm
-	 * for pri 0
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_rx_bytes_dropped_pri0;
+	uint16_t	seq_id;
 	/*
-	 * Total number of bytes dropped on rx during PFC watchdog storm
-	 * for pri 1
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint64_t	rx_pfc_watchdog_storms_rx_bytes_dropped_pri1;
+	uint16_t	target_id;
 	/*
-	 * Total number of bytes dropped on rx during PFC watchdog storm
-	 *  for pri 2
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_rx_bytes_dropped_pri2;
+	uint64_t	resp_addr;
+} hwrm_cfa_tcp_flag_process_qcfg_input_t, *phwrm_cfa_tcp_flag_process_qcfg_input_t;
+
+/* hwrm_cfa_tcp_flag_process_qcfg_output (size:192b/24B) */
+
+typedef struct hwrm_cfa_tcp_flag_process_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* The port 0 RX mirror action record ID. */
+	uint16_t	rx_ar_id_port0;
+	/* The port 1 RX mirror action record ID. */
+	uint16_t	rx_ar_id_port1;
 	/*
-	 * Total number of bytes dropped on rx during PFC watchdog storm
-	 *  for pri 3
+	 * The port 0 RX action record ID for TX TCP flag packets from
+	 * loopback path.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_rx_bytes_dropped_pri3;
+	uint16_t	tx_ar_id_port0;
 	/*
-	 * Total number of bytes dropped on rx during PFC watchdog storm
-	 *  for pri 4
+	 * The port 1 RX action record ID for TX TCP flag packets from
+	 * loopback path.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_rx_bytes_dropped_pri4;
+	uint16_t	tx_ar_id_port1;
+	uint8_t	unused_0[7];
 	/*
-	 * Total number of bytes dropped on rx during PFC watchdog storm
-	 *  for pri 5
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_rx_bytes_dropped_pri5;
+	uint8_t	valid;
+} hwrm_cfa_tcp_flag_process_qcfg_output_t, *phwrm_cfa_tcp_flag_process_qcfg_output_t;
+
+/**************************
+ * hwrm_cfa_vf_pair_alloc *
+ **************************/
+
+
+/* hwrm_cfa_vf_pair_alloc_input (size:448b/56B) */
+
+typedef struct hwrm_cfa_vf_pair_alloc_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * Total number of bytes dropped on rx during PFC watchdog storm
-	 *  for pri 6
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_rx_bytes_dropped_pri6;
+	uint16_t	cmpl_ring;
 	/*
-	 * Total number of bytes dropped on rx during PFC watchdog storm
-	 *  for pri 7
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint64_t	rx_pfc_watchdog_storms_rx_bytes_dropped_pri7;
+	uint16_t	seq_id;
 	/*
-	 * Number of packets received during last PFC watchdog storm
-	 * for pri 0
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint64_t	rx_pfc_watchdog_last_storm_rx_packets_pri0;
+	uint16_t	target_id;
 	/*
-	 * Number of packets received during last PFC watchdog storm
-	 * for pri 1
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint64_t	rx_pfc_watchdog_last_storm_rx_packets_pri1;
+	uint64_t	resp_addr;
+	/* Logical VF number (range: 0 -> MAX_VFS -1). */
+	uint16_t	vf_a_id;
+	/* Logical VF number (range: 0 -> MAX_VFS -1). */
+	uint16_t	vf_b_id;
+	uint8_t	unused_0[4];
+	/* VF Pair name (32 byte string). */
+	char	pair_name[32];
+} hwrm_cfa_vf_pair_alloc_input_t, *phwrm_cfa_vf_pair_alloc_input_t;
+
+/* hwrm_cfa_vf_pair_alloc_output (size:128b/16B) */
+
+typedef struct hwrm_cfa_vf_pair_alloc_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
 	/*
-	 * Number of packets received during last PFC watchdog storm
-	 *  for pri 2
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	uint64_t	rx_pfc_watchdog_last_storm_rx_packets_pri2;
+	uint8_t	valid;
+} hwrm_cfa_vf_pair_alloc_output_t, *phwrm_cfa_vf_pair_alloc_output_t;
+
+/*************************
+ * hwrm_cfa_vf_pair_free *
+ *************************/
+
+
+/* hwrm_cfa_vf_pair_free_input (size:384b/48B) */
+
+typedef struct hwrm_cfa_vf_pair_free_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * Number of packets received during last PFC watchdog storm
-	 *  for pri 3
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint64_t	rx_pfc_watchdog_last_storm_rx_packets_pri3;
+	uint16_t	cmpl_ring;
 	/*
-	 * Number of packets received during last PFC watchdog storm
-	 *  for pri 4
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint64_t	rx_pfc_watchdog_last_storm_rx_packets_pri4;
+	uint16_t	seq_id;
 	/*
-	 * Number of packets received during last PFC watchdog storm
-	 *  for pri 5
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint64_t	rx_pfc_watchdog_last_storm_rx_packets_pri5;
+	uint16_t	target_id;
 	/*
-	 * Number of packets received during last PFC watchdog storm
-	 *  for pri 6
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint64_t	rx_pfc_watchdog_last_storm_rx_packets_pri6;
+	uint64_t	resp_addr;
+	/* VF Pair name (32 byte string). */
+	char	pair_name[32];
+} hwrm_cfa_vf_pair_free_input_t, *phwrm_cfa_vf_pair_free_input_t;
+
+/* hwrm_cfa_vf_pair_free_output (size:128b/16B) */
+
+typedef struct hwrm_cfa_vf_pair_free_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
 	/*
-	 * Number of packets received during last PFC watchdog storm
-	 *  for pri 7
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	uint64_t	rx_pfc_watchdog_last_storm_rx_packets_pri7;
+	uint8_t	valid;
+} hwrm_cfa_vf_pair_free_output_t, *phwrm_cfa_vf_pair_free_output_t;
+
+/*************************
+ * hwrm_cfa_vf_pair_info *
+ *************************/
+
+
+/* hwrm_cfa_vf_pair_info_input (size:448b/56B) */
+
+typedef struct hwrm_cfa_vf_pair_info_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * Number of bytes received during last PFC watchdog storm
-	 * for pri 0
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint64_t	rx_pfc_watchdog_last_storm_rx_bytes_pri0;
+	uint16_t	cmpl_ring;
 	/*
-	 * Number of bytes received during last PFC watchdog storm
-	 * for pri 1
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint64_t	rx_pfc_watchdog_last_storm_rx_bytes_pri1;
+	uint16_t	seq_id;
 	/*
-	 * Number of bytes received during last PFC watchdog storm
-	 *  for pri 2
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint64_t	rx_pfc_watchdog_last_storm_rx_bytes_pri2;
+	uint16_t	target_id;
 	/*
-	 * Number of bytes received during last PFC watchdog storm
-	 *  for pri 3
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint64_t	rx_pfc_watchdog_last_storm_rx_bytes_pri3;
+	uint64_t	resp_addr;
+	uint32_t	flags;
+	/* If this flag is set, lookup by name else lookup by index. */
+	#define HWRM_CFA_VF_PAIR_INFO_INPUT_FLAGS_LOOKUP_TYPE	UINT32_C(0x1)
+	/* vf pair table index. */
+	uint16_t	vf_pair_index;
+	uint8_t	unused_0[2];
+	/* VF Pair name (32 byte string). */
+	char	vf_pair_name[32];
+} hwrm_cfa_vf_pair_info_input_t, *phwrm_cfa_vf_pair_info_input_t;
+
+/* hwrm_cfa_vf_pair_info_output (size:512b/64B) */
+
+typedef struct hwrm_cfa_vf_pair_info_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* vf pair table index. */
+	uint16_t	next_vf_pair_index;
+	/* vf pair member a's vf_fid. */
+	uint16_t	vf_a_fid;
+	/* vf pair member a's Linux logical VF number. */
+	uint16_t	vf_a_index;
+	/* vf pair member b's vf_fid. */
+	uint16_t	vf_b_fid;
+	/* vf pair member a's Linux logical VF number. */
+	uint16_t	vf_b_index;
+	/* vf pair state. */
+	uint8_t	pair_state;
+	/* Pair has been allocated */
+	#define HWRM_CFA_VF_PAIR_INFO_OUTPUT_PAIR_STATE_ALLOCATED UINT32_C(0x1)
+	/* Both pair members are active */
+	#define HWRM_CFA_VF_PAIR_INFO_OUTPUT_PAIR_STATE_ACTIVE	UINT32_C(0x2)
+	#define HWRM_CFA_VF_PAIR_INFO_OUTPUT_PAIR_STATE_LAST	HWRM_CFA_VF_PAIR_INFO_OUTPUT_PAIR_STATE_ACTIVE
+	uint8_t	unused_0[5];
+	/* VF Pair name (32 byte string). */
+	char	pair_name[32];
+	uint8_t	unused_1[7];
 	/*
-	 * Number of bytes received during last PFC watchdog storm
-	 *  for pri 4
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	uint64_t	rx_pfc_watchdog_last_storm_rx_bytes_pri4;
+	uint8_t	valid;
+} hwrm_cfa_vf_pair_info_output_t, *phwrm_cfa_vf_pair_info_output_t;
+
+/***********************
+ * hwrm_cfa_pair_alloc *
+ ***********************/
+
+
+/* hwrm_cfa_pair_alloc_input (size:576b/72B) */
+
+typedef struct hwrm_cfa_pair_alloc_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * Number of bytes received during last PFC watchdog storm
-	 *  for pri 5
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint64_t	rx_pfc_watchdog_last_storm_rx_bytes_pri5;
+	uint16_t	cmpl_ring;
 	/*
-	 * Number of bytes received during last PFC watchdog storm
-	 *  for pri 6
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint64_t	rx_pfc_watchdog_last_storm_rx_bytes_pri6;
+	uint16_t	seq_id;
 	/*
-	 * Number of bytes received during last PFC watchdog storm
-	 *  for pri 7
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint64_t	rx_pfc_watchdog_last_storm_rx_bytes_pri7;
+	uint16_t	target_id;
 	/*
-	 * Number of packets dropped on rx during last PFC watchdog storm
-	 * for pri 0
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint64_t	rx_pfc_watchdog_last_storm_rx_packets_dropped_pri0;
+	uint64_t	resp_addr;
 	/*
-	 * Number of packets dropped on rx during last PFC watchdog storm
-	 * for pri 1
+	 * Pair mode (0-vf2fn, 1-rep2fn, 2-rep2rep, 3-proxy, 4-pfpair,
+	 *		5-rep2fn_mod, 6-rep2fn_modall, 7-rep2fn_truflow).
 	 */
-	uint64_t	rx_pfc_watchdog_last_storm_rx_packets_dropped_pri1;
+	uint16_t	pair_mode;
 	/*
-	 * Number of packets dropped on rx during last PFC watchdog storm
-	 *  for pri 2
+	 * Pair between VF on local host with PF or VF on specified host.
+	 * (deprecated)
 	 */
-	uint64_t	rx_pfc_watchdog_last_storm_rx_packets_dropped_pri2;
+	#define HWRM_CFA_PAIR_ALLOC_INPUT_PAIR_MODE_VF2FN	UINT32_C(0x0)
 	/*
-	 * Number of packets dropped on rx during last PFC watchdog storm
-	 *  for pri 3
+	 * Pair between REP on local host with PF or VF on specified host.
+	 * (deprecated)
 	 */
-	uint64_t	rx_pfc_watchdog_last_storm_rx_packets_dropped_pri3;
+	#define HWRM_CFA_PAIR_ALLOC_INPUT_PAIR_MODE_REP2FN	UINT32_C(0x1)
 	/*
-	 * Number of packets dropped on rx during last PFC watchdog storm
-	 *  for pri 4
+	 * Pair between REP on local host with REP on specified host.
+	 * (deprecated)
 	 */
-	uint64_t	rx_pfc_watchdog_last_storm_rx_packets_dropped_pri4;
+	#define HWRM_CFA_PAIR_ALLOC_INPUT_PAIR_MODE_REP2REP	UINT32_C(0x2)
+	/* Pair for the proxy interface. (deprecated) */
+	#define HWRM_CFA_PAIR_ALLOC_INPUT_PAIR_MODE_PROXY	UINT32_C(0x3)
+	/* Pair for the PF interface. (deprecated) */
+	#define HWRM_CFA_PAIR_ALLOC_INPUT_PAIR_MODE_PFPAIR	UINT32_C(0x4)
+	/* Modify existing rep2fn pair and move pair to new PF. (deprecated) */
+	#define HWRM_CFA_PAIR_ALLOC_INPUT_PAIR_MODE_REP2FN_MOD	UINT32_C(0x5)
 	/*
-	 * Number of packets dropped on rx during last PFC watchdog storm
-	 *  for pri 5
+	 * Modify existing rep2fn pairs paired with same PF and move pairs
+	 * to new PF. (deprecated)
 	 */
-	uint64_t	rx_pfc_watchdog_last_storm_rx_packets_dropped_pri5;
+	#define HWRM_CFA_PAIR_ALLOC_INPUT_PAIR_MODE_REP2FN_MODALL  UINT32_C(0x6)
 	/*
-	 * Number of packets dropped on rx during last PFC watchdog storm
-	 *  for pri 6
+	 * Truflow pair between REP on local host with PF or VF on specified
+	 * host.
 	 */
-	uint64_t	rx_pfc_watchdog_last_storm_rx_packets_dropped_pri6;
+	#define HWRM_CFA_PAIR_ALLOC_INPUT_PAIR_MODE_REP2FN_TRUFLOW UINT32_C(0x7)
+	#define HWRM_CFA_PAIR_ALLOC_INPUT_PAIR_MODE_LAST	HWRM_CFA_PAIR_ALLOC_INPUT_PAIR_MODE_REP2FN_TRUFLOW
+	/* Logical VF number (range: 0 -> MAX_VFS -1). */
+	uint16_t	vf_a_id;
+	/* Logical Host (0xff-local host). */
+	uint8_t	host_b_id;
+	/* Logical PF (0xff-PF for command channel). */
+	uint8_t	pf_b_id;
+	/* Logical VF number (range: 0 -> MAX_VFS -1). */
+	uint16_t	vf_b_id;
+	/* Loopback port (0xff-internal loopback), valid for mode-3. */
+	uint8_t	port_id;
+	/* Priority used for encap of loopback packets valid for mode-3. */
+	uint8_t	pri;
+	/* New PF for rep2fn modify, valid for mode 5. */
+	uint16_t	new_pf_fid;
+	uint32_t	enables;
 	/*
-	 * Number of packets dropped on rx during last PFC watchdog storm
-	 *  for pri 7
+	 * This bit must be '1' for the q_ab field to be
+	 * configured.
 	 */
-	uint64_t	rx_pfc_watchdog_last_storm_rx_packets_dropped_pri7;
+	#define HWRM_CFA_PAIR_ALLOC_INPUT_ENABLES_Q_AB_VALID	UINT32_C(0x1)
 	/*
-	 * Total number of bytes dropped on rx during PFC watchdog storm
-	 * for pri 0
+	 * This bit must be '1' for the q_ba field to be
+	 * configured.
 	 */
-	uint64_t	rx_pfc_watchdog_last_storm_rx_bytes_dropped_pri0;
+	#define HWRM_CFA_PAIR_ALLOC_INPUT_ENABLES_Q_BA_VALID	UINT32_C(0x2)
 	/*
-	 * Number of bytes dropped on rx during last PFC watchdog storm
-	 * for pri 1
+	 * This bit must be '1' for the fc_ab field to be
+	 * configured.
 	 */
-	uint64_t	rx_pfc_watchdog_last_storm_rx_bytes_dropped_pri1;
+	#define HWRM_CFA_PAIR_ALLOC_INPUT_ENABLES_FC_AB_VALID	UINT32_C(0x4)
 	/*
-	 * Number of bytes dropped on rx during last PFC watchdog storm
-	 *  for pri 2
+	 * This bit must be '1' for the fc_ba field to be
+	 * configured.
 	 */
-	uint64_t	rx_pfc_watchdog_last_storm_rx_bytes_dropped_pri2;
+	#define HWRM_CFA_PAIR_ALLOC_INPUT_ENABLES_FC_BA_VALID	UINT32_C(0x8)
+	/* VF Pair name (32 byte string). */
+	char	pair_name[32];
 	/*
-	 * Number of bytes dropped on rx during last PFC watchdog storm
-	 *  for pri 3
+	 * The q_ab value specifies the logical index of the TX/RX CoS
+	 * queue to be assigned for traffic in the A to B direction of
+	 * the interface pair. The default value is 0.
 	 */
-	uint64_t	rx_pfc_watchdog_last_storm_rx_bytes_dropped_pri3;
+	uint8_t	q_ab;
 	/*
-	 * Number of bytes dropped on rx during last PFC watchdog storm
-	 *  for pri 4
+	 * The q_ba value specifies the logical index of the TX/RX CoS
+	 * queue to be assigned for traffic in the B to A direction of
+	 * the interface pair. The default value is 1.
 	 */
-	uint64_t	rx_pfc_watchdog_last_storm_rx_bytes_dropped_pri4;
+	uint8_t	q_ba;
 	/*
-	 * Number of bytes dropped on rx during last PFC watchdog storm
-	 *  for pri 5
+	 * Specifies whether RX ring flow control is disabled (0) or enabled
+	 * (1) in the A to B direction. The default value is 0, meaning that
+	 * packets will be dropped when the B-side RX rings are full.
 	 */
-	uint64_t	rx_pfc_watchdog_last_storm_rx_bytes_dropped_pri5;
+	uint8_t	fc_ab;
 	/*
-	 * Number of bytes dropped on rx during last PFC watchdog storm
-	 *  for pri 6
+	 * Specifies whether RX ring flow control is disabled (0) or enabled
+	 * (1) in the B to A direction. The default value is 1, meaning that
+	 * the RX CoS queue will be flow controlled when the A-side RX rings
+	 * are full.
 	 */
-	uint64_t	rx_pfc_watchdog_last_storm_rx_bytes_dropped_pri6;
+	uint8_t	fc_ba;
+	uint8_t	unused_1[4];
+} hwrm_cfa_pair_alloc_input_t, *phwrm_cfa_pair_alloc_input_t;
+
+/* hwrm_cfa_pair_alloc_output (size:192b/24B) */
+
+typedef struct hwrm_cfa_pair_alloc_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Only valid for modes 1 and 2. */
+	uint16_t	rx_cfa_code_a;
+	/* Only valid for modes 1 and 2. */
+	uint16_t	tx_cfa_action_a;
+	/* Only valid for mode 2. */
+	uint16_t	rx_cfa_code_b;
+	/* Only valid for mode 2. */
+	uint16_t	tx_cfa_action_b;
+	uint8_t	unused_0[7];
 	/*
-	 * Number of bytes dropped on rx during last PFC watchdog storm
-	 *  for pri 7
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	uint64_t	rx_pfc_watchdog_last_storm_rx_bytes_dropped_pri7;
-} rx_port_stats_ext_pfc_wd_t, *prx_port_stats_ext_pfc_wd_t;
+	uint8_t	valid;
+} hwrm_cfa_pair_alloc_output_t, *phwrm_cfa_pair_alloc_output_t;
 
-/************************
- * hwrm_port_qstats_ext *
- ************************/
+/**********************
+ * hwrm_cfa_pair_free *
+ **********************/
 
 
-/* hwrm_port_qstats_ext_input (size:320b/40B) */
+/* hwrm_cfa_pair_free_input (size:448b/56B) */
 
-typedef struct hwrm_port_qstats_ext_input {
+typedef struct hwrm_cfa_pair_free_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -22104,44 +50434,55 @@ typedef struct hwrm_port_qstats_ext_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Port ID of port that is being queried. */
-	uint16_t	port_id;
+	/* VF Pair name (32 byte string). */
+	char	pair_name[32];
+	/* Logical PF (0xff-PF for command channel). */
+	uint8_t	pf_b_id;
+	uint8_t	unused_0[3];
+	/* Logical VF number (range: 0 -> MAX_VFS -1). */
+	uint16_t	vf_id;
 	/*
-	 * The size of TX port extended
-	 * statistics block in bytes.
+	 * Pair mode (0-vf2fn, 1-rep2fn, 2-rep2rep, 3-proxy, 4-pfpair,
+	 *		5-rep2fn_mod, 6-rep2fn_modall, 7-rep2fn_truflow).
 	 */
-	uint16_t	tx_stat_size;
+	uint16_t	pair_mode;
 	/*
-	 * The size of RX port extended
-	 * statistics block in bytes
+	 * Pair between VF on local host with PF or VF on specified host.
+	 * (deprecated)
 	 */
-	uint16_t	rx_stat_size;
-	uint8_t	flags;
-	/* This value is not used to avoid backward compatibility issues. */
-	#define HWRM_PORT_QSTATS_EXT_INPUT_FLAGS_UNUSED	UINT32_C(0x0)
+	#define HWRM_CFA_PAIR_FREE_INPUT_PAIR_MODE_VF2FN	UINT32_C(0x0)
 	/*
-	 * This bit is set to 1 when request is for the counter mask,
-	 * representing width of each of the stats counters, rather than
-	 * counters themselves.
+	 * Pair between REP on local host with PF or VF on specified host.
+	 * (deprecated)
 	 */
-	#define HWRM_PORT_QSTATS_EXT_INPUT_FLAGS_COUNTER_MASK UINT32_C(0x1)
-	#define HWRM_PORT_QSTATS_EXT_INPUT_FLAGS_LAST	HWRM_PORT_QSTATS_EXT_INPUT_FLAGS_COUNTER_MASK
-	uint8_t	unused_0;
+	#define HWRM_CFA_PAIR_FREE_INPUT_PAIR_MODE_REP2FN	UINT32_C(0x1)
 	/*
-	 * This is the host address where
-	 * Tx port statistics will be stored
+	 * Pair between REP on local host with REP on specified host.
+	 * (deprecated)
 	 */
-	uint64_t	tx_stat_host_addr;
+	#define HWRM_CFA_PAIR_FREE_INPUT_PAIR_MODE_REP2REP	UINT32_C(0x2)
+	/* Pair for the proxy interface. (deprecated) */
+	#define HWRM_CFA_PAIR_FREE_INPUT_PAIR_MODE_PROXY	UINT32_C(0x3)
+	/* Pair for the PF interface. (deprecated) */
+	#define HWRM_CFA_PAIR_FREE_INPUT_PAIR_MODE_PFPAIR	UINT32_C(0x4)
+	/* Modify existing rep2fn pair and move pair to new PF. (deprecated) */
+	#define HWRM_CFA_PAIR_FREE_INPUT_PAIR_MODE_REP2FN_MOD	UINT32_C(0x5)
 	/*
-	 * This is the host address where
-	 * Rx port statistics will be stored
+	 * Modify existing rep2fn pairs paired with same PF and move pairs
+	 * to new PF. (deprecated)
 	 */
-	uint64_t	rx_stat_host_addr;
-} hwrm_port_qstats_ext_input_t, *phwrm_port_qstats_ext_input_t;
+	#define HWRM_CFA_PAIR_FREE_INPUT_PAIR_MODE_REP2FN_MODALL  UINT32_C(0x6)
+	/*
+	 * Truflow pair between REP on local host with PF or VF on
+	 * specified host.
+	 */
+	#define HWRM_CFA_PAIR_FREE_INPUT_PAIR_MODE_REP2FN_TRUFLOW UINT32_C(0x7)
+	#define HWRM_CFA_PAIR_FREE_INPUT_PAIR_MODE_LAST	HWRM_CFA_PAIR_FREE_INPUT_PAIR_MODE_REP2FN_TRUFLOW
+} hwrm_cfa_pair_free_input_t, *phwrm_cfa_pair_free_input_t;
 
-/* hwrm_port_qstats_ext_output (size:128b/16B) */
+/* hwrm_cfa_pair_free_output (size:128b/16B) */
 
-typedef struct hwrm_port_qstats_ext_output {
+typedef struct hwrm_cfa_pair_free_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -22150,36 +50491,26 @@ typedef struct hwrm_port_qstats_ext_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* The size of TX port statistics block in bytes. */
-	uint16_t	tx_stat_size;
-	/* The size of RX port statistics block in bytes. */
-	uint16_t	rx_stat_size;
-	/* Total number of active cos queues available. */
-	uint16_t	total_active_cos_queues;
-	uint8_t	flags;
-	/*
-	 * If set to 1, then this field indicates that clear
-	 * roce specific counters is supported.
-	 */
-	#define HWRM_PORT_QSTATS_EXT_OUTPUT_FLAGS_CLEAR_ROCE_COUNTERS_SUPPORTED	UINT32_C(0x1)
+	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_port_qstats_ext_output_t, *phwrm_port_qstats_ext_output_t;
+} hwrm_cfa_pair_free_output_t, *phwrm_cfa_pair_free_output_t;
 
-/*******************************
- * hwrm_port_qstats_ext_pfc_wd *
- *******************************/
+/**********************
+ * hwrm_cfa_pair_info *
+ **********************/
 
 
-/* hwrm_port_qstats_ext_pfc_wd_input (size:256b/32B) */
+/* hwrm_cfa_pair_info_input (size:448b/56B) */
 
-typedef struct hwrm_port_qstats_ext_pfc_wd_input {
+typedef struct hwrm_cfa_pair_info_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -22208,24 +50539,24 @@ typedef struct hwrm_port_qstats_ext_pfc_wd_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Port ID of port that is being queried. */
-	uint16_t	port_id;
-	/*
-	 * The size of rx_port_stats_ext_pfc_wd
-	 * block in bytes
-	 */
-	uint16_t	pfc_wd_stat_size;
-	uint8_t	unused_0[4];
-	/*
-	 * This is the host address where
-	 * rx_port_stats_ext_pfc_wd will be stored
-	 */
-	uint64_t	pfc_wd_stat_host_addr;
-} hwrm_port_qstats_ext_pfc_wd_input_t, *phwrm_port_qstats_ext_pfc_wd_input_t;
+	uint32_t	flags;
+	/* If this flag is set, lookup by name else lookup by index. */
+	#define HWRM_CFA_PAIR_INFO_INPUT_FLAGS_LOOKUP_TYPE	UINT32_C(0x1)
+	/* If this flag is set, lookup by PF id and VF id. */
+	#define HWRM_CFA_PAIR_INFO_INPUT_FLAGS_LOOKUP_REPRE	UINT32_C(0x2)
+	/* Pair table index. */
+	uint16_t	pair_index;
+	/* Pair pf index. */
+	uint8_t	pair_pfid;
+	/* Pair vf index. */
+	uint8_t	pair_vfid;
+	/* Pair name (32 byte string). */
+	char	pair_name[32];
+} hwrm_cfa_pair_info_input_t, *phwrm_cfa_pair_info_input_t;
 
-/* hwrm_port_qstats_ext_pfc_wd_output (size:128b/16B) */
+/* hwrm_cfa_pair_info_output (size:576b/72B) */
 
-typedef struct hwrm_port_qstats_ext_pfc_wd_output {
+typedef struct hwrm_cfa_pair_info_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -22234,31 +50565,83 @@ typedef struct hwrm_port_qstats_ext_pfc_wd_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
+	/* Pair table index. */
+	uint16_t	next_pair_index;
+	/* Pair member a's fid. */
+	uint16_t	a_fid;
+	/* Logical host number. */
+	uint8_t	host_a_index;
+	/* Logical PF number. */
+	uint8_t	pf_a_index;
+	/* Pair member a's Linux logical VF number. */
+	uint16_t	vf_a_index;
+	/* Rx CFA code. */
+	uint16_t	rx_cfa_code_a;
+	/* Tx CFA action. */
+	uint16_t	tx_cfa_action_a;
+	/* Pair member b's fid. */
+	uint16_t	b_fid;
+	/* Logical host number. */
+	uint8_t	host_b_index;
+	/* Logical PF number. */
+	uint8_t	pf_b_index;
+	/* Pair member a's Linux logical VF number. */
+	uint16_t	vf_b_index;
+	/* Rx CFA code. */
+	uint16_t	rx_cfa_code_b;
+	/* Tx CFA action. */
+	uint16_t	tx_cfa_action_b;
+	/* Pair mode (0-vf2fn, 1-rep2fn, 2-rep2rep, 3-proxy, 4-pfpair). */
+	uint8_t	pair_mode;
 	/*
-	 * The size of rx_port_stats_ext_pfc_wd
-	 * statistics block in bytes.
+	 * Pair between VF on local host with PF or VF on specified host.
+	 * (deprecated)
 	 */
-	uint16_t	pfc_wd_stat_size;
-	uint8_t	flags;
+	#define HWRM_CFA_PAIR_INFO_OUTPUT_PAIR_MODE_VF2FN   UINT32_C(0x0)
+	/*
+	 * Pair between REP on local host with PF or VF on specified host.
+	 * (deprecated)
+	 */
+	#define HWRM_CFA_PAIR_INFO_OUTPUT_PAIR_MODE_REP2FN  UINT32_C(0x1)
+	/*
+	 * Pair between REP on local host with REP on specified host.
+	 * (deprecated)
+	 */
+	#define HWRM_CFA_PAIR_INFO_OUTPUT_PAIR_MODE_REP2REP UINT32_C(0x2)
+	/* Pair for the proxy interface. (deprecated) */
+	#define HWRM_CFA_PAIR_INFO_OUTPUT_PAIR_MODE_PROXY   UINT32_C(0x3)
+	/* Pair for the PF interface. (deprecated) */
+	#define HWRM_CFA_PAIR_INFO_OUTPUT_PAIR_MODE_PFPAIR  UINT32_C(0x4)
+	#define HWRM_CFA_PAIR_INFO_OUTPUT_PAIR_MODE_LAST   HWRM_CFA_PAIR_INFO_OUTPUT_PAIR_MODE_PFPAIR
+	/* Pair state. */
+	uint8_t	pair_state;
+	/* Pair has been allocated */
+	#define HWRM_CFA_PAIR_INFO_OUTPUT_PAIR_STATE_ALLOCATED UINT32_C(0x1)
+	/* Both pair members are active */
+	#define HWRM_CFA_PAIR_INFO_OUTPUT_PAIR_STATE_ACTIVE	UINT32_C(0x2)
+	#define HWRM_CFA_PAIR_INFO_OUTPUT_PAIR_STATE_LAST	HWRM_CFA_PAIR_INFO_OUTPUT_PAIR_STATE_ACTIVE
+	/* Pair name (32 byte string). */
+	char	pair_name[32];
+	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-	uint8_t	unused_0[4];
-} hwrm_port_qstats_ext_pfc_wd_output_t, *phwrm_port_qstats_ext_pfc_wd_output_t;
+} hwrm_cfa_pair_info_output_t, *phwrm_cfa_pair_info_output_t;
 
-/*************************
- * hwrm_port_lpbk_qstats *
- *************************/
+/**********************
+ * hwrm_cfa_vfr_alloc *
+ **********************/
 
 
-/* hwrm_port_lpbk_qstats_input (size:128b/16B) */
+/* hwrm_cfa_vfr_alloc_input (size:448b/56B) */
 
-typedef struct hwrm_port_lpbk_qstats_input {
+typedef struct hwrm_cfa_vfr_alloc_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -22287,11 +50670,21 @@ typedef struct hwrm_port_lpbk_qstats_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-} hwrm_port_lpbk_qstats_input_t, *phwrm_port_lpbk_qstats_input_t;
+	/* Logical VF number (range: 0 -> MAX_VFS -1). */
+	uint16_t	vf_id;
+	/*
+	 * This field is reserved for the future use.
+	 * It shall be set to 0.
+	 */
+	uint16_t	reserved;
+	uint8_t	unused_0[4];
+	/* VF Representor name (32 byte string). */
+	char	vfr_name[32];
+} hwrm_cfa_vfr_alloc_input_t, *phwrm_cfa_vfr_alloc_input_t;
 
-/* hwrm_port_lpbk_qstats_output (size:768b/96B) */
+/* hwrm_cfa_vfr_alloc_output (size:128b/16B) */
 
-typedef struct hwrm_port_lpbk_qstats_output {
+typedef struct hwrm_cfa_vfr_alloc_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -22300,45 +50693,30 @@ typedef struct hwrm_port_lpbk_qstats_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* Number of transmitted unicast frames */
-	uint64_t	lpbk_ucast_frames;
-	/* Number of transmitted multicast frames */
-	uint64_t	lpbk_mcast_frames;
-	/* Number of transmitted broadcast frames */
-	uint64_t	lpbk_bcast_frames;
-	/* Number of transmitted bytes for unicast traffic */
-	uint64_t	lpbk_ucast_bytes;
-	/* Number of transmitted bytes for multicast traffic */
-	uint64_t	lpbk_mcast_bytes;
-	/* Number of transmitted bytes for broadcast traffic */
-	uint64_t	lpbk_bcast_bytes;
-	/* Total Tx Drops for loopback traffic reported by STATS block */
-	uint64_t	tx_stat_discard;
-	/* Total Tx Error Drops for loopback traffic reported by STATS block */
-	uint64_t	tx_stat_error;
-	/* Total Rx Drops for loopback traffic reported by STATS block */
-	uint64_t	rx_stat_discard;
-	/* Total Rx Error Drops for loopback traffic reported by STATS block */
-	uint64_t	rx_stat_error;
-	uint8_t	unused_0[7];
+	/* Rx CFA code. */
+	uint16_t	rx_cfa_code;
+	/* Tx CFA action. */
+	uint16_t	tx_cfa_action;
+	uint8_t	unused_0[3];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_port_lpbk_qstats_output_t, *phwrm_port_lpbk_qstats_output_t;
+} hwrm_cfa_vfr_alloc_output_t, *phwrm_cfa_vfr_alloc_output_t;
 
-/************************
- * hwrm_port_ecn_qstats *
- ************************/
+/*********************
+ * hwrm_cfa_vfr_free *
+ *********************/
 
 
-/* hwrm_port_ecn_qstats_input (size:256b/32B) */
+/* hwrm_cfa_vfr_free_input (size:448b/56B) */
 
-typedef struct hwrm_port_ecn_qstats_input {
+typedef struct hwrm_cfa_vfr_free_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -22367,37 +50745,21 @@ typedef struct hwrm_port_ecn_qstats_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
+	/* VF Representor name (32 byte string). */
+	char	vfr_name[32];
+	/* Logical VF number (range: 0 -> MAX_VFS -1). */
+	uint16_t	vf_id;
 	/*
-	 * Port ID of port that is being queried. Unused if NIC is in
-	 * multi-host mode.
-	 */
-	uint16_t	port_id;
-	/*
-	 * Size of the DMA buffer the caller has allocated for the firmware to
-	 * write into.
-	 */
-	uint16_t	ecn_stat_buf_size;
-	uint8_t	flags;
-	/* This value is not used to avoid backward compatibility issues. */
-	#define HWRM_PORT_ECN_QSTATS_INPUT_FLAGS_UNUSED	UINT32_C(0x0)
-	/*
-	 * This bit is set to 1 when request is for a counter mask,
-	 * representing the width of each of the stats counters, rather
-	 * than counters themselves.
-	 */
-	#define HWRM_PORT_ECN_QSTATS_INPUT_FLAGS_COUNTER_MASK UINT32_C(0x1)
-	#define HWRM_PORT_ECN_QSTATS_INPUT_FLAGS_LAST	HWRM_PORT_ECN_QSTATS_INPUT_FLAGS_COUNTER_MASK
-	uint8_t	unused_0[3];
-	/*
-	 * This is the host address where
-	 * ECN port statistics will be stored
+	 * This field is reserved for the future use.
+	 * It shall be set to 0.
 	 */
-	uint64_t	ecn_stat_host_addr;
-} hwrm_port_ecn_qstats_input_t, *phwrm_port_ecn_qstats_input_t;
+	uint16_t	reserved;
+	uint8_t	unused_0[4];
+} hwrm_cfa_vfr_free_input_t, *phwrm_cfa_vfr_free_input_t;
 
-/* hwrm_port_ecn_qstats_output (size:128b/16B) */
+/* hwrm_cfa_vfr_free_output (size:128b/16B) */
 
-typedef struct hwrm_port_ecn_qstats_output {
+typedef struct hwrm_cfa_vfr_free_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -22406,86 +50768,26 @@ typedef struct hwrm_port_ecn_qstats_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* Number of bytes of stats the firmware wrote to the DMA buffer. */
-	uint16_t	ecn_stat_buf_size;
-	/*
-	 * Bitmask that indicates which CoS queues have ECN marking enabled.
-	 * Bit i corresponds to CoS queue i.
-	 */
-	uint8_t	mark_en;
-	uint8_t	unused_0[4];
+	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_port_ecn_qstats_output_t, *phwrm_port_ecn_qstats_output_t;
-
-/* ECN mark statistics format */
-/* port_stats_ecn (size:512b/64B) */
-
-typedef struct port_stats_ecn {
-	/*
-	 * Number of packets marked in CoS queue 0.
-	 * Or, if the driver requested counter masks, a mask to indicate the size
-	 * of the counter.
-	 */
-	uint64_t	mark_cnt_cos0;
-	/*
-	 * Number of packets marked in CoS queue 1.
-	 * Or, if the driver requested counter masks, a mask to indicate the size
-	 * of the counter.
-	 */
-	uint64_t	mark_cnt_cos1;
-	/*
-	 * Number of packets marked in CoS queue 2.
-	 * Or, if the driver requested counter masks, a mask to indicate the size
-	 * of the counter.
-	 */
-	uint64_t	mark_cnt_cos2;
-	/*
-	 * Number of packets marked in CoS queue 3.
-	 * Or, if the driver requested counter masks, a mask to indicate the size
-	 * of the counter.
-	 */
-	uint64_t	mark_cnt_cos3;
-	/*
-	 * Number of packets marked in CoS queue 4.
-	 * Or, if the driver requested counter masks, a mask to indicate the size
-	 * of the counter.
-	 */
-	uint64_t	mark_cnt_cos4;
-	/*
-	 * Number of packets marked in CoS queue 5.
-	 * Or, if the driver requested counter masks, a mask to indicate the size
-	 * of the counter.
-	 */
-	uint64_t	mark_cnt_cos5;
-	/*
-	 * Number of packets marked in CoS queue 6.
-	 * Or, if the driver requested counter masks, a mask to indicate the size
-	 * of the counter.
-	 */
-	uint64_t	mark_cnt_cos6;
-	/*
-	 * Number of packets marked in CoS queue 7.
-	 * Or, if the driver requested counter masks, a mask to indicate the size
-	 * of the counter.
-	 */
-	uint64_t	mark_cnt_cos7;
-} port_stats_ecn_t, *pport_stats_ecn_t;
+} hwrm_cfa_vfr_free_output_t, *phwrm_cfa_vfr_free_output_t;
 
-/***********************
- * hwrm_port_clr_stats *
- ***********************/
+/***************************************
+ * hwrm_cfa_redirect_query_tunnel_type *
+ ***************************************/
 
 
-/* hwrm_port_clr_stats_input (size:192b/24B) */
+/* hwrm_cfa_redirect_query_tunnel_type_input (size:192b/24B) */
 
-typedef struct hwrm_port_clr_stats_input {
+typedef struct hwrm_cfa_redirect_query_tunnel_type_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -22514,25 +50816,14 @@ typedef struct hwrm_port_clr_stats_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Port ID of port that is being queried. */
-	uint16_t	port_id;
-	uint8_t	flags;
-	/*
-	 * If set to 1, then this field indicates clear the following RoCE
-	 * specific counters.
-	 * RoCE associated TX/RX cos counters
-	 * CNP associated TX/RX cos counters
-	 * RoCE/CNP specific TX/RX flow counters
-	 * Firmware will determine the RoCE/CNP cos queue based on qos profile.
-	 * This flag is honored only when RoCE is enabled on that port.
-	 */
-	#define HWRM_PORT_CLR_STATS_INPUT_FLAGS_ROCE_COUNTERS	UINT32_C(0x1)
-	uint8_t	unused_0[5];
-} hwrm_port_clr_stats_input_t, *phwrm_port_clr_stats_input_t;
+	/* The source function id. */
+	uint16_t	src_fid;
+	uint8_t	unused_0[6];
+} hwrm_cfa_redirect_query_tunnel_type_input_t, *phwrm_cfa_redirect_query_tunnel_type_input_t;
 
-/* hwrm_port_clr_stats_output (size:128b/16B) */
+/* hwrm_cfa_redirect_query_tunnel_type_output (size:128b/16B) */
 
-typedef struct hwrm_port_clr_stats_output {
+typedef struct hwrm_cfa_redirect_query_tunnel_type_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -22541,25 +50832,64 @@ typedef struct hwrm_port_clr_stats_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	/* Tunnel Mask. */
+	uint32_t	tunnel_mask;
+	/* Non-tunnel */
+	#define HWRM_CFA_REDIRECT_QUERY_TUNNEL_TYPE_OUTPUT_TUNNEL_MASK_NONTUNNEL	UINT32_C(0x1)
+	/* Virtual eXtensible Local Area Network (VXLAN) */
+	#define HWRM_CFA_REDIRECT_QUERY_TUNNEL_TYPE_OUTPUT_TUNNEL_MASK_VXLAN		UINT32_C(0x2)
+	/* Network Virtualization Generic Routing Encapsulation (NVGRE) */
+	#define HWRM_CFA_REDIRECT_QUERY_TUNNEL_TYPE_OUTPUT_TUNNEL_MASK_NVGRE		UINT32_C(0x4)
+	/* Generic Routing Encapsulation (GRE) inside Ethernet payload */
+	#define HWRM_CFA_REDIRECT_QUERY_TUNNEL_TYPE_OUTPUT_TUNNEL_MASK_L2GRE		UINT32_C(0x8)
+	/* IP in IP */
+	#define HWRM_CFA_REDIRECT_QUERY_TUNNEL_TYPE_OUTPUT_TUNNEL_MASK_IPIP		UINT32_C(0x10)
+	/* Generic Network Virtualization Encapsulation (Geneve) */
+	#define HWRM_CFA_REDIRECT_QUERY_TUNNEL_TYPE_OUTPUT_TUNNEL_MASK_GENEVE	UINT32_C(0x20)
+	/* Multi-Protocol Label Switching (MPLS) */
+	#define HWRM_CFA_REDIRECT_QUERY_TUNNEL_TYPE_OUTPUT_TUNNEL_MASK_MPLS		UINT32_C(0x40)
+	/* Stateless Transport Tunnel (STT) */
+	#define HWRM_CFA_REDIRECT_QUERY_TUNNEL_TYPE_OUTPUT_TUNNEL_MASK_STT		UINT32_C(0x80)
+	/* Generic Routing Encapsulation (GRE) inside IP datagram payload */
+	#define HWRM_CFA_REDIRECT_QUERY_TUNNEL_TYPE_OUTPUT_TUNNEL_MASK_IPGRE		UINT32_C(0x100)
+	/* IPV4 over virtual eXtensible Local Area Network (IPV4oVXLAN) */
+	#define HWRM_CFA_REDIRECT_QUERY_TUNNEL_TYPE_OUTPUT_TUNNEL_MASK_VXLAN_V4	UINT32_C(0x200)
+	/*
+	 * Enhance Generic Routing Encapsulation (GRE version 1) inside IP
+	 * datagram payload
+	 */
+	#define HWRM_CFA_REDIRECT_QUERY_TUNNEL_TYPE_OUTPUT_TUNNEL_MASK_IPGRE_V1	UINT32_C(0x400)
+	/* Any tunneled traffic */
+	#define HWRM_CFA_REDIRECT_QUERY_TUNNEL_TYPE_OUTPUT_TUNNEL_MASK_ANYTUNNEL	UINT32_C(0x800)
+	/* Use fixed layer 2 ether type of 0xFFFF */
+	#define HWRM_CFA_REDIRECT_QUERY_TUNNEL_TYPE_OUTPUT_TUNNEL_MASK_L2_ETYPE	UINT32_C(0x1000)
+	/*
+	 * IPV6 over virtual eXtensible Local Area Network with GPE header
+	 * (IPV6oVXLANGPE)
+	 */
+	#define HWRM_CFA_REDIRECT_QUERY_TUNNEL_TYPE_OUTPUT_TUNNEL_MASK_VXLAN_GPE_V6	UINT32_C(0x2000)
+	/* Generic Protocol Extension for VXLAN (VXLAN-GPE) */
+	#define HWRM_CFA_REDIRECT_QUERY_TUNNEL_TYPE_OUTPUT_TUNNEL_MASK_VXLAN_GPE	UINT32_C(0x4000)
+	uint8_t	unused_0[3];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_port_clr_stats_output_t, *phwrm_port_clr_stats_output_t;
+} hwrm_cfa_redirect_query_tunnel_type_output_t, *phwrm_cfa_redirect_query_tunnel_type_output_t;
 
-/***********************
- * hwrm_port_phy_qcaps *
- ***********************/
+/*************************
+ * hwrm_cfa_ctx_mem_rgtr *
+ *************************/
 
 
-/* hwrm_port_phy_qcaps_input (size:192b/24B) */
+/* hwrm_cfa_ctx_mem_rgtr_input (size:256b/32B) */
 
-typedef struct hwrm_port_phy_qcaps_input {
+typedef struct hwrm_cfa_ctx_mem_rgtr_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -22588,14 +50918,46 @@ typedef struct hwrm_port_phy_qcaps_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Port ID of port that is being queried. */
-	uint16_t	port_id;
-	uint8_t	unused_0[6];
-} hwrm_port_phy_qcaps_input_t, *phwrm_port_phy_qcaps_input_t;
+	uint16_t	flags;
+	/* Counter PBL indirect levels. */
+	uint8_t	page_level;
+	/* PBL pointer is physical start address. */
+	#define HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_LEVEL_LVL_0 UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+	#define HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_LEVEL_LVL_1 UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+	#define HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_LEVEL_LVL_2 UINT32_C(0x2)
+	#define HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_LEVEL_LAST HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_LEVEL_LVL_2
+	/* Page size. */
+	uint8_t	page_size;
+	/* 4KB page size. */
+	#define HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_SIZE_4K   UINT32_C(0x0)
+	/* 8KB page size. */
+	#define HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_SIZE_8K   UINT32_C(0x1)
+	/* 64KB page size. */
+	#define HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_SIZE_64K  UINT32_C(0x4)
+	/* 256KB page size. */
+	#define HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_SIZE_256K UINT32_C(0x6)
+	/* 1MB page size. */
+	#define HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_SIZE_1M   UINT32_C(0x8)
+	/* 2MB page size. */
+	#define HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_SIZE_2M   UINT32_C(0x9)
+	/* 4MB page size. */
+	#define HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_SIZE_4M   UINT32_C(0xa)
+	/* 1GB page size. */
+	#define HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_SIZE_1G   UINT32_C(0x12)
+	#define HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_SIZE_LAST HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_SIZE_1G
+	uint32_t	unused_0;
+	/* Pointer to the PBL, or PDL depending on number of levels */
+	uint64_t	page_dir;
+} hwrm_cfa_ctx_mem_rgtr_input_t, *phwrm_cfa_ctx_mem_rgtr_input_t;
 
-/* hwrm_port_phy_qcaps_output (size:256b/32B) */
+/* hwrm_cfa_ctx_mem_rgtr_output (size:128b/16B) */
 
-typedef struct hwrm_port_phy_qcaps_output {
+typedef struct hwrm_cfa_ctx_mem_rgtr_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -22604,229 +50966,31 @@ typedef struct hwrm_port_phy_qcaps_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* PHY capability flags */
-	uint8_t	flags;
-	/*
-	 * If set to 1, then this field indicates that the
-	 * link is capable of supporting EEE.
-	 */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS_EEE_SUPPORTED			UINT32_C(0x1)
-	/*
-	 * If set to 1, then this field indicates that the
-	 * PHY is capable of supporting external loopback.
-	 */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS_EXTERNAL_LPBK_SUPPORTED	UINT32_C(0x2)
-	/*
-	 * If set to 1, then this field indicates that the
-	 * PHY is capable of supporting loopback in autoneg mode.
-	 */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS_AUTONEG_LPBK_SUPPORTED	UINT32_C(0x4)
-	/*
-	 * Indicates if the configuration of shared PHY settings is supported.
-	 * In cases where a physical port is shared by multiple functions
-	 * (e.g. NPAR, multihost, etc), the configuration of PHY
-	 * settings may not be allowed. Callers to HWRM_PORT_PHY_CFG will
-	 * get an HWRM_ERR_CODE_RESOURCE_ACCESS_DENIED error in this case.
-	 */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS_SHARED_PHY_CFG_SUPPORTED	UINT32_C(0x8)
-	/*
-	 * If set to 1, it indicates that the port counters and extended
-	 * port counters will not reset when the firmware shuts down or
-	 * resets the PHY.  These counters will only be reset during power
-	 * cycle or by calling HWRM_PORT_CLR_STATS.
-	 * If set to 0, the state of the counters is unspecified when
-	 * firmware shuts down or resets the PHY.
-	 */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS_CUMULATIVE_COUNTERS_ON_RESET	UINT32_C(0x10)
-	/*
-	 * If set to 1, then this field indicates that the
-	 * local loopback is not supported on this controller.
-	 */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS_LOCAL_LPBK_NOT_SUPPORTED	UINT32_C(0x20)
-	/*
-	 * If set to 1, then this field indicates that the
-	 * PHY/Link down policy during PF shutdown is totally
-	 * controlled by the firmware. It can shutdown the link
-	 * even when there are active VFs associated with the PF.
-	 * Host PF driver can send HWRM_PHY_CFG command to bring
-	 * down the PHY even when the port is shared between VFs
-	 * and PFs.
-	 */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS_FW_MANAGED_LINK_DOWN		UINT32_C(0x40)
-	/*
-	 * If set to 1, this field indicates that the FCS may
-	 * be disabled for a given packet via the transmit
-	 * buffer descriptor.
-	 */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_FLAGS_NO_FCS			UINT32_C(0x80)
-	/* Number of front panel ports for this device. */
-	uint8_t	port_cnt;
-	/* Not supported or unknown */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_PORT_CNT_UNKNOWN UINT32_C(0x0)
-	/* single port device */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_PORT_CNT_1	UINT32_C(0x1)
-	/* 2-port device */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_PORT_CNT_2	UINT32_C(0x2)
-	/* 3-port device */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_PORT_CNT_3	UINT32_C(0x3)
-	/* 4-port device */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_PORT_CNT_4	UINT32_C(0x4)
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_PORT_CNT_LAST   HWRM_PORT_PHY_QCAPS_OUTPUT_PORT_CNT_4
-	/*
-	 * This is a bit mask to indicate what speeds are supported
-	 * as forced speeds on this link.
-	 * For each speed that can be forced on this link, the
-	 * corresponding mask bit shall be set to '1'.
-	 */
-	uint16_t	supported_speeds_force_mode;
-	/* 100Mb link speed (Half-duplex) */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_FORCE_MODE_100MBHD	UINT32_C(0x1)
-	/* 100Mb link speed (Full-duplex) */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_FORCE_MODE_100MB	UINT32_C(0x2)
-	/* 1Gb link speed (Half-duplex) */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_FORCE_MODE_1GBHD	UINT32_C(0x4)
-	/* 1Gb link speed (Full-duplex) */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_FORCE_MODE_1GB	UINT32_C(0x8)
-	/* 2Gb link speed */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_FORCE_MODE_2GB	UINT32_C(0x10)
-	/* 25Gb link speed */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_FORCE_MODE_2_5GB	UINT32_C(0x20)
-	/* 10Gb link speed */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_FORCE_MODE_10GB	UINT32_C(0x40)
-	/* 20Gb link speed */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_FORCE_MODE_20GB	UINT32_C(0x80)
-	/* 25Gb link speed */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_FORCE_MODE_25GB	UINT32_C(0x100)
-	/* 40Gb link speed */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_FORCE_MODE_40GB	UINT32_C(0x200)
-	/* 50Gb link speed */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_FORCE_MODE_50GB	UINT32_C(0x400)
-	/* 100Gb link speed */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_FORCE_MODE_100GB	UINT32_C(0x800)
-	/* 10Mb link speed (Half-duplex) */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_FORCE_MODE_10MBHD	UINT32_C(0x1000)
-	/* 10Mb link speed (Full-duplex) */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_FORCE_MODE_10MB	UINT32_C(0x2000)
-	/*
-	 * This is a bit mask to indicate what speeds are supported
-	 * for autonegotiation on this link.
-	 * For each speed that can be autonegotiated on this link, the
-	 * corresponding mask bit shall be set to '1'.
-	 */
-	uint16_t	supported_speeds_auto_mode;
-	/* 100Mb link speed (Half-duplex) */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_AUTO_MODE_100MBHD	UINT32_C(0x1)
-	/* 100Mb link speed (Full-duplex) */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_AUTO_MODE_100MB	UINT32_C(0x2)
-	/* 1Gb link speed (Half-duplex) */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_AUTO_MODE_1GBHD	UINT32_C(0x4)
-	/* 1Gb link speed (Full-duplex) */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_AUTO_MODE_1GB	UINT32_C(0x8)
-	/* 2Gb link speed */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_AUTO_MODE_2GB	UINT32_C(0x10)
-	/* 25Gb link speed */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_AUTO_MODE_2_5GB	UINT32_C(0x20)
-	/* 10Gb link speed */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_AUTO_MODE_10GB	UINT32_C(0x40)
-	/* 20Gb link speed */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_AUTO_MODE_20GB	UINT32_C(0x80)
-	/* 25Gb link speed */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_AUTO_MODE_25GB	UINT32_C(0x100)
-	/* 40Gb link speed */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_AUTO_MODE_40GB	UINT32_C(0x200)
-	/* 50Gb link speed */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_AUTO_MODE_50GB	UINT32_C(0x400)
-	/* 100Gb link speed */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_AUTO_MODE_100GB	UINT32_C(0x800)
-	/* 10Mb link speed (Half-duplex) */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_AUTO_MODE_10MBHD	UINT32_C(0x1000)
-	/* 10Mb link speed (Full-duplex) */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_AUTO_MODE_10MB	UINT32_C(0x2000)
-	/*
-	 * This is a bit mask to indicate what speeds are supported
-	 * for EEE on this link.
-	 * For each speed that can be autonegotiated when EEE is enabled
-	 * on this link, the corresponding mask bit shall be set to '1'.
-	 * This field is only valid when the eee_suppotred is set to '1'.
-	 */
-	uint16_t	supported_speeds_eee_mode;
-	/* Reserved */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_EEE_MODE_RSVD1	UINT32_C(0x1)
-	/* 100Mb link speed (Full-duplex) */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_EEE_MODE_100MB	UINT32_C(0x2)
-	/* Reserved */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_EEE_MODE_RSVD2	UINT32_C(0x4)
-	/* 1Gb link speed (Full-duplex) */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_EEE_MODE_1GB	UINT32_C(0x8)
-	/* Reserved */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_EEE_MODE_RSVD3	UINT32_C(0x10)
-	/* Reserved */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_EEE_MODE_RSVD4	UINT32_C(0x20)
-	/* 10Gb link speed */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_SPEEDS_EEE_MODE_10GB	UINT32_C(0x40)
-	uint32_t	tx_lpi_timer_low;
-	/*
-	 * The lowest value of TX LPI timer that can be set on this link
-	 * when EEE is enabled. This value is in microseconds.
-	 * This field is valid only when_eee_supported is set to '1'.
-	 */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_TX_LPI_TIMER_LOW_MASK UINT32_C(0xffffff)
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_TX_LPI_TIMER_LOW_SFT 0
-	/*
-	 * Reserved field. The HWRM shall set this field to 0.
-	 * An HWRM client shall ignore this field.
-	 */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_RSVD2_MASK	UINT32_C(0xff000000)
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_RSVD2_SFT		24
-	uint32_t	valid_tx_lpi_timer_high;
-	/*
-	 * The highest value of TX LPI timer that can be set on this link
-	 * when EEE is enabled. This value is in microseconds.
-	 * This field is valid only when_eee_supported is set to '1'.
-	 */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_TX_LPI_TIMER_HIGH_MASK UINT32_C(0xffffff)
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_TX_LPI_TIMER_HIGH_SFT 0
-	/*
-	 * Reserved field. The HWRM shall set this field to 0.
-	 * An HWRM client shall ignore this field.
-	 */
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_RSVD_MASK		UINT32_C(0xff000000)
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_RSVD_SFT		24
-	/*
-	 * This field is used to advertise which PAM4 speeds are supported
-	 * in auto mode.
-	 */
-	uint16_t	supported_pam4_speeds_auto_mode;
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_PAM4_SPEEDS_AUTO_MODE_50G	UINT32_C(0x1)
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_PAM4_SPEEDS_AUTO_MODE_100G	UINT32_C(0x2)
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_PAM4_SPEEDS_AUTO_MODE_200G	UINT32_C(0x4)
 	/*
-	 * This field is used to advertise which PAM4 speeds are supported
-	 * in forced mode.
-	 */
-	uint16_t	supported_pam4_speeds_force_mode;
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_PAM4_SPEEDS_FORCE_MODE_50G	UINT32_C(0x1)
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_PAM4_SPEEDS_FORCE_MODE_100G	UINT32_C(0x2)
-	#define HWRM_PORT_PHY_QCAPS_OUTPUT_SUPPORTED_PAM4_SPEEDS_FORCE_MODE_200G	UINT32_C(0x4)
-	uint8_t	unused_0[3];
+	 * Id/Handle to the recently register context memory. This handle is
+	 * passed to the CFA feature.
+	 */
+	uint16_t	ctx_id;
+	uint8_t	unused_0[5];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_port_phy_qcaps_output_t, *phwrm_port_phy_qcaps_output_t;
+} hwrm_cfa_ctx_mem_rgtr_output_t, *phwrm_cfa_ctx_mem_rgtr_output_t;
 
-/****************************
- * hwrm_port_phy_mdio_write *
- ****************************/
+/***************************
+ * hwrm_cfa_ctx_mem_unrgtr *
+ ***************************/
 
 
-/* hwrm_port_phy_mdio_write_input (size:320b/40B) */
+/* hwrm_cfa_ctx_mem_unrgtr_input (size:192b/24B) */
 
-typedef struct hwrm_port_phy_mdio_write_input {
+typedef struct hwrm_cfa_ctx_mem_unrgtr_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -22855,30 +51019,17 @@ typedef struct hwrm_port_phy_mdio_write_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Reserved for future use. */
-	uint64_t	unused_0;
-	/* Port ID of port. */
-	uint16_t	port_id;
-	/* If phy_address is 0xFF, port_id will be used to derive phy_addr. */
-	uint8_t	phy_addr;
-	/* 8-bit device address. */
-	uint8_t	dev_addr;
-	/* 16-bit register address. */
-	uint16_t	reg_addr;
-	/* 16-bit register data. */
-	uint16_t	reg_data;
 	/*
-	 * When this bit is set to 1 a Clause 45 mdio access is done.
-	 * when this bit is set to 0 a Clause 22 mdio access is done.
+	 * Id/Handle to the recently register context memory. This handle is
+	 * passed to the CFA feature.
 	 */
-	uint8_t	cl45_mdio;
-	/*  */
-	uint8_t	unused_1[7];
-} hwrm_port_phy_mdio_write_input_t, *phwrm_port_phy_mdio_write_input_t;
+	uint16_t	ctx_id;
+	uint8_t	unused_0[6];
+} hwrm_cfa_ctx_mem_unrgtr_input_t, *phwrm_cfa_ctx_mem_unrgtr_input_t;
 
-/* hwrm_port_phy_mdio_write_output (size:128b/16B) */
+/* hwrm_cfa_ctx_mem_unrgtr_output (size:128b/16B) */
 
-typedef struct hwrm_port_phy_mdio_write_output {
+typedef struct hwrm_cfa_ctx_mem_unrgtr_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -22890,22 +51041,23 @@ typedef struct hwrm_port_phy_mdio_write_output {
 	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_port_phy_mdio_write_output_t, *phwrm_port_phy_mdio_write_output_t;
+} hwrm_cfa_ctx_mem_unrgtr_output_t, *phwrm_cfa_ctx_mem_unrgtr_output_t;
 
-/***************************
- * hwrm_port_phy_mdio_read *
- ***************************/
+/*************************
+ * hwrm_cfa_ctx_mem_qctx *
+ *************************/
 
 
-/* hwrm_port_phy_mdio_read_input (size:256b/32B) */
+/* hwrm_cfa_ctx_mem_qctx_input (size:192b/24B) */
 
-typedef struct hwrm_port_phy_mdio_read_input {
+typedef struct hwrm_cfa_ctx_mem_qctx_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -22934,28 +51086,17 @@ typedef struct hwrm_port_phy_mdio_read_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Reserved for future use. */
-	uint64_t	unused_0;
-	/* Port ID of port. */
-	uint16_t	port_id;
-	/* If phy_address is 0xFF, port_id will be used to derive phy_addr. */
-	uint8_t	phy_addr;
-	/* 8-bit device address. */
-	uint8_t	dev_addr;
-	/* 16-bit register address. */
-	uint16_t	reg_addr;
 	/*
-	 * When this bit is set to 1 a Clause 45 mdio access is done.
-	 * when this bit is set to 0 a Clause 22 mdio access is done.
+	 * Id/Handle to the recently register context memory. This handle is
+	 * passed to the CFA feature.
 	 */
-	uint8_t	cl45_mdio;
-	/*  */
-	uint8_t	unused_1;
-} hwrm_port_phy_mdio_read_input_t, *phwrm_port_phy_mdio_read_input_t;
+	uint16_t	ctx_id;
+	uint8_t	unused_0[6];
+} hwrm_cfa_ctx_mem_qctx_input_t, *phwrm_cfa_ctx_mem_qctx_input_t;
 
-/* hwrm_port_phy_mdio_read_output (size:128b/16B) */
+/* hwrm_cfa_ctx_mem_qctx_output (size:256b/32B) */
 
-typedef struct hwrm_port_phy_mdio_read_output {
+typedef struct hwrm_cfa_ctx_mem_qctx_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -22964,27 +51105,61 @@ typedef struct hwrm_port_phy_mdio_read_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* 16-bit register data. */
-	uint16_t	reg_data;
-	uint8_t	unused_0[5];
+	uint16_t	flags;
+	/* Counter PBL indirect levels. */
+	uint8_t	page_level;
+	/* PBL pointer is physical start address. */
+	#define HWRM_CFA_CTX_MEM_QCTX_OUTPUT_PAGE_LEVEL_LVL_0 UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+	#define HWRM_CFA_CTX_MEM_QCTX_OUTPUT_PAGE_LEVEL_LVL_1 UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
+	 */
+	#define HWRM_CFA_CTX_MEM_QCTX_OUTPUT_PAGE_LEVEL_LVL_2 UINT32_C(0x2)
+	#define HWRM_CFA_CTX_MEM_QCTX_OUTPUT_PAGE_LEVEL_LAST HWRM_CFA_CTX_MEM_QCTX_OUTPUT_PAGE_LEVEL_LVL_2
+	/* Page size. */
+	uint8_t	page_size;
+	/* 4KB page size. */
+	#define HWRM_CFA_CTX_MEM_QCTX_OUTPUT_PAGE_SIZE_4K   UINT32_C(0x0)
+	/* 8KB page size. */
+	#define HWRM_CFA_CTX_MEM_QCTX_OUTPUT_PAGE_SIZE_8K   UINT32_C(0x1)
+	/* 64KB page size. */
+	#define HWRM_CFA_CTX_MEM_QCTX_OUTPUT_PAGE_SIZE_64K  UINT32_C(0x4)
+	/* 256KB page size. */
+	#define HWRM_CFA_CTX_MEM_QCTX_OUTPUT_PAGE_SIZE_256K UINT32_C(0x6)
+	/* 1MB page size. */
+	#define HWRM_CFA_CTX_MEM_QCTX_OUTPUT_PAGE_SIZE_1M   UINT32_C(0x8)
+	/* 2MB page size. */
+	#define HWRM_CFA_CTX_MEM_QCTX_OUTPUT_PAGE_SIZE_2M   UINT32_C(0x9)
+	/* 4MB page size. */
+	#define HWRM_CFA_CTX_MEM_QCTX_OUTPUT_PAGE_SIZE_4M   UINT32_C(0xa)
+	/* 1GB page size. */
+	#define HWRM_CFA_CTX_MEM_QCTX_OUTPUT_PAGE_SIZE_1G   UINT32_C(0x12)
+	#define HWRM_CFA_CTX_MEM_QCTX_OUTPUT_PAGE_SIZE_LAST HWRM_CFA_CTX_MEM_QCTX_OUTPUT_PAGE_SIZE_1G
+	uint8_t	unused_0[4];
+	/* Pointer to the PBL, or PDL depending on number of levels */
+	uint64_t	page_dir;
+	uint8_t	unused_1[7];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_port_phy_mdio_read_output_t, *phwrm_port_phy_mdio_read_output_t;
+} hwrm_cfa_ctx_mem_qctx_output_t, *phwrm_cfa_ctx_mem_qctx_output_t;
 
-/*********************
- * hwrm_port_led_cfg *
- *********************/
+/**************************
+ * hwrm_cfa_ctx_mem_qcaps *
+ **************************/
 
 
-/* hwrm_port_led_cfg_input (size:512b/64B) */
+/* hwrm_cfa_ctx_mem_qcaps_input (size:128b/16B) */
 
-typedef struct hwrm_port_led_cfg_input {
+typedef struct hwrm_cfa_ctx_mem_qcaps_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -23013,345 +51188,413 @@ typedef struct hwrm_port_led_cfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	enables;
-	/*
-	 * This bit must be '1' for the led0_id field to be
-	 * configured.
-	 */
-	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED0_ID		UINT32_C(0x1)
-	/*
-	 * This bit must be '1' for the led0_state field to be
-	 * configured.
-	 */
-	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED0_STATE	UINT32_C(0x2)
-	/*
-	 * This bit must be '1' for the led0_color field to be
-	 * configured.
-	 */
-	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED0_COLOR	UINT32_C(0x4)
+} hwrm_cfa_ctx_mem_qcaps_input_t, *phwrm_cfa_ctx_mem_qcaps_input_t;
+
+/* hwrm_cfa_ctx_mem_qcaps_output (size:128b/16B) */
+
+typedef struct hwrm_cfa_ctx_mem_qcaps_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
 	/*
-	 * This bit must be '1' for the led0_blink_on field to be
-	 * configured.
+	 * Indicates the maximum number of context memory which can be
+	 * registered.
 	 */
-	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED0_BLINK_ON	UINT32_C(0x8)
+	uint16_t	max_entries;
+	uint8_t	unused_0[5];
 	/*
-	 * This bit must be '1' for the led0_blink_off field to be
-	 * configured.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED0_BLINK_OFF	UINT32_C(0x10)
+	uint8_t	valid;
+} hwrm_cfa_ctx_mem_qcaps_output_t, *phwrm_cfa_ctx_mem_qcaps_output_t;
+
+/**************************
+ * hwrm_cfa_counter_qcaps *
+ **************************/
+
+
+/* hwrm_cfa_counter_qcaps_input (size:128b/16B) */
+
+typedef struct hwrm_cfa_counter_qcaps_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * This bit must be '1' for the led0_group_id field to be
-	 * configured.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED0_GROUP_ID	UINT32_C(0x20)
+	uint16_t	cmpl_ring;
 	/*
-	 * This bit must be '1' for the led1_id field to be
-	 * configured.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED1_ID		UINT32_C(0x40)
+	uint16_t	seq_id;
 	/*
-	 * This bit must be '1' for the led1_state field to be
-	 * configured.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED1_STATE	UINT32_C(0x80)
+	uint16_t	target_id;
 	/*
-	 * This bit must be '1' for the led1_color field to be
-	 * configured.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED1_COLOR	UINT32_C(0x100)
+	uint64_t	resp_addr;
+} hwrm_cfa_counter_qcaps_input_t, *phwrm_cfa_counter_qcaps_input_t;
+
+/* hwrm_cfa_counter_qcaps_output (size:576b/72B) */
+
+typedef struct hwrm_cfa_counter_qcaps_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint32_t	flags;
+	/* Enumeration denoting the supported CFA counter format. */
+	#define HWRM_CFA_COUNTER_QCAPS_OUTPUT_FLAGS_COUNTER_FORMAT	UINT32_C(0x1)
+	/* CFA counter types are not supported. */
+		#define HWRM_CFA_COUNTER_QCAPS_OUTPUT_FLAGS_COUNTER_FORMAT_NONE	UINT32_C(0x0)
+	/* 64-bit packet counters followed by 64-bit byte counters format. */
+		#define HWRM_CFA_COUNTER_QCAPS_OUTPUT_FLAGS_COUNTER_FORMAT_64_BIT  UINT32_C(0x1)
+		#define HWRM_CFA_COUNTER_QCAPS_OUTPUT_FLAGS_COUNTER_FORMAT_LAST   HWRM_CFA_COUNTER_QCAPS_OUTPUT_FLAGS_COUNTER_FORMAT_64_BIT
+	uint32_t	unused_0;
 	/*
-	 * This bit must be '1' for the led1_blink_on field to be
-	 * configured.
+	 * Minimum guaranteed number of flow counters supported for this
+	 * function, in RX direction.
 	 */
-	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED1_BLINK_ON	UINT32_C(0x200)
+	uint32_t	min_rx_fc;
 	/*
-	 * This bit must be '1' for the led1_blink_off field to be
-	 * configured.
+	 * Maximum non-guaranteed number of flow counters supported for this
+	 * function, in RX direction.
 	 */
-	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED1_BLINK_OFF	UINT32_C(0x400)
+	uint32_t	max_rx_fc;
 	/*
-	 * This bit must be '1' for the led1_group_id field to be
-	 * configured.
+	 * Minimum guaranteed number of flow counters supported for this
+	 * function, in TX direction.
 	 */
-	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED1_GROUP_ID	UINT32_C(0x800)
+	uint32_t	min_tx_fc;
 	/*
-	 * This bit must be '1' for the led2_id field to be
-	 * configured.
+	 * Maximum non-guaranteed number of flow counters supported for this
+	 * function, in TX direction.
 	 */
-	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED2_ID		UINT32_C(0x1000)
+	uint32_t	max_tx_fc;
 	/*
-	 * This bit must be '1' for the led2_state field to be
-	 * configured.
+	 * Minimum guaranteed number of extension flow counters supported for
+	 * this function, in RX direction.
 	 */
-	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED2_STATE	UINT32_C(0x2000)
+	uint32_t	min_rx_efc;
 	/*
-	 * This bit must be '1' for the led2_color field to be
-	 * configured.
+	 * Maximum non-guaranteed number of extension flow counters supported
+	 * for this function, in RX direction.
 	 */
-	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED2_COLOR	UINT32_C(0x4000)
+	uint32_t	max_rx_efc;
 	/*
-	 * This bit must be '1' for the led2_blink_on field to be
-	 * configured.
+	 * Minimum guaranteed number of extension flow counters supported for
+	 * this function, in TX direction.
 	 */
-	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED2_BLINK_ON	UINT32_C(0x8000)
+	uint32_t	min_tx_efc;
 	/*
-	 * This bit must be '1' for the led2_blink_off field to be
-	 * configured.
+	 * Maximum non-guaranteed number of extension flow counters supported
+	 * for this function, in TX direction.
 	 */
-	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED2_BLINK_OFF	UINT32_C(0x10000)
+	uint32_t	max_tx_efc;
 	/*
-	 * This bit must be '1' for the led2_group_id field to be
-	 * configured.
+	 * Minimum guaranteed number of meter drop counters supported for
+	 * this function, in RX direction.
 	 */
-	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED2_GROUP_ID	UINT32_C(0x20000)
+	uint32_t	min_rx_mdc;
 	/*
-	 * This bit must be '1' for the led3_id field to be
-	 * configured.
+	 * Maximum non-guaranteed number of meter drop counters supported for
+	 * this function, in RX direction.
 	 */
-	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED3_ID		UINT32_C(0x40000)
+	uint32_t	max_rx_mdc;
 	/*
-	 * This bit must be '1' for the led3_state field to be
-	 * configured.
+	 * Minimum guaranteed number of meter drop counters supported for this
+	 * function, in TX direction.
 	 */
-	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED3_STATE	UINT32_C(0x80000)
+	uint32_t	min_tx_mdc;
 	/*
-	 * This bit must be '1' for the led3_color field to be
-	 * configured.
+	 * Maximum non-guaranteed number of meter drop counters supported for
+	 * this function, in TX direction.
 	 */
-	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED3_COLOR	UINT32_C(0x100000)
+	uint32_t	max_tx_mdc;
 	/*
-	 * This bit must be '1' for the led3_blink_on field to be
-	 * configured.
+	 * Maximum guaranteed number of flow counters which can be used during
+	 * flow alloc.
 	 */
-	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED3_BLINK_ON	UINT32_C(0x200000)
+	uint32_t	max_flow_alloc_fc;
+	uint8_t	unused_1[3];
 	/*
-	 * This bit must be '1' for the led3_blink_off field to be
-	 * configured.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED3_BLINK_OFF	UINT32_C(0x400000)
+	uint8_t	valid;
+} hwrm_cfa_counter_qcaps_output_t, *phwrm_cfa_counter_qcaps_output_t;
+
+/************************
+ * hwrm_cfa_counter_cfg *
+ ************************/
+
+
+/* hwrm_cfa_counter_cfg_input (size:256b/32B) */
+
+typedef struct hwrm_cfa_counter_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * This bit must be '1' for the led3_group_id field to be
-	 * configured.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define HWRM_PORT_LED_CFG_INPUT_ENABLES_LED3_GROUP_ID	UINT32_C(0x800000)
-	/* Port ID of port whose LEDs are configured. */
-	uint16_t	port_id;
+	uint16_t	cmpl_ring;
 	/*
-	 * The number of LEDs that are being configured.
-	 * Up to 4 LEDs can be configured with this command.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint8_t	num_leds;
-	/* Reserved field. */
-	uint8_t	rsvd;
-	/* An identifier for the LED #0. */
-	uint8_t	led0_id;
-	/* The requested state of the LED #0. */
-	uint8_t	led0_state;
-	/* Default state of the LED */
-	#define HWRM_PORT_LED_CFG_INPUT_LED0_STATE_DEFAULT  UINT32_C(0x0)
-	/* Off */
-	#define HWRM_PORT_LED_CFG_INPUT_LED0_STATE_OFF	UINT32_C(0x1)
-	/* On */
-	#define HWRM_PORT_LED_CFG_INPUT_LED0_STATE_ON	UINT32_C(0x2)
-	/* Blink */
-	#define HWRM_PORT_LED_CFG_INPUT_LED0_STATE_BLINK	UINT32_C(0x3)
-	/* Blink Alternately */
-	#define HWRM_PORT_LED_CFG_INPUT_LED0_STATE_BLINKALT UINT32_C(0x4)
-	#define HWRM_PORT_LED_CFG_INPUT_LED0_STATE_LAST	HWRM_PORT_LED_CFG_INPUT_LED0_STATE_BLINKALT
-	/* The requested color of LED #0. */
-	uint8_t	led0_color;
-	/* Default */
-	#define HWRM_PORT_LED_CFG_INPUT_LED0_COLOR_DEFAULT	UINT32_C(0x0)
-	/* Amber */
-	#define HWRM_PORT_LED_CFG_INPUT_LED0_COLOR_AMBER	UINT32_C(0x1)
-	/* Green */
-	#define HWRM_PORT_LED_CFG_INPUT_LED0_COLOR_GREEN	UINT32_C(0x2)
-	/* Green or Amber */
-	#define HWRM_PORT_LED_CFG_INPUT_LED0_COLOR_GREENAMBER UINT32_C(0x3)
-	#define HWRM_PORT_LED_CFG_INPUT_LED0_COLOR_LAST	HWRM_PORT_LED_CFG_INPUT_LED0_COLOR_GREENAMBER
-	uint8_t	unused_0;
+	uint16_t	seq_id;
 	/*
-	 * If the LED #0 state is "blink" or "blinkalt", then
-	 * this field represents the requested time in milliseconds
-	 * to keep LED on between cycles.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint16_t	led0_blink_on;
+	uint16_t	target_id;
 	/*
-	 * If the LED #0 state is "blink" or "blinkalt", then
-	 * this field represents the requested time in milliseconds
-	 * to keep LED off between cycles.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint16_t	led0_blink_off;
+	uint64_t	resp_addr;
+	uint16_t	flags;
+	/* Enumeration denoting the configuration mode. */
+	#define HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_CFG_MODE			UINT32_C(0x1)
+	/* Disable the configuration mode. */
+		#define HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_CFG_MODE_DISABLE		UINT32_C(0x0)
+	/* Enable the configuration mode. */
+		#define HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_CFG_MODE_ENABLE		UINT32_C(0x1)
+		#define HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_CFG_MODE_LAST		HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_CFG_MODE_ENABLE
+	/* Enumeration denoting the RX, TX type of the resource. */
+	#define HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_PATH			UINT32_C(0x2)
+	/* Tx path. */
+		#define HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_PATH_TX			(UINT32_C(0x0) << 1)
+	/* Rx path. */
+		#define HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_PATH_RX			(UINT32_C(0x1) << 1)
+		#define HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_PATH_LAST			HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_PATH_RX
+	/* Enumeration denoting the data transfer mode. */
+	#define HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_DATA_TRANSFER_MODE_MASK	UINT32_C(0xc)
+	#define HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_DATA_TRANSFER_MODE_SFT	2
+	/* Push mode. */
+		#define HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_DATA_TRANSFER_MODE_PUSH	(UINT32_C(0x0) << 2)
+	/* Pull mode. */
+		#define HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_DATA_TRANSFER_MODE_PULL	(UINT32_C(0x1) << 2)
+	/* Pull on async update. */
+		#define HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_DATA_TRANSFER_MODE_PULL_ASYNC  (UINT32_C(0x2) << 2)
+		#define HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_DATA_TRANSFER_MODE_LAST	HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_DATA_TRANSFER_MODE_PULL_ASYNC
+	uint16_t	counter_type;
+	/* Flow counters. */
+	#define HWRM_CFA_COUNTER_CFG_INPUT_COUNTER_TYPE_FC  UINT32_C(0x0)
+	/* Extended flow counters. */
+	#define HWRM_CFA_COUNTER_CFG_INPUT_COUNTER_TYPE_EFC UINT32_C(0x1)
+	/* Meter drop counters. */
+	#define HWRM_CFA_COUNTER_CFG_INPUT_COUNTER_TYPE_MDC UINT32_C(0x2)
+	#define HWRM_CFA_COUNTER_CFG_INPUT_COUNTER_TYPE_LAST HWRM_CFA_COUNTER_CFG_INPUT_COUNTER_TYPE_MDC
+	/* Ctx memory handle to be used for the counter. */
+	uint16_t	ctx_id;
+	/* Counter update cadence hint (only in Push mode). */
+	uint16_t	update_tmr_ms;
+	/* Total number of entries. */
+	uint32_t	num_entries;
+	uint32_t	unused_0;
+} hwrm_cfa_counter_cfg_input_t, *phwrm_cfa_counter_cfg_input_t;
+
+/* hwrm_cfa_counter_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_cfa_counter_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
 	/*
-	 * An identifier for the group of LEDs that LED #0 belongs
-	 * to.
-	 * If set to 0, then the LED #0 shall not be grouped and
-	 * shall be treated as an individual resource.
-	 * For all other non-zero values of this field, LED #0 shall
-	 * be grouped together with the LEDs with the same group ID
-	 * value.
-	 */
-	uint8_t	led0_group_id;
-	/* Reserved field. */
-	uint8_t	rsvd0;
-	/* An identifier for the LED #1. */
-	uint8_t	led1_id;
-	/* The requested state of the LED #1. */
-	uint8_t	led1_state;
-	/* Default state of the LED */
-	#define HWRM_PORT_LED_CFG_INPUT_LED1_STATE_DEFAULT  UINT32_C(0x0)
-	/* Off */
-	#define HWRM_PORT_LED_CFG_INPUT_LED1_STATE_OFF	UINT32_C(0x1)
-	/* On */
-	#define HWRM_PORT_LED_CFG_INPUT_LED1_STATE_ON	UINT32_C(0x2)
-	/* Blink */
-	#define HWRM_PORT_LED_CFG_INPUT_LED1_STATE_BLINK	UINT32_C(0x3)
-	/* Blink Alternately */
-	#define HWRM_PORT_LED_CFG_INPUT_LED1_STATE_BLINKALT UINT32_C(0x4)
-	#define HWRM_PORT_LED_CFG_INPUT_LED1_STATE_LAST	HWRM_PORT_LED_CFG_INPUT_LED1_STATE_BLINKALT
-	/* The requested color of LED #1. */
-	uint8_t	led1_color;
-	/* Default */
-	#define HWRM_PORT_LED_CFG_INPUT_LED1_COLOR_DEFAULT	UINT32_C(0x0)
-	/* Amber */
-	#define HWRM_PORT_LED_CFG_INPUT_LED1_COLOR_AMBER	UINT32_C(0x1)
-	/* Green */
-	#define HWRM_PORT_LED_CFG_INPUT_LED1_COLOR_GREEN	UINT32_C(0x2)
-	/* Green or Amber */
-	#define HWRM_PORT_LED_CFG_INPUT_LED1_COLOR_GREENAMBER UINT32_C(0x3)
-	#define HWRM_PORT_LED_CFG_INPUT_LED1_COLOR_LAST	HWRM_PORT_LED_CFG_INPUT_LED1_COLOR_GREENAMBER
-	uint8_t	unused_1;
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
+	 */
+	uint8_t	valid;
+} hwrm_cfa_counter_cfg_output_t, *phwrm_cfa_counter_cfg_output_t;
+
+/*************************
+ * hwrm_cfa_counter_qcfg *
+ *************************/
+
+
+/* hwrm_cfa_counter_qcfg_input (size:192b/24B) */
+
+typedef struct hwrm_cfa_counter_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * If the LED #1 state is "blink" or "blinkalt", then
-	 * this field represents the requested time in milliseconds
-	 * to keep LED on between cycles.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint16_t	led1_blink_on;
+	uint16_t	cmpl_ring;
 	/*
-	 * If the LED #1 state is "blink" or "blinkalt", then
-	 * this field represents the requested time in milliseconds
-	 * to keep LED off between cycles.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint16_t	led1_blink_off;
+	uint16_t	seq_id;
 	/*
-	 * An identifier for the group of LEDs that LED #1 belongs
-	 * to.
-	 * If set to 0, then the LED #1 shall not be grouped and
-	 * shall be treated as an individual resource.
-	 * For all other non-zero values of this field, LED #1 shall
-	 * be grouped together with the LEDs with the same group ID
-	 * value.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint8_t	led1_group_id;
-	/* Reserved field. */
-	uint8_t	rsvd1;
-	/* An identifier for the LED #2. */
-	uint8_t	led2_id;
-	/* The requested state of the LED #2. */
-	uint8_t	led2_state;
-	/* Default state of the LED */
-	#define HWRM_PORT_LED_CFG_INPUT_LED2_STATE_DEFAULT  UINT32_C(0x0)
-	/* Off */
-	#define HWRM_PORT_LED_CFG_INPUT_LED2_STATE_OFF	UINT32_C(0x1)
-	/* On */
-	#define HWRM_PORT_LED_CFG_INPUT_LED2_STATE_ON	UINT32_C(0x2)
-	/* Blink */
-	#define HWRM_PORT_LED_CFG_INPUT_LED2_STATE_BLINK	UINT32_C(0x3)
-	/* Blink Alternately */
-	#define HWRM_PORT_LED_CFG_INPUT_LED2_STATE_BLINKALT UINT32_C(0x4)
-	#define HWRM_PORT_LED_CFG_INPUT_LED2_STATE_LAST	HWRM_PORT_LED_CFG_INPUT_LED2_STATE_BLINKALT
-	/* The requested color of LED #2. */
-	uint8_t	led2_color;
-	/* Default */
-	#define HWRM_PORT_LED_CFG_INPUT_LED2_COLOR_DEFAULT	UINT32_C(0x0)
-	/* Amber */
-	#define HWRM_PORT_LED_CFG_INPUT_LED2_COLOR_AMBER	UINT32_C(0x1)
-	/* Green */
-	#define HWRM_PORT_LED_CFG_INPUT_LED2_COLOR_GREEN	UINT32_C(0x2)
-	/* Green or Amber */
-	#define HWRM_PORT_LED_CFG_INPUT_LED2_COLOR_GREENAMBER UINT32_C(0x3)
-	#define HWRM_PORT_LED_CFG_INPUT_LED2_COLOR_LAST	HWRM_PORT_LED_CFG_INPUT_LED2_COLOR_GREENAMBER
-	uint8_t	unused_2;
+	uint16_t	target_id;
 	/*
-	 * If the LED #2 state is "blink" or "blinkalt", then
-	 * this field represents the requested time in milliseconds
-	 * to keep LED on between cycles.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint16_t	led2_blink_on;
+	uint64_t	resp_addr;
+	uint16_t	flags;
+	/* Enumeration denoting the RX, TX type of the resource. */
+	#define HWRM_CFA_COUNTER_QCFG_INPUT_FLAGS_PATH			UINT32_C(0x1)
+	/* Tx path. */
+		#define HWRM_CFA_COUNTER_QCFG_INPUT_FLAGS_PATH_TX			UINT32_C(0x0)
+	/* Rx path. */
+		#define HWRM_CFA_COUNTER_QCFG_INPUT_FLAGS_PATH_RX			UINT32_C(0x1)
+		#define HWRM_CFA_COUNTER_QCFG_INPUT_FLAGS_PATH_LAST			HWRM_CFA_COUNTER_QCFG_INPUT_FLAGS_PATH_RX
+	/* Enumeration denoting the data transfer mode. */
+	#define HWRM_CFA_COUNTER_QCFG_INPUT_FLAGS_DATA_TRANSFER_MODE_MASK	UINT32_C(0x6)
+	#define HWRM_CFA_COUNTER_QCFG_INPUT_FLAGS_DATA_TRANSFER_MODE_SFT	1
+	/* Push mode. */
+		#define HWRM_CFA_COUNTER_QCFG_INPUT_FLAGS_DATA_TRANSFER_MODE_PUSH	(UINT32_C(0x0) << 1)
+	/* Pull mode. */
+		#define HWRM_CFA_COUNTER_QCFG_INPUT_FLAGS_DATA_TRANSFER_MODE_PULL	(UINT32_C(0x1) << 1)
+	/* Pull on async update. */
+		#define HWRM_CFA_COUNTER_QCFG_INPUT_FLAGS_DATA_TRANSFER_MODE_PULL_ASYNC  (UINT32_C(0x2) << 1)
+		#define HWRM_CFA_COUNTER_QCFG_INPUT_FLAGS_DATA_TRANSFER_MODE_LAST	HWRM_CFA_COUNTER_QCFG_INPUT_FLAGS_DATA_TRANSFER_MODE_PULL_ASYNC
+	uint16_t	counter_type;
+	uint32_t	unused_0;
+} hwrm_cfa_counter_qcfg_input_t, *phwrm_cfa_counter_qcfg_input_t;
+
+/* hwrm_cfa_counter_qcfg_output (size:192b/24B) */
+
+typedef struct hwrm_cfa_counter_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint16_t	ctx_id;
+	uint16_t	update_tmr_ms;
+	uint32_t	num_entries;
+	uint8_t	unused_0[7];
 	/*
-	 * If the LED #2 state is "blink" or "blinkalt", then
-	 * this field represents the requested time in milliseconds
-	 * to keep LED off between cycles.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	uint16_t	led2_blink_off;
+	uint8_t	valid;
+} hwrm_cfa_counter_qcfg_output_t, *phwrm_cfa_counter_qcfg_output_t;
+
+/***************************
+ * hwrm_cfa_counter_qstats *
+ ***************************/
+
+
+/* hwrm_cfa_counter_qstats_input (size:320b/40B) */
+
+typedef struct hwrm_cfa_counter_qstats_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * An identifier for the group of LEDs that LED #2 belongs
-	 * to.
-	 * If set to 0, then the LED #2 shall not be grouped and
-	 * shall be treated as an individual resource.
-	 * For all other non-zero values of this field, LED #2 shall
-	 * be grouped together with the LEDs with the same group ID
-	 * value.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint8_t	led2_group_id;
-	/* Reserved field. */
-	uint8_t	rsvd2;
-	/* An identifier for the LED #3. */
-	uint8_t	led3_id;
-	/* The requested state of the LED #3. */
-	uint8_t	led3_state;
-	/* Default state of the LED */
-	#define HWRM_PORT_LED_CFG_INPUT_LED3_STATE_DEFAULT  UINT32_C(0x0)
-	/* Off */
-	#define HWRM_PORT_LED_CFG_INPUT_LED3_STATE_OFF	UINT32_C(0x1)
-	/* On */
-	#define HWRM_PORT_LED_CFG_INPUT_LED3_STATE_ON	UINT32_C(0x2)
-	/* Blink */
-	#define HWRM_PORT_LED_CFG_INPUT_LED3_STATE_BLINK	UINT32_C(0x3)
-	/* Blink Alternately */
-	#define HWRM_PORT_LED_CFG_INPUT_LED3_STATE_BLINKALT UINT32_C(0x4)
-	#define HWRM_PORT_LED_CFG_INPUT_LED3_STATE_LAST	HWRM_PORT_LED_CFG_INPUT_LED3_STATE_BLINKALT
-	/* The requested color of LED #3. */
-	uint8_t	led3_color;
-	/* Default */
-	#define HWRM_PORT_LED_CFG_INPUT_LED3_COLOR_DEFAULT	UINT32_C(0x0)
-	/* Amber */
-	#define HWRM_PORT_LED_CFG_INPUT_LED3_COLOR_AMBER	UINT32_C(0x1)
-	/* Green */
-	#define HWRM_PORT_LED_CFG_INPUT_LED3_COLOR_GREEN	UINT32_C(0x2)
-	/* Green or Amber */
-	#define HWRM_PORT_LED_CFG_INPUT_LED3_COLOR_GREENAMBER UINT32_C(0x3)
-	#define HWRM_PORT_LED_CFG_INPUT_LED3_COLOR_LAST	HWRM_PORT_LED_CFG_INPUT_LED3_COLOR_GREENAMBER
-	uint8_t	unused_3;
+	uint16_t	cmpl_ring;
 	/*
-	 * If the LED #3 state is "blink" or "blinkalt", then
-	 * this field represents the requested time in milliseconds
-	 * to keep LED on between cycles.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint16_t	led3_blink_on;
+	uint16_t	seq_id;
 	/*
-	 * If the LED #3 state is "blink" or "blinkalt", then
-	 * this field represents the requested time in milliseconds
-	 * to keep LED off between cycles.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint16_t	led3_blink_off;
+	uint16_t	target_id;
 	/*
-	 * An identifier for the group of LEDs that LED #3 belongs
-	 * to.
-	 * If set to 0, then the LED #3 shall not be grouped and
-	 * shall be treated as an individual resource.
-	 * For all other non-zero values of this field, LED #3 shall
-	 * be grouped together with the LEDs with the same group ID
-	 * value.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint8_t	led3_group_id;
-	/* Reserved field. */
-	uint8_t	rsvd3;
-} hwrm_port_led_cfg_input_t, *phwrm_port_led_cfg_input_t;
+	uint64_t	resp_addr;
+	uint16_t	flags;
+	/* Enumeration denoting the RX, TX type of the resource. */
+	#define HWRM_CFA_COUNTER_QSTATS_INPUT_FLAGS_PATH	UINT32_C(0x1)
+	/* Tx path. */
+		#define HWRM_CFA_COUNTER_QSTATS_INPUT_FLAGS_PATH_TX	UINT32_C(0x0)
+	/* Rx path. */
+		#define HWRM_CFA_COUNTER_QSTATS_INPUT_FLAGS_PATH_RX	UINT32_C(0x1)
+		#define HWRM_CFA_COUNTER_QSTATS_INPUT_FLAGS_PATH_LAST HWRM_CFA_COUNTER_QSTATS_INPUT_FLAGS_PATH_RX
+	uint16_t	counter_type;
+	uint16_t	input_flow_ctx_id;
+	uint16_t	num_entries;
+	uint16_t	delta_time_ms;
+	uint16_t	meter_instance_id;
+	uint16_t	mdc_ctx_id;
+	uint8_t	unused_0[2];
+	uint64_t	expected_count;
+} hwrm_cfa_counter_qstats_input_t, *phwrm_cfa_counter_qstats_input_t;
 
-/* hwrm_port_led_cfg_output (size:128b/16B) */
+/* hwrm_cfa_counter_qstats_output (size:128b/16B) */
 
-typedef struct hwrm_port_led_cfg_output {
+typedef struct hwrm_cfa_counter_qstats_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -23363,22 +51606,23 @@ typedef struct hwrm_port_led_cfg_output {
 	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_port_led_cfg_output_t, *phwrm_port_led_cfg_output_t;
+} hwrm_cfa_counter_qstats_output_t, *phwrm_cfa_counter_qstats_output_t;
 
 /**********************
- * hwrm_port_led_qcfg *
+ * hwrm_cfa_eem_qcaps *
  **********************/
 
 
-/* hwrm_port_led_qcfg_input (size:192b/24B) */
+/* hwrm_cfa_eem_qcaps_input (size:192b/24B) */
 
-typedef struct hwrm_port_led_qcfg_input {
+typedef struct hwrm_cfa_eem_qcaps_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -23407,14 +51651,27 @@ typedef struct hwrm_port_led_qcfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Port ID of port whose LED configuration is being queried. */
-	uint16_t	port_id;
-	uint8_t	unused_0[6];
-} hwrm_port_led_qcfg_input_t, *phwrm_port_led_qcfg_input_t;
+	uint32_t	flags;
+	/*
+	 * When set to 1, indicates the configuration will apply to TX flows
+	 * which are to be offloaded.
+	 * Note if this bit is set then the path_rx bit can't be set.
+	 */
+	#define HWRM_CFA_EEM_QCAPS_INPUT_FLAGS_PATH_TX		UINT32_C(0x1)
+	/*
+	 * When set to 1, indicates the configuration will apply to RX flows
+	 * which are to be offloaded.
+	 * Note if this bit is set then the path_tx bit can't be set.
+	 */
+	#define HWRM_CFA_EEM_QCAPS_INPUT_FLAGS_PATH_RX		UINT32_C(0x2)
+	/* When set to 1, all offloaded flows will be sent to EEM. */
+	#define HWRM_CFA_EEM_QCAPS_INPUT_FLAGS_PREFERRED_OFFLOAD	UINT32_C(0x4)
+	uint32_t	unused_0;
+} hwrm_cfa_eem_qcaps_input_t, *phwrm_cfa_eem_qcaps_input_t;
 
-/* hwrm_port_led_qcfg_output (size:448b/56B) */
+/* hwrm_cfa_eem_qcaps_output (size:320b/40B) */
 
-typedef struct hwrm_port_led_qcfg_output {
+typedef struct hwrm_cfa_eem_qcaps_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -23423,258 +51680,205 @@ typedef struct hwrm_port_led_qcfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
+	uint32_t	flags;
 	/*
-	 * The number of LEDs that are configured on this port.
-	 * Up to 4 LEDs can be returned in the response.
+	 * When set to 1, indicates the configuration will apply to TX flows
+	 * which are to be offloaded.
+	 * Note if this bit is set then the path_rx bit can't be set.
 	 */
-	uint8_t	num_leds;
-	/* An identifier for the LED #0. */
-	uint8_t	led0_id;
-	/* The type of LED #0. */
-	uint8_t	led0_type;
-	/* Speed LED */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED0_TYPE_SPEED	UINT32_C(0x0)
-	/* Activity LED */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED0_TYPE_ACTIVITY UINT32_C(0x1)
-	/* Invalid */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED0_TYPE_INVALID  UINT32_C(0xff)
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED0_TYPE_LAST	HWRM_PORT_LED_QCFG_OUTPUT_LED0_TYPE_INVALID
-	/* The current state of the LED #0. */
-	uint8_t	led0_state;
-	/* Default state of the LED */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED0_STATE_DEFAULT  UINT32_C(0x0)
-	/* Off */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED0_STATE_OFF	UINT32_C(0x1)
-	/* On */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED0_STATE_ON	UINT32_C(0x2)
-	/* Blink */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED0_STATE_BLINK	UINT32_C(0x3)
-	/* Blink Alternately */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED0_STATE_BLINKALT UINT32_C(0x4)
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED0_STATE_LAST	HWRM_PORT_LED_QCFG_OUTPUT_LED0_STATE_BLINKALT
-	/* The color of LED #0. */
-	uint8_t	led0_color;
-	/* Default */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED0_COLOR_DEFAULT	UINT32_C(0x0)
-	/* Amber */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED0_COLOR_AMBER	UINT32_C(0x1)
-	/* Green */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED0_COLOR_GREEN	UINT32_C(0x2)
-	/* Green or Amber */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED0_COLOR_GREENAMBER UINT32_C(0x3)
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED0_COLOR_LAST	HWRM_PORT_LED_QCFG_OUTPUT_LED0_COLOR_GREENAMBER
-	uint8_t	unused_0;
+	#define HWRM_CFA_EEM_QCAPS_OUTPUT_FLAGS_PATH_TX					UINT32_C(0x1)
 	/*
-	 * If the LED #0 state is "blink" or "blinkalt", then
-	 * this field represents the requested time in milliseconds
-	 * to keep LED on between cycles.
+	 * When set to 1, indicates the configuration will apply to RX flows
+	 * which are to be offloaded.
+	 * Note if this bit is set then the path_tx bit can't be set.
 	 */
-	uint16_t	led0_blink_on;
+	#define HWRM_CFA_EEM_QCAPS_OUTPUT_FLAGS_PATH_RX					UINT32_C(0x2)
 	/*
-	 * If the LED #0 state is "blink" or "blinkalt", then
-	 * this field represents the requested time in milliseconds
-	 * to keep LED off between cycles.
+	 * When set to 1, indicates the FW supports the Centralized
+	 * Memory Model. The concept designates one entity for the
+	 * memory allocation while all others 'subscribe' to it.
 	 */
-	uint16_t	led0_blink_off;
+	#define HWRM_CFA_EEM_QCAPS_OUTPUT_FLAGS_CENTRALIZED_MEMORY_MODEL_SUPPORTED		UINT32_C(0x4)
 	/*
-	 * An identifier for the group of LEDs that LED #0 belongs
-	 * to.
-	 * If set to 0, then the LED #0 is not grouped.
-	 * For all other non-zero values of this field, LED #0 is
-	 * grouped together with the LEDs with the same group ID
-	 * value.
+	 * When set to 1, indicates the FW supports the Detached
+	 * Centralized Memory Model. The memory is allocated and managed
+	 * as a separate entity. All PFs and VFs will be granted direct
+	 * or semi-direct access to the allocated memory while none of
+	 * which can interfere with the management of the memory.
 	 */
-	uint8_t	led0_group_id;
-	/* An identifier for the LED #1. */
-	uint8_t	led1_id;
-	/* The type of LED #1. */
-	uint8_t	led1_type;
-	/* Speed LED */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED1_TYPE_SPEED	UINT32_C(0x0)
-	/* Activity LED */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED1_TYPE_ACTIVITY UINT32_C(0x1)
-	/* Invalid */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED1_TYPE_INVALID  UINT32_C(0xff)
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED1_TYPE_LAST	HWRM_PORT_LED_QCFG_OUTPUT_LED1_TYPE_INVALID
-	/* The current state of the LED #1. */
-	uint8_t	led1_state;
-	/* Default state of the LED */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED1_STATE_DEFAULT  UINT32_C(0x0)
-	/* Off */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED1_STATE_OFF	UINT32_C(0x1)
-	/* On */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED1_STATE_ON	UINT32_C(0x2)
-	/* Blink */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED1_STATE_BLINK	UINT32_C(0x3)
-	/* Blink Alternately */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED1_STATE_BLINKALT UINT32_C(0x4)
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED1_STATE_LAST	HWRM_PORT_LED_QCFG_OUTPUT_LED1_STATE_BLINKALT
-	/* The color of LED #1. */
-	uint8_t	led1_color;
-	/* Default */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED1_COLOR_DEFAULT	UINT32_C(0x0)
-	/* Amber */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED1_COLOR_AMBER	UINT32_C(0x1)
-	/* Green */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED1_COLOR_GREEN	UINT32_C(0x2)
-	/* Green or Amber */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED1_COLOR_GREENAMBER UINT32_C(0x3)
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED1_COLOR_LAST	HWRM_PORT_LED_QCFG_OUTPUT_LED1_COLOR_GREENAMBER
-	uint8_t	unused_1;
+	#define HWRM_CFA_EEM_QCAPS_OUTPUT_FLAGS_DETACHED_CENTRALIZED_MEMORY_MODEL_SUPPORTED	UINT32_C(0x8)
+	uint32_t	unused_0;
+	uint32_t	supported;
 	/*
-	 * If the LED #1 state is "blink" or "blinkalt", then
-	 * this field represents the requested time in milliseconds
-	 * to keep LED on between cycles.
+	 * If set to 1, then EEM KEY0 table is supported using crc32 hash.
+	 * If set to 0, EEM KEY0 table is not supported.
 	 */
-	uint16_t	led1_blink_on;
+	#define HWRM_CFA_EEM_QCAPS_OUTPUT_SUPPORTED_KEY0_TABLE			UINT32_C(0x1)
 	/*
-	 * If the LED #1 state is "blink" or "blinkalt", then
-	 * this field represents the requested time in milliseconds
-	 * to keep LED off between cycles.
+	 * If set to 1, then EEM KEY1 table is supported using lookup3 hash.
+	 * If set to 0, EEM KEY1 table is not supported.
 	 */
-	uint16_t	led1_blink_off;
+	#define HWRM_CFA_EEM_QCAPS_OUTPUT_SUPPORTED_KEY1_TABLE			UINT32_C(0x2)
 	/*
-	 * An identifier for the group of LEDs that LED #1 belongs
-	 * to.
-	 * If set to 0, then the LED #1 is not grouped.
-	 * For all other non-zero values of this field, LED #1 is
-	 * grouped together with the LEDs with the same group ID
-	 * value.
+	 * If set to 1, then EEM External Record table is supported.
+	 * If set to 0, EEM External Record table is not supported.
+	 * (This table includes action record, EFC pointers, encap pointers)
 	 */
-	uint8_t	led1_group_id;
-	/* An identifier for the LED #2. */
-	uint8_t	led2_id;
-	/* The type of LED #2. */
-	uint8_t	led2_type;
-	/* Speed LED */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED2_TYPE_SPEED	UINT32_C(0x0)
-	/* Activity LED */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED2_TYPE_ACTIVITY UINT32_C(0x1)
-	/* Invalid */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED2_TYPE_INVALID  UINT32_C(0xff)
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED2_TYPE_LAST	HWRM_PORT_LED_QCFG_OUTPUT_LED2_TYPE_INVALID
-	/* The current state of the LED #2. */
-	uint8_t	led2_state;
-	/* Default state of the LED */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED2_STATE_DEFAULT  UINT32_C(0x0)
-	/* Off */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED2_STATE_OFF	UINT32_C(0x1)
-	/* On */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED2_STATE_ON	UINT32_C(0x2)
-	/* Blink */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED2_STATE_BLINK	UINT32_C(0x3)
-	/* Blink Alternately */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED2_STATE_BLINKALT UINT32_C(0x4)
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED2_STATE_LAST	HWRM_PORT_LED_QCFG_OUTPUT_LED2_STATE_BLINKALT
-	/* The color of LED #2. */
-	uint8_t	led2_color;
-	/* Default */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED2_COLOR_DEFAULT	UINT32_C(0x0)
-	/* Amber */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED2_COLOR_AMBER	UINT32_C(0x1)
-	/* Green */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED2_COLOR_GREEN	UINT32_C(0x2)
-	/* Green or Amber */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED2_COLOR_GREENAMBER UINT32_C(0x3)
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED2_COLOR_LAST	HWRM_PORT_LED_QCFG_OUTPUT_LED2_COLOR_GREENAMBER
-	uint8_t	unused_2;
+	#define HWRM_CFA_EEM_QCAPS_OUTPUT_SUPPORTED_EXTERNAL_RECORD_TABLE		UINT32_C(0x4)
 	/*
-	 * If the LED #2 state is "blink" or "blinkalt", then
-	 * this field represents the requested time in milliseconds
-	 * to keep LED on between cycles.
+	 * If set to 1, then EEM External Flow Counters table is supported.
+	 * If set to 0, EEM External Flow Counters table is not supported.
 	 */
-	uint16_t	led2_blink_on;
+	#define HWRM_CFA_EEM_QCAPS_OUTPUT_SUPPORTED_EXTERNAL_FLOW_COUNTERS_TABLE	UINT32_C(0x8)
 	/*
-	 * If the LED #2 state is "blink" or "blinkalt", then
-	 * this field represents the requested time in milliseconds
-	 * to keep LED off between cycles.
+	 * If set to 1, then FID table used for implicit flow flush is
+	 * supported.
+	 * If set to 0, then FID table used for implicit flow flush is
+	 * not supported.
 	 */
-	uint16_t	led2_blink_off;
+	#define HWRM_CFA_EEM_QCAPS_OUTPUT_SUPPORTED_FID_TABLE			UINT32_C(0x10)
+	/*
+	 * The maximum number of entries supported by EEM. When configuring
+	 * the host memory, the number of numbers of entries that can
+	 * supported are:
+	 *	32k, 64k 128k, 256k, 512k, 1M, 2M, 4M, 8M, 32M, 64M, 128M
+	 *	entries.
+	 * Any value that are not these values, the FW will round down to the
+	 * closest support number of entries.
+	 */
+	uint32_t	max_entries_supported;
+	/* The entry size in bytes of each entry in the EEM KEY0/KEY1 tables. */
+	uint16_t	key_entry_size;
+	/* The entry size in bytes of each entry in the EEM RECORD tables. */
+	uint16_t	record_entry_size;
+	/* The entry size in bytes of each entry in the EEM EFC tables. */
+	uint16_t	efc_entry_size;
+	/* The FID size in bytes of each entry in the EEM FID tables. */
+	uint16_t	fid_entry_size;
+	uint8_t	unused_1[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
+	 */
+	uint8_t	valid;
+} hwrm_cfa_eem_qcaps_output_t, *phwrm_cfa_eem_qcaps_output_t;
+
+/********************
+ * hwrm_cfa_eem_cfg *
+ ********************/
+
+
+/* hwrm_cfa_eem_cfg_input (size:384b/48B) */
+
+typedef struct hwrm_cfa_eem_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	uint32_t	flags;
 	/*
-	 * An identifier for the group of LEDs that LED #2 belongs
-	 * to.
-	 * If set to 0, then the LED #2 is not grouped.
-	 * For all other non-zero values of this field, LED #2 is
-	 * grouped together with the LEDs with the same group ID
-	 * value.
+	 * When set to 1, indicates the configuration will apply to TX flows
+	 * which are to be offloaded.
+	 * Note if this bit is set then the path_rx bit can't be set.
 	 */
-	uint8_t	led2_group_id;
-	/* An identifier for the LED #3. */
-	uint8_t	led3_id;
-	/* The type of LED #3. */
-	uint8_t	led3_type;
-	/* Speed LED */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED3_TYPE_SPEED	UINT32_C(0x0)
-	/* Activity LED */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED3_TYPE_ACTIVITY UINT32_C(0x1)
-	/* Invalid */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED3_TYPE_INVALID  UINT32_C(0xff)
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED3_TYPE_LAST	HWRM_PORT_LED_QCFG_OUTPUT_LED3_TYPE_INVALID
-	/* The current state of the LED #3. */
-	uint8_t	led3_state;
-	/* Default state of the LED */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED3_STATE_DEFAULT  UINT32_C(0x0)
-	/* Off */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED3_STATE_OFF	UINT32_C(0x1)
-	/* On */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED3_STATE_ON	UINT32_C(0x2)
-	/* Blink */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED3_STATE_BLINK	UINT32_C(0x3)
-	/* Blink Alternately */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED3_STATE_BLINKALT UINT32_C(0x4)
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED3_STATE_LAST	HWRM_PORT_LED_QCFG_OUTPUT_LED3_STATE_BLINKALT
-	/* The color of LED #3. */
-	uint8_t	led3_color;
-	/* Default */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED3_COLOR_DEFAULT	UINT32_C(0x0)
-	/* Amber */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED3_COLOR_AMBER	UINT32_C(0x1)
-	/* Green */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED3_COLOR_GREEN	UINT32_C(0x2)
-	/* Green or Amber */
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED3_COLOR_GREENAMBER UINT32_C(0x3)
-	#define HWRM_PORT_LED_QCFG_OUTPUT_LED3_COLOR_LAST	HWRM_PORT_LED_QCFG_OUTPUT_LED3_COLOR_GREENAMBER
-	uint8_t	unused_3;
+	#define HWRM_CFA_EEM_CFG_INPUT_FLAGS_PATH_TX		UINT32_C(0x1)
 	/*
-	 * If the LED #3 state is "blink" or "blinkalt", then
-	 * this field represents the requested time in milliseconds
-	 * to keep LED on between cycles.
+	 * When set to 1, indicates the configuration will apply to RX flows
+	 * which are to be offloaded.
+	 * Note if this bit is set then the path_tx bit can't be set.
 	 */
-	uint16_t	led3_blink_on;
+	#define HWRM_CFA_EEM_CFG_INPUT_FLAGS_PATH_RX		UINT32_C(0x2)
+	/* When set to 1, all offloaded flows will be sent to EEM. */
+	#define HWRM_CFA_EEM_CFG_INPUT_FLAGS_PREFERRED_OFFLOAD	UINT32_C(0x4)
+	/* When set to 1, secondary, 0 means primary. */
+	#define HWRM_CFA_EEM_CFG_INPUT_FLAGS_SECONDARY_PF	UINT32_C(0x8)
 	/*
-	 * If the LED #3 state is "blink" or "blinkalt", then
-	 * this field represents the requested time in milliseconds
-	 * to keep LED off between cycles.
+	 * Group_id which used by Firmware to identify memory pools belonging
+	 * to certain group.
 	 */
-	uint16_t	led3_blink_off;
+	uint16_t	group_id;
+	uint16_t	unused_0;
 	/*
-	 * An identifier for the group of LEDs that LED #3 belongs
-	 * to.
-	 * If set to 0, then the LED #3 is not grouped.
-	 * For all other non-zero values of this field, LED #3 is
-	 * grouped together with the LEDs with the same group ID
-	 * value.
+	 * Configured EEM with the given number of entries. All the EEM tables
+	 * KEY0, KEY1, RECORD, EFC all have the same number of entries and all
+	 * tables will be configured using this value. Current minimum value
+	 * is 32k. Current maximum value is 128M.
 	 */
-	uint8_t	led3_group_id;
-	uint8_t	unused_4[6];
+	uint32_t	num_entries;
+	uint32_t	unused_1;
+	/* Configured EEM with the given context if for KEY0 table. */
+	uint16_t	key0_ctx_id;
+	/* Configured EEM with the given context if for KEY1 table. */
+	uint16_t	key1_ctx_id;
+	/* Configured EEM with the given context if for RECORD table. */
+	uint16_t	record_ctx_id;
+	/* Configured EEM with the given context if for EFC table. */
+	uint16_t	efc_ctx_id;
+	/* Configured EEM with the given context if for EFC table. */
+	uint16_t	fid_ctx_id;
+	uint16_t	unused_2;
+	uint32_t	unused_3;
+} hwrm_cfa_eem_cfg_input_t, *phwrm_cfa_eem_cfg_input_t;
+
+/* hwrm_cfa_eem_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_cfa_eem_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_port_led_qcfg_output_t, *phwrm_port_led_qcfg_output_t;
+} hwrm_cfa_eem_cfg_output_t, *phwrm_cfa_eem_cfg_output_t;
 
-/***********************
- * hwrm_port_led_qcaps *
- ***********************/
+/*********************
+ * hwrm_cfa_eem_qcfg *
+ *********************/
 
 
-/* hwrm_port_led_qcaps_input (size:192b/24B) */
+/* hwrm_cfa_eem_qcfg_input (size:192b/24B) */
 
-typedef struct hwrm_port_led_qcaps_input {
+typedef struct hwrm_cfa_eem_qcfg_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -23703,14 +51907,17 @@ typedef struct hwrm_port_led_qcaps_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Port ID of port whose LED configuration is being queried. */
-	uint16_t	port_id;
-	uint8_t	unused_0[6];
-} hwrm_port_led_qcaps_input_t, *phwrm_port_led_qcaps_input_t;
+	uint32_t	flags;
+	/* When set to 1, indicates the configuration is the TX flow. */
+	#define HWRM_CFA_EEM_QCFG_INPUT_FLAGS_PATH_TX	UINT32_C(0x1)
+	/* When set to 1, indicates the configuration is the RX flow. */
+	#define HWRM_CFA_EEM_QCFG_INPUT_FLAGS_PATH_RX	UINT32_C(0x2)
+	uint32_t	unused_0;
+} hwrm_cfa_eem_qcfg_input_t, *phwrm_cfa_eem_qcfg_input_t;
 
-/* hwrm_port_led_qcaps_output (size:384b/48B) */
+/* hwrm_cfa_eem_qcfg_output (size:256b/32B) */
 
-typedef struct hwrm_port_led_qcaps_output {
+typedef struct hwrm_cfa_eem_qcfg_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -23719,280 +51926,342 @@ typedef struct hwrm_port_led_qcaps_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
+	uint32_t	flags;
+	/* When set to 1, indicates the configuration is the TX flow. */
+	#define HWRM_CFA_EEM_QCFG_OUTPUT_FLAGS_PATH_TX		UINT32_C(0x1)
+	/* When set to 1, indicates the configuration is the RX flow. */
+	#define HWRM_CFA_EEM_QCFG_OUTPUT_FLAGS_PATH_RX		UINT32_C(0x2)
+	/* When set to 1, all offloaded flows will be sent to EEM. */
+	#define HWRM_CFA_EEM_QCFG_OUTPUT_FLAGS_PREFERRED_OFFLOAD	UINT32_C(0x4)
+	/* The number of entries the FW has configured for EEM. */
+	uint32_t	num_entries;
+	/* Configured EEM with the given context if for KEY0 table. */
+	uint16_t	key0_ctx_id;
+	/* Configured EEM with the given context if for KEY1 table. */
+	uint16_t	key1_ctx_id;
+	/* Configured EEM with the given context if for RECORD table. */
+	uint16_t	record_ctx_id;
+	/* Configured EEM with the given context if for EFC table. */
+	uint16_t	efc_ctx_id;
+	/* Configured EEM with the given context if for EFC table. */
+	uint16_t	fid_ctx_id;
+	uint8_t	unused_2[5];
 	/*
-	 * The number of LEDs that are configured on this port.
-	 * Up to 4 LEDs can be returned in the response.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	uint8_t	num_leds;
-	/* Reserved for future use. */
-	uint8_t	unused[3];
-	/* An identifier for the LED #0. */
-	uint8_t	led0_id;
-	/* The type of LED #0. */
-	uint8_t	led0_type;
-	/* Speed LED */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED0_TYPE_SPEED	UINT32_C(0x0)
-	/* Activity LED */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED0_TYPE_ACTIVITY UINT32_C(0x1)
-	/* Invalid */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED0_TYPE_INVALID  UINT32_C(0xff)
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED0_TYPE_LAST	HWRM_PORT_LED_QCAPS_OUTPUT_LED0_TYPE_INVALID
+	uint8_t	valid;
+} hwrm_cfa_eem_qcfg_output_t, *phwrm_cfa_eem_qcfg_output_t;
+
+/*******************
+ * hwrm_cfa_eem_op *
+ *******************/
+
+
+/* hwrm_cfa_eem_op_input (size:192b/24B) */
+
+typedef struct hwrm_cfa_eem_op_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * An identifier for the group of LEDs that LED #0 belongs
-	 * to.
-	 * If set to 0, then the LED #0 cannot be grouped.
-	 * For all other non-zero values of this field, LED #0 is
-	 * grouped together with the LEDs with the same group ID
-	 * value.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint8_t	led0_group_id;
-	uint8_t	unused_0;
-	/* The states supported by LED #0. */
-	uint16_t	led0_state_caps;
+	uint16_t	cmpl_ring;
 	/*
-	 * If set to 1, this LED is enabled.
-	 * If set to 0, this LED is disabled.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED0_STATE_CAPS_ENABLED		UINT32_C(0x1)
+	uint16_t	seq_id;
 	/*
-	 * If set to 1, off state is supported on this LED.
-	 * If set to 0, off state is not supported on this LED.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED0_STATE_CAPS_OFF_SUPPORTED	UINT32_C(0x2)
+	uint16_t	target_id;
 	/*
-	 * If set to 1, on state is supported on this LED.
-	 * If set to 0, on state is not supported on this LED.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED0_STATE_CAPS_ON_SUPPORTED		UINT32_C(0x4)
+	uint64_t	resp_addr;
+	uint32_t	flags;
 	/*
-	 * If set to 1, blink state is supported on this LED.
-	 * If set to 0, blink state is not supported on this LED.
+	 * When set to 1, indicates the host memory which is passed will be
+	 * used for the TX flow offload function specified in fid.
+	 * Note if this bit is set then the path_rx bit can't be set.
 	 */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED0_STATE_CAPS_BLINK_SUPPORTED	UINT32_C(0x8)
+	#define HWRM_CFA_EEM_OP_INPUT_FLAGS_PATH_TX	UINT32_C(0x1)
 	/*
-	 * If set to 1, blink_alt state is supported on this LED.
-	 * If set to 0, blink_alt state is not supported on this LED.
+	 * When set to 1, indicates the host memory which is passed will be
+	 * used for the RX flow offload function specified in fid.
+	 * Note if this bit is set then the path_tx bit can't be set.
 	 */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED0_STATE_CAPS_BLINK_ALT_SUPPORTED	UINT32_C(0x10)
-	/* The colors supported by LED #0. */
-	uint16_t	led0_color_caps;
-	/* reserved. */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED0_COLOR_CAPS_RSVD		UINT32_C(0x1)
+	#define HWRM_CFA_EEM_OP_INPUT_FLAGS_PATH_RX	UINT32_C(0x2)
+	uint16_t	unused_0;
+	/* The number of EEM key table entries to be configured. */
+	uint16_t	op;
+	/* This value is reserved and should not be used. */
+	#define HWRM_CFA_EEM_OP_INPUT_OP_RESERVED	UINT32_C(0x0)
 	/*
-	 * If set to 1, Amber color is supported on this LED.
-	 * If set to 0, Amber color is not supported on this LED.
+	 * To properly stop EEM and ensure there are no DMA's, the caller
+	 * must disable EEM for the given PF, using this call. This will
+	 * safely disable EEM and ensure that all DMA'ed to the
+	 * keys/records/efc have been completed.
 	 */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED0_COLOR_CAPS_AMBER_SUPPORTED	UINT32_C(0x2)
+	#define HWRM_CFA_EEM_OP_INPUT_OP_EEM_DISABLE UINT32_C(0x1)
 	/*
-	 * If set to 1, Green color is supported on this LED.
-	 * If set to 0, Green color is not supported on this LED.
+	 * Once the EEM host memory has been configured, EEM options have
+	 * been configured. Then the caller should enable EEM for the given
+	 * PF. Note once this call has been made, then the EEM mechanism
+	 * will be active and DMA's will occur as packets are processed.
 	 */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED0_COLOR_CAPS_GREEN_SUPPORTED	UINT32_C(0x4)
-	/* An identifier for the LED #1. */
-	uint8_t	led1_id;
-	/* The type of LED #1. */
-	uint8_t	led1_type;
-	/* Speed LED */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED1_TYPE_SPEED	UINT32_C(0x0)
-	/* Activity LED */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED1_TYPE_ACTIVITY UINT32_C(0x1)
-	/* Invalid */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED1_TYPE_INVALID  UINT32_C(0xff)
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED1_TYPE_LAST	HWRM_PORT_LED_QCAPS_OUTPUT_LED1_TYPE_INVALID
+	#define HWRM_CFA_EEM_OP_INPUT_OP_EEM_ENABLE  UINT32_C(0x2)
 	/*
-	 * An identifier for the group of LEDs that LED #1 belongs
-	 * to.
-	 * If set to 0, then the LED #0 cannot be grouped.
-	 * For all other non-zero values of this field, LED #0 is
-	 * grouped together with the LEDs with the same group ID
-	 * value.
+	 * Clear EEM settings for the given PF so that the register values
+	 * are reset back to there initial state.
 	 */
-	uint8_t	led1_group_id;
-	uint8_t	unused_1;
-	/* The states supported by LED #1. */
-	uint16_t	led1_state_caps;
+	#define HWRM_CFA_EEM_OP_INPUT_OP_EEM_CLEANUP UINT32_C(0x3)
+	#define HWRM_CFA_EEM_OP_INPUT_OP_LAST	HWRM_CFA_EEM_OP_INPUT_OP_EEM_CLEANUP
+} hwrm_cfa_eem_op_input_t, *phwrm_cfa_eem_op_input_t;
+
+/* hwrm_cfa_eem_op_output (size:128b/16B) */
+
+typedef struct hwrm_cfa_eem_op_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
 	/*
-	 * If set to 1, this LED is enabled.
-	 * If set to 0, this LED is disabled.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED1_STATE_CAPS_ENABLED		UINT32_C(0x1)
+	uint8_t	valid;
+} hwrm_cfa_eem_op_output_t, *phwrm_cfa_eem_op_output_t;
+
+/********************************
+ * hwrm_cfa_adv_flow_mgnt_qcaps *
+ ********************************/
+
+
+/* hwrm_cfa_adv_flow_mgnt_qcaps_input (size:256b/32B) */
+
+typedef struct hwrm_cfa_adv_flow_mgnt_qcaps_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * If set to 1, off state is supported on this LED.
-	 * If set to 0, off state is not supported on this LED.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED1_STATE_CAPS_OFF_SUPPORTED	UINT32_C(0x2)
+	uint16_t	cmpl_ring;
 	/*
-	 * If set to 1, on state is supported on this LED.
-	 * If set to 0, on state is not supported on this LED.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED1_STATE_CAPS_ON_SUPPORTED		UINT32_C(0x4)
+	uint16_t	seq_id;
 	/*
-	 * If set to 1, blink state is supported on this LED.
-	 * If set to 0, blink state is not supported on this LED.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED1_STATE_CAPS_BLINK_SUPPORTED	UINT32_C(0x8)
+	uint16_t	target_id;
 	/*
-	 * If set to 1, blink_alt state is supported on this LED.
-	 * If set to 0, blink_alt state is not supported on this LED.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED1_STATE_CAPS_BLINK_ALT_SUPPORTED	UINT32_C(0x10)
-	/* The colors supported by LED #1. */
-	uint16_t	led1_color_caps;
-	/* reserved. */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED1_COLOR_CAPS_RSVD		UINT32_C(0x1)
+	uint64_t	resp_addr;
+	uint32_t	unused_0[4];
+} hwrm_cfa_adv_flow_mgnt_qcaps_input_t, *phwrm_cfa_adv_flow_mgnt_qcaps_input_t;
+
+/* hwrm_cfa_adv_flow_mgnt_qcaps_output (size:128b/16B) */
+
+typedef struct hwrm_cfa_adv_flow_mgnt_qcaps_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint32_t	flags;
 	/*
-	 * If set to 1, Amber color is supported on this LED.
-	 * If set to 0, Amber color is not supported on this LED.
+	 * Value of 1 to indicate firmware support 16-bit flow handle.
+	 * Value of 0 to indicate firmware not support 16-bit flow handle.
 	 */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED1_COLOR_CAPS_AMBER_SUPPORTED	UINT32_C(0x2)
+	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_FLOW_HND_16BIT_SUPPORTED			UINT32_C(0x1)
 	/*
-	 * If set to 1, Green color is supported on this LED.
-	 * If set to 0, Green color is not supported on this LED.
+	 * Value of 1 to indicate firmware support 64-bit flow handle.
+	 * Value of 0 to indicate firmware not support 64-bit flow handle.
 	 */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED1_COLOR_CAPS_GREEN_SUPPORTED	UINT32_C(0x4)
-	/* An identifier for the LED #2. */
-	uint8_t	led2_id;
-	/* The type of LED #2. */
-	uint8_t	led2_type;
-	/* Speed LED */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED2_TYPE_SPEED	UINT32_C(0x0)
-	/* Activity LED */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED2_TYPE_ACTIVITY UINT32_C(0x1)
-	/* Invalid */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED2_TYPE_INVALID  UINT32_C(0xff)
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED2_TYPE_LAST	HWRM_PORT_LED_QCAPS_OUTPUT_LED2_TYPE_INVALID
+	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_FLOW_HND_64BIT_SUPPORTED			UINT32_C(0x2)
 	/*
-	 * An identifier for the group of LEDs that LED #0 belongs
-	 * to.
-	 * If set to 0, then the LED #0 cannot be grouped.
-	 * For all other non-zero values of this field, LED #0 is
-	 * grouped together with the LEDs with the same group ID
-	 * value.
+	 * Value of 1 to indicate firmware support flow batch delete
+	 * operation through HWRM_CFA_FLOW_FLUSH command.
+	 * Value of 0 to indicate that the firmware does not support flow
+	 * batch delete operation. (deprecated)
 	 */
-	uint8_t	led2_group_id;
-	uint8_t	unused_2;
-	/* The states supported by LED #2. */
-	uint16_t	led2_state_caps;
+	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_FLOW_BATCH_DELETE_SUPPORTED		UINT32_C(0x4)
 	/*
-	 * If set to 1, this LED is enabled.
-	 * If set to 0, this LED is disabled.
+	 * Value of 1 to indicate that the firmware support flow reset all
+	 * operation through HWRM_CFA_FLOW_FLUSH command.
+	 * Value of 0 indicates firmware does not support flow reset all
+	 * operation. (deprecated)
 	 */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED2_STATE_CAPS_ENABLED		UINT32_C(0x1)
+	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_FLOW_RESET_ALL_SUPPORTED			UINT32_C(0x8)
 	/*
-	 * If set to 1, off state is supported on this LED.
-	 * If set to 0, off state is not supported on this LED.
+	 * Value of 1 to indicate that firmware supports use of FID as
+	 * dest_id in HWRM_CFA_NTUPLE_ALLOC/CFG commands.
+	 * Value of 0 indicates firmware does not support use of FID as
+	 * dest_id.
 	 */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED2_STATE_CAPS_OFF_SUPPORTED	UINT32_C(0x2)
+	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_NTUPLE_FLOW_DEST_FUNC_SUPPORTED		UINT32_C(0x10)
 	/*
-	 * If set to 1, on state is supported on this LED.
-	 * If set to 0, on state is not supported on this LED.
+	 * Value of 1 to indicate that firmware supports TX EEM flows.
+	 * Value of 0 indicates firmware does not support TX EEM flows.
+	 * (deprecated)
 	 */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED2_STATE_CAPS_ON_SUPPORTED		UINT32_C(0x4)
+	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_TX_EEM_FLOW_SUPPORTED			UINT32_C(0x20)
 	/*
-	 * If set to 1, blink state is supported on this LED.
-	 * If set to 0, blink state is not supported on this LED.
+	 * Value of 1 to indicate that firmware supports RX EEM flows.
+	 * Value of 0 indicates firmware does not support RX EEM flows.
+	 * (deprecated)
 	 */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED2_STATE_CAPS_BLINK_SUPPORTED	UINT32_C(0x8)
+	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_RX_EEM_FLOW_SUPPORTED			UINT32_C(0x40)
 	/*
-	 * If set to 1, blink_alt state is supported on this LED.
-	 * If set to 0, blink_alt state is not supported on this LED.
+	 * Value of 1 to indicate that firmware supports the dynamic
+	 * allocation of an on-chip flow counter which can be used for EEM
+	 * flows. Value of 0 indicates firmware does not support the dynamic
+	 * allocation of an on-chip flow counter.
+	 * (deprecated)
 	 */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED2_STATE_CAPS_BLINK_ALT_SUPPORTED	UINT32_C(0x10)
-	/* The colors supported by LED #2. */
-	uint16_t	led2_color_caps;
-	/* reserved. */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED2_COLOR_CAPS_RSVD		UINT32_C(0x1)
+	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_FLOW_COUNTER_ALLOC_SUPPORTED		UINT32_C(0x80)
 	/*
-	 * If set to 1, Amber color is supported on this LED.
-	 * If set to 0, Amber color is not supported on this LED.
+	 * Value of 1 to indicate that firmware supports setting of
+	 * rfs_ring_tbl_idx in HWRM_CFA_NTUPLE_ALLOC command.
+	 * Value of 0 indicates firmware does not support rfs_ring_tbl_idx.
 	 */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED2_COLOR_CAPS_AMBER_SUPPORTED	UINT32_C(0x2)
+	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_RFS_RING_TBL_IDX_SUPPORTED		UINT32_C(0x100)
 	/*
-	 * If set to 1, Green color is supported on this LED.
-	 * If set to 0, Green color is not supported on this LED.
+	 * Value of 1 to indicate that firmware supports untagged matching
+	 * criteria on HWRM_CFA_L2_FILTER_ALLOC command. Value of 0
+	 * indicates firmware does not support untagged matching.
 	 */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED2_COLOR_CAPS_GREEN_SUPPORTED	UINT32_C(0x4)
-	/* An identifier for the LED #3. */
-	uint8_t	led3_id;
-	/* The type of LED #3. */
-	uint8_t	led3_type;
-	/* Speed LED */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED3_TYPE_SPEED	UINT32_C(0x0)
-	/* Activity LED */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED3_TYPE_ACTIVITY UINT32_C(0x1)
-	/* Invalid */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED3_TYPE_INVALID  UINT32_C(0xff)
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED3_TYPE_LAST	HWRM_PORT_LED_QCAPS_OUTPUT_LED3_TYPE_INVALID
+	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_UNTAGGED_VLAN_SUPPORTED			UINT32_C(0x200)
 	/*
-	 * An identifier for the group of LEDs that LED #3 belongs
-	 * to.
-	 * If set to 0, then the LED #0 cannot be grouped.
-	 * For all other non-zero values of this field, LED #0 is
-	 * grouped together with the LEDs with the same group ID
-	 * value.
+	 * Value of 1 to indicate that firmware supports XDP filter. Value
+	 * of 0 indicates firmware does not support XDP filter.
+	 */
+	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_XDP_SUPPORTED				UINT32_C(0x400)
+	/*
+	 * Value of 1 to indicate that the firmware support L2 header source
+	 * fields matching criteria on HWRM_CFA_L2_FILTER_ALLOC command.
+	 * Value of 0 indicates firmware does not support L2 header source
+	 * fields matching.
+	 */
+	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_L2_HEADER_SOURCE_FIELDS_SUPPORTED		UINT32_C(0x800)
+	/*
+	 * If set to 1, firmware is capable of supporting ARP ethertype as
+	 * matching criteria for HWRM_CFA_NTUPLE_FILTER_ALLOC command on the
+	 * RX direction. By default, this flag should be 0 for older version
+	 * of firmware.
+	 */
+	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_NTUPLE_FLOW_RX_ARP_SUPPORTED		UINT32_C(0x1000)
+	/*
+	 * Value of 1 to indicate that firmware supports setting of
+	 * rfs_ring_tbl_idx in dst_id field of the HWRM_CFA_NTUPLE_ALLOC
+	 * command. Value of 0 indicates firmware does not support
+	 * rfs_ring_tbl_idx in dst_id field.
 	 */
-	uint8_t	led3_group_id;
-	uint8_t	unused_3;
-	/* The states supported by LED #3. */
-	uint16_t	led3_state_caps;
+	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_RFS_RING_TBL_IDX_V2_SUPPORTED		UINT32_C(0x2000)
 	/*
-	 * If set to 1, this LED is enabled.
-	 * If set to 0, this LED is disabled.
+	 * If set to 1, firmware is capable of supporting IPv4/IPv6 as
+	 * ethertype in HWRM_CFA_NTUPLE_FILTER_ALLOC command on the RX
+	 * direction. By default, this flag should be 0 for older version
+	 * of firmware.
 	 */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED3_STATE_CAPS_ENABLED		UINT32_C(0x1)
+	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_NTUPLE_FLOW_RX_ETHERTYPE_IP_SUPPORTED	UINT32_C(0x4000)
 	/*
-	 * If set to 1, off state is supported on this LED.
-	 * If set to 0, off state is not supported on this LED.
+	 * When this bit is '1', it indicates that core firmware is
+	 * capable of TruFlow. Driver can restrict sending HWRM CFA_FLOW_XXX
+	 * and CFA_ENCAP_XXX, CFA_DECAP_XXX commands.
 	 */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED3_STATE_CAPS_OFF_SUPPORTED	UINT32_C(0x2)
+	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_TRUFLOW_CAPABLE				UINT32_C(0x8000)
 	/*
-	 * If set to 1, on state is supported on this LED.
-	 * If set to 0, on state is not supported on this LED.
+	 * If set to 1, firmware is capable of supporting L2/ROCE as
+	 * traffic type in flags field of HWRM_CFA_L2_FILTER_ALLOC command.
+	 * By default, this flag should be 0 for older version of firmware.
 	 */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED3_STATE_CAPS_ON_SUPPORTED		UINT32_C(0x4)
+	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_L2_FILTER_TRAFFIC_TYPE_L2_ROCE_SUPPORTED	UINT32_C(0x10000)
 	/*
-	 * If set to 1, blink state is supported on this LED.
-	 * If set to 0, blink state is not supported on this LED.
+	 * If set to 1, firmware is capable of HW LAG. This bit is only
+	 * advertised if the calling function is a PAXC function.
 	 */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED3_STATE_CAPS_BLINK_SUPPORTED	UINT32_C(0x8)
+	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_LAG_SUPPORTED				UINT32_C(0x20000)
 	/*
-	 * If set to 1, blink_alt state is supported on this LED.
-	 * If set to 0, blink_alt state is not supported on this LED.
+	 * If set to 1, firmware is capable installing ntuple rules without
+	 * additional classification on the L2 Context.
 	 */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED3_STATE_CAPS_BLINK_ALT_SUPPORTED	UINT32_C(0x10)
-	/* The colors supported by LED #3. */
-	uint16_t	led3_color_caps;
-	/* reserved. */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED3_COLOR_CAPS_RSVD		UINT32_C(0x1)
+	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_NTUPLE_FLOW_NO_L2CTX_SUPPORTED		UINT32_C(0x40000)
 	/*
-	 * If set to 1, Amber color is supported on this LED.
-	 * If set to 0, Amber color is not supported on this LED.
+	 * If set to 1, firmware is capable returning stats for nic flows
+	 * in cfa_flow_stats command where flow_handle value 0xF000.
 	 */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED3_COLOR_CAPS_AMBER_SUPPORTED	UINT32_C(0x2)
+	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_NIC_FLOW_STATS_SUPPORTED			UINT32_C(0x80000)
 	/*
-	 * If set to 1, Green color is supported on this LED.
-	 * If set to 0, Green color is not supported on this LED.
+	 * If set to 1, firmware is capable of supporting these additional
+	 * ip_protocols: ICMP, ICMPV6, RSVD for ntuple rules. By default,
+	 * this flag should be 0 for older version of firmware.
 	 */
-	#define HWRM_PORT_LED_QCAPS_OUTPUT_LED3_COLOR_CAPS_GREEN_SUPPORTED	UINT32_C(0x4)
-	uint8_t	unused_4[3];
+	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_NTUPLE_FLOW_RX_EXT_IP_PROTO_SUPPORTED	UINT32_C(0x100000)
+	/*
+	 * Value of 1 to indicate that firmware supports setting of
+	 * rfs_ring_tbl_idx (new offset) in HWRM_CFA_NTUPLE_ALLOC command.
+	 * Value of 0 indicates ring tbl idx should be passed using dst_id.
+	 */
+	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_RFS_RING_TBL_IDX_V3_SUPPORTED		UINT32_C(0x200000)
+	uint8_t	unused_0[3];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_port_led_qcaps_output_t, *phwrm_port_led_qcaps_output_t;
+} hwrm_cfa_adv_flow_mgnt_qcaps_output_t, *phwrm_cfa_adv_flow_mgnt_qcaps_output_t;
 
-/***********************
- * hwrm_port_prbs_test *
- ***********************/
+/******************
+ * hwrm_cfa_tflib *
+ ******************/
 
 
-/* hwrm_port_prbs_test_input (size:384b/48B) */
+/* hwrm_cfa_tflib_input (size:1024b/128B) */
 
-typedef struct hwrm_port_prbs_test_input {
+typedef struct hwrm_cfa_tflib_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -24021,77 +52290,19 @@ typedef struct hwrm_port_prbs_test_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Host address data is to DMA'd to. */
-	uint64_t	resp_data_addr;
-	/*
-	 * Size of the buffer pointed to by resp_data_addr. The firmware may
-	 * use this entire buffer or less than the entire buffer, but never more.
-	 */
-	uint16_t	data_len;
-	uint16_t	unused_0;
-	uint32_t	unused_1;
-	/* Port ID of port where PRBS test to be run. */
-	uint16_t	port_id;
-	/* Polynomial selection for PRBS test. */
-	uint16_t	poly;
-	/* PRBS7 */
-	#define HWRM_PORT_PRBS_TEST_INPUT_POLY_PRBS7   UINT32_C(0x0)
-	/* PRBS9 */
-	#define HWRM_PORT_PRBS_TEST_INPUT_POLY_PRBS9   UINT32_C(0x1)
-	/* PRBS11 */
-	#define HWRM_PORT_PRBS_TEST_INPUT_POLY_PRBS11  UINT32_C(0x2)
-	/* PRBS15 */
-	#define HWRM_PORT_PRBS_TEST_INPUT_POLY_PRBS15  UINT32_C(0x3)
-	/* PRBS23 */
-	#define HWRM_PORT_PRBS_TEST_INPUT_POLY_PRBS23  UINT32_C(0x4)
-	/* PRBS31 */
-	#define HWRM_PORT_PRBS_TEST_INPUT_POLY_PRBS31  UINT32_C(0x5)
-	/* PRBS58 */
-	#define HWRM_PORT_PRBS_TEST_INPUT_POLY_PRBS58  UINT32_C(0x6)
-	/* Invalid */
-	#define HWRM_PORT_PRBS_TEST_INPUT_POLY_INVALID UINT32_C(0xff)
-	#define HWRM_PORT_PRBS_TEST_INPUT_POLY_LAST   HWRM_PORT_PRBS_TEST_INPUT_POLY_INVALID
-	/*
-	 * Configuration bits for PRBS test.
-	 * Use enable bit to start/stop test.
-	 * Use tx/rx lane map bits to run test on specific lanes,
-	 * if set to 0 test will be run on all lanes.
-	 */
-	uint16_t	prbs_config;
-	/*
-	 * Set 0 to stop test currently in progress
-	 * Set 1 to start test with configuration provided.
-	 */
-	#define HWRM_PORT_PRBS_TEST_INPUT_PRBS_CONFIG_START_STOP		UINT32_C(0x1)
-	/*
-	 * If set to 1, tx_lane_map bitmap should have lane bits set.
-	 * If set to 0, test will be run on all lanes for this port.
-	 */
-	#define HWRM_PORT_PRBS_TEST_INPUT_PRBS_CONFIG_TX_LANE_MAP_VALID	UINT32_C(0x2)
-	/*
-	 * If set to 1, rx_lane_map bitmap should have lane bits set.
-	 * If set to 0, test will be run on all lanes for this port.
-	 */
-	#define HWRM_PORT_PRBS_TEST_INPUT_PRBS_CONFIG_RX_LANE_MAP_VALID	UINT32_C(0x4)
-	/* Duration in seconds to run the PRBS test. */
-	uint16_t	timeout;
-	/*
-	 * If tx_lane_map_valid is set to 1, this field is a bitmap
-	 * of tx lanes to run PRBS test. bit0 = lane0,
-	 * bit1 = lane1 ..bit31 = lane31
-	 */
-	uint32_t	tx_lane_map;
-	/*
-	 * If rx_lane_map_valid is set to 1, this field is a bitmap
-	 * of rx lanes to run PRBS test. bit0 = lane0,
-	 * bit1 = lane1 ..bit31 = lane31
-	 */
-	uint32_t	rx_lane_map;
-} hwrm_port_prbs_test_input_t, *phwrm_port_prbs_test_input_t;
+	/* TFLIB message type. */
+	uint16_t	tf_type;
+	/* TFLIB message subtype. */
+	uint16_t	tf_subtype;
+	/* unused. */
+	uint8_t	unused0[4];
+	/* TFLIB request data. */
+	uint32_t	tf_req[26];
+} hwrm_cfa_tflib_input_t, *phwrm_cfa_tflib_input_t;
 
-/* hwrm_port_prbs_test_output (size:128b/16B) */
+/* hwrm_cfa_tflib_output (size:5632b/704B) */
 
-typedef struct hwrm_port_prbs_test_output {
+typedef struct hwrm_cfa_tflib_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -24100,28 +52311,35 @@ typedef struct hwrm_port_prbs_test_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* Total length of stored data. */
-	uint16_t	total_data_len;
-	uint16_t	unused_0;
-	uint8_t	unused_1[3];
+	/* TFLIB message type. */
+	uint16_t	tf_type;
+	/* TFLIB message subtype. */
+	uint16_t	tf_subtype;
+	/* TFLIB response code */
+	uint32_t	tf_resp_code;
+	/* TFLIB response data. */
+	uint32_t	tf_resp[170];
+	/* unused. */
+	uint8_t	unused1[7];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_port_prbs_test_output_t, *phwrm_port_prbs_test_output_t;
+} hwrm_cfa_tflib_output_t, *phwrm_cfa_tflib_output_t;
 
-/**********************
- * hwrm_port_dsc_dump *
- **********************/
+/**********************************
+ * hwrm_cfa_lag_group_member_rgtr *
+ **********************************/
 
 
-/* hwrm_port_dsc_dump_input (size:320b/40B) */
+/* hwrm_cfa_lag_group_member_rgtr_input (size:192b/24B) */
 
-typedef struct hwrm_port_dsc_dump_input {
+typedef struct hwrm_cfa_lag_group_member_rgtr_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -24150,67 +52368,39 @@ typedef struct hwrm_port_dsc_dump_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Host address where response diagnostic data is returned. */
-	uint64_t	resp_data_addr;
-	/*
-	 * Size of the buffer pointed to by resp_data_addr. The firmware
-	 * may use this entire buffer or less than the entire buffer, but
-	 * never more.
-	 */
-	uint16_t	data_len;
-	uint16_t	unused_0;
-	uint32_t	unused_1;
-	/* Port ID of port where dsc dump to be collected. */
-	uint16_t	port_id;
-	/* Diag level specified by the user */
-	uint16_t	diag_level;
-	/* SRDS_DIAG_LANE */
-	#define HWRM_PORT_DSC_DUMP_INPUT_DIAG_LEVEL_SRDS_DIAG_LANE	UINT32_C(0x0)
-	/* SRDS_DIAG_CORE */
-	#define HWRM_PORT_DSC_DUMP_INPUT_DIAG_LEVEL_SRDS_DIAG_CORE	UINT32_C(0x1)
-	/* SRDS_DIAG_EVENT */
-	#define HWRM_PORT_DSC_DUMP_INPUT_DIAG_LEVEL_SRDS_DIAG_EVENT	UINT32_C(0x2)
-	/* SRDS_DIAG_EYE */
-	#define HWRM_PORT_DSC_DUMP_INPUT_DIAG_LEVEL_SRDS_DIAG_EYE	UINT32_C(0x3)
-	/* SRDS_DIAG_REG_CORE */
-	#define HWRM_PORT_DSC_DUMP_INPUT_DIAG_LEVEL_SRDS_DIAG_REG_CORE   UINT32_C(0x4)
-	/* SRDS_DIAG_REG_LANE */
-	#define HWRM_PORT_DSC_DUMP_INPUT_DIAG_LEVEL_SRDS_DIAG_REG_LANE   UINT32_C(0x5)
-	/* SRDS_DIAG_UC_CORE */
-	#define HWRM_PORT_DSC_DUMP_INPUT_DIAG_LEVEL_SRDS_DIAG_UC_CORE	UINT32_C(0x6)
-	/* SRDS_DIAG_UC_LANE */
-	#define HWRM_PORT_DSC_DUMP_INPUT_DIAG_LEVEL_SRDS_DIAG_UC_LANE	UINT32_C(0x7)
-	/* SRDS_DIAG_LANE_DEBUG */
-	#define HWRM_PORT_DSC_DUMP_INPUT_DIAG_LEVEL_SRDS_DIAG_LANE_DEBUG UINT32_C(0x8)
-	/* SRDS_DIAG_BER_VERT */
-	#define HWRM_PORT_DSC_DUMP_INPUT_DIAG_LEVEL_SRDS_DIAG_BER_VERT   UINT32_C(0x9)
-	/* SRDS_DIAG_BER_HORZ */
-	#define HWRM_PORT_DSC_DUMP_INPUT_DIAG_LEVEL_SRDS_DIAG_BER_HORZ   UINT32_C(0xa)
-	/* SRDS_DIAG_EVENT_SAFE */
-	#define HWRM_PORT_DSC_DUMP_INPUT_DIAG_LEVEL_SRDS_DIAG_EVENT_SAFE UINT32_C(0xb)
-	/* SRDS_DIAG_TIMESTAMP */
-	#define HWRM_PORT_DSC_DUMP_INPUT_DIAG_LEVEL_SRDS_DIAG_TIMESTAMP  UINT32_C(0xc)
-	#define HWRM_PORT_DSC_DUMP_INPUT_DIAG_LEVEL_LAST		HWRM_PORT_DSC_DUMP_INPUT_DIAG_LEVEL_SRDS_DIAG_TIMESTAMP
+	uint8_t	mode;
 	/*
-	 * This field is a lane number
-	 * on which to collect the dsc dump
+	 * Transmit only on the active port. Automatically failover
+	 * to backup port.
 	 */
-	uint16_t	lane_number;
+	#define HWRM_CFA_LAG_GROUP_MEMBER_RGTR_INPUT_MODE_ACTIVE_BACKUP UINT32_C(0x1)
 	/*
-	 * Configuration bits.
-	 * Use enable bit to start dsc dump or retrieve dump
+	 * Transmit based on packet header ntuple hash. Packet with only
+	 * layer 2 headers will hash using the destination MAC, source MAC
+	 * and Ethertype fields. Packets with layer 3 (IP) headers will
+	 * hash using the destination MAC, source MAC, IP protocol/next
+	 * header, source IP address and destination IP address. Packets
+	 * with layer 4 (TCP/UDP) headers will hash using the destination
+	 * MAC, source MAC, IP protocol/next header, source IP address,
+	 * destination IP address, source port and destination port fields.
 	 */
-	uint16_t	dsc_dump_config;
+	#define HWRM_CFA_LAG_GROUP_MEMBER_RGTR_INPUT_MODE_BALANCE_XOR   UINT32_C(0x2)
+	/* Transmit packets on all specified ports. */
+	#define HWRM_CFA_LAG_GROUP_MEMBER_RGTR_INPUT_MODE_BROADCAST	UINT32_C(0x3)
+	#define HWRM_CFA_LAG_GROUP_MEMBER_RGTR_INPUT_MODE_LAST	HWRM_CFA_LAG_GROUP_MEMBER_RGTR_INPUT_MODE_BROADCAST
 	/*
-	 * Set 0 to retrieve the dsc dump
-	 * Set 1 to start the dsc dump
+	 * Supports up to 5 ports. bit0 = port 0, bit1 = port 1,
+	 * bit2 = port 2, bit3 = port 4, bit4 = loopback port
 	 */
-	#define HWRM_PORT_DSC_DUMP_INPUT_DSC_DUMP_CONFIG_START_RETRIEVE	UINT32_C(0x1)
-} hwrm_port_dsc_dump_input_t, *phwrm_port_dsc_dump_input_t;
+	uint8_t	port_bitmap;
+	/* Specify the active port when active-backup mode is specified */
+	uint8_t	active_port;
+	uint8_t	unused_0[5];
+} hwrm_cfa_lag_group_member_rgtr_input_t, *phwrm_cfa_lag_group_member_rgtr_input_t;
 
-/* hwrm_port_dsc_dump_output (size:128b/16B) */
+/* hwrm_cfa_lag_group_member_rgtr_output (size:128b/16B) */
 
-typedef struct hwrm_port_dsc_dump_output {
+typedef struct hwrm_cfa_lag_group_member_rgtr_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -24219,28 +52409,28 @@ typedef struct hwrm_port_dsc_dump_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* Total length of stored data. */
-	uint16_t	total_data_len;
-	uint16_t	unused_0;
-	uint8_t	unused_1[3];
+	/* lag group ID configured for the function */
+	uint16_t	lag_id;
+	uint8_t	unused_0[5];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_port_dsc_dump_output_t, *phwrm_port_dsc_dump_output_t;
+} hwrm_cfa_lag_group_member_rgtr_output_t, *phwrm_cfa_lag_group_member_rgtr_output_t;
 
-/******************************
- * hwrm_port_sfp_sideband_cfg *
- ******************************/
+/************************************
+ * hwrm_cfa_lag_group_member_unrgtr *
+ ************************************/
 
 
-/* hwrm_port_sfp_sideband_cfg_input (size:256b/32B) */
+/* hwrm_cfa_lag_group_member_unrgtr_input (size:192b/24B) */
 
-typedef struct hwrm_port_sfp_sideband_cfg_input {
+typedef struct hwrm_cfa_lag_group_member_unrgtr_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -24269,80 +52459,14 @@ typedef struct hwrm_port_sfp_sideband_cfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Port ID of port that is to be queried. */
-	uint16_t	port_id;
+	/* lag group ID configured for the function */
+	uint16_t	lag_id;
 	uint8_t	unused_0[6];
-	/*
-	 * This bitfield is used to specify which bits from the 'flags'
-	 * fields are being configured by the caller.
-	 */
-	uint32_t	enables;
-	/* This bit must be '1' for rs0 to be configured. */
-	#define HWRM_PORT_SFP_SIDEBAND_CFG_INPUT_ENABLES_RS0	UINT32_C(0x1)
-	/* This bit must be '1' for rs1 to be configured. */
-	#define HWRM_PORT_SFP_SIDEBAND_CFG_INPUT_ENABLES_RS1	UINT32_C(0x2)
-	/* This bit must be '1' for tx_disable to be configured. */
-	#define HWRM_PORT_SFP_SIDEBAND_CFG_INPUT_ENABLES_TX_DIS	UINT32_C(0x4)
-	/*
-	 * This bit must be '1' for mod_sel to be configured.
-	 * Valid only on QSFP modules
-	 */
-	#define HWRM_PORT_SFP_SIDEBAND_CFG_INPUT_ENABLES_MOD_SEL	UINT32_C(0x8)
-	/* This bit must be '1' for reset_l to be configured. */
-	#define HWRM_PORT_SFP_SIDEBAND_CFG_INPUT_ENABLES_RESET_L	UINT32_C(0x10)
-	/* This bit must be '1' for lp_mode to be configured. */
-	#define HWRM_PORT_SFP_SIDEBAND_CFG_INPUT_ENABLES_LP_MODE	UINT32_C(0x20)
-	/* This bit must be '1' for pwr_disable to be configured. */
-	#define HWRM_PORT_SFP_SIDEBAND_CFG_INPUT_ENABLES_PWR_DIS	UINT32_C(0x40)
-	/*
-	 * Only bits that have corresponding bits in the 'enables'
-	 * bitfield are processed by the firmware, all other bits
-	 * of 'flags' are ignored.
-	 */
-	uint32_t	flags;
-	/*
-	 * This bit along with rs1 configures the current speed of the dual
-	 * rate module. If these pins are GNDed then the speed can be changed
-	 * by driectly writing to EEPROM.
-	 */
-	#define HWRM_PORT_SFP_SIDEBAND_CFG_INPUT_FLAGS_RS0	UINT32_C(0x1)
-	/*
-	 * This bit along with rs0 configures the current speed of the dual
-	 * rate module. If these pins are GNDed then the speed can be changed
-	 * by driectly writing to EEPROM.
-	 */
-	#define HWRM_PORT_SFP_SIDEBAND_CFG_INPUT_FLAGS_RS1	UINT32_C(0x2)
-	/*
-	 * When this bit is set to '1', tx_disable is set.
-	 * On a 1G BASE-T module, if this bit is set,
-	 * module PHY registers will not be accessible.
-	 */
-	#define HWRM_PORT_SFP_SIDEBAND_CFG_INPUT_FLAGS_TX_DIS	UINT32_C(0x4)
-	/*
-	 * When this bit is set to '1', this module is selected.
-	 * Valid only on QSFP modules
-	 */
-	#define HWRM_PORT_SFP_SIDEBAND_CFG_INPUT_FLAGS_MOD_SEL	UINT32_C(0x8)
-	/*
-	 * If reset_l is set to 0, Module will be taken out of reset
-	 * and other signals will be set to their requested state once
-	 * the module is out of reset.
-	 * Valid only on QSFP modules
-	 */
-	#define HWRM_PORT_SFP_SIDEBAND_CFG_INPUT_FLAGS_RESET_L	UINT32_C(0x10)
-	/*
-	 * When this bit is set to '1', the module will be configured
-	 * in low power mode.
-	 * Valid only on QSFP modules
-	 */
-	#define HWRM_PORT_SFP_SIDEBAND_CFG_INPUT_FLAGS_LP_MODE	UINT32_C(0x20)
-	/* When this bit is set to '1', the module will be powered down. */
-	#define HWRM_PORT_SFP_SIDEBAND_CFG_INPUT_FLAGS_PWR_DIS	UINT32_C(0x40)
-} hwrm_port_sfp_sideband_cfg_input_t, *phwrm_port_sfp_sideband_cfg_input_t;
+} hwrm_cfa_lag_group_member_unrgtr_input_t, *phwrm_cfa_lag_group_member_unrgtr_input_t;
 
-/* hwrm_port_sfp_sideband_cfg_output (size:128b/16B) */
+/* hwrm_cfa_lag_group_member_unrgtr_output (size:128b/16B) */
 
-typedef struct hwrm_port_sfp_sideband_cfg_output {
+typedef struct hwrm_cfa_lag_group_member_unrgtr_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -24351,25 +52475,26 @@ typedef struct hwrm_port_sfp_sideband_cfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused[7];
+	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written. When
-	 * writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_port_sfp_sideband_cfg_output_t, *phwrm_port_sfp_sideband_cfg_output_t;
+} hwrm_cfa_lag_group_member_unrgtr_output_t, *phwrm_cfa_lag_group_member_unrgtr_output_t;
 
-/*******************************
- * hwrm_port_sfp_sideband_qcfg *
- *******************************/
+/*****************************
+ * hwrm_cfa_tls_filter_alloc *
+ *****************************/
 
 
-/* hwrm_port_sfp_sideband_qcfg_input (size:192b/24B) */
+/* hwrm_cfa_tls_filter_alloc_input (size:768b/96B) */
 
-typedef struct hwrm_port_sfp_sideband_qcfg_input {
+typedef struct hwrm_cfa_tls_filter_alloc_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -24398,144 +52523,149 @@ typedef struct hwrm_port_sfp_sideband_qcfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Port ID of port that is to be queried. */
-	uint16_t	port_id;
-	uint8_t	unused_0[6];
-} hwrm_port_sfp_sideband_qcfg_input_t, *phwrm_port_sfp_sideband_qcfg_input_t;
-
-/* hwrm_port_sfp_sideband_qcfg_output (size:192b/24B) */
-
-typedef struct hwrm_port_sfp_sideband_qcfg_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
+	uint32_t	unused_0;
+	uint32_t	enables;
 	/*
-	 * Bitmask indicating which sideband signals are valid.
-	 * This is based on the board and nvm cfg that is present on the board.
+	 * This bit must be '1' for the l2_filter_id field to be
+	 * configured.
 	 */
-	uint32_t	supported_mask;
-	uint32_t	sideband_signals;
-	/* When this bit is set to '1', the Module is absent. */
-	#define HWRM_PORT_SFP_SIDEBAND_QCFG_OUTPUT_SIDEBAND_SIGNALS_MOD_ABS	UINT32_C(0x1)
+	#define HWRM_CFA_TLS_FILTER_ALLOC_INPUT_ENABLES_L2_FILTER_ID		UINT32_C(0x1)
 	/*
-	 * When this bit is set to '1', there is no valid signal on RX.
-	 * This signal is a filtered version of Signal Detect.
+	 * This bit must be '1' for the ethertype field to be
+	 * configured.
 	 */
-	#define HWRM_PORT_SFP_SIDEBAND_QCFG_OUTPUT_SIDEBAND_SIGNALS_RX_LOS	UINT32_C(0x2)
+	#define HWRM_CFA_TLS_FILTER_ALLOC_INPUT_ENABLES_ETHERTYPE		UINT32_C(0x2)
 	/*
-	 * This bit along with rs1 indiactes the current speed of the dual
-	 * rate module.If these pins are grounded then the speed can be
-	 * changed by driectky writing to EEPROM.
+	 * This bit must be '1' for the ipaddr_type field to be
+	 * configured.
 	 */
-	#define HWRM_PORT_SFP_SIDEBAND_QCFG_OUTPUT_SIDEBAND_SIGNALS_RS0	UINT32_C(0x4)
+	#define HWRM_CFA_TLS_FILTER_ALLOC_INPUT_ENABLES_IPADDR_TYPE		UINT32_C(0x4)
 	/*
-	 * This bit along with rs0 indiactes the current speed of the dual
-	 * rate module.If these pins are grounded then the speed can be
-	 * changed by driectky writing to EEPROM.
+	 * This bit must be '1' for the src_ipaddr field to be
+	 * configured.
 	 */
-	#define HWRM_PORT_SFP_SIDEBAND_QCFG_OUTPUT_SIDEBAND_SIGNALS_RS1	UINT32_C(0x8)
+	#define HWRM_CFA_TLS_FILTER_ALLOC_INPUT_ENABLES_SRC_IPADDR		UINT32_C(0x8)
 	/*
-	 * When this bit is set to '1', tx_disable is set.
-	 * On a 1G BASE-T module, if this bit is set, module PHY
-	 * registers will not be accessible.
+	 * This bit must be '1' for the dst_ipaddr field to be
+	 * configured.
 	 */
-	#define HWRM_PORT_SFP_SIDEBAND_QCFG_OUTPUT_SIDEBAND_SIGNALS_TX_DIS	UINT32_C(0x10)
-	/* When this bit is set to '1', tx_fault is set. */
-	#define HWRM_PORT_SFP_SIDEBAND_QCFG_OUTPUT_SIDEBAND_SIGNALS_TX_FAULT	UINT32_C(0x20)
+	#define HWRM_CFA_TLS_FILTER_ALLOC_INPUT_ENABLES_DST_IPADDR		UINT32_C(0x10)
 	/*
-	 * When this bit is set to '1', module is selected.
-	 * Valid only on QSFP modules
+	 * This bit must be '1' for the ip_protocol field to be
+	 * configured.
 	 */
-	#define HWRM_PORT_SFP_SIDEBAND_QCFG_OUTPUT_SIDEBAND_SIGNALS_MOD_SEL	UINT32_C(0x40)
+	#define HWRM_CFA_TLS_FILTER_ALLOC_INPUT_ENABLES_IP_PROTOCOL		UINT32_C(0x20)
 	/*
-	 * When this bit is set to '0', the module is held in reset.
-	 * if reset_l is set to 1,first module is taken out of reset
-	 * and other signals will be set to their requested state.
-	 * Valid only on QSFP modules.
+	 * This bit must be '1' for the src_port field to be
+	 * configured.
 	 */
-	#define HWRM_PORT_SFP_SIDEBAND_QCFG_OUTPUT_SIDEBAND_SIGNALS_RESET_L	UINT32_C(0x80)
+	#define HWRM_CFA_TLS_FILTER_ALLOC_INPUT_ENABLES_SRC_PORT		UINT32_C(0x40)
 	/*
-	 * When this bit is set to '1', the module is in low power mode.
-	 * Valid only on QSFP modules
+	 * This bit must be '1' for the dst_port field to be
+	 * configured.
 	 */
-	#define HWRM_PORT_SFP_SIDEBAND_QCFG_OUTPUT_SIDEBAND_SIGNALS_LP_MODE	UINT32_C(0x100)
-	/* When this bit is set to '1', module is in power down state. */
-	#define HWRM_PORT_SFP_SIDEBAND_QCFG_OUTPUT_SIDEBAND_SIGNALS_PWR_DIS	UINT32_C(0x200)
-	uint8_t	unused[7];
+	#define HWRM_CFA_TLS_FILTER_ALLOC_INPUT_ENABLES_DST_PORT		UINT32_C(0x80)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written. When
-	 * writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * This bit must be '1' for the kid field to be
+	 * configured.
 	 */
-	uint8_t	valid;
-} hwrm_port_sfp_sideband_qcfg_output_t, *phwrm_port_sfp_sideband_qcfg_output_t;
-
-/**********************************
- * hwrm_port_phy_mdio_bus_acquire *
- **********************************/
-
-
-/* hwrm_port_phy_mdio_bus_acquire_input (size:192b/24B) */
-
-typedef struct hwrm_port_phy_mdio_bus_acquire_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define HWRM_CFA_TLS_FILTER_ALLOC_INPUT_ENABLES_KID			UINT32_C(0x100)
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * This bit must be '1' for the dst_id field to be
+	 * configured.
 	 */
-	uint16_t	cmpl_ring;
+	#define HWRM_CFA_TLS_FILTER_ALLOC_INPUT_ENABLES_DST_ID		UINT32_C(0x200)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * This bit must be '1' for the mirror_vnic_id field to be
+	 * configured.
 	 */
-	uint16_t	seq_id;
+	#define HWRM_CFA_TLS_FILTER_ALLOC_INPUT_ENABLES_MIRROR_VNIC_ID	UINT32_C(0x400)
+	/*
+	 * This bit must be '1' for the quic_dst_connect_id field to be
+	 * configured.
+	 */
+	#define HWRM_CFA_TLS_FILTER_ALLOC_INPUT_ENABLES_QUIC_DST_CONNECT_ID	UINT32_C(0x800)
+	/*
+	 * This value identifies a set of CFA data structures used for an L2
+	 * context.
+	 */
+	uint64_t	l2_filter_id;
+	uint8_t	unused_1[6];
+	/* This value indicates the ethertype in the Ethernet header. */
+	uint16_t	ethertype;
+	/*
+	 * This value indicates the type of IP address.
+	 * 4 - IPv4
+	 * 6 - IPv6
+	 * All others are invalid.
+	 */
+	uint8_t	ip_addr_type;
+	/* invalid */
+	#define HWRM_CFA_TLS_FILTER_ALLOC_INPUT_IP_ADDR_TYPE_UNKNOWN UINT32_C(0x0)
+	/* IPv4 */
+	#define HWRM_CFA_TLS_FILTER_ALLOC_INPUT_IP_ADDR_TYPE_IPV4	UINT32_C(0x4)
+	/* IPv6 */
+	#define HWRM_CFA_TLS_FILTER_ALLOC_INPUT_IP_ADDR_TYPE_IPV6	UINT32_C(0x6)
+	#define HWRM_CFA_TLS_FILTER_ALLOC_INPUT_IP_ADDR_TYPE_LAST   HWRM_CFA_TLS_FILTER_ALLOC_INPUT_IP_ADDR_TYPE_IPV6
+	/*
+	 * The value of protocol field in IP header.
+	 * Applies to UDP and TCP traffic.
+	 * 6 - TCP
+	 * 17 - UDP
+	 */
+	uint8_t	ip_protocol;
+	/* invalid */
+	#define HWRM_CFA_TLS_FILTER_ALLOC_INPUT_IP_PROTOCOL_UNKNOWN UINT32_C(0x0)
+	/* TCP */
+	#define HWRM_CFA_TLS_FILTER_ALLOC_INPUT_IP_PROTOCOL_TCP	UINT32_C(0x6)
+	/* UDP */
+	#define HWRM_CFA_TLS_FILTER_ALLOC_INPUT_IP_PROTOCOL_UDP	UINT32_C(0x11)
+	#define HWRM_CFA_TLS_FILTER_ALLOC_INPUT_IP_PROTOCOL_LAST   HWRM_CFA_TLS_FILTER_ALLOC_INPUT_IP_PROTOCOL_UDP
+	/*
+	 * If set, this value shall represent the
+	 * Logical VNIC ID of the destination VNIC for the RX
+	 * path and network port id of the destination port for
+	 * the TX path.
+	 */
+	uint16_t	dst_id;
+	/*
+	 * Logical VNIC ID of the VNIC where traffic is
+	 * mirrored.
+	 */
+	uint16_t	mirror_vnic_id;
+	uint8_t	unused_2[2];
+	/*
+	 * The value of source IP address to be used in filtering.
+	 * For IPv4, first four bytes represent the IP address.
+	 */
+	uint32_t	src_ipaddr[4];
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * The value of destination IP address to be used in filtering.
+	 * For IPv4, first four bytes represent the IP address.
 	 */
-	uint16_t	target_id;
+	uint32_t	dst_ipaddr[4];
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * The value of source port to be used in filtering.
+	 * Applies to UDP and TCP traffic.
 	 */
-	uint64_t	resp_addr;
-	/* Port ID of the port. */
-	uint16_t	port_id;
+	uint16_t	src_port;
 	/*
-	 * client_id of the client requesting BUS access.
-	 * Any value from 0x10 to 0xFFFF can be used.
-	 * Client should make sure that the returned client_id
-	 * in response matches the client_id in request.
-	 * 0-0xF are reserved for internal use.
+	 * The value of destination port to be used in filtering.
+	 * Applies to UDP and TCP traffic.
 	 */
-	uint16_t	client_id;
+	uint16_t	dst_port;
 	/*
-	 * Timeout in milli seconds, MDIO BUS will be released automatically
-	 * after this time, if another mdio acquire command is not received
-	 * within the timeout window from the same client.
-	 * A 0xFFFF will hold the bus until this bus is released.
+	 * The Key Context Identifier (KID) for use with KTLS or QUIC.
+	 * KID is limited to 20-bits.
 	 */
-	uint16_t	mdio_bus_timeout;
-	uint8_t	unused_0[2];
-} hwrm_port_phy_mdio_bus_acquire_input_t, *phwrm_port_phy_mdio_bus_acquire_input_t;
+	uint32_t	kid;
+	/* The Destination Connection ID of QUIC. */
+	uint64_t	quic_dst_connect_id;
+} hwrm_cfa_tls_filter_alloc_input_t, *phwrm_cfa_tls_filter_alloc_input_t;
 
-/* hwrm_port_phy_mdio_bus_acquire_output (size:128b/16B) */
+/* hwrm_cfa_tls_filter_alloc_output (size:192b/24B) */
 
-typedef struct hwrm_port_phy_mdio_bus_acquire_output {
+typedef struct hwrm_cfa_tls_filter_alloc_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -24544,31 +52674,59 @@ typedef struct hwrm_port_phy_mdio_bus_acquire_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint16_t	unused_0;
+	/* This value is an opaque id into CFA data structures. */
+	uint64_t	tls_filter_id;
 	/*
-	 * client_id of the module holding the BUS.
-	 * 0-0xF are reserved for internal use.
+	 * The flow id value in bit 0-29 is the actual ID of the flow
+	 * associated with this filter and it shall be used to match
+	 * and associate the flow identifier returned in completion
+	 * records. A value of 0xFFFFFFFF in the 32-bit flow_id field
+	 * shall indicate no valid flow id.
 	 */
-	uint16_t	client_id;
-	uint8_t	unused_1[3];
+	uint32_t	flow_id;
+	/* Indicate the flow id value. */
+	#define HWRM_CFA_TLS_FILTER_ALLOC_OUTPUT_FLOW_ID_VALUE_MASK UINT32_C(0x3fffffff)
+	#define HWRM_CFA_TLS_FILTER_ALLOC_OUTPUT_FLOW_ID_VALUE_SFT 0
+	/* Indicate type of the flow. */
+	#define HWRM_CFA_TLS_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE	UINT32_C(0x40000000)
+	/*
+	 * If this bit set to 0, then it indicates that the flow is
+	 * internal flow.
+	 */
+		#define HWRM_CFA_TLS_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE_INT	(UINT32_C(0x0) << 30)
+	/*
+	 * If this bit is set to 1, then it indicates that the flow is
+	 * external flow.
+	 */
+		#define HWRM_CFA_TLS_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE_EXT	(UINT32_C(0x1) << 30)
+		#define HWRM_CFA_TLS_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE_LAST  HWRM_CFA_TLS_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE_EXT
+	/* Indicate the flow direction. */
+	#define HWRM_CFA_TLS_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR	UINT32_C(0x80000000)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_CFA_TLS_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR_RX	(UINT32_C(0x0) << 31)
+	/* If this bit is set to 1, then it indicates that tx flow. */
+		#define HWRM_CFA_TLS_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR_TX	(UINT32_C(0x1) << 31)
+		#define HWRM_CFA_TLS_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR_LAST   HWRM_CFA_TLS_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR_TX
+	uint8_t	unused_0[3];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_port_phy_mdio_bus_acquire_output_t, *phwrm_port_phy_mdio_bus_acquire_output_t;
+} hwrm_cfa_tls_filter_alloc_output_t, *phwrm_cfa_tls_filter_alloc_output_t;
 
-/**********************************
- * hwrm_port_phy_mdio_bus_release *
- **********************************/
+/****************************
+ * hwrm_cfa_tls_filter_free *
+ ****************************/
 
 
-/* hwrm_port_phy_mdio_bus_release_input (size:192b/24B) */
+/* hwrm_cfa_tls_filter_free_input (size:192b/24B) */
 
-typedef struct hwrm_port_phy_mdio_bus_release_input {
+typedef struct hwrm_cfa_tls_filter_free_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -24597,19 +52755,13 @@ typedef struct hwrm_port_phy_mdio_bus_release_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Port ID of the port. */
-	uint16_t	port_id;
-	/*
-	 * client_id of the client requesting BUS release.
-	 * A client should not release any other clients BUS.
-	 */
-	uint16_t	client_id;
-	uint8_t	unused_0[4];
-} hwrm_port_phy_mdio_bus_release_input_t, *phwrm_port_phy_mdio_bus_release_input_t;
+	/* This value is an opaque id into CFA data structures. */
+	uint64_t	tls_filter_id;
+} hwrm_cfa_tls_filter_free_input_t, *phwrm_cfa_tls_filter_free_input_t;
 
-/* hwrm_port_phy_mdio_bus_release_output (size:128b/16B) */
+/* hwrm_cfa_tls_filter_free_output (size:128b/16B) */
 
-typedef struct hwrm_port_phy_mdio_bus_release_output {
+typedef struct hwrm_cfa_tls_filter_free_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -24618,28 +52770,26 @@ typedef struct hwrm_port_phy_mdio_bus_release_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint16_t	unused_0;
-	/* The BUS is released if client_id matches the client_id in request. */
-	uint16_t	clients_id;
-	uint8_t	unused_1[3];
+	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_port_phy_mdio_bus_release_output_t, *phwrm_port_phy_mdio_bus_release_output_t;
+} hwrm_cfa_tls_filter_free_output_t, *phwrm_cfa_tls_filter_free_output_t;
 
-/************************
- * hwrm_port_tx_fir_cfg *
- ************************/
+/*****************************
+ * hwrm_cfa_release_afm_func *
+ *****************************/
 
 
-/* hwrm_port_tx_fir_cfg_input (size:320b/40B) */
+/* hwrm_cfa_release_afm_func_input (size:256b/32B) */
 
-typedef struct hwrm_port_tx_fir_cfg_input {
+typedef struct hwrm_cfa_release_afm_func_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -24668,30 +52818,37 @@ typedef struct hwrm_port_tx_fir_cfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Modulation types of TX FIR: NRZ, PAM4. */
-	uint8_t	mod_type;
-	/* For NRZ */
-	#define HWRM_PORT_TX_FIR_CFG_INPUT_MOD_TYPE_NRZ  UINT32_C(0x0)
-	/* For PAM4 */
-	#define HWRM_PORT_TX_FIR_CFG_INPUT_MOD_TYPE_PAM4 UINT32_C(0x1)
-	#define HWRM_PORT_TX_FIR_CFG_INPUT_MOD_TYPE_LAST HWRM_PORT_TX_FIR_CFG_INPUT_MOD_TYPE_PAM4
-	/* The lane mask of the lane TX FIR will be configured. */
-	uint8_t	lane_mask;
-	uint8_t	unused_0[2];
-	/* Value1 of TX FIR, required for NRZ or PAM4. */
-	uint32_t	txfir_val_1;
-	/* Value2 of TX FIR, required for NRZ or PAM4. */
-	uint32_t	txfir_val_2;
-	/* Value3 of TX FIR, required for PAM4. */
-	uint32_t	txfir_val_3;
-	/* Value4 of TX FIR, required for PAM4. */
-	uint32_t	txfir_val_4;
-	uint8_t	unused_1[4];
-} hwrm_port_tx_fir_cfg_input_t, *phwrm_port_tx_fir_cfg_input_t;
+	/* Function identifier, may be of type efid, rfid or dfid. */
+	uint16_t	fid;
+	/* Representor function identifier. */
+	uint16_t	rfid;
+	/* Fid type. */
+	uint8_t	type;
+	/* Endpoint fid. */
+	#define HWRM_CFA_RELEASE_AFM_FUNC_INPUT_TYPE_EFID UINT32_C(0x1)
+	/* Representor fid. */
+	#define HWRM_CFA_RELEASE_AFM_FUNC_INPUT_TYPE_RFID UINT32_C(0x2)
+	/* Redirect fid. */
+	#define HWRM_CFA_RELEASE_AFM_FUNC_INPUT_TYPE_DFID UINT32_C(0x3)
+	#define HWRM_CFA_RELEASE_AFM_FUNC_INPUT_TYPE_LAST HWRM_CFA_RELEASE_AFM_FUNC_INPUT_TYPE_DFID
+	uint8_t	unused_0[3];
+	/*
+	 * Flags used to control AFMs actions when releasing the function.
+	 * Only used when type is dfid.
+	 */
+	uint32_t	flags;
+	/* Remove broadcast. */
+	#define HWRM_CFA_RELEASE_AFM_FUNC_INPUT_FLAGS_BC_REM	UINT32_C(0x1)
+	/* Remove multicast. */
+	#define HWRM_CFA_RELEASE_AFM_FUNC_INPUT_FLAGS_MC_REM	UINT32_C(0x2)
+	/* Remove promiscuous. */
+	#define HWRM_CFA_RELEASE_AFM_FUNC_INPUT_FLAGS_PROMISC_REM	UINT32_C(0x4)
+	uint32_t	unused_1;
+} hwrm_cfa_release_afm_func_input_t, *phwrm_cfa_release_afm_func_input_t;
 
-/* hwrm_port_tx_fir_cfg_output (size:128b/16B) */
+/* hwrm_cfa_release_afm_func_output (size:128b/16B) */
 
-typedef struct hwrm_port_tx_fir_cfg_output {
+typedef struct hwrm_cfa_release_afm_func_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -24700,25 +52857,26 @@ typedef struct hwrm_port_tx_fir_cfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused[7];
+	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_port_tx_fir_cfg_output_t, *phwrm_port_tx_fir_cfg_output_t;
+} hwrm_cfa_release_afm_func_output_t, *phwrm_cfa_release_afm_func_output_t;
 
-/*************************
- * hwrm_port_tx_fir_qcfg *
- *************************/
+/***********
+ * hwrm_tf *
+ ***********/
 
 
-/* hwrm_port_tx_fir_qcfg_input (size:192b/24B) */
+/* hwrm_tf_input (size:1024b/128B) */
 
-typedef struct hwrm_port_tx_fir_qcfg_input {
+typedef struct hwrm_tf_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -24747,21 +52905,19 @@ typedef struct hwrm_port_tx_fir_qcfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Modulation types of TX FIR: NRZ, PAM4. */
-	uint8_t	mod_type;
-	/* For NRZ */
-	#define HWRM_PORT_TX_FIR_QCFG_INPUT_MOD_TYPE_NRZ  UINT32_C(0x0)
-	/* For PAM4 */
-	#define HWRM_PORT_TX_FIR_QCFG_INPUT_MOD_TYPE_PAM4 UINT32_C(0x1)
-	#define HWRM_PORT_TX_FIR_QCFG_INPUT_MOD_TYPE_LAST HWRM_PORT_TX_FIR_QCFG_INPUT_MOD_TYPE_PAM4
-	/* The ID of the lane TX FIR will be queried. */
-	uint8_t	lane_id;
-	uint8_t	unused[6];
-} hwrm_port_tx_fir_qcfg_input_t, *phwrm_port_tx_fir_qcfg_input_t;
+	/* TF message type. */
+	uint16_t	type;
+	/* TF message subtype. */
+	uint16_t	subtype;
+	/* unused. */
+	uint8_t	unused0[4];
+	/* TF request data. */
+	uint32_t	req[26];
+} hwrm_tf_input_t, *phwrm_tf_input_t;
 
-/* hwrm_port_tx_fir_qcfg_output (size:256b/32B) */
+/* hwrm_tf_output (size:5632b/704B) */
 
-typedef struct hwrm_port_tx_fir_qcfg_output {
+typedef struct hwrm_tf_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -24770,33 +52926,35 @@ typedef struct hwrm_port_tx_fir_qcfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* Value1 of TX FIR, required for NRZ or PAM4. */
-	uint32_t	txfir_val_1;
-	/* Value2 of TX FIR, required for NRZ or PAM4. */
-	uint32_t	txfir_val_2;
-	/* Value3 of TX FIR, required for PAM4. */
-	uint32_t	txfir_val_3;
-	/* Value4 of TX FIR, required for PAM4. */
-	uint32_t	txfir_val_4;
-	uint8_t	unused[7];
+	/* TF message type. */
+	uint16_t	type;
+	/* TF message subtype. */
+	uint16_t	subtype;
+	/* TF response code */
+	uint32_t	resp_code;
+	/* TF response data. */
+	uint32_t	resp[170];
+	/* unused. */
+	uint8_t	unused1[7];
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * This field is used in Output records to indicate that the
+	 * output is completely written to RAM. This field should be
+	 * read as '1' to indicate that the output has been
+	 * completely written. When writing a command completion or
+	 * response to an internal processor, the order of writes has
+	 * to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_port_tx_fir_qcfg_output_t, *phwrm_port_tx_fir_qcfg_output_t;
+} hwrm_tf_output_t, *phwrm_tf_output_t;
 
 /***********************
- * hwrm_queue_qportcfg *
+ * hwrm_tf_version_get *
  ***********************/
 
 
-/* hwrm_queue_qportcfg_input (size:192b/24B) */
+/* hwrm_tf_version_get_input (size:128b/16B) */
 
-typedef struct hwrm_queue_qportcfg_input {
+typedef struct hwrm_tf_version_get_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -24825,520 +52983,146 @@ typedef struct hwrm_queue_qportcfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	flags;
-	/*
-	 * Enumeration denoting the RX, TX type of the resource.
-	 * This enumeration is used for resources that are similar for both
-	 * TX and RX paths of the chip.
-	 */
-	#define HWRM_QUEUE_QPORTCFG_INPUT_FLAGS_PATH	UINT32_C(0x1)
-	/* tx path */
-		#define HWRM_QUEUE_QPORTCFG_INPUT_FLAGS_PATH_TX	UINT32_C(0x0)
-	/* rx path */
-		#define HWRM_QUEUE_QPORTCFG_INPUT_FLAGS_PATH_RX	UINT32_C(0x1)
-		#define HWRM_QUEUE_QPORTCFG_INPUT_FLAGS_PATH_LAST HWRM_QUEUE_QPORTCFG_INPUT_FLAGS_PATH_RX
-	/*
-	 * Port ID of port for which the queue configuration is being
-	 * queried. This field is only required when sent by IPC.
-	 */
-	uint16_t	port_id;
-	/*
-	 * Drivers will set this capability when it can use
-	 * queue_idx_service_profile to map the queues to application.
-	 */
-	uint8_t	drv_qmap_cap;
-	/* disabled */
-	#define HWRM_QUEUE_QPORTCFG_INPUT_DRV_QMAP_CAP_DISABLED UINT32_C(0x0)
-	/* enabled */
-	#define HWRM_QUEUE_QPORTCFG_INPUT_DRV_QMAP_CAP_ENABLED  UINT32_C(0x1)
-	#define HWRM_QUEUE_QPORTCFG_INPUT_DRV_QMAP_CAP_LAST	HWRM_QUEUE_QPORTCFG_INPUT_DRV_QMAP_CAP_ENABLED
-	uint8_t	unused_0;
-} hwrm_queue_qportcfg_input_t, *phwrm_queue_qportcfg_input_t;
+} hwrm_tf_version_get_input_t, *phwrm_tf_version_get_input_t;
 
-/* hwrm_queue_qportcfg_output (size:1344b/168B) */
+/* hwrm_tf_version_get_output (size:256b/32B) */
 
-typedef struct hwrm_queue_qportcfg_output {
+typedef struct hwrm_tf_version_get_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
 	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/*
-	 * The maximum number of queues that can be configured on this
-	 * port.
-	 * Valid values range from 1 through 8.
-	 */
-	uint8_t	max_configurable_queues;
-	/*
-	 * The maximum number of lossless queues that can be configured
-	 * on this port.
-	 * Valid values range from 0 through 8.
-	 */
-	uint8_t	max_configurable_lossless_queues;
-	/*
-	 * Bitmask indicating which queues can be configured by the
-	 * hwrm_queue_cfg command.
-	 *
-	 * Each bit represents a specific queue where bit 0 represents
-	 * queue 0 and bit 7 represents queue 7.
-	 * # A value of 0 indicates that the queue is not configurable
-	 * by the hwrm_queue_cfg command.
-	 * # A value of 1 indicates that the queue is configurable.
-	 * # A hwrm_queue_cfg command shall return error when trying to
-	 * configure a queue not configurable.
-	 */
-	uint8_t	queue_cfg_allowed;
-	/* Information about queue configuration. */
-	uint8_t	queue_cfg_info;
-	/*
-	 * If this flag is set to '1', then the queues are
-	 * configured asymmetrically on TX and RX sides.
-	 * If this flag is set to '0', then the queues are
-	 * configured symmetrically on TX and RX sides. For
-	 * symmetric configuration, the queue configuration
-	 * including queue ids and service profiles on the
-	 * TX side is the same as the corresponding queue
-	 * configuration on the RX side.
-	 */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_CFG_INFO_ASYM_CFG		UINT32_C(0x1)
-	/*
-	 * If this flag is set to '1', then service_profile will carry
-	 * either lossy/lossless type and the new service_profile_type
-	 * field will be used to determine if the queue is for L2/ROCE/CNP.
-	 */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_CFG_INFO_USE_PROFILE_TYPE	UINT32_C(0x2)
-	/*
-	 * Bitmask indicating which queues can be configured by the
-	 * hwrm_queue_pfcenable_cfg command.
-	 *
-	 * Each bit represents a specific priority where bit 0 represents
-	 * priority 0 and bit 7 represents priority 7.
-	 * # A value of 0 indicates that the priority is not configurable by
-	 * the hwrm_queue_pfcenable_cfg command.
-	 * # A value of 1 indicates that the priority is configurable.
-	 * # A hwrm_queue_pfcenable_cfg command shall return error when
-	 * trying to configure a priority that is not configurable.
-	 */
-	uint8_t	queue_pfcenable_cfg_allowed;
-	/*
-	 * Bitmask indicating which queues can be configured by the
-	 * hwrm_queue_pri2cos_cfg command.
-	 *
-	 * Each bit represents a specific queue where bit 0 represents
-	 * queue 0 and bit 7 represents queue 7.
-	 * # A value of 0 indicates that the queue is not configurable
-	 * by the hwrm_queue_pri2cos_cfg command.
-	 * # A value of 1 indicates that the queue is configurable.
-	 * # A hwrm_queue_pri2cos_cfg command shall return error when
-	 * trying to configure a queue that is not configurable.
-	 */
-	uint8_t	queue_pri2cos_cfg_allowed;
-	/*
-	 * Bitmask indicating which queues can be configured by the
-	 * hwrm_queue_pri2cos_cfg command.
-	 *
-	 * Each bit represents a specific queue where bit 0 represents
-	 * queue 0 and bit 7 represents queue 7.
-	 * # A value of 0 indicates that the queue is not configurable
-	 * by the hwrm_queue_pri2cos_cfg command.
-	 * # A value of 1 indicates that the queue is configurable.
-	 * # A hwrm_queue_pri2cos_cfg command shall return error when
-	 * trying to configure a queue not configurable.
-	 */
-	uint8_t	queue_cos2bw_cfg_allowed;
-	/*
-	 * ID of CoS Queue 0.
-	 * FF - Invalid id
-	 *
-	 * # This ID can be used on any subsequent call to an hwrm command
-	 * that takes a queue id.
-	 * # IDs must always be queried by this command before any use
-	 * by the driver or software.
-	 * # The CoS queue index is obtained by applying modulo 10 to the
-	 * CoS queue ID. Valid CoS queue indexes are in the range of 0 to 7.
-	 * The CoS queue index is used to reference port statistics for the
-	 * CoS queue.
-	 * # A value of 0xff indicates that the queue is not available.
-	 * # Available queues may not be in sequential order.
-	 */
-	uint8_t	queue_id0;
-	/* This value specifies service profile kind for CoS queue */
-	uint8_t	queue_id0_service_profile;
-	/* Lossy (best-effort) */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_LOSSY	UINT32_C(0x0)
-	/* Lossless */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_LOSSLESS	UINT32_C(0x1)
-	/* Lossless RoCE (deprecated) */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_LOSSLESS_ROCE  UINT32_C(0x1)
-	/* Lossy RoCE CNP (deprecated) */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_LOSSY_ROCE_CNP UINT32_C(0x2)
-	/* Lossless NIC (deprecated) */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_LOSSLESS_NIC   UINT32_C(0x3)
-	/* Set to 0xFF... (All Fs) if there is no service profile specified */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_UNKNOWN	UINT32_C(0xff)
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_LAST	HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_UNKNOWN
-	/*
-	 * ID of CoS Queue 1.
-	 * FF - Invalid id
-	 *
-	 * # This ID can be used on any subsequent call to an hwrm command
-	 * that takes a queue id.
-	 * # IDs must always be queried by this command before any use
-	 * by the driver or software.
-	 * # The CoS queue index is obtained by applying modulo 10 to the
-	 * CoS queue ID. Valid CoS queue indexes are in the range of 0 to 7.
-	 * The CoS queue index is used to reference port statistics for the
-	 * CoS queue.
-	 * # A value of 0xff indicates that the queue is not available.
-	 * # Available queues may not be in sequential order.
-	 */
-	uint8_t	queue_id1;
-	/* This value specifies service profile kind for CoS queue */
-	uint8_t	queue_id1_service_profile;
-	/* Lossy (best-effort) */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID1_SERVICE_PROFILE_LOSSY	UINT32_C(0x0)
-	/* Lossless */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID1_SERVICE_PROFILE_LOSSLESS	UINT32_C(0x1)
-	/* Lossless RoCE (deprecated) */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID1_SERVICE_PROFILE_LOSSLESS_ROCE  UINT32_C(0x1)
-	/* Lossy RoCE CNP (deprecated) */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID1_SERVICE_PROFILE_LOSSY_ROCE_CNP UINT32_C(0x2)
-	/* Lossless NIC (deprecated) */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID1_SERVICE_PROFILE_LOSSLESS_NIC   UINT32_C(0x3)
-	/* Set to 0xFF... (All Fs) if there is no service profile specified */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID1_SERVICE_PROFILE_UNKNOWN	UINT32_C(0xff)
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID1_SERVICE_PROFILE_LAST	HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID1_SERVICE_PROFILE_UNKNOWN
-	/*
-	 * ID of CoS Queue 2.
-	 * FF - Invalid id
-	 *
-	 * # This ID can be used on any subsequent call to an hwrm command
-	 * that takes a queue id.
-	 * # IDs must always be queried by this command before any use
-	 * by the driver or software.
-	 * # The CoS queue index is obtained by applying modulo 10 to the
-	 * CoS queue ID. Valid CoS queue indexes are in the range of 0 to 7.
-	 * The CoS queue index is used to reference port statistics for the
-	 * CoS queue.
-	 * # A value of 0xff indicates that the queue is not available.
-	 * # Available queues may not be in sequential order.
-	 */
-	uint8_t	queue_id2;
-	/* This value specifies service profile kind for CoS queue */
-	uint8_t	queue_id2_service_profile;
-	/* Lossy (best-effort) */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID2_SERVICE_PROFILE_LOSSY	UINT32_C(0x0)
-	/* Lossless */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID2_SERVICE_PROFILE_LOSSLESS	UINT32_C(0x1)
-	/* Lossless RoCE (deprecated) */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID2_SERVICE_PROFILE_LOSSLESS_ROCE  UINT32_C(0x1)
-	/* Lossy RoCE CNP (deprecated) */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID2_SERVICE_PROFILE_LOSSY_ROCE_CNP UINT32_C(0x2)
-	/* Lossless NIC (deprecated) */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID2_SERVICE_PROFILE_LOSSLESS_NIC   UINT32_C(0x3)
-	/* Set to 0xFF... (All Fs) if there is no service profile specified */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID2_SERVICE_PROFILE_UNKNOWN	UINT32_C(0xff)
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID2_SERVICE_PROFILE_LAST	HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID2_SERVICE_PROFILE_UNKNOWN
-	/*
-	 * ID of CoS Queue 3.
-	 * FF - Invalid id
-	 *
-	 * # This ID can be used on any subsequent call to an hwrm command
-	 * that takes a queue id.
-	 * # IDs must always be queried by this command before any use
-	 * by the driver or software.
-	 * # The CoS queue index is obtained by applying modulo 10 to the
-	 * CoS queue ID. Valid CoS queue indexes are in the range of 0 to 7.
-	 * The CoS queue index is used to reference port statistics for the
-	 * CoS queue.
-	 * # A value of 0xff indicates that the queue is not available.
-	 * # Available queues may not be in sequential order.
-	 */
-	uint8_t	queue_id3;
-	/* This value specifies service profile kind for CoS queue */
-	uint8_t	queue_id3_service_profile;
-	/* Lossy (best-effort) */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID3_SERVICE_PROFILE_LOSSY	UINT32_C(0x0)
-	/* Lossless */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID3_SERVICE_PROFILE_LOSSLESS	UINT32_C(0x1)
-	/* Lossless RoCE (deprecated) */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID3_SERVICE_PROFILE_LOSSLESS_ROCE  UINT32_C(0x1)
-	/* Lossy RoCE CNP (deprecated) */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID3_SERVICE_PROFILE_LOSSY_ROCE_CNP UINT32_C(0x2)
-	/* Lossless NIC (deprecated) */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID3_SERVICE_PROFILE_LOSSLESS_NIC   UINT32_C(0x3)
-	/* Set to 0xFF... (All Fs) if there is no service profile specified */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID3_SERVICE_PROFILE_UNKNOWN	UINT32_C(0xff)
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID3_SERVICE_PROFILE_LAST	HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID3_SERVICE_PROFILE_UNKNOWN
-	/*
-	 * ID of CoS Queue 4.
-	 * FF - Invalid id
-	 *
-	 * # This ID can be used on any subsequent call to an hwrm command
-	 * that takes a queue id.
-	 * # IDs must always be queried by this command before any use
-	 * by the driver or software.
-	 * # The CoS queue index is obtained by applying modulo 10 to the
-	 * CoS queue ID. Valid CoS queue indexes are in the range of 0 to 7.
-	 * The CoS queue index is used to reference port statistics for the
-	 * CoS queue.
-	 * # A value of 0xff indicates that the queue is not available.
-	 * # Available queues may not be in sequential order.
-	 */
-	uint8_t	queue_id4;
-	/* This value specifies service profile kind for CoS queue */
-	uint8_t	queue_id4_service_profile;
-	/* Lossy (best-effort) */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID4_SERVICE_PROFILE_LOSSY	UINT32_C(0x0)
-	/* Lossless */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID4_SERVICE_PROFILE_LOSSLESS	UINT32_C(0x1)
-	/* Lossless RoCE (deprecated) */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID4_SERVICE_PROFILE_LOSSLESS_ROCE  UINT32_C(0x1)
-	/* Lossy RoCE CNP (deprecated) */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID4_SERVICE_PROFILE_LOSSY_ROCE_CNP UINT32_C(0x2)
-	/* Lossless NIC (deprecated) */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID4_SERVICE_PROFILE_LOSSLESS_NIC   UINT32_C(0x3)
-	/* Set to 0xFF... (All Fs) if there is no service profile specified */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID4_SERVICE_PROFILE_UNKNOWN	UINT32_C(0xff)
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID4_SERVICE_PROFILE_LAST	HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID4_SERVICE_PROFILE_UNKNOWN
-	/*
-	 * ID of CoS Queue 5.
-	 * FF - Invalid id
-	 *
-	 * # This ID can be used on any subsequent call to an hwrm command
-	 * that takes a queue id.
-	 * # IDs must always be queried by this command before any use
-	 * by the driver or software.
-	 * # The CoS queue index is obtained by applying modulo 10 to the
-	 * CoS queue ID. Valid CoS queue indexes are in the range of 0 to 7.
-	 * The CoS queue index is used to reference port statistics for the
-	 * CoS queue.
-	 * # A value of 0xff indicates that the queue is not available.
-	 * # Available queues may not be in sequential order.
-	 */
-	uint8_t	queue_id5;
-	/* This value specifies service profile kind for CoS queue */
-	uint8_t	queue_id5_service_profile;
-	/* Lossy (best-effort) */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID5_SERVICE_PROFILE_LOSSY	UINT32_C(0x0)
-	/* Lossless */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID5_SERVICE_PROFILE_LOSSLESS	UINT32_C(0x1)
-	/* Lossless RoCE (deprecated) */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID5_SERVICE_PROFILE_LOSSLESS_ROCE  UINT32_C(0x1)
-	/* Lossy RoCE CNP (deprecated) */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID5_SERVICE_PROFILE_LOSSY_ROCE_CNP UINT32_C(0x2)
-	/* Lossless NIC (deprecated) */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID5_SERVICE_PROFILE_LOSSLESS_NIC   UINT32_C(0x3)
-	/* Set to 0xFF... (All Fs) if there is no service profile specified */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID5_SERVICE_PROFILE_UNKNOWN	UINT32_C(0xff)
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID5_SERVICE_PROFILE_LAST	HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID5_SERVICE_PROFILE_UNKNOWN
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Version Major number. */
+	uint8_t	major;
+	/* Version Minor number. */
+	uint8_t	minor;
+	/* Version Update number. */
+	uint8_t	update;
+	/* unused. */
+	uint8_t	unused0[5];
 	/*
-	 * ID of CoS Queue 6.
-	 * FF - Invalid id
-	 *
-	 * # This ID can be used on any subsequent call to an hwrm command
-	 * that takes a queue id.
-	 * # IDs must always be queried by this command before any use
-	 * by the driver or software.
-	 * # The CoS queue index is obtained by applying modulo 10 to the
-	 * CoS queue ID. Valid CoS queue indexes are in the range of 0 to 7.
-	 * The CoS queue index is used to reference port statistics for the
-	 * CoS queue.
-	 * # A value of 0xff indicates that the queue is not available.
-	 * # Available queues may not be in sequential order.
+	 * This field is used to indicate device's capabilities and
+	 * configurations.
 	 */
-	uint8_t	queue_id6;
-	/* This value specifies service profile kind for CoS queue */
-	uint8_t	queue_id6_service_profile;
-	/* Lossy (best-effort) */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID6_SERVICE_PROFILE_LOSSY	UINT32_C(0x0)
-	/* Lossless */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID6_SERVICE_PROFILE_LOSSLESS	UINT32_C(0x1)
-	/* Lossless RoCE (deprecated) */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID6_SERVICE_PROFILE_LOSSLESS_ROCE  UINT32_C(0x1)
-	/* Lossy RoCE CNP (deprecated) */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID6_SERVICE_PROFILE_LOSSY_ROCE_CNP UINT32_C(0x2)
-	/* Lossless NIC (deprecated) */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID6_SERVICE_PROFILE_LOSSLESS_NIC   UINT32_C(0x3)
-	/* Set to 0xFF... (All Fs) if there is no service profile specified */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID6_SERVICE_PROFILE_UNKNOWN	UINT32_C(0xff)
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID6_SERVICE_PROFILE_LAST	HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID6_SERVICE_PROFILE_UNKNOWN
+	uint64_t	dev_caps_cfg;
+	/* unused. */
+	uint8_t	unused1[7];
 	/*
-	 * ID of CoS Queue 7.
-	 * FF - Invalid id
-	 *
-	 * # This ID can be used on any subsequent call to an hwrm command
-	 * that takes a queue id.
-	 * # IDs must always be queried by this command before any use
-	 * by the driver or software.
-	 * # The CoS queue index is obtained by applying modulo 10 to the
-	 * CoS queue ID. Valid CoS queue indexes are in the range of 0 to 7.
-	 * The CoS queue index is used to reference port statistics for the
-	 * CoS queue.
-	 * # A value of 0xff indicates that the queue is not available.
-	 * # Available queues may not be in sequential order.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	uint8_t	queue_id7;
-	/* This value specifies service profile kind for CoS queue */
-	uint8_t	queue_id7_service_profile;
-	/* Lossy (best-effort) */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID7_SERVICE_PROFILE_LOSSY	UINT32_C(0x0)
-	/* Lossless */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID7_SERVICE_PROFILE_LOSSLESS	UINT32_C(0x1)
-	/* Lossless RoCE (deprecated) */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID7_SERVICE_PROFILE_LOSSLESS_ROCE  UINT32_C(0x1)
-	/* Lossy RoCE CNP (deprecated) */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID7_SERVICE_PROFILE_LOSSY_ROCE_CNP UINT32_C(0x2)
-	/* Lossless NIC (deprecated) */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID7_SERVICE_PROFILE_LOSSLESS_NIC   UINT32_C(0x3)
-	/* Set to 0xFF... (All Fs) if there is no service profile specified */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID7_SERVICE_PROFILE_UNKNOWN	UINT32_C(0xff)
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID7_SERVICE_PROFILE_LAST	HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID7_SERVICE_PROFILE_UNKNOWN
+	uint8_t	valid;
+} hwrm_tf_version_get_output_t, *phwrm_tf_version_get_output_t;
+
+/************************
+ * hwrm_tf_session_open *
+ ************************/
+
+
+/* hwrm_tf_session_open_input (size:640b/80B) */
+
+typedef struct hwrm_tf_session_open_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * This value specifies traffic type for the service profile. We can
-	 * have a TC mapped to multiple traffic types. For example shared
-	 * CoS Q for CNP and NIC will have both cnp and nic bits set (0x6).
-	 * A value of zero is considered as invalid.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint8_t	queue_id0_service_profile_type;
-	/* Recommended to be used for RoCE traffic only. */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_TYPE_ROCE	UINT32_C(0x1)
-	/* Recommended to be used for NIC/L2 traffic only. */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_TYPE_NIC	UINT32_C(0x2)
-	/* Recommended to be used for CNP traffic only. */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_TYPE_CNP	UINT32_C(0x4)
+	uint16_t	cmpl_ring;
 	/*
-	 * Up to 16 bytes of null padded ASCII string describing this queue.
-	 * The queue name includes a CoS queue index and, in some cases, text
-	 * that distinguishes the queue from other queues in the group.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	char	qid0_name[16];
-	/* Up to 16 bytes of null padded ASCII string describing this queue. */
-	char	qid1_name[16];
-	/* Up to 16 bytes of null padded ASCII string describing this queue. */
-	char	qid2_name[16];
-	/* Up to 16 bytes of null padded ASCII string describing this queue. */
-	char	qid3_name[16];
-	/* Up to 16 bytes of null padded ASCII string describing this queue. */
-	char	qid4_name[16];
-	/* Up to 16 bytes of null padded ASCII string describing this queue. */
-	char	qid5_name[16];
-	/* Up to 16 bytes of null padded ASCII string describing this queue. */
-	char	qid6_name[16];
-	/* Up to 16 bytes of null padded ASCII string describing this queue. */
-	char	qid7_name[16];
+	uint16_t	seq_id;
 	/*
-	 * This value specifies traffic type for the service profile. We can
-	 * have a TC mapped to multiple traffic types. For example shared
-	 * CoS Q for CNP and NIC will have both cnp and nic bits set (0x6).
-	 * A value of zero is considered as invalid.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint8_t	queue_id1_service_profile_type;
-	/* Recommended to be used for RoCE traffic only. */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID1_SERVICE_PROFILE_TYPE_ROCE	UINT32_C(0x1)
-	/* Recommended to be used for NIC/L2 traffic only. */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID1_SERVICE_PROFILE_TYPE_NIC	UINT32_C(0x2)
-	/* Recommended to be used for CNP traffic only. */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID1_SERVICE_PROFILE_TYPE_CNP	UINT32_C(0x4)
+	uint16_t	target_id;
 	/*
-	 * This value specifies traffic type for the service profile. We can
-	 * have a TC mapped to multiple traffic types. For example shared
-	 * CoS Q for CNP and NIC will have both cnp and nic bits set (0x6).
-	 * A value of zero is considered as invalid.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint8_t	queue_id2_service_profile_type;
-	/* Recommended to be used for RoCE traffic only. */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID2_SERVICE_PROFILE_TYPE_ROCE	UINT32_C(0x1)
-	/* Recommended to be used for NIC/L2 traffic only. */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID2_SERVICE_PROFILE_TYPE_NIC	UINT32_C(0x2)
-	/* Recommended to be used for CNP traffic only. */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID2_SERVICE_PROFILE_TYPE_CNP	UINT32_C(0x4)
+	uint64_t	resp_addr;
+	/* Name of the session. */
+	uint8_t	session_name[64];
+} hwrm_tf_session_open_input_t, *phwrm_tf_session_open_input_t;
+
+/* hwrm_tf_session_open_output (size:192b/24B) */
+
+typedef struct hwrm_tf_session_open_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
 	/*
-	 * This value specifies traffic type for the service profile. We can
-	 * have a TC mapped to multiple traffic types. For example shared
-	 * CoS Q for CNP and NIC will have both cnp and nic bits set (0x6).
-	 * A value of zero is considered as invalid.
+	 * Unique session identifier for the session created by the
+	 * firmware.
 	 */
-	uint8_t	queue_id3_service_profile_type;
-	/* Recommended to be used for RoCE traffic only. */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID3_SERVICE_PROFILE_TYPE_ROCE	UINT32_C(0x1)
-	/* Recommended to be used for NIC/L2 traffic only. */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID3_SERVICE_PROFILE_TYPE_NIC	UINT32_C(0x2)
-	/* Recommended to be used for CNP traffic only. */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID3_SERVICE_PROFILE_TYPE_CNP	UINT32_C(0x4)
+	uint32_t	fw_session_id;
 	/*
-	 * This value specifies traffic type for the service profile. We can
-	 * have a TC mapped to multiple traffic types. For example shared
-	 * CoS Q for CNP and NIC will have both cnp and nic bits set (0x6).
-	 * A value of zero is considered as invalid.
+	 * Unique session client identifier for the first client on
+	 * the newly created session.
 	 */
-	uint8_t	queue_id4_service_profile_type;
-	/* Recommended to be used for RoCE traffic only. */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID4_SERVICE_PROFILE_TYPE_ROCE	UINT32_C(0x1)
-	/* Recommended to be used for NIC/L2 traffic only. */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID4_SERVICE_PROFILE_TYPE_NIC	UINT32_C(0x2)
-	/* Recommended to be used for CNP traffic only. */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID4_SERVICE_PROFILE_TYPE_CNP	UINT32_C(0x4)
+	uint32_t	fw_session_client_id;
+	/* This field is used to return the status of fw session to host. */
+	uint32_t	flags;
 	/*
-	 * This value specifies traffic type for the service profile. We can
-	 * have a TC mapped to multiple traffic types. For example shared
-	 * CoS Q for CNP and NIC will have both cnp and nic bits set (0x6).
-	 * A value of zero is considered as invalid.
+	 * Indicates if the shared session has been created. Shared session
+	 * should be the first session created ever. Its fw_rm_client_id
+	 * should be 1. The AFM session's fw_rm_client_id is 0.
 	 */
-	uint8_t	queue_id5_service_profile_type;
-	/* Recommended to be used for RoCE traffic only. */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID5_SERVICE_PROFILE_TYPE_ROCE	UINT32_C(0x1)
-	/* Recommended to be used for NIC/L2 traffic only. */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID5_SERVICE_PROFILE_TYPE_NIC	UINT32_C(0x2)
-	/* Recommended to be used for CNP traffic only. */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID5_SERVICE_PROFILE_TYPE_CNP	UINT32_C(0x4)
+	#define HWRM_TF_SESSION_OPEN_OUTPUT_FLAGS_SHARED_SESSION		UINT32_C(0x1)
 	/*
-	 * This value specifies traffic type for the service profile. We can
-	 * have a TC mapped to multiple traffic types. For example shared
-	 * CoS Q for CNP and NIC will have both cnp and nic bits set (0x6).
-	 * A value of zero is considered as invalid.
+	 * If this bit set to 0, then it indicates the shared session
+	 * has been created by another session.
 	 */
-	uint8_t	queue_id6_service_profile_type;
-	/* Recommended to be used for RoCE traffic only. */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID6_SERVICE_PROFILE_TYPE_ROCE	UINT32_C(0x1)
-	/* Recommended to be used for NIC/L2 traffic only. */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID6_SERVICE_PROFILE_TYPE_NIC	UINT32_C(0x2)
-	/* Recommended to be used for CNP traffic only. */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID6_SERVICE_PROFILE_TYPE_CNP	UINT32_C(0x4)
+		#define HWRM_TF_SESSION_OPEN_OUTPUT_FLAGS_SHARED_SESSION_NOT_CREATOR  UINT32_C(0x0)
 	/*
-	 * This value specifies traffic type for the service profile. We can
-	 * have a TC mapped to multiple traffic types. For example shared
-	 * CoS Q for CNP and NIC will have both cnp and nic bits set (0x6).
-	 * A value of zero is considered as invalid.
+	 * If this bit is set to 1, then it indicates the shared session
+	 * is created by this session.
 	 */
-	uint8_t	queue_id7_service_profile_type;
-	/* Recommended to be used for RoCE traffic only. */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID7_SERVICE_PROFILE_TYPE_ROCE	UINT32_C(0x1)
-	/* Recommended to be used for NIC/L2 traffic only. */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID7_SERVICE_PROFILE_TYPE_NIC	UINT32_C(0x2)
-	/* Recommended to be used for CNP traffic only. */
-	#define HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID7_SERVICE_PROFILE_TYPE_CNP	UINT32_C(0x4)
+		#define HWRM_TF_SESSION_OPEN_OUTPUT_FLAGS_SHARED_SESSION_CREATOR	UINT32_C(0x1)
+		#define HWRM_TF_SESSION_OPEN_OUTPUT_FLAGS_SHARED_SESSION_LAST	HWRM_TF_SESSION_OPEN_OUTPUT_FLAGS_SHARED_SESSION_CREATOR
+	/* unused. */
+	uint8_t	unused1[3];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_queue_qportcfg_output_t, *phwrm_queue_qportcfg_output_t;
+} hwrm_tf_session_open_output_t, *phwrm_tf_session_open_output_t;
 
-/*******************
- * hwrm_queue_qcfg *
- *******************/
+/****************************
+ * hwrm_tf_session_register *
+ ****************************/
 
 
-/* hwrm_queue_qcfg_input (size:192b/24B) */
+/* hwrm_tf_session_register_input (size:704b/88B) */
 
-typedef struct hwrm_queue_qcfg_input {
+typedef struct hwrm_tf_session_register_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -25367,25 +53151,24 @@ typedef struct hwrm_queue_qcfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	flags;
 	/*
-	 * Enumeration denoting the RX, TX type of the resource.
-	 * This enumeration is used for resources that are similar for both
-	 * TX and RX paths of the chip.
+	 * Unique session identifier for the session that the
+	 * register request want to create a new client on. This
+	 * value originates from the first open request.
+	 * The fw_session_id of the attach session includes PCIe bus
+	 * info to distinguish the PF and session info to identify
+	 * the associated TruFlow session.
 	 */
-	#define HWRM_QUEUE_QCFG_INPUT_FLAGS_PATH	UINT32_C(0x1)
-	/* tx path */
-		#define HWRM_QUEUE_QCFG_INPUT_FLAGS_PATH_TX	UINT32_C(0x0)
-	/* rx path */
-		#define HWRM_QUEUE_QCFG_INPUT_FLAGS_PATH_RX	UINT32_C(0x1)
-		#define HWRM_QUEUE_QCFG_INPUT_FLAGS_PATH_LAST HWRM_QUEUE_QCFG_INPUT_FLAGS_PATH_RX
-	/* Queue ID of the queue. */
-	uint32_t	queue_id;
-} hwrm_queue_qcfg_input_t, *phwrm_queue_qcfg_input_t;
+	uint32_t	fw_session_id;
+	/* unused. */
+	uint32_t	unused0;
+	/* Name of the session client. */
+	uint8_t	session_client_name[64];
+} hwrm_tf_session_register_input_t, *phwrm_tf_session_register_input_t;
 
-/* hwrm_queue_qcfg_output (size:128b/16B) */
+/* hwrm_tf_session_register_output (size:128b/16B) */
 
-typedef struct hwrm_queue_qcfg_output {
+typedef struct hwrm_tf_session_register_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -25395,47 +53178,104 @@ typedef struct hwrm_queue_qcfg_output {
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
 	/*
-	 * This value is the estimate packet length used in the
-	 * TX arbiter.
+	 * Unique session client identifier for the session created
+	 * by the firmware. It includes the session the client it
+	 * attached to and session client info.
 	 */
-	uint32_t	queue_len;
-	/* This value is applicable to CoS queues only. */
-	uint8_t	service_profile;
-	/* Lossy (best-effort) */
-	#define HWRM_QUEUE_QCFG_OUTPUT_SERVICE_PROFILE_LOSSY	UINT32_C(0x0)
-	/* Lossless */
-	#define HWRM_QUEUE_QCFG_OUTPUT_SERVICE_PROFILE_LOSSLESS UINT32_C(0x1)
-	/* Set to 0xFF... (All Fs) if there is no service profile specified */
-	#define HWRM_QUEUE_QCFG_OUTPUT_SERVICE_PROFILE_UNKNOWN  UINT32_C(0xff)
-	#define HWRM_QUEUE_QCFG_OUTPUT_SERVICE_PROFILE_LAST	HWRM_QUEUE_QCFG_OUTPUT_SERVICE_PROFILE_UNKNOWN
-	/* Information about queue configuration. */
-	uint8_t	queue_cfg_info;
+	uint32_t	fw_session_client_id;
+	/* unused. */
+	uint8_t	unused0[3];
 	/*
-	 * If this flag is set to '1', then the queue is
-	 * configured asymmetrically on TX and RX sides.
-	 * If this flag is set to '0', then this queue is
-	 * configured symmetrically on TX and RX sides.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	#define HWRM_QUEUE_QCFG_OUTPUT_QUEUE_CFG_INFO_ASYM_CFG	UINT32_C(0x1)
-	uint8_t	unused_0;
+	uint8_t	valid;
+} hwrm_tf_session_register_output_t, *phwrm_tf_session_register_output_t;
+
+/******************************
+ * hwrm_tf_session_unregister *
+ ******************************/
+
+
+/* hwrm_tf_session_unregister_input (size:192b/24B) */
+
+typedef struct hwrm_tf_session_unregister_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/*
+	 * Unique session identifier for the session that the
+	 * unregister request want to close a session client on.
+	 */
+	uint32_t	fw_session_id;
+	/*
+	 * Unique session client identifier for the session that the
+	 * unregister request want to close.
+	 */
+	uint32_t	fw_session_client_id;
+} hwrm_tf_session_unregister_input_t, *phwrm_tf_session_unregister_input_t;
+
+/* hwrm_tf_session_unregister_output (size:128b/16B) */
+
+typedef struct hwrm_tf_session_unregister_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* unused. */
+	uint8_t	unused0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_queue_qcfg_output_t, *phwrm_queue_qcfg_output_t;
+} hwrm_tf_session_unregister_output_t, *phwrm_tf_session_unregister_output_t;
 
-/******************
- * hwrm_queue_cfg *
- ******************/
+/*************************
+ * hwrm_tf_session_close *
+ *************************/
 
 
-/* hwrm_queue_cfg_input (size:320b/40B) */
+/* hwrm_tf_session_close_input (size:192b/24B) */
 
-typedef struct hwrm_queue_cfg_input {
+typedef struct hwrm_tf_session_close_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -25464,55 +53304,81 @@ typedef struct hwrm_queue_cfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	flags;
+	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
+	uint32_t	fw_session_id;
+	/* unused. */
+	uint8_t	unused0[4];
+} hwrm_tf_session_close_input_t, *phwrm_tf_session_close_input_t;
+
+/* hwrm_tf_session_close_output (size:128b/16B) */
+
+typedef struct hwrm_tf_session_close_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* unused. */
+	uint8_t	unused0[7];
 	/*
-	 * Enumeration denoting the RX, TX, or both directions applicable to the resource.
-	 * This enumeration is used for resources that are similar for both
-	 * TX and RX paths of the chip.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
-	#define HWRM_QUEUE_CFG_INPUT_FLAGS_PATH_MASK UINT32_C(0x3)
-	#define HWRM_QUEUE_CFG_INPUT_FLAGS_PATH_SFT  0
-	/* tx path */
-		#define HWRM_QUEUE_CFG_INPUT_FLAGS_PATH_TX	UINT32_C(0x0)
-	/* rx path */
-		#define HWRM_QUEUE_CFG_INPUT_FLAGS_PATH_RX	UINT32_C(0x1)
-	/* Bi-directional (Symmetrically applicable to TX and RX paths) */
-		#define HWRM_QUEUE_CFG_INPUT_FLAGS_PATH_BIDIR  UINT32_C(0x2)
-		#define HWRM_QUEUE_CFG_INPUT_FLAGS_PATH_LAST  HWRM_QUEUE_CFG_INPUT_FLAGS_PATH_BIDIR
-	uint32_t	enables;
+	uint8_t	valid;
+} hwrm_tf_session_close_output_t, *phwrm_tf_session_close_output_t;
+
+/************************
+ * hwrm_tf_session_qcfg *
+ ************************/
+
+
+/* hwrm_tf_session_qcfg_input (size:192b/24B) */
+
+typedef struct hwrm_tf_session_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * This bit must be '1' for the dflt_len field to be
-	 * configured.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define HWRM_QUEUE_CFG_INPUT_ENABLES_DFLT_LEN		UINT32_C(0x1)
+	uint16_t	cmpl_ring;
 	/*
-	 * This bit must be '1' for the service_profile field to be
-	 * configured.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define HWRM_QUEUE_CFG_INPUT_ENABLES_SERVICE_PROFILE	UINT32_C(0x2)
-	/* Queue ID of queue that is to be configured by this function. */
-	uint32_t	queue_id;
+	uint16_t	seq_id;
 	/*
-	 * This value is a the estimate packet length used in the
-	 * TX arbiter.
-	 * Set to 0xFF... (All Fs) to not adjust this value.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint32_t	dflt_len;
-	/* This value is applicable to CoS queues only. */
-	uint8_t	service_profile;
-	/* Lossy (best-effort) */
-	#define HWRM_QUEUE_CFG_INPUT_SERVICE_PROFILE_LOSSY	UINT32_C(0x0)
-	/* Lossless */
-	#define HWRM_QUEUE_CFG_INPUT_SERVICE_PROFILE_LOSSLESS UINT32_C(0x1)
-	/* Set to 0xFF... (All Fs) if there is no service profile specified */
-	#define HWRM_QUEUE_CFG_INPUT_SERVICE_PROFILE_UNKNOWN  UINT32_C(0xff)
-	#define HWRM_QUEUE_CFG_INPUT_SERVICE_PROFILE_LAST	HWRM_QUEUE_CFG_INPUT_SERVICE_PROFILE_UNKNOWN
-	uint8_t	unused_0[7];
-} hwrm_queue_cfg_input_t, *phwrm_queue_cfg_input_t;
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
+	uint32_t	fw_session_id;
+	/* unused. */
+	uint8_t	unused0[4];
+} hwrm_tf_session_qcfg_input_t, *phwrm_tf_session_qcfg_input_t;
 
-/* hwrm_queue_cfg_output (size:128b/16B) */
+/* hwrm_tf_session_qcfg_output (size:128b/16B) */
 
-typedef struct hwrm_queue_cfg_output {
+typedef struct hwrm_tf_session_qcfg_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -25521,25 +53387,68 @@ typedef struct hwrm_queue_cfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	/* RX action control settings flags. */
+	uint8_t	rx_act_flags;
+	/*
+	 * A value of 1 in this field indicates that Global Flow ID
+	 * reporting into cfa_code and cfa_metadata is enabled.
+	 */
+	#define HWRM_TF_SESSION_QCFG_OUTPUT_RX_ACT_FLAGS_ABCR_GFID_EN		UINT32_C(0x1)
+	/*
+	 * A value of 1 in this field indicates that both inner and outer
+	 * are stripped and inner tag is passed.
+	 * Enabled.
+	 */
+	#define HWRM_TF_SESSION_QCFG_OUTPUT_RX_ACT_FLAGS_ABCR_VTAG_DLT_BOTH	UINT32_C(0x2)
+	/*
+	 * A value of 1 in this field indicates that the re-use of
+	 * existing tunnel L2 header SMAC is enabled for
+	 * Non-tunnel L2, L2-L3 and IP-IP tunnel.
+	 */
+	#define HWRM_TF_SESSION_QCFG_OUTPUT_RX_ACT_FLAGS_TECT_SMAC_OVR_RUTNSL2	UINT32_C(0x4)
+	/* TX Action control settings flags. */
+	uint8_t	tx_act_flags;
+	/* Disabled. */
+	#define HWRM_TF_SESSION_QCFG_OUTPUT_TX_ACT_FLAGS_ABCR_VEB_EN	UINT32_C(0x1)
+	/*
+	 * When set to 1 any GRE tunnels will include the
+	 * optional Key field.
+	 */
+	#define HWRM_TF_SESSION_QCFG_OUTPUT_TX_ACT_FLAGS_TECT_GRE_SET_K	UINT32_C(0x2)
+	/*
+	 * When set to 1, for GRE tunnels, the IPV6 Traffic Class (TC)
+	 * field of the outer header is inherited from the inner header
+	 * (if present) or the fixed value as taken from the encap
+	 * record.
+	 */
+	#define HWRM_TF_SESSION_QCFG_OUTPUT_TX_ACT_FLAGS_TECT_IPV6_TC_IH	UINT32_C(0x4)
+	/*
+	 * When set to 1, for GRE tunnels, the IPV4 Type Of Service (TOS)
+	 * field of the outer header is inherited from the inner header
+	 * (if present) or the fixed value as taken from the encap record.
+	 */
+	#define HWRM_TF_SESSION_QCFG_OUTPUT_TX_ACT_FLAGS_TECT_IPV4_TOS_IH	UINT32_C(0x8)
+	/* unused. */
+	uint8_t	unused0[5];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
 	uint8_t	valid;
-} hwrm_queue_cfg_output_t, *phwrm_queue_cfg_output_t;
+} hwrm_tf_session_qcfg_output_t, *phwrm_tf_session_qcfg_output_t;
 
-/*****************************
- * hwrm_queue_pfcenable_qcfg *
- *****************************/
+/******************************
+ * hwrm_tf_session_resc_qcaps *
+ ******************************/
 
 
-/* hwrm_queue_pfcenable_qcfg_input (size:192b/24B) */
+/* hwrm_tf_session_resc_qcaps_input (size:256b/32B) */
 
-typedef struct hwrm_queue_pfcenable_qcfg_input {
+typedef struct hwrm_tf_session_resc_qcaps_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -25568,18 +53477,36 @@ typedef struct hwrm_queue_pfcenable_qcfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
+	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
+	uint32_t	fw_session_id;
+	/* Control flags. */
+	uint16_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TF_SESSION_RESC_QCAPS_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TF_SESSION_RESC_QCAPS_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TF_SESSION_RESC_QCAPS_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TF_SESSION_RESC_QCAPS_INPUT_FLAGS_DIR_LAST HWRM_TF_SESSION_RESC_QCAPS_INPUT_FLAGS_DIR_TX
 	/*
-	 * Port ID of port for which the table is being configured.
-	 * The HWRM needs to check whether this function is allowed
-	 * to configure pri2cos mapping on this port.
+	 * Defines the size of the provided qcaps_addr array
+	 * buffer. The size should be set to the Resource Manager
+	 * provided max number of qcaps entries which is device
+	 * specific. Resource Manager gets the max size from HCAPI
+	 * RM.
 	 */
-	uint16_t	port_id;
-	uint8_t	unused_0[6];
-} hwrm_queue_pfcenable_qcfg_input_t, *phwrm_queue_pfcenable_qcfg_input_t;
+	uint16_t	qcaps_size;
+	/*
+	 * This is the DMA address for the qcaps output data array
+	 * buffer. Array is of tf_rm_resc_req_entry type and is
+	 * device specific.
+	 */
+	uint64_t	qcaps_addr;
+} hwrm_tf_session_resc_qcaps_input_t, *phwrm_tf_session_resc_qcaps_input_t;
 
-/* hwrm_queue_pfcenable_qcfg_output (size:128b/16B) */
+/* hwrm_tf_session_resc_qcaps_output (size:192b/24B) */
 
-typedef struct hwrm_queue_pfcenable_qcfg_output {
+typedef struct hwrm_tf_session_resc_qcaps_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -25588,58 +53515,54 @@ typedef struct hwrm_queue_pfcenable_qcfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
+	/* Control flags. */
 	uint32_t	flags;
-	/* If set to 1, then PFC is enabled on PRI 0. */
-	#define HWRM_QUEUE_PFCENABLE_QCFG_OUTPUT_FLAGS_PRI0_PFC_ENABLED		UINT32_C(0x1)
-	/* If set to 1, then PFC is enabled on PRI 1. */
-	#define HWRM_QUEUE_PFCENABLE_QCFG_OUTPUT_FLAGS_PRI1_PFC_ENABLED		UINT32_C(0x2)
-	/* If set to 1, then PFC is enabled on PRI 2. */
-	#define HWRM_QUEUE_PFCENABLE_QCFG_OUTPUT_FLAGS_PRI2_PFC_ENABLED		UINT32_C(0x4)
-	/* If set to 1, then PFC is enabled on PRI 3. */
-	#define HWRM_QUEUE_PFCENABLE_QCFG_OUTPUT_FLAGS_PRI3_PFC_ENABLED		UINT32_C(0x8)
-	/* If set to 1, then PFC is enabled on PRI 4. */
-	#define HWRM_QUEUE_PFCENABLE_QCFG_OUTPUT_FLAGS_PRI4_PFC_ENABLED		UINT32_C(0x10)
-	/* If set to 1, then PFC is enabled on PRI 5. */
-	#define HWRM_QUEUE_PFCENABLE_QCFG_OUTPUT_FLAGS_PRI5_PFC_ENABLED		UINT32_C(0x20)
-	/* If set to 1, then PFC is enabled on PRI 6. */
-	#define HWRM_QUEUE_PFCENABLE_QCFG_OUTPUT_FLAGS_PRI6_PFC_ENABLED		UINT32_C(0x40)
-	/* If set to 1, then PFC is enabled on PRI 7. */
-	#define HWRM_QUEUE_PFCENABLE_QCFG_OUTPUT_FLAGS_PRI7_PFC_ENABLED		UINT32_C(0x80)
-	/* If set to 1, then PFC WatchDog is requested to be enabled on PRI0. */
-	#define HWRM_QUEUE_PFCENABLE_QCFG_OUTPUT_FLAGS_PRI0_PFC_WATCHDOG_ENABLED	UINT32_C(0x100)
-	/* If set to 1, then PFC WatchDog is requested to be enabled on PRI1. */
-	#define HWRM_QUEUE_PFCENABLE_QCFG_OUTPUT_FLAGS_PRI1_PFC_WATCHDOG_ENABLED	UINT32_C(0x200)
-	/* If set to 1, then PFC WatchDog is requested to be enabled on PRI2. */
-	#define HWRM_QUEUE_PFCENABLE_QCFG_OUTPUT_FLAGS_PRI2_PFC_WATCHDOG_ENABLED	UINT32_C(0x400)
-	/* If set to 1, then PFC WatchDog is requested to be enabled on PRI3. */
-	#define HWRM_QUEUE_PFCENABLE_QCFG_OUTPUT_FLAGS_PRI3_PFC_WATCHDOG_ENABLED	UINT32_C(0x800)
-	/* If set to 1, then PFC WatchDog is requested to be enabled on PRI4. */
-	#define HWRM_QUEUE_PFCENABLE_QCFG_OUTPUT_FLAGS_PRI4_PFC_WATCHDOG_ENABLED	UINT32_C(0x1000)
-	/* If set to 1, then PFC WatchDog is requested to be enabled on PRI5. */
-	#define HWRM_QUEUE_PFCENABLE_QCFG_OUTPUT_FLAGS_PRI5_PFC_WATCHDOG_ENABLED	UINT32_C(0x2000)
-	/* If set to 1, then PFC WatchDog is requested to be enabled on PRI6. */
-	#define HWRM_QUEUE_PFCENABLE_QCFG_OUTPUT_FLAGS_PRI6_PFC_WATCHDOG_ENABLED	UINT32_C(0x4000)
-	/* If set to 1, then PFC WatchDog is requested to be enabled on PRI7. */
-	#define HWRM_QUEUE_PFCENABLE_QCFG_OUTPUT_FLAGS_PRI7_PFC_WATCHDOG_ENABLED	UINT32_C(0x8000)
-	uint8_t	unused_0[3];
+	/* Session reservation strategy. */
+	#define HWRM_TF_SESSION_RESC_QCAPS_OUTPUT_FLAGS_SESS_RESV_STRATEGY_MASK  UINT32_C(0x3)
+	#define HWRM_TF_SESSION_RESC_QCAPS_OUTPUT_FLAGS_SESS_RESV_STRATEGY_SFT   0
+	/* Static partitioning. */
+		#define HWRM_TF_SESSION_RESC_QCAPS_OUTPUT_FLAGS_SESS_RESV_STRATEGY_STATIC  UINT32_C(0x0)
+	/* Strategy 1. */
+		#define HWRM_TF_SESSION_RESC_QCAPS_OUTPUT_FLAGS_SESS_RESV_STRATEGY_1	UINT32_C(0x1)
+	/* Strategy 2. */
+		#define HWRM_TF_SESSION_RESC_QCAPS_OUTPUT_FLAGS_SESS_RESV_STRATEGY_2	UINT32_C(0x2)
+	/* Strategy 3. */
+		#define HWRM_TF_SESSION_RESC_QCAPS_OUTPUT_FLAGS_SESS_RESV_STRATEGY_3	UINT32_C(0x3)
+		#define HWRM_TF_SESSION_RESC_QCAPS_OUTPUT_FLAGS_SESS_RESV_STRATEGY_LAST   HWRM_TF_SESSION_RESC_QCAPS_OUTPUT_FLAGS_SESS_RESV_STRATEGY_3
+	/*
+	 * Size of the returned qcaps_addr data array buffer. The
+	 * value cannot exceed the size defined by the input msg,
+	 * qcaps_size.
+	 */
+	uint16_t	size;
+	/*
+	 * SRAM profile number that sets the partition of SRAM memory
+	 * between TF and AFM within the 4 internal memory banks (Thor).
+	 */
+	uint8_t	sram_profile;
+	/* unused. */
+	uint8_t	unused0;
+	/* unused. */
+	uint8_t	unused1[7];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_queue_pfcenable_qcfg_output_t, *phwrm_queue_pfcenable_qcfg_output_t;
+} hwrm_tf_session_resc_qcaps_output_t, *phwrm_tf_session_resc_qcaps_output_t;
 
-/****************************
- * hwrm_queue_pfcenable_cfg *
- ****************************/
+/******************************
+ * hwrm_tf_session_resc_alloc *
+ ******************************/
 
 
-/* hwrm_queue_pfcenable_cfg_input (size:192b/24B) */
+/* hwrm_tf_session_resc_alloc_input (size:320b/40B) */
 
-typedef struct hwrm_queue_pfcenable_cfg_input {
+typedef struct hwrm_tf_session_resc_alloc_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -25668,51 +53591,42 @@ typedef struct hwrm_queue_pfcenable_cfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	flags;
-	/* If set to 1, then PFC is requested to be enabled on PRI 0. */
-	#define HWRM_QUEUE_PFCENABLE_CFG_INPUT_FLAGS_PRI0_PFC_ENABLED		UINT32_C(0x1)
-	/* If set to 1, then PFC is requested to be enabled on PRI 1. */
-	#define HWRM_QUEUE_PFCENABLE_CFG_INPUT_FLAGS_PRI1_PFC_ENABLED		UINT32_C(0x2)
-	/* If set to 1, then PFC is requested to be enabled on PRI 2. */
-	#define HWRM_QUEUE_PFCENABLE_CFG_INPUT_FLAGS_PRI2_PFC_ENABLED		UINT32_C(0x4)
-	/* If set to 1, then PFC is requested to be enabled on PRI 3. */
-	#define HWRM_QUEUE_PFCENABLE_CFG_INPUT_FLAGS_PRI3_PFC_ENABLED		UINT32_C(0x8)
-	/* If set to 1, then PFC is requested to be enabled on PRI 4. */
-	#define HWRM_QUEUE_PFCENABLE_CFG_INPUT_FLAGS_PRI4_PFC_ENABLED		UINT32_C(0x10)
-	/* If set to 1, then PFC is requested to be enabled on PRI 5. */
-	#define HWRM_QUEUE_PFCENABLE_CFG_INPUT_FLAGS_PRI5_PFC_ENABLED		UINT32_C(0x20)
-	/* If set to 1, then PFC is requested to be enabled on PRI 6. */
-	#define HWRM_QUEUE_PFCENABLE_CFG_INPUT_FLAGS_PRI6_PFC_ENABLED		UINT32_C(0x40)
-	/* If set to 1, then PFC is requested to be enabled on PRI 7. */
-	#define HWRM_QUEUE_PFCENABLE_CFG_INPUT_FLAGS_PRI7_PFC_ENABLED		UINT32_C(0x80)
-	/* If set to 1, then PFC WatchDog is requested to be enabled on PRI0. */
-	#define HWRM_QUEUE_PFCENABLE_CFG_INPUT_FLAGS_PRI0_PFC_WATCHDOG_ENABLED	UINT32_C(0x100)
-	/* If set to 1, then PFC WatchDog is requested to be enabled on PRI1. */
-	#define HWRM_QUEUE_PFCENABLE_CFG_INPUT_FLAGS_PRI1_PFC_WATCHDOG_ENABLED	UINT32_C(0x200)
-	/* If set to 1, then PFC WatchDog is requested to be enabled on PRI2. */
-	#define HWRM_QUEUE_PFCENABLE_CFG_INPUT_FLAGS_PRI2_PFC_WATCHDOG_ENABLED	UINT32_C(0x400)
-	/* If set to 1, then PFC WatchDog is requested to be enabled on PRI3. */
-	#define HWRM_QUEUE_PFCENABLE_CFG_INPUT_FLAGS_PRI3_PFC_WATCHDOG_ENABLED	UINT32_C(0x800)
-	/* If set to 1, then PFC WatchDog is requested to be enabled on PRI4. */
-	#define HWRM_QUEUE_PFCENABLE_CFG_INPUT_FLAGS_PRI4_PFC_WATCHDOG_ENABLED	UINT32_C(0x1000)
-	/* If set to 1, then PFC WatchDog is requested to be enabled on PRI5. */
-	#define HWRM_QUEUE_PFCENABLE_CFG_INPUT_FLAGS_PRI5_PFC_WATCHDOG_ENABLED	UINT32_C(0x2000)
-	/* If set to 1, then PFC WatchDog is requested to be enabled on PRI6. */
-	#define HWRM_QUEUE_PFCENABLE_CFG_INPUT_FLAGS_PRI6_PFC_WATCHDOG_ENABLED	UINT32_C(0x4000)
-	/* If set to 1, then PFC WatchDog is requested to be enabled on PRI7. */
-	#define HWRM_QUEUE_PFCENABLE_CFG_INPUT_FLAGS_PRI7_PFC_WATCHDOG_ENABLED	UINT32_C(0x8000)
+	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
+	uint32_t	fw_session_id;
+	/* Control flags. */
+	uint16_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TF_SESSION_RESC_ALLOC_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TF_SESSION_RESC_ALLOC_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TF_SESSION_RESC_ALLOC_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TF_SESSION_RESC_ALLOC_INPUT_FLAGS_DIR_LAST HWRM_TF_SESSION_RESC_ALLOC_INPUT_FLAGS_DIR_TX
 	/*
-	 * Port ID of port for which the table is being configured.
-	 * The HWRM needs to check whether this function is allowed
-	 * to configure pri2cos mapping on this port.
+	 * Defines the array size of the provided req_addr and
+	 * resv_addr array buffers. Should be set to the number of
+	 * request entries.
 	 */
-	uint16_t	port_id;
-	uint8_t	unused_0[2];
-} hwrm_queue_pfcenable_cfg_input_t, *phwrm_queue_pfcenable_cfg_input_t;
+	uint16_t	req_size;
+	/*
+	 * This is the DMA address for the request input data array
+	 * buffer. Array is of tf_rm_resc_req_entry type. Size of the
+	 * array buffer is provided by the 'req_size' field in this
+	 * message.
+	 */
+	uint64_t	req_addr;
+	/*
+	 * This is the DMA address for the resc output data array
+	 * buffer. Array is of tf_rm_resc_entry type. Size of the array
+	 * buffer is provided by the 'req_size' field in this
+	 * message.
+	 */
+	uint64_t	resc_addr;
+} hwrm_tf_session_resc_alloc_input_t, *phwrm_tf_session_resc_alloc_input_t;
 
-/* hwrm_queue_pfcenable_cfg_output (size:128b/16B) */
+/* hwrm_tf_session_resc_alloc_output (size:128b/16B) */
 
-typedef struct hwrm_queue_pfcenable_cfg_output {
+typedef struct hwrm_tf_session_resc_alloc_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -25721,25 +53635,34 @@ typedef struct hwrm_queue_pfcenable_cfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	/*
+	 * Size of the returned tf_rm_resc_entry data array. The value
+	 * cannot exceed the req_size defined by the input msg. The data
+	 * array is returned using the resv_addr specified DMA
+	 * address also provided by the input msg.
+	 */
+	uint16_t	size;
+	/* unused. */
+	uint8_t	unused0[5];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_queue_pfcenable_cfg_output_t, *phwrm_queue_pfcenable_cfg_output_t;
+} hwrm_tf_session_resc_alloc_output_t, *phwrm_tf_session_resc_alloc_output_t;
 
-/***************************
- * hwrm_queue_pri2cos_qcfg *
- ***************************/
+/******************************
+ * hwrm_tf_session_resc_flush *
+ ******************************/
 
 
-/* hwrm_queue_pri2cos_qcfg_input (size:192b/24B) */
+/* hwrm_tf_session_resc_flush_input (size:256b/32B) */
 
-typedef struct hwrm_queue_pri2cos_qcfg_input {
+typedef struct hwrm_tf_session_resc_flush_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -25768,37 +53691,34 @@ typedef struct hwrm_queue_pri2cos_qcfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	flags;
-	/*
-	 * Enumeration denoting the RX, TX type of the resource.
-	 * This enumeration is used for resources that are similar for both
-	 * TX and RX paths of the chip.
-	 */
-	#define HWRM_QUEUE_PRI2COS_QCFG_INPUT_FLAGS_PATH	UINT32_C(0x1)
-	/* tx path */
-		#define HWRM_QUEUE_PRI2COS_QCFG_INPUT_FLAGS_PATH_TX	UINT32_C(0x0)
-	/* rx path */
-		#define HWRM_QUEUE_PRI2COS_QCFG_INPUT_FLAGS_PATH_RX	UINT32_C(0x1)
-		#define HWRM_QUEUE_PRI2COS_QCFG_INPUT_FLAGS_PATH_LAST  HWRM_QUEUE_PRI2COS_QCFG_INPUT_FLAGS_PATH_RX
+	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
+	uint32_t	fw_session_id;
+	/* Control flags. */
+	uint16_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TF_SESSION_RESC_FLUSH_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TF_SESSION_RESC_FLUSH_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TF_SESSION_RESC_FLUSH_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TF_SESSION_RESC_FLUSH_INPUT_FLAGS_DIR_LAST HWRM_TF_SESSION_RESC_FLUSH_INPUT_FLAGS_DIR_TX
 	/*
-	 * When this bit is set to '0', the query is
-	 * for PRI from tunnel headers.
-	 * When this bit is set to '1', the query is
-	 * for PRI from inner packet headers.
+	 * Defines the size, in bytes, of the provided flush_addr
+	 * buffer.
 	 */
-	#define HWRM_QUEUE_PRI2COS_QCFG_INPUT_FLAGS_IVLAN	UINT32_C(0x2)
+	uint16_t	flush_size;
 	/*
-	 * Port ID of port for which the table is being configured.
-	 * The HWRM needs to check whether this function is allowed
-	 * to configure pri2cos mapping on this port.
+	 * This is the DMA address for the flush input data array
+	 * buffer. Array of tf_rm_resc_entry type. Size of the
+	 * buffer is provided by the 'flush_size' field in this
+	 * message.
 	 */
-	uint8_t	port_id;
-	uint8_t	unused_0[3];
-} hwrm_queue_pri2cos_qcfg_input_t, *phwrm_queue_pri2cos_qcfg_input_t;
+	uint64_t	flush_addr;
+} hwrm_tf_session_resc_flush_input_t, *phwrm_tf_session_resc_flush_input_t;
 
-/* hwrm_queue_pri2cos_qcfg_output (size:192b/24B) */
+/* hwrm_tf_session_resc_flush_output (size:128b/16B) */
 
-typedef struct hwrm_queue_pri2cos_qcfg_output {
+typedef struct hwrm_tf_session_resc_flush_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -25807,90 +53727,27 @@ typedef struct hwrm_queue_pri2cos_qcfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/*
-	 * CoS Queue assigned to priority 0. This value can only
-	 * be changed before traffic has started.
-	 * A value of 0xff indicates that no CoS queue is assigned to the
-	 * specified priority.
-	 */
-	uint8_t	pri0_cos_queue_id;
-	/*
-	 * CoS Queue assigned to priority 1. This value can only
-	 * be changed before traffic has started.
-	 * A value of 0xff indicates that no CoS queue is assigned to the
-	 * specified priority.
-	 */
-	uint8_t	pri1_cos_queue_id;
-	/*
-	 * CoS Queue assigned to priority 2. This value can only
-	 * be changed before traffic has started.
-	 * A value of 0xff indicates that no CoS queue is assigned to the
-	 * specified priority.
-	 */
-	uint8_t	pri2_cos_queue_id;
-	/*
-	 * CoS Queue assigned to priority 3. This value can only
-	 * be changed before traffic has started.
-	 * A value of 0xff indicates that no CoS queue is assigned to the
-	 * specified priority.
-	 */
-	uint8_t	pri3_cos_queue_id;
-	/*
-	 * CoS Queue assigned to priority 4. This value can only
-	 * be changed before traffic has started.
-	 * A value of 0xff indicates that no CoS queue is assigned to the
-	 * specified priority.
-	 */
-	uint8_t	pri4_cos_queue_id;
-	/*
-	 * CoS Queue assigned to priority 5. This value can only
-	 * be changed before traffic has started.
-	 * A value of 0xff indicates that no CoS queue is assigned to the
-	 * specified priority.
-	 */
-	uint8_t	pri5_cos_queue_id;
-	/*
-	 * CoS Queue assigned to priority 6. This value can only
-	 * be changed before traffic has started.
-	 * A value of 0xff indicates that no CoS queue is assigned to the
-	 * specified priority.
-	 */
-	uint8_t	pri6_cos_queue_id;
-	/*
-	 * CoS Queue assigned to priority 7. This value can only
-	 * be changed before traffic has started.
-	 * A value of 0xff indicates that no CoS queue is assigned to the
-	 * specified priority.
-	 */
-	uint8_t	pri7_cos_queue_id;
-	/* Information about queue configuration. */
-	uint8_t	queue_cfg_info;
-	/*
-	 * If this flag is set to '1', then the PRI to CoS
-	 * configuration is asymmetric on TX and RX sides.
-	 * If this flag is set to '0', then PRI to CoS configuration
-	 * is symmetric on TX and RX sides.
-	 */
-	#define HWRM_QUEUE_PRI2COS_QCFG_OUTPUT_QUEUE_CFG_INFO_ASYM_CFG	UINT32_C(0x1)
-	uint8_t	unused_0[6];
+	/* unused. */
+	uint8_t	unused0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_queue_pri2cos_qcfg_output_t, *phwrm_queue_pri2cos_qcfg_output_t;
+} hwrm_tf_session_resc_flush_output_t, *phwrm_tf_session_resc_flush_output_t;
 
-/**************************
- * hwrm_queue_pri2cos_cfg *
- **************************/
+/*****************************
+ * hwrm_tf_session_resc_info *
+ *****************************/
 
 
-/* hwrm_queue_pri2cos_cfg_input (size:320b/40B) */
+/* hwrm_tf_session_resc_info_input (size:320b/40B) */
 
-typedef struct hwrm_queue_pri2cos_cfg_input {
+typedef struct hwrm_tf_session_resc_info_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -25919,121 +53776,42 @@ typedef struct hwrm_queue_pri2cos_cfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	flags;
-	/*
-	 * Enumeration denoting the RX, TX, or both directions applicable to the resource.
-	 * This enumeration is used for resources that are similar for both
-	 * TX and RX paths of the chip.
-	 */
-	#define HWRM_QUEUE_PRI2COS_CFG_INPUT_FLAGS_PATH_MASK UINT32_C(0x3)
-	#define HWRM_QUEUE_PRI2COS_CFG_INPUT_FLAGS_PATH_SFT  0
-	/* tx path */
-		#define HWRM_QUEUE_PRI2COS_CFG_INPUT_FLAGS_PATH_TX	UINT32_C(0x0)
-	/* rx path */
-		#define HWRM_QUEUE_PRI2COS_CFG_INPUT_FLAGS_PATH_RX	UINT32_C(0x1)
-	/* Bi-directional (Symmetrically applicable to TX and RX paths) */
-		#define HWRM_QUEUE_PRI2COS_CFG_INPUT_FLAGS_PATH_BIDIR  UINT32_C(0x2)
-		#define HWRM_QUEUE_PRI2COS_CFG_INPUT_FLAGS_PATH_LAST  HWRM_QUEUE_PRI2COS_CFG_INPUT_FLAGS_PATH_BIDIR
-	/*
-	 * When this bit is set to '0', the mapping is requested
-	 * for PRI from tunnel headers.
-	 * When this bit is set to '1', the mapping is requested
-	 * for PRI from inner packet headers.
-	 */
-	#define HWRM_QUEUE_PRI2COS_CFG_INPUT_FLAGS_IVLAN	UINT32_C(0x4)
-	uint32_t	enables;
-	/*
-	 * This bit must be '1' for the pri0_cos_queue_id field to be
-	 * configured.
-	 */
-	#define HWRM_QUEUE_PRI2COS_CFG_INPUT_ENABLES_PRI0_COS_QUEUE_ID	UINT32_C(0x1)
-	/*
-	 * This bit must be '1' for the pri1_cos_queue_id field to be
-	 * configured.
-	 */
-	#define HWRM_QUEUE_PRI2COS_CFG_INPUT_ENABLES_PRI1_COS_QUEUE_ID	UINT32_C(0x2)
-	/*
-	 * This bit must be '1' for the pri2_cos_queue_id field to be
-	 * configured.
-	 */
-	#define HWRM_QUEUE_PRI2COS_CFG_INPUT_ENABLES_PRI2_COS_QUEUE_ID	UINT32_C(0x4)
-	/*
-	 * This bit must be '1' for the pri3_cos_queue_id field to be
-	 * configured.
-	 */
-	#define HWRM_QUEUE_PRI2COS_CFG_INPUT_ENABLES_PRI3_COS_QUEUE_ID	UINT32_C(0x8)
-	/*
-	 * This bit must be '1' for the pri4_cos_queue_id field to be
-	 * configured.
-	 */
-	#define HWRM_QUEUE_PRI2COS_CFG_INPUT_ENABLES_PRI4_COS_QUEUE_ID	UINT32_C(0x10)
-	/*
-	 * This bit must be '1' for the pri5_cos_queue_id field to be
-	 * configured.
-	 */
-	#define HWRM_QUEUE_PRI2COS_CFG_INPUT_ENABLES_PRI5_COS_QUEUE_ID	UINT32_C(0x20)
-	/*
-	 * This bit must be '1' for the pri6_cos_queue_id field to be
-	 * configured.
-	 */
-	#define HWRM_QUEUE_PRI2COS_CFG_INPUT_ENABLES_PRI6_COS_QUEUE_ID	UINT32_C(0x40)
-	/*
-	 * This bit must be '1' for the pri7_cos_queue_id field to be
-	 * configured.
-	 */
-	#define HWRM_QUEUE_PRI2COS_CFG_INPUT_ENABLES_PRI7_COS_QUEUE_ID	UINT32_C(0x80)
-	/*
-	 * Port ID of port for which the table is being configured.
-	 * The HWRM needs to check whether this function is allowed
-	 * to configure pri2cos mapping on this port.
-	 */
-	uint8_t	port_id;
-	/*
-	 * CoS Queue assigned to priority 0. This value can only
-	 * be changed before traffic has started.
-	 */
-	uint8_t	pri0_cos_queue_id;
-	/*
-	 * CoS Queue assigned to priority 1. This value can only
-	 * be changed before traffic has started.
-	 */
-	uint8_t	pri1_cos_queue_id;
-	/*
-	 * CoS Queue assigned to priority 2  This value can only
-	 * be changed before traffic has started.
-	 */
-	uint8_t	pri2_cos_queue_id;
-	/*
-	 * CoS Queue assigned to priority 3. This value can only
-	 * be changed before traffic has started.
-	 */
-	uint8_t	pri3_cos_queue_id;
-	/*
-	 * CoS Queue assigned to priority 4. This value can only
-	 * be changed before traffic has started.
-	 */
-	uint8_t	pri4_cos_queue_id;
+	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
+	uint32_t	fw_session_id;
+	/* Control flags. */
+	uint16_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TF_SESSION_RESC_INFO_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TF_SESSION_RESC_INFO_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TF_SESSION_RESC_INFO_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TF_SESSION_RESC_INFO_INPUT_FLAGS_DIR_LAST HWRM_TF_SESSION_RESC_INFO_INPUT_FLAGS_DIR_TX
 	/*
-	 * CoS Queue assigned to priority 5. This value can only
-	 * be changed before traffic has started.
+	 * Defines the array size of the provided req_addr and
+	 * resv_addr array buffers. Should be set to the number of
+	 * request entries.
 	 */
-	uint8_t	pri5_cos_queue_id;
+	uint16_t	req_size;
 	/*
-	 * CoS Queue assigned to priority 6. This value can only
-	 * be changed before traffic has started.
+	 * This is the DMA address for the request input data array
+	 * buffer. Array is of tf_rm_resc_req_entry type. Size of the
+	 * array buffer is provided by the 'req_size' field in this
+	 * message.
 	 */
-	uint8_t	pri6_cos_queue_id;
+	uint64_t	req_addr;
 	/*
-	 * CoS Queue assigned to priority 7. This value can only
-	 * be changed before traffic has started.
+	 * This is the DMA address for the resc output data array
+	 * buffer. Array is of tf_rm_resc_entry type. Size of the array
+	 * buffer is provided by the 'req_size' field in this
+	 * message.
 	 */
-	uint8_t	pri7_cos_queue_id;
-	uint8_t	unused_0[7];
-} hwrm_queue_pri2cos_cfg_input_t, *phwrm_queue_pri2cos_cfg_input_t;
+	uint64_t	resc_addr;
+} hwrm_tf_session_resc_info_input_t, *phwrm_tf_session_resc_info_input_t;
 
-/* hwrm_queue_pri2cos_cfg_output (size:128b/16B) */
+/* hwrm_tf_session_resc_info_output (size:128b/16B) */
 
-typedef struct hwrm_queue_pri2cos_cfg_output {
+typedef struct hwrm_tf_session_resc_info_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -26042,25 +53820,58 @@ typedef struct hwrm_queue_pri2cos_cfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	/*
+	 * Size of the returned tf_rm_resc_entry data array. The value
+	 * cannot exceed the req_size defined by the input msg. The data
+	 * array is returned using the resv_addr specified DMA
+	 * address also provided by the input msg.
+	 */
+	uint16_t	size;
+	/* unused. */
+	uint8_t	unused0[5];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_queue_pri2cos_cfg_output_t, *phwrm_queue_pri2cos_cfg_output_t;
+} hwrm_tf_session_resc_info_output_t, *phwrm_tf_session_resc_info_output_t;
+
+/* TruFlow RM capability of a resource. */
+/* tf_rm_resc_req_entry (size:64b/8B) */
+
+typedef struct tf_rm_resc_req_entry {
+	/* Type of the resource, defined globally in HCAPI RM. */
+	uint32_t	type;
+	/* Minimum value. */
+	uint16_t	min;
+	/* Maximum value. */
+	uint16_t	max;
+} tf_rm_resc_req_entry_t, *ptf_rm_resc_req_entry_t;
+
+/* TruFlow RM reservation information. */
+/* tf_rm_resc_entry (size:64b/8B) */
+
+typedef struct tf_rm_resc_entry {
+	/* Type of the resource, defined globally in HCAPI RM. */
+	uint32_t	type;
+	/* Start offset. */
+	uint16_t	start;
+	/* Number of resources. */
+	uint16_t	stride;
+} tf_rm_resc_entry_t, *ptf_rm_resc_entry_t;
 
 /**************************
- * hwrm_queue_cos2bw_qcfg *
+ * hwrm_tf_tbl_type_alloc *
  **************************/
 
 
-/* hwrm_queue_cos2bw_qcfg_input (size:192b/24B) */
+/* hwrm_tf_tbl_type_alloc_input (size:192b/24B) */
 
-typedef struct hwrm_queue_cos2bw_qcfg_input {
+typedef struct hwrm_tf_tbl_type_alloc_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -26089,18 +53900,39 @@ typedef struct hwrm_queue_cos2bw_qcfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/*
-	 * Port ID of port for which the table is being configured.
-	 * The HWRM needs to check whether this function is allowed
-	 * to configure TC BW assignment on this port.
+	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
+	uint32_t	fw_session_id;
+	/* Control flags. */
+	uint16_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TF_TBL_TYPE_ALLOC_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TF_TBL_TYPE_ALLOC_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TF_TBL_TYPE_ALLOC_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TF_TBL_TYPE_ALLOC_INPUT_FLAGS_DIR_LAST HWRM_TF_TBL_TYPE_ALLOC_INPUT_FLAGS_DIR_TX
+	/* Specifies which block this idx table alloc request is for */
+	uint8_t	blktype;
+	/* CFA block type */
+	#define HWRM_TF_TBL_TYPE_ALLOC_INPUT_BLKTYPE_BLKTYPE_CFA	UINT32_C(0x0)
+	/* RXP gparse block type */
+	#define HWRM_TF_TBL_TYPE_ALLOC_INPUT_BLKTYPE_BLKTYPE_RXP	UINT32_C(0x1)
+	/* RE gparse block type */
+	#define HWRM_TF_TBL_TYPE_ALLOC_INPUT_BLKTYPE_BLKTYPE_RE_GPARSE UINT32_C(0x2)
+	/* TE gparse block type */
+	#define HWRM_TF_TBL_TYPE_ALLOC_INPUT_BLKTYPE_BLKTYPE_TE_GPARSE UINT32_C(0x3)
+	#define HWRM_TF_TBL_TYPE_ALLOC_INPUT_BLKTYPE_LAST		HWRM_TF_TBL_TYPE_ALLOC_INPUT_BLKTYPE_BLKTYPE_TE_GPARSE
+	/*
+	 * This field is blktype specific. For any of the UPAR types it is
+	 * set to a non-zero value in case of a re-alloc, specifies a
+	 * tunnel-type of dynamic UPAR tunnel.
 	 */
-	uint16_t	port_id;
-	uint8_t	unused_0[6];
-} hwrm_queue_cos2bw_qcfg_input_t, *phwrm_queue_cos2bw_qcfg_input_t;
+	uint8_t	type;
+} hwrm_tf_tbl_type_alloc_input_t, *phwrm_tf_tbl_type_alloc_input_t;
 
-/* hwrm_queue_cos2bw_qcfg_output (size:896b/112B) */
+/* hwrm_tf_tbl_type_alloc_output (size:128b/16B) */
 
-typedef struct hwrm_queue_cos2bw_qcfg_output {
+typedef struct hwrm_tf_tbl_type_alloc_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -26109,731 +53941,520 @@ typedef struct hwrm_queue_cos2bw_qcfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* ID of CoS Queue 0. */
-	uint8_t	queue_id0;
-	uint8_t	unused_0;
-	uint16_t	unused_1;
-	/*
-	 * Minimum BW allocated to CoS Queue.
-	 * The HWRM will translate this value into byte counter and
-	 * time interval used for this COS inside the device.
-	 */
-	uint32_t	queue_id0_min_bw;
-	/* The bandwidth value. */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MIN_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MIN_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MIN_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MIN_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_INVALID
-	/*
-	 * Maximum BW allocated to CoS Queue.
-	 * The HWRM will translate this value into byte counter and
-	 * time interval used for this COS inside the device.
-	 */
-	uint32_t	queue_id0_max_bw;
-	/* The bandwidth value. */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MAX_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MAX_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MAX_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MAX_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_INVALID
-	/* Transmission Selection Algorithm (TSA) for CoS Queue. */
-	uint8_t	queue_id0_tsa_assign;
-	/* Strict Priority */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_TSA_ASSIGN_SP		UINT32_C(0x0)
-	/* Enhanced Transmission Selection */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_TSA_ASSIGN_ETS		UINT32_C(0x1)
-	/* reserved. */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_TSA_ASSIGN_RESERVED_FIRST UINT32_C(0x2)
-	/* reserved. */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID0_TSA_ASSIGN_RESERVED_LAST  UINT32_C(0xff)
-	/*
-	 * Priority level for strict priority. Valid only when the
-	 * tsa_assign is 0 - Strict Priority (SP)
-	 * 0..7 - Valid values.
-	 * 8..255 - Reserved.
-	 */
-	uint8_t	queue_id0_pri_lvl;
-	/*
-	 * Weight used to allocate remaining BW for this COS after
-	 * servicing guaranteed bandwidths for all COS.
-	 */
-	uint8_t	queue_id0_bw_weight;
-	/* ID of CoS Queue 1. */
-	uint8_t	queue_id1;
-	/*
-	 * Minimum BW allocated to CoS Queue.
-	 * The HWRM will translate this value into byte counter and
-	 * time interval used for this COS inside the device.
-	 */
-	uint32_t	queue_id1_min_bw;
-	/* The bandwidth value. */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MIN_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MIN_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MIN_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MIN_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_INVALID
+	/* Response code. */
+	uint32_t	resp_code;
 	/*
-	 * Maximum BW allocated to CoS queue.
-	 * The HWRM will translate this value into byte counter and
-	 * time interval used for this COS inside the device.
+	 * Table entry allocated by the firmware using the
+	 * parameters above.
 	 */
-	uint32_t	queue_id1_max_bw;
-	/* The bandwidth value. */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MAX_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MAX_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MAX_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MAX_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_INVALID
-	/* Transmission Selection Algorithm (TSA) for CoS Queue. */
-	uint8_t	queue_id1_tsa_assign;
-	/* Strict Priority */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_TSA_ASSIGN_SP		UINT32_C(0x0)
-	/* Enhanced Transmission Selection */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_TSA_ASSIGN_ETS		UINT32_C(0x1)
-	/* reserved. */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_TSA_ASSIGN_RESERVED_FIRST UINT32_C(0x2)
-	/* reserved. */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID1_TSA_ASSIGN_RESERVED_LAST  UINT32_C(0xff)
+	uint16_t	idx_tbl_id;
+	/* unused */
+	uint8_t	unused0;
 	/*
-	 * Priority level for strict priority. Valid only when the
-	 * tsa_assign is 0 - Strict Priority (SP)
-	 * 0..7 - Valid values.
-	 * 8..255 - Reserved.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
-	uint8_t	queue_id1_pri_lvl;
+	uint8_t	valid;
+} hwrm_tf_tbl_type_alloc_output_t, *phwrm_tf_tbl_type_alloc_output_t;
+
+/************************
+ * hwrm_tf_tbl_type_get *
+ ************************/
+
+
+/* hwrm_tf_tbl_type_get_input (size:256b/32B) */
+
+typedef struct hwrm_tf_tbl_type_get_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * Weight used to allocate remaining BW for this COS after
-	 * servicing guaranteed bandwidths for all COS.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint8_t	queue_id1_bw_weight;
-	/* ID of CoS Queue 2. */
-	uint8_t	queue_id2;
+	uint16_t	cmpl_ring;
 	/*
-	 * Minimum BW allocated to CoS Queue.
-	 * The HWRM will translate this value into byte counter and
-	 * time interval used for this COS inside the device.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint32_t	queue_id2_min_bw;
-	/* The bandwidth value. */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MIN_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MIN_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MIN_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MIN_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_INVALID
+	uint16_t	seq_id;
 	/*
-	 * Maximum BW allocated to CoS queue.
-	 * The HWRM will translate this value into byte counter and
-	 * time interval used for this COS inside the device.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint32_t	queue_id2_max_bw;
-	/* The bandwidth value. */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MAX_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MAX_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MAX_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MAX_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_INVALID
-	/* Transmission Selection Algorithm (TSA) for CoS Queue. */
-	uint8_t	queue_id2_tsa_assign;
-	/* Strict Priority */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_TSA_ASSIGN_SP		UINT32_C(0x0)
-	/* Enhanced Transmission Selection */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_TSA_ASSIGN_ETS		UINT32_C(0x1)
-	/* reserved. */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_TSA_ASSIGN_RESERVED_FIRST UINT32_C(0x2)
-	/* reserved. */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID2_TSA_ASSIGN_RESERVED_LAST  UINT32_C(0xff)
+	uint16_t	target_id;
 	/*
-	 * Priority level for strict priority. Valid only when the
-	 * tsa_assign is 0 - Strict Priority (SP)
-	 * 0..7 - Valid values.
-	 * 8..255 - Reserved.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint8_t	queue_id2_pri_lvl;
+	uint64_t	resp_addr;
+	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
+	uint32_t	fw_session_id;
+	/* Control flags. */
+	uint16_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TF_TBL_TYPE_GET_INPUT_FLAGS_DIR		UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TF_TBL_TYPE_GET_INPUT_FLAGS_DIR_RX		UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TF_TBL_TYPE_GET_INPUT_FLAGS_DIR_TX		UINT32_C(0x1)
+		#define HWRM_TF_TBL_TYPE_GET_INPUT_FLAGS_DIR_LAST	HWRM_TF_TBL_TYPE_GET_INPUT_FLAGS_DIR_TX
+	/*
+	 * When set use the special access register access to clear
+	 * the table entry on read.
+	 */
+	#define HWRM_TF_TBL_TYPE_GET_INPUT_FLAGS_CLEAR_ON_READ	UINT32_C(0x2)
+	/* Specifies which block this idx table alloc request is for */
+	uint8_t	blktype;
+	/* CFA block type */
+	#define HWRM_TF_TBL_TYPE_GET_INPUT_BLKTYPE_BLKTYPE_CFA	UINT32_C(0x0)
+	/* RXP gparse block type */
+	#define HWRM_TF_TBL_TYPE_GET_INPUT_BLKTYPE_BLKTYPE_RXP	UINT32_C(0x1)
+	/* RE gparse block type */
+	#define HWRM_TF_TBL_TYPE_GET_INPUT_BLKTYPE_BLKTYPE_RE_GPARSE UINT32_C(0x2)
+	/* TE gparse block type */
+	#define HWRM_TF_TBL_TYPE_GET_INPUT_BLKTYPE_BLKTYPE_TE_GPARSE UINT32_C(0x3)
+	#define HWRM_TF_TBL_TYPE_GET_INPUT_BLKTYPE_LAST		HWRM_TF_TBL_TYPE_GET_INPUT_BLKTYPE_BLKTYPE_TE_GPARSE
+	/* unused. */
+	uint8_t	unused0;
 	/*
-	 * Weight used to allocate remaining BW for this COS after
-	 * servicing guaranteed bandwidths for all COS.
+	 * Type of the resource, defined globally in the
+	 * hwrm_tf_resc_type enum.
 	 */
-	uint8_t	queue_id2_bw_weight;
-	/* ID of CoS Queue 3. */
-	uint8_t	queue_id3;
+	uint32_t	type;
+	/* Index of the type to retrieve. */
+	uint32_t	index;
+} hwrm_tf_tbl_type_get_input_t, *phwrm_tf_tbl_type_get_input_t;
+
+/* hwrm_tf_tbl_type_get_output (size:2240b/280B) */
+
+typedef struct hwrm_tf_tbl_type_get_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Response code. */
+	uint32_t	resp_code;
+	/* Response size. */
+	uint16_t	size;
+	/* unused */
+	uint16_t	unused0;
+	/* Response data. */
+	uint8_t	data[256];
+	/* unused */
+	uint8_t	unused1[7];
 	/*
-	 * Minimum BW allocated to CoS Queue.
-	 * The HWRM will translate this value into byte counter and
-	 * time interval used for this COS inside the device.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
-	uint32_t	queue_id3_min_bw;
-	/* The bandwidth value. */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MIN_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MIN_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MIN_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MIN_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_INVALID
+	uint8_t	valid;
+} hwrm_tf_tbl_type_get_output_t, *phwrm_tf_tbl_type_get_output_t;
+
+/************************
+ * hwrm_tf_tbl_type_set *
+ ************************/
+
+
+/* hwrm_tf_tbl_type_set_input (size:1024b/128B) */
+
+typedef struct hwrm_tf_tbl_type_set_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * Maximum BW allocated to CoS queue.
-	 * The HWRM will translate this value into byte counter and
-	 * time interval used for this COS inside the device.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint32_t	queue_id3_max_bw;
-	/* The bandwidth value. */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MAX_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MAX_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MAX_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MAX_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_INVALID
-	/* Transmission Selection Algorithm (TSA) for CoS Queue. */
-	uint8_t	queue_id3_tsa_assign;
-	/* Strict Priority */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_TSA_ASSIGN_SP		UINT32_C(0x0)
-	/* Enhanced Transmission Selection */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_TSA_ASSIGN_ETS		UINT32_C(0x1)
-	/* reserved. */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_TSA_ASSIGN_RESERVED_FIRST UINT32_C(0x2)
-	/* reserved. */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID3_TSA_ASSIGN_RESERVED_LAST  UINT32_C(0xff)
+	uint16_t	cmpl_ring;
 	/*
-	 * Priority level for strict priority. Valid only when the
-	 * tsa_assign is 0 - Strict Priority (SP)
-	 * 0..7 - Valid values.
-	 * 8..255 - Reserved.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint8_t	queue_id3_pri_lvl;
+	uint16_t	seq_id;
 	/*
-	 * Weight used to allocate remaining BW for this COS after
-	 * servicing guaranteed bandwidths for all COS.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint8_t	queue_id3_bw_weight;
-	/* ID of CoS Queue 4. */
-	uint8_t	queue_id4;
+	uint16_t	target_id;
 	/*
-	 * Minimum BW allocated to CoS Queue.
-	 * The HWRM will translate this value into byte counter and
-	 * time interval used for this COS inside the device.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint32_t	queue_id4_min_bw;
-	/* The bandwidth value. */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MIN_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MIN_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MIN_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MIN_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_INVALID
+	uint64_t	resp_addr;
+	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
+	uint32_t	fw_session_id;
+	/* Control flags. */
+	uint16_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TF_TBL_TYPE_SET_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TF_TBL_TYPE_SET_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TF_TBL_TYPE_SET_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TF_TBL_TYPE_SET_INPUT_FLAGS_DIR_LAST HWRM_TF_TBL_TYPE_SET_INPUT_FLAGS_DIR_TX
+	/* Indicate table data is being sent via DMA. */
+	#define HWRM_TF_TBL_TYPE_SET_INPUT_FLAGS_DMA	UINT32_C(0x2)
+	/* Specifies which block this idx table alloc request is for */
+	uint8_t	blktype;
+	/* CFA block type */
+	#define HWRM_TF_TBL_TYPE_SET_INPUT_BLKTYPE_BLKTYPE_CFA	UINT32_C(0x0)
+	/* RXP gparse block type */
+	#define HWRM_TF_TBL_TYPE_SET_INPUT_BLKTYPE_BLKTYPE_RXP	UINT32_C(0x1)
+	/* RE gparse block type */
+	#define HWRM_TF_TBL_TYPE_SET_INPUT_BLKTYPE_BLKTYPE_RE_GPARSE UINT32_C(0x2)
+	/* TE gparse block type */
+	#define HWRM_TF_TBL_TYPE_SET_INPUT_BLKTYPE_BLKTYPE_TE_GPARSE UINT32_C(0x3)
+	#define HWRM_TF_TBL_TYPE_SET_INPUT_BLKTYPE_LAST		HWRM_TF_TBL_TYPE_SET_INPUT_BLKTYPE_BLKTYPE_TE_GPARSE
+	/* unused. */
+	uint8_t	unused0;
 	/*
-	 * Maximum BW allocated to CoS queue.
-	 * The HWRM will translate this value into byte counter and
-	 * time interval used for this COS inside the device.
+	 * Type of the resource, defined globally in the
+	 * hwrm_tf_resc_type enum.
 	 */
-	uint32_t	queue_id4_max_bw;
-	/* The bandwidth value. */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MAX_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MAX_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MAX_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MAX_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_INVALID
-	/* Transmission Selection Algorithm (TSA) for CoS Queue. */
-	uint8_t	queue_id4_tsa_assign;
-	/* Strict Priority */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_TSA_ASSIGN_SP		UINT32_C(0x0)
-	/* Enhanced Transmission Selection */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_TSA_ASSIGN_ETS		UINT32_C(0x1)
-	/* reserved. */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_TSA_ASSIGN_RESERVED_FIRST UINT32_C(0x2)
-	/* reserved. */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID4_TSA_ASSIGN_RESERVED_LAST  UINT32_C(0xff)
+	uint32_t	type;
+	/* Index of the type to retrieve. */
+	uint32_t	index;
+	/* Size of the data to set. */
+	uint16_t	size;
+	/* unused */
+	uint8_t	unused1[6];
+	/* Data to be set. */
+	uint8_t	data[88];
+} hwrm_tf_tbl_type_set_input_t, *phwrm_tf_tbl_type_set_input_t;
+
+/* hwrm_tf_tbl_type_set_output (size:128b/16B) */
+
+typedef struct hwrm_tf_tbl_type_set_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* unused. */
+	uint8_t	unused0[7];
 	/*
-	 * Priority level for strict priority. Valid only when the
-	 * tsa_assign is 0 - Strict Priority (SP)
-	 * 0..7 - Valid values.
-	 * 8..255 - Reserved.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
-	uint8_t	queue_id4_pri_lvl;
+	uint8_t	valid;
+} hwrm_tf_tbl_type_set_output_t, *phwrm_tf_tbl_type_set_output_t;
+
+/*************************
+ * hwrm_tf_tbl_type_free *
+ *************************/
+
+
+/* hwrm_tf_tbl_type_free_input (size:256b/32B) */
+
+typedef struct hwrm_tf_tbl_type_free_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * Weight used to allocate remaining BW for this COS after
-	 * servicing guaranteed bandwidths for all COS.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint8_t	queue_id4_bw_weight;
-	/* ID of CoS Queue 5. */
-	uint8_t	queue_id5;
+	uint16_t	cmpl_ring;
 	/*
-	 * Minimum BW allocated to CoS Queue.
-	 * The HWRM will translate this value into byte counter and
-	 * time interval used for this COS inside the device.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint32_t	queue_id5_min_bw;
-	/* The bandwidth value. */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MIN_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MIN_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MIN_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MIN_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_INVALID
+	uint16_t	seq_id;
 	/*
-	 * Maximum BW allocated to CoS queue.
-	 * The HWRM will translate this value into byte counter and
-	 * time interval used for this COS inside the device.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint32_t	queue_id5_max_bw;
-	/* The bandwidth value. */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MAX_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MAX_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MAX_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MAX_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_INVALID
-	/* Transmission Selection Algorithm (TSA) for CoS Queue. */
-	uint8_t	queue_id5_tsa_assign;
-	/* Strict Priority */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_TSA_ASSIGN_SP		UINT32_C(0x0)
-	/* Enhanced Transmission Selection */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_TSA_ASSIGN_ETS		UINT32_C(0x1)
-	/* reserved. */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_TSA_ASSIGN_RESERVED_FIRST UINT32_C(0x2)
-	/* reserved. */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID5_TSA_ASSIGN_RESERVED_LAST  UINT32_C(0xff)
+	uint16_t	target_id;
 	/*
-	 * Priority level for strict priority. Valid only when the
-	 * tsa_assign is 0 - Strict Priority (SP)
-	 * 0..7 - Valid values.
-	 * 8..255 - Reserved.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint8_t	queue_id5_pri_lvl;
+	uint64_t	resp_addr;
+	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
+	uint32_t	fw_session_id;
+	/* Control flags. */
+	uint16_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TF_TBL_TYPE_FREE_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TF_TBL_TYPE_FREE_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TF_TBL_TYPE_FREE_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TF_TBL_TYPE_FREE_INPUT_FLAGS_DIR_LAST HWRM_TF_TBL_TYPE_FREE_INPUT_FLAGS_DIR_TX
+	/* Specifies which block this idx table alloc request is for */
+	uint8_t	blktype;
+	/* CFA block type */
+	#define HWRM_TF_TBL_TYPE_FREE_INPUT_BLKTYPE_BLKTYPE_CFA	UINT32_C(0x0)
+	/* RXP gparse block type */
+	#define HWRM_TF_TBL_TYPE_FREE_INPUT_BLKTYPE_BLKTYPE_RXP	UINT32_C(0x1)
+	/* RE gparse block type */
+	#define HWRM_TF_TBL_TYPE_FREE_INPUT_BLKTYPE_BLKTYPE_RE_GPARSE UINT32_C(0x2)
+	/* TE gparse block type */
+	#define HWRM_TF_TBL_TYPE_FREE_INPUT_BLKTYPE_BLKTYPE_TE_GPARSE UINT32_C(0x3)
+	#define HWRM_TF_TBL_TYPE_FREE_INPUT_BLKTYPE_LAST		HWRM_TF_TBL_TYPE_FREE_INPUT_BLKTYPE_BLKTYPE_TE_GPARSE
+	/* Unused */
+	uint8_t	unused0;
 	/*
-	 * Weight used to allocate remaining BW for this COS after
-	 * servicing guaranteed bandwidths for all COS.
+	 * Table entry to be freed by the firmware using the parameters
+	 * above.
 	 */
-	uint8_t	queue_id5_bw_weight;
-	/* ID of CoS Queue 6. */
-	uint8_t	queue_id6;
+	uint16_t	idx_tbl_id;
+	/* Unused */
+	uint8_t	unused1[6];
+} hwrm_tf_tbl_type_free_input_t, *phwrm_tf_tbl_type_free_input_t;
+
+/* hwrm_tf_tbl_type_free_output (size:128b/16B) */
+
+typedef struct hwrm_tf_tbl_type_free_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Response code. */
+	uint32_t	resp_code;
+	/* unused */
+	uint8_t	unused0[3];
 	/*
-	 * Minimum BW allocated to CoS Queue.
-	 * The HWRM will translate this value into byte counter and
-	 * time interval used for this COS inside the device.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
-	uint32_t	queue_id6_min_bw;
-	/* The bandwidth value. */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MIN_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MIN_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MIN_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MIN_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_INVALID
+	uint8_t	valid;
+} hwrm_tf_tbl_type_free_output_t, *phwrm_tf_tbl_type_free_output_t;
+
+/*********************
+ * hwrm_tf_em_insert *
+ *********************/
+
+
+/* hwrm_tf_em_insert_input (size:832b/104B) */
+
+typedef struct hwrm_tf_em_insert_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * Maximum BW allocated to CoS queue.
-	 * The HWRM will translate this value into byte counter and
-	 * time interval used for this COS inside the device.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint32_t	queue_id6_max_bw;
-	/* The bandwidth value. */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MAX_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MAX_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MAX_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MAX_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_INVALID
-	/* Transmission Selection Algorithm (TSA) for CoS Queue. */
-	uint8_t	queue_id6_tsa_assign;
-	/* Strict Priority */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_TSA_ASSIGN_SP		UINT32_C(0x0)
-	/* Enhanced Transmission Selection */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_TSA_ASSIGN_ETS		UINT32_C(0x1)
-	/* reserved. */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_TSA_ASSIGN_RESERVED_FIRST UINT32_C(0x2)
-	/* reserved. */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID6_TSA_ASSIGN_RESERVED_LAST  UINT32_C(0xff)
+	uint16_t	cmpl_ring;
 	/*
-	 * Priority level for strict priority. Valid only when the
-	 * tsa_assign is 0 - Strict Priority (SP)
-	 * 0..7 - Valid values.
-	 * 8..255 - Reserved.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint8_t	queue_id6_pri_lvl;
+	uint16_t	seq_id;
 	/*
-	 * Weight used to allocate remaining BW for this COS after
-	 * servicing guaranteed bandwidths for all COS.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint8_t	queue_id6_bw_weight;
-	/* ID of CoS Queue 7. */
-	uint8_t	queue_id7;
+	uint16_t	target_id;
 	/*
-	 * Minimum BW allocated to CoS Queue.
-	 * The HWRM will translate this value into byte counter and
-	 * time interval used for this COS inside the device.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint32_t	queue_id7_min_bw;
-	/* The bandwidth value. */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MIN_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MIN_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MIN_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MIN_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_INVALID
+	uint64_t	resp_addr;
+	/* Firmware Session Id. */
+	uint32_t	fw_session_id;
+	/* Control Flags. */
+	uint16_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TF_EM_INSERT_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TF_EM_INSERT_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TF_EM_INSERT_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TF_EM_INSERT_INPUT_FLAGS_DIR_LAST HWRM_TF_EM_INSERT_INPUT_FLAGS_DIR_TX
+	/* Reported match strength. */
+	uint16_t	strength;
+	/* Index to action. */
+	uint32_t	action_ptr;
+	/* Index of EM record. */
+	uint32_t	em_record_idx;
+	/* EM Key value. */
+	uint64_t	em_key[8];
+	/* Number of bits in em_key. */
+	uint16_t	em_key_bitlen;
+	/* unused. */
+	uint16_t	unused0[3];
+} hwrm_tf_em_insert_input_t, *phwrm_tf_em_insert_input_t;
+
+/* hwrm_tf_em_insert_output (size:128b/16B) */
+
+typedef struct hwrm_tf_em_insert_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* EM record pointer index. */
+	uint16_t	rptr_index;
+	/* EM record offset 0~3. */
+	uint8_t	rptr_entry;
+	/* Number of word entries consumed by the key. */
+	uint8_t	num_of_entries;
+	/* unused. */
+	uint8_t	unused0[3];
 	/*
-	 * Maximum BW allocated to CoS queue.
-	 * The HWRM will translate this value into byte counter and
-	 * time interval used for this COS inside the device.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
-	uint32_t	queue_id7_max_bw;
-	/* The bandwidth value. */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MAX_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MAX_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MAX_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MAX_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_INVALID
-	/* Transmission Selection Algorithm (TSA) for CoS Queue. */
-	uint8_t	queue_id7_tsa_assign;
-	/* Strict Priority */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_TSA_ASSIGN_SP		UINT32_C(0x0)
-	/* Enhanced Transmission Selection */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_TSA_ASSIGN_ETS		UINT32_C(0x1)
-	/* reserved. */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_TSA_ASSIGN_RESERVED_FIRST UINT32_C(0x2)
-	/* reserved. */
-	#define HWRM_QUEUE_COS2BW_QCFG_OUTPUT_QUEUE_ID7_TSA_ASSIGN_RESERVED_LAST  UINT32_C(0xff)
+	uint8_t	valid;
+} hwrm_tf_em_insert_output_t, *phwrm_tf_em_insert_output_t;
+
+/**************************
+ * hwrm_tf_em_hash_insert *
+ **************************/
+
+
+/* hwrm_tf_em_hash_insert_input (size:1024b/128B) */
+
+typedef struct hwrm_tf_em_hash_insert_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * Priority level for strict priority. Valid only when the
-	 * tsa_assign is 0 - Strict Priority (SP)
-	 * 0..7 - Valid values.
-	 * 8..255 - Reserved.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint8_t	queue_id7_pri_lvl;
+	uint16_t	cmpl_ring;
 	/*
-	 * Weight used to allocate remaining BW for this COS after
-	 * servicing guaranteed bandwidths for all COS.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint8_t	queue_id7_bw_weight;
-	uint8_t	unused_2[4];
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Firmware Session Id. */
+	uint32_t	fw_session_id;
+	/* Control Flags. */
+	uint16_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TF_EM_HASH_INSERT_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TF_EM_HASH_INSERT_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TF_EM_HASH_INSERT_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TF_EM_HASH_INSERT_INPUT_FLAGS_DIR_LAST HWRM_TF_EM_HASH_INSERT_INPUT_FLAGS_DIR_TX
+	/* Indicates table data is being sent via DMA. */
+	#define HWRM_TF_EM_HASH_INSERT_INPUT_FLAGS_DMA	UINT32_C(0x2)
+	/* Number of bits in the EM record. */
+	uint16_t	em_record_size_bits;
+	/* CRC32 hash of key. */
+	uint32_t	key0_hash;
+	/* Lookup3 hash of key. */
+	uint32_t	key1_hash;
+	/* Index of EM record. */
+	uint32_t	em_record_idx;
+	/* Unused. */
+	uint32_t	unused0;
+	/* EM record. */
+	uint64_t	em_record[11];
+} hwrm_tf_em_hash_insert_input_t, *phwrm_tf_em_hash_insert_input_t;
+
+/* hwrm_tf_em_hash_insert_output (size:128b/16B) */
+
+typedef struct hwrm_tf_em_hash_insert_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* EM record pointer index. */
+	uint16_t	rptr_index;
+	/* EM record offset 0~3. */
+	uint8_t	rptr_entry;
+	/* Number of word entries consumed by the key. */
+	uint8_t	num_of_entries;
+	/* unused. */
+	uint8_t	unused0[3];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
 	uint8_t	valid;
-} hwrm_queue_cos2bw_qcfg_output_t, *phwrm_queue_cos2bw_qcfg_output_t;
+} hwrm_tf_em_hash_insert_output_t, *phwrm_tf_em_hash_insert_output_t;
 
-/*************************
- * hwrm_queue_cos2bw_cfg *
- *************************/
+/*********************
+ * hwrm_tf_em_delete *
+ *********************/
 
 
-/* hwrm_queue_cos2bw_cfg_input (size:1024b/128B) */
+/* hwrm_tf_em_delete_input (size:832b/104B) */
 
-typedef struct hwrm_queue_cos2bw_cfg_input {
+typedef struct hwrm_tf_em_delete_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -26862,765 +54483,653 @@ typedef struct hwrm_queue_cos2bw_cfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	flags;
-	uint32_t	enables;
+	/* Session Id. */
+	uint32_t	fw_session_id;
+	/* Control flags. */
+	uint16_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TF_EM_DELETE_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TF_EM_DELETE_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TF_EM_DELETE_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TF_EM_DELETE_INPUT_FLAGS_DIR_LAST HWRM_TF_EM_DELETE_INPUT_FLAGS_DIR_TX
+	/* Unused0 */
+	uint16_t	unused0;
+	/* EM internal flow handle. */
+	uint64_t	flow_handle;
+	/* EM Key value */
+	uint64_t	em_key[8];
+	/* Number of bits in em_key. */
+	uint16_t	em_key_bitlen;
+	/* unused. */
+	uint16_t	unused1[3];
+} hwrm_tf_em_delete_input_t, *phwrm_tf_em_delete_input_t;
+
+/* hwrm_tf_em_delete_output (size:128b/16B) */
+
+typedef struct hwrm_tf_em_delete_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Original stack allocation index. */
+	uint16_t	em_index;
+	/* unused. */
+	uint8_t	unused0[5];
 	/*
-	 * If this bit is set to 1, then all queue_id0 related
-	 * parameters in this command are valid.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_ENABLES_COS_QUEUE_ID0_VALID	UINT32_C(0x1)
+	uint8_t	valid;
+} hwrm_tf_em_delete_output_t, *phwrm_tf_em_delete_output_t;
+
+/*******************
+ * hwrm_tf_em_move *
+ *******************/
+
+
+/* hwrm_tf_em_move_input (size:320b/40B) */
+
+typedef struct hwrm_tf_em_move_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * If this bit is set to 1, then all queue_id1 related
-	 * parameters in this command are valid.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_ENABLES_COS_QUEUE_ID1_VALID	UINT32_C(0x2)
+	uint16_t	cmpl_ring;
 	/*
-	 * If this bit is set to 1, then all queue_id2 related
-	 * parameters in this command are valid.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_ENABLES_COS_QUEUE_ID2_VALID	UINT32_C(0x4)
+	uint16_t	seq_id;
 	/*
-	 * If this bit is set to 1, then all queue_id3 related
-	 * parameters in this command are valid.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_ENABLES_COS_QUEUE_ID3_VALID	UINT32_C(0x8)
+	uint16_t	target_id;
 	/*
-	 * If this bit is set to 1, then all queue_id4 related
-	 * parameters in this command are valid.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_ENABLES_COS_QUEUE_ID4_VALID	UINT32_C(0x10)
+	uint64_t	resp_addr;
+	/* Session Id. */
+	uint32_t	fw_session_id;
+	/* Control flags. */
+	uint16_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TF_EM_MOVE_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TF_EM_MOVE_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TF_EM_MOVE_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TF_EM_MOVE_INPUT_FLAGS_DIR_LAST HWRM_TF_EM_MOVE_INPUT_FLAGS_DIR_TX
+	/* Number of EM entry blocks */
+	uint16_t	num_blocks;
+	/* New index for entry */
+	uint32_t	new_index;
+	/* Unused */
+	uint32_t	unused0;
+	/* EM internal flow handle. */
+	uint64_t	flow_handle;
+} hwrm_tf_em_move_input_t, *phwrm_tf_em_move_input_t;
+
+/* hwrm_tf_em_move_output (size:128b/16B) */
+
+typedef struct hwrm_tf_em_move_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Index of old entry. */
+	uint16_t	em_index;
+	/* unused. */
+	uint8_t	unused0[5];
 	/*
-	 * If this bit is set to 1, then all queue_id5 related
-	 * parameters in this command are valid.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_ENABLES_COS_QUEUE_ID5_VALID	UINT32_C(0x20)
+	uint8_t	valid;
+} hwrm_tf_em_move_output_t, *phwrm_tf_em_move_output_t;
+
+/********************
+ * hwrm_tf_tcam_set *
+ ********************/
+
+
+/* hwrm_tf_tcam_set_input (size:1024b/128B) */
+
+typedef struct hwrm_tf_tcam_set_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * If this bit is set to 1, then all queue_id6 related
-	 * parameters in this command are valid.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_ENABLES_COS_QUEUE_ID6_VALID	UINT32_C(0x40)
+	uint16_t	cmpl_ring;
 	/*
-	 * If this bit is set to 1, then all queue_id7 related
-	 * parameters in this command are valid.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_ENABLES_COS_QUEUE_ID7_VALID	UINT32_C(0x80)
+	uint16_t	seq_id;
 	/*
-	 * Port ID of port for which the table is being configured.
-	 * The HWRM needs to check whether this function is allowed
-	 * to configure TC BW assignment on this port.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint16_t	port_id;
-	/* ID of CoS Queue 0. */
-	uint8_t	queue_id0;
-	uint8_t	unused_0;
+	uint16_t	target_id;
 	/*
-	 * Minimum BW allocated to CoS Queue.
-	 * The HWRM will translate this value into byte counter and
-	 * time interval used for this COS inside the device.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint32_t	queue_id0_min_bw;
-	/* The bandwidth value. */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MIN_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MIN_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MIN_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MIN_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_INVALID
+	uint64_t	resp_addr;
+	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
+	uint32_t	fw_session_id;
+	/* Control flags. */
+	uint32_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TF_TCAM_SET_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TF_TCAM_SET_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TF_TCAM_SET_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TF_TCAM_SET_INPUT_FLAGS_DIR_LAST HWRM_TF_TCAM_SET_INPUT_FLAGS_DIR_TX
 	/*
-	 * Maximum BW allocated to CoS Queue.
-	 * The HWRM will translate this value into byte counter and
-	 * time interval used for this COS inside the device.
+	 * Indicate device data is being sent via DMA, the device
+	 * data is packing does not change.
 	 */
-	uint32_t	queue_id0_max_bw;
-	/* The bandwidth value. */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MAX_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MAX_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MAX_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MAX_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_INVALID
-	/* Transmission Selection Algorithm (TSA) for CoS Queue. */
-	uint8_t	queue_id0_tsa_assign;
-	/* Strict Priority */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_TSA_ASSIGN_SP		UINT32_C(0x0)
-	/* Enhanced Transmission Selection */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_TSA_ASSIGN_ETS		UINT32_C(0x1)
-	/* reserved. */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_TSA_ASSIGN_RESERVED_FIRST UINT32_C(0x2)
-	/* reserved. */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID0_TSA_ASSIGN_RESERVED_LAST  UINT32_C(0xff)
+	#define HWRM_TF_TCAM_SET_INPUT_FLAGS_DMA	UINT32_C(0x2)
 	/*
-	 * Priority level for strict priority. Valid only when the
-	 * tsa_assign is 0 - Strict Priority (SP)
-	 * 0..7 - Valid values.
-	 * 8..255 - Reserved.
+	 * TCAM type of the resource, defined globally in the
+	 * hwrm_tf_resc_type enum.
 	 */
-	uint8_t	queue_id0_pri_lvl;
+	uint32_t	type;
+	/* Index of TCAM entry. */
+	uint16_t	idx;
+	/* Number of bytes in the TCAM key. */
+	uint8_t	key_size;
+	/* Number of bytes in the TCAM result. */
+	uint8_t	result_size;
 	/*
-	 * Weight used to allocate remaining BW for this COS after
-	 * servicing guaranteed bandwidths for all COS.
+	 * Offset from which the mask bytes start in the device data
+	 * array, key offset is always 0.
 	 */
-	uint8_t	queue_id0_bw_weight;
-	/* ID of CoS Queue 1. */
-	uint8_t	queue_id1;
+	uint8_t	mask_offset;
+	/* Offset from which the result bytes start in the device data array. */
+	uint8_t	result_offset;
+	/* unused. */
+	uint8_t	unused0[6];
 	/*
-	 * Minimum BW allocated to CoS Queue.
-	 * The HWRM will translate this value into byte counter and
-	 * time interval used for this COS inside the device.
+	 * TCAM key located at offset 0, mask located at mask_offset
+	 * and result at result_offset for the device.
 	 */
-	uint32_t	queue_id1_min_bw;
-	/* The bandwidth value. */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MIN_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MIN_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MIN_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MIN_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_INVALID
+	uint8_t	dev_data[88];
+} hwrm_tf_tcam_set_input_t, *phwrm_tf_tcam_set_input_t;
+
+/* hwrm_tf_tcam_set_output (size:128b/16B) */
+
+typedef struct hwrm_tf_tcam_set_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* unused. */
+	uint8_t	unused0[7];
 	/*
-	 * Maximum BW allocated to CoS queue.
-	 * The HWRM will translate this value into byte counter and
-	 * time interval used for this COS inside the device.
+	 * This field is used in Output records to indicate that the
+	 * output is completely written to RAM. This field should be
+	 * read as '1' to indicate that the output has been
+	 * completely written. When writing a command completion or
+	 * response to an internal processor, the order of writes has
+	 * to be such that this field is written last.
 	 */
-	uint32_t	queue_id1_max_bw;
-	/* The bandwidth value. */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MAX_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MAX_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MAX_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MAX_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_INVALID
-	/* Transmission Selection Algorithm (TSA) for CoS Queue. */
-	uint8_t	queue_id1_tsa_assign;
-	/* Strict Priority */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_TSA_ASSIGN_SP		UINT32_C(0x0)
-	/* Enhanced Transmission Selection */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_TSA_ASSIGN_ETS		UINT32_C(0x1)
-	/* reserved. */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_TSA_ASSIGN_RESERVED_FIRST UINT32_C(0x2)
-	/* reserved. */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID1_TSA_ASSIGN_RESERVED_LAST  UINT32_C(0xff)
+	uint8_t	valid;
+} hwrm_tf_tcam_set_output_t, *phwrm_tf_tcam_set_output_t;
+
+/********************
+ * hwrm_tf_tcam_get *
+ ********************/
+
+
+/* hwrm_tf_tcam_get_input (size:256b/32B) */
+
+typedef struct hwrm_tf_tcam_get_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * Priority level for strict priority. Valid only when the
-	 * tsa_assign is 0 - Strict Priority (SP)
-	 * 0..7 - Valid values.
-	 * 8..255 - Reserved.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint8_t	queue_id1_pri_lvl;
+	uint16_t	target_id;
 	/*
-	 * Weight used to allocate remaining BW for this COS after
-	 * servicing guaranteed bandwidths for all COS.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint8_t	queue_id1_bw_weight;
-	/* ID of CoS Queue 2. */
-	uint8_t	queue_id2;
+	uint64_t	resp_addr;
+	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
+	uint32_t	fw_session_id;
+	/* Control flags. */
+	uint32_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TF_TCAM_GET_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TF_TCAM_GET_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TF_TCAM_GET_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TF_TCAM_GET_INPUT_FLAGS_DIR_LAST HWRM_TF_TCAM_GET_INPUT_FLAGS_DIR_TX
 	/*
-	 * Minimum BW allocated to CoS Queue.
-	 * The HWRM will translate this value into byte counter and
-	 * time interval used for this COS inside the device.
+	 * TCAM type of the resource, defined globally in the
+	 * hwrm_tf_resc_type enum.
 	 */
-	uint32_t	queue_id2_min_bw;
-	/* The bandwidth value. */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MIN_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MIN_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MIN_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MIN_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_INVALID
+	uint32_t	type;
+	/* Index of a TCAM entry. */
+	uint16_t	idx;
+	/* unused. */
+	uint16_t	unused0;
+} hwrm_tf_tcam_get_input_t, *phwrm_tf_tcam_get_input_t;
+
+/* hwrm_tf_tcam_get_output (size:2368b/296B) */
+
+typedef struct hwrm_tf_tcam_get_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Number of bytes in the TCAM key. */
+	uint8_t	key_size;
+	/* Number of bytes in the TCAM entry. */
+	uint8_t	result_size;
+	/* Offset from which the mask bytes start in the device data array. */
+	uint8_t	mask_offset;
+	/* Offset from which the result bytes start in the device data array. */
+	uint8_t	result_offset;
+	/* unused. */
+	uint8_t	unused0[4];
 	/*
-	 * Maximum BW allocated to CoS queue.
-	 * The HWRM will translate this value into byte counter and
-	 * time interval used for this COS inside the device.
+	 * TCAM key located at offset 0, mask located at mask_offset
+	 * and result at result_offset for the device.
 	 */
-	uint32_t	queue_id2_max_bw;
-	/* The bandwidth value. */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MAX_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MAX_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MAX_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MAX_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_INVALID
-	/* Transmission Selection Algorithm (TSA) for CoS Queue. */
-	uint8_t	queue_id2_tsa_assign;
-	/* Strict Priority */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_TSA_ASSIGN_SP		UINT32_C(0x0)
-	/* Enhanced Transmission Selection */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_TSA_ASSIGN_ETS		UINT32_C(0x1)
-	/* reserved. */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_TSA_ASSIGN_RESERVED_FIRST UINT32_C(0x2)
-	/* reserved. */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID2_TSA_ASSIGN_RESERVED_LAST  UINT32_C(0xff)
+	uint8_t	dev_data[272];
+	/* unused. */
+	uint8_t	unused1[7];
 	/*
-	 * Priority level for strict priority. Valid only when the
-	 * tsa_assign is 0 - Strict Priority (SP)
-	 * 0..7 - Valid values.
-	 * 8..255 - Reserved.
+	 * This field is used in Output records to indicate that the
+	 * output is completely written to RAM. This field should be
+	 * read as '1' to indicate that the output has been
+	 * completely written. When writing a command completion or
+	 * response to an internal processor, the order of writes has
+	 * to be such that this field is written last.
 	 */
-	uint8_t	queue_id2_pri_lvl;
+	uint8_t	valid;
+} hwrm_tf_tcam_get_output_t, *phwrm_tf_tcam_get_output_t;
+
+/*********************
+ * hwrm_tf_tcam_move *
+ *********************/
+
+
+/* hwrm_tf_tcam_move_input (size:1024b/128B) */
+
+typedef struct hwrm_tf_tcam_move_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * Weight used to allocate remaining BW for this COS after
-	 * servicing guaranteed bandwidths for all COS.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint8_t	queue_id2_bw_weight;
-	/* ID of CoS Queue 3. */
-	uint8_t	queue_id3;
+	uint16_t	cmpl_ring;
 	/*
-	 * Minimum BW allocated to CoS Queue.
-	 * The HWRM will translate this value into byte counter and
-	 * time interval used for this COS inside the device.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint32_t	queue_id3_min_bw;
-	/* The bandwidth value. */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MIN_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MIN_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MIN_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MIN_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_INVALID
+	uint16_t	seq_id;
 	/*
-	 * Maximum BW allocated to CoS queue.
-	 * The HWRM will translate this value into byte counter and
-	 * time interval used for this COS inside the device.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint32_t	queue_id3_max_bw;
-	/* The bandwidth value. */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MAX_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MAX_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MAX_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MAX_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_INVALID
-	/* Transmission Selection Algorithm (TSA) for CoS Queue. */
-	uint8_t	queue_id3_tsa_assign;
-	/* Strict Priority */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_TSA_ASSIGN_SP		UINT32_C(0x0)
-	/* Enhanced Transmission Selection */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_TSA_ASSIGN_ETS		UINT32_C(0x1)
-	/* reserved. */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_TSA_ASSIGN_RESERVED_FIRST UINT32_C(0x2)
-	/* reserved. */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID3_TSA_ASSIGN_RESERVED_LAST  UINT32_C(0xff)
+	uint16_t	target_id;
 	/*
-	 * Priority level for strict priority. Valid only when the
-	 * tsa_assign is 0 - Strict Priority (SP)
-	 * 0..7 - Valid values.
-	 * 8..255 - Reserved.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint8_t	queue_id3_pri_lvl;
+	uint64_t	resp_addr;
+	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
+	uint32_t	fw_session_id;
+	/* Control flags. */
+	uint32_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TF_TCAM_MOVE_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TF_TCAM_MOVE_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TF_TCAM_MOVE_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TF_TCAM_MOVE_INPUT_FLAGS_DIR_LAST HWRM_TF_TCAM_MOVE_INPUT_FLAGS_DIR_TX
 	/*
-	 * Weight used to allocate remaining BW for this COS after
-	 * servicing guaranteed bandwidths for all COS.
+	 * TCAM type of the resource, defined globally in the
+	 * hwrm_tf_resc_type enum.
 	 */
-	uint8_t	queue_id3_bw_weight;
-	/* ID of CoS Queue 4. */
-	uint8_t	queue_id4;
+	uint32_t	type;
+	/* Number of TCAM index pairs to be swapped for the device. */
+	uint16_t	count;
+	/* unused. */
+	uint16_t	unused0;
+	/* TCAM index pairs to be swapped for the device. */
+	uint16_t	idx_pairs[48];
+} hwrm_tf_tcam_move_input_t, *phwrm_tf_tcam_move_input_t;
+
+/* hwrm_tf_tcam_move_output (size:128b/16B) */
+
+typedef struct hwrm_tf_tcam_move_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* unused. */
+	uint8_t	unused0[7];
 	/*
-	 * Minimum BW allocated to CoS Queue.
-	 * The HWRM will translate this value into byte counter and
-	 * time interval used for this COS inside the device.
+	 * This field is used in Output records to indicate that the
+	 * output is completely written to RAM. This field should be
+	 * read as '1' to indicate that the output has been
+	 * completely written. When writing a command completion or
+	 * response to an internal processor, the order of writes has
+	 * to be such that this field is written last.
 	 */
-	uint32_t	queue_id4_min_bw;
-	/* The bandwidth value. */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MIN_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MIN_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MIN_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MIN_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_INVALID
+	uint8_t	valid;
+} hwrm_tf_tcam_move_output_t, *phwrm_tf_tcam_move_output_t;
+
+/*********************
+ * hwrm_tf_tcam_free *
+ *********************/
+
+
+/* hwrm_tf_tcam_free_input (size:1024b/128B) */
+
+typedef struct hwrm_tf_tcam_free_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * Maximum BW allocated to CoS queue.
-	 * The HWRM will translate this value into byte counter and
-	 * time interval used for this COS inside the device.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint32_t	queue_id4_max_bw;
-	/* The bandwidth value. */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MAX_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MAX_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MAX_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MAX_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_INVALID
-	/* Transmission Selection Algorithm (TSA) for CoS Queue. */
-	uint8_t	queue_id4_tsa_assign;
-	/* Strict Priority */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_TSA_ASSIGN_SP		UINT32_C(0x0)
-	/* Enhanced Transmission Selection */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_TSA_ASSIGN_ETS		UINT32_C(0x1)
-	/* reserved. */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_TSA_ASSIGN_RESERVED_FIRST UINT32_C(0x2)
-	/* reserved. */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID4_TSA_ASSIGN_RESERVED_LAST  UINT32_C(0xff)
+	uint16_t	cmpl_ring;
 	/*
-	 * Priority level for strict priority. Valid only when the
-	 * tsa_assign is 0 - Strict Priority (SP)
-	 * 0..7 - Valid values.
-	 * 8..255 - Reserved.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint8_t	queue_id4_pri_lvl;
+	uint16_t	seq_id;
 	/*
-	 * Weight used to allocate remaining BW for this COS after
-	 * servicing guaranteed bandwidths for all COS.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint8_t	queue_id4_bw_weight;
-	/* ID of CoS Queue 5. */
-	uint8_t	queue_id5;
+	uint16_t	target_id;
 	/*
-	 * Minimum BW allocated to CoS Queue.
-	 * The HWRM will translate this value into byte counter and
-	 * time interval used for this COS inside the device.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint32_t	queue_id5_min_bw;
-	/* The bandwidth value. */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MIN_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MIN_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MIN_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MIN_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_INVALID
+	uint64_t	resp_addr;
+	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
+	uint32_t	fw_session_id;
+	/* Control flags. */
+	uint32_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TF_TCAM_FREE_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TF_TCAM_FREE_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TF_TCAM_FREE_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TF_TCAM_FREE_INPUT_FLAGS_DIR_LAST HWRM_TF_TCAM_FREE_INPUT_FLAGS_DIR_TX
 	/*
-	 * Maximum BW allocated to CoS queue.
-	 * The HWRM will translate this value into byte counter and
-	 * time interval used for this COS inside the device.
+	 * TCAM type of the resource, defined globally in the
+	 * hwrm_tf_resc_type enum.
 	 */
-	uint32_t	queue_id5_max_bw;
-	/* The bandwidth value. */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MAX_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MAX_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MAX_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MAX_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_INVALID
-	/* Transmission Selection Algorithm (TSA) for CoS Queue. */
-	uint8_t	queue_id5_tsa_assign;
-	/* Strict Priority */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_TSA_ASSIGN_SP		UINT32_C(0x0)
-	/* Enhanced Transmission Selection */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_TSA_ASSIGN_ETS		UINT32_C(0x1)
-	/* reserved. */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_TSA_ASSIGN_RESERVED_FIRST UINT32_C(0x2)
-	/* reserved. */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID5_TSA_ASSIGN_RESERVED_LAST  UINT32_C(0xff)
-	/*
-	 * Priority level for strict priority. Valid only when the
-	 * tsa_assign is 0 - Strict Priority (SP)
-	 * 0..7 - Valid values.
-	 * 8..255 - Reserved.
+	uint32_t	type;
+	/* Number of TCAM index to be deleted for the device. */
+	uint16_t	count;
+	/* unused. */
+	uint16_t	unused0;
+	/* TCAM index list to be deleted for the device. */
+	uint16_t	idx_list[48];
+} hwrm_tf_tcam_free_input_t, *phwrm_tf_tcam_free_input_t;
+
+/* hwrm_tf_tcam_free_output (size:128b/16B) */
+
+typedef struct hwrm_tf_tcam_free_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* unused. */
+	uint8_t	unused0[7];
+	/*
+	 * This field is used in Output records to indicate that the
+	 * output is completely written to RAM. This field should be
+	 * read as '1' to indicate that the output has been
+	 * completely written. When writing a command completion or
+	 * response to an internal processor, the order of writes has
+	 * to be such that this field is written last.
 	 */
-	uint8_t	queue_id5_pri_lvl;
+	uint8_t	valid;
+} hwrm_tf_tcam_free_output_t, *phwrm_tf_tcam_free_output_t;
+
+/**************************
+ * hwrm_tf_global_cfg_set *
+ **************************/
+
+
+/* hwrm_tf_global_cfg_set_input (size:448b/56B) */
+
+typedef struct hwrm_tf_global_cfg_set_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * Weight used to allocate remaining BW for this COS after
-	 * servicing guaranteed bandwidths for all COS.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint8_t	queue_id5_bw_weight;
-	/* ID of CoS Queue 6. */
-	uint8_t	queue_id6;
+	uint16_t	cmpl_ring;
 	/*
-	 * Minimum BW allocated to CoS Queue.
-	 * The HWRM will translate this value into byte counter and
-	 * time interval used for this COS inside the device.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint32_t	queue_id6_min_bw;
-	/* The bandwidth value. */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MIN_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MIN_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MIN_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MIN_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_INVALID
+	uint16_t	seq_id;
 	/*
-	 * Maximum BW allocated to CoS queue.
-	 * The HWRM will translate this value into byte counter and
-	 * time interval used for this COS inside the device.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint32_t	queue_id6_max_bw;
-	/* The bandwidth value. */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MAX_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MAX_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MAX_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MAX_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_INVALID
-	/* Transmission Selection Algorithm (TSA) for CoS Queue. */
-	uint8_t	queue_id6_tsa_assign;
-	/* Strict Priority */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_TSA_ASSIGN_SP		UINT32_C(0x0)
-	/* Enhanced Transmission Selection */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_TSA_ASSIGN_ETS		UINT32_C(0x1)
-	/* reserved. */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_TSA_ASSIGN_RESERVED_FIRST UINT32_C(0x2)
-	/* reserved. */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID6_TSA_ASSIGN_RESERVED_LAST  UINT32_C(0xff)
+	uint16_t	target_id;
 	/*
-	 * Priority level for strict priority. Valid only when the
-	 * tsa_assign is 0 - Strict Priority (SP)
-	 * 0..7 - Valid values.
-	 * 8..255 - Reserved.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint8_t	queue_id6_pri_lvl;
+	uint64_t	resp_addr;
+	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
+	uint32_t	fw_session_id;
+	/* Control flags. */
+	uint32_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TF_GLOBAL_CFG_SET_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TF_GLOBAL_CFG_SET_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TF_GLOBAL_CFG_SET_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TF_GLOBAL_CFG_SET_INPUT_FLAGS_DIR_LAST HWRM_TF_GLOBAL_CFG_SET_INPUT_FLAGS_DIR_TX
+	/* Indicate device data is being sent via DMA. */
+	#define HWRM_TF_GLOBAL_CFG_SET_INPUT_FLAGS_DMA	UINT32_C(0x2)
+	/* Global Cfg type */
+	uint32_t	type;
+	/* Offset of the type */
+	uint32_t	offset;
+	/* Size of the data to set in bytes */
+	uint16_t	size;
+	/* unused. */
+	uint8_t	unused0[6];
+	/* Data to set */
+	uint8_t	data[8];
+	/* Mask of data to set, 0 indicates no mask */
+	uint8_t	mask[8];
+} hwrm_tf_global_cfg_set_input_t, *phwrm_tf_global_cfg_set_input_t;
+
+/* hwrm_tf_global_cfg_set_output (size:128b/16B) */
+
+typedef struct hwrm_tf_global_cfg_set_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* unused. */
+	uint8_t	unused0[7];
 	/*
-	 * Weight used to allocate remaining BW for this COS after
-	 * servicing guaranteed bandwidths for all COS.
+	 * This field is used in Output records to indicate that the
+	 * output is completely written to RAM. This field should be
+	 * read as '1' to indicate that the output has been
+	 * completely written. When writing a command completion or
+	 * response to an internal processor, the order of writes has
+	 * to be such that this field is written last.
 	 */
-	uint8_t	queue_id6_bw_weight;
-	/* ID of CoS Queue 7. */
-	uint8_t	queue_id7;
+	uint8_t	valid;
+} hwrm_tf_global_cfg_set_output_t, *phwrm_tf_global_cfg_set_output_t;
+
+/**************************
+ * hwrm_tf_global_cfg_get *
+ **************************/
+
+
+/* hwrm_tf_global_cfg_get_input (size:320b/40B) */
+
+typedef struct hwrm_tf_global_cfg_get_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * Minimum BW allocated to CoS Queue.
-	 * The HWRM will translate this value into byte counter and
-	 * time interval used for this COS inside the device.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint32_t	queue_id7_min_bw;
-	/* The bandwidth value. */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MIN_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MIN_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MIN_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MIN_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MIN_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MIN_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MIN_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_INVALID
+	uint16_t	cmpl_ring;
 	/*
-	 * Maximum BW allocated to CoS queue.
-	 * The HWRM will translate this value into byte counter and
-	 * time interval used for this COS inside the device.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint32_t	queue_id7_max_bw;
-	/* The bandwidth value. */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MAX_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MAX_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MAX_BW_SCALE_LAST		HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MAX_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_INVALID
-	/* Transmission Selection Algorithm (TSA) for CoS Queue. */
-	uint8_t	queue_id7_tsa_assign;
-	/* Strict Priority */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_TSA_ASSIGN_SP		UINT32_C(0x0)
-	/* Enhanced Transmission Selection */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_TSA_ASSIGN_ETS		UINT32_C(0x1)
-	/* reserved. */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_TSA_ASSIGN_RESERVED_FIRST UINT32_C(0x2)
-	/* reserved. */
-	#define HWRM_QUEUE_COS2BW_CFG_INPUT_QUEUE_ID7_TSA_ASSIGN_RESERVED_LAST  UINT32_C(0xff)
+	uint16_t	seq_id;
 	/*
-	 * Priority level for strict priority. Valid only when the
-	 * tsa_assign is 0 - Strict Priority (SP)
-	 * 0..7 - Valid values.
-	 * 8..255 - Reserved.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint8_t	queue_id7_pri_lvl;
+	uint16_t	target_id;
 	/*
-	 * Weight used to allocate remaining BW for this COS after
-	 * servicing guaranteed bandwidths for all COS.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint8_t	queue_id7_bw_weight;
-	uint8_t	unused_1[5];
-} hwrm_queue_cos2bw_cfg_input_t, *phwrm_queue_cos2bw_cfg_input_t;
+	uint64_t	resp_addr;
+	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
+	uint32_t	fw_session_id;
+	/* Control flags. */
+	uint32_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TF_GLOBAL_CFG_GET_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TF_GLOBAL_CFG_GET_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TF_GLOBAL_CFG_GET_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TF_GLOBAL_CFG_GET_INPUT_FLAGS_DIR_LAST HWRM_TF_GLOBAL_CFG_GET_INPUT_FLAGS_DIR_TX
+	/* Global Cfg type */
+	uint32_t	type;
+	/* Offset of the type */
+	uint32_t	offset;
+	/* Size of the data to set in bytes */
+	uint16_t	size;
+	/* unused. */
+	uint8_t	unused0[6];
+} hwrm_tf_global_cfg_get_input_t, *phwrm_tf_global_cfg_get_input_t;
 
-/* hwrm_queue_cos2bw_cfg_output (size:128b/16B) */
+/* hwrm_tf_global_cfg_get_output (size:2240b/280B) */
 
-typedef struct hwrm_queue_cos2bw_cfg_output {
+typedef struct hwrm_tf_global_cfg_get_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -27629,25 +55138,33 @@ typedef struct hwrm_queue_cos2bw_cfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	/* Size of the data read in bytes */
+	uint16_t	size;
+	/* unused. */
+	uint8_t	unused0[6];
+	/* Data to set */
+	uint8_t	data[256];
+	/* unused. */
+	uint8_t	unused1[7];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_queue_cos2bw_cfg_output_t, *phwrm_queue_cos2bw_cfg_output_t;
+} hwrm_tf_global_cfg_get_output_t, *phwrm_tf_global_cfg_get_output_t;
 
-/*************************
- * hwrm_queue_dscp_qcaps *
- *************************/
+/**********************
+ * hwrm_tf_if_tbl_get *
+ **********************/
 
 
-/* hwrm_queue_dscp_qcaps_input (size:192b/24B) */
+/* hwrm_tf_if_tbl_get_input (size:256b/32B) */
 
-typedef struct hwrm_queue_dscp_qcaps_input {
+typedef struct hwrm_tf_if_tbl_get_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -27676,18 +55193,31 @@ typedef struct hwrm_queue_dscp_qcaps_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
+	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
+	uint32_t	fw_session_id;
+	/* Control flags. */
+	uint16_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TF_IF_TBL_GET_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TF_IF_TBL_GET_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TF_IF_TBL_GET_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TF_IF_TBL_GET_INPUT_FLAGS_DIR_LAST HWRM_TF_IF_TBL_GET_INPUT_FLAGS_DIR_TX
+	/* Size of the data to set. */
+	uint16_t	size;
 	/*
-	 * Port ID of port for which the table is being configured.
-	 * The HWRM needs to check whether this function is allowed
-	 * to configure pri2cos mapping on this port.
+	 * Type of the resource, defined globally in the
+	 * hwrm_tf_resc_type enum.
 	 */
-	uint8_t	port_id;
-	uint8_t	unused_0[7];
-} hwrm_queue_dscp_qcaps_input_t, *phwrm_queue_dscp_qcaps_input_t;
+	uint32_t	type;
+	/* Index of the type to retrieve. */
+	uint32_t	index;
+} hwrm_tf_if_tbl_get_input_t, *phwrm_tf_if_tbl_get_input_t;
 
-/* hwrm_queue_dscp_qcaps_output (size:128b/16B) */
+/* hwrm_tf_if_tbl_get_output (size:1216b/152B) */
 
-typedef struct hwrm_queue_dscp_qcaps_output {
+typedef struct hwrm_tf_if_tbl_get_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -27696,30 +55226,35 @@ typedef struct hwrm_queue_dscp_qcaps_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* The number of bits provided by the hardware for the DSCP value. */
-	uint8_t	num_dscp_bits;
-	uint8_t	unused_0;
-	/* Max number of DSCP-MASK-PRI entries supported. */
-	uint16_t	max_entries;
-	uint8_t	unused_1[3];
+	/* Response code. */
+	uint32_t	resp_code;
+	/* Response size. */
+	uint16_t	size;
+	/* unused */
+	uint16_t	unused0;
+	/* Response data. */
+	uint8_t	data[128];
+	/* unused */
+	uint8_t	unused1[7];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
 	uint8_t	valid;
-} hwrm_queue_dscp_qcaps_output_t, *phwrm_queue_dscp_qcaps_output_t;
+} hwrm_tf_if_tbl_get_output_t, *phwrm_tf_if_tbl_get_output_t;
 
-/****************************
- * hwrm_queue_dscp2pri_qcfg *
- ****************************/
+/***************************
+ * hwrm_tf_if_tbl_type_set *
+ ***************************/
 
 
-/* hwrm_queue_dscp2pri_qcfg_input (size:256b/32B) */
+/* hwrm_tf_if_tbl_set_input (size:1024b/128B) */
 
-typedef struct hwrm_queue_dscp2pri_qcfg_input {
+typedef struct hwrm_tf_if_tbl_set_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -27748,26 +55283,37 @@ typedef struct hwrm_queue_dscp2pri_qcfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
+	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
+	uint32_t	fw_session_id;
+	/* Control flags. */
+	uint16_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TF_IF_TBL_SET_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TF_IF_TBL_SET_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TF_IF_TBL_SET_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TF_IF_TBL_SET_INPUT_FLAGS_DIR_LAST HWRM_TF_IF_TBL_SET_INPUT_FLAGS_DIR_TX
+	/* unused. */
+	uint8_t	unused0[2];
 	/*
-	 * This is the host address where the 24-bits DSCP-MASK-PRI
-	 * tuple(s) will be copied to.
-	 */
-	uint64_t	dest_data_addr;
-	/*
-	 * Port ID of port for which the table is being configured.
-	 * The HWRM needs to check whether this function is allowed
-	 * to configure pri2cos mapping on this port.
+	 * Type of the resource, defined globally in the
+	 * hwrm_tf_resc_type enum.
 	 */
-	uint8_t	port_id;
-	uint8_t	unused_0;
-	/* Size of the buffer pointed to by dest_data_addr. */
-	uint16_t	dest_data_buffer_size;
-	uint8_t	unused_1[4];
-} hwrm_queue_dscp2pri_qcfg_input_t, *phwrm_queue_dscp2pri_qcfg_input_t;
+	uint32_t	type;
+	/* Index of the type to set. */
+	uint32_t	index;
+	/* Size of the data to set. */
+	uint16_t	size;
+	/* unused */
+	uint8_t	unused1[6];
+	/* Data to be set. */
+	uint8_t	data[88];
+} hwrm_tf_if_tbl_set_input_t, *phwrm_tf_if_tbl_set_input_t;
 
-/* hwrm_queue_dscp2pri_qcfg_output (size:128b/16B) */
+/* hwrm_tf_if_tbl_set_output (size:128b/16B) */
 
-typedef struct hwrm_queue_dscp2pri_qcfg_output {
+typedef struct hwrm_tf_if_tbl_set_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -27776,35 +55322,124 @@ typedef struct hwrm_queue_dscp2pri_qcfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
+	/* unused. */
+	uint8_t	unused0[7];
 	/*
-	 * A count of the number of DSCP-MASK-PRI tuple(s) pointed to
-	 * by the dest_data_addr.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
-	uint16_t	entry_cnt;
+	uint8_t	valid;
+} hwrm_tf_if_tbl_set_output_t, *phwrm_tf_if_tbl_set_output_t;
+
+/*****************************
+ * hwrm_tf_tbl_type_bulk_get *
+ *****************************/
+
+
+/* hwrm_tf_tbl_type_bulk_get_input (size:384b/48B) */
+
+typedef struct hwrm_tf_tbl_type_bulk_get_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * This is the default PRI which un-initialized DSCP values are
-	 * mapped to.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint8_t	default_pri;
-	uint8_t	unused_0[4];
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
+	uint32_t	fw_session_id;
+	/* Control flags. */
+	uint16_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TF_TBL_TYPE_BULK_GET_INPUT_FLAGS_DIR		UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TF_TBL_TYPE_BULK_GET_INPUT_FLAGS_DIR_RX		UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TF_TBL_TYPE_BULK_GET_INPUT_FLAGS_DIR_TX		UINT32_C(0x1)
+		#define HWRM_TF_TBL_TYPE_BULK_GET_INPUT_FLAGS_DIR_LAST	HWRM_TF_TBL_TYPE_BULK_GET_INPUT_FLAGS_DIR_TX
+	/*
+	 * When set use the special access register access to clear
+	 * the table entries on read.
+	 */
+	#define HWRM_TF_TBL_TYPE_BULK_GET_INPUT_FLAGS_CLEAR_ON_READ	UINT32_C(0x2)
+	/* unused. */
+	uint8_t	unused0[2];
+	/*
+	 * Type of the resource, defined globally in the
+	 * hwrm_tf_resc_type enum.
+	 */
+	uint32_t	type;
+	/* Starting index of the type to retrieve. */
+	uint32_t	start_index;
+	/* Number of entries to retrieve. */
+	uint32_t	num_entries;
+	/* Number of entries to retrieve. */
+	uint32_t	unused1;
+	/* Host memory where data will be stored. */
+	uint64_t	host_addr;
+} hwrm_tf_tbl_type_bulk_get_input_t, *phwrm_tf_tbl_type_bulk_get_input_t;
+
+/* hwrm_tf_tbl_type_bulk_get_output (size:128b/16B) */
+
+typedef struct hwrm_tf_tbl_type_bulk_get_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Response code. */
+	uint32_t	resp_code;
+	/* Response size. */
+	uint16_t	size;
+	/* unused */
+	uint8_t	unused0;
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
 	uint8_t	valid;
-} hwrm_queue_dscp2pri_qcfg_output_t, *phwrm_queue_dscp2pri_qcfg_output_t;
+} hwrm_tf_tbl_type_bulk_get_output_t, *phwrm_tf_tbl_type_bulk_get_output_t;
 
-/***************************
- * hwrm_queue_dscp2pri_cfg *
- ***************************/
+/***********************************
+ * hwrm_tf_session_hotup_state_set *
+ ***********************************/
 
 
-/* hwrm_queue_dscp2pri_cfg_input (size:320b/40B) */
+/* hwrm_tf_session_hotup_state_set_input (size:192b/24B) */
 
-typedef struct hwrm_queue_dscp2pri_cfg_input {
+typedef struct hwrm_tf_session_hotup_state_set_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -27833,42 +55468,24 @@ typedef struct hwrm_queue_dscp2pri_cfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/*
-	 * This is the host address where the 24-bits DSCP-MASK-PRI tuple
-	 * will be copied from.
-	 */
-	uint64_t	src_data_addr;
-	uint32_t	flags;
-	/* use_hw_default_pri is 1 b */
-	#define HWRM_QUEUE_DSCP2PRI_CFG_INPUT_FLAGS_USE_HW_DEFAULT_PRI	UINT32_C(0x1)
-	uint32_t	enables;
-	/*
-	 * This bit must be '1' for the default_pri field to be
-	 * configured.
-	 */
-	#define HWRM_QUEUE_DSCP2PRI_CFG_INPUT_ENABLES_DEFAULT_PRI	UINT32_C(0x1)
-	/*
-	 * Port ID of port for which the table is being configured.
-	 * The HWRM needs to check whether this function is allowed
-	 * to configure pri2cos mapping on this port.
-	 */
-	uint8_t	port_id;
-	/*
-	 * This is the default PRI which un-initialized DSCP values will be
-	 * mapped to.
-	 */
-	uint8_t	default_pri;
-	/*
-	 * A count of the number of DSCP-MASK-PRI tuple(s) in the data pointed
-	 * to by src_data_addr.
-	 */
-	uint16_t	entry_cnt;
-	uint8_t	unused_0[4];
-} hwrm_queue_dscp2pri_cfg_input_t, *phwrm_queue_dscp2pri_cfg_input_t;
+	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
+	uint32_t	fw_session_id;
+	/* Shared session state. */
+	uint16_t	state;
+	/* Control flags. */
+	uint16_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TF_SESSION_HOTUP_STATE_SET_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TF_SESSION_HOTUP_STATE_SET_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TF_SESSION_HOTUP_STATE_SET_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TF_SESSION_HOTUP_STATE_SET_INPUT_FLAGS_DIR_LAST HWRM_TF_SESSION_HOTUP_STATE_SET_INPUT_FLAGS_DIR_TX
+} hwrm_tf_session_hotup_state_set_input_t, *phwrm_tf_session_hotup_state_set_input_t;
 
-/* hwrm_queue_dscp2pri_cfg_output (size:128b/16B) */
+/* hwrm_tf_session_hotup_state_set_output (size:128b/16B) */
 
-typedef struct hwrm_queue_dscp2pri_cfg_output {
+typedef struct hwrm_tf_session_hotup_state_set_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -27877,25 +55494,27 @@ typedef struct hwrm_queue_dscp2pri_cfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	/* unused. */
+	uint8_t	unused0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
 	uint8_t	valid;
-} hwrm_queue_dscp2pri_cfg_output_t, *phwrm_queue_dscp2pri_cfg_output_t;
+} hwrm_tf_session_hotup_state_set_output_t, *phwrm_tf_session_hotup_state_set_output_t;
 
-/*************************
- * hwrm_queue_mpls_qcaps *
- *************************/
+/***********************************
+ * hwrm_tf_session_hotup_state_get *
+ ***********************************/
 
 
-/* hwrm_queue_mpls_qcaps_input (size:192b/24B) */
+/* hwrm_tf_session_hotup_state_get_input (size:192b/24B) */
 
-typedef struct hwrm_queue_mpls_qcaps_input {
+typedef struct hwrm_tf_session_hotup_state_get_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -27924,18 +55543,24 @@ typedef struct hwrm_queue_mpls_qcaps_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/*
-	 * Port ID of port for which the table is being configured.
-	 * The HWRM needs to check whether this function is allowed
-	 * to configure MPLS TC(EXP) to pri mapping on this port.
-	 */
-	uint8_t	port_id;
-	uint8_t	unused_0[7];
-} hwrm_queue_mpls_qcaps_input_t, *phwrm_queue_mpls_qcaps_input_t;
+	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
+	uint32_t	fw_session_id;
+	/* Control flags. */
+	uint16_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TF_SESSION_HOTUP_STATE_GET_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TF_SESSION_HOTUP_STATE_GET_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TF_SESSION_HOTUP_STATE_GET_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TF_SESSION_HOTUP_STATE_GET_INPUT_FLAGS_DIR_LAST HWRM_TF_SESSION_HOTUP_STATE_GET_INPUT_FLAGS_DIR_TX
+	/* unused. */
+	uint8_t	unused0[2];
+} hwrm_tf_session_hotup_state_get_input_t, *phwrm_tf_session_hotup_state_get_input_t;
 
-/* hwrm_queue_mpls_qcaps_output (size:128b/16B) */
+/* hwrm_tf_session_hotup_state_get_output (size:128b/16B) */
 
-typedef struct hwrm_queue_mpls_qcaps_output {
+typedef struct hwrm_tf_session_hotup_state_get_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -27944,43 +55569,31 @@ typedef struct hwrm_queue_mpls_qcaps_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/*
-	 * Bitmask indicating which queues can be configured by the
-	 * hwrm_queue_mplstc2pri_cfg command.
-	 *
-	 * Each bit represents a specific pri where bit 0 represents
-	 * pri 0 and bit 7 represents pri 7.
-	 * # A value of 0 indicates that the pri is not configurable
-	 * by the hwrm_queue_mplstc2pri_cfg command.
-	 * # A value of 1 indicates that the pri is configurable.
-	 * # A hwrm_queue_mplstc2pri_cfg command shall return error when
-	 * trying to configure a pri that is not configurable.
-	 */
-	uint8_t	queue_mplstc2pri_cfg_allowed;
-	/*
-	 * This is the default PRI which un-initialized MPLS values will be
-	 * mapped to.
-	 */
-	uint8_t	hw_default_pri;
-	uint8_t	unused_0[5];
+	/* Shared session HA state. */
+	uint16_t	state;
+	/* Shared session HA reference count. */
+	uint16_t	ref_cnt;
+	/* unused. */
+	uint8_t	unused0[3];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
 	uint8_t	valid;
-} hwrm_queue_mpls_qcaps_output_t, *phwrm_queue_mpls_qcaps_output_t;
+} hwrm_tf_session_hotup_state_get_output_t, *phwrm_tf_session_hotup_state_get_output_t;
 
-/******************************
- * hwrm_queue_mplstc2pri_qcfg *
- ******************************/
+/**************************
+ * hwrm_tf_resc_usage_set *
+ **************************/
 
 
-/* hwrm_queue_mplstc2pri_qcfg_input (size:192b/24B) */
+/* hwrm_tf_resc_usage_set_input (size:1024b/128B) */
 
-typedef struct hwrm_queue_mplstc2pri_qcfg_input {
+typedef struct hwrm_tf_resc_usage_set_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -28009,18 +55622,48 @@ typedef struct hwrm_queue_mplstc2pri_qcfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/*
-	 * Port ID of port for which the table is being configured.
-	 * The HWRM needs to check whether this function is allowed
-	 * to configure MPLS TC(EXP) to pri mapping on this port.
-	 */
-	uint8_t	port_id;
-	uint8_t	unused_0[7];
-} hwrm_queue_mplstc2pri_qcfg_input_t, *phwrm_queue_mplstc2pri_qcfg_input_t;
+	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
+	uint32_t	fw_session_id;
+	/* Control flags. */
+	uint16_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TF_RESC_USAGE_SET_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TF_RESC_USAGE_SET_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TF_RESC_USAGE_SET_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TF_RESC_USAGE_SET_INPUT_FLAGS_DIR_LAST HWRM_TF_RESC_USAGE_SET_INPUT_FLAGS_DIR_TX
+	/* Indicate table data is being sent via DMA. */
+	#define HWRM_TF_RESC_USAGE_SET_INPUT_FLAGS_DMA	UINT32_C(0x2)
+	/* Types of the resource to set their usage state. */
+	uint16_t	types;
+	/* WC TCAM Pool */
+	#define HWRM_TF_RESC_USAGE_SET_INPUT_TYPES_WC_TCAM	UINT32_C(0x1)
+	/* EM Internal Memory Pool */
+	#define HWRM_TF_RESC_USAGE_SET_INPUT_TYPES_EM		UINT32_C(0x2)
+	/* Meter Instance */
+	#define HWRM_TF_RESC_USAGE_SET_INPUT_TYPES_METER		UINT32_C(0x4)
+	/* Counter Record Table */
+	#define HWRM_TF_RESC_USAGE_SET_INPUT_TYPES_COUNTER	UINT32_C(0x8)
+	/* Action Record Table */
+	#define HWRM_TF_RESC_USAGE_SET_INPUT_TYPES_ACTION		UINT32_C(0x10)
+	/* ACT MODIFY/ENCAP Record Table */
+	#define HWRM_TF_RESC_USAGE_SET_INPUT_TYPES_ACT_MOD_ENCAP	UINT32_C(0x20)
+	/* Source Property SMAC Record Table */
+	#define HWRM_TF_RESC_USAGE_SET_INPUT_TYPES_SP_SMAC	UINT32_C(0x40)
+	/* All Resource Types */
+	#define HWRM_TF_RESC_USAGE_SET_INPUT_TYPES_ALL		UINT32_C(0x80)
+	/* Size of the data to set. */
+	uint16_t	size;
+	/* unused */
+	uint8_t	unused1[6];
+	/* Data to be set. */
+	uint8_t	data[96];
+} hwrm_tf_resc_usage_set_input_t, *phwrm_tf_resc_usage_set_input_t;
 
-/* hwrm_queue_mplstc2pri_qcfg_output (size:192b/24B) */
+/* hwrm_tf_resc_usage_set_output (size:128b/16B) */
 
-typedef struct hwrm_queue_mplstc2pri_qcfg_output {
+typedef struct hwrm_tf_resc_usage_set_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -28029,81 +55672,27 @@ typedef struct hwrm_queue_mplstc2pri_qcfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/*
-	 * pri assigned to MPLS TC(EXP) 0. This value can only be changed
-	 * before traffic has started.
-	 * A value of 0xff indicates that no pri is assigned to the
-	 * MPLS TC(EXP) 0.
-	 */
-	uint8_t	tc0_pri_queue_id;
-	/*
-	 * pri assigned to MPLS TC(EXP) 1. This value can only be changed
-	 * before traffic has started.
-	 * A value of 0xff indicates that no pri is assigned to the
-	 * MPLS TC(EXP) 1.
-	 */
-	uint8_t	tc1_pri_queue_id;
-	/*
-	 * pri assigned to MPLS TC(EXP) 2. This value can only be changed
-	 * before traffic has started.
-	 * A value of 0xff indicates that no pri is assigned to the
-	 * MPLS TC(EXP) 2.
-	 */
-	uint8_t	tc2_pri_queue_id;
-	/*
-	 * pri assigned to MPLS TC(EXP) 3. This value can only be changed
-	 * before traffic has started.
-	 * A value of 0xff indicates that no pri is assigned to the
-	 * MPLS TC(EXP) 3.
-	 */
-	uint8_t	tc3_pri_queue_id;
-	/*
-	 * pri assigned to MPLS TC(EXP) 4. This value can only be changed
-	 * before traffic has started.
-	 * A value of 0xff indicates that no pri is assigned to the
-	 * MPLS TC(EXP) 4.
-	 */
-	uint8_t	tc4_pri_queue_id;
-	/*
-	 * pri assigned to MPLS TC(EXP) 5. This value can only be changed
-	 * before traffic has started.
-	 * A value of 0xff indicates that no pri is assigned to the
-	 * MPLS TC(EXP) 5.
-	 */
-	uint8_t	tc5_pri_queue_id;
-	/*
-	 * pri assigned to MPLS TC(EXP) 6. This value can only
-	 * be changed before traffic has started.
-	 * A value of 0xff indicates that no pri is assigned to the
-	 * MPLS TC(EXP) 6.
-	 */
-	uint8_t	tc6_pri_queue_id;
-	/*
-	 * pri assigned to MPLS TC(EXP) 7. This value can only
-	 * be changed before traffic has started.
-	 * A value of 0xff indicates that no pri is assigned to the
-	 * MPLS TC(EXP) 7.
-	 */
-	uint8_t	tc7_pri_queue_id;
-	uint8_t	unused_0[7];
+	/* unused. */
+	uint8_t	unused0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
 	uint8_t	valid;
-} hwrm_queue_mplstc2pri_qcfg_output_t, *phwrm_queue_mplstc2pri_qcfg_output_t;
+} hwrm_tf_resc_usage_set_output_t, *phwrm_tf_resc_usage_set_output_t;
 
-/*****************************
- * hwrm_queue_mplstc2pri_cfg *
- *****************************/
+/****************************
+ * hwrm_tf_resc_usage_query *
+ ****************************/
 
 
-/* hwrm_queue_mplstc2pri_cfg_input (size:256b/32B) */
+/* hwrm_tf_resc_usage_query_input (size:256b/32B) */
 
-typedef struct hwrm_queue_mplstc2pri_cfg_input {
+typedef struct hwrm_tf_resc_usage_query_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -28132,99 +55721,44 @@ typedef struct hwrm_queue_mplstc2pri_cfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	enables;
-	/*
-	 * This bit must be '1' for the mplstc0_pri_queue_id field to be
-	 * configured.
-	 */
-	#define HWRM_QUEUE_MPLSTC2PRI_CFG_INPUT_ENABLES_TC0_PRI_QUEUE_ID	UINT32_C(0x1)
-	/*
-	 * This bit must be '1' for the mplstc1_pri_queue_id field to be
-	 * configured.
-	 */
-	#define HWRM_QUEUE_MPLSTC2PRI_CFG_INPUT_ENABLES_TC1_PRI_QUEUE_ID	UINT32_C(0x2)
-	/*
-	 * This bit must be '1' for the mplstc2_pri_queue_id field to be
-	 * configured.
-	 */
-	#define HWRM_QUEUE_MPLSTC2PRI_CFG_INPUT_ENABLES_TC2_PRI_QUEUE_ID	UINT32_C(0x4)
-	/*
-	 * This bit must be '1' for the mplstc3_pri_queue_id field to be
-	 * configured.
-	 */
-	#define HWRM_QUEUE_MPLSTC2PRI_CFG_INPUT_ENABLES_TC3_PRI_QUEUE_ID	UINT32_C(0x8)
-	/*
-	 * This bit must be '1' for the mplstc4_pri_queue_id field to be
-	 * configured.
-	 */
-	#define HWRM_QUEUE_MPLSTC2PRI_CFG_INPUT_ENABLES_TC4_PRI_QUEUE_ID	UINT32_C(0x10)
-	/*
-	 * This bit must be '1' for the mplstc5_pri_queue_id field to be
-	 * configured.
-	 */
-	#define HWRM_QUEUE_MPLSTC2PRI_CFG_INPUT_ENABLES_TC5_PRI_QUEUE_ID	UINT32_C(0x20)
-	/*
-	 * This bit must be '1' for the mplstc6_pri_queue_id field to be
-	 * configured.
-	 */
-	#define HWRM_QUEUE_MPLSTC2PRI_CFG_INPUT_ENABLES_TC6_PRI_QUEUE_ID	UINT32_C(0x40)
-	/*
-	 * This bit must be '1' for the mplstc7_pri_queue_id field to be
-	 * configured.
-	 */
-	#define HWRM_QUEUE_MPLSTC2PRI_CFG_INPUT_ENABLES_TC7_PRI_QUEUE_ID	UINT32_C(0x80)
-	/*
-	 * Port ID of port for which the table is being configured.
-	 * The HWRM needs to check whether this function is allowed
-	 * to configure MPLS TC(EXP)to pri mapping on this port.
-	 */
-	uint8_t	port_id;
-	uint8_t	unused_0[3];
-	/*
-	 * pri assigned to MPLS TC(EXP) 0. This value can only
-	 * be changed before traffic has started.
-	 */
-	uint8_t	tc0_pri_queue_id;
-	/*
-	 * pri assigned to MPLS TC(EXP) 1. This value can only
-	 * be changed before traffic has started.
-	 */
-	uint8_t	tc1_pri_queue_id;
-	/*
-	 * pri assigned to MPLS TC(EXP) 2  This value can only
-	 * be changed before traffic has started.
-	 */
-	uint8_t	tc2_pri_queue_id;
-	/*
-	 * pri assigned to MPLS TC(EXP) 3. This value can only
-	 * be changed before traffic has started.
-	 */
-	uint8_t	tc3_pri_queue_id;
-	/*
-	 * pri assigned to MPLS TC(EXP) 4. This value can only
-	 * be changed before traffic has started.
-	 */
-	uint8_t	tc4_pri_queue_id;
-	/*
-	 * pri assigned to MPLS TC(EXP) 5. This value can only
-	 * be changed before traffic has started.
-	 */
-	uint8_t	tc5_pri_queue_id;
-	/*
-	 * pri assigned to MPLS TC(EXP) 6. This value can only
-	 * be changed before traffic has started.
-	 */
-	uint8_t	tc6_pri_queue_id;
-	/*
-	 * pri assigned to MPLS TC(EXP) 7. This value can only
-	 * be changed before traffic has started.
-	 */
-	uint8_t	tc7_pri_queue_id;
-} hwrm_queue_mplstc2pri_cfg_input_t, *phwrm_queue_mplstc2pri_cfg_input_t;
+	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
+	uint32_t	fw_session_id;
+	/* Control flags. */
+	uint16_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TF_RESC_USAGE_QUERY_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TF_RESC_USAGE_QUERY_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TF_RESC_USAGE_QUERY_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TF_RESC_USAGE_QUERY_INPUT_FLAGS_DIR_LAST HWRM_TF_RESC_USAGE_QUERY_INPUT_FLAGS_DIR_TX
+	/* unused. */
+	uint8_t	unused0[2];
+	/* Types of the resource to retrieve their usage state. */
+	uint16_t	types;
+	/* WC TCAM Pool */
+	#define HWRM_TF_RESC_USAGE_QUERY_INPUT_TYPES_WC_TCAM	UINT32_C(0x1)
+	/* EM Internal Memory Pool */
+	#define HWRM_TF_RESC_USAGE_QUERY_INPUT_TYPES_EM		UINT32_C(0x2)
+	/* Meter Instance */
+	#define HWRM_TF_RESC_USAGE_QUERY_INPUT_TYPES_METER		UINT32_C(0x4)
+	/* Counter Record Table */
+	#define HWRM_TF_RESC_USAGE_QUERY_INPUT_TYPES_COUNTER	UINT32_C(0x8)
+	/* Action Record Table */
+	#define HWRM_TF_RESC_USAGE_QUERY_INPUT_TYPES_ACTION		UINT32_C(0x10)
+	/* ACT MODIFY/ENCAP Record Table */
+	#define HWRM_TF_RESC_USAGE_QUERY_INPUT_TYPES_ACT_MOD_ENCAP	UINT32_C(0x20)
+	/* Source Property SMAC Record Table */
+	#define HWRM_TF_RESC_USAGE_QUERY_INPUT_TYPES_SP_SMAC	UINT32_C(0x40)
+	/* All Resource Types */
+	#define HWRM_TF_RESC_USAGE_QUERY_INPUT_TYPES_ALL		UINT32_C(0x80)
+	/* unused */
+	uint8_t	unused1[6];
+} hwrm_tf_resc_usage_query_input_t, *phwrm_tf_resc_usage_query_input_t;
 
-/* hwrm_queue_mplstc2pri_cfg_output (size:128b/16B) */
+/* hwrm_tf_resc_usage_query_output (size:960b/120B) */
 
-typedef struct hwrm_queue_mplstc2pri_cfg_output {
+typedef struct hwrm_tf_resc_usage_query_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -28233,25 +55767,39 @@ typedef struct hwrm_queue_mplstc2pri_cfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	/* Response code. */
+	uint32_t	resp_code;
+	/* Response size. */
+	uint16_t	size;
+	/* unused */
+	uint16_t	unused0;
+	/* Response data. */
+	uint8_t	data[96];
+	/* unused */
+	uint8_t	unused1[7];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
 	uint8_t	valid;
-} hwrm_queue_mplstc2pri_cfg_output_t, *phwrm_queue_mplstc2pri_cfg_output_t;
+} hwrm_tf_resc_usage_query_output_t, *phwrm_tf_resc_usage_query_output_t;
 
 /****************************
- * hwrm_queue_vlanpri_qcaps *
+ * hwrm_tfc_tbl_scope_qcaps *
  ****************************/
 
 
-/* hwrm_queue_vlanpri_qcaps_input (size:192b/24B) */
+/*
+ * TruFlow command to check if firmware is capable of
+ * supporting table scopes.
+ */
+/* hwrm_tfc_tbl_scope_qcaps_input (size:128b/16B) */
 
-typedef struct hwrm_queue_vlanpri_qcaps_input {
+typedef struct hwrm_tfc_tbl_scope_qcaps_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -28280,18 +55828,11 @@ typedef struct hwrm_queue_vlanpri_qcaps_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/*
-	 * Port ID of port for which the table is being configured.
-	 * The HWRM needs to check whether this function is allowed
-	 * to configure VLAN priority to user priority mapping on this port.
-	 */
-	uint8_t	port_id;
-	uint8_t	unused_0[7];
-} hwrm_queue_vlanpri_qcaps_input_t, *phwrm_queue_vlanpri_qcaps_input_t;
+} hwrm_tfc_tbl_scope_qcaps_input_t, *phwrm_tfc_tbl_scope_qcaps_input_t;
 
-/* hwrm_queue_vlanpri_qcaps_output (size:128b/16B) */
+/* hwrm_tfc_tbl_scope_qcaps_output (size:192b/24B) */
 
-typedef struct hwrm_queue_vlanpri_qcaps_output {
+typedef struct hwrm_tfc_tbl_scope_qcaps_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -28301,29 +55842,52 @@ typedef struct hwrm_queue_vlanpri_qcaps_output {
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
 	/*
-	 * This is the default user priority which all VLAN priority values
-	 * are mapped to if there is no VLAN priority to user priority mapping.
+	 * The maximum number of lookup records that a table scope can support.
+	 * This field is only valid if tbl_scope_capable is not zero.
 	 */
-	uint8_t	hw_default_pri;
-	uint8_t	unused_0[6];
+	uint32_t	max_lkup_rec_cnt;
+	/*
+	 * The maximum number of action records that a table scope can support.
+	 * This field is only valid if tbl_scope_capable is not zero.
+	 */
+	uint32_t	max_act_rec_cnt;
+	/* Not zero if firmware capable of table scopes. */
+	uint8_t	tbl_scope_capable;
+	/*
+	 * log2 of the number of lookup static buckets that a table scope can
+	 * support. This field is only valid if tbl_scope_capable is not zero.
+	 */
+	uint8_t	max_lkup_static_buckets_exp;
+	/* unused. */
+	uint8_t	unused0[5];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
 	uint8_t	valid;
-} hwrm_queue_vlanpri_qcaps_output_t, *phwrm_queue_vlanpri_qcaps_output_t;
+} hwrm_tfc_tbl_scope_qcaps_output_t, *phwrm_tfc_tbl_scope_qcaps_output_t;
 
 /*******************************
- * hwrm_queue_vlanpri2pri_qcfg *
+ * hwrm_tfc_tbl_scope_id_alloc *
  *******************************/
 
 
-/* hwrm_queue_vlanpri2pri_qcfg_input (size:192b/24B) */
+/*
+ * TruFlow command to allocate a table scope ID and create the pools.
+ *
+ * There is no corresponding free command since a table scope
+ * ID will automatically be freed once the last FID is removed.
+ * That is, when the hwrm_tfc_tbl_scope_fid_rem command returns
+ * a fid_cnt of 0 that also means that the table scope ID has
+ * been freed.
+ */
+/* hwrm_tfc_tbl_scope_id_alloc_input (size:256b/32B) */
 
-typedef struct hwrm_queue_vlanpri2pri_qcfg_input {
+typedef struct hwrm_tfc_tbl_scope_id_alloc_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -28353,17 +55917,41 @@ typedef struct hwrm_queue_vlanpri2pri_qcfg_input {
 	 */
 	uint64_t	resp_addr;
 	/*
-	 * Port ID of port for which the table is being configured.
-	 * The HWRM needs to check whether this function is allowed
-	 * to configure VLAN priority to user priority mapping on this port.
+	 * Function ID.
+	 * If running on a trusted VF or PF, the fid field can be used to
+	 * specify that the function is a non-trusted VF of the parent PF.
+	 * If this command is used for the target_id itself, this field is
+	 * set to 0xffff. A non-trusted VF cannot specify a valid FID in this
+	 * field.
 	 */
-	uint8_t	port_id;
-	uint8_t	unused_0[7];
-} hwrm_queue_vlanpri2pri_qcfg_input_t, *phwrm_queue_vlanpri2pri_qcfg_input_t;
+	uint16_t	fid;
+	/* The maximum number of pools for this table scope. */
+	uint16_t	max_pools;
+	/* Non-zero if this table scope is shared. */
+	uint8_t	shared;
+	/*
+	 * The size of the lookup pools per direction expressed as
+	 * log2(max_records/max_pools). That is, size=2^exp.
+	 *
+	 * Array is indexed by enum cfa_dir.
+	 */
+	uint8_t	lkup_pool_sz_exp[2];
+	/*
+	 * The size of the action pools per direction expressed as
+	 * log2(max_records/max_pools). That is, size=2^exp.
+	 *
+	 * Array is indexed by enum cfa_dir.
+	 */
+	uint8_t	act_pool_sz_exp[2];
+	/* Application type. 0 (AFM), 1 (TF) */
+	uint8_t	app_type;
+	/* unused. */
+	uint8_t	unused0[6];
+} hwrm_tfc_tbl_scope_id_alloc_input_t, *phwrm_tfc_tbl_scope_id_alloc_input_t;
 
-/* hwrm_queue_vlanpri2pri_qcfg_output (size:192b/24B) */
+/* hwrm_tfc_tbl_scope_id_alloc_output (size:128b/16B) */
 
-typedef struct hwrm_queue_vlanpri2pri_qcfg_output {
+typedef struct hwrm_tfc_tbl_scope_id_alloc_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -28372,73 +55960,35 @@ typedef struct hwrm_queue_vlanpri2pri_qcfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
+	/* The table scope ID that was allocated. */
+	uint8_t	tsid;
 	/*
-	 * User priority assigned to VLAN priority 0. A value of 0xff
-	 * indicates that no user priority is assigned. The default user
-	 * priority will be used.
-	 */
-	uint8_t	vlanpri0_user_pri_id;
-	/*
-	 * User priority assigned to VLAN priority 1. A value of 0xff
-	 * indicates that no user priority is assigned. The default user
-	 * priority will be used.
-	 */
-	uint8_t	vlanpri1_user_pri_id;
-	/*
-	 * User priority assigned to VLAN priority 2. A value of 0xff
-	 * indicates that no user priority is assigned. The default user
-	 * priority will be used.
-	 */
-	uint8_t	vlanpri2_user_pri_id;
-	/*
-	 * User priority assigned to VLAN priority 3. A value of 0xff
-	 * indicates that no user priority is assigned. The default user
-	 * priority will be used.
-	 */
-	uint8_t	vlanpri3_user_pri_id;
-	/*
-	 * User priority assigned to VLAN priority 4. A value of 0xff
-	 * indicates that no user priority is assigned. The default user
-	 * priority will be used.
-	 */
-	uint8_t	vlanpri4_user_pri_id;
-	/*
-	 * User priority assigned to VLAN priority 5. A value of 0xff
-	 * indicates that no user priority is assigned. The default user
-	 * priority will be used.
-	 */
-	uint8_t	vlanpri5_user_pri_id;
-	/*
-	 * User priority assigned to VLAN priority 6. A value of 0xff
-	 * indicates that no user priority is assigned. The default user
-	 * priority will be used.
-	 */
-	uint8_t	vlanpri6_user_pri_id;
-	/*
-	 * User priority assigned to VLAN priority 7. A value of 0xff
-	 * indicates that no user priority is assigned. The default user
-	 * priority will be used.
+	 * Non-zero if this is the first FID associated with this table scope
+	 * ID.
 	 */
-	uint8_t	vlanpri7_user_pri_id;
-	uint8_t	unused_0[7];
+	uint8_t	first;
+	/* unused. */
+	uint8_t	unused0[5];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
 	uint8_t	valid;
-} hwrm_queue_vlanpri2pri_qcfg_output_t, *phwrm_queue_vlanpri2pri_qcfg_output_t;
+} hwrm_tfc_tbl_scope_id_alloc_output_t, *phwrm_tfc_tbl_scope_id_alloc_output_t;
 
-/******************************
- * hwrm_queue_vlanpri2pri_cfg *
- ******************************/
+/*****************************
+ * hwrm_tfc_tbl_scope_config *
+ *****************************/
 
 
-/* hwrm_queue_vlanpri2pri_cfg_input (size:256b/32B) */
+/* TruFlow command to configure the table scope memory. */
+/* hwrm_tfc_tbl_scope_config_input (size:704b/88B) */
 
-typedef struct hwrm_queue_vlanpri2pri_cfg_input {
+typedef struct hwrm_tfc_tbl_scope_config_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -28455,111 +56005,71 @@ typedef struct hwrm_queue_vlanpri2pri_cfg_input {
 	/*
 	 * The target ID of the command:
 	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
-	 */
-	uint16_t	target_id;
-	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
-	 */
-	uint64_t	resp_addr;
-	uint32_t	enables;
-	/*
-	 * This bit must be '1' for the vlanpri0_user_pri_id field to be
-	 * configured.
-	 */
-	#define HWRM_QUEUE_VLANPRI2PRI_CFG_INPUT_ENABLES_VLANPRI0_USER_PRI_ID	UINT32_C(0x1)
-	/*
-	 * This bit must be '1' for the vlanpri1_user_pri_id field to be
-	 * configured.
-	 */
-	#define HWRM_QUEUE_VLANPRI2PRI_CFG_INPUT_ENABLES_VLANPRI1_USER_PRI_ID	UINT32_C(0x2)
-	/*
-	 * This bit must be '1' for the vlanpri2_user_pri_id field to be
-	 * configured.
-	 */
-	#define HWRM_QUEUE_VLANPRI2PRI_CFG_INPUT_ENABLES_VLANPRI2_USER_PRI_ID	UINT32_C(0x4)
-	/*
-	 * This bit must be '1' for the vlanpri3_user_pri_id field to be
-	 * configured.
-	 */
-	#define HWRM_QUEUE_VLANPRI2PRI_CFG_INPUT_ENABLES_VLANPRI3_USER_PRI_ID	UINT32_C(0x8)
-	/*
-	 * This bit must be '1' for the vlanpri4_user_pri_id field to be
-	 * configured.
-	 */
-	#define HWRM_QUEUE_VLANPRI2PRI_CFG_INPUT_ENABLES_VLANPRI4_USER_PRI_ID	UINT32_C(0x10)
-	/*
-	 * This bit must be '1' for the vlanpri5_user_pri_id field to be
-	 * configured.
-	 */
-	#define HWRM_QUEUE_VLANPRI2PRI_CFG_INPUT_ENABLES_VLANPRI5_USER_PRI_ID	UINT32_C(0x20)
-	/*
-	 * This bit must be '1' for the vlanpri6_user_pri_id field to be
-	 * configured.
-	 */
-	#define HWRM_QUEUE_VLANPRI2PRI_CFG_INPUT_ENABLES_VLANPRI6_USER_PRI_ID	UINT32_C(0x40)
-	/*
-	 * This bit must be '1' for the vlanpri7_user_pri_id field to be
-	 * configured.
-	 */
-	#define HWRM_QUEUE_VLANPRI2PRI_CFG_INPUT_ENABLES_VLANPRI7_USER_PRI_ID	UINT32_C(0x80)
-	/*
-	 * Port ID of port for which the table is being configured.
-	 * The HWRM needs to check whether this function is allowed
-	 * to configure VLAN priority to user priority mapping on this port.
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint8_t	port_id;
-	uint8_t	unused_0[3];
+	uint16_t	target_id;
 	/*
-	 * User priority assigned to VLAN priority 0. This value can only
-	 * be changed before traffic has started.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint8_t	vlanpri0_user_pri_id;
+	uint64_t	resp_addr;
 	/*
-	 * User priority assigned to VLAN priority 1. This value can only
-	 * be changed before traffic has started.
+	 * The base addresses for lookup memory.
+	 * Array is indexed by enum cfa_dir.
 	 */
-	uint8_t	vlanpri1_user_pri_id;
+	uint64_t	lkup_base_addr[2];
 	/*
-	 * User priority assigned to VLAN priority 2. This value can only
-	 * be changed before traffic has started.
+	 * The base addresses for action memory.
+	 * Array is indexed by enum cfa_dir.
 	 */
-	uint8_t	vlanpri2_user_pri_id;
+	uint64_t	act_base_addr[2];
 	/*
-	 * User priority assigned to VLAN priority 3. This value can only
-	 * be changed before traffic has started.
+	 * The number of minimum sized lkup records per direction.
+	 * In this usage, records are the minimum lookup memory
+	 * allocation unit in a table scope. This value is the total
+	 * memory required for buckets and entries.
+	 *
+	 * Array is indexed by enum cfa_dir.
 	 */
-	uint8_t	vlanpri3_user_pri_id;
+	uint64_t	lkup_rec_cnt;
 	/*
-	 * User priority assigned to VLAN priority 4. This value can only
-	 * be changed before traffic has started.
+	 * The number of minimum sized action records per direction.
+	 * Similar to the lkup_rec_cnt, records are the minimum
+	 * action memory allocation unit in a table scope.
+	 *
+	 * Array is indexed by enum cfa_dir.
 	 */
-	uint8_t	vlanpri4_user_pri_id;
+	uint64_t	act_rec_cnt;
 	/*
-	 * User priority assigned to VLAN priority 5. This value can only
-	 * be changed before traffic has started.
+	 * The number of static lookup buckets in the table scope.
+	 * Array is indexed by enum cfa_dir.
 	 */
-	uint8_t	vlanpri5_user_pri_id;
+	uint64_t	lkup_static_bucket_cnt;
+	/* The page size of the table scope. */
+	uint32_t	pbl_page_sz;
 	/*
-	 * User priority assigned to VLAN priority 6. This value can only
-	 * be changed before traffic has started.
+	 * The PBL level for lookup memory.
+	 * Array is indexed by enum cfa_dir.
 	 */
-	uint8_t	vlanpri6_user_pri_id;
+	uint8_t	lkup_pbl_level[2];
 	/*
-	 * User priority assigned to VLAN priority 7. This value can only
-	 * be changed before traffic has started.
+	 * The PBL level for action memory.
+	 * Array is indexed by enum cfa_dir.
 	 */
-	uint8_t	vlanpri7_user_pri_id;
-} hwrm_queue_vlanpri2pri_cfg_input_t, *phwrm_queue_vlanpri2pri_cfg_input_t;
+	uint8_t	act_pbl_level[2];
+	/* The table scope ID. */
+	uint8_t	tsid;
+	/* unused. */
+	uint8_t	unused0[7];
+} hwrm_tfc_tbl_scope_config_input_t, *phwrm_tfc_tbl_scope_config_input_t;
 
-/* hwrm_queue_vlanpri2pri_cfg_output (size:128b/16B) */
+/* hwrm_tfc_tbl_scope_config_output (size:128b/16B) */
 
-typedef struct hwrm_queue_vlanpri2pri_cfg_output {
+typedef struct hwrm_tfc_tbl_scope_config_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -28568,25 +56078,28 @@ typedef struct hwrm_queue_vlanpri2pri_cfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	/* unused. */
+	uint8_t	unused0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
 	uint8_t	valid;
-} hwrm_queue_vlanpri2pri_cfg_output_t, *phwrm_queue_vlanpri2pri_cfg_output_t;
+} hwrm_tfc_tbl_scope_config_output_t, *phwrm_tfc_tbl_scope_config_output_t;
 
-/*************************
- * hwrm_queue_global_cfg *
- *************************/
+/*******************************
+ * hwrm_tfc_tbl_scope_deconfig *
+ *******************************/
 
 
-/* hwrm_queue_global_cfg_input (size:192b/24B) */
+/* TruFlow command to deconfigure the table scope memory. */
+/* hwrm_tfc_tbl_scope_deconfig_input (size:192b/24B) */
 
-typedef struct hwrm_queue_global_cfg_input {
+typedef struct hwrm_tfc_tbl_scope_deconfig_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -28615,26 +56128,15 @@ typedef struct hwrm_queue_global_cfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/*
-	 * Configuration mode for rx cos queues, configuring whether they
-	 * use one shared buffer pool (across ports or PCIe endpoints) or
-	 * independent per port or per endpoint buffer pools.
-	 */
-	uint8_t	mode;
-	/* One shared buffer pool to be used by all RX CoS queues */
-	#define HWRM_QUEUE_GLOBAL_CFG_INPUT_MODE_SHARED	UINT32_C(0x0)
-	/*
-	 * Each port or PCIe endpoint to use an independent buffer pool
-	 * for its RX CoS queues
-	 */
-	#define HWRM_QUEUE_GLOBAL_CFG_INPUT_MODE_INDEPENDENT UINT32_C(0x1)
-	#define HWRM_QUEUE_GLOBAL_CFG_INPUT_MODE_LAST	HWRM_QUEUE_GLOBAL_CFG_INPUT_MODE_INDEPENDENT
-	uint8_t	unused_0[7];
-} hwrm_queue_global_cfg_input_t, *phwrm_queue_global_cfg_input_t;
+	/* The table scope ID. */
+	uint8_t	tsid;
+	/* unused. */
+	uint8_t	unused0[7];
+} hwrm_tfc_tbl_scope_deconfig_input_t, *phwrm_tfc_tbl_scope_deconfig_input_t;
 
-/* hwrm_queue_global_cfg_output (size:128b/16B) */
+/* hwrm_tfc_tbl_scope_deconfig_output (size:128b/16B) */
 
-typedef struct hwrm_queue_global_cfg_output {
+typedef struct hwrm_tfc_tbl_scope_deconfig_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -28643,25 +56145,28 @@ typedef struct hwrm_queue_global_cfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	/* unused. */
+	uint8_t	unused0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
 	uint8_t	valid;
-} hwrm_queue_global_cfg_output_t, *phwrm_queue_global_cfg_output_t;
+} hwrm_tfc_tbl_scope_deconfig_output_t, *phwrm_tfc_tbl_scope_deconfig_output_t;
 
-/**************************
- * hwrm_queue_global_qcfg *
- **************************/
+/******************************
+ * hwrm_tfc_tbl_scope_fid_add *
+ ******************************/
 
 
-/* hwrm_queue_global_qcfg_input (size:128b/16B) */
+/* TruFlow command to add a FID to a table scope. */
+/* hwrm_tfc_tbl_scope_fid_add_input (size:192b/24B) */
 
-typedef struct hwrm_queue_global_qcfg_input {
+typedef struct hwrm_tfc_tbl_scope_fid_add_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -28690,11 +56195,24 @@ typedef struct hwrm_queue_global_qcfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-} hwrm_queue_global_qcfg_input_t, *phwrm_queue_global_qcfg_input_t;
+	/*
+	 * Function ID.
+	 * If running on a trusted VF or PF, the fid field can be used to
+	 * specify that the function is a non-trusted VF of the parent PF.
+	 * If this command is used for the target_id itself, this field is
+	 * set to 0xffff. A non-trusted VF cannot specify a valid FID in this
+	 * field.
+	 */
+	uint16_t	fid;
+	/* The table scope ID. */
+	uint8_t	tsid;
+	/* unused. */
+	uint8_t	unused0[5];
+} hwrm_tfc_tbl_scope_fid_add_input_t, *phwrm_tfc_tbl_scope_fid_add_input_t;
 
-/* hwrm_queue_global_qcfg_output (size:256b/32B) */
+/* hwrm_tfc_tbl_scope_fid_add_output (size:128b/16B) */
 
-typedef struct hwrm_queue_global_qcfg_output {
+typedef struct hwrm_tfc_tbl_scope_fid_add_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -28703,71 +56221,30 @@ typedef struct hwrm_queue_global_qcfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* Port or PCIe endpoint id to be mapped for buffer pool 0. */
-	uint8_t	buffer_pool_id0_map;
-	/* Port or PCIe endpoint id to be mapped for buffer pool 1. */
-	uint8_t	buffer_pool_id1_map;
-	/* Port or PCIe endpoint id to be mapped for buffer pool 2. */
-	uint8_t	buffer_pool_id2_map;
-	/* Port or PCIe endpoint id to be mapped for buffer pool 3. */
-	uint8_t	buffer_pool_id3_map;
-	/* Size of buffer pool 0 (KBytes). */
-	uint32_t	buffer_pool_id0_size;
-	/* Size of buffer pool 1 (KBytes). */
-	uint32_t	buffer_pool_id1_size;
-	/* Size of buffer pool 2 (KBytes). */
-	uint32_t	buffer_pool_id2_size;
-	/* Size of buffer pool 3 (KBytes). */
-	uint32_t	buffer_pool_id3_size;
-	uint16_t	flags;
-	/*
-	 * Enumeration denoting whether the rx buffer pool mapping is
-	 * per port or per PCIe endpoint
-	 */
-	#define HWRM_QUEUE_GLOBAL_QCFG_OUTPUT_FLAGS_MAPPING			UINT32_C(0x1)
-	/*
-	 * The buffer_pool_id[0-3]_map field represents mapping of rx
-	 * buffer pools to a port.
-	 */
-		#define HWRM_QUEUE_GLOBAL_QCFG_OUTPUT_FLAGS_MAPPING_MAPPING_PER_PORT	UINT32_C(0x0)
-	/*
-	 * The buffer_pool_id[0-3]_map field represents mapping of rx
-	 * buffer pools to a PCIe endpoint.
-	 */
-		#define HWRM_QUEUE_GLOBAL_QCFG_OUTPUT_FLAGS_MAPPING_MAPPING_PER_ENDPOINT  UINT32_C(0x1)
-		#define HWRM_QUEUE_GLOBAL_QCFG_OUTPUT_FLAGS_MAPPING_LAST		HWRM_QUEUE_GLOBAL_QCFG_OUTPUT_FLAGS_MAPPING_MAPPING_PER_ENDPOINT
-	/*
-	 * Configuration mode for rx cos queues, configuring whether they
-	 * use one shared buffer pool (across ports or PCIe endpoints) or
-	 * independent per port or per endpoint buffer pools.
-	 */
-	uint8_t	mode;
-	/* One shared buffer pool to be used by all RX CoS queues */
-	#define HWRM_QUEUE_GLOBAL_QCFG_OUTPUT_MODE_SHARED	UINT32_C(0x0)
-	/*
-	 * Each port or PCIe endpoint to use an independent buffer pool
-	 * for its RX CoS queues
-	 */
-	#define HWRM_QUEUE_GLOBAL_QCFG_OUTPUT_MODE_INDEPENDENT UINT32_C(0x1)
-	#define HWRM_QUEUE_GLOBAL_QCFG_OUTPUT_MODE_LAST	HWRM_QUEUE_GLOBAL_QCFG_OUTPUT_MODE_INDEPENDENT
+	/* The number of FIDs currently in the table scope ID. */
+	uint8_t	fid_cnt;
+	/* unused. */
+	uint8_t	unused0[6];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
 	uint8_t	valid;
-} hwrm_queue_global_qcfg_output_t, *phwrm_queue_global_qcfg_output_t;
+} hwrm_tfc_tbl_scope_fid_add_output_t, *phwrm_tfc_tbl_scope_fid_add_output_t;
 
-/*******************
- * hwrm_vnic_alloc *
- *******************/
+/******************************
+ * hwrm_tfc_tbl_scope_fid_rem *
+ ******************************/
 
 
-/* hwrm_vnic_alloc_input (size:192b/24B) */
+/* TruFlow command to remove a FID from a table scope. */
+/* hwrm_tfc_tbl_scope_fid_rem_input (size:192b/24B) */
 
-typedef struct hwrm_vnic_alloc_input {
+typedef struct hwrm_tfc_tbl_scope_fid_rem_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -28796,30 +56273,24 @@ typedef struct hwrm_vnic_alloc_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	flags;
-	/*
-	 * When this bit is '1', this VNIC is requested to
-	 * be the default VNIC for this function.
-	 */
-	#define HWRM_VNIC_ALLOC_INPUT_FLAGS_DEFAULT		UINT32_C(0x1)
-	/*
-	 * When this bit is '1', proxy VEE PF is requesting
-	 * allocation of a default VNIC on behalf of virtio-net
-	 * function given in virtio_net_fid field.
-	 */
-	#define HWRM_VNIC_ALLOC_INPUT_FLAGS_VIRTIO_NET_FID_VALID	UINT32_C(0x2)
 	/*
-	 * Virtio-net function's FID.
-	 * This virtio-net function is requesting allocation of default
-	 * VNIC through proxy VEE PF.
+	 * Function ID.
+	 * If running on a trusted VF or PF, the fid field can be used to
+	 * specify that the function is a non-trusted VF of the parent PF.
+	 * If this command is used for the target_id itself, this field is
+	 * set to 0xffff. A non-trusted VF cannot specify a valid FID in this
+	 * field.
 	 */
-	uint16_t	virtio_net_fid;
-	uint8_t	unused_0[2];
-} hwrm_vnic_alloc_input_t, *phwrm_vnic_alloc_input_t;
+	uint16_t	fid;
+	/* The table scope ID. */
+	uint8_t	tsid;
+	/* unused. */
+	uint8_t	unused0[5];
+} hwrm_tfc_tbl_scope_fid_rem_input_t, *phwrm_tfc_tbl_scope_fid_rem_input_t;
 
-/* hwrm_vnic_alloc_output (size:128b/16B) */
+/* hwrm_tfc_tbl_scope_fid_rem_output (size:128b/16B) */
 
-typedef struct hwrm_vnic_alloc_output {
+typedef struct hwrm_tfc_tbl_scope_fid_rem_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -28828,27 +56299,36 @@ typedef struct hwrm_vnic_alloc_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* Logical vnic ID */
-	uint32_t	vnic_id;
-	uint8_t	unused_0[3];
+	/* The number of FIDs remaining in the table scope ID. */
+	uint16_t	fid_cnt;
+	/* unused. */
+	uint8_t	unused0[5];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
 	uint8_t	valid;
-} hwrm_vnic_alloc_output_t, *phwrm_vnic_alloc_output_t;
+} hwrm_tfc_tbl_scope_fid_rem_output_t, *phwrm_tfc_tbl_scope_fid_rem_output_t;
 
-/********************
- * hwrm_vnic_update *
- ********************/
+/*****************************
+ * hwrm_tfc_session_id_alloc *
+ *****************************/
 
 
-/* hwrm_vnic_update_input (size:256b/32B) */
+/*
+ * Allocate a TFC session. Requests the firmware to allocate a TFC
+ * session identifier and associate a forwarding function with the
+ * session. Though there's not an explicit matching free for a session
+ * id alloc, dis-associating the last fid from a session id (fid_cnt goes
+ * to 0), will result in this session id being freed automatically.
+ */
+/* hwrm_tfc_session_id_alloc_input (size:192b/24B) */
 
-typedef struct hwrm_vnic_update_input {
+typedef struct hwrm_tfc_session_id_alloc_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -28877,68 +56357,22 @@ typedef struct hwrm_vnic_update_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Logical vnic ID */
-	uint32_t	vnic_id;
-	uint32_t	enables;
-	/*
-	 * This bit must be '1' for the vnic_state field to be
-	 * configured.
-	 */
-	#define HWRM_VNIC_UPDATE_INPUT_ENABLES_VNIC_STATE_VALID		UINT32_C(0x1)
-	/*
-	 * This bit must be '1' for the mru field to be
-	 * configured.
-	 */
-	#define HWRM_VNIC_UPDATE_INPUT_ENABLES_MRU_VALID			UINT32_C(0x2)
-	/*
-	 * This bit must be '1' for the metadata_format_type field to be
-	 * configured.
-	 */
-	#define HWRM_VNIC_UPDATE_INPUT_ENABLES_METADATA_FORMAT_TYPE_VALID	UINT32_C(0x4)
-	/*
-	 * This will update the context variable with the same name if
-	 * the corresponding enable is set.
-	 */
-	uint8_t	vnic_state;
-	/* Normal operation state for the VNIC. */
-	#define HWRM_VNIC_UPDATE_INPUT_VNIC_STATE_NORMAL UINT32_C(0x0)
-	/* All packets are dropped in this state. */
-	#define HWRM_VNIC_UPDATE_INPUT_VNIC_STATE_DROP   UINT32_C(0x1)
-	#define HWRM_VNIC_UPDATE_INPUT_VNIC_STATE_LAST  HWRM_VNIC_UPDATE_INPUT_VNIC_STATE_DROP
-	/*
-	 * The metadata format type used in all the RX packet completions
-	 * going through this VNIC.
-	 */
-	uint8_t	metadata_format_type;
-	/* No metadata information. */
-	#define HWRM_VNIC_UPDATE_INPUT_METADATA_FORMAT_TYPE_NONE		UINT32_C(0x0)
-	/*
-	 * Action record pointer (table_scope[4:0], act_rec_ptr[25:0],
-	 * vtag[19:0]).
-	 */
-	#define HWRM_VNIC_UPDATE_INPUT_METADATA_FORMAT_TYPE_ACT_RECORD_PTR  UINT32_C(0x1)
-	/* Tunnel ID (tunnel_id[31:0], vtag[19:0]) */
-	#define HWRM_VNIC_UPDATE_INPUT_METADATA_FORMAT_TYPE_TUNNEL_ID	UINT32_C(0x2)
-	/* Custom header data (updated_chdr_data[31:0], vtag[19:0]) */
-	#define HWRM_VNIC_UPDATE_INPUT_METADATA_FORMAT_TYPE_CUSTOM_HDR_DATA UINT32_C(0x3)
-	/* Header offsets (hdr_offsets[31:0], vtag[19:0]) */
-	#define HWRM_VNIC_UPDATE_INPUT_METADATA_FORMAT_TYPE_HDR_OFFSETS	UINT32_C(0x4)
-	#define HWRM_VNIC_UPDATE_INPUT_METADATA_FORMAT_TYPE_LAST	HWRM_VNIC_UPDATE_INPUT_METADATA_FORMAT_TYPE_HDR_OFFSETS
 	/*
-	 * The maximum receive unit of the vnic.
-	 * Each vnic is associated with a function.
-	 * The vnic mru value overwrites the mru setting of the
-	 * associated function.
-	 * The HWRM shall make sure that vnic mru does not exceed
-	 * the mru of the port the function is associated with.
+	 * Function ID.
+	 * If running on a trusted VF or PF, the fid field can be used to
+	 * specify that the function is a non-trusted VF of the parent PF.
+	 * If this command is used for the target_id itself, this field is
+	 * set to 0xffff. A non-trusted VF cannot specify a valid FID in this
+	 * field.
 	 */
-	uint16_t	mru;
-	uint8_t	unused_1[4];
-} hwrm_vnic_update_input_t, *phwrm_vnic_update_input_t;
+	uint16_t	fid;
+	/* Unused field */
+	uint8_t	unused0[6];
+} hwrm_tfc_session_id_alloc_input_t, *phwrm_tfc_session_id_alloc_input_t;
 
-/* hwrm_vnic_update_output (size:128b/16B) */
+/* hwrm_tfc_session_id_alloc_output (size:128b/16B) */
 
-typedef struct hwrm_vnic_update_output {
+typedef struct hwrm_tfc_session_id_alloc_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -28947,26 +56381,36 @@ typedef struct hwrm_vnic_update_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	/*
+	 * Unique session identifier for the session created by the
+	 * firmware.
+	 */
+	uint16_t	sid;
+	/* Unused field */
+	uint8_t	unused0[5];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
 	 * When writing a command completion or response to an internal
 	 * processor, the order of writes has to be such that this field is
 	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_vnic_update_output_t, *phwrm_vnic_update_output_t;
+} hwrm_tfc_session_id_alloc_output_t, *phwrm_tfc_session_id_alloc_output_t;
 
-/******************
- * hwrm_vnic_free *
- ******************/
+/****************************
+ * hwrm_tfc_session_fid_add *
+ ****************************/
 
 
-/* hwrm_vnic_free_input (size:192b/24B) */
+/*
+ * Associate a TFC session id with a forwarding function. The target_fid
+ * will be associated with the passed in sid.
+ */
+/* hwrm_tfc_session_fid_add_input (size:192b/24B) */
 
-typedef struct hwrm_vnic_free_input {
+typedef struct hwrm_tfc_session_fid_add_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -28995,14 +56439,27 @@ typedef struct hwrm_vnic_free_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Logical vnic ID */
-	uint32_t	vnic_id;
-	uint8_t	unused_0[4];
-} hwrm_vnic_free_input_t, *phwrm_vnic_free_input_t;
+	/*
+	 * Function ID.
+	 * If running on a trusted VF or PF, the fid field can be used to
+	 * specify that the function is a non-trusted VF of the parent PF.
+	 * If this command is used for the target_id itself, this field is
+	 * set to 0xffff. A non-trusted VF cannot specify a valid FID in this
+	 * field.
+	 */
+	uint16_t	fid;
+	/*
+	 * Unique session identifier for the session created by the
+	 * firmware.
+	 */
+	uint16_t	sid;
+	/* Unused field */
+	uint8_t	unused0[4];
+} hwrm_tfc_session_fid_add_input_t, *phwrm_tfc_session_fid_add_input_t;
 
-/* hwrm_vnic_free_output (size:128b/16B) */
+/* hwrm_tfc_session_fid_add_output (size:128b/16B) */
 
-typedef struct hwrm_vnic_free_output {
+typedef struct hwrm_tfc_session_fid_add_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -29011,25 +56468,36 @@ typedef struct hwrm_vnic_free_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	/* The number of FIDs that share this session. */
+	uint16_t	fid_cnt;
+	/* Unused field */
+	uint8_t	unused0[5];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_vnic_free_output_t, *phwrm_vnic_free_output_t;
+} hwrm_tfc_session_fid_add_output_t, *phwrm_tfc_session_fid_add_output_t;
 
-/*****************
- * hwrm_vnic_cfg *
- *****************/
+/****************************
+ * hwrm_tfc_session_fid_rem *
+ ****************************/
 
 
-/* hwrm_vnic_cfg_input (size:384b/48B) */
+/*
+ * Dis-associate a TFC session from the target_fid.
+ * Though there's not an explicit matching free for a
+ * session id alloc, dis-associating the last fid from a session id
+ * (fid_cnt goes to 0), will result in this session id being freed
+ * automatically.
+ */
+/* hwrm_tfc_session_fid_rem_input (size:192b/24B) */
 
-typedef struct hwrm_vnic_cfg_input {
+typedef struct hwrm_tfc_session_fid_rem_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -29058,205 +56526,137 @@ typedef struct hwrm_vnic_cfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	flags;
-	/*
-	 * When this bit is '1', the VNIC is requested to
-	 * be the default VNIC for the function.
-	 */
-	#define HWRM_VNIC_CFG_INPUT_FLAGS_DEFAULT				UINT32_C(0x1)
-	/*
-	 * When this bit is '1', the VNIC is being configured to
-	 * strip VLAN in the RX path.
-	 * If set to '0', then VLAN stripping is disabled on
-	 * this VNIC.
-	 */
-	#define HWRM_VNIC_CFG_INPUT_FLAGS_VLAN_STRIP_MODE			UINT32_C(0x2)
-	/*
-	 * When this bit is '1', the VNIC is being configured to
-	 * buffer receive packets in the hardware until the host
-	 * posts new receive buffers.
-	 * If set to '0', then bd_stall is being configured to be
-	 * disabled on this VNIC.
-	 */
-	#define HWRM_VNIC_CFG_INPUT_FLAGS_BD_STALL_MODE			UINT32_C(0x4)
-	/*
-	 * When this bit is '1', the VNIC is being configured to
-	 * receive both RoCE and non-RoCE traffic.
-	 * If set to '0', then this VNIC is not configured to be
-	 * operating in dual VNIC mode.
-	 */
-	#define HWRM_VNIC_CFG_INPUT_FLAGS_ROCE_DUAL_VNIC_MODE		UINT32_C(0x8)
-	/*
-	 * When this flag is set to '1', the VNIC is requested to
-	 * be configured to receive only RoCE traffic.
-	 * If this flag is set to '0', then this flag shall be
-	 * ignored by the HWRM.
-	 * If roce_dual_vnic_mode flag is set to '1'
-	 * or roce_mirroring_capable_vnic_mode flag to 1,
-	 * then the HWRM client shall not set this flag to '1'.
-	 */
-	#define HWRM_VNIC_CFG_INPUT_FLAGS_ROCE_ONLY_VNIC_MODE		UINT32_C(0x10)
-	/*
-	 * When a VNIC uses one destination ring group for certain
-	 * application (e.g. Receive Flow Steering) where
-	 * exact match is used to direct packets to a VNIC with one
-	 * destination ring group only, there is no need to configure
-	 * RSS indirection table for that VNIC as only one destination
-	 * ring group is used.
-	 *
-	 * This flag is used to enable a mode where
-	 * RSS is enabled in the VNIC using a RSS context
-	 * for computing RSS hash but the RSS indirection table is
-	 * not configured using hwrm_vnic_rss_cfg.
-	 *
-	 * If this mode is enabled, then the driver should not program
-	 * RSS indirection table for the RSS context that is used for
-	 * computing RSS hash only.
-	 */
-	#define HWRM_VNIC_CFG_INPUT_FLAGS_RSS_DFLT_CR_MODE			UINT32_C(0x20)
-	/*
-	 * When this bit is '1', the VNIC is being configured to
-	 * receive both RoCE and non-RoCE traffic, but forward only the
-	 * RoCE traffic further. Also, RoCE traffic can be mirrored to
-	 * L2 driver.
-	 */
-	#define HWRM_VNIC_CFG_INPUT_FLAGS_ROCE_MIRRORING_CAPABLE_VNIC_MODE	UINT32_C(0x40)
-	uint32_t	enables;
-	/*
-	 * This bit must be '1' for the dflt_ring_grp field to be
-	 * configured.
-	 */
-	#define HWRM_VNIC_CFG_INPUT_ENABLES_DFLT_RING_GRP		UINT32_C(0x1)
-	/*
-	 * This bit must be '1' for the rss_rule field to be
-	 * configured.
-	 */
-	#define HWRM_VNIC_CFG_INPUT_ENABLES_RSS_RULE		UINT32_C(0x2)
-	/*
-	 * This bit must be '1' for the cos_rule field to be
-	 * configured.
-	 */
-	#define HWRM_VNIC_CFG_INPUT_ENABLES_COS_RULE		UINT32_C(0x4)
-	/*
-	 * This bit must be '1' for the lb_rule field to be
-	 * configured.
-	 */
-	#define HWRM_VNIC_CFG_INPUT_ENABLES_LB_RULE		UINT32_C(0x8)
-	/*
-	 * This bit must be '1' for the mru field to be
-	 * configured.
-	 */
-	#define HWRM_VNIC_CFG_INPUT_ENABLES_MRU			UINT32_C(0x10)
-	/*
-	 * This bit must be '1' for the default_rx_ring_id field to be
-	 * configured.
-	 */
-	#define HWRM_VNIC_CFG_INPUT_ENABLES_DEFAULT_RX_RING_ID	UINT32_C(0x20)
-	/*
-	 * This bit must be '1' for the default_cmpl_ring_id field to be
-	 * configured.
-	 */
-	#define HWRM_VNIC_CFG_INPUT_ENABLES_DEFAULT_CMPL_RING_ID	UINT32_C(0x40)
-	/* This bit must be '1' for the queue_id field to be configured. */
-	#define HWRM_VNIC_CFG_INPUT_ENABLES_QUEUE_ID		UINT32_C(0x80)
-	/* This bit must be '1' for the rx_csum_v2_mode field to be configured. */
-	#define HWRM_VNIC_CFG_INPUT_ENABLES_RX_CSUM_V2_MODE	UINT32_C(0x100)
-	/* Logical vnic ID */
-	uint16_t	vnic_id;
-	/*
-	 * Default Completion ring for the VNIC.  This ring will
-	 * be chosen if packet does not match any RSS rules and if
-	 * there is no COS rule.
-	 */
-	uint16_t	dflt_ring_grp;
-	/*
-	 * RSS ID for RSS rule/table structure.  0xFF... (All Fs) if
-	 * there is no RSS rule.
-	 */
-	uint16_t	rss_rule;
 	/*
-	 * RSS ID for COS rule/table structure.  0xFF... (All Fs) if
-	 * there is no COS rule.
+	 * Function ID.
+	 * If running on a trusted VF or PF, the fid field can be used to
+	 * specify that the function is a non-trusted VF of the parent PF.
+	 * If this command is used for the target_id itself, this field is
+	 * set to 0xffff. A non-trusted VF cannot specify a valid FID in this
+	 * field.
 	 */
-	uint16_t	cos_rule;
+	uint16_t	fid;
 	/*
-	 * RSS ID for load balancing rule/table structure.
-	 * 0xFF... (All Fs) if there is no LB rule.
+	 * Unique session identifier for the session created by the
+	 * firmware.
 	 */
-	uint16_t	lb_rule;
+	uint16_t	sid;
+	/* Unused field */
+	uint8_t	unused0[4];
+} hwrm_tfc_session_fid_rem_input_t, *phwrm_tfc_session_fid_rem_input_t;
+
+/* hwrm_tfc_session_fid_rem_output (size:128b/16B) */
+
+typedef struct hwrm_tfc_session_fid_rem_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* The number of FIDs that share this session. */
+	uint16_t	fid_cnt;
+	/* Unused field */
+	uint8_t	unused0[5];
 	/*
-	 * The maximum receive unit of the vnic.
-	 * Each vnic is associated with a function.
-	 * The vnic mru value overwrites the mru setting of the
-	 * associated function.
-	 * The HWRM shall make sure that vnic mru does not exceed
-	 * the mru of the port the function is associated with.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	uint16_t	mru;
+	uint8_t	valid;
+} hwrm_tfc_session_fid_rem_output_t, *phwrm_tfc_session_fid_rem_output_t;
+
+/************************
+ * hwrm_tfc_ident_alloc *
+ ************************/
+
+
+/*
+ * Allocate a TFC identifier. Requests the firmware to
+ * allocate a TFC identifier. The session id and track_type are passed
+ * in. The tracking_id is either the sid or target_fid depends on the
+ * track_type. The resource subtype is passed in, an id corresponding
+ * to all these is allocated and returned in the HWRM response.
+ */
+/* hwrm_tfc_ident_alloc_input (size:192b/24B) */
+
+typedef struct hwrm_tfc_ident_alloc_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * Default Rx ring for the VNIC.  This ring will
-	 * be chosen if packet does not match any RSS rules.
-	 * The aggregation ring associated with the Rx ring is
-	 * implied based on the Rx ring specified when the
-	 * aggregation ring was allocated.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint16_t	default_rx_ring_id;
+	uint16_t	cmpl_ring;
 	/*
-	 * Default completion ring for the VNIC.  This ring will
-	 * be chosen if packet does not match any RSS rules.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint16_t	default_cmpl_ring_id;
+	uint16_t	seq_id;
 	/*
-	 * When specified, only incoming packets classified to the specified CoS
-	 * queue ID will be arriving on this VNIC.  Packet priority to CoS mapping
-	 * rules can be specified using HWRM_QUEUE_PRI2COS_CFG.  In this mode,
-	 * ntuple filters with VNIC destination specified are invalid since they
-	 * conflict with the the CoS to VNIC steering rules in this mode.
-	 *
-	 * If this field is not specified, packet to VNIC steering will be
-	 * subject to the standard L2 filter rules and any additional ntuple
-	 * filter rules with destination VNIC specified.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint16_t	queue_id;
+	uint16_t	target_id;
 	/*
-	 * If the device supports the RX V2 and RX TPA start V2 completion
-	 * records as indicated by the HWRM_VNIC_QCAPS command, this field is
-	 * used to specify the two RX checksum modes supported by these
-	 * completion records.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint8_t	rx_csum_v2_mode;
+	uint64_t	resp_addr;
 	/*
-	 * When configured with this checksum mode, the number of header
-	 * groups in the delivered packet with a valid IP checksum and
-	 * the number of header groups in the delivered packet with a valid
-	 * L4 checksum are reported. Valid checksums are counted from the
-	 * outermost header group to the innermost header group, stopping at
-	 * the first error.  This is the default checksum mode supported if
-	 * the driver doesn't explicitly configure the RX checksum mode.
+	 * Function ID.
+	 * If running on a trusted VF or PF, the fid field can be used to
+	 * specify that the function is a non-trusted VF of the parent PF.
+	 * If this command is used for the target_id itself, this field is
+	 * set to 0xffff. A non-trusted VF cannot specify a valid FID in this
+	 * field.
 	 */
-	#define HWRM_VNIC_CFG_INPUT_RX_CSUM_V2_MODE_DEFAULT UINT32_C(0x0)
+	uint16_t	fid;
 	/*
-	 * When configured with this checksum mode, the checksum status is
-	 * reported using 'all ok' mode. In the RX completion record, one
-	 * bit indicates if the IP checksum is valid for all the parsed
-	 * header groups with an IP checksum. Another bit indicates if the
-	 * L4 checksum is valid for all the parsed header groups with an L4
-	 * checksum. The number of header groups that were parsed by the
-	 * chip and passed in the delivered packet is also reported.
+	 * Unique session identifier for the session created by the
+	 * firmware. Will be used to track this identifier.
 	 */
-	#define HWRM_VNIC_CFG_INPUT_RX_CSUM_V2_MODE_ALL_OK  UINT32_C(0x1)
+	uint16_t	sid;
+	/* Control flags. Direction. */
+	uint8_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TFC_IDENT_ALLOC_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TFC_IDENT_ALLOC_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TFC_IDENT_ALLOC_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TFC_IDENT_ALLOC_INPUT_FLAGS_DIR_LAST HWRM_TFC_IDENT_ALLOC_INPUT_FLAGS_DIR_TX
 	/*
-	 * Any rx_csum_v2_mode value larger than or equal to this is not
-	 * valid
+	 * CFA resource subtype. For definitions, please see
+	 * cfa_v3/include/cfa_resources.h.
 	 */
-	#define HWRM_VNIC_CFG_INPUT_RX_CSUM_V2_MODE_MAX	UINT32_C(0x2)
-	#define HWRM_VNIC_CFG_INPUT_RX_CSUM_V2_MODE_LAST   HWRM_VNIC_CFG_INPUT_RX_CSUM_V2_MODE_MAX
-	uint8_t	unused0[5];
-} hwrm_vnic_cfg_input_t, *phwrm_vnic_cfg_input_t;
+	uint8_t	subtype;
+	/* Describes the type of tracking tag to be used */
+	uint8_t	track_type;
+	/* Invalid track type */
+	#define HWRM_TFC_IDENT_ALLOC_INPUT_TRACK_TYPE_TRACK_TYPE_INVALID UINT32_C(0x0)
+	/* Tracked by session id */
+	#define HWRM_TFC_IDENT_ALLOC_INPUT_TRACK_TYPE_TRACK_TYPE_SID	UINT32_C(0x1)
+	/* Tracked by function id */
+	#define HWRM_TFC_IDENT_ALLOC_INPUT_TRACK_TYPE_TRACK_TYPE_FID	UINT32_C(0x2)
+	#define HWRM_TFC_IDENT_ALLOC_INPUT_TRACK_TYPE_LAST		HWRM_TFC_IDENT_ALLOC_INPUT_TRACK_TYPE_TRACK_TYPE_FID
+	/* Unused field */
+	uint8_t	unused0;
+} hwrm_tfc_ident_alloc_input_t, *phwrm_tfc_ident_alloc_input_t;
 
-/* hwrm_vnic_cfg_output (size:128b/16B) */
+/* hwrm_tfc_ident_alloc_output (size:128b/16B) */
 
-typedef struct hwrm_vnic_cfg_output {
+typedef struct hwrm_tfc_ident_alloc_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -29265,25 +56665,38 @@ typedef struct hwrm_vnic_cfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	/*
+	 * Resource identifier allocated by the firmware using
+	 * parameters above.
+	 */
+	uint16_t	ident_id;
+	/* Unused field */
+	uint8_t	unused0[5];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_vnic_cfg_output_t, *phwrm_vnic_cfg_output_t;
+} hwrm_tfc_ident_alloc_output_t, *phwrm_tfc_ident_alloc_output_t;
 
-/******************
- * hwrm_vnic_qcfg *
- ******************/
+/***********************
+ * hwrm_tfc_ident_free *
+ ***********************/
 
 
-/* hwrm_vnic_qcfg_input (size:256b/32B) */
+/*
+ * Requests the firmware to free a TFC resource identifier.
+ * A resource subtype and session id are passed in.
+ * An identifier (previously allocated) corresponding to all these is
+ * freed, only after various sanity checks are completed.
+ */
+/* hwrm_tfc_ident_free_input (size:192b/24B) */
 
-typedef struct hwrm_vnic_qcfg_input {
+typedef struct hwrm_tfc_ident_free_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -29312,22 +56725,41 @@ typedef struct hwrm_vnic_qcfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	enables;
 	/*
-	 * This bit must be '1' for the vf_id_valid field to be
-	 * configured.
+	 * Function ID.
+	 * If running on a trusted VF or PF, the fid field can be used to
+	 * specify that the function is a non-trusted VF of the parent PF.
+	 * If this command is used for the target_id itself, this field is
+	 * set to 0xffff. A non-trusted VF cannot specify a valid FID in this
+	 * field.
 	 */
-	#define HWRM_VNIC_QCFG_INPUT_ENABLES_VF_ID_VALID	UINT32_C(0x1)
-	/* Logical vnic ID */
-	uint32_t	vnic_id;
-	/* ID of Virtual Function whose VNIC resource is being queried. */
-	uint16_t	vf_id;
-	uint8_t	unused_0[6];
-} hwrm_vnic_qcfg_input_t, *phwrm_vnic_qcfg_input_t;
+	uint16_t	fid;
+	/*
+	 * Unique session identifier for the session created by the
+	 * firmware. Will be used to validate this request.
+	 */
+	uint16_t	sid;
+	/*
+	 * CFA resource subtype. For definitions, please see
+	 * cfa_v3/include/cfa_resources.h.
+	 */
+	uint8_t	subtype;
+	/* Control flags. Direction. */
+	uint8_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TFC_IDENT_FREE_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TFC_IDENT_FREE_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TFC_IDENT_FREE_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TFC_IDENT_FREE_INPUT_FLAGS_DIR_LAST HWRM_TFC_IDENT_FREE_INPUT_FLAGS_DIR_TX
+	/* The resource identifier to be freed */
+	uint16_t	ident_id;
+} hwrm_tfc_ident_free_input_t, *phwrm_tfc_ident_free_input_t;
 
-/* hwrm_vnic_qcfg_output (size:256b/32B) */
+/* hwrm_tfc_ident_free_output (size:128b/16B) */
 
-typedef struct hwrm_vnic_qcfg_output {
+typedef struct hwrm_tfc_ident_free_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -29336,141 +56768,27 @@ typedef struct hwrm_vnic_qcfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* Default Completion ring for the VNIC. */
-	uint16_t	dflt_ring_grp;
-	/*
-	 * RSS ID for RSS rule/table structure.  0xFF... (All Fs) if
-	 * there is no RSS rule.
-	 */
-	uint16_t	rss_rule;
-	/*
-	 * RSS ID for COS rule/table structure.  0xFF... (All Fs) if
-	 * there is no COS rule.
-	 */
-	uint16_t	cos_rule;
-	/*
-	 * RSS ID for load balancing rule/table structure.
-	 * 0xFF... (All Fs) if there is no LB rule.
-	 */
-	uint16_t	lb_rule;
-	/* The maximum receive unit of the vnic. */
-	uint16_t	mru;
-	uint8_t	unused_0[2];
-	uint32_t	flags;
-	/*
-	 * When this bit is '1', the VNIC is the default VNIC for
-	 * the function.
-	 */
-	#define HWRM_VNIC_QCFG_OUTPUT_FLAGS_DEFAULT				UINT32_C(0x1)
-	/*
-	 * When this bit is '1', the VNIC is configured to
-	 * strip VLAN in the RX path.
-	 * If set to '0', then VLAN stripping is disabled on
-	 * this VNIC.
-	 */
-	#define HWRM_VNIC_QCFG_OUTPUT_FLAGS_VLAN_STRIP_MODE			UINT32_C(0x2)
-	/*
-	 * When this bit is '1', the VNIC is configured to
-	 * buffer receive packets in the hardware until the host
-	 * posts new receive buffers.
-	 * If set to '0', then bd_stall is disabled on
-	 * this VNIC.
-	 */
-	#define HWRM_VNIC_QCFG_OUTPUT_FLAGS_BD_STALL_MODE			UINT32_C(0x4)
-	/*
-	 * When this bit is '1', the VNIC is configured to
-	 * receive both RoCE and non-RoCE traffic.
-	 * If set to '0', then this VNIC is not configured to
-	 * operate in dual VNIC mode.
-	 */
-	#define HWRM_VNIC_QCFG_OUTPUT_FLAGS_ROCE_DUAL_VNIC_MODE		UINT32_C(0x8)
-	/*
-	 * When this flag is set to '1', the VNIC is configured to
-	 * receive only RoCE traffic.
-	 * When this flag is set to '0', the VNIC is not configured
-	 * to receive only RoCE traffic.
-	 * If roce_dual_vnic_mode flag and this flag both are set
-	 * to '1', then it is an invalid configuration of the
-	 * VNIC. The HWRM should not allow that type of
-	 * mis-configuration by HWRM clients.
-	 */
-	#define HWRM_VNIC_QCFG_OUTPUT_FLAGS_ROCE_ONLY_VNIC_MODE		UINT32_C(0x10)
-	/*
-	 * When a VNIC uses one destination ring group for certain
-	 * application (e.g. Receive Flow Steering) where
-	 * exact match is used to direct packets to a VNIC with one
-	 * destination ring group only, there is no need to configure
-	 * RSS indirection table for that VNIC as only one destination
-	 * ring group is used.
-	 *
-	 * When this bit is set to '1', then the VNIC is enabled in a
-	 * mode where RSS is enabled in the VNIC using a RSS context
-	 * for computing RSS hash but the RSS indirection table is
-	 * not configured.
-	 */
-	#define HWRM_VNIC_QCFG_OUTPUT_FLAGS_RSS_DFLT_CR_MODE			UINT32_C(0x20)
-	/*
-	 * When this bit is '1', the VNIC is configured to
-	 * receive both RoCE and non-RoCE traffic, but forward only
-	 * RoCE traffic further. Also RoCE traffic can be mirrored to
-	 * L2 driver.
-	 */
-	#define HWRM_VNIC_QCFG_OUTPUT_FLAGS_ROCE_MIRRORING_CAPABLE_VNIC_MODE	UINT32_C(0x40)
-	/*
-	 * When this bit is '0', VNIC is in normal operation state.
-	 * When this bit is '1', VNIC drops all the received packets.
-	 */
-	#define HWRM_VNIC_QCFG_OUTPUT_FLAGS_OPERATION_STATE			UINT32_C(0x80)
-	/*
-	 * When returned with a valid CoS Queue id, the CoS Queue/VNIC association
-	 * is valid.  Otherwise it will return 0xFFFF to indicate no VNIC/CoS
-	 * queue association.
-	 */
-	uint16_t	queue_id;
-	/*
-	 * If the device supports the RX V2 and RX TPA start V2 completion
-	 * records as indicated by the HWRM_VNIC_QCAPS command, this field is
-	 * used to specify the current RX checksum mode configured for all the
-	 * RX rings of a VNIC.
-	 */
-	uint8_t	rx_csum_v2_mode;
-	/*
-	 * This value indicates that the VNIC is configured to use the
-	 * default RX checksum mode for all the rings associated with this
-	 * VNIC.
-	 */
-	#define HWRM_VNIC_QCFG_OUTPUT_RX_CSUM_V2_MODE_DEFAULT UINT32_C(0x0)
-	/*
-	 * This value indicates that the VNIC is configured to use the RX
-	 * checksum ‘all_ok’ mode for all the rings associated with this
-	 * VNIC.
-	 */
-	#define HWRM_VNIC_QCFG_OUTPUT_RX_CSUM_V2_MODE_ALL_OK  UINT32_C(0x1)
-	/*
-	 * Any rx_csum_v2_mode value larger than or equal to this is not
-	 * valid
-	 */
-	#define HWRM_VNIC_QCFG_OUTPUT_RX_CSUM_V2_MODE_MAX	UINT32_C(0x2)
-	#define HWRM_VNIC_QCFG_OUTPUT_RX_CSUM_V2_MODE_LAST   HWRM_VNIC_QCFG_OUTPUT_RX_CSUM_V2_MODE_MAX
-	uint8_t	unused_1[4];
+	/* Reserved */
+	uint8_t	unused0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_vnic_qcfg_output_t, *phwrm_vnic_qcfg_output_t;
+} hwrm_tfc_ident_free_output_t, *phwrm_tfc_ident_free_output_t;
 
-/*******************
- * hwrm_vnic_qcaps *
- *******************/
+/**************************
+ * hwrm_tfc_idx_tbl_alloc *
+ **************************/
 
 
-/* hwrm_vnic_qcaps_input (size:192b/24B) */
+/* hwrm_tfc_idx_tbl_alloc_input (size:192b/24B) */
 
-typedef struct hwrm_vnic_qcaps_input {
+typedef struct hwrm_tfc_idx_tbl_alloc_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -29499,13 +56817,65 @@ typedef struct hwrm_vnic_qcaps_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	enables;
-	uint8_t	unused_0[4];
-} hwrm_vnic_qcaps_input_t, *phwrm_vnic_qcaps_input_t;
-
-/* hwrm_vnic_qcaps_output (size:192b/24B) */
-
-typedef struct hwrm_vnic_qcaps_output {
+	/*
+	 * Function ID.
+	 * If running on a trusted VF or PF, the fid field can be used to
+	 * specify that the function is a non-trusted VF of the parent PF.
+	 * If this command is used for the target_id itself, this field is
+	 * set to 0xffff. A non-trusted VF cannot specify a valid FID in this
+	 * field.
+	 */
+	uint16_t	fid;
+	/*
+	 * Unique session id for the session created by the
+	 * firmware. Will be used to track this index table entry
+	 * only if track type is track_type_sid.
+	 */
+	uint16_t	sid;
+	/* Control flags. */
+	uint8_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TFC_IDX_TBL_ALLOC_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TFC_IDX_TBL_ALLOC_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TFC_IDX_TBL_ALLOC_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TFC_IDX_TBL_ALLOC_INPUT_FLAGS_DIR_LAST HWRM_TFC_IDX_TBL_ALLOC_INPUT_FLAGS_DIR_TX
+	/*
+	 * This field is blktype specific.
+	 * For blktype CFA - CFA resource subtype. For definitions,
+	 * please see cfa_v3/include/cfa_resources.h.
+	 * For blktype rxp, re_gparse, te_gparse -
+	 * Tunnel Type. A value of zero (or unknown) means alloc. A known
+	 * value (previously allocated dynamic UPAR for tunnel_type) means
+	 * realloc. Will fail if a realloc is for previously allocated FID,
+	 */
+	uint8_t	subtype;
+	/* Describes the type of tracking id to be used */
+	uint8_t	track_type;
+	/* Invalid track type */
+	#define HWRM_TFC_IDX_TBL_ALLOC_INPUT_TRACK_TYPE_TRACK_TYPE_INVALID UINT32_C(0x0)
+	/* Tracked by session id */
+	#define HWRM_TFC_IDX_TBL_ALLOC_INPUT_TRACK_TYPE_TRACK_TYPE_SID	UINT32_C(0x1)
+	/* Tracked by function id */
+	#define HWRM_TFC_IDX_TBL_ALLOC_INPUT_TRACK_TYPE_TRACK_TYPE_FID	UINT32_C(0x2)
+	#define HWRM_TFC_IDX_TBL_ALLOC_INPUT_TRACK_TYPE_LAST		HWRM_TFC_IDX_TBL_ALLOC_INPUT_TRACK_TYPE_TRACK_TYPE_FID
+	/* Specifies which block this idx table alloc request is for */
+	uint8_t	blktype;
+	/* CFA block type */
+	#define HWRM_TFC_IDX_TBL_ALLOC_INPUT_BLKTYPE_BLKTYPE_CFA	UINT32_C(0x0)
+	/* RXP gparse block type */
+	#define HWRM_TFC_IDX_TBL_ALLOC_INPUT_BLKTYPE_BLKTYPE_RXP	UINT32_C(0x1)
+	/* RE gparse block type */
+	#define HWRM_TFC_IDX_TBL_ALLOC_INPUT_BLKTYPE_BLKTYPE_RE_GPARSE UINT32_C(0x2)
+	/* TE gparse block type */
+	#define HWRM_TFC_IDX_TBL_ALLOC_INPUT_BLKTYPE_BLKTYPE_TE_GPARSE UINT32_C(0x3)
+	#define HWRM_TFC_IDX_TBL_ALLOC_INPUT_BLKTYPE_LAST		HWRM_TFC_IDX_TBL_ALLOC_INPUT_BLKTYPE_BLKTYPE_TE_GPARSE
+} hwrm_tfc_idx_tbl_alloc_input_t, *phwrm_tfc_idx_tbl_alloc_input_t;
+
+/* hwrm_tfc_idx_tbl_alloc_output (size:128b/16B) */
+
+typedef struct hwrm_tfc_idx_tbl_alloc_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -29514,132 +56884,169 @@ typedef struct hwrm_vnic_qcaps_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* The maximum receive unit that is settable on a vnic. */
-	uint16_t	mru;
-	uint8_t	unused_0[2];
-	uint32_t	flags;
-	/* Unused. */
-	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_UNUSED				UINT32_C(0x1)
-	/*
-	 * When this bit is '1', the capability of stripping VLAN in
-	 * the RX path is supported on VNIC(s).
-	 * If set to '0', then VLAN stripping capability is
-	 * not supported on VNIC(s).
-	 */
-	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_VLAN_STRIP_CAP			UINT32_C(0x2)
 	/*
-	 * When this bit is '1', the capability to buffer receive
-	 * packets in the hardware until the host posts new receive buffers
-	 * is supported on VNIC(s).
-	 * If set to '0', then bd_stall capability is not supported
-	 * on VNIC(s).
+	 * Index table entry allocated by the firmware using the
+	 * parameters above.
 	 */
-	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_BD_STALL_CAP			UINT32_C(0x4)
+	uint16_t	idx_tbl_id;
+	/* Reserved */
+	uint8_t	unused0[5];
 	/*
-	 * When this bit is '1', the capability to
-	 * receive both RoCE and non-RoCE traffic on VNIC(s) is
-	 * supported.
-	 * If set to '0', then the capability to receive
-	 * both RoCE and non-RoCE traffic on VNIC(s) is
-	 * not supported.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
-	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_ROCE_DUAL_VNIC_CAP		UINT32_C(0x8)
+	uint8_t	valid;
+} hwrm_tfc_idx_tbl_alloc_output_t, *phwrm_tfc_idx_tbl_alloc_output_t;
+
+/******************************
+ * hwrm_tfc_idx_tbl_alloc_set *
+ ******************************/
+
+
+/* hwrm_tfc_idx_tbl_alloc_set_input (size:1088b/136B) */
+
+typedef struct hwrm_tfc_idx_tbl_alloc_set_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * When this bit is set to '1', the capability to configure
-	 * a VNIC to receive only RoCE traffic is supported.
-	 * When this flag is set to '0', the VNIC capability to
-	 * configure to receive only RoCE traffic is not supported.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_ROCE_ONLY_VNIC_CAP		UINT32_C(0x10)
+	uint16_t	cmpl_ring;
 	/*
-	 * When this bit is set to '1', then the capability to enable
-	 * a VNIC in a mode where RSS context without configuring
-	 * RSS indirection table is supported (for RSS hash computation).
-	 * When this bit is set to '0', then a VNIC can not be configured
-	 * with a mode to enable RSS context without configuring RSS
-	 * indirection table.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_RSS_DFLT_CR_CAP			UINT32_C(0x20)
+	uint16_t	seq_id;
 	/*
-	 * When this bit is '1', the capability to
-	 * mirror the the RoCE traffic is supported.
-	 * If set to '0', then the capability to mirror the
-	 * RoCE traffic is not supported.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_ROCE_MIRRORING_CAPABLE_VNIC_CAP	UINT32_C(0x40)
+	uint16_t	target_id;
 	/*
-	 * When this bit is '1', the outermost RSS hashing capability
-	 * is supported. If set to '0', then the outermost RSS hashing
-	 * capability is not supported.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_OUTERMOST_RSS_CAP		UINT32_C(0x80)
+	uint64_t	resp_addr;
 	/*
-	 * When this bit is '1', it indicates that firmware supports the
-	 * ability to steer incoming packets from one CoS queue to one
-	 * VNIC.  This optional feature can then be enabled
-	 * using HWRM_VNIC_CFG on any VNIC.  This feature is only
-	 * available when NVM option “enable_cos_classfication” is set
-	 * to 1.  If set to '0', firmware does not support this feature.
+	 * Function ID.
+	 * If running on a trusted VF or PF, the fid field can be used to
+	 * specify that the function is a non-trusted VF of the parent PF.
+	 * If this command is used for the target_id itself, this field is
+	 * set to 0xffff. A non-trusted VF cannot specify a valid FID in this
+	 * field.
 	 */
-	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_COS_ASSIGNMENT_CAP		UINT32_C(0x100)
+	uint16_t	fid;
 	/*
-	 * When this bit is '1', it indicates that HW and firmware supports
-	 * the use of RX V2 and RX TPA start V2 completion records for all
-	 * the RX rings of a VNIC. Once set, this feature is mandatory to
-	 * be used for the RX rings of the VNIC. Additionally, two new RX
-	 * checksum features supported by these ompletion records can be
-	 * configured using the HWRM_VNIC_CFG on a VNIC. If set to '0', the
-	 * HW and the firmware does not support this feature.
+	 * Unique session id for the session created by the
+	 * firmware. Will be used to track this index table entry
+	 * only if track type is track_type_sid.
 	 */
-	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_RX_CMPL_V2_CAP			UINT32_C(0x200)
+	uint16_t	sid;
+	/* Control flags. */
+	uint8_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TFC_IDX_TBL_ALLOC_SET_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TFC_IDX_TBL_ALLOC_SET_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TFC_IDX_TBL_ALLOC_SET_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TFC_IDX_TBL_ALLOC_SET_INPUT_FLAGS_DIR_LAST HWRM_TFC_IDX_TBL_ALLOC_SET_INPUT_FLAGS_DIR_TX
 	/*
-	 * When this bit is '1', it indicates that HW and firmware support
-	 * vnic state change. Host drivers can change the vnic state using
-	 * HWRM_VNIC_UPDATE. If set to '0', the HW and firmware do not
-	 * support this feature.
+	 * Indicate device data is being sent via DMA, the device
+	 * data packing does not change.
 	 */
-	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_VNIC_STATE_CAP			UINT32_C(0x400)
+	#define HWRM_TFC_IDX_TBL_ALLOC_SET_INPUT_FLAGS_DMA	UINT32_C(0x2)
 	/*
-	 * When this bit is '1', it indicates that firmware supports
-	 * virtio-net functions default VNIC allocation using
-	 * HWRM_VNIC_ALLOC.
-	 * This capability is available only on Proxy VEE PF. If set to '0',
-	 * firmware does not support this feature.
+	 * This field is blktype specific.
+	 * For blktype CFA - CFA resource subtype. For definitions,
+	 * please see cfa_v3/include/cfa_resources.h.
+	 * For blktype rxp, re_gparse, te_gparse -
+	 * Tunnel Type. A value of zero (or unknown) means alloc. A known
+	 * value (previously allocated dynamic UPAR for tunnel_type) means
+	 * realloc. Will fail if a realloc is for previously allocated FID,
 	 */
-	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_VIRTIO_NET_VNIC_ALLOC_CAP	UINT32_C(0x800)
+	uint8_t	subtype;
+	/* Describes the type of tracking id to be used */
+	uint8_t	track_type;
+	/* Invalid track type */
+	#define HWRM_TFC_IDX_TBL_ALLOC_SET_INPUT_TRACK_TYPE_TRACK_TYPE_INVALID UINT32_C(0x0)
+	/* Tracked by session id */
+	#define HWRM_TFC_IDX_TBL_ALLOC_SET_INPUT_TRACK_TYPE_TRACK_TYPE_SID	UINT32_C(0x1)
+	/* Tracked by function id */
+	#define HWRM_TFC_IDX_TBL_ALLOC_SET_INPUT_TRACK_TYPE_TRACK_TYPE_FID	UINT32_C(0x2)
+	#define HWRM_TFC_IDX_TBL_ALLOC_SET_INPUT_TRACK_TYPE_LAST		HWRM_TFC_IDX_TBL_ALLOC_SET_INPUT_TRACK_TYPE_TRACK_TYPE_FID
+	/* Specifies which block this idx table alloc request is for */
+	uint8_t	blktype;
+	/* CFA block type */
+	#define HWRM_TFC_IDX_TBL_ALLOC_SET_INPUT_BLKTYPE_BLKTYPE_CFA	UINT32_C(0x0)
+	/* RXP gparse block type */
+	#define HWRM_TFC_IDX_TBL_ALLOC_SET_INPUT_BLKTYPE_BLKTYPE_RXP	UINT32_C(0x1)
+	/* RE gparse block type */
+	#define HWRM_TFC_IDX_TBL_ALLOC_SET_INPUT_BLKTYPE_BLKTYPE_RE_GPARSE UINT32_C(0x2)
+	/* TE gparse block type */
+	#define HWRM_TFC_IDX_TBL_ALLOC_SET_INPUT_BLKTYPE_BLKTYPE_TE_GPARSE UINT32_C(0x3)
+	#define HWRM_TFC_IDX_TBL_ALLOC_SET_INPUT_BLKTYPE_LAST		HWRM_TFC_IDX_TBL_ALLOC_SET_INPUT_BLKTYPE_BLKTYPE_TE_GPARSE
+	/* The size of the index table entry in bytes. */
+	uint16_t	data_size;
+	/* Reserved */
+	uint8_t	unused1[6];
+	/* The location of the dma buffer */
+	uint64_t	dma_addr;
 	/*
-	 * When this bit is set '1', then the capability to configure the
-	 * metadata format in the RX completion is supported for the VNIC.
-	 * When this bit is set to '0', then the capability to configure
-	 * the metadata format in the RX completion is not supported for
-	 * the VNIC.
+	 * Index table data located at offset 0. If dma bit is set,
+	 * then this field contains the DMA buffer pointer.
 	 */
-	#define HWRM_VNIC_QCAPS_OUTPUT_FLAGS_METADATA_FORMAT_CAP		UINT32_C(0x1000)
+	uint8_t	dev_data[96];
+} hwrm_tfc_idx_tbl_alloc_set_input_t, *phwrm_tfc_idx_tbl_alloc_set_input_t;
+
+/* hwrm_tfc_idx_tbl_alloc_set_output (size:128b/16B) */
+
+typedef struct hwrm_tfc_idx_tbl_alloc_set_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
 	/*
-	 * This field advertises the maximum concurrent TPA aggregations
-	 * supported by the VNIC on new devices that support TPA v2.
-	 * '0' means that TPA v2 is not supported.
+	 * Index table entry allocated by the firmware using the
+	 * parameters above.
 	 */
-	uint16_t	max_aggs_supported;
-	uint8_t	unused_1[5];
+	uint16_t	idx_tbl_id;
+	/* Reserved */
+	uint8_t	unused0[5];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
 	uint8_t	valid;
-} hwrm_vnic_qcaps_output_t, *phwrm_vnic_qcaps_output_t;
+} hwrm_tfc_idx_tbl_alloc_set_output_t, *phwrm_tfc_idx_tbl_alloc_set_output_t;
 
-/*********************
- * hwrm_vnic_tpa_cfg *
- *********************/
+/************************
+ * hwrm_tfc_idx_tbl_set *
+ ************************/
 
 
-/* hwrm_vnic_tpa_cfg_input (size:320b/40B) */
+/* hwrm_tfc_idx_tbl_set_input (size:1088b/136B) */
 
-typedef struct hwrm_vnic_tpa_cfg_input {
+typedef struct hwrm_tfc_idx_tbl_set_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -29668,148 +57075,188 @@ typedef struct hwrm_vnic_tpa_cfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	flags;
+	/* Control flags. */
+	uint8_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TFC_IDX_TBL_SET_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TFC_IDX_TBL_SET_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TFC_IDX_TBL_SET_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TFC_IDX_TBL_SET_INPUT_FLAGS_DIR_LAST HWRM_TFC_IDX_TBL_SET_INPUT_FLAGS_DIR_TX
 	/*
-	 * When this bit is '1', the VNIC shall be configured to
-	 * perform transparent packet aggregation (TPA) of
-	 * non-tunneled TCP packets.
+	 * Indicate device data is being sent via DMA, the device
+	 * data packing does not change.
 	 */
-	#define HWRM_VNIC_TPA_CFG_INPUT_FLAGS_TPA			UINT32_C(0x1)
+	#define HWRM_TFC_IDX_TBL_SET_INPUT_FLAGS_DMA	UINT32_C(0x2)
 	/*
-	 * When this bit is '1', the VNIC shall be configured to
-	 * perform transparent packet aggregation (TPA) of
-	 * tunneled TCP packets.
+	 * CFA resource subtype. For definitions, please see
+	 * cfa_v3/include/cfa_resources.h.
 	 */
-	#define HWRM_VNIC_TPA_CFG_INPUT_FLAGS_ENCAP_TPA		UINT32_C(0x2)
+	uint8_t	subtype;
 	/*
-	 * When this bit is '1', the VNIC shall be configured to
-	 * perform transparent packet aggregation (TPA) according
-	 * to Windows Receive Segment Coalescing (RSC) rules.
+	 * Function ID.
+	 * If running on a trusted VF or PF, the fid field can be used to
+	 * specify that the function is a non-trusted VF of the parent PF.
+	 * If this command is used for the target_id itself, this field is
+	 * set to 0xffff. A non-trusted VF cannot specify a valid FID in this
+	 * field.
 	 */
-	#define HWRM_VNIC_TPA_CFG_INPUT_FLAGS_RSC_WND_UPDATE		UINT32_C(0x4)
+	uint16_t	fid;
 	/*
-	 * When this bit is '1', the VNIC shall be configured to
-	 * perform transparent packet aggregation (TPA) according
-	 * to Linux Generic Receive Offload (GRO) rules.
+	 * Session id associated with the firmware. Will be used
+	 * for validation if the track type matches.
 	 */
-	#define HWRM_VNIC_TPA_CFG_INPUT_FLAGS_GRO			UINT32_C(0x8)
+	uint16_t	sid;
 	/*
-	 * When this bit is '1', the VNIC shall be configured to
-	 * perform transparent packet aggregation (TPA) for TCP
-	 * packets with IP ECN set to non-zero.
+	 * Index table index returned during alloc by the
+	 * firmware.
 	 */
-	#define HWRM_VNIC_TPA_CFG_INPUT_FLAGS_AGG_WITH_ECN		UINT32_C(0x10)
+	uint16_t	idx_tbl_id;
+	/* The size of the index table entry in bytes. */
+	uint16_t	data_size;
+	/* Specifies which block this idx table alloc request is for */
+	uint8_t	blktype;
+	/* CFA block type */
+	#define HWRM_TFC_IDX_TBL_SET_INPUT_BLKTYPE_BLKTYPE_CFA	UINT32_C(0x0)
+	/* RXP gparse block type */
+	#define HWRM_TFC_IDX_TBL_SET_INPUT_BLKTYPE_BLKTYPE_RXP	UINT32_C(0x1)
+	/* RE gparse block type */
+	#define HWRM_TFC_IDX_TBL_SET_INPUT_BLKTYPE_BLKTYPE_RE_GPARSE UINT32_C(0x2)
+	/* TE gparse block type */
+	#define HWRM_TFC_IDX_TBL_SET_INPUT_BLKTYPE_BLKTYPE_TE_GPARSE UINT32_C(0x3)
+	#define HWRM_TFC_IDX_TBL_SET_INPUT_BLKTYPE_LAST		HWRM_TFC_IDX_TBL_SET_INPUT_BLKTYPE_BLKTYPE_TE_GPARSE
+	/* unused. */
+	uint8_t	unused0[5];
+	/* The location of the dma buffer */
+	uint64_t	dma_addr;
 	/*
-	 * When this bit is '1', the VNIC shall be configured to
-	 * perform transparent packet aggregation (TPA) for
-	 * GRE tunneled TCP packets only if all packets have the
-	 * same GRE sequence.
+	 * Index table data located at offset 0. If dma bit is set,
+	 * then this field contains the DMA buffer pointer.
 	 */
-	#define HWRM_VNIC_TPA_CFG_INPUT_FLAGS_AGG_WITH_SAME_GRE_SEQ	UINT32_C(0x20)
+	uint8_t	dev_data[96];
+} hwrm_tfc_idx_tbl_set_input_t, *phwrm_tfc_idx_tbl_set_input_t;
+
+/* hwrm_tfc_idx_tbl_set_output (size:128b/16B) */
+
+typedef struct hwrm_tfc_idx_tbl_set_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* unused. */
+	uint8_t	unused0[7];
 	/*
-	 * When this bit is '1' and the GRO mode is enabled,
-	 * the VNIC shall be configured to
-	 * perform transparent packet aggregation (TPA) for
-	 * TCP/IPv4 packets with consecutively increasing IPIDs.
-	 * In other words, the last packet that is being
-	 * aggregated to an already existing aggregation context
-	 * shall have IPID 1 more than the IPID of the last packet
-	 * that was aggregated in that aggregation context.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
-	#define HWRM_VNIC_TPA_CFG_INPUT_FLAGS_GRO_IPID_CHECK		UINT32_C(0x40)
+	uint8_t	valid;
+} hwrm_tfc_idx_tbl_set_output_t, *phwrm_tfc_idx_tbl_set_output_t;
+
+/************************
+ * hwrm_tfc_idx_tbl_get *
+ ************************/
+
+
+/* hwrm_tfc_idx_tbl_get_input (size:320b/40B) */
+
+typedef struct hwrm_tfc_idx_tbl_get_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * When this bit is '1' and the GRO mode is enabled,
-	 * the VNIC shall be configured to
-	 * perform transparent packet aggregation (TPA) for
-	 * TCP packets with the same TTL (IPv4) or Hop limit (IPv6)
-	 * value.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define HWRM_VNIC_TPA_CFG_INPUT_FLAGS_GRO_TTL_CHECK		UINT32_C(0x80)
+	uint16_t	cmpl_ring;
 	/*
-	 * When this bit is '1' and the GRO mode is enabled,
-	 * the VNIC shall DMA payload data using GRO rules.
-	 * When this bit is '0', the VNIC shall DMA payload data
-	 * using the more efficient LRO rules of filling all
-	 * aggregation buffers.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define HWRM_VNIC_TPA_CFG_INPUT_FLAGS_AGG_PACK_AS_GRO	UINT32_C(0x100)
-	uint32_t	enables;
+	uint16_t	seq_id;
 	/*
-	 * This bit must be '1' for the max_agg_segs field to be
-	 * configured.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define HWRM_VNIC_TPA_CFG_INPUT_ENABLES_MAX_AGG_SEGS	UINT32_C(0x1)
+	uint16_t	target_id;
 	/*
-	 * This bit must be '1' for the max_aggs field to be
-	 * configured.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define HWRM_VNIC_TPA_CFG_INPUT_ENABLES_MAX_AGGS	UINT32_C(0x2)
+	uint64_t	resp_addr;
+	/* Control flags. */
+	uint8_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TFC_IDX_TBL_GET_INPUT_FLAGS_DIR		UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TFC_IDX_TBL_GET_INPUT_FLAGS_DIR_RX		UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TFC_IDX_TBL_GET_INPUT_FLAGS_DIR_TX		UINT32_C(0x1)
+		#define HWRM_TFC_IDX_TBL_GET_INPUT_FLAGS_DIR_LAST	HWRM_TFC_IDX_TBL_GET_INPUT_FLAGS_DIR_TX
 	/*
-	 * This bit must be '1' for the max_agg_timer field to be
-	 * configured.
+	 * When set use the special access register access to clear
+	 * the table entry on read.
 	 */
-	#define HWRM_VNIC_TPA_CFG_INPUT_ENABLES_MAX_AGG_TIMER	UINT32_C(0x4)
-	/* deprecated bit.  Do not use!!! */
-	#define HWRM_VNIC_TPA_CFG_INPUT_ENABLES_MIN_AGG_LEN	UINT32_C(0x8)
-	/* Logical vnic ID */
-	uint16_t	vnic_id;
+	#define HWRM_TFC_IDX_TBL_GET_INPUT_FLAGS_CLEAR_ON_READ	UINT32_C(0x2)
 	/*
-	 * This is the maximum number of TCP segments that can
-	 * be aggregated (unit is Log2). Max value is 31. On new
-	 * devices supporting TPA v2, the unit is multiples of 4 and
-	 * valid values are > 0 and <= 63.
+	 * CFA resource subtype. For definitions, please see
+	 * cfa_v3/include/cfa_resources.h.
 	 */
-	uint16_t	max_agg_segs;
-	/* 1 segment */
-	#define HWRM_VNIC_TPA_CFG_INPUT_MAX_AGG_SEGS_1   UINT32_C(0x0)
-	/* 2 segments */
-	#define HWRM_VNIC_TPA_CFG_INPUT_MAX_AGG_SEGS_2   UINT32_C(0x1)
-	/* 4 segments */
-	#define HWRM_VNIC_TPA_CFG_INPUT_MAX_AGG_SEGS_4   UINT32_C(0x2)
-	/* 8 segments */
-	#define HWRM_VNIC_TPA_CFG_INPUT_MAX_AGG_SEGS_8   UINT32_C(0x3)
-	/* Any segment size larger than this is not valid */
-	#define HWRM_VNIC_TPA_CFG_INPUT_MAX_AGG_SEGS_MAX UINT32_C(0x1f)
-	#define HWRM_VNIC_TPA_CFG_INPUT_MAX_AGG_SEGS_LAST HWRM_VNIC_TPA_CFG_INPUT_MAX_AGG_SEGS_MAX
+	uint8_t	subtype;
 	/*
-	 * This is the maximum number of aggregations this VNIC is
-	 * allowed (unit is Log2). Max value is 7. On new devices
-	 * supporting TPA v2, this is in unit of 1 and must be > 0
-	 * and <= max_aggs_supported in the hwrm_vnic_qcaps response
-	 * to enable TPA v2.
+	 * Function ID.
+	 * If running on a trusted VF or PF, the fid field can be used to
+	 * specify that the function is a non-trusted VF of the parent PF.
+	 * If this command is used for the target_id itself, this field is
+	 * set to 0xffff. A non-trusted VF cannot specify a valid FID in this
+	 * field.
 	 */
-	uint16_t	max_aggs;
-	/* 1 aggregation */
-	#define HWRM_VNIC_TPA_CFG_INPUT_MAX_AGGS_1   UINT32_C(0x0)
-	/* 2 aggregations */
-	#define HWRM_VNIC_TPA_CFG_INPUT_MAX_AGGS_2   UINT32_C(0x1)
-	/* 4 aggregations */
-	#define HWRM_VNIC_TPA_CFG_INPUT_MAX_AGGS_4   UINT32_C(0x2)
-	/* 8 aggregations */
-	#define HWRM_VNIC_TPA_CFG_INPUT_MAX_AGGS_8   UINT32_C(0x3)
-	/* 16 aggregations */
-	#define HWRM_VNIC_TPA_CFG_INPUT_MAX_AGGS_16  UINT32_C(0x4)
-	/* Any aggregation size larger than this is not valid */
-	#define HWRM_VNIC_TPA_CFG_INPUT_MAX_AGGS_MAX UINT32_C(0x7)
-	#define HWRM_VNIC_TPA_CFG_INPUT_MAX_AGGS_LAST HWRM_VNIC_TPA_CFG_INPUT_MAX_AGGS_MAX
-	uint8_t	unused_0[2];
+	uint16_t	fid;
 	/*
-	 * This is the maximum amount of time allowed for
-	 * an aggregation context to complete after it was initiated.
+	 * Session id associated with the firmware. Will be used
+	 * for validation if the track type matches.
 	 */
-	uint32_t	max_agg_timer;
-	/*
-	 * This is the minimum amount of payload length required to
-	 * start an aggregation context. This field is deprecated and
-	 * should be set to 0.  The minimum length is set by firmware
-	 * and can be queried using hwrm_vnic_tpa_qcfg.
+	uint16_t	sid;
+	/*
+	 * Index table index returned during alloc by the
+	 * firmware.
 	 */
-	uint32_t	min_agg_len;
-} hwrm_vnic_tpa_cfg_input_t, *phwrm_vnic_tpa_cfg_input_t;
+	uint16_t	idx_tbl_id;
+	/* The size of the index table entry buffer in bytes. */
+	uint16_t	buffer_size;
+	/* Specifies which block this idx table alloc request is for */
+	uint8_t	blktype;
+	/* CFA block type */
+	#define HWRM_TFC_IDX_TBL_GET_INPUT_BLKTYPE_BLKTYPE_CFA	UINT32_C(0x0)
+	/* RXP block type */
+	#define HWRM_TFC_IDX_TBL_GET_INPUT_BLKTYPE_BLKTYPE_RXP	UINT32_C(0x1)
+	/* RE gparse block type */
+	#define HWRM_TFC_IDX_TBL_GET_INPUT_BLKTYPE_BLKTYPE_RE_GPARSE UINT32_C(0x2)
+	/* TE gparse block type */
+	#define HWRM_TFC_IDX_TBL_GET_INPUT_BLKTYPE_BLKTYPE_TE_GPARSE UINT32_C(0x3)
+	#define HWRM_TFC_IDX_TBL_GET_INPUT_BLKTYPE_LAST		HWRM_TFC_IDX_TBL_GET_INPUT_BLKTYPE_BLKTYPE_TE_GPARSE
+	/* unused. */
+	uint8_t	unused0[5];
+	/* The location of the response dma buffer */
+	uint64_t	dma_addr;
+} hwrm_tfc_idx_tbl_get_input_t, *phwrm_tfc_idx_tbl_get_input_t;
 
-/* hwrm_vnic_tpa_cfg_output (size:128b/16B) */
+/* hwrm_tfc_idx_tbl_get_output (size:128b/16B) */
 
-typedef struct hwrm_vnic_tpa_cfg_output {
+typedef struct hwrm_tfc_idx_tbl_get_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -29818,25 +57265,29 @@ typedef struct hwrm_vnic_tpa_cfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	/* The size of the index table buffer returned in device size bytes. */
+	uint16_t	data_size;
+	/* unused */
+	uint8_t	unused1[5];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
 	uint8_t	valid;
-} hwrm_vnic_tpa_cfg_output_t, *phwrm_vnic_tpa_cfg_output_t;
+} hwrm_tfc_idx_tbl_get_output_t, *phwrm_tfc_idx_tbl_get_output_t;
 
-/*********************
- * hwrm_vnic_rss_cfg *
- *********************/
+/*************************
+ * hwrm_tfc_idx_tbl_free *
+ *************************/
 
 
-/* hwrm_vnic_rss_cfg_input (size:384b/48B) */
+/* hwrm_tfc_idx_tbl_free_input (size:256b/32B) */
 
-typedef struct hwrm_vnic_rss_cfg_input {
+typedef struct hwrm_tfc_idx_tbl_free_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -29865,99 +57316,177 @@ typedef struct hwrm_vnic_rss_cfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	hash_type;
+	/* Control flags. */
+	uint8_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TFC_IDX_TBL_FREE_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TFC_IDX_TBL_FREE_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TFC_IDX_TBL_FREE_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TFC_IDX_TBL_FREE_INPUT_FLAGS_DIR_LAST HWRM_TFC_IDX_TBL_FREE_INPUT_FLAGS_DIR_TX
 	/*
-	 * When this bit is '1', the RSS hash shall be computed
-	 * over source and destination IPv4 addresses of IPv4
-	 * packets.
+	 * CFA resource subtype. For definitions, please see
+	 * cfa_v3/include/cfa_resources.h.
 	 */
-	#define HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV4	UINT32_C(0x1)
+	uint8_t	subtype;
 	/*
-	 * When this bit is '1', the RSS hash shall be computed
-	 * over source/destination IPv4 addresses and
-	 * source/destination ports of TCP/IPv4 packets.
+	 * Function ID.
+	 * If running on a trusted VF or PF, the fid field can be used to
+	 * specify that the function is a non-trusted VF of the parent PF.
+	 * If this command is used for the target_id itself, this field is
+	 * set to 0xffff. A non-trusted VF cannot specify a valid FID in this
+	 * field.
 	 */
-	#define HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV4	UINT32_C(0x2)
+	uint16_t	fid;
 	/*
-	 * When this bit is '1', the RSS hash shall be computed
-	 * over source/destination IPv4 addresses and
-	 * source/destination ports of UDP/IPv4 packets.
-	 */
-	#define HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_UDP_IPV4	UINT32_C(0x4)
+	 * Session id associated with the firmware. Will be used
+	 * for validation if the track type matches.
+	 */
+	uint16_t	sid;
+	/* Index table id to be freed by the firmware. */
+	uint16_t	idx_tbl_id;
+	/* Specifies which block this idx table alloc request is for */
+	uint8_t	blktype;
+	/* CFA block type */
+	#define HWRM_TFC_IDX_TBL_FREE_INPUT_BLKTYPE_BLKTYPE_CFA	UINT32_C(0x0)
+	/* RXP block type */
+	#define HWRM_TFC_IDX_TBL_FREE_INPUT_BLKTYPE_BLKTYPE_RXP	UINT32_C(0x1)
+	/* RE parse block type */
+	#define HWRM_TFC_IDX_TBL_FREE_INPUT_BLKTYPE_BLKTYPE_RE_GPARSE UINT32_C(0x2)
+	/* TE parse block type */
+	#define HWRM_TFC_IDX_TBL_FREE_INPUT_BLKTYPE_BLKTYPE_TE_GPARSE UINT32_C(0x3)
+	#define HWRM_TFC_IDX_TBL_FREE_INPUT_BLKTYPE_LAST		HWRM_TFC_IDX_TBL_FREE_INPUT_BLKTYPE_BLKTYPE_TE_GPARSE
+	/* unused. */
+	uint8_t	unused0[7];
+} hwrm_tfc_idx_tbl_free_input_t, *phwrm_tfc_idx_tbl_free_input_t;
+
+/* hwrm_tfc_idx_tbl_free_output (size:128b/16B) */
+
+typedef struct hwrm_tfc_idx_tbl_free_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Reserved */
+	uint8_t	unused0[7];
 	/*
-	 * When this bit is '1', the RSS hash shall be computed
-	 * over source and destination IPv4 addresses of IPv6
-	 * packets.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
-	#define HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV6	UINT32_C(0x8)
+	uint8_t	valid;
+} hwrm_tfc_idx_tbl_free_output_t, *phwrm_tfc_idx_tbl_free_output_t;
+
+/* TruFlow resources request for a global id. */
+/* tfc_global_id_hwrm_req (size:64b/8B) */
+
+typedef struct tfc_global_id_hwrm_req {
+	/* Type of the resource, defined in enum cfa_resource_type HCAPI RM. */
+	uint16_t	rtype;
+	/* Indicates the flow direction in type of cfa_dir. */
+	uint16_t	dir;
+	/* Subtype of the resource type. */
+	uint16_t	subtype;
+	/* Number of the type of resources. */
+	uint16_t	cnt;
+} tfc_global_id_hwrm_req_t, *ptfc_global_id_hwrm_req_t;
+
+/* The reserved resources for the global id. */
+/* tfc_global_id_hwrm_rsp (size:64b/8B) */
+
+typedef struct tfc_global_id_hwrm_rsp {
+	/* Type of the resource, defined in enum cfa_resource_type HCAPI RM. */
+	uint16_t	rtype;
+	/* Indicates the flow direction in type of cfa_dir. */
+	uint16_t	dir;
+	/* Subtype of the resource type. */
+	uint16_t	subtype;
+	/* The global id that the resources reserved for. */
+	uint16_t	id;
+} tfc_global_id_hwrm_rsp_t, *ptfc_global_id_hwrm_rsp_t;
+
+/****************************
+ * hwrm_tfc_global_id_alloc *
+ ****************************/
+
+
+/* hwrm_tfc_global_id_alloc_input (size:320b/40B) */
+
+typedef struct hwrm_tfc_global_id_alloc_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * When this bit is '1', the RSS hash shall be computed
-	 * over source/destination IPv6 addresses and
-	 * source/destination ports of TCP/IPv6 packets.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV6	UINT32_C(0x10)
+	uint16_t	cmpl_ring;
 	/*
-	 * When this bit is '1', the RSS hash shall be computed
-	 * over source/destination IPv6 addresses and
-	 * source/destination ports of UDP/IPv6 packets.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_UDP_IPV6	UINT32_C(0x20)
-	/* VNIC ID of VNIC associated with RSS table being configured. */
-	uint16_t	vnic_id;
+	uint16_t	seq_id;
 	/*
-	 * Specifies which VNIC ring table pair to configure.
-	 * Valid values range from 0 to 7.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint8_t	ring_table_pair_index;
-	/* Flags to specify different RSS hash modes. */
-	uint8_t	hash_mode_flags;
+	uint16_t	target_id;
 	/*
-	 * When this bit is '1', it indicates using current RSS
-	 * hash mode setting configured in the device.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define HWRM_VNIC_RSS_CFG_INPUT_HASH_MODE_FLAGS_DEFAULT	UINT32_C(0x1)
+	uint64_t	resp_addr;
 	/*
-	 * When this bit is '1', it indicates requesting support of
-	 * RSS hashing over innermost 4 tuples {l3.src, l3.dest,
-	 * l4.src, l4.dest} for tunnel packets. For none-tunnel
-	 * packets, the RSS hash is computed over the normal
-	 * src/dest l3 and src/dest l4 headers.
+	 * Function ID.
+	 * If running on a trusted VF or PF, the fid field can be used to
+	 * specify that the function is a non-trusted VF of the parent PF.
+	 * If this command is used for the target_id itself, this field is
+	 * set to 0xffff. A non-trusted VF cannot specify a valid FID in this
+	 * field.
 	 */
-	#define HWRM_VNIC_RSS_CFG_INPUT_HASH_MODE_FLAGS_INNERMOST_4	UINT32_C(0x2)
+	uint16_t	fid;
+	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
+	uint16_t	sid;
+	/* Global domain id. */
+	uint16_t	global_id;
 	/*
-	 * When this bit is '1', it indicates requesting support of
-	 * RSS hashing over innermost 2 tuples {l3.src, l3.dest} for
-	 * tunnel packets. For none-tunnel packets, the RSS hash is
-	 * computed over the normal src/dest l3 headers.
+	 * Defines the array size of the provided req_addr and
+	 * resv_addr array buffers. Should be set to the number of
+	 * request entries.
 	 */
-	#define HWRM_VNIC_RSS_CFG_INPUT_HASH_MODE_FLAGS_INNERMOST_2	UINT32_C(0x4)
+	uint16_t	req_cnt;
 	/*
-	 * When this bit is '1', it indicates requesting support of
-	 * RSS hashing over outermost 4 tuples {t_l3.src, t_l3.dest,
-	 * t_l4.src, t_l4.dest} for tunnel packets. For none-tunnel
-	 * packets, the RSS hash is computed over the normal
-	 * src/dest l3 and src/dest l4 headers.
+	 * This is the DMA address for the request input data array
+	 * buffer. Array is of tfc_global_id_hwrm_req type. Size of the
+	 * array buffer is provided by the 'req_cnt' field in this
+	 * message.
 	 */
-	#define HWRM_VNIC_RSS_CFG_INPUT_HASH_MODE_FLAGS_OUTERMOST_4	UINT32_C(0x8)
+	uint64_t	req_addr;
 	/*
-	 * When this bit is '1', it indicates requesting support of
-	 * RSS hashing over outermost 2 tuples {t_l3.src, t_l3.dest} for
-	 * tunnel packets. For none-tunnel packets, the RSS hash is
-	 * computed over the normal src/dest l3 headers.
+	 * This is the DMA address for the resc output data array
+	 * buffer. Array is of tfc_global_id_hwrm_rsp type. Size of the array
+	 * buffer is provided by the 'req_cnt' field in this
+	 * message.
 	 */
-	#define HWRM_VNIC_RSS_CFG_INPUT_HASH_MODE_FLAGS_OUTERMOST_2	UINT32_C(0x10)
-	/* This is the address for rss ring group table */
-	uint64_t	ring_grp_tbl_addr;
-	/* This is the address for rss hash key table */
-	uint64_t	hash_key_tbl_addr;
-	/* Index to the rss indirection table. */
-	uint16_t	rss_ctx_idx;
-	uint8_t	unused_1[6];
-} hwrm_vnic_rss_cfg_input_t, *phwrm_vnic_rss_cfg_input_t;
+	uint64_t	resc_addr;
+} hwrm_tfc_global_id_alloc_input_t, *phwrm_tfc_global_id_alloc_input_t;
 
-/* hwrm_vnic_rss_cfg_output (size:128b/16B) */
+/* hwrm_tfc_global_id_alloc_output (size:128b/16B) */
 
-typedef struct hwrm_vnic_rss_cfg_output {
+typedef struct hwrm_tfc_global_id_alloc_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -29966,44 +57495,36 @@ typedef struct hwrm_vnic_rss_cfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	/*
+	 * Size of the returned hwrm_tfc_global_id_req data array. The value
+	 * cannot exceed the req_cnt defined by the input msg. The data
+	 * array is returned using the resv_addr specified DMA
+	 * address also provided by the input msg.
+	 */
+	uint16_t	rsp_cnt;
+	/* Non-zero if this is the first allocation for the global ID. */
+	uint8_t	first;
+	/* unused. */
+	uint8_t	unused0[4];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
 	uint8_t	valid;
-} hwrm_vnic_rss_cfg_output_t, *phwrm_vnic_rss_cfg_output_t;
-
-/* hwrm_vnic_rss_cfg_cmd_err (size:64b/8B) */
-
-typedef struct hwrm_vnic_rss_cfg_cmd_err {
-	/*
-	 * command specific error codes that goes to
-	 * the cmd_err field in Common HWRM Error Response.
-	 */
-	uint8_t	code;
-	/* Unknown error */
-	#define HWRM_VNIC_RSS_CFG_CMD_ERR_CODE_UNKNOWN		UINT32_C(0x0)
-	/*
-	 * Unable to change global RSS mode to outer due to all active
-	 * interfaces are not ready to support outer RSS hashing.
-	 */
-	#define HWRM_VNIC_RSS_CFG_CMD_ERR_CODE_INTERFACE_NOT_READY UINT32_C(0x1)
-	#define HWRM_VNIC_RSS_CFG_CMD_ERR_CODE_LAST		HWRM_VNIC_RSS_CFG_CMD_ERR_CODE_INTERFACE_NOT_READY
-	uint8_t	unused_0[7];
-} hwrm_vnic_rss_cfg_cmd_err_t, *phwrm_vnic_rss_cfg_cmd_err_t;
+} hwrm_tfc_global_id_alloc_output_t, *phwrm_tfc_global_id_alloc_output_t;
 
-/**********************
- * hwrm_vnic_rss_qcfg *
- **********************/
+/*********************
+ * hwrm_tfc_tcam_set *
+ *********************/
 
 
-/* hwrm_vnic_rss_qcfg_input (size:192b/24B) */
+/* hwrm_tfc_tcam_set_input (size:1088b/136B) */
 
-typedef struct hwrm_vnic_rss_qcfg_input {
+typedef struct hwrm_tfc_tcam_set_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -30032,14 +57553,56 @@ typedef struct hwrm_vnic_rss_qcfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Index to the rss indirection table. */
-	uint16_t	rss_ctx_idx;
-	uint8_t	unused_0[6];
-} hwrm_vnic_rss_qcfg_input_t, *phwrm_vnic_rss_qcfg_input_t;
+	/*
+	 * Function ID.
+	 * If running on a trusted VF or PF, the fid field can be used to
+	 * specify that the function is a non-trusted VF of the parent PF.
+	 * If this command is used for the target_id itself, this field is
+	 * set to 0xffff. A non-trusted VF cannot specify a valid FID in this
+	 * field.
+	 */
+	uint16_t	fid;
+	/*
+	 * Session id associated with the firmware. Will be used
+	 * for validation if the track type matches.
+	 */
+	uint16_t	sid;
+	/* Logical TCAM ID. */
+	uint16_t	tcam_id;
+	/* Number of bytes in the TCAM key. */
+	uint16_t	key_size;
+	/* Number of bytes in the TCAM result. */
+	uint16_t	result_size;
+	/* Control flags. */
+	uint8_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TFC_TCAM_SET_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TFC_TCAM_SET_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TFC_TCAM_SET_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TFC_TCAM_SET_INPUT_FLAGS_DIR_LAST HWRM_TFC_TCAM_SET_INPUT_FLAGS_DIR_TX
+	/* Indicate device data is being sent via DMA. */
+	#define HWRM_TFC_TCAM_SET_INPUT_FLAGS_DMA	UINT32_C(0x2)
+	/*
+	 * Subtype of TCAM resource. See
+	 * cfa_v3/include/cfa_resources.h.
+	 */
+	uint8_t	subtype;
+	/* unused. */
+	uint8_t	unused0[4];
+	/* The location of the response dma buffer */
+	uint64_t	dma_addr;
+	/*
+	 * TCAM key located at offset 0, mask located at mask_offset
+	 * and result at result_offset for the device.
+	 */
+	uint8_t	dev_data[96];
+} hwrm_tfc_tcam_set_input_t, *phwrm_tfc_tcam_set_input_t;
 
-/* hwrm_vnic_rss_qcfg_output (size:512b/64B) */
+/* hwrm_tfc_tcam_set_output (size:128b/16B) */
 
-typedef struct hwrm_vnic_rss_qcfg_output {
+typedef struct hwrm_tfc_tcam_set_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -30048,102 +57611,130 @@ typedef struct hwrm_vnic_rss_qcfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint32_t	hash_type;
-	/*
-	 * When this bit is '1', the RSS hash shall be computed
-	 * over source and destination IPv4 addresses of IPv4
-	 * packets.
-	 */
-	#define HWRM_VNIC_RSS_QCFG_OUTPUT_HASH_TYPE_IPV4	UINT32_C(0x1)
-	/*
-	 * When this bit is '1', the RSS hash shall be computed
-	 * over source/destination IPv4 addresses and
-	 * source/destination ports of TCP/IPv4 packets.
-	 */
-	#define HWRM_VNIC_RSS_QCFG_OUTPUT_HASH_TYPE_TCP_IPV4	UINT32_C(0x2)
+	/* unused. */
+	uint8_t	unused0[7];
 	/*
-	 * When this bit is '1', the RSS hash shall be computed
-	 * over source/destination IPv4 addresses and
-	 * source/destination ports of UDP/IPv4 packets.
+	 * This field is used in Output records to indicate that the
+	 * output is completely written to RAM. This field should be
+	 * read as '1' to indicate that the output has been
+	 * completely written. When writing a command completion or
+	 * response to an internal processor, the order of writes has
+	 * to be such that this field is written last.
 	 */
-	#define HWRM_VNIC_RSS_QCFG_OUTPUT_HASH_TYPE_UDP_IPV4	UINT32_C(0x4)
+	uint8_t	valid;
+} hwrm_tfc_tcam_set_output_t, *phwrm_tfc_tcam_set_output_t;
+
+/*********************
+ * hwrm_tfc_tcam_get *
+ *********************/
+
+
+/* hwrm_tfc_tcam_get_input (size:192b/24B) */
+
+typedef struct hwrm_tfc_tcam_get_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * When this bit is '1', the RSS hash shall be computed
-	 * over source and destination IPv4 addresses of IPv6
-	 * packets.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define HWRM_VNIC_RSS_QCFG_OUTPUT_HASH_TYPE_IPV6	UINT32_C(0x8)
+	uint16_t	cmpl_ring;
 	/*
-	 * When this bit is '1', the RSS hash shall be computed
-	 * over source/destination IPv6 addresses and
-	 * source/destination ports of TCP/IPv6 packets.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define HWRM_VNIC_RSS_QCFG_OUTPUT_HASH_TYPE_TCP_IPV6	UINT32_C(0x10)
+	uint16_t	seq_id;
 	/*
-	 * When this bit is '1', the RSS hash shall be computed
-	 * over source/destination IPv6 addresses and
-	 * source/destination ports of UDP/IPv6 packets.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define HWRM_VNIC_RSS_QCFG_OUTPUT_HASH_TYPE_UDP_IPV6	UINT32_C(0x20)
-	uint8_t	unused_0[4];
-	/* This is the value of rss hash key */
-	uint32_t	hash_key[10];
-	/* Flags to specify different RSS hash modes. */
-	uint8_t	hash_mode_flags;
+	uint16_t	target_id;
 	/*
-	 * When this bit is '1', it indicates using current RSS
-	 * hash mode setting configured in the device.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define HWRM_VNIC_RSS_QCFG_OUTPUT_HASH_MODE_FLAGS_DEFAULT	UINT32_C(0x1)
+	uint64_t	resp_addr;
+	/* Control flags. */
+	uint8_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TFC_TCAM_GET_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TFC_TCAM_GET_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TFC_TCAM_GET_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TFC_TCAM_GET_INPUT_FLAGS_DIR_LAST HWRM_TFC_TCAM_GET_INPUT_FLAGS_DIR_TX
 	/*
-	 * When this bit is '1', it indicates requesting support of
-	 * RSS hashing over innermost 4 tuples {l3.src, l3.dest,
-	 * l4.src, l4.dest} for tunnel packets. For none-tunnel
-	 * packets, the RSS hash is computed over the normal
-	 * src/dest l3 and src/dest l4 headers.
+	 * Subtype of TCAM resource See
+	 * cfa_v3/include/cfa_resources.h.
 	 */
-	#define HWRM_VNIC_RSS_QCFG_OUTPUT_HASH_MODE_FLAGS_INNERMOST_4	UINT32_C(0x2)
+	uint8_t	subtype;
 	/*
-	 * When this bit is '1', it indicates requesting support of
-	 * RSS hashing over innermost 2 tuples {l3.src, l3.dest} for
-	 * tunnel packets. For none-tunnel packets, the RSS hash is
-	 * computed over the normal src/dest l3 headers.
+	 * Function ID.
+	 * If running on a trusted VF or PF, the fid field can be used to
+	 * specify that the function is a non-trusted VF of the parent PF.
+	 * If this command is used for the target_id itself, this field is
+	 * set to 0xffff. A non-trusted VF cannot specify a valid FID in this
+	 * field.
 	 */
-	#define HWRM_VNIC_RSS_QCFG_OUTPUT_HASH_MODE_FLAGS_INNERMOST_2	UINT32_C(0x4)
+	uint16_t	fid;
 	/*
-	 * When this bit is '1', it indicates requesting support of
-	 * RSS hashing over outermost 4 tuples {t_l3.src, t_l3.dest,
-	 * t_l4.src, t_l4.dest} for tunnel packets. For none-tunnel
-	 * packets, the RSS hash is computed over the normal
-	 * src/dest l3 and src/dest l4 headers.
+	 * Session id associated with the firmware. Will be used
+	 * for validation if the track type matches.
 	 */
-	#define HWRM_VNIC_RSS_QCFG_OUTPUT_HASH_MODE_FLAGS_OUTERMOST_4	UINT32_C(0x8)
+	uint16_t	sid;
+	/* Logical TCAM ID. */
+	uint16_t	tcam_id;
+} hwrm_tfc_tcam_get_input_t, *phwrm_tfc_tcam_get_input_t;
+
+/* hwrm_tfc_tcam_get_output (size:2368b/296B) */
+
+typedef struct hwrm_tfc_tcam_get_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Number of bytes in the TCAM key. */
+	uint16_t	key_size;
+	/* Number of bytes in the TCAM result. */
+	uint16_t	result_size;
+	/* unused. */
+	uint8_t	unused0[4];
 	/*
-	 * When this bit is '1', it indicates requesting support of
-	 * RSS hashing over outermost 2 tuples {t_l3.src, t_l3.dest} for
-	 * tunnel packets. For none-tunnel packets, the RSS hash is
-	 * computed over the normal src/dest l3 headers.
+	 * TCAM key located at offset 0, mask located at key_size
+	 * and result at 2 * key_size for the device.
 	 */
-	#define HWRM_VNIC_RSS_QCFG_OUTPUT_HASH_MODE_FLAGS_OUTERMOST_2	UINT32_C(0x10)
-	uint8_t	unused_1[6];
+	uint8_t	dev_data[272];
+	/* unused. */
+	uint8_t	unused1[7];
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * This field is used in Output records to indicate that the
+	 * output is completely written to RAM. This field should be
+	 * read as '1' to indicate that the output has been
+	 * completely written. When writing a command completion or
+	 * response to an internal processor, the order of writes has
+	 * to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_vnic_rss_qcfg_output_t, *phwrm_vnic_rss_qcfg_output_t;
+} hwrm_tfc_tcam_get_output_t, *phwrm_tfc_tcam_get_output_t;
 
-/**************************
- * hwrm_vnic_plcmodes_cfg *
- **************************/
+/***********************
+ * hwrm_tfc_tcam_alloc *
+ ***********************/
 
 
-/* hwrm_vnic_plcmodes_cfg_input (size:320b/40B) */
+/* hwrm_tfc_tcam_alloc_input (size:256b/32B) */
 
-typedef struct hwrm_vnic_plcmodes_cfg_input {
+typedef struct hwrm_tfc_tcam_alloc_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -30172,133 +57763,177 @@ typedef struct hwrm_vnic_plcmodes_cfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	flags;
-	/*
-	 * When this bit is '1', the VNIC shall be configured to
-	 * use regular placement algorithm.
-	 * By default, the regular placement algorithm shall be
-	 * enabled on the VNIC.
-	 */
-	#define HWRM_VNIC_PLCMODES_CFG_INPUT_FLAGS_REGULAR_PLACEMENT	UINT32_C(0x1)
-	/*
-	 * When this bit is '1', the VNIC shall be configured
-	 * use the jumbo placement algorithm.
-	 */
-	#define HWRM_VNIC_PLCMODES_CFG_INPUT_FLAGS_JUMBO_PLACEMENT	UINT32_C(0x2)
+	/* Control flags. */
+	uint8_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TFC_TCAM_ALLOC_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TFC_TCAM_ALLOC_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TFC_TCAM_ALLOC_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TFC_TCAM_ALLOC_INPUT_FLAGS_DIR_LAST HWRM_TFC_TCAM_ALLOC_INPUT_FLAGS_DIR_TX
 	/*
-	 * When this bit is '1', the VNIC shall be configured
-	 * to enable Header-Data split for IPv4 packets according
-	 * to the following rules:
-	 * # If the packet is identified as TCP/IPv4, then the
-	 * packet is split at the beginning of the TCP payload.
-	 * # If the packet is identified as UDP/IPv4, then the
-	 * packet is split at the beginning of UDP payload.
-	 * # If the packet is identified as non-TCP and non-UDP
-	 * IPv4 packet, then the packet is split at the beginning
-	 * of the upper layer protocol header carried in the IPv4
-	 * packet.
+	 * Subtype of TCAM resource. See
+	 * cfa_v3/include/cfa_resources.h.
 	 */
-	#define HWRM_VNIC_PLCMODES_CFG_INPUT_FLAGS_HDS_IPV4		UINT32_C(0x4)
+	uint8_t	subtype;
 	/*
-	 * When this bit is '1', the VNIC shall be configured
-	 * to enable Header-Data split for IPv6 packets according
-	 * to the following rules:
-	 * # If the packet is identified as TCP/IPv6, then the
-	 * packet is split at the beginning of the TCP payload.
-	 * # If the packet is identified as UDP/IPv6, then the
-	 * packet is split at the beginning of UDP payload.
-	 * # If the packet is identified as non-TCP and non-UDP
-	 * IPv6 packet, then the packet is split at the beginning
-	 * of the upper layer protocol header carried in the IPv6
-	 * packet.
+	 * Function ID.
+	 * If running on a trusted VF or PF, the fid field can be used to
+	 * specify that the function is a non-trusted VF of the parent PF.
+	 * If this command is used for the target_id itself, this field is
+	 * set to 0xffff. A non-trusted VF cannot specify a valid FID in this
+	 * field.
 	 */
-	#define HWRM_VNIC_PLCMODES_CFG_INPUT_FLAGS_HDS_IPV6		UINT32_C(0x8)
+	uint16_t	fid;
 	/*
-	 * When this bit is '1', the VNIC shall be configured
-	 * to enable Header-Data split for FCoE packets at the
-	 * beginning of FC payload.
+	 * Unique session id for the session created by the
+	 * firmware. Will be used to track this index table entry
+	 * only if track type is track_type_sid.
 	 */
-	#define HWRM_VNIC_PLCMODES_CFG_INPUT_FLAGS_HDS_FCOE		UINT32_C(0x10)
+	uint16_t	sid;
+	/* Number of bytes in the TCAM key. */
+	uint16_t	key_size;
+	/* Entry priority. */
+	uint16_t	priority;
+	/* Describes the type of tracking id to be used */
+	uint8_t	track_type;
+	/* Invalid track type */
+	#define HWRM_TFC_TCAM_ALLOC_INPUT_TRACK_TYPE_TRACK_TYPE_INVALID UINT32_C(0x0)
+	/* Tracked by session id */
+	#define HWRM_TFC_TCAM_ALLOC_INPUT_TRACK_TYPE_TRACK_TYPE_SID	UINT32_C(0x1)
+	/* Tracked by function id */
+	#define HWRM_TFC_TCAM_ALLOC_INPUT_TRACK_TYPE_TRACK_TYPE_FID	UINT32_C(0x2)
+	#define HWRM_TFC_TCAM_ALLOC_INPUT_TRACK_TYPE_LAST		HWRM_TFC_TCAM_ALLOC_INPUT_TRACK_TYPE_TRACK_TYPE_FID
+	/* Unused. */
+	uint8_t	unused0[5];
+} hwrm_tfc_tcam_alloc_input_t, *phwrm_tfc_tcam_alloc_input_t;
+
+/* hwrm_tfc_tcam_alloc_output (size:128b/16B) */
+
+typedef struct hwrm_tfc_tcam_alloc_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
 	/*
-	 * When this bit is '1', the VNIC shall be configured
-	 * to enable Header-Data split for RoCE packets at the
-	 * beginning of RoCE payload (after BTH/GRH headers).
+	 * Index table entry allocated by the firmware using the
+	 * parameters above.
 	 */
-	#define HWRM_VNIC_PLCMODES_CFG_INPUT_FLAGS_HDS_ROCE		UINT32_C(0x20)
+	uint16_t	idx;
+	/* Reserved */
+	uint8_t	unused0[5];
 	/*
-	 * When this bit is '1', the VNIC shall be configured use the virtio
-	 * placement algorithm. This feature can only be configured when
-	 * proxy mode is supported on the function.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
-	#define HWRM_VNIC_PLCMODES_CFG_INPUT_FLAGS_VIRTIO_PLACEMENT	UINT32_C(0x40)
-	uint32_t	enables;
+	uint8_t	valid;
+} hwrm_tfc_tcam_alloc_output_t, *phwrm_tfc_tcam_alloc_output_t;
+
+/***************************
+ * hwrm_tfc_tcam_alloc_set *
+ ***************************/
+
+
+/* hwrm_tfc_tcam_alloc_set_input (size:1088b/136B) */
+
+typedef struct hwrm_tfc_tcam_alloc_set_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * This bit must be '1' for the jumbo_thresh_valid field to be
-	 * configured.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define HWRM_VNIC_PLCMODES_CFG_INPUT_ENABLES_JUMBO_THRESH_VALID	UINT32_C(0x1)
+	uint16_t	cmpl_ring;
 	/*
-	 * This bit must be '1' for the hds_offset_valid field to be
-	 * configured.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define HWRM_VNIC_PLCMODES_CFG_INPUT_ENABLES_HDS_OFFSET_VALID	UINT32_C(0x2)
+	uint16_t	seq_id;
 	/*
-	 * This bit must be '1' for the hds_threshold_valid field to be
-	 * configured.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define HWRM_VNIC_PLCMODES_CFG_INPUT_ENABLES_HDS_THRESHOLD_VALID	UINT32_C(0x4)
+	uint16_t	target_id;
 	/*
-	 * This bit must be '1' for the max_bds_valid field to be
-	 * configured.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define HWRM_VNIC_PLCMODES_CFG_INPUT_ENABLES_MAX_BDS_VALID	UINT32_C(0x8)
-	/* Logical vnic ID */
-	uint32_t	vnic_id;
+	uint64_t	resp_addr;
+	/* Control flags. */
+	uint8_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TFC_TCAM_ALLOC_SET_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TFC_TCAM_ALLOC_SET_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TFC_TCAM_ALLOC_SET_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TFC_TCAM_ALLOC_SET_INPUT_FLAGS_DIR_LAST HWRM_TFC_TCAM_ALLOC_SET_INPUT_FLAGS_DIR_TX
+	/* Indicate device data is being sent via DMA. */
+	#define HWRM_TFC_TCAM_ALLOC_SET_INPUT_FLAGS_DMA	UINT32_C(0x2)
 	/*
-	 * When jumbo placement algorithm is enabled, this value
-	 * is used to determine the threshold for jumbo placement.
-	 * Packets with length larger than this value will be
-	 * placed according to the jumbo placement algorithm.
+	 * Subtype of TCAM resource. See
+	 * cfa_v3/include/cfa_resources.h.
 	 */
-	uint16_t	jumbo_thresh;
+	uint8_t	subtype;
 	/*
-	 * This value is used to determine the offset into
-	 * packet buffer where the split data (payload) will be
-	 * placed according to one of HDS placement algorithm.
-	 *
-	 * The lengths of packet buffers provided for split data
-	 * shall be larger than this value.
+	 * Function ID.
+	 * If running on a trusted VF or PF, the fid field can be used to
+	 * specify that the function is a non-trusted VF of the parent PF.
+	 * If this command is used for the target_id itself, this field is
+	 * set to 0xffff. A non-trusted VF cannot specify a valid FID in this
+	 * field.
 	 */
-	uint16_t	hds_offset;
+	uint16_t	fid;
 	/*
-	 * When one of the HDS placement algorithm is enabled, this
-	 * value is used to determine the threshold for HDS
-	 * placement.
-	 * Packets with length larger than this value will be
-	 * placed according to the HDS placement algorithm.
-	 * This value shall be in multiple of 4 bytes.
+	 * Unique session id for the session created by the
+	 * firmware. Will be used to track this index table entry
+	 * only if track type is track_type_sid.
 	 */
-	uint16_t	hds_threshold;
-	/*
-	 * When virtio placement algorithm is enabled, this
-	 * value is used to determine the the maximum number of BDs
-	 * that can be used to place an Rx Packet.
-	 * If an incoming packet does not fit in the buffers described
-	 * by the max BDs, the packet will be dropped and an error
-	 * will be reported in the completion. Valid values for this
-	 * field are between 1 and 8. If the VNIC uses header-data-
-	 * separation and/or TPA with buffer spanning enabled, valid
-	 * values for this field are between 2 and 8.
-	 * This feature can only be configured when proxy mode is
-	 * supported on the function.
+	uint16_t	sid;
+	/* Number of bytes in the TCAM key. */
+	uint16_t	key_size;
+	/* The size of the TCAM table entry in bytes. */
+	uint16_t	result_size;
+	/* Entry priority. */
+	uint16_t	priority;
+	/* Describes the type of tracking id to be used */
+	uint8_t	track_type;
+	/* Invalid track type */
+	#define HWRM_TFC_TCAM_ALLOC_SET_INPUT_TRACK_TYPE_TRACK_TYPE_INVALID UINT32_C(0x0)
+	/* Tracked by session id */
+	#define HWRM_TFC_TCAM_ALLOC_SET_INPUT_TRACK_TYPE_TRACK_TYPE_SID	UINT32_C(0x1)
+	/* Tracked by function id */
+	#define HWRM_TFC_TCAM_ALLOC_SET_INPUT_TRACK_TYPE_TRACK_TYPE_FID	UINT32_C(0x2)
+	#define HWRM_TFC_TCAM_ALLOC_SET_INPUT_TRACK_TYPE_LAST		HWRM_TFC_TCAM_ALLOC_SET_INPUT_TRACK_TYPE_TRACK_TYPE_FID
+	/* Unused */
+	uint8_t	unused[3];
+	/* The location of the response dma buffer */
+	uint64_t	dma_addr;
+	/*
+	 * Index table data located at offset 0. If dma bit is set,
+	 * then this field contains the DMA buffer pointer.
 	 */
-	uint16_t	max_bds;
-	uint8_t	unused_0[4];
-} hwrm_vnic_plcmodes_cfg_input_t, *phwrm_vnic_plcmodes_cfg_input_t;
+	uint8_t	dev_data[96];
+} hwrm_tfc_tcam_alloc_set_input_t, *phwrm_tfc_tcam_alloc_set_input_t;
 
-/* hwrm_vnic_plcmodes_cfg_output (size:128b/16B) */
+/* hwrm_tfc_tcam_alloc_set_output (size:128b/16B) */
 
-typedef struct hwrm_vnic_plcmodes_cfg_output {
+typedef struct hwrm_tfc_tcam_alloc_set_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -30307,26 +57942,29 @@ typedef struct hwrm_vnic_plcmodes_cfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	/* Logical TCAM ID. */
+	uint16_t	tcam_id;
+	/* Reserved */
+	uint8_t	unused0[5];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
 	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
 	uint8_t	valid;
-} hwrm_vnic_plcmodes_cfg_output_t, *phwrm_vnic_plcmodes_cfg_output_t;
+} hwrm_tfc_tcam_alloc_set_output_t, *phwrm_tfc_tcam_alloc_set_output_t;
 
-/***************************
- * hwrm_vnic_plcmodes_qcfg *
- ***************************/
+/**********************
+ * hwrm_tfc_tcam_free *
+ **********************/
 
 
-/* hwrm_vnic_plcmodes_qcfg_input (size:192b/24B) */
+/* hwrm_tfc_tcam_free_input (size:192b/24B) */
 
-typedef struct hwrm_vnic_plcmodes_qcfg_input {
+typedef struct hwrm_tfc_tcam_free_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -30355,14 +57993,41 @@ typedef struct hwrm_vnic_plcmodes_qcfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Logical vnic ID */
-	uint32_t	vnic_id;
-	uint8_t	unused_0[4];
-} hwrm_vnic_plcmodes_qcfg_input_t, *phwrm_vnic_plcmodes_qcfg_input_t;
+	/* Control flags. */
+	uint8_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TFC_TCAM_FREE_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TFC_TCAM_FREE_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TFC_TCAM_FREE_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TFC_TCAM_FREE_INPUT_FLAGS_DIR_LAST HWRM_TFC_TCAM_FREE_INPUT_FLAGS_DIR_TX
+	/*
+	 * Subtype of TCAM resource. See
+	 * cfa_v3/include/cfa_resources.h.
+	 */
+	uint8_t	subtype;
+	/*
+	 * Function ID.
+	 * If running on a trusted VF or PF, the fid field can be used to
+	 * specify that the function is a non-trusted VF of the parent PF.
+	 * If this command is used for the target_id itself, this field is
+	 * set to 0xffff. A non-trusted VF cannot specify a valid FID in this
+	 * field.
+	 */
+	uint16_t	fid;
+	/*
+	 * Session id associated with the firmware. Will be used
+	 * for validation if the track type matches.
+	 */
+	uint16_t	sid;
+	/* Logical TCAM ID. */
+	uint16_t	tcam_id;
+} hwrm_tfc_tcam_free_input_t, *phwrm_tfc_tcam_free_input_t;
 
-/* hwrm_vnic_plcmodes_qcfg_output (size:192b/24B) */
+/* hwrm_tfc_tcam_free_output (size:128b/16B) */
 
-typedef struct hwrm_vnic_plcmodes_qcfg_output {
+typedef struct hwrm_tfc_tcam_free_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -30371,107 +58036,27 @@ typedef struct hwrm_vnic_plcmodes_qcfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint32_t	flags;
-	/*
-	 * When this bit is '1', the VNIC is configured to
-	 * use regular placement algorithm.
-	 */
-	#define HWRM_VNIC_PLCMODES_QCFG_OUTPUT_FLAGS_REGULAR_PLACEMENT	UINT32_C(0x1)
-	/*
-	 * When this bit is '1', the VNIC is configured to
-	 * use the jumbo placement algorithm.
-	 */
-	#define HWRM_VNIC_PLCMODES_QCFG_OUTPUT_FLAGS_JUMBO_PLACEMENT	UINT32_C(0x2)
-	/*
-	 * When this bit is '1', the VNIC is configured
-	 * to enable Header-Data split for IPv4 packets.
-	 */
-	#define HWRM_VNIC_PLCMODES_QCFG_OUTPUT_FLAGS_HDS_IPV4		UINT32_C(0x4)
-	/*
-	 * When this bit is '1', the VNIC is configured
-	 * to enable Header-Data split for IPv6 packets.
-	 */
-	#define HWRM_VNIC_PLCMODES_QCFG_OUTPUT_FLAGS_HDS_IPV6		UINT32_C(0x8)
-	/*
-	 * When this bit is '1', the VNIC is configured
-	 * to enable Header-Data split for FCoE packets.
-	 */
-	#define HWRM_VNIC_PLCMODES_QCFG_OUTPUT_FLAGS_HDS_FCOE		UINT32_C(0x10)
-	/*
-	 * When this bit is '1', the VNIC is configured
-	 * to enable Header-Data split for RoCE packets.
-	 */
-	#define HWRM_VNIC_PLCMODES_QCFG_OUTPUT_FLAGS_HDS_ROCE		UINT32_C(0x20)
-	/*
-	 * When this bit is '1', the VNIC is configured
-	 * to be the default VNIC of the requesting function.
-	 */
-	#define HWRM_VNIC_PLCMODES_QCFG_OUTPUT_FLAGS_DFLT_VNIC		UINT32_C(0x40)
-	/*
-	 * When this bit is '1', the VNIC is configured to use the virtio
-	 * placement algorithm. This feature can only be configured when
-	 * proxy mode is supported on the function.
-	 */
-	#define HWRM_VNIC_PLCMODES_QCFG_OUTPUT_FLAGS_VIRTIO_PLACEMENT	UINT32_C(0x80)
-	/*
-	 * When jumbo placement algorithm is enabled, this value
-	 * is used to determine the threshold for jumbo placement.
-	 * Packets with length larger than this value will be
-	 * placed according to the jumbo placement algorithm.
-	 */
-	uint16_t	jumbo_thresh;
-	/*
-	 * This value is used to determine the offset into
-	 * packet buffer where the split data (payload) will be
-	 * placed according to one of HDS placement algorithm.
-	 *
-	 * The lengths of packet buffers provided for split data
-	 * shall be larger than this value.
-	 */
-	uint16_t	hds_offset;
-	/*
-	 * When one of the HDS placement algorithm is enabled, this
-	 * value is used to determine the threshold for HDS
-	 * placement.
-	 * Packets with length larger than this value will be
-	 * placed according to the HDS placement algorithm.
-	 * This value shall be in multiple of 4 bytes.
-	 */
-	uint16_t	hds_threshold;
-	/*
-	 * When virtio placement algorithm is enabled, this
-	 * value is used to determine the the maximum number of BDs
-	 * that can be used to place an Rx Packet.
-	 * If an incoming packet does not fit in the buffers described
-	 * by the max BDs, the packet will be dropped and an error
-	 * will be reported in the completion. Valid values for this
-	 * field are between 1 and 8. If the VNIC uses header-data-
-	 * separation and/or TPA with buffer spanning enabled, valid
-	 * values for this field are between 2 and 8.
-	 * This feature can only be configured when proxy mode is supported
-	 * on the function
-	 */
-	uint16_t	max_bds;
-	uint8_t	unused_0[3];
+	/* Reserved */
+	uint8_t	unused0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
 	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
 	uint8_t	valid;
-} hwrm_vnic_plcmodes_qcfg_output_t, *phwrm_vnic_plcmodes_qcfg_output_t;
+} hwrm_tfc_tcam_free_output_t, *phwrm_tfc_tcam_free_output_t;
 
-/**********************************
- * hwrm_vnic_rss_cos_lb_ctx_alloc *
- **********************************/
+/***********************
+ * hwrm_tfc_if_tbl_set *
+ ***********************/
 
 
-/* hwrm_vnic_rss_cos_lb_ctx_alloc_input (size:128b/16B) */
+/* hwrm_tfc_if_tbl_set_input (size:960b/120B) */
 
-typedef struct hwrm_vnic_rss_cos_lb_ctx_alloc_input {
+typedef struct hwrm_tfc_if_tbl_set_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -30500,11 +58085,37 @@ typedef struct hwrm_vnic_rss_cos_lb_ctx_alloc_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-} hwrm_vnic_rss_cos_lb_ctx_alloc_input_t, *phwrm_vnic_rss_cos_lb_ctx_alloc_input_t;
+	/* Session identifier. */
+	uint16_t	sid;
+	/* Function identifier. */
+	uint16_t	fid;
+	/*
+	 * Subtype identifying IF table type. See
+	 * cfa_v3/include/cfa_resources.h.
+	 */
+	uint8_t	subtype;
+	/* Control flags. */
+	uint8_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TFC_IF_TBL_SET_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TFC_IF_TBL_SET_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TFC_IF_TBL_SET_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TFC_IF_TBL_SET_INPUT_FLAGS_DIR_LAST HWRM_TFC_IF_TBL_SET_INPUT_FLAGS_DIR_TX
+	/* Table entry index. */
+	uint16_t	index;
+	/* Size of data in data field. */
+	uint8_t	data_size;
+	/* Reserved */
+	uint8_t	unused0[7];
+	/* Table data. */
+	uint8_t	data[88];
+} hwrm_tfc_if_tbl_set_input_t, *phwrm_tfc_if_tbl_set_input_t;
 
-/* hwrm_vnic_rss_cos_lb_ctx_alloc_output (size:128b/16B) */
+/* hwrm_tfc_if_tbl_set_output (size:128b/16B) */
 
-typedef struct hwrm_vnic_rss_cos_lb_ctx_alloc_output {
+typedef struct hwrm_tfc_if_tbl_set_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -30513,27 +58124,27 @@ typedef struct hwrm_vnic_rss_cos_lb_ctx_alloc_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* rss_cos_lb_ctx_id is 16 b */
-	uint16_t	rss_cos_lb_ctx_id;
-	uint8_t	unused_0[5];
+	/* Reserved */
+	uint8_t	unused0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
 	uint8_t	valid;
-} hwrm_vnic_rss_cos_lb_ctx_alloc_output_t, *phwrm_vnic_rss_cos_lb_ctx_alloc_output_t;
+} hwrm_tfc_if_tbl_set_output_t, *phwrm_tfc_if_tbl_set_output_t;
 
-/*********************************
- * hwrm_vnic_rss_cos_lb_ctx_free *
- *********************************/
+/***********************
+ * hwrm_tfc_if_tbl_get *
+ ***********************/
 
 
-/* hwrm_vnic_rss_cos_lb_ctx_free_input (size:192b/24B) */
+/* hwrm_tfc_if_tbl_get_input (size:256b/32B) */
 
-typedef struct hwrm_vnic_rss_cos_lb_ctx_free_input {
+typedef struct hwrm_tfc_if_tbl_get_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -30562,14 +58173,35 @@ typedef struct hwrm_vnic_rss_cos_lb_ctx_free_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* rss_cos_lb_ctx_id is 16 b */
-	uint16_t	rss_cos_lb_ctx_id;
-	uint8_t	unused_0[6];
-} hwrm_vnic_rss_cos_lb_ctx_free_input_t, *phwrm_vnic_rss_cos_lb_ctx_free_input_t;
+	/* Session identifier. */
+	uint16_t	sid;
+	/* Function identifier. */
+	uint16_t	fid;
+	/*
+	 * Subtype identifying IF table type. See
+	 * cfa_v3/include/cfa_resources.h.
+	 */
+	uint8_t	subtype;
+	/* Control flags. */
+	uint8_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TFC_IF_TBL_GET_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TFC_IF_TBL_GET_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TFC_IF_TBL_GET_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TFC_IF_TBL_GET_INPUT_FLAGS_DIR_LAST HWRM_TFC_IF_TBL_GET_INPUT_FLAGS_DIR_TX
+	/* Table entry index. */
+	uint16_t	index;
+	/* Size of data in data field. */
+	uint8_t	data_size;
+	/* Reserved */
+	uint8_t	unused0[7];
+} hwrm_tfc_if_tbl_get_input_t, *phwrm_tfc_if_tbl_get_input_t;
 
-/* hwrm_vnic_rss_cos_lb_ctx_free_output (size:128b/16B) */
+/* hwrm_tfc_if_tbl_get_output (size:960b/120B) */
 
-typedef struct hwrm_vnic_rss_cos_lb_ctx_free_output {
+typedef struct hwrm_tfc_if_tbl_get_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -30578,25 +58210,54 @@ typedef struct hwrm_vnic_rss_cos_lb_ctx_free_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	/* Session identifier. */
+	uint16_t	sid;
+	/* Function identifier. */
+	uint16_t	fid;
+	/*
+	 * Subtype identifying IF table type. See
+	 * cfa_v3/include/cfa_resources.h.
+	 */
+	uint8_t	subtype;
+	/* Control flags. */
+	uint8_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TFC_IF_TBL_GET_OUTPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TFC_IF_TBL_GET_OUTPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TFC_IF_TBL_GET_OUTPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TFC_IF_TBL_GET_OUTPUT_FLAGS_DIR_LAST HWRM_TFC_IF_TBL_GET_OUTPUT_FLAGS_DIR_TX
+	/* Table entry index. */
+	uint16_t	index;
+	/* Size of data in data field. */
+	uint8_t	data_size;
+	/* Reserved */
+	uint8_t	unused0[7];
+	/* Table data. */
+	uint8_t	data[88];
+	/* Reserved */
+	uint8_t	unused1[7];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
 	uint8_t	valid;
-} hwrm_vnic_rss_cos_lb_ctx_free_output_t, *phwrm_vnic_rss_cos_lb_ctx_free_output_t;
+} hwrm_tfc_if_tbl_get_output_t, *phwrm_tfc_if_tbl_get_output_t;
 
-/*******************
- * hwrm_ring_alloc *
- *******************/
+/*********************************
+ * hwrm_tfc_tbl_scope_config_get *
+ *********************************/
 
 
-/* hwrm_ring_alloc_input (size:704b/88B) */
+/* TruFlow command to return whether the table scope is fully configured. */
+/* hwrm_tfc_tbl_scope_config_get_input (size:192b/24B) */
 
-typedef struct hwrm_ring_alloc_input {
+typedef struct hwrm_tfc_tbl_scope_config_get_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -30625,299 +58286,105 @@ typedef struct hwrm_ring_alloc_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	enables;
-	/*
-	 * This bit must be '1' for the ring_arb_cfg field to be
-	 * configured.
-	 */
-	#define HWRM_RING_ALLOC_INPUT_ENABLES_RING_ARB_CFG	UINT32_C(0x2)
-	/*
-	 * This bit must be '1' for the stat_ctx_id_valid field to be
-	 * configured.
-	 */
-	#define HWRM_RING_ALLOC_INPUT_ENABLES_STAT_CTX_ID_VALID	UINT32_C(0x8)
-	/*
-	 * This bit must be '1' for the max_bw_valid field to be
-	 * configured.
-	 */
-	#define HWRM_RING_ALLOC_INPUT_ENABLES_MAX_BW_VALID	UINT32_C(0x20)
-	/*
-	 * This bit must be '1' for the rx_ring_id field to be
-	 * configured.
-	 */
-	#define HWRM_RING_ALLOC_INPUT_ENABLES_RX_RING_ID_VALID	UINT32_C(0x40)
-	/*
-	 * This bit must be '1' for the nq_ring_id field to be
-	 * configured.
-	 */
-	#define HWRM_RING_ALLOC_INPUT_ENABLES_NQ_RING_ID_VALID	UINT32_C(0x80)
-	/*
-	 * This bit must be '1' for the rx_buf_size field to be
-	 * configured.
-	 */
-	#define HWRM_RING_ALLOC_INPUT_ENABLES_RX_BUF_SIZE_VALID	UINT32_C(0x100)
-	/*
-	 * This bit must be '1' for the schq_id field to be
-	 * configured.
-	 */
-	#define HWRM_RING_ALLOC_INPUT_ENABLES_SCHQ_ID		UINT32_C(0x200)
-	/*
-	 * This bit must be '1' for the mpc_chnls_type field to be
-	 * configured.
-	 */
-	#define HWRM_RING_ALLOC_INPUT_ENABLES_MPC_CHNLS_TYPE	UINT32_C(0x400)
-	/* Ring Type. */
-	uint8_t	ring_type;
-	/* L2 Completion Ring (CR) */
-	#define HWRM_RING_ALLOC_INPUT_RING_TYPE_L2_CMPL   UINT32_C(0x0)
-	/* TX Ring (TR) */
-	#define HWRM_RING_ALLOC_INPUT_RING_TYPE_TX	UINT32_C(0x1)
-	/* RX Ring (RR) */
-	#define HWRM_RING_ALLOC_INPUT_RING_TYPE_RX	UINT32_C(0x2)
-	/* RoCE Notification Completion Ring (ROCE_CR) */
-	#define HWRM_RING_ALLOC_INPUT_RING_TYPE_ROCE_CMPL UINT32_C(0x3)
-	/* RX Aggregation Ring */
-	#define HWRM_RING_ALLOC_INPUT_RING_TYPE_RX_AGG	UINT32_C(0x4)
-	/* Notification Queue */
-	#define HWRM_RING_ALLOC_INPUT_RING_TYPE_NQ	UINT32_C(0x5)
-	#define HWRM_RING_ALLOC_INPUT_RING_TYPE_LAST	HWRM_RING_ALLOC_INPUT_RING_TYPE_NQ
-	uint8_t	unused_0;
-	/* Ring allocation flags. */
-	uint16_t	flags;
-	/*
-	 * For Rx rings, the incoming packet data can be placed at either
-	 * a 0B or 2B offset from the start of the Rx packet buffer. When
-	 * '1', the received packet will be padded with 2B of zeros at the
-	 * front of the packet. Note that this flag is only used for
-	 * Rx rings and is ignored for all other rings included Rx
-	 * Aggregation rings.
-	 */
-	#define HWRM_RING_ALLOC_INPUT_FLAGS_RX_SOP_PAD	UINT32_C(0x1)
-	/*
-	 * This value is a pointer to the page table for the
-	 * Ring.
-	 */
-	uint64_t	page_tbl_addr;
-	/* First Byte Offset of the first entry in the first page. */
-	uint32_t	fbo;
-	/*
-	 * Actual page size in 2^page_size. The supported range is increments
-	 * in powers of 2 from 16 bytes to 1GB.
-	 * - 4 = 16 B
-	 *	Page size is 16 B.
-	 * - 12 = 4 KB
-	 *	Page size is 4 KB.
-	 * - 13 = 8 KB
-	 *	Page size is 8 KB.
-	 * - 16 = 64 KB
-	 *	Page size is 64 KB.
-	 * - 21 = 2 MB
-	 *	Page size is 2 MB.
-	 * - 22 = 4 MB
-	 *	Page size is 4 MB.
-	 * - 30 = 1 GB
-	 *	Page size is 1 GB.
-	 */
-	uint8_t	page_size;
-	/*
-	 * This value indicates the depth of page table.
-	 * For this version of the specification, value other than 0 or
-	 * 1 shall be considered as an invalid value.
-	 * When the page_tbl_depth = 0, then it is treated as a
-	 * special case with the following.
-	 * 1. FBO and page size fields are not valid.
-	 * 2. page_tbl_addr is the physical address of the first
-	 *	element of the ring.
-	 */
-	uint8_t	page_tbl_depth;
-	/* Used by a PF driver to associate a SCHQ with one of its TX rings. */
-	uint16_t	schq_id;
-	/*
-	 * Number of 16B units in the ring.  Minimum size for
-	 * a ring is 16 16B entries.
-	 */
-	uint32_t	length;
-	/*
-	 * Logical ring number for the ring to be allocated.
-	 * This value determines the position in the doorbell
-	 * area where the update to the ring will be made.
-	 *
-	 * For completion rings, this value is also the MSI-X
-	 * vector number for the function the completion ring is
-	 * associated with.
-	 */
-	uint16_t	logical_id;
-	/*
-	 * This field is used only when ring_type is a TX ring.
-	 * This value indicates what completion ring the TX ring
-	 * is associated with.
-	 */
-	uint16_t	cmpl_ring_id;
-	/*
-	 * This field is used only when ring_type is a TX ring.
-	 * This value indicates what CoS queue the TX ring
-	 * is associated with.
-	 */
-	uint16_t	queue_id;
-	/*
-	 * When allocating a Rx ring or Rx aggregation ring, this field
-	 * specifies the size of the buffer descriptors posted to the ring.
-	 */
-	uint16_t	rx_buf_size;
-	/*
-	 * When allocating an Rx aggregation ring, this field
-	 * specifies the associated Rx ring ID.
-	 */
-	uint16_t	rx_ring_id;
-	/*
-	 * When allocating a completion ring, this field
-	 * specifies the associated NQ ring ID.
-	 */
-	uint16_t	nq_ring_id;
-	/*
-	 * This field is used only when ring_type is a TX ring.
-	 * This field is used to configure arbitration related
-	 * parameters for a TX ring.
-	 */
-	uint16_t	ring_arb_cfg;
-	/* Arbitration policy used for the ring. */
-	#define HWRM_RING_ALLOC_INPUT_RING_ARB_CFG_ARB_POLICY_MASK	UINT32_C(0xf)
-	#define HWRM_RING_ALLOC_INPUT_RING_ARB_CFG_ARB_POLICY_SFT	0
-	/*
-	 * Use strict priority for the TX ring.
-	 * Priority value is specified in arb_policy_param
-	 */
-		#define HWRM_RING_ALLOC_INPUT_RING_ARB_CFG_ARB_POLICY_SP	UINT32_C(0x1)
-	/*
-	 * Use weighted fair queue arbitration for the TX ring.
-	 * Weight is specified in arb_policy_param
-	 */
-		#define HWRM_RING_ALLOC_INPUT_RING_ARB_CFG_ARB_POLICY_WFQ	UINT32_C(0x2)
-		#define HWRM_RING_ALLOC_INPUT_RING_ARB_CFG_ARB_POLICY_LAST	HWRM_RING_ALLOC_INPUT_RING_ARB_CFG_ARB_POLICY_WFQ
-	/* Reserved field. */
-	#define HWRM_RING_ALLOC_INPUT_RING_ARB_CFG_RSVD_MASK		UINT32_C(0xf0)
-	#define HWRM_RING_ALLOC_INPUT_RING_ARB_CFG_RSVD_SFT		4
-	/*
-	 * Arbitration policy specific parameter.
-	 * # For strict priority arbitration policy, this field
-	 * represents a priority value. If set to 0, then the priority
-	 * is not specified and the HWRM is allowed to select
-	 * any priority for this TX ring.
-	 * # For weighted fair queue arbitration policy, this field
-	 * represents a weight value. If set to 0, then the weight
-	 * is not specified and the HWRM is allowed to select
-	 * any weight for this TX ring.
-	 */
-	#define HWRM_RING_ALLOC_INPUT_RING_ARB_CFG_ARB_POLICY_PARAM_MASK UINT32_C(0xff00)
-	#define HWRM_RING_ALLOC_INPUT_RING_ARB_CFG_ARB_POLICY_PARAM_SFT 8
-	uint16_t	unused_3;
-	/*
-	 * This field is reserved for the future use.
-	 * It shall be set to 0.
-	 */
-	uint32_t	reserved3;
-	/*
-	 * This field is used only when ring_type is a TX ring.
-	 * This input indicates what statistics context this ring
-	 * should be associated with.
-	 */
-	uint32_t	stat_ctx_id;
-	/*
-	 * This field is reserved for the future use.
-	 * It shall be set to 0.
-	 */
-	uint32_t	reserved4;
-	/*
-	 * This field is used only when ring_type is a TX ring
-	 * to specify maximum BW allocated to the TX ring.
-	 * The HWRM will translate this value into byte counter and
-	 * time interval used for this ring inside the device.
-	 */
-	uint32_t	max_bw;
-	/* The bandwidth value. */
-	#define HWRM_RING_ALLOC_INPUT_MAX_BW_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_RING_ALLOC_INPUT_MAX_BW_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_RING_ALLOC_INPUT_MAX_BW_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_RING_ALLOC_INPUT_MAX_BW_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_RING_ALLOC_INPUT_MAX_BW_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_RING_ALLOC_INPUT_MAX_BW_SCALE_LAST		HWRM_RING_ALLOC_INPUT_MAX_BW_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_RING_ALLOC_INPUT_MAX_BW_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_RING_ALLOC_INPUT_MAX_BW_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_RING_ALLOC_INPUT_MAX_BW_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_RING_ALLOC_INPUT_MAX_BW_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_RING_ALLOC_INPUT_MAX_BW_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_RING_ALLOC_INPUT_MAX_BW_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_RING_ALLOC_INPUT_MAX_BW_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_RING_ALLOC_INPUT_MAX_BW_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_RING_ALLOC_INPUT_MAX_BW_BW_VALUE_UNIT_LAST	HWRM_RING_ALLOC_INPUT_MAX_BW_BW_VALUE_UNIT_INVALID
-	/*
-	 * This field is used only when ring_type is a Completion ring.
-	 * This value indicates what interrupt mode should be used
-	 * on this completion ring.
-	 * Note: In the legacy interrupt mode, no more than 16
-	 * completion rings are allowed.
-	 */
-	uint8_t	int_mode;
-	/* Legacy INTA */
-	#define HWRM_RING_ALLOC_INPUT_INT_MODE_LEGACY UINT32_C(0x0)
-	/* Reserved */
-	#define HWRM_RING_ALLOC_INPUT_INT_MODE_RSVD   UINT32_C(0x1)
-	/* MSI-X */
-	#define HWRM_RING_ALLOC_INPUT_INT_MODE_MSIX   UINT32_C(0x2)
-	/* No Interrupt - Polled mode */
-	#define HWRM_RING_ALLOC_INPUT_INT_MODE_POLL   UINT32_C(0x3)
-	#define HWRM_RING_ALLOC_INPUT_INT_MODE_LAST  HWRM_RING_ALLOC_INPUT_INT_MODE_POLL
-	/* Midpath channel type */
-	uint8_t	mpc_chnls_type;
-	/*
-	 * Indicate the TX ring alloc MPC channel type is a MPC channel
-	 * with destination to the TX crypto engine block.
-	 */
-	#define HWRM_RING_ALLOC_INPUT_MPC_CHNLS_TYPE_TCE	UINT32_C(0x0)
+	/* The table scope ID. */
+	uint8_t	tsid;
+	/* unused. */
+	uint8_t	unused0[7];
+} hwrm_tfc_tbl_scope_config_get_input_t, *phwrm_tfc_tbl_scope_config_get_input_t;
+
+/* hwrm_tfc_tbl_scope_config_get_output (size:128b/16B) */
+
+typedef struct hwrm_tfc_tbl_scope_config_get_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* If set to 1, the table scope is configured. */
+	uint8_t	configured;
+	/* unused. */
+	uint8_t	unused0[6];
 	/*
-	 * Indicate the RX ring alloc MPC channel type is a MPC channel
-	 * with destination to the RX crypto engine block.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
-	#define HWRM_RING_ALLOC_INPUT_MPC_CHNLS_TYPE_RCE	UINT32_C(0x1)
+	uint8_t	valid;
+} hwrm_tfc_tbl_scope_config_get_output_t, *phwrm_tfc_tbl_scope_config_get_output_t;
+
+/*****************************
+ * hwrm_tfc_resc_usage_query *
+ *****************************/
+
+
+/* hwrm_tfc_resc_usage_query_input (size:256b/32B) */
+
+typedef struct hwrm_tfc_resc_usage_query_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * Indicate the RX ring alloc MPC channel type is a MPC channel
-	 * with destination to the TX configurable flow processing block.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define HWRM_RING_ALLOC_INPUT_MPC_CHNLS_TYPE_TE_CFA  UINT32_C(0x2)
+	uint16_t	cmpl_ring;
 	/*
-	 * Indicate the RX ring alloc MPC channel type is a MPC channel
-	 * with destination to the RX configurable flow processing block.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define HWRM_RING_ALLOC_INPUT_MPC_CHNLS_TYPE_RE_CFA  UINT32_C(0x3)
+	uint16_t	seq_id;
 	/*
-	 * Indicate the RX ring alloc MPC channel type is a MPC channel
-	 * with destination to the primate processor block.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define HWRM_RING_ALLOC_INPUT_MPC_CHNLS_TYPE_PRIMATE UINT32_C(0x4)
-	#define HWRM_RING_ALLOC_INPUT_MPC_CHNLS_TYPE_LAST   HWRM_RING_ALLOC_INPUT_MPC_CHNLS_TYPE_PRIMATE
-	uint8_t	unused_4[2];
+	uint16_t	target_id;
 	/*
-	 * The cq_handle is specified when allocating a completion ring. For
-	 * devices that support NQs, this cq_handle will be included in the
-	 * NQE to specify which CQ should be read to retrieve the completion
-	 * record.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint64_t	cq_handle;
-} hwrm_ring_alloc_input_t, *phwrm_ring_alloc_input_t;
+	uint64_t	resp_addr;
+	/* Session identifier. */
+	uint16_t	sid;
+	/* Function identifier. */
+	uint16_t	fid;
+	/* Control flags. */
+	uint8_t	flags;
+	/* Indicates the flow direction. */
+	#define HWRM_TFC_RESC_USAGE_QUERY_INPUT_FLAGS_DIR	UINT32_C(0x1)
+	/* If this bit set to 0, then it indicates rx flow. */
+		#define HWRM_TFC_RESC_USAGE_QUERY_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
+	/* If this bit is set to 1, then it indicates tx flow. */
+		#define HWRM_TFC_RESC_USAGE_QUERY_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
+		#define HWRM_TFC_RESC_USAGE_QUERY_INPUT_FLAGS_DIR_LAST HWRM_TFC_RESC_USAGE_QUERY_INPUT_FLAGS_DIR_TX
+	/* Describes the type of tracking id to be used */
+	uint8_t	track_type;
+	/* Invalid track type */
+	#define HWRM_TFC_RESC_USAGE_QUERY_INPUT_TRACK_TYPE_TRACK_TYPE_INVALID UINT32_C(0x0)
+	/* Tracked by session id */
+	#define HWRM_TFC_RESC_USAGE_QUERY_INPUT_TRACK_TYPE_TRACK_TYPE_SID	UINT32_C(0x1)
+	/* Tracked by function id */
+	#define HWRM_TFC_RESC_USAGE_QUERY_INPUT_TRACK_TYPE_TRACK_TYPE_FID	UINT32_C(0x2)
+	#define HWRM_TFC_RESC_USAGE_QUERY_INPUT_TRACK_TYPE_LAST		HWRM_TFC_RESC_USAGE_QUERY_INPUT_TRACK_TYPE_TRACK_TYPE_FID
+	/* Size of data in data field. */
+	uint16_t	data_size;
+	/* unused */
+	uint8_t	unused1[8];
+} hwrm_tfc_resc_usage_query_input_t, *phwrm_tfc_resc_usage_query_input_t;
 
-/* hwrm_ring_alloc_output (size:128b/16B) */
+/* hwrm_tfc_resc_usage_query_output (size:960b/120B) */
 
-typedef struct hwrm_ring_alloc_output {
+typedef struct hwrm_tfc_resc_usage_query_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -30926,42 +58393,35 @@ typedef struct hwrm_ring_alloc_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/*
-	 * Physical number of ring allocated.
-	 * This value shall be unique for a ring type.
-	 */
-	uint16_t	ring_id;
-	/* Logical number of ring allocated. */
-	uint16_t	logical_ring_id;
-	/*
-	 * This field will tell whether to use ping or pong buffer
-	 * for first push operation.
-	 */
-	uint8_t	push_buffer_index;
-	/* Start push from ping buffer index */
-	#define HWRM_RING_ALLOC_OUTPUT_PUSH_BUFFER_INDEX_PING_BUFFER UINT32_C(0x0)
-	/* Start push from pong buffer index */
-	#define HWRM_RING_ALLOC_OUTPUT_PUSH_BUFFER_INDEX_PONG_BUFFER UINT32_C(0x1)
-	#define HWRM_RING_ALLOC_OUTPUT_PUSH_BUFFER_INDEX_LAST	HWRM_RING_ALLOC_OUTPUT_PUSH_BUFFER_INDEX_PONG_BUFFER
-	uint8_t	unused_0[2];
+	/* Response code. */
+	uint32_t	resp_code;
+	/* Size of data in data field. */
+	uint16_t	data_size;
+	/* unused */
+	uint16_t	unused0;
+	/* Response data. */
+	uint8_t	data[96];
+	/* unused */
+	uint8_t	unused1[7];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field
+	 * is written last.
 	 */
 	uint8_t	valid;
-} hwrm_ring_alloc_output_t, *phwrm_ring_alloc_output_t;
+} hwrm_tfc_resc_usage_query_output_t, *phwrm_tfc_resc_usage_query_output_t;
 
-/******************
- * hwrm_ring_free *
- ******************/
+/******************************
+ * hwrm_tunnel_dst_port_query *
+ ******************************/
 
 
-/* hwrm_ring_free_input (size:256b/32B) */
+/* hwrm_tunnel_dst_port_query_input (size:192b/24B) */
 
-typedef struct hwrm_ring_free_input {
+typedef struct hwrm_tunnel_dst_port_query_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -30990,56 +58450,64 @@ typedef struct hwrm_ring_free_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Ring Type. */
-	uint8_t	ring_type;
-	/* L2 Completion Ring (CR) */
-	#define HWRM_RING_FREE_INPUT_RING_TYPE_L2_CMPL   UINT32_C(0x0)
-	/* TX Ring (TR) */
-	#define HWRM_RING_FREE_INPUT_RING_TYPE_TX	UINT32_C(0x1)
-	/* RX Ring (RR) */
-	#define HWRM_RING_FREE_INPUT_RING_TYPE_RX	UINT32_C(0x2)
-	/* RoCE Notification Completion Ring (ROCE_CR) */
-	#define HWRM_RING_FREE_INPUT_RING_TYPE_ROCE_CMPL UINT32_C(0x3)
-	/* RX Aggregation Ring */
-	#define HWRM_RING_FREE_INPUT_RING_TYPE_RX_AGG	UINT32_C(0x4)
-	/* Notification Queue */
-	#define HWRM_RING_FREE_INPUT_RING_TYPE_NQ	UINT32_C(0x5)
-	#define HWRM_RING_FREE_INPUT_RING_TYPE_LAST	HWRM_RING_FREE_INPUT_RING_TYPE_NQ
-	uint8_t	flags;
-	/*
-	 * If this bit is set to '1', ring_id in this command belongs to
-	 * virtio function. prod_idx in this command corresponds to doorbell
-	 * producer index. opaque field in this command needs to be inserted
-	 * by firmware in VEE_FLUSH completion record.
-	 * Firmware will poll the corresponding ring context to reach the
-	 * given producer index before sending successful response. It will
-	 * finish the completion using VEE_FLUSH completion record.
-	 *
-	 * If this bit is '0', firmware will not treat ring_id as virtio
-	 * ring and ignore prod_idx, opaque fields.
-	 *
-	 * This feature is not applicable for L2 or RoCE.
-	 */
-	#define HWRM_RING_FREE_INPUT_FLAGS_VIRTIO_RING_VALID UINT32_C(0x1)
-	#define HWRM_RING_FREE_INPUT_FLAGS_LAST		HWRM_RING_FREE_INPUT_FLAGS_VIRTIO_RING_VALID
-	/* Physical number of ring allocated. */
-	uint16_t	ring_id;
+	/* Tunnel Type. */
+	uint8_t	tunnel_type;
+	/* Virtual eXtensible Local Area Network (VXLAN) */
+	#define HWRM_TUNNEL_DST_PORT_QUERY_INPUT_TUNNEL_TYPE_VXLAN		UINT32_C(0x1)
+	/* Generic Network Virtualization Encapsulation (Geneve) */
+	#define HWRM_TUNNEL_DST_PORT_QUERY_INPUT_TUNNEL_TYPE_GENEVE		UINT32_C(0x5)
+	/* IPV4 over virtual eXtensible Local Area Network (IPV4oVXLAN) */
+	#define HWRM_TUNNEL_DST_PORT_QUERY_INPUT_TUNNEL_TYPE_VXLAN_V4	UINT32_C(0x9)
 	/*
-	 * Ring BD producer index posted by the virtio block.
-	 * This field is valid if virtio_ring_valid flag is set.
+	 * Enhance Generic Routing Encapsulation (GRE version 1) inside IP
+	 * datagram payload
 	 */
-	uint32_t	prod_idx;
+	#define HWRM_TUNNEL_DST_PORT_QUERY_INPUT_TUNNEL_TYPE_IPGRE_V1	UINT32_C(0xa)
+	/* Use fixed layer 2 ether type of 0xFFFF */
+	#define HWRM_TUNNEL_DST_PORT_QUERY_INPUT_TUNNEL_TYPE_L2_ETYPE	UINT32_C(0xb)
 	/*
-	 * User defined opaque field to be inserted into VEE_FLUSH completion
-	 * record. This field is valid if virtio_ring_valid flag is set.
+	 * IPV6 over virtual eXtensible Local Area Network with GPE header
+	 * (IPV6oVXLANGPE)
 	 */
-	uint32_t	opaque;
-	uint32_t	unused_1;
-} hwrm_ring_free_input_t, *phwrm_ring_free_input_t;
+	#define HWRM_TUNNEL_DST_PORT_QUERY_INPUT_TUNNEL_TYPE_VXLAN_GPE_V6	UINT32_C(0xc)
+	/* Custom GRE uses UPAR to parse customized GRE packets */
+	#define HWRM_TUNNEL_DST_PORT_QUERY_INPUT_TUNNEL_TYPE_CUSTOM_GRE	UINT32_C(0xd)
+	/* Enhanced Common Packet Radio Interface (eCPRI) */
+	#define HWRM_TUNNEL_DST_PORT_QUERY_INPUT_TUNNEL_TYPE_ECPRI		UINT32_C(0xe)
+	/* IPv6 Segment Routing (SRv6) */
+	#define HWRM_TUNNEL_DST_PORT_QUERY_INPUT_TUNNEL_TYPE_SRV6		UINT32_C(0xf)
+	/* Generic Protocol Extension for VXLAN (VXLAN-GPE) */
+	#define HWRM_TUNNEL_DST_PORT_QUERY_INPUT_TUNNEL_TYPE_VXLAN_GPE	UINT32_C(0x10)
+	/* Generic Routing Encapsulation */
+	#define HWRM_TUNNEL_DST_PORT_QUERY_INPUT_TUNNEL_TYPE_GRE		UINT32_C(0x11)
+	/* ULP Dynamic UPAR tunnel */
+	#define HWRM_TUNNEL_DST_PORT_QUERY_INPUT_TUNNEL_TYPE_ULP_DYN_UPAR	UINT32_C(0x12)
+	/* ULP Dynamic UPAR tunnel reserved 1 */
+	#define HWRM_TUNNEL_DST_PORT_QUERY_INPUT_TUNNEL_TYPE_ULP_DYN_UPAR_RES01 UINT32_C(0x13)
+	/* ULP Dynamic UPAR tunnel reserved 2 */
+	#define HWRM_TUNNEL_DST_PORT_QUERY_INPUT_TUNNEL_TYPE_ULP_DYN_UPAR_RES02 UINT32_C(0x14)
+	/* ULP Dynamic UPAR tunnel reserved 3 */
+	#define HWRM_TUNNEL_DST_PORT_QUERY_INPUT_TUNNEL_TYPE_ULP_DYN_UPAR_RES03 UINT32_C(0x15)
+	/* ULP Dynamic UPAR tunnel reserved 4 */
+	#define HWRM_TUNNEL_DST_PORT_QUERY_INPUT_TUNNEL_TYPE_ULP_DYN_UPAR_RES04 UINT32_C(0x16)
+	/* ULP Dynamic UPAR tunnel reserved 5 */
+	#define HWRM_TUNNEL_DST_PORT_QUERY_INPUT_TUNNEL_TYPE_ULP_DYN_UPAR_RES05 UINT32_C(0x17)
+	/* ULP Dynamic UPAR tunnel reserved 6 */
+	#define HWRM_TUNNEL_DST_PORT_QUERY_INPUT_TUNNEL_TYPE_ULP_DYN_UPAR_RES06 UINT32_C(0x18)
+	/* ULP Dynamic UPAR tunnel reserved 7 */
+	#define HWRM_TUNNEL_DST_PORT_QUERY_INPUT_TUNNEL_TYPE_ULP_DYN_UPAR_RES07 UINT32_C(0x19)
+	#define HWRM_TUNNEL_DST_PORT_QUERY_INPUT_TUNNEL_TYPE_LAST		HWRM_TUNNEL_DST_PORT_QUERY_INPUT_TUNNEL_TYPE_ULP_DYN_UPAR_RES07
+	/*
+	 * This field is used to specify the next protocol value defined in the
+	 * corresponding RFC spec for the applicable tunnel type.
+	 */
+	uint8_t	tunnel_next_proto;
+	uint8_t	unused_0[6];
+} hwrm_tunnel_dst_port_query_input_t, *phwrm_tunnel_dst_port_query_input_t;
 
-/* hwrm_ring_free_output (size:128b/16B) */
+/* hwrm_tunnel_dst_port_query_output (size:128b/16B) */
 
-typedef struct hwrm_ring_free_output {
+typedef struct hwrm_tunnel_dst_port_query_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -31048,25 +58516,78 @@ typedef struct hwrm_ring_free_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	/*
+	 * This field represents the identifier of L4 destination port
+	 * used for the given tunnel type. This field is valid for
+	 * specific tunnel types that use layer 4 (e.g. UDP)
+	 * transports for tunneling.
+	 */
+	uint16_t	tunnel_dst_port_id;
+	/*
+	 * This field represents the value of L4 destination port
+	 * identified by tunnel_dst_port_id. This field is valid for
+	 * specific tunnel types that use layer 4 (e.g. UDP)
+	 * transports for tunneling.
+	 * This field is in network byte order.
+	 *
+	 * A value of 0 means that the destination port is not
+	 * configured.
+	 */
+	uint16_t	tunnel_dst_port_val;
+	/*
+	 * This field represents the UPAR usage status.
+	 * Available UPARs on wh+ are UPAR0 and UPAR1
+	 * Available UPARs on Thor are UPAR0 to UPAR3
+	 * Available UPARs on Thor2 are UPAR0 to UPAR7
+	 */
+	uint8_t	upar_in_use;
+	/* This bit will be '1' when UPAR0 is IN_USE */
+	#define HWRM_TUNNEL_DST_PORT_QUERY_OUTPUT_UPAR_IN_USE_UPAR0	UINT32_C(0x1)
+	/* This bit will be '1' when UPAR1 is IN_USE */
+	#define HWRM_TUNNEL_DST_PORT_QUERY_OUTPUT_UPAR_IN_USE_UPAR1	UINT32_C(0x2)
+	/* This bit will be '1' when UPAR2 is IN_USE */
+	#define HWRM_TUNNEL_DST_PORT_QUERY_OUTPUT_UPAR_IN_USE_UPAR2	UINT32_C(0x4)
+	/* This bit will be '1' when UPAR3 is IN_USE */
+	#define HWRM_TUNNEL_DST_PORT_QUERY_OUTPUT_UPAR_IN_USE_UPAR3	UINT32_C(0x8)
+	/* This bit will be '1' when UPAR4 is IN_USE */
+	#define HWRM_TUNNEL_DST_PORT_QUERY_OUTPUT_UPAR_IN_USE_UPAR4	UINT32_C(0x10)
+	/* This bit will be '1' when UPAR5 is IN_USE */
+	#define HWRM_TUNNEL_DST_PORT_QUERY_OUTPUT_UPAR_IN_USE_UPAR5	UINT32_C(0x20)
+	/* This bit will be '1' when UPAR6 is IN_USE */
+	#define HWRM_TUNNEL_DST_PORT_QUERY_OUTPUT_UPAR_IN_USE_UPAR6	UINT32_C(0x40)
+	/* This bit will be '1' when UPAR7 is IN_USE */
+	#define HWRM_TUNNEL_DST_PORT_QUERY_OUTPUT_UPAR_IN_USE_UPAR7	UINT32_C(0x80)
+	/*
+	 * This field is used to convey the status of non udp port based
+	 * tunnel parsing at chip level and at function level.
+	 */
+	uint8_t	status;
+	/* This bit will be '1' when tunnel parsing is enabled globally. */
+	#define HWRM_TUNNEL_DST_PORT_QUERY_OUTPUT_STATUS_CHIP_LEVEL	UINT32_C(0x1)
+	/*
+	 * This bit will be '1' when tunnel parsing is enabled
+	 * on the corresponding function.
+	 */
+	#define HWRM_TUNNEL_DST_PORT_QUERY_OUTPUT_STATUS_FUNC_LEVEL	UINT32_C(0x2)
+	uint8_t	unused_0;
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
 	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_ring_free_output_t, *phwrm_ring_free_output_t;
+} hwrm_tunnel_dst_port_query_output_t, *phwrm_tunnel_dst_port_query_output_t;
 
-/*******************
- * hwrm_ring_reset *
- *******************/
+/******************************
+ * hwrm_tunnel_dst_port_alloc *
+ ******************************/
 
 
-/* hwrm_ring_reset_input (size:192b/24B) */
+/* hwrm_tunnel_dst_port_alloc_input (size:192b/24B) */
 
-typedef struct hwrm_ring_reset_input {
+typedef struct hwrm_tunnel_dst_port_alloc_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -31095,35 +58616,78 @@ typedef struct hwrm_ring_reset_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Ring Type. */
-	uint8_t	ring_type;
-	/* L2 Completion Ring (CR) */
-	#define HWRM_RING_RESET_INPUT_RING_TYPE_L2_CMPL	UINT32_C(0x0)
-	/* TX Ring (TR) */
-	#define HWRM_RING_RESET_INPUT_RING_TYPE_TX	UINT32_C(0x1)
-	/* RX Ring (RR) */
-	#define HWRM_RING_RESET_INPUT_RING_TYPE_RX	UINT32_C(0x2)
-	/* RoCE Notification Completion Ring (ROCE_CR) */
-	#define HWRM_RING_RESET_INPUT_RING_TYPE_ROCE_CMPL   UINT32_C(0x3)
+	/* Tunnel Type. */
+	uint8_t	tunnel_type;
+	/* Virtual eXtensible Local Area Network (VXLAN) */
+	#define HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_VXLAN		UINT32_C(0x1)
+	/* Generic Network Virtualization Encapsulation (Geneve) */
+	#define HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_GENEVE		UINT32_C(0x5)
+	/* IPV4 over virtual eXtensible Local Area Network (IPV4oVXLAN) */
+	#define HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_V4	UINT32_C(0x9)
 	/*
-	 * Rx Ring Group.  This is to reset rx and aggregation in an atomic
-	 * operation. Completion ring associated with this ring group is
-	 * not reset.
+	 * Enhance Generic Routing Encapsulation (GRE version 1) inside IP
+	 * datagram payload
 	 */
-	#define HWRM_RING_RESET_INPUT_RING_TYPE_RX_RING_GRP UINT32_C(0x6)
-	#define HWRM_RING_RESET_INPUT_RING_TYPE_LAST	HWRM_RING_RESET_INPUT_RING_TYPE_RX_RING_GRP
-	uint8_t	unused_0;
+	#define HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_IPGRE_V1	UINT32_C(0xa)
+	/* Use fixed layer 2 ether type of 0xFFFF */
+	#define HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_L2_ETYPE	UINT32_C(0xb)
 	/*
-	 * Physical number of the ring. When ring type is rx_ring_grp, ring id
-	 * actually refers to ring group id.
+	 * IPV6 over virtual eXtensible Local Area Network with GPE header
+	 * (IPV6oVXLANGPE)
 	 */
-	uint16_t	ring_id;
-	uint8_t	unused_1[4];
-} hwrm_ring_reset_input_t, *phwrm_ring_reset_input_t;
+	#define HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_GPE_V6	UINT32_C(0xc)
+	/*
+	 * Custom GRE uses UPAR to parse customized GRE packets. This is not
+	 * supported.
+	 */
+	#define HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_CUSTOM_GRE	UINT32_C(0xd)
+	/* Enhanced Common Packet Radio Interface (eCPRI) */
+	#define HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_ECPRI		UINT32_C(0xe)
+	/* IPv6 Segment Routing (SRv6) */
+	#define HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_SRV6		UINT32_C(0xf)
+	/* Generic Protocol Extension for VXLAN (VXLAN-GPE) */
+	#define HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_GPE	UINT32_C(0x10)
+	/* Generic Routing Encapsulation */
+	#define HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_GRE		UINT32_C(0x11)
+	/* ULP Dynamic UPAR tunnel */
+	#define HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_ULP_DYN_UPAR	UINT32_C(0x12)
+	/* ULP Dynamic UPAR tunnel reserved 1 */
+	#define HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_ULP_DYN_UPAR_RES01 UINT32_C(0x13)
+	/* ULP Dynamic UPAR tunnel reserved 2 */
+	#define HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_ULP_DYN_UPAR_RES02 UINT32_C(0x14)
+	/* ULP Dynamic UPAR tunnel reserved 3 */
+	#define HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_ULP_DYN_UPAR_RES03 UINT32_C(0x15)
+	/* ULP Dynamic UPAR tunnel reserved 4 */
+	#define HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_ULP_DYN_UPAR_RES04 UINT32_C(0x16)
+	/* ULP Dynamic UPAR tunnel reserved 5 */
+	#define HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_ULP_DYN_UPAR_RES05 UINT32_C(0x17)
+	/* ULP Dynamic UPAR tunnel reserved 6 */
+	#define HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_ULP_DYN_UPAR_RES06 UINT32_C(0x18)
+	/* ULP Dynamic UPAR tunnel reserved 7 */
+	#define HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_ULP_DYN_UPAR_RES07 UINT32_C(0x19)
+	#define HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_LAST		HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_ULP_DYN_UPAR_RES07
+	/*
+	 * This field is used to specify the next protocol value defined in the
+	 * corresponding RFC spec for the applicable tunnel type.
+	 */
+	uint8_t	tunnel_next_proto;
+	/*
+	 * This field represents the value of L4 destination port used
+	 * for the given tunnel type. This field is valid for
+	 * specific tunnel types that use layer 4 (e.g. UDP)
+	 * transports for tunneling.
+	 *
+	 * This field is in network byte order.
+	 *
+	 * A value of 0 shall fail the command.
+	 */
+	uint16_t	tunnel_dst_port_val;
+	uint8_t	unused_0[4];
+} hwrm_tunnel_dst_port_alloc_input_t, *phwrm_tunnel_dst_port_alloc_input_t;
 
-/* hwrm_ring_reset_output (size:128b/16B) */
+/* hwrm_tunnel_dst_port_alloc_output (size:128b/16B) */
 
-typedef struct hwrm_ring_reset_output {
+typedef struct hwrm_tunnel_dst_port_alloc_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -31133,36 +58697,63 @@ typedef struct hwrm_ring_reset_output {
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
 	/*
-	 * This field will tell whether to use ping or pong buffer
-	 * for first push operation.
+	 * Identifier of a tunnel L4 destination port value. Only applies to
+	 * tunnel types that has l4 destination port parameters.
 	 */
-	uint8_t	push_buffer_index;
-	/* Start push from ping buffer index */
-	#define HWRM_RING_RESET_OUTPUT_PUSH_BUFFER_INDEX_PING_BUFFER UINT32_C(0x0)
-	/* Start push from pong buffer index */
-	#define HWRM_RING_RESET_OUTPUT_PUSH_BUFFER_INDEX_PONG_BUFFER UINT32_C(0x1)
-	#define HWRM_RING_RESET_OUTPUT_PUSH_BUFFER_INDEX_LAST	HWRM_RING_RESET_OUTPUT_PUSH_BUFFER_INDEX_PONG_BUFFER
+	uint16_t	tunnel_dst_port_id;
+	/* Error information */
+	uint8_t	error_info;
+	/* No error */
+	#define HWRM_TUNNEL_DST_PORT_ALLOC_OUTPUT_ERROR_INFO_SUCCESS	UINT32_C(0x0)
+	/* Tunnel port is already allocated */
+	#define HWRM_TUNNEL_DST_PORT_ALLOC_OUTPUT_ERROR_INFO_ERR_ALLOCATED   UINT32_C(0x1)
+	/* Out of resources error */
+	#define HWRM_TUNNEL_DST_PORT_ALLOC_OUTPUT_ERROR_INFO_ERR_NO_RESOURCE UINT32_C(0x2)
+	/* Tunnel type is already enabled */
+	#define HWRM_TUNNEL_DST_PORT_ALLOC_OUTPUT_ERROR_INFO_ERR_ENABLED	UINT32_C(0x3)
+	#define HWRM_TUNNEL_DST_PORT_ALLOC_OUTPUT_ERROR_INFO_LAST	HWRM_TUNNEL_DST_PORT_ALLOC_OUTPUT_ERROR_INFO_ERR_ENABLED
+	/*
+	 * This field represents the UPAR usage status.
+	 * Available UPARs on wh+ are UPAR0 and UPAR1
+	 * Available UPARs on Thor are UPAR0 to UPAR3
+	 * Available UPARs on Thor2 are UPAR0 to UPAR7
+	 */
+	uint8_t	upar_in_use;
+	/* This bit will be '1' when UPAR0 is IN_USE */
+	#define HWRM_TUNNEL_DST_PORT_ALLOC_OUTPUT_UPAR_IN_USE_UPAR0	UINT32_C(0x1)
+	/* This bit will be '1' when UPAR1 is IN_USE */
+	#define HWRM_TUNNEL_DST_PORT_ALLOC_OUTPUT_UPAR_IN_USE_UPAR1	UINT32_C(0x2)
+	/* This bit will be '1' when UPAR2 is IN_USE */
+	#define HWRM_TUNNEL_DST_PORT_ALLOC_OUTPUT_UPAR_IN_USE_UPAR2	UINT32_C(0x4)
+	/* This bit will be '1' when UPAR3 is IN_USE */
+	#define HWRM_TUNNEL_DST_PORT_ALLOC_OUTPUT_UPAR_IN_USE_UPAR3	UINT32_C(0x8)
+	/* This bit will be '1' when UPAR4 is IN_USE */
+	#define HWRM_TUNNEL_DST_PORT_ALLOC_OUTPUT_UPAR_IN_USE_UPAR4	UINT32_C(0x10)
+	/* This bit will be '1' when UPAR5 is IN_USE */
+	#define HWRM_TUNNEL_DST_PORT_ALLOC_OUTPUT_UPAR_IN_USE_UPAR5	UINT32_C(0x20)
+	/* This bit will be '1' when UPAR6 is IN_USE */
+	#define HWRM_TUNNEL_DST_PORT_ALLOC_OUTPUT_UPAR_IN_USE_UPAR6	UINT32_C(0x40)
+	/* This bit will be '1' when UPAR7 is IN_USE */
+	#define HWRM_TUNNEL_DST_PORT_ALLOC_OUTPUT_UPAR_IN_USE_UPAR7	UINT32_C(0x80)
 	uint8_t	unused_0[3];
-	/* Position of consumer index after ring reset completes. */
-	uint8_t	consumer_idx[3];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
 	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_ring_reset_output_t, *phwrm_ring_reset_output_t;
+} hwrm_tunnel_dst_port_alloc_output_t, *phwrm_tunnel_dst_port_alloc_output_t;
 
-/*****************
- * hwrm_ring_cfg *
- *****************/
+/*****************************
+ * hwrm_tunnel_dst_port_free *
+ *****************************/
 
 
-/* hwrm_ring_cfg_input (size:320b/40B) */
+/* hwrm_tunnel_dst_port_free_input (size:192b/24B) */
 
-typedef struct hwrm_ring_cfg_input {
+typedef struct hwrm_tunnel_dst_port_free_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -31191,106 +58782,72 @@ typedef struct hwrm_ring_cfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Ring Type. */
-	uint8_t	ring_type;
-	/* TX Ring (TR) */
-	#define HWRM_RING_CFG_INPUT_RING_TYPE_TX UINT32_C(0x1)
-	/* RX Ring (RR) */
-	#define HWRM_RING_CFG_INPUT_RING_TYPE_RX UINT32_C(0x2)
-	#define HWRM_RING_CFG_INPUT_RING_TYPE_LAST HWRM_RING_CFG_INPUT_RING_TYPE_RX
-	uint8_t	unused_0;
-	/* Physical number of the ring. */
-	uint16_t	ring_id;
-	/* Ring config enable bits. */
-	uint16_t	enables;
-	/*
-	 * For Rx rings, the incoming packet data can be placed at either
-	 * a 0B, 2B, 10B or 12B offset from the start of the Rx packet
-	 * buffer.
-	 * When '1', the received packet will be padded with 2B, 10B or 12B
-	 * of zeros at the front of the packet. The exact offset is specified
-	 * by rx_sop_pad_bytes parameter.
-	 * When '0', the received packet will not be padded.
-	 * Note that this flag is only used for Rx rings and is ignored
-	 * for all other rings included Rx Aggregation rings.
-	 */
-	#define HWRM_RING_CFG_INPUT_ENABLES_RX_SOP_PAD_ENABLE		UINT32_C(0x1)
-	/*
-	 * Proxy mode enable, for Tx, Rx and Rx aggregation rings only.
-	 * When rings are allocated, the PCI function on which driver issues
-	 * HWRM_RING_CFG command is assumed to own the rings. Hardware takes
-	 * the buffer descriptors (BDs) from those rings is assumed to issue
-	 * packet payload DMA using same PCI function. When proxy mode is
-	 * enabled, hardware can perform payload DMA using another PCI
-	 * function on same or different host.
-	 * When set to '0', the PCI function on which driver issues
-	 * HWRM_RING_CFG command is used for host payload DMA operation.
-	 * When set to '1', the host PCI function specified by proxy_fid is
-	 * used for host payload DMA operation.
-	 */
-	#define HWRM_RING_CFG_INPUT_ENABLES_PROXY_MODE_ENABLE		UINT32_C(0x2)
-	/*
-	 * Tx ring packet source interface override, for Tx rings only.
-	 * When TX rings are allocated, the PCI function on which driver
-	 * issues HWRM_RING_CFG is assumed to be source interface of
-	 * packets sent from TX ring.
-	 * When set to '1', the host PCI function specified by proxy_fid
-	 * is used as source interface of the transmitted packets.
-	 */
-	#define HWRM_RING_CFG_INPUT_ENABLES_TX_PROXY_SRC_INTF_OVERRIDE	UINT32_C(0x4)
-	/* The schq_id field is valid */
-	#define HWRM_RING_CFG_INPUT_ENABLES_SCHQ_ID			UINT32_C(0x8)
-	/* Update completion ring ID associated with Tx or Rx ring. */
-	#define HWRM_RING_CFG_INPUT_ENABLES_CMPL_RING_ID_UPDATE		UINT32_C(0x10)
-	/*
-	 * When set to '1', metadata value provided by tx_metadata
-	 * field in this command is inserted in the lb_header_metadata
-	 * QP context field. When set to '0', no change done to metadata.
-	 * Firmware rejects the tx ring metadata programming with
-	 * HWRM_ERR_CODE_UNSUPPORTED error if the per function CFA BD
-	 * metadata feature is not disabled.
-	 */
-	#define HWRM_RING_CFG_INPUT_ENABLES_TX_METADATA			UINT32_C(0x20)
-	/*
-	 * Proxy function FID value.
-	 * This value is only used when either proxy_mode_enable flag or
-	 * tx_proxy_svif_override is set to '1'.
-	 * When proxy_mode_enable is set to '1', it identifies a host PCI
-	 * function used for host payload DMA operations.
-	 * When tx_proxy_src_intf is set to '1', it identifies a host PCI
-	 * function as source interface for all transmitted packets from
-	 * the TX ring.
-	 */
-	uint16_t	proxy_fid;
+	/* Tunnel Type. */
+	uint8_t	tunnel_type;
+	/* Virtual eXtensible Local Area Network (VXLAN) */
+	#define HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_VXLAN		UINT32_C(0x1)
+	/* Generic Network Virtualization Encapsulation (Geneve) */
+	#define HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_GENEVE		UINT32_C(0x5)
+	/* IPV4 over virtual eXtensible Local Area Network (IPV4oVXLAN) */
+	#define HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_VXLAN_V4	UINT32_C(0x9)
 	/*
-	 * Identifies the new scheduler queue (SCHQ) to associate with the
-	 * ring. Only valid for Tx rings.
-	 * A value of zero indicates that the Tx ring should be associated
-	 * with the default scheduler queue (SCHQ).
+	 * Enhance Generic Routing Encapsulation (GRE version 1) inside IP
+	 * datagram payload
 	 */
-	uint16_t	schq_id;
+	#define HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_IPGRE_V1	UINT32_C(0xa)
+	/* Use fixed layer 2 ether type of 0xFFFF */
+	#define HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_L2_ETYPE	UINT32_C(0xb)
 	/*
-	 * This field is valid for TX or Rx rings. This value identifies the
-	 * new completion ring ID to associate with the TX or Rx ring.
+	 * IPV6 over virtual eXtensible Local Area Network with GPE header
+	 * (IPV6oVXLANGPE)
 	 */
-	uint16_t	cmpl_ring_id;
+	#define HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_VXLAN_GPE_V6	UINT32_C(0xc)
 	/*
-	 * Rx SOP padding amount in bytes.
-	 * This value is only used when rx_sop_pad_enable flag is set to '1'.
+	 * Custom GRE uses UPAR to parse customized GRE packets. This is not
+	 * supported.
 	 */
-	uint8_t	rx_sop_pad_bytes;
-	uint8_t	unused_1[3];
-	/*
-	 * When tx_metadata enable bit is set, value specified in this field
-	 * is copied to lb_header_metadata in the QP context.
+	#define HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_CUSTOM_GRE	UINT32_C(0xd)
+	/* Enhanced Common Packet Radio Interface (eCPRI) */
+	#define HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_ECPRI		UINT32_C(0xe)
+	/* IPv6 Segment Routing (SRv6) */
+	#define HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_SRV6		UINT32_C(0xf)
+	/* Generic Protocol Extension for VXLAN (VXLAN-GPE) */
+	#define HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_VXLAN_GPE	UINT32_C(0x10)
+	/* Generic Routing Encapsulation */
+	#define HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_GRE		UINT32_C(0x11)
+	/* ULP Dynamic UPAR tunnel */
+	#define HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_ULP_DYN_UPAR	UINT32_C(0x12)
+	/* ULP Dynamic UPAR tunnel reserved 1 */
+	#define HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_ULP_DYN_UPAR_RES01 UINT32_C(0x13)
+	/* ULP Dynamic UPAR tunnel reserved 2 */
+	#define HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_ULP_DYN_UPAR_RES02 UINT32_C(0x14)
+	/* ULP Dynamic UPAR tunnel reserved 3 */
+	#define HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_ULP_DYN_UPAR_RES03 UINT32_C(0x15)
+	/* ULP Dynamic UPAR tunnel reserved 4 */
+	#define HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_ULP_DYN_UPAR_RES04 UINT32_C(0x16)
+	/* ULP Dynamic UPAR tunnel reserved 5 */
+	#define HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_ULP_DYN_UPAR_RES05 UINT32_C(0x17)
+	/* ULP Dynamic UPAR tunnel reserved 6 */
+	#define HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_ULP_DYN_UPAR_RES06 UINT32_C(0x18)
+	/* ULP Dynamic UPAR tunnel reserved 7 */
+	#define HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_ULP_DYN_UPAR_RES07 UINT32_C(0x19)
+	#define HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_LAST		HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_ULP_DYN_UPAR_RES07
+	/*
+	 * This field is used to specify the next protocol value defined in the
+	 * corresponding RFC spec for the applicable tunnel type.
+	 */
+	uint8_t	tunnel_next_proto;
+	/*
+	 * Identifier of a tunnel L4 destination port value. Only applies to
+	 * tunnel types that has l4 destination port parameters.
 	 */
-	uint32_t	tx_metadata;
-	uint8_t	unused_2[4];
-} hwrm_ring_cfg_input_t, *phwrm_ring_cfg_input_t;
+	uint16_t	tunnel_dst_port_id;
+	uint8_t	unused_0[4];
+} hwrm_tunnel_dst_port_free_input_t, *phwrm_tunnel_dst_port_free_input_t;
 
-/* hwrm_ring_cfg_output (size:128b/16B) */
+/* hwrm_tunnel_dst_port_free_output (size:128b/16B) */
 
-typedef struct hwrm_ring_cfg_output {
+typedef struct hwrm_tunnel_dst_port_free_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -31299,26 +58856,181 @@ typedef struct hwrm_ring_cfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	/* Error information */
+	uint8_t	error_info;
+	/* No error */
+	#define HWRM_TUNNEL_DST_PORT_FREE_OUTPUT_ERROR_INFO_SUCCESS	UINT32_C(0x0)
+	/* Not owner error */
+	#define HWRM_TUNNEL_DST_PORT_FREE_OUTPUT_ERROR_INFO_ERR_NOT_OWNER	UINT32_C(0x1)
+	/* Not allocated error */
+	#define HWRM_TUNNEL_DST_PORT_FREE_OUTPUT_ERROR_INFO_ERR_NOT_ALLOCATED UINT32_C(0x2)
+	#define HWRM_TUNNEL_DST_PORT_FREE_OUTPUT_ERROR_INFO_LAST		HWRM_TUNNEL_DST_PORT_FREE_OUTPUT_ERROR_INFO_ERR_NOT_ALLOCATED
+	uint8_t	unused_1[6];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_tunnel_dst_port_free_output_t, *phwrm_tunnel_dst_port_free_output_t;
+
+/* Periodic statistics context DMA to host. */
+/* ctx_hw_stats (size:1280b/160B) */
+
+typedef struct ctx_hw_stats {
+	/* Number of received unicast packets */
+	uint64_t	rx_ucast_pkts;
+	/* Number of received multicast packets */
+	uint64_t	rx_mcast_pkts;
+	/* Number of received broadcast packets */
+	uint64_t	rx_bcast_pkts;
+	/* Number of discarded packets on receive path */
+	uint64_t	rx_discard_pkts;
+	/* Number of packets on receive path with error */
+	uint64_t	rx_error_pkts;
+	/* Number of received bytes for unicast traffic */
+	uint64_t	rx_ucast_bytes;
+	/* Number of received bytes for multicast traffic */
+	uint64_t	rx_mcast_bytes;
+	/* Number of received bytes for broadcast traffic */
+	uint64_t	rx_bcast_bytes;
+	/* Number of transmitted unicast packets */
+	uint64_t	tx_ucast_pkts;
+	/* Number of transmitted multicast packets */
+	uint64_t	tx_mcast_pkts;
+	/* Number of transmitted broadcast packets */
+	uint64_t	tx_bcast_pkts;
+	/* Number of packets on transmit path with error */
+	uint64_t	tx_error_pkts;
+	/* Number of discarded packets on transmit path */
+	uint64_t	tx_discard_pkts;
+	/* Number of transmitted bytes for unicast traffic */
+	uint64_t	tx_ucast_bytes;
+	/* Number of transmitted bytes for multicast traffic */
+	uint64_t	tx_mcast_bytes;
+	/* Number of transmitted bytes for broadcast traffic */
+	uint64_t	tx_bcast_bytes;
+	/* Number of TPA packets */
+	uint64_t	tpa_pkts;
+	/* Number of TPA bytes */
+	uint64_t	tpa_bytes;
+	/* Number of TPA events */
+	uint64_t	tpa_events;
+	/* Number of TPA aborts */
+	uint64_t	tpa_aborts;
+} ctx_hw_stats_t, *pctx_hw_stats_t;
+
+/*
+ * Extended periodic statistics context DMA to host. On cards that
+ * support TPA v2, additional TPA related stats exist and can be retrieved
+ * by DMA of ctx_hw_stats_ext, rather than legacy ctx_hw_stats structure.
+ */
+/* ctx_hw_stats_ext (size:1408b/176B) */
+
+typedef struct ctx_hw_stats_ext {
+	/* Number of received unicast packets */
+	uint64_t	rx_ucast_pkts;
+	/* Number of received multicast packets */
+	uint64_t	rx_mcast_pkts;
+	/* Number of received broadcast packets */
+	uint64_t	rx_bcast_pkts;
+	/* Number of discarded packets on receive path */
+	uint64_t	rx_discard_pkts;
+	/* Number of packets on receive path with error */
+	uint64_t	rx_error_pkts;
+	/* Number of received bytes for unicast traffic */
+	uint64_t	rx_ucast_bytes;
+	/* Number of received bytes for multicast traffic */
+	uint64_t	rx_mcast_bytes;
+	/* Number of received bytes for broadcast traffic */
+	uint64_t	rx_bcast_bytes;
+	/* Number of transmitted unicast packets */
+	uint64_t	tx_ucast_pkts;
+	/* Number of transmitted multicast packets */
+	uint64_t	tx_mcast_pkts;
+	/* Number of transmitted broadcast packets */
+	uint64_t	tx_bcast_pkts;
+	/* Number of packets on transmit path with error */
+	uint64_t	tx_error_pkts;
+	/* Number of discarded packets on transmit path */
+	uint64_t	tx_discard_pkts;
+	/* Number of transmitted bytes for unicast traffic */
+	uint64_t	tx_ucast_bytes;
+	/* Number of transmitted bytes for multicast traffic */
+	uint64_t	tx_mcast_bytes;
+	/* Number of transmitted bytes for broadcast traffic */
+	uint64_t	tx_bcast_bytes;
+	/* Number of TPA eligible packets */
+	uint64_t	rx_tpa_eligible_pkt;
+	/* Number of TPA eligible bytes */
+	uint64_t	rx_tpa_eligible_bytes;
+	/* Number of TPA packets */
+	uint64_t	rx_tpa_pkt;
+	/* Number of TPA bytes */
+	uint64_t	rx_tpa_bytes;
+	/* Number of TPA errors */
+	uint64_t	rx_tpa_errors;
+	/* Number of TPA events */
+	uint64_t	rx_tpa_events;
+} ctx_hw_stats_ext_t, *pctx_hw_stats_ext_t;
+
+/* Periodic Engine statistics context DMA to host. */
+/* ctx_eng_stats (size:512b/64B) */
+
+typedef struct ctx_eng_stats {
+	/*
+	 * Count of data bytes into the Engine.
+	 * This includes any user supplied prefix,
+	 * but does not include any predefined
+	 * prefix data.
+	 */
+	uint64_t	eng_bytes_in;
+	/* Count of data bytes out of the Engine. */
+	uint64_t	eng_bytes_out;
+	/*
+	 * Count, in 4-byte (dword) units, of bytes
+	 * that are input as auxiliary data.
+	 * This includes the aux_cmd data.
+	 */
+	uint64_t	aux_bytes_in;
+	/*
+	 * Count, in 4-byte (dword) units, of bytes
+	 * that are output as auxiliary data.
+	 * This count is the buffer space for aux_data
+	 * output provided in the RQE, not the actual
+	 * aux_data written
+	 */
+	uint64_t	aux_bytes_out;
+	/* Count of number of commands executed. */
+	uint64_t	commands;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * Count of number of error commands.
+	 * These are the commands with a
+	 * non-zero status value.
 	 */
-	uint8_t	valid;
-} hwrm_ring_cfg_output_t, *phwrm_ring_cfg_output_t;
+	uint64_t	error_commands;
+	/*
+	 * Compression/Encryption Engine usage,
+	 * the unit is count of clock cycles
+	 */
+	uint64_t	cce_engine_usage;
+	/*
+	 * De-Compression/De-cryption Engine usage,
+	 * the unit is count of clock cycles
+	 */
+	uint64_t	cdd_engine_usage;
+} ctx_eng_stats_t, *pctx_eng_stats_t;
 
-/******************
- * hwrm_ring_qcfg *
- ******************/
+/***********************
+ * hwrm_stat_ctx_alloc *
+ ***********************/
 
 
-/* hwrm_ring_qcfg_input (size:192b/24B) */
+/* hwrm_stat_ctx_alloc_input (size:320b/40B) */
 
-typedef struct hwrm_ring_qcfg_input {
+typedef struct hwrm_stat_ctx_alloc_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -31347,118 +59059,92 @@ typedef struct hwrm_ring_qcfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Ring Type. */
-	uint8_t	ring_type;
-	/* TX Ring (TR) */
-	#define HWRM_RING_QCFG_INPUT_RING_TYPE_TX UINT32_C(0x1)
-	/* RX Ring (RR) */
-	#define HWRM_RING_QCFG_INPUT_RING_TYPE_RX UINT32_C(0x2)
-	#define HWRM_RING_QCFG_INPUT_RING_TYPE_LAST HWRM_RING_QCFG_INPUT_RING_TYPE_RX
-	uint8_t	unused_0[5];
-	/* Physical number of the ring. */
-	uint16_t	ring_id;
-} hwrm_ring_qcfg_input_t, *phwrm_ring_qcfg_input_t;
-
-/* hwrm_ring_qcfg_output (size:256b/32B) */
-
-typedef struct hwrm_ring_qcfg_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Ring config enable bits. */
-	uint16_t	enables;
-	/*
-	 * For Rx rings, the incoming packet data can be placed at either
-	 * a 0B, 2B, 10B or 12B offset from the start of the Rx packet
-	 * buffer.
-	 * When '1', the received packet will be padded with 2B, 10B or 12B
-	 * of zeros at the front of the packet. The exact offset is specified
-	 * by rx_sop_pad_bytes parameter.
-	 * When '0', the received packet will not be padded.
-	 * Note that this flag is only used for Rx rings and is ignored
-	 * for all other rings included Rx Aggregation rings.
-	 */
-	#define HWRM_RING_QCFG_OUTPUT_ENABLES_RX_SOP_PAD_ENABLE		UINT32_C(0x1)
 	/*
-	 * Proxy mode enable, for Tx, Rx and Rx aggregation rings only.
-	 * When rings are allocated, the PCI function on which driver issues
-	 * HWRM_RING_CFG command is assumed to own the rings. Hardware takes
-	 * the buffer descriptors (BDs) from those rings is assumed to issue
-	 * packet payload DMA using same PCI function. When proxy mode is
-	 * enabled, hardware can perform payload DMA using another PCI
-	 * function on same or different host.
-	 * When set to '0', the PCI function on which driver issues
-	 * HWRM_RING_CFG command is used for host payload DMA operation.
-	 * When set to '1', the host PCI function specified by proxy_fid is
-	 * used for host payload DMA operation.
+	 * This is the address for statistic block.
+	 * > For new versions of the chip, this address should be 128B
+	 * > aligned.
 	 */
-	#define HWRM_RING_QCFG_OUTPUT_ENABLES_PROXY_MODE_ENABLE		UINT32_C(0x2)
+	uint64_t	stats_dma_addr;
 	/*
-	 * Tx ring packet source interface override, for Tx rings only.
-	 * When TX rings are allocated, the PCI function on which driver
-	 * issues HWRM_RING_CFG is assumed to be source interface of
-	 * packets sent from TX ring.
-	 * When set to '1', the host PCI function specified by proxy_fid is
-	 * used as source interface of the transmitted packets.
+	 * The statistic block update period in ms.
+	 * e.g. 250ms, 500ms, 750ms, 1000ms.
+	 * If update_period_ms is 0, then the stats update
+	 * shall be never done and the DMA address shall not be used.
+	 * In this case, the stat block can only be read by
+	 * hwrm_stat_ctx_query command.
+	 * On Ethernet/L2 based devices:
+	 *   if tpa v2 supported (hwrm_vnic_qcaps[max_aggs_supported]>0),
+	 *	ctx_hw_stats_ext is used for DMA,
+	 *   else
+	 *	ctx_hw_stats is used for DMA.
 	 */
-	#define HWRM_RING_QCFG_OUTPUT_ENABLES_TX_PROXY_SRC_INTF_OVERRIDE	UINT32_C(0x4)
+	uint32_t	update_period_ms;
 	/*
-	 * Proxy function FID value.
-	 * This value is only used when either proxy_mode_enable flag or
-	 * tx_proxy_svif_override is set to '1'.
-	 * When proxy_mode_enable is set to '1', it identifies a host PCI
-	 * function used for host payload DMA operations.
-	 * When tx_proxy_src_intf is set to '1', it identifies a host PCI
-	 * function as source interface for all transmitted packets from the TX
-	 * ring.
+	 * This field is used to specify statistics context specific
+	 * configuration flags.
 	 */
-	uint16_t	proxy_fid;
+	uint8_t	stat_ctx_flags;
 	/*
-	 * Identifies the new scheduler queue (SCHQ) to associate with the
-	 * ring. Only valid for Tx rings.
-	 * A value of zero indicates that the Tx ring should be associated with
-	 * the default scheduler queue (SCHQ).
+	 * When this bit is set to '1', the statistics context shall be
+	 * allocated for RoCE traffic only. In this case, traffic other
+	 * than offloaded RoCE traffic shall not be included in this
+	 * statistic context.
+	 * When this bit is set to '0', the statistics context shall be
+	 * used for network traffic or engine traffic.
 	 */
-	uint16_t	schq_id;
+	#define HWRM_STAT_CTX_ALLOC_INPUT_STAT_CTX_FLAGS_ROCE	UINT32_C(0x1)
+	uint8_t	unused_0;
 	/*
-	 * This field is used when ring_type is a TX or Rx ring.
-	 * This value indicates what completion ring the TX or Rx ring
-	 * is associated with.
+	 * This is the size of the structure (ctx_hw_stats or
+	 * ctx_hw_stats_ext) that the driver has allocated to be used
+	 * for the periodic DMA updates.
 	 */
-	uint16_t	cmpl_ring_id;
+	uint16_t	stats_dma_length;
+	uint16_t	flags;
+	/* This stats context uses the steering tag specified in the command. */
+	#define HWRM_STAT_CTX_ALLOC_INPUT_FLAGS_STEERING_TAG_VALID	UINT32_C(0x1)
 	/*
-	 * Rx SOP padding amount in bytes.
-	 * This value is only used when rx_sop_pad_enable flag is set to '1'.
+	 * Steering tag to use for memory transactions from the periodic DMA
+	 * updates. 'steering_tag_valid' should be set and 'steering_tag'
+	 * should be specified, when the 'steering_tag_supported' bit is set
+	 * under the 'flags_ext2' field of the hwrm_func_qcaps_output.
 	 */
-	uint8_t	rx_sop_pad_bytes;
+	uint16_t	steering_tag;
+	uint32_t	unused_1;
+} hwrm_stat_ctx_alloc_input_t, *phwrm_stat_ctx_alloc_input_t;
+
+/* hwrm_stat_ctx_alloc_output (size:128b/16B) */
+
+typedef struct hwrm_stat_ctx_alloc_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* This is the statistics context ID value. */
+	uint32_t	stat_ctx_id;
 	uint8_t	unused_0[3];
-	/* lb_header_metadata in the QP context is copied to this field. */
-	uint32_t	tx_metadata;
-	uint8_t	unused_1[7];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_ring_qcfg_output_t, *phwrm_ring_qcfg_output_t;
+} hwrm_stat_ctx_alloc_output_t, *phwrm_stat_ctx_alloc_output_t;
 
-/**************************
- * hwrm_ring_aggint_qcaps *
- **************************/
+/**********************
+ * hwrm_stat_ctx_free *
+ **********************/
 
 
-/* hwrm_ring_aggint_qcaps_input (size:128b/16B) */
+/* hwrm_stat_ctx_free_input (size:192b/24B) */
 
-typedef struct hwrm_ring_aggint_qcaps_input {
+typedef struct hwrm_stat_ctx_free_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -31487,11 +59173,14 @@ typedef struct hwrm_ring_aggint_qcaps_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-} hwrm_ring_aggint_qcaps_input_t, *phwrm_ring_aggint_qcaps_input_t;
+	/* ID of the statistics context that is being queried. */
+	uint32_t	stat_ctx_id;
+	uint8_t	unused_0[4];
+} hwrm_stat_ctx_free_input_t, *phwrm_stat_ctx_free_input_t;
 
-/* hwrm_ring_aggint_qcaps_output (size:384b/48B) */
+/* hwrm_stat_ctx_free_output (size:128b/16B) */
 
-typedef struct hwrm_ring_aggint_qcaps_output {
+typedef struct hwrm_stat_ctx_free_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -31500,107 +59189,27 @@ typedef struct hwrm_ring_aggint_qcaps_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint32_t	cmpl_params;
-	/*
-	 * When this bit is set to '1', int_lat_tmr_min can be configured
-	 * on completion rings.
-	 */
-	#define HWRM_RING_AGGINT_QCAPS_OUTPUT_CMPL_PARAMS_INT_LAT_TMR_MIN		UINT32_C(0x1)
-	/*
-	 * When this bit is set to '1', int_lat_tmr_max can be configured
-	 * on completion rings.
-	 */
-	#define HWRM_RING_AGGINT_QCAPS_OUTPUT_CMPL_PARAMS_INT_LAT_TMR_MAX		UINT32_C(0x2)
-	/*
-	 * When this bit is set to '1', timer_reset can be enabled
-	 * on completion rings.
-	 */
-	#define HWRM_RING_AGGINT_QCAPS_OUTPUT_CMPL_PARAMS_TIMER_RESET			UINT32_C(0x4)
-	/*
-	 * When this bit is set to '1', ring_idle can be enabled
-	 * on completion rings.
-	 */
-	#define HWRM_RING_AGGINT_QCAPS_OUTPUT_CMPL_PARAMS_RING_IDLE			UINT32_C(0x8)
-	/*
-	 * When this bit is set to '1', num_cmpl_dma_aggr can be configured
-	 * on completion rings.
-	 */
-	#define HWRM_RING_AGGINT_QCAPS_OUTPUT_CMPL_PARAMS_NUM_CMPL_DMA_AGGR		UINT32_C(0x10)
-	/*
-	 * When this bit is set to '1', num_cmpl_dma_aggr_during_int can be configured
-	 * on completion rings.
-	 */
-	#define HWRM_RING_AGGINT_QCAPS_OUTPUT_CMPL_PARAMS_NUM_CMPL_DMA_AGGR_DURING_INT	UINT32_C(0x20)
-	/*
-	 * When this bit is set to '1', cmpl_aggr_dma_tmr can be configured
-	 * on completion rings.
-	 */
-	#define HWRM_RING_AGGINT_QCAPS_OUTPUT_CMPL_PARAMS_CMPL_AGGR_DMA_TMR		UINT32_C(0x40)
-	/*
-	 * When this bit is set to '1', cmpl_aggr_dma_tmr_during_int can be configured
-	 * on completion rings.
-	 */
-	#define HWRM_RING_AGGINT_QCAPS_OUTPUT_CMPL_PARAMS_CMPL_AGGR_DMA_TMR_DURING_INT	UINT32_C(0x80)
-	/*
-	 * When this bit is set to '1', num_cmpl_aggr_int can be configured
-	 * on completion rings.
-	 */
-	#define HWRM_RING_AGGINT_QCAPS_OUTPUT_CMPL_PARAMS_NUM_CMPL_AGGR_INT		UINT32_C(0x100)
-	uint32_t	nq_params;
-	/*
-	 * When this bit is set to '1', int_lat_tmr_min can be configured
-	 * on notification queues.
-	 */
-	#define HWRM_RING_AGGINT_QCAPS_OUTPUT_NQ_PARAMS_INT_LAT_TMR_MIN	UINT32_C(0x1)
-	/* Minimum value for num_cmpl_dma_aggr */
-	uint16_t	num_cmpl_dma_aggr_min;
-	/* Maximum value for num_cmpl_dma_aggr */
-	uint16_t	num_cmpl_dma_aggr_max;
-	/* Minimum value for num_cmpl_dma_aggr_during_int */
-	uint16_t	num_cmpl_dma_aggr_during_int_min;
-	/* Maximum value for num_cmpl_dma_aggr_during_int */
-	uint16_t	num_cmpl_dma_aggr_during_int_max;
-	/* Minimum value for cmpl_aggr_dma_tmr */
-	uint16_t	cmpl_aggr_dma_tmr_min;
-	/* Maximum value for cmpl_aggr_dma_tmr */
-	uint16_t	cmpl_aggr_dma_tmr_max;
-	/* Minimum value for cmpl_aggr_dma_tmr_during_int */
-	uint16_t	cmpl_aggr_dma_tmr_during_int_min;
-	/* Maximum value for cmpl_aggr_dma_tmr_during_int */
-	uint16_t	cmpl_aggr_dma_tmr_during_int_max;
-	/* Minimum value for int_lat_tmr_min */
-	uint16_t	int_lat_tmr_min_min;
-	/* Maximum value for int_lat_tmr_min */
-	uint16_t	int_lat_tmr_min_max;
-	/* Minimum value for int_lat_tmr_max */
-	uint16_t	int_lat_tmr_max_min;
-	/* Maximum value for int_lat_tmr_max */
-	uint16_t	int_lat_tmr_max_max;
-	/* Minimum value for num_cmpl_aggr_int */
-	uint16_t	num_cmpl_aggr_int_min;
-	/* Maximum value for num_cmpl_aggr_int */
-	uint16_t	num_cmpl_aggr_int_max;
-	/* The units for timer parameters, in nanoseconds. */
-	uint16_t	timer_units;
-	uint8_t	unused_0[1];
+	/* This is the statistics context ID value. */
+	uint32_t	stat_ctx_id;
+	uint8_t	unused_0[3];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
 	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_ring_aggint_qcaps_output_t, *phwrm_ring_aggint_qcaps_output_t;
+} hwrm_stat_ctx_free_output_t, *phwrm_stat_ctx_free_output_t;
 
-/**************************************
- * hwrm_ring_cmpl_ring_qaggint_params *
- **************************************/
+/***********************
+ * hwrm_stat_ctx_query *
+ ***********************/
 
 
-/* hwrm_ring_cmpl_ring_qaggint_params_input (size:192b/24B) */
+/* hwrm_stat_ctx_query_input (size:192b/24B) */
 
-typedef struct hwrm_ring_cmpl_ring_qaggint_params_input {
+typedef struct hwrm_stat_ctx_query_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -31629,23 +59238,21 @@ typedef struct hwrm_ring_cmpl_ring_qaggint_params_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Physical number of completion ring. */
-	uint16_t	ring_id;
-	uint16_t	flags;
-	#define HWRM_RING_CMPL_RING_QAGGINT_PARAMS_INPUT_FLAGS_UNUSED_0_MASK UINT32_C(0x3)
-	#define HWRM_RING_CMPL_RING_QAGGINT_PARAMS_INPUT_FLAGS_UNUSED_0_SFT 0
+	/* ID of the statistics context that is being queried. */
+	uint32_t	stat_ctx_id;
+	uint8_t	flags;
 	/*
-	 * Set this flag to 1 when querying parameters on a notification
-	 * queue. Set this flag to 0 when querying parameters on a
-	 * completion queue or completion ring.
+	 * This bit is set to 1 when request is for a counter mask,
+	 * representing the width of each of the stats counters, rather
+	 * than counters themselves.
 	 */
-	#define HWRM_RING_CMPL_RING_QAGGINT_PARAMS_INPUT_FLAGS_IS_NQ	UINT32_C(0x4)
-	uint8_t	unused_0[4];
-} hwrm_ring_cmpl_ring_qaggint_params_input_t, *phwrm_ring_cmpl_ring_qaggint_params_input_t;
+	#define HWRM_STAT_CTX_QUERY_INPUT_FLAGS_COUNTER_MASK	UINT32_C(0x1)
+	uint8_t	unused_0[3];
+} hwrm_stat_ctx_query_input_t, *phwrm_stat_ctx_query_input_t;
 
-/* hwrm_ring_cmpl_ring_qaggint_params_output (size:256b/32B) */
+/* hwrm_stat_ctx_query_output (size:1408b/176B) */
 
-typedef struct hwrm_ring_cmpl_ring_qaggint_params_output {
+typedef struct hwrm_stat_ctx_query_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -31654,69 +59261,65 @@ typedef struct hwrm_ring_cmpl_ring_qaggint_params_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint16_t	flags;
-	/*
-	 * When this bit is set to '1', interrupt max
-	 * timer is reset whenever a completion is received.
-	 */
-	#define HWRM_RING_CMPL_RING_QAGGINT_PARAMS_OUTPUT_FLAGS_TIMER_RESET	UINT32_C(0x1)
-	/*
-	 * When this bit is set to '1', ring idle mode
-	 * aggregation will be enabled.
-	 */
-	#define HWRM_RING_CMPL_RING_QAGGINT_PARAMS_OUTPUT_FLAGS_RING_IDLE	UINT32_C(0x2)
-	/*
-	 * Number of completions to aggregate before DMA
-	 * during the normal mode.
-	 */
-	uint16_t	num_cmpl_dma_aggr;
-	/*
-	 * Number of completions to aggregate before DMA
-	 * during the interrupt mode.
-	 */
-	uint16_t	num_cmpl_dma_aggr_during_int;
-	/*
-	 * Timer used to aggregate completions before
-	 * DMA during the normal mode (not in interrupt mode).
-	 */
-	uint16_t	cmpl_aggr_dma_tmr;
-	/*
-	 * Timer used to aggregate completions before
-	 * DMA when in interrupt mode.
-	 */
-	uint16_t	cmpl_aggr_dma_tmr_during_int;
-	/* Minimum time between two interrupts. */
-	uint16_t	int_lat_tmr_min;
-	/*
-	 * Maximum wait time spent aggregating
-	 * completions before signaling the interrupt after the
-	 * interrupt is enabled.
-	 */
-	uint16_t	int_lat_tmr_max;
-	/*
-	 * Minimum number of completions aggregated before signaling
-	 * an interrupt.
-	 */
-	uint16_t	num_cmpl_aggr_int;
+	/* Number of transmitted unicast packets */
+	uint64_t	tx_ucast_pkts;
+	/* Number of transmitted multicast packets */
+	uint64_t	tx_mcast_pkts;
+	/* Number of transmitted broadcast packets */
+	uint64_t	tx_bcast_pkts;
+	/* Number of packets discarded in transmit path */
+	uint64_t	tx_discard_pkts;
+	/* Number of packets in transmit path with error */
+	uint64_t	tx_error_pkts;
+	/* Number of transmitted bytes for unicast traffic */
+	uint64_t	tx_ucast_bytes;
+	/* Number of transmitted bytes for multicast traffic */
+	uint64_t	tx_mcast_bytes;
+	/* Number of transmitted bytes for broadcast traffic */
+	uint64_t	tx_bcast_bytes;
+	/* Number of received unicast packets */
+	uint64_t	rx_ucast_pkts;
+	/* Number of received multicast packets */
+	uint64_t	rx_mcast_pkts;
+	/* Number of received broadcast packets */
+	uint64_t	rx_bcast_pkts;
+	/* Number of packets discarded in receive path */
+	uint64_t	rx_discard_pkts;
+	/* Number of packets in receive path with errors */
+	uint64_t	rx_error_pkts;
+	/* Number of received bytes for unicast traffic */
+	uint64_t	rx_ucast_bytes;
+	/* Number of received bytes for multicast traffic */
+	uint64_t	rx_mcast_bytes;
+	/* Number of received bytes for broadcast traffic */
+	uint64_t	rx_bcast_bytes;
+	/* Number of aggregated unicast packets */
+	uint64_t	rx_agg_pkts;
+	/* Number of aggregated unicast bytes */
+	uint64_t	rx_agg_bytes;
+	/* Number of aggregation events */
+	uint64_t	rx_agg_events;
+	/* Number of aborted aggregations */
+	uint64_t	rx_agg_aborts;
 	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
 	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_ring_cmpl_ring_qaggint_params_output_t, *phwrm_ring_cmpl_ring_qaggint_params_output_t;
+} hwrm_stat_ctx_query_output_t, *phwrm_stat_ctx_query_output_t;
 
-/*****************************************
- * hwrm_ring_cmpl_ring_cfg_aggint_params *
- *****************************************/
+/***************************
+ * hwrm_stat_ext_ctx_query *
+ ***************************/
 
 
-/* hwrm_ring_cmpl_ring_cfg_aggint_params_input (size:320b/40B) */
+/* hwrm_stat_ext_ctx_query_input (size:192b/24B) */
 
-typedef struct hwrm_ring_cmpl_ring_cfg_aggint_params_input {
+typedef struct hwrm_stat_ext_ctx_query_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -31745,101 +59348,21 @@ typedef struct hwrm_ring_cmpl_ring_cfg_aggint_params_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Physical number of completion ring. */
-	uint16_t	ring_id;
-	uint16_t	flags;
-	/*
-	 * When this bit is set to '1', interrupt latency max
-	 * timer is reset whenever a completion is received.
-	 */
-	#define HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_FLAGS_TIMER_RESET	UINT32_C(0x1)
-	/*
-	 * When this bit is set to '1', ring idle mode
-	 * aggregation will be enabled.
-	 */
-	#define HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_FLAGS_RING_IDLE	UINT32_C(0x2)
-	/*
-	 * Set this flag to 1 when configuring parameters on a
-	 * notification queue. Set this flag to 0 when configuring
-	 * parameters on a completion queue or completion ring.
-	 */
-	#define HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_FLAGS_IS_NQ	UINT32_C(0x4)
-	/*
-	 * Number of completions to aggregate before DMA
-	 * during the normal mode.
-	 */
-	uint16_t	num_cmpl_dma_aggr;
-	/*
-	 * Number of completions to aggregate before DMA
-	 * during the interrupt mode.
-	 */
-	uint16_t	num_cmpl_dma_aggr_during_int;
-	/*
-	 * Timer used to aggregate completions before
-	 * DMA during the normal mode (not in interrupt mode).
-	 */
-	uint16_t	cmpl_aggr_dma_tmr;
-	/*
-	 * Timer used to aggregate completions before
-	 * DMA while in interrupt mode.
-	 */
-	uint16_t	cmpl_aggr_dma_tmr_during_int;
-	/* Minimum time between two interrupts. */
-	uint16_t	int_lat_tmr_min;
-	/*
-	 * Maximum wait time spent aggregating
-	 * completions before signaling the interrupt after the
-	 * interrupt is enabled.
-	 */
-	uint16_t	int_lat_tmr_max;
-	/*
-	 * Minimum number of completions aggregated before signaling
-	 * an interrupt.
-	 */
-	uint16_t	num_cmpl_aggr_int;
-	/*
-	 * Bitfield that indicates which parameters are to be applied. Only
-	 * required when configuring devices with notification queues, and
-	 * used in that case to set certain parameters on completion queues
-	 * and others on notification queues.
-	 */
-	uint16_t	enables;
-	/*
-	 * This bit must be '1' for the num_cmpl_dma_aggr field to be
-	 * configured.
-	 */
-	#define HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_ENABLES_NUM_CMPL_DMA_AGGR		UINT32_C(0x1)
-	/*
-	 * This bit must be '1' for the num_cmpl_dma_aggr_during_int field to be
-	 * configured.
-	 */
-	#define HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_ENABLES_NUM_CMPL_DMA_AGGR_DURING_INT	UINT32_C(0x2)
-	/*
-	 * This bit must be '1' for the cmpl_aggr_dma_tmr field to be
-	 * configured.
-	 */
-	#define HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_ENABLES_CMPL_AGGR_DMA_TMR		UINT32_C(0x4)
-	/*
-	 * This bit must be '1' for the int_lat_tmr_min field to be
-	 * configured.
-	 */
-	#define HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_ENABLES_INT_LAT_TMR_MIN		UINT32_C(0x8)
-	/*
-	 * This bit must be '1' for the int_lat_tmr_max field to be
-	 * configured.
-	 */
-	#define HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_ENABLES_INT_LAT_TMR_MAX		UINT32_C(0x10)
+	/* ID of the extended statistics context that is being queried. */
+	uint32_t	stat_ctx_id;
+	uint8_t	flags;
 	/*
-	 * This bit must be '1' for the num_cmpl_aggr_int field to be
-	 * configured.
+	 * This bit is set to 1 when request is for a counter mask,
+	 * representing the width of each of the stats counters, rather
+	 * than counters themselves.
 	 */
-	#define HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_ENABLES_NUM_CMPL_AGGR_INT		UINT32_C(0x20)
-	uint8_t	unused_0[4];
-} hwrm_ring_cmpl_ring_cfg_aggint_params_input_t, *phwrm_ring_cmpl_ring_cfg_aggint_params_input_t;
+	#define HWRM_STAT_EXT_CTX_QUERY_INPUT_FLAGS_COUNTER_MASK	UINT32_C(0x1)
+	uint8_t	unused_0[3];
+} hwrm_stat_ext_ctx_query_input_t, *phwrm_stat_ext_ctx_query_input_t;
 
-/* hwrm_ring_cmpl_ring_cfg_aggint_params_output (size:128b/16B) */
+/* hwrm_stat_ext_ctx_query_output (size:1536b/192B) */
 
-typedef struct hwrm_ring_cmpl_ring_cfg_aggint_params_output {
+typedef struct hwrm_stat_ext_ctx_query_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -31848,25 +59371,69 @@ typedef struct hwrm_ring_cmpl_ring_cfg_aggint_params_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
+	/* Number of received unicast packets */
+	uint64_t	rx_ucast_pkts;
+	/* Number of received multicast packets */
+	uint64_t	rx_mcast_pkts;
+	/* Number of received broadcast packets */
+	uint64_t	rx_bcast_pkts;
+	/* Number of discarded packets on receive path */
+	uint64_t	rx_discard_pkts;
+	/* Number of packets on receive path with error */
+	uint64_t	rx_error_pkts;
+	/* Number of received bytes for unicast traffic */
+	uint64_t	rx_ucast_bytes;
+	/* Number of received bytes for multicast traffic */
+	uint64_t	rx_mcast_bytes;
+	/* Number of received bytes for broadcast traffic */
+	uint64_t	rx_bcast_bytes;
+	/* Number of transmitted unicast packets */
+	uint64_t	tx_ucast_pkts;
+	/* Number of transmitted multicast packets */
+	uint64_t	tx_mcast_pkts;
+	/* Number of transmitted broadcast packets */
+	uint64_t	tx_bcast_pkts;
+	/* Number of packets on transmit path with error */
+	uint64_t	tx_error_pkts;
+	/* Number of discarded packets on transmit path */
+	uint64_t	tx_discard_pkts;
+	/* Number of transmitted bytes for unicast traffic */
+	uint64_t	tx_ucast_bytes;
+	/* Number of transmitted bytes for multicast traffic */
+	uint64_t	tx_mcast_bytes;
+	/* Number of transmitted bytes for broadcast traffic */
+	uint64_t	tx_bcast_bytes;
+	/* Number of TPA eligible packets */
+	uint64_t	rx_tpa_eligible_pkt;
+	/* Number of TPA eligible bytes */
+	uint64_t	rx_tpa_eligible_bytes;
+	/* Number of TPA packets */
+	uint64_t	rx_tpa_pkt;
+	/* Number of TPA bytes */
+	uint64_t	rx_tpa_bytes;
+	/* Number of TPA errors */
+	uint64_t	rx_tpa_errors;
+	/* Number of TPA events */
+	uint64_t	rx_tpa_events;
 	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
 	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_ring_cmpl_ring_cfg_aggint_params_output_t, *phwrm_ring_cmpl_ring_cfg_aggint_params_output_t;
+} hwrm_stat_ext_ctx_query_output_t, *phwrm_stat_ext_ctx_query_output_t;
 
-/***********************
- * hwrm_ring_grp_alloc *
- ***********************/
+/***************************
+ * hwrm_stat_ctx_eng_query *
+ ***************************/
 
 
-/* hwrm_ring_grp_alloc_input (size:192b/24B) */
+/* hwrm_stat_ctx_eng_query_input (size:192b/24B) */
 
-typedef struct hwrm_ring_grp_alloc_input {
+typedef struct hwrm_stat_ctx_eng_query_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -31895,32 +59462,14 @@ typedef struct hwrm_ring_grp_alloc_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/*
-	 * This value identifies the CR associated with the ring
-	 * group.
-	 */
-	uint16_t	cr;
-	/*
-	 * This value identifies the main RR associated with the ring
-	 * group.
-	 */
-	uint16_t	rr;
-	/*
-	 * This value identifies the aggregation RR associated with
-	 * the ring group.  If this value is 0xFF... (All Fs), then no
-	 * Aggregation ring will be set.
-	 */
-	uint16_t	ar;
-	/*
-	 * This value identifies the statistics context associated
-	 * with the ring group.
-	 */
-	uint16_t	sc;
-} hwrm_ring_grp_alloc_input_t, *phwrm_ring_grp_alloc_input_t;
+	/* ID of the statistics context that is being queried. */
+	uint32_t	stat_ctx_id;
+	uint8_t	unused_0[4];
+} hwrm_stat_ctx_eng_query_input_t, *phwrm_stat_ctx_eng_query_input_t;
 
-/* hwrm_ring_grp_alloc_output (size:128b/16B) */
+/* hwrm_stat_ctx_eng_query_output (size:640b/80B) */
 
-typedef struct hwrm_ring_grp_alloc_output {
+typedef struct hwrm_stat_ctx_eng_query_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -31930,30 +59479,65 @@ typedef struct hwrm_ring_grp_alloc_output {
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
 	/*
-	 * This is the ring group ID value.  Use this value to program
-	 * the default ring group for the VNIC or as table entries
-	 * in an RSS/COS context.
+	 * Count of data bytes into the Engine.
+	 * This includes any user supplied prefix,
+	 * but does not include any predefined
+	 * prefix data.
 	 */
-	uint32_t	ring_group_id;
-	uint8_t	unused_0[3];
+	uint64_t	eng_bytes_in;
+	/* Count of data bytes out of the Engine. */
+	uint64_t	eng_bytes_out;
+	/*
+	 * Count, in 4-byte (dword) units, of bytes
+	 * that are input as auxiliary data.
+	 * This includes the aux_cmd data.
+	 */
+	uint64_t	aux_bytes_in;
+	/*
+	 * Count, in 4-byte (dword) units, of bytes
+	 * that are output as auxiliary data.
+	 * This count is the buffer space for aux_data
+	 * output provided in the RQE, not the actual
+	 * aux_data written
+	 */
+	uint64_t	aux_bytes_out;
+	/* Count of number of commands executed. */
+	uint64_t	commands;
+	/*
+	 * Count of number of error commands.
+	 * These are the commands with a
+	 * non-zero status value.
+	 */
+	uint64_t	error_commands;
+	/*
+	 * Compression/Encryption Engine usage,
+	 * the unit is count of clock cycles
+	 */
+	uint64_t	cce_engine_usage;
+	/*
+	 * De-Compression/De-cryption Engine usage,
+	 * the unit is count of clock cycles
+	 */
+	uint64_t	cdd_engine_usage;
+	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
 	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_ring_grp_alloc_output_t, *phwrm_ring_grp_alloc_output_t;
+} hwrm_stat_ctx_eng_query_output_t, *phwrm_stat_ctx_eng_query_output_t;
 
-/**********************
- * hwrm_ring_grp_free *
- **********************/
+/***************************
+ * hwrm_stat_ctx_clr_stats *
+ ***************************/
 
 
-/* hwrm_ring_grp_free_input (size:192b/24B) */
+/* hwrm_stat_ctx_clr_stats_input (size:192b/24B) */
 
-typedef struct hwrm_ring_grp_free_input {
+typedef struct hwrm_stat_ctx_clr_stats_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -31982,14 +59566,14 @@ typedef struct hwrm_ring_grp_free_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* This is the ring group ID value. */
-	uint32_t	ring_group_id;
+	/* ID of the statistics context that is being queried. */
+	uint32_t	stat_ctx_id;
 	uint8_t	unused_0[4];
-} hwrm_ring_grp_free_input_t, *phwrm_ring_grp_free_input_t;
+} hwrm_stat_ctx_clr_stats_input_t, *phwrm_stat_ctx_clr_stats_input_t;
 
-/* hwrm_ring_grp_free_output (size:128b/16B) */
+/* hwrm_stat_ctx_clr_stats_output (size:128b/16B) */
 
-typedef struct hwrm_ring_grp_free_output {
+typedef struct hwrm_stat_ctx_clr_stats_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -32001,22 +59585,22 @@ typedef struct hwrm_ring_grp_free_output {
 	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
 	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_ring_grp_free_output_t, *phwrm_ring_grp_free_output_t;
+} hwrm_stat_ctx_clr_stats_output_t, *phwrm_stat_ctx_clr_stats_output_t;
 
-/************************
- * hwrm_ring_schq_alloc *
- ************************/
+/********************
+ * hwrm_pcie_qstats *
+ ********************/
 
 
-/* hwrm_ring_schq_alloc_input (size:1088b/136B) */
+/* hwrm_pcie_qstats_input (size:256b/32B) */
 
-typedef struct hwrm_ring_schq_alloc_input {
+typedef struct hwrm_pcie_qstats_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -32045,417 +59629,309 @@ typedef struct hwrm_ring_schq_alloc_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	enables;
 	/*
-	 * This bit must be '1' for the tqm_ring0 fields to be
-	 * configured.
+	 * The size of PCIe statistics block in bytes.
+	 * Firmware will DMA the PCIe statistics to
+	 * the host with this field size in the response.
 	 */
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_ENABLES_TQM_RING0	UINT32_C(0x1)
+	uint16_t	pcie_stat_size;
+	uint8_t	unused_0[6];
 	/*
-	 * This bit must be '1' for the tqm_ring1 fields to be
-	 * configured.
+	 * This is the host address where
+	 * PCIe statistics will be stored
 	 */
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_ENABLES_TQM_RING1	UINT32_C(0x2)
+	uint64_t	pcie_stat_host_addr;
+} hwrm_pcie_qstats_input_t, *phwrm_pcie_qstats_input_t;
+
+/* hwrm_pcie_qstats_output (size:128b/16B) */
+
+typedef struct hwrm_pcie_qstats_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* The size of PCIe statistics block in bytes. */
+	uint16_t	pcie_stat_size;
+	uint8_t	unused_0[5];
 	/*
-	 * This bit must be '1' for the tqm_ring2 fields to be
-	 * configured.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_ENABLES_TQM_RING2	UINT32_C(0x4)
+	uint8_t	valid;
+} hwrm_pcie_qstats_output_t, *phwrm_pcie_qstats_output_t;
+
+/* PCIe Statistics Formats */
+/* pcie_ctx_hw_stats (size:768b/96B) */
+
+typedef struct pcie_ctx_hw_stats {
+	/* Number of physical layer receiver errors */
+	uint64_t	pcie_pl_signal_integrity;
+	/* Number of DLLP CRC errors detected by Data Link Layer */
+	uint64_t	pcie_dl_signal_integrity;
 	/*
-	 * This bit must be '1' for the tqm_ring3 fields to be
-	 * configured.
+	 * Number of TLP LCRC and sequence number errors detected
+	 * by Data Link Layer
 	 */
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_ENABLES_TQM_RING3	UINT32_C(0x8)
+	uint64_t	pcie_tl_signal_integrity;
+	/* Number of times LTSSM entered Recovery state */
+	uint64_t	pcie_link_integrity;
+	/* Report number of TLP bits that have been transmitted in Mbps */
+	uint64_t	pcie_tx_traffic_rate;
+	/* Report number of TLP bits that have been received in Mbps */
+	uint64_t	pcie_rx_traffic_rate;
+	/* Number of DLLP bytes that have been transmitted */
+	uint64_t	pcie_tx_dllp_statistics;
+	/* Number of DLLP bytes that have been received */
+	uint64_t	pcie_rx_dllp_statistics;
 	/*
-	 * This bit must be '1' for the tqm_ring4 fields to be
-	 * configured.
+	 * Number of times spent in each phase of gen3
+	 * equalization
 	 */
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_ENABLES_TQM_RING4	UINT32_C(0x10)
+	uint64_t	pcie_equalization_time;
+	/* Records the last 16 transitions of the LTSSM */
+	uint32_t	pcie_ltssm_histogram[4];
 	/*
-	 * This bit must be '1' for the tqm_ring5 fields to be
-	 * configured.
+	 * Record the last 8 reasons on why LTSSM transitioned
+	 * to Recovery
 	 */
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_ENABLES_TQM_RING5	UINT32_C(0x20)
+	uint64_t	pcie_recovery_histogram;
+} pcie_ctx_hw_stats_t, *ppcie_ctx_hw_stats_t;
+
+/****************************
+ * hwrm_stat_generic_qstats *
+ ****************************/
+
+
+/* hwrm_stat_generic_qstats_input (size:256b/32B) */
+
+typedef struct hwrm_stat_generic_qstats_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * This bit must be '1' for the tqm_ring6 fields to be
-	 * configured.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_ENABLES_TQM_RING6	UINT32_C(0x40)
+	uint16_t	cmpl_ring;
 	/*
-	 * This bit must be '1' for the tqm_ring7 fields to be
-	 * configured.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_ENABLES_TQM_RING7	UINT32_C(0x80)
-	/* Reserved for future use. */
-	uint32_t	reserved;
-	/* TQM ring 0 page size and level. */
-	uint8_t	tqm_ring0_pg_size_tqm_ring0_lvl;
-	/* TQM ring 0 PBL indirect levels. */
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING0_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING0_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING0_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING0_LVL_LVL_1	UINT32_C(0x1)
+	uint16_t	seq_id;
 	/*
-	 * PBL pointer points to PDE table with each entry pointing to PTE
-	 * tables.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING0_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING0_LVL_LAST	HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING0_LVL_LVL_2
-	/* TQM ring 0 page size. */
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING0_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING0_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING0_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING0_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING0_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING0_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING0_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING0_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING0_PG_SIZE_LAST   HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING0_PG_SIZE_PG_1G
-	/* TQM ring 1 page size and level. */
-	uint8_t	tqm_ring1_pg_size_tqm_ring1_lvl;
-	/* TQM ring 1 PBL indirect levels. */
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING1_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING1_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING1_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING1_LVL_LVL_1	UINT32_C(0x1)
+	uint16_t	target_id;
 	/*
-	 * PBL pointer points to PDE table with each entry pointing to PTE
-	 * tables.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING1_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING1_LVL_LAST	HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING1_LVL_LVL_2
-	/* TQM ring 1 page size. */
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING1_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING1_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING1_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING1_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING1_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING1_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING1_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING1_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING1_PG_SIZE_LAST   HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING1_PG_SIZE_PG_1G
-	/* TQM ring 2 page size and level. */
-	uint8_t	tqm_ring2_pg_size_tqm_ring2_lvl;
-	/* TQM ring 2 PBL indirect levels. */
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING2_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING2_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING2_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING2_LVL_LVL_1	UINT32_C(0x1)
+	uint64_t	resp_addr;
 	/*
-	 * PBL pointer points to PDE table with each entry pointing to PTE
-	 * tables.
+	 * The size of the generic statistics buffer passed in the
+	 * generic_stat_host_addr in bytes.
+	 * Firmware will not exceed this size when it DMAs the
+	 * statistics structure to the host. The actual DMA size
+	 * will be returned in the response.
 	 */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING2_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING2_LVL_LAST	HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING2_LVL_LVL_2
-	/* TQM ring 2 page size. */
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING2_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING2_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING2_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING2_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING2_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING2_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING2_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING2_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING2_PG_SIZE_LAST   HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING2_PG_SIZE_PG_1G
-	/* TQM ring 3 page size and level. */
-	uint8_t	tqm_ring3_pg_size_tqm_ring3_lvl;
-	/* TQM ring 3 PBL indirect levels. */
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING3_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING3_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING3_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING3_LVL_LVL_1	UINT32_C(0x1)
+	uint16_t	generic_stat_size;
+	uint8_t	flags;
 	/*
-	 * PBL pointer points to PDE table with each entry pointing to PTE
-	 * tables.
+	 * The bit should be set to 1 when request is for the counter mask
+	 * representing the width of each of the stats counters, rather
+	 * than counters themselves.
 	 */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING3_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING3_LVL_LAST	HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING3_LVL_LVL_2
-	/* TQM ring 3 page size. */
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING3_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING3_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING3_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING3_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING3_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING3_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING3_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING3_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING3_PG_SIZE_LAST   HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING3_PG_SIZE_PG_1G
-	/* TQM ring 4 page size and level. */
-	uint8_t	tqm_ring4_pg_size_tqm_ring4_lvl;
-	/* TQM ring 4 PBL indirect levels. */
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING4_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING4_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING4_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING4_LVL_LVL_1	UINT32_C(0x1)
+	#define HWRM_STAT_GENERIC_QSTATS_INPUT_FLAGS_COUNTER_MASK	UINT32_C(0x1)
+	uint8_t	unused_0[5];
 	/*
-	 * PBL pointer points to PDE table with each entry pointing to PTE
-	 * tables.
+	 * This is the host address where
+	 * generic statistics will be stored
 	 */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING4_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING4_LVL_LAST	HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING4_LVL_LVL_2
-	/* TQM ring 4 page size. */
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING4_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING4_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING4_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING4_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING4_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING4_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING4_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING4_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING4_PG_SIZE_LAST   HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING4_PG_SIZE_PG_1G
-	/* TQM ring 5 page size and level. */
-	uint8_t	tqm_ring5_pg_size_tqm_ring5_lvl;
-	/* TQM ring 5 PBL indirect levels. */
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING5_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING5_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING5_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING5_LVL_LVL_1	UINT32_C(0x1)
+	uint64_t	generic_stat_host_addr;
+} hwrm_stat_generic_qstats_input_t, *phwrm_stat_generic_qstats_input_t;
+
+/* hwrm_stat_generic_qstats_output (size:128b/16B) */
+
+typedef struct hwrm_stat_generic_qstats_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* The size of Generic Statistics block in bytes. */
+	uint16_t	generic_stat_size;
+	uint8_t	unused_0[5];
 	/*
-	 * PBL pointer points to PDE table with each entry pointing to PTE
-	 * tables.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING5_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING5_LVL_LAST	HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING5_LVL_LVL_2
-	/* TQM ring 5 page size. */
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING5_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING5_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING5_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING5_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING5_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING5_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING5_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING5_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING5_PG_SIZE_LAST   HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING5_PG_SIZE_PG_1G
-	/* TQM ring 6 page size and level. */
-	uint8_t	tqm_ring6_pg_size_tqm_ring6_lvl;
-	/* TQM ring 6 PBL indirect levels. */
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING6_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING6_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING6_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING6_LVL_LVL_1	UINT32_C(0x1)
+	uint8_t	valid;
+} hwrm_stat_generic_qstats_output_t, *phwrm_stat_generic_qstats_output_t;
+
+/* Generic Statistic Format */
+/* generic_sw_hw_stats (size:1472b/184B) */
+
+typedef struct generic_sw_hw_stats {
+	/*
+	 * This is the number of TLP bytes that have been transmitted for
+	 * the caller PF.
+	 */
+	uint64_t	pcie_statistics_tx_tlp;
+	/*
+	 * This is the number of TLP bytes that have been received
+	 * for the caller PF.
+	 */
+	uint64_t	pcie_statistics_rx_tlp;
+	/* Posted Header Flow Control credits available for the caller PF. */
+	uint64_t	pcie_credit_fc_hdr_posted;
+	/* Non-posted Header Flow Control credits available for the caller PF. */
+	uint64_t	pcie_credit_fc_hdr_nonposted;
+	/* Completion Header Flow Control credits available for the caller PF. */
+	uint64_t	pcie_credit_fc_hdr_cmpl;
+	/* Posted Data Flow Control credits available for the caller PF. */
+	uint64_t	pcie_credit_fc_data_posted;
+	/* Non-Posted Data Flow Control credits available for the caller PF. */
+	uint64_t	pcie_credit_fc_data_nonposted;
+	/* Completion Data Flow Control credits available for the caller PF. */
+	uint64_t	pcie_credit_fc_data_cmpl;
+	/*
+	 * Available Non-posted credit for target flow control reads or
+	 * config for the caller PF.
+	 */
+	uint64_t	pcie_credit_fc_tgt_nonposted;
+	/*
+	 * Available posted data credit for target flow control writes
+	 * for the caller PF.
+	 */
+	uint64_t	pcie_credit_fc_tgt_data_posted;
+	/*
+	 * Available posted header credit for target flow control writes
+	 * for the caller PF.
+	 */
+	uint64_t	pcie_credit_fc_tgt_hdr_posted;
+	/* Available completion flow control header credits for the caller PF. */
+	uint64_t	pcie_credit_fc_cmpl_hdr_posted;
+	/* Available completion flow control data credits. */
+	uint64_t	pcie_credit_fc_cmpl_data_posted;
 	/*
-	 * PBL pointer points to PDE table with each entry pointing to PTE
-	 * tables.
+	 * Displays Time information of the longest completion time from any of
+	 * the 4 tags for the caller PF. The unit of time recorded is in
+	 * microseconds.
 	 */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING6_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING6_LVL_LAST	HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING6_LVL_LVL_2
-	/* TQM ring 6 page size. */
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING6_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING6_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING6_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING6_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING6_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING6_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING6_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING6_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING6_PG_SIZE_LAST   HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING6_PG_SIZE_PG_1G
-	/* TQM ring 7 page size and level. */
-	uint8_t	tqm_ring7_pg_size_tqm_ring7_lvl;
-	/* TQM ring 7 PBL indirect levels. */
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING7_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING7_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING7_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING7_LVL_LVL_1	UINT32_C(0x1)
+	uint64_t	pcie_cmpl_longest;
 	/*
-	 * PBL pointer points to PDE table with each entry pointing to PTE
-	 * tables.
+	 * Displays Time information of the shortest completion time from any
+	 * of the 4 tags for the caller PF. The unit of time recorded is in
+	 * microseconds.
 	 */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING7_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING7_LVL_LAST	HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING7_LVL_LVL_2
-	/* TQM ring 7 page size. */
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING7_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING7_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING7_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING7_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING7_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING7_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING7_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING7_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING7_PG_SIZE_LAST   HWRM_RING_SCHQ_ALLOC_INPUT_TQM_RING7_PG_SIZE_PG_1G
-	/* TQM ring 0 page directory. */
-	uint64_t	tqm_ring0_page_dir;
-	/* TQM ring 1 page directory. */
-	uint64_t	tqm_ring1_page_dir;
-	/* TQM ring 2 page directory. */
-	uint64_t	tqm_ring2_page_dir;
-	/* TQM ring 3 page directory. */
-	uint64_t	tqm_ring3_page_dir;
-	/* TQM ring 4 page directory. */
-	uint64_t	tqm_ring4_page_dir;
-	/* TQM ring 5 page directory. */
-	uint64_t	tqm_ring5_page_dir;
-	/* TQM ring 6 page directory. */
-	uint64_t	tqm_ring6_page_dir;
-	/* TQM ring 7 page directory. */
-	uint64_t	tqm_ring7_page_dir;
+	uint64_t	pcie_cmpl_shortest;
 	/*
-	 * Number of TQM ring 0 entries.
-	 *
-	 * TQM fastpath rings should be sized large enough to accommodate the
-	 * maximum number of QPs (either L2 or RoCE, or both if shared)
-	 * that can be enqueued to the TQM ring.
-	 *
-	 * Note that TQM ring sizes cannot be extended while the system is
-	 * operational. If a PF driver needs to extend a TQM ring, it needs
-	 * to delete the SCHQ and then reallocate it.
+	 * This field contains the total number of CFCQ 'misses' observed for
+	 * all the PF's.
 	 */
-	uint32_t	tqm_ring0_num_entries;
+	uint64_t	cache_miss_count_cfcq;
 	/*
-	 * Number of TQM ring 1 entries.
-	 *
-	 * TQM fastpath rings should be sized large enough to accommodate the
-	 * maximum number of QPs (either L2 or RoCE, or both if shared)
-	 * that can be enqueued to the TQM ring.
-	 *
-	 * Note that TQM ring sizes cannot be extended while the system is
-	 * operational. If a PF driver needs to extend a TQM ring, it needs
-	 * to delete the SCHQ and then reallocate it.
+	 * This field contains the total number of CFCS 'misses' observed for
+	 * all the PF's.
 	 */
-	uint32_t	tqm_ring1_num_entries;
+	uint64_t	cache_miss_count_cfcs;
 	/*
-	 * Number of TQM ring 2 entries.
-	 *
-	 * TQM fastpath rings should be sized large enough to accommodate the
-	 * maximum number of QPs (either L2 or RoCE, or both if shared)
-	 * that can be enqueued to the TQM ring.
-	 *
-	 * Note that TQM ring sizes cannot be extended while the system is
-	 * operational. If a PF driver needs to extend a TQM ring, it needs
-	 * to delete the SCHQ and then reallocate it.
+	 * This field contains the total number of CFCC 'misses' observed for
+	 * all the PF's.
 	 */
-	uint32_t	tqm_ring2_num_entries;
+	uint64_t	cache_miss_count_cfcc;
 	/*
-	 * Number of TQM ring 3 entries.
-	 *
-	 * TQM fastpath rings should be sized large enough to accommodate the
-	 * maximum number of QPs (either L2 or RoCE, or both if shared)
-	 * that can be enqueued to the TQM ring.
-	 *
-	 * Note that TQM ring sizes cannot be extended while the system is
-	 * operational. If a PF driver needs to extend a TQM ring, it needs
-	 * to delete the SCHQ and then reallocate it.
+	 * This field contains the total number of CFCM 'misses' observed
+	 * for all the PF's.
 	 */
-	uint32_t	tqm_ring3_num_entries;
+	uint64_t	cache_miss_count_cfcm;
 	/*
-	 * Number of TQM ring 4 entries.
-	 *
-	 * TQM fastpath rings should be sized large enough to accommodate the
-	 * maximum number of QPs (either L2 or RoCE, or both if shared)
-	 * that can be enqueued to the TQM ring.
-	 *
-	 * Note that TQM ring sizes cannot be extended while the system is
-	 * operational. If a PF driver needs to extend a TQM ring, it needs
-	 * to delete the SCHQ and then reallocate it.
+	 * Total number of Doorbell messages dropped from the DB FIFO.
+	 * This counter is only applicable for devices that support
+	 * the hardware based doorbell drop recovery feature.
 	 */
-	uint32_t	tqm_ring4_num_entries;
+	uint64_t	hw_db_recov_dbs_dropped;
 	/*
-	 * Number of TQM ring 5 entries.
-	 *
-	 * TQM fastpath rings should be sized large enough to accommodate the
-	 * maximum number of QPs (either L2 or RoCE, or both if shared)
-	 * that can be enqueued to the TQM ring.
-	 *
-	 * Note that TQM ring sizes cannot be extended while the system is
-	 * operational. If a PF driver needs to extend a TQM ring, it needs
-	 * to delete the SCHQ and then reallocate it.
+	 * Total number of doorbell drops serviced.
+	 * This counter is only applicable for devices that support
+	 * the hardware based doorbell drop recovery feature.
 	 */
-	uint32_t	tqm_ring5_num_entries;
+	uint64_t	hw_db_recov_drops_serviced;
 	/*
-	 * Number of TQM ring 6 entries.
-	 *
-	 * TQM fastpath rings should be sized large enough to accommodate the
-	 * maximum number of QPs (either L2 or RoCE, or both if shared)
-	 * that can be enqueued to the TQM ring.
-	 *
-	 * Note that TQM ring sizes cannot be extended while the system is
-	 * operational. If a PF driver needs to extend a TQM ring, it needs
-	 * to delete the SCHQ and then reallocate it.
+	 * Total number of dropped doorbells recovered.
+	 * This counter is only applicable for devices that support
+	 * the hardware based doorbell drop recovery feature.
 	 */
-	uint32_t	tqm_ring6_num_entries;
+	uint64_t	hw_db_recov_dbs_recovered;
 	/*
-	 * Number of TQM ring 7 entries.
-	 *
-	 * TQM fastpath rings should be sized large enough to accommodate the
-	 * maximum number of QPs (either L2 or RoCE, or both if shared)
-	 * that can be enqueued to the TQM ring.
-	 *
-	 * Note that TQM ring sizes cannot be extended while the system is
-	 * operational. If a PF driver needs to extend a TQM ring, it needs
-	 * to delete the SCHQ and then reallocate it.
+	 * Total number of out of order doorbell messages dropped.
+	 * This counter is only applicable for devices that support
+	 * the hardware based doorbell drop recovery feature.
 	 */
-	uint32_t	tqm_ring7_num_entries;
-	/* Number of bytes that have been allocated for each context entry. */
-	uint16_t	tqm_entry_size;
-	uint8_t	unused_0[6];
-} hwrm_ring_schq_alloc_input_t, *phwrm_ring_schq_alloc_input_t;
+	uint64_t	hw_db_recov_oo_drop_count;
+} generic_sw_hw_stats_t, *pgeneric_sw_hw_stats_t;
 
-/* hwrm_ring_schq_alloc_output (size:128b/16B) */
+/*****************************
+ * hwrm_stat_db_error_qstats *
+ *****************************/
 
-typedef struct hwrm_ring_schq_alloc_output {
+
+/* hwrm_stat_db_error_qstats_input (size:128b/16B) */
+
+typedef struct hwrm_stat_db_error_qstats_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+} hwrm_stat_db_error_qstats_input_t, *phwrm_stat_db_error_qstats_input_t;
+
+/* hwrm_stat_db_error_qstats_output (size:320b/40B) */
+
+typedef struct hwrm_stat_db_error_qstats_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -32465,30 +59941,57 @@ typedef struct hwrm_ring_schq_alloc_output {
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
 	/*
-	 * This is an identifier for the SCHQ to be used in other HWRM commands
-	 * that need to reference this SCHQ. This value is greater than zero
-	 * (i.e. a schq_id of zero references the default SCHQ).
+	 * Specifies count of doorbells dropped due to RoCE SQs or L2
+	 * Tx Rings being in invalid state.
 	 */
-	uint16_t	schq_id;
-	uint8_t	unused_0[5];
+	uint32_t	tx_db_drop_invalid_qp_state;
+	/*
+	 * Specifies count of doorbells dropped due to RoCE RQs/SRQs or
+	 * L2 Rx Rings being used in invalid state.
+	 */
+	uint32_t	rx_db_drop_invalid_rq_state;
+	/*
+	 * Specifies count of doorbells dropped for any doorbell type
+	 * due to formatting errors such as illegal doorbell message
+	 * type, index out of range etc.
+	 */
+	uint32_t	tx_db_drop_format_error;
+	/*
+	 * Specifies count of express mode doorbells dropped for any
+	 * doorbell type due to error conditions such as DPI check,
+	 * context load error etc.
+	 */
+	uint32_t	express_db_dropped_misc_error;
+	/*
+	 * Specifies count of express mode doorbells dropped due to
+	 * RoCE SQ overflow.
+	 */
+	uint32_t	express_db_dropped_sq_overflow;
+	/*
+	 * Specifies count of express mode doorbells dropped due to
+	 * RoCE RQ overflow.
+	 */
+	uint32_t	express_db_dropped_rq_overflow;
+	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
+	 * is completely written to RAM. This field should be read as '1'
 	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_ring_schq_alloc_output_t, *phwrm_ring_schq_alloc_output_t;
+} hwrm_stat_db_error_qstats_output_t, *phwrm_stat_db_error_qstats_output_t;
 
-/**********************
- * hwrm_ring_schq_cfg *
- **********************/
+/*****************
+ * hwrm_fw_reset *
+ *****************/
 
 
-/* hwrm_ring_schq_cfg_input (size:768b/96B) */
+/* hwrm_fw_reset_input (size:192b/24B) */
 
-typedef struct hwrm_ring_schq_cfg_input {
+typedef struct hwrm_fw_reset_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -32517,106 +60020,289 @@ typedef struct hwrm_ring_schq_cfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
+	/* Type of embedded processor. */
+	uint8_t	embedded_proc_type;
+	/* Boot Processor */
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_BOOT		UINT32_C(0x0)
+	/* Management Processor */
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_MGMT		UINT32_C(0x1)
+	/* Network control processor */
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_NETCTRL		UINT32_C(0x2)
+	/* RoCE control processor */
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_ROCE		UINT32_C(0x3)
 	/*
-	 * Identifies the SCHQ being configured. A schq_id of zero refers to
-	 * the default SCHQ.
+	 * Host (in multi-host environment): This is only valid if requester
+	 * is IPC. Reinit host hardware resources and PCIe.
 	 */
-	uint16_t	schq_id;
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_HOST		UINT32_C(0x4)
 	/*
-	 * This field is an 8 bit bitmap that indicates which TCs are enabled
-	 * in this SCHQ. Bit 0 represents traffic class 0 and bit 7 represents
-	 * traffic class 7.
+	 * AP processor complex (in multi-host environment).
+	 * Use host_idx to control which core is reset.
 	 */
-	uint8_t	tc_enabled;
-	uint8_t	unused_0;
-	uint32_t	flags;
-	/* The tc_max_bw array and the max_bw parameters are valid */
-	#define HWRM_RING_SCHQ_CFG_INPUT_FLAGS_TC_MAX_BW_ENABLED	UINT32_C(0x1)
-	/* The tc_min_bw array is valid */
-	#define HWRM_RING_SCHQ_CFG_INPUT_FLAGS_TC_MIN_BW_ENABLED	UINT32_C(0x2)
-	/* Maximum bandwidth of the traffic class, specified in Mbps. */
-	uint32_t	max_bw_tc0;
-	/* Maximum bandwidth of the traffic class, specified in Mbps. */
-	uint32_t	max_bw_tc1;
-	/* Maximum bandwidth of the traffic class, specified in Mbps. */
-	uint32_t	max_bw_tc2;
-	/* Maximum bandwidth of the traffic class, specified in Mbps. */
-	uint32_t	max_bw_tc3;
-	/* Maximum bandwidth of the traffic class, specified in Mbps. */
-	uint32_t	max_bw_tc4;
-	/* Maximum bandwidth of the traffic class, specified in Mbps. */
-	uint32_t	max_bw_tc5;
-	/* Maximum bandwidth of the traffic class, specified in Mbps. */
-	uint32_t	max_bw_tc6;
-	/* Maximum bandwidth of the traffic class, specified in Mbps. */
-	uint32_t	max_bw_tc7;
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_AP			UINT32_C(0x5)
+	/* Reset all blocks of the chip (including all processors) */
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_CHIP		UINT32_C(0x6)
 	/*
-	 * Bandwidth reservation for the traffic class, specified in Mbps.
-	 * A value of zero signifies that traffic belonging to this class
-	 * shares the bandwidth reservation for the same traffic class of
-	 * the default SCHQ.
+	 * Host (in multi-host environment): This is only valid if requester
+	 * is IPC. Reinit host hardware resources.
 	 */
-	uint32_t	min_bw_tc0;
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_HOST_RESOURCE_REINIT  UINT32_C(0x7)
 	/*
-	 * Bandwidth reservation for the traffic class, specified in Mbps.
-	 * A value of zero signifies that traffic belonging to this class
-	 * shares the bandwidth reservation for the same traffic class of
-	 * the default SCHQ.
+	 * Activate firmware that has been programmed to NVM. The
+	 * activation is done in an impactless manner as part of the scheme
+	 * where hwrm_fw_state_backup precedes the call, and
+	 * hwrm_fw_state_restore follows it. Before this call returns, FW
+	 * status is set to a non-0x8000 value to disambiguate reset pending
+	 * from reset complete. The reset process begins after this call
+	 * returns to ensure this HWRM has completed before reset begins.
 	 */
-	uint32_t	min_bw_tc1;
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_IMPACTLESS_ACTIVATION UINT32_C(0x8)
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_LAST		HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_IMPACTLESS_ACTIVATION
+	/* Type of self reset. */
+	uint8_t	selfrst_status;
+	/* No Self Reset */
+	#define HWRM_FW_RESET_INPUT_SELFRST_STATUS_SELFRSTNONE	UINT32_C(0x0)
+	/* Self Reset as soon as possible to do so safely */
+	#define HWRM_FW_RESET_INPUT_SELFRST_STATUS_SELFRSTASAP	UINT32_C(0x1)
+	/* Self Reset on PCIe Reset */
+	#define HWRM_FW_RESET_INPUT_SELFRST_STATUS_SELFRSTPCIERST   UINT32_C(0x2)
+	/* Self Reset immediately after notification to all clients. */
+	#define HWRM_FW_RESET_INPUT_SELFRST_STATUS_SELFRSTIMMEDIATE UINT32_C(0x3)
+	#define HWRM_FW_RESET_INPUT_SELFRST_STATUS_LAST		HWRM_FW_RESET_INPUT_SELFRST_STATUS_SELFRSTIMMEDIATE
 	/*
-	 * Bandwidth reservation for the traffic class, specified in Mbps.
-	 * A value of zero signifies that traffic belonging to this class
-	 * shares the bandwidth reservation for the same traffic class of
-	 * the default SCHQ.
+	 * Indicate which host is being reset. 0 means first host.
+	 * Only valid when embedded_proc_type is host in multihost
+	 * environment
 	 */
-	uint32_t	min_bw_tc2;
+	uint8_t	host_idx;
+	uint8_t	flags;
 	/*
-	 * Bandwidth reservation for the traffic class, specified in Mbps.
-	 * A value of zero signifies that traffic belonging to this class
-	 * shares the bandwidth reservation for the same traffic class of
-	 * the default SCHQ.
+	 * When this bit is '1', then the core firmware initiates
+	 * the reset only after graceful shut down of all registered
+	 * instances. If not, the device will continue with the existing
+	 * firmware.
 	 */
-	uint32_t	min_bw_tc3;
+	#define HWRM_FW_RESET_INPUT_FLAGS_RESET_GRACEFUL	UINT32_C(0x1)
 	/*
-	 * Bandwidth reservation for the traffic class, specified in Mbps.
-	 * A value of zero signifies that traffic belonging to this class
-	 * shares the bandwidth reservation for the same traffic class of
-	 * the default SCHQ.
+	 * When this bit is '1', then drivers will be notified that
+	 * that the purpose of the reset was a firmware activation.
+	 * Such notifications are delivered via the RESET_NOTIFY async
+	 * event (reason_code: fw_activation).
+	 */
+	#define HWRM_FW_RESET_INPUT_FLAGS_FW_ACTIVATION	UINT32_C(0x2)
+	uint8_t	unused_0[4];
+} hwrm_fw_reset_input_t, *phwrm_fw_reset_input_t;
+
+/* hwrm_fw_reset_output (size:128b/16B) */
+
+typedef struct hwrm_fw_reset_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Type of self reset. */
+	uint8_t	selfrst_status;
+	/* No Self Reset */
+	#define HWRM_FW_RESET_OUTPUT_SELFRST_STATUS_SELFRSTNONE	UINT32_C(0x0)
+	/* Self Reset as soon as possible to do so safely */
+	#define HWRM_FW_RESET_OUTPUT_SELFRST_STATUS_SELFRSTASAP	UINT32_C(0x1)
+	/* Self Reset on PCIe Reset */
+	#define HWRM_FW_RESET_OUTPUT_SELFRST_STATUS_SELFRSTPCIERST   UINT32_C(0x2)
+	/* Self Reset immediately after notification to all clients. */
+	#define HWRM_FW_RESET_OUTPUT_SELFRST_STATUS_SELFRSTIMMEDIATE UINT32_C(0x3)
+	#define HWRM_FW_RESET_OUTPUT_SELFRST_STATUS_LAST		HWRM_FW_RESET_OUTPUT_SELFRST_STATUS_SELFRSTIMMEDIATE
+	uint8_t	unused_0[6];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	uint32_t	min_bw_tc4;
+	uint8_t	valid;
+} hwrm_fw_reset_output_t, *phwrm_fw_reset_output_t;
+
+/*******************
+ * hwrm_fw_qstatus *
+ *******************/
+
+
+/* hwrm_fw_qstatus_input (size:192b/24B) */
+
+typedef struct hwrm_fw_qstatus_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * Bandwidth reservation for the traffic class, specified in Mbps.
-	 * A value of zero signifies that traffic belonging to this class
-	 * shares the bandwidth reservation for the same traffic class of
-	 * the default SCHQ.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint32_t	min_bw_tc5;
+	uint16_t	cmpl_ring;
 	/*
-	 * Bandwidth reservation for the traffic class, specified in Mbps.
-	 * A value of zero signifies that traffic belonging to this class
-	 * shares the bandwidth reservation for the same traffic class of
-	 * the default SCHQ.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint32_t	min_bw_tc6;
+	uint16_t	seq_id;
 	/*
-	 * Bandwidth reservation for the traffic class, specified in Mbps.
-	 * A value of zero signifies that traffic belonging to this class
-	 * shares the bandwidth reservation for the same traffic class of
-	 * the default SCHQ.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint32_t	min_bw_tc7;
+	uint16_t	target_id;
 	/*
-	 * Indicates the max bandwidth for all enabled traffic classes in
-	 * this SCHQ, specified in Mbps.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint32_t	max_bw;
+	uint64_t	resp_addr;
+	/* Type of embedded processor. */
+	uint8_t	embedded_proc_type;
+	/* Boot Processor */
+	#define HWRM_FW_QSTATUS_INPUT_EMBEDDED_PROC_TYPE_BOOT	UINT32_C(0x0)
+	/* Management Processor */
+	#define HWRM_FW_QSTATUS_INPUT_EMBEDDED_PROC_TYPE_MGMT	UINT32_C(0x1)
+	/* Network control processor */
+	#define HWRM_FW_QSTATUS_INPUT_EMBEDDED_PROC_TYPE_NETCTRL UINT32_C(0x2)
+	/* RoCE control processor */
+	#define HWRM_FW_QSTATUS_INPUT_EMBEDDED_PROC_TYPE_ROCE	UINT32_C(0x3)
+	/*
+	 * Host (in multi-host environment): This is only valid if requester
+	 * is IPC
+	 */
+	#define HWRM_FW_QSTATUS_INPUT_EMBEDDED_PROC_TYPE_HOST	UINT32_C(0x4)
+	/*
+	 * AP processor complex (in multi-host environment). Use host_idx to
+	 * control which core is reset
+	 */
+	#define HWRM_FW_QSTATUS_INPUT_EMBEDDED_PROC_TYPE_AP	UINT32_C(0x5)
+	/* Reset all blocks of the chip (including all processors) */
+	#define HWRM_FW_QSTATUS_INPUT_EMBEDDED_PROC_TYPE_CHIP	UINT32_C(0x6)
+	#define HWRM_FW_QSTATUS_INPUT_EMBEDDED_PROC_TYPE_LAST   HWRM_FW_QSTATUS_INPUT_EMBEDDED_PROC_TYPE_CHIP
+	uint8_t	unused_0[7];
+} hwrm_fw_qstatus_input_t, *phwrm_fw_qstatus_input_t;
+
+/* hwrm_fw_qstatus_output (size:128b/16B) */
+
+typedef struct hwrm_fw_qstatus_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Type of self reset. */
+	uint8_t	selfrst_status;
+	/* No Self Reset */
+	#define HWRM_FW_QSTATUS_OUTPUT_SELFRST_STATUS_SELFRSTNONE	UINT32_C(0x0)
+	/* Self Reset as soon as possible to do so safely */
+	#define HWRM_FW_QSTATUS_OUTPUT_SELFRST_STATUS_SELFRSTASAP	UINT32_C(0x1)
+	/* Self Reset on PCIe Reset */
+	#define HWRM_FW_QSTATUS_OUTPUT_SELFRST_STATUS_SELFRSTPCIERST UINT32_C(0x2)
+	/* NIC power cycle (system cold boot) required */
+	#define HWRM_FW_QSTATUS_OUTPUT_SELFRST_STATUS_SELFRSTPOWER   UINT32_C(0x3)
+	#define HWRM_FW_QSTATUS_OUTPUT_SELFRST_STATUS_LAST	HWRM_FW_QSTATUS_OUTPUT_SELFRST_STATUS_SELFRSTPOWER
+	/*
+	 * The action needed to apply any pend nvm option changes.
+	 * If multiple options have been set the highest level
+	 * action is reported.
+	 */
+	uint8_t	nvm_option_action_status;
+	/* No Action needed */
+	#define HWRM_FW_QSTATUS_OUTPUT_NVM_OPTION_ACTION_STATUS_NVMOPT_ACTION_NONE	UINT32_C(0x0)
+	/* Hot reset needed to apply nvm options */
+	#define HWRM_FW_QSTATUS_OUTPUT_NVM_OPTION_ACTION_STATUS_NVMOPT_ACTION_HOTRESET UINT32_C(0x1)
+	/* Warm boot needed to apply nvm options */
+	#define HWRM_FW_QSTATUS_OUTPUT_NVM_OPTION_ACTION_STATUS_NVMOPT_ACTION_WARMBOOT UINT32_C(0x2)
+	/* Cold boot needed to apply nvm options */
+	#define HWRM_FW_QSTATUS_OUTPUT_NVM_OPTION_ACTION_STATUS_NVMOPT_ACTION_COLDBOOT UINT32_C(0x3)
+	#define HWRM_FW_QSTATUS_OUTPUT_NVM_OPTION_ACTION_STATUS_LAST		HWRM_FW_QSTATUS_OUTPUT_NVM_OPTION_ACTION_STATUS_NVMOPT_ACTION_COLDBOOT
+	uint8_t	unused_0[5];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_fw_qstatus_output_t, *phwrm_fw_qstatus_output_t;
+
+/********************
+ * hwrm_fw_set_time *
+ ********************/
+
+
+/* hwrm_fw_set_time_input (size:256b/32B) */
+
+typedef struct hwrm_fw_set_time_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Current year */
+	uint16_t	year;
+	/* Date/time is not known */
+	#define HWRM_FW_SET_TIME_INPUT_YEAR_UNKNOWN UINT32_C(0x0)
+	#define HWRM_FW_SET_TIME_INPUT_YEAR_LAST   HWRM_FW_SET_TIME_INPUT_YEAR_UNKNOWN
+	/* Current month of year (1-12) */
+	uint8_t	month;
+	/* Current day of month (1-31) */
+	uint8_t	day;
+	/* Current hour (0-23) */
+	uint8_t	hour;
+	/* Current minute (0-59) */
+	uint8_t	minute;
+	/* Current second (0-59) */
+	uint8_t	second;
+	uint8_t	unused_0;
+	/* Current millisecond (0-999) */
+	uint16_t	millisecond;
+	/* Minutes east of UTC, 0xffff if TZ is not known */
+	int16_t	zone;
+	/* Time zone is Coordinated Universal Time (UTC) */
+	#define HWRM_FW_SET_TIME_INPUT_ZONE_UTC	0
+	/* Time zone is not known */
+	#define HWRM_FW_SET_TIME_INPUT_ZONE_UNKNOWN 65535
+	#define HWRM_FW_SET_TIME_INPUT_ZONE_LAST   HWRM_FW_SET_TIME_INPUT_ZONE_UNKNOWN
 	uint8_t	unused_1[4];
-} hwrm_ring_schq_cfg_input_t, *phwrm_ring_schq_cfg_input_t;
+} hwrm_fw_set_time_input_t, *phwrm_fw_set_time_input_t;
 
-/* hwrm_ring_schq_cfg_output (size:128b/16B) */
+/* hwrm_fw_set_time_output (size:128b/16B) */
 
-typedef struct hwrm_ring_schq_cfg_output {
+typedef struct hwrm_fw_set_time_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -32628,22 +60314,22 @@ typedef struct hwrm_ring_schq_cfg_output {
 	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
 	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_ring_schq_cfg_output_t, *phwrm_ring_schq_cfg_output_t;
+} hwrm_fw_set_time_output_t, *phwrm_fw_set_time_output_t;
 
-/***********************
- * hwrm_ring_schq_free *
- ***********************/
+/********************
+ * hwrm_fw_get_time *
+ ********************/
 
 
-/* hwrm_ring_schq_free_input (size:192b/24B) */
+/* hwrm_fw_get_time_input (size:128b/16B) */
 
-typedef struct hwrm_ring_schq_free_input {
+typedef struct hwrm_fw_get_time_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -32672,14 +60358,11 @@ typedef struct hwrm_ring_schq_free_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Identifies the SCHQ being freed. */
-	uint16_t	schq_id;
-	uint8_t	unused_0[6];
-} hwrm_ring_schq_free_input_t, *phwrm_ring_schq_free_input_t;
+} hwrm_fw_get_time_input_t, *phwrm_fw_get_time_input_t;
 
-/* hwrm_ring_schq_free_output (size:128b/16B) */
+/* hwrm_fw_get_time_output (size:192b/24B) */
 
-typedef struct hwrm_ring_schq_free_output {
+typedef struct hwrm_fw_get_time_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -32688,46 +60371,512 @@ typedef struct hwrm_ring_schq_free_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	/* Current year */
+	uint16_t	year;
+	/* Date/time is not known */
+	#define HWRM_FW_GET_TIME_OUTPUT_YEAR_UNKNOWN UINT32_C(0x0)
+	#define HWRM_FW_GET_TIME_OUTPUT_YEAR_LAST   HWRM_FW_GET_TIME_OUTPUT_YEAR_UNKNOWN
+	/* Current month of year (1-12) */
+	uint8_t	month;
+	/* Current day of month (1-31) */
+	uint8_t	day;
+	/* Current hour (0-23) */
+	uint8_t	hour;
+	/* Current minute (0-59) */
+	uint8_t	minute;
+	/* Current second (0-59) */
+	uint8_t	second;
+	uint8_t	unused_0;
+	/* Current millisecond (0-999) */
+	uint16_t	millisecond;
+	/* Minutes east of UTC, 0xffff if TZ is not known */
+	int16_t	zone;
+	/* Time zone is Coordinated Universal Time (UTC) */
+	#define HWRM_FW_GET_TIME_OUTPUT_ZONE_UTC	0
+	/* Time zone is not known */
+	#define HWRM_FW_GET_TIME_OUTPUT_ZONE_UNKNOWN 65535
+	#define HWRM_FW_GET_TIME_OUTPUT_ZONE_LAST   HWRM_FW_GET_TIME_OUTPUT_ZONE_UNKNOWN
+	uint8_t	unused_1[3];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
 	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_ring_schq_free_output_t, *phwrm_ring_schq_free_output_t;
+} hwrm_fw_get_time_output_t, *phwrm_fw_get_time_output_t;
 
-/*
- * special reserved flow ID to identify per function default
- * flows for vSwitch offload
- */
-#define DEFAULT_FLOW_ID 0xFFFFFFFFUL
-/*
- * special reserved flow ID to identify per function RoCEv1
- * flows
- */
-#define ROCEV1_FLOW_ID 0xFFFFFFFEUL
-/*
- * special reserved flow ID to identify per function RoCEv2
- * flows
- */
-#define ROCEV2_FLOW_ID 0xFFFFFFFDUL
-/*
- * special reserved flow ID to identify per function RoCEv2
- * CNP flows
- */
-#define ROCEV2_CNP_FLOW_ID 0xFFFFFFFCUL
+/* hwrm_struct_hdr (size:128b/16B) */
+
+typedef struct hwrm_struct_hdr {
+	/* This value indicates the structured data ID. */
+	uint16_t	struct_id;
+	/* LLDP configuration structured data ID. */
+	#define HWRM_STRUCT_HDR_STRUCT_ID_LLDP_CFG	UINT32_C(0x41b)
+	/* DCBX ETS configuration structured data ID. */
+	#define HWRM_STRUCT_HDR_STRUCT_ID_DCBX_ETS	UINT32_C(0x41d)
+	/* DCBX PFC configuration structured data ID. */
+	#define HWRM_STRUCT_HDR_STRUCT_ID_DCBX_PFC	UINT32_C(0x41f)
+	/* DCBX APP configuration structured data ID. */
+	#define HWRM_STRUCT_HDR_STRUCT_ID_DCBX_APP	UINT32_C(0x421)
+	/* DCBX state configuration structured data ID for all DCBX features. */
+	#define HWRM_STRUCT_HDR_STRUCT_ID_DCBX_FEATURE_STATE UINT32_C(0x422)
+	/*
+	 * LLDP generic structured data ID. This is used with
+	 * GET_STRUCTURED_DATA only.
+	 */
+	#define HWRM_STRUCT_HDR_STRUCT_ID_LLDP_GENERIC	UINT32_C(0x424)
+	/*
+	 * LLDP device structured data ID. This is used with
+	 * GET_STRUCTURED_DATA only.
+	 */
+	#define HWRM_STRUCT_HDR_STRUCT_ID_LLDP_DEVICE	UINT32_C(0x426)
+	/* Power Backup info */
+	#define HWRM_STRUCT_HDR_STRUCT_ID_POWER_BKUP	UINT32_C(0x427)
+	/* reserved for AFM usage. */
+	#define HWRM_STRUCT_HDR_STRUCT_ID_AFM_OPAQUE	UINT32_C(0x1)
+	/* Port description. */
+	#define HWRM_STRUCT_HDR_STRUCT_ID_PORT_DESCRIPTION   UINT32_C(0xa)
+	/* RSSv2 Configuration. */
+	#define HWRM_STRUCT_HDR_STRUCT_ID_RSS_V2		UINT32_C(0x64)
+	/* MSI-X vectors per VF table. */
+	#define HWRM_STRUCT_HDR_STRUCT_ID_MSIX_PER_VF	UINT32_C(0xc8)
+	#define HWRM_STRUCT_HDR_STRUCT_ID_LAST		HWRM_STRUCT_HDR_STRUCT_ID_MSIX_PER_VF
+	/* This value indicates the length of structured data. */
+	uint16_t	len;
+	/* This value indicates the version of structured data. */
+	uint8_t	version;
+	/* This value indicates the number of structured data elements. */
+	uint8_t	count;
+	/* This value indicates the subtype. */
+	uint16_t	subtype;
+	/*
+	 * This value indicates the count of 64-bit values that point to the next
+	 * header. A value of 0 means that this is the last element. The value is
+	 * a count of 64-bit words from the beginning of the current header.
+	 */
+	uint16_t	next_offset;
+	/* This value indicates this is the last element */
+	#define HWRM_STRUCT_HDR_NEXT_OFFSET_LAST UINT32_C(0x0)
+	uint8_t	unused_0[6];
+} hwrm_struct_hdr_t, *phwrm_struct_hdr_t;
+
+/* hwrm_struct_data_dcbx_ets (size:256b/32B) */
+
+typedef struct hwrm_struct_data_dcbx_ets {
+	/*
+	 * This field indicates if this configuration is ETS recommendation or
+	 * ETS configuration. A value 1 means it is ETS configuration, A value of
+	 * 2 means it is a ETS recommendation.
+	 */
+	uint8_t	destination;
+	/* ETS configuration */
+	#define HWRM_STRUCT_DATA_DCBX_ETS_DESTINATION_CONFIGURATION   UINT32_C(0x1)
+	/* ETS recommendation */
+	#define HWRM_STRUCT_DATA_DCBX_ETS_DESTINATION_RECOMMMENDATION UINT32_C(0x2)
+	#define HWRM_STRUCT_DATA_DCBX_ETS_DESTINATION_LAST	HWRM_STRUCT_DATA_DCBX_ETS_DESTINATION_RECOMMMENDATION
+	/* This value indicates maximum ETS TCs supported. */
+	uint8_t	max_tcs;
+	/* unused. */
+	uint16_t	unused1;
+	/* ETS priority 0 to TC map. */
+	uint8_t	pri0_to_tc_map;
+	/* ETS priority 1 to TC map. */
+	uint8_t	pri1_to_tc_map;
+	/* ETS priority 2 to TC map. */
+	uint8_t	pri2_to_tc_map;
+	/* ETS priority 3 to TC map. */
+	uint8_t	pri3_to_tc_map;
+	/* ETS priority 4 to TC map. */
+	uint8_t	pri4_to_tc_map;
+	/* ETS priority 5 to TC map. */
+	uint8_t	pri5_to_tc_map;
+	/* ETS priority 6 to TC map. */
+	uint8_t	pri6_to_tc_map;
+	/* ETS priority 7 to TC map. */
+	uint8_t	pri7_to_tc_map;
+	/* ETS TC 0 to bandwidth map. */
+	uint8_t	tc0_to_bw_map;
+	/* ETS TC 1 to bandwidth map. */
+	uint8_t	tc1_to_bw_map;
+	/* ETS TC 2 to bandwidth map. */
+	uint8_t	tc2_to_bw_map;
+	/* ETS TC 3 to bandwidth map. */
+	uint8_t	tc3_to_bw_map;
+	/* ETS TC 4 to bandwidth map. */
+	uint8_t	tc4_to_bw_map;
+	/* ETS TC 5 to bandwidth map. */
+	uint8_t	tc5_to_bw_map;
+	/* ETS TC 6 to bandwidth map. */
+	uint8_t	tc6_to_bw_map;
+	/* ETS TC 7 to bandwidth map. */
+	uint8_t	tc7_to_bw_map;
+	/* ETS TC 0 to TSA map. */
+	uint8_t	tc0_to_tsa_map;
+	/* strict priority */
+	#define HWRM_STRUCT_DATA_DCBX_ETS_TC0_TO_TSA_MAP_TSA_TYPE_SP		UINT32_C(0x0)
+	/* credit based shaper */
+	#define HWRM_STRUCT_DATA_DCBX_ETS_TC0_TO_TSA_MAP_TSA_TYPE_CBS		UINT32_C(0x1)
+	/* ETS */
+	#define HWRM_STRUCT_DATA_DCBX_ETS_TC0_TO_TSA_MAP_TSA_TYPE_ETS		UINT32_C(0x2)
+	/* vendor specific */
+	#define HWRM_STRUCT_DATA_DCBX_ETS_TC0_TO_TSA_MAP_TSA_TYPE_VENDOR_SPECIFIC UINT32_C(0xff)
+	#define HWRM_STRUCT_DATA_DCBX_ETS_TC0_TO_TSA_MAP_LAST			HWRM_STRUCT_DATA_DCBX_ETS_TC0_TO_TSA_MAP_TSA_TYPE_VENDOR_SPECIFIC
+	/* ETS TC 1 to TSA map. */
+	uint8_t	tc1_to_tsa_map;
+	/* ETS TC 2 to TSA map. */
+	uint8_t	tc2_to_tsa_map;
+	/* ETS TC 3 to TSA map. */
+	uint8_t	tc3_to_tsa_map;
+	/* ETS TC 4 to TSA map. */
+	uint8_t	tc4_to_tsa_map;
+	/* ETS TC 5 to TSA map. */
+	uint8_t	tc5_to_tsa_map;
+	/* ETS TC 6 to TSA map. */
+	uint8_t	tc6_to_tsa_map;
+	/* ETS TC 7 to TSA map. */
+	uint8_t	tc7_to_tsa_map;
+	uint8_t	unused_0[4];
+} hwrm_struct_data_dcbx_ets_t, *phwrm_struct_data_dcbx_ets_t;
+
+/* hwrm_struct_data_dcbx_pfc (size:64b/8B) */
+
+typedef struct hwrm_struct_data_dcbx_pfc {
+	/*
+	 * This field indicates PFC priority bit map. A value of '0' indicates
+	 * PFC is disabled. A value of '1' indicates PFC is enabled on that
+	 * priority.
+	 */
+	uint8_t	pfc_priority_bitmap;
+	/*
+	 * This field indicates max PFC TCs supported. Each PFC TC will map to
+	 * a lossless CoS queue.
+	 */
+	uint8_t	max_pfc_tcs;
+	/*
+	 * This field indicates if MACSec bypass capability is enabled. A value
+	 * of '1' indicates MBC is enabled. A value of '0' indicates MBC is
+	 * disabled.
+	 */
+	uint8_t	mbc;
+	uint8_t	unused_0[5];
+} hwrm_struct_data_dcbx_pfc_t, *phwrm_struct_data_dcbx_pfc_t;
+
+/* hwrm_struct_data_dcbx_app (size:64b/8B) */
+
+typedef struct hwrm_struct_data_dcbx_app {
+	/*
+	 * This field indicates the protocol identifier. This should be specified
+	 *		in big endian format.
+	 */
+	uint16_t	protocol_id;
+	/*
+	 * This field indicates the protocol selector. The valid values are
+	 *		mentioned below.
+	 */
+	uint8_t	protocol_selector;
+	/* ether type */
+	#define HWRM_STRUCT_DATA_DCBX_APP_PROTOCOL_SELECTOR_ETHER_TYPE   UINT32_C(0x1)
+	/* TCP port */
+	#define HWRM_STRUCT_DATA_DCBX_APP_PROTOCOL_SELECTOR_TCP_PORT	UINT32_C(0x2)
+	/* UDP port */
+	#define HWRM_STRUCT_DATA_DCBX_APP_PROTOCOL_SELECTOR_UDP_PORT	UINT32_C(0x3)
+	/* TCP & UDP port */
+	#define HWRM_STRUCT_DATA_DCBX_APP_PROTOCOL_SELECTOR_TCP_UDP_PORT UINT32_C(0x4)
+	#define HWRM_STRUCT_DATA_DCBX_APP_PROTOCOL_SELECTOR_LAST	HWRM_STRUCT_DATA_DCBX_APP_PROTOCOL_SELECTOR_TCP_UDP_PORT
+	/* This field indicates application priority. */
+	uint8_t	priority;
+	/* This field indicates this entry is valid. */
+	uint8_t	valid;
+	uint8_t	unused_0[3];
+} hwrm_struct_data_dcbx_app_t, *phwrm_struct_data_dcbx_app_t;
+
+/* hwrm_struct_data_dcbx_feature_state (size:64b/8B) */
+
+typedef struct hwrm_struct_data_dcbx_feature_state {
+	/* DCBX mode - IEEE or CEE. This is read only field. */
+	uint8_t	dcbx_mode;
+	/* DCBX disabled mode. */
+	#define HWRM_STRUCT_DATA_DCBX_FEATURE_STATE_DCBX_MODE_DCBX_DISABLED UINT32_C(0x0)
+	/* DCBX IEEE mode. */
+	#define HWRM_STRUCT_DATA_DCBX_FEATURE_STATE_DCBX_MODE_DCBX_IEEE	UINT32_C(0x1)
+	/* DCBX CEE mode. */
+	#define HWRM_STRUCT_DATA_DCBX_FEATURE_STATE_DCBX_MODE_DCBX_CEE	UINT32_C(0x2)
+	#define HWRM_STRUCT_DATA_DCBX_FEATURE_STATE_DCBX_MODE_LAST	HWRM_STRUCT_DATA_DCBX_FEATURE_STATE_DCBX_MODE_DCBX_CEE
+	/* ETS TLV state. */
+	uint8_t	ets_state;
+	/* PFC TLV state. */
+	uint8_t	pfc_state;
+	/* App TLV state. */
+	uint8_t	app_state;
+	/* Feature enable bit position. */
+	#define HWRM_STRUCT_DATA_DCBX_FEATURE_STATE_APP_STATE_ENABLE_BIT_POS	UINT32_C(0x7)
+	/* Feature willing bit position. */
+	#define HWRM_STRUCT_DATA_DCBX_FEATURE_STATE_APP_STATE_WILLING_BIT_POS   UINT32_C(0x6)
+	/* Feature advertise bit position. */
+	#define HWRM_STRUCT_DATA_DCBX_FEATURE_STATE_APP_STATE_ADVERTISE_BIT_POS UINT32_C(0x5)
+	#define HWRM_STRUCT_DATA_DCBX_FEATURE_STATE_APP_STATE_LAST		HWRM_STRUCT_DATA_DCBX_FEATURE_STATE_APP_STATE_ADVERTISE_BIT_POS
+	/* unused. */
+	uint8_t	unused[3];
+	/*
+	 * This field is used to reset the DCBX configuration to factory
+	 * defaults.
+	 */
+	uint8_t	resets;
+	/* reset ETS configuration. */
+	#define HWRM_STRUCT_DATA_DCBX_FEATURE_STATE_RESETS_RESET_ETS   UINT32_C(0x1)
+	/* reset PFC configuration. */
+	#define HWRM_STRUCT_DATA_DCBX_FEATURE_STATE_RESETS_RESET_PFC   UINT32_C(0x2)
+	/* reset application configuration. */
+	#define HWRM_STRUCT_DATA_DCBX_FEATURE_STATE_RESETS_RESET_APP   UINT32_C(0x4)
+	/* reset DCBX state configuration. */
+	#define HWRM_STRUCT_DATA_DCBX_FEATURE_STATE_RESETS_RESET_STATE UINT32_C(0x8)
+	#define HWRM_STRUCT_DATA_DCBX_FEATURE_STATE_RESETS_LAST	HWRM_STRUCT_DATA_DCBX_FEATURE_STATE_RESETS_RESET_STATE
+} hwrm_struct_data_dcbx_feature_state_t, *phwrm_struct_data_dcbx_feature_state_t;
+
+/* hwrm_struct_data_lldp (size:64b/8B) */
+
+typedef struct hwrm_struct_data_lldp {
+	/* Port admin state */
+	uint8_t	admin_state;
+	/* Disable both Tx and Rx */
+	#define HWRM_STRUCT_DATA_LLDP_ADMIN_STATE_DISABLE UINT32_C(0x0)
+	/* Enable Tx only */
+	#define HWRM_STRUCT_DATA_LLDP_ADMIN_STATE_TX	UINT32_C(0x1)
+	/* Enable Rx only */
+	#define HWRM_STRUCT_DATA_LLDP_ADMIN_STATE_RX	UINT32_C(0x2)
+	/* Enable both Tx and Rx */
+	#define HWRM_STRUCT_DATA_LLDP_ADMIN_STATE_ENABLE  UINT32_C(0x3)
+	#define HWRM_STRUCT_DATA_LLDP_ADMIN_STATE_LAST   HWRM_STRUCT_DATA_LLDP_ADMIN_STATE_ENABLE
+	/* Port description TLV transmit state (enable(1)/disable(0)). */
+	uint8_t	port_description_state;
+	/* Disable */
+	#define HWRM_STRUCT_DATA_LLDP_PORT_DESCRIPTION_STATE_DISABLE UINT32_C(0x0)
+	/* Enable. */
+	#define HWRM_STRUCT_DATA_LLDP_PORT_DESCRIPTION_STATE_ENABLE  UINT32_C(0x1)
+	#define HWRM_STRUCT_DATA_LLDP_PORT_DESCRIPTION_STATE_LAST   HWRM_STRUCT_DATA_LLDP_PORT_DESCRIPTION_STATE_ENABLE
+	/* System name TLV transmit state (enable(1)/disable(0)). */
+	uint8_t	system_name_state;
+	/* Disable */
+	#define HWRM_STRUCT_DATA_LLDP_SYSTEM_NAME_STATE_DISABLE UINT32_C(0x0)
+	/* Enable. */
+	#define HWRM_STRUCT_DATA_LLDP_SYSTEM_NAME_STATE_ENABLE  UINT32_C(0x1)
+	#define HWRM_STRUCT_DATA_LLDP_SYSTEM_NAME_STATE_LAST   HWRM_STRUCT_DATA_LLDP_SYSTEM_NAME_STATE_ENABLE
+	/* System description TLV transmit state (enable(1)/disable(0)). */
+	uint8_t	system_desc_state;
+	/* Disable */
+	#define HWRM_STRUCT_DATA_LLDP_SYSTEM_DESC_STATE_DISABLE UINT32_C(0x0)
+	/* Enable. */
+	#define HWRM_STRUCT_DATA_LLDP_SYSTEM_DESC_STATE_ENABLE  UINT32_C(0x1)
+	#define HWRM_STRUCT_DATA_LLDP_SYSTEM_DESC_STATE_LAST   HWRM_STRUCT_DATA_LLDP_SYSTEM_DESC_STATE_ENABLE
+	/* System capabilities TLV transmit state (enable(1)/disable(0)). */
+	uint8_t	system_cap_state;
+	/* Disable */
+	#define HWRM_STRUCT_DATA_LLDP_SYSTEM_CAP_STATE_DISABLE UINT32_C(0x0)
+	/* Enable. */
+	#define HWRM_STRUCT_DATA_LLDP_SYSTEM_CAP_STATE_ENABLE  UINT32_C(0x1)
+	#define HWRM_STRUCT_DATA_LLDP_SYSTEM_CAP_STATE_LAST   HWRM_STRUCT_DATA_LLDP_SYSTEM_CAP_STATE_ENABLE
+	/* Management address TLV transmit state (enable(1)/disable(0)). */
+	uint8_t	mgmt_addr_state;
+	/* Disable */
+	#define HWRM_STRUCT_DATA_LLDP_MGMT_ADDR_STATE_DISABLE UINT32_C(0x0)
+	/* Enable. */
+	#define HWRM_STRUCT_DATA_LLDP_MGMT_ADDR_STATE_ENABLE  UINT32_C(0x1)
+	#define HWRM_STRUCT_DATA_LLDP_MGMT_ADDR_STATE_LAST   HWRM_STRUCT_DATA_LLDP_MGMT_ADDR_STATE_ENABLE
+	/* Async event notification state (enable(1)/disable(0)). */
+	uint8_t	async_event_notification_state;
+	/* Disable */
+	#define HWRM_STRUCT_DATA_LLDP_ASYNC_EVENT_NOTIFICATION_STATE_DISABLE UINT32_C(0x0)
+	/* Enable. */
+	#define HWRM_STRUCT_DATA_LLDP_ASYNC_EVENT_NOTIFICATION_STATE_ENABLE  UINT32_C(0x1)
+	#define HWRM_STRUCT_DATA_LLDP_ASYNC_EVENT_NOTIFICATION_STATE_LAST   HWRM_STRUCT_DATA_LLDP_ASYNC_EVENT_NOTIFICATION_STATE_ENABLE
+	uint8_t	unused_0;
+} hwrm_struct_data_lldp_t, *phwrm_struct_data_lldp_t;
+
+/* hwrm_struct_data_lldp_generic (size:2112b/264B) */
+
+typedef struct hwrm_struct_data_lldp_generic {
+	/* TLV type. */
+	uint8_t	tlv_type;
+	/* Chassis ID TLV */
+	#define HWRM_STRUCT_DATA_LLDP_GENERIC_TLV_TYPE_CHASSIS		UINT32_C(0x1)
+	/* Port ID TLV */
+	#define HWRM_STRUCT_DATA_LLDP_GENERIC_TLV_TYPE_PORT		UINT32_C(0x2)
+	/* System name TLV */
+	#define HWRM_STRUCT_DATA_LLDP_GENERIC_TLV_TYPE_SYSTEM_NAME	UINT32_C(0x3)
+	/* System description TLV */
+	#define HWRM_STRUCT_DATA_LLDP_GENERIC_TLV_TYPE_SYSTEM_DESCRIPTION UINT32_C(0x4)
+	/* Port name TLV */
+	#define HWRM_STRUCT_DATA_LLDP_GENERIC_TLV_TYPE_PORT_NAME	UINT32_C(0x5)
+	/* Port description TLV */
+	#define HWRM_STRUCT_DATA_LLDP_GENERIC_TLV_TYPE_PORT_DESCRIPTION   UINT32_C(0x6)
+	#define HWRM_STRUCT_DATA_LLDP_GENERIC_TLV_TYPE_LAST		HWRM_STRUCT_DATA_LLDP_GENERIC_TLV_TYPE_PORT_DESCRIPTION
+	/* TLV sub-type. */
+	uint8_t	subtype;
+	/* Length. */
+	uint8_t	length;
+	/* unused. */
+	uint8_t	unused1[5];
+	/* TLV value. */
+	uint32_t	tlv_value[64];
+} hwrm_struct_data_lldp_generic_t, *phwrm_struct_data_lldp_generic_t;
+
+/* hwrm_struct_data_lldp_device (size:1472b/184B) */
+
+typedef struct hwrm_struct_data_lldp_device {
+	/* Time to Live. */
+	uint16_t	ttl;
+	/* Management address length. */
+	uint8_t	mgmt_addr_len;
+	/* Management address type. */
+	uint8_t	mgmt_addr_type;
+	uint8_t	unused_3[4];
+	/* Management address. */
+	uint32_t	mgmt_addr[8];
+	/* System capabilities. */
+	uint32_t	system_caps;
+	/* Interface number type. */
+	uint8_t	intf_num_type;
+	/* Management address OID length. */
+	uint8_t	mgmt_addr_oid_length;
+	uint8_t	unused_4[2];
+	/* Interface number. */
+	uint32_t	intf_num;
+	uint8_t	unused_5[4];
+	/* Management address OID. */
+	uint32_t	mgmt_addr_oid[32];
+} hwrm_struct_data_lldp_device_t, *phwrm_struct_data_lldp_device_t;
+
+/* hwrm_struct_data_port_description (size:64b/8B) */
+
+typedef struct hwrm_struct_data_port_description {
+	/*
+	 * Port #. Port number starts at 0 and anything greater than number of
+	 * ports minus 1 is an error.
+	 */
+	uint8_t	port_id;
+	uint8_t	unused_0[7];
+} hwrm_struct_data_port_description_t, *phwrm_struct_data_port_description_t;
+
+/* hwrm_struct_data_rss_v2 (size:128b/16B) */
+
+typedef struct hwrm_struct_data_rss_v2 {
+	uint16_t	flags;
+	/* When this bit is '1', the hash type and hash key are included. */
+	#define HWRM_STRUCT_DATA_RSS_V2_FLAGS_HASH_VALID	UINT32_C(0x1)
+	/* RSS Context index. */
+	uint16_t	rss_ctx_id;
+	/* Number ring group IDs. */
+	uint16_t	num_ring_groups;
+	uint16_t	hash_type;
+	/*
+	 * When this bit is '1', the RSS hash shall be computed
+	 * over source and destination IPv4 addresses of IPv4
+	 * packets.
+	 */
+	#define HWRM_STRUCT_DATA_RSS_V2_HASH_TYPE_IPV4	UINT32_C(0x1)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed
+	 * over source/destination IPv4 addresses and
+	 * source/destination ports of TCP/IPv4 packets.
+	 */
+	#define HWRM_STRUCT_DATA_RSS_V2_HASH_TYPE_TCP_IPV4	UINT32_C(0x2)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed
+	 * over source/destination IPv4 addresses and
+	 * source/destination ports of UDP/IPv4 packets.
+	 */
+	#define HWRM_STRUCT_DATA_RSS_V2_HASH_TYPE_UDP_IPV4	UINT32_C(0x4)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed
+	 * over source and destination IPv4 addresses of IPv6
+	 * packets.
+	 */
+	#define HWRM_STRUCT_DATA_RSS_V2_HASH_TYPE_IPV6	UINT32_C(0x8)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed
+	 * over source/destination IPv6 addresses and
+	 * source/destination ports of TCP/IPv6 packets.
+	 */
+	#define HWRM_STRUCT_DATA_RSS_V2_HASH_TYPE_TCP_IPV6	UINT32_C(0x10)
+	/*
+	 * When this bit is '1', the RSS hash shall be computed
+	 * over source/destination IPv6 addresses and
+	 * source/destination ports of UDP/IPv6 packets.
+	 */
+	#define HWRM_STRUCT_DATA_RSS_V2_HASH_TYPE_UDP_IPV6	UINT32_C(0x20)
+	/* Hash key. This field is optional. */
+	uint64_t	hash_key_ring_group_ids;
+} hwrm_struct_data_rss_v2_t, *phwrm_struct_data_rss_v2_t;
+
+/* hwrm_struct_data_power_information (size:192b/24B) */
+
+typedef struct hwrm_struct_data_power_information {
+	/* Backup power information version */
+	uint32_t	bkup_power_info_ver;
+	/* Platform backup power count */
+	uint32_t	platform_bkup_power_count;
+	/* Load in milliwatts */
+	uint32_t	load_milli_watt;
+	/* Backup time in milliseconds */
+	uint32_t	bkup_time_milli_seconds;
+	/* Backup power status */
+	uint32_t	bkup_power_status;
+	/* Backup power charge time */
+	uint32_t	bkup_power_charge_time;
+} hwrm_struct_data_power_information_t, *phwrm_struct_data_power_information_t;
+
+/* hwrm_struct_data_msix_per_vf (size:320b/40B) */
+
+typedef struct hwrm_struct_data_msix_per_vf {
+	/* PF ID */
+	uint16_t	pf_id;
+	/* Number of rows in table. */
+	uint16_t	count;
+	uint32_t	unused_0;
+	/* Starting VF for row 0 */
+	uint16_t	start_vf_0;
+	/* MSI-X vectors per VF for row 0 */
+	uint16_t	msix_0;
+	/* Starting VF for row 1 */
+	uint16_t	start_vf_1;
+	/* MSI-X vectors per VF for row 1 */
+	uint16_t	msix_1;
+	/* Starting VF for row 2 */
+	uint16_t	start_vf_2;
+	/* MSI-X vectors per VF for row 2 */
+	uint16_t	msix_2;
+	/* Starting VF for row 3 */
+	uint16_t	start_vf_3;
+	/* MSI-X vectors per VF for row 3 */
+	uint16_t	msix_3;
+	/* Starting VF for row 4 */
+	uint16_t	start_vf_4;
+	/* MSI-X vectors per VF for row 4 */
+	uint16_t	msix_4;
+	/* Starting VF for row 5 */
+	uint16_t	start_vf_5;
+	/* MSI-X vectors per VF for row 5 */
+	uint16_t	msix_5;
+	/* Starting VF for row 6 */
+	uint16_t	start_vf_6;
+	/* MSI-X vectors per VF for row 6 */
+	uint16_t	msix_6;
+	/* Starting VF for row 7 */
+	uint16_t	start_vf_7;
+	/* MSI-X vectors per VF for row 7 */
+	uint16_t	msix_7;
+} hwrm_struct_data_msix_per_vf_t, *phwrm_struct_data_msix_per_vf_t;
 
-/****************************
- * hwrm_cfa_l2_filter_alloc *
- ****************************/
+/*******************************
+ * hwrm_fw_set_structured_data *
+ *******************************/
 
 
-/* hwrm_cfa_l2_filter_alloc_input (size:768b/96B) */
+/* hwrm_fw_set_structured_data_input (size:256b/32B) */
 
-typedef struct hwrm_cfa_l2_filter_alloc_input {
+typedef struct hwrm_fw_set_structured_data_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -32756,340 +60905,24 @@ typedef struct hwrm_cfa_l2_filter_alloc_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	flags;
-	/*
-	 * Enumeration denoting the RX, TX type of the resource.
-	 * This enumeration is used for resources that are similar for both
-	 * TX and RX paths of the chip.
-	 */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_PATH		UINT32_C(0x1)
-	/* tx path */
-		#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_PATH_TX		UINT32_C(0x0)
-	/* rx path */
-		#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_PATH_RX		UINT32_C(0x1)
-		#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_PATH_LAST	HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_PATH_RX
-	/*
-	 * Setting of this flag indicates the applicability to the loopback
-	 * path.
-	 */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_LOOPBACK	UINT32_C(0x2)
-	/*
-	 * Setting of this flag indicates drop action. If this flag is not
-	 * set, then it should be considered accept action.
-	 */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_DROP		UINT32_C(0x4)
-	/*
-	 * If this flag is set, all t_l2_* fields are invalid
-	 * and they should not be specified.
-	 * If this flag is set, then l2_* fields refer to
-	 * fields of outermost L2 header.
-	 */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_OUTERMOST	UINT32_C(0x8)
-	/*
-	 * Enumeration denoting NO_ROCE_L2 to support old drivers.
-	 * New driver L2 for only L2 traffic, ROCE for roce and l2 traffic
-	 */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_TRAFFIC_MASK	UINT32_C(0x30)
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_TRAFFIC_SFT	4
-	/* To support old drivers */
-		#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_TRAFFIC_NO_ROCE_L2  (UINT32_C(0x0) << 4)
-	/* Only L2 traffic */
-		#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_TRAFFIC_L2	(UINT32_C(0x1) << 4)
-	/* Roce & L2 traffic */
-		#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_TRAFFIC_ROCE	(UINT32_C(0x2) << 4)
-		#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_TRAFFIC_LAST	HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_TRAFFIC_ROCE
-	/*
-	 * Setting of this flag indicates that no XDP filter is created with
-	 * L2 filter.
-	 * 0 - legacy behavior, XDP filter is created with L2 filter
-	 * 1 - XDP filter won't be created with L2 filter
-	 */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_XDP_DISABLE	UINT32_C(0x40)
-	/*
-	 * Setting this flag to 1 indicate the L2 fields in this command
-	 * pertain to source fields. Setting this flag to 0 indicate the
-	 * L2 fields in this command pertain to the destination fields
-	 * and this is the default/legacy behavior.
-	 */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_SOURCE_VALID	UINT32_C(0x80)
-	uint32_t	enables;
-	/*
-	 * This bit must be '1' for the l2_addr field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR		UINT32_C(0x1)
-	/*
-	 * This bit must be '1' for the l2_addr_mask field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR_MASK	UINT32_C(0x2)
-	/*
-	 * This bit must be '1' for the l2_ovlan field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_OVLAN		UINT32_C(0x4)
-	/*
-	 * This bit must be '1' for the l2_ovlan_mask field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_OVLAN_MASK	UINT32_C(0x8)
-	/*
-	 * This bit must be '1' for the l2_ivlan field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_IVLAN		UINT32_C(0x10)
-	/*
-	 * This bit must be '1' for the l2_ivlan_mask field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_IVLAN_MASK	UINT32_C(0x20)
-	/*
-	 * This bit must be '1' for the t_l2_addr field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_T_L2_ADDR	UINT32_C(0x40)
-	/*
-	 * This bit must be '1' for the t_l2_addr_mask field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_T_L2_ADDR_MASK	UINT32_C(0x80)
-	/*
-	 * This bit must be '1' for the t_l2_ovlan field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_T_L2_OVLAN	UINT32_C(0x100)
-	/*
-	 * This bit must be '1' for the t_l2_ovlan_mask field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_T_L2_OVLAN_MASK	UINT32_C(0x200)
-	/*
-	 * This bit must be '1' for the t_l2_ivlan field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_T_L2_IVLAN	UINT32_C(0x400)
-	/*
-	 * This bit must be '1' for the t_l2_ivlan_mask field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_T_L2_IVLAN_MASK	UINT32_C(0x800)
-	/*
-	 * This bit must be '1' for the src_type field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_SRC_TYPE		UINT32_C(0x1000)
-	/*
-	 * This bit must be '1' for the src_id field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_SRC_ID		UINT32_C(0x2000)
-	/*
-	 * This bit must be '1' for the tunnel_type field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_TUNNEL_TYPE	UINT32_C(0x4000)
-	/*
-	 * This bit must be '1' for the dst_id field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_DST_ID		UINT32_C(0x8000)
-	/*
-	 * This bit must be '1' for the mirror_vnic_id field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_MIRROR_VNIC_ID	UINT32_C(0x10000)
-	/*
-	 * This bit must be '1' for the num_vlans field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_NUM_VLANS	UINT32_C(0x20000)
-	/*
-	 * This bit must be '1' for the t_num_vlans field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_T_NUM_VLANS	UINT32_C(0x40000)
-	/*
-	 * This value sets the match value for the L2 MAC address.
-	 * Destination MAC address for RX path.
-	 * Source MAC address for TX path.
-	 */
-	uint8_t	l2_addr[6];
-	/* This value sets the match value for the number of VLANs. */
-	uint8_t	num_vlans;
-	/*
-	 * This value sets the match value for the number of VLANs
-	 * in the tunnel headers.
-	 */
-	uint8_t	t_num_vlans;
-	/*
-	 * This value sets the mask value for the L2 address.
-	 * A value of 0 will mask the corresponding bit from
-	 * compare.
-	 */
-	uint8_t	l2_addr_mask[6];
-	/* This value sets VLAN ID value for outer VLAN. */
-	uint16_t	l2_ovlan;
-	/*
-	 * This value sets the mask value for the ovlan id.
-	 * A value of 0 will mask the corresponding bit from
-	 * compare.
-	 */
-	uint16_t	l2_ovlan_mask;
-	/* This value sets VLAN ID value for inner VLAN. */
-	uint16_t	l2_ivlan;
-	/*
-	 * This value sets the mask value for the ivlan id.
-	 * A value of 0 will mask the corresponding bit from
-	 * compare.
-	 */
-	uint16_t	l2_ivlan_mask;
-	uint8_t	unused_1[2];
-	/*
-	 * This value sets the match value for the tunnel
-	 * L2 MAC address.
-	 * Destination MAC address for RX path.
-	 * Source MAC address for TX path.
-	 */
-	uint8_t	t_l2_addr[6];
-	uint8_t	unused_2[2];
-	/*
-	 * This value sets the mask value for the tunnel L2
-	 * address.
-	 * A value of 0 will mask the corresponding bit from
-	 * compare.
-	 */
-	uint8_t	t_l2_addr_mask[6];
-	/* This value sets VLAN ID value for tunnel outer VLAN. */
-	uint16_t	t_l2_ovlan;
-	/*
-	 * This value sets the mask value for the tunnel ovlan id.
-	 * A value of 0 will mask the corresponding bit from
-	 * compare.
-	 */
-	uint16_t	t_l2_ovlan_mask;
-	/* This value sets VLAN ID value for tunnel inner VLAN. */
-	uint16_t	t_l2_ivlan;
-	/*
-	 * This value sets the mask value for the tunnel ivlan id.
-	 * A value of 0 will mask the corresponding bit from
-	 * compare.
-	 */
-	uint16_t	t_l2_ivlan_mask;
-	/* This value identifies the type of source of the packet. */
-	uint8_t	src_type;
-	/* Network port */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_SRC_TYPE_NPORT UINT32_C(0x0)
-	/* Physical function */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_SRC_TYPE_PF	UINT32_C(0x1)
-	/* Virtual function */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_SRC_TYPE_VF	UINT32_C(0x2)
-	/* Virtual NIC of a function */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_SRC_TYPE_VNIC  UINT32_C(0x3)
-	/* Embedded processor for CFA management */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_SRC_TYPE_KONG  UINT32_C(0x4)
-	/* Embedded processor for OOB management */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_SRC_TYPE_APE   UINT32_C(0x5)
-	/* Embedded processor for RoCE */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_SRC_TYPE_BONO  UINT32_C(0x6)
-	/* Embedded processor for network proxy functions */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_SRC_TYPE_TANG  UINT32_C(0x7)
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_SRC_TYPE_LAST HWRM_CFA_L2_FILTER_ALLOC_INPUT_SRC_TYPE_TANG
-	uint8_t	unused_3;
-	/*
-	 * This value is the id of the source.
-	 * For a network port, it represents port_id.
-	 * For a physical function, it represents fid.
-	 * For a virtual function, it represents vf_id.
-	 * For a vnic, it represents vnic_id.
-	 * For embedded processors, this id is not valid.
-	 *
-	 * Notes:
-	 * 1. The function ID is implied if it src_id is
-	 *	not provided for a src_type that is either
-	 */
-	uint32_t	src_id;
-	/* Tunnel Type. */
-	uint8_t	tunnel_type;
-	/* Non-tunnel */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_TUNNEL_TYPE_NONTUNNEL	UINT32_C(0x0)
-	/* Virtual eXtensible Local Area Network (VXLAN) */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_TUNNEL_TYPE_VXLAN	UINT32_C(0x1)
-	/* Network Virtualization Generic Routing Encapsulation (NVGRE) */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_TUNNEL_TYPE_NVGRE	UINT32_C(0x2)
-	/* Generic Routing Encapsulation (GRE) inside Ethernet payload */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_TUNNEL_TYPE_L2GRE	UINT32_C(0x3)
-	/* IP in IP */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_TUNNEL_TYPE_IPIP	UINT32_C(0x4)
-	/* Generic Network Virtualization Encapsulation (Geneve) */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_TUNNEL_TYPE_GENEVE	UINT32_C(0x5)
-	/* Multi-Protocol Label Switching (MPLS) */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_TUNNEL_TYPE_MPLS	UINT32_C(0x6)
-	/* Stateless Transport Tunnel (STT) */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_TUNNEL_TYPE_STT	UINT32_C(0x7)
-	/* Generic Routing Encapsulation (GRE) inside IP datagram payload */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_TUNNEL_TYPE_IPGRE	UINT32_C(0x8)
-	/* IPV4 over virtual eXtensible Local Area Network (IPV4oVXLAN) */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_V4	UINT32_C(0x9)
 	/*
-	 * Enhance Generic Routing Encapsulation (GRE version 1) inside IP
-	 * datagram payload
-	 */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_TUNNEL_TYPE_IPGRE_V1	UINT32_C(0xa)
-	/* Use fixed layer 2 ether type of 0xFFFF */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_TUNNEL_TYPE_L2_ETYPE	UINT32_C(0xb)
-	/*
-	 * IPV6 over virtual eXtensible Local Area Network with GPE header
-	 * (IPV6oVXLANGPE)
-	 */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_GPE_V6 UINT32_C(0xc)
-	/* Any tunneled traffic */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_TUNNEL_TYPE_ANYTUNNEL	UINT32_C(0xff)
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_TUNNEL_TYPE_LAST	HWRM_CFA_L2_FILTER_ALLOC_INPUT_TUNNEL_TYPE_ANYTUNNEL
-	uint8_t	unused_4;
-	/*
-	 * If set, this value shall represent the
-	 * Logical VNIC ID of the destination VNIC for the RX
-	 * path and network port id of the destination port for
-	 * the TX path.
-	 */
-	uint16_t	dst_id;
-	/*
-	 * Logical VNIC ID of the VNIC where traffic is
-	 * mirrored.
-	 */
-	uint16_t	mirror_vnic_id;
-	/*
-	 * This hint is provided to help in placing
-	 * the filter in the filter table.
+	 * This is the host address where
+	 * structured data will be copied from
 	 */
-	uint8_t	pri_hint;
-	/* No preference */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_PRI_HINT_NO_PREFER	UINT32_C(0x0)
-	/* Above the given filter */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_PRI_HINT_ABOVE_FILTER UINT32_C(0x1)
-	/* Below the given filter */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_PRI_HINT_BELOW_FILTER UINT32_C(0x2)
-	/* As high as possible */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_PRI_HINT_MAX	UINT32_C(0x3)
-	/* As low as possible */
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_PRI_HINT_MIN	UINT32_C(0x4)
-	#define HWRM_CFA_L2_FILTER_ALLOC_INPUT_PRI_HINT_LAST	HWRM_CFA_L2_FILTER_ALLOC_INPUT_PRI_HINT_MIN
-	uint8_t	unused_5;
-	uint32_t	unused_6;
+	uint64_t	src_data_addr;
+	/* size of data in bytes */
+	uint16_t	data_len;
 	/*
-	 * This is the ID of the filter that goes along with
-	 * the pri_hint.
-	 *
-	 * This field is valid only for the following values.
-	 * 1 - Above the given filter
-	 * 2 - Below the given filter
+	 * a count of the number of Structured Data Headers in the data
+	 * pointed by src_data_addr.
 	 */
-	uint64_t	l2_filter_id_hint;
-} hwrm_cfa_l2_filter_alloc_input_t, *phwrm_cfa_l2_filter_alloc_input_t;
+	uint8_t	hdr_cnt;
+	uint8_t	unused_0[5];
+} hwrm_fw_set_structured_data_input_t, *phwrm_fw_set_structured_data_input_t;
 
-/* hwrm_cfa_l2_filter_alloc_output (size:192b/24B) */
+/* hwrm_fw_set_structured_data_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_l2_filter_alloc_output {
+typedef struct hwrm_fw_set_structured_data_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -33098,62 +60931,45 @@ typedef struct hwrm_cfa_l2_filter_alloc_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/*
-	 * This value identifies a set of CFA data structures used for an L2
-	 * context.
-	 */
-	uint64_t	l2_filter_id;
-	/*
-	 * The flow id value in bit 0-29 is the actual ID of the flow
-	 * associated with this filter and it shall be used to match
-	 * and associate the flow identifier returned in completion
-	 * records. A value of 0xFFFFFFFF in the 32-bit flow_id field
-	 * shall indicate no valid flow id.
-	 */
-	uint32_t	flow_id;
-	/* Indicate the flow id value. */
-	#define HWRM_CFA_L2_FILTER_ALLOC_OUTPUT_FLOW_ID_VALUE_MASK UINT32_C(0x3fffffff)
-	#define HWRM_CFA_L2_FILTER_ALLOC_OUTPUT_FLOW_ID_VALUE_SFT 0
-	/* Indicate type of the flow. */
-	#define HWRM_CFA_L2_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE	UINT32_C(0x40000000)
-	/*
-	 * If this bit set to 0, then it indicates that the flow is
-	 * internal flow.
-	 */
-		#define HWRM_CFA_L2_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE_INT	(UINT32_C(0x0) << 30)
-	/*
-	 * If this bit is set to 1, then it indicates that the flow is
-	 * external flow.
-	 */
-		#define HWRM_CFA_L2_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE_EXT	(UINT32_C(0x1) << 30)
-		#define HWRM_CFA_L2_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE_LAST  HWRM_CFA_L2_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE_EXT
-	/* Indicate the flow direction. */
-	#define HWRM_CFA_L2_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR	UINT32_C(0x80000000)
-	/* If this bit set to 0, then it indicates rx flow. */
-		#define HWRM_CFA_L2_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR_RX	(UINT32_C(0x0) << 31)
-	/* If this bit is set to 1, then it indicates that tx flow. */
-		#define HWRM_CFA_L2_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR_TX	(UINT32_C(0x1) << 31)
-		#define HWRM_CFA_L2_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR_LAST   HWRM_CFA_L2_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR_TX
-	uint8_t	unused_0[3];
+	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_l2_filter_alloc_output_t, *phwrm_cfa_l2_filter_alloc_output_t;
+} hwrm_fw_set_structured_data_output_t, *phwrm_fw_set_structured_data_output_t;
 
-/***************************
- * hwrm_cfa_l2_filter_free *
- ***************************/
+/* hwrm_fw_set_structured_data_cmd_err (size:64b/8B) */
+
+typedef struct hwrm_fw_set_structured_data_cmd_err {
+	/*
+	 * command specific error codes that goes to
+	 * the cmd_err field in Common HWRM Error Response.
+	 */
+	uint8_t	code;
+	/* Unknown error */
+	#define HWRM_FW_SET_STRUCTURED_DATA_CMD_ERR_CODE_UNKNOWN	UINT32_C(0x0)
+	/* count_of_headers is incorrect */
+	#define HWRM_FW_SET_STRUCTURED_DATA_CMD_ERR_CODE_BAD_HDR_CNT UINT32_C(0x1)
+	/* data improperly formatted */
+	#define HWRM_FW_SET_STRUCTURED_DATA_CMD_ERR_CODE_BAD_FMT	UINT32_C(0x2)
+	/* unknown structure ID(s) */
+	#define HWRM_FW_SET_STRUCTURED_DATA_CMD_ERR_CODE_BAD_ID	UINT32_C(0x3)
+	#define HWRM_FW_SET_STRUCTURED_DATA_CMD_ERR_CODE_LAST	HWRM_FW_SET_STRUCTURED_DATA_CMD_ERR_CODE_BAD_ID
+	uint8_t	unused_0[7];
+} hwrm_fw_set_structured_data_cmd_err_t, *phwrm_fw_set_structured_data_cmd_err_t;
+
+/*******************************
+ * hwrm_fw_get_structured_data *
+ *******************************/
 
 
-/* hwrm_cfa_l2_filter_free_input (size:192b/24B) */
+/* hwrm_fw_get_structured_data_input (size:256b/32B) */
 
-typedef struct hwrm_cfa_l2_filter_free_input {
+typedef struct hwrm_fw_get_structured_data_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -33183,15 +60999,50 @@ typedef struct hwrm_cfa_l2_filter_free_input {
 	 */
 	uint64_t	resp_addr;
 	/*
-	 * This value identifies a set of CFA data structures used for an L2
-	 * context.
+	 * This is the host address where
+	 * structured data will be copied to
 	 */
-	uint64_t	l2_filter_id;
-} hwrm_cfa_l2_filter_free_input_t, *phwrm_cfa_l2_filter_free_input_t;
+	uint64_t	dest_data_addr;
+	/* size of data in bytes */
+	uint16_t	data_len;
+	/*
+	 * Structure_id is the id of the structure data requesting and count is
+	 * a requested number of instances of this data requested. The actual
+	 * number will be returned in count_of_headers
+	 */
+	uint16_t	structure_id;
+	/*
+	 * Subtype is an optional field used to specify additional information
+	 * of the data being retrieved. For example, if data can be categorized
+	 * as "live" vs "saved" then this field can be used to provide an
+	 * indication of "saved" vs "live" data. Not all structured data
+	 * supports subtypes and if they are supported then the structured data
+	 * will specify the valid values. If structured data is requested that
+	 * supports subtypes but no subtype is given then it is implementation
+	 * specific what will be returned. Some structure data can support a
+	 * subtype of "All" which would cause a list of structures to be
+	 * returned for all supported subtypes. "All" is only used on the
+	 * hwrm_get_structured_data command.
+	 */
+	uint16_t	subtype;
+	#define HWRM_FW_GET_STRUCTURED_DATA_INPUT_SUBTYPE_UNUSED		UINT32_C(0x0)
+	#define HWRM_FW_GET_STRUCTURED_DATA_INPUT_SUBTYPE_ALL			UINT32_C(0xffff)
+	#define HWRM_FW_GET_STRUCTURED_DATA_INPUT_SUBTYPE_NEAR_BRIDGE_ADMIN	UINT32_C(0x100)
+	#define HWRM_FW_GET_STRUCTURED_DATA_INPUT_SUBTYPE_NEAR_BRIDGE_PEER	UINT32_C(0x101)
+	#define HWRM_FW_GET_STRUCTURED_DATA_INPUT_SUBTYPE_NEAR_BRIDGE_OPERATIONAL UINT32_C(0x102)
+	#define HWRM_FW_GET_STRUCTURED_DATA_INPUT_SUBTYPE_NON_TPMR_ADMIN	UINT32_C(0x200)
+	#define HWRM_FW_GET_STRUCTURED_DATA_INPUT_SUBTYPE_NON_TPMR_PEER	UINT32_C(0x201)
+	#define HWRM_FW_GET_STRUCTURED_DATA_INPUT_SUBTYPE_NON_TPMR_OPERATIONAL	UINT32_C(0x202)
+	#define HWRM_FW_GET_STRUCTURED_DATA_INPUT_SUBTYPE_HOST_OPERATIONAL	UINT32_C(0x300)
+	#define HWRM_FW_GET_STRUCTURED_DATA_INPUT_SUBTYPE_LAST		HWRM_FW_GET_STRUCTURED_DATA_INPUT_SUBTYPE_HOST_OPERATIONAL
+	/* Number of elements. This allows support of arrayed data */
+	uint8_t	count;
+	uint8_t	unused_0;
+} hwrm_fw_get_structured_data_input_t, *phwrm_fw_get_structured_data_input_t;
 
-/* hwrm_cfa_l2_filter_free_output (size:128b/16B) */
+/* hwrm_fw_get_structured_data_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_l2_filter_free_output {
+typedef struct hwrm_fw_get_structured_data_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -33200,26 +61051,46 @@ typedef struct hwrm_cfa_l2_filter_free_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	/*
+	 * a count of the number of Structured Data Headers in the data
+	 * pointed by dest_data_addr.
+	 */
+	uint8_t	hdr_cnt;
+	uint8_t	unused_0[6];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_l2_filter_free_output_t, *phwrm_cfa_l2_filter_free_output_t;
+} hwrm_fw_get_structured_data_output_t, *phwrm_fw_get_structured_data_output_t;
 
-/**************************
- * hwrm_cfa_l2_filter_cfg *
- **************************/
+/* hwrm_fw_get_structured_data_cmd_err (size:64b/8B) */
+
+typedef struct hwrm_fw_get_structured_data_cmd_err {
+	/*
+	 * command specific error codes that goes to
+	 * the cmd_err field in Common HWRM Error Response.
+	 */
+	uint8_t	code;
+	/* Unknown error */
+	#define HWRM_FW_GET_STRUCTURED_DATA_CMD_ERR_CODE_UNKNOWN UINT32_C(0x0)
+	/* unknown structure ID(s) */
+	#define HWRM_FW_GET_STRUCTURED_DATA_CMD_ERR_CODE_BAD_ID  UINT32_C(0x3)
+	#define HWRM_FW_GET_STRUCTURED_DATA_CMD_ERR_CODE_LAST   HWRM_FW_GET_STRUCTURED_DATA_CMD_ERR_CODE_BAD_ID
+	uint8_t	unused_0[7];
+} hwrm_fw_get_structured_data_cmd_err_t, *phwrm_fw_get_structured_data_cmd_err_t;
+
+/*******************
+ * hwrm_fw_ipc_msg *
+ *******************/
 
 
-/* hwrm_cfa_l2_filter_cfg_input (size:320b/40B) */
+/* hwrm_fw_ipc_msg_input (size:320b/40B) */
 
-typedef struct hwrm_cfa_l2_filter_cfg_input {
+typedef struct hwrm_fw_ipc_msg_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -33248,69 +61119,60 @@ typedef struct hwrm_cfa_l2_filter_cfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	flags;
-	/*
-	 * Enumeration denoting the RX, TX type of the resource.
-	 * This enumeration is used for resources that are similar for both
-	 * TX and RX paths of the chip.
-	 */
-	#define HWRM_CFA_L2_FILTER_CFG_INPUT_FLAGS_PATH		UINT32_C(0x1)
-	/* tx path */
-		#define HWRM_CFA_L2_FILTER_CFG_INPUT_FLAGS_PATH_TX		UINT32_C(0x0)
-	/* rx path */
-		#define HWRM_CFA_L2_FILTER_CFG_INPUT_FLAGS_PATH_RX		UINT32_C(0x1)
-		#define HWRM_CFA_L2_FILTER_CFG_INPUT_FLAGS_PATH_LAST	HWRM_CFA_L2_FILTER_CFG_INPUT_FLAGS_PATH_RX
-	/*
-	 * Setting of this flag indicates drop action. If this flag is not
-	 * set, then it should be considered accept action.
-	 */
-	#define HWRM_CFA_L2_FILTER_CFG_INPUT_FLAGS_DROP		UINT32_C(0x2)
-	/*
-	 * Enumeration denoting NO_ROCE_L2 to support old drivers.
-	 * New driver L2 for only L2 traffic, ROCE for roce and l2 traffic
-	 */
-	#define HWRM_CFA_L2_FILTER_CFG_INPUT_FLAGS_TRAFFIC_MASK	UINT32_C(0xc)
-	#define HWRM_CFA_L2_FILTER_CFG_INPUT_FLAGS_TRAFFIC_SFT	2
-	/* To support old drivers */
-		#define HWRM_CFA_L2_FILTER_CFG_INPUT_FLAGS_TRAFFIC_NO_ROCE_L2  (UINT32_C(0x0) << 2)
-	/* Only L2 traffic */
-		#define HWRM_CFA_L2_FILTER_CFG_INPUT_FLAGS_TRAFFIC_L2	(UINT32_C(0x1) << 2)
-	/* Roce & L2 traffic */
-		#define HWRM_CFA_L2_FILTER_CFG_INPUT_FLAGS_TRAFFIC_ROCE	(UINT32_C(0x2) << 2)
-		#define HWRM_CFA_L2_FILTER_CFG_INPUT_FLAGS_TRAFFIC_LAST	HWRM_CFA_L2_FILTER_CFG_INPUT_FLAGS_TRAFFIC_ROCE
 	uint32_t	enables;
 	/*
-	 * This bit must be '1' for the dst_id field to be
+	 * This bit must be '1' for the command_id field to be
 	 * configured.
 	 */
-	#define HWRM_CFA_L2_FILTER_CFG_INPUT_ENABLES_DST_ID		UINT32_C(0x1)
+	#define HWRM_FW_IPC_MSG_INPUT_ENABLES_COMMAND_ID	UINT32_C(0x1)
 	/*
-	 * This bit must be '1' for the new_mirror_vnic_id field to be
+	 * This bit must be '1' for the src_processor field to be
 	 * configured.
 	 */
-	#define HWRM_CFA_L2_FILTER_CFG_INPUT_ENABLES_NEW_MIRROR_VNIC_ID	UINT32_C(0x2)
-	/*
-	 * This value identifies a set of CFA data structures used for an L2
-	 * context.
-	 */
-	uint64_t	l2_filter_id;
+	#define HWRM_FW_IPC_MSG_INPUT_ENABLES_SRC_PROCESSOR	UINT32_C(0x2)
 	/*
-	 * If set, this value shall represent the
-	 * Logical VNIC ID of the destination VNIC for the RX
-	 * path and network port id of the destination port for
-	 * the TX path.
+	 * This bit must be '1' for the data_offset field to be
+	 * configured.
 	 */
-	uint32_t	dst_id;
+	#define HWRM_FW_IPC_MSG_INPUT_ENABLES_DATA_OFFSET	UINT32_C(0x4)
 	/*
-	 * New Logical VNIC ID of the VNIC where traffic is
-	 * mirrored.
+	 * This bit must be '1' for the length field to be
+	 * configured.
 	 */
-	uint32_t	new_mirror_vnic_id;
-} hwrm_cfa_l2_filter_cfg_input_t, *phwrm_cfa_l2_filter_cfg_input_t;
+	#define HWRM_FW_IPC_MSG_INPUT_ENABLES_LENGTH		UINT32_C(0x8)
+	/* Command ID */
+	uint16_t	command_id;
+	/* RoCE LAG message */
+	#define HWRM_FW_IPC_MSG_INPUT_COMMAND_ID_ROCE_LAG	UINT32_C(0x1)
+	/* Query information on PF mapping for x86 and MAIA. */
+	#define HWRM_FW_IPC_MSG_INPUT_COMMAND_ID_MHB_HOST	UINT32_C(0x2)
+	/* RoCE driver version details to be sent to chimp */
+	#define HWRM_FW_IPC_MSG_INPUT_COMMAND_ID_ROCE_DRVR_VERSION UINT32_C(0x3)
+	#define HWRM_FW_IPC_MSG_INPUT_COMMAND_ID_LAST		HWRM_FW_IPC_MSG_INPUT_COMMAND_ID_ROCE_DRVR_VERSION
+	/* Source processor for this command. */
+	uint8_t	src_processor;
+	/* Chimp processor */
+	#define HWRM_FW_IPC_MSG_INPUT_SRC_PROCESSOR_CFW  UINT32_C(0x1)
+	/* BONO processor */
+	#define HWRM_FW_IPC_MSG_INPUT_SRC_PROCESSOR_BONO UINT32_C(0x2)
+	/* APE processor */
+	#define HWRM_FW_IPC_MSG_INPUT_SRC_PROCESSOR_APE  UINT32_C(0x3)
+	/* KONG processor */
+	#define HWRM_FW_IPC_MSG_INPUT_SRC_PROCESSOR_KONG UINT32_C(0x4)
+	#define HWRM_FW_IPC_MSG_INPUT_SRC_PROCESSOR_LAST HWRM_FW_IPC_MSG_INPUT_SRC_PROCESSOR_KONG
+	uint8_t	unused_0;
+	/* Offset of the data in the source processor memory. */
+	uint32_t	data_offset;
+	/* Length of the data in source processor. */
+	uint16_t	length;
+	uint8_t	unused_1[2];
+	/* This is for storing FW opaque data. */
+	uint64_t	opaque;
+} hwrm_fw_ipc_msg_input_t, *phwrm_fw_ipc_msg_input_t;
 
-/* hwrm_cfa_l2_filter_cfg_output (size:128b/16B) */
+/* hwrm_fw_ipc_msg_output (size:256b/32B) */
 
-typedef struct hwrm_cfa_l2_filter_cfg_output {
+typedef struct hwrm_fw_ipc_msg_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -33319,26 +61181,28 @@ typedef struct hwrm_cfa_l2_filter_cfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	uint32_t	msg_data_1;
+	uint32_t	msg_data_2;
+	uint64_t	reserved64;
+	uint8_t	reserved48[7];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_l2_filter_cfg_output_t, *phwrm_cfa_l2_filter_cfg_output_t;
+} hwrm_fw_ipc_msg_output_t, *phwrm_fw_ipc_msg_output_t;
 
-/***************************
- * hwrm_cfa_l2_set_rx_mask *
- ***************************/
+/***********************
+ * hwrm_fw_ipc_mailbox *
+ ***********************/
 
 
-/* hwrm_cfa_l2_set_rx_mask_input (size:448b/56B) */
+/* hwrm_fw_ipc_mailbox_input (size:256b/32B) */
 
-typedef struct hwrm_cfa_l2_set_rx_mask_input {
+typedef struct hwrm_fw_ipc_mailbox_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -33367,127 +61231,23 @@ typedef struct hwrm_cfa_l2_set_rx_mask_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* VNIC ID */
-	uint32_t	vnic_id;
-	uint32_t	mask;
-	/*
-	 * When this bit is '1', the function is requested to accept
-	 * multi-cast packets specified by the multicast addr table.
-	 */
-	#define HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_MCAST		UINT32_C(0x2)
-	/*
-	 * When this bit is '1', the function is requested to accept
-	 * all multi-cast packets.
-	 */
-	#define HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_ALL_MCAST	UINT32_C(0x4)
-	/*
-	 * When this bit is '1', the function is requested to accept
-	 * broadcast packets.
-	 */
-	#define HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_BCAST		UINT32_C(0x8)
-	/*
-	 * When this bit is '1', the function is requested to be
-	 * put in the promiscuous mode.
-	 *
-	 * The HWRM should accept any function to set up
-	 * promiscuous mode.
-	 *
-	 * The HWRM shall follow the semantics below for the
-	 * promiscuous mode support.
-	 * # When partitioning is not enabled on a port
-	 * (i.e. single PF on the port), then the PF shall
-	 * be allowed to be in the promiscuous mode. When the
-	 * PF is in the promiscuous mode, then it shall
-	 * receive all host bound traffic on that port.
-	 * # When partitioning is enabled on a port
-	 * (i.e. multiple PFs per port) and a PF on that
-	 * port is in the promiscuous mode, then the PF
-	 * receives all traffic within that partition as
-	 * identified by a unique identifier for the
-	 * PF (e.g. S-Tag). If a unique outer VLAN
-	 * for the PF is specified, then the setting of
-	 * promiscuous mode on that PF shall result in the
-	 * PF receiving all host bound traffic with matching
-	 * outer VLAN.
-	 * # A VF shall can be set in the promiscuous mode.
-	 * In the promiscuous mode, the VF does not receive any
-	 * traffic unless a unique outer VLAN for the
-	 * VF is specified. If a unique outer VLAN
-	 * for the VF is specified, then the setting of
-	 * promiscuous mode on that VF shall result in the
-	 * VF receiving all host bound traffic with the
-	 * matching outer VLAN.
-	 * # The HWRM shall allow the setting of promiscuous
-	 * mode on a function independently from the
-	 * promiscuous mode settings on other functions.
-	 */
-	#define HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_PROMISCUOUS	UINT32_C(0x10)
-	/*
-	 * If this flag is set, the corresponding RX
-	 * filters shall be set up to cover multicast/broadcast
-	 * filters for the outermost Layer 2 destination MAC
-	 * address field.
-	 */
-	#define HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_OUTERMOST	UINT32_C(0x20)
-	/*
-	 * If this flag is set, the corresponding RX
-	 * filters shall be set up to cover multicast/broadcast
-	 * filters for the VLAN-tagged packets that match the
-	 * TPID and VID fields of VLAN tags in the VLAN tag
-	 * table specified in this command.
-	 */
-	#define HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_VLANONLY		UINT32_C(0x40)
-	/*
-	 * If this flag is set, the corresponding RX
-	 * filters shall be set up to cover multicast/broadcast
-	 * filters for non-VLAN tagged packets and VLAN-tagged
-	 * packets that match the TPID and VID fields of VLAN
-	 * tags in the VLAN tag table specified in this command.
-	 */
-	#define HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_VLAN_NONVLAN	UINT32_C(0x80)
-	/*
-	 * If this flag is set, the corresponding RX
-	 * filters shall be set up to cover multicast/broadcast
-	 * filters for non-VLAN tagged packets and VLAN-tagged
-	 * packets matching any VLAN tag.
-	 *
-	 * If this flag is set, then the HWRM shall ignore
-	 * VLAN tags specified in vlan_tag_tbl.
-	 *
-	 * If none of vlanonly, vlan_nonvlan, and anyvlan_nonvlan
-	 * flags is set, then the HWRM shall ignore
-	 * VLAN tags specified in vlan_tag_tbl.
-	 *
-	 * The HWRM client shall set at most one flag out of
-	 * vlanonly, vlan_nonvlan, and anyvlan_nonvlan.
-	 */
-	#define HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_ANYVLAN_NONVLAN	UINT32_C(0x100)
-	/* This is the address for mcast address tbl. */
-	uint64_t	mc_tbl_addr;
-	/*
-	 * This value indicates how many entries in mc_tbl are valid.
-	 * Each entry is 6 bytes.
-	 */
-	uint32_t	num_mc_entries;
+	uint8_t	flags;
+	/* unused is 8 b */
+	uint8_t	unused;
+	/* asynchronous event to hosts. */
+	uint8_t	event_id;
+	/* PORT ID */
+	uint8_t	port_id;
+	/* event data1 of asynchronous event */
+	uint32_t	event_data1;
+	/* event data2 of asynchronous event */
+	uint32_t	event_data2;
 	uint8_t	unused_0[4];
-	/*
-	 * This is the address for VLAN tag table.
-	 * Each VLAN entry in the table is 4 bytes of a VLAN tag
-	 * including TPID, PCP, DEI, and VID fields in network byte
-	 * order.
-	 */
-	uint64_t	vlan_tag_tbl_addr;
-	/*
-	 * This value indicates how many entries in vlan_tag_tbl are
-	 * valid. Each entry is 4 bytes.
-	 */
-	uint32_t	num_vlan_tags;
-	uint8_t	unused_1[4];
-} hwrm_cfa_l2_set_rx_mask_input_t, *phwrm_cfa_l2_set_rx_mask_input_t;
+} hwrm_fw_ipc_mailbox_input_t, *phwrm_fw_ipc_mailbox_input_t;
 
-/* hwrm_cfa_l2_set_rx_mask_output (size:128b/16B) */
+/* hwrm_fw_ipc_mailbox_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_l2_set_rx_mask_output {
+typedef struct hwrm_fw_ipc_mailbox_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -33500,38 +61260,37 @@ typedef struct hwrm_cfa_l2_set_rx_mask_output {
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_l2_set_rx_mask_output_t, *phwrm_cfa_l2_set_rx_mask_output_t;
+} hwrm_fw_ipc_mailbox_output_t, *phwrm_fw_ipc_mailbox_output_t;
 
-/* hwrm_cfa_l2_set_rx_mask_cmd_err (size:64b/8B) */
+/* hwrm_fw_ipc_mailbox_cmd_err (size:64b/8B) */
 
-typedef struct hwrm_cfa_l2_set_rx_mask_cmd_err {
+typedef struct hwrm_fw_ipc_mailbox_cmd_err {
 	/*
 	 * command specific error codes that goes to
 	 * the cmd_err field in Common HWRM Error Response.
 	 */
 	uint8_t	code;
 	/* Unknown error */
-	#define HWRM_CFA_L2_SET_RX_MASK_CMD_ERR_CODE_UNKNOWN			UINT32_C(0x0)
-	/* Unable to complete operation due to conflict with Ntuple Filter */
-	#define HWRM_CFA_L2_SET_RX_MASK_CMD_ERR_CODE_NTUPLE_FILTER_CONFLICT_ERR UINT32_C(0x1)
-	#define HWRM_CFA_L2_SET_RX_MASK_CMD_ERR_CODE_LAST			HWRM_CFA_L2_SET_RX_MASK_CMD_ERR_CODE_NTUPLE_FILTER_CONFLICT_ERR
+	#define HWRM_FW_IPC_MAILBOX_CMD_ERR_CODE_UNKNOWN UINT32_C(0x0)
+	/* invalid event */
+	#define HWRM_FW_IPC_MAILBOX_CMD_ERR_CODE_BAD_ID  UINT32_C(0x3)
+	#define HWRM_FW_IPC_MAILBOX_CMD_ERR_CODE_LAST   HWRM_FW_IPC_MAILBOX_CMD_ERR_CODE_BAD_ID
 	uint8_t	unused_0[7];
-} hwrm_cfa_l2_set_rx_mask_cmd_err_t, *phwrm_cfa_l2_set_rx_mask_cmd_err_t;
+} hwrm_fw_ipc_mailbox_cmd_err_t, *phwrm_fw_ipc_mailbox_cmd_err_t;
 
-/*******************************
- * hwrm_cfa_vlan_antispoof_cfg *
- *******************************/
+/*******************
+ * hwrm_fw_ecn_cfg *
+ *******************/
 
 
-/* hwrm_cfa_vlan_antispoof_cfg_input (size:256b/32B) */
+/* hwrm_fw_ecn_cfg_input (size:192b/24B) */
 
-typedef struct hwrm_cfa_vlan_antispoof_cfg_input {
+typedef struct hwrm_fw_ecn_cfg_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -33560,28 +61319,25 @@ typedef struct hwrm_cfa_vlan_antispoof_cfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
+	uint16_t	flags;
 	/*
-	 * Function ID of the function that is being configured.
-	 * Only valid for a VF FID configured by the PF.
-	 */
-	uint16_t	fid;
-	uint8_t	unused_0[2];
-	/* Number of VLAN entries in the vlan_tag_mask_tbl. */
-	uint32_t	num_vlan_entries;
-	/*
-	 * The vlan_tag_mask_tbl_addr is the DMA address of the VLAN
-	 * antispoof table. Each table entry contains the 16-bit TPID
-	 * (0x8100 or 0x88a8 only), 16-bit VLAN ID, and a 16-bit mask,
-	 * all in network order to match hwrm_cfa_l2_set_rx_mask.
-	 * For an individual VLAN entry, the mask value should be 0xfff
-	 * for the 12-bit VLAN ID.
+	 * When this bit is '1', Explicit Congestion Notification (ECN) is
+	 * enabled device-wide. When ECN is enabled on a multi-host system,
+	 * it is enabled for all hosts. This setting takes effect
+	 * immediately. When ECN is enabled, the firmware activates
+	 * additional receive Class of Service (CoS) queues that are enabled
+	 * for ECN marking and steers ECN-capable packets to those queues.
+	 * This setting is not saved persistently. To enable ECN
+	 * persistently, set NVM option 173, ENABLE_ECN.
+	 * Setting this bit to '0' disables ECN immediately.
 	 */
-	uint64_t	vlan_tag_mask_tbl_addr;
-} hwrm_cfa_vlan_antispoof_cfg_input_t, *phwrm_cfa_vlan_antispoof_cfg_input_t;
+	#define HWRM_FW_ECN_CFG_INPUT_FLAGS_ENABLE_ECN	UINT32_C(0x1)
+	uint8_t	unused_0[6];
+} hwrm_fw_ecn_cfg_input_t, *phwrm_fw_ecn_cfg_input_t;
 
-/* hwrm_cfa_vlan_antispoof_cfg_output (size:128b/16B) */
+/* hwrm_fw_ecn_cfg_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_vlan_antispoof_cfg_output {
+typedef struct hwrm_fw_ecn_cfg_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -33594,22 +61350,21 @@ typedef struct hwrm_cfa_vlan_antispoof_cfg_output {
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_vlan_antispoof_cfg_output_t, *phwrm_cfa_vlan_antispoof_cfg_output_t;
+} hwrm_fw_ecn_cfg_output_t, *phwrm_fw_ecn_cfg_output_t;
 
-/********************************
- * hwrm_cfa_vlan_antispoof_qcfg *
- ********************************/
+/********************
+ * hwrm_fw_ecn_qcfg *
+ ********************/
 
 
-/* hwrm_cfa_vlan_antispoof_qcfg_input (size:256b/32B) */
+/* hwrm_fw_ecn_qcfg_input (size:128b/16B) */
 
-typedef struct hwrm_cfa_vlan_antispoof_qcfg_input {
+typedef struct hwrm_fw_ecn_qcfg_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -33638,31 +61393,11 @@ typedef struct hwrm_cfa_vlan_antispoof_qcfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/*
-	 * Function ID of the function that is being queried.
-	 * Only valid for a VF FID queried by the PF.
-	 */
-	uint16_t	fid;
-	uint8_t	unused_0[2];
-	/*
-	 * Maximum number of VLAN entries the firmware is allowed to DMA
-	 * to vlan_tag_mask_tbl.
-	 */
-	uint32_t	max_vlan_entries;
-	/*
-	 * The vlan_tag_mask_tbl_addr is the DMA address of the VLAN
-	 * antispoof table to which firmware will DMA to. Each table
-	 * entry will contain the 16-bit TPID (0x8100 or 0x88a8 only),
-	 * 16-bit VLAN ID, and a 16-bit mask, all in network order to
-	 * match hwrm_cfa_l2_set_rx_mask. For an individual VLAN entry,
-	 * the mask value should be 0xfff for the 12-bit VLAN ID.
-	 */
-	uint64_t	vlan_tag_mask_tbl_addr;
-} hwrm_cfa_vlan_antispoof_qcfg_input_t, *phwrm_cfa_vlan_antispoof_qcfg_input_t;
+} hwrm_fw_ecn_qcfg_input_t, *phwrm_fw_ecn_qcfg_input_t;
 
-/* hwrm_cfa_vlan_antispoof_qcfg_output (size:128b/16B) */
+/* hwrm_fw_ecn_qcfg_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_vlan_antispoof_qcfg_output {
+typedef struct hwrm_fw_ecn_qcfg_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -33671,28 +61406,28 @@ typedef struct hwrm_cfa_vlan_antispoof_qcfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* Number of valid entries DMAd by firmware to vlan_tag_mask_tbl. */
-	uint32_t	num_vlan_entries;
-	uint8_t	unused_0[3];
+	uint16_t	flags;
+	/* When this bit is '1', ECN is enabled device-wide. */
+	#define HWRM_FW_ECN_QCFG_OUTPUT_FLAGS_ENABLE_ECN	UINT32_C(0x1)
+	uint8_t	unused_0[5];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_vlan_antispoof_qcfg_output_t, *phwrm_cfa_vlan_antispoof_qcfg_output_t;
+} hwrm_fw_ecn_qcfg_output_t, *phwrm_fw_ecn_qcfg_output_t;
 
-/********************************
- * hwrm_cfa_tunnel_filter_alloc *
- ********************************/
+/************************
+ * hwrm_fw_health_check *
+ ************************/
 
 
-/* hwrm_cfa_tunnel_filter_alloc_input (size:704b/88B) */
+/* hwrm_fw_health_check_input (size:128b/16B) */
 
-typedef struct hwrm_cfa_tunnel_filter_alloc_input {
+typedef struct hwrm_fw_health_check_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -33721,261 +61456,126 @@ typedef struct hwrm_cfa_tunnel_filter_alloc_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	flags;
-	/*
-	 * Setting of this flag indicates the applicability to the loopback
-	 * path.
-	 */
-	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_FLAGS_LOOPBACK	UINT32_C(0x1)
-	uint32_t	enables;
-	/*
-	 * This bit must be '1' for the l2_filter_id field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_ENABLES_L2_FILTER_ID	UINT32_C(0x1)
-	/*
-	 * This bit must be '1' for the l2_addr field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR		UINT32_C(0x2)
-	/*
-	 * This bit must be '1' for the l2_ivlan field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_ENABLES_L2_IVLAN	UINT32_C(0x4)
-	/*
-	 * This bit must be '1' for the l3_addr field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_ENABLES_L3_ADDR		UINT32_C(0x8)
-	/*
-	 * This bit must be '1' for the l3_addr_type field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_ENABLES_L3_ADDR_TYPE	UINT32_C(0x10)
-	/*
-	 * This bit must be '1' for the t_l3_addr_type field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_ENABLES_T_L3_ADDR_TYPE	UINT32_C(0x20)
-	/*
-	 * This bit must be '1' for the t_l3_addr field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_ENABLES_T_L3_ADDR	UINT32_C(0x40)
-	/*
-	 * This bit must be '1' for the tunnel_type field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_ENABLES_TUNNEL_TYPE	UINT32_C(0x80)
-	/*
-	 * This bit must be '1' for the vni field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_ENABLES_VNI		UINT32_C(0x100)
-	/*
-	 * This bit must be '1' for the dst_vnic_id field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_ENABLES_DST_VNIC_ID	UINT32_C(0x200)
-	/*
-	 * This bit must be '1' for the mirror_vnic_id field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_ENABLES_MIRROR_VNIC_ID	UINT32_C(0x400)
-	/*
-	 * This value identifies a set of CFA data structures used for an L2
-	 * context.
-	 */
-	uint64_t	l2_filter_id;
+} hwrm_fw_health_check_input_t, *phwrm_fw_health_check_input_t;
+
+/* hwrm_fw_health_check_output (size:128b/16B) */
+
+typedef struct hwrm_fw_health_check_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint32_t	fw_status;
 	/*
-	 * This value sets the match value for the inner L2
-	 * MAC address.
-	 * Destination MAC address for RX path.
-	 * Source MAC address for TX path.
+	 * This bit is '0' if the primary SBI was used this boot,
+	 * or '1' if the secondary SBI was used.
 	 */
-	uint8_t	l2_addr[6];
+	#define HWRM_FW_HEALTH_CHECK_OUTPUT_FW_STATUS_SBI_BOOTED	UINT32_C(0x1)
 	/*
-	 * This value sets VLAN ID value for inner VLAN.
-	 * Only 12-bits of VLAN ID are used in setting the filter.
+	 * This bit is '0' if the primary and secondary SBI images
+	 * match, or '1' if they do not match.
 	 */
-	uint16_t	l2_ivlan;
+	#define HWRM_FW_HEALTH_CHECK_OUTPUT_FW_STATUS_SBI_MISMATCH	UINT32_C(0x2)
 	/*
-	 * The value of inner destination IP address to be used in filtering.
-	 * For IPv4, first four bytes represent the IP address.
+	 * This bit is '0' if the primary SRT was used this boot,
+	 * or '1' if the secondary SRT was used.
 	 */
-	uint32_t	l3_addr[4];
+	#define HWRM_FW_HEALTH_CHECK_OUTPUT_FW_STATUS_SRT_BOOTED	UINT32_C(0x4)
 	/*
-	 * The value of tunnel destination IP address to be used in filtering.
-	 * For IPv4, first four bytes represent the IP address.
+	 * This bit is '0' if the primary and secondary SRT images
+	 * match, or '1' if they do not match.
 	 */
-	uint32_t	t_l3_addr[4];
+	#define HWRM_FW_HEALTH_CHECK_OUTPUT_FW_STATUS_SRT_MISMATCH	UINT32_C(0x8)
 	/*
-	 * This value indicates the type of inner IP address.
-	 * 4 - IPv4
-	 * 6 - IPv6
-	 * All others are invalid.
+	 * This bit is '0' if the primary CRT (or second stage SRT)
+	 * was used this boot, or '1' if the secondary CRT (or
+	 * second stage SRT) was used.
 	 */
-	uint8_t	l3_addr_type;
+	#define HWRM_FW_HEALTH_CHECK_OUTPUT_FW_STATUS_CRT_BOOTED	UINT32_C(0x10)
 	/*
-	 * This value indicates the type of tunnel IP address.
-	 * 4 - IPv4
-	 * 6 - IPv6
-	 * All others are invalid.
+	 * This bit is '0' if the primary and secondary CRT images
+	 * (or second stage SRT images) match, or '1' if they do not
+	 * match.
 	 */
-	uint8_t	t_l3_addr_type;
-	/* Tunnel Type. */
-	uint8_t	tunnel_type;
-	/* Non-tunnel */
-	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_TYPE_NONTUNNEL	UINT32_C(0x0)
-	/* Virtual eXtensible Local Area Network (VXLAN) */
-	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_TYPE_VXLAN	UINT32_C(0x1)
-	/* Network Virtualization Generic Routing Encapsulation (NVGRE) */
-	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_TYPE_NVGRE	UINT32_C(0x2)
-	/* Generic Routing Encapsulation (GRE) inside Ethernet payload */
-	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_TYPE_L2GRE	UINT32_C(0x3)
-	/* IP in IP */
-	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_TYPE_IPIP	UINT32_C(0x4)
-	/* Generic Network Virtualization Encapsulation (Geneve) */
-	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_TYPE_GENEVE	UINT32_C(0x5)
-	/* Multi-Protocol Label Switching (MPLS) */
-	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_TYPE_MPLS	UINT32_C(0x6)
-	/* Stateless Transport Tunnel (STT) */
-	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_TYPE_STT	UINT32_C(0x7)
-	/* Generic Routing Encapsulation (GRE) inside IP datagram payload */
-	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_TYPE_IPGRE	UINT32_C(0x8)
-	/* IPV4 over virtual eXtensible Local Area Network (IPV4oVXLAN) */
-	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_V4	UINT32_C(0x9)
+	#define HWRM_FW_HEALTH_CHECK_OUTPUT_FW_STATUS_CRT_MISMATCH	UINT32_C(0x20)
 	/*
-	 * Enhance Generic Routing Encapsulation (GRE version 1) inside IP
-	 * datagram payload
+	 * This bit is '0' if the second stage RT image is a CRT,
+	 * or '1' if the second stage RT image is an SRT.
 	 */
-	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_TYPE_IPGRE_V1	UINT32_C(0xa)
-	/* Use fixed layer 2 ether type of 0xFFFF */
-	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_TYPE_L2_ETYPE	UINT32_C(0xb)
+	#define HWRM_FW_HEALTH_CHECK_OUTPUT_FW_STATUS_SECOND_RT		UINT32_C(0x40)
 	/*
-	 * IPV6 over virtual eXtensible Local Area Network with GPE header
-	 * (IPV6oVXLANGPE)
+	 * This bit is '0' if the image was loaded from flash,
+	 * or '1' if the image was fastbooted.
 	 */
-	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_GPE_V6 UINT32_C(0xc)
-	/* Any tunneled traffic */
-	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_TYPE_ANYTUNNEL	UINT32_C(0xff)
-	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_TYPE_LAST	HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_TYPE_ANYTUNNEL
+	#define HWRM_FW_HEALTH_CHECK_OUTPUT_FW_STATUS_FASTBOOTED	UINT32_C(0x80)
 	/*
-	 * tunnel_flags allows the user to indicate the tunnel tag detection
-	 * for the tunnel type specified in tunnel_type.
+	 * This bit is '0' if the primary dir_hdr was used to locate
+	 * the firmware, or '1' if the secondary dir_hdr was used.
 	 */
-	uint8_t	tunnel_flags;
+	#define HWRM_FW_HEALTH_CHECK_OUTPUT_FW_STATUS_DIR_HDR_BOOTED	UINT32_C(0x100)
 	/*
-	 * If the tunnel_type is geneve, then this bit indicates if we
-	 * need to match the geneve OAM packet.
-	 * If the tunnel_type is nvgre or gre, then this bit indicates if
-	 * we need to detect checksum present bit in geneve header.
-	 * If the tunnel_type is mpls, then this bit indicates if we need
-	 * to match mpls packet with explicit IPV4/IPV6 null header.
+	 * This bit is '0' if the primary and secondary dir_hdr match,
+	 * or '1' if they do not match.
 	 */
-	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_FLAGS_TUN_FLAGS_OAM_CHECKSUM_EXPLHDR	UINT32_C(0x1)
+	#define HWRM_FW_HEALTH_CHECK_OUTPUT_FW_STATUS_DIR_HDR_MISMATCH	UINT32_C(0x200)
 	/*
-	 * If the tunnel_type is geneve, then this bit indicates if we
-	 * need to detect the critical option bit set in the oam packet.
-	 * If the tunnel_type is nvgre or gre, then this bit indicates
-	 * if we need to match nvgre packets with key present bit set in
-	 * gre header.
-	 * If the tunnel_type is mpls, then this bit indicates if we
-	 * need to match mpls packet with S bit from inner/second label.
+	 * This bit is '0' if the Master Boot Record is in good condition,
+	 * or '1' if it is corrupted.
 	 */
-	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_FLAGS_TUN_FLAGS_CRITICAL_OPT_S1	UINT32_C(0x2)
+	#define HWRM_FW_HEALTH_CHECK_OUTPUT_FW_STATUS_MBR_CORRUPT	UINT32_C(0x400)
 	/*
-	 * If the tunnel_type is geneve, then this bit indicates if we
-	 * need to match geneve packet with extended header bit set in
-	 * geneve header.
-	 * If the tunnel_type is nvgre or gre, then this bit indicates
-	 * if we need to match nvgre packets with sequence number
-	 * present bit set in gre header.
-	 * If the tunnel_type is mpls, then this bit indicates if we
-	 * need to match mpls packet with S bit from out/first label.
+	 * This bit is '0' if the configuration is in good condition,
+	 * or '1' if it is corrupted.
 	 */
-	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_INPUT_TUNNEL_FLAGS_TUN_FLAGS_EXTHDR_SEQNUM_S0	UINT32_C(0x4)
+	#define HWRM_FW_HEALTH_CHECK_OUTPUT_FW_STATUS_CFG_MISMATCH	UINT32_C(0x800)
 	/*
-	 * Virtual Network Identifier (VNI). Only valid with
-	 * tunnel_types VXLAN, NVGRE, and Geneve.
-	 * Only lower 24-bits of VNI field are used
-	 * in setting up the filter.
+	 * This bit is '0' if both FRU entries match,
+	 * or '1' if they do not match.
 	 */
-	uint32_t	vni;
-	/* Logical VNIC ID of the destination VNIC. */
-	uint32_t	dst_vnic_id;
+	#define HWRM_FW_HEALTH_CHECK_OUTPUT_FW_STATUS_FRU_MISMATCH	UINT32_C(0x1000)
 	/*
-	 * Logical VNIC ID of the VNIC where traffic is
-	 * mirrored.
+	 * This bit is '0' if the primary CRT2 was used this boot,
+	 * or '1' if the secondary CRT2 was used.
 	 */
-	uint32_t	mirror_vnic_id;
-} hwrm_cfa_tunnel_filter_alloc_input_t, *phwrm_cfa_tunnel_filter_alloc_input_t;
-
-/* hwrm_cfa_tunnel_filter_alloc_output (size:192b/24B) */
-
-typedef struct hwrm_cfa_tunnel_filter_alloc_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* This value is an opaque id into CFA data structures. */
-	uint64_t	tunnel_filter_id;
+	#define HWRM_FW_HEALTH_CHECK_OUTPUT_FW_STATUS_CRT2_BOOTED	UINT32_C(0x2000)
 	/*
-	 * The flow id value in bit 0-29 is the actual ID of the flow
-	 * associated with this filter and it shall be used to match
-	 * and associate the flow identifier returned in completion
-	 * records. A value of 0xFFFFFFFF in the 32-bit flow_id field
-	 * shall indicate no valid flow id.
+	 * This bit is '0' if the primary and secondary CRT2 images
+	 * match, or '1' if they do not match.
 	 */
-	uint32_t	flow_id;
-	/* Indicate the flow id value. */
-	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_OUTPUT_FLOW_ID_VALUE_MASK UINT32_C(0x3fffffff)
-	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_OUTPUT_FLOW_ID_VALUE_SFT 0
-	/* Indicate type of the flow. */
-	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE	UINT32_C(0x40000000)
+	#define HWRM_FW_HEALTH_CHECK_OUTPUT_FW_STATUS_CRT2_MISMATCH	UINT32_C(0x4000)
 	/*
-	 * If this bit set to 0, then it indicates that the flow is
-	 * internal flow.
+	 * This bit is '0' if the primary GXRT was used this boot,
+	 * or '1' if the secondary GXRT was used.
 	 */
-		#define HWRM_CFA_TUNNEL_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE_INT	(UINT32_C(0x0) << 30)
+	#define HWRM_FW_HEALTH_CHECK_OUTPUT_FW_STATUS_GXRT_BOOTED	UINT32_C(0x8000)
 	/*
-	 * If this bit is set to 1, then it indicates that the flow is
-	 * external flow.
-	 */
-		#define HWRM_CFA_TUNNEL_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE_EXT	(UINT32_C(0x1) << 30)
-		#define HWRM_CFA_TUNNEL_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE_LAST  HWRM_CFA_TUNNEL_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE_EXT
-	/* Indicate the flow direction. */
-	#define HWRM_CFA_TUNNEL_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR	UINT32_C(0x80000000)
-	/* If this bit set to 0, then it indicates rx flow. */
-		#define HWRM_CFA_TUNNEL_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR_RX	(UINT32_C(0x0) << 31)
-	/* If this bit is set to 1, then it indicates that tx flow. */
-		#define HWRM_CFA_TUNNEL_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR_TX	(UINT32_C(0x1) << 31)
-		#define HWRM_CFA_TUNNEL_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR_LAST   HWRM_CFA_TUNNEL_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR_TX
+	 * This bit is '0' if the primary and secondary GXRT images
+	 * match, or '1' if they do not match.
+	 */
+	#define HWRM_FW_HEALTH_CHECK_OUTPUT_FW_STATUS_GXRT_MISMATCH	UINT32_C(0x10000)
 	uint8_t	unused_0[3];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_tunnel_filter_alloc_output_t, *phwrm_cfa_tunnel_filter_alloc_output_t;
+} hwrm_fw_health_check_output_t, *phwrm_fw_health_check_output_t;
 
-/*******************************
- * hwrm_cfa_tunnel_filter_free *
- *******************************/
+/***************************
+ * hwrm_fw_livepatch_query *
+ ***************************/
 
 
-/* hwrm_cfa_tunnel_filter_free_input (size:192b/24B) */
+/* hwrm_fw_livepatch_query_input (size:192b/24B) */
 
-typedef struct hwrm_cfa_tunnel_filter_free_input {
+typedef struct hwrm_fw_livepatch_query_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -34004,13 +61604,19 @@ typedef struct hwrm_cfa_tunnel_filter_free_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* This value is an opaque id into CFA data structures. */
-	uint64_t	tunnel_filter_id;
-} hwrm_cfa_tunnel_filter_free_input_t, *phwrm_cfa_tunnel_filter_free_input_t;
+	/* Firmware target to which to apply the livepatch query */
+	uint8_t	fw_target;
+	/* Common firmware livepatch query. */
+	#define HWRM_FW_LIVEPATCH_QUERY_INPUT_FW_TARGET_COMMON_FW UINT32_C(0x1)
+	/* Secure firmware livepatch query. */
+	#define HWRM_FW_LIVEPATCH_QUERY_INPUT_FW_TARGET_SECURE_FW UINT32_C(0x2)
+	#define HWRM_FW_LIVEPATCH_QUERY_INPUT_FW_TARGET_LAST	HWRM_FW_LIVEPATCH_QUERY_INPUT_FW_TARGET_SECURE_FW
+	uint8_t	unused_0[7];
+} hwrm_fw_livepatch_query_input_t, *phwrm_fw_livepatch_query_input_t;
 
-/* hwrm_cfa_tunnel_filter_free_output (size:128b/16B) */
+/* hwrm_fw_livepatch_query_output (size:640b/80B) */
 
-typedef struct hwrm_cfa_tunnel_filter_free_output {
+typedef struct hwrm_fw_livepatch_query_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -34019,26 +61625,40 @@ typedef struct hwrm_cfa_tunnel_filter_free_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	/*
+	 * This field represents the patch version string of the NVM installed
+	 * livepatch. (ASCII chars with NULL at the end).
+	 */
+	char	install_ver[32];
+	/*
+	 * This field represents the patch version string of the active
+	 * livepatch. (ASCII chars with NULL at the end).
+	 */
+	char	active_ver[32];
+	uint16_t	status_flags;
+	/* This bit is '1' if a livepatch image is installed to NVM. */
+	#define HWRM_FW_LIVEPATCH_QUERY_OUTPUT_STATUS_FLAGS_INSTALL	UINT32_C(0x1)
+	/* This bit is '1' if firmware livepatch is active. */
+	#define HWRM_FW_LIVEPATCH_QUERY_OUTPUT_STATUS_FLAGS_ACTIVE	UINT32_C(0x2)
+	uint8_t	unused_0[5];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_tunnel_filter_free_output_t, *phwrm_cfa_tunnel_filter_free_output_t;
+} hwrm_fw_livepatch_query_output_t, *phwrm_fw_livepatch_query_output_t;
 
-/***************************************
- * hwrm_cfa_redirect_tunnel_type_alloc *
- ***************************************/
+/*********************
+ * hwrm_fw_livepatch *
+ *********************/
 
 
-/* hwrm_cfa_redirect_tunnel_type_alloc_input (size:192b/24B) */
+/* hwrm_fw_livepatch_input (size:256b/32B) */
 
-typedef struct hwrm_cfa_redirect_tunnel_type_alloc_input {
+typedef struct hwrm_fw_livepatch_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -34067,58 +61687,49 @@ typedef struct hwrm_cfa_redirect_tunnel_type_alloc_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* The destination function id, to whom the traffic is redirected. */
-	uint16_t	dest_fid;
-	/* Tunnel Type. */
-	uint8_t	tunnel_type;
-	/* Non-tunnel */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_TUNNEL_TYPE_NONTUNNEL	UINT32_C(0x0)
-	/* Virtual eXtensible Local Area Network (VXLAN) */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_TUNNEL_TYPE_VXLAN	UINT32_C(0x1)
-	/* Network Virtualization Generic Routing Encapsulation (NVGRE) */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_TUNNEL_TYPE_NVGRE	UINT32_C(0x2)
-	/* Generic Routing Encapsulation (GRE) inside Ethernet payload */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_TUNNEL_TYPE_L2GRE	UINT32_C(0x3)
-	/* IP in IP */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_TUNNEL_TYPE_IPIP	UINT32_C(0x4)
-	/* Generic Network Virtualization Encapsulation (Geneve) */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_TUNNEL_TYPE_GENEVE	UINT32_C(0x5)
-	/* Multi-Protocol Label Switching (MPLS) */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_TUNNEL_TYPE_MPLS	UINT32_C(0x6)
-	/* Stateless Transport Tunnel (STT) */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_TUNNEL_TYPE_STT	UINT32_C(0x7)
-	/* Generic Routing Encapsulation (GRE) inside IP datagram payload */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_TUNNEL_TYPE_IPGRE	UINT32_C(0x8)
-	/* IPV4 over virtual eXtensible Local Area Network (IPV4oVXLAN) */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_V4	UINT32_C(0x9)
+	/* Livepatch operation */
+	uint8_t	opcode;
 	/*
-	 * Enhance Generic Routing Encapsulation (GRE version 1) inside IP
-	 * datagram payload
+	 * Activate a livepatch that is NVM installed or via direct load
+	 * from host memory. Activate will authenticate a signed patch,
+	 * verify the patch version for compatibility and apply the
+	 * livepatch to existing firmware at run-time.
 	 */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_TUNNEL_TYPE_IPGRE_V1	UINT32_C(0xa)
-	/* Use fixed layer 2 ether type of 0xFFFF */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_TUNNEL_TYPE_L2_ETYPE	UINT32_C(0xb)
+	#define HWRM_FW_LIVEPATCH_INPUT_OPCODE_ACTIVATE   UINT32_C(0x1)
 	/*
-	 * IPV6 over virtual eXtensible Local Area Network with GPE header
-	 * (IPV6oVXLANGPE)
+	 * Deactivate a livepatch and restore to the original firmware
+	 * operation state.
 	 */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_GPE_V6 UINT32_C(0xc)
-	/* Any tunneled traffic */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_TUNNEL_TYPE_ANYTUNNEL	UINT32_C(0xff)
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_TUNNEL_TYPE_LAST	HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_TUNNEL_TYPE_ANYTUNNEL
-	/* Tunnel alloc flags. */
-	uint8_t	flags;
+	#define HWRM_FW_LIVEPATCH_INPUT_OPCODE_DEACTIVATE UINT32_C(0x2)
+	#define HWRM_FW_LIVEPATCH_INPUT_OPCODE_LAST	HWRM_FW_LIVEPATCH_INPUT_OPCODE_DEACTIVATE
+	/* Firmware target to which to apply the livepatch operation. */
+	uint8_t	fw_target;
+	/* Common firmware livepatch. */
+	#define HWRM_FW_LIVEPATCH_INPUT_FW_TARGET_COMMON_FW UINT32_C(0x1)
+	/* Secure firmware livepatch. */
+	#define HWRM_FW_LIVEPATCH_INPUT_FW_TARGET_SECURE_FW UINT32_C(0x2)
+	#define HWRM_FW_LIVEPATCH_INPUT_FW_TARGET_LAST	HWRM_FW_LIVEPATCH_INPUT_FW_TARGET_SECURE_FW
+	/* Load method for livepatch. */
+	uint8_t	loadtype;
+	/* Load a livepatch currently installed on NVM. */
+	#define HWRM_FW_LIVEPATCH_INPUT_LOADTYPE_NVM_INSTALL   UINT32_C(0x1)
 	/*
-	 * Setting of this flag indicates modify existing redirect tunnel
-	 * to new destination function ID.
+	 * Load a livepatch directly from host memory. The livepatch image
+	 * is available at host_addr.
 	 */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_ALLOC_INPUT_FLAGS_MODIFY_DST	UINT32_C(0x1)
-	uint8_t	unused_0[4];
-} hwrm_cfa_redirect_tunnel_type_alloc_input_t, *phwrm_cfa_redirect_tunnel_type_alloc_input_t;
+	#define HWRM_FW_LIVEPATCH_INPUT_LOADTYPE_MEMORY_DIRECT UINT32_C(0x2)
+	#define HWRM_FW_LIVEPATCH_INPUT_LOADTYPE_LAST	HWRM_FW_LIVEPATCH_INPUT_LOADTYPE_MEMORY_DIRECT
+	/* Reserved for future use. */
+	uint8_t	flags;
+	/* Length of livepatch image for memory direct loading, in bytes. */
+	uint32_t	patch_len;
+	/* 64-bit Host address of livepatch image for memory direct loading. */
+	uint64_t	host_addr;
+} hwrm_fw_livepatch_input_t, *phwrm_fw_livepatch_input_t;
 
-/* hwrm_cfa_redirect_tunnel_type_alloc_output (size:128b/16B) */
+/* hwrm_fw_livepatch_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_redirect_tunnel_type_alloc_output {
+typedef struct hwrm_fw_livepatch_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -34131,22 +61742,56 @@ typedef struct hwrm_cfa_redirect_tunnel_type_alloc_output {
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_redirect_tunnel_type_alloc_output_t, *phwrm_cfa_redirect_tunnel_type_alloc_output_t;
+} hwrm_fw_livepatch_output_t, *phwrm_fw_livepatch_output_t;
 
-/**************************************
- * hwrm_cfa_redirect_tunnel_type_free *
- **************************************/
+/* hwrm_fw_livepatch_cmd_err (size:64b/8B) */
 
+typedef struct hwrm_fw_livepatch_cmd_err {
+	/*
+	 * command specific error codes that goes to
+	 * the cmd_err field in Common HWRM Error Response.
+	 */
+	uint8_t	code;
+	/* Unknown error. */
+	#define HWRM_FW_LIVEPATCH_CMD_ERR_CODE_UNKNOWN	UINT32_C(0x0)
+	/* Opcode invalid. */
+	#define HWRM_FW_LIVEPATCH_CMD_ERR_CODE_INVALID_OPCODE  UINT32_C(0x1)
+	/* Firmware target invalid. */
+	#define HWRM_FW_LIVEPATCH_CMD_ERR_CODE_INVALID_TARGET  UINT32_C(0x2)
+	/* Livepatch operation not supported. */
+	#define HWRM_FW_LIVEPATCH_CMD_ERR_CODE_NOT_SUPPORTED   UINT32_C(0x3)
+	/* Livepatch image is not installed in NVRAM. */
+	#define HWRM_FW_LIVEPATCH_CMD_ERR_CODE_NOT_INSTALLED   UINT32_C(0x4)
+	/* Deactivate failed. Firmware is not currently patched. */
+	#define HWRM_FW_LIVEPATCH_CMD_ERR_CODE_NOT_PATCHED	UINT32_C(0x5)
+	/* Authentication of a signed livepatch failed. */
+	#define HWRM_FW_LIVEPATCH_CMD_ERR_CODE_AUTH_FAIL	UINT32_C(0x6)
+	/* Livepatch header check failed. Patch incompatible. */
+	#define HWRM_FW_LIVEPATCH_CMD_ERR_CODE_INVALID_HEADER  UINT32_C(0x7)
+	/* Livepatch size incompatible. */
+	#define HWRM_FW_LIVEPATCH_CMD_ERR_CODE_INVALID_SIZE	UINT32_C(0x8)
+	/*
+	 * Activate failed. Firmware has already been patched. Deactivate
+	 * existing livepatch before proceeding.
+	 */
+	#define HWRM_FW_LIVEPATCH_CMD_ERR_CODE_ALREADY_PATCHED UINT32_C(0x9)
+	#define HWRM_FW_LIVEPATCH_CMD_ERR_CODE_LAST	HWRM_FW_LIVEPATCH_CMD_ERR_CODE_ALREADY_PATCHED
+	uint8_t	unused_0[7];
+} hwrm_fw_livepatch_cmd_err_t, *phwrm_fw_livepatch_cmd_err_t;
 
-/* hwrm_cfa_redirect_tunnel_type_free_input (size:192b/24B) */
+/****************
+ * hwrm_fw_sync *
+ ****************/
 
-typedef struct hwrm_cfa_redirect_tunnel_type_free_input {
+
+/* hwrm_fw_sync_input (size:192b/24B) */
+
+typedef struct hwrm_fw_sync_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -34175,51 +61820,80 @@ typedef struct hwrm_cfa_redirect_tunnel_type_free_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* The destination function id, to whom the traffic is redirected. */
-	uint16_t	dest_fid;
-	/* Tunnel Type. */
-	uint8_t	tunnel_type;
-	/* Non-tunnel */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE_INPUT_TUNNEL_TYPE_NONTUNNEL	UINT32_C(0x0)
-	/* Virtual eXtensible Local Area Network (VXLAN) */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE_INPUT_TUNNEL_TYPE_VXLAN	UINT32_C(0x1)
-	/* Network Virtualization Generic Routing Encapsulation (NVGRE) */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE_INPUT_TUNNEL_TYPE_NVGRE	UINT32_C(0x2)
-	/* Generic Routing Encapsulation (GRE) inside Ethernet payload */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE_INPUT_TUNNEL_TYPE_L2GRE	UINT32_C(0x3)
-	/* IP in IP */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE_INPUT_TUNNEL_TYPE_IPIP	UINT32_C(0x4)
-	/* Generic Network Virtualization Encapsulation (Geneve) */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE_INPUT_TUNNEL_TYPE_GENEVE	UINT32_C(0x5)
-	/* Multi-Protocol Label Switching (MPLS) */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE_INPUT_TUNNEL_TYPE_MPLS	UINT32_C(0x6)
-	/* Stateless Transport Tunnel (STT) */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE_INPUT_TUNNEL_TYPE_STT	UINT32_C(0x7)
-	/* Generic Routing Encapsulation (GRE) inside IP datagram payload */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE_INPUT_TUNNEL_TYPE_IPGRE	UINT32_C(0x8)
-	/* IPV4 over virtual eXtensible Local Area Network (IPV4oVXLAN) */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE_INPUT_TUNNEL_TYPE_VXLAN_V4	UINT32_C(0x9)
+	uint32_t	sync_action;
 	/*
-	 * Enhance Generic Routing Encapsulation (GRE version 1) inside IP
-	 * datagram payload
+	 * If action is '1' (sync) and this bit is set, the SBI
+	 * images will be synchronized, copying from the instance
+	 * used for boot to the other instance, if they currently
+	 * do not match.
 	 */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE_INPUT_TUNNEL_TYPE_IPGRE_V1	UINT32_C(0xa)
-	/* Use fixed layer 2 ether type of 0xFFFF */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE_INPUT_TUNNEL_TYPE_L2_ETYPE	UINT32_C(0xb)
+	#define HWRM_FW_SYNC_INPUT_SYNC_ACTION_SYNC_SBI	UINT32_C(0x1)
 	/*
-	 * IPV6 over virtual eXtensible Local Area Network with GPE header
-	 * (IPV6oVXLANGPE)
+	 * If action is '1' (sync) and this bit is set, the SRT
+	 * images will be synchronized, copying from the instance
+	 * used for boot to the other instance, if they currently
+	 * do not match.
 	 */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE_INPUT_TUNNEL_TYPE_VXLAN_GPE_V6 UINT32_C(0xc)
-	/* Any tunneled traffic */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE_INPUT_TUNNEL_TYPE_ANYTUNNEL	UINT32_C(0xff)
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE_INPUT_TUNNEL_TYPE_LAST	HWRM_CFA_REDIRECT_TUNNEL_TYPE_FREE_INPUT_TUNNEL_TYPE_ANYTUNNEL
-	uint8_t	unused_0[5];
-} hwrm_cfa_redirect_tunnel_type_free_input_t, *phwrm_cfa_redirect_tunnel_type_free_input_t;
+	#define HWRM_FW_SYNC_INPUT_SYNC_ACTION_SYNC_SRT	UINT32_C(0x2)
+	/*
+	 * If action is '1' (sync) and this bit is set, the CRT
+	 * images will be synchronized (or second stage SRT if that
+	 * is used in place of CRT), copying from the instance
+	 * used for boot to the other instance, if they currently
+	 * do not match.
+	 */
+	#define HWRM_FW_SYNC_INPUT_SYNC_ACTION_SYNC_CRT	UINT32_C(0x4)
+	/*
+	 * If action is '1' (sync) and this bit is set, the dir_hdr
+	 * partition will be synchronized, copying from the instance
+	 * used for boot to the other instance, if they currently
+	 * do not match.
+	 */
+	#define HWRM_FW_SYNC_INPUT_SYNC_ACTION_SYNC_DIR_HDR	UINT32_C(0x8)
+	/*
+	 * If action is '1' (sync) and this bit is set, the MBR
+	 * will be erased and reprogrammed with valid content.
+	 */
+	#define HWRM_FW_SYNC_INPUT_SYNC_ACTION_WRITE_MBR	UINT32_C(0x10)
+	/*
+	 * If action is '1' (sync) and this bit is set, the
+	 * configuration will be resynced or repaired as needed.
+	 */
+	#define HWRM_FW_SYNC_INPUT_SYNC_ACTION_SYNC_CFG	UINT32_C(0x20)
+	/*
+	 * If action is '1' (sync) and this bit is set, the
+	 * FRU in NVM file will be synchronized, copying the active
+	 * FRU to the backup FRU.
+	 */
+	#define HWRM_FW_SYNC_INPUT_SYNC_ACTION_SYNC_FRU	UINT32_C(0x40)
+	/*
+	 * If action is '1' (sync) and this bit is set, the CRT2
+	 * images will be synchronized, copying from the instance
+	 * used for boot to the other instance, if they currently
+	 * do not match.
+	 */
+	#define HWRM_FW_SYNC_INPUT_SYNC_ACTION_SYNC_CRT2	UINT32_C(0x80)
+	/*
+	 * If action is '1' (sync) and this bit is set, the GXRT
+	 * images will be synchronized, copying from the instance
+	 * used for boot to the other instance, if they currently
+	 * do not match.
+	 */
+	#define HWRM_FW_SYNC_INPUT_SYNC_ACTION_SYNC_GXRT	UINT32_C(0x100)
+	/*
+	 * A value of '1' instructs the firmware to perform an image
+	 * synchronization of the firmware types denoted by the
+	 * sync_sbi, sync_srt, sync_crt, sync_crt2 bits. A value of '0' just
+	 * requests the status for the previously requested sync
+	 * operation.
+	 */
+	#define HWRM_FW_SYNC_INPUT_SYNC_ACTION_ACTION	UINT32_C(0x80000000)
+	uint8_t	unused_0[4];
+} hwrm_fw_sync_input_t, *phwrm_fw_sync_input_t;
 
-/* hwrm_cfa_redirect_tunnel_type_free_output (size:128b/16B) */
+/* hwrm_fw_sync_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_redirect_tunnel_type_free_output {
+typedef struct hwrm_fw_sync_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -34228,26 +61902,55 @@ typedef struct hwrm_cfa_redirect_tunnel_type_free_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	uint32_t	sync_status;
+	/* This bit field indicates the error if 'sync_err' bit is set. */
+	#define HWRM_FW_SYNC_OUTPUT_SYNC_STATUS_ERR_CODE_MASK	UINT32_C(0xff)
+	#define HWRM_FW_SYNC_OUTPUT_SYNC_STATUS_ERR_CODE_SFT	0
+	/* Success, no error */
+		#define HWRM_FW_SYNC_OUTPUT_SYNC_STATUS_ERR_CODE_SUCCESS	UINT32_C(0x0)
+	/*
+	 * A previously requested synchronization command is still
+	 * in progress.
+	 */
+		#define HWRM_FW_SYNC_OUTPUT_SYNC_STATUS_ERR_CODE_IN_PROGRESS  UINT32_C(0x1)
+	/* An NVRAM operation has timed out. */
+		#define HWRM_FW_SYNC_OUTPUT_SYNC_STATUS_ERR_CODE_TIMEOUT	UINT32_C(0x2)
+	/* General NVRAM error code. */
+		#define HWRM_FW_SYNC_OUTPUT_SYNC_STATUS_ERR_CODE_GENERAL	UINT32_C(0x3)
+		#define HWRM_FW_SYNC_OUTPUT_SYNC_STATUS_ERR_CODE_LAST	HWRM_FW_SYNC_OUTPUT_SYNC_STATUS_ERR_CODE_GENERAL
+	/*
+	 * This bit is '1' if the synchronization request has completed
+	 * with an error; the 'err_code' field can be used to obtain
+	 * information about error type.
+	 */
+	#define HWRM_FW_SYNC_OUTPUT_SYNC_STATUS_SYNC_ERR		UINT32_C(0x40000000)
+	/*
+	 * This bit is '0' if the previously requested synchronization
+	 * command is still in progress, or '1' if the previously
+	 * requested sync command has completed. If '1', the 'sync_err'
+	 * field will indicate if it completed successfully or with
+	 * an error.
+	 */
+	#define HWRM_FW_SYNC_OUTPUT_SYNC_STATUS_SYNC_COMPLETE	UINT32_C(0x80000000)
+	uint8_t	unused_0[3];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_redirect_tunnel_type_free_output_t, *phwrm_cfa_redirect_tunnel_type_free_output_t;
+} hwrm_fw_sync_output_t, *phwrm_fw_sync_output_t;
 
-/**************************************
- * hwrm_cfa_redirect_tunnel_type_info *
- **************************************/
+/***********************
+ * hwrm_fw_state_qcaps *
+ ***********************/
 
 
-/* hwrm_cfa_redirect_tunnel_type_info_input (size:192b/24B) */
+/* hwrm_fw_state_qcaps_input (size:128b/16B) */
 
-typedef struct hwrm_cfa_redirect_tunnel_type_info_input {
+typedef struct hwrm_fw_state_qcaps_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -34276,51 +61979,11 @@ typedef struct hwrm_cfa_redirect_tunnel_type_info_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* The source function id. */
-	uint16_t	src_fid;
-	/* Tunnel Type. */
-	uint8_t	tunnel_type;
-	/* Non-tunnel */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO_INPUT_TUNNEL_TYPE_NONTUNNEL	UINT32_C(0x0)
-	/* Virtual eXtensible Local Area Network (VXLAN) */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO_INPUT_TUNNEL_TYPE_VXLAN	UINT32_C(0x1)
-	/* Network Virtualization Generic Routing Encapsulation (NVGRE) */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO_INPUT_TUNNEL_TYPE_NVGRE	UINT32_C(0x2)
-	/* Generic Routing Encapsulation (GRE) inside Ethernet payload */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO_INPUT_TUNNEL_TYPE_L2GRE	UINT32_C(0x3)
-	/* IP in IP */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO_INPUT_TUNNEL_TYPE_IPIP	UINT32_C(0x4)
-	/* Generic Network Virtualization Encapsulation (Geneve) */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO_INPUT_TUNNEL_TYPE_GENEVE	UINT32_C(0x5)
-	/* Multi-Protocol Label Switching (MPLS) */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO_INPUT_TUNNEL_TYPE_MPLS	UINT32_C(0x6)
-	/* Stateless Transport Tunnel (STT) */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO_INPUT_TUNNEL_TYPE_STT	UINT32_C(0x7)
-	/* Generic Routing Encapsulation (GRE) inside IP datagram payload */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO_INPUT_TUNNEL_TYPE_IPGRE	UINT32_C(0x8)
-	/* IPV4 over virtual eXtensible Local Area Network (IPV4oVXLAN) */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO_INPUT_TUNNEL_TYPE_VXLAN_V4	UINT32_C(0x9)
-	/*
-	 * Enhance Generic Routing Encapsulation (GRE version 1) inside IP
-	 * datagram payload
-	 */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO_INPUT_TUNNEL_TYPE_IPGRE_V1	UINT32_C(0xa)
-	/* Use fixed layer 2 ether type of 0xFFFF */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO_INPUT_TUNNEL_TYPE_L2_ETYPE	UINT32_C(0xb)
-	/*
-	 * IPV6 over virtual eXtensible Local Area Network with GPE header
-	 * (IPV6oVXLANGPE)
-	 */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO_INPUT_TUNNEL_TYPE_VXLAN_GPE_V6 UINT32_C(0xc)
-	/* Any tunneled traffic */
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO_INPUT_TUNNEL_TYPE_ANYTUNNEL	UINT32_C(0xff)
-	#define HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO_INPUT_TUNNEL_TYPE_LAST	HWRM_CFA_REDIRECT_TUNNEL_TYPE_INFO_INPUT_TUNNEL_TYPE_ANYTUNNEL
-	uint8_t	unused_0[5];
-} hwrm_cfa_redirect_tunnel_type_info_input_t, *phwrm_cfa_redirect_tunnel_type_info_input_t;
+} hwrm_fw_state_qcaps_input_t, *phwrm_fw_state_qcaps_input_t;
 
-/* hwrm_cfa_redirect_tunnel_type_info_output (size:128b/16B) */
+/* hwrm_fw_state_qcaps_output (size:256b/32B) */
 
-typedef struct hwrm_cfa_redirect_tunnel_type_info_output {
+typedef struct hwrm_fw_state_qcaps_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -34329,133 +61992,66 @@ typedef struct hwrm_cfa_redirect_tunnel_type_info_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* The destination function id, to whom the traffic is redirected. */
-	uint16_t	dest_fid;
-	uint8_t	unused_0[5];
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * This field indicates the size in bytes required by host backup
+	 * memory. Host software should allocate memory according to this
+	 * size requirement and pass the allocated memory to the
+	 * HWRM_FW_STATE_BACKUP and HWRM_FW_STATE_RESTORE commands in the form
+	 * of PBL data as specified in those commands.
 	 */
-	uint8_t	valid;
-} hwrm_cfa_redirect_tunnel_type_info_output_t, *phwrm_cfa_redirect_tunnel_type_info_output_t;
-
-/* hwrm_vxlan_ipv4_hdr (size:128b/16B) */
-
-typedef struct hwrm_vxlan_ipv4_hdr {
-	/* IPv4 version and header length. */
-	uint8_t	ver_hlen;
-	/* IPv4 header length */
-	#define HWRM_VXLAN_IPV4_HDR_VER_HLEN_HEADER_LENGTH_MASK UINT32_C(0xf)
-	#define HWRM_VXLAN_IPV4_HDR_VER_HLEN_HEADER_LENGTH_SFT 0
-	/* Version */
-	#define HWRM_VXLAN_IPV4_HDR_VER_HLEN_VERSION_MASK	UINT32_C(0xf0)
-	#define HWRM_VXLAN_IPV4_HDR_VER_HLEN_VERSION_SFT	4
-	/* IPv4 type of service. */
-	uint8_t	tos;
-	/* IPv4 identification. */
-	uint16_t	ip_id;
-	/* IPv4 flags and offset. */
-	uint16_t	flags_frag_offset;
-	/* IPv4 TTL. */
-	uint8_t	ttl;
-	/* IPv4 protocol. */
-	uint8_t	protocol;
-	/* IPv4 source address. */
-	uint32_t	src_ip_addr;
-	/* IPv4 destination address. */
-	uint32_t	dest_ip_addr;
-} hwrm_vxlan_ipv4_hdr_t, *phwrm_vxlan_ipv4_hdr_t;
-
-/* hwrm_vxlan_ipv6_hdr (size:320b/40B) */
-
-typedef struct hwrm_vxlan_ipv6_hdr {
-	/* IPv6 version, traffic class and flow label. */
-	uint32_t	ver_tc_flow_label;
-	/* IPv6 version shift */
-	#define HWRM_VXLAN_IPV6_HDR_VER_TC_FLOW_LABEL_VER_SFT	UINT32_C(0x1c)
-	/* IPv6 version mask */
-	#define HWRM_VXLAN_IPV6_HDR_VER_TC_FLOW_LABEL_VER_MASK	UINT32_C(0xf0000000)
-	/* IPv6 TC shift */
-	#define HWRM_VXLAN_IPV6_HDR_VER_TC_FLOW_LABEL_TC_SFT	UINT32_C(0x14)
-	/* IPv6 TC mask */
-	#define HWRM_VXLAN_IPV6_HDR_VER_TC_FLOW_LABEL_TC_MASK	UINT32_C(0xff00000)
-	/* IPv6 flow label shift */
-	#define HWRM_VXLAN_IPV6_HDR_VER_TC_FLOW_LABEL_FLOW_LABEL_SFT  UINT32_C(0x0)
-	/* IPv6 flow label mask */
-	#define HWRM_VXLAN_IPV6_HDR_VER_TC_FLOW_LABEL_FLOW_LABEL_MASK UINT32_C(0xfffff)
-	#define HWRM_VXLAN_IPV6_HDR_VER_TC_FLOW_LABEL_LAST	HWRM_VXLAN_IPV6_HDR_VER_TC_FLOW_LABEL_FLOW_LABEL_MASK
-	/* IPv6 payload length. */
-	uint16_t	payload_len;
-	/* IPv6 next header. */
-	uint8_t	next_hdr;
-	/* IPv6 TTL. */
-	uint8_t	ttl;
-	/* IPv6 source address. */
-	uint32_t	src_ip_addr[4];
-	/* IPv6 destination address. */
-	uint32_t	dest_ip_addr[4];
-} hwrm_vxlan_ipv6_hdr_t, *phwrm_vxlan_ipv6_hdr_t;
-
-/* hwrm_cfa_encap_data_vxlan (size:640b/80B) */
-
-typedef struct hwrm_cfa_encap_data_vxlan {
-	/* Source MAC address. */
-	uint8_t	src_mac_addr[6];
-	/* reserved. */
-	uint16_t	unused_0;
-	/* Destination MAC address. */
-	uint8_t	dst_mac_addr[6];
-	/* Number of VLAN tags. */
-	uint8_t	num_vlan_tags;
-	/* reserved. */
-	uint8_t	unused_1;
-	/* Outer VLAN TPID. */
-	uint16_t	ovlan_tpid;
-	/* Outer VLAN TCI. */
-	uint16_t	ovlan_tci;
-	/* Inner VLAN TPID. */
-	uint16_t	ivlan_tpid;
-	/* Inner VLAN TCI. */
-	uint16_t	ivlan_tci;
-	/* L3 header fields. */
-	uint32_t	l3[10];
-	/* IP version mask. */
-	#define HWRM_CFA_ENCAP_DATA_VXLAN_L3_VER_MASK UINT32_C(0xf)
-	/* IP version 4. */
-	#define HWRM_CFA_ENCAP_DATA_VXLAN_L3_VER_IPV4 UINT32_C(0x4)
-	/* IP version 6. */
-	#define HWRM_CFA_ENCAP_DATA_VXLAN_L3_VER_IPV6 UINT32_C(0x6)
-	#define HWRM_CFA_ENCAP_DATA_VXLAN_L3_LAST	HWRM_CFA_ENCAP_DATA_VXLAN_L3_VER_IPV6
-	/* UDP source port. */
-	uint16_t	src_port;
-	/* UDP destination port. */
-	uint16_t	dst_port;
-	/* VXLAN Network Identifier. */
-	uint32_t	vni;
+	uint32_t	backup_memory;
+	/*
+	 * This field indicates the max time in milliseconds that firmware
+	 * waits for quiesce to complete. Firmware indicates successful
+	 * quiesce completion if the quiesce operation completes within this
+	 * timeout. If firmware is still waiting for the quiesce operation
+	 * to complete when this timeout is reached, firmware stops waiting
+	 * (without canceling any quiesce action such as pausing or
+	 * clearing meter profiles) and indicates a timeout status result
+	 * via NQE completion notification. This timeout value may also be
+	 * used by the driver to know the max time to wait for any NQE
+	 * notification response to the HWRM_FW_STATE_QUIESCE command. After
+	 * a timeout, the driver may elect to invoke HWRM_FW_STATE_QUIESCE
+	 * again to keep trying or to invoke HWRM_FW_STATE_UNQUIESCE to
+	 * revert the operation. Since there is no identifier correlating
+	 * each HWRM_FW_STATE_QUIESCE command with its NQE response, it is
+	 * important for the driver to wait for the NQE response before
+	 * issuing a subsequent HWRM_FW_STATE_QUIESCE command.
+	 */
+	uint32_t	quiesce_timeout;
 	/*
-	 * 3 bytes VXLAN header reserve fields from 1st dword of the VXLAN
-	 * header.
+	 * This field indicates time in milliseconds that the driver should
+	 * wait after return from HWRM_FW_RESET to begin polling the device
+	 * for status 0x8000.
 	 */
-	uint8_t	hdr_rsvd0[3];
-	/* 1 byte VXLAN header reserve field from 2nd dword of the VXLAN header. */
-	uint8_t	hdr_rsvd1;
-	/* VXLAN header flags field. */
-	uint8_t	hdr_flags;
-	uint8_t	unused[3];
-} hwrm_cfa_encap_data_vxlan_t, *phwrm_cfa_encap_data_vxlan_t;
+	uint32_t	fw_status_blackout;
+	/*
+	 * This field indicates a max time for firmware to poll for status
+	 * 0x8000 before assuming a reset failure occurred. This time does
+	 * not include fw_status_blackout time which would immediately precede
+	 * this wait.
+	 */
+	uint32_t	fw_status_max_wait;
+	uint8_t	unused_0[4];
+	uint8_t	unused_1[3];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_fw_state_qcaps_output_t, *phwrm_fw_state_qcaps_output_t;
 
-/*******************************
- * hwrm_cfa_encap_record_alloc *
- *******************************/
+/*************************
+ * hwrm_fw_state_quiesce *
+ *************************/
 
 
-/* hwrm_cfa_encap_record_alloc_input (size:832b/104B) */
+/* hwrm_fw_state_quiesce_input (size:192b/24B) */
 
-typedef struct hwrm_cfa_encap_record_alloc_input {
+typedef struct hwrm_fw_state_quiesce_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -34484,59 +62080,27 @@ typedef struct hwrm_cfa_encap_record_alloc_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	flags;
-	/*
-	 * Setting of this flag indicates the applicability to the loopback
-	 * path.
-	 */
-	#define HWRM_CFA_ENCAP_RECORD_ALLOC_INPUT_FLAGS_LOOPBACK	UINT32_C(0x1)
-	/*
-	 * Setting of this flag indicates this encap record is external
-	 * encap record. Resetting of this flag indicates this flag is
-	 * internal encap record and this is the default setting.
-	 */
-	#define HWRM_CFA_ENCAP_RECORD_ALLOC_INPUT_FLAGS_EXTERNAL	UINT32_C(0x2)
-	/* Encapsulation Type. */
-	uint8_t	encap_type;
-	/* Virtual eXtensible Local Area Network (VXLAN) */
-	#define HWRM_CFA_ENCAP_RECORD_ALLOC_INPUT_ENCAP_TYPE_VXLAN	UINT32_C(0x1)
-	/* Network Virtualization Generic Routing Encapsulation (NVGRE) */
-	#define HWRM_CFA_ENCAP_RECORD_ALLOC_INPUT_ENCAP_TYPE_NVGRE	UINT32_C(0x2)
-	/* Generic Routing Encapsulation (GRE) after inside Ethernet payload */
-	#define HWRM_CFA_ENCAP_RECORD_ALLOC_INPUT_ENCAP_TYPE_L2GRE	UINT32_C(0x3)
-	/* IP in IP */
-	#define HWRM_CFA_ENCAP_RECORD_ALLOC_INPUT_ENCAP_TYPE_IPIP	UINT32_C(0x4)
-	/* Generic Network Virtualization Encapsulation (Geneve) */
-	#define HWRM_CFA_ENCAP_RECORD_ALLOC_INPUT_ENCAP_TYPE_GENEVE	UINT32_C(0x5)
-	/* Multi-Protocol Label Switching (MPLS) */
-	#define HWRM_CFA_ENCAP_RECORD_ALLOC_INPUT_ENCAP_TYPE_MPLS	UINT32_C(0x6)
-	/* VLAN */
-	#define HWRM_CFA_ENCAP_RECORD_ALLOC_INPUT_ENCAP_TYPE_VLAN	UINT32_C(0x7)
-	/* Generic Routing Encapsulation (GRE) inside IP datagram payload */
-	#define HWRM_CFA_ENCAP_RECORD_ALLOC_INPUT_ENCAP_TYPE_IPGRE	UINT32_C(0x8)
-	/* IPV4 over virtual eXtensible Local Area Network (IPV4oVXLAN) */
-	#define HWRM_CFA_ENCAP_RECORD_ALLOC_INPUT_ENCAP_TYPE_VXLAN_V4	UINT32_C(0x9)
-	/*
-	 * Enhance Generic Routing Encapsulation (GRE version 1) inside IP
-	 * datagram payload
-	 */
-	#define HWRM_CFA_ENCAP_RECORD_ALLOC_INPUT_ENCAP_TYPE_IPGRE_V1	UINT32_C(0xa)
-	/* Use fixed layer 2 ether type of 0xFFFF */
-	#define HWRM_CFA_ENCAP_RECORD_ALLOC_INPUT_ENCAP_TYPE_L2_ETYPE	UINT32_C(0xb)
+	uint8_t	flags;
 	/*
-	 * IPV6 over virtual eXtensible Local Area Network with GPE header
-	 * (IPV6oVXLANGPE)
+	 * Setting this bit to '1', indicates impactless firmware update
+	 * is in a recovery mode where hardware is in an error state and
+	 * where recovery is desired with reasonably minimal impact to
+	 * connected clients. The quiesce operation may require separate
+	 * steps to handle quiescing when hardware is in a hung or locked
+	 * state. For example, quiesce via draining may not be possible
+	 * depending on the type of error. This flag's state would be kept
+	 * in firmware if recovery-specific steps are also needed for the
+	 * HWRM_FW_STATE_BACKUP. Note this option is available only for
+	 * specific recovery scenarios and may not be operational across
+	 * all controllers.
 	 */
-	#define HWRM_CFA_ENCAP_RECORD_ALLOC_INPUT_ENCAP_TYPE_VXLAN_GPE_V6 UINT32_C(0xc)
-	#define HWRM_CFA_ENCAP_RECORD_ALLOC_INPUT_ENCAP_TYPE_LAST	HWRM_CFA_ENCAP_RECORD_ALLOC_INPUT_ENCAP_TYPE_VXLAN_GPE_V6
-	uint8_t	unused_0[3];
-	/* This value is encap data used for the given encap type. */
-	uint32_t	encap_data[20];
-} hwrm_cfa_encap_record_alloc_input_t, *phwrm_cfa_encap_record_alloc_input_t;
+	#define HWRM_FW_STATE_QUIESCE_INPUT_FLAGS_ERROR_RECOVERY	UINT32_C(0x1)
+	uint8_t	unused_0[7];
+} hwrm_fw_state_quiesce_input_t, *phwrm_fw_state_quiesce_input_t;
 
-/* hwrm_cfa_encap_record_alloc_output (size:128b/16B) */
+/* hwrm_fw_state_quiesce_output (size:192b/24B) */
 
-typedef struct hwrm_cfa_encap_record_alloc_output {
+typedef struct hwrm_fw_state_quiesce_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -34545,28 +62109,33 @@ typedef struct hwrm_cfa_encap_record_alloc_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* This value is an opaque id into CFA data structures. */
-	uint32_t	encap_record_id;
-	uint8_t	unused_0[3];
+	uint32_t	quiesce_status;
+	/*
+	 * This bit is '1' if the quiesce request has been successfully
+	 * initiated.
+	 */
+	#define HWRM_FW_STATE_QUIESCE_OUTPUT_QUIESCE_STATUS_INITIATED	UINT32_C(0x80000000)
+	uint8_t	unused_0[4];
+	uint8_t	unused_1[7];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
+	 * is completely written to RAM. This field should be read as '1' to
+	 * indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal
 	 * processor, the order of writes has to be such that this field is
 	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_encap_record_alloc_output_t, *phwrm_cfa_encap_record_alloc_output_t;
+} hwrm_fw_state_quiesce_output_t, *phwrm_fw_state_quiesce_output_t;
 
-/******************************
- * hwrm_cfa_encap_record_free *
- ******************************/
+/***************************
+ * hwrm_fw_state_unquiesce *
+ ***************************/
 
 
-/* hwrm_cfa_encap_record_free_input (size:192b/24B) */
+/* hwrm_fw_state_unquiesce_input (size:128b/16B) */
 
-typedef struct hwrm_cfa_encap_record_free_input {
+typedef struct hwrm_fw_state_unquiesce_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -34595,14 +62164,11 @@ typedef struct hwrm_cfa_encap_record_free_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* This value is an opaque id into CFA data structures. */
-	uint32_t	encap_record_id;
-	uint8_t	unused_0[4];
-} hwrm_cfa_encap_record_free_input_t, *phwrm_cfa_encap_record_free_input_t;
+} hwrm_fw_state_unquiesce_input_t, *phwrm_fw_state_unquiesce_input_t;
 
-/* hwrm_cfa_encap_record_free_output (size:128b/16B) */
+/* hwrm_fw_state_unquiesce_output (size:192b/24B) */
 
-typedef struct hwrm_cfa_encap_record_free_output {
+typedef struct hwrm_fw_state_unquiesce_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -34611,26 +62177,29 @@ typedef struct hwrm_cfa_encap_record_free_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	uint32_t	unquiesce_status;
+	/* This bit is '1' if the unquiesce request has fully completed. */
+	#define HWRM_FW_STATE_UNQUIESCE_OUTPUT_UNQUIESCE_STATUS_COMPLETE	UINT32_C(0x80000000)
+	uint8_t	unused_0[4];
+	uint8_t	unused_1[7];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_encap_record_free_output_t, *phwrm_cfa_encap_record_free_output_t;
+} hwrm_fw_state_unquiesce_output_t, *phwrm_fw_state_unquiesce_output_t;
 
-/********************************
- * hwrm_cfa_ntuple_filter_alloc *
- ********************************/
+/************************
+ * hwrm_fw_state_backup *
+ ************************/
 
 
-/* hwrm_cfa_ntuple_filter_alloc_input (size:1024b/128B) */
+/* hwrm_fw_state_backup_input (size:256b/32B) */
 
-typedef struct hwrm_cfa_ntuple_filter_alloc_input {
+typedef struct hwrm_fw_state_backup_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -34659,305 +62228,166 @@ typedef struct hwrm_cfa_ntuple_filter_alloc_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	flags;
-	/*
-	 * Setting of this flag indicates the applicability to the loopback
-	 * path.
-	 */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_FLAGS_LOOPBACK		UINT32_C(0x1)
-	/*
-	 * Setting of this flag indicates drop action. If this flag is not
-	 * set, then it should be considered accept action.
-	 */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_FLAGS_DROP		UINT32_C(0x2)
-	/*
-	 * Setting of this flag indicates that a meter is expected to be
-	 * attached to this flow. This hint can be used when choosing the
-	 * action record format required for the flow.
-	 */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_FLAGS_METER		UINT32_C(0x4)
-	/*
-	 * Setting of this flag indicates that the dst_id field contains
-	 * function ID. If this is not set it indicates dest_id is VNIC
-	 * or VPORT.
-	 */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_FLAGS_DEST_FID		UINT32_C(0x8)
-	/*
-	 * Setting of this flag indicates match on arp reply when ethertype
-	 * is 0x0806. If this is not set it indicates no specific arp opcode
-	 * matching.
-	 */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_FLAGS_ARP_REPLY		UINT32_C(0x10)
-	/*
-	 * Setting of this flag indicates that the dst_id field contains RFS
-	 * ring table index. If this is not set it indicates dst_id is VNIC
-	 * or VPORT or function ID.  Note dest_fid and dest_rfs_ring_idx
-	 * can’t be set at the same time.
-	 */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_FLAGS_DEST_RFS_RING_IDX	UINT32_C(0x20)
-	uint32_t	enables;
-	/*
-	 * This bit must be '1' for the l2_filter_id field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_L2_FILTER_ID	UINT32_C(0x1)
-	/*
-	 * This bit must be '1' for the ethertype field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_ETHERTYPE		UINT32_C(0x2)
-	/*
-	 * This bit must be '1' for the tunnel_type field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_TUNNEL_TYPE	UINT32_C(0x4)
-	/*
-	 * This bit must be '1' for the src_macaddr field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_SRC_MACADDR	UINT32_C(0x8)
-	/*
-	 * This bit must be '1' for the ipaddr_type field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_IPADDR_TYPE	UINT32_C(0x10)
-	/*
-	 * This bit must be '1' for the src_ipaddr field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_SRC_IPADDR	UINT32_C(0x20)
-	/*
-	 * This bit must be '1' for the src_ipaddr_mask field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_SRC_IPADDR_MASK	UINT32_C(0x40)
-	/*
-	 * This bit must be '1' for the dst_ipaddr field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_DST_IPADDR	UINT32_C(0x80)
-	/*
-	 * This bit must be '1' for the dst_ipaddr_mask field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_DST_IPADDR_MASK	UINT32_C(0x100)
-	/*
-	 * This bit must be '1' for the ip_protocol field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_IP_PROTOCOL	UINT32_C(0x200)
-	/*
-	 * This bit must be '1' for the src_port field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_SRC_PORT		UINT32_C(0x400)
-	/*
-	 * This bit must be '1' for the src_port_mask field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_SRC_PORT_MASK	UINT32_C(0x800)
-	/*
-	 * This bit must be '1' for the dst_port field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_DST_PORT		UINT32_C(0x1000)
-	/*
-	 * This bit must be '1' for the dst_port_mask field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_DST_PORT_MASK	UINT32_C(0x2000)
-	/*
-	 * This bit must be '1' for the pri_hint field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_PRI_HINT		UINT32_C(0x4000)
-	/*
-	 * This bit must be '1' for the ntuple_filter_id field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_NTUPLE_FILTER_ID	UINT32_C(0x8000)
-	/*
-	 * This bit must be '1' for the dst_id field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_DST_ID		UINT32_C(0x10000)
-	/*
-	 * This bit must be '1' for the mirror_vnic_id field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_MIRROR_VNIC_ID	UINT32_C(0x20000)
-	/*
-	 * This bit must be '1' for the dst_macaddr field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_DST_MACADDR	UINT32_C(0x40000)
-	/* This flag is deprecated. */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_RFS_RING_TBL_IDX	UINT32_C(0x80000)
-	/*
-	 * This value identifies a set of CFA data structures used for an L2
-	 * context.
-	 */
-	uint64_t	l2_filter_id;
-	/*
-	 * This value indicates the source MAC address in
-	 * the Ethernet header.
-	 */
-	uint8_t	src_macaddr[6];
-	/* This value indicates the ethertype in the Ethernet header. */
-	uint16_t	ethertype;
-	/*
-	 * This value indicates the type of IP address.
-	 * 4 - IPv4
-	 * 6 - IPv6
-	 * All others are invalid.
-	 */
-	uint8_t	ip_addr_type;
-	/* invalid */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_IP_ADDR_TYPE_UNKNOWN UINT32_C(0x0)
-	/* IPv4 */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_IP_ADDR_TYPE_IPV4	UINT32_C(0x4)
-	/* IPv6 */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_IP_ADDR_TYPE_IPV6	UINT32_C(0x6)
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_IP_ADDR_TYPE_LAST   HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_IP_ADDR_TYPE_IPV6
-	/*
-	 * The value of protocol filed in IP header.
-	 * Applies to UDP and TCP traffic.
-	 * 6 - TCP
-	 * 17 - UDP
-	 */
-	uint8_t	ip_protocol;
-	/* invalid */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_IP_PROTOCOL_UNKNOWN UINT32_C(0x0)
-	/* TCP */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_IP_PROTOCOL_TCP	UINT32_C(0x6)
-	/* UDP */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_IP_PROTOCOL_UDP	UINT32_C(0x11)
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_IP_PROTOCOL_LAST   HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_IP_PROTOCOL_UDP
-	/*
-	 * If set, this value shall represent the
-	 * Logical VNIC ID of the destination VNIC for the RX
-	 * path and network port id of the destination port for
-	 * the TX path.
-	 */
-	uint16_t	dst_id;
-	/*
-	 * Logical VNIC ID of the VNIC where traffic is
-	 * mirrored.
-	 */
-	uint16_t	mirror_vnic_id;
-	/*
-	 * This value indicates the tunnel type for this filter.
-	 * If this field is not specified, then the filter shall
-	 * apply to both non-tunneled and tunneled packets.
-	 * If this field conflicts with the tunnel_type specified
-	 * in the l2_filter_id, then the HWRM shall return an
-	 * error for this command.
-	 */
-	uint8_t	tunnel_type;
-	/* Non-tunnel */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_TUNNEL_TYPE_NONTUNNEL	UINT32_C(0x0)
-	/* Virtual eXtensible Local Area Network (VXLAN) */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_TUNNEL_TYPE_VXLAN	UINT32_C(0x1)
-	/* Network Virtualization Generic Routing Encapsulation (NVGRE) */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_TUNNEL_TYPE_NVGRE	UINT32_C(0x2)
-	/* Generic Routing Encapsulation (GRE) inside Ethernet payload */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_TUNNEL_TYPE_L2GRE	UINT32_C(0x3)
-	/* IP in IP */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_TUNNEL_TYPE_IPIP	UINT32_C(0x4)
-	/* Generic Network Virtualization Encapsulation (Geneve) */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_TUNNEL_TYPE_GENEVE	UINT32_C(0x5)
-	/* Multi-Protocol Label Switching (MPLS) */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_TUNNEL_TYPE_MPLS	UINT32_C(0x6)
-	/* Stateless Transport Tunnel (STT) */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_TUNNEL_TYPE_STT	UINT32_C(0x7)
-	/* Generic Routing Encapsulation (GRE) inside IP datagram payload */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_TUNNEL_TYPE_IPGRE	UINT32_C(0x8)
-	/* IPV4 over virtual eXtensible Local Area Network (IPV4oVXLAN) */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_V4	UINT32_C(0x9)
-	/*
-	 * Enhance Generic Routing Encapsulation (GRE version 1) inside IP
-	 * datagram payload
-	 */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_TUNNEL_TYPE_IPGRE_V1	UINT32_C(0xa)
-	/* Use fixed layer 2 ether type of 0xFFFF */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_TUNNEL_TYPE_L2_ETYPE	UINT32_C(0xb)
-	/*
-	 * IPV6 over virtual eXtensible Local Area Network with GPE header
-	 * (IPV6oVXLANGPE)
-	 */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_GPE_V6 UINT32_C(0xc)
-	/* Any tunneled traffic */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_TUNNEL_TYPE_ANYTUNNEL	UINT32_C(0xff)
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_TUNNEL_TYPE_LAST	HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_TUNNEL_TYPE_ANYTUNNEL
-	/*
-	 * This hint is provided to help in placing
-	 * the filter in the filter table.
-	 */
-	uint8_t	pri_hint;
-	/* No preference */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_PRI_HINT_NO_PREFER UINT32_C(0x0)
-	/* Above the given filter */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_PRI_HINT_ABOVE	UINT32_C(0x1)
-	/* Below the given filter */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_PRI_HINT_BELOW	UINT32_C(0x2)
-	/* As high as possible */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_PRI_HINT_HIGHEST   UINT32_C(0x3)
-	/* As low as possible */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_PRI_HINT_LOWEST	UINT32_C(0x4)
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_PRI_HINT_LAST	HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_PRI_HINT_LOWEST
+	/* State backup page size and level. */
+	uint8_t	backup_pg_size_backup_lvl;
+	/* State backup PBL indirect levels. */
+	#define HWRM_FW_STATE_BACKUP_INPUT_BACKUP_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FW_STATE_BACKUP_INPUT_BACKUP_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FW_STATE_BACKUP_INPUT_BACKUP_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FW_STATE_BACKUP_INPUT_BACKUP_LVL_LVL_1	UINT32_C(0x1)
 	/*
-	 * The value of source IP address to be used in filtering.
-	 * For IPv4, first four bytes represent the IP address.
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
 	 */
-	uint32_t	src_ipaddr[4];
+		#define HWRM_FW_STATE_BACKUP_INPUT_BACKUP_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FW_STATE_BACKUP_INPUT_BACKUP_LVL_LAST	HWRM_FW_STATE_BACKUP_INPUT_BACKUP_LVL_LVL_2
+	/* State backup page size. */
+	#define HWRM_FW_STATE_BACKUP_INPUT_BACKUP_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FW_STATE_BACKUP_INPUT_BACKUP_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FW_STATE_BACKUP_INPUT_BACKUP_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FW_STATE_BACKUP_INPUT_BACKUP_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FW_STATE_BACKUP_INPUT_BACKUP_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FW_STATE_BACKUP_INPUT_BACKUP_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FW_STATE_BACKUP_INPUT_BACKUP_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FW_STATE_BACKUP_INPUT_BACKUP_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FW_STATE_BACKUP_INPUT_BACKUP_PG_SIZE_LAST   HWRM_FW_STATE_BACKUP_INPUT_BACKUP_PG_SIZE_PG_1G
+	uint8_t	unused_0[7];
+	/* State backup page directory. */
+	uint64_t	backup_page_dir;
+} hwrm_fw_state_backup_input_t, *phwrm_fw_state_backup_input_t;
+
+/* hwrm_fw_state_backup_output (size:192b/24B) */
+
+typedef struct hwrm_fw_state_backup_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint32_t	backup_status;
 	/*
-	 * The value of source IP address mask to be used in
-	 * filtering.
-	 * For IPv4, first four bytes represent the IP address mask.
+	 * This bit field provides additional information if the error if
+	 * error_code in the common HWRM header is set.
 	 */
-	uint32_t	src_ipaddr_mask[4];
+	#define HWRM_FW_STATE_BACKUP_OUTPUT_BACKUP_STATUS_ERR_CODE_MASK	UINT32_C(0xff)
+	#define HWRM_FW_STATE_BACKUP_OUTPUT_BACKUP_STATUS_ERR_CODE_SFT	0
+	/* Success, no error */
+		#define HWRM_FW_STATE_BACKUP_OUTPUT_BACKUP_STATUS_ERR_CODE_SUCCESS	UINT32_C(0x0)
+	/* Data or control plane detected as non-quiesced */
+		#define HWRM_FW_STATE_BACKUP_OUTPUT_BACKUP_STATUS_ERR_CODE_QUIESCE_ERROR  UINT32_C(0x1)
+	/* General backup error */
+		#define HWRM_FW_STATE_BACKUP_OUTPUT_BACKUP_STATUS_ERR_CODE_GENERAL	UINT32_C(0x3)
+		#define HWRM_FW_STATE_BACKUP_OUTPUT_BACKUP_STATUS_ERR_CODE_LAST	HWRM_FW_STATE_BACKUP_OUTPUT_BACKUP_STATUS_ERR_CODE_GENERAL
 	/*
-	 * The value of destination IP address to be used in filtering.
-	 * For IPv4, first four bytes represent the IP address.
+	 * This bit is '0' if the backout was done in a way that firmware
+	 * may continue running normally after the backup, for example if
+	 * the host elects to skip the subsequent reset and restore for any
+	 * reason. A value of '1' indicates the act of backing up has left
+	 * the firmware/device in a state where subsequent reset is
+	 * required, for example of probing state of a queue leaves changes
+	 * state in a way that is detectable by users.
 	 */
-	uint32_t	dst_ipaddr[4];
+	#define HWRM_FW_STATE_BACKUP_OUTPUT_BACKUP_STATUS_RESET_REQUIRED	UINT32_C(0x40000000)
+	/* This bit is '1' if the backup request has fully completed. */
+	#define HWRM_FW_STATE_BACKUP_OUTPUT_BACKUP_STATUS_COMPLETE		UINT32_C(0x80000000)
+	uint8_t	unused_0[4];
+	uint8_t	unused_1[7];
 	/*
-	 * The value of destination IP address mask to be used in
-	 * filtering.
-	 * For IPv4, first four bytes represent the IP address mask.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	uint32_t	dst_ipaddr_mask[4];
+	uint8_t	valid;
+} hwrm_fw_state_backup_output_t, *phwrm_fw_state_backup_output_t;
+
+/*************************
+ * hwrm_fw_state_restore *
+ *************************/
+
+
+/* hwrm_fw_state_restore_input (size:256b/32B) */
+
+typedef struct hwrm_fw_state_restore_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * The value of source port to be used in filtering.
-	 * Applies to UDP and TCP traffic.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint16_t	src_port;
+	uint16_t	cmpl_ring;
 	/*
-	 * The value of source port mask to be used in filtering.
-	 * Applies to UDP and TCP traffic.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint16_t	src_port_mask;
+	uint16_t	seq_id;
 	/*
-	 * The value of destination port to be used in filtering.
-	 * Applies to UDP and TCP traffic.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint16_t	dst_port;
+	uint16_t	target_id;
 	/*
-	 * The value of destination port mask to be used in
-	 * filtering.
-	 * Applies to UDP and TCP traffic.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint16_t	dst_port_mask;
+	uint64_t	resp_addr;
+	/* State restore page size and level. */
+	uint8_t	restore_pg_size_restore_lvl;
+	/* State restore PBL indirect levels. */
+	#define HWRM_FW_STATE_RESTORE_INPUT_RESTORE_LVL_MASK	UINT32_C(0xf)
+	#define HWRM_FW_STATE_RESTORE_INPUT_RESTORE_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_FW_STATE_RESTORE_INPUT_RESTORE_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_FW_STATE_RESTORE_INPUT_RESTORE_LVL_LVL_1	UINT32_C(0x1)
 	/*
-	 * This is the ID of the filter that goes along with
-	 * the pri_hint.
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
 	 */
-	uint64_t	ntuple_filter_id_hint;
-} hwrm_cfa_ntuple_filter_alloc_input_t, *phwrm_cfa_ntuple_filter_alloc_input_t;
+		#define HWRM_FW_STATE_RESTORE_INPUT_RESTORE_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_FW_STATE_RESTORE_INPUT_RESTORE_LVL_LAST	HWRM_FW_STATE_RESTORE_INPUT_RESTORE_LVL_LVL_2
+	/* State restore page size. */
+	#define HWRM_FW_STATE_RESTORE_INPUT_RESTORE_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define HWRM_FW_STATE_RESTORE_INPUT_RESTORE_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define HWRM_FW_STATE_RESTORE_INPUT_RESTORE_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define HWRM_FW_STATE_RESTORE_INPUT_RESTORE_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define HWRM_FW_STATE_RESTORE_INPUT_RESTORE_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define HWRM_FW_STATE_RESTORE_INPUT_RESTORE_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define HWRM_FW_STATE_RESTORE_INPUT_RESTORE_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define HWRM_FW_STATE_RESTORE_INPUT_RESTORE_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define HWRM_FW_STATE_RESTORE_INPUT_RESTORE_PG_SIZE_LAST   HWRM_FW_STATE_RESTORE_INPUT_RESTORE_PG_SIZE_PG_1G
+	uint8_t	unused_0[7];
+	/* State restore page directory. */
+	uint64_t	restore_page_dir;
+} hwrm_fw_state_restore_input_t, *phwrm_fw_state_restore_input_t;
 
-/* hwrm_cfa_ntuple_filter_alloc_output (size:192b/24B) */
+/* hwrm_fw_state_restore_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_ntuple_filter_alloc_output {
+typedef struct hwrm_fw_state_restore_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -34966,75 +62396,50 @@ typedef struct hwrm_cfa_ntuple_filter_alloc_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* This value is an opaque id into CFA data structures. */
-	uint64_t	ntuple_filter_id;
-	/*
-	 * The flow id value in bit 0-29 is the actual ID of the flow
-	 * associated with this filter and it shall be used to match
-	 * and associate the flow identifier returned in completion
-	 * records. A value of 0xFFFFFFFF in the 32-bit flow_id field
-	 * shall indicate no valid flow id.
-	 */
-	uint32_t	flow_id;
-	/* Indicate the flow id value. */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_OUTPUT_FLOW_ID_VALUE_MASK UINT32_C(0x3fffffff)
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_OUTPUT_FLOW_ID_VALUE_SFT 0
-	/* Indicate type of the flow. */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE	UINT32_C(0x40000000)
+	uint32_t	restore_status;
 	/*
-	 * If this bit set to 0, then it indicates that the flow is
-	 * internal flow.
+	 * This bit field provides additional information if the error if
+	 * error_code in the common HWRM header is set.
 	 */
-		#define HWRM_CFA_NTUPLE_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE_INT	(UINT32_C(0x0) << 30)
+	#define HWRM_FW_STATE_RESTORE_OUTPUT_RESTORE_STATUS_ERR_CODE_MASK		UINT32_C(0xff)
+	#define HWRM_FW_STATE_RESTORE_OUTPUT_RESTORE_STATUS_ERR_CODE_SFT		0
+	/* Success, no error */
+		#define HWRM_FW_STATE_RESTORE_OUTPUT_RESTORE_STATUS_ERR_CODE_SUCCESS		UINT32_C(0x0)
+	/* General restore error */
+		#define HWRM_FW_STATE_RESTORE_OUTPUT_RESTORE_STATUS_ERR_CODE_GENERAL		UINT32_C(0x1)
+	/* Format parse error */
+		#define HWRM_FW_STATE_RESTORE_OUTPUT_RESTORE_STATUS_ERR_CODE_FORMAT_PARSE		UINT32_C(0x2)
+	/* Integrity check error */
+		#define HWRM_FW_STATE_RESTORE_OUTPUT_RESTORE_STATUS_ERR_CODE_INTEGRITY_CHECK	UINT32_C(0x3)
+		#define HWRM_FW_STATE_RESTORE_OUTPUT_RESTORE_STATUS_ERR_CODE_LAST		HWRM_FW_STATE_RESTORE_OUTPUT_RESTORE_STATUS_ERR_CODE_INTEGRITY_CHECK
 	/*
-	 * If this bit is set to 1, then it indicates that the flow is
-	 * external flow.
+	 * If a failure occurs (complete is 0), restore attempts to
+	 * completely roll back any state applied so that the failure
+	 * results in no state change. This flag indicates whether that
+	 * rollback completed successfully and thoroughly.
 	 */
-		#define HWRM_CFA_NTUPLE_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE_EXT	(UINT32_C(0x1) << 30)
-		#define HWRM_CFA_NTUPLE_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE_LAST  HWRM_CFA_NTUPLE_FILTER_ALLOC_OUTPUT_FLOW_ID_TYPE_EXT
-	/* Indicate the flow direction. */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR	UINT32_C(0x80000000)
-	/* If this bit set to 0, then it indicates rx flow. */
-		#define HWRM_CFA_NTUPLE_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR_RX	(UINT32_C(0x0) << 31)
-	/* If this bit is set to 1, then it indicates that tx flow. */
-		#define HWRM_CFA_NTUPLE_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR_TX	(UINT32_C(0x1) << 31)
-		#define HWRM_CFA_NTUPLE_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR_LAST   HWRM_CFA_NTUPLE_FILTER_ALLOC_OUTPUT_FLOW_ID_DIR_TX
+	#define HWRM_FW_STATE_RESTORE_OUTPUT_RESTORE_STATUS_FAILURE_ROLLBACK_COMPLETED	UINT32_C(0x40000000)
+	/* This bit is '1' if the restore request has fully completed. */
+	#define HWRM_FW_STATE_RESTORE_OUTPUT_RESTORE_STATUS_COMPLETE			UINT32_C(0x80000000)
 	uint8_t	unused_0[3];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_ntuple_filter_alloc_output_t, *phwrm_cfa_ntuple_filter_alloc_output_t;
-
-/* hwrm_cfa_ntuple_filter_alloc_cmd_err (size:64b/8B) */
-
-typedef struct hwrm_cfa_ntuple_filter_alloc_cmd_err {
-	/*
-	 * command specific error codes that goes to
-	 * the cmd_err field in Common HWRM Error Response.
-	 */
-	uint8_t	code;
-	/* Unknown error */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_CMD_ERR_CODE_UNKNOWN		UINT32_C(0x0)
-	/* Unable to complete operation due to conflict with Rx Mask VLAN */
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_CMD_ERR_CODE_RX_MASK_VLAN_CONFLICT_ERR UINT32_C(0x1)
-	#define HWRM_CFA_NTUPLE_FILTER_ALLOC_CMD_ERR_CODE_LAST			HWRM_CFA_NTUPLE_FILTER_ALLOC_CMD_ERR_CODE_RX_MASK_VLAN_CONFLICT_ERR
-	uint8_t	unused_0[7];
-} hwrm_cfa_ntuple_filter_alloc_cmd_err_t, *phwrm_cfa_ntuple_filter_alloc_cmd_err_t;
+} hwrm_fw_state_restore_output_t, *phwrm_fw_state_restore_output_t;
 
-/*******************************
- * hwrm_cfa_ntuple_filter_free *
- *******************************/
+/**********************
+ * hwrm_fw_secure_cfg *
+ **********************/
 
 
-/* hwrm_cfa_ntuple_filter_free_input (size:192b/24B) */
+/* hwrm_fw_secure_cfg_input (size:256b/32B) */
 
-typedef struct hwrm_cfa_ntuple_filter_free_input {
+typedef struct hwrm_fw_secure_cfg_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -35063,13 +62468,78 @@ typedef struct hwrm_cfa_ntuple_filter_free_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* This value is an opaque id into CFA data structures. */
-	uint64_t	ntuple_filter_id;
-} hwrm_cfa_ntuple_filter_free_input_t, *phwrm_cfa_ntuple_filter_free_input_t;
+	/* Specify the type of security option. */
+	uint8_t	enable;
+	/* Fields for the nvm lock mode are valid. */
+	#define HWRM_FW_SECURE_CFG_INPUT_ENABLE_NVRAM UINT32_C(0x1)
+	/* Fields for the grc access control are valid. */
+	#define HWRM_FW_SECURE_CFG_INPUT_ENABLE_GRC   UINT32_C(0x2)
+	/* Fields for the uart access control are valid. */
+	#define HWRM_FW_SECURE_CFG_INPUT_ENABLE_UART  UINT32_C(0x3)
+	#define HWRM_FW_SECURE_CFG_INPUT_ENABLE_LAST HWRM_FW_SECURE_CFG_INPUT_ENABLE_UART
+	/*
+	 * This bit field indicates the type of the configuration to be
+	 * updated.
+	 */
+	uint8_t	config_mode;
+	/* When this bit is '1', persistent config would be updated. */
+	#define HWRM_FW_SECURE_CFG_INPUT_CONFIG_MODE_PERSISTENT	UINT32_C(0x1)
+	/* When this bit is '1', runtime config would be updated. */
+	#define HWRM_FW_SECURE_CFG_INPUT_CONFIG_MODE_RUNTIME	UINT32_C(0x2)
+	/* define lock mode for nvram. */
+	uint8_t	nvm_lock_mode;
+	/*
+	 * Contents of the entire NVRAM including FW and Config can be
+	 * altered by a HWRM client.
+	 */
+	#define HWRM_FW_SECURE_CFG_INPUT_NVM_LOCK_MODE_NONE	UINT32_C(0x0)
+	/*
+	 * Only partial sections of the NVM are to be locked. To specify
+	 * section to be locked the 'nvm_partial_lock_mask' should be used.
+	 */
+	#define HWRM_FW_SECURE_CFG_INPUT_NVM_LOCK_MODE_PARTIAL UINT32_C(0x1)
+	/*
+	 * Contents of the entire NVM including FW and Config are to be
+	 * locked against any alteration by any HWRM client.
+	 */
+	#define HWRM_FW_SECURE_CFG_INPUT_NVM_LOCK_MODE_FULL	UINT32_C(0x2)
+	/*
+	 * This is a HW lock of the NVM itself. Once locked firmware has no
+	 * control to unlock. Contents of the NVM cannot be altered.
+	 * Require a power cycle to unlock.
+	 */
+	#define HWRM_FW_SECURE_CFG_INPUT_NVM_LOCK_MODE_CHIP	UINT32_C(0x3)
+	#define HWRM_FW_SECURE_CFG_INPUT_NVM_LOCK_MODE_LAST   HWRM_FW_SECURE_CFG_INPUT_NVM_LOCK_MODE_CHIP
+	/*
+	 * bit field indicating the type of partial_lock.
+	 * This field is only applicable if the partial_lock is set.
+	 */
+	uint8_t	nvm_partial_lock_mask;
+	/* When this bit is '1', updating the FW images are locked. */
+	#define HWRM_FW_SECURE_CFG_INPUT_NVM_PARTIAL_LOCK_MASK_EXE	UINT32_C(0x1)
+	/* When this bit is '1', updating the CFG are locked. */
+	#define HWRM_FW_SECURE_CFG_INPUT_NVM_PARTIAL_LOCK_MASK_CFG	UINT32_C(0x2)
+	/* specify grc access control for specified HWRM clients. */
+	uint8_t	grc_ctrl;
+	/* Read Only */
+	#define HWRM_FW_SECURE_CFG_INPUT_GRC_CTRL_RO UINT32_C(0x0)
+	/* Read-Write */
+	#define HWRM_FW_SECURE_CFG_INPUT_GRC_CTRL_RW UINT32_C(0x1)
+	#define HWRM_FW_SECURE_CFG_INPUT_GRC_CTRL_LAST HWRM_FW_SECURE_CFG_INPUT_GRC_CTRL_RW
+	/* specify debug access control via UART */
+	uint8_t	uart_ctrl;
+	/* disable UART access for debugging */
+	#define HWRM_FW_SECURE_CFG_INPUT_UART_CTRL_DISABLE UINT32_C(0x0)
+	/* enable UART access for debugging */
+	#define HWRM_FW_SECURE_CFG_INPUT_UART_CTRL_ENABLE  UINT32_C(0x1)
+	#define HWRM_FW_SECURE_CFG_INPUT_UART_CTRL_LAST   HWRM_FW_SECURE_CFG_INPUT_UART_CTRL_ENABLE
+	uint8_t	unused_0[2];
+	uint64_t	unused_1;
+} hwrm_fw_secure_cfg_input_t, *phwrm_fw_secure_cfg_input_t;
 
-/* hwrm_cfa_ntuple_filter_free_output (size:128b/16B) */
+/* hwrm_fw_secure_cfg_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_ntuple_filter_free_output {
+typedef struct hwrm_fw_secure_cfg_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -35088,16 +62558,16 @@ typedef struct hwrm_cfa_ntuple_filter_free_output {
 	 * written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_ntuple_filter_free_output_t, *phwrm_cfa_ntuple_filter_free_output_t;
+} hwrm_fw_secure_cfg_output_t, *phwrm_fw_secure_cfg_output_t;
 
-/******************************
- * hwrm_cfa_ntuple_filter_cfg *
- ******************************/
+/**********************
+ * hwrm_exec_fwd_resp *
+ **********************/
 
 
-/* hwrm_cfa_ntuple_filter_cfg_input (size:384b/48B) */
+/* hwrm_exec_fwd_resp_input (size:1024b/128B) */
 
-typedef struct hwrm_cfa_ntuple_filter_cfg_input {
+typedef struct hwrm_exec_fwd_resp_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -35126,68 +62596,27 @@ typedef struct hwrm_cfa_ntuple_filter_cfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	enables;
-	/*
-	 * This bit must be '1' for the new_dst_id field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_NTUPLE_FILTER_CFG_INPUT_ENABLES_NEW_DST_ID		UINT32_C(0x1)
-	/*
-	 * This bit must be '1' for the new_mirror_vnic_id field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_NTUPLE_FILTER_CFG_INPUT_ENABLES_NEW_MIRROR_VNIC_ID	UINT32_C(0x2)
-	/*
-	 * This bit must be '1' for the new_meter_instance_id field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_NTUPLE_FILTER_CFG_INPUT_ENABLES_NEW_METER_INSTANCE_ID	UINT32_C(0x4)
-	uint32_t	flags;
-	/*
-	 * Setting this bit to 1 indicates that dest_id field contains FID.
-	 * Setting this to 0 indicates that dest_id field contains VNIC or
-	 * VPORT.
-	 */
-	#define HWRM_CFA_NTUPLE_FILTER_CFG_INPUT_FLAGS_DEST_FID		UINT32_C(0x1)
-	/*
-	 * Setting of this flag indicates that the new_dst_id field contains
-	 * RFS ring table index. If this is not set it indicates new_dst_id
-	 * is VNIC or VPORT or function ID.  Note dest_fid and
-	 * dest_rfs_ring_idx can’t be set at the same time.
-	 */
-	#define HWRM_CFA_NTUPLE_FILTER_CFG_INPUT_FLAGS_DEST_RFS_RING_IDX	UINT32_C(0x2)
-	/* This value is an opaque id into CFA data structures. */
-	uint64_t	ntuple_filter_id;
-	/*
-	 * If set, this value shall represent the new
-	 * Logical VNIC ID of the destination VNIC for the RX
-	 * path and new network port id of the destination port for
-	 * the TX path.
-	 */
-	uint32_t	new_dst_id;
-	/*
-	 * New Logical VNIC ID of the VNIC where traffic is
-	 * mirrored.
-	 */
-	uint32_t	new_mirror_vnic_id;
 	/*
-	 * New meter to attach to the flow. Specifying the
-	 * invalid instance ID is used to remove any existing
-	 * meter from the flow.
+	 * This is an encapsulated request. This request should
+	 * be executed by the HWRM and the response should be
+	 * provided in the response buffer inside the encapsulated
+	 * request.
 	 */
-	uint16_t	new_meter_instance_id;
+	uint32_t	encap_request[26];
 	/*
-	 * A value of 0xfff is considered invalid and implies the
-	 * instance is not configured.
+	 * This value indicates the target id of the response to
+	 * the encapsulated request.
+	 * 0x0 - 0xFFF8 - Used for function ids
+	 * 0xFFF8 - 0xFFFE - Reserved for internal processors
+	 * 0xFFFF - HWRM
 	 */
-	#define HWRM_CFA_NTUPLE_FILTER_CFG_INPUT_NEW_METER_INSTANCE_ID_INVALID UINT32_C(0xffff)
-	#define HWRM_CFA_NTUPLE_FILTER_CFG_INPUT_NEW_METER_INSTANCE_ID_LAST   HWRM_CFA_NTUPLE_FILTER_CFG_INPUT_NEW_METER_INSTANCE_ID_INVALID
-	uint8_t	unused_1[6];
-} hwrm_cfa_ntuple_filter_cfg_input_t, *phwrm_cfa_ntuple_filter_cfg_input_t;
+	uint16_t	encap_resp_target_id;
+	uint8_t	unused_0[6];
+} hwrm_exec_fwd_resp_input_t, *phwrm_exec_fwd_resp_input_t;
 
-/* hwrm_cfa_ntuple_filter_cfg_output (size:128b/16B) */
+/* hwrm_exec_fwd_resp_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_ntuple_filter_cfg_output {
+typedef struct hwrm_exec_fwd_resp_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -35200,22 +62629,21 @@ typedef struct hwrm_cfa_ntuple_filter_cfg_output {
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_ntuple_filter_cfg_output_t, *phwrm_cfa_ntuple_filter_cfg_output_t;
+} hwrm_exec_fwd_resp_output_t, *phwrm_exec_fwd_resp_output_t;
 
-/**************************
- * hwrm_cfa_em_flow_alloc *
- **************************/
+/************************
+ * hwrm_reject_fwd_resp *
+ ************************/
 
 
-/* hwrm_cfa_em_flow_alloc_input (size:896b/112B) */
+/* hwrm_reject_fwd_resp_input (size:1024b/128B) */
 
-typedef struct hwrm_cfa_em_flow_alloc_input {
+typedef struct hwrm_reject_fwd_resp_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -35244,291 +62672,118 @@ typedef struct hwrm_cfa_em_flow_alloc_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	flags;
-	/*
-	 * Enumeration denoting the RX, TX type of the resource.
-	 * This enumeration is used for resources that are similar for both
-	 * TX and RX paths of the chip.
-	 */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_FLAGS_PATH	UINT32_C(0x1)
-	/* tx path */
-		#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_FLAGS_PATH_TX	UINT32_C(0x0)
-	/* rx path */
-		#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_FLAGS_PATH_RX	UINT32_C(0x1)
-		#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_FLAGS_PATH_LAST	HWRM_CFA_EM_FLOW_ALLOC_INPUT_FLAGS_PATH_RX
-	/*
-	 * Setting of this flag indicates enabling of a byte counter for a
-	 * given flow.
-	 */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_FLAGS_BYTE_CTR	UINT32_C(0x2)
-	/*
-	 * Setting of this flag indicates enabling of a packet counter for a
-	 * given flow.
-	 */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_FLAGS_PKT_CTR	UINT32_C(0x4)
-	/*
-	 * Setting of this flag indicates de-capsulation action for the
-	 * given flow.
-	 */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_FLAGS_DECAP	UINT32_C(0x8)
-	/*
-	 * Setting of this flag indicates encapsulation action for the
-	 * given flow.
-	 */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_FLAGS_ENCAP	UINT32_C(0x10)
-	/*
-	 * Setting of this flag indicates drop action. If this flag is not
-	 * set, then it should be considered accept action.
-	 */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_FLAGS_DROP	UINT32_C(0x20)
-	/*
-	 * Setting of this flag indicates that a meter is expected to be
-	 * attached to this flow. This hint can be used when choosing the
-	 * action record format required for the flow.
-	 */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_FLAGS_METER	UINT32_C(0x40)
-	uint32_t	enables;
-	/*
-	 * This bit must be '1' for the l2_filter_id field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_L2_FILTER_ID	UINT32_C(0x1)
-	/*
-	 * This bit must be '1' for the tunnel_type field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_TUNNEL_TYPE	UINT32_C(0x2)
-	/*
-	 * This bit must be '1' for the tunnel_id field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_TUNNEL_ID		UINT32_C(0x4)
-	/*
-	 * This bit must be '1' for the src_macaddr field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_SRC_MACADDR	UINT32_C(0x8)
-	/*
-	 * This bit must be '1' for the dst_macaddr field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_DST_MACADDR	UINT32_C(0x10)
-	/*
-	 * This bit must be '1' for the ovlan_vid field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_OVLAN_VID		UINT32_C(0x20)
-	/*
-	 * This bit must be '1' for the ivlan_vid field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_IVLAN_VID		UINT32_C(0x40)
-	/*
-	 * This bit must be '1' for the ethertype field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_ETHERTYPE		UINT32_C(0x80)
-	/*
-	 * This bit must be '1' for the src_ipaddr field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_SRC_IPADDR		UINT32_C(0x100)
-	/*
-	 * This bit must be '1' for the dst_ipaddr field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_DST_IPADDR		UINT32_C(0x200)
-	/*
-	 * This bit must be '1' for the ipaddr_type field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_IPADDR_TYPE	UINT32_C(0x400)
-	/*
-	 * This bit must be '1' for the ip_protocol field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_IP_PROTOCOL	UINT32_C(0x800)
-	/*
-	 * This bit must be '1' for the src_port field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_SRC_PORT		UINT32_C(0x1000)
-	/*
-	 * This bit must be '1' for the dst_port field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_DST_PORT		UINT32_C(0x2000)
-	/*
-	 * This bit must be '1' for the dst_id field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_DST_ID		UINT32_C(0x4000)
-	/*
-	 * This bit must be '1' for the mirror_vnic_id field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_MIRROR_VNIC_ID	UINT32_C(0x8000)
 	/*
-	 * This bit must be '1' for the encap_record_id field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_ENCAP_RECORD_ID	UINT32_C(0x10000)
-	/*
-	 * This bit must be '1' for the meter_instance_id field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_METER_INSTANCE_ID	UINT32_C(0x20000)
-	/*
-	 * This value identifies a set of CFA data structures used for an L2
-	 * context.
-	 */
-	uint64_t	l2_filter_id;
-	/* Tunnel Type. */
-	uint8_t	tunnel_type;
-	/* Non-tunnel */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_TUNNEL_TYPE_NONTUNNEL	UINT32_C(0x0)
-	/* Virtual eXtensible Local Area Network (VXLAN) */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_TUNNEL_TYPE_VXLAN	UINT32_C(0x1)
-	/* Network Virtualization Generic Routing Encapsulation (NVGRE) */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_TUNNEL_TYPE_NVGRE	UINT32_C(0x2)
-	/* Generic Routing Encapsulation (GRE) inside Ethernet payload */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_TUNNEL_TYPE_L2GRE	UINT32_C(0x3)
-	/* IP in IP */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_TUNNEL_TYPE_IPIP	UINT32_C(0x4)
-	/* Generic Network Virtualization Encapsulation (Geneve) */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_TUNNEL_TYPE_GENEVE	UINT32_C(0x5)
-	/* Multi-Protocol Label Switching (MPLS) */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_TUNNEL_TYPE_MPLS	UINT32_C(0x6)
-	/* Stateless Transport Tunnel (STT) */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_TUNNEL_TYPE_STT	UINT32_C(0x7)
-	/* Generic Routing Encapsulation (GRE) inside IP datagram payload */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_TUNNEL_TYPE_IPGRE	UINT32_C(0x8)
-	/* IPV4 over virtual eXtensible Local Area Network (IPV4oVXLAN) */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_V4	UINT32_C(0x9)
-	/*
-	 * Enhance Generic Routing Encapsulation (GRE version 1) inside IP
-	 * datagram payload
-	 */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_TUNNEL_TYPE_IPGRE_V1	UINT32_C(0xa)
-	/* Use fixed layer 2 ether type of 0xFFFF */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_TUNNEL_TYPE_L2_ETYPE	UINT32_C(0xb)
-	/*
-	 * IPV6 over virtual eXtensible Local Area Network with GPE header
-	 * (IPV6oVXLANGPE)
-	 */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_GPE_V6 UINT32_C(0xc)
-	/* Any tunneled traffic */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_TUNNEL_TYPE_ANYTUNNEL	UINT32_C(0xff)
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_TUNNEL_TYPE_LAST	HWRM_CFA_EM_FLOW_ALLOC_INPUT_TUNNEL_TYPE_ANYTUNNEL
-	uint8_t	unused_0[3];
-	/*
-	 * Tunnel identifier.
-	 * Virtual Network Identifier (VNI). Only valid with
-	 * tunnel_types VXLAN, NVGRE, and Geneve.
-	 * Only lower 24-bits of VNI field are used
-	 * in setting up the filter.
-	 */
-	uint32_t	tunnel_id;
-	/*
-	 * This value indicates the source MAC address in
-	 * the Ethernet header.
-	 */
-	uint8_t	src_macaddr[6];
-	/* The meter instance to attach to the flow. */
-	uint16_t	meter_instance_id;
-	/*
-	 * A value of 0xfff is considered invalid and implies the
-	 * instance is not configured.
-	 */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_METER_INSTANCE_ID_INVALID UINT32_C(0xffff)
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_METER_INSTANCE_ID_LAST   HWRM_CFA_EM_FLOW_ALLOC_INPUT_METER_INSTANCE_ID_INVALID
-	/*
-	 * This value indicates the destination MAC address in
-	 * the Ethernet header.
-	 */
-	uint8_t	dst_macaddr[6];
-	/*
-	 * This value indicates the VLAN ID of the outer VLAN tag
-	 * in the Ethernet header.
+	 * This is an encapsulated request. This request should
+	 * be rejected by the HWRM and the error response should be
+	 * provided in the response buffer inside the encapsulated
+	 * request.
 	 */
-	uint16_t	ovlan_vid;
+	uint32_t	encap_request[26];
 	/*
-	 * This value indicates the VLAN ID of the inner VLAN tag
-	 * in the Ethernet header.
+	 * This value indicates the target id of the response to
+	 * the encapsulated request.
+	 * 0x0 - 0xFFF8 - Used for function ids
+	 * 0xFFF8 - 0xFFFE - Reserved for internal processors
+	 * 0xFFFF - HWRM
 	 */
-	uint16_t	ivlan_vid;
-	/* This value indicates the ethertype in the Ethernet header. */
-	uint16_t	ethertype;
+	uint16_t	encap_resp_target_id;
+	uint8_t	unused_0[6];
+} hwrm_reject_fwd_resp_input_t, *phwrm_reject_fwd_resp_input_t;
+
+/* hwrm_reject_fwd_resp_output (size:128b/16B) */
+
+typedef struct hwrm_reject_fwd_resp_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
 	/*
-	 * This value indicates the type of IP address.
-	 * 4 - IPv4
-	 * 6 - IPv6
-	 * All others are invalid.
-	 */
-	uint8_t	ip_addr_type;
-	/* invalid */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_IP_ADDR_TYPE_UNKNOWN UINT32_C(0x0)
-	/* IPv4 */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_IP_ADDR_TYPE_IPV4	UINT32_C(0x4)
-	/* IPv6 */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_IP_ADDR_TYPE_IPV6	UINT32_C(0x6)
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_IP_ADDR_TYPE_LAST   HWRM_CFA_EM_FLOW_ALLOC_INPUT_IP_ADDR_TYPE_IPV6
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_reject_fwd_resp_output_t, *phwrm_reject_fwd_resp_output_t;
+
+/*****************
+ * hwrm_fwd_resp *
+ *****************/
+
+
+/* hwrm_fwd_resp_input (size:1024b/128B) */
+
+typedef struct hwrm_fwd_resp_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * The value of protocol filed in IP header.
-	 * Applies to UDP and TCP traffic.
-	 * 6 - TCP
-	 * 17 - UDP
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint8_t	ip_protocol;
-	/* invalid */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_IP_PROTOCOL_UNKNOWN UINT32_C(0x0)
-	/* TCP */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_IP_PROTOCOL_TCP	UINT32_C(0x6)
-	/* UDP */
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_IP_PROTOCOL_UDP	UINT32_C(0x11)
-	#define HWRM_CFA_EM_FLOW_ALLOC_INPUT_IP_PROTOCOL_LAST   HWRM_CFA_EM_FLOW_ALLOC_INPUT_IP_PROTOCOL_UDP
-	uint8_t	unused_1[2];
+	uint16_t	cmpl_ring;
 	/*
-	 * The value of source IP address to be used in filtering.
-	 * For IPv4, first four bytes represent the IP address.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint32_t	src_ipaddr[4];
+	uint16_t	seq_id;
 	/*
-	 * big_endian = True
-	 *	The value of destination IP address to be used in filtering.
-	 *	For IPv4, first four bytes represent the IP address.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint32_t	dst_ipaddr[4];
+	uint16_t	target_id;
 	/*
-	 * The value of source port to be used in filtering.
-	 * Applies to UDP and TCP traffic.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint16_t	src_port;
+	uint64_t	resp_addr;
 	/*
-	 * The value of destination port to be used in filtering.
-	 * Applies to UDP and TCP traffic.
+	 * This value indicates the target id of the encapsulated
+	 * response.
+	 * 0x0 - 0xFFF8 - Used for function ids
+	 * 0xFFF8 - 0xFFFE - Reserved for internal processors
+	 * 0xFFFF - HWRM
 	 */
-	uint16_t	dst_port;
+	uint16_t	encap_resp_target_id;
 	/*
-	 * If set, this value shall represent the
-	 * Logical VNIC ID of the destination VNIC for the RX
-	 * path and network port id of the destination port for
-	 * the TX path.
+	 * This value indicates the completion ring the encapsulated
+	 * response will be optionally completed on. If the value is
+	 * -1, then no CR completion shall be generated for the
+	 * encapsulated response. Any other value must be a
+	 * valid CR ring_id value. If a valid encap_resp_cmpl_ring
+	 * is provided, then a CR completion shall be generated for
+	 * the encapsulated response.
 	 */
-	uint16_t	dst_id;
+	uint16_t	encap_resp_cmpl_ring;
+	/* This field indicates the length of encapsulated response. */
+	uint16_t	encap_resp_len;
+	uint8_t	unused_0;
+	uint8_t	unused_1;
 	/*
-	 * Logical VNIC ID of the VNIC where traffic is
-	 * mirrored.
+	 * This is the host address where the encapsulated response
+	 * will be written.
+	 * This area must be 16B aligned and must be cleared to zero
+	 * before the original request is made.
 	 */
-	uint16_t	mirror_vnic_id;
-	/* Logical ID of the encapsulation record. */
-	uint32_t	encap_record_id;
-	uint8_t	unused_2[4];
-} hwrm_cfa_em_flow_alloc_input_t, *phwrm_cfa_em_flow_alloc_input_t;
+	uint64_t	encap_resp_addr;
+	/* This is an encapsulated response. */
+	uint32_t	encap_resp[24];
+} hwrm_fwd_resp_input_t, *phwrm_fwd_resp_input_t;
 
-/* hwrm_cfa_em_flow_alloc_output (size:192b/24B) */
+/* hwrm_fwd_resp_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_em_flow_alloc_output {
+typedef struct hwrm_fwd_resp_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -35537,59 +62792,25 @@ typedef struct hwrm_cfa_em_flow_alloc_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* This value is an opaque id into CFA data structures. */
-	uint64_t	em_filter_id;
-	/*
-	 * The flow id value in bit 0-29 is the actual ID of the flow
-	 * associated with this filter and it shall be used to match
-	 * and associate the flow identifier returned in completion
-	 * records. A value of 0xFFFFFFFF in the 32-bit flow_id field
-	 * shall indicate no valid flow id.
-	 */
-	uint32_t	flow_id;
-	/* Indicate the flow id value. */
-	#define HWRM_CFA_EM_FLOW_ALLOC_OUTPUT_FLOW_ID_VALUE_MASK UINT32_C(0x3fffffff)
-	#define HWRM_CFA_EM_FLOW_ALLOC_OUTPUT_FLOW_ID_VALUE_SFT 0
-	/* Indicate type of the flow. */
-	#define HWRM_CFA_EM_FLOW_ALLOC_OUTPUT_FLOW_ID_TYPE	UINT32_C(0x40000000)
-	/*
-	 * If this bit set to 0, then it indicates that the flow is
-	 * internal flow.
-	 */
-		#define HWRM_CFA_EM_FLOW_ALLOC_OUTPUT_FLOW_ID_TYPE_INT	(UINT32_C(0x0) << 30)
-	/*
-	 * If this bit is set to 1, then it indicates that the flow is
-	 * external flow.
-	 */
-		#define HWRM_CFA_EM_FLOW_ALLOC_OUTPUT_FLOW_ID_TYPE_EXT	(UINT32_C(0x1) << 30)
-		#define HWRM_CFA_EM_FLOW_ALLOC_OUTPUT_FLOW_ID_TYPE_LAST  HWRM_CFA_EM_FLOW_ALLOC_OUTPUT_FLOW_ID_TYPE_EXT
-	/* Indicate the flow direction. */
-	#define HWRM_CFA_EM_FLOW_ALLOC_OUTPUT_FLOW_ID_DIR	UINT32_C(0x80000000)
-	/* If this bit set to 0, then it indicates rx flow. */
-		#define HWRM_CFA_EM_FLOW_ALLOC_OUTPUT_FLOW_ID_DIR_RX	(UINT32_C(0x0) << 31)
-	/* If this bit is set to 1, then it indicates that tx flow. */
-		#define HWRM_CFA_EM_FLOW_ALLOC_OUTPUT_FLOW_ID_DIR_TX	(UINT32_C(0x1) << 31)
-		#define HWRM_CFA_EM_FLOW_ALLOC_OUTPUT_FLOW_ID_DIR_LAST   HWRM_CFA_EM_FLOW_ALLOC_OUTPUT_FLOW_ID_DIR_TX
-	uint8_t	unused_0[3];
+	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_em_flow_alloc_output_t, *phwrm_cfa_em_flow_alloc_output_t;
+} hwrm_fwd_resp_output_t, *phwrm_fwd_resp_output_t;
 
-/*************************
- * hwrm_cfa_em_flow_free *
- *************************/
+/*****************************
+ * hwrm_fwd_async_event_cmpl *
+ *****************************/
 
 
-/* hwrm_cfa_em_flow_free_input (size:192b/24B) */
+/* hwrm_fwd_async_event_cmpl_input (size:320b/40B) */
 
-typedef struct hwrm_cfa_em_flow_free_input {
+typedef struct hwrm_fwd_async_event_cmpl_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -35618,13 +62839,23 @@ typedef struct hwrm_cfa_em_flow_free_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* This value is an opaque id into CFA data structures. */
-	uint64_t	em_filter_id;
-} hwrm_cfa_em_flow_free_input_t, *phwrm_cfa_em_flow_free_input_t;
+	/*
+	 * This value indicates the target id of the encapsulated
+	 * asynchronous event.
+	 * 0x0 - 0xFFF8 - Used for function ids
+	 * 0xFFF8 - 0xFFFE - Reserved for internal processors
+	 * 0xFFFF - Broadcast to all children VFs (only applicable when
+	 * a PF is the requester)
+	 */
+	uint16_t	encap_async_event_target_id;
+	uint8_t	unused_0[6];
+	/* This is an encapsulated asynchronous event completion. */
+	uint32_t	encap_async_event_cmpl[4];
+} hwrm_fwd_async_event_cmpl_input_t, *phwrm_fwd_async_event_cmpl_input_t;
 
-/* hwrm_cfa_em_flow_free_output (size:128b/16B) */
+/* hwrm_fwd_async_event_cmpl_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_em_flow_free_output {
+typedef struct hwrm_fwd_async_event_cmpl_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -35637,22 +62868,21 @@ typedef struct hwrm_cfa_em_flow_free_output {
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_em_flow_free_output_t, *phwrm_cfa_em_flow_free_output_t;
+} hwrm_fwd_async_event_cmpl_output_t, *phwrm_fwd_async_event_cmpl_output_t;
 
-/************************
- * hwrm_cfa_meter_qcaps *
- ************************/
+/***************************
+ * hwrm_temp_monitor_query *
+ ***************************/
 
 
-/* hwrm_cfa_meter_qcaps_input (size:128b/16B) */
+/* hwrm_temp_monitor_query_input (size:128b/16B) */
 
-typedef struct hwrm_cfa_meter_qcaps_input {
+typedef struct hwrm_temp_monitor_query_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -35681,11 +62911,11 @@ typedef struct hwrm_cfa_meter_qcaps_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-} hwrm_cfa_meter_qcaps_input_t, *phwrm_cfa_meter_qcaps_input_t;
+} hwrm_temp_monitor_query_input_t, *phwrm_temp_monitor_query_input_t;
 
-/* hwrm_cfa_meter_qcaps_output (size:320b/40B) */
+/* hwrm_temp_monitor_query_output (size:192b/24B) */
 
-typedef struct hwrm_cfa_meter_qcaps_output {
+typedef struct hwrm_temp_monitor_query_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -35694,80 +62924,119 @@ typedef struct hwrm_cfa_meter_qcaps_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint32_t	flags;
 	/*
-	 * Enumeration denoting the clock at which the Meter is running
-	 * with. This enumeration is used for resources that are similar
-	 * for both TX and RX paths of the chip.
+	 * The HWRM shall provide the current temperature of
+	 * the device in Celsius. This is the max of PCIe_temp
+	 * and PM_temp
 	 */
-	#define HWRM_CFA_METER_QCAPS_OUTPUT_FLAGS_CLOCK_MASK  UINT32_C(0xf)
-	#define HWRM_CFA_METER_QCAPS_OUTPUT_FLAGS_CLOCK_SFT   0
-	/* 375 MHz */
-		#define HWRM_CFA_METER_QCAPS_OUTPUT_FLAGS_CLOCK_375MHZ  UINT32_C(0x0)
-	/* 625 MHz */
-		#define HWRM_CFA_METER_QCAPS_OUTPUT_FLAGS_CLOCK_625MHZ  UINT32_C(0x1)
-		#define HWRM_CFA_METER_QCAPS_OUTPUT_FLAGS_CLOCK_LAST   HWRM_CFA_METER_QCAPS_OUTPUT_FLAGS_CLOCK_625MHZ
-	uint8_t	unused_0[4];
+	uint8_t	temp;
 	/*
-	 * The minimum guaranteed number of tx meter profiles supported
-	 * for this function.
+	 * The HWRM shall provide the current temperature of
+	 * the phy in Celsius.
 	 */
-	uint16_t	min_tx_profile;
+	uint8_t	phy_temp;
 	/*
-	 * The maximum non-guaranteed number of tx meter profiles supported
-	 * for this function.
+	 * The HWRM shall provide the current temperature of
+	 * the module_index in Celsius.
 	 */
-	uint16_t	max_tx_profile;
+	uint8_t	om_temp;
+	/* Describe individual temperature sensor condition. */
+	uint8_t	flags;
 	/*
-	 * The minimum guaranteed number of rx meter profiles supported
-	 * for this function.
+	 * "1" in this bit indicates temperature read not
+	 * successful.
 	 */
-	uint16_t	min_rx_profile;
+	#define HWRM_TEMP_MONITOR_QUERY_OUTPUT_FLAGS_TEMP_NOT_AVAILABLE		UINT32_C(0x1)
 	/*
-	 * The maximum non-guaranteed number of rx meter profiles supported
-	 * for this function.
+	 * "1" in this bit indicates phy temperature read not
+	 * successful.
 	 */
-	uint16_t	max_rx_profile;
+	#define HWRM_TEMP_MONITOR_QUERY_OUTPUT_FLAGS_PHY_TEMP_NOT_AVAILABLE	UINT32_C(0x2)
+	/* "1" in this bit indicates optical module(s) not present. */
+	#define HWRM_TEMP_MONITOR_QUERY_OUTPUT_FLAGS_OM_NOT_PRESENT		UINT32_C(0x4)
 	/*
-	 * The minimum guaranteed number of tx meter instances supported
-	 * for this function.
+	 * "1" in this bit indicates om temperature read not
+	 * successful.
 	 */
-	uint16_t	min_tx_instance;
+	#define HWRM_TEMP_MONITOR_QUERY_OUTPUT_FLAGS_OM_TEMP_NOT_AVAILABLE	UINT32_C(0x8)
 	/*
-	 * The maximum non-guaranteed number of tx meter instances supported
-	 * for this function.
+	 * "1" in this bit indicates the extended temperature fields are
+	 * available.
 	 */
-	uint16_t	max_tx_instance;
+	#define HWRM_TEMP_MONITOR_QUERY_OUTPUT_FLAGS_EXT_TEMP_FIELDS_AVAILABLE	UINT32_C(0x10)
 	/*
-	 * The minimum guaranteed number of rx meter instances supported
-	 * for this function.
+	 * "1" in this bit indicates the thermal threshold values are
+	 * available.
 	 */
-	uint16_t	min_rx_instance;
+	#define HWRM_TEMP_MONITOR_QUERY_OUTPUT_FLAGS_THRESHOLD_VALUES_AVAILABLE	UINT32_C(0x20)
 	/*
-	 * The maximum non-guaranteed number of rx meter instances supported
-	 * for this function.
+	 * This field encodes the current device temperature in Celsius.
+	 * This field is unsigned and the value range of 0 to 255 is used to
+	 * indicate a temperature range from -64 to +191. The actual
+	 * temperature is derived by subtracting 64 from this field.
+	 * Example: A value of 0 represents a temperature of -64, a value of
+	 * 255 represents a temperature of 191.
 	 */
-	uint16_t	max_rx_instance;
-	uint8_t	unused_1[7];
+	uint8_t	temp2;
+	/*
+	 * This field encodes the current phy temperature in Celsius. This
+	 * field is unsigned and the value range of 0 to 255 is used to
+	 * indicate a temperature range from -64 to +191. The actual
+	 * temperature is derived by subtracting 64 from this field.
+	 * Example: A value of 0 represents a temperature of -64, a value of
+	 * 255 represents a temperature of 191.
+	 */
+	uint8_t	phy_temp2;
+	/*
+	 * This field encodes the current module index temperature in Celsius.
+	 * This field is unsigned and the value range of 0 to 255 is used to
+	 * indicate a temperature range from -64 to +191. The actual
+	 * temperature is derived by subtracting 64 from this field.
+	 * Example: A value of 0 represents a temperature of -64, a value of
+	 * 255 represents a temperature of 191.
+	 */
+	uint8_t	om_temp2;
+	/*
+	 * This field reports the device's threshold value for reporting
+	 * a warning indication. The temperature is reported in Celsius.
+	 */
+	uint8_t	warn_threshold;
+	/*
+	 * This field reports the device's threshold value for reporting
+	 * a critical indication. The temperature is reported in Celsius.
+	 */
+	uint8_t	critical_threshold;
+	/*
+	 * This field reports the device's threshold value for reporting
+	 * a fatal indication. The temperature is reported in Celsius.
+	 */
+	uint8_t	fatal_threshold;
+	/*
+	 * This field reports the threshold value at which the device will
+	 * a perform a self shutdown. The temperature is reported in Celsius.
+	 * If the value is zero, then that indicates self shutdown is not
+	 * configured.
+	 */
+	uint8_t	shutdown_threshold;
+	uint8_t	unused_0[4];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_meter_qcaps_output_t, *phwrm_cfa_meter_qcaps_output_t;
+} hwrm_temp_monitor_query_output_t, *phwrm_temp_monitor_query_output_t;
 
-/********************************
- * hwrm_cfa_meter_profile_alloc *
- ********************************/
+/************************
+ * hwrm_reg_power_query *
+ ************************/
 
 
-/* hwrm_cfa_meter_profile_alloc_input (size:320b/40B) */
+/* hwrm_reg_power_query_input (size:128b/16B) */
 
-typedef struct hwrm_cfa_meter_profile_alloc_input {
+typedef struct hwrm_reg_power_query_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -35796,154 +63065,87 @@ typedef struct hwrm_cfa_meter_profile_alloc_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint8_t	flags;
+} hwrm_reg_power_query_input_t, *phwrm_reg_power_query_input_t;
+
+/* hwrm_reg_power_query_output (size:192b/24B) */
+
+typedef struct hwrm_reg_power_query_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Describe availability of switching regulator power values. */
+	uint32_t	flags;
+	/* When this bit is set to '1', the input power is available. */
+	#define HWRM_REG_POWER_QUERY_OUTPUT_FLAGS_IN_POWER_AVAILABLE	UINT32_C(0x1)
+	/* When this bit is set to '1', the output power is available. */
+	#define HWRM_REG_POWER_QUERY_OUTPUT_FLAGS_OUT_POWER_AVAILABLE	UINT32_C(0x2)
 	/*
-	 * Enumeration denoting the RX, TX type of the resource.
-	 * This enumeration is used for resources that are similar for both
-	 * TX and RX paths of the chip.
+	 * The HWRM shall provide the current switching regulator
+	 * input power in mW, if available.
 	 */
-	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_FLAGS_PATH	UINT32_C(0x1)
-	/* tx path */
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_FLAGS_PATH_TX	UINT32_C(0x0)
-	/* rx path */
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_FLAGS_PATH_RX	UINT32_C(0x1)
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_FLAGS_PATH_LAST HWRM_CFA_METER_PROFILE_ALLOC_INPUT_FLAGS_PATH_RX
-	/* The meter algorithm type. */
-	uint8_t	meter_type;
-	/* RFC 2697 (srTCM) */
-	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_METER_TYPE_RFC2697 UINT32_C(0x0)
-	/* RFC 2698 (trTCM) */
-	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_METER_TYPE_RFC2698 UINT32_C(0x1)
-	/* RFC 4115 (trTCM) */
-	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_METER_TYPE_RFC4115 UINT32_C(0x2)
-	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_METER_TYPE_LAST   HWRM_CFA_METER_PROFILE_ALLOC_INPUT_METER_TYPE_RFC4115
+	uint32_t	in_power_mw;
 	/*
-	 * This field is reserved for the future use.
-	 * It shall be set to 0.
+	 * The HWRM shall provide the current switching regulator
+	 * output power in mW, if available.
 	 */
-	uint16_t	reserved1;
+	uint32_t	out_power_mw;
+	uint8_t	unused_0[3];
 	/*
-	 * This field is reserved for the future use.
-	 * It shall be set to 0.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	uint32_t	reserved2;
-	/* A meter rate specified in bytes-per-second. */
-	uint32_t	commit_rate;
-	/* The bandwidth value. */
-	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_RATE_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_RATE_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_RATE_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_RATE_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_RATE_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_RATE_SCALE_LAST		HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_RATE_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_RATE_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_RATE_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_RATE_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_RATE_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_RATE_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_RATE_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_RATE_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Raw value */
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_RATE_BW_VALUE_UNIT_RAW	(UINT32_C(0x7) << 29)
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_RATE_BW_VALUE_UNIT_LAST	HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_RATE_BW_VALUE_UNIT_RAW
-	/* A meter burst size specified in bytes. */
-	uint32_t	commit_burst;
-	/* The bandwidth value. */
-	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_BURST_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_BURST_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_BURST_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_BURST_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_BURST_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_BURST_SCALE_LAST		HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_BURST_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_BURST_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_BURST_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_BURST_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_BURST_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_BURST_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_BURST_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_BURST_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid value */
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_BURST_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_BURST_BW_VALUE_UNIT_LAST	HWRM_CFA_METER_PROFILE_ALLOC_INPUT_COMMIT_BURST_BW_VALUE_UNIT_INVALID
-	/* A meter rate specified in bytes-per-second. */
-	uint32_t	excess_peak_rate;
-	/* The bandwidth value. */
-	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_RATE_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_RATE_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_RATE_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_RATE_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_RATE_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_RATE_SCALE_LAST		HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_RATE_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Raw unit */
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_RAW	(UINT32_C(0x7) << 29)
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_LAST	HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_RAW
-	/* A meter burst size specified in bytes. */
-	uint32_t	excess_peak_burst;
-	/* The bandwidth value. */
-	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_BURST_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_BURST_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_BURST_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_BURST_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_BURST_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_BURST_SCALE_LAST		HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_BURST_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_LAST	HWRM_CFA_METER_PROFILE_ALLOC_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_INVALID
-} hwrm_cfa_meter_profile_alloc_input_t, *phwrm_cfa_meter_profile_alloc_input_t;
+	uint8_t	valid;
+} hwrm_reg_power_query_output_t, *phwrm_reg_power_query_output_t;
+
+/*****************************
+ * hwrm_core_frequency_query *
+ *****************************/
+
+
+/* hwrm_core_frequency_query_input (size:128b/16B) */
+
+typedef struct hwrm_core_frequency_query_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+} hwrm_core_frequency_query_input_t, *phwrm_core_frequency_query_input_t;
 
-/* hwrm_cfa_meter_profile_alloc_output (size:128b/16B) */
+/* hwrm_core_frequency_query_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_meter_profile_alloc_output {
+typedef struct hwrm_core_frequency_query_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -35952,34 +63154,206 @@ typedef struct hwrm_cfa_meter_profile_alloc_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* This value identifies a meter profile in CFA. */
-	uint16_t	meter_profile_id;
+	/* The HWRM shall provide the core frequency in Hz. */
+	uint32_t	core_frequency_hz;
+	uint8_t	unused_0[3];
 	/*
-	 * A value of 0xfff is considered invalid and implies the
-	 * profile is not configured.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	#define HWRM_CFA_METER_PROFILE_ALLOC_OUTPUT_METER_PROFILE_ID_INVALID UINT32_C(0xffff)
-	#define HWRM_CFA_METER_PROFILE_ALLOC_OUTPUT_METER_PROFILE_ID_LAST   HWRM_CFA_METER_PROFILE_ALLOC_OUTPUT_METER_PROFILE_ID_INVALID
-	uint8_t	unused_0[5];
+	uint8_t	valid;
+} hwrm_core_frequency_query_output_t, *phwrm_core_frequency_query_output_t;
+
+/****************************
+ * hwrm_reg_power_histogram *
+ ****************************/
+
+
+/* hwrm_reg_power_histogram_input (size:192b/24B) */
+
+typedef struct hwrm_reg_power_histogram_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Describe operational mode of power histogram command. */
+	uint32_t	flags;
+	/*
+	 * When this bit is set to '1', histogram data for the respective
+	 * client (HWRM or BMC) is cleared after read.
+	 */
+	#define HWRM_REG_POWER_HISTOGRAM_INPUT_FLAGS_CLEAR_HISTOGRAM	UINT32_C(0x1)
+	uint32_t	unused_0;
+} hwrm_reg_power_histogram_input_t, *phwrm_reg_power_histogram_input_t;
+
+/* hwrm_reg_power_histogram_output (size:1088b/136B) */
+
+typedef struct hwrm_reg_power_histogram_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Describe output characteristics of power histogram command. */
+	uint16_t	flags;
+	/*
+	 * Indicates whether input or output power is used. Some switching
+	 * regulators provide both input and output voltage and current
+	 * measurements, and others provide only output measurements. When
+	 * both are available, input is used. This value is constant for a
+	 * given board.
+	 */
+	#define HWRM_REG_POWER_HISTOGRAM_OUTPUT_FLAGS_POWER_IN_OUT	UINT32_C(0x1)
+	/*
+	 * The switching regulator's input power is used
+	 * data.
+	 */
+		#define HWRM_REG_POWER_HISTOGRAM_OUTPUT_FLAGS_POWER_IN_OUT_INPUT   UINT32_C(0x0)
+	/*
+	 * The switching regulator's output power is used
+	 * data.
+	 */
+		#define HWRM_REG_POWER_HISTOGRAM_OUTPUT_FLAGS_POWER_IN_OUT_OUTPUT  UINT32_C(0x1)
+		#define HWRM_REG_POWER_HISTOGRAM_OUTPUT_FLAGS_POWER_IN_OUT_LAST   HWRM_REG_POWER_HISTOGRAM_OUTPUT_FLAGS_POWER_IN_OUT_OUTPUT
+	uint8_t	unused_0[2];
+	/*
+	 * Time in microseconds between samples. This value is constant in
+	 * firmware. The initial design sets this constant at 10000 us (10
+	 * ms). Power values for voltage regulators calculate a power value
+	 * over a 300 us period, so a 10 ms sampling period covers 3% of
+	 * time ranges. Future firmware designs may opt for different
+	 * sampling periods, so this value is provided on output.
+	 */
+	uint32_t	sampling_period;
+	/*
+	 * Total samples taken since last clear. If no counter has
+	 * saturated, the sum of counts in each bucket equates to this
+	 * sample_count value. If a single counter has saturated, its value
+	 * can be calculated by subtracting the remaining bucket values from
+	 * this sample_count value.
+	 */
+	uint64_t	sample_count;
+	/*
+	 * The power usage expressed in histogram buckets. Bucket value
+	 * ranges and array indices are defined per the enumeration
+	 * power_histogram_bucket_enum. Values saturate at the max 32-bit
+	 * value, 0xFFFFFFFF, and do not roll over. Clients should use the
+	 * clear bit on input to clear the histogram array periodically or
+	 * when saturation is observed.
+	 */
+	uint32_t	power_hist[26];
+	uint8_t	unused_1[7];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_meter_profile_alloc_output_t, *phwrm_cfa_meter_profile_alloc_output_t;
+} hwrm_reg_power_histogram_output_t, *phwrm_reg_power_histogram_output_t;
 
-/*******************************
- * hwrm_cfa_meter_profile_free *
- *******************************/
+/*
+ * Count of timer callback routines run with no data measured. This
+ * may occur when data from the switching regulator is not available
+ * to the firmware timer callback routine. One possible reason for
+ * this is contention with other users of the i2c bus which is used
+ * to communicate with the switching regulator, for example when a
+ * call to hwrm_reg_power_query occurs while the timer routine is
+ * running.
+ */
+#define BUCKET_NO_DATA_FOR_SAMPLE UINT32_C(0x0)
+/* Count of samples measured at less than 8W */
+#define BUCKET_RANGE_8W_OR_LESS   UINT32_C(0x1)
+/* Count of samples measured >= 8 W and < 9 W */
+#define BUCKET_RANGE_8W_TO_9W	UINT32_C(0x2)
+/* Count of samples measured >= 9 W and < 10 W */
+#define BUCKET_RANGE_9W_TO_10W	UINT32_C(0x3)
+/* Count of samples measured >= 10 W and < 11 W */
+#define BUCKET_RANGE_10W_TO_11W   UINT32_C(0x4)
+/* Count of samples measured >= 11 W and < 12 W */
+#define BUCKET_RANGE_11W_TO_12W   UINT32_C(0x5)
+/* Count of samples measured >= 12 W and < 13 W */
+#define BUCKET_RANGE_12W_TO_13W   UINT32_C(0x6)
+/* Count of samples measured >= 13 W and < 14 W */
+#define BUCKET_RANGE_13W_TO_14W   UINT32_C(0x7)
+/* Count of samples measured >= 14 W and < 15 W */
+#define BUCKET_RANGE_14W_TO_15W   UINT32_C(0x8)
+/* Count of samples measured >= 15 W and < 16 W */
+#define BUCKET_RANGE_15W_TO_16W   UINT32_C(0x9)
+/* Count of samples measured >= 16 W and < 18 W */
+#define BUCKET_RANGE_16W_TO_18W   UINT32_C(0xa)
+/* Count of samples measured >= 18 W and < 20 W */
+#define BUCKET_RANGE_18W_TO_20W   UINT32_C(0xb)
+/* Count of samples measured >= 20 W and < 22 W */
+#define BUCKET_RANGE_20W_TO_22W   UINT32_C(0xc)
+/* Count of samples measured >= 22 W and < 24 W */
+#define BUCKET_RANGE_22W_TO_24W   UINT32_C(0xd)
+/* Count of samples measured >= 24 W and < 26 W */
+#define BUCKET_RANGE_24W_TO_26W   UINT32_C(0xe)
+/* Count of samples measured >= 26 W and < 28 W */
+#define BUCKET_RANGE_26W_TO_28W   UINT32_C(0xf)
+/* Count of samples measured >= 28 W and < 30 W */
+#define BUCKET_RANGE_28W_TO_30W   UINT32_C(0x10)
+/* Count of samples measured >= 30 W and < 32 W */
+#define BUCKET_RANGE_30W_TO_32W   UINT32_C(0x11)
+/* Count of samples measured >= 32 W and < 34 W */
+#define BUCKET_RANGE_32W_TO_34W   UINT32_C(0x12)
+/* Count of samples measured >= 34 W and < 36 W */
+#define BUCKET_RANGE_34W_TO_36W   UINT32_C(0x13)
+/* Count of samples measured >= 36 W and < 38 W */
+#define BUCKET_RANGE_36W_TO_38W   UINT32_C(0x14)
+/* Count of samples measured >= 38 W and < 40 W */
+#define BUCKET_RANGE_38W_TO_40W   UINT32_C(0x15)
+/* Count of samples measured >= 40 W and < 42 W */
+#define BUCKET_RANGE_40W_TO_42W   UINT32_C(0x16)
+/* Count of samples measured >= 42 W and < 44 W */
+#define BUCKET_RANGE_42W_TO_44W   UINT32_C(0x17)
+/* Count of samples measured >= 44 W and < 50 W */
+#define BUCKET_RANGE_44W_TO_50W   UINT32_C(0x18)
+/* Count of samples measured at 50 W or greater */
+#define BUCKET_RANGE_OVER_50W	UINT32_C(0x19)
+#define BUCKET_LAST		BUCKET_RANGE_OVER_50W
 
 
-/* hwrm_cfa_meter_profile_free_input (size:192b/24B) */
+/*************************
+ * hwrm_wol_filter_alloc *
+ *************************/
 
-typedef struct hwrm_cfa_meter_profile_free_input {
+
+/* hwrm_wol_filter_alloc_input (size:512b/64B) */
+
+typedef struct hwrm_wol_filter_alloc_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -36008,33 +63382,98 @@ typedef struct hwrm_cfa_meter_profile_free_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint8_t	flags;
+	uint32_t	flags;
+	uint32_t	enables;
 	/*
-	 * Enumeration denoting the RX, TX type of the resource.
-	 * This enumeration is used for resources that are similar for both
-	 * TX and RX paths of the chip.
+	 * This bit must be '1' for the mac_address field to be
+	 * configured.
 	 */
-	#define HWRM_CFA_METER_PROFILE_FREE_INPUT_FLAGS_PATH	UINT32_C(0x1)
-	/* tx path */
-		#define HWRM_CFA_METER_PROFILE_FREE_INPUT_FLAGS_PATH_TX	UINT32_C(0x0)
-	/* rx path */
-		#define HWRM_CFA_METER_PROFILE_FREE_INPUT_FLAGS_PATH_RX	UINT32_C(0x1)
-		#define HWRM_CFA_METER_PROFILE_FREE_INPUT_FLAGS_PATH_LAST HWRM_CFA_METER_PROFILE_FREE_INPUT_FLAGS_PATH_RX
-	uint8_t	unused_0;
-	/* This value identifies a meter profile in CFA. */
-	uint16_t	meter_profile_id;
+	#define HWRM_WOL_FILTER_ALLOC_INPUT_ENABLES_MAC_ADDRESS	UINT32_C(0x1)
 	/*
-	 * A value of 0xfff is considered invalid and implies the
-	 * profile is not configured.
+	 * This bit must be '1' for the pattern_offset field to be
+	 * configured.
 	 */
-	#define HWRM_CFA_METER_PROFILE_FREE_INPUT_METER_PROFILE_ID_INVALID UINT32_C(0xffff)
-	#define HWRM_CFA_METER_PROFILE_FREE_INPUT_METER_PROFILE_ID_LAST   HWRM_CFA_METER_PROFILE_FREE_INPUT_METER_PROFILE_ID_INVALID
+	#define HWRM_WOL_FILTER_ALLOC_INPUT_ENABLES_PATTERN_OFFSET	UINT32_C(0x2)
+	/*
+	 * This bit must be '1' for the pattern_buf_size field to be
+	 * configured.
+	 */
+	#define HWRM_WOL_FILTER_ALLOC_INPUT_ENABLES_PATTERN_BUF_SIZE	UINT32_C(0x4)
+	/*
+	 * This bit must be '1' for the pattern_buf_addr field to be
+	 * configured.
+	 */
+	#define HWRM_WOL_FILTER_ALLOC_INPUT_ENABLES_PATTERN_BUF_ADDR	UINT32_C(0x8)
+	/*
+	 * This bit must be '1' for the pattern_mask_addr field to be
+	 * configured.
+	 */
+	#define HWRM_WOL_FILTER_ALLOC_INPUT_ENABLES_PATTERN_MASK_ADDR	UINT32_C(0x10)
+	/*
+	 * This bit must be '1' for the pattern_mask_size field to be
+	 * configured.
+	 */
+	#define HWRM_WOL_FILTER_ALLOC_INPUT_ENABLES_PATTERN_MASK_SIZE	UINT32_C(0x20)
+	/* Port ID of port on which WoL filter is configured. */
+	uint16_t	port_id;
+	/* This value represents a Wake-on-LAN type. */
+	uint8_t	wol_type;
+	/* Magic Packet */
+	#define HWRM_WOL_FILTER_ALLOC_INPUT_WOL_TYPE_MAGICPKT UINT32_C(0x0)
+	/* Bitmap */
+	#define HWRM_WOL_FILTER_ALLOC_INPUT_WOL_TYPE_BMP	UINT32_C(0x1)
+	/* Invalid */
+	#define HWRM_WOL_FILTER_ALLOC_INPUT_WOL_TYPE_INVALID  UINT32_C(0xff)
+	#define HWRM_WOL_FILTER_ALLOC_INPUT_WOL_TYPE_LAST	HWRM_WOL_FILTER_ALLOC_INPUT_WOL_TYPE_INVALID
+	uint8_t	unused_0[5];
+	/*
+	 * # If this field is enabled and magic packet WoL filter
+	 * type is specified in this command, the value set in this
+	 * field shall be used in setting the magic packet based
+	 * WoL filter.
+	 * # If this field is not enabled and magic packet WoL
+	 * filter type is specified and port id is specified to
+	 * 0xFF in this command, then the HWRM
+	 * shall use default MAC address configured on the
+	 * function associated with the HWRM client.
+	 * # If this field is not enabled and magic packet WoL
+	 * filter type is specified and port id is not specified to
+	 * 0xFF in this command, then the HWRM
+	 * shall use default MAC address configured on the port.
+	 */
+	uint8_t	mac_address[6];
+	/*
+	 * The offset from the beginning of MAC header where
+	 * pattern should be matched.
+	 * Applies to bitmap WoL.
+	 */
+	uint16_t	pattern_offset;
+	/*
+	 * The size of the pattern that is being matched.
+	 * Applies to bitmap WoL.
+	 */
+	uint16_t	pattern_buf_size;
+	/*
+	 * The size of the pattern mask.
+	 * Applies to bitmap WoL.
+	 */
+	uint16_t	pattern_mask_size;
 	uint8_t	unused_1[4];
-} hwrm_cfa_meter_profile_free_input_t, *phwrm_cfa_meter_profile_free_input_t;
+	/*
+	 * Physical address of the pattern buffer.
+	 * Applies to bitmap WoL.
+	 */
+	uint64_t	pattern_buf_addr;
+	/*
+	 * Physical address of the pattern mask.
+	 * Applies to bitmap WoL.
+	 */
+	uint64_t	pattern_mask_addr;
+} hwrm_wol_filter_alloc_input_t, *phwrm_wol_filter_alloc_input_t;
 
-/* hwrm_cfa_meter_profile_free_output (size:128b/16B) */
+/* hwrm_wol_filter_alloc_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_meter_profile_free_output {
+typedef struct hwrm_wol_filter_alloc_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -36043,26 +63482,27 @@ typedef struct hwrm_cfa_meter_profile_free_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	/* This value identifies a Wake-on-LAN (WoL) filter. */
+	uint8_t	wol_filter_id;
+	uint8_t	unused_0[6];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_meter_profile_free_output_t, *phwrm_cfa_meter_profile_free_output_t;
+} hwrm_wol_filter_alloc_output_t, *phwrm_wol_filter_alloc_output_t;
 
-/******************************
- * hwrm_cfa_meter_profile_cfg *
- ******************************/
+/************************
+ * hwrm_wol_filter_free *
+ ************************/
 
 
-/* hwrm_cfa_meter_profile_cfg_input (size:320b/40B) */
+/* hwrm_wol_filter_free_input (size:256b/32B) */
 
-typedef struct hwrm_cfa_meter_profile_cfg_input {
+typedef struct hwrm_wol_filter_free_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -36091,157 +63531,34 @@ typedef struct hwrm_cfa_meter_profile_cfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint8_t	flags;
+	uint32_t	flags;
 	/*
-	 * Enumeration denoting the RX, TX type of the resource.
-	 * This enumeration is used for resources that are similar for both
-	 * TX and RX paths of the chip.
+	 * # When this bit is set to '1', then all active WoL
+	 * filters on the port are requested to be freed.
+	 * # If the a function driver sets this flag to '1', then
+	 * the HWRM shall free all active WoL filters that are not
+	 * set by other function drivers on that port.
 	 */
-	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_FLAGS_PATH	UINT32_C(0x1)
-	/* tx path */
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_FLAGS_PATH_TX	UINT32_C(0x0)
-	/* rx path */
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_FLAGS_PATH_RX	UINT32_C(0x1)
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_FLAGS_PATH_LAST HWRM_CFA_METER_PROFILE_CFG_INPUT_FLAGS_PATH_RX
-	/* The meter algorithm type. */
-	uint8_t	meter_type;
-	/* RFC 2697 (srTCM) */
-	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_METER_TYPE_RFC2697 UINT32_C(0x0)
-	/* RFC 2698 (trTCM) */
-	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_METER_TYPE_RFC2698 UINT32_C(0x1)
-	/* RFC 4115 (trTCM) */
-	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_METER_TYPE_RFC4115 UINT32_C(0x2)
-	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_METER_TYPE_LAST   HWRM_CFA_METER_PROFILE_CFG_INPUT_METER_TYPE_RFC4115
-	/* This value identifies a meter profile in CFA. */
-	uint16_t	meter_profile_id;
+	#define HWRM_WOL_FILTER_FREE_INPUT_FLAGS_FREE_ALL_WOL_FILTERS	UINT32_C(0x1)
+	uint32_t	enables;
 	/*
-	 * A value of 0xfff is considered invalid and implies the
-	 * profile is not configured.
+	 * This bit must be '1' for the wol_filter_id field to be
+	 * configured.
 	 */
-	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_METER_PROFILE_ID_INVALID UINT32_C(0xffff)
-	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_METER_PROFILE_ID_LAST   HWRM_CFA_METER_PROFILE_CFG_INPUT_METER_PROFILE_ID_INVALID
+	#define HWRM_WOL_FILTER_FREE_INPUT_ENABLES_WOL_FILTER_ID	UINT32_C(0x1)
+	/* Port ID of the port on which WoL filter(s) is (are) being freed. */
+	uint16_t	port_id;
 	/*
-	 * This field is reserved for the future use.
-	 * It shall be set to 0.
+	 * The HWRM shall ignore this field if free_all_wol_filters
+	 * flag is set.
 	 */
-	uint32_t	reserved;
-	/* A meter rate specified in bytes-per-second. */
-	uint32_t	commit_rate;
-	/* The bandwidth value. */
-	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_RATE_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_RATE_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_RATE_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_RATE_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_RATE_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_RATE_SCALE_LAST		HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_RATE_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_RATE_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_RATE_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_RATE_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_RATE_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_RATE_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_RATE_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_RATE_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Raw value */
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_RATE_BW_VALUE_UNIT_RAW	(UINT32_C(0x7) << 29)
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_RATE_BW_VALUE_UNIT_LAST	HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_RATE_BW_VALUE_UNIT_RAW
-	/* A meter burst size specified in bytes. */
-	uint32_t	commit_burst;
-	/* The bandwidth value. */
-	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_BURST_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_BURST_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_BURST_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_BURST_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_BURST_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_BURST_SCALE_LAST		HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_BURST_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_BURST_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_BURST_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_BURST_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_BURST_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_BURST_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_BURST_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_BURST_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid value */
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_BURST_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_BURST_BW_VALUE_UNIT_LAST	HWRM_CFA_METER_PROFILE_CFG_INPUT_COMMIT_BURST_BW_VALUE_UNIT_INVALID
-	/* A meter rate specified in bytes-per-second. */
-	uint32_t	excess_peak_rate;
-	/* The bandwidth value. */
-	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_RATE_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_RATE_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_RATE_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_RATE_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_RATE_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_RATE_SCALE_LAST		HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_RATE_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Raw unit */
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_RAW	(UINT32_C(0x7) << 29)
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_LAST	HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_RATE_BW_VALUE_UNIT_RAW
-	/* A meter burst size specified in bytes. */
-	uint32_t	excess_peak_burst;
-	/* The bandwidth value. */
-	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_BURST_BW_VALUE_MASK		UINT32_C(0xfffffff)
-	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_BURST_BW_VALUE_SFT		0
-	/* The granularity of the value (bits or bytes). */
-	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_BURST_SCALE			UINT32_C(0x10000000)
-	/* Value is in bits. */
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_BURST_SCALE_BITS		(UINT32_C(0x0) << 28)
-	/* Value is in bytes. */
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_BURST_SCALE_BYTES		(UINT32_C(0x1) << 28)
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_BURST_SCALE_LAST		HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_BURST_SCALE_BYTES
-	/* bw_value_unit is 3 b */
-	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_MASK	UINT32_C(0xe0000000)
-	#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_SFT	29
-	/* Value is in Mb or MB (base 10). */
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_MEGA	(UINT32_C(0x0) << 29)
-	/* Value is in Kb or KB (base 10). */
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_KILO	(UINT32_C(0x2) << 29)
-	/* Value is in bits or bytes. */
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_BASE	(UINT32_C(0x4) << 29)
-	/* Value is in Gb or GB (base 10). */
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_GIGA	(UINT32_C(0x6) << 29)
-	/* Value is in 1/100th of a percentage of total bandwidth. */
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_PERCENT1_100  (UINT32_C(0x1) << 29)
-	/* Invalid unit */
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_INVALID	(UINT32_C(0x7) << 29)
-		#define HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_LAST	HWRM_CFA_METER_PROFILE_CFG_INPUT_EXCESS_PEAK_BURST_BW_VALUE_UNIT_INVALID
-} hwrm_cfa_meter_profile_cfg_input_t, *phwrm_cfa_meter_profile_cfg_input_t;
+	uint8_t	wol_filter_id;
+	uint8_t	unused_0[5];
+} hwrm_wol_filter_free_input_t, *phwrm_wol_filter_free_input_t;
 
-/* hwrm_cfa_meter_profile_cfg_output (size:128b/16B) */
+/* hwrm_wol_filter_free_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_meter_profile_cfg_output {
+typedef struct hwrm_wol_filter_free_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -36254,22 +63571,21 @@ typedef struct hwrm_cfa_meter_profile_cfg_output {
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_meter_profile_cfg_output_t, *phwrm_cfa_meter_profile_cfg_output_t;
+} hwrm_wol_filter_free_output_t, *phwrm_wol_filter_free_output_t;
 
-/*********************************
- * hwrm_cfa_meter_instance_alloc *
- *********************************/
+/************************
+ * hwrm_wol_filter_qcfg *
+ ************************/
 
 
-/* hwrm_cfa_meter_instance_alloc_input (size:192b/24B) */
+/* hwrm_wol_filter_qcfg_input (size:448b/56B) */
 
-typedef struct hwrm_cfa_meter_instance_alloc_input {
+typedef struct hwrm_wol_filter_qcfg_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -36298,33 +63614,59 @@ typedef struct hwrm_cfa_meter_instance_alloc_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint8_t	flags;
+	/* Port ID of port on which WoL filter that is being queried. */
+	uint16_t	port_id;
 	/*
-	 * Enumeration denoting the RX, TX type of the resource.
-	 * This enumeration is used for resources that are similar for both
-	 * TX and RX paths of the chip.
+	 * This is an opaque handle used to access filters.
+	 * # The HWRM client shall set this field to 0x0000 to begin
+	 * the query.
+	 * # After the first query, the HWRM client shall retrieve
+	 * next filters (if they exist) using the HWRM provided handle
+	 * in the response.
 	 */
-	#define HWRM_CFA_METER_INSTANCE_ALLOC_INPUT_FLAGS_PATH	UINT32_C(0x1)
-	/* tx path */
-		#define HWRM_CFA_METER_INSTANCE_ALLOC_INPUT_FLAGS_PATH_TX	UINT32_C(0x0)
-	/* rx path */
-		#define HWRM_CFA_METER_INSTANCE_ALLOC_INPUT_FLAGS_PATH_RX	UINT32_C(0x1)
-		#define HWRM_CFA_METER_INSTANCE_ALLOC_INPUT_FLAGS_PATH_LAST HWRM_CFA_METER_INSTANCE_ALLOC_INPUT_FLAGS_PATH_RX
-	uint8_t	unused_0;
-	/* This value identifies a meter profile in CFA. */
-	uint16_t	meter_profile_id;
+	uint16_t	handle;
+	uint8_t	unused_0[4];
 	/*
-	 * A value of 0xffff is considered invalid and implies the
-	 * profile is not configured.
+	 * Physical address of the pattern buffer.
+	 * Applies to bitmap WoL filter only.
+	 * # Value of 0 indicates an invalid buffer address.
+	 * If this field is set to 0, then HWRM shall ignore
+	 * pattern_buf_size.
+	 * # If the HWRM client provides an invalid buffer address
+	 * for the pattern, then the HWRM is not required to
+	 * provide pattern when the response contains a bitmap WoL
+	 * filter.
 	 */
-	#define HWRM_CFA_METER_INSTANCE_ALLOC_INPUT_METER_PROFILE_ID_INVALID UINT32_C(0xffff)
-	#define HWRM_CFA_METER_INSTANCE_ALLOC_INPUT_METER_PROFILE_ID_LAST   HWRM_CFA_METER_INSTANCE_ALLOC_INPUT_METER_PROFILE_ID_INVALID
-	uint8_t	unused_1[4];
-} hwrm_cfa_meter_instance_alloc_input_t, *phwrm_cfa_meter_instance_alloc_input_t;
+	uint64_t	pattern_buf_addr;
+	/*
+	 * The size of the pattern buffer.
+	 * Applies to bitmap WoL filter only.
+	 */
+	uint16_t	pattern_buf_size;
+	uint8_t	unused_1[6];
+	/*
+	 * Physical address of the pattern mask.
+	 * Applies to bitmap WoL filter only.
+	 * # Value of 0 indicates an invalid pattern mask address.
+	 * If this field is set to 0, then HWRM shall ignore
+	 * pattern_mask_size.
+	 * # If the HWRM client provides an invalid mask address
+	 * for the pattern, then the HWRM is not required to
+	 * provide mask when the response contains a bitmap WoL
+	 * filter.
+	 */
+	uint64_t	pattern_mask_addr;
+	/*
+	 * The size of the buffer for pattern mask.
+	 * Applies to bitmap WoL filter only.
+	 */
+	uint16_t	pattern_mask_size;
+	uint8_t	unused_2[6];
+} hwrm_wol_filter_qcfg_input_t, *phwrm_wol_filter_qcfg_input_t;
 
-/* hwrm_cfa_meter_instance_alloc_output (size:128b/16B) */
+/* hwrm_wol_filter_qcfg_output (size:256b/32B) */
 
-typedef struct hwrm_cfa_meter_instance_alloc_output {
+typedef struct hwrm_wol_filter_qcfg_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -36333,34 +63675,78 @@ typedef struct hwrm_cfa_meter_instance_alloc_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* This value identifies a meter instance in CFA. */
-	uint16_t	meter_instance_id;
 	/*
-	 * A value of 0xffff is considered invalid and implies the
-	 * instance is not configured.
+	 * This is the next handle that is used to access filters.
+	 * # If this field is set to 0x0000, then no WoL filters are
+	 * currently configured on this port and all other fields in
+	 * the output shall be ignored by the HWRM client.
+	 * # If this field is set to neither 0x0000 nor 0xFFFF, then the
+	 * wol_filter_id is valid and the parameters provided in the
+	 * response are based on the wol_type.
+	 * # If this field is set to 0xFFFF, then there are no remaining
+	 * configured WoL filters to be queried for the queried function
+	 * after this response, wol_filter_id is valid and the parameters
+	 * provided in the response are based on the wol_type.
 	 */
-	#define HWRM_CFA_METER_INSTANCE_ALLOC_OUTPUT_METER_INSTANCE_ID_INVALID UINT32_C(0xffff)
-	#define HWRM_CFA_METER_INSTANCE_ALLOC_OUTPUT_METER_INSTANCE_ID_LAST   HWRM_CFA_METER_INSTANCE_ALLOC_OUTPUT_METER_INSTANCE_ID_INVALID
-	uint8_t	unused_0[5];
+	uint16_t	next_handle;
+	/*
+	 * This value identifies the filter returned in this
+	 * response.
+	 */
+	uint8_t	wol_filter_id;
+	/*
+	 * This value identifies the type of WoL filter returned
+	 * in this response.
+	 */
+	uint8_t	wol_type;
+	/* Magic Packet */
+	#define HWRM_WOL_FILTER_QCFG_OUTPUT_WOL_TYPE_MAGICPKT UINT32_C(0x0)
+	/* Bitmap */
+	#define HWRM_WOL_FILTER_QCFG_OUTPUT_WOL_TYPE_BMP	UINT32_C(0x1)
+	/* Invalid */
+	#define HWRM_WOL_FILTER_QCFG_OUTPUT_WOL_TYPE_INVALID  UINT32_C(0xff)
+	#define HWRM_WOL_FILTER_QCFG_OUTPUT_WOL_TYPE_LAST	HWRM_WOL_FILTER_QCFG_OUTPUT_WOL_TYPE_INVALID
+	uint32_t	unused_0;
+	/*
+	 * The MAC address value used by the WoL filter.
+	 * Applies to magic packet based WoL.
+	 */
+	uint8_t	mac_address[6];
+	/*
+	 * The offset from the beginning of MAC header where
+	 * pattern should be matched.
+	 * Applies to bitmap WoL.
+	 */
+	uint16_t	pattern_offset;
+	/*
+	 * The actual size of the pattern that is being returned.
+	 * Applies to bitmap WoL.
+	 */
+	uint16_t	pattern_size;
+	/*
+	 * The actual size of the pattern mask that is being returned.
+	 * Applies to bitmap WoL.
+	 */
+	uint16_t	pattern_mask_size;
+	uint8_t	unused_1[3];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_meter_instance_alloc_output_t, *phwrm_cfa_meter_instance_alloc_output_t;
+} hwrm_wol_filter_qcfg_output_t, *phwrm_wol_filter_qcfg_output_t;
 
-/*******************************
- * hwrm_cfa_meter_instance_cfg *
- *******************************/
+/************************
+ * hwrm_wol_reason_qcfg *
+ ************************/
 
 
-/* hwrm_cfa_meter_instance_cfg_input (size:192b/24B) */
+/* hwrm_wol_reason_qcfg_input (size:320b/40B) */
 
-typedef struct hwrm_cfa_meter_instance_cfg_input {
+typedef struct hwrm_wol_reason_qcfg_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -36389,41 +63775,22 @@ typedef struct hwrm_cfa_meter_instance_cfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint8_t	flags;
-	/*
-	 * Enumeration denoting the RX, TX type of the resource.
-	 * This enumeration is used for resources that are similar for both
-	 * TX and RX paths of the chip.
-	 */
-	#define HWRM_CFA_METER_INSTANCE_CFG_INPUT_FLAGS_PATH	UINT32_C(0x1)
-	/* tx path */
-		#define HWRM_CFA_METER_INSTANCE_CFG_INPUT_FLAGS_PATH_TX	UINT32_C(0x0)
-	/* rx path */
-		#define HWRM_CFA_METER_INSTANCE_CFG_INPUT_FLAGS_PATH_RX	UINT32_C(0x1)
-		#define HWRM_CFA_METER_INSTANCE_CFG_INPUT_FLAGS_PATH_LAST HWRM_CFA_METER_INSTANCE_CFG_INPUT_FLAGS_PATH_RX
-	uint8_t	unused_0;
-	/*
-	 * This value identifies a new meter profile to be associated with
-	 * the meter instance specified in this command.
-	 */
-	uint16_t	meter_profile_id;
-	/*
-	 * A value of 0xffff is considered invalid and implies the
-	 * profile is not configured.
-	 */
-	#define HWRM_CFA_METER_INSTANCE_CFG_INPUT_METER_PROFILE_ID_INVALID UINT32_C(0xffff)
-	#define HWRM_CFA_METER_INSTANCE_CFG_INPUT_METER_PROFILE_ID_LAST   HWRM_CFA_METER_INSTANCE_CFG_INPUT_METER_PROFILE_ID_INVALID
+	/* Port ID of port for which this query is for. */
+	uint16_t	port_id;
+	uint8_t	unused_0[6];
 	/*
-	 * This value identifies the ID of a meter instance that needs to be
-	 * updated with a new meter profile specified in this command.
+	 * Physical address of the packet buffer for querying
+	 * WoL packet.
 	 */
-	uint16_t	meter_instance_id;
-	uint8_t	unused_1[2];
-} hwrm_cfa_meter_instance_cfg_input_t, *phwrm_cfa_meter_instance_cfg_input_t;
+	uint64_t	wol_pkt_buf_addr;
+	/* The size of the buffer for the WoL packet. */
+	uint16_t	wol_pkt_buf_size;
+	uint8_t	unused_1[6];
+} hwrm_wol_reason_qcfg_input_t, *phwrm_wol_reason_qcfg_input_t;
 
-/* hwrm_cfa_meter_instance_cfg_output (size:128b/16B) */
+/* hwrm_wol_reason_qcfg_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_meter_instance_cfg_output {
+typedef struct hwrm_wol_reason_qcfg_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -36432,26 +63799,48 @@ typedef struct hwrm_cfa_meter_instance_cfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	/*
+	 * This value identifies the filter that matched
+	 * the last WoL packet.
+	 * This id is only valid with valid WoL reason.
+	 */
+	uint8_t	wol_filter_id;
+	/*
+	 * This value identifies the type of WoL reason returned
+	 * in this response.
+	 * When the wol_type is set to invalid, then there is
+	 * no WoL event that happened during last system
+	 * wake-up.
+	 */
+	uint8_t	wol_reason;
+	/* Magic Packet */
+	#define HWRM_WOL_REASON_QCFG_OUTPUT_WOL_REASON_MAGICPKT UINT32_C(0x0)
+	/* Bitmap */
+	#define HWRM_WOL_REASON_QCFG_OUTPUT_WOL_REASON_BMP	UINT32_C(0x1)
+	/* Invalid */
+	#define HWRM_WOL_REASON_QCFG_OUTPUT_WOL_REASON_INVALID  UINT32_C(0xff)
+	#define HWRM_WOL_REASON_QCFG_OUTPUT_WOL_REASON_LAST	HWRM_WOL_REASON_QCFG_OUTPUT_WOL_REASON_INVALID
+	/* The value identifies the length of the WoL packet in bytes. */
+	uint8_t	wol_pkt_len;
+	uint8_t	unused_0[4];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_meter_instance_cfg_output_t, *phwrm_cfa_meter_instance_cfg_output_t;
+} hwrm_wol_reason_qcfg_output_t, *phwrm_wol_reason_qcfg_output_t;
 
-/********************************
- * hwrm_cfa_meter_instance_free *
- ********************************/
+/************************
+ * hwrm_dbg_read_direct *
+ ************************/
 
 
-/* hwrm_cfa_meter_instance_free_input (size:192b/24B) */
+/* hwrm_dbg_read_direct_input (size:256b/32B) */
 
-typedef struct hwrm_cfa_meter_instance_free_input {
+typedef struct hwrm_dbg_read_direct_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -36480,33 +63869,20 @@ typedef struct hwrm_cfa_meter_instance_free_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint8_t	flags;
-	/*
-	 * Enumeration denoting the RX, TX type of the resource.
-	 * This enumeration is used for resources that are similar for both
-	 * TX and RX paths of the chip.
-	 */
-	#define HWRM_CFA_METER_INSTANCE_FREE_INPUT_FLAGS_PATH	UINT32_C(0x1)
-	/* tx path */
-		#define HWRM_CFA_METER_INSTANCE_FREE_INPUT_FLAGS_PATH_TX	UINT32_C(0x0)
-	/* rx path */
-		#define HWRM_CFA_METER_INSTANCE_FREE_INPUT_FLAGS_PATH_RX	UINT32_C(0x1)
-		#define HWRM_CFA_METER_INSTANCE_FREE_INPUT_FLAGS_PATH_LAST HWRM_CFA_METER_INSTANCE_FREE_INPUT_FLAGS_PATH_RX
-	uint8_t	unused_0;
-	/* This value identifies a meter instance in CFA. */
-	uint16_t	meter_instance_id;
 	/*
-	 * A value of 0xfff is considered invalid and implies the
-	 * instance is not configured.
+	 * host address where the data content will be written
+	 * when the request is complete. This area must be 16B aligned.
 	 */
-	#define HWRM_CFA_METER_INSTANCE_FREE_INPUT_METER_INSTANCE_ID_INVALID UINT32_C(0xffff)
-	#define HWRM_CFA_METER_INSTANCE_FREE_INPUT_METER_INSTANCE_ID_LAST   HWRM_CFA_METER_INSTANCE_FREE_INPUT_METER_INSTANCE_ID_INVALID
-	uint8_t	unused_1[4];
-} hwrm_cfa_meter_instance_free_input_t, *phwrm_cfa_meter_instance_free_input_t;
+	uint64_t	host_dest_addr;
+	/* address(in ChiMP view) to start reading */
+	uint32_t	read_addr;
+	/* number of dwords to read */
+	uint32_t	read_len32;
+} hwrm_dbg_read_direct_input_t, *phwrm_dbg_read_direct_input_t;
 
-/* hwrm_cfa_meter_instance_free_output (size:128b/16B) */
+/* hwrm_dbg_read_direct_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_meter_instance_free_output {
+typedef struct hwrm_dbg_read_direct_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -36515,26 +63891,31 @@ typedef struct hwrm_cfa_meter_instance_free_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	/*
+	 * This field, if not zero, contains the IEEE 802.3 CRC-32 checksum of
+	 * the number of dwords read in this request using this polynomial:
+	 * x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1
+	 */
+	uint32_t	crc32;
+	uint8_t	unused_0[3];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_meter_instance_free_output_t, *phwrm_cfa_meter_instance_free_output_t;
+} hwrm_dbg_read_direct_output_t, *phwrm_dbg_read_direct_output_t;
 
-/*******************************
- * hwrm_cfa_decap_filter_alloc *
- *******************************/
+/*************************
+ * hwrm_dbg_write_direct *
+ *************************/
 
 
-/* hwrm_cfa_decap_filter_alloc_input (size:832b/104B) */
+/* hwrm_dbg_write_direct_input (size:448b/56B) */
 
-typedef struct hwrm_cfa_decap_filter_alloc_input {
+typedef struct hwrm_dbg_write_direct_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -36563,241 +63944,275 @@ typedef struct hwrm_cfa_decap_filter_alloc_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	flags;
-	/* ovs_tunnel is 1 b */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_FLAGS_OVS_TUNNEL	UINT32_C(0x1)
-	uint32_t	enables;
-	/*
-	 * This bit must be '1' for the tunnel_type field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_ENABLES_TUNNEL_TYPE	UINT32_C(0x1)
-	/*
-	 * This bit must be '1' for the tunnel_id field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_ENABLES_TUNNEL_ID	UINT32_C(0x2)
-	/*
-	 * This bit must be '1' for the src_macaddr field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_ENABLES_SRC_MACADDR	UINT32_C(0x4)
-	/*
-	 * This bit must be '1' for the dst_macaddr field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_ENABLES_DST_MACADDR	UINT32_C(0x8)
-	/*
-	 * This bit must be '1' for the ovlan_vid field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_ENABLES_OVLAN_VID	UINT32_C(0x10)
-	/*
-	 * This bit must be '1' for the ivlan_vid field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_ENABLES_IVLAN_VID	UINT32_C(0x20)
-	/*
-	 * This bit must be '1' for the t_ovlan_vid field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_ENABLES_T_OVLAN_VID	UINT32_C(0x40)
-	/*
-	 * This bit must be '1' for the t_ivlan_vid field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_ENABLES_T_IVLAN_VID	UINT32_C(0x80)
-	/*
-	 * This bit must be '1' for the ethertype field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_ENABLES_ETHERTYPE	UINT32_C(0x100)
-	/*
-	 * This bit must be '1' for the src_ipaddr field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_ENABLES_SRC_IPADDR	UINT32_C(0x200)
-	/*
-	 * This bit must be '1' for the dst_ipaddr field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_ENABLES_DST_IPADDR	UINT32_C(0x400)
-	/*
-	 * This bit must be '1' for the ipaddr_type field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_ENABLES_IPADDR_TYPE	UINT32_C(0x800)
-	/*
-	 * This bit must be '1' for the ip_protocol field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_ENABLES_IP_PROTOCOL	UINT32_C(0x1000)
-	/*
-	 * This bit must be '1' for the src_port field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_ENABLES_SRC_PORT	UINT32_C(0x2000)
-	/*
-	 * This bit must be '1' for the dst_port field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_ENABLES_DST_PORT	UINT32_C(0x4000)
-	/*
-	 * This bit must be '1' for the dst_id field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_ENABLES_DST_ID		UINT32_C(0x8000)
-	/*
-	 * This bit must be '1' for the mirror_vnic_id field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_ENABLES_MIRROR_VNIC_ID	UINT32_C(0x10000)
-	/*
-	 * Tunnel identifier.
-	 * Virtual Network Identifier (VNI). Only valid with
-	 * tunnel_types VXLAN, NVGRE, and Geneve.
-	 * Only lower 24-bits of VNI field are used
-	 * in setting up the filter.
-	 */
-	uint32_t	tunnel_id;
-	/* Tunnel Type. */
-	uint8_t	tunnel_type;
-	/* Non-tunnel */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_TUNNEL_TYPE_NONTUNNEL	UINT32_C(0x0)
-	/* Virtual eXtensible Local Area Network (VXLAN) */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_TUNNEL_TYPE_VXLAN	UINT32_C(0x1)
-	/* Network Virtualization Generic Routing Encapsulation (NVGRE) */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_TUNNEL_TYPE_NVGRE	UINT32_C(0x2)
-	/* Generic Routing Encapsulation (GRE) inside Ethernet payload */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_TUNNEL_TYPE_L2GRE	UINT32_C(0x3)
-	/* IP in IP */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_TUNNEL_TYPE_IPIP	UINT32_C(0x4)
-	/* Generic Network Virtualization Encapsulation (Geneve) */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_TUNNEL_TYPE_GENEVE	UINT32_C(0x5)
-	/* Multi-Protocol Label Switching (MPLS) */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_TUNNEL_TYPE_MPLS	UINT32_C(0x6)
-	/* Stateless Transport Tunnel (STT) */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_TUNNEL_TYPE_STT	UINT32_C(0x7)
-	/* Generic Routing Encapsulation (GRE) inside IP datagram payload */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_TUNNEL_TYPE_IPGRE	UINT32_C(0x8)
-	/* IPV4 over virtual eXtensible Local Area Network (IPV4oVXLAN) */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_V4	UINT32_C(0x9)
-	/*
-	 * Enhance Generic Routing Encapsulation (GRE version 1) inside IP
-	 * datagram payload
-	 */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_TUNNEL_TYPE_IPGRE_V1	UINT32_C(0xa)
-	/* Use fixed layer 2 ether type of 0xFFFF */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_TUNNEL_TYPE_L2_ETYPE	UINT32_C(0xb)
-	/*
-	 * IPV6 over virtual eXtensible Local Area Network with GPE header
-	 * (IPV6oVXLANGPE)
-	 */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_GPE_V6 UINT32_C(0xc)
-	/* Any tunneled traffic */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_TUNNEL_TYPE_ANYTUNNEL	UINT32_C(0xff)
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_TUNNEL_TYPE_LAST	HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_TUNNEL_TYPE_ANYTUNNEL
-	uint8_t	unused_0;
-	uint16_t	unused_1;
-	/*
-	 * This value indicates the source MAC address in
-	 * the Ethernet header.
-	 */
-	uint8_t	src_macaddr[6];
-	uint8_t	unused_2[2];
-	/*
-	 * This value indicates the destination MAC address in
-	 * the Ethernet header.
-	 */
-	uint8_t	dst_macaddr[6];
+	/* address(in ChiMP view) to start writing */
+	uint32_t	write_addr;
+	/* number of dwords to write (up to 8 dwords) */
+	uint32_t	write_len32;
+	/* write data (up to 8 dwords) */
+	uint32_t	write_data[8];
+} hwrm_dbg_write_direct_input_t, *phwrm_dbg_write_direct_input_t;
+
+/* hwrm_dbg_write_direct_output (size:128b/16B) */
+
+typedef struct hwrm_dbg_write_direct_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
 	/*
-	 * This value indicates the VLAN ID of the outer VLAN tag
-	 * in the Ethernet header.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	uint16_t	ovlan_vid;
+	uint8_t	valid;
+} hwrm_dbg_write_direct_output_t, *phwrm_dbg_write_direct_output_t;
+
+/**************************
+ * hwrm_dbg_read_indirect *
+ **************************/
+
+
+/* hwrm_dbg_read_indirect_input (size:640b/80B) */
+
+typedef struct hwrm_dbg_read_indirect_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * This value indicates the VLAN ID of the inner VLAN tag
-	 * in the Ethernet header.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint16_t	ivlan_vid;
+	uint16_t	cmpl_ring;
 	/*
-	 * This value indicates the VLAN ID of the outer VLAN tag
-	 * in the tunnel Ethernet header.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint16_t	t_ovlan_vid;
+	uint16_t	seq_id;
 	/*
-	 * This value indicates the VLAN ID of the inner VLAN tag
-	 * in the tunnel Ethernet header.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint16_t	t_ivlan_vid;
-	/* This value indicates the ethertype in the Ethernet header. */
-	uint16_t	ethertype;
+	uint16_t	target_id;
 	/*
-	 * This value indicates the type of IP address.
-	 * 4 - IPv4
-	 * 6 - IPv6
-	 * All others are invalid.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint8_t	ip_addr_type;
-	/* invalid */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_IP_ADDR_TYPE_UNKNOWN UINT32_C(0x0)
-	/* IPv4 */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_IP_ADDR_TYPE_IPV4	UINT32_C(0x4)
-	/* IPv6 */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_IP_ADDR_TYPE_IPV6	UINT32_C(0x6)
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_IP_ADDR_TYPE_LAST   HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_IP_ADDR_TYPE_IPV6
+	uint64_t	resp_addr;
 	/*
-	 * The value of protocol filed in IP header.
-	 * Applies to UDP and TCP traffic.
-	 * 6 - TCP
-	 * 17 - UDP
+	 * host address where the data content will be written
+	 * when the request is complete. This area must be 16B aligned.
 	 */
-	uint8_t	ip_protocol;
-	/* invalid */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_IP_PROTOCOL_UNKNOWN UINT32_C(0x0)
-	/* TCP */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_IP_PROTOCOL_TCP	UINT32_C(0x6)
-	/* UDP */
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_IP_PROTOCOL_UDP	UINT32_C(0x11)
-	#define HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_IP_PROTOCOL_LAST   HWRM_CFA_DECAP_FILTER_ALLOC_INPUT_IP_PROTOCOL_UDP
-	uint16_t	unused_3;
-	uint32_t	unused_4;
+	uint64_t	host_dest_addr;
+	/* Length of host buffer used for transferring debug data. */
+	uint32_t	host_dest_addr_len;
+	/* Indirect access type to on-chip data structures. */
+	uint8_t	indirect_access_type;
+	/* L2 Mgmt filters in Transmit Engine (TE) */
+	#define HWRM_DBG_READ_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_TE_MGMT_FILTERS_L2	UINT32_C(0x0)
+	/* L3/L4 Mgmt filters in Transmit Engine (TE) */
+	#define HWRM_DBG_READ_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_TE_MGMT_FILTERS_L3L4	UINT32_C(0x1)
+	/* L2 Mgmt filters in Receive Engine (RE) */
+	#define HWRM_DBG_READ_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_RE_MGMT_FILTERS_L2	UINT32_C(0x2)
+	/* L3/L4 Mgmt filters in Receive Engine (RE) */
+	#define HWRM_DBG_READ_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_RE_MGMT_FILTERS_L3L4	UINT32_C(0x3)
+	/* Statistics contexts */
+	#define HWRM_DBG_READ_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_STAT_CTXS		UINT32_C(0x4)
+	/* TX L2 TCAM */
+	#define HWRM_DBG_READ_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_CFA_TX_L2_TCAM		UINT32_C(0x5)
+	/* RX L2 TCAM */
+	#define HWRM_DBG_READ_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_CFA_RX_L2_TCAM		UINT32_C(0x6)
+	/* TX IPv6 subnet TCAM */
+	#define HWRM_DBG_READ_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_CFA_TX_IPV6_SUBNET_TCAM	UINT32_C(0x7)
+	/* RX IPv6 subnet TCAM */
+	#define HWRM_DBG_READ_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_CFA_RX_IPV6_SUBNET_TCAM	UINT32_C(0x8)
+	/* TX source properties TCAM */
+	#define HWRM_DBG_READ_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_CFA_TX_SRC_PROPERTIES_TCAM UINT32_C(0x9)
+	/* RX source properties TCAM */
+	#define HWRM_DBG_READ_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_CFA_RX_SRC_PROPERTIES_TCAM UINT32_C(0xa)
+	/* VEB Lookup TCAM */
+	#define HWRM_DBG_READ_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_CFA_VEB_LOOKUP_TCAM	UINT32_C(0xb)
+	/* TX Profile Lookup TCAM */
+	#define HWRM_DBG_READ_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_CFA_TX_PROFILE_LOOKUP_TCAM UINT32_C(0xc)
+	/* RX Profile Lookup TCAM */
+	#define HWRM_DBG_READ_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_CFA_RX_PROFILE_LOOKUP_TCAM UINT32_C(0xd)
+	/* TX Lookup TCAM */
+	#define HWRM_DBG_READ_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_CFA_TX_LOOKUP_TCAM	UINT32_C(0xe)
+	/* RX Lookup TCAM */
+	#define HWRM_DBG_READ_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_CFA_RX_LOOKUP_TCAM	UINT32_C(0xf)
+	/* MHB registers (valid for multi-host environment) */
+	#define HWRM_DBG_READ_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_MHB			UINT32_C(0x10)
+	/* PCIE global registers (valid for multi-host environment) */
+	#define HWRM_DBG_READ_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_PCIE_GBL		UINT32_C(0x11)
+	/* SOC registers (valid for multi-host environment) */
+	#define HWRM_DBG_READ_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_MULTI_HOST_SOC		UINT32_C(0x12)
+	/* PCIE private registers */
+	#define HWRM_DBG_READ_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_PCIE_PRIVATE		UINT32_C(0x13)
+	/* Host DMA read */
+	#define HWRM_DBG_READ_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_HOST_DMA		UINT32_C(0x14)
+	/*
+	 * Elog (valid for only smartNIC only)
+	 * Three sub-types will be supported which will be specified
+	 * in the opaque[0] field.
+	 * 1) sub-type CHECK(0) if ELOG is available in media.
+	 * 2) sub-type READ(1) a portion of the elog.
+	 * 3) sub-type ERASE(2) a portion of the elog.
+	 *	> opaque[1] Erase offset.
+	 *	> opaque[2] Erase size.
+	 */
+	#define HWRM_DBG_READ_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_SOC_ELOG		UINT32_C(0x15)
+	/* Context operation */
+	#define HWRM_DBG_READ_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_CTX			UINT32_C(0x16)
+	/* Port Stats */
+	#define HWRM_DBG_READ_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_STATS			UINT32_C(0x17)
+	#define HWRM_DBG_READ_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_LAST			HWRM_DBG_READ_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_STATS
+	uint8_t	unused_0[3];
+	/* Entry number to start reading */
+	uint32_t	start_index;
+	/* Total number of entries to read */
+	uint32_t	num_of_entries;
 	/*
-	 * The value of source IP address to be used in filtering.
-	 * For IPv4, first four bytes represent the IP address.
+	 * command dependent data (e.g. function id for host dma command or
+	 * sub-code, erase offset and erase size for soc_elog)
 	 */
-	uint32_t	src_ipaddr[4];
+	uint32_t	opaque[10];
+} hwrm_dbg_read_indirect_input_t, *phwrm_dbg_read_indirect_input_t;
+
+/* hwrm_dbg_read_indirect_output (size:128b/16B) */
+
+typedef struct hwrm_dbg_read_indirect_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
 	/*
-	 * The value of destination IP address to be used in filtering.
-	 * For IPv4, first four bytes represent the IP address.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	uint32_t	dst_ipaddr[4];
+	uint8_t	valid;
+} hwrm_dbg_read_indirect_output_t, *phwrm_dbg_read_indirect_output_t;
+
+/***************************
+ * hwrm_dbg_write_indirect *
+ ***************************/
+
+
+/* hwrm_dbg_write_indirect_input (size:832b/104B) */
+
+typedef struct hwrm_dbg_write_indirect_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * The value of source port to be used in filtering.
-	 * Applies to UDP and TCP traffic.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint16_t	src_port;
+	uint16_t	cmpl_ring;
 	/*
-	 * The value of destination port to be used in filtering.
-	 * Applies to UDP and TCP traffic.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint16_t	dst_port;
+	uint16_t	seq_id;
 	/*
-	 * If set, this value shall represent the
-	 * Logical VNIC ID of the destination VNIC for the RX
-	 * path.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint16_t	dst_id;
+	uint16_t	target_id;
 	/*
-	 * If set, this value shall represent the L2 context that matches the
-	 * L2 information of the decap filter.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint16_t	l2_ctxt_ref_id;
-} hwrm_cfa_decap_filter_alloc_input_t, *phwrm_cfa_decap_filter_alloc_input_t;
+	uint64_t	resp_addr;
+	/* Indirect access type to on-chip data structures. */
+	uint8_t	indirect_access_type;
+	/* L2 Mgmt filters in Transmit Engine (TE) */
+	#define HWRM_DBG_WRITE_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_TE_MGMT_FILTERS_L2	UINT32_C(0x0)
+	/* L3/L4 Mgmt filters in Transmit Engine (TE) */
+	#define HWRM_DBG_WRITE_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_TE_MGMT_FILTERS_L3L4	UINT32_C(0x1)
+	/* L2 Mgmt filters in Receive Engine (RE) */
+	#define HWRM_DBG_WRITE_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_RE_MGMT_FILTERS_L2	UINT32_C(0x2)
+	/* L3/L4 Mgmt filters in Receive Engine (RE) */
+	#define HWRM_DBG_WRITE_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_RE_MGMT_FILTERS_L3L4	UINT32_C(0x3)
+	/* Statistics contexts */
+	#define HWRM_DBG_WRITE_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_STAT_CTXS		UINT32_C(0x4)
+	/* TX L2 TCAM */
+	#define HWRM_DBG_WRITE_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_CFA_TX_L2_TCAM		UINT32_C(0x5)
+	/* RX L2 TCAM */
+	#define HWRM_DBG_WRITE_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_CFA_RX_L2_TCAM		UINT32_C(0x6)
+	/* TX IPv6 subnet TCAM */
+	#define HWRM_DBG_WRITE_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_CFA_TX_IPV6_SUBNET_TCAM	UINT32_C(0x7)
+	/* RX IPv6 subnet TCAM */
+	#define HWRM_DBG_WRITE_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_CFA_RX_IPV6_SUBNET_TCAM	UINT32_C(0x8)
+	/* TX source properties TCAM */
+	#define HWRM_DBG_WRITE_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_CFA_TX_SRC_PROPERTIES_TCAM UINT32_C(0x9)
+	/* RX source properties TCAM */
+	#define HWRM_DBG_WRITE_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_CFA_RX_SRC_PROPERTIES_TCAM UINT32_C(0xa)
+	/* VEB Lookup TCAM */
+	#define HWRM_DBG_WRITE_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_CFA_VEB_LOOKUP_TCAM	UINT32_C(0xb)
+	/* TX Profile Lookup TCAM */
+	#define HWRM_DBG_WRITE_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_CFA_TX_PROFILE_LOOKUP_TCAM UINT32_C(0xc)
+	/* RX Profile Lookup TCAM */
+	#define HWRM_DBG_WRITE_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_CFA_RX_PROFILE_LOOKUP_TCAM UINT32_C(0xd)
+	/* TX Lookup TCAM */
+	#define HWRM_DBG_WRITE_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_CFA_TX_LOOKUP_TCAM	UINT32_C(0xe)
+	/* RX Lookup TCAM */
+	#define HWRM_DBG_WRITE_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_CFA_RX_LOOKUP_TCAM	UINT32_C(0xf)
+	/* MHB registers (valid for multi-host environment) */
+	#define HWRM_DBG_WRITE_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_MHB			UINT32_C(0x10)
+	/* PCIE global registers (valid for multi-host environment) */
+	#define HWRM_DBG_WRITE_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_PCIE_GBL		UINT32_C(0x11)
+	/* SOC registers (valid for multi-host environment) */
+	#define HWRM_DBG_WRITE_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_MULTI_HOST_SOC		UINT32_C(0x12)
+	/* PCIE private registers */
+	#define HWRM_DBG_WRITE_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_PCIE_PRIVATE		UINT32_C(0x13)
+	/* Host DMA write */
+	#define HWRM_DBG_WRITE_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_HOST_DMA		UINT32_C(0x14)
+	/* Invalid */
+	#define HWRM_DBG_WRITE_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_SOC_ELOG		UINT32_C(0x15)
+	/* Context operation */
+	#define HWRM_DBG_WRITE_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_CTX			UINT32_C(0x16)
+	/* Port Stats */
+	#define HWRM_DBG_WRITE_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_STATS			UINT32_C(0x17)
+	#define HWRM_DBG_WRITE_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_LAST			HWRM_DBG_WRITE_INDIRECT_INPUT_INDIRECT_ACCESS_TYPE_STATS
+	uint8_t	unused_0[3];
+	/* Entry number to start reading */
+	uint32_t	start_index;
+	/* Total number of entries to read */
+	uint32_t	num_of_entries;
+	uint8_t	unused_1[4];
+	/* write data (up to 8 dwords) */
+	uint32_t	write_data[8];
+	/* command dependent data (e.g. function id for host dma command) */
+	uint32_t	opaque[10];
+} hwrm_dbg_write_indirect_input_t, *phwrm_dbg_write_indirect_input_t;
 
-/* hwrm_cfa_decap_filter_alloc_output (size:128b/16B) */
+/* hwrm_dbg_write_indirect_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_decap_filter_alloc_output {
+typedef struct hwrm_dbg_write_indirect_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -36806,28 +64221,25 @@ typedef struct hwrm_cfa_decap_filter_alloc_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* This value is an opaque id into CFA data structures. */
-	uint32_t	decap_filter_id;
-	uint8_t	unused_0[3];
+	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_decap_filter_alloc_output_t, *phwrm_cfa_decap_filter_alloc_output_t;
+} hwrm_dbg_write_indirect_output_t, *phwrm_dbg_write_indirect_output_t;
 
-/******************************
- * hwrm_cfa_decap_filter_free *
- ******************************/
+/*****************
+ * hwrm_dbg_dump *
+ *****************/
 
 
-/* hwrm_cfa_decap_filter_free_input (size:192b/24B) */
+/* hwrm_dbg_dump_input (size:320b/40B) */
 
-typedef struct hwrm_cfa_decap_filter_free_input {
+typedef struct hwrm_dbg_dump_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -36856,14 +64268,25 @@ typedef struct hwrm_cfa_decap_filter_free_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* This value is an opaque id into CFA data structures. */
-	uint32_t	decap_filter_id;
+	/*
+	 * Handle used to dump debug data.
+	 * handle = 0 indicates the beginning of the dump.
+	 * handle != 0 indicates the request to dump the next part.
+	 */
+	uint32_t	handle;
 	uint8_t	unused_0[4];
-} hwrm_cfa_decap_filter_free_input_t, *phwrm_cfa_decap_filter_free_input_t;
+	/*
+	 * Address of the host buffer where the debug data is
+	 * requested to be dumped.
+	 */
+	uint64_t	host_dbg_dump_addr;
+	/* Length of host buffer used for transferring debug data. */
+	uint64_t	host_dbg_dump_addr_len;
+} hwrm_dbg_dump_input_t, *phwrm_dbg_dump_input_t;
 
-/* hwrm_cfa_decap_filter_free_output (size:128b/16B) */
+/* hwrm_dbg_dump_output (size:192b/24B) */
 
-typedef struct hwrm_cfa_decap_filter_free_output {
+typedef struct hwrm_dbg_dump_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -36872,26 +64295,39 @@ typedef struct hwrm_cfa_decap_filter_free_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
+	/*
+	 * Handle used to indicate availability of additional
+	 * debug data.
+	 * nexthandle = 0 indicates that there is no more debug data
+	 * available.
+	 * nexthandle != 0 indicates the handle value that should be used
+	 * to request the next part of debug data.
+	 */
+	uint32_t	nexthandle;
+	/*
+	 * The number of bytes of debug data written to debug dump
+	 * buffer.
+	 */
+	uint32_t	dbg_data_len;
 	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_decap_filter_free_output_t, *phwrm_cfa_decap_filter_free_output_t;
+} hwrm_dbg_dump_output_t, *phwrm_dbg_dump_output_t;
 
-/***********************
- * hwrm_cfa_flow_alloc *
- ***********************/
+/**********************
+ * hwrm_dbg_erase_nvm *
+ **********************/
 
 
-/* hwrm_cfa_flow_alloc_input (size:1024b/128B) */
+/* hwrm_dbg_erase_nvm_input (size:192b/24B) */
 
-typedef struct hwrm_cfa_flow_alloc_input {
+typedef struct hwrm_dbg_erase_nvm_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -36921,224 +64357,176 @@ typedef struct hwrm_cfa_flow_alloc_input {
 	 */
 	uint64_t	resp_addr;
 	uint16_t	flags;
-	/* tunnel is 1 b */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_TUNNEL		UINT32_C(0x1)
-	/* num_vlan is 2 b */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_NUM_VLAN_MASK	UINT32_C(0x6)
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_NUM_VLAN_SFT	1
-	/* no tags */
-		#define HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_NUM_VLAN_NONE		(UINT32_C(0x0) << 1)
-	/* 1 tag */
-		#define HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_NUM_VLAN_ONE		(UINT32_C(0x1) << 1)
-	/* 2 tags */
-		#define HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_NUM_VLAN_TWO		(UINT32_C(0x2) << 1)
-		#define HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_NUM_VLAN_LAST	HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_NUM_VLAN_TWO
-	/* Enumeration denoting the Flow Type. */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_FLOWTYPE_MASK	UINT32_C(0x38)
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_FLOWTYPE_SFT	3
-	/* L2 flow */
-		#define HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_FLOWTYPE_L2		(UINT32_C(0x0) << 3)
-	/* IPV4 flow */
-		#define HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_FLOWTYPE_IPV4		(UINT32_C(0x1) << 3)
-	/* IPV6 flow */
-		#define HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_FLOWTYPE_IPV6		(UINT32_C(0x2) << 3)
-		#define HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_FLOWTYPE_LAST	HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_FLOWTYPE_IPV6
-	/*
-	 * when set to 1, indicates TX flow offload for function specified
-	 * in src_fid and the dst_fid should be set to invalid value. To
-	 * indicate a VM to VM flow, both of the path_tx and path_rx flags
-	 * need to be set. For virtio vSwitch offload case, the src_fid and
-	 * dst_fid is set to the same fid value. For the SRIOV vSwitch
-	 * offload case, the src_fid and dst_fid must be set to the same VF
-	 * FID belong to the children VFs of the same PF to indicate VM to
-	 * VM flow.
-	 */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_PATH_TX		UINT32_C(0x40)
-	/*
-	 * when set to 1, indicates RX flow offload for function specified
-	 * in dst_fid and the src_fid should be set to invalid value.
-	 */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_PATH_RX		UINT32_C(0x80)
+	/* If set to 1, then erase all locations in persistent storage. */
+	#define HWRM_DBG_ERASE_NVM_INPUT_FLAGS_ERASE_ALL	UINT32_C(0x1)
+	uint8_t	unused_0[6];
+} hwrm_dbg_erase_nvm_input_t, *phwrm_dbg_erase_nvm_input_t;
+
+/* hwrm_dbg_erase_nvm_output (size:128b/16B) */
+
+typedef struct hwrm_dbg_erase_nvm_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
 	/*
-	 * Set to 1 to indicate matching of VXLAN VNI from the custom vxlan
-	 * header is required and the VXLAN VNI value is stored in the first
-	 * 24 bits of the dmac field. This flag is only valid when the flow
-	 * direction is RX.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_MATCH_VXLAN_IP_VNI	UINT32_C(0x100)
+	uint8_t	valid;
+} hwrm_dbg_erase_nvm_output_t, *phwrm_dbg_erase_nvm_output_t;
+
+/****************
+ * hwrm_dbg_cfg *
+ ****************/
+
+
+/* hwrm_dbg_cfg_input (size:192b/24B) */
+
+typedef struct hwrm_dbg_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * Set to 1 to indicate vhost_id is specified in the outer_vlan_tci
-	 * field.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_FLAGS_VHOST_ID_USE_VLAN	UINT32_C(0x200)
+	uint16_t	cmpl_ring;
 	/*
-	 * Tx Flow: vf fid.
-	 * Rx Flow: pf fid.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint16_t	src_fid;
-	/* Tunnel handle valid when tunnel flag is set. */
-	uint32_t	tunnel_handle;
-	uint16_t	action_flags;
+	uint16_t	seq_id;
 	/*
-	 * Setting of this flag indicates drop action. If this flag is not
-	 * set, then it should be considered accept action.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_ACTION_FLAGS_FWD			UINT32_C(0x1)
-	/* recycle is 1 b */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_ACTION_FLAGS_RECYCLE		UINT32_C(0x2)
+	uint16_t	target_id;
 	/*
-	 * Setting of this flag indicates drop action. If this flag is not
-	 * set, then it should be considered accept action.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_ACTION_FLAGS_DROP			UINT32_C(0x4)
-	/* meter is 1 b */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_ACTION_FLAGS_METER			UINT32_C(0x8)
-	/* tunnel is 1 b */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_ACTION_FLAGS_TUNNEL			UINT32_C(0x10)
-	/* nat_src is 1 b */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_ACTION_FLAGS_NAT_SRC		UINT32_C(0x20)
-	/* nat_dest is 1 b */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_ACTION_FLAGS_NAT_DEST		UINT32_C(0x40)
-	/* nat_ipv4_address is 1 b */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_ACTION_FLAGS_NAT_IPV4_ADDRESS	UINT32_C(0x80)
-	/* l2_header_rewrite is 1 b */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_ACTION_FLAGS_L2_HEADER_REWRITE	UINT32_C(0x100)
-	/* ttl_decrement is 1 b */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_ACTION_FLAGS_TTL_DECREMENT		UINT32_C(0x200)
+	uint64_t	resp_addr;
+	uint32_t	flags;
 	/*
-	 * If set to 1 and flow direction is TX, it indicates decap of L2
-	 * header and encap of tunnel header. If set to 1 and flow direction
-	 * is RX, it indicates decap of tunnel header and encap L2 header.
-	 * The type of tunnel is specified in the tunnel_type field.
+	 * If set to 1, then UART logging will be enabled for the primary
+	 * firmware. Disabled otherwise.
 	 */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_ACTION_FLAGS_TUNNEL_IP		UINT32_C(0x400)
-	/* If set to 1, flow aging is enabled for this flow. */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_ACTION_FLAGS_FLOW_AGING_ENABLED	UINT32_C(0x800)
+	#define HWRM_DBG_CFG_INPUT_FLAGS_UART_LOG		UINT32_C(0x1)
 	/*
-	 * If set to 1 an attempt will be made to try to offload this flow
-	 * to the most optimal flow table resource. If set to 0, the flow
-	 * will be placed to the default flow table resource.
+	 * If set to 1, then UART logging will be enabled for the secondary
+	 * firmware. Disabled otherwise. If a single UART is available then
+	 * setting this bit will override the uart_log bit.
 	 */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_ACTION_FLAGS_PRI_HINT		UINT32_C(0x1000)
+	#define HWRM_DBG_CFG_INPUT_FLAGS_UART_LOG_SECONDARY	UINT32_C(0x2)
 	/*
-	 * If set to 1 there will be no attempt to allocate an on-chip try
-	 * to offload this flow. If set to 0, which will keep compatibility
-	 * with the older drivers, will cause the FW to attempt to allocate
-	 * an on-chip flow counter for the newly created flow. This will
-	 * keep the existing behavior with EM flows which always had an
-	 * associated flow counter.
+	 * If set to 1, then completion ring logging will be enabled for the
+	 * primary firmware. Disabled otherwise.
 	 */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_ACTION_FLAGS_NO_FLOW_COUNTER_ALLOC	UINT32_C(0x2000)
+	#define HWRM_DBG_CFG_INPUT_FLAGS_FW_TRACE		UINT32_C(0x4)
 	/*
-	 * Tx Flow: pf or vf fid.
-	 * Rx Flow: vf fid.
+	 * If set to 1, then completion ring logging will be enabled for the
+	 * secondary firmware. Disabled otherwise.
 	 */
-	uint16_t	dst_fid;
-	/* VLAN tpid, valid when push_vlan flag is set. */
-	uint16_t	l2_rewrite_vlan_tpid;
-	/* VLAN tci, valid when push_vlan flag is set. */
-	uint16_t	l2_rewrite_vlan_tci;
-	/* Meter id, valid when meter flag is set. */
-	uint16_t	act_meter_id;
-	/* Flow with the same l2 context tcam key. */
-	uint16_t	ref_flow_handle;
-	/* This value sets the match value for the ethertype. */
-	uint16_t	ethertype;
-	/* valid when num tags is 1 or 2. */
-	uint16_t	outer_vlan_tci;
-	/* This value sets the match value for the Destination MAC address. */
-	uint16_t	dmac[3];
-	/* valid when num tags is 2. */
-	uint16_t	inner_vlan_tci;
-	/* This value sets the match value for the Source MAC address. */
-	uint16_t	smac[3];
-	/* The bit length of destination IP address mask. */
-	uint8_t	ip_dst_mask_len;
-	/* The bit length of source IP address mask. */
-	uint8_t	ip_src_mask_len;
-	/* The value of destination IPv4/IPv6 address. */
-	uint32_t	ip_dst[4];
-	/* The source IPv4/IPv6 address. */
-	uint32_t	ip_src[4];
+	#define HWRM_DBG_CFG_INPUT_FLAGS_FW_TRACE_SECONDARY	UINT32_C(0x8)
 	/*
-	 * The value of source port.
-	 * Applies to UDP and TCP traffic.
+	 * If set to 1, firmware will generate debug_notification async
+	 * events to the driver as applicable.
 	 */
-	uint16_t	l4_src_port;
+	#define HWRM_DBG_CFG_INPUT_FLAGS_DEBUG_NOTIFY	UINT32_C(0x10)
 	/*
-	 * The value of source port mask.
-	 * Applies to UDP and TCP traffic.
+	 * If set to 1, firmware is allowed to be unresponsive to heartbeat
+	 * health checks, allowing for JTAG debugging scenarios where the
+	 * debugger has the firmware processes stopped indefinitely. This
+	 * flag has effect only on debug builds of firmware.
 	 */
-	uint16_t	l4_src_port_mask;
+	#define HWRM_DBG_CFG_INPUT_FLAGS_JTAG_DEBUG		UINT32_C(0x20)
 	/*
-	 * The value of destination port.
-	 * Applies to UDP and TCP traffic.
+	 * Notification queue (completion ring) used by the firmware to post
+	 * async debug notifications and fw trace logs. This field is valid
+	 * when fw_trace, fw_trace_secondary or debug_notify flags are set.
 	 */
-	uint16_t	l4_dst_port;
+	uint16_t	async_cmpl_ring;
+	uint8_t	unused_0[2];
+} hwrm_dbg_cfg_input_t, *phwrm_dbg_cfg_input_t;
+
+/* hwrm_dbg_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_dbg_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
 	/*
-	 * The value of destination port mask.
-	 * Applies to UDP and TCP traffic.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	uint16_t	l4_dst_port_mask;
+	uint8_t	valid;
+} hwrm_dbg_cfg_output_t, *phwrm_dbg_cfg_output_t;
+
+/*****************************
+ * hwrm_dbg_crashdump_header *
+ *****************************/
+
+
+/* hwrm_dbg_crashdump_header_input (size:192b/24B) */
+
+typedef struct hwrm_dbg_crashdump_header_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * NAT IPv4/6 address based on address type flag.
-	 * 0 values are ignored.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint32_t	nat_ip_address[4];
-	/* L2 header re-write Destination MAC address. */
-	uint16_t	l2_rewrite_dmac[3];
+	uint16_t	cmpl_ring;
 	/*
-	 * The NAT source/destination port based on direction flag.
-	 * Applies to UDP and TCP traffic.
-	 * 0 values are ignored.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint16_t	nat_port;
-	/* L2 header re-write Source MAC address. */
-	uint16_t	l2_rewrite_smac[3];
-	/* The value of ip protocol. */
-	uint8_t	ip_proto;
-	/* Tunnel Type. */
-	uint8_t	tunnel_type;
-	/* Non-tunnel */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_TUNNEL_TYPE_NONTUNNEL	UINT32_C(0x0)
-	/* Virtual eXtensible Local Area Network (VXLAN) */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_TUNNEL_TYPE_VXLAN	UINT32_C(0x1)
-	/* Network Virtualization Generic Routing Encapsulation (NVGRE) */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_TUNNEL_TYPE_NVGRE	UINT32_C(0x2)
-	/* Generic Routing Encapsulation (GRE) inside Ethernet payload */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_TUNNEL_TYPE_L2GRE	UINT32_C(0x3)
-	/* IP in IP */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_TUNNEL_TYPE_IPIP	UINT32_C(0x4)
-	/* Generic Network Virtualization Encapsulation (Geneve) */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_TUNNEL_TYPE_GENEVE	UINT32_C(0x5)
-	/* Multi-Protocol Label Switching (MPLS) */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_TUNNEL_TYPE_MPLS	UINT32_C(0x6)
-	/* Stateless Transport Tunnel (STT) */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_TUNNEL_TYPE_STT	UINT32_C(0x7)
-	/* Generic Routing Encapsulation (GRE) inside IP datagram payload */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_TUNNEL_TYPE_IPGRE	UINT32_C(0x8)
-	/* IPV4 over virtual eXtensible Local Area Network (IPV4oVXLAN) */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_V4	UINT32_C(0x9)
+	uint16_t	seq_id;
 	/*
-	 * Enhance Generic Routing Encapsulation (GRE version 1) inside IP
-	 * datagram payload
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_TUNNEL_TYPE_IPGRE_V1	UINT32_C(0xa)
-	/* Use fixed layer 2 ether type of 0xFFFF */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_TUNNEL_TYPE_L2_ETYPE	UINT32_C(0xb)
+	uint16_t	target_id;
 	/*
-	 * IPV6 over virtual eXtensible Local Area Network with GPE header
-	 * (IPV6oVXLANGPE)
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_GPE_V6 UINT32_C(0xc)
-	/* Any tunneled traffic */
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_TUNNEL_TYPE_ANYTUNNEL	UINT32_C(0xff)
-	#define HWRM_CFA_FLOW_ALLOC_INPUT_TUNNEL_TYPE_LAST	HWRM_CFA_FLOW_ALLOC_INPUT_TUNNEL_TYPE_ANYTUNNEL
-} hwrm_cfa_flow_alloc_input_t, *phwrm_cfa_flow_alloc_input_t;
+	uint64_t	resp_addr;
+	uint64_t	unused_0;
+} hwrm_dbg_crashdump_header_input_t, *phwrm_dbg_crashdump_header_input_t;
 
-/* hwrm_cfa_flow_alloc_output (size:256b/32B) */
+/* hwrm_dbg_crashdump_header_output (size:512b/64B) */
 
-typedef struct hwrm_cfa_flow_alloc_output {
+typedef struct hwrm_dbg_crashdump_header_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -37147,91 +64535,109 @@ typedef struct hwrm_cfa_flow_alloc_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* Flow record index. */
-	uint16_t	flow_handle;
-	uint8_t	unused_0[2];
+	/* Major version. */
+	uint8_t	version_hi;
+	/* Minor version. */
+	uint8_t	version_low;
 	/*
-	 * The flow id value in bit 0-29 is the actual ID of the flow
-	 * associated with this filter and it shall be used to match
-	 * and associate the flow identifier returned in completion
-	 * records. A value of 0xFFFFFFFF in the 32-bit flow_id field
-	 * shall indicate no valid flow id.
+	 * Header length in bytes. This includes all fields from version
+	 * to dev_uid (whose length is specified in dev_uid_length).
 	 */
-	uint32_t	flow_id;
-	/* Indicate the flow id value. */
-	#define HWRM_CFA_FLOW_ALLOC_OUTPUT_FLOW_ID_VALUE_MASK UINT32_C(0x3fffffff)
-	#define HWRM_CFA_FLOW_ALLOC_OUTPUT_FLOW_ID_VALUE_SFT 0
-	/* Indicate type of the flow. */
-	#define HWRM_CFA_FLOW_ALLOC_OUTPUT_FLOW_ID_TYPE	UINT32_C(0x40000000)
+	uint16_t	header_len;
+	/* This is the crash dump size in bytes. */
+	uint32_t	dump_size;
 	/*
-	 * If this bit set to 0, then it indicates that the flow is
-	 * internal flow.
+	 * This is a "wall clock" timestamp value of when the crash occurred.
+	 * Format is of time_t type.
+	 */
+	uint32_t	crash_time;
+	/* This is the timezone information for the crash_time. */
+	int8_t	utc_offset;
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_UTC				0
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_AMSTERDAM			4
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_EGYPT			8
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_EUROPE_MOSCOW		12
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_IRAN			14
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_ASIA_DUBAI			16
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_ASIA_KABUL			18
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_ANTARCTICA_MAWSON		20
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_ASIA_COLOMBO		22
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_ASIA_KATHMANDU		23
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_INDIAN_CHAGOS		24
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_INDIAN_COCOS		26
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_ASIA_BANGKOK		28
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_ASIA_HONG_KONG		32
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_ASIA_PYONGYANG		34
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_AUSTRALIA_EUCLA		35
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_ASIA_TOKYO			36
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_AUSTRALIA_ADELAIDE		38
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_AUSTRALIA_BROKEN_HILL	38
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_AUSTRALIA_DARWIN		38
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_AUSTRALIA_SYDNEY		40
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_AUSTRALIA_LORD_HOWE		42
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_ANTARCTICA_MACQUARIE	44
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_ANTARCTICA_SOUTH_POLE	48
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_PACIFIC_CHATHAM		51
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_PACIFIC_APIA		52
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_PACIFIC_KIRITIMATIS		56
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_ATLANTIC_CAPE_VERDE		-4
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_ATLANTIC_SOUTH_GEORGIA	-8
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_AMERICA_ARGENTINA_BUENOS_AIRES -12
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_AMERICA_SAO_PAULO		-12
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_AMERICA_NEWFOUNDLAND	-14
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_AMERICA_BARBADOS		-16
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_AMERICA_CANCUN		-20
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_AMERICA_COSTA_RICA		-24
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_AMERICA_PHOENIX		-28
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_US_ARIZONA			-28
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_US_PACIFIC			-32
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_US_ALASKA			-36
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_PACIFIC_MARQUESAS		-38
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_PACIFIC_HAWAII		-40
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_PACIFIC_MIDWAY		-44
+	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_LAST			HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_PACIFIC_MIDWAY
+	/*
+	 * This field is a counter value of the crash dump available. This
+	 * value is incremented monotonically at each crash.
+	 */
+	uint8_t	crash_cntr;
+	/*
+	 * This specifies the length of the dev_uid in bytes. The maximum
+	 * value is 31.
+	 */
+	uint16_t	dev_uid_length;
+	/*
+	 * This is a unique device identifier (e.g. the first port MAC
+	 * address for a network controller or a serial number for an
+	 * en/decryption device) in ASCII format. It is used to identify
+	 * where the crash dump content is coming from. Unused bytes must
+	 * have '\0' character.
 	 */
-		#define HWRM_CFA_FLOW_ALLOC_OUTPUT_FLOW_ID_TYPE_INT	(UINT32_C(0x0) << 30)
+	uint8_t	dev_uid[32];
 	/*
-	 * If this bit is set to 1, then it indicates that the flow is
-	 * external flow.
+	 * This is a count value tracking the number of successful boots
+	 * before the crash occurred.
 	 */
-		#define HWRM_CFA_FLOW_ALLOC_OUTPUT_FLOW_ID_TYPE_EXT	(UINT32_C(0x1) << 30)
-		#define HWRM_CFA_FLOW_ALLOC_OUTPUT_FLOW_ID_TYPE_LAST  HWRM_CFA_FLOW_ALLOC_OUTPUT_FLOW_ID_TYPE_EXT
-	/* Indicate the flow direction. */
-	#define HWRM_CFA_FLOW_ALLOC_OUTPUT_FLOW_ID_DIR	UINT32_C(0x80000000)
-	/* If this bit set to 0, then it indicates rx flow. */
-		#define HWRM_CFA_FLOW_ALLOC_OUTPUT_FLOW_ID_DIR_RX	(UINT32_C(0x0) << 31)
-	/* If this bit is set to 1, then it indicates that tx flow. */
-		#define HWRM_CFA_FLOW_ALLOC_OUTPUT_FLOW_ID_DIR_TX	(UINT32_C(0x1) << 31)
-		#define HWRM_CFA_FLOW_ALLOC_OUTPUT_FLOW_ID_DIR_LAST   HWRM_CFA_FLOW_ALLOC_OUTPUT_FLOW_ID_DIR_TX
-	/* This value identifies a set of CFA data structures used for a flow. */
-	uint64_t	ext_flow_handle;
-	uint32_t	flow_counter_id;
-	uint8_t	unused_1[3];
+	uint32_t	power_on_count;
+	uint8_t	unused_2[3];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_flow_alloc_output_t, *phwrm_cfa_flow_alloc_output_t;
-
-/* hwrm_cfa_flow_alloc_cmd_err (size:64b/8B) */
-
-typedef struct hwrm_cfa_flow_alloc_cmd_err {
-	/*
-	 * command specific error codes that goes to
-	 * the cmd_err field in Common HWRM Error Response.
-	 */
-	uint8_t	code;
-	/* Unknown error */
-	#define HWRM_CFA_FLOW_ALLOC_CMD_ERR_CODE_UNKNOWN	UINT32_C(0x0)
-	/* No more L2 Context TCAM */
-	#define HWRM_CFA_FLOW_ALLOC_CMD_ERR_CODE_L2_CONTEXT_TCAM UINT32_C(0x1)
-	/* No more action records */
-	#define HWRM_CFA_FLOW_ALLOC_CMD_ERR_CODE_ACTION_RECORD   UINT32_C(0x2)
-	/* No more flow counters */
-	#define HWRM_CFA_FLOW_ALLOC_CMD_ERR_CODE_FLOW_COUNTER	UINT32_C(0x3)
-	/* No more wild-card TCAM */
-	#define HWRM_CFA_FLOW_ALLOC_CMD_ERR_CODE_WILD_CARD_TCAM  UINT32_C(0x4)
-	/* Hash collsion in exact match tables */
-	#define HWRM_CFA_FLOW_ALLOC_CMD_ERR_CODE_HASH_COLLISION  UINT32_C(0x5)
-	/* Key is already installed */
-	#define HWRM_CFA_FLOW_ALLOC_CMD_ERR_CODE_KEY_EXISTS	UINT32_C(0x6)
-	/* Flow Context DB is out of resource */
-	#define HWRM_CFA_FLOW_ALLOC_CMD_ERR_CODE_FLOW_CTXT_DB	UINT32_C(0x7)
-	#define HWRM_CFA_FLOW_ALLOC_CMD_ERR_CODE_LAST	HWRM_CFA_FLOW_ALLOC_CMD_ERR_CODE_FLOW_CTXT_DB
-	uint8_t	unused_0[7];
-} hwrm_cfa_flow_alloc_cmd_err_t, *phwrm_cfa_flow_alloc_cmd_err_t;
+} hwrm_dbg_crashdump_header_output_t, *phwrm_dbg_crashdump_header_output_t;
 
-/**********************
- * hwrm_cfa_flow_free *
- **********************/
+/****************************
+ * hwrm_dbg_crashdump_erase *
+ ****************************/
 
 
-/* hwrm_cfa_flow_free_input (size:256b/32B) */
+/* hwrm_dbg_crashdump_erase_input (size:192b/24B) */
 
-typedef struct hwrm_cfa_flow_free_input {
+typedef struct hwrm_dbg_crashdump_erase_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -37260,18 +64666,29 @@ typedef struct hwrm_cfa_flow_free_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Flow record index. */
-	uint16_t	flow_handle;
-	uint16_t	unused_0;
-	/* Flow counter id to be freed. */
-	uint32_t	flow_counter_id;
-	/* This value identifies a set of CFA data structures used for a flow. */
-	uint64_t	ext_flow_handle;
-} hwrm_cfa_flow_free_input_t, *phwrm_cfa_flow_free_input_t;
+	/* The scope of the erase */
+	uint8_t	scope;
+	/*
+	 * Wipe all crashdump data blocks, making them available for
+	 * the next crash(es). This is the typical value to be used.
+	 */
+	#define HWRM_DBG_CRASHDUMP_ERASE_INPUT_SCOPE_INVALIDATE UINT32_C(0x0)
+	/*
+	 * Experimental: Remove all data blocks from the directory
+	 * (without erasing any existing contents), re-allocate and
+	 * re-initialize new ones. In case where the crash dump feature
+	 * stops functioning, this can be used to restore it back to the
+	 * clean slate.
+	 */
+	#define HWRM_DBG_CRASHDUMP_ERASE_INPUT_SCOPE_REINIT	UINT32_C(0x1)
+	#define HWRM_DBG_CRASHDUMP_ERASE_INPUT_SCOPE_LAST	HWRM_DBG_CRASHDUMP_ERASE_INPUT_SCOPE_REINIT
+	uint8_t	unused_0[3];
+	uint32_t	unused_1;
+} hwrm_dbg_crashdump_erase_input_t, *phwrm_dbg_crashdump_erase_input_t;
 
-/* hwrm_cfa_flow_free_output (size:256b/32B) */
+/* hwrm_dbg_crashdump_erase_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_flow_free_output {
+typedef struct hwrm_dbg_crashdump_erase_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -37280,245 +64697,25 @@ typedef struct hwrm_cfa_flow_free_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* packet is 64 b */
-	uint64_t	packet;
-	/* byte is 64 b */
-	uint64_t	byte;
-	uint8_t	unused_0[7];
+	uint8_t	unused_1[7];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_flow_free_output_t, *phwrm_cfa_flow_free_output_t;
-
-/* hwrm_cfa_flow_action_data (size:960b/120B) */
-
-typedef struct hwrm_cfa_flow_action_data {
-	uint16_t	action_flags;
-	/* Setting of this flag indicates accept action. */
-	#define HWRM_CFA_FLOW_ACTION_DATA_ACTION_FLAGS_FWD			UINT32_C(0x1)
-	/* Setting of this flag indicates recycle action. */
-	#define HWRM_CFA_FLOW_ACTION_DATA_ACTION_FLAGS_RECYCLE		UINT32_C(0x2)
-	/* Setting of this flag indicates drop action. */
-	#define HWRM_CFA_FLOW_ACTION_DATA_ACTION_FLAGS_DROP		UINT32_C(0x4)
-	/* Setting of this flag indicates meter action. */
-	#define HWRM_CFA_FLOW_ACTION_DATA_ACTION_FLAGS_METER		UINT32_C(0x8)
-	/* Setting of this flag indicates tunnel action. */
-	#define HWRM_CFA_FLOW_ACTION_DATA_ACTION_FLAGS_TUNNEL		UINT32_C(0x10)
-	/*
-	 * If set to 1 and flow direction is TX, it indicates decap of L2
-	 * header and encap of tunnel header. If set to 1 and flow direction
-	 * is RX, it indicates decap of tunnel header and encap L2 header.
-	 */
-	#define HWRM_CFA_FLOW_ACTION_DATA_ACTION_FLAGS_TUNNEL_IP		UINT32_C(0x20)
-	/* Setting of this flag indicates ttl decrement action. */
-	#define HWRM_CFA_FLOW_ACTION_DATA_ACTION_FLAGS_TTL_DECREMENT	UINT32_C(0x40)
-	/* If set to 1, flow aging is enabled for this flow. */
-	#define HWRM_CFA_FLOW_ACTION_DATA_ACTION_FLAGS_FLOW_AGING_ENABLED	UINT32_C(0x80)
-	/* Setting of this flag indicates encap action. */
-	#define HWRM_CFA_FLOW_ACTION_DATA_ACTION_FLAGS_ENCAP		UINT32_C(0x100)
-	/* Setting of this flag indicates decap action. */
-	#define HWRM_CFA_FLOW_ACTION_DATA_ACTION_FLAGS_DECAP		UINT32_C(0x200)
-	/* Meter id. */
-	uint16_t	act_meter_id;
-	/* VNIC id. */
-	uint16_t	vnic_id;
-	/* vport number. */
-	uint16_t	vport_id;
-	/* The NAT source/destination. */
-	uint16_t	nat_port;
-	uint16_t	unused_0[3];
-	/* NAT IPv4/IPv6 address. */
-	uint32_t	nat_ip_address[4];
-	/* Encapsulation Type. */
-	uint8_t	encap_type;
-	/* Virtual eXtensible Local Area Network (VXLAN) */
-	#define HWRM_CFA_FLOW_ACTION_DATA_ENCAP_TYPE_VXLAN	UINT32_C(0x1)
-	/* Network Virtualization Generic Routing Encapsulation (NVGRE) */
-	#define HWRM_CFA_FLOW_ACTION_DATA_ENCAP_TYPE_NVGRE	UINT32_C(0x2)
-	/* Generic Routing Encapsulation (GRE) after inside Ethernet payload */
-	#define HWRM_CFA_FLOW_ACTION_DATA_ENCAP_TYPE_L2GRE	UINT32_C(0x3)
-	/* IP in IP */
-	#define HWRM_CFA_FLOW_ACTION_DATA_ENCAP_TYPE_IPIP	UINT32_C(0x4)
-	/* Generic Network Virtualization Encapsulation (Geneve) */
-	#define HWRM_CFA_FLOW_ACTION_DATA_ENCAP_TYPE_GENEVE	UINT32_C(0x5)
-	/* Multi-Protocol Label Switching (MPLS) */
-	#define HWRM_CFA_FLOW_ACTION_DATA_ENCAP_TYPE_MPLS	UINT32_C(0x6)
-	/* VLAN */
-	#define HWRM_CFA_FLOW_ACTION_DATA_ENCAP_TYPE_VLAN	UINT32_C(0x7)
-	/* Generic Routing Encapsulation (GRE) inside IP datagram payload */
-	#define HWRM_CFA_FLOW_ACTION_DATA_ENCAP_TYPE_IPGRE	UINT32_C(0x8)
-	/* IPV4 over virtual eXtensible Local Area Network (IPV4oVXLAN) */
-	#define HWRM_CFA_FLOW_ACTION_DATA_ENCAP_TYPE_VXLAN_V4	UINT32_C(0x9)
-	/*
-	 * Enhance Generic Routing Encapsulation (GRE version 1) inside IP
-	 * datagram payload
-	 */
-	#define HWRM_CFA_FLOW_ACTION_DATA_ENCAP_TYPE_IPGRE_V1	UINT32_C(0xa)
-	/* Use fixed layer 2 ether type of 0xFFFF */
-	#define HWRM_CFA_FLOW_ACTION_DATA_ENCAP_TYPE_L2_ETYPE	UINT32_C(0xb)
-	/*
-	 * IPV6 over virtual eXtensible Local Area Network with GPE header
-	 * (IPV6oVXLANGPE)
-	 */
-	#define HWRM_CFA_FLOW_ACTION_DATA_ENCAP_TYPE_VXLAN_GPE_V6 UINT32_C(0xc)
-	#define HWRM_CFA_FLOW_ACTION_DATA_ENCAP_TYPE_LAST	HWRM_CFA_FLOW_ACTION_DATA_ENCAP_TYPE_VXLAN_GPE_V6
-	uint8_t	unused[7];
-	/* This value is encap data for the associated encap type. */
-	uint32_t	encap_data[20];
-} hwrm_cfa_flow_action_data_t, *phwrm_cfa_flow_action_data_t;
-
-/* hwrm_cfa_flow_tunnel_hdr_data (size:64b/8B) */
-
-typedef struct hwrm_cfa_flow_tunnel_hdr_data {
-	/* Tunnel Type. */
-	uint8_t	tunnel_type;
-	/* Non-tunnel */
-	#define HWRM_CFA_FLOW_TUNNEL_HDR_DATA_TUNNEL_TYPE_NONTUNNEL	UINT32_C(0x0)
-	/* Virtual eXtensible Local Area Network (VXLAN) */
-	#define HWRM_CFA_FLOW_TUNNEL_HDR_DATA_TUNNEL_TYPE_VXLAN	UINT32_C(0x1)
-	/* Network Virtualization Generic Routing Encapsulation (NVGRE) */
-	#define HWRM_CFA_FLOW_TUNNEL_HDR_DATA_TUNNEL_TYPE_NVGRE	UINT32_C(0x2)
-	/* Generic Routing Encapsulation (GRE) inside Ethernet payload */
-	#define HWRM_CFA_FLOW_TUNNEL_HDR_DATA_TUNNEL_TYPE_L2GRE	UINT32_C(0x3)
-	/* IP in IP */
-	#define HWRM_CFA_FLOW_TUNNEL_HDR_DATA_TUNNEL_TYPE_IPIP	UINT32_C(0x4)
-	/* Generic Network Virtualization Encapsulation (Geneve) */
-	#define HWRM_CFA_FLOW_TUNNEL_HDR_DATA_TUNNEL_TYPE_GENEVE	UINT32_C(0x5)
-	/* Multi-Protocol Label Switching (MPLS) */
-	#define HWRM_CFA_FLOW_TUNNEL_HDR_DATA_TUNNEL_TYPE_MPLS	UINT32_C(0x6)
-	/* Stateless Transport Tunnel (STT) */
-	#define HWRM_CFA_FLOW_TUNNEL_HDR_DATA_TUNNEL_TYPE_STT	UINT32_C(0x7)
-	/* Generic Routing Encapsulation (GRE) inside IP datagram payload */
-	#define HWRM_CFA_FLOW_TUNNEL_HDR_DATA_TUNNEL_TYPE_IPGRE	UINT32_C(0x8)
-	/* IPV4 over virtual eXtensible Local Area Network (IPV4oVXLAN) */
-	#define HWRM_CFA_FLOW_TUNNEL_HDR_DATA_TUNNEL_TYPE_VXLAN_V4	UINT32_C(0x9)
-	/*
-	 * Enhance Generic Routing Encapsulation (GRE version 1) inside IP
-	 * datagram payload
-	 */
-	#define HWRM_CFA_FLOW_TUNNEL_HDR_DATA_TUNNEL_TYPE_IPGRE_V1	UINT32_C(0xa)
-	/* Use fixed layer 2 ether type of 0xFFFF */
-	#define HWRM_CFA_FLOW_TUNNEL_HDR_DATA_TUNNEL_TYPE_L2_ETYPE	UINT32_C(0xb)
-	/*
-	 * IPV6 over virtual eXtensible Local Area Network with GPE header
-	 * (IPV6oVXLANGPE)
-	 */
-	#define HWRM_CFA_FLOW_TUNNEL_HDR_DATA_TUNNEL_TYPE_VXLAN_GPE_V6 UINT32_C(0xc)
-	/* Any tunneled traffic */
-	#define HWRM_CFA_FLOW_TUNNEL_HDR_DATA_TUNNEL_TYPE_ANYTUNNEL	UINT32_C(0xff)
-	#define HWRM_CFA_FLOW_TUNNEL_HDR_DATA_TUNNEL_TYPE_LAST	HWRM_CFA_FLOW_TUNNEL_HDR_DATA_TUNNEL_TYPE_ANYTUNNEL
-	uint8_t	unused[3];
-	/*
-	 * Tunnel identifier.
-	 * Virtual Network Identifier (VNI).
-	 */
-	uint32_t	tunnel_id;
-} hwrm_cfa_flow_tunnel_hdr_data_t, *phwrm_cfa_flow_tunnel_hdr_data_t;
-
-/* hwrm_cfa_flow_l4_key_data (size:64b/8B) */
-
-typedef struct hwrm_cfa_flow_l4_key_data {
-	/* The value of source port. */
-	uint16_t	l4_src_port;
-	/* The value of destination port. */
-	uint16_t	l4_dst_port;
-	uint32_t	unused;
-} hwrm_cfa_flow_l4_key_data_t, *phwrm_cfa_flow_l4_key_data_t;
-
-/* hwrm_cfa_flow_l3_key_data (size:512b/64B) */
-
-typedef struct hwrm_cfa_flow_l3_key_data {
-	/* The value of ip protocol. */
-	uint8_t	ip_protocol;
-	uint8_t	unused_0[7];
-	/* The value of destination IPv4/IPv6 address. */
-	uint32_t	ip_dst[4];
-	/* The source IPv4/IPv6 address. */
-	uint32_t	ip_src[4];
-	/* NAT IPv4/IPv6 address. */
-	uint32_t	nat_ip_address[4];
-	uint64_t	unused;
-} hwrm_cfa_flow_l3_key_data_t, *phwrm_cfa_flow_l3_key_data_t;
-
-/* hwrm_cfa_flow_l2_key_data (size:448b/56B) */
-
-typedef struct hwrm_cfa_flow_l2_key_data {
-	/* Destination MAC address. */
-	uint16_t	dmac[3];
-	uint16_t	unused_0;
-	/* Source MAC address. */
-	uint16_t	smac[3];
-	uint16_t	unused_1;
-	/* L2 header re-write Destination MAC address. */
-	uint16_t	l2_rewrite_dmac[3];
-	uint16_t	unused_2;
-	/* L2 header re-write Source MAC address. */
-	uint16_t	l2_rewrite_smac[3];
-	/* Ethertype. */
-	uint16_t	ethertype;
-	/* Number of VLAN tags. */
-	uint16_t	num_vlan_tags;
-	/* VLAN tpid. */
-	uint16_t	l2_rewrite_vlan_tpid;
-	/* VLAN tci. */
-	uint16_t	l2_rewrite_vlan_tci;
-	uint8_t	unused_3[2];
-	/* Outer VLAN TPID. */
-	uint16_t	ovlan_tpid;
-	/* Outer VLAN TCI. */
-	uint16_t	ovlan_tci;
-	/* Inner VLAN TPID. */
-	uint16_t	ivlan_tpid;
-	/* Inner VLAN TCI. */
-	uint16_t	ivlan_tci;
-	uint8_t	unused[8];
-} hwrm_cfa_flow_l2_key_data_t, *phwrm_cfa_flow_l2_key_data_t;
-
-/* hwrm_cfa_flow_key_data (size:4160b/520B) */
-
-typedef struct hwrm_cfa_flow_key_data {
-	/* Flow associated tunnel L2 header key info. */
-	uint32_t	t_l2_key_data[14];
-	/* Flow associated tunnel L2 header mask info. */
-	uint32_t	t_l2_key_mask[14];
-	/* Flow associated tunnel L3 header key info. */
-	uint32_t	t_l3_key_data[16];
-	/* Flow associated tunnel L3 header mask info. */
-	uint32_t	t_l3_key_mask[16];
-	/* Flow associated tunnel L4 header key info. */
-	uint64_t	t_l4_key_data;
-	/* Flow associated tunnel L4 header mask info. */
-	uint64_t	t_l4_key_mask;
-	/* Flow associated tunnel header info. */
-	uint64_t	tunnel_hdr;
-	/* Flow associated L2 header key info. */
-	uint32_t	l2_key_data[14];
-	/* Flow associated L2 header mask info. */
-	uint32_t	l2_key_mask[14];
-	/* Flow associated L3 header key info. */
-	uint32_t	l3_key_data[16];
-	/* Flow associated L3 header mask info. */
-	uint32_t	l3_key_mask[16];
-	/* Flow associated L4 header key info. */
-	uint64_t	l4_key_data;
-	/* Flow associated L4 header mask info. */
-	uint64_t	l4_key_mask;
-} hwrm_cfa_flow_key_data_t, *phwrm_cfa_flow_key_data_t;
+} hwrm_dbg_crashdump_erase_output_t, *phwrm_dbg_crashdump_erase_output_t;
 
-/**********************
- * hwrm_cfa_flow_info *
- **********************/
+/******************
+ * hwrm_dbg_qcaps *
+ ******************/
 
 
-/* hwrm_cfa_flow_info_input (size:256b/32B) */
+/* hwrm_dbg_qcaps_input (size:192b/24B) */
 
-typedef struct hwrm_cfa_flow_info_input {
+typedef struct hwrm_dbg_qcaps_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -37547,27 +64744,18 @@ typedef struct hwrm_cfa_flow_info_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Flow record index. */
-	uint16_t	flow_handle;
-	/* Max flow handle */
-	#define HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_MAX_MASK	UINT32_C(0xfff)
-	#define HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_MAX_SFT	0
-	/* CNP flow handle */
-	#define HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_CNP_CNT	UINT32_C(0x1000)
-	/* RoCEv1 flow handle */
-	#define HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_ROCEV1_CNT	UINT32_C(0x2000)
-	/* RoCEv2 flow handle */
-	#define HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_ROCEV2_CNT	UINT32_C(0x4000)
-	/* Direction rx = 1 */
-	#define HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_DIR_RX	UINT32_C(0x8000)
+	/*
+	 * Function ID of the function that is being queried.
+	 * 0xFF... (All Fs) if the query is for the requesting
+	 * function.
+	 */
+	uint16_t	fid;
 	uint8_t	unused_0[6];
-	/* This value identifies a set of CFA data structures used for a flow. */
-	uint64_t	ext_flow_handle;
-} hwrm_cfa_flow_info_input_t, *phwrm_cfa_flow_info_input_t;
+} hwrm_dbg_qcaps_input_t, *phwrm_dbg_qcaps_input_t;
 
-/* hwrm_cfa_flow_info_output (size:5632b/704B) */
+/* hwrm_dbg_qcaps_output (size:192b/24B) */
 
-typedef struct hwrm_cfa_flow_info_output {
+typedef struct hwrm_dbg_qcaps_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -37576,58 +64764,50 @@ typedef struct hwrm_cfa_flow_info_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	flags;
-	/* When set to 1, indicates the configuration is the TX flow. */
-	#define HWRM_CFA_FLOW_INFO_OUTPUT_FLAGS_PATH_TX	UINT32_C(0x1)
-	/* When set to 1, indicates the configuration is the RX flow. */
-	#define HWRM_CFA_FLOW_INFO_OUTPUT_FLAGS_PATH_RX	UINT32_C(0x2)
-	/* profile is 8 b */
-	uint8_t	profile;
-	/* src_fid is 16 b */
-	uint16_t	src_fid;
-	/* dst_fid is 16 b */
-	uint16_t	dst_fid;
-	/* l2_ctxt_id is 16 b */
-	uint16_t	l2_ctxt_id;
-	/* em_info is 64 b */
-	uint64_t	em_info;
-	/* tcam_info is 64 b */
-	uint64_t	tcam_info;
-	/* vfp_tcam_info is 64 b */
-	uint64_t	vfp_tcam_info;
-	/* ar_id is 16 b */
-	uint16_t	ar_id;
-	/* flow_handle is 16 b */
-	uint16_t	flow_handle;
-	/* tunnel_handle is 32 b */
-	uint32_t	tunnel_handle;
-	/* The flow aging timer for the flow, the unit is 100 milliseconds */
-	uint16_t	flow_timer;
-	uint8_t	unused_0[6];
-	/* Flow associated L2, L3 and L4 headers info. */
-	uint32_t	flow_key_data[130];
-	/* Flow associated action record info. */
-	uint32_t	flow_action_info[30];
-	uint8_t	unused_1[7];
+	/*
+	 * FID value. This value is used to identify operations on the PCI
+	 * bus as belonging to a particular PCI function.
+	 */
+	uint16_t	fid;
+	uint8_t	unused_0[2];
+	/*
+	 * Bitwise field of components FW supports skipping during collection
+	 * of coredump as part of a crash collection.
+	 */
+	uint32_t	coredump_component_disable_caps;
+	/*
+	 * If 1, FW supports disabling the collection of NVM during a
+	 * coredump taken as part of crash collection.
+	 */
+	#define HWRM_DBG_QCAPS_OUTPUT_COREDUMP_COMPONENT_DISABLE_CAPS_NVRAM	UINT32_C(0x1)
+	uint32_t	flags;
+	/* If 1, FW supports writing a crashdump to NVM. */
+	#define HWRM_DBG_QCAPS_OUTPUT_FLAGS_CRASHDUMP_NVM	UINT32_C(0x1)
+	/* If 1, FW supports writing a crashdump to host ddr. */
+	#define HWRM_DBG_QCAPS_OUTPUT_FLAGS_CRASHDUMP_HOST_DDR	UINT32_C(0x2)
+	/* If 1, FW supports writing a crashdump to soc ddr. */
+	#define HWRM_DBG_QCAPS_OUTPUT_FLAGS_CRASHDUMP_SOC_DDR	UINT32_C(0x4)
+	/* If 1, FW supports USEQ operations */
+	#define HWRM_DBG_QCAPS_OUTPUT_FLAGS_USEQ		UINT32_C(0x8)
+	uint8_t	unused_1[3];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_flow_info_output_t, *phwrm_cfa_flow_info_output_t;
+} hwrm_dbg_qcaps_output_t, *phwrm_dbg_qcaps_output_t;
 
-/***********************
- * hwrm_cfa_flow_flush *
- ***********************/
+/*****************
+ * hwrm_dbg_qcfg *
+ *****************/
 
 
-/* hwrm_cfa_flow_flush_input (size:256b/32B) */
+/* hwrm_dbg_qcfg_input (size:192b/24B) */
 
-typedef struct hwrm_cfa_flow_flush_input {
+typedef struct hwrm_dbg_qcfg_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -37656,86 +64836,41 @@ typedef struct hwrm_cfa_flow_flush_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* flags is 32 b */
-	uint32_t	flags;
-	/*
-	 * Set to 1 to indicate the page size, page layers, and
-	 * flow_handle_table_dma_addr fields are valid. The flow flush
-	 * operation should only flush the flows from the flow table
-	 * specified. This flag is set to 0 by older driver. For older
-	 * firmware, setting this flag has no effect.
-	 */
-	#define HWRM_CFA_FLOW_FLUSH_INPUT_FLAGS_FLOW_TABLE_VALID			UINT32_C(0x1)
-	/*
-	 * Set to 1 to indicate flow flush operation to cleanup all the
-	 * flows, meters, CFA context memory tables etc. This flag is set to
-	 * 0 by older driver. For older firmware, setting this flag has no
-	 * effect.
-	 */
-	#define HWRM_CFA_FLOW_FLUSH_INPUT_FLAGS_FLOW_RESET_ALL			UINT32_C(0x2)
-	/*
-	 * Set to 1 to indicate flow flush operation to cleanup all the
-	 * flows by the caller. This flag is set to 0 by older driver. For
-	 * older firmware, setting this flag has no effect.
-	 */
-	#define HWRM_CFA_FLOW_FLUSH_INPUT_FLAGS_FLOW_RESET_PORT			UINT32_C(0x4)
-	/*
-	 * Set to 1 to indicate the flow counter IDs are included in the
-	 * flow table.
-	 */
-	#define HWRM_CFA_FLOW_FLUSH_INPUT_FLAGS_FLOW_HANDLE_INCL_FC		UINT32_C(0x8000000)
 	/*
-	 * This specifies the size of flow handle entries provided by the
-	 * driver in the flow table specified below. Only two flow handle
-	 * size enums are defined.
+	 * Function ID of the function that is being queried.
+	 * 0xFF... (All Fs) if the query is for the requesting
+	 * function.
 	 */
-	#define HWRM_CFA_FLOW_FLUSH_INPUT_FLAGS_FLOW_HANDLE_ENTRY_SIZE_MASK	UINT32_C(0xc0000000)
-	#define HWRM_CFA_FLOW_FLUSH_INPUT_FLAGS_FLOW_HANDLE_ENTRY_SIZE_SFT	30
-	/* The flow handle is 16bit */
-		#define HWRM_CFA_FLOW_FLUSH_INPUT_FLAGS_FLOW_HANDLE_ENTRY_SIZE_FLOW_HND_16BIT  (UINT32_C(0x0) << 30)
-	/* The flow handle is 64bit */
-		#define HWRM_CFA_FLOW_FLUSH_INPUT_FLAGS_FLOW_HANDLE_ENTRY_SIZE_FLOW_HND_64BIT  (UINT32_C(0x1) << 30)
-		#define HWRM_CFA_FLOW_FLUSH_INPUT_FLAGS_FLOW_HANDLE_ENTRY_SIZE_LAST	HWRM_CFA_FLOW_FLUSH_INPUT_FLAGS_FLOW_HANDLE_ENTRY_SIZE_FLOW_HND_64BIT
-	/* Specify page size of the flow table memory. */
-	uint8_t	page_size;
-	/* The page size is 4K */
-	#define HWRM_CFA_FLOW_FLUSH_INPUT_PAGE_SIZE_4K   UINT32_C(0x0)
-	/* The page size is 8K */
-	#define HWRM_CFA_FLOW_FLUSH_INPUT_PAGE_SIZE_8K   UINT32_C(0x1)
-	/* The page size is 64K */
-	#define HWRM_CFA_FLOW_FLUSH_INPUT_PAGE_SIZE_64K  UINT32_C(0x4)
-	/* The page size is 256K */
-	#define HWRM_CFA_FLOW_FLUSH_INPUT_PAGE_SIZE_256K UINT32_C(0x6)
-	/* The page size is 1M */
-	#define HWRM_CFA_FLOW_FLUSH_INPUT_PAGE_SIZE_1M   UINT32_C(0x8)
-	/* The page size is 2M */
-	#define HWRM_CFA_FLOW_FLUSH_INPUT_PAGE_SIZE_2M   UINT32_C(0x9)
-	/* The page size is 4M */
-	#define HWRM_CFA_FLOW_FLUSH_INPUT_PAGE_SIZE_4M   UINT32_C(0xa)
-	/* The page size is 1G */
-	#define HWRM_CFA_FLOW_FLUSH_INPUT_PAGE_SIZE_1G   UINT32_C(0x12)
-	#define HWRM_CFA_FLOW_FLUSH_INPUT_PAGE_SIZE_LAST HWRM_CFA_FLOW_FLUSH_INPUT_PAGE_SIZE_1G
-	/* FLow table memory indirect levels. */
-	uint8_t	page_level;
-	/* PBL pointer is physical start address. */
-	#define HWRM_CFA_FLOW_FLUSH_INPUT_PAGE_LEVEL_LVL_0 UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-	#define HWRM_CFA_FLOW_FLUSH_INPUT_PAGE_LEVEL_LVL_1 UINT32_C(0x1)
+	uint16_t	fid;
+	uint16_t	flags;
 	/*
-	 * PBL pointer points to PDE table with each entry pointing to PTE
-	 * tables.
+	 * The crashdump size represents size of crashdump
+	 * written to the specified destination.
 	 */
-	#define HWRM_CFA_FLOW_FLUSH_INPUT_PAGE_LEVEL_LVL_2 UINT32_C(0x2)
-	#define HWRM_CFA_FLOW_FLUSH_INPUT_PAGE_LEVEL_LAST HWRM_CFA_FLOW_FLUSH_INPUT_PAGE_LEVEL_LVL_2
-	/* number of flows in the flow table */
-	uint16_t	num_flows;
-	/* Pointer to the PBL, or PDL depending on number of levels */
-	uint64_t	page_dir;
-} hwrm_cfa_flow_flush_input_t, *phwrm_cfa_flow_flush_input_t;
+	#define HWRM_DBG_QCFG_INPUT_FLAGS_CRASHDUMP_SIZE_FOR_DEST_MASK	UINT32_C(0x3)
+	#define HWRM_DBG_QCFG_INPUT_FLAGS_CRASHDUMP_SIZE_FOR_DEST_SFT	0
+	/* crashdump size written to nvm */
+		#define HWRM_DBG_QCFG_INPUT_FLAGS_CRASHDUMP_SIZE_FOR_DEST_DEST_NVM	UINT32_C(0x0)
+	/* crashdump size written to host_ddr */
+		#define HWRM_DBG_QCFG_INPUT_FLAGS_CRASHDUMP_SIZE_FOR_DEST_DEST_HOST_DDR  UINT32_C(0x1)
+	/* crashdump size written to soc_ddr */
+		#define HWRM_DBG_QCFG_INPUT_FLAGS_CRASHDUMP_SIZE_FOR_DEST_DEST_SOC_DDR   UINT32_C(0x2)
+		#define HWRM_DBG_QCFG_INPUT_FLAGS_CRASHDUMP_SIZE_FOR_DEST_LAST	HWRM_DBG_QCFG_INPUT_FLAGS_CRASHDUMP_SIZE_FOR_DEST_DEST_SOC_DDR
+	/*
+	 * Bitwise field of components requested for FW to skip when
+	 * calculating the size of a coredump collection.
+	 */
+	uint32_t	coredump_component_disable_flags;
+	/*
+	 * If 1, NVM will not be collected during a coredump taken as part
+	 * of crash collection.
+	 */
+	#define HWRM_DBG_QCFG_INPUT_COREDUMP_COMPONENT_DISABLE_FLAGS_NVRAM	UINT32_C(0x1)
+} hwrm_dbg_qcfg_input_t, *phwrm_dbg_qcfg_input_t;
 
-/* hwrm_cfa_flow_flush_output (size:128b/16B) */
+/* hwrm_dbg_qcfg_output (size:256b/32B) */
 
-typedef struct hwrm_cfa_flow_flush_output {
+typedef struct hwrm_dbg_qcfg_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -37744,26 +64879,82 @@ typedef struct hwrm_cfa_flow_flush_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	/*
+	 * FID value. This value is used to identify operations on the PCI
+	 * bus as belonging to a particular PCI function.
+	 */
+	uint16_t	fid;
+	uint8_t	unused_0[2];
+	/*
+	 * Size in bytes of a coredump file created by the FW. This takes into
+	 * consideration any components selected in the
+	 * coredump_component_disable_flags field from hwrm_dbg_qcfg_input.
+	 */
+	uint32_t	coredump_size;
+	uint32_t	flags;
+	/*
+	 * If set to 1, then UART logging is enabled for the primary
+	 * firmware. Disabled otherwise.
+	 */
+	#define HWRM_DBG_QCFG_OUTPUT_FLAGS_UART_LOG		UINT32_C(0x1)
+	/*
+	 * If set to 1, then UART logging is enabled for the secondary
+	 * firmware. Disabled otherwise.
+	 */
+	#define HWRM_DBG_QCFG_OUTPUT_FLAGS_UART_LOG_SECONDARY	UINT32_C(0x2)
+	/*
+	 * If set to 1, then completion ring logging is enabled for the
+	 * primary firmware. Disabled otherwise.
+	 */
+	#define HWRM_DBG_QCFG_OUTPUT_FLAGS_FW_TRACE		UINT32_C(0x4)
+	/*
+	 * If set to 1, then completion ring logging is enabled for the
+	 * secondary firmware. Disabled otherwise.
+	 */
+	#define HWRM_DBG_QCFG_OUTPUT_FLAGS_FW_TRACE_SECONDARY	UINT32_C(0x8)
+	/*
+	 * If set to 1, firmware will generate debug_notification async
+	 * events to the driver as applicable.
+	 */
+	#define HWRM_DBG_QCFG_OUTPUT_FLAGS_DEBUG_NOTIFY	UINT32_C(0x10)
+	/*
+	 * If set to 1, firmware is allowed to be unresponsive to heartbeat
+	 * health checks, allowing for JTAG debugging scenarios where the
+	 * debugger has the firmware processes stopped indefinitely. This
+	 * flag has effect only on debug builds of firmware.
+	 */
+	#define HWRM_DBG_QCFG_OUTPUT_FLAGS_JTAG_DEBUG		UINT32_C(0x20)
+	/*
+	 * Notification queue (completion ring) used by the firmware to post
+	 * async debug notifications and fw trace logs. This field is valid
+	 * when fw_trace, fw_trace_secondary or debug_notify flags are set.
+	 */
+	uint16_t	async_cmpl_ring;
+	uint8_t	unused_2[2];
+	/*
+	 * Size in bytes of a crashdump file created by the FW. Uses input
+	 * flags to determine medium destination and corresponding size.
+	 */
+	uint32_t	crashdump_size;
+	uint8_t	unused_3[3];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_flow_flush_output_t, *phwrm_cfa_flow_flush_output_t;
+} hwrm_dbg_qcfg_output_t, *phwrm_dbg_qcfg_output_t;
 
-/***********************
- * hwrm_cfa_flow_stats *
- ***********************/
+/*********************************
+ * hwrm_dbg_crashdump_medium_cfg *
+ *********************************/
 
 
-/* hwrm_cfa_flow_stats_input (size:640b/80B) */
+/* hwrm_dbg_crashdump_medium_cfg_input (size:320b/40B) */
 
-typedef struct hwrm_cfa_flow_stats_input {
+typedef struct hwrm_dbg_crashdump_medium_cfg_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -37792,54 +64983,62 @@ typedef struct hwrm_cfa_flow_stats_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Flow handle. */
-	uint16_t	num_flows;
-	/* Flow handle. */
-	uint16_t	flow_handle_0;
-	/* Flow handle. */
-	uint16_t	flow_handle_1;
-	/* Flow handle. */
-	uint16_t	flow_handle_2;
-	/* Flow handle. */
-	uint16_t	flow_handle_3;
-	/* Flow handle. */
-	uint16_t	flow_handle_4;
-	/* Flow handle. */
-	uint16_t	flow_handle_5;
-	/* Flow handle. */
-	uint16_t	flow_handle_6;
-	/* Flow handle. */
-	uint16_t	flow_handle_7;
-	/* Flow handle. */
-	uint16_t	flow_handle_8;
-	/* Flow handle. */
-	uint16_t	flow_handle_9;
-	uint8_t	unused_0[2];
-	/* Flow ID of a flow. */
-	uint32_t	flow_id_0;
-	/* Flow ID of a flow. */
-	uint32_t	flow_id_1;
-	/* Flow ID of a flow. */
-	uint32_t	flow_id_2;
-	/* Flow ID of a flow. */
-	uint32_t	flow_id_3;
-	/* Flow ID of a flow. */
-	uint32_t	flow_id_4;
-	/* Flow ID of a flow. */
-	uint32_t	flow_id_5;
-	/* Flow ID of a flow. */
-	uint32_t	flow_id_6;
-	/* Flow ID of a flow. */
-	uint32_t	flow_id_7;
-	/* Flow ID of a flow. */
-	uint32_t	flow_id_8;
-	/* Flow ID of a flow. */
-	uint32_t	flow_id_9;
-} hwrm_cfa_flow_stats_input_t, *phwrm_cfa_flow_stats_input_t;
+	uint16_t	output_dest_flags;
+	/* Destination is DDR ram. */
+	#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_TYPE_DDR	UINT32_C(0x1)
+	uint16_t	pg_size_lvl;
+	/* PBL indirect levels. */
+	#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_LVL_MASK	UINT32_C(0x3)
+	#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to
+	 * PTE tables.
+	 */
+		#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_LVL_LVL_2	UINT32_C(0x2)
+		#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_LVL_LAST	HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_LVL_LVL_2
+	/* page size. */
+	#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_PG_SIZE_MASK  UINT32_C(0x1c)
+	#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_PG_SIZE_SFT   2
+	/* 4KB. */
+		#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_PG_SIZE_PG_4K   (UINT32_C(0x0) << 2)
+	/* 8KB. */
+		#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_PG_SIZE_PG_8K   (UINT32_C(0x1) << 2)
+	/* 64KB. */
+		#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_PG_SIZE_PG_64K  (UINT32_C(0x2) << 2)
+	/* 2MB. */
+		#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_PG_SIZE_PG_2M   (UINT32_C(0x3) << 2)
+	/* 8MB. */
+		#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_PG_SIZE_PG_8M   (UINT32_C(0x4) << 2)
+	/* 1GB. */
+		#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_PG_SIZE_PG_1G   (UINT32_C(0x5) << 2)
+		#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_PG_SIZE_LAST   HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_PG_SIZE_PG_1G
+	/* unused11 is 11 b */
+	#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_UNUSED11_MASK UINT32_C(0xffe0)
+	#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_UNUSED11_SFT  5
+	/* Crashdump buffer size. */
+	uint32_t	size;
+	/*
+	 * Bitwise field of components that FW is requested to skip during
+	 * coredump as part of a crash collection.
+	 */
+	uint32_t	coredump_component_disable_flags;
+	/*
+	 * If 1, then NVM will not be collected during a coredump taken as
+	 * part of crash collection.
+	 */
+	#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_NVRAM	UINT32_C(0x1)
+	uint32_t	unused_0;
+	/* Crashdump buffer PBL physical address. */
+	uint64_t	pbl;
+} hwrm_dbg_crashdump_medium_cfg_input_t, *phwrm_dbg_crashdump_medium_cfg_input_t;
 
-/* hwrm_cfa_flow_stats_output (size:1408b/176B) */
+/* hwrm_dbg_crashdump_medium_cfg_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_flow_stats_output {
+typedef struct hwrm_dbg_crashdump_medium_cfg_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -37848,66 +65047,58 @@ typedef struct hwrm_cfa_flow_stats_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* packet_0 is 64 b */
-	uint64_t	packet_0;
-	/* packet_1 is 64 b */
-	uint64_t	packet_1;
-	/* packet_2 is 64 b */
-	uint64_t	packet_2;
-	/* packet_3 is 64 b */
-	uint64_t	packet_3;
-	/* packet_4 is 64 b */
-	uint64_t	packet_4;
-	/* packet_5 is 64 b */
-	uint64_t	packet_5;
-	/* packet_6 is 64 b */
-	uint64_t	packet_6;
-	/* packet_7 is 64 b */
-	uint64_t	packet_7;
-	/* packet_8 is 64 b */
-	uint64_t	packet_8;
-	/* packet_9 is 64 b */
-	uint64_t	packet_9;
-	/* byte_0 is 64 b */
-	uint64_t	byte_0;
-	/* byte_1 is 64 b */
-	uint64_t	byte_1;
-	/* byte_2 is 64 b */
-	uint64_t	byte_2;
-	/* byte_3 is 64 b */
-	uint64_t	byte_3;
-	/* byte_4 is 64 b */
-	uint64_t	byte_4;
-	/* byte_5 is 64 b */
-	uint64_t	byte_5;
-	/* byte_6 is 64 b */
-	uint64_t	byte_6;
-	/* byte_7 is 64 b */
-	uint64_t	byte_7;
-	/* byte_8 is 64 b */
-	uint64_t	byte_8;
-	/* byte_9 is 64 b */
-	uint64_t	byte_9;
-	uint8_t	unused_0[7];
+	uint8_t	unused_1[7];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_flow_stats_output_t, *phwrm_cfa_flow_stats_output_t;
+} hwrm_dbg_crashdump_medium_cfg_output_t, *phwrm_dbg_crashdump_medium_cfg_output_t;
 
-/***********************************
- * hwrm_cfa_flow_aging_timer_reset *
- ***********************************/
+/* coredump_segment_record (size:128b/16B) */
+
+typedef struct coredump_segment_record {
+	/* Component id of the returned component. */
+	uint16_t	component_id;
+	/* Segment id of the returned component. */
+	uint16_t	segment_id;
+	/* Not used. */
+	uint16_t	max_instances;
+	/* Major version. */
+	uint8_t	version_hi;
+	/* Minor version. */
+	uint8_t	version_low;
+	/*
+	 * bit 0: live data
+	 * bit 1: crashed data
+	 */
+	uint8_t	seg_flags;
+	/* This field is used to indicate the segment is compressed. */
+	uint8_t	compress_flags;
+	/*
+	 * SFLAG_COMPRESSED_ZLIB indicates that the segment data is
+	 * compressed.
+	 */
+	#define SFLAG_COMPRESSED_ZLIB	UINT32_C(0x1)
+	uint8_t	unused_0[2];
+	/*
+	 * This field is the length of the segment data. It will be zero if
+	 * the firmware does not support returning the segment data length.
+	 */
+	uint32_t	segment_len;
+} coredump_segment_record_t, *pcoredump_segment_record_t;
+
+/**************************
+ * hwrm_dbg_coredump_list *
+ **************************/
 
 
-/* hwrm_cfa_flow_aging_timer_reset_input (size:256b/32B) */
+/* hwrm_dbg_coredump_list_input (size:256b/32B) */
 
-typedef struct hwrm_cfa_flow_aging_timer_reset_input {
+typedef struct hwrm_dbg_coredump_list_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -37936,21 +65127,28 @@ typedef struct hwrm_cfa_flow_aging_timer_reset_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Flow record index. */
-	uint16_t	flow_handle;
-	uint8_t	unused_0[2];
 	/*
-	 * New flow timer value for the flow specified in the ext_flow_handle.
-	 * The flow timer unit is 100ms.
+	 * host address where the data content will be written
+	 * when the request is complete. This area must be 16B aligned.
 	 */
-	uint32_t	flow_timer;
-	/* This value identifies a set of CFA data structures used for a flow. */
-	uint64_t	ext_flow_handle;
-} hwrm_cfa_flow_aging_timer_reset_input_t, *phwrm_cfa_flow_aging_timer_reset_input_t;
+	uint64_t	host_dest_addr;
+	/* Length of host buffer used for transferring debug data. */
+	uint32_t	host_buf_len;
+	/* Sequence number of the request. Starts at 0. */
+	uint16_t	seq_no;
+	/*  */
+	uint8_t	flags;
+	/*
+	 * If set to 1, crash dump is requested.
+	 * If set to 0, both live core and crash dump are requested.
+	 */
+	#define HWRM_DBG_COREDUMP_LIST_INPUT_FLAGS_CRASHDUMP	UINT32_C(0x1)
+	uint8_t	unused_0[1];
+} hwrm_dbg_coredump_list_input_t, *phwrm_dbg_coredump_list_input_t;
 
-/* hwrm_cfa_flow_aging_timer_reset_output (size:128b/16B) */
+/* hwrm_dbg_coredump_list_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_flow_aging_timer_reset_output {
+typedef struct hwrm_dbg_coredump_list_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -37959,26 +65157,36 @@ typedef struct hwrm_cfa_flow_aging_timer_reset_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	uint8_t	flags;
+	/*
+	 * Value of 1 means that there is more data available.
+	 * Issue the request again with the next sequence number.
+	 */
+	#define HWRM_DBG_COREDUMP_LIST_OUTPUT_FLAGS_MORE	UINT32_C(0x1)
+	uint8_t	unused_0;
+	/* Total number of segments to be returned. */
+	uint16_t	total_segments;
+	/* Actual length of data returned in bytes. */
+	uint16_t	data_len;
+	uint8_t	unused_1;
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_flow_aging_timer_reset_output_t, *phwrm_cfa_flow_aging_timer_reset_output_t;
+} hwrm_dbg_coredump_list_output_t, *phwrm_dbg_coredump_list_output_t;
 
-/***************************
- * hwrm_cfa_flow_aging_cfg *
- ***************************/
+/******************************
+ * hwrm_dbg_coredump_initiate *
+ ******************************/
 
 
-/* hwrm_cfa_flow_aging_cfg_input (size:384b/48B) */
+/* hwrm_dbg_coredump_initiate_input (size:256b/32B) */
 
-typedef struct hwrm_cfa_flow_aging_cfg_input {
+typedef struct hwrm_dbg_coredump_initiate_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -38007,109 +65215,26 @@ typedef struct hwrm_cfa_flow_aging_cfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* The bit field to enable per flow aging configuration. */
-	uint16_t	enables;
-	/*
-	 * This bit must be '1' for the tcp flow timer field to be
-	 * configured
-	 */
-	#define HWRM_CFA_FLOW_AGING_CFG_INPUT_ENABLES_TCP_FLOW_TIMER	UINT32_C(0x1)
-	/*
-	 * This bit must be '1' for the tcp finish timer field to be
-	 * configured
-	 */
-	#define HWRM_CFA_FLOW_AGING_CFG_INPUT_ENABLES_TCP_FIN_TIMER	UINT32_C(0x2)
-	/*
-	 * This bit must be '1' for the udp flow timer field to be
-	 * configured
-	 */
-	#define HWRM_CFA_FLOW_AGING_CFG_INPUT_ENABLES_UDP_FLOW_TIMER	UINT32_C(0x4)
-	/*
-	 * This bit must be '1' for the eem dma interval field to be
-	 * configured
-	 */
-	#define HWRM_CFA_FLOW_AGING_CFG_INPUT_ENABLES_EEM_DMA_INTERVAL	UINT32_C(0x8)
-	/*
-	 * This bit must be '1' for the eem notice interval field to be
-	 * configured
-	 */
-	#define HWRM_CFA_FLOW_AGING_CFG_INPUT_ENABLES_EEM_NOTICE_INTERVAL	UINT32_C(0x10)
-	/*
-	 * This bit must be '1' for the eem context memory maximum entries
-	 * field to be configured
-	 */
-	#define HWRM_CFA_FLOW_AGING_CFG_INPUT_ENABLES_EEM_CTX_MAX_ENTRIES	UINT32_C(0x20)
-	/*
-	 * This bit must be '1' for the eem context memory ID field to be
-	 * configured
-	 */
-	#define HWRM_CFA_FLOW_AGING_CFG_INPUT_ENABLES_EEM_CTX_ID		UINT32_C(0x40)
-	/*
-	 * This bit must be '1' for the eem context memory type field to be
-	 * configured
-	 */
-	#define HWRM_CFA_FLOW_AGING_CFG_INPUT_ENABLES_EEM_CTX_MEM_TYPE	UINT32_C(0x80)
-	uint8_t	flags;
-	/* Enumeration denoting the RX, TX type of the resource. */
-	#define HWRM_CFA_FLOW_AGING_CFG_INPUT_FLAGS_PATH	UINT32_C(0x1)
-	/* tx path */
-		#define HWRM_CFA_FLOW_AGING_CFG_INPUT_FLAGS_PATH_TX	UINT32_C(0x0)
-	/* rx path */
-		#define HWRM_CFA_FLOW_AGING_CFG_INPUT_FLAGS_PATH_RX	UINT32_C(0x1)
-		#define HWRM_CFA_FLOW_AGING_CFG_INPUT_FLAGS_PATH_LAST   HWRM_CFA_FLOW_AGING_CFG_INPUT_FLAGS_PATH_RX
-	/*
-	 * Enumeration denoting the enable, disable eem flow aging
-	 * configuration.
-	 */
-	#define HWRM_CFA_FLOW_AGING_CFG_INPUT_FLAGS_EEM	UINT32_C(0x2)
-	/* tx path */
-		#define HWRM_CFA_FLOW_AGING_CFG_INPUT_FLAGS_EEM_DISABLE  (UINT32_C(0x0) << 1)
-	/* rx path */
-		#define HWRM_CFA_FLOW_AGING_CFG_INPUT_FLAGS_EEM_ENABLE   (UINT32_C(0x1) << 1)
-		#define HWRM_CFA_FLOW_AGING_CFG_INPUT_FLAGS_EEM_LAST	HWRM_CFA_FLOW_AGING_CFG_INPUT_FLAGS_EEM_ENABLE
-	uint8_t	unused_0;
-	/*
-	 * The flow aging timer for all TCP flows, the unit is 100
-	 * milliseconds.
-	 */
-	uint32_t	tcp_flow_timer;
-	/*
-	 * The TCP finished timer for all TCP flows, the unit is 100
-	 * milliseconds.
-	 */
-	uint32_t	tcp_fin_timer;
-	/*
-	 * The flow aging timer for all UDP flows, the unit is 100
-	 * milliseconds.
-	 */
-	uint32_t	udp_flow_timer;
-	/*
-	 * The interval to dma eem ejection data to host memory, the unit is
-	 * milliseconds.
-	 */
-	uint16_t	eem_dma_interval;
-	/*
-	 * The interval to notify driver to read the eem ejection data, the
-	 * unit is milliseconds.
-	 */
-	uint16_t	eem_notice_interval;
-	/* The maximum entries number in the eem context memory. */
-	uint32_t	eem_ctx_max_entries;
-	/* The context memory ID for eem flow aging. */
-	uint16_t	eem_ctx_id;
-	uint16_t	eem_ctx_mem_type;
+	/* Component id of the returned component. */
+	uint16_t	component_id;
+	/* Segment id of the returned component. */
+	uint16_t	segment_id;
+	/* Not used. */
+	uint16_t	instance;
+	/* Not used. */
+	uint16_t	unused_0;
 	/*
-	 * The content of context memory is eem ejection data, the size of
-	 * each entry is 4 bytes.
+	 * bit 0: live data
+	 * bit 1: crashed data
 	 */
-	#define HWRM_CFA_FLOW_AGING_CFG_INPUT_EEM_CTX_MEM_TYPE_EJECTION_DATA UINT32_C(0x0)
-	#define HWRM_CFA_FLOW_AGING_CFG_INPUT_EEM_CTX_MEM_TYPE_LAST	HWRM_CFA_FLOW_AGING_CFG_INPUT_EEM_CTX_MEM_TYPE_EJECTION_DATA
-	uint8_t	unused_1[4];
-} hwrm_cfa_flow_aging_cfg_input_t, *phwrm_cfa_flow_aging_cfg_input_t;
+	uint8_t	seg_flags;
+	/* Not used. */
+	uint8_t	unused_1[7];
+} hwrm_dbg_coredump_initiate_input_t, *phwrm_dbg_coredump_initiate_input_t;
 
-/* hwrm_cfa_flow_aging_cfg_output (size:128b/16B) */
+/* hwrm_dbg_coredump_initiate_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_flow_aging_cfg_output {
+typedef struct hwrm_dbg_coredump_initiate_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -38122,22 +65247,43 @@ typedef struct hwrm_cfa_flow_aging_cfg_output {
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_flow_aging_cfg_output_t, *phwrm_cfa_flow_aging_cfg_output_t;
+} hwrm_dbg_coredump_initiate_output_t, *phwrm_dbg_coredump_initiate_output_t;
 
-/****************************
- * hwrm_cfa_flow_aging_qcfg *
- ****************************/
+/* coredump_data_hdr (size:128b/16B) */
+
+typedef struct coredump_data_hdr {
+	/* Starting address of the register range. */
+	uint32_t	address;
+	/*
+	 * length: 0 - 23 bits represents the actual data without the pad.
+	 * flags: 24 - 31 bits represents indirect register ranges.
+	 *   - bit 24: Set if registers in this segment are indirect accessed.
+	 */
+	uint32_t	flags_length;
+	/* These bits represents the actual length of the data segment */
+	#define COREDUMP_DATA_HDR_FLAGS_LENGTH_ACTUAL_LEN_MASK	UINT32_C(0xffffff)
+	#define COREDUMP_DATA_HDR_FLAGS_LENGTH_ACTUAL_LEN_SFT	0
+	/* Set if registers in this segment are indirect accessed. */
+	#define COREDUMP_DATA_HDR_FLAGS_LENGTH_INDIRECT_ACCESS	UINT32_C(0x1000000)
+	/* Value in the partner register for indirect or multi-field registers. */
+	uint32_t	instance;
+	/* Starting address of the next register after the current data range */
+	uint32_t	next_offset;
+} coredump_data_hdr_t, *pcoredump_data_hdr_t;
+
+/******************************
+ * hwrm_dbg_coredump_retrieve *
+ ******************************/
 
 
-/* hwrm_cfa_flow_aging_qcfg_input (size:192b/24B) */
+/* hwrm_dbg_coredump_retrieve_input (size:448b/56B) */
 
-typedef struct hwrm_cfa_flow_aging_qcfg_input {
+typedef struct hwrm_dbg_coredump_retrieve_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -38167,23 +65313,39 @@ typedef struct hwrm_cfa_flow_aging_qcfg_input {
 	 */
 	uint64_t	resp_addr;
 	/*
-	 * The direction for the flow aging configuration, 1 is rx path, 2 is
-	 * tx path.
+	 * host address where the data content will be written
+	 * when the request is complete. This area must be 16B aligned.
+	 */
+	uint64_t	host_dest_addr;
+	/* Length of host buffer used for transferring debug data. */
+	uint32_t	host_buf_len;
+	/* Not used. */
+	uint32_t	unused_0;
+	/* Component id of the returned component. */
+	uint16_t	component_id;
+	/* Segment id of the returned component. */
+	uint16_t	segment_id;
+	/* Not used. */
+	uint16_t	instance;
+	/* Not used. */
+	uint16_t	unused_1;
+	/*
+	 * bit 0: live data
+	 * bit 1: crashed data
 	 */
-	uint8_t	flags;
-	/* Enumeration denoting the RX, TX type of the resource. */
-	#define HWRM_CFA_FLOW_AGING_QCFG_INPUT_FLAGS_PATH	UINT32_C(0x1)
-	/* tx path */
-		#define HWRM_CFA_FLOW_AGING_QCFG_INPUT_FLAGS_PATH_TX	UINT32_C(0x0)
-	/* rx path */
-		#define HWRM_CFA_FLOW_AGING_QCFG_INPUT_FLAGS_PATH_RX	UINT32_C(0x1)
-		#define HWRM_CFA_FLOW_AGING_QCFG_INPUT_FLAGS_PATH_LAST HWRM_CFA_FLOW_AGING_QCFG_INPUT_FLAGS_PATH_RX
-	uint8_t	unused_0[7];
-} hwrm_cfa_flow_aging_qcfg_input_t, *phwrm_cfa_flow_aging_qcfg_input_t;
+	uint8_t	seg_flags;
+	uint8_t	unused_2;
+	uint16_t	unused_3;
+	/* Not used. */
+	uint32_t	unused_4;
+	/* Sequence number is used per segment request. Starts at 0. */
+	uint32_t	seq_no;
+	uint32_t	unused_5;
+} hwrm_dbg_coredump_retrieve_input_t, *phwrm_dbg_coredump_retrieve_input_t;
 
-/* hwrm_cfa_flow_aging_qcfg_output (size:320b/40B) */
+/* hwrm_dbg_coredump_retrieve_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_flow_aging_qcfg_output {
+typedef struct hwrm_dbg_coredump_retrieve_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -38192,57 +65354,34 @@ typedef struct hwrm_cfa_flow_aging_qcfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
+	uint8_t	flags;
 	/*
-	 * The current flow aging timer for all TCP flows, the unit is 100
-	 * millisecond.
-	 */
-	uint32_t	tcp_flow_timer;
-	/*
-	 * The current TCP finished timer for all TCP flows, the unit is 100
-	 * millisecond.
-	 */
-	uint32_t	tcp_fin_timer;
-	/*
-	 * The current flow aging timer for all UDP flows, the unit is 100
-	 * millisecond.
-	 */
-	uint32_t	udp_flow_timer;
-	/*
-	 * The interval to dma eem ejection data to host memory, the unit is
-	 * milliseconds.
-	 */
-	uint16_t	eem_dma_interval;
-	/*
-	 * The interval to notify driver to read the eem ejection data, the
-	 * unit is milliseconds.
+	 * Value of 1 means that there is more data available.
+	 * Issue the request again with the next sequence number.
 	 */
-	uint16_t	eem_notice_interval;
-	/* The maximum entries number in the eem context memory. */
-	uint32_t	eem_ctx_max_entries;
-	/* The context memory ID for eem flow aging. */
-	uint16_t	eem_ctx_id;
-	/* The context memory type for eem flow aging. */
-	uint16_t	eem_ctx_mem_type;
-	uint8_t	unused_0[7];
+	#define HWRM_DBG_COREDUMP_RETRIEVE_OUTPUT_FLAGS_MORE	UINT32_C(0x1)
+	uint8_t	unused_0;
+	/* Actual length of data returned in bytes. */
+	uint16_t	data_len;
+	uint8_t	unused_1[3];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_flow_aging_qcfg_output_t, *phwrm_cfa_flow_aging_qcfg_output_t;
+} hwrm_dbg_coredump_retrieve_output_t, *phwrm_dbg_coredump_retrieve_output_t;
 
-/*****************************
- * hwrm_cfa_flow_aging_qcaps *
- *****************************/
+/********************
+ * hwrm_dbg_i2c_cmd *
+ ********************/
 
 
-/* hwrm_cfa_flow_aging_qcaps_input (size:192b/24B) */
+/* hwrm_dbg_i2c_cmd_input (size:320b/40B) */
 
-typedef struct hwrm_cfa_flow_aging_qcaps_input {
+typedef struct hwrm_dbg_i2c_cmd_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -38272,23 +65411,55 @@ typedef struct hwrm_cfa_flow_aging_qcaps_input {
 	 */
 	uint64_t	resp_addr;
 	/*
-	 * The direction for the flow aging configuration, 1 is rx path, 2 is
-	 * tx path.
+	 * host address where the data content will be read or written.
+	 * For master write, data content will be read from host memory and
+	 * write to i2c slave. (size defined by write_size)
+	 * For master read, data content will be read from i2c slave and write
+	 * to the host memory. (size defined by read_size)
+	 * For master write/read, data content will be first read from host
+	 * memory and write to i2c slave. (size defined by write_size) then
+	 * data read from i2c slave will be written back to the same host
+	 * memory. (size defined by read_size)
 	 */
-	uint8_t	flags;
-	/* Enumeration denoting the RX, TX type of the resource. */
-	#define HWRM_CFA_FLOW_AGING_QCAPS_INPUT_FLAGS_PATH	UINT32_C(0x1)
-	/* tx path */
-		#define HWRM_CFA_FLOW_AGING_QCAPS_INPUT_FLAGS_PATH_TX	UINT32_C(0x0)
-	/* rx path */
-		#define HWRM_CFA_FLOW_AGING_QCAPS_INPUT_FLAGS_PATH_RX	UINT32_C(0x1)
-		#define HWRM_CFA_FLOW_AGING_QCAPS_INPUT_FLAGS_PATH_LAST HWRM_CFA_FLOW_AGING_QCAPS_INPUT_FLAGS_PATH_RX
-	uint8_t	unused_0[7];
-} hwrm_cfa_flow_aging_qcaps_input_t, *phwrm_cfa_flow_aging_qcaps_input_t;
+	uint64_t	host_dest_addr;
+	/* read size in bytes, valid only for master read and write/read */
+	uint16_t	read_size;
+	/* write size in bytes, valid only for master write and write/read */
+	uint16_t	write_size;
+	/*
+	 * instance of i2c channel for this operation. Valid if multiple
+	 * instances
+	 * of i2c channels are connected to external i2c devices.
+	 */
+	uint8_t	chnl_id;
+	uint8_t	options;
+	/*
+	 * This bit must be '1' for 10-bit i2c addressing,
+	 * 7-bit addressing otherwise.
+	 */
+	#define HWRM_DBG_I2C_CMD_INPUT_OPTIONS_10_BIT_ADDRESSING	UINT32_C(0x1)
+	/*
+	 * This bit must be '1' for 400 kbit/s, 100 kbit/s
+	 * otherwise.
+	 */
+	#define HWRM_DBG_I2C_CMD_INPUT_OPTIONS_FAST_MODE		UINT32_C(0x2)
+	/* I2C slave address. */
+	uint16_t	slave_addr;
+	/* I2C transfer mode. */
+	uint8_t	xfer_mode;
+	/* read data from slave device */
+	#define HWRM_DBG_I2C_CMD_INPUT_XFER_MODE_MASTER_READ	UINT32_C(0x0)
+	/* write data to slave device */
+	#define HWRM_DBG_I2C_CMD_INPUT_XFER_MODE_MASTER_WRITE	UINT32_C(0x1)
+	/* write follow by read data from slave device */
+	#define HWRM_DBG_I2C_CMD_INPUT_XFER_MODE_MASTER_WRITE_READ UINT32_C(0x2)
+	#define HWRM_DBG_I2C_CMD_INPUT_XFER_MODE_LAST		HWRM_DBG_I2C_CMD_INPUT_XFER_MODE_MASTER_WRITE_READ
+	uint8_t	unused_1[7];
+} hwrm_dbg_i2c_cmd_input_t, *phwrm_dbg_i2c_cmd_input_t;
 
-/* hwrm_cfa_flow_aging_qcaps_output (size:256b/32B) */
+/* hwrm_dbg_i2c_cmd_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_flow_aging_qcaps_output {
+typedef struct hwrm_dbg_i2c_cmd_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -38297,43 +65468,25 @@ typedef struct hwrm_cfa_flow_aging_qcaps_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/*
-	 * The maximum flow aging timer for all TCP flows, the unit is 100
-	 * millisecond.
-	 */
-	uint32_t	max_tcp_flow_timer;
-	/*
-	 * The maximum TCP finished timer for all TCP flows, the unit is 100
-	 * millisecond.
-	 */
-	uint32_t	max_tcp_fin_timer;
-	/*
-	 * The maximum flow aging timer for all UDP flows, the unit is 100
-	 * millisecond.
-	 */
-	uint32_t	max_udp_flow_timer;
-	/* The maximum aging flows that HW can support. */
-	uint32_t	max_aging_flows;
 	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_flow_aging_qcaps_output_t, *phwrm_cfa_flow_aging_qcaps_output_t;
+} hwrm_dbg_i2c_cmd_output_t, *phwrm_dbg_i2c_cmd_output_t;
 
-/**********************************
- * hwrm_cfa_tcp_flag_process_qcfg *
- **********************************/
+/*******************
+ * hwrm_dbg_fw_cli *
+ *******************/
 
 
-/* hwrm_cfa_tcp_flag_process_qcfg_input (size:128b/16B) */
+/* hwrm_dbg_fw_cli_input (size:1024b/128B) */
 
-typedef struct hwrm_cfa_tcp_flag_process_qcfg_input {
+typedef struct hwrm_dbg_fw_cli_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -38362,11 +65515,23 @@ typedef struct hwrm_cfa_tcp_flag_process_qcfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-} hwrm_cfa_tcp_flag_process_qcfg_input_t, *phwrm_cfa_tcp_flag_process_qcfg_input_t;
+	/*
+	 * Address of the host buffer where debug CLI data
+	 * is requested to be dumped.
+	 */
+	uint64_t	host_dest_addr;
+	/* Length of host buffer used for transferring debug data. */
+	uint32_t	host_buf_len;
+	/* Length of CLI command. */
+	uint16_t	cli_cmd_len;
+	uint8_t	unused_0[2];
+	/* CLI command string, a single ASCII encoded null terminated string. */
+	uint8_t	cli_cmd[96];
+} hwrm_dbg_fw_cli_input_t, *phwrm_dbg_fw_cli_input_t;
 
-/* hwrm_cfa_tcp_flag_process_qcfg_output (size:192b/24B) */
+/* hwrm_dbg_fw_cli_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_tcp_flag_process_qcfg_output {
+typedef struct hwrm_dbg_fw_cli_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -38375,40 +65540,27 @@ typedef struct hwrm_cfa_tcp_flag_process_qcfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* The port 0 RX mirror action record ID. */
-	uint16_t	rx_ar_id_port0;
-	/* The port 1 RX mirror action record ID. */
-	uint16_t	rx_ar_id_port1;
-	/*
-	 * The port 0 RX action record ID for TX TCP flag packets from
-	 * loopback path.
-	 */
-	uint16_t	tx_ar_id_port0;
-	/*
-	 * The port 1 RX action record ID for TX TCP flag packets from
-	 * loopback path.
-	 */
-	uint16_t	tx_ar_id_port1;
-	uint8_t	unused_0[7];
+	/* Size of debug CLI data returned in bytes. */
+	uint32_t	cli_data_len;
+	uint8_t	unused_0[3];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_tcp_flag_process_qcfg_output_t, *phwrm_cfa_tcp_flag_process_qcfg_output_t;
+} hwrm_dbg_fw_cli_output_t, *phwrm_dbg_fw_cli_output_t;
 
 /**************************
- * hwrm_cfa_vf_pair_alloc *
+ * hwrm_dbg_ring_info_get *
  **************************/
 
 
-/* hwrm_cfa_vf_pair_alloc_input (size:448b/56B) */
+/* hwrm_dbg_ring_info_get_input (size:192b/24B) */
 
-typedef struct hwrm_cfa_vf_pair_alloc_input {
+typedef struct hwrm_dbg_ring_info_get_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -38437,18 +65589,25 @@ typedef struct hwrm_cfa_vf_pair_alloc_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Logical VF number (range: 0 -> MAX_VFS -1). */
-	uint16_t	vf_a_id;
-	/* Logical VF number (range: 0 -> MAX_VFS -1). */
-	uint16_t	vf_b_id;
-	uint8_t	unused_0[4];
-	/* VF Pair name (32 byte string). */
-	char	pair_name[32];
-} hwrm_cfa_vf_pair_alloc_input_t, *phwrm_cfa_vf_pair_alloc_input_t;
+	/* Ring Type. */
+	uint8_t	ring_type;
+	/* L2 Completion Ring (CR) */
+	#define HWRM_DBG_RING_INFO_GET_INPUT_RING_TYPE_L2_CMPL UINT32_C(0x0)
+	/* TX Ring (TR) */
+	#define HWRM_DBG_RING_INFO_GET_INPUT_RING_TYPE_TX	UINT32_C(0x1)
+	/* RX Ring (RR) */
+	#define HWRM_DBG_RING_INFO_GET_INPUT_RING_TYPE_RX	UINT32_C(0x2)
+	/* Notification Queue (NQ) */
+	#define HWRM_DBG_RING_INFO_GET_INPUT_RING_TYPE_NQ	UINT32_C(0x3)
+	#define HWRM_DBG_RING_INFO_GET_INPUT_RING_TYPE_LAST   HWRM_DBG_RING_INFO_GET_INPUT_RING_TYPE_NQ
+	uint8_t	unused_0[3];
+	/* Firmware ring ID associated with ring being queried. */
+	uint32_t	fw_ring_id;
+} hwrm_dbg_ring_info_get_input_t, *phwrm_dbg_ring_info_get_input_t;
 
-/* hwrm_cfa_vf_pair_alloc_output (size:128b/16B) */
+/* hwrm_dbg_ring_info_get_output (size:192b/24B) */
 
-typedef struct hwrm_cfa_vf_pair_alloc_output {
+typedef struct hwrm_dbg_ring_info_get_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -38457,26 +65616,40 @@ typedef struct hwrm_cfa_vf_pair_alloc_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	/* Producer index for the queried ring. */
+	uint32_t	producer_index;
+	/* Consumer index for the queried ring. */
+	uint32_t	consumer_index;
+	/*
+	 * CAG Vector Control for the queried NQ ring.
+	 * Not valid for other ring types.
+	 */
+	uint32_t	cag_vector_ctrl;
+	/*
+	 * Steering Tag. The current value of the steering tag for the ring.
+	 * The steering tag is only valid if it is advertised by Firmware in
+	 * flags_ext2.steering_tag_supported of hwrm_func_qcaps response.
+	 */
+	uint16_t	st_tag;
+	uint8_t	unused_0;
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_vf_pair_alloc_output_t, *phwrm_cfa_vf_pair_alloc_output_t;
+} hwrm_dbg_ring_info_get_output_t, *phwrm_dbg_ring_info_get_output_t;
 
-/*************************
- * hwrm_cfa_vf_pair_free *
- *************************/
+/**********************
+ * hwrm_dbg_drv_trace *
+ **********************/
 
 
-/* hwrm_cfa_vf_pair_free_input (size:384b/48B) */
+/* hwrm_dbg_drv_trace_input (size:1024b/128B) */
 
-typedef struct hwrm_cfa_vf_pair_free_input {
+typedef struct hwrm_dbg_drv_trace_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -38505,13 +65678,32 @@ typedef struct hwrm_cfa_vf_pair_free_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* VF Pair name (32 byte string). */
-	char	pair_name[32];
-} hwrm_cfa_vf_pair_free_input_t, *phwrm_cfa_vf_pair_free_input_t;
+	/* Severity of the message. */
+	uint8_t	severity;
+	/* Fatal */
+	#define HWRM_DBG_DRV_TRACE_INPUT_SEVERITY_TRACE_LEVEL_FATAL   UINT32_C(0x0)
+	/* Error */
+	#define HWRM_DBG_DRV_TRACE_INPUT_SEVERITY_TRACE_LEVEL_ERROR   UINT32_C(0x1)
+	/* Warning */
+	#define HWRM_DBG_DRV_TRACE_INPUT_SEVERITY_TRACE_LEVEL_WARNING UINT32_C(0x2)
+	/* Info */
+	#define HWRM_DBG_DRV_TRACE_INPUT_SEVERITY_TRACE_LEVEL_INFO	UINT32_C(0x3)
+	/* Debug */
+	#define HWRM_DBG_DRV_TRACE_INPUT_SEVERITY_TRACE_LEVEL_DEBUG   UINT32_C(0x4)
+	#define HWRM_DBG_DRV_TRACE_INPUT_SEVERITY_LAST		HWRM_DBG_DRV_TRACE_INPUT_SEVERITY_TRACE_LEVEL_DEBUG
+	/* Number of bytes to write including terminating 'NULL' if any. */
+	uint8_t	write_len;
+	uint8_t	unused_0[6];
+	/*
+	 * This field represents the debug data sent by driver
+	 * ASCII chars, 'NULL' termination not required.
+	 */
+	char	trace_data[104];
+} hwrm_dbg_drv_trace_input_t, *phwrm_dbg_drv_trace_input_t;
 
-/* hwrm_cfa_vf_pair_free_output (size:128b/16B) */
+/* hwrm_dbg_drv_trace_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_vf_pair_free_output {
+typedef struct hwrm_dbg_drv_trace_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -38524,22 +65716,21 @@ typedef struct hwrm_cfa_vf_pair_free_output {
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_vf_pair_free_output_t, *phwrm_cfa_vf_pair_free_output_t;
+} hwrm_dbg_drv_trace_output_t, *phwrm_dbg_drv_trace_output_t;
 
-/*************************
- * hwrm_cfa_vf_pair_info *
- *************************/
+/***********************
+ * hwrm_dbg_useq_alloc *
+ ***********************/
 
 
-/* hwrm_cfa_vf_pair_info_input (size:448b/56B) */
+/* hwrm_dbg_useq_alloc_input (size:192b/24B) */
 
-typedef struct hwrm_cfa_vf_pair_info_input {
+typedef struct hwrm_dbg_useq_alloc_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -38568,19 +65759,23 @@ typedef struct hwrm_cfa_vf_pair_info_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	flags;
-	/* If this flag is set, lookup by name else lookup by index. */
-	#define HWRM_CFA_VF_PAIR_INFO_INPUT_FLAGS_LOOKUP_TYPE	UINT32_C(0x1)
-	/* vf pair table index. */
-	uint16_t	vf_pair_index;
-	uint8_t	unused_0[2];
-	/* VF Pair name (32 byte string). */
-	char	vf_pair_name[32];
-} hwrm_cfa_vf_pair_info_input_t, *phwrm_cfa_vf_pair_info_input_t;
+	/*
+	 * Number size of the allocation, in bytes, for the USEQ in the code
+	 * words array
+	 */
+	uint32_t	size;
+	/*
+	 * Number of bytes executing the USEQ will produce. Must be a multiple
+	 * of 4
+	 */
+	uint16_t	output_bytes;
+	/* This field is reserved */
+	uint16_t	unused_0;
+} hwrm_dbg_useq_alloc_input_t, *phwrm_dbg_useq_alloc_input_t;
 
-/* hwrm_cfa_vf_pair_info_output (size:512b/64B) */
+/* hwrm_dbg_useq_alloc_output (size:256b/32B) */
 
-typedef struct hwrm_cfa_vf_pair_info_output {
+typedef struct hwrm_dbg_useq_alloc_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -38589,46 +65784,45 @@ typedef struct hwrm_cfa_vf_pair_info_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* vf pair table index. */
-	uint16_t	next_vf_pair_index;
-	/* vf pair member a's vf_fid. */
-	uint16_t	vf_a_fid;
-	/* vf pair member a's Linux logical VF number. */
-	uint16_t	vf_a_index;
-	/* vf pair member b's vf_fid. */
-	uint16_t	vf_b_fid;
-	/* vf pair member a's Linux logical VF number. */
-	uint16_t	vf_b_index;
-	/* vf pair state. */
-	uint8_t	pair_state;
-	/* Pair has been allocated */
-	#define HWRM_CFA_VF_PAIR_INFO_OUTPUT_PAIR_STATE_ALLOCATED UINT32_C(0x1)
-	/* Both pair members are active */
-	#define HWRM_CFA_VF_PAIR_INFO_OUTPUT_PAIR_STATE_ACTIVE	UINT32_C(0x2)
-	#define HWRM_CFA_VF_PAIR_INFO_OUTPUT_PAIR_STATE_LAST	HWRM_CFA_VF_PAIR_INFO_OUTPUT_PAIR_STATE_ACTIVE
-	uint8_t	unused_0[5];
-	/* VF Pair name (32 byte string). */
-	char	pair_name[32];
-	uint8_t	unused_1[7];
+	/* Non-zero firmware timestamp */
+	uint32_t	nz_fw_timestamp;
+	/* The last selected USID */
+	uint16_t	last_usid;
+	/* The number of USEQs currently allocated */
+	uint16_t	num_useq_allocd;
+	/* Flags indicating current USEQ engine state */
+	uint32_t	useq_resp_flags;
+	/* When set, there is at least some data available to be delivered */
+	#define HWRM_DBG_USEQ_ALLOC_OUTPUT_HWRM_DBG_USEQ_RESP_HDR_USEQ_RESP_FLAGS_AVAIL	UINT32_C(0x1)
+	/* When set, all internal buffers are full */
+	#define HWRM_DBG_USEQ_ALLOC_OUTPUT_HWRM_DBG_USEQ_RESP_HDR_USEQ_RESP_FLAGS_OVERFLOW UINT32_C(0x2)
+	#define HWRM_DBG_USEQ_ALLOC_OUTPUT_HWRM_DBG_USEQ_RESP_HDR_USEQ_RESP_FLAGS_LAST	HWRM_DBG_USEQ_ALLOC_OUTPUT_HWRM_DBG_USEQ_RESP_HDR_USEQ_RESP_FLAGS_OVERFLOW
+	/* Current count of the number of full buffers available for delivery */
+	uint8_t	full_cnt;
+	/* Reserved */
+	uint8_t	useq_resp_unused_0[3];
+	/* This is the allocated usid */
+	uint16_t	alloc_usid;
+	/* This field is reserved */
+	uint16_t	unused_0;
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	uint8_t	valid;
-} hwrm_cfa_vf_pair_info_output_t, *phwrm_cfa_vf_pair_info_output_t;
+	uint32_t	valid;
+} hwrm_dbg_useq_alloc_output_t, *phwrm_dbg_useq_alloc_output_t;
 
-/***********************
- * hwrm_cfa_pair_alloc *
- ***********************/
+/**********************
+ * hwrm_dbg_useq_free *
+ **********************/
 
 
-/* hwrm_cfa_pair_alloc_input (size:576b/72B) */
+/* hwrm_dbg_useq_free_input (size:192b/24B) */
 
-typedef struct hwrm_cfa_pair_alloc_input {
+typedef struct hwrm_dbg_useq_free_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -38657,102 +65851,15 @@ typedef struct hwrm_cfa_pair_alloc_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/*
-	 * Pair mode (0-vf2fn, 1-rep2fn, 2-rep2rep, 3-proxy, 4-pfpair,
-	 *		5-rep2fn_mod, 6-rep2fn_modall, 7-rep2fn_truflow).
-	 */
-	uint16_t	pair_mode;
-	/* Pair between VF on local host with PF or VF on specified host. */
-	#define HWRM_CFA_PAIR_ALLOC_INPUT_PAIR_MODE_VF2FN	UINT32_C(0x0)
-	/* Pair between REP on local host with PF or VF on specified host. */
-	#define HWRM_CFA_PAIR_ALLOC_INPUT_PAIR_MODE_REP2FN	UINT32_C(0x1)
-	/* Pair between REP on local host with REP on specified host. */
-	#define HWRM_CFA_PAIR_ALLOC_INPUT_PAIR_MODE_REP2REP	UINT32_C(0x2)
-	/* Pair for the proxy interface. */
-	#define HWRM_CFA_PAIR_ALLOC_INPUT_PAIR_MODE_PROXY	UINT32_C(0x3)
-	/* Pair for the PF interface. */
-	#define HWRM_CFA_PAIR_ALLOC_INPUT_PAIR_MODE_PFPAIR	UINT32_C(0x4)
-	/* Modify existing rep2fn pair and move pair to new PF. */
-	#define HWRM_CFA_PAIR_ALLOC_INPUT_PAIR_MODE_REP2FN_MOD	UINT32_C(0x5)
-	/*
-	 * Modify existing rep2fn pairs paired with same PF and move pairs
-	 * to new PF.
-	 */
-	#define HWRM_CFA_PAIR_ALLOC_INPUT_PAIR_MODE_REP2FN_MODALL  UINT32_C(0x6)
-	/*
-	 * Truflow pair between REP on local host with PF or VF on specified
-	 * host.
-	 */
-	#define HWRM_CFA_PAIR_ALLOC_INPUT_PAIR_MODE_REP2FN_TRUFLOW UINT32_C(0x7)
-	#define HWRM_CFA_PAIR_ALLOC_INPUT_PAIR_MODE_LAST	HWRM_CFA_PAIR_ALLOC_INPUT_PAIR_MODE_REP2FN_TRUFLOW
-	/* Logical VF number (range: 0 -> MAX_VFS -1). */
-	uint16_t	vf_a_id;
-	/* Logical Host (0xff-local host). */
-	uint8_t	host_b_id;
-	/* Logical PF (0xff-PF for command channel). */
-	uint8_t	pf_b_id;
-	/* Logical VF number (range: 0 -> MAX_VFS -1). */
-	uint16_t	vf_b_id;
-	/* Loopback port (0xff-internal loopback), valid for mode-3. */
-	uint8_t	port_id;
-	/* Priority used for encap of loopback packets valid for mode-3. */
-	uint8_t	pri;
-	/* New PF for rep2fn modify, valid for mode 5. */
-	uint16_t	new_pf_fid;
-	uint32_t	enables;
-	/*
-	 * This bit must be '1' for the q_ab field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_PAIR_ALLOC_INPUT_ENABLES_Q_AB_VALID	UINT32_C(0x1)
-	/*
-	 * This bit must be '1' for the q_ba field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_PAIR_ALLOC_INPUT_ENABLES_Q_BA_VALID	UINT32_C(0x2)
-	/*
-	 * This bit must be '1' for the fc_ab field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_PAIR_ALLOC_INPUT_ENABLES_FC_AB_VALID	UINT32_C(0x4)
-	/*
-	 * This bit must be '1' for the fc_ba field to be
-	 * configured.
-	 */
-	#define HWRM_CFA_PAIR_ALLOC_INPUT_ENABLES_FC_BA_VALID	UINT32_C(0x8)
-	/* VF Pair name (32 byte string). */
-	char	pair_name[32];
-	/*
-	 * The q_ab value specifies the logical index of the TX/RX CoS
-	 * queue to be assigned for traffic in the A to B direction of
-	 * the interface pair. The default value is 0.
-	 */
-	uint8_t	q_ab;
-	/*
-	 * The q_ba value specifies the logical index of the TX/RX CoS
-	 * queue to be assigned for traffic in the B to A direction of
-	 * the interface pair. The default value is 1.
-	 */
-	uint8_t	q_ba;
-	/*
-	 * Specifies whether RX ring flow control is disabled (0) or enabled
-	 * (1) in the A to B direction. The default value is 0, meaning that
-	 * packets will be dropped when the B-side RX rings are full.
-	 */
-	uint8_t	fc_ab;
-	/*
-	 * Specifies whether RX ring flow control is disabled (0) or enabled
-	 * (1) in the B to A direction. The default value is 1, meaning that
-	 * the RX CoS queue will be flow controlled when the A-side RX rings
-	 * are full.
-	 */
-	uint8_t	fc_ba;
-	uint8_t	unused_1[4];
-} hwrm_cfa_pair_alloc_input_t, *phwrm_cfa_pair_alloc_input_t;
+	/* The USID of the sequence to free */
+	uint16_t	usid;
+	/* This field is reserved */
+	uint8_t	unused_0[6];
+} hwrm_dbg_useq_free_input_t, *phwrm_dbg_useq_free_input_t;
 
-/* hwrm_cfa_pair_alloc_output (size:192b/24B) */
+/* hwrm_dbg_useq_free_output (size:256b/32B) */
 
-typedef struct hwrm_cfa_pair_alloc_output {
+typedef struct hwrm_dbg_useq_free_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -38761,34 +65868,43 @@ typedef struct hwrm_cfa_pair_alloc_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* Only valid for modes 1 and 2. */
-	uint16_t	rx_cfa_code_a;
-	/* Only valid for modes 1 and 2. */
-	uint16_t	tx_cfa_action_a;
-	/* Only valid for mode 2. */
-	uint16_t	rx_cfa_code_b;
-	/* Only valid for mode 2. */
-	uint16_t	tx_cfa_action_b;
-	uint8_t	unused_0[7];
+	/* Non-zero firmware timestamp */
+	uint32_t	nz_fw_timestamp;
+	/* The last selected USID */
+	uint16_t	last_usid;
+	/* The number of USEQs currently allocated */
+	uint16_t	num_useq_allocd;
+	/* Flags indicating current USEQ engine state */
+	uint32_t	useq_resp_flags;
+	/* When set, there is at least some data available to be delivered */
+	#define HWRM_DBG_USEQ_FREE_OUTPUT_HWRM_DBG_USEQ_RESP_HDR_USEQ_RESP_FLAGS_AVAIL	UINT32_C(0x1)
+	/* When set, all internal buffers are full */
+	#define HWRM_DBG_USEQ_FREE_OUTPUT_HWRM_DBG_USEQ_RESP_HDR_USEQ_RESP_FLAGS_OVERFLOW UINT32_C(0x2)
+	#define HWRM_DBG_USEQ_FREE_OUTPUT_HWRM_DBG_USEQ_RESP_HDR_USEQ_RESP_FLAGS_LAST	HWRM_DBG_USEQ_FREE_OUTPUT_HWRM_DBG_USEQ_RESP_HDR_USEQ_RESP_FLAGS_OVERFLOW
+	/* Current count of the number of full buffers available for delivery */
+	uint8_t	full_cnt;
+	/* Reserved */
+	uint8_t	useq_resp_unused_0[3];
+	/* This field is reserved */
+	uint32_t	unused_0;
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	uint8_t	valid;
-} hwrm_cfa_pair_alloc_output_t, *phwrm_cfa_pair_alloc_output_t;
+	uint32_t	valid;
+} hwrm_dbg_useq_free_output_t, *phwrm_dbg_useq_free_output_t;
 
-/**********************
- * hwrm_cfa_pair_free *
- **********************/
+/***********************
+ * hwrm_dbg_useq_flush *
+ ***********************/
 
 
-/* hwrm_cfa_pair_free_input (size:448b/56B) */
+/* hwrm_dbg_useq_flush_input (size:192b/24B) */
 
-typedef struct hwrm_cfa_pair_free_input {
+typedef struct hwrm_dbg_useq_flush_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -38817,46 +65933,20 @@ typedef struct hwrm_cfa_pair_free_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* VF Pair name (32 byte string). */
-	char	pair_name[32];
-	/* Logical PF (0xff-PF for command channel). */
-	uint8_t	pf_b_id;
-	uint8_t	unused_0[3];
-	/* Logical VF number (range: 0 -> MAX_VFS -1). */
-	uint16_t	vf_id;
-	/*
-	 * Pair mode (0-vf2fn, 1-rep2fn, 2-rep2rep, 3-proxy, 4-pfpair,
-	 *		5-rep2fn_mod, 6-rep2fn_modall, 7-rep2fn_truflow).
-	 */
-	uint16_t	pair_mode;
-	/* Pair between VF on local host with PF or VF on specified host. */
-	#define HWRM_CFA_PAIR_FREE_INPUT_PAIR_MODE_VF2FN	UINT32_C(0x0)
-	/* Pair between REP on local host with PF or VF on specified host. */
-	#define HWRM_CFA_PAIR_FREE_INPUT_PAIR_MODE_REP2FN	UINT32_C(0x1)
-	/* Pair between REP on local host with REP on specified host. */
-	#define HWRM_CFA_PAIR_FREE_INPUT_PAIR_MODE_REP2REP	UINT32_C(0x2)
-	/* Pair for the proxy interface. */
-	#define HWRM_CFA_PAIR_FREE_INPUT_PAIR_MODE_PROXY	UINT32_C(0x3)
-	/* Pair for the PF interface. */
-	#define HWRM_CFA_PAIR_FREE_INPUT_PAIR_MODE_PFPAIR	UINT32_C(0x4)
-	/* Modify existing rep2fn pair and move pair to new PF. */
-	#define HWRM_CFA_PAIR_FREE_INPUT_PAIR_MODE_REP2FN_MOD	UINT32_C(0x5)
-	/*
-	 * Modify existing rep2fn pairs paired with same PF and move pairs
-	 * to new PF.
-	 */
-	#define HWRM_CFA_PAIR_FREE_INPUT_PAIR_MODE_REP2FN_MODALL  UINT32_C(0x6)
-	/*
-	 * Truflow pair between REP on local host with PF or VF on
-	 * specified host.
-	 */
-	#define HWRM_CFA_PAIR_FREE_INPUT_PAIR_MODE_REP2FN_TRUFLOW UINT32_C(0x7)
-	#define HWRM_CFA_PAIR_FREE_INPUT_PAIR_MODE_LAST	HWRM_CFA_PAIR_FREE_INPUT_PAIR_MODE_REP2FN_TRUFLOW
-} hwrm_cfa_pair_free_input_t, *phwrm_cfa_pair_free_input_t;
+	/* Bitwise flags described below */
+	uint16_t	flags;
+	/* Flush all USEQ code words, resetting all USIDs to invalid */
+	#define HWRM_DBG_USEQ_FLUSH_INPUT_USEQ_CODE_WORDS UINT32_C(0x1)
+	/* Initialize all buffers, clearing out any collected data */
+	#define HWRM_DBG_USEQ_FLUSH_INPUT_BUFFERS	UINT32_C(0x2)
+	#define HWRM_DBG_USEQ_FLUSH_INPUT_LAST	HWRM_DBG_USEQ_FLUSH_INPUT_BUFFERS
+	/* This field is reserved */
+	uint8_t	unused_0[6];
+} hwrm_dbg_useq_flush_input_t, *phwrm_dbg_useq_flush_input_t;
 
-/* hwrm_cfa_pair_free_output (size:128b/16B) */
+/* hwrm_dbg_useq_flush_output (size:256b/32B) */
 
-typedef struct hwrm_cfa_pair_free_output {
+typedef struct hwrm_dbg_useq_flush_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -38865,26 +65955,43 @@ typedef struct hwrm_cfa_pair_free_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	/* Non-zero firmware timestamp */
+	uint32_t	nz_fw_timestamp;
+	/* The last selected USID */
+	uint16_t	last_usid;
+	/* The number of USEQs currently allocated */
+	uint16_t	num_useq_allocd;
+	/* Flags indicating current USEQ engine state */
+	uint32_t	useq_resp_flags;
+	/* When set, there is at least some data available to be delivered */
+	#define HWRM_DBG_USEQ_FLUSH_OUTPUT_HWRM_DBG_USEQ_RESP_HDR_USEQ_RESP_FLAGS_AVAIL	UINT32_C(0x1)
+	/* When set, all internal buffers are full */
+	#define HWRM_DBG_USEQ_FLUSH_OUTPUT_HWRM_DBG_USEQ_RESP_HDR_USEQ_RESP_FLAGS_OVERFLOW UINT32_C(0x2)
+	#define HWRM_DBG_USEQ_FLUSH_OUTPUT_HWRM_DBG_USEQ_RESP_HDR_USEQ_RESP_FLAGS_LAST	HWRM_DBG_USEQ_FLUSH_OUTPUT_HWRM_DBG_USEQ_RESP_HDR_USEQ_RESP_FLAGS_OVERFLOW
+	/* Current count of the number of full buffers available for delivery */
+	uint8_t	full_cnt;
+	/* Reserved */
+	uint8_t	useq_resp_unused_0[3];
+	/* This field is reserved */
+	uint32_t	unused_0;
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	uint8_t	valid;
-} hwrm_cfa_pair_free_output_t, *phwrm_cfa_pair_free_output_t;
+	uint32_t	valid;
+} hwrm_dbg_useq_flush_output_t, *phwrm_dbg_useq_flush_output_t;
 
-/**********************
- * hwrm_cfa_pair_info *
- **********************/
+/************************
+ * hwrm_dbg_useq_cw_cfg *
+ ************************/
 
 
-/* hwrm_cfa_pair_info_input (size:448b/56B) */
+/* hwrm_dbg_useq_cw_cfg_input (size:960b/120B) */
 
-typedef struct hwrm_cfa_pair_info_input {
+typedef struct hwrm_dbg_useq_cw_cfg_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -38913,24 +66020,53 @@ typedef struct hwrm_cfa_pair_info_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	flags;
-	/* If this flag is set, lookup by name else lookup by index. */
-	#define HWRM_CFA_PAIR_INFO_INPUT_FLAGS_LOOKUP_TYPE	UINT32_C(0x1)
-	/* If this flag is set, lookup by PF id and VF id. */
-	#define HWRM_CFA_PAIR_INFO_INPUT_FLAGS_LOOKUP_REPRE	UINT32_C(0x2)
-	/* Pair table index. */
-	uint16_t	pair_index;
-	/* Pair pf index. */
-	uint8_t	pair_pfid;
-	/* Pair vf index. */
-	uint8_t	pair_vfid;
-	/* Pair name (32 byte string). */
-	char	pair_name[32];
-} hwrm_cfa_pair_info_input_t, *phwrm_cfa_pair_info_input_t;
+	/* The USID of the sequence being configured */
+	uint16_t	usid;
+	/*
+	 * The code words given in this message will be placed
+	 * at this offset from the starting code word for this
+	 * usid. NOTE: when offset is zero, the first 6 32-bit
+	 * words may contain values for F0-F7 as well as the
+	 * main code word index. This is determined by checking
+	 * the usid_ctrl_present flag.
+	 */
+	uint16_t	offset;
+	/*
+	 * When the use_dma flag is clear, this is the length in bytes
+	 * to be digested from the opaque data area.
+	 */
+	uint16_t	size;
+	/*
+	 * Flags associated with the current message
+	 * data area.
+	 */
+	uint16_t	flags;
+	/*
+	 * When set, the opaque data begins with a block of control
+	 * information to be associated with the usid. This includes
+	 * F0-F7 code word indexes as well as the code word index for
+	 * main.
+	 */
+	#define HWRM_DBG_USEQ_CW_CFG_INPUT_FLAGS_USID_CTRL_PRESENT UINT32_C(0x1)
+	/*
+	 * When set, opaque contains a 64b host address used to DMA
+	 * the entire code word sequence. The offset within the
+	 * opaque data depends on the state of other flags.
+	 */
+	#define HWRM_DBG_USEQ_CW_CFG_INPUT_FLAGS_USE_DMA	UINT32_C(0x2)
+	/*
+	 * When set, this message is the last configuration message
+	 * for the given usid.
+	 */
+	#define HWRM_DBG_USEQ_CW_CFG_INPUT_FLAGS_END		UINT32_C(0x8000)
+	#define HWRM_DBG_USEQ_CW_CFG_INPUT_FLAGS_LAST		HWRM_DBG_USEQ_CW_CFG_INPUT_FLAGS_END
+	/* command dependent data (e.g. function id for host dma command) */
+	uint32_t	opaque[24];
+} hwrm_dbg_useq_cw_cfg_input_t, *phwrm_dbg_useq_cw_cfg_input_t;
 
-/* hwrm_cfa_pair_info_output (size:576b/72B) */
+/* hwrm_dbg_useq_cw_cfg_output (size:192b/24B) */
 
-typedef struct hwrm_cfa_pair_info_output {
+typedef struct hwrm_dbg_useq_cw_cfg_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -38939,74 +66075,33 @@ typedef struct hwrm_cfa_pair_info_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* Pair table index. */
-	uint16_t	next_pair_index;
-	/* Pair member a's fid. */
-	uint16_t	a_fid;
-	/* Logical host number. */
-	uint8_t	host_a_index;
-	/* Logical PF number. */
-	uint8_t	pf_a_index;
-	/* Pair member a's Linux logical VF number. */
-	uint16_t	vf_a_index;
-	/* Rx CFA code. */
-	uint16_t	rx_cfa_code_a;
-	/* Tx CFA action. */
-	uint16_t	tx_cfa_action_a;
-	/* Pair member b's fid. */
-	uint16_t	b_fid;
-	/* Logical host number. */
-	uint8_t	host_b_index;
-	/* Logical PF number. */
-	uint8_t	pf_b_index;
-	/* Pair member a's Linux logical VF number. */
-	uint16_t	vf_b_index;
-	/* Rx CFA code. */
-	uint16_t	rx_cfa_code_b;
-	/* Tx CFA action. */
-	uint16_t	tx_cfa_action_b;
-	/* Pair mode (0-vf2fn, 1-rep2fn, 2-rep2rep, 3-proxy, 4-pfpair). */
-	uint8_t	pair_mode;
-	/* Pair between VF on local host with PF or VF on specified host. */
-	#define HWRM_CFA_PAIR_INFO_OUTPUT_PAIR_MODE_VF2FN   UINT32_C(0x0)
-	/* Pair between REP on local host with PF or VF on specified host. */
-	#define HWRM_CFA_PAIR_INFO_OUTPUT_PAIR_MODE_REP2FN  UINT32_C(0x1)
-	/* Pair between REP on local host with REP on specified host. */
-	#define HWRM_CFA_PAIR_INFO_OUTPUT_PAIR_MODE_REP2REP UINT32_C(0x2)
-	/* Pair for the proxy interface. */
-	#define HWRM_CFA_PAIR_INFO_OUTPUT_PAIR_MODE_PROXY   UINT32_C(0x3)
-	/* Pair for the PF interface. */
-	#define HWRM_CFA_PAIR_INFO_OUTPUT_PAIR_MODE_PFPAIR  UINT32_C(0x4)
-	#define HWRM_CFA_PAIR_INFO_OUTPUT_PAIR_MODE_LAST   HWRM_CFA_PAIR_INFO_OUTPUT_PAIR_MODE_PFPAIR
-	/* Pair state. */
-	uint8_t	pair_state;
-	/* Pair has been allocated */
-	#define HWRM_CFA_PAIR_INFO_OUTPUT_PAIR_STATE_ALLOCATED UINT32_C(0x1)
-	/* Both pair members are active */
-	#define HWRM_CFA_PAIR_INFO_OUTPUT_PAIR_STATE_ACTIVE	UINT32_C(0x2)
-	#define HWRM_CFA_PAIR_INFO_OUTPUT_PAIR_STATE_LAST	HWRM_CFA_PAIR_INFO_OUTPUT_PAIR_STATE_ACTIVE
-	/* Pair name (32 byte string). */
-	char	pair_name[32];
-	uint8_t	unused_0[7];
-	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
-	 */
-	uint8_t	valid;
-} hwrm_cfa_pair_info_output_t, *phwrm_cfa_pair_info_output_t;
+	/* Non-zero firmware timestamp */
+	uint32_t	nz_fw_timestamp;
+	/* The last selected USID */
+	uint16_t	last_usid;
+	/* The number of USEQs currently allocated */
+	uint16_t	num_useq_allocd;
+	/* Flags indicating current USEQ engine state */
+	uint32_t	useq_resp_flags;
+	/* When set, there is at least some data available to be delivered */
+	#define HWRM_DBG_USEQ_CW_CFG_OUTPUT_HWRM_DBG_USEQ_RESP_HDR_USEQ_RESP_FLAGS_AVAIL	UINT32_C(0x1)
+	/* When set, all internal buffers are full */
+	#define HWRM_DBG_USEQ_CW_CFG_OUTPUT_HWRM_DBG_USEQ_RESP_HDR_USEQ_RESP_FLAGS_OVERFLOW UINT32_C(0x2)
+	#define HWRM_DBG_USEQ_CW_CFG_OUTPUT_HWRM_DBG_USEQ_RESP_HDR_USEQ_RESP_FLAGS_LAST	HWRM_DBG_USEQ_CW_CFG_OUTPUT_HWRM_DBG_USEQ_RESP_HDR_USEQ_RESP_FLAGS_OVERFLOW
+	/* Current count of the number of full buffers available for delivery */
+	uint8_t	full_cnt;
+	/* Reserved */
+	uint8_t	useq_resp_unused_0[3];
+} hwrm_dbg_useq_cw_cfg_output_t, *phwrm_dbg_useq_cw_cfg_output_t;
 
-/**********************
- * hwrm_cfa_vfr_alloc *
- **********************/
+/***********************
+ * hwrm_dbg_useq_qcaps *
+ ***********************/
 
 
-/* hwrm_cfa_vfr_alloc_input (size:448b/56B) */
+/* hwrm_dbg_useq_qcaps_input (size:128b/16B) */
 
-typedef struct hwrm_cfa_vfr_alloc_input {
+typedef struct hwrm_dbg_useq_qcaps_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -39035,21 +66130,11 @@ typedef struct hwrm_cfa_vfr_alloc_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Logical VF number (range: 0 -> MAX_VFS -1). */
-	uint16_t	vf_id;
-	/*
-	 * This field is reserved for the future use.
-	 * It shall be set to 0.
-	 */
-	uint16_t	reserved;
-	uint8_t	unused_0[4];
-	/* VF Representor name (32 byte string). */
-	char	vfr_name[32];
-} hwrm_cfa_vfr_alloc_input_t, *phwrm_cfa_vfr_alloc_input_t;
+} hwrm_dbg_useq_qcaps_input_t, *phwrm_dbg_useq_qcaps_input_t;
 
-/* hwrm_cfa_vfr_alloc_output (size:128b/16B) */
+/* hwrm_dbg_useq_qcaps_output (size:384b/48B) */
 
-typedef struct hwrm_cfa_vfr_alloc_output {
+typedef struct hwrm_dbg_useq_qcaps_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -39058,30 +66143,51 @@ typedef struct hwrm_cfa_vfr_alloc_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* Rx CFA code. */
-	uint16_t	rx_cfa_code;
-	/* Tx CFA action. */
-	uint16_t	tx_cfa_action;
-	uint8_t	unused_0[3];
+	/* Non-zero firmware timestamp */
+	uint32_t	nz_fw_timestamp;
+	/* The last selected USID */
+	uint16_t	last_usid;
+	/* The number of USEQs currently allocated */
+	uint16_t	num_useq_allocd;
+	/* Flags indicating current USEQ engine state */
+	uint32_t	useq_resp_flags;
+	/* When set, there is at least some data available to be delivered */
+	#define HWRM_DBG_USEQ_QCAPS_OUTPUT_HWRM_DBG_USEQ_RESP_HDR_USEQ_RESP_FLAGS_AVAIL	UINT32_C(0x1)
+	/* When set, all internal buffers are full */
+	#define HWRM_DBG_USEQ_QCAPS_OUTPUT_HWRM_DBG_USEQ_RESP_HDR_USEQ_RESP_FLAGS_OVERFLOW UINT32_C(0x2)
+	#define HWRM_DBG_USEQ_QCAPS_OUTPUT_HWRM_DBG_USEQ_RESP_HDR_USEQ_RESP_FLAGS_LAST	HWRM_DBG_USEQ_QCAPS_OUTPUT_HWRM_DBG_USEQ_RESP_HDR_USEQ_RESP_FLAGS_OVERFLOW
+	/* Current count of the number of full buffers available for delivery */
+	uint8_t	full_cnt;
+	/* Reserved */
+	uint8_t	useq_resp_unused_0[3];
+	/* Maximum number of USEQ that can be tracked by firmware */
+	uint32_t	max_num_useq;
+	/* Maximum number of code word bytes for a single USEQ */
+	uint32_t	max_useq_size;
+	/* The maximum number of output bytes a single USEQ may generate */
+	uint32_t	max_useq_32b_output_size;
+	/* The number of internal USEQ output buffers, each of 4096 bytes */
+	uint32_t	num_buf;
+	/* This field is reserved */
+	uint32_t	unused_0;
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	uint8_t	valid;
-} hwrm_cfa_vfr_alloc_output_t, *phwrm_cfa_vfr_alloc_output_t;
+	uint32_t	valid;
+} hwrm_dbg_useq_qcaps_output_t, *phwrm_dbg_useq_qcaps_output_t;
 
-/*********************
- * hwrm_cfa_vfr_free *
- *********************/
+/***************************
+ * hwrm_dbg_useq_sched_cfg *
+ ***************************/
 
 
-/* hwrm_cfa_vfr_free_input (size:448b/56B) */
+/* hwrm_dbg_useq_sched_cfg_input (size:192b/24B) */
 
-typedef struct hwrm_cfa_vfr_free_input {
+typedef struct hwrm_dbg_useq_sched_cfg_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -39110,21 +66216,35 @@ typedef struct hwrm_cfa_vfr_free_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* VF Representor name (32 byte string). */
-	char	vfr_name[32];
-	/* Logical VF number (range: 0 -> MAX_VFS -1). */
-	uint16_t	vf_id;
+	/* Enumeration values for enabling, disabling scheduler */
+	uint16_t	global_cfg;
+	/* This value will leave the global scheduler in its current state */
+	#define HWRM_DBG_USEQ_SCHED_CFG_INPUT_NO_CHANGE UINT32_C(0x0)
 	/*
-	 * This field is reserved for the future use.
-	 * It shall be set to 0.
+	 * This value disables the global scheduler. This mode must be used
+	 * when the RUN command is being used to run individual sequences.
 	 */
-	uint16_t	reserved;
-	uint8_t	unused_0[4];
-} hwrm_cfa_vfr_free_input_t, *phwrm_cfa_vfr_free_input_t;
+	#define HWRM_DBG_USEQ_SCHED_CFG_INPUT_DISABLE   UINT32_C(0x1)
+	/*
+	 * This value enables the global scheduler. When enabled, USEQs will
+	 * be scheduled based on their polling intervals
+	 */
+	#define HWRM_DBG_USEQ_SCHED_CFG_INPUT_ENABLE	UINT32_C(0x2)
+	#define HWRM_DBG_USEQ_SCHED_CFG_INPUT_LAST	HWRM_DBG_USEQ_SCHED_CFG_INPUT_ENABLE
+	/*
+	 * The given polling interval will be associated with this USID. A
+	 * value of -1 indicates that the USID is invalid. The invalid USID is
+	 * used when using this message only for global scheduler
+	 * configuration.
+	 */
+	uint16_t	usid;
+	/* This value represents microseconds between runs of the USEQ */
+	uint32_t	polling_interval;
+} hwrm_dbg_useq_sched_cfg_input_t, *phwrm_dbg_useq_sched_cfg_input_t;
 
-/* hwrm_cfa_vfr_free_output (size:128b/16B) */
+/* hwrm_dbg_useq_sched_cfg_output (size:256b/32B) */
 
-typedef struct hwrm_cfa_vfr_free_output {
+typedef struct hwrm_dbg_useq_sched_cfg_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -39133,26 +66253,43 @@ typedef struct hwrm_cfa_vfr_free_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	/* Non-zero firmware timestamp */
+	uint32_t	nz_fw_timestamp;
+	/* The last selected USID */
+	uint16_t	last_usid;
+	/* The number of USEQs currently allocated */
+	uint16_t	num_useq_allocd;
+	/* Flags indicating current USEQ engine state */
+	uint32_t	useq_resp_flags;
+	/* When set, there is at least some data available to be delivered */
+	#define HWRM_DBG_USEQ_SCHED_CFG_OUTPUT_HWRM_DBG_USEQ_RESP_HDR_USEQ_RESP_FLAGS_AVAIL	UINT32_C(0x1)
+	/* When set, all internal buffers are full */
+	#define HWRM_DBG_USEQ_SCHED_CFG_OUTPUT_HWRM_DBG_USEQ_RESP_HDR_USEQ_RESP_FLAGS_OVERFLOW UINT32_C(0x2)
+	#define HWRM_DBG_USEQ_SCHED_CFG_OUTPUT_HWRM_DBG_USEQ_RESP_HDR_USEQ_RESP_FLAGS_LAST	HWRM_DBG_USEQ_SCHED_CFG_OUTPUT_HWRM_DBG_USEQ_RESP_HDR_USEQ_RESP_FLAGS_OVERFLOW
+	/* Current count of the number of full buffers available for delivery */
+	uint8_t	full_cnt;
+	/* Reserved */
+	uint8_t	useq_resp_unused_0[3];
+	/* This field is reserved */
+	uint32_t	unused_0;
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	uint8_t	valid;
-} hwrm_cfa_vfr_free_output_t, *phwrm_cfa_vfr_free_output_t;
+	uint32_t	valid;
+} hwrm_dbg_useq_sched_cfg_output_t, *phwrm_dbg_useq_sched_cfg_output_t;
 
-/***************************************
- * hwrm_cfa_redirect_query_tunnel_type *
- ***************************************/
+/*********************
+ * hwrm_dbg_useq_run *
+ *********************/
 
 
-/* hwrm_cfa_redirect_query_tunnel_type_input (size:192b/24B) */
+/* hwrm_dbg_useq_run_input (size:320b/40B) */
 
-typedef struct hwrm_cfa_redirect_query_tunnel_type_input {
+typedef struct hwrm_dbg_useq_run_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -39181,14 +66318,56 @@ typedef struct hwrm_cfa_redirect_query_tunnel_type_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* The source function id. */
-	uint16_t	src_fid;
-	uint8_t	unused_0[6];
-} hwrm_cfa_redirect_query_tunnel_type_input_t, *phwrm_cfa_redirect_query_tunnel_type_input_t;
+	/* The USID to be run */
+	uint16_t	usid;
+	/* Type of run to execute for the given USID */
+	uint8_t	run_type;
+	/* This run type will execute the requested USEQ only a single time */
+	#define HWRM_DBG_USEQ_RUN_INPUT_RUN_TYPE_SINGLE   UINT32_C(0x0)
+	/*
+	 * This run type will execute the requested USEQ a number of times
+	 * given by run_cnt with a run interval given by the run_interval
+	 * parameter.
+	 */
+	#define HWRM_DBG_USEQ_RUN_INPUT_RUN_TYPE_CNT	UINT32_C(0x1)
+	/*
+	 * This run type will execute the requested USEQ as many times as it
+	 * needs to fill an entire buffer to return to the host. The runs
+	 * will occur with a run interval given by the run_interval
+	 * parameter.
+	 */
+	#define HWRM_DBG_USEQ_RUN_INPUT_RUN_TYPE_FILL_BUF UINT32_C(0x2)
+	#define HWRM_DBG_USEQ_RUN_INPUT_RUN_TYPE_LAST	HWRM_DBG_USEQ_RUN_INPUT_RUN_TYPE_FILL_BUF
+	/*
+	 * If indicated by flags, this represents the number of times to run
+	 * the USEQ. Note that runs are stopped if the buffer fills prior
+	 * regardless of the number of runs. For example, if a run_cnt of 10 is
+	 * specified and 3 runs results in the buffer being full then only 3
+	 * runs are executed.
+	 */
+	uint8_t	run_cnt;
+	/*
+	 * This value represents microseconds between runs of the USEQ when
+	 * running multiple times as indicated by flags.
+	 */
+	uint32_t	run_interval;
+	/*
+	 * Address of the host buffer where collected USEQ output data will be
+	 * placed
+	 */
+	uint64_t	host_dest_addr;
+	/*
+	 * Size, in bytes, of the memory associated with host_dest_addr. It is
+	 * expected that this is >= 4096
+	 */
+	uint32_t	host_dest_len;
+	/* This field is reserved */
+	uint32_t	unused_0;
+} hwrm_dbg_useq_run_input_t, *phwrm_dbg_useq_run_input_t;
 
-/* hwrm_cfa_redirect_query_tunnel_type_output (size:128b/16B) */
+/* hwrm_dbg_useq_run_output (size:256b/32B) */
 
-typedef struct hwrm_cfa_redirect_query_tunnel_type_output {
+typedef struct hwrm_dbg_useq_run_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -39197,62 +66376,47 @@ typedef struct hwrm_cfa_redirect_query_tunnel_type_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* Tunnel Mask. */
-	uint32_t	tunnel_mask;
-	/* Non-tunnel */
-	#define HWRM_CFA_REDIRECT_QUERY_TUNNEL_TYPE_OUTPUT_TUNNEL_MASK_NONTUNNEL	UINT32_C(0x1)
-	/* Virtual eXtensible Local Area Network (VXLAN) */
-	#define HWRM_CFA_REDIRECT_QUERY_TUNNEL_TYPE_OUTPUT_TUNNEL_MASK_VXLAN		UINT32_C(0x2)
-	/* Network Virtualization Generic Routing Encapsulation (NVGRE) */
-	#define HWRM_CFA_REDIRECT_QUERY_TUNNEL_TYPE_OUTPUT_TUNNEL_MASK_NVGRE		UINT32_C(0x4)
-	/* Generic Routing Encapsulation (GRE) inside Ethernet payload */
-	#define HWRM_CFA_REDIRECT_QUERY_TUNNEL_TYPE_OUTPUT_TUNNEL_MASK_L2GRE		UINT32_C(0x8)
-	/* IP in IP */
-	#define HWRM_CFA_REDIRECT_QUERY_TUNNEL_TYPE_OUTPUT_TUNNEL_MASK_IPIP		UINT32_C(0x10)
-	/* Generic Network Virtualization Encapsulation (Geneve) */
-	#define HWRM_CFA_REDIRECT_QUERY_TUNNEL_TYPE_OUTPUT_TUNNEL_MASK_GENEVE	UINT32_C(0x20)
-	/* Multi-Protocol Label Switching (MPLS) */
-	#define HWRM_CFA_REDIRECT_QUERY_TUNNEL_TYPE_OUTPUT_TUNNEL_MASK_MPLS		UINT32_C(0x40)
-	/* Stateless Transport Tunnel (STT) */
-	#define HWRM_CFA_REDIRECT_QUERY_TUNNEL_TYPE_OUTPUT_TUNNEL_MASK_STT		UINT32_C(0x80)
-	/* Generic Routing Encapsulation (GRE) inside IP datagram payload */
-	#define HWRM_CFA_REDIRECT_QUERY_TUNNEL_TYPE_OUTPUT_TUNNEL_MASK_IPGRE		UINT32_C(0x100)
-	/* IPV4 over virtual eXtensible Local Area Network (IPV4oVXLAN) */
-	#define HWRM_CFA_REDIRECT_QUERY_TUNNEL_TYPE_OUTPUT_TUNNEL_MASK_VXLAN_V4	UINT32_C(0x200)
-	/*
-	 * Enhance Generic Routing Encapsulation (GRE version 1) inside IP
-	 * datagram payload
-	 */
-	#define HWRM_CFA_REDIRECT_QUERY_TUNNEL_TYPE_OUTPUT_TUNNEL_MASK_IPGRE_V1	UINT32_C(0x400)
-	/* Any tunneled traffic */
-	#define HWRM_CFA_REDIRECT_QUERY_TUNNEL_TYPE_OUTPUT_TUNNEL_MASK_ANYTUNNEL	UINT32_C(0x800)
-	/* Use fixed layer 2 ether type of 0xFFFF */
-	#define HWRM_CFA_REDIRECT_QUERY_TUNNEL_TYPE_OUTPUT_TUNNEL_MASK_L2_ETYPE	UINT32_C(0x1000)
+	/* Non-zero firmware timestamp */
+	uint32_t	nz_fw_timestamp;
+	/* The last selected USID */
+	uint16_t	last_usid;
+	/* The number of USEQs currently allocated */
+	uint16_t	num_useq_allocd;
+	/* Flags indicating current USEQ engine state */
+	uint32_t	useq_resp_flags;
+	/* When set, there is at least some data available to be delivered */
+	#define HWRM_DBG_USEQ_RUN_OUTPUT_HWRM_DBG_USEQ_RESP_HDR_USEQ_RESP_FLAGS_AVAIL	UINT32_C(0x1)
+	/* When set, all internal buffers are full */
+	#define HWRM_DBG_USEQ_RUN_OUTPUT_HWRM_DBG_USEQ_RESP_HDR_USEQ_RESP_FLAGS_OVERFLOW UINT32_C(0x2)
+	#define HWRM_DBG_USEQ_RUN_OUTPUT_HWRM_DBG_USEQ_RESP_HDR_USEQ_RESP_FLAGS_LAST	HWRM_DBG_USEQ_RUN_OUTPUT_HWRM_DBG_USEQ_RESP_HDR_USEQ_RESP_FLAGS_OVERFLOW
+	/* Current count of the number of full buffers available for delivery */
+	uint8_t	full_cnt;
+	/* Reserved */
+	uint8_t	useq_resp_unused_0[3];
 	/*
-	 * IPV6 over virtual eXtensible Local Area Network with GPE header
-	 * (IPV6oVXLANGPE)
+	 * The length, in bytes, of the amount of data placed in the
+	 * corresponding host_dest_addr given in the input message. This will
+	 * always be a multiple of 4096
 	 */
-	#define HWRM_CFA_REDIRECT_QUERY_TUNNEL_TYPE_OUTPUT_TUNNEL_MASK_VXLAN_GPE_V6	UINT32_C(0x2000)
-	uint8_t	unused_0[3];
+	uint32_t	host_dest_filled_len;
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	uint8_t	valid;
-} hwrm_cfa_redirect_query_tunnel_type_output_t, *phwrm_cfa_redirect_query_tunnel_type_output_t;
+	uint32_t	valid;
+} hwrm_dbg_useq_run_output_t, *phwrm_dbg_useq_run_output_t;
 
-/*************************
- * hwrm_cfa_ctx_mem_rgtr *
- *************************/
+/******************************
+ * hwrm_dbg_useq_delivery_req *
+ ******************************/
 
 
-/* hwrm_cfa_ctx_mem_rgtr_input (size:256b/32B) */
+/* hwrm_dbg_useq_delivery_req_input (size:896b/112B) */
 
-typedef struct hwrm_cfa_ctx_mem_rgtr_input {
+typedef struct hwrm_dbg_useq_delivery_req_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -39281,46 +66445,23 @@ typedef struct hwrm_cfa_ctx_mem_rgtr_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint16_t	flags;
-	/* Counter PBL indirect levels. */
-	uint8_t	page_level;
-	/* PBL pointer is physical start address. */
-	#define HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_LEVEL_LVL_0 UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-	#define HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_LEVEL_LVL_1 UINT32_C(0x1)
 	/*
-	 * PBL pointer points to PDE table with each entry pointing to PTE
-	 * tables.
+	 * Eight destination addresses provide host memory space for FW to
+	 * deliver USEQ output details. A value of 0x0 for the address can be
+	 * used to inform FW that the buffer is not available.
 	 */
-	#define HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_LEVEL_LVL_2 UINT32_C(0x2)
-	#define HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_LEVEL_LAST HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_LEVEL_LVL_2
-	/* Page size. */
-	uint8_t	page_size;
-	/* 4KB page size. */
-	#define HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_SIZE_4K   UINT32_C(0x0)
-	/* 8KB page size. */
-	#define HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_SIZE_8K   UINT32_C(0x1)
-	/* 64KB page size. */
-	#define HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_SIZE_64K  UINT32_C(0x4)
-	/* 256KB page size. */
-	#define HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_SIZE_256K UINT32_C(0x6)
-	/* 1MB page size. */
-	#define HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_SIZE_1M   UINT32_C(0x8)
-	/* 2MB page size. */
-	#define HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_SIZE_2M   UINT32_C(0x9)
-	/* 4MB page size. */
-	#define HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_SIZE_4M   UINT32_C(0xa)
-	/* 1GB page size. */
-	#define HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_SIZE_1G   UINT32_C(0x12)
-	#define HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_SIZE_LAST HWRM_CFA_CTX_MEM_RGTR_INPUT_PAGE_SIZE_1G
-	uint32_t	unused_0;
-	/* Pointer to the PBL, or PDL depending on number of levels */
-	uint64_t	page_dir;
-} hwrm_cfa_ctx_mem_rgtr_input_t, *phwrm_cfa_ctx_mem_rgtr_input_t;
+	uint64_t	host_dest_addrs[8];
+	/*
+	 * The length, in bytes, of the corresponding host_dest_addrs array
+	 * entry. Each valid hist_dest_addrs entry must have a len of at least
+	 * 4096 bytes.
+	 */
+	uint32_t	host_dest_len[8];
+} hwrm_dbg_useq_delivery_req_input_t, *phwrm_dbg_useq_delivery_req_input_t;
 
-/* hwrm_cfa_ctx_mem_rgtr_output (size:128b/16B) */
+/* hwrm_dbg_useq_delivery_req_output (size:512b/64B) */
 
-typedef struct hwrm_cfa_ctx_mem_rgtr_output {
+typedef struct hwrm_dbg_useq_delivery_req_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -39329,31 +66470,49 @@ typedef struct hwrm_cfa_ctx_mem_rgtr_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
+	/* Non-zero firmware timestamp */
+	uint32_t	nz_fw_timestamp;
+	/* The last selected USID */
+	uint16_t	last_usid;
+	/* The number of USEQs currently allocated */
+	uint16_t	num_useq_allocd;
+	/* Flags indicating current USEQ engine state */
+	uint32_t	useq_resp_flags;
+	/* When set, there is at least some data available to be delivered */
+	#define HWRM_DBG_USEQ_DELIVERY_REQ_OUTPUT_HWRM_DBG_USEQ_RESP_HDR_USEQ_RESP_FLAGS_AVAIL	UINT32_C(0x1)
+	/* When set, all internal buffers are full */
+	#define HWRM_DBG_USEQ_DELIVERY_REQ_OUTPUT_HWRM_DBG_USEQ_RESP_HDR_USEQ_RESP_FLAGS_OVERFLOW UINT32_C(0x2)
+	#define HWRM_DBG_USEQ_DELIVERY_REQ_OUTPUT_HWRM_DBG_USEQ_RESP_HDR_USEQ_RESP_FLAGS_LAST	HWRM_DBG_USEQ_DELIVERY_REQ_OUTPUT_HWRM_DBG_USEQ_RESP_HDR_USEQ_RESP_FLAGS_OVERFLOW
+	/* Current count of the number of full buffers available for delivery */
+	uint8_t	full_cnt;
+	/* Reserved */
+	uint8_t	useq_resp_unused_0[3];
 	/*
-	 * Id/Handle to the recently register context memory. This handle is
-	 * passed to the CFA feature.
+	 * The length, in bytes, of the amount of data placed in the
+	 * corresponding host_dest_addrs entry given in the input message. This
+	 * will always be a multiple of 4096.
 	 */
-	uint16_t	ctx_id;
-	uint8_t	unused_0[5];
+	uint32_t	host_dest_filled_len[8];
+	/* This field is reserved */
+	uint32_t	unused_0;
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	uint8_t	valid;
-} hwrm_cfa_ctx_mem_rgtr_output_t, *phwrm_cfa_ctx_mem_rgtr_output_t;
+	uint32_t	valid;
+} hwrm_dbg_useq_delivery_req_output_t, *phwrm_dbg_useq_delivery_req_output_t;
 
-/***************************
- * hwrm_cfa_ctx_mem_unrgtr *
- ***************************/
+/*****************************
+ * hwrm_dbg_log_buffer_flush *
+ *****************************/
 
 
-/* hwrm_cfa_ctx_mem_unrgtr_input (size:192b/24B) */
+/* hwrm_dbg_log_buffer_flush_input (size:192b/24B) */
 
-typedef struct hwrm_cfa_ctx_mem_unrgtr_input {
+typedef struct hwrm_dbg_log_buffer_flush_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -39382,17 +66541,36 @@ typedef struct hwrm_cfa_ctx_mem_unrgtr_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
+	/* Type of trace buffer to flush. */
+	uint16_t	type;
+	/* SRT trace. */
+	#define HWRM_DBG_LOG_BUFFER_FLUSH_INPUT_TYPE_SRT_TRACE	UINT32_C(0x0)
+	/* SRT2 trace. */
+	#define HWRM_DBG_LOG_BUFFER_FLUSH_INPUT_TYPE_SRT2_TRACE	UINT32_C(0x1)
+	/* CRT trace. */
+	#define HWRM_DBG_LOG_BUFFER_FLUSH_INPUT_TYPE_CRT_TRACE	UINT32_C(0x2)
+	/* CRT2 trace. */
+	#define HWRM_DBG_LOG_BUFFER_FLUSH_INPUT_TYPE_CRT2_TRACE	UINT32_C(0x3)
+	/* RIGP0 trace. */
+	#define HWRM_DBG_LOG_BUFFER_FLUSH_INPUT_TYPE_RIGP0_TRACE	UINT32_C(0x4)
+	/* L2 HWRM trace. */
+	#define HWRM_DBG_LOG_BUFFER_FLUSH_INPUT_TYPE_L2_HWRM_TRACE   UINT32_C(0x5)
+	/* RoCE HWRM trace. */
+	#define HWRM_DBG_LOG_BUFFER_FLUSH_INPUT_TYPE_ROCE_HWRM_TRACE UINT32_C(0x6)
+	#define HWRM_DBG_LOG_BUFFER_FLUSH_INPUT_TYPE_LAST	HWRM_DBG_LOG_BUFFER_FLUSH_INPUT_TYPE_ROCE_HWRM_TRACE
+	uint8_t	unused_1[2];
+	/* Control flags. */
+	uint32_t	flags;
 	/*
-	 * Id/Handle to the recently register context memory. This handle is
-	 * passed to the CFA feature.
+	 * When set, it indicates that all buffers should be flushed.
+	 * The type will be ignored.
 	 */
-	uint16_t	ctx_id;
-	uint8_t	unused_0[6];
-} hwrm_cfa_ctx_mem_unrgtr_input_t, *phwrm_cfa_ctx_mem_unrgtr_input_t;
+	#define HWRM_DBG_LOG_BUFFER_FLUSH_INPUT_FLAGS_FLUSH_ALL_BUFFERS	UINT32_C(0x1)
+} hwrm_dbg_log_buffer_flush_input_t, *phwrm_dbg_log_buffer_flush_input_t;
 
-/* hwrm_cfa_ctx_mem_unrgtr_output (size:128b/16B) */
+/* hwrm_dbg_log_buffer_flush_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_ctx_mem_unrgtr_output {
+typedef struct hwrm_dbg_log_buffer_flush_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -39401,26 +66579,33 @@ typedef struct hwrm_cfa_ctx_mem_unrgtr_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	/*
+	 * Specifies the current host buffer offset. Data up to this offset
+	 * has been populated by the firmware. For example, if the firmware
+	 * has DMA-ed 8192 bytes to the host buffer, then this field has a
+	 * value of 8192. This field rolls over to zero once the firmware
+	 * writes the last page of the host buffer
+	 */
+	uint32_t	current_buffer_offset;
+	uint8_t	unused_1[3];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_ctx_mem_unrgtr_output_t, *phwrm_cfa_ctx_mem_unrgtr_output_t;
+} hwrm_dbg_log_buffer_flush_output_t, *phwrm_dbg_log_buffer_flush_output_t;
 
-/*************************
- * hwrm_cfa_ctx_mem_qctx *
- *************************/
+/**************************
+ * hwrm_nvm_raw_write_blk *
+ **************************/
 
 
-/* hwrm_cfa_ctx_mem_qctx_input (size:192b/24B) */
+/* hwrm_nvm_raw_write_blk_input (size:320b/40B) */
 
-typedef struct hwrm_cfa_ctx_mem_qctx_input {
+typedef struct hwrm_nvm_raw_write_blk_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -39450,16 +66635,33 @@ typedef struct hwrm_cfa_ctx_mem_qctx_input {
 	 */
 	uint64_t	resp_addr;
 	/*
-	 * Id/Handle to the recently register context memory. This handle is
-	 * passed to the CFA feature.
+	 * 64-bit Host Source Address.
+	 * This is the location of the source data to be written.
 	 */
-	uint16_t	ctx_id;
-	uint8_t	unused_0[6];
-} hwrm_cfa_ctx_mem_qctx_input_t, *phwrm_cfa_ctx_mem_qctx_input_t;
+	uint64_t	host_src_addr;
+	/*
+	 * 32-bit Destination Address.
+	 * This is the NVRAM byte-offset where the source data will be written
+	 * to.
+	 */
+	uint32_t	dest_addr;
+	/* Length of data to be written, in bytes. */
+	uint32_t	len;
+	uint8_t	flags;
+	/*
+	 * This bit is only used when external secure SoC is used for
+	 * secure boot. This bit is utilized to differentiate between
+	 * writes for NIC or Security SoC non-volatile storage on the
+	 * device. If this bit is set, then this write is for the
+	 * Security SoC non-volatile storage on the device.
+	 */
+	#define HWRM_NVM_RAW_WRITE_BLK_INPUT_FLAGS_SECURITY_SOC_NVM	UINT32_C(0x1)
+	uint8_t	unused_0[7];
+} hwrm_nvm_raw_write_blk_input_t, *phwrm_nvm_raw_write_blk_input_t;
 
-/* hwrm_cfa_ctx_mem_qctx_output (size:256b/32B) */
+/* hwrm_nvm_raw_write_blk_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_ctx_mem_qctx_output {
+typedef struct hwrm_nvm_raw_write_blk_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -39468,61 +66670,25 @@ typedef struct hwrm_cfa_ctx_mem_qctx_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint16_t	flags;
-	/* Counter PBL indirect levels. */
-	uint8_t	page_level;
-	/* PBL pointer is physical start address. */
-	#define HWRM_CFA_CTX_MEM_QCTX_OUTPUT_PAGE_LEVEL_LVL_0 UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-	#define HWRM_CFA_CTX_MEM_QCTX_OUTPUT_PAGE_LEVEL_LVL_1 UINT32_C(0x1)
-	/*
-	 * PBL pointer points to PDE table with each entry pointing to PTE
-	 * tables.
-	 */
-	#define HWRM_CFA_CTX_MEM_QCTX_OUTPUT_PAGE_LEVEL_LVL_2 UINT32_C(0x2)
-	#define HWRM_CFA_CTX_MEM_QCTX_OUTPUT_PAGE_LEVEL_LAST HWRM_CFA_CTX_MEM_QCTX_OUTPUT_PAGE_LEVEL_LVL_2
-	/* Page size. */
-	uint8_t	page_size;
-	/* 4KB page size. */
-	#define HWRM_CFA_CTX_MEM_QCTX_OUTPUT_PAGE_SIZE_4K   UINT32_C(0x0)
-	/* 8KB page size. */
-	#define HWRM_CFA_CTX_MEM_QCTX_OUTPUT_PAGE_SIZE_8K   UINT32_C(0x1)
-	/* 64KB page size. */
-	#define HWRM_CFA_CTX_MEM_QCTX_OUTPUT_PAGE_SIZE_64K  UINT32_C(0x4)
-	/* 256KB page size. */
-	#define HWRM_CFA_CTX_MEM_QCTX_OUTPUT_PAGE_SIZE_256K UINT32_C(0x6)
-	/* 1MB page size. */
-	#define HWRM_CFA_CTX_MEM_QCTX_OUTPUT_PAGE_SIZE_1M   UINT32_C(0x8)
-	/* 2MB page size. */
-	#define HWRM_CFA_CTX_MEM_QCTX_OUTPUT_PAGE_SIZE_2M   UINT32_C(0x9)
-	/* 4MB page size. */
-	#define HWRM_CFA_CTX_MEM_QCTX_OUTPUT_PAGE_SIZE_4M   UINT32_C(0xa)
-	/* 1GB page size. */
-	#define HWRM_CFA_CTX_MEM_QCTX_OUTPUT_PAGE_SIZE_1G   UINT32_C(0x12)
-	#define HWRM_CFA_CTX_MEM_QCTX_OUTPUT_PAGE_SIZE_LAST HWRM_CFA_CTX_MEM_QCTX_OUTPUT_PAGE_SIZE_1G
-	uint8_t	unused_0[4];
-	/* Pointer to the PBL, or PDL depending on number of levels */
-	uint64_t	page_dir;
-	uint8_t	unused_1[7];
+	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_ctx_mem_qctx_output_t, *phwrm_cfa_ctx_mem_qctx_output_t;
+} hwrm_nvm_raw_write_blk_output_t, *phwrm_nvm_raw_write_blk_output_t;
 
-/**************************
- * hwrm_cfa_ctx_mem_qcaps *
- **************************/
+/*****************
+ * hwrm_nvm_read *
+ *****************/
 
 
-/* hwrm_cfa_ctx_mem_qcaps_input (size:128b/16B) */
+/* hwrm_nvm_read_input (size:320b/40B) */
 
-typedef struct hwrm_cfa_ctx_mem_qcaps_input {
+typedef struct hwrm_nvm_read_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -39551,11 +66717,24 @@ typedef struct hwrm_cfa_ctx_mem_qcaps_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-} hwrm_cfa_ctx_mem_qcaps_input_t, *phwrm_cfa_ctx_mem_qcaps_input_t;
+	/*
+	 * 64-bit Host Destination Address.
+	 * This is the host address where the data will be written to.
+	 */
+	uint64_t	host_dest_addr;
+	/* The 0-based index of the directory entry. */
+	uint16_t	dir_idx;
+	uint8_t	unused_0[2];
+	/* The NVRAM byte-offset to read from. */
+	uint32_t	offset;
+	/* The length of the data to be read, in bytes. */
+	uint32_t	len;
+	uint8_t	unused_1[4];
+} hwrm_nvm_read_input_t, *phwrm_nvm_read_input_t;
 
-/* hwrm_cfa_ctx_mem_qcaps_output (size:128b/16B) */
+/* hwrm_nvm_read_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_ctx_mem_qcaps_output {
+typedef struct hwrm_nvm_read_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -39564,31 +66743,25 @@ typedef struct hwrm_cfa_ctx_mem_qcaps_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/*
-	 * Indicates the maximum number of context memory which can be
-	 * registered.
-	 */
-	uint16_t	max_entries;
-	uint8_t	unused_0[5];
+	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_ctx_mem_qcaps_output_t, *phwrm_cfa_ctx_mem_qcaps_output_t;
+} hwrm_nvm_read_output_t, *phwrm_nvm_read_output_t;
 
-/**************************
- * hwrm_cfa_counter_qcaps *
- **************************/
+/*********************
+ * hwrm_nvm_raw_dump *
+ *********************/
 
 
-/* hwrm_cfa_counter_qcaps_input (size:128b/16B) */
+/* hwrm_nvm_raw_dump_input (size:320b/40B) */
 
-typedef struct hwrm_cfa_counter_qcaps_input {
+typedef struct hwrm_nvm_raw_dump_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -39617,11 +66790,30 @@ typedef struct hwrm_cfa_counter_qcaps_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-} hwrm_cfa_counter_qcaps_input_t, *phwrm_cfa_counter_qcaps_input_t;
+	/*
+	 * 64-bit Host Destination Address.
+	 * This is the host address where the data will be written to.
+	 */
+	uint64_t	host_dest_addr;
+	/* 32-bit NVRAM byte-offset to read from. */
+	uint32_t	offset;
+	/* Total length of NVRAM contents to be read, in bytes. */
+	uint32_t	len;
+	uint8_t	flags;
+	/*
+	 * This bit is only used when external secure SoC is used for
+	 * secure boot. This bit is utilized to differentiate between
+	 * read for NIC or Security SoC non-volatile storage on the
+	 * device. If this bit is set, then this read is for the Security
+	 * SoC non-volatile storage on the device.
+	 */
+	#define HWRM_NVM_RAW_DUMP_INPUT_FLAGS_SECURITY_SOC_NVM	UINT32_C(0x1)
+	uint8_t	unused_0[7];
+} hwrm_nvm_raw_dump_input_t, *phwrm_nvm_raw_dump_input_t;
 
-/* hwrm_cfa_counter_qcaps_output (size:576b/72B) */
+/* hwrm_nvm_raw_dump_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_counter_qcaps_output {
+typedef struct hwrm_nvm_raw_dump_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -39630,100 +66822,25 @@ typedef struct hwrm_cfa_counter_qcaps_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint32_t	flags;
-	/* Enumeration denoting the supported CFA counter format. */
-	#define HWRM_CFA_COUNTER_QCAPS_OUTPUT_FLAGS_COUNTER_FORMAT	UINT32_C(0x1)
-	/* CFA counter types are not supported. */
-		#define HWRM_CFA_COUNTER_QCAPS_OUTPUT_FLAGS_COUNTER_FORMAT_NONE	UINT32_C(0x0)
-	/* 64-bit packet counters followed by 64-bit byte counters format. */
-		#define HWRM_CFA_COUNTER_QCAPS_OUTPUT_FLAGS_COUNTER_FORMAT_64_BIT  UINT32_C(0x1)
-		#define HWRM_CFA_COUNTER_QCAPS_OUTPUT_FLAGS_COUNTER_FORMAT_LAST   HWRM_CFA_COUNTER_QCAPS_OUTPUT_FLAGS_COUNTER_FORMAT_64_BIT
-	uint32_t	unused_0;
-	/*
-	 * Minimum guaranteed number of flow counters supported for this
-	 * function, in RX direction.
-	 */
-	uint32_t	min_rx_fc;
-	/*
-	 * Maximum non-guaranteed number of flow counters supported for this
-	 * function, in RX direction.
-	 */
-	uint32_t	max_rx_fc;
-	/*
-	 * Minimum guaranteed number of flow counters supported for this
-	 * function, in TX direction.
-	 */
-	uint32_t	min_tx_fc;
-	/*
-	 * Maximum non-guaranteed number of flow counters supported for this
-	 * function, in TX direction.
-	 */
-	uint32_t	max_tx_fc;
-	/*
-	 * Minimum guaranteed number of extension flow counters supported for
-	 * this function, in RX direction.
-	 */
-	uint32_t	min_rx_efc;
-	/*
-	 * Maximum non-guaranteed number of extension flow counters supported
-	 * for this function, in RX direction.
-	 */
-	uint32_t	max_rx_efc;
-	/*
-	 * Minimum guaranteed number of extension flow counters supported for
-	 * this function, in TX direction.
-	 */
-	uint32_t	min_tx_efc;
-	/*
-	 * Maximum non-guaranteed number of extension flow counters supported
-	 * for this function, in TX direction.
-	 */
-	uint32_t	max_tx_efc;
-	/*
-	 * Minimum guaranteed number of meter drop counters supported for
-	 * this function, in RX direction.
-	 */
-	uint32_t	min_rx_mdc;
-	/*
-	 * Maximum non-guaranteed number of meter drop counters supported for
-	 * this function, in RX direction.
-	 */
-	uint32_t	max_rx_mdc;
-	/*
-	 * Minimum guaranteed number of meter drop counters supported for this
-	 * function, in TX direction.
-	 */
-	uint32_t	min_tx_mdc;
-	/*
-	 * Maximum non-guaranteed number of meter drop counters supported for
-	 * this function, in TX direction.
-	 */
-	uint32_t	max_tx_mdc;
-	/*
-	 * Maximum guaranteed number of flow counters which can be used during
-	 * flow alloc.
-	 */
-	uint32_t	max_flow_alloc_fc;
-	uint8_t	unused_1[3];
+	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_counter_qcaps_output_t, *phwrm_cfa_counter_qcaps_output_t;
+} hwrm_nvm_raw_dump_output_t, *phwrm_nvm_raw_dump_output_t;
 
-/************************
- * hwrm_cfa_counter_cfg *
- ************************/
+/****************************
+ * hwrm_nvm_get_dir_entries *
+ ****************************/
 
 
-/* hwrm_cfa_counter_cfg_input (size:256b/32B) */
+/* hwrm_nvm_get_dir_entries_input (size:192b/24B) */
 
-typedef struct hwrm_cfa_counter_cfg_input {
+typedef struct hwrm_nvm_get_dir_entries_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -39752,51 +66869,16 @@ typedef struct hwrm_cfa_counter_cfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint16_t	flags;
-	/* Enumeration denoting the configuration mode. */
-	#define HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_CFG_MODE			UINT32_C(0x1)
-	/* Disable the configuration mode. */
-		#define HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_CFG_MODE_DISABLE		UINT32_C(0x0)
-	/* Enable the configuration mode. */
-		#define HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_CFG_MODE_ENABLE		UINT32_C(0x1)
-		#define HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_CFG_MODE_LAST		HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_CFG_MODE_ENABLE
-	/* Enumeration denoting the RX, TX type of the resource. */
-	#define HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_PATH			UINT32_C(0x2)
-	/* Tx path. */
-		#define HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_PATH_TX			(UINT32_C(0x0) << 1)
-	/* Rx path. */
-		#define HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_PATH_RX			(UINT32_C(0x1) << 1)
-		#define HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_PATH_LAST			HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_PATH_RX
-	/* Enumeration denoting the data transfer mode. */
-	#define HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_DATA_TRANSFER_MODE_MASK	UINT32_C(0xc)
-	#define HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_DATA_TRANSFER_MODE_SFT	2
-	/* Push mode. */
-		#define HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_DATA_TRANSFER_MODE_PUSH	(UINT32_C(0x0) << 2)
-	/* Pull mode. */
-		#define HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_DATA_TRANSFER_MODE_PULL	(UINT32_C(0x1) << 2)
-	/* Pull on async update. */
-		#define HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_DATA_TRANSFER_MODE_PULL_ASYNC  (UINT32_C(0x2) << 2)
-		#define HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_DATA_TRANSFER_MODE_LAST	HWRM_CFA_COUNTER_CFG_INPUT_FLAGS_DATA_TRANSFER_MODE_PULL_ASYNC
-	uint16_t	counter_type;
-	/* Flow counters. */
-	#define HWRM_CFA_COUNTER_CFG_INPUT_COUNTER_TYPE_FC  UINT32_C(0x0)
-	/* Extended flow counters. */
-	#define HWRM_CFA_COUNTER_CFG_INPUT_COUNTER_TYPE_EFC UINT32_C(0x1)
-	/* Meter drop counters. */
-	#define HWRM_CFA_COUNTER_CFG_INPUT_COUNTER_TYPE_MDC UINT32_C(0x2)
-	#define HWRM_CFA_COUNTER_CFG_INPUT_COUNTER_TYPE_LAST HWRM_CFA_COUNTER_CFG_INPUT_COUNTER_TYPE_MDC
-	/* Ctx memory handle to be used for the counter. */
-	uint16_t	ctx_id;
-	/* Counter update cadence hint (only in Push mode). */
-	uint16_t	update_tmr_ms;
-	/* Total number of entries. */
-	uint32_t	num_entries;
-	uint32_t	unused_0;
-} hwrm_cfa_counter_cfg_input_t, *phwrm_cfa_counter_cfg_input_t;
+	/*
+	 * 64-bit Host Destination Address.
+	 * This is the host address where the directory will be written.
+	 */
+	uint64_t	host_dest_addr;
+} hwrm_nvm_get_dir_entries_input_t, *phwrm_nvm_get_dir_entries_input_t;
 
-/* hwrm_cfa_counter_cfg_output (size:128b/16B) */
+/* hwrm_nvm_get_dir_entries_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_counter_cfg_output {
+typedef struct hwrm_nvm_get_dir_entries_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -39809,22 +66891,21 @@ typedef struct hwrm_cfa_counter_cfg_output {
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_counter_cfg_output_t, *phwrm_cfa_counter_cfg_output_t;
+} hwrm_nvm_get_dir_entries_output_t, *phwrm_nvm_get_dir_entries_output_t;
 
-/***************************
- * hwrm_cfa_counter_qstats *
- ***************************/
+/*************************
+ * hwrm_nvm_get_dir_info *
+ *************************/
 
 
-/* hwrm_cfa_counter_qstats_input (size:320b/40B) */
+/* hwrm_nvm_get_dir_info_input (size:128b/16B) */
 
-typedef struct hwrm_cfa_counter_qstats_input {
+typedef struct hwrm_nvm_get_dir_info_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -39853,27 +66934,11 @@ typedef struct hwrm_cfa_counter_qstats_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint16_t	flags;
-	/* Enumeration denoting the RX, TX type of the resource. */
-	#define HWRM_CFA_COUNTER_QSTATS_INPUT_FLAGS_PATH	UINT32_C(0x1)
-	/* Tx path. */
-		#define HWRM_CFA_COUNTER_QSTATS_INPUT_FLAGS_PATH_TX	UINT32_C(0x0)
-	/* Rx path. */
-		#define HWRM_CFA_COUNTER_QSTATS_INPUT_FLAGS_PATH_RX	UINT32_C(0x1)
-		#define HWRM_CFA_COUNTER_QSTATS_INPUT_FLAGS_PATH_LAST HWRM_CFA_COUNTER_QSTATS_INPUT_FLAGS_PATH_RX
-	uint16_t	counter_type;
-	uint16_t	input_flow_ctx_id;
-	uint16_t	num_entries;
-	uint16_t	delta_time_ms;
-	uint16_t	meter_instance_id;
-	uint16_t	mdc_ctx_id;
-	uint8_t	unused_0[2];
-	uint64_t	expected_count;
-} hwrm_cfa_counter_qstats_input_t, *phwrm_cfa_counter_qstats_input_t;
+} hwrm_nvm_get_dir_info_input_t, *phwrm_nvm_get_dir_info_input_t;
 
-/* hwrm_cfa_counter_qstats_output (size:128b/16B) */
+/* hwrm_nvm_get_dir_info_output (size:192b/24B) */
 
-typedef struct hwrm_cfa_counter_qstats_output {
+typedef struct hwrm_nvm_get_dir_info_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -39882,26 +66947,29 @@ typedef struct hwrm_cfa_counter_qstats_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
+	/* Number of directory entries in the directory. */
+	uint32_t	entries;
+	/* Size of each directory entry, in bytes. */
+	uint32_t	entry_length;
 	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_counter_qstats_output_t, *phwrm_cfa_counter_qstats_output_t;
+} hwrm_nvm_get_dir_info_output_t, *phwrm_nvm_get_dir_info_output_t;
 
-/**********************
- * hwrm_cfa_eem_qcaps *
- **********************/
+/******************
+ * hwrm_nvm_write *
+ ******************/
 
 
-/* hwrm_cfa_eem_qcaps_input (size:192b/24B) */
+/* hwrm_nvm_write_input (size:448b/56B) */
 
-typedef struct hwrm_cfa_eem_qcaps_input {
+typedef struct hwrm_nvm_write_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -39930,130 +66998,148 @@ typedef struct hwrm_cfa_eem_qcaps_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	flags;
-	/*
-	 * When set to 1, indicates the configuration will apply to TX flows
-	 * which are to be offloaded.
-	 * Note if this bit is set then the path_rx bit can't be set.
-	 */
-	#define HWRM_CFA_EEM_QCAPS_INPUT_FLAGS_PATH_TX		UINT32_C(0x1)
 	/*
-	 * When set to 1, indicates the configuration will apply to RX flows
-	 * which are to be offloaded.
-	 * Note if this bit is set then the path_tx bit can't be set.
+	 * 64-bit Host Source Address.
+	 * This is where the source data is.
 	 */
-	#define HWRM_CFA_EEM_QCAPS_INPUT_FLAGS_PATH_RX		UINT32_C(0x2)
-	/* When set to 1, all offloaded flows will be sent to EEM. */
-	#define HWRM_CFA_EEM_QCAPS_INPUT_FLAGS_PREFERRED_OFFLOAD	UINT32_C(0x4)
-	uint32_t	unused_0;
-} hwrm_cfa_eem_qcaps_input_t, *phwrm_cfa_eem_qcaps_input_t;
-
-/* hwrm_cfa_eem_qcaps_output (size:320b/40B) */
-
-typedef struct hwrm_cfa_eem_qcaps_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint32_t	flags;
+	uint64_t	host_src_addr;
 	/*
-	 * When set to 1, indicates the configuration will apply to TX flows
-	 * which are to be offloaded.
-	 * Note if this bit is set then the path_rx bit can't be set.
+	 * The Directory Entry Type (valid values are defined in the
+	 * bnxnvm_directory_type enum defined in the file bnxnvm_defs.h).
 	 */
-	#define HWRM_CFA_EEM_QCAPS_OUTPUT_FLAGS_PATH_TX					UINT32_C(0x1)
+	uint16_t	dir_type;
 	/*
-	 * When set to 1, indicates the configuration will apply to RX flows
-	 * which are to be offloaded.
-	 * Note if this bit is set then the path_tx bit can't be set.
+	 * Directory ordinal.
+	 * The 0-based instance of the combined Directory Entry Type and
+	 * Extension.
 	 */
-	#define HWRM_CFA_EEM_QCAPS_OUTPUT_FLAGS_PATH_RX					UINT32_C(0x2)
+	uint16_t	dir_ordinal;
 	/*
-	 * When set to 1, indicates the the FW supports the Centralized
-	 * Memory Model. The concept designates one entity for the
-	 * memory allocation while all others ‘subscribe’ to it.
+	 * The Directory Entry Extension flags (see BNX_DIR_EXT_* in the file
+	 * bnxnvm_defs.h).
 	 */
-	#define HWRM_CFA_EEM_QCAPS_OUTPUT_FLAGS_CENTRALIZED_MEMORY_MODEL_SUPPORTED		UINT32_C(0x4)
+	uint16_t	dir_ext;
 	/*
-	 * When set to 1, indicates the the FW supports the Detached
-	 * Centralized Memory Model. The memory is allocated and managed
-	 * as a separate entity. All PFs and VFs will be granted direct
-	 * or semi-direct access to the allocated memory while none of
-	 * which can interfere with the management of the memory.
+	 * Directory Entry Attribute flags (see BNX_DIR_ATTR_* in the file
+	 * bnxnvm_defs.h).
 	 */
-	#define HWRM_CFA_EEM_QCAPS_OUTPUT_FLAGS_DETACHED_CENTRALIZED_MEMORY_MODEL_SUPPORTED	UINT32_C(0x8)
-	uint32_t	unused_0;
-	uint32_t	supported;
+	uint16_t	dir_attr;
 	/*
-	 * If set to 1, then EEM KEY0 table is supported using crc32 hash.
-	 * If set to 0, EEM KEY0 table is not supported.
+	 * Length of data to write, in bytes. May be less than or equal to the
+	 * allocated size for the directory entry.
+	 * The data length stored in the directory entry will be updated to
+	 * reflect this value once the write is complete.
 	 */
-	#define HWRM_CFA_EEM_QCAPS_OUTPUT_SUPPORTED_KEY0_TABLE			UINT32_C(0x1)
+	uint32_t	dir_data_length;
+	/* Option. */
+	uint16_t	option;
+	uint16_t	flags;
 	/*
-	 * If set to 1, then EEM KEY1 table is supported using lookup3 hash.
-	 * If set to 0, EEM KEY1 table is not supported.
+	 * When this bit is '1', the original active image
+	 * will not be removed. TBD: what purpose is this?
 	 */
-	#define HWRM_CFA_EEM_QCAPS_OUTPUT_SUPPORTED_KEY1_TABLE			UINT32_C(0x2)
+	#define HWRM_NVM_WRITE_INPUT_FLAGS_KEEP_ORIG_ACTIVE_IMG	UINT32_C(0x1)
 	/*
-	 * If set to 1, then EEM External Record table is supported.
-	 * If set to 0, EEM External Record table is not supported.
-	 * (This table includes action record, EFC pointers, encap pointers)
+	 * This flag indicates the sender wants to modify a continuous
+	 * NVRAM area using a batch of this HWRM requests. The
+	 * offset of a request must be continuous to the end of previous
+	 * request's. Firmware does not update the directory entry until
+	 * receiving the last request, which is indicated by the batch_last
+	 * flag. This flag is set usually when a sender does not have a
+	 * block of memory that is big enough to hold the entire NVRAM
+	 * data for send at one time.
+	 */
+	#define HWRM_NVM_WRITE_INPUT_FLAGS_BATCH_MODE		UINT32_C(0x2)
+	/*
+	 * This flag can be used only when the batch_mode flag is set. It
+	 * indicates this request is the last of batch requests.
+	 */
+	#define HWRM_NVM_WRITE_INPUT_FLAGS_BATCH_LAST		UINT32_C(0x4)
+	/*
+	 * The requested length of the allocated NVM for the item, in bytes.
+	 * This value may be greater than or equal to the specified data
+	 * length (dir_data_length).
+	 * If this value is less than the specified data length, it will be
+	 * ignored. The response will contain the actual allocated item length,
+	 * which may be greater than the requested item length.
+	 * The purpose for allocating more than the required number of bytes
+	 * for an item's data is to pre-allocate extra storage (padding) to
+	 * accommodate the potential future growth of an item (e.g. upgraded
+	 * firmware with a size increase, log growth, expanded configuration
+	 * data).
 	 */
-	#define HWRM_CFA_EEM_QCAPS_OUTPUT_SUPPORTED_EXTERNAL_RECORD_TABLE		UINT32_C(0x4)
+	uint32_t	dir_item_length;
 	/*
-	 * If set to 1, then EEM External Flow Counters table is supported.
-	 * If set to 0, EEM External Flow Counters table is not supported.
+	 * 32-bit offset of data blob from where data is being written.
+	 * Only valid for batch mode. For non-batch writes 'dont care'.
 	 */
-	#define HWRM_CFA_EEM_QCAPS_OUTPUT_SUPPORTED_EXTERNAL_FLOW_COUNTERS_TABLE	UINT32_C(0x8)
+	uint32_t	offset;
 	/*
-	 * If set to 1, then FID table used for implicit flow flush is
-	 * supported.
-	 * If set to 0, then FID table used for implicit flow flush is
-	 * not supported.
+	 * Length of data to be written.Should be non-zero.
+	 * Only valid for batch mode. For non-batch writes 'dont care'.
 	 */
-	#define HWRM_CFA_EEM_QCAPS_OUTPUT_SUPPORTED_FID_TABLE			UINT32_C(0x10)
+	uint32_t	len;
+	uint32_t	unused_0;
+} hwrm_nvm_write_input_t, *phwrm_nvm_write_input_t;
+
+/* hwrm_nvm_write_output (size:128b/16B) */
+
+typedef struct hwrm_nvm_write_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
 	/*
-	 * The maximum number of entries supported by EEM. When configuring
-	 * the host memory, the number of numbers of entries that can
-	 * supported are:
-	 *	32k, 64k 128k, 256k, 512k, 1M, 2M, 4M, 8M, 32M, 64M, 128M
-	 *	entries.
-	 * Any value that are not these values, the FW will round down to the
-	 * closest support number of entries.
+	 * Length of the allocated NVM for the item, in bytes. The value may be
+	 * greater than or equal to the specified data length or the requested
+	 * item length.
+	 * The actual item length used when creating a new directory entry will
+	 * be a multiple of an NVM block size.
 	 */
-	uint32_t	max_entries_supported;
-	/* The entry size in bytes of each entry in the EEM KEY0/KEY1 tables. */
-	uint16_t	key_entry_size;
-	/* The entry size in bytes of each entry in the EEM RECORD tables. */
-	uint16_t	record_entry_size;
-	/* The entry size in bytes of each entry in the EEM EFC tables. */
-	uint16_t	efc_entry_size;
-	/* The FID size in bytes of each entry in the EEM FID tables. */
-	uint16_t	fid_entry_size;
-	uint8_t	unused_1[7];
+	uint32_t	dir_item_length;
+	/* The directory index of the created or modified item. */
+	uint16_t	dir_idx;
+	uint8_t	unused_0;
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_eem_qcaps_output_t, *phwrm_cfa_eem_qcaps_output_t;
+} hwrm_nvm_write_output_t, *phwrm_nvm_write_output_t;
 
-/********************
- * hwrm_cfa_eem_cfg *
- ********************/
+/* hwrm_nvm_write_cmd_err (size:64b/8B) */
+
+typedef struct hwrm_nvm_write_cmd_err {
+	/*
+	 * command specific error codes that goes to
+	 * the cmd_err field in Common HWRM Error Response.
+	 */
+	uint8_t	code;
+	/* Unknown error */
+	#define HWRM_NVM_WRITE_CMD_ERR_CODE_UNKNOWN  UINT32_C(0x0)
+	/* Unable to complete operation due to fragmentation */
+	#define HWRM_NVM_WRITE_CMD_ERR_CODE_FRAG_ERR UINT32_C(0x1)
+	/* nvm is completely full. */
+	#define HWRM_NVM_WRITE_CMD_ERR_CODE_NO_SPACE UINT32_C(0x2)
+	#define HWRM_NVM_WRITE_CMD_ERR_CODE_LAST	HWRM_NVM_WRITE_CMD_ERR_CODE_NO_SPACE
+	uint8_t	unused_0[7];
+} hwrm_nvm_write_cmd_err_t, *phwrm_nvm_write_cmd_err_t;
 
+/*******************
+ * hwrm_nvm_modify *
+ *******************/
 
-/* hwrm_cfa_eem_cfg_input (size:384b/48B) */
 
-typedef struct hwrm_cfa_eem_cfg_input {
+/* hwrm_nvm_modify_input (size:320b/40B) */
+
+typedef struct hwrm_nvm_modify_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -40081,55 +67167,44 @@ typedef struct hwrm_cfa_eem_cfg_input {
 	 * physical address (HPA) or a guest physical address (GPA) and must
 	 * point to a physically contiguous block of memory.
 	 */
-	uint64_t	resp_addr;
-	uint32_t	flags;
-	/*
-	 * When set to 1, indicates the configuration will apply to TX flows
-	 * which are to be offloaded.
-	 * Note if this bit is set then the path_rx bit can't be set.
+	uint64_t	resp_addr;
+	/*
+	 * 64-bit Host Source Address.
+	 * This is where the modified data is.
 	 */
-	#define HWRM_CFA_EEM_CFG_INPUT_FLAGS_PATH_TX		UINT32_C(0x1)
+	uint64_t	host_src_addr;
+	/* 16-bit directory entry index. */
+	uint16_t	dir_idx;
+	uint16_t	flags;
 	/*
-	 * When set to 1, indicates the configuration will apply to RX flows
-	 * which are to be offloaded.
-	 * Note if this bit is set then the path_tx bit can't be set.
+	 * This flag indicates the sender wants to modify a continuous NVRAM
+	 * area using a batch of this HWRM requests. The offset of a request
+	 * must be continuous to the end of previous request's. Firmware does
+	 * not update the directory entry until receiving the last request,
+	 * which is indicated by the batch_last flag.
+	 * This flag is set usually when a sender does not have a block of
+	 * memory that is big enough to hold the entire NVRAM data for send
+	 * at one time.
 	 */
-	#define HWRM_CFA_EEM_CFG_INPUT_FLAGS_PATH_RX		UINT32_C(0x2)
-	/* When set to 1, all offloaded flows will be sent to EEM. */
-	#define HWRM_CFA_EEM_CFG_INPUT_FLAGS_PREFERRED_OFFLOAD	UINT32_C(0x4)
-	/* When set to 1, secondary, 0 means primary. */
-	#define HWRM_CFA_EEM_CFG_INPUT_FLAGS_SECONDARY_PF	UINT32_C(0x8)
+	#define HWRM_NVM_MODIFY_INPUT_FLAGS_BATCH_MODE	UINT32_C(0x1)
 	/*
-	 * Group_id which used by Firmware to identify memory pools belonging
-	 * to certain group.
+	 * This flag can be used only when the batch_mode flag is set.
+	 * It indicates this request is the last of batch requests.
 	 */
-	uint16_t	group_id;
-	uint16_t	unused_0;
+	#define HWRM_NVM_MODIFY_INPUT_FLAGS_BATCH_LAST	UINT32_C(0x2)
+	/* 32-bit NVRAM byte-offset to modify content from. */
+	uint32_t	offset;
 	/*
-	 * Configured EEM with the given number of entries. All the EEM tables
-	 * KEY0, KEY1, RECORD, EFC all have the same number of entries and all
-	 * tables will be configured using this value. Current minimum value
-	 * is 32k. Current maximum value is 128M.
+	 * Length of data to be modified, in bytes. The length shall
+	 * be non-zero.
 	 */
-	uint32_t	num_entries;
-	uint32_t	unused_1;
-	/* Configured EEM with the given context if for KEY0 table. */
-	uint16_t	key0_ctx_id;
-	/* Configured EEM with the given context if for KEY1 table. */
-	uint16_t	key1_ctx_id;
-	/* Configured EEM with the given context if for RECORD table. */
-	uint16_t	record_ctx_id;
-	/* Configured EEM with the given context if for EFC table. */
-	uint16_t	efc_ctx_id;
-	/* Configured EEM with the given context if for EFC table. */
-	uint16_t	fid_ctx_id;
-	uint16_t	unused_2;
-	uint32_t	unused_3;
-} hwrm_cfa_eem_cfg_input_t, *phwrm_cfa_eem_cfg_input_t;
+	uint32_t	len;
+	uint8_t	unused_1[4];
+} hwrm_nvm_modify_input_t, *phwrm_nvm_modify_input_t;
 
-/* hwrm_cfa_eem_cfg_output (size:128b/16B) */
+/* hwrm_nvm_modify_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_eem_cfg_output {
+typedef struct hwrm_nvm_modify_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -40142,22 +67217,21 @@ typedef struct hwrm_cfa_eem_cfg_output {
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_eem_cfg_output_t, *phwrm_cfa_eem_cfg_output_t;
+} hwrm_nvm_modify_output_t, *phwrm_nvm_modify_output_t;
 
-/*********************
- * hwrm_cfa_eem_qcfg *
- *********************/
+/***************************
+ * hwrm_nvm_find_dir_entry *
+ ***************************/
 
 
-/* hwrm_cfa_eem_qcfg_input (size:192b/24B) */
+/* hwrm_nvm_find_dir_entry_input (size:256b/32B) */
 
-typedef struct hwrm_cfa_eem_qcfg_input {
+typedef struct hwrm_nvm_find_dir_entry_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -40186,17 +67260,41 @@ typedef struct hwrm_cfa_eem_qcfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	flags;
-	/* When set to 1, indicates the configuration is the TX flow. */
-	#define HWRM_CFA_EEM_QCFG_INPUT_FLAGS_PATH_TX	UINT32_C(0x1)
-	/* When set to 1, indicates the configuration is the RX flow. */
-	#define HWRM_CFA_EEM_QCFG_INPUT_FLAGS_PATH_RX	UINT32_C(0x2)
-	uint32_t	unused_0;
-} hwrm_cfa_eem_qcfg_input_t, *phwrm_cfa_eem_qcfg_input_t;
+	uint32_t	enables;
+	/*
+	 * This bit must be '1' for the dir_idx_valid field to be
+	 * configured.
+	 */
+	#define HWRM_NVM_FIND_DIR_ENTRY_INPUT_ENABLES_DIR_IDX_VALID	UINT32_C(0x1)
+	/* Directory Entry Index */
+	uint16_t	dir_idx;
+	/* Directory Entry (Image) Type */
+	uint16_t	dir_type;
+	/*
+	 * Directory ordinal.
+	 * The instance of this Directory Type
+	 */
+	uint16_t	dir_ordinal;
+	/* The Directory Entry Extension flags. */
+	uint16_t	dir_ext;
+	/* This value indicates the search option using dir_ordinal. */
+	uint8_t	opt_ordinal;
+	/* This value indicates the search option using dir_ordinal. */
+	#define HWRM_NVM_FIND_DIR_ENTRY_INPUT_OPT_ORDINAL_MASK UINT32_C(0x3)
+	#define HWRM_NVM_FIND_DIR_ENTRY_INPUT_OPT_ORDINAL_SFT 0
+	/* Equal to specified ordinal value. */
+		#define HWRM_NVM_FIND_DIR_ENTRY_INPUT_OPT_ORDINAL_EQ	UINT32_C(0x0)
+	/* Greater than or equal to specified ordinal value */
+		#define HWRM_NVM_FIND_DIR_ENTRY_INPUT_OPT_ORDINAL_GE	UINT32_C(0x1)
+	/* Greater than specified ordinal value */
+		#define HWRM_NVM_FIND_DIR_ENTRY_INPUT_OPT_ORDINAL_GT	UINT32_C(0x2)
+		#define HWRM_NVM_FIND_DIR_ENTRY_INPUT_OPT_ORDINAL_LAST HWRM_NVM_FIND_DIR_ENTRY_INPUT_OPT_ORDINAL_GT
+	uint8_t	unused_0[3];
+} hwrm_nvm_find_dir_entry_input_t, *phwrm_nvm_find_dir_entry_input_t;
 
-/* hwrm_cfa_eem_qcfg_output (size:256b/32B) */
+/* hwrm_nvm_find_dir_entry_output (size:256b/32B) */
 
-typedef struct hwrm_cfa_eem_qcfg_output {
+typedef struct hwrm_nvm_find_dir_entry_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -40205,45 +67303,39 @@ typedef struct hwrm_cfa_eem_qcfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint32_t	flags;
-	/* When set to 1, indicates the configuration is the TX flow. */
-	#define HWRM_CFA_EEM_QCFG_OUTPUT_FLAGS_PATH_TX		UINT32_C(0x1)
-	/* When set to 1, indicates the configuration is the RX flow. */
-	#define HWRM_CFA_EEM_QCFG_OUTPUT_FLAGS_PATH_RX		UINT32_C(0x2)
-	/* When set to 1, all offloaded flows will be sent to EEM. */
-	#define HWRM_CFA_EEM_QCFG_OUTPUT_FLAGS_PREFERRED_OFFLOAD	UINT32_C(0x4)
-	/* The number of entries the FW has configured for EEM. */
-	uint32_t	num_entries;
-	/* Configured EEM with the given context if for KEY0 table. */
-	uint16_t	key0_ctx_id;
-	/* Configured EEM with the given context if for KEY1 table. */
-	uint16_t	key1_ctx_id;
-	/* Configured EEM with the given context if for RECORD table. */
-	uint16_t	record_ctx_id;
-	/* Configured EEM with the given context if for EFC table. */
-	uint16_t	efc_ctx_id;
-	/* Configured EEM with the given context if for EFC table. */
-	uint16_t	fid_ctx_id;
-	uint8_t	unused_2[5];
+	/* Allocated NVRAM for this directory entry, in bytes. */
+	uint32_t	dir_item_length;
+	/* Size of the stored data for this directory entry, in bytes. */
+	uint32_t	dir_data_length;
+	/*
+	 * Firmware version.
+	 * Only valid if the directory entry is for embedded firmware stored
+	 * in APE_BIN Format.
+	 */
+	uint32_t	fw_ver;
+	/* Directory ordinal. */
+	uint16_t	dir_ordinal;
+	/* Directory Entry Index */
+	uint16_t	dir_idx;
+	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_eem_qcfg_output_t, *phwrm_cfa_eem_qcfg_output_t;
+} hwrm_nvm_find_dir_entry_output_t, *phwrm_nvm_find_dir_entry_output_t;
 
-/*******************
- * hwrm_cfa_eem_op *
- *******************/
+/****************************
+ * hwrm_nvm_erase_dir_entry *
+ ****************************/
 
 
-/* hwrm_cfa_eem_op_input (size:192b/24B) */
+/* hwrm_nvm_erase_dir_entry_input (size:192b/24B) */
 
-typedef struct hwrm_cfa_eem_op_input {
+typedef struct hwrm_nvm_erase_dir_entry_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -40272,49 +67364,14 @@ typedef struct hwrm_cfa_eem_op_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	flags;
-	/*
-	 * When set to 1, indicates the host memory which is passed will be
-	 * used for the TX flow offload function specified in fid.
-	 * Note if this bit is set then the path_rx bit can't be set.
-	 */
-	#define HWRM_CFA_EEM_OP_INPUT_FLAGS_PATH_TX	UINT32_C(0x1)
-	/*
-	 * When set to 1, indicates the host memory which is passed will be
-	 * used for the RX flow offload function specified in fid.
-	 * Note if this bit is set then the path_tx bit can't be set.
-	 */
-	#define HWRM_CFA_EEM_OP_INPUT_FLAGS_PATH_RX	UINT32_C(0x2)
-	uint16_t	unused_0;
-	/* The number of EEM key table entries to be configured. */
-	uint16_t	op;
-	/* This value is reserved and should not be used. */
-	#define HWRM_CFA_EEM_OP_INPUT_OP_RESERVED	UINT32_C(0x0)
-	/*
-	 * To properly stop EEM and ensure there are no DMA's, the caller
-	 * must disable EEM for the given PF, using this call. This will
-	 * safely disable EEM and ensure that all DMA'ed to the
-	 * keys/records/efc have been completed.
-	 */
-	#define HWRM_CFA_EEM_OP_INPUT_OP_EEM_DISABLE UINT32_C(0x1)
-	/*
-	 * Once the EEM host memory has been configured, EEM options have
-	 * been configured. Then the caller should enable EEM for the given
-	 * PF. Note once this call has been made, then the EEM mechanism
-	 * will be active and DMA's will occur as packets are processed.
-	 */
-	#define HWRM_CFA_EEM_OP_INPUT_OP_EEM_ENABLE  UINT32_C(0x2)
-	/*
-	 * Clear EEM settings for the given PF so that the register values
-	 * are reset back to there initial state.
-	 */
-	#define HWRM_CFA_EEM_OP_INPUT_OP_EEM_CLEANUP UINT32_C(0x3)
-	#define HWRM_CFA_EEM_OP_INPUT_OP_LAST	HWRM_CFA_EEM_OP_INPUT_OP_EEM_CLEANUP
-} hwrm_cfa_eem_op_input_t, *phwrm_cfa_eem_op_input_t;
+	/* Directory Entry Index */
+	uint16_t	dir_idx;
+	uint8_t	unused_0[6];
+} hwrm_nvm_erase_dir_entry_input_t, *phwrm_nvm_erase_dir_entry_input_t;
 
-/* hwrm_cfa_eem_op_output (size:128b/16B) */
+/* hwrm_nvm_erase_dir_entry_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_eem_op_output {
+typedef struct hwrm_nvm_erase_dir_entry_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -40327,22 +67384,21 @@ typedef struct hwrm_cfa_eem_op_output {
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_eem_op_output_t, *phwrm_cfa_eem_op_output_t;
+} hwrm_nvm_erase_dir_entry_output_t, *phwrm_nvm_erase_dir_entry_output_t;
 
-/********************************
- * hwrm_cfa_adv_flow_mgnt_qcaps *
- ********************************/
+/*************************
+ * hwrm_nvm_get_dev_info *
+ *************************/
 
 
-/* hwrm_cfa_adv_flow_mgnt_qcaps_input (size:256b/32B) */
+/* hwrm_nvm_get_dev_info_input (size:128b/16B) */
 
-typedef struct hwrm_cfa_adv_flow_mgnt_qcaps_input {
+typedef struct hwrm_nvm_get_dev_info_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -40371,12 +67427,11 @@ typedef struct hwrm_cfa_adv_flow_mgnt_qcaps_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	unused_0[4];
-} hwrm_cfa_adv_flow_mgnt_qcaps_input_t, *phwrm_cfa_adv_flow_mgnt_qcaps_input_t;
+} hwrm_nvm_get_dev_info_input_t, *phwrm_nvm_get_dev_info_input_t;
 
-/* hwrm_cfa_adv_flow_mgnt_qcaps_output (size:128b/16B) */
+/* hwrm_nvm_get_dev_info_output (size:704b/88B) */
 
-typedef struct hwrm_cfa_adv_flow_mgnt_qcaps_output {
+typedef struct hwrm_nvm_get_dev_info_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -40385,137 +67440,140 @@ typedef struct hwrm_cfa_adv_flow_mgnt_qcaps_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint32_t	flags;
+	/* Manufacturer ID. */
+	uint16_t	manufacturer_id;
+	/* Device ID. */
+	uint16_t	device_id;
+	/* Sector size of the NVRAM device. */
+	uint32_t	sector_size;
+	/* Total size, in bytes of the NVRAM device. */
+	uint32_t	nvram_size;
+	uint32_t	reserved_size;
 	/*
-	 * Value of 1 to indicate firmware support 16-bit flow handle.
-	 * Value of 0 to indicate firmware not support 16-bit flow handle.
+	 * Available size that can be used, in bytes. Available size is the
+	 * NVRAM size take away the used size and reserved size.
 	 */
-	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_FLOW_HND_16BIT_SUPPORTED			UINT32_C(0x1)
+	uint32_t	available_size;
+	/* This field represents the major version of NVM cfg */
+	uint8_t	nvm_cfg_ver_maj;
+	/* This field represents the minor version of NVM cfg */
+	uint8_t	nvm_cfg_ver_min;
+	/* This field represents the update version of NVM cfg */
+	uint8_t	nvm_cfg_ver_upd;
+	uint8_t	flags;
 	/*
-	 * Value of 1 to indicate firmware support 64-bit flow handle.
-	 * Value of 0 to indicate firmware not support 64-bit flow handle.
+	 * If set to 1, firmware will provide various firmware version
+	 * information stored in the flash.
 	 */
-	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_FLOW_HND_64BIT_SUPPORTED			UINT32_C(0x2)
+	#define HWRM_NVM_GET_DEV_INFO_OUTPUT_FLAGS_FW_VER_VALID	UINT32_C(0x1)
 	/*
-	 * Value of 1 to indicate firmware support flow batch delete
-	 * operation through HWRM_CFA_FLOW_FLUSH command.
-	 * Value of 0 to indicate that the firmware does not support flow
-	 * batch delete operation.
+	 * This field represents the board package name stored in the flash.
+	 * (ASCII chars with NULL at the end).
 	 */
-	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_FLOW_BATCH_DELETE_SUPPORTED		UINT32_C(0x4)
+	char	pkg_name[16];
 	/*
-	 * Value of 1 to indicate that the firmware support flow reset all
-	 * operation through HWRM_CFA_FLOW_FLUSH command.
-	 * Value of 0 indicates firmware does not support flow reset all
-	 * operation.
+	 * This field represents the major version of HWRM firmware, stored in
+	 * the flash.
 	 */
-	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_FLOW_RESET_ALL_SUPPORTED			UINT32_C(0x8)
+	uint16_t	hwrm_fw_major;
 	/*
-	 * Value of 1 to indicate that firmware supports use of FID as
-	 * dest_id in HWRM_CFA_NTUPLE_ALLOC/CFG commands.
-	 * Value of 0 indicates firmware does not support use of FID as
-	 * dest_id.
+	 * This field represents the minor version of HWRM firmware, stored in
+	 * the flash.
 	 */
-	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_NTUPLE_FLOW_DEST_FUNC_SUPPORTED		UINT32_C(0x10)
+	uint16_t	hwrm_fw_minor;
 	/*
-	 * Value of 1 to indicate that firmware supports TX EEM flows.
-	 * Value of 0 indicates firmware does not support TX EEM flows.
+	 * This field represents the build version of HWRM firmware, stored in
+	 * the flash.
 	 */
-	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_TX_EEM_FLOW_SUPPORTED			UINT32_C(0x20)
+	uint16_t	hwrm_fw_build;
 	/*
-	 * Value of 1 to indicate that firmware supports RX EEM flows.
-	 * Value of 0 indicates firmware does not support RX EEM flows.
+	 * This field can be used to represent firmware branches or customer
+	 * specific releases tied to a specific (major, minor, build) version
+	 * of the HWRM firmware.
 	 */
-	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_RX_EEM_FLOW_SUPPORTED			UINT32_C(0x40)
+	uint16_t	hwrm_fw_patch;
 	/*
-	 * Value of 1 to indicate that firmware supports the dynamic
-	 * allocation of an on-chip flow counter which can be used for EEM
-	 * flows. Value of 0 indicates firmware does not support the dynamic
-	 * allocation of an on-chip flow counter.
+	 * This field represents the major version of mgmt firmware, stored in
+	 * the flash.
 	 */
-	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_FLOW_COUNTER_ALLOC_SUPPORTED		UINT32_C(0x80)
+	uint16_t	mgmt_fw_major;
 	/*
-	 * Value of 1 to indicate that firmware supports setting of
-	 * rfs_ring_tbl_idx in HWRM_CFA_NTUPLE_ALLOC command.
-	 * Value of 0 indicates firmware does not support rfs_ring_tbl_idx.
+	 * This field represents the minor version of mgmt firmware, stored in
+	 * the flash.
 	 */
-	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_RFS_RING_TBL_IDX_SUPPORTED		UINT32_C(0x100)
+	uint16_t	mgmt_fw_minor;
 	/*
-	 * Value of 1 to indicate that firmware supports untagged matching
-	 * criteria on HWRM_CFA_L2_FILTER_ALLOC command. Value of 0
-	 * indicates firmware does not support untagged matching.
+	 * This field represents the build version of mgmt firmware, stored in
+	 * the flash.
 	 */
-	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_UNTAGGED_VLAN_SUPPORTED			UINT32_C(0x200)
+	uint16_t	mgmt_fw_build;
 	/*
-	 * Value of 1 to indicate that firmware supports XDP filter. Value
-	 * of 0 indicates firmware does not support XDP filter.
+	 * This field can be used to represent firmware branches or customer
+	 * specific releases tied to a specific (major, minor, build) version
+	 * of the mgmt firmware.
 	 */
-	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_XDP_SUPPORTED				UINT32_C(0x400)
+	uint16_t	mgmt_fw_patch;
 	/*
-	 * Value of 1 to indicate that the firmware support L2 header source
-	 * fields matching criteria on HWRM_CFA_L2_FILTER_ALLOC command.
-	 * Value of 0 indicates firmware does not support L2 header source
-	 * fields matching.
+	 * This field represents the major version of roce firmware, stored in
+	 * the flash.
 	 */
-	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_L2_HEADER_SOURCE_FIELDS_SUPPORTED		UINT32_C(0x800)
+	uint16_t	roce_fw_major;
 	/*
-	 * If set to 1, firmware is capable of supporting ARP ethertype as
-	 * matching criteria for HWRM_CFA_NTUPLE_FILTER_ALLOC command on the
-	 * RX direction. By default, this flag should be 0 for older version
-	 * of firmware.
+	 * This field represents the minor version of roce firmware, stored in
+	 * the flash.
 	 */
-	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_NTUPLE_FLOW_RX_ARP_SUPPORTED		UINT32_C(0x1000)
+	uint16_t	roce_fw_minor;
 	/*
-	 * Value of 1 to indicate that firmware supports setting of
-	 * rfs_ring_tbl_idx in dst_id field of the HWRM_CFA_NTUPLE_ALLOC
-	 * command. Value of 0 indicates firmware does not support
-	 * rfs_ring_tbl_idx in dst_id field.
+	 * This field represents the build version of roce firmware, stored in
+	 * the flash.
 	 */
-	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_RFS_RING_TBL_IDX_V2_SUPPORTED		UINT32_C(0x2000)
+	uint16_t	roce_fw_build;
 	/*
-	 * If set to 1, firmware is capable of supporting IPv4/IPv6 as
-	 * ethertype in HWRM_CFA_NTUPLE_FILTER_ALLOC command on the RX
-	 * direction. By default, this flag should be 0 for older version
-	 * of firmware.
+	 * This field can be used to represent firmware branches or customer
+	 * specific releases tied to a specific (major, minor, build) version
+	 * of the roce firmware.
 	 */
-	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_NTUPLE_FLOW_RX_ETHERTYPE_IP_SUPPORTED	UINT32_C(0x4000)
+	uint16_t	roce_fw_patch;
 	/*
-	 * When this bit is '1', it indicates that core firmware is
-	 * capable of TruFlow. Driver can restrict sending HWRM CFA_FLOW_XXX
-	 * and CFA_ENCAP_XXX, CFA_DECAP_XXX commands.
+	 * This field represents the major version of network control firmware,
+	 * stored in the flash.
 	 */
-	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_TRUFLOW_CAPABLE				UINT32_C(0x8000)
+	uint16_t	netctrl_fw_major;
 	/*
-	 * If set to 1, firmware is capable of supporting L2/ROCE as
-	 * traffic type in flags field of HWRM_CFA_L2_FILTER_ALLOC command.
-	 * By default, this flag should be 0 for older version of firmware.
+	 * This field represents the minor version of network control firmware,
+	 * stored in the flash.
 	 */
-	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_L2_FILTER_TRAFFIC_TYPE_L2_ROCE_SUPPORTED	UINT32_C(0x10000)
+	uint16_t	netctrl_fw_minor;
 	/*
-	 * If set to 1, firmware is capable of HW LAG. This bit is only
-	 * advertised if the calling function is a PAXC function.
+	 * This field represents the build version of network control firmware,
+	 * stored in the flash.
 	 */
-	#define HWRM_CFA_ADV_FLOW_MGNT_QCAPS_OUTPUT_FLAGS_LAG_SUPPORTED				UINT32_C(0x20000)
-	uint8_t	unused_0[3];
+	uint16_t	netctrl_fw_build;
+	/*
+	 * This field can be used to represent firmware branches or customer
+	 * specific releases tied to a specific (major, minor, build) version
+	 * of the network control firmware.
+	 */
+	uint16_t	netctrl_fw_patch;
+	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_adv_flow_mgnt_qcaps_output_t, *phwrm_cfa_adv_flow_mgnt_qcaps_output_t;
+} hwrm_nvm_get_dev_info_output_t, *phwrm_nvm_get_dev_info_output_t;
 
-/******************
- * hwrm_cfa_tflib *
- ******************/
+/**************************
+ * hwrm_nvm_mod_dir_entry *
+ **************************/
 
 
-/* hwrm_cfa_tflib_input (size:1024b/128B) */
+/* hwrm_nvm_mod_dir_entry_input (size:256b/32B) */
 
-typedef struct hwrm_cfa_tflib_input {
+typedef struct hwrm_nvm_mod_dir_entry_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -40544,19 +67602,117 @@ typedef struct hwrm_cfa_tflib_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* TFLIB message type. */
-	uint16_t	tf_type;
-	/* TFLIB message subtype. */
-	uint16_t	tf_subtype;
-	/* unused. */
-	uint8_t	unused0[4];
-	/* TFLIB request data. */
-	uint32_t	tf_req[26];
-} hwrm_cfa_tflib_input_t, *phwrm_cfa_tflib_input_t;
+	uint32_t	enables;
+	/*
+	 * This bit must be '1' for the checksum field to be
+	 * configured.
+	 */
+	#define HWRM_NVM_MOD_DIR_ENTRY_INPUT_ENABLES_CHECKSUM	UINT32_C(0x1)
+	/* Directory Entry Index */
+	uint16_t	dir_idx;
+	/*
+	 * Directory ordinal.
+	 * The (0-based) instance of this Directory Type.
+	 */
+	uint16_t	dir_ordinal;
+	/*
+	 * The Directory Entry Extension flags (see BNX_DIR_EXT_* for
+	 * extension flag definitions).
+	 */
+	uint16_t	dir_ext;
+	/*
+	 * Directory Entry Attribute flags (see BNX_DIR_ATTR_* for attribute
+	 * flag definitions).
+	 */
+	uint16_t	dir_attr;
+	/*
+	 * If valid, then this field updates the checksum
+	 * value of the content in the directory entry.
+	 */
+	uint32_t	checksum;
+} hwrm_nvm_mod_dir_entry_input_t, *phwrm_nvm_mod_dir_entry_input_t;
+
+/* hwrm_nvm_mod_dir_entry_output (size:128b/16B) */
+
+typedef struct hwrm_nvm_mod_dir_entry_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_nvm_mod_dir_entry_output_t, *phwrm_nvm_mod_dir_entry_output_t;
+
+/**************************
+ * hwrm_nvm_verify_update *
+ **************************/
+
+
+/* hwrm_nvm_verify_update_input (size:192b/24B) */
+
+typedef struct hwrm_nvm_verify_update_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t	target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t	resp_addr;
+	/* Directory Entry Type, to be verified. */
+	uint16_t	dir_type;
+	/*
+	 * Directory ordinal.
+	 * The instance of the Directory Type to be verified.
+	 */
+	uint16_t	dir_ordinal;
+	/*
+	 * The Directory Entry Extension flags.
+	 * The "UPDATE" extension flag must be set in this value.
+	 * A corresponding directory entry with the same type and ordinal
+	 * values but *without*
+	 * the "UPDATE" extension flag must also exist. The other flags of
+	 * the extension must
+	 * be identical between the active and update entries.
+	 */
+	uint16_t	dir_ext;
+	uint8_t	unused_0[2];
+} hwrm_nvm_verify_update_input_t, *phwrm_nvm_verify_update_input_t;
 
-/* hwrm_cfa_tflib_output (size:5632b/704B) */
+/* hwrm_nvm_verify_update_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_tflib_output {
+typedef struct hwrm_nvm_verify_update_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -40565,35 +67721,25 @@ typedef struct hwrm_cfa_tflib_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* TFLIB message type. */
-	uint16_t	tf_type;
-	/* TFLIB message subtype. */
-	uint16_t	tf_subtype;
-	/* TFLIB response code */
-	uint32_t	tf_resp_code;
-	/* TFLIB response data. */
-	uint32_t	tf_resp[170];
-	/* unused. */
-	uint8_t	unused1[7];
+	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_tflib_output_t, *phwrm_cfa_tflib_output_t;
+} hwrm_nvm_verify_update_output_t, *phwrm_nvm_verify_update_output_t;
 
-/**********************************
- * hwrm_cfa_lag_group_member_rgtr *
- **********************************/
+/***************************
+ * hwrm_nvm_install_update *
+ ***************************/
 
 
-/* hwrm_cfa_lag_group_member_rgtr_input (size:192b/24B) */
+/* hwrm_nvm_install_update_input (size:192b/24B) */
 
-typedef struct hwrm_cfa_lag_group_member_rgtr_input {
+typedef struct hwrm_nvm_install_update_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -40622,39 +67768,59 @@ typedef struct hwrm_cfa_lag_group_member_rgtr_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint8_t	mode;
 	/*
-	 * Transmit only on the active port. Automatically failover
-	 * to backup port.
+	 * Installation type. If the value 3 through 0xffff is used,
+	 * only packaged items with that type value will be installed and
+	 * conditional installation directives for those packaged items
+	 * will be over-ridden (i.e. 'create' or 'replace' will be treated
+	 * as 'install').
 	 */
-	#define HWRM_CFA_LAG_GROUP_MEMBER_RGTR_INPUT_MODE_ACTIVE_BACKUP UINT32_C(0x1)
+	uint32_t	install_type;
 	/*
-	 * Transmit based on packet header ntuple hash. Packet with only
-	 * layer 2 headers will hash using the destination MAC, source MAC
-	 * and Ethertype fields.  Packets with layer 3 (IP) headers will
-	 * hash using the destination MAC, source MAC, IP protocol/next
-	 * header, source IP address and destination IP address. Packets
-	 * with layer 4 (TCP/UDP) headers will hash using the destination
-	 * MAC, source MAC, IP protocol/next header, source IP address,
-	 * destination IP address, source port and destination port fields.
+	 * Perform a normal package installation. Conditional installation
+	 * directives (e.g. 'create' and 'replace') of packaged items
+	 * will be followed.
 	 */
-	#define HWRM_CFA_LAG_GROUP_MEMBER_RGTR_INPUT_MODE_BALANCE_XOR   UINT32_C(0x2)
-	/* Transmit packets on all specified ports. */
-	#define HWRM_CFA_LAG_GROUP_MEMBER_RGTR_INPUT_MODE_BROADCAST	UINT32_C(0x3)
-	#define HWRM_CFA_LAG_GROUP_MEMBER_RGTR_INPUT_MODE_LAST	HWRM_CFA_LAG_GROUP_MEMBER_RGTR_INPUT_MODE_BROADCAST
+	#define HWRM_NVM_INSTALL_UPDATE_INPUT_INSTALL_TYPE_NORMAL UINT32_C(0x0)
 	/*
-	 * Supports up to 5 ports. bit0 = port 0, bit1 = port 1,
-	 * bit2 = port 2, bit3 = port 4, bit4 = loopback port
+	 * Install all packaged items regardless of installation directive
+	 * (i.e. treat all packaged items as though they have an installation
+	 * directive of 'install').
 	 */
-	uint8_t	port_bitmap;
-	/* Specify the active port when active-backup mode is specified */
-	uint8_t	active_port;
-	uint8_t	unused_0[5];
-} hwrm_cfa_lag_group_member_rgtr_input_t, *phwrm_cfa_lag_group_member_rgtr_input_t;
+	#define HWRM_NVM_INSTALL_UPDATE_INPUT_INSTALL_TYPE_ALL	UINT32_C(0xffffffff)
+	#define HWRM_NVM_INSTALL_UPDATE_INPUT_INSTALL_TYPE_LAST  HWRM_NVM_INSTALL_UPDATE_INPUT_INSTALL_TYPE_ALL
+	uint16_t	flags;
+	/*
+	 * If set to 1, then securely erase all unused locations in
+	 * persistent storage.
+	 */
+	#define HWRM_NVM_INSTALL_UPDATE_INPUT_FLAGS_ERASE_UNUSED_SPACE	UINT32_C(0x1)
+	/*
+	 * If set to 1, then unspecified images, images not in the package
+	 * file, will be safely deleted.
+	 * When combined with erase_unused_space then unspecified images will
+	 * be securely erased.
+	 */
+	#define HWRM_NVM_INSTALL_UPDATE_INPUT_FLAGS_REMOVE_UNUSED_PKG	UINT32_C(0x2)
+	/*
+	 * If set to 1, FW will defragment the NVM if defragmentation is
+	 * required for the update.
+	 * Allow additional time for this command to complete if this bit is
+	 * set to 1.
+	 */
+	#define HWRM_NVM_INSTALL_UPDATE_INPUT_FLAGS_ALLOWED_TO_DEFRAG	UINT32_C(0x4)
+	/*
+	 * If set to 1, FW will verify the package in the "UPDATE" NVM item
+	 * without installing it. This flag is for FW internal use only.
+	 * Users should not set this flag. The request will otherwise fail.
+	 */
+	#define HWRM_NVM_INSTALL_UPDATE_INPUT_FLAGS_VERIFY_ONLY		UINT32_C(0x8)
+	uint8_t	unused_0[2];
+} hwrm_nvm_install_update_input_t, *phwrm_nvm_install_update_input_t;
 
-/* hwrm_cfa_lag_group_member_rgtr_output (size:128b/16B) */
+/* hwrm_nvm_install_update_output (size:192b/24B) */
 
-typedef struct hwrm_cfa_lag_group_member_rgtr_output {
+typedef struct hwrm_nvm_install_update_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -40663,28 +67829,142 @@ typedef struct hwrm_cfa_lag_group_member_rgtr_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* lag group ID configured for the function */
-	uint16_t	lag_id;
-	uint8_t	unused_0[5];
+	/*
+	 * Bit-mask of successfully installed items.
+	 * Bit-0 corresponding to the first packaged item, Bit-1 for the second
+	 * item, etc. A value of 0 indicates that no items were successfully
+	 * installed.
+	 */
+	uint64_t	installed_items;
+	/* result is 8 b corresponding to BCMRETVAL error codes */
+	uint8_t	result;
+	/* There was no problem with the package installation. */
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESULT_SUCCESS			UINT32_C(0x0)
+	/* Generic failure */
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESULT_FAILURE			UINT32_C(0xff)
+	/* Allocation error malloc failure */
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESULT_MALLOC_FAILURE		UINT32_C(0xfd)
+	/* NVM install error due to invalid index */
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESULT_INVALID_INDEX_PARAMETER	UINT32_C(0xfb)
+	/* NVM install error due to invalid type */
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESULT_INVALID_TYPE_PARAMETER	UINT32_C(0xf3)
+	/* Invalid package due to invalid prerequisite */
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESULT_INVALID_PREREQUISITE	UINT32_C(0xf2)
+	/* Invalid package due to invalid file header */
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESULT_INVALID_FILE_HEADER	UINT32_C(0xec)
+	/* Invalid package due to invalid format */
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESULT_INVALID_SIGNATURE		UINT32_C(0xeb)
+	/* Invalid package due to invalid property stream */
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESULT_INVALID_PROP_STREAM	UINT32_C(0xea)
+	/* Invalid package due to invalid property length */
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESULT_INVALID_PROP_LENGTH	UINT32_C(0xe9)
+	/* Invalid package due to invalid manifest */
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESULT_INVALID_MANIFEST		UINT32_C(0xe8)
+	/* Invalid package due to invalid trailer */
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESULT_INVALID_TRAILER		UINT32_C(0xe7)
+	/* Invalid package due to invalid checksum */
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESULT_INVALID_CHECKSUM		UINT32_C(0xe6)
+	/* Invalid package due to invalid item checksum */
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESULT_INVALID_ITEM_CHECKSUM	UINT32_C(0xe5)
+	/* Invalid package due to invalid length */
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESULT_INVALID_DATA_LENGTH	UINT32_C(0xe4)
+	/* Invalid package due to invalid directive */
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESULT_INVALID_DIRECTIVE		UINT32_C(0xe1)
+	/* Invalid device due to unsupported chip revision */
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESULT_UNSUPPORTED_CHIP_REV	UINT32_C(0xce)
+	/* Invalid device due to unsupported device ID */
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESULT_UNSUPPORTED_DEVICE_ID	UINT32_C(0xcd)
+	/* Invalid device due to unsupported subsystem vendor */
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESULT_UNSUPPORTED_SUBSYS_VENDOR	UINT32_C(0xcc)
+	/* Invalid device due to unsupported subsystem ID */
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESULT_UNSUPPORTED_SUBSYS_ID	UINT32_C(0xcb)
+	/* Invalid device due to unsupported product ID or customer ID */
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESULT_UNSUPPORTED_PLATFORM	UINT32_C(0xc5)
+	/* Invalid package due to duplicate item */
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESULT_DUPLICATE_ITEM		UINT32_C(0xc4)
+	/* Invalid package due to zero length item */
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESULT_ZERO_LENGTH_ITEM		UINT32_C(0xc3)
+	/* NVM integrity error checksum */
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESULT_INSTALL_CHECKSUM_ERROR	UINT32_C(0xb9)
+	/* NVM integrity error */
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESULT_INSTALL_DATA_ERROR	UINT32_C(0xb8)
+	/* Authentication error */
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESULT_INSTALL_AUTHENTICATION_ERROR UINT32_C(0xb7)
+	/* NVM install error item not found */
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESULT_ITEM_NOT_FOUND		UINT32_C(0xb0)
+	/* NVM install error item locked */
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESULT_ITEM_LOCKED		UINT32_C(0xa7)
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESULT_LAST			HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESULT_ITEM_LOCKED
+	/* problem_item is 8 b */
+	uint8_t	problem_item;
+	/* There was no problem with any packaged items. */
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_PROBLEM_ITEM_NONE	UINT32_C(0x0)
+	/* There was a problem with the NVM package itself. */
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_PROBLEM_ITEM_PACKAGE UINT32_C(0xff)
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_PROBLEM_ITEM_LAST   HWRM_NVM_INSTALL_UPDATE_OUTPUT_PROBLEM_ITEM_PACKAGE
+	/* reset_required is 8 b */
+	uint8_t	reset_required;
+	/*
+	 * No reset is required for installed/updated firmware or
+	 * microcode to take effect.
+	 */
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESET_REQUIRED_NONE  UINT32_C(0x0)
+	/*
+	 * A PCIe reset (e.g. system reboot) is
+	 * required for newly installed/updated firmware or
+	 * microcode to take effect.
+	 */
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESET_REQUIRED_PCI   UINT32_C(0x1)
+	/*
+	 * A controller power reset (e.g. system power-cycle) is
+	 * required for newly installed/updated firmware or
+	 * microcode to take effect. Some newly installed/updated
+	 * firmware or microcode may still take effect upon the
+	 * next PCIe reset.
+	 */
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESET_REQUIRED_POWER UINT32_C(0x2)
+	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESET_REQUIRED_LAST HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESET_REQUIRED_POWER
+	uint8_t	unused_0[4];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_lag_group_member_rgtr_output_t, *phwrm_cfa_lag_group_member_rgtr_output_t;
+} hwrm_nvm_install_update_output_t, *phwrm_nvm_install_update_output_t;
 
-/************************************
- * hwrm_cfa_lag_group_member_unrgtr *
- ************************************/
+/* hwrm_nvm_install_update_cmd_err (size:64b/8B) */
+
+typedef struct hwrm_nvm_install_update_cmd_err {
+	/*
+	 * command specific error codes that goes to
+	 * the cmd_err field in Common HWRM Error Response.
+	 */
+	uint8_t	code;
+	/* Unknown error */
+	#define HWRM_NVM_INSTALL_UPDATE_CMD_ERR_CODE_UNKNOWN		UINT32_C(0x0)
+	/* Unable to complete operation due to fragmentation */
+	#define HWRM_NVM_INSTALL_UPDATE_CMD_ERR_CODE_FRAG_ERR	UINT32_C(0x1)
+	/* nvm is completely full. */
+	#define HWRM_NVM_INSTALL_UPDATE_CMD_ERR_CODE_NO_SPACE	UINT32_C(0x2)
+	/* Firmware update failed due to Anti-rollback. */
+	#define HWRM_NVM_INSTALL_UPDATE_CMD_ERR_CODE_ANTI_ROLLBACK	UINT32_C(0x3)
+	/* Firmware update does not support voltage regulators on the device. */
+	#define HWRM_NVM_INSTALL_UPDATE_CMD_ERR_CODE_NO_VOLTREG_SUPPORT UINT32_C(0x4)
+	#define HWRM_NVM_INSTALL_UPDATE_CMD_ERR_CODE_LAST		HWRM_NVM_INSTALL_UPDATE_CMD_ERR_CODE_NO_VOLTREG_SUPPORT
+	uint8_t	unused_0[7];
+} hwrm_nvm_install_update_cmd_err_t, *phwrm_nvm_install_update_cmd_err_t;
+
+/******************
+ * hwrm_nvm_flush *
+ ******************/
 
 
-/* hwrm_cfa_lag_group_member_unrgtr_input (size:192b/24B) */
+/* hwrm_nvm_flush_input (size:128b/16B) */
 
-typedef struct hwrm_cfa_lag_group_member_unrgtr_input {
+typedef struct hwrm_nvm_flush_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -40713,14 +67993,11 @@ typedef struct hwrm_cfa_lag_group_member_unrgtr_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* lag group ID configured for the function */
-	uint16_t	lag_id;
-	uint8_t	unused_0[6];
-} hwrm_cfa_lag_group_member_unrgtr_input_t, *phwrm_cfa_lag_group_member_unrgtr_input_t;
+} hwrm_nvm_flush_input_t, *phwrm_nvm_flush_input_t;
 
-/* hwrm_cfa_lag_group_member_unrgtr_output (size:128b/16B) */
+/* hwrm_nvm_flush_output (size:128b/16B) */
 
-typedef struct hwrm_cfa_lag_group_member_unrgtr_output {
+typedef struct hwrm_nvm_flush_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -40733,22 +68010,37 @@ typedef struct hwrm_cfa_lag_group_member_unrgtr_output {
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_cfa_lag_group_member_unrgtr_output_t, *phwrm_cfa_lag_group_member_unrgtr_output_t;
+} hwrm_nvm_flush_output_t, *phwrm_nvm_flush_output_t;
 
-/***********
- * hwrm_tf *
- ***********/
+/* hwrm_nvm_flush_cmd_err (size:64b/8B) */
+
+typedef struct hwrm_nvm_flush_cmd_err {
+	/*
+	 * command specific error codes that goes to
+	 * the cmd_err field in Common HWRM Error Response.
+	 */
+	uint8_t	code;
+	/* Unknown error */
+	#define HWRM_NVM_FLUSH_CMD_ERR_CODE_UNKNOWN UINT32_C(0x0)
+	/* flush could not be performed */
+	#define HWRM_NVM_FLUSH_CMD_ERR_CODE_FAIL	UINT32_C(0x1)
+	#define HWRM_NVM_FLUSH_CMD_ERR_CODE_LAST   HWRM_NVM_FLUSH_CMD_ERR_CODE_FAIL
+	uint8_t	unused_0[7];
+} hwrm_nvm_flush_cmd_err_t, *phwrm_nvm_flush_cmd_err_t;
 
+/*************************
+ * hwrm_nvm_get_variable *
+ *************************/
 
-/* hwrm_tf_input (size:1024b/128B) */
 
-typedef struct hwrm_tf_input {
+/* hwrm_nvm_get_variable_input (size:320b/40B) */
+
+typedef struct hwrm_nvm_get_variable_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -40777,19 +68069,48 @@ typedef struct hwrm_tf_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* TF message type. */
-	uint16_t	type;
-	/* TF message subtype. */
-	uint16_t	subtype;
-	/* unused. */
-	uint8_t	unused0[4];
-	/* TF request data. */
-	uint32_t	req[26];
-} hwrm_tf_input_t, *phwrm_tf_input_t;
+	/*
+	 * This is the host address where
+	 * nvm variable will be stored
+	 */
+	uint64_t	dest_data_addr;
+	/* size of data in bits */
+	uint16_t	data_len;
+	/* nvm cfg option number */
+	uint16_t	option_num;
+	/* reserved. */
+	#define HWRM_NVM_GET_VARIABLE_INPUT_OPTION_NUM_RSVD_0	UINT32_C(0x0)
+	/* reserved. */
+	#define HWRM_NVM_GET_VARIABLE_INPUT_OPTION_NUM_RSVD_FFFF UINT32_C(0xffff)
+	#define HWRM_NVM_GET_VARIABLE_INPUT_OPTION_NUM_LAST	HWRM_NVM_GET_VARIABLE_INPUT_OPTION_NUM_RSVD_FFFF
+	/*
+	 * Number of dimensions for this nvm configuration variable.
+	 * This value indicates how many of the indexN values to use.
+	 * A value of 0 means that none of the indexN values are valid.
+	 * A value of 1 requires at index0 is valued, a value of 2
+	 * requires that index0 and index1 are valid, and so forth
+	 */
+	uint16_t	dimensions;
+	/* index for the 1st dimensions */
+	uint16_t	index_0;
+	/* index for the 2nd dimensions */
+	uint16_t	index_1;
+	/* index for the 3rd dimensions */
+	uint16_t	index_2;
+	/* index for the 4th dimensions */
+	uint16_t	index_3;
+	uint8_t	flags;
+	/*
+	 * When this bit is set to 1, the factory default value will be
+	 * returned, 0 returns the operational value.
+	 */
+	#define HWRM_NVM_GET_VARIABLE_INPUT_FLAGS_FACTORY_DFLT	UINT32_C(0x1)
+	uint8_t	unused_0;
+} hwrm_nvm_get_variable_input_t, *phwrm_nvm_get_variable_input_t;
 
-/* hwrm_tf_output (size:5632b/704B) */
+/* hwrm_nvm_get_variable_output (size:128b/16B) */
 
-typedef struct hwrm_tf_output {
+typedef struct hwrm_nvm_get_variable_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -40798,35 +68119,62 @@ typedef struct hwrm_tf_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* TF message type. */
-	uint16_t	type;
-	/* TF message subtype. */
-	uint16_t	subtype;
-	/* TF response code */
-	uint32_t	resp_code;
-	/* TF response data. */
-	uint32_t	resp[170];
-	/* unused. */
-	uint8_t	unused1[7];
+	/* size of data of the actual variable retrieved in bits */
+	uint16_t	data_len;
 	/*
-	 * This field is used in Output records to indicate that the
-	 * output is completely written to RAM. This field should be
-	 * read as '1' to indicate that the output has been
-	 * completely written.  When writing a command completion or
-	 * response to an internal processor, the order of writes has
-	 * to be such that this field is written last.
+	 * option_num is the option number for the data retrieved. It is
+	 * possible in the future that the option number returned would be
+	 * different than requested. This condition could occur if an option is
+	 * deprecated and a new option id is defined with similar
+	 * characteristics, but has a slightly different definition. This
+	 * also makes it convenient for the caller to identify the variable
+	 * result with the option id from the response.
+	 */
+	uint16_t	option_num;
+	/* reserved. */
+	#define HWRM_NVM_GET_VARIABLE_OUTPUT_OPTION_NUM_RSVD_0	UINT32_C(0x0)
+	/* reserved. */
+	#define HWRM_NVM_GET_VARIABLE_OUTPUT_OPTION_NUM_RSVD_FFFF UINT32_C(0xffff)
+	#define HWRM_NVM_GET_VARIABLE_OUTPUT_OPTION_NUM_LAST	HWRM_NVM_GET_VARIABLE_OUTPUT_OPTION_NUM_RSVD_FFFF
+	uint8_t	unused_0[3];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_tf_output_t, *phwrm_tf_output_t;
+} hwrm_nvm_get_variable_output_t, *phwrm_nvm_get_variable_output_t;
 
-/***********************
- * hwrm_tf_version_get *
- ***********************/
+/* hwrm_nvm_get_variable_cmd_err (size:64b/8B) */
+
+typedef struct hwrm_nvm_get_variable_cmd_err {
+	/*
+	 * command specific error codes that goes to
+	 * the cmd_err field in Common HWRM Error Response.
+	 */
+	uint8_t	code;
+	/* Unknown error */
+	#define HWRM_NVM_GET_VARIABLE_CMD_ERR_CODE_UNKNOWN	UINT32_C(0x0)
+	/* variable does not exist */
+	#define HWRM_NVM_GET_VARIABLE_CMD_ERR_CODE_VAR_NOT_EXIST UINT32_C(0x1)
+	/* configuration is corrupted and the variable cannot be saved */
+	#define HWRM_NVM_GET_VARIABLE_CMD_ERR_CODE_CORRUPT_VAR   UINT32_C(0x2)
+	/* length specified is too small */
+	#define HWRM_NVM_GET_VARIABLE_CMD_ERR_CODE_LEN_TOO_SHORT UINT32_C(0x3)
+	#define HWRM_NVM_GET_VARIABLE_CMD_ERR_CODE_LAST	HWRM_NVM_GET_VARIABLE_CMD_ERR_CODE_LEN_TOO_SHORT
+	uint8_t	unused_0[7];
+} hwrm_nvm_get_variable_cmd_err_t, *phwrm_nvm_get_variable_cmd_err_t;
 
+/*************************
+ * hwrm_nvm_set_variable *
+ *************************/
 
-/* hwrm_tf_version_get_input (size:128b/16B) */
 
-typedef struct hwrm_tf_version_get_input {
+/* hwrm_nvm_set_variable_input (size:320b/40B) */
+
+typedef struct hwrm_nvm_set_variable_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -40855,11 +68203,64 @@ typedef struct hwrm_tf_version_get_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-} hwrm_tf_version_get_input_t, *phwrm_tf_version_get_input_t;
+	/*
+	 * This is the host address where
+	 * nvm variable will be copied from
+	 */
+	uint64_t	src_data_addr;
+	/* size of data in bits */
+	uint16_t	data_len;
+	/* nvm cfg option number */
+	uint16_t	option_num;
+	/* reserved. */
+	#define HWRM_NVM_SET_VARIABLE_INPUT_OPTION_NUM_RSVD_0	UINT32_C(0x0)
+	/* reserved. */
+	#define HWRM_NVM_SET_VARIABLE_INPUT_OPTION_NUM_RSVD_FFFF UINT32_C(0xffff)
+	#define HWRM_NVM_SET_VARIABLE_INPUT_OPTION_NUM_LAST	HWRM_NVM_SET_VARIABLE_INPUT_OPTION_NUM_RSVD_FFFF
+	/*
+	 * Number of dimensions for this nvm configuration variable.
+	 * This value indicates how many of the indexN values to use.
+	 * A value of 0 means that none of the indexN values are valid.
+	 * A value of 1 requires at index0 is valued, a value of 2
+	 * requires that index0 and index1 are valid, and so forth
+	 */
+	uint16_t	dimensions;
+	/* index for the 1st dimensions */
+	uint16_t	index_0;
+	/* index for the 2nd dimensions */
+	uint16_t	index_1;
+	/* index for the 3rd dimensions */
+	uint16_t	index_2;
+	/* index for the 4th dimensions */
+	uint16_t	index_3;
+	uint8_t	flags;
+	/*
+	 * When this bit is 1, flush internal cache after this write
+	 * operation (see hwrm_nvm_flush command.)
+	 */
+	#define HWRM_NVM_SET_VARIABLE_INPUT_FLAGS_FORCE_FLUSH		UINT32_C(0x1)
+	/* encryption method */
+	#define HWRM_NVM_SET_VARIABLE_INPUT_FLAGS_ENCRYPT_MODE_MASK	UINT32_C(0xe)
+	#define HWRM_NVM_SET_VARIABLE_INPUT_FLAGS_ENCRYPT_MODE_SFT	1
+	/* No encryption. */
+		#define HWRM_NVM_SET_VARIABLE_INPUT_FLAGS_ENCRYPT_MODE_NONE		(UINT32_C(0x0) << 1)
+	/* one-way encryption. */
+		#define HWRM_NVM_SET_VARIABLE_INPUT_FLAGS_ENCRYPT_MODE_HMAC_SHA1	(UINT32_C(0x1) << 1)
+	/* symmetric AES256 encryption. */
+		#define HWRM_NVM_SET_VARIABLE_INPUT_FLAGS_ENCRYPT_MODE_AES256	(UINT32_C(0x2) << 1)
+	/* SHA1 digest appended to plaintext contents, for authentication */
+		#define HWRM_NVM_SET_VARIABLE_INPUT_FLAGS_ENCRYPT_MODE_HMAC_SHA1_AUTH  (UINT32_C(0x3) << 1)
+		#define HWRM_NVM_SET_VARIABLE_INPUT_FLAGS_ENCRYPT_MODE_LAST	HWRM_NVM_SET_VARIABLE_INPUT_FLAGS_ENCRYPT_MODE_HMAC_SHA1_AUTH
+	#define HWRM_NVM_SET_VARIABLE_INPUT_FLAGS_FLAGS_UNUSED_0_MASK	UINT32_C(0x70)
+	#define HWRM_NVM_SET_VARIABLE_INPUT_FLAGS_FLAGS_UNUSED_0_SFT	4
+	/* When this bit is 1, update the factory default region */
+	#define HWRM_NVM_SET_VARIABLE_INPUT_FLAGS_FACTORY_DEFAULT		UINT32_C(0x80)
+	uint8_t	unused_0;
+} hwrm_nvm_set_variable_input_t, *phwrm_nvm_set_variable_input_t;
 
-/* hwrm_tf_version_get_output (size:128b/16B) */
+/* hwrm_nvm_set_variable_output (size:128b/16B) */
 
-typedef struct hwrm_tf_version_get_output {
+typedef struct hwrm_nvm_set_variable_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -40868,33 +68269,43 @@ typedef struct hwrm_tf_version_get_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* Version Major number. */
-	uint8_t	major;
-	/* Version Minor number. */
-	uint8_t	minor;
-	/* Version Update number. */
-	uint8_t	update;
-	/* unused. */
-	uint8_t	unused0[4];
+	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_tf_version_get_output_t, *phwrm_tf_version_get_output_t;
+} hwrm_nvm_set_variable_output_t, *phwrm_nvm_set_variable_output_t;
 
-/************************
- * hwrm_tf_session_open *
- ************************/
+/* hwrm_nvm_set_variable_cmd_err (size:64b/8B) */
+
+typedef struct hwrm_nvm_set_variable_cmd_err {
+	/*
+	 * command specific error codes that goes to
+	 * the cmd_err field in Common HWRM Error Response.
+	 */
+	uint8_t	code;
+	/* Unknown error */
+	#define HWRM_NVM_SET_VARIABLE_CMD_ERR_CODE_UNKNOWN	UINT32_C(0x0)
+	/* variable does not exist */
+	#define HWRM_NVM_SET_VARIABLE_CMD_ERR_CODE_VAR_NOT_EXIST UINT32_C(0x1)
+	/* configuration is corrupted and the variable cannot be saved */
+	#define HWRM_NVM_SET_VARIABLE_CMD_ERR_CODE_CORRUPT_VAR   UINT32_C(0x2)
+	#define HWRM_NVM_SET_VARIABLE_CMD_ERR_CODE_LAST	HWRM_NVM_SET_VARIABLE_CMD_ERR_CODE_CORRUPT_VAR
+	uint8_t	unused_0[7];
+} hwrm_nvm_set_variable_cmd_err_t, *phwrm_nvm_set_variable_cmd_err_t;
 
+/****************************
+ * hwrm_nvm_validate_option *
+ ****************************/
 
-/* hwrm_tf_session_open_input (size:640b/80B) */
 
-typedef struct hwrm_tf_session_open_input {
+/* hwrm_nvm_validate_option_input (size:320b/40B) */
+
+typedef struct hwrm_nvm_validate_option_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -40923,13 +68334,42 @@ typedef struct hwrm_tf_session_open_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Name of the session. */
-	uint8_t	session_name[64];
-} hwrm_tf_session_open_input_t, *phwrm_tf_session_open_input_t;
+	/*
+	 * This is the host address where
+	 * nvm variable will be copied from
+	 */
+	uint64_t	src_data_addr;
+	/* size of data in bits */
+	uint16_t	data_len;
+	/* nvm cfg option number */
+	uint16_t	option_num;
+	/* reserved. */
+	#define HWRM_NVM_VALIDATE_OPTION_INPUT_OPTION_NUM_RSVD_0	UINT32_C(0x0)
+	/* reserved. */
+	#define HWRM_NVM_VALIDATE_OPTION_INPUT_OPTION_NUM_RSVD_FFFF UINT32_C(0xffff)
+	#define HWRM_NVM_VALIDATE_OPTION_INPUT_OPTION_NUM_LAST	HWRM_NVM_VALIDATE_OPTION_INPUT_OPTION_NUM_RSVD_FFFF
+	/*
+	 * Number of dimensions for this nvm configuration variable.
+	 * This value indicates how many of the indexN values to use.
+	 * A value of 0 means that none of the indexN values are valid.
+	 * A value of 1 requires at index0 is valued, a value of 2
+	 * requires that index0 and index1 are valid, and so forth
+	 */
+	uint16_t	dimensions;
+	/* index for the 1st dimensions */
+	uint16_t	index_0;
+	/* index for the 2nd dimensions */
+	uint16_t	index_1;
+	/* index for the 3rd dimensions */
+	uint16_t	index_2;
+	/* index for the 4th dimensions */
+	uint16_t	index_3;
+	uint8_t	unused_0[2];
+} hwrm_nvm_validate_option_input_t, *phwrm_nvm_validate_option_input_t;
 
-/* hwrm_tf_session_open_output (size:192b/24B) */
+/* hwrm_nvm_validate_option_output (size:128b/16B) */
 
-typedef struct hwrm_tf_session_open_output {
+typedef struct hwrm_nvm_validate_option_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -40938,56 +68378,51 @@ typedef struct hwrm_tf_session_open_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
+	uint8_t	result;
 	/*
-	 * Unique session identifier for the session created by the
-	 * firmware.
-	 */
-	uint32_t	fw_session_id;
-	/*
-	 * Unique session client identifier for the first client on
-	 * the newly created session.
-	 */
-	uint32_t	fw_session_client_id;
-	/* This field is used to return the status of fw session to host. */
-	uint32_t	flags;
-	/*
-	 * Indicates if the shared session has been created. Shared seesion
-	 * should be the first session created ever. Its fw_rm_client_id
-	 * should be 1. The AFM session's fw_rm_client_id is 0.
-	 */
-	#define HWRM_TF_SESSION_OPEN_OUTPUT_FLAGS_SHARED_SESSION		UINT32_C(0x1)
-	/*
-	 * If this bit set to 0, then it indicates the shared session
-	 * has been created by another session.
+	 * indicates that the value provided for the option is not matching
+	 * with the saved data.
 	 */
-		#define HWRM_TF_SESSION_OPEN_OUTPUT_FLAGS_SHARED_SESSION_NOT_CREATOR  UINT32_C(0x0)
+	#define HWRM_NVM_VALIDATE_OPTION_OUTPUT_RESULT_NOT_MATCH UINT32_C(0x0)
 	/*
-	 * If this bit is set to 1, then it indicates the shared session
-	 * is created by this session.
+	 * indicates that the value provided for the option is matching the
+	 * saved data.
 	 */
-		#define HWRM_TF_SESSION_OPEN_OUTPUT_FLAGS_SHARED_SESSION_CREATOR	UINT32_C(0x1)
-		#define HWRM_TF_SESSION_OPEN_OUTPUT_FLAGS_SHARED_SESSION_LAST	HWRM_TF_SESSION_OPEN_OUTPUT_FLAGS_SHARED_SESSION_CREATOR
-	/* unused. */
-	uint8_t	unused1[3];
+	#define HWRM_NVM_VALIDATE_OPTION_OUTPUT_RESULT_MATCH	UINT32_C(0x1)
+	#define HWRM_NVM_VALIDATE_OPTION_OUTPUT_RESULT_LAST	HWRM_NVM_VALIDATE_OPTION_OUTPUT_RESULT_MATCH
+	uint8_t	unused_0[6];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_nvm_validate_option_output_t, *phwrm_nvm_validate_option_output_t;
+
+/* hwrm_nvm_validate_option_cmd_err (size:64b/8B) */
+
+typedef struct hwrm_nvm_validate_option_cmd_err {
+	/*
+	 * command specific error codes that goes to
+	 * the cmd_err field in Common HWRM Error Response.
 	 */
-	uint8_t	valid;
-} hwrm_tf_session_open_output_t, *phwrm_tf_session_open_output_t;
+	uint8_t	code;
+	/* Unknown error */
+	#define HWRM_NVM_VALIDATE_OPTION_CMD_ERR_CODE_UNKNOWN UINT32_C(0x0)
+	#define HWRM_NVM_VALIDATE_OPTION_CMD_ERR_CODE_LAST   HWRM_NVM_VALIDATE_OPTION_CMD_ERR_CODE_UNKNOWN
+	uint8_t	unused_0[7];
+} hwrm_nvm_validate_option_cmd_err_t, *phwrm_nvm_validate_option_cmd_err_t;
 
-/**************************
- * hwrm_tf_session_attach *
- **************************/
+/*****************************
+ * hwrm_nvm_factory_defaults *
+ *****************************/
 
 
-/* hwrm_tf_session_attach_input (size:704b/88B) */
+/* hwrm_nvm_factory_defaults_input (size:192b/24B) */
 
-typedef struct hwrm_tf_session_attach_input {
+typedef struct hwrm_nvm_factory_defaults_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -41016,26 +68451,40 @@ typedef struct hwrm_tf_session_attach_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
+	/* mode is 8 b */
+	uint8_t	mode;
 	/*
-	 * Unique session identifier for the session that the attach
-	 * request want to attach to. This value originates from the
-	 * shared session memory that the attach request opened by
-	 * way of the 'attach name' that was passed in to the core
-	 * attach API.
-	 * The fw_session_id of the attach session includes PCIe bus
-	 * info to distinguish the PF and session info to identify
-	 * the associated TruFlow session.
+	 * If set to 1, it triggers restoration of factory default data.
+	 * If the selection field is zero, all data are restored to default.
+	 * If the selection field is non-zero, only the selected data are
+	 * restored.
 	 */
-	uint32_t	attach_fw_session_id;
-	/* unused. */
-	uint32_t	unused0;
-	/* Name of the session it self. */
-	uint8_t	session_name[64];
-} hwrm_tf_session_attach_input_t, *phwrm_tf_session_attach_input_t;
+	#define HWRM_NVM_FACTORY_DEFAULTS_INPUT_MODE_RESTORE UINT32_C(0x0)
+	/*
+	 * If set to 1, it triggers creation of factory default data.
+	 * If the selection field is zero, all default data are created.
+	 * If the selection field is non-zero, only the selected data are
+	 * created.
+	 */
+	#define HWRM_NVM_FACTORY_DEFAULTS_INPUT_MODE_CREATE  UINT32_C(0x1)
+	#define HWRM_NVM_FACTORY_DEFAULTS_INPUT_MODE_LAST   HWRM_NVM_FACTORY_DEFAULTS_INPUT_MODE_CREATE
+	uint8_t	unused_0[1];
+	/*
+	 * This field selects which data the factory default operation applies.
+	 * If it is '0', the operation applies to all data. If it is not '0',
+	 * the operation only applies to the data selected by this field.
+	 */
+	uint16_t	selection;
+	/* When this bit is '1', config option is selected. */
+	#define HWRM_NVM_FACTORY_DEFAULTS_INPUT_SELECTION_CFG_OPTION	UINT32_C(0x1)
+	/* When this bit is '1', crashdump is selected. */
+	#define HWRM_NVM_FACTORY_DEFAULTS_INPUT_SELECTION_CRASHDUMP	UINT32_C(0x2)
+	uint8_t	unused_1[4];
+} hwrm_nvm_factory_defaults_input_t, *phwrm_nvm_factory_defaults_input_t;
 
-/* hwrm_tf_session_attach_output (size:128b/16B) */
+/* hwrm_nvm_factory_defaults_output (size:128b/16B) */
 
-typedef struct hwrm_tf_session_attach_output {
+typedef struct hwrm_nvm_factory_defaults_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -41044,35 +68493,51 @@ typedef struct hwrm_tf_session_attach_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/*
-	 * Unique session identifier for the session created by the
-	 * firmware. It includes PCIe bus info to distinguish the PF
-	 * and session info to identify the associated TruFlow
-	 * session. This fw_session_id is unique to the attach
-	 * request.
-	 */
-	uint32_t	fw_session_id;
-	/* unused. */
-	uint8_t	unused0[3];
+	uint8_t	result;
+	/* factory defaults created successfully. */
+	#define HWRM_NVM_FACTORY_DEFAULTS_OUTPUT_RESULT_CREATE_OK	UINT32_C(0x0)
+	/* factory defaults restored successfully. */
+	#define HWRM_NVM_FACTORY_DEFAULTS_OUTPUT_RESULT_RESTORE_OK	UINT32_C(0x1)
+	/* factory defaults already created. */
+	#define HWRM_NVM_FACTORY_DEFAULTS_OUTPUT_RESULT_CREATE_ALREADY UINT32_C(0x2)
+	#define HWRM_NVM_FACTORY_DEFAULTS_OUTPUT_RESULT_LAST	HWRM_NVM_FACTORY_DEFAULTS_OUTPUT_RESULT_CREATE_ALREADY
+	uint8_t	unused_0[6];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_tf_session_attach_output_t, *phwrm_tf_session_attach_output_t;
+} hwrm_nvm_factory_defaults_output_t, *phwrm_nvm_factory_defaults_output_t;
+
+/* hwrm_nvm_factory_defaults_cmd_err (size:64b/8B) */
+
+typedef struct hwrm_nvm_factory_defaults_cmd_err {
+	/*
+	 * command specific error codes that goes to
+	 * the cmd_err field in Common HWRM Error Response.
+	 */
+	uint8_t	code;
+	/* Unknown error */
+	#define HWRM_NVM_FACTORY_DEFAULTS_CMD_ERR_CODE_UNKNOWN	UINT32_C(0x0)
+	/* valid configuration not present to create defaults */
+	#define HWRM_NVM_FACTORY_DEFAULTS_CMD_ERR_CODE_NO_VALID_CFG UINT32_C(0x1)
+	/* No saved configuration present to restore, restore failed */
+	#define HWRM_NVM_FACTORY_DEFAULTS_CMD_ERR_CODE_NO_SAVED_CFG UINT32_C(0x2)
+	#define HWRM_NVM_FACTORY_DEFAULTS_CMD_ERR_CODE_LAST	HWRM_NVM_FACTORY_DEFAULTS_CMD_ERR_CODE_NO_SAVED_CFG
+	uint8_t	unused_0[7];
+} hwrm_nvm_factory_defaults_cmd_err_t, *phwrm_nvm_factory_defaults_cmd_err_t;
 
 /****************************
- * hwrm_tf_session_register *
+ * hwrm_nvm_req_arbitration *
  ****************************/
 
 
-/* hwrm_tf_session_register_input (size:704b/88B) */
+/* hwrm_nvm_req_arbitration_input (size:192b/24B) */
 
-typedef struct hwrm_tf_session_register_input {
+typedef struct hwrm_nvm_req_arbitration_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -41101,24 +68566,21 @@ typedef struct hwrm_tf_session_register_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/*
-	 * Unique session identifier for the session that the
-	 * register request want to create a new client on. This
-	 * value originates from the first open request.
-	 * The fw_session_id of the attach session includes PCIe bus
-	 * info to distinguish the PF and session info to identify
-	 * the associated TruFlow session.
-	 */
-	uint32_t	fw_session_id;
-	/* unused. */
-	uint32_t	unused0;
-	/* Name of the session client. */
-	uint8_t	session_client_name[64];
-} hwrm_tf_session_register_input_t, *phwrm_tf_session_register_input_t;
+	/* Type of NVRAM arbitration request */
+	uint8_t	type;
+	/* Query if NVRAM arbitration semaphore is acquired outside of Nitro */
+	#define HWRM_NVM_REQ_ARBITRATION_INPUT_TYPE_STATUS  UINT32_C(0x0)
+	/* Acquire NVRAM arbitration semaphore */
+	#define HWRM_NVM_REQ_ARBITRATION_INPUT_TYPE_ACQUIRE UINT32_C(0x1)
+	/* Release NVRAM arbitration semaphore */
+	#define HWRM_NVM_REQ_ARBITRATION_INPUT_TYPE_RELEASE UINT32_C(0x2)
+	#define HWRM_NVM_REQ_ARBITRATION_INPUT_TYPE_LAST   HWRM_NVM_REQ_ARBITRATION_INPUT_TYPE_RELEASE
+	uint8_t	unused_0[7];
+} hwrm_nvm_req_arbitration_input_t, *phwrm_nvm_req_arbitration_input_t;
 
-/* hwrm_tf_session_register_output (size:128b/16B) */
+/* hwrm_nvm_req_arbitration_output (size:128b/16B) */
 
-typedef struct hwrm_tf_session_register_output {
+typedef struct hwrm_nvm_req_arbitration_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -41127,33 +68589,27 @@ typedef struct hwrm_tf_session_register_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/*
-	 * Unique session client identifier for the session created
-	 * by the firmware. It includes the session the client it
-	 * attached to and session client info.
-	 */
-	uint32_t	fw_session_client_id;
-	/* unused. */
-	uint8_t	unused0[3];
+	/* NVRAM arbitration semaphore is acquired if value is 1 */
+	uint8_t	acquired;
+	uint8_t	unused_0[6];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_tf_session_register_output_t, *phwrm_tf_session_register_output_t;
+} hwrm_nvm_req_arbitration_output_t, *phwrm_nvm_req_arbitration_output_t;
 
-/******************************
- * hwrm_tf_session_unregister *
- ******************************/
+/*******************
+ * hwrm_nvm_defrag *
+ *******************/
 
 
-/* hwrm_tf_session_unregister_input (size:192b/24B) */
+/* hwrm_nvm_defrag_input (size:192b/24B) */
 
-typedef struct hwrm_tf_session_unregister_input {
+typedef struct hwrm_nvm_defrag_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -41182,21 +68638,15 @@ typedef struct hwrm_tf_session_unregister_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/*
-	 * Unique session identifier for the session that the
-	 * unregister request want to close a session client on.
-	 */
-	uint32_t	fw_session_id;
-	/*
-	 * Unique session client identifier for the session that the
-	 * unregister request want to close.
-	 */
-	uint32_t	fw_session_client_id;
-} hwrm_tf_session_unregister_input_t, *phwrm_tf_session_unregister_input_t;
+	uint32_t	flags;
+	/* This bit must be '1' to perform NVM defragmentation. */
+	#define HWRM_NVM_DEFRAG_INPUT_FLAGS_DEFRAG	UINT32_C(0x1)
+	uint8_t	unused_0[4];
+} hwrm_nvm_defrag_input_t, *phwrm_nvm_defrag_input_t;
 
-/* hwrm_tf_session_unregister_output (size:128b/16B) */
+/* hwrm_nvm_defrag_output (size:128b/16B) */
 
-typedef struct hwrm_tf_session_unregister_output {
+typedef struct hwrm_nvm_defrag_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -41205,27 +68655,41 @@ typedef struct hwrm_tf_session_unregister_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* unused. */
-	uint8_t	unused0[7];
+	uint8_t	unused_0[7];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_tf_session_unregister_output_t, *phwrm_tf_session_unregister_output_t;
+} hwrm_nvm_defrag_output_t, *phwrm_nvm_defrag_output_t;
 
-/*************************
- * hwrm_tf_session_close *
- *************************/
+/* hwrm_nvm_defrag_cmd_err (size:64b/8B) */
+
+typedef struct hwrm_nvm_defrag_cmd_err {
+	/*
+	 * command specific error codes that goes to
+	 * the cmd_err field in Common HWRM Error Response.
+	 */
+	uint8_t	code;
+	/* Unknown error */
+	#define HWRM_NVM_DEFRAG_CMD_ERR_CODE_UNKNOWN UINT32_C(0x0)
+	/* NVM defragmentation could not be performed */
+	#define HWRM_NVM_DEFRAG_CMD_ERR_CODE_FAIL	UINT32_C(0x1)
+	#define HWRM_NVM_DEFRAG_CMD_ERR_CODE_LAST   HWRM_NVM_DEFRAG_CMD_ERR_CODE_FAIL
+	uint8_t	unused_0[7];
+} hwrm_nvm_defrag_cmd_err_t, *phwrm_nvm_defrag_cmd_err_t;
+
+/*******************************
+ * hwrm_nvm_get_vpd_field_info *
+ *******************************/
 
 
-/* hwrm_tf_session_close_input (size:192b/24B) */
+/* hwrm_nvm_get_vpd_field_info_input (size:192b/24B) */
 
-typedef struct hwrm_tf_session_close_input {
+typedef struct hwrm_nvm_get_vpd_field_info_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -41254,15 +68718,20 @@ typedef struct hwrm_tf_session_close_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
-	uint32_t	fw_session_id;
-	/* unused. */
-	uint8_t	unused0[4];
-} hwrm_tf_session_close_input_t, *phwrm_tf_session_close_input_t;
+	/*
+	 * Tag ID of the requested field. To request the Product Name
+	 * a value of [0x00, 0x82] should be used. All other fields
+	 * would use the two byte hexadecimal value of the ASCII
+	 * characters. The first letter of the ASCII keyword is recorded
+	 * in tag_id[0] and the next letter in tag_id[1].
+	 */
+	uint8_t	tag_id[2];
+	uint8_t	unused_0[6];
+} hwrm_nvm_get_vpd_field_info_input_t, *phwrm_nvm_get_vpd_field_info_input_t;
 
-/* hwrm_tf_session_close_output (size:128b/16B) */
+/* hwrm_nvm_get_vpd_field_info_output (size:2176b/272B) */
 
-typedef struct hwrm_tf_session_close_output {
+typedef struct hwrm_nvm_get_vpd_field_info_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -41271,27 +68740,29 @@ typedef struct hwrm_tf_session_close_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* unused. */
-	uint8_t	unused0[7];
+	/* Data retrieved from VPD field */
+	uint8_t	data[256];
+	/* size of data retrieved in bytes */
+	uint16_t	data_len;
+	uint8_t	unused_0[5];
 	/*
 	 * This field is used in Output records to indicate that the output
 	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field
-	 * is written last.
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_tf_session_close_output_t, *phwrm_tf_session_close_output_t;
+} hwrm_nvm_get_vpd_field_info_output_t, *phwrm_nvm_get_vpd_field_info_output_t;
 
-/************************
- * hwrm_tf_session_qcfg *
- ************************/
+/*******************************
+ * hwrm_nvm_set_vpd_field_info *
+ *******************************/
 
 
-/* hwrm_tf_session_qcfg_input (size:192b/24B) */
+/* hwrm_nvm_set_vpd_field_info_input (size:256b/32B) */
 
-typedef struct hwrm_tf_session_qcfg_input {
+typedef struct hwrm_nvm_set_vpd_field_info_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -41320,15 +68791,27 @@ typedef struct hwrm_tf_session_qcfg_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
-	uint32_t	fw_session_id;
-	/* unused. */
-	uint8_t	unused0[4];
-} hwrm_tf_session_qcfg_input_t, *phwrm_tf_session_qcfg_input_t;
+	/*
+	 * This is the host address where
+	 * VPD data value will be copied from
+	 */
+	uint64_t	host_src_addr;
+	/*
+	 * Tag ID of the requested field. To request the Product Name
+	 * a value of [0x00, 0x82] should be used. All other fields
+	 * would use the two byte hexadecimal value of the ASCII
+	 * characters. The first letter of the ASCII keyword is recorded
+	 * in tag_id[0] and the next letter in tag_id[1].
+	 */
+	uint8_t	tag_id[2];
+	/* size of data in bytes */
+	uint16_t	data_len;
+	uint8_t	unused_0[4];
+} hwrm_nvm_set_vpd_field_info_input_t, *phwrm_nvm_set_vpd_field_info_input_t;
 
-/* hwrm_tf_session_qcfg_output (size:128b/16B) */
+/* hwrm_nvm_set_vpd_field_info_output (size:128b/16B) */
 
-typedef struct hwrm_tf_session_qcfg_output {
+typedef struct hwrm_nvm_set_vpd_field_info_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -41337,22748 +68820,22520 @@ typedef struct hwrm_tf_session_qcfg_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	/* RX action control settings flags. */
-	uint8_t	rx_act_flags;
+	uint8_t	unused_0[7];
 	/*
-	 * A value of 1 in this field indicates that Global Flow ID
-	 * reporting into cfa_code and cfa_metadata is enabled.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	#define HWRM_TF_SESSION_QCFG_OUTPUT_RX_ACT_FLAGS_ABCR_GFID_EN		UINT32_C(0x1)
+	uint8_t	valid;
+} hwrm_nvm_set_vpd_field_info_output_t, *phwrm_nvm_set_vpd_field_info_output_t;
+
+#define ROCE_SP_HSI_VERSION_MAJOR 1
+#define ROCE_SP_HSI_VERSION_MINOR 8
+#define ROCE_SP_HSI_VERSION_UPDATE 4
+#define ROCE_SP_HSI_VERSION_STR "1.8.4"
+/*
+ * Following is the signature for ROCE_SP_HSI message field that indicates
+ * not applicable (All F's). Need to cast it the size of the field if
+ * needed.
+ */
+#define ROCE_SP_HSI_NA_SIGNATURE ((uint32_t)(-1))
+
+/* cmdq_init (size:128b/16B) */
+
+typedef struct cmdq_init {
+	/* CMDQ PBL physical address. */
+	uint64_t	cmdq_pbl;
+	uint16_t	cmdq_size_cmdq_lvl;
+	/* CMDQ PBL indirection levels. */
+	#define CMDQ_INIT_CMDQ_LVL_MASK UINT32_C(0x3)
+	#define CMDQ_INIT_CMDQ_LVL_SFT  0
+	/* CMDQ size. */
+	#define CMDQ_INIT_CMDQ_SIZE_MASK UINT32_C(0xfffc)
+	#define CMDQ_INIT_CMDQ_SIZE_SFT 2
+	/* CREQ completion ring id. */
+	uint16_t	creq_ring_id;
+	/* Mailbox producer index. MSB must also be set. */
+	uint32_t	prod_idx;
+} cmdq_init_t, *pcmdq_init_t;
+
+/* cmdq_update (size:128b/16B) */
+
+typedef struct cmdq_update {
+	/* reserved64 is 64 b */
+	uint64_t	reserved64;
+	/* reserved32 is 32 b */
+	uint32_t	reserved32;
+	/* Mailbox producer index. */
+	uint32_t	prod_idx;
+} cmdq_update_t, *pcmdq_update_t;
+
+/* cmdq_base (size:128b/16B) */
+
+typedef struct cmdq_base {
+	/* Command opcode. */
+	uint8_t	opcode;
 	/*
-	 * A value of 1 in this field indicates that both inner and outer
-	 * are stripped and inner tag is passed.
-	 * Enabled.
+	 * Create QP command allocates QP context with the specified
+	 * SQ, RQ/SRQ, CQ and other parameters.
 	 */
-	#define HWRM_TF_SESSION_QCFG_OUTPUT_RX_ACT_FLAGS_ABCR_VTAG_DLT_BOTH	UINT32_C(0x2)
+	#define CMDQ_BASE_OPCODE_CREATE_QP			UINT32_C(0x1)
 	/*
-	 * A value of 1 in this field indicates that the re-use of
-	 * existing tunnel L2 header SMAC is enabled for
-	 * Non-tunnel L2, L2-L3 and IP-IP tunnel.
+	 * Destroy QP command deletes the QP context and ceases
+	 * any further reference.
 	 */
-	#define HWRM_TF_SESSION_QCFG_OUTPUT_RX_ACT_FLAGS_TECT_SMAC_OVR_RUTNSL2	UINT32_C(0x4)
-	/* TX Action control settings flags. */
-	uint8_t	tx_act_flags;
-	/* Disabled. */
-	#define HWRM_TF_SESSION_QCFG_OUTPUT_TX_ACT_FLAGS_ABCR_VEB_EN	UINT32_C(0x1)
+	#define CMDQ_BASE_OPCODE_DESTROY_QP			UINT32_C(0x2)
 	/*
-	 * When set to 1 any GRE tunnels will include the
-	 * optional Key field.
+	 * Modify QP command changes QP states and other QP specific
+	 * parameters.
 	 */
-	#define HWRM_TF_SESSION_QCFG_OUTPUT_TX_ACT_FLAGS_TECT_GRE_SET_K	UINT32_C(0x2)
+	#define CMDQ_BASE_OPCODE_MODIFY_QP			UINT32_C(0x3)
+	/* Query QP command retrieves info about the specified QP. */
+	#define CMDQ_BASE_OPCODE_QUERY_QP			UINT32_C(0x4)
+	/* Create SRQ command allocates a SRQ with the specified parameters. */
+	#define CMDQ_BASE_OPCODE_CREATE_SRQ			UINT32_C(0x5)
+	/* Destroy SRQ command deletes and flushes the specified SRQ. */
+	#define CMDQ_BASE_OPCODE_DESTROY_SRQ			UINT32_C(0x6)
+	/* Query SRP command retrieves info about the specified SRQ. */
+	#define CMDQ_BASE_OPCODE_QUERY_SRQ			UINT32_C(0x8)
+	/* Create CQ command allocates a CQ with the specified parameters. */
+	#define CMDQ_BASE_OPCODE_CREATE_CQ			UINT32_C(0x9)
+	/* Destroy CQ command deletes and flushes the specified CQ. */
+	#define CMDQ_BASE_OPCODE_DESTROY_CQ			UINT32_C(0xa)
+	/* Resize CQ command resizes the specified CQ. */
+	#define CMDQ_BASE_OPCODE_RESIZE_CQ			UINT32_C(0xc)
 	/*
-	 * When set to 1, for GRE tunnels, the IPV6 Traffic Class (TC)
-	 * field of the outer header is inherited from the inner header
-	 * (if present) or the fixed value as taken from the encap
-	 * record.
+	 * Allocate MRW command allocates a MR/MW with the specified parameters
+	 * and returns the region's L_KEY/R_KEY
 	 */
-	#define HWRM_TF_SESSION_QCFG_OUTPUT_TX_ACT_FLAGS_TECT_IPV6_TC_IH	UINT32_C(0x4)
+	#define CMDQ_BASE_OPCODE_ALLOCATE_MRW			UINT32_C(0xd)
 	/*
-	 * When set to 1, for GRE tunnels, the IPV4 Type Of Service (TOS)
-	 * field of the outer header is inherited from the inner header
-	 * (if present) or the fixed value as taken from the encap record.
+	 * De-allocate key command frees a MR/MW entry associated with the
+	 * specified key.
 	 */
-	#define HWRM_TF_SESSION_QCFG_OUTPUT_TX_ACT_FLAGS_TECT_IPV4_TOS_IH	UINT32_C(0x8)
-	/* unused. */
-	uint8_t	unused0[5];
+	#define CMDQ_BASE_OPCODE_DEALLOCATE_KEY		UINT32_C(0xe)
+	/* Register MR command registers memory to the specified MR. */
+	#define CMDQ_BASE_OPCODE_REGISTER_MR			UINT32_C(0xf)
+	/* Deregister MR command de-registers memory from the specified MR. */
+	#define CMDQ_BASE_OPCODE_DEREGISTER_MR		UINT32_C(0x10)
+	/* Add GID command adds a GID to the local address table. */
+	#define CMDQ_BASE_OPCODE_ADD_GID			UINT32_C(0x11)
+	/* Delete GID command deletes a GID from the local address table. */
+	#define CMDQ_BASE_OPCODE_DELETE_GID			UINT32_C(0x12)
+	/* Modify GID command modifies a GID in the local address table. */
+	#define CMDQ_BASE_OPCODE_MODIFY_GID			UINT32_C(0x17)
+	/* Query GID command queries a GID in the local address table. */
+	#define CMDQ_BASE_OPCODE_QUERY_GID			UINT32_C(0x18)
+	/* Create QP1 command allocates a QP1 only. */
+	#define CMDQ_BASE_OPCODE_CREATE_QP1			UINT32_C(0x13)
+	/* Destroy QP1 command deletes and flushes the specified QP1. */
+	#define CMDQ_BASE_OPCODE_DESTROY_QP1			UINT32_C(0x14)
+	/* Create AH command allocates an AH with the specified parameters. */
+	#define CMDQ_BASE_OPCODE_CREATE_AH			UINT32_C(0x15)
+	/* Destroy AH command deletes the specified AH. */
+	#define CMDQ_BASE_OPCODE_DESTROY_AH			UINT32_C(0x16)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field
-	 * is written last.
+	 * Initialize firmware command initializes the firmware with
+	 * the specified parameters.
 	 */
-	uint8_t	valid;
-} hwrm_tf_session_qcfg_output_t, *phwrm_tf_session_qcfg_output_t;
+	#define CMDQ_BASE_OPCODE_INITIALIZE_FW		UINT32_C(0x80)
+	/* De-initialize firmware command deinitializes the firmware. */
+	#define CMDQ_BASE_OPCODE_DEINITIALIZE_FW		UINT32_C(0x81)
+	/* Stop the function */
+	#define CMDQ_BASE_OPCODE_STOP_FUNC			UINT32_C(0x82)
+	/* Query the HW capabilities for the function. */
+	#define CMDQ_BASE_OPCODE_QUERY_FUNC			UINT32_C(0x83)
+	/*
+	 * Set the following resources for the function:
+	 * - Max QP, CQ, MR+MW, SRQ per PF
+	 * - Max QP, CQ, MR+MW, SRQ per VF
+	 */
+	#define CMDQ_BASE_OPCODE_SET_FUNC_RESOURCES		UINT32_C(0x84)
+	/*
+	 * Read the current state of any internal resource context. Can only be
+	 * issued from a PF.
+	 */
+	#define CMDQ_BASE_OPCODE_READ_CONTEXT			UINT32_C(0x85)
+	/*
+	 * Send a request from VF to pass a command to the PF. VF HSI is
+	 * suspended until the PF returns the response
+	 */
+	#define CMDQ_BASE_OPCODE_VF_BACKCHANNEL_REQUEST	UINT32_C(0x86)
+	/*
+	 * Read VF memory (primarily to get the backchannel request blob). Can
+	 * only be issued from a PF.
+	 */
+	#define CMDQ_BASE_OPCODE_READ_VF_MEMORY		UINT32_C(0x87)
+	/*
+	 * Write VF memory (primarily to put the backchannel response blob),
+	 * and reenable VF HSI (post a CAG completion to it). Can only be
+	 * issued from a PF.
+	 */
+	#define CMDQ_BASE_OPCODE_COMPLETE_VF_REQUEST		UINT32_C(0x88)
+	/*
+	 * Deprecated.
+	 * Extend resource (QPC, MRW, CQ, SRQ) array, after the host allocates
+	 * more. Can only be issued from a PF.
+	 */
+	#define CMDQ_BASE_OPCODE_EXTEND_CONTEXT_ARRAY_DEPRECATED UINT32_C(0x89)
+	/* Map TC to COS. Can only be issued from a PF. */
+	#define CMDQ_BASE_OPCODE_MAP_TC_TO_COS		UINT32_C(0x8a)
+	/* Query version. */
+	#define CMDQ_BASE_OPCODE_QUERY_VERSION		UINT32_C(0x8b)
+	/* Modify congestion control. Can only be issued from a PF. */
+	#define CMDQ_BASE_OPCODE_MODIFY_ROCE_CC		UINT32_C(0x8c)
+	/* Query congestion control. */
+	#define CMDQ_BASE_OPCODE_QUERY_ROCE_CC		UINT32_C(0x8d)
+	/* Query RoCE statistics. */
+	#define CMDQ_BASE_OPCODE_QUERY_ROCE_STATS		UINT32_C(0x8e)
+	/* Set LAG mode. */
+	#define CMDQ_BASE_OPCODE_SET_LINK_AGGR_MODE		UINT32_C(0x8f)
+	/* Modify CQ */
+	#define CMDQ_BASE_OPCODE_MODIFY_CQ			UINT32_C(0x90)
+	/*
+	 * Query QP for a PF other than the requesting PF. Also can query for
+	 * more than one QP.
+	 */
+	#define CMDQ_BASE_OPCODE_QUERY_QP_EXTEND		UINT32_C(0x91)
+	/* Query extended RoCE statistics. */
+	#define CMDQ_BASE_OPCODE_QUERY_ROCE_STATS_EXT		UINT32_C(0x92)
+	/*
+	 * This command updates the QP context id ranges on the PF,
+	 * to orchestrate QP context id range migration.
+	 * This command is valid for devices that
+	 * support the pseudo-static QP allocation feature.
+	 */
+	#define CMDQ_BASE_OPCODE_ORCHESTRATE_QID_MIGRATION	UINT32_C(0x93)
+	/*
+	 * This command allocates a batch of the requested count of QPs
+	 * in a sequential range.
+	 */
+	#define CMDQ_BASE_OPCODE_CREATE_QP_BATCH		UINT32_C(0x94)
+	/*
+	 * This command deletes a batch of the requested count of QPs.
+	 * The starting QP ID can be specified to request a batch deletion
+	 * of a sequential range.
+	 */
+	#define CMDQ_BASE_OPCODE_DESTROY_QP_BATCH		UINT32_C(0x95)
+	/*
+	 * This command allocates an extended RoCE statistics context
+	 * that supports periodic DMA to a host address. The extended
+	 * statistics context id can be assigned by the driver
+	 * via `create_qp`, `create_qp_batch`, or `modify_qp` to a specific QP,
+	 * a subset of QPs or to all QPs of a specific function.
+	 * These statistics can be queried via `query_roce_stats_ext_v2`.
+	 */
+	#define CMDQ_BASE_OPCODE_ALLOCATE_ROCE_STATS_EXT_CTX	UINT32_C(0x96)
+	/* This command deallocates an extended RoCE statistics context. */
+	#define CMDQ_BASE_OPCODE_DEALLOCATE_ROCE_STATS_EXT_CTX   UINT32_C(0x97)
+	/*
+	 * This command queries extended RoCE statistics for context
+	 * allocated via `allocate_roce_stats_ext_ctx`.
+	 */
+	#define CMDQ_BASE_OPCODE_QUERY_ROCE_STATS_EXT_V2	UINT32_C(0x98)
+	#define CMDQ_BASE_OPCODE_LAST			CMDQ_BASE_OPCODE_QUERY_ROCE_STATS_EXT_V2
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+} cmdq_base_t, *pcmdq_base_t;
 
-/******************************
- * hwrm_tf_session_resc_qcaps *
- ******************************/
+/* creq_base (size:128b/16B) */
+
+typedef struct creq_base {
+	uint8_t	type;
+	/*
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
+	 */
+	#define CREQ_BASE_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_BASE_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_BASE_TYPE_QP_EVENT	UINT32_C(0x38)
+	/* Function Async Notification */
+		#define CREQ_BASE_TYPE_FUNC_EVENT  UINT32_C(0x3a)
+		#define CREQ_BASE_TYPE_LAST	CREQ_BASE_TYPE_FUNC_EVENT
+	uint8_t	reserved56[7];
+	uint8_t	v;
+	/*
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
+	 */
+	#define CREQ_BASE_V	UINT32_C(0x1)
+	/* This is the modifier on to the type field. */
+	uint8_t	event;
+	uint8_t	reserved48[6];
+} creq_base_t, *pcreq_base_t;
 
+/* creq_resp_sb_hdr (size:64b/8B) */
 
-/* hwrm_tf_session_resc_qcaps_input (size:256b/32B) */
+typedef struct creq_resp_sb_hdr {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Query QP command response. */
+	#define CREQ_RESP_SB_HDR_OPCODE_QUERY_QP		UINT32_C(0x4)
+	/* Query SRQ command response. */
+	#define CREQ_RESP_SB_HDR_OPCODE_QUERY_SRQ		UINT32_C(0x8)
+	/* Query GID command response. */
+	#define CREQ_RESP_SB_HDR_OPCODE_QUERY_GID		UINT32_C(0x18)
+	/* Query info PF command response */
+	#define CREQ_RESP_SB_HDR_OPCODE_QUERY_FUNC		UINT32_C(0x83)
+	/* Query version response. */
+	#define CREQ_RESP_SB_HDR_OPCODE_QUERY_VERSION	UINT32_C(0x8b)
+	/* Query congestion control response. */
+	#define CREQ_RESP_SB_HDR_OPCODE_QUERY_ROCE_CC	UINT32_C(0x8d)
+	/* Query RoCE statistics response. */
+	#define CREQ_RESP_SB_HDR_OPCODE_QUERY_ROCE_STATS	UINT32_C(0x8e)
+	/* Query QP extended response. */
+	#define CREQ_RESP_SB_HDR_OPCODE_QUERY_QP_EXTEND	UINT32_C(0x91)
+	/* Query extended RoCE statistics response. */
+	#define CREQ_RESP_SB_HDR_OPCODE_QUERY_ROCE_STATS_EXT	UINT32_C(0x92)
+	/* Query extended RoCE statistics v2 response. */
+	#define CREQ_RESP_SB_HDR_OPCODE_QUERY_ROCE_STATS_EXT_V2 UINT32_C(0x98)
+	#define CREQ_RESP_SB_HDR_OPCODE_LAST		CREQ_RESP_SB_HDR_OPCODE_QUERY_ROCE_STATS_EXT_V2
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+} creq_resp_sb_hdr_t, *pcreq_resp_sb_hdr_t;
 
-typedef struct hwrm_tf_session_resc_qcaps_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+/*
+ * Structure to be used for the qp_params array of
+ * the `create_qp_batch` command.
+ */
+/* create_qp_batch_data (size:768b/96B) */
+
+typedef struct create_qp_batch_data {
+	/* QP handle. */
+	uint64_t	qp_handle;
+	/* Create QP flags. */
+	uint32_t	qp_flags;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * SRQ is used.
+	 * This flag is not supported on express mode QPs.
 	 */
-	uint16_t	cmpl_ring;
+	#define CREATE_QP_BATCH_DATA_QP_FLAGS_SRQ_USED		UINT32_C(0x1)
+	/* post CQE for all SQ WQEs. */
+	#define CREATE_QP_BATCH_DATA_QP_FLAGS_FORCE_COMPLETION	UINT32_C(0x2)
+	/* This QP can use reserved L_Key */
+	#define CREATE_QP_BATCH_DATA_QP_FLAGS_RESERVED_LKEY_ENABLE	UINT32_C(0x4)
+	/* This QP can fast register physical memory */
+	#define CREATE_QP_BATCH_DATA_QP_FLAGS_FR_PMR_ENABLED		UINT32_C(0x8)
+	/* This QP can send variable sized WQEs. */
+	#define CREATE_QP_BATCH_DATA_QP_FLAGS_VARIABLE_SIZED_WQE_ENABLED UINT32_C(0x10)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * WQEs with inline data sent on this QP are able to flow
+	 * through an optimized transmit path to lower latency. This
+	 * transmit path is opportunistic and not guaranteed to always
+	 * occur.
 	 */
-	uint16_t	seq_id;
+	#define CREATE_QP_BATCH_DATA_QP_FLAGS_OPTIMIZED_TRANSMIT_ENABLED UINT32_C(0x20)
+	/*
+	 * For UD QPs the default responder CQE format is `cq_res_ud`.
+	 * This flag specifies the `cq_res_ud_cfa` format to be used
+	 * instead.
+	 */
+	#define CREATE_QP_BATCH_DATA_QP_FLAGS_RESPONDER_UD_CQE_WITH_CFA  UINT32_C(0x40)
+	/*
+	 * This QP must be included in the extended RoCE statistics
+	 * that can be queried via `query_roce_stats_ext`.
+	 */
+	#define CREATE_QP_BATCH_DATA_QP_FLAGS_EXT_STATS_ENABLED	UINT32_C(0x80)
+	/* This QP uses express mode. */
+	#define CREATE_QP_BATCH_DATA_QP_FLAGS_EXPRESS_MODE_ENABLED	UINT32_C(0x100)
+	/* This QP uses the steering tag specified in the command. */
+	#define CREATE_QP_BATCH_DATA_QP_FLAGS_STEERING_TAG_VALID	UINT32_C(0x200)
+	/*
+	 * This QP can be used for RDMA Read or Atomic operations.
+	 * This value is used to optimize metadata memory allocation
+	 * when the device supports `internal_queue_memory` feature.
+	 */
+	#define CREATE_QP_BATCH_DATA_QP_FLAGS_RDMA_READ_OR_ATOMICS_USED  UINT32_C(0x400)
+	/*
+	 * This QP must be included in the extended RoCE statistics context
+	 * specified in the field `ext_stats_ctx_id`
+	 */
+	#define CREATE_QP_BATCH_DATA_QP_FLAGS_EXT_STATS_CTX_VALID	UINT32_C(0x800)
+	/* The schq_id field passed in by the caller is valid. */
+	#define CREATE_QP_BATCH_DATA_QP_FLAGS_SCHQ_ID_VALID		UINT32_C(0x1000)
+	#define CREATE_QP_BATCH_DATA_QP_FLAGS_LAST			CREATE_QP_BATCH_DATA_QP_FLAGS_SCHQ_ID_VALID
+	/* Supported QP types. */
+	uint8_t	type;
+	/* Reliable Connection. */
+	#define CREATE_QP_BATCH_DATA_TYPE_RC		UINT32_C(0x2)
+	/* Unreliable Datagram. */
+	#define CREATE_QP_BATCH_DATA_TYPE_UD		UINT32_C(0x4)
+	/* Raw Ethertype. */
+	#define CREATE_QP_BATCH_DATA_TYPE_RAW_ETHERTYPE UINT32_C(0x6)
+	/* General Services Interface on QP1 over UD. */
+	#define CREATE_QP_BATCH_DATA_TYPE_GSI	UINT32_C(0x7)
+	#define CREATE_QP_BATCH_DATA_TYPE_LAST	CREATE_QP_BATCH_DATA_TYPE_GSI
+	uint8_t	sq_pg_size_sq_lvl;
+	/*
+	 * SQ PBL indirect levels.
+	 * This field is ignored for express mode QPs.
+	 */
+	#define CREATE_QP_BATCH_DATA_SQ_LVL_MASK	UINT32_C(0xf)
+	#define CREATE_QP_BATCH_DATA_SQ_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define CREATE_QP_BATCH_DATA_SQ_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define CREATE_QP_BATCH_DATA_SQ_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to
+	 * PTE tables.
+	 */
+		#define CREATE_QP_BATCH_DATA_SQ_LVL_LVL_2	UINT32_C(0x2)
+		#define CREATE_QP_BATCH_DATA_SQ_LVL_LAST	CREATE_QP_BATCH_DATA_SQ_LVL_LVL_2
+	/*
+	 * SQ page size.
+	 * This field is ignored for express mode QPs.
+	 */
+	#define CREATE_QP_BATCH_DATA_SQ_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define CREATE_QP_BATCH_DATA_SQ_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define CREATE_QP_BATCH_DATA_SQ_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define CREATE_QP_BATCH_DATA_SQ_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define CREATE_QP_BATCH_DATA_SQ_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define CREATE_QP_BATCH_DATA_SQ_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define CREATE_QP_BATCH_DATA_SQ_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define CREATE_QP_BATCH_DATA_SQ_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define CREATE_QP_BATCH_DATA_SQ_PG_SIZE_LAST   CREATE_QP_BATCH_DATA_SQ_PG_SIZE_PG_1G
+	uint8_t	rq_pg_size_rq_lvl;
+	/*
+	 * RQ PBL indirect levels.
+	 * This field is ignored for express mode QPs.
+	 */
+	#define CREATE_QP_BATCH_DATA_RQ_LVL_MASK	UINT32_C(0xf)
+	#define CREATE_QP_BATCH_DATA_RQ_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define CREATE_QP_BATCH_DATA_RQ_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define CREATE_QP_BATCH_DATA_RQ_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to
+	 * PTE tables.
+	 */
+		#define CREATE_QP_BATCH_DATA_RQ_LVL_LVL_2	UINT32_C(0x2)
+		#define CREATE_QP_BATCH_DATA_RQ_LVL_LAST	CREATE_QP_BATCH_DATA_RQ_LVL_LVL_2
+	/*
+	 * RQ page size.
+	 * This field is ignored for express mode QPs.
+	 */
+	#define CREATE_QP_BATCH_DATA_RQ_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define CREATE_QP_BATCH_DATA_RQ_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define CREATE_QP_BATCH_DATA_RQ_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define CREATE_QP_BATCH_DATA_RQ_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define CREATE_QP_BATCH_DATA_RQ_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define CREATE_QP_BATCH_DATA_RQ_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define CREATE_QP_BATCH_DATA_RQ_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define CREATE_QP_BATCH_DATA_RQ_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define CREATE_QP_BATCH_DATA_RQ_PG_SIZE_LAST   CREATE_QP_BATCH_DATA_RQ_PG_SIZE_PG_1G
+	uint8_t	unused_0;
+	/* Doorbell page index. */
+	uint32_t	dpi;
+	/*
+	 * When the SQ is configured to use variable-size WQE, 'sq_size'
+	 * denotes the SQ size with a unit of 16B. When the SQ is configured
+	 * to use fixed-size WQE, 'sq_size' denotes the max number of SQ WQEs.
+	 */
+	uint32_t	sq_size;
+	/* Max number of RQ wqes. */
+	uint32_t	rq_size;
+	uint16_t	sq_fwo_sq_sge;
+	/*
+	 * Max send SGEs per SWQE. This is only applicable to fixed-size
+	 * WQE support. On variable-size WQE, this is ignored.
+	 */
+	#define CREATE_QP_BATCH_DATA_SQ_SGE_MASK UINT32_C(0xf)
+	#define CREATE_QP_BATCH_DATA_SQ_SGE_SFT 0
+	/*
+	 * Offset of First WQE in the first SQ page, in 128 byte units.
+	 * This field is ignored for express mode QPs.
+	 */
+	#define CREATE_QP_BATCH_DATA_SQ_FWO_MASK UINT32_C(0xfff0)
+	#define CREATE_QP_BATCH_DATA_SQ_FWO_SFT 4
+	uint16_t	rq_fwo_rq_sge;
+	/*
+	 * Max recv SGEs per RWQE.
+	 * On chips with variable-size WQE support, a value of zero implies
+	 * 30 SGEs.
+	 */
+	#define CREATE_QP_BATCH_DATA_RQ_SGE_MASK UINT32_C(0xf)
+	#define CREATE_QP_BATCH_DATA_RQ_SGE_SFT 0
+	/*
+	 * Offset of First WQE in the first RQ page, in 128 byte units.
+	 * This field is ignored for express mode QPs.
+	 */
+	#define CREATE_QP_BATCH_DATA_RQ_FWO_MASK UINT32_C(0xfff0)
+	#define CREATE_QP_BATCH_DATA_RQ_FWO_SFT 4
+	/* Send CQ context id. */
+	uint32_t	scq_cid;
+	/* Receive CQ context id. */
+	uint32_t	rcq_cid;
+	/* SRQ context id. */
+	uint32_t	srq_cid;
+	/* Protection domain id. */
+	uint32_t	pd_id;
+	/*
+	 * SQ PBL physical address.
+	 * This field is ignored for express mode QPs.
+	 */
+	uint64_t	sq_pbl;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * RQ PBL physical address.
+	 * This field is ignored for express mode QPs.
 	 */
-	uint16_t	target_id;
+	uint64_t	rq_pbl;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * IRRQ address. This field is ignored on devices that
+	 * support the `internal_queue_memory` feature.
 	 */
-	uint64_t	resp_addr;
-	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
-	uint32_t	fw_session_id;
-	/* Control flags. */
-	uint16_t	flags;
-	/* Indicates the flow direction. */
-	#define HWRM_TF_SESSION_RESC_QCAPS_INPUT_FLAGS_DIR	UINT32_C(0x1)
-	/* If this bit set to 0, then it indicates rx flow. */
-		#define HWRM_TF_SESSION_RESC_QCAPS_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
-	/* If this bit is set to 1, then it indicates tx flow. */
-		#define HWRM_TF_SESSION_RESC_QCAPS_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
-		#define HWRM_TF_SESSION_RESC_QCAPS_INPUT_FLAGS_DIR_LAST HWRM_TF_SESSION_RESC_QCAPS_INPUT_FLAGS_DIR_TX
+	uint64_t	irrq_addr;
 	/*
-	 * Defines the size of the provided qcaps_addr array
-	 * buffer. The size should be set to the Resource Manager
-	 * provided max number of qcaps entries which is device
-	 * specific. Resource Manager gets the max size from HCAPI
-	 * RM.
+	 * ORRQ address. This field is ignored on devices that
+	 * support the `internal_queue_memory` feature.
 	 */
-	uint16_t	qcaps_size;
+	uint64_t	orrq_addr;
 	/*
-	 * This is the DMA address for the qcaps output data array
-	 * buffer. Array is of tf_rm_resc_req_entry type and is
-	 * device specific.
+	 * xid to use for the non-QP1 QP.
+	 * The requested xid must be within the valid range
+	 * of the predetermined assignment scheme of the
+	 * pseudo static QP allocation feature. The valid range
+	 * for the data QPs is determined by the start_qid and
+	 * max_qp fields of query_func response. When the value is zero,
+	 * firmware will automatically choose an xid from its free pool.
+	 * QP1 allocation, indicated by specifying `type` field as gsi,
+	 * must specify a request_xid as zero.
+	 * This field is ignored on devices that do not support
+	 * the pseudo static QP allocation feature.
+	 */
+	uint32_t	request_xid;
+	/* Steering tag to use for memory transactions. */
+	uint16_t	steering_tag;
+	/*
+	 * This value is used to optimize metadata memory allocation when
+	 * the device supports `internal_queue_memory` feature.
+	 * When the SQ is configured to use variable-size WQEs, the SQ size is
+	 * only specified in units of 16 Bytes. This value hints the max number
+	 * of WQEs that would ever be present on the SQ.
+	 */
+	uint16_t	sq_max_num_wqes;
+	/* Extended RoCE statistics context id. */
+	uint32_t	ext_stats_ctx_id;
+	/*
+	 * Identifies the new scheduling queue to associate with
+	 * the RoCE QP. A value of zero indicates that the QP is being
+	 * created with the default scheduling queue. Can only be specified
+	 * by the PF driver. VFs get assigned a scheduling queue based on PF
+	 * configuration (via HWRM_FUNC_CFG). Specified scheduling queue id is
+	 * allocated by firmware (via HWRM_SCHQ_ALLOC) when the device supports
+	 * the `scheduling queue` feature.
 	 */
-	uint64_t	qcaps_addr;
-} hwrm_tf_session_resc_qcaps_input_t, *phwrm_tf_session_resc_qcaps_input_t;
+	uint16_t	schq_id;
+	uint16_t	reserved16;
+} create_qp_batch_data_t, *pcreate_qp_batch_data_t;
 
-/* hwrm_tf_session_resc_qcaps_output (size:192b/24B) */
+/* Periodic extended RoCE statistics context DMA to host. */
+/* roce_stats_ext_ctx (size:1856b/232B) */
 
-typedef struct hwrm_tf_session_resc_qcaps_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Control flags. */
-	uint32_t	flags;
-	/* Session reservation strategy. */
-	#define HWRM_TF_SESSION_RESC_QCAPS_OUTPUT_FLAGS_SESS_RESV_STRATEGY_MASK  UINT32_C(0x3)
-	#define HWRM_TF_SESSION_RESC_QCAPS_OUTPUT_FLAGS_SESS_RESV_STRATEGY_SFT   0
-	/* Static partitioning. */
-		#define HWRM_TF_SESSION_RESC_QCAPS_OUTPUT_FLAGS_SESS_RESV_STRATEGY_STATIC  UINT32_C(0x0)
-	/* Strategy 1. */
-		#define HWRM_TF_SESSION_RESC_QCAPS_OUTPUT_FLAGS_SESS_RESV_STRATEGY_1	UINT32_C(0x1)
-	/* Strategy 2. */
-		#define HWRM_TF_SESSION_RESC_QCAPS_OUTPUT_FLAGS_SESS_RESV_STRATEGY_2	UINT32_C(0x2)
-	/* Strategy 3. */
-		#define HWRM_TF_SESSION_RESC_QCAPS_OUTPUT_FLAGS_SESS_RESV_STRATEGY_3	UINT32_C(0x3)
-		#define HWRM_TF_SESSION_RESC_QCAPS_OUTPUT_FLAGS_SESS_RESV_STRATEGY_LAST   HWRM_TF_SESSION_RESC_QCAPS_OUTPUT_FLAGS_SESS_RESV_STRATEGY_3
+typedef struct roce_stats_ext_ctx {
+	/* Number of transmitted Atomic request packets without errors. */
+	uint64_t	tx_atomic_req_pkts;
+	/* Number of transmitted Read request packets without errors. */
+	uint64_t	tx_read_req_pkts;
+	/* Number of transmitted Read response packets without errors. */
+	uint64_t	tx_read_res_pkts;
+	/* Number of transmitted Write request packets without errors. */
+	uint64_t	tx_write_req_pkts;
+	/* Number of transmitted RC Send packets without errors. */
+	uint64_t	tx_rc_send_req_pkts;
 	/*
-	 * Size of the returned qcaps_addr data array buffer. The
-	 * value cannot exceed the size defined by the input msg,
-	 * qcaps_size.
+	 * Number of transmitted UD Send (including QP1) packets
+	 * without errors.
 	 */
-	uint16_t	size;
-	/* unused. */
-	uint16_t	unused0;
-	/* unused. */
-	uint8_t	unused1[7];
+	uint64_t	tx_ud_send_req_pkts;
+	/* Number of transmitted CNPs. Includes DCN_CNPs. */
+	uint64_t	tx_cnp_pkts;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * Number of transmitted RoCE packets.
+	 * This includes RC, UD, RawEth, and QP1 packets
 	 */
-	uint8_t	valid;
-} hwrm_tf_session_resc_qcaps_output_t, *phwrm_tf_session_resc_qcaps_output_t;
-
-/******************************
- * hwrm_tf_session_resc_alloc *
- ******************************/
-
-
-/* hwrm_tf_session_resc_alloc_input (size:320b/40B) */
-
-typedef struct hwrm_tf_session_resc_alloc_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	uint64_t	tx_roce_pkts;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * Number of transmitted RoCE header and payload bytes.
+	 * This includes RC, UD, RawEth, and QP1 packets.
 	 */
-	uint16_t	cmpl_ring;
+	uint64_t	tx_roce_bytes;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Number of drops that occurred to lack of buffers.
+	 * This count includes RC sends, RC writes with immediate,
+	 * UD sends, RawEth, and QP1 packets dropped due to lack of buffers.
 	 */
-	uint16_t	seq_id;
+	uint64_t	rx_out_of_buffer_pkts;
+	/* Number of packets that were received out of sequence. */
+	uint64_t	rx_out_of_sequence_pkts;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Number of duplicate read/atomic requests resulting in responder
+	 * hardware retransmission.
 	 */
-	uint16_t	target_id;
+	uint64_t	dup_req;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Number of missing response packets resulting in hardware
+	 * retransmission.
 	 */
-	uint64_t	resp_addr;
-	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
-	uint32_t	fw_session_id;
-	/* Control flags. */
-	uint16_t	flags;
-	/* Indicates the flow direction. */
-	#define HWRM_TF_SESSION_RESC_ALLOC_INPUT_FLAGS_DIR	UINT32_C(0x1)
-	/* If this bit set to 0, then it indicates rx flow. */
-		#define HWRM_TF_SESSION_RESC_ALLOC_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
-	/* If this bit is set to 1, then it indicates tx flow. */
-		#define HWRM_TF_SESSION_RESC_ALLOC_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
-		#define HWRM_TF_SESSION_RESC_ALLOC_INPUT_FLAGS_DIR_LAST HWRM_TF_SESSION_RESC_ALLOC_INPUT_FLAGS_DIR_TX
+	uint64_t	missing_resp;
 	/*
-	 * Defines the array size of the provided req_addr and
-	 * resv_addr array buffers. Should be set to the number of
-	 * request entries.
+	 * Number of sequence error NAKs received resulting in hardware
+	 * retransmission.
 	 */
-	uint16_t	req_size;
+	uint64_t	seq_err_naks_rcvd;
+	/* Number of RNR NAKs received resulting in hardware retransmission. */
+	uint64_t	rnr_naks_rcvd;
+	/* Number of timeouts resulting in hardware retransmission. */
+	uint64_t	to_retransmits;
+	/* Number of received Atomic request packets without errors. */
+	uint64_t	rx_atomic_req_pkts;
+	/* Number of received Read request packets without errors. */
+	uint64_t	rx_read_req_pkts;
+	/* Number of received Read response packets without errors. */
+	uint64_t	rx_read_res_pkts;
+	/* Number of received Write request packets without errors. */
+	uint64_t	rx_write_req_pkts;
+	/* Number of received RC Send packets without errors. */
+	uint64_t	rx_rc_send_pkts;
+	/* Number of received UD Send packets without errors. */
+	uint64_t	rx_ud_send_pkts;
+	/* Number of received DCN payload cut packets. */
+	uint64_t	rx_dcn_payload_cut;
+	/* Number of received ECN-marked packets. */
+	uint64_t	rx_ecn_marked_pkts;
+	/* Number of received CNP packets. Includes DCN_CNPs. */
+	uint64_t	rx_cnp_pkts;
 	/*
-	 * This is the DMA address for the request input data array
-	 * buffer. Array is of tf_rm_resc_req_entry type. Size of the
-	 * array buffer is provided by the 'req_size' field in this
-	 * message.
+	 * Number of received RoCE packets including RoCE packets with errors.
+	 * This includes RC, UD, RawEth, and QP1 packets
 	 */
-	uint64_t	req_addr;
+	uint64_t	rx_roce_pkts;
 	/*
-	 * This is the DMA address for the resc output data array
-	 * buffer. Array is of tf_rm_resc_entry type. Size of the array
-	 * buffer is provided by the 'req_size' field in this
-	 * message.
+	 * Number of received RoCE header and payload bytes including RoCE
+	 * packets with errors.
+	 * This includes RC, UD, RawEth, and QP1 packets.
 	 */
-	uint64_t	resc_addr;
-} hwrm_tf_session_resc_alloc_input_t, *phwrm_tf_session_resc_alloc_input_t;
+	uint64_t	rx_roce_bytes;
+	/*
+	 * Number of received RoCE packets without errors.
+	 * This includes RC, UD, RawEth, and QP1 packets
+	 */
+	uint64_t	rx_roce_good_pkts;
+	/*
+	 * Number of received RoCE header and payload bytes without errors.
+	 * This includes RC, UD, RawEth, and QP1 packets.
+	 */
+	uint64_t	rx_roce_good_bytes;
+} roce_stats_ext_ctx_t, *proce_stats_ext_ctx_t;
 
-/* hwrm_tf_session_resc_alloc_output (size:128b/16B) */
+/*****************
+ * query_version *
+ *****************/
 
-typedef struct hwrm_tf_session_resc_alloc_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
+
+/* cmdq_query_version (size:128b/16B) */
+
+typedef struct cmdq_query_version {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Query version. */
+	#define CMDQ_QUERY_VERSION_OPCODE_QUERY_VERSION UINT32_C(0x8b)
+	#define CMDQ_QUERY_VERSION_OPCODE_LAST	CMDQ_QUERY_VERSION_OPCODE_QUERY_VERSION
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+} cmdq_query_version_t, *pcmdq_query_version_t;
+
+/* creq_query_version_resp (size:128b/16B) */
+
+typedef struct creq_query_version_resp {
+	uint8_t	type;
 	/*
-	 * Size of the returned tf_rm_resc_entry data array. The value
-	 * cannot exceed the req_size defined by the input msg. The data
-	 * array is returned using the resv_addr specified DMA
-	 * address also provided by the input msg.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint16_t	size;
-	/* unused. */
-	uint8_t	unused0[5];
+	#define CREQ_QUERY_VERSION_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_QUERY_VERSION_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_QUERY_VERSION_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_QUERY_VERSION_RESP_TYPE_LAST	CREQ_QUERY_VERSION_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* firmware major version */
+	uint8_t	fw_maj;
+	/* firmware minor version */
+	uint8_t	fw_minor;
+	/* firmware build version */
+	uint8_t	fw_bld;
+	/* firmware reserved version */
+	uint8_t	fw_rsvd;
+	uint8_t	v;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint8_t	valid;
-} hwrm_tf_session_resc_alloc_output_t, *phwrm_tf_session_resc_alloc_output_t;
+	#define CREQ_QUERY_VERSION_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Query firmware and interface version response. */
+	#define CREQ_QUERY_VERSION_RESP_EVENT_QUERY_VERSION UINT32_C(0x8b)
+	#define CREQ_QUERY_VERSION_RESP_EVENT_LAST	CREQ_QUERY_VERSION_RESP_EVENT_QUERY_VERSION
+	uint16_t	reserved16;
+	/* interface major version */
+	uint8_t	intf_maj;
+	/* interface minor version */
+	uint8_t	intf_minor;
+	/* interface build version */
+	uint8_t	intf_bld;
+	/* interface reserved version */
+	uint8_t	intf_rsvd;
+} creq_query_version_resp_t, *pcreq_query_version_resp_t;
 
-/*****************************
- * hwrm_tf_session_resc_free *
- *****************************/
+/*****************
+ * initialize_fw *
+ *****************/
 
 
-/* hwrm_tf_session_resc_free_input (size:256b/32B) */
+/* cmdq_initialize_fw (size:1024b/128B) */
 
-typedef struct hwrm_tf_session_resc_free_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+typedef struct cmdq_initialize_fw {
+	/* Command opcode. */
+	uint8_t	opcode;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * Initialize firmware command initializes the firmware with
+	 * the specified parameters.
 	 */
-	uint16_t	cmpl_ring;
+	#define CMDQ_INITIALIZE_FW_OPCODE_INITIALIZE_FW UINT32_C(0x80)
+	#define CMDQ_INITIALIZE_FW_OPCODE_LAST	CMDQ_INITIALIZE_FW_OPCODE_INITIALIZE_FW
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * When set, the 32b `max_mrw_per_vf` field is logically divided
+	 * into two 16b fields, `max_mr_per_vf` and `max_av_per_vf`.
 	 */
-	uint16_t	seq_id;
+	#define CMDQ_INITIALIZE_FW_FLAGS_MRAV_RESERVATION_SPLIT	UINT32_C(0x1)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * When set, the hardware based requester retransmission
+	 * feature is supported.
 	 */
-	uint16_t	target_id;
+	#define CMDQ_INITIALIZE_FW_FLAGS_HW_REQUESTER_RETX_SUPPORTED	UINT32_C(0x2)
+	/* When set, the driver version is provided. */
+	#define CMDQ_INITIALIZE_FW_FLAGS_DRV_VERSION			UINT32_C(0x4)
+	/* When set, driver supports optimizing Modify QP operation. */
+	#define CMDQ_INITIALIZE_FW_FLAGS_OPTIMIZE_MODIFY_QP_SUPPORTED	UINT32_C(0x8)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * When set, the VF RoCE resources will be managed by the L2
+	 * driver via func_cfg.
 	 */
+	#define CMDQ_INITIALIZE_FW_FLAGS_L2_VF_RESOURCE_MGMT		UINT32_C(0x10)
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
 	uint64_t	resp_addr;
-	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
-	uint32_t	fw_session_id;
-	/* Control flags. */
-	uint16_t	flags;
-	/* Indicates the flow direction. */
-	#define HWRM_TF_SESSION_RESC_FREE_INPUT_FLAGS_DIR	UINT32_C(0x1)
-	/* If this bit set to 0, then it indicates rx flow. */
-		#define HWRM_TF_SESSION_RESC_FREE_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
-	/* If this bit is set to 1, then it indicates tx flow. */
-		#define HWRM_TF_SESSION_RESC_FREE_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
-		#define HWRM_TF_SESSION_RESC_FREE_INPUT_FLAGS_DIR_LAST HWRM_TF_SESSION_RESC_FREE_INPUT_FLAGS_DIR_TX
-	/*
-	 * Defines the size, in bytes, of the provided free_addr
-	 * buffer.
-	 */
-	uint16_t	free_size;
+	uint8_t	qpc_pg_size_qpc_lvl;
+	/* QPC PBL indirect levels. */
+	#define CMDQ_INITIALIZE_FW_QPC_LVL_MASK	UINT32_C(0xf)
+	#define CMDQ_INITIALIZE_FW_QPC_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define CMDQ_INITIALIZE_FW_QPC_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define CMDQ_INITIALIZE_FW_QPC_LVL_LVL_1	UINT32_C(0x1)
 	/*
-	 * This is the DMA address for the free input data array
-	 * buffer.  Array is of tf_rm_resc_entry type. Size of the
-	 * buffer is provided by the 'free_size' field of this
-	 * message.
+	 * PBL pointer points to PDE table with each entry pointing to
+	 * PTE tables.
 	 */
-	uint64_t	free_addr;
-} hwrm_tf_session_resc_free_input_t, *phwrm_tf_session_resc_free_input_t;
-
-/* hwrm_tf_session_resc_free_output (size:128b/16B) */
-
-typedef struct hwrm_tf_session_resc_free_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* unused. */
-	uint8_t	unused0[7];
+		#define CMDQ_INITIALIZE_FW_QPC_LVL_LVL_2	UINT32_C(0x2)
+		#define CMDQ_INITIALIZE_FW_QPC_LVL_LAST	CMDQ_INITIALIZE_FW_QPC_LVL_LVL_2
+	/* QPC page size. */
+	#define CMDQ_INITIALIZE_FW_QPC_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define CMDQ_INITIALIZE_FW_QPC_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define CMDQ_INITIALIZE_FW_QPC_PG_SIZE_LAST   CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_1G
+	uint8_t	mrw_pg_size_mrw_lvl;
+	/* MRW PBL indirect levels. */
+	#define CMDQ_INITIALIZE_FW_MRW_LVL_MASK	UINT32_C(0xf)
+	#define CMDQ_INITIALIZE_FW_MRW_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define CMDQ_INITIALIZE_FW_MRW_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define CMDQ_INITIALIZE_FW_MRW_LVL_LVL_1	UINT32_C(0x1)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
 	 */
-	uint8_t	valid;
-} hwrm_tf_session_resc_free_output_t, *phwrm_tf_session_resc_free_output_t;
-
-/******************************
- * hwrm_tf_session_resc_flush *
- ******************************/
-
-
-/* hwrm_tf_session_resc_flush_input (size:256b/32B) */
-
-typedef struct hwrm_tf_session_resc_flush_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+		#define CMDQ_INITIALIZE_FW_MRW_LVL_LVL_2	UINT32_C(0x2)
+		#define CMDQ_INITIALIZE_FW_MRW_LVL_LAST	CMDQ_INITIALIZE_FW_MRW_LVL_LVL_2
+	/* MRW page size. */
+	#define CMDQ_INITIALIZE_FW_MRW_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define CMDQ_INITIALIZE_FW_MRW_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define CMDQ_INITIALIZE_FW_MRW_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define CMDQ_INITIALIZE_FW_MRW_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define CMDQ_INITIALIZE_FW_MRW_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define CMDQ_INITIALIZE_FW_MRW_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define CMDQ_INITIALIZE_FW_MRW_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define CMDQ_INITIALIZE_FW_MRW_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define CMDQ_INITIALIZE_FW_MRW_PG_SIZE_LAST   CMDQ_INITIALIZE_FW_MRW_PG_SIZE_PG_1G
+	uint8_t	srq_pg_size_srq_lvl;
+	/* SRQ PBL indirect levels. */
+	#define CMDQ_INITIALIZE_FW_SRQ_LVL_MASK	UINT32_C(0xf)
+	#define CMDQ_INITIALIZE_FW_SRQ_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define CMDQ_INITIALIZE_FW_SRQ_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define CMDQ_INITIALIZE_FW_SRQ_LVL_LVL_1	UINT32_C(0x1)
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
 	 */
-	uint16_t	cmpl_ring;
+		#define CMDQ_INITIALIZE_FW_SRQ_LVL_LVL_2	UINT32_C(0x2)
+		#define CMDQ_INITIALIZE_FW_SRQ_LVL_LAST	CMDQ_INITIALIZE_FW_SRQ_LVL_LVL_2
+	/* SRQ page size. */
+	#define CMDQ_INITIALIZE_FW_SRQ_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define CMDQ_INITIALIZE_FW_SRQ_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define CMDQ_INITIALIZE_FW_SRQ_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define CMDQ_INITIALIZE_FW_SRQ_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define CMDQ_INITIALIZE_FW_SRQ_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define CMDQ_INITIALIZE_FW_SRQ_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define CMDQ_INITIALIZE_FW_SRQ_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define CMDQ_INITIALIZE_FW_SRQ_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define CMDQ_INITIALIZE_FW_SRQ_PG_SIZE_LAST   CMDQ_INITIALIZE_FW_SRQ_PG_SIZE_PG_1G
+	uint8_t	cq_pg_size_cq_lvl;
+	/* CQ PBL indirect levels. */
+	#define CMDQ_INITIALIZE_FW_CQ_LVL_MASK	UINT32_C(0xf)
+	#define CMDQ_INITIALIZE_FW_CQ_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define CMDQ_INITIALIZE_FW_CQ_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define CMDQ_INITIALIZE_FW_CQ_LVL_LVL_1	UINT32_C(0x1)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
 	 */
-	uint16_t	seq_id;
+		#define CMDQ_INITIALIZE_FW_CQ_LVL_LVL_2	UINT32_C(0x2)
+		#define CMDQ_INITIALIZE_FW_CQ_LVL_LAST	CMDQ_INITIALIZE_FW_CQ_LVL_LVL_2
+	/* CQ page size. */
+	#define CMDQ_INITIALIZE_FW_CQ_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define CMDQ_INITIALIZE_FW_CQ_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define CMDQ_INITIALIZE_FW_CQ_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define CMDQ_INITIALIZE_FW_CQ_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define CMDQ_INITIALIZE_FW_CQ_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define CMDQ_INITIALIZE_FW_CQ_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define CMDQ_INITIALIZE_FW_CQ_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define CMDQ_INITIALIZE_FW_CQ_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define CMDQ_INITIALIZE_FW_CQ_PG_SIZE_LAST   CMDQ_INITIALIZE_FW_CQ_PG_SIZE_PG_1G
+	uint8_t	tqm_pg_size_tqm_lvl;
+	/* TQM PBL indirect levels. */
+	#define CMDQ_INITIALIZE_FW_TQM_LVL_MASK	UINT32_C(0xf)
+	#define CMDQ_INITIALIZE_FW_TQM_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define CMDQ_INITIALIZE_FW_TQM_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define CMDQ_INITIALIZE_FW_TQM_LVL_LVL_1	UINT32_C(0x1)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
 	 */
-	uint16_t	target_id;
+		#define CMDQ_INITIALIZE_FW_TQM_LVL_LVL_2	UINT32_C(0x2)
+		#define CMDQ_INITIALIZE_FW_TQM_LVL_LAST	CMDQ_INITIALIZE_FW_TQM_LVL_LVL_2
+	/* TQM page size. */
+	#define CMDQ_INITIALIZE_FW_TQM_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define CMDQ_INITIALIZE_FW_TQM_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define CMDQ_INITIALIZE_FW_TQM_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define CMDQ_INITIALIZE_FW_TQM_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define CMDQ_INITIALIZE_FW_TQM_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define CMDQ_INITIALIZE_FW_TQM_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define CMDQ_INITIALIZE_FW_TQM_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define CMDQ_INITIALIZE_FW_TQM_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define CMDQ_INITIALIZE_FW_TQM_PG_SIZE_LAST   CMDQ_INITIALIZE_FW_TQM_PG_SIZE_PG_1G
+	uint8_t	tim_pg_size_tim_lvl;
+	/* TIM PBL indirect levels. */
+	#define CMDQ_INITIALIZE_FW_TIM_LVL_MASK	UINT32_C(0xf)
+	#define CMDQ_INITIALIZE_FW_TIM_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define CMDQ_INITIALIZE_FW_TIM_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define CMDQ_INITIALIZE_FW_TIM_LVL_LVL_1	UINT32_C(0x1)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
 	 */
-	uint64_t	resp_addr;
-	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
-	uint32_t	fw_session_id;
-	/* Control flags. */
-	uint16_t	flags;
-	/* Indicates the flow direction. */
-	#define HWRM_TF_SESSION_RESC_FLUSH_INPUT_FLAGS_DIR	UINT32_C(0x1)
-	/* If this bit set to 0, then it indicates rx flow. */
-		#define HWRM_TF_SESSION_RESC_FLUSH_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
-	/* If this bit is set to 1, then it indicates tx flow. */
-		#define HWRM_TF_SESSION_RESC_FLUSH_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
-		#define HWRM_TF_SESSION_RESC_FLUSH_INPUT_FLAGS_DIR_LAST HWRM_TF_SESSION_RESC_FLUSH_INPUT_FLAGS_DIR_TX
+		#define CMDQ_INITIALIZE_FW_TIM_LVL_LVL_2	UINT32_C(0x2)
+		#define CMDQ_INITIALIZE_FW_TIM_LVL_LAST	CMDQ_INITIALIZE_FW_TIM_LVL_LVL_2
+	/* TIM page size. */
+	#define CMDQ_INITIALIZE_FW_TIM_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define CMDQ_INITIALIZE_FW_TIM_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define CMDQ_INITIALIZE_FW_TIM_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define CMDQ_INITIALIZE_FW_TIM_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define CMDQ_INITIALIZE_FW_TIM_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define CMDQ_INITIALIZE_FW_TIM_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define CMDQ_INITIALIZE_FW_TIM_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define CMDQ_INITIALIZE_FW_TIM_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define CMDQ_INITIALIZE_FW_TIM_PG_SIZE_LAST   CMDQ_INITIALIZE_FW_TIM_PG_SIZE_PG_1G
+	uint16_t	log2_dbr_pg_size;
 	/*
-	 * Defines the size, in bytes, of the provided flush_addr
-	 * buffer.
+	 * Log base 2 of DBR page size - 12. 0 for 4KB. HW supported values
+	 * are enumerated below.
 	 */
-	uint16_t	flush_size;
+	#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_MASK   UINT32_C(0xf)
+	#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_SFT	0
+	/* 4KB. */
+		#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_PG_4K	UINT32_C(0x0)
+	/* 8KB. */
+		#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_PG_8K	UINT32_C(0x1)
+	/* 16KB. */
+		#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_PG_16K   UINT32_C(0x2)
+	/* 32KB. */
+		#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_PG_32K   UINT32_C(0x3)
+	/* 64KB. */
+		#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_PG_64K   UINT32_C(0x4)
+	/* 128KB. */
+		#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_PG_128K  UINT32_C(0x5)
+	/* 256KB. */
+		#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_PG_256K  UINT32_C(0x6)
+	/* 512KB. */
+		#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_PG_512K  UINT32_C(0x7)
+	/* 1MB. */
+		#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_PG_1M	UINT32_C(0x8)
+	/* 2MB. */
+		#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_PG_2M	UINT32_C(0x9)
+	/* 4MB. */
+		#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_PG_4M	UINT32_C(0xa)
+	/* 8MB. */
+		#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_PG_8M	UINT32_C(0xb)
+	/* 16MB. */
+		#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_PG_16M   UINT32_C(0xc)
+	/* 32MB. */
+		#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_PG_32M   UINT32_C(0xd)
+	/* 64MB. */
+		#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_PG_64M   UINT32_C(0xe)
+	/* 128MB. */
+		#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_PG_128M  UINT32_C(0xf)
+		#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_LAST	CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_PG_128M
+	/* rsvd is 12 b */
+	#define CMDQ_INITIALIZE_FW_RSVD_MASK		UINT32_C(0xfff0)
+	#define CMDQ_INITIALIZE_FW_RSVD_SFT		4
+	/* Kernel notification queue page directory. */
+	uint64_t	qpc_page_dir;
+	/* MRW page directory. */
+	uint64_t	mrw_page_dir;
+	/* SRQ page directory. */
+	uint64_t	srq_page_dir;
+	/* CQ page directory. */
+	uint64_t	cq_page_dir;
+	/* TQM page directory. */
+	uint64_t	tqm_page_dir;
+	/* TIM page directory. */
+	uint64_t	tim_page_dir;
 	/*
-	 * This is the DMA address for the flush input data array
-	 * buffer.  Array of tf_rm_resc_entry type. Size of the
-	 * buffer is provided by the 'flush_size' field in this
-	 * message.
+	 * Number of QPs. This field is ignored when the backing store HWRM's
+	 * are used.
 	 */
-	uint64_t	flush_addr;
-} hwrm_tf_session_resc_flush_input_t, *phwrm_tf_session_resc_flush_input_t;
-
-/* hwrm_tf_session_resc_flush_output (size:128b/16B) */
-
-typedef struct hwrm_tf_session_resc_flush_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* unused. */
-	uint8_t	unused0[7];
+	uint32_t	number_of_qp;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * Number of MRWs. This field is ignored when the backing store HWRM's
+	 * are used.
 	 */
-	uint8_t	valid;
-} hwrm_tf_session_resc_flush_output_t, *phwrm_tf_session_resc_flush_output_t;
-
-/*****************************
- * hwrm_tf_session_resc_info *
- *****************************/
-
-
-/* hwrm_tf_session_resc_info_input (size:320b/40B) */
-
-typedef struct hwrm_tf_session_resc_info_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	uint32_t	number_of_mrw;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * Number of SRQs. This field is ignored when the backing store HWRM's
+	 * are used.
 	 */
-	uint16_t	cmpl_ring;
+	uint32_t	number_of_srq;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Number of CQs. This field is ignored when the backing store HWRM's
+	 * are used.
 	 */
-	uint16_t	seq_id;
+	uint32_t	number_of_cq;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Number of QPs per VF. This field must be set to zero when the flag,
+	 * l2_vf_resource_mgmt, is set and RoCE SRIOV is enabled.
 	 */
-	uint16_t	target_id;
+	uint32_t	max_qp_per_vf;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * If the MR/AV split reservation flag is not set, then this field
+	 * represents the total number of MR plus AV entries allowed per
+	 * VF. For versions of firmware that support the split reservation,
+	 * when it is not specified half of the entries will be reserved
+	 * for MRs and the other half for AVs.
+	 *
+	 * If the MR/AV split reservation flag is set, then this
+	 * field is logically divided into two 16b fields. Bits `[31:16]`
+	 * represents the `max_mr_per_vf` and bits `[15:0]` represents
+	 * `max_av_per_vf`. The granularity of these values is defined by
+	 * the `mrav_num_entries_unit` field returned by the
+	 * `backing_store_qcaps` command.
+	 *
+	 * This field must be set to zero when the flag, l2_vf_resource_mgmt,
+	 * is set and RoCE SRIOV is enabled.
 	 */
-	uint64_t	resp_addr;
-	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
-	uint32_t	fw_session_id;
-	/* Control flags. */
-	uint16_t	flags;
-	/* Indicates the flow direction. */
-	#define HWRM_TF_SESSION_RESC_INFO_INPUT_FLAGS_DIR	UINT32_C(0x1)
-	/* If this bit set to 0, then it indicates rx flow. */
-		#define HWRM_TF_SESSION_RESC_INFO_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
-	/* If this bit is set to 1, then it indicates tx flow. */
-		#define HWRM_TF_SESSION_RESC_INFO_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
-		#define HWRM_TF_SESSION_RESC_INFO_INPUT_FLAGS_DIR_LAST HWRM_TF_SESSION_RESC_INFO_INPUT_FLAGS_DIR_TX
+	uint32_t	max_mrw_per_vf;
 	/*
-	 * Defines the array size of the provided req_addr and
-	 * resv_addr array buffers. Should be set to the number of
-	 * request entries.
+	 * Number of SRQs per VF. This field must be set to zero when the flag,
+	 * l2_vf_resource_mgmt, is set and RoCE SRIOV is enabled.
 	 */
-	uint16_t	req_size;
+	uint32_t	max_srq_per_vf;
 	/*
-	 * This is the DMA address for the request input data array
-	 * buffer. Array is of tf_rm_resc_req_entry type. Size of the
-	 * array buffer is provided by the 'req_size' field in this
-	 * message.
+	 * Number of CQs per VF. This field must be set to zero when the flag,
+	 * l2_vf_resource_mgmt, is set and RoCE SRIOV is enabled.
 	 */
-	uint64_t	req_addr;
+	uint32_t	max_cq_per_vf;
 	/*
-	 * This is the DMA address for the resc output data array
-	 * buffer. Array is of tf_rm_resc_entry type. Size of the array
-	 * buffer is provided by the 'req_size' field in this
-	 * message.
+	 * Number of GIDs per VF. This field must be set to zero when the flag,
+	 * l2_vf_resource_mgmt, is set and RoCE SRIOV is enabled.
 	 */
-	uint64_t	resc_addr;
-} hwrm_tf_session_resc_info_input_t, *phwrm_tf_session_resc_info_input_t;
+	uint32_t	max_gid_per_vf;
+	/* Statistics context index for this function. */
+	uint32_t	stat_ctx_id;
+	/* The driver HSI major version number. */
+	uint8_t	drv_hsi_ver_maj;
+	/* The driver HSI minor version number. */
+	uint8_t	drv_hsi_ver_min;
+	/* The driver HSI update version number. */
+	uint8_t	drv_hsi_ver_upd;
+	/* This is the 40bit unused. */
+	uint8_t	unused40[5];
+	/* The driver build major version number. */
+	uint16_t	drv_build_ver_maj;
+	/* The driver build minor version number. */
+	uint16_t	drv_build_ver_min;
+	/* The driver build update version number. */
+	uint16_t	drv_build_ver_upd;
+	/* The driver build patch version number. */
+	uint16_t	drv_build_ver_patch;
+} cmdq_initialize_fw_t, *pcmdq_initialize_fw_t;
 
-/* hwrm_tf_session_resc_info_output (size:128b/16B) */
+/* creq_initialize_fw_resp (size:128b/16B) */
 
-typedef struct hwrm_tf_session_resc_info_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
+typedef struct creq_initialize_fw_resp {
+	uint8_t	type;
 	/*
-	 * Size of the returned tf_rm_resc_entry data array. The value
-	 * cannot exceed the req_size defined by the input msg. The data
-	 * array is returned using the resv_addr specified DMA
-	 * address also provided by the input msg.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint16_t	size;
-	/* unused. */
-	uint8_t	unused0[5];
+	#define CREQ_INITIALIZE_FW_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_INITIALIZE_FW_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_INITIALIZE_FW_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_INITIALIZE_FW_RESP_TYPE_LAST	CREQ_INITIALIZE_FW_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	uint32_t	reserved32;
+	uint8_t	v;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint8_t	valid;
-} hwrm_tf_session_resc_info_output_t, *phwrm_tf_session_resc_info_output_t;
-
-/* TruFlow RM capability of a resource. */
-/* tf_rm_resc_req_entry (size:64b/8B) */
-
-typedef struct tf_rm_resc_req_entry {
-	/* Type of the resource, defined globally in HCAPI RM. */
-	uint32_t	type;
-	/* Minimum value. */
-	uint16_t	min;
-	/* Maximum value. */
-	uint16_t	max;
-} tf_rm_resc_req_entry_t, *ptf_rm_resc_req_entry_t;
+	#define CREQ_INITIALIZE_FW_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Initialize firmware command response. */
+	#define CREQ_INITIALIZE_FW_RESP_EVENT_INITIALIZE_FW UINT32_C(0x80)
+	#define CREQ_INITIALIZE_FW_RESP_EVENT_LAST	CREQ_INITIALIZE_FW_RESP_EVENT_INITIALIZE_FW
+	uint8_t	reserved48[6];
+} creq_initialize_fw_resp_t, *pcreq_initialize_fw_resp_t;
 
-/* TruFlow RM reservation information. */
-/* tf_rm_resc_entry (size:64b/8B) */
+/*******************
+ * deinitialize_fw *
+ *******************/
 
-typedef struct tf_rm_resc_entry {
-	/* Type of the resource, defined globally in HCAPI RM. */
-	uint32_t	type;
-	/* Start offset. */
-	uint16_t	start;
-	/* Number of resources. */
-	uint16_t	stride;
-} tf_rm_resc_entry_t, *ptf_rm_resc_entry_t;
 
-/************************
- * hwrm_tf_tbl_type_get *
- ************************/
+/* cmdq_deinitialize_fw (size:128b/16B) */
 
+typedef struct cmdq_deinitialize_fw {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* De-initialize firmware command deinitializes the firmware. */
+	#define CMDQ_DEINITIALIZE_FW_OPCODE_DEINITIALIZE_FW UINT32_C(0x81)
+	#define CMDQ_DEINITIALIZE_FW_OPCODE_LAST	CMDQ_DEINITIALIZE_FW_OPCODE_DEINITIALIZE_FW
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+} cmdq_deinitialize_fw_t, *pcmdq_deinitialize_fw_t;
 
-/* hwrm_tf_tbl_type_get_input (size:256b/32B) */
+/* creq_deinitialize_fw_resp (size:128b/16B) */
 
-typedef struct hwrm_tf_tbl_type_get_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
-	 */
-	uint16_t	cmpl_ring;
-	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
-	 */
-	uint16_t	seq_id;
-	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
-	 */
-	uint16_t	target_id;
-	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
-	 */
-	uint64_t	resp_addr;
-	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
-	uint32_t	fw_session_id;
-	/* Control flags. */
-	uint16_t	flags;
-	/* Indicates the flow direction. */
-	#define HWRM_TF_TBL_TYPE_GET_INPUT_FLAGS_DIR	UINT32_C(0x1)
-	/* If this bit set to 0, then it indicates rx flow. */
-		#define HWRM_TF_TBL_TYPE_GET_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
-	/* If this bit is set to 1, then it indicates tx flow. */
-		#define HWRM_TF_TBL_TYPE_GET_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
-		#define HWRM_TF_TBL_TYPE_GET_INPUT_FLAGS_DIR_LAST HWRM_TF_TBL_TYPE_GET_INPUT_FLAGS_DIR_TX
-	/* unused. */
-	uint8_t	unused0[2];
+typedef struct creq_deinitialize_fw_resp {
+	uint8_t	type;
 	/*
-	 * Type of the resource, defined globally in the
-	 * hwrm_tf_resc_type enum.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint32_t	type;
-	/* Index of the type to retrieve. */
-	uint32_t	index;
-} hwrm_tf_tbl_type_get_input_t, *phwrm_tf_tbl_type_get_input_t;
-
-/* hwrm_tf_tbl_type_get_output (size:1216b/152B) */
-
-typedef struct hwrm_tf_tbl_type_get_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Response code. */
-	uint32_t	resp_code;
-	/* Response size. */
-	uint16_t	size;
-	/* unused */
-	uint16_t	unused0;
-	/* Response data. */
-	uint8_t	data[128];
-	/* unused */
-	uint8_t	unused1[7];
+	#define CREQ_DEINITIALIZE_FW_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_DEINITIALIZE_FW_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_DEINITIALIZE_FW_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_DEINITIALIZE_FW_RESP_TYPE_LAST	CREQ_DEINITIALIZE_FW_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	uint32_t	reserved32;
+	uint8_t	v;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field
-	 * is written last.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint8_t	valid;
-} hwrm_tf_tbl_type_get_output_t, *phwrm_tf_tbl_type_get_output_t;
+	#define CREQ_DEINITIALIZE_FW_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* De-initialize firmware command response. */
+	#define CREQ_DEINITIALIZE_FW_RESP_EVENT_DEINITIALIZE_FW UINT32_C(0x81)
+	#define CREQ_DEINITIALIZE_FW_RESP_EVENT_LAST	CREQ_DEINITIALIZE_FW_RESP_EVENT_DEINITIALIZE_FW
+	uint8_t	reserved48[6];
+} creq_deinitialize_fw_resp_t, *pcreq_deinitialize_fw_resp_t;
 
-/************************
- * hwrm_tf_tbl_type_set *
- ************************/
+/*************
+ * create_qp *
+ *************/
 
 
-/* hwrm_tf_tbl_type_set_input (size:1024b/128B) */
+/* cmdq_create_qp (size:896b/112B) */
 
-typedef struct hwrm_tf_tbl_type_set_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
-	 */
-	uint16_t	cmpl_ring;
-	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
-	 */
-	uint16_t	seq_id;
-	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
-	 */
-	uint16_t	target_id;
+typedef struct cmdq_create_qp {
+	/* Command opcode. */
+	uint8_t	opcode;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Create QP command allocates QP context with the specified
+	 * SQ, RQ/SRQ, CQ and other parameters.
 	 */
-	uint64_t	resp_addr;
-	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
-	uint32_t	fw_session_id;
-	/* Control flags. */
+	#define CMDQ_CREATE_QP_OPCODE_CREATE_QP UINT32_C(0x1)
+	#define CMDQ_CREATE_QP_OPCODE_LAST	CMDQ_CREATE_QP_OPCODE_CREATE_QP
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
 	uint16_t	flags;
-	/* Indicates the flow direction. */
-	#define HWRM_TF_TBL_TYPE_SET_INPUT_FLAGS_DIR	UINT32_C(0x1)
-	/* If this bit set to 0, then it indicates rx flow. */
-		#define HWRM_TF_TBL_TYPE_SET_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
-	/* If this bit is set to 1, then it indicates tx flow. */
-		#define HWRM_TF_TBL_TYPE_SET_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
-		#define HWRM_TF_TBL_TYPE_SET_INPUT_FLAGS_DIR_LAST HWRM_TF_TBL_TYPE_SET_INPUT_FLAGS_DIR_TX
-	/* unused. */
-	uint8_t	unused0[2];
-	/*
-	 * Type of the resource, defined globally in the
-	 * hwrm_tf_resc_type enum.
-	 */
-	uint32_t	type;
-	/* Index of the type to retrieve. */
-	uint32_t	index;
-	/* Size of the data to set. */
-	uint16_t	size;
-	/* unused */
-	uint8_t	unused1[6];
-	/* Data to be set. */
-	uint8_t	data[88];
-} hwrm_tf_tbl_type_set_input_t, *phwrm_tf_tbl_type_set_input_t;
-
-/* hwrm_tf_tbl_type_set_output (size:128b/16B) */
-
-typedef struct hwrm_tf_tbl_type_set_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* unused. */
-	uint8_t	unused0[7];
-	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field
-	 * is written last.
-	 */
-	uint8_t	valid;
-} hwrm_tf_tbl_type_set_output_t, *phwrm_tf_tbl_type_set_output_t;
-
-/**************************
- * hwrm_tf_ctxt_mem_alloc *
- **************************/
-
-
-/* hwrm_tf_ctxt_mem_alloc_input (size:192b/24B) */
-
-typedef struct hwrm_tf_ctxt_mem_alloc_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+	/* QP handle. */
+	uint64_t	qp_handle;
+	/* Create QP flags. */
+	uint32_t	qp_flags;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * SRQ is used.
+	 * This flag is not supported on express mode QPs.
 	 */
-	uint16_t	cmpl_ring;
+	#define CMDQ_CREATE_QP_QP_FLAGS_SRQ_USED		UINT32_C(0x1)
+	/* post CQE for all SQ WQEs. */
+	#define CMDQ_CREATE_QP_QP_FLAGS_FORCE_COMPLETION	UINT32_C(0x2)
+	/* This QP can use reserved L_Key */
+	#define CMDQ_CREATE_QP_QP_FLAGS_RESERVED_LKEY_ENABLE	UINT32_C(0x4)
+	/* This QP can fast register physical memory */
+	#define CMDQ_CREATE_QP_QP_FLAGS_FR_PMR_ENABLED		UINT32_C(0x8)
+	/* This QP can send variable sized WQEs. */
+	#define CMDQ_CREATE_QP_QP_FLAGS_VARIABLE_SIZED_WQE_ENABLED UINT32_C(0x10)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * WQEs with inline data sent on this QP are able to flow
+	 * through an optimized transmit path to lower latency. This
+	 * transmit path is opportunistic and not guaranteed to always
+	 * occur.
 	 */
-	uint16_t	seq_id;
+	#define CMDQ_CREATE_QP_QP_FLAGS_OPTIMIZED_TRANSMIT_ENABLED UINT32_C(0x20)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * For UD QPs the default responder CQE format is `cq_res_ud`.
+	 * This flag specifies the `cq_res_ud_cfa` format to be used
+	 * instead.
 	 */
-	uint16_t	target_id;
+	#define CMDQ_CREATE_QP_QP_FLAGS_RESPONDER_UD_CQE_WITH_CFA  UINT32_C(0x40)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * This QP must be included in the extended RoCE statistics
+	 * that can be queried via `query_roce_stats_ext`.
 	 */
-	uint64_t	resp_addr;
-	/* Size in KB of memory to be allocated. */
-	uint32_t	mem_size;
-	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
-	uint32_t	fw_session_id;
-} hwrm_tf_ctxt_mem_alloc_input_t, *phwrm_tf_ctxt_mem_alloc_input_t;
-
-/* hwrm_tf_ctxt_mem_alloc_output (size:192b/24B) */
-
-typedef struct hwrm_tf_ctxt_mem_alloc_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Pointer to the PBL, or PDL depending on number of levels */
-	uint64_t	page_dir;
-	/* Size of memory allocated. */
-	uint32_t	mem_size;
-	/* Counter PBL indirect levels. */
-	uint8_t	page_level;
-	/* PBL pointer is physical start address. */
-	#define HWRM_TF_CTXT_MEM_ALLOC_OUTPUT_PAGE_LEVEL_LVL_0 UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-	#define HWRM_TF_CTXT_MEM_ALLOC_OUTPUT_PAGE_LEVEL_LVL_1 UINT32_C(0x1)
+	#define CMDQ_CREATE_QP_QP_FLAGS_EXT_STATS_ENABLED	UINT32_C(0x80)
+	/* This QP uses express mode. */
+	#define CMDQ_CREATE_QP_QP_FLAGS_EXPRESS_MODE_ENABLED	UINT32_C(0x100)
+	/* This QP uses the steering tag specified in the command. */
+	#define CMDQ_CREATE_QP_QP_FLAGS_STEERING_TAG_VALID	UINT32_C(0x200)
 	/*
-	 * PBL pointer points to PDE table with each entry pointing
-	 * to PTE tables.
+	 * This QP can be used for RDMA Read or Atomic operations.
+	 * This value is used to optimize metadata memory allocation
+	 * when the device supports `internal_queue_memory` feature.
 	 */
-	#define HWRM_TF_CTXT_MEM_ALLOC_OUTPUT_PAGE_LEVEL_LVL_2 UINT32_C(0x2)
-	#define HWRM_TF_CTXT_MEM_ALLOC_OUTPUT_PAGE_LEVEL_LAST HWRM_TF_CTXT_MEM_ALLOC_OUTPUT_PAGE_LEVEL_LVL_2
-	/* Page size. */
-	uint8_t	page_size;
-	/* 4KB page size. */
-	#define HWRM_TF_CTXT_MEM_ALLOC_OUTPUT_PAGE_SIZE_4K   UINT32_C(0x0)
-	/* 8KB page size. */
-	#define HWRM_TF_CTXT_MEM_ALLOC_OUTPUT_PAGE_SIZE_8K   UINT32_C(0x1)
-	/* 64KB page size. */
-	#define HWRM_TF_CTXT_MEM_ALLOC_OUTPUT_PAGE_SIZE_64K  UINT32_C(0x4)
-	/* 128KB page size. */
-	#define HWRM_TF_CTXT_MEM_ALLOC_OUTPUT_PAGE_SIZE_128K UINT32_C(0x5)
-	/* 256KB page size. */
-	#define HWRM_TF_CTXT_MEM_ALLOC_OUTPUT_PAGE_SIZE_256K UINT32_C(0x6)
-	/* 512KB page size. */
-	#define HWRM_TF_CTXT_MEM_ALLOC_OUTPUT_PAGE_SIZE_512K UINT32_C(0x7)
-	/* 1MB page size. */
-	#define HWRM_TF_CTXT_MEM_ALLOC_OUTPUT_PAGE_SIZE_1M   UINT32_C(0x8)
-	/* 2MB page size. */
-	#define HWRM_TF_CTXT_MEM_ALLOC_OUTPUT_PAGE_SIZE_2M   UINT32_C(0x9)
-	/* 4MB page size. */
-	#define HWRM_TF_CTXT_MEM_ALLOC_OUTPUT_PAGE_SIZE_4M   UINT32_C(0xa)
-	/* 8MB page size. */
-	#define HWRM_TF_CTXT_MEM_ALLOC_OUTPUT_PAGE_SIZE_8M   UINT32_C(0xb)
-	/* 1GB page size. */
-	#define HWRM_TF_CTXT_MEM_ALLOC_OUTPUT_PAGE_SIZE_1G   UINT32_C(0x12)
-	#define HWRM_TF_CTXT_MEM_ALLOC_OUTPUT_PAGE_SIZE_LAST HWRM_TF_CTXT_MEM_ALLOC_OUTPUT_PAGE_SIZE_1G
-	/* unused. */
-	uint8_t	unused0;
+	#define CMDQ_CREATE_QP_QP_FLAGS_RDMA_READ_OR_ATOMICS_USED  UINT32_C(0x400)
 	/*
-	 * This field is used in Output records to indicate that the
-	 * output is completely written to RAM. This field should be
-	 * read as '1' to indicate that the output has been
-	 * completely written.  When writing a command completion or
-	 * response to an internal processor, the order of writes has
-	 * to be such that this field is written last.
+	 * This QP must be included in the extended RoCE statistics context
+	 * specified in the field `ext_stats_ctx_id`
 	 */
-	uint8_t	valid;
-} hwrm_tf_ctxt_mem_alloc_output_t, *phwrm_tf_ctxt_mem_alloc_output_t;
-
-/*************************
- * hwrm_tf_ctxt_mem_free *
- *************************/
-
-
-/* hwrm_tf_ctxt_mem_free_input (size:320b/40B) */
-
-typedef struct hwrm_tf_ctxt_mem_free_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define CMDQ_CREATE_QP_QP_FLAGS_EXT_STATS_CTX_VALID	UINT32_C(0x800)
+	/* The schq_id field passed in by the caller is valid. */
+	#define CMDQ_CREATE_QP_QP_FLAGS_SCHQ_ID_VALID		UINT32_C(0x1000)
+	#define CMDQ_CREATE_QP_QP_FLAGS_LAST			CMDQ_CREATE_QP_QP_FLAGS_SCHQ_ID_VALID
+	/* Supported QP types. */
+	uint8_t	type;
+	/* Reliable Connection. */
+	#define CMDQ_CREATE_QP_TYPE_RC		UINT32_C(0x2)
+	/* Unreliable Datagram. */
+	#define CMDQ_CREATE_QP_TYPE_UD		UINT32_C(0x4)
+	/* Raw Ethertype. */
+	#define CMDQ_CREATE_QP_TYPE_RAW_ETHERTYPE UINT32_C(0x6)
+	/* General Services Interface on QP1 over UD. */
+	#define CMDQ_CREATE_QP_TYPE_GSI	UINT32_C(0x7)
+	#define CMDQ_CREATE_QP_TYPE_LAST	CMDQ_CREATE_QP_TYPE_GSI
+	uint8_t	sq_pg_size_sq_lvl;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * SQ PBL indirect levels.
+	 * This field is ignored for express mode QPs.
 	 */
-	uint16_t	cmpl_ring;
+	#define CMDQ_CREATE_QP_SQ_LVL_MASK	UINT32_C(0xf)
+	#define CMDQ_CREATE_QP_SQ_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define CMDQ_CREATE_QP_SQ_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define CMDQ_CREATE_QP_SQ_LVL_LVL_1	UINT32_C(0x1)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * PBL pointer points to PDE table with each entry pointing to
+	 * PTE tables.
 	 */
-	uint16_t	seq_id;
+		#define CMDQ_CREATE_QP_SQ_LVL_LVL_2	UINT32_C(0x2)
+		#define CMDQ_CREATE_QP_SQ_LVL_LAST	CMDQ_CREATE_QP_SQ_LVL_LVL_2
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * SQ page size.
+	 * This field is ignored for express mode QPs.
 	 */
-	uint16_t	target_id;
+	#define CMDQ_CREATE_QP_SQ_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define CMDQ_CREATE_QP_SQ_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define CMDQ_CREATE_QP_SQ_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define CMDQ_CREATE_QP_SQ_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define CMDQ_CREATE_QP_SQ_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define CMDQ_CREATE_QP_SQ_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define CMDQ_CREATE_QP_SQ_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define CMDQ_CREATE_QP_SQ_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define CMDQ_CREATE_QP_SQ_PG_SIZE_LAST   CMDQ_CREATE_QP_SQ_PG_SIZE_PG_1G
+	uint8_t	rq_pg_size_rq_lvl;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * RQ PBL indirect levels.
+	 * This field is ignored for express mode QPs.
 	 */
-	uint64_t	resp_addr;
-	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
-	uint32_t	fw_session_id;
-	/* Counter PBL indirect levels. */
-	uint8_t	page_level;
+	#define CMDQ_CREATE_QP_RQ_LVL_MASK	UINT32_C(0xf)
+	#define CMDQ_CREATE_QP_RQ_LVL_SFT	0
 	/* PBL pointer is physical start address. */
-	#define HWRM_TF_CTXT_MEM_FREE_INPUT_PAGE_LEVEL_LVL_0 UINT32_C(0x0)
+		#define CMDQ_CREATE_QP_RQ_LVL_LVL_0	UINT32_C(0x0)
 	/* PBL pointer points to PTE table. */
-	#define HWRM_TF_CTXT_MEM_FREE_INPUT_PAGE_LEVEL_LVL_1 UINT32_C(0x1)
+		#define CMDQ_CREATE_QP_RQ_LVL_LVL_1	UINT32_C(0x1)
 	/*
-	 * PBL pointer points to PDE table with each entry pointing
-	 * to PTE tables.
+	 * PBL pointer points to PDE table with each entry pointing to
+	 * PTE tables.
 	 */
-	#define HWRM_TF_CTXT_MEM_FREE_INPUT_PAGE_LEVEL_LVL_2 UINT32_C(0x2)
-	#define HWRM_TF_CTXT_MEM_FREE_INPUT_PAGE_LEVEL_LAST HWRM_TF_CTXT_MEM_FREE_INPUT_PAGE_LEVEL_LVL_2
-	/* Page size. */
-	uint8_t	page_size;
-	/* 4KB page size. */
-	#define HWRM_TF_CTXT_MEM_FREE_INPUT_PAGE_SIZE_4K   UINT32_C(0x0)
-	/* 8KB page size. */
-	#define HWRM_TF_CTXT_MEM_FREE_INPUT_PAGE_SIZE_8K   UINT32_C(0x1)
-	/* 64KB page size. */
-	#define HWRM_TF_CTXT_MEM_FREE_INPUT_PAGE_SIZE_64K  UINT32_C(0x4)
-	/* 128KB page size. */
-	#define HWRM_TF_CTXT_MEM_FREE_INPUT_PAGE_SIZE_128K UINT32_C(0x5)
-	/* 256KB page size. */
-	#define HWRM_TF_CTXT_MEM_FREE_INPUT_PAGE_SIZE_256K UINT32_C(0x6)
-	/* 512KB page size. */
-	#define HWRM_TF_CTXT_MEM_FREE_INPUT_PAGE_SIZE_512K UINT32_C(0x7)
-	/* 1MB page size. */
-	#define HWRM_TF_CTXT_MEM_FREE_INPUT_PAGE_SIZE_1M   UINT32_C(0x8)
-	/* 2MB page size. */
-	#define HWRM_TF_CTXT_MEM_FREE_INPUT_PAGE_SIZE_2M   UINT32_C(0x9)
-	/* 4MB page size. */
-	#define HWRM_TF_CTXT_MEM_FREE_INPUT_PAGE_SIZE_4M   UINT32_C(0xa)
-	/* 8MB page size. */
-	#define HWRM_TF_CTXT_MEM_FREE_INPUT_PAGE_SIZE_8M   UINT32_C(0xb)
-	/* 1GB page size. */
-	#define HWRM_TF_CTXT_MEM_FREE_INPUT_PAGE_SIZE_1G   UINT32_C(0x12)
-	#define HWRM_TF_CTXT_MEM_FREE_INPUT_PAGE_SIZE_LAST HWRM_TF_CTXT_MEM_FREE_INPUT_PAGE_SIZE_1G
-	/* unused. */
-	uint8_t	unused0[2];
-	/* Pointer to the PBL, or PDL depending on number of levels */
-	uint64_t	page_dir;
-	/* Size of memory allocated. */
-	uint32_t	mem_size;
-	/* unused. */
-	uint8_t	unused1[4];
-} hwrm_tf_ctxt_mem_free_input_t, *phwrm_tf_ctxt_mem_free_input_t;
-
-/* hwrm_tf_ctxt_mem_free_output (size:128b/16B) */
-
-typedef struct hwrm_tf_ctxt_mem_free_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* unused. */
-	uint8_t	unused0[7];
+		#define CMDQ_CREATE_QP_RQ_LVL_LVL_2	UINT32_C(0x2)
+		#define CMDQ_CREATE_QP_RQ_LVL_LAST	CMDQ_CREATE_QP_RQ_LVL_LVL_2
 	/*
-	 * This field is used in Output records to indicate that the
-	 * output is completely written to RAM. This field should be
-	 * read as '1' to indicate that the output has been
-	 * completely written.  When writing a command completion or
-	 * response to an internal processor, the order of writes has
-	 * to be such that this field is written last.
+	 * RQ page size.
+	 * This field is ignored for express mode QPs.
 	 */
-	uint8_t	valid;
-} hwrm_tf_ctxt_mem_free_output_t, *phwrm_tf_ctxt_mem_free_output_t;
-
-/*************************
- * hwrm_tf_ctxt_mem_rgtr *
- *************************/
-
-
-/* hwrm_tf_ctxt_mem_rgtr_input (size:256b/32B) */
-
-typedef struct hwrm_tf_ctxt_mem_rgtr_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define CMDQ_CREATE_QP_RQ_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define CMDQ_CREATE_QP_RQ_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define CMDQ_CREATE_QP_RQ_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define CMDQ_CREATE_QP_RQ_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define CMDQ_CREATE_QP_RQ_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define CMDQ_CREATE_QP_RQ_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define CMDQ_CREATE_QP_RQ_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define CMDQ_CREATE_QP_RQ_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define CMDQ_CREATE_QP_RQ_PG_SIZE_LAST   CMDQ_CREATE_QP_RQ_PG_SIZE_PG_1G
+	uint8_t	unused_0;
+	/* Doorbell page index. */
+	uint32_t	dpi;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * When the SQ is configured to use variable-size WQE, 'sq_size'
+	 * denotes the SQ size with a unit of 16B. When the SQ is configured
+	 * to use fixed-size WQE, 'sq_size' denotes the max number of SQ WQEs.
 	 */
-	uint16_t	cmpl_ring;
+	uint32_t	sq_size;
+	/* Max number of RQ wqes. */
+	uint32_t	rq_size;
+	uint16_t	sq_fwo_sq_sge;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Max send SGEs per SWQE. This is only applicable to fixed-size
+	 * WQE support. On variable-size WQE, this is ignored.
 	 */
-	uint16_t	seq_id;
+	#define CMDQ_CREATE_QP_SQ_SGE_MASK UINT32_C(0xf)
+	#define CMDQ_CREATE_QP_SQ_SGE_SFT 0
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Offset of First WQE in the first SQ page, in 128 byte units.
+	 * This field is ignored for express mode QPs.
 	 */
-	uint16_t	target_id;
+	#define CMDQ_CREATE_QP_SQ_FWO_MASK UINT32_C(0xfff0)
+	#define CMDQ_CREATE_QP_SQ_FWO_SFT 4
+	uint16_t	rq_fwo_rq_sge;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Max recv SGEs per RWQE.
+	 * On chips with variable-size WQE support, a value of zero implies
+	 * 30 SGEs.
 	 */
-	uint64_t	resp_addr;
-	/* Control flags. */
-	uint16_t	flags;
-	/* Counter PBL indirect levels. */
-	uint8_t	page_level;
-	/* PBL pointer is physical start address. */
-	#define HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_LEVEL_LVL_0 UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-	#define HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_LEVEL_LVL_1 UINT32_C(0x1)
+	#define CMDQ_CREATE_QP_RQ_SGE_MASK UINT32_C(0xf)
+	#define CMDQ_CREATE_QP_RQ_SGE_SFT 0
 	/*
-	 * PBL pointer points to PDE table with each entry pointing
-	 * to PTE tables.
+	 * Offset of First WQE in the first RQ page, in 128 byte units.
+	 * This field is ignored for express mode QPs.
 	 */
-	#define HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_LEVEL_LVL_2 UINT32_C(0x2)
-	#define HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_LEVEL_LAST HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_LEVEL_LVL_2
-	/* Page size. */
-	uint8_t	page_size;
-	/* 4KB page size. */
-	#define HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_4K   UINT32_C(0x0)
-	/* 8KB page size. */
-	#define HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_8K   UINT32_C(0x1)
-	/* 64KB page size. */
-	#define HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_64K  UINT32_C(0x4)
-	/* 128KB page size. */
-	#define HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_128K UINT32_C(0x5)
-	/* 256KB page size. */
-	#define HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_256K UINT32_C(0x6)
-	/* 512KB page size. */
-	#define HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_512K UINT32_C(0x7)
-	/* 1MB page size. */
-	#define HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_1M   UINT32_C(0x8)
-	/* 2MB page size. */
-	#define HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_2M   UINT32_C(0x9)
-	/* 4MB page size. */
-	#define HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_4M   UINT32_C(0xa)
-	/* 8MB page size. */
-	#define HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_8M   UINT32_C(0xb)
-	/* 1GB page size. */
-	#define HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_1G   UINT32_C(0x12)
-	#define HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_LAST HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_1G
-	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
-	uint32_t	fw_session_id;
-	/* Pointer to the PBL, or PDL depending on number of levels */
-	uint64_t	page_dir;
-} hwrm_tf_ctxt_mem_rgtr_input_t, *phwrm_tf_ctxt_mem_rgtr_input_t;
-
-/* hwrm_tf_ctxt_mem_rgtr_output (size:128b/16B) */
-
-typedef struct hwrm_tf_ctxt_mem_rgtr_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
+	#define CMDQ_CREATE_QP_RQ_FWO_MASK UINT32_C(0xfff0)
+	#define CMDQ_CREATE_QP_RQ_FWO_SFT 4
+	/* Send CQ context id. */
+	uint32_t	scq_cid;
+	/* Receive CQ context id. */
+	uint32_t	rcq_cid;
+	/* SRQ context id. */
+	uint32_t	srq_cid;
+	/* Protection domain id. */
+	uint32_t	pd_id;
 	/*
-	 * Id/Handle to the recently register context memory. This
-	 * handle is passed to the TF session.
+	 * SQ PBL physical address.
+	 * This field is ignored for express mode QPs.
 	 */
-	uint16_t	ctx_id;
-	/* unused. */
-	uint8_t	unused0[5];
+	uint64_t	sq_pbl;
 	/*
-	 * This field is used in Output records to indicate that the
-	 * output is completely written to RAM. This field should be
-	 * read as '1' to indicate that the output has been
-	 * completely written.  When writing a command completion or
-	 * response to an internal processor, the order of writes has
-	 * to be such that this field is written last.
+	 * RQ PBL physical address.
+	 * This field is ignored for express mode QPs.
 	 */
-	uint8_t	valid;
-} hwrm_tf_ctxt_mem_rgtr_output_t, *phwrm_tf_ctxt_mem_rgtr_output_t;
-
-/***************************
- * hwrm_tf_ctxt_mem_unrgtr *
- ***************************/
-
-
-/* hwrm_tf_ctxt_mem_unrgtr_input (size:192b/24B) */
-
-typedef struct hwrm_tf_ctxt_mem_unrgtr_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	uint64_t	rq_pbl;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * IRRQ address. This field is ignored on devices that
+	 * support the `internal_queue_memory` feature.
 	 */
-	uint16_t	cmpl_ring;
+	uint64_t	irrq_addr;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * ORRQ address. This field is ignored on devices that
+	 * support the `internal_queue_memory` feature.
 	 */
-	uint16_t	seq_id;
+	uint64_t	orrq_addr;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * xid to use for the non-QP1 QP.
+	 * The requested xid must be within the valid range
+	 * of the predetermined assignment scheme of the
+	 * pseudo static QP allocation feature. The valid range
+	 * for the data QPs is determined by the start_qid and
+	 * max_qp fields of query_func response. When the value is zero,
+	 * firmware will automatically choose an xid from its free pool.
+	 * QP1 allocation, indicated by specifying `type` field as gsi,
+	 * must specify a request_xid as zero.
+	 * This field is ignored on devices that do not support
+	 * the pseudo static QP allocation feature.
+	 */
+	uint32_t	request_xid;
+	/* Steering tag to use for memory transactions. */
+	uint16_t	steering_tag;
+	/*
+	 * This value is used to optimize metadata memory allocation when
+	 * the device supports `internal_queue_memory` feature.
+	 * When the SQ is configured to use variable-size WQEs, the SQ size is
+	 * only specified in units of 16 Bytes. This value hints the max number
+	 * of WQEs that would ever be present on the SQ.
+	 */
+	uint16_t	sq_max_num_wqes;
+	/* Extended RoCE statistics context id. */
+	uint32_t	ext_stats_ctx_id;
+	/*
+	 * Identifies the new scheduling queue to associate with
+	 * the RoCE QP. A value of zero indicates that the QP is being
+	 * created with the default scheduling queue. Can only be specified
+	 * by the PF driver. VFs get assigned a scheduling queue based on PF
+	 * configuration (via HWRM_FUNC_CFG). Specified scheduling queue id is
+	 * allocated by firmware (via HWRM_SCHQ_ALLOC) when the device supports
+	 * the `scheduling queue` feature.
 	 */
-	uint16_t	target_id;
+	uint16_t	schq_id;
+	uint16_t	reserved16;
+} cmdq_create_qp_t, *pcmdq_create_qp_t;
+
+/* creq_create_qp_resp (size:128b/16B) */
+
+typedef struct creq_create_qp_resp {
+	uint8_t	type;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint64_t	resp_addr;
+	#define CREQ_CREATE_QP_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_CREATE_QP_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_CREATE_QP_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_CREATE_QP_RESP_TYPE_LAST	CREQ_CREATE_QP_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* QP context id */
+	uint32_t	xid;
+	uint8_t	v;
 	/*
-	 * Id/Handle to the recently register context memory. This
-	 * handle is passed to the TF session.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint16_t	ctx_id;
-	/* unused. */
-	uint8_t	unused0[2];
-	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
-	uint32_t	fw_session_id;
-} hwrm_tf_ctxt_mem_unrgtr_input_t, *phwrm_tf_ctxt_mem_unrgtr_input_t;
-
-/* hwrm_tf_ctxt_mem_unrgtr_output (size:128b/16B) */
-
-typedef struct hwrm_tf_ctxt_mem_unrgtr_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* unused. */
-	uint8_t	unused0[7];
+	#define CREQ_CREATE_QP_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Create QP command response. */
+	#define CREQ_CREATE_QP_RESP_EVENT_CREATE_QP UINT32_C(0x1)
+	#define CREQ_CREATE_QP_RESP_EVENT_LAST	CREQ_CREATE_QP_RESP_EVENT_CREATE_QP
 	/*
-	 * This field is used in Output records to indicate that the
-	 * output is completely written to RAM. This field should be
-	 * read as '1' to indicate that the output has been
-	 * completely written.  When writing a command completion or
-	 * response to an internal processor, the order of writes has
-	 * to be such that this field is written last.
+	 * Support for optimized transmit path to lower latency
+	 * for WQEs with inline data has been enabled for this QP.
 	 */
-	uint8_t	valid;
-} hwrm_tf_ctxt_mem_unrgtr_output_t, *phwrm_tf_ctxt_mem_unrgtr_output_t;
+	uint8_t	optimized_transmit_enabled;
+	uint8_t	reserved48[5];
+} creq_create_qp_resp_t, *pcreq_create_qp_resp_t;
 
-/************************
- * hwrm_tf_ext_em_qcaps *
- ************************/
+/**************
+ * destroy_qp *
+ **************/
 
 
-/* hwrm_tf_ext_em_qcaps_input (size:192b/24B) */
+/* cmdq_destroy_qp (size:192b/24B) */
 
-typedef struct hwrm_tf_ext_em_qcaps_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
-	 */
-	uint16_t	cmpl_ring;
+typedef struct cmdq_destroy_qp {
+	/* Command opcode. */
+	uint8_t	opcode;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Destroy QP command deletes the QP context and ceases
+	 * any further reference.
 	 */
-	uint16_t	seq_id;
+	#define CMDQ_DESTROY_QP_OPCODE_DESTROY_QP UINT32_C(0x2)
+	#define CMDQ_DESTROY_QP_OPCODE_LAST	CMDQ_DESTROY_QP_OPCODE_DESTROY_QP
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+	/* QP context id */
+	uint32_t	qp_cid;
+	uint32_t	unused_0;
+} cmdq_destroy_qp_t, *pcmdq_destroy_qp_t;
+
+/* creq_destroy_qp_resp (size:128b/16B) */
+
+typedef struct creq_destroy_qp_resp {
+	uint8_t	type;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint16_t	target_id;
+	#define CREQ_DESTROY_QP_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_DESTROY_QP_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_DESTROY_QP_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_DESTROY_QP_RESP_TYPE_LAST	CREQ_DESTROY_QP_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* QP context id */
+	uint32_t	xid;
+	uint8_t	v;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint64_t	resp_addr;
-	/* Control flags. */
-	uint32_t	flags;
-	/* Indicates the flow direction. */
-	#define HWRM_TF_EXT_EM_QCAPS_INPUT_FLAGS_DIR		UINT32_C(0x1)
-	/* If this bit set to 0, then it indicates rx flow. */
-		#define HWRM_TF_EXT_EM_QCAPS_INPUT_FLAGS_DIR_RX		UINT32_C(0x0)
-	/* If this bit is set to 1, then it indicates tx flow. */
-		#define HWRM_TF_EXT_EM_QCAPS_INPUT_FLAGS_DIR_TX		UINT32_C(0x1)
-		#define HWRM_TF_EXT_EM_QCAPS_INPUT_FLAGS_DIR_LAST		HWRM_TF_EXT_EM_QCAPS_INPUT_FLAGS_DIR_TX
-	/* When set to 1, all offloaded flows will be sent to EXT EM. */
-	#define HWRM_TF_EXT_EM_QCAPS_INPUT_FLAGS_PREFERRED_OFFLOAD	UINT32_C(0x2)
-	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
-	uint32_t	fw_session_id;
-} hwrm_tf_ext_em_qcaps_input_t, *phwrm_tf_ext_em_qcaps_input_t;
+	#define CREQ_DESTROY_QP_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Destroy QP command response. */
+	#define CREQ_DESTROY_QP_RESP_EVENT_DESTROY_QP UINT32_C(0x2)
+	#define CREQ_DESTROY_QP_RESP_EVENT_LAST	CREQ_DESTROY_QP_RESP_EVENT_DESTROY_QP
+	uint8_t	reserved48[6];
+} creq_destroy_qp_resp_t, *pcreq_destroy_qp_resp_t;
 
-/* hwrm_tf_ext_em_qcaps_output (size:384b/48B) */
+/*************
+ * modify_qp *
+ *************/
 
-typedef struct hwrm_tf_ext_em_qcaps_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint32_t	flags;
-	/*
-	 * When set to 1, indicates the the FW supports the Centralized
-	 * Memory Model. The concept designates one entity for the
-	 * memory allocation while all others ‘subscribe’ to it.
-	 */
-	#define HWRM_TF_EXT_EM_QCAPS_OUTPUT_FLAGS_CENTRALIZED_MEMORY_MODEL_SUPPORTED		UINT32_C(0x1)
+
+/* cmdq_modify_qp (size:1152b/144B) */
+
+typedef struct cmdq_modify_qp {
+	/* Command opcode. */
+	uint8_t	opcode;
 	/*
-	 * When set to 1, indicates the the FW supports the Detached
-	 * Centralized Memory Model. The memory is allocated and managed
-	 * as a separate entity. All PFs and VFs will be granted direct
-	 * or semi-direct access to the allocated memory while none of
-	 * which can interfere with the management of the memory.
+	 * Modify QP command changes QP states and other QP specific
+	 * parameters.
 	 */
-	#define HWRM_TF_EXT_EM_QCAPS_OUTPUT_FLAGS_DETACHED_CENTRALIZED_MEMORY_MODEL_SUPPORTED	UINT32_C(0x2)
-	/* When set to 1, indicates FW support for host based EEM memory. */
-	#define HWRM_TF_EXT_EM_QCAPS_OUTPUT_FLAGS_HOST_MEMORY_SUPPORTED			UINT32_C(0x4)
-	/* When set to 1, indicates FW support for on-chip based EEM memory. */
-	#define HWRM_TF_EXT_EM_QCAPS_OUTPUT_FLAGS_FW_MEMORY_SUPPORTED				UINT32_C(0x8)
-	/* unused. */
-	uint32_t	unused0;
-	/* Support flags. */
-	uint32_t	supported;
+	#define CMDQ_MODIFY_QP_OPCODE_MODIFY_QP UINT32_C(0x3)
+	#define CMDQ_MODIFY_QP_OPCODE_LAST	CMDQ_MODIFY_QP_OPCODE_MODIFY_QP
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
 	/*
-	 * If set to 1, then EXT EM KEY0 table is supported using
-	 * crc32 hash.
-	 * If set to 0, EXT EM KEY0 table is not supported.
+	 * This field, used by firmware for optimizing Modify QP operation,
+	 * must be set when the driver has indicated support for the
+	 * optimize_modify_qp_supported feature in cmdq_initialize_fw and
+	 * when QP Type RC is configured to use SRQ.
 	 */
-	#define HWRM_TF_EXT_EM_QCAPS_OUTPUT_SUPPORTED_KEY0_TABLE			UINT32_C(0x1)
+	#define CMDQ_MODIFY_QP_FLAGS_SRQ_USED	UINT32_C(0x1)
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
 	/*
-	 * If set to 1, then EXT EM KEY1 table is supported using
-	 * lookup3 hash.
-	 * If set to 0, EXT EM KEY1 table is not supported.
+	 * This field, used by firmware for optimizing Modify QP operation,
+	 * must be set when the driver has indicated support for the
+	 * optimize_modify_qp_supported feature in cmdq_initialize_fw.
 	 */
-	#define HWRM_TF_EXT_EM_QCAPS_OUTPUT_SUPPORTED_KEY1_TABLE			UINT32_C(0x2)
+	uint8_t	qp_type;
+	/* Reliable Connection. */
+	#define CMDQ_MODIFY_QP_QP_TYPE_RC		UINT32_C(0x2)
+	/* Unreliable Datagram. */
+	#define CMDQ_MODIFY_QP_QP_TYPE_UD		UINT32_C(0x4)
+	/* Raw Ethertype. */
+	#define CMDQ_MODIFY_QP_QP_TYPE_RAW_ETHERTYPE UINT32_C(0x6)
+	/* General Services Interface on QP1 over UD. */
+	#define CMDQ_MODIFY_QP_QP_TYPE_GSI	UINT32_C(0x7)
+	#define CMDQ_MODIFY_QP_QP_TYPE_LAST	CMDQ_MODIFY_QP_QP_TYPE_GSI
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+	/* Modify mask signifies the field that is requesting the change. */
+	uint32_t	modify_mask;
+	/* QP state change. */
+	#define CMDQ_MODIFY_QP_MODIFY_MASK_STATE		UINT32_C(0x1)
+	/* Enable SQ drain asynchronous notification change. */
+	#define CMDQ_MODIFY_QP_MODIFY_MASK_EN_SQD_ASYNC_NOTIFY	UINT32_C(0x2)
+	/* Access change. */
+	#define CMDQ_MODIFY_QP_MODIFY_MASK_ACCESS		UINT32_C(0x4)
+	/* P_KEY change. */
+	#define CMDQ_MODIFY_QP_MODIFY_MASK_PKEY			UINT32_C(0x8)
+	/* Q_KEY index change. */
+	#define CMDQ_MODIFY_QP_MODIFY_MASK_QKEY			UINT32_C(0x10)
+	/* Destination GID change. */
+	#define CMDQ_MODIFY_QP_MODIFY_MASK_DGID			UINT32_C(0x20)
+	/* Flow label change. */
+	#define CMDQ_MODIFY_QP_MODIFY_MASK_FLOW_LABEL		UINT32_C(0x40)
+	/* SGID change. */
+	#define CMDQ_MODIFY_QP_MODIFY_MASK_SGID_INDEX		UINT32_C(0x80)
+	/* Hop limit change. */
+	#define CMDQ_MODIFY_QP_MODIFY_MASK_HOP_LIMIT		UINT32_C(0x100)
+	/* Traffic class change. */
+	#define CMDQ_MODIFY_QP_MODIFY_MASK_TRAFFIC_CLASS	UINT32_C(0x200)
+	/* destination MAC change. */
+	#define CMDQ_MODIFY_QP_MODIFY_MASK_DEST_MAC		UINT32_C(0x400)
+	/* Ping pong push mode change. */
+	#define CMDQ_MODIFY_QP_MODIFY_MASK_PINGPONG_PUSH_MODE	UINT32_C(0x800)
+	/* Path MTU change. */
+	#define CMDQ_MODIFY_QP_MODIFY_MASK_PATH_MTU		UINT32_C(0x1000)
+	/* Timeout change. */
+	#define CMDQ_MODIFY_QP_MODIFY_MASK_TIMEOUT		UINT32_C(0x2000)
+	/* Retry count change. */
+	#define CMDQ_MODIFY_QP_MODIFY_MASK_RETRY_CNT		UINT32_C(0x4000)
+	/* RNR Retry change. */
+	#define CMDQ_MODIFY_QP_MODIFY_MASK_RNR_RETRY		UINT32_C(0x8000)
+	/* RQ start packet sequence number change. */
+	#define CMDQ_MODIFY_QP_MODIFY_MASK_RQ_PSN		UINT32_C(0x10000)
+	/* Max outstanding RDMA read atomic change. */
+	#define CMDQ_MODIFY_QP_MODIFY_MASK_MAX_RD_ATOMIC	UINT32_C(0x20000)
+	/* RNR minimum timer change. */
+	#define CMDQ_MODIFY_QP_MODIFY_MASK_MIN_RNR_TIMER	UINT32_C(0x40000)
+	/* SQ start packet sequence number change. */
+	#define CMDQ_MODIFY_QP_MODIFY_MASK_SQ_PSN		UINT32_C(0x80000)
+	/* Max destination outstanding RDMA read atomic change. */
+	#define CMDQ_MODIFY_QP_MODIFY_MASK_MAX_DEST_RD_ATOMIC	UINT32_C(0x100000)
+	/* Max send WQE change. */
+	#define CMDQ_MODIFY_QP_MODIFY_MASK_SQ_SIZE		UINT32_C(0x200000)
+	/* Max recv WQE change. */
+	#define CMDQ_MODIFY_QP_MODIFY_MASK_RQ_SIZE		UINT32_C(0x400000)
+	/* Max recv SGEs per SWQE change. */
+	#define CMDQ_MODIFY_QP_MODIFY_MASK_SQ_SGE		UINT32_C(0x800000)
+	/* Max send SGEs per RWQE change. */
+	#define CMDQ_MODIFY_QP_MODIFY_MASK_RQ_SGE		UINT32_C(0x1000000)
+	/* Max inline data length change. */
+	#define CMDQ_MODIFY_QP_MODIFY_MASK_MAX_INLINE_DATA	UINT32_C(0x2000000)
+	/* Destination QP id change. */
+	#define CMDQ_MODIFY_QP_MODIFY_MASK_DEST_QP_ID		UINT32_C(0x4000000)
+	/* Source MAC change. */
+	#define CMDQ_MODIFY_QP_MODIFY_MASK_SRC_MAC		UINT32_C(0x8000000)
+	/* Source VLAN id change. */
+	#define CMDQ_MODIFY_QP_MODIFY_MASK_VLAN_ID		UINT32_C(0x10000000)
+	/* Congestion control RoCE v2 change. */
+	#define CMDQ_MODIFY_QP_MODIFY_MASK_ENABLE_CC		UINT32_C(0x20000000)
+	/* IP TOS ECN change */
+	#define CMDQ_MODIFY_QP_MODIFY_MASK_TOS_ECN		UINT32_C(0x40000000)
+	/* IP TOS DSCP change */
+	#define CMDQ_MODIFY_QP_MODIFY_MASK_TOS_DSCP		UINT32_C(0x80000000)
+	/* QP context id */
+	uint32_t	qp_cid;
+	uint8_t	network_type_en_sqd_async_notify_new_state;
+	/* New QP state. */
+	#define CMDQ_MODIFY_QP_NEW_STATE_MASK	UINT32_C(0xf)
+	#define CMDQ_MODIFY_QP_NEW_STATE_SFT	0
+	/* Reset. */
+		#define CMDQ_MODIFY_QP_NEW_STATE_RESET	UINT32_C(0x0)
+	/* Init. */
+		#define CMDQ_MODIFY_QP_NEW_STATE_INIT		UINT32_C(0x1)
+	/* Ready To Receive. */
+		#define CMDQ_MODIFY_QP_NEW_STATE_RTR		UINT32_C(0x2)
+	/* Ready To Send. */
+		#define CMDQ_MODIFY_QP_NEW_STATE_RTS		UINT32_C(0x3)
+	/* SQ Drain. */
+		#define CMDQ_MODIFY_QP_NEW_STATE_SQD		UINT32_C(0x4)
+	/* SQ Error. */
+		#define CMDQ_MODIFY_QP_NEW_STATE_SQE		UINT32_C(0x5)
+	/* Error. */
+		#define CMDQ_MODIFY_QP_NEW_STATE_ERR		UINT32_C(0x6)
+		#define CMDQ_MODIFY_QP_NEW_STATE_LAST	CMDQ_MODIFY_QP_NEW_STATE_ERR
+	/* Enable SQ drain asynchronous notification. */
+	#define CMDQ_MODIFY_QP_EN_SQD_ASYNC_NOTIFY	UINT32_C(0x10)
+	/* unused1 is 1 b */
+	#define CMDQ_MODIFY_QP_UNUSED1		UINT32_C(0x20)
+	/* network type. */
+	#define CMDQ_MODIFY_QP_NETWORK_TYPE_MASK	UINT32_C(0xc0)
+	#define CMDQ_MODIFY_QP_NETWORK_TYPE_SFT	6
+	/* RoCEv1. */
+		#define CMDQ_MODIFY_QP_NETWORK_TYPE_ROCEV1	(UINT32_C(0x0) << 6)
+	/* RoCEv2 IPv4. */
+		#define CMDQ_MODIFY_QP_NETWORK_TYPE_ROCEV2_IPV4  (UINT32_C(0x2) << 6)
+	/* RoCEv2 IPv6. */
+		#define CMDQ_MODIFY_QP_NETWORK_TYPE_ROCEV2_IPV6  (UINT32_C(0x3) << 6)
+		#define CMDQ_MODIFY_QP_NETWORK_TYPE_LAST	CMDQ_MODIFY_QP_NETWORK_TYPE_ROCEV2_IPV6
+	/* Access flags. */
+	uint8_t	access;
+	#define CMDQ_MODIFY_QP_ACCESS_REMOTE_ATOMIC_REMOTE_READ_REMOTE_WRITE_LOCAL_WRITE_MASK		UINT32_C(0xff)
+	#define CMDQ_MODIFY_QP_ACCESS_REMOTE_ATOMIC_REMOTE_READ_REMOTE_WRITE_LOCAL_WRITE_SFT		0
+	/* Local write access. */
+	#define CMDQ_MODIFY_QP_ACCESS_LOCAL_WRITE							UINT32_C(0x1)
+	/* Remote write access. */
+	#define CMDQ_MODIFY_QP_ACCESS_REMOTE_WRITE							UINT32_C(0x2)
+	/* Remote read access. */
+	#define CMDQ_MODIFY_QP_ACCESS_REMOTE_READ							UINT32_C(0x4)
 	/*
-	 * If set to 1, then EXT EM External Record table is supported.
-	 * If set to 0, EXT EM External Record table is not
-	 * supported.  (This table includes action record, EFC
-	 * pointers, encap pointers)
+	 * Remote atomic access. Applicable to devices that support
+	 * Atomic operations.
 	 */
-	#define HWRM_TF_EXT_EM_QCAPS_OUTPUT_SUPPORTED_EXTERNAL_RECORD_TABLE		UINT32_C(0x4)
+	#define CMDQ_MODIFY_QP_ACCESS_REMOTE_ATOMIC							UINT32_C(0x8)
+	/* P_KEY. */
+	uint16_t	pkey;
+	/* Q_KEY. */
+	uint32_t	qkey;
+	/* Destination GID. */
+	uint32_t	dgid[4];
+	/* Flow label. */
+	uint32_t	flow_label;
+	/* Source GID index. */
+	uint16_t	sgid_index;
+	/* Hop limit. */
+	uint8_t	hop_limit;
+	/* Traffic class. */
+	uint8_t	traffic_class;
+	/* Destination MAC address. */
+	uint16_t	dest_mac[3];
+	uint8_t	tos_dscp_tos_ecn;
+	/* IP TOS ECN. Valid values are 1 or 2 when ECN is enabled. */
+	#define CMDQ_MODIFY_QP_TOS_ECN_MASK UINT32_C(0x3)
+	#define CMDQ_MODIFY_QP_TOS_ECN_SFT  0
+	/* IP TOS DSCP. */
+	#define CMDQ_MODIFY_QP_TOS_DSCP_MASK UINT32_C(0xfc)
+	#define CMDQ_MODIFY_QP_TOS_DSCP_SFT 2
+	uint8_t	path_mtu_pingpong_push_enable;
 	/*
-	 * If set to 1, then EXT EM External Flow Counters table is
-	 * supported.
-	 * If set to 0, EXT EM External Flow Counters table is not
-	 * supported.
+	 * Driver requests for ping pong push mode to be enabled for this
+	 * QP. This request can be done only during modify from RST to INIT
+	 * state.
 	 */
-	#define HWRM_TF_EXT_EM_QCAPS_OUTPUT_SUPPORTED_EXTERNAL_FLOW_COUNTERS_TABLE	UINT32_C(0x8)
+	#define CMDQ_MODIFY_QP_PINGPONG_PUSH_ENABLE	UINT32_C(0x1)
+	/* unused3 is 3 b */
+	#define CMDQ_MODIFY_QP_UNUSED3_MASK		UINT32_C(0xe)
+	#define CMDQ_MODIFY_QP_UNUSED3_SFT		1
+	/* Path MTU. */
+	#define CMDQ_MODIFY_QP_PATH_MTU_MASK		UINT32_C(0xf0)
+	#define CMDQ_MODIFY_QP_PATH_MTU_SFT		4
+	/* 256. */
+		#define CMDQ_MODIFY_QP_PATH_MTU_MTU_256	(UINT32_C(0x0) << 4)
+	/* 512. */
+		#define CMDQ_MODIFY_QP_PATH_MTU_MTU_512	(UINT32_C(0x1) << 4)
+	/* 1024. */
+		#define CMDQ_MODIFY_QP_PATH_MTU_MTU_1024	(UINT32_C(0x2) << 4)
+	/* 2048. */
+		#define CMDQ_MODIFY_QP_PATH_MTU_MTU_2048	(UINT32_C(0x3) << 4)
+	/* 4096. */
+		#define CMDQ_MODIFY_QP_PATH_MTU_MTU_4096	(UINT32_C(0x4) << 4)
+	/* 8192. */
+		#define CMDQ_MODIFY_QP_PATH_MTU_MTU_8192	(UINT32_C(0x5) << 4)
+		#define CMDQ_MODIFY_QP_PATH_MTU_LAST		CMDQ_MODIFY_QP_PATH_MTU_MTU_8192
+	/* Timeout value for SWQEs. */
+	uint8_t	timeout;
+	/* Max retry count for WQEs. */
+	uint8_t	retry_cnt;
+	/* Max RNR retry count for WQEs. */
+	uint8_t	rnr_retry;
+	/* Min RNR timer that the QP will report to the remote. */
+	uint8_t	min_rnr_timer;
+	/* RQ start packet sequence number. */
+	uint32_t	rq_psn;
+	/* SQ start packet sequence number. */
+	uint32_t	sq_psn;
+	/* Max outstanding RDMA read atomic. */
+	uint8_t	max_rd_atomic;
+	/* Max destination outstanding RDMA read atomic. */
+	uint8_t	max_dest_rd_atomic;
+	uint16_t	enable_cc;
+	/* Enable congestion control. */
+	#define CMDQ_MODIFY_QP_ENABLE_CC	UINT32_C(0x1)
+	/* unused15 is 15 b */
+	#define CMDQ_MODIFY_QP_UNUSED15_MASK UINT32_C(0xfffe)
+	#define CMDQ_MODIFY_QP_UNUSED15_SFT  1
+	/* Max send WQE. */
+	uint32_t	sq_size;
+	/* Max recv WQE. */
+	uint32_t	rq_size;
+	/* Max send SGEs per SWQE. */
+	uint16_t	sq_sge;
+	/* Max recv SGEs per RWQE. */
+	uint16_t	rq_sge;
+	/* Max inline data length (up to 120 bytes). */
+	uint32_t	max_inline_data;
+	/* Destination QP id. */
+	uint32_t	dest_qp_id;
+	/* This is the DPI RoCE driver allocated for ping pong push. */
+	uint32_t	pingpong_push_dpi;
+	/* Source MAC. (Unused. Comes from Source GID index) */
+	uint16_t	src_mac[3];
+	uint16_t	vlan_pcp_vlan_dei_vlan_id;
+	/* VLAN id. (Unused. Comes from Source GID index) */
+	#define CMDQ_MODIFY_QP_VLAN_ID_MASK UINT32_C(0xfff)
+	#define CMDQ_MODIFY_QP_VLAN_ID_SFT  0
+	/* VLAN DEI field - Drop Eligibility Indicator. */
+	#define CMDQ_MODIFY_QP_VLAN_DEI	UINT32_C(0x1000)
+	/* VLAN PCP field - Priority Code Point. */
+	#define CMDQ_MODIFY_QP_VLAN_PCP_MASK UINT32_C(0xe000)
+	#define CMDQ_MODIFY_QP_VLAN_PCP_SFT 13
+	/* IRRQ address. */
+	uint64_t	irrq_addr;
+	/* ORRQ address. */
+	uint64_t	orrq_addr;
 	/*
-	 * If set to 1, then FID table used for implicit flow flush
-	 * is supported.
-	 * If set to 0, then FID table used for implicit flow flush
-	 * is not supported.
+	 * Extended Modify mask signifies the field that is requesting the
+	 * change.
 	 */
-	#define HWRM_TF_EXT_EM_QCAPS_OUTPUT_SUPPORTED_FID_TABLE			UINT32_C(0x10)
+	uint32_t	ext_modify_mask;
+	/* Extended RoCE statistics context id change */
+	#define CMDQ_MODIFY_QP_EXT_MODIFY_MASK_EXT_STATS_CTX	UINT32_C(0x1)
+	/* The schq_id field is valid */
+	#define CMDQ_MODIFY_QP_EXT_MODIFY_MASK_SCHQ_ID_VALID	UINT32_C(0x2)
+	/* Extended RoCE statistics context id. */
+	uint32_t	ext_stats_ctx_id;
 	/*
-	 * If set to 1, then table scopes are supported.
-	 * If set to 0, then table scopes are not supported.
+	 * Identifies the new scheduling queue to associate to the RoCE QP.
+	 * A value of zero indicates that the QP is being modified to use
+	 * the default scheduling queue. Specified scheduling queue id is
+	 * allocated by firmware (via HWRM_SCHQ_ALLOC) when the device supports
+	 * the `scheduling queue` feature.
 	 */
-	#define HWRM_TF_EXT_EM_QCAPS_OUTPUT_SUPPORTED_TBL_SCOPES			UINT32_C(0x20)
+	uint16_t	schq_id;
+	/* unused_0 is 16 b */
+	uint16_t	unused_0;
+	/* reserved32 is 32 b */
+	uint32_t	reserved32;
+} cmdq_modify_qp_t, *pcmdq_modify_qp_t;
+
+/* creq_modify_qp_resp (size:128b/16B) */
+
+typedef struct creq_modify_qp_resp {
+	uint8_t	type;
 	/*
-	 * The maximum number of entries supported by EXT EM. When
-	 * configuring the host memory the number of numbers of
-	 * entries that can supported are -
-	 *	32k, 64k 128k, 256k, 512k, 1M, 2M, 4M, 8M, 32M, 64M,
-	 *	128M entries.
-	 * Any value that are not these values, the FW will round
-	 * down to the closest support number of entries.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint32_t	max_entries_supported;
+	#define CREQ_MODIFY_QP_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_MODIFY_QP_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_MODIFY_QP_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_MODIFY_QP_RESP_TYPE_LAST	CREQ_MODIFY_QP_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* QP context id */
+	uint32_t	xid;
+	uint8_t	v;
 	/*
-	 * The entry size in bytes of each entry in the EXT EM
-	 * KEY0/KEY1 tables.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint16_t	key_entry_size;
+	#define CREQ_MODIFY_QP_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Modify QP command response. */
+	#define CREQ_MODIFY_QP_RESP_EVENT_MODIFY_QP UINT32_C(0x3)
+	#define CREQ_MODIFY_QP_RESP_EVENT_LAST	CREQ_MODIFY_QP_RESP_EVENT_MODIFY_QP
+	uint8_t	pingpong_push_state_index_enabled;
 	/*
-	 * The entry size in bytes of each entry in the EXT EM RECORD
-	 * tables.
+	 * When set it indicates that FW was able to successfully enable
+	 * ping pong push mode for this QP.
 	 */
-	uint16_t	record_entry_size;
-	/* The entry size in bytes of each entry in the EXT EM EFC tables. */
-	uint16_t	efc_entry_size;
-	/* The FID size in bytes of each entry in the EXT EM FID tables. */
-	uint16_t	fid_entry_size;
-	/* Maximum number of ctxt mem allocations allowed. */
-	uint32_t	max_ctxt_mem_allocs;
+	#define CREQ_MODIFY_QP_RESP_PINGPONG_PUSH_ENABLED	UINT32_C(0x1)
 	/*
-	 * Maximum number of static buckets that can be assigned to lookup
-	 * table scopes.
+	 * When ping pong push mode is enabled this field will give the
+	 * index into the push page where the QP has been mapped.
 	 */
-	uint32_t	max_static_buckets;
-	/* unused. */
-	uint8_t	unused1[7];
+	#define CREQ_MODIFY_QP_RESP_PINGPONG_PUSH_INDEX_MASK  UINT32_C(0xe)
+	#define CREQ_MODIFY_QP_RESP_PINGPONG_PUSH_INDEX_SFT   1
 	/*
-	 * This field is used in Output records to indicate that the
-	 * output is completely written to RAM. This field should be
-	 * read as '1' to indicate that the output has been
-	 * completely written.  When writing a command completion or
-	 * response to an internal processor, the order of writes has
-	 * to be such that this field is written last.
+	 * This bit will tell whether to use ping or pong buffer
+	 * for first push operation. 0 - ping buffer, 1 - pong buffer.
 	 */
-	uint8_t	valid;
-} hwrm_tf_ext_em_qcaps_output_t, *phwrm_tf_ext_em_qcaps_output_t;
+	#define CREQ_MODIFY_QP_RESP_PINGPONG_PUSH_STATE	UINT32_C(0x10)
+	uint8_t	reserved8;
+	/* Scrambled src mac needed to calculate UDP source port. */
+	uint32_t	lag_src_mac;
+} creq_modify_qp_resp_t, *pcreq_modify_qp_resp_t;
 
-/*********************
- * hwrm_tf_ext_em_op *
- *********************/
+/************
+ * query_qp *
+ ************/
 
 
-/* hwrm_tf_ext_em_op_input (size:256b/32B) */
+/* cmdq_query_qp (size:192b/24B) */
 
-typedef struct hwrm_tf_ext_em_op_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
-	 */
-	uint16_t	cmpl_ring;
-	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
-	 */
-	uint16_t	seq_id;
-	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
-	 */
-	uint16_t	target_id;
-	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
-	 */
-	uint64_t	resp_addr;
-	/* Control flags. */
+typedef struct cmdq_query_qp {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Query QP command retrieves info about the specified QP. */
+	#define CMDQ_QUERY_QP_OPCODE_QUERY_QP UINT32_C(0x4)
+	#define CMDQ_QUERY_QP_OPCODE_LAST	CMDQ_QUERY_QP_OPCODE_QUERY_QP
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
 	uint16_t	flags;
-	/* Indicates the flow direction. */
-	#define HWRM_TF_EXT_EM_OP_INPUT_FLAGS_DIR	UINT32_C(0x1)
-	/* If this bit set to 0, then it indicates rx flow. */
-		#define HWRM_TF_EXT_EM_OP_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
-	/* If this bit is set to 1, then it indicates tx flow. */
-		#define HWRM_TF_EXT_EM_OP_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
-		#define HWRM_TF_EXT_EM_OP_INPUT_FLAGS_DIR_LAST HWRM_TF_EXT_EM_OP_INPUT_FLAGS_DIR_TX
-	/* unused. */
-	uint16_t	unused0;
-	/* The number of EXT EM key table entries to be configured. */
-	uint16_t	op;
-	/* This value is reserved and should not be used. */
-	#define HWRM_TF_EXT_EM_OP_INPUT_OP_RESERVED	UINT32_C(0x0)
-	/*
-	 * To properly stop EXT EM and ensure there are no DMA's,
-	 * the caller must disable EXT EM for the given PF, using
-	 * this call. This will safely disable EXT EM and ensure
-	 * that all DMA'ed to the keys/records/efc have been
-	 * completed.
-	 */
-	#define HWRM_TF_EXT_EM_OP_INPUT_OP_EXT_EM_DISABLE UINT32_C(0x1)
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+	/* QP context id */
+	uint32_t	qp_cid;
+	uint32_t	unused_0;
+} cmdq_query_qp_t, *pcmdq_query_qp_t;
+
+/* creq_query_qp_resp (size:128b/16B) */
+
+typedef struct creq_query_qp_resp {
+	uint8_t	type;
 	/*
-	 * Once the EXT EM host memory has been configured, EXT EM
-	 * options have been configured. Then the caller should
-	 * enable EXT EM for the given PF. Note once this call has
-	 * been made, then the EXT EM mechanism will be active and
-	 * DMA's will occur as packets are processed.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	#define HWRM_TF_EXT_EM_OP_INPUT_OP_EXT_EM_ENABLE  UINT32_C(0x2)
+	#define CREQ_QUERY_QP_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_QUERY_QP_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_QUERY_QP_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_QUERY_QP_RESP_TYPE_LAST	CREQ_QUERY_QP_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Side buffer size in 16-byte units */
+	uint32_t	size;
+	uint8_t	v;
 	/*
-	 * Clear EXT EM settings for the given PF so that the
-	 * register values are reset back to their initial state.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	#define HWRM_TF_EXT_EM_OP_INPUT_OP_EXT_EM_CLEANUP UINT32_C(0x3)
-	#define HWRM_TF_EXT_EM_OP_INPUT_OP_LAST	HWRM_TF_EXT_EM_OP_INPUT_OP_EXT_EM_CLEANUP
-	/* unused. */
-	uint16_t	unused1;
-	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
-	uint32_t	fw_session_id;
-	/* unused. */
-	uint32_t	unused2;
-} hwrm_tf_ext_em_op_input_t, *phwrm_tf_ext_em_op_input_t;
+	#define CREQ_QUERY_QP_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Query QP command response. */
+	#define CREQ_QUERY_QP_RESP_EVENT_QUERY_QP UINT32_C(0x4)
+	#define CREQ_QUERY_QP_RESP_EVENT_LAST	CREQ_QUERY_QP_RESP_EVENT_QUERY_QP
+	uint8_t	reserved48[6];
+} creq_query_qp_resp_t, *pcreq_query_qp_resp_t;
 
-/* hwrm_tf_ext_em_op_output (size:128b/16B) */
+/* Query QP command response side buffer structure. */
+/* creq_query_qp_resp_sb (size:832b/104B) */
 
-typedef struct hwrm_tf_ext_em_op_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* unused. */
-	uint8_t	unused0[7];
+typedef struct creq_query_qp_resp_sb {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Query QP command response. */
+	#define CREQ_QUERY_QP_RESP_SB_OPCODE_QUERY_QP UINT32_C(0x4)
+	#define CREQ_QUERY_QP_RESP_SB_OPCODE_LAST	CREQ_QUERY_QP_RESP_SB_OPCODE_QUERY_QP
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* QP context id */
+	uint32_t	xid;
+	uint8_t	en_sqd_async_notify_state;
+	/* QP state */
+	#define CREQ_QUERY_QP_RESP_SB_STATE_MASK		UINT32_C(0xf)
+	#define CREQ_QUERY_QP_RESP_SB_STATE_SFT		0
+	/* Reset. */
+		#define CREQ_QUERY_QP_RESP_SB_STATE_RESET		UINT32_C(0x0)
+	/* Init. */
+		#define CREQ_QUERY_QP_RESP_SB_STATE_INIT		UINT32_C(0x1)
+	/* Ready To Receive. */
+		#define CREQ_QUERY_QP_RESP_SB_STATE_RTR		UINT32_C(0x2)
+	/* Ready To Send. */
+		#define CREQ_QUERY_QP_RESP_SB_STATE_RTS		UINT32_C(0x3)
+	/* SQ Drain. */
+		#define CREQ_QUERY_QP_RESP_SB_STATE_SQD		UINT32_C(0x4)
+	/* SQ Error. */
+		#define CREQ_QUERY_QP_RESP_SB_STATE_SQE		UINT32_C(0x5)
+	/* Error. */
+		#define CREQ_QUERY_QP_RESP_SB_STATE_ERR		UINT32_C(0x6)
+		#define CREQ_QUERY_QP_RESP_SB_STATE_LAST		CREQ_QUERY_QP_RESP_SB_STATE_ERR
+	/* SQ drain asynchronous notification. */
+	#define CREQ_QUERY_QP_RESP_SB_EN_SQD_ASYNC_NOTIFY	UINT32_C(0x10)
+	/* Enable congestion control. */
+	#define CREQ_QUERY_QP_RESP_SB_UNUSED3_MASK		UINT32_C(0xe0)
+	#define CREQ_QUERY_QP_RESP_SB_UNUSED3_SFT		5
+	/* Access flags. */
+	uint8_t	access;
+	#define CREQ_QUERY_QP_RESP_SB_ACCESS_REMOTE_ATOMIC_REMOTE_READ_REMOTE_WRITE_LOCAL_WRITE_MASK		UINT32_C(0xff)
+	#define CREQ_QUERY_QP_RESP_SB_ACCESS_REMOTE_ATOMIC_REMOTE_READ_REMOTE_WRITE_LOCAL_WRITE_SFT		0
+	/* Local write access. */
+	#define CREQ_QUERY_QP_RESP_SB_ACCESS_LOCAL_WRITE							UINT32_C(0x1)
+	/* Remote write access. */
+	#define CREQ_QUERY_QP_RESP_SB_ACCESS_REMOTE_WRITE							UINT32_C(0x2)
+	/* Remote read access. */
+	#define CREQ_QUERY_QP_RESP_SB_ACCESS_REMOTE_READ							UINT32_C(0x4)
+	/* Remote atomic access. */
+	#define CREQ_QUERY_QP_RESP_SB_ACCESS_REMOTE_ATOMIC							UINT32_C(0x8)
+	/* P_KEY index. */
+	uint16_t	pkey;
+	/* Q_KEY. */
+	uint32_t	qkey;
 	/*
-	 * This field is used in Output records to indicate that the
-	 * output is completely written to RAM. This field should be
-	 * read as '1' to indicate that the output has been
-	 * completely written.  When writing a command completion or
-	 * response to an internal processor, the order of writes has
-	 * to be such that this field is written last.
+	 * UDP source port used in RoCEv2 packets. Valid only when
+	 * change_udp_src_port_wqe_supported feature is advertised.
 	 */
-	uint8_t	valid;
-} hwrm_tf_ext_em_op_output_t, *phwrm_tf_ext_em_op_output_t;
+	uint16_t	udp_src_port;
+	uint16_t	reserved16;
+	/* Destination GID. */
+	uint32_t	dgid[4];
+	/* Flow label. */
+	uint32_t	flow_label;
+	/* Source GID index. */
+	uint16_t	sgid_index;
+	/* Hop limit. */
+	uint8_t	hop_limit;
+	/* Traffic class. */
+	uint8_t	traffic_class;
+	/* Destination MAC address. */
+	uint16_t	dest_mac[3];
+	uint16_t	path_mtu_dest_vlan_id;
+	/* Destination VLAN ID. */
+	#define CREQ_QUERY_QP_RESP_SB_DEST_VLAN_ID_MASK UINT32_C(0xfff)
+	#define CREQ_QUERY_QP_RESP_SB_DEST_VLAN_ID_SFT 0
+	/* Path MTU. */
+	#define CREQ_QUERY_QP_RESP_SB_PATH_MTU_MASK	UINT32_C(0xf000)
+	#define CREQ_QUERY_QP_RESP_SB_PATH_MTU_SFT	12
+	/* 256. */
+		#define CREQ_QUERY_QP_RESP_SB_PATH_MTU_MTU_256   (UINT32_C(0x0) << 12)
+	/* 512. */
+		#define CREQ_QUERY_QP_RESP_SB_PATH_MTU_MTU_512   (UINT32_C(0x1) << 12)
+	/* 1024. */
+		#define CREQ_QUERY_QP_RESP_SB_PATH_MTU_MTU_1024  (UINT32_C(0x2) << 12)
+	/* 2048. */
+		#define CREQ_QUERY_QP_RESP_SB_PATH_MTU_MTU_2048  (UINT32_C(0x3) << 12)
+	/* 4096. */
+		#define CREQ_QUERY_QP_RESP_SB_PATH_MTU_MTU_4096  (UINT32_C(0x4) << 12)
+	/* 8192. */
+		#define CREQ_QUERY_QP_RESP_SB_PATH_MTU_MTU_8192  (UINT32_C(0x5) << 12)
+		#define CREQ_QUERY_QP_RESP_SB_PATH_MTU_LAST	CREQ_QUERY_QP_RESP_SB_PATH_MTU_MTU_8192
+	/* Timeout value for SWQEs. */
+	uint8_t	timeout;
+	/* Max retry count for WQEs. */
+	uint8_t	retry_cnt;
+	/* Max RNR retry count for WQEs. */
+	uint8_t	rnr_retry;
+	/* Min RNR timer that the QP will report to the remote. */
+	uint8_t	min_rnr_timer;
+	/* RQ start packet sequence number. */
+	uint32_t	rq_psn;
+	/* SQ start packet sequence number. */
+	uint32_t	sq_psn;
+	/* Max outstanding RDMA read atomic. */
+	uint8_t	max_rd_atomic;
+	/* Max destination outstanding RDMA read atomic. */
+	uint8_t	max_dest_rd_atomic;
+	uint8_t	tos_dscp_tos_ecn;
+	/* IP TOS ECN. */
+	#define CREQ_QUERY_QP_RESP_SB_TOS_ECN_MASK UINT32_C(0x3)
+	#define CREQ_QUERY_QP_RESP_SB_TOS_ECN_SFT  0
+	/* IP TOS DSCP. */
+	#define CREQ_QUERY_QP_RESP_SB_TOS_DSCP_MASK UINT32_C(0xfc)
+	#define CREQ_QUERY_QP_RESP_SB_TOS_DSCP_SFT 2
+	uint8_t	enable_cc;
+	/* enable_cc is 1 b */
+	#define CREQ_QUERY_QP_RESP_SB_ENABLE_CC	UINT32_C(0x1)
+	/* Max send WQE. */
+	uint32_t	sq_size;
+	/* Max recv WQE. */
+	uint32_t	rq_size;
+	/* Max send SGEs per SWQE. */
+	uint16_t	sq_sge;
+	/* Max recv SGEs per RWQE (NOT SUPPORTED BY HARDWARE). */
+	uint16_t	rq_sge;
+	/* Max inline data length (up to 120 bytes). */
+	uint32_t	max_inline_data;
+	/* Destination QP id. */
+	uint32_t	dest_qp_id;
+	/* Port ID associated with the QP. */
+	uint16_t	port_id;
+	uint8_t	unused_0;
+	/* Statistic collection ID allocated for this QP. */
+	uint8_t	stat_collection_id;
+	/* Source MAC. */
+	uint16_t	src_mac[3];
+	uint16_t	vlan_pcp_vlan_dei_vlan_id;
+	/* Source VLAN id. */
+	#define CREQ_QUERY_QP_RESP_SB_VLAN_ID_MASK UINT32_C(0xfff)
+	#define CREQ_QUERY_QP_RESP_SB_VLAN_ID_SFT  0
+	/* VLAN DEI field - Drop Eligibility Indicator. */
+	#define CREQ_QUERY_QP_RESP_SB_VLAN_DEI	UINT32_C(0x1000)
+	/* VLAN PCP field - Priority Code Point. */
+	#define CREQ_QUERY_QP_RESP_SB_VLAN_PCP_MASK UINT32_C(0xe000)
+	#define CREQ_QUERY_QP_RESP_SB_VLAN_PCP_SFT 13
+} creq_query_qp_resp_sb_t, *pcreq_query_qp_resp_sb_t;
 
-/**********************
- * hwrm_tf_ext_em_cfg *
- **********************/
+/*******************
+ * query_qp_extend *
+ *******************/
 
 
-/* hwrm_tf_ext_em_cfg_input (size:512b/64B) */
+/* cmdq_query_qp_extend (size:192b/24B) */
 
-typedef struct hwrm_tf_ext_em_cfg_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
-	 */
-	uint16_t	cmpl_ring;
-	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
-	 */
-	uint16_t	seq_id;
+typedef struct cmdq_query_qp_extend {
+	/* Command opcode. */
+	uint8_t	opcode;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Query QP extend command retrieves info about multiple QPs
+	 * associated with a specific PF.
 	 */
-	uint16_t	target_id;
+	#define CMDQ_QUERY_QP_EXTEND_OPCODE_QUERY_QP_EXTEND UINT32_C(0x91)
+	#define CMDQ_QUERY_QP_EXTEND_OPCODE_LAST	CMDQ_QUERY_QP_EXTEND_OPCODE_QUERY_QP_EXTEND
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Number of QPs for which FW needs to query and provide info back to
+	 * host.
 	 */
+	uint8_t	num_qps;
+	/* Host address of the response. */
 	uint64_t	resp_addr;
-	/* Control flags. */
-	uint32_t	flags;
-	/* Indicates the flow direction. */
-	#define HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR		UINT32_C(0x1)
-	/* If this bit set to 0, then it indicates rx flow. */
-		#define HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_RX		UINT32_C(0x0)
-	/* If this bit is set to 1, then it indicates tx flow. */
-		#define HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_TX		UINT32_C(0x1)
-		#define HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_LAST		HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_TX
-	/* When set to 1, all offloaded flows will be sent to EXT EM. */
-	#define HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_PREFERRED_OFFLOAD	UINT32_C(0x2)
-	/* When set to 1, secondary, 0 means primary. */
-	#define HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_SECONDARY_PF	UINT32_C(0x4)
-	/*
-	 * Group_id which used by Firmware to identify memory pools belonging
-	 * to certain group.
-	 */
-	uint16_t	group_id;
-	/*
-	 * Dynamically reconfigure EEM pending cache every 1/10th of second.
-	 * If set to 0 it will disable the EEM HW flush of the pending cache.
-	 */
-	uint8_t	flush_interval;
-	/* unused. */
-	uint8_t	unused0;
-	/*
-	 * Configured EXT EM with the given number of entries. All
-	 * the EXT EM tables KEY0, KEY1, RECORD, EFC all have the
-	 * same number of entries and all tables will be configured
-	 * using this value. Current minimum value is 32k. Current
-	 * maximum value is 128M.
-	 */
-	uint32_t	num_entries;
-	uint32_t	enables;
-	/*
-	 * This bit must be '1' for the group_id field to be
-	 * configured.
-	 */
-	#define HWRM_TF_EXT_EM_CFG_INPUT_ENABLES_GROUP_ID		UINT32_C(0x1)
-	/*
-	 * This bit must be '1' for the flush_interval field to be
-	 * configured.
-	 */
-	#define HWRM_TF_EXT_EM_CFG_INPUT_ENABLES_FLUSH_INTERVAL	UINT32_C(0x2)
-	/*
-	 * This bit must be '1' for the num_entries field to be
-	 * configured.
-	 */
-	#define HWRM_TF_EXT_EM_CFG_INPUT_ENABLES_NUM_ENTRIES		UINT32_C(0x4)
-	/*
-	 * This bit must be '1' for the key0_ctx_id field to be
-	 * configured.
-	 */
-	#define HWRM_TF_EXT_EM_CFG_INPUT_ENABLES_KEY0_CTX_ID		UINT32_C(0x8)
-	/*
-	 * This bit must be '1' for the key1_ctx_id field to be
-	 * configured.
-	 */
-	#define HWRM_TF_EXT_EM_CFG_INPUT_ENABLES_KEY1_CTX_ID		UINT32_C(0x10)
+	/* Unique identified for a function */
+	uint32_t	function_id;
+	/* PF number */
+	#define CMDQ_QUERY_QP_EXTEND_PF_NUM_MASK  UINT32_C(0xff)
+	#define CMDQ_QUERY_QP_EXTEND_PF_NUM_SFT   0
+	/* VF number */
+	#define CMDQ_QUERY_QP_EXTEND_VF_NUM_MASK  UINT32_C(0xffff00)
+	#define CMDQ_QUERY_QP_EXTEND_VF_NUM_SFT   8
+	/* When set the vf_num is valid. */
+	#define CMDQ_QUERY_QP_EXTEND_VF_VALID	UINT32_C(0x1000000)
 	/*
-	 * This bit must be '1' for the record_ctx_id field to be
-	 * configured.
+	 * This is the current index where firmware left off for query qp.
+	 * Driver will pass this back in the next query_qp_extend command.
 	 */
-	#define HWRM_TF_EXT_EM_CFG_INPUT_ENABLES_RECORD_CTX_ID	UINT32_C(0x20)
+	uint32_t	current_index;
+} cmdq_query_qp_extend_t, *pcmdq_query_qp_extend_t;
+
+/* creq_query_qp_extend_resp (size:128b/16B) */
+
+typedef struct creq_query_qp_extend_resp {
+	uint8_t	type;
 	/*
-	 * This bit must be '1' for the efc_ctx_id field to be
-	 * configured.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	#define HWRM_TF_EXT_EM_CFG_INPUT_ENABLES_EFC_CTX_ID		UINT32_C(0x40)
+	#define CREQ_QUERY_QP_EXTEND_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_QUERY_QP_EXTEND_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_QUERY_QP_EXTEND_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_QUERY_QP_EXTEND_RESP_TYPE_LAST	CREQ_QUERY_QP_EXTEND_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Side buffer size in 16-byte units */
+	uint32_t	size;
+	uint8_t	v;
 	/*
-	 * This bit must be '1' for the fid_ctx_id field to be
-	 * configured.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	#define HWRM_TF_EXT_EM_CFG_INPUT_ENABLES_FID_CTX_ID		UINT32_C(0x80)
+	#define CREQ_QUERY_QP_EXTEND_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Query QP extend command response. */
+	#define CREQ_QUERY_QP_EXTEND_RESP_EVENT_QUERY_QP_EXTEND UINT32_C(0x91)
+	#define CREQ_QUERY_QP_EXTEND_RESP_EVENT_LAST	CREQ_QUERY_QP_EXTEND_RESP_EVENT_QUERY_QP_EXTEND
+	uint16_t	reserved16;
 	/*
-	 * This bit must be '1' for the action_ctx_id field to be
-	 * configured.
+	 * This is the current index where firmware left off for query qp.
+	 * Driver will pass this back in the next query_qp_extend command.
 	 */
-	#define HWRM_TF_EXT_EM_CFG_INPUT_ENABLES_ACTION_CTX_ID	UINT32_C(0x100)
+	uint32_t	current_index;
+} creq_query_qp_extend_resp_t, *pcreq_query_qp_extend_resp_t;
+
+/* Query QP extend command response side buffer structure. */
+/* creq_query_qp_extend_resp_sb (size:384b/48B) */
+
+typedef struct creq_query_qp_extend_resp_sb {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Query QP command extend response. */
+	#define CREQ_QUERY_QP_EXTEND_RESP_SB_OPCODE_QUERY_QP_EXTEND UINT32_C(0x91)
+	#define CREQ_QUERY_QP_EXTEND_RESP_SB_OPCODE_LAST	CREQ_QUERY_QP_EXTEND_RESP_SB_OPCODE_QUERY_QP_EXTEND
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* QP context id */
+	uint32_t	xid;
+	uint8_t	state;
+	/* QP state */
+	#define CREQ_QUERY_QP_EXTEND_RESP_SB_STATE_MASK  UINT32_C(0xf)
+	#define CREQ_QUERY_QP_EXTEND_RESP_SB_STATE_SFT   0
+	/* Reset. */
+		#define CREQ_QUERY_QP_EXTEND_RESP_SB_STATE_RESET   UINT32_C(0x0)
+	/* Init. */
+		#define CREQ_QUERY_QP_EXTEND_RESP_SB_STATE_INIT	UINT32_C(0x1)
+	/* Ready To Receive. */
+		#define CREQ_QUERY_QP_EXTEND_RESP_SB_STATE_RTR	UINT32_C(0x2)
+	/* Ready To Send. */
+		#define CREQ_QUERY_QP_EXTEND_RESP_SB_STATE_RTS	UINT32_C(0x3)
+	/* SQ Drain. */
+		#define CREQ_QUERY_QP_EXTEND_RESP_SB_STATE_SQD	UINT32_C(0x4)
+	/* SQ Error. */
+		#define CREQ_QUERY_QP_EXTEND_RESP_SB_STATE_SQE	UINT32_C(0x5)
+	/* Error. */
+		#define CREQ_QUERY_QP_EXTEND_RESP_SB_STATE_ERR	UINT32_C(0x6)
+		#define CREQ_QUERY_QP_EXTEND_RESP_SB_STATE_LAST   CREQ_QUERY_QP_EXTEND_RESP_SB_STATE_ERR
+	/*  */
+	#define CREQ_QUERY_QP_EXTEND_RESP_SB_UNUSED4_MASK UINT32_C(0xf0)
+	#define CREQ_QUERY_QP_EXTEND_RESP_SB_UNUSED4_SFT 4
+	uint8_t	reserved_8;
+	/* Port ID associated with the QP. */
+	uint16_t	port_id;
+	/* Q_KEY. */
+	uint32_t	qkey;
+	/* Source GID index. */
+	uint16_t	sgid_index;
+	/* Network type. */
+	uint8_t	network_type;
+	/* RoCEv1. */
+	#define CREQ_QUERY_QP_EXTEND_RESP_SB_NETWORK_TYPE_ROCEV1	UINT32_C(0x0)
+	/* RoCEv2 IPv4. */
+	#define CREQ_QUERY_QP_EXTEND_RESP_SB_NETWORK_TYPE_ROCEV2_IPV4 UINT32_C(0x2)
+	/* RoCEv2 IPv6. */
+	#define CREQ_QUERY_QP_EXTEND_RESP_SB_NETWORK_TYPE_ROCEV2_IPV6 UINT32_C(0x3)
+	#define CREQ_QUERY_QP_EXTEND_RESP_SB_NETWORK_TYPE_LAST	CREQ_QUERY_QP_EXTEND_RESP_SB_NETWORK_TYPE_ROCEV2_IPV6
+	uint8_t	unused_0;
+	/* Destination GID. */
+	uint32_t	dgid[4];
+	/* Destination QP id. */
+	uint32_t	dest_qp_id;
+	/* Statistic collection ID allocated for this QP. */
+	uint8_t	stat_collection_id;
+	uint8_t	reserved2_8;
+	uint16_t	reserved_16;
+} creq_query_qp_extend_resp_sb_t, *pcreq_query_qp_extend_resp_sb_t;
+
+/*
+ * TLV encapsulated Query QP extend control command response
+ * side buffer.
+ */
+/* creq_query_qp_extend_resp_sb_tlv (size:512b/64B) */
+
+typedef struct creq_query_qp_extend_resp_sb_tlv {
 	/*
-	 * This bit must be '1' for the action_tbl_scope field to be
-	 * configured.
+	 * The command discriminator is used to differentiate between various
+	 * types of HWRM messages. This includes legacy HWRM and RoCE slowpath
+	 * command messages as well as newer TLV encapsulated HWRM commands.
+	 *
+	 * For TLV encapsulated messages this field must be 0x8000.
 	 */
-	#define HWRM_TF_EXT_EM_CFG_INPUT_ENABLES_ACTION_TBL_SCOPE	UINT32_C(0x200)
+	uint16_t	cmd_discr;
+	uint8_t	reserved_8b;
+	uint8_t	tlv_flags;
 	/*
-	 * This bit must be '1' for the lkup_ctx_id field to be
-	 * configured.
+	 * Indicates the presence of additional TLV encapsulated data
+	 * follows this TLV.
 	 */
-	#define HWRM_TF_EXT_EM_CFG_INPUT_ENABLES_LKUP_CTX_ID		UINT32_C(0x400)
+	#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_TLV_FLAGS_MORE	UINT32_C(0x1)
+	/* Last TLV in a sequence of TLVs. */
+		#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_TLV_FLAGS_MORE_LAST	UINT32_C(0x0)
+	/* More TLVs follow this TLV. */
+		#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_TLV_FLAGS_MORE_NOT_LAST  UINT32_C(0x1)
 	/*
-	 * This bit must be '1' for the lkup_tbl_scope field to be
-	 * configured.
+	 * When an HWRM receiver detects a TLV type that it does not
+	 * support with the TLV required flag set, the receiver must
+	 * reject the HWRM message with an error code indicating an
+	 * unsupported TLV type.
 	 */
-	#define HWRM_TF_EXT_EM_CFG_INPUT_ENABLES_LKUP_TBL_SCOPE	UINT32_C(0x800)
+	#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_TLV_FLAGS_REQUIRED	UINT32_C(0x2)
+	/* No */
+		#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_TLV_FLAGS_REQUIRED_NO	(UINT32_C(0x0) << 1)
+	/* Yes */
+		#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_TLV_FLAGS_REQUIRED_YES   (UINT32_C(0x1) << 1)
+		#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_TLV_FLAGS_REQUIRED_LAST CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_TLV_FLAGS_REQUIRED_YES
 	/*
-	 * This bit must be '1' for the lkup_static_buckets field to be
-	 * configured.
+	 * This field defines the TLV type value which is divided into
+	 * two ranges to differentiate between global and local TLV types.
+	 * Global TLV types must be unique across all defined TLV types.
+	 * Local TLV types are valid only for extensions to a given
+	 * HWRM message and may be repeated across different HWRM message
+	 * types. There is a direct correlation of each HWRM message type
+	 * to a single global TLV type value.
+	 *
+	 * Global TLV range: `0 - (63k-1)`
+	 *
+	 * Local TLV range: `63k - (64k-1)`
 	 */
-	#define HWRM_TF_EXT_EM_CFG_INPUT_ENABLES_LKUP_STATIC_BUCKETS	UINT32_C(0x1000)
-	/* Configured EXT EM with the given context if for KEY0 table. */
-	uint16_t	key0_ctx_id;
-	/* Configured EXT EM with the given context if for KEY1 table. */
-	uint16_t	key1_ctx_id;
-	/* Configured EXT EM with the given context if for RECORD table. */
-	uint16_t	record_ctx_id;
-	/* Configured EXT EM with the given context if for EFC table. */
-	uint16_t	efc_ctx_id;
-	/* Configured EXT EM with the given context if for EFC table. */
-	uint16_t	fid_ctx_id;
-	/* Context id of action table scope. */
-	uint16_t	action_ctx_id;
-	/* Table scope id used for action record entries. */
-	uint16_t	action_tbl_scope;
-	/* Context id of lookup table scope. */
-	uint16_t	lkup_ctx_id;
-	/* Table scope id used for EM lookup entries. */
-	uint16_t	lkup_tbl_scope;
-	/* unused. */
-	uint16_t	unused1;
+	uint16_t	tlv_type;
 	/*
-	 * Number of 32B static buckets to be allocated at the beginning
-	 * of table scope.
+	 * Length of the message data encapsulated by this TLV in bytes.
+	 * This length does not include the size of the TLV header itself
+	 * and it must be an integer multiple of 8B.
 	 */
-	uint32_t	lkup_static_buckets;
-	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
-	uint32_t	fw_session_id;
-	/* unused. */
-	uint32_t	unused2;
-} hwrm_tf_ext_em_cfg_input_t, *phwrm_tf_ext_em_cfg_input_t;
-
-/* hwrm_tf_ext_em_cfg_output (size:128b/16B) */
-
-typedef struct hwrm_tf_ext_em_cfg_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* unused. */
-	uint8_t	unused0[7];
+	uint16_t	length;
 	/*
-	 * This field is used in Output records to indicate that the
-	 * output is completely written to RAM. This field should be
-	 * read as '1' to indicate that the output has been
-	 * completely written.  When writing a command completion or
-	 * response to an internal processor, the order of writes has
-	 * to be such that this field is written last.
+	 * Size of the tlv encapsulated response,
+	 * including all tlvs and extension data in 16-byte units.
 	 */
-	uint8_t	valid;
-} hwrm_tf_ext_em_cfg_output_t, *phwrm_tf_ext_em_cfg_output_t;
+	uint8_t	total_size;
+	uint8_t	reserved56[7];
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Query QP command extend response. */
+	#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_OPCODE_QUERY_QP_EXTEND UINT32_C(0x91)
+	#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_OPCODE_LAST	CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_OPCODE_QUERY_QP_EXTEND
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* QP context id */
+	uint32_t	xid;
+	uint8_t	state;
+	/* QP state */
+	#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_STATE_MASK  UINT32_C(0xf)
+	#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_STATE_SFT   0
+	/* Reset. */
+		#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_STATE_RESET   UINT32_C(0x0)
+	/* Init. */
+		#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_STATE_INIT	UINT32_C(0x1)
+	/* Ready To Receive. */
+		#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_STATE_RTR	UINT32_C(0x2)
+	/* Ready To Send. */
+		#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_STATE_RTS	UINT32_C(0x3)
+	/* SQ Drain. */
+		#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_STATE_SQD	UINT32_C(0x4)
+	/* SQ Error. */
+		#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_STATE_SQE	UINT32_C(0x5)
+	/* Error. */
+		#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_STATE_ERR	UINT32_C(0x6)
+		#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_STATE_LAST   CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_STATE_ERR
+	/*  */
+	#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_UNUSED4_MASK UINT32_C(0xf0)
+	#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_UNUSED4_SFT 4
+	uint8_t	reserved_8;
+	/* Port ID associated with the QP. */
+	uint16_t	port_id;
+	/* Q_KEY. */
+	uint32_t	qkey;
+	/* Source GID index. */
+	uint16_t	sgid_index;
+	/* Network type. */
+	uint8_t	network_type;
+	/* RoCEv1. */
+	#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_NETWORK_TYPE_ROCEV1	UINT32_C(0x0)
+	/* RoCEv2 IPv4. */
+	#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_NETWORK_TYPE_ROCEV2_IPV4 UINT32_C(0x2)
+	/* RoCEv2 IPv6. */
+	#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_NETWORK_TYPE_ROCEV2_IPV6 UINT32_C(0x3)
+	#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_NETWORK_TYPE_LAST	CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_NETWORK_TYPE_ROCEV2_IPV6
+	uint8_t	unused_0;
+	/* Destination GID. */
+	uint32_t	dgid[4];
+	/* Destination QP id. */
+	uint32_t	dest_qp_id;
+	/* Statistic collection ID allocated for this QP. */
+	uint8_t	stat_collection_id;
+	uint8_t	reserved2_8;
+	uint16_t	reserved_16;
+} creq_query_qp_extend_resp_sb_tlv_t, *pcreq_query_qp_extend_resp_sb_tlv_t;
 
-/***********************
- * hwrm_tf_ext_em_qcfg *
- ***********************/
+/**************
+ * create_srq *
+ **************/
 
 
-/* hwrm_tf_ext_em_qcfg_input (size:192b/24B) */
+/* cmdq_create_srq (size:512b/64B) */
 
-typedef struct hwrm_tf_ext_em_qcfg_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
-	 */
-	uint16_t	cmpl_ring;
-	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
-	 */
-	uint16_t	seq_id;
-	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
-	 */
-	uint16_t	target_id;
-	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
-	 */
+typedef struct cmdq_create_srq {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Create SRQ command allocates a SRQ with the specified parameters. */
+	#define CMDQ_CREATE_SRQ_OPCODE_CREATE_SRQ UINT32_C(0x5)
+	#define CMDQ_CREATE_SRQ_OPCODE_LAST	CMDQ_CREATE_SRQ_OPCODE_CREATE_SRQ
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* This SRQ uses the steering tag specified in the command. */
+	#define CMDQ_CREATE_SRQ_FLAGS_STEERING_TAG_VALID	UINT32_C(0x1)
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
 	uint64_t	resp_addr;
-	/* Control flags. */
-	uint32_t	flags;
-	/* Indicates the flow direction. */
-	#define HWRM_TF_EXT_EM_QCFG_INPUT_FLAGS_DIR	UINT32_C(0x1)
-	/* If this bit set to 0, then it indicates rx flow. */
-		#define HWRM_TF_EXT_EM_QCFG_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
-	/* If this bit is set to 1, then it indicates tx flow. */
-		#define HWRM_TF_EXT_EM_QCFG_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
-		#define HWRM_TF_EXT_EM_QCFG_INPUT_FLAGS_DIR_LAST HWRM_TF_EXT_EM_QCFG_INPUT_FLAGS_DIR_TX
-	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
-	uint32_t	fw_session_id;
-} hwrm_tf_ext_em_qcfg_input_t, *phwrm_tf_ext_em_qcfg_input_t;
-
-/* hwrm_tf_ext_em_qcfg_output (size:448b/56B) */
-
-typedef struct hwrm_tf_ext_em_qcfg_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Control flags. */
-	uint32_t	flags;
-	/* Indicates the flow direction. */
-	#define HWRM_TF_EXT_EM_QCFG_OUTPUT_FLAGS_DIR		UINT32_C(0x1)
-	/* If this bit set to 0, then it indicates rx flow. */
-		#define HWRM_TF_EXT_EM_QCFG_OUTPUT_FLAGS_DIR_RX		UINT32_C(0x0)
-	/* If this bit is set to 1, then it indicates tx flow. */
-		#define HWRM_TF_EXT_EM_QCFG_OUTPUT_FLAGS_DIR_TX		UINT32_C(0x1)
-		#define HWRM_TF_EXT_EM_QCFG_OUTPUT_FLAGS_DIR_LAST		HWRM_TF_EXT_EM_QCFG_OUTPUT_FLAGS_DIR_TX
-	/* When set to 1, all offloaded flows will be sent to EXT EM. */
-	#define HWRM_TF_EXT_EM_QCFG_OUTPUT_FLAGS_PREFERRED_OFFLOAD	UINT32_C(0x2)
-	/* The number of entries the FW has configured for EXT EM. */
-	uint32_t	num_entries;
-	/* Configured EXT EM with the given context if for KEY0 table. */
-	uint16_t	key0_ctx_id;
-	/* Configured EXT EM with the given context if for KEY1 table. */
-	uint16_t	key1_ctx_id;
-	/* Configured EXT EM with the given context if for RECORD table. */
-	uint16_t	record_ctx_id;
-	/* Configured EXT EM with the given context if for EFC table. */
-	uint16_t	efc_ctx_id;
-	/* Configured EXT EM with the given context if for EFC table. */
-	uint16_t	fid_ctx_id;
-	/* unused. */
-	uint16_t	unused0;
-	uint32_t	supported;
-	/* This bit must be '1' for the group_id field is set. */
-	#define HWRM_TF_EXT_EM_QCFG_OUTPUT_SUPPORTED_GROUP_ID		UINT32_C(0x1)
-	/* This bit must be '1' for the flush_interval field is set. */
-	#define HWRM_TF_EXT_EM_QCFG_OUTPUT_SUPPORTED_FLUSH_INTERVAL	UINT32_C(0x2)
-	/* This bit must be '1' for the num_entries field is set. */
-	#define HWRM_TF_EXT_EM_QCFG_OUTPUT_SUPPORTED_NUM_ENTRIES		UINT32_C(0x4)
-	/* This bit must be '1' for the key0_ctx_id field is set. */
-	#define HWRM_TF_EXT_EM_QCFG_OUTPUT_SUPPORTED_KEY0_CTX_ID		UINT32_C(0x8)
-	/* This bit must be '1' for the key1_ctx_id field is set. */
-	#define HWRM_TF_EXT_EM_QCFG_OUTPUT_SUPPORTED_KEY1_CTX_ID		UINT32_C(0x10)
-	/* This bit must be '1' for the record_ctx_id field is set. */
-	#define HWRM_TF_EXT_EM_QCFG_OUTPUT_SUPPORTED_RECORD_CTX_ID	UINT32_C(0x20)
-	/* This bit must be '1' for the efc_ctx_id field is set. */
-	#define HWRM_TF_EXT_EM_QCFG_OUTPUT_SUPPORTED_EFC_CTX_ID		UINT32_C(0x40)
-	/* This bit must be '1' for the fid_ctx_id field is set. */
-	#define HWRM_TF_EXT_EM_QCFG_OUTPUT_SUPPORTED_FID_CTX_ID		UINT32_C(0x80)
-	/* This bit must be '1' for the action_ctx_id field is set. */
-	#define HWRM_TF_EXT_EM_QCFG_OUTPUT_SUPPORTED_ACTION_CTX_ID	UINT32_C(0x100)
-	/* This bit must be '1' for the action_tbl_scope field is set. */
-	#define HWRM_TF_EXT_EM_QCFG_OUTPUT_SUPPORTED_ACTION_TBL_SCOPE	UINT32_C(0x200)
-	/* This bit must be '1' for the lkup_ctx_id field is set. */
-	#define HWRM_TF_EXT_EM_QCFG_OUTPUT_SUPPORTED_LKUP_CTX_ID		UINT32_C(0x400)
-	/* This bit must be '1' for the lkup_tbl_scope field is set. */
-	#define HWRM_TF_EXT_EM_QCFG_OUTPUT_SUPPORTED_LKUP_TBL_SCOPE	UINT32_C(0x800)
-	/* This bit must be '1' for the lkup_static_buckets field is set. */
-	#define HWRM_TF_EXT_EM_QCFG_OUTPUT_SUPPORTED_LKUP_STATIC_BUCKETS	UINT32_C(0x1000)
-	/*
-	 * Group id is used by firmware to identify memory pools belonging
-	 * to certain group.
+	/* SRQ handle. */
+	uint64_t	srq_handle;
+	uint16_t	pg_size_lvl;
+	/* SRQ PBL indirect levels. */
+	#define CMDQ_CREATE_SRQ_LVL_MASK	UINT32_C(0x3)
+	#define CMDQ_CREATE_SRQ_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define CMDQ_CREATE_SRQ_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define CMDQ_CREATE_SRQ_LVL_LVL_1	UINT32_C(0x1)
+	/*
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
 	 */
-	uint16_t	group_id;
-	/* EEM pending cache flush interval in 1/10th of second. */
-	uint8_t	flush_interval;
-	/* unused. */
-	uint8_t	unused1;
-	/* Context id of action table scope. */
-	uint16_t	action_ctx_id;
-	/* Table scope id used for action record entries. */
-	uint16_t	action_tbl_scope;
-	/* Context id of lookup table scope. */
-	uint16_t	lkup_ctx_id;
-	/* Table scope id used for EM lookup entries. */
-	uint16_t	lkup_tbl_scope;
-	/*
-	 * Number of 32B static buckets to be allocated at the beginning
-	 * of table scope.
-	 */
-	uint32_t	lkup_static_buckets;
-	/* unused. */
-	uint8_t	unused2[7];
+		#define CMDQ_CREATE_SRQ_LVL_LVL_2	UINT32_C(0x2)
+		#define CMDQ_CREATE_SRQ_LVL_LAST	CMDQ_CREATE_SRQ_LVL_LVL_2
+	/* page size. */
+	#define CMDQ_CREATE_SRQ_PG_SIZE_MASK  UINT32_C(0x1c)
+	#define CMDQ_CREATE_SRQ_PG_SIZE_SFT   2
+	/* 4KB. */
+		#define CMDQ_CREATE_SRQ_PG_SIZE_PG_4K   (UINT32_C(0x0) << 2)
+	/* 8KB. */
+		#define CMDQ_CREATE_SRQ_PG_SIZE_PG_8K   (UINT32_C(0x1) << 2)
+	/* 64KB. */
+		#define CMDQ_CREATE_SRQ_PG_SIZE_PG_64K  (UINT32_C(0x2) << 2)
+	/* 2MB. */
+		#define CMDQ_CREATE_SRQ_PG_SIZE_PG_2M   (UINT32_C(0x3) << 2)
+	/* 8MB. */
+		#define CMDQ_CREATE_SRQ_PG_SIZE_PG_8M   (UINT32_C(0x4) << 2)
+	/* 1GB. */
+		#define CMDQ_CREATE_SRQ_PG_SIZE_PG_1G   (UINT32_C(0x5) << 2)
+		#define CMDQ_CREATE_SRQ_PG_SIZE_LAST   CMDQ_CREATE_SRQ_PG_SIZE_PG_1G
+	/* unused11 is 11 b */
+	#define CMDQ_CREATE_SRQ_UNUSED11_MASK UINT32_C(0xffe0)
+	#define CMDQ_CREATE_SRQ_UNUSED11_SFT  5
+	uint16_t	eventq_id;
+	/* eventq_id is 12 b */
+	#define CMDQ_CREATE_SRQ_EVENTQ_ID_MASK UINT32_C(0xfff)
+	#define CMDQ_CREATE_SRQ_EVENTQ_ID_SFT 0
+	/* unused4 is 4 b */
+	#define CMDQ_CREATE_SRQ_UNUSED4_MASK  UINT32_C(0xf000)
+	#define CMDQ_CREATE_SRQ_UNUSED4_SFT   12
+	/* Max number of SRQ wqes. */
+	uint16_t	srq_size;
+	uint16_t	srq_fwo;
+	/* Offset of first WQE in the first page of SRQ, in 128 byte units */
+	#define CMDQ_CREATE_SRQ_SRQ_FWO_MASK UINT32_C(0xfff)
+	#define CMDQ_CREATE_SRQ_SRQ_FWO_SFT 0
 	/*
-	 * This field is used in Output records to indicate that the
-	 * output is completely written to RAM. This field should be
-	 * read as '1' to indicate that the output has been
-	 * completely written.  When writing a command completion or
-	 * response to an internal processor, the order of writes has
-	 * to be such that this field is written last.
+	 * Max SGEs per SRQ WQE. This field is enabled if flag,
+	 * create_srq_sge_supported, is set in query_func response.
 	 */
-	uint8_t	valid;
-} hwrm_tf_ext_em_qcfg_output_t, *phwrm_tf_ext_em_qcfg_output_t;
-
-/*********************
- * hwrm_tf_em_insert *
- *********************/
-
+	#define CMDQ_CREATE_SRQ_SRQ_SGE_MASK UINT32_C(0xf000)
+	#define CMDQ_CREATE_SRQ_SRQ_SGE_SFT 12
+	/* Doorbell page index. */
+	uint32_t	dpi;
+	/* Protection domain id. */
+	uint32_t	pd_id;
+	/* RQ PBL physical address. */
+	uint64_t	pbl;
+	/* Steering tag to use for memory transactions. */
+	uint16_t	steering_tag;
+	uint8_t	reserved48[6];
+	/* reserved64 is 64 b */
+	uint64_t	reserved64;
+} cmdq_create_srq_t, *pcmdq_create_srq_t;
 
-/* hwrm_tf_em_insert_input (size:832b/104B) */
+/* creq_create_srq_resp (size:128b/16B) */
 
-typedef struct hwrm_tf_em_insert_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
-	 */
-	uint16_t	cmpl_ring;
-	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
-	 */
-	uint16_t	seq_id;
+typedef struct creq_create_srq_resp {
+	uint8_t	type;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint16_t	target_id;
+	#define CREQ_CREATE_SRQ_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_CREATE_SRQ_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_CREATE_SRQ_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_CREATE_SRQ_RESP_TYPE_LAST	CREQ_CREATE_SRQ_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* SRQ context id */
+	uint32_t	xid;
+	uint8_t	v;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint64_t	resp_addr;
-	/* Firmware Session Id. */
-	uint32_t	fw_session_id;
-	/* Control Flags. */
-	uint16_t	flags;
-	/* Indicates the flow direction. */
-	#define HWRM_TF_EM_INSERT_INPUT_FLAGS_DIR	UINT32_C(0x1)
-	/* If this bit set to 0, then it indicates rx flow. */
-		#define HWRM_TF_EM_INSERT_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
-	/* If this bit is set to 1, then it indicates tx flow. */
-		#define HWRM_TF_EM_INSERT_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
-		#define HWRM_TF_EM_INSERT_INPUT_FLAGS_DIR_LAST HWRM_TF_EM_INSERT_INPUT_FLAGS_DIR_TX
-	/* Reported match strength. */
-	uint16_t	strength;
-	/* Index to action. */
-	uint32_t	action_ptr;
-	/* Index of EM record. */
-	uint32_t	em_record_idx;
-	/* EM Key value. */
-	uint64_t	em_key[8];
-	/* Number of bits in em_key. */
-	uint16_t	em_key_bitlen;
-	/* unused. */
-	uint16_t	unused0[3];
-} hwrm_tf_em_insert_input_t, *phwrm_tf_em_insert_input_t;
+	#define CREQ_CREATE_SRQ_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Create SRQ command response. */
+	#define CREQ_CREATE_SRQ_RESP_EVENT_CREATE_SRQ UINT32_C(0x5)
+	#define CREQ_CREATE_SRQ_RESP_EVENT_LAST	CREQ_CREATE_SRQ_RESP_EVENT_CREATE_SRQ
+	uint8_t	reserved48[6];
+} creq_create_srq_resp_t, *pcreq_create_srq_resp_t;
 
-/* hwrm_tf_em_insert_output (size:128b/16B) */
+/***************
+ * destroy_srq *
+ ***************/
 
-typedef struct hwrm_tf_em_insert_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* EM record pointer index. */
-	uint16_t	rptr_index;
-	/* EM record offset 0~3. */
-	uint8_t	rptr_entry;
-	/* Number of word entries consumed by the key. */
-	uint8_t	num_of_entries;
-	/* unused. */
-	uint32_t	unused0;
-} hwrm_tf_em_insert_output_t, *phwrm_tf_em_insert_output_t;
 
-/**************************
- * hwrm_tf_em_hash_insert *
- **************************/
+/* cmdq_destroy_srq (size:192b/24B) */
 
+typedef struct cmdq_destroy_srq {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Destroy SRQ command deletes and flushes the specified SRQ. */
+	#define CMDQ_DESTROY_SRQ_OPCODE_DESTROY_SRQ UINT32_C(0x6)
+	#define CMDQ_DESTROY_SRQ_OPCODE_LAST	CMDQ_DESTROY_SRQ_OPCODE_DESTROY_SRQ
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+	/* SRQ context id */
+	uint32_t	srq_cid;
+	uint32_t	unused_0;
+} cmdq_destroy_srq_t, *pcmdq_destroy_srq_t;
 
-/* hwrm_tf_em_hash_insert_input (size:1024b/128B) */
+/* creq_destroy_srq_resp (size:128b/16B) */
 
-typedef struct hwrm_tf_em_hash_insert_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
-	 */
-	uint16_t	cmpl_ring;
+typedef struct creq_destroy_srq_resp {
+	uint8_t	type;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint16_t	seq_id;
+	#define CREQ_DESTROY_SRQ_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_DESTROY_SRQ_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_DESTROY_SRQ_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_DESTROY_SRQ_RESP_TYPE_LAST	CREQ_DESTROY_SRQ_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* SRQ context id */
+	uint32_t	xid;
+	uint8_t	v;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint16_t	target_id;
+	#define CREQ_DESTROY_SRQ_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Destroy SRQ command response. */
+	#define CREQ_DESTROY_SRQ_RESP_EVENT_DESTROY_SRQ UINT32_C(0x6)
+	#define CREQ_DESTROY_SRQ_RESP_EVENT_LAST	CREQ_DESTROY_SRQ_RESP_EVENT_DESTROY_SRQ
+	uint16_t	enable_for_arm[3];
+	#define CREQ_DESTROY_SRQ_RESP_UNUSED0_MASK	UINT32_C(0xffff)
+	#define CREQ_DESTROY_SRQ_RESP_UNUSED0_SFT	0
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Set to 1 if this SRQ is allowed to be armed for threshold async
+	 * event
 	 */
-	uint64_t	resp_addr;
-	/* Firmware Session Id. */
-	uint32_t	fw_session_id;
-	/* Control Flags. */
-	uint16_t	flags;
-	/* Indicates the flow direction. */
-	#define HWRM_TF_EM_HASH_INSERT_INPUT_FLAGS_DIR	UINT32_C(0x1)
-	/* If this bit set to 0, then it indicates rx flow. */
-		#define HWRM_TF_EM_HASH_INSERT_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
-	/* If this bit is set to 1, then it indicates tx flow. */
-		#define HWRM_TF_EM_HASH_INSERT_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
-		#define HWRM_TF_EM_HASH_INSERT_INPUT_FLAGS_DIR_LAST HWRM_TF_EM_HASH_INSERT_INPUT_FLAGS_DIR_TX
-	/* Number of bits in the EM record. */
-	uint16_t	em_record_size_bits;
-	/* CRC32 hash of key. */
-	uint32_t	key0_hash;
-	/* Lookup3 hash of key. */
-	uint32_t	key1_hash;
-	/* Index of EM record. */
-	uint32_t	em_record_idx;
-	/* Unused. */
-	uint32_t	unused0;
-	/* EM record. */
-	uint64_t	em_record[11];
-} hwrm_tf_em_hash_insert_input_t, *phwrm_tf_em_hash_insert_input_t;
+	#define CREQ_DESTROY_SRQ_RESP_ENABLE_FOR_ARM_MASK UINT32_C(0x30000)
+	#define CREQ_DESTROY_SRQ_RESP_ENABLE_FOR_ARM_SFT 16
+} creq_destroy_srq_resp_t, *pcreq_destroy_srq_resp_t;
 
-/* hwrm_tf_em_hash_insert_output (size:128b/16B) */
+/*************
+ * query_srq *
+ *************/
 
-typedef struct hwrm_tf_em_hash_insert_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* EM record pointer index. */
-	uint16_t	rptr_index;
-	/* EM record offset 0~3. */
-	uint8_t	rptr_entry;
-	/* Number of word entries consumed by the key. */
-	uint8_t	num_of_entries;
-	/* unused. */
-	uint32_t	unused0;
-} hwrm_tf_em_hash_insert_output_t, *phwrm_tf_em_hash_insert_output_t;
 
-/*********************
- * hwrm_tf_em_delete *
- *********************/
+/* cmdq_query_srq (size:192b/24B) */
 
+typedef struct cmdq_query_srq {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Query SRP command retrieves info about the specified SRQ. */
+	#define CMDQ_QUERY_SRQ_OPCODE_QUERY_SRQ UINT32_C(0x8)
+	#define CMDQ_QUERY_SRQ_OPCODE_LAST	CMDQ_QUERY_SRQ_OPCODE_QUERY_SRQ
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+	/* SRQ context id */
+	uint32_t	srq_cid;
+	uint32_t	unused_0;
+} cmdq_query_srq_t, *pcmdq_query_srq_t;
 
-/* hwrm_tf_em_delete_input (size:832b/104B) */
+/* creq_query_srq_resp (size:128b/16B) */
 
-typedef struct hwrm_tf_em_delete_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
-	 */
-	uint16_t	cmpl_ring;
-	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
-	 */
-	uint16_t	seq_id;
+typedef struct creq_query_srq_resp {
+	uint8_t	type;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint16_t	target_id;
+	#define CREQ_QUERY_SRQ_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_QUERY_SRQ_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_QUERY_SRQ_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_QUERY_SRQ_RESP_TYPE_LAST	CREQ_QUERY_SRQ_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Side buffer size in 16-byte units */
+	uint32_t	size;
+	uint8_t	v;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint64_t	resp_addr;
-	/* Session Id. */
-	uint32_t	fw_session_id;
-	/* Control flags. */
-	uint16_t	flags;
-	/* Indicates the flow direction. */
-	#define HWRM_TF_EM_DELETE_INPUT_FLAGS_DIR	UINT32_C(0x1)
-	/* If this bit set to 0, then it indicates rx flow. */
-		#define HWRM_TF_EM_DELETE_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
-	/* If this bit is set to 1, then it indicates tx flow. */
-		#define HWRM_TF_EM_DELETE_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
-		#define HWRM_TF_EM_DELETE_INPUT_FLAGS_DIR_LAST HWRM_TF_EM_DELETE_INPUT_FLAGS_DIR_TX
-	/* Unused0 */
-	uint16_t	unused0;
-	/* EM internal flow handle. */
-	uint64_t	flow_handle;
-	/* EM Key value */
-	uint64_t	em_key[8];
-	/* Number of bits in em_key. */
-	uint16_t	em_key_bitlen;
-	/* unused. */
-	uint16_t	unused1[3];
-} hwrm_tf_em_delete_input_t, *phwrm_tf_em_delete_input_t;
+	#define CREQ_QUERY_SRQ_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Query SRQ command response. */
+	#define CREQ_QUERY_SRQ_RESP_EVENT_QUERY_SRQ UINT32_C(0x8)
+	#define CREQ_QUERY_SRQ_RESP_EVENT_LAST	CREQ_QUERY_SRQ_RESP_EVENT_QUERY_SRQ
+	uint8_t	reserved48[6];
+} creq_query_srq_resp_t, *pcreq_query_srq_resp_t;
 
-/* hwrm_tf_em_delete_output (size:128b/16B) */
+/* Query SRQ command response side buffer structure. */
+/* creq_query_srq_resp_sb (size:256b/32B) */
 
-typedef struct hwrm_tf_em_delete_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Original stack allocation index. */
-	uint16_t	em_index;
-	/* unused. */
-	uint16_t	unused0[3];
-} hwrm_tf_em_delete_output_t, *phwrm_tf_em_delete_output_t;
+typedef struct creq_query_srq_resp_sb {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Query SRQ command response. */
+	#define CREQ_QUERY_SRQ_RESP_SB_OPCODE_QUERY_SRQ UINT32_C(0x8)
+	#define CREQ_QUERY_SRQ_RESP_SB_OPCODE_LAST	CREQ_QUERY_SRQ_RESP_SB_OPCODE_QUERY_SRQ
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* SRQ context id */
+	uint32_t	xid;
+	/* Watermark value to generate a SRQ limit event. */
+	uint16_t	srq_limit;
+	uint16_t	reserved16;
+	/* data is 128 b */
+	uint32_t	data[4];
+} creq_query_srq_resp_sb_t, *pcreq_query_srq_resp_sb_t;
 
-/*******************
- * hwrm_tf_em_move *
- *******************/
+/*************
+ * create_cq *
+ *************/
 
 
-/* hwrm_tf_em_move_input (size:320b/40B) */
+/* cmdq_create_cq (size:512b/64B) */
 
-typedef struct hwrm_tf_em_move_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+typedef struct cmdq_create_cq {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Create CQ command allocates a CQ with the specified parameters. */
+	#define CMDQ_CREATE_CQ_OPCODE_CREATE_CQ UINT32_C(0x9)
+	#define CMDQ_CREATE_CQ_OPCODE_LAST	CMDQ_CREATE_CQ_OPCODE_CREATE_CQ
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
-	 */
-	uint16_t	cmpl_ring;
+	 * When the HW Doorbell Drop Recovery feature is enabled,
+	 * HW can flag false CQ overflow when CQ consumer index
+	 * doorbells are dropped when there really wasn't any overflow.
+	 * The CQE values could have already been processed by the driver,
+	 * but HW doesn't know about this because of the doorbell drop.
+	 * To avoid false detection of CQ overflow events,
+	 * it is recommended that CQ overflow detection is disabled
+	 * by the driver when HW based doorbell recovery is enabled.
+	 */
+	#define CMDQ_CREATE_CQ_FLAGS_DISABLE_CQ_OVERFLOW_DETECTION	UINT32_C(0x1)
+	/* This CQ uses the steering tag specified in the command. */
+	#define CMDQ_CREATE_CQ_FLAGS_STEERING_TAG_VALID		UINT32_C(0x2)
+	/*
+	 * This CQ uses the infinite CQ mode.
+	 * In the infinite CQ mode, all CQEs are written to the same
+	 * address. Note that this mode implies a HW client is
+	 * handling each entry instantly and avoiding overwrites.
+	 * The following limitations apply when this mode is enabled:
+	 * -cq_size field must be 1
+	 * -disable_cq_overflow_detection flag must be true.
+	 * -the CQ will never be armed.
+	 * -the consumer index of CQ will never be changed
+	 */
+	#define CMDQ_CREATE_CQ_FLAGS_INFINITE_CQ_MODE		UINT32_C(0x4)
+	/*
+	 * This CQ uses coalescing data specified in the command.
+	 * This feature is not supported if infinite_cq_mode is also enabled.
+	 */
+	#define CMDQ_CREATE_CQ_FLAGS_COALESCING_VALID		UINT32_C(0x8)
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+	/* CQ handle. */
+	uint64_t	cq_handle;
+	uint32_t	pg_size_lvl;
+	/* PBL indirect levels. */
+	#define CMDQ_CREATE_CQ_LVL_MASK	UINT32_C(0x3)
+	#define CMDQ_CREATE_CQ_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define CMDQ_CREATE_CQ_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define CMDQ_CREATE_CQ_LVL_LVL_1	UINT32_C(0x1)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
 	 */
-	uint16_t	seq_id;
+		#define CMDQ_CREATE_CQ_LVL_LVL_2	UINT32_C(0x2)
+		#define CMDQ_CREATE_CQ_LVL_LAST	CMDQ_CREATE_CQ_LVL_LVL_2
+	/* page size. */
+	#define CMDQ_CREATE_CQ_PG_SIZE_MASK  UINT32_C(0x1c)
+	#define CMDQ_CREATE_CQ_PG_SIZE_SFT   2
+	/* 4KB. */
+		#define CMDQ_CREATE_CQ_PG_SIZE_PG_4K   (UINT32_C(0x0) << 2)
+	/* 8KB. */
+		#define CMDQ_CREATE_CQ_PG_SIZE_PG_8K   (UINT32_C(0x1) << 2)
+	/* 64KB. */
+		#define CMDQ_CREATE_CQ_PG_SIZE_PG_64K  (UINT32_C(0x2) << 2)
+	/* 2MB. */
+		#define CMDQ_CREATE_CQ_PG_SIZE_PG_2M   (UINT32_C(0x3) << 2)
+	/* 8MB. */
+		#define CMDQ_CREATE_CQ_PG_SIZE_PG_8M   (UINT32_C(0x4) << 2)
+	/* 1GB. */
+		#define CMDQ_CREATE_CQ_PG_SIZE_PG_1G   (UINT32_C(0x5) << 2)
+		#define CMDQ_CREATE_CQ_PG_SIZE_LAST   CMDQ_CREATE_CQ_PG_SIZE_PG_1G
+	/* unused27 is 27 b */
+	#define CMDQ_CREATE_CQ_UNUSED27_MASK UINT32_C(0xffffffe0)
+	#define CMDQ_CREATE_CQ_UNUSED27_SFT  5
+	uint32_t	cq_fco_cnq_id;
+	/* cnq_id is 12 b */
+	#define CMDQ_CREATE_CQ_CNQ_ID_MASK UINT32_C(0xfff)
+	#define CMDQ_CREATE_CQ_CNQ_ID_SFT 0
+	/* Offset of first CQE in the first Page, in 32 byte units */
+	#define CMDQ_CREATE_CQ_CQ_FCO_MASK UINT32_C(0xfffff000)
+	#define CMDQ_CREATE_CQ_CQ_FCO_SFT 12
+	/* Doorbell page index. */
+	uint32_t	dpi;
+	/* Max number of CQ wqes. */
+	uint32_t	cq_size;
+	/* CQ PBL physical address. */
+	uint64_t	pbl;
+	/* Steering tag to use for memory transactions. */
+	uint16_t	steering_tag;
+	uint8_t	reserved16[2];
+	uint32_t	coalescing;
+	/*
+	 * Buffer Max time before flushing buffer (units of 1us). This
+	 * specifies the maximum time before completion buffers are
+	 * flushed out to host memory even if the number of coalesced
+	 * buffers is less than the threshold. buf_maxtime is 9 bits.
+	 */
+	#define CMDQ_CREATE_CQ_BUF_MAXTIME_MASK	UINT32_C(0x1ff)
+	#define CMDQ_CREATE_CQ_BUF_MAXTIME_SFT	0
+	/*
+	 * This specifies the number of buffers coalesced before sending
+	 * to memory during normal operation. Buffer unit is 16B
+	 * completions. normal_maxbuf is 5 bits.
+	 */
+	#define CMDQ_CREATE_CQ_NORMAL_MAXBUF_MASK	UINT32_C(0x3e00)
+	#define CMDQ_CREATE_CQ_NORMAL_MAXBUF_SFT	9
+	/*
+	 * This specifies the number of buffers coalesced before sending
+	 * to memory when the interrupt is masked. Buffer unit is 16B
+	 * completions. during_maxbuf is 5 bits.
+	 */
+	#define CMDQ_CREATE_CQ_DURING_MAXBUF_MASK	UINT32_C(0x7c000)
+	#define CMDQ_CREATE_CQ_DURING_MAXBUF_SFT	14
+	/*
+	 * This field is used to enable ring for global idle mode interrupt
+	 * generation. This mode will generate a notification (interrupt)
+	 * if armed when only one completion has been generated if the chip
+	 * is globally idle as determined by the device.
+	 * enable_ring_idle_mode is 1 bit.
+	 */
+	#define CMDQ_CREATE_CQ_ENABLE_RING_IDLE_MODE	UINT32_C(0x80000)
+	/* unused12 is 12 b */
+	#define CMDQ_CREATE_CQ_UNUSED12_MASK		UINT32_C(0xfff00000)
+	#define CMDQ_CREATE_CQ_UNUSED12_SFT		20
+	/* reserved64 is 64 b */
+	uint64_t	reserved64;
+} cmdq_create_cq_t, *pcmdq_create_cq_t;
+
+/* creq_create_cq_resp (size:128b/16B) */
+
+typedef struct creq_create_cq_resp {
+	uint8_t	type;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint16_t	target_id;
+	#define CREQ_CREATE_CQ_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_CREATE_CQ_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_CREATE_CQ_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_CREATE_CQ_RESP_TYPE_LAST	CREQ_CREATE_CQ_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* CQ context id */
+	uint32_t	xid;
+	uint8_t	v;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint64_t	resp_addr;
-	/* Session Id. */
-	uint32_t	fw_session_id;
-	/* Control flags. */
-	uint16_t	flags;
-	/* Indicates the flow direction. */
-	#define HWRM_TF_EM_MOVE_INPUT_FLAGS_DIR	UINT32_C(0x1)
-	/* If this bit set to 0, then it indicates rx flow. */
-		#define HWRM_TF_EM_MOVE_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
-	/* If this bit is set to 1, then it indicates tx flow. */
-		#define HWRM_TF_EM_MOVE_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
-		#define HWRM_TF_EM_MOVE_INPUT_FLAGS_DIR_LAST HWRM_TF_EM_MOVE_INPUT_FLAGS_DIR_TX
-	/* Number of EM entry blocks */
-	uint16_t	num_blocks;
-	/* New index for entry */
-	uint32_t	new_index;
-	/* Unused */
-	uint32_t	unused0;
-	/* EM internal flow handle. */
-	uint64_t	flow_handle;
-} hwrm_tf_em_move_input_t, *phwrm_tf_em_move_input_t;
+	#define CREQ_CREATE_CQ_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Create CQ command response. */
+	#define CREQ_CREATE_CQ_RESP_EVENT_CREATE_CQ UINT32_C(0x9)
+	#define CREQ_CREATE_CQ_RESP_EVENT_LAST	CREQ_CREATE_CQ_RESP_EVENT_CREATE_CQ
+	uint8_t	reserved48[6];
+} creq_create_cq_resp_t, *pcreq_create_cq_resp_t;
 
-/* hwrm_tf_em_move_output (size:128b/16B) */
+/**************
+ * destroy_cq *
+ **************/
 
-typedef struct hwrm_tf_em_move_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Index of old entry. */
-	uint16_t	em_index;
-	/* unused. */
-	uint16_t	unused0[3];
-} hwrm_tf_em_move_output_t, *phwrm_tf_em_move_output_t;
 
-/********************
- * hwrm_tf_tcam_set *
- ********************/
+/* cmdq_destroy_cq (size:192b/24B) */
 
+typedef struct cmdq_destroy_cq {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Destroy CQ command deletes and flushes the specified CQ. */
+	#define CMDQ_DESTROY_CQ_OPCODE_DESTROY_CQ UINT32_C(0xa)
+	#define CMDQ_DESTROY_CQ_OPCODE_LAST	CMDQ_DESTROY_CQ_OPCODE_DESTROY_CQ
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+	/* CQ context id */
+	uint32_t	cq_cid;
+	uint32_t	unused_0;
+} cmdq_destroy_cq_t, *pcmdq_destroy_cq_t;
 
-/* hwrm_tf_tcam_set_input (size:1024b/128B) */
+/* creq_destroy_cq_resp (size:128b/16B) */
 
-typedef struct hwrm_tf_tcam_set_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+typedef struct creq_destroy_cq_resp {
+	uint8_t	type;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint16_t	cmpl_ring;
+	#define CREQ_DESTROY_CQ_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_DESTROY_CQ_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_DESTROY_CQ_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_DESTROY_CQ_RESP_TYPE_LAST	CREQ_DESTROY_CQ_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* CQ context id */
+	uint32_t	xid;
+	uint8_t	v;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint16_t	seq_id;
+	#define CREQ_DESTROY_CQ_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Destroy CQ command response. */
+	#define CREQ_DESTROY_CQ_RESP_EVENT_DESTROY_CQ UINT32_C(0xa)
+	#define CREQ_DESTROY_CQ_RESP_EVENT_LAST	CREQ_DESTROY_CQ_RESP_EVENT_DESTROY_CQ
+	uint16_t	cq_arm_lvl;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * CQ ARM Level:
+	 * 0 ? Not Armed
+	 * 1 ? Arm SE Only, Generate CNQE only for incoming Solicited Events
+	 * 2 ? Arm all, Generate CNQE for Rx and Tx
 	 */
-	uint16_t	target_id;
+	#define CREQ_DESTROY_CQ_RESP_CQ_ARM_LVL_MASK UINT32_C(0x3)
+	#define CREQ_DESTROY_CQ_RESP_CQ_ARM_LVL_SFT 0
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * The total number of CNQ events for the CQ, incremented on each CNQ
+	 * event for the CQ (including firmware-generated CQ error
+	 * notification).
 	 */
+	uint16_t	total_cnq_events;
+	uint16_t	reserved16;
+} creq_destroy_cq_resp_t, *pcreq_destroy_cq_resp_t;
+
+/*************
+ * resize_cq *
+ *************/
+
+
+/* cmdq_resize_cq (size:320b/40B) */
+
+typedef struct cmdq_resize_cq {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Resize CQ command resizes the specified CQ. */
+	#define CMDQ_RESIZE_CQ_OPCODE_RESIZE_CQ UINT32_C(0xc)
+	#define CMDQ_RESIZE_CQ_OPCODE_LAST	CMDQ_RESIZE_CQ_OPCODE_RESIZE_CQ
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
 	uint64_t	resp_addr;
-	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
-	uint32_t	fw_session_id;
-	/* Control flags. */
-	uint32_t	flags;
-	/* Indicates the flow direction. */
-	#define HWRM_TF_TCAM_SET_INPUT_FLAGS_DIR	UINT32_C(0x1)
-	/* If this bit set to 0, then it indicates rx flow. */
-		#define HWRM_TF_TCAM_SET_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
-	/* If this bit is set to 1, then it indicates tx flow. */
-		#define HWRM_TF_TCAM_SET_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
-		#define HWRM_TF_TCAM_SET_INPUT_FLAGS_DIR_LAST HWRM_TF_TCAM_SET_INPUT_FLAGS_DIR_TX
-	/*
-	 * Indicate device data is being sent via DMA, the device
-	 * data is packing does not change.
-	 */
-	#define HWRM_TF_TCAM_SET_INPUT_FLAGS_DMA	UINT32_C(0x2)
-	/*
-	 * TCAM type of the resource, defined globally in the
-	 * hwrm_tf_resc_type enum.
-	 */
-	uint32_t	type;
-	/* Index of TCAM entry. */
-	uint16_t	idx;
-	/* Number of bytes in the TCAM key. */
-	uint8_t	key_size;
-	/* Number of bytes in the TCAM result. */
-	uint8_t	result_size;
-	/*
-	 * Offset from which the mask bytes start in the device data
-	 * array, key offset is always 0.
-	 */
-	uint8_t	mask_offset;
-	/* Offset from which the result bytes start in the device data array. */
-	uint8_t	result_offset;
-	/* unused. */
-	uint8_t	unused0[6];
+	/* CQ context id */
+	uint32_t	cq_cid;
+	uint32_t	new_cq_size_pg_size_lvl;
+	/* PBL indirect levels. */
+	#define CMDQ_RESIZE_CQ_LVL_MASK	UINT32_C(0x3)
+	#define CMDQ_RESIZE_CQ_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define CMDQ_RESIZE_CQ_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define CMDQ_RESIZE_CQ_LVL_LVL_1	UINT32_C(0x1)
 	/*
-	 * TCAM key located at offset 0, mask located at mask_offsec
-	 * and result at result_offsec for the device.
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
 	 */
-	uint8_t	dev_data[88];
-} hwrm_tf_tcam_set_input_t, *phwrm_tf_tcam_set_input_t;
+		#define CMDQ_RESIZE_CQ_LVL_LVL_2	UINT32_C(0x2)
+		#define CMDQ_RESIZE_CQ_LVL_LAST	CMDQ_RESIZE_CQ_LVL_LVL_2
+	/* page size. */
+	#define CMDQ_RESIZE_CQ_PG_SIZE_MASK	UINT32_C(0x1c)
+	#define CMDQ_RESIZE_CQ_PG_SIZE_SFT	2
+	/* 4KB. */
+		#define CMDQ_RESIZE_CQ_PG_SIZE_PG_4K	(UINT32_C(0x0) << 2)
+	/* 8KB. */
+		#define CMDQ_RESIZE_CQ_PG_SIZE_PG_8K	(UINT32_C(0x1) << 2)
+	/* 64KB. */
+		#define CMDQ_RESIZE_CQ_PG_SIZE_PG_64K	(UINT32_C(0x2) << 2)
+	/* 2MB. */
+		#define CMDQ_RESIZE_CQ_PG_SIZE_PG_2M	(UINT32_C(0x3) << 2)
+	/* 8MB. */
+		#define CMDQ_RESIZE_CQ_PG_SIZE_PG_8M	(UINT32_C(0x4) << 2)
+	/* 1GB. */
+		#define CMDQ_RESIZE_CQ_PG_SIZE_PG_1G	(UINT32_C(0x5) << 2)
+		#define CMDQ_RESIZE_CQ_PG_SIZE_LAST	CMDQ_RESIZE_CQ_PG_SIZE_PG_1G
+	/* New max number of CQ wqes. */
+	#define CMDQ_RESIZE_CQ_NEW_CQ_SIZE_MASK UINT32_C(0x1fffffe0)
+	#define CMDQ_RESIZE_CQ_NEW_CQ_SIZE_SFT 5
+	/* CQ PBL physical address. */
+	uint64_t	new_pbl;
+	/* Offset of first CQE in the first Page, in 32 byte units */
+	uint32_t	new_cq_fco;
+	uint32_t	unused_0;
+} cmdq_resize_cq_t, *pcmdq_resize_cq_t;
 
-/* hwrm_tf_tcam_set_output (size:128b/16B) */
+/* creq_resize_cq_resp (size:128b/16B) */
 
-typedef struct hwrm_tf_tcam_set_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* unused. */
-	uint8_t	unused0[7];
+typedef struct creq_resize_cq_resp {
+	uint8_t	type;
 	/*
-	 * This field is used in Output records to indicate that the
-	 * output is completely written to RAM. This field should be
-	 * read as '1' to indicate that the output has been
-	 * completely written.  When writing a command completion or
-	 * response to an internal processor, the order of writes has
-	 * to be such that this field is written last.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint8_t	valid;
-} hwrm_tf_tcam_set_output_t, *phwrm_tf_tcam_set_output_t;
+	#define CREQ_RESIZE_CQ_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_RESIZE_CQ_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_RESIZE_CQ_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_RESIZE_CQ_RESP_TYPE_LAST	CREQ_RESIZE_CQ_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* CQ context id */
+	uint32_t	xid;
+	uint8_t	v;
+	/*
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
+	 */
+	#define CREQ_RESIZE_CQ_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Resize CQ command response. */
+	#define CREQ_RESIZE_CQ_RESP_EVENT_RESIZE_CQ UINT32_C(0xc)
+	#define CREQ_RESIZE_CQ_RESP_EVENT_LAST	CREQ_RESIZE_CQ_RESP_EVENT_RESIZE_CQ
+	uint8_t	reserved48[6];
+} creq_resize_cq_resp_t, *pcreq_resize_cq_resp_t;
 
-/********************
- * hwrm_tf_tcam_get *
- ********************/
+/*************
+ * modify_cq *
+ *************/
 
 
-/* hwrm_tf_tcam_get_input (size:256b/32B) */
+/* cmdq_modify_cq (size:512b/64B) */
 
-typedef struct hwrm_tf_tcam_get_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+typedef struct cmdq_modify_cq {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Modify CQ updates specific params in the CQ context. */
+	#define CMDQ_MODIFY_CQ_OPCODE_MODIFY_CQ UINT32_C(0x90)
+	#define CMDQ_MODIFY_CQ_OPCODE_LAST	CMDQ_MODIFY_CQ_OPCODE_MODIFY_CQ
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * When the HW Doorbell Drop Recovery feature is enabled,
+	 * HW can flag false CQ overflow when CQ consumer index
+	 * doorbells are dropped when there really wasn't any overflow.
+	 * The CQE values could have already been processed by the driver,
+	 * but HW doesn't know about this because of the doorbell drop.
+	 * To avoid false detection of CQ overflow events,
+	 * it is recommended that CQ overflow detection is disabled
+	 * by the driver when HW based doorbell recovery is enabled.
 	 */
-	uint16_t	cmpl_ring;
+	#define CMDQ_MODIFY_CQ_FLAGS_DISABLE_CQ_OVERFLOW_DETECTION	UINT32_C(0x1)
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+	/* Modify mask signifies the field that is requesting the change. */
+	uint32_t	modify_mask;
+	/* Enable change. */
+	#define CMDQ_MODIFY_CQ_MODIFY_MASK_CQ_HANDLE	UINT32_C(0x1)
+	/* CNQ ID */
+	#define CMDQ_MODIFY_CQ_MODIFY_MASK_CNQ_ID	UINT32_C(0x2)
+	/* Offset of first CQE in the first page, in 32 byte units */
+	#define CMDQ_MODIFY_CQ_MODIFY_MASK_FCO	UINT32_C(0x4)
+	/* Doorbell page index */
+	#define CMDQ_MODIFY_CQ_MODIFY_MASK_DPI	UINT32_C(0x8)
+	/* Max number of CQ Wqes */
+	#define CMDQ_MODIFY_CQ_MODIFY_MASK_CQ_SIZE	UINT32_C(0x10)
+	/* CQ PBL physical address */
+	#define CMDQ_MODIFY_CQ_MODIFY_MASK_PBL	UINT32_C(0x20)
+	/* reserved32 is 32 b */
+	uint32_t	reserved32;
+	/* CQ handle. */
+	uint64_t	cq_handle;
+	uint32_t	cq_fco_cnq_id;
+	/* cnq_id is 12 b */
+	#define CMDQ_MODIFY_CQ_CNQ_ID_MASK UINT32_C(0xfff)
+	#define CMDQ_MODIFY_CQ_CNQ_ID_SFT 0
+	/* Offset of first CQE in the first Page, in 32 byte units */
+	#define CMDQ_MODIFY_CQ_CQ_FCO_MASK UINT32_C(0xfffff000)
+	#define CMDQ_MODIFY_CQ_CQ_FCO_SFT 12
+	/* Doorbell page index. */
+	uint32_t	dpi;
+	/* Max number of CQ wqes. */
+	uint32_t	cq_size;
+	/* reserved32_1 is 32 b */
+	uint32_t	reserved32_1;
+	/* CQ PBL physical address. */
+	uint64_t	pbl;
+	/* reserved64 is 64 b */
+	uint64_t	reserved64;
+} cmdq_modify_cq_t, *pcmdq_modify_cq_t;
+
+/* creq_modify_cq_resp (size:128b/16B) */
+
+typedef struct creq_modify_cq_resp {
+	uint8_t	type;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint16_t	seq_id;
+	#define CREQ_MODIFY_CQ_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_MODIFY_CQ_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_MODIFY_CQ_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_MODIFY_CQ_RESP_TYPE_LAST	CREQ_MODIFY_CQ_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* CQ context id */
+	uint32_t	xid;
+	uint8_t	v;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint16_t	target_id;
+	#define CREQ_MODIFY_CQ_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Modify CQ command response. */
+	#define CREQ_MODIFY_CQ_RESP_EVENT_MODIFY_CQ UINT32_C(0x9)
+	#define CREQ_MODIFY_CQ_RESP_EVENT_LAST	CREQ_MODIFY_CQ_RESP_EVENT_MODIFY_CQ
+	uint8_t	reserved48[6];
+} creq_modify_cq_resp_t, *pcreq_modify_cq_resp_t;
+
+/****************
+ * allocate_mrw *
+ ****************/
+
+
+/* cmdq_allocate_mrw (size:256b/32B) */
+
+typedef struct cmdq_allocate_mrw {
+	/* Command opcode. */
+	uint8_t	opcode;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Allocate MRW command allocates a MR/MW with the specified
+	 * parameters and returns the region's L_KEY/R_KEY
 	 */
+	#define CMDQ_ALLOCATE_MRW_OPCODE_ALLOCATE_MRW UINT32_C(0xd)
+	#define CMDQ_ALLOCATE_MRW_OPCODE_LAST	CMDQ_ALLOCATE_MRW_OPCODE_ALLOCATE_MRW
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
 	uint64_t	resp_addr;
-	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
-	uint32_t	fw_session_id;
-	/* Control flags. */
-	uint32_t	flags;
-	/* Indicates the flow direction. */
-	#define HWRM_TF_TCAM_GET_INPUT_FLAGS_DIR	UINT32_C(0x1)
-	/* If this bit set to 0, then it indicates rx flow. */
-		#define HWRM_TF_TCAM_GET_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
-	/* If this bit is set to 1, then it indicates tx flow. */
-		#define HWRM_TF_TCAM_GET_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
-		#define HWRM_TF_TCAM_GET_INPUT_FLAGS_DIR_LAST HWRM_TF_TCAM_GET_INPUT_FLAGS_DIR_TX
+	/* MRW handle. */
+	uint64_t	mrw_handle;
+	uint8_t	mrw_flags;
+	/* Allocate MRW flags. */
+	#define CMDQ_ALLOCATE_MRW_MRW_FLAGS_MASK	UINT32_C(0xf)
+	#define CMDQ_ALLOCATE_MRW_MRW_FLAGS_SFT	0
+	/* Allocate Memory Region */
+		#define CMDQ_ALLOCATE_MRW_MRW_FLAGS_MR		UINT32_C(0x0)
+	/* Allocate Physical Memory Region */
+		#define CMDQ_ALLOCATE_MRW_MRW_FLAGS_PMR		UINT32_C(0x1)
+	/* Allocate Memory Window (type 1) */
+		#define CMDQ_ALLOCATE_MRW_MRW_FLAGS_MW_TYPE1	UINT32_C(0x2)
+	/* Allocate Memory Window (type 2A) */
+		#define CMDQ_ALLOCATE_MRW_MRW_FLAGS_MW_TYPE2A	UINT32_C(0x3)
+	/* Allocate Memory Window (type 2B) */
+		#define CMDQ_ALLOCATE_MRW_MRW_FLAGS_MW_TYPE2B	UINT32_C(0x4)
+		#define CMDQ_ALLOCATE_MRW_MRW_FLAGS_LAST	CMDQ_ALLOCATE_MRW_MRW_FLAGS_MW_TYPE2B
 	/*
-	 * TCAM type of the resource, defined globally in the
-	 * hwrm_tf_resc_type enum.
+	 * This Memory Region / Memory Window uses the
+	 * steering tag specified in the command.
 	 */
-	uint32_t	type;
-	/* Index of a TCAM entry. */
-	uint16_t	idx;
-	/* unused. */
-	uint16_t	unused0;
-} hwrm_tf_tcam_get_input_t, *phwrm_tf_tcam_get_input_t;
+	#define CMDQ_ALLOCATE_MRW_STEERING_TAG_VALID	UINT32_C(0x10)
+	/* unused3 is 3 b */
+	#define CMDQ_ALLOCATE_MRW_UNUSED3_MASK	UINT32_C(0xe0)
+	#define CMDQ_ALLOCATE_MRW_UNUSED3_SFT		5
+	/* Access flags. */
+	uint8_t	access;
+	/* Consumer owns the key */
+	#define CMDQ_ALLOCATE_MRW_ACCESS_CONSUMER_OWNED_KEY	UINT32_C(0x20)
+	/* Steering tag to use for memory transactions. */
+	uint16_t	steering_tag;
+	/* Protection domain id. */
+	uint32_t	pd_id;
+} cmdq_allocate_mrw_t, *pcmdq_allocate_mrw_t;
 
-/* hwrm_tf_tcam_get_output (size:2368b/296B) */
+/* creq_allocate_mrw_resp (size:128b/16B) */
 
-typedef struct hwrm_tf_tcam_get_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Number of bytes in the TCAM key. */
-	uint8_t	key_size;
-	/* Number of bytes in the TCAM entry. */
-	uint8_t	result_size;
-	/* Offset from which the mask bytes start in the device data array. */
-	uint8_t	mask_offset;
-	/* Offset from which the result bytes start in the device data array. */
-	uint8_t	result_offset;
-	/* unused. */
-	uint8_t	unused0[4];
+typedef struct creq_allocate_mrw_resp {
+	uint8_t	type;
 	/*
-	 * TCAM key located at offset 0, mask located at mask_offsec
-	 * and result at result_offsec for the device.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint8_t	dev_data[272];
-	/* unused. */
-	uint8_t	unused1[7];
+	#define CREQ_ALLOCATE_MRW_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_ALLOCATE_MRW_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_ALLOCATE_MRW_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_ALLOCATE_MRW_RESP_TYPE_LAST	CREQ_ALLOCATE_MRW_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* L_KEY for MR, R_KEY for MW */
+	uint32_t	xid;
+	uint8_t	v;
 	/*
-	 * This field is used in Output records to indicate that the
-	 * output is completely written to RAM. This field should be
-	 * read as '1' to indicate that the output has been
-	 * completely written.  When writing a command completion or
-	 * response to an internal processor, the order of writes has
-	 * to be such that this field is written last.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint8_t	valid;
-} hwrm_tf_tcam_get_output_t, *phwrm_tf_tcam_get_output_t;
+	#define CREQ_ALLOCATE_MRW_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Allocate MRW command response. */
+	#define CREQ_ALLOCATE_MRW_RESP_EVENT_ALLOCATE_MRW UINT32_C(0xd)
+	#define CREQ_ALLOCATE_MRW_RESP_EVENT_LAST	CREQ_ALLOCATE_MRW_RESP_EVENT_ALLOCATE_MRW
+	uint8_t	reserved48[6];
+} creq_allocate_mrw_resp_t, *pcreq_allocate_mrw_resp_t;
 
-/*********************
- * hwrm_tf_tcam_move *
- *********************/
+/******************
+ * deallocate_key *
+ ******************/
 
 
-/* hwrm_tf_tcam_move_input (size:1024b/128B) */
+/* cmdq_deallocate_key (size:192b/24B) */
 
-typedef struct hwrm_tf_tcam_move_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
-	 */
-	uint16_t	cmpl_ring;
-	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
-	 */
-	uint16_t	seq_id;
+typedef struct cmdq_deallocate_key {
+	/* Command opcode. */
+	uint8_t	opcode;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * De-allocate key command frees a MR/MW entry associated with the
+	 * specified key.
 	 */
-	uint16_t	target_id;
+	#define CMDQ_DEALLOCATE_KEY_OPCODE_DEALLOCATE_KEY UINT32_C(0xe)
+	#define CMDQ_DEALLOCATE_KEY_OPCODE_LAST	CMDQ_DEALLOCATE_KEY_OPCODE_DEALLOCATE_KEY
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+	uint8_t	mrw_flags;
+	/* Deallocate MRW flags. */
+	#define CMDQ_DEALLOCATE_KEY_MRW_FLAGS_MASK	UINT32_C(0xf)
+	#define CMDQ_DEALLOCATE_KEY_MRW_FLAGS_SFT	0
+	/* Deallocate Memory Region */
+		#define CMDQ_DEALLOCATE_KEY_MRW_FLAGS_MR	UINT32_C(0x0)
+	/* Deallocate Physical Memory Region */
+		#define CMDQ_DEALLOCATE_KEY_MRW_FLAGS_PMR	UINT32_C(0x1)
+	/* Deallocate Memory Window (type 1) */
+		#define CMDQ_DEALLOCATE_KEY_MRW_FLAGS_MW_TYPE1   UINT32_C(0x2)
+	/* Deallocate Memory Window (type 2A) */
+		#define CMDQ_DEALLOCATE_KEY_MRW_FLAGS_MW_TYPE2A  UINT32_C(0x3)
+	/* Deallocate Memory Window (type 2B) */
+		#define CMDQ_DEALLOCATE_KEY_MRW_FLAGS_MW_TYPE2B  UINT32_C(0x4)
+		#define CMDQ_DEALLOCATE_KEY_MRW_FLAGS_LAST	CMDQ_DEALLOCATE_KEY_MRW_FLAGS_MW_TYPE2B
+	/* unused4 is 4 b */
+	#define CMDQ_DEALLOCATE_KEY_UNUSED4_MASK	UINT32_C(0xf0)
+	#define CMDQ_DEALLOCATE_KEY_UNUSED4_SFT	4
+	/* unused24 is 24 b */
+	uint8_t	unused24[3];
+	/* key is 32 b */
+	uint32_t	key;
+} cmdq_deallocate_key_t, *pcmdq_deallocate_key_t;
+
+/* creq_deallocate_key_resp (size:128b/16B) */
+
+typedef struct creq_deallocate_key_resp {
+	uint8_t	type;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint64_t	resp_addr;
-	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
-	uint32_t	fw_session_id;
-	/* Control flags. */
-	uint32_t	flags;
-	/* Indicates the flow direction. */
-	#define HWRM_TF_TCAM_MOVE_INPUT_FLAGS_DIR	UINT32_C(0x1)
-	/* If this bit set to 0, then it indicates rx flow. */
-		#define HWRM_TF_TCAM_MOVE_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
-	/* If this bit is set to 1, then it indicates tx flow. */
-		#define HWRM_TF_TCAM_MOVE_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
-		#define HWRM_TF_TCAM_MOVE_INPUT_FLAGS_DIR_LAST HWRM_TF_TCAM_MOVE_INPUT_FLAGS_DIR_TX
+	#define CREQ_DEALLOCATE_KEY_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_DEALLOCATE_KEY_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_DEALLOCATE_KEY_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_DEALLOCATE_KEY_RESP_TYPE_LAST	CREQ_DEALLOCATE_KEY_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* L_KEY for MR, R_KEY for MW */
+	uint32_t	xid;
+	uint8_t	v;
 	/*
-	 * TCAM type of the resource, defined globally in the
-	 * hwrm_tf_resc_type enum.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint32_t	type;
-	/* Number of TCAM index pairs to be swapped for the device. */
-	uint16_t	count;
-	/* unused. */
-	uint16_t	unused0;
-	/* TCAM index pairs to be swapped for the device. */
-	uint16_t	idx_pairs[48];
-} hwrm_tf_tcam_move_input_t, *phwrm_tf_tcam_move_input_t;
-
-/* hwrm_tf_tcam_move_output (size:128b/16B) */
-
-typedef struct hwrm_tf_tcam_move_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* unused. */
-	uint8_t	unused0[7];
+	#define CREQ_DEALLOCATE_KEY_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* De-allocate key command response. */
+	#define CREQ_DEALLOCATE_KEY_RESP_EVENT_DEALLOCATE_KEY UINT32_C(0xe)
+	#define CREQ_DEALLOCATE_KEY_RESP_EVENT_LAST	CREQ_DEALLOCATE_KEY_RESP_EVENT_DEALLOCATE_KEY
+	uint16_t	reserved16;
 	/*
-	 * This field is used in Output records to indicate that the
-	 * output is completely written to RAM. This field should be
-	 * read as '1' to indicate that the output has been
-	 * completely written.  When writing a command completion or
-	 * response to an internal processor, the order of writes has
-	 * to be such that this field is written last.
+	 * This is advisory data to facilitate eventual destruction of
+	 * lingering memory regions in Windows. For memory window, it contains
+	 * non-zero HWID of a region this window was bound to (without the
+	 * 8-bit key portion). The host may check if the region is lingering in
+	 * destroyed state and try to destroy it now. For memory region, if
+	 * deallocation fails because there are windows bound to this region,
+	 * this field will contain approximate number of those windows. This
+	 * number is read from the context right before the deregistration is
+	 * attempted and can potentially be slightly different from the current
+	 * number.
 	 */
-	uint8_t	valid;
-} hwrm_tf_tcam_move_output_t, *phwrm_tf_tcam_move_output_t;
+	uint32_t	bound_window_info;
+} creq_deallocate_key_resp_t, *pcreq_deallocate_key_resp_t;
 
-/*********************
- * hwrm_tf_tcam_free *
- *********************/
+/***************
+ * register_mr *
+ ***************/
 
 
-/* hwrm_tf_tcam_free_input (size:1024b/128B) */
+/* cmdq_register_mr (size:512b/64B) */
 
-typedef struct hwrm_tf_tcam_free_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+typedef struct cmdq_register_mr {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Register MR command registers memory to the specified MR. */
+	#define CMDQ_REGISTER_MR_OPCODE_REGISTER_MR UINT32_C(0xf)
+	#define CMDQ_REGISTER_MR_OPCODE_LAST	CMDQ_REGISTER_MR_OPCODE_REGISTER_MR
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * When set, a new MR will be allocated first and then registered
+	 * using the fields in this command. Note that for MR allocation
+	 * the `key` field doesn't hold a valid L_KEY and is instead
+	 * overloaded to hold the Protection Domain ID `pd_id`.
 	 */
-	uint16_t	cmpl_ring;
+	#define CMDQ_REGISTER_MR_FLAGS_ALLOC_MR		UINT32_C(0x1)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * This MR uses the steering tag specified in the command.
+	 * This flag can only be enabled when the command is used
+	 * to allocate a new MR first.
 	 */
-	uint16_t	seq_id;
+	#define CMDQ_REGISTER_MR_FLAGS_STEERING_TAG_VALID	UINT32_C(0x2)
+	/* When set, enable per MR relaxed ordering support. */
+	#define CMDQ_REGISTER_MR_FLAGS_ENABLE_RO		UINT32_C(0x4)
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+	uint8_t	log2_pg_size_lvl;
+	/* PBL indirect levels. */
+	#define CMDQ_REGISTER_MR_LVL_MASK		UINT32_C(0x3)
+	#define CMDQ_REGISTER_MR_LVL_SFT		0
+	/* PBL pointer is physical start address. */
+		#define CMDQ_REGISTER_MR_LVL_LVL_0		UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define CMDQ_REGISTER_MR_LVL_LVL_1		UINT32_C(0x1)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
 	 */
-	uint16_t	target_id;
+		#define CMDQ_REGISTER_MR_LVL_LVL_2		UINT32_C(0x2)
+		#define CMDQ_REGISTER_MR_LVL_LAST		CMDQ_REGISTER_MR_LVL_LVL_2
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Log base 2 of page size; 12 is the minimum for 4KB. HW supported
+	 * values are enumerated below.
 	 */
-	uint64_t	resp_addr;
-	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
-	uint32_t	fw_session_id;
-	/* Control flags. */
-	uint32_t	flags;
-	/* Indicates the flow direction. */
-	#define HWRM_TF_TCAM_FREE_INPUT_FLAGS_DIR	UINT32_C(0x1)
-	/* If this bit set to 0, then it indicates rx flow. */
-		#define HWRM_TF_TCAM_FREE_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
-	/* If this bit is set to 1, then it indicates tx flow. */
-		#define HWRM_TF_TCAM_FREE_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
-		#define HWRM_TF_TCAM_FREE_INPUT_FLAGS_DIR_LAST HWRM_TF_TCAM_FREE_INPUT_FLAGS_DIR_TX
+	#define CMDQ_REGISTER_MR_LOG2_PG_SIZE_MASK   UINT32_C(0x7c)
+	#define CMDQ_REGISTER_MR_LOG2_PG_SIZE_SFT	2
+	/* 4KB. */
+		#define CMDQ_REGISTER_MR_LOG2_PG_SIZE_PG_4K	(UINT32_C(0xc) << 2)
+	/* 8KB. */
+		#define CMDQ_REGISTER_MR_LOG2_PG_SIZE_PG_8K	(UINT32_C(0xd) << 2)
+	/* 64KB. */
+		#define CMDQ_REGISTER_MR_LOG2_PG_SIZE_PG_64K   (UINT32_C(0x10) << 2)
+	/* 256KB. */
+		#define CMDQ_REGISTER_MR_LOG2_PG_SIZE_PG_256K  (UINT32_C(0x12) << 2)
+	/* 1MB. */
+		#define CMDQ_REGISTER_MR_LOG2_PG_SIZE_PG_1M	(UINT32_C(0x14) << 2)
+	/* 2MB. */
+		#define CMDQ_REGISTER_MR_LOG2_PG_SIZE_PG_2M	(UINT32_C(0x15) << 2)
+	/* 4MB. */
+		#define CMDQ_REGISTER_MR_LOG2_PG_SIZE_PG_4M	(UINT32_C(0x16) << 2)
+	/* 1GB. */
+		#define CMDQ_REGISTER_MR_LOG2_PG_SIZE_PG_1G	(UINT32_C(0x1e) << 2)
+		#define CMDQ_REGISTER_MR_LOG2_PG_SIZE_LAST	CMDQ_REGISTER_MR_LOG2_PG_SIZE_PG_1G
+	/* unused1 is 1 b */
+	#define CMDQ_REGISTER_MR_UNUSED1		UINT32_C(0x80)
+	/* Access flags. */
+	uint8_t	access;
+	/* Local write access. */
+	#define CMDQ_REGISTER_MR_ACCESS_LOCAL_WRITE	UINT32_C(0x1)
+	/* Remote read access. */
+	#define CMDQ_REGISTER_MR_ACCESS_REMOTE_READ	UINT32_C(0x2)
+	/* Remote write access. */
+	#define CMDQ_REGISTER_MR_ACCESS_REMOTE_WRITE	UINT32_C(0x4)
+	/* Remote atomic access. */
+	#define CMDQ_REGISTER_MR_ACCESS_REMOTE_ATOMIC	UINT32_C(0x8)
+	/* Bind access allowed. */
+	#define CMDQ_REGISTER_MR_ACCESS_MW_BIND	UINT32_C(0x10)
+	/* Indicate Zero Based Virtual Address (ZBVA). */
+	#define CMDQ_REGISTER_MR_ACCESS_ZERO_BASED	UINT32_C(0x20)
+	uint16_t	log2_pbl_pg_size;
 	/*
-	 * TCAM type of the resource, defined globally in the
-	 * hwrm_tf_resc_type enum.
+	 * Log base 2 of PBL page size; 12 is the minimum for 4KB. HW
+	 * supported values are enumerated below
 	 */
-	uint32_t	type;
-	/* Number of TCAM index to be deleted for the device. */
-	uint16_t	count;
-	/* unused. */
-	uint16_t	unused0;
-	/* TCAM index list to be deleted for the device. */
-	uint16_t	idx_list[48];
-} hwrm_tf_tcam_free_input_t, *phwrm_tf_tcam_free_input_t;
-
-/* hwrm_tf_tcam_free_output (size:128b/16B) */
-
-typedef struct hwrm_tf_tcam_free_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* unused. */
-	uint8_t	unused0[7];
+	#define CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_MASK   UINT32_C(0x1f)
+	#define CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_SFT	0
+	/* 4KB. */
+		#define CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_PG_4K	UINT32_C(0xc)
+	/* 8KB. */
+		#define CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_PG_8K	UINT32_C(0xd)
+	/* 64KB. */
+		#define CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_PG_64K   UINT32_C(0x10)
+	/* 256KB. */
+		#define CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_PG_256K  UINT32_C(0x12)
+	/* 1MB. */
+		#define CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_PG_1M	UINT32_C(0x14)
+	/* 2MB. */
+		#define CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_PG_2M	UINT32_C(0x15)
+	/* 4MB. */
+		#define CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_PG_4M	UINT32_C(0x16)
+	/* 1GB. */
+		#define CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_PG_1G	UINT32_C(0x1e)
+		#define CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_LAST	CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_PG_1G
+	/* unused11 is 11 b */
+	#define CMDQ_REGISTER_MR_UNUSED11_MASK	UINT32_C(0xffe0)
+	#define CMDQ_REGISTER_MR_UNUSED11_SFT		5
 	/*
-	 * This field is used in Output records to indicate that the
-	 * output is completely written to RAM. This field should be
-	 * read as '1' to indicate that the output has been
-	 * completely written.  When writing a command completion or
-	 * response to an internal processor, the order of writes has
-	 * to be such that this field is written last.
+	 * L_KEY of the previously allocated MR.
+	 *
+	 * If the `ALLOC_MR` flag is set then this field does not hold an
+	 * L_KEY and instead contains the Protection Domain ID `pd_id`.
 	 */
-	uint8_t	valid;
-} hwrm_tf_tcam_free_output_t, *phwrm_tf_tcam_free_output_t;
-
-/**************************
- * hwrm_tf_global_cfg_set *
- **************************/
-
+	uint32_t	key;
+	/* Page table of the MR memory. */
+	uint64_t	pbl;
+	/* Virtual address of the MR. */
+	uint64_t	va;
+	/* Size of the MR. */
+	uint64_t	mr_size;
+	/* Steering tag to use for memory transactions. */
+	uint16_t	steering_tag;
+	uint8_t	reserved48[6];
+	/* reserved64 is 64 b */
+	uint64_t	reserved64;
+} cmdq_register_mr_t, *pcmdq_register_mr_t;
 
-/* hwrm_tf_global_cfg_set_input (size:448b/56B) */
+/* creq_register_mr_resp (size:128b/16B) */
 
-typedef struct hwrm_tf_global_cfg_set_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+typedef struct creq_register_mr_resp {
+	uint8_t	type;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint16_t	cmpl_ring;
+	#define CREQ_REGISTER_MR_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_REGISTER_MR_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_REGISTER_MR_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_REGISTER_MR_RESP_TYPE_LAST	CREQ_REGISTER_MR_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* L_KEY */
+	uint32_t	xid;
+	uint8_t	v;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint16_t	seq_id;
+	#define CREQ_REGISTER_MR_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Register MR command response. */
+	#define CREQ_REGISTER_MR_RESP_EVENT_REGISTER_MR UINT32_C(0xf)
+	#define CREQ_REGISTER_MR_RESP_EVENT_LAST	CREQ_REGISTER_MR_RESP_EVENT_REGISTER_MR
+	uint8_t	reserved48[6];
+} creq_register_mr_resp_t, *pcreq_register_mr_resp_t;
+
+/*****************
+ * deregister_mr *
+ *****************/
+
+
+/* cmdq_deregister_mr (size:192b/24B) */
+
+typedef struct cmdq_deregister_mr {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Deregister MR command de-registers memory from the specified MR. */
+	#define CMDQ_DEREGISTER_MR_OPCODE_DEREGISTER_MR UINT32_C(0x10)
+	#define CMDQ_DEREGISTER_MR_OPCODE_LAST	CMDQ_DEREGISTER_MR_OPCODE_DEREGISTER_MR
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+	/* L_KEY of the MR. */
+	uint32_t	lkey;
+	uint32_t	unused_0;
+} cmdq_deregister_mr_t, *pcmdq_deregister_mr_t;
+
+/* creq_deregister_mr_resp (size:128b/16B) */
+
+typedef struct creq_deregister_mr_resp {
+	uint8_t	type;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint16_t	target_id;
+	#define CREQ_DEREGISTER_MR_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_DEREGISTER_MR_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_DEREGISTER_MR_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_DEREGISTER_MR_RESP_TYPE_LAST	CREQ_DEREGISTER_MR_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* L_KEY */
+	uint32_t	xid;
+	uint8_t	v;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint64_t	resp_addr;
-	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
-	uint32_t	fw_session_id;
-	/* Control flags. */
-	uint32_t	flags;
-	/* Indicates the flow direction. */
-	#define HWRM_TF_GLOBAL_CFG_SET_INPUT_FLAGS_DIR	UINT32_C(0x1)
-	/* If this bit set to 0, then it indicates rx flow. */
-		#define HWRM_TF_GLOBAL_CFG_SET_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
-	/* If this bit is set to 1, then it indicates tx flow. */
-		#define HWRM_TF_GLOBAL_CFG_SET_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
-		#define HWRM_TF_GLOBAL_CFG_SET_INPUT_FLAGS_DIR_LAST HWRM_TF_GLOBAL_CFG_SET_INPUT_FLAGS_DIR_TX
-	/* Global Cfg type */
-	uint32_t	type;
-	/* Offset of the type */
-	uint32_t	offset;
-	/* Size of the data to set in bytes */
-	uint16_t	size;
-	/* unused. */
-	uint8_t	unused0[6];
-	/* Data to set */
-	uint8_t	data[8];
-	/* Mask of data to set, 0 indicates no mask */
-	uint8_t	mask[8];
-} hwrm_tf_global_cfg_set_input_t, *phwrm_tf_global_cfg_set_input_t;
-
-/* hwrm_tf_global_cfg_set_output (size:128b/16B) */
-
-typedef struct hwrm_tf_global_cfg_set_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* unused. */
-	uint8_t	unused0[7];
+	#define CREQ_DEREGISTER_MR_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Deregister MR command response. */
+	#define CREQ_DEREGISTER_MR_RESP_EVENT_DEREGISTER_MR UINT32_C(0x10)
+	#define CREQ_DEREGISTER_MR_RESP_EVENT_LAST	CREQ_DEREGISTER_MR_RESP_EVENT_DEREGISTER_MR
+	uint16_t	reserved16;
 	/*
-	 * This field is used in Output records to indicate that the
-	 * output is completely written to RAM. This field should be
-	 * read as '1' to indicate that the output has been
-	 * completely written.  When writing a command completion or
-	 * response to an internal processor, the order of writes has
-	 * to be such that this field is written last.
+	 * If deregister fails because there are windows bound to this region,
+	 * this field will contain approximate number of those windows. This
+	 * number is read from the context right before the deregistration is
+	 * attempted and can potentially be slightly different from the current
+	 * number.
 	 */
-	uint8_t	valid;
-} hwrm_tf_global_cfg_set_output_t, *phwrm_tf_global_cfg_set_output_t;
+	uint32_t	bound_windows;
+} creq_deregister_mr_resp_t, *pcreq_deregister_mr_resp_t;
 
-/**************************
- * hwrm_tf_global_cfg_get *
- **************************/
+/***********
+ * add_gid *
+ ***********/
 
 
-/* hwrm_tf_global_cfg_get_input (size:320b/40B) */
+/* cmdq_add_gid (size:384b/48B) */
 
-typedef struct hwrm_tf_global_cfg_get_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+typedef struct cmdq_add_gid {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Add GID command adds a GID to the local address table. */
+	#define CMDQ_ADD_GID_OPCODE_ADD_GID UINT32_C(0x11)
+	#define CMDQ_ADD_GID_OPCODE_LAST   CMDQ_ADD_GID_OPCODE_ADD_GID
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+	/* GID, specified in LE format. */
+	uint32_t	gid[4];
+	/* Source MAC. */
+	uint16_t	src_mac[3];
+	/* flags. */
+	uint16_t	vlan;
+	#define CMDQ_ADD_GID_VLAN_VLAN_EN_TPID_VLAN_ID_MASK	UINT32_C(0xffff)
+	#define CMDQ_ADD_GID_VLAN_VLAN_EN_TPID_VLAN_ID_SFT	0
+	/* Source VLAN id. */
+	#define CMDQ_ADD_GID_VLAN_VLAN_ID_MASK			UINT32_C(0xfff)
+	#define CMDQ_ADD_GID_VLAN_VLAN_ID_SFT			0
+	/* This set of bits select the TPID of the VLAN Tag. */
+	#define CMDQ_ADD_GID_VLAN_TPID_MASK			UINT32_C(0x7000)
+	#define CMDQ_ADD_GID_VLAN_TPID_SFT			12
+	/* TPID = 0x88A8. */
+		#define CMDQ_ADD_GID_VLAN_TPID_TPID_88A8			(UINT32_C(0x0) << 12)
+	/* TPID = 0x8100. */
+		#define CMDQ_ADD_GID_VLAN_TPID_TPID_8100			(UINT32_C(0x1) << 12)
+	/* TPID = 0x9100. */
+		#define CMDQ_ADD_GID_VLAN_TPID_TPID_9100			(UINT32_C(0x2) << 12)
+	/* TPID = 0x9200. */
+		#define CMDQ_ADD_GID_VLAN_TPID_TPID_9200			(UINT32_C(0x3) << 12)
+	/* TPID = 0x9300. */
+		#define CMDQ_ADD_GID_VLAN_TPID_TPID_9300			(UINT32_C(0x4) << 12)
+	/* TPID = Configurable 1. */
+		#define CMDQ_ADD_GID_VLAN_TPID_TPID_CFG1			(UINT32_C(0x5) << 12)
+	/* TPID = Configurable 2. */
+		#define CMDQ_ADD_GID_VLAN_TPID_TPID_CFG2			(UINT32_C(0x6) << 12)
+	/* TPID = Configurable 3. */
+		#define CMDQ_ADD_GID_VLAN_TPID_TPID_CFG3			(UINT32_C(0x7) << 12)
+		#define CMDQ_ADD_GID_VLAN_TPID_LAST			CMDQ_ADD_GID_VLAN_TPID_TPID_CFG3
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * Setting this bit to 1 enables insertion of a VLAN Tag to a RoCE
+	 * header.
 	 */
-	uint16_t	cmpl_ring;
+	#define CMDQ_ADD_GID_VLAN_VLAN_EN				UINT32_C(0x8000)
+	/* Identifier field in the IP header. */
+	uint16_t	ipid;
+	/* Stats context ID to use with this SGID */
+	uint16_t	stats_ctx;
+	#define CMDQ_ADD_GID_STATS_CTX_STATS_CTX_VALID_STATS_CTX_ID_MASK		UINT32_C(0xffff)
+	#define CMDQ_ADD_GID_STATS_CTX_STATS_CTX_VALID_STATS_CTX_ID_SFT		0
+	/* stats_ctx_id is 15 b */
+	#define CMDQ_ADD_GID_STATS_CTX_STATS_CTX_ID_MASK				UINT32_C(0x7fff)
+	#define CMDQ_ADD_GID_STATS_CTX_STATS_CTX_ID_SFT				0
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Setting this bit to 1 enables use of own stats context ID
+	 * instead of per-function.
 	 */
-	uint16_t	seq_id;
+	#define CMDQ_ADD_GID_STATS_CTX_STATS_CTX_VALID				UINT32_C(0x8000)
+	uint32_t	unused_0;
+} cmdq_add_gid_t, *pcmdq_add_gid_t;
+
+/* creq_add_gid_resp (size:128b/16B) */
+
+typedef struct creq_add_gid_resp {
+	uint8_t	type;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint16_t	target_id;
+	#define CREQ_ADD_GID_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_ADD_GID_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_ADD_GID_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_ADD_GID_RESP_TYPE_LAST	CREQ_ADD_GID_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* GID index */
+	uint32_t	xid;
+	uint8_t	v;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint64_t	resp_addr;
-	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
-	uint32_t	fw_session_id;
-	/* Control flags. */
-	uint32_t	flags;
-	/* Indicates the flow direction. */
-	#define HWRM_TF_GLOBAL_CFG_GET_INPUT_FLAGS_DIR	UINT32_C(0x1)
-	/* If this bit set to 0, then it indicates rx flow. */
-		#define HWRM_TF_GLOBAL_CFG_GET_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
-	/* If this bit is set to 1, then it indicates tx flow. */
-		#define HWRM_TF_GLOBAL_CFG_GET_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
-		#define HWRM_TF_GLOBAL_CFG_GET_INPUT_FLAGS_DIR_LAST HWRM_TF_GLOBAL_CFG_GET_INPUT_FLAGS_DIR_TX
-	/* Global Cfg type */
-	uint32_t	type;
-	/* Offset of the type */
-	uint32_t	offset;
-	/* Size of the data to set in bytes */
-	uint16_t	size;
-	/* unused. */
-	uint8_t	unused0[6];
-} hwrm_tf_global_cfg_get_input_t, *phwrm_tf_global_cfg_get_input_t;
+	#define CREQ_ADD_GID_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Add GID command response. */
+	#define CREQ_ADD_GID_RESP_EVENT_ADD_GID UINT32_C(0x11)
+	#define CREQ_ADD_GID_RESP_EVENT_LAST   CREQ_ADD_GID_RESP_EVENT_ADD_GID
+	uint8_t	reserved48[6];
+} creq_add_gid_resp_t, *pcreq_add_gid_resp_t;
 
-/* hwrm_tf_global_cfg_get_output (size:256b/32B) */
+/**************
+ * delete_gid *
+ **************/
 
-typedef struct hwrm_tf_global_cfg_get_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Size of the data read in bytes */
-	uint16_t	size;
-	/* unused. */
-	uint8_t	unused0[6];
-	/* Data to set */
-	uint8_t	data[16];
-} hwrm_tf_global_cfg_get_output_t, *phwrm_tf_global_cfg_get_output_t;
 
-/**********************
- * hwrm_tf_if_tbl_get *
- **********************/
+/* cmdq_delete_gid (size:192b/24B) */
 
+typedef struct cmdq_delete_gid {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Delete GID command deletes a GID from the local address table. */
+	#define CMDQ_DELETE_GID_OPCODE_DELETE_GID UINT32_C(0x12)
+	#define CMDQ_DELETE_GID_OPCODE_LAST	CMDQ_DELETE_GID_OPCODE_DELETE_GID
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+	/* GID index */
+	uint16_t	gid_index;
+	uint8_t	unused_0[6];
+} cmdq_delete_gid_t, *pcmdq_delete_gid_t;
 
-/* hwrm_tf_if_tbl_get_input (size:256b/32B) */
+/* creq_delete_gid_resp (size:128b/16B) */
 
-typedef struct hwrm_tf_if_tbl_get_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
-	 */
-	uint16_t	cmpl_ring;
+typedef struct creq_delete_gid_resp {
+	uint8_t	type;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint16_t	seq_id;
+	#define CREQ_DELETE_GID_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_DELETE_GID_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_DELETE_GID_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_DELETE_GID_RESP_TYPE_LAST	CREQ_DELETE_GID_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* GID index */
+	uint32_t	xid;
+	uint8_t	v;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint16_t	target_id;
+	#define CREQ_DELETE_GID_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Delete GID command response. */
+	#define CREQ_DELETE_GID_RESP_EVENT_DELETE_GID UINT32_C(0x12)
+	#define CREQ_DELETE_GID_RESP_EVENT_LAST	CREQ_DELETE_GID_RESP_EVENT_DELETE_GID
+	uint8_t	reserved48[6];
+} creq_delete_gid_resp_t, *pcreq_delete_gid_resp_t;
+
+/**************
+ * modify_gid *
+ **************/
+
+
+/* cmdq_modify_gid (size:384b/48B) */
+
+typedef struct cmdq_modify_gid {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Modify GID command modifies a GID in the local address table. */
+	#define CMDQ_MODIFY_GID_OPCODE_MODIFY_GID UINT32_C(0x17)
+	#define CMDQ_MODIFY_GID_OPCODE_LAST	CMDQ_MODIFY_GID_OPCODE_MODIFY_GID
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+	/* GID */
+	uint32_t	gid[4];
+	/* Source MAC. */
+	uint16_t	src_mac[3];
+	/* flags. */
+	uint16_t	vlan;
+	/* Source VLAN id. */
+	#define CMDQ_MODIFY_GID_VLAN_VLAN_ID_MASK  UINT32_C(0xfff)
+	#define CMDQ_MODIFY_GID_VLAN_VLAN_ID_SFT   0
+	/* This set of bits select the TPID of the VLAN Tag. */
+	#define CMDQ_MODIFY_GID_VLAN_TPID_MASK	UINT32_C(0x7000)
+	#define CMDQ_MODIFY_GID_VLAN_TPID_SFT	12
+	/* TPID = 0x88A8. */
+		#define CMDQ_MODIFY_GID_VLAN_TPID_TPID_88A8  (UINT32_C(0x0) << 12)
+	/* TPID = 0x8100. */
+		#define CMDQ_MODIFY_GID_VLAN_TPID_TPID_8100  (UINT32_C(0x1) << 12)
+	/* TPID = 0x9100. */
+		#define CMDQ_MODIFY_GID_VLAN_TPID_TPID_9100  (UINT32_C(0x2) << 12)
+	/* TPID = 0x9200. */
+		#define CMDQ_MODIFY_GID_VLAN_TPID_TPID_9200  (UINT32_C(0x3) << 12)
+	/* TPID = 0x9300. */
+		#define CMDQ_MODIFY_GID_VLAN_TPID_TPID_9300  (UINT32_C(0x4) << 12)
+	/* TPID = Configurable 1. */
+		#define CMDQ_MODIFY_GID_VLAN_TPID_TPID_CFG1  (UINT32_C(0x5) << 12)
+	/* TPID = Configurable 2. */
+		#define CMDQ_MODIFY_GID_VLAN_TPID_TPID_CFG2  (UINT32_C(0x6) << 12)
+	/* TPID = Configurable 3. */
+		#define CMDQ_MODIFY_GID_VLAN_TPID_TPID_CFG3  (UINT32_C(0x7) << 12)
+		#define CMDQ_MODIFY_GID_VLAN_TPID_LAST	CMDQ_MODIFY_GID_VLAN_TPID_TPID_CFG3
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Setting this bit to 1 enables insertion of a VLAN Tag to a RoCE
+	 * header.
 	 */
-	uint64_t	resp_addr;
-	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
-	uint32_t	fw_session_id;
-	/* Control flags. */
-	uint16_t	flags;
-	/* Indicates the flow direction. */
-	#define HWRM_TF_IF_TBL_GET_INPUT_FLAGS_DIR	UINT32_C(0x1)
-	/* If this bit set to 0, then it indicates rx flow. */
-		#define HWRM_TF_IF_TBL_GET_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
-	/* If this bit is set to 1, then it indicates tx flow. */
-		#define HWRM_TF_IF_TBL_GET_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
-		#define HWRM_TF_IF_TBL_GET_INPUT_FLAGS_DIR_LAST HWRM_TF_IF_TBL_GET_INPUT_FLAGS_DIR_TX
-	/* Size of the data to set. */
-	uint16_t	size;
+	#define CMDQ_MODIFY_GID_VLAN_VLAN_EN	UINT32_C(0x8000)
+	/* Identifier field in the IP header. */
+	uint16_t	ipid;
+	/* GID index */
+	uint16_t	gid_index;
+	/* Stats context ID to use with this SGID */
+	uint16_t	stats_ctx;
+	/* stats_ctx_id is 15 b */
+	#define CMDQ_MODIFY_GID_STATS_CTX_STATS_CTX_ID_MASK   UINT32_C(0x7fff)
+	#define CMDQ_MODIFY_GID_STATS_CTX_STATS_CTX_ID_SFT	0
 	/*
-	 * Type of the resource, defined globally in the
-	 * hwrm_tf_resc_type enum.
+	 * Setting this bit to 1 enables use of own stats context ID
+	 * instead of per-function.
 	 */
-	uint32_t	type;
-	/* Index of the type to retrieve. */
-	uint32_t	index;
-} hwrm_tf_if_tbl_get_input_t, *phwrm_tf_if_tbl_get_input_t;
+	#define CMDQ_MODIFY_GID_STATS_CTX_STATS_CTX_VALID	UINT32_C(0x8000)
+	uint16_t	unused_0;
+} cmdq_modify_gid_t, *pcmdq_modify_gid_t;
 
-/* hwrm_tf_if_tbl_get_output (size:256b/32B) */
+/* creq_modify_gid_resp (size:128b/16B) */
 
-typedef struct hwrm_tf_if_tbl_get_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Response code. */
-	uint32_t	resp_code;
-	/* Response size. */
-	uint16_t	size;
-	/* unused */
-	uint16_t	unused0;
-	/* Response data. */
-	uint8_t	data[8];
-	/* unused */
-	uint8_t	unused1[7];
+typedef struct creq_modify_gid_resp {
+	uint8_t	type;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field
-	 * is written last.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint8_t	valid;
-} hwrm_tf_if_tbl_get_output_t, *phwrm_tf_if_tbl_get_output_t;
+	#define CREQ_MODIFY_GID_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_MODIFY_GID_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_MODIFY_GID_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_MODIFY_GID_RESP_TYPE_LAST	CREQ_MODIFY_GID_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* GID index */
+	uint32_t	xid;
+	uint8_t	v;
+	/*
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
+	 */
+	#define CREQ_MODIFY_GID_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Add GID command response. */
+	#define CREQ_MODIFY_GID_RESP_EVENT_ADD_GID UINT32_C(0x11)
+	#define CREQ_MODIFY_GID_RESP_EVENT_LAST   CREQ_MODIFY_GID_RESP_EVENT_ADD_GID
+	uint8_t	reserved48[6];
+} creq_modify_gid_resp_t, *pcreq_modify_gid_resp_t;
 
-/***************************
- * hwrm_tf_if_tbl_type_set *
- ***************************/
+/*************
+ * query_gid *
+ *************/
 
 
-/* hwrm_tf_if_tbl_set_input (size:384b/48B) */
+/* cmdq_query_gid (size:192b/24B) */
 
-typedef struct hwrm_tf_if_tbl_set_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
-	 */
-	uint16_t	cmpl_ring;
-	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
-	 */
-	uint16_t	seq_id;
-	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
-	 */
-	uint16_t	target_id;
+typedef struct cmdq_query_gid {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Query GID command queries a GID in the local address table. */
+	#define CMDQ_QUERY_GID_OPCODE_QUERY_GID UINT32_C(0x18)
+	#define CMDQ_QUERY_GID_OPCODE_LAST	CMDQ_QUERY_GID_OPCODE_QUERY_GID
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+	/* GID index */
+	uint16_t	gid_index;
+	/* unused16 is 16 b */
+	uint8_t	unused16[6];
+} cmdq_query_gid_t, *pcmdq_query_gid_t;
+
+/* creq_query_gid_resp (size:128b/16B) */
+
+typedef struct creq_query_gid_resp {
+	uint8_t	type;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint64_t	resp_addr;
-	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
-	uint32_t	fw_session_id;
-	/* Control flags. */
-	uint16_t	flags;
-	/* Indicates the flow direction. */
-	#define HWRM_TF_IF_TBL_SET_INPUT_FLAGS_DIR	UINT32_C(0x1)
-	/* If this bit set to 0, then it indicates rx flow. */
-		#define HWRM_TF_IF_TBL_SET_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
-	/* If this bit is set to 1, then it indicates tx flow. */
-		#define HWRM_TF_IF_TBL_SET_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
-		#define HWRM_TF_IF_TBL_SET_INPUT_FLAGS_DIR_LAST HWRM_TF_IF_TBL_SET_INPUT_FLAGS_DIR_TX
-	/* unused. */
-	uint8_t	unused0[2];
+	#define CREQ_QUERY_GID_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_QUERY_GID_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_QUERY_GID_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_QUERY_GID_RESP_TYPE_LAST	CREQ_QUERY_GID_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Side buffer size in 16-byte units */
+	uint32_t	size;
+	uint8_t	v;
 	/*
-	 * Type of the resource, defined globally in the
-	 * hwrm_tf_resc_type enum.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint32_t	type;
-	/* Index of the type to set. */
-	uint32_t	index;
-	/* Size of the data to set. */
-	uint16_t	size;
-	/* unused */
-	uint8_t	unused1[6];
-	/* Data to be set. */
-	uint8_t	data[8];
-} hwrm_tf_if_tbl_set_input_t, *phwrm_tf_if_tbl_set_input_t;
-
-/* hwrm_tf_if_tbl_set_output (size:128b/16B) */
-
-typedef struct hwrm_tf_if_tbl_set_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* unused. */
-	uint8_t	unused0[7];
+	#define CREQ_QUERY_GID_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Query GID command response. */
+	#define CREQ_QUERY_GID_RESP_EVENT_QUERY_GID UINT32_C(0x18)
+	#define CREQ_QUERY_GID_RESP_EVENT_LAST	CREQ_QUERY_GID_RESP_EVENT_QUERY_GID
+	uint8_t	reserved48[6];
+} creq_query_gid_resp_t, *pcreq_query_gid_resp_t;
+
+/* Query GID command response side buffer structure */
+/* creq_query_gid_resp_sb (size:320b/40B) */
+
+typedef struct creq_query_gid_resp_sb {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Query GID command response. */
+	#define CREQ_QUERY_GID_RESP_SB_OPCODE_QUERY_GID UINT32_C(0x18)
+	#define CREQ_QUERY_GID_RESP_SB_OPCODE_LAST	CREQ_QUERY_GID_RESP_SB_OPCODE_QUERY_GID
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* GID */
+	uint32_t	gid[4];
+	/* Source MAC. */
+	uint16_t	src_mac[3];
+	/* flags. */
+	uint16_t	vlan;
+	#define CREQ_QUERY_GID_RESP_SB_VLAN_VLAN_EN_TPID_VLAN_ID_MASK	UINT32_C(0xffff)
+	#define CREQ_QUERY_GID_RESP_SB_VLAN_VLAN_EN_TPID_VLAN_ID_SFT	0
+	/* Source VLAN id. */
+	#define CREQ_QUERY_GID_RESP_SB_VLAN_VLAN_ID_MASK			UINT32_C(0xfff)
+	#define CREQ_QUERY_GID_RESP_SB_VLAN_VLAN_ID_SFT			0
+	/* This set of bits select the TPID of the VLAN Tag. */
+	#define CREQ_QUERY_GID_RESP_SB_VLAN_TPID_MASK			UINT32_C(0x7000)
+	#define CREQ_QUERY_GID_RESP_SB_VLAN_TPID_SFT			12
+	/* TPID = 0x88A8. */
+		#define CREQ_QUERY_GID_RESP_SB_VLAN_TPID_TPID_88A8			(UINT32_C(0x0) << 12)
+	/* TPID = 0x8100. */
+		#define CREQ_QUERY_GID_RESP_SB_VLAN_TPID_TPID_8100			(UINT32_C(0x1) << 12)
+	/* TPID = 0x9100. */
+		#define CREQ_QUERY_GID_RESP_SB_VLAN_TPID_TPID_9100			(UINT32_C(0x2) << 12)
+	/* TPID = 0x9200. */
+		#define CREQ_QUERY_GID_RESP_SB_VLAN_TPID_TPID_9200			(UINT32_C(0x3) << 12)
+	/* TPID = 0x9300. */
+		#define CREQ_QUERY_GID_RESP_SB_VLAN_TPID_TPID_9300			(UINT32_C(0x4) << 12)
+	/* TPID = Configurable 1. */
+		#define CREQ_QUERY_GID_RESP_SB_VLAN_TPID_TPID_CFG1			(UINT32_C(0x5) << 12)
+	/* TPID = Configurable 2. */
+		#define CREQ_QUERY_GID_RESP_SB_VLAN_TPID_TPID_CFG2			(UINT32_C(0x6) << 12)
+	/* TPID = Configurable 3. */
+		#define CREQ_QUERY_GID_RESP_SB_VLAN_TPID_TPID_CFG3			(UINT32_C(0x7) << 12)
+		#define CREQ_QUERY_GID_RESP_SB_VLAN_TPID_LAST			CREQ_QUERY_GID_RESP_SB_VLAN_TPID_TPID_CFG3
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field
-	 * is written last.
+	 * Setting this bit to 1 enables insertion of a VLAN Tag to a RoCE
+	 * header.
 	 */
-	uint8_t	valid;
-} hwrm_tf_if_tbl_set_output_t, *phwrm_tf_if_tbl_set_output_t;
+	#define CREQ_QUERY_GID_RESP_SB_VLAN_VLAN_EN				UINT32_C(0x8000)
+	/* Identifier field in the IP header. */
+	uint16_t	ipid;
+	/* GID index */
+	uint16_t	gid_index;
+	uint32_t	unused_0;
+} creq_query_gid_resp_sb_t, *pcreq_query_gid_resp_sb_t;
 
-/*****************************
- * hwrm_tf_tbl_type_bulk_get *
- *****************************/
+/**************
+ * create_qp1 *
+ **************/
 
 
-/* hwrm_tf_tbl_type_bulk_get_input (size:384b/48B) */
+/* cmdq_create_qp1 (size:640b/80B) */
 
-typedef struct hwrm_tf_tbl_type_bulk_get_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
-	 */
-	uint16_t	cmpl_ring;
+typedef struct cmdq_create_qp1 {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Create QP1 command allocates a QP1 only. */
+	#define CMDQ_CREATE_QP1_OPCODE_CREATE_QP1 UINT32_C(0x13)
+	#define CMDQ_CREATE_QP1_OPCODE_LAST	CMDQ_CREATE_QP1_OPCODE_CREATE_QP1
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+	/* QP1 handle. */
+	uint64_t	qp_handle;
+	/* Create QP1 flags. */
+	uint32_t	qp_flags;
+	/* SRQ is used. */
+	#define CMDQ_CREATE_QP1_QP_FLAGS_SRQ_USED		UINT32_C(0x1)
+	/* post CQE for all SQ WQEs. */
+	#define CMDQ_CREATE_QP1_QP_FLAGS_FORCE_COMPLETION	UINT32_C(0x2)
+	/* This QP can use reserved L_Key */
+	#define CMDQ_CREATE_QP1_QP_FLAGS_RESERVED_LKEY_ENABLE UINT32_C(0x4)
+	#define CMDQ_CREATE_QP1_QP_FLAGS_LAST		CMDQ_CREATE_QP1_QP_FLAGS_RESERVED_LKEY_ENABLE
+	/* Supported QP1 types. */
+	uint8_t	type;
+	/* General Services Interface on QP 1. */
+	#define CMDQ_CREATE_QP1_TYPE_GSI UINT32_C(0x1)
+	#define CMDQ_CREATE_QP1_TYPE_LAST CMDQ_CREATE_QP1_TYPE_GSI
+	uint8_t	sq_pg_size_sq_lvl;
+	/* SQ PBL indirect levels. */
+	#define CMDQ_CREATE_QP1_SQ_LVL_MASK	UINT32_C(0xf)
+	#define CMDQ_CREATE_QP1_SQ_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define CMDQ_CREATE_QP1_SQ_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define CMDQ_CREATE_QP1_SQ_LVL_LVL_1	UINT32_C(0x1)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
 	 */
-	uint16_t	seq_id;
+		#define CMDQ_CREATE_QP1_SQ_LVL_LVL_2	UINT32_C(0x2)
+		#define CMDQ_CREATE_QP1_SQ_LVL_LAST	CMDQ_CREATE_QP1_SQ_LVL_LVL_2
+	/* SQ page size. */
+	#define CMDQ_CREATE_QP1_SQ_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define CMDQ_CREATE_QP1_SQ_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define CMDQ_CREATE_QP1_SQ_PG_SIZE_LAST   CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_1G
+	uint8_t	rq_pg_size_rq_lvl;
+	/* RQ PBL indirect levels. */
+	#define CMDQ_CREATE_QP1_RQ_LVL_MASK	UINT32_C(0xf)
+	#define CMDQ_CREATE_QP1_RQ_LVL_SFT	0
+	/* PBL pointer is physical start address. */
+		#define CMDQ_CREATE_QP1_RQ_LVL_LVL_0	UINT32_C(0x0)
+	/* PBL pointer points to PTE table. */
+		#define CMDQ_CREATE_QP1_RQ_LVL_LVL_1	UINT32_C(0x1)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * PBL pointer points to PDE table with each entry pointing to PTE
+	 * tables.
 	 */
-	uint16_t	target_id;
+		#define CMDQ_CREATE_QP1_RQ_LVL_LVL_2	UINT32_C(0x2)
+		#define CMDQ_CREATE_QP1_RQ_LVL_LAST	CMDQ_CREATE_QP1_RQ_LVL_LVL_2
+	/* RQ page size. */
+	#define CMDQ_CREATE_QP1_RQ_PG_SIZE_MASK  UINT32_C(0xf0)
+	#define CMDQ_CREATE_QP1_RQ_PG_SIZE_SFT   4
+	/* 4KB. */
+		#define CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
+	/* 8KB. */
+		#define CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
+	/* 64KB. */
+		#define CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
+	/* 2MB. */
+		#define CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
+	/* 8MB. */
+		#define CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
+	/* 1GB. */
+		#define CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
+		#define CMDQ_CREATE_QP1_RQ_PG_SIZE_LAST   CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_1G
+	uint8_t	unused_0;
+	/* Doorbell page index. */
+	uint32_t	dpi;
+	/* Max number of SQ wqes. */
+	uint32_t	sq_size;
+	/* Max number of RQ wqes. */
+	uint32_t	rq_size;
+	uint16_t	sq_fwo_sq_sge;
+	/* Max send SGEs per SWQE. */
+	#define CMDQ_CREATE_QP1_SQ_SGE_MASK UINT32_C(0xf)
+	#define CMDQ_CREATE_QP1_SQ_SGE_SFT 0
+	/* Offset of First WQE in the first SQ page, in 128 byte units */
+	#define CMDQ_CREATE_QP1_SQ_FWO_MASK UINT32_C(0xfff0)
+	#define CMDQ_CREATE_QP1_SQ_FWO_SFT 4
+	uint16_t	rq_fwo_rq_sge;
+	/* Max recv SGEs per RWQE (NOT SUPPORTED BY HARDWARE). */
+	#define CMDQ_CREATE_QP1_RQ_SGE_MASK UINT32_C(0xf)
+	#define CMDQ_CREATE_QP1_RQ_SGE_SFT 0
+	/* Offset of First WQE in the first RQ page, in 128 byte units */
+	#define CMDQ_CREATE_QP1_RQ_FWO_MASK UINT32_C(0xfff0)
+	#define CMDQ_CREATE_QP1_RQ_FWO_SFT 4
+	/* Send CQ context id. */
+	uint32_t	scq_cid;
+	/* Receive CQ context id. */
+	uint32_t	rcq_cid;
+	/* SRQ CQ context id. */
+	uint32_t	srq_cid;
+	/* Protection domain id. */
+	uint32_t	pd_id;
+	/* SQ PBL physical address. */
+	uint64_t	sq_pbl;
+	/* RQ PBL physical address. */
+	uint64_t	rq_pbl;
+} cmdq_create_qp1_t, *pcmdq_create_qp1_t;
+
+/* creq_create_qp1_resp (size:128b/16B) */
+
+typedef struct creq_create_qp1_resp {
+	uint8_t	type;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint64_t	resp_addr;
-	/* Firmware session id returned when HWRM_TF_SESSION_OPEN is sent. */
-	uint32_t	fw_session_id;
-	/* Control flags. */
-	uint16_t	flags;
-	/* Indicates the flow direction. */
-	#define HWRM_TF_TBL_TYPE_BULK_GET_INPUT_FLAGS_DIR	UINT32_C(0x1)
-	/* If this bit set to 0, then it indicates rx flow. */
-		#define HWRM_TF_TBL_TYPE_BULK_GET_INPUT_FLAGS_DIR_RX	UINT32_C(0x0)
-	/* If this bit is set to 1, then it indicates tx flow. */
-		#define HWRM_TF_TBL_TYPE_BULK_GET_INPUT_FLAGS_DIR_TX	UINT32_C(0x1)
-		#define HWRM_TF_TBL_TYPE_BULK_GET_INPUT_FLAGS_DIR_LAST HWRM_TF_TBL_TYPE_BULK_GET_INPUT_FLAGS_DIR_TX
-	/* unused. */
-	uint8_t	unused0[2];
+	#define CREQ_CREATE_QP1_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_CREATE_QP1_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_CREATE_QP1_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_CREATE_QP1_RESP_TYPE_LAST	CREQ_CREATE_QP1_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* QP1 context id */
+	uint32_t	xid;
+	uint8_t	v;
 	/*
-	 * Type of the resource, defined globally in the
-	 * hwrm_tf_resc_type enum.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint32_t	type;
-	/* Starting index of the type to retrieve. */
-	uint32_t	start_index;
-	/* Number of entries to retrieve. */
-	uint32_t	num_entries;
-	/* Number of entries to retrieve. */
-	uint32_t	unused1;
-	/* Host memory where data will be stored. */
-	uint64_t	host_addr;
-} hwrm_tf_tbl_type_bulk_get_input_t, *phwrm_tf_tbl_type_bulk_get_input_t;
+	#define CREQ_CREATE_QP1_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Create QP1 command response. */
+	#define CREQ_CREATE_QP1_RESP_EVENT_CREATE_QP1 UINT32_C(0x13)
+	#define CREQ_CREATE_QP1_RESP_EVENT_LAST	CREQ_CREATE_QP1_RESP_EVENT_CREATE_QP1
+	uint8_t	reserved48[6];
+} creq_create_qp1_resp_t, *pcreq_create_qp1_resp_t;
 
-/* hwrm_tf_tbl_type_bulk_get_output (size:128b/16B) */
+/***************
+ * destroy_qp1 *
+ ***************/
 
-typedef struct hwrm_tf_tbl_type_bulk_get_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Response code. */
-	uint32_t	resp_code;
-	/* Response size. */
-	uint16_t	size;
-	/* unused */
-	uint8_t	unused0;
-	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM. This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field
-	 * is written last.
-	 */
-	uint8_t	valid;
-} hwrm_tf_tbl_type_bulk_get_output_t, *phwrm_tf_tbl_type_bulk_get_output_t;
 
-/******************************
- * hwrm_tunnel_dst_port_query *
- ******************************/
+/* cmdq_destroy_qp1 (size:192b/24B) */
 
+typedef struct cmdq_destroy_qp1 {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Destroy QP1 command deletes and flushes the specified QP1. */
+	#define CMDQ_DESTROY_QP1_OPCODE_DESTROY_QP1 UINT32_C(0x14)
+	#define CMDQ_DESTROY_QP1_OPCODE_LAST	CMDQ_DESTROY_QP1_OPCODE_DESTROY_QP1
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+	/* QP1 context id */
+	uint32_t	qp1_cid;
+	uint32_t	unused_0;
+} cmdq_destroy_qp1_t, *pcmdq_destroy_qp1_t;
 
-/* hwrm_tunnel_dst_port_query_input (size:192b/24B) */
+/* creq_destroy_qp1_resp (size:128b/16B) */
 
-typedef struct hwrm_tunnel_dst_port_query_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
-	 */
-	uint16_t	cmpl_ring;
-	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
-	 */
-	uint16_t	seq_id;
+typedef struct creq_destroy_qp1_resp {
+	uint8_t	type;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint16_t	target_id;
+	#define CREQ_DESTROY_QP1_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_DESTROY_QP1_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_DESTROY_QP1_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_DESTROY_QP1_RESP_TYPE_LAST	CREQ_DESTROY_QP1_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* QP1 context id */
+	uint32_t	xid;
+	uint8_t	v;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
+	#define CREQ_DESTROY_QP1_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Destroy QP1 command response. */
+	#define CREQ_DESTROY_QP1_RESP_EVENT_DESTROY_QP1 UINT32_C(0x14)
+	#define CREQ_DESTROY_QP1_RESP_EVENT_LAST	CREQ_DESTROY_QP1_RESP_EVENT_DESTROY_QP1
+	uint8_t	reserved48[6];
+} creq_destroy_qp1_resp_t, *pcreq_destroy_qp1_resp_t;
+
+/*************
+ * create_ah *
+ *************/
+
+
+/* cmdq_create_ah (size:512b/64B) */
+
+typedef struct cmdq_create_ah {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Create AH command allocates an AH with the specified parameters. */
+	#define CMDQ_CREATE_AH_OPCODE_CREATE_AH UINT32_C(0x15)
+	#define CMDQ_CREATE_AH_OPCODE_LAST	CMDQ_CREATE_AH_OPCODE_CREATE_AH
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
 	uint64_t	resp_addr;
-	/* Tunnel Type. */
-	uint8_t	tunnel_type;
-	/* Virtual eXtensible Local Area Network (VXLAN) */
-	#define HWRM_TUNNEL_DST_PORT_QUERY_INPUT_TUNNEL_TYPE_VXLAN	UINT32_C(0x1)
-	/* Generic Network Virtualization Encapsulation (Geneve) */
-	#define HWRM_TUNNEL_DST_PORT_QUERY_INPUT_TUNNEL_TYPE_GENEVE	UINT32_C(0x5)
-	/* IPV4 over virtual eXtensible Local Area Network (IPV4oVXLAN) */
-	#define HWRM_TUNNEL_DST_PORT_QUERY_INPUT_TUNNEL_TYPE_VXLAN_V4	UINT32_C(0x9)
-	/* Enhance Generic Routing Encapsulation (GRE version 1) inside IP datagram payload */
-	#define HWRM_TUNNEL_DST_PORT_QUERY_INPUT_TUNNEL_TYPE_IPGRE_V1	UINT32_C(0xa)
-	/* Use fixed layer 2 ether type of 0xFFFF */
-	#define HWRM_TUNNEL_DST_PORT_QUERY_INPUT_TUNNEL_TYPE_L2_ETYPE	UINT32_C(0xb)
-	/* IPV6 over virtual eXtensible Local Area Network with GPE header (IPV6oVXLANGPE) */
-	#define HWRM_TUNNEL_DST_PORT_QUERY_INPUT_TUNNEL_TYPE_VXLAN_GPE_V6 UINT32_C(0xc)
-	#define HWRM_TUNNEL_DST_PORT_QUERY_INPUT_TUNNEL_TYPE_LAST	HWRM_TUNNEL_DST_PORT_QUERY_INPUT_TUNNEL_TYPE_VXLAN_GPE_V6
-	uint8_t	unused_0[7];
-} hwrm_tunnel_dst_port_query_input_t, *phwrm_tunnel_dst_port_query_input_t;
+	/* AH handle. */
+	uint64_t	ah_handle;
+	/* Destination GID, specified in BE format. */
+	uint32_t	dgid[4];
+	/* V1, V2IPv4 or V2IPv6. */
+	uint8_t	type;
+	/* V2IPv4. */
+	#define CMDQ_CREATE_AH_TYPE_V1	UINT32_C(0x0)
+	/* V2IPv4. */
+	#define CMDQ_CREATE_AH_TYPE_V2IPV4 UINT32_C(0x2)
+	/* V2IPv6. */
+	#define CMDQ_CREATE_AH_TYPE_V2IPV6 UINT32_C(0x3)
+	#define CMDQ_CREATE_AH_TYPE_LAST  CMDQ_CREATE_AH_TYPE_V2IPV6
+	/* IPv6 Hop limit. */
+	uint8_t	hop_limit;
+	/* SGID index. */
+	uint16_t	sgid_index;
+	uint32_t	dest_vlan_id_flow_label;
+	/* Flow label. */
+	#define CMDQ_CREATE_AH_FLOW_LABEL_MASK  UINT32_C(0xfffff)
+	#define CMDQ_CREATE_AH_FLOW_LABEL_SFT   0
+	/* Destination VLAN ID. */
+	#define CMDQ_CREATE_AH_DEST_VLAN_ID_MASK UINT32_C(0xfff00000)
+	#define CMDQ_CREATE_AH_DEST_VLAN_ID_SFT 20
+	/* Protection domain id. */
+	uint32_t	pd_id;
+	uint32_t	unused_0;
+	/* Destination MAC address. */
+	uint16_t	dest_mac[3];
+	/* Traffic class. */
+	uint8_t	traffic_class;
+	uint8_t	enable_cc;
+	/* Enable congestion control. */
+	#define CMDQ_CREATE_AH_ENABLE_CC	UINT32_C(0x1)
+} cmdq_create_ah_t, *pcmdq_create_ah_t;
 
-/* hwrm_tunnel_dst_port_query_output (size:128b/16B) */
+/* creq_create_ah_resp (size:128b/16B) */
 
-typedef struct hwrm_tunnel_dst_port_query_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/*
-	 * This field represents the identifier of L4 destination port
-	 * used for the given tunnel type. This field is valid for
-	 * specific tunnel types that use layer 4 (e.g. UDP)
-	 * transports for tunneling.
-	 */
-	uint16_t	tunnel_dst_port_id;
+typedef struct creq_create_ah_resp {
+	uint8_t	type;
 	/*
-	 * This field represents the value of L4 destination port
-	 * identified by tunnel_dst_port_id. This field is valid for
-	 * specific tunnel types that use layer 4 (e.g. UDP)
-	 * transports for tunneling.
-	 * This field is in network byte order.
-	 *
-	 * A value of 0 means that the destination port is not
-	 * configured.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint16_t	tunnel_dst_port_val;
-	uint8_t	unused_0[3];
+	#define CREQ_CREATE_AH_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_CREATE_AH_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_CREATE_AH_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_CREATE_AH_RESP_TYPE_LAST	CREQ_CREATE_AH_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* AH context id */
+	uint32_t	xid;
+	uint8_t	v;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint8_t	valid;
-} hwrm_tunnel_dst_port_query_output_t, *phwrm_tunnel_dst_port_query_output_t;
+	#define CREQ_CREATE_AH_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Create AH command response. */
+	#define CREQ_CREATE_AH_RESP_EVENT_CREATE_AH UINT32_C(0x15)
+	#define CREQ_CREATE_AH_RESP_EVENT_LAST	CREQ_CREATE_AH_RESP_EVENT_CREATE_AH
+	uint8_t	reserved48[6];
+} creq_create_ah_resp_t, *pcreq_create_ah_resp_t;
 
-/******************************
- * hwrm_tunnel_dst_port_alloc *
- ******************************/
+/**************
+ * destroy_ah *
+ **************/
 
 
-/* hwrm_tunnel_dst_port_alloc_input (size:192b/24B) */
+/* cmdq_destroy_ah (size:192b/24B) */
 
-typedef struct hwrm_tunnel_dst_port_alloc_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
-	 */
-	uint16_t	cmpl_ring;
-	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
-	 */
-	uint16_t	seq_id;
-	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
-	 */
-	uint16_t	target_id;
-	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
-	 */
+typedef struct cmdq_destroy_ah {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Destroy AH command deletes the specified AH. */
+	#define CMDQ_DESTROY_AH_OPCODE_DESTROY_AH UINT32_C(0x16)
+	#define CMDQ_DESTROY_AH_OPCODE_LAST	CMDQ_DESTROY_AH_OPCODE_DESTROY_AH
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
 	uint64_t	resp_addr;
-	/* Tunnel Type. */
-	uint8_t	tunnel_type;
-	/* Virtual eXtensible Local Area Network (VXLAN) */
-	#define HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_VXLAN	UINT32_C(0x1)
-	/* Generic Network Virtualization Encapsulation (Geneve) */
-	#define HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_GENEVE	UINT32_C(0x5)
-	/* IPV4 over virtual eXtensible Local Area Network (IPV4oVXLAN) */
-	#define HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_V4	UINT32_C(0x9)
-	/* Enhance Generic Routing Encapsulation (GRE version 1) inside IP datagram payload */
-	#define HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_IPGRE_V1	UINT32_C(0xa)
-	/* Use fixed layer 2 ether type of 0xFFFF */
-	#define HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_L2_ETYPE	UINT32_C(0xb)
-	/* IPV6 over virtual eXtensible Local Area Network with GPE header (IPV6oVXLANGPE) */
-	#define HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_GPE_V6 UINT32_C(0xc)
-	#define HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_LAST	HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_VXLAN_GPE_V6
-	uint8_t	unused_0;
-	/*
-	 * This field represents the value of L4 destination port used
-	 * for the given tunnel type. This field is valid for
-	 * specific tunnel types that use layer 4 (e.g. UDP)
-	 * transports for tunneling.
-	 *
-	 * This field is in network byte order.
-	 *
-	 * A value of 0 shall fail the command.
-	 */
-	uint16_t	tunnel_dst_port_val;
-	uint8_t	unused_1[4];
-} hwrm_tunnel_dst_port_alloc_input_t, *phwrm_tunnel_dst_port_alloc_input_t;
+	/* AH context id */
+	uint32_t	ah_cid;
+	uint32_t	unused_0;
+} cmdq_destroy_ah_t, *pcmdq_destroy_ah_t;
 
-/* hwrm_tunnel_dst_port_alloc_output (size:128b/16B) */
+/* creq_destroy_ah_resp (size:128b/16B) */
 
-typedef struct hwrm_tunnel_dst_port_alloc_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
+typedef struct creq_destroy_ah_resp {
+	uint8_t	type;
 	/*
-	 * Identifier of a tunnel L4 destination port value. Only applies to tunnel
-	 * types that has l4 destination port parameters.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint16_t	tunnel_dst_port_id;
-	uint8_t	unused_0[5];
+	#define CREQ_DESTROY_AH_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_DESTROY_AH_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_DESTROY_AH_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_DESTROY_AH_RESP_TYPE_LAST	CREQ_DESTROY_AH_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* AH context id */
+	uint32_t	xid;
+	uint8_t	v;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint8_t	valid;
-} hwrm_tunnel_dst_port_alloc_output_t, *phwrm_tunnel_dst_port_alloc_output_t;
+	#define CREQ_DESTROY_AH_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Destroy AH command response. */
+	#define CREQ_DESTROY_AH_RESP_EVENT_DESTROY_AH UINT32_C(0x16)
+	#define CREQ_DESTROY_AH_RESP_EVENT_LAST	CREQ_DESTROY_AH_RESP_EVENT_DESTROY_AH
+	uint8_t	reserved48[6];
+} creq_destroy_ah_resp_t, *pcreq_destroy_ah_resp_t;
 
-/*****************************
- * hwrm_tunnel_dst_port_free *
- *****************************/
+/********************
+ * query_roce_stats *
+ ********************/
 
 
-/* hwrm_tunnel_dst_port_free_input (size:192b/24B) */
+/* cmdq_query_roce_stats (size:192b/24B) */
 
-typedef struct hwrm_tunnel_dst_port_free_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
-	 */
-	uint16_t	cmpl_ring;
-	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
-	 */
-	uint16_t	seq_id;
+typedef struct cmdq_query_roce_stats {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Query RoCE statistics. */
+	#define CMDQ_QUERY_ROCE_STATS_OPCODE_QUERY_ROCE_STATS UINT32_C(0x8e)
+	#define CMDQ_QUERY_ROCE_STATS_OPCODE_LAST		CMDQ_QUERY_ROCE_STATS_OPCODE_QUERY_ROCE_STATS
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * When this bit is set FW will use the collection_id to extract
+	 * RoCE statistics. If function_id is also specified the FW will
+	 * return stats corresponding to the collection for the function_id
+	 * specified.
 	 */
-	uint16_t	target_id;
+	#define CMDQ_QUERY_ROCE_STATS_FLAGS_COLLECTION_ID	UINT32_C(0x1)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * When this bit is set FW will use the function_id to extract RoCE
+	 * statistics. When collection is specified then FW will return the
+	 * specific collection stats and if the collection is not specified
+	 * then FW will return the default stats which will be for all QPs.
 	 */
+	#define CMDQ_QUERY_ROCE_STATS_FLAGS_FUNCTION_ID	UINT32_C(0x2)
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	/* The specific statistics group being queried. */
+	uint8_t	collection_id;
+	/* Host address of the response. */
 	uint64_t	resp_addr;
-	/* Tunnel Type. */
-	uint8_t	tunnel_type;
-	/* Virtual eXtensible Local Area Network (VXLAN) */
-	#define HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_VXLAN	UINT32_C(0x1)
-	/* Generic Network Virtualization Encapsulation (Geneve) */
-	#define HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_GENEVE	UINT32_C(0x5)
-	/* IPV4 over virtual eXtensible Local Area Network (IPV4oVXLAN) */
-	#define HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_VXLAN_V4	UINT32_C(0x9)
-	/* Enhance Generic Routing Encapsulation (GRE version 1) inside IP datagram payload */
-	#define HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_IPGRE_V1	UINT32_C(0xa)
-	/* Use fixed layer 2 ether type of 0xFFFF */
-	#define HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_L2_ETYPE	UINT32_C(0xb)
-	/* IPV6 over virtual eXtensible Local Area Network with GPE header (IPV6oVXLANGPE) */
-	#define HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_VXLAN_GPE_V6 UINT32_C(0xc)
-	#define HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_LAST	HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_VXLAN_GPE_V6
-	uint8_t	unused_0;
-	/*
-	 * Identifier of a tunnel L4 destination port value. Only applies to tunnel
-	 * types that has l4 destination port parameters.
-	 */
-	uint16_t	tunnel_dst_port_id;
-	uint8_t	unused_1[4];
-} hwrm_tunnel_dst_port_free_input_t, *phwrm_tunnel_dst_port_free_input_t;
+	/* Unique identifier for a function */
+	uint32_t	function_id;
+	/* PF number */
+	#define CMDQ_QUERY_ROCE_STATS_PF_NUM_MASK  UINT32_C(0xff)
+	#define CMDQ_QUERY_ROCE_STATS_PF_NUM_SFT   0
+	/* VF number */
+	#define CMDQ_QUERY_ROCE_STATS_VF_NUM_MASK  UINT32_C(0xffff00)
+	#define CMDQ_QUERY_ROCE_STATS_VF_NUM_SFT   8
+	/* When set the vf_num is valid. */
+	#define CMDQ_QUERY_ROCE_STATS_VF_VALID	UINT32_C(0x1000000)
+	uint32_t	reserved32;
+} cmdq_query_roce_stats_t, *pcmdq_query_roce_stats_t;
 
-/* hwrm_tunnel_dst_port_free_output (size:128b/16B) */
+/* creq_query_roce_stats_resp (size:128b/16B) */
 
-typedef struct hwrm_tunnel_dst_port_free_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	unused_1[7];
+typedef struct creq_query_roce_stats_resp {
+	uint8_t	type;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint8_t	valid;
-} hwrm_tunnel_dst_port_free_output_t, *phwrm_tunnel_dst_port_free_output_t;
+	#define CREQ_QUERY_ROCE_STATS_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_QUERY_ROCE_STATS_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_QUERY_ROCE_STATS_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_QUERY_ROCE_STATS_RESP_TYPE_LAST	CREQ_QUERY_ROCE_STATS_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Side buffer size in 16-byte units */
+	uint32_t	size;
+	uint8_t	v;
+	/*
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
+	 */
+	#define CREQ_QUERY_ROCE_STATS_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Query RoCE statistics. */
+	#define CREQ_QUERY_ROCE_STATS_RESP_EVENT_QUERY_ROCE_STATS UINT32_C(0x8e)
+	#define CREQ_QUERY_ROCE_STATS_RESP_EVENT_LAST		CREQ_QUERY_ROCE_STATS_RESP_EVENT_QUERY_ROCE_STATS
+	uint8_t	reserved48[6];
+} creq_query_roce_stats_resp_t, *pcreq_query_roce_stats_resp_t;
 
-/* Periodic statistics context DMA to host. */
-/* ctx_hw_stats (size:1280b/160B) */
+/* Query RoCE Stats command response side buffer structure. */
+/* creq_query_roce_stats_resp_sb (size:3072b/384B) */
 
-typedef struct ctx_hw_stats {
-	/* Number of received unicast packets */
-	uint64_t	rx_ucast_pkts;
-	/* Number of received multicast packets */
-	uint64_t	rx_mcast_pkts;
-	/* Number of received broadcast packets */
-	uint64_t	rx_bcast_pkts;
-	/* Number of discarded packets on receive path */
-	uint64_t	rx_discard_pkts;
-	/* Number of packets on receive path with error */
-	uint64_t	rx_error_pkts;
-	/* Number of received bytes for unicast traffic */
-	uint64_t	rx_ucast_bytes;
-	/* Number of received bytes for multicast traffic */
-	uint64_t	rx_mcast_bytes;
-	/* Number of received bytes for broadcast traffic */
-	uint64_t	rx_bcast_bytes;
-	/* Number of transmitted unicast packets */
-	uint64_t	tx_ucast_pkts;
-	/* Number of transmitted multicast packets */
-	uint64_t	tx_mcast_pkts;
-	/* Number of transmitted broadcast packets */
-	uint64_t	tx_bcast_pkts;
-	/* Number of packets on transmit path with error */
-	uint64_t	tx_error_pkts;
-	/* Number of discarded packets on transmit path */
-	uint64_t	tx_discard_pkts;
-	/* Number of transmitted bytes for unicast traffic */
-	uint64_t	tx_ucast_bytes;
-	/* Number of transmitted bytes for multicast traffic */
-	uint64_t	tx_mcast_bytes;
-	/* Number of transmitted bytes for broadcast traffic */
-	uint64_t	tx_bcast_bytes;
-	/* Number of TPA packets */
-	uint64_t	tpa_pkts;
-	/* Number of TPA bytes */
-	uint64_t	tpa_bytes;
-	/* Number of TPA events */
-	uint64_t	tpa_events;
-	/* Number of TPA aborts */
-	uint64_t	tpa_aborts;
-} ctx_hw_stats_t, *pctx_hw_stats_t;
+typedef struct creq_query_roce_stats_resp_sb {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Query RoCE statistics. */
+	#define CREQ_QUERY_ROCE_STATS_RESP_SB_OPCODE_QUERY_ROCE_STATS UINT32_C(0x8e)
+	#define CREQ_QUERY_ROCE_STATS_RESP_SB_OPCODE_LAST		CREQ_QUERY_ROCE_STATS_RESP_SB_OPCODE_QUERY_ROCE_STATS
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	rsvd;
+	uint32_t	num_counters;
+	uint32_t	rsvd1;
+	uint64_t	to_retransmits;
+	/* seq_err_naks_rcvd is 64 b */
+	uint64_t	seq_err_naks_rcvd;
+	/* max_retry_exceeded is 64 b */
+	uint64_t	max_retry_exceeded;
+	/* rnr_naks_rcvd is 64 b */
+	uint64_t	rnr_naks_rcvd;
+	uint64_t	missing_resp;
+	/* unrecoverable_err is 64 b */
+	uint64_t	unrecoverable_err;
+	/* bad_resp_err is 64 b */
+	uint64_t	bad_resp_err;
+	/* local_qp_op_err is 64 b */
+	uint64_t	local_qp_op_err;
+	/* local_protection_err is 64 b */
+	uint64_t	local_protection_err;
+	/* mem_mgmt_op_err is 64 b */
+	uint64_t	mem_mgmt_op_err;
+	/* remote_invalid_req_err is 64 b */
+	uint64_t	remote_invalid_req_err;
+	/* remote_access_err is 64 b */
+	uint64_t	remote_access_err;
+	/* remote_op_err is 64 b */
+	uint64_t	remote_op_err;
+	/* dup_req is 64 b */
+	uint64_t	dup_req;
+	/* res_exceed_max is 64 b */
+	uint64_t	res_exceed_max;
+	/* res_length_mismatch is 64 b */
+	uint64_t	res_length_mismatch;
+	/* res_exceeds_wqe is 64 b */
+	uint64_t	res_exceeds_wqe;
+	/* res_opcode_err is 64 b */
+	uint64_t	res_opcode_err;
+	/* res_rx_invalid_rkey is 64 b */
+	uint64_t	res_rx_invalid_rkey;
+	/* res_rx_domain_err is 64 b */
+	uint64_t	res_rx_domain_err;
+	/* res_rx_no_perm is 64 b */
+	uint64_t	res_rx_no_perm;
+	/* res_rx_range_err is 64 b */
+	uint64_t	res_rx_range_err;
+	/* res_tx_invalid_rkey is 64 b */
+	uint64_t	res_tx_invalid_rkey;
+	/* res_tx_domain_err is 64 b */
+	uint64_t	res_tx_domain_err;
+	/* res_tx_no_perm is 64 b */
+	uint64_t	res_tx_no_perm;
+	/* res_tx_range_err is 64 b */
+	uint64_t	res_tx_range_err;
+	/* res_irrq_oflow is 64 b */
+	uint64_t	res_irrq_oflow;
+	/* res_unsup_opcode is 64 b */
+	uint64_t	res_unsup_opcode;
+	/* res_unaligned_atomic is 64 b */
+	uint64_t	res_unaligned_atomic;
+	/* res_rem_inv_err is 64 b */
+	uint64_t	res_rem_inv_err;
+	/* res_mem_error is 64 b */
+	uint64_t	res_mem_error;
+	/* res_srq_err is 64 b */
+	uint64_t	res_srq_err;
+	/* res_cmp_err is 64 b */
+	uint64_t	res_cmp_err;
+	/* res_invalid_dup_rkey is 64 b */
+	uint64_t	res_invalid_dup_rkey;
+	/* res_wqe_format_err is 64 b */
+	uint64_t	res_wqe_format_err;
+	/* res_cq_load_err is 64 b */
+	uint64_t	res_cq_load_err;
+	/* res_srq_load_err is 64 b */
+	uint64_t	res_srq_load_err;
+	/* res_tx_pci_err is 64 b */
+	uint64_t	res_tx_pci_err;
+	/* res_rx_pci_err is 64 b */
+	uint64_t	res_rx_pci_err;
+	/* res_oos_drop_count is 64 b */
+	uint64_t	res_oos_drop_count;
+	/* active_qp_count_p0 is 64 b */
+	uint64_t	active_qp_count_p0;
+	/* active_qp_count_p1 is 64 b */
+	uint64_t	active_qp_count_p1;
+	/* active_qp_count_p2 is 64 b */
+	uint64_t	active_qp_count_p2;
+	/* active_qp_count_p3 is 64 b */
+	uint64_t	active_qp_count_p3;
+	/* express mode SQ doorbell overflow error 64b counter. */
+	uint64_t	xp_sq_overflow_err;
+	/* express mode RQ doorbell overflow error 64b counter. */
+	uint64_t	xp_rq_overflow_error;
+} creq_query_roce_stats_resp_sb_t, *pcreq_query_roce_stats_resp_sb_t;
 
-/*
- * Extended periodic statistics context DMA to host. On cards that
- * support TPA v2, additional TPA related stats exist and can be retrieved
- * by DMA of ctx_hw_stats_ext, rather than legacy ctx_hw_stats structure.
- */
-/* ctx_hw_stats_ext (size:1408b/176B) */
+/************************
+ * query_roce_stats_ext *
+ ************************/
 
-typedef struct ctx_hw_stats_ext {
-	/* Number of received unicast packets */
-	uint64_t	rx_ucast_pkts;
-	/* Number of received multicast packets */
-	uint64_t	rx_mcast_pkts;
-	/* Number of received broadcast packets */
-	uint64_t	rx_bcast_pkts;
-	/* Number of discarded packets on receive path */
-	uint64_t	rx_discard_pkts;
-	/* Number of packets on receive path with error */
-	uint64_t	rx_error_pkts;
-	/* Number of received bytes for unicast traffic */
-	uint64_t	rx_ucast_bytes;
-	/* Number of received bytes for multicast traffic */
-	uint64_t	rx_mcast_bytes;
-	/* Number of received bytes for broadcast traffic */
-	uint64_t	rx_bcast_bytes;
-	/* Number of transmitted unicast packets */
-	uint64_t	tx_ucast_pkts;
-	/* Number of transmitted multicast packets */
-	uint64_t	tx_mcast_pkts;
-	/* Number of transmitted broadcast packets */
-	uint64_t	tx_bcast_pkts;
-	/* Number of packets on transmit path with error */
-	uint64_t	tx_error_pkts;
-	/* Number of discarded packets on transmit path */
-	uint64_t	tx_discard_pkts;
-	/* Number of transmitted bytes for unicast traffic */
-	uint64_t	tx_ucast_bytes;
-	/* Number of transmitted bytes for multicast traffic */
-	uint64_t	tx_mcast_bytes;
-	/* Number of transmitted bytes for broadcast traffic */
-	uint64_t	tx_bcast_bytes;
-	/* Number of TPA eligible packets */
-	uint64_t	rx_tpa_eligible_pkt;
-	/* Number of TPA eligible bytes */
-	uint64_t	rx_tpa_eligible_bytes;
-	/* Number of TPA packets */
-	uint64_t	rx_tpa_pkt;
-	/* Number of TPA bytes */
-	uint64_t	rx_tpa_bytes;
-	/* Number of TPA errors */
-	uint64_t	rx_tpa_errors;
-	/* Number of TPA events */
-	uint64_t	rx_tpa_events;
-} ctx_hw_stats_ext_t, *pctx_hw_stats_ext_t;
 
-/* Periodic Engine statistics context DMA to host. */
-/* ctx_eng_stats (size:512b/64B) */
+/* cmdq_query_roce_stats_ext (size:192b/24B) */
 
-typedef struct ctx_eng_stats {
-	/*
-	 * Count of data bytes into the Engine.
-	 * This includes any user supplied prefix,
-	 * but does not include any predefined
-	 * prefix data.
-	 */
-	uint64_t	eng_bytes_in;
-	/* Count of data bytes out of the Engine. */
-	uint64_t	eng_bytes_out;
-	/*
-	 * Count, in 4-byte (dword) units, of bytes
-	 * that are input as auxiliary data.
-	 * This includes the aux_cmd data.
-	 */
-	uint64_t	aux_bytes_in;
+typedef struct cmdq_query_roce_stats_ext {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Query extended RoCE statistics. */
+	#define CMDQ_QUERY_ROCE_STATS_EXT_OPCODE_QUERY_ROCE_STATS UINT32_C(0x92)
+	#define CMDQ_QUERY_ROCE_STATS_EXT_OPCODE_LAST		CMDQ_QUERY_ROCE_STATS_EXT_OPCODE_QUERY_ROCE_STATS
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
 	/*
-	 * Count, in 4-byte (dword) units, of bytes
-	 * that are output as auxiliary data.
-	 * This count is the buffer space for aux_data
-	 * output provided in the RQE, not the actual
-	 * aux_data written
+	 * When this bit is set FW will use the collection_id to extract
+	 * RoCE statistics. If function_id is also specified the FW will
+	 * return stats corresponding to the collection for the function_id
+	 * specified.
 	 */
-	uint64_t	aux_bytes_out;
-	/* Count of number of commands executed. */
-	uint64_t	commands;
+	#define CMDQ_QUERY_ROCE_STATS_EXT_FLAGS_COLLECTION_ID	UINT32_C(0x1)
 	/*
-	 * Count of number of error commands.
-	 * These are the commands with a
-	 * non-zero status value.
+	 * When this bit is set FW will use the function_id to extract RoCE
+	 * statistics. When collection is specified then FW will return the
+	 * specific collection stats and if the collection is not specified
+	 * then FW will return the default stats which will be for all QPs.
 	 */
-	uint64_t	error_commands;
+	#define CMDQ_QUERY_ROCE_STATS_EXT_FLAGS_FUNCTION_ID	UINT32_C(0x2)
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	/* The specific statistics group being queried. */
+	uint8_t	collection_id;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+	/* Unique identifier for a function */
+	uint32_t	function_id;
+	/* PF number */
+	#define CMDQ_QUERY_ROCE_STATS_EXT_PF_NUM_MASK  UINT32_C(0xff)
+	#define CMDQ_QUERY_ROCE_STATS_EXT_PF_NUM_SFT   0
+	/* VF number */
+	#define CMDQ_QUERY_ROCE_STATS_EXT_VF_NUM_MASK  UINT32_C(0xffff00)
+	#define CMDQ_QUERY_ROCE_STATS_EXT_VF_NUM_SFT   8
+	/* When set the vf_num is valid. */
+	#define CMDQ_QUERY_ROCE_STATS_EXT_VF_VALID	UINT32_C(0x1000000)
+	uint32_t	reserved32;
+} cmdq_query_roce_stats_ext_t, *pcmdq_query_roce_stats_ext_t;
+
+/* creq_query_roce_stats_ext_resp (size:128b/16B) */
+
+typedef struct creq_query_roce_stats_ext_resp {
+	uint8_t	type;
 	/*
-	 * Compression/Encryption Engine usage,
-	 * the unit is count of clock cycles
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint64_t	cce_engine_usage;
+	#define CREQ_QUERY_ROCE_STATS_EXT_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_QUERY_ROCE_STATS_EXT_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_QUERY_ROCE_STATS_EXT_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_QUERY_ROCE_STATS_EXT_RESP_TYPE_LAST	CREQ_QUERY_ROCE_STATS_EXT_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Side buffer size in 16-byte units */
+	uint32_t	size;
+	uint8_t	v;
 	/*
-	 * De-Compression/De-cryption Engine usage,
-	 * the unit is count of clock cycles
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint64_t	cdd_engine_usage;
-} ctx_eng_stats_t, *pctx_eng_stats_t;
-
-/***********************
- * hwrm_stat_ctx_alloc *
- ***********************/
-
+	#define CREQ_QUERY_ROCE_STATS_EXT_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Query extended RoCE statistics. */
+	#define CREQ_QUERY_ROCE_STATS_EXT_RESP_EVENT_QUERY_ROCE_STATS_EXT UINT32_C(0x92)
+	#define CREQ_QUERY_ROCE_STATS_EXT_RESP_EVENT_LAST		CREQ_QUERY_ROCE_STATS_EXT_RESP_EVENT_QUERY_ROCE_STATS_EXT
+	uint8_t	reserved48[6];
+} creq_query_roce_stats_ext_resp_t, *pcreq_query_roce_stats_ext_resp_t;
 
-/* hwrm_stat_ctx_alloc_input (size:256b/32B) */
+/* Query extended RoCE Stats command response side buffer structure. */
+/* creq_query_roce_stats_ext_resp_sb (size:2304b/288B) */
 
-typedef struct hwrm_stat_ctx_alloc_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+typedef struct creq_query_roce_stats_ext_resp_sb {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Query extended RoCE statistics. */
+	#define CREQ_QUERY_ROCE_STATS_EXT_RESP_SB_OPCODE_QUERY_ROCE_STATS_EXT UINT32_C(0x92)
+	#define CREQ_QUERY_ROCE_STATS_EXT_RESP_SB_OPCODE_LAST		CREQ_QUERY_ROCE_STATS_EXT_RESP_SB_OPCODE_QUERY_ROCE_STATS_EXT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	rsvd;
+	/* Number of transmitted Atomic request packets. */
+	uint64_t	tx_atomic_req_pkts;
+	/* Number of transmitted Read request packets. */
+	uint64_t	tx_read_req_pkts;
+	/* Number of transmitted Read response packets. */
+	uint64_t	tx_read_res_pkts;
+	/* Number of transmitted Write request packets. */
+	uint64_t	tx_write_req_pkts;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * Number of transmitted Send request packets.
+	 * This is for RC QPs only.
 	 */
-	uint16_t	cmpl_ring;
+	uint64_t	tx_send_req_pkts;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Number of transmitted RoCE packets.
+	 * This includes RC, UD, RawEth, and QP1 packets
 	 */
-	uint16_t	seq_id;
+	uint64_t	tx_roce_pkts;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Number of transmitted RoCE header and payload bytes.
+	 * This includes RC, UD, RawEth, and QP1 packets.
 	 */
-	uint16_t	target_id;
+	uint64_t	tx_roce_bytes;
+	/* Number of received Atomic request packets. */
+	uint64_t	rx_atomic_req_pkts;
+	/* Number of received Read request packets. */
+	uint64_t	rx_read_req_pkts;
+	/* Number of received Read response packets. */
+	uint64_t	rx_read_res_pkts;
+	/* Number of received Write request packets. */
+	uint64_t	rx_write_req_pkts;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Number of received Send request packets.
+	 * This is for RC QPs only.
 	 */
-	uint64_t	resp_addr;
+	uint64_t	rx_send_req_pkts;
 	/*
-	 * This is the address for statistic block.
-	 * > For new versions of the chip, this address should be 128B
-	 * > aligned.
+	 * Number of received RoCE packets including RoCE packets with errors.
+	 * This includes RC, UD, RawEth, and QP1 packets
 	 */
-	uint64_t	stats_dma_addr;
+	uint64_t	rx_roce_pkts;
 	/*
-	 * The statistic block update period in ms.
-	 * e.g. 250ms, 500ms, 750ms, 1000ms.
-	 * If update_period_ms is 0, then the stats update
-	 * shall be never done and the DMA address shall not be used.
-	 * In this case, the stat block can only be read by
-	 * hwrm_stat_ctx_query command.
-	 * On Ethernet/L2 based devices:
-	 *   if tpa v2 supported (hwrm_vnic_qcaps[max_aggs_supported]>0),
-	 *	ctx_hw_stats_ext is used for DMA,
-	 *   else
-	 *	ctx_hw_stats is used for DMA.
+	 * Number of received RoCE header and payload bytes including RoCE
+	 * packets with errors.
+	 * This includes RC, UD, RawEth, and QP1 packets.
 	 */
-	uint32_t	update_period_ms;
+	uint64_t	rx_roce_bytes;
 	/*
-	 * This field is used to specify statistics context specific
-	 * configuration flags.
+	 * Number of received RoCE packets.
+	 * This includes RC, UD, RawEth, and QP1 packets
 	 */
-	uint8_t	stat_ctx_flags;
+	uint64_t	rx_roce_good_pkts;
 	/*
-	 * When this bit is set to '1', the statistics context shall be
-	 * allocated for RoCE traffic only. In this case, traffic other
-	 * than offloaded RoCE traffic shall not be included in this
-	 * statistic context.
-	 * When this bit is set to '0', the statistics context shall be
-	 * used for network traffic or engine traffic.
+	 * Number of received RoCE header and payload bytes.
+	 * This includes RC, UD, RawEth, and QP1 packets.
 	 */
-	#define HWRM_STAT_CTX_ALLOC_INPUT_STAT_CTX_FLAGS_ROCE	UINT32_C(0x1)
-	uint8_t	unused_0;
+	uint64_t	rx_roce_good_bytes;
 	/*
-	 * This is the size of the structure (ctx_hw_stats or
-	 * ctx_hw_stats_ext) that the driver has allocated to be used
-	 * for the periodic DMA updates.
+	 * Number of drops that occurred to lack of buffers.
+	 * This is for RC QPs only.
 	 */
-	uint16_t	stats_dma_length;
-} hwrm_stat_ctx_alloc_input_t, *phwrm_stat_ctx_alloc_input_t;
-
-/* hwrm_stat_ctx_alloc_output (size:128b/16B) */
-
-typedef struct hwrm_stat_ctx_alloc_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* This is the statistics context ID value. */
-	uint32_t	stat_ctx_id;
-	uint8_t	unused_0[3];
+	uint64_t	rx_out_of_buffer_pkts;
+	/* Number of packets that were received out of sequence. */
+	uint64_t	rx_out_of_sequence_pkts;
+	/* Number of transmitted CNP packets. The counter is per port. */
+	uint64_t	tx_cnp_pkts;
+	/* Number of received CNP packets. The counter is per port. */
+	uint64_t	rx_cnp_pkts;
+	/* Number of received ECN-marked RoCE packets. The counter is per port. */
+	uint64_t	rx_ecn_marked_pkts;
+	/* Number of transmitted CNP bytes. */
+	uint64_t	tx_cnp_bytes;
+	/* Number of received CNP bytes. */
+	uint64_t	rx_cnp_bytes;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * Number of sequence error NAKs received.
+	 * This counter is only applicable for devices that support
+	 * hardware based retransmission.
 	 */
-	uint8_t	valid;
-} hwrm_stat_ctx_alloc_output_t, *phwrm_stat_ctx_alloc_output_t;
-
-/**********************
- * hwrm_stat_ctx_free *
- **********************/
-
-
-/* hwrm_stat_ctx_free_input (size:192b/24B) */
-
-typedef struct hwrm_stat_ctx_free_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	uint64_t	seq_err_naks_rcvd;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * Number of RNR NAKs received.
+	 * This counter is only applicable for devices that support
+	 * hardware based retransmission.
 	 */
-	uint16_t	cmpl_ring;
+	uint64_t	rnr_naks_rcvd;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Number of missing response resulting in HW retransmission.
+	 * This counter is only applicable for devices that support
+	 * hardware based retransmission.
 	 */
-	uint16_t	seq_id;
+	uint64_t	missing_resp;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Number of timeouts resulting in HW retransmission.
+	 * This counter is only applicable for devices that support
+	 * hardware based retransmission.
 	 */
-	uint16_t	target_id;
+	uint64_t	to_retransmit;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Number of duplicate read/atomic requests resulting in HW
+	 * retransmission.
+	 * This counter is only applicable for devices that support
+	 * hardware based retransmission.
 	 */
-	uint64_t	resp_addr;
-	/* ID of the statistics context that is being queried. */
-	uint32_t	stat_ctx_id;
-	uint8_t	unused_0[4];
-} hwrm_stat_ctx_free_input_t, *phwrm_stat_ctx_free_input_t;
-
-/* hwrm_stat_ctx_free_output (size:128b/16B) */
-
-typedef struct hwrm_stat_ctx_free_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* This is the statistics context ID value. */
-	uint32_t	stat_ctx_id;
-	uint8_t	unused_0[3];
+	uint64_t	dup_req;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * Number of received DCN payload cut packets.
+	 * This counter is only applicable for devices that support
+	 * the DCN Payload Cut feature.
 	 */
-	uint8_t	valid;
-} hwrm_stat_ctx_free_output_t, *phwrm_stat_ctx_free_output_t;
-
-/***********************
- * hwrm_stat_ctx_query *
- ***********************/
-
-
-/* hwrm_stat_ctx_query_input (size:192b/24B) */
-
-typedef struct hwrm_stat_ctx_query_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	uint64_t	rx_dcn_payload_cut;
+	/* Number of transmitted packets that bypassed the transmit engine. */
+	uint64_t	te_bypassed;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * Number of transmitted DCN CNP packets.
+	 * This counter is only applicable for devices that support
+	 * the DCN Payload Cut feature.
 	 */
-	uint16_t	cmpl_ring;
+	uint64_t	tx_dcn_cnp;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Number of received DCN CNP packets.
+	 * This counter is only applicable for devices that support
+	 * the DCN Payload Cut feature.
 	 */
-	uint16_t	seq_id;
+	uint64_t	rx_dcn_cnp;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Number of received DCN payload cut packets.
+	 * This counter is only applicable for devices that support
+	 * the DCN Payload Cut feature.
 	 */
-	uint16_t	target_id;
+	uint64_t	rx_payload_cut;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Number of received DCN payload cut packets that are ignored
+	 * because they failed the PSN checks.
+	 * This counter is only applicable for devices that support
+	 * the DCN Payload Cut feature.
 	 */
-	uint64_t	resp_addr;
-	/* ID of the statistics context that is being queried. */
-	uint32_t	stat_ctx_id;
-	uint8_t	flags;
+	uint64_t	rx_payload_cut_ignored;
 	/*
-	 * This bit is set to 1 when request is for a counter mask,
-	 * representing the width of each of the stats counters, rather
-	 * than counters themselves.
+	 * Number of received DCN CNP packets that are ignored either
+	 * because the ECN is not enabled on the QP or the ECN is enabled
+	 * but the CNP packets do not pass the packet validation checks.
+	 * This counter is only applicable for devices that support
+	 * the DCN Payload Cut feature.
 	 */
-	#define HWRM_STAT_CTX_QUERY_INPUT_FLAGS_COUNTER_MASK	UINT32_C(0x1)
-	uint8_t	unused_0[3];
-} hwrm_stat_ctx_query_input_t, *phwrm_stat_ctx_query_input_t;
+	uint64_t	rx_dcn_cnp_ignored;
+} creq_query_roce_stats_ext_resp_sb_t, *pcreq_query_roce_stats_ext_resp_sb_t;
 
-/* hwrm_stat_ctx_query_output (size:1408b/176B) */
+/**************
+ * query_func *
+ **************/
 
-typedef struct hwrm_stat_ctx_query_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Number of transmitted unicast packets */
-	uint64_t	tx_ucast_pkts;
-	/* Number of transmitted multicast packets */
-	uint64_t	tx_mcast_pkts;
-	/* Number of transmitted broadcast packets */
-	uint64_t	tx_bcast_pkts;
-	/* Number of packets discarded in transmit path */
-	uint64_t	tx_discard_pkts;
-	/* Number of packets in transmit path with error */
-	uint64_t	tx_error_pkts;
-	/* Number of transmitted bytes for unicast traffic */
-	uint64_t	tx_ucast_bytes;
-	/* Number of transmitted bytes for multicast traffic */
-	uint64_t	tx_mcast_bytes;
-	/* Number of transmitted bytes for broadcast traffic */
-	uint64_t	tx_bcast_bytes;
-	/* Number of received unicast packets */
-	uint64_t	rx_ucast_pkts;
-	/* Number of received multicast packets */
-	uint64_t	rx_mcast_pkts;
-	/* Number of received broadcast packets */
-	uint64_t	rx_bcast_pkts;
-	/* Number of packets discarded in receive path */
-	uint64_t	rx_discard_pkts;
-	/* Number of packets in receive path with errors */
-	uint64_t	rx_error_pkts;
-	/* Number of received bytes for unicast traffic */
-	uint64_t	rx_ucast_bytes;
-	/* Number of received bytes for multicast traffic */
-	uint64_t	rx_mcast_bytes;
-	/* Number of received bytes for broadcast traffic */
-	uint64_t	rx_bcast_bytes;
-	/* Number of aggregated unicast packets */
-	uint64_t	rx_agg_pkts;
-	/* Number of aggregated unicast bytes */
-	uint64_t	rx_agg_bytes;
-	/* Number of aggregation events */
-	uint64_t	rx_agg_events;
-	/* Number of aborted aggregations */
-	uint64_t	rx_agg_aborts;
-	uint8_t	unused_0[7];
-	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
-	 */
-	uint8_t	valid;
-} hwrm_stat_ctx_query_output_t, *phwrm_stat_ctx_query_output_t;
 
-/***************************
- * hwrm_stat_ext_ctx_query *
- ***************************/
+/* cmdq_query_func (size:128b/16B) */
 
+typedef struct cmdq_query_func {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Query the HW capabilities for the function. */
+	#define CMDQ_QUERY_FUNC_OPCODE_QUERY_FUNC UINT32_C(0x83)
+	#define CMDQ_QUERY_FUNC_OPCODE_LAST	CMDQ_QUERY_FUNC_OPCODE_QUERY_FUNC
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+} cmdq_query_func_t, *pcmdq_query_func_t;
 
-/* hwrm_stat_ext_ctx_query_input (size:192b/24B) */
+/* creq_query_func_resp (size:128b/16B) */
 
-typedef struct hwrm_stat_ext_ctx_query_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
-	 */
-	uint16_t	cmpl_ring;
-	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
-	 */
-	uint16_t	seq_id;
-	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
-	 */
-	uint16_t	target_id;
-	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
-	 */
-	uint64_t	resp_addr;
-	/* ID of the extended statistics context that is being queried. */
-	uint32_t	stat_ctx_id;
-	uint8_t	flags;
+typedef struct creq_query_func_resp {
+	uint8_t	type;
 	/*
-	 * This bit is set to 1 when request is for a counter mask,
-	 * representing the width of each of the stats counters, rather
-	 * than counters themselves.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	#define HWRM_STAT_EXT_CTX_QUERY_INPUT_FLAGS_COUNTER_MASK	UINT32_C(0x1)
-	uint8_t	unused_0[3];
-} hwrm_stat_ext_ctx_query_input_t, *phwrm_stat_ext_ctx_query_input_t;
-
-/* hwrm_stat_ext_ctx_query_output (size:1536b/192B) */
-
-typedef struct hwrm_stat_ext_ctx_query_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Number of received unicast packets */
-	uint64_t	rx_ucast_pkts;
-	/* Number of received multicast packets */
-	uint64_t	rx_mcast_pkts;
-	/* Number of received broadcast packets */
-	uint64_t	rx_bcast_pkts;
-	/* Number of discarded packets on receive path */
-	uint64_t	rx_discard_pkts;
-	/* Number of packets on receive path with error */
-	uint64_t	rx_error_pkts;
-	/* Number of received bytes for unicast traffic */
-	uint64_t	rx_ucast_bytes;
-	/* Number of received bytes for multicast traffic */
-	uint64_t	rx_mcast_bytes;
-	/* Number of received bytes for broadcast traffic */
-	uint64_t	rx_bcast_bytes;
-	/* Number of transmitted unicast packets */
-	uint64_t	tx_ucast_pkts;
-	/* Number of transmitted multicast packets */
-	uint64_t	tx_mcast_pkts;
-	/* Number of transmitted broadcast packets */
-	uint64_t	tx_bcast_pkts;
-	/* Number of packets on transmit path with error */
-	uint64_t	tx_error_pkts;
-	/* Number of discarded packets on transmit path */
-	uint64_t	tx_discard_pkts;
-	/* Number of transmitted bytes for unicast traffic */
-	uint64_t	tx_ucast_bytes;
-	/* Number of transmitted bytes for multicast traffic */
-	uint64_t	tx_mcast_bytes;
-	/* Number of transmitted bytes for broadcast traffic */
-	uint64_t	tx_bcast_bytes;
-	/* Number of TPA eligible packets */
-	uint64_t	rx_tpa_eligible_pkt;
-	/* Number of TPA eligible bytes */
-	uint64_t	rx_tpa_eligible_bytes;
-	/* Number of TPA packets */
-	uint64_t	rx_tpa_pkt;
-	/* Number of TPA bytes */
-	uint64_t	rx_tpa_bytes;
-	/* Number of TPA errors */
-	uint64_t	rx_tpa_errors;
-	/* Number of TPA events */
-	uint64_t	rx_tpa_events;
-	uint8_t	unused_0[7];
+	#define CREQ_QUERY_FUNC_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_QUERY_FUNC_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_QUERY_FUNC_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_QUERY_FUNC_RESP_TYPE_LAST	CREQ_QUERY_FUNC_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Side buffer size in 16-byte units */
+	uint32_t	size;
+	uint8_t	v;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint8_t	valid;
-} hwrm_stat_ext_ctx_query_output_t, *phwrm_stat_ext_ctx_query_output_t;
-
-/***************************
- * hwrm_stat_ctx_eng_query *
- ***************************/
-
+	#define CREQ_QUERY_FUNC_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Query info PF command response. */
+	#define CREQ_QUERY_FUNC_RESP_EVENT_QUERY_FUNC UINT32_C(0x83)
+	#define CREQ_QUERY_FUNC_RESP_EVENT_LAST	CREQ_QUERY_FUNC_RESP_EVENT_QUERY_FUNC
+	uint8_t	reserved48[6];
+} creq_query_func_resp_t, *pcreq_query_func_resp_t;
 
-/* hwrm_stat_ctx_eng_query_input (size:192b/24B) */
+/* Query function command response side buffer structure. */
+/* creq_query_func_resp_sb (size:1280b/160B) */
 
-typedef struct hwrm_stat_ctx_eng_query_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+typedef struct creq_query_func_resp_sb {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Query info PF command response. */
+	#define CREQ_QUERY_FUNC_RESP_SB_OPCODE_QUERY_FUNC UINT32_C(0x83)
+	#define CREQ_QUERY_FUNC_RESP_SB_OPCODE_LAST	CREQ_QUERY_FUNC_RESP_SB_OPCODE_QUERY_FUNC
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Max MR size supported. */
+	uint64_t	max_mr_size;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * Max QP supported.
+	 * For devices that support the pseudo static allocation scheme,
+	 * this count:
+	 * -excludes the QP1 count.
+	 * -includes the count of QPs that can be migrated from the other PF
+	 *  Therefore, during normal operation when both PFs are active,
+	 *  the supported number of RoCE QPs for each of the PF is half
+	 *  of the advertised value.
 	 */
-	uint16_t	cmpl_ring;
+	uint32_t	max_qp;
+	/* Max WQEs per QP. */
+	uint16_t	max_qp_wr;
+	/* Device capability flags. */
+	uint16_t	dev_cap_flags;
+	/* Allow QP resizing. */
+	#define CREQ_QUERY_FUNC_RESP_SB_RESIZE_QP				UINT32_C(0x1)
+	/* Specifies Congestion Control (CC) generation. */
+	#define CREQ_QUERY_FUNC_RESP_SB_CC_GENERATION_MASK		UINT32_C(0xe)
+	#define CREQ_QUERY_FUNC_RESP_SB_CC_GENERATION_SFT			1
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Includes support for DCTCP and TCP CC algorithms,
+	 * enabling operation in networks where PFC is enabled.
 	 */
-	uint16_t	seq_id;
+		#define CREQ_QUERY_FUNC_RESP_SB_CC_GENERATION_CC_GEN0		(UINT32_C(0x0) << 1)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Enhances cc_gen0 support with probabilistic marking algorithm,
+	 * enabling fast ramp up and convergence,
+	 * as well as operation in networks where PFC is not enabled.
+	 * Includes a number of parameters that are different from cc_gen0
+	 * chips as well as new parameters. TCP CC algorithm is not
+	 * supported.
 	 */
-	uint16_t	target_id;
+		#define CREQ_QUERY_FUNC_RESP_SB_CC_GENERATION_CC_GEN1		(UINT32_C(0x1) << 1)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Enhances cc_gen1 support for additional CC parameters:
+	 * reduce_init_en, reduce_init_cong_free_rtts_th, random_no_red_en,
+	 * actual_cr_shift_correction_en, quota_period_adjust_en
 	 */
-	uint64_t	resp_addr;
-	/* ID of the statistics context that is being queried. */
-	uint32_t	stat_ctx_id;
-	uint8_t	unused_0[4];
-} hwrm_stat_ctx_eng_query_input_t, *phwrm_stat_ctx_eng_query_input_t;
-
-/* hwrm_stat_ctx_eng_query_output (size:640b/80B) */
-
-typedef struct hwrm_stat_ctx_eng_query_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
+		#define CREQ_QUERY_FUNC_RESP_SB_CC_GENERATION_CC_GEN1_EXT		(UINT32_C(0x2) << 1)
 	/*
-	 * Count of data bytes into the Engine.
-	 * This includes any user supplied prefix,
-	 * but does not include any predefined
-	 * prefix data.
+	 * Enhances cc_gen1_ext support, to include support for DCN/SARA.
+	 * Enables query and modification of Queue level table attributes,
+	 * which are used by the hardware to determine the QP's flow rate
+	 * based on congestion level and thereby reduce RoCE packet drop
+	 * due to network congestion.
 	 */
-	uint64_t	eng_bytes_in;
-	/* Count of data bytes out of the Engine. */
-	uint64_t	eng_bytes_out;
+		#define CREQ_QUERY_FUNC_RESP_SB_CC_GENERATION_CC_GEN2		(UINT32_C(0x3) << 1)
+		#define CREQ_QUERY_FUNC_RESP_SB_CC_GENERATION_LAST			CREQ_QUERY_FUNC_RESP_SB_CC_GENERATION_CC_GEN2
 	/*
-	 * Count, in 4-byte (dword) units, of bytes
-	 * that are input as auxiliary data.
-	 * This includes the aux_cmd data.
+	 * Support for the extended RoCE statistics is available. These
+	 * statistics are queried via the `query_roce_stats_ext` command
+	 * and are enabled on a per-QP basis via `create_qp`.
 	 */
-	uint64_t	aux_bytes_in;
+	#define CREQ_QUERY_FUNC_RESP_SB_EXT_STATS				UINT32_C(0x10)
 	/*
-	 * Count, in 4-byte (dword) units, of bytes
-	 * that are output as auxiliary data.
-	 * This count is the buffer space for aux_data
-	 * output provided in the RQE, not the actual
-	 * aux_data written
+	 * Support for both allocating and registering a new MR via the
+	 * `register_mr` command is available. With this feature the
+	 * `allocate_mrw` command does not have to be called before
+	 * registering.
 	 */
-	uint64_t	aux_bytes_out;
-	/* Count of number of commands executed. */
-	uint64_t	commands;
+	#define CREQ_QUERY_FUNC_RESP_SB_MR_REGISTER_ALLOC			UINT32_C(0x20)
 	/*
-	 * Count of number of error commands.
-	 * These are the commands with a
-	 * non-zero status value.
+	 * Support for optimized transmit path to lower latency for WQEs
+	 * with inline data.
 	 */
-	uint64_t	error_commands;
+	#define CREQ_QUERY_FUNC_RESP_SB_OPTIMIZED_TRANSMIT_ENABLED	UINT32_C(0x40)
 	/*
-	 * Compression/Encryption Engine usage,
-	 * the unit is count of clock cycles
+	 * The underlying HW uses the version 2 of the CQEs definitions for
+	 * the following CQE types:
+	 * RES_UD, RES_RAWETH_QP1, RES_UD_CFA
 	 */
-	uint64_t	cce_engine_usage;
+	#define CREQ_QUERY_FUNC_RESP_SB_CQE_V2				UINT32_C(0x80)
+	/* Support for ping pong push mode is available. */
+	#define CREQ_QUERY_FUNC_RESP_SB_PINGPONG_PUSH_MODE		UINT32_C(0x100)
+	/* Support for hardware requester retransmission is enabled. */
+	#define CREQ_QUERY_FUNC_RESP_SB_HW_REQUESTER_RETX_ENABLED		UINT32_C(0x200)
+	/* Support for hardware responder retransmission is enabled. */
+	#define CREQ_QUERY_FUNC_RESP_SB_HW_RESPONDER_RETX_ENABLED		UINT32_C(0x400)
+	/* Support for link aggregation is enabled. */
+	#define CREQ_QUERY_FUNC_RESP_SB_LINK_AGGR_SUPPORTED		UINT32_C(0x800)
+	/* link_aggr_supported is valid. */
+	#define CREQ_QUERY_FUNC_RESP_SB_LINK_AGGR_SUPPORTED_VALID		UINT32_C(0x1000)
+	/*
+	 * Support for pseudo static QP allocation is enabled.
+	 * This feature enables the following capabilities:
+	 * - QP context ID space is pseudo-static partitioned across PFs.
+	 * - An application can use a predetermined
+	 *   QP context ID assignment scheme for specific operations.
+	 * - For 2-port adapters, the application can migrate the QP context
+	 *   ID range across PFs, using the `orchestrate_qid_migration` HWRM,
+	 *   during network events such as Link Down.
+	 */
+	#define CREQ_QUERY_FUNC_RESP_SB_PSEUDO_STATIC_QP_ALLOC_SUPPORTED	UINT32_C(0x2000)
+	/*
+	 * Support for Express Mode is enabled.
+	 * For Express mode, the QP resources (SQ/RQ) are allocated in
+	 * on-chip queue memory. The host driver should not allocate memory
+	 * for these queue structures.
+	 */
+	#define CREQ_QUERY_FUNC_RESP_SB_EXPRESS_MODE_SUPPORTED		UINT32_C(0x4000)
+	/*
+	 * IRRQ/ORRQ and MSN Table structures are allocated in internal
+	 * queue memory.
+	 */
+	#define CREQ_QUERY_FUNC_RESP_SB_INTERNAL_QUEUE_MEMORY		UINT32_C(0x8000)
+	/* Max CQs supported. */
+	uint32_t	max_cq;
+	/* Max CQEs per CQ supported. */
+	uint32_t	max_cqe;
+	/* Max PDs supported. */
+	uint32_t	max_pd;
 	/*
-	 * De-Compression/De-cryption Engine usage,
-	 * the unit is count of clock cycles
+	 * Max SGEs per QP WQE supported. On chips with variable-size WQE
+	 * support, this field is applicable only for the backward compatible
+	 * mode.
 	 */
-	uint64_t	cdd_engine_usage;
-	uint8_t	unused_0[7];
+	uint8_t	max_sge;
+	/* Max SGEs per SRQ WQE supported. */
+	uint8_t	max_srq_sge;
+	/* Max outstanding RDMA read & atomic supported. */
+	uint8_t	max_qp_rd_atom;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * Max outstanding RDMA read & atomic that can be sent from an
+	 * initiator.
 	 */
-	uint8_t	valid;
-} hwrm_stat_ctx_eng_query_output_t, *phwrm_stat_ctx_eng_query_output_t;
-
-/***************************
- * hwrm_stat_ctx_clr_stats *
- ***************************/
-
-
-/* hwrm_stat_ctx_clr_stats_input (size:192b/24B) */
-
-typedef struct hwrm_stat_ctx_clr_stats_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	uint8_t	max_qp_init_rd_atom;
+	/* Max MRs supported. */
+	uint32_t	max_mr;
+	/* Max MWs supported. */
+	uint32_t	max_mw;
+	/* Max Raw Ethertype QPs supported. */
+	uint32_t	max_raw_eth_qp;
+	/* Max AHs supported. */
+	uint32_t	max_ah;
+	/* Max FMRs supported. */
+	uint32_t	max_fmr;
+	/* Max WQEs per SRQ supported. */
+	uint32_t	max_srq_wr;
+	/* Max PKEYs supported. */
+	uint32_t	max_pkeys;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * Max inline data supported. On chips with variable-size WQE support,
+	 * this field is applicable only for the backward compatible mode.
 	 */
-	uint16_t	cmpl_ring;
+	uint32_t	max_inline_data;
+	/* Max mappings per FMR supported. */
+	uint8_t	max_map_per_fmr;
+	/* L2 DB space size in pages. */
+	uint8_t	l2_db_space_size;
+	/* Max SRQs supported. */
+	uint16_t	max_srq;
+	/* Max GIDs supported. */
+	uint32_t	max_gid;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * An array of 48 8-bit values to specify allocation multiplier for TQM
+	 * host buffer regions. Each region occupies 16 MB of TQM PBL address
+	 * space: 0x00000000, 0x01000000, 0x02000000, etc.
+	 * The host needs to allocate (<Number of QPs>*multiplier, rounded up
+	 * to page size) of physical memory for non-zero slots and map the
+	 * pages to the corresponding 16MB regions. Typically there are total
+	 * 3 non-zero values in this array, their values are 16, 16, 12.
+	 * Cu+ will only populate up to index 11. SR may populate up to
+	 * index 47.
 	 */
-	uint16_t	seq_id;
-	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	uint32_t	tqm_alloc_reqs[12];
+	/* Max Doorbell page indices supported. */
+	uint32_t	max_dpi;
+	/* Max SGEs per QP WQE supported in the variable-size WQE mode. */
+	uint8_t	max_sge_var_wqe;
+	/* Device capability extended flags. */
+	uint8_t	dev_cap_ext_flags;
+	/* RDMA Atomic operations are not supported. */
+	#define CREQ_QUERY_FUNC_RESP_SB_ATOMIC_OPS_NOT_SUPPORTED	UINT32_C(0x1)
+	/* Support driver version registration. */
+	#define CREQ_QUERY_FUNC_RESP_SB_DRV_VERSION_RGTR_SUPPORTED	UINT32_C(0x2)
+	/* Support for batch allocation of QPs is enabled. */
+	#define CREQ_QUERY_FUNC_RESP_SB_CREATE_QP_BATCH_SUPPORTED	UINT32_C(0x4)
+	/* Support for batch deletion of QPs is enabled. */
+	#define CREQ_QUERY_FUNC_RESP_SB_DESTROY_QP_BATCH_SUPPORTED	UINT32_C(0x8)
+	/*
+	 * Support for extended RoCE statistics context
+	 * with periodic DMA is enabled. The statistics contexts
+	 * are allocated via `allocate_roce_stats_ext_ctx`
+	 * and deallocated via `deallocate_roce_stats_ext_ctx`.
+	 * These contexts are assigned on a per-QP, per-group of QPs
+	 * or per-function basis via `create_qp`, `create_qp_batch`
+	 * or `modify_qp`command.
+	 * In addition to periodic DMA to a host address,
+	 * these statistics can be queried via `query_roce_stats_ext_v2`.
+	 */
+	#define CREQ_QUERY_FUNC_RESP_SB_ROCE_STATS_EXT_CTX_SUPPORTED	UINT32_C(0x10)
+	/*
+	 * Support for the srq_sge field in the create_srq command is
+	 * enabled.
 	 */
-	uint16_t	target_id;
+	#define CREQ_QUERY_FUNC_RESP_SB_CREATE_SRQ_SGE_SUPPORTED	UINT32_C(0x20)
+	/* Support for fixed size SQ wqe (128B) is disabled. */
+	#define CREQ_QUERY_FUNC_RESP_SB_FIXED_SIZE_WQE_DISABLED	UINT32_C(0x40)
+	/* Support for DCN (Drop Congestion Notification) is enabled. */
+	#define CREQ_QUERY_FUNC_RESP_SB_DCN_SUPPORTED			UINT32_C(0x80)
+	/* Max inline data supported in the variable-size WQE mode. */
+	uint16_t	max_inline_data_var_wqe;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * starting xid of the predetermined assignment scheme supported
+	 * by the pseudo static allocation feature. Note that for a PF,
+	 * the start_qid is itself pseudo_static, and can change when the QP
+	 * context id range is migrated by the driver using the
+	 * cmdq_orchestrate_qid_migration. The supported QP count is
+	 * available in the `max_qp` field of `cmdq_query_func`.
 	 */
-	uint64_t	resp_addr;
-	/* ID of the statistics context that is being queried. */
-	uint32_t	stat_ctx_id;
-	uint8_t	unused_0[4];
-} hwrm_stat_ctx_clr_stats_input_t, *phwrm_stat_ctx_clr_stats_input_t;
-
-/* hwrm_stat_ctx_clr_stats_output (size:128b/16B) */
-
-typedef struct hwrm_stat_ctx_clr_stats_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	uint32_t	start_qid;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * Max number of MSN table entries supported for devices that support
+	 * the `internal_queue_memory` feature.
 	 */
-	uint8_t	valid;
-} hwrm_stat_ctx_clr_stats_output_t, *phwrm_stat_ctx_clr_stats_output_t;
-
-/********************
- * hwrm_pcie_qstats *
- ********************/
-
-
-/* hwrm_pcie_qstats_input (size:256b/32B) */
-
-typedef struct hwrm_pcie_qstats_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	uint8_t	max_msn_table_size;
+	/* reserved8_1 is 8 b */
+	uint8_t	reserved8_1;
+	/* Device capability extended flags_2 */
+	uint16_t	dev_cap_ext_flags_2;
+	/* Firmware support for optimizing Modify QP operation */
+	#define CREQ_QUERY_FUNC_RESP_SB_OPTIMIZE_MODIFY_QP_SUPPORTED		UINT32_C(0x1)
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * Device supports changing UDP source port of RoCEv2 packets using
+	 * WQE.
 	 */
-	uint16_t	cmpl_ring;
+	#define CREQ_QUERY_FUNC_RESP_SB_CHANGE_UDP_SRC_PORT_WQE_SUPPORTED	UINT32_C(0x2)
+	/* Device supports CQ Coalescing. */
+	#define CREQ_QUERY_FUNC_RESP_SB_CQ_COALESCING_SUPPORTED		UINT32_C(0x4)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Device allows a memory region to be designated as
+	 * relaxed-ordering enabled or disabled.
 	 */
-	uint16_t	seq_id;
+	#define CREQ_QUERY_FUNC_RESP_SB_MEMORY_REGION_RO_SUPPORTED		UINT32_C(0x8)
+	/* The type of lookup table used for requester retransmission. */
+	#define CREQ_QUERY_FUNC_RESP_SB_REQ_RETRANSMISSION_SUPPORT_MASK	UINT32_C(0x30)
+	#define CREQ_QUERY_FUNC_RESP_SB_REQ_RETRANSMISSION_SUPPORT_SFT	4
+	/* Requester Retransmission uses a PSN table in host memory. */
+		#define CREQ_QUERY_FUNC_RESP_SB_REQ_RETRANSMISSION_SUPPORT_HOST_PSN_TABLE  (UINT32_C(0x0) << 4)
+	/* Requester Retransmission uses an MSN table in host memory. */
+		#define CREQ_QUERY_FUNC_RESP_SB_REQ_RETRANSMISSION_SUPPORT_HOST_MSN_TABLE  (UINT32_C(0x1) << 4)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Requester Retransmission uses an MSN table in Device Internal
+	 * Queue Memory.
 	 */
-	uint16_t	target_id;
+		#define CREQ_QUERY_FUNC_RESP_SB_REQ_RETRANSMISSION_SUPPORT_IQM_MSN_TABLE   (UINT32_C(0x2) << 4)
+		#define CREQ_QUERY_FUNC_RESP_SB_REQ_RETRANSMISSION_SUPPORT_LAST	CREQ_QUERY_FUNC_RESP_SB_REQ_RETRANSMISSION_SUPPORT_IQM_MSN_TABLE
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Max number of 16B IQM memory slots supported by SQ or RQ
+	 * when QP is in express mode.
+	 * This field is only valid for express mode QPs.
 	 */
-	uint64_t	resp_addr;
+	uint16_t	max_xp_qp_size;
 	/*
-	 * The size of PCIe statistics block in bytes.
-	 * Firmware will DMA the PCIe statistics to
-	 * the host with this field size in the response.
+	 * Max number of QPs that can be created in one `create_qp_batch`
+	 * command.
 	 */
-	uint16_t	pcie_stat_size;
-	uint8_t	unused_0[6];
+	uint16_t	create_qp_batch_size;
 	/*
-	 * This is the host address where
-	 * PCIe statistics will be stored
+	 * Max number of QPs that can be destroyed in one `destroy_qp_batch`
+	 * command.
 	 */
-	uint64_t	pcie_stat_host_addr;
-} hwrm_pcie_qstats_input_t, *phwrm_pcie_qstats_input_t;
+	uint16_t	destroy_qp_batch_size;
+	uint16_t	reserved16;
+	uint64_t	reserved64;
+} creq_query_func_resp_sb_t, *pcreq_query_func_resp_sb_t;
 
-/* hwrm_pcie_qstats_output (size:128b/16B) */
+/**********************
+ * set_func_resources *
+ **********************/
 
-typedef struct hwrm_pcie_qstats_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* The size of PCIe statistics block in bytes. */
-	uint16_t	pcie_stat_size;
-	uint8_t	unused_0[5];
-	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
-	 */
-	uint8_t	valid;
-} hwrm_pcie_qstats_output_t, *phwrm_pcie_qstats_output_t;
 
-/* PCIe Statistics Formats */
-/* pcie_ctx_hw_stats (size:768b/96B) */
+/* cmdq_set_func_resources (size:448b/56B) */
 
-typedef struct pcie_ctx_hw_stats {
-	/* Number of physical layer receiver errors */
-	uint64_t	pcie_pl_signal_integrity;
-	/* Number of DLLP CRC errors detected by Data Link Layer */
-	uint64_t	pcie_dl_signal_integrity;
+typedef struct cmdq_set_func_resources {
+	/* Command opcode. */
+	uint8_t	opcode;
 	/*
-	 * Number of TLP LCRC and sequence number errors detected
-	 * by Data Link Layer
+	 * Set the following resources for the function:
+	 * - Max QP, CQ, MR+MW, SRQ per PF
+	 * - Max QP, CQ, MR+MW, SRQ per VF
 	 */
-	uint64_t	pcie_tl_signal_integrity;
-	/* Number of times LTSSM entered Recovery state */
-	uint64_t	pcie_link_integrity;
-	/* Report number of TLP bits that have been transmitted in Mbps */
-	uint64_t	pcie_tx_traffic_rate;
-	/* Report number of TLP bits that have been received in Mbps */
-	uint64_t	pcie_rx_traffic_rate;
-	/* Number of DLLP bytes that have been transmitted */
-	uint64_t	pcie_tx_dllp_statistics;
-	/* Number of DLLP bytes that have been received */
-	uint64_t	pcie_rx_dllp_statistics;
+	#define CMDQ_SET_FUNC_RESOURCES_OPCODE_SET_FUNC_RESOURCES UINT32_C(0x84)
+	#define CMDQ_SET_FUNC_RESOURCES_OPCODE_LAST		CMDQ_SET_FUNC_RESOURCES_OPCODE_SET_FUNC_RESOURCES
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
 	/*
-	 * Number of times spent in each phase of gen3
-	 * equalization
+	 * When set, the 32b `max_mrw_per_vf` field is logically divided
+	 * into two 16b fields, `max_mr_per_vf` and `max_av_per_vf`.
 	 */
-	uint64_t	pcie_equalization_time;
-	/* Records the last 16 transitions of the LTSSM */
-	uint32_t	pcie_ltssm_histogram[4];
+	#define CMDQ_SET_FUNC_RESOURCES_FLAGS_MRAV_RESERVATION_SPLIT	UINT32_C(0x1)
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
 	/*
-	 * Record the last 8 reasons on why LTSSM transitioned
-	 * to Recovery
+	 * Number of QPs. It is the responsibility of the host to first extend
+	 * the existing PBL with new addresses to pages to handle the
+	 * adjustment. Must be greater or equal to current.
 	 */
-	uint64_t	pcie_recovery_histogram;
-} pcie_ctx_hw_stats_t, *ppcie_ctx_hw_stats_t;
-
-/*****************
- * hwrm_fw_reset *
- *****************/
-
-
-/* hwrm_fw_reset_input (size:192b/24B) */
-
-typedef struct hwrm_fw_reset_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	uint32_t	number_of_qp;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * Number of MRWs. It is the responsibility of the host to first extend
+	 * the existing PBL with new addresses to pages to handle the
+	 * adjustment. Must be greater or equal to current.
 	 */
-	uint16_t	cmpl_ring;
+	uint32_t	number_of_mrw;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Number of SRQs. It is the responsibility of the host to first extend
+	 * the existing PBL with new addresses to pages to handle the
+	 * adjustment. Must be greater or equal to current.
 	 */
-	uint16_t	seq_id;
+	uint32_t	number_of_srq;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Number of CQs. It is the responsibility of the host to first extend
+	 * the existing PBL with new addresses to pages to handle the
+	 * adjustment. Must be greater or equal to current.
 	 */
-	uint16_t	target_id;
+	uint32_t	number_of_cq;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Number of QPs per VF. This field must be set to zero when the flag,
+	 * l2_vf_resource_mgmt, is set and RoCE SRIOV is enabled.
 	 */
-	uint64_t	resp_addr;
-	/* Type of embedded processor. */
-	uint8_t	embedded_proc_type;
-	/* Boot Processor */
-	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_BOOT		UINT32_C(0x0)
-	/* Management Processor */
-	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_MGMT		UINT32_C(0x1)
-	/* Network control processor */
-	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_NETCTRL		UINT32_C(0x2)
-	/* RoCE control processor */
-	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_ROCE		UINT32_C(0x3)
+	uint32_t	max_qp_per_vf;
 	/*
-	 * Host (in multi-host environment): This is only valid if requester is IPC.
-	 * Reinit host hardware resources and PCIe.
+	 * If the MR/AV split reservation flag is not set, then this field
+	 * represents the total number of MR plus AV entries allowed per
+	 * VF. For versions of firmware that support the split reservation,
+	 * when it is not specified half of the entries will be reserved
+	 * for MRs and the other half for AVs.
+	 *
+	 * If the MR/AV split reservation flag is set, then this
+	 * field is logically divided into two 16b fields. Bits `[31:16]`
+	 * represents the `max_mr_per_vf` and bits `[15:0]` represents
+	 * `max_av_per_vf`. The granularity of these values is defined by
+	 * the `mrav_num_entries_unit` field returned by the
+	 * `backing_store_qcaps` command.
+	 *
+	 * This field must be set to zero when the flag, l2_vf_resource_mgmt,
+	 * is set and RoCE SRIOV is enabled.
 	 */
-	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_HOST		UINT32_C(0x4)
-	/* AP processor complex (in multi-host environment). Use host_idx to control which core is reset */
-	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_AP			UINT32_C(0x5)
-	/* Reset all blocks of the chip (including all processors) */
-	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_CHIP		UINT32_C(0x6)
+	uint32_t	max_mrw_per_vf;
 	/*
-	 * Host (in multi-host environment): This is only valid if requester is IPC.
-	 * Reinit host hardware resources.
+	 * Number of SRQs per VF. This field must be set to zero when the flag,
+	 * l2_vf_resource_mgmt, is set and RoCE SRIOV is enabled.
 	 */
-	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_HOST_RESOURCE_REINIT  UINT32_C(0x7)
+	uint32_t	max_srq_per_vf;
 	/*
-	 * Activate firmware that has been programmed to NVM.  The
-	 * activation is done in an impactless manner as part of the scheme
-	 * where hwrm_fw_state_backup precedes the call, and
-	 * hwrm_fw_state_restore follows it.  Before this call returns, FW
-	 * status is set to a non-0x8000 value to disambiguate reset pending
-	 * from reset complete.  The reset process begins after this call
-	 * returns to ensure this HWRM has completed before reset begins.
+	 * Number of CQs per VF. This field must be set to zero when the flag,
+	 * l2_vf_resource_mgmt, is set and RoCE SRIOV is enabled.
 	 */
-	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_IMPACTLESS_ACTIVATION UINT32_C(0x8)
-	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_LAST		HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_IMPACTLESS_ACTIVATION
-	/* Type of self reset. */
-	uint8_t	selfrst_status;
-	/* No Self Reset */
-	#define HWRM_FW_RESET_INPUT_SELFRST_STATUS_SELFRSTNONE	UINT32_C(0x0)
-	/* Self Reset as soon as possible to do so safely */
-	#define HWRM_FW_RESET_INPUT_SELFRST_STATUS_SELFRSTASAP	UINT32_C(0x1)
-	/* Self Reset on PCIe Reset */
-	#define HWRM_FW_RESET_INPUT_SELFRST_STATUS_SELFRSTPCIERST   UINT32_C(0x2)
-	/* Self Reset immediately after notification to all clients. */
-	#define HWRM_FW_RESET_INPUT_SELFRST_STATUS_SELFRSTIMMEDIATE UINT32_C(0x3)
-	#define HWRM_FW_RESET_INPUT_SELFRST_STATUS_LAST		HWRM_FW_RESET_INPUT_SELFRST_STATUS_SELFRSTIMMEDIATE
+	uint32_t	max_cq_per_vf;
 	/*
-	 * Indicate which host is being reset. 0 means first host.
-	 * Only valid when embedded_proc_type is host in multihost
-	 * environment
+	 * Number of GIDs per VF. This field must be set to zero when the flag,
+	 * l2_vf_resource_mgmt, is set and RoCE SRIOV is enabled.
 	 */
-	uint8_t	host_idx;
-	uint8_t	flags;
+	uint32_t	max_gid_per_vf;
+	/* Statistics context index for this function. */
+	uint32_t	stat_ctx_id;
+} cmdq_set_func_resources_t, *pcmdq_set_func_resources_t;
+
+/* creq_set_func_resources_resp (size:128b/16B) */
+
+typedef struct creq_set_func_resources_resp {
+	uint8_t	type;
 	/*
-	 * When this bit is '1', then the core firmware initiates
-	 * the reset only after graceful shut down of all registered instances.
-	 * If not, the device will continue with the existing firmware.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
+	 */
+	#define CREQ_SET_FUNC_RESOURCES_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_SET_FUNC_RESOURCES_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_SET_FUNC_RESOURCES_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_SET_FUNC_RESOURCES_RESP_TYPE_LAST	CREQ_SET_FUNC_RESOURCES_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	uint32_t	reserved32;
+	uint8_t	v;
+	/*
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
+	 */
+	#define CREQ_SET_FUNC_RESOURCES_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Set function resources command response. */
+	#define CREQ_SET_FUNC_RESOURCES_RESP_EVENT_SET_FUNC_RESOURCES UINT32_C(0x84)
+	#define CREQ_SET_FUNC_RESOURCES_RESP_EVENT_LAST		CREQ_SET_FUNC_RESOURCES_RESP_EVENT_SET_FUNC_RESOURCES
+	uint8_t	reserved48[6];
+} creq_set_func_resources_resp_t, *pcreq_set_func_resources_resp_t;
+
+/*************
+ * stop_func *
+ *************/
+
+
+/* cmdq_stop_func (size:128b/16B) */
+
+typedef struct cmdq_stop_func {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Stop the function */
+	#define CMDQ_STOP_FUNC_OPCODE_STOP_FUNC UINT32_C(0x82)
+	#define CMDQ_STOP_FUNC_OPCODE_LAST	CMDQ_STOP_FUNC_OPCODE_STOP_FUNC
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+} cmdq_stop_func_t, *pcmdq_stop_func_t;
+
+/* creq_stop_func_resp (size:128b/16B) */
+
+typedef struct creq_stop_func_resp {
+	uint8_t	type;
+	/*
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	#define HWRM_FW_RESET_INPUT_FLAGS_RESET_GRACEFUL	UINT32_C(0x1)
-	uint8_t	unused_0[4];
-} hwrm_fw_reset_input_t, *phwrm_fw_reset_input_t;
-
-/* hwrm_fw_reset_output (size:128b/16B) */
-
-typedef struct hwrm_fw_reset_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Type of self reset. */
-	uint8_t	selfrst_status;
-	/* No Self Reset */
-	#define HWRM_FW_RESET_OUTPUT_SELFRST_STATUS_SELFRSTNONE	UINT32_C(0x0)
-	/* Self Reset as soon as possible to do so safely */
-	#define HWRM_FW_RESET_OUTPUT_SELFRST_STATUS_SELFRSTASAP	UINT32_C(0x1)
-	/* Self Reset on PCIe Reset */
-	#define HWRM_FW_RESET_OUTPUT_SELFRST_STATUS_SELFRSTPCIERST   UINT32_C(0x2)
-	/* Self Reset immediately after notification to all clients. */
-	#define HWRM_FW_RESET_OUTPUT_SELFRST_STATUS_SELFRSTIMMEDIATE UINT32_C(0x3)
-	#define HWRM_FW_RESET_OUTPUT_SELFRST_STATUS_LAST		HWRM_FW_RESET_OUTPUT_SELFRST_STATUS_SELFRSTIMMEDIATE
-	uint8_t	unused_0[6];
+	#define CREQ_STOP_FUNC_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_STOP_FUNC_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_STOP_FUNC_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_STOP_FUNC_RESP_TYPE_LAST	CREQ_STOP_FUNC_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	uint32_t	reserved32;
+	uint8_t	v;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint8_t	valid;
-} hwrm_fw_reset_output_t, *phwrm_fw_reset_output_t;
+	#define CREQ_STOP_FUNC_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Stop PF command response. */
+	#define CREQ_STOP_FUNC_RESP_EVENT_STOP_FUNC UINT32_C(0x82)
+	#define CREQ_STOP_FUNC_RESP_EVENT_LAST	CREQ_STOP_FUNC_RESP_EVENT_STOP_FUNC
+	uint8_t	reserved48[6];
+} creq_stop_func_resp_t, *pcreq_stop_func_resp_t;
 
-/*******************
- * hwrm_fw_qstatus *
- *******************/
+/****************
+ * read_context *
+ ****************/
 
 
-/* hwrm_fw_qstatus_input (size:192b/24B) */
+/* cmdq_read_context (size:192b/24B) */
 
-typedef struct hwrm_fw_qstatus_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+typedef struct cmdq_read_context {
+	/* Command opcode. */
+	uint8_t	opcode;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * Read the current state of any internal resource context. Can only
+	 * be issued from a PF.
 	 */
-	uint16_t	cmpl_ring;
+	#define CMDQ_READ_CONTEXT_OPCODE_READ_CONTEXT UINT32_C(0x85)
+	#define CMDQ_READ_CONTEXT_OPCODE_LAST	CMDQ_READ_CONTEXT_OPCODE_READ_CONTEXT
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+	/* Context ID */
+	uint32_t	xid;
+	/* Context type */
+	uint8_t	type;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Read QPC. The context (448 bytes) goes to resp_addr (as is,
+	 * without a header), and resp_size should be set to 28
+	 * (448/16).
 	 */
-	uint16_t	seq_id;
+	#define CMDQ_READ_CONTEXT_TYPE_QPC UINT32_C(0x0)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Read CQ. The context (64 bytes) goes to resp_addr (as is,
+	 * without a header), and resp_size should be set to 4 (64/16)
 	 */
-	uint16_t	target_id;
+	#define CMDQ_READ_CONTEXT_TYPE_CQ  UINT32_C(0x1)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Read MRW. The context (128 bytes) goes to resp_addr (as is,
+	 * without a header), and resp_size should be set to 8 (128/16)
 	 */
-	uint64_t	resp_addr;
-	/* Type of embedded processor. */
-	uint8_t	embedded_proc_type;
-	/* Boot Processor */
-	#define HWRM_FW_QSTATUS_INPUT_EMBEDDED_PROC_TYPE_BOOT	UINT32_C(0x0)
-	/* Management Processor */
-	#define HWRM_FW_QSTATUS_INPUT_EMBEDDED_PROC_TYPE_MGMT	UINT32_C(0x1)
-	/* Network control processor */
-	#define HWRM_FW_QSTATUS_INPUT_EMBEDDED_PROC_TYPE_NETCTRL UINT32_C(0x2)
-	/* RoCE control processor */
-	#define HWRM_FW_QSTATUS_INPUT_EMBEDDED_PROC_TYPE_ROCE	UINT32_C(0x3)
-	/* Host (in multi-host environment): This is only valid if requester is IPC */
-	#define HWRM_FW_QSTATUS_INPUT_EMBEDDED_PROC_TYPE_HOST	UINT32_C(0x4)
-	/* AP processor complex (in multi-host environment). Use host_idx to control which core is reset */
-	#define HWRM_FW_QSTATUS_INPUT_EMBEDDED_PROC_TYPE_AP	UINT32_C(0x5)
-	/* Reset all blocks of the chip (including all processors) */
-	#define HWRM_FW_QSTATUS_INPUT_EMBEDDED_PROC_TYPE_CHIP	UINT32_C(0x6)
-	#define HWRM_FW_QSTATUS_INPUT_EMBEDDED_PROC_TYPE_LAST   HWRM_FW_QSTATUS_INPUT_EMBEDDED_PROC_TYPE_CHIP
-	uint8_t	unused_0[7];
-} hwrm_fw_qstatus_input_t, *phwrm_fw_qstatus_input_t;
+	#define CMDQ_READ_CONTEXT_TYPE_MRW UINT32_C(0x2)
+	/*
+	 * Read SRQ. The context (64 bytes) goes to resp_addr (as is,
+	 * without a header), and resp_size should be set to 4 (64/16)
+	 */
+	#define CMDQ_READ_CONTEXT_TYPE_SRQ UINT32_C(0x3)
+	#define CMDQ_READ_CONTEXT_TYPE_LAST CMDQ_READ_CONTEXT_TYPE_SRQ
+	uint8_t	unused_0[3];
+} cmdq_read_context_t, *pcmdq_read_context_t;
 
-/* hwrm_fw_qstatus_output (size:128b/16B) */
+/* creq_read_context (size:128b/16B) */
 
-typedef struct hwrm_fw_qstatus_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Type of self reset. */
-	uint8_t	selfrst_status;
-	/* No Self Reset */
-	#define HWRM_FW_QSTATUS_OUTPUT_SELFRST_STATUS_SELFRSTNONE	UINT32_C(0x0)
-	/* Self Reset as soon as possible to do so safely */
-	#define HWRM_FW_QSTATUS_OUTPUT_SELFRST_STATUS_SELFRSTASAP	UINT32_C(0x1)
-	/* Self Reset on PCIe Reset */
-	#define HWRM_FW_QSTATUS_OUTPUT_SELFRST_STATUS_SELFRSTPCIERST UINT32_C(0x2)
-	/* NIC power cycle (system cold boot) required */
-	#define HWRM_FW_QSTATUS_OUTPUT_SELFRST_STATUS_SELFRSTPOWER   UINT32_C(0x3)
-	#define HWRM_FW_QSTATUS_OUTPUT_SELFRST_STATUS_LAST	HWRM_FW_QSTATUS_OUTPUT_SELFRST_STATUS_SELFRSTPOWER
+typedef struct creq_read_context {
+	uint8_t	type;
 	/*
-	 * The action needed to apply any pend nvm option changes.
-	 * If multiple options have been set the highest level
-	 * action is reported.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B records.
+	 * records.
 	 */
-	uint8_t	nvm_option_action_status;
-	/* No Action needed */
-	#define HWRM_FW_QSTATUS_OUTPUT_NVM_OPTION_ACTION_STATUS_NVMOPT_ACTION_NONE	UINT32_C(0x0)
-	/* Hot reset needed to apply nvm options */
-	#define HWRM_FW_QSTATUS_OUTPUT_NVM_OPTION_ACTION_STATUS_NVMOPT_ACTION_HOTRESET UINT32_C(0x1)
-	/* Warm boot needed to apply nvm options */
-	#define HWRM_FW_QSTATUS_OUTPUT_NVM_OPTION_ACTION_STATUS_NVMOPT_ACTION_WARMBOOT UINT32_C(0x2)
-	/* Cold boot needed to apply nvm options */
-	#define HWRM_FW_QSTATUS_OUTPUT_NVM_OPTION_ACTION_STATUS_NVMOPT_ACTION_COLDBOOT UINT32_C(0x3)
-	#define HWRM_FW_QSTATUS_OUTPUT_NVM_OPTION_ACTION_STATUS_LAST		HWRM_FW_QSTATUS_OUTPUT_NVM_OPTION_ACTION_STATUS_NVMOPT_ACTION_COLDBOOT
-	uint8_t	unused_0[5];
+	#define CREQ_READ_CONTEXT_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_READ_CONTEXT_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_READ_CONTEXT_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_READ_CONTEXT_TYPE_LAST	CREQ_READ_CONTEXT_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	uint32_t	reserved32;
+	uint8_t	v;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint8_t	valid;
-} hwrm_fw_qstatus_output_t, *phwrm_fw_qstatus_output_t;
+	#define CREQ_READ_CONTEXT_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/*
+	 * Read the current state of any internal resource context. Can only
+	 * be issued from a PF.
+	 */
+	#define CREQ_READ_CONTEXT_EVENT_READ_CONTEXT UINT32_C(0x85)
+	#define CREQ_READ_CONTEXT_EVENT_LAST	CREQ_READ_CONTEXT_EVENT_READ_CONTEXT
+	uint16_t	reserved16;
+	uint32_t	reserved_32;
+} creq_read_context_t, *pcreq_read_context_t;
 
-/********************
- * hwrm_fw_set_time *
- ********************/
+/*****************
+ * map_tc_to_cos *
+ *****************/
 
 
-/* hwrm_fw_set_time_input (size:256b/32B) */
+/* cmdq_map_tc_to_cos (size:192b/24B) */
 
-typedef struct hwrm_fw_set_time_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+typedef struct cmdq_map_tc_to_cos {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Map TC to COS. Can only be issued from a PF. */
+	#define CMDQ_MAP_TC_TO_COS_OPCODE_MAP_TC_TO_COS UINT32_C(0x8a)
+	#define CMDQ_MAP_TC_TO_COS_OPCODE_LAST	CMDQ_MAP_TC_TO_COS_OPCODE_MAP_TC_TO_COS
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+	/* 1st COS index mapped to RoCE */
+	uint16_t	cos0;
+	/* Don't change this COS. */
+	#define CMDQ_MAP_TC_TO_COS_COS0_NO_CHANGE UINT32_C(0xffff)
+	#define CMDQ_MAP_TC_TO_COS_COS0_LAST	CMDQ_MAP_TC_TO_COS_COS0_NO_CHANGE
+	/* 2nd COS index mapped to RoCE */
+	uint16_t	cos1;
+	/* Disable this COS. */
+	#define CMDQ_MAP_TC_TO_COS_COS1_DISABLE   UINT32_C(0x8000)
+	/* Don't change this COS. */
+	#define CMDQ_MAP_TC_TO_COS_COS1_NO_CHANGE UINT32_C(0xffff)
+	#define CMDQ_MAP_TC_TO_COS_COS1_LAST	CMDQ_MAP_TC_TO_COS_COS1_NO_CHANGE
+	uint32_t	unused_0;
+} cmdq_map_tc_to_cos_t, *pcmdq_map_tc_to_cos_t;
+
+/* creq_map_tc_to_cos_resp (size:128b/16B) */
+
+typedef struct creq_map_tc_to_cos_resp {
+	uint8_t	type;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint16_t	cmpl_ring;
+	#define CREQ_MAP_TC_TO_COS_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_MAP_TC_TO_COS_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_MAP_TC_TO_COS_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_MAP_TC_TO_COS_RESP_TYPE_LAST	CREQ_MAP_TC_TO_COS_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	uint32_t	reserved32;
+	uint8_t	v;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint16_t	seq_id;
+	#define CREQ_MAP_TC_TO_COS_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Map TC to COS response. */
+	#define CREQ_MAP_TC_TO_COS_RESP_EVENT_MAP_TC_TO_COS UINT32_C(0x8a)
+	#define CREQ_MAP_TC_TO_COS_RESP_EVENT_LAST	CREQ_MAP_TC_TO_COS_RESP_EVENT_MAP_TC_TO_COS
+	uint8_t	reserved48[6];
+} creq_map_tc_to_cos_resp_t, *pcreq_map_tc_to_cos_resp_t;
+
+/*****************
+ * query_roce_cc *
+ *****************/
+
+
+/* cmdq_query_roce_cc (size:128b/16B) */
+
+typedef struct cmdq_query_roce_cc {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Query congestion control. */
+	#define CMDQ_QUERY_ROCE_CC_OPCODE_QUERY_ROCE_CC UINT32_C(0x8d)
+	#define CMDQ_QUERY_ROCE_CC_OPCODE_LAST	CMDQ_QUERY_ROCE_CC_OPCODE_QUERY_ROCE_CC
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+} cmdq_query_roce_cc_t, *pcmdq_query_roce_cc_t;
+
+/* creq_query_roce_cc_resp (size:128b/16B) */
+
+typedef struct creq_query_roce_cc_resp {
+	uint8_t	type;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint16_t	target_id;
+	#define CREQ_QUERY_ROCE_CC_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_QUERY_ROCE_CC_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_QUERY_ROCE_CC_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_QUERY_ROCE_CC_RESP_TYPE_LAST	CREQ_QUERY_ROCE_CC_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Side buffer size in 16-byte units */
+	uint32_t	size;
+	uint8_t	v;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint64_t	resp_addr;
-	/* Current year */
-	uint16_t	year;
-	/* Date/time is not known */
-	#define HWRM_FW_SET_TIME_INPUT_YEAR_UNKNOWN UINT32_C(0x0)
-	#define HWRM_FW_SET_TIME_INPUT_YEAR_LAST   HWRM_FW_SET_TIME_INPUT_YEAR_UNKNOWN
-	/* Current month of year (1-12) */
-	uint8_t	month;
-	/* Current day of month (1-31) */
-	uint8_t	day;
-	/* Current hour (0-23) */
-	uint8_t	hour;
-	/* Current minute (0-59) */
-	uint8_t	minute;
-	/* Current second (0-59) */
-	uint8_t	second;
-	uint8_t	unused_0;
-	/* Current millisecond (0-999) */
-	uint16_t	millisecond;
-	/* Minutes east of UTC, 0xffff if TZ is not known */
-	int16_t	zone;
-	/* Time zone is Coordinated Universal Time (UTC) */
-	#define HWRM_FW_SET_TIME_INPUT_ZONE_UTC	0
-	/* Time zone is not known */
-	#define HWRM_FW_SET_TIME_INPUT_ZONE_UNKNOWN 65535
-	#define HWRM_FW_SET_TIME_INPUT_ZONE_LAST   HWRM_FW_SET_TIME_INPUT_ZONE_UNKNOWN
-	uint8_t	unused_1[4];
-} hwrm_fw_set_time_input_t, *phwrm_fw_set_time_input_t;
+	#define CREQ_QUERY_ROCE_CC_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Query congestion control response. */
+	#define CREQ_QUERY_ROCE_CC_RESP_EVENT_QUERY_ROCE_CC UINT32_C(0x8d)
+	#define CREQ_QUERY_ROCE_CC_RESP_EVENT_LAST	CREQ_QUERY_ROCE_CC_RESP_EVENT_QUERY_ROCE_CC
+	uint8_t	reserved48[6];
+} creq_query_roce_cc_resp_t, *pcreq_query_roce_cc_resp_t;
 
-/* hwrm_fw_set_time_output (size:128b/16B) */
+/* Query congestion control command response side buffer structure. */
+/* creq_query_roce_cc_resp_sb (size:256b/32B) */
 
-typedef struct hwrm_fw_set_time_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+typedef struct creq_query_roce_cc_resp_sb {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Query congestion control response. */
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_OPCODE_QUERY_ROCE_CC UINT32_C(0x8d)
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_OPCODE_LAST	CREQ_QUERY_ROCE_CC_RESP_SB_OPCODE_QUERY_ROCE_CC
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	uint8_t	enable_cc;
+	/* Enable. */
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_ENABLE_CC	UINT32_C(0x1)
+	/* unused7 is 7 b */
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_UNUSED7_MASK  UINT32_C(0xfe)
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_UNUSED7_SFT   1
+	uint8_t	tos_dscp_tos_ecn;
+	/* IP TOS ECN. */
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TOS_ECN_MASK UINT32_C(0x3)
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TOS_ECN_SFT  0
+	/* IP TOS DSCP. */
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TOS_DSCP_MASK UINT32_C(0xfc)
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TOS_DSCP_SFT 2
+	/* Congestion Probability averaging factor. */
+	uint8_t	g;
+	/* Number of phases in Fast Recovery and Active Increase. */
+	uint8_t	num_phases_per_state;
+	/* The starting value of rate. */
+	uint16_t	init_cr;
+	/* The starting value of target rate. */
+	uint16_t	init_tr;
+	uint8_t	alt_vlan_pcp;
+	/* Alternate vlan pcp value for CNP packets. */
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_ALT_VLAN_PCP_MASK UINT32_C(0x7)
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_ALT_VLAN_PCP_SFT 0
+	/* rsvd1 is 5 b */
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_RSVD1_MASK	UINT32_C(0xf8)
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_RSVD1_SFT	3
+	uint8_t	alt_tos_dscp;
+	/* Alternate IP TOS DSCP. */
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_ALT_TOS_DSCP_MASK UINT32_C(0x3f)
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_ALT_TOS_DSCP_SFT 0
+	/* rsvd4 is 2 b */
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_RSVD4_MASK	UINT32_C(0xc0)
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_RSVD4_SFT	6
+	uint8_t	cc_mode;
+	/* DCTCP CC algorithm. */
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_CC_MODE_DCTCP	UINT32_C(0x0)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * Probabilistic marking CC algorithm. On chips with CC Gen 0
+	 * support this will be TCP CC algorithm.
 	 */
-	uint8_t	valid;
-} hwrm_fw_set_time_output_t, *phwrm_fw_set_time_output_t;
-
-/********************
- * hwrm_fw_get_time *
- ********************/
-
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_CC_MODE_PROBABILISTIC UINT32_C(0x1)
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_CC_MODE_LAST	CREQ_QUERY_ROCE_CC_RESP_SB_CC_MODE_PROBABILISTIC
+	/* Specifies the RoCE Tx Queue to use for sending CNP packets. */
+	uint8_t	tx_queue;
+	uint16_t	rtt;
+	/* Round trip time in units of usecs */
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_RTT_MASK  UINT32_C(0x3fff)
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_RTT_SFT   0
+	/* rsvd5 is 2 b */
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_RSVD5_MASK UINT32_C(0xc000)
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_RSVD5_SFT 14
+	uint16_t	tcp_cp;
+	/* The value used as CP when cc_mode is 1(TCP) */
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TCP_CP_MASK UINT32_C(0x3ff)
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TCP_CP_SFT 0
+	/* rsvd6 is 6 b */
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_RSVD6_MASK UINT32_C(0xfc00)
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_RSVD6_SFT  10
+	/* Inactivity time after which QP CC parameters are initialized */
+	uint16_t	inactivity_th;
+	/* Number of packets per phase. Max is 255. */
+	uint8_t	pkts_per_phase;
+	/* Amount of time per phase in units of ms. Max is 15 */
+	uint8_t	time_per_phase;
+	uint32_t	reserved32;
+} creq_query_roce_cc_resp_sb_t, *pcreq_query_roce_cc_resp_sb_t;
 
-/* hwrm_fw_get_time_input (size:128b/16B) */
+/*
+ * TLV encapsulated Query congestion control command response
+ * side buffer, with extended TLV record included for specifying
+ * the extended configuration for CC level 1.
+ */
+/* creq_query_roce_cc_resp_sb_tlv (size:384b/48B) */
 
-typedef struct hwrm_fw_get_time_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+typedef struct creq_query_roce_cc_resp_sb_tlv {
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * The command discriminator is used to differentiate between various
+	 * types of HWRM messages. This includes legacy HWRM and RoCE slowpath
+	 * command messages as well as newer TLV encapsulated HWRM commands.
+	 *
+	 * For TLV encapsulated messages this field must be 0x8000.
 	 */
-	uint16_t	cmpl_ring;
+	uint16_t	cmd_discr;
+	uint8_t	reserved_8b;
+	uint8_t	tlv_flags;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Indicates the presence of additional TLV encapsulated data
+	 * follows this TLV.
 	 */
-	uint16_t	seq_id;
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_TLV_FLAGS_MORE	UINT32_C(0x1)
+	/* Last TLV in a sequence of TLVs. */
+		#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_TLV_FLAGS_MORE_LAST	UINT32_C(0x0)
+	/* More TLVs follow this TLV. */
+		#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_TLV_FLAGS_MORE_NOT_LAST  UINT32_C(0x1)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * When an HWRM receiver detects a TLV type that it does not
+	 * support with the TLV required flag set, the receiver must
+	 * reject the HWRM message with an error code indicating an
+	 * unsupported TLV type.
 	 */
-	uint16_t	target_id;
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_TLV_FLAGS_REQUIRED	UINT32_C(0x2)
+	/* No */
+		#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_TLV_FLAGS_REQUIRED_NO	(UINT32_C(0x0) << 1)
+	/* Yes */
+		#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_TLV_FLAGS_REQUIRED_YES   (UINT32_C(0x1) << 1)
+		#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_TLV_FLAGS_REQUIRED_LAST CREQ_QUERY_ROCE_CC_RESP_SB_TLV_TLV_FLAGS_REQUIRED_YES
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * This field defines the TLV type value which is divided into
+	 * two ranges to differentiate between global and local TLV types.
+	 * Global TLV types must be unique across all defined TLV types.
+	 * Local TLV types are valid only for extensions to a given
+	 * HWRM message and may be repeated across different HWRM message
+	 * types. There is a direct correlation of each HWRM message type
+	 * to a single global TLV type value.
+	 *
+	 * Global TLV range: `0 - (63k-1)`
+	 *
+	 * Local TLV range: `63k - (64k-1)`
 	 */
-	uint64_t	resp_addr;
-} hwrm_fw_get_time_input_t, *phwrm_fw_get_time_input_t;
-
-/* hwrm_fw_get_time_output (size:192b/24B) */
-
-typedef struct hwrm_fw_get_time_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Current year */
-	uint16_t	year;
-	/* Date/time is not known */
-	#define HWRM_FW_GET_TIME_OUTPUT_YEAR_UNKNOWN UINT32_C(0x0)
-	#define HWRM_FW_GET_TIME_OUTPUT_YEAR_LAST   HWRM_FW_GET_TIME_OUTPUT_YEAR_UNKNOWN
-	/* Current month of year (1-12) */
-	uint8_t	month;
-	/* Current day of month (1-31) */
-	uint8_t	day;
-	/* Current hour (0-23) */
-	uint8_t	hour;
-	/* Current minute (0-59) */
-	uint8_t	minute;
-	/* Current second (0-59) */
-	uint8_t	second;
-	uint8_t	unused_0;
-	/* Current millisecond (0-999) */
-	uint16_t	millisecond;
-	/* Minutes east of UTC, 0xffff if TZ is not known */
-	int16_t	zone;
-	/* Time zone is Coordinated Universal Time (UTC) */
-	#define HWRM_FW_GET_TIME_OUTPUT_ZONE_UTC	0
-	/* Time zone is not known */
-	#define HWRM_FW_GET_TIME_OUTPUT_ZONE_UNKNOWN 65535
-	#define HWRM_FW_GET_TIME_OUTPUT_ZONE_LAST   HWRM_FW_GET_TIME_OUTPUT_ZONE_UNKNOWN
-	uint8_t	unused_1[3];
+	uint16_t	tlv_type;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * Length of the message data encapsulated by this TLV in bytes.
+	 * This length does not include the size of the TLV header itself
+	 * and it must be an integer multiple of 8B.
 	 */
-	uint8_t	valid;
-} hwrm_fw_get_time_output_t, *phwrm_fw_get_time_output_t;
-
-/* hwrm_struct_hdr (size:128b/16B) */
-
-typedef struct hwrm_struct_hdr {
-	/* This value indicates the structured data ID. */
-	uint16_t	struct_id;
-	/* LLDP configuration structured data ID. */
-	#define HWRM_STRUCT_HDR_STRUCT_ID_LLDP_CFG	UINT32_C(0x41b)
-	/* DCBX ETS configuration structured data ID. */
-	#define HWRM_STRUCT_HDR_STRUCT_ID_DCBX_ETS	UINT32_C(0x41d)
-	/* DCBX PFC configuration structured data ID. */
-	#define HWRM_STRUCT_HDR_STRUCT_ID_DCBX_PFC	UINT32_C(0x41f)
-	/* DCBX APP configuration structured data ID. */
-	#define HWRM_STRUCT_HDR_STRUCT_ID_DCBX_APP	UINT32_C(0x421)
-	/* DCBX state configuration structured data ID for all DCBX features. */
-	#define HWRM_STRUCT_HDR_STRUCT_ID_DCBX_FEATURE_STATE UINT32_C(0x422)
-	/* LLDP generic structured data ID. This is used with GET_STRUCTURED_DATA only. */
-	#define HWRM_STRUCT_HDR_STRUCT_ID_LLDP_GENERIC	UINT32_C(0x424)
-	/* LLDP device structured data ID. This is used with GET_STRUCTURED_DATA only. */
-	#define HWRM_STRUCT_HDR_STRUCT_ID_LLDP_DEVICE	UINT32_C(0x426)
-	/* Power Backup info */
-	#define HWRM_STRUCT_HDR_STRUCT_ID_POWER_BKUP	UINT32_C(0x427)
-	/* reserved for AFM usage. */
-	#define HWRM_STRUCT_HDR_STRUCT_ID_AFM_OPAQUE	UINT32_C(0x1)
-	/* Port description. */
-	#define HWRM_STRUCT_HDR_STRUCT_ID_PORT_DESCRIPTION   UINT32_C(0xa)
-	/* RSSv2 Configuration. */
-	#define HWRM_STRUCT_HDR_STRUCT_ID_RSS_V2		UINT32_C(0x64)
-	/* MSI-X vectors per VF table. */
-	#define HWRM_STRUCT_HDR_STRUCT_ID_MSIX_PER_VF	UINT32_C(0xc8)
-	#define HWRM_STRUCT_HDR_STRUCT_ID_LAST		HWRM_STRUCT_HDR_STRUCT_ID_MSIX_PER_VF
-	/* This value indicates the length of structured data. */
-	uint16_t	len;
-	/* This value indicates the version of structured data. */
-	uint8_t	version;
-	/* This value indicates the number of structured data elements. */
-	uint8_t	count;
-	/* This value indicates the subtype. */
-	uint16_t	subtype;
+	uint16_t	length;
 	/*
-	 * This value indicates the count of 64-bit values that point to the next header.
-	 * A value of 0 means that this is the last element.  The value is a count of 64-bit
-	 * words from the beginning of the current header.
+	 * Size of the tlv encapsulated response,
+	 * including all tlvs and extension data in 16-byte units.
 	 */
-	uint16_t	next_offset;
-	/* This value indicates this is the last element */
-	#define HWRM_STRUCT_HDR_NEXT_OFFSET_LAST UINT32_C(0x0)
-	uint8_t	unused_0[6];
-} hwrm_struct_hdr_t, *phwrm_struct_hdr_t;
-
-/* hwrm_struct_data_dcbx_ets (size:256b/32B) */
-
-typedef struct hwrm_struct_data_dcbx_ets {
+	uint8_t	total_size;
+	uint8_t	reserved56[7];
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Query congestion control response. */
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_OPCODE_QUERY_ROCE_CC UINT32_C(0x8d)
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_OPCODE_LAST	CREQ_QUERY_ROCE_CC_RESP_SB_TLV_OPCODE_QUERY_ROCE_CC
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	uint8_t	enable_cc;
+	/* Enable. */
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_ENABLE_CC	UINT32_C(0x1)
+	/* unused7 is 7 b */
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_UNUSED7_MASK  UINT32_C(0xfe)
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_UNUSED7_SFT   1
+	uint8_t	tos_dscp_tos_ecn;
+	/* IP TOS ECN. */
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_TOS_ECN_MASK UINT32_C(0x3)
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_TOS_ECN_SFT  0
+	/* IP TOS DSCP. */
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_TOS_DSCP_MASK UINT32_C(0xfc)
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_TOS_DSCP_SFT 2
+	/* Congestion Probability averaging factor. */
+	uint8_t	g;
+	/* Number of phases in Fast Recovery and Active Increase. */
+	uint8_t	num_phases_per_state;
+	/* The starting value of rate. */
+	uint16_t	init_cr;
+	/* The starting value of target rate. */
+	uint16_t	init_tr;
+	uint8_t	alt_vlan_pcp;
+	/* Alternate vlan pcp value for CNP packets. */
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_ALT_VLAN_PCP_MASK UINT32_C(0x7)
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_ALT_VLAN_PCP_SFT 0
+	/* rsvd1 is 5 b */
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_RSVD1_MASK	UINT32_C(0xf8)
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_RSVD1_SFT	3
+	uint8_t	alt_tos_dscp;
+	/* Alternate IP TOS DSCP. */
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_ALT_TOS_DSCP_MASK UINT32_C(0x3f)
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_ALT_TOS_DSCP_SFT 0
+	/* rsvd4 is 2 b */
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_RSVD4_MASK	UINT32_C(0xc0)
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_RSVD4_SFT	6
+	uint8_t	cc_mode;
+	/* DCTCP CC algorithm. */
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_CC_MODE_DCTCP	UINT32_C(0x0)
 	/*
-	 * This field indicates if this configuration is ETS recommendation or ETS configuration.
-	 * A value 1 means it is ETS configuration, A value of 2 means it is a ETS recommendation.
+	 * Probabilistic marking CC algorithm. On chips with CC Gen 0
+	 * support this will be TCP CC algorithm.
 	 */
-	uint8_t	destination;
-	/* ETS configuration */
-	#define HWRM_STRUCT_DATA_DCBX_ETS_DESTINATION_CONFIGURATION   UINT32_C(0x1)
-	/* ETS recommendation */
-	#define HWRM_STRUCT_DATA_DCBX_ETS_DESTINATION_RECOMMMENDATION UINT32_C(0x2)
-	#define HWRM_STRUCT_DATA_DCBX_ETS_DESTINATION_LAST	HWRM_STRUCT_DATA_DCBX_ETS_DESTINATION_RECOMMMENDATION
-	/* This value indicates maximum ETS TCs supported. */
-	uint8_t	max_tcs;
-	/* unused. */
-	uint16_t	unused1;
-	/* ETS priority 0 to TC map. */
-	uint8_t	pri0_to_tc_map;
-	/* ETS priority 1 to TC map. */
-	uint8_t	pri1_to_tc_map;
-	/* ETS priority 2 to TC map. */
-	uint8_t	pri2_to_tc_map;
-	/* ETS priority 3 to TC map. */
-	uint8_t	pri3_to_tc_map;
-	/* ETS priority 4 to TC map. */
-	uint8_t	pri4_to_tc_map;
-	/* ETS priority 5 to TC map. */
-	uint8_t	pri5_to_tc_map;
-	/* ETS priority 6 to TC map. */
-	uint8_t	pri6_to_tc_map;
-	/* ETS priority 7 to TC map. */
-	uint8_t	pri7_to_tc_map;
-	/* ETS TC 0 to bandwidth map. */
-	uint8_t	tc0_to_bw_map;
-	/* ETS TC 1 to bandwidth map. */
-	uint8_t	tc1_to_bw_map;
-	/* ETS TC 2 to bandwidth map. */
-	uint8_t	tc2_to_bw_map;
-	/* ETS TC 3 to bandwidth map. */
-	uint8_t	tc3_to_bw_map;
-	/* ETS TC 4 to bandwidth map. */
-	uint8_t	tc4_to_bw_map;
-	/* ETS TC 5 to bandwidth map. */
-	uint8_t	tc5_to_bw_map;
-	/* ETS TC 6 to bandwidth map. */
-	uint8_t	tc6_to_bw_map;
-	/* ETS TC 7 to bandwidth map. */
-	uint8_t	tc7_to_bw_map;
-	/* ETS TC 0 to TSA map. */
-	uint8_t	tc0_to_tsa_map;
-	/* strict priority */
-	#define HWRM_STRUCT_DATA_DCBX_ETS_TC0_TO_TSA_MAP_TSA_TYPE_SP		UINT32_C(0x0)
-	/* credit based shaper */
-	#define HWRM_STRUCT_DATA_DCBX_ETS_TC0_TO_TSA_MAP_TSA_TYPE_CBS		UINT32_C(0x1)
-	/* ETS */
-	#define HWRM_STRUCT_DATA_DCBX_ETS_TC0_TO_TSA_MAP_TSA_TYPE_ETS		UINT32_C(0x2)
-	/* vendor specific */
-	#define HWRM_STRUCT_DATA_DCBX_ETS_TC0_TO_TSA_MAP_TSA_TYPE_VENDOR_SPECIFIC UINT32_C(0xff)
-	#define HWRM_STRUCT_DATA_DCBX_ETS_TC0_TO_TSA_MAP_LAST			HWRM_STRUCT_DATA_DCBX_ETS_TC0_TO_TSA_MAP_TSA_TYPE_VENDOR_SPECIFIC
-	/* ETS TC 1 to TSA map. */
-	uint8_t	tc1_to_tsa_map;
-	/* ETS TC 2 to TSA map. */
-	uint8_t	tc2_to_tsa_map;
-	/* ETS TC 3 to TSA map. */
-	uint8_t	tc3_to_tsa_map;
-	/* ETS TC 4 to TSA map. */
-	uint8_t	tc4_to_tsa_map;
-	/* ETS TC 5 to TSA map. */
-	uint8_t	tc5_to_tsa_map;
-	/* ETS TC 6 to TSA map. */
-	uint8_t	tc6_to_tsa_map;
-	/* ETS TC 7 to TSA map. */
-	uint8_t	tc7_to_tsa_map;
-	uint8_t	unused_0[4];
-} hwrm_struct_data_dcbx_ets_t, *phwrm_struct_data_dcbx_ets_t;
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_CC_MODE_PROBABILISTIC UINT32_C(0x1)
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_CC_MODE_LAST	CREQ_QUERY_ROCE_CC_RESP_SB_TLV_CC_MODE_PROBABILISTIC
+	/* Specifies the RoCE Tx Queue to use for sending CNP packets. */
+	uint8_t	tx_queue;
+	uint16_t	rtt;
+	/* Round trip time in units of usecs */
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_RTT_MASK  UINT32_C(0x3fff)
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_RTT_SFT   0
+	/* rsvd5 is 2 b */
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_RSVD5_MASK UINT32_C(0xc000)
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_RSVD5_SFT 14
+	uint16_t	tcp_cp;
+	/* The value used as CP when cc_mode is 1(TCP) */
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_TCP_CP_MASK UINT32_C(0x3ff)
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_TCP_CP_SFT 0
+	/* rsvd6 is 6 b */
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_RSVD6_MASK UINT32_C(0xfc00)
+	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_RSVD6_SFT  10
+	/* Inactivity time after which QP CC parameters are initialized */
+	uint16_t	inactivity_th;
+	/* Number of packets per phase. Max is 255. */
+	uint8_t	pkts_per_phase;
+	/* Amount of time per phase in units of ms. Max is 15 */
+	uint8_t	time_per_phase;
+	uint32_t	reserved32;
+} creq_query_roce_cc_resp_sb_tlv_t, *pcreq_query_roce_cc_resp_sb_tlv_t;
 
-/* hwrm_struct_data_dcbx_pfc (size:64b/8B) */
+/* creq_query_roce_cc_gen1_resp_sb_tlv (size:704b/88B) */
 
-typedef struct hwrm_struct_data_dcbx_pfc {
+typedef struct creq_query_roce_cc_gen1_resp_sb_tlv {
 	/*
-	 * This field indicates PFC priority bit map. A value of '0' indicates PFC
-	 * 		is disabled. A value of '1' indicates PFC is enabled on that priority.
+	 * The command discriminator is used to differentiate between various
+	 * types of HWRM messages. This includes legacy HWRM and RoCE slowpath
+	 * command messages as well as newer TLV encapsulated HWRM commands.
+	 *
+	 * For TLV encapsulated messages this field must be 0x8000.
 	 */
-	uint8_t	pfc_priority_bitmap;
+	uint16_t	cmd_discr;
+	uint8_t	reserved_8b;
+	uint8_t	tlv_flags;
 	/*
-	 * This field indicates max PFC TCs supported. Each PFC TC will map to
-	 * a lossless CoS queue.
+	 * Indicates the presence of additional TLV encapsulated data
+	 * follows this TLV.
 	 */
-	uint8_t	max_pfc_tcs;
+	#define CREQ_QUERY_ROCE_CC_GEN1_RESP_SB_TLV_TLV_FLAGS_MORE	UINT32_C(0x1)
+	/* Last TLV in a sequence of TLVs. */
+		#define CREQ_QUERY_ROCE_CC_GEN1_RESP_SB_TLV_TLV_FLAGS_MORE_LAST	UINT32_C(0x0)
+	/* More TLVs follow this TLV. */
+		#define CREQ_QUERY_ROCE_CC_GEN1_RESP_SB_TLV_TLV_FLAGS_MORE_NOT_LAST  UINT32_C(0x1)
 	/*
-	 * This field indicates if MACSec bypass capability is enabled. A value
-	 * of '1' indicates MBC is enabled. A value of '0' indicates MBC is disabled.
+	 * When an HWRM receiver detects a TLV type that it does not
+	 * support with the TLV required flag set, the receiver must
+	 * reject the HWRM message with an error code indicating an
+	 * unsupported TLV type.
 	 */
-	uint8_t	mbc;
-	uint8_t	unused_0[5];
-} hwrm_struct_data_dcbx_pfc_t, *phwrm_struct_data_dcbx_pfc_t;
-
-/* hwrm_struct_data_dcbx_app (size:64b/8B) */
-
-typedef struct hwrm_struct_data_dcbx_app {
+	#define CREQ_QUERY_ROCE_CC_GEN1_RESP_SB_TLV_TLV_FLAGS_REQUIRED	UINT32_C(0x2)
+	/* No */
+		#define CREQ_QUERY_ROCE_CC_GEN1_RESP_SB_TLV_TLV_FLAGS_REQUIRED_NO	(UINT32_C(0x0) << 1)
+	/* Yes */
+		#define CREQ_QUERY_ROCE_CC_GEN1_RESP_SB_TLV_TLV_FLAGS_REQUIRED_YES   (UINT32_C(0x1) << 1)
+		#define CREQ_QUERY_ROCE_CC_GEN1_RESP_SB_TLV_TLV_FLAGS_REQUIRED_LAST CREQ_QUERY_ROCE_CC_GEN1_RESP_SB_TLV_TLV_FLAGS_REQUIRED_YES
 	/*
-	 * This field indicates the protocol identifier. This should be specified
-	 *		in big endian format.
+	 * This field defines the TLV type value which is divided into
+	 * two ranges to differentiate between global and local TLV types.
+	 * Global TLV types must be unique across all defined TLV types.
+	 * Local TLV types are valid only for extensions to a given
+	 * HWRM message and may be repeated across different HWRM message
+	 * types. There is a direct correlation of each HWRM message type
+	 * to a single global TLV type value.
+	 *
+	 * Global TLV range: `0 - (63k-1)`
+	 *
+	 * Local TLV range: `63k - (64k-1)`
 	 */
-	uint16_t	protocol_id;
+	uint16_t	tlv_type;
 	/*
-	 * This field indicates the protocol selector. The valid values are
-	 *		mentioned below.
-	 */
-	uint8_t	protocol_selector;
-	/* ether type */
-	#define HWRM_STRUCT_DATA_DCBX_APP_PROTOCOL_SELECTOR_ETHER_TYPE   UINT32_C(0x1)
-	/* TCP port */
-	#define HWRM_STRUCT_DATA_DCBX_APP_PROTOCOL_SELECTOR_TCP_PORT	UINT32_C(0x2)
-	/* UDP port */
-	#define HWRM_STRUCT_DATA_DCBX_APP_PROTOCOL_SELECTOR_UDP_PORT	UINT32_C(0x3)
-	/* TCP & UDP port */
-	#define HWRM_STRUCT_DATA_DCBX_APP_PROTOCOL_SELECTOR_TCP_UDP_PORT UINT32_C(0x4)
-	#define HWRM_STRUCT_DATA_DCBX_APP_PROTOCOL_SELECTOR_LAST	HWRM_STRUCT_DATA_DCBX_APP_PROTOCOL_SELECTOR_TCP_UDP_PORT
-	/* This field indicates application priority. */
-	uint8_t	priority;
-	/* This field indicates this entry is valid. */
-	uint8_t	valid;
-	uint8_t	unused_0[3];
-} hwrm_struct_data_dcbx_app_t, *phwrm_struct_data_dcbx_app_t;
-
-/* hwrm_struct_data_dcbx_feature_state (size:64b/8B) */
-
-typedef struct hwrm_struct_data_dcbx_feature_state {
-	/* DCBX mode - IEEE or CEE. This is read only field. */
-	uint8_t	dcbx_mode;
-	/* DCBX disabled mode. */
-	#define HWRM_STRUCT_DATA_DCBX_FEATURE_STATE_DCBX_MODE_DCBX_DISABLED UINT32_C(0x0)
-	/* DCBX IEEE mode. */
-	#define HWRM_STRUCT_DATA_DCBX_FEATURE_STATE_DCBX_MODE_DCBX_IEEE	UINT32_C(0x1)
-	/* DCBX CEE mode. */
-	#define HWRM_STRUCT_DATA_DCBX_FEATURE_STATE_DCBX_MODE_DCBX_CEE	UINT32_C(0x2)
-	#define HWRM_STRUCT_DATA_DCBX_FEATURE_STATE_DCBX_MODE_LAST	HWRM_STRUCT_DATA_DCBX_FEATURE_STATE_DCBX_MODE_DCBX_CEE
-	/* ETS TLV state. */
-	uint8_t	ets_state;
-	/* PFC TLV state. */
-	uint8_t	pfc_state;
-	/* App TLV state. */
-	uint8_t	app_state;
-	/* Feature enable bit position. */
-	#define HWRM_STRUCT_DATA_DCBX_FEATURE_STATE_APP_STATE_ENABLE_BIT_POS	UINT32_C(0x7)
-	/* Feature willing bit position. */
-	#define HWRM_STRUCT_DATA_DCBX_FEATURE_STATE_APP_STATE_WILLING_BIT_POS   UINT32_C(0x6)
-	/* Feature advertise bit position. */
-	#define HWRM_STRUCT_DATA_DCBX_FEATURE_STATE_APP_STATE_ADVERTISE_BIT_POS UINT32_C(0x5)
-	#define HWRM_STRUCT_DATA_DCBX_FEATURE_STATE_APP_STATE_LAST		HWRM_STRUCT_DATA_DCBX_FEATURE_STATE_APP_STATE_ADVERTISE_BIT_POS
-	/* unused. */
-	uint8_t	unused[3];
-	/* This field is used to reset the DCBX configuration to factory defaults. */
-	uint8_t	resets;
-	/* reset ETS configuration. */
-	#define HWRM_STRUCT_DATA_DCBX_FEATURE_STATE_RESETS_RESET_ETS   UINT32_C(0x1)
-	/* reset PFC configuration. */
-	#define HWRM_STRUCT_DATA_DCBX_FEATURE_STATE_RESETS_RESET_PFC   UINT32_C(0x2)
-	/* reset application configuration. */
-	#define HWRM_STRUCT_DATA_DCBX_FEATURE_STATE_RESETS_RESET_APP   UINT32_C(0x4)
-	/* reset DCBX state configuration. */
-	#define HWRM_STRUCT_DATA_DCBX_FEATURE_STATE_RESETS_RESET_STATE UINT32_C(0x8)
-	#define HWRM_STRUCT_DATA_DCBX_FEATURE_STATE_RESETS_LAST	HWRM_STRUCT_DATA_DCBX_FEATURE_STATE_RESETS_RESET_STATE
-} hwrm_struct_data_dcbx_feature_state_t, *phwrm_struct_data_dcbx_feature_state_t;
-
-/* hwrm_struct_data_lldp (size:64b/8B) */
-
-typedef struct hwrm_struct_data_lldp {
-	/* Port admin state */
-	uint8_t	admin_state;
-	/* Disable both Tx and Rx */
-	#define HWRM_STRUCT_DATA_LLDP_ADMIN_STATE_DISABLE UINT32_C(0x0)
-	/* Enable Tx only */
-	#define HWRM_STRUCT_DATA_LLDP_ADMIN_STATE_TX	UINT32_C(0x1)
-	/* Enable Rx only */
-	#define HWRM_STRUCT_DATA_LLDP_ADMIN_STATE_RX	UINT32_C(0x2)
-	/* Enable both Tx and Rx */
-	#define HWRM_STRUCT_DATA_LLDP_ADMIN_STATE_ENABLE  UINT32_C(0x3)
-	#define HWRM_STRUCT_DATA_LLDP_ADMIN_STATE_LAST   HWRM_STRUCT_DATA_LLDP_ADMIN_STATE_ENABLE
-	/* Port description TLV transmit state (enable(1)/disable(0)). */
-	uint8_t	port_description_state;
-	/* Disable */
-	#define HWRM_STRUCT_DATA_LLDP_PORT_DESCRIPTION_STATE_DISABLE UINT32_C(0x0)
-	/* Enable. */
-	#define HWRM_STRUCT_DATA_LLDP_PORT_DESCRIPTION_STATE_ENABLE  UINT32_C(0x1)
-	#define HWRM_STRUCT_DATA_LLDP_PORT_DESCRIPTION_STATE_LAST   HWRM_STRUCT_DATA_LLDP_PORT_DESCRIPTION_STATE_ENABLE
-	/* System name TLV transmit state (enable(1)/disable(0)). */
-	uint8_t	system_name_state;
-	/* Disable */
-	#define HWRM_STRUCT_DATA_LLDP_SYSTEM_NAME_STATE_DISABLE UINT32_C(0x0)
-	/* Enable. */
-	#define HWRM_STRUCT_DATA_LLDP_SYSTEM_NAME_STATE_ENABLE  UINT32_C(0x1)
-	#define HWRM_STRUCT_DATA_LLDP_SYSTEM_NAME_STATE_LAST   HWRM_STRUCT_DATA_LLDP_SYSTEM_NAME_STATE_ENABLE
-	/* System description TLV transmit state (enable(1)/disable(0)). */
-	uint8_t	system_desc_state;
-	/* Disable */
-	#define HWRM_STRUCT_DATA_LLDP_SYSTEM_DESC_STATE_DISABLE UINT32_C(0x0)
-	/* Enable. */
-	#define HWRM_STRUCT_DATA_LLDP_SYSTEM_DESC_STATE_ENABLE  UINT32_C(0x1)
-	#define HWRM_STRUCT_DATA_LLDP_SYSTEM_DESC_STATE_LAST   HWRM_STRUCT_DATA_LLDP_SYSTEM_DESC_STATE_ENABLE
-	/* System capabilities TLV transmit state (enable(1)/disable(0)). */
-	uint8_t	system_cap_state;
-	/* Disable */
-	#define HWRM_STRUCT_DATA_LLDP_SYSTEM_CAP_STATE_DISABLE UINT32_C(0x0)
-	/* Enable. */
-	#define HWRM_STRUCT_DATA_LLDP_SYSTEM_CAP_STATE_ENABLE  UINT32_C(0x1)
-	#define HWRM_STRUCT_DATA_LLDP_SYSTEM_CAP_STATE_LAST   HWRM_STRUCT_DATA_LLDP_SYSTEM_CAP_STATE_ENABLE
-	/* Management address TLV transmit state (enable(1)/disable(0)). */
-	uint8_t	mgmt_addr_state;
-	/* Disable */
-	#define HWRM_STRUCT_DATA_LLDP_MGMT_ADDR_STATE_DISABLE UINT32_C(0x0)
-	/* Enable. */
-	#define HWRM_STRUCT_DATA_LLDP_MGMT_ADDR_STATE_ENABLE  UINT32_C(0x1)
-	#define HWRM_STRUCT_DATA_LLDP_MGMT_ADDR_STATE_LAST   HWRM_STRUCT_DATA_LLDP_MGMT_ADDR_STATE_ENABLE
-	/* Async event notification state (enable(1)/disable(0)). */
-	uint8_t	async_event_notification_state;
-	/* Disable */
-	#define HWRM_STRUCT_DATA_LLDP_ASYNC_EVENT_NOTIFICATION_STATE_DISABLE UINT32_C(0x0)
-	/* Enable. */
-	#define HWRM_STRUCT_DATA_LLDP_ASYNC_EVENT_NOTIFICATION_STATE_ENABLE  UINT32_C(0x1)
-	#define HWRM_STRUCT_DATA_LLDP_ASYNC_EVENT_NOTIFICATION_STATE_LAST   HWRM_STRUCT_DATA_LLDP_ASYNC_EVENT_NOTIFICATION_STATE_ENABLE
-	uint8_t	unused_0;
-} hwrm_struct_data_lldp_t, *phwrm_struct_data_lldp_t;
-
-/* hwrm_struct_data_lldp_generic (size:2112b/264B) */
-
-typedef struct hwrm_struct_data_lldp_generic {
-	/* TLV type. */
-	uint8_t	tlv_type;
-	/* Chassis ID TLV */
-	#define HWRM_STRUCT_DATA_LLDP_GENERIC_TLV_TYPE_CHASSIS		UINT32_C(0x1)
-	/* Port ID TLV */
-	#define HWRM_STRUCT_DATA_LLDP_GENERIC_TLV_TYPE_PORT		UINT32_C(0x2)
-	/* System name TLV */
-	#define HWRM_STRUCT_DATA_LLDP_GENERIC_TLV_TYPE_SYSTEM_NAME	UINT32_C(0x3)
-	/* System description TLV */
-	#define HWRM_STRUCT_DATA_LLDP_GENERIC_TLV_TYPE_SYSTEM_DESCRIPTION UINT32_C(0x4)
-	/* Port name TLV */
-	#define HWRM_STRUCT_DATA_LLDP_GENERIC_TLV_TYPE_PORT_NAME	UINT32_C(0x5)
-	/* Port description TLV */
-	#define HWRM_STRUCT_DATA_LLDP_GENERIC_TLV_TYPE_PORT_DESCRIPTION   UINT32_C(0x6)
-	#define HWRM_STRUCT_DATA_LLDP_GENERIC_TLV_TYPE_LAST		HWRM_STRUCT_DATA_LLDP_GENERIC_TLV_TYPE_PORT_DESCRIPTION
-	/* TLV sub-type. */
-	uint8_t	subtype;
-	/* Length. */
-	uint8_t	length;
-	/* unused. */
-	uint8_t	unused1[5];
-	/* TLV value. */
-	uint32_t	tlv_value[64];
-} hwrm_struct_data_lldp_generic_t, *phwrm_struct_data_lldp_generic_t;
-
-/* hwrm_struct_data_lldp_device (size:1472b/184B) */
-
-typedef struct hwrm_struct_data_lldp_device {
-	/* Time to Live. */
-	uint16_t	ttl;
-	/* Management address length. */
-	uint8_t	mgmt_addr_len;
-	/* Management address type. */
-	uint8_t	mgmt_addr_type;
-	uint8_t	unused_3[4];
-	/* Management address. */
-	uint32_t	mgmt_addr[8];
-	/* System capabilities. */
-	uint32_t	system_caps;
-	/* Interface number type. */
-	uint8_t	intf_num_type;
-	/* Management address OID length. */
-	uint8_t	mgmt_addr_oid_length;
-	uint8_t	unused_4[2];
-	/* Interface number. */
-	uint32_t	intf_num;
-	uint8_t	unused_5[4];
-	/* Management address OID. */
-	uint32_t	mgmt_addr_oid[32];
-} hwrm_struct_data_lldp_device_t, *phwrm_struct_data_lldp_device_t;
-
-/* hwrm_struct_data_port_description (size:64b/8B) */
-
-typedef struct hwrm_struct_data_port_description {
+	 * Length of the message data encapsulated by this TLV in bytes.
+	 * This length does not include the size of the TLV header itself
+	 * and it must be an integer multiple of 8B.
+	 */
+	uint16_t	length;
+	uint64_t	reserved64;
+	/* High order bits of inactivity threshold. */
+	uint16_t	inactivity_th_hi;
 	/*
-	 * Port #.  Port number starts at 0 and anything greater than number of ports
-	 *		minus 1 is an error.
+	 * The number of uS between generation of CNPs when cc_mode is
+	 * probabilistic marking.
 	 */
-	uint8_t	port_id;
-	uint8_t	unused_0[7];
-} hwrm_struct_data_port_description_t, *phwrm_struct_data_port_description_t;
-
-/* hwrm_struct_data_rss_v2 (size:128b/16B) */
-
-typedef struct hwrm_struct_data_rss_v2 {
-	uint16_t	flags;
-	/* When this bit is '1', the hash type and hash key are included. */
-	#define HWRM_STRUCT_DATA_RSS_V2_FLAGS_HASH_VALID	UINT32_C(0x1)
-	/* RSS Context index. */
-	uint16_t	rss_ctx_id;
-	/* Number ring group IDs. */
-	uint16_t	num_ring_groups;
-	uint16_t	hash_type;
+	uint16_t	min_time_between_cnps;
 	/*
-	 * When this bit is '1', the RSS hash shall be computed
-	 * over source and destination IPv4 addresses of IPv4
-	 * packets.
+	 * The starting value of congestion probability. Input range
+	 * is 0 - 1023.
 	 */
-	#define HWRM_STRUCT_DATA_RSS_V2_HASH_TYPE_IPV4	UINT32_C(0x1)
+	uint16_t	init_cp;
 	/*
-	 * When this bit is '1', the RSS hash shall be computed
-	 * over source/destination IPv4 addresses and
-	 * source/destination ports of TCP/IPv4 packets.
+	 * In tr_update_mode 0, Target Rate (TR) is updated to
+	 * halfway between the Current Rate (CR) before and after reduction.
+	 * In tr_update_mode 1, TR is updated to CR's value before reduction.
 	 */
-	#define HWRM_STRUCT_DATA_RSS_V2_HASH_TYPE_TCP_IPV4	UINT32_C(0x2)
+	uint8_t	tr_update_mode;
 	/*
-	 * When this bit is '1', the RSS hash shall be computed
-	 * over source/destination IPv4 addresses and
-	 * source/destination ports of UDP/IPv4 packets.
+	 * Determine for how many RTTs with CNPs in a row, TR is being updated.
+	 * 0: TR is updated when QPC. rtts_with_cnps == 0
+	 * 1-6: TR is updated if QPC. rtts_with_cnps <= tr_update_cycles
+	 * 7: TR is updated on all reductions.
 	 */
-	#define HWRM_STRUCT_DATA_RSS_V2_HASH_TYPE_UDP_IPV4	UINT32_C(0x4)
+	uint8_t	tr_update_cycles;
+	/* Number of RTTs in Fast Recovery stage. */
+	uint8_t	fr_num_rtts;
+	/* Time increment to increase TR in active increase phase. */
+	uint8_t	ai_rate_increase;
 	/*
-	 * When this bit is '1', the RSS hash shall be computed
-	 * over source and destination IPv4 addresses of IPv6
-	 * packets.
+	 * Indicates for how many RTTs with CNPs after the first one
+	 * to not reduce rate even if CNPs are received.
 	 */
-	#define HWRM_STRUCT_DATA_RSS_V2_HASH_TYPE_IPV6	UINT32_C(0x8)
+	uint16_t	reduction_relax_rtts_th;
 	/*
-	 * When this bit is '1', the RSS hash shall be computed
-	 * over source/destination IPv6 addresses and
-	 * source/destination ports of TCP/IPv6 packets.
+	 * For low rates, additional number of RTTS with CNPs
+	 * for which no rate reduction is made.
+	 * num_bits: 14
 	 */
-	#define HWRM_STRUCT_DATA_RSS_V2_HASH_TYPE_TCP_IPV6	UINT32_C(0x10)
+	uint16_t	additional_relax_cr_th;
 	/*
-	 * When this bit is '1', the RSS hash shall be computed
-	 * over source/destination IPv6 addresses and
-	 * source/destination ports of UDP/IPv6 packets.
+	 * If CR is less than or equal to this value,
+	 * then the actual CR average is set to this value
+	 * (shifted by bw_avg_weight).
 	 */
-	#define HWRM_STRUCT_DATA_RSS_V2_HASH_TYPE_UDP_IPV6	UINT32_C(0x20)
-	/* Hash key. This field is optional. */
-	uint64_t	hash_key_ring_group_ids;
-} hwrm_struct_data_rss_v2_t, *phwrm_struct_data_rss_v2_t;
-
-/* hwrm_struct_data_power_information (size:192b/24B) */
-
-typedef struct hwrm_struct_data_power_information {
-	/* Backup power information version */
-	uint32_t	bkup_power_info_ver;
-	/* Platform backup power count */
-	uint32_t	platform_bkup_power_count;
-	/* Load in milli Watt */
-	uint32_t	load_milli_watt;
-	/* Backup time in milli seconds */
-	uint32_t	bkup_time_milli_seconds;
-	/* Backup power status */
-	uint32_t	bkup_power_status;
-	/* Backup power charge time */
-	uint32_t	bkup_power_charge_time;
-} hwrm_struct_data_power_information_t, *phwrm_struct_data_power_information_t;
-
-/* hwrm_struct_data_msix_per_vf (size:320b/40B) */
-
-typedef struct hwrm_struct_data_msix_per_vf {
-	/* PF ID */
-	uint16_t	pf_id;
-	/* Number of rows in table. */
-	uint16_t	count;
-	uint32_t	unused_0;
-	/* Starting VF for row 0 */
-	uint16_t	start_vf_0;
-	/* MSI-X vectors per VF for row 0 */
-	uint16_t	msix_0;
-	/* Starting VF for row 1 */
-	uint16_t	start_vf_1;
-	/* MSI-X vectors per VF for row 1 */
-	uint16_t	msix_1;
-	/* Starting VF for row 2 */
-	uint16_t	start_vf_2;
-	/* MSI-X vectors per VF for row 2 */
-	uint16_t	msix_2;
-	/* Starting VF for row 3 */
-	uint16_t	start_vf_3;
-	/* MSI-X vectors per VF for row 3 */
-	uint16_t	msix_3;
-	/* Starting VF for row 4 */
-	uint16_t	start_vf_4;
-	/* MSI-X vectors per VF for row 4 */
-	uint16_t	msix_4;
-	/* Starting VF for row 5 */
-	uint16_t	start_vf_5;
-	/* MSI-X vectors per VF for row 5 */
-	uint16_t	msix_5;
-	/* Starting VF for row 6 */
-	uint16_t	start_vf_6;
-	/* MSI-X vectors per VF for row 6 */
-	uint16_t	msix_6;
-	/* Starting VF for row 7 */
-	uint16_t	start_vf_7;
-	/* MSI-X vectors per VF for row 7 */
-	uint16_t	msix_7;
-} hwrm_struct_data_msix_per_vf_t, *phwrm_struct_data_msix_per_vf_t;
-
-/*******************
- * hwrm_fw_ecn_cfg *
- *******************/
-
-
-/* hwrm_fw_ecn_cfg_input (size:192b/24B) */
-
-typedef struct hwrm_fw_ecn_cfg_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	uint16_t	cr_min_th;
+	/* Log based averaging weight for QPC variable actual_cr_avg. */
+	uint8_t	bw_avg_weight;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * Used to compare CR to this factor times QPC.actual_cr_average
+	 * as a reduction reference. Values between 0 and 6 represent factor of
+	 * 1.125, 1.25, 1.5, 1.75, 2, 2.25, 2.5 respectively.
 	 */
-	uint16_t	cmpl_ring;
+	uint8_t	actual_cr_factor;
+	/* The level of CR above which CP is set to maximum level. */
+	uint16_t	max_cp_cr_th;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Enable adding fraction of CR to CP.
+	 * 0 for disable, 1 for enable.
 	 */
-	uint16_t	seq_id;
+	uint8_t	cp_bias_en;
+	/* Log based fraction of cr to add to CP when cp_bias_en is 1. */
+	uint8_t	cp_bias;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * The value of ECN bits in a CNP packet generated by hardware.
+	 * ECN-Capable Transport (ECT) codepoints supported include:
+	 * 0 for not_ect, 1 for ect_0, 2 for ect_1
 	 */
-	uint16_t	target_id;
+	uint8_t	cnp_ecn;
+	/* Not ECN capable Transport */
+	#define CREQ_QUERY_ROCE_CC_GEN1_RESP_SB_TLV_CNP_ECN_NOT_ECT UINT32_C(0x0)
+	/* ECN Capable Transport-1 */
+	#define CREQ_QUERY_ROCE_CC_GEN1_RESP_SB_TLV_CNP_ECN_ECT_1   UINT32_C(0x1)
+	/* ECN Capable Transport-0 */
+	#define CREQ_QUERY_ROCE_CC_GEN1_RESP_SB_TLV_CNP_ECN_ECT_0   UINT32_C(0x2)
+	#define CREQ_QUERY_ROCE_CC_GEN1_RESP_SB_TLV_CNP_ECN_LAST   CREQ_QUERY_ROCE_CC_GEN1_RESP_SB_TLV_CNP_ECN_ECT_0
+	/* Enables jitter in RTT. */
+	uint8_t	rtt_jitter_en;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Number of bytes per usec, dependent on port speed.
+	 * 200 Gbps: 25,000
+	 * 100 Gbps: 12,500
+	 * 50 Gbps: 6,250
+	 * 25 Gbps: 3125
+	 * 10 Gbps: 1250
 	 */
-	uint64_t	resp_addr;
-	uint16_t	flags;
+	uint16_t	link_bytes_per_usec;
 	/*
-	 * When this bit is '1', Explicit Congestion Notification (ECN) is
-	 * enabled device-wide. When ECN is enabled on a multi-host system,
-	 * it is enabled for all hosts. This setting takes effect
-	 * immediately. When ECN is enabled, the firmware activates
-	 * additional receive Class of Service (CoS) queues that are enabled
-	 * for ECN marking and steers ECN-capable packets to those queues.
-	 * This setting is not saved persistently. To enable ECN
-	 * persistently, set NVM option 173, ENABLE_ECN.
-	 * Setting this bit to '0' disables ECN immediately.
+	 * If CR is greater than or equal to this threshold,
+	 * QPC's CC state is reset to its initial state.
 	 */
-	#define HWRM_FW_ECN_CFG_INPUT_FLAGS_ENABLE_ECN	UINT32_C(0x1)
-	uint8_t	unused_0[6];
-} hwrm_fw_ecn_cfg_input_t, *phwrm_fw_ecn_cfg_input_t;
-
-/* hwrm_fw_ecn_cfg_output (size:128b/16B) */
-
-typedef struct hwrm_fw_ecn_cfg_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	uint16_t	reset_cc_cr_th;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * The number of valid lsbits in CR and TR.
+	 * Supported values include 10 through 14 to support 2^cr_width rate.
 	 */
-	uint8_t	valid;
-} hwrm_fw_ecn_cfg_output_t, *phwrm_fw_ecn_cfg_output_t;
-
-/********************
- * hwrm_fw_ecn_qcfg *
- ********************/
-
-
-/* hwrm_fw_ecn_qcfg_input (size:128b/16B) */
-
-typedef struct hwrm_fw_ecn_qcfg_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	uint8_t	cr_width;
+	/* Lower end of random selection of quota_period. */
+	uint8_t	quota_period_min;
+	/* Upper end of random selection of quota_period. */
+	uint8_t	quota_period_max;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * The absolute maximum possible quota_period,
+	 * applicable when rate table for lower 24 levels is used.
 	 */
-	uint16_t	cmpl_ring;
+	uint8_t	quota_period_abs_max;
+	/* TR never goes below this level. */
+	uint16_t	tr_lower_bound;
+	/* Factor on probability threshold for adding 0.5 to CR randomly. */
+	uint8_t	cr_prob_factor;
+	/* Factor on probability threshold for adding 0.5 to TR randomly. */
+	uint8_t	tr_prob_factor;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Threshold to ensure fairness between requester and responder.
+	 * If CR is less than the fairness threshold and a quota period has
+	 * passed priority will be given to the path that did not last
+	 * transfer data.
 	 */
-	uint16_t	seq_id;
+	uint16_t	fairness_cr_th;
+	/* Log based rate reduction divider. */
+	uint8_t	red_div;
+	/* Threshold for rate reductions when CNPS received over last RTT. */
+	uint8_t	cnp_ratio_th;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Extended number of RTTS to wait, when there is no congestion,
+	 * to start doubling the rate.
 	 */
-	uint16_t	target_id;
+	uint16_t	exp_ai_rtts;
+	/* Log based CR to CP ratio used in exponential increase. */
+	uint8_t	exp_ai_cr_cp_ratio;
+	/* Enable use of lowest 24 rate levels rate_table. */
+	uint8_t	use_rate_table;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Determines after how many congestion free RTTs to start
+	 * updating CP to track CR.
 	 */
-	uint64_t	resp_addr;
-} hwrm_fw_ecn_qcfg_input_t, *phwrm_fw_ecn_qcfg_input_t;
-
-/* hwrm_fw_ecn_qcfg_output (size:128b/16B) */
-
-typedef struct hwrm_fw_ecn_qcfg_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint16_t	flags;
-	/* When this bit is '1', ECN is enabled device-wide. */
-	#define HWRM_FW_ECN_QCFG_OUTPUT_FLAGS_ENABLE_ECN	UINT32_C(0x1)
-	uint8_t	unused_0[5];
+	uint16_t	cp_exp_update_th;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * The threshold on congestion free RTTs above which AI can increase
+	 * to 16.
 	 */
-	uint8_t	valid;
-} hwrm_fw_ecn_qcfg_output_t, *phwrm_fw_ecn_qcfg_output_t;
-
-/************************
- * hwrm_fw_health_check *
- ************************/
-
+	uint16_t	high_exp_ai_rtts_th1;
+	/*
+	 * The threshold on congestion free RTTs above which AI can increase
+	 * to 32.
+	 */
+	uint16_t	high_exp_ai_rtts_th2;
+	/*
+	 * The number of congestion free RTTs above which
+	 * reduction based on actual rate is enabled.
+	 */
+	uint16_t	actual_cr_cong_free_rtts_th;
+	/*
+	 * If rtts_with_cong is greater than 7 (severe congestion) and
+	 * CR level post reduction is above this threshold,
+	 * then TR is capped to 1.5 times CR..
+	 */
+	uint16_t	severe_cong_cr_th1;
+	/*
+	 * If rtts_with_cong is greater than 7 (severe congestion) and
+	 * CR level post reduction is above this threshold,
+	 * then TR is capped to 1.25 times CR..
+	 */
+	uint16_t	severe_cong_cr_th2;
+	/*
+	 * The maximum number of 64B that can be transmitted during RTT time,
+	 * including all headers and Inter Packet Gap.
+	 */
+	uint32_t	link64B_per_rtt;
+	/*
+	 * The number of bytes to subtract from QPC.cc_bucket
+	 * when an ack is scheduled.
+	 */
+	uint8_t	cc_ack_bytes;
+	/*
+	 * Enables reduction of CR, TR, and CP to init values when
+	 * congestion free RTTs is greater than reduce2_init_cong_free_rtts_th.
+	 */
+	uint8_t	reduce_init_en;
+	/*
+	 * Minimum threshold value for number of congestion free RTTs before
+	 * reducing to init values for CR, TR, and CP when reduce_init_en is
+	 * enabled.
+	 */
+	uint16_t	reduce_init_cong_free_rtts_th;
+	/* Enables random no reduction of CR. */
+	uint8_t	random_no_red_en;
+	/*
+	 * Enables coarse correction to actual CR when actual RTT is longer
+	 * than nominal.
+	 */
+	uint8_t	actual_cr_shift_correction_en;
+	/* Enables adjustment to refill quota. */
+	uint8_t	quota_period_adjust_en;
+	uint8_t	reserved[5];
+} creq_query_roce_cc_gen1_resp_sb_tlv_t, *pcreq_query_roce_cc_gen1_resp_sb_tlv_t;
 
-/* hwrm_fw_health_check_input (size:128b/16B) */
+/* creq_query_roce_cc_gen2_resp_sb_tlv (size:512b/64B) */
 
-typedef struct hwrm_fw_health_check_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+typedef struct creq_query_roce_cc_gen2_resp_sb_tlv {
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * The command discriminator is used to differentiate between various
+	 * types of HWRM messages. This includes legacy HWRM and RoCE slowpath
+	 * command messages as well as newer TLV encapsulated HWRM commands.
+	 *
+	 * For TLV encapsulated messages this field must be 0x8000.
 	 */
-	uint16_t	cmpl_ring;
+	uint16_t	cmd_discr;
+	uint8_t	reserved_8b;
+	uint8_t	tlv_flags;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Indicates the presence of additional TLV encapsulated data
+	 * follows this TLV.
 	 */
-	uint16_t	seq_id;
+	#define CREQ_QUERY_ROCE_CC_GEN2_RESP_SB_TLV_TLV_FLAGS_MORE	UINT32_C(0x1)
+	/* Last TLV in a sequence of TLVs. */
+		#define CREQ_QUERY_ROCE_CC_GEN2_RESP_SB_TLV_TLV_FLAGS_MORE_LAST	UINT32_C(0x0)
+	/* More TLVs follow this TLV. */
+		#define CREQ_QUERY_ROCE_CC_GEN2_RESP_SB_TLV_TLV_FLAGS_MORE_NOT_LAST  UINT32_C(0x1)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * When an HWRM receiver detects a TLV type that it does not
+	 * support with the TLV required flag set, the receiver must
+	 * reject the HWRM message with an error code indicating an
+	 * unsupported TLV type.
 	 */
-	uint16_t	target_id;
+	#define CREQ_QUERY_ROCE_CC_GEN2_RESP_SB_TLV_TLV_FLAGS_REQUIRED	UINT32_C(0x2)
+	/* No */
+		#define CREQ_QUERY_ROCE_CC_GEN2_RESP_SB_TLV_TLV_FLAGS_REQUIRED_NO	(UINT32_C(0x0) << 1)
+	/* Yes */
+		#define CREQ_QUERY_ROCE_CC_GEN2_RESP_SB_TLV_TLV_FLAGS_REQUIRED_YES   (UINT32_C(0x1) << 1)
+		#define CREQ_QUERY_ROCE_CC_GEN2_RESP_SB_TLV_TLV_FLAGS_REQUIRED_LAST CREQ_QUERY_ROCE_CC_GEN2_RESP_SB_TLV_TLV_FLAGS_REQUIRED_YES
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * This field defines the TLV type value which is divided into
+	 * two ranges to differentiate between global and local TLV types.
+	 * Global TLV types must be unique across all defined TLV types.
+	 * Local TLV types are valid only for extensions to a given
+	 * HWRM message and may be repeated across different HWRM message
+	 * types. There is a direct correlation of each HWRM message type
+	 * to a single global TLV type value.
+	 *
+	 * Global TLV range: `0 - (63k-1)`
+	 *
+	 * Local TLV range: `63k - (64k-1)`
 	 */
-	uint64_t	resp_addr;
-} hwrm_fw_health_check_input_t, *phwrm_fw_health_check_input_t;
+	uint16_t	tlv_type;
+	/*
+	 * Length of the message data encapsulated by this TLV in bytes.
+	 * This length does not include the size of the TLV header itself
+	 * and it must be an integer multiple of 8B.
+	 */
+	uint16_t	length;
+	uint64_t	reserved64;
+	/*
+	 * DCN queue level threshold values associated with DCN queue
+	 * level table indices 0 to 7.
+	 */
+	uint16_t	dcn_qlevel_tbl_thr[8];
+	/*
+	 * DCN queue level table action values.
+	 * Returns CR, INC_CNP, UPD_IMM & TR fields associated with
+	 * DCN queue level table indices 0 to 7.
+	 */
+	uint32_t	dcn_qlevel_tbl_act[8];
+	/* DCN queue level current rate. */
+	#define CREQ_QUERY_ROCE_CC_GEN2_RESP_SB_TLV_DCN_QLEVEL_TBL_ACT_CR_MASK	UINT32_C(0x3fff)
+	#define CREQ_QUERY_ROCE_CC_GEN2_RESP_SB_TLV_DCN_QLEVEL_TBL_ACT_CR_SFT	0
+	/* DCN queue level increment CNP count. */
+	#define CREQ_QUERY_ROCE_CC_GEN2_RESP_SB_TLV_DCN_QLEVEL_TBL_ACT_INC_CNP	UINT32_C(0x4000)
+	/* DCN queue level update CR and TR immediately. */
+	#define CREQ_QUERY_ROCE_CC_GEN2_RESP_SB_TLV_DCN_QLEVEL_TBL_ACT_UPD_IMM	UINT32_C(0x8000)
+	/* DCN queue level target rate */
+	#define CREQ_QUERY_ROCE_CC_GEN2_RESP_SB_TLV_DCN_QLEVEL_TBL_ACT_TR_MASK	UINT32_C(0x3fff0000)
+	#define CREQ_QUERY_ROCE_CC_GEN2_RESP_SB_TLV_DCN_QLEVEL_TBL_ACT_TR_SFT	16
+} creq_query_roce_cc_gen2_resp_sb_tlv_t, *pcreq_query_roce_cc_gen2_resp_sb_tlv_t;
 
-/* hwrm_fw_health_check_output (size:128b/16B) */
+/***********************
+ * cmdq_modify_roce_cc *
+ ***********************/
 
-typedef struct hwrm_fw_health_check_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint32_t	fw_status;
+
+/* cmdq_modify_roce_cc (size:448b/56B) */
+
+typedef struct cmdq_modify_roce_cc {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Modify congestion control. Can only be issued from a PF. */
+	#define CMDQ_MODIFY_ROCE_CC_OPCODE_MODIFY_ROCE_CC UINT32_C(0x8c)
+	#define CMDQ_MODIFY_ROCE_CC_OPCODE_LAST	CMDQ_MODIFY_ROCE_CC_OPCODE_MODIFY_ROCE_CC
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+	/* Modify mask signifies the field that is requesting the change. */
+	uint32_t	modify_mask;
+	/* Enable change. */
+	#define CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_ENABLE_CC		UINT32_C(0x1)
+	/* Running average weight change. */
+	#define CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_G			UINT32_C(0x2)
+	/* Number of phases in Fast Recovery. */
+	#define CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_NUMPHASEPERSTATE	UINT32_C(0x4)
+	/* The starting value of rate change. */
+	#define CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_INIT_CR		UINT32_C(0x8)
+	/* The starting value of target rate change. */
+	#define CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_INIT_TR		UINT32_C(0x10)
+	/* IP TOS ECN change */
+	#define CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_TOS_ECN		UINT32_C(0x20)
+	/* IP TOS DSCP change */
+	#define CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_TOS_DSCP		UINT32_C(0x40)
+	/* Alternate IP TOS ECN change */
+	#define CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_ALT_VLAN_PCP	UINT32_C(0x80)
+	/* Alternate IP TOS DSCP change */
+	#define CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_ALT_TOS_DSCP	UINT32_C(0x100)
+	/* Round trip time in units of usecs */
+	#define CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_RTT		UINT32_C(0x200)
+	/* Congestion Control mode */
+	#define CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_CC_MODE		UINT32_C(0x400)
+	/* The value used as CP when cc_mode is 1(TCP) */
+	#define CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_TCP_CP		UINT32_C(0x800)
+	/* Specifies the RoCE Tx Queue to use for sending CNP packets */
+	#define CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_TX_QUEUE		UINT32_C(0x1000)
+	/* Inactivity time after which QP CC parameters are initialized */
+	#define CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_INACTIVITY_CP	UINT32_C(0x2000)
+	/* Amount of time per phase in units of ms. Max is 15. */
+	#define CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_TIME_PER_PHASE	UINT32_C(0x4000)
+	/* Number of packets per phase. Max is 255. */
+	#define CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_PKTS_PER_PHASE	UINT32_C(0x8000)
+	uint8_t	enable_cc;
+	/* Enable. */
+	#define CMDQ_MODIFY_ROCE_CC_ENABLE_CC	UINT32_C(0x1)
+	/* rsvd1 is 7 b */
+	#define CMDQ_MODIFY_ROCE_CC_RSVD1_MASK	UINT32_C(0xfe)
+	#define CMDQ_MODIFY_ROCE_CC_RSVD1_SFT	1
+	/* Congestion Probability averaging factor. */
+	uint8_t	g;
+	/* Number of phases in Fast Recovery. */
+	uint8_t	num_phases_per_state;
+	/* Number of packets per phase. Max is 255. */
+	uint8_t	pkts_per_phase;
 	/*
-	 * This bit is '0' if the primary SBI was used this boot,
-	 * or '1' if the secondary SBI was used.
+	 * The starting value of rate.
+	 * The max value supported for CC support level 1 is 1024.
 	 */
-	#define HWRM_FW_HEALTH_CHECK_OUTPUT_FW_STATUS_SBI_BOOTED	UINT32_C(0x1)
+	uint16_t	init_cr;
 	/*
-	 * This bit is '0' if the primary and secondary SBI images
-	 * match, or '1' if they do not match.
+	 * The starting value of target rate.
+	 * The max value supported for CC support level 1 is 1024.
 	 */
-	#define HWRM_FW_HEALTH_CHECK_OUTPUT_FW_STATUS_SBI_MISMATCH	UINT32_C(0x2)
+	uint16_t	init_tr;
+	uint8_t	tos_dscp_tos_ecn;
+	/* IP TOS ECN. Valid values are 1 or 2 when ECN is enabled. */
+	#define CMDQ_MODIFY_ROCE_CC_TOS_ECN_MASK UINT32_C(0x3)
+	#define CMDQ_MODIFY_ROCE_CC_TOS_ECN_SFT  0
+	/* IP TOS DSCP. */
+	#define CMDQ_MODIFY_ROCE_CC_TOS_DSCP_MASK UINT32_C(0xfc)
+	#define CMDQ_MODIFY_ROCE_CC_TOS_DSCP_SFT 2
+	uint8_t	alt_vlan_pcp;
+	/* Alternate vlan pcp value for CNP packets. */
+	#define CMDQ_MODIFY_ROCE_CC_ALT_VLAN_PCP_MASK UINT32_C(0x7)
+	#define CMDQ_MODIFY_ROCE_CC_ALT_VLAN_PCP_SFT 0
+	/* rsvd3 is 5 b */
+	#define CMDQ_MODIFY_ROCE_CC_RSVD3_MASK	UINT32_C(0xf8)
+	#define CMDQ_MODIFY_ROCE_CC_RSVD3_SFT	3
+	uint16_t	alt_tos_dscp;
+	/* Alternate IP TOS DSCP. */
+	#define CMDQ_MODIFY_ROCE_CC_ALT_TOS_DSCP_MASK UINT32_C(0x3f)
+	#define CMDQ_MODIFY_ROCE_CC_ALT_TOS_DSCP_SFT 0
+	/* rsvd4 is 10 b */
+	#define CMDQ_MODIFY_ROCE_CC_RSVD4_MASK	UINT32_C(0xffc0)
+	#define CMDQ_MODIFY_ROCE_CC_RSVD4_SFT	6
+	uint16_t	rtt;
 	/*
-	 * This bit is '0' if the primary SRT was used this boot,
-	 * or '1' if the secondary SRT was used.
+	 * Round trip time in units of usecs.
+	 * The max value supported for CC support level 1 is 2047.
 	 */
-	#define HWRM_FW_HEALTH_CHECK_OUTPUT_FW_STATUS_SRT_BOOTED	UINT32_C(0x4)
+	#define CMDQ_MODIFY_ROCE_CC_RTT_MASK  UINT32_C(0x3fff)
+	#define CMDQ_MODIFY_ROCE_CC_RTT_SFT   0
+	/* rsvd5 is 2 b */
+	#define CMDQ_MODIFY_ROCE_CC_RSVD5_MASK UINT32_C(0xc000)
+	#define CMDQ_MODIFY_ROCE_CC_RSVD5_SFT 14
+	uint16_t	tcp_cp;
+	/* The value used as CP when cc_mode is 1(TCP) */
+	#define CMDQ_MODIFY_ROCE_CC_TCP_CP_MASK UINT32_C(0x3ff)
+	#define CMDQ_MODIFY_ROCE_CC_TCP_CP_SFT 0
+	/* rsvd6 is 6 b */
+	#define CMDQ_MODIFY_ROCE_CC_RSVD6_MASK UINT32_C(0xfc00)
+	#define CMDQ_MODIFY_ROCE_CC_RSVD6_SFT  10
+	uint8_t	cc_mode;
+	/* DCTCP */
+	#define CMDQ_MODIFY_ROCE_CC_CC_MODE_DCTCP_CC_MODE	UINT32_C(0x0)
 	/*
-	 * This bit is '0' if the primary and secondary SRT images
-	 * match, or '1' if they do not match.
+	 * Probabilistic marking. On chips with CC Gen 0 support this
+	 * will be TCP CC algorithm.
 	 */
-	#define HWRM_FW_HEALTH_CHECK_OUTPUT_FW_STATUS_SRT_MISMATCH	UINT32_C(0x8)
+	#define CMDQ_MODIFY_ROCE_CC_CC_MODE_PROBABILISTIC_CC_MODE UINT32_C(0x1)
+	#define CMDQ_MODIFY_ROCE_CC_CC_MODE_LAST		CMDQ_MODIFY_ROCE_CC_CC_MODE_PROBABILISTIC_CC_MODE
 	/*
-	 * This bit is '0' if the primary CRT (or second stage SRT)
-	 * was used this boot, or '1' if the secondary CRT (or
-	 * second stage SRT) was used.
+	 * Specifies the RoCE Tx Queue to use for sending CNP packets.
+	 * CC support level 0 support 0 to 3 Tx queues.
+	 * CC support level 1 supports 0 to 7 Tx queues.
 	 */
-	#define HWRM_FW_HEALTH_CHECK_OUTPUT_FW_STATUS_CRT_BOOTED	UINT32_C(0x10)
+	uint8_t	tx_queue;
+	/* Inactivity time after which QP CC parameters are initialized */
+	uint16_t	inactivity_th;
+	/* Amount of time per phase in units of ms. Max is 15 */
+	uint8_t	time_per_phase;
+	/* reserved8 is 8 b */
+	uint8_t	reserved8_1;
+	/* reserved16 is 16 b */
+	uint16_t	reserved16;
+	uint32_t	reserved32;
+	uint64_t	reserved64;
+} cmdq_modify_roce_cc_t, *pcmdq_modify_roce_cc_t;
+
+/*
+ * TLV encapsulated modify CC command, with extended TLV record
+ * included for specifying the extended configuration for CC level 1.
+ */
+/* cmdq_modify_roce_cc_tlv (size:640b/80B) */
+
+typedef struct cmdq_modify_roce_cc_tlv {
 	/*
-	 * This bit is '0' if the primary and secondary CRT images
-	 * (or second stage SRT images) match, or '1' if they do not
-	 * match.
+	 * The command discriminator is used to differentiate between various
+	 * types of HWRM messages. This includes legacy HWRM and RoCE slowpath
+	 * command messages as well as newer TLV encapsulated HWRM commands.
+	 *
+	 * For TLV encapsulated messages this field must be 0x8000.
 	 */
-	#define HWRM_FW_HEALTH_CHECK_OUTPUT_FW_STATUS_CRT_MISMATCH	UINT32_C(0x20)
+	uint16_t	cmd_discr;
+	uint8_t	reserved_8b;
+	uint8_t	tlv_flags;
 	/*
-	 * This bit is '0' if the the second stage RT image is a CRT,
-	 * or '1' if the second stage RT image is an SRT.
+	 * Indicates the presence of additional TLV encapsulated data
+	 * follows this TLV.
 	 */
-	#define HWRM_FW_HEALTH_CHECK_OUTPUT_FW_STATUS_SECOND_RT		UINT32_C(0x40)
+	#define CMDQ_MODIFY_ROCE_CC_TLV_TLV_FLAGS_MORE	UINT32_C(0x1)
+	/* Last TLV in a sequence of TLVs. */
+		#define CMDQ_MODIFY_ROCE_CC_TLV_TLV_FLAGS_MORE_LAST	UINT32_C(0x0)
+	/* More TLVs follow this TLV. */
+		#define CMDQ_MODIFY_ROCE_CC_TLV_TLV_FLAGS_MORE_NOT_LAST  UINT32_C(0x1)
 	/*
-	 * This bit is '0' if the the image was loaded from flash,
-	 * or '1' if the image was fastbooted.
+	 * When an HWRM receiver detects a TLV type that it does not
+	 * support with the TLV required flag set, the receiver must
+	 * reject the HWRM message with an error code indicating an
+	 * unsupported TLV type.
 	 */
-	#define HWRM_FW_HEALTH_CHECK_OUTPUT_FW_STATUS_FASTBOOTED	UINT32_C(0x80)
+	#define CMDQ_MODIFY_ROCE_CC_TLV_TLV_FLAGS_REQUIRED	UINT32_C(0x2)
+	/* No */
+		#define CMDQ_MODIFY_ROCE_CC_TLV_TLV_FLAGS_REQUIRED_NO	(UINT32_C(0x0) << 1)
+	/* Yes */
+		#define CMDQ_MODIFY_ROCE_CC_TLV_TLV_FLAGS_REQUIRED_YES   (UINT32_C(0x1) << 1)
+		#define CMDQ_MODIFY_ROCE_CC_TLV_TLV_FLAGS_REQUIRED_LAST CMDQ_MODIFY_ROCE_CC_TLV_TLV_FLAGS_REQUIRED_YES
 	/*
-	 * This bit is '0' if the primary dir_hdr was used to locate
-	 * the firmware, or '1' if the secondary dir_hdr was used.
+	 * This field defines the TLV type value which is divided into
+	 * two ranges to differentiate between global and local TLV types.
+	 * Global TLV types must be unique across all defined TLV types.
+	 * Local TLV types are valid only for extensions to a given
+	 * HWRM message and may be repeated across different HWRM message
+	 * types. There is a direct correlation of each HWRM message type
+	 * to a single global TLV type value.
+	 *
+	 * Global TLV range: `0 - (63k-1)`
+	 *
+	 * Local TLV range: `63k - (64k-1)`
 	 */
-	#define HWRM_FW_HEALTH_CHECK_OUTPUT_FW_STATUS_DIR_HDR_BOOTED	UINT32_C(0x100)
+	uint16_t	tlv_type;
 	/*
-	 * This bit is '0' if the primary and secondary dir_hdr match,
-	 * or '1' if they do not match.
+	 * Length of the message data encapsulated by this TLV in bytes.
+	 * This length does not include the size of the TLV header itself
+	 * and it must be an integer multiple of 8B.
 	 */
-	#define HWRM_FW_HEALTH_CHECK_OUTPUT_FW_STATUS_DIR_HDR_MISMATCH	UINT32_C(0x200)
+	uint16_t	length;
 	/*
-	 * This bit is '0' if the Master Boot Record is in good condition,
-	 * or '1' if it is corrupted.
+	 * Size of the tlv encapsulated command, including all tlvs and
+	 * extension data in 16-byte units.
 	 */
-	#define HWRM_FW_HEALTH_CHECK_OUTPUT_FW_STATUS_MBR_CORRUPT	UINT32_C(0x400)
-	uint8_t	unused_0[3];
+	uint8_t	total_size;
+	uint8_t	reserved56[7];
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Modify congestion control. Can only be issued from a PF. */
+	#define CMDQ_MODIFY_ROCE_CC_TLV_OPCODE_MODIFY_ROCE_CC UINT32_C(0x8c)
+	#define CMDQ_MODIFY_ROCE_CC_TLV_OPCODE_LAST	CMDQ_MODIFY_ROCE_CC_TLV_OPCODE_MODIFY_ROCE_CC
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+	/* Modify mask signifies the field that is requesting the change. */
+	uint32_t	modify_mask;
+	/* Enable change. */
+	#define CMDQ_MODIFY_ROCE_CC_TLV_MODIFY_MASK_ENABLE_CC		UINT32_C(0x1)
+	/* Running average weight change. */
+	#define CMDQ_MODIFY_ROCE_CC_TLV_MODIFY_MASK_G			UINT32_C(0x2)
+	/* Number of phases in Fast Recovery. */
+	#define CMDQ_MODIFY_ROCE_CC_TLV_MODIFY_MASK_NUMPHASEPERSTATE	UINT32_C(0x4)
+	/* The starting value of rate change. */
+	#define CMDQ_MODIFY_ROCE_CC_TLV_MODIFY_MASK_INIT_CR		UINT32_C(0x8)
+	/* The starting value of target rate change. */
+	#define CMDQ_MODIFY_ROCE_CC_TLV_MODIFY_MASK_INIT_TR		UINT32_C(0x10)
+	/* IP TOS ECN change */
+	#define CMDQ_MODIFY_ROCE_CC_TLV_MODIFY_MASK_TOS_ECN		UINT32_C(0x20)
+	/* IP TOS DSCP change */
+	#define CMDQ_MODIFY_ROCE_CC_TLV_MODIFY_MASK_TOS_DSCP		UINT32_C(0x40)
+	/* Alternate IP TOS ECN change */
+	#define CMDQ_MODIFY_ROCE_CC_TLV_MODIFY_MASK_ALT_VLAN_PCP	UINT32_C(0x80)
+	/* Alternate IP TOS DSCP change */
+	#define CMDQ_MODIFY_ROCE_CC_TLV_MODIFY_MASK_ALT_TOS_DSCP	UINT32_C(0x100)
+	/* Round trip time in units of usecs */
+	#define CMDQ_MODIFY_ROCE_CC_TLV_MODIFY_MASK_RTT		UINT32_C(0x200)
+	/* Congestion Control mode */
+	#define CMDQ_MODIFY_ROCE_CC_TLV_MODIFY_MASK_CC_MODE		UINT32_C(0x400)
+	/* The value used as CP when cc_mode is 1(TCP) */
+	#define CMDQ_MODIFY_ROCE_CC_TLV_MODIFY_MASK_TCP_CP		UINT32_C(0x800)
+	/* Specifies the RoCE Tx Queue to use for sending CNP packets */
+	#define CMDQ_MODIFY_ROCE_CC_TLV_MODIFY_MASK_TX_QUEUE		UINT32_C(0x1000)
+	/* Inactivity time after which QP CC parameters are initialized */
+	#define CMDQ_MODIFY_ROCE_CC_TLV_MODIFY_MASK_INACTIVITY_CP	UINT32_C(0x2000)
+	/* Amount of time per phase in units of ms. Max is 15. */
+	#define CMDQ_MODIFY_ROCE_CC_TLV_MODIFY_MASK_TIME_PER_PHASE	UINT32_C(0x4000)
+	/* Number of packets per phase. Max is 255. */
+	#define CMDQ_MODIFY_ROCE_CC_TLV_MODIFY_MASK_PKTS_PER_PHASE	UINT32_C(0x8000)
+	uint8_t	enable_cc;
+	/* Enable. */
+	#define CMDQ_MODIFY_ROCE_CC_TLV_ENABLE_CC	UINT32_C(0x1)
+	/* rsvd1 is 7 b */
+	#define CMDQ_MODIFY_ROCE_CC_TLV_RSVD1_MASK	UINT32_C(0xfe)
+	#define CMDQ_MODIFY_ROCE_CC_TLV_RSVD1_SFT	1
+	/* Congestion Probability averaging factor. */
+	uint8_t	g;
+	/* Number of phases in Fast Recovery. */
+	uint8_t	num_phases_per_state;
+	/* Number of packets per phase. Max is 255. */
+	uint8_t	pkts_per_phase;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * The starting value of rate.
+	 * The max value supported for CC support level 1 is 1024.
 	 */
-	uint8_t	valid;
-} hwrm_fw_health_check_output_t, *phwrm_fw_health_check_output_t;
-
-/***************************
- * hwrm_fw_livepatch_query *
- ***************************/
-
-
-/* hwrm_fw_livepatch_query_input (size:192b/24B) */
-
-typedef struct hwrm_fw_livepatch_query_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	uint16_t	init_cr;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * The starting value of target rate.
+	 * The max value supported for CC support level 1 is 1024.
 	 */
-	uint16_t	cmpl_ring;
+	uint16_t	init_tr;
+	uint8_t	tos_dscp_tos_ecn;
+	/* IP TOS ECN. Valid values are 1 or 2 when ECN is enabled. */
+	#define CMDQ_MODIFY_ROCE_CC_TLV_TOS_ECN_MASK UINT32_C(0x3)
+	#define CMDQ_MODIFY_ROCE_CC_TLV_TOS_ECN_SFT  0
+	/* IP TOS DSCP. */
+	#define CMDQ_MODIFY_ROCE_CC_TLV_TOS_DSCP_MASK UINT32_C(0xfc)
+	#define CMDQ_MODIFY_ROCE_CC_TLV_TOS_DSCP_SFT 2
+	uint8_t	alt_vlan_pcp;
+	/* Alternate vlan pcp value for CNP packets. */
+	#define CMDQ_MODIFY_ROCE_CC_TLV_ALT_VLAN_PCP_MASK UINT32_C(0x7)
+	#define CMDQ_MODIFY_ROCE_CC_TLV_ALT_VLAN_PCP_SFT 0
+	/* rsvd3 is 5 b */
+	#define CMDQ_MODIFY_ROCE_CC_TLV_RSVD3_MASK	UINT32_C(0xf8)
+	#define CMDQ_MODIFY_ROCE_CC_TLV_RSVD3_SFT	3
+	uint16_t	alt_tos_dscp;
+	/* Alternate IP TOS DSCP. */
+	#define CMDQ_MODIFY_ROCE_CC_TLV_ALT_TOS_DSCP_MASK UINT32_C(0x3f)
+	#define CMDQ_MODIFY_ROCE_CC_TLV_ALT_TOS_DSCP_SFT 0
+	/* rsvd4 is 10 b */
+	#define CMDQ_MODIFY_ROCE_CC_TLV_RSVD4_MASK	UINT32_C(0xffc0)
+	#define CMDQ_MODIFY_ROCE_CC_TLV_RSVD4_SFT	6
+	uint16_t	rtt;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Round trip time in units of usecs.
+	 * The max value supported for CC support level 1 is 2047.
 	 */
-	uint16_t	seq_id;
+	#define CMDQ_MODIFY_ROCE_CC_TLV_RTT_MASK  UINT32_C(0x3fff)
+	#define CMDQ_MODIFY_ROCE_CC_TLV_RTT_SFT   0
+	/* rsvd5 is 2 b */
+	#define CMDQ_MODIFY_ROCE_CC_TLV_RSVD5_MASK UINT32_C(0xc000)
+	#define CMDQ_MODIFY_ROCE_CC_TLV_RSVD5_SFT 14
+	uint16_t	tcp_cp;
+	/* The value used as CP when cc_mode is 1(TCP) */
+	#define CMDQ_MODIFY_ROCE_CC_TLV_TCP_CP_MASK UINT32_C(0x3ff)
+	#define CMDQ_MODIFY_ROCE_CC_TLV_TCP_CP_SFT 0
+	/* rsvd6 is 6 b */
+	#define CMDQ_MODIFY_ROCE_CC_TLV_RSVD6_MASK UINT32_C(0xfc00)
+	#define CMDQ_MODIFY_ROCE_CC_TLV_RSVD6_SFT  10
+	uint8_t	cc_mode;
+	/* DCTCP */
+	#define CMDQ_MODIFY_ROCE_CC_TLV_CC_MODE_DCTCP_CC_MODE	UINT32_C(0x0)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Probabilistic marking. On chips with CC Gen 0 support this
+	 * will be TCP CC algorithm.
 	 */
-	uint16_t	target_id;
+	#define CMDQ_MODIFY_ROCE_CC_TLV_CC_MODE_PROBABILISTIC_CC_MODE UINT32_C(0x1)
+	#define CMDQ_MODIFY_ROCE_CC_TLV_CC_MODE_LAST		CMDQ_MODIFY_ROCE_CC_TLV_CC_MODE_PROBABILISTIC_CC_MODE
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Specifies the RoCE Tx Queue to use for sending CNP packets.
+	 * CC support level 0 support 0 to 3 Tx queues.
+	 * CC support level 1 supports 0 to 7 Tx queues.
 	 */
-	uint64_t	resp_addr;
-	/* Firmware target to which to apply the livepatch query */
-	uint8_t	fw_target;
-	/* Common firmware livepatch query. */
-	#define HWRM_FW_LIVEPATCH_QUERY_INPUT_FW_TARGET_COMMON_FW UINT32_C(0x1)
-	/* Secure firmware livepatch query. */
-	#define HWRM_FW_LIVEPATCH_QUERY_INPUT_FW_TARGET_SECURE_FW UINT32_C(0x2)
-	#define HWRM_FW_LIVEPATCH_QUERY_INPUT_FW_TARGET_LAST	HWRM_FW_LIVEPATCH_QUERY_INPUT_FW_TARGET_SECURE_FW
-	uint8_t	unused_0[7];
-} hwrm_fw_livepatch_query_input_t, *phwrm_fw_livepatch_query_input_t;
+	uint8_t	tx_queue;
+	/* Inactivity time after which QP CC parameters are initialized */
+	uint16_t	inactivity_th;
+	/* Amount of time per phase in units of ms. Max is 15 */
+	uint8_t	time_per_phase;
+	/* reserved8 is 8 b */
+	uint8_t	reserved8_1;
+	/* reserved16 is 16 b */
+	uint16_t	reserved16;
+	uint32_t	reserved32;
+	uint64_t	reserved64;
+	uint64_t	reservedtlvpad;
+} cmdq_modify_roce_cc_tlv_t, *pcmdq_modify_roce_cc_tlv_t;
 
-/* hwrm_fw_livepatch_query_output (size:640b/80B) */
+/* cmdq_modify_roce_cc_gen1_tlv (size:768b/96B) */
 
-typedef struct hwrm_fw_livepatch_query_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
+typedef struct cmdq_modify_roce_cc_gen1_tlv {
 	/*
-	 * This field represents the patch version string of the NVM installed
-	 * livepatch.  (ASCII chars with NULL at the end).
+	 * The command discriminator is used to differentiate between various
+	 * types of HWRM messages. This includes legacy HWRM and RoCE slowpath
+	 * command messages as well as newer TLV encapsulated HWRM commands.
+	 *
+	 * For TLV encapsulated messages this field must be 0x8000.
 	 */
-	char	install_ver[32];
+	uint16_t	cmd_discr;
+	uint8_t	reserved_8b;
+	uint8_t	tlv_flags;
 	/*
-	 * This field represents the patch version string of the active
-	 * livepatch.  (ASCII chars with NULL at the end).
+	 * Indicates the presence of additional TLV encapsulated data
+	 * follows this TLV.
 	 */
-	char	active_ver[32];
-	uint16_t	status_flags;
-	/* This bit is '1' if a livepatch image is installed to NVM. */
-	#define HWRM_FW_LIVEPATCH_QUERY_OUTPUT_STATUS_FLAGS_INSTALL	UINT32_C(0x1)
-	/* This bit is '1' if firmware livepatch is active. */
-	#define HWRM_FW_LIVEPATCH_QUERY_OUTPUT_STATUS_FLAGS_ACTIVE	UINT32_C(0x2)
-	uint8_t	unused_0[5];
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_TLV_FLAGS_MORE	UINT32_C(0x1)
+	/* Last TLV in a sequence of TLVs. */
+		#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_TLV_FLAGS_MORE_LAST	UINT32_C(0x0)
+	/* More TLVs follow this TLV. */
+		#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_TLV_FLAGS_MORE_NOT_LAST  UINT32_C(0x1)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When an HWRM receiver detects a TLV type that it does not
+	 * support with the TLV required flag set, the receiver must
+	 * reject the HWRM message with an error code indicating an
+	 * unsupported TLV type.
 	 */
-	uint8_t	valid;
-} hwrm_fw_livepatch_query_output_t, *phwrm_fw_livepatch_query_output_t;
-
-/*********************
- * hwrm_fw_livepatch *
- *********************/
-
-
-/* hwrm_fw_livepatch_input (size:256b/32B) */
-
-typedef struct hwrm_fw_livepatch_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_TLV_FLAGS_REQUIRED	UINT32_C(0x2)
+	/* No */
+		#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_TLV_FLAGS_REQUIRED_NO	(UINT32_C(0x0) << 1)
+	/* Yes */
+		#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_TLV_FLAGS_REQUIRED_YES   (UINT32_C(0x1) << 1)
+		#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_TLV_FLAGS_REQUIRED_LAST CMDQ_MODIFY_ROCE_CC_GEN1_TLV_TLV_FLAGS_REQUIRED_YES
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * This field defines the TLV type value which is divided into
+	 * two ranges to differentiate between global and local TLV types.
+	 * Global TLV types must be unique across all defined TLV types.
+	 * Local TLV types are valid only for extensions to a given
+	 * HWRM message and may be repeated across different HWRM message
+	 * types. There is a direct correlation of each HWRM message type
+	 * to a single global TLV type value.
+	 *
+	 * Global TLV range: `0 - (63k-1)`
+	 *
+	 * Local TLV range: `63k - (64k-1)`
 	 */
-	uint16_t	cmpl_ring;
+	uint16_t	tlv_type;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Length of the message data encapsulated by this TLV in bytes.
+	 * This length does not include the size of the TLV header itself
+	 * and it must be an integer multiple of 8B.
 	 */
-	uint16_t	seq_id;
+	uint16_t	length;
+	uint64_t	reserved64;
+	/* Modify mask signifies the field that is requesting the change. */
+	uint64_t	modify_mask;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Update the number of uS between generation of CNPs for
+	 * probabilistic marking mode.
 	 */
-	uint16_t	target_id;
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_MIN_TIME_BETWEEN_CNPS		UINT32_C(0x1)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Update starting value of Congestion Probability (CP).
+	 * Maximum value supported is 1023.
 	 */
-	uint64_t	resp_addr;
-	/* Livepatch operation */
-	uint8_t	opcode;
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_INIT_CP			UINT32_C(0x2)
+	/* Update Target Rate (TR) Update Mode. */
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_TR_UPDATE_MODE			UINT32_C(0x4)
+	/* Update number of RTTs with CNPs in a row for TR update. */
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_TR_UPDATE_CYCLES		UINT32_C(0x8)
+	/* Update number of RTTs in Fast Recovery stage. */
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_FR_NUM_RTTS			UINT32_C(0x10)
+	/* Update time increment to increase TR in active increase phase. */
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_AI_RATE_INCREASE		UINT32_C(0x20)
 	/*
-	 * Activate a livepatch that is NVM installed or via direct load
-	 * from host memory.   Activate will authenticate a signed patch,
-	 * verify the patch version for compatibility and apply the
-	 * livepatch to existing firmware at run-time.
+	 * Update count of RTTs with CNPs, received after
+	 * the first one, to wait, before reducing rate.
 	 */
-	#define HWRM_FW_LIVEPATCH_INPUT_OPCODE_ACTIVATE   UINT32_C(0x1)
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_REDUCTION_RELAX_RTTS_TH	UINT32_C(0x40)
 	/*
-	 * Deactivate a livepatch and restore to the original firmware
-	 * operation state.
+	 * Update additional number of RTTS with CNPs, to wait,
+	 * before further rate reduction, for low rates.
 	 */
-	#define HWRM_FW_LIVEPATCH_INPUT_OPCODE_DEACTIVATE UINT32_C(0x2)
-	#define HWRM_FW_LIVEPATCH_INPUT_OPCODE_LAST	HWRM_FW_LIVEPATCH_INPUT_OPCODE_DEACTIVATE
-	/* Firmware target to which to apply the livepatch operation. */
-	uint8_t	fw_target;
-	/* Common firmware livepatch. */
-	#define HWRM_FW_LIVEPATCH_INPUT_FW_TARGET_COMMON_FW UINT32_C(0x1)
-	/* Secure firmware livepatch. */
-	#define HWRM_FW_LIVEPATCH_INPUT_FW_TARGET_SECURE_FW UINT32_C(0x2)
-	#define HWRM_FW_LIVEPATCH_INPUT_FW_TARGET_LAST	HWRM_FW_LIVEPATCH_INPUT_FW_TARGET_SECURE_FW
-	/* Load method for livepatch. */
-	uint8_t	loadtype;
-	/* Load a livepatch currently installed on NVM. */
-	#define HWRM_FW_LIVEPATCH_INPUT_LOADTYPE_NVM_INSTALL   UINT32_C(0x1)
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_ADDITIONAL_RELAX_CR_TH		UINT32_C(0x80)
+	/* Update threshold for update to Actual Current Rate (CR) */
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_CR_MIN_TH			UINT32_C(0x100)
+	/* Update log based averaging weight for QPC variable actual_cr */
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_BW_AVG_WEIGHT			UINT32_C(0x200)
+	/* Update factor used in the computation of rate reduction. */
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_ACTUAL_CR_FACTOR		UINT32_C(0x400)
+	/* Update the level of CR above which CP is set to maximum level. */
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_MAX_CP_CR_TH			UINT32_C(0x800)
+	/* Enable adding fraction of CR to CP. */
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_CP_BIAS_EN			UINT32_C(0x1000)
 	/*
-	 * Load a livepatch directly from host memory.  The livepatch image
-	 * is available at host_addr.
+	 * Update log based fraction of CR to add to CP
+	 * when cp_bias_en is 1.
 	 */
-	#define HWRM_FW_LIVEPATCH_INPUT_LOADTYPE_MEMORY_DIRECT UINT32_C(0x2)
-	#define HWRM_FW_LIVEPATCH_INPUT_LOADTYPE_LAST	HWRM_FW_LIVEPATCH_INPUT_LOADTYPE_MEMORY_DIRECT
-	/* Reserved for future use. */
-	uint8_t	flags;
-	/* Length of livepatch image for memory direct loading, in bytes. */
-	uint32_t	patch_len;
-	/* 64-bit Host address of livepatch image for memory direct loading. */
-	uint64_t	host_addr;
-} hwrm_fw_livepatch_input_t, *phwrm_fw_livepatch_input_t;
-
-/* hwrm_fw_livepatch_output (size:128b/16B) */
-
-typedef struct hwrm_fw_livepatch_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_CP_BIAS			UINT32_C(0x2000)
+	/* Update ECN bits in a CNP packet generated by hardware. */
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_CNP_ECN			UINT32_C(0x4000)
+	/* Update enable of jitter in RTT. */
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_RTT_JITTER_EN			UINT32_C(0x8000)
+	/* Update number of bytes per usec. */
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_LINK_BYTES_PER_USEC		UINT32_C(0x10000)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * Update threshold used to reset QPC CC state to its initial
+	 * state.
 	 */
-	uint8_t	valid;
-} hwrm_fw_livepatch_output_t, *phwrm_fw_livepatch_output_t;
-
-/* hwrm_fw_livepatch_cmd_err (size:64b/8B) */
-
-typedef struct hwrm_fw_livepatch_cmd_err {
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_RESET_CC_CR_TH			UINT32_C(0x20000)
+	/* Update number of valid lsbits in CR and TR */
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_CR_WIDTH			UINT32_C(0x40000)
+	/* Update lower end of random selection of quota_period. */
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_QUOTA_PERIOD_MIN		UINT32_C(0x80000)
+	/* Update upper end of random selection of quota_period. */
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_QUOTA_PERIOD_MAX		UINT32_C(0x100000)
 	/*
-	 * command specific error codes that goes to
-	 * the cmd_err field in Common HWRM Error Response.
+	 * Update absolute maximum possible quota_period,
+	 * when rate table for lower 24 levels is used.
 	 */
-	uint8_t	code;
-	/* Unknown error. */
-	#define HWRM_FW_LIVEPATCH_CMD_ERR_CODE_UNKNOWN	UINT32_C(0x0)
-	/* Opcode invalid. */
-	#define HWRM_FW_LIVEPATCH_CMD_ERR_CODE_INVALID_OPCODE  UINT32_C(0x1)
-	/* Firmware target invalid. */
-	#define HWRM_FW_LIVEPATCH_CMD_ERR_CODE_INVALID_TARGET  UINT32_C(0x2)
-	/* Livepatch operation not supported. */
-	#define HWRM_FW_LIVEPATCH_CMD_ERR_CODE_NOT_SUPPORTED   UINT32_C(0x3)
-	/* Livepatch image is not installed in NVRAM. */
-	#define HWRM_FW_LIVEPATCH_CMD_ERR_CODE_NOT_INSTALLED   UINT32_C(0x4)
-	/* Deactivate failed.  Firmware is not currently patched. */
-	#define HWRM_FW_LIVEPATCH_CMD_ERR_CODE_NOT_PATCHED	UINT32_C(0x5)
-	/* Authentication of a signed livepatch failed. */
-	#define HWRM_FW_LIVEPATCH_CMD_ERR_CODE_AUTH_FAIL	UINT32_C(0x6)
-	/* Livepatch header check failed.  Patch incompatible. */
-	#define HWRM_FW_LIVEPATCH_CMD_ERR_CODE_INVALID_HEADER  UINT32_C(0x7)
-	/* Livepatch size incompatible. */
-	#define HWRM_FW_LIVEPATCH_CMD_ERR_CODE_INVALID_SIZE	UINT32_C(0x8)
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_QUOTA_PERIOD_ABS_MAX		UINT32_C(0x200000)
+	/* Update lower bound of TR. */
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_TR_LOWER_BOUND			UINT32_C(0x400000)
 	/*
-	 * Activate failed.  Firmware has already been patched.  Deactivate
-	 * existing livepatch before proceeding.
+	 * Update factor on probability threshold for adding
+	 * 0.5 to CR randomly.
 	 */
-	#define HWRM_FW_LIVEPATCH_CMD_ERR_CODE_ALREADY_PATCHED UINT32_C(0x9)
-	#define HWRM_FW_LIVEPATCH_CMD_ERR_CODE_LAST	HWRM_FW_LIVEPATCH_CMD_ERR_CODE_ALREADY_PATCHED
-	uint8_t	unused_0[7];
-} hwrm_fw_livepatch_cmd_err_t, *phwrm_fw_livepatch_cmd_err_t;
-
-/****************
- * hwrm_fw_sync *
- ****************/
-
-
-/* hwrm_fw_sync_input (size:192b/24B) */
-
-typedef struct hwrm_fw_sync_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_CR_PROB_FACTOR			UINT32_C(0x800000)
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * Update factor on probability threshold for adding
+	 * 0.5 to TR randomly.
 	 */
-	uint16_t	cmpl_ring;
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_TR_PROB_FACTOR			UINT32_C(0x1000000)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Update threshold that ensures fairness between requester
+	 * and responder
 	 */
-	uint16_t	seq_id;
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_FAIRNESS_CR_TH			UINT32_C(0x2000000)
+	/* Update log based rate reduction divider. */
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_RED_DIV			UINT32_C(0x4000000)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Update threshold for rate reductions when CNPS received
+	 * over last RTT.
 	 */
-	uint16_t	target_id;
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_CNP_RATIO_TH			UINT32_C(0x8000000)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Update extended number of RTTS to wait,
+	 * when there is no congestion, to start doubling the rate.
 	 */
-	uint64_t	resp_addr;
-	uint32_t	sync_action;
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_EXP_AI_RTTS			UINT32_C(0x10000000)
+	/* Update log based CR to CP ratio used in exponential increase. */
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_EXP_AI_CR_CP_RATIO		UINT32_C(0x20000000)
 	/*
-	 * If action is '1' (sync) and this bit is set, the SBI
-	 * images will be synchronized, copying from the instance
-	 * used for boot to the other instance, if they currently
-	 * do not match.
+	 * Update threshold, in congestion free RTTs,
+	 * that triggers start of CP update to track CR.
 	 */
-	#define HWRM_FW_SYNC_INPUT_SYNC_ACTION_SYNC_SBI	UINT32_C(0x1)
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_CP_EXP_UPDATE_TH		UINT32_C(0x40000000)
 	/*
-	 * If action is '1' (sync) and this bit is set, the SRT
-	 * images will be synchronized, copying from the instance
-	 * used for boot to the other instance, if they currently
-	 * do not match.
+	 * Update threshold on congestion free RTTs above
+	 * which AI can increase to 16.
 	 */
-	#define HWRM_FW_SYNC_INPUT_SYNC_ACTION_SYNC_SRT	UINT32_C(0x2)
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_HIGH_EXP_AI_RTTS_TH1		UINT32_C(0x80000000)
 	/*
-	 * If action is '1' (sync) and this bit is set, the CRT
-	 * images will be synchronized (or second stage SRT if that
-	 * is used in place of CRT), copying from the instance
-	 * used for boot to the other instance, if they currently
-	 * do not match.
+	 * Update threshold on congestion free RTTs above
+	 * which AI can increase to 32.
 	 */
-	#define HWRM_FW_SYNC_INPUT_SYNC_ACTION_SYNC_CRT	UINT32_C(0x4)
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_HIGH_EXP_AI_RTTS_TH2		UINT32_C(0x100000000)L
+	/* Update use of lowest 24 rate levels rate_table. */
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_USE_RATE_TABLE			UINT32_C(0x200000000)L
 	/*
-	 * If action is '1' (sync) and this bit is set, the dir_hdr
-	 * partition will be synchronized, copying from the instance
-	 * used for boot to the other instance, if they currently
-	 * do not match.
+	 * Update the maximum number of 64B that can be transmitted
+	 * during RTT time.
 	 */
-	#define HWRM_FW_SYNC_INPUT_SYNC_ACTION_SYNC_DIR_HDR	UINT32_C(0x8)
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_LINK64B_PER_RTT		UINT32_C(0x400000000)L
 	/*
-	 * If action is '1' (sync) and this bit is set, the MBR
-	 * will be erased and reprogrammed with valid content.
+	 * Update number of congestion free RTTs above which
+	 * reduction based on actual rate is enabled.
 	 */
-	#define HWRM_FW_SYNC_INPUT_SYNC_ACTION_WRITE_MBR	UINT32_C(0x10)
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_ACTUAL_CR_CONG_FREE_RTTS_TH	UINT32_C(0x800000000)L
 	/*
-	 * A value of '1' instructs the firmware to perform an image
-	 * synchronization of the firmware types denoted by the
-	 * sync_sbi, sync_srt, sync_crt bits.  A value of '0' just
-	 * requests the status for the previously requested sync
-	 * operation.
+	 * Update threshold used in severe congestion for
+	 * limiting TR to 1.5 times CR.
 	 */
-	#define HWRM_FW_SYNC_INPUT_SYNC_ACTION_ACTION	UINT32_C(0x80000000)
-	uint8_t	unused_0[4];
-} hwrm_fw_sync_input_t, *phwrm_fw_sync_input_t;
-
-/* hwrm_fw_sync_output (size:128b/16B) */
-
-typedef struct hwrm_fw_sync_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint32_t	sync_status;
-	/* This bit field indicates the error if 'sync_err' bit is set. */
-	#define HWRM_FW_SYNC_OUTPUT_SYNC_STATUS_ERR_CODE_MASK	UINT32_C(0xff)
-	#define HWRM_FW_SYNC_OUTPUT_SYNC_STATUS_ERR_CODE_SFT	0
-	/* Success, no error */
-		#define HWRM_FW_SYNC_OUTPUT_SYNC_STATUS_ERR_CODE_SUCCESS	UINT32_C(0x0)
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_SEVERE_CONG_CR_TH1		UINT32_C(0x1000000000)L
 	/*
-	 * A previously requested synchronization command is still
-	 * in progress.
+	 * Update threshold used in severe congestion for
+	 * limiting TR to 1.25 times CR.
 	 */
-		#define HWRM_FW_SYNC_OUTPUT_SYNC_STATUS_ERR_CODE_IN_PROGRESS  UINT32_C(0x1)
-	/* An NVRAM operation has timed out. */
-		#define HWRM_FW_SYNC_OUTPUT_SYNC_STATUS_ERR_CODE_TIMEOUT	UINT32_C(0x2)
-	/* General NVRAM error code. */
-		#define HWRM_FW_SYNC_OUTPUT_SYNC_STATUS_ERR_CODE_GENERAL	UINT32_C(0x3)
-		#define HWRM_FW_SYNC_OUTPUT_SYNC_STATUS_ERR_CODE_LAST	HWRM_FW_SYNC_OUTPUT_SYNC_STATUS_ERR_CODE_GENERAL
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_SEVERE_CONG_CR_TH2		UINT32_C(0x2000000000)L
 	/*
-	 * This bit is '1' if the syncronization request has completed
-	 * with an error; the 'err_code' field can be used to obtain
-	 * information about error type.
+	 * Update number of bytes to subtract from QPC.cc_bucket
+	 * when an ack is scheduled.
 	 */
-	#define HWRM_FW_SYNC_OUTPUT_SYNC_STATUS_SYNC_ERR		UINT32_C(0x40000000)
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_CC_ACK_BYTES			UINT32_C(0x4000000000)L
+	/* Update enable of reduction of CR, TR, and CP to init values. */
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_REDUCE_INIT_EN			UINT32_C(0x8000000000)L
 	/*
-	 * This bit is '0' if the previously requested synchronization
-	 * command is still in progress, or '1' if the previously
-	 * requested sync command has completed.  If '1', the 'sync_err'
-	 * field will indicate if it completed successfully or with
-	 * an error.
+	 * Update threshold used for reduction of CR, TR, and CP to init
+	 * values.
 	 */
-	#define HWRM_FW_SYNC_OUTPUT_SYNC_STATUS_SYNC_COMPLETE	UINT32_C(0x80000000)
-	uint8_t	unused_0[3];
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_REDUCE_INIT_CONG_FREE_RTTS_TH	UINT32_C(0x10000000000)L
+	/* Update enable of random no reduction of CR. */
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_RANDOM_NO_RED_EN		UINT32_C(0x20000000000)L
+	/* Update enable of coarse correction to actual CR. */
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_ACTUAL_CR_SHIFT_CORRECTION_EN	UINT32_C(0x40000000000)L
+	/* Update enable of adjustment to refill quota. */
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_QUOTA_PERIOD_ADJUST_EN		UINT32_C(0x80000000000)L
+	/* High order bits of inactivity threshold. */
+	uint16_t	inactivity_th_hi;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * The number of uS between generation of CNPs when cc_mode is
+	 * probabilistic marking.
 	 */
-	uint8_t	valid;
-} hwrm_fw_sync_output_t, *phwrm_fw_sync_output_t;
-
-/***********************
- * hwrm_fw_state_qcaps *
- ***********************/
-
-
-/* hwrm_fw_state_qcaps_input (size:128b/16B) */
-
-typedef struct hwrm_fw_state_qcaps_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	uint16_t	min_time_between_cnps;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * The starting value of congestion probability. Input range
+	 * is 0 - 1023.
 	 */
-	uint16_t	cmpl_ring;
+	uint16_t	init_cp;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * In tr_update_mode 0, Target Rate (TR) is updated to
+	 * halfway between the Current Rate (CR) before and after reduction.
+	 * In tr_update_mode 1, TR is updated to CR's value before reduction.
 	 */
-	uint16_t	seq_id;
+	uint8_t	tr_update_mode;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Determine for how many RTTs with CNPs in a row, TR is being updated.
+	 * 0: TR is updated when QPC. rtts_with_cnps == 0
+	 * 1-6: TR is updated if QPC. rtts_with_cnps <= tr_update_cycles
+	 * 7: TR is updated on all reductions.
 	 */
-	uint16_t	target_id;
+	uint8_t	tr_update_cycles;
+	/* Number of RTTs in Fast Recovery stage. */
+	uint8_t	fr_num_rtts;
+	/* Time increment to increase TR in active increase phase. */
+	uint8_t	ai_rate_increase;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Indicates for how many RTTs with CNPs after the first one
+	 * to not reduce rate even if CNPs are received.
 	 */
-	uint64_t	resp_addr;
-} hwrm_fw_state_qcaps_input_t, *phwrm_fw_state_qcaps_input_t;
-
-/* hwrm_fw_state_qcaps_output (size:256b/32B) */
-
-typedef struct hwrm_fw_state_qcaps_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
+	uint16_t	reduction_relax_rtts_th;
 	/*
-	 * This field indicates the size in bytes required by host backup
-	 * memory.  Host software should allocate memory according to this
-	 * size requirement and pass the allocated memory to the
-	 * HWRM_FW_STATE_BACKUP and HWRM_FW_STATE_RESTORE commands in the form
-	 * of PBL data as specified in those commands.
+	 * For low rates, additional number of RTTS with CNPs
+	 * for which no rate reduction is made.
+	 * num_bits: 14
 	 */
-	uint32_t	backup_memory;
+	uint16_t	additional_relax_cr_th;
 	/*
-	 * This field indicates the max time in milliseconds that firmware
-	 * waits for quiesce to complete. Firmware indicates successful
-	 * quiesce completion if the quiesce operation completes within this
-	 * timeout. If firmware is still waiting for the quiesce operation
-	 * to complete when this timeout is reached, firmware stops waiting
-	 * (without cancelling any quiesce action such as pausing or
-	 * clearing meter profiles) and indicates a timeout status result
-	 * via NQE completion notification. This timeout value may also be
-	 * used by the driver to know the max time to wait for any NQE
-	 * notification response to the HWRM_FW_STATE_QUIESCE command. After
-	 * a timeout, the driver may elect to invoke HWRM_FW_STATE_QUIESCE
-	 * again to keep trying or to invoke HWRM_FW_STATE_UNQUIESCE to
-	 * revert the operation. Since there is no identifier correlating
-	 * each HWRM_FW_STATE_QUIESCE command with its NQE response, it is
-	 * important for the driver to wait for the NQE response before
-	 * issuing a subsequent HWRM_FW_STATE_QUIESCE command.
+	 * If CR is less than or equal to this value,
+	 * then the actual CR average is set to this value
+	 * (shifted by bw_avg_weight).
 	 */
-	uint32_t	quiesce_timeout;
+	uint16_t	cr_min_th;
+	/* Log based averaging weight for QPC variable actual_cr_avg. */
+	uint8_t	bw_avg_weight;
 	/*
-	 * This field indicates time in milliseconds that the driver should
-	 * wait after return from HWRM_FW_RESET to begin polling the device
-	 * for status 0x8000.
+	 * Used to compare CR to this factor times QPC.actual_cr_average
+	 * as a reduction reference. Values between 0 and 6 represent factor of
+	 * 1.125, 1.25, 1.5, 1.75, 2, 2.25, 2.5 respectively.
 	 */
-	uint32_t	fw_status_blackout;
+	uint8_t	actual_cr_factor;
+	/* The level of CR above which CP is set to maximum level. */
+	uint16_t	max_cp_cr_th;
 	/*
-	 * This field indicates a max time for firmware to poll for status
-	 * 0x8000 before assuming a reset failure occurred.  This time does
-	 * not include fw_status_blackout time which would immediately precede
-	 * this wait.
+	 * Enable adding fraction of CR to CP.
+	 * 0 for disable, 1 for enable.
 	 */
-	uint32_t	fw_status_max_wait;
-	uint8_t	unused_0[4];
-	uint8_t	unused_1[3];
+	uint8_t	cp_bias_en;
+	/* Log based fraction of cr to add to CP when cp_bias_en is 1. */
+	uint8_t	cp_bias;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * The value of ECN bits in a CNP packet generated by hardware.
+	 * ECN-Capable Transport (ECT) codepoints supported include:
+	 * 0 for not_ect, 1 for ect_0, 2 for ect_1
 	 */
-	uint8_t	valid;
-} hwrm_fw_state_qcaps_output_t, *phwrm_fw_state_qcaps_output_t;
-
-/*************************
- * hwrm_fw_state_quiesce *
- *************************/
-
-
-/* hwrm_fw_state_quiesce_input (size:192b/24B) */
-
-typedef struct hwrm_fw_state_quiesce_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	uint8_t	cnp_ecn;
+	/* Not ECN capable Transport */
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_CNP_ECN_NOT_ECT UINT32_C(0x0)
+	/* ECN Capable Transport-1 */
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_CNP_ECN_ECT_1   UINT32_C(0x1)
+	/* ECN Capable Transport-0 */
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_CNP_ECN_ECT_0   UINT32_C(0x2)
+	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_CNP_ECN_LAST   CMDQ_MODIFY_ROCE_CC_GEN1_TLV_CNP_ECN_ECT_0
+	/* Enables jitter in RTT. */
+	uint8_t	rtt_jitter_en;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * Number of bytes per usec, dependent on port speed.
+	 * 200 Gbps: 25,000
+	 * 100 Gbps: 12,500
+	 * 50 Gbps: 6,250
+	 * 25 Gbps: 3125
+	 * 10 Gbps: 1250
 	 */
-	uint16_t	cmpl_ring;
+	uint16_t	link_bytes_per_usec;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * If CR is greater than or equal to this threshold,
+	 * QPC's CC state is reset to its initial state.
 	 */
-	uint16_t	seq_id;
+	uint16_t	reset_cc_cr_th;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * The number of valid lsbits in CR and TR.
+	 * Supported values include 10 through 14 to support 2^cr_width rate.
 	 */
-	uint16_t	target_id;
+	uint8_t	cr_width;
+	/* Lower end of random selection of quota_period. */
+	uint8_t	quota_period_min;
+	/* Upper end of random selection of quota_period. */
+	uint8_t	quota_period_max;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * The absolute maximum possible quota_period,
+	 * applicable when rate table for lower 24 levels is used.
 	 */
-	uint64_t	resp_addr;
-	uint8_t	flags;
+	uint8_t	quota_period_abs_max;
+	/* TR never goes below this level. */
+	uint16_t	tr_lower_bound;
+	/* Factor on probability threshold for adding 0.5 to CR randomly. */
+	uint8_t	cr_prob_factor;
+	/* Factor on probability threshold for adding 0.5 to TR randomly. */
+	uint8_t	tr_prob_factor;
 	/*
-	 * Setting this bit to '1', indicates impactless firmware update
-	 * is in a recovery mode where hardware is in an error state and
-	 * where recovery is desired with reasonably minimial impact to
-	 * connected clients. The quiesce operation may require separate
-	 * steps to handle quiescing when hardware is in a hung or locked
-	 * state. For example, quiesce via draining may not be possible
-	 * depending on the type of error. This flag's state would be kept
-	 * in firmware if recovery-specific steps are also needed for the
-	 * HWRM_FW_STATE_BACKUP. Note this option is available only for
-	 * specific recovery scenarios and may not be operational across
-	 * all controllers.
+	 * Threshold to ensure fairness between requester and responder.
+	 * If CR is less than the fairness threshold and a quota period has
+	 * passed priority will be given to the path that did not last
+	 * transfer data.
 	 */
-	#define HWRM_FW_STATE_QUIESCE_INPUT_FLAGS_ERROR_RECOVERY	UINT32_C(0x1)
-	uint8_t	unused_0[7];
-} hwrm_fw_state_quiesce_input_t, *phwrm_fw_state_quiesce_input_t;
-
-/* hwrm_fw_state_quiesce_output (size:192b/24B) */
-
-typedef struct hwrm_fw_state_quiesce_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint32_t	quiesce_status;
+	uint16_t	fairness_cr_th;
+	/* Log based rate reduction divider. */
+	uint8_t	red_div;
+	/* Threshold for rate reductions when CNPS received over last RTT. */
+	uint8_t	cnp_ratio_th;
 	/*
-	 * This bit is '1' if the quiesce request has been successfully
-	 * initiated.
+	 * Extended number of RTTS to wait, when there is no congestion,
+	 * to start doubling the rate.
 	 */
-	#define HWRM_FW_STATE_QUIESCE_OUTPUT_QUIESCE_STATUS_INITIATED	UINT32_C(0x80000000)
-	uint8_t	unused_0[4];
-	uint8_t	unused_1[7];
+	uint16_t	exp_ai_rtts;
+	/* Log based CR to CP ratio used in exponential increase. */
+	uint8_t	exp_ai_cr_cp_ratio;
+	/* Enable use of lowest 24 rate levels rate_table. */
+	uint8_t	use_rate_table;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM. This field should be read as '1' to
-	 * indicate that the output has been completely written. When
-	 * writing a command completion or response to an internal
-	 * processor, the order of writes has to be such that this field is
-	 * written last.
+	 * Determines after how many congestion free RTTs to start
+	 * updating CP to track CR.
 	 */
-	uint8_t	valid;
-} hwrm_fw_state_quiesce_output_t, *phwrm_fw_state_quiesce_output_t;
-
-/***************************
- * hwrm_fw_state_unquiesce *
- ***************************/
-
-
-/* hwrm_fw_state_unquiesce_input (size:128b/16B) */
-
-typedef struct hwrm_fw_state_unquiesce_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	uint16_t	cp_exp_update_th;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * The threshold on congestion free RTTs above which AI can increase
+	 * to 16.
 	 */
-	uint16_t	cmpl_ring;
+	uint16_t	high_exp_ai_rtts_th1;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * The threshold on congestion free RTTs above which AI can increase
+	 * to 32.
 	 */
-	uint16_t	seq_id;
+	uint16_t	high_exp_ai_rtts_th2;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * The number of congestion free RTTs above which
+	 * reduction based on actual rate is enabled.
 	 */
-	uint16_t	target_id;
+	uint16_t	actual_cr_cong_free_rtts_th;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * If rtts_with_cong is greater than 7 (severe congestion) and
+	 * CR level post reduction is above this threshold,
+	 * then TR is capped to 1.5 times CR..
 	 */
-	uint64_t	resp_addr;
-} hwrm_fw_state_unquiesce_input_t, *phwrm_fw_state_unquiesce_input_t;
-
-/* hwrm_fw_state_unquiesce_output (size:192b/24B) */
-
-typedef struct hwrm_fw_state_unquiesce_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint32_t	unquiesce_status;
-	/* This bit is '1' if the unquiesce request has fully completed. */
-	#define HWRM_FW_STATE_UNQUIESCE_OUTPUT_UNQUIESCE_STATUS_COMPLETE	UINT32_C(0x80000000)
-	uint8_t	unused_0[4];
-	uint8_t	unused_1[7];
+	uint16_t	severe_cong_cr_th1;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * If rtts_with_cong is greater than 7 (severe congestion) and
+	 * CR level post reduction is above this threshold,
+	 * then TR is capped to 1.25 times CR..
 	 */
-	uint8_t	valid;
-} hwrm_fw_state_unquiesce_output_t, *phwrm_fw_state_unquiesce_output_t;
-
-/************************
- * hwrm_fw_state_backup *
- ************************/
-
-
-/* hwrm_fw_state_backup_input (size:256b/32B) */
-
-typedef struct hwrm_fw_state_backup_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	uint16_t	severe_cong_cr_th2;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * The maximum number of 64B that can be transmitted during RTT time,
+	 * including all headers and Inter Packet Gap.
 	 */
-	uint16_t	cmpl_ring;
-	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	uint32_t	link64B_per_rtt;
+	/*
+	 * The number of bytes to subtract from QPC.cc_bucket
+	 * when an ack is scheduled.
 	 */
-	uint16_t	seq_id;
+	uint8_t	cc_ack_bytes;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Enables reduction of CR, TR, and CP to init values when
+	 * congestion free RTTs is greater than reduce2_init_cong_free_rtts_th.
 	 */
-	uint16_t	target_id;
+	uint8_t	reduce_init_en;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Minimum threshold value for number of congestion free RTTs before
+	 * reducing to init values for CR, TR, and CP when reduce_init_en is
+	 * enabled.
 	 */
-	uint64_t	resp_addr;
-	/* State backup page size and level. */
-	uint8_t	backup_pg_size_backup_lvl;
-	/* State backup PBL indirect levels. */
-	#define HWRM_FW_STATE_BACKUP_INPUT_BACKUP_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FW_STATE_BACKUP_INPUT_BACKUP_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_FW_STATE_BACKUP_INPUT_BACKUP_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_FW_STATE_BACKUP_INPUT_BACKUP_LVL_LVL_1	UINT32_C(0x1)
+	uint16_t	reduce_init_cong_free_rtts_th;
+	/* Enables random no reduction of CR. */
+	uint8_t	random_no_red_en;
 	/*
-	 * PBL pointer points to PDE table with each entry pointing to PTE
-	 * tables.
+	 * Enables coarse correction to actual CR when actual RTT is longer
+	 * than nominal.
 	 */
-		#define HWRM_FW_STATE_BACKUP_INPUT_BACKUP_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FW_STATE_BACKUP_INPUT_BACKUP_LVL_LAST	HWRM_FW_STATE_BACKUP_INPUT_BACKUP_LVL_LVL_2
-	/* State backup page size. */
-	#define HWRM_FW_STATE_BACKUP_INPUT_BACKUP_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FW_STATE_BACKUP_INPUT_BACKUP_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_FW_STATE_BACKUP_INPUT_BACKUP_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_FW_STATE_BACKUP_INPUT_BACKUP_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_FW_STATE_BACKUP_INPUT_BACKUP_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_FW_STATE_BACKUP_INPUT_BACKUP_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_FW_STATE_BACKUP_INPUT_BACKUP_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_FW_STATE_BACKUP_INPUT_BACKUP_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FW_STATE_BACKUP_INPUT_BACKUP_PG_SIZE_LAST   HWRM_FW_STATE_BACKUP_INPUT_BACKUP_PG_SIZE_PG_1G
-	uint8_t	unused_0[7];
-	/* State backup page directory. */
-	uint64_t	backup_page_dir;
-} hwrm_fw_state_backup_input_t, *phwrm_fw_state_backup_input_t;
+	uint8_t	actual_cr_shift_correction_en;
+	/* Enables adjustment to refill quota. */
+	uint8_t	quota_period_adjust_en;
+	uint8_t	reserved[5];
+} cmdq_modify_roce_cc_gen1_tlv_t, *pcmdq_modify_roce_cc_gen1_tlv_t;
 
-/* hwrm_fw_state_backup_output (size:192b/24B) */
+/* cmdq_modify_roce_cc_gen2_tlv (size:256b/32B) */
 
-typedef struct hwrm_fw_state_backup_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint32_t	backup_status;
+typedef struct cmdq_modify_roce_cc_gen2_tlv {
 	/*
-	 * This bit field provides additional information if the error if
-	 * error_code in the common HWRM header is set.
+	 * The command discriminator is used to differentiate between various
+	 * types of HWRM messages. This includes legacy HWRM and RoCE slowpath
+	 * command messages as well as newer TLV encapsulated HWRM commands.
+	 *
+	 * For TLV encapsulated messages this field must be 0x8000.
 	 */
-	#define HWRM_FW_STATE_BACKUP_OUTPUT_BACKUP_STATUS_ERR_CODE_MASK	UINT32_C(0xff)
-	#define HWRM_FW_STATE_BACKUP_OUTPUT_BACKUP_STATUS_ERR_CODE_SFT	0
-	/* Success, no error */
-		#define HWRM_FW_STATE_BACKUP_OUTPUT_BACKUP_STATUS_ERR_CODE_SUCCESS	UINT32_C(0x0)
-	/* Data or control plane detected as non-quiesced */
-		#define HWRM_FW_STATE_BACKUP_OUTPUT_BACKUP_STATUS_ERR_CODE_QUIESCE_ERROR  UINT32_C(0x1)
-	/* General backup error */
-		#define HWRM_FW_STATE_BACKUP_OUTPUT_BACKUP_STATUS_ERR_CODE_GENERAL	UINT32_C(0x3)
-		#define HWRM_FW_STATE_BACKUP_OUTPUT_BACKUP_STATUS_ERR_CODE_LAST	HWRM_FW_STATE_BACKUP_OUTPUT_BACKUP_STATUS_ERR_CODE_GENERAL
+	uint16_t	cmd_discr;
+	uint8_t	reserved_8b;
+	uint8_t	tlv_flags;
 	/*
-	 * This bit is '0' if the backout was done in a way that firmware
-	 * may continue running normally after the backup, for example if
-	 * the host elects to skip the subsequent reset and restore for any
-	 * reason.  A value of '1' indicates the act of backing up has left
-	 * the firmware/device in a state where subsequent reset is
-	 * required, for example of probing state of a queue leaves changes
-	 * state in a way that is detectable by users.
+	 * Indicates the presence of additional TLV encapsulated data
+	 * follows this TLV.
 	 */
-	#define HWRM_FW_STATE_BACKUP_OUTPUT_BACKUP_STATUS_RESET_REQUIRED	UINT32_C(0x40000000)
-	/* This bit is '1' if the backup request has fully completed. */
-	#define HWRM_FW_STATE_BACKUP_OUTPUT_BACKUP_STATUS_COMPLETE		UINT32_C(0x80000000)
-	uint8_t	unused_0[4];
-	uint8_t	unused_1[7];
+	#define CMDQ_MODIFY_ROCE_CC_GEN2_TLV_TLV_FLAGS_MORE	UINT32_C(0x1)
+	/* Last TLV in a sequence of TLVs. */
+		#define CMDQ_MODIFY_ROCE_CC_GEN2_TLV_TLV_FLAGS_MORE_LAST	UINT32_C(0x0)
+	/* More TLVs follow this TLV. */
+		#define CMDQ_MODIFY_ROCE_CC_GEN2_TLV_TLV_FLAGS_MORE_NOT_LAST  UINT32_C(0x1)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When an HWRM receiver detects a TLV type that it does not
+	 * support with the TLV required flag set, the receiver must
+	 * reject the HWRM message with an error code indicating an
+	 * unsupported TLV type.
 	 */
-	uint8_t	valid;
-} hwrm_fw_state_backup_output_t, *phwrm_fw_state_backup_output_t;
-
-/*************************
- * hwrm_fw_state_restore *
- *************************/
-
-
-/* hwrm_fw_state_restore_input (size:256b/32B) */
-
-typedef struct hwrm_fw_state_restore_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define CMDQ_MODIFY_ROCE_CC_GEN2_TLV_TLV_FLAGS_REQUIRED	UINT32_C(0x2)
+	/* No */
+		#define CMDQ_MODIFY_ROCE_CC_GEN2_TLV_TLV_FLAGS_REQUIRED_NO	(UINT32_C(0x0) << 1)
+	/* Yes */
+		#define CMDQ_MODIFY_ROCE_CC_GEN2_TLV_TLV_FLAGS_REQUIRED_YES   (UINT32_C(0x1) << 1)
+		#define CMDQ_MODIFY_ROCE_CC_GEN2_TLV_TLV_FLAGS_REQUIRED_LAST CMDQ_MODIFY_ROCE_CC_GEN2_TLV_TLV_FLAGS_REQUIRED_YES
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * This field defines the TLV type value which is divided into
+	 * two ranges to differentiate between global and local TLV types.
+	 * Global TLV types must be unique across all defined TLV types.
+	 * Local TLV types are valid only for extensions to a given
+	 * HWRM message and may be repeated across different HWRM message
+	 * types. There is a direct correlation of each HWRM message type
+	 * to a single global TLV type value.
+	 *
+	 * Global TLV range: `0 - (63k-1)`
+	 *
+	 * Local TLV range: `63k - (64k-1)`
 	 */
-	uint16_t	cmpl_ring;
+	uint16_t	tlv_type;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Length of the message data encapsulated by this TLV in bytes.
+	 * This length does not include the size of the TLV header itself
+	 * and it must be an integer multiple of 8B.
 	 */
-	uint16_t	seq_id;
+	uint16_t	length;
+	uint64_t	reserved64;
+	/* Modify mask signifies the field that is requesting the change. */
+	uint64_t	modify_mask;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Modify the specific DCN queue level table index data.
+	 * This must be set, to select the table index that needs an
+	 * update.
 	 */
-	uint16_t	target_id;
+	#define CMDQ_MODIFY_ROCE_CC_GEN2_TLV_MODIFY_MASK_DCN_QLEVEL_TBL_IDX	UINT32_C(0x1)
+	/* Modify the DCN queue level threshold. */
+	#define CMDQ_MODIFY_ROCE_CC_GEN2_TLV_MODIFY_MASK_DCN_QLEVEL_TBL_THR	UINT32_C(0x2)
+	/* Modify DCN queue level current rate. */
+	#define CMDQ_MODIFY_ROCE_CC_GEN2_TLV_MODIFY_MASK_DCN_QLEVEL_TBL_CR	UINT32_C(0x4)
+	/* Modify DCN queue level increment CNP count. */
+	#define CMDQ_MODIFY_ROCE_CC_GEN2_TLV_MODIFY_MASK_DCN_QLEVEL_TBL_INC_CNP	UINT32_C(0x8)
+	/* Modify DCN queue level update current & target rate immediately. */
+	#define CMDQ_MODIFY_ROCE_CC_GEN2_TLV_MODIFY_MASK_DCN_QLEVEL_TBL_UPD_IMM	UINT32_C(0x10)
+	/* Modify DCN queue level target rate. */
+	#define CMDQ_MODIFY_ROCE_CC_GEN2_TLV_MODIFY_MASK_DCN_QLEVEL_TBL_TR	UINT32_C(0x20)
+	/* DCN queue level table index. Valid values are from 0 to 7. */
+	uint8_t	dcn_qlevel_tbl_idx;
+	uint8_t	reserved8;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * DCN queue level threshold value associated with a DCN queue
+	 * level table index.
 	 */
-	uint64_t	resp_addr;
-	/* State restore page size and level. */
-	uint8_t	restore_pg_size_restore_lvl;
-	/* State restore PBL indirect levels. */
-	#define HWRM_FW_STATE_RESTORE_INPUT_RESTORE_LVL_MASK	UINT32_C(0xf)
-	#define HWRM_FW_STATE_RESTORE_INPUT_RESTORE_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_FW_STATE_RESTORE_INPUT_RESTORE_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_FW_STATE_RESTORE_INPUT_RESTORE_LVL_LVL_1	UINT32_C(0x1)
+	uint16_t	dcn_qlevel_tbl_thr;
 	/*
-	 * PBL pointer points to PDE table with each entry pointing to PTE
-	 * tables.
+	 * DCN queue level table action.
+	 * Updates CR, INC_CNP, UPD_IMM & TR fields associated with the
+	 * DCN queue level table index.
 	 */
-		#define HWRM_FW_STATE_RESTORE_INPUT_RESTORE_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_FW_STATE_RESTORE_INPUT_RESTORE_LVL_LAST	HWRM_FW_STATE_RESTORE_INPUT_RESTORE_LVL_LVL_2
-	/* State restore page size. */
-	#define HWRM_FW_STATE_RESTORE_INPUT_RESTORE_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define HWRM_FW_STATE_RESTORE_INPUT_RESTORE_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define HWRM_FW_STATE_RESTORE_INPUT_RESTORE_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define HWRM_FW_STATE_RESTORE_INPUT_RESTORE_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define HWRM_FW_STATE_RESTORE_INPUT_RESTORE_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define HWRM_FW_STATE_RESTORE_INPUT_RESTORE_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define HWRM_FW_STATE_RESTORE_INPUT_RESTORE_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define HWRM_FW_STATE_RESTORE_INPUT_RESTORE_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define HWRM_FW_STATE_RESTORE_INPUT_RESTORE_PG_SIZE_LAST   HWRM_FW_STATE_RESTORE_INPUT_RESTORE_PG_SIZE_PG_1G
-	uint8_t	unused_0[7];
-	/* State restore page directory. */
-	uint64_t	restore_page_dir;
-} hwrm_fw_state_restore_input_t, *phwrm_fw_state_restore_input_t;
+	uint32_t	dcn_qlevel_tbl_act;
+	/* DCN queue level current rate. */
+	#define CMDQ_MODIFY_ROCE_CC_GEN2_TLV_DCN_QLEVEL_TBL_ACT_CR_MASK	UINT32_C(0x3fff)
+	#define CMDQ_MODIFY_ROCE_CC_GEN2_TLV_DCN_QLEVEL_TBL_ACT_CR_SFT	0
+	/* DCN queue level increment CNP count. */
+	#define CMDQ_MODIFY_ROCE_CC_GEN2_TLV_DCN_QLEVEL_TBL_ACT_INC_CNP	UINT32_C(0x4000)
+	/* DCN queue level update CR and TR immediately. */
+	#define CMDQ_MODIFY_ROCE_CC_GEN2_TLV_DCN_QLEVEL_TBL_ACT_UPD_IMM	UINT32_C(0x8000)
+	/* DCN queue level target rate */
+	#define CMDQ_MODIFY_ROCE_CC_GEN2_TLV_DCN_QLEVEL_TBL_ACT_TR_MASK	UINT32_C(0x3fff0000)
+	#define CMDQ_MODIFY_ROCE_CC_GEN2_TLV_DCN_QLEVEL_TBL_ACT_TR_SFT	16
+} cmdq_modify_roce_cc_gen2_tlv_t, *pcmdq_modify_roce_cc_gen2_tlv_t;
 
-/* hwrm_fw_state_restore_output (size:128b/16B) */
+/* creq_modify_roce_cc_resp (size:128b/16B) */
 
-typedef struct hwrm_fw_state_restore_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint32_t	restore_status;
-	/*
-	 * This bit field provides additional information if the error if
-	 * error_code in the common HWRM header is set.
-	 */
-	#define HWRM_FW_STATE_RESTORE_OUTPUT_RESTORE_STATUS_ERR_CODE_MASK		UINT32_C(0xff)
-	#define HWRM_FW_STATE_RESTORE_OUTPUT_RESTORE_STATUS_ERR_CODE_SFT		0
-	/* Success, no error */
-		#define HWRM_FW_STATE_RESTORE_OUTPUT_RESTORE_STATUS_ERR_CODE_SUCCESS		UINT32_C(0x0)
-	/* General restore error */
-		#define HWRM_FW_STATE_RESTORE_OUTPUT_RESTORE_STATUS_ERR_CODE_GENERAL		UINT32_C(0x1)
-	/* Format parse error */
-		#define HWRM_FW_STATE_RESTORE_OUTPUT_RESTORE_STATUS_ERR_CODE_FORMAT_PARSE		UINT32_C(0x2)
-	/* Integrity check error */
-		#define HWRM_FW_STATE_RESTORE_OUTPUT_RESTORE_STATUS_ERR_CODE_INTEGRITY_CHECK	UINT32_C(0x3)
-		#define HWRM_FW_STATE_RESTORE_OUTPUT_RESTORE_STATUS_ERR_CODE_LAST		HWRM_FW_STATE_RESTORE_OUTPUT_RESTORE_STATUS_ERR_CODE_INTEGRITY_CHECK
+typedef struct creq_modify_roce_cc_resp {
+	uint8_t	type;
 	/*
-	 * If a failure occurs (complete is 0), restore attempts to
-	 * completely roll back any state applied so that the failure
-	 * results in no state change.  This flag indidicates whether that
-	 * rollback completed successfully and thoroughly.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	#define HWRM_FW_STATE_RESTORE_OUTPUT_RESTORE_STATUS_FAILURE_ROLLBACK_COMPLETED	UINT32_C(0x40000000)
-	/* This bit is '1' if the restore request has fully completed. */
-	#define HWRM_FW_STATE_RESTORE_OUTPUT_RESTORE_STATUS_COMPLETE			UINT32_C(0x80000000)
-	uint8_t	unused_0[3];
+	#define CREQ_MODIFY_ROCE_CC_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_MODIFY_ROCE_CC_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_MODIFY_ROCE_CC_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_MODIFY_ROCE_CC_RESP_TYPE_LAST	CREQ_MODIFY_ROCE_CC_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	uint32_t	reserved32;
+	uint8_t	v;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint8_t	valid;
-} hwrm_fw_state_restore_output_t, *phwrm_fw_state_restore_output_t;
+	#define CREQ_MODIFY_ROCE_CC_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Modify congestion control response. */
+	#define CREQ_MODIFY_ROCE_CC_RESP_EVENT_MODIFY_ROCE_CC UINT32_C(0x8c)
+	#define CREQ_MODIFY_ROCE_CC_RESP_EVENT_LAST	CREQ_MODIFY_ROCE_CC_RESP_EVENT_MODIFY_ROCE_CC
+	uint8_t	reserved48[6];
+} creq_modify_roce_cc_resp_t, *pcreq_modify_roce_cc_resp_t;
 
-/**********************
- * hwrm_exec_fwd_resp *
- **********************/
+/******************************
+ * cmdq_set_link_aggr_mode_cc *
+ ******************************/
 
 
-/* hwrm_exec_fwd_resp_input (size:1024b/128B) */
+/* cmdq_set_link_aggr_mode_cc (size:320b/40B) */
 
-typedef struct hwrm_exec_fwd_resp_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
-	 */
-	uint16_t	cmpl_ring;
+typedef struct cmdq_set_link_aggr_mode_cc {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Set LAG mode. */
+	#define CMDQ_SET_LINK_AGGR_MODE_OPCODE_SET_LINK_AGGR_MODE UINT32_C(0x8f)
+	#define CMDQ_SET_LINK_AGGR_MODE_OPCODE_LAST		CMDQ_SET_LINK_AGGR_MODE_OPCODE_SET_LINK_AGGR_MODE
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+	/* Modify mask signifies the field that is requesting the change. */
+	uint32_t	modify_mask;
+	/* Enable Link aggregation. */
+	#define CMDQ_SET_LINK_AGGR_MODE_MODIFY_MASK_AGGR_EN		UINT32_C(0x1)
+	/* Bitmap of ports that are eligible to transmit RoCE traffic. */
+	#define CMDQ_SET_LINK_AGGR_MODE_MODIFY_MASK_ACTIVE_PORT_MAP	UINT32_C(0x2)
+	/* Bitmap of ports that are members of the RoCE LAG. */
+	#define CMDQ_SET_LINK_AGGR_MODE_MODIFY_MASK_MEMBER_PORT_MAP	UINT32_C(0x4)
+	/* Link aggregation mode being used. */
+	#define CMDQ_SET_LINK_AGGR_MODE_MODIFY_MASK_AGGR_MODE	UINT32_C(0x8)
+	/* Stat context ID for all the ports. */
+	#define CMDQ_SET_LINK_AGGR_MODE_MODIFY_MASK_STAT_CTX_ID	UINT32_C(0x10)
+	uint8_t	aggr_enable;
+	/* Enable Link aggregation. */
+	#define CMDQ_SET_LINK_AGGR_MODE_AGGR_ENABLE	UINT32_C(0x1)
+	/* rsvd1 is 7 b */
+	#define CMDQ_SET_LINK_AGGR_MODE_RSVD1_MASK	UINT32_C(0xfe)
+	#define CMDQ_SET_LINK_AGGR_MODE_RSVD1_SFT	1
+	uint8_t	active_port_map;
+	/* Bitmap of ports that are eligible to transmit RoCE traffic. */
+	#define CMDQ_SET_LINK_AGGR_MODE_ACTIVE_PORT_MAP_MASK UINT32_C(0xf)
+	#define CMDQ_SET_LINK_AGGR_MODE_ACTIVE_PORT_MAP_SFT 0
+	/* rsvd2 is 4 b */
+	#define CMDQ_SET_LINK_AGGR_MODE_RSVD2_MASK	UINT32_C(0xf0)
+	#define CMDQ_SET_LINK_AGGR_MODE_RSVD2_SFT	4
+	/* Bitmap of ports that are members of the RoCE LAG. */
+	uint8_t	member_port_map;
+	/* Link aggregation mode being used. */
+	uint8_t	link_aggr_mode;
+	/* active active mode. */
+	#define CMDQ_SET_LINK_AGGR_MODE_AGGR_MODE_ACTIVE_ACTIVE UINT32_C(0x1)
+	/* active backup mode. */
+	#define CMDQ_SET_LINK_AGGR_MODE_AGGR_MODE_ACTIVE_BACKUP UINT32_C(0x2)
+	/* Balance XOR mode. */
+	#define CMDQ_SET_LINK_AGGR_MODE_AGGR_MODE_BALANCE_XOR   UINT32_C(0x3)
+	/* 802.3AD mode. */
+	#define CMDQ_SET_LINK_AGGR_MODE_AGGR_MODE_802_3_AD	UINT32_C(0x4)
+	#define CMDQ_SET_LINK_AGGR_MODE_AGGR_MODE_LAST	CMDQ_SET_LINK_AGGR_MODE_AGGR_MODE_802_3_AD
+	/* Stat context IDs for all 4 ports. */
+	uint16_t	stat_ctx_id[4];
+	uint64_t	rsvd1;
+} cmdq_set_link_aggr_mode_cc_t, *pcmdq_set_link_aggr_mode_cc_t;
+
+/* creq_set_link_aggr_mode_resources_resp (size:128b/16B) */
+
+typedef struct creq_set_link_aggr_mode_resources_resp {
+	uint8_t	type;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint16_t	seq_id;
+	#define CREQ_SET_LINK_AGGR_MODE_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_SET_LINK_AGGR_MODE_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_SET_LINK_AGGR_MODE_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_SET_LINK_AGGR_MODE_RESP_TYPE_LAST	CREQ_SET_LINK_AGGR_MODE_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	uint32_t	reserved32;
+	uint8_t	v;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint16_t	target_id;
+	#define CREQ_SET_LINK_AGGR_MODE_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Set LAG mode. */
+	#define CREQ_SET_LINK_AGGR_MODE_RESP_EVENT_SET_LINK_AGGR_MODE UINT32_C(0x8f)
+	#define CREQ_SET_LINK_AGGR_MODE_RESP_EVENT_LAST		CREQ_SET_LINK_AGGR_MODE_RESP_EVENT_SET_LINK_AGGR_MODE
+	uint8_t	reserved48[6];
+} creq_set_link_aggr_mode_resources_resp_t, *pcreq_set_link_aggr_mode_resources_resp_t;
+
+/* Send a request from VF to pass a command to the PF. VF HSI is suspended. */
+/* cmdq_vf_backchannel_request (size:256b/32B) */
+
+typedef struct cmdq_vf_backchannel_request {
+	/* Command opcode. */
+	uint8_t	opcode;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Send a request from VF to pass a command to the PF. VF HSI is
+	 * suspended until the PF returns the response.
 	 */
+	#define CMDQ_VF_BACKCHANNEL_REQUEST_OPCODE_VF_BACKCHANNEL_REQUEST UINT32_C(0x86)
+	#define CMDQ_VF_BACKCHANNEL_REQUEST_OPCODE_LAST		CMDQ_VF_BACKCHANNEL_REQUEST_OPCODE_VF_BACKCHANNEL_REQUEST
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
 	uint64_t	resp_addr;
+	/* Address of command request structure in VF space */
+	uint64_t	command_addr;
 	/*
-	 * This is an encapsulated request. This request should
-	 * be executed by the HWRM and the response should be
-	 * provided in the response buffer inside the encapsulated
-	 * request.
-	 */
-	uint32_t	encap_request[26];
-	/*
-	 * This value indicates the target id of the response to
-	 * the encapsulated request.
-	 * 0x0 - 0xFFF8 - Used for function ids
-	 * 0xFFF8 - 0xFFFE - Reserved for internal processors
-	 * 0xFFFF - HWRM
+	 * Command request length (up to 4K). An optional address of the extended
+	 * response buffer should be provided in the request.
 	 */
-	uint16_t	encap_resp_target_id;
+	uint16_t	command_length;
 	uint8_t	unused_0[6];
-} hwrm_exec_fwd_resp_input_t, *phwrm_exec_fwd_resp_input_t;
+} cmdq_vf_backchannel_request_t, *pcmdq_vf_backchannel_request_t;
 
-/* hwrm_exec_fwd_resp_output (size:128b/16B) */
+/* Read VF memory (primarily to get the backchannel request blob). */
+/* cmdq_read_vf_memory (size:256b/32B) */
 
-typedef struct hwrm_exec_fwd_resp_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+typedef struct cmdq_read_vf_memory {
+	/* Command opcode. */
+	uint8_t	opcode;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * Read VF memory (primarily to get the backchannel request blob). Can
+	 * only be issued from a PF.
 	 */
-	uint8_t	valid;
-} hwrm_exec_fwd_resp_output_t, *phwrm_exec_fwd_resp_output_t;
-
-/************************
- * hwrm_reject_fwd_resp *
- ************************/
-
+	#define CMDQ_READ_VF_MEMORY_OPCODE_READ_VF_MEMORY UINT32_C(0x87)
+	#define CMDQ_READ_VF_MEMORY_OPCODE_LAST	CMDQ_READ_VF_MEMORY_OPCODE_READ_VF_MEMORY
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+	/* Address of memory in VF space to read */
+	uint64_t	addr;
+	/* VF id, as provided in 0xC0 VF request notification */
+	uint16_t	vf_id;
+	/* Length to read, up to 4K */
+	uint16_t	length;
+	uint32_t	unused_0;
+} cmdq_read_vf_memory_t, *pcmdq_read_vf_memory_t;
 
-/* hwrm_reject_fwd_resp_input (size:1024b/128B) */
+/* Write VF memory (primarily to put the backchannel response blob). */
+/* cmdq_complete_vf_request (size:320b/40B) */
 
-typedef struct hwrm_reject_fwd_resp_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
-	 */
-	uint16_t	cmpl_ring;
-	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
-	 */
-	uint16_t	seq_id;
-	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
-	 */
-	uint16_t	target_id;
+typedef struct cmdq_complete_vf_request {
+	/* Command opcode. */
+	uint8_t	opcode;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Write VF memory (primarily to put the backchannel response blob),
+	 * and reenable VF HSI (post a CAG completion to it). Can only be
+	 * issued from a PF.
 	 */
+	#define CMDQ_COMPLETE_VF_REQUEST_OPCODE_COMPLETE_VF_REQUEST UINT32_C(0x88)
+	#define CMDQ_COMPLETE_VF_REQUEST_OPCODE_LAST		CMDQ_COMPLETE_VF_REQUEST_OPCODE_COMPLETE_VF_REQUEST
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
 	uint64_t	resp_addr;
 	/*
-	 * This is an encapsulated request. This request should
-	 * be rejected by the HWRM and the error response should be
-	 * provided in the response buffer inside the encapsulated
-	 * request.
+	 * Optional address of extended response in VF space to write. Length is
+	 * in resp_size in 16 byte units.
 	 */
-	uint32_t	encap_request[26];
+	uint64_t	addr;
+	/* Completion misc field to VF CREQ */
+	uint32_t	vf_misc;
+	/* VF id, as provided in 0xC0 VF request notification */
+	uint16_t	vf_id;
+	/* Completion cookie for the VF command, goes to VF CREQ */
+	uint16_t	vf_cookie;
+	/* Completion status for the VF command, goes to VF CREQ */
+	uint8_t	vf_status;
+	uint8_t	unused_0[3];
+	uint32_t	unused_1;
+} cmdq_complete_vf_request_t, *pcmdq_complete_vf_request_t;
+
+/*****************************
+ * orchestrate_qid_migration *
+ *****************************/
+
+
+/* cmdq_orchestrate_qid_migration (size:256b/32B) */
+
+typedef struct cmdq_orchestrate_qid_migration {
+	/* Command opcode. */
+	uint8_t	opcode;
 	/*
-	 * This value indicates the target id of the response to
-	 * the encapsulated request.
-	 * 0x0 - 0xFFF8 - Used for function ids
-	 * 0xFFF8 - 0xFFFE - Reserved for internal processors
-	 * 0xFFFF - HWRM
+	 * This command updates the QP context id ranges on the PF,
+	 * to orchestrate QP context id range migration for devices that
+	 * support the pseudo-static QP allocation feature.
 	 */
-	uint16_t	encap_resp_target_id;
-	uint8_t	unused_0[6];
-} hwrm_reject_fwd_resp_input_t, *phwrm_reject_fwd_resp_input_t;
+	#define CMDQ_ORCHESTRATE_QID_MIGRATION_OPCODE_ORCHESTRATE_QID_MIGRATION UINT32_C(0x93)
+	#define CMDQ_ORCHESTRATE_QID_MIGRATION_OPCODE_LAST			CMDQ_ORCHESTRATE_QID_MIGRATION_OPCODE_ORCHESTRATE_QID_MIGRATION
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+	uint8_t	qid_migration_flags;
+	/* Flags to orchestrate QP context ID range migration amongst PFs. */
+	#define CMDQ_ORCHESTRATE_QID_MIGRATION_QID_MIGRATION_FLAGS_MASK			UINT32_C(0xf)
+	#define CMDQ_ORCHESTRATE_QID_MIGRATION_QID_MIGRATION_FLAGS_SFT			0
+	/* Enable the PF's native QP context ID range. */
+		#define CMDQ_ORCHESTRATE_QID_MIGRATION_QID_MIGRATION_FLAGS_ENABLE_NATIVE_QID_RANGE	UINT32_C(0x0)
+	/* Enable the PF's extended QP context ID range. */
+		#define CMDQ_ORCHESTRATE_QID_MIGRATION_QID_MIGRATION_FLAGS_ENABLE_EXTENDED_QID_RANGE   UINT32_C(0x1)
+	/* Disable the PF's native QP context ID range. */
+		#define CMDQ_ORCHESTRATE_QID_MIGRATION_QID_MIGRATION_FLAGS_DISABLE_NATIVE_QID_RANGE	UINT32_C(0x2)
+	/* Disable the PF's extended QP context ID range. */
+		#define CMDQ_ORCHESTRATE_QID_MIGRATION_QID_MIGRATION_FLAGS_DISABLE_EXTENDED_QID_RANGE  UINT32_C(0x3)
+		#define CMDQ_ORCHESTRATE_QID_MIGRATION_QID_MIGRATION_FLAGS_LAST			CMDQ_ORCHESTRATE_QID_MIGRATION_QID_MIGRATION_FLAGS_DISABLE_EXTENDED_QID_RANGE
+	/* unused4 is 4 b */
+	#define CMDQ_ORCHESTRATE_QID_MIGRATION_UNUSED4_MASK				UINT32_C(0xf0)
+	#define CMDQ_ORCHESTRATE_QID_MIGRATION_UNUSED4_SFT				4
+	uint8_t	reserved56[7];
+	/* reserved64 is 64 b */
+	uint64_t	reserved64;
+} cmdq_orchestrate_qid_migration_t, *pcmdq_orchestrate_qid_migration_t;
 
-/* hwrm_reject_fwd_resp_output (size:128b/16B) */
+/* creq_orchestrate_qid_migration_resp (size:128b/16B) */
 
-typedef struct hwrm_reject_fwd_resp_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+typedef struct creq_orchestrate_qid_migration_resp {
+	uint8_t	type;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint8_t	valid;
-} hwrm_reject_fwd_resp_output_t, *phwrm_reject_fwd_resp_output_t;
+	#define CREQ_ORCHESTRATE_QID_MIGRATION_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_ORCHESTRATE_QID_MIGRATION_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_ORCHESTRATE_QID_MIGRATION_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_ORCHESTRATE_QID_MIGRATION_RESP_TYPE_LAST	CREQ_ORCHESTRATE_QID_MIGRATION_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	uint32_t	reserved32;
+	uint8_t	v;
+	/*
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
+	 */
+	#define CREQ_ORCHESTRATE_QID_MIGRATION_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Orchestrate QPID migration command response. */
+	#define CREQ_ORCHESTRATE_QID_MIGRATION_RESP_EVENT_ORCHESTRATE_QID_MIGRATION UINT32_C(0x93)
+	#define CREQ_ORCHESTRATE_QID_MIGRATION_RESP_EVENT_LAST			CREQ_ORCHESTRATE_QID_MIGRATION_RESP_EVENT_ORCHESTRATE_QID_MIGRATION
+	uint8_t	reserved48[6];
+} creq_orchestrate_qid_migration_resp_t, *pcreq_orchestrate_qid_migration_resp_t;
 
-/*****************
- * hwrm_fwd_resp *
- *****************/
+/*******************
+ * create_qp_batch *
+ *******************/
 
 
-/* hwrm_fwd_resp_input (size:1024b/128B) */
+/* cmdq_create_qp_batch (size:384b/48B) */
 
-typedef struct hwrm_fwd_resp_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+typedef struct cmdq_create_qp_batch {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* This command allocates a batch of QPs in a sequential range. */
+	#define CMDQ_CREATE_QP_BATCH_OPCODE_CREATE_QP_BATCH UINT32_C(0x94)
+	#define CMDQ_CREATE_QP_BATCH_OPCODE_LAST	CMDQ_CREATE_QP_BATCH_OPCODE_CREATE_QP_BATCH
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+	/* Starting QP context id to be used for the sequential range. */
+	uint32_t	start_xid;
+	/* Count of QPs to be allocated */
+	uint32_t	count;
+	/* Size of an individual element of the qp_params_array. */
+	uint32_t	per_qp_param_size;
+	uint32_t	reserved32;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * Host DMA address of the array of per-QP parameters.
+	 * Per-QP parameters are identical to those of the
+	 * `create_qp` command and specified by the
+	 * `create_qp_batch_data` structure.
 	 */
-	uint16_t	cmpl_ring;
+	uint64_t	qp_params_array;
+	/* reserved64 is 64 b */
+	uint64_t	reserved64;
+} cmdq_create_qp_batch_t, *pcmdq_create_qp_batch_t;
+
+/* creq_create_qp_batch_resp (size:128b/16B) */
+
+typedef struct creq_create_qp_batch_resp {
+	uint8_t	type;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint16_t	seq_id;
+	#define CREQ_CREATE_QP_BATCH_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_CREATE_QP_BATCH_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_CREATE_QP_BATCH_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_CREATE_QP_BATCH_RESP_TYPE_LAST	CREQ_CREATE_QP_BATCH_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	uint32_t	reserved32;
+	uint8_t	v;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint16_t	target_id;
+	#define CREQ_CREATE_QP_BATCH_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Create batch QPs command response. */
+	#define CREQ_CREATE_QP_BATCH_RESP_EVENT_CREATE_QP_BATCH UINT32_C(0x94)
+	#define CREQ_CREATE_QP_BATCH_RESP_EVENT_LAST	CREQ_CREATE_QP_BATCH_RESP_EVENT_CREATE_QP_BATCH
+	uint16_t	reserved16;
+	/* Count of QPs successfully created. */
+	uint32_t	count;
+} creq_create_qp_batch_resp_t, *pcreq_create_qp_batch_resp_t;
+
+/********************
+ * destroy_qp_batch *
+ ********************/
+
+
+/* cmdq_destroy_qp_batch (size:256b/32B) */
+
+typedef struct cmdq_destroy_qp_batch {
+	/* Command opcode. */
+	uint8_t	opcode;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * This command deletes the batch of requested count of QPs.
+	 * The starting QP ID can be specified to request a batch deletion
+	 * of a sequential range.
 	 */
+	#define CMDQ_DESTROY_QP_BATCH_OPCODE_DESTROY_QP_BATCH UINT32_C(0x95)
+	#define CMDQ_DESTROY_QP_BATCH_OPCODE_LAST		CMDQ_DESTROY_QP_BATCH_OPCODE_DESTROY_QP_BATCH
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
 	uint64_t	resp_addr;
+	/* Starting QP context id to be used for the sequential range. */
+	uint32_t	start_xid;
 	/*
-	 * This value indicates the target id of the encapsulated
-	 * response.
-	 * 0x0 - 0xFFF8 - Used for function ids
-	 * 0xFFF8 - 0xFFFE - Reserved for internal processors
-	 * 0xFFFF - HWRM
-	 */
-	uint16_t	encap_resp_target_id;
-	/*
-	 * This value indicates the completion ring the encapsulated
-	 * response will be optionally completed on.  If the value is
-	 * -1, then no CR completion shall be generated for the
-	 * encapsulated response. Any other value must be a
-	 * valid CR ring_id value. If a valid encap_resp_cmpl_ring
-	 * is provided, then a CR completion shall be generated for
-	 * the encapsulated response.
-	 */
-	uint16_t	encap_resp_cmpl_ring;
-	/* This field indicates the length of encapsulated response. */
-	uint16_t	encap_resp_len;
-	uint8_t	unused_0;
-	uint8_t	unused_1;
-	/*
-	 * This is the host address where the encapsulated response
-	 * will be written.
-	 * This area must be 16B aligned and must be cleared to zero
-	 * before the original request is made.
+	 * Count of QPs to be deleted. A value of zero implies all QPs
+	 * are to be deleted.
 	 */
-	uint64_t	encap_resp_addr;
-	/* This is an encapsulated response. */
-	uint32_t	encap_resp[24];
-} hwrm_fwd_resp_input_t, *phwrm_fwd_resp_input_t;
+	uint32_t	count;
+	/* reserved64 is 64 b */
+	uint64_t	reserved64;
+} cmdq_destroy_qp_batch_t, *pcmdq_destroy_qp_batch_t;
 
-/* hwrm_fwd_resp_output (size:128b/16B) */
+/* creq_destroy_qp_batch_resp (size:128b/16B) */
 
-typedef struct hwrm_fwd_resp_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+typedef struct creq_destroy_qp_batch_resp {
+	uint8_t	type;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint8_t	valid;
-} hwrm_fwd_resp_output_t, *phwrm_fwd_resp_output_t;
+	#define CREQ_DESTROY_QP_BATCH_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_DESTROY_QP_BATCH_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_DESTROY_QP_BATCH_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_DESTROY_QP_BATCH_RESP_TYPE_LAST	CREQ_DESTROY_QP_BATCH_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	uint32_t	reserved32;
+	uint8_t	v;
+	/*
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
+	 */
+	#define CREQ_DESTROY_QP_BATCH_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Destroy batch QPs command response. */
+	#define CREQ_DESTROY_QP_BATCH_RESP_EVENT_DESTROY_QP_BATCH UINT32_C(0x95)
+	#define CREQ_DESTROY_QP_BATCH_RESP_EVENT_LAST		CREQ_DESTROY_QP_BATCH_RESP_EVENT_DESTROY_QP_BATCH
+	uint16_t	reserved16;
+	/* Count of QPs successfully destroyed. */
+	uint32_t	count;
+} creq_destroy_qp_batch_resp_t, *pcreq_destroy_qp_batch_resp_t;
 
-/*****************************
- * hwrm_fwd_async_event_cmpl *
- *****************************/
+/*******************************
+ * allocate_roce_stats_ext_ctx *
+ *******************************/
 
 
-/* hwrm_fwd_async_event_cmpl_input (size:320b/40B) */
+/* cmdq_allocate_roce_stats_ext_ctx (size:256b/32B) */
 
-typedef struct hwrm_fwd_async_event_cmpl_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+typedef struct cmdq_allocate_roce_stats_ext_ctx {
+	/* Command opcode. */
+	uint8_t	opcode;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * This command allocates an extended RoCE statistics context
+	 * that supports periodic DMA to a host address. The extended
+	 * statistics context id can be assigned by the driver,
+	 * via `create_qp`, `create_qp_batch` or `modify_qp` to a
+	 * specific QP, a subset of QPs or to all QPs of a specific function.
+	 * These statistics can be queried via `query_roce_stats_ext_v2`.
 	 */
-	uint16_t	cmpl_ring;
+	#define CMDQ_ALLOCATE_ROCE_STATS_EXT_CTX_OPCODE_ALLOCATE_ROCE_STATS_EXT_CTX UINT32_C(0x96)
+	#define CMDQ_ALLOCATE_ROCE_STATS_EXT_CTX_OPCODE_LAST			CMDQ_ALLOCATE_ROCE_STATS_EXT_CTX_OPCODE_ALLOCATE_ROCE_STATS_EXT_CTX
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * This is the address to be programmed in the statistic block
+	 * by the firmware to support periodic DMA of the statistics.
 	 */
-	uint16_t	seq_id;
+	uint64_t	stats_dma_addr;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * The statistic block update period in ms.
+	 * e.g. 250ms, 500ms, 750ms, 1000ms.
+	 * If update_period_ms is 0, then the stats update
+	 * shall be never done and the DMA address shall not be used.
+	 * In this case, the statistics can only be read by
+	 * `query_roce_stats_ext_v2` command.
 	 */
-	uint16_t	target_id;
+	uint32_t	update_period_ms;
+	/* Steering tag to use for memory transactions. */
+	uint16_t	steering_tag;
+	uint16_t	reserved16;
+} cmdq_allocate_roce_stats_ext_ctx_t, *pcmdq_allocate_roce_stats_ext_ctx_t;
+
+/* creq_allocate_roce_stats_ext_ctx_resp (size:128b/16B) */
+
+typedef struct creq_allocate_roce_stats_ext_ctx_resp {
+	uint8_t	type;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint64_t	resp_addr;
+	#define CREQ_ALLOCATE_ROCE_STATS_EXT_CTX_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_ALLOCATE_ROCE_STATS_EXT_CTX_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_ALLOCATE_ROCE_STATS_EXT_CTX_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_ALLOCATE_ROCE_STATS_EXT_CTX_RESP_TYPE_LAST	CREQ_ALLOCATE_ROCE_STATS_EXT_CTX_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Extended RoCE statistics context id. */
+	uint32_t	roce_stats_ext_xid;
+	uint8_t	v;
 	/*
-	 * This value indicates the target id of the encapsulated
-	 * asynchronous event.
-	 * 0x0 - 0xFFF8 - Used for function ids
-	 * 0xFFF8 - 0xFFFE - Reserved for internal processors
-	 * 0xFFFF - Broadcast to all children VFs (only applicable when
-	 * a PF is the requester)
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint16_t	encap_async_event_target_id;
-	uint8_t	unused_0[6];
-	/* This is an encapsulated asynchronous event completion. */
-	uint32_t	encap_async_event_cmpl[4];
-} hwrm_fwd_async_event_cmpl_input_t, *phwrm_fwd_async_event_cmpl_input_t;
+	#define CREQ_ALLOCATE_ROCE_STATS_EXT_CTX_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Allocate extended RoCE statistics context command response. */
+	#define CREQ_ALLOCATE_ROCE_STATS_EXT_CTX_RESP_EVENT_ALLOCATE_ROCE_STATS_EXT_CTX UINT32_C(0x96)
+	#define CREQ_ALLOCATE_ROCE_STATS_EXT_CTX_RESP_EVENT_LAST			CREQ_ALLOCATE_ROCE_STATS_EXT_CTX_RESP_EVENT_ALLOCATE_ROCE_STATS_EXT_CTX
+	uint8_t	reserved48[6];
+} creq_allocate_roce_stats_ext_ctx_resp_t, *pcreq_allocate_roce_stats_ext_ctx_resp_t;
 
-/* hwrm_fwd_async_event_cmpl_output (size:128b/16B) */
+/*********************************
+ * deallocate_roce_stats_ext_ctx *
+ *********************************/
 
-typedef struct hwrm_fwd_async_event_cmpl_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+
+/* cmdq_deallocate_roce_stats_ext_ctx (size:256b/32B) */
+
+typedef struct cmdq_deallocate_roce_stats_ext_ctx {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* This command deallocates an extended RoCE statistics context. */
+	#define CMDQ_DEALLOCATE_ROCE_STATS_EXT_CTX_OPCODE_DEALLOCATE_ROCE_STATS_EXT_CTX UINT32_C(0x97)
+	#define CMDQ_DEALLOCATE_ROCE_STATS_EXT_CTX_OPCODE_LAST			CMDQ_DEALLOCATE_ROCE_STATS_EXT_CTX_OPCODE_DEALLOCATE_ROCE_STATS_EXT_CTX
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+	/* Extended RoCE statistics context id. */
+	uint32_t	roce_stats_ext_xid;
+	uint32_t	reserved32;
+	/* reserved64 is 64 b */
+	uint64_t	reserved64;
+} cmdq_deallocate_roce_stats_ext_ctx_t, *pcmdq_deallocate_roce_stats_ext_ctx_t;
+
+/* creq_deallocate_roce_stats_ext_ctx_resp (size:128b/16B) */
+
+typedef struct creq_deallocate_roce_stats_ext_ctx_resp {
+	uint8_t	type;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint8_t	valid;
-} hwrm_fwd_async_event_cmpl_output_t, *phwrm_fwd_async_event_cmpl_output_t;
+	#define CREQ_DEALLOCATE_ROCE_STATS_EXT_CTX_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_DEALLOCATE_ROCE_STATS_EXT_CTX_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_DEALLOCATE_ROCE_STATS_EXT_CTX_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_DEALLOCATE_ROCE_STATS_EXT_CTX_RESP_TYPE_LAST	CREQ_DEALLOCATE_ROCE_STATS_EXT_CTX_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Extended RoCE statistics context id. */
+	uint32_t	roce_stats_ext_xid;
+	uint8_t	v;
+	/*
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
+	 */
+	#define CREQ_DEALLOCATE_ROCE_STATS_EXT_CTX_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Deallocate extended RoCE statistics context command response. */
+	#define CREQ_DEALLOCATE_ROCE_STATS_EXT_CTX_RESP_EVENT_DEALLOCATE_ROCE_STATS_EXT_CTX UINT32_C(0x97)
+	#define CREQ_DEALLOCATE_ROCE_STATS_EXT_CTX_RESP_EVENT_LAST			CREQ_DEALLOCATE_ROCE_STATS_EXT_CTX_RESP_EVENT_DEALLOCATE_ROCE_STATS_EXT_CTX
+	uint8_t	reserved48[6];
+} creq_deallocate_roce_stats_ext_ctx_resp_t, *pcreq_deallocate_roce_stats_ext_ctx_resp_t;
 
 /***************************
- * hwrm_temp_monitor_query *
+ * query_roce_stats_ext_v2 *
  ***************************/
 
 
-/* hwrm_temp_monitor_query_input (size:128b/16B) */
+/* cmdq_query_roce_stats_ext_v2 (size:256b/32B) */
 
-typedef struct hwrm_temp_monitor_query_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
-	 */
-	uint16_t	cmpl_ring;
+typedef struct cmdq_query_roce_stats_ext_v2 {
+	/* Command opcode. */
+	uint8_t	opcode;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Query extended RoCE statistics for devices that support
+	 * `roce_stats_ext_ctx_supported` feature.
 	 */
-	uint16_t	seq_id;
+	#define CMDQ_QUERY_ROCE_STATS_EXT_V2_OPCODE_QUERY_ROCE_STATS_EXT_V2 UINT32_C(0x98)
+	#define CMDQ_QUERY_ROCE_STATS_EXT_V2_OPCODE_LAST		CMDQ_QUERY_ROCE_STATS_EXT_V2_OPCODE_QUERY_ROCE_STATS_EXT_V2
+	/* Size of the command in 16-byte units. */
+	uint8_t	cmd_size;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	reserved8;
+	/* Host address of the response. */
+	uint64_t	resp_addr;
+	/* Extended RoCE statistics context id. */
+	uint32_t	roce_stats_ext_xid;
+	uint32_t	reserved32;
+	/* reserved64 is 64 b */
+	uint64_t	reserved64;
+} cmdq_query_roce_stats_ext_v2_t, *pcmdq_query_roce_stats_ext_v2_t;
+
+/* creq_query_roce_stats_ext_v2_resp (size:128b/16B) */
+
+typedef struct creq_query_roce_stats_ext_v2_resp {
+	uint8_t	type;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint16_t	target_id;
+	#define CREQ_QUERY_ROCE_STATS_EXT_V2_RESP_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_QUERY_ROCE_STATS_EXT_V2_RESP_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_QUERY_ROCE_STATS_EXT_V2_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_QUERY_ROCE_STATS_EXT_V2_RESP_TYPE_LAST	CREQ_QUERY_ROCE_STATS_EXT_V2_RESP_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Side buffer size in 16-byte units */
+	uint32_t	size;
+	uint8_t	v;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint64_t	resp_addr;
-} hwrm_temp_monitor_query_input_t, *phwrm_temp_monitor_query_input_t;
+	#define CREQ_QUERY_ROCE_STATS_EXT_V2_RESP_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Query extended RoCE statistics v2. */
+	#define CREQ_QUERY_ROCE_STATS_EXT_V2_RESP_EVENT_QUERY_ROCE_STATS_EXT_V2 UINT32_C(0x98)
+	#define CREQ_QUERY_ROCE_STATS_EXT_V2_RESP_EVENT_LAST		CREQ_QUERY_ROCE_STATS_EXT_V2_RESP_EVENT_QUERY_ROCE_STATS_EXT_V2
+	uint8_t	reserved48[6];
+} creq_query_roce_stats_ext_v2_resp_t, *pcreq_query_roce_stats_ext_v2_resp_t;
 
-/* hwrm_temp_monitor_query_output (size:128b/16B) */
+/* Query extended RoCE Stats command response side buffer structure. */
+/* creq_query_roce_stats_ext_v2_resp_sb (size:1920b/240B) */
 
-typedef struct hwrm_temp_monitor_query_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
+typedef struct creq_query_roce_stats_ext_v2_resp_sb {
+	/* Command opcode. */
+	uint8_t	opcode;
+	/* Query extended RoCE statistics v2. */
+	#define CREQ_QUERY_ROCE_STATS_EXT_V2_RESP_SB_OPCODE_QUERY_ROCE_STATS_EXT_V2 UINT32_C(0x98)
+	#define CREQ_QUERY_ROCE_STATS_EXT_V2_RESP_SB_OPCODE_LAST		CREQ_QUERY_ROCE_STATS_EXT_V2_RESP_SB_OPCODE_QUERY_ROCE_STATS_EXT_V2
+	/* Status of the response. */
+	uint8_t	status;
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	/* Flags and attribs of the command. */
+	uint16_t	flags;
+	/* Size of the response buffer in 16-byte units. */
+	uint8_t	resp_size;
+	uint8_t	rsvd;
+	/* Number of transmitted Atomic request packets without errors. */
+	uint64_t	tx_atomic_req_pkts;
+	/* Number of transmitted Read request packets without errors. */
+	uint64_t	tx_read_req_pkts;
+	/* Number of transmitted Read response packets without errors. */
+	uint64_t	tx_read_res_pkts;
+	/* Number of transmitted Write request packets without errors. */
+	uint64_t	tx_write_req_pkts;
+	/* Number of transmitted RC Send packets without errors. */
+	uint64_t	tx_rc_send_req_pkts;
 	/*
-	 * The HWRM shall provide the current temperature of
-	 * the device in Celsius. This is the max of PCIe_temp
-	 * and PM_temp
+	 * Number of transmitted UD Send (including QP1) packets
+	 * without errors.
 	 */
-	uint8_t	temp;
+	uint64_t	tx_ud_send_req_pkts;
+	/* Number of transmitted CNPs. Includes DCN_CNPs. */
+	uint64_t	tx_cnp_pkts;
 	/*
-	 * The HWRM shall provide the current temperature of
-	 * the phy in Celsius.
+	 * Number of transmitted RoCE packets.
+	 * This includes RC, UD, RawEth, and QP1 packets
 	 */
-	uint8_t	phy_temp;
+	uint64_t	tx_roce_pkts;
 	/*
-	 * The HWRM shall provide the current temperature of
-	 * the module_index in Celsius.
+	 * Number of transmitted RoCE header and payload bytes.
+	 * This includes RC, UD, RawEth, and QP1 packets.
 	 */
-	uint8_t	om_temp;
-	/* Describe individual temperature sensor condition. */
-	uint8_t	flags;
+	uint64_t	tx_roce_bytes;
 	/*
-	 * "1" in this bit indicates temperature read not
-	 * successful.
+	 * Number of drops that occurred to lack of buffers.
+	 * This count includes RC sends, RC writes with immediate,
+	 * UD sends, RawEth, and QP1 packets dropped due to lack of buffers.
 	 */
-	#define HWRM_TEMP_MONITOR_QUERY_OUTPUT_FLAGS_TEMP_NOT_AVAILABLE		UINT32_C(0x1)
+	uint64_t	rx_out_of_buffer_pkts;
+	/* Number of packets that were received out of sequence. */
+	uint64_t	rx_out_of_sequence_pkts;
 	/*
-	 * "1" in this bit indicates phy temperature read not
-	 * successful.
+	 * Number of duplicate read/atomic requests resulting in responder
+	 * hardware retransmission.
 	 */
-	#define HWRM_TEMP_MONITOR_QUERY_OUTPUT_FLAGS_PHY_TEMP_NOT_AVAILABLE	UINT32_C(0x2)
-	/* "1" in this bit indicates optical module(s) not present. */
-	#define HWRM_TEMP_MONITOR_QUERY_OUTPUT_FLAGS_OM_NOT_PRESENT		UINT32_C(0x4)
+	uint64_t	dup_req;
 	/*
-	 * "1" in this bit indicates om temperature read not
-	 * successful.
+	 * Number of missing response packets resulting in hardware
+	 * retransmission.
 	 */
-	#define HWRM_TEMP_MONITOR_QUERY_OUTPUT_FLAGS_OM_TEMP_NOT_AVAILABLE	UINT32_C(0x8)
+	uint64_t	missing_resp;
 	/*
-	 * "1" in this bit indicates the extended temperature fields are
-	 * available.
+	 * Number of sequence error NAKs received resulting in hardware
+	 * retransmission.
 	 */
-	#define HWRM_TEMP_MONITOR_QUERY_OUTPUT_FLAGS_EXT_TEMP_FIELDS_AVAILABLE	UINT32_C(0x10)
+	uint64_t	seq_err_naks_rcvd;
+	/* Number of RNR NAKs received resulting in hardware retransmission. */
+	uint64_t	rnr_naks_rcvd;
+	/* Number of timeouts resulting in hardware retransmission. */
+	uint64_t	to_retransmits;
+	/* Number of received Atomic request packets without errors. */
+	uint64_t	rx_atomic_req_pkts;
+	/* Number of received Read request packets without errors. */
+	uint64_t	rx_read_req_pkts;
+	/* Number of received Read response packets without errors. */
+	uint64_t	rx_read_res_pkts;
+	/* Number of received Write request packets without errors. */
+	uint64_t	rx_write_req_pkts;
+	/* Number of received RC Send packets without errors. */
+	uint64_t	rx_rc_send_pkts;
+	/* Number of received UD Send packets without errors. */
+	uint64_t	rx_ud_send_pkts;
+	/* Number of received DCN payload cut packets. */
+	uint64_t	rx_dcn_payload_cut;
+	/* Number of received ECN-marked packets. */
+	uint64_t	rx_ecn_marked_pkts;
+	/* Number of received CNP packets. Includes DCN_CNPs. */
+	uint64_t	rx_cnp_pkts;
 	/*
-	 * This field encodes the current device temperature in Celsius.
-	 * This field is unsigned and the value range of 0 to 255 is used to
-	 * indicate a temperature range from -64 to +191. The actual
-	 * temperature is derived by subtracting 64 from this field.
-	 * Example: A value of 0 represents a temperature of -64, a value of
-	 * 255 represents a temperature of 191.
+	 * Number of received RoCE packets including RoCE packets with errors.
+	 * This includes RC, UD, RawEth, and QP1 packets
 	 */
-	uint8_t	temp2;
+	uint64_t	rx_roce_pkts;
 	/*
-	 * This field encodes the current phy temperature in Celsius. This
-	 * field is unsigned and the value range of 0 to 255 is used to
-	 * indicate a temperature range from -64 to +191. The actual
-	 * temperature is derived by subtracting 64 from this field.
-	 * Example: A value of 0 represents a temperature of -64, a value of
-	 * 255 represents a temperature of 191.
+	 * Number of received RoCE header and payload bytes including RoCE
+	 * packets with errors.
+	 * This includes RC, UD, RawEth, and QP1 packets.
 	 */
-	uint8_t	phy_temp2;
+	uint64_t	rx_roce_bytes;
 	/*
-	 * This field encodes the current module index temperature in Celsius.
-	 * This field is unsigned and the value range of 0 to 255 is used to
-	 * indicate a temperature range from -64 to +191. The actual
-	 * temperature is derived by subtracting 64 from this field.
-	 * Example: A value of 0 represents a temperature of -64, a value of
-	 * 255 represents a temperature of 191.
+	 * Number of received RoCE packets without errors.
+	 * This includes RC, UD, RawEth, and QP1 packets
 	 */
-	uint8_t	om_temp2;
+	uint64_t	rx_roce_good_pkts;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * Number of received RoCE header and payload bytes without errors.
+	 * This includes RC, UD, RawEth, and QP1 packets.
 	 */
-	uint8_t	valid;
-} hwrm_temp_monitor_query_output_t, *phwrm_temp_monitor_query_output_t;
-
-/************************
- * hwrm_reg_power_query *
- ************************/
-
+	uint64_t	rx_roce_good_bytes;
+} creq_query_roce_stats_ext_v2_resp_sb_t, *pcreq_query_roce_stats_ext_v2_resp_sb_t;
 
-/* hwrm_reg_power_query_input (size:128b/16B) */
+/* RoCE function async event notifications. */
+/* creq_func_event (size:128b/16B) */
 
-typedef struct hwrm_reg_power_query_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+typedef struct creq_func_event {
+	uint8_t	type;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint16_t	cmpl_ring;
+	#define CREQ_FUNC_EVENT_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_FUNC_EVENT_TYPE_SFT	0
+	/* Function Async Notification */
+		#define CREQ_FUNC_EVENT_TYPE_FUNC_EVENT  UINT32_C(0x3a)
+		#define CREQ_FUNC_EVENT_TYPE_LAST	CREQ_FUNC_EVENT_TYPE_FUNC_EVENT
+	uint8_t	reserved56[7];
+	uint8_t	v;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint16_t	seq_id;
+	#define CREQ_FUNC_EVENT_V	UINT32_C(0x1)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * This value defines what type of async event has occurred
+	 * on the function.
 	 */
-	uint16_t	target_id;
+	uint8_t	event;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Invalid PBL or PCIE UR response occurred
+	 * in SQ WQE or IRRQ read access.
 	 */
-	uint64_t	resp_addr;
-} hwrm_reg_power_query_input_t, *phwrm_reg_power_query_input_t;
-
-/* hwrm_reg_power_query_output (size:192b/24B) */
-
-typedef struct hwrm_reg_power_query_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Describe availability of switching regulator power values. */
-	uint32_t	flags;
-	/* When this bit is set to '1', the input power is available. */
-	#define HWRM_REG_POWER_QUERY_OUTPUT_FLAGS_IN_POWER_AVAILABLE	UINT32_C(0x1)
-	/* When this bit is set to '1', the output power is available. */
-	#define HWRM_REG_POWER_QUERY_OUTPUT_FLAGS_OUT_POWER_AVAILABLE	UINT32_C(0x2)
+	#define CREQ_FUNC_EVENT_EVENT_TX_WQE_ERROR	UINT32_C(0x1)
 	/*
-	 * The HWRM shall provide the current switching regulator
-	 * input power in mW, if available.
+	 * Invalid PBL or PCIE UR response occurred
+	 * during data read access.
 	 */
-	uint32_t	in_power_mw;
+	#define CREQ_FUNC_EVENT_EVENT_TX_DATA_ERROR	UINT32_C(0x2)
 	/*
-	 * The HWRM shall provide the current switching regulator
-	 * output power in mW, if available.
+	 * Invalid PBL or PCIE UR response occurred
+	 * in RQ/SRQ WQE or ORRQ read access.
 	 */
-	uint32_t	out_power_mw;
-	uint8_t	unused_0[3];
+	#define CREQ_FUNC_EVENT_EVENT_RX_WQE_ERROR	UINT32_C(0x3)
+	/* Invalid PBL occurred during data write access. */
+	#define CREQ_FUNC_EVENT_EVENT_RX_DATA_ERROR	UINT32_C(0x4)
+	/* Invalid PBL occurred during CQ write access. */
+	#define CREQ_FUNC_EVENT_EVENT_CQ_ERROR	UINT32_C(0x5)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * Invalid PBL or PCIE UR response occurred in TQM
+	 * read access.
 	 */
-	uint8_t	valid;
-} hwrm_reg_power_query_output_t, *phwrm_reg_power_query_output_t;
-
-/*****************************
- * hwrm_core_frequency_query *
- *****************************/
-
+	#define CREQ_FUNC_EVENT_EVENT_TQM_ERROR	UINT32_C(0x6)
+	/* PCIE UR response occurred in CFC read access. */
+	#define CREQ_FUNC_EVENT_EVENT_CFCQ_ERROR	UINT32_C(0x7)
+	/* PCIE UR response occurred in CFC read access. */
+	#define CREQ_FUNC_EVENT_EVENT_CFCS_ERROR	UINT32_C(0x8)
+	/* PCIE UR response occurred in CFC read access. */
+	#define CREQ_FUNC_EVENT_EVENT_CFCC_ERROR	UINT32_C(0x9)
+	/* PCIE UR response occurred in CFC read access. */
+	#define CREQ_FUNC_EVENT_EVENT_CFCM_ERROR	UINT32_C(0xa)
+	/*
+	 * Invalid PBL or
+	 * PCIE UR response
+	 * occurred on timer read access.
+	 */
+	#define CREQ_FUNC_EVENT_EVENT_TIM_ERROR	UINT32_C(0xb)
+	/* A VF sent a backchannel command request */
+	#define CREQ_FUNC_EVENT_EVENT_VF_COMM_REQUEST	UINT32_C(0x80)
+	/*
+	 * Communication resource (QPC, CQ, SRQ, MRW) exhausted, and resource
+	 * array extension is enabled.
+	 */
+	#define CREQ_FUNC_EVENT_EVENT_RESOURCE_EXHAUSTED UINT32_C(0x81)
+	#define CREQ_FUNC_EVENT_EVENT_LAST		CREQ_FUNC_EVENT_EVENT_RESOURCE_EXHAUSTED
+	uint8_t	reserved48[6];
+} creq_func_event_t, *pcreq_func_event_t;
 
-/* hwrm_core_frequency_query_input (size:128b/16B) */
+/* RoCE slowpath command completion events. */
+/* creq_qp_event (size:128b/16B) */
 
-typedef struct hwrm_core_frequency_query_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+typedef struct creq_qp_event {
+	uint8_t	type;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint16_t	cmpl_ring;
+	#define CREQ_QP_EVENT_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_QP_EVENT_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_QP_EVENT_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_QP_EVENT_TYPE_LAST	CREQ_QP_EVENT_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* Success. */
+	#define CREQ_QP_EVENT_STATUS_SUCCESS	UINT32_C(0x0)
+	/* Fail. */
+	#define CREQ_QP_EVENT_STATUS_FAIL		UINT32_C(0x1)
+	/* Resources. */
+	#define CREQ_QP_EVENT_STATUS_RESOURCES	UINT32_C(0x2)
+	/* Invalid command. */
+	#define CREQ_QP_EVENT_STATUS_INVALID_CMD	UINT32_C(0x3)
+	/* Not implemented. */
+	#define CREQ_QP_EVENT_STATUS_NOT_IMPLEMENTED   UINT32_C(0x4)
+	/* Invalid parameter. */
+	#define CREQ_QP_EVENT_STATUS_INVALID_PARAMETER UINT32_C(0x5)
+	/* Hardware operation failed. */
+	#define CREQ_QP_EVENT_STATUS_HARDWARE_ERROR	UINT32_C(0x6)
+	/* Firmware operation failed due to internal error. */
+	#define CREQ_QP_EVENT_STATUS_INTERNAL_ERROR	UINT32_C(0x7)
+	#define CREQ_QP_EVENT_STATUS_LAST		CREQ_QP_EVENT_STATUS_INTERNAL_ERROR
+	/* Driver supplied handle to associate the command and the response. */
+	uint16_t	cookie;
+	uint32_t	reserved32;
+	uint8_t	v;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint16_t	seq_id;
+	#define CREQ_QP_EVENT_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* Create QP command response. */
+	#define CREQ_QP_EVENT_EVENT_CREATE_QP		UINT32_C(0x1)
+	/* Destroy QP command response. */
+	#define CREQ_QP_EVENT_EVENT_DESTROY_QP		UINT32_C(0x2)
+	/* Modify QP command response. */
+	#define CREQ_QP_EVENT_EVENT_MODIFY_QP		UINT32_C(0x3)
+	/* Query QP command response. */
+	#define CREQ_QP_EVENT_EVENT_QUERY_QP		UINT32_C(0x4)
+	/* Create SRQ command response. */
+	#define CREQ_QP_EVENT_EVENT_CREATE_SRQ		UINT32_C(0x5)
+	/* Destroy SRQ command response. */
+	#define CREQ_QP_EVENT_EVENT_DESTROY_SRQ	UINT32_C(0x6)
+	/* Query SRQ command response. */
+	#define CREQ_QP_EVENT_EVENT_QUERY_SRQ		UINT32_C(0x8)
+	/* Create CQ command response. */
+	#define CREQ_QP_EVENT_EVENT_CREATE_CQ		UINT32_C(0x9)
+	/* Destroy CQ command response. */
+	#define CREQ_QP_EVENT_EVENT_DESTROY_CQ		UINT32_C(0xa)
+	/* Resize CQ command response. */
+	#define CREQ_QP_EVENT_EVENT_RESIZE_CQ		UINT32_C(0xc)
+	/* Allocate MRW command response. */
+	#define CREQ_QP_EVENT_EVENT_ALLOCATE_MRW	UINT32_C(0xd)
+	/* De-allocate key command response. */
+	#define CREQ_QP_EVENT_EVENT_DEALLOCATE_KEY	UINT32_C(0xe)
+	/* Register MR command response. */
+	#define CREQ_QP_EVENT_EVENT_REGISTER_MR	UINT32_C(0xf)
+	/* Deregister MR command response. */
+	#define CREQ_QP_EVENT_EVENT_DEREGISTER_MR	UINT32_C(0x10)
+	/* Add GID command response. */
+	#define CREQ_QP_EVENT_EVENT_ADD_GID		UINT32_C(0x11)
+	/* Delete GID command response. */
+	#define CREQ_QP_EVENT_EVENT_DELETE_GID		UINT32_C(0x12)
+	/* Modify GID command response. */
+	#define CREQ_QP_EVENT_EVENT_MODIFY_GID		UINT32_C(0x17)
+	/* Query GID command response. */
+	#define CREQ_QP_EVENT_EVENT_QUERY_GID		UINT32_C(0x18)
+	/* Create QP1 command response. */
+	#define CREQ_QP_EVENT_EVENT_CREATE_QP1		UINT32_C(0x13)
+	/* Destroy QP1 command response. */
+	#define CREQ_QP_EVENT_EVENT_DESTROY_QP1	UINT32_C(0x14)
+	/* Create AH command response. */
+	#define CREQ_QP_EVENT_EVENT_CREATE_AH		UINT32_C(0x15)
+	/* Destroy AH command response. */
+	#define CREQ_QP_EVENT_EVENT_DESTROY_AH		UINT32_C(0x16)
+	/* Initialize firmware command response. */
+	#define CREQ_QP_EVENT_EVENT_INITIALIZE_FW	UINT32_C(0x80)
+	/* De-initialize firmware command response. */
+	#define CREQ_QP_EVENT_EVENT_DEINITIALIZE_FW	UINT32_C(0x81)
+	/* Stop PF command response. */
+	#define CREQ_QP_EVENT_EVENT_STOP_FUNC		UINT32_C(0x82)
+	/* Query info PF command response. */
+	#define CREQ_QP_EVENT_EVENT_QUERY_FUNC		UINT32_C(0x83)
+	/* Set function resources command response. */
+	#define CREQ_QP_EVENT_EVENT_SET_FUNC_RESOURCES	UINT32_C(0x84)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Read the current state of any internal resource context. Can only be
+	 * issued from a PF.
 	 */
-	uint16_t	target_id;
+	#define CREQ_QP_EVENT_EVENT_READ_CONTEXT	UINT32_C(0x85)
+	/* Map TC to COS response. */
+	#define CREQ_QP_EVENT_EVENT_MAP_TC_TO_COS	UINT32_C(0x8a)
+	/* Query firmware and interface version response. */
+	#define CREQ_QP_EVENT_EVENT_QUERY_VERSION	UINT32_C(0x8b)
+	/* Modify congestion control response. */
+	#define CREQ_QP_EVENT_EVENT_MODIFY_CC		UINT32_C(0x8c)
+	/* Query congestion control response. */
+	#define CREQ_QP_EVENT_EVENT_QUERY_CC		UINT32_C(0x8d)
+	/* Query RoCE statistics. */
+	#define CREQ_QP_EVENT_EVENT_QUERY_ROCE_STATS	UINT32_C(0x8e)
+	/* Set LAG mode. */
+	#define CREQ_QP_EVENT_EVENT_SET_LINK_AGGR_MODE	UINT32_C(0x8f)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Query QP for a PF other than the requesting PF. Also can query for
+	 * more than one QP.
 	 */
-	uint64_t	resp_addr;
-} hwrm_core_frequency_query_input_t, *phwrm_core_frequency_query_input_t;
+	#define CREQ_QP_EVENT_EVENT_QUERY_QP_EXTEND	UINT32_C(0x91)
+	/* QP error notification event. */
+	#define CREQ_QP_EVENT_EVENT_QP_ERROR_NOTIFICATION UINT32_C(0xc0)
+	/* CQ error notification event. */
+	#define CREQ_QP_EVENT_EVENT_CQ_ERROR_NOTIFICATION UINT32_C(0xc1)
+	#define CREQ_QP_EVENT_EVENT_LAST		CREQ_QP_EVENT_EVENT_CQ_ERROR_NOTIFICATION
+	uint8_t	reserved48[6];
+} creq_qp_event_t, *pcreq_qp_event_t;
 
-/* hwrm_core_frequency_query_output (size:128b/16B) */
+/* QP error notification event. */
+/* creq_qp_error_notification (size:128b/16B) */
 
-typedef struct hwrm_core_frequency_query_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* The HWRM shall provide the core frequency in Hz. */
-	uint32_t	core_frequency_hz;
-	uint8_t	unused_0[3];
+typedef struct creq_qp_error_notification {
+	uint8_t	type;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	uint8_t	valid;
-} hwrm_core_frequency_query_output_t, *phwrm_core_frequency_query_output_t;
-
-/****************************
- * hwrm_reg_power_histogram *
- ****************************/
-
-
-/* hwrm_reg_power_histogram_input (size:192b/24B) */
-
-typedef struct hwrm_reg_power_histogram_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define CREQ_QP_ERROR_NOTIFICATION_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_QP_ERROR_NOTIFICATION_TYPE_SFT	0
+	/* QP Async Notification */
+		#define CREQ_QP_ERROR_NOTIFICATION_TYPE_QP_EVENT  UINT32_C(0x38)
+		#define CREQ_QP_ERROR_NOTIFICATION_TYPE_LAST	CREQ_QP_ERROR_NOTIFICATION_TYPE_QP_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* requestor slow path state */
+	uint8_t	req_slow_path_state;
+	/* requestor error reason */
+	uint8_t	req_err_state_reason;
+	/* No error. */
+	#define CREQ_QP_ERROR_NOTIFICATION_REQ_ERR_STATE_REASON_NO_ERROR			UINT32_C(0x0)
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * Requester detected opcode error.
+	 * * First, only, middle, last for incoming RDMA read
+	 *   responses are improperly ordered with respect to previous
+	 *   (PSN) packet.
+	 * * First or middle packet is not full MTU size.
+	 * This is an RX Detected Error.
 	 */
-	uint16_t	cmpl_ring;
+	#define CREQ_QP_ERROR_NOTIFICATION_REQ_ERR_STATE_REASON_REQ_OPCODE_ERROR		UINT32_C(0x1)
+	/*
+	 * Transport timeout retry limit exceeded.
+	 * The requestor retried the same unacked PSN request packet
+	 * too many times.
+	 * This is an RX Detected Error.
+	 */
+	#define CREQ_QP_ERROR_NOTIFICATION_REQ_ERR_STATE_REASON_REQ_TIMEOUT_RETRY_LIMIT	UINT32_C(0x2)
+	/*
+	 * RNR NAK retry limit exceeded.
+	 * The requestor received an RNR NAK with the same NAK PSN
+	 * too many times.
+	 * This is an RX Detected Error.
+	 */
+	#define CREQ_QP_ERROR_NOTIFICATION_REQ_ERR_STATE_REASON_REQ_RNR_TIMEOUT_RETRY_LIMIT UINT32_C(0x3)
+	/*
+	 * NAK arrival, When NAK code is 1, Invalid Request.
+	 * This is an RX Detected Error.
+	 */
+	#define CREQ_QP_ERROR_NOTIFICATION_REQ_ERR_STATE_REASON_REQ_NAK_ARRIVAL_1	UINT32_C(0x4)
+	/*
+	 * NAK arrival, When NAK code is 2, Remote Access Error.
+	 * This is an RX Detected Error.
+	 */
+	#define CREQ_QP_ERROR_NOTIFICATION_REQ_ERR_STATE_REASON_REQ_NAK_ARRIVAL_2	UINT32_C(0x5)
+	/*
+	 * NAK arrival, When NAK code is 3, Remote Operational Error.
+	 * This is an RX Detected Error.
+	 */
+	#define CREQ_QP_ERROR_NOTIFICATION_REQ_ERR_STATE_REASON_REQ_NAK_ARRIVAL_3	UINT32_C(0x6)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * NAK arrival. When NAK code is 4, Invalid RD Request.
+	 * This is an RX Detected Error.
 	 */
-	uint16_t	seq_id;
+	#define CREQ_QP_ERROR_NOTIFICATION_REQ_ERR_STATE_REASON_REQ_NAK_ARRIVAL_4	UINT32_C(0x7)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Local memory error.
+	 * An SGE described an inaccessible memory.
+	 * This is an RX Detected Error.
 	 */
-	uint16_t	target_id;
+	#define CREQ_QP_ERROR_NOTIFICATION_REQ_ERR_STATE_REASON_REQ_RX_MEMORY_ERROR	UINT32_C(0x8)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Local memory error.
+	 * An SGE described an inaccessible memory.
+	 * This is a TX Detected Error.
 	 */
-	uint64_t	resp_addr;
-	/* Describe operational mode of power histogram command. */
-	uint32_t	flags;
+	#define CREQ_QP_ERROR_NOTIFICATION_REQ_ERR_STATE_REASON_REQ_TX_MEMORY_ERROR	UINT32_C(0x9)
 	/*
-	 * When this bit is set to '1', histogram data for the respective
-	 * client (HWRM or BMC) is cleared after read.
+	 * Read response length error.
+	 * The read response payload size does not match the read
+	 * length of the request.
+	 * This is an RX Detected Error.
 	 */
-	#define HWRM_REG_POWER_HISTOGRAM_INPUT_FLAGS_CLEAR_HISTOGRAM	UINT32_C(0x1)
-	uint32_t	unused_0;
-} hwrm_reg_power_histogram_input_t, *phwrm_reg_power_histogram_input_t;
-
-/* hwrm_reg_power_histogram_output (size:1088b/136B) */
-
-typedef struct hwrm_reg_power_histogram_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Describe output characteristics of power histogram command. */
-	uint16_t	flags;
+	#define CREQ_QP_ERROR_NOTIFICATION_REQ_ERR_STATE_REASON_REQ_READ_RESP_LENGTH	UINT32_C(0xa)
 	/*
-	 * Indicates whether input or output power is used. Some switching
-	 * regulators provide both input and output voltage and current
-	 * measurements, and others provide only output measurements. When
-	 * both are available, input is used. This value is constant for a
-	 * given board.
+	 * Invalid read response.
+	 * A read response arrived and had a PSN that was not in the
+	 * reply range of any outstanding read request on the ORRQ.
+	 * This is an RX Detected Error.
 	 */
-	#define HWRM_REG_POWER_HISTOGRAM_OUTPUT_FLAGS_POWER_IN_OUT	UINT32_C(0x1)
+	#define CREQ_QP_ERROR_NOTIFICATION_REQ_ERR_STATE_REASON_REQ_INVALID_READ_RESP	UINT32_C(0xb)
 	/*
-	 * The switching regulator's input power is used
-	 * data.
+	 * Illegal bind.
+	 * * No MW with the specified R_Key exists.
+	 * * No MR with the specified L_Key exists.
+	 * * A bind request was performed on a window that was already
+	 *   bound.
+	 * * A bind request was performed for an underlying MR that
+	 *   is not registered.
+	 * * A bind request was performed for a memory area that exceeds
+	 *   the range of the underlying MR.
+	 * * A bind request was performed with a set of permissions
+	 *   that are looser than the permissions of the underlying MR.
+	 * * Domain error MW - When QP's PD does not match MW PD.
+	 * * Domain error MR - When QP's PD does not match parent MR's
+	 *   PD.
+	 * This is a TX Detected Error.
 	 */
-		#define HWRM_REG_POWER_HISTOGRAM_OUTPUT_FLAGS_POWER_IN_OUT_INPUT   UINT32_C(0x0)
+	#define CREQ_QP_ERROR_NOTIFICATION_REQ_ERR_STATE_REASON_REQ_ILLEGAL_BIND		UINT32_C(0xc)
 	/*
-	 * The switching regulator's output power is used
-	 * data.
+	 * Illegal fast register.
+	 * * No MR with the specified L_Key exists.
+	 * * A fast register request was performed on a non-
+	 *   physical MR.
+	 * * A fast register request was performed on a physical MR
+	 *   that is already registered.
+	 * * A fast register request was performed on a physical MR
+	 *   that does not have a page list allocated (has not been
+	 *   initialized).
+	 * * The number of pages being registered exceeds the capacity
+	 *   of the physical MR.
+	 * * The length of the registration is not possible with the
+	 *   actual number of pages provided.
+	 * * Domain error - when QP's PD does not match PMR PD.
+	 * This is a TX Detected Error.
 	 */
-		#define HWRM_REG_POWER_HISTOGRAM_OUTPUT_FLAGS_POWER_IN_OUT_OUTPUT  UINT32_C(0x1)
-		#define HWRM_REG_POWER_HISTOGRAM_OUTPUT_FLAGS_POWER_IN_OUT_LAST   HWRM_REG_POWER_HISTOGRAM_OUTPUT_FLAGS_POWER_IN_OUT_OUTPUT
-	uint8_t	unused_0[2];
+	#define CREQ_QP_ERROR_NOTIFICATION_REQ_ERR_STATE_REASON_REQ_ILLEGAL_FAST_REG	UINT32_C(0xd)
 	/*
-	 * Time in microseconds between samples. This value is constant in
-	 * firmware. The initial design sets this constant at 10000 us (10
-	 * ms). Power values for voltage regulators calculate a power value
-	 * over a 300 us period, so a 10 ms sampling period covers 3% of
-	 * time ranges. Future firmware designs may opt for different
-	 * sampling periods, so this value is provided on output.
+	 * Illegal invalidate.
+	 * * No MR with the specified L_Key exists.
+	 * * No MW with the specified R_Key exists.
+	 * * An invalidate was performed against a non-physical MR.
+	 * * An invalidate was performed against a physical MR that
+	 *   is not registered.
+	 * * An invalidate was performed against a MW that is not
+	 *   bound.
+	 * * The PD of the MR/MW being invalidated does not match the PD
+	 *   of the QP.
+	 * This is a TX Detected Error.
 	 */
-	uint32_t	sampling_period;
+	#define CREQ_QP_ERROR_NOTIFICATION_REQ_ERR_STATE_REASON_REQ_ILLEGAL_INVALIDATE	UINT32_C(0xe)
 	/*
-	 * Total samples taken since last clear. If no counter has
-	 * saturated, the sum of counts in each bucket equates to this
-	 * sample_count value. If a single counter has saturated, its value
-	 * can be calculated by subtracting the remaining bucket values from
-	 * this sample_count value.
+	 * Completion Error.
+	 * No CQE space available on queue, or CQ not in VALID state.
+	 * This is a Completion Detected Error.
 	 */
-	uint64_t	sample_count;
+	#define CREQ_QP_ERROR_NOTIFICATION_REQ_ERR_STATE_REASON_REQ_CMP_ERROR		UINT32_C(0xf)
 	/*
-	 * The power usage expressed in histogram buckets. Bucket value
-	 * ranges and array indices are defined per the enumeration
-	 * power_histogram_bucket_enum. Values saturate at the max 32-bit
-	 * value, 0xFFFFFFFF, and do not roll over. Clients should use the
-	 * clear bit on input to clear the histogram array periodically or
-	 * when saturation is observed.
+	 * Local memory error while retransmitting WQE.
+	 * An SQ SGE described an inaccessible memory.
+	 * This is a TX Detected Error.
 	 */
-	uint32_t	power_hist[26];
-	uint8_t	unused_1[7];
+	#define CREQ_QP_ERROR_NOTIFICATION_REQ_ERR_STATE_REASON_REQ_RETRAN_LOCAL_ERROR	UINT32_C(0x10)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * Problem found in the format of a WQE in the SQ.
+	 * This is a TX Detected Error.
 	 */
-	uint8_t	valid;
-} hwrm_reg_power_histogram_output_t, *phwrm_reg_power_histogram_output_t;
-
-/*
- * Count of timer callback routines run with no data measured. This
- * may occur when data from the switching regulator is not available
- * to the firmware timer callback routine. One possible reason for
- * this is contention with other users of the i2c bus which is used
- * to communicate with the switching regulator, for example when a
- * call to hwrm_reg_power_query occurs while the timer routine is
- * running.
- */
-#define BUCKET_NO_DATA_FOR_SAMPLE UINT32_C(0x0)
-/* Count of samples measured at less than 8W */
-#define BUCKET_RANGE_8W_OR_LESS   UINT32_C(0x1)
-/* Count of samples measured >= 8 W and < 9 W */
-#define BUCKET_RANGE_8W_TO_9W	UINT32_C(0x2)
-/* Count of samples measured >= 9 W and < 10 W */
-#define BUCKET_RANGE_9W_TO_10W	UINT32_C(0x3)
-/* Count of samples measured >= 10 W and < 11 W */
-#define BUCKET_RANGE_10W_TO_11W   UINT32_C(0x4)
-/* Count of samples measured >= 11 W and < 12 W */
-#define BUCKET_RANGE_11W_TO_12W   UINT32_C(0x5)
-/* Count of samples measured >= 12 W and < 13 W */
-#define BUCKET_RANGE_12W_TO_13W   UINT32_C(0x6)
-/* Count of samples measured >= 13 W and < 14 W */
-#define BUCKET_RANGE_13W_TO_14W   UINT32_C(0x7)
-/* Count of samples measured >= 14 W and < 15 W */
-#define BUCKET_RANGE_14W_TO_15W   UINT32_C(0x8)
-/* Count of samples measured >= 15 W and < 16 W */
-#define BUCKET_RANGE_15W_TO_16W   UINT32_C(0x9)
-/* Count of samples measured >= 16 W and < 18 W */
-#define BUCKET_RANGE_16W_TO_18W   UINT32_C(0xa)
-/* Count of samples measured >= 18 W and < 20 W */
-#define BUCKET_RANGE_18W_TO_20W   UINT32_C(0xb)
-/* Count of samples measured >= 20 W and < 22 W */
-#define BUCKET_RANGE_20W_TO_22W   UINT32_C(0xc)
-/* Count of samples measured >= 22 W and < 24 W */
-#define BUCKET_RANGE_22W_TO_24W   UINT32_C(0xd)
-/* Count of samples measured >= 24 W and < 26 W */
-#define BUCKET_RANGE_24W_TO_26W   UINT32_C(0xe)
-/* Count of samples measured >= 26 W and < 28 W */
-#define BUCKET_RANGE_26W_TO_28W   UINT32_C(0xf)
-/* Count of samples measured >= 28 W and < 30 W */
-#define BUCKET_RANGE_28W_TO_30W   UINT32_C(0x10)
-/* Count of samples measured >= 30 W and < 32 W */
-#define BUCKET_RANGE_30W_TO_32W   UINT32_C(0x11)
-/* Count of samples measured >= 32 W and < 34 W */
-#define BUCKET_RANGE_32W_TO_34W   UINT32_C(0x12)
-/* Count of samples measured >= 34 W and < 36 W */
-#define BUCKET_RANGE_34W_TO_36W   UINT32_C(0x13)
-/* Count of samples measured >= 36 W and < 38 W */
-#define BUCKET_RANGE_36W_TO_38W   UINT32_C(0x14)
-/* Count of samples measured >= 38 W and < 40 W */
-#define BUCKET_RANGE_38W_TO_40W   UINT32_C(0x15)
-/* Count of samples measured >= 40 W and < 42 W */
-#define BUCKET_RANGE_40W_TO_42W   UINT32_C(0x16)
-/* Count of samples measured >= 42 W and < 44 W */
-#define BUCKET_RANGE_42W_TO_44W   UINT32_C(0x17)
-/* Count of samples measured >= 44 W and < 50 W */
-#define BUCKET_RANGE_44W_TO_50W   UINT32_C(0x18)
-/* Count of samples measured at 50 W or greater */
-#define BUCKET_RANGE_OVER_50W	UINT32_C(0x19)
-#define BUCKET_LAST		BUCKET_RANGE_OVER_50W
-
-
-/*************************
- * hwrm_wol_filter_alloc *
- *************************/
-
-
-/* hwrm_wol_filter_alloc_input (size:512b/64B) */
-
-typedef struct hwrm_wol_filter_alloc_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define CREQ_QP_ERROR_NOTIFICATION_REQ_ERR_STATE_REASON_REQ_WQE_FORMAT_ERROR	UINT32_C(0x11)
+	/*
+	 * Problem was found in the format of an ORRQ entry.
+	 * This is a RX Detected Error.
+	 */
+	#define CREQ_QP_ERROR_NOTIFICATION_REQ_ERR_STATE_REASON_REQ_ORRQ_FORMAT_ERROR	UINT32_C(0x12)
+	/*
+	 * A UD send attempted to use an invalid AVID.
+	 * This is a TX Detected Error.
+	 */
+	#define CREQ_QP_ERROR_NOTIFICATION_REQ_ERR_STATE_REASON_REQ_INVALID_AVID_ERROR	UINT32_C(0x13)
+	/*
+	 * A UD send attempted to use an AVID that is outside of its
+	 * QP's protection domain.
+	 * This is a TX Detected Error.
+	 */
+	#define CREQ_QP_ERROR_NOTIFICATION_REQ_ERR_STATE_REASON_REQ_AV_DOMAIN_ERROR	UINT32_C(0x14)
+	/*
+	 * A load error occurred on an attempt to load the CQ Context.
+	 * This is a Completion Detected Error.
+	 */
+	#define CREQ_QP_ERROR_NOTIFICATION_REQ_ERR_STATE_REASON_REQ_CQ_LOAD_ERROR	UINT32_C(0x15)
+	/*
+	 * There was an attempt to process a WQE from the SQ that
+	 * corresponds to an operation that is unsupported for the
+	 * corresponding QP.
+	 * This is a TX Detected Error.
+	 */
+	#define CREQ_QP_ERROR_NOTIFICATION_REQ_ERR_STATE_REASON_REQ_SERV_TYPE_ERROR	UINT32_C(0x16)
+	/*
+	 * There was an attempt to process a WQE from the SQ that
+	 * corresponds to an operation that is unsupported for the
+	 * corresponding QP, according to the supported_operations QPC
+	 * field.
+	 * This is a TX Detected Error.
+	 */
+	#define CREQ_QP_ERROR_NOTIFICATION_REQ_ERR_STATE_REASON_REQ_INVALID_OP_ERROR	UINT32_C(0x17)
+	/*
+	 * A fatal error was detected on an attempt to read from
+	 * or write to PCIe on the transmit side. This error is
+	 * detected by the TX side (or CAGR), but has the priority
+	 * of a Completion Detected Error.
+	 */
+	#define CREQ_QP_ERROR_NOTIFICATION_REQ_ERR_STATE_REASON_REQ_TX_PCI_ERROR		UINT32_C(0x18)
+	/*
+	 * A fatal error was detected on an attempt to read from
+	 * or write to PCIe on the receive side. This error is detected
+	 * by the RX side (or CAGR), but has the priority of a
+	 * Completion Detected Error.
+	 */
+	#define CREQ_QP_ERROR_NOTIFICATION_REQ_ERR_STATE_REASON_REQ_RX_PCI_ERROR		UINT32_C(0x19)
+	/*
+	 * When processing a WQE from the SQ, TWE detected an error
+	 * such that the wqe_size given in the header is larger than
+	 * the delta between sq_work_idx and sq_prod_idx. This error
+	 * has priority over the non-error case that occurs when TWE
+	 * detects that it simply doesn't have enough slots fetched
+	 * to execute the WQE during the current residency.
+	 */
+	#define CREQ_QP_ERROR_NOTIFICATION_REQ_ERR_STATE_REASON_REQ_PROD_WQE_MSMTCH_ERROR   UINT32_C(0x1a)
+	/*
+	 * When reading the MSN table to initiate HW retransmit, RWE
+	 * found that to_retransmit_psn was not within the range defined
+	 * by start_psn and next_psn in the corresponding MSN table
+	 * entry. To_retransmit_psn must be greater than or equal to
+	 * start_psn and less than next_psn in order for the range check
+	 * to succeed.
+	 * This is a RX Detected Error.
+	 */
+	#define CREQ_QP_ERROR_NOTIFICATION_REQ_ERR_STATE_REASON_REQ_PSN_RANGE_CHECK_ERROR   UINT32_C(0x1b)
+	/*
+	 * While retransmitting, TWE detected one of several possible
+	 * error detection scenarios related to the improper setup of
+	 * retransmission. These include a category or errors known as
+	 * retx_end_error where the retransmission end does not line up
+	 * sequentially with the WQE index and PSN upon continuing on
+	 * with the regular transmission that follows the
+	 * retransmission. It also includes the error condition in which
+	 * the retransmission Work Request has gen_dup_read_request set
+	 * and the WQE fetched by TWE is not an RDMA Read or Atomic WQE.
+	 * Please see TWE requirements for a full list of the various
+	 * possible retransmit setup error cases. These error cases
+	 * apply to H/W and F/W retransmission, alike.
+	 * This is a TX Detected Error.
+	 */
+	#define CREQ_QP_ERROR_NOTIFICATION_REQ_ERR_STATE_REASON_REQ_RETX_SETUP_ERROR	UINT32_C(0x1c)
+	/*
+	 * An express doorbell was posted that overflowed the SQ. The
+	 * doorbell is dropped, along with all subsequent doorbells for
+	 * this SQ. This is a TX Detected Error.
+	 */
+	#define CREQ_QP_ERROR_NOTIFICATION_REQ_ERR_STATE_REASON_REQ_SQ_OVERFLOW		UINT32_C(0x1d)
+	#define CREQ_QP_ERROR_NOTIFICATION_REQ_ERR_STATE_REASON_LAST			CREQ_QP_ERROR_NOTIFICATION_REQ_ERR_STATE_REASON_REQ_SQ_OVERFLOW
+	/* QP context id */
+	uint32_t	xid;
+	uint8_t	v;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint16_t	cmpl_ring;
+	#define CREQ_QP_ERROR_NOTIFICATION_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* QP error notification event. */
+	#define CREQ_QP_ERROR_NOTIFICATION_EVENT_QP_ERROR_NOTIFICATION UINT32_C(0xc0)
+	#define CREQ_QP_ERROR_NOTIFICATION_EVENT_LAST		CREQ_QP_ERROR_NOTIFICATION_EVENT_QP_ERROR_NOTIFICATION
+	/* responder slow path state */
+	uint8_t	res_slow_path_state;
+	uint8_t	res_err_state_reason;
+	/* No error. */
+	#define CREQ_QP_ERROR_NOTIFICATION_RES_ERR_STATE_REASON_NO_ERROR			UINT32_C(0x0)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Incoming Send, RDMA write, or RDMA read exceeds the maximum
+	 * transfer length. Detected on RX first and only packets for
+	 * write. Detected on RX request for read.
+	 * This is an RX Detected Error.
 	 */
-	uint16_t	seq_id;
+	#define CREQ_QP_ERROR_NOTIFICATION_RES_ERR_STATE_REASON_RES_EXCEED_MAX		UINT32_C(0x1)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * RDMA write payload size does not match write length. Detected
+	 * when total write payload is not equal to the RDMA write
+	 * length that was given in the first or only packet of the
+	 * request.
+	 * This is an RX Detected Error.
 	 */
-	uint16_t	target_id;
+	#define CREQ_QP_ERROR_NOTIFICATION_RES_ERR_STATE_REASON_RES_PAYLOAD_LENGTH_MISMATCH   UINT32_C(0x2)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Send payload exceeds RQ/SRQ WQE buffer capacity. The total
+	 * send payload that arrived is more than the size of the WQE
+	 * buffer that was fetched from the RQ/SRQ.
+	 * This is an RX Detected Error.
 	 */
-	uint64_t	resp_addr;
-	uint32_t	flags;
-	uint32_t	enables;
+	#define CREQ_QP_ERROR_NOTIFICATION_RES_ERR_STATE_REASON_RES_EXCEEDS_WQE		UINT32_C(0x3)
 	/*
-	 * This bit must be '1' for the mac_address field to be
-	 * configured.
+	 * Responder detected opcode error.
+	 * * First, only, middle, last or incoming requests are
+	 *   improperly ordered with respect to previous (PSN) packet.
+	 * * First or middle packet is not full MTU size.
+	 * This is an RX Detected Error.
 	 */
-	#define HWRM_WOL_FILTER_ALLOC_INPUT_ENABLES_MAC_ADDRESS	UINT32_C(0x1)
+	#define CREQ_QP_ERROR_NOTIFICATION_RES_ERR_STATE_REASON_RES_OPCODE_ERROR		UINT32_C(0x4)
 	/*
-	 * This bit must be '1' for the pattern_offset field to be
-	 * configured.
+	 * PSN sequence error retry limit exceeded.
+	 * The responder encountered a PSN sequence error for the
+	 * same PSN too many times. This can occur via implicit or
+	 * explicit NAK.
+	 * This is an RX Detected Error.
 	 */
-	#define HWRM_WOL_FILTER_ALLOC_INPUT_ENABLES_PATTERN_OFFSET	UINT32_C(0x2)
+	#define CREQ_QP_ERROR_NOTIFICATION_RES_ERR_STATE_REASON_RES_PSN_SEQ_ERROR_RETRY_LIMIT UINT32_C(0x5)
 	/*
-	 * This bit must be '1' for the pattern_buf_size field to be
-	 * configured.
+	 * Invalid R_Key.
+	 * An incoming request contained an R_Key that did not reference
+	 * a valid MR/MW. This error may be detected by the RX engine
+	 * for RDMA write or by the TX engine for RDMA read
+	 * (detected while servicing IRRQ).
+	 * This is an RX Detected Error.
 	 */
-	#define HWRM_WOL_FILTER_ALLOC_INPUT_ENABLES_PATTERN_BUF_SIZE	UINT32_C(0x4)
+	#define CREQ_QP_ERROR_NOTIFICATION_RES_ERR_STATE_REASON_RES_RX_INVALID_R_KEY	UINT32_C(0x6)
 	/*
-	 * This bit must be '1' for the pattern_buf_addr field to be
-	 * configured.
+	 * Domain error.
+	 * An incoming request specified an R_Key which
+	 * referenced a MR/MW that was not in the same PD as the QP on
+	 * which the request arrived.
+	 * This is an RX Detected Error.
 	 */
-	#define HWRM_WOL_FILTER_ALLOC_INPUT_ENABLES_PATTERN_BUF_ADDR	UINT32_C(0x8)
+	#define CREQ_QP_ERROR_NOTIFICATION_RES_ERR_STATE_REASON_RES_RX_DOMAIN_ERROR	UINT32_C(0x7)
 	/*
-	 * This bit must be '1' for the pattern_mask_addr field to be
-	 * configured.
+	 * No permission.
+	 * An incoming request contained an R_Key that referenced a
+	 * MR/MW which did not have the access permission needed for
+	 * the operation.
+	 * This is an RX Detected Error.
 	 */
-	#define HWRM_WOL_FILTER_ALLOC_INPUT_ENABLES_PATTERN_MASK_ADDR	UINT32_C(0x10)
+	#define CREQ_QP_ERROR_NOTIFICATION_RES_ERR_STATE_REASON_RES_RX_NO_PERMISSION	UINT32_C(0x8)
 	/*
-	 * This bit must be '1' for the pattern_mask_size field to be
-	 * configured.
+	 * Range error.
+	 * An incoming request had a combination of R_Key,VA, and
+	 * length that was out of bounds of the associated MR/MW.
+	 * This is an RX Detected Error.
 	 */
-	#define HWRM_WOL_FILTER_ALLOC_INPUT_ENABLES_PATTERN_MASK_SIZE	UINT32_C(0x20)
-	/* Port ID of port on which WoL filter is configured. */
-	uint16_t	port_id;
-	/* This value represents a Wake-on-LAN type. */
-	uint8_t	wol_type;
-	/* Magic Packet */
-	#define HWRM_WOL_FILTER_ALLOC_INPUT_WOL_TYPE_MAGICPKT UINT32_C(0x0)
-	/* Bitmap */
-	#define HWRM_WOL_FILTER_ALLOC_INPUT_WOL_TYPE_BMP	UINT32_C(0x1)
-	/* Invalid */
-	#define HWRM_WOL_FILTER_ALLOC_INPUT_WOL_TYPE_INVALID  UINT32_C(0xff)
-	#define HWRM_WOL_FILTER_ALLOC_INPUT_WOL_TYPE_LAST	HWRM_WOL_FILTER_ALLOC_INPUT_WOL_TYPE_INVALID
-	uint8_t	unused_0[5];
+	#define CREQ_QP_ERROR_NOTIFICATION_RES_ERR_STATE_REASON_RES_RX_RANGE_ERROR		UINT32_C(0x9)
 	/*
-	 * # If this field is enabled and magic packet WoL filter
-	 * type is specified in this command, the value set in this
-	 * field shall be used in setting the magic packet based
-	 * WoL filter.
-	 * # If this field is not enabled and magic packet WoL
-	 * filter type is specified and port id is specified to
-	 * 0xFF in this command, then the HWRM
-	 * shall use default MAC address configured on the
-	 * function associated with the HWRM client.
-	 * # If this field is not enabled and magic packet WoL
-	 * filter type is specified and port id is not specified to
-	 * 0xFF in this command, then the HWRM
-	 * shall use default MAC address configured on the port.
+	 * Invalid R_Key.
+	 * An incoming request contained an R_Key that did not
+	 * reference a valid MR/MW. This error may be detected
+	 * by the RX engine for RDMA write or by the TX engine
+	 * for RDMA read (detected while servicing IRRQ).
+	 * This is a TX Detected Error.
 	 */
-	uint8_t	mac_address[6];
+	#define CREQ_QP_ERROR_NOTIFICATION_RES_ERR_STATE_REASON_RES_TX_INVALID_R_KEY	UINT32_C(0xa)
 	/*
-	 * The offset from the beginning of MAC header where
-	 * pattern should be matched.
-	 * Applies to bitmap WoL.
+	 * Domain error.
+	 * An incoming request specified an R_Key which referenced
+	 * a MR/MW that was not in the same PD as the QP on
+	 * which the request arrived.
+	 * This is a TX Detected Error.
 	 */
-	uint16_t	pattern_offset;
+	#define CREQ_QP_ERROR_NOTIFICATION_RES_ERR_STATE_REASON_RES_TX_DOMAIN_ERROR	UINT32_C(0xb)
 	/*
-	 * The size of the pattern that is being matched.
-	 * Applies to bitmap WoL.
+	 * No permission.
+	 * An incoming request contained an R_Key that referenced a
+	 * MR/MW which did not have the access permission needed for
+	 * the operation.
+	 * This is a TX Detected Error.
 	 */
-	uint16_t	pattern_buf_size;
+	#define CREQ_QP_ERROR_NOTIFICATION_RES_ERR_STATE_REASON_RES_TX_NO_PERMISSION	UINT32_C(0xc)
 	/*
-	 * The size of the pattern mask.
-	 * Applies to bitmap WoL.
+	 * Range error.
+	 * An incoming request had a combination of R_Key, VA, and
+	 * length that was out of bounds of the associated MR/MW.
+	 * This is a TX Detected Error.
 	 */
-	uint16_t	pattern_mask_size;
-	uint8_t	unused_1[4];
+	#define CREQ_QP_ERROR_NOTIFICATION_RES_ERR_STATE_REASON_RES_TX_RANGE_ERROR		UINT32_C(0xd)
 	/*
-	 * Physical address of the pattern buffer.
-	 * Applies to bitmap WoL.
+	 * IRRQ overflow.
+	 * The peer sent us more RDMA read or atomic requests than
+	 * the negotiated maximum.
+	 * This is an RX Detected Error.
 	 */
-	uint64_t	pattern_buf_addr;
+	#define CREQ_QP_ERROR_NOTIFICATION_RES_ERR_STATE_REASON_RES_IRRQ_OFLOW		UINT32_C(0xe)
 	/*
-	 * Physical address of the pattern mask.
-	 * Applies to bitmap WoL.
+	 * Unsupported opcode.
+	 * The peer sent us a request with an opcode for a request
+	 * type that is not supported on this QP.
+	 * This is an RX Detected Error.
 	 */
-	uint64_t	pattern_mask_addr;
-} hwrm_wol_filter_alloc_input_t, *phwrm_wol_filter_alloc_input_t;
-
-/* hwrm_wol_filter_alloc_output (size:128b/16B) */
-
-typedef struct hwrm_wol_filter_alloc_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* This value identifies a Wake-on-LAN (WoL) filter. */
-	uint8_t	wol_filter_id;
-	uint8_t	unused_0[6];
+	#define CREQ_QP_ERROR_NOTIFICATION_RES_ERR_STATE_REASON_RES_UNSUPPORTED_OPCODE	UINT32_C(0xf)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * Unaligned atomic operation. The VA of an atomic request
+	 * is on a memory boundary that prevents atomic execution.
+	 * This is an RX Detected Error.
 	 */
-	uint8_t	valid;
-} hwrm_wol_filter_alloc_output_t, *phwrm_wol_filter_alloc_output_t;
-
-/************************
- * hwrm_wol_filter_free *
- ************************/
-
-
-/* hwrm_wol_filter_free_input (size:256b/32B) */
-
-typedef struct hwrm_wol_filter_free_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define CREQ_QP_ERROR_NOTIFICATION_RES_ERR_STATE_REASON_RES_UNALIGN_ATOMIC		UINT32_C(0x10)
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * Remote invalidate error.
+	 * A send with invalidate request arrived in which the
+	 * R_Key to invalidate did not describe a MR/MW which could
+	 * be invalidated. RQ WQE completes with error status.
+	 * This error is only reported if the send operation did
+	 * not fail. If the send operation failed then the remote
+	 * invalidate error is not reported.
+	 * This is an RX Detected Error.
 	 */
-	uint16_t	cmpl_ring;
+	#define CREQ_QP_ERROR_NOTIFICATION_RES_ERR_STATE_REASON_RES_REM_INVALIDATE		UINT32_C(0x11)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Local memory error. An RQ/SRQ SGE described an inaccessible
+	 * memory.
+	 * This is an RX Detected Error.
 	 */
-	uint16_t	seq_id;
+	#define CREQ_QP_ERROR_NOTIFICATION_RES_ERR_STATE_REASON_RES_MEMORY_ERROR		UINT32_C(0x12)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * SRQ in error. The QP is moving to error state because it
+	 * found SRQ it uses in error.
+	 * This is an RX Detected Error.
 	 */
-	uint16_t	target_id;
+	#define CREQ_QP_ERROR_NOTIFICATION_RES_ERR_STATE_REASON_RES_SRQ_ERROR		UINT32_C(0x13)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Completion error. No CQE space available on queue or CQ not
+	 * in VALID state.
+	 * This is a Completion Detected Error.
 	 */
-	uint64_t	resp_addr;
-	uint32_t	flags;
+	#define CREQ_QP_ERROR_NOTIFICATION_RES_ERR_STATE_REASON_RES_CMP_ERROR		UINT32_C(0x14)
 	/*
-	 * # When this bit is set to '1', then all active WoL
-	 * filters on the port are requested to be freed.
-	 * # If the a function driver sets this flag to '1', then
-	 * the HWRM shall free all active WoL filters that are not
-	 * set by other function drivers on that port.
+	 * Invalid R_Key while resending responses to duplicate request.
+	 * This is a TX Detected Error.
 	 */
-	#define HWRM_WOL_FILTER_FREE_INPUT_FLAGS_FREE_ALL_WOL_FILTERS	UINT32_C(0x1)
-	uint32_t	enables;
+	#define CREQ_QP_ERROR_NOTIFICATION_RES_ERR_STATE_REASON_RES_INVALID_DUP_RKEY	UINT32_C(0x15)
 	/*
-	 * This bit must be '1' for the wol_filter_id field to be
-	 * configured.
+	 * Problem was found in the format of a WQE in the RQ/SRQ.
+	 * This is an RX Detected Error.
 	 */
-	#define HWRM_WOL_FILTER_FREE_INPUT_ENABLES_WOL_FILTER_ID	UINT32_C(0x1)
-	/* Port ID of the port on which WoL filter(s) is (are) being freed. */
-	uint16_t	port_id;
+	#define CREQ_QP_ERROR_NOTIFICATION_RES_ERR_STATE_REASON_RES_WQE_FORMAT_ERROR	UINT32_C(0x16)
 	/*
-	 * The HWRM shall ignore this field if free_all_wol_filters
-	 * flag is set.
+	 * Problem was found in the format of an IRRQ entry.
+	 * This is a TX Detected Error.
 	 */
-	uint8_t	wol_filter_id;
-	uint8_t	unused_0[5];
-} hwrm_wol_filter_free_input_t, *phwrm_wol_filter_free_input_t;
-
-/* hwrm_wol_filter_free_output (size:128b/16B) */
-
-typedef struct hwrm_wol_filter_free_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	#define CREQ_QP_ERROR_NOTIFICATION_RES_ERR_STATE_REASON_RES_IRRQ_FORMAT_ERROR	UINT32_C(0x17)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * A load error occurred on an attempt to load the CQ Context.
+	 * This is a Completion Detected Error.
 	 */
-	uint8_t	valid;
-} hwrm_wol_filter_free_output_t, *phwrm_wol_filter_free_output_t;
+	#define CREQ_QP_ERROR_NOTIFICATION_RES_ERR_STATE_REASON_RES_CQ_LOAD_ERROR		UINT32_C(0x18)
+	/*
+	 * A load error occurred on an attempt to load the SRQ Context.
+	 * This is an RX Detected Error.
+	 */
+	#define CREQ_QP_ERROR_NOTIFICATION_RES_ERR_STATE_REASON_RES_SRQ_LOAD_ERROR		UINT32_C(0x19)
+	/*
+	 * A fatal error was detected on an attempt to read from or
+	 * write to PCIe on the transmit side. This error is detected
+	 * by the TX side, but has the priority of a Completion
+	 * Detected Error.
+	 */
+	#define CREQ_QP_ERROR_NOTIFICATION_RES_ERR_STATE_REASON_RES_TX_PCI_ERROR		UINT32_C(0x1b)
+	/*
+	 * A fatal error was detected on an attempt to read from or
+	 * write to PCIe on the receive side. This error is detected
+	 * by the RX side (or CAGR), but has the priority of a Completion
+	 * Detected Error.
+	 */
+	#define CREQ_QP_ERROR_NOTIFICATION_RES_ERR_STATE_REASON_RES_RX_PCI_ERROR		UINT32_C(0x1c)
+	/*
+	 * When searching the IRRQ to respond to a duplicate request,
+	 * RWE could not find the duplicate request in the entire IRRQ.
+	 * This is a RX Detected Error.
+	 */
+	#define CREQ_QP_ERROR_NOTIFICATION_RES_ERR_STATE_REASON_RES_PSN_NOT_FOUND		UINT32_C(0x1d)
+	/*
+	 * An express doorbell was posted that overflowed the RQ. The
+	 * doorbell is dropped, along with all subsequent doorbells for
+	 * this RQ. This is an RX Detected Error.
+	 */
+	#define CREQ_QP_ERROR_NOTIFICATION_RES_ERR_STATE_REASON_RES_RQ_OVERFLOW		UINT32_C(0x1e)
+	#define CREQ_QP_ERROR_NOTIFICATION_RES_ERR_STATE_REASON_LAST			CREQ_QP_ERROR_NOTIFICATION_RES_ERR_STATE_REASON_RES_RQ_OVERFLOW
+	/*
+	 * Final SQ Consumer Index value. Any additional SQ WQEs will
+	 * have to be completed by the user provider.
+	 */
+	uint16_t	sq_cons_idx;
+	/*
+	 * Final RQ Consumer Index value. Any additional RQ WQEs will
+	 * have to be completed by the user provider.
+	 */
+	uint16_t	rq_cons_idx;
+} creq_qp_error_notification_t, *pcreq_qp_error_notification_t;
 
-/************************
- * hwrm_wol_filter_qcfg *
- ************************/
+/* CQ error notification event. */
+/* creq_cq_error_notification (size:128b/16B) */
 
+typedef struct creq_cq_error_notification {
+	uint8_t	type;
+	/*
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
+	 */
+	#define CREQ_CQ_ERROR_NOTIFICATION_TYPE_MASK	UINT32_C(0x3f)
+	#define CREQ_CQ_ERROR_NOTIFICATION_TYPE_SFT	0
+	/* CQ Async Notification */
+		#define CREQ_CQ_ERROR_NOTIFICATION_TYPE_CQ_EVENT  UINT32_C(0x38)
+		#define CREQ_CQ_ERROR_NOTIFICATION_TYPE_LAST	CREQ_CQ_ERROR_NOTIFICATION_TYPE_CQ_EVENT
+	/* Status of the response. */
+	uint8_t	status;
+	/* CQ error reason code. */
+	uint8_t	cq_err_reason;
+	/* Requester completion error for invalid CQ state. */
+	#define CREQ_CQ_ERROR_NOTIFICATION_CQ_ERR_REASON_REQ_CQ_INVALID_ERROR  UINT32_C(0x1)
+	/* Requester completion error for CQ overflow. */
+	#define CREQ_CQ_ERROR_NOTIFICATION_CQ_ERR_REASON_REQ_CQ_OVERFLOW_ERROR UINT32_C(0x2)
+	/* Attempt to load CQ context resulted in error. */
+	#define CREQ_CQ_ERROR_NOTIFICATION_CQ_ERR_REASON_REQ_CQ_LOAD_ERROR	UINT32_C(0x3)
+	/* Responder completion error for invalid CQ state. */
+	#define CREQ_CQ_ERROR_NOTIFICATION_CQ_ERR_REASON_RES_CQ_INVALID_ERROR  UINT32_C(0x4)
+	/* Responder completion error for CQ overflow. */
+	#define CREQ_CQ_ERROR_NOTIFICATION_CQ_ERR_REASON_RES_CQ_OVERFLOW_ERROR UINT32_C(0x5)
+	/* Attempt to load CQ context resulted in error. */
+	#define CREQ_CQ_ERROR_NOTIFICATION_CQ_ERR_REASON_RES_CQ_LOAD_ERROR	UINT32_C(0x6)
+	#define CREQ_CQ_ERROR_NOTIFICATION_CQ_ERR_REASON_LAST		CREQ_CQ_ERROR_NOTIFICATION_CQ_ERR_REASON_RES_CQ_LOAD_ERROR
+	uint8_t	reserved8;
+	/* CQ context id */
+	uint32_t	xid;
+	uint8_t	v;
+	/*
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
+	 */
+	#define CREQ_CQ_ERROR_NOTIFICATION_V	UINT32_C(0x1)
+	/* Event or command opcode. */
+	uint8_t	event;
+	/* CQ error notification event. */
+	#define CREQ_CQ_ERROR_NOTIFICATION_EVENT_CQ_ERROR_NOTIFICATION UINT32_C(0xc1)
+	#define CREQ_CQ_ERROR_NOTIFICATION_EVENT_LAST		CREQ_CQ_ERROR_NOTIFICATION_EVENT_CQ_ERROR_NOTIFICATION
+	uint8_t	reserved48[6];
+} creq_cq_error_notification_t, *pcreq_cq_error_notification_t;
 
-/* hwrm_wol_filter_qcfg_input (size:448b/56B) */
+/* sq_base (size:64b/8B) */
 
-typedef struct hwrm_wol_filter_qcfg_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+typedef struct sq_base {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
+	/* Send */
+	#define SQ_BASE_WQE_TYPE_SEND		UINT32_C(0x0)
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * Send with Immediate
+	 *
+	 * Allowed only on reliable connection (RC) and
+	 * unreliable datagram (UD) SQs.
 	 */
-	uint16_t	cmpl_ring;
+	#define SQ_BASE_WQE_TYPE_SEND_W_IMMEAD	UINT32_C(0x1)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Send with Invalidate.
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint16_t	seq_id;
+	#define SQ_BASE_WQE_TYPE_SEND_W_INVALID	UINT32_C(0x2)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * RDMA Write.
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint16_t	target_id;
+	#define SQ_BASE_WQE_TYPE_WRITE_WQE		UINT32_C(0x4)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * RDMA Write with Immediate.
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint64_t	resp_addr;
-	/* Port ID of port on which WoL filter that is being queried. */
-	uint16_t	port_id;
+	#define SQ_BASE_WQE_TYPE_WRITE_W_IMMEAD	UINT32_C(0x5)
 	/*
-	 * This is an opaque handle used to access filters.
-	 * # The HWRM client shall set this field to 0x0000 to begin
-	 * the query.
-	 * # After the first query, the HWRM client shall retrieve
-	 * next filters (if they exist) using the HWRM provided handle
-	 * in the response.
+	 * RDMA Read.
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint16_t	handle;
-	uint8_t	unused_0[4];
+	#define SQ_BASE_WQE_TYPE_READ_WQE		UINT32_C(0x6)
 	/*
-	 * Physical address of the pattern buffer.
-	 * Applies to bitmap WoL filter only.
-	 * # Value of 0 indicates an invalid buffer address.
-	 * If this field is set to 0, then HWRM shall ignore
-	 * pattern_buf_size.
-	 * # If the HWRM client provides an invalid buffer address
-	 * for the pattern, then the HWRM is not required to
-	 * provide pattern when the response contains a bitmap WoL
-	 * filter.
+	 * Atomic Compare/Swap.
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint64_t	pattern_buf_addr;
+	#define SQ_BASE_WQE_TYPE_ATOMIC_CS		UINT32_C(0x8)
 	/*
-	 * The size of the pattern buffer.
-	 * Applies to bitmap WoL filter only.
+	 * Atomic Fetch/Add.
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint16_t	pattern_buf_size;
-	uint8_t	unused_1[6];
+	#define SQ_BASE_WQE_TYPE_ATOMIC_FA		UINT32_C(0xb)
 	/*
-	 * Physical address of the pattern mask.
-	 * Applies to bitmap WoL filter only.
-	 * # Value of 0 indicates an invalid pattern mask address.
-	 * If this field is set to 0, then HWRM shall ignore
-	 * pattern_mask_size.
-	 * # If the HWRM client provides an invalid mask address
-	 * for the pattern, then the HWRM is not required to
-	 * provide mask when the response contains a bitmap WoL
-	 * filter.
+	 * Local Invalidate.
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint64_t	pattern_mask_addr;
+	#define SQ_BASE_WQE_TYPE_LOCAL_INVALID	UINT32_C(0xc)
 	/*
-	 * The size of the buffer for pattern mask.
-	 * Applies to bitmap WoL filter only.
+	 * FR-PMR (Fast Register Physical Memory Region)
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint16_t	pattern_mask_size;
-	uint8_t	unused_2[6];
-} hwrm_wol_filter_qcfg_input_t, *phwrm_wol_filter_qcfg_input_t;
-
-/* hwrm_wol_filter_qcfg_output (size:256b/32B) */
-
-typedef struct hwrm_wol_filter_qcfg_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
+	#define SQ_BASE_WQE_TYPE_FR_PMR		UINT32_C(0xd)
 	/*
-	 * This is the next handle that is used to access filters.
-	 * # If this field is set to 0x0000, then no WoL filters are
-	 * currently configured on this port and all other fields in
-	 * the output shall be ignored by the HWRM client.
-	 * # If this field is set to neither 0x0000 nor 0xFFFF, then the
-	 * wol_filter_id is valid and the parameters provided in the
-	 * response are based on the wol_type.
-	 * # If this field is set to 0xFFFF, then there are no remaining
-	 * configured WoL filters to be queried for the queried function
-	 * after this response, wol_filter_id is valid and the parameters
-	 * provided in the response are based on the wol_type.
+	 * Memory Bind
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint16_t	next_handle;
+	#define SQ_BASE_WQE_TYPE_BIND		UINT32_C(0xe)
 	/*
-	 * This value identifies the filter returned in this
-	 * response.
+	 * FR-PPMR (Fast Register Proxy Physical Memory Region)
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint8_t	wol_filter_id;
+	#define SQ_BASE_WQE_TYPE_FR_PPMR		UINT32_C(0xf)
+	/* Send V3 */
+	#define SQ_BASE_WQE_TYPE_SEND_V3		UINT32_C(0x10)
 	/*
-	 * This value identifies the type of WoL filter returned
-	 * in this response.
+	 * Send with Immediate V3
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint8_t	wol_type;
-	/* Magic Packet */
-	#define HWRM_WOL_FILTER_QCFG_OUTPUT_WOL_TYPE_MAGICPKT UINT32_C(0x0)
-	/* Bitmap */
-	#define HWRM_WOL_FILTER_QCFG_OUTPUT_WOL_TYPE_BMP	UINT32_C(0x1)
-	/* Invalid */
-	#define HWRM_WOL_FILTER_QCFG_OUTPUT_WOL_TYPE_INVALID  UINT32_C(0xff)
-	#define HWRM_WOL_FILTER_QCFG_OUTPUT_WOL_TYPE_LAST	HWRM_WOL_FILTER_QCFG_OUTPUT_WOL_TYPE_INVALID
-	uint32_t	unused_0;
+	#define SQ_BASE_WQE_TYPE_SEND_W_IMMED_V3	UINT32_C(0x11)
 	/*
-	 * The MAC address value used by the WoL filter.
-	 * Applies to magic packet based WoL.
+	 * Send with Invalidate V3
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint8_t	mac_address[6];
+	#define SQ_BASE_WQE_TYPE_SEND_W_INVALID_V3	UINT32_C(0x12)
 	/*
-	 * The offset from the beginning of MAC header where
-	 * pattern should be matched.
-	 * Applies to bitmap WoL.
+	 * UD Send V3
+	 *
+	 * Allowed only on unreliable datagram (UD) SQs.
 	 */
-	uint16_t	pattern_offset;
+	#define SQ_BASE_WQE_TYPE_UDSEND_V3		UINT32_C(0x13)
 	/*
-	 * The actual size of the pattern that is being returned.
-	 * Applies to bitmap WoL.
+	 * UD Send with Immediate V3
+	 *
+	 * Allowed only on unreliable datagram (UD) SQs.
 	 */
-	uint16_t	pattern_size;
+	#define SQ_BASE_WQE_TYPE_UDSEND_W_IMMED_V3	UINT32_C(0x14)
 	/*
-	 * The actual size of the pattern mask that is being returned.
-	 * Applies to bitmap WoL.
+	 * RDMA Write V3
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint16_t	pattern_mask_size;
-	uint8_t	unused_1[3];
+	#define SQ_BASE_WQE_TYPE_WRITE_WQE_V3	UINT32_C(0x15)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * RDMA Write with Immediate V3
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint8_t	valid;
-} hwrm_wol_filter_qcfg_output_t, *phwrm_wol_filter_qcfg_output_t;
-
-/************************
- * hwrm_wol_reason_qcfg *
- ************************/
-
+	#define SQ_BASE_WQE_TYPE_WRITE_W_IMMED_V3	UINT32_C(0x16)
+	/*
+	 * RDMA Read V3
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
+	 */
+	#define SQ_BASE_WQE_TYPE_READ_WQE_V3	UINT32_C(0x17)
+	/*
+	 * Atomic Compare/Swap V3
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
+	 */
+	#define SQ_BASE_WQE_TYPE_ATOMIC_CS_V3	UINT32_C(0x18)
+	/*
+	 * Atomic Fetch/Add V3
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
+	 */
+	#define SQ_BASE_WQE_TYPE_ATOMIC_FA_V3	UINT32_C(0x19)
+	/*
+	 * Local Invalidate V3
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
+	 */
+	#define SQ_BASE_WQE_TYPE_LOCAL_INVALID_V3	UINT32_C(0x1a)
+	/*
+	 * FR-PMR (Fast Register Physical Memory Region) V3
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
+	 */
+	#define SQ_BASE_WQE_TYPE_FR_PMR_V3		UINT32_C(0x1b)
+	/*
+	 * Memory Bind V3
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
+	 */
+	#define SQ_BASE_WQE_TYPE_BIND_V3		UINT32_C(0x1c)
+	/* RawEth/QP1 Send V3 */
+	#define SQ_BASE_WQE_TYPE_RAWQP1SEND_V3	UINT32_C(0x1d)
+	/* Change UDP Source Port V3 */
+	#define SQ_BASE_WQE_TYPE_CHANGE_UDPSRCPORT_V3 UINT32_C(0x1e)
+	#define SQ_BASE_WQE_TYPE_LAST		SQ_BASE_WQE_TYPE_CHANGE_UDPSRCPORT_V3
+	uint8_t	unused_0[7];
+} sq_base_t, *psq_base_t;
 
-/* hwrm_wol_reason_qcfg_input (size:320b/40B) */
+/*
+ * Most SQ WQEs contain SGEs used to define the SGL used to map payload
+ * data in host memory. The number of SGE structures is defined by the
+ * wqe_size field. SGE structures are aligned to 16B boundaries.
+ *
+ * In backward-compatible modes there can be 2, 4 or 6 SGEs (based on
+ * the mode). In variable-sized WQE mode there can be 0-30 SGE
+ * structures.
+ */
+/* sq_sge (size:128b/16B) */
 
-typedef struct hwrm_wol_reason_qcfg_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+typedef struct sq_sge {
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * The virtual address in local memory or a physical address
+	 * when l_key value is a reserved value of a physical address.
+	 * Driver configures this value in the chip and the chip compares
+	 * l_key in SGEs with that reserved value, if equal it access
+	 * the physical address specified. The chip however MUST verify
+	 * that the QP allows the use reserved key.
 	 */
-	uint16_t	cmpl_ring;
+	uint64_t	va_or_pa;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Local Key associated with this registered MR; The 24 msb of
+	 * the key used to index the MRW Table and the 8 lsb are compared
+	 * with the 8 bits key part stored in the MRWC. The PBL in the
+	 * MRW Context is used to translate the above VA to physical
+	 * address.
 	 */
-	uint16_t	seq_id;
+	uint32_t	l_key;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Size of SGE in bytes; Based on page size of the system the
+	 * chip knows how many entries are in the PBL
 	 */
-	uint16_t	target_id;
+	uint32_t	size;
+} sq_sge_t, *psq_sge_t;
+
+/* sq_psn_search (size:64b/8B) */
+
+typedef struct sq_psn_search {
+	/* Start PSN. */
+	uint32_t	opcode_start_psn;
+	/* Start PSN. */
+	#define SQ_PSN_SEARCH_START_PSN_MASK UINT32_C(0xffffff)
+	#define SQ_PSN_SEARCH_START_PSN_SFT 0
+	/* The opcodes are software defined. */
+	#define SQ_PSN_SEARCH_OPCODE_MASK   UINT32_C(0xff000000)
+	#define SQ_PSN_SEARCH_OPCODE_SFT	24
+	uint32_t	flags_next_psn;
+	/* Next PSN. Equal to the start PSN of the next WQE. */
+	#define SQ_PSN_SEARCH_NEXT_PSN_MASK UINT32_C(0xffffff)
+	#define SQ_PSN_SEARCH_NEXT_PSN_SFT 0
+	/* Opcode specific flags. */
+	#define SQ_PSN_SEARCH_FLAGS_MASK   UINT32_C(0xff000000)
+	#define SQ_PSN_SEARCH_FLAGS_SFT	24
+} sq_psn_search_t, *psq_psn_search_t;
+
+/* This PSN table structure is used only on devices where variable size WQEs are supported. */
+/* sq_psn_search_ext (size:128b/16B) */
+
+typedef struct sq_psn_search_ext {
+	/* Start PSN. */
+	uint32_t	opcode_start_psn;
+	/* Start PSN. */
+	#define SQ_PSN_SEARCH_EXT_START_PSN_MASK UINT32_C(0xffffff)
+	#define SQ_PSN_SEARCH_EXT_START_PSN_SFT 0
+	/* The opcodes are software defined. */
+	#define SQ_PSN_SEARCH_EXT_OPCODE_MASK   UINT32_C(0xff000000)
+	#define SQ_PSN_SEARCH_EXT_OPCODE_SFT	24
+	uint32_t	flags_next_psn;
+	/* Next PSN. Equal to the start PSN of the next WQE. */
+	#define SQ_PSN_SEARCH_EXT_NEXT_PSN_MASK UINT32_C(0xffffff)
+	#define SQ_PSN_SEARCH_EXT_NEXT_PSN_SFT 0
+	/* Opcode specific flags. */
+	#define SQ_PSN_SEARCH_EXT_FLAGS_MASK   UINT32_C(0xff000000)
+	#define SQ_PSN_SEARCH_EXT_FLAGS_SFT	24
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * This field is used only when variable sized WQEs are being used.
+	 * This indicates the starting slot index of the corresponding WQE.
 	 */
-	uint64_t	resp_addr;
-	/* Port ID of port for which this query is for. */
-	uint16_t	port_id;
-	uint8_t	unused_0[6];
+	uint16_t	start_slot_idx;
+	/* reserved16 is 16 b */
+	uint16_t	reserved16;
+	/* reserved32 is 32 b */
+	uint32_t	reserved32;
+} sq_psn_search_ext_t, *psq_psn_search_ext_t;
+
+/* This MSN table structure is used only on devices where Hardware based Requester retransmission is used. */
+/* sq_msn_search (size:64b/8B) */
+
+typedef struct sq_msn_search {
+	/* MSN search entry. */
+	uint64_t	start_idx_next_psn_start_psn;
+	/* Start PSN. */
+	#define SQ_MSN_SEARCH_START_PSN_MASK UINT32_C(0xffffff)
+	#define SQ_MSN_SEARCH_START_PSN_SFT 0
+	/* Next PSN. Equal to the start PSN of the next WQE. */
+	#define SQ_MSN_SEARCH_NEXT_PSN_MASK 0xffffff000000ULL
+	#define SQ_MSN_SEARCH_NEXT_PSN_SFT  24
 	/*
-	 * Physical address of the packet buffer for querying
-	 * WoL packet.
+	 * For variable-size WQEs, this field indicates the starting
+	 * slot index that corresponds to the WQE.
+	 * In backward-compatible mode, this is the starting WQE index.
 	 */
-	uint64_t	wol_pkt_buf_addr;
-	/* The size of the buffer for the WoL packet. */
-	uint16_t	wol_pkt_buf_size;
-	uint8_t	unused_1[6];
-} hwrm_wol_reason_qcfg_input_t, *phwrm_wol_reason_qcfg_input_t;
+	#define SQ_MSN_SEARCH_START_IDX_MASK 0xffff000000000000ULL
+	#define SQ_MSN_SEARCH_START_IDX_SFT 48
+} sq_msn_search_t, *psq_msn_search_t;
 
-/* hwrm_wol_reason_qcfg_output (size:128b/16B) */
+/* Send SQ WQE */
+/* sq_send (size:1024b/128B) */
 
-typedef struct hwrm_wol_reason_qcfg_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
+typedef struct sq_send {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
+	/* Send */
+	#define SQ_SEND_WQE_TYPE_SEND	UINT32_C(0x0)
 	/*
-	 * This value identifies the filter that matched
-	 * the last WoL packet.
-	 * This id is only valid with valid WoL reason.
+	 * Send with Immediate
+	 *
+	 * Allowed only on reliable connection (RC) and
+	 * unreliable datagram (UD) SQs.
 	 */
-	uint8_t	wol_filter_id;
+	#define SQ_SEND_WQE_TYPE_SEND_W_IMMEAD  UINT32_C(0x1)
 	/*
-	 * This value identifies the type of WoL reason returned
-	 * in this response.
-	 * When the wol_type is set to invalid, then there is
-	 * no WoL event that happened during last system
-	 * wake-up.
+	 * Send with Invalidate.
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint8_t	wol_reason;
-	/* Magic Packet */
-	#define HWRM_WOL_REASON_QCFG_OUTPUT_WOL_REASON_MAGICPKT UINT32_C(0x0)
-	/* Bitmap */
-	#define HWRM_WOL_REASON_QCFG_OUTPUT_WOL_REASON_BMP	UINT32_C(0x1)
-	/* Invalid */
-	#define HWRM_WOL_REASON_QCFG_OUTPUT_WOL_REASON_INVALID  UINT32_C(0xff)
-	#define HWRM_WOL_REASON_QCFG_OUTPUT_WOL_REASON_LAST	HWRM_WOL_REASON_QCFG_OUTPUT_WOL_REASON_INVALID
-	/* The value identifies the length of the WoL packet in bytes. */
-	uint8_t	wol_pkt_len;
-	uint8_t	unused_0[4];
+	#define SQ_SEND_WQE_TYPE_SEND_W_INVALID UINT32_C(0x2)
+	#define SQ_SEND_WQE_TYPE_LAST	SQ_SEND_WQE_TYPE_SEND_W_INVALID
+	uint8_t	flags;
+	#define SQ_SEND_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_MASK		UINT32_C(0xff)
+	#define SQ_SEND_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_SFT			0
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * Set if completion signaling is requested. If this bit is
+	 * 0, and the SQ is configured to support Unsignaled completion
+	 * the controller should not generate a CQE unless there was
+	 * an error. This refers to the CQE on the sender side. (The se
+	 * flag refers to the receiver side).
 	 */
-	uint8_t	valid;
-} hwrm_wol_reason_qcfg_output_t, *phwrm_wol_reason_qcfg_output_t;
-
-/*****************************
- * hwrm_dbg_crashdump_header *
- *****************************/
-
-
-/* hwrm_dbg_crashdump_header_input (size:192b/24B) */
-
-typedef struct hwrm_dbg_crashdump_header_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define SQ_SEND_FLAGS_SIGNAL_COMP								UINT32_C(0x1)
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * Indication to complete all previous RDMA Read or Atomic WQEs
+	 * on the SQ before executing this WQE.
+	 *
+	 * This flag must be zero for a UD send.
 	 */
-	uint16_t	cmpl_ring;
+	#define SQ_SEND_FLAGS_RD_OR_ATOMIC_FENCE							UINT32_C(0x2)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * For local invalidate request. Indication to complete all
+	 * previous SQ's WQEs before executing this WQE.
+	 *
+	 * This flag must be zero for a UD send.
 	 */
-	uint16_t	seq_id;
+	#define SQ_SEND_FLAGS_UC_FENCE								UINT32_C(0x4)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Solicit event flag. Indication sent in BTH header to the
+	 * receiver to generate a Completion Event Notification, i.e.
+	 * CNQE. This bit should be set only in the last (or only) packet
+	 * of the message.
 	 */
-	uint16_t	target_id;
+	#define SQ_SEND_FLAGS_SE									UINT32_C(0x8)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Indicate that inline data is posted to the SQ in the data
+	 * area of this WQE.
 	 */
-	uint64_t	resp_addr;
-	uint64_t	unused_0;
-} hwrm_dbg_crashdump_header_input_t, *phwrm_dbg_crashdump_header_input_t;
-
-/* hwrm_dbg_crashdump_header_output (size:512b/64B) */
-
-typedef struct hwrm_dbg_crashdump_header_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Major version. */
-	uint8_t	version_hi;
-	/* Minor version. */
-	uint8_t	version_low;
+	#define SQ_SEND_FLAGS_INLINE								UINT32_C(0x10)
 	/*
-	 * Header length in bytes. This includes all fields from version
-	 * to dev_uid (whose length is specified in dev_uid_length).
+	 * If set to 1, then the timestamp from the WQE is used. If
+	 * cleared to 0, then TWE provides the timestamp.
 	 */
-	uint16_t	header_len;
-	/* This is the crash dump size in bytes. */
-	uint32_t	dump_size;
+	#define SQ_SEND_FLAGS_WQE_TS_EN								UINT32_C(0x20)
 	/*
-	 * This is a "wall clock" timestamp value of when the crash occurred.
-	 * Format is of time_t type.
+	 * When set to '1', this operation will cause a trace capture in
+	 * each block it passes through.
 	 */
-	uint32_t	crash_time;
-	/* This is the timezone information for the crash_time. */
-	int8_t	utc_offset;
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_UTC				0
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_AMSTERDAM			4
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_EGYPT			8
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_EUROPE_MOSCOW		12
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_IRAN			14
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_ASIA_DUBAI			16
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_ASIA_KABUL			18
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_ANTARCTICA_MAWSON		20
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_ASIA_COLOMBO		22
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_ASIA_KATHMANDU		23
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_INDIAN_CHAGOS		24
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_INDIAN_COCOS		26
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_ASIA_BANGKOK		28
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_ASIA_HONG_KONG		32
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_ASIA_PYONGYANG		34
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_AUSTRALIA_EUCLA		35
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_ASIA_TOKYO			36
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_AUSTRALIA_ADELAIDE		38
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_AUSTRALIA_BROKEN_HILL	38
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_AUSTRALIA_DARWIN		38
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_AUSTRALIA_SYDNEY		40
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_AUSTRALIA_LORD_HOWE		42
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_ANTARCTICA_MACQUARIE	44
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_ANTARCTICA_SOUTH_POLE	48
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_PACIFIC_CHATHAM		51
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_PACIFIC_APIA		52
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_PACIFIC_KIRITIMATIS		56
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_ATLANTIC_CAPE_VERDE		-4
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_ATLANTIC_SOUTH_GEORGIA	-8
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_AMERICA_ARGENTINA_BUENOS_AIRES -12
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_AMERICA_SAO_PAULO		-12
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_AMERICA_NEWFOUNDLAND	-14
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_AMERICA_BARBADOS		-16
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_AMERICA_CANCUN		-20
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_AMERICA_COSTA_RICA		-24
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_AMERICA_PHOENIX		-28
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_US_ARIZONA			-28
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_US_PACIFIC			-32
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_US_ALASKA			-36
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_PACIFIC_MARQUESAS		-38
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_PACIFIC_HAWAII		-40
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_PACIFIC_MIDWAY		-44
-	#define HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_LAST			HWRM_DBG_CRASHDUMP_HEADER_OUTPUT_UTC_OFFSET_PACIFIC_MIDWAY
+	#define SQ_SEND_FLAGS_DEBUG_TRACE								UINT32_C(0x40)
 	/*
-	 * This field is a counter value of the crash dump available. This
-	 * value is incremented monotonically at each crash.
+	 * The number of 16 bytes chunks of data including this first
+	 * word of the request that are a valid part of the request. The
+	 * valid 16 bytes units other than the WQE structure can be
+	 * SGEs (Scatter Gather Elements) OR inline data.
+	 *
+	 * While this field defines the valid WQE size. The actual
+	 * total WQE size is always 128B.
 	 */
-	uint8_t	crash_cntr;
+	uint8_t	wqe_size;
+	uint8_t	reserved8_1;
 	/*
-	 * This specifies the length of the dev_uid in bytes. The maximum
-	 * value is 31.
+	 * Either invalidate key (R_Key of the remote host) that will
+	 * be send with IETH (Invalidate ETH) if wqe_type is of Send
+	 * with Invalidate, or immediate value that will be sent with
+	 * ImmDt header if wqe_type is Send with Immediate.
 	 */
-	uint16_t	dev_uid_length;
+	uint32_t	inv_key_or_imm_data;
+	/* This field represents a 32-bit total data length, in bytes. */
+	uint32_t	length;
 	/*
-	 * This is a unique device identifier (e.g. the first port MAC
-	 * address for a network controller or a serial number for an
-	 * en/decryption device) in ASCII format. It is used to identify
-	 * where the crash dump content is coming from. Unused bytes must
-	 * have '\0' character.
+	 * When in the SQ of a UD QP, indicates the q_key to be used in
+	 * the transmitted packet. However, if the most significant bit
+	 * of this field is set, then the q_key will be taken from QP
+	 * context, rather than from this field.
+	 *
+	 * When in the SQ of a non-UD QP, this field is reserved and
+	 * should be filled with zeros.
 	 */
-	uint8_t	dev_uid[32];
+	uint32_t	q_key;
 	/*
-	 * This is a count value tracking the number of successful boots
-	 * before the crash occurred.
+	 * When in the SQ of a UD QP, indicates the destination QP to be
+	 * used in the transmitted packet.
+	 *
+	 * When in the SQ of a non-UD QP, this field is reserved and
+	 * should be filled with zeros.
 	 */
-	uint32_t	power_on_count;
-	uint8_t	unused_2[3];
+	uint32_t	dst_qp;
+	#define SQ_SEND_DST_QP_MASK UINT32_C(0xffffff)
+	#define SQ_SEND_DST_QP_SFT 0
+	uint32_t	avid;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * If the serv_type is 'UD', then this field supplies the AVID
+	 * (Address Vector ID).
 	 */
-	uint8_t	valid;
-} hwrm_dbg_crashdump_header_output_t, *phwrm_dbg_crashdump_header_output_t;
-
-/****************************
- * hwrm_dbg_crashdump_erase *
- ****************************/
-
-
-/* hwrm_dbg_crashdump_erase_input (size:192b/24B) */
-
-typedef struct hwrm_dbg_crashdump_erase_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define SQ_SEND_AVID_MASK UINT32_C(0xfffff)
+	#define SQ_SEND_AVID_SFT 0
+	uint32_t	reserved32;
+	uint32_t	timestamp;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * This field specifies a 24-bit timestamp that can be passed
+	 * down the TX path and optionally logged in the TXP timestamp
+	 * histogram.
 	 */
-	uint16_t	cmpl_ring;
+	#define SQ_SEND_TIMESTAMP_MASK UINT32_C(0xffffff)
+	#define SQ_SEND_TIMESTAMP_SFT 0
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * When inline=0, then this area is filled with from 1 to 6
+	 * SGEs based on the wqe_size field.
+	 *
+	 * When inline=1, this area is filled with payload data for the
+	 * send based on the length_or_AVID field. Bits [7:0] of word 0
+	 * hold the first byte to go out on the wire.
 	 */
-	uint16_t	seq_id;
+	uint32_t	data[24];
+} sq_send_t, *psq_send_t;
+
+/* Send SQ WQE header. */
+/* sq_send_hdr (size:256b/32B) */
+
+typedef struct sq_send_hdr {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
+	/* Send */
+	#define SQ_SEND_HDR_WQE_TYPE_SEND	UINT32_C(0x0)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Send with Immediate
+	 *
+	 * Allowed only on reliable connection (RC) and
+	 * unreliable datagram (UD) SQs.
 	 */
-	uint16_t	target_id;
+	#define SQ_SEND_HDR_WQE_TYPE_SEND_W_IMMEAD  UINT32_C(0x1)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Send with Invalidate.
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint64_t	resp_addr;
-	/* The scope of the erase */
-	uint8_t	scope;
+	#define SQ_SEND_HDR_WQE_TYPE_SEND_W_INVALID UINT32_C(0x2)
+	#define SQ_SEND_HDR_WQE_TYPE_LAST	SQ_SEND_HDR_WQE_TYPE_SEND_W_INVALID
+	uint8_t	flags;
+	#define SQ_SEND_HDR_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_MASK		UINT32_C(0xff)
+	#define SQ_SEND_HDR_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_SFT			0
 	/*
-	 * Wipe all crashdump data blocks, making them available for
-	 * the next crash(es). This is the typical value to be used.
+	 * Set if completion signaling is requested. If this bit is
+	 * 0, and the SQ is configured to support Unsignaled completion
+	 * the controller should not generate a CQE unless there was
+	 * an error. This refers to the CQE on the sender side. (The se
+	 * flag refers to the receiver side).
 	 */
-	#define HWRM_DBG_CRASHDUMP_ERASE_INPUT_SCOPE_INVALIDATE UINT32_C(0x0)
+	#define SQ_SEND_HDR_FLAGS_SIGNAL_COMP								UINT32_C(0x1)
 	/*
-	 * Experimental: Remove all data blocks from the directory
-	 * (without erasing any existing contents), re-allocate and
-	 * re-initialize new ones. In case where the crash dump feature
-	 * stops functioning, this can be used to restore it back to the
-	 * clean slate.
+	 * Indication to complete all previous RDMA Read or Atomic WQEs
+	 * on the SQ before executing this WQE.
+	 *
+	 * This flag must be zero for a UD send.
 	 */
-	#define HWRM_DBG_CRASHDUMP_ERASE_INPUT_SCOPE_REINIT	UINT32_C(0x1)
-	#define HWRM_DBG_CRASHDUMP_ERASE_INPUT_SCOPE_LAST	HWRM_DBG_CRASHDUMP_ERASE_INPUT_SCOPE_REINIT
-	uint8_t	unused_0[3];
-	uint32_t	unused_1;
-} hwrm_dbg_crashdump_erase_input_t, *phwrm_dbg_crashdump_erase_input_t;
-
-/* hwrm_dbg_crashdump_erase_output (size:128b/16B) */
-
-typedef struct hwrm_dbg_crashdump_erase_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	unused_1[7];
+	#define SQ_SEND_HDR_FLAGS_RD_OR_ATOMIC_FENCE							UINT32_C(0x2)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * For local invalidate request. Indication to complete all
+	 * previous SQ's WQEs before executing this WQE.
+	 *
+	 * This flag must be zero for a UD send.
 	 */
-	uint8_t	valid;
-} hwrm_dbg_crashdump_erase_output_t, *phwrm_dbg_crashdump_erase_output_t;
-
-/******************
- * hwrm_dbg_qcaps *
- ******************/
-
-
-/* hwrm_dbg_qcaps_input (size:192b/24B) */
-
-typedef struct hwrm_dbg_qcaps_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define SQ_SEND_HDR_FLAGS_UC_FENCE								UINT32_C(0x4)
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * Solicit event flag. Indication sent in BTH header to the
+	 * receiver to generate a Completion Event Notification, i.e.
+	 * CNQE. This bit should be set only in the last (or only) packet
+	 * of the message.
 	 */
-	uint16_t	cmpl_ring;
+	#define SQ_SEND_HDR_FLAGS_SE									UINT32_C(0x8)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Indicate that inline data is posted to the SQ in the data
+	 * area of this WQE.
 	 */
-	uint16_t	seq_id;
+	#define SQ_SEND_HDR_FLAGS_INLINE								UINT32_C(0x10)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * If set to 1, then the timestamp from the WQE is used. If
+	 * cleared to 0, then TWE provides the timestamp.
 	 */
-	uint16_t	target_id;
+	#define SQ_SEND_HDR_FLAGS_WQE_TS_EN								UINT32_C(0x20)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * When set to '1', this operation will cause a trace capture in
+	 * each block it passes through.
 	 */
-	uint64_t	resp_addr;
+	#define SQ_SEND_HDR_FLAGS_DEBUG_TRACE								UINT32_C(0x40)
 	/*
-	 * Function ID of the function that is being queried.
-	 * 0xFF... (All Fs) if the query is for the requesting
-	 * function.
+	 * The number of 16 bytes chunks of data including this first
+	 * word of the request that are a valid part of the request. The
+	 * valid 16 bytes units other than the WQE structure can be
+	 * SGEs (Scatter Gather Elements) OR inline data.
+	 *
+	 * While this field defines the valid WQE size. The actual
+	 * total WQE size is always 128B.
 	 */
-	uint16_t	fid;
-	uint8_t	unused_0[6];
-} hwrm_dbg_qcaps_input_t, *phwrm_dbg_qcaps_input_t;
-
-/* hwrm_dbg_qcaps_output (size:192b/24B) */
-
-typedef struct hwrm_dbg_qcaps_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
+	uint8_t	wqe_size;
+	uint8_t	reserved8_1;
 	/*
-	 * FID value.  This value is used to identify operations on the PCI
-	 * bus as belonging to a particular PCI function.
+	 * Either invalidate key (R_Key of the remote host) that will
+	 * be send with IETH (Invalidate ETH) if wqe_type is of Send
+	 * with Invalidate, or immediate value that will be sent with
+	 * ImmDt header if wqe_type is Send with Immediate.
 	 */
-	uint16_t	fid;
-	uint8_t	unused_0[2];
+	uint32_t	inv_key_or_imm_data;
+	/* This field represents a 32-bit total data length, in bytes. */
+	uint32_t	length;
 	/*
-	 * Bitwise field of components FW supports skipping during collection
-	 * of coredump as part of a crash collection.
+	 * When in the SQ of a UD QP, indicates the q_key to be used in
+	 * the transmitted packet. However, if the most significant bit
+	 * of this field is set, then the q_key will be taken from QP
+	 * context, rather than from this field.
+	 *
+	 * When in the SQ of a non-UD QP, this field is reserved and
+	 * should be filled with zeros.
 	 */
-	uint32_t	coredump_component_disable_caps;
+	uint32_t	q_key;
 	/*
-	 * If 1, FW supports disabling the collection of NVM during a
-	 * coredump taken as part of crash collection.
+	 * When in the SQ of a UD QP, indicates the destination QP to be
+	 * used in the transmitted packet.
+	 *
+	 * When in the SQ of a non-UD QP, this field is reserved and
+	 * should be filled with zeros.
 	 */
-	#define HWRM_DBG_QCAPS_OUTPUT_COREDUMP_COMPONENT_DISABLE_CAPS_NVRAM	UINT32_C(0x1)
-	uint32_t	flags;
-	/* If 1, FW supports writing a crashdump to NVM. */
-	#define HWRM_DBG_QCAPS_OUTPUT_FLAGS_CRASHDUMP_NVM	UINT32_C(0x1)
-	/* If 1, FW supports writing a crashdump to host ddr. */
-	#define HWRM_DBG_QCAPS_OUTPUT_FLAGS_CRASHDUMP_HOST_DDR	UINT32_C(0x2)
-	/* If 1, FW supports writing a crashdump to soc ddr. */
-	#define HWRM_DBG_QCAPS_OUTPUT_FLAGS_CRASHDUMP_SOC_DDR	UINT32_C(0x4)
-	/* If 1, FW supports USEQ operations */
-	#define HWRM_DBG_QCAPS_OUTPUT_FLAGS_USEQ		UINT32_C(0x8)
-	uint8_t	unused_1[3];
+	uint32_t	dst_qp;
+	#define SQ_SEND_HDR_DST_QP_MASK UINT32_C(0xffffff)
+	#define SQ_SEND_HDR_DST_QP_SFT 0
+	uint32_t	avid;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * If the serv_type is 'UD', then this field supplies the AVID
+	 * (Address Vector ID).
 	 */
-	uint8_t	valid;
-} hwrm_dbg_qcaps_output_t, *phwrm_dbg_qcaps_output_t;
-
-/*****************
- * hwrm_dbg_qcfg *
- *****************/
-
+	#define SQ_SEND_HDR_AVID_MASK UINT32_C(0xfffff)
+	#define SQ_SEND_HDR_AVID_SFT 0
+	uint32_t	reserved32;
+	uint32_t	timestamp;
+	/*
+	 * This field specifies a 24-bit timestamp that can be passed
+	 * down the TX path and optionally logged in the TXP timestamp
+	 * histogram.
+	 */
+	#define SQ_SEND_HDR_TIMESTAMP_MASK UINT32_C(0xffffff)
+	#define SQ_SEND_HDR_TIMESTAMP_SFT 0
+} sq_send_hdr_t, *psq_send_hdr_t;
 
-/* hwrm_dbg_qcfg_input (size:192b/24B) */
+/* Send Raw Ethernet and QP1 SQ WQE */
+/* sq_send_raweth_qp1 (size:1024b/128B) */
 
-typedef struct hwrm_dbg_qcfg_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+typedef struct sq_send_raweth_qp1 {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
+	/* Send */
+	#define SQ_SEND_RAWETH_QP1_WQE_TYPE_SEND UINT32_C(0x0)
+	#define SQ_SEND_RAWETH_QP1_WQE_TYPE_LAST SQ_SEND_RAWETH_QP1_WQE_TYPE_SEND
+	uint8_t	flags;
+	#define SQ_SEND_RAWETH_QP1_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_MASK		UINT32_C(0xff)
+	#define SQ_SEND_RAWETH_QP1_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_SFT			0
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * Set if completion signaling is requested. If this bit is
+	 * 0, and the SQ is configured to support Unsignaled completion
+	 * the controller should not generate a CQE unless there was
+	 * an error. This refers to the CQE on the sender side. (The se
+	 * flag refers to the receiver side).
 	 */
-	uint16_t	cmpl_ring;
+	#define SQ_SEND_RAWETH_QP1_FLAGS_SIGNAL_COMP								UINT32_C(0x1)
+	/* This flag must be zero for a Raweth or QP1 send. */
+	#define SQ_SEND_RAWETH_QP1_FLAGS_RD_OR_ATOMIC_FENCE							UINT32_C(0x2)
+	/* This flag must be zero for a Raweth or QP1 send. */
+	#define SQ_SEND_RAWETH_QP1_FLAGS_UC_FENCE								UINT32_C(0x4)
+	/* This flag must be zero for a Raweth or QP1 send. */
+	#define SQ_SEND_RAWETH_QP1_FLAGS_SE									UINT32_C(0x8)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Indicate that inline data is posted to the SQ in the data
+	 * area of this WQE.
 	 */
-	uint16_t	seq_id;
+	#define SQ_SEND_RAWETH_QP1_FLAGS_INLINE								UINT32_C(0x10)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * If set to 1, then the timestamp from the WQE is used. If
+	 * cleared to 0, then TWE provides the timestamp.
 	 */
-	uint16_t	target_id;
+	#define SQ_SEND_RAWETH_QP1_FLAGS_WQE_TS_EN								UINT32_C(0x20)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * When set to '1', this operation will cause a trace capture in
+	 * each block it passes through.
 	 */
-	uint64_t	resp_addr;
+	#define SQ_SEND_RAWETH_QP1_FLAGS_DEBUG_TRACE								UINT32_C(0x40)
 	/*
-	 * Function ID of the function that is being queried.
-	 * 0xFF... (All Fs) if the query is for the requesting
-	 * function.
+	 * The number of 16 bytes chunks of data including this first
+	 * word of the request that are a valid part of the request. The
+	 * valid 16 bytes units other than the WQE structure can be
+	 * SGEs (Scatter Gather Elements) OR inline data.
+	 *
+	 * While this field defines the valid WQE size. The actual
+	 * total WQE size is always 128B.
 	 */
-	uint16_t	fid;
-	uint16_t	flags;
+	uint8_t	wqe_size;
+	uint8_t	reserved8;
 	/*
-	 * The crashdump size represents size of crashdump
-	 * written to the specified destination.
+	 * All bits in this field must be valid on the first BD of a packet.
+	 * Their value on other BDs of the packet will be ignored.
 	 */
-	#define HWRM_DBG_QCFG_INPUT_FLAGS_CRASHDUMP_SIZE_FOR_DEST_MASK	UINT32_C(0x3)
-	#define HWRM_DBG_QCFG_INPUT_FLAGS_CRASHDUMP_SIZE_FOR_DEST_SFT	0
-	/* crashdump size written to nvm */
-		#define HWRM_DBG_QCFG_INPUT_FLAGS_CRASHDUMP_SIZE_FOR_DEST_DEST_NVM	UINT32_C(0x0)
-	/* crashdump size written to host_ddr */
-		#define HWRM_DBG_QCFG_INPUT_FLAGS_CRASHDUMP_SIZE_FOR_DEST_DEST_HOST_DDR  UINT32_C(0x1)
-	/* crashdump size written to soc_ddr */
-		#define HWRM_DBG_QCFG_INPUT_FLAGS_CRASHDUMP_SIZE_FOR_DEST_DEST_SOC_DDR   UINT32_C(0x2)
-		#define HWRM_DBG_QCFG_INPUT_FLAGS_CRASHDUMP_SIZE_FOR_DEST_LAST	HWRM_DBG_QCFG_INPUT_FLAGS_CRASHDUMP_SIZE_FOR_DEST_DEST_SOC_DDR
+	uint16_t	lflags;
 	/*
-	 * Bitwise field of components requested for FW to skip when
-	 * calculating the size of a coredump collection.
+	 * If set to 1, the controller replaces the TCP/UPD checksum
+	 * fields of normal TCP/UPD checksum, or the inner TCP/UDP
+	 * checksum field of the encapsulated TCP/UDP packets with the
+	 * hardware calculated TCP/UDP checksum for the packet associated
+	 * with this descriptor.
+	 *
+	 * This bit must be valid on the first BD of a packet.
 	 */
-	uint32_t	coredump_component_disable_flags;
+	#define SQ_SEND_RAWETH_QP1_LFLAGS_TCP_UDP_CHKSUM	UINT32_C(0x1)
 	/*
-	 * If 1, NVM will not be collected during a coredump taken as part
-	 * of crash collection.
+	 * If set to 1, the controller replaces the IP checksum of the
+	 * normal packets, or the inner IP checksum of the encapsulated
+	 * packets with the hardware calculated IP checksum for the
+	 * packet associated with this descriptor.
+	 *
+	 * This bit must be valid on the first BD of a packet.
 	 */
-	#define HWRM_DBG_QCFG_INPUT_COREDUMP_COMPONENT_DISABLE_FLAGS_NVRAM	UINT32_C(0x1)
-} hwrm_dbg_qcfg_input_t, *phwrm_dbg_qcfg_input_t;
-
-/* hwrm_dbg_qcfg_output (size:256b/32B) */
-
-typedef struct hwrm_dbg_qcfg_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
+	#define SQ_SEND_RAWETH_QP1_LFLAGS_IP_CHKSUM	UINT32_C(0x2)
 	/*
-	 * FID value.  This value is used to identify operations on the PCI
-	 * bus as belonging to a particular PCI function.
+	 * If set to 1, the controller will not append an Ethernet CRC
+	 * to the end of the frame.
+	 *
+	 * This bit must be valid on the first BD of a packet.
+	 *
+	 * Packet must be 64B or longer when this flag is set. It is not
+	 * useful to use this bit with any form of TX offload such as
+	 * CSO or LSO. The intent is that the packet from the host already
+	 * has a valid Ethernet CRC on the packet.
 	 */
-	uint16_t	fid;
-	uint8_t	unused_0[2];
+	#define SQ_SEND_RAWETH_QP1_LFLAGS_NOCRC		UINT32_C(0x4)
 	/*
-	 * Size in bytes of a coredump file created by the FW.  This takes into
-	 * consideration any components selected in the
-	 * coredump_component_disable_flags field from hwrm_dbg_qcfg_input.
+	 * If set to 1, the device will record the time at which the packet
+	 * was actually transmitted at the TX MAC.
+	 *
+	 * This bit must be valid on the first BD of a packet.
 	 */
-	uint32_t	coredump_size;
-	uint32_t	flags;
+	#define SQ_SEND_RAWETH_QP1_LFLAGS_STAMP		UINT32_C(0x8)
 	/*
-	 * If set to 1, then UART logging is enabled for the primary
-	 * firmware. Disabled otherwise.
+	 * If set to 1, The controller replaces the tunnel IP checksum
+	 * field with hardware calculated IP checksum for the IP header
+	 * of the packet associated with this descriptor. In case of
+	 * VXLAN, the controller also replaces the outer header UDP
+	 * checksum with hardware calculated UDP checksum for the packet
+	 * associated with this descriptor.
 	 */
-	#define HWRM_DBG_QCFG_OUTPUT_FLAGS_UART_LOG		UINT32_C(0x1)
+	#define SQ_SEND_RAWETH_QP1_LFLAGS_T_IP_CHKSUM	UINT32_C(0x10)
 	/*
-	 * If set to 1, then UART logging is enabled for the secondary
-	 * firmware. Disabled otherwise.
+	 * If set to '1', then the RoCE ICRC will be appended to the
+	 * packet. Packet must be a valid RoCE format packet.
 	 */
-	#define HWRM_DBG_QCFG_OUTPUT_FLAGS_UART_LOG_SECONDARY	UINT32_C(0x2)
+	#define SQ_SEND_RAWETH_QP1_LFLAGS_ROCE_CRC	UINT32_C(0x100)
 	/*
-	 * If set to 1, then completion ring logging is enabled for the
-	 * primary firmware. Disabled otherwise.
+	 * If set to '1', then the FCoE CRC will be appended to the
+	 * packet. Packet must be a valid FCoE format packet.
 	 */
-	#define HWRM_DBG_QCFG_OUTPUT_FLAGS_FW_TRACE		UINT32_C(0x4)
+	#define SQ_SEND_RAWETH_QP1_LFLAGS_FCOE_CRC	UINT32_C(0x200)
 	/*
-	 * If set to 1, then completion ring logging  is enabled for the
-	 * secondary firmware. Disabled otherwise.
+	 * This value selects a CFA action to perform on the packet.
+	 * Set this value to zero if no CFA action is desired.
+	 *
+	 * This value must be valid on the first BD of a packet.
 	 */
-	#define HWRM_DBG_QCFG_OUTPUT_FLAGS_FW_TRACE_SECONDARY	UINT32_C(0x8)
+	uint16_t	cfa_action;
 	/*
-	 * If set to 1, firmware will generate debug_notification async
-	 * events to the driver as applicable.
+	 * This field represents a 32-bit total data length, in bytes.
+	 * Note, however, that the length cannot exceed the MTU.
 	 */
-	#define HWRM_DBG_QCFG_OUTPUT_FLAGS_DEBUG_NOTIFY	UINT32_C(0x10)
+	uint32_t	length;
+	uint32_t	reserved32_1;
 	/*
-	 * If set to 1, firmware is allowed to be unresponsive to heartbeat
-	 * health checks, allowing for JTAG debugging scenarios where the
-	 * debugger has the firmware processes stopped indefinitely.  This
-	 * flag has effect only on debug builds of firmware.
+	 * This value is action meta-data that defines CFA edit operations
+	 * that are done in addition to any action editing.
 	 */
-	#define HWRM_DBG_QCFG_OUTPUT_FLAGS_JTAG_DEBUG		UINT32_C(0x20)
+	uint32_t	cfa_meta;
+	/* When key=1, This is the VLAN tag VID value. */
+	#define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_VID_MASK	UINT32_C(0xfff)
+	#define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_VID_SFT	0
+	/* When key=1, This is the VLAN tag DE value. */
+	#define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_DE	UINT32_C(0x1000)
+	/* When key=1, This is the VLAN tag PRI value. */
+	#define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_PRI_MASK	UINT32_C(0xe000)
+	#define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_PRI_SFT	13
+	/* When key=1, This is the VLAN tag TPID select value. */
+	#define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_TPID_MASK	UINT32_C(0x70000)
+	#define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_TPID_SFT	16
+	/* 0x88a8 */
+		#define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_TPID_TPID88A8  (UINT32_C(0x0) << 16)
+	/* 0x8100 */
+		#define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_TPID_TPID8100  (UINT32_C(0x1) << 16)
+	/* 0x9100 */
+		#define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_TPID_TPID9100  (UINT32_C(0x2) << 16)
+	/* 0x9200 */
+		#define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_TPID_TPID9200  (UINT32_C(0x3) << 16)
+	/* 0x9300 */
+		#define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_TPID_TPID9300  (UINT32_C(0x4) << 16)
+	/* Value programmed in CFA VLANTPID register. */
+		#define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_TPID_TPIDCFG   (UINT32_C(0x5) << 16)
+		#define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_TPID_LAST	SQ_SEND_RAWETH_QP1_CFA_META_VLAN_TPID_TPIDCFG
+	/* When key=1, This is the VLAN tag TPID select value. */
+	#define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_RESERVED_MASK UINT32_C(0xff80000)
+	#define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_RESERVED_SFT 19
 	/*
-	 * Notification queue (completion ring) used by the firmware to post
-	 * async debug notifications and fw trace logs. This field is valid
-	 * when fw_trace, fw_trace_secondary or debug_notify flags are set.
+	 * This field identifies the type of edit to be performed
+	 * on the packet.
+	 *
+	 * This value must be valid on the first BD of a packet.
 	 */
-	uint16_t	async_cmpl_ring;
-	uint8_t	unused_2[2];
+	#define SQ_SEND_RAWETH_QP1_CFA_META_KEY_MASK	UINT32_C(0xf0000000)
+	#define SQ_SEND_RAWETH_QP1_CFA_META_KEY_SFT	28
+	/* No editing */
+		#define SQ_SEND_RAWETH_QP1_CFA_META_KEY_NONE		(UINT32_C(0x0) << 28)
 	/*
-	 * Size in bytes of a crashdump file created by the FW.  Uses input
-	 * flags to determine medium destination and corresponding size.
+	 * - meta[17:16] - TPID select value (0 = 0x8100).
+	 * - meta[15:12] - PRI/DE value.
+	 * - meta[11:0] - VID value.
 	 */
-	uint32_t	crashdump_size;
-	uint8_t	unused_3[3];
+		#define SQ_SEND_RAWETH_QP1_CFA_META_KEY_VLAN_TAG	(UINT32_C(0x1) << 28)
+		#define SQ_SEND_RAWETH_QP1_CFA_META_KEY_LAST	SQ_SEND_RAWETH_QP1_CFA_META_KEY_VLAN_TAG
+	uint32_t	reserved32_2;
+	uint32_t	reserved32_3;
+	uint32_t	timestamp;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * This field specifies a 24-bit timestamp that can be passed
+	 * down the TX path and optionally logged in the TXP timestamp
+	 * histogram.
 	 */
-	uint8_t	valid;
-} hwrm_dbg_qcfg_output_t, *phwrm_dbg_qcfg_output_t;
-
-/*********************************
- * hwrm_dbg_crashdump_medium_cfg *
- *********************************/
-
+	#define SQ_SEND_RAWETH_QP1_TIMESTAMP_MASK UINT32_C(0xffffff)
+	#define SQ_SEND_RAWETH_QP1_TIMESTAMP_SFT 0
+	/*
+	 * When inline=0, then this area is filled with from 1 to 6
+	 * SGEs based on the wqe_size field.
+	 *
+	 * When inline=1, this area is filled with payload data for the
+	 * send based on the length_or_AVID field. Bits [7:0] of word 0
+	 * hold the first byte to go out on the wire.
+	 */
+	uint32_t	data[24];
+} sq_send_raweth_qp1_t, *psq_send_raweth_qp1_t;
 
-/* hwrm_dbg_crashdump_medium_cfg_input (size:320b/40B) */
+/* Send Raw Ethernet and QP1 SQ WQE header. */
+/* sq_send_raweth_qp1_hdr (size:256b/32B) */
 
-typedef struct hwrm_dbg_crashdump_medium_cfg_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+typedef struct sq_send_raweth_qp1_hdr {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
+	/* Send */
+	#define SQ_SEND_RAWETH_QP1_HDR_WQE_TYPE_SEND UINT32_C(0x0)
+	#define SQ_SEND_RAWETH_QP1_HDR_WQE_TYPE_LAST SQ_SEND_RAWETH_QP1_HDR_WQE_TYPE_SEND
+	uint8_t	flags;
+	#define SQ_SEND_RAWETH_QP1_HDR_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_MASK		UINT32_C(0xff)
+	#define SQ_SEND_RAWETH_QP1_HDR_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_SFT			0
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * Set if completion signaling is requested. If this bit is
+	 * 0, and the SQ is configured to support Unsignaled completion
+	 * the controller should not generate a CQE unless there was
+	 * an error. This refers to the CQE on the sender side. (The se
+	 * flag refers to the receiver side).
 	 */
-	uint16_t	cmpl_ring;
+	#define SQ_SEND_RAWETH_QP1_HDR_FLAGS_SIGNAL_COMP								UINT32_C(0x1)
+	/* This flag must be zero for a Raweth or QP1 send. */
+	#define SQ_SEND_RAWETH_QP1_HDR_FLAGS_RD_OR_ATOMIC_FENCE							UINT32_C(0x2)
+	/* This flag must be zero for a Raweth or QP1 send. */
+	#define SQ_SEND_RAWETH_QP1_HDR_FLAGS_UC_FENCE								UINT32_C(0x4)
+	/* This flag must be zero for a Raweth or QP1 send. */
+	#define SQ_SEND_RAWETH_QP1_HDR_FLAGS_SE									UINT32_C(0x8)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Indicate that inline data is posted to the SQ in the data
+	 * area of this WQE.
 	 */
-	uint16_t	seq_id;
+	#define SQ_SEND_RAWETH_QP1_HDR_FLAGS_INLINE								UINT32_C(0x10)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * If set to 1, then the timestamp from the WQE is used. If
+	 * cleared to 0, then TWE provides the timestamp.
 	 */
-	uint16_t	target_id;
+	#define SQ_SEND_RAWETH_QP1_HDR_FLAGS_WQE_TS_EN								UINT32_C(0x20)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * When set to '1', this operation will cause a trace capture in
+	 * each block it passes through.
 	 */
-	uint64_t	resp_addr;
-	uint16_t	output_dest_flags;
-	/* Destination is DDR ram. */
-	#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_TYPE_DDR	UINT32_C(0x1)
-	uint16_t	pg_size_lvl;
-	/* PBL indirect levels. */
-	#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_LVL_MASK	UINT32_C(0x3)
-	#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_LVL_LVL_1	UINT32_C(0x1)
+	#define SQ_SEND_RAWETH_QP1_HDR_FLAGS_DEBUG_TRACE								UINT32_C(0x40)
 	/*
-	 * PBL pointer points to PDE table with each entry pointing to
-	 * PTE tables.
+	 * The number of 16 bytes chunks of data including this first
+	 * word of the request that are a valid part of the request. The
+	 * valid 16 bytes units other than the WQE structure can be
+	 * SGEs (Scatter Gather Elements) OR inline data.
+	 *
+	 * While this field defines the valid WQE size. The actual
+	 * total WQE size is always 128B.
 	 */
-		#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_LVL_LVL_2	UINT32_C(0x2)
-		#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_LVL_LAST	HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_LVL_LVL_2
-	/* page size. */
-	#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_PG_SIZE_MASK  UINT32_C(0x1c)
-	#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_PG_SIZE_SFT   2
-	/* 4KB. */
-		#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_PG_SIZE_PG_4K   (UINT32_C(0x0) << 2)
-	/* 8KB. */
-		#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_PG_SIZE_PG_8K   (UINT32_C(0x1) << 2)
-	/* 64KB. */
-		#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_PG_SIZE_PG_64K  (UINT32_C(0x2) << 2)
-	/* 2MB. */
-		#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_PG_SIZE_PG_2M   (UINT32_C(0x3) << 2)
-	/* 8MB. */
-		#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_PG_SIZE_PG_8M   (UINT32_C(0x4) << 2)
-	/* 1GB. */
-		#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_PG_SIZE_PG_1G   (UINT32_C(0x5) << 2)
-		#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_PG_SIZE_LAST   HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_PG_SIZE_PG_1G
-	/* unused11 is 11 b */
-	#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_UNUSED11_MASK UINT32_C(0xffe0)
-	#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_UNUSED11_SFT  5
-	/* Crashdump buffer size. */
-	uint32_t	size;
+	uint8_t	wqe_size;
+	uint8_t	reserved8;
 	/*
-	 * Bitwise field of components that FW is requested to skip during
-	 * coredump as part of a crash collection.
+	 * All bits in this field must be valid on the first BD of a packet.
+	 * Their value on other BDs of the packet will be ignored.
 	 */
-	uint32_t	coredump_component_disable_flags;
+	uint16_t	lflags;
 	/*
-	 * If 1, then NVM will not be collected during a coredump taken as
-	 * part of crash collection.
+	 * If set to 1, the controller replaces the TCP/UPD checksum
+	 * fields of normal TCP/UPD checksum, or the inner TCP/UDP
+	 * checksum field of the encapsulated TCP/UDP packets with the
+	 * hardware calculated TCP/UDP checksum for the packet associated
+	 * with this descriptor.
+	 *
+	 * This bit must be valid on the first BD of a packet.
 	 */
-	#define HWRM_DBG_CRASHDUMP_MEDIUM_CFG_INPUT_NVRAM	UINT32_C(0x1)
-	uint32_t	unused_0;
-	/* Crashdump buffer PBL physical address. */
-	uint64_t	pbl;
-} hwrm_dbg_crashdump_medium_cfg_input_t, *phwrm_dbg_crashdump_medium_cfg_input_t;
-
-/* hwrm_dbg_crashdump_medium_cfg_output (size:128b/16B) */
-
-typedef struct hwrm_dbg_crashdump_medium_cfg_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	unused_1[7];
+	#define SQ_SEND_RAWETH_QP1_HDR_LFLAGS_TCP_UDP_CHKSUM	UINT32_C(0x1)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * If set to 1, the controller replaces the IP checksum of the
+	 * normal packets, or the inner IP checksum of the encapsulated
+	 * packets with the hardware calculated IP checksum for the
+	 * packet associated with this descriptor.
+	 *
+	 * This bit must be valid on the first BD of a packet.
 	 */
-	uint8_t	valid;
-} hwrm_dbg_crashdump_medium_cfg_output_t, *phwrm_dbg_crashdump_medium_cfg_output_t;
-
-/* coredump_segment_record (size:128b/16B) */
-
-typedef struct coredump_segment_record {
-	/* Component id of the returned component. */
-	uint16_t	component_id;
-	/* Segment id of the returned component. */
-	uint16_t	segment_id;
-	/* Not used. */
-	uint16_t	max_instances;
-	/* Major version. */
-	uint8_t	version_hi;
-	/* Minor version. */
-	uint8_t	version_low;
+	#define SQ_SEND_RAWETH_QP1_HDR_LFLAGS_IP_CHKSUM	UINT32_C(0x2)
 	/*
-	 * bit 0: live data
-	 * bit 1: crashed data
+	 * If set to 1, the controller will not append an Ethernet CRC
+	 * to the end of the frame.
+	 *
+	 * This bit must be valid on the first BD of a packet.
+	 *
+	 * Packet must be 64B or longer when this flag is set. It is not
+	 * useful to use this bit with any form of TX offload such as
+	 * CSO or LSO. The intent is that the packet from the host already
+	 * has a valid Ethernet CRC on the packet.
 	 */
-	uint8_t	seg_flags;
-	/* This field is used to indicate the segment is compressed. */
-	uint8_t	compress_flags;
+	#define SQ_SEND_RAWETH_QP1_HDR_LFLAGS_NOCRC		UINT32_C(0x4)
 	/*
-	 * SFLAG_COMPRESSED_ZLIB indicates that the segment data is
-	 * compressed.
+	 * If set to 1, the device will record the time at which the packet
+	 * was actually transmitted at the TX MAC.
+	 *
+	 * This bit must be valid on the first BD of a packet.
 	 */
-	#define SFLAG_COMPRESSED_ZLIB	UINT32_C(0x1)
-	uint8_t	unused_0[2];
+	#define SQ_SEND_RAWETH_QP1_HDR_LFLAGS_STAMP		UINT32_C(0x8)
 	/*
-	 * This field is the length of the segment data. It will be zero if
-	 * the firmware does not support returning the segment data length.
+	 * If set to 1, The controller replaces the tunnel IP checksum
+	 * field with hardware calculated IP checksum for the IP header
+	 * of the packet associated with this descriptor. In case of
+	 * VXLAN, the controller also replaces the outer header UDP
+	 * checksum with hardware calculated UDP checksum for the packet
+	 * associated with this descriptor.
 	 */
-	uint32_t	segment_len;
-} coredump_segment_record_t, *pcoredump_segment_record_t;
-
-/**************************
- * hwrm_dbg_coredump_list *
- **************************/
-
-
-/* hwrm_dbg_coredump_list_input (size:256b/32B) */
-
-typedef struct hwrm_dbg_coredump_list_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define SQ_SEND_RAWETH_QP1_HDR_LFLAGS_T_IP_CHKSUM	UINT32_C(0x10)
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * If set to '1', then the RoCE ICRC will be appended to the
+	 * packet. Packet must be a valid RoCE format packet.
 	 */
-	uint16_t	cmpl_ring;
+	#define SQ_SEND_RAWETH_QP1_HDR_LFLAGS_ROCE_CRC	UINT32_C(0x100)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * If set to '1', then the FCoE CRC will be appended to the
+	 * packet. Packet must be a valid FCoE format packet.
 	 */
-	uint16_t	seq_id;
+	#define SQ_SEND_RAWETH_QP1_HDR_LFLAGS_FCOE_CRC	UINT32_C(0x200)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * This value selects a CFA action to perform on the packet.
+	 * Set this value to zero if no CFA action is desired.
+	 *
+	 * This value must be valid on the first BD of a packet.
+	 */
+	uint16_t	cfa_action;
+	/*
+	 * This field represents a 32-bit total data length, in bytes.
+	 * Note, however, that the length cannot exceed the MTU.
+	 */
+	uint32_t	length;
+	uint32_t	reserved32_1;
+	/*
+	 * This value is action meta-data that defines CFA edit operations
+	 * that are done in addition to any action editing.
 	 */
-	uint16_t	target_id;
+	uint32_t	cfa_meta;
+	/* When key=1, This is the VLAN tag VID value. */
+	#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_VLAN_VID_MASK	UINT32_C(0xfff)
+	#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_VLAN_VID_SFT	0
+	/* When key=1, This is the VLAN tag DE value. */
+	#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_VLAN_DE	UINT32_C(0x1000)
+	/* When key=1, This is the VLAN tag PRI value. */
+	#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_VLAN_PRI_MASK	UINT32_C(0xe000)
+	#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_VLAN_PRI_SFT	13
+	/* When key=1, This is the VLAN tag TPID select value. */
+	#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_VLAN_TPID_MASK	UINT32_C(0x70000)
+	#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_VLAN_TPID_SFT	16
+	/* 0x88a8 */
+		#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_VLAN_TPID_TPID88A8  (UINT32_C(0x0) << 16)
+	/* 0x8100 */
+		#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_VLAN_TPID_TPID8100  (UINT32_C(0x1) << 16)
+	/* 0x9100 */
+		#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_VLAN_TPID_TPID9100  (UINT32_C(0x2) << 16)
+	/* 0x9200 */
+		#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_VLAN_TPID_TPID9200  (UINT32_C(0x3) << 16)
+	/* 0x9300 */
+		#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_VLAN_TPID_TPID9300  (UINT32_C(0x4) << 16)
+	/* Value programmed in CFA VLANTPID register. */
+		#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_VLAN_TPID_TPIDCFG   (UINT32_C(0x5) << 16)
+		#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_VLAN_TPID_LAST	SQ_SEND_RAWETH_QP1_HDR_CFA_META_VLAN_TPID_TPIDCFG
+	/* When key=1, This is the VLAN tag TPID select value. */
+	#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_VLAN_RESERVED_MASK UINT32_C(0xff80000)
+	#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_VLAN_RESERVED_SFT 19
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * This field identifies the type of edit to be performed
+	 * on the packet.
+	 *
+	 * This value must be valid on the first BD of a packet.
 	 */
-	uint64_t	resp_addr;
+	#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_KEY_MASK	UINT32_C(0xf0000000)
+	#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_KEY_SFT	28
+	/* No editing */
+		#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_KEY_NONE		(UINT32_C(0x0) << 28)
 	/*
-	 * host address where the data content will be written
-	 * when the request is complete.  This area must be 16B aligned.
+	 * - meta[17:16] - TPID select value (0 = 0x8100).
+	 * - meta[15:12] - PRI/DE value.
+	 * - meta[11:0] - VID value.
 	 */
-	uint64_t	host_dest_addr;
-	/* Length of host buffer used for transferring debug data. */
-	uint32_t	host_buf_len;
-	/* Sequence number of the request. Starts at 0. */
-	uint16_t	seq_no;
-	/*  */
-	uint8_t	flags;
+		#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_KEY_VLAN_TAG	(UINT32_C(0x1) << 28)
+		#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_KEY_LAST	SQ_SEND_RAWETH_QP1_HDR_CFA_META_KEY_VLAN_TAG
+	uint32_t	reserved32_2;
+	uint32_t	reserved32_3;
+	uint32_t	timestamp;
 	/*
-	 * If set to 1, crash dump is requested.
-	 * If set to 0, both live core and crash dump are requested.
+	 * This field specifies a 24-bit timestamp that can be passed
+	 * down the TX path and optionally logged in the TXP timestamp
+	 * histogram.
 	 */
-	#define HWRM_DBG_COREDUMP_LIST_INPUT_FLAGS_CRASHDUMP	UINT32_C(0x1)
-	uint8_t	unused_0[1];
-} hwrm_dbg_coredump_list_input_t, *phwrm_dbg_coredump_list_input_t;
+	#define SQ_SEND_RAWETH_QP1_HDR_TIMESTAMP_MASK UINT32_C(0xffffff)
+	#define SQ_SEND_RAWETH_QP1_HDR_TIMESTAMP_SFT 0
+} sq_send_raweth_qp1_hdr_t, *psq_send_raweth_qp1_hdr_t;
 
-/* hwrm_dbg_coredump_list_output (size:128b/16B) */
+/* RDMA SQ WQE */
+/* sq_rdma (size:1024b/128B) */
 
-typedef struct hwrm_dbg_coredump_list_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	flags;
+typedef struct sq_rdma {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
 	/*
-	 * Value of 1 means that there is more data available.
-	 * Issue the request again with the next sequence number.
+	 * RDMA Write.
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	#define HWRM_DBG_COREDUMP_LIST_OUTPUT_FLAGS_MORE	UINT32_C(0x1)
-	uint8_t	unused_0;
-	/* Total number of segments to be returned. */
-	uint16_t	total_segments;
-	/* Actual length of data returned in bytes. */
-	uint16_t	data_len;
-	uint8_t	unused_1;
+	#define SQ_RDMA_WQE_TYPE_WRITE_WQE	UINT32_C(0x4)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * RDMA Write with Immediate.
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint8_t	valid;
-} hwrm_dbg_coredump_list_output_t, *phwrm_dbg_coredump_list_output_t;
-
-/******************************
- * hwrm_dbg_coredump_initiate *
- ******************************/
-
-
-/* hwrm_dbg_coredump_initiate_input (size:256b/32B) */
-
-typedef struct hwrm_dbg_coredump_initiate_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define SQ_RDMA_WQE_TYPE_WRITE_W_IMMEAD UINT32_C(0x5)
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * RDMA Read.
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint16_t	cmpl_ring;
+	#define SQ_RDMA_WQE_TYPE_READ_WQE	UINT32_C(0x6)
+	#define SQ_RDMA_WQE_TYPE_LAST	SQ_RDMA_WQE_TYPE_READ_WQE
+	uint8_t	flags;
+	#define SQ_RDMA_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_MASK		UINT32_C(0xff)
+	#define SQ_RDMA_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_SFT			0
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Set if completion signaling is requested. If this bit is
+	 * 0, and the SQ is configured to support Unsignaled
+	 * completion the controller should not generate a CQE
+	 * unless there was an error. This refers to CQE on the
+	 * sender side (se_flag refers to the receiver side)
 	 */
-	uint16_t	seq_id;
+	#define SQ_RDMA_FLAGS_SIGNAL_COMP								UINT32_C(0x1)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Indication to complete all previous RDMA Read or Atomic
+	 * WQEs on the SQ before executing this WQE
 	 */
-	uint16_t	target_id;
+	#define SQ_RDMA_FLAGS_RD_OR_ATOMIC_FENCE							UINT32_C(0x2)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Unconditional fence. Indication to complete all previous
+	 * SQ's WQEs before executing this WQE.
 	 */
-	uint64_t	resp_addr;
-	/* Component id of the returned component. */
-	uint16_t	component_id;
-	/* Segment id of the returned component. */
-	uint16_t	segment_id;
-	/* Not used. */
-	uint16_t	instance;
-	/* Not used. */
-	uint16_t	unused_0;
+	#define SQ_RDMA_FLAGS_UC_FENCE								UINT32_C(0x4)
 	/*
-	 * bit 0: live data
-	 * bit 1: crashed data
+	 * Solicit event. Indication sent in BTH header to the
+	 * receiver to generate a Completion Event Notification,
+	 * i.e. CNQE. This bit should be set only in the last (or
+	 * only) packet of the message.
 	 */
-	uint8_t	seg_flags;
-	/* Not used. */
-	uint8_t	unused_1[7];
-} hwrm_dbg_coredump_initiate_input_t, *phwrm_dbg_coredump_initiate_input_t;
-
-/* hwrm_dbg_coredump_initiate_output (size:128b/16B) */
-
-typedef struct hwrm_dbg_coredump_initiate_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	#define SQ_RDMA_FLAGS_SE									UINT32_C(0x8)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * Indicate that inline data is posted to the SQ following
+	 * this WQE. This bit may be 1 only for write operations.
 	 */
-	uint8_t	valid;
-} hwrm_dbg_coredump_initiate_output_t, *phwrm_dbg_coredump_initiate_output_t;
-
-/* coredump_data_hdr (size:128b/16B) */
-
-typedef struct coredump_data_hdr {
-	/* Starting address of the register range. */
-	uint32_t	address;
+	#define SQ_RDMA_FLAGS_INLINE								UINT32_C(0x10)
 	/*
-	 * length: 0 - 23 bits represents the actual data without the pad.
-	 * flags: 24 - 31 bits represents indirect register ranges.
-	 *   - bit 24: Set if registers in this segment are indirect accessed.
+	 * If set to 1, then the timestamp from the WQE is used. If
+	 * cleared to 0, then TWE provides the timestamp.
 	 */
-	uint32_t	flags_length;
-	/* These bits represents the actual length of the data segment */
-	#define COREDUMP_DATA_HDR_FLAGS_LENGTH_ACTUAL_LEN_MASK	UINT32_C(0xffffff)
-	#define COREDUMP_DATA_HDR_FLAGS_LENGTH_ACTUAL_LEN_SFT	0
-	/* Set if registers in this segment are indirect accessed. */
-	#define COREDUMP_DATA_HDR_FLAGS_LENGTH_INDIRECT_ACCESS	UINT32_C(0x1000000)
-	/* Value in the partner register for indirect or multi-field registers. */
-	uint32_t	instance;
-	/* Starting address of the next register after the current data range */
-	uint32_t	next_offset;
-} coredump_data_hdr_t, *pcoredump_data_hdr_t;
-
-/******************************
- * hwrm_dbg_coredump_retrieve *
- ******************************/
-
-
-/* hwrm_dbg_coredump_retrieve_input (size:448b/56B) */
-
-typedef struct hwrm_dbg_coredump_retrieve_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define SQ_RDMA_FLAGS_WQE_TS_EN								UINT32_C(0x20)
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * When set to '1', this operation will cause a trace capture in
+	 * each block it passes through.
 	 */
-	uint16_t	cmpl_ring;
+	#define SQ_RDMA_FLAGS_DEBUG_TRACE								UINT32_C(0x40)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * The number of 16 bytes chunks of data including this first
+	 * wqe of the request that are a valid part of the request. The
+	 * valid 16 bytes units other than the WQE structure can be
+	 * SGEs (Scatter Gather Elements) OR inline data.
+	 *
+	 * While this field defines the valid WQE size. The actual
+	 * total WQE size is always 128B.
 	 */
-	uint16_t	seq_id;
+	uint8_t	wqe_size;
+	uint8_t	reserved8;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Immediate data - valid for RDMA Write with immediate and
+	 * causes the controller to add immDt header with this value
 	 */
-	uint16_t	target_id;
+	uint32_t	imm_data;
+	/* Total data length in bytes */
+	uint32_t	length;
+	uint32_t	reserved32_1;
+	/* Remote VA sent to the destination QP */
+	uint64_t	remote_va;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * R_Key provided by remote node when the connection was
+	 * established and placed in the RETH header. It identify the
+	 * MRW on the remote host
 	 */
-	uint64_t	resp_addr;
+	uint32_t	remote_key;
+	uint32_t	timestamp;
 	/*
-	 * host address where the data content will be written
-	 * when the request is complete.  This area must be 16B aligned.
+	 * This field specifies a 24-bit timestamp that can be passed
+	 * down the TX path and optionally logged in the TXP timestamp
+	 * histogram.
 	 */
-	uint64_t	host_dest_addr;
-	/* Length of host buffer used for transferring debug data. */
-	uint32_t	host_buf_len;
-	/* Not used. */
-	uint32_t	unused_0;
-	/* Component id of the returned component. */
-	uint16_t	component_id;
-	/* Segment id of the returned component. */
-	uint16_t	segment_id;
-	/* Not used. */
-	uint16_t	instance;
-	/* Not used. */
-	uint16_t	unused_1;
+	#define SQ_RDMA_TIMESTAMP_MASK UINT32_C(0xffffff)
+	#define SQ_RDMA_TIMESTAMP_SFT 0
 	/*
-	 * bit 0: live data
-	 * bit 1: crashed data
+	 * When inline=0, then this area is filled with from 1 to 6
+	 * SGEs based on the wqe_size field.
+	 *
+	 * When inline=1, this area is filled with payload data for the
+	 * write based on the length field. Bits [7:0] of word 0
+	 * hold the first byte to go out on the wire.
 	 */
-	uint8_t	seg_flags;
-	uint8_t	unused_2;
-	uint16_t	unused_3;
-	/* Not used. */
-	uint32_t	unused_4;
-	/* Sequence number is used per segment request. Starts at 0. */
-	uint32_t	seq_no;
-	uint32_t	unused_5;
-} hwrm_dbg_coredump_retrieve_input_t, *phwrm_dbg_coredump_retrieve_input_t;
+	uint32_t	data[24];
+} sq_rdma_t, *psq_rdma_t;
 
-/* hwrm_dbg_coredump_retrieve_output (size:128b/16B) */
+/* RDMA SQ WQE header. */
+/* sq_rdma_hdr (size:256b/32B) */
 
-typedef struct hwrm_dbg_coredump_retrieve_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	flags;
+typedef struct sq_rdma_hdr {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
 	/*
-	 * Value of 1 means that there is more data available.
-	 * Issue the request again with the next sequence number.
+	 * RDMA Write.
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	#define HWRM_DBG_COREDUMP_RETRIEVE_OUTPUT_FLAGS_MORE	UINT32_C(0x1)
-	uint8_t	unused_0;
-	/* Actual length of data returned in bytes. */
-	uint16_t	data_len;
-	uint8_t	unused_1[3];
+	#define SQ_RDMA_HDR_WQE_TYPE_WRITE_WQE	UINT32_C(0x4)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * RDMA Write with Immediate.
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint8_t	valid;
-} hwrm_dbg_coredump_retrieve_output_t, *phwrm_dbg_coredump_retrieve_output_t;
-
-/*******************
- * hwrm_dbg_fw_cli *
- *******************/
-
-
-/* hwrm_dbg_fw_cli_input (size:1024b/128B) */
-
-typedef struct hwrm_dbg_fw_cli_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define SQ_RDMA_HDR_WQE_TYPE_WRITE_W_IMMEAD UINT32_C(0x5)
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * RDMA Read.
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint16_t	cmpl_ring;
+	#define SQ_RDMA_HDR_WQE_TYPE_READ_WQE	UINT32_C(0x6)
+	#define SQ_RDMA_HDR_WQE_TYPE_LAST	SQ_RDMA_HDR_WQE_TYPE_READ_WQE
+	uint8_t	flags;
+	#define SQ_RDMA_HDR_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_MASK		UINT32_C(0xff)
+	#define SQ_RDMA_HDR_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_SFT			0
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Set if completion signaling is requested. If this bit is
+	 * 0, and the SQ is configured to support Unsignaled
+	 * completion the controller should not generate a CQE
+	 * unless there was an error. This refers to CQE on the
+	 * sender side (se_flag refers to the receiver side)
 	 */
-	uint16_t	seq_id;
+	#define SQ_RDMA_HDR_FLAGS_SIGNAL_COMP								UINT32_C(0x1)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Indication to complete all previous RDMA Read or Atomic
+	 * WQEs on the SQ before executing this WQE
 	 */
-	uint16_t	target_id;
+	#define SQ_RDMA_HDR_FLAGS_RD_OR_ATOMIC_FENCE							UINT32_C(0x2)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Unconditional fence. Indication to complete all previous
+	 * SQ's WQEs before executing this WQE.
 	 */
-	uint64_t	resp_addr;
+	#define SQ_RDMA_HDR_FLAGS_UC_FENCE								UINT32_C(0x4)
 	/*
-	 * Address of the host buffer where debug CLI data
-	 * is requested to be dumped.
+	 * Solicit event. Indication sent in BTH header to the
+	 * receiver to generate a Completion Event Notification,
+	 * i.e. CNQE. This bit should be set only in the last (or
+	 * only) packet of the message.
 	 */
-	uint64_t	host_dest_addr;
-	/* Length of host buffer used for transferring debug data. */
-	uint32_t	host_buf_len;
-	/* Length of CLI command. */
-	uint16_t	cli_cmd_len;
-	uint8_t	unused_0[2];
-	/* CLI command string, a single ASCII encoded null terminated string. */
-	uint8_t	cli_cmd[96];
-} hwrm_dbg_fw_cli_input_t, *phwrm_dbg_fw_cli_input_t;
-
-/* hwrm_dbg_fw_cli_output (size:128b/16B) */
-
-typedef struct hwrm_dbg_fw_cli_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Size of debug CLI data returned in bytes. */
-	uint32_t	cli_data_len;
-	uint8_t	unused_0[3];
+	#define SQ_RDMA_HDR_FLAGS_SE									UINT32_C(0x8)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * Indicate that inline data is posted to the SQ following
+	 * this WQE. This bit may be 1 only for write operations.
 	 */
-	uint8_t	valid;
-} hwrm_dbg_fw_cli_output_t, *phwrm_dbg_fw_cli_output_t;
-
-/**************************
- * hwrm_dbg_ring_info_get *
- **************************/
-
-
-/* hwrm_dbg_ring_info_get_input (size:192b/24B) */
-
-typedef struct hwrm_dbg_ring_info_get_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define SQ_RDMA_HDR_FLAGS_INLINE								UINT32_C(0x10)
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * If set to 1, then the timestamp from the WQE is used. If
+	 * cleared to 0, then TWE provides the timestamp.
 	 */
-	uint16_t	cmpl_ring;
+	#define SQ_RDMA_HDR_FLAGS_WQE_TS_EN								UINT32_C(0x20)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * When set to '1', this operation will cause a trace capture in
+	 * each block it passes through.
 	 */
-	uint16_t	seq_id;
+	#define SQ_RDMA_HDR_FLAGS_DEBUG_TRACE								UINT32_C(0x40)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * The number of 16 bytes chunks of data including this first
+	 * wqe of the request that are a valid part of the request. The
+	 * valid 16 bytes units other than the WQE structure can be
+	 * SGEs (Scatter Gather Elements) OR inline data.
+	 *
+	 * While this field defines the valid WQE size. The actual
+	 * total WQE size is always 128B.
 	 */
-	uint16_t	target_id;
+	uint8_t	wqe_size;
+	uint8_t	reserved8;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Immediate data - valid for RDMA Write with immediate and
+	 * causes the controller to add immDt header with this value
 	 */
-	uint64_t	resp_addr;
-	/* Ring Type. */
-	uint8_t	ring_type;
-	/* L2 Completion Ring (CR) */
-	#define HWRM_DBG_RING_INFO_GET_INPUT_RING_TYPE_L2_CMPL UINT32_C(0x0)
-	/* TX Ring (TR) */
-	#define HWRM_DBG_RING_INFO_GET_INPUT_RING_TYPE_TX	UINT32_C(0x1)
-	/* RX Ring (RR) */
-	#define HWRM_DBG_RING_INFO_GET_INPUT_RING_TYPE_RX	UINT32_C(0x2)
-	/* Notification Queue (NQ) */
-	#define HWRM_DBG_RING_INFO_GET_INPUT_RING_TYPE_NQ	UINT32_C(0x3)
-	#define HWRM_DBG_RING_INFO_GET_INPUT_RING_TYPE_LAST   HWRM_DBG_RING_INFO_GET_INPUT_RING_TYPE_NQ
-	uint8_t	unused_0[3];
-	/* Firmware ring ID associated with ring being queried. */
-	uint32_t	fw_ring_id;
-} hwrm_dbg_ring_info_get_input_t, *phwrm_dbg_ring_info_get_input_t;
-
-/* hwrm_dbg_ring_info_get_output (size:192b/24B) */
-
-typedef struct hwrm_dbg_ring_info_get_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Producer index for the queried ring. */
-	uint32_t	producer_index;
-	/* Consumer index for the queried ring. */
-	uint32_t	consumer_index;
+	uint32_t	imm_data;
+	/* Total data length in bytes */
+	uint32_t	length;
+	uint32_t	reserved32_1;
+	/* Remote VA sent to the destination QP */
+	uint64_t	remote_va;
 	/*
-	 * CAG Vector Control for the queried NQ ring.
-	 * Not valid for other ring types.
+	 * R_Key provided by remote node when the connection was
+	 * established and placed in the RETH header. It identify the
+	 * MRW on the remote host
 	 */
-	uint32_t	cag_vector_ctrl;
-	uint8_t	unused_0[3];
+	uint32_t	remote_key;
+	uint32_t	timestamp;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * This field specifies a 24-bit timestamp that can be passed
+	 * down the TX path and optionally logged in the TXP timestamp
+	 * histogram.
 	 */
-	uint8_t	valid;
-} hwrm_dbg_ring_info_get_output_t, *phwrm_dbg_ring_info_get_output_t;
-
-/**********************
- * hwrm_dbg_drv_trace *
- **********************/
-
+	#define SQ_RDMA_HDR_TIMESTAMP_MASK UINT32_C(0xffffff)
+	#define SQ_RDMA_HDR_TIMESTAMP_SFT 0
+} sq_rdma_hdr_t, *psq_rdma_hdr_t;
 
-/* hwrm_dbg_drv_trace_input (size:1024b/128B) */
+/* Atomic SQ WQE */
+/* sq_atomic (size:1024b/128B) */
 
-typedef struct hwrm_dbg_drv_trace_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+typedef struct sq_atomic {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * Atomic Compare/Swap.
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint16_t	cmpl_ring;
+	#define SQ_ATOMIC_WQE_TYPE_ATOMIC_CS UINT32_C(0x8)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Atomic Fetch/Add.
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint16_t	seq_id;
+	#define SQ_ATOMIC_WQE_TYPE_ATOMIC_FA UINT32_C(0xb)
+	#define SQ_ATOMIC_WQE_TYPE_LAST	SQ_ATOMIC_WQE_TYPE_ATOMIC_FA
+	uint8_t	flags;
+	#define SQ_ATOMIC_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_MASK		UINT32_C(0xff)
+	#define SQ_ATOMIC_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_SFT			0
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Set if completion signaling is requested. If this bit is
+	 * 0, and the SQ is configured to support Unsignaled
+	 * completion the controller should not generate a CQE
+	 * unless there was an error. This refers to CQE on the
+	 * sender side (se_flag refers to the receiver side)
 	 */
-	uint16_t	target_id;
+	#define SQ_ATOMIC_FLAGS_SIGNAL_COMP								UINT32_C(0x1)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Indication to complete all previous RDMA Read or Atomic
+	 * WQEs on the SQ before executing this WQE
 	 */
-	uint64_t	resp_addr;
-	/* Severity of the messege. */
-	uint8_t	severity;
-	/* Fatal */
-	#define HWRM_DBG_DRV_TRACE_INPUT_SEVERITY_TRACE_LEVEL_FATAL   UINT32_C(0x0)
-	/* Error */
-	#define HWRM_DBG_DRV_TRACE_INPUT_SEVERITY_TRACE_LEVEL_ERROR   UINT32_C(0x1)
-	/* Warning */
-	#define HWRM_DBG_DRV_TRACE_INPUT_SEVERITY_TRACE_LEVEL_WARNING UINT32_C(0x2)
-	/* Info */
-	#define HWRM_DBG_DRV_TRACE_INPUT_SEVERITY_TRACE_LEVEL_INFO	UINT32_C(0x3)
-	/* Debug */
-	#define HWRM_DBG_DRV_TRACE_INPUT_SEVERITY_TRACE_LEVEL_DEBUG   UINT32_C(0x4)
-	#define HWRM_DBG_DRV_TRACE_INPUT_SEVERITY_LAST		HWRM_DBG_DRV_TRACE_INPUT_SEVERITY_TRACE_LEVEL_DEBUG
-	/* Number of bytes to write including terminating 'NULL' if any. */
-	uint8_t	write_len;
-	uint8_t	unused_0[6];
+	#define SQ_ATOMIC_FLAGS_RD_OR_ATOMIC_FENCE							UINT32_C(0x2)
 	/*
-	 * This field reprsents the debug data sent by driver
-	 * ASCII chars, 'NULL' termination not required.
+	 * Unconditional fence. Indication to complete all previous
+	 * SQ's WQEs before executing this WQE.
 	 */
-	char	trace_data[104];
-} hwrm_dbg_drv_trace_input_t, *phwrm_dbg_drv_trace_input_t;
-
-/* hwrm_dbg_drv_trace_output (size:128b/16B) */
-
-typedef struct hwrm_dbg_drv_trace_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	#define SQ_ATOMIC_FLAGS_UC_FENCE								UINT32_C(0x4)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * Solicit event. Indication sent in BTH header to the
+	 * receiver to generate a Completion Event Notification,
+	 * i.e. CNQE. This bit should be set only in the last (or
+	 * only) packet of the message.
 	 */
-	uint8_t	valid;
-} hwrm_dbg_drv_trace_output_t, *phwrm_dbg_drv_trace_output_t;
-
-/***********************
- * hwrm_dbg_useq_alloc *
- ***********************/
-
-
-/* hwrm_dbg_useq_alloc_input (size:192b/24B) */
-
-typedef struct hwrm_dbg_useq_alloc_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define SQ_ATOMIC_FLAGS_SE									UINT32_C(0x8)
+	/* NA for this WQE */
+	#define SQ_ATOMIC_FLAGS_INLINE								UINT32_C(0x10)
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * The atomic WQE does not have a timestamp field, so this field is
+	 * ignored and should be zero.
 	 */
-	uint16_t	cmpl_ring;
+	#define SQ_ATOMIC_FLAGS_WQE_TS_EN								UINT32_C(0x20)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * When set to '1', this operation will cause a trace capture in
+	 * each block it passes through.
 	 */
-	uint16_t	seq_id;
+	#define SQ_ATOMIC_FLAGS_DEBUG_TRACE								UINT32_C(0x40)
+	uint16_t	reserved16;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * R_Key provided by remote node when the connection was
+	 * established and placed in the AETH header. It identify the
+	 * MRW on the remote host
 	 */
-	uint16_t	target_id;
+	uint32_t	remote_key;
+	/* Remote VA sent to the destination QP */
+	uint64_t	remote_va;
+	/* Data value to be placed in remote host specified address */
+	uint64_t	swap_data;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Data value to be compared with the value in the remote host
+	 * specified address
 	 */
-	uint64_t	resp_addr;
-	/* Number size of the allocation, in bytes, for the USEQ in the code words array */
-	uint32_t	size;
-	/* Number of bytes executing the USEQ will produce.  Must be a multiple of 4 */
-	uint16_t	output_bytes;
-	/* This field is reserved */
-	uint16_t	unused_0;
-} hwrm_dbg_useq_alloc_input_t, *phwrm_dbg_useq_alloc_input_t;
-
-/* hwrm_dbg_useq_alloc_output (size:256b/32B) */
-
-typedef struct hwrm_dbg_useq_alloc_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Non-zero firmware timestamp */
-	uint32_t	nz_fw_timestamp;
-	/* The last selected USID */
-	uint16_t	last_usid;
-	/* The number of USEQs currently allocated */
-	uint16_t	num_useq_allocd;
-	/* A non-zero value indicates data is available for delivery */
-	uint8_t	avail;
-	/* Current count of the number of full buffers available for delivery */
-	uint8_t	full_cnt;
-	/* Reserved */
-	uint16_t	durh_unused_0;
-	/* A non-zero value indicates that all internal buffers are full */
-	uint8_t	overflow;
-	/* Reserved */
-	uint8_t	durh_unused_1[3];
-	/* This field is reserved */
-	uint32_t	unused_0;
+	uint64_t	cmp_data;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * The first 16B of the data field must be filled with a single
+	 * SGE. This will be used to store the return value from the
+	 * Atomic Ack response. The size of the single SGE must be 8B.
 	 */
-	uint32_t	valid;
-} hwrm_dbg_useq_alloc_output_t, *phwrm_dbg_useq_alloc_output_t;
-
-/**********************
- * hwrm_dbg_useq_free *
- **********************/
-
+	uint32_t	data[24];
+} sq_atomic_t, *psq_atomic_t;
 
-/* hwrm_dbg_useq_free_input (size:192b/24B) */
+/* Atomic SQ WQE header. */
+/* sq_atomic_hdr (size:256b/32B) */
 
-typedef struct hwrm_dbg_useq_free_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+typedef struct sq_atomic_hdr {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * Atomic Compare/Swap.
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint16_t	cmpl_ring;
+	#define SQ_ATOMIC_HDR_WQE_TYPE_ATOMIC_CS UINT32_C(0x8)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Atomic Fetch/Add.
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint16_t	seq_id;
+	#define SQ_ATOMIC_HDR_WQE_TYPE_ATOMIC_FA UINT32_C(0xb)
+	#define SQ_ATOMIC_HDR_WQE_TYPE_LAST	SQ_ATOMIC_HDR_WQE_TYPE_ATOMIC_FA
+	uint8_t	flags;
+	#define SQ_ATOMIC_HDR_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_MASK		UINT32_C(0xff)
+	#define SQ_ATOMIC_HDR_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_SFT			0
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Set if completion signaling is requested. If this bit is
+	 * 0, and the SQ is configured to support Unsignaled
+	 * completion the controller should not generate a CQE
+	 * unless there was an error. This refers to CQE on the
+	 * sender side (se_flag refers to the receiver side)
 	 */
-	uint16_t	target_id;
+	#define SQ_ATOMIC_HDR_FLAGS_SIGNAL_COMP								UINT32_C(0x1)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Indication to complete all previous RDMA Read or Atomic
+	 * WQEs on the SQ before executing this WQE
 	 */
-	uint64_t	resp_addr;
-	/* The USID of the sequence to free */
-	uint16_t	usid;
-	/* This field is reserved */
-	uint8_t	unused_0[6];
-} hwrm_dbg_useq_free_input_t, *phwrm_dbg_useq_free_input_t;
-
-/* hwrm_dbg_useq_free_output (size:256b/32B) */
-
-typedef struct hwrm_dbg_useq_free_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Non-zero firmware timestamp */
-	uint32_t	nz_fw_timestamp;
-	/* The last selected USID */
-	uint16_t	last_usid;
-	/* The number of USEQs currently allocated */
-	uint16_t	num_useq_allocd;
-	/* A non-zero value indicates data is available for delivery */
-	uint8_t	avail;
-	/* Current count of the number of full buffers available for delivery */
-	uint8_t	full_cnt;
-	/* Reserved */
-	uint16_t	durh_unused_0;
-	/* A non-zero value indicates that all internal buffers are full */
-	uint8_t	overflow;
-	/* Reserved */
-	uint8_t	durh_unused_1[3];
-	/* This field is reserved */
-	uint32_t	unused_0;
+	#define SQ_ATOMIC_HDR_FLAGS_RD_OR_ATOMIC_FENCE							UINT32_C(0x2)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * Unconditional fence. Indication to complete all previous
+	 * SQ's WQEs before executing this WQE.
 	 */
-	uint32_t	valid;
-} hwrm_dbg_useq_free_output_t, *phwrm_dbg_useq_free_output_t;
-
-/***********************
- * hwrm_dbg_useq_flush *
- ***********************/
-
-
-/* hwrm_dbg_useq_flush_input (size:192b/24B) */
-
-typedef struct hwrm_dbg_useq_flush_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define SQ_ATOMIC_HDR_FLAGS_UC_FENCE								UINT32_C(0x4)
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * Solicit event. Indication sent in BTH header to the
+	 * receiver to generate a Completion Event Notification,
+	 * i.e. CNQE. This bit should be set only in the last (or
+	 * only) packet of the message.
 	 */
-	uint16_t	cmpl_ring;
+	#define SQ_ATOMIC_HDR_FLAGS_SE									UINT32_C(0x8)
+	/* NA for this WQE */
+	#define SQ_ATOMIC_HDR_FLAGS_INLINE								UINT32_C(0x10)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * The atomic WQE does not have a timestamp field, so this field is
+	 * ignored and should be zero.
 	 */
-	uint16_t	seq_id;
+	#define SQ_ATOMIC_HDR_FLAGS_WQE_TS_EN								UINT32_C(0x20)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * When set to '1', this operation will cause a trace capture in
+	 * each block it passes through.
 	 */
-	uint16_t	target_id;
+	#define SQ_ATOMIC_HDR_FLAGS_DEBUG_TRACE								UINT32_C(0x40)
+	uint16_t	reserved16;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * R_Key provided by remote node when the connection was
+	 * established and placed in the AETH header. It identify the
+	 * MRW on the remote host
 	 */
-	uint64_t	resp_addr;
-	/* Bitwise flags described below */
-	uint16_t	flags;
-	/* Flush all USEQ code words, resetting all USIDs to invalid */
-	#define HWRM_DBG_USEQ_FLUSH_INPUT_USEQ_CODE_WORDS UINT32_C(0x1)
-	/* Initialize all buffers, clearing out any collected data */
-	#define HWRM_DBG_USEQ_FLUSH_INPUT_BUFFERS	UINT32_C(0x2)
-	#define HWRM_DBG_USEQ_FLUSH_INPUT_LAST	HWRM_DBG_USEQ_FLUSH_INPUT_BUFFERS
-	/* This field is reserved */
-	uint8_t	unused_0[6];
-} hwrm_dbg_useq_flush_input_t, *phwrm_dbg_useq_flush_input_t;
-
-/* hwrm_dbg_useq_flush_output (size:256b/32B) */
-
-typedef struct hwrm_dbg_useq_flush_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Non-zero firmware timestamp */
-	uint32_t	nz_fw_timestamp;
-	/* The last selected USID */
-	uint16_t	last_usid;
-	/* The number of USEQs currently allocated */
-	uint16_t	num_useq_allocd;
-	/* A non-zero value indicates data is available for delivery */
-	uint8_t	avail;
-	/* Current count of the number of full buffers available for delivery */
-	uint8_t	full_cnt;
-	/* Reserved */
-	uint16_t	durh_unused_0;
-	/* A non-zero value indicates that all internal buffers are full */
-	uint8_t	overflow;
-	/* Reserved */
-	uint8_t	durh_unused_1[3];
-	/* This field is reserved */
-	uint32_t	unused_0;
+	uint32_t	remote_key;
+	/* Remote VA sent to the destination QP */
+	uint64_t	remote_va;
+	/* Data value to be placed in remote host specified address */
+	uint64_t	swap_data;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * Data value to be compared with the value in the remote host
+	 * specified address
 	 */
-	uint32_t	valid;
-} hwrm_dbg_useq_flush_output_t, *phwrm_dbg_useq_flush_output_t;
-
-/***********************
- * hwrm_dbg_useq_qcaps *
- ***********************/
-
+	uint64_t	cmp_data;
+} sq_atomic_hdr_t, *psq_atomic_hdr_t;
 
-/* hwrm_dbg_useq_qcaps_input (size:128b/16B) */
+/* Local Invalidate SQ WQE */
+/* sq_localinvalidate (size:1024b/128B) */
 
-typedef struct hwrm_dbg_useq_qcaps_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+typedef struct sq_localinvalidate {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * Local Invalidate.
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint16_t	cmpl_ring;
+	#define SQ_LOCALINVALIDATE_WQE_TYPE_LOCAL_INVALID UINT32_C(0xc)
+	#define SQ_LOCALINVALIDATE_WQE_TYPE_LAST	SQ_LOCALINVALIDATE_WQE_TYPE_LOCAL_INVALID
+	uint8_t	flags;
+	#define SQ_LOCALINVALIDATE_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_MASK		UINT32_C(0xff)
+	#define SQ_LOCALINVALIDATE_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_SFT			0
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Set if completion signaling is requested. If this bit is
+	 * 0, and the SQ is configured to support Unsignaled
+	 * completion the controller should not generate a CQE
+	 * unless there was an error. This refers to CQE on the
+	 * sender side (se_flag refers to the receiver side)
 	 */
-	uint16_t	seq_id;
+	#define SQ_LOCALINVALIDATE_FLAGS_SIGNAL_COMP								UINT32_C(0x1)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Indication to complete all previous RDMA Read or Atomic
+	 * WQEs on the SQ before executing this WQE
 	 */
-	uint16_t	target_id;
+	#define SQ_LOCALINVALIDATE_FLAGS_RD_OR_ATOMIC_FENCE							UINT32_C(0x2)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Unconditional fence. Indication to complete all previous
+	 * SQ's WQEs before executing this WQE.
 	 */
-	uint64_t	resp_addr;
-} hwrm_dbg_useq_qcaps_input_t, *phwrm_dbg_useq_qcaps_input_t;
-
-/* hwrm_dbg_useq_qcaps_output (size:384b/48B) */
-
-typedef struct hwrm_dbg_useq_qcaps_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Non-zero firmware timestamp */
-	uint32_t	nz_fw_timestamp;
-	/* The last selected USID */
-	uint16_t	last_usid;
-	/* The number of USEQs currently allocated */
-	uint16_t	num_useq_allocd;
-	/* A non-zero value indicates data is available for delivery */
-	uint8_t	avail;
-	/* Current count of the number of full buffers available for delivery */
-	uint8_t	full_cnt;
-	/* Reserved */
-	uint16_t	durh_unused_0;
-	/* A non-zero value indicates that all internal buffers are full */
-	uint8_t	overflow;
-	/* Reserved */
-	uint8_t	durh_unused_1[3];
-	/* Maximum number of USEQ that can be tracked by firmware */
-	uint32_t	max_num_useq;
-	/* Maximum number of code words for a single USEQ */
-	uint32_t	max_useq_len;
-	/* The maximum number of 32-bit words a single USEQ may generate */
-	uint32_t	max_useq_32b_output_words;
-	/* The number of internal USEQ output buffers, each of 4096 bytes */
-	uint32_t	num_buf;
-	/* This field is reserved */
-	uint32_t	unused_0;
+	#define SQ_LOCALINVALIDATE_FLAGS_UC_FENCE								UINT32_C(0x4)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * Solicit event. Indication sent in BTH header to the
+	 * receiver to generate a Completion Event Notification,
+	 * i.e. CNQE. This bit should be set only in the last (or
+	 * only) packet of the message.
 	 */
-	uint32_t	valid;
-} hwrm_dbg_useq_qcaps_output_t, *phwrm_dbg_useq_qcaps_output_t;
-
-/***************************
- * hwrm_dbg_useq_sched_cfg *
- ***************************/
-
+	#define SQ_LOCALINVALIDATE_FLAGS_SE									UINT32_C(0x8)
+	/* NA for this WQE */
+	#define SQ_LOCALINVALIDATE_FLAGS_INLINE								UINT32_C(0x10)
+	/*
+	 * This flag is not applicable and should be 0 for a local memory
+	 * operation WQE.
+	 */
+	#define SQ_LOCALINVALIDATE_FLAGS_WQE_TS_EN								UINT32_C(0x20)
+	/*
+	 * When set to '1', this operation will cause a trace capture in
+	 * each block it passes through.
+	 */
+	#define SQ_LOCALINVALIDATE_FLAGS_DEBUG_TRACE								UINT32_C(0x40)
+	uint16_t	reserved16;
+	/*
+	 * The local key for the MR/W to invalidate; 24 msb of the key
+	 * are used to index the MRW table, 8 lsb are compared with the
+	 * 8 bit key in the MRWC
+	 */
+	uint32_t	inv_l_key;
+	uint64_t	reserved64;
+	uint8_t	reserved128[16];
+	/* The data field for local invalidate is not used. */
+	uint32_t	data[24];
+} sq_localinvalidate_t, *psq_localinvalidate_t;
 
-/* hwrm_dbg_useq_sched_cfg_input (size:192b/24B) */
+/* Local Invalidate SQ WQE header. */
+/* sq_localinvalidate_hdr (size:256b/32B) */
 
-typedef struct hwrm_dbg_useq_sched_cfg_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+typedef struct sq_localinvalidate_hdr {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * Local Invalidate.
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint16_t	cmpl_ring;
+	#define SQ_LOCALINVALIDATE_HDR_WQE_TYPE_LOCAL_INVALID UINT32_C(0xc)
+	#define SQ_LOCALINVALIDATE_HDR_WQE_TYPE_LAST	SQ_LOCALINVALIDATE_HDR_WQE_TYPE_LOCAL_INVALID
+	uint8_t	flags;
+	#define SQ_LOCALINVALIDATE_HDR_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_MASK		UINT32_C(0xff)
+	#define SQ_LOCALINVALIDATE_HDR_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_SFT			0
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Set if completion signaling is requested. If this bit is
+	 * 0, and the SQ is configured to support Unsignaled
+	 * completion the controller should not generate a CQE
+	 * unless there was an error. This refers to CQE on the
+	 * sender side (se_flag refers to the receiver side)
 	 */
-	uint16_t	seq_id;
+	#define SQ_LOCALINVALIDATE_HDR_FLAGS_SIGNAL_COMP								UINT32_C(0x1)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Indication to complete all previous RDMA Read or Atomic
+	 * WQEs on the SQ before executing this WQE
 	 */
-	uint16_t	target_id;
+	#define SQ_LOCALINVALIDATE_HDR_FLAGS_RD_OR_ATOMIC_FENCE							UINT32_C(0x2)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Unconditional fence. Indication to complete all previous
+	 * SQ's WQEs before executing this WQE.
 	 */
-	uint64_t	resp_addr;
-	/* Enumeration values for enabling, disabling scheduler */
-	uint16_t	global_cfg;
-	/* This value will leave the global scheduler in its current state */
-	#define HWRM_DBG_USEQ_SCHED_CFG_INPUT_NO_CHANGE UINT32_C(0x0)
+	#define SQ_LOCALINVALIDATE_HDR_FLAGS_UC_FENCE								UINT32_C(0x4)
 	/*
-	 * This value disables the global scheduler.  This mode must be used
-	 * when the RUN command is being used to run individual sequences.
+	 * Solicit event. Indication sent in BTH header to the
+	 * receiver to generate a Completion Event Notification,
+	 * i.e. CNQE. This bit should be set only in the last (or
+	 * only) packet of the message.
 	 */
-	#define HWRM_DBG_USEQ_SCHED_CFG_INPUT_DISABLE   UINT32_C(0x1)
+	#define SQ_LOCALINVALIDATE_HDR_FLAGS_SE									UINT32_C(0x8)
+	/* NA for this WQE */
+	#define SQ_LOCALINVALIDATE_HDR_FLAGS_INLINE								UINT32_C(0x10)
 	/*
-	 * This value enables the global scheduler.  When enabled, USEQs will
-	 * be scheduled based on their polling intervals
+	 * This flag is not applicable and should be 0 for a local memory
+	 * operation WQE.
 	 */
-	#define HWRM_DBG_USEQ_SCHED_CFG_INPUT_ENABLE	UINT32_C(0x2)
-	#define HWRM_DBG_USEQ_SCHED_CFG_INPUT_LAST	HWRM_DBG_USEQ_SCHED_CFG_INPUT_ENABLE
+	#define SQ_LOCALINVALIDATE_HDR_FLAGS_WQE_TS_EN								UINT32_C(0x20)
 	/*
-	 * The given polling interval will be associated with this USID.  A value
-	 * of -1 indicates that the USID is invalid.  The invalid USID is used when
-	 * using this message only for global scheduler configuration.
+	 * When set to '1', this operation will cause a trace capture in
+	 * each block it passes through.
 	 */
-	uint16_t	usid;
-	/* This value represents microseconds between runs of the USEQ */
-	uint32_t	polling_interval;
-} hwrm_dbg_useq_sched_cfg_input_t, *phwrm_dbg_useq_sched_cfg_input_t;
-
-/* hwrm_dbg_useq_sched_cfg_output (size:256b/32B) */
-
-typedef struct hwrm_dbg_useq_sched_cfg_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Non-zero firmware timestamp */
-	uint32_t	nz_fw_timestamp;
-	/* The last selected USID */
-	uint16_t	last_usid;
-	/* The number of USEQs currently allocated */
-	uint16_t	num_useq_allocd;
-	/* A non-zero value indicates data is available for delivery */
-	uint8_t	avail;
-	/* Current count of the number of full buffers available for delivery */
-	uint8_t	full_cnt;
-	/* Reserved */
-	uint16_t	durh_unused_0;
-	/* A non-zero value indicates that all internal buffers are full */
-	uint8_t	overflow;
-	/* Reserved */
-	uint8_t	durh_unused_1[3];
-	/* This field is reserved */
-	uint32_t	unused_0;
+	#define SQ_LOCALINVALIDATE_HDR_FLAGS_DEBUG_TRACE								UINT32_C(0x40)
+	uint16_t	reserved16;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * The local key for the MR/W to invalidate; 24 msb of the key
+	 * are used to index the MRW table, 8 lsb are compared with the
+	 * 8 bit key in the MRWC
 	 */
-	uint32_t	valid;
-} hwrm_dbg_useq_sched_cfg_output_t, *phwrm_dbg_useq_sched_cfg_output_t;
-
-/*********************
- * hwrm_dbg_useq_run *
- *********************/
-
+	uint32_t	inv_l_key;
+	uint64_t	reserved64;
+	uint8_t	reserved128[16];
+} sq_localinvalidate_hdr_t, *psq_localinvalidate_hdr_t;
 
-/* hwrm_dbg_useq_run_input (size:320b/40B) */
+/* FR-PMR SQ WQE */
+/* sq_fr_pmr (size:1024b/128B) */
 
-typedef struct hwrm_dbg_useq_run_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+typedef struct sq_fr_pmr {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * FR-PMR (Fast Register Physical Memory Region)
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint16_t	cmpl_ring;
+	#define SQ_FR_PMR_WQE_TYPE_FR_PMR UINT32_C(0xd)
+	#define SQ_FR_PMR_WQE_TYPE_LAST  SQ_FR_PMR_WQE_TYPE_FR_PMR
+	uint8_t	flags;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Set if completion signaling is requested. If this bit is
+	 * 0, and the SQ is configured to support Unsignaled
+	 * completion the controller should not generate a CQE
+	 * unless there was an error. This refers to CQE on the
+	 * sender side (se_flag refers to the receiver side)
 	 */
-	uint16_t	seq_id;
+	#define SQ_FR_PMR_FLAGS_SIGNAL_COMP		UINT32_C(0x1)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Indication to complete all previous RDMA Read or Atomic
+	 * WQEs on the SQ before executing this WQE
 	 */
-	uint16_t	target_id;
+	#define SQ_FR_PMR_FLAGS_RD_OR_ATOMIC_FENCE	UINT32_C(0x2)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Unconditional fence. Indication to complete all previous
+	 * SQ's WQEs before executing this WQE.
 	 */
-	uint64_t	resp_addr;
-	/* The USID to be run */
-	uint16_t	usid;
-	/* Type of run to execute for the given USID */
-	uint8_t	run_type;
-	/* This run type will execute the requested USEQ only a single time */
-	#define HWRM_DBG_USEQ_RUN_INPUT_RUN_TYPE_SINGLE   UINT32_C(0x0)
+	#define SQ_FR_PMR_FLAGS_UC_FENCE		UINT32_C(0x4)
+	/* Not Applicable for FR_PMR. Nothing is sent */
+	#define SQ_FR_PMR_FLAGS_SE			UINT32_C(0x8)
+	/* NA */
+	#define SQ_FR_PMR_FLAGS_INLINE		UINT32_C(0x10)
 	/*
-	 * This run type will execute the requested USEQ a number of times given
-	 * by run_cnt with a run interval given by the run_interval parameter.
+	 * This flag is not applicable and should be 0 for a local memory
+	 * operation WQE.
 	 */
-	#define HWRM_DBG_USEQ_RUN_INPUT_RUN_TYPE_CNT	UINT32_C(0x1)
+	#define SQ_FR_PMR_FLAGS_WQE_TS_EN		UINT32_C(0x20)
 	/*
-	 * This run type will execute the requested USEQ as many times as it needs
-	 * to fill an entire buffer to return to the host.  The runs will occur
-	 * with a run interval given by the run_interval parameter.
+	 * When set to '1', this operation will cause a trace capture in
+	 * each block it passes through.
 	 */
-	#define HWRM_DBG_USEQ_RUN_INPUT_RUN_TYPE_FILL_BUF UINT32_C(0x2)
-	#define HWRM_DBG_USEQ_RUN_INPUT_RUN_TYPE_LAST	HWRM_DBG_USEQ_RUN_INPUT_RUN_TYPE_FILL_BUF
+	#define SQ_FR_PMR_FLAGS_DEBUG_TRACE		UINT32_C(0x40)
 	/*
-	 * If indicated by flags, this represents the number of times to run the USEQ.
-	 * Note that runs are stopped if the buffer fills prior regardless of the
-	 * number of runs.  For example, if a run_cnt of 10 is specified and 3 runs
-	 * results in the buffer being full then only 3 runs are executed.
+	 * This is the new access control for the MR. '1' means
+	 * the operation is allowed. '0' means operation is
+	 * not allowed.
 	 */
-	uint8_t	run_cnt;
+	uint8_t	access_cntl;
+	/* Local Write Access */
+	#define SQ_FR_PMR_ACCESS_CNTL_LOCAL_WRITE	UINT32_C(0x1)
+	/* Remote Read Access */
+	#define SQ_FR_PMR_ACCESS_CNTL_REMOTE_READ	UINT32_C(0x2)
+	/* Remote Write Access */
+	#define SQ_FR_PMR_ACCESS_CNTL_REMOTE_WRITE	UINT32_C(0x4)
+	/* Remote Atomic Access */
+	#define SQ_FR_PMR_ACCESS_CNTL_REMOTE_ATOMIC	UINT32_C(0x8)
+	/* Window Binding Allowed */
+	#define SQ_FR_PMR_ACCESS_CNTL_WINDOW_BIND	UINT32_C(0x10)
+	uint8_t	zero_based_page_size_log;
+	/* Page size. 0 for 4KB page size, ... to 8TB. */
+	#define SQ_FR_PMR_PAGE_SIZE_LOG_MASK	UINT32_C(0x1f)
+	#define SQ_FR_PMR_PAGE_SIZE_LOG_SFT	0
+	/* Page size is 4KB. */
+		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_4K	UINT32_C(0x0)
+	/* Page size is 8KB. */
+		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_8K	UINT32_C(0x1)
+	/* Page size is 16KB. */
+		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_16K   UINT32_C(0x2)
+	/* Page size is 32KB. */
+		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_32K   UINT32_C(0x3)
+	/* Page size is 64KB. */
+		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_64K   UINT32_C(0x4)
+	/* Page size is 128KB. */
+		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_128K  UINT32_C(0x5)
+	/* Page size is 256KB. */
+		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_256K  UINT32_C(0x6)
+	/* Page size is 512KB. */
+		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_512K  UINT32_C(0x7)
+	/* Page size is 1MB. */
+		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_1M	UINT32_C(0x8)
+	/* Page size is 2MB. */
+		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_2M	UINT32_C(0x9)
+	/* Page size is 4MB. */
+		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_4M	UINT32_C(0xa)
+	/* Page size is 8MB. */
+		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_8M	UINT32_C(0xb)
+	/* Page size is 16MB. */
+		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_16M   UINT32_C(0xc)
+	/* Page size is 32MB. */
+		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_32M   UINT32_C(0xd)
+	/* Page size is 64MB. */
+		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_64M   UINT32_C(0xe)
+	/* Page size is 128MB. */
+		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_128M  UINT32_C(0xf)
+	/* Page size is 256MB. */
+		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_256M  UINT32_C(0x10)
+	/* Page size is 512MB. */
+		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_512M  UINT32_C(0x11)
+	/* Page size is 1GB. */
+		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_1G	UINT32_C(0x12)
+	/* Page size is 2GB. */
+		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_2G	UINT32_C(0x13)
+	/* Page size is 4GB. */
+		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_4G	UINT32_C(0x14)
+	/* Page size is 8GB. */
+		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_8G	UINT32_C(0x15)
+	/* Page size is 16GB. */
+		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_16G   UINT32_C(0x16)
+	/* Page size is 32GB. */
+		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_32G   UINT32_C(0x17)
+	/* Page size is 64GB. */
+		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_64G   UINT32_C(0x18)
+	/* Page size is 128GB. */
+		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_128G  UINT32_C(0x19)
+	/* Page size is 256GB. */
+		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_256G  UINT32_C(0x1a)
+	/* Page size is 512GB. */
+		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_512G  UINT32_C(0x1b)
+	/* Page size is 1TB. */
+		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_1T	UINT32_C(0x1c)
+	/* Page size is 2TB. */
+		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_2T	UINT32_C(0x1d)
+	/* Page size is 4TB. */
+		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_4T	UINT32_C(0x1e)
+	/* Page size is 8TB. */
+		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_8T	UINT32_C(0x1f)
+		#define SQ_FR_PMR_PAGE_SIZE_LOG_LAST	SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_8T
+	/* Indicate the MR is ZBVA (Zero Base VA) */
+	#define SQ_FR_PMR_ZERO_BASED		UINT32_C(0x20)
 	/*
-	 * This value represents microseconds between runs of the USEQ when running
-	 * multiple times as indicated by flags.
+	 * Local Key; 24 msb of the key are used to index the MRW
+	 * table, 8 lsb are assigned to the 8 bit key_lsb field in
+	 * the MRWC.
 	 */
-	uint32_t	run_interval;
-	/* Address of the host buffer where collected USEQ output data will be placed */
-	uint64_t	host_dest_addr;
+	uint32_t	l_key;
+	/* Length in bytes of registered MR */
+	uint8_t	length[5];
+	uint8_t	reserved8_1;
+	uint8_t	reserved8_2;
+	uint8_t	numlevels_pbl_page_size_log;
+	/* PBL page size. 0 for 4KB page size, ... to 8TB. */
+	#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_MASK	UINT32_C(0x1f)
+	#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_SFT	0
+	/* Page size is 4KB. */
+		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_4K	UINT32_C(0x0)
+	/* Page size is 8KB. */
+		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_8K	UINT32_C(0x1)
+	/* Page size is 16KB. */
+		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_16K   UINT32_C(0x2)
+	/* Page size is 32KB. */
+		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_32K   UINT32_C(0x3)
+	/* Page size is 64KB. */
+		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_64K   UINT32_C(0x4)
+	/* Page size is 128KB. */
+		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_128K  UINT32_C(0x5)
+	/* Page size is 256KB. */
+		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_256K  UINT32_C(0x6)
+	/* Page size is 512KB. */
+		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_512K  UINT32_C(0x7)
+	/* Page size is 1MB. */
+		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_1M	UINT32_C(0x8)
+	/* Page size is 2MB. */
+		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_2M	UINT32_C(0x9)
+	/* Page size is 4MB. */
+		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_4M	UINT32_C(0xa)
+	/* Page size is 8MB. */
+		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_8M	UINT32_C(0xb)
+	/* Page size is 16MB. */
+		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_16M   UINT32_C(0xc)
+	/* Page size is 32MB. */
+		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_32M   UINT32_C(0xd)
+	/* Page size is 64MB. */
+		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_64M   UINT32_C(0xe)
+	/* Page size is 128MB. */
+		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_128M  UINT32_C(0xf)
+	/* Page size is 256MB. */
+		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_256M  UINT32_C(0x10)
+	/* Page size is 512MB. */
+		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_512M  UINT32_C(0x11)
+	/* Page size is 1GB. */
+		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_1G	UINT32_C(0x12)
+	/* Page size is 2GB. */
+		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_2G	UINT32_C(0x13)
+	/* Page size is 4GB. */
+		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_4G	UINT32_C(0x14)
+	/* Page size is 8GB. */
+		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_8G	UINT32_C(0x15)
+	/* Page size is 16GB. */
+		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_16G   UINT32_C(0x16)
+	/* Page size is 32GB. */
+		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_32G   UINT32_C(0x17)
+	/* Page size is 64GB. */
+		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_64G   UINT32_C(0x18)
+	/* Page size is 128GB. */
+		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_128G  UINT32_C(0x19)
+	/* Page size is 256GB. */
+		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_256G  UINT32_C(0x1a)
+	/* Page size is 512GB. */
+		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_512G  UINT32_C(0x1b)
+	/* Page size is 1TB. */
+		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_1T	UINT32_C(0x1c)
+	/* Page size is 2TB. */
+		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_2T	UINT32_C(0x1d)
+	/* Page size is 4TB. */
+		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_4T	UINT32_C(0x1e)
+	/* Page size is 8TB. */
+		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_8T	UINT32_C(0x1f)
+		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_LAST	SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_8T
+	/* Number of levels of PBL for translation */
+	#define SQ_FR_PMR_NUMLEVELS_MASK		UINT32_C(0xc0)
+	#define SQ_FR_PMR_NUMLEVELS_SFT		6
 	/*
-	 * Size, in bytes, of the memory associated with host_dest_addr.  It is expected
-	 * that this is >= 4096
+	 * A zero level PBL means that the VA is the physical address used
+	 * for the operation. No translation is done by the PTU.
 	 */
-	uint32_t	host_dest_len;
-	/* This field is reserved */
-	uint32_t	unused_0;
-} hwrm_dbg_useq_run_input_t, *phwrm_dbg_useq_run_input_t;
-
-/* hwrm_dbg_useq_run_output (size:256b/32B) */
-
-typedef struct hwrm_dbg_useq_run_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Non-zero firmware timestamp */
-	uint32_t	nz_fw_timestamp;
-	/* The last selected USID */
-	uint16_t	last_usid;
-	/* The number of USEQs currently allocated */
-	uint16_t	num_useq_allocd;
-	/* A non-zero value indicates data is available for delivery */
-	uint8_t	avail;
-	/* Current count of the number of full buffers available for delivery */
-	uint8_t	full_cnt;
-	/* Reserved */
-	uint16_t	durh_unused_0;
-	/* A non-zero value indicates that all internal buffers are full */
-	uint8_t	overflow;
-	/* Reserved */
-	uint8_t	durh_unused_1[3];
+		#define SQ_FR_PMR_NUMLEVELS_PHYSICAL	(UINT32_C(0x0) << 6)
 	/*
-	 * The length, in bytes, of the amount of data placed in the corresponding
-	 * host_dest_addr given in the input message.  This will always be a multiple
-	 * of 4096
+	 * A one layer translation is provided between the logical and
+	 * physical address. The PBL points to a physical page that
+	 * contains PBE values that point to actual pg_size physical pages.
 	 */
-	uint32_t	host_dest_filled_len;
+		#define SQ_FR_PMR_NUMLEVELS_LAYER1		(UINT32_C(0x1) << 6)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * A two layer translation is provided between the logical and
+	 * physical address. The PBL points to a physical page that
+	 * contains PDE values that in turn point to pbl_pg_size physical
+	 * pages that contain PBE values that point to actual physical
+	 * pages.
 	 */
-	uint32_t	valid;
-} hwrm_dbg_useq_run_output_t, *phwrm_dbg_useq_run_output_t;
-
-/******************************
- * hwrm_dbg_useq_delivery_req *
- ******************************/
-
+		#define SQ_FR_PMR_NUMLEVELS_LAYER2		(UINT32_C(0x2) << 6)
+		#define SQ_FR_PMR_NUMLEVELS_LAST		SQ_FR_PMR_NUMLEVELS_LAYER2
+	/* Pointer to the PBL, or PDL depending on number of levels */
+	uint64_t	pblptr;
+	/* Local Virtual Address */
+	uint64_t	va;
+	/* The data field for FR-PMR is not used. */
+	uint32_t	data[24];
+} sq_fr_pmr_t, *psq_fr_pmr_t;
 
-/* hwrm_dbg_useq_delivery_req_input (size:896b/112B) */
+/* FR-PMR SQ WQE header. */
+/* sq_fr_pmr_hdr (size:256b/32B) */
 
-typedef struct hwrm_dbg_useq_delivery_req_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+typedef struct sq_fr_pmr_hdr {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * FR-PMR (Fast Register Physical Memory Region)
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint16_t	cmpl_ring;
+	#define SQ_FR_PMR_HDR_WQE_TYPE_FR_PMR UINT32_C(0xd)
+	#define SQ_FR_PMR_HDR_WQE_TYPE_LAST  SQ_FR_PMR_HDR_WQE_TYPE_FR_PMR
+	uint8_t	flags;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Set if completion signaling is requested. If this bit is
+	 * 0, and the SQ is configured to support Unsignaled
+	 * completion the controller should not generate a CQE
+	 * unless there was an error. This refers to CQE on the
+	 * sender side (se_flag refers to the receiver side)
 	 */
-	uint16_t	seq_id;
+	#define SQ_FR_PMR_HDR_FLAGS_SIGNAL_COMP		UINT32_C(0x1)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Indication to complete all previous RDMA Read or Atomic
+	 * WQEs on the SQ before executing this WQE
 	 */
-	uint16_t	target_id;
+	#define SQ_FR_PMR_HDR_FLAGS_RD_OR_ATOMIC_FENCE	UINT32_C(0x2)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Unconditional fence. Indication to complete all previous
+	 * SQ's WQEs before executing this WQE.
 	 */
-	uint64_t	resp_addr;
+	#define SQ_FR_PMR_HDR_FLAGS_UC_FENCE		UINT32_C(0x4)
+	/* Not Applicable for FR_PMR. Nothing is sent */
+	#define SQ_FR_PMR_HDR_FLAGS_SE			UINT32_C(0x8)
+	/* NA */
+	#define SQ_FR_PMR_HDR_FLAGS_INLINE		UINT32_C(0x10)
+	/*
+	 * This flag is not applicable and should be 0 for a local memory
+	 * operation WQE.
+	 */
+	#define SQ_FR_PMR_HDR_FLAGS_WQE_TS_EN		UINT32_C(0x20)
+	/*
+	 * When set to '1', this operation will cause a trace capture in
+	 * each block it passes through.
+	 */
+	#define SQ_FR_PMR_HDR_FLAGS_DEBUG_TRACE		UINT32_C(0x40)
+	/*
+	 * This is the new access control for the MR. '1' means
+	 * the operation is allowed. '0' means operation is
+	 * not allowed.
+	 */
+	uint8_t	access_cntl;
+	/* Local Write Access */
+	#define SQ_FR_PMR_HDR_ACCESS_CNTL_LOCAL_WRITE	UINT32_C(0x1)
+	/* Remote Read Access */
+	#define SQ_FR_PMR_HDR_ACCESS_CNTL_REMOTE_READ	UINT32_C(0x2)
+	/* Remote Write Access */
+	#define SQ_FR_PMR_HDR_ACCESS_CNTL_REMOTE_WRITE	UINT32_C(0x4)
+	/* Remote Atomic Access */
+	#define SQ_FR_PMR_HDR_ACCESS_CNTL_REMOTE_ATOMIC	UINT32_C(0x8)
+	/* Window Binding Allowed */
+	#define SQ_FR_PMR_HDR_ACCESS_CNTL_WINDOW_BIND	UINT32_C(0x10)
+	uint8_t	zero_based_page_size_log;
+	/* Page size. 0 for 4KB page size, ... to 8TB. */
+	#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_MASK	UINT32_C(0x1f)
+	#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_SFT	0
+	/* Page size is 4KB. */
+		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_4K	UINT32_C(0x0)
+	/* Page size is 8KB. */
+		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_8K	UINT32_C(0x1)
+	/* Page size is 16KB. */
+		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_16K   UINT32_C(0x2)
+	/* Page size is 32KB. */
+		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_32K   UINT32_C(0x3)
+	/* Page size is 64KB. */
+		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_64K   UINT32_C(0x4)
+	/* Page size is 128KB. */
+		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_128K  UINT32_C(0x5)
+	/* Page size is 256KB. */
+		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_256K  UINT32_C(0x6)
+	/* Page size is 512KB. */
+		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_512K  UINT32_C(0x7)
+	/* Page size is 1MB. */
+		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_1M	UINT32_C(0x8)
+	/* Page size is 2MB. */
+		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_2M	UINT32_C(0x9)
+	/* Page size is 4MB. */
+		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_4M	UINT32_C(0xa)
+	/* Page size is 8MB. */
+		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_8M	UINT32_C(0xb)
+	/* Page size is 16MB. */
+		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_16M   UINT32_C(0xc)
+	/* Page size is 32MB. */
+		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_32M   UINT32_C(0xd)
+	/* Page size is 64MB. */
+		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_64M   UINT32_C(0xe)
+	/* Page size is 128MB. */
+		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_128M  UINT32_C(0xf)
+	/* Page size is 256MB. */
+		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_256M  UINT32_C(0x10)
+	/* Page size is 512MB. */
+		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_512M  UINT32_C(0x11)
+	/* Page size is 1GB. */
+		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_1G	UINT32_C(0x12)
+	/* Page size is 2GB. */
+		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_2G	UINT32_C(0x13)
+	/* Page size is 4GB. */
+		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_4G	UINT32_C(0x14)
+	/* Page size is 8GB. */
+		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_8G	UINT32_C(0x15)
+	/* Page size is 16GB. */
+		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_16G   UINT32_C(0x16)
+	/* Page size is 32GB. */
+		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_32G   UINT32_C(0x17)
+	/* Page size is 64GB. */
+		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_64G   UINT32_C(0x18)
+	/* Page size is 128GB. */
+		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_128G  UINT32_C(0x19)
+	/* Page size is 256GB. */
+		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_256G  UINT32_C(0x1a)
+	/* Page size is 512GB. */
+		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_512G  UINT32_C(0x1b)
+	/* Page size is 1TB. */
+		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_1T	UINT32_C(0x1c)
+	/* Page size is 2TB. */
+		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_2T	UINT32_C(0x1d)
+	/* Page size is 4TB. */
+		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_4T	UINT32_C(0x1e)
+	/* Page size is 8TB. */
+		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_8T	UINT32_C(0x1f)
+		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_LAST	SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_8T
+	/* Indicate the MR is ZBVA (Zero Base VA) */
+	#define SQ_FR_PMR_HDR_ZERO_BASED		UINT32_C(0x20)
 	/*
-	 * Eight destination addresses provide host memory space for FW to deliver
-	 * USEQ output details.  A value of 0x0 for the address can be used to
-	 * inform FW that the buffer is not available.
+	 * Local Key; 24 msb of the key are used to index the MRW
+	 * table, 8 lsb are assigned to the 8 bit key_lsb field in
+	 * the MRWC.
 	 */
-	uint64_t	host_dest_addrs[8];
+	uint32_t	l_key;
+	/* Length in bytes of registered MR */
+	uint8_t	length[5];
+	uint8_t	reserved8_1;
+	uint8_t	reserved8_2;
+	uint8_t	numlevels_pbl_page_size_log;
+	/* PBL page size. 0 for 4KB page size, ... to 8TB. */
+	#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_MASK	UINT32_C(0x1f)
+	#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_SFT	0
+	/* Page size is 4KB. */
+		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_4K	UINT32_C(0x0)
+	/* Page size is 8KB. */
+		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_8K	UINT32_C(0x1)
+	/* Page size is 16KB. */
+		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_16K   UINT32_C(0x2)
+	/* Page size is 32KB. */
+		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_32K   UINT32_C(0x3)
+	/* Page size is 64KB. */
+		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_64K   UINT32_C(0x4)
+	/* Page size is 128KB. */
+		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_128K  UINT32_C(0x5)
+	/* Page size is 256KB. */
+		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_256K  UINT32_C(0x6)
+	/* Page size is 512KB. */
+		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_512K  UINT32_C(0x7)
+	/* Page size is 1MB. */
+		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_1M	UINT32_C(0x8)
+	/* Page size is 2MB. */
+		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_2M	UINT32_C(0x9)
+	/* Page size is 4MB. */
+		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_4M	UINT32_C(0xa)
+	/* Page size is 8MB. */
+		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_8M	UINT32_C(0xb)
+	/* Page size is 16MB. */
+		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_16M   UINT32_C(0xc)
+	/* Page size is 32MB. */
+		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_32M   UINT32_C(0xd)
+	/* Page size is 64MB. */
+		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_64M   UINT32_C(0xe)
+	/* Page size is 128MB. */
+		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_128M  UINT32_C(0xf)
+	/* Page size is 256MB. */
+		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_256M  UINT32_C(0x10)
+	/* Page size is 512MB. */
+		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_512M  UINT32_C(0x11)
+	/* Page size is 1GB. */
+		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_1G	UINT32_C(0x12)
+	/* Page size is 2GB. */
+		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_2G	UINT32_C(0x13)
+	/* Page size is 4GB. */
+		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_4G	UINT32_C(0x14)
+	/* Page size is 8GB. */
+		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_8G	UINT32_C(0x15)
+	/* Page size is 16GB. */
+		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_16G   UINT32_C(0x16)
+	/* Page size is 32GB. */
+		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_32G   UINT32_C(0x17)
+	/* Page size is 64GB. */
+		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_64G   UINT32_C(0x18)
+	/* Page size is 128GB. */
+		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_128G  UINT32_C(0x19)
+	/* Page size is 256GB. */
+		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_256G  UINT32_C(0x1a)
+	/* Page size is 512GB. */
+		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_512G  UINT32_C(0x1b)
+	/* Page size is 1TB. */
+		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_1T	UINT32_C(0x1c)
+	/* Page size is 2TB. */
+		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_2T	UINT32_C(0x1d)
+	/* Page size is 4TB. */
+		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_4T	UINT32_C(0x1e)
+	/* Page size is 8TB. */
+		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_8T	UINT32_C(0x1f)
+		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_LAST	SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_8T
+	/* Number of levels of PBL for translation */
+	#define SQ_FR_PMR_HDR_NUMLEVELS_MASK		UINT32_C(0xc0)
+	#define SQ_FR_PMR_HDR_NUMLEVELS_SFT		6
 	/*
-	 * The length, in bytes, of the corresponding host_dest_addrs array entry.  Each
-	 * valid hist_dest_addrs entry must have a len of at least 4096 bytes
+	 * A zero level PBL means that the VA is the physical address used
+	 * for the operation. No translation is done by the PTU.
 	 */
-	uint32_t	host_dest_len[8];
-} hwrm_dbg_useq_delivery_req_input_t, *phwrm_dbg_useq_delivery_req_input_t;
-
-/* hwrm_dbg_useq_delivery_req_output (size:512b/64B) */
-
-typedef struct hwrm_dbg_useq_delivery_req_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Non-zero firmware timestamp */
-	uint32_t	nz_fw_timestamp;
-	/* The last selected USID */
-	uint16_t	last_usid;
-	/* The number of USEQs currently allocated */
-	uint16_t	num_useq_allocd;
-	/* A non-zero value indicates data is available for delivery */
-	uint8_t	avail;
-	/* Current count of the number of full buffers available for delivery */
-	uint8_t	full_cnt;
-	/* Reserved */
-	uint16_t	durh_unused_0;
-	/* A non-zero value indicates that all internal buffers are full */
-	uint8_t	overflow;
-	/* Reserved */
-	uint8_t	durh_unused_1[3];
+		#define SQ_FR_PMR_HDR_NUMLEVELS_PHYSICAL	(UINT32_C(0x0) << 6)
 	/*
-	 * The length, in bytes, of the amount of data placed in the corresponding
-	 * host_dest_addrs entry given in the input message.  This will always be a
-	 * multiple of 4096
+	 * A one layer translation is provided between the logical and
+	 * physical address. The PBL points to a physical page that
+	 * contains PBE values that point to actual pg_size physical pages.
 	 */
-	uint32_t	host_dest_filled_len[8];
-	/* This field is reserved */
-	uint32_t	unused_0;
+		#define SQ_FR_PMR_HDR_NUMLEVELS_LAYER1		(UINT32_C(0x1) << 6)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * A two layer translation is provided between the logical and
+	 * physical address. The PBL points to a physical page that
+	 * contains PDE values that in turn point to pbl_pg_size physical
+	 * pages that contain PBE values that point to actual physical
+	 * pages.
 	 */
-	uint32_t	valid;
-} hwrm_dbg_useq_delivery_req_output_t, *phwrm_dbg_useq_delivery_req_output_t;
-
-/**************************
- * hwrm_nvm_raw_write_blk *
- **************************/
-
+		#define SQ_FR_PMR_HDR_NUMLEVELS_LAYER2		(UINT32_C(0x2) << 6)
+		#define SQ_FR_PMR_HDR_NUMLEVELS_LAST		SQ_FR_PMR_HDR_NUMLEVELS_LAYER2
+	/* Pointer to the PBL, or PDL depending on number of levels */
+	uint64_t	pblptr;
+	/* Local Virtual Address */
+	uint64_t	va;
+} sq_fr_pmr_hdr_t, *psq_fr_pmr_hdr_t;
 
-/* hwrm_nvm_raw_write_blk_input (size:256b/32B) */
+/* FR-PPMR SQ WQE */
+/* sq_fr_ppmr (size:1024b/128B) */
 
-typedef struct hwrm_nvm_raw_write_blk_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
-	 */
-	uint16_t	cmpl_ring;
-	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
-	 */
-	uint16_t	seq_id;
+typedef struct sq_fr_ppmr {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * FR-PPMR (Fast Register Proxy Physical Memory Region)
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint16_t	target_id;
+	#define SQ_FR_PPMR_WQE_TYPE_FR_PPMR UINT32_C(0xf)
+	#define SQ_FR_PPMR_WQE_TYPE_LAST   SQ_FR_PPMR_WQE_TYPE_FR_PPMR
+	uint8_t	flags;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Set if completion signaling is requested. If this bit is
+	 * 0, and the SQ is configured to support Unsignaled
+	 * completion the controller should not generate a CQE
+	 * unless there was an error. This refers to CQE on the
+	 * sender side (se_flag refers to the receiver side)
 	 */
-	uint64_t	resp_addr;
+	#define SQ_FR_PPMR_FLAGS_SIGNAL_COMP		UINT32_C(0x1)
 	/*
-	 * 64-bit Host Source Address.
-	 * This is the location of the source data to be written.
+	 * Indication to complete all previous RDMA Read or Atomic
+	 * WQEs on the SQ before executing this WQE
 	 */
-	uint64_t	host_src_addr;
+	#define SQ_FR_PPMR_FLAGS_RD_OR_ATOMIC_FENCE	UINT32_C(0x2)
 	/*
-	 * 32-bit Destination Address.
-	 * This is the NVRAM byte-offset where the source data will be written to.
+	 * Unconditional fence. Indication to complete all previous
+	 * SQ's WQEs before executing this WQE.
 	 */
-	uint32_t	dest_addr;
-	/* Length of data to be written, in bytes. */
-	uint32_t	len;
-} hwrm_nvm_raw_write_blk_input_t, *phwrm_nvm_raw_write_blk_input_t;
-
-/* hwrm_nvm_raw_write_blk_output (size:128b/16B) */
-
-typedef struct hwrm_nvm_raw_write_blk_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	#define SQ_FR_PPMR_FLAGS_UC_FENCE		UINT32_C(0x4)
+	/* Not Applicable for FR_PPMR. Nothing is sent */
+	#define SQ_FR_PPMR_FLAGS_SE			UINT32_C(0x8)
+	/* NA */
+	#define SQ_FR_PPMR_FLAGS_INLINE		UINT32_C(0x10)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * This flag is not applicable and should be 0 for a local memory
+	 * operation WQE.
 	 */
-	uint8_t	valid;
-} hwrm_nvm_raw_write_blk_output_t, *phwrm_nvm_raw_write_blk_output_t;
-
-/*****************
- * hwrm_nvm_read *
- *****************/
-
-
-/* hwrm_nvm_read_input (size:320b/40B) */
-
-typedef struct hwrm_nvm_read_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define SQ_FR_PPMR_FLAGS_WQE_TS_EN		UINT32_C(0x20)
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * When set to '1', this operation will cause a trace capture in
+	 * each block it passes through.
 	 */
-	uint16_t	cmpl_ring;
+	#define SQ_FR_PPMR_FLAGS_DEBUG_TRACE		UINT32_C(0x40)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * This is the new access control for the MR. '1' means
+	 * the operation is allowed. '0' means operation is
+	 * not allowed.
 	 */
-	uint16_t	seq_id;
+	uint8_t	access_cntl;
+	/* Local Write Access */
+	#define SQ_FR_PPMR_ACCESS_CNTL_LOCAL_WRITE	UINT32_C(0x1)
+	/* Remote Read Access */
+	#define SQ_FR_PPMR_ACCESS_CNTL_REMOTE_READ	UINT32_C(0x2)
+	/* Remote Write Access */
+	#define SQ_FR_PPMR_ACCESS_CNTL_REMOTE_WRITE	UINT32_C(0x4)
+	/* Remote Atomic Access */
+	#define SQ_FR_PPMR_ACCESS_CNTL_REMOTE_ATOMIC	UINT32_C(0x8)
+	/* Window Binding Allowed */
+	#define SQ_FR_PPMR_ACCESS_CNTL_WINDOW_BIND	UINT32_C(0x10)
+	uint8_t	zero_based_page_size_log;
+	/* Page size. 0 for 4KB page size, ... to 8TB. */
+	#define SQ_FR_PPMR_PAGE_SIZE_LOG_MASK	UINT32_C(0x1f)
+	#define SQ_FR_PPMR_PAGE_SIZE_LOG_SFT	0
+	/* Page size is 4KB. */
+		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_4K	UINT32_C(0x0)
+	/* Page size is 8KB. */
+		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_8K	UINT32_C(0x1)
+	/* Page size is 16KB. */
+		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_16K   UINT32_C(0x2)
+	/* Page size is 32KB. */
+		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_32K   UINT32_C(0x3)
+	/* Page size is 64KB. */
+		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_64K   UINT32_C(0x4)
+	/* Page size is 128KB. */
+		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_128K  UINT32_C(0x5)
+	/* Page size is 256KB. */
+		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_256K  UINT32_C(0x6)
+	/* Page size is 512KB. */
+		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_512K  UINT32_C(0x7)
+	/* Page size is 1MB. */
+		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_1M	UINT32_C(0x8)
+	/* Page size is 2MB. */
+		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_2M	UINT32_C(0x9)
+	/* Page size is 4MB. */
+		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_4M	UINT32_C(0xa)
+	/* Page size is 8MB. */
+		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_8M	UINT32_C(0xb)
+	/* Page size is 16MB. */
+		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_16M   UINT32_C(0xc)
+	/* Page size is 32MB. */
+		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_32M   UINT32_C(0xd)
+	/* Page size is 64MB. */
+		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_64M   UINT32_C(0xe)
+	/* Page size is 128MB. */
+		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_128M  UINT32_C(0xf)
+	/* Page size is 256MB. */
+		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_256M  UINT32_C(0x10)
+	/* Page size is 512MB. */
+		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_512M  UINT32_C(0x11)
+	/* Page size is 1GB. */
+		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_1G	UINT32_C(0x12)
+	/* Page size is 2GB. */
+		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_2G	UINT32_C(0x13)
+	/* Page size is 4GB. */
+		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_4G	UINT32_C(0x14)
+	/* Page size is 8GB. */
+		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_8G	UINT32_C(0x15)
+	/* Page size is 16GB. */
+		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_16G   UINT32_C(0x16)
+	/* Page size is 32GB. */
+		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_32G   UINT32_C(0x17)
+	/* Page size is 64GB. */
+		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_64G   UINT32_C(0x18)
+	/* Page size is 128GB. */
+		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_128G  UINT32_C(0x19)
+	/* Page size is 256GB. */
+		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_256G  UINT32_C(0x1a)
+	/* Page size is 512GB. */
+		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_512G  UINT32_C(0x1b)
+	/* Page size is 1TB. */
+		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_1T	UINT32_C(0x1c)
+	/* Page size is 2TB. */
+		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_2T	UINT32_C(0x1d)
+	/* Page size is 4TB. */
+		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_4T	UINT32_C(0x1e)
+	/* Page size is 8TB. */
+		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_8T	UINT32_C(0x1f)
+		#define SQ_FR_PPMR_PAGE_SIZE_LOG_LAST	SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_8T
+	/* Indicate the MR is ZBVA (Zero Base VA) */
+	#define SQ_FR_PPMR_ZERO_BASED		UINT32_C(0x20)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Local Key; 24 msb of the key are used to index the MRW
+	 * table, 8 lsb are assigned to the 8 bit key_lsb field in
+	 * the MRWC.
 	 */
-	uint16_t	target_id;
+	uint32_t	l_key;
+	/* Length in bytes of registered MR */
+	uint32_t	length;
+	/* Sets the proxy_vfid field of the physical memory region. */
+	uint16_t	proxy_vfid;
+	/* Sets the proxy_pfid field of the physical memory region. */
+	uint8_t	proxy_pfid;
+	uint8_t	numlevels_pbl_page_size_log;
+	/* PBL page size. 0 for 4KB page size, ... to 8TB. */
+	#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_MASK	UINT32_C(0x1f)
+	#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_SFT	0
+	/* Page size is 4KB. */
+		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_4K	UINT32_C(0x0)
+	/* Page size is 8KB. */
+		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_8K	UINT32_C(0x1)
+	/* Page size is 16KB. */
+		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_16K   UINT32_C(0x2)
+	/* Page size is 32KB. */
+		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_32K   UINT32_C(0x3)
+	/* Page size is 64KB. */
+		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_64K   UINT32_C(0x4)
+	/* Page size is 128KB. */
+		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_128K  UINT32_C(0x5)
+	/* Page size is 256KB. */
+		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_256K  UINT32_C(0x6)
+	/* Page size is 512KB. */
+		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_512K  UINT32_C(0x7)
+	/* Page size is 1MB. */
+		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_1M	UINT32_C(0x8)
+	/* Page size is 2MB. */
+		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_2M	UINT32_C(0x9)
+	/* Page size is 4MB. */
+		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_4M	UINT32_C(0xa)
+	/* Page size is 8MB. */
+		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_8M	UINT32_C(0xb)
+	/* Page size is 16MB. */
+		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_16M   UINT32_C(0xc)
+	/* Page size is 32MB. */
+		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_32M   UINT32_C(0xd)
+	/* Page size is 64MB. */
+		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_64M   UINT32_C(0xe)
+	/* Page size is 128MB. */
+		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_128M  UINT32_C(0xf)
+	/* Page size is 256MB. */
+		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_256M  UINT32_C(0x10)
+	/* Page size is 512MB. */
+		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_512M  UINT32_C(0x11)
+	/* Page size is 1GB. */
+		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_1G	UINT32_C(0x12)
+	/* Page size is 2GB. */
+		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_2G	UINT32_C(0x13)
+	/* Page size is 4GB. */
+		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_4G	UINT32_C(0x14)
+	/* Page size is 8GB. */
+		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_8G	UINT32_C(0x15)
+	/* Page size is 16GB. */
+		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_16G   UINT32_C(0x16)
+	/* Page size is 32GB. */
+		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_32G   UINT32_C(0x17)
+	/* Page size is 64GB. */
+		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_64G   UINT32_C(0x18)
+	/* Page size is 128GB. */
+		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_128G  UINT32_C(0x19)
+	/* Page size is 256GB. */
+		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_256G  UINT32_C(0x1a)
+	/* Page size is 512GB. */
+		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_512G  UINT32_C(0x1b)
+	/* Page size is 1TB. */
+		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_1T	UINT32_C(0x1c)
+	/* Page size is 2TB. */
+		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_2T	UINT32_C(0x1d)
+	/* Page size is 4TB. */
+		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_4T	UINT32_C(0x1e)
+	/* Page size is 8TB. */
+		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_8T	UINT32_C(0x1f)
+		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_LAST	SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_8T
+	/* Sets the proxy_vf_valid field of the physical memory region. */
+	#define SQ_FR_PPMR_PROXY_VF_VALID		UINT32_C(0x20)
+	/* Number of levels of PBL for translation */
+	#define SQ_FR_PPMR_NUMLEVELS_MASK		UINT32_C(0xc0)
+	#define SQ_FR_PPMR_NUMLEVELS_SFT		6
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * A zero level PBL means that the VA is the physical address used
+	 * for the operation. No translation is done by the PTU.
 	 */
-	uint64_t	resp_addr;
+		#define SQ_FR_PPMR_NUMLEVELS_PHYSICAL	(UINT32_C(0x0) << 6)
 	/*
-	 * 64-bit Host Destination Address.
-	 * This is the host address where the data will be written to.
+	 * A one layer translation is provided between the logical and
+	 * physical address. The PBL points to a physical page that
+	 * contains PBE values that point to actual pg_size physical pages.
 	 */
-	uint64_t	host_dest_addr;
-	/* The 0-based index of the directory entry. */
-	uint16_t	dir_idx;
-	uint8_t	unused_0[2];
-	/* The NVRAM byte-offset to read from. */
-	uint32_t	offset;
-	/* The length of the data to be read, in bytes. */
-	uint32_t	len;
-	uint8_t	unused_1[4];
-} hwrm_nvm_read_input_t, *phwrm_nvm_read_input_t;
-
-/* hwrm_nvm_read_output (size:128b/16B) */
-
-typedef struct hwrm_nvm_read_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+		#define SQ_FR_PPMR_NUMLEVELS_LAYER1		(UINT32_C(0x1) << 6)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * A two layer translation is provided between the logical and
+	 * physical address. The PBL points to a physical page that
+	 * contains PDE values that in turn point to pbl_pg_size physical
+	 * pages that contain PBE values that point to actual physical
+	 * pages.
 	 */
-	uint8_t	valid;
-} hwrm_nvm_read_output_t, *phwrm_nvm_read_output_t;
-
-/*********************
- * hwrm_nvm_raw_dump *
- *********************/
-
+		#define SQ_FR_PPMR_NUMLEVELS_LAYER2		(UINT32_C(0x2) << 6)
+		#define SQ_FR_PPMR_NUMLEVELS_LAST		SQ_FR_PPMR_NUMLEVELS_LAYER2
+	/* Pointer to the PBL, or PDL depending on number of levels */
+	uint64_t	pblptr;
+	/* Local Virtual Address */
+	uint64_t	va;
+	/* The data field for FR-PPMR is not used. */
+	uint32_t	data[24];
+} sq_fr_ppmr_t, *psq_fr_ppmr_t;
 
-/* hwrm_nvm_raw_dump_input (size:256b/32B) */
+/* FR-PPMR SQ WQE header. */
+/* sq_fr_ppmr_hdr (size:256b/32B) */
 
-typedef struct hwrm_nvm_raw_dump_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+typedef struct sq_fr_ppmr_hdr {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * FR-PPMR (Fast Register Proxy Physical Memory Region)
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint16_t	cmpl_ring;
+	#define SQ_FR_PPMR_HDR_WQE_TYPE_FR_PPMR UINT32_C(0xf)
+	#define SQ_FR_PPMR_HDR_WQE_TYPE_LAST   SQ_FR_PPMR_HDR_WQE_TYPE_FR_PPMR
+	uint8_t	flags;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Set if completion signaling is requested. If this bit is
+	 * 0, and the SQ is configured to support Unsignaled
+	 * completion the controller should not generate a CQE
+	 * unless there was an error. This refers to CQE on the
+	 * sender side (se_flag refers to the receiver side)
 	 */
-	uint16_t	seq_id;
+	#define SQ_FR_PPMR_HDR_FLAGS_SIGNAL_COMP		UINT32_C(0x1)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Indication to complete all previous RDMA Read or Atomic
+	 * WQEs on the SQ before executing this WQE
 	 */
-	uint16_t	target_id;
+	#define SQ_FR_PPMR_HDR_FLAGS_RD_OR_ATOMIC_FENCE	UINT32_C(0x2)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Unconditional fence. Indication to complete all previous
+	 * SQ's WQEs before executing this WQE.
 	 */
-	uint64_t	resp_addr;
+	#define SQ_FR_PPMR_HDR_FLAGS_UC_FENCE		UINT32_C(0x4)
+	/* Not Applicable for FR_PPMR. Nothing is sent */
+	#define SQ_FR_PPMR_HDR_FLAGS_SE			UINT32_C(0x8)
+	/* NA */
+	#define SQ_FR_PPMR_HDR_FLAGS_INLINE		UINT32_C(0x10)
 	/*
-	 * 64-bit Host Destination Address.
-	 * This is the host address where the data will be written to.
+	 * This flag is not applicable and should be 0 for a local memory
+	 * operation WQE.
 	 */
-	uint64_t	host_dest_addr;
-	/* 32-bit NVRAM byte-offset to read from. */
-	uint32_t	offset;
-	/* Total length of NVRAM contents to be read, in bytes. */
-	uint32_t	len;
-} hwrm_nvm_raw_dump_input_t, *phwrm_nvm_raw_dump_input_t;
-
-/* hwrm_nvm_raw_dump_output (size:128b/16B) */
-
-typedef struct hwrm_nvm_raw_dump_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	#define SQ_FR_PPMR_HDR_FLAGS_WQE_TS_EN		UINT32_C(0x20)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When set to '1', this operation will cause a trace capture in
+	 * each block it passes through.
 	 */
-	uint8_t	valid;
-} hwrm_nvm_raw_dump_output_t, *phwrm_nvm_raw_dump_output_t;
-
-/****************************
- * hwrm_nvm_get_dir_entries *
- ****************************/
-
-
-/* hwrm_nvm_get_dir_entries_input (size:192b/24B) */
-
-typedef struct hwrm_nvm_get_dir_entries_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define SQ_FR_PPMR_HDR_FLAGS_DEBUG_TRACE		UINT32_C(0x40)
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * This is the new access control for the MR. '1' means
+	 * the operation is allowed. '0' means operation is
+	 * not allowed.
 	 */
-	uint16_t	cmpl_ring;
+	uint8_t	access_cntl;
+	/* Local Write Access */
+	#define SQ_FR_PPMR_HDR_ACCESS_CNTL_LOCAL_WRITE	UINT32_C(0x1)
+	/* Remote Read Access */
+	#define SQ_FR_PPMR_HDR_ACCESS_CNTL_REMOTE_READ	UINT32_C(0x2)
+	/* Remote Write Access */
+	#define SQ_FR_PPMR_HDR_ACCESS_CNTL_REMOTE_WRITE	UINT32_C(0x4)
+	/* Remote Atomic Access */
+	#define SQ_FR_PPMR_HDR_ACCESS_CNTL_REMOTE_ATOMIC	UINT32_C(0x8)
+	/* Window Binding Allowed */
+	#define SQ_FR_PPMR_HDR_ACCESS_CNTL_WINDOW_BIND	UINT32_C(0x10)
+	uint8_t	zero_based_page_size_log;
+	/* Page size. 0 for 4KB page size, ... to 8TB. */
+	#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_MASK	UINT32_C(0x1f)
+	#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_SFT	0
+	/* Page size is 4KB. */
+		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_4K	UINT32_C(0x0)
+	/* Page size is 8KB. */
+		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_8K	UINT32_C(0x1)
+	/* Page size is 16KB. */
+		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_16K   UINT32_C(0x2)
+	/* Page size is 32KB. */
+		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_32K   UINT32_C(0x3)
+	/* Page size is 64KB. */
+		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_64K   UINT32_C(0x4)
+	/* Page size is 128KB. */
+		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_128K  UINT32_C(0x5)
+	/* Page size is 256KB. */
+		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_256K  UINT32_C(0x6)
+	/* Page size is 512KB. */
+		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_512K  UINT32_C(0x7)
+	/* Page size is 1MB. */
+		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_1M	UINT32_C(0x8)
+	/* Page size is 2MB. */
+		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_2M	UINT32_C(0x9)
+	/* Page size is 4MB. */
+		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_4M	UINT32_C(0xa)
+	/* Page size is 8MB. */
+		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_8M	UINT32_C(0xb)
+	/* Page size is 16MB. */
+		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_16M   UINT32_C(0xc)
+	/* Page size is 32MB. */
+		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_32M   UINT32_C(0xd)
+	/* Page size is 64MB. */
+		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_64M   UINT32_C(0xe)
+	/* Page size is 128MB. */
+		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_128M  UINT32_C(0xf)
+	/* Page size is 256MB. */
+		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_256M  UINT32_C(0x10)
+	/* Page size is 512MB. */
+		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_512M  UINT32_C(0x11)
+	/* Page size is 1GB. */
+		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_1G	UINT32_C(0x12)
+	/* Page size is 2GB. */
+		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_2G	UINT32_C(0x13)
+	/* Page size is 4GB. */
+		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_4G	UINT32_C(0x14)
+	/* Page size is 8GB. */
+		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_8G	UINT32_C(0x15)
+	/* Page size is 16GB. */
+		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_16G   UINT32_C(0x16)
+	/* Page size is 32GB. */
+		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_32G   UINT32_C(0x17)
+	/* Page size is 64GB. */
+		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_64G   UINT32_C(0x18)
+	/* Page size is 128GB. */
+		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_128G  UINT32_C(0x19)
+	/* Page size is 256GB. */
+		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_256G  UINT32_C(0x1a)
+	/* Page size is 512GB. */
+		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_512G  UINT32_C(0x1b)
+	/* Page size is 1TB. */
+		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_1T	UINT32_C(0x1c)
+	/* Page size is 2TB. */
+		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_2T	UINT32_C(0x1d)
+	/* Page size is 4TB. */
+		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_4T	UINT32_C(0x1e)
+	/* Page size is 8TB. */
+		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_8T	UINT32_C(0x1f)
+		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_LAST	SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_8T
+	/* Indicate the MR is ZBVA (Zero Base VA) */
+	#define SQ_FR_PPMR_HDR_ZERO_BASED		UINT32_C(0x20)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Local Key; 24 msb of the key are used to index the MRW
+	 * table, 8 lsb are assigned to the 8 bit key_lsb field in
+	 * the MRWC.
 	 */
-	uint16_t	seq_id;
+	uint32_t	l_key;
+	/* Length in bytes of registered MR */
+	uint32_t	length;
+	/* Sets the proxy_vfid field of the physical memory region. */
+	uint16_t	proxy_vfid;
+	/* Sets the proxy_pfid field of the physical memory region. */
+	uint8_t	proxy_pfid;
+	uint8_t	numlevels_pbl_page_size_log;
+	/* PBL page size. 0 for 4KB page size, ... to 8TB. */
+	#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_MASK	UINT32_C(0x1f)
+	#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_SFT	0
+	/* Page size is 4KB. */
+		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_4K	UINT32_C(0x0)
+	/* Page size is 8KB. */
+		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_8K	UINT32_C(0x1)
+	/* Page size is 16KB. */
+		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_16K   UINT32_C(0x2)
+	/* Page size is 32KB. */
+		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_32K   UINT32_C(0x3)
+	/* Page size is 64KB. */
+		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_64K   UINT32_C(0x4)
+	/* Page size is 128KB. */
+		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_128K  UINT32_C(0x5)
+	/* Page size is 256KB. */
+		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_256K  UINT32_C(0x6)
+	/* Page size is 512KB. */
+		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_512K  UINT32_C(0x7)
+	/* Page size is 1MB. */
+		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_1M	UINT32_C(0x8)
+	/* Page size is 2MB. */
+		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_2M	UINT32_C(0x9)
+	/* Page size is 4MB. */
+		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_4M	UINT32_C(0xa)
+	/* Page size is 8MB. */
+		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_8M	UINT32_C(0xb)
+	/* Page size is 16MB. */
+		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_16M   UINT32_C(0xc)
+	/* Page size is 32MB. */
+		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_32M   UINT32_C(0xd)
+	/* Page size is 64MB. */
+		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_64M   UINT32_C(0xe)
+	/* Page size is 128MB. */
+		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_128M  UINT32_C(0xf)
+	/* Page size is 256MB. */
+		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_256M  UINT32_C(0x10)
+	/* Page size is 512MB. */
+		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_512M  UINT32_C(0x11)
+	/* Page size is 1GB. */
+		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_1G	UINT32_C(0x12)
+	/* Page size is 2GB. */
+		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_2G	UINT32_C(0x13)
+	/* Page size is 4GB. */
+		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_4G	UINT32_C(0x14)
+	/* Page size is 8GB. */
+		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_8G	UINT32_C(0x15)
+	/* Page size is 16GB. */
+		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_16G   UINT32_C(0x16)
+	/* Page size is 32GB. */
+		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_32G   UINT32_C(0x17)
+	/* Page size is 64GB. */
+		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_64G   UINT32_C(0x18)
+	/* Page size is 128GB. */
+		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_128G  UINT32_C(0x19)
+	/* Page size is 256GB. */
+		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_256G  UINT32_C(0x1a)
+	/* Page size is 512GB. */
+		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_512G  UINT32_C(0x1b)
+	/* Page size is 1TB. */
+		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_1T	UINT32_C(0x1c)
+	/* Page size is 2TB. */
+		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_2T	UINT32_C(0x1d)
+	/* Page size is 4TB. */
+		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_4T	UINT32_C(0x1e)
+	/* Page size is 8TB. */
+		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_8T	UINT32_C(0x1f)
+		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_LAST	SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_8T
+	/* Sets the proxy_vf_valid field of the physical memory region. */
+	#define SQ_FR_PPMR_HDR_PROXY_VF_VALID		UINT32_C(0x20)
+	/* Number of levels of PBL for translation */
+	#define SQ_FR_PPMR_HDR_NUMLEVELS_MASK		UINT32_C(0xc0)
+	#define SQ_FR_PPMR_HDR_NUMLEVELS_SFT		6
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * A zero level PBL means that the VA is the physical address used
+	 * for the operation. No translation is done by the PTU.
 	 */
-	uint16_t	target_id;
+		#define SQ_FR_PPMR_HDR_NUMLEVELS_PHYSICAL	(UINT32_C(0x0) << 6)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * A one layer translation is provided between the logical and
+	 * physical address. The PBL points to a physical page that
+	 * contains PBE values that point to actual pg_size physical pages.
 	 */
-	uint64_t	resp_addr;
+		#define SQ_FR_PPMR_HDR_NUMLEVELS_LAYER1		(UINT32_C(0x1) << 6)
 	/*
-	 * 64-bit Host Destination Address.
-	 * This is the host address where the directory will be written.
+	 * A two layer translation is provided between the logical and
+	 * physical address. The PBL points to a physical page that
+	 * contains PDE values that in turn point to pbl_pg_size physical
+	 * pages that contain PBE values that point to actual physical
+	 * pages.
 	 */
-	uint64_t	host_dest_addr;
-} hwrm_nvm_get_dir_entries_input_t, *phwrm_nvm_get_dir_entries_input_t;
+		#define SQ_FR_PPMR_HDR_NUMLEVELS_LAYER2		(UINT32_C(0x2) << 6)
+		#define SQ_FR_PPMR_HDR_NUMLEVELS_LAST		SQ_FR_PPMR_HDR_NUMLEVELS_LAYER2
+	/* Pointer to the PBL, or PDL depending on number of levels */
+	uint64_t	pblptr;
+	/* Local Virtual Address */
+	uint64_t	va;
+} sq_fr_ppmr_hdr_t, *psq_fr_ppmr_hdr_t;
 
-/* hwrm_nvm_get_dir_entries_output (size:128b/16B) */
+/*
+ * Bind SQ WQE. This WQE can perform either:
+ * * type1 "bind memory window", if mw_type==Type1
+ * * type2 "post send bind memory window", if mw_type==Type2
+ */
+/* sq_bind (size:1024b/128B) */
 
-typedef struct hwrm_nvm_get_dir_entries_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+typedef struct sq_bind {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * Memory Bind
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint8_t	valid;
-} hwrm_nvm_get_dir_entries_output_t, *phwrm_nvm_get_dir_entries_output_t;
-
-/*************************
- * hwrm_nvm_get_dir_info *
- *************************/
-
-
-/* hwrm_nvm_get_dir_info_input (size:128b/16B) */
-
-typedef struct hwrm_nvm_get_dir_info_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define SQ_BIND_WQE_TYPE_BIND UINT32_C(0xe)
+	#define SQ_BIND_WQE_TYPE_LAST SQ_BIND_WQE_TYPE_BIND
+	uint8_t	flags;
+	#define SQ_BIND_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_MASK		UINT32_C(0xff)
+	#define SQ_BIND_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_SFT			0
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * Set if completion signaling is requested. If this bit is
+	 * 0, and the SQ is configured to support Unsignaled
+	 * completion the controller should not generate a CQE
+	 * unless there was an error. This refers to CQE on the
+	 * sender side (se_flag refers to the receiver side)
 	 */
-	uint16_t	cmpl_ring;
+	#define SQ_BIND_FLAGS_SIGNAL_COMP								UINT32_C(0x1)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Indication to complete all previous RDMA Read or Atomic
+	 * WQEs on the SQ before executing this WQE
 	 */
-	uint16_t	seq_id;
+	#define SQ_BIND_FLAGS_RD_OR_ATOMIC_FENCE							UINT32_C(0x2)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Unconditional fence. Indication to complete all previous
+	 * SQ's WQEs before executing this WQE.
 	 */
-	uint16_t	target_id;
+	#define SQ_BIND_FLAGS_UC_FENCE								UINT32_C(0x4)
+	/* NA, nothing is sent. */
+	#define SQ_BIND_FLAGS_SE									UINT32_C(0x8)
+	/* NA */
+	#define SQ_BIND_FLAGS_INLINE								UINT32_C(0x10)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * This flag is not applicable and should be 0 for a local memory
+	 * operation WQE.
 	 */
-	uint64_t	resp_addr;
-} hwrm_nvm_get_dir_info_input_t, *phwrm_nvm_get_dir_info_input_t;
-
-/* hwrm_nvm_get_dir_info_output (size:192b/24B) */
-
-typedef struct hwrm_nvm_get_dir_info_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Number of directory entries in the directory. */
-	uint32_t	entries;
-	/* Size of each directory entry, in bytes. */
-	uint32_t	entry_length;
-	uint8_t	unused_0[7];
+	#define SQ_BIND_FLAGS_WQE_TS_EN								UINT32_C(0x20)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * When set to '1', this operation will cause a trace capture in
+	 * each block it passes through.
 	 */
-	uint8_t	valid;
-} hwrm_nvm_get_dir_info_output_t, *phwrm_nvm_get_dir_info_output_t;
-
-/******************
- * hwrm_nvm_write *
- ******************/
-
-
-/* hwrm_nvm_write_input (size:384b/48B) */
-
-typedef struct hwrm_nvm_write_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define SQ_BIND_FLAGS_DEBUG_TRACE								UINT32_C(0x40)
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * This is the new access control for the MR. '1' means
+	 * the operation is allowed. '0' means operation is
+	 * not allowed.
 	 */
-	uint16_t	cmpl_ring;
+	uint8_t	access_cntl;
+	#define SQ_BIND_ACCESS_CNTL_WINDOW_BIND_REMOTE_ATOMIC_REMOTE_WRITE_REMOTE_READ_LOCAL_WRITE_MASK		UINT32_C(0xff)
+	#define SQ_BIND_ACCESS_CNTL_WINDOW_BIND_REMOTE_ATOMIC_REMOTE_WRITE_REMOTE_READ_LOCAL_WRITE_SFT		0
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Local Write Access.
+	 *
+	 * Local accesses are never allowed for memory windows, so this
+	 * bit must always be zero in a bind WQE. If this bit is ever
+	 * set, the bind will fail with an errored completion.
 	 */
-	uint16_t	seq_id;
+	#define SQ_BIND_ACCESS_CNTL_LOCAL_WRITE									UINT32_C(0x1)
+	/* Remote Read Access */
+	#define SQ_BIND_ACCESS_CNTL_REMOTE_READ									UINT32_C(0x2)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Remote Write Access.
+	 *
+	 * Note that, if this bit is set, then the parent region to which
+	 * the window is being bound must allow local writes. If this is
+	 * not the case, then the bind will fail with an errored
+	 * completion.
 	 */
-	uint16_t	target_id;
+	#define SQ_BIND_ACCESS_CNTL_REMOTE_WRITE									UINT32_C(0x4)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Remote Atomic Access.
+	 *
+	 * Note that, if this bit is set, then the parent region to which
+	 * the window is being bound must allow local writes. If this is
+	 * not the case, then the bind will fail with an errored
+	 * completion.
 	 */
-	uint64_t	resp_addr;
+	#define SQ_BIND_ACCESS_CNTL_REMOTE_ATOMIC									UINT32_C(0x8)
 	/*
-	 * 64-bit Host Source Address.
-	 * This is where the source data is.
+	 * Window Binding Allowed.
+	 *
+	 * It is never allowed to bind windows to windows, so this bit
+	 * must always be zero in a bind WQE. If this bit is ever set,
+	 * the bind will fail with an errored completion.
 	 */
-	uint64_t	host_src_addr;
-	/* The Directory Entry Type (valid values are defined in the bnxnvm_directory_type enum defined in the file bnxnvm_defs.h). */
-	uint16_t	dir_type;
+	#define SQ_BIND_ACCESS_CNTL_WINDOW_BIND									UINT32_C(0x10)
+	/* reserved8_1 is 8 b */
+	uint8_t	reserved8_1;
+	uint8_t	mw_type_zero_based;
 	/*
-	 * Directory ordinal.
-	 * The 0-based instance of the combined Directory Entry Type and Extension.
+	 * If this bit is set, then the newly-bound memory window will be
+	 * zero-based. If clear, then the newly-bound memory window will be
+	 * non-zero-based.
 	 */
-	uint16_t	dir_ordinal;
-	/* The Directory Entry Extension flags (see BNX_DIR_EXT_* in the file bnxnvm_defs.h). */
-	uint16_t	dir_ext;
-	/* Directory Entry Attribute flags (see BNX_DIR_ATTR_* in the file bnxnvm_defs.h). */
-	uint16_t	dir_attr;
+	#define SQ_BIND_ZERO_BASED	UINT32_C(0x1)
+	/*
+	 * If type1 is specified, then this WQE performs a "bind memory
+	 * window" operation on a type1 window. If type2 is specified, then
+	 * this WQE performs a "post send bind memory window" operation on a
+	 * type2 window.
+	 *
+	 * Note that the bind WQE cannot change the type of the memory
+	 * window.
+	 *
+	 * If a "bind memory window" operation is attempted on a memory
+	 * window that was allocated as type2, then the bind will fail with
+	 * an errored completion, as "bind memory window" is allowed only on
+	 * type1 memory windows.
+	 *
+	 * Similarly, if a "post send bind memory window" operation is
+	 * attempted on a memory window that was allocated as type1, then the
+	 * bind will fail with an errored completions, as "post send bind
+	 * memory window" is allowed only on type2 memory windows.
+	 */
+	#define SQ_BIND_MW_TYPE	UINT32_C(0x2)
+	/* Type 1 Bind Memory Window */
+		#define SQ_BIND_MW_TYPE_TYPE1	(UINT32_C(0x0) << 1)
+	/* Type 2 Post Send Bind Memory Window */
+		#define SQ_BIND_MW_TYPE_TYPE2	(UINT32_C(0x1) << 1)
+		#define SQ_BIND_MW_TYPE_LAST	SQ_BIND_MW_TYPE_TYPE2
+	uint8_t	reserved8_2;
+	uint16_t	reserved16;
 	/*
-	 * Length of data to write, in bytes. May be less than or equal to the allocated size for the directory entry.
-	 * The data length stored in the directory entry will be updated to reflect this value once the write is complete.
+	 * The L_Key of the parent MR; 24 msb of the key are used to
+	 * index the MRW table, 8 lsb are compared with the 8 bit key
+	 * in the MRWC.
 	 */
-	uint32_t	dir_data_length;
-	/* Option. */
-	uint16_t	option;
-	uint16_t	flags;
+	uint32_t	parent_l_key;
 	/*
-	 * When this bit is '1', the original active image
-	 * will not be removed. TBD: what purpose is this?
+	 * Local Key; 24 msb of the key are used to index the memory
+	 * window being bound in the MRW table, 8 lsb are assign to the
+	 * 8 bit key_lsb field in the MRWC.
 	 */
-	#define HWRM_NVM_WRITE_INPUT_FLAGS_KEEP_ORIG_ACTIVE_IMG	UINT32_C(0x1)
+	uint32_t	l_key;
+	/* Local Virtual Address */
+	uint64_t	va;
 	/*
-	 * The requested length of the allocated NVM for the item, in bytes. This value may be greater than or equal to the specified data length (dir_data_length).
-	 * If this value is less than the specified data length, it will be ignored.
-	 * The response will contain the actual allocated item length, which may be greater than the requested item length.
-	 * The purpose for allocating more than the required number of bytes for an item's data is to pre-allocate extra storage (padding) to accommodate
-	 * the potential future growth of an item (e.g. upgraded firmware with a size increase, log growth, expanded configuration data).
+	 * Length in bytes of registered MW; 40 bits as this is the max
+	 * size of an MR/W
 	 */
-	uint32_t	dir_item_length;
-	uint32_t	unused_0;
-} hwrm_nvm_write_input_t, *phwrm_nvm_write_input_t;
+	uint8_t	length[5];
+	uint8_t	reserved24[3];
+	/* The data field for Bind is not used. */
+	uint32_t	data[24];
+} sq_bind_t, *psq_bind_t;
 
-/* hwrm_nvm_write_output (size:128b/16B) */
+/*
+ * Bind SQ WQE header. This WQE can perform either:
+ * * type1 "bind memory window", if mw_type==Type1
+ * * type2 "post send bind memory window", if mw_type==Type2
+ */
+/* sq_bind_hdr (size:256b/32B) */
 
-typedef struct hwrm_nvm_write_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
+typedef struct sq_bind_hdr {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
+	/*
+	 * Memory Bind
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
+	 */
+	#define SQ_BIND_HDR_WQE_TYPE_BIND UINT32_C(0xe)
+	#define SQ_BIND_HDR_WQE_TYPE_LAST SQ_BIND_HDR_WQE_TYPE_BIND
+	uint8_t	flags;
+	#define SQ_BIND_HDR_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_MASK		UINT32_C(0xff)
+	#define SQ_BIND_HDR_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_SFT			0
 	/*
-	 * Length of the allocated NVM for the item, in bytes. The value may be greater than or equal to the specified data length or the requested item length.
-	 * The actual item length used when creating a new directory entry will be a multiple of an NVM block size.
+	 * Set if completion signaling is requested. If this bit is
+	 * 0, and the SQ is configured to support Unsignaled
+	 * completion the controller should not generate a CQE
+	 * unless there was an error. This refers to CQE on the
+	 * sender side (se_flag refers to the receiver side)
 	 */
-	uint32_t	dir_item_length;
-	/* The directory index of the created or modified item. */
-	uint16_t	dir_idx;
-	uint8_t	unused_0;
+	#define SQ_BIND_HDR_FLAGS_SIGNAL_COMP								UINT32_C(0x1)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * Indication to complete all previous RDMA Read or Atomic
+	 * WQEs on the SQ before executing this WQE
 	 */
-	uint8_t	valid;
-} hwrm_nvm_write_output_t, *phwrm_nvm_write_output_t;
-
-/* hwrm_nvm_write_cmd_err (size:64b/8B) */
-
-typedef struct hwrm_nvm_write_cmd_err {
+	#define SQ_BIND_HDR_FLAGS_RD_OR_ATOMIC_FENCE							UINT32_C(0x2)
 	/*
-	 * command specific error codes that goes to
-	 * the cmd_err field in Common HWRM Error Response.
+	 * Unconditional fence. Indication to complete all previous
+	 * SQ's WQEs before executing this WQE.
 	 */
-	uint8_t	code;
-	/* Unknown error */
-	#define HWRM_NVM_WRITE_CMD_ERR_CODE_UNKNOWN  UINT32_C(0x0)
-	/* Unable to complete operation due to fragmentation */
-	#define HWRM_NVM_WRITE_CMD_ERR_CODE_FRAG_ERR UINT32_C(0x1)
-	/* nvm is completely full. */
-	#define HWRM_NVM_WRITE_CMD_ERR_CODE_NO_SPACE UINT32_C(0x2)
-	#define HWRM_NVM_WRITE_CMD_ERR_CODE_LAST	HWRM_NVM_WRITE_CMD_ERR_CODE_NO_SPACE
-	uint8_t	unused_0[7];
-} hwrm_nvm_write_cmd_err_t, *phwrm_nvm_write_cmd_err_t;
-
-/*******************
- * hwrm_nvm_modify *
- *******************/
-
-
-/* hwrm_nvm_modify_input (size:320b/40B) */
-
-typedef struct hwrm_nvm_modify_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define SQ_BIND_HDR_FLAGS_UC_FENCE								UINT32_C(0x4)
+	/* NA, nothing is sent. */
+	#define SQ_BIND_HDR_FLAGS_SE									UINT32_C(0x8)
+	/* NA */
+	#define SQ_BIND_HDR_FLAGS_INLINE								UINT32_C(0x10)
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * This flag is not applicable and should be 0 for a local memory
+	 * operation WQE.
 	 */
-	uint16_t	cmpl_ring;
+	#define SQ_BIND_HDR_FLAGS_WQE_TS_EN								UINT32_C(0x20)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * When set to '1', this operation will cause a trace capture in
+	 * each block it passes through.
 	 */
-	uint16_t	seq_id;
+	#define SQ_BIND_HDR_FLAGS_DEBUG_TRACE								UINT32_C(0x40)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * This is the new access control for the MR. '1' means
+	 * the operation is allowed. '0' means operation is
+	 * not allowed.
 	 */
-	uint16_t	target_id;
+	uint8_t	access_cntl;
+	#define SQ_BIND_HDR_ACCESS_CNTL_WINDOW_BIND_REMOTE_ATOMIC_REMOTE_WRITE_REMOTE_READ_LOCAL_WRITE_MASK		UINT32_C(0xff)
+	#define SQ_BIND_HDR_ACCESS_CNTL_WINDOW_BIND_REMOTE_ATOMIC_REMOTE_WRITE_REMOTE_READ_LOCAL_WRITE_SFT		0
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Local Write Access.
+	 *
+	 * Local accesses are never allowed for memory windows, so this
+	 * bit must always be zero in a bind WQE. If this bit is ever
+	 * set, the bind will fail with an errored completion.
 	 */
-	uint64_t	resp_addr;
+	#define SQ_BIND_HDR_ACCESS_CNTL_LOCAL_WRITE									UINT32_C(0x1)
+	/* Remote Read Access */
+	#define SQ_BIND_HDR_ACCESS_CNTL_REMOTE_READ									UINT32_C(0x2)
 	/*
-	 * 64-bit Host Source Address.
-	 * This is where the modified data is.
+	 * Remote Write Access.
+	 *
+	 * Note that, if this bit is set, then the parent region to which
+	 * the window is being bound must allow local writes. If this is
+	 * not the case, then the bind will fail with an errored
+	 * completion.
 	 */
-	uint64_t	host_src_addr;
-	/* 16-bit directory entry index. */
-	uint16_t	dir_idx;
-	uint16_t	flags;
+	#define SQ_BIND_HDR_ACCESS_CNTL_REMOTE_WRITE									UINT32_C(0x4)
 	/*
-	 * This flag indicates the sender wants to modify a continuous NVRAM
-	 * area using a batch of this HWRM requests. The offset of a request
-	 * must be continuous to the end of previous request's. Firmware does
-	 * not update the directory entry until receiving the last request,
-	 * which is indicated by the batch_last flag.
-	 * This flag is set usually when a sender does not have a block of
-	 * memory that is big enough to hold the entire NVRAM data for send
-	 * at one time.
+	 * Remote Atomic Access.
+	 *
+	 * Note that, if this bit is set, then the parent region to which
+	 * the window is being bound must allow local writes. If this is
+	 * not the case, then the bind will fail with an errored
+	 * completion.
 	 */
-	#define HWRM_NVM_MODIFY_INPUT_FLAGS_BATCH_MODE	UINT32_C(0x1)
+	#define SQ_BIND_HDR_ACCESS_CNTL_REMOTE_ATOMIC									UINT32_C(0x8)
 	/*
-	 * This flag can be used only when the batch_mode flag is set.
-	 * It indicates this request is the last of batch requests.
+	 * Window Binding Allowed.
+	 *
+	 * It is never allowed to bind windows to windows, so this bit
+	 * must always be zero in a bind WQE. If this bit is ever set,
+	 * the bind will fail with an errored completion.
 	 */
-	#define HWRM_NVM_MODIFY_INPUT_FLAGS_BATCH_LAST	UINT32_C(0x2)
-	/* 32-bit NVRAM byte-offset to modify content from. */
-	uint32_t	offset;
+	#define SQ_BIND_HDR_ACCESS_CNTL_WINDOW_BIND									UINT32_C(0x10)
+	/* reserved8_1 is 8 b */
+	uint8_t	reserved8_1;
+	uint8_t	mw_type_zero_based;
 	/*
-	 * Length of data to be modified, in bytes. The length shall
-	 * be non-zero.
+	 * If this bit is set, then the newly-bound memory window will be
+	 * zero-based. If clear, then the newly-bound memory window will be
+	 * non-zero-based.
 	 */
-	uint32_t	len;
-	uint8_t	unused_1[4];
-} hwrm_nvm_modify_input_t, *phwrm_nvm_modify_input_t;
-
-/* hwrm_nvm_modify_output (size:128b/16B) */
-
-typedef struct hwrm_nvm_modify_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	#define SQ_BIND_HDR_ZERO_BASED	UINT32_C(0x1)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * If type1 is specified, then this WQE performs a "bind memory
+	 * window" operation on a type1 window. If type2 is specified, then
+	 * this WQE performs a "post send bind memory window" operation on a
+	 * type2 window.
+	 *
+	 * Note that the bind WQE cannot change the type of the memory
+	 * window.
+	 *
+	 * If a "bind memory window" operation is attempted on a memory
+	 * window that was allocated as type2, then the bind will fail with
+	 * an errored completion, as "bind memory window" is allowed only on
+	 * type1 memory windows.
+	 *
+	 * Similarly, if a "post send bind memory window" operation is
+	 * attempted on a memory window that was allocated as type1, then the
+	 * bind will fail with an errored completions, as "post send bind
+	 * memory window" is allowed only on type2 memory windows.
 	 */
-	uint8_t	valid;
-} hwrm_nvm_modify_output_t, *phwrm_nvm_modify_output_t;
-
-/***************************
- * hwrm_nvm_find_dir_entry *
- ***************************/
-
-
-/* hwrm_nvm_find_dir_entry_input (size:256b/32B) */
-
-typedef struct hwrm_nvm_find_dir_entry_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define SQ_BIND_HDR_MW_TYPE	UINT32_C(0x2)
+	/* Type 1 Bind Memory Window */
+		#define SQ_BIND_HDR_MW_TYPE_TYPE1	(UINT32_C(0x0) << 1)
+	/* Type 2 Post Send Bind Memory Window */
+		#define SQ_BIND_HDR_MW_TYPE_TYPE2	(UINT32_C(0x1) << 1)
+		#define SQ_BIND_HDR_MW_TYPE_LAST	SQ_BIND_HDR_MW_TYPE_TYPE2
+	uint8_t	reserved8_2;
+	uint16_t	reserved16;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * The L_Key of the parent MR; 24 msb of the key are used to
+	 * index the MRW table, 8 lsb are compared with the 8 bit key
+	 * in the MRWC.
 	 */
-	uint16_t	cmpl_ring;
+	uint32_t	parent_l_key;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Local Key; 24 msb of the key are used to index the memory
+	 * window being bound in the MRW table, 8 lsb are assign to the
+	 * 8 bit key_lsb field in the MRWC.
 	 */
-	uint16_t	seq_id;
+	uint32_t	l_key;
+	/* Local Virtual Address */
+	uint64_t	va;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Length in bytes of registered MW; 40 bits as this is the max
+	 * size of an MR/W
 	 */
-	uint16_t	target_id;
+	uint8_t	length[5];
+	uint8_t	reserved24[3];
+} sq_bind_hdr_t, *psq_bind_hdr_t;
+
+/*
+ * This V3 version of structure is not accessible from host software, but is documented here (in the SW section) anyway.
+ * This is the MSN Table (located in IQM). The table is written by the RoCE transmitter when sending wire operation WQEs. It is used to provide the RoCE receiver with information about the SQ WQEs in order to make requester completions and to perform requester HW retransmission. The number of entries in the table is configured in the QPC and must be equal to the maximum number of WQEs that can be present in the SQ at one time, rounded up to the nearest power of two.
+ */
+/* sq_msn_search_v3 (size:128b/16B) */
+
+typedef struct sq_msn_search_v3 {
+	uint64_t	idx_psn;
+	/* Start PSN of the WQE. */
+	#define SQ_MSN_SEARCH_V3_START_PSN_MASK UINT32_C(0xffffff)
+	#define SQ_MSN_SEARCH_V3_START_PSN_SFT 0
+	/* Next PSN. Equal to the start PSN of the next WQE. */
+	#define SQ_MSN_SEARCH_V3_NEXT_PSN_MASK UINT32_C(0xffffff000000)L
+	#define SQ_MSN_SEARCH_V3_NEXT_PSN_SFT  24
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Start index. For variable-size WQEs, this field indicates the
+	 * starting slot index that corresponds to the WQE. In
+	 * backward-compatible mode, this is the starting WQE index.
 	 */
-	uint64_t	resp_addr;
-	uint32_t	enables;
+	#define SQ_MSN_SEARCH_V3_START_IDX_MASK UINT32_C(0xffff000000000000)L
+	#define SQ_MSN_SEARCH_V3_START_IDX_SFT 48
 	/*
-	 * This bit must be '1' for the dir_idx_valid field to be
-	 * configured.
+	 * This value will be returned in the completion if the completion
+	 * is signaled.
 	 */
-	#define HWRM_NVM_FIND_DIR_ENTRY_INPUT_ENABLES_DIR_IDX_VALID	UINT32_C(0x1)
-	/* Directory Entry Index */
-	uint16_t	dir_idx;
-	/* Directory Entry (Image) Type */
-	uint16_t	dir_type;
+	uint32_t	wqe_opaque;
+	/* The size of the WQE in units of 16B chunks. */
+	uint8_t	wqe_size;
+	uint8_t	signal;
+	/* Set if completion signaling is requested. */
+	#define SQ_MSN_SEARCH_V3_SGNLD			UINT32_C(0x1)
 	/*
-	 * Directory ordinal.
-	 * The instance of this Directory Type
+	 * Set if at least one signaled local memory operation WQE is
+	 * present in the SQ between the previous wire-operation WQE
+	 * and this WQE.
 	 */
-	uint16_t	dir_ordinal;
-	/* The Directory Entry Extension flags. */
-	uint16_t	dir_ext;
-	/* This value indicates the search option using dir_ordinal. */
-	uint8_t	opt_ordinal;
-	/* This value indicates the search option using dir_ordinal. */
-	#define HWRM_NVM_FIND_DIR_ENTRY_INPUT_OPT_ORDINAL_MASK UINT32_C(0x3)
-	#define HWRM_NVM_FIND_DIR_ENTRY_INPUT_OPT_ORDINAL_SFT 0
-	/* Equal to specified ordinal value. */
-		#define HWRM_NVM_FIND_DIR_ENTRY_INPUT_OPT_ORDINAL_EQ	UINT32_C(0x0)
-	/* Greater than or equal to specified ordinal value */
-		#define HWRM_NVM_FIND_DIR_ENTRY_INPUT_OPT_ORDINAL_GE	UINT32_C(0x1)
-	/* Greater than specified ordinal value */
-		#define HWRM_NVM_FIND_DIR_ENTRY_INPUT_OPT_ORDINAL_GT	UINT32_C(0x2)
-		#define HWRM_NVM_FIND_DIR_ENTRY_INPUT_OPT_ORDINAL_LAST HWRM_NVM_FIND_DIR_ENTRY_INPUT_OPT_ORDINAL_GT
-	uint8_t	unused_0[3];
-} hwrm_nvm_find_dir_entry_input_t, *phwrm_nvm_find_dir_entry_input_t;
+	#define SQ_MSN_SEARCH_V3_PREV_SGNLD_LOCAL_MEM_WQE	UINT32_C(0x2)
+	uint16_t	reserved;
+} sq_msn_search_v3_t, *psq_msn_search_v3_t;
 
-/* hwrm_nvm_find_dir_entry_output (size:256b/32B) */
+/* SQ Send WQE V3 for RC SQs. */
+/* sq_send_v3 (size:1024b/128B) */
 
-typedef struct hwrm_nvm_find_dir_entry_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Allocated NVRAM for this directory entry, in bytes. */
-	uint32_t	dir_item_length;
-	/* Size of the stored data for this directory entry, in bytes. */
-	uint32_t	dir_data_length;
+typedef struct sq_send_v3 {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
+	/* Send V3 */
+	#define SQ_SEND_V3_WQE_TYPE_SEND_V3	UINT32_C(0x10)
 	/*
-	 * Firmware version.
-	 * Only valid if the directory entry is for embedded firmware stored in APE_BIN Format.
+	 * Send with Immediate V3
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint32_t	fw_ver;
-	/* Directory ordinal. */
-	uint16_t	dir_ordinal;
-	/* Directory Entry Index */
-	uint16_t	dir_idx;
-	uint8_t	unused_0[7];
+	#define SQ_SEND_V3_WQE_TYPE_SEND_W_IMMED_V3   UINT32_C(0x11)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * Send with Invalidate V3
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint8_t	valid;
-} hwrm_nvm_find_dir_entry_output_t, *phwrm_nvm_find_dir_entry_output_t;
-
-/****************************
- * hwrm_nvm_erase_dir_entry *
- ****************************/
-
-
-/* hwrm_nvm_erase_dir_entry_input (size:192b/24B) */
-
-typedef struct hwrm_nvm_erase_dir_entry_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define SQ_SEND_V3_WQE_TYPE_SEND_W_INVALID_V3 UINT32_C(0x12)
+	#define SQ_SEND_V3_WQE_TYPE_LAST		SQ_SEND_V3_WQE_TYPE_SEND_W_INVALID_V3
+	uint8_t	flags;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * Set if completion signaling is requested. If this bit is
+	 * 0, and the SQ is configured to support Unsignaled completion
+	 * the controller should not generate a CQE unless there was
+	 * an error. This refers to the CQE on the sender side. (The se
+	 * flag refers to the receiver side).
 	 */
-	uint16_t	cmpl_ring;
+	#define SQ_SEND_V3_FLAGS_SIGNAL_COMP		UINT32_C(0x1)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Indication to complete all previous RDMA Read or Atomic WQEs
+	 * on the SQ before executing this WQE.
+	 *
+	 * This flag must be zero for a UD send.
 	 */
-	uint16_t	seq_id;
+	#define SQ_SEND_V3_FLAGS_RD_OR_ATOMIC_FENCE	UINT32_C(0x2)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Unconditional fence. Indication to complete all
+	 * previous SQ's WQEs before executing this WQE.
+	 *
+	 * This flag must be zero for a UD send.
 	 */
-	uint16_t	target_id;
+	#define SQ_SEND_V3_FLAGS_UC_FENCE		UINT32_C(0x4)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Solicit event flag. Indication sent in BTH header to the
+	 * receiver to generate a Completion Event Notification, i.e.
+	 * CNQE.
 	 */
-	uint64_t	resp_addr;
-	/* Directory Entry Index */
-	uint16_t	dir_idx;
-	uint8_t	unused_0[6];
-} hwrm_nvm_erase_dir_entry_input_t, *phwrm_nvm_erase_dir_entry_input_t;
-
-/* hwrm_nvm_erase_dir_entry_output (size:128b/16B) */
-
-typedef struct hwrm_nvm_erase_dir_entry_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	#define SQ_SEND_V3_FLAGS_SE			UINT32_C(0x8)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * Indicate that inline data is posted to the SQ in the data
+	 * area of this WQE.
 	 */
-	uint8_t	valid;
-} hwrm_nvm_erase_dir_entry_output_t, *phwrm_nvm_erase_dir_entry_output_t;
-
-/*************************
- * hwrm_nvm_get_dev_info *
- *************************/
-
-
-/* hwrm_nvm_get_dev_info_input (size:128b/16B) */
-
-typedef struct hwrm_nvm_get_dev_info_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define SQ_SEND_V3_FLAGS_INLINE		UINT32_C(0x10)
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * If set to 1, then the timestamp from the WQE is used. If
+	 * cleared to 0, then TWE provides the timestamp.
 	 */
-	uint16_t	cmpl_ring;
+	#define SQ_SEND_V3_FLAGS_WQE_TS_EN		UINT32_C(0x20)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * When set to '1', this operation will cause a trace capture in
+	 * each block it passes through.
 	 */
-	uint16_t	seq_id;
+	#define SQ_SEND_V3_FLAGS_DEBUG_TRACE		UINT32_C(0x40)
+	/*  */
+	uint8_t	wqe_size;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * The number of 16 bytes chunks of data including this first
+	 * word of the request that are a valid part of the request. The
+	 * valid 16 bytes units other than the WQE structure can be
+	 * SGEs (Scatter Gather Elements) OR inline data.
+	 *
+	 * Note: Since the WQE header consumes only one slot (16 bytes)
+	 * for this type of WQE, and the maximum number of SGEs supported
+	 * by the device is 30, this field must never exceed 31.
+	 */
+	#define SQ_SEND_V3_WQE_SIZE_MASK UINT32_C(0x3f)
+	#define SQ_SEND_V3_WQE_SIZE_SFT 0
+	uint8_t	inline_length;
+	/*
+	 * When inline flag is '1', this field determines the number of
+	 * bytes that are valid in the last 16B unit of the inline WQE.
+	 * Zero means all 16 bytes are valid. One means only bits 7:0 of
+	 * the last 16B unit are valid. This means the total size of the
+	 * inline data is determined by a combination of the wqe_size field
+	 * and this inline_length field.
+	 *
+	 * `inline_size = ((wqe_size - 1) * 16) - data_offset_in_bytes +
+	 * ((inline_length == 0 ) ? 16 : inline_length)
+	 *
+	 * Where data_offset_in_bytes is the offset within the WQE where
+	 * the data field starts.
+	 *
+	 * Note that this field is not applicable for zero-length inline
+	 * WQEs.
 	 */
-	uint16_t	target_id;
+	#define SQ_SEND_V3_INLINE_LENGTH_MASK UINT32_C(0xf)
+	#define SQ_SEND_V3_INLINE_LENGTH_SFT 0
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * This value will be returned in the completion if the completion is
+	 * signaled.
 	 */
-	uint64_t	resp_addr;
-} hwrm_nvm_get_dev_info_input_t, *phwrm_nvm_get_dev_info_input_t;
-
-/* hwrm_nvm_get_dev_info_output (size:640b/80B) */
-
-typedef struct hwrm_nvm_get_dev_info_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* Manufacturer ID. */
-	uint16_t	manufacturer_id;
-	/* Device ID. */
-	uint16_t	device_id;
-	/* Sector size of the NVRAM device. */
-	uint32_t	sector_size;
-	/* Total size, in bytes of the NVRAM device. */
-	uint32_t	nvram_size;
-	uint32_t	reserved_size;
-	/* Available size that can be used, in bytes.  Available size is the NVRAM size take away the used size and reserved size. */
-	uint32_t	available_size;
-	/* This field represents the major version of NVM cfg */
-	uint8_t	nvm_cfg_ver_maj;
-	/* This field represents the minor version of NVM cfg */
-	uint8_t	nvm_cfg_ver_min;
-	/* This field represents the update version of NVM cfg */
-	uint8_t	nvm_cfg_ver_upd;
-	uint8_t	flags;
+	uint32_t	opaque;
 	/*
-	 * If set to 1, firmware will provide various firmware version
-	 * information stored in the flash.
+	 * Either invalidate key (R_Key of the remote host) that will
+	 * be send with IETH (Invalidate ETH) if wqe_type is of Send
+	 * with Invalidate, or immediate value that will be sent with
+	 * ImmDt header if wqe_type is Send with Immediate.
 	 */
-	#define HWRM_NVM_GET_DEV_INFO_OUTPUT_FLAGS_FW_VER_VALID	UINT32_C(0x1)
+	uint32_t	inv_key_or_imm_data;
+	uint32_t	timestamp;
 	/*
-	 * This field represents the board package name stored in the flash.
-	 * (ASCII chars with NULL at the end).
+	 * This field specifies a 24-bit timestamp that can be passed
+	 * down the TX path and optionally logged in the TXP timestamp
+	 * histogram.
 	 */
-	char	pkg_name[16];
+	#define SQ_SEND_V3_TIMESTAMP_MASK UINT32_C(0xffffff)
+	#define SQ_SEND_V3_TIMESTAMP_SFT 0
 	/*
-	 * This field represents the major version of HWRM firmware, stored in
-	 * the flash.
+	 * When inline=0, then this area is filled with from 1 to 30 SGEs
+	 * based on the wqe_size field.
+	 *
+	 * When inline=1, this area is filled with payload data for the
+	 * send. Length of data is described in the inline_length field.
+	 * Bits [7:0] of word 0 hold the first byte to go out on the wire.
 	 */
-	uint16_t	hwrm_fw_major;
+	uint32_t	data[28];
+} sq_send_v3_t, *psq_send_v3_t;
+
+/* Send SQ WQE V3 header. */
+/* sq_send_hdr_v3 (size:128b/16B) */
+
+typedef struct sq_send_hdr_v3 {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
+	/* Send V3 */
+	#define SQ_SEND_HDR_V3_WQE_TYPE_SEND_V3	UINT32_C(0x10)
 	/*
-	 * This field represents the minor version of HWRM firmware, stored in
-	 * the flash.
+	 * Send with Immediate V3
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint16_t	hwrm_fw_minor;
+	#define SQ_SEND_HDR_V3_WQE_TYPE_SEND_W_IMMED_V3   UINT32_C(0x11)
 	/*
-	 * This field represents the build version of HWRM firmware, stored in
-	 * the flash.
+	 * Send with Invalidate V3
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	uint16_t	hwrm_fw_build;
+	#define SQ_SEND_HDR_V3_WQE_TYPE_SEND_W_INVALID_V3 UINT32_C(0x12)
+	#define SQ_SEND_HDR_V3_WQE_TYPE_LAST		SQ_SEND_HDR_V3_WQE_TYPE_SEND_W_INVALID_V3
+	uint8_t	flags;
 	/*
-	 * This field can be used to represent firmware branches or customer
-	 * specific releases tied to a specific (major, minor, build) version
-	 * of the HWRM firmware.
+	 * Set if completion signaling is requested. If this bit is
+	 * 0, and the SQ is configured to support Unsignaled completion
+	 * the controller should not generate a CQE unless there was
+	 * an error. This refers to the CQE on the sender side. (The se
+	 * flag refers to the receiver side).
 	 */
-	uint16_t	hwrm_fw_patch;
+	#define SQ_SEND_HDR_V3_FLAGS_SIGNAL_COMP		UINT32_C(0x1)
 	/*
-	 * This field represents the major version of mgmt firmware, stored in
-	 * the flash.
+	 * Indication to complete all previous RDMA Read or Atomic WQEs
+	 * on the SQ before executing this WQE.
+	 *
+	 * This flag must be zero for a UD send.
 	 */
-	uint16_t	mgmt_fw_major;
+	#define SQ_SEND_HDR_V3_FLAGS_RD_OR_ATOMIC_FENCE	UINT32_C(0x2)
 	/*
-	 * This field represents the minor version of mgmt firmware, stored in
-	 * the flash.
+	 * Unconditional fence. Indication to complete all
+	 * previous SQ's WQEs before executing this WQE.
+	 *
+	 * This flag must be zero for a UD send.
 	 */
-	uint16_t	mgmt_fw_minor;
+	#define SQ_SEND_HDR_V3_FLAGS_UC_FENCE		UINT32_C(0x4)
 	/*
-	 * This field represents the build version of mgmt firmware, stored in
-	 * the flash.
+	 * Solicit event flag. Indication sent in BTH header to the
+	 * receiver to generate a Completion Event Notification, i.e.
+	 * CNQE.
 	 */
-	uint16_t	mgmt_fw_build;
+	#define SQ_SEND_HDR_V3_FLAGS_SE			UINT32_C(0x8)
 	/*
-	 * This field can be used to represent firmware branches or customer
-	 * specific releases tied to a specific (major, minor, build) version
-	 * of the mgmt firmware.
+	 * Indicate that inline data is posted to the SQ in the data
+	 * area of this WQE.
 	 */
-	uint16_t	mgmt_fw_patch;
+	#define SQ_SEND_HDR_V3_FLAGS_INLINE		UINT32_C(0x10)
 	/*
-	 * This field represents the major version of roce firmware, stored in
-	 * the flash.
+	 * If set to 1, then the timestamp from the WQE is used. If
+	 * cleared to 0, then TWE provides the timestamp.
 	 */
-	uint16_t	roce_fw_major;
+	#define SQ_SEND_HDR_V3_FLAGS_WQE_TS_EN		UINT32_C(0x20)
 	/*
-	 * This field represents the minor version of roce firmware, stored in
-	 * the flash.
+	 * When set to '1', this operation will cause a trace capture in
+	 * each block it passes through.
 	 */
-	uint16_t	roce_fw_minor;
+	#define SQ_SEND_HDR_V3_FLAGS_DEBUG_TRACE		UINT32_C(0x40)
+	/*  */
+	uint8_t	wqe_size;
 	/*
-	 * This field represents the build version of roce firmware, stored in
-	 * the flash.
+	 * The number of 16 bytes chunks of data including this first
+	 * word of the request that are a valid part of the request. The
+	 * valid 16 bytes units other than the WQE structure can be
+	 * SGEs (Scatter Gather Elements) OR inline data.
+	 *
+	 * Note: Since the WQE header consumes only one slot (16 bytes)
+	 * for this type of WQE, and the maximum number of SGEs supported
+	 * by the device is 30, this field must never exceed 31.
+	 */
+	#define SQ_SEND_HDR_V3_WQE_SIZE_MASK UINT32_C(0x3f)
+	#define SQ_SEND_HDR_V3_WQE_SIZE_SFT 0
+	uint8_t	inline_length;
+	/*
+	 * When inline flag is '1', this field determines the number of
+	 * bytes that are valid in the last 16B unit of the inline WQE.
+	 * Zero means all 16 bytes are valid. One means only bits 7:0 of
+	 * the last 16B unit are valid. This means the total size of the
+	 * inline data is determined by a combination of the wqe_size field
+	 * and this inline_length field.
+	 *
+	 * `inline_size = ((wqe_size - 1) * 16) - data_offset_in_bytes +
+	 * ((inline_length == 0 ) ? 16 : inline_length)
+	 *
+	 * Where data_offset_in_bytes is the offset within the WQE where
+	 * the data field starts.
+	 *
+	 * Note that this field is not applicable for zero-length inline
+	 * WQEs.
 	 */
-	uint16_t	roce_fw_build;
+	#define SQ_SEND_HDR_V3_INLINE_LENGTH_MASK UINT32_C(0xf)
+	#define SQ_SEND_HDR_V3_INLINE_LENGTH_SFT 0
 	/*
-	 * This field can be used to represent firmware branches or customer
-	 * specific releases tied to a specific (major, minor, build) version
-	 * of the roce firmware.
+	 * This value will be returned in the completion if the completion is
+	 * signaled.
+	 */
+	uint32_t	opaque;
+	/*
+	 * Either invalidate key (R_Key of the remote host) that will
+	 * be send with IETH (Invalidate ETH) if wqe_type is of Send
+	 * with Invalidate, or immediate value that will be sent with
+	 * ImmDt header if wqe_type is Send with Immediate.
 	 */
-	uint16_t	roce_fw_patch;
-	uint8_t	unused_0[7];
+	uint32_t	inv_key_or_imm_data;
+	uint32_t	timestamp;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * This field specifies a 24-bit timestamp that can be passed
+	 * down the TX path and optionally logged in the TXP timestamp
+	 * histogram.
 	 */
-	uint8_t	valid;
-} hwrm_nvm_get_dev_info_output_t, *phwrm_nvm_get_dev_info_output_t;
-
-/**************************
- * hwrm_nvm_mod_dir_entry *
- **************************/
-
+	#define SQ_SEND_HDR_V3_TIMESTAMP_MASK UINT32_C(0xffffff)
+	#define SQ_SEND_HDR_V3_TIMESTAMP_SFT 0
+} sq_send_hdr_v3_t, *psq_send_hdr_v3_t;
 
-/* hwrm_nvm_mod_dir_entry_input (size:256b/32B) */
+/* SQ WQE V3 for Raw Ethernet and QP1 */
+/* sq_rawqp1send_v3 (size:1024b/128B) */
 
-typedef struct hwrm_nvm_mod_dir_entry_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+typedef struct sq_rawqp1send_v3 {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
+	/* RawEth/QP1 Send V3 */
+	#define SQ_RAWQP1SEND_V3_WQE_TYPE_RAWQP1SEND_V3 UINT32_C(0x1d)
+	#define SQ_RAWQP1SEND_V3_WQE_TYPE_LAST	SQ_RAWQP1SEND_V3_WQE_TYPE_RAWQP1SEND_V3
+	uint8_t	flags;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * Set if completion signaling is requested. If this bit is
+	 * 0, and the SQ is configured to support Unsignaled completion
+	 * the controller should not generate a CQE unless there was
+	 * an error. This refers to the CQE on the sender side. (The se
+	 * flag refers to the receiver side).
 	 */
-	uint16_t	cmpl_ring;
+	#define SQ_RAWQP1SEND_V3_FLAGS_SIGNAL_COMP		UINT32_C(0x1)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Indication to complete all previous RDMA Read or Atomic WQEs
+	 * on the SQ before executing this WQE.
+	 *
+	 * This flag must be zero for a QP1 send.
 	 */
-	uint16_t	seq_id;
+	#define SQ_RAWQP1SEND_V3_FLAGS_RD_OR_ATOMIC_FENCE	UINT32_C(0x2)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Unconditional fence. Indication to complete all
+	 * previous SQ's WQEs before executing this WQE.
+	 *
+	 * This flag must be zero for a QP1 send.
 	 */
-	uint16_t	target_id;
+	#define SQ_RAWQP1SEND_V3_FLAGS_UC_FENCE		UINT32_C(0x4)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Solicit event flag. Indication sent in BTH header to the
+	 * receiver to generate a Completion Event Notification, i.e.
+	 * CNQE.
+	 *
+	 * This flag must be zero for a QP1 send.
 	 */
-	uint64_t	resp_addr;
-	uint32_t	enables;
+	#define SQ_RAWQP1SEND_V3_FLAGS_SE			UINT32_C(0x8)
 	/*
-	 * This bit must be '1' for the checksum field to be
-	 * configured.
+	 * Indicate that inline data is posted to the SQ in the data
+	 * area of this WQE.
 	 */
-	#define HWRM_NVM_MOD_DIR_ENTRY_INPUT_ENABLES_CHECKSUM	UINT32_C(0x1)
-	/* Directory Entry Index */
-	uint16_t	dir_idx;
+	#define SQ_RAWQP1SEND_V3_FLAGS_INLINE		UINT32_C(0x10)
 	/*
-	 * Directory ordinal.
-	 * The (0-based) instance of this Directory Type.
+	 * If set to 1, then the timestamp from the WQE is used. If
+	 * cleared to 0, then TWE provides the timestamp.
 	 */
-	uint16_t	dir_ordinal;
-	/* The Directory Entry Extension flags (see BNX_DIR_EXT_* for extension flag definitions). */
-	uint16_t	dir_ext;
-	/* Directory Entry Attribute flags (see BNX_DIR_ATTR_* for attribute flag definitions). */
-	uint16_t	dir_attr;
+	#define SQ_RAWQP1SEND_V3_FLAGS_WQE_TS_EN		UINT32_C(0x20)
 	/*
-	 * If valid, then this field updates the checksum
-	 * value of the content in the directory entry.
+	 * When set to '1', this operation will cause a trace capture in
+	 * each block it passes through.
 	 */
-	uint32_t	checksum;
-} hwrm_nvm_mod_dir_entry_input_t, *phwrm_nvm_mod_dir_entry_input_t;
-
-/* hwrm_nvm_mod_dir_entry_output (size:128b/16B) */
-
-typedef struct hwrm_nvm_mod_dir_entry_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	#define SQ_RAWQP1SEND_V3_FLAGS_DEBUG_TRACE		UINT32_C(0x40)
+	/*  */
+	uint8_t	wqe_size;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * The number of 16 bytes chunks of data including this first
+	 * word of the request that are a valid part of the request. The
+	 * valid 16 bytes units other than the WQE structure can be
+	 * SGEs (Scatter Gather Elements) OR inline data.
+	 *
+	 * This field shall never exceed 32 for WQEs of this type.
+	 */
+	#define SQ_RAWQP1SEND_V3_WQE_SIZE_MASK UINT32_C(0x3f)
+	#define SQ_RAWQP1SEND_V3_WQE_SIZE_SFT 0
+	uint8_t	inline_length;
+	/*
+	 * When inline flag is '1', this field determines the number of
+	 * bytes that are valid in the last 16B unit of the inline WQE.
+	 * Zero means all 16 bytes are valid. One means only bits 7:0 of
+	 * the last 16B unit are valid. This means the total size of the
+	 * inline data is determined by a combination of the wqe_size field
+	 * and this inline_length field.
+	 *
+	 * `inline_size = ((wqe_size - 1) * 16) - data_offset_in_bytes +
+	 * ((inline_length == 0 ) ? 16 : inline_length)
+	 *
+	 * Where data_offset_in_bytes is the offset within the WQE where
+	 * the data field starts.
+	 *
+	 * Note that this field is not applicable for zero-length inline
+	 * WQEs.
 	 */
-	uint8_t	valid;
-} hwrm_nvm_mod_dir_entry_output_t, *phwrm_nvm_mod_dir_entry_output_t;
-
-/**************************
- * hwrm_nvm_verify_update *
- **************************/
-
-
-/* hwrm_nvm_verify_update_input (size:192b/24B) */
-
-typedef struct hwrm_nvm_verify_update_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define SQ_RAWQP1SEND_V3_INLINE_LENGTH_MASK UINT32_C(0xf)
+	#define SQ_RAWQP1SEND_V3_INLINE_LENGTH_SFT 0
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * This value will be returned in the completion if the completion is
+	 * signaled.
 	 */
-	uint16_t	cmpl_ring;
+	uint32_t	opaque;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * All bits in this field must be valid on the first BD of a packet.
+	 * Their value on other BDs of the packet will be ignored.
 	 */
-	uint16_t	seq_id;
+	uint16_t	lflags;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * If set to 1, the controller replaces the TCP/UPD checksum
+	 * fields of normal TCP/UPD checksum, or the inner TCP/UDP
+	 * checksum field of the encapsulated TCP/UDP packets with the
+	 * hardware calculated TCP/UDP checksum for the packet associated
+	 * with this descriptor.
+	 *
+	 * This bit must be valid on the first BD of a packet.
 	 */
-	uint16_t	target_id;
+	#define SQ_RAWQP1SEND_V3_LFLAGS_TCP_UDP_CHKSUM	UINT32_C(0x1)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * If set to 1, the controller replaces the IP checksum of the
+	 * normal packets, or the inner IP checksum of the encapsulated
+	 * packets with the hardware calculated IP checksum for the
+	 * packet associated with this descriptor.
+	 *
+	 * This bit must be valid on the first BD of a packet.
 	 */
-	uint64_t	resp_addr;
-	/* Directory Entry Type, to be verified. */
-	uint16_t	dir_type;
+	#define SQ_RAWQP1SEND_V3_LFLAGS_IP_CHKSUM	UINT32_C(0x2)
 	/*
-	 * Directory ordinal.
-	 * The instance of the Directory Type to be verified.
+	 * If set to 1, the controller will not append an Ethernet CRC
+	 * to the end of the frame.
+	 *
+	 * This bit must be valid on the first BD of a packet.
+	 *
+	 * Packet must be 64B or longer when this flag is set. It is not
+	 * useful to use this bit with any form of TX offload such as
+	 * CSO or LSO. The intent is that the packet from the host already
+	 * has a valid Ethernet CRC on the packet.
 	 */
-	uint16_t	dir_ordinal;
+	#define SQ_RAWQP1SEND_V3_LFLAGS_NOCRC		UINT32_C(0x4)
 	/*
-	 * The Directory Entry Extension flags.
-	 * The "UPDATE" extension flag must be set in this value.
-	 * A corresponding directory entry with the same type and ordinal values but *without*
-	 * the "UPDATE" extension flag must also exist. The other flags of the extension must
-	 * be identical between the active and update entries.
+	 * If set to 1, The controller replaces the tunnel IP checksum
+	 * field with hardware calculated IP checksum for the IP header
+	 * of the packet associated with this descriptor. In case of
+	 * VXLAN, the controller also replaces the outer header UDP
+	 * checksum with hardware calculated UDP checksum for the packet
+	 * associated with this descriptor.
 	 */
-	uint16_t	dir_ext;
-	uint8_t	unused_0[2];
-} hwrm_nvm_verify_update_input_t, *phwrm_nvm_verify_update_input_t;
-
-/* hwrm_nvm_verify_update_output (size:128b/16B) */
-
-typedef struct hwrm_nvm_verify_update_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	#define SQ_RAWQP1SEND_V3_LFLAGS_T_IP_CHKSUM	UINT32_C(0x10)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * If set to 1, The controller replaces the Outer-tunnel IP
+	 * checksum field with hardware calculated IP checksum for the IP
+	 * header of the packet associated with this descriptor.
+	 *
+	 * For outer UDP checksum, it will be the following behavior for
+	 * all cases independent of settings of inner LSO and checksum
+	 * offload BD flags:
+	 *
+	 * - If outer UDP checksum is 0, then do not update it.
+	 * - If outer UDP checksum is non zero, then the hardware should
+	 *   compute and update it.
 	 */
-	uint8_t	valid;
-} hwrm_nvm_verify_update_output_t, *phwrm_nvm_verify_update_output_t;
-
-/***************************
- * hwrm_nvm_install_update *
- ***************************/
-
-
-/* hwrm_nvm_install_update_input (size:192b/24B) */
-
-typedef struct hwrm_nvm_install_update_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define SQ_RAWQP1SEND_V3_LFLAGS_OT_IP_CHKSUM	UINT32_C(0x20)
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * If set to '1', then the RoCE ICRC will be appended to the
+	 * packet. Packet must be a valid RoCE format packet.
 	 */
-	uint16_t	cmpl_ring;
+	#define SQ_RAWQP1SEND_V3_LFLAGS_ROCE_CRC	UINT32_C(0x100)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * If set to '1', then the FCoE CRC will be appended to the
+	 * packet. Packet must be a valid FCoE format packet.
 	 */
-	uint16_t	seq_id;
+	#define SQ_RAWQP1SEND_V3_LFLAGS_FCOE_CRC	UINT32_C(0x200)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * This value selects a CFA action to perform on the packet.
+	 * Set this value to zero if no CFA action is desired.
+	 *
+	 * This value must be valid on the first BD of a packet.
 	 */
-	uint16_t	target_id;
+	uint16_t	cfa_action;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * This value selects a CFA action to perform on the packet.
+	 * Set this value to zero if no CFA action is desired.
+	 *
+	 * This value must be valid on the first BD of a packet.
 	 */
-	uint64_t	resp_addr;
+	uint16_t	cfa_action_high;
 	/*
-	 * Installation type. If the value 3 through 0xffff is used,
-	 * only packaged items with that type value will be installed and
-	 * conditional installation directives for those packaged items
-	 * will be over-ridden (i.e. 'create' or 'replace' will be treated
-	 * as 'install').
+	 * This value selects bits 25:16 of the CFA action to perform on
+	 * the packet. See the cfa_action field for more information.
 	 */
-	uint32_t	install_type;
+	#define SQ_RAWQP1SEND_V3_CFA_ACTION_HIGH_MASK UINT32_C(0x3ff)
+	#define SQ_RAWQP1SEND_V3_CFA_ACTION_HIGH_SFT 0
+	uint16_t	reserved_2;
 	/*
-	 * Perform a normal package installation. Conditional installation
-	 * directives (e.g. 'create' and 'replace') of packaged items
-	 * will be followed.
+	 * This value is action meta-data that defines CFA edit operations
+	 * that are done in addition to any action editing.
 	 */
-	#define HWRM_NVM_INSTALL_UPDATE_INPUT_INSTALL_TYPE_NORMAL UINT32_C(0x0)
+	uint32_t	cfa_meta;
+	/* When key=1, This is the VLAN tag VID value. */
+	#define SQ_RAWQP1SEND_V3_CFA_META_VLAN_VID_MASK	UINT32_C(0xfff)
+	#define SQ_RAWQP1SEND_V3_CFA_META_VLAN_VID_SFT	0
+	/* When key=1, This is the VLAN tag DE value. */
+	#define SQ_RAWQP1SEND_V3_CFA_META_VLAN_DE	UINT32_C(0x1000)
+	/* When key=1, This is the VLAN tag PRI value. */
+	#define SQ_RAWQP1SEND_V3_CFA_META_VLAN_PRI_MASK	UINT32_C(0xe000)
+	#define SQ_RAWQP1SEND_V3_CFA_META_VLAN_PRI_SFT	13
+	/* When key=1, This is the VLAN tag TPID select value. */
+	#define SQ_RAWQP1SEND_V3_CFA_META_VLAN_TPID_MASK	UINT32_C(0x70000)
+	#define SQ_RAWQP1SEND_V3_CFA_META_VLAN_TPID_SFT	16
+	/* 0x88a8 */
+		#define SQ_RAWQP1SEND_V3_CFA_META_VLAN_TPID_TPID88A8  (UINT32_C(0x0) << 16)
+	/* 0x8100 */
+		#define SQ_RAWQP1SEND_V3_CFA_META_VLAN_TPID_TPID8100  (UINT32_C(0x1) << 16)
+	/* 0x9100 */
+		#define SQ_RAWQP1SEND_V3_CFA_META_VLAN_TPID_TPID9100  (UINT32_C(0x2) << 16)
+	/* 0x9200 */
+		#define SQ_RAWQP1SEND_V3_CFA_META_VLAN_TPID_TPID9200  (UINT32_C(0x3) << 16)
+	/* 0x9300 */
+		#define SQ_RAWQP1SEND_V3_CFA_META_VLAN_TPID_TPID9300  (UINT32_C(0x4) << 16)
+	/* Value programmed in CFA VLANTPID register. */
+		#define SQ_RAWQP1SEND_V3_CFA_META_VLAN_TPID_TPIDCFG   (UINT32_C(0x5) << 16)
+		#define SQ_RAWQP1SEND_V3_CFA_META_VLAN_TPID_LAST	SQ_RAWQP1SEND_V3_CFA_META_VLAN_TPID_TPIDCFG
+	/* When key=1, This is the VLAN tag TPID select value. */
+	#define SQ_RAWQP1SEND_V3_CFA_META_VLAN_RESERVED_MASK UINT32_C(0xff80000)
+	#define SQ_RAWQP1SEND_V3_CFA_META_VLAN_RESERVED_SFT 19
 	/*
-	 * Install all packaged items regardless of installation directive
-	 * (i.e. treat all packaged items as though they have an installation
-	 * directive of 'install').
+	 * This field identifies the type of edit to be performed
+	 * on the packet.
+	 *
+	 * This value must be valid on the first BD of a packet.
 	 */
-	#define HWRM_NVM_INSTALL_UPDATE_INPUT_INSTALL_TYPE_ALL	UINT32_C(0xffffffff)
-	#define HWRM_NVM_INSTALL_UPDATE_INPUT_INSTALL_TYPE_LAST  HWRM_NVM_INSTALL_UPDATE_INPUT_INSTALL_TYPE_ALL
-	uint16_t	flags;
-	/* If set to 1, then securely erase all unused locations in persistent storage. */
-	#define HWRM_NVM_INSTALL_UPDATE_INPUT_FLAGS_ERASE_UNUSED_SPACE	UINT32_C(0x1)
+	#define SQ_RAWQP1SEND_V3_CFA_META_KEY_MASK	UINT32_C(0xf0000000)
+	#define SQ_RAWQP1SEND_V3_CFA_META_KEY_SFT	28
+	/* No editing */
+		#define SQ_RAWQP1SEND_V3_CFA_META_KEY_NONE		(UINT32_C(0x0) << 28)
 	/*
-	 * If set to 1, then unspecified images, images not in the package file, will be safely deleted.
-	 * When combined with erase_unused_space then unspecified images will be securely erased.
+	 * - meta[17:16] - TPID select value (0 = 0x8100).
+	 * - meta[15:12] - PRI/DE value.
+	 * - meta[11:0] - VID value.
 	 */
-	#define HWRM_NVM_INSTALL_UPDATE_INPUT_FLAGS_REMOVE_UNUSED_PKG	UINT32_C(0x2)
+		#define SQ_RAWQP1SEND_V3_CFA_META_KEY_VLAN_TAG	(UINT32_C(0x1) << 28)
+		#define SQ_RAWQP1SEND_V3_CFA_META_KEY_LAST	SQ_RAWQP1SEND_V3_CFA_META_KEY_VLAN_TAG
+	uint32_t	timestamp;
 	/*
-	 * If set to 1, FW will defragment the NVM if defragmentation is required for the update.
-	 * Allow additional time for this command to complete if this bit is set to 1.
+	 * This field specifies a 24-bit timestamp that can be passed
+	 * down the TX path and optionally logged in the TXP timestamp
+	 * histogram.
 	 */
-	#define HWRM_NVM_INSTALL_UPDATE_INPUT_FLAGS_ALLOWED_TO_DEFRAG	UINT32_C(0x4)
+	#define SQ_RAWQP1SEND_V3_TIMESTAMP_MASK UINT32_C(0xffffff)
+	#define SQ_RAWQP1SEND_V3_TIMESTAMP_SFT 0
+	uint64_t	reserved_3;
 	/*
-	 * If set to 1, FW will verify the package in the "UPDATE" NVM item
-	 * without installing it. This flag is for FW internal use only.
-	 * Users should not set this flag. The request will otherwise fail.
+	 * When inline=0, then this area is filled with from 1 to 6 SGEs
+	 * based on the wqe_size field.
+	 *
+	 * When inline=1, this area is filled with payload data for the
+	 * send. Length of data is described in the inline_length field.
+	 * Bits [7:0] of word 0 hold the first byte to go out on the wire.
 	 */
-	#define HWRM_NVM_INSTALL_UPDATE_INPUT_FLAGS_VERIFY_ONLY		UINT32_C(0x8)
-	uint8_t	unused_0[2];
-} hwrm_nvm_install_update_input_t, *phwrm_nvm_install_update_input_t;
+	uint32_t	data[24];
+} sq_rawqp1send_v3_t, *psq_rawqp1send_v3_t;
 
-/* hwrm_nvm_install_update_output (size:192b/24B) */
+/* SQ WQE V3 structure for Raw Ethernet and QP1 SQs. */
+/* sq_rawqp1send_hdr_v3 (size:256b/32B) */
 
-typedef struct hwrm_nvm_install_update_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
+typedef struct sq_rawqp1send_hdr_v3 {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
+	/* RawEth/QP1 Send V3 */
+	#define SQ_RAWQP1SEND_HDR_V3_WQE_TYPE_RAWQP1SEND_V3 UINT32_C(0x1d)
+	#define SQ_RAWQP1SEND_HDR_V3_WQE_TYPE_LAST	SQ_RAWQP1SEND_HDR_V3_WQE_TYPE_RAWQP1SEND_V3
+	uint8_t	flags;
 	/*
-	 * Bit-mask of successfully installed items.
-	 * Bit-0 corresponding to the first packaged item, Bit-1 for the second item, etc.
-	 * A value of 0 indicates that no items were successfully installed.
+	 * Set if completion signaling is requested. If this bit is
+	 * 0, and the SQ is configured to support Unsignaled completion
+	 * the controller should not generate a CQE unless there was
+	 * an error. This refers to the CQE on the sender side. (The se
+	 * flag refers to the receiver side).
 	 */
-	uint64_t	installed_items;
-	/* result is 8 b */
-	uint8_t	result;
-	/* There was no problem with the package installation. */
-	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESULT_SUCCESS UINT32_C(0x0)
-	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESULT_LAST   HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESULT_SUCCESS
-	/* problem_item is 8 b */
-	uint8_t	problem_item;
-	/* There was no problem with any packaged items. */
-	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_PROBLEM_ITEM_NONE	UINT32_C(0x0)
-	/* There was a problem with the NVM package itself. */
-	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_PROBLEM_ITEM_PACKAGE UINT32_C(0xff)
-	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_PROBLEM_ITEM_LAST   HWRM_NVM_INSTALL_UPDATE_OUTPUT_PROBLEM_ITEM_PACKAGE
-	/* reset_required is 8 b */
-	uint8_t	reset_required;
+	#define SQ_RAWQP1SEND_HDR_V3_FLAGS_SIGNAL_COMP		UINT32_C(0x1)
 	/*
-	 * No reset is required for installed/updated firmware or
-	 * microcode to take effect.
+	 * Indication to complete all previous RDMA Read or Atomic WQEs
+	 * on the SQ before executing this WQE.
+	 *
+	 * This flag must be zero for a QP1 send.
 	 */
-	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESET_REQUIRED_NONE  UINT32_C(0x0)
+	#define SQ_RAWQP1SEND_HDR_V3_FLAGS_RD_OR_ATOMIC_FENCE	UINT32_C(0x2)
 	/*
-	 * A PCIe reset (e.g. system reboot) is
-	 * required for newly installed/updated firmware or
-	 * microcode to take effect.
+	 * Unconditional fence. Indication to complete all
+	 * previous SQ's WQEs before executing this WQE.
+	 *
+	 * This flag must be zero for a QP1 send.
 	 */
-	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESET_REQUIRED_PCI   UINT32_C(0x1)
+	#define SQ_RAWQP1SEND_HDR_V3_FLAGS_UC_FENCE		UINT32_C(0x4)
 	/*
-	 * A controller power reset (e.g. system power-cycle) is
-	 * required for newly installed/updated firmware or
-	 * microcode to take effect. Some newly installed/updated
-	 * firmware or microcode may still take effect upon the
-	 * next PCIe reset.
+	 * Solicit event flag. Indication sent in BTH header to the
+	 * receiver to generate a Completion Event Notification, i.e.
+	 * CNQE.
+	 *
+	 * This flag must be zero for a QP1 send.
 	 */
-	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESET_REQUIRED_POWER UINT32_C(0x2)
-	#define HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESET_REQUIRED_LAST HWRM_NVM_INSTALL_UPDATE_OUTPUT_RESET_REQUIRED_POWER
-	uint8_t	unused_0[4];
+	#define SQ_RAWQP1SEND_HDR_V3_FLAGS_SE			UINT32_C(0x8)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * Indicate that inline data is posted to the SQ in the data
+	 * area of this WQE.
 	 */
-	uint8_t	valid;
-} hwrm_nvm_install_update_output_t, *phwrm_nvm_install_update_output_t;
-
-/* hwrm_nvm_install_update_cmd_err (size:64b/8B) */
-
-typedef struct hwrm_nvm_install_update_cmd_err {
+	#define SQ_RAWQP1SEND_HDR_V3_FLAGS_INLINE		UINT32_C(0x10)
 	/*
-	 * command specific error codes that goes to
-	 * the cmd_err field in Common HWRM Error Response.
+	 * If set to 1, then the timestamp from the WQE is used. If
+	 * cleared to 0, then TWE provides the timestamp.
 	 */
-	uint8_t	code;
-	/* Unknown error */
-	#define HWRM_NVM_INSTALL_UPDATE_CMD_ERR_CODE_UNKNOWN  UINT32_C(0x0)
-	/* Unable to complete operation due to fragmentation */
-	#define HWRM_NVM_INSTALL_UPDATE_CMD_ERR_CODE_FRAG_ERR UINT32_C(0x1)
-	/* nvm is completely full. */
-	#define HWRM_NVM_INSTALL_UPDATE_CMD_ERR_CODE_NO_SPACE UINT32_C(0x2)
-	#define HWRM_NVM_INSTALL_UPDATE_CMD_ERR_CODE_LAST	HWRM_NVM_INSTALL_UPDATE_CMD_ERR_CODE_NO_SPACE
-	uint8_t	unused_0[7];
-} hwrm_nvm_install_update_cmd_err_t, *phwrm_nvm_install_update_cmd_err_t;
-
-/******************
- * hwrm_nvm_flush *
- ******************/
-
-
-/* hwrm_nvm_flush_input (size:128b/16B) */
-
-typedef struct hwrm_nvm_flush_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define SQ_RAWQP1SEND_HDR_V3_FLAGS_WQE_TS_EN		UINT32_C(0x20)
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * When set to '1', this operation will cause a trace capture in
+	 * each block it passes through.
 	 */
-	uint16_t	cmpl_ring;
+	#define SQ_RAWQP1SEND_HDR_V3_FLAGS_DEBUG_TRACE		UINT32_C(0x40)
+	/*  */
+	uint8_t	wqe_size;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * The number of 16 bytes chunks of data including this first
+	 * word of the request that are a valid part of the request. The
+	 * valid 16 bytes units other than the WQE structure can be
+	 * SGEs (Scatter Gather Elements) OR inline data.
+	 *
+	 * This field shall never exceed 32 for WQEs of this type.
+	 */
+	#define SQ_RAWQP1SEND_HDR_V3_WQE_SIZE_MASK UINT32_C(0x3f)
+	#define SQ_RAWQP1SEND_HDR_V3_WQE_SIZE_SFT 0
+	uint8_t	inline_length;
+	/*
+	 * When inline flag is '1', this field determines the number of
+	 * bytes that are valid in the last 16B unit of the inline WQE.
+	 * Zero means all 16 bytes are valid. One means only bits 7:0 of
+	 * the last 16B unit are valid. This means the total size of the
+	 * inline data is determined by a combination of the wqe_size field
+	 * and this inline_length field.
+	 *
+	 * `inline_size = ((wqe_size - 1) * 16) - data_offset_in_bytes +
+	 * ((inline_length == 0 ) ? 16 : inline_length)
+	 *
+	 * Where data_offset_in_bytes is the offset within the WQE where
+	 * the data field starts.
+	 *
+	 * Note that this field is not applicable for zero-length inline
+	 * WQEs.
 	 */
-	uint16_t	seq_id;
+	#define SQ_RAWQP1SEND_HDR_V3_INLINE_LENGTH_MASK UINT32_C(0xf)
+	#define SQ_RAWQP1SEND_HDR_V3_INLINE_LENGTH_SFT 0
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * This value will be returned in the completion if the completion is
+	 * signaled.
 	 */
-	uint16_t	target_id;
+	uint32_t	opaque;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * All bits in this field must be valid on the first BD of a packet.
+	 * Their value on other BDs of the packet will be ignored.
 	 */
-	uint64_t	resp_addr;
-} hwrm_nvm_flush_input_t, *phwrm_nvm_flush_input_t;
-
-/* hwrm_nvm_flush_output (size:128b/16B) */
-
-typedef struct hwrm_nvm_flush_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	uint16_t	lflags;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * If set to 1, the controller replaces the TCP/UPD checksum
+	 * fields of normal TCP/UPD checksum, or the inner TCP/UDP
+	 * checksum field of the encapsulated TCP/UDP packets with the
+	 * hardware calculated TCP/UDP checksum for the packet associated
+	 * with this descriptor.
+	 *
+	 * This bit must be valid on the first BD of a packet.
 	 */
-	uint8_t	valid;
-} hwrm_nvm_flush_output_t, *phwrm_nvm_flush_output_t;
-
-/* hwrm_nvm_flush_cmd_err (size:64b/8B) */
-
-typedef struct hwrm_nvm_flush_cmd_err {
+	#define SQ_RAWQP1SEND_HDR_V3_LFLAGS_TCP_UDP_CHKSUM	UINT32_C(0x1)
 	/*
-	 * command specific error codes that goes to
-	 * the cmd_err field in Common HWRM Error Response.
+	 * If set to 1, the controller replaces the IP checksum of the
+	 * normal packets, or the inner IP checksum of the encapsulated
+	 * packets with the hardware calculated IP checksum for the
+	 * packet associated with this descriptor.
+	 *
+	 * This bit must be valid on the first BD of a packet.
 	 */
-	uint8_t	code;
-	/* Unknown error */
-	#define HWRM_NVM_FLUSH_CMD_ERR_CODE_UNKNOWN UINT32_C(0x0)
-	/* flush could not be performed */
-	#define HWRM_NVM_FLUSH_CMD_ERR_CODE_FAIL	UINT32_C(0x1)
-	#define HWRM_NVM_FLUSH_CMD_ERR_CODE_LAST   HWRM_NVM_FLUSH_CMD_ERR_CODE_FAIL
-	uint8_t	unused_0[7];
-} hwrm_nvm_flush_cmd_err_t, *phwrm_nvm_flush_cmd_err_t;
-
-/*************************
- * hwrm_nvm_get_variable *
- *************************/
-
-
-/* hwrm_nvm_get_variable_input (size:320b/40B) */
-
-typedef struct hwrm_nvm_get_variable_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define SQ_RAWQP1SEND_HDR_V3_LFLAGS_IP_CHKSUM	UINT32_C(0x2)
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * If set to 1, the controller will not append an Ethernet CRC
+	 * to the end of the frame.
+	 *
+	 * This bit must be valid on the first BD of a packet.
+	 *
+	 * Packet must be 64B or longer when this flag is set. It is not
+	 * useful to use this bit with any form of TX offload such as
+	 * CSO or LSO. The intent is that the packet from the host already
+	 * has a valid Ethernet CRC on the packet.
 	 */
-	uint16_t	cmpl_ring;
+	#define SQ_RAWQP1SEND_HDR_V3_LFLAGS_NOCRC		UINT32_C(0x4)
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * If set to 1, The controller replaces the tunnel IP checksum
+	 * field with hardware calculated IP checksum for the IP header
+	 * of the packet associated with this descriptor. In case of
+	 * VXLAN, the controller also replaces the outer header UDP
+	 * checksum with hardware calculated UDP checksum for the packet
+	 * associated with this descriptor.
 	 */
-	uint16_t	seq_id;
+	#define SQ_RAWQP1SEND_HDR_V3_LFLAGS_T_IP_CHKSUM	UINT32_C(0x10)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * If set to 1, The controller replaces the Outer-tunnel IP
+	 * checksum field with hardware calculated IP checksum for the IP
+	 * header of the packet associated with this descriptor.
+	 *
+	 * For outer UDP checksum, it will be the following behavior for
+	 * all cases independent of settings of inner LSO and checksum
+	 * offload BD flags:
+	 *
+	 * - If outer UDP checksum is 0, then do not update it.
+	 * - If outer UDP checksum is non zero, then the hardware should
+	 *   compute and update it.
+	 */
+	#define SQ_RAWQP1SEND_HDR_V3_LFLAGS_OT_IP_CHKSUM	UINT32_C(0x20)
+	/*
+	 * If set to '1', then the RoCE ICRC will be appended to the
+	 * packet. Packet must be a valid RoCE format packet.
+	 */
+	#define SQ_RAWQP1SEND_HDR_V3_LFLAGS_ROCE_CRC	UINT32_C(0x100)
+	/*
+	 * If set to '1', then the FCoE CRC will be appended to the
+	 * packet. Packet must be a valid FCoE format packet.
+	 */
+	#define SQ_RAWQP1SEND_HDR_V3_LFLAGS_FCOE_CRC	UINT32_C(0x200)
+	/*
+	 * This value selects a CFA action to perform on the packet.
+	 * Set this value to zero if no CFA action is desired.
+	 *
+	 * This value must be valid on the first BD of a packet.
 	 */
-	uint16_t	target_id;
+	uint16_t	cfa_action;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * This value selects a CFA action to perform on the packet.
+	 * Set this value to zero if no CFA action is desired.
+	 *
+	 * This value must be valid on the first BD of a packet.
 	 */
-	uint64_t	resp_addr;
+	uint16_t	cfa_action_high;
 	/*
-	 * This is the host address where
-	 * nvm variable will be stored
+	 * This value selects bits 25:16 of the CFA action to perform on
+	 * the packet. See the cfa_action field for more information.
 	 */
-	uint64_t	dest_data_addr;
-	/* size of data in bits */
-	uint16_t	data_len;
-	/* nvm cfg option number */
-	uint16_t	option_num;
-	/* reserved. */
-	#define HWRM_NVM_GET_VARIABLE_INPUT_OPTION_NUM_RSVD_0	UINT32_C(0x0)
-	/* reserved. */
-	#define HWRM_NVM_GET_VARIABLE_INPUT_OPTION_NUM_RSVD_FFFF UINT32_C(0xffff)
-	#define HWRM_NVM_GET_VARIABLE_INPUT_OPTION_NUM_LAST	HWRM_NVM_GET_VARIABLE_INPUT_OPTION_NUM_RSVD_FFFF
+	#define SQ_RAWQP1SEND_HDR_V3_CFA_ACTION_HIGH_MASK UINT32_C(0x3ff)
+	#define SQ_RAWQP1SEND_HDR_V3_CFA_ACTION_HIGH_SFT 0
+	uint16_t	reserved_2;
 	/*
-	 * Number of dimensions for this nvm configuration variable.
-	 * This value indicates how many of the indexN values to use.
-	 * A value of 0 means that none of the indexN values are valid.
-	 * A value of 1 requires at index0 is valued, a value of 2
-	 * requires that index0 and index1 are valid, and so forth
+	 * This value is action meta-data that defines CFA edit operations
+	 * that are done in addition to any action editing.
 	 */
-	uint16_t	dimensions;
-	/* index for the 1st dimensions */
-	uint16_t	index_0;
-	/* index for the 2nd dimensions */
-	uint16_t	index_1;
-	/* index for the 3rd dimensions */
-	uint16_t	index_2;
-	/* index for the 4th dimensions */
-	uint16_t	index_3;
-	uint8_t	flags;
+	uint32_t	cfa_meta;
+	/* When key=1, This is the VLAN tag VID value. */
+	#define SQ_RAWQP1SEND_HDR_V3_CFA_META_VLAN_VID_MASK	UINT32_C(0xfff)
+	#define SQ_RAWQP1SEND_HDR_V3_CFA_META_VLAN_VID_SFT	0
+	/* When key=1, This is the VLAN tag DE value. */
+	#define SQ_RAWQP1SEND_HDR_V3_CFA_META_VLAN_DE	UINT32_C(0x1000)
+	/* When key=1, This is the VLAN tag PRI value. */
+	#define SQ_RAWQP1SEND_HDR_V3_CFA_META_VLAN_PRI_MASK	UINT32_C(0xe000)
+	#define SQ_RAWQP1SEND_HDR_V3_CFA_META_VLAN_PRI_SFT	13
+	/* When key=1, This is the VLAN tag TPID select value. */
+	#define SQ_RAWQP1SEND_HDR_V3_CFA_META_VLAN_TPID_MASK	UINT32_C(0x70000)
+	#define SQ_RAWQP1SEND_HDR_V3_CFA_META_VLAN_TPID_SFT	16
+	/* 0x88a8 */
+		#define SQ_RAWQP1SEND_HDR_V3_CFA_META_VLAN_TPID_TPID88A8  (UINT32_C(0x0) << 16)
+	/* 0x8100 */
+		#define SQ_RAWQP1SEND_HDR_V3_CFA_META_VLAN_TPID_TPID8100  (UINT32_C(0x1) << 16)
+	/* 0x9100 */
+		#define SQ_RAWQP1SEND_HDR_V3_CFA_META_VLAN_TPID_TPID9100  (UINT32_C(0x2) << 16)
+	/* 0x9200 */
+		#define SQ_RAWQP1SEND_HDR_V3_CFA_META_VLAN_TPID_TPID9200  (UINT32_C(0x3) << 16)
+	/* 0x9300 */
+		#define SQ_RAWQP1SEND_HDR_V3_CFA_META_VLAN_TPID_TPID9300  (UINT32_C(0x4) << 16)
+	/* Value programmed in CFA VLANTPID register. */
+		#define SQ_RAWQP1SEND_HDR_V3_CFA_META_VLAN_TPID_TPIDCFG   (UINT32_C(0x5) << 16)
+		#define SQ_RAWQP1SEND_HDR_V3_CFA_META_VLAN_TPID_LAST	SQ_RAWQP1SEND_HDR_V3_CFA_META_VLAN_TPID_TPIDCFG
+	/* When key=1, This is the VLAN tag TPID select value. */
+	#define SQ_RAWQP1SEND_HDR_V3_CFA_META_VLAN_RESERVED_MASK UINT32_C(0xff80000)
+	#define SQ_RAWQP1SEND_HDR_V3_CFA_META_VLAN_RESERVED_SFT 19
 	/*
-	 * When this bit is set to 1, the factory default value will be returned,
-	 * 0 returns the operational value.
+	 * This field identifies the type of edit to be performed
+	 * on the packet.
+	 *
+	 * This value must be valid on the first BD of a packet.
 	 */
-	#define HWRM_NVM_GET_VARIABLE_INPUT_FLAGS_FACTORY_DFLT	UINT32_C(0x1)
-	uint8_t	unused_0;
-} hwrm_nvm_get_variable_input_t, *phwrm_nvm_get_variable_input_t;
-
-/* hwrm_nvm_get_variable_output (size:128b/16B) */
-
-typedef struct hwrm_nvm_get_variable_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	/* size of data of the actual variable retrieved in bits */
-	uint16_t	data_len;
+	#define SQ_RAWQP1SEND_HDR_V3_CFA_META_KEY_MASK	UINT32_C(0xf0000000)
+	#define SQ_RAWQP1SEND_HDR_V3_CFA_META_KEY_SFT	28
+	/* No editing */
+		#define SQ_RAWQP1SEND_HDR_V3_CFA_META_KEY_NONE		(UINT32_C(0x0) << 28)
 	/*
-	 * option_num is the option number for the data retrieved.  It is possible in the
-	 * future that the option number returned would be different than requested.  This
-	 * condition could occur if an option is deprecated and a new option id is defined
-	 * with similar characteristics, but has a slightly different definition.  This
-	 * also makes it convenient for the caller to identify the variable result with
-	 * the option id from the response.
+	 * - meta[17:16] - TPID select value (0 = 0x8100).
+	 * - meta[15:12] - PRI/DE value.
+	 * - meta[11:0] - VID value.
 	 */
-	uint16_t	option_num;
-	/* reserved. */
-	#define HWRM_NVM_GET_VARIABLE_OUTPUT_OPTION_NUM_RSVD_0	UINT32_C(0x0)
-	/* reserved. */
-	#define HWRM_NVM_GET_VARIABLE_OUTPUT_OPTION_NUM_RSVD_FFFF UINT32_C(0xffff)
-	#define HWRM_NVM_GET_VARIABLE_OUTPUT_OPTION_NUM_LAST	HWRM_NVM_GET_VARIABLE_OUTPUT_OPTION_NUM_RSVD_FFFF
-	uint8_t	unused_0[3];
+		#define SQ_RAWQP1SEND_HDR_V3_CFA_META_KEY_VLAN_TAG	(UINT32_C(0x1) << 28)
+		#define SQ_RAWQP1SEND_HDR_V3_CFA_META_KEY_LAST	SQ_RAWQP1SEND_HDR_V3_CFA_META_KEY_VLAN_TAG
+	uint32_t	timestamp;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * This field specifies a 24-bit timestamp that can be passed
+	 * down the TX path and optionally logged in the TXP timestamp
+	 * histogram.
 	 */
-	uint8_t	valid;
-} hwrm_nvm_get_variable_output_t, *phwrm_nvm_get_variable_output_t;
+	#define SQ_RAWQP1SEND_HDR_V3_TIMESTAMP_MASK UINT32_C(0xffffff)
+	#define SQ_RAWQP1SEND_HDR_V3_TIMESTAMP_SFT 0
+	uint64_t	reserved_3;
+} sq_rawqp1send_hdr_v3_t, *psq_rawqp1send_hdr_v3_t;
 
-/* hwrm_nvm_get_variable_cmd_err (size:64b/8B) */
+/* SQ Send WQE V3 for UD SQs. */
+/* sq_udsend_v3 (size:1024b/128B) */
 
-typedef struct hwrm_nvm_get_variable_cmd_err {
+typedef struct sq_udsend_v3 {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
 	/*
-	 * command specific error codes that goes to
-	 * the cmd_err field in Common HWRM Error Response.
+	 * UD Send V3
+	 *
+	 * Allowed only on unreliable datagram (UD) SQs.
 	 */
-	uint8_t	code;
-	/* Unknown error */
-	#define HWRM_NVM_GET_VARIABLE_CMD_ERR_CODE_UNKNOWN	UINT32_C(0x0)
-	/* variable does not exist */
-	#define HWRM_NVM_GET_VARIABLE_CMD_ERR_CODE_VAR_NOT_EXIST UINT32_C(0x1)
-	/* configuration is corrupted and the variable cannot be saved */
-	#define HWRM_NVM_GET_VARIABLE_CMD_ERR_CODE_CORRUPT_VAR   UINT32_C(0x2)
-	/* length specified is too small */
-	#define HWRM_NVM_GET_VARIABLE_CMD_ERR_CODE_LEN_TOO_SHORT UINT32_C(0x3)
-	#define HWRM_NVM_GET_VARIABLE_CMD_ERR_CODE_LAST	HWRM_NVM_GET_VARIABLE_CMD_ERR_CODE_LEN_TOO_SHORT
-	uint8_t	unused_0[7];
-} hwrm_nvm_get_variable_cmd_err_t, *phwrm_nvm_get_variable_cmd_err_t;
-
-/*************************
- * hwrm_nvm_set_variable *
- *************************/
-
-
-/* hwrm_nvm_set_variable_input (size:320b/40B) */
-
-typedef struct hwrm_nvm_set_variable_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define SQ_UDSEND_V3_WQE_TYPE_UDSEND_V3	UINT32_C(0x13)
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * UD Send with Immediate V3
+	 *
+	 * Allowed only on unreliable datagram (UD) SQs.
 	 */
-	uint16_t	cmpl_ring;
+	#define SQ_UDSEND_V3_WQE_TYPE_UDSEND_W_IMMED_V3 UINT32_C(0x14)
+	#define SQ_UDSEND_V3_WQE_TYPE_LAST		SQ_UDSEND_V3_WQE_TYPE_UDSEND_W_IMMED_V3
+	uint8_t	flags;
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * Set if completion signaling is requested. If this bit is
+	 * 0, and the SQ is configured to support Unsignaled completion
+	 * the controller should not generate a CQE unless there was
+	 * an error. This refers to the CQE on the sender side. (The se
+	 * flag refers to the receiver side).
 	 */
-	uint16_t	seq_id;
+	#define SQ_UDSEND_V3_FLAGS_SIGNAL_COMP		UINT32_C(0x1)
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Indication to complete all previous RDMA Read or Atomic WQEs
+	 * on the SQ before executing this WQE.
+	 *
+	 * This flag must be zero for a UD send.
 	 */
-	uint16_t	target_id;
+	#define SQ_UDSEND_V3_FLAGS_RD_OR_ATOMIC_FENCE	UINT32_C(0x2)
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * Unconditional fence. Indication to complete all
+	 * previous SQ's WQEs before executing this WQE.
+	 *
+	 * This flag must be zero for a UD send.
 	 */
-	uint64_t	resp_addr;
+	#define SQ_UDSEND_V3_FLAGS_UC_FENCE		UINT32_C(0x4)
 	/*
-	 * This is the host address where
-	 * nvm variable will be copied from
+	 * Solicit event flag. Indication sent in BTH header to the
+	 * receiver to generate a Completion Event Notification, i.e.
+	 * CNQE.
 	 */
-	uint64_t	src_data_addr;
-	/* size of data in bits */
-	uint16_t	data_len;
-	/* nvm cfg option number */
-	uint16_t	option_num;
-	/* reserved. */
-	#define HWRM_NVM_SET_VARIABLE_INPUT_OPTION_NUM_RSVD_0	UINT32_C(0x0)
-	/* reserved. */
-	#define HWRM_NVM_SET_VARIABLE_INPUT_OPTION_NUM_RSVD_FFFF UINT32_C(0xffff)
-	#define HWRM_NVM_SET_VARIABLE_INPUT_OPTION_NUM_LAST	HWRM_NVM_SET_VARIABLE_INPUT_OPTION_NUM_RSVD_FFFF
+	#define SQ_UDSEND_V3_FLAGS_SE			UINT32_C(0x8)
 	/*
-	 * Number of dimensions for this nvm configuration variable.
-	 * This value indicates how many of the indexN values to use.
-	 * A value of 0 means that none of the indexN values are valid.
-	 * A value of 1 requires at index0 is valued, a value of 2
-	 * requires that index0 and index1 are valid, and so forth
+	 * Indicate that inline data is posted to the SQ in the data
+	 * area of this WQE.
 	 */
-	uint16_t	dimensions;
-	/* index for the 1st dimensions */
-	uint16_t	index_0;
-	/* index for the 2nd dimensions */
-	uint16_t	index_1;
-	/* index for the 3rd dimensions */
-	uint16_t	index_2;
-	/* index for the 4th dimensions */
-	uint16_t	index_3;
-	uint8_t	flags;
-	/* When this bit is 1, flush internal cache after this write operation (see hwrm_nvm_flush command.) */
-	#define HWRM_NVM_SET_VARIABLE_INPUT_FLAGS_FORCE_FLUSH		UINT32_C(0x1)
-	/* encryption method */
-	#define HWRM_NVM_SET_VARIABLE_INPUT_FLAGS_ENCRYPT_MODE_MASK	UINT32_C(0xe)
-	#define HWRM_NVM_SET_VARIABLE_INPUT_FLAGS_ENCRYPT_MODE_SFT	1
-	/* No encryption. */
-		#define HWRM_NVM_SET_VARIABLE_INPUT_FLAGS_ENCRYPT_MODE_NONE		(UINT32_C(0x0) << 1)
-	/* one-way encryption. */
-		#define HWRM_NVM_SET_VARIABLE_INPUT_FLAGS_ENCRYPT_MODE_HMAC_SHA1	(UINT32_C(0x1) << 1)
-	/* symmetric AES256 encryption. */
-		#define HWRM_NVM_SET_VARIABLE_INPUT_FLAGS_ENCRYPT_MODE_AES256	(UINT32_C(0x2) << 1)
-	/* SHA1 digest appended to plaintext contents, for authentication */
-		#define HWRM_NVM_SET_VARIABLE_INPUT_FLAGS_ENCRYPT_MODE_HMAC_SHA1_AUTH  (UINT32_C(0x3) << 1)
-		#define HWRM_NVM_SET_VARIABLE_INPUT_FLAGS_ENCRYPT_MODE_LAST	HWRM_NVM_SET_VARIABLE_INPUT_FLAGS_ENCRYPT_MODE_HMAC_SHA1_AUTH
-	#define HWRM_NVM_SET_VARIABLE_INPUT_FLAGS_FLAGS_UNUSED_0_MASK	UINT32_C(0x70)
-	#define HWRM_NVM_SET_VARIABLE_INPUT_FLAGS_FLAGS_UNUSED_0_SFT	4
-	/* When this bit is 1, update the factory default region */
-	#define HWRM_NVM_SET_VARIABLE_INPUT_FLAGS_FACTORY_DEFAULT		UINT32_C(0x80)
-	uint8_t	unused_0;
-} hwrm_nvm_set_variable_input_t, *phwrm_nvm_set_variable_input_t;
-
-/* hwrm_nvm_set_variable_output (size:128b/16B) */
-
-typedef struct hwrm_nvm_set_variable_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	unused_0[7];
+	#define SQ_UDSEND_V3_FLAGS_INLINE		UINT32_C(0x10)
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * If set to 1, then the timestamp from the WQE is used. If
+	 * cleared to 0, then TWE provides the timestamp.
 	 */
-	uint8_t	valid;
-} hwrm_nvm_set_variable_output_t, *phwrm_nvm_set_variable_output_t;
-
-/* hwrm_nvm_set_variable_cmd_err (size:64b/8B) */
-
-typedef struct hwrm_nvm_set_variable_cmd_err {
+	#define SQ_UDSEND_V3_FLAGS_WQE_TS_EN		UINT32_C(0x20)
 	/*
-	 * command specific error codes that goes to
-	 * the cmd_err field in Common HWRM Error Response.
+	 * When set to '1', this operation will cause a trace capture in
+	 * each block it passes through.
 	 */
-	uint8_t	code;
-	/* Unknown error */
-	#define HWRM_NVM_SET_VARIABLE_CMD_ERR_CODE_UNKNOWN	UINT32_C(0x0)
-	/* variable does not exist */
-	#define HWRM_NVM_SET_VARIABLE_CMD_ERR_CODE_VAR_NOT_EXIST UINT32_C(0x1)
-	/* configuration is corrupted and the variable cannot be saved */
-	#define HWRM_NVM_SET_VARIABLE_CMD_ERR_CODE_CORRUPT_VAR   UINT32_C(0x2)
-	#define HWRM_NVM_SET_VARIABLE_CMD_ERR_CODE_LAST	HWRM_NVM_SET_VARIABLE_CMD_ERR_CODE_CORRUPT_VAR
-	uint8_t	unused_0[7];
-} hwrm_nvm_set_variable_cmd_err_t, *phwrm_nvm_set_variable_cmd_err_t;
-
-/****************************
- * hwrm_nvm_validate_option *
- ****************************/
-
-
-/* hwrm_nvm_validate_option_input (size:320b/40B) */
-
-typedef struct hwrm_nvm_validate_option_input {
-	/* The HWRM command request type. */
-	uint16_t	req_type;
+	#define SQ_UDSEND_V3_FLAGS_DEBUG_TRACE		UINT32_C(0x40)
+	/*  */
+	uint8_t	wqe_size;
 	/*
-	 * The completion ring to send the completion event on. This should
-	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 * The number of 16 bytes chunks of data including this first
+	 * word of the request that are a valid part of the request. The
+	 * valid 16 bytes units other than the WQE structure can be
+	 * SGEs (Scatter Gather Elements) OR inline data.
+	 *
+	 * This field shall never exceed 32 for WQEs of this type.
+	 */
+	#define SQ_UDSEND_V3_WQE_SIZE_MASK UINT32_C(0x3f)
+	#define SQ_UDSEND_V3_WQE_SIZE_SFT 0
+	uint8_t	inline_length;
+	/*
+	 * When inline flag is '1', this field determines the number of
+	 * bytes that are valid in the last 16B unit of the inline WQE.
+	 * Zero means all 16 bytes are valid. One means only bits 7:0 of
+	 * the last 16B unit are valid. This means the total size of the
+	 * inline data is determined by a combination of the wqe_size field
+	 * and this inline_length field.
+	 *
+	 * `inline_size = ((wqe_size - 1) * 16) - data_offset_in_bytes +
+	 * ((inline_length == 0 ) ? 16 : inline_length)
+	 *
+	 * Where data_offset_in_bytes is the offset within the WQE where
+	 * the data field starts.
+	 *
+	 * Note that this field is not applicable for zero-length inline
+	 * WQEs.
 	 */
-	uint16_t	cmpl_ring;
+	#define SQ_UDSEND_V3_INLINE_LENGTH_MASK UINT32_C(0xf)
+	#define SQ_UDSEND_V3_INLINE_LENGTH_SFT 0
 	/*
-	 * The sequence ID is used by the driver for tracking multiple
-	 * commands. This ID is treated as opaque data by the firmware and
-	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 * This value will be returned in the completion if the completion is
+	 * signaled.
 	 */
-	uint16_t	seq_id;
+	uint32_t	opaque;
 	/*
-	 * The target ID of the command:
-	 * * 0x0-0xFFF8 - The function ID
-	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
-	 * * 0xFFFD - Reserved for user-space HWRM interface
-	 * * 0xFFFF - HWRM
+	 * Immediate value that will be sent with ImmDt header if wqe_type is
+	 * UD Send with Immediate.
 	 */
-	uint16_t	target_id;
+	uint32_t	imm_data;
 	/*
-	 * A physical address pointer pointing to a host buffer that the
-	 * command's response data will be written. This can be either a host
-	 * physical address (HPA) or a guest physical address (GPA) and must
-	 * point to a physically contiguous block of memory.
+	 * When in the SQ of a UD QP, indicates the q_key to be used in
+	 * the transmitted packet. However, if the most significant bit
+	 * of this field is set, then the q_key will be taken from QP
+	 * context, rather than from this field.
+	 *
+	 * When in the SQ of a non-UD QP, this field is reserved and
+	 * should be filled with zeros.
 	 */
-	uint64_t	resp_addr;
+	uint32_t	q_key;
 	/*
-	 * This is the host address where
-	 * nvm variable will be copied from
+	 * When in the SQ of a UD QP, indicates the destination QP to be
+	 * used in the transmitted packet.
+	 *
+	 * When in the SQ of a non-UD QP, this field is reserved and
+	 * should be filled with zeros.
 	 */
-	uint64_t	src_data_addr;
-	/* size of data in bits */
-	uint16_t	data_len;
-	/* nvm cfg option number */
-	uint16_t	option_num;
-	/* reserved. */
-	#define HWRM_NVM_VALIDATE_OPTION_INPUT_OPTION_NUM_RSVD_0	UINT32_C(0x0)
-	/* reserved. */
-	#define HWRM_NVM_VALIDATE_OPTION_INPUT_OPTION_NUM_RSVD_FFFF UINT32_C(0xffff)
-	#define HWRM_NVM_VALIDATE_OPTION_INPUT_OPTION_NUM_LAST	HWRM_NVM_VALIDATE_OPTION_INPUT_OPTION_NUM_RSVD_FFFF
+	uint32_t	dst_qp;
+	#define SQ_UDSEND_V3_DST_QP_MASK UINT32_C(0xffffff)
+	#define SQ_UDSEND_V3_DST_QP_SFT 0
+	uint32_t	avid;
 	/*
-	 * Number of dimensions for this nvm configuration variable.
-	 * This value indicates how many of the indexN values to use.
-	 * A value of 0 means that none of the indexN values are valid.
-	 * A value of 1 requires at index0 is valued, a value of 2
-	 * requires that index0 and index1 are valid, and so forth
+	 * If the serv_type is 'UD', then this field supplies the AVID
+	 * (Address Vector ID).
 	 */
-	uint16_t	dimensions;
-	/* index for the 1st dimensions */
-	uint16_t	index_0;
-	/* index for the 2nd dimensions */
-	uint16_t	index_1;
-	/* index for the 3rd dimensions */
-	uint16_t	index_2;
-	/* index for the 4th dimensions */
-	uint16_t	index_3;
-	uint8_t	unused_0[2];
-} hwrm_nvm_validate_option_input_t, *phwrm_nvm_validate_option_input_t;
-
-/* hwrm_nvm_validate_option_output (size:128b/16B) */
-
-typedef struct hwrm_nvm_validate_option_output {
-	/* The specific error status for the command. */
-	uint16_t	error_code;
-	/* The HWRM command request type. */
-	uint16_t	req_type;
-	/* The sequence ID from the original command. */
-	uint16_t	seq_id;
-	/* The length of the response data in number of bytes. */
-	uint16_t	resp_len;
-	uint8_t	result;
-	/* indicates that the value provided for the option is not matching with the saved data. */
-	#define HWRM_NVM_VALIDATE_OPTION_OUTPUT_RESULT_NOT_MATCH UINT32_C(0x0)
-	/* indicates that the value provided for the option is matching the saved data. */
-	#define HWRM_NVM_VALIDATE_OPTION_OUTPUT_RESULT_MATCH	UINT32_C(0x1)
-	#define HWRM_NVM_VALIDATE_OPTION_OUTPUT_RESULT_LAST	HWRM_NVM_VALIDATE_OPTION_OUTPUT_RESULT_MATCH
-	uint8_t	unused_0[6];
+	#define SQ_UDSEND_V3_AVID_MASK UINT32_C(0x3ff)
+	#define SQ_UDSEND_V3_AVID_SFT 0
+	uint32_t	reserved2;
+	uint32_t	timestamp;
 	/*
-	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
-	 * the order of writes has to be such that this field is written last.
+	 * This field specifies a 24-bit timestamp that can be passed
+	 * down the TX path and optionally logged in the TXP timestamp
+	 * histogram.
 	 */
-	uint8_t	valid;
-} hwrm_nvm_validate_option_output_t, *phwrm_nvm_validate_option_output_t;
-
-/* hwrm_nvm_validate_option_cmd_err (size:64b/8B) */
-
-typedef struct hwrm_nvm_validate_option_cmd_err {
+	#define SQ_UDSEND_V3_TIMESTAMP_MASK UINT32_C(0xffffff)
+	#define SQ_UDSEND_V3_TIMESTAMP_SFT 0
 	/*
-	 * command specific error codes that goes to
-	 * the cmd_err field in Common HWRM Error Response.
+	 * When inline=0, then this area is filled with from 1 to 30 SGEs
+	 * based on the wqe_size field.
+	 *
+	 * When inline=1, this area is filled with payload data for the
+	 * send. Length of data is described in the inline_length field.
+	 * Bits [7:0] of word 0 hold the first byte to go out on the wire.
 	 */
-	uint8_t	code;
-	/* Unknown error */
-	#define HWRM_NVM_VALIDATE_OPTION_CMD_ERR_CODE_UNKNOWN UINT32_C(0x0)
-	#define HWRM_NVM_VALIDATE_OPTION_CMD_ERR_CODE_LAST   HWRM_NVM_VALIDATE_OPTION_CMD_ERR_CODE_UNKNOWN
-	uint8_t	unused_0[7];
-} hwrm_nvm_validate_option_cmd_err_t, *phwrm_nvm_validate_option_cmd_err_t;
-
-#define ROCE_SP_HSI_VERSION_MAJOR 1
-#define ROCE_SP_HSI_VERSION_MINOR 8
-#define ROCE_SP_HSI_VERSION_UPDATE 4
-#define ROCE_SP_HSI_VERSION_STR "1.8.4"
-/*
- * Following is the signature for ROCE_SP_HSI message field that indicates not
- * applicable (All F's). Need to cast it the size of the field if needed.
- */
-#define ROCE_SP_HSI_NA_SIGNATURE ((uint32_t)(-1))
-
-/* cmdq_init (size:128b/16B) */
-
-typedef struct cmdq_init {
-	/* CMDQ PBL physical address. */
-	uint64_t	cmdq_pbl;
-	uint16_t	cmdq_size_cmdq_lvl;
-	/* CMDQ PBL indirection levels. */
-	#define CMDQ_INIT_CMDQ_LVL_MASK UINT32_C(0x3)
-	#define CMDQ_INIT_CMDQ_LVL_SFT  0
-	/* CMDQ size. */
-	#define CMDQ_INIT_CMDQ_SIZE_MASK UINT32_C(0xfffc)
-	#define CMDQ_INIT_CMDQ_SIZE_SFT 2
-	/* CREQ completion ring id. */
-	uint16_t	creq_ring_id;
-	/* Mailbox producer index. MSB must also be set. */
-	uint32_t	prod_idx;
-} cmdq_init_t, *pcmdq_init_t;
-
-/* cmdq_update (size:128b/16B) */
-
-typedef struct cmdq_update {
-	/* reserved64 is 64 b */
-	uint64_t	reserved64;
-	/* reserved32 is 32 b */
-	uint32_t	reserved32;
-	/* Mailbox producer index. */
-	uint32_t	prod_idx;
-} cmdq_update_t, *pcmdq_update_t;
+	uint32_t	data[24];
+} sq_udsend_v3_t, *psq_udsend_v3_t;
 
-/* cmdq_base (size:128b/16B) */
+/* SQ WQE V3 header for UD SQs. */
+/* sq_udsend_hdr_v3 (size:256b/32B) */
 
-typedef struct cmdq_base {
-	/* Command opcode. */
-	uint8_t	opcode;
+typedef struct sq_udsend_hdr_v3 {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
 	/*
-	 * Create QP command allocates QP context with the specified
-	 * SQ, RQ/SRQ, CQ and other parameters.
+	 * UD Send V3
+	 *
+	 * Allowed only on unreliable datagram (UD) SQs.
 	 */
-	#define CMDQ_BASE_OPCODE_CREATE_QP		UINT32_C(0x1)
+	#define SQ_UDSEND_HDR_V3_WQE_TYPE_UDSEND_V3	UINT32_C(0x13)
 	/*
-	 * Destroy QP command deletes the QP context and ceases
-	 * any further reference.
+	 * UD Send with Immediate V3
+	 *
+	 * Allowed only on unreliable datagram (UD) SQs.
 	 */
-	#define CMDQ_BASE_OPCODE_DESTROY_QP		UINT32_C(0x2)
+	#define SQ_UDSEND_HDR_V3_WQE_TYPE_UDSEND_W_IMMED_V3 UINT32_C(0x14)
+	#define SQ_UDSEND_HDR_V3_WQE_TYPE_LAST		SQ_UDSEND_HDR_V3_WQE_TYPE_UDSEND_W_IMMED_V3
+	uint8_t	flags;
 	/*
-	 * Modify QP command changes QP states and other QP specific
-	 * parameters.
+	 * Set if completion signaling is requested. If this bit is
+	 * 0, and the SQ is configured to support Unsignaled completion
+	 * the controller should not generate a CQE unless there was
+	 * an error. This refers to the CQE on the sender side. (The se
+	 * flag refers to the receiver side).
 	 */
-	#define CMDQ_BASE_OPCODE_MODIFY_QP		UINT32_C(0x3)
-	/* Query QP command retrieves info about the specified QP. */
-	#define CMDQ_BASE_OPCODE_QUERY_QP		UINT32_C(0x4)
-	/* Create SRQ command allocates a SRQ with the specified parameters. */
-	#define CMDQ_BASE_OPCODE_CREATE_SRQ		UINT32_C(0x5)
-	/* Destroy SRQ command deletes and flushes the specified SRQ. */
-	#define CMDQ_BASE_OPCODE_DESTROY_SRQ		UINT32_C(0x6)
-	/* Query SRP command retrieves info about the specified SRQ. */
-	#define CMDQ_BASE_OPCODE_QUERY_SRQ		UINT32_C(0x8)
-	/* Create CQ command allocates a CQ with the specified parameters. */
-	#define CMDQ_BASE_OPCODE_CREATE_CQ		UINT32_C(0x9)
-	/* Destroy CQ command deletes and flushes the specified CQ. */
-	#define CMDQ_BASE_OPCODE_DESTROY_CQ		UINT32_C(0xa)
-	/* Resize CQ command resizes the specified CQ. */
-	#define CMDQ_BASE_OPCODE_RESIZE_CQ		UINT32_C(0xc)
+	#define SQ_UDSEND_HDR_V3_FLAGS_SIGNAL_COMP		UINT32_C(0x1)
 	/*
-	 * Allocate MRW command allocates a MR/MW with the specified parameters
-	 * and returns the region's L_KEY/R_KEY
+	 * Indication to complete all previous RDMA Read or Atomic WQEs
+	 * on the SQ before executing this WQE.
+	 *
+	 * This flag must be zero for a UD send.
 	 */
-	#define CMDQ_BASE_OPCODE_ALLOCATE_MRW	UINT32_C(0xd)
-	/* De-allocate key command frees a MR/MW entry associated with the specified key. */
-	#define CMDQ_BASE_OPCODE_DEALLOCATE_KEY	UINT32_C(0xe)
-	/* Register MR command registers memory to the specified MR. */
-	#define CMDQ_BASE_OPCODE_REGISTER_MR		UINT32_C(0xf)
-	/* Deregister MR command de-registers memory from the specified MR. */
-	#define CMDQ_BASE_OPCODE_DEREGISTER_MR	UINT32_C(0x10)
-	/* Add GID command adds a GID to the local address table. */
-	#define CMDQ_BASE_OPCODE_ADD_GID		UINT32_C(0x11)
-	/* Delete GID command deletes a GID from the local address table. */
-	#define CMDQ_BASE_OPCODE_DELETE_GID		UINT32_C(0x12)
-	/* Modify GID command modifies a GID in the local address table. */
-	#define CMDQ_BASE_OPCODE_MODIFY_GID		UINT32_C(0x17)
-	/* Query GID command queries a GID in the local address table. */
-	#define CMDQ_BASE_OPCODE_QUERY_GID		UINT32_C(0x18)
-	/* Create QP1 command allocates a QP1 only. */
-	#define CMDQ_BASE_OPCODE_CREATE_QP1		UINT32_C(0x13)
-	/* Destroy QP1 command deletes and flushes the specified QP1. */
-	#define CMDQ_BASE_OPCODE_DESTROY_QP1		UINT32_C(0x14)
-	/* Create AH command allocates an AH with the specified parameters. */
-	#define CMDQ_BASE_OPCODE_CREATE_AH		UINT32_C(0x15)
-	/* Destroy AH command deletes the specified AH. */
-	#define CMDQ_BASE_OPCODE_DESTROY_AH		UINT32_C(0x16)
+	#define SQ_UDSEND_HDR_V3_FLAGS_RD_OR_ATOMIC_FENCE	UINT32_C(0x2)
 	/*
-	 * Initialize firmware command initializes the firmware with
-	 * the specified parameters.
+	 * Unconditional fence. Indication to complete all
+	 * previous SQ's WQEs before executing this WQE.
+	 *
+	 * This flag must be zero for a UD send.
 	 */
-	#define CMDQ_BASE_OPCODE_INITIALIZE_FW	UINT32_C(0x80)
-	/* De-initialize firmware command deinitializes the firmware. */
-	#define CMDQ_BASE_OPCODE_DEINITIALIZE_FW	UINT32_C(0x81)
-	/* Stop the function */
-	#define CMDQ_BASE_OPCODE_STOP_FUNC		UINT32_C(0x82)
-	/* Query the HW capabilities for the function. */
-	#define CMDQ_BASE_OPCODE_QUERY_FUNC		UINT32_C(0x83)
+	#define SQ_UDSEND_HDR_V3_FLAGS_UC_FENCE		UINT32_C(0x4)
 	/*
-	 * Set the following resources for the function:
-	 * - Max QP, CQ, MR+MW, SRQ per PF
-	 * - Max QP, CQ, MR+MW, SRQ per VF
+	 * Solicit event flag. Indication sent in BTH header to the
+	 * receiver to generate a Completion Event Notification, i.e.
+	 * CNQE.
 	 */
-	#define CMDQ_BASE_OPCODE_SET_FUNC_RESOURCES	UINT32_C(0x84)
-	/* Read the current state of any internal resource context. Can only be issued from a PF. */
-	#define CMDQ_BASE_OPCODE_READ_CONTEXT	UINT32_C(0x85)
-	/* Send a request from VF to pass a command to the PF. VF HSI is suspended until the PF returns the response */
-	#define CMDQ_BASE_OPCODE_VF_BACKCHANNEL_REQUEST UINT32_C(0x86)
-	/* Read VF memory (primarily to get the backchannel request blob). Can only be issued from a PF. */
-	#define CMDQ_BASE_OPCODE_READ_VF_MEMORY	UINT32_C(0x87)
-	/* Write VF memory (primarily to put the backchannel response blob), and reenable VF HSI (post a CAG completion to it). Can only be issued from a PF. */
-	#define CMDQ_BASE_OPCODE_COMPLETE_VF_REQUEST	UINT32_C(0x88)
-	/* Extend resource (QPC, MRW, CQ, SRQ) array, after the host allocates more. Can only be issued from a PF. */
-	#define CMDQ_BASE_OPCODE_EXTEND_CONTEXT_ARRRAY  UINT32_C(0x89)
-	/* Map TC to COS. Can only be issued from a PF. */
-	#define CMDQ_BASE_OPCODE_MAP_TC_TO_COS	UINT32_C(0x8a)
-	/* Query version. */
-	#define CMDQ_BASE_OPCODE_QUERY_VERSION	UINT32_C(0x8b)
-	/* Modify congestion control. Can only be issued from a PF. */
-	#define CMDQ_BASE_OPCODE_MODIFY_ROCE_CC	UINT32_C(0x8c)
-	/* Query congestion control. */
-	#define CMDQ_BASE_OPCODE_QUERY_ROCE_CC	UINT32_C(0x8d)
-	/* Query RoCE statistics. */
-	#define CMDQ_BASE_OPCODE_QUERY_ROCE_STATS	UINT32_C(0x8e)
-	/* Set LAG mode. */
-	#define CMDQ_BASE_OPCODE_SET_LINK_AGGR_MODE	UINT32_C(0x8f)
-	/* Modify CQ */
-	#define CMDQ_BASE_OPCODE_MODIFY_CQ		UINT32_C(0x90)
+	#define SQ_UDSEND_HDR_V3_FLAGS_SE			UINT32_C(0x8)
 	/*
-	 * Query QP for a PF other than the requesting PF. Also can query for more
-	 * than one QP.
+	 * Indicate that inline data is posted to the SQ in the data
+	 * area of this WQE.
 	 */
-	#define CMDQ_BASE_OPCODE_QUERY_QP_EXTEND	UINT32_C(0x91)
-	/* Query extended RoCE statistics. */
-	#define CMDQ_BASE_OPCODE_QUERY_ROCE_STATS_EXT   UINT32_C(0x92)
-	#define CMDQ_BASE_OPCODE_LAST		CMDQ_BASE_OPCODE_QUERY_ROCE_STATS_EXT
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-} cmdq_base_t, *pcmdq_base_t;
-
-/* creq_base (size:128b/16B) */
-
-typedef struct creq_base {
-	uint8_t	type;
+	#define SQ_UDSEND_HDR_V3_FLAGS_INLINE		UINT32_C(0x10)
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * If set to 1, then the timestamp from the WQE is used. If
+	 * cleared to 0, then TWE provides the timestamp.
 	 */
-	#define CREQ_BASE_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_BASE_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_BASE_TYPE_QP_EVENT	UINT32_C(0x38)
-	/* Function Async Notification */
-		#define CREQ_BASE_TYPE_FUNC_EVENT  UINT32_C(0x3a)
-		#define CREQ_BASE_TYPE_LAST	CREQ_BASE_TYPE_FUNC_EVENT
-	uint8_t	reserved56[7];
-	uint8_t	v;
+	#define SQ_UDSEND_HDR_V3_FLAGS_WQE_TS_EN		UINT32_C(0x20)
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * When set to '1', this operation will cause a trace capture in
+	 * each block it passes through.
 	 */
-	#define CREQ_BASE_V	UINT32_C(0x1)
-	/* This is the modifier on to the type field. */
-	uint8_t	event;
-	uint8_t	reserved48[6];
-} creq_base_t, *pcreq_base_t;
-
-/*****************
- * query_version *
- *****************/
-
-
-/* cmdq_query_version (size:128b/16B) */
-
-typedef struct cmdq_query_version {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Query version. */
-	#define CMDQ_QUERY_VERSION_OPCODE_QUERY_VERSION UINT32_C(0x8b)
-	#define CMDQ_QUERY_VERSION_OPCODE_LAST	CMDQ_QUERY_VERSION_OPCODE_QUERY_VERSION
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-} cmdq_query_version_t, *pcmdq_query_version_t;
-
-/* creq_query_version_resp (size:128b/16B) */
-
-typedef struct creq_query_version_resp {
-	uint8_t	type;
+	#define SQ_UDSEND_HDR_V3_FLAGS_DEBUG_TRACE		UINT32_C(0x40)
+	/*  */
+	uint8_t	wqe_size;
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * The number of 16 bytes chunks of data including this first
+	 * word of the request that are a valid part of the request. The
+	 * valid 16 bytes units other than the WQE structure can be
+	 * SGEs (Scatter Gather Elements) OR inline data.
+	 *
+	 * This field shall never exceed 32 for WQEs of this type.
+	 */
+	#define SQ_UDSEND_HDR_V3_WQE_SIZE_MASK UINT32_C(0x3f)
+	#define SQ_UDSEND_HDR_V3_WQE_SIZE_SFT 0
+	uint8_t	inline_length;
+	/*
+	 * When inline flag is '1', this field determines the number of
+	 * bytes that are valid in the last 16B unit of the inline WQE.
+	 * Zero means all 16 bytes are valid. One means only bits 7:0 of
+	 * the last 16B unit are valid. This means the total size of the
+	 * inline data is determined by a combination of the wqe_size field
+	 * and this inline_length field.
+	 *
+	 * `inline_size = ((wqe_size - 1) * 16) - data_offset_in_bytes +
+	 * ((inline_length == 0 ) ? 16 : inline_length)
+	 *
+	 * Where data_offset_in_bytes is the offset within the WQE where
+	 * the data field starts.
+	 *
+	 * Note that this field is not applicable for zero-length inline
+	 * WQEs.
 	 */
-	#define CREQ_QUERY_VERSION_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_QUERY_VERSION_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_QUERY_VERSION_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_QUERY_VERSION_RESP_TYPE_LAST	CREQ_QUERY_VERSION_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* firmware major version */
-	uint8_t	fw_maj;
-	/* firmware minor version */
-	uint8_t	fw_minor;
-	/* firmware build version */
-	uint8_t	fw_bld;
-	/* firmware reserved version */
-	uint8_t	fw_rsvd;
-	uint8_t	v;
+	#define SQ_UDSEND_HDR_V3_INLINE_LENGTH_MASK UINT32_C(0xf)
+	#define SQ_UDSEND_HDR_V3_INLINE_LENGTH_SFT 0
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * This value will be returned in the completion if the completion is
+	 * signaled.
 	 */
-	#define CREQ_QUERY_VERSION_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Query firmware and interface version response. */
-	#define CREQ_QUERY_VERSION_RESP_EVENT_QUERY_VERSION UINT32_C(0x8b)
-	#define CREQ_QUERY_VERSION_RESP_EVENT_LAST	CREQ_QUERY_VERSION_RESP_EVENT_QUERY_VERSION
-	uint16_t	reserved16;
-	/* interface major version */
-	uint8_t	intf_maj;
-	/* interface minor version */
-	uint8_t	intf_minor;
-	/* interface build version */
-	uint8_t	intf_bld;
-	/* interface reserved version */
-	uint8_t	intf_rsvd;
-} creq_query_version_resp_t, *pcreq_query_version_resp_t;
-
-/*****************
- * initialize_fw *
- *****************/
-
-
-/* cmdq_initialize_fw (size:896b/112B) */
-
-typedef struct cmdq_initialize_fw {
-	/* Command opcode. */
-	uint8_t	opcode;
+	uint32_t	opaque;
 	/*
-	 * Initialize firmware command initializes the firmware with
-	 * the specified parameters.
+	 * Immediate value that will be sent with ImmDt header if wqe_type is
+	 * UD Send with Immediate.
 	 */
-	#define CMDQ_INITIALIZE_FW_OPCODE_INITIALIZE_FW UINT32_C(0x80)
-	#define CMDQ_INITIALIZE_FW_OPCODE_LAST	CMDQ_INITIALIZE_FW_OPCODE_INITIALIZE_FW
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
+	uint32_t	imm_data;
 	/*
-	 * When set, the 32b `max_mrw_per_vf` field is logically divided
-	 * into two 16b fields, `max_mr_per_vf` and `max_av_per_vf`.
+	 * When in the SQ of a UD QP, indicates the q_key to be used in
+	 * the transmitted packet. However, if the most significant bit
+	 * of this field is set, then the q_key will be taken from QP
+	 * context, rather than from this field.
+	 *
+	 * When in the SQ of a non-UD QP, this field is reserved and
+	 * should be filled with zeros.
 	 */
-	#define CMDQ_INITIALIZE_FW_FLAGS_MRAV_RESERVATION_SPLIT	UINT32_C(0x1)
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	uint8_t	qpc_pg_size_qpc_lvl;
-	/* QPC PBL indirect levels. */
-	#define CMDQ_INITIALIZE_FW_QPC_LVL_MASK	UINT32_C(0xf)
-	#define CMDQ_INITIALIZE_FW_QPC_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define CMDQ_INITIALIZE_FW_QPC_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define CMDQ_INITIALIZE_FW_QPC_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define CMDQ_INITIALIZE_FW_QPC_LVL_LVL_2	UINT32_C(0x2)
-		#define CMDQ_INITIALIZE_FW_QPC_LVL_LAST	CMDQ_INITIALIZE_FW_QPC_LVL_LVL_2
-	/* QPC page size. */
-	#define CMDQ_INITIALIZE_FW_QPC_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define CMDQ_INITIALIZE_FW_QPC_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define CMDQ_INITIALIZE_FW_QPC_PG_SIZE_LAST   CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_1G
-	uint8_t	mrw_pg_size_mrw_lvl;
-	/* MRW PBL indirect levels. */
-	#define CMDQ_INITIALIZE_FW_MRW_LVL_MASK	UINT32_C(0xf)
-	#define CMDQ_INITIALIZE_FW_MRW_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define CMDQ_INITIALIZE_FW_MRW_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define CMDQ_INITIALIZE_FW_MRW_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define CMDQ_INITIALIZE_FW_MRW_LVL_LVL_2	UINT32_C(0x2)
-		#define CMDQ_INITIALIZE_FW_MRW_LVL_LAST	CMDQ_INITIALIZE_FW_MRW_LVL_LVL_2
-	/* MRW page size. */
-	#define CMDQ_INITIALIZE_FW_MRW_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define CMDQ_INITIALIZE_FW_MRW_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define CMDQ_INITIALIZE_FW_MRW_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define CMDQ_INITIALIZE_FW_MRW_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define CMDQ_INITIALIZE_FW_MRW_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define CMDQ_INITIALIZE_FW_MRW_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define CMDQ_INITIALIZE_FW_MRW_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define CMDQ_INITIALIZE_FW_MRW_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define CMDQ_INITIALIZE_FW_MRW_PG_SIZE_LAST   CMDQ_INITIALIZE_FW_MRW_PG_SIZE_PG_1G
-	uint8_t	srq_pg_size_srq_lvl;
-	/* SRQ PBL indirect levels. */
-	#define CMDQ_INITIALIZE_FW_SRQ_LVL_MASK	UINT32_C(0xf)
-	#define CMDQ_INITIALIZE_FW_SRQ_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define CMDQ_INITIALIZE_FW_SRQ_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define CMDQ_INITIALIZE_FW_SRQ_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define CMDQ_INITIALIZE_FW_SRQ_LVL_LVL_2	UINT32_C(0x2)
-		#define CMDQ_INITIALIZE_FW_SRQ_LVL_LAST	CMDQ_INITIALIZE_FW_SRQ_LVL_LVL_2
-	/* SRQ page size. */
-	#define CMDQ_INITIALIZE_FW_SRQ_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define CMDQ_INITIALIZE_FW_SRQ_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define CMDQ_INITIALIZE_FW_SRQ_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define CMDQ_INITIALIZE_FW_SRQ_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define CMDQ_INITIALIZE_FW_SRQ_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define CMDQ_INITIALIZE_FW_SRQ_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define CMDQ_INITIALIZE_FW_SRQ_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define CMDQ_INITIALIZE_FW_SRQ_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define CMDQ_INITIALIZE_FW_SRQ_PG_SIZE_LAST   CMDQ_INITIALIZE_FW_SRQ_PG_SIZE_PG_1G
-	uint8_t	cq_pg_size_cq_lvl;
-	/* CQ PBL indirect levels. */
-	#define CMDQ_INITIALIZE_FW_CQ_LVL_MASK	UINT32_C(0xf)
-	#define CMDQ_INITIALIZE_FW_CQ_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define CMDQ_INITIALIZE_FW_CQ_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define CMDQ_INITIALIZE_FW_CQ_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define CMDQ_INITIALIZE_FW_CQ_LVL_LVL_2	UINT32_C(0x2)
-		#define CMDQ_INITIALIZE_FW_CQ_LVL_LAST	CMDQ_INITIALIZE_FW_CQ_LVL_LVL_2
-	/* CQ page size. */
-	#define CMDQ_INITIALIZE_FW_CQ_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define CMDQ_INITIALIZE_FW_CQ_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define CMDQ_INITIALIZE_FW_CQ_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define CMDQ_INITIALIZE_FW_CQ_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define CMDQ_INITIALIZE_FW_CQ_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define CMDQ_INITIALIZE_FW_CQ_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define CMDQ_INITIALIZE_FW_CQ_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define CMDQ_INITIALIZE_FW_CQ_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define CMDQ_INITIALIZE_FW_CQ_PG_SIZE_LAST   CMDQ_INITIALIZE_FW_CQ_PG_SIZE_PG_1G
-	uint8_t	tqm_pg_size_tqm_lvl;
-	/* TQM PBL indirect levels. */
-	#define CMDQ_INITIALIZE_FW_TQM_LVL_MASK	UINT32_C(0xf)
-	#define CMDQ_INITIALIZE_FW_TQM_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define CMDQ_INITIALIZE_FW_TQM_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define CMDQ_INITIALIZE_FW_TQM_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define CMDQ_INITIALIZE_FW_TQM_LVL_LVL_2	UINT32_C(0x2)
-		#define CMDQ_INITIALIZE_FW_TQM_LVL_LAST	CMDQ_INITIALIZE_FW_TQM_LVL_LVL_2
-	/* TQM page size. */
-	#define CMDQ_INITIALIZE_FW_TQM_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define CMDQ_INITIALIZE_FW_TQM_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define CMDQ_INITIALIZE_FW_TQM_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define CMDQ_INITIALIZE_FW_TQM_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define CMDQ_INITIALIZE_FW_TQM_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define CMDQ_INITIALIZE_FW_TQM_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define CMDQ_INITIALIZE_FW_TQM_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define CMDQ_INITIALIZE_FW_TQM_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define CMDQ_INITIALIZE_FW_TQM_PG_SIZE_LAST   CMDQ_INITIALIZE_FW_TQM_PG_SIZE_PG_1G
-	uint8_t	tim_pg_size_tim_lvl;
-	/* TIM PBL indirect levels. */
-	#define CMDQ_INITIALIZE_FW_TIM_LVL_MASK	UINT32_C(0xf)
-	#define CMDQ_INITIALIZE_FW_TIM_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define CMDQ_INITIALIZE_FW_TIM_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define CMDQ_INITIALIZE_FW_TIM_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define CMDQ_INITIALIZE_FW_TIM_LVL_LVL_2	UINT32_C(0x2)
-		#define CMDQ_INITIALIZE_FW_TIM_LVL_LAST	CMDQ_INITIALIZE_FW_TIM_LVL_LVL_2
-	/* TIM page size. */
-	#define CMDQ_INITIALIZE_FW_TIM_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define CMDQ_INITIALIZE_FW_TIM_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define CMDQ_INITIALIZE_FW_TIM_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define CMDQ_INITIALIZE_FW_TIM_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define CMDQ_INITIALIZE_FW_TIM_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define CMDQ_INITIALIZE_FW_TIM_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define CMDQ_INITIALIZE_FW_TIM_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define CMDQ_INITIALIZE_FW_TIM_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define CMDQ_INITIALIZE_FW_TIM_PG_SIZE_LAST   CMDQ_INITIALIZE_FW_TIM_PG_SIZE_PG_1G
-	uint16_t	log2_dbr_pg_size;
-	/* Log base 2 of DBR page size - 12. 0 for 4KB. HW supported values are enumerated below. */
-	#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_MASK   UINT32_C(0xf)
-	#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_SFT	0
-	/* 4KB. */
-		#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_PG_4K	UINT32_C(0x0)
-	/* 8KB. */
-		#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_PG_8K	UINT32_C(0x1)
-	/* 16KB. */
-		#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_PG_16K   UINT32_C(0x2)
-	/* 32KB. */
-		#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_PG_32K   UINT32_C(0x3)
-	/* 64KB. */
-		#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_PG_64K   UINT32_C(0x4)
-	/* 128KB. */
-		#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_PG_128K  UINT32_C(0x5)
-	/* 256KB. */
-		#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_PG_256K  UINT32_C(0x6)
-	/* 512KB. */
-		#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_PG_512K  UINT32_C(0x7)
-	/* 1MB. */
-		#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_PG_1M	UINT32_C(0x8)
-	/* 2MB. */
-		#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_PG_2M	UINT32_C(0x9)
-	/* 4MB. */
-		#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_PG_4M	UINT32_C(0xa)
-	/* 8MB. */
-		#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_PG_8M	UINT32_C(0xb)
-	/* 16MB. */
-		#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_PG_16M   UINT32_C(0xc)
-	/* 32MB. */
-		#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_PG_32M   UINT32_C(0xd)
-	/* 64MB. */
-		#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_PG_64M   UINT32_C(0xe)
-	/* 128MB. */
-		#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_PG_128M  UINT32_C(0xf)
-		#define CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_LAST	CMDQ_INITIALIZE_FW_LOG2_DBR_PG_SIZE_PG_128M
-	/* rsvd is 12 b */
-	#define CMDQ_INITIALIZE_FW_RSVD_MASK		UINT32_C(0xfff0)
-	#define CMDQ_INITIALIZE_FW_RSVD_SFT		4
-	/* Kernel notification queue page directory. */
-	uint64_t	qpc_page_dir;
-	/* MRW page directory. */
-	uint64_t	mrw_page_dir;
-	/* SRQ page directory. */
-	uint64_t	srq_page_dir;
-	/* CQ page directory. */
-	uint64_t	cq_page_dir;
-	/* TQM page directory. */
-	uint64_t	tqm_page_dir;
-	/* TIM page directory. */
-	uint64_t	tim_page_dir;
-	/* Number of QPs. */
-	uint32_t	number_of_qp;
-	/* Number of MRWs. */
-	uint32_t	number_of_mrw;
-	/* Number of SRQs. */
-	uint32_t	number_of_srq;
-	/* Number of CQs. */
-	uint32_t	number_of_cq;
-	/* Number of QPs per VF. */
-	uint32_t	max_qp_per_vf;
+	uint32_t	q_key;
 	/*
-	 * If the MR/AV split reservation flag is not set, then this field
-	 * represents the total number of MR plus AV entries allowed per
-	 * VF. For versions of firmware that support the split reservation,
-	 * when it is not specified half of the entries will be reserved
-	 * for MRs and the other half for AVs.
+	 * When in the SQ of a UD QP, indicates the destination QP to be
+	 * used in the transmitted packet.
 	 *
-	 * If the MR/AV split reservation flag is set, then this
-	 * field is logically divided into two 16b fields. Bits `[31:16]`
-	 * represents the `max_mr_per_vf` and bits `[15:0]` represents
-	 * `max_av_per_vf`. The granularity of these values is defined by
-	 * the `mrav_num_entries_unit` field returned by the
-	 * `backing_store_qcaps` command.
+	 * When in the SQ of a non-UD QP, this field is reserved and
+	 * should be filled with zeros.
 	 */
-	uint32_t	max_mrw_per_vf;
-	/* Number of SRQs per VF. */
-	uint32_t	max_srq_per_vf;
-	/* Number of CQs per VF. */
-	uint32_t	max_cq_per_vf;
-	/* Number of GIDs per VF. */
-	uint32_t	max_gid_per_vf;
-	/* Statistics context index for this function. */
-	uint32_t	stat_ctx_id;
-} cmdq_initialize_fw_t, *pcmdq_initialize_fw_t;
-
-/* creq_initialize_fw_resp (size:128b/16B) */
-
-typedef struct creq_initialize_fw_resp {
-	uint8_t	type;
+	uint32_t	dst_qp;
+	#define SQ_UDSEND_HDR_V3_DST_QP_MASK UINT32_C(0xffffff)
+	#define SQ_UDSEND_HDR_V3_DST_QP_SFT 0
+	uint32_t	avid;
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * If the serv_type is 'UD', then this field supplies the AVID
+	 * (Address Vector ID).
 	 */
-	#define CREQ_INITIALIZE_FW_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_INITIALIZE_FW_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_INITIALIZE_FW_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_INITIALIZE_FW_RESP_TYPE_LAST	CREQ_INITIALIZE_FW_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	uint32_t	reserved32;
-	uint8_t	v;
+	#define SQ_UDSEND_HDR_V3_AVID_MASK UINT32_C(0x3ff)
+	#define SQ_UDSEND_HDR_V3_AVID_SFT 0
+	uint32_t	reserved2;
+	uint32_t	timestamp;
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * This field specifies a 24-bit timestamp that can be passed
+	 * down the TX path and optionally logged in the TXP timestamp
+	 * histogram.
 	 */
-	#define CREQ_INITIALIZE_FW_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Initialize firmware command response. */
-	#define CREQ_INITIALIZE_FW_RESP_EVENT_INITIALIZE_FW UINT32_C(0x80)
-	#define CREQ_INITIALIZE_FW_RESP_EVENT_LAST	CREQ_INITIALIZE_FW_RESP_EVENT_INITIALIZE_FW
-	uint8_t	reserved48[6];
-} creq_initialize_fw_resp_t, *pcreq_initialize_fw_resp_t;
-
-/*******************
- * deinitialize_fw *
- *******************/
-
-
-/* cmdq_deinitialize_fw (size:128b/16B) */
-
-typedef struct cmdq_deinitialize_fw {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* De-initialize firmware command deinitializes the firmware. */
-	#define CMDQ_DEINITIALIZE_FW_OPCODE_DEINITIALIZE_FW UINT32_C(0x81)
-	#define CMDQ_DEINITIALIZE_FW_OPCODE_LAST	CMDQ_DEINITIALIZE_FW_OPCODE_DEINITIALIZE_FW
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-} cmdq_deinitialize_fw_t, *pcmdq_deinitialize_fw_t;
+	#define SQ_UDSEND_HDR_V3_TIMESTAMP_MASK UINT32_C(0xffffff)
+	#define SQ_UDSEND_HDR_V3_TIMESTAMP_SFT 0
+} sq_udsend_hdr_v3_t, *psq_udsend_hdr_v3_t;
 
-/* creq_deinitialize_fw_resp (size:128b/16B) */
+/* SQ RDMA WQE V3 for RC SQs. */
+/* sq_rdma_v3 (size:1024b/128B) */
 
-typedef struct creq_deinitialize_fw_resp {
-	uint8_t	type;
+typedef struct sq_rdma_v3 {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * RDMA Write V3
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	#define CREQ_DEINITIALIZE_FW_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_DEINITIALIZE_FW_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_DEINITIALIZE_FW_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_DEINITIALIZE_FW_RESP_TYPE_LAST	CREQ_DEINITIALIZE_FW_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	uint32_t	reserved32;
-	uint8_t	v;
+	#define SQ_RDMA_V3_WQE_TYPE_WRITE_WQE_V3	UINT32_C(0x15)
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * RDMA Write with Immediate V3
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	#define CREQ_DEINITIALIZE_FW_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* De-initialize firmware command response. */
-	#define CREQ_DEINITIALIZE_FW_RESP_EVENT_DEINITIALIZE_FW UINT32_C(0x81)
-	#define CREQ_DEINITIALIZE_FW_RESP_EVENT_LAST	CREQ_DEINITIALIZE_FW_RESP_EVENT_DEINITIALIZE_FW
-	uint8_t	reserved48[6];
-} creq_deinitialize_fw_resp_t, *pcreq_deinitialize_fw_resp_t;
-
-/*************
- * create_qp *
- *************/
-
-
-/* cmdq_create_qp (size:768b/96B) */
-
-typedef struct cmdq_create_qp {
-	/* Command opcode. */
-	uint8_t	opcode;
+	#define SQ_RDMA_V3_WQE_TYPE_WRITE_W_IMMED_V3 UINT32_C(0x16)
 	/*
-	 * Create QP command allocates QP context with the specified
-	 * SQ, RQ/SRQ, CQ and other parameters.
+	 * RDMA Read V3
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	#define CMDQ_CREATE_QP_OPCODE_CREATE_QP UINT32_C(0x1)
-	#define CMDQ_CREATE_QP_OPCODE_LAST	CMDQ_CREATE_QP_OPCODE_CREATE_QP
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	/* QP handle. */
-	uint64_t	qp_handle;
-	/* Create QP flags. */
-	uint32_t	qp_flags;
-	/* SRQ is used. */
-	#define CMDQ_CREATE_QP_QP_FLAGS_SRQ_USED		UINT32_C(0x1)
-	/* post CQE for all SQ WQEs. */
-	#define CMDQ_CREATE_QP_QP_FLAGS_FORCE_COMPLETION	UINT32_C(0x2)
-	/* This QP can use reserved L_Key */
-	#define CMDQ_CREATE_QP_QP_FLAGS_RESERVED_LKEY_ENABLE	UINT32_C(0x4)
-	/* This QP can fast register physical memory */
-	#define CMDQ_CREATE_QP_QP_FLAGS_FR_PMR_ENABLED		UINT32_C(0x8)
-	/* This QP can send variable sized WQEs. */
-	#define CMDQ_CREATE_QP_QP_FLAGS_VARIABLE_SIZED_WQE_ENABLED UINT32_C(0x10)
+	#define SQ_RDMA_V3_WQE_TYPE_READ_WQE_V3	UINT32_C(0x17)
+	#define SQ_RDMA_V3_WQE_TYPE_LAST		SQ_RDMA_V3_WQE_TYPE_READ_WQE_V3
+	uint8_t	flags;
 	/*
-	 * WQEs with inline data sent on this QP are able to flow
-	 * through an optimized transmit path to lower latency. This
-	 * transmit path is opportunistic and not guaranteed to always
-	 * occur.
+	 * Set if completion signaling is requested. If this bit is
+	 * 0, and the SQ is configured to support Unsignaled
+	 * completion the controller should not generate a CQE
+	 * unless there was an error. This refers to CQE on the
+	 * sender side (The se flag refers to the receiver side).
 	 */
-	#define CMDQ_CREATE_QP_QP_FLAGS_OPTIMIZED_TRANSMIT_ENABLED UINT32_C(0x20)
+	#define SQ_RDMA_V3_FLAGS_SIGNAL_COMP		UINT32_C(0x1)
 	/*
-	 * For UD QPs the default responder CQE format is `cq_res_ud`.
-	 * This flag specifies the `cq_res_ud_cfa` format to be used
-	 * instead.
+	 * Indication to complete all previous RDMA Read or Atomic
+	 * WQEs on the SQ before executing this WQE
 	 */
-	#define CMDQ_CREATE_QP_QP_FLAGS_RESPONDER_UD_CQE_WITH_CFA  UINT32_C(0x40)
+	#define SQ_RDMA_V3_FLAGS_RD_OR_ATOMIC_FENCE	UINT32_C(0x2)
 	/*
-	 * This QP must be included in the extended RoCE statistics
-	 * that can be queried via `query_roce_stats_ext`.
+	 * Unconditional fence. Indication to complete all previous
+	 * SQ's WQEs before executing this WQE.
 	 */
-	#define CMDQ_CREATE_QP_QP_FLAGS_EXT_STATS_ENABLED	UINT32_C(0x80)
-	#define CMDQ_CREATE_QP_QP_FLAGS_LAST			CMDQ_CREATE_QP_QP_FLAGS_EXT_STATS_ENABLED
-	/* Supported QP types. */
-	uint8_t	type;
-	/* Reliable Connection. */
-	#define CMDQ_CREATE_QP_TYPE_RC		UINT32_C(0x2)
-	/* Unreliable Datagram. */
-	#define CMDQ_CREATE_QP_TYPE_UD		UINT32_C(0x4)
-	/* Raw Ethertype. */
-	#define CMDQ_CREATE_QP_TYPE_RAW_ETHERTYPE UINT32_C(0x6)
-	/* General Services Interface on QP1 over UD. */
-	#define CMDQ_CREATE_QP_TYPE_GSI	UINT32_C(0x7)
-	#define CMDQ_CREATE_QP_TYPE_LAST	CMDQ_CREATE_QP_TYPE_GSI
-	uint8_t	sq_pg_size_sq_lvl;
-	/* SQ PBL indirect levels. */
-	#define CMDQ_CREATE_QP_SQ_LVL_MASK	UINT32_C(0xf)
-	#define CMDQ_CREATE_QP_SQ_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define CMDQ_CREATE_QP_SQ_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define CMDQ_CREATE_QP_SQ_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define CMDQ_CREATE_QP_SQ_LVL_LVL_2	UINT32_C(0x2)
-		#define CMDQ_CREATE_QP_SQ_LVL_LAST	CMDQ_CREATE_QP_SQ_LVL_LVL_2
-	/* SQ page size. */
-	#define CMDQ_CREATE_QP_SQ_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define CMDQ_CREATE_QP_SQ_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define CMDQ_CREATE_QP_SQ_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define CMDQ_CREATE_QP_SQ_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define CMDQ_CREATE_QP_SQ_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define CMDQ_CREATE_QP_SQ_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define CMDQ_CREATE_QP_SQ_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define CMDQ_CREATE_QP_SQ_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define CMDQ_CREATE_QP_SQ_PG_SIZE_LAST   CMDQ_CREATE_QP_SQ_PG_SIZE_PG_1G
-	uint8_t	rq_pg_size_rq_lvl;
-	/* RQ PBL indirect levels. */
-	#define CMDQ_CREATE_QP_RQ_LVL_MASK	UINT32_C(0xf)
-	#define CMDQ_CREATE_QP_RQ_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define CMDQ_CREATE_QP_RQ_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define CMDQ_CREATE_QP_RQ_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define CMDQ_CREATE_QP_RQ_LVL_LVL_2	UINT32_C(0x2)
-		#define CMDQ_CREATE_QP_RQ_LVL_LAST	CMDQ_CREATE_QP_RQ_LVL_LVL_2
-	/* RQ page size. */
-	#define CMDQ_CREATE_QP_RQ_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define CMDQ_CREATE_QP_RQ_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define CMDQ_CREATE_QP_RQ_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define CMDQ_CREATE_QP_RQ_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define CMDQ_CREATE_QP_RQ_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define CMDQ_CREATE_QP_RQ_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define CMDQ_CREATE_QP_RQ_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define CMDQ_CREATE_QP_RQ_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define CMDQ_CREATE_QP_RQ_PG_SIZE_LAST   CMDQ_CREATE_QP_RQ_PG_SIZE_PG_1G
-	uint8_t	unused_0;
-	/* Doorbell page index. */
-	uint32_t	dpi;
-	/* Max number of SQ wqes. */
-	uint32_t	sq_size;
-	/* Max number of RQ wqes. */
-	uint32_t	rq_size;
-	uint16_t	sq_fwo_sq_sge;
-	/* Max send SGEs per SWQE. */
-	#define CMDQ_CREATE_QP_SQ_SGE_MASK UINT32_C(0xf)
-	#define CMDQ_CREATE_QP_SQ_SGE_SFT 0
-	/* Offset of First WQE in the first SQ page, in 128 byte units */
-	#define CMDQ_CREATE_QP_SQ_FWO_MASK UINT32_C(0xfff0)
-	#define CMDQ_CREATE_QP_SQ_FWO_SFT 4
-	uint16_t	rq_fwo_rq_sge;
+	#define SQ_RDMA_V3_FLAGS_UC_FENCE		UINT32_C(0x4)
 	/*
-	 * Max recv SGEs per RWQE.
-	 * On chips with variable-size WQE support, a value of zero implies 30 SGEs.
+	 * Solicit event. Indication sent in BTH header to the
+	 * receiver to generate a Completion Event Notification,
+	 * i.e. CNQE.
 	 */
-	#define CMDQ_CREATE_QP_RQ_SGE_MASK UINT32_C(0xf)
-	#define CMDQ_CREATE_QP_RQ_SGE_SFT 0
-	/* Offset of First WQE in the first RQ page, in 128 byte units */
-	#define CMDQ_CREATE_QP_RQ_FWO_MASK UINT32_C(0xfff0)
-	#define CMDQ_CREATE_QP_RQ_FWO_SFT 4
-	/* Send CQ context id. */
-	uint32_t	scq_cid;
-	/* Receive CQ context id. */
-	uint32_t	rcq_cid;
-	/* SRQ context id. */
-	uint32_t	srq_cid;
-	/* Protection domain id. */
-	uint32_t	pd_id;
-	/* SQ PBL physical address. */
-	uint64_t	sq_pbl;
-	/* RQ PBL physical address. */
-	uint64_t	rq_pbl;
-	/* IRRQ address. */
-	uint64_t	irrq_addr;
-	/* ORRQ address. */
-	uint64_t	orrq_addr;
-} cmdq_create_qp_t, *pcmdq_create_qp_t;
-
-/* creq_create_qp_resp (size:128b/16B) */
-
-typedef struct creq_create_qp_resp {
-	uint8_t	type;
+	#define SQ_RDMA_V3_FLAGS_SE			UINT32_C(0x8)
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * Indicate that inline data is posted to the SQ following
+	 * this WQE. This bit may be 1 only for write operations.
 	 */
-	#define CREQ_CREATE_QP_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_CREATE_QP_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_CREATE_QP_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_CREATE_QP_RESP_TYPE_LAST	CREQ_CREATE_QP_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* QP context id */
-	uint32_t	xid;
-	uint8_t	v;
+	#define SQ_RDMA_V3_FLAGS_INLINE		UINT32_C(0x10)
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * If set to 1, then the timestamp from the WQE is used. If
+	 * cleared to 0, then TWE provides the timestamp.
 	 */
-	#define CREQ_CREATE_QP_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Create QP command response. */
-	#define CREQ_CREATE_QP_RESP_EVENT_CREATE_QP UINT32_C(0x1)
-	#define CREQ_CREATE_QP_RESP_EVENT_LAST	CREQ_CREATE_QP_RESP_EVENT_CREATE_QP
+	#define SQ_RDMA_V3_FLAGS_WQE_TS_EN		UINT32_C(0x20)
 	/*
-	 * Support for optimized transmit path to lower latency
-	 * for WQEs with inline data has been enabled for this QP.
+	 * When set to '1', this operation will cause a trace capture in
+	 * each block it passes through.
 	 */
-	uint8_t	optimized_transmit_enabled;
-	uint8_t	reserved48[5];
-} creq_create_qp_resp_t, *pcreq_create_qp_resp_t;
-
-/**************
- * destroy_qp *
- **************/
-
-
-/* cmdq_destroy_qp (size:192b/24B) */
-
-typedef struct cmdq_destroy_qp {
-	/* Command opcode. */
-	uint8_t	opcode;
+	#define SQ_RDMA_V3_FLAGS_DEBUG_TRACE		UINT32_C(0x40)
+	/*  */
+	uint8_t	wqe_size;
 	/*
-	 * Destroy QP command deletes the QP context and ceases
-	 * any further reference.
+	 * The number of 16 bytes chunks of data including this first
+	 * word of the request that are a valid part of the request. The
+	 * valid 16 bytes units other than the WQE structure can be
+	 * SGEs (Scatter Gather Elements) OR inline data.
+	 *
+	 * This field shall never exceed 32 for WQEs of this type.
+	 */
+	#define SQ_RDMA_V3_WQE_SIZE_MASK UINT32_C(0x3f)
+	#define SQ_RDMA_V3_WQE_SIZE_SFT 0
+	uint8_t	inline_length;
+	/*
+	 * When inline flag is '1', this field determines the number of
+	 * bytes that are valid in the last 16B unit of the inline WQE.
+	 * Zero means all 16 bytes are valid. One means only bits 7:0 of
+	 * the last 16B unit are valid. This means the total size of the
+	 * inline data is determined by a combination of the wqe_size field
+	 * and this inline_length field.
+	 *
+	 * `inline_size = ((wqe_size - 1) * 16) - data_offset_in_bytes +
+	 * ((inline_length == 0 ) ? 16 : inline_length)
+	 *
+	 * Where data_offset_in_bytes is the offset within the WQE where
+	 * the data field starts.
+	 *
+	 * Note that this field is not applicable for zero-length inline
+	 * WQEs.
 	 */
-	#define CMDQ_DESTROY_QP_OPCODE_DESTROY_QP UINT32_C(0x2)
-	#define CMDQ_DESTROY_QP_OPCODE_LAST	CMDQ_DESTROY_QP_OPCODE_DESTROY_QP
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	/* QP context id */
-	uint32_t	qp_cid;
-	uint32_t	unused_0;
-} cmdq_destroy_qp_t, *pcmdq_destroy_qp_t;
-
-/* creq_destroy_qp_resp (size:128b/16B) */
-
-typedef struct creq_destroy_qp_resp {
-	uint8_t	type;
+	#define SQ_RDMA_V3_INLINE_LENGTH_MASK UINT32_C(0xf)
+	#define SQ_RDMA_V3_INLINE_LENGTH_SFT 0
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * This value will be returned in the completion if the completion is
+	 * signaled.
 	 */
-	#define CREQ_DESTROY_QP_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_DESTROY_QP_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_DESTROY_QP_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_DESTROY_QP_RESP_TYPE_LAST	CREQ_DESTROY_QP_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* QP context id */
-	uint32_t	xid;
-	uint8_t	v;
+	uint32_t	opaque;
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * Immediate data - valid for RDMA Write with immediate and
+	 * causes the controller to add immDt header with this value
 	 */
-	#define CREQ_DESTROY_QP_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Destroy QP command response. */
-	#define CREQ_DESTROY_QP_RESP_EVENT_DESTROY_QP UINT32_C(0x2)
-	#define CREQ_DESTROY_QP_RESP_EVENT_LAST	CREQ_DESTROY_QP_RESP_EVENT_DESTROY_QP
-	uint8_t	reserved48[6];
-} creq_destroy_qp_resp_t, *pcreq_destroy_qp_resp_t;
-
-/*************
- * modify_qp *
- *************/
-
-
-/* cmdq_modify_qp (size:1024b/128B) */
-
-typedef struct cmdq_modify_qp {
-	/* Command opcode. */
-	uint8_t	opcode;
+	uint32_t	imm_data;
+	uint32_t	reserved2;
+	/* Remote VA sent to the destination QP */
+	uint64_t	remote_va;
 	/*
-	 * Modify QP command changes QP states and other QP specific
-	 * parameters.
+	 * R_Key provided by remote node when the connection was
+	 * established and placed in the RETH header. It identify the
+	 * MRW on the remote host
 	 */
-	#define CMDQ_MODIFY_QP_OPCODE_MODIFY_QP UINT32_C(0x3)
-	#define CMDQ_MODIFY_QP_OPCODE_LAST	CMDQ_MODIFY_QP_OPCODE_MODIFY_QP
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	/* Modify mask signifies the field that is requesting the change. */
-	uint32_t	modify_mask;
-	/* QP state change. */
-	#define CMDQ_MODIFY_QP_MODIFY_MASK_STATE		UINT32_C(0x1)
-	/* Enable SQ drain asynchronous notification change. */
-	#define CMDQ_MODIFY_QP_MODIFY_MASK_EN_SQD_ASYNC_NOTIFY	UINT32_C(0x2)
-	/* Access change. */
-	#define CMDQ_MODIFY_QP_MODIFY_MASK_ACCESS		UINT32_C(0x4)
-	/* P_KEY change. */
-	#define CMDQ_MODIFY_QP_MODIFY_MASK_PKEY			UINT32_C(0x8)
-	/* Q_KEY index change. */
-	#define CMDQ_MODIFY_QP_MODIFY_MASK_QKEY			UINT32_C(0x10)
-	/* Destination GID change. */
-	#define CMDQ_MODIFY_QP_MODIFY_MASK_DGID			UINT32_C(0x20)
-	/* Flow label change. */
-	#define CMDQ_MODIFY_QP_MODIFY_MASK_FLOW_LABEL		UINT32_C(0x40)
-	/* SGID change. */
-	#define CMDQ_MODIFY_QP_MODIFY_MASK_SGID_INDEX		UINT32_C(0x80)
-	/* Hop limit change. */
-	#define CMDQ_MODIFY_QP_MODIFY_MASK_HOP_LIMIT		UINT32_C(0x100)
-	/* Traffic class change. */
-	#define CMDQ_MODIFY_QP_MODIFY_MASK_TRAFFIC_CLASS	UINT32_C(0x200)
-	/* destination MAC change. */
-	#define CMDQ_MODIFY_QP_MODIFY_MASK_DEST_MAC		UINT32_C(0x400)
-	/* Ping pong push mode change. */
-	#define CMDQ_MODIFY_QP_MODIFY_MASK_PINGPONG_PUSH_MODE	UINT32_C(0x800)
-	/* Path MTU change. */
-	#define CMDQ_MODIFY_QP_MODIFY_MASK_PATH_MTU		UINT32_C(0x1000)
-	/* Timeout change. */
-	#define CMDQ_MODIFY_QP_MODIFY_MASK_TIMEOUT		UINT32_C(0x2000)
-	/* Retry count change. */
-	#define CMDQ_MODIFY_QP_MODIFY_MASK_RETRY_CNT		UINT32_C(0x4000)
-	/* RNR Retry change. */
-	#define CMDQ_MODIFY_QP_MODIFY_MASK_RNR_RETRY		UINT32_C(0x8000)
-	/* RQ start packet sequence number change. */
-	#define CMDQ_MODIFY_QP_MODIFY_MASK_RQ_PSN		UINT32_C(0x10000)
-	/* Max outstanding RDMA read atomic change. */
-	#define CMDQ_MODIFY_QP_MODIFY_MASK_MAX_RD_ATOMIC	UINT32_C(0x20000)
-	/* RNR minimum timer change. */
-	#define CMDQ_MODIFY_QP_MODIFY_MASK_MIN_RNR_TIMER	UINT32_C(0x40000)
-	/* SQ start packet sequence number change. */
-	#define CMDQ_MODIFY_QP_MODIFY_MASK_SQ_PSN		UINT32_C(0x80000)
-	/* Max destination outstanding RDMA read atomic change. */
-	#define CMDQ_MODIFY_QP_MODIFY_MASK_MAX_DEST_RD_ATOMIC	UINT32_C(0x100000)
-	/* Max send WQE change. */
-	#define CMDQ_MODIFY_QP_MODIFY_MASK_SQ_SIZE		UINT32_C(0x200000)
-	/* Max recv WQE change. */
-	#define CMDQ_MODIFY_QP_MODIFY_MASK_RQ_SIZE		UINT32_C(0x400000)
-	/* Max recv SGEs per SWQE change. */
-	#define CMDQ_MODIFY_QP_MODIFY_MASK_SQ_SGE		UINT32_C(0x800000)
-	/* Max send SGEs per RWQE change. */
-	#define CMDQ_MODIFY_QP_MODIFY_MASK_RQ_SGE		UINT32_C(0x1000000)
-	/* Max inline data length change. */
-	#define CMDQ_MODIFY_QP_MODIFY_MASK_MAX_INLINE_DATA	UINT32_C(0x2000000)
-	/* Destination QP id change. */
-	#define CMDQ_MODIFY_QP_MODIFY_MASK_DEST_QP_ID		UINT32_C(0x4000000)
-	/* Source MAC change. */
-	#define CMDQ_MODIFY_QP_MODIFY_MASK_SRC_MAC		UINT32_C(0x8000000)
-	/* Source VLAN id change. */
-	#define CMDQ_MODIFY_QP_MODIFY_MASK_VLAN_ID		UINT32_C(0x10000000)
-	/* Congestion control RoCE v2 change. */
-	#define CMDQ_MODIFY_QP_MODIFY_MASK_ENABLE_CC		UINT32_C(0x20000000)
-	/* IP TOS ECN change */
-	#define CMDQ_MODIFY_QP_MODIFY_MASK_TOS_ECN		UINT32_C(0x40000000)
-	/* IP TOS DSCP change */
-	#define CMDQ_MODIFY_QP_MODIFY_MASK_TOS_DSCP		UINT32_C(0x80000000)
-	/* QP context id */
-	uint32_t	qp_cid;
-	uint8_t	network_type_en_sqd_async_notify_new_state;
-	/* New QP state. */
-	#define CMDQ_MODIFY_QP_NEW_STATE_MASK	UINT32_C(0xf)
-	#define CMDQ_MODIFY_QP_NEW_STATE_SFT	0
-	/* Reset. */
-		#define CMDQ_MODIFY_QP_NEW_STATE_RESET	UINT32_C(0x0)
-	/* Init. */
-		#define CMDQ_MODIFY_QP_NEW_STATE_INIT		UINT32_C(0x1)
-	/* Ready To Receive. */
-		#define CMDQ_MODIFY_QP_NEW_STATE_RTR		UINT32_C(0x2)
-	/* Ready To Send. */
-		#define CMDQ_MODIFY_QP_NEW_STATE_RTS		UINT32_C(0x3)
-	/* SQ Drain. */
-		#define CMDQ_MODIFY_QP_NEW_STATE_SQD		UINT32_C(0x4)
-	/* SQ Error. */
-		#define CMDQ_MODIFY_QP_NEW_STATE_SQE		UINT32_C(0x5)
-	/* Error. */
-		#define CMDQ_MODIFY_QP_NEW_STATE_ERR		UINT32_C(0x6)
-		#define CMDQ_MODIFY_QP_NEW_STATE_LAST	CMDQ_MODIFY_QP_NEW_STATE_ERR
-	/* Enable SQ drain asynchronous notification. */
-	#define CMDQ_MODIFY_QP_EN_SQD_ASYNC_NOTIFY	UINT32_C(0x10)
-	/* unused1 is 1 b */
-	#define CMDQ_MODIFY_QP_UNUSED1		UINT32_C(0x20)
-	/* network type. */
-	#define CMDQ_MODIFY_QP_NETWORK_TYPE_MASK	UINT32_C(0xc0)
-	#define CMDQ_MODIFY_QP_NETWORK_TYPE_SFT	6
-	/* RoCEv1. */
-		#define CMDQ_MODIFY_QP_NETWORK_TYPE_ROCEV1	(UINT32_C(0x0) << 6)
-	/* RoCEv2 IPv4. */
-		#define CMDQ_MODIFY_QP_NETWORK_TYPE_ROCEV2_IPV4  (UINT32_C(0x2) << 6)
-	/* RoCEv2 IPv6. */
-		#define CMDQ_MODIFY_QP_NETWORK_TYPE_ROCEV2_IPV6  (UINT32_C(0x3) << 6)
-		#define CMDQ_MODIFY_QP_NETWORK_TYPE_LAST	CMDQ_MODIFY_QP_NETWORK_TYPE_ROCEV2_IPV6
-	/* Access flags. */
-	uint8_t	access;
-	#define CMDQ_MODIFY_QP_ACCESS_REMOTE_ATOMIC_REMOTE_READ_REMOTE_WRITE_LOCAL_WRITE_MASK		UINT32_C(0xff)
-	#define CMDQ_MODIFY_QP_ACCESS_REMOTE_ATOMIC_REMOTE_READ_REMOTE_WRITE_LOCAL_WRITE_SFT		0
-	/* Local write access. */
-	#define CMDQ_MODIFY_QP_ACCESS_LOCAL_WRITE							UINT32_C(0x1)
-	/* Remote write access. */
-	#define CMDQ_MODIFY_QP_ACCESS_REMOTE_WRITE							UINT32_C(0x2)
-	/* Remote read access. */
-	#define CMDQ_MODIFY_QP_ACCESS_REMOTE_READ							UINT32_C(0x4)
-	/* Remote atomic access. */
-	#define CMDQ_MODIFY_QP_ACCESS_REMOTE_ATOMIC							UINT32_C(0x8)
-	/* P_KEY. */
-	uint16_t	pkey;
-	/* Q_KEY. */
-	uint32_t	qkey;
-	/* Destination GID. */
-	uint32_t	dgid[4];
-	/* Flow label. */
-	uint32_t	flow_label;
-	/* Source GID index. */
-	uint16_t	sgid_index;
-	/* Hop limit. */
-	uint8_t	hop_limit;
-	/* Traffic class. */
-	uint8_t	traffic_class;
-	/* Destination MAC address. */
-	uint16_t	dest_mac[3];
-	uint8_t	tos_dscp_tos_ecn;
-	/* IP TOS ECN. Valid values are 1 or 2 when ECN is enabled. */
-	#define CMDQ_MODIFY_QP_TOS_ECN_MASK UINT32_C(0x3)
-	#define CMDQ_MODIFY_QP_TOS_ECN_SFT  0
-	/* IP TOS DSCP. */
-	#define CMDQ_MODIFY_QP_TOS_DSCP_MASK UINT32_C(0xfc)
-	#define CMDQ_MODIFY_QP_TOS_DSCP_SFT 2
-	uint8_t	path_mtu_pingpong_push_enable;
+	uint32_t	remote_key;
+	uint32_t	timestamp;
 	/*
-	 * Driver requests for ping pong push mode to be enbabled for this
-	 * QP. This request can be done only during modify from RST to INIT
-	 * state.
+	 * This field specifies a 24-bit timestamp that can be passed
+	 * down the TX path and optionally logged in the TXP timestamp
+	 * histogram.
 	 */
-	#define CMDQ_MODIFY_QP_PINGPONG_PUSH_ENABLE	UINT32_C(0x1)
-	/* unused3 is 3 b */
-	#define CMDQ_MODIFY_QP_UNUSED3_MASK		UINT32_C(0xe)
-	#define CMDQ_MODIFY_QP_UNUSED3_SFT		1
-	/* Path MTU. */
-	#define CMDQ_MODIFY_QP_PATH_MTU_MASK		UINT32_C(0xf0)
-	#define CMDQ_MODIFY_QP_PATH_MTU_SFT		4
-	/* 256. */
-		#define CMDQ_MODIFY_QP_PATH_MTU_MTU_256	(UINT32_C(0x0) << 4)
-	/* 512. */
-		#define CMDQ_MODIFY_QP_PATH_MTU_MTU_512	(UINT32_C(0x1) << 4)
-	/* 1024. */
-		#define CMDQ_MODIFY_QP_PATH_MTU_MTU_1024	(UINT32_C(0x2) << 4)
-	/* 2048. */
-		#define CMDQ_MODIFY_QP_PATH_MTU_MTU_2048	(UINT32_C(0x3) << 4)
-	/* 4096. */
-		#define CMDQ_MODIFY_QP_PATH_MTU_MTU_4096	(UINT32_C(0x4) << 4)
-	/* 8192. */
-		#define CMDQ_MODIFY_QP_PATH_MTU_MTU_8192	(UINT32_C(0x5) << 4)
-		#define CMDQ_MODIFY_QP_PATH_MTU_LAST		CMDQ_MODIFY_QP_PATH_MTU_MTU_8192
-	/* Timeout value for SWQEs. */
-	uint8_t	timeout;
-	/* Max retry count for WQEs. */
-	uint8_t	retry_cnt;
-	/* Max RNR retry count for WQEs. */
-	uint8_t	rnr_retry;
-	/* Min RNR timer that the QP will report to the remote. */
-	uint8_t	min_rnr_timer;
-	/* RQ start packet sequence number. */
-	uint32_t	rq_psn;
-	/* SQ start packet sequence number. */
-	uint32_t	sq_psn;
-	/* Max outstanding RDMA read atomic. */
-	uint8_t	max_rd_atomic;
-	/* Max destination outstanding RDMA read atomic. */
-	uint8_t	max_dest_rd_atomic;
-	uint16_t	enable_cc;
-	/* Enable congestion control. */
-	#define CMDQ_MODIFY_QP_ENABLE_CC	UINT32_C(0x1)
-	/* unused15 is 15 b */
-	#define CMDQ_MODIFY_QP_UNUSED15_MASK UINT32_C(0xfffe)
-	#define CMDQ_MODIFY_QP_UNUSED15_SFT  1
-	/* Max send WQE. */
-	uint32_t	sq_size;
-	/* Max recv WQE. */
-	uint32_t	rq_size;
-	/* Max send SGEs per SWQE. */
-	uint16_t	sq_sge;
-	/* Max recv SGEs per RWQE. */
-	uint16_t	rq_sge;
-	/* Max inline data length (upto 120 bytes). */
-	uint32_t	max_inline_data;
-	/* Destination QP id. */
-	uint32_t	dest_qp_id;
-	/* This is the DPI RoCE driver allocated for ping pong push. */
-	uint32_t	pingpong_push_dpi;
-	/* Source MAC. (Unused. Comes from Source GID index) */
-	uint16_t	src_mac[3];
-	uint16_t	vlan_pcp_vlan_dei_vlan_id;
-	/* VLAN id. (Unused. Comes from Source GID index) */
-	#define CMDQ_MODIFY_QP_VLAN_ID_MASK UINT32_C(0xfff)
-	#define CMDQ_MODIFY_QP_VLAN_ID_SFT  0
-	/* VLAN DEI field - Drop Eligibility Indicator. */
-	#define CMDQ_MODIFY_QP_VLAN_DEI	UINT32_C(0x1000)
-	/* VLAN PCP field - Priority Code Point. */
-	#define CMDQ_MODIFY_QP_VLAN_PCP_MASK UINT32_C(0xe000)
-	#define CMDQ_MODIFY_QP_VLAN_PCP_SFT 13
-	/* IRRQ address. */
-	uint64_t	irrq_addr;
-	/* ORRQ address. */
-	uint64_t	orrq_addr;
-} cmdq_modify_qp_t, *pcmdq_modify_qp_t;
+	#define SQ_RDMA_V3_TIMESTAMP_MASK UINT32_C(0xffffff)
+	#define SQ_RDMA_V3_TIMESTAMP_SFT 0
+	/*
+	 * When inline=0, then this area is filled with from 1 to 30 SGEs
+	 * based on the wqe_size field.
+	 *
+	 * When inline=1, this area is filled with payload data for the send.
+	 * Length of data is described in the inline_length field. Bits [7:0]
+	 * of word 0 hold the first byte to go out on the wire.
+	 */
+	uint32_t	data[24];
+} sq_rdma_v3_t, *psq_rdma_v3_t;
 
-/* creq_modify_qp_resp (size:128b/16B) */
+/* SQ RDMA WQE V3 header for RC SQs. */
+/* sq_rdma_hdr_v3 (size:256b/32B) */
 
-typedef struct creq_modify_qp_resp {
-	uint8_t	type;
+typedef struct sq_rdma_hdr_v3 {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
+	/*
+	 * RDMA Write V3
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
+	 */
+	#define SQ_RDMA_HDR_V3_WQE_TYPE_WRITE_WQE_V3	UINT32_C(0x15)
+	/*
+	 * RDMA Write with Immediate V3
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
+	 */
+	#define SQ_RDMA_HDR_V3_WQE_TYPE_WRITE_W_IMMED_V3 UINT32_C(0x16)
+	/*
+	 * RDMA Read V3
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
+	 */
+	#define SQ_RDMA_HDR_V3_WQE_TYPE_READ_WQE_V3	UINT32_C(0x17)
+	#define SQ_RDMA_HDR_V3_WQE_TYPE_LAST		SQ_RDMA_HDR_V3_WQE_TYPE_READ_WQE_V3
+	uint8_t	flags;
+	/*
+	 * Set if completion signaling is requested. If this bit is
+	 * 0, and the SQ is configured to support Unsignaled
+	 * completion the controller should not generate a CQE
+	 * unless there was an error. This refers to CQE on the
+	 * sender side (The se flag refers to the receiver side).
+	 */
+	#define SQ_RDMA_HDR_V3_FLAGS_SIGNAL_COMP		UINT32_C(0x1)
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * Indication to complete all previous RDMA Read or Atomic
+	 * WQEs on the SQ before executing this WQE
 	 */
-	#define CREQ_MODIFY_QP_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_MODIFY_QP_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_MODIFY_QP_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_MODIFY_QP_RESP_TYPE_LAST	CREQ_MODIFY_QP_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* QP context id */
-	uint32_t	xid;
-	uint8_t	v;
+	#define SQ_RDMA_HDR_V3_FLAGS_RD_OR_ATOMIC_FENCE	UINT32_C(0x2)
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * Unconditional fence. Indication to complete all previous
+	 * SQ's WQEs before executing this WQE.
 	 */
-	#define CREQ_MODIFY_QP_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Modify QP command response. */
-	#define CREQ_MODIFY_QP_RESP_EVENT_MODIFY_QP UINT32_C(0x3)
-	#define CREQ_MODIFY_QP_RESP_EVENT_LAST	CREQ_MODIFY_QP_RESP_EVENT_MODIFY_QP
-	uint8_t	pingpong_push_state_index_enabled;
+	#define SQ_RDMA_HDR_V3_FLAGS_UC_FENCE		UINT32_C(0x4)
 	/*
-	 * When set it indicates that FW was able to successfully enable
-	 * ping pong push mode for this QP.
+	 * Solicit event. Indication sent in BTH header to the
+	 * receiver to generate a Completion Event Notification,
+	 * i.e. CNQE.
 	 */
-	#define CREQ_MODIFY_QP_RESP_PINGPONG_PUSH_ENABLED	UINT32_C(0x1)
+	#define SQ_RDMA_HDR_V3_FLAGS_SE			UINT32_C(0x8)
 	/*
-	 * When ping pong push mode is enabled this field will give the
-	 * index into the push page where the QP has been mapped.
+	 * Indicate that inline data is posted to the SQ following
+	 * this WQE. This bit may be 1 only for write operations.
 	 */
-	#define CREQ_MODIFY_QP_RESP_PINGPONG_PUSH_INDEX_MASK  UINT32_C(0xe)
-	#define CREQ_MODIFY_QP_RESP_PINGPONG_PUSH_INDEX_SFT   1
+	#define SQ_RDMA_HDR_V3_FLAGS_INLINE		UINT32_C(0x10)
 	/*
-	 * This bit will tell whether to use ping or pong buffer
-	 * for first push operation. 0 - ping buffer, 1 - pong buffer.
+	 * If set to 1, then the timestamp from the WQE is used. If
+	 * cleared to 0, then TWE provides the timestamp.
 	 */
-	#define CREQ_MODIFY_QP_RESP_PINGPONG_PUSH_STATE	UINT32_C(0x10)
-	uint8_t	reserved8;
-	/* Scrambled src mac needed to calculate UDP source port. */
-	uint32_t	lag_src_mac;
-} creq_modify_qp_resp_t, *pcreq_modify_qp_resp_t;
-
-/************
- * query_qp *
- ************/
-
-
-/* cmdq_query_qp (size:192b/24B) */
-
-typedef struct cmdq_query_qp {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Query QP command retrieves info about the specified QP. */
-	#define CMDQ_QUERY_QP_OPCODE_QUERY_QP UINT32_C(0x4)
-	#define CMDQ_QUERY_QP_OPCODE_LAST	CMDQ_QUERY_QP_OPCODE_QUERY_QP
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	/* QP context id */
-	uint32_t	qp_cid;
-	uint32_t	unused_0;
-} cmdq_query_qp_t, *pcmdq_query_qp_t;
-
-/* creq_query_qp_resp (size:128b/16B) */
-
-typedef struct creq_query_qp_resp {
-	uint8_t	type;
+	#define SQ_RDMA_HDR_V3_FLAGS_WQE_TS_EN		UINT32_C(0x20)
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * When set to '1', this operation will cause a trace capture in
+	 * each block it passes through.
 	 */
-	#define CREQ_QUERY_QP_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_QUERY_QP_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_QUERY_QP_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_QUERY_QP_RESP_TYPE_LAST	CREQ_QUERY_QP_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Side buffer size in 16-byte units */
-	uint32_t	size;
-	uint8_t	v;
+	#define SQ_RDMA_HDR_V3_FLAGS_DEBUG_TRACE		UINT32_C(0x40)
+	/*  */
+	uint8_t	wqe_size;
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * The number of 16 bytes chunks of data including this first
+	 * word of the request that are a valid part of the request. The
+	 * valid 16 bytes units other than the WQE structure can be
+	 * SGEs (Scatter Gather Elements) OR inline data.
+	 *
+	 * This field shall never exceed 32 for WQEs of this type.
+	 */
+	#define SQ_RDMA_HDR_V3_WQE_SIZE_MASK UINT32_C(0x3f)
+	#define SQ_RDMA_HDR_V3_WQE_SIZE_SFT 0
+	uint8_t	inline_length;
+	/*
+	 * When inline flag is '1', this field determines the number of
+	 * bytes that are valid in the last 16B unit of the inline WQE.
+	 * Zero means all 16 bytes are valid. One means only bits 7:0 of
+	 * the last 16B unit are valid. This means the total size of the
+	 * inline data is determined by a combination of the wqe_size field
+	 * and this inline_length field.
+	 *
+	 * `inline_size = ((wqe_size - 1) * 16) - data_offset_in_bytes +
+	 * ((inline_length == 0 ) ? 16 : inline_length)
+	 *
+	 * Where data_offset_in_bytes is the offset within the WQE where
+	 * the data field starts.
+	 *
+	 * Note that this field is not applicable for zero-length inline
+	 * WQEs.
 	 */
-	#define CREQ_QUERY_QP_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Query QP command response. */
-	#define CREQ_QUERY_QP_RESP_EVENT_QUERY_QP UINT32_C(0x4)
-	#define CREQ_QUERY_QP_RESP_EVENT_LAST	CREQ_QUERY_QP_RESP_EVENT_QUERY_QP
-	uint8_t	reserved48[6];
-} creq_query_qp_resp_t, *pcreq_query_qp_resp_t;
-
-/* Query QP command response side buffer structure. */
-/* creq_query_qp_resp_sb (size:832b/104B) */
-
-typedef struct creq_query_qp_resp_sb {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Query QP command response. */
-	#define CREQ_QUERY_QP_RESP_SB_OPCODE_QUERY_QP UINT32_C(0x4)
-	#define CREQ_QUERY_QP_RESP_SB_OPCODE_LAST	CREQ_QUERY_QP_RESP_SB_OPCODE_QUERY_QP
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* QP context id */
-	uint32_t	xid;
-	uint8_t	en_sqd_async_notify_state;
-	/* QP state */
-	#define CREQ_QUERY_QP_RESP_SB_STATE_MASK		UINT32_C(0xf)
-	#define CREQ_QUERY_QP_RESP_SB_STATE_SFT		0
-	/* Reset. */
-		#define CREQ_QUERY_QP_RESP_SB_STATE_RESET		UINT32_C(0x0)
-	/* Init. */
-		#define CREQ_QUERY_QP_RESP_SB_STATE_INIT		UINT32_C(0x1)
-	/* Ready To Receive. */
-		#define CREQ_QUERY_QP_RESP_SB_STATE_RTR		UINT32_C(0x2)
-	/* Ready To Send. */
-		#define CREQ_QUERY_QP_RESP_SB_STATE_RTS		UINT32_C(0x3)
-	/* SQ Drain. */
-		#define CREQ_QUERY_QP_RESP_SB_STATE_SQD		UINT32_C(0x4)
-	/* SQ Error. */
-		#define CREQ_QUERY_QP_RESP_SB_STATE_SQE		UINT32_C(0x5)
-	/* Error. */
-		#define CREQ_QUERY_QP_RESP_SB_STATE_ERR		UINT32_C(0x6)
-		#define CREQ_QUERY_QP_RESP_SB_STATE_LAST		CREQ_QUERY_QP_RESP_SB_STATE_ERR
-	/* SQ drain asynchronous notification. */
-	#define CREQ_QUERY_QP_RESP_SB_EN_SQD_ASYNC_NOTIFY	UINT32_C(0x10)
-	/* Enable congestion control. */
-	#define CREQ_QUERY_QP_RESP_SB_UNUSED3_MASK		UINT32_C(0xe0)
-	#define CREQ_QUERY_QP_RESP_SB_UNUSED3_SFT		5
-	/* Access flags. */
-	uint8_t	access;
-	#define CREQ_QUERY_QP_RESP_SB_ACCESS_REMOTE_ATOMIC_REMOTE_READ_REMOTE_WRITE_LOCAL_WRITE_MASK		UINT32_C(0xff)
-	#define CREQ_QUERY_QP_RESP_SB_ACCESS_REMOTE_ATOMIC_REMOTE_READ_REMOTE_WRITE_LOCAL_WRITE_SFT		0
-	/* Local write access. */
-	#define CREQ_QUERY_QP_RESP_SB_ACCESS_LOCAL_WRITE							UINT32_C(0x1)
-	/* Remote write access. */
-	#define CREQ_QUERY_QP_RESP_SB_ACCESS_REMOTE_WRITE							UINT32_C(0x2)
-	/* Remote read access. */
-	#define CREQ_QUERY_QP_RESP_SB_ACCESS_REMOTE_READ							UINT32_C(0x4)
-	/* Remote atomic access. */
-	#define CREQ_QUERY_QP_RESP_SB_ACCESS_REMOTE_ATOMIC							UINT32_C(0x8)
-	/* P_KEY index. */
-	uint16_t	pkey;
-	/* Q_KEY. */
-	uint32_t	qkey;
-	uint32_t	reserved32;
-	/* Destination GID. */
-	uint32_t	dgid[4];
-	/* Flow label. */
-	uint32_t	flow_label;
-	/* Source GID index. */
-	uint16_t	sgid_index;
-	/* Hop limit. */
-	uint8_t	hop_limit;
-	/* Traffic class. */
-	uint8_t	traffic_class;
-	/* Destination MAC address. */
-	uint16_t	dest_mac[3];
-	uint16_t	path_mtu_dest_vlan_id;
-	/* Destination VLAN ID. */
-	#define CREQ_QUERY_QP_RESP_SB_DEST_VLAN_ID_MASK UINT32_C(0xfff)
-	#define CREQ_QUERY_QP_RESP_SB_DEST_VLAN_ID_SFT 0
-	/* Path MTU. */
-	#define CREQ_QUERY_QP_RESP_SB_PATH_MTU_MASK	UINT32_C(0xf000)
-	#define CREQ_QUERY_QP_RESP_SB_PATH_MTU_SFT	12
-	/* 256. */
-		#define CREQ_QUERY_QP_RESP_SB_PATH_MTU_MTU_256   (UINT32_C(0x0) << 12)
-	/* 512. */
-		#define CREQ_QUERY_QP_RESP_SB_PATH_MTU_MTU_512   (UINT32_C(0x1) << 12)
-	/* 1024. */
-		#define CREQ_QUERY_QP_RESP_SB_PATH_MTU_MTU_1024  (UINT32_C(0x2) << 12)
-	/* 2048. */
-		#define CREQ_QUERY_QP_RESP_SB_PATH_MTU_MTU_2048  (UINT32_C(0x3) << 12)
-	/* 4096. */
-		#define CREQ_QUERY_QP_RESP_SB_PATH_MTU_MTU_4096  (UINT32_C(0x4) << 12)
-	/* 8192. */
-		#define CREQ_QUERY_QP_RESP_SB_PATH_MTU_MTU_8192  (UINT32_C(0x5) << 12)
-		#define CREQ_QUERY_QP_RESP_SB_PATH_MTU_LAST	CREQ_QUERY_QP_RESP_SB_PATH_MTU_MTU_8192
-	/* Timeout value for SWQEs. */
-	uint8_t	timeout;
-	/* Max retry count for WQEs. */
-	uint8_t	retry_cnt;
-	/* Max RNR retry count for WQEs. */
-	uint8_t	rnr_retry;
-	/* Min RNR timer that the QP will report to the remote. */
-	uint8_t	min_rnr_timer;
-	/* RQ start packet sequence number. */
-	uint32_t	rq_psn;
-	/* SQ start packet sequence number. */
-	uint32_t	sq_psn;
-	/* Max outstanding RDMA read atomic. */
-	uint8_t	max_rd_atomic;
-	/* Max destination outstanding RDMA read atomic. */
-	uint8_t	max_dest_rd_atomic;
-	uint8_t	tos_dscp_tos_ecn;
-	/* IP TOS ECN. */
-	#define CREQ_QUERY_QP_RESP_SB_TOS_ECN_MASK UINT32_C(0x3)
-	#define CREQ_QUERY_QP_RESP_SB_TOS_ECN_SFT  0
-	/* IP TOS DSCP. */
-	#define CREQ_QUERY_QP_RESP_SB_TOS_DSCP_MASK UINT32_C(0xfc)
-	#define CREQ_QUERY_QP_RESP_SB_TOS_DSCP_SFT 2
-	uint8_t	enable_cc;
-	/* enable_cc is 1 b */
-	#define CREQ_QUERY_QP_RESP_SB_ENABLE_CC	UINT32_C(0x1)
-	/* Max send WQE. */
-	uint32_t	sq_size;
-	/* Max recv WQE. */
-	uint32_t	rq_size;
-	/* Max send SGEs per SWQE. */
-	uint16_t	sq_sge;
-	/* Max recv SGEs per RWQE (NOT SUPPORTED BY HARDWARE). */
-	uint16_t	rq_sge;
-	/* Max inline data length (upto 120 bytes). */
-	uint32_t	max_inline_data;
-	/* Destination QP id. */
-	uint32_t	dest_qp_id;
-	/* Port ID associated with the QP. */
-	uint16_t	port_id;
-	uint8_t	unused_0;
-	/* Statistic collection ID allocated for this QP. */
-	uint8_t	stat_collection_id;
-	/* Source MAC. */
-	uint16_t	src_mac[3];
-	uint16_t	vlan_pcp_vlan_dei_vlan_id;
-	/* Source VLAN id. */
-	#define CREQ_QUERY_QP_RESP_SB_VLAN_ID_MASK UINT32_C(0xfff)
-	#define CREQ_QUERY_QP_RESP_SB_VLAN_ID_SFT  0
-	/* VLAN DEI field - Drop Eligibility Indicator. */
-	#define CREQ_QUERY_QP_RESP_SB_VLAN_DEI	UINT32_C(0x1000)
-	/* VLAN PCP field - Priority Code Point. */
-	#define CREQ_QUERY_QP_RESP_SB_VLAN_PCP_MASK UINT32_C(0xe000)
-	#define CREQ_QUERY_QP_RESP_SB_VLAN_PCP_SFT 13
-} creq_query_qp_resp_sb_t, *pcreq_query_qp_resp_sb_t;
-
-/*******************
- * query_qp_extend *
- *******************/
-
-
-/* cmdq_query_qp_extend (size:192b/24B) */
-
-typedef struct cmdq_query_qp_extend {
-	/* Command opcode. */
-	uint8_t	opcode;
+	#define SQ_RDMA_HDR_V3_INLINE_LENGTH_MASK UINT32_C(0xf)
+	#define SQ_RDMA_HDR_V3_INLINE_LENGTH_SFT 0
 	/*
-	 * Query QP extend command retrieves info about multiple QPs associated
-	 * with a specific PF.
+	 * This value will be returned in the completion if the completion is
+	 * signaled.
 	 */
-	#define CMDQ_QUERY_QP_EXTEND_OPCODE_QUERY_QP_EXTEND UINT32_C(0x91)
-	#define CMDQ_QUERY_QP_EXTEND_OPCODE_LAST	CMDQ_QUERY_QP_EXTEND_OPCODE_QUERY_QP_EXTEND
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	/* Number of QPs for which FW needs to query and provide info back to host. */
-	uint8_t	num_qps;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	/* Unique identified for a function */
-	uint32_t	function_id;
-	/* PF number */
-	#define CMDQ_QUERY_QP_EXTEND_PF_NUM_MASK  UINT32_C(0xff)
-	#define CMDQ_QUERY_QP_EXTEND_PF_NUM_SFT   0
-	/* VF number */
-	#define CMDQ_QUERY_QP_EXTEND_VF_NUM_MASK  UINT32_C(0xffff00)
-	#define CMDQ_QUERY_QP_EXTEND_VF_NUM_SFT   8
-	/* When set the vf_num is valid. */
-	#define CMDQ_QUERY_QP_EXTEND_VF_VALID	UINT32_C(0x1000000)
+	uint32_t	opaque;
 	/*
-	 * This is the current index where firmware left off for query qp. Driver
-	 * will pass this back in the next query_qp_extend command.
+	 * Immediate data - valid for RDMA Write with immediate and
+	 * causes the controller to add immDt header with this value
 	 */
-	uint32_t	current_index;
-} cmdq_query_qp_extend_t, *pcmdq_query_qp_extend_t;
+	uint32_t	imm_data;
+	uint32_t	reserved2;
+	/* Remote VA sent to the destination QP */
+	uint64_t	remote_va;
+	/*
+	 * R_Key provided by remote node when the connection was
+	 * established and placed in the RETH header. It identify the
+	 * MRW on the remote host
+	 */
+	uint32_t	remote_key;
+	uint32_t	timestamp;
+	/*
+	 * This field specifies a 24-bit timestamp that can be passed
+	 * down the TX path and optionally logged in the TXP timestamp
+	 * histogram.
+	 */
+	#define SQ_RDMA_HDR_V3_TIMESTAMP_MASK UINT32_C(0xffffff)
+	#define SQ_RDMA_HDR_V3_TIMESTAMP_SFT 0
+} sq_rdma_hdr_v3_t, *psq_rdma_hdr_v3_t;
 
-/* creq_query_qp_extend_resp (size:128b/16B) */
+/* SQ Atomic V3 WQE for RC SQs. */
+/* sq_atomic_v3 (size:448b/56B) */
 
-typedef struct creq_query_qp_extend_resp {
-	uint8_t	type;
+typedef struct sq_atomic_v3 {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * Atomic Compare/Swap V3
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	#define CREQ_QUERY_QP_EXTEND_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_QUERY_QP_EXTEND_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_QUERY_QP_EXTEND_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_QUERY_QP_EXTEND_RESP_TYPE_LAST	CREQ_QUERY_QP_EXTEND_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Side buffer size in 16-byte units */
-	uint32_t	size;
-	uint8_t	v;
+	#define SQ_ATOMIC_V3_WQE_TYPE_ATOMIC_CS_V3 UINT32_C(0x18)
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * Atomic Fetch/Add V3
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	#define CREQ_QUERY_QP_EXTEND_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Query QP extend command response. */
-	#define CREQ_QUERY_QP_EXTEND_RESP_EVENT_QUERY_QP_EXTEND UINT32_C(0x91)
-	#define CREQ_QUERY_QP_EXTEND_RESP_EVENT_LAST	CREQ_QUERY_QP_EXTEND_RESP_EVENT_QUERY_QP_EXTEND
-	uint16_t	reserved16;
+	#define SQ_ATOMIC_V3_WQE_TYPE_ATOMIC_FA_V3 UINT32_C(0x19)
+	#define SQ_ATOMIC_V3_WQE_TYPE_LAST	SQ_ATOMIC_V3_WQE_TYPE_ATOMIC_FA_V3
+	uint8_t	flags;
 	/*
-	 * This is the current index where firmware left off for query qp. Driver
-	 * will pass this back in the next query_qp_extend command.
+	 * Set if completion signaling is requested. If this bit is
+	 * 0, and the SQ is configured to support Unsignaled
+	 * completion the controller should not generate a CQE
+	 * unless there was an error. This refers to CQE on the
+	 * sender side (The se flag refers to the receiver side).
 	 */
-	uint32_t	current_index;
-} creq_query_qp_extend_resp_t, *pcreq_query_qp_extend_resp_t;
-
-/* Query QP extend command response side buffer structure. */
-/* creq_query_qp_extend_resp_sb (size:384b/48B) */
-
-typedef struct creq_query_qp_extend_resp_sb {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Query QP command extend response. */
-	#define CREQ_QUERY_QP_EXTEND_RESP_SB_OPCODE_QUERY_QP_EXTEND UINT32_C(0x91)
-	#define CREQ_QUERY_QP_EXTEND_RESP_SB_OPCODE_LAST	CREQ_QUERY_QP_EXTEND_RESP_SB_OPCODE_QUERY_QP_EXTEND
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* QP context id */
-	uint32_t	xid;
-	uint8_t	state;
-	/* QP state */
-	#define CREQ_QUERY_QP_EXTEND_RESP_SB_STATE_MASK  UINT32_C(0xf)
-	#define CREQ_QUERY_QP_EXTEND_RESP_SB_STATE_SFT   0
-	/* Reset. */
-		#define CREQ_QUERY_QP_EXTEND_RESP_SB_STATE_RESET   UINT32_C(0x0)
-	/* Init. */
-		#define CREQ_QUERY_QP_EXTEND_RESP_SB_STATE_INIT	UINT32_C(0x1)
-	/* Ready To Receive. */
-		#define CREQ_QUERY_QP_EXTEND_RESP_SB_STATE_RTR	UINT32_C(0x2)
-	/* Ready To Send. */
-		#define CREQ_QUERY_QP_EXTEND_RESP_SB_STATE_RTS	UINT32_C(0x3)
-	/* SQ Drain. */
-		#define CREQ_QUERY_QP_EXTEND_RESP_SB_STATE_SQD	UINT32_C(0x4)
-	/* SQ Error. */
-		#define CREQ_QUERY_QP_EXTEND_RESP_SB_STATE_SQE	UINT32_C(0x5)
-	/* Error. */
-		#define CREQ_QUERY_QP_EXTEND_RESP_SB_STATE_ERR	UINT32_C(0x6)
-		#define CREQ_QUERY_QP_EXTEND_RESP_SB_STATE_LAST   CREQ_QUERY_QP_EXTEND_RESP_SB_STATE_ERR
+	#define SQ_ATOMIC_V3_FLAGS_SIGNAL_COMP		UINT32_C(0x1)
+	/*
+	 * Indication to complete all previous RDMA Read or Atomic
+	 * WQEs on the SQ before executing this WQE
+	 */
+	#define SQ_ATOMIC_V3_FLAGS_RD_OR_ATOMIC_FENCE	UINT32_C(0x2)
+	/*
+	 * Unconditional fence. Indication to complete all previous
+	 * SQ's WQEs before executing this WQE.
+	 */
+	#define SQ_ATOMIC_V3_FLAGS_UC_FENCE		UINT32_C(0x4)
+	/*
+	 * Solicit event. Indication sent in BTH header to the
+	 * receiver to generate a Completion Event Notification,
+	 * i.e. CNQE.
+	 */
+	#define SQ_ATOMIC_V3_FLAGS_SE			UINT32_C(0x8)
+	/* NA for this WQE */
+	#define SQ_ATOMIC_V3_FLAGS_INLINE		UINT32_C(0x10)
+	/*
+	 * The atomic WQE does not have a timestamp field, so this field is
+	 * ignored and should be zero.
+	 */
+	#define SQ_ATOMIC_V3_FLAGS_WQE_TS_EN		UINT32_C(0x20)
+	/*
+	 * When set to '1', this operation will cause a trace capture in
+	 * each block it passes through.
+	 */
+	#define SQ_ATOMIC_V3_FLAGS_DEBUG_TRACE		UINT32_C(0x40)
 	/*  */
-	#define CREQ_QUERY_QP_EXTEND_RESP_SB_UNUSED4_MASK UINT32_C(0xf0)
-	#define CREQ_QUERY_QP_EXTEND_RESP_SB_UNUSED4_SFT 4
-	uint8_t	reserved_8;
-	/* Port ID associated with the QP. */
-	uint16_t	port_id;
-	/* Q_KEY. */
-	uint32_t	qkey;
-	/* Source GID index. */
-	uint16_t	sgid_index;
-	/* Network type. */
-	uint8_t	network_type;
-	/* RoCEv1. */
-	#define CREQ_QUERY_QP_EXTEND_RESP_SB_NETWORK_TYPE_ROCEV1	UINT32_C(0x0)
-	/* RoCEv2 IPv4. */
-	#define CREQ_QUERY_QP_EXTEND_RESP_SB_NETWORK_TYPE_ROCEV2_IPV4 UINT32_C(0x2)
-	/* RoCEv2 IPv6. */
-	#define CREQ_QUERY_QP_EXTEND_RESP_SB_NETWORK_TYPE_ROCEV2_IPV6 UINT32_C(0x3)
-	#define CREQ_QUERY_QP_EXTEND_RESP_SB_NETWORK_TYPE_LAST	CREQ_QUERY_QP_EXTEND_RESP_SB_NETWORK_TYPE_ROCEV2_IPV6
-	uint8_t	unused_0;
-	/* Destination GID. */
-	uint32_t	dgid[4];
-	/* Destination QP id. */
-	uint32_t	dest_qp_id;
-	/* Statistic collection ID allocated for this QP. */
-	uint8_t	stat_collection_id;
-	uint8_t	reservred_8;
-	uint16_t	reserved_16;
-} creq_query_qp_extend_resp_sb_t, *pcreq_query_qp_extend_resp_sb_t;
-
-/*
- * TLV encapsulated Query QP extend control command response
- * side buffer.
- */
-/* creq_query_qp_extend_resp_sb_tlv (size:512b/64B) */
-
-typedef struct creq_query_qp_extend_resp_sb_tlv {
+	uint8_t	wqe_size;
 	/*
-	 * The command discriminator is used to differentiate between various
-	 * types of HWRM messages. This includes legacy HWRM and RoCE slowpath
-	 * command messages as well as newer TLV encapsulated HWRM commands.
+	 * The size of the WQE in units of 16B chunks.
 	 *
-	 * For TLV encapsulated messages this field must be 0x8000.
+	 * For the Atomic WQE, this field will always have a value of 4.
 	 */
-	uint16_t	cmd_discr;
-	uint8_t	reserved_8b;
-	uint8_t	tlv_flags;
+	#define SQ_ATOMIC_V3_WQE_SIZE_MASK UINT32_C(0x3f)
+	#define SQ_ATOMIC_V3_WQE_SIZE_SFT 0
+	uint8_t	reserved1;
 	/*
-	 * Indicates the presence of additional TLV encapsulated data
-	 * follows this TLV.
+	 * This value will be returned in the completion if the completion is
+	 * signaled.
 	 */
-	#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_TLV_FLAGS_MORE	UINT32_C(0x1)
-	/* Last TLV in a sequence of TLVs. */
-		#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_TLV_FLAGS_MORE_LAST	UINT32_C(0x0)
-	/* More TLVs follow this TLV. */
-		#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_TLV_FLAGS_MORE_NOT_LAST  UINT32_C(0x1)
+	uint32_t	opaque;
 	/*
-	 * When an HWRM receiver detects a TLV type that it does not
-	 * support with the TLV required flag set, the receiver must
-	 * reject the HWRM message with an error code indicating an
-	 * unsupported TLV type.
+	 * R_Key provided by remote node when the connection was
+	 * established and placed in the AETH header. It identifies the
+	 * MRW on the remote host.
 	 */
-	#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_TLV_FLAGS_REQUIRED	UINT32_C(0x2)
-	/* No */
-		#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_TLV_FLAGS_REQUIRED_NO	(UINT32_C(0x0) << 1)
-	/* Yes */
-		#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_TLV_FLAGS_REQUIRED_YES   (UINT32_C(0x1) << 1)
-		#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_TLV_FLAGS_REQUIRED_LAST CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_TLV_FLAGS_REQUIRED_YES
+	uint32_t	remote_key;
+	uint32_t	reserved2;
+	/* Remote VA sent to the destination QP */
+	uint64_t	remote_va;
 	/*
-	 * This field defines the TLV type value which is divided into
-	 * two ranges to differentiate between global and local TLV types.
-	 * Global TLV types must be unique across all defined TLV types.
-	 * Local TLV types are valid only for extensions to a given
-	 * HWRM message and may be repeated across different HWRM message
-	 * types. There is a direct correlation of each HWRM message type
-	 * to a single global TLV type value.
+	 * For compare/swap, this is the data value to be placed in the
+	 * remote host at the specified remote_VA if the comparison succeeds.
 	 *
-	 * Global TLV range: `0 - (63k-1)`
+	 * For fetch/add, this is the value to be added to the data in the
+	 * remote host at the specified remote_VA.
+	 */
+	uint64_t	swap_data;
+	/*
+	 * For compare/swap, this is the data value to be compared with the
+	 * value in the remote host at the specified remote_VA.
 	 *
-	 * Local TLV range: `63k - (64k-1)`
+	 * This field is not used for fetch/add.
 	 */
-	uint16_t	tlv_type;
+	uint64_t	cmp_data;
 	/*
-	 * Length of the message data encapsulated by this TLV in bytes.
-	 * This length does not include the size of the TLV header itself
-	 * and it must be an integer multiple of 8B.
+	 * The virtual address in local memory or a physical address when
+	 * l_key value is a reserved value of a physical address. Driver
+	 * configures this value in the chip and the chip compares l_key in
+	 * SGEs with that reserved value, if equal it access the physical
+	 * address specified. The chip however MUST verify that the QP allows
+	 * the use reserved key.
 	 */
-	uint16_t	length;
+	uint64_t	va_or_pa;
 	/*
-	 * Size of the tlv encapsulated response,
-	 * including all tlvs and extension data in 16-byte units.
+	 * Local Key associated with this registered MR; The 24 msb of the
+	 * key used to index the MRW Table and the 8 lsb are compared with
+	 * the 8 bits key part stored in the MRWC. The PBL in the MRW Context
+	 * is used to translate the above VA to physical address.
 	 */
-	uint8_t	total_size;
-	uint8_t	reserved56[7];
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Query QP command extend response. */
-	#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_OPCODE_QUERY_QP_EXTEND UINT32_C(0x91)
-	#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_OPCODE_LAST	CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_OPCODE_QUERY_QP_EXTEND
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* QP context id */
-	uint32_t	xid;
-	uint8_t	state;
-	/* QP state */
-	#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_STATE_MASK  UINT32_C(0xf)
-	#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_STATE_SFT   0
-	/* Reset. */
-		#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_STATE_RESET   UINT32_C(0x0)
-	/* Init. */
-		#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_STATE_INIT	UINT32_C(0x1)
-	/* Ready To Receive. */
-		#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_STATE_RTR	UINT32_C(0x2)
-	/* Ready To Send. */
-		#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_STATE_RTS	UINT32_C(0x3)
-	/* SQ Drain. */
-		#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_STATE_SQD	UINT32_C(0x4)
-	/* SQ Error. */
-		#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_STATE_SQE	UINT32_C(0x5)
-	/* Error. */
-		#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_STATE_ERR	UINT32_C(0x6)
-		#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_STATE_LAST   CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_STATE_ERR
-	/*  */
-	#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_UNUSED4_MASK UINT32_C(0xf0)
-	#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_UNUSED4_SFT 4
-	uint8_t	reserved_8;
-	/* Port ID associated with the QP. */
-	uint16_t	port_id;
-	/* Q_KEY. */
-	uint32_t	qkey;
-	/* Source GID index. */
-	uint16_t	sgid_index;
-	/* Network type. */
-	uint8_t	network_type;
-	/* RoCEv1. */
-	#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_NETWORK_TYPE_ROCEV1	UINT32_C(0x0)
-	/* RoCEv2 IPv4. */
-	#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_NETWORK_TYPE_ROCEV2_IPV4 UINT32_C(0x2)
-	/* RoCEv2 IPv6. */
-	#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_NETWORK_TYPE_ROCEV2_IPV6 UINT32_C(0x3)
-	#define CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_NETWORK_TYPE_LAST	CREQ_QUERY_QP_EXTEND_RESP_SB_TLV_NETWORK_TYPE_ROCEV2_IPV6
-	uint8_t	unused_0;
-	/* Destination GID. */
-	uint32_t	dgid[4];
-	/* Destination QP id. */
-	uint32_t	dest_qp_id;
-	/* Statistic collection ID allocated for this QP. */
-	uint8_t	stat_collection_id;
-	uint8_t	reservred_8;
-	uint16_t	reserved_16;
-} creq_query_qp_extend_resp_sb_tlv_t, *pcreq_query_qp_extend_resp_sb_tlv_t;
-
-/**************
- * create_srq *
- **************/
-
-
-/* cmdq_create_srq (size:384b/48B) */
-
-typedef struct cmdq_create_srq {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Create SRQ command allocates a SRQ with the specified parameters. */
-	#define CMDQ_CREATE_SRQ_OPCODE_CREATE_SRQ UINT32_C(0x5)
-	#define CMDQ_CREATE_SRQ_OPCODE_LAST	CMDQ_CREATE_SRQ_OPCODE_CREATE_SRQ
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	/* SRQ handle. */
-	uint64_t	srq_handle;
-	uint16_t	pg_size_lvl;
-	/* SRQ PBL indirect levels. */
-	#define CMDQ_CREATE_SRQ_LVL_MASK	UINT32_C(0x3)
-	#define CMDQ_CREATE_SRQ_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define CMDQ_CREATE_SRQ_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define CMDQ_CREATE_SRQ_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define CMDQ_CREATE_SRQ_LVL_LVL_2	UINT32_C(0x2)
-		#define CMDQ_CREATE_SRQ_LVL_LAST	CMDQ_CREATE_SRQ_LVL_LVL_2
-	/* page size. */
-	#define CMDQ_CREATE_SRQ_PG_SIZE_MASK  UINT32_C(0x1c)
-	#define CMDQ_CREATE_SRQ_PG_SIZE_SFT   2
-	/* 4KB. */
-		#define CMDQ_CREATE_SRQ_PG_SIZE_PG_4K   (UINT32_C(0x0) << 2)
-	/* 8KB. */
-		#define CMDQ_CREATE_SRQ_PG_SIZE_PG_8K   (UINT32_C(0x1) << 2)
-	/* 64KB. */
-		#define CMDQ_CREATE_SRQ_PG_SIZE_PG_64K  (UINT32_C(0x2) << 2)
-	/* 2MB. */
-		#define CMDQ_CREATE_SRQ_PG_SIZE_PG_2M   (UINT32_C(0x3) << 2)
-	/* 8MB. */
-		#define CMDQ_CREATE_SRQ_PG_SIZE_PG_8M   (UINT32_C(0x4) << 2)
-	/* 1GB. */
-		#define CMDQ_CREATE_SRQ_PG_SIZE_PG_1G   (UINT32_C(0x5) << 2)
-		#define CMDQ_CREATE_SRQ_PG_SIZE_LAST   CMDQ_CREATE_SRQ_PG_SIZE_PG_1G
-	/* unused11 is 11 b */
-	#define CMDQ_CREATE_SRQ_UNUSED11_MASK UINT32_C(0xffe0)
-	#define CMDQ_CREATE_SRQ_UNUSED11_SFT  5
-	uint16_t	eventq_id;
-	/* eventq_id is 12 b */
-	#define CMDQ_CREATE_SRQ_EVENTQ_ID_MASK UINT32_C(0xfff)
-	#define CMDQ_CREATE_SRQ_EVENTQ_ID_SFT 0
-	/* unused4 is 4 b */
-	#define CMDQ_CREATE_SRQ_UNUSED4_MASK  UINT32_C(0xf000)
-	#define CMDQ_CREATE_SRQ_UNUSED4_SFT   12
-	/* Max number of SRQ wqes. */
-	uint16_t	srq_size;
-	/* Offsetof first WQE in the first page of SRQ, in 128 byte units */
-	uint16_t	srq_fwo;
-	/* Doorbell page index. */
-	uint32_t	dpi;
-	/* Protection domain id. */
-	uint32_t	pd_id;
-	/* RQ PBL physical address. */
-	uint64_t	pbl;
-} cmdq_create_srq_t, *pcmdq_create_srq_t;
+	uint32_t	l_key;
+	/*
+	 * Size of SGE in bytes; Based on page size of the system the chip
+	 * knows how many entries are in the PBL
+	 *
+	 * This field must have a value of 8 for an Atomic WQE.
+	 */
+	uint32_t	size;
+} sq_atomic_v3_t, *psq_atomic_v3_t;
 
-/* creq_create_srq_resp (size:128b/16B) */
+/* SQ Atomic WQE V3 header for RC SQs. */
+/* sq_atomic_hdr_v3 (size:320b/40B) */
 
-typedef struct creq_create_srq_resp {
-	uint8_t	type;
+typedef struct sq_atomic_hdr_v3 {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * Atomic Compare/Swap V3
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	#define CREQ_CREATE_SRQ_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_CREATE_SRQ_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_CREATE_SRQ_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_CREATE_SRQ_RESP_TYPE_LAST	CREQ_CREATE_SRQ_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* SRQ context id */
-	uint32_t	xid;
-	uint8_t	v;
+	#define SQ_ATOMIC_HDR_V3_WQE_TYPE_ATOMIC_CS_V3 UINT32_C(0x18)
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * Atomic Fetch/Add V3
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	#define CREQ_CREATE_SRQ_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Create SRQ command response. */
-	#define CREQ_CREATE_SRQ_RESP_EVENT_CREATE_SRQ UINT32_C(0x5)
-	#define CREQ_CREATE_SRQ_RESP_EVENT_LAST	CREQ_CREATE_SRQ_RESP_EVENT_CREATE_SRQ
-	uint8_t	reserved48[6];
-} creq_create_srq_resp_t, *pcreq_create_srq_resp_t;
-
-/***************
- * destroy_srq *
- ***************/
-
-
-/* cmdq_destroy_srq (size:192b/24B) */
-
-typedef struct cmdq_destroy_srq {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Destroy SRQ command deletes and flushes the specified SRQ. */
-	#define CMDQ_DESTROY_SRQ_OPCODE_DESTROY_SRQ UINT32_C(0x6)
-	#define CMDQ_DESTROY_SRQ_OPCODE_LAST	CMDQ_DESTROY_SRQ_OPCODE_DESTROY_SRQ
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	/* SRQ context id */
-	uint32_t	srq_cid;
-	uint32_t	unused_0;
-} cmdq_destroy_srq_t, *pcmdq_destroy_srq_t;
-
-/* creq_destroy_srq_resp (size:128b/16B) */
-
-typedef struct creq_destroy_srq_resp {
-	uint8_t	type;
+	#define SQ_ATOMIC_HDR_V3_WQE_TYPE_ATOMIC_FA_V3 UINT32_C(0x19)
+	#define SQ_ATOMIC_HDR_V3_WQE_TYPE_LAST	SQ_ATOMIC_HDR_V3_WQE_TYPE_ATOMIC_FA_V3
+	uint8_t	flags;
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * Set if completion signaling is requested. If this bit is
+	 * 0, and the SQ is configured to support Unsignaled
+	 * completion the controller should not generate a CQE
+	 * unless there was an error. This refers to CQE on the
+	 * sender side (The se flag refers to the receiver side).
 	 */
-	#define CREQ_DESTROY_SRQ_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_DESTROY_SRQ_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_DESTROY_SRQ_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_DESTROY_SRQ_RESP_TYPE_LAST	CREQ_DESTROY_SRQ_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* SRQ context id */
-	uint32_t	xid;
-	uint8_t	v;
+	#define SQ_ATOMIC_HDR_V3_FLAGS_SIGNAL_COMP		UINT32_C(0x1)
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * Indication to complete all previous RDMA Read or Atomic
+	 * WQEs on the SQ before executing this WQE
 	 */
-	#define CREQ_DESTROY_SRQ_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Destroy SRQ command response. */
-	#define CREQ_DESTROY_SRQ_RESP_EVENT_DESTROY_SRQ UINT32_C(0x6)
-	#define CREQ_DESTROY_SRQ_RESP_EVENT_LAST	CREQ_DESTROY_SRQ_RESP_EVENT_DESTROY_SRQ
-	uint16_t	enable_for_arm[3];
-	#define CREQ_DESTROY_SRQ_RESP_UNUSED0_MASK	UINT32_C(0xffff)
-	#define CREQ_DESTROY_SRQ_RESP_UNUSED0_SFT	0
-	/* Set to 1 if this SRQ is allowed to be armed for threshold async event */
-	#define CREQ_DESTROY_SRQ_RESP_ENABLE_FOR_ARM_MASK UINT32_C(0x30000)
-	#define CREQ_DESTROY_SRQ_RESP_ENABLE_FOR_ARM_SFT 16
-} creq_destroy_srq_resp_t, *pcreq_destroy_srq_resp_t;
-
-/*************
- * query_srq *
- *************/
-
-
-/* cmdq_query_srq (size:192b/24B) */
-
-typedef struct cmdq_query_srq {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Query SRP command retrieves info about the specified SRQ. */
-	#define CMDQ_QUERY_SRQ_OPCODE_QUERY_SRQ UINT32_C(0x8)
-	#define CMDQ_QUERY_SRQ_OPCODE_LAST	CMDQ_QUERY_SRQ_OPCODE_QUERY_SRQ
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	/* SRQ context id */
-	uint32_t	srq_cid;
-	uint32_t	unused_0;
-} cmdq_query_srq_t, *pcmdq_query_srq_t;
-
-/* creq_query_srq_resp (size:128b/16B) */
-
-typedef struct creq_query_srq_resp {
-	uint8_t	type;
+	#define SQ_ATOMIC_HDR_V3_FLAGS_RD_OR_ATOMIC_FENCE	UINT32_C(0x2)
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * Unconditional fence. Indication to complete all previous
+	 * SQ's WQEs before executing this WQE.
 	 */
-	#define CREQ_QUERY_SRQ_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_QUERY_SRQ_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_QUERY_SRQ_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_QUERY_SRQ_RESP_TYPE_LAST	CREQ_QUERY_SRQ_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Side buffer size in 16-byte units */
-	uint32_t	size;
-	uint8_t	v;
+	#define SQ_ATOMIC_HDR_V3_FLAGS_UC_FENCE		UINT32_C(0x4)
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * Solicit event. Indication sent in BTH header to the
+	 * receiver to generate a Completion Event Notification,
+	 * i.e. CNQE.
 	 */
-	#define CREQ_QUERY_SRQ_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Query SRQ command response. */
-	#define CREQ_QUERY_SRQ_RESP_EVENT_QUERY_SRQ UINT32_C(0x8)
-	#define CREQ_QUERY_SRQ_RESP_EVENT_LAST	CREQ_QUERY_SRQ_RESP_EVENT_QUERY_SRQ
-	uint8_t	reserved48[6];
-} creq_query_srq_resp_t, *pcreq_query_srq_resp_t;
-
-/* Query SRQ command response side buffer structure. */
-/* creq_query_srq_resp_sb (size:256b/32B) */
-
-typedef struct creq_query_srq_resp_sb {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Query SRQ command response. */
-	#define CREQ_QUERY_SRQ_RESP_SB_OPCODE_QUERY_SRQ UINT32_C(0x8)
-	#define CREQ_QUERY_SRQ_RESP_SB_OPCODE_LAST	CREQ_QUERY_SRQ_RESP_SB_OPCODE_QUERY_SRQ
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* SRQ context id */
-	uint32_t	xid;
-	/* Watermark value to generate a SRQ limit event. */
-	uint16_t	srq_limit;
-	uint16_t	reserved16;
-	/* data is 128 b */
-	uint32_t	data[4];
-} creq_query_srq_resp_sb_t, *pcreq_query_srq_resp_sb_t;
-
-/*************
- * create_cq *
- *************/
-
-
-/* cmdq_create_cq (size:384b/48B) */
-
-typedef struct cmdq_create_cq {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Create CQ command allocates a CQ with the specified parameters. */
-	#define CMDQ_CREATE_CQ_OPCODE_CREATE_CQ UINT32_C(0x9)
-	#define CMDQ_CREATE_CQ_OPCODE_LAST	CMDQ_CREATE_CQ_OPCODE_CREATE_CQ
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	/* CQ handle. */
-	uint64_t	cq_handle;
-	uint32_t	pg_size_lvl;
-	/* PBL indirect levels. */
-	#define CMDQ_CREATE_CQ_LVL_MASK	UINT32_C(0x3)
-	#define CMDQ_CREATE_CQ_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define CMDQ_CREATE_CQ_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define CMDQ_CREATE_CQ_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define CMDQ_CREATE_CQ_LVL_LVL_2	UINT32_C(0x2)
-		#define CMDQ_CREATE_CQ_LVL_LAST	CMDQ_CREATE_CQ_LVL_LVL_2
-	/* page size. */
-	#define CMDQ_CREATE_CQ_PG_SIZE_MASK  UINT32_C(0x1c)
-	#define CMDQ_CREATE_CQ_PG_SIZE_SFT   2
-	/* 4KB. */
-		#define CMDQ_CREATE_CQ_PG_SIZE_PG_4K   (UINT32_C(0x0) << 2)
-	/* 8KB. */
-		#define CMDQ_CREATE_CQ_PG_SIZE_PG_8K   (UINT32_C(0x1) << 2)
-	/* 64KB. */
-		#define CMDQ_CREATE_CQ_PG_SIZE_PG_64K  (UINT32_C(0x2) << 2)
-	/* 2MB. */
-		#define CMDQ_CREATE_CQ_PG_SIZE_PG_2M   (UINT32_C(0x3) << 2)
-	/* 8MB. */
-		#define CMDQ_CREATE_CQ_PG_SIZE_PG_8M   (UINT32_C(0x4) << 2)
-	/* 1GB. */
-		#define CMDQ_CREATE_CQ_PG_SIZE_PG_1G   (UINT32_C(0x5) << 2)
-		#define CMDQ_CREATE_CQ_PG_SIZE_LAST   CMDQ_CREATE_CQ_PG_SIZE_PG_1G
-	/* unused27 is 27 b */
-	#define CMDQ_CREATE_CQ_UNUSED27_MASK UINT32_C(0xffffffe0)
-	#define CMDQ_CREATE_CQ_UNUSED27_SFT  5
-	uint32_t	cq_fco_cnq_id;
-	/* cnq_id is 12 b */
-	#define CMDQ_CREATE_CQ_CNQ_ID_MASK UINT32_C(0xfff)
-	#define CMDQ_CREATE_CQ_CNQ_ID_SFT 0
-	/* Offset of first CQE in the first Page, in 32 byte units */
-	#define CMDQ_CREATE_CQ_CQ_FCO_MASK UINT32_C(0xfffff000)
-	#define CMDQ_CREATE_CQ_CQ_FCO_SFT 12
-	/* Doorbell page index. */
-	uint32_t	dpi;
-	/* Max number of CQ wqes. */
-	uint32_t	cq_size;
-	/* CQ PBL physical address. */
-	uint64_t	pbl;
-} cmdq_create_cq_t, *pcmdq_create_cq_t;
-
-/* creq_create_cq_resp (size:128b/16B) */
-
-typedef struct creq_create_cq_resp {
-	uint8_t	type;
+	#define SQ_ATOMIC_HDR_V3_FLAGS_SE			UINT32_C(0x8)
+	/* NA for this WQE */
+	#define SQ_ATOMIC_HDR_V3_FLAGS_INLINE		UINT32_C(0x10)
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * The atomic WQE does not have a timestamp field, so this field is
+	 * ignored and should be zero.
 	 */
-	#define CREQ_CREATE_CQ_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_CREATE_CQ_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_CREATE_CQ_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_CREATE_CQ_RESP_TYPE_LAST	CREQ_CREATE_CQ_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* CQ context id */
-	uint32_t	xid;
-	uint8_t	v;
+	#define SQ_ATOMIC_HDR_V3_FLAGS_WQE_TS_EN		UINT32_C(0x20)
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * When set to '1', this operation will cause a trace capture in
+	 * each block it passes through.
 	 */
-	#define CREQ_CREATE_CQ_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Create CQ command response. */
-	#define CREQ_CREATE_CQ_RESP_EVENT_CREATE_CQ UINT32_C(0x9)
-	#define CREQ_CREATE_CQ_RESP_EVENT_LAST	CREQ_CREATE_CQ_RESP_EVENT_CREATE_CQ
-	uint8_t	reserved48[6];
-} creq_create_cq_resp_t, *pcreq_create_cq_resp_t;
-
-/**************
- * destroy_cq *
- **************/
-
-
-/* cmdq_destroy_cq (size:192b/24B) */
-
-typedef struct cmdq_destroy_cq {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Destroy CQ command deletes and flushes the specified CQ. */
-	#define CMDQ_DESTROY_CQ_OPCODE_DESTROY_CQ UINT32_C(0xa)
-	#define CMDQ_DESTROY_CQ_OPCODE_LAST	CMDQ_DESTROY_CQ_OPCODE_DESTROY_CQ
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	/* CQ context id */
-	uint32_t	cq_cid;
-	uint32_t	unused_0;
-} cmdq_destroy_cq_t, *pcmdq_destroy_cq_t;
+	#define SQ_ATOMIC_HDR_V3_FLAGS_DEBUG_TRACE		UINT32_C(0x40)
+	/*  */
+	uint8_t	wqe_size;
+	/*
+	 * The size of the WQE in units of 16B chunks.
+	 *
+	 * For the Atomic WQE, this field will always have a value of 4.
+	 */
+	#define SQ_ATOMIC_HDR_V3_WQE_SIZE_MASK UINT32_C(0x3f)
+	#define SQ_ATOMIC_HDR_V3_WQE_SIZE_SFT 0
+	uint8_t	reserved1;
+	/*
+	 * This value will be returned in the completion if the completion is
+	 * signaled.
+	 */
+	uint32_t	opaque;
+	/*
+	 * R_Key provided by remote node when the connection was
+	 * established and placed in the AETH header. It identifies the
+	 * MRW on the remote host.
+	 */
+	uint32_t	remote_key;
+	uint32_t	reserved2;
+	/* Remote VA sent to the destination QP */
+	uint64_t	remote_va;
+	/*
+	 * For compare/swap, this is the data value to be placed in the
+	 * remote host at the specified remote_VA if the comparison succeeds.
+	 *
+	 * For fetch/add, this is the value to be added to the data in the
+	 * remote host at the specified remote_VA.
+	 */
+	uint64_t	swap_data;
+	/*
+	 * For compare/swap, this is the data value to be compared with the
+	 * value in the remote host at the specified remote_VA.
+	 *
+	 * This field is not used for fetch/add.
+	 */
+	uint64_t	cmp_data;
+} sq_atomic_hdr_v3_t, *psq_atomic_hdr_v3_t;
 
-/* creq_destroy_cq_resp (size:128b/16B) */
+/* SQ Local Invalidate WQE V3 for RC SQs. */
+/* sq_localinvalidate_v3 (size:128b/16B) */
 
-typedef struct creq_destroy_cq_resp {
-	uint8_t	type;
+typedef struct sq_localinvalidate_v3 {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * Local Invalidate V3
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	#define CREQ_DESTROY_CQ_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_DESTROY_CQ_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_DESTROY_CQ_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_DESTROY_CQ_RESP_TYPE_LAST	CREQ_DESTROY_CQ_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* CQ context id */
-	uint32_t	xid;
-	uint8_t	v;
+	#define SQ_LOCALINVALIDATE_V3_WQE_TYPE_LOCAL_INVALID_V3 UINT32_C(0x1a)
+	#define SQ_LOCALINVALIDATE_V3_WQE_TYPE_LAST		SQ_LOCALINVALIDATE_V3_WQE_TYPE_LOCAL_INVALID_V3
+	uint8_t	flags;
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * Set if completion signaling is requested. If this bit is
+	 * 0, and the SQ is configured to support Unsignaled
+	 * completion the controller should not generate a CQE
+	 * unless there was an error. This refers to CQE on the
+	 * sender side (The se flag refers to the receiver side).
 	 */
-	#define CREQ_DESTROY_CQ_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Destroy CQ command response. */
-	#define CREQ_DESTROY_CQ_RESP_EVENT_DESTROY_CQ UINT32_C(0xa)
-	#define CREQ_DESTROY_CQ_RESP_EVENT_LAST	CREQ_DESTROY_CQ_RESP_EVENT_DESTROY_CQ
-	uint16_t	cq_arm_lvl;
+	#define SQ_LOCALINVALIDATE_V3_FLAGS_SIGNAL_COMP		UINT32_C(0x1)
 	/*
-	 * CQ ARM Level:
-	 * 0 ? Not Armed
-	 * 1 ? Arm SE Only, Generate CNQE only for incoming Solicted Events
-	 * 2 ? Arm all, Generate CNQE for Rx and Tx
+	 * Indication to complete all previous RDMA Read or Atomic
+	 * WQEs on the SQ before executing this WQE
 	 */
-	#define CREQ_DESTROY_CQ_RESP_CQ_ARM_LVL_MASK UINT32_C(0x3)
-	#define CREQ_DESTROY_CQ_RESP_CQ_ARM_LVL_SFT 0
+	#define SQ_LOCALINVALIDATE_V3_FLAGS_RD_OR_ATOMIC_FENCE	UINT32_C(0x2)
 	/*
-	 * The total number of CNQ events for the CQ, incremented on each CNQ event for the CQ
-	 *	(including firmware-generated CQ error notification).
+	 * Unconditional fence. Indication to complete all previous
+	 * SQ's WQEs before executing this WQE.
 	 */
-	uint16_t	total_cnq_events;
-	uint16_t	reserved16;
-} creq_destroy_cq_resp_t, *pcreq_destroy_cq_resp_t;
-
-/*************
- * resize_cq *
- *************/
-
-
-/* cmdq_resize_cq (size:320b/40B) */
-
-typedef struct cmdq_resize_cq {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Resize CQ command resizes the specified CQ. */
-	#define CMDQ_RESIZE_CQ_OPCODE_RESIZE_CQ UINT32_C(0xc)
-	#define CMDQ_RESIZE_CQ_OPCODE_LAST	CMDQ_RESIZE_CQ_OPCODE_RESIZE_CQ
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	/* CQ context id */
-	uint32_t	cq_cid;
-	uint32_t	new_cq_size_pg_size_lvl;
-	/* PBL indirect levels. */
-	#define CMDQ_RESIZE_CQ_LVL_MASK	UINT32_C(0x3)
-	#define CMDQ_RESIZE_CQ_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define CMDQ_RESIZE_CQ_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define CMDQ_RESIZE_CQ_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define CMDQ_RESIZE_CQ_LVL_LVL_2	UINT32_C(0x2)
-		#define CMDQ_RESIZE_CQ_LVL_LAST	CMDQ_RESIZE_CQ_LVL_LVL_2
-	/* page size. */
-	#define CMDQ_RESIZE_CQ_PG_SIZE_MASK	UINT32_C(0x1c)
-	#define CMDQ_RESIZE_CQ_PG_SIZE_SFT	2
-	/* 4KB. */
-		#define CMDQ_RESIZE_CQ_PG_SIZE_PG_4K	(UINT32_C(0x0) << 2)
-	/* 8KB. */
-		#define CMDQ_RESIZE_CQ_PG_SIZE_PG_8K	(UINT32_C(0x1) << 2)
-	/* 64KB. */
-		#define CMDQ_RESIZE_CQ_PG_SIZE_PG_64K	(UINT32_C(0x2) << 2)
-	/* 2MB. */
-		#define CMDQ_RESIZE_CQ_PG_SIZE_PG_2M	(UINT32_C(0x3) << 2)
-	/* 8MB. */
-		#define CMDQ_RESIZE_CQ_PG_SIZE_PG_8M	(UINT32_C(0x4) << 2)
-	/* 1GB. */
-		#define CMDQ_RESIZE_CQ_PG_SIZE_PG_1G	(UINT32_C(0x5) << 2)
-		#define CMDQ_RESIZE_CQ_PG_SIZE_LAST	CMDQ_RESIZE_CQ_PG_SIZE_PG_1G
-	/* New max number of CQ wqes. */
-	#define CMDQ_RESIZE_CQ_NEW_CQ_SIZE_MASK UINT32_C(0x1fffffe0)
-	#define CMDQ_RESIZE_CQ_NEW_CQ_SIZE_SFT 5
-	/* CQ PBL physical address. */
-	uint64_t	new_pbl;
-	/* Offset of first CQE in the first Page, in 32 byte units */
-	uint32_t	new_cq_fco;
-	uint32_t	unused_0;
-} cmdq_resize_cq_t, *pcmdq_resize_cq_t;
-
-/* creq_resize_cq_resp (size:128b/16B) */
-
-typedef struct creq_resize_cq_resp {
-	uint8_t	type;
+	#define SQ_LOCALINVALIDATE_V3_FLAGS_UC_FENCE		UINT32_C(0x4)
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * This flag is not applicable and should be 0 for a local memory
+	 * operation WQE.
 	 */
-	#define CREQ_RESIZE_CQ_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_RESIZE_CQ_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_RESIZE_CQ_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_RESIZE_CQ_RESP_TYPE_LAST	CREQ_RESIZE_CQ_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* CQ context id */
-	uint32_t	xid;
-	uint8_t	v;
+	#define SQ_LOCALINVALIDATE_V3_FLAGS_SE			UINT32_C(0x8)
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * This flag is not applicable and should be 0 for a local memory
+	 * operation WQE.
 	 */
-	#define CREQ_RESIZE_CQ_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Resize CQ command response. */
-	#define CREQ_RESIZE_CQ_RESP_EVENT_RESIZE_CQ UINT32_C(0xc)
-	#define CREQ_RESIZE_CQ_RESP_EVENT_LAST	CREQ_RESIZE_CQ_RESP_EVENT_RESIZE_CQ
-	uint8_t	reserved48[6];
-} creq_resize_cq_resp_t, *pcreq_resize_cq_resp_t;
-
-/*************
- * modify_cq *
- *************/
-
-
-/* cmdq_modify_cq (size:512b/64B) */
-
-typedef struct cmdq_modify_cq {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Modify CQ updates specific params in the CQ context. */
-	#define CMDQ_MODIFY_CQ_OPCODE_MODIFY_CQ UINT32_C(0x90)
-	#define CMDQ_MODIFY_CQ_OPCODE_LAST	CMDQ_MODIFY_CQ_OPCODE_MODIFY_CQ
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	/* Modify mask signifies the field that is requesting the change. */
-	uint32_t	modify_mask;
-	/* Enable change. */
-	#define CMDQ_MODIFY_CQ_MODIFY_MASK_CQ_HANDLE	UINT32_C(0x1)
-	/* CNQ ID */
-	#define CMDQ_MODIFY_CQ_MODIFY_MASK_CNQ_ID	UINT32_C(0x2)
-	/* Offset of first CQE in the first page, in 32 byte units */
-	#define CMDQ_MODIFY_CQ_MODIFY_MASK_FCO	UINT32_C(0x4)
-	/* Doorbell page index */
-	#define CMDQ_MODIFY_CQ_MODIFY_MASK_DPI	UINT32_C(0x8)
-	/* Max number of CQ Wqes */
-	#define CMDQ_MODIFY_CQ_MODIFY_MASK_CQ_SIZE	UINT32_C(0x10)
-	/* CQ PBL physical address */
-	#define CMDQ_MODIFY_CQ_MODIFY_MASK_PBL	UINT32_C(0x20)
-	/* reserved32 is 32 b */
-	uint32_t	reserved32;
-	/* CQ handle. */
-	uint64_t	cq_handle;
-	uint32_t	cq_fco_cnq_id;
-	/* cnq_id is 12 b */
-	#define CMDQ_MODIFY_CQ_CNQ_ID_MASK UINT32_C(0xfff)
-	#define CMDQ_MODIFY_CQ_CNQ_ID_SFT 0
-	/* Offset of first CQE in the first Page, in 32 byte units */
-	#define CMDQ_MODIFY_CQ_CQ_FCO_MASK UINT32_C(0xfffff000)
-	#define CMDQ_MODIFY_CQ_CQ_FCO_SFT 12
-	/* Doorbell page index. */
-	uint32_t	dpi;
-	/* Max number of CQ wqes. */
-	uint32_t	cq_size;
-	/* reserved32_1 is 32 b */
-	uint32_t	reserved32_1;
-	/* CQ PBL physical address. */
-	uint64_t	pbl;
-	/* reserved64 is 64 b */
-	uint64_t	reserved64;
-} cmdq_modify_cq_t, *pcmdq_modify_cq_t;
-
-/* creq_modify_cq_resp (size:128b/16B) */
-
-typedef struct creq_modify_cq_resp {
-	uint8_t	type;
+	#define SQ_LOCALINVALIDATE_V3_FLAGS_INLINE		UINT32_C(0x10)
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * This flag is not applicable and should be 0 for a local memory
+	 * operation WQE.
 	 */
-	#define CREQ_MODIFY_CQ_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_MODIFY_CQ_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_MODIFY_CQ_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_MODIFY_CQ_RESP_TYPE_LAST	CREQ_MODIFY_CQ_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* CQ context id */
-	uint32_t	xid;
-	uint8_t	v;
+	#define SQ_LOCALINVALIDATE_V3_FLAGS_WQE_TS_EN		UINT32_C(0x20)
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * When set to '1', this operation will cause a trace capture in
+	 * each block it passes through.
 	 */
-	#define CREQ_MODIFY_CQ_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Modify CQ command response. */
-	#define CREQ_MODIFY_CQ_RESP_EVENT_MODIFY_CQ UINT32_C(0x9)
-	#define CREQ_MODIFY_CQ_RESP_EVENT_LAST	CREQ_MODIFY_CQ_RESP_EVENT_MODIFY_CQ
-	uint8_t	reserved48[6];
-} creq_modify_cq_resp_t, *pcreq_modify_cq_resp_t;
-
-/****************
- * allocate_mrw *
- ****************/
-
+	#define SQ_LOCALINVALIDATE_V3_FLAGS_DEBUG_TRACE		UINT32_C(0x40)
+	/*  */
+	uint8_t	wqe_size;
+	/*
+	 * The size of the WQE in units of 16B chunks.
+	 *
+	 * For the Local Invalidate WQE, this field will always have
+	 * a value of 1.
+	 */
+	#define SQ_LOCALINVALIDATE_V3_WQE_SIZE_MASK UINT32_C(0x3f)
+	#define SQ_LOCALINVALIDATE_V3_WQE_SIZE_SFT 0
+	uint8_t	reserved1;
+	/*
+	 * This value will be returned in the completion if the completion is
+	 * signaled.
+	 */
+	uint32_t	opaque;
+	/*
+	 * The local key for the MR/W to invalidate; 24 msb of the key
+	 * are used to index the MRW table, 8 lsb are compared with the
+	 * 8 bit key in the MRWC
+	 */
+	uint32_t	inv_l_key;
+	uint32_t	reserved2;
+} sq_localinvalidate_v3_t, *psq_localinvalidate_v3_t;
 
-/* cmdq_allocate_mrw (size:256b/32B) */
+/* SQ Local Invalidate WQE V3 header for RC SQs. */
+/* sq_localinvalidate_hdr_v3 (size:128b/16B) */
 
-typedef struct cmdq_allocate_mrw {
-	/* Command opcode. */
-	uint8_t	opcode;
+typedef struct sq_localinvalidate_hdr_v3 {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
 	/*
-	 * Allocate MRW command allocates a MR/MW with the specified parameters
-	 * and returns the region's L_KEY/R_KEY
+	 * Local Invalidate V3
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	#define CMDQ_ALLOCATE_MRW_OPCODE_ALLOCATE_MRW UINT32_C(0xd)
-	#define CMDQ_ALLOCATE_MRW_OPCODE_LAST	CMDQ_ALLOCATE_MRW_OPCODE_ALLOCATE_MRW
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	/* MRW handle. */
-	uint64_t	mrw_handle;
-	uint8_t	mrw_flags;
-	/* Allocate MRW flags. */
-	#define CMDQ_ALLOCATE_MRW_MRW_FLAGS_MASK	UINT32_C(0xf)
-	#define CMDQ_ALLOCATE_MRW_MRW_FLAGS_SFT	0
-	/* Allocate Memory Region */
-		#define CMDQ_ALLOCATE_MRW_MRW_FLAGS_MR	UINT32_C(0x0)
-	/* Allocate Physical Memory Region */
-		#define CMDQ_ALLOCATE_MRW_MRW_FLAGS_PMR	UINT32_C(0x1)
-	/* Allocate Memory Window (type 1) */
-		#define CMDQ_ALLOCATE_MRW_MRW_FLAGS_MW_TYPE1   UINT32_C(0x2)
-	/* Allocate Memory Window (type 2A) */
-		#define CMDQ_ALLOCATE_MRW_MRW_FLAGS_MW_TYPE2A  UINT32_C(0x3)
-	/* Allocate Memory Window (type 2B) */
-		#define CMDQ_ALLOCATE_MRW_MRW_FLAGS_MW_TYPE2B  UINT32_C(0x4)
-		#define CMDQ_ALLOCATE_MRW_MRW_FLAGS_LAST	CMDQ_ALLOCATE_MRW_MRW_FLAGS_MW_TYPE2B
-	/* unused4 is 4 b */
-	#define CMDQ_ALLOCATE_MRW_UNUSED4_MASK	UINT32_C(0xf0)
-	#define CMDQ_ALLOCATE_MRW_UNUSED4_SFT	4
-	/* Access flags. */
-	uint8_t	access;
-	/* Consumer owns the key */
-	#define CMDQ_ALLOCATE_MRW_ACCESS_CONSUMER_OWNED_KEY	UINT32_C(0x20)
-	/* unused16 is 16 b */
-	uint16_t	unused16;
-	/* Protection domain id. */
-	uint32_t	pd_id;
-} cmdq_allocate_mrw_t, *pcmdq_allocate_mrw_t;
+	#define SQ_LOCALINVALIDATE_HDR_V3_WQE_TYPE_LOCAL_INVALID_V3 UINT32_C(0x1a)
+	#define SQ_LOCALINVALIDATE_HDR_V3_WQE_TYPE_LAST		SQ_LOCALINVALIDATE_HDR_V3_WQE_TYPE_LOCAL_INVALID_V3
+	uint8_t	flags;
+	/*
+	 * Set if completion signaling is requested. If this bit is
+	 * 0, and the SQ is configured to support Unsignaled
+	 * completion the controller should not generate a CQE
+	 * unless there was an error. This refers to CQE on the
+	 * sender side (The se flag refers to the receiver side).
+	 */
+	#define SQ_LOCALINVALIDATE_HDR_V3_FLAGS_SIGNAL_COMP		UINT32_C(0x1)
+	/*
+	 * Indication to complete all previous RDMA Read or Atomic
+	 * WQEs on the SQ before executing this WQE
+	 */
+	#define SQ_LOCALINVALIDATE_HDR_V3_FLAGS_RD_OR_ATOMIC_FENCE	UINT32_C(0x2)
+	/*
+	 * Unconditional fence. Indication to complete all previous
+	 * SQ's WQEs before executing this WQE.
+	 */
+	#define SQ_LOCALINVALIDATE_HDR_V3_FLAGS_UC_FENCE		UINT32_C(0x4)
+	/*
+	 * This flag is not applicable and should be 0 for a local memory
+	 * operation WQE.
+	 */
+	#define SQ_LOCALINVALIDATE_HDR_V3_FLAGS_SE			UINT32_C(0x8)
+	/*
+	 * This flag is not applicable and should be 0 for a local memory
+	 * operation WQE.
+	 */
+	#define SQ_LOCALINVALIDATE_HDR_V3_FLAGS_INLINE		UINT32_C(0x10)
+	/*
+	 * This flag is not applicable and should be 0 for a local memory
+	 * operation WQE.
+	 */
+	#define SQ_LOCALINVALIDATE_HDR_V3_FLAGS_WQE_TS_EN		UINT32_C(0x20)
+	/*
+	 * When set to '1', this operation will cause a trace capture in
+	 * each block it passes through.
+	 */
+	#define SQ_LOCALINVALIDATE_HDR_V3_FLAGS_DEBUG_TRACE		UINT32_C(0x40)
+	/*  */
+	uint8_t	wqe_size;
+	/*
+	 * The size of the WQE in units of 16B chunks.
+	 *
+	 * For the Local Invalidate WQE, this field will always have
+	 * a value of 1.
+	 */
+	#define SQ_LOCALINVALIDATE_HDR_V3_WQE_SIZE_MASK UINT32_C(0x3f)
+	#define SQ_LOCALINVALIDATE_HDR_V3_WQE_SIZE_SFT 0
+	uint8_t	reserved1;
+	/*
+	 * This value will be returned in the completion if the completion is
+	 * signaled.
+	 */
+	uint32_t	opaque;
+	/*
+	 * The local key for the MR/W to invalidate; 24 msb of the key
+	 * are used to index the MRW table, 8 lsb are compared with the
+	 * 8 bit key in the MRWC
+	 */
+	uint32_t	inv_l_key;
+	uint32_t	reserved2;
+} sq_localinvalidate_hdr_v3_t, *psq_localinvalidate_hdr_v3_t;
 
-/* creq_allocate_mrw_resp (size:128b/16B) */
+/*
+ * SQ FR-PMR WQE V3 for RC SQs.
+ *
+ * The FR-PMR WQE must be padded to 3 slots (48 bytes) in the SQ, even
+ * though the final 8 bytes are not shown here.
+ */
+/* sq_fr_pmr_v3 (size:320b/40B) */
 
-typedef struct creq_allocate_mrw_resp {
-	uint8_t	type;
+typedef struct sq_fr_pmr_v3 {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * FR-PMR (Fast Register Physical Memory Region) V3
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	#define CREQ_ALLOCATE_MRW_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_ALLOCATE_MRW_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_ALLOCATE_MRW_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_ALLOCATE_MRW_RESP_TYPE_LAST	CREQ_ALLOCATE_MRW_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* L_KEY for MR, R_KEY for MW */
-	uint32_t	xid;
-	uint8_t	v;
+	#define SQ_FR_PMR_V3_WQE_TYPE_FR_PMR_V3 UINT32_C(0x1b)
+	#define SQ_FR_PMR_V3_WQE_TYPE_LAST	SQ_FR_PMR_V3_WQE_TYPE_FR_PMR_V3
+	uint8_t	flags;
+	/*
+	 * Set if completion signaling is requested. If this bit is
+	 * 0, and the SQ is configured to support Unsignaled
+	 * completion the controller should not generate a CQE
+	 * unless there was an error. This refers to CQE on the
+	 * sender side (The se flag refers to the receiver side).
+	 */
+	#define SQ_FR_PMR_V3_FLAGS_SIGNAL_COMP		UINT32_C(0x1)
+	/*
+	 * Indication to complete all previous RDMA Read or Atomic
+	 * WQEs on the SQ before executing this WQE
+	 */
+	#define SQ_FR_PMR_V3_FLAGS_RD_OR_ATOMIC_FENCE	UINT32_C(0x2)
+	/*
+	 * Unconditional fence. Indication to complete all previous
+	 * SQ's WQEs before executing this WQE.
+	 */
+	#define SQ_FR_PMR_V3_FLAGS_UC_FENCE		UINT32_C(0x4)
+	/*
+	 * This flag is not applicable and should be 0 for a local memory
+	 * operation WQE.
+	 */
+	#define SQ_FR_PMR_V3_FLAGS_SE			UINT32_C(0x8)
+	/*
+	 * This flag is not applicable and should be 0 for a local memory
+	 * operation WQE.
+	 */
+	#define SQ_FR_PMR_V3_FLAGS_INLINE		UINT32_C(0x10)
+	/*
+	 * This flag is not applicable and should be 0 for a local memory
+	 * operation WQE.
+	 */
+	#define SQ_FR_PMR_V3_FLAGS_WQE_TS_EN		UINT32_C(0x20)
+	/*
+	 * When set to '1', this operation will cause a trace capture in
+	 * each block it passes through.
+	 */
+	#define SQ_FR_PMR_V3_FLAGS_DEBUG_TRACE		UINT32_C(0x40)
+	/*  */
+	uint8_t	wqe_size_zero_based;
+	/*
+	 * The size of the WQE in units of 16B chunks.
+	 *
+	 * For the FR-PMR WQE, this field will always have a value of 3.
+	 */
+	#define SQ_FR_PMR_V3_WQE_SIZE_MASK  UINT32_C(0x3f)
+	#define SQ_FR_PMR_V3_WQE_SIZE_SFT   0
+	/*
+	 * If this is set, the PMR will be zero-based. If clear, the PMR
+	 * will be non-zero-based.
+	 */
+	#define SQ_FR_PMR_V3_ZERO_BASED	UINT32_C(0x40)
+	/*
+	 * This is the new access control for the MR. '1' means
+	 * the operation is allowed. '0' means operation is
+	 * not allowed.
+	 */
+	uint8_t	access_cntl;
+	/* Local Write Access */
+	#define SQ_FR_PMR_V3_ACCESS_CNTL_LOCAL_WRITE	UINT32_C(0x1)
+	/* Remote Read Access */
+	#define SQ_FR_PMR_V3_ACCESS_CNTL_REMOTE_READ	UINT32_C(0x2)
+	/* Remote Write Access */
+	#define SQ_FR_PMR_V3_ACCESS_CNTL_REMOTE_WRITE	UINT32_C(0x4)
+	/* Remote Atomic Access */
+	#define SQ_FR_PMR_V3_ACCESS_CNTL_REMOTE_ATOMIC	UINT32_C(0x8)
+	/* Window Binding Allowed */
+	#define SQ_FR_PMR_V3_ACCESS_CNTL_WINDOW_BIND	UINT32_C(0x10)
+	/*
+	 * This value will be returned in the completion if the completion is
+	 * signaled.
+	 */
+	uint32_t	opaque;
+	/*
+	 * Local Key; 24 msb of the key are used to index the MRW
+	 * table, 8 lsb are assigned to the 8 bit key_lsb field in
+	 * the MRWC.
+	 */
+	uint32_t	l_key;
+	uint16_t	page_size_log;
+	/*
+	 * This value controls the page size for leaf memory pages in
+	 * a PBL. While many page sizes are supported only the following
+	 * should be tested - 4k, 8k, 64k, 256k, 1m, 2m, 4m, 1g
+	 */
+	#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_MASK	UINT32_C(0x1f)
+	#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_SFT	0
+	/* Page size is 4KB. */
+		#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_PGSZ_4K	UINT32_C(0x0)
+	/* Page size is 8KB. */
+		#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_PGSZ_8K	UINT32_C(0x1)
+	/* Page size is 16KB. */
+		#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_PGSZ_16K	UINT32_C(0x2)
+	/* Page size is 32KB. */
+		#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_PGSZ_32K	UINT32_C(0x3)
+	/* Page size is 64KB. */
+		#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_PGSZ_64K	UINT32_C(0x4)
+	/* Page size is 128KB. */
+		#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_PGSZ_128K	UINT32_C(0x5)
+	/* Page size is 256KB. */
+		#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_PGSZ_256K	UINT32_C(0x6)
+	/* Page size is 512KB. */
+		#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_PGSZ_512K	UINT32_C(0x7)
+	/* Page size is 1MB. */
+		#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_PGSZ_1M	UINT32_C(0x8)
+	/* Page size is 2MB. */
+		#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_PGSZ_2M	UINT32_C(0x9)
+	/* Page size is 4MB. */
+		#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_PGSZ_4M	UINT32_C(0xa)
+	/* Page size is 8MB. */
+		#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_PGSZ_8M	UINT32_C(0xb)
+	/* Page size is 16MB. */
+		#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_PGSZ_16M	UINT32_C(0xc)
+	/* Page size is 32MB. */
+		#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_PGSZ_32M	UINT32_C(0xd)
+	/* Page size is 64MB. */
+		#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_PGSZ_64M	UINT32_C(0xe)
+	/* Page size is 128MB. */
+		#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_PGSZ_128M	UINT32_C(0xf)
+	/* Page size is 256MB. */
+		#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_PGSZ_256M	UINT32_C(0x10)
+	/* Page size is 512MB. */
+		#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_PGSZ_512M	UINT32_C(0x11)
+	/* Page size is 1GB. */
+		#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_PGSZ_1G	UINT32_C(0x12)
+	/* Page size is 2GB. */
+		#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_PGSZ_2G	UINT32_C(0x13)
+	/* Page size is 4GB. */
+		#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_PGSZ_4G	UINT32_C(0x14)
+	/* Page size is 8GB. */
+		#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_PGSZ_8G	UINT32_C(0x15)
+	/* Page size is 16GB. */
+		#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_PGSZ_16G	UINT32_C(0x16)
+	/* Page size is 32GB. */
+		#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_PGSZ_32G	UINT32_C(0x17)
+	/* Page size is 64GB. */
+		#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_PGSZ_64G	UINT32_C(0x18)
+	/* Page size is 128GB. */
+		#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_PGSZ_128G	UINT32_C(0x19)
+	/* Page size is 256GB. */
+		#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_PGSZ_256G	UINT32_C(0x1a)
+	/* Page size is 512GB. */
+		#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_PGSZ_512G	UINT32_C(0x1b)
+	/* Page size is 1TB. */
+		#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_PGSZ_1T	UINT32_C(0x1c)
+	/* Page size is 2TB. */
+		#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_PGSZ_2T	UINT32_C(0x1d)
+	/* Page size is 4TB. */
+		#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_PGSZ_4T	UINT32_C(0x1e)
+	/* Page size is 8TB. */
+		#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_PGSZ_8T	UINT32_C(0x1f)
+		#define SQ_FR_PMR_V3_PAGE_SIZE_LOG_LAST	SQ_FR_PMR_V3_PAGE_SIZE_LOG_PGSZ_8T
+	/*
+	 * This value controls the page size for page table elements
+	 * within a PBL. While many page sizes are supported only the
+	 * following should be tested - 4k, 8k, 64k, 256k, 1m, 2m, 4m, 1g
+	 */
+	#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_MASK	UINT32_C(0x3e0)
+	#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_SFT	5
+	/* Page size is 4KB. */
+		#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_PGSZ_4K	(UINT32_C(0x0) << 5)
+	/* Page size is 8KB. */
+		#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_PGSZ_8K	(UINT32_C(0x1) << 5)
+	/* Page size is 16KB. */
+		#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_PGSZ_16K   (UINT32_C(0x2) << 5)
+	/* Page size is 32KB. */
+		#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_PGSZ_32K   (UINT32_C(0x3) << 5)
+	/* Page size is 64KB. */
+		#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_PGSZ_64K   (UINT32_C(0x4) << 5)
+	/* Page size is 128KB. */
+		#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_PGSZ_128K  (UINT32_C(0x5) << 5)
+	/* Page size is 256KB. */
+		#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_PGSZ_256K  (UINT32_C(0x6) << 5)
+	/* Page size is 512KB. */
+		#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_PGSZ_512K  (UINT32_C(0x7) << 5)
+	/* Page size is 1MB. */
+		#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_PGSZ_1M	(UINT32_C(0x8) << 5)
+	/* Page size is 2MB. */
+		#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_PGSZ_2M	(UINT32_C(0x9) << 5)
+	/* Page size is 4MB. */
+		#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_PGSZ_4M	(UINT32_C(0xa) << 5)
+	/* Page size is 8MB. */
+		#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_PGSZ_8M	(UINT32_C(0xb) << 5)
+	/* Page size is 16MB. */
+		#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_PGSZ_16M   (UINT32_C(0xc) << 5)
+	/* Page size is 32MB. */
+		#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_PGSZ_32M   (UINT32_C(0xd) << 5)
+	/* Page size is 64MB. */
+		#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_PGSZ_64M   (UINT32_C(0xe) << 5)
+	/* Page size is 128MB. */
+		#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_PGSZ_128M  (UINT32_C(0xf) << 5)
+	/* Page size is 256MB. */
+		#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_PGSZ_256M  (UINT32_C(0x10) << 5)
+	/* Page size is 512MB. */
+		#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_PGSZ_512M  (UINT32_C(0x11) << 5)
+	/* Page size is 1GB. */
+		#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_PGSZ_1G	(UINT32_C(0x12) << 5)
+	/* Page size is 2GB. */
+		#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_PGSZ_2G	(UINT32_C(0x13) << 5)
+	/* Page size is 4GB. */
+		#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_PGSZ_4G	(UINT32_C(0x14) << 5)
+	/* Page size is 8GB. */
+		#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_PGSZ_8G	(UINT32_C(0x15) << 5)
+	/* Page size is 16GB. */
+		#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_PGSZ_16G   (UINT32_C(0x16) << 5)
+	/* Page size is 32GB. */
+		#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_PGSZ_32G   (UINT32_C(0x17) << 5)
+	/* Page size is 64GB. */
+		#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_PGSZ_64G   (UINT32_C(0x18) << 5)
+	/* Page size is 128GB. */
+		#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_PGSZ_128G  (UINT32_C(0x19) << 5)
+	/* Page size is 256GB. */
+		#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_PGSZ_256G  (UINT32_C(0x1a) << 5)
+	/* Page size is 512GB. */
+		#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_PGSZ_512G  (UINT32_C(0x1b) << 5)
+	/* Page size is 1TB. */
+		#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_PGSZ_1T	(UINT32_C(0x1c) << 5)
+	/* Page size is 2TB. */
+		#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_PGSZ_2T	(UINT32_C(0x1d) << 5)
+	/* Page size is 4TB. */
+		#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_PGSZ_4T	(UINT32_C(0x1e) << 5)
+	/* Page size is 8TB. */
+		#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_PGSZ_8T	(UINT32_C(0x1f) << 5)
+		#define SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_LAST	SQ_FR_PMR_V3_PBL_PAGE_SIZE_LOG_PGSZ_8T
+	/* Number of levels of PBL for translation */
+	#define SQ_FR_PMR_V3_NUMLEVELS_MASK		UINT32_C(0xc00)
+	#define SQ_FR_PMR_V3_NUMLEVELS_SFT		10
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * A zero level PBL means that the VA is the physical address
+	 * used for the operation. No translation is done by the PTU.
 	 */
-	#define CREQ_ALLOCATE_MRW_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Allocate MRW command response. */
-	#define CREQ_ALLOCATE_MRW_RESP_EVENT_ALLOCATE_MRW UINT32_C(0xd)
-	#define CREQ_ALLOCATE_MRW_RESP_EVENT_LAST	CREQ_ALLOCATE_MRW_RESP_EVENT_ALLOCATE_MRW
-	uint8_t	reserved48[6];
-} creq_allocate_mrw_resp_t, *pcreq_allocate_mrw_resp_t;
-
-/******************
- * deallocate_key *
- ******************/
-
-
-/* cmdq_deallocate_key (size:192b/24B) */
-
-typedef struct cmdq_deallocate_key {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* De-allocate key command frees a MR/MW entry associated with the specified key. */
-	#define CMDQ_DEALLOCATE_KEY_OPCODE_DEALLOCATE_KEY UINT32_C(0xe)
-	#define CMDQ_DEALLOCATE_KEY_OPCODE_LAST	CMDQ_DEALLOCATE_KEY_OPCODE_DEALLOCATE_KEY
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	uint8_t	mrw_flags;
-	/* Deallocate MRW flags. */
-	#define CMDQ_DEALLOCATE_KEY_MRW_FLAGS_MASK	UINT32_C(0xf)
-	#define CMDQ_DEALLOCATE_KEY_MRW_FLAGS_SFT	0
-	/* Deallocate Memory Region */
-		#define CMDQ_DEALLOCATE_KEY_MRW_FLAGS_MR	UINT32_C(0x0)
-	/* Deallocate Physical Memory Region */
-		#define CMDQ_DEALLOCATE_KEY_MRW_FLAGS_PMR	UINT32_C(0x1)
-	/* Deallocate Memory Window (type 1) */
-		#define CMDQ_DEALLOCATE_KEY_MRW_FLAGS_MW_TYPE1   UINT32_C(0x2)
-	/* Deallocate Memory Window (type 2A) */
-		#define CMDQ_DEALLOCATE_KEY_MRW_FLAGS_MW_TYPE2A  UINT32_C(0x3)
-	/* Deallocate Memory Window (type 2B) */
-		#define CMDQ_DEALLOCATE_KEY_MRW_FLAGS_MW_TYPE2B  UINT32_C(0x4)
-		#define CMDQ_DEALLOCATE_KEY_MRW_FLAGS_LAST	CMDQ_DEALLOCATE_KEY_MRW_FLAGS_MW_TYPE2B
-	/* unused4 is 4 b */
-	#define CMDQ_DEALLOCATE_KEY_UNUSED4_MASK	UINT32_C(0xf0)
-	#define CMDQ_DEALLOCATE_KEY_UNUSED4_SFT	4
-	/* unused24 is 24 b */
-	uint8_t	unused24[3];
-	/* key is 32 b */
-	uint32_t	key;
-} cmdq_deallocate_key_t, *pcmdq_deallocate_key_t;
+		#define SQ_FR_PMR_V3_NUMLEVELS_PHYSICAL	(UINT32_C(0x0) << 10)
+	/*
+	 * A one layer translation is provided between the logical and
+	 * physical address. The PBL points to a physical page that
+	 * contains PBE values that point to actual pg_size physical
+	 * pages.
+	 */
+		#define SQ_FR_PMR_V3_NUMLEVELS_LAYER1		(UINT32_C(0x1) << 10)
+	/*
+	 * A two layer translation is provided between the logical and
+	 * physical address. The PBL points to a physical page that
+	 * contains PDE values that in turn point to pbl_pg_size
+	 * physical pages that contain PBE values that point to actual
+	 * physical pages.
+	 */
+		#define SQ_FR_PMR_V3_NUMLEVELS_LAYER2		(UINT32_C(0x2) << 10)
+		#define SQ_FR_PMR_V3_NUMLEVELS_LAST		SQ_FR_PMR_V3_NUMLEVELS_LAYER2
+	uint16_t	reserved;
+	/* Local Virtual Address */
+	uint64_t	va;
+	/* Length in bytes of registered MR */
+	uint64_t	length;
+	/* Pointer to the PBL, or PDL depending on number of levels */
+	uint64_t	pbl_ptr;
+} sq_fr_pmr_v3_t, *psq_fr_pmr_v3_t;
 
-/* creq_deallocate_key_resp (size:128b/16B) */
+/* SQ FR-PMR WQE V3 header for RC SQs. */
+/* sq_fr_pmr_hdr_v3 (size:320b/40B) */
 
-typedef struct creq_deallocate_key_resp {
-	uint8_t	type;
+typedef struct sq_fr_pmr_hdr_v3 {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * FR-PMR (Fast Register Physical Memory Region) V3
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	#define CREQ_DEALLOCATE_KEY_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_DEALLOCATE_KEY_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_DEALLOCATE_KEY_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_DEALLOCATE_KEY_RESP_TYPE_LAST	CREQ_DEALLOCATE_KEY_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* L_KEY for MR, R_KEY for MW */
-	uint32_t	xid;
-	uint8_t	v;
+	#define SQ_FR_PMR_HDR_V3_WQE_TYPE_FR_PMR_V3 UINT32_C(0x1b)
+	#define SQ_FR_PMR_HDR_V3_WQE_TYPE_LAST	SQ_FR_PMR_HDR_V3_WQE_TYPE_FR_PMR_V3
+	uint8_t	flags;
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * Set if completion signaling is requested. If this bit is
+	 * 0, and the SQ is configured to support Unsignaled
+	 * completion the controller should not generate a CQE
+	 * unless there was an error. This refers to CQE on the
+	 * sender side (The se flag refers to the receiver side).
 	 */
-	#define CREQ_DEALLOCATE_KEY_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* De-allocate key command response. */
-	#define CREQ_DEALLOCATE_KEY_RESP_EVENT_DEALLOCATE_KEY UINT32_C(0xe)
-	#define CREQ_DEALLOCATE_KEY_RESP_EVENT_LAST	CREQ_DEALLOCATE_KEY_RESP_EVENT_DEALLOCATE_KEY
-	uint16_t	reserved16;
+	#define SQ_FR_PMR_HDR_V3_FLAGS_SIGNAL_COMP		UINT32_C(0x1)
 	/*
-	 * This is advisory data to facilitate eventual descruction of lingering memory regions in Windows.
-	 * For memory window, it contains non-zero HWID of a region this window was bound to (without the 8-bit key portion).
-	 * The host may check if the region is lingering in destroyed state and try to destroy it now.
-	 * For memory region, if deallocation fails because there are windows bound to this region, this field will contain
-	 * approximate number of those windows. This number is read from the context right before the
-	 * deregistration is attempted and can potentially be slightly different from the current number.
+	 * Indication to complete all previous RDMA Read or Atomic
+	 * WQEs on the SQ before executing this WQE
 	 */
-	uint32_t	bound_window_info;
-} creq_deallocate_key_resp_t, *pcreq_deallocate_key_resp_t;
-
-/***************
- * register_mr *
- ***************/
-
-
-/* cmdq_register_mr (size:384b/48B) */
-
-typedef struct cmdq_register_mr {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Register MR command registers memory to the specified MR. */
-	#define CMDQ_REGISTER_MR_OPCODE_REGISTER_MR UINT32_C(0xf)
-	#define CMDQ_REGISTER_MR_OPCODE_LAST	CMDQ_REGISTER_MR_OPCODE_REGISTER_MR
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
+	#define SQ_FR_PMR_HDR_V3_FLAGS_RD_OR_ATOMIC_FENCE	UINT32_C(0x2)
 	/*
-	 * When set, a new MR will be allocated first and then registered
-	 * using the fields in this command. Note that for MR allocation
-	 * the `key` field doesn't hold a valid L_KEY and is instead
-	 * overloaded to hold the Protection Domain ID `pd_id`.
+	 * Unconditional fence. Indication to complete all previous
+	 * SQ's WQEs before executing this WQE.
 	 */
-	#define CMDQ_REGISTER_MR_FLAGS_ALLOC_MR	UINT32_C(0x1)
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	uint8_t	log2_pg_size_lvl;
-	/* PBL indirect levels. */
-	#define CMDQ_REGISTER_MR_LVL_MASK		UINT32_C(0x3)
-	#define CMDQ_REGISTER_MR_LVL_SFT		0
-	/* PBL pointer is physical start address. */
-		#define CMDQ_REGISTER_MR_LVL_LVL_0		UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define CMDQ_REGISTER_MR_LVL_LVL_1		UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define CMDQ_REGISTER_MR_LVL_LVL_2		UINT32_C(0x2)
-		#define CMDQ_REGISTER_MR_LVL_LAST		CMDQ_REGISTER_MR_LVL_LVL_2
-	/* Log base 2 of page size; 12 is the minimum for 4KB. HW supported values are enumerated below. */
-	#define CMDQ_REGISTER_MR_LOG2_PG_SIZE_MASK   UINT32_C(0x7c)
-	#define CMDQ_REGISTER_MR_LOG2_PG_SIZE_SFT	2
-	/* 4KB. */
-		#define CMDQ_REGISTER_MR_LOG2_PG_SIZE_PG_4K	(UINT32_C(0xc) << 2)
-	/* 8KB. */
-		#define CMDQ_REGISTER_MR_LOG2_PG_SIZE_PG_8K	(UINT32_C(0xd) << 2)
-	/* 64KB. */
-		#define CMDQ_REGISTER_MR_LOG2_PG_SIZE_PG_64K   (UINT32_C(0x10) << 2)
-	/* 256KB. */
-		#define CMDQ_REGISTER_MR_LOG2_PG_SIZE_PG_256K  (UINT32_C(0x12) << 2)
-	/* 1MB. */
-		#define CMDQ_REGISTER_MR_LOG2_PG_SIZE_PG_1M	(UINT32_C(0x14) << 2)
-	/* 2MB. */
-		#define CMDQ_REGISTER_MR_LOG2_PG_SIZE_PG_2M	(UINT32_C(0x15) << 2)
-	/* 4MB. */
-		#define CMDQ_REGISTER_MR_LOG2_PG_SIZE_PG_4M	(UINT32_C(0x16) << 2)
-	/* 1GB. */
-		#define CMDQ_REGISTER_MR_LOG2_PG_SIZE_PG_1G	(UINT32_C(0x1e) << 2)
-		#define CMDQ_REGISTER_MR_LOG2_PG_SIZE_LAST	CMDQ_REGISTER_MR_LOG2_PG_SIZE_PG_1G
-	/* unused1 is 1 b */
-	#define CMDQ_REGISTER_MR_UNUSED1		UINT32_C(0x80)
-	/* Access flags. */
-	uint8_t	access;
-	/* Local write access. */
-	#define CMDQ_REGISTER_MR_ACCESS_LOCAL_WRITE	UINT32_C(0x1)
-	/* Remote read access. */
-	#define CMDQ_REGISTER_MR_ACCESS_REMOTE_READ	UINT32_C(0x2)
-	/* Remote write access. */
-	#define CMDQ_REGISTER_MR_ACCESS_REMOTE_WRITE	UINT32_C(0x4)
-	/* Remote atomic access. */
-	#define CMDQ_REGISTER_MR_ACCESS_REMOTE_ATOMIC	UINT32_C(0x8)
-	/* Bind access allowed. */
-	#define CMDQ_REGISTER_MR_ACCESS_MW_BIND	UINT32_C(0x10)
-	/* Indicate Zero Based Virtual Address (ZBVA). */
-	#define CMDQ_REGISTER_MR_ACCESS_ZERO_BASED	UINT32_C(0x20)
-	uint16_t	log2_pbl_pg_size;
-	/* Log base 2 of PBL page size; 12 is the minimum for 4KB. HW supported values are enumerated below */
-	#define CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_MASK   UINT32_C(0x1f)
-	#define CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_SFT	0
-	/* 4KB. */
-		#define CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_PG_4K	UINT32_C(0xc)
-	/* 8KB. */
-		#define CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_PG_8K	UINT32_C(0xd)
-	/* 64KB. */
-		#define CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_PG_64K   UINT32_C(0x10)
-	/* 256KB. */
-		#define CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_PG_256K  UINT32_C(0x12)
-	/* 1MB. */
-		#define CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_PG_1M	UINT32_C(0x14)
-	/* 2MB. */
-		#define CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_PG_2M	UINT32_C(0x15)
-	/* 4MB. */
-		#define CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_PG_4M	UINT32_C(0x16)
-	/* 1GB. */
-		#define CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_PG_1G	UINT32_C(0x1e)
-		#define CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_LAST	CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_PG_1G
-	/* unused11 is 11 b */
-	#define CMDQ_REGISTER_MR_UNUSED11_MASK	UINT32_C(0xffe0)
-	#define CMDQ_REGISTER_MR_UNUSED11_SFT		5
+	#define SQ_FR_PMR_HDR_V3_FLAGS_UC_FENCE		UINT32_C(0x4)
 	/*
-	 * L_KEY of the previously allocated MR.
+	 * This flag is not applicable and should be 0 for a local memory
+	 * operation WQE.
+	 */
+	#define SQ_FR_PMR_HDR_V3_FLAGS_SE			UINT32_C(0x8)
+	/*
+	 * This flag is not applicable and should be 0 for a local memory
+	 * operation WQE.
+	 */
+	#define SQ_FR_PMR_HDR_V3_FLAGS_INLINE		UINT32_C(0x10)
+	/*
+	 * This flag is not applicable and should be 0 for a local memory
+	 * operation WQE.
+	 */
+	#define SQ_FR_PMR_HDR_V3_FLAGS_WQE_TS_EN		UINT32_C(0x20)
+	/*
+	 * When set to '1', this operation will cause a trace capture in
+	 * each block it passes through.
+	 */
+	#define SQ_FR_PMR_HDR_V3_FLAGS_DEBUG_TRACE		UINT32_C(0x40)
+	/*  */
+	uint8_t	wqe_size_zero_based;
+	/*
+	 * The size of the WQE in units of 16B chunks.
 	 *
-	 * If the `ALLOC_MR` flag is set then this field does not hold an
-	 * L_KEY and instead contains the Protection Domain ID `pd_id`.
+	 * For the FR-PMR WQE, this field will always have a value of 3.
 	 */
-	uint32_t	key;
-	/* Page table of the MR memory. */
-	uint64_t	pbl;
-	/* Virtual address of the MR. */
-	uint64_t	va;
-	/* Size of the MR. */
-	uint64_t	mr_size;
-} cmdq_register_mr_t, *pcmdq_register_mr_t;
-
-/* creq_register_mr_resp (size:128b/16B) */
-
-typedef struct creq_register_mr_resp {
-	uint8_t	type;
+	#define SQ_FR_PMR_HDR_V3_WQE_SIZE_MASK  UINT32_C(0x3f)
+	#define SQ_FR_PMR_HDR_V3_WQE_SIZE_SFT   0
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * If this is set, the PMR will be zero-based. If clear, the PMR
+	 * will be non-zero-based.
 	 */
-	#define CREQ_REGISTER_MR_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_REGISTER_MR_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_REGISTER_MR_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_REGISTER_MR_RESP_TYPE_LAST	CREQ_REGISTER_MR_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* L_KEY */
-	uint32_t	xid;
-	uint8_t	v;
+	#define SQ_FR_PMR_HDR_V3_ZERO_BASED	UINT32_C(0x40)
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * This is the new access control for the MR. '1' means
+	 * the operation is allowed. '0' means operation is
+	 * not allowed.
 	 */
-	#define CREQ_REGISTER_MR_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Register MR command response. */
-	#define CREQ_REGISTER_MR_RESP_EVENT_REGISTER_MR UINT32_C(0xf)
-	#define CREQ_REGISTER_MR_RESP_EVENT_LAST	CREQ_REGISTER_MR_RESP_EVENT_REGISTER_MR
-	uint8_t	reserved48[6];
-} creq_register_mr_resp_t, *pcreq_register_mr_resp_t;
-
-/*****************
- * deregister_mr *
- *****************/
-
-
-/* cmdq_deregister_mr (size:192b/24B) */
-
-typedef struct cmdq_deregister_mr {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Deregister MR command de-registers memory from the specified MR. */
-	#define CMDQ_DEREGISTER_MR_OPCODE_DEREGISTER_MR UINT32_C(0x10)
-	#define CMDQ_DEREGISTER_MR_OPCODE_LAST	CMDQ_DEREGISTER_MR_OPCODE_DEREGISTER_MR
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	/* L_KEY of the MR. */
-	uint32_t	lkey;
-	uint32_t	unused_0;
-} cmdq_deregister_mr_t, *pcmdq_deregister_mr_t;
-
-/* creq_deregister_mr_resp (size:128b/16B) */
-
-typedef struct creq_deregister_mr_resp {
-	uint8_t	type;
+	uint8_t	access_cntl;
+	/* Local Write Access */
+	#define SQ_FR_PMR_HDR_V3_ACCESS_CNTL_LOCAL_WRITE	UINT32_C(0x1)
+	/* Remote Read Access */
+	#define SQ_FR_PMR_HDR_V3_ACCESS_CNTL_REMOTE_READ	UINT32_C(0x2)
+	/* Remote Write Access */
+	#define SQ_FR_PMR_HDR_V3_ACCESS_CNTL_REMOTE_WRITE	UINT32_C(0x4)
+	/* Remote Atomic Access */
+	#define SQ_FR_PMR_HDR_V3_ACCESS_CNTL_REMOTE_ATOMIC	UINT32_C(0x8)
+	/* Window Binding Allowed */
+	#define SQ_FR_PMR_HDR_V3_ACCESS_CNTL_WINDOW_BIND	UINT32_C(0x10)
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * This value will be returned in the completion if the completion is
+	 * signaled.
 	 */
-	#define CREQ_DEREGISTER_MR_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_DEREGISTER_MR_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_DEREGISTER_MR_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_DEREGISTER_MR_RESP_TYPE_LAST	CREQ_DEREGISTER_MR_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* L_KEY */
-	uint32_t	xid;
-	uint8_t	v;
+	uint32_t	opaque;
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * Local Key; 24 msb of the key are used to index the MRW
+	 * table, 8 lsb are assigned to the 8 bit key_lsb field in
+	 * the MRWC.
 	 */
-	#define CREQ_DEREGISTER_MR_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Deregister MR command response. */
-	#define CREQ_DEREGISTER_MR_RESP_EVENT_DEREGISTER_MR UINT32_C(0x10)
-	#define CREQ_DEREGISTER_MR_RESP_EVENT_LAST	CREQ_DEREGISTER_MR_RESP_EVENT_DEREGISTER_MR
-	uint16_t	reserved16;
+	uint32_t	l_key;
+	uint16_t	page_size_log;
 	/*
-	 * If deregister fails because there are windows bound to this region, this field will contain
-	 * approximate number of those windows. This number is read from the context right before the
-	 * deregistration is attempted and can potentially be slightly different from the current number.
+	 * This value controls the page size for leaf memory pages in
+	 * a PBL. While many page sizes are supported only the following
+	 * should be tested - 4k, 8k, 64k, 256k, 1m, 2m, 4m, 1g
 	 */
-	uint32_t	bound_windows;
-} creq_deregister_mr_resp_t, *pcreq_deregister_mr_resp_t;
-
-/***********
- * add_gid *
- ***********/
-
-
-/* cmdq_add_gid (size:384b/48B) */
-
-typedef struct cmdq_add_gid {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Add GID command adds a GID to the local address table. */
-	#define CMDQ_ADD_GID_OPCODE_ADD_GID UINT32_C(0x11)
-	#define CMDQ_ADD_GID_OPCODE_LAST   CMDQ_ADD_GID_OPCODE_ADD_GID
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	/* GID, specified in LE format. */
-	uint32_t	gid[4];
-	/* Source MAC. */
-	uint16_t	src_mac[3];
-	/* flags. */
-	uint16_t	vlan;
-	#define CMDQ_ADD_GID_VLAN_VLAN_EN_TPID_VLAN_ID_MASK	UINT32_C(0xffff)
-	#define CMDQ_ADD_GID_VLAN_VLAN_EN_TPID_VLAN_ID_SFT	0
-	/* Source VLAN id. */
-	#define CMDQ_ADD_GID_VLAN_VLAN_ID_MASK			UINT32_C(0xfff)
-	#define CMDQ_ADD_GID_VLAN_VLAN_ID_SFT			0
-	/* This set of bits select the TPID of the VLAN Tag. */
-	#define CMDQ_ADD_GID_VLAN_TPID_MASK			UINT32_C(0x7000)
-	#define CMDQ_ADD_GID_VLAN_TPID_SFT			12
-	/* TPID = 0x88A8. */
-		#define CMDQ_ADD_GID_VLAN_TPID_TPID_88A8			(UINT32_C(0x0) << 12)
-	/* TPID = 0x8100. */
-		#define CMDQ_ADD_GID_VLAN_TPID_TPID_8100			(UINT32_C(0x1) << 12)
-	/* TPID = 0x9100. */
-		#define CMDQ_ADD_GID_VLAN_TPID_TPID_9100			(UINT32_C(0x2) << 12)
-	/* TPID = 0x9200. */
-		#define CMDQ_ADD_GID_VLAN_TPID_TPID_9200			(UINT32_C(0x3) << 12)
-	/* TPID = 0x9300. */
-		#define CMDQ_ADD_GID_VLAN_TPID_TPID_9300			(UINT32_C(0x4) << 12)
-	/* TPID = Configurable 1. */
-		#define CMDQ_ADD_GID_VLAN_TPID_TPID_CFG1			(UINT32_C(0x5) << 12)
-	/* TPID = Configurable 2. */
-		#define CMDQ_ADD_GID_VLAN_TPID_TPID_CFG2			(UINT32_C(0x6) << 12)
-	/* TPID = Configurable 3. */
-		#define CMDQ_ADD_GID_VLAN_TPID_TPID_CFG3			(UINT32_C(0x7) << 12)
-		#define CMDQ_ADD_GID_VLAN_TPID_LAST			CMDQ_ADD_GID_VLAN_TPID_TPID_CFG3
-	/* Setting this bit to 1 enables insertion of a VLAN Tag to a RoCE header. */
-	#define CMDQ_ADD_GID_VLAN_VLAN_EN				UINT32_C(0x8000)
-	/* Identifier field in the IP header. */
-	uint16_t	ipid;
-	/* Stats context ID to use with this SGID */
-	uint16_t	stats_ctx;
-	#define CMDQ_ADD_GID_STATS_CTX_STATS_CTX_VALID_STATS_CTX_ID_MASK		UINT32_C(0xffff)
-	#define CMDQ_ADD_GID_STATS_CTX_STATS_CTX_VALID_STATS_CTX_ID_SFT		0
-	/* stats_ctx_id is 15 b */
-	#define CMDQ_ADD_GID_STATS_CTX_STATS_CTX_ID_MASK				UINT32_C(0x7fff)
-	#define CMDQ_ADD_GID_STATS_CTX_STATS_CTX_ID_SFT				0
-	/* Setting this bit to 1 enables use of own stats context ID instead of per-function */
-	#define CMDQ_ADD_GID_STATS_CTX_STATS_CTX_VALID				UINT32_C(0x8000)
-	uint32_t	unused_0;
-} cmdq_add_gid_t, *pcmdq_add_gid_t;
+	#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_MASK	UINT32_C(0x1f)
+	#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_SFT	0
+	/* Page size is 4KB. */
+		#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_PGSZ_4K	UINT32_C(0x0)
+	/* Page size is 8KB. */
+		#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_PGSZ_8K	UINT32_C(0x1)
+	/* Page size is 16KB. */
+		#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_PGSZ_16K	UINT32_C(0x2)
+	/* Page size is 32KB. */
+		#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_PGSZ_32K	UINT32_C(0x3)
+	/* Page size is 64KB. */
+		#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_PGSZ_64K	UINT32_C(0x4)
+	/* Page size is 128KB. */
+		#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_PGSZ_128K	UINT32_C(0x5)
+	/* Page size is 256KB. */
+		#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_PGSZ_256K	UINT32_C(0x6)
+	/* Page size is 512KB. */
+		#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_PGSZ_512K	UINT32_C(0x7)
+	/* Page size is 1MB. */
+		#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_PGSZ_1M	UINT32_C(0x8)
+	/* Page size is 2MB. */
+		#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_PGSZ_2M	UINT32_C(0x9)
+	/* Page size is 4MB. */
+		#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_PGSZ_4M	UINT32_C(0xa)
+	/* Page size is 8MB. */
+		#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_PGSZ_8M	UINT32_C(0xb)
+	/* Page size is 16MB. */
+		#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_PGSZ_16M	UINT32_C(0xc)
+	/* Page size is 32MB. */
+		#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_PGSZ_32M	UINT32_C(0xd)
+	/* Page size is 64MB. */
+		#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_PGSZ_64M	UINT32_C(0xe)
+	/* Page size is 128MB. */
+		#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_PGSZ_128M	UINT32_C(0xf)
+	/* Page size is 256MB. */
+		#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_PGSZ_256M	UINT32_C(0x10)
+	/* Page size is 512MB. */
+		#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_PGSZ_512M	UINT32_C(0x11)
+	/* Page size is 1GB. */
+		#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_PGSZ_1G	UINT32_C(0x12)
+	/* Page size is 2GB. */
+		#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_PGSZ_2G	UINT32_C(0x13)
+	/* Page size is 4GB. */
+		#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_PGSZ_4G	UINT32_C(0x14)
+	/* Page size is 8GB. */
+		#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_PGSZ_8G	UINT32_C(0x15)
+	/* Page size is 16GB. */
+		#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_PGSZ_16G	UINT32_C(0x16)
+	/* Page size is 32GB. */
+		#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_PGSZ_32G	UINT32_C(0x17)
+	/* Page size is 64GB. */
+		#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_PGSZ_64G	UINT32_C(0x18)
+	/* Page size is 128GB. */
+		#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_PGSZ_128G	UINT32_C(0x19)
+	/* Page size is 256GB. */
+		#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_PGSZ_256G	UINT32_C(0x1a)
+	/* Page size is 512GB. */
+		#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_PGSZ_512G	UINT32_C(0x1b)
+	/* Page size is 1TB. */
+		#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_PGSZ_1T	UINT32_C(0x1c)
+	/* Page size is 2TB. */
+		#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_PGSZ_2T	UINT32_C(0x1d)
+	/* Page size is 4TB. */
+		#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_PGSZ_4T	UINT32_C(0x1e)
+	/* Page size is 8TB. */
+		#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_PGSZ_8T	UINT32_C(0x1f)
+		#define SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_LAST	SQ_FR_PMR_HDR_V3_PAGE_SIZE_LOG_PGSZ_8T
+	/*
+	 * This value controls the page size for page table elements
+	 * within a PBL. While many page sizes are supported only the
+	 * following should be tested - 4k, 8k, 64k, 256k, 1m, 2m, 4m, 1g
+	 */
+	#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_MASK	UINT32_C(0x3e0)
+	#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_SFT	5
+	/* Page size is 4KB. */
+		#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_PGSZ_4K	(UINT32_C(0x0) << 5)
+	/* Page size is 8KB. */
+		#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_PGSZ_8K	(UINT32_C(0x1) << 5)
+	/* Page size is 16KB. */
+		#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_PGSZ_16K   (UINT32_C(0x2) << 5)
+	/* Page size is 32KB. */
+		#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_PGSZ_32K   (UINT32_C(0x3) << 5)
+	/* Page size is 64KB. */
+		#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_PGSZ_64K   (UINT32_C(0x4) << 5)
+	/* Page size is 128KB. */
+		#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_PGSZ_128K  (UINT32_C(0x5) << 5)
+	/* Page size is 256KB. */
+		#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_PGSZ_256K  (UINT32_C(0x6) << 5)
+	/* Page size is 512KB. */
+		#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_PGSZ_512K  (UINT32_C(0x7) << 5)
+	/* Page size is 1MB. */
+		#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_PGSZ_1M	(UINT32_C(0x8) << 5)
+	/* Page size is 2MB. */
+		#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_PGSZ_2M	(UINT32_C(0x9) << 5)
+	/* Page size is 4MB. */
+		#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_PGSZ_4M	(UINT32_C(0xa) << 5)
+	/* Page size is 8MB. */
+		#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_PGSZ_8M	(UINT32_C(0xb) << 5)
+	/* Page size is 16MB. */
+		#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_PGSZ_16M   (UINT32_C(0xc) << 5)
+	/* Page size is 32MB. */
+		#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_PGSZ_32M   (UINT32_C(0xd) << 5)
+	/* Page size is 64MB. */
+		#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_PGSZ_64M   (UINT32_C(0xe) << 5)
+	/* Page size is 128MB. */
+		#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_PGSZ_128M  (UINT32_C(0xf) << 5)
+	/* Page size is 256MB. */
+		#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_PGSZ_256M  (UINT32_C(0x10) << 5)
+	/* Page size is 512MB. */
+		#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_PGSZ_512M  (UINT32_C(0x11) << 5)
+	/* Page size is 1GB. */
+		#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_PGSZ_1G	(UINT32_C(0x12) << 5)
+	/* Page size is 2GB. */
+		#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_PGSZ_2G	(UINT32_C(0x13) << 5)
+	/* Page size is 4GB. */
+		#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_PGSZ_4G	(UINT32_C(0x14) << 5)
+	/* Page size is 8GB. */
+		#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_PGSZ_8G	(UINT32_C(0x15) << 5)
+	/* Page size is 16GB. */
+		#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_PGSZ_16G   (UINT32_C(0x16) << 5)
+	/* Page size is 32GB. */
+		#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_PGSZ_32G   (UINT32_C(0x17) << 5)
+	/* Page size is 64GB. */
+		#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_PGSZ_64G   (UINT32_C(0x18) << 5)
+	/* Page size is 128GB. */
+		#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_PGSZ_128G  (UINT32_C(0x19) << 5)
+	/* Page size is 256GB. */
+		#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_PGSZ_256G  (UINT32_C(0x1a) << 5)
+	/* Page size is 512GB. */
+		#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_PGSZ_512G  (UINT32_C(0x1b) << 5)
+	/* Page size is 1TB. */
+		#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_PGSZ_1T	(UINT32_C(0x1c) << 5)
+	/* Page size is 2TB. */
+		#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_PGSZ_2T	(UINT32_C(0x1d) << 5)
+	/* Page size is 4TB. */
+		#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_PGSZ_4T	(UINT32_C(0x1e) << 5)
+	/* Page size is 8TB. */
+		#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_PGSZ_8T	(UINT32_C(0x1f) << 5)
+		#define SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_LAST	SQ_FR_PMR_HDR_V3_PBL_PAGE_SIZE_LOG_PGSZ_8T
+	/* Number of levels of PBL for translation */
+	#define SQ_FR_PMR_HDR_V3_NUMLEVELS_MASK		UINT32_C(0xc00)
+	#define SQ_FR_PMR_HDR_V3_NUMLEVELS_SFT		10
+	/*
+	 * A zero level PBL means that the VA is the physical address
+	 * used for the operation. No translation is done by the PTU.
+	 */
+		#define SQ_FR_PMR_HDR_V3_NUMLEVELS_PHYSICAL	(UINT32_C(0x0) << 10)
+	/*
+	 * A one layer translation is provided between the logical and
+	 * physical address. The PBL points to a physical page that
+	 * contains PBE values that point to actual pg_size physical
+	 * pages.
+	 */
+		#define SQ_FR_PMR_HDR_V3_NUMLEVELS_LAYER1		(UINT32_C(0x1) << 10)
+	/*
+	 * A two layer translation is provided between the logical and
+	 * physical address. The PBL points to a physical page that
+	 * contains PDE values that in turn point to pbl_pg_size
+	 * physical pages that contain PBE values that point to actual
+	 * physical pages.
+	 */
+		#define SQ_FR_PMR_HDR_V3_NUMLEVELS_LAYER2		(UINT32_C(0x2) << 10)
+		#define SQ_FR_PMR_HDR_V3_NUMLEVELS_LAST		SQ_FR_PMR_HDR_V3_NUMLEVELS_LAYER2
+	uint16_t	reserved;
+	/* Local Virtual Address */
+	uint64_t	va;
+	/* Length in bytes of registered MR */
+	uint64_t	length;
+	/* Pointer to the PBL, or PDL depending on number of levels */
+	uint64_t	pbl_ptr;
+} sq_fr_pmr_hdr_v3_t, *psq_fr_pmr_hdr_v3_t;
 
-/* creq_add_gid_resp (size:128b/16B) */
+/*
+ * SQ Bind WQE V3. This WQE can perform either:
+ * * type1 "bind memory window", if mw_type==Type1
+ * * type2 "post send bind memory window", if mw_type==Type2
+ */
+/* sq_bind_v3 (size:256b/32B) */
 
-typedef struct creq_add_gid_resp {
-	uint8_t	type;
+typedef struct sq_bind_v3 {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
+	/*
+	 * Memory Bind V3
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
+	 */
+	#define SQ_BIND_V3_WQE_TYPE_BIND_V3 UINT32_C(0x1c)
+	#define SQ_BIND_V3_WQE_TYPE_LAST   SQ_BIND_V3_WQE_TYPE_BIND_V3
+	uint8_t	flags;
+	/*
+	 * Set if completion signaling is requested. If this bit is
+	 * 0, and the SQ is configured to support Unsignaled
+	 * completion the controller should not generate a CQE
+	 * unless there was an error. This refers to CQE on the
+	 * sender side (The se flag refers to the receiver side).
+	 */
+	#define SQ_BIND_V3_FLAGS_SIGNAL_COMP		UINT32_C(0x1)
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * Indication to complete all previous RDMA Read or Atomic
+	 * WQEs on the SQ before executing this WQE
 	 */
-	#define CREQ_ADD_GID_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_ADD_GID_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_ADD_GID_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_ADD_GID_RESP_TYPE_LAST	CREQ_ADD_GID_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* GID index */
-	uint32_t	xid;
-	uint8_t	v;
+	#define SQ_BIND_V3_FLAGS_RD_OR_ATOMIC_FENCE	UINT32_C(0x2)
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * Unconditional fence. Indication to complete all previous
+	 * SQ's WQEs before executing this WQE.
 	 */
-	#define CREQ_ADD_GID_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Add GID command response. */
-	#define CREQ_ADD_GID_RESP_EVENT_ADD_GID UINT32_C(0x11)
-	#define CREQ_ADD_GID_RESP_EVENT_LAST   CREQ_ADD_GID_RESP_EVENT_ADD_GID
-	uint8_t	reserved48[6];
-} creq_add_gid_resp_t, *pcreq_add_gid_resp_t;
-
-/**************
- * delete_gid *
- **************/
-
-
-/* cmdq_delete_gid (size:192b/24B) */
-
-typedef struct cmdq_delete_gid {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Delete GID command deletes a GID from the local address table. */
-	#define CMDQ_DELETE_GID_OPCODE_DELETE_GID UINT32_C(0x12)
-	#define CMDQ_DELETE_GID_OPCODE_LAST	CMDQ_DELETE_GID_OPCODE_DELETE_GID
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	/* GID index */
-	uint16_t	gid_index;
-	uint8_t	unused_0[6];
-} cmdq_delete_gid_t, *pcmdq_delete_gid_t;
-
-/* creq_delete_gid_resp (size:128b/16B) */
-
-typedef struct creq_delete_gid_resp {
-	uint8_t	type;
+	#define SQ_BIND_V3_FLAGS_UC_FENCE		UINT32_C(0x4)
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * This flag is not applicable and should be 0 for a local memory
+	 * operation WQE.
 	 */
-	#define CREQ_DELETE_GID_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_DELETE_GID_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_DELETE_GID_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_DELETE_GID_RESP_TYPE_LAST	CREQ_DELETE_GID_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* GID index */
-	uint32_t	xid;
-	uint8_t	v;
+	#define SQ_BIND_V3_FLAGS_SE			UINT32_C(0x8)
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * This flag is not applicable and should be 0 for a local memory
+	 * operation WQE.
 	 */
-	#define CREQ_DELETE_GID_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Delete GID command response. */
-	#define CREQ_DELETE_GID_RESP_EVENT_DELETE_GID UINT32_C(0x12)
-	#define CREQ_DELETE_GID_RESP_EVENT_LAST	CREQ_DELETE_GID_RESP_EVENT_DELETE_GID
-	uint8_t	reserved48[6];
-} creq_delete_gid_resp_t, *pcreq_delete_gid_resp_t;
-
-/**************
- * modify_gid *
- **************/
-
-
-/* cmdq_modify_gid (size:384b/48B) */
-
-typedef struct cmdq_modify_gid {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Modify GID command modifies a GID in the local address table. */
-	#define CMDQ_MODIFY_GID_OPCODE_MODIFY_GID UINT32_C(0x17)
-	#define CMDQ_MODIFY_GID_OPCODE_LAST	CMDQ_MODIFY_GID_OPCODE_MODIFY_GID
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	/* GID */
-	uint32_t	gid[4];
-	/* Source MAC. */
-	uint16_t	src_mac[3];
-	/* flags. */
-	uint16_t	vlan;
-	/* Source VLAN id. */
-	#define CMDQ_MODIFY_GID_VLAN_VLAN_ID_MASK  UINT32_C(0xfff)
-	#define CMDQ_MODIFY_GID_VLAN_VLAN_ID_SFT   0
-	/* This set of bits select the TPID of the VLAN Tag. */
-	#define CMDQ_MODIFY_GID_VLAN_TPID_MASK	UINT32_C(0x7000)
-	#define CMDQ_MODIFY_GID_VLAN_TPID_SFT	12
-	/* TPID = 0x88A8. */
-		#define CMDQ_MODIFY_GID_VLAN_TPID_TPID_88A8  (UINT32_C(0x0) << 12)
-	/* TPID = 0x8100. */
-		#define CMDQ_MODIFY_GID_VLAN_TPID_TPID_8100  (UINT32_C(0x1) << 12)
-	/* TPID = 0x9100. */
-		#define CMDQ_MODIFY_GID_VLAN_TPID_TPID_9100  (UINT32_C(0x2) << 12)
-	/* TPID = 0x9200. */
-		#define CMDQ_MODIFY_GID_VLAN_TPID_TPID_9200  (UINT32_C(0x3) << 12)
-	/* TPID = 0x9300. */
-		#define CMDQ_MODIFY_GID_VLAN_TPID_TPID_9300  (UINT32_C(0x4) << 12)
-	/* TPID = Configurable 1. */
-		#define CMDQ_MODIFY_GID_VLAN_TPID_TPID_CFG1  (UINT32_C(0x5) << 12)
-	/* TPID = Configurable 2. */
-		#define CMDQ_MODIFY_GID_VLAN_TPID_TPID_CFG2  (UINT32_C(0x6) << 12)
-	/* TPID = Configurable 3. */
-		#define CMDQ_MODIFY_GID_VLAN_TPID_TPID_CFG3  (UINT32_C(0x7) << 12)
-		#define CMDQ_MODIFY_GID_VLAN_TPID_LAST	CMDQ_MODIFY_GID_VLAN_TPID_TPID_CFG3
-	/* Setting this bit to 1 enables insertion of a VLAN Tag to a RoCE header. */
-	#define CMDQ_MODIFY_GID_VLAN_VLAN_EN	UINT32_C(0x8000)
-	/* Identifier field in the IP header. */
-	uint16_t	ipid;
-	/* GID index */
-	uint16_t	gid_index;
-	/* Stats context ID to use with this SGID */
-	uint16_t	stats_ctx;
-	/* stats_ctx_id is 15 b */
-	#define CMDQ_MODIFY_GID_STATS_CTX_STATS_CTX_ID_MASK   UINT32_C(0x7fff)
-	#define CMDQ_MODIFY_GID_STATS_CTX_STATS_CTX_ID_SFT	0
-	/* Setting this bit to 1 enables use of own stats context ID instead of per-function */
-	#define CMDQ_MODIFY_GID_STATS_CTX_STATS_CTX_VALID	UINT32_C(0x8000)
-	uint16_t	unused_0;
-} cmdq_modify_gid_t, *pcmdq_modify_gid_t;
-
-/* creq_modify_gid_resp (size:128b/16B) */
-
-typedef struct creq_modify_gid_resp {
-	uint8_t	type;
+	#define SQ_BIND_V3_FLAGS_INLINE		UINT32_C(0x10)
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * This flag is not applicable and should be 0 for a local memory
+	 * operation WQE.
 	 */
-	#define CREQ_MODIFY_GID_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_MODIFY_GID_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_MODIFY_GID_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_MODIFY_GID_RESP_TYPE_LAST	CREQ_MODIFY_GID_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* GID index */
-	uint32_t	xid;
-	uint8_t	v;
+	#define SQ_BIND_V3_FLAGS_WQE_TS_EN		UINT32_C(0x20)
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * When set to '1', this operation will cause a trace capture in
+	 * each block it passes through.
 	 */
-	#define CREQ_MODIFY_GID_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Add GID command response. */
-	#define CREQ_MODIFY_GID_RESP_EVENT_ADD_GID UINT32_C(0x11)
-	#define CREQ_MODIFY_GID_RESP_EVENT_LAST   CREQ_MODIFY_GID_RESP_EVENT_ADD_GID
-	uint8_t	reserved48[6];
-} creq_modify_gid_resp_t, *pcreq_modify_gid_resp_t;
-
-/*************
- * query_gid *
- *************/
-
-
-/* cmdq_query_gid (size:192b/24B) */
-
-typedef struct cmdq_query_gid {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Query GID command queries a GID in the local address table. */
-	#define CMDQ_QUERY_GID_OPCODE_QUERY_GID UINT32_C(0x18)
-	#define CMDQ_QUERY_GID_OPCODE_LAST	CMDQ_QUERY_GID_OPCODE_QUERY_GID
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	/* GID index */
-	uint16_t	gid_index;
-	/* unused16 is 16 b */
-	uint8_t	unused16[6];
-} cmdq_query_gid_t, *pcmdq_query_gid_t;
-
-/* creq_query_gid_resp (size:128b/16B) */
-
-typedef struct creq_query_gid_resp {
-	uint8_t	type;
+	#define SQ_BIND_V3_FLAGS_DEBUG_TRACE		UINT32_C(0x40)
+	uint8_t	wqe_size_zero_based_mw_type;
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * The size of the WQE in units of 16B chunks.
+	 *
+	 * For the Bind WQE, this field will always have a value of 2.
 	 */
-	#define CREQ_QUERY_GID_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_QUERY_GID_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_QUERY_GID_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_QUERY_GID_RESP_TYPE_LAST	CREQ_QUERY_GID_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Side buffer size in 16-byte units */
-	uint32_t	size;
-	uint8_t	v;
+	#define SQ_BIND_V3_WQE_SIZE_MASK  UINT32_C(0x3f)
+	#define SQ_BIND_V3_WQE_SIZE_SFT   0
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * If this bit is set, then the newly-bound memory window will be
+	 * zero-based. If clear, then the newly-bound memory window will be
+	 * non-zero-based.
 	 */
-	#define CREQ_QUERY_GID_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Query GID command response. */
-	#define CREQ_QUERY_GID_RESP_EVENT_QUERY_GID UINT32_C(0x18)
-	#define CREQ_QUERY_GID_RESP_EVENT_LAST	CREQ_QUERY_GID_RESP_EVENT_QUERY_GID
-	uint8_t	reserved48[6];
-} creq_query_gid_resp_t, *pcreq_query_gid_resp_t;
-
-/* Query GID command response side buffer structure */
-/* creq_query_gid_resp_sb (size:320b/40B) */
-
-typedef struct creq_query_gid_resp_sb {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Query GID command response. */
-	#define CREQ_QUERY_GID_RESP_SB_OPCODE_QUERY_GID UINT32_C(0x18)
-	#define CREQ_QUERY_GID_RESP_SB_OPCODE_LAST	CREQ_QUERY_GID_RESP_SB_OPCODE_QUERY_GID
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* GID */
-	uint32_t	gid[4];
-	/* Source MAC. */
-	uint16_t	src_mac[3];
-	/* flags. */
-	uint16_t	vlan;
-	#define CREQ_QUERY_GID_RESP_SB_VLAN_VLAN_EN_TPID_VLAN_ID_MASK	UINT32_C(0xffff)
-	#define CREQ_QUERY_GID_RESP_SB_VLAN_VLAN_EN_TPID_VLAN_ID_SFT	0
-	/* Source VLAN id. */
-	#define CREQ_QUERY_GID_RESP_SB_VLAN_VLAN_ID_MASK			UINT32_C(0xfff)
-	#define CREQ_QUERY_GID_RESP_SB_VLAN_VLAN_ID_SFT			0
-	/* This set of bits select the TPID of the VLAN Tag. */
-	#define CREQ_QUERY_GID_RESP_SB_VLAN_TPID_MASK			UINT32_C(0x7000)
-	#define CREQ_QUERY_GID_RESP_SB_VLAN_TPID_SFT			12
-	/* TPID = 0x88A8. */
-		#define CREQ_QUERY_GID_RESP_SB_VLAN_TPID_TPID_88A8			(UINT32_C(0x0) << 12)
-	/* TPID = 0x8100. */
-		#define CREQ_QUERY_GID_RESP_SB_VLAN_TPID_TPID_8100			(UINT32_C(0x1) << 12)
-	/* TPID = 0x9100. */
-		#define CREQ_QUERY_GID_RESP_SB_VLAN_TPID_TPID_9100			(UINT32_C(0x2) << 12)
-	/* TPID = 0x9200. */
-		#define CREQ_QUERY_GID_RESP_SB_VLAN_TPID_TPID_9200			(UINT32_C(0x3) << 12)
-	/* TPID = 0x9300. */
-		#define CREQ_QUERY_GID_RESP_SB_VLAN_TPID_TPID_9300			(UINT32_C(0x4) << 12)
-	/* TPID = Configurable 1. */
-		#define CREQ_QUERY_GID_RESP_SB_VLAN_TPID_TPID_CFG1			(UINT32_C(0x5) << 12)
-	/* TPID = Configurable 2. */
-		#define CREQ_QUERY_GID_RESP_SB_VLAN_TPID_TPID_CFG2			(UINT32_C(0x6) << 12)
-	/* TPID = Configurable 3. */
-		#define CREQ_QUERY_GID_RESP_SB_VLAN_TPID_TPID_CFG3			(UINT32_C(0x7) << 12)
-		#define CREQ_QUERY_GID_RESP_SB_VLAN_TPID_LAST			CREQ_QUERY_GID_RESP_SB_VLAN_TPID_TPID_CFG3
-	/* Setting this bit to 1 enables insertion of a VLAN Tag to a RoCE header. */
-	#define CREQ_QUERY_GID_RESP_SB_VLAN_VLAN_EN				UINT32_C(0x8000)
-	/* Identifier field in the IP header. */
-	uint16_t	ipid;
-	/* GID index */
-	uint16_t	gid_index;
-	uint32_t	unused_0;
-} creq_query_gid_resp_sb_t, *pcreq_query_gid_resp_sb_t;
-
-/**************
- * create_qp1 *
- **************/
-
-
-/* cmdq_create_qp1 (size:640b/80B) */
-
-typedef struct cmdq_create_qp1 {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Create QP1 command allocates a QP1 only. */
-	#define CMDQ_CREATE_QP1_OPCODE_CREATE_QP1 UINT32_C(0x13)
-	#define CMDQ_CREATE_QP1_OPCODE_LAST	CMDQ_CREATE_QP1_OPCODE_CREATE_QP1
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	/* QP1 handle. */
-	uint64_t	qp_handle;
-	/* Create QP1 flags. */
-	uint32_t	qp_flags;
-	/* SRQ is used. */
-	#define CMDQ_CREATE_QP1_QP_FLAGS_SRQ_USED		UINT32_C(0x1)
-	/* post CQE for all SQ WQEs. */
-	#define CMDQ_CREATE_QP1_QP_FLAGS_FORCE_COMPLETION	UINT32_C(0x2)
-	/* This QP can use reserved L_Key */
-	#define CMDQ_CREATE_QP1_QP_FLAGS_RESERVED_LKEY_ENABLE UINT32_C(0x4)
-	#define CMDQ_CREATE_QP1_QP_FLAGS_LAST		CMDQ_CREATE_QP1_QP_FLAGS_RESERVED_LKEY_ENABLE
-	/* Supported QP1 types. */
-	uint8_t	type;
-	/* General Services Interface on QP 1. */
-	#define CMDQ_CREATE_QP1_TYPE_GSI UINT32_C(0x1)
-	#define CMDQ_CREATE_QP1_TYPE_LAST CMDQ_CREATE_QP1_TYPE_GSI
-	uint8_t	sq_pg_size_sq_lvl;
-	/* SQ PBL indirect levels. */
-	#define CMDQ_CREATE_QP1_SQ_LVL_MASK	UINT32_C(0xf)
-	#define CMDQ_CREATE_QP1_SQ_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define CMDQ_CREATE_QP1_SQ_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define CMDQ_CREATE_QP1_SQ_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define CMDQ_CREATE_QP1_SQ_LVL_LVL_2	UINT32_C(0x2)
-		#define CMDQ_CREATE_QP1_SQ_LVL_LAST	CMDQ_CREATE_QP1_SQ_LVL_LVL_2
-	/* SQ page size. */
-	#define CMDQ_CREATE_QP1_SQ_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define CMDQ_CREATE_QP1_SQ_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define CMDQ_CREATE_QP1_SQ_PG_SIZE_LAST   CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_1G
-	uint8_t	rq_pg_size_rq_lvl;
-	/* RQ PBL indirect levels. */
-	#define CMDQ_CREATE_QP1_RQ_LVL_MASK	UINT32_C(0xf)
-	#define CMDQ_CREATE_QP1_RQ_LVL_SFT	0
-	/* PBL pointer is physical start address. */
-		#define CMDQ_CREATE_QP1_RQ_LVL_LVL_0	UINT32_C(0x0)
-	/* PBL pointer points to PTE table. */
-		#define CMDQ_CREATE_QP1_RQ_LVL_LVL_1	UINT32_C(0x1)
-	/* PBL pointer points to PDE table with each entry pointing to PTE tables. */
-		#define CMDQ_CREATE_QP1_RQ_LVL_LVL_2	UINT32_C(0x2)
-		#define CMDQ_CREATE_QP1_RQ_LVL_LAST	CMDQ_CREATE_QP1_RQ_LVL_LVL_2
-	/* RQ page size. */
-	#define CMDQ_CREATE_QP1_RQ_PG_SIZE_MASK  UINT32_C(0xf0)
-	#define CMDQ_CREATE_QP1_RQ_PG_SIZE_SFT   4
-	/* 4KB. */
-		#define CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_4K   (UINT32_C(0x0) << 4)
-	/* 8KB. */
-		#define CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_8K   (UINT32_C(0x1) << 4)
-	/* 64KB. */
-		#define CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_64K  (UINT32_C(0x2) << 4)
-	/* 2MB. */
-		#define CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_2M   (UINT32_C(0x3) << 4)
-	/* 8MB. */
-		#define CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_8M   (UINT32_C(0x4) << 4)
-	/* 1GB. */
-		#define CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_1G   (UINT32_C(0x5) << 4)
-		#define CMDQ_CREATE_QP1_RQ_PG_SIZE_LAST   CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_1G
-	uint8_t	unused_0;
-	/* Doorbell page index. */
-	uint32_t	dpi;
-	/* Max number of SQ wqes. */
-	uint32_t	sq_size;
-	/* Max number of RQ wqes. */
-	uint32_t	rq_size;
-	uint16_t	sq_fwo_sq_sge;
-	/* Max send SGEs per SWQE. */
-	#define CMDQ_CREATE_QP1_SQ_SGE_MASK UINT32_C(0xf)
-	#define CMDQ_CREATE_QP1_SQ_SGE_SFT 0
-	/* Offset of First WQE in the first SQ page, in 128 byte units */
-	#define CMDQ_CREATE_QP1_SQ_FWO_MASK UINT32_C(0xfff0)
-	#define CMDQ_CREATE_QP1_SQ_FWO_SFT 4
-	uint16_t	rq_fwo_rq_sge;
-	/* Max recv SGEs per RWQE (NOT SUPPORTED BY HARDWARE). */
-	#define CMDQ_CREATE_QP1_RQ_SGE_MASK UINT32_C(0xf)
-	#define CMDQ_CREATE_QP1_RQ_SGE_SFT 0
-	/* Offset of First WQE in the first RQ page, in 128 byte units */
-	#define CMDQ_CREATE_QP1_RQ_FWO_MASK UINT32_C(0xfff0)
-	#define CMDQ_CREATE_QP1_RQ_FWO_SFT 4
-	/* Send CQ context id. */
-	uint32_t	scq_cid;
-	/* Receive CQ context id. */
-	uint32_t	rcq_cid;
-	/* SRQ CQ context id. */
-	uint32_t	srq_cid;
-	/* Protection domain id. */
-	uint32_t	pd_id;
-	/* SQ PBL physical address. */
-	uint64_t	sq_pbl;
-	/* RQ PBL physical address. */
-	uint64_t	rq_pbl;
-} cmdq_create_qp1_t, *pcmdq_create_qp1_t;
+	#define SQ_BIND_V3_ZERO_BASED	UINT32_C(0x40)
+	/*
+	 * If type1 is specified, then this WQE performs a "bind memory
+	 * window" operation on a type1 window. If type2 is specified, then
+	 * this WQE performs a "post send bind memory window" operation on a
+	 * type2 window.
+	 *
+	 * Note that the bind WQE cannot change the type of the memory
+	 * window.
+	 *
+	 * If a "bind memory window" operation is attempted on a memory
+	 * window that was allocated as type2, then the bind will fail with
+	 * an errored completion, as "bind memory window" is allowed only on
+	 * type1 memory windows.
+	 *
+	 * Similarly, if a "post send bind memory window" operation is
+	 * attempted on a memory window that was allocated as type1, then the
+	 * bind will fail with an errored completions, as "post send bind
+	 * memory window" is allowed only on type2 memory windows.
+	 */
+	#define SQ_BIND_V3_MW_TYPE	UINT32_C(0x80)
+	/* Type 1 Bind Memory Window */
+		#define SQ_BIND_V3__TYPE1	(UINT32_C(0x0) << 7)
+	/* Type 2 Post Send Bind Memory Window */
+		#define SQ_BIND_V3__TYPE2	(UINT32_C(0x1) << 7)
+		#define SQ_BIND_V3__LAST	SQ_BIND_V3__TYPE2
+	/*
+	 * This is the new access control for the MR. '1' means
+	 * the operation is allowed. '0' means operation is
+	 * not allowed.
+	 */
+	uint8_t	access_cntl;
+	/*
+	 * Local Write Access.
+	 *
+	 * Local accesses are never allowed for memory windows, so this
+	 * bit must always be zero in a bind WQE. If this bit is ever
+	 * set, the bind will fail with an errored completion.
+	 */
+	#define SQ_BIND_V3_ACCESS_CNTL_LOCAL_WRITE	UINT32_C(0x1)
+	/* Remote Read Access */
+	#define SQ_BIND_V3_ACCESS_CNTL_REMOTE_READ	UINT32_C(0x2)
+	/*
+	 * Remote Write Access.
+	 *
+	 * Note that, if this bit is set, then the parent region to which
+	 * the window is being bound must allow local writes. If this is not
+	 * the case, then the bind will fail with an errored completion.
+	 */
+	#define SQ_BIND_V3_ACCESS_CNTL_REMOTE_WRITE	UINT32_C(0x4)
+	/*
+	 * Remote Atomic Access.
+	 *
+	 * Note that, if this bit is set, then the parent region to which
+	 * the window is being bound must allow local writes. If this is not
+	 * the case, then the bind will fail with an errored completion.
+	 */
+	#define SQ_BIND_V3_ACCESS_CNTL_REMOTE_ATOMIC	UINT32_C(0x8)
+	/*
+	 * Window Binding Allowed.
+	 *
+	 * It is never allowed to bind windows to windows, so this bit
+	 * must always be zero in a bind WQE. If this bit is ever set,
+	 * the bind will fail with an errored completion.
+	 */
+	#define SQ_BIND_V3_ACCESS_CNTL_WINDOW_BIND	UINT32_C(0x10)
+	/*
+	 * This value will be returned in the completion if the completion is
+	 * signaled.
+	 */
+	uint32_t	opaque;
+	/*
+	 * The L_Key of the parent MR; 24 msb of the key are used to
+	 * index the MRW table, 8 lsb are compared with the 8 bit key
+	 * in the MRWC.
+	 */
+	uint32_t	parent_l_key;
+	/*
+	 * Local Key; 24 msb of the key are used to index the memory
+	 * window being bound in the MRW table, 8 lsb are assign to the
+	 * 8 bit key_lsb field in the MRWC.
+	 */
+	uint32_t	l_key;
+	/* Local Virtual Address */
+	uint64_t	va;
+	/*
+	 * Length in bytes of registered MW; 40 bits as this is the max
+	 * size of an MR/W
+	 */
+	uint64_t	length;
+} sq_bind_v3_t, *psq_bind_v3_t;
 
-/* creq_create_qp1_resp (size:128b/16B) */
+/*
+ * SQ Bind WQE V3 header. This WQE can perform either:
+ * * type1 "bind memory window", if mw_type==Type1
+ * * type2 "post send bind memory window", if mw_type==Type2
+ */
+/* sq_bind_hdr_v3 (size:256b/32B) */
 
-typedef struct creq_create_qp1_resp {
-	uint8_t	type;
+typedef struct sq_bind_hdr_v3 {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * Memory Bind V3
+	 *
+	 * Allowed only on reliable connection (RC) SQs.
 	 */
-	#define CREQ_CREATE_QP1_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_CREATE_QP1_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_CREATE_QP1_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_CREATE_QP1_RESP_TYPE_LAST	CREQ_CREATE_QP1_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* QP1 context id */
-	uint32_t	xid;
-	uint8_t	v;
+	#define SQ_BIND_HDR_V3_WQE_TYPE_BIND_V3 UINT32_C(0x1c)
+	#define SQ_BIND_HDR_V3_WQE_TYPE_LAST   SQ_BIND_HDR_V3_WQE_TYPE_BIND_V3
+	uint8_t	flags;
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * Set if completion signaling is requested. If this bit is
+	 * 0, and the SQ is configured to support Unsignaled
+	 * completion the controller should not generate a CQE
+	 * unless there was an error. This refers to CQE on the
+	 * sender side (The se flag refers to the receiver side).
 	 */
-	#define CREQ_CREATE_QP1_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Create QP1 command response. */
-	#define CREQ_CREATE_QP1_RESP_EVENT_CREATE_QP1 UINT32_C(0x13)
-	#define CREQ_CREATE_QP1_RESP_EVENT_LAST	CREQ_CREATE_QP1_RESP_EVENT_CREATE_QP1
-	uint8_t	reserved48[6];
-} creq_create_qp1_resp_t, *pcreq_create_qp1_resp_t;
-
-/***************
- * destroy_qp1 *
- ***************/
-
-
-/* cmdq_destroy_qp1 (size:192b/24B) */
-
-typedef struct cmdq_destroy_qp1 {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Destroy QP1 command deletes and flushes the specified QP1. */
-	#define CMDQ_DESTROY_QP1_OPCODE_DESTROY_QP1 UINT32_C(0x14)
-	#define CMDQ_DESTROY_QP1_OPCODE_LAST	CMDQ_DESTROY_QP1_OPCODE_DESTROY_QP1
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	/* QP1 context id */
-	uint32_t	qp1_cid;
-	uint32_t	unused_0;
-} cmdq_destroy_qp1_t, *pcmdq_destroy_qp1_t;
+	#define SQ_BIND_HDR_V3_FLAGS_SIGNAL_COMP		UINT32_C(0x1)
+	/*
+	 * Indication to complete all previous RDMA Read or Atomic
+	 * WQEs on the SQ before executing this WQE
+	 */
+	#define SQ_BIND_HDR_V3_FLAGS_RD_OR_ATOMIC_FENCE	UINT32_C(0x2)
+	/*
+	 * Unconditional fence. Indication to complete all previous
+	 * SQ's WQEs before executing this WQE.
+	 */
+	#define SQ_BIND_HDR_V3_FLAGS_UC_FENCE		UINT32_C(0x4)
+	/*
+	 * This flag is not applicable and should be 0 for a local memory
+	 * operation WQE.
+	 */
+	#define SQ_BIND_HDR_V3_FLAGS_SE			UINT32_C(0x8)
+	/*
+	 * This flag is not applicable and should be 0 for a local memory
+	 * operation WQE.
+	 */
+	#define SQ_BIND_HDR_V3_FLAGS_INLINE		UINT32_C(0x10)
+	/*
+	 * This flag is not applicable and should be 0 for a local memory
+	 * operation WQE.
+	 */
+	#define SQ_BIND_HDR_V3_FLAGS_WQE_TS_EN		UINT32_C(0x20)
+	/*
+	 * When set to '1', this operation will cause a trace capture in
+	 * each block it passes through.
+	 */
+	#define SQ_BIND_HDR_V3_FLAGS_DEBUG_TRACE		UINT32_C(0x40)
+	uint8_t	wqe_size_zero_based_mw_type;
+	/*
+	 * The size of the WQE in units of 16B chunks.
+	 *
+	 * For the Bind WQE, this field will always have a value of 2.
+	 */
+	#define SQ_BIND_HDR_V3_WQE_SIZE_MASK  UINT32_C(0x3f)
+	#define SQ_BIND_HDR_V3_WQE_SIZE_SFT   0
+	/*
+	 * If this bit is set, then the newly-bound memory window will be
+	 * zero-based. If clear, then the newly-bound memory window will be
+	 * non-zero-based.
+	 */
+	#define SQ_BIND_HDR_V3_ZERO_BASED	UINT32_C(0x40)
+	/*
+	 * If type1 is specified, then this WQE performs a "bind memory
+	 * window" operation on a type1 window. If type2 is specified, then
+	 * this WQE performs a "post send bind memory window" operation on a
+	 * type2 window.
+	 *
+	 * Note that the bind WQE cannot change the type of the memory
+	 * window.
+	 *
+	 * If a "bind memory window" operation is attempted on a memory
+	 * window that was allocated as type2, then the bind will fail with
+	 * an errored completion, as "bind memory window" is allowed only on
+	 * type1 memory windows.
+	 *
+	 * Similarly, if a "post send bind memory window" operation is
+	 * attempted on a memory window that was allocated as type1, then the
+	 * bind will fail with an errored completions, as "post send bind
+	 * memory window" is allowed only on type2 memory windows.
+	 */
+	#define SQ_BIND_HDR_V3_MW_TYPE	UINT32_C(0x80)
+	/* Type 1 Bind Memory Window */
+		#define SQ_BIND_HDR_V3__TYPE1	(UINT32_C(0x0) << 7)
+	/* Type 2 Post Send Bind Memory Window */
+		#define SQ_BIND_HDR_V3__TYPE2	(UINT32_C(0x1) << 7)
+		#define SQ_BIND_HDR_V3__LAST	SQ_BIND_HDR_V3__TYPE2
+	/*
+	 * This is the new access control for the MR. '1' means
+	 * the operation is allowed. '0' means operation is
+	 * not allowed.
+	 */
+	uint8_t	access_cntl;
+	/*
+	 * Local Write Access.
+	 *
+	 * Local accesses are never allowed for memory windows, so this
+	 * bit must always be zero in a bind WQE. If this bit is ever
+	 * set, the bind will fail with an errored completion.
+	 */
+	#define SQ_BIND_HDR_V3_ACCESS_CNTL_LOCAL_WRITE	UINT32_C(0x1)
+	/* Remote Read Access */
+	#define SQ_BIND_HDR_V3_ACCESS_CNTL_REMOTE_READ	UINT32_C(0x2)
+	/*
+	 * Remote Write Access.
+	 *
+	 * Note that, if this bit is set, then the parent region to which
+	 * the window is being bound must allow local writes. If this is not
+	 * the case, then the bind will fail with an errored completion.
+	 */
+	#define SQ_BIND_HDR_V3_ACCESS_CNTL_REMOTE_WRITE	UINT32_C(0x4)
+	/*
+	 * Remote Atomic Access.
+	 *
+	 * Note that, if this bit is set, then the parent region to which
+	 * the window is being bound must allow local writes. If this is not
+	 * the case, then the bind will fail with an errored completion.
+	 */
+	#define SQ_BIND_HDR_V3_ACCESS_CNTL_REMOTE_ATOMIC	UINT32_C(0x8)
+	/*
+	 * Window Binding Allowed.
+	 *
+	 * It is never allowed to bind windows to windows, so this bit
+	 * must always be zero in a bind WQE. If this bit is ever set,
+	 * the bind will fail with an errored completion.
+	 */
+	#define SQ_BIND_HDR_V3_ACCESS_CNTL_WINDOW_BIND	UINT32_C(0x10)
+	/*
+	 * This value will be returned in the completion if the completion is
+	 * signaled.
+	 */
+	uint32_t	opaque;
+	/*
+	 * The L_Key of the parent MR; 24 msb of the key are used to
+	 * index the MRW table, 8 lsb are compared with the 8 bit key
+	 * in the MRWC.
+	 */
+	uint32_t	parent_l_key;
+	/*
+	 * Local Key; 24 msb of the key are used to index the memory
+	 * window being bound in the MRW table, 8 lsb are assign to the
+	 * 8 bit key_lsb field in the MRWC.
+	 */
+	uint32_t	l_key;
+	/* Local Virtual Address */
+	uint64_t	va;
+	/*
+	 * Length in bytes of registered MW; 40 bits as this is the max
+	 * size of an MR/W
+	 */
+	uint64_t	length;
+} sq_bind_hdr_v3_t, *psq_bind_hdr_v3_t;
 
-/* creq_destroy_qp1_resp (size:128b/16B) */
+/*
+ * This is the Change UDP Source Port WQE V3 structure. It is supported
+ * for both RC and UD QP's.
+ *
+ * It is recommended to set the uc_fence flag for this WQE, so that the
+ * source port does not change while there are unacknowledged packets.
+ */
+/* sq_change_udpsrcport_v3 (size:128b/16B) */
 
-typedef struct creq_destroy_qp1_resp {
-	uint8_t	type;
+typedef struct sq_change_udpsrcport_v3 {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
+	/* Change UDP Source Port V3 */
+	#define SQ_CHANGE_UDPSRCPORT_V3_WQE_TYPE_CHANGE_UDPSRCPORT_V3 UINT32_C(0x1e)
+	#define SQ_CHANGE_UDPSRCPORT_V3_WQE_TYPE_LAST		SQ_CHANGE_UDPSRCPORT_V3_WQE_TYPE_CHANGE_UDPSRCPORT_V3
+	uint8_t	flags;
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * Set if completion signaling is requested. If this bit is
+	 * 0, and the SQ is configured to support Unsignaled
+	 * completion the controller should not generate a CQE
+	 * unless there was an error. This refers to CQE on the
+	 * sender side (The se flag refers to the receiver side).
 	 */
-	#define CREQ_DESTROY_QP1_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_DESTROY_QP1_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_DESTROY_QP1_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_DESTROY_QP1_RESP_TYPE_LAST	CREQ_DESTROY_QP1_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* QP1 context id */
-	uint32_t	xid;
-	uint8_t	v;
+	#define SQ_CHANGE_UDPSRCPORT_V3_FLAGS_SIGNAL_COMP		UINT32_C(0x1)
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * Indication to complete all previous RDMA Read or Atomic
+	 * WQEs on the SQ before executing this WQE
 	 */
-	#define CREQ_DESTROY_QP1_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Destroy QP1 command response. */
-	#define CREQ_DESTROY_QP1_RESP_EVENT_DESTROY_QP1 UINT32_C(0x14)
-	#define CREQ_DESTROY_QP1_RESP_EVENT_LAST	CREQ_DESTROY_QP1_RESP_EVENT_DESTROY_QP1
-	uint8_t	reserved48[6];
-} creq_destroy_qp1_resp_t, *pcreq_destroy_qp1_resp_t;
+	#define SQ_CHANGE_UDPSRCPORT_V3_FLAGS_RD_OR_ATOMIC_FENCE	UINT32_C(0x2)
+	/*
+	 * Unconditional fence. Indication to complete all previous
+	 * SQ's WQEs before executing this WQE.
+	 *
+	 * It is recommended to set this flag for Change UDP Source Port
+	 * WQE's.
+	 */
+	#define SQ_CHANGE_UDPSRCPORT_V3_FLAGS_UC_FENCE		UINT32_C(0x4)
+	/*
+	 * This flag is not applicable and should be 0 for a local memory
+	 * operation WQE.
+	 */
+	#define SQ_CHANGE_UDPSRCPORT_V3_FLAGS_SE			UINT32_C(0x8)
+	/*
+	 * This flag is not applicable and should be 0 for a local memory
+	 * operation WQE.
+	 */
+	#define SQ_CHANGE_UDPSRCPORT_V3_FLAGS_INLINE		UINT32_C(0x10)
+	/*
+	 * This flag is not applicable and should be 0 for a local memory
+	 * operation WQE.
+	 */
+	#define SQ_CHANGE_UDPSRCPORT_V3_FLAGS_WQE_TS_EN		UINT32_C(0x20)
+	/*
+	 * When set to '1', this operation will cause a trace capture in
+	 * each block it passes through.
+	 */
+	#define SQ_CHANGE_UDPSRCPORT_V3_FLAGS_DEBUG_TRACE		UINT32_C(0x40)
+	uint8_t	wqe_size;
+	/*
+	 * The size of the WQE in units of 16B chunks.
+	 *
+	 * For the Change UDP Source Port WQE, this field will always have
+	 * a value of 1.
+	 */
+	#define SQ_CHANGE_UDPSRCPORT_V3_WQE_SIZE_MASK UINT32_C(0x3f)
+	#define SQ_CHANGE_UDPSRCPORT_V3_WQE_SIZE_SFT 0
+	uint8_t	reserved_1;
+	/*
+	 * This value will be returned in the completion if the completion is
+	 * signaled.
+	 */
+	uint32_t	opaque;
+	/* The new value for the QP's UDP source port. */
+	uint16_t	udp_src_port;
+	uint16_t	reserved_2;
+	uint32_t	reserved_3;
+} sq_change_udpsrcport_v3_t, *psq_change_udpsrcport_v3_t;
 
-/*************
- * create_ah *
- *************/
+/* SQ Change UDP Source Port WQE V3 header */
+/* sq_change_udpsrcport_hdr_v3 (size:128b/16B) */
 
+typedef struct sq_change_udpsrcport_hdr_v3 {
+	/* This field defines the type of SQ WQE. */
+	uint8_t	wqe_type;
+	/* Change UDP Source Port V3 */
+	#define SQ_CHANGE_UDPSRCPORT_HDR_V3_WQE_TYPE_CHANGE_UDPSRCPORT_V3 UINT32_C(0x1e)
+	#define SQ_CHANGE_UDPSRCPORT_HDR_V3_WQE_TYPE_LAST		SQ_CHANGE_UDPSRCPORT_HDR_V3_WQE_TYPE_CHANGE_UDPSRCPORT_V3
+	uint8_t	flags;
+	/*
+	 * Set if completion signaling is requested. If this bit is
+	 * 0, and the SQ is configured to support Unsignaled
+	 * completion the controller should not generate a CQE
+	 * unless there was an error. This refers to CQE on the
+	 * sender side (The se flag refers to the receiver side).
+	 */
+	#define SQ_CHANGE_UDPSRCPORT_HDR_V3_FLAGS_SIGNAL_COMP		UINT32_C(0x1)
+	/*
+	 * Indication to complete all previous RDMA Read or Atomic
+	 * WQEs on the SQ before executing this WQE
+	 */
+	#define SQ_CHANGE_UDPSRCPORT_HDR_V3_FLAGS_RD_OR_ATOMIC_FENCE	UINT32_C(0x2)
+	/*
+	 * Unconditional fence. Indication to complete all previous
+	 * SQ's WQEs before executing this WQE.
+	 *
+	 * It is recommended to set this flag for Change UDP Source Port
+	 * WQE's.
+	 */
+	#define SQ_CHANGE_UDPSRCPORT_HDR_V3_FLAGS_UC_FENCE		UINT32_C(0x4)
+	/*
+	 * This flag is not applicable and should be 0 for a local memory
+	 * operation WQE.
+	 */
+	#define SQ_CHANGE_UDPSRCPORT_HDR_V3_FLAGS_SE			UINT32_C(0x8)
+	/*
+	 * This flag is not applicable and should be 0 for a local memory
+	 * operation WQE.
+	 */
+	#define SQ_CHANGE_UDPSRCPORT_HDR_V3_FLAGS_INLINE		UINT32_C(0x10)
+	/*
+	 * This flag is not applicable and should be 0 for a local memory
+	 * operation WQE.
+	 */
+	#define SQ_CHANGE_UDPSRCPORT_HDR_V3_FLAGS_WQE_TS_EN		UINT32_C(0x20)
+	/*
+	 * When set to '1', this operation will cause a trace capture in
+	 * each block it passes through.
+	 */
+	#define SQ_CHANGE_UDPSRCPORT_HDR_V3_FLAGS_DEBUG_TRACE		UINT32_C(0x40)
+	uint8_t	wqe_size;
+	/*
+	 * The size of the WQE in units of 16B chunks.
+	 *
+	 * For the Change UDP Source Port WQE, this field will always have
+	 * a value of 1.
+	 */
+	#define SQ_CHANGE_UDPSRCPORT_HDR_V3_WQE_SIZE_MASK UINT32_C(0x3f)
+	#define SQ_CHANGE_UDPSRCPORT_HDR_V3_WQE_SIZE_SFT 0
+	uint8_t	reserved_1;
+	/*
+	 * This value will be returned in the completion if the completion is
+	 * signaled.
+	 */
+	uint32_t	opaque;
+	/* The new value for the QP's UDP source port. */
+	uint16_t	udp_src_port;
+	uint16_t	reserved_2;
+	uint32_t	reserved_3;
+} sq_change_udpsrcport_hdr_v3_t, *psq_change_udpsrcport_hdr_v3_t;
 
-/* cmdq_create_ah (size:512b/64B) */
+/* RQ/SRQ WQE */
+/* rq_wqe (size:1024b/128B) */
 
-typedef struct cmdq_create_ah {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Create AH command allocates an AH with the specified parameters. */
-	#define CMDQ_CREATE_AH_OPCODE_CREATE_AH UINT32_C(0x15)
-	#define CMDQ_CREATE_AH_OPCODE_LAST	CMDQ_CREATE_AH_OPCODE_CREATE_AH
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
+typedef struct rq_wqe {
+	/* wqe_type is 8 b */
+	uint8_t	wqe_type;
+	/*
+	 * RQ/SRQ WQE. This WQE is used for posting buffers on
+	 * an RQ or SRQ.
+	 */
+	#define RQ_WQE_WQE_TYPE_RCV UINT32_C(0x80)
+	#define RQ_WQE_WQE_TYPE_LAST RQ_WQE_WQE_TYPE_RCV
+	/* No flags supported for this WQE type. */
+	uint8_t	flags;
+	/*
+	 * Specify the total number 16B chunks that make up the valid
+	 * portion of the WQE. This includes the first chunk that is the
+	 * WQE structure and up to 6 SGE structures.
+	 *
+	 * While the valid area is defined by the wqe_size field, the
+	 * actual WQE size is fixed at 128B.
+	 */
+	uint8_t	wqe_size;
 	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	/* AH handle. */
-	uint64_t	ah_handle;
-	/* Destination GID, specified in BE format. */
-	uint32_t	dgid[4];
-	/* V1, V2IPv4 or V2IPv6. */
-	uint8_t	type;
-	/* V2IPv4. */
-	#define CMDQ_CREATE_AH_TYPE_V1	UINT32_C(0x0)
-	/* V2IPv4. */
-	#define CMDQ_CREATE_AH_TYPE_V2IPV4 UINT32_C(0x2)
-	/* V2IPv6. */
-	#define CMDQ_CREATE_AH_TYPE_V2IPV6 UINT32_C(0x3)
-	#define CMDQ_CREATE_AH_TYPE_LAST  CMDQ_CREATE_AH_TYPE_V2IPV6
-	/* IPv6 Hop limit. */
-	uint8_t	hop_limit;
-	/* SGID index. */
-	uint16_t	sgid_index;
-	uint32_t	dest_vlan_id_flow_label;
-	/* Flow label. */
-	#define CMDQ_CREATE_AH_FLOW_LABEL_MASK  UINT32_C(0xfffff)
-	#define CMDQ_CREATE_AH_FLOW_LABEL_SFT   0
-	/* Destination VLAN ID. */
-	#define CMDQ_CREATE_AH_DEST_VLAN_ID_MASK UINT32_C(0xfff00000)
-	#define CMDQ_CREATE_AH_DEST_VLAN_ID_SFT 20
-	/* Protection domain id. */
-	uint32_t	pd_id;
-	uint32_t	unused_0;
-	/* Destination MAC address. */
-	uint16_t	dest_mac[3];
-	/* Traffic class. */
-	uint8_t	traffic_class;
-	uint8_t	enable_cc;
-	/* Enable congestion control. */
-	#define CMDQ_CREATE_AH_ENABLE_CC	UINT32_C(0x1)
-} cmdq_create_ah_t, *pcmdq_create_ah_t;
+	uint32_t	reserved32;
+	uint64_t	wr_id;
+	/*
+	 * Opaque value used by upper layer SW to identify the id of the
+	 * WR which generated the WQE. Used in CQE. Valid in the first
+	 * SGE of an SRQ WQE.
+	 */
+	#define RQ_WQE_WR_ID_MASK UINT32_C(0xfffff)
+	#define RQ_WQE_WR_ID_SFT 0
+	uint8_t	reserved128[16];
+	/*
+	 * The data field for RQ WQE is filled with from 1 to 6 SGE
+	 * structures as defined by the wqe_size field.
+	 */
+	uint32_t	data[24];
+} rq_wqe_t, *prq_wqe_t;
 
-/* creq_create_ah_resp (size:128b/16B) */
+/* RQ/SRQ WQE header. */
+/* rq_wqe_hdr (size:256b/32B) */
 
-typedef struct creq_create_ah_resp {
-	uint8_t	type;
+typedef struct rq_wqe_hdr {
+	/* wqe_type is 8 b */
+	uint8_t	wqe_type;
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * RQ/SRQ WQE. This WQE is used for posting buffers on
+	 * an RQ or SRQ.
 	 */
-	#define CREQ_CREATE_AH_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_CREATE_AH_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_CREATE_AH_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_CREATE_AH_RESP_TYPE_LAST	CREQ_CREATE_AH_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* AH context id */
-	uint32_t	xid;
-	uint8_t	v;
+	#define RQ_WQE_HDR_WQE_TYPE_RCV UINT32_C(0x80)
+	#define RQ_WQE_HDR_WQE_TYPE_LAST RQ_WQE_HDR_WQE_TYPE_RCV
+	/* No flags supported for this WQE type. */
+	uint8_t	flags;
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * Specify the total number 16B chunks that make up the valid
+	 * portion of the WQE. This includes the first chunk that is the
+	 * WQE structure and up to 6 SGE structures.
+	 *
+	 * While the valid area is defined by the wqe_size field, the
+	 * actual WQE size is fixed at 128B.
 	 */
-	#define CREQ_CREATE_AH_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Create AH command response. */
-	#define CREQ_CREATE_AH_RESP_EVENT_CREATE_AH UINT32_C(0x15)
-	#define CREQ_CREATE_AH_RESP_EVENT_LAST	CREQ_CREATE_AH_RESP_EVENT_CREATE_AH
-	uint8_t	reserved48[6];
-} creq_create_ah_resp_t, *pcreq_create_ah_resp_t;
+	uint8_t	wqe_size;
+	uint8_t	reserved8;
+	uint32_t	reserved32;
+	uint64_t	wr_id;
+	/*
+	 * Opaque value used by upper layer SW to identify the id of the
+	 * WR which generated the WQE. Used in CQE. Valid in the first
+	 * SGE of an SRQ WQE.
+	 */
+	#define RQ_WQE_HDR_WR_ID_MASK UINT32_C(0xfffff)
+	#define RQ_WQE_HDR_WR_ID_SFT 0
+	uint8_t	reserved128[16];
+} rq_wqe_hdr_t, *prq_wqe_hdr_t;
 
-/**************
- * destroy_ah *
- **************/
+/* RQ/SRQ WQE V3 */
+/* rq_wqe_v3 (size:4096b/512B) */
 
+typedef struct rq_wqe_v3 {
+	/* wqe_type is 8 b */
+	uint8_t	wqe_type;
+	/*
+	 * RQ/SRQ WQE V3. This WQE is used for posting buffers on
+	 * an RQ or SRQ.
+	 */
+	#define RQ_WQE_V3_WQE_TYPE_RCV_V3 UINT32_C(0x90)
+	#define RQ_WQE_V3_WQE_TYPE_LAST  RQ_WQE_V3_WQE_TYPE_RCV_V3
+	/* No flags supported for this WQE type. */
+	uint8_t	flags;
+	/*
+	 * Specify the total number 16B chunks that make up the valid portion
+	 * of the WQE. This includes the first chunk that is the WQE
+	 * structure and up to 30 SGE structures. The maximum value for this
+	 * field is 32, representing a maximum-sized WQE of 512B.
+	 */
+	uint8_t	wqe_size;
+	uint8_t	reserved1;
+	/* This value will be returned in the completion. */
+	uint32_t	opaque;
+	uint64_t	reserved2;
+	/*
+	 * The data field for RQ WQE is filled with from 1 to 30 SGE
+	 * structures as defined by the wqe_size field.
+	 */
+	uint32_t	data[124];
+} rq_wqe_v3_t, *prq_wqe_v3_t;
 
-/* cmdq_destroy_ah (size:192b/24B) */
+/* RQ/SRQ WQE V3 header. */
+/* rq_wqe_hdr_v3 (size:128b/16B) */
 
-typedef struct cmdq_destroy_ah {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Destroy AH command deletes the specified AH. */
-	#define CMDQ_DESTROY_AH_OPCODE_DESTROY_AH UINT32_C(0x16)
-	#define CMDQ_DESTROY_AH_OPCODE_LAST	CMDQ_DESTROY_AH_OPCODE_DESTROY_AH
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	/* AH context id */
-	uint32_t	ah_cid;
-	uint32_t	unused_0;
-} cmdq_destroy_ah_t, *pcmdq_destroy_ah_t;
+typedef struct rq_wqe_hdr_v3 {
+	/* wqe_type is 8 b */
+	uint8_t	wqe_type;
+	/*
+	 * RQ/SRQ WQE V3. This WQE is used for posting buffers on
+	 * an RQ or SRQ.
+	 */
+	#define RQ_WQE_HDR_V3_WQE_TYPE_RCV_V3 UINT32_C(0x90)
+	#define RQ_WQE_HDR_V3_WQE_TYPE_LAST  RQ_WQE_HDR_V3_WQE_TYPE_RCV_V3
+	/* No flags supported for this WQE type. */
+	uint8_t	flags;
+	/*
+	 * Specify the total number 16B chunks that make up the valid portion
+	 * of the WQE. This includes the first chunk that is the WQE
+	 * structure and up to 30 SGE structures. The maximum value for this
+	 * field is 32, representing a maximum-sized WQE of 512B.
+	 */
+	uint8_t	wqe_size;
+	uint8_t	reserved1;
+	/* This value will be returned in the completion. */
+	uint32_t	opaque;
+	uint64_t	reserved2;
+} rq_wqe_hdr_v3_t, *prq_wqe_hdr_v3_t;
 
-/* creq_destroy_ah_resp (size:128b/16B) */
+/* cq_base (size:256b/32B) */
 
-typedef struct creq_destroy_ah_resp {
-	uint8_t	type;
+typedef struct cq_base {
+	uint64_t	reserved64_1;
+	uint64_t	reserved64_2;
+	uint64_t	reserved64_3;
+	uint8_t	cqe_type_toggle;
+	/*
+	 * Indicate valid completion - written by the chip. The NIC
+	 * toggle this bit each time it finished consuming all PBL
+	 * entries.
+	 */
+	#define CQ_BASE_TOGGLE			UINT32_C(0x1)
+	/* This field defines the type of CQE. */
+	#define CQ_BASE_CQE_TYPE_MASK		UINT32_C(0x1e)
+	#define CQ_BASE_CQE_TYPE_SFT		1
+	/*
+	 * Requester completion - This is used for both RC and UD SQ
+	 * completions.
+	 */
+		#define CQ_BASE_CQE_TYPE_REQ		(UINT32_C(0x0) << 1)
+	/*
+	 * Responder RC Completion - This is used for both RQ and SRQ
+	 * completions for RC service QPs.
+	 */
+		#define CQ_BASE_CQE_TYPE_RES_RC		(UINT32_C(0x1) << 1)
+	/*
+	 * Responder UD Completion - This is used for both RQ and SRQ
+	 * completion for UD service QPs.
+	 */
+		#define CQ_BASE_CQE_TYPE_RES_UD		(UINT32_C(0x2) << 1)
+	/*
+	 * Responder RawEth and QP1 Completion - This is used for RQ
+	 * completion for RawEth service and QP1 service QPs.
+	 */
+		#define CQ_BASE_CQE_TYPE_RES_RAWETH_QP1	(UINT32_C(0x3) << 1)
+	/*
+	 * Responder UD completion with CFA. This is used for both RQ
+	 * and SQ completion for UD service QPs. It includes cfa fields
+	 * (some of which carry VLAN information), in place of QP handle.
+	 */
+		#define CQ_BASE_CQE_TYPE_RES_UD_CFA	(UINT32_C(0x4) << 1)
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * Requester completion V3 - This is used for both RC and UD SQ
+	 * completions.
 	 */
-	#define CREQ_DESTROY_AH_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_DESTROY_AH_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_DESTROY_AH_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_DESTROY_AH_RESP_TYPE_LAST	CREQ_DESTROY_AH_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* AH context id */
-	uint32_t	xid;
-	uint8_t	v;
+		#define CQ_BASE_CQE_TYPE_REQ_V3		(UINT32_C(0x8) << 1)
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * Responder RC Completion V3 - This is used for both RQ and SRQ
+	 * completions for RC service QPs.
 	 */
-	#define CREQ_DESTROY_AH_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Destroy AH command response. */
-	#define CREQ_DESTROY_AH_RESP_EVENT_DESTROY_AH UINT32_C(0x16)
-	#define CREQ_DESTROY_AH_RESP_EVENT_LAST	CREQ_DESTROY_AH_RESP_EVENT_DESTROY_AH
-	uint8_t	reserved48[6];
-} creq_destroy_ah_resp_t, *pcreq_destroy_ah_resp_t;
-
-/********************
- * query_roce_stats *
- ********************/
-
-
-/* cmdq_query_roce_stats (size:192b/24B) */
-
-typedef struct cmdq_query_roce_stats {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Query RoCE statistics. */
-	#define CMDQ_QUERY_ROCE_STATS_OPCODE_QUERY_ROCE_STATS UINT32_C(0x8e)
-	#define CMDQ_QUERY_ROCE_STATS_OPCODE_LAST		CMDQ_QUERY_ROCE_STATS_OPCODE_QUERY_ROCE_STATS
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
+		#define CQ_BASE_CQE_TYPE_RES_RC_V3	(UINT32_C(0x9) << 1)
 	/*
-	 * When this bit is set FW will use the collection_id to extract RoCE statistics.
-	 * If function_id is also specified the FW will return stats corresponding to the
-	 * collection for the function_id specified.
+	 * Responder UD Completion V3 - This is used for both RQ and SRQ
+	 * completion for UD service QPs. It is also used for QP1 QPs
+	 * that are treated as UD.
 	 */
-	#define CMDQ_QUERY_ROCE_STATS_FLAGS_COLLECTION_ID	UINT32_C(0x1)
+		#define CQ_BASE_CQE_TYPE_RES_UD_V3	(UINT32_C(0xa) << 1)
 	/*
-	 * When this bit is set FW will use the function_id to extract RoCE statistics.
-	 * When collection is specified then FW will return the specific collection
-	 * stats and if the collection is not specified then FW will return the default
-	 * stats which will be for all QPs.
+	 * Responder RawEth and QP1 Completion V3 - This is used for RQ and
+	 * SRQ completion for RawEth service. It is also used for QP1 QPs
+	 * that are treated as RawEth.
 	 */
-	#define CMDQ_QUERY_ROCE_STATS_FLAGS_FUNCTION_ID	UINT32_C(0x2)
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	/* The specific statistics group being queried. */
-	uint8_t	collection_id;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	/* Unique identifier for a function */
-	uint32_t	function_id;
-	/* PF number */
-	#define CMDQ_QUERY_ROCE_STATS_PF_NUM_MASK  UINT32_C(0xff)
-	#define CMDQ_QUERY_ROCE_STATS_PF_NUM_SFT   0
-	/* VF number */
-	#define CMDQ_QUERY_ROCE_STATS_VF_NUM_MASK  UINT32_C(0xffff00)
-	#define CMDQ_QUERY_ROCE_STATS_VF_NUM_SFT   8
-	/* When set the vf_num is valid. */
-	#define CMDQ_QUERY_ROCE_STATS_VF_VALID	UINT32_C(0x1000000)
-	uint32_t	reserved32;
-} cmdq_query_roce_stats_t, *pcmdq_query_roce_stats_t;
-
-/* creq_query_roce_stats_resp (size:128b/16B) */
-
-typedef struct creq_query_roce_stats_resp {
-	uint8_t	type;
+		#define CQ_BASE_CQE_TYPE_RES_RAWETH_QP1_V3  (UINT32_C(0xb) << 1)
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * Responder UD Completion with CFA V3 - This is used for both RQ
+	 * and SRQ completion for UD service QPs. It includes CFA fields
+	 * (some of which carry VLAN information), in place of the QP
+	 * handle. It is also used for QP1 QPs that are treated as UD.
 	 */
-	#define CREQ_QUERY_ROCE_STATS_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_QUERY_ROCE_STATS_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_QUERY_ROCE_STATS_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_QUERY_ROCE_STATS_RESP_TYPE_LAST	CREQ_QUERY_ROCE_STATS_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Side buffer size in 16-byte units */
-	uint32_t	size;
-	uint8_t	v;
+		#define CQ_BASE_CQE_TYPE_RES_UD_CFA_V3	(UINT32_C(0xc) << 1)
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * NO_OP completion - This is used to indicate that no
+	 * operation completed.
 	 */
-	#define CREQ_QUERY_ROCE_STATS_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Query RoCE statistics. */
-	#define CREQ_QUERY_ROCE_STATS_RESP_EVENT_QUERY_ROCE_STATS UINT32_C(0x8e)
-	#define CREQ_QUERY_ROCE_STATS_RESP_EVENT_LAST		CREQ_QUERY_ROCE_STATS_RESP_EVENT_QUERY_ROCE_STATS
-	uint8_t	reserved48[6];
-} creq_query_roce_stats_resp_t, *pcreq_query_roce_stats_resp_t;
-
-/* Query RoCE Stats command response side buffer structure. */
-/* creq_query_roce_stats_resp_sb (size:2944b/368B) */
-
-typedef struct creq_query_roce_stats_resp_sb {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Query RoCE statistics. */
-	#define CREQ_QUERY_ROCE_STATS_RESP_SB_OPCODE_QUERY_ROCE_STATS UINT32_C(0x8e)
-	#define CREQ_QUERY_ROCE_STATS_RESP_SB_OPCODE_LAST		CREQ_QUERY_ROCE_STATS_RESP_SB_OPCODE_QUERY_ROCE_STATS
-	/* Status of the response. */
+		#define CQ_BASE_CQE_TYPE_NO_OP		(UINT32_C(0xd) << 1)
+	/*
+	 * Terminal completion - This is used to indicate that no
+	 * further completions will be made for this QP on this CQ.
+	 */
+		#define CQ_BASE_CQE_TYPE_TERMINAL	(UINT32_C(0xe) << 1)
+	/*
+	 * Cut off CQE; for CQ resize. This CQE is written to the "old"
+	 * CQ as the last CQE written. SW may use this to know when the
+	 * "old" CQ can be destroyed.
+	 */
+		#define CQ_BASE_CQE_TYPE_CUT_OFF		(UINT32_C(0xf) << 1)
+		#define CQ_BASE_CQE_TYPE_LAST		CQ_BASE_CQE_TYPE_CUT_OFF
+	/* This field indicates the status for the CQE. */
 	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	rsvd;
-	uint32_t	num_counters;
-	uint32_t	rsvd1;
-	uint64_t	to_retransmits;
-	/* seq_err_naks_rcvd is 64 b */
-	uint64_t	seq_err_naks_rcvd;
-	/* max_retry_exceeded is 64 b */
-	uint64_t	max_retry_exceeded;
-	/* rnr_naks_rcvd is 64 b */
-	uint64_t	rnr_naks_rcvd;
-	uint64_t	missing_resp;
-	/* unrecoverable_err is 64 b */
-	uint64_t	unrecoverable_err;
-	/* bad_resp_err is 64 b */
-	uint64_t	bad_resp_err;
-	/* local_qp_op_err is 64 b */
-	uint64_t	local_qp_op_err;
-	/* local_protection_err is 64 b */
-	uint64_t	local_protection_err;
-	/* mem_mgmt_op_err is 64 b */
-	uint64_t	mem_mgmt_op_err;
-	/* remote_invalid_req_err is 64 b */
-	uint64_t	remote_invalid_req_err;
-	/* remote_access_err is 64 b */
-	uint64_t	remote_access_err;
-	/* remote_op_err is 64 b */
-	uint64_t	remote_op_err;
-	/* dup_req is 64 b */
-	uint64_t	dup_req;
-	/* res_exceed_max is 64 b */
-	uint64_t	res_exceed_max;
-	/* res_length_mismatch is 64 b */
-	uint64_t	res_length_mismatch;
-	/* res_exceeds_wqe is 64 b */
-	uint64_t	res_exceeds_wqe;
-	/* res_opcode_err is 64 b */
-	uint64_t	res_opcode_err;
-	/* res_rx_invalid_rkey is 64 b */
-	uint64_t	res_rx_invalid_rkey;
-	/* res_rx_domain_err is 64 b */
-	uint64_t	res_rx_domain_err;
-	/* res_rx_no_perm is 64 b */
-	uint64_t	res_rx_no_perm;
-	/* res_rx_range_err is 64 b */
-	uint64_t	res_rx_range_err;
-	/* res_tx_invalid_rkey is 64 b */
-	uint64_t	res_tx_invalid_rkey;
-	/* res_tx_domain_err is 64 b */
-	uint64_t	res_tx_domain_err;
-	/* res_tx_no_perm is 64 b */
-	uint64_t	res_tx_no_perm;
-	/* res_tx_range_err is 64 b */
-	uint64_t	res_tx_range_err;
-	/* res_irrq_oflow is 64 b */
-	uint64_t	res_irrq_oflow;
-	/* res_unsup_opcode is 64 b */
-	uint64_t	res_unsup_opcode;
-	/* res_unaligned_atomic is 64 b */
-	uint64_t	res_unaligned_atomic;
-	/* res_rem_inv_err is 64 b */
-	uint64_t	res_rem_inv_err;
-	/* res_mem_error is 64 b */
-	uint64_t	res_mem_error;
-	/* res_srq_err is 64 b */
-	uint64_t	res_srq_err;
-	/* res_cmp_err is 64 b */
-	uint64_t	res_cmp_err;
-	/* res_invalid_dup_rkey is 64 b */
-	uint64_t	res_invalid_dup_rkey;
-	/* res_wqe_format_err is 64 b */
-	uint64_t	res_wqe_format_err;
-	/* res_cq_load_err is 64 b */
-	uint64_t	res_cq_load_err;
-	/* res_srq_load_err is 64 b */
-	uint64_t	res_srq_load_err;
-	/* res_tx_pci_err is 64 b */
-	uint64_t	res_tx_pci_err;
-	/* res_rx_pci_err is 64 b */
-	uint64_t	res_rx_pci_err;
-	/* res_oos_drop_count is 64 b */
-	uint64_t	res_oos_drop_count;
-	/* active_qp_count_p0 is 64 b */
-	uint64_t	active_qp_count_p0;
-	/* active_qp_count_p1 is 64 b */
-	uint64_t	active_qp_count_p1;
-	/* active_qp_count_p2 is 64 b */
-	uint64_t	active_qp_count_p2;
-	/* active_qp_count_p3 is 64 b */
-	uint64_t	active_qp_count_p3;
-} creq_query_roce_stats_resp_sb_t, *pcreq_query_roce_stats_resp_sb_t;
-
-/************************
- * query_roce_stats_ext *
- ************************/
-
-
-/* cmdq_query_roce_stats_ext (size:192b/24B) */
-
-typedef struct cmdq_query_roce_stats_ext {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Query extended RoCE statistics. */
-	#define CMDQ_QUERY_ROCE_STATS_EXT_OPCODE_QUERY_ROCE_STATS UINT32_C(0x92)
-	#define CMDQ_QUERY_ROCE_STATS_EXT_OPCODE_LAST		CMDQ_QUERY_ROCE_STATS_EXT_OPCODE_QUERY_ROCE_STATS
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
+	/* The operation completed successfully. */
+	#define CQ_BASE_STATUS_OK			UINT32_C(0x0)
 	/*
-	 * When this bit is set FW will use the collection_id to extract RoCE statistics.
-	 * If function_id is also specified the FW will return stats corresponding to the
-	 * collection for the function_id specified.
+	 * An unexpected BTH opcode or a First/Middle packet that is not
+	 * the full MTU size was returned by the responder.
+	 *
+	 * This is a fatal error detected by the requester Rx.
 	 */
-	#define CMDQ_QUERY_ROCE_STATS_EXT_FLAGS_COLLECTION_ID	UINT32_C(0x1)
+	#define CQ_BASE_STATUS_BAD_RESPONSE_ERR	UINT32_C(0x1)
 	/*
-	 * When this bit is set FW will use the function_id to extract RoCE statistics.
-	 * When collection is specified then FW will return the specific collection
-	 * stats and if the collection is not specified then FW will return the default
-	 * stats which will be for all QPs.
+	 * Generated for a WQE posted to the local SQ when the sum of the
+	 * lengths of the SGEs in the WQE exceeds the maximum message
+	 * length of 2^31 bytes.
+	 *
+	 * Generated for a WQE posted to the local RQ/SRQ when the sum of
+	 * the lengths of the SGEs in the WQE is too small to receive the
+	 * (valid) incoming message or the length of the incoming message
+	 * is greater than the maximum message size supported.
+	 *
+	 * This is a fatal error detected by the requester Tx or responder
+	 * Rx. For responder CQEs, only the opaque field is valid.
 	 */
-	#define CMDQ_QUERY_ROCE_STATS_EXT_FLAGS_FUNCTION_ID	UINT32_C(0x2)
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	/* The specific statistics group being queried. */
-	uint8_t	collection_id;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	/* Unique identifier for a function */
-	uint32_t	function_id;
-	/* PF number */
-	#define CMDQ_QUERY_ROCE_STATS_EXT_PF_NUM_MASK  UINT32_C(0xff)
-	#define CMDQ_QUERY_ROCE_STATS_EXT_PF_NUM_SFT   0
-	/* VF number */
-	#define CMDQ_QUERY_ROCE_STATS_EXT_VF_NUM_MASK  UINT32_C(0xffff00)
-	#define CMDQ_QUERY_ROCE_STATS_EXT_VF_NUM_SFT   8
-	/* When set the vf_num is valid. */
-	#define CMDQ_QUERY_ROCE_STATS_EXT_VF_VALID	UINT32_C(0x1000000)
-	uint32_t	reserved32;
-} cmdq_query_roce_stats_ext_t, *pcmdq_query_roce_stats_ext_t;
-
-/* creq_query_roce_stats_ext_resp (size:128b/16B) */
-
-typedef struct creq_query_roce_stats_ext_resp {
-	uint8_t	type;
+	#define CQ_BASE_STATUS_LOCAL_LENGTH_ERR	UINT32_C(0x2)
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * This indicates that the packet was too long for the WQE provided
+	 * on the SRQ/RQ.
+	 *
+	 * This is not a fatal error. All the fields in the CQE are valid.
 	 */
-	#define CREQ_QUERY_ROCE_STATS_EXT_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_QUERY_ROCE_STATS_EXT_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_QUERY_ROCE_STATS_EXT_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_QUERY_ROCE_STATS_EXT_RESP_TYPE_LAST	CREQ_QUERY_ROCE_STATS_EXT_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Side buffer size in 16-byte units */
-	uint32_t	size;
-	uint8_t	v;
+	#define CQ_BASE_STATUS_HW_LOCAL_LENGTH_ERR	UINT32_C(0x3)
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * An internal QP consistency error was detected while processing
+	 * this Work Request. For requester, this could be an SQ WQE format
+	 * error or an operation specified in the WQE that is not supported
+	 * for the QP. For responder, this is an RQ/SRQ WQE format error.
+	 *
+	 * This is a fatal error detected by the requester Tx or responder
+	 * Rx. For responder CQEs, only the opaque field is valid.
 	 */
-	#define CREQ_QUERY_ROCE_STATS_EXT_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Query extended RoCE statistics. */
-	#define CREQ_QUERY_ROCE_STATS_EXT_RESP_EVENT_QUERY_ROCE_STATS_EXT UINT32_C(0x92)
-	#define CREQ_QUERY_ROCE_STATS_EXT_RESP_EVENT_LAST		CREQ_QUERY_ROCE_STATS_EXT_RESP_EVENT_QUERY_ROCE_STATS_EXT
-	uint8_t	reserved48[6];
-} creq_query_roce_stats_ext_resp_t, *pcreq_query_roce_stats_ext_resp_t;
-
-/* Query extended RoCE Stats command response side buffer structure. */
-/* creq_query_roce_stats_ext_resp_sb (size:1536b/192B) */
-
-typedef struct creq_query_roce_stats_ext_resp_sb {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Query extended RoCE statistics. */
-	#define CREQ_QUERY_ROCE_STATS_EXT_RESP_SB_OPCODE_QUERY_ROCE_STATS_EXT UINT32_C(0x92)
-	#define CREQ_QUERY_ROCE_STATS_EXT_RESP_SB_OPCODE_LAST		CREQ_QUERY_ROCE_STATS_EXT_RESP_SB_OPCODE_QUERY_ROCE_STATS_EXT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	rsvd;
-	/* Number of transmitted Atomic request packets. */
-	uint64_t	tx_atomic_req_pkts;
-	/* Number of transmitted Read request packets. */
-	uint64_t	tx_read_req_pkts;
-	/* Number of transmitted Read response packets. */
-	uint64_t	tx_read_res_pkts;
-	/* Number of transmitted Write request packets. */
-	uint64_t	tx_write_req_pkts;
+	#define CQ_BASE_STATUS_LOCAL_QP_OPERATION_ERR	UINT32_C(0x4)
 	/*
-	 * Number of transmitted Send request packets.
-	 * This is for RC QPs only.
+	 * An SGE in the locally posted WQE does not reference a Memory
+	 * Region that is valid for the requested operation. If this error
+	 * is generated for an SGE using the reserved l_key, this means
+	 * that the reserved l_key is not enabled.
+	 *
+	 * This is a fatal error detected by the requester Tx or responder
+	 * Rx. For responder CQEs, only the opaque field is valid.
 	 */
-	uint64_t	tx_send_req_pkts;
+	#define CQ_BASE_STATUS_LOCAL_PROTECTION_ERR	UINT32_C(0x5)
 	/*
-	 * Number of transmitted RoCE packets.
-	 * This includes RC, UD, RawEth, and QP1 packets
+	 * A protection error occurred on a local data buffer during the
+	 * processing of a RDMA Write with Immediate Data operation sent
+	 * from the remote node.
+	 *
+	 * This is a fatal error detected by the responder Rx. Only the
+	 * opaque field in the CQE is valid.
 	 */
-	uint64_t	tx_roce_pkts;
+	#define CQ_BASE_STATUS_LOCAL_ACCESS_ERROR	UINT32_C(0x6)
 	/*
-	 * Number of transmitted RoCE header and payload bytes.
-	 * This includes RC, UD, RawEth, and QP1 packets.
+	 * The SSC detected an error on a local memory operation from the
+	 * SQ (fast-register, local invalidate, or bind).
+	 *
+	 * This is a fatal error detected by the requester Tx.
 	 */
-	uint64_t	tx_roce_bytes;
-	/* Number of received Atomic request packets. */
-	uint64_t	rx_atomic_req_pkts;
-	/* Number of received Read request packets. */
-	uint64_t	rx_read_req_pkts;
-	/* Number of received Read response packets. */
-	uint64_t	rx_read_res_pkts;
-	/* Number of received Write request packets. */
-	uint64_t	rx_write_req_pkts;
+	#define CQ_BASE_STATUS_MEMORY_MGT_OPERATION_ERR   UINT32_C(0x7)
 	/*
-	 * Number of received Send request packets.
-	 * This is for RC QPs only.
+	 * An invalid message was received by the responder. This could be
+	 * an operation that is not supported by this QP, an IRRQ overflow
+	 * error, or the length in an RDMA operation is greater than the
+	 * maximum message size (2^31 bytes).
+	 *
+	 * This is a fatal error detected by the responder and communicated
+	 * back to the requester using a NAK-Invalid Request. For responder
+	 * CQEs, only the opaque field is valid.
 	 */
-	uint64_t	rx_send_req_pkts;
+	#define CQ_BASE_STATUS_REMOTE_INVALID_REQUEST_ERR UINT32_C(0x8)
 	/*
-	 * Number of received RoCE packets including RoCE packets with errors.
-	 * This includes RC, UD, RawEth, and QP1 packets
+	 * A protection error occurred on a remote data buffer to be read
+	 * by an RDMA Read, written by an RDMA Write or accessed by an
+	 * atomic operation. This error is reported only on RDMA operations
+	 * or atomic operations.
+	 *
+	 * This is a fatal error detected by the responder and communicated
+	 * back to the requester using a NAK-Remote Access Violation.
 	 */
-	uint64_t	rx_roce_pkts;
+	#define CQ_BASE_STATUS_REMOTE_ACCESS_ERR	UINT32_C(0x9)
 	/*
-	 * Number of received RoCE header and payload bytes including RoCE
-	 * packets with errors.
-	 * This includes RC, UD, RawEth, and QP1 packets.
+	 * The operation could not be completed successfully by the
+	 * responder. Possible causes include an RQ/SRQ WQE format error,
+	 * an SSC error when validating an SGE from an RQ/SRQ WQE, or the
+	 * message received was too long for the RQ/SRQ WQE.
+	 *
+	 * This is a fatal error detected by the responder and communicated
+	 * back to the requester using a NAK-Remote Operation Error.
 	 */
-	uint64_t	rx_roce_bytes;
+	#define CQ_BASE_STATUS_REMOTE_OPERATION_ERR	UINT32_C(0xa)
 	/*
-	 * Number of received RoCE packets.
-	 * This includes RC, UD, RawEth, and QP1 packets
+	 * The RNR NAK retry count was exceeded while trying to send this
+	 * message.
+	 *
+	 * This is a fatal error detected by the requester.
 	 */
-	uint64_t	rx_roce_good_pkts;
+	#define CQ_BASE_STATUS_RNR_NAK_RETRY_CNT_ERR	UINT32_C(0xb)
 	/*
-	 * Number of received RoCE header and payload bytes.
-	 * This includes RC, UD, RawEth, and QP1 packets.
+	 * The local transport timeout retry counter was exceeded while
+	 * trying to send this message.
+	 *
+	 * This is a fatal error detected by the requester.
 	 */
-	uint64_t	rx_roce_good_bytes;
+	#define CQ_BASE_STATUS_TRANSPORT_RETRY_CNT_ERR	UINT32_C(0xc)
 	/*
-	 * Number of drops that occurred to lack of buffers.
-	 * This is for RC QPs only.
+	 * A WQE was in process or outstanding when the QP transitioned
+	 * into the Error State.
 	 */
-	uint64_t	rx_out_of_buffer_pkts;
-	/* Number of packets that were received out of sequence. */
-	uint64_t	rx_out_of_sequence_pkts;
-	/* Number of transmitted CNP packets. */
-	uint64_t	tx_cnp_pkts;
-	/* Number of received CNP packets. */
-	uint64_t	rx_cnp_pkts;
-	/* Number of received ECN-marked RoCE packets. */
-	uint64_t	rx_ecn_marked_pkts;
-	/* Number of transmitted CNP bytes. */
-	uint64_t	tx_cnp_bytes;
-	/* Number of received CNP bytes. */
-	uint64_t	rx_cnp_bytes;
-} creq_query_roce_stats_ext_resp_sb_t, *pcreq_query_roce_stats_ext_resp_sb_t;
-
-/**************
- * query_func *
- **************/
-
+	#define CQ_BASE_STATUS_WORK_REQUEST_FLUSHED_ERR   UINT32_C(0xd)
+	/*
+	 * A WQE had already been taken off the RQ/SRQ when a fatal error
+	 * was detected on responder Rx. Only the opaque field in the CQE
+	 * is valid.
+	 */
+	#define CQ_BASE_STATUS_HW_FLUSH_ERR		UINT32_C(0xe)
+	/*
+	 * A WQE was posted to the SQ/RQ that caused it to overflow. For
+	 * requester CQEs, it was the SQ that overflowed. For responder
+	 * CQEs, it was the RQ that overflowed.
+	 */
+	#define CQ_BASE_STATUS_OVERFLOW_ERR		UINT32_C(0xf)
+	#define CQ_BASE_STATUS_LAST			CQ_BASE_STATUS_OVERFLOW_ERR
+	uint16_t	reserved16;
+	/*
+	 * This value is from the WQE that is being completed. This field is
+	 * only applicable to V3 version of CQEs.
+	 */
+	uint32_t	opaque;
+} cq_base_t, *pcq_base_t;
 
-/* cmdq_query_func (size:128b/16B) */
+/* Requester CQ CQE */
+/* cq_req (size:256b/32B) */
 
-typedef struct cmdq_query_func {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Query the HW capabilities for the function. */
-	#define CMDQ_QUERY_FUNC_OPCODE_QUERY_FUNC UINT32_C(0x83)
-	#define CMDQ_QUERY_FUNC_OPCODE_LAST	CMDQ_QUERY_FUNC_OPCODE_QUERY_FUNC
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-} cmdq_query_func_t, *pcmdq_query_func_t;
+typedef struct cq_req {
+	/*
+	 * This is an application level ID used to identify the
+	 * QP and its SQ and RQ.
+	 */
+	uint64_t	qp_handle;
+	/*
+	 * SQ Consumer Index - points to the entry just past the last WQE
+	 * that has been completed by the chip. Wraps around at
+	 * QPC.sq_size (i.e. the valid range of the SQ Consumer Index is 0
+	 * to (QPC.sq_size - 1)).
+	 */
+	uint16_t	sq_cons_idx;
+	uint16_t	reserved16_1;
+	uint32_t	reserved32_2;
+	uint64_t	reserved64;
+	uint8_t	cqe_type_toggle;
+	/*
+	 * Indicate valid completion - written by the chip. Cumulus
+	 * toggle this bit each time it finished consuming all PBL
+	 * entries
+	 */
+	#define CQ_REQ_TOGGLE	UINT32_C(0x1)
+	/* This field defines the type of CQE. */
+	#define CQ_REQ_CQE_TYPE_MASK UINT32_C(0x1e)
+	#define CQ_REQ_CQE_TYPE_SFT 1
+	/*
+	 * Requester completion - This is used for both RC and UD SQ
+	 * completions.
+	 */
+		#define CQ_REQ_CQE_TYPE_REQ   (UINT32_C(0x0) << 1)
+		#define CQ_REQ_CQE_TYPE_LAST CQ_REQ_CQE_TYPE_REQ
+	/*
+	 * When this bit is '1', it indicates that the packet completed
+	 * was transmitted using the push accelerated data provided by
+	 * the driver. When this bit is '0', it indicates that the packet
+	 * had not push acceleration data written or was executed as a
+	 * normal packet even though push data was provided.
+	 * This field is intended to be used for driver-generated push
+	 * statistics. It is not applicable for RC since not all RC packets
+	 * return a CQE.
+	 */
+	#define CQ_REQ_PUSH	UINT32_C(0x20)
+	/* This field indicates the status for the CQE. */
+	uint8_t	status;
+	/* OK is 0 */
+	#define CQ_REQ_STATUS_OK			UINT32_C(0x0)
+	/* BAD_RESPONSE_ERR is 1 */
+	#define CQ_REQ_STATUS_BAD_RESPONSE_ERR	UINT32_C(0x1)
+	/* LOCAL_LENGTH_ERR is 2 */
+	#define CQ_REQ_STATUS_LOCAL_LENGTH_ERR	UINT32_C(0x2)
+	/* LOCAL_QP_OPERATION_ERR is 3 */
+	#define CQ_REQ_STATUS_LOCAL_QP_OPERATION_ERR	UINT32_C(0x3)
+	/* LOCAL_PROTECTION_ERR is 4 */
+	#define CQ_REQ_STATUS_LOCAL_PROTECTION_ERR	UINT32_C(0x4)
+	/* MEMORY_MGT_OPERATION_ERR is 5 */
+	#define CQ_REQ_STATUS_MEMORY_MGT_OPERATION_ERR   UINT32_C(0x5)
+	/* REMOTE_INVALID_REQUEST_ERR is 6 */
+	#define CQ_REQ_STATUS_REMOTE_INVALID_REQUEST_ERR UINT32_C(0x6)
+	/* REMOTE_ACCESS_ERR is 7 */
+	#define CQ_REQ_STATUS_REMOTE_ACCESS_ERR	UINT32_C(0x7)
+	/* REMOTE_OPERATION_ERR is 8 */
+	#define CQ_REQ_STATUS_REMOTE_OPERATION_ERR	UINT32_C(0x8)
+	/* RNR_NAK_RETRY_CNT_ERR is 9 */
+	#define CQ_REQ_STATUS_RNR_NAK_RETRY_CNT_ERR	UINT32_C(0x9)
+	/* TRANSPORT_RETRY_CNT_ERR is 10 */
+	#define CQ_REQ_STATUS_TRANSPORT_RETRY_CNT_ERR	UINT32_C(0xa)
+	/* WORK_REQUEST_FLUSHED_ERR is 11 */
+	#define CQ_REQ_STATUS_WORK_REQUEST_FLUSHED_ERR   UINT32_C(0xb)
+	#define CQ_REQ_STATUS_LAST			CQ_REQ_STATUS_WORK_REQUEST_FLUSHED_ERR
+	uint16_t	reserved16_2;
+	uint32_t	reserved32_1;
+} cq_req_t, *pcq_req_t;
 
-/* creq_query_func_resp (size:128b/16B) */
+/* Responder RC CQE */
+/* cq_res_rc (size:256b/32B) */
 
-typedef struct creq_query_func_resp {
-	uint8_t	type;
+typedef struct cq_res_rc {
+	/*
+	 * The length of the message's payload in bytes, stored in
+	 * the SGEs
+	 */
+	uint32_t	length;
+	/*
+	 * Immediate data in case the imm_flag set, R_Key to be
+	 * invalidated in case inv_flag is set.
+	 */
+	uint32_t	imm_data_or_inv_r_key;
+	/*
+	 * This is an application level ID used to identify the
+	 * QP and its SQ and RQ.
+	 */
+	uint64_t	qp_handle;
+	/*
+	 * Opaque value - valid when inv_flag is set. Used by driver
+	 * to reference the buffer used to store PBL when the MR was
+	 * fast registered. The driver can reclaim this buffer after
+	 * an MR was remotely invalidated. The controller take that
+	 * value from the MR referenced by R_Key
+	 */
+	uint64_t	mr_handle;
+	uint8_t	cqe_type_toggle;
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * Indicate valid completion - written by the chip. Cumulus
+	 * toggle this bit each time it finished consuming all PBL
+	 * entries
 	 */
-	#define CREQ_QUERY_FUNC_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_QUERY_FUNC_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_QUERY_FUNC_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_QUERY_FUNC_RESP_TYPE_LAST	CREQ_QUERY_FUNC_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Side buffer size in 16-byte units */
-	uint32_t	size;
-	uint8_t	v;
+	#define CQ_RES_RC_TOGGLE	UINT32_C(0x1)
+	/* This field defines the type of CQE. */
+	#define CQ_RES_RC_CQE_TYPE_MASK  UINT32_C(0x1e)
+	#define CQ_RES_RC_CQE_TYPE_SFT   1
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * Responder RC Completion - This is used for both RQ and SRQ
+	 * completions for RC service QPs.
 	 */
-	#define CREQ_QUERY_FUNC_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Query info PF command response. */
-	#define CREQ_QUERY_FUNC_RESP_EVENT_QUERY_FUNC UINT32_C(0x83)
-	#define CREQ_QUERY_FUNC_RESP_EVENT_LAST	CREQ_QUERY_FUNC_RESP_EVENT_QUERY_FUNC
-	uint8_t	reserved48[6];
-} creq_query_func_resp_t, *pcreq_query_func_resp_t;
-
-/* Query function command response side buffer structure. */
-/* creq_query_func_resp_sb (size:1088b/136B) */
-
-typedef struct creq_query_func_resp_sb {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Query info PF command response. */
-	#define CREQ_QUERY_FUNC_RESP_SB_OPCODE_QUERY_FUNC UINT32_C(0x83)
-	#define CREQ_QUERY_FUNC_RESP_SB_OPCODE_LAST	CREQ_QUERY_FUNC_RESP_SB_OPCODE_QUERY_FUNC
-	/* Status of the response. */
+		#define CQ_RES_RC_CQE_TYPE_RES_RC  (UINT32_C(0x1) << 1)
+		#define CQ_RES_RC_CQE_TYPE_LAST   CQ_RES_RC_CQE_TYPE_RES_RC
+	/* This field indicates the status for the CQE. */
 	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Flags and attribs of the command. */
+	/* OK is 0 */
+	#define CQ_RES_RC_STATUS_OK			UINT32_C(0x0)
+	/* LOCAL_ACCESS_ERROR is 1 */
+	#define CQ_RES_RC_STATUS_LOCAL_ACCESS_ERROR	UINT32_C(0x1)
+	/* LOCAL_LENGTH_ERR is 2 */
+	#define CQ_RES_RC_STATUS_LOCAL_LENGTH_ERR	UINT32_C(0x2)
+	/* LOCAL_PROTECTION_ERR is 3 */
+	#define CQ_RES_RC_STATUS_LOCAL_PROTECTION_ERR	UINT32_C(0x3)
+	/* LOCAL_QP_OPERATION_ERR is 4 */
+	#define CQ_RES_RC_STATUS_LOCAL_QP_OPERATION_ERR	UINT32_C(0x4)
+	/* MEMORY_MGT_OPERATION_ERR is 5 */
+	#define CQ_RES_RC_STATUS_MEMORY_MGT_OPERATION_ERR   UINT32_C(0x5)
+	/* REMOTE_INVALID_REQUEST_ERR is 6 */
+	#define CQ_RES_RC_STATUS_REMOTE_INVALID_REQUEST_ERR UINT32_C(0x6)
+	/* WORK_REQUEST_FLUSHED_ERR is 7 */
+	#define CQ_RES_RC_STATUS_WORK_REQUEST_FLUSHED_ERR   UINT32_C(0x7)
+	/* HW_FLUSH_ERR is 8 */
+	#define CQ_RES_RC_STATUS_HW_FLUSH_ERR		UINT32_C(0x8)
+	#define CQ_RES_RC_STATUS_LAST			CQ_RES_RC_STATUS_HW_FLUSH_ERR
 	uint16_t	flags;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Max MR size supported. */
-	uint64_t	max_mr_size;
-	/* Max QP supported. */
-	uint32_t	max_qp;
-	/* Max WQEs per QP. */
-	uint16_t	max_qp_wr;
-	/* Device capability flags. */
-	uint16_t	dev_cap_flags;
-	/* Allow QP resizing. */
-	#define CREQ_QUERY_FUNC_RESP_SB_RESIZE_QP			UINT32_C(0x1)
-	/* Specifies Congestion Control (CC) generation. */
-	#define CREQ_QUERY_FUNC_RESP_SB_CC_GENERATION_MASK		UINT32_C(0xe)
-	#define CREQ_QUERY_FUNC_RESP_SB_CC_GENERATION_SFT		1
 	/*
-	 * Includes support for DCTCP and TCP CC algorithms,
-	 * enabling operation in networks where PFC is enabled.
+	 * This flag indicates that the completion is for a SRQ entry
+	 * rather than for an RQ entry.
 	 */
-		#define CREQ_QUERY_FUNC_RESP_SB_CC_GENERATION_CC_GEN0		(UINT32_C(0x0) << 1)
+	#define CQ_RES_RC_FLAGS_SRQ		UINT32_C(0x1)
+	/* CQE relates to RQ WQE. */
+		#define CQ_RES_RC_FLAGS_SRQ_RQ	UINT32_C(0x0)
+	/* CQE relates to SRQ WQE. */
+		#define CQ_RES_RC_FLAGS_SRQ_SRQ	UINT32_C(0x1)
+		#define CQ_RES_RC_FLAGS_SRQ_LAST	CQ_RES_RC_FLAGS_SRQ_SRQ
+	/* Immediate data indicator */
+	#define CQ_RES_RC_FLAGS_IMM		UINT32_C(0x2)
+	/* R_Key invalidate indicator */
+	#define CQ_RES_RC_FLAGS_INV		UINT32_C(0x4)
+	#define CQ_RES_RC_FLAGS_RDMA	UINT32_C(0x8)
+	/* CQE relates to an incoming Send request */
+		#define CQ_RES_RC_FLAGS_RDMA_SEND	(UINT32_C(0x0) << 3)
+	/* CQE relates to incoming RDMA Write request */
+		#define CQ_RES_RC_FLAGS_RDMA_RDMA_WRITE  (UINT32_C(0x1) << 3)
+		#define CQ_RES_RC_FLAGS_RDMA_LAST	CQ_RES_RC_FLAGS_RDMA_RDMA_WRITE
+	uint32_t	srq_or_rq_wr_id;
 	/*
-	 * Enhances cc_gen0 support with probabilistic marking algorithm,
-	 * enabling fast ramp up and convergence,
-	 * as well as operation in networks where PFC is not enabled.
-	 * Includes a number of parameters that are different from cc_gen0
-	 * chips as well as new parameters. TCP CC algorithm is not supported.
+	 * Opaque value from RQ or SRQ WQE. Used by driver/lib to
+	 * reference the WQE in order to claim the received data
+	 * and reuse the WQE space
 	 */
-		#define CREQ_QUERY_FUNC_RESP_SB_CC_GENERATION_CC_GEN1		(UINT32_C(0x1) << 1)
+	#define CQ_RES_RC_SRQ_OR_RQ_WR_ID_MASK UINT32_C(0xfffff)
+	#define CQ_RES_RC_SRQ_OR_RQ_WR_ID_SFT 0
+} cq_res_rc_t, *pcq_res_rc_t;
+
+/* Responder UD CQE */
+/* cq_res_ud (size:256b/32B) */
+
+typedef struct cq_res_ud {
+	uint16_t	length;
 	/*
-	 * Enhances cc_gen1 support for additional CC parameters:
-	 * reduce_init_en, reduce_init_cong_free_rtts_th, random_no_red_en,
-	 * actual_cr_shift_correction_en, quota_period_adjust_en
+	 * The length of the message's payload in bytes, stored in
+	 * the SGEs
 	 */
-		#define CREQ_QUERY_FUNC_RESP_SB_CC_GENERATION_CC_GEN1_EXT	(UINT32_C(0x2) << 1)
-		#define CREQ_QUERY_FUNC_RESP_SB_CC_GENERATION_LAST		CREQ_QUERY_FUNC_RESP_SB_CC_GENERATION_CC_GEN1_EXT
+	#define CQ_RES_UD_LENGTH_MASK UINT32_C(0x3fff)
+	#define CQ_RES_UD_LENGTH_SFT 0
 	/*
-	 * Support for the extended RoCE statistics is available. These
-	 * statistics are queried via the `query_roce_stats_ext` command
-	 * and are enabled on a per-QP basis via `create_qp`.
+	 * This is data from the CFA or VNIC block as indicated by the
+	 * ext_meta_format and meta_format fields.
 	 */
-	#define CREQ_QUERY_FUNC_RESP_SB_EXT_STATS			UINT32_C(0x10)
+	uint16_t	cfa_metadata;
+	/* When meta_format=1, this value is the VLAN VID. */
+	#define CQ_RES_UD_CFA_METADATA_VID_MASK UINT32_C(0xfff)
+	#define CQ_RES_UD_CFA_METADATA_VID_SFT 0
+	/* When meta_format=1, this value is the VLAN DE. */
+	#define CQ_RES_UD_CFA_METADATA_DE	UINT32_C(0x1000)
+	/* When meta_format=1, this value is the VLAN PRI. */
+	#define CQ_RES_UD_CFA_METADATA_PRI_MASK UINT32_C(0xe000)
+	#define CQ_RES_UD_CFA_METADATA_PRI_SFT 13
+	/* Immediate data in case the imm_flag set. */
+	uint32_t	imm_data;
 	/*
-	 * Support for both allocating and registering a new MR via the
-	 * `register_mr` command is available. With this feature the
-	 * `allocate_mrw` command does not have to be called before
-	 * registering.
+	 * This is an application level ID used to identify the
+	 * QP and its SQ and RQ.
 	 */
-	#define CREQ_QUERY_FUNC_RESP_SB_MR_REGISTER_ALLOC		UINT32_C(0x20)
+	uint64_t	qp_handle;
 	/*
-	 * Support for optimized transmit path to lower latency for WQEs
-	 * with inline data.
+	 * Source MAC address for the UD message placed in the WQE
+	 * that is completed by this CQE.
 	 */
-	#define CREQ_QUERY_FUNC_RESP_SB_OPTIMIZED_TRANSMIT_ENABLED	UINT32_C(0x40)
+	uint16_t	src_mac[3];
+	/* Lower 16b of the Source QP value from the DETH header. */
+	uint16_t	src_qp_low;
+	uint8_t	cqe_type_toggle;
 	/*
-	 * The underlying HW uses the version 2 of the CQEs definitions for
-	 * the following CQE types:
-	 * RES_UD, RES_RAWETH_QP1, RES_UD_CFA
+	 * Indicate valid completion - written by the chip. Cumulus
+	 * toggle this bit each time it finished consuming all PBL
+	 * entries
 	 */
-	#define CREQ_QUERY_FUNC_RESP_SB_CQE_V2			UINT32_C(0x80)
-	/* Support for ping pong push mode is available. */
-	#define CREQ_QUERY_FUNC_RESP_SB_PINGPONG_PUSH_MODE		UINT32_C(0x100)
-	/* Max CQs supported. */
-	uint32_t	max_cq;
-	/* Max CQEs per CQ supported. */
-	uint32_t	max_cqe;
-	/* Max PDs supported. */
-	uint32_t	max_pd;
+	#define CQ_RES_UD_TOGGLE	UINT32_C(0x1)
+	/* This field defines the type of CQE. */
+	#define CQ_RES_UD_CQE_TYPE_MASK  UINT32_C(0x1e)
+	#define CQ_RES_UD_CQE_TYPE_SFT   1
 	/*
-	 * Max SGEs per QP WQE supported. On chips with variable-size WQE support,
-	 * this field is applicable only for the backward compatible mode.
+	 * Responder UD Completion - This is used for both RQ and SRQ
+	 * completion for UD service QPs.
 	 */
-	uint8_t	max_sge;
-	/* Max SGEs per SRQ WQE supported. */
-	uint8_t	max_srq_sge;
-	/* Max outstanding RDMA read & atomic supported. */
-	uint8_t	max_qp_rd_atom;
-	/* Max outstanding RDMA read & atomic that can be sent from an initiator. */
-	uint8_t	max_qp_init_rd_atom;
-	/* Max MRs supported. */
-	uint32_t	max_mr;
-	/* Max MWs supported. */
-	uint32_t	max_mw;
-	/* Max Raw Ethertype QPs supported. */
-	uint32_t	max_raw_eth_qp;
-	/* Max AHs supported. */
-	uint32_t	max_ah;
-	/* Max FMRs supported. */
-	uint32_t	max_fmr;
-	/* Max WQEs per SRQ supported. */
-	uint32_t	max_srq_wr;
-	/* Max PKEYs supported. */
-	uint32_t	max_pkeys;
+		#define CQ_RES_UD_CQE_TYPE_RES_UD  (UINT32_C(0x2) << 1)
+		#define CQ_RES_UD_CQE_TYPE_LAST   CQ_RES_UD_CQE_TYPE_RES_UD
+	/* This field indicates the status for the CQE. */
+	uint8_t	status;
 	/*
-	 * Max inline data supported. On chips with variable-size WQE support,
-	 * this field is applicable only for the backward compatible mode.
+	 * This indicates that the completion is without error.
+	 * All fields are valid.
 	 */
-	uint32_t	max_inline_data;
-	/* Max mappings per FMR supported. */
-	uint8_t	max_map_per_fmr;
-	/* L2 DB space size in pages. */
-	uint8_t	l2_db_space_size;
-	/* Max SRQs supported. */
-	uint16_t	max_srq;
-	/* Max GIDs supported. */
-	uint32_t	max_gid;
+	#define CQ_RES_UD_STATUS_OK			UINT32_C(0x0)
 	/*
-	 * An array of 48 8-bit values to specify allocation multiplier for TQM host buffer regions.
-	 * Each region occupies 16 MB of TQM PBL address space: 0x00000000, 0x01000000, 0x02000000, etc.
-	 * The host needs to allocate (<Number of QPs>*multiplier, rounded up to page size) of physical memory for non-zero slots
-	 * and map the pages to the corresponding 16MB regions.
-	 * Typically there are total 3 non-zero values in this array, their values are 16, 16, 12.
-	 * Cu+ will only populate up to index 11. SR may populate up to index 47.
+	 * This indicates that write access was not allowed for
+	 * at least one of the SGEs in the WQE.
+	 *
+	 * This is a fatal error. Only the srq_or_rq_wr_id is field
+	 * is valid.
 	 */
-	uint32_t	tqm_alloc_reqs[12];
-	/* Max Doorbell page indices supported. */
-	uint32_t	max_dpi;
-	/* Max SGEs per QP WQE supported in the variable-size WQE mode. */
-	uint8_t	max_sge_var_wqe;
-	uint8_t	reserved_8;
-	/* Max inline data supported in the variable-size WQE mode. */
-	uint16_t	max_inline_data_var_wqe;
-} creq_query_func_resp_sb_t, *pcreq_query_func_resp_sb_t;
-
-/**********************
- * set_func_resources *
- **********************/
-
-
-/* cmdq_set_func_resources (size:448b/56B) */
-
-typedef struct cmdq_set_func_resources {
-	/* Command opcode. */
-	uint8_t	opcode;
+	#define CQ_RES_UD_STATUS_LOCAL_ACCESS_ERROR	UINT32_C(0x1)
 	/*
-	 * Set the following resources for the function:
-	 * - Max QP, CQ, MR+MW, SRQ per PF
-	 * - Max QP, CQ, MR+MW, SRQ per VF
+	 * This indicates that the packet was too long for the WQE
+	 * provided on the SRQ/RQ.
+	 *
+	 * This is not a fatal error. All the fields are valid.
 	 */
-	#define CMDQ_SET_FUNC_RESOURCES_OPCODE_SET_FUNC_RESOURCES UINT32_C(0x84)
-	#define CMDQ_SET_FUNC_RESOURCES_OPCODE_LAST		CMDQ_SET_FUNC_RESOURCES_OPCODE_SET_FUNC_RESOURCES
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
+	#define CQ_RES_UD_STATUS_HW_LOCAL_LENGTH_ERR	UINT32_C(0x2)
+	/* LOCAL_PROTECTION_ERR is 3 */
+	#define CQ_RES_UD_STATUS_LOCAL_PROTECTION_ERR	UINT32_C(0x3)
+	/* LOCAL_QP_OPERATION_ERR is 4 */
+	#define CQ_RES_UD_STATUS_LOCAL_QP_OPERATION_ERR   UINT32_C(0x4)
+	/* MEMORY_MGT_OPERATION_ERR is 5 */
+	#define CQ_RES_UD_STATUS_MEMORY_MGT_OPERATION_ERR UINT32_C(0x5)
+	/* WORK_REQUEST_FLUSHED_ERR is 7 */
+	#define CQ_RES_UD_STATUS_WORK_REQUEST_FLUSHED_ERR UINT32_C(0x7)
+	/* HW_FLUSH_ERR is 8 */
+	#define CQ_RES_UD_STATUS_HW_FLUSH_ERR		UINT32_C(0x8)
+	#define CQ_RES_UD_STATUS_LAST			CQ_RES_UD_STATUS_HW_FLUSH_ERR
 	uint16_t	flags;
 	/*
-	 * When set, the 32b `max_mrw_per_vf` field is logically divided
-	 * into two 16b fields, `max_mr_per_vf` and `max_av_per_vf`.
+	 * This flag indicates that the completion is for a SRQ entry
+	 * rather than for an RQ entry.
 	 */
-	#define CMDQ_SET_FUNC_RESOURCES_FLAGS_MRAV_RESERVATION_SPLIT	UINT32_C(0x1)
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	/* Number of QPs. It is the responsibility of the host to first extend the existing PBL with new addresses to pages to handle the adjustment. Must be greater or equal to current. */
-	uint32_t	number_of_qp;
-	/* Number of MRWs. It is the responsibility of the host to first extend the existing PBL with new addresses to pages to handle the adjustment. Must be greater or equal to current. */
-	uint32_t	number_of_mrw;
-	/* Number of SRQs. It is the responsibility of the host to first extend the existing PBL with new addresses to pages to handle the adjustment. Must be greater or equal to current. */
-	uint32_t	number_of_srq;
-	/* Number of CQs. It is the responsibility of the host to first extend the existing PBL with new addresses to pages to handle the adjustment. Must be greater or equal to current. */
-	uint32_t	number_of_cq;
-	/* Number of QPs per VF. */
-	uint32_t	max_qp_per_vf;
+	#define CQ_RES_UD_FLAGS_SRQ		UINT32_C(0x1)
+	/* CQE relates to RQ WQE. */
+		#define CQ_RES_UD_FLAGS_SRQ_RQ		UINT32_C(0x0)
+	/* CQE relates to SRQ WQE. */
+		#define CQ_RES_UD_FLAGS_SRQ_SRQ		UINT32_C(0x1)
+		#define CQ_RES_UD_FLAGS_SRQ_LAST		CQ_RES_UD_FLAGS_SRQ_SRQ
+	/* Immediate data indicator */
+	#define CQ_RES_UD_FLAGS_IMM		UINT32_C(0x2)
+	#define CQ_RES_UD_FLAGS_UNUSED_MASK	UINT32_C(0xc)
+	#define CQ_RES_UD_FLAGS_UNUSED_SFT		2
+	#define CQ_RES_UD_FLAGS_ROCE_IP_VER_MASK	UINT32_C(0x30)
+	#define CQ_RES_UD_FLAGS_ROCE_IP_VER_SFT	4
+	/* RoCEv1 Message */
+		#define CQ_RES_UD_FLAGS_ROCE_IP_VER_V1	(UINT32_C(0x0) << 4)
+	/* RoCEv2 IPv4 Message */
+		#define CQ_RES_UD_FLAGS_ROCE_IP_VER_V2IPV4	(UINT32_C(0x2) << 4)
+	/* RoCEv2 IPv6 Message */
+		#define CQ_RES_UD_FLAGS_ROCE_IP_VER_V2IPV6	(UINT32_C(0x3) << 4)
+		#define CQ_RES_UD_FLAGS_ROCE_IP_VER_LAST	CQ_RES_UD_FLAGS_ROCE_IP_VER_V2IPV6
 	/*
-	 * If the MR/AV split reservation flag is not set, then this field
-	 * represents the total number of MR plus AV entries allowed per
-	 * VF. For versions of firmware that support the split reservation,
-	 * when it is not specified half of the entries will be reserved
-	 * for MRs and the other half for AVs.
-	 *
-	 * If the MR/AV split reservation flag is set, then this
-	 * field is logically divided into two 16b fields. Bits `[31:16]`
-	 * represents the `max_mr_per_vf` and bits `[15:0]` represents
-	 * `max_av_per_vf`. The granularity of these values is defined by
-	 * the `mrav_num_entries_unit` field returned by the
-	 * `backing_store_qcaps` command.
+	 * The combination of this value and ext_meta_format indicates
+	 * what format the metadata field is.
 	 */
-	uint32_t	max_mrw_per_vf;
-	/* Number of SRQs per VF. */
-	uint32_t	max_srq_per_vf;
-	/* Number of CQs per VF. */
-	uint32_t	max_cq_per_vf;
-	/* Number of GIDs per VF. */
-	uint32_t	max_gid_per_vf;
-	/* Statistics context index for this function. */
-	uint32_t	stat_ctx_id;
-} cmdq_set_func_resources_t, *pcmdq_set_func_resources_t;
-
-/* creq_set_func_resources_resp (size:128b/16B) */
-
-typedef struct creq_set_func_resources_resp {
-	uint8_t	type;
+	#define CQ_RES_UD_FLAGS_META_FORMAT_MASK	UINT32_C(0x3c0)
+	#define CQ_RES_UD_FLAGS_META_FORMAT_SFT	6
+	/* No metadata information. Value is zero. */
+		#define CQ_RES_UD_FLAGS_META_FORMAT_NONE	(UINT32_C(0x0) << 6)
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * The metadata field contains the VLAN tag and TPID value.
+	 * - metadata[11:0] contains the vlan VID value.
+	 * - metadata[12] contains the vlan DE value.
+	 * - metadata[15:13] contains the vlan PRI value.
 	 */
-	#define CREQ_SET_FUNC_RESOURCES_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_SET_FUNC_RESOURCES_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_SET_FUNC_RESOURCES_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_SET_FUNC_RESOURCES_RESP_TYPE_LAST	CREQ_SET_FUNC_RESOURCES_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	uint32_t	reserved32;
-	uint8_t	v;
+		#define CQ_RES_UD_FLAGS_META_FORMAT_VLAN	(UINT32_C(0x1) << 6)
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * If ext_meta_format is equal to 1, the metadata field
+	 * contains the lower 16b of the tunnel ID value, justified
+	 * to LSB
+	 * - VXLAN = VNI[23:0] -> VXLAN Network ID
+	 * - Geneve (NGE) = VNI[23:0] -> Virtual Network Identifier.
+	 * - NVGRE = TNI[23:0] -> Tenant Network ID
+	 * - GRE = KEY[31:0] -> key field with bit mask. zero if K = 0
+	 * - IPV4 = 0 (not populated)
+	 * - IPV6 = Flow Label[19:0]
+	 * - PPPoE = sessionID[15:0]
+	 * - MPLs = Outer label[19:0]
+	 * - UPAR = Selected[31:0] with bit mask
 	 */
-	#define CREQ_SET_FUNC_RESOURCES_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Set function resources command response. */
-	#define CREQ_SET_FUNC_RESOURCES_RESP_EVENT_SET_FUNC_RESOURCES UINT32_C(0x84)
-	#define CREQ_SET_FUNC_RESOURCES_RESP_EVENT_LAST		CREQ_SET_FUNC_RESOURCES_RESP_EVENT_SET_FUNC_RESOURCES
-	uint8_t	reserved48[6];
-} creq_set_func_resources_resp_t, *pcreq_set_func_resources_resp_t;
-
-/*************
- * stop_func *
- *************/
-
-
-/* cmdq_stop_func (size:128b/16B) */
-
-typedef struct cmdq_stop_func {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Stop the function */
-	#define CMDQ_STOP_FUNC_OPCODE_STOP_FUNC UINT32_C(0x82)
-	#define CMDQ_STOP_FUNC_OPCODE_LAST	CMDQ_STOP_FUNC_OPCODE_STOP_FUNC
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-} cmdq_stop_func_t, *pcmdq_stop_func_t;
-
-/* creq_stop_func_resp (size:128b/16B) */
-
-typedef struct creq_stop_func_resp {
-	uint8_t	type;
+		#define CQ_RES_UD_FLAGS_META_FORMAT_TUNNEL_ID   (UINT32_C(0x2) << 6)
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * if ext_meta_format is equal to 1, metadata field contains
+	 * 16b metadata from the prepended header (chdr_data).
 	 */
-	#define CREQ_STOP_FUNC_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_STOP_FUNC_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_STOP_FUNC_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_STOP_FUNC_RESP_TYPE_LAST	CREQ_STOP_FUNC_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	uint32_t	reserved32;
-	uint8_t	v;
+		#define CQ_RES_UD_FLAGS_META_FORMAT_CHDR_DATA   (UINT32_C(0x3) << 6)
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * If ext_meta_format is equal to 1, the metadata field contains
+	 * the outer_l3_offset and lower 7 bits of the inner_l2_offset,
+	 * - metadata[8:0] contains the outer_l3_offset.
+	 * - metadata[15:9] contains the inner_l2_offset[6:0]
 	 */
-	#define CREQ_STOP_FUNC_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Stop PF command response. */
-	#define CREQ_STOP_FUNC_RESP_EVENT_STOP_FUNC UINT32_C(0x82)
-	#define CREQ_STOP_FUNC_RESP_EVENT_LAST	CREQ_STOP_FUNC_RESP_EVENT_STOP_FUNC
-	uint8_t	reserved48[6];
-} creq_stop_func_resp_t, *pcreq_stop_func_resp_t;
-
-/****************
- * read_context *
- ****************/
-
-
-/* cmdq_read_context (size:192b/24B) */
-
-typedef struct cmdq_read_context {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Read the current state of any internal resource context. Can only be issued from a PF. */
-	#define CMDQ_READ_CONTEXT_OPCODE_READ_CONTEXT UINT32_C(0x85)
-	#define CMDQ_READ_CONTEXT_OPCODE_LAST	CMDQ_READ_CONTEXT_OPCODE_READ_CONTEXT
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	uint32_t	type_xid;
-	/* Context ID */
-	#define CMDQ_READ_CONTEXT_XID_MASK UINT32_C(0xffffff)
-	#define CMDQ_READ_CONTEXT_XID_SFT  0
-	/* Context type */
-	#define CMDQ_READ_CONTEXT_TYPE_MASK UINT32_C(0xff000000)
-	#define CMDQ_READ_CONTEXT_TYPE_SFT 24
-	/* Read QPC. The context (448 bytes) goes to resp_addr (as is, without a header), and resp_size should be set to 28 (448/16) */
-		#define CMDQ_READ_CONTEXT_TYPE_QPC   (UINT32_C(0x0) << 24)
-	/* Read CQ. The context (64 bytes) goes to resp_addr (as is, without a header), and resp_size should be set to 4 (64/16) */
-		#define CMDQ_READ_CONTEXT_TYPE_CQ	(UINT32_C(0x1) << 24)
-	/* Read MRW. The context (128 bytes) goes to resp_addr (as is, without a header), and resp_size should be set to 8 (128/16) */
-		#define CMDQ_READ_CONTEXT_TYPE_MRW   (UINT32_C(0x2) << 24)
-	/* Read SRQ. The context (64 bytes) goes to resp_addr (as is, without a header), and resp_size should be set to 4 (64/16) */
-		#define CMDQ_READ_CONTEXT_TYPE_SRQ   (UINT32_C(0x3) << 24)
-		#define CMDQ_READ_CONTEXT_TYPE_LAST CMDQ_READ_CONTEXT_TYPE_SRQ
-	uint32_t	unused_0;
-} cmdq_read_context_t, *pcmdq_read_context_t;
-
-/* creq_read_context (size:128b/16B) */
-
-typedef struct creq_read_context {
-	uint8_t	type;
+		#define CQ_RES_UD_FLAGS_META_FORMAT_HDR_OFFSET  (UINT32_C(0x4) << 6)
+		#define CQ_RES_UD_FLAGS_META_FORMAT_LAST	CQ_RES_UD_FLAGS_META_FORMAT_HDR_OFFSET
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B records.
-	 * records.
+	 * The combination of this value and meta_format indicates what
+	 * format the metadata field is
 	 */
-	#define CREQ_READ_CONTEXT_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_READ_CONTEXT_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_READ_CONTEXT_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_READ_CONTEXT_TYPE_LAST	CREQ_READ_CONTEXT_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	uint32_t	reserved32;
-	uint8_t	v;
-	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	#define CQ_RES_UD_FLAGS_EXT_META_FORMAT_MASK  UINT32_C(0xc00)
+	#define CQ_RES_UD_FLAGS_EXT_META_FORMAT_SFT   10
+	uint32_t	src_qp_high_srq_or_rq_wr_id;
+	/*
+	 * Opaque value from RQ or SRQ WQE. Used by driver/lib to
+	 * reference the WQE in order to claim the received data
+	 * and reuse the WQE space
 	 */
-	#define CREQ_READ_CONTEXT_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Read the current state of any internal resource context. Can only be issued from a PF. */
-	#define CREQ_READ_CONTEXT_EVENT_READ_CONTEXT UINT32_C(0x85)
-	#define CREQ_READ_CONTEXT_EVENT_LAST	CREQ_READ_CONTEXT_EVENT_READ_CONTEXT
-	uint16_t	reserved16;
-	uint32_t	reserved_32;
-} creq_read_context_t, *pcreq_read_context_t;
-
-/*****************
- * map_tc_to_cos *
- *****************/
-
-
-/* cmdq_map_tc_to_cos (size:192b/24B) */
-
-typedef struct cmdq_map_tc_to_cos {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Map TC to COS. Can only be issued from a PF. */
-	#define CMDQ_MAP_TC_TO_COS_OPCODE_MAP_TC_TO_COS UINT32_C(0x8a)
-	#define CMDQ_MAP_TC_TO_COS_OPCODE_LAST	CMDQ_MAP_TC_TO_COS_OPCODE_MAP_TC_TO_COS
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	/* 1st COS index mapped to RoCE */
-	uint16_t	cos0;
-	/* Don't change this COS. */
-	#define CMDQ_MAP_TC_TO_COS_COS0_NO_CHANGE UINT32_C(0xffff)
-	#define CMDQ_MAP_TC_TO_COS_COS0_LAST	CMDQ_MAP_TC_TO_COS_COS0_NO_CHANGE
-	/* 2nd COS index mapped to RoCE */
-	uint16_t	cos1;
-	/* Disable this COS. */
-	#define CMDQ_MAP_TC_TO_COS_COS1_DISABLE   UINT32_C(0x8000)
-	/* Don't change this COS. */
-	#define CMDQ_MAP_TC_TO_COS_COS1_NO_CHANGE UINT32_C(0xffff)
-	#define CMDQ_MAP_TC_TO_COS_COS1_LAST	CMDQ_MAP_TC_TO_COS_COS1_NO_CHANGE
-	uint32_t	unused_0;
-} cmdq_map_tc_to_cos_t, *pcmdq_map_tc_to_cos_t;
+	#define CQ_RES_UD_SRQ_OR_RQ_WR_ID_MASK UINT32_C(0xfffff)
+	#define CQ_RES_UD_SRQ_OR_RQ_WR_ID_SFT 0
+	/* Upper 8b of the Source QP value from the DETH header. */
+	#define CQ_RES_UD_SRC_QP_HIGH_MASK	UINT32_C(0xff000000)
+	#define CQ_RES_UD_SRC_QP_HIGH_SFT	24
+} cq_res_ud_t, *pcq_res_ud_t;
 
-/* creq_map_tc_to_cos_resp (size:128b/16B) */
+/* Responder UD CQE version 2 */
+/* cq_res_ud_v2 (size:256b/32B) */
 
-typedef struct creq_map_tc_to_cos_resp {
-	uint8_t	type;
+typedef struct cq_res_ud_v2 {
+	uint16_t	length;
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * The length of the message's payload in bytes, stored in
+	 * the SGEs
 	 */
-	#define CREQ_MAP_TC_TO_COS_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_MAP_TC_TO_COS_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_MAP_TC_TO_COS_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_MAP_TC_TO_COS_RESP_TYPE_LAST	CREQ_MAP_TC_TO_COS_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	uint32_t	reserved32;
-	uint8_t	v;
+	#define CQ_RES_UD_V2_LENGTH_MASK UINT32_C(0x3fff)
+	#define CQ_RES_UD_V2_LENGTH_SFT 0
+	/* This is data from the CFA as indicated by the meta_format field. */
+	uint16_t	cfa_metadata0;
+	/* When meta_format=1, this value is the VLAN VID. */
+	#define CQ_RES_UD_V2_CFA_METADATA0_VID_MASK UINT32_C(0xfff)
+	#define CQ_RES_UD_V2_CFA_METADATA0_VID_SFT 0
+	/* When meta_format=1, this value is the VLAN DE. */
+	#define CQ_RES_UD_V2_CFA_METADATA0_DE	UINT32_C(0x1000)
+	/* When meta_format=1, this value is the VLAN PRI. */
+	#define CQ_RES_UD_V2_CFA_METADATA0_PRI_MASK UINT32_C(0xe000)
+	#define CQ_RES_UD_V2_CFA_METADATA0_PRI_SFT 13
+	/* Immediate data in case the imm_flag set. */
+	uint32_t	imm_data;
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * This is an application level ID used to identify the
+	 * QP and its SQ and RQ.
 	 */
-	#define CREQ_MAP_TC_TO_COS_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Map TC to COS response. */
-	#define CREQ_MAP_TC_TO_COS_RESP_EVENT_MAP_TC_TO_COS UINT32_C(0x8a)
-	#define CREQ_MAP_TC_TO_COS_RESP_EVENT_LAST	CREQ_MAP_TC_TO_COS_RESP_EVENT_MAP_TC_TO_COS
-	uint8_t	reserved48[6];
-} creq_map_tc_to_cos_resp_t, *pcreq_map_tc_to_cos_resp_t;
-
-/*****************
- * query_roce_cc *
- *****************/
-
-
-/* cmdq_query_roce_cc (size:128b/16B) */
-
-typedef struct cmdq_query_roce_cc {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Query congestion control. */
-	#define CMDQ_QUERY_ROCE_CC_OPCODE_QUERY_ROCE_CC UINT32_C(0x8d)
-	#define CMDQ_QUERY_ROCE_CC_OPCODE_LAST	CMDQ_QUERY_ROCE_CC_OPCODE_QUERY_ROCE_CC
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-} cmdq_query_roce_cc_t, *pcmdq_query_roce_cc_t;
-
-/* creq_query_roce_cc_resp (size:128b/16B) */
-
-typedef struct creq_query_roce_cc_resp {
-	uint8_t	type;
+	uint64_t	qp_handle;
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * Source MAC address for the UD message placed in the WQE
+	 * that is completed by this CQE.
 	 */
-	#define CREQ_QUERY_ROCE_CC_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_QUERY_ROCE_CC_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_QUERY_ROCE_CC_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_QUERY_ROCE_CC_RESP_TYPE_LAST	CREQ_QUERY_ROCE_CC_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Side buffer size in 16-byte units */
-	uint32_t	size;
-	uint8_t	v;
+	uint16_t	src_mac[3];
+	/* Lower 16b of the Source QP value from the DETH header. */
+	uint16_t	src_qp_low;
+	uint8_t	cqe_type_toggle;
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * Indicate valid completion - written by the chip. Cumulus
+	 * toggle this bit each time it finished consuming all PBL
+	 * entries
 	 */
-	#define CREQ_QUERY_ROCE_CC_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Query congestion control response. */
-	#define CREQ_QUERY_ROCE_CC_RESP_EVENT_QUERY_ROCE_CC UINT32_C(0x8d)
-	#define CREQ_QUERY_ROCE_CC_RESP_EVENT_LAST	CREQ_QUERY_ROCE_CC_RESP_EVENT_QUERY_ROCE_CC
-	uint8_t	reserved48[6];
-} creq_query_roce_cc_resp_t, *pcreq_query_roce_cc_resp_t;
-
-/* Query congestion control command response side buffer structure. */
-/* creq_query_roce_cc_resp_sb (size:256b/32B) */
-
-typedef struct creq_query_roce_cc_resp_sb {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Query congestion control response. */
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_OPCODE_QUERY_ROCE_CC UINT32_C(0x8d)
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_OPCODE_LAST	CREQ_QUERY_ROCE_CC_RESP_SB_OPCODE_QUERY_ROCE_CC
-	/* Status of the response. */
+	#define CQ_RES_UD_V2_TOGGLE	UINT32_C(0x1)
+	/* This field defines the type of CQE. */
+	#define CQ_RES_UD_V2_CQE_TYPE_MASK  UINT32_C(0x1e)
+	#define CQ_RES_UD_V2_CQE_TYPE_SFT   1
+	/*
+	 * Responder UD Completion - This is used for both RQ and SRQ
+	 * completion for UD service QPs.
+	 */
+		#define CQ_RES_UD_V2_CQE_TYPE_RES_UD  (UINT32_C(0x2) << 1)
+		#define CQ_RES_UD_V2_CQE_TYPE_LAST   CQ_RES_UD_V2_CQE_TYPE_RES_UD
+	/* This field indicates the status for the CQE. */
 	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	uint8_t	enable_cc;
-	/* Enable. */
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_ENABLE_CC	UINT32_C(0x1)
-	/* unused7 is 7 b */
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_UNUSED7_MASK  UINT32_C(0xfe)
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_UNUSED7_SFT   1
-	uint8_t	tos_dscp_tos_ecn;
-	/* IP TOS ECN. */
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TOS_ECN_MASK UINT32_C(0x3)
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TOS_ECN_SFT  0
-	/* IP TOS DSCP. */
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TOS_DSCP_MASK UINT32_C(0xfc)
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TOS_DSCP_SFT 2
-	/* Congestion Probability averaging factor. */
-	uint8_t	g;
-	/* Number of phases in Fast Recovery and Active Increase. */
-	uint8_t	num_phases_per_state;
-	/* The starting value of rate. */
-	uint16_t	init_cr;
-	/* The starting value of target rate. */
-	uint16_t	init_tr;
-	uint8_t	alt_vlan_pcp;
-	/* Alternate vlan pcp value for CNP packets. */
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_ALT_VLAN_PCP_MASK UINT32_C(0x7)
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_ALT_VLAN_PCP_SFT 0
-	/* rsvd1 is 5 b */
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_RSVD1_MASK	UINT32_C(0xf8)
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_RSVD1_SFT	3
-	uint8_t	alt_tos_dscp;
-	/* Alternate IP TOS DSCP. */
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_ALT_TOS_DSCP_MASK UINT32_C(0x3f)
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_ALT_TOS_DSCP_SFT 0
-	/* rsvd4 is 2 b */
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_RSVD4_MASK	UINT32_C(0xc0)
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_RSVD4_SFT	6
-	uint8_t	cc_mode;
-	/* DCTCP CC algorithm. */
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_CC_MODE_DCTCP	UINT32_C(0x0)
 	/*
-	 * Probabilistic marking CC algorithm. On chips with CC Gen 0
-	 * support this will be TCP CC algorithm.
+	 * This indicates that the completion is without error.
+	 * All fields are valid.
 	 */
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_CC_MODE_PROBABILISTIC UINT32_C(0x1)
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_CC_MODE_LAST	CREQ_QUERY_ROCE_CC_RESP_SB_CC_MODE_PROBABILISTIC
-	/* Specifies the RoCE Tx Queue to use for sending CNP packets. */
-	uint8_t	tx_queue;
-	uint16_t	rtt;
-	/* Round trip time in units of usecs */
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_RTT_MASK  UINT32_C(0x3fff)
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_RTT_SFT   0
-	/* rsvd5 is 2 b */
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_RSVD5_MASK UINT32_C(0xc000)
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_RSVD5_SFT 14
-	uint16_t	tcp_cp;
-	/* The value used as CP when cc_mode is 1(TCP) */
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TCP_CP_MASK UINT32_C(0x3ff)
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TCP_CP_SFT 0
-	/* rsvd6 is 6 b */
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_RSVD6_MASK UINT32_C(0xfc00)
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_RSVD6_SFT  10
-	/* Inactivity time after which QP CC parameters are initialized */
-	uint16_t	inactivity_th;
-	/* Number of packets per phase. Max is 255. */
-	uint8_t	pkts_per_phase;
-	/* Amount of time per phase in units of ms. Max is 15 */
-	uint8_t	time_per_phase;
-	uint32_t	reserved32;
-} creq_query_roce_cc_resp_sb_t, *pcreq_query_roce_cc_resp_sb_t;
-
-/*
- * TLV encapsulated Query congestion control command response
- * side buffer, with extended TLV record included for specifying
- * the extended configuration for CC level 1.
- */
-/* creq_query_roce_cc_resp_sb_tlv (size:384b/48B) */
-
-typedef struct creq_query_roce_cc_resp_sb_tlv {
+	#define CQ_RES_UD_V2_STATUS_OK			UINT32_C(0x0)
 	/*
-	 * The command discriminator is used to differentiate between various
-	 * types of HWRM messages. This includes legacy HWRM and RoCE slowpath
-	 * command messages as well as newer TLV encapsulated HWRM commands.
+	 * This indicates that write access was not allowed for
+	 * at least one of the SGEs in the WQE.
 	 *
-	 * For TLV encapsulated messages this field must be 0x8000.
+	 * This is a fatal error. Only the srq_or_rq_wr_id is field
+	 * is valid.
 	 */
-	uint16_t	cmd_discr;
-	uint8_t	reserved_8b;
-	uint8_t	tlv_flags;
+	#define CQ_RES_UD_V2_STATUS_LOCAL_ACCESS_ERROR	UINT32_C(0x1)
 	/*
-	 * Indicates the presence of additional TLV encapsulated data
-	 * follows this TLV.
+	 * This indicates that the packet was too long for the WQE
+	 * provided on the SRQ/RQ.
+	 *
+	 * This is not a fatal error. All the fields are valid.
 	 */
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_TLV_FLAGS_MORE	UINT32_C(0x1)
-	/* Last TLV in a sequence of TLVs. */
-		#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_TLV_FLAGS_MORE_LAST	UINT32_C(0x0)
-	/* More TLVs follow this TLV. */
-		#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_TLV_FLAGS_MORE_NOT_LAST  UINT32_C(0x1)
+	#define CQ_RES_UD_V2_STATUS_HW_LOCAL_LENGTH_ERR	UINT32_C(0x2)
+	/* LOCAL_PROTECTION_ERR is 3 */
+	#define CQ_RES_UD_V2_STATUS_LOCAL_PROTECTION_ERR	UINT32_C(0x3)
+	/* LOCAL_QP_OPERATION_ERR is 4 */
+	#define CQ_RES_UD_V2_STATUS_LOCAL_QP_OPERATION_ERR   UINT32_C(0x4)
+	/* MEMORY_MGT_OPERATION_ERR is 5 */
+	#define CQ_RES_UD_V2_STATUS_MEMORY_MGT_OPERATION_ERR UINT32_C(0x5)
+	/* WORK_REQUEST_FLUSHED_ERR is 7 */
+	#define CQ_RES_UD_V2_STATUS_WORK_REQUEST_FLUSHED_ERR UINT32_C(0x7)
+	/* HW_FLUSH_ERR is 8 */
+	#define CQ_RES_UD_V2_STATUS_HW_FLUSH_ERR		UINT32_C(0x8)
+	#define CQ_RES_UD_V2_STATUS_LAST			CQ_RES_UD_V2_STATUS_HW_FLUSH_ERR
+	uint16_t	flags;
 	/*
-	 * When an HWRM receiver detects a TLV type that it does not
-	 * support with the TLV required flag set, the receiver must
-	 * reject the HWRM message with an error code indicating an
-	 * unsupported TLV type.
+	 * This flag indicates that the completion is for a SRQ entry
+	 * rather than for an RQ entry.
 	 */
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_TLV_FLAGS_REQUIRED	UINT32_C(0x2)
-	/* No */
-		#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_TLV_FLAGS_REQUIRED_NO	(UINT32_C(0x0) << 1)
-	/* Yes */
-		#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_TLV_FLAGS_REQUIRED_YES   (UINT32_C(0x1) << 1)
-		#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_TLV_FLAGS_REQUIRED_LAST CREQ_QUERY_ROCE_CC_RESP_SB_TLV_TLV_FLAGS_REQUIRED_YES
+	#define CQ_RES_UD_V2_FLAGS_SRQ			UINT32_C(0x1)
+	/* CQE relates to RQ WQE. */
+		#define CQ_RES_UD_V2_FLAGS_SRQ_RQ		UINT32_C(0x0)
+	/* CQE relates to SRQ WQE. */
+		#define CQ_RES_UD_V2_FLAGS_SRQ_SRQ		UINT32_C(0x1)
+		#define CQ_RES_UD_V2_FLAGS_SRQ_LAST		CQ_RES_UD_V2_FLAGS_SRQ_SRQ
+	/* Immediate data indicator */
+	#define CQ_RES_UD_V2_FLAGS_IMM			UINT32_C(0x2)
+	#define CQ_RES_UD_V2_FLAGS_UNUSED_MASK		UINT32_C(0xc)
+	#define CQ_RES_UD_V2_FLAGS_UNUSED_SFT		2
+	#define CQ_RES_UD_V2_FLAGS_ROCE_IP_VER_MASK	UINT32_C(0x30)
+	#define CQ_RES_UD_V2_FLAGS_ROCE_IP_VER_SFT	4
+	/* RoCEv1 Message */
+		#define CQ_RES_UD_V2_FLAGS_ROCE_IP_VER_V1	(UINT32_C(0x0) << 4)
+	/* RoCEv2 IPv4 Message */
+		#define CQ_RES_UD_V2_FLAGS_ROCE_IP_VER_V2IPV4	(UINT32_C(0x2) << 4)
+	/* RoCEv2 IPv6 Message */
+		#define CQ_RES_UD_V2_FLAGS_ROCE_IP_VER_V2IPV6	(UINT32_C(0x3) << 4)
+		#define CQ_RES_UD_V2_FLAGS_ROCE_IP_VER_LAST	CQ_RES_UD_V2_FLAGS_ROCE_IP_VER_V2IPV6
+	/* The field indicates what format the metadata field is. */
+	#define CQ_RES_UD_V2_FLAGS_META_FORMAT_MASK	UINT32_C(0x3c0)
+	#define CQ_RES_UD_V2_FLAGS_META_FORMAT_SFT	6
+	/* No metadata information. Value is zero. */
+		#define CQ_RES_UD_V2_FLAGS_META_FORMAT_NONE	(UINT32_C(0x0) << 6)
 	/*
-	 * This field defines the TLV type value which is divided into
-	 * two ranges to differentiate between global and local TLV types.
-	 * Global TLV types must be unique across all defined TLV types.
-	 * Local TLV types are valid only for extensions to a given
-	 * HWRM message and may be repeated across different HWRM message
-	 * types. There is a direct correlation of each HWRM message type
-	 * to a single global TLV type value.
-	 *
-	 * Global TLV range: `0 - (63k-1)`
-	 *
-	 * Local TLV range: `63k - (64k-1)`
+	 * The {metadata1, metadata0} fields contain the vtag
+	 * information: - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0],
+	 * de, vid[11:0]} The metadata2 field contains the table scope
+	 * and action record pointer. - metadata2[25:0] contains the
+	 * action record pointer. - metadata2[31:26] contains the table
+	 * scope.
 	 */
-	uint16_t	tlv_type;
+		#define CQ_RES_UD_V2_FLAGS_META_FORMAT_ACT_REC_PTR  (UINT32_C(0x1) << 6)
 	/*
-	 * Length of the message data encapsulated by this TLV in bytes.
-	 * This length does not include the size of the TLV header itself
-	 * and it must be an integer multiple of 8B.
+	 * The {metadata1, metadata0} fields contain the vtag
+	 * information:
+	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0], de, vid[11:0]}
+	 * The metadata2 field contains the Tunnel ID
+	 * value, justified to LSB. i
+	 * - VXLAN = VNI[23:0] -> VXLAN Network ID
+	 * - Geneve (NGE) = VNI[23:0] a-> Virtual Network Identifier
+	 * - NVGRE = TNI[23:0] -> Tenant Network ID
+	 * - GRE = KEY[31:0] -> key field with bit mask. zero if K=0
+	 * - IPv4 = 0 (not populated)
+	 * - IPv6 = Flow Label[19:0]
+	 * - PPPoE = sessionID[15:0]
+	 * - MPLs = Outer label[19:0]
+	 * - UPAR = Selected[31:0] with bit mask
 	 */
-	uint16_t	length;
+		#define CQ_RES_UD_V2_FLAGS_META_FORMAT_TUNNEL_ID	(UINT32_C(0x2) << 6)
 	/*
-	 * Size of the tlv encapsulated response,
-	 * including all tlvs and extension data in 16-byte units.
+	 * The {metadata1, metadata0} fields contain the vtag
+	 * information:
+	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0],de, vid[11:0]}
+	 * The metadata2 field contains the 32b metadata from the
+	 * prepended header (chdr_data).
 	 */
-	uint8_t	total_size;
-	uint8_t	reserved56[7];
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Query congestion control response. */
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_OPCODE_QUERY_ROCE_CC UINT32_C(0x8d)
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_OPCODE_LAST	CREQ_QUERY_ROCE_CC_RESP_SB_TLV_OPCODE_QUERY_ROCE_CC
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	uint8_t	enable_cc;
-	/* Enable. */
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_ENABLE_CC	UINT32_C(0x1)
-	/* unused7 is 7 b */
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_UNUSED7_MASK  UINT32_C(0xfe)
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_UNUSED7_SFT   1
-	uint8_t	tos_dscp_tos_ecn;
-	/* IP TOS ECN. */
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_TOS_ECN_MASK UINT32_C(0x3)
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_TOS_ECN_SFT  0
-	/* IP TOS DSCP. */
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_TOS_DSCP_MASK UINT32_C(0xfc)
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_TOS_DSCP_SFT 2
-	/* Congestion Probability averaging factor. */
-	uint8_t	g;
-	/* Number of phases in Fast Recovery and Active Increase. */
-	uint8_t	num_phases_per_state;
-	/* The starting value of rate. */
-	uint16_t	init_cr;
-	/* The starting value of target rate. */
-	uint16_t	init_tr;
-	uint8_t	alt_vlan_pcp;
-	/* Alternate vlan pcp value for CNP packets. */
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_ALT_VLAN_PCP_MASK UINT32_C(0x7)
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_ALT_VLAN_PCP_SFT 0
-	/* rsvd1 is 5 b */
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_RSVD1_MASK	UINT32_C(0xf8)
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_RSVD1_SFT	3
-	uint8_t	alt_tos_dscp;
-	/* Alternate IP TOS DSCP. */
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_ALT_TOS_DSCP_MASK UINT32_C(0x3f)
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_ALT_TOS_DSCP_SFT 0
-	/* rsvd4 is 2 b */
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_RSVD4_MASK	UINT32_C(0xc0)
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_RSVD4_SFT	6
-	uint8_t	cc_mode;
-	/* DCTCP CC algorithm. */
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_CC_MODE_DCTCP	UINT32_C(0x0)
+		#define CQ_RES_UD_V2_FLAGS_META_FORMAT_CHDR_DATA	(UINT32_C(0x3) << 6)
 	/*
-	 * Probabilistic marking CC algorithm. On chips with CC Gen 0
-	 * support this will be TCP CC algorithm.
+	 * If ext_meta_format is equal to 1, the metadata field contains
+	 * the outer_l3_offset and lower 7 bits of the inner_l2_offset,
+	 * - metadata[8:0] contains the outer_l3_offset.
+	 * - metadata[15:9] contains the inner_l2_offset[6:0]
 	 */
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_CC_MODE_PROBABILISTIC UINT32_C(0x1)
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_CC_MODE_LAST	CREQ_QUERY_ROCE_CC_RESP_SB_TLV_CC_MODE_PROBABILISTIC
-	/* Specifies the RoCE Tx Queue to use for sending CNP packets. */
-	uint8_t	tx_queue;
-	uint16_t	rtt;
-	/* Round trip time in units of usecs */
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_RTT_MASK  UINT32_C(0x3fff)
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_RTT_SFT   0
-	/* rsvd5 is 2 b */
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_RSVD5_MASK UINT32_C(0xc000)
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_RSVD5_SFT 14
-	uint16_t	tcp_cp;
-	/* The value used as CP when cc_mode is 1(TCP) */
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_TCP_CP_MASK UINT32_C(0x3ff)
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_TCP_CP_SFT 0
-	/* rsvd6 is 6 b */
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_RSVD6_MASK UINT32_C(0xfc00)
-	#define CREQ_QUERY_ROCE_CC_RESP_SB_TLV_RSVD6_SFT  10
-	/* Inactivity time after which QP CC parameters are initialized */
-	uint16_t	inactivity_th;
-	/* Number of packets per phase. Max is 255. */
-	uint8_t	pkts_per_phase;
-	/* Amount of time per phase in units of ms. Max is 15 */
-	uint8_t	time_per_phase;
-	uint32_t	reserved32;
-} creq_query_roce_cc_resp_sb_tlv_t, *pcreq_query_roce_cc_resp_sb_tlv_t;
+		#define CQ_RES_UD_V2_FLAGS_META_FORMAT_HDR_OFFSET   (UINT32_C(0x4) << 6)
+		#define CQ_RES_UD_V2_FLAGS_META_FORMAT_LAST	CQ_RES_UD_V2_FLAGS_META_FORMAT_HDR_OFFSET
+	uint32_t	src_qp_high_srq_or_rq_wr_id;
+	/*
+	 * Opaque value from RQ or SRQ WQE. Used by driver/lib to
+	 * reference the WQE in order to claim the received data
+	 * and reuse the WQE space
+	 */
+	#define CQ_RES_UD_V2_SRQ_OR_RQ_WR_ID_MASK	UINT32_C(0xfffff)
+	#define CQ_RES_UD_V2_SRQ_OR_RQ_WR_ID_SFT		0
+	#define CQ_RES_UD_V2_CFA_METADATA1_MASK		UINT32_C(0xf00000)
+	#define CQ_RES_UD_V2_CFA_METADATA1_SFT		20
+	/* When meta_format != 0, this value is the VLAN TPID_SEL. */
+	#define CQ_RES_UD_V2_CFA_METADATA1_TPID_SEL_MASK	UINT32_C(0x700000)
+	#define CQ_RES_UD_V2_CFA_METADATA1_TPID_SEL_SFT	20
+	/* 0x88a8 */
+		#define CQ_RES_UD_V2_CFA_METADATA1_TPID_SEL_TPID88A8   (UINT32_C(0x0) << 20)
+	/* 0x8100 */
+		#define CQ_RES_UD_V2_CFA_METADATA1_TPID_SEL_TPID8100   (UINT32_C(0x1) << 20)
+	/* 0x9100 */
+		#define CQ_RES_UD_V2_CFA_METADATA1_TPID_SEL_TPID9100   (UINT32_C(0x2) << 20)
+	/* 0x9200 */
+		#define CQ_RES_UD_V2_CFA_METADATA1_TPID_SEL_TPID9200   (UINT32_C(0x3) << 20)
+	/* 0x9300 */
+		#define CQ_RES_UD_V2_CFA_METADATA1_TPID_SEL_TPID9300   (UINT32_C(0x4) << 20)
+	/* Value programmed in CFA VLANTPID register. */
+		#define CQ_RES_UD_V2_CFA_METADATA1_TPID_SEL_TPIDCFG	(UINT32_C(0x5) << 20)
+		#define CQ_RES_UD_V2_CFA_METADATA1_TPID_SEL_LAST	CQ_RES_UD_V2_CFA_METADATA1_TPID_SEL_TPIDCFG
+	/* When meta_format != 0, this value is the VLAN valid. */
+	#define CQ_RES_UD_V2_CFA_METADATA1_VALID		UINT32_C(0x800000)
+	/* Upper 8b of the Source QP value from the DETH header. */
+	#define CQ_RES_UD_V2_SRC_QP_HIGH_MASK		UINT32_C(0xff000000)
+	#define CQ_RES_UD_V2_SRC_QP_HIGH_SFT		24
+} cq_res_ud_v2_t, *pcq_res_ud_v2_t;
 
-/* creq_query_roce_cc_gen1_resp_sb_tlv (size:704b/88B) */
+/* Responder UD with CFA CQE */
+/* cq_res_ud_cfa (size:256b/32B) */
 
-typedef struct creq_query_roce_cc_gen1_resp_sb_tlv {
+typedef struct cq_res_ud_cfa {
+	uint16_t	length;
 	/*
-	 * The command discriminator is used to differentiate between various
-	 * types of HWRM messages. This includes legacy HWRM and RoCE slowpath
-	 * command messages as well as newer TLV encapsulated HWRM commands.
-	 *
-	 * For TLV encapsulated messages this field must be 0x8000.
+	 * The length of the message's payload in bytes, stored in
+	 * the SGEs
 	 */
-	uint16_t	cmd_discr;
-	uint8_t	reserved_8b;
-	uint8_t	tlv_flags;
+	#define CQ_RES_UD_CFA_LENGTH_MASK UINT32_C(0x3fff)
+	#define CQ_RES_UD_CFA_LENGTH_SFT 0
 	/*
-	 * Indicates the presence of additional TLV encapsulated data
-	 * follows this TLV.
+	 * This field identifies the CFA action rule that was used
+	 * for this packet.
 	 */
-	#define CREQ_QUERY_ROCE_CC_GEN1_RESP_SB_TLV_TLV_FLAGS_MORE	UINT32_C(0x1)
-	/* Last TLV in a sequence of TLVs. */
-		#define CREQ_QUERY_ROCE_CC_GEN1_RESP_SB_TLV_TLV_FLAGS_MORE_LAST	UINT32_C(0x0)
-	/* More TLVs follow this TLV. */
-		#define CREQ_QUERY_ROCE_CC_GEN1_RESP_SB_TLV_TLV_FLAGS_MORE_NOT_LAST  UINT32_C(0x1)
+	uint16_t	cfa_code;
+	/* Immediate data in case the imm_flag set. */
+	uint32_t	imm_data;
+	uint32_t	qid;
 	/*
-	 * When an HWRM receiver detects a TLV type that it does not
-	 * support with the TLV required flag set, the receiver must
-	 * reject the HWRM message with an error code indicating an
-	 * unsupported TLV type.
+	 * This value indicates the QPID associated with this operation.
+	 * The driver will use the qid from this CQE to map a QP handle
+	 * in the completion record returned to the application.
 	 */
-	#define CREQ_QUERY_ROCE_CC_GEN1_RESP_SB_TLV_TLV_FLAGS_REQUIRED	UINT32_C(0x2)
-	/* No */
-		#define CREQ_QUERY_ROCE_CC_GEN1_RESP_SB_TLV_TLV_FLAGS_REQUIRED_NO	(UINT32_C(0x0) << 1)
-	/* Yes */
-		#define CREQ_QUERY_ROCE_CC_GEN1_RESP_SB_TLV_TLV_FLAGS_REQUIRED_YES   (UINT32_C(0x1) << 1)
-		#define CREQ_QUERY_ROCE_CC_GEN1_RESP_SB_TLV_TLV_FLAGS_REQUIRED_LAST CREQ_QUERY_ROCE_CC_GEN1_RESP_SB_TLV_TLV_FLAGS_REQUIRED_YES
+	#define CQ_RES_UD_CFA_QID_MASK UINT32_C(0xfffff)
+	#define CQ_RES_UD_CFA_QID_SFT 0
 	/*
-	 * This field defines the TLV type value which is divided into
-	 * two ranges to differentiate between global and local TLV types.
-	 * Global TLV types must be unique across all defined TLV types.
-	 * Local TLV types are valid only for extensions to a given
-	 * HWRM message and may be repeated across different HWRM message
-	 * types. There is a direct correlation of each HWRM message type
-	 * to a single global TLV type value.
+	 * This is data from the CFA or VNIC block as indicated by the
+	 * ext_meta_format and meta_format fields.
+	 */
+	uint32_t	cfa_metadata;
+	/* When meta_format=1, this value is the VLAN VID. */
+	#define CQ_RES_UD_CFA_CFA_METADATA_VID_MASK UINT32_C(0xfff)
+	#define CQ_RES_UD_CFA_CFA_METADATA_VID_SFT  0
+	/* When meta_format=1, this value is the VLAN DE. */
+	#define CQ_RES_UD_CFA_CFA_METADATA_DE	UINT32_C(0x1000)
+	/* When meta_format=1, this value is the VLAN PRI. */
+	#define CQ_RES_UD_CFA_CFA_METADATA_PRI_MASK UINT32_C(0xe000)
+	#define CQ_RES_UD_CFA_CFA_METADATA_PRI_SFT  13
+	/* When meta_format=1, this value is the VLAN TPID. */
+	#define CQ_RES_UD_CFA_CFA_METADATA_TPID_MASK UINT32_C(0xffff0000)
+	#define CQ_RES_UD_CFA_CFA_METADATA_TPID_SFT 16
+	/*
+	 * Source MAC address for the UD message placed in the WQE
+	 * that is completed by this CQE.
+	 */
+	uint16_t	src_mac[3];
+	/* Lower 16b of the Source QP value from the DETH header. */
+	uint16_t	src_qp_low;
+	uint8_t	cqe_type_toggle;
+	/*
+	 * Indicate valid completion - written by the chip. Cumulus
+	 * toggle this bit each time it finished consuming all PBL
+	 * entries
+	 */
+	#define CQ_RES_UD_CFA_TOGGLE		UINT32_C(0x1)
+	/* This field defines the type of CQE. */
+	#define CQ_RES_UD_CFA_CQE_TYPE_MASK	UINT32_C(0x1e)
+	#define CQ_RES_UD_CFA_CQE_TYPE_SFT	1
+	/*
+	 * Responder UD Completion with CFA - This is used for both RQ
+	 * and SRQ completion for UD service QPs. It includes cfa fields
+	 * (some of which carry VLAN information), in place of the QP
+	 * handle. It is also used for QP1 QPs that are treated as UD.
+	 */
+		#define CQ_RES_UD_CFA_CQE_TYPE_RES_UD_CFA  (UINT32_C(0x4) << 1)
+		#define CQ_RES_UD_CFA_CQE_TYPE_LAST	CQ_RES_UD_CFA_CQE_TYPE_RES_UD_CFA
+	/* This field indicates the status for the CQE. */
+	uint8_t	status;
+	/*
+	 * This indicates that the completion is without error.
+	 * All fields are valid.
+	 */
+	#define CQ_RES_UD_CFA_STATUS_OK			UINT32_C(0x0)
+	/*
+	 * This indicates that write access was not allowed for
+	 * at least one of the SGEs in the WQE.
 	 *
-	 * Global TLV range: `0 - (63k-1)`
+	 * This is a fatal error. Only the srq_or_rq_wr_id is field
+	 * is valid.
+	 */
+	#define CQ_RES_UD_CFA_STATUS_LOCAL_ACCESS_ERROR	UINT32_C(0x1)
+	/*
+	 * This indicates that the packet was too long for the WQE
+	 * provided on the SRQ/RQ.
 	 *
-	 * Local TLV range: `63k - (64k-1)`
+	 * This is not a fatal error. All the fields are valid.
 	 */
-	uint16_t	tlv_type;
+	#define CQ_RES_UD_CFA_STATUS_HW_LOCAL_LENGTH_ERR	UINT32_C(0x2)
+	/* LOCAL_PROTECTION_ERR is 3 */
+	#define CQ_RES_UD_CFA_STATUS_LOCAL_PROTECTION_ERR	UINT32_C(0x3)
+	/* LOCAL_QP_OPERATION_ERR is 4 */
+	#define CQ_RES_UD_CFA_STATUS_LOCAL_QP_OPERATION_ERR   UINT32_C(0x4)
+	/* MEMORY_MGT_OPERATION_ERR is 5 */
+	#define CQ_RES_UD_CFA_STATUS_MEMORY_MGT_OPERATION_ERR UINT32_C(0x5)
+	/* WORK_REQUEST_FLUSHED_ERR is 7 */
+	#define CQ_RES_UD_CFA_STATUS_WORK_REQUEST_FLUSHED_ERR UINT32_C(0x7)
+	/* HW_FLUSH_ERR is 8 */
+	#define CQ_RES_UD_CFA_STATUS_HW_FLUSH_ERR		UINT32_C(0x8)
+	#define CQ_RES_UD_CFA_STATUS_LAST			CQ_RES_UD_CFA_STATUS_HW_FLUSH_ERR
+	uint16_t	flags;
 	/*
-	 * Length of the message data encapsulated by this TLV in bytes.
-	 * This length does not include the size of the TLV header itself
-	 * and it must be an integer multiple of 8B.
+	 * This flag indicates that the completion is for a SRQ entry
+	 * rather than for an RQ entry.
 	 */
-	uint16_t	length;
-	uint64_t	reserved64;
-	/* High order bits of inactivity threshold. */
-	uint16_t	inactivity_th_hi;
-	/* The number of uS between generation of CNPs when cc_mode is probabilistic marking. */
-	uint16_t	min_time_between_cnps;
-	/* The starting value of congestion probability. Input range is 0 - 1023. */
-	uint16_t	init_cp;
+	#define CQ_RES_UD_CFA_FLAGS_SRQ		UINT32_C(0x1)
+	/* CQE relates to RQ WQE. */
+		#define CQ_RES_UD_CFA_FLAGS_SRQ_RQ		UINT32_C(0x0)
+	/* CQE relates to SRQ WQE. */
+		#define CQ_RES_UD_CFA_FLAGS_SRQ_SRQ		UINT32_C(0x1)
+		#define CQ_RES_UD_CFA_FLAGS_SRQ_LAST		CQ_RES_UD_CFA_FLAGS_SRQ_SRQ
+	/* Immediate data indicator */
+	#define CQ_RES_UD_CFA_FLAGS_IMM		UINT32_C(0x2)
+	#define CQ_RES_UD_CFA_FLAGS_UNUSED_MASK	UINT32_C(0xc)
+	#define CQ_RES_UD_CFA_FLAGS_UNUSED_SFT		2
+	#define CQ_RES_UD_CFA_FLAGS_ROCE_IP_VER_MASK	UINT32_C(0x30)
+	#define CQ_RES_UD_CFA_FLAGS_ROCE_IP_VER_SFT	4
+	/* RoCEv1 Message */
+		#define CQ_RES_UD_CFA_FLAGS_ROCE_IP_VER_V1	(UINT32_C(0x0) << 4)
+	/* RoCEv2 IPv4 Message */
+		#define CQ_RES_UD_CFA_FLAGS_ROCE_IP_VER_V2IPV4	(UINT32_C(0x2) << 4)
+	/* RoCEv2 IPv6 Message */
+		#define CQ_RES_UD_CFA_FLAGS_ROCE_IP_VER_V2IPV6	(UINT32_C(0x3) << 4)
+		#define CQ_RES_UD_CFA_FLAGS_ROCE_IP_VER_LAST	CQ_RES_UD_CFA_FLAGS_ROCE_IP_VER_V2IPV6
 	/*
-	 * In tr_update_mode 0, Target Rate (TR) is updated to
-	 * halfway between the Current Rate (CR) before and after reduction.
-	 * In tr_update_mode 1, TR is updated to CR's value before reduction.
+	 * The combination of this value and ext_meta_format indicates
+	 * what format the metadata field is.
 	 */
-	uint8_t	tr_update_mode;
+	#define CQ_RES_UD_CFA_FLAGS_META_FORMAT_MASK	UINT32_C(0x3c0)
+	#define CQ_RES_UD_CFA_FLAGS_META_FORMAT_SFT	6
 	/*
-	 * Determine for how many RTTs with CNPs in a row, TR is being updated.
-	 * 0: TR is updated when QPC. rtts_with_cnps == 0
-	 * 1-6: TR is updated if QPC. rtts_with_cnps <= tr_update_cycles
-	 * 7: TR is updated on all reductions.
+	 * If ext_meta_format is equal to 0, there is no metadata
+	 * information. Value is zero.
 	 */
-	uint8_t	tr_update_cycles;
-	/* Number of RTTs in Fast Recovery stage. */
-	uint8_t	fr_num_rtts;
-	/* Time increment to increase TR in active increase phase. */
-	uint8_t	ai_rate_increase;
+		#define CQ_RES_UD_CFA_FLAGS_META_FORMAT_NONE	(UINT32_C(0x0) << 6)
 	/*
-	 * Indicates for how many RTTs with CNPs after the first one
-	 * to not reduce rate even if CNPs are received.
+	 * If ext_meta_format is equal to 0, the metadata field contains
+	 * the VLAN tag and TPID value.
+	 * - metadata[11:0] contains the vlan VID value.
+	 * - metadata[12] contains the vlan DE value.
+	 * - metadata[15:13] contains the vlan PRI value.
+	 * - metadata[31:16] contains the vlan TPID value.
 	 */
-	uint16_t	reduction_relax_rtts_th;
+		#define CQ_RES_UD_CFA_FLAGS_META_FORMAT_VLAN	(UINT32_C(0x1) << 6)
 	/*
-	 * For low rates, additional number of RTTS with CNPs
-	 * for which no rate reduction is made.
-	 * num_bits: 14
+	 * If ext_meta_format is equal to 1, the metadata field contains
+	 * the Tunnel ID value, justified to LSB.
+	 * - VXLAN = VNI[23:0] -> VXLAN Network ID
+	 * - Geneve (NGE) = VNI[23:0] -> Virtual Network Identifier
+	 * - NVGRE = TNI[23:0] -> Tenant Network ID
+	 * - GRE = KEY[31:0] -> key field with bit mask. zero if K = 0
+	 * - IPV4 = 0 (not populated)
+	 * - IPV6 = Flow Label[19:0]
+	 * - PPPoE = sessionID[15:0]
+	 * - MPLs = Outer label[19:0]
+	 * - UPAR = Selected[31:0] with bit mask
 	 */
-	uint16_t	additional_relax_cr_th;
+		#define CQ_RES_UD_CFA_FLAGS_META_FORMAT_TUNNEL_ID   (UINT32_C(0x2) << 6)
 	/*
-	 * If CR is less than or equal to this value,
-	 * then the actual CR average is set to this value
-	 * (shifted by bw_avg_weight).
+	 * if ext_meta_format is equal to 1, metadata field contains
+	 * 16b metadata from the prepended header (chdr_data).
 	 */
-	uint16_t	cr_min_th;
-	/* Log based averaging weight for QPC variable actual_cr_avg. */
-	uint8_t	bw_avg_weight;
+		#define CQ_RES_UD_CFA_FLAGS_META_FORMAT_CHDR_DATA   (UINT32_C(0x3) << 6)
 	/*
-	 * Used to compare CR to this factor times QPC.actual_cr_average
-	 * as a reduction reference. Values between 0 and 6 represent factor of
-	 * 1.125, 1.25, 1.5, 1.75, 2, 2.25, 2.5 respectively.
+	 * If ext_meta_format is equal to 1, the metadata field contains
+	 * the outer_l3_offset, inner_l2_offset, inner_l3_offset, and
+	 * inner_l4_size.
+	 * - metadata[8:0] contains the outer_l3_offset.
+	 * - metadata[17:9] contains the inner_l2_offset.
+	 * - metadata[26:18] contains the inner_l3_offset.
+	 * - metadata[31:27] contains the inner_l4_size.
 	 */
-	uint8_t	actual_cr_factor;
-	/* The level of CR above which CP is set to maximum level. */
-	uint16_t	max_cp_cr_th;
+		#define CQ_RES_UD_CFA_FLAGS_META_FORMAT_HDR_OFFSET  (UINT32_C(0x4) << 6)
+		#define CQ_RES_UD_CFA_FLAGS_META_FORMAT_LAST	CQ_RES_UD_CFA_FLAGS_META_FORMAT_HDR_OFFSET
 	/*
-	 * Enable adding fraction of CR to CP.
-	 * 0 for disable, 1 for enable.
+	 * The combination of this value and meta_format indicates what
+	 * format the metadata field is
 	 */
-	uint8_t	cp_bias_en;
-	/* Log based fraction of cr to add to CP when cp_bias_en is 1. */
-	uint8_t	cp_bias;
+	#define CQ_RES_UD_CFA_FLAGS_EXT_META_FORMAT_MASK  UINT32_C(0xc00)
+	#define CQ_RES_UD_CFA_FLAGS_EXT_META_FORMAT_SFT   10
+	uint32_t	src_qp_high_srq_or_rq_wr_id;
 	/*
-	 * The value of ECN bits in a CNP packet generated by hardware.
-	 * ECN-Capabale Transport (ECT) codepoints supported include:
-	 * 0 for not_ect, 1 for ect_0, 2 for ect_1
+	 * Opaque value from RQ or SRQ WQE. Used by driver/lib to
+	 * reference the WQE in order to claim the received data
+	 * and reuse the WQE space
 	 */
-	uint8_t	cnp_ecn;
-	/* Not ECN capable Transport */
-	#define CREQ_QUERY_ROCE_CC_GEN1_RESP_SB_TLV_CNP_ECN_NOT_ECT UINT32_C(0x0)
-	/* ECN Capable Transport-1 */
-	#define CREQ_QUERY_ROCE_CC_GEN1_RESP_SB_TLV_CNP_ECN_ECT_1   UINT32_C(0x1)
-	/* ECN Capable Transport-0 */
-	#define CREQ_QUERY_ROCE_CC_GEN1_RESP_SB_TLV_CNP_ECN_ECT_0   UINT32_C(0x2)
-	#define CREQ_QUERY_ROCE_CC_GEN1_RESP_SB_TLV_CNP_ECN_LAST   CREQ_QUERY_ROCE_CC_GEN1_RESP_SB_TLV_CNP_ECN_ECT_0
-	/* Enables jitter in RTT. */
-	uint8_t	rtt_jitter_en;
+	#define CQ_RES_UD_CFA_SRQ_OR_RQ_WR_ID_MASK UINT32_C(0xfffff)
+	#define CQ_RES_UD_CFA_SRQ_OR_RQ_WR_ID_SFT 0
+	/* Upper 8b of the Source QP value from the DETH header. */
+	#define CQ_RES_UD_CFA_SRC_QP_HIGH_MASK	UINT32_C(0xff000000)
+	#define CQ_RES_UD_CFA_SRC_QP_HIGH_SFT	24
+} cq_res_ud_cfa_t, *pcq_res_ud_cfa_t;
+
+/* Responder UD with CFA CQE version 2 */
+/* cq_res_ud_cfa_v2 (size:256b/32B) */
+
+typedef struct cq_res_ud_cfa_v2 {
+	uint16_t	length;
 	/*
-	 * Number of bytes per usec, dependant on port speed.
-	 * 200 Gbps: 25,000
-	 * 100 Gbps: 12,500
-	 * 50 Gbps: 6,250
-	 * 25 Gbps: 3125
-	 * 10 Gbps: 1250
+	 * The length of the message's payload in bytes, stored in
+	 * the SGEs
 	 */
-	uint16_t	link_bytes_per_usec;
+	#define CQ_RES_UD_CFA_V2_LENGTH_MASK UINT32_C(0x3fff)
+	#define CQ_RES_UD_CFA_V2_LENGTH_SFT 0
+	/* This is data from the CFA as indicated by the meta_format field. */
+	uint16_t	cfa_metadata0;
+	/* When meta_format=1, this value is the VLAN VID. */
+	#define CQ_RES_UD_CFA_V2_CFA_METADATA0_VID_MASK UINT32_C(0xfff)
+	#define CQ_RES_UD_CFA_V2_CFA_METADATA0_VID_SFT 0
+	/* When meta_format=1, this value is the VLAN DE. */
+	#define CQ_RES_UD_CFA_V2_CFA_METADATA0_DE	UINT32_C(0x1000)
+	/* When meta_format=1, this value is the VLAN PRI. */
+	#define CQ_RES_UD_CFA_V2_CFA_METADATA0_PRI_MASK UINT32_C(0xe000)
+	#define CQ_RES_UD_CFA_V2_CFA_METADATA0_PRI_SFT 13
+	/* Immediate data in case the imm_flag set. */
+	uint32_t	imm_data;
+	uint32_t	qid;
 	/*
-	 * If CR is greater than or equal to this threshold,
-	 * QPC's CC state is reset to its initial state.
+	 * This value indicates the QPID associated with this operation.
+	 * The driver will use the qid from this CQE to map a QP handle
+	 * in the completion record returned to the application.
 	 */
-	uint16_t	reset_cc_cr_th;
+	#define CQ_RES_UD_CFA_V2_QID_MASK UINT32_C(0xfffff)
+	#define CQ_RES_UD_CFA_V2_QID_SFT 0
 	/*
-	 * The number of valid lsbits in CR and TR.
-	 * Supported values include 10 through 14 to support 2^cr_width rate.
+	 * This is data from the CFA block as indicated by the meta_format
+	 * field.
+	 * - meta_format 0 - none - metadata2 = 0 - not valid/not stripped
+	 * - meta_format 1 - act_rec_ptr - metadata2 = {table_scope[5:0],
+	 *   act_rec_ptr[25:0]}
+	 * - meta_format 2 - tunnel_id - metadata2 = tunnel_id[31:0]
+	 * - meta_format 3 - chdr_data - metadata2 = updated_chdr_data[31:0]
+	 * - meta_format 4 - hdr_offsets - metadata2 = hdr_offsets[31:0]
+	 * When vee_cmpl_mode is set in VNIC context, this is the upper 32b
+	 * of the host address from the first BD used to place the packet.
 	 */
-	uint8_t	cr_width;
-	/* Lower end of random selection of quota_period. */
-	uint8_t	quota_period_min;
-	/* Upper end of random selection of quota_period. */
-	uint8_t	quota_period_max;
+	uint32_t	cfa_metadata2;
 	/*
-	 * The absolute maximum possible quota_period,
-	 * applicable when rate table for lower 24 levels is used.
+	 * Source MAC address for the UD message placed in the WQE
+	 * that is completed by this CQE.
 	 */
-	uint8_t	quota_period_abs_max;
-	/* TR never goes below this level. */
-	uint16_t	tr_lower_bound;
-	/* Factor on probability threshold for adding 0.5 to CR randomly. */
-	uint8_t	cr_prob_factor;
-	/* Factor on probability threshold for adding 0.5 to TR randomly. */
-	uint8_t	tr_prob_factor;
+	uint16_t	src_mac[3];
+	/* Lower 16b of the Source QP value from the DETH header. */
+	uint16_t	src_qp_low;
+	uint8_t	cqe_type_toggle;
 	/*
-	 * Threshold to ensure fairness between requester and responder.
-	 * If CR is less than the fairness threshold and a quota period has passed
-	 * priority will be given to the path that did not last transfer data.
+	 * Indicate valid completion - written by the chip. Cumulus
+	 * toggle this bit each time it finished consuming all PBL
+	 * entries
 	 */
-	uint16_t	fairness_cr_th;
-	/* Log based rate reduction divider. */
-	uint8_t	red_div;
-	/* Threshold for rate reductions when CNPS received over last RTT. */
-	uint8_t	cnp_ratio_th;
+	#define CQ_RES_UD_CFA_V2_TOGGLE		UINT32_C(0x1)
+	/* This field defines the type of CQE. */
+	#define CQ_RES_UD_CFA_V2_CQE_TYPE_MASK	UINT32_C(0x1e)
+	#define CQ_RES_UD_CFA_V2_CQE_TYPE_SFT	1
 	/*
-	 * Extended number of RTTS to wait, when there is no congestion,
-	 * to start doubling the rate.
+	 * Responder UD Completion with CFA - This is used for both RQ
+	 * and SRQ completion for UD service QPs. It includes cfa fields
+	 * (some of which carry VLAN information), in place of the QP
+	 * handle. It is also used for QP1 QPs that are treated as UD.
 	 */
-	uint16_t	exp_ai_rtts;
-	/* Log based CR to CP ratio used in exponential increase. */
-	uint8_t	exp_ai_cr_cp_ratio;
-	/* Enable use of lowest 24 rate levels rate_table. */
-	uint8_t	use_rate_table;
+		#define CQ_RES_UD_CFA_V2_CQE_TYPE_RES_UD_CFA  (UINT32_C(0x4) << 1)
+		#define CQ_RES_UD_CFA_V2_CQE_TYPE_LAST	CQ_RES_UD_CFA_V2_CQE_TYPE_RES_UD_CFA
+	/* This field indicates the status for the CQE. */
+	uint8_t	status;
 	/*
-	 * Determines after how many congestion free RTTs to start
-	 * updating CP to track CR.
+	 * This indicates that the completion is without error.
+	 * All fields are valid.
 	 */
-	uint16_t	cp_exp_update_th;
-	/* The threshold on congestion free RTTs above which AI can increase to 16. */
-	uint16_t	high_exp_ai_rtts_th1;
-	/* The threshold on congestion free RTTs above which AI can increase to 32. */
-	uint16_t	high_exp_ai_rtts_th2;
+	#define CQ_RES_UD_CFA_V2_STATUS_OK			UINT32_C(0x0)
 	/*
-	 * The number of congestion free RTTs above which
-	 * reduction based on actual rate is enabled.
+	 * This indicates that write access was not allowed for
+	 * at least one of the SGEs in the WQE.
+	 *
+	 * This is a fatal error. Only the srq_or_rq_wr_id is field
+	 * is valid.
 	 */
-	uint16_t	actual_cr_cong_free_rtts_th;
+	#define CQ_RES_UD_CFA_V2_STATUS_LOCAL_ACCESS_ERROR	UINT32_C(0x1)
 	/*
-	 * If rtts_with_cong is greater than 7 (severe congestion) and
-	 * CR level post reduction is above this threshold,
-	 * then TR is capped to 1.5 times CR..
+	 * This indicates that the packet was too long for the WQE
+	 * provided on the SRQ/RQ.
+	 *
+	 * This is not a fatal error. All the fields are valid.
 	 */
-	uint16_t	severe_cong_cr_th1;
+	#define CQ_RES_UD_CFA_V2_STATUS_HW_LOCAL_LENGTH_ERR	UINT32_C(0x2)
+	/* LOCAL_PROTECTION_ERR is 3 */
+	#define CQ_RES_UD_CFA_V2_STATUS_LOCAL_PROTECTION_ERR	UINT32_C(0x3)
+	/* LOCAL_QP_OPERATION_ERR is 4 */
+	#define CQ_RES_UD_CFA_V2_STATUS_LOCAL_QP_OPERATION_ERR   UINT32_C(0x4)
+	/* MEMORY_MGT_OPERATION_ERR is 5 */
+	#define CQ_RES_UD_CFA_V2_STATUS_MEMORY_MGT_OPERATION_ERR UINT32_C(0x5)
+	/* WORK_REQUEST_FLUSHED_ERR is 7 */
+	#define CQ_RES_UD_CFA_V2_STATUS_WORK_REQUEST_FLUSHED_ERR UINT32_C(0x7)
+	/* HW_FLUSH_ERR is 8 */
+	#define CQ_RES_UD_CFA_V2_STATUS_HW_FLUSH_ERR		UINT32_C(0x8)
+	#define CQ_RES_UD_CFA_V2_STATUS_LAST			CQ_RES_UD_CFA_V2_STATUS_HW_FLUSH_ERR
+	uint16_t	flags;
 	/*
-	 * If rtts_with_cong is greater than 7 (severe congestion) and
-	 * CR level post reduction is above this threshold,
-	 * then TR is capped to 1.25 times CR..
+	 * This flag indicates that the completion is for a SRQ entry
+	 * rather than for an RQ entry.
 	 */
-	uint16_t	severe_cong_cr_th2;
+	#define CQ_RES_UD_CFA_V2_FLAGS_SRQ			UINT32_C(0x1)
+	/* CQE relates to RQ WQE. */
+		#define CQ_RES_UD_CFA_V2_FLAGS_SRQ_RQ		UINT32_C(0x0)
+	/* CQE relates to SRQ WQE. */
+		#define CQ_RES_UD_CFA_V2_FLAGS_SRQ_SRQ		UINT32_C(0x1)
+		#define CQ_RES_UD_CFA_V2_FLAGS_SRQ_LAST		CQ_RES_UD_CFA_V2_FLAGS_SRQ_SRQ
+	/* Immediate data indicator */
+	#define CQ_RES_UD_CFA_V2_FLAGS_IMM			UINT32_C(0x2)
+	#define CQ_RES_UD_CFA_V2_FLAGS_UNUSED_MASK		UINT32_C(0xc)
+	#define CQ_RES_UD_CFA_V2_FLAGS_UNUSED_SFT		2
+	#define CQ_RES_UD_CFA_V2_FLAGS_ROCE_IP_VER_MASK	UINT32_C(0x30)
+	#define CQ_RES_UD_CFA_V2_FLAGS_ROCE_IP_VER_SFT	4
+	/* RoCEv1 Message */
+		#define CQ_RES_UD_CFA_V2_FLAGS_ROCE_IP_VER_V1	(UINT32_C(0x0) << 4)
+	/* RoCEv2 IPv4 Message */
+		#define CQ_RES_UD_CFA_V2_FLAGS_ROCE_IP_VER_V2IPV4	(UINT32_C(0x2) << 4)
+	/* RoCEv2 IPv6 Message */
+		#define CQ_RES_UD_CFA_V2_FLAGS_ROCE_IP_VER_V2IPV6	(UINT32_C(0x3) << 4)
+		#define CQ_RES_UD_CFA_V2_FLAGS_ROCE_IP_VER_LAST	CQ_RES_UD_CFA_V2_FLAGS_ROCE_IP_VER_V2IPV6
+	/* The field indicates what format the metadata field is. */
+	#define CQ_RES_UD_CFA_V2_FLAGS_META_FORMAT_MASK	UINT32_C(0x3c0)
+	#define CQ_RES_UD_CFA_V2_FLAGS_META_FORMAT_SFT	6
+	/* No metadata information. Value is zero. */
+		#define CQ_RES_UD_CFA_V2_FLAGS_META_FORMAT_NONE	(UINT32_C(0x0) << 6)
 	/*
-	 * The maximum number of 64B that can be transmitted during RTT time,
-	 * including all headers and Inter Packet Gap.
+	 * The {metadata1, metadata0} fields contain the vtag
+	 * information: - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0],
+	 * de, vid[11:0]} The metadata2 field contains the table scope
+	 * and action record pointer. - metadata2[25:0] contains the
+	 * action record pointer. - metadata2[31:26] contains the table
+	 * scope.
 	 */
-	uint32_t	link64B_per_rtt;
+		#define CQ_RES_UD_CFA_V2_FLAGS_META_FORMAT_ACT_REC_PTR  (UINT32_C(0x1) << 6)
+	/*
+	 * The {metadata1, metadata0} fields contain the vtag
+	 * information:
+	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0], de, vid[11:0]}
+	 * The metadata2 field contains the Tunnel ID
+	 * value, justified to LSB. i
+	 * - VXLAN = VNI[23:0] -> VXLAN Network ID
+	 * - Geneve (NGE) = VNI[23:0] a-> Virtual Network Identifier
+	 * - NVGRE = TNI[23:0] -> Tenant Network ID
+	 * - GRE = KEY[31:0] -> key field with bit mask. zero if K=0
+	 * - IPv4 = 0 (not populated)
+	 * - IPv6 = Flow Label[19:0]
+	 * - PPPoE = sessionID[15:0]
+	 * - MPLs = Outer label[19:0]
+	 * - UPAR = Selected[31:0] with bit mask
+	 */
+		#define CQ_RES_UD_CFA_V2_FLAGS_META_FORMAT_TUNNEL_ID	(UINT32_C(0x2) << 6)
+	/*
+	 * The {metadata1, metadata0} fields contain the vtag
+	 * information:
+	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0],de, vid[11:0]}
+	 * The metadata2 field contains the 32b metadata from the
+	 * prepended header (chdr_data).
+	 */
+		#define CQ_RES_UD_CFA_V2_FLAGS_META_FORMAT_CHDR_DATA	(UINT32_C(0x3) << 6)
+	/*
+	 * If ext_meta_format is equal to 1, the metadata field contains
+	 * the outer_l3_offset and lower 7 bits of the inner_l2_offset,
+	 * - metadata[8:0] contains the outer_l3_offset.
+	 * - metadata[15:9] contains the inner_l2_offset[6:0]
+	 */
+		#define CQ_RES_UD_CFA_V2_FLAGS_META_FORMAT_HDR_OFFSET   (UINT32_C(0x4) << 6)
+		#define CQ_RES_UD_CFA_V2_FLAGS_META_FORMAT_LAST	CQ_RES_UD_CFA_V2_FLAGS_META_FORMAT_HDR_OFFSET
+	uint32_t	src_qp_high_srq_or_rq_wr_id;
+	/*
+	 * Opaque value from RQ or SRQ WQE. Used by driver/lib to
+	 * reference the WQE in order to claim the received data
+	 * and reuse the WQE space
+	 */
+	#define CQ_RES_UD_CFA_V2_SRQ_OR_RQ_WR_ID_MASK	UINT32_C(0xfffff)
+	#define CQ_RES_UD_CFA_V2_SRQ_OR_RQ_WR_ID_SFT		0
+	#define CQ_RES_UD_CFA_V2_CFA_METADATA1_MASK		UINT32_C(0xf00000)
+	#define CQ_RES_UD_CFA_V2_CFA_METADATA1_SFT		20
+	/* When meta_format != 0, this value is the VLAN TPID_SEL. */
+	#define CQ_RES_UD_CFA_V2_CFA_METADATA1_TPID_SEL_MASK	UINT32_C(0x700000)
+	#define CQ_RES_UD_CFA_V2_CFA_METADATA1_TPID_SEL_SFT	20
+	/* 0x88a8 */
+		#define CQ_RES_UD_CFA_V2_CFA_METADATA1_TPID_SEL_TPID88A8   (UINT32_C(0x0) << 20)
+	/* 0x8100 */
+		#define CQ_RES_UD_CFA_V2_CFA_METADATA1_TPID_SEL_TPID8100   (UINT32_C(0x1) << 20)
+	/* 0x9100 */
+		#define CQ_RES_UD_CFA_V2_CFA_METADATA1_TPID_SEL_TPID9100   (UINT32_C(0x2) << 20)
+	/* 0x9200 */
+		#define CQ_RES_UD_CFA_V2_CFA_METADATA1_TPID_SEL_TPID9200   (UINT32_C(0x3) << 20)
+	/* 0x9300 */
+		#define CQ_RES_UD_CFA_V2_CFA_METADATA1_TPID_SEL_TPID9300   (UINT32_C(0x4) << 20)
+	/* Value programmed in CFA VLANTPID register. */
+		#define CQ_RES_UD_CFA_V2_CFA_METADATA1_TPID_SEL_TPIDCFG	(UINT32_C(0x5) << 20)
+		#define CQ_RES_UD_CFA_V2_CFA_METADATA1_TPID_SEL_LAST	CQ_RES_UD_CFA_V2_CFA_METADATA1_TPID_SEL_TPIDCFG
+	/* When meta_format != 0, this value is the VLAN valid. */
+	#define CQ_RES_UD_CFA_V2_CFA_METADATA1_VALID		UINT32_C(0x800000)
+	/* Upper 8b of the Source QP value from the DETH header. */
+	#define CQ_RES_UD_CFA_V2_SRC_QP_HIGH_MASK		UINT32_C(0xff000000)
+	#define CQ_RES_UD_CFA_V2_SRC_QP_HIGH_SFT		24
+} cq_res_ud_cfa_v2_t, *pcq_res_ud_cfa_v2_t;
+
+/* Responder RawEth and QP1 CQE */
+/* cq_res_raweth_qp1 (size:256b/32B) */
+
+typedef struct cq_res_raweth_qp1 {
+	uint16_t	length;
 	/*
-	 * The number of bytes to subtract from QPC.cc_bucket
-	 * when an ack is scheduled.
+	 * The length of the message's payload in bytes, stored in
+	 * the SGEs
 	 */
-	uint8_t	cc_ack_bytes;
+	#define CQ_RES_RAWETH_QP1_LENGTH_MASK UINT32_C(0x3fff)
+	#define CQ_RES_RAWETH_QP1_LENGTH_SFT 0
+	uint16_t	raweth_qp1_flags;
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_MASK		UINT32_C(0x3ff)
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_SFT		0
 	/*
-	 * Enables reduction of CR, TR, and CP to init values when
-	 * congestion free RTTs is greater than reduce2_init_cong_free_rtts_th.
+	 * When this bit is '1', it indicates a packet that has an
+	 * error of some type. Type of error is indicated in
+	 * raweth_qp1_errors.
 	 */
-	uint8_t	reduce_init_en;
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ERROR		UINT32_C(0x1)
 	/*
-	 * Minimum threshold value for number of congestion free RTTs before reducing
-	 * to init values for CR, TR, and CP when reduce_init_en is enabled.
+	 * This value indicates what the inner packet determined for the
+	 * packet was.
 	 */
-	uint16_t	reduce_init_cong_free_rtts_th;
-	/* Enables random no reduction of CR. */
-	uint8_t	random_no_red_en;
-	/* Enables coarse correction to actual CR when actual RTT is longer than nominal. */
-	uint8_t	actual_cr_shift_correction_en;
-	/* Enables adjustment to refill quota. */
-	uint8_t	quota_period_adjust_en;
-	uint8_t	reserved[5];
-} creq_query_roce_cc_gen1_resp_sb_tlv_t, *pcreq_query_roce_cc_gen1_resp_sb_tlv_t;
-
-/***********************
- * cmdq_modify_roce_cc *
- ***********************/
-
-
-/* cmdq_modify_roce_cc (size:448b/56B) */
-
-typedef struct cmdq_modify_roce_cc {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Modify congestion control. Can only be issued from a PF. */
-	#define CMDQ_MODIFY_ROCE_CC_OPCODE_MODIFY_ROCE_CC UINT32_C(0x8c)
-	#define CMDQ_MODIFY_ROCE_CC_OPCODE_LAST	CMDQ_MODIFY_ROCE_CC_OPCODE_MODIFY_ROCE_CC
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	/* Modify mask signifies the field that is requesting the change. */
-	uint32_t	modify_mask;
-	/* Enable change. */
-	#define CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_ENABLE_CC		UINT32_C(0x1)
-	/* Running average weight change. */
-	#define CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_G			UINT32_C(0x2)
-	/* Number of phases in Fast Recovery. */
-	#define CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_NUMPHASEPERSTATE	UINT32_C(0x4)
-	/* The starting value of rate change. */
-	#define CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_INIT_CR		UINT32_C(0x8)
-	/* The starting value of target rate change. */
-	#define CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_INIT_TR		UINT32_C(0x10)
-	/* IP TOS ECN change */
-	#define CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_TOS_ECN		UINT32_C(0x20)
-	/* IP TOS DSCP change */
-	#define CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_TOS_DSCP		UINT32_C(0x40)
-	/* Alternate IP TOS ECN change */
-	#define CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_ALT_VLAN_PCP	UINT32_C(0x80)
-	/* Alternate IP TOS DSCP change */
-	#define CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_ALT_TOS_DSCP	UINT32_C(0x100)
-	/* Round trip time in units of usecs */
-	#define CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_RTT		UINT32_C(0x200)
-	/* Congestion Control mode */
-	#define CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_CC_MODE		UINT32_C(0x400)
-	/* The value used as CP when cc_mode is 1(TCP) */
-	#define CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_TCP_CP		UINT32_C(0x800)
-	/* Specifies the RoCE Tx Queue to use for sending CNP packets */
-	#define CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_TX_QUEUE		UINT32_C(0x1000)
-	/* Inactivity time after which QP CC parameters are initialized */
-	#define CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_INACTIVITY_CP	UINT32_C(0x2000)
-	/* Amount of time per phase in units of ms. Max is 15. */
-	#define CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_TIME_PER_PHASE	UINT32_C(0x4000)
-	/* Number of packets per phase. Max is 255. */
-	#define CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_PKTS_PER_PHASE	UINT32_C(0x8000)
-	uint8_t	enable_cc;
-	/* Enable. */
-	#define CMDQ_MODIFY_ROCE_CC_ENABLE_CC	UINT32_C(0x1)
-	/* rsvd1 is 7 b */
-	#define CMDQ_MODIFY_ROCE_CC_RSVD1_MASK	UINT32_C(0xfe)
-	#define CMDQ_MODIFY_ROCE_CC_RSVD1_SFT	1
-	/* Congestion Probability averaging factor. */
-	uint8_t	g;
-	/* Number of phases in Fast Recovery. */
-	uint8_t	num_phases_per_state;
-	/* Number of packets per phase. Max is 255. */
-	uint8_t	pkts_per_phase;
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_MASK		UINT32_C(0x3c0)
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_SFT		6
 	/*
-	 * The starting value of rate.
-	 * The max value supported for CC support level 1 is 1024.
+	 * Not Known:
+	 * Indicates that the packet type was not known.
 	 */
-	uint16_t	init_cr;
+		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_NOT_KNOWN	(UINT32_C(0x0) << 6)
 	/*
-	 * The starting value of target rate.
-	 * The max value supported for CC support level 1 is 1024.
+	 * IP Packet:
+	 * Indicates that the packet was an IP packet, but further
+	 * classification was not possible.
 	 */
-	uint16_t	init_tr;
-	uint8_t	tos_dscp_tos_ecn;
-	/* IP TOS ECN. Valid values are 1 or 2 when ECN is enabled. */
-	#define CMDQ_MODIFY_ROCE_CC_TOS_ECN_MASK UINT32_C(0x3)
-	#define CMDQ_MODIFY_ROCE_CC_TOS_ECN_SFT  0
-	/* IP TOS DSCP. */
-	#define CMDQ_MODIFY_ROCE_CC_TOS_DSCP_MASK UINT32_C(0xfc)
-	#define CMDQ_MODIFY_ROCE_CC_TOS_DSCP_SFT 2
-	uint8_t	alt_vlan_pcp;
-	/* Alternate vlan pcp value for CNP packets. */
-	#define CMDQ_MODIFY_ROCE_CC_ALT_VLAN_PCP_MASK UINT32_C(0x7)
-	#define CMDQ_MODIFY_ROCE_CC_ALT_VLAN_PCP_SFT 0
-	/* rsvd3 is 5 b */
-	#define CMDQ_MODIFY_ROCE_CC_RSVD3_MASK	UINT32_C(0xf8)
-	#define CMDQ_MODIFY_ROCE_CC_RSVD3_SFT	3
-	uint16_t	alt_tos_dscp;
-	/* Alternate IP TOS DSCP. */
-	#define CMDQ_MODIFY_ROCE_CC_ALT_TOS_DSCP_MASK UINT32_C(0x3f)
-	#define CMDQ_MODIFY_ROCE_CC_ALT_TOS_DSCP_SFT 0
-	/* rsvd4 is 10 b */
-	#define CMDQ_MODIFY_ROCE_CC_RSVD4_MASK	UINT32_C(0xffc0)
-	#define CMDQ_MODIFY_ROCE_CC_RSVD4_SFT	6
-	uint16_t	rtt;
+		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_IP		(UINT32_C(0x1) << 6)
 	/*
-	 * Round trip time in units of usecs.
-	 * The max value supported for CC support level 1 is 2047.
+	 * TCP Packet:
+	 * Indicates that the packet was IP and TCP.
+	 * This indicates that the raweth_qp1_payload_offset field is
+	 * valid.
 	 */
-	#define CMDQ_MODIFY_ROCE_CC_RTT_MASK  UINT32_C(0x3fff)
-	#define CMDQ_MODIFY_ROCE_CC_RTT_SFT   0
-	/* rsvd5 is 2 b */
-	#define CMDQ_MODIFY_ROCE_CC_RSVD5_MASK UINT32_C(0xc000)
-	#define CMDQ_MODIFY_ROCE_CC_RSVD5_SFT 14
-	uint16_t	tcp_cp;
-	/* The value used as CP when cc_mode is 1(TCP) */
-	#define CMDQ_MODIFY_ROCE_CC_TCP_CP_MASK UINT32_C(0x3ff)
-	#define CMDQ_MODIFY_ROCE_CC_TCP_CP_SFT 0
-	/* rsvd6 is 6 b */
-	#define CMDQ_MODIFY_ROCE_CC_RSVD6_MASK UINT32_C(0xfc00)
-	#define CMDQ_MODIFY_ROCE_CC_RSVD6_SFT  10
-	uint8_t	cc_mode;
-	/* DCTCP */
-	#define CMDQ_MODIFY_ROCE_CC_CC_MODE_DCTCP_CC_MODE	UINT32_C(0x0)
+		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_TCP		(UINT32_C(0x2) << 6)
 	/*
-	 * Probabilistic marking. On chips with CC Gen 0 support this
-	 * will be TCP CC algorithm.
+	 * UDP Packet:
+	 * Indicates that the packet was IP and UDP.
+	 * This indicates that the raweth_qp1_payload_offset field is
+	 * valid.
 	 */
-	#define CMDQ_MODIFY_ROCE_CC_CC_MODE_PROBABILISTIC_CC_MODE UINT32_C(0x1)
-	#define CMDQ_MODIFY_ROCE_CC_CC_MODE_LAST		CMDQ_MODIFY_ROCE_CC_CC_MODE_PROBABILISTIC_CC_MODE
+		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_UDP		(UINT32_C(0x3) << 6)
 	/*
-	 * Specifies the RoCE Tx Queue to use for sending CNP packets.
-	 * CC support level 0 support 0 to 3 Tx queues.
-	 * CC support level 1 supports 0 to 7 Tx queues.
+	 * FCoE Packet:
+	 * Indicates that the packet was recognized as a FCoE.
+	 * This also indicates that the raweth_qp1_payload_offset field
+	 * is valid.
 	 */
-	uint8_t	tx_queue;
-	/* Inactivity time after which QP CC parameters are initialized */
-	uint16_t	inactivity_th;
-	/* Amount of time per phase in units of ms. Max is 15 */
-	uint8_t	time_per_phase;
-	/* reserved8 is 8 b */
-	uint8_t	reserved8_1;
-	/* reserved16 is 16 b */
-	uint16_t	reserved16;
-	uint32_t	reserved32;
-	uint64_t	reserved64;
-} cmdq_modify_roce_cc_t, *pcmdq_modify_roce_cc_t;
-
-/*
- * TLV encapsulated modify CC command, with extended TLV record
- * included for specifying the extended configuration for CC level 1.
- */
-/* cmdq_modify_roce_cc_tlv (size:640b/80B) */
-
-typedef struct cmdq_modify_roce_cc_tlv {
+		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_FCOE		(UINT32_C(0x4) << 6)
 	/*
-	 * The command discriminator is used to differentiate between various
-	 * types of HWRM messages. This includes legacy HWRM and RoCE slowpath
-	 * command messages as well as newer TLV encapsulated HWRM commands.
-	 *
-	 * For TLV encapsulated messages this field must be 0x8000.
+	 * RoCE Packet:
+	 * Indicates that the packet was recognized as a RoCE.
+	 * This also indicates that the raweth_qp1_payload_offset field
+	 * is valid.
 	 */
-	uint16_t	cmd_discr;
-	uint8_t	reserved_8b;
-	uint8_t	tlv_flags;
+		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_ROCE		(UINT32_C(0x5) << 6)
 	/*
-	 * Indicates the presence of additional TLV encapsulated data
-	 * follows this TLV.
+	 * ICMP Packet:
+	 * Indicates that the packet was recognized as ICMP.
+	 * This indicates that the raweth_qp1_payload_offset field is
+	 * valid.
 	 */
-	#define CMDQ_MODIFY_ROCE_CC_TLV_TLV_FLAGS_MORE	UINT32_C(0x1)
-	/* Last TLV in a sequence of TLVs. */
-		#define CMDQ_MODIFY_ROCE_CC_TLV_TLV_FLAGS_MORE_LAST	UINT32_C(0x0)
-	/* More TLVs follow this TLV. */
-		#define CMDQ_MODIFY_ROCE_CC_TLV_TLV_FLAGS_MORE_NOT_LAST  UINT32_C(0x1)
+		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_ICMP		(UINT32_C(0x7) << 6)
 	/*
-	 * When an HWRM receiver detects a TLV type that it does not
-	 * support with the TLV required flag set, the receiver must
-	 * reject the HWRM message with an error code indicating an
-	 * unsupported TLV type.
+	 * PtP packet wo/timestamp:
+	 * Indicates that the packet was recognized as a PtP
+	 * packet.
 	 */
-	#define CMDQ_MODIFY_ROCE_CC_TLV_TLV_FLAGS_REQUIRED	UINT32_C(0x2)
-	/* No */
-		#define CMDQ_MODIFY_ROCE_CC_TLV_TLV_FLAGS_REQUIRED_NO	(UINT32_C(0x0) << 1)
-	/* Yes */
-		#define CMDQ_MODIFY_ROCE_CC_TLV_TLV_FLAGS_REQUIRED_YES   (UINT32_C(0x1) << 1)
-		#define CMDQ_MODIFY_ROCE_CC_TLV_TLV_FLAGS_REQUIRED_LAST CMDQ_MODIFY_ROCE_CC_TLV_TLV_FLAGS_REQUIRED_YES
+		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_PTP_WO_TIMESTAMP   (UINT32_C(0x8) << 6)
 	/*
-	 * This field defines the TLV type value which is divided into
-	 * two ranges to differentiate between global and local TLV types.
-	 * Global TLV types must be unique across all defined TLV types.
-	 * Local TLV types are valid only for extensions to a given
-	 * HWRM message and may be repeated across different HWRM message
-	 * types. There is a direct correlation of each HWRM message type
-	 * to a single global TLV type value.
-	 *
-	 * Global TLV range: `0 - (63k-1)`
-	 *
-	 * Local TLV range: `63k - (64k-1)`
+	 * PtP packet w/timestamp:
+	 * Indicates that the packet was recognized as a PtP
+	 * packet and that a timestamp was taken for the packet.
 	 */
-	uint16_t	tlv_type;
+		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_PTP_W_TIMESTAMP	(UINT32_C(0x9) << 6)
+		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_LAST		CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_PTP_W_TIMESTAMP
+	uint16_t	raweth_qp1_errors;
 	/*
-	 * Length of the message data encapsulated by this TLV in bytes.
-	 * This length does not include the size of the TLV header itself
-	 * and it must be an integer multiple of 8B.
+	 * This indicates that there was an error in the IP header
+	 * checksum.
 	 */
-	uint16_t	length;
-	/* Size of the tlv encapsulated command, including all tlvs and extension data in 16-byte units. */
-	uint8_t	total_size;
-	uint8_t	reserved56[7];
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Modify congestion control. Can only be issued from a PF. */
-	#define CMDQ_MODIFY_ROCE_CC_TLV_OPCODE_MODIFY_ROCE_CC UINT32_C(0x8c)
-	#define CMDQ_MODIFY_ROCE_CC_TLV_OPCODE_LAST	CMDQ_MODIFY_ROCE_CC_TLV_OPCODE_MODIFY_ROCE_CC
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	/* Modify mask signifies the field that is requesting the change. */
-	uint32_t	modify_mask;
-	/* Enable change. */
-	#define CMDQ_MODIFY_ROCE_CC_TLV_MODIFY_MASK_ENABLE_CC		UINT32_C(0x1)
-	/* Running average weight change. */
-	#define CMDQ_MODIFY_ROCE_CC_TLV_MODIFY_MASK_G			UINT32_C(0x2)
-	/* Number of phases in Fast Recovery. */
-	#define CMDQ_MODIFY_ROCE_CC_TLV_MODIFY_MASK_NUMPHASEPERSTATE	UINT32_C(0x4)
-	/* The starting value of rate change. */
-	#define CMDQ_MODIFY_ROCE_CC_TLV_MODIFY_MASK_INIT_CR		UINT32_C(0x8)
-	/* The starting value of target rate change. */
-	#define CMDQ_MODIFY_ROCE_CC_TLV_MODIFY_MASK_INIT_TR		UINT32_C(0x10)
-	/* IP TOS ECN change */
-	#define CMDQ_MODIFY_ROCE_CC_TLV_MODIFY_MASK_TOS_ECN		UINT32_C(0x20)
-	/* IP TOS DSCP change */
-	#define CMDQ_MODIFY_ROCE_CC_TLV_MODIFY_MASK_TOS_DSCP		UINT32_C(0x40)
-	/* Alternate IP TOS ECN change */
-	#define CMDQ_MODIFY_ROCE_CC_TLV_MODIFY_MASK_ALT_VLAN_PCP	UINT32_C(0x80)
-	/* Alternate IP TOS DSCP change */
-	#define CMDQ_MODIFY_ROCE_CC_TLV_MODIFY_MASK_ALT_TOS_DSCP	UINT32_C(0x100)
-	/* Round trip time in units of usecs */
-	#define CMDQ_MODIFY_ROCE_CC_TLV_MODIFY_MASK_RTT		UINT32_C(0x200)
-	/* Congestion Control mode */
-	#define CMDQ_MODIFY_ROCE_CC_TLV_MODIFY_MASK_CC_MODE		UINT32_C(0x400)
-	/* The value used as CP when cc_mode is 1(TCP) */
-	#define CMDQ_MODIFY_ROCE_CC_TLV_MODIFY_MASK_TCP_CP		UINT32_C(0x800)
-	/* Specifies the RoCE Tx Queue to use for sending CNP packets */
-	#define CMDQ_MODIFY_ROCE_CC_TLV_MODIFY_MASK_TX_QUEUE		UINT32_C(0x1000)
-	/* Inactivity time after which QP CC parameters are initialized */
-	#define CMDQ_MODIFY_ROCE_CC_TLV_MODIFY_MASK_INACTIVITY_CP	UINT32_C(0x2000)
-	/* Amount of time per phase in units of ms. Max is 15. */
-	#define CMDQ_MODIFY_ROCE_CC_TLV_MODIFY_MASK_TIME_PER_PHASE	UINT32_C(0x4000)
-	/* Number of packets per phase. Max is 255. */
-	#define CMDQ_MODIFY_ROCE_CC_TLV_MODIFY_MASK_PKTS_PER_PHASE	UINT32_C(0x8000)
-	uint8_t	enable_cc;
-	/* Enable. */
-	#define CMDQ_MODIFY_ROCE_CC_TLV_ENABLE_CC	UINT32_C(0x1)
-	/* rsvd1 is 7 b */
-	#define CMDQ_MODIFY_ROCE_CC_TLV_RSVD1_MASK	UINT32_C(0xfe)
-	#define CMDQ_MODIFY_ROCE_CC_TLV_RSVD1_SFT	1
-	/* Congestion Probability averaging factor. */
-	uint8_t	g;
-	/* Number of phases in Fast Recovery. */
-	uint8_t	num_phases_per_state;
-	/* Number of packets per phase. Max is 255. */
-	uint8_t	pkts_per_phase;
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_IP_CS_ERROR			UINT32_C(0x10)
 	/*
-	 * The starting value of rate.
-	 * The max value supported for CC support level 1 is 1024.
+	 * This indicates that there was an error in the TCP, UDP
+	 * or ICMP checksum.
 	 */
-	uint16_t	init_cr;
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_L4_CS_ERROR			UINT32_C(0x20)
 	/*
-	 * The starting value of target rate.
-	 * The max value supported for CC support level 1 is 1024.
+	 * This indicates that there was an error in the tunnel
+	 * IP header checksum.
 	 */
-	uint16_t	init_tr;
-	uint8_t	tos_dscp_tos_ecn;
-	/* IP TOS ECN. Valid values are 1 or 2 when ECN is enabled. */
-	#define CMDQ_MODIFY_ROCE_CC_TLV_TOS_ECN_MASK UINT32_C(0x3)
-	#define CMDQ_MODIFY_ROCE_CC_TLV_TOS_ECN_SFT  0
-	/* IP TOS DSCP. */
-	#define CMDQ_MODIFY_ROCE_CC_TLV_TOS_DSCP_MASK UINT32_C(0xfc)
-	#define CMDQ_MODIFY_ROCE_CC_TLV_TOS_DSCP_SFT 2
-	uint8_t	alt_vlan_pcp;
-	/* Alternate vlan pcp value for CNP packets. */
-	#define CMDQ_MODIFY_ROCE_CC_TLV_ALT_VLAN_PCP_MASK UINT32_C(0x7)
-	#define CMDQ_MODIFY_ROCE_CC_TLV_ALT_VLAN_PCP_SFT 0
-	/* rsvd3 is 5 b */
-	#define CMDQ_MODIFY_ROCE_CC_TLV_RSVD3_MASK	UINT32_C(0xf8)
-	#define CMDQ_MODIFY_ROCE_CC_TLV_RSVD3_SFT	3
-	uint16_t	alt_tos_dscp;
-	/* Alternate IP TOS DSCP. */
-	#define CMDQ_MODIFY_ROCE_CC_TLV_ALT_TOS_DSCP_MASK UINT32_C(0x3f)
-	#define CMDQ_MODIFY_ROCE_CC_TLV_ALT_TOS_DSCP_SFT 0
-	/* rsvd4 is 10 b */
-	#define CMDQ_MODIFY_ROCE_CC_TLV_RSVD4_MASK	UINT32_C(0xffc0)
-	#define CMDQ_MODIFY_ROCE_CC_TLV_RSVD4_SFT	6
-	uint16_t	rtt;
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_IP_CS_ERROR			UINT32_C(0x40)
 	/*
-	 * Round trip time in units of usecs.
-	 * The max value supported for CC support level 1 is 2047.
+	 * This indicates that there was an error in the tunnel
+	 * UDP checksum.
 	 */
-	#define CMDQ_MODIFY_ROCE_CC_TLV_RTT_MASK  UINT32_C(0x3fff)
-	#define CMDQ_MODIFY_ROCE_CC_TLV_RTT_SFT   0
-	/* rsvd5 is 2 b */
-	#define CMDQ_MODIFY_ROCE_CC_TLV_RSVD5_MASK UINT32_C(0xc000)
-	#define CMDQ_MODIFY_ROCE_CC_TLV_RSVD5_SFT 14
-	uint16_t	tcp_cp;
-	/* The value used as CP when cc_mode is 1(TCP) */
-	#define CMDQ_MODIFY_ROCE_CC_TLV_TCP_CP_MASK UINT32_C(0x3ff)
-	#define CMDQ_MODIFY_ROCE_CC_TLV_TCP_CP_SFT 0
-	/* rsvd6 is 6 b */
-	#define CMDQ_MODIFY_ROCE_CC_TLV_RSVD6_MASK UINT32_C(0xfc00)
-	#define CMDQ_MODIFY_ROCE_CC_TLV_RSVD6_SFT  10
-	uint8_t	cc_mode;
-	/* DCTCP */
-	#define CMDQ_MODIFY_ROCE_CC_TLV_CC_MODE_DCTCP_CC_MODE	UINT32_C(0x0)
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_L4_CS_ERROR			UINT32_C(0x80)
 	/*
-	 * Probabilistic marking. On chips with CC Gen 0 support this
-	 * will be TCP CC algorithm.
+	 * This indicates that there was a CRC error on either an FCoE
+	 * or RoCE packet. The itype indicates the packet type.
 	 */
-	#define CMDQ_MODIFY_ROCE_CC_TLV_CC_MODE_PROBABILISTIC_CC_MODE UINT32_C(0x1)
-	#define CMDQ_MODIFY_ROCE_CC_TLV_CC_MODE_LAST		CMDQ_MODIFY_ROCE_CC_TLV_CC_MODE_PROBABILISTIC_CC_MODE
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_CRC_ERROR			UINT32_C(0x100)
 	/*
-	 * Specifies the RoCE Tx Queue to use for sending CNP packets.
-	 * CC support level 0 support 0 to 3 Tx queues.
-	 * CC support level 1 supports 0 to 7 Tx queues.
+	 * This indicates that there was an error in the tunnel
+	 * portion of the packet when this
+	 * field is non-zero.
 	 */
-	uint8_t	tx_queue;
-	/* Inactivity time after which QP CC parameters are initialized */
-	uint16_t	inactivity_th;
-	/* Amount of time per phase in units of ms. Max is 15 */
-	uint8_t	time_per_phase;
-	/* reserved8 is 8 b */
-	uint8_t	reserved8_1;
-	/* reserved16 is 16 b */
-	uint16_t	reserved16;
-	uint32_t	reserved32;
-	uint64_t	reserved64;
-	uint64_t	reservedtlvpad;
-} cmdq_modify_roce_cc_tlv_t, *pcmdq_modify_roce_cc_tlv_t;
-
-/* cmdq_modify_roce_cc_gen1_tlv (size:768b/96B) */
-
-typedef struct cmdq_modify_roce_cc_gen1_tlv {
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_PKT_ERROR_MASK		UINT32_C(0xe00)
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_PKT_ERROR_SFT		9
 	/*
-	 * The command discriminator is used to differentiate between various
-	 * types of HWRM messages. This includes legacy HWRM and RoCE slowpath
-	 * command messages as well as newer TLV encapsulated HWRM commands.
-	 *
-	 * For TLV encapsulated messages this field must be 0x8000.
+	 * No additional error occurred on the tunnel portion
+	 * of the packet of the packet does not have a tunnel.
 	 */
-	uint16_t	cmd_discr;
-	uint8_t	reserved_8b;
-	uint8_t	tlv_flags;
+		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_PKT_ERROR_NO_ERROR		(UINT32_C(0x0) << 9)
 	/*
-	 * Indicates the presence of additional TLV encapsulated data
-	 * follows this TLV.
+	 * Indicates that IP header version does not match
+	 * expectation from L2 Ethertype for IPv4 and IPv6
+	 * in the tunnel header.
 	 */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_TLV_FLAGS_MORE	UINT32_C(0x1)
-	/* Last TLV in a sequence of TLVs. */
-		#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_TLV_FLAGS_MORE_LAST	UINT32_C(0x0)
-	/* More TLVs follow this TLV. */
-		#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_TLV_FLAGS_MORE_NOT_LAST  UINT32_C(0x1)
+		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_L3_BAD_VERSION	(UINT32_C(0x1) << 9)
 	/*
-	 * When an HWRM receiver detects a TLV type that it does not
-	 * support with the TLV required flag set, the receiver must
-	 * reject the HWRM message with an error code indicating an
-	 * unsupported TLV type.
+	 * Indicates that header length is out of range in the
+	 * tunnel header. Valid for
+	 * IPv4.
 	 */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_TLV_FLAGS_REQUIRED	UINT32_C(0x2)
-	/* No */
-		#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_TLV_FLAGS_REQUIRED_NO	(UINT32_C(0x0) << 1)
-	/* Yes */
-		#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_TLV_FLAGS_REQUIRED_YES   (UINT32_C(0x1) << 1)
-		#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_TLV_FLAGS_REQUIRED_LAST CMDQ_MODIFY_ROCE_CC_GEN1_TLV_TLV_FLAGS_REQUIRED_YES
+		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_L3_BAD_HDR_LEN	(UINT32_C(0x2) << 9)
 	/*
-	 * This field defines the TLV type value which is divided into
-	 * two ranges to differentiate between global and local TLV types.
-	 * Global TLV types must be unique across all defined TLV types.
-	 * Local TLV types are valid only for extensions to a given
-	 * HWRM message and may be repeated across different HWRM message
-	 * types. There is a direct correlation of each HWRM message type
-	 * to a single global TLV type value.
-	 *
-	 * Global TLV range: `0 - (63k-1)`
-	 *
-	 * Local TLV range: `63k - (64k-1)`
+	 * Indicates that the physical packet is shorter than that
+	 * claimed by the PPPoE header length for a tunnel PPPoE
+	 * packet.
 	 */
-	uint16_t	tlv_type;
+		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_PKT_ERROR_TUNNEL_TOTAL_ERROR	(UINT32_C(0x3) << 9)
 	/*
-	 * Length of the message data encapsulated by this TLV in bytes.
-	 * This length does not include the size of the TLV header itself
-	 * and it must be an integer multiple of 8B.
+	 * Indicates that physical packet is shorter than that claimed
+	 * by the tunnel l3 header length. Valid for IPv4, or IPv6
+	 * tunnel packet packets.
 	 */
-	uint16_t	length;
-	uint64_t	reserved64;
-	/* Modify mask signifies the field that is requesting the change. */
-	uint64_t	modify_mask;
-	/* Update the number of uS between generation of CNPs for probabilistic marking mode. */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_MIN_TIME_BETWEEN_CNPS		UINT32_C(0x1)
+		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_IP_TOTAL_ERROR	(UINT32_C(0x4) << 9)
 	/*
-	 * Update starting value of Congestion Probability (CP).
-	 * Maximum value supported is 1023.
+	 * Indicates that the physical packet is shorter than that
+	 * claimed by the tunnel UDP header length for a tunnel
+	 * UDP packet that is not fragmented.
 	 */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_INIT_CP			UINT32_C(0x2)
-	/* Update Target Rate (TR) Update Mode. */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_TR_UPDATE_MODE			UINT32_C(0x4)
-	/* Update number of RTTs with CNPs in a row for TR update. */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_TR_UPDATE_CYCLES		UINT32_C(0x8)
-	/* Update number of RTTs in Fast Recovery stage. */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_FR_NUM_RTTS			UINT32_C(0x10)
-	/* Update time increment to increase TR in active increase phase. */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_AI_RATE_INCREASE		UINT32_C(0x20)
+		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_UDP_TOTAL_ERROR	(UINT32_C(0x5) << 9)
 	/*
-	 * Update count of RTTs with CNPs, received after
-	 * the first one, to wait, before reducing rate.
+	 * indicates that the IPv4 TTL or IPv6 hop limit check
+	 * have failed (e.g. TTL = 0) in the tunnel header. Valid
+	 * for IPv4, and IPv6.
 	 */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_REDUCTION_RELAX_RTTS_TH	UINT32_C(0x40)
+		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_L3_BAD_TTL		(UINT32_C(0x6) << 9)
+		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_PKT_ERROR_LAST		CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_L3_BAD_TTL
 	/*
-	 * Update additional number of RTTS with CNPs, to wait,
-	 * before further rate reduction, for low rates.
+	 * This indicates that there was an error in the inner
+	 * portion of the packet when this
+	 * field is non-zero.
 	 */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_ADDITIONAL_RELAX_CR_TH		UINT32_C(0x80)
-	/* Update threshold for update to Actual Current Rate (CR) */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_CR_MIN_TH			UINT32_C(0x100)
-	/* Update log based averaging weight for QPC variable actual_cr */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_BW_AVG_WEIGHT			UINT32_C(0x200)
-	/* Update factor used in the computation of rate reduction. */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_ACTUAL_CR_FACTOR		UINT32_C(0x400)
-	/* Update the level of CR above which CP is set to maximum level. */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_MAX_CP_CR_TH			UINT32_C(0x800)
-	/* Enable adding fraction of CR to CP. */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_CP_BIAS_EN			UINT32_C(0x1000)
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_MASK			UINT32_C(0xf000)
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_SFT			12
 	/*
-	 * Update log based fraction of CR to add to CP
-	 * when cp_bias_en is 1.
+	 * No additional error occurred on the tunnel portion
+	 * of the packet of the packet does not have a tunnel.
 	 */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_CP_BIAS			UINT32_C(0x2000)
-	/* Update ECN bits in a CNP packet generated by hardware. */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_CNP_ECN			UINT32_C(0x4000)
-	/* Update enable of jitter in RTT. */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_RTT_JITTER_EN			UINT32_C(0x8000)
-	/* Update number of bytes per usec. */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_LINK_BYTES_PER_USEC		UINT32_C(0x10000)
-	/* Update threshold used to reset QPC CC state to its initial state. */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_RESET_CC_CR_TH			UINT32_C(0x20000)
-	/* Update number of valid lsbits in CR and TR */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_CR_WIDTH			UINT32_C(0x40000)
-	/* Update lower end of random selection of quota_period. */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_QUOTA_PERIOD_MIN		UINT32_C(0x80000)
-	/* Update upper end of random selection of quota_period. */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_QUOTA_PERIOD_MAX		UINT32_C(0x100000)
+		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_NO_ERROR		(UINT32_C(0x0) << 12)
 	/*
-	 * Update absolute maximum possible quota_period,
-	 * when rate table for lower 24 levels is used.
+	 * Indicates that IP header version does not match
+	 * expectation from L2 Ethertype for IPv4 and IPv6 or that
+	 * option other than VFT was parsed on
+	 * FCoE packet.
 	 */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_QUOTA_PERIOD_ABS_MAX		UINT32_C(0x200000)
-	/* Update lower bound of TR. */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_TR_LOWER_BOUND			UINT32_C(0x400000)
+		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_L3_BAD_VERSION		(UINT32_C(0x1) << 12)
 	/*
-	 * Update factor on probability threshold for adding
-	 * 0.5 to CR randomly.
+	 * indicates that header length is out of range. Valid for
+	 * IPv4 and RoCE
 	 */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_CR_PROB_FACTOR			UINT32_C(0x800000)
+		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_L3_BAD_HDR_LEN		(UINT32_C(0x2) << 12)
 	/*
-	 * Update factor on probability threshold for adding
-	 * 0.5 to TR randomly.
+	 * indicates that the IPv4 TTL or IPv6 hop limit check
+	 * have failed (e.g. TTL = 0). Valid for IPv4, and IPv6
 	 */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_TR_PROB_FACTOR			UINT32_C(0x1000000)
+		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_L3_BAD_TTL		(UINT32_C(0x3) << 12)
 	/*
-	 * Update threshold that ensures fairness between requester
-	 * and responder
+	 * Indicates that physical packet is shorter than that
+	 * claimed by the l3 header length. Valid for IPv4,
+	 * IPv6 packet or RoCE packets.
 	 */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_FAIRNESS_CR_TH			UINT32_C(0x2000000)
-	/* Update log based rate reduction divider. */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_RED_DIV			UINT32_C(0x4000000)
+		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_IP_TOTAL_ERROR		(UINT32_C(0x4) << 12)
 	/*
-	 * Update threshold for rate reductions when CNPS received
-	 * over last RTT.
+	 * Indicates that the physical packet is shorter than that
+	 * claimed by the UDP header length for a UDP packet that is
+	 * not fragmented.
 	 */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_CNP_RATIO_TH			UINT32_C(0x8000000)
+		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_UDP_TOTAL_ERROR	(UINT32_C(0x5) << 12)
 	/*
-	 * Update extended number of RTTS to wait,
-	 * when there is no congestion, to start doubling the rate.
+	 * Indicates that TCP header length > IP payload. Valid for
+	 * TCP packets only.
 	 */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_EXP_AI_RTTS			UINT32_C(0x10000000)
-	/* Update log based CR to CP ratio used in exponential increase. */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_EXP_AI_CR_CP_RATIO		UINT32_C(0x20000000)
+		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_L4_BAD_HDR_LEN		(UINT32_C(0x6) << 12)
+	/* Indicates that TCP header length < 5. Valid for TCP. */
+		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_L4_BAD_HDR_LEN_TOO_SMALL  (UINT32_C(0x7) << 12)
 	/*
-	 * Update threshold, in congestion free RTTs,
-	 * that triggers start of CP update to track CR.
+	 * Indicates that TCP option headers result in a TCP header
+	 * size that does not match data offset in TCP header. Valid
+	 * for TCP.
 	 */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_CP_EXP_UPDATE_TH		UINT32_C(0x40000000)
+		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_L4_BAD_OPT_LEN		(UINT32_C(0x8) << 12)
+		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_LAST			CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_L4_BAD_OPT_LEN
 	/*
-	 * Update threshold on congestion free RTTs above
-	 * which AI can increase to 16.
+	 * This field identifies the CFA action rule that was used for this
+	 * packet.
 	 */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_HIGH_EXP_AI_RTTS_TH1		UINT32_C(0x80000000)
+	uint16_t	raweth_qp1_cfa_code;
 	/*
-	 * Update threshold on congestion free RTTs above
-	 * which AI can increase to 32.
+	 * This is an application level ID used to identify the
+	 * QP and its SQ and RQ.
 	 */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_HIGH_EXP_AI_RTTS_TH2		UINT32_C(0x100000000)L
-	/* Update use of lowest 24 rate levels rate_table. */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_USE_RATE_TABLE			UINT32_C(0x200000000)L
+	uint64_t	qp_handle;
+	uint32_t	raweth_qp1_flags2;
 	/*
-	 * Update the maximum number of 64B that can be transmitted
-	 * during RTT time.
+	 * This indicates that the ip checksum was calculated for the
+	 * inner packet and that the ip_cs_error field indicates if there
+	 * was an error.
 	 */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_LINK64B_PER_RTT		UINT32_C(0x400000000)L
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_IP_CS_CALC		UINT32_C(0x1)
 	/*
-	 * Update number of congestion free RTTs above which
-	 * reduction based on actual rate is enabled.
+	 * This indicates that the TCP, UDP or ICMP checksum was
+	 * calculated for the inner packet and that the l4_cs_error field
+	 * indicates if there was an error.
 	 */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_ACTUAL_CR_CONG_FREE_RTTS_TH	UINT32_C(0x800000000)L
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_L4_CS_CALC		UINT32_C(0x2)
 	/*
-	 * Update threshold used in severe congestion for
-	 * limiting TR to 1.5 times CR.
+	 * This indicates that the ip checksum was calculated for the
+	 * tunnel header and that the t_ip_cs_error field indicates if
+	 * there was an error.
 	 */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_SEVERE_CONG_CR_TH1		UINT32_C(0x1000000000)L
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_T_IP_CS_CALC		UINT32_C(0x4)
 	/*
-	 * Update threshold used in severe congestion for
-	 * limiting TR to 1.25 times CR.
+	 * This indicates that the UDP checksum was
+	 * calculated for the tunnel packet and that the t_l4_cs_error
+	 * field indicates if there was an error.
 	 */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_SEVERE_CONG_CR_TH2		UINT32_C(0x2000000000)L
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_T_L4_CS_CALC		UINT32_C(0x8)
 	/*
-	 * Update number of bytes to subtract from QPC.cc_bucket
-	 * when an ack is scheduled.
+	 * This value indicates what format the raweth_qp1_metadata field
+	 * is.
 	 */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_CC_ACK_BYTES			UINT32_C(0x4000000000)L
-	/* Update enable of reduction of CR, TR, and CP to init values. */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_REDUCE_INIT_EN			UINT32_C(0x8000000000)L
-	/* Update threshold used for reduction of CR, TR, and CP to init values. */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_REDUCE_INIT_CONG_FREE_RTTS_TH	UINT32_C(0x10000000000)L
-	/* Update enable of random no reduction of CR. */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_RANDOM_NO_RED_EN		UINT32_C(0x20000000000)L
-	/* Update enable of coarse correction to actual CR. */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_ACTUAL_CR_SHIFT_CORRECTION_EN	UINT32_C(0x40000000000)L
-	/* Update enable of adjustment to refill quota. */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_MODIFY_MASK_QUOTA_PERIOD_ADJUST_EN		UINT32_C(0x80000000000)L
-	/* High order bits of inactivity threshold. */
-	uint16_t	inactivity_th_hi;
-	/* The number of uS between generation of CNPs when cc_mode is probabilistic marking. */
-	uint16_t	min_time_between_cnps;
-	/* The starting value of congestion probability. Input range is 0 - 1023. */
-	uint16_t	init_cp;
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_META_FORMAT_MASK	UINT32_C(0xf0)
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_META_FORMAT_SFT		4
+	/* No metadata information. Value is zero. */
+		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_META_FORMAT_NONE		(UINT32_C(0x0) << 4)
 	/*
-	 * In tr_update_mode 0, Target Rate (TR) is updated to
-	 * halfway between the Current Rate (CR) before and after reduction.
-	 * In tr_update_mode 1, TR is updated to CR's value before reduction.
+	 * The raweth_qp1_metadata field contains the VLAN tag and TPID
+	 * value.
+	 * - raweth_qp1_metadata[11:0] contains the vlan VID value.
+	 * - raweth_qp1_metadata[12] contains the vlan DE value.
+	 * - raweth_qp1_metadata[15:13] contains the vlan PRI value.
+	 * - raweth_qp1_metadata[31:16] contains the vlan TPID value.
 	 */
-	uint8_t	tr_update_mode;
+		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_META_FORMAT_VLAN		(UINT32_C(0x1) << 4)
 	/*
-	 * Determine for how many RTTs with CNPs in a row, TR is being updated.
-	 * 0: TR is updated when QPC. rtts_with_cnps == 0
-	 * 1-6: TR is updated if QPC. rtts_with_cnps <= tr_update_cycles
-	 * 7: TR is updated on all reductions.
+	 * If ext_meta_format is equal to 1, the metadata field
+	 * contains the lower 16b of the tunnel ID value, justified
+	 * to LSB
+	 * - VXLAN = VNI[23:0] -> VXLAN Network ID
+	 * - Geneve (NGE) = VNI[23:0] -> Virtual Network Identifier.
+	 * - NVGRE = TNI[23:0] -> Tenant Network ID
+	 * - GRE = KEY[31:0] -> key field with bit mask. zero if K = 0
+	 * - IPV4 = 0 (not populated)
+	 * - IPV6 = Flow Label[19:0]
+	 * - PPPoE = sessionID[15:0]
+	 * - MPLs = Outer label[19:0]
+	 * - UPAR = Selected[31:0] with bit mask
 	 */
-	uint8_t	tr_update_cycles;
-	/* Number of RTTs in Fast Recovery stage. */
-	uint8_t	fr_num_rtts;
-	/* Time increment to increase TR in active increase phase. */
-	uint8_t	ai_rate_increase;
+		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_META_FORMAT_TUNNEL_ID	(UINT32_C(0x2) << 4)
 	/*
-	 * Indicates for how many RTTs with CNPs after the first one
-	 * to not reduce rate even if CNPs are received.
+	 * if ext_meta_format is equal to 1, metadata field contains
+	 * 16b metadata from the prepended header (chdr_data).
 	 */
-	uint16_t	reduction_relax_rtts_th;
+		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_META_FORMAT_CHDR_DATA	(UINT32_C(0x3) << 4)
 	/*
-	 * For low rates, additional number of RTTS with CNPs
-	 * for which no rate reduction is made.
-	 * num_bits: 14
+	 * If ext_meta_format is equal to 1, the metadata field contains
+	 * the outer_l3_offset and lower 7 bits of the inner_l2_offset,
+	 * - metadata[8:0] contains the outer_l3_offset.
+	 * - metadata[15:9] contains the inner_l2_offset[6:0]
 	 */
-	uint16_t	additional_relax_cr_th;
+		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_META_FORMAT_HDR_OFFSET	(UINT32_C(0x4) << 4)
+		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_META_FORMAT_LAST		CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_META_FORMAT_HDR_OFFSET
 	/*
-	 * If CR is less than or equal to this value,
-	 * then the actual CR average is set to this value
-	 * (shifted by bw_avg_weight).
+	 * This field indicates the IP type for the inner-most IP header.
+	 * A value of '0' indicates IPv4. A value of '1' indicates IPv6.
+	 * This value is only valid if itype indicates a packet
+	 * with an IP header.
 	 */
-	uint16_t	cr_min_th;
-	/* Log based averaging weight for QPC variable actual_cr_avg. */
-	uint8_t	bw_avg_weight;
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_IP_TYPE			UINT32_C(0x100)
 	/*
-	 * Used to compare CR to this factor times QPC.actual_cr_average
-	 * as a reduction reference. Values between 0 and 6 represent factor of
-	 * 1.125, 1.25, 1.5, 1.75, 2, 2.25, 2.5 respectively.
+	 * This indicates that the complete 1's complement checksum was
+	 * calculated for the packet.
 	 */
-	uint8_t	actual_cr_factor;
-	/* The level of CR above which CP is set to maximum level. */
-	uint16_t	max_cp_cr_th;
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_COMPLETE_CHECKSUM_CALC	UINT32_C(0x200)
 	/*
-	 * Enable adding fraction of CR to CP.
-	 * 0 for disable, 1 for enable.
+	 * The combination of this value and meta_format indicated what
+	 * format the metadata field is.
 	 */
-	uint8_t	cp_bias_en;
-	/* Log based fraction of cr to add to CP when cp_bias_en is 1. */
-	uint8_t	cp_bias;
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_EXT_META_FORMAT_MASK	UINT32_C(0xc00)
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_EXT_META_FORMAT_SFT	10
 	/*
-	 * The value of ECN bits in a CNP packet generated by hardware.
-	 * ECN-Capabale Transport (ECT) codepoints supported include:
-	 * 0 for not_ect, 1 for ect_0, 2 for ect_1
+	 * This value is the complete 1's complement checksum calculated
+	 * from the start of the outer L3 header to the end of the packet
+	 * (not including the ethernet crc). It is valid when the
+	 * 'complete_checksum_calc' flag is set.
 	 */
-	uint8_t	cnp_ecn;
-	/* Not ECN capable Transport */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_CNP_ECN_NOT_ECT UINT32_C(0x0)
-	/* ECN Capable Transport-1 */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_CNP_ECN_ECT_1   UINT32_C(0x1)
-	/* ECN Capable Transport-0 */
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_CNP_ECN_ECT_0   UINT32_C(0x2)
-	#define CMDQ_MODIFY_ROCE_CC_GEN1_TLV_CNP_ECN_LAST   CMDQ_MODIFY_ROCE_CC_GEN1_TLV_CNP_ECN_ECT_0
-	/* Enables jitter in RTT. */
-	uint8_t	rtt_jitter_en;
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_COMPLETE_CHECKSUM_MASK	UINT32_C(0xffff0000)
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_COMPLETE_CHECKSUM_SFT	16
 	/*
-	 * Number of bytes per usec, dependant on port speed.
-	 * 200 Gbps: 25,000
-	 * 100 Gbps: 12,500
-	 * 50 Gbps: 6,250
-	 * 25 Gbps: 3125
-	 * 10 Gbps: 1250
+	 * This is data from the CFA block as indicated by the meta_format
+	 * field.
 	 */
-	uint16_t	link_bytes_per_usec;
+	uint32_t	raweth_qp1_metadata;
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_PRI_DE_VID_MASK	UINT32_C(0xffff)
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_PRI_DE_VID_SFT	0
+	/* When meta_format=1, this value is the VLAN VID. */
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_VID_MASK	UINT32_C(0xfff)
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_VID_SFT		0
+	/* When meta_format=1, this value is the VLAN DE. */
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_DE		UINT32_C(0x1000)
+	/* When meta_format=1, this value is the VLAN PRI. */
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_PRI_MASK	UINT32_C(0xe000)
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_PRI_SFT		13
+	/* When meta_format=1, this value is the VLAN TPID. */
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_TPID_MASK	UINT32_C(0xffff0000)
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_TPID_SFT	16
+	uint8_t	cqe_type_toggle;
 	/*
-	 * If CR is greater than or equal to this threshold,
-	 * QPC's CC state is reset to its initial state.
+	 * Indicate valid completion - written by the chip. Cumulus
+	 * toggle this bit each time it finished consuming all PBL
+	 * entries
 	 */
-	uint16_t	reset_cc_cr_th;
+	#define CQ_RES_RAWETH_QP1_TOGGLE		UINT32_C(0x1)
+	/* This field defines the type of CQE. */
+	#define CQ_RES_RAWETH_QP1_CQE_TYPE_MASK	UINT32_C(0x1e)
+	#define CQ_RES_RAWETH_QP1_CQE_TYPE_SFT	1
 	/*
-	 * The number of valid lsbits in CR and TR.
-	 * Supported values include 10 through 14 to support 2^cr_width rate.
+	 * Responder RawEth and QP1 Completion - This is used for RQ
+	 * completion for RawEth service and QP1 service QPs.
 	 */
-	uint8_t	cr_width;
-	/* Lower end of random selection of quota_period. */
-	uint8_t	quota_period_min;
-	/* Upper end of random selection of quota_period. */
-	uint8_t	quota_period_max;
+		#define CQ_RES_RAWETH_QP1_CQE_TYPE_RES_RAWETH_QP1  (UINT32_C(0x3) << 1)
+		#define CQ_RES_RAWETH_QP1_CQE_TYPE_LAST	CQ_RES_RAWETH_QP1_CQE_TYPE_RES_RAWETH_QP1
+	/* This field indicates the status for the CQE. */
+	uint8_t	status;
 	/*
-	 * The absolute maximum possible quota_period,
-	 * applicable when rate table for lower 24 levels is used.
+	 * This indicates that the completion is without error.
+	 * All fields are valid.
 	 */
-	uint8_t	quota_period_abs_max;
-	/* TR never goes below this level. */
-	uint16_t	tr_lower_bound;
-	/* Factor on probability threshold for adding 0.5 to CR randomly. */
-	uint8_t	cr_prob_factor;
-	/* Factor on probability threshold for adding 0.5 to TR randomly. */
-	uint8_t	tr_prob_factor;
+	#define CQ_RES_RAWETH_QP1_STATUS_OK			UINT32_C(0x0)
 	/*
-	 * Threshold to ensure fairness between requester and responder.
-	 * If CR is less than the fairness threshold and a quota period has passed
-	 * priority will be given to the path that did not last transfer data.
+	 * This indicates that write access was not allowed for
+	 * at least one of the SGEs in the WQE.
+	 *
+	 * This is a fatal error. Only the srq_or_rq_wr_id is field
+	 * is valid.
 	 */
-	uint16_t	fairness_cr_th;
-	/* Log based rate reduction divider. */
-	uint8_t	red_div;
-	/* Threshold for rate reductions when CNPS received over last RTT. */
-	uint8_t	cnp_ratio_th;
+	#define CQ_RES_RAWETH_QP1_STATUS_LOCAL_ACCESS_ERROR	UINT32_C(0x1)
 	/*
-	 * Extended number of RTTS to wait, when there is no congestion,
-	 * to start doubling the rate.
+	 * This indicates that the packet was too long for the WQE
+	 * provided on the RQ.
+	 *
+	 * This is not a fatal error. All the fields are valid.
 	 */
-	uint16_t	exp_ai_rtts;
-	/* Log based CR to CP ratio used in exponential increase. */
-	uint8_t	exp_ai_cr_cp_ratio;
-	/* Enable use of lowest 24 rate levels rate_table. */
-	uint8_t	use_rate_table;
+	#define CQ_RES_RAWETH_QP1_STATUS_HW_LOCAL_LENGTH_ERR	UINT32_C(0x2)
+	/* LOCAL_PROTECTION_ERR is 3 */
+	#define CQ_RES_RAWETH_QP1_STATUS_LOCAL_PROTECTION_ERR	UINT32_C(0x3)
+	/* LOCAL_QP_OPERATION_ERR is 4 */
+	#define CQ_RES_RAWETH_QP1_STATUS_LOCAL_QP_OPERATION_ERR   UINT32_C(0x4)
+	/* MEMORY_MGT_OPERATION_ERR is 5 */
+	#define CQ_RES_RAWETH_QP1_STATUS_MEMORY_MGT_OPERATION_ERR UINT32_C(0x5)
+	/* WORK_REQUEST_FLUSHED_ERR is 7 */
+	#define CQ_RES_RAWETH_QP1_STATUS_WORK_REQUEST_FLUSHED_ERR UINT32_C(0x7)
+	/* HW_FLUSH_ERR is 8 */
+	#define CQ_RES_RAWETH_QP1_STATUS_HW_FLUSH_ERR		UINT32_C(0x8)
+	#define CQ_RES_RAWETH_QP1_STATUS_LAST			CQ_RES_RAWETH_QP1_STATUS_HW_FLUSH_ERR
+	uint16_t	flags;
 	/*
-	 * Determines after how many congestion free RTTs to start
-	 * updating CP to track CR.
+	 * This flag indicates that the completion is for a SRQ entry
+	 * rather than for an RQ entry.
 	 */
-	uint16_t	cp_exp_update_th;
-	/* The threshold on congestion free RTTs above which AI can increase to 16. */
-	uint16_t	high_exp_ai_rtts_th1;
-	/* The threshold on congestion free RTTs above which AI can increase to 32. */
-	uint16_t	high_exp_ai_rtts_th2;
+	#define CQ_RES_RAWETH_QP1_FLAGS_SRQ	UINT32_C(0x1)
+	/* CQE relates to RQ WQE. */
+		#define CQ_RES_RAWETH_QP1_FLAGS_SRQ_RQ	UINT32_C(0x0)
+	/* CQE relates to SRQ WQE. */
+		#define CQ_RES_RAWETH_QP1_FLAGS_SRQ_SRQ   UINT32_C(0x1)
+		#define CQ_RES_RAWETH_QP1_FLAGS_SRQ_LAST CQ_RES_RAWETH_QP1_FLAGS_SRQ_SRQ
+	uint32_t	raweth_qp1_payload_offset_srq_or_rq_wr_id;
 	/*
-	 * The number of congestion free RTTs above which
-	 * reduction based on actual rate is enabled.
+	 * Opaque value from RQ or SRQ WQE. Used by driver/lib to
+	 * reference the WQE in order to claim the received data
+	 * and reuse the WQE space
 	 */
-	uint16_t	actual_cr_cong_free_rtts_th;
+	#define CQ_RES_RAWETH_QP1_SRQ_OR_RQ_WR_ID_MASK	UINT32_C(0xfffff)
+	#define CQ_RES_RAWETH_QP1_SRQ_OR_RQ_WR_ID_SFT	0
 	/*
-	 * If rtts_with_cong is greater than 7 (severe congestion) and
-	 * CR level post reduction is above this threshold,
-	 * then TR is capped to 1.5 times CR..
+	 * This value indicates the offset in bytes from the beginning of the
+	 * packet where the inner payload starts. This value is valid for
+	 * TCP, UDP, FCoE, and RoCE packets.
+	 * A value of zero indicates an offset of 256 bytes.
 	 */
-	uint16_t	severe_cong_cr_th1;
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_PAYLOAD_OFFSET_MASK UINT32_C(0xff000000)
+	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_PAYLOAD_OFFSET_SFT 24
+} cq_res_raweth_qp1_t, *pcq_res_raweth_qp1_t;
+
+/* Responder RawEth and QP1 CQE version 2 */
+/* cq_res_raweth_qp1_v2 (size:256b/32B) */
+
+typedef struct cq_res_raweth_qp1_v2 {
+	uint16_t	length;
 	/*
-	 * If rtts_with_cong is greater than 7 (severe congestion) and
-	 * CR level post reduction is above this threshold,
-	 * then TR is capped to 1.25 times CR..
+	 * The length of the message's payload in bytes, stored in
+	 * the SGEs
 	 */
-	uint16_t	severe_cong_cr_th2;
+	#define CQ_RES_RAWETH_QP1_V2_LENGTH_MASK UINT32_C(0x3fff)
+	#define CQ_RES_RAWETH_QP1_V2_LENGTH_SFT 0
+	uint16_t	raweth_qp1_flags;
+	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS_MASK		UINT32_C(0x3ff)
+	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS_SFT		0
 	/*
-	 * The maximum number of 64B that can be transmitted during RTT time,
-	 * including all headers and Inter Packet Gap.
+	 * When this bit is '1', it indicates a packet that has an
+	 * error of some type. Type of error is indicated in
+	 * raweth_qp1_errors.
 	 */
-	uint32_t	link64B_per_rtt;
+	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS_ERROR		UINT32_C(0x1)
 	/*
-	 * The number of bytes to subtract from QPC.cc_bucket
-	 * when an ack is scheduled.
+	 * This value indicates what the inner packet determined for the
+	 * packet was.
 	 */
-	uint8_t	cc_ack_bytes;
+	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS_ITYPE_MASK		UINT32_C(0x3c0)
+	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS_ITYPE_SFT		6
 	/*
-	 * Enables reduction of CR, TR, and CP to init values when
-	 * congestion free RTTs is greater than reduce2_init_cong_free_rtts_th.
+	 * Not Known:
+	 * Indicates that the packet type was not known.
 	 */
-	uint8_t	reduce_init_en;
+		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS_ITYPE_NOT_KNOWN	(UINT32_C(0x0) << 6)
 	/*
-	 * Minimum threshold value for number of congestion free RTTs before reducing
-	 * to init values for CR, TR, and CP when reduce_init_en is enabled.
+	 * IP Packet:
+	 * Indicates that the packet was an IP packet, but further
+	 * classification was not possible.
 	 */
-	uint16_t	reduce_init_cong_free_rtts_th;
-	/* Enables random no reduction of CR. */
-	uint8_t	random_no_red_en;
-	/* Enables coarse correction to actual CR when actual RTT is longer than nominal. */
-	uint8_t	actual_cr_shift_correction_en;
-	/* Enables adjustment to refill quota. */
-	uint8_t	quota_period_adjust_en;
-	uint8_t	reserved[5];
-} cmdq_modify_roce_cc_gen1_tlv_t, *pcmdq_modify_roce_cc_gen1_tlv_t;
-
-/* creq_modify_roce_cc_resp (size:128b/16B) */
-
-typedef struct creq_modify_roce_cc_resp {
-	uint8_t	type;
+		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS_ITYPE_IP		(UINT32_C(0x1) << 6)
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * TCP Packet:
+	 * Indicates that the packet was IP and TCP.
+	 * This indicates that the raweth_qp1_payload_offset field is
+	 * valid.
 	 */
-	#define CREQ_MODIFY_ROCE_CC_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_MODIFY_ROCE_CC_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_MODIFY_ROCE_CC_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_MODIFY_ROCE_CC_RESP_TYPE_LAST	CREQ_MODIFY_ROCE_CC_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	uint32_t	reserved32;
-	uint8_t	v;
+		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS_ITYPE_TCP		(UINT32_C(0x2) << 6)
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * UDP Packet:
+	 * Indicates that the packet was IP and UDP.
+	 * This indicates that the raweth_qp1_payload_offset field is
+	 * valid.
 	 */
-	#define CREQ_MODIFY_ROCE_CC_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Modify congestion control response. */
-	#define CREQ_MODIFY_ROCE_CC_RESP_EVENT_MODIFY_ROCE_CC UINT32_C(0x8c)
-	#define CREQ_MODIFY_ROCE_CC_RESP_EVENT_LAST	CREQ_MODIFY_ROCE_CC_RESP_EVENT_MODIFY_ROCE_CC
-	uint8_t	reserved48[6];
-} creq_modify_roce_cc_resp_t, *pcreq_modify_roce_cc_resp_t;
-
-/******************************
- * cmdq_set_link_aggr_mode_cc *
- ******************************/
-
-
-/* cmdq_set_link_aggr_mode_cc (size:320b/40B) */
-
-typedef struct cmdq_set_link_aggr_mode_cc {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Set LAG mode. */
-	#define CMDQ_SET_LINK_AGGR_MODE_OPCODE_SET_LINK_AGGR_MODE UINT32_C(0x8f)
-	#define CMDQ_SET_LINK_AGGR_MODE_OPCODE_LAST		CMDQ_SET_LINK_AGGR_MODE_OPCODE_SET_LINK_AGGR_MODE
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	/* Modify mask signifies the field that is requesting the change. */
-	uint32_t	modify_mask;
-	/* Enable Link aggregation. */
-	#define CMDQ_SET_LINK_AGGR_MODE_MODIFY_MASK_AGGR_EN		UINT32_C(0x1)
-	/* Bitmap of ports that are eligible to transmit RoCE traffic. */
-	#define CMDQ_SET_LINK_AGGR_MODE_MODIFY_MASK_ACTIVE_PORT_MAP	UINT32_C(0x2)
-	/* Bitmap of ports that are members of the RoCE LAG. */
-	#define CMDQ_SET_LINK_AGGR_MODE_MODIFY_MASK_MEMBER_PORT_MAP	UINT32_C(0x4)
-	/* Link aggregation mode being used. */
-	#define CMDQ_SET_LINK_AGGR_MODE_MODIFY_MASK_AGGR_MODE	UINT32_C(0x8)
-	/* Stat context ID for all the ports. */
-	#define CMDQ_SET_LINK_AGGR_MODE_MODIFY_MASK_STAT_CTX_ID	UINT32_C(0x10)
-	uint8_t	aggr_enable;
-	/* Enable Link aggregation. */
-	#define CMDQ_SET_LINK_AGGR_MODE_AGGR_ENABLE	UINT32_C(0x1)
-	/* rsvd1 is 7 b */
-	#define CMDQ_SET_LINK_AGGR_MODE_RSVD1_MASK	UINT32_C(0xfe)
-	#define CMDQ_SET_LINK_AGGR_MODE_RSVD1_SFT	1
-	uint8_t	active_port_map;
-	/* Bitmap of ports that are eligible to transmit RoCE traffic. */
-	#define CMDQ_SET_LINK_AGGR_MODE_ACTIVE_PORT_MAP_MASK UINT32_C(0xf)
-	#define CMDQ_SET_LINK_AGGR_MODE_ACTIVE_PORT_MAP_SFT 0
-	/* rsvd2 is 4 b */
-	#define CMDQ_SET_LINK_AGGR_MODE_RSVD2_MASK	UINT32_C(0xf0)
-	#define CMDQ_SET_LINK_AGGR_MODE_RSVD2_SFT	4
-	/* Bitmap of ports that are members of the RoCE LAG. */
-	uint8_t	member_port_map;
-	/* Link aggregation mode being used. */
-	uint8_t	link_aggr_mode;
-	/* active active mode. */
-	#define CMDQ_SET_LINK_AGGR_MODE_AGGR_MODE_ACTIVE_ACTIVE UINT32_C(0x1)
-	/* active backup mode. */
-	#define CMDQ_SET_LINK_AGGR_MODE_AGGR_MODE_ACTIVE_BACKUP UINT32_C(0x2)
-	/* Balance XOR mode. */
-	#define CMDQ_SET_LINK_AGGR_MODE_AGGR_MODE_BALANCE_XOR   UINT32_C(0x3)
-	/* 802.3AD mode. */
-	#define CMDQ_SET_LINK_AGGR_MODE_AGGR_MODE_802_3_AD	UINT32_C(0x4)
-	#define CMDQ_SET_LINK_AGGR_MODE_AGGR_MODE_LAST	CMDQ_SET_LINK_AGGR_MODE_AGGR_MODE_802_3_AD
-	/* Stat context IDs for all 4 ports. */
-	uint16_t	stat_ctx_id[4];
-	uint64_t	rsvd1;
-} cmdq_set_link_aggr_mode_cc_t, *pcmdq_set_link_aggr_mode_cc_t;
-
-/* creq_set_link_aggr_mode_resources_resp (size:128b/16B) */
-
-typedef struct creq_set_link_aggr_mode_resources_resp {
-	uint8_t	type;
+		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS_ITYPE_UDP		(UINT32_C(0x3) << 6)
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * FCoE Packet:
+	 * Indicates that the packet was recognized as a FCoE.
+	 * This also indicates that the raweth_qp1_payload_offset field
+	 * is valid.
 	 */
-	#define CREQ_SET_LINK_AGGR_MODE_RESP_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_SET_LINK_AGGR_MODE_RESP_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_SET_LINK_AGGR_MODE_RESP_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_SET_LINK_AGGR_MODE_RESP_TYPE_LAST	CREQ_SET_LINK_AGGR_MODE_RESP_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	uint32_t	reserved32;
-	uint8_t	v;
+		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS_ITYPE_FCOE		(UINT32_C(0x4) << 6)
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * RoCE Packet:
+	 * Indicates that the packet was recognized as a RoCE.
+	 * This also indicates that the raweth_qp1_payload_offset field
+	 * is valid.
 	 */
-	#define CREQ_SET_LINK_AGGR_MODE_RESP_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Set LAG mode. */
-	#define CREQ_SET_LINK_AGGR_MODE_RESP_EVENT_SET_LINK_AGGR_MODE UINT32_C(0x8f)
-	#define CREQ_SET_LINK_AGGR_MODE_RESP_EVENT_LAST		CREQ_SET_LINK_AGGR_MODE_RESP_EVENT_SET_LINK_AGGR_MODE
-	uint8_t	reserved48[6];
-} creq_set_link_aggr_mode_resources_resp_t, *pcreq_set_link_aggr_mode_resources_resp_t;
-
-/* Send a request from VF to pass a command to the PF. VF HSI is suspended. */
-/* cmdq_vf_backchannel_request (size:256b/32B) */
-
-typedef struct cmdq_vf_backchannel_request {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Send a request from VF to pass a command to the PF. VF HSI is suspended until the PF returns the response */
-	#define CMDQ_VF_BACKCHANNEL_REQUEST_OPCODE_VF_BACKCHANNEL_REQUEST UINT32_C(0x86)
-	#define CMDQ_VF_BACKCHANNEL_REQUEST_OPCODE_LAST		CMDQ_VF_BACKCHANNEL_REQUEST_OPCODE_VF_BACKCHANNEL_REQUEST
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	/* Address of command request structure in VF space */
-	uint64_t	command_addr;
-	/* Command request length (up to 4K). An optional address of the extended response buffer should be provided in the request */
-	uint16_t	command_length;
-	uint8_t	unused_0[6];
-} cmdq_vf_backchannel_request_t, *pcmdq_vf_backchannel_request_t;
-
-/* Read VF memory (primarily to get the backchannel request blob). */
-/* cmdq_read_vf_memory (size:256b/32B) */
-
-typedef struct cmdq_read_vf_memory {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Read VF memory (primarily to get the backchannel request blob). Can only be issued from a PF. */
-	#define CMDQ_READ_VF_MEMORY_OPCODE_READ_VF_MEMORY UINT32_C(0x87)
-	#define CMDQ_READ_VF_MEMORY_OPCODE_LAST	CMDQ_READ_VF_MEMORY_OPCODE_READ_VF_MEMORY
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	/* Address of memory in VF space to read */
-	uint64_t	addr;
-	/* VF id, as provided in 0xC0 VF request notification */
-	uint16_t	vf_id;
-	/* Length to read, up to 4K */
-	uint16_t	length;
-	uint32_t	unused_0;
-} cmdq_read_vf_memory_t, *pcmdq_read_vf_memory_t;
-
-/* Write VF memory (primarily to put the backchannel response blob). */
-/* cmdq_complete_vf_request (size:320b/40B) */
-
-typedef struct cmdq_complete_vf_request {
-	/* Command opcode. */
-	uint8_t	opcode;
-	/* Write VF memory (primarily to put the backchannel response blob), and reenable VF HSI (post a CAG completion to it). Can only be issued from a PF. */
-	#define CMDQ_COMPLETE_VF_REQUEST_OPCODE_COMPLETE_VF_REQUEST UINT32_C(0x88)
-	#define CMDQ_COMPLETE_VF_REQUEST_OPCODE_LAST		CMDQ_COMPLETE_VF_REQUEST_OPCODE_COMPLETE_VF_REQUEST
-	/* Size of the command in 16-byte units. */
-	uint8_t	cmd_size;
-	/* Flags and attribs of the command. */
-	uint16_t	flags;
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	/* Size of the response buffer in 16-byte units. */
-	uint8_t	resp_size;
-	uint8_t	reserved8;
-	/* Host address of the response. */
-	uint64_t	resp_addr;
-	/* Optional address of extended response in VF space to write. Length is in resp_size in 16 byte units. */
-	uint64_t	addr;
-	/* Completion misc field to VF CREQ */
-	uint32_t	vf_misc;
-	/* VF id, as provided in 0xC0 VF request notification */
-	uint16_t	vf_id;
-	/* Completion cookie for the VF command, goes to VF CREQ */
-	uint16_t	vf_cookie;
-	/* Completion status for the VF command, goes to VF CREQ */
-	uint8_t	vf_status;
-	uint8_t	unused_0[3];
-	uint32_t	unused_1;
-} cmdq_complete_vf_request_t, *pcmdq_complete_vf_request_t;
-
-/* RoCE function async event notifications. */
-/* creq_func_event (size:128b/16B) */
-
-typedef struct creq_func_event {
-	uint8_t	type;
+		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS_ITYPE_ROCE		(UINT32_C(0x5) << 6)
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * ICMP Packet:
+	 * Indicates that the packet was recognized as ICMP.
+	 * This indicates that the raweth_qp1_payload_offset field is
+	 * valid.
 	 */
-	#define CREQ_FUNC_EVENT_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_FUNC_EVENT_TYPE_SFT	0
-	/* Function Async Notification */
-		#define CREQ_FUNC_EVENT_TYPE_FUNC_EVENT  UINT32_C(0x3a)
-		#define CREQ_FUNC_EVENT_TYPE_LAST	CREQ_FUNC_EVENT_TYPE_FUNC_EVENT
-	uint8_t	reserved56[7];
-	uint8_t	v;
+		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS_ITYPE_ICMP		(UINT32_C(0x7) << 6)
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * PtP packet wo/timestamp:
+	 * Indicates that the packet was recognized as a PtP
+	 * packet.
 	 */
-	#define CREQ_FUNC_EVENT_V	UINT32_C(0x1)
+		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS_ITYPE_PTP_WO_TIMESTAMP   (UINT32_C(0x8) << 6)
 	/*
-	 * This value defines what type of async event has occurred
-	 * on the function.
+	 * PtP packet w/timestamp:
+	 * Indicates that the packet was recognized as a PtP
+	 * packet and that a timestamp was taken for the packet.
 	 */
-	uint8_t	event;
+		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS_ITYPE_PTP_W_TIMESTAMP	(UINT32_C(0x9) << 6)
+		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS_ITYPE_LAST		CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS_ITYPE_PTP_W_TIMESTAMP
+	uint16_t	raweth_qp1_errors;
 	/*
-	 * Invalid PBL or PCIE UR response occurred
-	 * in SQ WQE or IRRQ read access.
+	 * This indicates that there was an error in the IP header
+	 * checksum.
 	 */
-	#define CREQ_FUNC_EVENT_EVENT_TX_WQE_ERROR	UINT32_C(0x1)
+	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_IP_CS_ERROR			UINT32_C(0x10)
 	/*
-	 * Invalid PBL or PCIE UR response occurred
-	 * during data read access.
+	 * This indicates that there was an error in the TCP, UDP
+	 * or ICMP checksum.
 	 */
-	#define CREQ_FUNC_EVENT_EVENT_TX_DATA_ERROR	UINT32_C(0x2)
+	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_L4_CS_ERROR			UINT32_C(0x20)
 	/*
-	 * Invalid PBL or PCIE UR response occurred
-	 * in RQ/SRQ WQE or ORRQ read access.
+	 * This indicates that there was an error in the tunnel
+	 * IP header checksum.
 	 */
-	#define CREQ_FUNC_EVENT_EVENT_RX_WQE_ERROR	UINT32_C(0x3)
-	/* Invalid PBL occurred during data write access. */
-	#define CREQ_FUNC_EVENT_EVENT_RX_DATA_ERROR	UINT32_C(0x4)
-	/* Invalid PBL occurred during CQ write access. */
-	#define CREQ_FUNC_EVENT_EVENT_CQ_ERROR	UINT32_C(0x5)
+	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_T_IP_CS_ERROR			UINT32_C(0x40)
 	/*
-	 * Invalid PBL or PCIE UR response occurred in TQM
-	 * read access.
+	 * This indicates that there was an error in the tunnel
+	 * UDP checksum.
 	 */
-	#define CREQ_FUNC_EVENT_EVENT_TQM_ERROR	UINT32_C(0x6)
-	/* PCIE UR response occurred in CFC read access. */
-	#define CREQ_FUNC_EVENT_EVENT_CFCQ_ERROR	UINT32_C(0x7)
-	/* PCIE UR response occurred in CFC read access. */
-	#define CREQ_FUNC_EVENT_EVENT_CFCS_ERROR	UINT32_C(0x8)
-	/* PCIE UR response occurred in CFC read access. */
-	#define CREQ_FUNC_EVENT_EVENT_CFCC_ERROR	UINT32_C(0x9)
-	/* PCIE UR response occurred in CFC read access. */
-	#define CREQ_FUNC_EVENT_EVENT_CFCM_ERROR	UINT32_C(0xa)
+	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_T_L4_CS_ERROR			UINT32_C(0x80)
 	/*
-	 * Invalid PBL or
-	 * PCIE UR response
-	 * occurred on timer read access.
+	 * This indicates that there was a CRC error on either an FCoE
+	 * or RoCE packet. The itype indicates the packet type.
 	 */
-	#define CREQ_FUNC_EVENT_EVENT_TIM_ERROR	UINT32_C(0xb)
-	/* A VF sent a backchannel command request */
-	#define CREQ_FUNC_EVENT_EVENT_VF_COMM_REQUEST	UINT32_C(0x80)
-	/* Communication resource (QPC, CQ, SRQ, MRW) exhausted, and resource array extension is enabled */
-	#define CREQ_FUNC_EVENT_EVENT_RESOURCE_EXHAUSTED UINT32_C(0x81)
-	#define CREQ_FUNC_EVENT_EVENT_LAST		CREQ_FUNC_EVENT_EVENT_RESOURCE_EXHAUSTED
-	uint8_t	reserved48[6];
-} creq_func_event_t, *pcreq_func_event_t;
-
-/* RoCE slowpath command completion events. */
-/* creq_qp_event (size:128b/16B) */
-
-typedef struct creq_qp_event {
-	uint8_t	type;
+	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_CRC_ERROR			UINT32_C(0x100)
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * This indicates that there was an error in the tunnel
+	 * portion of the packet when this
+	 * field is non-zero.
 	 */
-	#define CREQ_QP_EVENT_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_QP_EVENT_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_QP_EVENT_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_QP_EVENT_TYPE_LAST	CREQ_QP_EVENT_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* Success. */
-	#define CREQ_QP_EVENT_STATUS_SUCCESS	UINT32_C(0x0)
-	/* Fail. */
-	#define CREQ_QP_EVENT_STATUS_FAIL		UINT32_C(0x1)
-	/* Resources. */
-	#define CREQ_QP_EVENT_STATUS_RESOURCES	UINT32_C(0x2)
-	/* Invalid command. */
-	#define CREQ_QP_EVENT_STATUS_INVALID_CMD	UINT32_C(0x3)
-	/* Not implemented. */
-	#define CREQ_QP_EVENT_STATUS_NOT_IMPLEMENTED   UINT32_C(0x4)
-	/* Invalid parameter. */
-	#define CREQ_QP_EVENT_STATUS_INVALID_PARAMETER UINT32_C(0x5)
-	/* Hardware operation failed. */
-	#define CREQ_QP_EVENT_STATUS_HARDWARE_ERROR	UINT32_C(0x6)
-	/* Firmware operation failed due to internal error. */
-	#define CREQ_QP_EVENT_STATUS_INTERNAL_ERROR	UINT32_C(0x7)
-	#define CREQ_QP_EVENT_STATUS_LAST		CREQ_QP_EVENT_STATUS_INTERNAL_ERROR
-	/* Driver supplied handle to associate the command and the response. */
-	uint16_t	cookie;
-	uint32_t	reserved32;
-	uint8_t	v;
+	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_T_PKT_ERROR_MASK		UINT32_C(0xe00)
+	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_T_PKT_ERROR_SFT		9
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * No additional error occurred on the tunnel portion
+	 * of the packet of the packet does not have a tunnel.
 	 */
-	#define CREQ_QP_EVENT_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* Create QP command response. */
-	#define CREQ_QP_EVENT_EVENT_CREATE_QP		UINT32_C(0x1)
-	/* Destroy QP command response. */
-	#define CREQ_QP_EVENT_EVENT_DESTROY_QP		UINT32_C(0x2)
-	/* Modify QP command response. */
-	#define CREQ_QP_EVENT_EVENT_MODIFY_QP		UINT32_C(0x3)
-	/* Query QP command response. */
-	#define CREQ_QP_EVENT_EVENT_QUERY_QP		UINT32_C(0x4)
-	/* Create SRQ command response. */
-	#define CREQ_QP_EVENT_EVENT_CREATE_SRQ		UINT32_C(0x5)
-	/* Destroy SRQ command response. */
-	#define CREQ_QP_EVENT_EVENT_DESTROY_SRQ	UINT32_C(0x6)
-	/* Query SRQ command response. */
-	#define CREQ_QP_EVENT_EVENT_QUERY_SRQ		UINT32_C(0x8)
-	/* Create CQ command response. */
-	#define CREQ_QP_EVENT_EVENT_CREATE_CQ		UINT32_C(0x9)
-	/* Destroy CQ command response. */
-	#define CREQ_QP_EVENT_EVENT_DESTROY_CQ		UINT32_C(0xa)
-	/* Resize CQ command response. */
-	#define CREQ_QP_EVENT_EVENT_RESIZE_CQ		UINT32_C(0xc)
-	/* Allocate MRW command response. */
-	#define CREQ_QP_EVENT_EVENT_ALLOCATE_MRW	UINT32_C(0xd)
-	/* De-allocate key command response. */
-	#define CREQ_QP_EVENT_EVENT_DEALLOCATE_KEY	UINT32_C(0xe)
-	/* Register MR command response. */
-	#define CREQ_QP_EVENT_EVENT_REGISTER_MR	UINT32_C(0xf)
-	/* Deregister MR command response. */
-	#define CREQ_QP_EVENT_EVENT_DEREGISTER_MR	UINT32_C(0x10)
-	/* Add GID command response. */
-	#define CREQ_QP_EVENT_EVENT_ADD_GID		UINT32_C(0x11)
-	/* Delete GID command response. */
-	#define CREQ_QP_EVENT_EVENT_DELETE_GID		UINT32_C(0x12)
-	/* Modify GID command response. */
-	#define CREQ_QP_EVENT_EVENT_MODIFY_GID		UINT32_C(0x17)
-	/* Query GID command response. */
-	#define CREQ_QP_EVENT_EVENT_QUERY_GID		UINT32_C(0x18)
-	/* Create QP1 command response. */
-	#define CREQ_QP_EVENT_EVENT_CREATE_QP1		UINT32_C(0x13)
-	/* Destroy QP1 command response. */
-	#define CREQ_QP_EVENT_EVENT_DESTROY_QP1	UINT32_C(0x14)
-	/* Create AH command response. */
-	#define CREQ_QP_EVENT_EVENT_CREATE_AH		UINT32_C(0x15)
-	/* Destroy AH command response. */
-	#define CREQ_QP_EVENT_EVENT_DESTROY_AH		UINT32_C(0x16)
-	/* Initialize firmware command response. */
-	#define CREQ_QP_EVENT_EVENT_INITIALIZE_FW	UINT32_C(0x80)
-	/* De-initialize firmware command response. */
-	#define CREQ_QP_EVENT_EVENT_DEINITIALIZE_FW	UINT32_C(0x81)
-	/* Stop PF command response. */
-	#define CREQ_QP_EVENT_EVENT_STOP_FUNC		UINT32_C(0x82)
-	/* Query info PF command response. */
-	#define CREQ_QP_EVENT_EVENT_QUERY_FUNC		UINT32_C(0x83)
-	/* Set function resources command response. */
-	#define CREQ_QP_EVENT_EVENT_SET_FUNC_RESOURCES	UINT32_C(0x84)
-	/* Read the current state of any internal resource context. Can only be issued from a PF. */
-	#define CREQ_QP_EVENT_EVENT_READ_CONTEXT	UINT32_C(0x85)
-	/* Map TC to COS response. */
-	#define CREQ_QP_EVENT_EVENT_MAP_TC_TO_COS	UINT32_C(0x8a)
-	/* Query firmware and interface version response. */
-	#define CREQ_QP_EVENT_EVENT_QUERY_VERSION	UINT32_C(0x8b)
-	/* Modify congestion control response. */
-	#define CREQ_QP_EVENT_EVENT_MODIFY_CC		UINT32_C(0x8c)
-	/* Query congestion control response. */
-	#define CREQ_QP_EVENT_EVENT_QUERY_CC		UINT32_C(0x8d)
-	/* Query RoCE statistics. */
-	#define CREQ_QP_EVENT_EVENT_QUERY_ROCE_STATS	UINT32_C(0x8e)
-	/* Set LAG mode. */
-	#define CREQ_QP_EVENT_EVENT_SET_LINK_AGGR_MODE	UINT32_C(0x8f)
+		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_T_PKT_ERROR_NO_ERROR		(UINT32_C(0x0) << 9)
 	/*
-	 * Query QP for a PF other than the requesting PF. Also can query for more
-	 * than one QP.
+	 * Indicates that IP header version does not match
+	 * expectation from L2 Ethertype for IPv4 and IPv6
+	 * in the tunnel header.
 	 */
-	#define CREQ_QP_EVENT_EVENT_QUERY_QP_EXTEND	UINT32_C(0x91)
-	/* QP error notification event. */
-	#define CREQ_QP_EVENT_EVENT_QP_ERROR_NOTIFICATION UINT32_C(0xc0)
-	/* CQ error notification event. */
-	#define CREQ_QP_EVENT_EVENT_CQ_ERROR_NOTIFICATION UINT32_C(0xc1)
-	#define CREQ_QP_EVENT_EVENT_LAST		CREQ_QP_EVENT_EVENT_CQ_ERROR_NOTIFICATION
-	uint8_t	reserved48[6];
-} creq_qp_event_t, *pcreq_qp_event_t;
-
-/* QP error notification event. */
-/* creq_qp_error_notification (size:128b/16B) */
-
-typedef struct creq_qp_error_notification {
-	uint8_t	type;
+		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_L3_BAD_VERSION	(UINT32_C(0x1) << 9)
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * Indicates that header length is out of range in the
+	 * tunnel header. Valid for
+	 * IPv4.
 	 */
-	#define CREQ_QP_ERROR_NOTIFICATION_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_QP_ERROR_NOTIFICATION_TYPE_SFT	0
-	/* QP Async Notification */
-		#define CREQ_QP_ERROR_NOTIFICATION_TYPE_QP_EVENT  UINT32_C(0x38)
-		#define CREQ_QP_ERROR_NOTIFICATION_TYPE_LAST	CREQ_QP_ERROR_NOTIFICATION_TYPE_QP_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* requestor slow path state */
-	uint8_t	req_slow_path_state;
-	/* requestor error reason */
-	uint8_t	req_err_state_reason;
-	/* QP context id */
-	uint32_t	xid;
-	uint8_t	v;
+		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_L3_BAD_HDR_LEN	(UINT32_C(0x2) << 9)
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * Indicates that the physical packet is shorter than that
+	 * claimed by the PPPoE header length for a tunnel PPPoE
+	 * packet.
 	 */
-	#define CREQ_QP_ERROR_NOTIFICATION_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* QP error notification event. */
-	#define CREQ_QP_ERROR_NOTIFICATION_EVENT_QP_ERROR_NOTIFICATION UINT32_C(0xc0)
-	#define CREQ_QP_ERROR_NOTIFICATION_EVENT_LAST		CREQ_QP_ERROR_NOTIFICATION_EVENT_QP_ERROR_NOTIFICATION
-	/* responder slow path state */
-	uint8_t	res_slow_path_state;
-	uint8_t	res_err_state_reason;
+		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_T_PKT_ERROR_TUNNEL_TOTAL_ERROR	(UINT32_C(0x3) << 9)
 	/*
-	 * Final SQ Consumer Index value. Any additional SQ WQEs will
-	 * have to be completed by the user provider.
+	 * Indicates that physical packet is shorter than that claimed
+	 * by the tunnel l3 header length. Valid for IPv4, or IPv6
+	 * tunnel packet packets.
 	 */
-	uint16_t	sq_cons_idx;
+		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_IP_TOTAL_ERROR	(UINT32_C(0x4) << 9)
 	/*
-	 * Final RQ Consumer Index value. Any additional RQ WQEs will
-	 * have to be completed by the user provider.
+	 * Indicates that the physical packet is shorter than that
+	 * claimed by the tunnel UDP header length for a tunnel
+	 * UDP packet that is not fragmented.
 	 */
-	uint16_t	rq_cons_idx;
-} creq_qp_error_notification_t, *pcreq_qp_error_notification_t;
-
-/* CQ error notification event. */
-/* creq_cq_error_notification (size:128b/16B) */
-
-typedef struct creq_cq_error_notification {
-	uint8_t	type;
+		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_UDP_TOTAL_ERROR	(UINT32_C(0x5) << 9)
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units. Even values indicate 16B
-	 * records. Odd values indicate 32B
-	 * records.
+	 * indicates that the IPv4 TTL or IPv6 hop limit check
+	 * have failed (e.g. TTL = 0) in the tunnel header. Valid
+	 * for IPv4, and IPv6.
 	 */
-	#define CREQ_CQ_ERROR_NOTIFICATION_TYPE_MASK	UINT32_C(0x3f)
-	#define CREQ_CQ_ERROR_NOTIFICATION_TYPE_SFT	0
-	/* CQ Async Notification */
-		#define CREQ_CQ_ERROR_NOTIFICATION_TYPE_CQ_EVENT  UINT32_C(0x38)
-		#define CREQ_CQ_ERROR_NOTIFICATION_TYPE_LAST	CREQ_CQ_ERROR_NOTIFICATION_TYPE_CQ_EVENT
-	/* Status of the response. */
-	uint8_t	status;
-	/* CQ error reason code. */
-	uint8_t	cq_err_reason;
-	/* Requester completion error for invalid CQ state. */
-	#define CREQ_CQ_ERROR_NOTIFICATION_CQ_ERR_REASON_REQ_CQ_INVALID_ERROR  UINT32_C(0x1)
-	/* Requester completion error for CQ overflow. */
-	#define CREQ_CQ_ERROR_NOTIFICATION_CQ_ERR_REASON_REQ_CQ_OVERFLOW_ERROR UINT32_C(0x2)
-	/* Attempt to load CQ context resulted in error. */
-	#define CREQ_CQ_ERROR_NOTIFICATION_CQ_ERR_REASON_REQ_CQ_LOAD_ERROR	UINT32_C(0x3)
-	/* Responder completion error for invalid CQ state. */
-	#define CREQ_CQ_ERROR_NOTIFICATION_CQ_ERR_REASON_RES_CQ_INVALID_ERROR  UINT32_C(0x4)
-	/* Responder completion error for CQ overflow. */
-	#define CREQ_CQ_ERROR_NOTIFICATION_CQ_ERR_REASON_RES_CQ_OVERFLOW_ERROR UINT32_C(0x5)
-	/* Attempt to load CQ context resulted in error. */
-	#define CREQ_CQ_ERROR_NOTIFICATION_CQ_ERR_REASON_RES_CQ_LOAD_ERROR	UINT32_C(0x6)
-	#define CREQ_CQ_ERROR_NOTIFICATION_CQ_ERR_REASON_LAST		CREQ_CQ_ERROR_NOTIFICATION_CQ_ERR_REASON_RES_CQ_LOAD_ERROR
-	uint8_t	reserved8;
-	/* CQ context id */
-	uint32_t	xid;
-	uint8_t	v;
+		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_L3_BAD_TTL		(UINT32_C(0x6) << 9)
+		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_T_PKT_ERROR_LAST		CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_L3_BAD_TTL
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue. The even passes
-	 * will write 1. The odd passes will write 0.
+	 * This indicates that there was an error in the inner
+	 * portion of the packet when this
+	 * field is non-zero.
 	 */
-	#define CREQ_CQ_ERROR_NOTIFICATION_V	UINT32_C(0x1)
-	/* Event or command opcode. */
-	uint8_t	event;
-	/* CQ error notification event. */
-	#define CREQ_CQ_ERROR_NOTIFICATION_EVENT_CQ_ERROR_NOTIFICATION UINT32_C(0xc1)
-	#define CREQ_CQ_ERROR_NOTIFICATION_EVENT_LAST		CREQ_CQ_ERROR_NOTIFICATION_EVENT_CQ_ERROR_NOTIFICATION
-	uint8_t	reserved48[6];
-} creq_cq_error_notification_t, *pcreq_cq_error_notification_t;
-
-/* sq_base (size:64b/8B) */
-
-typedef struct sq_base {
-	/* This field defines the type of SQ WQE. */
-	uint8_t	wqe_type;
-	/* Send */
-	#define SQ_BASE_WQE_TYPE_SEND	UINT32_C(0x0)
+	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_PKT_ERROR_MASK			UINT32_C(0xf000)
+	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_PKT_ERROR_SFT			12
 	/*
-	 * Send with Immediate
-	 *
-	 * Allowed only on reliable connection (RC) and
-	 * unreliable datagram (UD) SQs.
+	 * No additional error occurred on the tunnel portion
+	 * of the packet of the packet does not have a tunnel.
+	 */
+		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_PKT_ERROR_NO_ERROR		(UINT32_C(0x0) << 12)
+	/*
+	 * Indicates that IP header version does not match
+	 * expectation from L2 Ethertype for IPv4 and IPv6 or that
+	 * option other than VFT was parsed on
+	 * FCoE packet.
+	 */
+		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_PKT_ERROR_L3_BAD_VERSION		(UINT32_C(0x1) << 12)
+	/*
+	 * indicates that header length is out of range. Valid for
+	 * IPv4 and RoCE
+	 */
+		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_PKT_ERROR_L3_BAD_HDR_LEN		(UINT32_C(0x2) << 12)
+	/*
+	 * indicates that the IPv4 TTL or IPv6 hop limit check
+	 * have failed (e.g. TTL = 0). Valid for IPv4, and IPv6
+	 */
+		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_PKT_ERROR_L3_BAD_TTL		(UINT32_C(0x3) << 12)
+	/*
+	 * Indicates that physical packet is shorter than that
+	 * claimed by the l3 header length. Valid for IPv4,
+	 * IPv6 packet or RoCE packets.
+	 */
+		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_PKT_ERROR_IP_TOTAL_ERROR		(UINT32_C(0x4) << 12)
+	/*
+	 * Indicates that the physical packet is shorter than that
+	 * claimed by the UDP header length for a UDP packet that is
+	 * not fragmented.
+	 */
+		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_PKT_ERROR_UDP_TOTAL_ERROR	(UINT32_C(0x5) << 12)
+	/*
+	 * Indicates that TCP header length > IP payload. Valid for
+	 * TCP packets only.
+	 */
+		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_PKT_ERROR_L4_BAD_HDR_LEN		(UINT32_C(0x6) << 12)
+	/* Indicates that TCP header length < 5. Valid for TCP. */
+		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_PKT_ERROR_L4_BAD_HDR_LEN_TOO_SMALL  (UINT32_C(0x7) << 12)
+	/*
+	 * Indicates that TCP option headers result in a TCP header
+	 * size that does not match data offset in TCP header. Valid
+	 * for TCP.
 	 */
-	#define SQ_BASE_WQE_TYPE_SEND_W_IMMEAD  UINT32_C(0x1)
+		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_PKT_ERROR_L4_BAD_OPT_LEN		(UINT32_C(0x8) << 12)
+		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_PKT_ERROR_LAST			CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_PKT_ERROR_L4_BAD_OPT_LEN
+	/* This is data from the CFA as indicated by the meta_format field. */
+	uint16_t	cfa_metadata0;
+	/* When meta_format=1, this value is the VLAN VID. */
+	#define CQ_RES_RAWETH_QP1_V2_CFA_METADATA0_VID_MASK UINT32_C(0xfff)
+	#define CQ_RES_RAWETH_QP1_V2_CFA_METADATA0_VID_SFT 0
+	/* When meta_format=1, this value is the VLAN DE. */
+	#define CQ_RES_RAWETH_QP1_V2_CFA_METADATA0_DE	UINT32_C(0x1000)
+	/* When meta_format=1, this value is the VLAN PRI. */
+	#define CQ_RES_RAWETH_QP1_V2_CFA_METADATA0_PRI_MASK UINT32_C(0xe000)
+	#define CQ_RES_RAWETH_QP1_V2_CFA_METADATA0_PRI_SFT 13
 	/*
-	 * Send with Invalidate.
-	 *
-	 * Allowed only on reliable connection (RC) SQs.
+	 * This is an application level ID used to identify the
+	 * QP and its SQ and RQ.
 	 */
-	#define SQ_BASE_WQE_TYPE_SEND_W_INVALID UINT32_C(0x2)
+	uint64_t	qp_handle;
+	uint32_t	raweth_qp1_flags2;
 	/*
-	 * RDMA Write.
-	 *
-	 * Allowed only on reliable connection (RC) SQs.
+	 * When this bit is '0', the cs_ok field has the following
+	 * definition:- ip_cs_ok[2:0] = The number of header groups with a
+	 * valid IP checksum in the delivered packet, counted from the
+	 * outer-most header group to the inner-most header group, stopping
+	 * at the first error. - l4_cs_ok[5:3] = The number of header groups
+	 * with a valid L4 checksum in the delivered packet, counted from
+	 * the outer-most header group to the inner-most header group,
+	 * stopping at the first error. When this bit is '1', the cs_ok
+	 * field has the following definition: - hdr_cnt[2:0] = The number of
+	 * header groups that were parsed by the chip and passed in the
+	 * delivered packet. - ip_cs_all_ok[3] =This bit will be '1' if all
+	 * the parsed header groups with an IP checksum are valid.
+	 * - l4_cs_all_ok[4] = This bit will be '1' if all the parsed header
+	 * groups with an L4 checksum are valid.
 	 */
-	#define SQ_BASE_WQE_TYPE_WRITE_WQE	UINT32_C(0x4)
+	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS2_CS_ALL_OK_MODE		UINT32_C(0x8)
+	/* This value indicates what format the metadata field is. */
+	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS2_META_FORMAT_MASK	UINT32_C(0xf0)
+	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS2_META_FORMAT_SFT		4
+	/* There is no metadata information. Values are zero. */
+		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS2_META_FORMAT_NONE		(UINT32_C(0x0) << 4)
 	/*
-	 * RDMA Write with Immediate.
-	 *
-	 * Allowed only on reliable connection (RC) SQs.
+	 * The {metadata1, metadata0} fields contain the vtag
+	 * information: - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0],
+	 * de, vid[11:0]} The metadata2 field contains the table scope
+	 * and action record pointer. - metadata2[25:0] contains the
+	 * action record pointer. - metadata2[31:26] contains the table
+	 * scope.
 	 */
-	#define SQ_BASE_WQE_TYPE_WRITE_W_IMMEAD UINT32_C(0x5)
+		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS2_META_FORMAT_ACT_REC_PTR	(UINT32_C(0x1) << 4)
 	/*
-	 * RDMA Read.
-	 *
-	 * Allowed only on reliable connection (RC) SQs.
+	 * The {metadata1, metadata0} fields contain the vtag
+	 * information:
+	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0], de, vid[11:0]}
+	 * The metadata2 field contains the Tunnel ID
+	 * value, justified to LSB. i
+	 * - VXLAN = VNI[23:0] -> VXLAN Network ID
+	 * - Geneve (NGE) = VNI[23:0] a-> Virtual Network Identifier
+	 * - NVGRE = TNI[23:0] -> Tenant Network ID
+	 * - GRE = KEY[31:0] -> key field with bit mask. zero if K=0
+	 * - IPv4 = 0 (not populated)
+	 * - IPv6 = Flow Label[19:0]
+	 * - PPPoE = sessionID[15:0]
+	 * - MPLs = Outer label[19:0]
+	 * - UPAR = Selected[31:0] with bit mask
 	 */
-	#define SQ_BASE_WQE_TYPE_READ_WQE	UINT32_C(0x6)
+		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS2_META_FORMAT_TUNNEL_ID	(UINT32_C(0x2) << 4)
 	/*
-	 * Atomic Compare/Swap.
-	 *
-	 * Allowed only on reliable connection (RC) SQs.
+	 * The {metadata1, metadata0} fields contain the vtag
+	 * information:
+	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0],de, vid[11:0]}
+	 * The metadata2 field contains the 32b metadata from the prepended
+	 * header (chdr_data).
 	 */
-	#define SQ_BASE_WQE_TYPE_ATOMIC_CS	UINT32_C(0x8)
+		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS2_META_FORMAT_CHDR_DATA	(UINT32_C(0x3) << 4)
 	/*
-	 * Atomic Fetch/Add.
-	 *
-	 * Allowed only on reliable connection (RC) SQs.
+	 * The {metadata1, metadata0} fields contain the vtag
+	 * information:
+	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0], de, vid[11:0]}
+	 * The metadata2 field contains the outer_l3_offset,
+	 * inner_l2_offset, inner_l3_offset, and inner_l4_size.
+	 * - metadata2[8:0] contains the outer_l3_offset.
+	 * - metadata2[17:9] contains the inner_l2_offset.
+	 * - metadata2[26:18] contains the inner_l3_offset.
+	 * - metadata2[31:27] contains the inner_l4_size.
 	 */
-	#define SQ_BASE_WQE_TYPE_ATOMIC_FA	UINT32_C(0xb)
+		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS2_META_FORMAT_HDR_OFFSET	(UINT32_C(0x4) << 4)
+		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS2_META_FORMAT_LAST		CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS2_META_FORMAT_HDR_OFFSET
 	/*
-	 * Local Invalidate.
-	 *
-	 * Allowed only on reliable connection (RC) SQs.
+	 * This field indicates the IP type for the inner-most IP header.
+	 * A value of '0' indicates IPv4. A value of '1' indicates IPv6.
+	 * This value is only valid if itype indicates a packet
+	 * with an IP header.
 	 */
-	#define SQ_BASE_WQE_TYPE_LOCAL_INVALID  UINT32_C(0xc)
+	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS2_IP_TYPE			UINT32_C(0x100)
 	/*
-	 * FR-PMR (Fast Register Physical Memory Region)
-	 *
-	 * Allowed only on reliable connection (RC) SQs.
+	 * This indicates that the complete 1's complement checksum was
+	 * calculated for the packet.
 	 */
-	#define SQ_BASE_WQE_TYPE_FR_PMR	UINT32_C(0xd)
+	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS2_COMPLETE_CHECKSUM_CALC	UINT32_C(0x200)
 	/*
-	 * Memory Bind
-	 *
-	 * Allowed only on reliable connection (RC) SQs.
+	 * This field indicates the status of IP and L4 CS calculations done
+	 * by the chip. The format of this field is indicated by the
+	 * cs_all_ok_mode bit.
 	 */
-	#define SQ_BASE_WQE_TYPE_BIND	UINT32_C(0xe)
+	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS2_CS_OK_MASK		UINT32_C(0xfc00)
+	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS2_CS_OK_SFT		10
 	/*
-	 * FR-PPMR (Fast Register Proxy Physical Memory Region)
-	 *
-	 * Allowed only on reliable connection (RC) SQs.
+	 * This value is the complete 1's complement checksum calculated from
+	 * the start of the outer L3 header to the end of the packet (not
+	 * including the ethernet crc). It is valid when the
+	 * 'complete_checksum_calc' flag is set.
 	 */
-	#define SQ_BASE_WQE_TYPE_FR_PPMR	UINT32_C(0xf)
-	#define SQ_BASE_WQE_TYPE_LAST	SQ_BASE_WQE_TYPE_FR_PPMR
-	uint8_t	unused_0[7];
-} sq_base_t, *psq_base_t;
-
-/* sq_sge (size:128b/16B) */
-
-typedef struct sq_sge {
+	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS2_COMPLETE_CHECKSUM_MASK	UINT32_C(0xffff0000)
+	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS2_COMPLETE_CHECKSUM_SFT	16
 	/*
-	 * The virtual address in local memory or a physical address
-	 * when l_key value is a reserved value of a physical address.
-	 * Driver configures this value in the chip and the chip compares
-	 * l_key in SGEs with that reserved value, if equal it access
-	 * the physical address specified. The chip however MUST verify
-	 * that the QP allows the use reserved key.
+	 * This is data from the CFA block as indicated by the meta_format
+	 * field.
+	 * - meta_format 0 - none - metadata2 = 0 - not valid/not stripped
+	 * - meta_format 1 - act_rec_ptr - metadata2 = {table_scope[5:0],
+	 *   act_rec_ptr[25:0]}
+	 * - meta_format 2 - tunnel_id - metadata2 = tunnel_id[31:0]
+	 * - meta_format 3 - chdr_data - metadata2 = updated_chdr_data[31:0]
+	 * - meta_format 4 - hdr_offsets - metadata2 = hdr_offsets[31:0]
+	 * When vee_cmpl_mode is set in VNIC context, this is the upper 32b
+	 * of the host address from the first BD used to place the packet.
 	 */
-	uint64_t	va_or_pa;
+	uint32_t	cfa_metadata2;
+	uint8_t	cqe_type_toggle;
 	/*
-	 * Local Key associated with this registered MR; The 24 msb of
-	 * the key used to index the MRW Table and the 8 lsb are compared
-	 * with the 8 bits key part stored in the MRWC. The PBL in the
-	 * MRW Context is used to translate the above VA to physical
-	 * address.
+	 * Indicate valid completion - written by the chip. Cumulus
+	 * toggle this bit each time it finished consuming all PBL
+	 * entries
 	 */
-	uint32_t	l_key;
+	#define CQ_RES_RAWETH_QP1_V2_TOGGLE		UINT32_C(0x1)
+	/* This field defines the type of CQE. */
+	#define CQ_RES_RAWETH_QP1_V2_CQE_TYPE_MASK	UINT32_C(0x1e)
+	#define CQ_RES_RAWETH_QP1_V2_CQE_TYPE_SFT	1
 	/*
-	 * Size of SGE in bytes; Based on page size of the system the
-	 * chip knows how many entries are in the PBL
+	 * Responder RawEth and QP1 Completion - This is used for RQ
+	 * completion for RawEth service and QP1 service QPs.
 	 */
-	uint32_t	size;
-} sq_sge_t, *psq_sge_t;
-
-/* sq_psn_search (size:64b/8B) */
-
-typedef struct sq_psn_search {
-	/* Start PSN. */
-	uint32_t	opcode_start_psn;
-	/* Start PSN. */
-	#define SQ_PSN_SEARCH_START_PSN_MASK UINT32_C(0xffffff)
-	#define SQ_PSN_SEARCH_START_PSN_SFT 0
-	/* The opcodes are software defined. */
-	#define SQ_PSN_SEARCH_OPCODE_MASK   UINT32_C(0xff000000)
-	#define SQ_PSN_SEARCH_OPCODE_SFT	24
-	uint32_t	flags_next_psn;
-	/* Next PSN. Equal to the start PSN of the next WQE. */
-	#define SQ_PSN_SEARCH_NEXT_PSN_MASK UINT32_C(0xffffff)
-	#define SQ_PSN_SEARCH_NEXT_PSN_SFT 0
-	/* Opcode specific flags. */
-	#define SQ_PSN_SEARCH_FLAGS_MASK   UINT32_C(0xff000000)
-	#define SQ_PSN_SEARCH_FLAGS_SFT	24
-} sq_psn_search_t, *psq_psn_search_t;
-
-/* This PSN table structure is used only on devices where variable size WQEs are supported. */
-/* sq_psn_search_ext (size:128b/16B) */
-
-typedef struct sq_psn_search_ext {
-	/* Start PSN. */
-	uint32_t	opcode_start_psn;
-	/* Start PSN. */
-	#define SQ_PSN_SEARCH_EXT_START_PSN_MASK UINT32_C(0xffffff)
-	#define SQ_PSN_SEARCH_EXT_START_PSN_SFT 0
-	/* The opcodes are software defined. */
-	#define SQ_PSN_SEARCH_EXT_OPCODE_MASK   UINT32_C(0xff000000)
-	#define SQ_PSN_SEARCH_EXT_OPCODE_SFT	24
-	uint32_t	flags_next_psn;
-	/* Next PSN. Equal to the start PSN of the next WQE. */
-	#define SQ_PSN_SEARCH_EXT_NEXT_PSN_MASK UINT32_C(0xffffff)
-	#define SQ_PSN_SEARCH_EXT_NEXT_PSN_SFT 0
-	/* Opcode specific flags. */
-	#define SQ_PSN_SEARCH_EXT_FLAGS_MASK   UINT32_C(0xff000000)
-	#define SQ_PSN_SEARCH_EXT_FLAGS_SFT	24
+		#define CQ_RES_RAWETH_QP1_V2_CQE_TYPE_RES_RAWETH_QP1  (UINT32_C(0x3) << 1)
+		#define CQ_RES_RAWETH_QP1_V2_CQE_TYPE_LAST	CQ_RES_RAWETH_QP1_V2_CQE_TYPE_RES_RAWETH_QP1
+	/* This field indicates the status for the CQE. */
+	uint8_t	status;
 	/*
-	 * This field is used only when variable sized WQEs are being used.
-	 * This indicates the starting slot index of the corresponding WQE.
+	 * This indicates that the completion is without error.
+	 * All fields are valid.
 	 */
-	uint16_t	start_slot_idx;
-	/* reserved16 is 16 b */
-	uint16_t	reserved16;
-	/* reserved32 is 32 b */
-	uint32_t	reserved32;
-} sq_psn_search_ext_t, *psq_psn_search_ext_t;
-
-/* Send SQ WQE */
-/* sq_send (size:1024b/128B) */
-
-typedef struct sq_send {
-	/* This field defines the type of SQ WQE. */
-	uint8_t	wqe_type;
-	/* Send */
-	#define SQ_SEND_WQE_TYPE_SEND	UINT32_C(0x0)
+	#define CQ_RES_RAWETH_QP1_V2_STATUS_OK			UINT32_C(0x0)
 	/*
-	 * Send with Immediate
+	 * This indicates that write access was not allowed for
+	 * at least one of the SGEs in the WQE.
 	 *
-	 * Allowed only on reliable connection (RC) and
-	 * unreliable datagram (UD) SQs.
+	 * This is a fatal error. Only the srq_or_rq_wr_id is field
+	 * is valid.
 	 */
-	#define SQ_SEND_WQE_TYPE_SEND_W_IMMEAD  UINT32_C(0x1)
+	#define CQ_RES_RAWETH_QP1_V2_STATUS_LOCAL_ACCESS_ERROR	UINT32_C(0x1)
 	/*
-	 * Send with Invalidate.
+	 * This indicates that the packet was too long for the WQE
+	 * provided on the RQ.
 	 *
-	 * Allowed only on reliable connection (RC) SQs.
+	 * This is not a fatal error. All the fields are valid.
 	 */
-	#define SQ_SEND_WQE_TYPE_SEND_W_INVALID UINT32_C(0x2)
-	#define SQ_SEND_WQE_TYPE_LAST	SQ_SEND_WQE_TYPE_SEND_W_INVALID
-	uint8_t	flags;
-	#define SQ_SEND_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_MASK		UINT32_C(0xff)
-	#define SQ_SEND_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_SFT			0
+	#define CQ_RES_RAWETH_QP1_V2_STATUS_HW_LOCAL_LENGTH_ERR	UINT32_C(0x2)
+	/* LOCAL_PROTECTION_ERR is 3 */
+	#define CQ_RES_RAWETH_QP1_V2_STATUS_LOCAL_PROTECTION_ERR	UINT32_C(0x3)
+	/* LOCAL_QP_OPERATION_ERR is 4 */
+	#define CQ_RES_RAWETH_QP1_V2_STATUS_LOCAL_QP_OPERATION_ERR   UINT32_C(0x4)
+	/* MEMORY_MGT_OPERATION_ERR is 5 */
+	#define CQ_RES_RAWETH_QP1_V2_STATUS_MEMORY_MGT_OPERATION_ERR UINT32_C(0x5)
+	/* WORK_REQUEST_FLUSHED_ERR is 7 */
+	#define CQ_RES_RAWETH_QP1_V2_STATUS_WORK_REQUEST_FLUSHED_ERR UINT32_C(0x7)
+	/* HW_FLUSH_ERR is 8 */
+	#define CQ_RES_RAWETH_QP1_V2_STATUS_HW_FLUSH_ERR		UINT32_C(0x8)
+	#define CQ_RES_RAWETH_QP1_V2_STATUS_LAST			CQ_RES_RAWETH_QP1_V2_STATUS_HW_FLUSH_ERR
+	uint16_t	flags;
 	/*
-	 * Set if completion signaling is requested. If this bit is
-	 * 0, and the SQ is configured to support Unsignaled completion
-	 * the controller should not generate a CQE unless there was
-	 * an error. This refers to the CQE on the sender side. (The se
-	 * flag refers to the receiver side).
+	 * This flag indicates that the completion is for a SRQ entry
+	 * rather than for an RQ entry.
 	 */
-	#define SQ_SEND_FLAGS_SIGNAL_COMP								UINT32_C(0x1)
+	#define CQ_RES_RAWETH_QP1_V2_FLAGS_SRQ	UINT32_C(0x1)
+	/* CQE relates to RQ WQE. */
+		#define CQ_RES_RAWETH_QP1_V2_FLAGS_SRQ_RQ	UINT32_C(0x0)
+	/* CQE relates to SRQ WQE. */
+		#define CQ_RES_RAWETH_QP1_V2_FLAGS_SRQ_SRQ   UINT32_C(0x1)
+		#define CQ_RES_RAWETH_QP1_V2_FLAGS_SRQ_LAST CQ_RES_RAWETH_QP1_V2_FLAGS_SRQ_SRQ
+	uint32_t	raweth_qp1_payload_offset_srq_or_rq_wr_id;
 	/*
-	 * Indication to complete all previous RDMA Read or Atomic WQEs
-	 * on the SQ before executing this WQE.
-	 *
-	 * This flag must be zero for a UD send.
+	 * Opaque value from RQ or SRQ WQE. Used by driver/lib to
+	 * reference the WQE in order to claim the received data
+	 * and reuse the WQE space
 	 */
-	#define SQ_SEND_FLAGS_RD_OR_ATOMIC_FENCE							UINT32_C(0x2)
+	#define CQ_RES_RAWETH_QP1_V2_SRQ_OR_RQ_WR_ID_MASK	UINT32_C(0xfffff)
+	#define CQ_RES_RAWETH_QP1_V2_SRQ_OR_RQ_WR_ID_SFT		0
+	#define CQ_RES_RAWETH_QP1_V2_CFA_METADATA1_MASK		UINT32_C(0xf00000)
+	#define CQ_RES_RAWETH_QP1_V2_CFA_METADATA1_SFT		20
+	/* When meta_format != 0, this value is the VLAN TPID_SEL. */
+	#define CQ_RES_RAWETH_QP1_V2_CFA_METADATA1_TPID_SEL_MASK	UINT32_C(0x700000)
+	#define CQ_RES_RAWETH_QP1_V2_CFA_METADATA1_TPID_SEL_SFT	20
+	/* 0x88a8 */
+		#define CQ_RES_RAWETH_QP1_V2_CFA_METADATA1_TPID_SEL_TPID88A8   (UINT32_C(0x0) << 20)
+	/* 0x8100 */
+		#define CQ_RES_RAWETH_QP1_V2_CFA_METADATA1_TPID_SEL_TPID8100   (UINT32_C(0x1) << 20)
+	/* 0x9100 */
+		#define CQ_RES_RAWETH_QP1_V2_CFA_METADATA1_TPID_SEL_TPID9100   (UINT32_C(0x2) << 20)
+	/* 0x9200 */
+		#define CQ_RES_RAWETH_QP1_V2_CFA_METADATA1_TPID_SEL_TPID9200   (UINT32_C(0x3) << 20)
+	/* 0x9300 */
+		#define CQ_RES_RAWETH_QP1_V2_CFA_METADATA1_TPID_SEL_TPID9300   (UINT32_C(0x4) << 20)
+	/* Value programmed in CFA VLANTPID register. */
+		#define CQ_RES_RAWETH_QP1_V2_CFA_METADATA1_TPID_SEL_TPIDCFG	(UINT32_C(0x5) << 20)
+		#define CQ_RES_RAWETH_QP1_V2_CFA_METADATA1_TPID_SEL_LAST	CQ_RES_RAWETH_QP1_V2_CFA_METADATA1_TPID_SEL_TPIDCFG
+	/* When meta_format != 0, this value is the VLAN valid. */
+	#define CQ_RES_RAWETH_QP1_V2_CFA_METADATA1_VALID		UINT32_C(0x800000)
 	/*
-	 * For local invalidate request. Indication to complete all
-	 * previous SQ's WQEs before executing this WQE.
+	 * This value indicates the offset in bytes from the beginning of
+	 * the packet where the inner payload starts. This value is valid
+	 * for TCP, UDP, FCoE, and RoCE packets.
 	 *
-	 * This flag must be zero for a UD send.
+	 * A value of zero indicates an offset of 256 bytes.
 	 */
-	#define SQ_SEND_FLAGS_UC_FENCE								UINT32_C(0x4)
+	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_PAYLOAD_OFFSET_MASK UINT32_C(0xff000000)
+	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_PAYLOAD_OFFSET_SFT  24
+} cq_res_raweth_qp1_v2_t, *pcq_res_raweth_qp1_v2_t;
+
+/*
+ * This is the terminal CQE structure. This CQE is generated to
+ * indicate that no further completions will be generated for this QP.
+ */
+/* cq_terminal (size:256b/32B) */
+
+typedef struct cq_terminal {
 	/*
-	 * Solicit event flag. Indication sent in BTH header to the
-	 * receiver to generate a Completion Event Notification, i.e.
-	 * CNQE. This bit should be set only in the last (or only) packet
-	 * of the message.
+	 * This is an application level ID used to identify the
+	 * QP and its SQ and RQ.
 	 */
-	#define SQ_SEND_FLAGS_SE									UINT32_C(0x8)
+	uint64_t	qp_handle;
 	/*
-	 * Indicate that inline data is posted to the SQ in the data
-	 * area of this WQE.
+	 * Final SQ Consumer Index value. Any additional SQ WQEs will
+	 * have to be completed by the user provider.
 	 */
-	#define SQ_SEND_FLAGS_INLINE								UINT32_C(0x10)
+	uint16_t	sq_cons_idx;
 	/*
-	 * If set to 1, then the timestamp from the WQE is used. If
-	 * cleared to 0, then TWE provides the timestamp.
+	 * Final RQ Consumer Index value. Any additional RQ WQEs will
+	 * have to be completed by the user provider.
 	 */
-	#define SQ_SEND_FLAGS_WQE_TS_EN								UINT32_C(0x20)
+	uint16_t	rq_cons_idx;
+	uint32_t	reserved32_1;
+	uint64_t	reserved64_3;
+	uint8_t	cqe_type_toggle;
 	/*
-	 * When set to '1', this operation will cause a trace capture in
-	 * each block it passes through.
+	 * Indicate valid completion - written by the chip. Cumulus
+	 * toggle this bit each time it finished consuming all PBL
+	 * entries
 	 */
-	#define SQ_SEND_FLAGS_DEBUG_TRACE								UINT32_C(0x40)
+	#define CQ_TERMINAL_TOGGLE	UINT32_C(0x1)
+	/* This field defines the type of CQE. */
+	#define CQ_TERMINAL_CQE_TYPE_MASK	UINT32_C(0x1e)
+	#define CQ_TERMINAL_CQE_TYPE_SFT	1
 	/*
-	 * The number of 16 bytes chunks of data including this first
-	 * word of the request that are a valid part of the request. The
-	 * valid 16 bytes units other than the WQE structure can be
-	 * SGEs (Scatter Gather Elements) OR inline data.
-	 *
-	 * While this field defines the valid WQE size.  The actual
-	 * total WQE size is always 128B.
+	 * Terminal completion - This is used to indicate that no
+	 * further completions will be made for this QP on this CQ.
 	 */
-	uint8_t	wqe_size;
-	uint8_t	reserved8_1;
+		#define CQ_TERMINAL_CQE_TYPE_TERMINAL  (UINT32_C(0xe) << 1)
+		#define CQ_TERMINAL_CQE_TYPE_LAST	CQ_TERMINAL_CQE_TYPE_TERMINAL
+	/* This field indicates the status for the CQE. */
+	uint8_t	status;
+	/* The operation completed successfully. */
+	#define CQ_TERMINAL_STATUS_OK UINT32_C(0x0)
+	#define CQ_TERMINAL_STATUS_LAST CQ_TERMINAL_STATUS_OK
+	uint16_t	reserved16;
+	uint32_t	reserved32_2;
+} cq_terminal_t, *pcq_terminal_t;
+
+/* Cutoff CQE */
+/* cq_cutoff (size:256b/32B) */
+
+typedef struct cq_cutoff {
+	uint64_t	reserved64_1;
+	uint64_t	reserved64_2;
+	uint64_t	reserved64_3;
+	uint8_t	cqe_type_toggle;
 	/*
-	 * Either invalidate key (R_Key of the remote host) that will
-	 * be send with IETH (Invalidate ETH) if wqe_type is of Send
-	 * with Invalidate, or immediate value that will be sent with
-	 * ImmDt header if wqe_type is Send with Immediate.
+	 * Indicate valid completion - written by the chip. The NIC
+	 * toggles this bit each time it finished consuming all PBL
+	 * entries
 	 */
-	uint32_t	inv_key_or_imm_data;
-	/* This field represents a 32-bit total data length, in bytes. */
-	uint32_t	length;
+	#define CQ_CUTOFF_TOGGLE		UINT32_C(0x1)
+	/* This field defines the type of CQE. */
+	#define CQ_CUTOFF_CQE_TYPE_MASK	UINT32_C(0x1e)
+	#define CQ_CUTOFF_CQE_TYPE_SFT	1
+	/* Cut off CQE; for CQ resize see CQ and SRQ Resize */
+		#define CQ_CUTOFF_CQE_TYPE_CUT_OFF	(UINT32_C(0xf) << 1)
+		#define CQ_CUTOFF_CQE_TYPE_LAST	CQ_CUTOFF_CQE_TYPE_CUT_OFF
 	/*
-	 * When in the SQ of a UD QP, indicates the q_key to be used in
-	 * the transmitted packet.  However, if the most significant bit
-	 * of this field is set, then the q_key will be taken from QP
-	 * context, rather than from this field.
+	 * This field carries the toggle value that must be used to
+	 * acknowledge this CQ resize operation. When this CQE is
+	 * processed, the driver should send a CQ_CUTOFF_ACK doorbell
+	 * to the chip to let the chip know that the resize operation
+	 * is complete.
 	 *
-	 * When in the SQ of a non-UD QP, this field is reserved and
-	 * should be filled with zeros.
-	 */
-	uint32_t	q_key;
+	 * This value is used by HW to detect old and
+	 * stale CQ_CUTOFF_ACK doorbells that are caused by having
+	 * a backup doorbell location or by PCI or other reordering
+	 * problems. Only doorbells with the latest value will be honored.
+	 * This field is needed only for devices that use the hardware
+	 * based doorbell drop recovery feature.
+	 */
+	#define CQ_CUTOFF_RESIZE_TOGGLE_MASK UINT32_C(0x60)
+	#define CQ_CUTOFF_RESIZE_TOGGLE_SFT 5
+	/* This field indicates the status for the CQE. */
+	uint8_t	status;
+	/* The operation completed successfully. */
+	#define CQ_CUTOFF_STATUS_OK UINT32_C(0x0)
+	#define CQ_CUTOFF_STATUS_LAST CQ_CUTOFF_STATUS_OK
+	uint16_t	reserved16;
+	uint32_t	reserved32;
+} cq_cutoff_t, *pcq_cutoff_t;
+
+/* No-Op CQE */
+/* cq_no_op (size:256b/32B) */
+
+typedef struct cq_no_op {
+	uint64_t	reserved64_1;
+	uint64_t	reserved64_2;
+	uint64_t	reserved64_3;
+	uint8_t	cqe_type_toggle;
 	/*
-	 * When in the SQ of a UD QP, indicates the destination QP to be
-	 * used in the transmitted packet.
-	 *
-	 * When in the SQ of a non-UD QP, this field is reserved and
-	 * should be filled with zeros.
+	 * Indicate valid completion - written by the chip. The NIC
+	 * toggles this bit each time it finished consuming all PBL
+	 * entries.
 	 */
-	uint32_t	dst_qp;
-	#define SQ_SEND_DST_QP_MASK UINT32_C(0xffffff)
-	#define SQ_SEND_DST_QP_SFT 0
-	uint32_t	avid;
+	#define CQ_NO_OP_TOGGLE	UINT32_C(0x1)
+	/* This field defines the type of CQE. */
+	#define CQ_NO_OP_CQE_TYPE_MASK UINT32_C(0x1e)
+	#define CQ_NO_OP_CQE_TYPE_SFT  1
 	/*
-	 * If the serv_type is 'UD', then this field supplies the AVID
-	 * (Address Vector ID).
+	 * NO-OP completion - This is used to indicate that no operation
+	 * completed.
 	 */
-	#define SQ_SEND_AVID_MASK UINT32_C(0xfffff)
-	#define SQ_SEND_AVID_SFT 0
+		#define CQ_NO_OP_CQE_TYPE_NO_OP  (UINT32_C(0xd) << 1)
+		#define CQ_NO_OP_CQE_TYPE_LAST  CQ_NO_OP_CQE_TYPE_NO_OP
+	/* This field indicates the status for the CQE. */
+	uint8_t	status;
+	/* The operation completed successfully. */
+	#define CQ_NO_OP_STATUS_OK UINT32_C(0x0)
+	#define CQ_NO_OP_STATUS_LAST CQ_NO_OP_STATUS_OK
+	uint16_t	reserved16;
 	uint32_t	reserved32;
-	uint32_t	timestamp;
+} cq_no_op_t, *pcq_no_op_t;
+
+/*
+ * This is the Requester CQE V3 structure. This is used to complete each
+ * signaled SQ WQE. The sq_cons_idx and opaque is used to indicate
+ * which WQE has been completed. When a WQE is completed, it indicates
+ * that all WQEs before it in the SQ are also completed without error.
+ * Space freed by completed WQEs can be used for new WQEs.
+ */
+/* cq_req_v3 (size:256b/32B) */
+
+typedef struct cq_req_v3 {
 	/*
-	 * This field specifies a 24-bit timestamp that can be passed
-	 * down the TX path and optionally logged in the TXP timestamp
-	 * histogram.
+	 * This is an application level ID used to identify the
+	 * QP and its SQ and RQ.
 	 */
-	#define SQ_SEND_TIMESTAMP_MASK UINT32_C(0xffffff)
-	#define SQ_SEND_TIMESTAMP_SFT 0
+	uint64_t	qp_handle;
 	/*
-	 * When inline=0, then this area is filled with from 1 to 6
-	 * SGEs based on the wqe_size field.
+	 * SQ Consumer Index - points to the entry just past the last WQE
+	 * that has been completed by the chip. Wraps around at QPC.sq_size
+	 * (i.e. the valid range of the SQ Consumer Index is 0 to
+	 * (QPC.sq_size - 1)). The sq_cons_idx is in 16B units (as is
+	 * QPC.sq_size).
 	 *
-	 * When inline=1, this area is filled with payload data for the
-	 * send based on the length_or_AVID field.  Bits [7:0] of word 0
-	 * hold the first byte to go out on the wire.
+	 * User can determine available space in the SQ by comparing
+	 * sq_cons_idx to a sq_prod_idx maintained by the user. When the two
+	 * values are equal, the SQ is empty. When
+	 * (sq_prod_idx+1)%QPC.sq_size==sq_cons_idx, the queue is full.
 	 */
-	uint32_t	data[24];
-} sq_send_t, *psq_send_t;
-
-/* Send SQ WQE header. */
-/* sq_send_hdr (size:256b/32B) */
-
-typedef struct sq_send_hdr {
-	/* This field defines the type of SQ WQE. */
-	uint8_t	wqe_type;
-	/* Send */
-	#define SQ_SEND_HDR_WQE_TYPE_SEND	UINT32_C(0x0)
+	uint16_t	sq_cons_idx;
+	uint16_t	reserved1;
+	uint32_t	reserved2;
+	uint64_t	reserved3;
+	uint8_t	cqe_type_toggle;
 	/*
-	 * Send with Immediate
-	 *
-	 * Allowed only on reliable connection (RC) and
-	 * unreliable datagram (UD) SQs.
+	 * Indicate valid completion - written by the chip. The NIC
+	 * toggles this bit each time it finished consuming all PBL
+	 * entries.
 	 */
-	#define SQ_SEND_HDR_WQE_TYPE_SEND_W_IMMEAD  UINT32_C(0x1)
+	#define CQ_REQ_V3_TOGGLE	UINT32_C(0x1)
+	/* This field defines the type of CQE. */
+	#define CQ_REQ_V3_CQE_TYPE_MASK  UINT32_C(0x1e)
+	#define CQ_REQ_V3_CQE_TYPE_SFT   1
 	/*
-	 * Send with Invalidate.
-	 *
-	 * Allowed only on reliable connection (RC) SQs.
+	 * Requester completion V3 - This is used for both RC and UD SQ
+	 * completions.
 	 */
-	#define SQ_SEND_HDR_WQE_TYPE_SEND_W_INVALID UINT32_C(0x2)
-	#define SQ_SEND_HDR_WQE_TYPE_LAST	SQ_SEND_HDR_WQE_TYPE_SEND_W_INVALID
-	uint8_t	flags;
-	#define SQ_SEND_HDR_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_MASK		UINT32_C(0xff)
-	#define SQ_SEND_HDR_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_SFT			0
+		#define CQ_REQ_V3_CQE_TYPE_REQ_V3  (UINT32_C(0x8) << 1)
+		#define CQ_REQ_V3_CQE_TYPE_LAST   CQ_REQ_V3_CQE_TYPE_REQ_V3
 	/*
-	 * Set if completion signaling is requested. If this bit is
-	 * 0, and the SQ is configured to support Unsignaled completion
-	 * the controller should not generate a CQE unless there was
-	 * an error. This refers to the CQE on the sender side. (The se
-	 * flag refers to the receiver side).
+	 * When this bit is '1', it indicates that the packet completed
+	 * was transmitted using the push accelerated data provided by
+	 * the driver. When this bit is '0', it indicates that the packet
+	 * had not push acceleration data written or was executed as a
+	 * normal packet even though push data was provided.
+	 *
+	 * Note: This field is intended to be used for driver-generated push
+	 * statistics. As such, It is not applicable for RC since not all
+	 * RC packets return a CQE.
 	 */
-	#define SQ_SEND_HDR_FLAGS_SIGNAL_COMP								UINT32_C(0x1)
+	#define CQ_REQ_V3_PUSH	UINT32_C(0x20)
+	/* This field indicates the status for the CQE. */
+	uint8_t	status;
+	/* The operation completed successfully. */
+	#define CQ_REQ_V3_STATUS_OK			UINT32_C(0x0)
 	/*
-	 * Indication to complete all previous RDMA Read or Atomic WQEs
-	 * on the SQ before executing this WQE.
+	 * An unexpected BTH opcode or a First/Middle packet that is not
+	 * the full MTU size was returned by the responder.
 	 *
-	 * This flag must be zero for a UD send.
+	 * This is a fatal error detected by the requester Rx.
 	 */
-	#define SQ_SEND_HDR_FLAGS_RD_OR_ATOMIC_FENCE							UINT32_C(0x2)
+	#define CQ_REQ_V3_STATUS_BAD_RESPONSE_ERR	UINT32_C(0x1)
 	/*
-	 * For local invalidate request. Indication to complete all
-	 * previous SQ's WQEs before executing this WQE.
+	 * Generated for a WQE posted to the local SQ when the sum of the
+	 * lengths of the SGEs in the WQE exceeds the maximum message
+	 * length of 2^31 bytes.
 	 *
-	 * This flag must be zero for a UD send.
+	 * Generated for a WQE posted to the local RQ/SRQ when the sum of
+	 * the lengths of the SGEs in the WQE is too small to receive the
+	 * (valid) incoming message or the length of the incoming message
+	 * is greater than the maximum message size supported.
+	 *
+	 * This is a fatal error detected by the requester Tx or responder
+	 * Rx. For responder CQEs, only the opaque field is valid.
 	 */
-	#define SQ_SEND_HDR_FLAGS_UC_FENCE								UINT32_C(0x4)
+	#define CQ_REQ_V3_STATUS_LOCAL_LENGTH_ERR	UINT32_C(0x2)
 	/*
-	 * Solicit event flag. Indication sent in BTH header to the
-	 * receiver to generate a Completion Event Notification, i.e.
-	 * CNQE. This bit should be set only in the last (or only) packet
-	 * of the message.
+	 * An internal QP consistency error was detected while processing
+	 * this Work Request. For requester, this could be an SQ WQE format
+	 * error or an operation specified in the WQE that is not supported
+	 * for the QP. For responder, this is an RQ/SRQ WQE format error.
+	 *
+	 * This is a fatal error detected by the requester Tx or responder
+	 * Rx. For responder CQEs, only the opaque field is valid.
 	 */
-	#define SQ_SEND_HDR_FLAGS_SE									UINT32_C(0x8)
+	#define CQ_REQ_V3_STATUS_LOCAL_QP_OPERATION_ERR	UINT32_C(0x4)
 	/*
-	 * Indicate that inline data is posted to the SQ in the data
-	 * area of this WQE.
+	 * An SGE in the locally posted WQE does not reference a Memory
+	 * Region that is valid for the requested operation. If this error
+	 * is generated for an SGE using the reserved l_key, this means
+	 * that the reserved l_key is not enabled.
+	 *
+	 * This is a fatal error detected by the requester Tx or responder
+	 * Rx. For responder CQEs, only the opaque field is valid.
 	 */
-	#define SQ_SEND_HDR_FLAGS_INLINE								UINT32_C(0x10)
+	#define CQ_REQ_V3_STATUS_LOCAL_PROTECTION_ERR	UINT32_C(0x5)
 	/*
-	 * If set to 1, then the timestamp from the WQE is used. If
-	 * cleared to 0, then TWE provides the timestamp.
+	 * The SSC detected an error on a local memory operation from the
+	 * SQ (fast-register, local invalidate, or bind).
+	 *
+	 * This is a fatal error detected by the requester Tx.
 	 */
-	#define SQ_SEND_HDR_FLAGS_WQE_TS_EN								UINT32_C(0x20)
+	#define CQ_REQ_V3_STATUS_MEMORY_MGT_OPERATION_ERR   UINT32_C(0x7)
 	/*
-	 * When set to '1', this operation will cause a trace capture in
-	 * each block it passes through.
+	 * An invalid message was received by the responder. This could be
+	 * an operation that is not supported by this QP, an IRRQ overflow
+	 * error, or the length in an RDMA operation is greater than the
+	 * maximum message size (2^31 bytes).
+	 *
+	 * This is a fatal error detected by the responder and communicated
+	 * back to the requester using a NAK-Invalid Request. For responder
+	 * CQEs, only the opaque field is valid.
 	 */
-	#define SQ_SEND_HDR_FLAGS_DEBUG_TRACE								UINT32_C(0x40)
+	#define CQ_REQ_V3_STATUS_REMOTE_INVALID_REQUEST_ERR UINT32_C(0x8)
 	/*
-	 * The number of 16 bytes chunks of data including this first
-	 * word of the request that are a valid part of the request. The
-	 * valid 16 bytes units other than the WQE structure can be
-	 * SGEs (Scatter Gather Elements) OR inline data.
+	 * A protection error occurred on a remote data buffer to be read
+	 * by an RDMA Read, written by an RDMA Write or accessed by an
+	 * atomic operation. This error is reported only on RDMA operations
+	 * or atomic operations.
 	 *
-	 * While this field defines the valid WQE size.  The actual
-	 * total WQE size is always 128B.
+	 * This is a fatal error detected by the responder and communicated
+	 * back to the requester using a NAK-Remote Access Violation.
 	 */
-	uint8_t	wqe_size;
-	uint8_t	reserved8_1;
+	#define CQ_REQ_V3_STATUS_REMOTE_ACCESS_ERR	UINT32_C(0x9)
 	/*
-	 * Either invalidate key (R_Key of the remote host) that will
-	 * be send with IETH (Invalidate ETH) if wqe_type is of Send
-	 * with Invalidate, or immediate value that will be sent with
-	 * ImmDt header if wqe_type is Send with Immediate.
+	 * The operation could not be completed successfully by the
+	 * responder. Possible causes include an RQ/SRQ WQE format error,
+	 * an SSC error when validating an SGE from an RQ/SRQ WQE, or the
+	 * message received was too long for the RQ/SRQ WQE.
+	 *
+	 * This is a fatal error detected by the responder and communicated
+	 * back to the requester using a NAK-Remote Operation Error.
 	 */
-	uint32_t	inv_key_or_imm_data;
-	/* This field represents a 32-bit total data length, in bytes. */
-	uint32_t	length;
+	#define CQ_REQ_V3_STATUS_REMOTE_OPERATION_ERR	UINT32_C(0xa)
 	/*
-	 * When in the SQ of a UD QP, indicates the q_key to be used in
-	 * the transmitted packet.  However, if the most significant bit
-	 * of this field is set, then the q_key will be taken from QP
-	 * context, rather than from this field.
+	 * The RNR NAK retry count was exceeded while trying to send this
+	 * message.
 	 *
-	 * When in the SQ of a non-UD QP, this field is reserved and
-	 * should be filled with zeros.
+	 * This is a fatal error detected by the requester.
 	 */
-	uint32_t	q_key;
+	#define CQ_REQ_V3_STATUS_RNR_NAK_RETRY_CNT_ERR	UINT32_C(0xb)
 	/*
-	 * When in the SQ of a UD QP, indicates the destination QP to be
-	 * used in the transmitted packet.
+	 * The local transport timeout retry counter was exceeded while
+	 * trying to send this message.
 	 *
-	 * When in the SQ of a non-UD QP, this field is reserved and
-	 * should be filled with zeros.
+	 * This is a fatal error detected by the requester.
 	 */
-	uint32_t	dst_qp;
-	#define SQ_SEND_HDR_DST_QP_MASK UINT32_C(0xffffff)
-	#define SQ_SEND_HDR_DST_QP_SFT 0
-	uint32_t	avid;
+	#define CQ_REQ_V3_STATUS_TRANSPORT_RETRY_CNT_ERR	UINT32_C(0xc)
 	/*
-	 * If the serv_type is 'UD', then this field supplies the AVID
-	 * (Address Vector ID).
+	 * A WQE was in process or outstanding when the QP transitioned
+	 * into the Error State.
 	 */
-	#define SQ_SEND_HDR_AVID_MASK UINT32_C(0xfffff)
-	#define SQ_SEND_HDR_AVID_SFT 0
-	uint32_t	reserved32;
-	uint32_t	timestamp;
+	#define CQ_REQ_V3_STATUS_WORK_REQUEST_FLUSHED_ERR   UINT32_C(0xd)
 	/*
-	 * This field specifies a 24-bit timestamp that can be passed
-	 * down the TX path and optionally logged in the TXP timestamp
-	 * histogram.
+	 * A WQE was posted to the SQ/RQ that caused it to overflow. For
+	 * requester CQEs, it was the SQ that overflowed. For responder
+	 * CQEs, it was the RQ that overflowed.
 	 */
-	#define SQ_SEND_HDR_TIMESTAMP_MASK UINT32_C(0xffffff)
-	#define SQ_SEND_HDR_TIMESTAMP_SFT 0
-} sq_send_hdr_t, *psq_send_hdr_t;
+	#define CQ_REQ_V3_STATUS_OVERFLOW_ERR		UINT32_C(0xf)
+	#define CQ_REQ_V3_STATUS_LAST			CQ_REQ_V3_STATUS_OVERFLOW_ERR
+	uint16_t	reserved4;
+	/* This value is from the WQE that is being completed. */
+	uint32_t	opaque;
+} cq_req_v3_t, *pcq_req_v3_t;
 
-/* Send Raw Ethernet and QP1 SQ WQE */
-/* sq_send_raweth_qp1 (size:1024b/128B) */
+/*
+ * This is the Responder RQ/SRQ CQE V3 structure for RC QPs. This is
+ * used to complete each RQ/SRQ WQE. When the WQE is completed, it
+ * indicates that there is room for one more WQE on the corresponding
+ * RQ/SRQ.
+ *
+ * User can determine available space in the RQ/SRQ by comparing
+ * a rq_cons_idx to a rq_prod_idx, both maintained by the user. The
+ * range for rq_prod/cons_idx is from 0 to QPC.rq_size-1. The
+ * rq_prod_idx value increments by one for each WQE that is added to
+ * the RQ/SRQ by the user. Value must be wrapped at rq_size. The
+ * rq_cons_idx value increments by one for each WQE that is completed
+ * from that particular RQ/SRQ. The qp_handle can be used by the user
+ * to determine what RQ/SRQ to increment. Value must also be wrapped at
+ * rq_size. When the two values are equal, the RQ/SRQ is empty. When
+ * (rq_prod_idx+1)%QPC.rq_size==rq_cons_idx, the queue is full.
+ */
+/* cq_res_rc_v3 (size:256b/32B) */
 
-typedef struct sq_send_raweth_qp1 {
-	/* This field defines the type of SQ WQE. */
-	uint8_t	wqe_type;
-	/* Send */
-	#define SQ_SEND_RAWETH_QP1_WQE_TYPE_SEND UINT32_C(0x0)
-	#define SQ_SEND_RAWETH_QP1_WQE_TYPE_LAST SQ_SEND_RAWETH_QP1_WQE_TYPE_SEND
-	uint8_t	flags;
-	#define SQ_SEND_RAWETH_QP1_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_MASK		UINT32_C(0xff)
-	#define SQ_SEND_RAWETH_QP1_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_SFT			0
+typedef struct cq_res_rc_v3 {
 	/*
-	 * Set if completion signaling is requested. If this bit is
-	 * 0, and the SQ is configured to support Unsignaled completion
-	 * the controller should not generate a CQE unless there was
-	 * an error. This refers to the CQE on the sender side. (The se
-	 * flag refers to the receiver side).
+	 * The length of the message's payload in bytes, stored in
+	 * the SGEs
 	 */
-	#define SQ_SEND_RAWETH_QP1_FLAGS_SIGNAL_COMP								UINT32_C(0x1)
-	/* This flag must be zero for a Raweth or QP1 send. */
-	#define SQ_SEND_RAWETH_QP1_FLAGS_RD_OR_ATOMIC_FENCE							UINT32_C(0x2)
-	/* This flag must be zero for a Raweth or QP1 send. */
-	#define SQ_SEND_RAWETH_QP1_FLAGS_UC_FENCE								UINT32_C(0x4)
-	/* This flag must be zero for a Raweth or QP1 send. */
-	#define SQ_SEND_RAWETH_QP1_FLAGS_SE									UINT32_C(0x8)
+	uint32_t	length;
 	/*
-	 * Indicate that inline data is posted to the SQ in the data
-	 * area of this WQE.
+	 * Immediate data in case the imm_flag set, R_Key to be
+	 * invalidated in case inv_flag is set.
 	 */
-	#define SQ_SEND_RAWETH_QP1_FLAGS_INLINE								UINT32_C(0x10)
+	uint32_t	imm_data_or_inv_r_key;
 	/*
-	 * If set to 1, then the timestamp from the WQE is used. If
-	 * cleared to 0, then TWE provides the timestamp.
+	 * This is an application level ID used to identify the
+	 * QP and its SQ and RQ.
 	 */
-	#define SQ_SEND_RAWETH_QP1_FLAGS_WQE_TS_EN								UINT32_C(0x20)
+	uint64_t	qp_handle;
 	/*
-	 * When set to '1', this operation will cause a trace capture in
-	 * each block it passes through.
+	 * Opaque value - valid when inv_flag is set. Used by driver
+	 * to reference the buffer used to store PBL when the MR was
+	 * fast registered. The driver can reclaim this buffer after
+	 * an MR was remotely invalidated. The controller take that
+	 * value from the MR referenced by R_Key
 	 */
-	#define SQ_SEND_RAWETH_QP1_FLAGS_DEBUG_TRACE								UINT32_C(0x40)
+	uint64_t	mr_handle;
+	uint8_t	cqe_type_toggle;
 	/*
-	 * The number of 16 bytes chunks of data including this first
-	 * word of the request that are a valid part of the request. The
-	 * valid 16 bytes units other than the WQE structure can be
-	 * SGEs (Scatter Gather Elements) OR inline data.
-	 *
-	 * While this field defines the valid WQE size.  The actual
-	 * total WQE size is always 128B.
+	 * Indicate valid completion - written by the chip. The NIC
+	 * toggles this bit each time it finished consuming all PBL
+	 * entries.
 	 */
-	uint8_t	wqe_size;
-	uint8_t	reserved8;
+	#define CQ_RES_RC_V3_TOGGLE		UINT32_C(0x1)
+	/* This field defines the type of CQE. */
+	#define CQ_RES_RC_V3_CQE_TYPE_MASK	UINT32_C(0x1e)
+	#define CQ_RES_RC_V3_CQE_TYPE_SFT	1
 	/*
-	 * All bits in this field must be valid on the first BD of a packet.
-	 * Their value on other BDs of the packet will be ignored.
+	 * Responder RC Completion - This is used for both RQ and SRQ
+	 * completions for RC service QPs.
 	 */
-	uint16_t	lflags;
+		#define CQ_RES_RC_V3_CQE_TYPE_RES_RC_V3  (UINT32_C(0x9) << 1)
+		#define CQ_RES_RC_V3_CQE_TYPE_LAST	CQ_RES_RC_V3_CQE_TYPE_RES_RC_V3
+	/* This field indicates the status for the CQE. */
+	uint8_t	status;
+	/* The operation completed successfully. */
+	#define CQ_RES_RC_V3_STATUS_OK			UINT32_C(0x0)
 	/*
-	 * If set to 1, the controller replaces the TCP/UPD checksum
-	 * fields of normal TCP/UPD checksum, or the inner TCP/UDP
-	 * checksum field of the encapsulated TCP/UDP packets with the
-	 * hardware calculated TCP/UDP checksum for the packet associated
-	 * with this descriptor.
+	 * Generated for a WQE posted to the local SQ when the sum of the
+	 * lengths of the SGEs in the WQE exceeds the maximum message
+	 * length of 2^31 bytes.
 	 *
-	 * This bit must be valid on the first BD of a packet.
-	 */
-	#define SQ_SEND_RAWETH_QP1_LFLAGS_TCP_UDP_CHKSUM	UINT32_C(0x1)
-	/*
-	 * If set to 1,  the controller replaces the IP checksum of the
-	 * normal packets, or the inner IP checksum of the encapsulated
-	 * packets with the hardware calculated IP checksum for the
-	 * packet associated with this descriptor.
+	 * Generated for a WQE posted to the local RQ/SRQ when the sum of
+	 * the lengths of the SGEs in the WQE is too small to receive the
+	 * (valid) incoming message or the length of the incoming message
+	 * is greater than the maximum message size supported.
 	 *
-	 * This bit must be valid on the first BD of a packet.
+	 * This is a fatal error detected by the requester Tx or responder
+	 * Rx. For responder CQEs, only the opaque field is valid.
 	 */
-	#define SQ_SEND_RAWETH_QP1_LFLAGS_IP_CHKSUM	UINT32_C(0x2)
+	#define CQ_RES_RC_V3_STATUS_LOCAL_LENGTH_ERR	UINT32_C(0x2)
 	/*
-	 * If set to 1, the controller will not append an Ethernet CRC
-	 * to the end of the frame.
-	 *
-	 * This bit must be valid on the first BD of a packet.
+	 * An internal QP consistency error was detected while processing
+	 * this Work Request. For requester, this could be an SQ WQE format
+	 * error or an operation specified in the WQE that is not supported
+	 * for the QP. For responder, this is an RQ/SRQ WQE format error.
 	 *
-	 * Packet must be 64B or longer when this flag is set.  It is not
-	 * usefull to use this bit with any form of TX offload such as
-	 * CSO or LSO.  The intent is that the packet from the host already
-	 * has a valid Ethernet CRC on the packet.
+	 * This is a fatal error detected by the requester Tx or responder
+	 * Rx. For responder CQEs, only the opaque field is valid.
 	 */
-	#define SQ_SEND_RAWETH_QP1_LFLAGS_NOCRC		UINT32_C(0x4)
+	#define CQ_RES_RC_V3_STATUS_LOCAL_QP_OPERATION_ERR	UINT32_C(0x4)
 	/*
-	 * If set to 1, the device will record the time at which the packet
-	 * was actually transmitted at the TX MAC.
+	 * An SGE in the locally posted WQE does not reference a Memory
+	 * Region that is valid for the requested operation. If this error
+	 * is generated for an SGE using the reserved l_key, this means
+	 * that the reserved l_key is not enabled.
 	 *
-	 * This bit must be valid on the first BD of a packet.
-	 */
-	#define SQ_SEND_RAWETH_QP1_LFLAGS_STAMP		UINT32_C(0x8)
-	/*
-	 * If set to 1, The controller replaces the tunnel IP checksum
-	 * field with hardware calculated IP checksum for the IP header
-	 * of the packet associated with this descriptor.  In case of
-	 * VXLAN, the controller also replaces the outer header UDP
-	 * checksum with hardware calculated UDP checksum for the packet
-	 * associated with this descriptor.
+	 * This is a fatal error detected by the requester Tx or responder
+	 * Rx. For responder CQEs, only the opaque field is valid.
 	 */
-	#define SQ_SEND_RAWETH_QP1_LFLAGS_T_IP_CHKSUM	UINT32_C(0x10)
+	#define CQ_RES_RC_V3_STATUS_LOCAL_PROTECTION_ERR	UINT32_C(0x5)
 	/*
-	 * If set to '1', then the RoCE ICRC will be appended to the
-	 * packet.  Packet must be a valid RoCE format packet.
+	 * A protection error occurred on a local data buffer during the
+	 * processing of a RDMA Write with Immediate Data operation sent
+	 * from the remote node.
+	 *
+	 * This is a fatal error detected by the responder Rx. Only the
+	 * opaque field in the CQE is valid.
 	 */
-	#define SQ_SEND_RAWETH_QP1_LFLAGS_ROCE_CRC	UINT32_C(0x100)
+	#define CQ_RES_RC_V3_STATUS_LOCAL_ACCESS_ERROR	UINT32_C(0x6)
 	/*
-	 * If set to '1', then the FCoE CRC will be appended to the
-	 * packet.  Packet must be a valid FCoE format packet.
+	 * An invalid message was received by the responder. This could be
+	 * an operation that is not supported by this QP, an IRRQ overflow
+	 * error, or the length in an RDMA operation is greater than the
+	 * maximum message size (2^31 bytes).
+	 *
+	 * This is a fatal error detected by the responder and communicated
+	 * back to the requester using a NAK-Invalid Request. For responder
+	 * CQEs, only the opaque field is valid.
 	 */
-	#define SQ_SEND_RAWETH_QP1_LFLAGS_FCOE_CRC	UINT32_C(0x200)
+	#define CQ_RES_RC_V3_STATUS_REMOTE_INVALID_REQUEST_ERR UINT32_C(0x8)
 	/*
-	 * This value selects a CFA action to perform on the packet.
-	 * Set this value to zero if no CFA action is desired.
-	 *
-	 * This value must be valid on the first BD of a packet.
+	 * A WQE was in process or outstanding when the QP transitioned
+	 * into the Error State.
 	 */
-	uint16_t	cfa_action;
+	#define CQ_RES_RC_V3_STATUS_WORK_REQUEST_FLUSHED_ERR   UINT32_C(0xd)
 	/*
-	 * This field represents a 32-bit total data length, in bytes.
-	 * Note, however, that the length cannot exceed the MTU.
+	 * A WQE had already been taken off the RQ/SRQ when a fatal error
+	 * was detected on responder Rx. Only the opaque field in the CQE
+	 * is valid.
 	 */
-	uint32_t	length;
-	uint32_t	reserved32_1;
+	#define CQ_RES_RC_V3_STATUS_HW_FLUSH_ERR		UINT32_C(0xe)
 	/*
-	 * This value is action meta-data that defines CFA edit operations
-	 * that are done in addition to any action editing.
+	 * A WQE was posted to the SQ/RQ that caused it to overflow. For
+	 * requester CQEs, it was the SQ that overflowed. For responder
+	 * CQEs, it was the RQ that overflowed.
 	 */
-	uint32_t	cfa_meta;
-	/* When key=1, This is the VLAN tag VID value. */
-	#define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_VID_MASK	UINT32_C(0xfff)
-	#define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_VID_SFT	0
-	/* When key=1, This is the VLAN tag DE value. */
-	#define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_DE	UINT32_C(0x1000)
-	/* When key=1, This is the VLAN tag PRI value. */
-	#define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_PRI_MASK	UINT32_C(0xe000)
-	#define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_PRI_SFT	13
-	/* When key=1, This is the VLAN tag TPID select value. */
-	#define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_TPID_MASK	UINT32_C(0x70000)
-	#define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_TPID_SFT	16
-	/* 0x88a8 */
-		#define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_TPID_TPID88A8  (UINT32_C(0x0) << 16)
-	/* 0x8100 */
-		#define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_TPID_TPID8100  (UINT32_C(0x1) << 16)
-	/* 0x9100 */
-		#define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_TPID_TPID9100  (UINT32_C(0x2) << 16)
-	/* 0x9200 */
-		#define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_TPID_TPID9200  (UINT32_C(0x3) << 16)
-	/* 0x9300 */
-		#define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_TPID_TPID9300  (UINT32_C(0x4) << 16)
-	/* Value programmed in CFA VLANTPID register. */
-		#define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_TPID_TPIDCFG   (UINT32_C(0x5) << 16)
-		#define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_TPID_LAST	SQ_SEND_RAWETH_QP1_CFA_META_VLAN_TPID_TPIDCFG
-	/* When key=1, This is the VLAN tag TPID select value. */
-	#define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_RESERVED_MASK UINT32_C(0xff80000)
-	#define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_RESERVED_SFT 19
+	#define CQ_RES_RC_V3_STATUS_OVERFLOW_ERR		UINT32_C(0xf)
+	#define CQ_RES_RC_V3_STATUS_LAST			CQ_RES_RC_V3_STATUS_OVERFLOW_ERR
+	uint16_t	flags;
 	/*
-	 * This field identifies the type of edit to be performed
-	 * on the packet.
-	 *
-	 * This value must be valid on the first BD of a packet.
+	 * This flag indicates that the completion is for a SRQ entry
+	 * rather than for an RQ entry.
 	 */
-	#define SQ_SEND_RAWETH_QP1_CFA_META_KEY_MASK	UINT32_C(0xf0000000)
-	#define SQ_SEND_RAWETH_QP1_CFA_META_KEY_SFT	28
-	/* No editing */
-		#define SQ_SEND_RAWETH_QP1_CFA_META_KEY_NONE		(UINT32_C(0x0) << 28)
+	#define CQ_RES_RC_V3_FLAGS_SRQ		UINT32_C(0x1)
+	/* CQE relates to RQ WQE. */
+		#define CQ_RES_RC_V3_FLAGS_SRQ_RQ	UINT32_C(0x0)
+	/* CQE relates to SRQ WQE. */
+		#define CQ_RES_RC_V3_FLAGS_SRQ_SRQ	UINT32_C(0x1)
+		#define CQ_RES_RC_V3_FLAGS_SRQ_LAST	CQ_RES_RC_V3_FLAGS_SRQ_SRQ
+	/* Immediate data indicator */
+	#define CQ_RES_RC_V3_FLAGS_IMM		UINT32_C(0x2)
+	/* R_Key invalidate indicator */
+	#define CQ_RES_RC_V3_FLAGS_INV		UINT32_C(0x4)
+	#define CQ_RES_RC_V3_FLAGS_RDMA	UINT32_C(0x8)
+	/* CQE relates to an incoming Send request */
+		#define CQ_RES_RC_V3_FLAGS_RDMA_SEND	(UINT32_C(0x0) << 3)
+	/* CQE relates to incoming RDMA Write request */
+		#define CQ_RES_RC_V3_FLAGS_RDMA_RDMA_WRITE  (UINT32_C(0x1) << 3)
+		#define CQ_RES_RC_V3_FLAGS_RDMA_LAST	CQ_RES_RC_V3_FLAGS_RDMA_RDMA_WRITE
+	/* This value is from the WQE that is being completed. */
+	uint32_t	opaque;
+} cq_res_rc_v3_t, *pcq_res_rc_v3_t;
+
+/*
+ * This is the Responder RQ/SRQ CQE V3 structure for UD QPs and QP1 QPs
+ * that are treated as UD. This is used to complete RQ/SRQ WQE's. When
+ * the WQE is completed, it indicates that there is room for one more
+ * WQE on the corresponding RQ/SRQ.
+ *
+ * User can determine available space in the RQ/SRQ by comparing
+ * a rq_cons_idx to a rq_prod_idx, both maintained by the user. The
+ * range for rq_prod/cons_idx is from 0 to QPC.rq_size-1. The
+ * rq_prod_idx value increments by one for each WQE that is added to
+ * the RQ/SRQ by the user. Value must be wrapped at rq_size. The
+ * rq_cons_idx value increments by one for each WQE that is completed
+ * from that particular RQ/SRQ. The qp_handle can be used by the user
+ * to determine what RQ/SRQ to increment. Value must also be wrapped at
+ * rq_size. When the two values are equal, the RQ/SRQ is empty. When
+ * (rq_prod_idx+1)%QPC.rq_size==rq_cons_idx, the queue is full.
+ */
+/* cq_res_ud_v3 (size:256b/32B) */
+
+typedef struct cq_res_ud_v3 {
+	uint16_t	length;
 	/*
-	 * - meta[17:16] - TPID select value (0 = 0x8100).
-	 * - meta[15:12] - PRI/DE value.
-	 * - meta[11:0] - VID value.
+	 * The length of the message's payload in bytes, stored in
+	 * the SGEs
 	 */
-		#define SQ_SEND_RAWETH_QP1_CFA_META_KEY_VLAN_TAG	(UINT32_C(0x1) << 28)
-		#define SQ_SEND_RAWETH_QP1_CFA_META_KEY_LAST	SQ_SEND_RAWETH_QP1_CFA_META_KEY_VLAN_TAG
-	uint32_t	reserved32_2;
-	uint32_t	reserved32_3;
-	uint32_t	timestamp;
+	#define CQ_RES_UD_V3_LENGTH_MASK UINT32_C(0x3fff)
+	#define CQ_RES_UD_V3_LENGTH_SFT 0
+	uint8_t	reserved1;
+	/* Upper 8b of the Source QP value from the DETH header. */
+	uint8_t	src_qp_high;
+	/* Immediate data in case the imm_flag set. */
+	uint32_t	imm_data;
 	/*
-	 * This field specifies a 24-bit timestamp that can be passed
-	 * down the TX path and optionally logged in the TXP timestamp
-	 * histogram.
+	 * This is an application level ID used to identify the
+	 * QP and its SQ and RQ.
 	 */
-	#define SQ_SEND_RAWETH_QP1_TIMESTAMP_MASK UINT32_C(0xffffff)
-	#define SQ_SEND_RAWETH_QP1_TIMESTAMP_SFT 0
+	uint64_t	qp_handle;
 	/*
-	 * When inline=0, then this area is filled with from 1 to 6
-	 * SGEs based on the wqe_size field.
-	 *
-	 * When inline=1, this area is filled with payload data for the
-	 * send based on the length_or_AVID field.  Bits [7:0] of word 0
-	 * hold the first byte to go out on the wire.
+	 * Source MAC address for the UD message placed in the WQE
+	 * that is completed by this CQE.
 	 */
-	uint32_t	data[24];
-} sq_send_raweth_qp1_t, *psq_send_raweth_qp1_t;
-
-/* Send Raw Ethernet and QP1 SQ WQE header. */
-/* sq_send_raweth_qp1_hdr (size:256b/32B) */
-
-typedef struct sq_send_raweth_qp1_hdr {
-	/* This field defines the type of SQ WQE. */
-	uint8_t	wqe_type;
-	/* Send */
-	#define SQ_SEND_RAWETH_QP1_HDR_WQE_TYPE_SEND UINT32_C(0x0)
-	#define SQ_SEND_RAWETH_QP1_HDR_WQE_TYPE_LAST SQ_SEND_RAWETH_QP1_HDR_WQE_TYPE_SEND
-	uint8_t	flags;
-	#define SQ_SEND_RAWETH_QP1_HDR_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_MASK		UINT32_C(0xff)
-	#define SQ_SEND_RAWETH_QP1_HDR_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_SFT			0
+	uint16_t	src_mac[3];
+	/* Lower 16b of the Source QP value from the DETH header. */
+	uint16_t	src_qp_low;
+	uint8_t	cqe_type_toggle;
 	/*
-	 * Set if completion signaling is requested. If this bit is
-	 * 0, and the SQ is configured to support Unsignaled completion
-	 * the controller should not generate a CQE unless there was
-	 * an error. This refers to the CQE on the sender side. (The se
-	 * flag refers to the receiver side).
+	 * Indicate valid completion - written by the chip. The NIC
+	 * toggles this bit each time it finished consuming all PBL
+	 * entries.
 	 */
-	#define SQ_SEND_RAWETH_QP1_HDR_FLAGS_SIGNAL_COMP								UINT32_C(0x1)
-	/* This flag must be zero for a Raweth or QP1 send. */
-	#define SQ_SEND_RAWETH_QP1_HDR_FLAGS_RD_OR_ATOMIC_FENCE							UINT32_C(0x2)
-	/* This flag must be zero for a Raweth or QP1 send. */
-	#define SQ_SEND_RAWETH_QP1_HDR_FLAGS_UC_FENCE								UINT32_C(0x4)
-	/* This flag must be zero for a Raweth or QP1 send. */
-	#define SQ_SEND_RAWETH_QP1_HDR_FLAGS_SE									UINT32_C(0x8)
+	#define CQ_RES_UD_V3_TOGGLE		UINT32_C(0x1)
+	/* This field defines the type of CQE. */
+	#define CQ_RES_UD_V3_CQE_TYPE_MASK	UINT32_C(0x1e)
+	#define CQ_RES_UD_V3_CQE_TYPE_SFT	1
 	/*
-	 * Indicate that inline data is posted to the SQ in the data
-	 * area of this WQE.
+	 * Responder UD Completion - This is used for both RQ and SRQ
+	 * completion for UD service QPs. It is also used for QP1 QPs
+	 * that are treated as UD.
 	 */
-	#define SQ_SEND_RAWETH_QP1_HDR_FLAGS_INLINE								UINT32_C(0x10)
+		#define CQ_RES_UD_V3_CQE_TYPE_RES_UD_V3  (UINT32_C(0xa) << 1)
+		#define CQ_RES_UD_V3_CQE_TYPE_LAST	CQ_RES_UD_V3_CQE_TYPE_RES_UD_V3
+	/* This field indicates the status for the CQE. */
+	uint8_t	status;
+	/* The operation completed successfully. */
+	#define CQ_RES_UD_V3_STATUS_OK			UINT32_C(0x0)
 	/*
-	 * If set to 1, then the timestamp from the WQE is used. If
-	 * cleared to 0, then TWE provides the timestamp.
+	 * This indicates that the packet was too long for the WQE provided
+	 * on the SRQ/RQ.
+	 *
+	 * This is not a fatal error. All the fields in the CQE are valid.
 	 */
-	#define SQ_SEND_RAWETH_QP1_HDR_FLAGS_WQE_TS_EN								UINT32_C(0x20)
+	#define CQ_RES_UD_V3_STATUS_HW_LOCAL_LENGTH_ERR	UINT32_C(0x3)
 	/*
-	 * When set to '1', this operation will cause a trace capture in
-	 * each block it passes through.
+	 * An internal QP consistency error was detected while processing
+	 * this Work Request. For requester, this could be an SQ WQE format
+	 * error or an operation specified in the WQE that is not supported
+	 * for the QP. For responder, this is an RQ/SRQ WQE format error.
+	 *
+	 * This is a fatal error detected by the requester Tx or responder
+	 * Rx. For responder CQEs, only the opaque field is valid.
 	 */
-	#define SQ_SEND_RAWETH_QP1_HDR_FLAGS_DEBUG_TRACE								UINT32_C(0x40)
+	#define CQ_RES_UD_V3_STATUS_LOCAL_QP_OPERATION_ERR   UINT32_C(0x4)
 	/*
-	 * The number of 16 bytes chunks of data including this first
-	 * word of the request that are a valid part of the request. The
-	 * valid 16 bytes units other than the WQE structure can be
-	 * SGEs (Scatter Gather Elements) OR inline data.
+	 * An SGE in the locally posted WQE does not reference a Memory
+	 * Region that is valid for the requested operation. If this error
+	 * is generated for an SGE using the reserved l_key, this means
+	 * that the reserved l_key is not enabled.
 	 *
-	 * While this field defines the valid WQE size.  The actual
-	 * total WQE size is always 128B.
+	 * This is a fatal error detected by the requester Tx or responder
+	 * Rx. For responder CQEs, only the opaque field is valid.
 	 */
-	uint8_t	wqe_size;
-	uint8_t	reserved8;
+	#define CQ_RES_UD_V3_STATUS_LOCAL_PROTECTION_ERR	UINT32_C(0x5)
 	/*
-	 * All bits in this field must be valid on the first BD of a packet.
-	 * Their value on other BDs of the packet will be ignored.
+	 * A WQE was in process or outstanding when the QP transitioned
+	 * into the Error State.
 	 */
-	uint16_t	lflags;
+	#define CQ_RES_UD_V3_STATUS_WORK_REQUEST_FLUSHED_ERR UINT32_C(0xd)
 	/*
-	 * If set to 1, the controller replaces the TCP/UPD checksum
-	 * fields of normal TCP/UPD checksum, or the inner TCP/UDP
-	 * checksum field of the encapsulated TCP/UDP packets with the
-	 * hardware calculated TCP/UDP checksum for the packet associated
-	 * with this descriptor.
-	 *
-	 * This bit must be valid on the first BD of a packet.
+	 * A WQE had already been taken off the RQ/SRQ when a fatal error
+	 * was detected on responder Rx. Only the opaque field in the CQE
+	 * is valid.
 	 */
-	#define SQ_SEND_RAWETH_QP1_HDR_LFLAGS_TCP_UDP_CHKSUM	UINT32_C(0x1)
+	#define CQ_RES_UD_V3_STATUS_HW_FLUSH_ERR		UINT32_C(0xe)
 	/*
-	 * If set to 1,  the controller replaces the IP checksum of the
-	 * normal packets, or the inner IP checksum of the encapsulated
-	 * packets with the hardware calculated IP checksum for the
-	 * packet associated with this descriptor.
-	 *
-	 * This bit must be valid on the first BD of a packet.
+	 * A WQE was posted to the SQ/RQ that caused it to overflow. For
+	 * requester CQEs, it was the SQ that overflowed. For responder
+	 * CQEs, it was the RQ that overflowed.
 	 */
-	#define SQ_SEND_RAWETH_QP1_HDR_LFLAGS_IP_CHKSUM	UINT32_C(0x2)
+	#define CQ_RES_UD_V3_STATUS_OVERFLOW_ERR		UINT32_C(0xf)
+	#define CQ_RES_UD_V3_STATUS_LAST			CQ_RES_UD_V3_STATUS_OVERFLOW_ERR
+	uint16_t	flags;
 	/*
-	 * If set to 1, the controller will not append an Ethernet CRC
-	 * to the end of the frame.
-	 *
-	 * This bit must be valid on the first BD of a packet.
-	 *
-	 * Packet must be 64B or longer when this flag is set.  It is not
-	 * usefull to use this bit with any form of TX offload such as
-	 * CSO or LSO.  The intent is that the packet from the host already
-	 * has a valid Ethernet CRC on the packet.
+	 * This flag indicates that the completion is for a SRQ entry
+	 * rather than for an RQ entry.
 	 */
-	#define SQ_SEND_RAWETH_QP1_HDR_LFLAGS_NOCRC		UINT32_C(0x4)
+	#define CQ_RES_UD_V3_FLAGS_SRQ		UINT32_C(0x1)
+	/* CQE relates to RQ WQE. */
+		#define CQ_RES_UD_V3_FLAGS_SRQ_RQ		UINT32_C(0x0)
+	/* CQE relates to SRQ WQE. */
+		#define CQ_RES_UD_V3_FLAGS_SRQ_SRQ		UINT32_C(0x1)
+		#define CQ_RES_UD_V3_FLAGS_SRQ_LAST	CQ_RES_UD_V3_FLAGS_SRQ_SRQ
+	/* Immediate data indicator */
+	#define CQ_RES_UD_V3_FLAGS_IMM		UINT32_C(0x2)
+	#define CQ_RES_UD_V3_FLAGS_UNUSED_MASK	UINT32_C(0xc)
+	#define CQ_RES_UD_V3_FLAGS_UNUSED_SFT	2
+	#define CQ_RES_UD_V3_FLAGS_ROCE_IP_VER_MASK  UINT32_C(0x30)
+	#define CQ_RES_UD_V3_FLAGS_ROCE_IP_VER_SFT   4
+	/* RoCEv1 Message */
+		#define CQ_RES_UD_V3_FLAGS_ROCE_IP_VER_V1	(UINT32_C(0x0) << 4)
+	/* RoCEv2 IPv4 Message */
+		#define CQ_RES_UD_V3_FLAGS_ROCE_IP_VER_V2IPV4  (UINT32_C(0x2) << 4)
+	/* RoCEv2 IPv6 Message */
+		#define CQ_RES_UD_V3_FLAGS_ROCE_IP_VER_V2IPV6  (UINT32_C(0x3) << 4)
+		#define CQ_RES_UD_V3_FLAGS_ROCE_IP_VER_LAST   CQ_RES_UD_V3_FLAGS_ROCE_IP_VER_V2IPV6
+	/* This value is from the WQE that is being completed. */
+	uint32_t	opaque;
+} cq_res_ud_v3_t, *pcq_res_ud_v3_t;
+
+/*
+ * This is the Responder RQ/SRQ CQE V3 structure for RawEth. This is
+ * used to complete RQ/SRQ WQE's. When the WQE is completed, it
+ * indicates that there is room for one more WQE on the corresponding
+ * RQ/SRQ.
+ *
+ * User can determine available space in the RQ/SRQ by comparing
+ * a rq_cons_idx to a rq_prod_idx, both maintained by the user. The
+ * range for rq_prod/cons_idx is from 0 to QPC.rq_size-1. The
+ * rq_prod_idx value increments by one for each WQE that is added to
+ * the RQ/SRQ by the user. Value must be wrapped at rq_size. The
+ * rq_cons_idx value increments by one for each WQE that is completed
+ * from that particular RQ/SRQ. The qp_handle can be used by the user
+ * to determine what RQ/SRQ to increment. Value must also be wrapped at
+ * rq_size. When the two values are equal, the RQ/SRQ is empty. When
+ * (rq_prod_idx+1)%QPC.rq_size==rq_cons_idx, the queue is full.
+ */
+/* cq_res_raweth_qp1_v3 (size:256b/32B) */
+
+typedef struct cq_res_raweth_qp1_v3 {
+	uint16_t	length;
 	/*
-	 * If set to 1, the device will record the time at which the packet
-	 * was actually transmitted at the TX MAC.
-	 *
-	 * This bit must be valid on the first BD of a packet.
+	 * The length of the message's payload in bytes, stored in
+	 * the SGEs
 	 */
-	#define SQ_SEND_RAWETH_QP1_HDR_LFLAGS_STAMP		UINT32_C(0x8)
+	#define CQ_RES_RAWETH_QP1_V3_LENGTH_MASK UINT32_C(0x3fff)
+	#define CQ_RES_RAWETH_QP1_V3_LENGTH_SFT 0
+	uint16_t	raweth_qp1_flags_cfa_metadata1;
 	/*
-	 * If set to 1, The controller replaces the tunnel IP checksum
-	 * field with hardware calculated IP checksum for the IP header
-	 * of the packet associated with this descriptor.  In case of
-	 * VXLAN, the controller also replaces the outer header UDP
-	 * checksum with hardware calculated UDP checksum for the packet
-	 * associated with this descriptor.
+	 * When this bit is '1', it indicates a packet that has an
+	 * error of some type. Type of error is indicated in
+	 * raweth_qp1_errors.
 	 */
-	#define SQ_SEND_RAWETH_QP1_HDR_LFLAGS_T_IP_CHKSUM	UINT32_C(0x10)
+	#define CQ_RES_RAWETH_QP1_V3_ERROR			UINT32_C(0x1)
 	/*
-	 * If set to '1', then the RoCE ICRC will be appended to the
-	 * packet.  Packet must be a valid RoCE format packet.
+	 * This value indicates what the inner packet determined for the
+	 * packet was.
 	 */
-	#define SQ_SEND_RAWETH_QP1_HDR_LFLAGS_ROCE_CRC	UINT32_C(0x100)
+	#define CQ_RES_RAWETH_QP1_V3_ITYPE_MASK		UINT32_C(0x3c0)
+	#define CQ_RES_RAWETH_QP1_V3_ITYPE_SFT		6
 	/*
-	 * If set to '1', then the FCoE CRC will be appended to the
-	 * packet.  Packet must be a valid FCoE format packet.
+	 * Not Known:
+	 * Indicates that the packet type was not known.
 	 */
-	#define SQ_SEND_RAWETH_QP1_HDR_LFLAGS_FCOE_CRC	UINT32_C(0x200)
+		#define CQ_RES_RAWETH_QP1_V3_ITYPE_NOT_KNOWN		(UINT32_C(0x0) << 6)
 	/*
-	 * This value selects a CFA action to perform on the packet.
-	 * Set this value to zero if no CFA action is desired.
-	 *
-	 * This value must be valid on the first BD of a packet.
+	 * IP Packet:
+	 * Indicates that the packet was an IP packet, but further
+	 * classification was not possible.
 	 */
-	uint16_t	cfa_action;
+		#define CQ_RES_RAWETH_QP1_V3_ITYPE_IP			(UINT32_C(0x1) << 6)
 	/*
-	 * This field represents a 32-bit total data length, in bytes.
-	 * Note, however, that the length cannot exceed the MTU.
+	 * TCP Packet:
+	 * Indicates that the packet was IP and TCP.
+	 * This indicates that the raweth_qp1_payload_offset field is
+	 * valid.
 	 */
-	uint32_t	length;
-	uint32_t	reserved32_1;
+		#define CQ_RES_RAWETH_QP1_V3_ITYPE_TCP			(UINT32_C(0x2) << 6)
 	/*
-	 * This value is action meta-data that defines CFA edit operations
-	 * that are done in addition to any action editing.
+	 * UDP Packet:
+	 * Indicates that the packet was IP and UDP.
+	 * This indicates that the raweth_qp1_payload_offset field is
+	 * valid.
 	 */
-	uint32_t	cfa_meta;
-	/* When key=1, This is the VLAN tag VID value. */
-	#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_VLAN_VID_MASK	UINT32_C(0xfff)
-	#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_VLAN_VID_SFT	0
-	/* When key=1, This is the VLAN tag DE value. */
-	#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_VLAN_DE	UINT32_C(0x1000)
-	/* When key=1, This is the VLAN tag PRI value. */
-	#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_VLAN_PRI_MASK	UINT32_C(0xe000)
-	#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_VLAN_PRI_SFT	13
-	/* When key=1, This is the VLAN tag TPID select value. */
-	#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_VLAN_TPID_MASK	UINT32_C(0x70000)
-	#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_VLAN_TPID_SFT	16
-	/* 0x88a8 */
-		#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_VLAN_TPID_TPID88A8  (UINT32_C(0x0) << 16)
-	/* 0x8100 */
-		#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_VLAN_TPID_TPID8100  (UINT32_C(0x1) << 16)
-	/* 0x9100 */
-		#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_VLAN_TPID_TPID9100  (UINT32_C(0x2) << 16)
-	/* 0x9200 */
-		#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_VLAN_TPID_TPID9200  (UINT32_C(0x3) << 16)
-	/* 0x9300 */
-		#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_VLAN_TPID_TPID9300  (UINT32_C(0x4) << 16)
-	/* Value programmed in CFA VLANTPID register. */
-		#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_VLAN_TPID_TPIDCFG   (UINT32_C(0x5) << 16)
-		#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_VLAN_TPID_LAST	SQ_SEND_RAWETH_QP1_HDR_CFA_META_VLAN_TPID_TPIDCFG
-	/* When key=1, This is the VLAN tag TPID select value. */
-	#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_VLAN_RESERVED_MASK UINT32_C(0xff80000)
-	#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_VLAN_RESERVED_SFT 19
+		#define CQ_RES_RAWETH_QP1_V3_ITYPE_UDP			(UINT32_C(0x3) << 6)
 	/*
-	 * This field identifies the type of edit to be performed
-	 * on the packet.
-	 *
-	 * This value must be valid on the first BD of a packet.
+	 * FCoE Packet:
+	 * Indicates that the packet was recognized as a FCoE.
+	 * This also indicates that the raweth_qp1_payload_offset field is
+	 * valid.
 	 */
-	#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_KEY_MASK	UINT32_C(0xf0000000)
-	#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_KEY_SFT	28
-	/* No editing */
-		#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_KEY_NONE		(UINT32_C(0x0) << 28)
+		#define CQ_RES_RAWETH_QP1_V3_ITYPE_FCOE		(UINT32_C(0x4) << 6)
 	/*
-	 * - meta[17:16] - TPID select value (0 = 0x8100).
-	 * - meta[15:12] - PRI/DE value.
-	 * - meta[11:0] - VID value.
+	 * RoCE Packet:
+	 * Indicates that the packet was recognized as a RoCE.
+	 * This also indicates that the raweth_qp1_payload_offset field is
+	 * valid.
 	 */
-		#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_KEY_VLAN_TAG	(UINT32_C(0x1) << 28)
-		#define SQ_SEND_RAWETH_QP1_HDR_CFA_META_KEY_LAST	SQ_SEND_RAWETH_QP1_HDR_CFA_META_KEY_VLAN_TAG
-	uint32_t	reserved32_2;
-	uint32_t	reserved32_3;
-	uint32_t	timestamp;
+		#define CQ_RES_RAWETH_QP1_V3_ITYPE_ROCE		(UINT32_C(0x5) << 6)
 	/*
-	 * This field specifies a 24-bit timestamp that can be passed
-	 * down the TX path and optionally logged in the TXP timestamp
-	 * histogram.
+	 * ICMP Packet:
+	 * Indicates that the packet was recognized as ICMP.
+	 * This indicates that the raweth_qp1_payload_offset field is
+	 * valid.
 	 */
-	#define SQ_SEND_RAWETH_QP1_HDR_TIMESTAMP_MASK UINT32_C(0xffffff)
-	#define SQ_SEND_RAWETH_QP1_HDR_TIMESTAMP_SFT 0
-} sq_send_raweth_qp1_hdr_t, *psq_send_raweth_qp1_hdr_t;
-
-/* RDMA SQ WQE */
-/* sq_rdma (size:1024b/128B) */
-
-typedef struct sq_rdma {
-	/* This field defines the type of SQ WQE. */
-	uint8_t	wqe_type;
+		#define CQ_RES_RAWETH_QP1_V3_ITYPE_ICMP		(UINT32_C(0x7) << 6)
 	/*
-	 * RDMA Write.
-	 *
-	 * Allowed only on reliable connection (RC) SQs.
+	 * PtP packet wo/timestamp:
+	 * Indicates that the packet was recognized as a PtP
+	 * packet.
 	 */
-	#define SQ_RDMA_WQE_TYPE_WRITE_WQE	UINT32_C(0x4)
+		#define CQ_RES_RAWETH_QP1_V3_ITYPE_PTP_WO_TIMESTAMP	(UINT32_C(0x8) << 6)
 	/*
-	 * RDMA Write with Immediate.
-	 *
-	 * Allowed only on reliable connection (RC) SQs.
+	 * PtP packet w/timestamp:
+	 * Indicates that the packet was recognized as a PtP
+	 * packet and that a timestamp was taken for the packet.
 	 */
-	#define SQ_RDMA_WQE_TYPE_WRITE_W_IMMEAD UINT32_C(0x5)
+		#define CQ_RES_RAWETH_QP1_V3_ITYPE_PTP_W_TIMESTAMP	(UINT32_C(0x9) << 6)
+		#define CQ_RES_RAWETH_QP1_V3_ITYPE_LAST		CQ_RES_RAWETH_QP1_V3_ITYPE_PTP_W_TIMESTAMP
+	#define CQ_RES_RAWETH_QP1_V3_CFA_METADATA1_MASK	UINT32_C(0xf000)
+	#define CQ_RES_RAWETH_QP1_V3_CFA_METADATA1_SFT	12
+	/* When meta_format != 0, this value is the VLAN TPID_SEL. */
+	#define CQ_RES_RAWETH_QP1_V3_CFA_METADATA1_TPID_SEL_MASK UINT32_C(0x7000)
+	#define CQ_RES_RAWETH_QP1_V3_CFA_METADATA1_TPID_SEL_SFT  12
+	/* When meta_format != 0, this value is the VLAN valid. */
+	#define CQ_RES_RAWETH_QP1_V3_CFA_METADATA1_VALID	UINT32_C(0x8000)
+	uint16_t	raweth_qp1_errors;
 	/*
-	 * RDMA Read.
-	 *
-	 * Allowed only on reliable connection (RC) SQs.
+	 * This indicates that there was an error in the IP header
+	 * checksum.
 	 */
-	#define SQ_RDMA_WQE_TYPE_READ_WQE	UINT32_C(0x6)
-	#define SQ_RDMA_WQE_TYPE_LAST	SQ_RDMA_WQE_TYPE_READ_WQE
-	uint8_t	flags;
-	#define SQ_RDMA_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_MASK		UINT32_C(0xff)
-	#define SQ_RDMA_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_SFT			0
+	#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_ERRORS_IP_CS_ERROR			UINT32_C(0x10)
 	/*
-	 * Set if completion signaling is requested. If this bit is
-	 * 0, and the SQ is configured to support Unsignaled
-	 * completion the controller should not generate a CQE
-	 * unless there was an error. This refers to CQE on the
-	 * sender side (se_flag refers to the receiver side)
+	 * This indicates that there was an error in the TCP, UDP
+	 * or ICMP checksum.
 	 */
-	#define SQ_RDMA_FLAGS_SIGNAL_COMP								UINT32_C(0x1)
+	#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_ERRORS_L4_CS_ERROR			UINT32_C(0x20)
 	/*
-	 * Indication to complete all previous RDMA Read or Atomic
-	 * WQEs on the SQ before executing this WQE
+	 * This indicates that there was an error in the tunnel
+	 * IP header checksum.
 	 */
-	#define SQ_RDMA_FLAGS_RD_OR_ATOMIC_FENCE							UINT32_C(0x2)
+	#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_ERRORS_T_IP_CS_ERROR			UINT32_C(0x40)
 	/*
-	 * Unconditional fence. Indication to complete all previous
-	 * SQ's WQEs before executing this WQE.
+	 * This indicates that there was an error in the tunnel
+	 * UDP checksum.
 	 */
-	#define SQ_RDMA_FLAGS_UC_FENCE								UINT32_C(0x4)
+	#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_ERRORS_T_L4_CS_ERROR			UINT32_C(0x80)
 	/*
-	 * Solicit event. Indication sent in BTH header to the
-	 * receiver to generate a Completion Event Notification,
-	 * i.e. CNQE. This bit should be set only in the last (or
-	 * only) packet of the message.
+	 * This indicates that there was a CRC error on either an FCoE
+	 * or RoCE packet. The itype indicates the packet type.
 	 */
-	#define SQ_RDMA_FLAGS_SE									UINT32_C(0x8)
+	#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_ERRORS_CRC_ERROR			UINT32_C(0x100)
 	/*
-	 * Indicate that inline data is posted to the SQ following
-	 * this WQE.  This bit may be 1 only for write operations.
+	 * This indicates that there was an error in the tunnel
+	 * portion of the packet when this
+	 * field is non-zero.
 	 */
-	#define SQ_RDMA_FLAGS_INLINE								UINT32_C(0x10)
+	#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_ERRORS_T_PKT_ERROR_MASK		UINT32_C(0xe00)
+	#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_ERRORS_T_PKT_ERROR_SFT		9
 	/*
-	 * If set to 1, then the timestamp from the WQE is used. If
-	 * cleared to 0, then TWE provides the timestamp.
+	 * No additional error occurred on the tunnel portion
+	 * of the packet of the packet does not have a tunnel.
 	 */
-	#define SQ_RDMA_FLAGS_WQE_TS_EN								UINT32_C(0x20)
+		#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_ERRORS_T_PKT_ERROR_NO_ERROR		(UINT32_C(0x0) << 9)
 	/*
-	 * When set to '1', this operation will cause a trace capture in
-	 * each block it passes through.
+	 * Indicates that IP header version does not match
+	 * expectation from L2 Ethertype for IPv4 and IPv6
+	 * in the tunnel header.
 	 */
-	#define SQ_RDMA_FLAGS_DEBUG_TRACE								UINT32_C(0x40)
+		#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_L3_BAD_VERSION	(UINT32_C(0x1) << 9)
 	/*
-	 * The number of 16 bytes chunks of data including this first
-	 * wqe of the request that are a valid part of the request. The
-	 * valid 16 bytes units other than the WQE structure can be
-	 * SGEs (Scatter Gather Elements) OR inline data.
-	 *
-	 * While this field defines the valid WQE size.  The actual
-	 * total WQE size is always 128B.
+	 * Indicates that header length is out of range in the
+	 * tunnel header. Valid for
+	 * IPv4.
 	 */
-	uint8_t	wqe_size;
-	uint8_t	reserved8;
+		#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_L3_BAD_HDR_LEN	(UINT32_C(0x2) << 9)
 	/*
-	 * Immediate data - valid for RDMA Write with immediate and
-	 * causes the controller to add immDt header with this value
+	 * Indicates that physical packet is shorter than that claimed
+	 * by the tunnel l3 header length. Valid for IPv4, or IPv6
+	 * tunnel packet packets.
 	 */
-	uint32_t	imm_data;
-	/* Total data length in bytes */
-	uint32_t	length;
-	uint32_t	reserved32_1;
-	/* Remote VA sent to the destination QP */
-	uint64_t	remote_va;
+		#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_IP_TOTAL_ERROR	(UINT32_C(0x3) << 9)
 	/*
-	 * R_Key provided by remote node when the connection was
-	 * established and placed in the RETH header. It identify the
-	 * MRW on the remote host
+	 * Indicates that the physical packet is shorter than that
+	 * claimed by the tunnel UDP header length for a tunnel
+	 * UDP packet that is not fragmented.
 	 */
-	uint32_t	remote_key;
-	uint32_t	timestamp;
+		#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_UDP_TOTAL_ERROR	(UINT32_C(0x4) << 9)
 	/*
-	 * This field specifies a 24-bit timestamp that can be passed
-	 * down the TX path and optionally logged in the TXP timestamp
-	 * histogram.
+	 * indicates that the IPv4 TTL or IPv6 hop limit check
+	 * have failed (e.g. TTL = 0) in the tunnel header. Valid
+	 * for IPv4, and IPv6.
 	 */
-	#define SQ_RDMA_TIMESTAMP_MASK UINT32_C(0xffffff)
-	#define SQ_RDMA_TIMESTAMP_SFT 0
+		#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_L3_BAD_TTL		(UINT32_C(0x5) << 9)
 	/*
-	 * When inline=0, then this area is filled with from 1 to 6
-	 * SGEs based on the wqe_size field.
-	 *
-	 * When inline=1, this area is filled with payload data for the
-	 * write based on the length field.  Bits [7:0] of word 0
-	 * hold the first byte to go out on the wire.
+	 * Indicates that the physical packet is shorter than that
+	 * claimed by the tunnel header length. Valid for GTPv1-U
+	 * packets.
 	 */
-	uint32_t	data[24];
-} sq_rdma_t, *psq_rdma_t;
-
-/* RDMA SQ WQE header. */
-/* sq_rdma_hdr (size:256b/32B) */
-
-typedef struct sq_rdma_hdr {
-	/* This field defines the type of SQ WQE. */
-	uint8_t	wqe_type;
+		#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_TOTAL_ERROR	(UINT32_C(0x6) << 9)
+		#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_ERRORS_T_PKT_ERROR_LAST		CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_TOTAL_ERROR
 	/*
-	 * RDMA Write.
-	 *
-	 * Allowed only on reliable connection (RC) SQs.
+	 * This indicates that there was an error in the inner
+	 * portion of the packet when this
+	 * field is non-zero.
 	 */
-	#define SQ_RDMA_HDR_WQE_TYPE_WRITE_WQE	UINT32_C(0x4)
+	#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_ERRORS_PKT_ERROR_MASK			UINT32_C(0xf000)
+	#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_ERRORS_PKT_ERROR_SFT			12
 	/*
-	 * RDMA Write with Immediate.
-	 *
-	 * Allowed only on reliable connection (RC) SQs.
+	 * No additional error occurred on the tunnel portion
+	 * of the packet of the packet does not have a tunnel.
 	 */
-	#define SQ_RDMA_HDR_WQE_TYPE_WRITE_W_IMMEAD UINT32_C(0x5)
+		#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_ERRORS_PKT_ERROR_NO_ERROR		(UINT32_C(0x0) << 12)
 	/*
-	 * RDMA Read.
-	 *
-	 * Allowed only on reliable connection (RC) SQs.
+	 * Indicates that IP header version does not match
+	 * expectation from L2 Ethertype for IPv4 and IPv6 or that
+	 * option other than VFT was parsed on
+	 * FCoE packet.
 	 */
-	#define SQ_RDMA_HDR_WQE_TYPE_READ_WQE	UINT32_C(0x6)
-	#define SQ_RDMA_HDR_WQE_TYPE_LAST	SQ_RDMA_HDR_WQE_TYPE_READ_WQE
-	uint8_t	flags;
-	#define SQ_RDMA_HDR_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_MASK		UINT32_C(0xff)
-	#define SQ_RDMA_HDR_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_SFT			0
+		#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_ERRORS_PKT_ERROR_L3_BAD_VERSION		(UINT32_C(0x1) << 12)
 	/*
-	 * Set if completion signaling is requested. If this bit is
-	 * 0, and the SQ is configured to support Unsignaled
-	 * completion the controller should not generate a CQE
-	 * unless there was an error. This refers to CQE on the
-	 * sender side (se_flag refers to the receiver side)
+	 * indicates that header length is out of range. Valid for
+	 * IPv4 and RoCE
 	 */
-	#define SQ_RDMA_HDR_FLAGS_SIGNAL_COMP								UINT32_C(0x1)
+		#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_ERRORS_PKT_ERROR_L3_BAD_HDR_LEN		(UINT32_C(0x2) << 12)
 	/*
-	 * Indication to complete all previous RDMA Read or Atomic
-	 * WQEs on the SQ before executing this WQE
+	 * indicates that the IPv4 TTL or IPv6 hop limit check
+	 * have failed (e.g. TTL = 0). Valid for IPv4, and IPv6
 	 */
-	#define SQ_RDMA_HDR_FLAGS_RD_OR_ATOMIC_FENCE							UINT32_C(0x2)
+		#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_ERRORS_PKT_ERROR_L3_BAD_TTL		(UINT32_C(0x3) << 12)
 	/*
-	 * Unconditional fence. Indication to complete all previous
-	 * SQ's WQEs before executing this WQE.
+	 * Indicates that physical packet is shorter than that
+	 * claimed by the l3 header length. Valid for IPv4,
+	 * IPv6 packet or RoCE packets.
 	 */
-	#define SQ_RDMA_HDR_FLAGS_UC_FENCE								UINT32_C(0x4)
+		#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_ERRORS_PKT_ERROR_IP_TOTAL_ERROR		(UINT32_C(0x4) << 12)
 	/*
-	 * Solicit event. Indication sent in BTH header to the
-	 * receiver to generate a Completion Event Notification,
-	 * i.e. CNQE. This bit should be set only in the last (or
-	 * only) packet of the message.
+	 * Indicates that the physical packet is shorter than that
+	 * claimed by the UDP header length for a UDP packet that is
+	 * not fragmented.
 	 */
-	#define SQ_RDMA_HDR_FLAGS_SE									UINT32_C(0x8)
+		#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_ERRORS_PKT_ERROR_UDP_TOTAL_ERROR	(UINT32_C(0x5) << 12)
 	/*
-	 * Indicate that inline data is posted to the SQ following
-	 * this WQE.  This bit may be 1 only for write operations.
+	 * Indicates that TCP header length > IP payload. Valid for
+	 * TCP packets only.
 	 */
-	#define SQ_RDMA_HDR_FLAGS_INLINE								UINT32_C(0x10)
+		#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_ERRORS_PKT_ERROR_L4_BAD_HDR_LEN		(UINT32_C(0x6) << 12)
+	/* Indicates that TCP header length < 5. Valid for TCP. */
+		#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_ERRORS_PKT_ERROR_L4_BAD_HDR_LEN_TOO_SMALL  (UINT32_C(0x7) << 12)
 	/*
-	 * If set to 1, then the timestamp from the WQE is used. If
-	 * cleared to 0, then TWE provides the timestamp.
+	 * Indicates that TCP option headers result in a TCP header
+	 * size that does not match data offset in TCP header. Valid
+	 * for TCP.
 	 */
-	#define SQ_RDMA_HDR_FLAGS_WQE_TS_EN								UINT32_C(0x20)
+		#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_ERRORS_PKT_ERROR_L4_BAD_OPT_LEN		(UINT32_C(0x8) << 12)
+		#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_ERRORS_PKT_ERROR_LAST			CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_ERRORS_PKT_ERROR_L4_BAD_OPT_LEN
+	/* This is data from the CFA as indicated by the meta_format field. */
+	uint16_t	cfa_metadata0;
+	/* When meta_format=1, this value is the VLAN VID. */
+	#define CQ_RES_RAWETH_QP1_V3_CFA_METADATA0_VID_MASK UINT32_C(0xfff)
+	#define CQ_RES_RAWETH_QP1_V3_CFA_METADATA0_VID_SFT 0
+	/* When meta_format=1, this value is the VLAN DE. */
+	#define CQ_RES_RAWETH_QP1_V3_CFA_METADATA0_DE	UINT32_C(0x1000)
+	/* When meta_format=1, this value is the VLAN PRI. */
+	#define CQ_RES_RAWETH_QP1_V3_CFA_METADATA0_PRI_MASK UINT32_C(0xe000)
+	#define CQ_RES_RAWETH_QP1_V3_CFA_METADATA0_PRI_SFT 13
 	/*
-	 * When set to '1', this operation will cause a trace capture in
-	 * each block it passes through.
+	 * This is an application level ID used to identify the
+	 * QP and its SQ and RQ.
 	 */
-	#define SQ_RDMA_HDR_FLAGS_DEBUG_TRACE								UINT32_C(0x40)
+	uint64_t	qp_handle;
+	uint32_t	raweth_qp1_flags2;
 	/*
-	 * The number of 16 bytes chunks of data including this first
-	 * wqe of the request that are a valid part of the request. The
-	 * valid 16 bytes units other than the WQE structure can be
-	 * SGEs (Scatter Gather Elements) OR inline data.
-	 *
-	 * While this field defines the valid WQE size.  The actual
-	 * total WQE size is always 128B.
+	 * This indicates that the ip checksum was calculated for the
+	 * inner packet and that the ip_cs_error field indicates if there
+	 * was an error.
 	 */
-	uint8_t	wqe_size;
-	uint8_t	reserved8;
+	#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_FLAGS2_IP_CS_CALC		UINT32_C(0x1)
 	/*
-	 * Immediate data - valid for RDMA Write with immediate and
-	 * causes the controller to add immDt header with this value
+	 * This indicates that the TCP, UDP or ICMP checksum was
+	 * calculated for the inner packet and that the l4_cs_error field
+	 * indicates if there was an error.
 	 */
-	uint32_t	imm_data;
-	/* Total data length in bytes */
-	uint32_t	length;
-	uint32_t	reserved32_1;
-	/* Remote VA sent to the destination QP */
-	uint64_t	remote_va;
+	#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_FLAGS2_L4_CS_CALC		UINT32_C(0x2)
 	/*
-	 * R_Key provided by remote node when the connection was
-	 * established and placed in the RETH header. It identify the
-	 * MRW on the remote host
+	 * This indicates that the ip checksum was calculated for the
+	 * tunnel header and that the t_ip_cs_error field indicates if
+	 * there was an error.
 	 */
-	uint32_t	remote_key;
-	uint32_t	timestamp;
+	#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_FLAGS2_T_IP_CS_CALC		UINT32_C(0x4)
 	/*
-	 * This field specifies a 24-bit timestamp that can be passed
-	 * down the TX path and optionally logged in the TXP timestamp
-	 * histogram.
+	 * This indicates that the UDP checksum was
+	 * calculated for the tunnel packet and that the t_l4_cs_error
+	 * field indicates if there was an error.
 	 */
-	#define SQ_RDMA_HDR_TIMESTAMP_MASK UINT32_C(0xffffff)
-	#define SQ_RDMA_HDR_TIMESTAMP_SFT 0
-} sq_rdma_hdr_t, *psq_rdma_hdr_t;
-
-/* Atomic SQ WQE */
-/* sq_atomic (size:1024b/128B) */
-
-typedef struct sq_atomic {
-	/* This field defines the type of SQ WQE. */
-	uint8_t	wqe_type;
+	#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_FLAGS2_T_L4_CS_CALC		UINT32_C(0x8)
+	/* The field indicates what format the metadata field is. */
+	#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_FLAGS2_META_FORMAT_MASK	UINT32_C(0xf0)
+	#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_FLAGS2_META_FORMAT_SFT		4
+	/* No metadata information. Values are zero. */
+		#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_FLAGS2_META_FORMAT_NONE		(UINT32_C(0x0) << 4)
 	/*
-	 * Atomic Compare/Swap.
+	 * The {metadata1, metadata0} fields contain the vtag
+	 * information:
 	 *
-	 * Allowed only on reliable connection (RC) SQs.
+	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0], de, vid[11:0]}
+	 *
+	 * The metadata2 field contains the table scope
+	 * and action record pointer.
+	 *
+	 * - metadata2[25:0] contains the action record pointer.
+	 * - metadata2[31:26] contains the table scope.
 	 */
-	#define SQ_ATOMIC_WQE_TYPE_ATOMIC_CS UINT32_C(0x8)
+		#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_FLAGS2_META_FORMAT_ACT_REC_PTR	(UINT32_C(0x1) << 4)
 	/*
-	 * Atomic Fetch/Add.
+	 * The {metadata1, metadata0} fields contain the vtag
+	 * information:
 	 *
-	 * Allowed only on reliable connection (RC) SQs.
+	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0], de, vid[11:0]}
+	 *
+	 * The metadata2 field contains the Tunnel ID value, justified
+	 * to LSB.
+	 *
+	 * - VXLAN = VNI[23:0] -> VXLAN Network ID
+	 * - Geneve (NGE) = VNI[23:0] a-> Virtual Network Identifier
+	 * - NVGRE = TNI[23:0] -> Tenant Network ID
+	 * - GRE = KEY[31:0] -> key field with bit mask. zero if K=0
+	 * - IPv4 = 0 (not populated)
+	 * - IPv6 = Flow Label[19:0]
+	 * - PPPoE = sessionID[15:0]
+	 * - MPLs = Outer label[19:0]
+	 * - UPAR = Selected[31:0] with bit mask
 	 */
-	#define SQ_ATOMIC_WQE_TYPE_ATOMIC_FA UINT32_C(0xb)
-	#define SQ_ATOMIC_WQE_TYPE_LAST	SQ_ATOMIC_WQE_TYPE_ATOMIC_FA
-	uint8_t	flags;
-	#define SQ_ATOMIC_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_MASK		UINT32_C(0xff)
-	#define SQ_ATOMIC_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_SFT			0
+		#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_FLAGS2_META_FORMAT_TUNNEL_ID	(UINT32_C(0x2) << 4)
 	/*
-	 * Set if completion signaling is requested. If this bit is
-	 * 0, and the SQ is configured to support Unsignaled
-	 * completion the controller should not generate a CQE
-	 * unless there was an error. This refers to CQE on the
-	 * sender side (se_flag refers to the receiver side)
+	 * The {metadata1, metadata0} fields contain the vtag
+	 * information:
+	 *
+	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0],de, vid[11:0]}
+	 *
+	 * The metadata2 field contains the 32b metadata from the
+	 * prepended header (chdr_data).
 	 */
-	#define SQ_ATOMIC_FLAGS_SIGNAL_COMP								UINT32_C(0x1)
+		#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_FLAGS2_META_FORMAT_CHDR_DATA	(UINT32_C(0x3) << 4)
 	/*
-	 * Indication to complete all previous RDMA Read or Atomic
-	 * WQEs on the SQ before executing this WQE
+	 * The {metadata1, metadata0} fields contain the vtag
+	 * information:
+	 *
+	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0], de, vid[11:0]}
+	 *
+	 * The metadata2 field contains the outer_l3_offset,
+	 * inner_l2_offset, inner_l3_offset, and inner_l4_size.
+	 *
+	 * - metadata2[8:0] contains the outer_l3_offset.
+	 * - metadata2[17:9] contains the inner_l2_offset.
+	 * - metadata2[26:18] contains the inner_l3_offset.
+	 * - metadata2[31:27] contains the inner_l4_size.
 	 */
-	#define SQ_ATOMIC_FLAGS_RD_OR_ATOMIC_FENCE							UINT32_C(0x2)
+		#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_FLAGS2_META_FORMAT_HDR_OFFSET	(UINT32_C(0x4) << 4)
+		#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_FLAGS2_META_FORMAT_LAST		CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_FLAGS2_META_FORMAT_HDR_OFFSET
 	/*
-	 * Unconditional fence. Indication to complete all previous
-	 * SQ's WQEs before executing this WQE.
+	 * This field indicates the IP type for the inner-most IP header.
+	 * A value of '0' indicates IPv4. A value of '1' indicates IPv6.
+	 * This value is only valid if itype indicates a packet
+	 * with an IP header.
 	 */
-	#define SQ_ATOMIC_FLAGS_UC_FENCE								UINT32_C(0x4)
+	#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_FLAGS2_IP_TYPE			UINT32_C(0x100)
 	/*
-	 * Solicit event. Indication sent in BTH header to the
-	 * receiver to generate a Completion Event Notification,
-	 * i.e. CNQE. This bit should be set only in the last (or
-	 * only) packet of the message.
+	 * This indicates that the complete 1's complement checksum was
+	 * calculated for the packet.
 	 */
-	#define SQ_ATOMIC_FLAGS_SE									UINT32_C(0x8)
-	/* NA for this WQE */
-	#define SQ_ATOMIC_FLAGS_INLINE								UINT32_C(0x10)
-	/*
-	 * The atomic WQE does not have a timestamp field, so this field is
-	 * ignored and should be zero.
+	#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_FLAGS2_COMPLETE_CHECKSUM_CALC	UINT32_C(0x200)
+	#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_FLAGS2_T_IP_TYPE		UINT32_C(0x400)
+	/* Indicates that the Tunnel IP type was IPv4. */
+		#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_FLAGS2_T_IP_TYPE_IPV4		(UINT32_C(0x0) << 10)
+	/* Indicates that the Tunnel IP type was IPv6. */
+		#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_FLAGS2_T_IP_TYPE_IPV6		(UINT32_C(0x1) << 10)
+		#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_FLAGS2_T_IP_TYPE_LAST		CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_FLAGS2_T_IP_TYPE_IPV6
+	/*
+	 * This value is the complete 1's complement checksum calculated
+	 * from the start of the outer L3 header to the end of the packet
+	 * (not including the ethernet crc). It is valid when the
+	 * 'complete_checksum_calc' flag is set.
 	 */
-	#define SQ_ATOMIC_FLAGS_WQE_TS_EN								UINT32_C(0x20)
+	#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_FLAGS2_COMPLETE_CHECKSUM_MASK	UINT32_C(0xffff0000)
+	#define CQ_RES_RAWETH_QP1_V3_RAWETH_QP1_FLAGS2_COMPLETE_CHECKSUM_SFT	16
 	/*
-	 * When set to '1', this operation will cause a trace capture in
-	 * each block it passes through.
+	 * This is data from the CFA block as indicated by the meta_format
+	 * field.
+	 *
+	 * - meta_format 0 - none - metadata2 = 0 - not valid/not stripped
+	 * - meta_format 1 - act_rec_ptr - metadata2 = {table_scope[5:0],
+	 *   act_rec_ptr[25:0]}
+	 * - meta_format 2 - tunnel_id - metadata2 = tunnel_id[31:0]
+	 * - meta_format 3 - chdr_data - metadata2 = updated_chdr_data[31:0]
+	 * - meta_format 4 - hdr_offsets - metadata2 = hdr_offsets[31:0]
 	 */
-	#define SQ_ATOMIC_FLAGS_DEBUG_TRACE								UINT32_C(0x40)
-	uint16_t	reserved16;
+	uint32_t	cfa_metadata2;
+	uint8_t	cqe_type_toggle;
 	/*
-	 * R_Key provided by remote node when the connection was
-	 * established and placed in the AETH header. It identify the
-	 * MRW on the remote host
+	 * Indicate valid completion - written by the chip. The NIC
+	 * toggles this bit each time it finished consuming all PBL
+	 * entries.
 	 */
-	uint32_t	remote_key;
-	/* Remote VA sent to the destination QP */
-	uint64_t	remote_va;
-	/* Data value to be placed in remote host specified address */
-	uint64_t	swap_data;
+	#define CQ_RES_RAWETH_QP1_V3_TOGGLE			UINT32_C(0x1)
+	/* This field defines the type of CQE. */
+	#define CQ_RES_RAWETH_QP1_V3_CQE_TYPE_MASK		UINT32_C(0x1e)
+	#define CQ_RES_RAWETH_QP1_V3_CQE_TYPE_SFT		1
 	/*
-	 * Data value to be compared with the value in the remote host
-	 * specified address
+	 * Responder RawEth and QP1 Completion - This is used for RQ and
+	 * SRQ completion for RawEth service. It is also used for QP1 QPs
+	 * that are treated as RawEth.
 	 */
-	uint64_t	cmp_data;
+		#define CQ_RES_RAWETH_QP1_V3_CQE_TYPE_RES_RAWETH_QP1_V3  (UINT32_C(0xb) << 1)
+		#define CQ_RES_RAWETH_QP1_V3_CQE_TYPE_LAST		CQ_RES_RAWETH_QP1_V3_CQE_TYPE_RES_RAWETH_QP1_V3
+	/* This field indicates the status for the CQE. */
+	uint8_t	status;
+	/* The operation completed successfully. */
+	#define CQ_RES_RAWETH_QP1_V3_STATUS_OK			UINT32_C(0x0)
 	/*
-	 * The first 16B of the data field must be filled with a single
-	 * SGE. This will be used to store the return value from the
-	 * Atomic Ack response.  The size of the single SGE must be 8B.
+	 * This indicates that the packet was too long for the WQE provided
+	 * on the SRQ/RQ.
+	 *
+	 * This is not a fatal error. All the fields in the CQE are valid.
 	 */
-	uint32_t	data[24];
-} sq_atomic_t, *psq_atomic_t;
-
-/* Atomic SQ WQE header. */
-/* sq_atomic_hdr (size:256b/32B) */
-
-typedef struct sq_atomic_hdr {
-	/* This field defines the type of SQ WQE. */
-	uint8_t	wqe_type;
+	#define CQ_RES_RAWETH_QP1_V3_STATUS_HW_LOCAL_LENGTH_ERR	UINT32_C(0x3)
 	/*
-	 * Atomic Compare/Swap.
+	 * An internal QP consistency error was detected while processing
+	 * this Work Request. For requester, this could be an SQ WQE format
+	 * error or an operation specified in the WQE that is not supported
+	 * for the QP. For responder, this is an RQ/SRQ WQE format error.
 	 *
-	 * Allowed only on reliable connection (RC) SQs.
+	 * This is a fatal error detected by the requester Tx or responder
+	 * Rx. For responder CQEs, only the opaque field is valid.
 	 */
-	#define SQ_ATOMIC_HDR_WQE_TYPE_ATOMIC_CS UINT32_C(0x8)
+	#define CQ_RES_RAWETH_QP1_V3_STATUS_LOCAL_QP_OPERATION_ERR   UINT32_C(0x4)
 	/*
-	 * Atomic Fetch/Add.
+	 * An SGE in the locally posted WQE does not reference a Memory
+	 * Region that is valid for the requested operation. If this error
+	 * is generated for an SGE using the reserved l_key, this means
+	 * that the reserved l_key is not enabled.
 	 *
-	 * Allowed only on reliable connection (RC) SQs.
+	 * This is a fatal error detected by the requester Tx or responder
+	 * Rx. For responder CQEs, only the opaque field is valid.
 	 */
-	#define SQ_ATOMIC_HDR_WQE_TYPE_ATOMIC_FA UINT32_C(0xb)
-	#define SQ_ATOMIC_HDR_WQE_TYPE_LAST	SQ_ATOMIC_HDR_WQE_TYPE_ATOMIC_FA
-	uint8_t	flags;
-	#define SQ_ATOMIC_HDR_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_MASK		UINT32_C(0xff)
-	#define SQ_ATOMIC_HDR_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_SFT			0
+	#define CQ_RES_RAWETH_QP1_V3_STATUS_LOCAL_PROTECTION_ERR	UINT32_C(0x5)
 	/*
-	 * Set if completion signaling is requested. If this bit is
-	 * 0, and the SQ is configured to support Unsignaled
-	 * completion the controller should not generate a CQE
-	 * unless there was an error. This refers to CQE on the
-	 * sender side (se_flag refers to the receiver side)
+	 * A WQE was in process or outstanding when the QP transitioned
+	 * into the Error State.
 	 */
-	#define SQ_ATOMIC_HDR_FLAGS_SIGNAL_COMP								UINT32_C(0x1)
+	#define CQ_RES_RAWETH_QP1_V3_STATUS_WORK_REQUEST_FLUSHED_ERR UINT32_C(0xd)
 	/*
-	 * Indication to complete all previous RDMA Read or Atomic
-	 * WQEs on the SQ before executing this WQE
+	 * A WQE had already been taken off the RQ/SRQ when a fatal error
+	 * was detected on responder Rx. Only the opaque field in the CQE
+	 * is valid.
 	 */
-	#define SQ_ATOMIC_HDR_FLAGS_RD_OR_ATOMIC_FENCE							UINT32_C(0x2)
+	#define CQ_RES_RAWETH_QP1_V3_STATUS_HW_FLUSH_ERR		UINT32_C(0xe)
 	/*
-	 * Unconditional fence. Indication to complete all previous
-	 * SQ's WQEs before executing this WQE.
+	 * A WQE was posted to the SQ/RQ that caused it to overflow. For
+	 * requester CQEs, it was the SQ that overflowed. For responder
+	 * CQEs, it was the RQ that overflowed.
 	 */
-	#define SQ_ATOMIC_HDR_FLAGS_UC_FENCE								UINT32_C(0x4)
+	#define CQ_RES_RAWETH_QP1_V3_STATUS_OVERFLOW_ERR		UINT32_C(0xf)
+	#define CQ_RES_RAWETH_QP1_V3_STATUS_LAST			CQ_RES_RAWETH_QP1_V3_STATUS_OVERFLOW_ERR
+	uint8_t	flags;
 	/*
-	 * Solicit event. Indication sent in BTH header to the
-	 * receiver to generate a Completion Event Notification,
-	 * i.e. CNQE. This bit should be set only in the last (or
-	 * only) packet of the message.
+	 * This flag indicates that the completion is for a SRQ entry
+	 * rather than for an RQ entry.
 	 */
-	#define SQ_ATOMIC_HDR_FLAGS_SE									UINT32_C(0x8)
-	/* NA for this WQE */
-	#define SQ_ATOMIC_HDR_FLAGS_INLINE								UINT32_C(0x10)
+	#define CQ_RES_RAWETH_QP1_V3_FLAGS_SRQ	UINT32_C(0x1)
+	/* CQE relates to RQ WQE. */
+		#define CQ_RES_RAWETH_QP1_V3_FLAGS_SRQ_RQ	UINT32_C(0x0)
+	/* CQE relates to SRQ WQE. */
+		#define CQ_RES_RAWETH_QP1_V3_FLAGS_SRQ_SRQ   UINT32_C(0x1)
+		#define CQ_RES_RAWETH_QP1_V3_FLAGS_SRQ_LAST CQ_RES_RAWETH_QP1_V3_FLAGS_SRQ_SRQ
 	/*
-	 * The atomic WQE does not have a timestamp field, so this field is
-	 * ignored and should be zero.
+	 * This value indicates the offset in bytes from the beginning of the
+	 * packet where the inner payload starts. This value is valid for
+	 * TCP, UDP, FCoE, and RoCE packets.
+	 *
+	 * A value of zero indicates an offset of 256 bytes.
 	 */
-	#define SQ_ATOMIC_HDR_FLAGS_WQE_TS_EN								UINT32_C(0x20)
+	uint8_t	raweth_qp1_payload_offset;
+	/* This value is from the WQE that is being completed. */
+	uint32_t	opaque;
+} cq_res_raweth_qp1_v3_t, *pcq_res_raweth_qp1_v3_t;
+
+/*
+ * This is the Responder RQ/SRQ CQE V3 structure for UD QPs and QP1 QPs
+ * treated as UD. This is used to complete RQ/SRQ WQE's. It differs
+ * from the Res_UD CQE in that it carries additional CFA fields, in
+ * place of the QP handle. (Instead of the QP handle, this CQE carries
+ * the QID. It is up to the user to map the QID back to a QP handle.)
+ * When the WQE is completed, it indicates that there is room for one
+ * more WQE on the corresponding RQ/SRQ.
+ *
+ * User can determine available space in the RQ/SRQ by comparing
+ * a rq_cons_idx to a rq_prod_idx, both maintained by the user. The
+ * range for rq_prod/cons_idx is from 0 to QPC.rq_size-1. The
+ * rq_prod_idx value increments by one for each WQE that is added to
+ * the RQ/SRQ by the user. Value must be wrapped at rq_size. The
+ * rq_cons_idx value increments by one for each WQE that is completed
+ * from that particular RQ/SRQ. The qp_handle can be used by the user
+ * to determine what RQ/SRQ to increment. Value must also be wrapped at
+ * rq_size. When the two values are equal, the RQ/SRQ is empty. When
+ * (rq_prod_idx+1)%QPC.rq_size==rq_cons_idx, the queue is full.
+ */
+/* cq_res_ud_cfa_v3 (size:256b/32B) */
+
+typedef struct cq_res_ud_cfa_v3 {
+	uint16_t	length;
 	/*
-	 * When set to '1', this operation will cause a trace capture in
-	 * each block it passes through.
+	 * The length of the message's payload in bytes, stored in
+	 * the SGEs
 	 */
-	#define SQ_ATOMIC_HDR_FLAGS_DEBUG_TRACE								UINT32_C(0x40)
-	uint16_t	reserved16;
+	#define CQ_RES_UD_CFA_V3_LENGTH_MASK UINT32_C(0x3fff)
+	#define CQ_RES_UD_CFA_V3_LENGTH_SFT 0
+	/* This is data from the CFA as indicated by the meta_format field. */
+	uint16_t	cfa_metadata0;
+	/* When meta_format=1, this value is the VLAN VID. */
+	#define CQ_RES_UD_CFA_V3_CFA_METADATA0_VID_MASK UINT32_C(0xfff)
+	#define CQ_RES_UD_CFA_V3_CFA_METADATA0_VID_SFT 0
+	/* When meta_format=1, this value is the VLAN DE. */
+	#define CQ_RES_UD_CFA_V3_CFA_METADATA0_DE	UINT32_C(0x1000)
+	/* When meta_format=1, this value is the VLAN PRI. */
+	#define CQ_RES_UD_CFA_V3_CFA_METADATA0_PRI_MASK UINT32_C(0xe000)
+	#define CQ_RES_UD_CFA_V3_CFA_METADATA0_PRI_SFT 13
+	/* Immediate data in case the imm_flag set. */
+	uint32_t	imm_data;
+	uint32_t	qid_cfa_metadata1_src_qp_high;
 	/*
-	 * R_Key provided by remote node when the connection was
-	 * established and placed in the AETH header. It identify the
-	 * MRW on the remote host
+	 * This value indicates the QPID associated with this operation.
+	 *
+	 * The driver will use the qid from this CQE to map a QP handle
+	 * in the completion record returned to the application.
 	 */
-	uint32_t	remote_key;
-	/* Remote VA sent to the destination QP */
-	uint64_t	remote_va;
-	/* Data value to be placed in remote host specified address */
-	uint64_t	swap_data;
+	#define CQ_RES_UD_CFA_V3_QID_MASK		UINT32_C(0x7ff)
+	#define CQ_RES_UD_CFA_V3_QID_SFT			0
+	#define CQ_RES_UD_CFA_V3_UNUSED_MASK		UINT32_C(0xff800)
+	#define CQ_RES_UD_CFA_V3_UNUSED_SFT		11
+	#define CQ_RES_UD_CFA_V3_CFA_METADATA1_MASK	UINT32_C(0xf00000)
+	#define CQ_RES_UD_CFA_V3_CFA_METADATA1_SFT	20
+	/* When meta_format != 0, this value is the VLAN TPID_SEL. */
+	#define CQ_RES_UD_CFA_V3_CFA_METADATA1_TPID_SEL_MASK UINT32_C(0x700000)
+	#define CQ_RES_UD_CFA_V3_CFA_METADATA1_TPID_SEL_SFT  20
+	/* When meta_format != 0, this value is the VLAN valid. */
+	#define CQ_RES_UD_CFA_V3_CFA_METADATA1_VALID	UINT32_C(0x800000)
+	/* Upper 8b of the Source QP value from the DETH header. */
+	#define CQ_RES_UD_CFA_V3_SRC_QP_HIGH_MASK	UINT32_C(0xff000000)
+	#define CQ_RES_UD_CFA_V3_SRC_QP_HIGH_SFT		24
 	/*
-	 * Data value to be compared with the value in the remote host
-	 * specified address
+	 * This is data from the CFA block as indicated by the meta_format
+	 * field.
+	 *
+	 * - meta_format 0 - none - metadata2 = 0 - not valid/not stripped
+	 * - meta_format 1 - act_rec_ptr - metadata2 = {table_scope[5:0],
+	 *   act_rec_ptr[25:0]}
+	 * - meta_format 2 - tunnel_id - metadata2 = tunnel_id[31:0]
+	 * - meta_format 3 - chdr_data - metadata2 = updated_chdr_data[31:0]
+	 * - meta_format 4 - hdr_offsets - metadata2 = hdr_offsets[31:0]
 	 */
-	uint64_t	cmp_data;
-} sq_atomic_hdr_t, *psq_atomic_hdr_t;
-
-/* Local Invalidate SQ WQE */
-/* sq_localinvalidate (size:1024b/128B) */
-
-typedef struct sq_localinvalidate {
-	/* This field defines the type of SQ WQE. */
-	uint8_t	wqe_type;
+	uint32_t	cfa_metadata2;
 	/*
-	 * Local Invalidate.
-	 *
-	 * Allowed only on reliable connection (RC) SQs.
+	 * Source MAC address for the UD message placed in the WQE
+	 * that is completed by this CQE.
 	 */
-	#define SQ_LOCALINVALIDATE_WQE_TYPE_LOCAL_INVALID UINT32_C(0xc)
-	#define SQ_LOCALINVALIDATE_WQE_TYPE_LAST	SQ_LOCALINVALIDATE_WQE_TYPE_LOCAL_INVALID
-	uint8_t	flags;
-	#define SQ_LOCALINVALIDATE_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_MASK		UINT32_C(0xff)
-	#define SQ_LOCALINVALIDATE_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_SFT			0
+	uint16_t	src_mac[3];
+	/* Lower 16b of the Source QP value from the DETH header. */
+	uint16_t	src_qp_low;
+	uint8_t	cqe_type_toggle;
 	/*
-	 * Set if completion signaling is requested. If this bit is
-	 * 0, and the SQ is configured to support Unsignaled
-	 * completion the controller should not generate a CQE
-	 * unless there was an error. This refers to CQE on the
-	 * sender side (se_flag refers to the receiver side)
+	 * Indicate valid completion - written by the chip. The NIC
+	 * toggles this bit each time it finished consuming all PBL
+	 * entries
 	 */
-	#define SQ_LOCALINVALIDATE_FLAGS_SIGNAL_COMP								UINT32_C(0x1)
+	#define CQ_RES_UD_CFA_V3_TOGGLE		UINT32_C(0x1)
+	/* This field defines the type of CQE. */
+	#define CQ_RES_UD_CFA_V3_CQE_TYPE_MASK	UINT32_C(0x1e)
+	#define CQ_RES_UD_CFA_V3_CQE_TYPE_SFT	1
 	/*
-	 * Indication to complete all previous RDMA Read or Atomic
-	 * WQEs on the SQ before executing this WQE
+	 * Responder UD Completion with CFA - This is used for both RQ
+	 * and SRQ completion for UD service QPs. It includes cfa fields
+	 * (some of which carry VLAN information), in place of the QP
+	 * handle. It is also used for QP1 QPs that are treated as UD.
 	 */
-	#define SQ_LOCALINVALIDATE_FLAGS_RD_OR_ATOMIC_FENCE							UINT32_C(0x2)
+		#define CQ_RES_UD_CFA_V3_CQE_TYPE_RES_UD_CFA_V3  (UINT32_C(0xc) << 1)
+		#define CQ_RES_UD_CFA_V3_CQE_TYPE_LAST	CQ_RES_UD_CFA_V3_CQE_TYPE_RES_UD_CFA_V3
+	/* This field indicates the status for the CQE. */
+	uint8_t	status;
+	/* The operation completed successfully. */
+	#define CQ_RES_UD_CFA_V3_STATUS_OK			UINT32_C(0x0)
 	/*
-	 * Unconditional fence. Indication to complete all previous
-	 * SQ's WQEs before executing this WQE.
+	 * This indicates that the packet was too long for the WQE provided
+	 * on the SRQ/RQ.
+	 *
+	 * This is not a fatal error. All the fields in the CQE are valid.
 	 */
-	#define SQ_LOCALINVALIDATE_FLAGS_UC_FENCE								UINT32_C(0x4)
+	#define CQ_RES_UD_CFA_V3_STATUS_HW_LOCAL_LENGTH_ERR	UINT32_C(0x3)
 	/*
-	 * Solicit event. Indication sent in BTH header to the
-	 * receiver to generate a Completion Event Notification,
-	 * i.e. CNQE. This bit should be set only in the last (or
-	 * only) packet of the message.
+	 * An internal QP consistency error was detected while processing
+	 * this Work Request. For requester, this could be an SQ WQE format
+	 * error or an operation specified in the WQE that is not supported
+	 * for the QP. For responder, this is an RQ/SRQ WQE format error.
+	 *
+	 * This is a fatal error detected by the requester Tx or responder
+	 * Rx. For responder CQEs, only the opaque field is valid.
 	 */
-	#define SQ_LOCALINVALIDATE_FLAGS_SE									UINT32_C(0x8)
-	/* NA for this WQE */
-	#define SQ_LOCALINVALIDATE_FLAGS_INLINE								UINT32_C(0x10)
+	#define CQ_RES_UD_CFA_V3_STATUS_LOCAL_QP_OPERATION_ERR   UINT32_C(0x4)
 	/*
-	 * This flag is not applicable and should be 0 for a local memory
-	 * operation WQE.
+	 * An SGE in the locally posted WQE does not reference a Memory
+	 * Region that is valid for the requested operation. If this error
+	 * is generated for an SGE using the reserved l_key, this means
+	 * that the reserved l_key is not enabled.
+	 *
+	 * This is a fatal error detected by the requester Tx or responder
+	 * Rx. For responder CQEs, only the opaque field is valid.
 	 */
-	#define SQ_LOCALINVALIDATE_FLAGS_WQE_TS_EN								UINT32_C(0x20)
+	#define CQ_RES_UD_CFA_V3_STATUS_LOCAL_PROTECTION_ERR	UINT32_C(0x5)
 	/*
-	 * When set to '1', this operation will cause a trace capture in
-	 * each block it passes through.
+	 * A WQE was in process or outstanding when the QP transitioned
+	 * into the Error State.
 	 */
-	#define SQ_LOCALINVALIDATE_FLAGS_DEBUG_TRACE								UINT32_C(0x40)
-	uint16_t	reserved16;
+	#define CQ_RES_UD_CFA_V3_STATUS_WORK_REQUEST_FLUSHED_ERR UINT32_C(0xd)
 	/*
-	 * The local key for the MR/W to invalidate; 24 msb of the key
-	 * are used to index the MRW table, 8 lsb are compared with the
-	 * 8 bit key in the MRWC
+	 * A WQE had already been taken off the RQ/SRQ when a fatal error
+	 * was detected on responder Rx. Only the opaque field in the CQE
+	 * is valid.
 	 */
-	uint32_t	inv_l_key;
-	uint64_t	reserved64;
-	uint8_t	reserved128[16];
-	/* The data field for local invalidate is not used. */
-	uint32_t	data[24];
-} sq_localinvalidate_t, *psq_localinvalidate_t;
-
-/* Local Invalidate SQ WQE header. */
-/* sq_localinvalidate_hdr (size:256b/32B) */
-
-typedef struct sq_localinvalidate_hdr {
-	/* This field defines the type of SQ WQE. */
-	uint8_t	wqe_type;
+	#define CQ_RES_UD_CFA_V3_STATUS_HW_FLUSH_ERR		UINT32_C(0xe)
 	/*
-	 * Local Invalidate.
-	 *
-	 * Allowed only on reliable connection (RC) SQs.
+	 * A WQE was posted to the SQ/RQ that caused it to overflow. For
+	 * requester CQEs, it was the SQ that overflowed. For responder
+	 * CQEs, it was the RQ that overflowed.
 	 */
-	#define SQ_LOCALINVALIDATE_HDR_WQE_TYPE_LOCAL_INVALID UINT32_C(0xc)
-	#define SQ_LOCALINVALIDATE_HDR_WQE_TYPE_LAST	SQ_LOCALINVALIDATE_HDR_WQE_TYPE_LOCAL_INVALID
-	uint8_t	flags;
-	#define SQ_LOCALINVALIDATE_HDR_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_MASK		UINT32_C(0xff)
-	#define SQ_LOCALINVALIDATE_HDR_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_SFT			0
+	#define CQ_RES_UD_CFA_V3_STATUS_OVERFLOW_ERR		UINT32_C(0xf)
+	#define CQ_RES_UD_CFA_V3_STATUS_LAST			CQ_RES_UD_CFA_V3_STATUS_OVERFLOW_ERR
+	uint16_t	flags;
 	/*
-	 * Set if completion signaling is requested. If this bit is
-	 * 0, and the SQ is configured to support Unsignaled
-	 * completion the controller should not generate a CQE
-	 * unless there was an error. This refers to CQE on the
-	 * sender side (se_flag refers to the receiver side)
+	 * This flag indicates that the completion is for a SRQ entry
+	 * rather than for an RQ entry.
 	 */
-	#define SQ_LOCALINVALIDATE_HDR_FLAGS_SIGNAL_COMP								UINT32_C(0x1)
+	#define CQ_RES_UD_CFA_V3_FLAGS_SRQ			UINT32_C(0x1)
+	/* CQE relates to RQ WQE. */
+		#define CQ_RES_UD_CFA_V3_FLAGS_SRQ_RQ		UINT32_C(0x0)
+	/* CQE relates to SRQ WQE. */
+		#define CQ_RES_UD_CFA_V3_FLAGS_SRQ_SRQ		UINT32_C(0x1)
+		#define CQ_RES_UD_CFA_V3_FLAGS_SRQ_LAST		CQ_RES_UD_CFA_V3_FLAGS_SRQ_SRQ
+	/* Immediate data indicator */
+	#define CQ_RES_UD_CFA_V3_FLAGS_IMM			UINT32_C(0x2)
+	#define CQ_RES_UD_CFA_V3_FLAGS_UNUSED_MASK		UINT32_C(0xc)
+	#define CQ_RES_UD_CFA_V3_FLAGS_UNUSED_SFT		2
+	#define CQ_RES_UD_CFA_V3_FLAGS_ROCE_IP_VER_MASK	UINT32_C(0x30)
+	#define CQ_RES_UD_CFA_V3_FLAGS_ROCE_IP_VER_SFT	4
+	/* RoCEv1 Message */
+		#define CQ_RES_UD_CFA_V3_FLAGS_ROCE_IP_VER_V1	(UINT32_C(0x0) << 4)
+	/* RoCEv2 IPv4 Message */
+		#define CQ_RES_UD_CFA_V3_FLAGS_ROCE_IP_VER_V2IPV4	(UINT32_C(0x2) << 4)
+	/* RoCEv2 IPv6 Message */
+		#define CQ_RES_UD_CFA_V3_FLAGS_ROCE_IP_VER_V2IPV6	(UINT32_C(0x3) << 4)
+		#define CQ_RES_UD_CFA_V3_FLAGS_ROCE_IP_VER_LAST	CQ_RES_UD_CFA_V3_FLAGS_ROCE_IP_VER_V2IPV6
+	/* The field indicates what format the metadata field is. */
+	#define CQ_RES_UD_CFA_V3_FLAGS_META_FORMAT_MASK	UINT32_C(0x3c0)
+	#define CQ_RES_UD_CFA_V3_FLAGS_META_FORMAT_SFT	6
+	/* No metadata information. Value is zero. */
+		#define CQ_RES_UD_CFA_V3_FLAGS_META_FORMAT_NONE	(UINT32_C(0x0) << 6)
 	/*
-	 * Indication to complete all previous RDMA Read or Atomic
-	 * WQEs on the SQ before executing this WQE
+	 * The {metadata1, metadata0} fields contain the vtag
+	 * information:
+	 *
+	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0], de, vid[11:0]}
+	 *
+	 * The metadata2 field contains the table scope
+	 * and action record pointer.
+	 *
+	 * - metadata2[25:0] contains the action record pointer.
+	 * - metadata2[31:26] contains the table scope.
+	 */
+		#define CQ_RES_UD_CFA_V3_FLAGS_META_FORMAT_ACT_REC_PTR  (UINT32_C(0x1) << 6)
+	/*
+	 * The {metadata1, metadata0} fields contain the vtag
+	 * information:
+	 *
+	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0], de, vid[11:0]}
+	 *
+	 * The metadata2 field contains the Tunnel ID
+	 * value, justified to LSB.
+	 *
+	 * - VXLAN = VNI[23:0] -> VXLAN Network ID
+	 * - Geneve (NGE) = VNI[23:0] a-> Virtual Network Identifier
+	 * - NVGRE = TNI[23:0] -> Tenant Network ID
+	 * - GRE = KEY[31:0] -> key field with bit mask. zero if K=0
+	 * - IPv4 = 0 (not populated)
+	 * - IPv6 = Flow Label[19:0]
+	 * - PPPoE = sessionID[15:0]
+	 * - MPLs = Outer label[19:0]
+	 * - UPAR = Selected[31:0] with bit mask
 	 */
-	#define SQ_LOCALINVALIDATE_HDR_FLAGS_RD_OR_ATOMIC_FENCE							UINT32_C(0x2)
+		#define CQ_RES_UD_CFA_V3_FLAGS_META_FORMAT_TUNNEL_ID	(UINT32_C(0x2) << 6)
 	/*
-	 * Unconditional fence. Indication to complete all previous
-	 * SQ's WQEs before executing this WQE.
+	 * The {metadata1, metadata0} fields contain the vtag
+	 * information:
+	 *
+	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0],de, vid[11:0]}
+	 *
+	 * The metadata2 field contains the 32b metadata from the
+	 * prepended header (chdr_data).
 	 */
-	#define SQ_LOCALINVALIDATE_HDR_FLAGS_UC_FENCE								UINT32_C(0x4)
+		#define CQ_RES_UD_CFA_V3_FLAGS_META_FORMAT_CHDR_DATA	(UINT32_C(0x3) << 6)
 	/*
-	 * Solicit event. Indication sent in BTH header to the
-	 * receiver to generate a Completion Event Notification,
-	 * i.e. CNQE. This bit should be set only in the last (or
-	 * only) packet of the message.
+	 * The {metadata1, metadata0} fields contain the vtag
+	 * information:
+	 *
+	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0], de, vid[11:0]}
+	 *
+	 * The metadata2 field contains the outer_l3_offset,
+	 * inner_l2_offset, inner_l3_offset, and inner_l4_size.
+	 *
+	 * - metadata2[8:0] contains the outer_l3_offset.
+	 * - metadata2[17:9] contains the inner_l2_offset.
+	 * - metadata2[26:18] contains the inner_l3_offset.
+	 * - metadata2[31:27] contains the inner_l4_size.
 	 */
-	#define SQ_LOCALINVALIDATE_HDR_FLAGS_SE									UINT32_C(0x8)
-	/* NA for this WQE */
-	#define SQ_LOCALINVALIDATE_HDR_FLAGS_INLINE								UINT32_C(0x10)
+		#define CQ_RES_UD_CFA_V3_FLAGS_META_FORMAT_HDR_OFFSET   (UINT32_C(0x4) << 6)
+		#define CQ_RES_UD_CFA_V3_FLAGS_META_FORMAT_LAST	CQ_RES_UD_CFA_V3_FLAGS_META_FORMAT_HDR_OFFSET
 	/*
-	 * This flag is not applicable and should be 0 for a local memory
-	 * operation WQE.
+	 * This value will be returned in the completion if the completion is
+	 * signaled.
 	 */
-	#define SQ_LOCALINVALIDATE_HDR_FLAGS_WQE_TS_EN								UINT32_C(0x20)
+	uint32_t	opaque;
+} cq_res_ud_cfa_v3_t, *pcq_res_ud_cfa_v3_t;
+
+/* nq_base (size:128b/16B) */
+
+typedef struct nq_base {
+	uint16_t	info10_type;
 	/*
-	 * When set to '1', this operation will cause a trace capture in
-	 * each block it passes through.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	#define SQ_LOCALINVALIDATE_HDR_FLAGS_DEBUG_TRACE								UINT32_C(0x40)
-	uint16_t	reserved16;
+	#define NQ_BASE_TYPE_MASK	UINT32_C(0x3f)
+	#define NQ_BASE_TYPE_SFT		0
+	/* CQ Notification */
+		#define NQ_BASE_TYPE_CQ_NOTIFICATION  UINT32_C(0x30)
+	/* SRQ Threshold Event */
+		#define NQ_BASE_TYPE_SRQ_EVENT	UINT32_C(0x32)
+	/* DBQ Threshold Event */
+		#define NQ_BASE_TYPE_DBQ_EVENT	UINT32_C(0x34)
+	/* QP Async Notification */
+		#define NQ_BASE_TYPE_QP_EVENT	UINT32_C(0x38)
+	/* Function Async Notification */
+		#define NQ_BASE_TYPE_FUNC_EVENT	UINT32_C(0x3a)
+	/* NQ Reassign Notification */
+		#define NQ_BASE_TYPE_NQ_REASSIGN	UINT32_C(0x3c)
+		#define NQ_BASE_TYPE_LAST		NQ_BASE_TYPE_NQ_REASSIGN
+	/* info10 is 10 b */
+	#define NQ_BASE_INFO10_MASK	UINT32_C(0xffc0)
+	#define NQ_BASE_INFO10_SFT	6
+	/* info16 is 16 b */
+	uint16_t	info16;
+	/* info32 is 32 b */
+	uint32_t	info32;
+	/* info32 is 32 b */
+	uint64_t	info63_v;
 	/*
-	 * The local key for the MR/W to invalidate; 24 msb of the key
-	 * are used to index the MRW table, 8 lsb are compared with the
-	 * 8 bit key in the MRWC
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	uint32_t	inv_l_key;
-	uint64_t	reserved64;
-	uint8_t	reserved128[16];
-} sq_localinvalidate_hdr_t, *psq_localinvalidate_hdr_t;
+	#define NQ_BASE_V	UINT32_C(0x1)
+	/* info63 is 63 b */
+	#define NQ_BASE_INFO63_MASK UINT32_C(0xfffffffe)
+	#define NQ_BASE_INFO63_SFT 1
+} nq_base_t, *pnq_base_t;
 
-/* FR-PMR SQ WQE */
-/* sq_fr_pmr (size:1024b/128B) */
+/* Completion Queue Notification */
+/* nq_cn (size:128b/16B) */
 
-typedef struct sq_fr_pmr {
-	/* This field defines the type of SQ WQE. */
-	uint8_t	wqe_type;
+typedef struct nq_cn {
+	uint16_t	type;
 	/*
-	 * FR-PMR (Fast Register Physical Memory Region)
-	 *
-	 * Allowed only on reliable connection (RC) SQs.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	#define SQ_FR_PMR_WQE_TYPE_FR_PMR UINT32_C(0xd)
-	#define SQ_FR_PMR_WQE_TYPE_LAST  SQ_FR_PMR_WQE_TYPE_FR_PMR
-	uint8_t	flags;
+	#define NQ_CN_TYPE_MASK	UINT32_C(0x3f)
+	#define NQ_CN_TYPE_SFT		0
+	/* CQ Notification */
+		#define NQ_CN_TYPE_CQ_NOTIFICATION  UINT32_C(0x30)
+		#define NQ_CN_TYPE_LAST		NQ_CN_TYPE_CQ_NOTIFICATION
 	/*
-	 * Set if completion signaling is requested. If this bit is
-	 * 0, and the SQ is configured to support Unsignaled
-	 * completion the controller should not generate a CQE
-	 * unless there was an error. This refers to CQE on the
-	 * sender side (se_flag refers to the receiver side)
-	 */
-	#define SQ_FR_PMR_FLAGS_SIGNAL_COMP		UINT32_C(0x1)
+	 * This field carries the toggle value that must be used to
+	 * re-arm this CQ. The toggle value should be copied into the
+	 * doorbell used to CQ_ARMENA, CQ_ARMALL or CQ_ARMSE doorbells.
+	 *
+	 * This value is used by HW to detect old and stale CQ_ARMENA,
+	 * CQ_ARMALL, or CQ_ARMSE doorbells that are caused by having
+	 * a backup doorbell location or by PCI or other reordering
+	 * problems. Only the doorbells that match the latest value of
+	 * toggle will be honored.
+	 */
+	#define NQ_CN_TOGGLE_MASK	UINT32_C(0xc0)
+	#define NQ_CN_TOGGLE_SFT	6
+	uint16_t	reserved16;
 	/*
-	 * Indication to complete all previous RDMA Read or Atomic
-	 * WQEs on the SQ before executing this WQE
+	 * This is an application level ID used to identify the
+	 * CQ. This field carries the lower 32b of the value.
 	 */
-	#define SQ_FR_PMR_FLAGS_RD_OR_ATOMIC_FENCE	UINT32_C(0x2)
+	uint32_t	cq_handle_low;
+	uint32_t	v;
 	/*
-	 * Unconditional fence. Indication to complete all previous
-	 * SQ's WQEs before executing this WQE.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	#define SQ_FR_PMR_FLAGS_UC_FENCE		UINT32_C(0x4)
-	/* Not Applicable for FR_PMR. Nothing is sent */
-	#define SQ_FR_PMR_FLAGS_SE			UINT32_C(0x8)
-	/* NA */
-	#define SQ_FR_PMR_FLAGS_INLINE		UINT32_C(0x10)
+	#define NQ_CN_V	UINT32_C(0x1)
 	/*
-	 * This flag is not applicable and should be 0 for a local memory
-	 * operation WQE.
+	 * This is an application level ID used to identify the
+	 * CQ. This field carries the upper 32b of the value.
 	 */
-	#define SQ_FR_PMR_FLAGS_WQE_TS_EN		UINT32_C(0x20)
+	uint32_t	cq_handle_high;
+} nq_cn_t, *pnq_cn_t;
+
+/* SRQ Event Notification */
+/* nq_srq_event (size:128b/16B) */
+
+typedef struct nq_srq_event {
+	uint8_t	type;
 	/*
-	 * When set to '1', this operation will cause a trace capture in
-	 * each block it passes through.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B records.
 	 */
-	#define SQ_FR_PMR_FLAGS_DEBUG_TRACE		UINT32_C(0x40)
+	#define NQ_SRQ_EVENT_TYPE_MASK	UINT32_C(0x3f)
+	#define NQ_SRQ_EVENT_TYPE_SFT	0
+	/* SRQ Threshold Event */
+		#define NQ_SRQ_EVENT_TYPE_SRQ_EVENT  UINT32_C(0x32)
+		#define NQ_SRQ_EVENT_TYPE_LAST	NQ_SRQ_EVENT_TYPE_SRQ_EVENT
 	/*
-	 * This is the new access control for the MR.  '1' means
-	 * the operation is allowed.  '0' means operation is
-	 * not allowed.
+	 * This field carries the toggle value that must be used
+	 * to re-arm this SRQ. The toggle value should be copied
+	 * into the doorbell used to SRQ_ARMENA or SRQ_ARM doorbells.
 	 */
-	uint8_t	access_cntl;
-	/* Local Write Access */
-	#define SQ_FR_PMR_ACCESS_CNTL_LOCAL_WRITE	UINT32_C(0x1)
-	/* Remote Read Access */
-	#define SQ_FR_PMR_ACCESS_CNTL_REMOTE_READ	UINT32_C(0x2)
-	/* Remote Write Access */
-	#define SQ_FR_PMR_ACCESS_CNTL_REMOTE_WRITE	UINT32_C(0x4)
-	/* Remote Atomic Access */
-	#define SQ_FR_PMR_ACCESS_CNTL_REMOTE_ATOMIC	UINT32_C(0x8)
-	/* Window Binding Allowed */
-	#define SQ_FR_PMR_ACCESS_CNTL_WINDOW_BIND	UINT32_C(0x10)
-	uint8_t	zero_based_page_size_log;
-	/* Page size. 0 for 4KB page size, ... to 8TB. */
-	#define SQ_FR_PMR_PAGE_SIZE_LOG_MASK	UINT32_C(0x1f)
-	#define SQ_FR_PMR_PAGE_SIZE_LOG_SFT	0
-	/* Page size is 4KB. */
-		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_4K	UINT32_C(0x0)
-	/* Page size is 8KB. */
-		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_8K	UINT32_C(0x1)
-	/* Page size is 16KB. */
-		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_16K   UINT32_C(0x2)
-	/* Page size is 32KB. */
-		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_32K   UINT32_C(0x3)
-	/* Page size is 64KB. */
-		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_64K   UINT32_C(0x4)
-	/* Page size is 128KB. */
-		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_128K  UINT32_C(0x5)
-	/* Page size is 256KB. */
-		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_256K  UINT32_C(0x6)
-	/* Page size is 512KB. */
-		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_512K  UINT32_C(0x7)
-	/* Page size is 1MB. */
-		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_1M	UINT32_C(0x8)
-	/* Page size is 2MB. */
-		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_2M	UINT32_C(0x9)
-	/* Page size is 4MB. */
-		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_4M	UINT32_C(0xa)
-	/* Page size is 8MB. */
-		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_8M	UINT32_C(0xb)
-	/* Page size is 16MB. */
-		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_16M   UINT32_C(0xc)
-	/* Page size is 32MB. */
-		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_32M   UINT32_C(0xd)
-	/* Page size is 64MB. */
-		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_64M   UINT32_C(0xe)
-	/* Page size is 128MB. */
-		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_128M  UINT32_C(0xf)
-	/* Page size is 256MB. */
-		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_256M  UINT32_C(0x10)
-	/* Page size is 512MB. */
-		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_512M  UINT32_C(0x11)
-	/* Page size is 1GB. */
-		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_1G	UINT32_C(0x12)
-	/* Page size is 2GB. */
-		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_2G	UINT32_C(0x13)
-	/* Page size is 4GB. */
-		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_4G	UINT32_C(0x14)
-	/* Page size is 8GB. */
-		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_8G	UINT32_C(0x15)
-	/* Page size is 16GB. */
-		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_16G   UINT32_C(0x16)
-	/* Page size is 32GB. */
-		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_32G   UINT32_C(0x17)
-	/* Page size is 64GB. */
-		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_64G   UINT32_C(0x18)
-	/* Page size is 128GB. */
-		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_128G  UINT32_C(0x19)
-	/* Page size is 256GB. */
-		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_256G  UINT32_C(0x1a)
-	/* Page size is 512GB. */
-		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_512G  UINT32_C(0x1b)
-	/* Page size is 1TB. */
-		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_1T	UINT32_C(0x1c)
-	/* Page size is 2TB. */
-		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_2T	UINT32_C(0x1d)
-	/* Page size is 4TB. */
-		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_4T	UINT32_C(0x1e)
-	/* Page size is 8TB. */
-		#define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_8T	UINT32_C(0x1f)
-		#define SQ_FR_PMR_PAGE_SIZE_LOG_LAST	SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_8T
-	/* Indicate the MR is ZBVA (Zero Base VA) */
-	#define SQ_FR_PMR_ZERO_BASED		UINT32_C(0x20)
+	#define NQ_SRQ_EVENT_TOGGLE_MASK   UINT32_C(0xc0)
+	#define NQ_SRQ_EVENT_TOGGLE_SFT	6
 	/*
-	 * Local Key; 24 msb of the key are used to index the MRW
-	 * table, 8 lsb are assigned to the 8 bit key_lsb field in
-	 * the MRWC.
+	 * This value define what type of async event has occurred
+	 * on the SRQ.
 	 */
-	uint32_t	l_key;
-	/* Length in bytes of registered MR */
-	uint8_t	length[5];
-	uint8_t	reserved8_1;
-	uint8_t	reserved8_2;
-	uint8_t	numlevels_pbl_page_size_log;
-	/* PBL page size. 0 for 4KB page size, ... to 8TB. */
-	#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_MASK	UINT32_C(0x1f)
-	#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_SFT	0
-	/* Page size is 4KB. */
-		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_4K	UINT32_C(0x0)
-	/* Page size is 8KB. */
-		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_8K	UINT32_C(0x1)
-	/* Page size is 16KB. */
-		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_16K   UINT32_C(0x2)
-	/* Page size is 32KB. */
-		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_32K   UINT32_C(0x3)
-	/* Page size is 64KB. */
-		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_64K   UINT32_C(0x4)
-	/* Page size is 128KB. */
-		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_128K  UINT32_C(0x5)
-	/* Page size is 256KB. */
-		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_256K  UINT32_C(0x6)
-	/* Page size is 512KB. */
-		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_512K  UINT32_C(0x7)
-	/* Page size is 1MB. */
-		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_1M	UINT32_C(0x8)
-	/* Page size is 2MB. */
-		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_2M	UINT32_C(0x9)
-	/* Page size is 4MB. */
-		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_4M	UINT32_C(0xa)
-	/* Page size is 8MB. */
-		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_8M	UINT32_C(0xb)
-	/* Page size is 16MB. */
-		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_16M   UINT32_C(0xc)
-	/* Page size is 32MB. */
-		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_32M   UINT32_C(0xd)
-	/* Page size is 64MB. */
-		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_64M   UINT32_C(0xe)
-	/* Page size is 128MB. */
-		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_128M  UINT32_C(0xf)
-	/* Page size is 256MB. */
-		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_256M  UINT32_C(0x10)
-	/* Page size is 512MB. */
-		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_512M  UINT32_C(0x11)
-	/* Page size is 1GB. */
-		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_1G	UINT32_C(0x12)
-	/* Page size is 2GB. */
-		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_2G	UINT32_C(0x13)
-	/* Page size is 4GB. */
-		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_4G	UINT32_C(0x14)
-	/* Page size is 8GB. */
-		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_8G	UINT32_C(0x15)
-	/* Page size is 16GB. */
-		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_16G   UINT32_C(0x16)
-	/* Page size is 32GB. */
-		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_32G   UINT32_C(0x17)
-	/* Page size is 64GB. */
-		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_64G   UINT32_C(0x18)
-	/* Page size is 128GB. */
-		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_128G  UINT32_C(0x19)
-	/* Page size is 256GB. */
-		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_256G  UINT32_C(0x1a)
-	/* Page size is 512GB. */
-		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_512G  UINT32_C(0x1b)
-	/* Page size is 1TB. */
-		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_1T	UINT32_C(0x1c)
-	/* Page size is 2TB. */
-		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_2T	UINT32_C(0x1d)
-	/* Page size is 4TB. */
-		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_4T	UINT32_C(0x1e)
-	/* Page size is 8TB. */
-		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_8T	UINT32_C(0x1f)
-		#define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_LAST	SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_8T
-	/* Number of levels of PBL for translation */
-	#define SQ_FR_PMR_NUMLEVELS_MASK		UINT32_C(0xc0)
-	#define SQ_FR_PMR_NUMLEVELS_SFT		6
+	uint8_t	event;
+	/* The threshold event has occurred on the specified SRQ. */
+	#define NQ_SRQ_EVENT_EVENT_SRQ_THRESHOLD_EVENT UINT32_C(0x1)
+	#define NQ_SRQ_EVENT_EVENT_LAST		NQ_SRQ_EVENT_EVENT_SRQ_THRESHOLD_EVENT
+	uint16_t	reserved16;
 	/*
-	 * A zero level PBL means that the VA is the physical address used
-	 * for the operation.  No translation is done by the PTU.
+	 * This is the SRQ handle value for the queue that has
+	 * reached it's event threshold. This field carries the
+	 * lower 32b of the value.
 	 */
-		#define SQ_FR_PMR_NUMLEVELS_PHYSICAL	(UINT32_C(0x0) << 6)
+	uint32_t	srq_handle_low;
+	uint32_t	v;
 	/*
-	 * A one layer translation is provided between the logical and
-	 * physical address.  The PBL points to a physical page that contains
-	 * PBE values that point to actual pg_size physical pages.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-		#define SQ_FR_PMR_NUMLEVELS_LAYER1		(UINT32_C(0x1) << 6)
+	#define NQ_SRQ_EVENT_V	UINT32_C(0x1)
 	/*
-	 * A two layer translation is provided between the logical and
-	 * physical address. The PBL points to a physical page that contains
-	 * PDE values that in turn point to pbl_pg_size physical pages that contain
-	 * PBE values that point to actual physical pages.
+	 * This is the SRQ handle value for the queue that has
+	 * reached it's event threshold. This field carries the
+	 * upper 32b of the value.
 	 */
-		#define SQ_FR_PMR_NUMLEVELS_LAYER2		(UINT32_C(0x2) << 6)
-		#define SQ_FR_PMR_NUMLEVELS_LAST		SQ_FR_PMR_NUMLEVELS_LAYER2
-	/* Pointer to the PBL, or PDL depending on number of levels */
-	uint64_t	pblptr;
-	/* Local Virtual Address */
-	uint64_t	va;
-	/* The data field for FR-PMR is not used. */
-	uint32_t	data[24];
-} sq_fr_pmr_t, *psq_fr_pmr_t;
+	uint32_t	srq_handle_high;
+} nq_srq_event_t, *pnq_srq_event_t;
 
-/* FR-PMR SQ WQE header. */
-/* sq_fr_pmr_hdr (size:256b/32B) */
+/* DBQ Async Event Notification */
+/* nq_dbq_event (size:128b/16B) */
 
-typedef struct sq_fr_pmr_hdr {
-	/* This field defines the type of SQ WQE. */
-	uint8_t	wqe_type;
-	/*
-	 * FR-PMR (Fast Register Physical Memory Region)
-	 *
-	 * Allowed only on reliable connection (RC) SQs.
-	 */
-	#define SQ_FR_PMR_HDR_WQE_TYPE_FR_PMR UINT32_C(0xd)
-	#define SQ_FR_PMR_HDR_WQE_TYPE_LAST  SQ_FR_PMR_HDR_WQE_TYPE_FR_PMR
-	uint8_t	flags;
-	/*
-	 * Set if completion signaling is requested. If this bit is
-	 * 0, and the SQ is configured to support Unsignaled
-	 * completion the controller should not generate a CQE
-	 * unless there was an error. This refers to CQE on the
-	 * sender side (se_flag refers to the receiver side)
-	 */
-	#define SQ_FR_PMR_HDR_FLAGS_SIGNAL_COMP		UINT32_C(0x1)
-	/*
-	 * Indication to complete all previous RDMA Read or Atomic
-	 * WQEs on the SQ before executing this WQE
-	 */
-	#define SQ_FR_PMR_HDR_FLAGS_RD_OR_ATOMIC_FENCE	UINT32_C(0x2)
-	/*
-	 * Unconditional fence. Indication to complete all previous
-	 * SQ's WQEs before executing this WQE.
-	 */
-	#define SQ_FR_PMR_HDR_FLAGS_UC_FENCE		UINT32_C(0x4)
-	/* Not Applicable for FR_PMR. Nothing is sent */
-	#define SQ_FR_PMR_HDR_FLAGS_SE			UINT32_C(0x8)
-	/* NA */
-	#define SQ_FR_PMR_HDR_FLAGS_INLINE		UINT32_C(0x10)
+typedef struct nq_dbq_event {
+	uint8_t	type;
 	/*
-	 * This flag is not applicable and should be 0 for a local memory
-	 * operation WQE.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B
+	 * records.
 	 */
-	#define SQ_FR_PMR_HDR_FLAGS_WQE_TS_EN		UINT32_C(0x20)
+	#define NQ_DBQ_EVENT_TYPE_MASK	UINT32_C(0x3f)
+	#define NQ_DBQ_EVENT_TYPE_SFT	0
+	/* DBQ Threshold Event */
+		#define NQ_DBQ_EVENT_TYPE_DBQ_EVENT  UINT32_C(0x34)
+		#define NQ_DBQ_EVENT_TYPE_LAST	NQ_DBQ_EVENT_TYPE_DBQ_EVENT
+	/* This value define what type of action the driver should take. */
+	uint8_t	event;
 	/*
-	 * When set to '1', this operation will cause a trace capture in
-	 * each block it passes through.
+	 * The driver should start writing dummy values to the
+	 * the doorbell in an attempt to consume all the PCIE
+	 * posted write resources and prevent doorbell overflow.
 	 */
-	#define SQ_FR_PMR_HDR_FLAGS_DEBUG_TRACE		UINT32_C(0x40)
+	#define NQ_DBQ_EVENT_EVENT_DBQ_THRESHOLD_EVENT UINT32_C(0x1)
+	#define NQ_DBQ_EVENT_EVENT_LAST		NQ_DBQ_EVENT_EVENT_DBQ_THRESHOLD_EVENT
+	uint16_t	db_pfid;
 	/*
-	 * This is the new access control for the MR.  '1' means
-	 * the operation is allowed.  '0' means operation is
-	 * not allowed.
+	 * This is the PFID of function that wrote the doorbell that
+	 * crossed the async event threshold.
 	 */
-	uint8_t	access_cntl;
-	/* Local Write Access */
-	#define SQ_FR_PMR_HDR_ACCESS_CNTL_LOCAL_WRITE	UINT32_C(0x1)
-	/* Remote Read Access */
-	#define SQ_FR_PMR_HDR_ACCESS_CNTL_REMOTE_READ	UINT32_C(0x2)
-	/* Remote Write Access */
-	#define SQ_FR_PMR_HDR_ACCESS_CNTL_REMOTE_WRITE	UINT32_C(0x4)
-	/* Remote Atomic Access */
-	#define SQ_FR_PMR_HDR_ACCESS_CNTL_REMOTE_ATOMIC	UINT32_C(0x8)
-	/* Window Binding Allowed */
-	#define SQ_FR_PMR_HDR_ACCESS_CNTL_WINDOW_BIND	UINT32_C(0x10)
-	uint8_t	zero_based_page_size_log;
-	/* Page size. 0 for 4KB page size, ... to 8TB. */
-	#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_MASK	UINT32_C(0x1f)
-	#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_SFT	0
-	/* Page size is 4KB. */
-		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_4K	UINT32_C(0x0)
-	/* Page size is 8KB. */
-		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_8K	UINT32_C(0x1)
-	/* Page size is 16KB. */
-		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_16K   UINT32_C(0x2)
-	/* Page size is 32KB. */
-		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_32K   UINT32_C(0x3)
-	/* Page size is 64KB. */
-		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_64K   UINT32_C(0x4)
-	/* Page size is 128KB. */
-		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_128K  UINT32_C(0x5)
-	/* Page size is 256KB. */
-		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_256K  UINT32_C(0x6)
-	/* Page size is 512KB. */
-		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_512K  UINT32_C(0x7)
-	/* Page size is 1MB. */
-		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_1M	UINT32_C(0x8)
-	/* Page size is 2MB. */
-		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_2M	UINT32_C(0x9)
-	/* Page size is 4MB. */
-		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_4M	UINT32_C(0xa)
-	/* Page size is 8MB. */
-		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_8M	UINT32_C(0xb)
-	/* Page size is 16MB. */
-		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_16M   UINT32_C(0xc)
-	/* Page size is 32MB. */
-		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_32M   UINT32_C(0xd)
-	/* Page size is 64MB. */
-		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_64M   UINT32_C(0xe)
-	/* Page size is 128MB. */
-		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_128M  UINT32_C(0xf)
-	/* Page size is 256MB. */
-		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_256M  UINT32_C(0x10)
-	/* Page size is 512MB. */
-		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_512M  UINT32_C(0x11)
-	/* Page size is 1GB. */
-		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_1G	UINT32_C(0x12)
-	/* Page size is 2GB. */
-		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_2G	UINT32_C(0x13)
-	/* Page size is 4GB. */
-		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_4G	UINT32_C(0x14)
-	/* Page size is 8GB. */
-		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_8G	UINT32_C(0x15)
-	/* Page size is 16GB. */
-		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_16G   UINT32_C(0x16)
-	/* Page size is 32GB. */
-		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_32G   UINT32_C(0x17)
-	/* Page size is 64GB. */
-		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_64G   UINT32_C(0x18)
-	/* Page size is 128GB. */
-		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_128G  UINT32_C(0x19)
-	/* Page size is 256GB. */
-		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_256G  UINT32_C(0x1a)
-	/* Page size is 512GB. */
-		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_512G  UINT32_C(0x1b)
-	/* Page size is 1TB. */
-		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_1T	UINT32_C(0x1c)
-	/* Page size is 2TB. */
-		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_2T	UINT32_C(0x1d)
-	/* Page size is 4TB. */
-		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_4T	UINT32_C(0x1e)
-	/* Page size is 8TB. */
-		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_8T	UINT32_C(0x1f)
-		#define SQ_FR_PMR_HDR_PAGE_SIZE_LOG_LAST	SQ_FR_PMR_HDR_PAGE_SIZE_LOG_PGSZ_8T
-	/* Indicate the MR is ZBVA (Zero Base VA) */
-	#define SQ_FR_PMR_HDR_ZERO_BASED		UINT32_C(0x20)
+	#define NQ_DBQ_EVENT_DB_PFID_MASK UINT32_C(0xf)
+	#define NQ_DBQ_EVENT_DB_PFID_SFT 0
+	uint32_t	db_dpi;
 	/*
-	 * Local Key; 24 msb of the key are used to index the MRW
-	 * table, 8 lsb are assigned to the 8 bit key_lsb field in
-	 * the MRWC.
+	 * This is the DPI of the doorbell write that crossed
+	 * the async event threshold.
 	 */
-	uint32_t	l_key;
-	/* Length in bytes of registered MR */
-	uint8_t	length[5];
-	uint8_t	reserved8_1;
-	uint8_t	reserved8_2;
-	uint8_t	numlevels_pbl_page_size_log;
-	/* PBL page size. 0 for 4KB page size, ... to 8TB. */
-	#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_MASK	UINT32_C(0x1f)
-	#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_SFT	0
-	/* Page size is 4KB. */
-		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_4K	UINT32_C(0x0)
-	/* Page size is 8KB. */
-		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_8K	UINT32_C(0x1)
-	/* Page size is 16KB. */
-		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_16K   UINT32_C(0x2)
-	/* Page size is 32KB. */
-		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_32K   UINT32_C(0x3)
-	/* Page size is 64KB. */
-		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_64K   UINT32_C(0x4)
-	/* Page size is 128KB. */
-		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_128K  UINT32_C(0x5)
-	/* Page size is 256KB. */
-		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_256K  UINT32_C(0x6)
-	/* Page size is 512KB. */
-		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_512K  UINT32_C(0x7)
-	/* Page size is 1MB. */
-		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_1M	UINT32_C(0x8)
-	/* Page size is 2MB. */
-		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_2M	UINT32_C(0x9)
-	/* Page size is 4MB. */
-		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_4M	UINT32_C(0xa)
-	/* Page size is 8MB. */
-		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_8M	UINT32_C(0xb)
-	/* Page size is 16MB. */
-		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_16M   UINT32_C(0xc)
-	/* Page size is 32MB. */
-		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_32M   UINT32_C(0xd)
-	/* Page size is 64MB. */
-		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_64M   UINT32_C(0xe)
-	/* Page size is 128MB. */
-		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_128M  UINT32_C(0xf)
-	/* Page size is 256MB. */
-		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_256M  UINT32_C(0x10)
-	/* Page size is 512MB. */
-		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_512M  UINT32_C(0x11)
-	/* Page size is 1GB. */
-		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_1G	UINT32_C(0x12)
-	/* Page size is 2GB. */
-		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_2G	UINT32_C(0x13)
-	/* Page size is 4GB. */
-		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_4G	UINT32_C(0x14)
-	/* Page size is 8GB. */
-		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_8G	UINT32_C(0x15)
-	/* Page size is 16GB. */
-		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_16G   UINT32_C(0x16)
-	/* Page size is 32GB. */
-		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_32G   UINT32_C(0x17)
-	/* Page size is 64GB. */
-		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_64G   UINT32_C(0x18)
-	/* Page size is 128GB. */
-		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_128G  UINT32_C(0x19)
-	/* Page size is 256GB. */
-		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_256G  UINT32_C(0x1a)
-	/* Page size is 512GB. */
-		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_512G  UINT32_C(0x1b)
-	/* Page size is 1TB. */
-		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_1T	UINT32_C(0x1c)
-	/* Page size is 2TB. */
-		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_2T	UINT32_C(0x1d)
-	/* Page size is 4TB. */
-		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_4T	UINT32_C(0x1e)
-	/* Page size is 8TB. */
-		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_8T	UINT32_C(0x1f)
-		#define SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_LAST	SQ_FR_PMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_8T
-	/* Number of levels of PBL for translation */
-	#define SQ_FR_PMR_HDR_NUMLEVELS_MASK		UINT32_C(0xc0)
-	#define SQ_FR_PMR_HDR_NUMLEVELS_SFT		6
+	#define NQ_DBQ_EVENT_DB_DPI_MASK UINT32_C(0xfffff)
+	#define NQ_DBQ_EVENT_DB_DPI_SFT 0
+	uint32_t	v;
 	/*
-	 * A zero level PBL means that the VA is the physical address used
-	 * for the operation.  No translation is done by the PTU.
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-		#define SQ_FR_PMR_HDR_NUMLEVELS_PHYSICAL	(UINT32_C(0x0) << 6)
+	#define NQ_DBQ_EVENT_V	UINT32_C(0x1)
+	uint32_t	db_type_db_xid;
 	/*
-	 * A one layer translation is provided between the logical and
-	 * physical address.  The PBL points to a physical page that contains
-	 * PBE values that point to actual pg_size physical pages.
+	 * DB 'XID' field from doorbell that crossed the async event
+	 * threshold. This is a QPID, SID, or CID, depending on
+	 * the db_type field.
 	 */
-		#define SQ_FR_PMR_HDR_NUMLEVELS_LAYER1		(UINT32_C(0x1) << 6)
+	#define NQ_DBQ_EVENT_DB_XID_MASK UINT32_C(0xfffff)
+	#define NQ_DBQ_EVENT_DB_XID_SFT  0
 	/*
-	 * A two layer translation is provided between the logical and
-	 * physical address. The PBL points to a physical page that contains
-	 * PDE values that in turn point to pbl_pg_size physical pages that contain
-	 * PBE values that point to actual physical pages.
+	 * DB 'type' field from doorbell that crossed the async event
+	 * threshold.
 	 */
-		#define SQ_FR_PMR_HDR_NUMLEVELS_LAYER2		(UINT32_C(0x2) << 6)
-		#define SQ_FR_PMR_HDR_NUMLEVELS_LAST		SQ_FR_PMR_HDR_NUMLEVELS_LAYER2
-	/* Pointer to the PBL, or PDL depending on number of levels */
-	uint64_t	pblptr;
-	/* Local Virtual Address */
-	uint64_t	va;
-} sq_fr_pmr_hdr_t, *psq_fr_pmr_hdr_t;
+	#define NQ_DBQ_EVENT_DB_TYPE_MASK UINT32_C(0xf0000000)
+	#define NQ_DBQ_EVENT_DB_TYPE_SFT 28
+} nq_dbq_event_t, *pnq_dbq_event_t;
 
-/* FR-PPMR SQ WQE */
-/* sq_fr_ppmr (size:1024b/128B) */
+/*
+ * This completion indicates that the NQ Reassign doorbell has been
+ * executed by the CQ processing block and no further NQE will arrive
+ * for this CQ on this NQ.
+ */
+/* nq_reassign (size:128b/16B) */
 
-typedef struct sq_fr_ppmr {
-	/* This field defines the type of SQ WQE. */
-	uint8_t	wqe_type;
+typedef struct nq_reassign {
+	uint16_t	type;
 	/*
-	 * FR-PPMR (Fast Register Proxy Physical Memory Region)
-	 *
-	 * Allowed only on reliable connection (RC) SQs.
+	 * This field indicates the exact type of the completion.
+	 * By convention, the LSB identifies the length of the
+	 * record in 16B units. Even values indicate 16B
+	 * records. Odd values indicate 32B records.
 	 */
-	#define SQ_FR_PPMR_WQE_TYPE_FR_PPMR UINT32_C(0xf)
-	#define SQ_FR_PPMR_WQE_TYPE_LAST   SQ_FR_PPMR_WQE_TYPE_FR_PPMR
-	uint8_t	flags;
+	#define NQ_REASSIGN_TYPE_MASK	UINT32_C(0x3f)
+	#define NQ_REASSIGN_TYPE_SFT	0
+	/* NQ Reassign Notification */
+		#define NQ_REASSIGN_TYPE_NQ_REASSIGN  UINT32_C(0x3c)
+		#define NQ_REASSIGN_TYPE_LAST	NQ_REASSIGN_TYPE_NQ_REASSIGN
+	uint16_t	reserved16;
 	/*
-	 * Set if completion signaling is requested. If this bit is
-	 * 0, and the SQ is configured to support Unsignaled
-	 * completion the controller should not generate a CQE
-	 * unless there was an error. This refers to CQE on the
-	 * sender side (se_flag refers to the receiver side)
+	 * This is an application level ID used to identify the
+	 * CQ. This field carries the lower 32b of the value.
 	 */
-	#define SQ_FR_PPMR_FLAGS_SIGNAL_COMP		UINT32_C(0x1)
+	uint32_t	cq_handle_low;
+	uint32_t	v;
 	/*
-	 * Indication to complete all previous RDMA Read or Atomic
-	 * WQEs on the SQ before executing this WQE
+	 * This value is written by the NIC such that it will be different
+	 * for each pass through the completion queue. The even passes
+	 * will write 1. The odd passes will write 0.
 	 */
-	#define SQ_FR_PPMR_FLAGS_RD_OR_ATOMIC_FENCE	UINT32_C(0x2)
+	#define NQ_REASSIGN_V	UINT32_C(0x1)
 	/*
-	 * Unconditional fence. Indication to complete all previous
-	 * SQ's WQEs before executing this WQE.
+	 * This is an application level ID used to identify the
+	 * CQ. This field carries the upper 32b of the value.
 	 */
-	#define SQ_FR_PPMR_FLAGS_UC_FENCE		UINT32_C(0x4)
-	/* Not Applicable for FR_PPMR. Nothing is sent */
-	#define SQ_FR_PPMR_FLAGS_SE			UINT32_C(0x8)
-	/* NA */
-	#define SQ_FR_PPMR_FLAGS_INLINE		UINT32_C(0x10)
+	uint32_t	cq_handle_high;
+} nq_reassign_t, *pnq_reassign_t;
+
+/* Input Read Request Queue (IRRQ) Message */
+/* xrrq_irrq (size:256b/32B) */
+
+typedef struct xrrq_irrq {
+	uint16_t	credits_type;
+	/* Type indication */
+	#define XRRQ_IRRQ_TYPE	UINT32_C(0x1)
+	/* RDMA Read */
+		#define XRRQ_IRRQ_TYPE_READ_REQ	UINT32_C(0x0)
+	/* Atomic */
+		#define XRRQ_IRRQ_TYPE_ATOMIC_REQ  UINT32_C(0x1)
+		#define XRRQ_IRRQ_TYPE_LAST	XRRQ_IRRQ_TYPE_ATOMIC_REQ
 	/*
-	 * This flag is not applicable and should be 0 for a local memory
-	 * operation WQE.
+	 * The credit code calculated by Rx path when receiving the
+	 * request. It will be placed in the syndrome credit code with
+	 * the acks on first and last response.
 	 */
-	#define SQ_FR_PPMR_FLAGS_WQE_TS_EN		UINT32_C(0x20)
+	#define XRRQ_IRRQ_CREDITS_MASK   UINT32_C(0xf800)
+	#define XRRQ_IRRQ_CREDITS_SFT	11
+	uint16_t	reserved16;
+	uint32_t	reserved32;
+	uint32_t	psn;
+	/* The PSN of the outstanding incoming request */
+	#define XRRQ_IRRQ_PSN_MASK UINT32_C(0xffffff)
+	#define XRRQ_IRRQ_PSN_SFT 0
+	uint32_t	msn;
 	/*
-	 * When set to '1', this operation will cause a trace capture in
-	 * each block it passes through.
+	 * The value of QPC.pending_ack_msn after it is incremented as a
+	 * result of receiving the read/atomic request. IRRQ.msn-1 will
+	 * be placed in the MSN field of the first response and IRRQ.msn
+	 * will placed in the MSN field of the last or only response.
 	 */
-	#define SQ_FR_PPMR_FLAGS_DEBUG_TRACE		UINT32_C(0x40)
+	#define XRRQ_IRRQ_MSN_MASK UINT32_C(0xffffff)
+	#define XRRQ_IRRQ_MSN_SFT 0
 	/*
-	 * This is the new access control for the MR.  '1' means
-	 * the operation is allowed.  '0' means operation is
-	 * not allowed.
+	 * Virtual address on local host for RDMA READ
+	 *
+	 * In case of duplicate Atomic, the VA is not required to
+	 * be validated, only the PSN is, thus this field is used
+	 * to store the value returned in the Ack to the atomic
+	 * request, and if duplicate arrives, this value is used
+	 * again for resending the ack.
 	 */
-	uint8_t	access_cntl;
-	/* Local Write Access */
-	#define SQ_FR_PPMR_ACCESS_CNTL_LOCAL_WRITE	UINT32_C(0x1)
-	/* Remote Read Access */
-	#define SQ_FR_PPMR_ACCESS_CNTL_REMOTE_READ	UINT32_C(0x2)
-	/* Remote Write Access */
-	#define SQ_FR_PPMR_ACCESS_CNTL_REMOTE_WRITE	UINT32_C(0x4)
-	/* Remote Atomic Access */
-	#define SQ_FR_PPMR_ACCESS_CNTL_REMOTE_ATOMIC	UINT32_C(0x8)
-	/* Window Binding Allowed */
-	#define SQ_FR_PPMR_ACCESS_CNTL_WINDOW_BIND	UINT32_C(0x10)
-	uint8_t	zero_based_page_size_log;
-	/* Page size. 0 for 4KB page size, ... to 8TB. */
-	#define SQ_FR_PPMR_PAGE_SIZE_LOG_MASK	UINT32_C(0x1f)
-	#define SQ_FR_PPMR_PAGE_SIZE_LOG_SFT	0
-	/* Page size is 4KB. */
-		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_4K	UINT32_C(0x0)
-	/* Page size is 8KB. */
-		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_8K	UINT32_C(0x1)
-	/* Page size is 16KB. */
-		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_16K   UINT32_C(0x2)
-	/* Page size is 32KB. */
-		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_32K   UINT32_C(0x3)
-	/* Page size is 64KB. */
-		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_64K   UINT32_C(0x4)
-	/* Page size is 128KB. */
-		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_128K  UINT32_C(0x5)
-	/* Page size is 256KB. */
-		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_256K  UINT32_C(0x6)
-	/* Page size is 512KB. */
-		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_512K  UINT32_C(0x7)
-	/* Page size is 1MB. */
-		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_1M	UINT32_C(0x8)
-	/* Page size is 2MB. */
-		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_2M	UINT32_C(0x9)
-	/* Page size is 4MB. */
-		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_4M	UINT32_C(0xa)
-	/* Page size is 8MB. */
-		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_8M	UINT32_C(0xb)
-	/* Page size is 16MB. */
-		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_16M   UINT32_C(0xc)
-	/* Page size is 32MB. */
-		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_32M   UINT32_C(0xd)
-	/* Page size is 64MB. */
-		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_64M   UINT32_C(0xe)
-	/* Page size is 128MB. */
-		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_128M  UINT32_C(0xf)
-	/* Page size is 256MB. */
-		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_256M  UINT32_C(0x10)
-	/* Page size is 512MB. */
-		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_512M  UINT32_C(0x11)
-	/* Page size is 1GB. */
-		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_1G	UINT32_C(0x12)
-	/* Page size is 2GB. */
-		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_2G	UINT32_C(0x13)
-	/* Page size is 4GB. */
-		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_4G	UINT32_C(0x14)
-	/* Page size is 8GB. */
-		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_8G	UINT32_C(0x15)
-	/* Page size is 16GB. */
-		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_16G   UINT32_C(0x16)
-	/* Page size is 32GB. */
-		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_32G   UINT32_C(0x17)
-	/* Page size is 64GB. */
-		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_64G   UINT32_C(0x18)
-	/* Page size is 128GB. */
-		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_128G  UINT32_C(0x19)
-	/* Page size is 256GB. */
-		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_256G  UINT32_C(0x1a)
-	/* Page size is 512GB. */
-		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_512G  UINT32_C(0x1b)
-	/* Page size is 1TB. */
-		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_1T	UINT32_C(0x1c)
-	/* Page size is 2TB. */
-		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_2T	UINT32_C(0x1d)
-	/* Page size is 4TB. */
-		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_4T	UINT32_C(0x1e)
-	/* Page size is 8TB. */
-		#define SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_8T	UINT32_C(0x1f)
-		#define SQ_FR_PPMR_PAGE_SIZE_LOG_LAST	SQ_FR_PPMR_PAGE_SIZE_LOG_PGSZ_8T
-	/* Indicate the MR is ZBVA (Zero Base VA) */
-	#define SQ_FR_PPMR_ZERO_BASED		UINT32_C(0x20)
+	uint64_t	va_or_atomic_result;
+	/* The key to the MR/W in the request */
+	uint32_t	rdma_r_key;
 	/*
-	 * Local Key; 24 msb of the key are used to index the MRW
-	 * table, 8 lsb are assigned to the 8 bit key_lsb field in
-	 * the MRWC.
+	 * Length in bytes of the data requested. Length must be 8 if type is
+	 * atomic.
 	 */
-	uint32_t	l_key;
-	/* Length in bytes of registered MR */
 	uint32_t	length;
-	/* Sets the proxy_vfid field of the physical memory region. */
-	uint16_t	proxy_vfid;
-	/* Sets the proxy_pfid field of the physical memory region. */
-	uint8_t	proxy_pfid;
-	uint8_t	numlevels_pbl_page_size_log;
-	/* PBL page size. 0 for 4KB page size, ... to 8TB. */
-	#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_MASK	UINT32_C(0x1f)
-	#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_SFT	0
-	/* Page size is 4KB. */
-		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_4K	UINT32_C(0x0)
-	/* Page size is 8KB. */
-		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_8K	UINT32_C(0x1)
-	/* Page size is 16KB. */
-		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_16K   UINT32_C(0x2)
-	/* Page size is 32KB. */
-		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_32K   UINT32_C(0x3)
-	/* Page size is 64KB. */
-		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_64K   UINT32_C(0x4)
-	/* Page size is 128KB. */
-		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_128K  UINT32_C(0x5)
-	/* Page size is 256KB. */
-		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_256K  UINT32_C(0x6)
-	/* Page size is 512KB. */
-		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_512K  UINT32_C(0x7)
-	/* Page size is 1MB. */
-		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_1M	UINT32_C(0x8)
-	/* Page size is 2MB. */
-		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_2M	UINT32_C(0x9)
-	/* Page size is 4MB. */
-		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_4M	UINT32_C(0xa)
-	/* Page size is 8MB. */
-		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_8M	UINT32_C(0xb)
-	/* Page size is 16MB. */
-		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_16M   UINT32_C(0xc)
-	/* Page size is 32MB. */
-		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_32M   UINT32_C(0xd)
-	/* Page size is 64MB. */
-		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_64M   UINT32_C(0xe)
-	/* Page size is 128MB. */
-		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_128M  UINT32_C(0xf)
-	/* Page size is 256MB. */
-		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_256M  UINT32_C(0x10)
-	/* Page size is 512MB. */
-		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_512M  UINT32_C(0x11)
-	/* Page size is 1GB. */
-		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_1G	UINT32_C(0x12)
-	/* Page size is 2GB. */
-		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_2G	UINT32_C(0x13)
-	/* Page size is 4GB. */
-		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_4G	UINT32_C(0x14)
-	/* Page size is 8GB. */
-		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_8G	UINT32_C(0x15)
-	/* Page size is 16GB. */
-		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_16G   UINT32_C(0x16)
-	/* Page size is 32GB. */
-		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_32G   UINT32_C(0x17)
-	/* Page size is 64GB. */
-		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_64G   UINT32_C(0x18)
-	/* Page size is 128GB. */
-		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_128G  UINT32_C(0x19)
-	/* Page size is 256GB. */
-		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_256G  UINT32_C(0x1a)
-	/* Page size is 512GB. */
-		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_512G  UINT32_C(0x1b)
-	/* Page size is 1TB. */
-		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_1T	UINT32_C(0x1c)
-	/* Page size is 2TB. */
-		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_2T	UINT32_C(0x1d)
-	/* Page size is 4TB. */
-		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_4T	UINT32_C(0x1e)
-	/* Page size is 8TB. */
-		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_8T	UINT32_C(0x1f)
-		#define SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_LAST	SQ_FR_PPMR_PBL_PAGE_SIZE_LOG_PGSZ_8T
-	/* Sets the proxy_vf_valid field of the physical memory region. */
-	#define SQ_FR_PPMR_PROXY_VF_VALID		UINT32_C(0x20)
-	/* Number of levels of PBL for translation */
-	#define SQ_FR_PPMR_NUMLEVELS_MASK		UINT32_C(0xc0)
-	#define SQ_FR_PPMR_NUMLEVELS_SFT		6
+} xrrq_irrq_t, *pxrrq_irrq_t;
+
+/* Output Read Request Queue (ORRQ) Message */
+/* xrrq_orrq (size:256b/32B) */
+
+typedef struct xrrq_orrq {
+	uint16_t	num_sges_type;
+	/* Type indication */
+	#define XRRQ_ORRQ_TYPE	UINT32_C(0x1)
+	/* RDMA Read */
+		#define XRRQ_ORRQ_TYPE_READ_REQ	UINT32_C(0x0)
+	/* Atomic */
+		#define XRRQ_ORRQ_TYPE_ATOMIC_REQ  UINT32_C(0x1)
+		#define XRRQ_ORRQ_TYPE_LAST	XRRQ_ORRQ_TYPE_ATOMIC_REQ
 	/*
-	 * A zero level PBL means that the VA is the physical address used
-	 * for the operation.  No translation is done by the PTU.
+	 * Up to 6 SGEs. This value is 1 if type is atomic as one
+	 * SGE is required to store Atomic response result field. 2
+	 * more bits allocated for future growth.
+	 *
+	 * Note that, if num_sges is 1 for an RDMA Read request, then
+	 * the first_sge_phy_or_sing_sge_va, single_sge_l_key, and
+	 * single_sge_size fields will be populated from the single
+	 * SGE.
+	 *
+	 * If num_sges is 2 or more for an RDMA Read request, then
+	 * the first_sge_phy_or_sing_sge_va field carries the
+	 * physical address in host memory where the first sge is
+	 * stored. The single_sge_l_key and single_sge_size fields
+	 * are unused in this case.
+	 *
+	 * A special case is a zero-length, zero-sge RDMA read request
+	 * WQE. In this situation, num_sges will be 1. However,
+	 * first_sge_phy_or_sing_sge_va, single_sge_l_key, and
+	 * single_sge_size will all be populated with zeros.
 	 */
-		#define SQ_FR_PPMR_NUMLEVELS_PHYSICAL	(UINT32_C(0x0) << 6)
+	#define XRRQ_ORRQ_NUM_SGES_MASK  UINT32_C(0xf800)
+	#define XRRQ_ORRQ_NUM_SGES_SFT   11
+	uint16_t	reserved16;
 	/*
-	 * A one layer translation is provided between the logical and
-	 * physical address.  The PBL points to a physical page that contains
-	 * PBE values that point to actual pg_size physical pages.
+	 * Length in bytes of the data requested. Length must be 8 if type is
+	 * atomic.
 	 */
-		#define SQ_FR_PPMR_NUMLEVELS_LAYER1		(UINT32_C(0x1) << 6)
+	uint32_t	length;
+	uint32_t	psn;
+	/* The PSN of the outstanding outgoing request */
+	#define XRRQ_ORRQ_PSN_MASK UINT32_C(0xffffff)
+	#define XRRQ_ORRQ_PSN_SFT 0
+	uint32_t	end_psn;
 	/*
-	 * A two layer translation is provided between the logical and
-	 * physical address. The PBL points to a physical page that contains
-	 * PDE values that in turn point to pbl_pg_size physical pages that contain
-	 * PBE values that point to actual physical pages.
+	 * The expected last PSN on a response to this request where
+	 * an ack with response, rather than just response, should
+	 * arrive. If ack arrive with smaller PSN than end_psn then it
+	 * is considered a NAK.
 	 */
-		#define SQ_FR_PPMR_NUMLEVELS_LAYER2		(UINT32_C(0x2) << 6)
-		#define SQ_FR_PPMR_NUMLEVELS_LAST		SQ_FR_PPMR_NUMLEVELS_LAYER2
-	/* Pointer to the PBL, or PDL depending on number of levels */
-	uint64_t	pblptr;
-	/* Local Virtual Address */
-	uint64_t	va;
-	/* The data field for FR-PPMR is not used. */
-	uint32_t	data[24];
-} sq_fr_ppmr_t, *psq_fr_ppmr_t;
+	#define XRRQ_ORRQ_END_PSN_MASK UINT32_C(0xffffff)
+	#define XRRQ_ORRQ_END_PSN_SFT 0
+	/*
+	 * If num_sges == 1 this is the va of that SGE. Otherwise,
+	 * physical address to the first SGE specified by the WQE.
+	 * Points to the first SGE in the Request's WQE in the SQ.
+	 * It is assumed that WQE does not cross page boundaries!
+	 * Driver is responsible to enforce that. SGEs are 16B
+	 * aligned 0b0000 lsb added to get 64 bit address.
+	 */
+	uint64_t	first_sge_phy_or_sing_sge_va;
+	/* The L_Key of a single SGE if used */
+	uint32_t	single_sge_l_key;
+	/* The size in bytes of the single SGE if used */
+	uint32_t	single_sge_size;
+} xrrq_orrq_t, *pxrrq_orrq_t;
 
-/* FR-PPMR SQ WQE header. */
-/* sq_fr_ppmr_hdr (size:256b/32B) */
+/* Page Table Entry (PTE) */
+/* ptu_pte (size:64b/8B) */
 
-typedef struct sq_fr_ppmr_hdr {
-	/* This field defines the type of SQ WQE. */
-	uint8_t	wqe_type;
+typedef struct ptu_pte {
+	uint64_t	page_next_to_last_last_valid;
+	/*
+	 * This field indicates if the PTE is valid. A value of '0'
+	 * indicates that the page is not valid. A value of '1'
+	 * indicates that the page is valid. A reference to an
+	 * invalid page will return a PTU error.
+	 */
+	#define PTU_PTE_VALID		UINT32_C(0x1)
+	/*
+	 * This field is used only for "ring" PBLs that are used for
+	 * SQ, RQ, SRQ, or CQ structures. For all other PBL structures,
+	 * this bit should be zero. When this bit is '1', it indicates
+	 * that the page pointed to by this PTE is the last page in the
+	 * ring. A prefetch for the ring should use the first PTE in
+	 * the PBL.
+	 */
+	#define PTU_PTE_LAST		UINT32_C(0x2)
+	/*
+	 * This field is used only for "ring" PBLs that are used for
+	 * SQ, RQ, SRQ, or CQ structures. For all other PBL structures,
+	 * this bit should be zero. When this bit is '1', it indicates
+	 * that this is the next-to-last page of the PBL.
+	 */
+	#define PTU_PTE_NEXT_TO_LAST	UINT32_C(0x4)
+	/* These bits should be programmed to zero. */
+	#define PTU_PTE_UNUSED_MASK	UINT32_C(0xff8)
+	#define PTU_PTE_UNUSED_SFT	3
+	/*
+	 * This is the upper bits of the physical page controlled by
+	 * this PTE. If the page is larger than 4KB, then the unused
+	 * lower bits of the page address should be zero.
+	 */
+	#define PTU_PTE_PAGE_MASK	UINT32_C(0xfffffffffffff000)L
+	#define PTU_PTE_PAGE_SFT	12
+} ptu_pte_t, *pptu_pte_t;
+
+/* Page Directory Entry (PDE) */
+/* ptu_pde (size:64b/8B) */
+
+typedef struct ptu_pde {
+	uint64_t	page_valid;
+	/*
+	 * This field indicates if the PTE is valid. A value of '0'
+	 * indicates that the page is not valid. A value of '1'
+	 * indicates that the page is valid. A reference to an
+	 * invalid page will return a PTU error.
+	 */
+	#define PTU_PDE_VALID	UINT32_C(0x1)
+	/* These bits should be programmed to zero. */
+	#define PTU_PDE_UNUSED_MASK UINT32_C(0xffe)
+	#define PTU_PDE_UNUSED_SFT 1
+	/*
+	 * This is the upper bits of the physical page controlled by
+	 * this PTE. If the page is larger than 4KB, then the unused
+	 * lower bits of the page address should be zero.
+	 */
+	#define PTU_PDE_PAGE_MASK  UINT32_C(0xfffffffffffff000)L
+	#define PTU_PDE_PAGE_SFT   12
+} ptu_pde_t, *pptu_pde_t;
+
+/*
+ * This is the 64b doorbell format. The host writes this message
+ * format directly to byte offset 0 of the appropriate doorbell page.
+ */
+/* dbc_dbc (size:64b/8B) */
+
+typedef struct dbc_dbc {
+	uint32_t	index;
+	/*
+	 * This value is the index being written.
+	 *
+	 * For SQ, RQ, and SRQ, this is the producer index and the unit is
+	 * 16B of queue space for L2 path and for the Engine path. For RoCE
+	 * path there is a legacy mode with 128B unit size and a variable
+	 * size WQE mode with 16B unit size of queue space. This mode is
+	 * configured in the QP.
+	 *
+	 * For CQ this is the consumer index and the unit is 32B of queue
+	 * space for the RoCE/Engine path and the CQ index unit is 16B of
+	 * queue space for the L2 path.
+	 *
+	 * For NQ this is the consumer index and the unit is always 16B of
+	 * queue space.
+	 *
+	 * The index size is 24b for L2 and engine paths and 16b for the
+	 * RoCE path. Unused bits should be written as zero.
+	 */
+	#define DBC_DBC_INDEX_MASK UINT32_C(0xffffff)
+	#define DBC_DBC_INDEX_SFT  0
 	/*
-	 * FR-PPMR (Fast Register Proxy Physical Memory Region)
+	 * The epoch bit provides a frame of reference for the queue index.
+	 * S/W will toggle this bit in the doorbell each time index range is
+	 * wrapped. This allows the receiving HW block to more efficiently
+	 * detect out-of-order doorbells and to ignore the older doorbells.
+	 * Out-of-order doorbells occur normally during dropped doorbell
+	 * recovery.
+	 */
+	#define DBC_DBC_EPOCH	UINT32_C(0x1000000)
+	/*
+	 * The toggle value is used in CQ_ARMENA, CQ_ARMSE, CQ_ARMALL,
+	 * SRQ_ARMENA, SRQ_ARM, and CQ_CUTOFF_ACK doorbells to qualify the
+	 * doorbell as valid. This value should be taken from the latest
+	 * NQE or cutoff completion.
 	 *
-	 * Allowed only on reliable connection (RC) SQs.
+	 * Doorbells of the above types with the wrong toggle value will
+	 * be ignored. This is how old values in of backup doorbells
+	 * are ignored.
 	 */
-	#define SQ_FR_PPMR_HDR_WQE_TYPE_FR_PPMR UINT32_C(0xf)
-	#define SQ_FR_PPMR_HDR_WQE_TYPE_LAST   SQ_FR_PPMR_HDR_WQE_TYPE_FR_PPMR
-	uint8_t	flags;
+	#define DBC_DBC_TOGGLE_MASK UINT32_C(0x6000000)
+	#define DBC_DBC_TOGGLE_SFT 25
+	uint32_t	type_path_xid;
 	/*
-	 * Set if completion signaling is requested. If this bit is
-	 * 0, and the SQ is configured to support Unsignaled
-	 * completion the controller should not generate a CQE
-	 * unless there was an error. This refers to CQE on the
-	 * sender side (se_flag refers to the receiver side)
+	 * This value identifies the resource that the doorbell is intended
+	 * to notify.
+	 *
+	 * For SQ and RQ, this is the QPID. For SRQ, this is the SID. For
+	 * CQ, this is the CID. For NQ, this is the NID.
+	 *
+	 * Bits [19:16] of this values must be zero for a SID value.
 	 */
-	#define SQ_FR_PPMR_HDR_FLAGS_SIGNAL_COMP		UINT32_C(0x1)
+	#define DBC_DBC_XID_MASK	UINT32_C(0xfffff)
+	#define DBC_DBC_XID_SFT	0
 	/*
-	 * Indication to complete all previous RDMA Read or Atomic
-	 * WQEs on the SQ before executing this WQE
+	 * This value defines the intended doorbell path between RoCE and
+	 * L2.
 	 */
-	#define SQ_FR_PPMR_HDR_FLAGS_RD_OR_ATOMIC_FENCE	UINT32_C(0x2)
+	#define DBC_DBC_PATH_MASK	UINT32_C(0x3000000)
+	#define DBC_DBC_PATH_SFT	24
+	/* This is a RoCE doorbell message. */
+		#define DBC_DBC_PATH_ROCE	(UINT32_C(0x0) << 24)
+	/* This is a L2 doorbell message. */
+		#define DBC_DBC_PATH_L2		(UINT32_C(0x1) << 24)
+	/* Engine path doorbell. */
+		#define DBC_DBC_PATH_ENGINE	(UINT32_C(0x2) << 24)
+		#define DBC_DBC_PATH_LAST	DBC_DBC_PATH_ENGINE
 	/*
-	 * Unconditional fence. Indication to complete all previous
-	 * SQ's WQEs before executing this WQE.
+	 * This indicates it is valid doorbell update. It should be set for
+	 * each doorbell written to the chip and set when doorbell message is
+	 * written to the backup doorbell location. The bit should be cleared
+	 * in the backup doorbell location at time zero to indicate that the
+	 * backup doorbell has not yet been written.
 	 */
-	#define SQ_FR_PPMR_HDR_FLAGS_UC_FENCE		UINT32_C(0x4)
-	/* Not Applicable for FR_PPMR. Nothing is sent */
-	#define SQ_FR_PPMR_HDR_FLAGS_SE			UINT32_C(0x8)
-	/* NA */
-	#define SQ_FR_PPMR_HDR_FLAGS_INLINE		UINT32_C(0x10)
+	#define DBC_DBC_VALID		UINT32_C(0x4000000)
 	/*
-	 * This flag is not applicable and should be 0 for a local memory
-	 * operation WQE.
+	 * When this bit is set to one, the chip will capture debug
+	 * information for the doorbell ring. This is intended to only be
+	 * used on SQ doorbell rings.
 	 */
-	#define SQ_FR_PPMR_HDR_FLAGS_WQE_TS_EN		UINT32_C(0x20)
+	#define DBC_DBC_DEBUG_TRACE	UINT32_C(0x8000000)
+	/* This value identifies the type of doorbell being written. */
+	#define DBC_DBC_TYPE_MASK	UINT32_C(0xf0000000)
+	#define DBC_DBC_TYPE_SFT	28
 	/*
-	 * When set to '1', this operation will cause a trace capture in
-	 * each block it passes through.
+	 * This is a SQ producer index update. It indicates one or more
+	 * new entries have been written to the SQ for the QPID indicated
+	 * on the xID field. This type is valid for L2, RoCE and Engine
+	 * path.
 	 */
-	#define SQ_FR_PPMR_HDR_FLAGS_DEBUG_TRACE		UINT32_C(0x40)
+		#define DBC_DBC_TYPE_SQ		(UINT32_C(0x0) << 28)
 	/*
-	 * This is the new access control for the MR.  '1' means
-	 * the operation is allowed.  '0' means operation is
-	 * not allowed.
+	 * This is a RQ producer index update. It indicates one or more
+	 * new entries have been written to the RQ for the QPID indicated
+	 * on the xID field. This type is valid for RoCE path.
 	 */
-	uint8_t	access_cntl;
-	/* Local Write Access */
-	#define SQ_FR_PPMR_HDR_ACCESS_CNTL_LOCAL_WRITE	UINT32_C(0x1)
-	/* Remote Read Access */
-	#define SQ_FR_PPMR_HDR_ACCESS_CNTL_REMOTE_READ	UINT32_C(0x2)
-	/* Remote Write Access */
-	#define SQ_FR_PPMR_HDR_ACCESS_CNTL_REMOTE_WRITE	UINT32_C(0x4)
-	/* Remote Atomic Access */
-	#define SQ_FR_PPMR_HDR_ACCESS_CNTL_REMOTE_ATOMIC	UINT32_C(0x8)
-	/* Window Binding Allowed */
-	#define SQ_FR_PPMR_HDR_ACCESS_CNTL_WINDOW_BIND	UINT32_C(0x10)
-	uint8_t	zero_based_page_size_log;
-	/* Page size. 0 for 4KB page size, ... to 8TB. */
-	#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_MASK	UINT32_C(0x1f)
-	#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_SFT	0
-	/* Page size is 4KB. */
-		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_4K	UINT32_C(0x0)
-	/* Page size is 8KB. */
-		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_8K	UINT32_C(0x1)
-	/* Page size is 16KB. */
-		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_16K   UINT32_C(0x2)
-	/* Page size is 32KB. */
-		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_32K   UINT32_C(0x3)
-	/* Page size is 64KB. */
-		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_64K   UINT32_C(0x4)
-	/* Page size is 128KB. */
-		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_128K  UINT32_C(0x5)
-	/* Page size is 256KB. */
-		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_256K  UINT32_C(0x6)
-	/* Page size is 512KB. */
-		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_512K  UINT32_C(0x7)
-	/* Page size is 1MB. */
-		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_1M	UINT32_C(0x8)
-	/* Page size is 2MB. */
-		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_2M	UINT32_C(0x9)
-	/* Page size is 4MB. */
-		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_4M	UINT32_C(0xa)
-	/* Page size is 8MB. */
-		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_8M	UINT32_C(0xb)
-	/* Page size is 16MB. */
-		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_16M   UINT32_C(0xc)
-	/* Page size is 32MB. */
-		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_32M   UINT32_C(0xd)
-	/* Page size is 64MB. */
-		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_64M   UINT32_C(0xe)
-	/* Page size is 128MB. */
-		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_128M  UINT32_C(0xf)
-	/* Page size is 256MB. */
-		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_256M  UINT32_C(0x10)
-	/* Page size is 512MB. */
-		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_512M  UINT32_C(0x11)
-	/* Page size is 1GB. */
-		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_1G	UINT32_C(0x12)
-	/* Page size is 2GB. */
-		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_2G	UINT32_C(0x13)
-	/* Page size is 4GB. */
-		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_4G	UINT32_C(0x14)
-	/* Page size is 8GB. */
-		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_8G	UINT32_C(0x15)
-	/* Page size is 16GB. */
-		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_16G   UINT32_C(0x16)
-	/* Page size is 32GB. */
-		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_32G   UINT32_C(0x17)
-	/* Page size is 64GB. */
-		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_64G   UINT32_C(0x18)
-	/* Page size is 128GB. */
-		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_128G  UINT32_C(0x19)
-	/* Page size is 256GB. */
-		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_256G  UINT32_C(0x1a)
-	/* Page size is 512GB. */
-		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_512G  UINT32_C(0x1b)
-	/* Page size is 1TB. */
-		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_1T	UINT32_C(0x1c)
-	/* Page size is 2TB. */
-		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_2T	UINT32_C(0x1d)
-	/* Page size is 4TB. */
-		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_4T	UINT32_C(0x1e)
-	/* Page size is 8TB. */
-		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_8T	UINT32_C(0x1f)
-		#define SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_LAST	SQ_FR_PPMR_HDR_PAGE_SIZE_LOG_PGSZ_8T
-	/* Indicate the MR is ZBVA (Zero Base VA) */
-	#define SQ_FR_PPMR_HDR_ZERO_BASED		UINT32_C(0x20)
+		#define DBC_DBC_TYPE_RQ		(UINT32_C(0x1) << 28)
 	/*
-	 * Local Key; 24 msb of the key are used to index the MRW
-	 * table, 8 lsb are assigned to the 8 bit key_lsb field in
-	 * the MRWC.
+	 * This is a SRQ producer index update. It indicates one or more
+	 * new entries have been written to the SRQ for the SID indicated
+	 * on the xID field. This type is valid for L2 and RoCE path.
 	 */
-	uint32_t	l_key;
-	/* Length in bytes of registered MR */
-	uint32_t	length;
-	/* Sets the proxy_vfid field of the physical memory region. */
-	uint16_t	proxy_vfid;
-	/* Sets the proxy_pfid field of the physical memory region. */
-	uint8_t	proxy_pfid;
-	uint8_t	numlevels_pbl_page_size_log;
-	/* PBL page size. 0 for 4KB page size, ... to 8TB. */
-	#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_MASK	UINT32_C(0x1f)
-	#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_SFT	0
-	/* Page size is 4KB. */
-		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_4K	UINT32_C(0x0)
-	/* Page size is 8KB. */
-		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_8K	UINT32_C(0x1)
-	/* Page size is 16KB. */
-		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_16K   UINT32_C(0x2)
-	/* Page size is 32KB. */
-		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_32K   UINT32_C(0x3)
-	/* Page size is 64KB. */
-		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_64K   UINT32_C(0x4)
-	/* Page size is 128KB. */
-		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_128K  UINT32_C(0x5)
-	/* Page size is 256KB. */
-		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_256K  UINT32_C(0x6)
-	/* Page size is 512KB. */
-		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_512K  UINT32_C(0x7)
-	/* Page size is 1MB. */
-		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_1M	UINT32_C(0x8)
-	/* Page size is 2MB. */
-		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_2M	UINT32_C(0x9)
-	/* Page size is 4MB. */
-		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_4M	UINT32_C(0xa)
-	/* Page size is 8MB. */
-		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_8M	UINT32_C(0xb)
-	/* Page size is 16MB. */
-		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_16M   UINT32_C(0xc)
-	/* Page size is 32MB. */
-		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_32M   UINT32_C(0xd)
-	/* Page size is 64MB. */
-		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_64M   UINT32_C(0xe)
-	/* Page size is 128MB. */
-		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_128M  UINT32_C(0xf)
-	/* Page size is 256MB. */
-		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_256M  UINT32_C(0x10)
-	/* Page size is 512MB. */
-		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_512M  UINT32_C(0x11)
-	/* Page size is 1GB. */
-		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_1G	UINT32_C(0x12)
-	/* Page size is 2GB. */
-		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_2G	UINT32_C(0x13)
-	/* Page size is 4GB. */
-		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_4G	UINT32_C(0x14)
-	/* Page size is 8GB. */
-		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_8G	UINT32_C(0x15)
-	/* Page size is 16GB. */
-		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_16G   UINT32_C(0x16)
-	/* Page size is 32GB. */
-		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_32G   UINT32_C(0x17)
-	/* Page size is 64GB. */
-		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_64G   UINT32_C(0x18)
-	/* Page size is 128GB. */
-		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_128G  UINT32_C(0x19)
-	/* Page size is 256GB. */
-		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_256G  UINT32_C(0x1a)
-	/* Page size is 512GB. */
-		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_512G  UINT32_C(0x1b)
-	/* Page size is 1TB. */
-		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_1T	UINT32_C(0x1c)
-	/* Page size is 2TB. */
-		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_2T	UINT32_C(0x1d)
-	/* Page size is 4TB. */
-		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_4T	UINT32_C(0x1e)
-	/* Page size is 8TB. */
-		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_8T	UINT32_C(0x1f)
-		#define SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_LAST	SQ_FR_PPMR_HDR_PBL_PAGE_SIZE_LOG_PGSZ_8T
-	/* Sets the proxy_vf_valid field of the physical memory region. */
-	#define SQ_FR_PPMR_HDR_PROXY_VF_VALID		UINT32_C(0x20)
-	/* Number of levels of PBL for translation */
-	#define SQ_FR_PPMR_HDR_NUMLEVELS_MASK		UINT32_C(0xc0)
-	#define SQ_FR_PPMR_HDR_NUMLEVELS_SFT		6
+		#define DBC_DBC_TYPE_SRQ		(UINT32_C(0x2) << 28)
 	/*
-	 * A zero level PBL means that the VA is the physical address used
-	 * for the operation.  No translation is done by the PTU.
+	 * This doorbell command arms the SRQ async event.
+	 * The xID field must identify the SID that is begin armed.
+	 * The index field is will set the arm threshold such that
+	 * a notification will be generated if less than that number
+	 * or SRQ entries are posted. This type is valid for RoCE path.
 	 */
-		#define SQ_FR_PPMR_HDR_NUMLEVELS_PHYSICAL	(UINT32_C(0x0) << 6)
+		#define DBC_DBC_TYPE_SRQ_ARM	(UINT32_C(0x3) << 28)
 	/*
-	 * A one layer translation is provided between the logical and
-	 * physical address.  The PBL points to a physical page that contains
-	 * PBE values that point to actual pg_size physical pages.
+	 * This is a CQ consumer index update. It indicates one or more
+	 * entries have been processed off the CQ indicated on the xID
+	 * field.This type is valid for L2, RoCE and Engine path.
 	 */
-		#define SQ_FR_PPMR_HDR_NUMLEVELS_LAYER1		(UINT32_C(0x1) << 6)
+		#define DBC_DBC_TYPE_CQ		(UINT32_C(0x4) << 28)
 	/*
-	 * A two layer translation is provided between the logical and
-	 * physical address. The PBL points to a physical page that contains
-	 * PDE values that in turn point to pbl_pg_size physical pages that contain
-	 * PBE values that point to actual physical pages.
+	 * this is a CQ consumer index update that also arms the CQ for
+	 * solicited events. This type is valid for RoCE path.
 	 */
-		#define SQ_FR_PPMR_HDR_NUMLEVELS_LAYER2		(UINT32_C(0x2) << 6)
-		#define SQ_FR_PPMR_HDR_NUMLEVELS_LAST		SQ_FR_PPMR_HDR_NUMLEVELS_LAYER2
-	/* Pointer to the PBL, or PDL depending on number of levels */
-	uint64_t	pblptr;
-	/* Local Virtual Address */
-	uint64_t	va;
-} sq_fr_ppmr_hdr_t, *psq_fr_ppmr_hdr_t;
-
-/*
- * Bind SQ WQE. This WQE can perform either:
- * * type1 "bind memory window", if mw_type==Type1
- * * type2 "post send bind memory window", if mw_type==Type2
- */
-/* sq_bind (size:1024b/128B) */
-
-typedef struct sq_bind {
-	/* This field defines the type of SQ WQE. */
-	uint8_t	wqe_type;
+		#define DBC_DBC_TYPE_CQ_ARMSE	(UINT32_C(0x5) << 28)
 	/*
-	 * Memory Bind
-	 *
-	 * Allowed only on reliable connection (RC) SQs.
+	 * This is a CQ consumer index update that also arms the CQ
+	 * for any new CQE. This type is valid for L2, RoCE and Engine
+	 * path.
 	 */
-	#define SQ_BIND_WQE_TYPE_BIND UINT32_C(0xe)
-	#define SQ_BIND_WQE_TYPE_LAST SQ_BIND_WQE_TYPE_BIND
-	uint8_t	flags;
-	#define SQ_BIND_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_MASK		UINT32_C(0xff)
-	#define SQ_BIND_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_SFT			0
+		#define DBC_DBC_TYPE_CQ_ARMALL	(UINT32_C(0x6) << 28)
 	/*
-	 * Set if completion signaling is requested. If this bit is
-	 * 0, and the SQ is configured to support Unsignaled
-	 * completion the controller should not generate a CQE
-	 * unless there was an error. This refers to CQE on the
-	 * sender side (se_flag refers to the receiver side)
+	 * This is a CQ arm enable message. This message must be sent
+	 * from the privileged driver before a new CQ_ARMSE or CQ_ARMALL
+	 * message will be accepted.
+	 *
+	 * This doorbell can only be sent from the privileged (first)
+	 * doorbell page of a function.
 	 */
-	#define SQ_BIND_FLAGS_SIGNAL_COMP								UINT32_C(0x1)
+		#define DBC_DBC_TYPE_CQ_ARMENA	(UINT32_C(0x7) << 28)
 	/*
-	 * Indication to complete all previous RDMA Read or Atomic
-	 * WQEs on the SQ before executing this WQE
+	 * This doorbell command enables the SRQ async event
+	 * to be armed. This message must be sent from the privileged
+	 * driver before a new SRQ_ARM message will be accepted.
+	 * The xID field must identify the SID that is begin enabled
+	 * for arm.
+	 *
+	 * This doorbell can only be sent from the privileged (first)
+	 * doorbell page of a function.
 	 */
-	#define SQ_BIND_FLAGS_RD_OR_ATOMIC_FENCE							UINT32_C(0x2)
+		#define DBC_DBC_TYPE_SRQ_ARMENA	(UINT32_C(0x8) << 28)
 	/*
-	 * Unconditional fence. Indication to complete all previous
-	 * SQ's WQEs before executing this WQE.
+	 * This doorbell command indicates that the cutoff CQE has
+	 * been processed and the driver is now processing completions
+	 * from the new CQ.
+	 *
+	 * The index field for this doorbell type must be zero.
 	 */
-	#define SQ_BIND_FLAGS_UC_FENCE								UINT32_C(0x4)
-	/* NA, nothing is sent. */
-	#define SQ_BIND_FLAGS_SE									UINT32_C(0x8)
-	/* NA */
-	#define SQ_BIND_FLAGS_INLINE								UINT32_C(0x10)
+		#define DBC_DBC_TYPE_CQ_CUTOFF_ACK  (UINT32_C(0x9) << 28)
 	/*
-	 * This flag is not applicable and should be 0 for a local memory
-	 * operation WQE.
+	 * This is a NQ consumer index update. It indicates one or more
+	 * entries have been processed off the NQ indicated on the xID
+	 * field. This type is valid for L2, RoCE and Engine path.
 	 */
-	#define SQ_BIND_FLAGS_WQE_TS_EN								UINT32_C(0x20)
+		#define DBC_DBC_TYPE_NQ		(UINT32_C(0xa) << 28)
 	/*
-	 * When set to '1', this operation will cause a trace capture in
-	 * each block it passes through.
+	 * This is a NQ consumer index update that also arms the NQ for
+	 * any new NQE. This type is valid for L2, RoCE and Engine path.
 	 */
-	#define SQ_BIND_FLAGS_DEBUG_TRACE								UINT32_C(0x40)
+		#define DBC_DBC_TYPE_NQ_ARM	(UINT32_C(0xb) << 28)
 	/*
-	 * This is the new access control for the MR.  '1' means
-	 * the operation is allowed.  '0' means operation is
-	 * not allowed.
+	 * This is a NQ consumer index update that also arms the NQ for
+	 * any new NQE. It is used for the legacy INT mask. This type
+	 * is valid for L2, RoCE and Engine path.
 	 */
-	uint8_t	access_cntl;
-	#define SQ_BIND_ACCESS_CNTL_WINDOW_BIND_REMOTE_ATOMIC_REMOTE_WRITE_REMOTE_READ_LOCAL_WRITE_MASK		UINT32_C(0xff)
-	#define SQ_BIND_ACCESS_CNTL_WINDOW_BIND_REMOTE_ATOMIC_REMOTE_WRITE_REMOTE_READ_LOCAL_WRITE_SFT		0
+		#define DBC_DBC_TYPE_NQ_MASK	(UINT32_C(0xe) << 28)
 	/*
-	 * Local Write Access.
+	 * This doorbell command is used during doorbell moderation
+	 * to consume system BW and help prevent doorbell FIFO
+	 * overflow.
 	 *
-	 * Local accesses are never allowed for memory windows, so this
-	 * bit must always be zero in a bind WQE.  If this bit is ever
-	 * set, the bind will fail with an errored completion.
+	 * All other fields should be zero for NULL doorbell.
+	 * For doorbell recovery, NULL doorbell type in the Application
+	 * table indicates that it is the last QP entry for the function.
+	 * This type is valid for L2, RoCE and Engine path.
 	 */
-	#define SQ_BIND_ACCESS_CNTL_LOCAL_WRITE									UINT32_C(0x1)
-	/* Remote Read Access */
-	#define SQ_BIND_ACCESS_CNTL_REMOTE_READ									UINT32_C(0x2)
+		#define DBC_DBC_TYPE_NULL	(UINT32_C(0xf) << 28)
+		#define DBC_DBC_TYPE_LAST	DBC_DBC_TYPE_NULL
+} dbc_dbc_t, *pdbc_dbc_t;
+
+/*
+ * This is the 32b doorbell format. The host writes this message
+ * format directly to byte offset 8 of the appropriate doorbell page.
+ */
+/* dbc_dbc32 (size:32b/4B) */
+
+typedef struct dbc_dbc32 {
+	uint32_t	type_abs_incr_xid;
 	/*
-	 * Remote Write Access.
+	 * This value identifies the resource that the doorbell is intended
+	 * to notify.
 	 *
-	 * Note that, if this bit is set, then the parent region to which
-	 * the window is being bound must allow local writes.  If this is not
-	 * the case, then the bind will fail with an errored completion.
+	 * For SQ and RQ, this is the QPID. For SRQ, this is the SID. For
+	 * CQ, this is the CID.
+	 *
+	 * Bits [19:16] of this values must be zero for a SID value.
 	 */
-	#define SQ_BIND_ACCESS_CNTL_REMOTE_WRITE									UINT32_C(0x4)
+	#define DBC_DBC32_XID_MASK UINT32_C(0xfffff)
+	#define DBC_DBC32_XID_SFT  0
 	/*
-	 * Remote Atomic Access.
-	 *
-	 * Note that, if this bit is set, then the parent region to which
-	 * the window is being bound must allow local writes.  If this is not
-	 * the case, then the bind will fail with an errored completion.
+	 * This value defines the intended doorbell path between RoCE and
+	 * L2.
 	 */
-	#define SQ_BIND_ACCESS_CNTL_REMOTE_ATOMIC									UINT32_C(0x8)
+	#define DBC_DBC32_PATH_MASK UINT32_C(0xc00000)
+	#define DBC_DBC32_PATH_SFT 22
+	/* This is a RoCE doorbell message. */
+		#define DBC_DBC32_PATH_ROCE  (UINT32_C(0x0) << 22)
+	/* This is a L2 doorbell message. */
+		#define DBC_DBC32_PATH_L2	(UINT32_C(0x1) << 22)
+		#define DBC_DBC32_PATH_LAST DBC_DBC32_PATH_L2
 	/*
-	 * Window Binding Allowed.
+	 * When abs=0, this value is the value to add to the appropriate
+	 * index value.
 	 *
-	 * It is never allowed to bind windows to windows, so this bit
-	 * must always be zero in a bind WQE.  If this bit is ever set,
-	 * the bind will fail with an errored completion.
+	 * When abs=1, this value is the new value for the index. Absolute
+	 * value is used when the queue is being wrapped. When abs=1,
+	 * the incr value follows the same rules as the index value
+	 * in the 64b doorbell.
 	 */
-	#define SQ_BIND_ACCESS_CNTL_WINDOW_BIND									UINT32_C(0x10)
-	/* reserved8_1 is 8 b */
-	uint8_t	reserved8_1;
-	uint8_t	mw_type_zero_based;
+	#define DBC_DBC32_INCR_MASK UINT32_C(0xf000000)
+	#define DBC_DBC32_INCR_SFT 24
+	/* This value defines how the incr value will be interpreted. */
+	#define DBC_DBC32_ABS	UINT32_C(0x10000000)
+	/* This value identifies the type of doorbell being written. */
+	#define DBC_DBC32_TYPE_MASK UINT32_C(0xe0000000)
+	#define DBC_DBC32_TYPE_SFT 29
 	/*
-	 * If this bit is set, then the newly-bound memory window will be
-	 * zero-based.  If clear, then the newly-bound memory window will be
-	 * non-zero-based.
+	 * This is a SQ producer index update. It indicates one or more
+	 * new entries have been written to the SQ for the QPID
+	 * indicated on the xID field.
 	 */
-	#define SQ_BIND_ZERO_BASED	UINT32_C(0x1)
+		#define DBC_DBC32_TYPE_SQ	(UINT32_C(0x0) << 29)
+		#define DBC_DBC32_TYPE_LAST DBC_DBC32_TYPE_SQ
+} dbc_dbc32_t, *pdbc_dbc32_t;
+
+/*
+ * This is the 64b Push Start doorbell format. The host writes this
+ * message format directly to offset of each push associated WCB (write
+ * combine buffer) within doorbell page. WCB#0 = offset 16, WCB#1 =
+ * offset 24, WCB#2 = offset 32, ... The start doorbell is followed by
+ * write combining data to the WCB and then that is followed by a end
+ * doorbell.
+ */
+/* db_push_start (size:64b/8B) */
+
+typedef struct db_push_start {
+	uint64_t	db;
 	/*
-	 * If type1 is specified, then this WQE performs a "bind memory window"
-	 * operation on a type1 window.  If type2 is specified, then this WQE
-	 * performs a "post send bind memory window" operation on a type2
-	 * window.
+	 * This is the push index and should be the SQ slot index,
+	 * aligned to the start of the corresponding push WQE/packet in
+	 * the Send Queue.
 	 *
-	 * Note that the bind WQE cannot change the type of the memory window.
+	 * The index size is 16b for RoCE path and 24b for L2 and Engine
+	 * paths. Any unused bits should be written as zero.
 	 *
-	 * If a "bind memory window" operation is attempted on a memory window
-	 * that was allocated as type2, then the bind will fail with an errored
-	 * completion, as "bind memory window" is allowed only on type1 memory
-	 * windows.
+	 * The index unit is 16B for L2 path. For RoCE there is a legacy
+	 * mode with 128B unit size and a variable size mode with 16B
+	 * unit size. For Engine mode, the unit size is 16B, where RQEs
+	 * are always 128B - so it always increments by eight 16B slots
+	 * per RQE.
 	 *
-	 * Similarly, if a "post send bind memory window" operation is attempted
-	 * on a memory window that was allocated as type1, then the bind will fail
-	 * with an errored completions, as "post send bind memory window" is allowed
-	 * only on type2 memory windows.
+	 * > This field is not used by the older versions of the chip,
+	 * > but is used in this and future revisions of the chip. In
+	 * > older versions of the chip, the driver is required to
+	 * > complete the push doorbell operation by following it with a
+	 * > regular doorbell which will be used to properly increment
+	 * > the producer index. This extra doorbell write is not needed
+	 * > on this and future versions of the chip.
 	 */
-	#define SQ_BIND_MW_TYPE	UINT32_C(0x2)
-	/* Type 1 Bind Memory Window */
-		#define SQ_BIND_MW_TYPE_TYPE1	(UINT32_C(0x0) << 1)
-	/* Type 2 Post Send Bind Memory Window */
-		#define SQ_BIND_MW_TYPE_TYPE2	(UINT32_C(0x1) << 1)
-		#define SQ_BIND_MW_TYPE_LAST	SQ_BIND_MW_TYPE_TYPE2
-	uint8_t	reserved8_2;
-	uint16_t	reserved16;
+	#define DB_PUSH_START_DB_INDEX_MASK	UINT32_C(0xffffff)
+	#define DB_PUSH_START_DB_INDEX_SFT	0
 	/*
-	 * The L_Key of the parent MR; 24 msb of the key are used to
-	 * index the MRW table, 8 lsb are compared with the 8 bit key
-	 * in the MRWC.
+	 * This value is the PI index (lower 8bits) within 4K DPI
+	 * associated with push write. It is the doorbell page that
+	 * contains the WCB that will be used.
 	 */
-	uint32_t	parent_l_key;
+	#define DB_PUSH_START_DB_PI_LO_MASK	UINT32_C(0xff000000)
+	#define DB_PUSH_START_DB_PI_LO_SFT	24
 	/*
-	 * Local Key; 24 msb of the key are used to index the memory
-	 * window being bound in the MRW table, 8 lsb are assign to the
-	 * 8 bit key_lsb field in the MRWC.
+	 * This value identifies the resource that the doorbell is
+	 * intended to notify.
+	 *
+	 * This is the QPID.
 	 */
-	uint32_t	l_key;
-	/* Local Virtual Address */
-	uint64_t	va;
+	#define DB_PUSH_START_DB_XID_MASK	UINT32_C(0xfffff00000000)L
+	#define DB_PUSH_START_DB_XID_SFT	32
+	/*
+	 * This value is the PI index (upper 4bits) within 4K DPI
+	 * associated with push write. It is the doorbell page that
+	 * contains the WCB that will be used.
+	 */
+	#define DB_PUSH_START_DB_PI_HI_MASK	UINT32_C(0xf0000000000000)L
+	#define DB_PUSH_START_DB_PI_HI_SFT	52
+	/* This value identifies the type of doorbell being written. */
+	#define DB_PUSH_START_DB_TYPE_MASK	UINT32_C(0xf000000000000000)L
+	#define DB_PUSH_START_DB_TYPE_SFT	60
+	/*
+	 * This is a SQ producer index update for Push. It indicates
+	 * one or more new entries have been written to the SQ for
+	 * the QPID indicated on the `xid` field.
+	 */
+		#define DB_PUSH_START_DB_TYPE_PUSH_START  (UINT32_C(0xc)L << 60)
+	/*
+	 * This is a SQ producer index update for Push. It indicates
+	 * one or more new entries have been written to the SQ for
+	 * the QPID indicated on the `xid` field.
+	 */
+		#define DB_PUSH_START_DB_TYPE_PUSH_END	(UINT32_C(0xd)L << 60)
+		#define DB_PUSH_START_DB_TYPE_LAST	DB_PUSH_START_DB_TYPE_PUSH_END
+} db_push_start_t, *pdb_push_start_t;
+
+/*
+ * This is the 64b Push End doorbell format. The host writes this message
+ * format directly to offset of each push associated WCB (write combine
+ * buffer) within doorbell page. WCB#0 = offset 16, WCB#1 = offset 24,
+ * WCB#2 = offset 32, ... The start doorbell is followed by write
+ * combining data to the WCB and then that is followed by a end doorbell.
+ */
+/* db_push_end (size:64b/8B) */
+
+typedef struct db_push_end {
+	uint64_t	db;
+	/*
+	 * This is the producer index and should be the queue index of
+	 * the last WQE written plus the length field contained in that
+	 * WQE. For example, if the length is 8 index units and the WQE
+	 * was written to the first location in the queue (zero), this
+	 * index should be written to 8. The index should point to the
+	 * start of the first location that has not been filled in with
+	 * WQE data.
+	 *
+	 * For L2 and Engine SQ, the index unit is 16B. For RoCE there
+	 * are two modes. For Legacy fixed size RQE mode, the unit is
+	 * 128B. For variable size RQE mode, the unit is 16B.
+	 *
+	 * The index size is 24b for L2 and engine paths and 16b for the
+	 * RoCE path. Unused bits should be written as zero.
+	 *
+	 * > In past revisions of this chip, this field was the push
+	 * > index rather than the producer index. For this version of
+	 * > the chip and future versions of the chip, this field must be
+	 * > the producer index, as described above.
+	 * >
+	 * > Also, in past revisions of this chip, an additional
+	 * > doorbell write was needed to communicate the producer index.
+	 * > In this and future versions of the chip, this extra doorbell
+	 * > write is no longer needed.
+	 */
+	#define DB_PUSH_END_DB_INDEX_MASK	UINT32_C(0xffffff)
+	#define DB_PUSH_END_DB_INDEX_SFT	0
 	/*
-	 * Length in bytes of registered MW; 40 bits as this is the max
-	 * size of an MR/W
+	 * This value is the PI index (lower 8bits) within 4K DPI
+	 * associated with push write. It is the doorbell page that
+	 * contains the WCB that will be used.
 	 */
-	uint8_t	length[5];
-	uint8_t	reserved24[3];
-	/* The data field for Bind is not used. */
-	uint32_t	data[24];
-} sq_bind_t, *psq_bind_t;
-
-/*
- * Bind SQ WQE header. This WQE can perform either:
- * * type1 "bind memory window", if mw_type==Type1
- * * type2 "post send bind memory window", if mw_type==Type2
- */
-/* sq_bind_hdr (size:256b/32B) */
-
-typedef struct sq_bind_hdr {
-	/* This field defines the type of SQ WQE. */
-	uint8_t	wqe_type;
+	#define DB_PUSH_END_DB_PI_LO_MASK	UINT32_C(0xff000000)
+	#define DB_PUSH_END_DB_PI_LO_SFT	24
 	/*
-	 * Memory Bind
+	 * This value identifies the resource that the doorbell is
+	 * intended to notify.
 	 *
-	 * Allowed only on reliable connection (RC) SQs.
+	 * This is the QPID.
 	 */
-	#define SQ_BIND_HDR_WQE_TYPE_BIND UINT32_C(0xe)
-	#define SQ_BIND_HDR_WQE_TYPE_LAST SQ_BIND_HDR_WQE_TYPE_BIND
-	uint8_t	flags;
-	#define SQ_BIND_HDR_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_MASK		UINT32_C(0xff)
-	#define SQ_BIND_HDR_FLAGS_INLINE_SE_UC_FENCE_RD_OR_ATOMIC_FENCE_SIGNAL_COMP_SFT			0
+	#define DB_PUSH_END_DB_XID_MASK	UINT32_C(0xfffff00000000)L
+	#define DB_PUSH_END_DB_XID_SFT	32
 	/*
-	 * Set if completion signaling is requested. If this bit is
-	 * 0, and the SQ is configured to support Unsignaled
-	 * completion the controller should not generate a CQE
-	 * unless there was an error. This refers to CQE on the
-	 * sender side (se_flag refers to the receiver side)
+	 * This value is the PI index (upper 4bits) within 4K DPI
+	 * associated with push write. It is the doorbell page that
+	 * contains the WCB that will be used.
 	 */
-	#define SQ_BIND_HDR_FLAGS_SIGNAL_COMP								UINT32_C(0x1)
+	#define DB_PUSH_END_DB_PI_HI_MASK	UINT32_C(0xf0000000000000)L
+	#define DB_PUSH_END_DB_PI_HI_SFT	52
 	/*
-	 * Indication to complete all previous RDMA Read or Atomic
-	 * WQEs on the SQ before executing this WQE
+	 * This value defines the intended doorbell path between RoCE and
+	 * L2.
 	 */
-	#define SQ_BIND_HDR_FLAGS_RD_OR_ATOMIC_FENCE							UINT32_C(0x2)
+	#define DB_PUSH_END_DB_PATH_MASK	UINT32_C(0x300000000000000)L
+	#define DB_PUSH_END_DB_PATH_SFT	56
+	/* This is a RoCE doorbell message. */
+		#define DB_PUSH_END_DB_PATH_ROCE	(UINT32_C(0x0)L << 56)
+	/* This is a L2 doorbell message. */
+		#define DB_PUSH_END_DB_PATH_L2	(UINT32_C(0x1)L << 56)
+	/* Engine path doorbell. */
+		#define DB_PUSH_END_DB_PATH_ENGINE	(UINT32_C(0x2)L << 56)
+		#define DB_PUSH_END_DB_PATH_LAST	DB_PUSH_END_DB_PATH_ENGINE
 	/*
-	 * Unconditional fence. Indication to complete all previous
-	 * SQ's WQEs before executing this WQE.
+	 * When this bit is set to one, the chip will capture debug
+	 * information for the doorbell ring. This is intended to only be
+	 * used on SQ doorbell rings.
 	 */
-	#define SQ_BIND_HDR_FLAGS_UC_FENCE								UINT32_C(0x4)
-	/* NA, nothing is sent. */
-	#define SQ_BIND_HDR_FLAGS_SE									UINT32_C(0x8)
-	/* NA */
-	#define SQ_BIND_HDR_FLAGS_INLINE								UINT32_C(0x10)
+	#define DB_PUSH_END_DB_DEBUG_TRACE	UINT32_C(0x800000000000000)L
+	/* This value identifies the type of doorbell being written. */
+	#define DB_PUSH_END_DB_TYPE_MASK	UINT32_C(0xf000000000000000)L
+	#define DB_PUSH_END_DB_TYPE_SFT	60
 	/*
-	 * This flag is not applicable and should be 0 for a local memory
-	 * operation WQE.
+	 * This is a SQ producer index update for Push. It indicates
+	 * one or more new entries have been written to the SQ for
+	 * the QPID indicated on the `xid` field.
 	 */
-	#define SQ_BIND_HDR_FLAGS_WQE_TS_EN								UINT32_C(0x20)
+		#define DB_PUSH_END_DB_TYPE_PUSH_START   (UINT32_C(0xc)L << 60)
 	/*
-	 * When set to '1', this operation will cause a trace capture in
-	 * each block it passes through.
+	 * This is a SQ producer index update for Push. It indicates
+	 * one or more new entries have been written to the SQ for
+	 * the QPID indicated on the `xid` field.
 	 */
-	#define SQ_BIND_HDR_FLAGS_DEBUG_TRACE								UINT32_C(0x40)
+		#define DB_PUSH_END_DB_TYPE_PUSH_END	(UINT32_C(0xd)L << 60)
+		#define DB_PUSH_END_DB_TYPE_LAST	DB_PUSH_END_DB_TYPE_PUSH_END
+} db_push_end_t, *pdb_push_end_t;
+
+/*
+ * This is the Push information that is the second 8B of the Push
+ * Doorbell.
+ */
+/* db_push_info (size:64b/8B) */
+
+typedef struct db_push_info {
+	uint32_t	push_size_push_index;
 	/*
-	 * This is the new access control for the MR.  '1' means
-	 * the operation is allowed.  '0' means operation is
-	 * not allowed.
+	 * This value is the index for the push being started. For
+	 * example, if the push_size is 8 index units and the WQE was
+	 * written to the first location in the queue (zero), this
+	 * push_index should be written to 0. The push_index should point
+	 * to the start of the first location that the push is started.
+	 *
+	 * The push_index unit is 16B, except in RoCE legacy WQE mode, in
+	 * which case the unit is 128B.
+	 *
+	 * The push_index size is 24b for L2 and 16b for the RoCE path.
+	 * Unused bits should be written as zero.
 	 */
-	uint8_t	access_cntl;
-	#define SQ_BIND_HDR_ACCESS_CNTL_WINDOW_BIND_REMOTE_ATOMIC_REMOTE_WRITE_REMOTE_READ_LOCAL_WRITE_MASK		UINT32_C(0xff)
-	#define SQ_BIND_HDR_ACCESS_CNTL_WINDOW_BIND_REMOTE_ATOMIC_REMOTE_WRITE_REMOTE_READ_LOCAL_WRITE_SFT		0
+	#define DB_PUSH_INFO_PUSH_INDEX_MASK UINT32_C(0xffffff)
+	#define DB_PUSH_INFO_PUSH_INDEX_SFT 0
 	/*
-	 * Local Write Access.
+	 * This value defines the size of push. The unit is 8B. The value
+	 * 0 means 256B size of push. The push write is done in 8B units
+	 * by the SW.
 	 *
-	 * Local accesses are never allowed for memory windows, so this
-	 * bit must always be zero in a bind WQE.  If this bit is ever
-	 * set, the bind will fail with an errored completion.
+	 * Note: For packet rate performance reasons, it is recommended
+	 * that SW aligns push requests with a granularity of 16B.
 	 */
-	#define SQ_BIND_HDR_ACCESS_CNTL_LOCAL_WRITE									UINT32_C(0x1)
-	/* Remote Read Access */
-	#define SQ_BIND_HDR_ACCESS_CNTL_REMOTE_READ									UINT32_C(0x2)
+	#define DB_PUSH_INFO_PUSH_SIZE_MASK UINT32_C(0x1f000000)
+	#define DB_PUSH_INFO_PUSH_SIZE_SFT  24
+	uint32_t	reserved32;
+} db_push_info_t, *pdb_push_info_t;
+
+/*
+ * This is the "Absolute" 32b Doorbell format. The host writes this
+ * message format directly to byte offset 0xC of the appropriate
+ * doorbell page.
+ *
+ * Absolute doorbells are supported for only a limited number of
+ * functions and for a limited number of xID values within each
+ * function.
+ *
+ * Doorbell recovery can be supported for absolute 32b doorbells.
+ */
+/* dbc_absolute_db_32 (size:32b/4B) */
+
+typedef struct dbc_absolute_db_32 {
+	uint32_t	index;
 	/*
-	 * Remote Write Access.
+	 * This value is the index being written. For SQ, RQ, SRQ, this is
+	 * the producer index and should be the queue index of the last WQE
+	 * or BD written plus the length field contained in that WQE/BD.
+	 * For example, if the length is 8 index units and the WQE was
+	 * written to the first location in the queue (zero), this index
+	 * should be written to 8. The index should point to the start of
+	 * the first location that has not been filled in with WQE/BD data.
 	 *
-	 * Note that, if this bit is set, then the parent region to which
-	 * the window is being bound must allow local writes.  If this is not
-	 * the case, then the bind will fail with an errored completion.
+	 * For CQ, this is the consumer index and should be the starting
+	 * queue index of the last CQE processed plus the size of the last
+	 * processed CQE in index units. The index should point to the start
+	 * of the first CQE in the queue that has not been processed.
+	 *
+	 * For NQ, this is the consumer index and should be the starting
+	 * queue index of the last NQE processed plus the size of the last
+	 * processed NQE in index units. The index should point to the start
+	 * of the first NQE in the queue that has not been processed.
+	 *
+	 * For L2 and Engine SQ, the index unit is 16B. For RoCE there are
+	 * two modes. For Legacy fixed size RQE mode, the unit is 128B. For
+	 * variable size RQE mode, the unit is 16B. For RoCE and engine CQs,
+	 * the index unit is 32B. For L2 CQs, the index unit is 16B.
+	 *
+	 * For NQ this is the consumer index and the unit is always 16B of
+	 * queue space.
+	 *
+	 * The index size is 16b for all queue types. This limits the size
+	 * of some queues when absolute doorbells are in use. Unused bits
+	 * should be written as zero.
 	 */
-	#define SQ_BIND_HDR_ACCESS_CNTL_REMOTE_WRITE									UINT32_C(0x4)
+	#define DBC_ABSOLUTE_DB_32_INDEX_MASK	UINT32_C(0xffff)
+	#define DBC_ABSOLUTE_DB_32_INDEX_SFT	0
 	/*
-	 * Remote Atomic Access.
+	 * The epoch bit provides a frame of reference for the queue index.
+	 * S/W will toggle this bit in the doorbell each time index range is
+	 * wrapped. This allows the receiving HW block to more efficiently
+	 * detect out-of-order doorbells and to ignore the older doorbells.
+	 * Out-of-order doorbells occur normally during dropped doorbell
+	 * recovery.
+	 */
+	#define DBC_ABSOLUTE_DB_32_EPOCH	UINT32_C(0x10000)
+	/*
+	 * The toggle value is used in CQ_ARMENA, CQ_ARMSE, CQ_ARMALL,
+	 * SRQ_ARMENA, SRQ_ARM, and CQ_CUTOFF_ACK doorbells to qualify the
+	 * doorbell as valid. This value should be taken from the latest NQE
+	 * or cutoff completion.
 	 *
-	 * Note that, if this bit is set, then the parent region to which
-	 * the window is being bound must allow local writes.  If this is not
-	 * the case, then the bind will fail with an errored completion.
+	 * Doorbells of the above types with the wrong toggle value will be
+	 * ignored. This is how old values in of backup doorbells are
+	 * ignored.
 	 */
-	#define SQ_BIND_HDR_ACCESS_CNTL_REMOTE_ATOMIC									UINT32_C(0x8)
+	#define DBC_ABSOLUTE_DB_32_TOGGLE_MASK	UINT32_C(0x60000)
+	#define DBC_ABSOLUTE_DB_32_TOGGLE_SFT	17
 	/*
-	 * Window Binding Allowed.
+	 * This value identifies the resource that the doorbell is intended
+	 * to notify.
 	 *
-	 * It is never allowed to bind windows to windows, so this bit
-	 * must always be zero in a bind WQE.  If this bit is ever set,
-	 * the bind will fail with an errored completion.
+	 * This is a "modified" xID value. The DBR block will convert this
+	 * value into the full xID value by looking up the base xID for this
+	 * particular function and adding the mxID value to that base value.
 	 */
-	#define SQ_BIND_HDR_ACCESS_CNTL_WINDOW_BIND									UINT32_C(0x10)
-	/* reserved8_1 is 8 b */
-	uint8_t	reserved8_1;
-	uint8_t	mw_type_zero_based;
+	#define DBC_ABSOLUTE_DB_32_MXID_MASK	UINT32_C(0x1f80000)
+	#define DBC_ABSOLUTE_DB_32_MXID_SFT	19
 	/*
-	 * If this bit is set, then the newly-bound memory window will be
-	 * zero-based.  If clear, then the newly-bound memory window will be
-	 * non-zero-based.
+	 * This value defines the intended doorbell path between RoCE and
+	 * L2.
 	 */
-	#define SQ_BIND_HDR_ZERO_BASED	UINT32_C(0x1)
+	#define DBC_ABSOLUTE_DB_32_PATH_MASK	UINT32_C(0x6000000)
+	#define DBC_ABSOLUTE_DB_32_PATH_SFT	25
+	/* This is a RoCE doorbell message. */
+		#define DBC_ABSOLUTE_DB_32_PATH_ROCE	(UINT32_C(0x0) << 25)
+	/* This is a L2 doorbell message. */
+		#define DBC_ABSOLUTE_DB_32_PATH_L2	(UINT32_C(0x1) << 25)
+		#define DBC_ABSOLUTE_DB_32_PATH_LAST	DBC_ABSOLUTE_DB_32_PATH_L2
 	/*
-	 * If type1 is specified, then this WQE performs a "bind memory window"
-	 * operation on a type1 window.  If type2 is specified, then this WQE
-	 * performs a "post send bind memory window" operation on a type2
-	 * window.
-	 *
-	 * Note that the bind WQE cannot change the type of the memory window.
-	 *
-	 * If a "bind memory window" operation is attempted on a memory window
-	 * that was allocated as type2, then the bind will fail with an errored
-	 * completion, as "bind memory window" is allowed only on type1 memory
-	 * windows.
-	 *
-	 * Similarly, if a "post send bind memory window" operation is attempted
-	 * on a memory window that was allocated as type1, then the bind will fail
-	 * with an errored completions, as "post send bind memory window" is allowed
-	 * only on type2 memory windows.
+	 * This indicates it is valid doorbell update. It should be set for
+	 * each doorbell written to the chip and set when doorbell message is
+	 * written to the backup doorbell location. The bit should be cleared
+	 * in the backup doorbell location at time zero to indicate that the
+	 * backup doorbell has not yet been written.
 	 */
-	#define SQ_BIND_HDR_MW_TYPE	UINT32_C(0x2)
-	/* Type 1 Bind Memory Window */
-		#define SQ_BIND_HDR_MW_TYPE_TYPE1	(UINT32_C(0x0) << 1)
-	/* Type 2 Post Send Bind Memory Window */
-		#define SQ_BIND_HDR_MW_TYPE_TYPE2	(UINT32_C(0x1) << 1)
-		#define SQ_BIND_HDR_MW_TYPE_LAST	SQ_BIND_HDR_MW_TYPE_TYPE2
-	uint8_t	reserved8_2;
-	uint16_t	reserved16;
+	#define DBC_ABSOLUTE_DB_32_VALID	UINT32_C(0x8000000)
+	/* This value identifies the type of doorbell being written. */
+	#define DBC_ABSOLUTE_DB_32_TYPE_MASK	UINT32_C(0xf0000000)
+	#define DBC_ABSOLUTE_DB_32_TYPE_SFT	28
 	/*
-	 * The L_Key of the parent MR; 24 msb of the key are used to
-	 * index the MRW table, 8 lsb are compared with the 8 bit key
-	 * in the MRWC.
+	 * This is a SQ producer index update. It indicates one or more
+	 * new entries have been written to the SQ for the QPID indicated
+	 * on the xID field. This type is valid for L2, RoCE and Engine
+	 * path.
 	 */
-	uint32_t	parent_l_key;
+		#define DBC_ABSOLUTE_DB_32_TYPE_SQ	(UINT32_C(0x0) << 28)
 	/*
-	 * Local Key; 24 msb of the key are used to index the memory
-	 * window being bound in the MRW table, 8 lsb are assign to the
-	 * 8 bit key_lsb field in the MRWC.
+	 * This is a RQ producer index update. It indicates one or more
+	 * new entries have been written to the RQ for the QPID indicated
+	 * on the xID field. This type is valid for RoCE path.
 	 */
-	uint32_t	l_key;
-	/* Local Virtual Address */
-	uint64_t	va;
+		#define DBC_ABSOLUTE_DB_32_TYPE_RQ	(UINT32_C(0x1) << 28)
 	/*
-	 * Length in bytes of registered MW; 40 bits as this is the max
-	 * size of an MR/W
+	 * This is a SRQ producer index update. It indicates one or more
+	 * new entries have been written to the SRQ for the SID indicated
+	 * on the xID field. This type is valid for L2 and RoCE path.
 	 */
-	uint8_t	length[5];
-	uint8_t	reserved24[3];
-} sq_bind_hdr_t, *psq_bind_hdr_t;
-
-/* RQ/SRQ WQE */
-/* rq_wqe (size:1024b/128B) */
-
-typedef struct rq_wqe {
-	/* wqe_type is 8 b */
-	uint8_t	wqe_type;
+		#define DBC_ABSOLUTE_DB_32_TYPE_SRQ	(UINT32_C(0x2) << 28)
 	/*
-	 * RQ/SRQ WQE.   This WQE is used for posting buffers on
-	 * an RQ or SRQ.
+	 * This doorbell command arms the SRQ async event.
+	 * The xID field must identify the SID that is begin armed.
+	 * The index field is will set the arm threshold such that
+	 * a notification will be generated if less than that number
+	 * or SRQ entries are posted. This type is valid for RoCE path.
 	 */
-	#define RQ_WQE_WQE_TYPE_RCV UINT32_C(0x80)
-	#define RQ_WQE_WQE_TYPE_LAST RQ_WQE_WQE_TYPE_RCV
-	/* No flags supported for this WQE type. */
-	uint8_t	flags;
+		#define DBC_ABSOLUTE_DB_32_TYPE_SRQ_ARM	(UINT32_C(0x3) << 28)
 	/*
-	 * Specify the total number 16B chunks that make up the valid
-	 * portion of the WQE.  This includes the first chunk that is the
-	 * WQE structure and up to 6 SGE structures.
-	 *
-	 * While the valid area is defined by the wqe_size field, the
-	 * actual WQE size is fixed at 128B.
+	 * This is a CQ consumer index update. It indicates one or more
+	 * entries have been processed off the CQ indicated on the xID
+	 * field.This type is valid for L2, RoCE and Engine path.
 	 */
-	uint8_t	wqe_size;
-	uint8_t	reserved8;
-	uint32_t	reserved32;
-	uint64_t	wr_id;
+		#define DBC_ABSOLUTE_DB_32_TYPE_CQ	(UINT32_C(0x4) << 28)
 	/*
-	 * Opaque value used by upper layer SW to identify the id of the
-	 * WR which generated the WQE. Used in CQE. Valid in the first
-	 * SGE of an SRQ WQE.
+	 * this is a CQ consumer index update that also arms the CQ for
+	 * solicited events. This type is valid for RoCE path.
 	 */
-	#define RQ_WQE_WR_ID_MASK UINT32_C(0xfffff)
-	#define RQ_WQE_WR_ID_SFT 0
-	uint8_t	reserved128[16];
+		#define DBC_ABSOLUTE_DB_32_TYPE_CQ_ARMSE	(UINT32_C(0x5) << 28)
 	/*
-	 * The data field for RQ WQE is filled with from 1 to 6 SGE
-	 * structures as defined by the wqe_size field.
+	 * This is a CQ consumer index update that also arms the CQ
+	 * for any new CQE. This type is valid for L2, RoCE and Engine
+	 * path.
 	 */
-	uint32_t	data[24];
-} rq_wqe_t, *prq_wqe_t;
-
-/* RQ/SRQ WQE header. */
-/* rq_wqe_hdr (size:256b/32B) */
-
-typedef struct rq_wqe_hdr {
-	/* wqe_type is 8 b */
-	uint8_t	wqe_type;
+		#define DBC_ABSOLUTE_DB_32_TYPE_CQ_ARMALL   (UINT32_C(0x6) << 28)
 	/*
-	 * RQ/SRQ WQE.   This WQE is used for posting buffers on
-	 * an RQ or SRQ.
+	 * This is a CQ arm enable message. This message must be sent from
+	 * the privileged driver before a new CQ_ARMSE or CQ_ARMALL message
+	 * will be accepted from user space (non-privileged doorbell page).
+	 * The index and epoch for this doorbell type are unused.
+	 *
+	 * This doorbell can only be sent from the privileged (first)
+	 * doorbell page of a function.
 	 */
-	#define RQ_WQE_HDR_WQE_TYPE_RCV UINT32_C(0x80)
-	#define RQ_WQE_HDR_WQE_TYPE_LAST RQ_WQE_HDR_WQE_TYPE_RCV
-	/* No flags supported for this WQE type. */
-	uint8_t	flags;
+		#define DBC_ABSOLUTE_DB_32_TYPE_CQ_ARMENA   (UINT32_C(0x7) << 28)
 	/*
-	 * Specify the total number 16B chunks that make up the valid
-	 * portion of the WQE.  This includes the first chunk that is the
-	 * WQE structure and up to 6 SGE structures.
+	 * This doorbell command enables the SRQ async event to be armed.
+	 * This message must be sent from the privileged driver before a
+	 * new SRQ_ARM message will be accepted from user space.
+	 * The xID field must identify the SID that is being enabled for
+	 * arm. The index and epoch for this doorbell type are unused.
 	 *
-	 * While the valid area is defined by the wqe_size field, the
-	 * actual WQE size is fixed at 128B.
+	 * This doorbell can only be sent from the privileged (first)
+	 * doorbell page of a function.
 	 */
-	uint8_t	wqe_size;
-	uint8_t	reserved8;
-	uint32_t	reserved32;
-	uint64_t	wr_id;
+		#define DBC_ABSOLUTE_DB_32_TYPE_SRQ_ARMENA  (UINT32_C(0x8) << 28)
 	/*
-	 * Opaque value used by upper layer SW to identify the id of the
-	 * WR which generated the WQE. Used in CQE. Valid in the first
-	 * SGE of an SRQ WQE.
+	 * This is a NQ consumer index update. It indicates one or more
+	 * entries have been processed off the NQ indicated on the xID
+	 * field. This type is valid for L2, RoCE and Engine path.
 	 */
-	#define RQ_WQE_HDR_WR_ID_MASK UINT32_C(0xfffff)
-	#define RQ_WQE_HDR_WR_ID_SFT 0
-	uint8_t	reserved128[16];
-} rq_wqe_hdr_t, *prq_wqe_hdr_t;
-
-/* cq_base (size:256b/32B) */
-
-typedef struct cq_base {
-	uint64_t	reserved64_1;
-	uint64_t	reserved64_2;
-	uint64_t	reserved64_3;
-	uint8_t	cqe_type_toggle;
+		#define DBC_ABSOLUTE_DB_32_TYPE_NQ	(UINT32_C(0xa) << 28)
 	/*
-	 * Indicate valid completion - written by the chip. Cumulus
-	 * toggle this bit each time it finished consuming all PBL
-	 * entries
+	 * This is a NQ consumer index update that also arms the NQ for
+	 * any new NQE. This type is valid for L2, RoCE and Engine path.
 	 */
-	#define CQ_BASE_TOGGLE		UINT32_C(0x1)
-	/* This field defines the type of SQ WQE. */
-	#define CQ_BASE_CQE_TYPE_MASK	UINT32_C(0x1e)
-	#define CQ_BASE_CQE_TYPE_SFT	1
+		#define DBC_ABSOLUTE_DB_32_TYPE_NQ_ARM	(UINT32_C(0xb) << 28)
 	/*
-	 * Requester completion - This is used for both RC and UD SQ
-	 * completions.
+	 * This is a NQ consumer index update that also arms the NQ for
+	 * any new NQE. It is used for the legacy INT mask. This type
+	 * is valid for L2, RoCE and Engine path.
 	 */
-		#define CQ_BASE_CQE_TYPE_REQ		(UINT32_C(0x0) << 1)
+		#define DBC_ABSOLUTE_DB_32_TYPE_NQ_MASK	(UINT32_C(0xe) << 28)
 	/*
-	 * Responder RC Completion - This is used for both RQ and SRQ
-	 * completions for RC service QPs.
+	 * This doorbell command is used during doorbell moderation
+	 * to consume system BW and help prevent doorbell FIFO
+	 * overflow.
+	 *
+	 * All other fields should be zero for NULL doorbell.
+	 * For doorbell recovery, NULL doorbell type in the Application
+	 * table indicates that it is the last QP entry for the function.
+	 * This type is valid for L2, RoCE and Engine path.
 	 */
-		#define CQ_BASE_CQE_TYPE_RES_RC	(UINT32_C(0x1) << 1)
+		#define DBC_ABSOLUTE_DB_32_TYPE_NULL	(UINT32_C(0xf) << 28)
+		#define DBC_ABSOLUTE_DB_32_TYPE_LAST	DBC_ABSOLUTE_DB_32_TYPE_NULL
+} dbc_absolute_db_32_t, *pdbc_absolute_db_32_t;
+
+/*
+ * This is the "Relative" 32b Doorbell format. The host writes this
+ * message format directly to byte offset 8 of the appropriate doorbell
+ * page.
+ *
+ * Doorbell recovery can not be supported for relative doorbells. So
+ * relative doorbells are only safe to use when SOC is supporting the
+ * context backing store in local DDR. If that is the case, it is safe
+ * to turn off doorbell drops and use this type of doorbell.
+ */
+/* dbc_relative_db_32 (size:32b/4B) */
+
+typedef struct dbc_relative_db_32 {
+	uint32_t	xid;
 	/*
-	 * Responder UD Completion - This is used for both RQ and SRQ
-	 * completion for UD service QPs.
+	 * This value identifies the resource that the doorbell is intended
+	 * to notify.
+	 *
+	 * For SQ, this is the QPID value.
 	 */
-		#define CQ_BASE_CQE_TYPE_RES_UD	(UINT32_C(0x2) << 1)
+	#define DBC_RELATIVE_DB_32_XID_MASK	UINT32_C(0xfffff)
+	#define DBC_RELATIVE_DB_32_XID_SFT	0
 	/*
-	 * Responder RawEth and QP1 Completion - This is used for RQ
-	 * completion for RawEth service and QP1 service QPs.
+	 * This value defines the intended doorbell path between RoCE and
+	 * L2.
 	 */
-		#define CQ_BASE_CQE_TYPE_RES_RAWETH_QP1  (UINT32_C(0x3) << 1)
+	#define DBC_RELATIVE_DB_32_PATH_MASK	UINT32_C(0xc00000)
+	#define DBC_RELATIVE_DB_32_PATH_SFT	22
+	/* This is a RoCE doorbell message. */
+		#define DBC_RELATIVE_DB_32_PATH_ROCE	(UINT32_C(0x0) << 22)
+	/* This is a L2 doorbell message. */
+		#define DBC_RELATIVE_DB_32_PATH_L2	(UINT32_C(0x1) << 22)
+		#define DBC_RELATIVE_DB_32_PATH_LAST	DBC_RELATIVE_DB_32_PATH_L2
 	/*
-	 * Responder UD completion with CFA. This is used for both RQ
-	 * and SQ completion for UD service QPs. It includes cfa fields
-	 * (some of which carry VLAN information), in place of QP handle.
+	 * This value is the value to add to the appropriate index value.
+	 *
+	 * The increment unit is 16B for L2 path. For RoCE there is a
+	 * legacy mode with 128B unit size and a variable size mode with
+	 * 32B unit size. For Engine mode, the unit size is always 128B.
 	 */
-		#define CQ_BASE_CQE_TYPE_RES_UD_CFA	(UINT32_C(0x4) << 1)
+	#define DBC_RELATIVE_DB_32_INCR_MASK	UINT32_C(0x1f000000)
+	#define DBC_RELATIVE_DB_32_INCR_SFT	24
+	/* This value identifies the type of doorbell being written. */
+	#define DBC_RELATIVE_DB_32_TYPE_MASK	UINT32_C(0xe0000000)
+	#define DBC_RELATIVE_DB_32_TYPE_SFT	29
 	/*
-	 * NO_OP completion - This is used to indicate that no
-	 * operation completion.
+	 * This is a SQ producer index update. It indicates one or more
+	 * new entries have been written to the SQ for the QPID indicated
+	 * on the xID field. This type is valid for L2, RoCE and Engine
+	 * path.
 	 */
-		#define CQ_BASE_CQE_TYPE_NO_OP	(UINT32_C(0xd) << 1)
+		#define DBC_RELATIVE_DB_32_TYPE_SQ	(UINT32_C(0x0) << 29)
 	/*
-	 * Terminal completion - This is used to indicate that no
-	 * further completions will be made for this QP on this CQ.
+	 * This is a SRQ producer index update. It indicates one or more
+	 * new entries have been written to the SRQ for the SID indicated
+	 * on the xID field. This type is valid for L2 and RoCE path.
 	 */
-		#define CQ_BASE_CQE_TYPE_TERMINAL	(UINT32_C(0xe) << 1)
-	/* Cut off CQE; for CQ resize see CQ and SRQ Resize */
-		#define CQ_BASE_CQE_TYPE_CUT_OFF	(UINT32_C(0xf) << 1)
-		#define CQ_BASE_CQE_TYPE_LAST	CQ_BASE_CQE_TYPE_CUT_OFF
-	/* This field indicates the status for the CQE. */
-	uint8_t	status;
-	uint16_t	reserved16;
-	uint32_t	reserved32;
-} cq_base_t, *pcq_base_t;
-
-/* Requester CQ CQE */
-/* cq_req (size:256b/32B) */
-
-typedef struct cq_req {
+		#define DBC_RELATIVE_DB_32_TYPE_SRQ	(UINT32_C(0x1) << 29)
 	/*
-	 * This is an application level ID used to identify the
-	 * QP and its SQ and RQ.
+	 * This is a CQ consumer index update. It indicates one or more
+	 * entries have been processed off the CQ indicated on the xID
+	 * field.This type is valid for L2, RoCE and Engine path.
 	 */
-	uint64_t	qp_handle;
+		#define DBC_RELATIVE_DB_32_TYPE_CQ	(UINT32_C(0x2) << 29)
 	/*
-	 * SQ Consumer Index - points to the entry just past the last WQE
-	 * that has been completed by the chip.  Wraps around at
-	 * QPC.sq_size (i.e. the valid range of the SQ Consumer Index is 0
-	 * to (QPC.sq_size - 1)).
+	 * This is a CQ consumer index update that also arms the CQ
+	 * for any new CQE. This type is valid for L2, RoCE and Engine
+	 * path.
 	 */
-	uint16_t	sq_cons_idx;
-	uint16_t	reserved16_1;
-	uint32_t	reserved32_2;
-	uint64_t	reserved64;
-	uint8_t	cqe_type_toggle;
+		#define DBC_RELATIVE_DB_32_TYPE_CQ_ARMALL  (UINT32_C(0x3) << 29)
 	/*
-	 * Indicate valid completion - written by the chip. Cumulus
-	 * toggle this bit each time it finished consuming all PBL
-	 * entries
+	 * This is a NQ consumer index update. It indicates one or more
+	 * entries have been processed off the NQ indicated on the xID
+	 * field. This type is valid for L2, RoCE and Engine path.
 	 */
-	#define CQ_REQ_TOGGLE	UINT32_C(0x1)
-	/* This field defines the type of SQ WQE. */
-	#define CQ_REQ_CQE_TYPE_MASK UINT32_C(0x1e)
-	#define CQ_REQ_CQE_TYPE_SFT 1
+		#define DBC_RELATIVE_DB_32_TYPE_NQ	(UINT32_C(0x4) << 29)
 	/*
-	 * Requester completion - This is used for both RC and UD SQ
-	 * completions.
+	 * This is a NQ consumer index update that also arms the NQ for
+	 * any new NQE. This type is valid for L2, RoCE and Engine path.
 	 */
-		#define CQ_REQ_CQE_TYPE_REQ   (UINT32_C(0x0) << 1)
-		#define CQ_REQ_CQE_TYPE_LAST CQ_REQ_CQE_TYPE_REQ
+		#define DBC_RELATIVE_DB_32_TYPE_NQ_ARM	(UINT32_C(0x5) << 29)
 	/*
-	 * When this bit is '1', it indicates that the packet completed
-	 * was transmitted using the push accelerated data provided by
-	 * the driver. When this bit is '0', it indicates that the packet
-	 * had not push acceleration data written or was executed as a
-	 * normal packet even though push data was provided.
-	 * This field is intended to be used for driver-generated push
-	 * statistics. It is not applicable for RC since not all RC packets
-	 * return a CQE.
+	 * This is a NQ consumer index update that also arms the NQ for
+	 * any new NQE. It is used for the legacy INT mask. This type
+	 * is valid for L2, RoCE and Engine path.
 	 */
-	#define CQ_REQ_PUSH	UINT32_C(0x20)
-	/* This field indicates the status for the CQE. */
-	uint8_t	status;
-	/* OK is 0 */
-	#define CQ_REQ_STATUS_OK			UINT32_C(0x0)
-	/* BAD_RESPONSE_ERR is 1 */
-	#define CQ_REQ_STATUS_BAD_RESPONSE_ERR	UINT32_C(0x1)
-	/* LOCAL_LENGTH_ERR is 2 */
-	#define CQ_REQ_STATUS_LOCAL_LENGTH_ERR	UINT32_C(0x2)
-	/* LOCAL_QP_OPERATION_ERR is 3 */
-	#define CQ_REQ_STATUS_LOCAL_QP_OPERATION_ERR	UINT32_C(0x3)
-	/* LOCAL_PROTECTION_ERR is 4 */
-	#define CQ_REQ_STATUS_LOCAL_PROTECTION_ERR	UINT32_C(0x4)
-	/* MEMORY_MGT_OPERATION_ERR is 5 */
-	#define CQ_REQ_STATUS_MEMORY_MGT_OPERATION_ERR   UINT32_C(0x5)
-	/* REMOTE_INVALID_REQUEST_ERR is 6 */
-	#define CQ_REQ_STATUS_REMOTE_INVALID_REQUEST_ERR UINT32_C(0x6)
-	/* REMOTE_ACCESS_ERR is 7 */
-	#define CQ_REQ_STATUS_REMOTE_ACCESS_ERR	UINT32_C(0x7)
-	/* REMOTE_OPERATION_ERR is 8 */
-	#define CQ_REQ_STATUS_REMOTE_OPERATION_ERR	UINT32_C(0x8)
-	/* RNR_NAK_RETRY_CNT_ERR is 9 */
-	#define CQ_REQ_STATUS_RNR_NAK_RETRY_CNT_ERR	UINT32_C(0x9)
-	/* TRANSPORT_RETRY_CNT_ERR is 10 */
-	#define CQ_REQ_STATUS_TRANSPORT_RETRY_CNT_ERR	UINT32_C(0xa)
-	/* WORK_REQUEST_FLUSHED_ERR is 11 */
-	#define CQ_REQ_STATUS_WORK_REQUEST_FLUSHED_ERR   UINT32_C(0xb)
-	#define CQ_REQ_STATUS_LAST			CQ_REQ_STATUS_WORK_REQUEST_FLUSHED_ERR
-	uint16_t	reserved16_2;
-	uint32_t	reserved32_1;
-} cq_req_t, *pcq_req_t;
+		#define DBC_RELATIVE_DB_32_TYPE_NQ_MASK	(UINT32_C(0x6) << 29)
+		#define DBC_RELATIVE_DB_32_TYPE_LAST	DBC_RELATIVE_DB_32_TYPE_NQ_MASK
+} dbc_relative_db_32_t, *pdbc_relative_db_32_t;
 
-/* Responder RC CQE */
-/* cq_res_rc (size:256b/32B) */
+/*
+ * The kernel memory structure is per-type (SQ, RQ, SRQ/SRQ_ARM and
+ * CQ/CQ_ARMSE/CQ_ARMALL). Each kernel driver will support a table for
+ * the doorbell recovery.
+ */
+/* dbc_drk (size:128b/16B) */
 
-typedef struct cq_res_rc {
+typedef struct dbc_drk {
+	uint32_t	db_format_linked_last_valid_stride_size;
 	/*
-	 * The length of the message's payload in bytes, stored in
-	 * the SGEs
+	 * This indicates it is valid entry. It should be set for each
+	 * doorbell written to the chip. The bit should be cleared at time
+	 * zero to indicate that it has not yet been written. The bit i
+	 * should be cleared when the function for the table is disabled.
 	 */
-	uint32_t	length;
+	#define DBC_DRK_VALID	UINT32_C(0x1)
+	/* This indicates it is last entry for the table. */
+	#define DBC_DRK_LAST	UINT32_C(0x2)
+	/* This indicates it is entry for the next 4KB kernel memory pointer. */
+	#define DBC_DRK_LINKED	UINT32_C(0x4)
 	/*
-	 * Immediate data in case the imm_flag set, R_Key to be
-	 * invalidated in case inv_flag is set.
+	 * This field indicates if the doorbells in the table are 32b
+	 * absolute or 64b format.
 	 */
-	uint32_t	imm_data_or_inv_r_key;
+	#define DBC_DRK_DB_FORMAT	UINT32_C(0x8)
+	/* The doorbells are 64b format. */
+		#define DBC_DRK_DB_FORMAT_B64   (UINT32_C(0x0) << 3)
 	/*
-	 * This is an application level ID used to identify the
-	 * QP and its SQ and RQ.
+	 * The doorbells are in the absolute 32b format. The doorbell
+	 * is in the right-most half of the 64b space provided in the
+	 * application table entry.
 	 */
-	uint64_t	qp_handle;
+		#define DBC_DRK_DB_FORMAT_B32A  (UINT32_C(0x1) << 3)
+		#define DBC_DRK_DB_FORMAT_LAST DBC_DRK_DB_FORMAT_B32A
 	/*
-	 * Opaque value - valid when inv_flag is set. Used by driver
-	 * to reference the buffer used to store PBL when the MR was
-	 * fast registered. The driver can reclaim this buffer after
-	 * an MR was remotely invalidated. The controller take that
-	 * value from the MR referenced by R_Key
+	 * This field controls the stride feature. The stride feature is
+	 * more bandwidth efficient on the PCIE bus when only a small number
+	 * of doorbells are used in each cache line.
 	 */
-	uint64_t	mr_handle;
-	uint8_t	cqe_type_toggle;
+	#define DBC_DRK_STRIDE_MASK   UINT32_C(0x300)
+	#define DBC_DRK_STRIDE_SFT	8
 	/*
-	 * Indicate valid completion - written by the chip. Cumulus
-	 * toggle this bit each time it finished consuming all PBL
-	 * entries
+	 * When stride is off, the DBR will read all the bytes in
+	 * an application page until a NULL doorbell is found or
+	 * the end of the 4K page is reached.
 	 */
-	#define CQ_RES_RC_TOGGLE	UINT32_C(0x1)
-	/* This field defines the type of SQ WQE. */
-	#define CQ_RES_RC_CQE_TYPE_MASK  UINT32_C(0x1e)
-	#define CQ_RES_RC_CQE_TYPE_SFT   1
+		#define DBC_DRK_STRIDE_OFF	(UINT32_C(0x0) << 8)
 	/*
-	 * Responder RC Completion - This is used for both RQ and SRQ
-	 * completions for RC service QPs.
+	 * When stride is 1, the DBR will read the 'size' doorbells,
+	 * starting at the next 64B cache line boundary or until
+	 * a NULL doorbell is found in the application page or
+	 * the end of the 4K page is reached.
 	 */
-		#define CQ_RES_RC_CQE_TYPE_RES_RC  (UINT32_C(0x1) << 1)
-		#define CQ_RES_RC_CQE_TYPE_LAST   CQ_RES_RC_CQE_TYPE_RES_RC
-	/* This field indicates the status for the CQE. */
-	uint8_t	status;
-	/* OK is 0 */
-	#define CQ_RES_RC_STATUS_OK			UINT32_C(0x0)
-	/* LOCAL_ACCESS_ERROR is 1 */
-	#define CQ_RES_RC_STATUS_LOCAL_ACCESS_ERROR	UINT32_C(0x1)
-	/* LOCAL_LENGTH_ERR is 2 */
-	#define CQ_RES_RC_STATUS_LOCAL_LENGTH_ERR	UINT32_C(0x2)
-	/* LOCAL_PROTECTION_ERR is 3 */
-	#define CQ_RES_RC_STATUS_LOCAL_PROTECTION_ERR	UINT32_C(0x3)
-	/* LOCAL_QP_OPERATION_ERR is 4 */
-	#define CQ_RES_RC_STATUS_LOCAL_QP_OPERATION_ERR	UINT32_C(0x4)
-	/* MEMORY_MGT_OPERATION_ERR is 5 */
-	#define CQ_RES_RC_STATUS_MEMORY_MGT_OPERATION_ERR   UINT32_C(0x5)
-	/* REMOTE_INVALID_REQUEST_ERR is 6 */
-	#define CQ_RES_RC_STATUS_REMOTE_INVALID_REQUEST_ERR UINT32_C(0x6)
-	/* WORK_REQUEST_FLUSHED_ERR is 7 */
-	#define CQ_RES_RC_STATUS_WORK_REQUEST_FLUSHED_ERR   UINT32_C(0x7)
-	/* HW_FLUSH_ERR is 8 */
-	#define CQ_RES_RC_STATUS_HW_FLUSH_ERR		UINT32_C(0x8)
-	#define CQ_RES_RC_STATUS_LAST			CQ_RES_RC_STATUS_HW_FLUSH_ERR
-	uint16_t	flags;
+		#define DBC_DRK_STRIDE_SZ64	(UINT32_C(0x1) << 8)
 	/*
-	 * This flag indicates that the completion is for a SRQ entry
-	 * rather than for an RQ entry.
+	 * When stride is 2, the DBR will read the 'size' doorbells,
+	 * starting at the next 128B cache line boundary or until
+	 * a NULL doorbell is found in the application page or
+	 * the end of the 4K page is reached.
 	 */
-	#define CQ_RES_RC_FLAGS_SRQ		UINT32_C(0x1)
-	/* CQE relates to RQ WQE. */
-		#define CQ_RES_RC_FLAGS_SRQ_RQ	UINT32_C(0x0)
-	/* CQE relates to SRQ WQE. */
-		#define CQ_RES_RC_FLAGS_SRQ_SRQ	UINT32_C(0x1)
-		#define CQ_RES_RC_FLAGS_SRQ_LAST	CQ_RES_RC_FLAGS_SRQ_SRQ
-	/* Immediate data indicator */
-	#define CQ_RES_RC_FLAGS_IMM		UINT32_C(0x2)
-	/* R_Key invalidate indicator */
-	#define CQ_RES_RC_FLAGS_INV		UINT32_C(0x4)
-	#define CQ_RES_RC_FLAGS_RDMA	UINT32_C(0x8)
-	/* CQE relates to an incoming Send request */
-		#define CQ_RES_RC_FLAGS_RDMA_SEND	(UINT32_C(0x0) << 3)
-	/* CQE relates to incoming RDMA Write request */
-		#define CQ_RES_RC_FLAGS_RDMA_RDMA_WRITE  (UINT32_C(0x1) << 3)
-		#define CQ_RES_RC_FLAGS_RDMA_LAST	CQ_RES_RC_FLAGS_RDMA_RDMA_WRITE
-	uint32_t	srq_or_rq_wr_id;
+		#define DBC_DRK_STRIDE_SZ128	(UINT32_C(0x2) << 8)
+		#define DBC_DRK_STRIDE_LAST	DBC_DRK_STRIDE_SZ128
 	/*
-	 * Opaque value from RQ or SRQ WQE. Used by driver/lib to
-	 * reference the WQE in order to claim the received data
-	 * and reuse the WQE space
+	 * This value controls how many doorbells are read at each stride
+	 * when stride mode is in use.
 	 */
-	#define CQ_RES_RC_SRQ_OR_RQ_WR_ID_MASK UINT32_C(0xfffff)
-	#define CQ_RES_RC_SRQ_OR_RQ_WR_ID_SFT 0
-} cq_res_rc_t, *pcq_res_rc_t;
-
-/* Responder UD CQE */
-/* cq_res_ud (size:256b/32B) */
-
-typedef struct cq_res_ud {
-	uint16_t	length;
+	#define DBC_DRK_SIZE_MASK	UINT32_C(0xc00)
+	#define DBC_DRK_SIZE_SFT	10
+	/* 4*8B is read at the start of each stride. */
+		#define DBC_DRK_SIZE_FOUR	(UINT32_C(0x0) << 10)
+	/* 1*8B is read at the start of each stride. */
+		#define DBC_DRK_SIZE_ONE	(UINT32_C(0x1) << 10)
+	/* 2*8B is read at the start of each stride. */
+		#define DBC_DRK_SIZE_TWO	(UINT32_C(0x2) << 10)
+	/* 3*8B is read at the start of each stride. */
+		#define DBC_DRK_SIZE_THREE	(UINT32_C(0x3) << 10)
+		#define DBC_DRK_SIZE_LAST	DBC_DRK_SIZE_THREE
+	uint32_t	pi;
 	/*
-	 * The length of the message's payload in bytes, stored in
-	 * the SGEs
+	 * Page Index portion of DPI{VF_VALID,VFID,PI}. The pi needs to match
+	 * the value from the context DPI for the operation to be valid or
+	 * the pi must be zero, indicating a write from the privileged
+	 * driver.
+	 *
+	 * pi in the kernel memory table is there for DBR to generate the DPI
+	 * message to the client.
 	 */
-	#define CQ_RES_UD_LENGTH_MASK UINT32_C(0x3fff)
-	#define CQ_RES_UD_LENGTH_SFT 0
+	#define DBC_DRK_PI_MASK UINT32_C(0xffff)
+	#define DBC_DRK_PI_SFT 0
 	/*
-	 * This is data from the CFA or VNIC block as indicated by the
-	 * ext_meta_format and meta_format fields.
+	 * It is the application memory page(4KB) pointer when linked = 0.
+	 * It is the next kernel memory page(4KB) pointer when linked = 1.
+	 * The pointer doesn't have to be aligned to the page(4KB) but it
+	 * should be aligned to 128B boundary. This means that the bottom
+	 * 7b of the pointer must be zero.
 	 */
-	uint16_t	cfa_metadata;
-	/* When meta_format=1, this value is the VLAN VID. */
-	#define CQ_RES_UD_CFA_METADATA_VID_MASK UINT32_C(0xfff)
-	#define CQ_RES_UD_CFA_METADATA_VID_SFT 0
-	/* When meta_format=1, this value is the VLAN DE. */
-	#define CQ_RES_UD_CFA_METADATA_DE	UINT32_C(0x1000)
-	/* When meta_format=1, this value is the VLAN PRI. */
-	#define CQ_RES_UD_CFA_METADATA_PRI_MASK UINT32_C(0xe000)
-	#define CQ_RES_UD_CFA_METADATA_PRI_SFT 13
-	/* Immediate data in case the imm_flag set. */
-	uint32_t	imm_data;
+	uint64_t	memptr;
+} dbc_drk_t, *pdbc_drk_t;
+
+/*
+ * This is the 64b doorbell format. The host writes this message
+ * format directly to byte offset 0 of the appropriate doorbell page.
+ */
+/* dbc_dbc_v3 (size:64b/8B) */
+
+typedef struct dbc_dbc_v3 {
+	uint32_t	index;
 	/*
-	 * This is an application level ID used to identify the
-	 * QP and its SQ and RQ.
+	 * This value is the index being written.
+	 *
+	 * For SQ/RQ/SRQ, this is the producer index. It should be set to
+	 * the queue index of the last WQE/BD written plus the number of
+	 * index units in the WQE/BD. For example, if the number of index
+	 * units in an SQ WQE is 8 and the WQE was written to the first
+	 * location in the queue (zero), this index should be written to 8.
+	 * The index should point to the start of the first location that
+	 * has not been filled in with WQE/BD data. For SQ (both RoCE and
+	 * L2), the index unit is 16B. For RQ/SRQ, the index unit is 1 WQE
+	 * (RoCE) or 1 BD (L2).
+	 *
+	 * For CQ, this is the consumer index and should be the starting
+	 * queue index of the last CQE processed plus the size of the last
+	 * processed CQE in index units. The index should point to the
+	 * start of the first CQE in the queue that has not been processed.
+	 * The index unit is 16B.
+	 *
+	 * For NQ, this is the consumer index and should be the starting
+	 * queue index of the last NQE processed plus the size of the last
+	 * processed NQE in index units. The index should point to the
+	 * start of the first NQE in the queue that has not been processed.
+	 * The index unit is 16B.
 	 */
-	uint64_t	qp_handle;
+	#define DBC_DBC_V3_INDEX_MASK UINT32_C(0xffffff)
+	#define DBC_DBC_V3_INDEX_SFT  0
 	/*
-	 * Source MAC address for the UD message placed in the WQE
-	 * that is completed by this CQE.
+	 * The epoch bit provides a frame of reference for the queue index.
+	 * S/W will toggle this bit in the doorbell each time index range is
+	 * wrapped. This allows the receiving HW block to more efficiently
+	 * detect out-of-order doorbells and to ignore the older doorbells.
+	 * Out-of-order doorbells occur normally during dropped doorbell
+	 * recovery.
 	 */
-	uint16_t	src_mac[3];
-	/* Lower 16b of the Source QP value from the DETH header. */
-	uint16_t	src_qp_low;
-	uint8_t	cqe_type_toggle;
+	#define DBC_DBC_V3_EPOCH	UINT32_C(0x1000000)
 	/*
-	 * Indicate valid completion - written by the chip. Cumulus
-	 * toggle this bit each time it finished consuming all PBL
-	 * entries
+	 * The toggle value is used in CQ_ARMENA, CQ_ARMSE, CQ_ARMALL,
+	 * SRQ_ARMENA, SRQ_ARM, and CQ_CUTOFF_ACK doorbells to qualify the
+	 * doorbell as valid. This value should be taken from the latest
+	 * NQE or cutoff completion.
+	 *
+	 * Doorbells of the above types with the wrong toggle value will
+	 * be ignored. This is how old values in of backup doorbells
+	 * are ignored.
 	 */
-	#define CQ_RES_UD_TOGGLE	UINT32_C(0x1)
-	/* This field defines the type of SQ WQE. */
-	#define CQ_RES_UD_CQE_TYPE_MASK  UINT32_C(0x1e)
-	#define CQ_RES_UD_CQE_TYPE_SFT   1
+	#define DBC_DBC_V3_TOGGLE_MASK UINT32_C(0x6000000)
+	#define DBC_DBC_V3_TOGGLE_SFT 25
+	uint32_t	type_path_xid;
 	/*
-	 * Responder UD Completion - This is used for both RQ and SRQ
-	 * completion for UD service QPs.
+	 * This value identifies the resource that the doorbell is intended
+	 * to notify.
+	 *
+	 * For SQ and RQ, this is the QPID. For SRQ, this is the SID. For
+	 * CQ, this is the CID. For NQ, this is the NID.
+	 *
+	 * Unused bits (for example bits [11:7] of the SID value) must be
+	 * zero.
 	 */
-		#define CQ_RES_UD_CQE_TYPE_RES_UD  (UINT32_C(0x2) << 1)
-		#define CQ_RES_UD_CQE_TYPE_LAST   CQ_RES_UD_CQE_TYPE_RES_UD
-	/* This field indicates the status for the CQE. */
-	uint8_t	status;
+	#define DBC_DBC_V3_XID_MASK	UINT32_C(0xfff)
+	#define DBC_DBC_V3_XID_SFT	0
 	/*
-	 * This indicates that the completion is without error.
-	 * All fields are valid.
+	 * This value defines the intended doorbell path between RoCE and
+	 * L2.
 	 */
-	#define CQ_RES_UD_STATUS_OK			UINT32_C(0x0)
+	#define DBC_DBC_V3_PATH_MASK	UINT32_C(0x3000000)
+	#define DBC_DBC_V3_PATH_SFT	24
+	/* This is a RoCE doorbell message. */
+		#define DBC_DBC_V3_PATH_ROCE	(UINT32_C(0x0) << 24)
+	/* This is a L2 doorbell message. */
+		#define DBC_DBC_V3_PATH_L2		(UINT32_C(0x1) << 24)
+		#define DBC_DBC_V3_PATH_LAST	DBC_DBC_V3_PATH_L2
 	/*
-	 * This indicates that write access was not allowed for
-	 * at least one of the SGEs in the WQE.
-	 *
-	 * This is a fatal error.  Only the srq_or_rq_wr_id is field
-	 * is valid.
+	 * This indicates it is valid doorbell update. It should be set for
+	 * each doorbell written to the chip and set when doorbell message is
+	 * written to the backup doorbell location. The bit should be cleared
+	 * in the backup doorbell location at time zero to indicate that the
+	 * backup doorbell has not yet been written.
 	 */
-	#define CQ_RES_UD_STATUS_LOCAL_ACCESS_ERROR	UINT32_C(0x1)
+	#define DBC_DBC_V3_VALID		UINT32_C(0x4000000)
 	/*
-	 * This indicates that the packet was too long for the WQE
-	 * provided on the SRQ/RQ.
-	 *
-	 * This is not a fatal error.  All the fields are valid.
+	 * When this bit is set to one, the chip will capture debug
+	 * information for the doorbell ring. This is intended to only be
+	 * used on SQ doorbell rings.
 	 */
-	#define CQ_RES_UD_STATUS_HW_LOCAL_LENGTH_ERR	UINT32_C(0x2)
-	/* LOCAL_PROTECTION_ERR is 3 */
-	#define CQ_RES_UD_STATUS_LOCAL_PROTECTION_ERR	UINT32_C(0x3)
-	/* LOCAL_QP_OPERATION_ERR is 4 */
-	#define CQ_RES_UD_STATUS_LOCAL_QP_OPERATION_ERR   UINT32_C(0x4)
-	/* MEMORY_MGT_OPERATION_ERR is 5 */
-	#define CQ_RES_UD_STATUS_MEMORY_MGT_OPERATION_ERR UINT32_C(0x5)
-	/* WORK_REQUEST_FLUSHED_ERR is 7 */
-	#define CQ_RES_UD_STATUS_WORK_REQUEST_FLUSHED_ERR UINT32_C(0x7)
-	/* HW_FLUSH_ERR is 8 */
-	#define CQ_RES_UD_STATUS_HW_FLUSH_ERR		UINT32_C(0x8)
-	#define CQ_RES_UD_STATUS_LAST			CQ_RES_UD_STATUS_HW_FLUSH_ERR
-	uint16_t	flags;
+	#define DBC_DBC_V3_DEBUG_TRACE	UINT32_C(0x8000000)
+	/* This value identifies the type of doorbell being written. */
+	#define DBC_DBC_V3_TYPE_MASK	UINT32_C(0xf0000000)
+	#define DBC_DBC_V3_TYPE_SFT	28
 	/*
-	 * This flag indicates that the completion is for a SRQ entry
-	 * rather than for an RQ entry.
+	 * This is a SQ producer index update. It indicates one or more
+	 * new entries have been written to the SQ for the QPID indicated
+	 * on the xID field. This type is valid for L2 and RoCE path.
 	 */
-	#define CQ_RES_UD_FLAGS_SRQ		UINT32_C(0x1)
-	/* CQE relates to RQ WQE. */
-		#define CQ_RES_UD_FLAGS_SRQ_RQ		UINT32_C(0x0)
-	/* CQE relates to SRQ WQE. */
-		#define CQ_RES_UD_FLAGS_SRQ_SRQ		UINT32_C(0x1)
-		#define CQ_RES_UD_FLAGS_SRQ_LAST		CQ_RES_UD_FLAGS_SRQ_SRQ
-	/* Immediate data indicator */
-	#define CQ_RES_UD_FLAGS_IMM		UINT32_C(0x2)
-	#define CQ_RES_UD_FLAGS_UNUSED_MASK	UINT32_C(0xc)
-	#define CQ_RES_UD_FLAGS_UNUSED_SFT		2
-	#define CQ_RES_UD_FLAGS_ROCE_IP_VER_MASK	UINT32_C(0x30)
-	#define CQ_RES_UD_FLAGS_ROCE_IP_VER_SFT	4
-	/* RoCEv1 Message */
-		#define CQ_RES_UD_FLAGS_ROCE_IP_VER_V1	(UINT32_C(0x0) << 4)
-	/* RoCEv2 IPv4 Message */
-		#define CQ_RES_UD_FLAGS_ROCE_IP_VER_V2IPV4	(UINT32_C(0x2) << 4)
-	/* RoCEv2 IPv6 Message */
-		#define CQ_RES_UD_FLAGS_ROCE_IP_VER_V2IPV6	(UINT32_C(0x3) << 4)
-		#define CQ_RES_UD_FLAGS_ROCE_IP_VER_LAST	CQ_RES_UD_FLAGS_ROCE_IP_VER_V2IPV6
+		#define DBC_DBC_V3_TYPE_SQ		(UINT32_C(0x0) << 28)
 	/*
-	 * The combination of this value and ext_meta_format indicates
-	 * what format the metadata field is.
+	 * This is a RQ producer index update. It indicates one or more
+	 * new entries have been written to the RQ for the QPID indicated
+	 * on the xID field. This type is valid for RoCE path.
 	 */
-	#define CQ_RES_UD_FLAGS_META_FORMAT_MASK	UINT32_C(0x3c0)
-	#define CQ_RES_UD_FLAGS_META_FORMAT_SFT	6
-	/* No metadata information.  Value is zero. */
-		#define CQ_RES_UD_FLAGS_META_FORMAT_NONE	(UINT32_C(0x0) << 6)
+		#define DBC_DBC_V3_TYPE_RQ		(UINT32_C(0x1) << 28)
 	/*
-	 * The metadata field contains the VLAN tag and TPID value.
-	 * - metadata[11:0] contains the vlan VID value.
-	 * - metadata[12] contains the vlan DE value.
-	 * - metadata[15:13] contains the vlan PRI value.
+	 * This is a SRQ producer index update. It indicates one or more
+	 * new entries have been written to the SRQ for the SID indicated
+	 * on the xID field. This type is valid for L2 and RoCE path.
 	 */
-		#define CQ_RES_UD_FLAGS_META_FORMAT_VLAN	(UINT32_C(0x1) << 6)
+		#define DBC_DBC_V3_TYPE_SRQ		(UINT32_C(0x2) << 28)
 	/*
-	 * If ext_meta_format is equal to 1, the metadata field
-	 * contains the lower 16b of the tunnel ID value, justified
-	 * to LSB
-	 * - VXLAN = VNI[23:0] -> VXLAN Network ID
-	 * - Geneve (NGE) = VNI[23:0] -> Virtual Network Identifier.
-	 * - NVGRE = TNI[23:0] -> Tenant Network ID
-	 * - GRE = KEY[31:0] -> key field with bit mask. zero if K = 0
-	 * - IPV4 = 0 (not populated)
-	 * - IPV6 = Flow Label[19:0]
-	 * - PPPoE = sessionID[15:0]
-	 * - MPLs = Outer label[19:0]
-	 * - UPAR = Selected[31:0] with bit mask
+	 * This doorbell command arms the SRQ async event. The xID field
+	 * must identify the SID that is begin armed. The index field is
+	 * will set the arm threshold such that a notification will be
+	 * generated if less than that number or SRQ entries are posted.
+	 *
+	 * This type is valid for RoCE path.
 	 */
-		#define CQ_RES_UD_FLAGS_META_FORMAT_TUNNEL_ID   (UINT32_C(0x2) << 6)
+		#define DBC_DBC_V3_TYPE_SRQ_ARM	(UINT32_C(0x3) << 28)
 	/*
-	 * if ext_meta_format is equal to 1, metadata field contains
-	 * 16b metadata from the prepended header (chdr_data).
+	 * CQ doorbell is used to update the consumer index for the CQ
+	 * for overflow detection. It should only be sent if overflow
+	 * detection is enabled for the CQ. Keep in mind that if
+	 * doorbells are being dropped due to PCIE ordering rules, you
+	 * may get a false overflow detection if you are checking for CQ
+	 * overflow.
+	 *
+	 * This type is valid for L2 and RoCE path.
 	 */
-		#define CQ_RES_UD_FLAGS_META_FORMAT_CHDR_DATA   (UINT32_C(0x3) << 6)
+		#define DBC_DBC_V3_TYPE_CQ		(UINT32_C(0x4) << 28)
 	/*
-	 * If ext_meta_format is equal to 1, the metadata field contains
-	 * the outer_l3_offset and lower 7 bits of the inner_l2_offset,
-	 * - metadata[8:0] contains the outer_l3_offset.
-	 * - metadata[15:9] contains the inner_l2_offset[6:0]
+	 * This is a CQ consumer index update that also arms the CQ for
+	 * solicited events. This is for roce only not for l2.
+	 *
+	 * The index is used as the location of the last CQE that was
+	 * processed by the driver. The new interrupt will be generated
+	 * based on this location.
+	 *
+	 * This type is valid for RoCE path.
 	 */
-		#define CQ_RES_UD_FLAGS_META_FORMAT_HDR_OFFSET  (UINT32_C(0x4) << 6)
-		#define CQ_RES_UD_FLAGS_META_FORMAT_LAST	CQ_RES_UD_FLAGS_META_FORMAT_HDR_OFFSET
+		#define DBC_DBC_V3_TYPE_CQ_ARMSE	(UINT32_C(0x5) << 28)
 	/*
-	 * The combination of this value and meta_format indicates what
-	 * format the metadata field is
+	 * This is a CQ consumer index update that also arms the CQ for
+	 * any new CQE.
+	 *
+	 * The index is used as the location of the last CQE that was
+	 * processed by the driver. The new interrupt will be generated
+	 * based on this location.
+	 *
+	 * This type is valid for L2 and RoCE path.
 	 */
-	#define CQ_RES_UD_FLAGS_EXT_META_FORMAT_MASK  UINT32_C(0xc00)
-	#define CQ_RES_UD_FLAGS_EXT_META_FORMAT_SFT   10
-	uint32_t	src_qp_high_srq_or_rq_wr_id;
+		#define DBC_DBC_V3_TYPE_CQ_ARMALL	(UINT32_C(0x6) << 28)
 	/*
-	 * Opaque value from RQ or SRQ WQE. Used by driver/lib to
-	 * reference the WQE in order to claim the received data
-	 * and reuse the WQE space
+	 * This is a CQ arm enable message. This message must be sent
+	 * from the privileged driver before a new CQ_ARMSE or CQ_ARMALL
+	 * message will be accepted from user space (non-privileged
+	 * doorbell page). The index and epoch for this doorbell type are
+	 * unused.
+	 *
+	 * This doorbell can only be sent from the privileged (first)
+	 * doorbell page of a function.
 	 */
-	#define CQ_RES_UD_SRQ_OR_RQ_WR_ID_MASK UINT32_C(0xfffff)
-	#define CQ_RES_UD_SRQ_OR_RQ_WR_ID_SFT 0
-	/* Upper 8b of the Source QP value from the DETH header. */
-	#define CQ_RES_UD_SRC_QP_HIGH_MASK	UINT32_C(0xff000000)
-	#define CQ_RES_UD_SRC_QP_HIGH_SFT	24
-} cq_res_ud_t, *pcq_res_ud_t;
-
-/* Responder UD CQE version 2 */
-/* cq_res_ud_v2 (size:256b/32B) */
-
-typedef struct cq_res_ud_v2 {
-	uint16_t	length;
+		#define DBC_DBC_V3_TYPE_CQ_ARMENA	(UINT32_C(0x7) << 28)
 	/*
-	 * The length of the message's payload in bytes, stored in
-	 * the SGEs
+	 * This doorbell command enables the SRQ async event to be armed.
+	 * This message must be sent from the privileged driver before
+	 * a new SRQ_ARM message will be accepted from user space. The
+	 * xID field must identify the SID that is being enabled for arm.
+	 * The index and epoch for this doorbell type are unused.
+	 *
+	 * This doorbell can only be sent from the privileged (first)
+	 * doorbell page of a function.
 	 */
-	#define CQ_RES_UD_V2_LENGTH_MASK UINT32_C(0x3fff)
-	#define CQ_RES_UD_V2_LENGTH_SFT 0
-	/* This is data from the CFA as indicated by the meta_format field. */
-	uint16_t	cfa_metadata0;
-	/* When meta_format=1, this value is the VLAN VID. */
-	#define CQ_RES_UD_V2_CFA_METADATA0_VID_MASK UINT32_C(0xfff)
-	#define CQ_RES_UD_V2_CFA_METADATA0_VID_SFT 0
-	/* When meta_format=1, this value is the VLAN DE. */
-	#define CQ_RES_UD_V2_CFA_METADATA0_DE	UINT32_C(0x1000)
-	/* When meta_format=1, this value is the VLAN PRI. */
-	#define CQ_RES_UD_V2_CFA_METADATA0_PRI_MASK UINT32_C(0xe000)
-	#define CQ_RES_UD_V2_CFA_METADATA0_PRI_SFT 13
-	/* Immediate data in case the imm_flag set. */
-	uint32_t	imm_data;
+		#define DBC_DBC_V3_TYPE_SRQ_ARMENA	(UINT32_C(0x8) << 28)
 	/*
-	 * This is an application level ID used to identify the
-	 * QP and its SQ and RQ.
+	 * This doorbell type is used to acknowledge a cutoff completion
+	 * in the CQ. The index and epoch for this doorbell type are
+	 * unused. This doorbell is sent when the cutoff completion has
+	 * been processed and the old CQ in a CQ resize operation is no
+	 * longer needed.
+	 *
+	 * The index and epoch must be valid for this doorbell if
+	 * overflow checking is enabled for the CQ.
 	 */
-	uint64_t	qp_handle;
+		#define DBC_DBC_V3_TYPE_CQ_CUTOFF_ACK  (UINT32_C(0x9) << 28)
 	/*
-	 * Source MAC address for the UD message placed in the WQE
-	 * that is completed by this CQE.
+	 * This is a NQ consumer index update. It indicates one or more
+	 * entries have been processed off the NQ indicated on the xID
+	 * field. It will also mask the NQ for any new NQE. This type is
+	 * valid for L2 and RoCE path.
+	 *
+	 * Thor is broken in that it doesn't mask a legacy INTA interrupt
+	 * when used at the start of an ISR, as it is supposed to be.
+	 *
+	 * type=NQ masks the current interrupt. When the iSR starts, it
+	 * writes a type=NQ with the current consumer index. For legacy
+	 * PCI interrupts, this needs to mask the interrupt so the legacy
+	 * interrupt is deasserted. Then the driver does some work and
+	 * writes some more type=NQ. Finally the driver stops the ISR and
+	 * does a type=NQ_ARM to get another interrupt (when needed). The
+	 * only reason to use type=NQ_MASK is to back out of the armed
+	 * state. In that request, the index update is not required.
 	 */
-	uint16_t	src_mac[3];
-	/* Lower 16b of the Source QP value from the DETH header. */
-	uint16_t	src_qp_low;
-	uint8_t	cqe_type_toggle;
+		#define DBC_DBC_V3_TYPE_NQ		(UINT32_C(0xa) << 28)
 	/*
-	 * Indicate valid completion - written by the chip. Cumulus
-	 * toggle this bit each time it finished consuming all PBL
-	 * entries
+	 * This is a NQ consumer index update that also arms the NQ for
+	 * any new NQE.
+	 *
+	 * This type is valid for L2 and RoCE path.
 	 */
-	#define CQ_RES_UD_V2_TOGGLE	UINT32_C(0x1)
-	/* This field defines the type of SQ WQE. */
-	#define CQ_RES_UD_V2_CQE_TYPE_MASK  UINT32_C(0x1e)
-	#define CQ_RES_UD_V2_CQE_TYPE_SFT   1
+		#define DBC_DBC_V3_TYPE_NQ_ARM	(UINT32_C(0xb) << 28)
 	/*
-	 * Responder UD Completion - This is used for both RQ and SRQ
-	 * completion for UD service QPs.
+	 * This doorbell will assign a new NQ to a CQ. This is handy if
+	 * the user wants to change which interrupt handler is going to
+	 * process a particular CQ. This doorbell must be sent from the
+	 * privileged driver.
+	 *
+	 * The xID must be the CID for the CQ that needs to be changed.
+	 * The index value is the NQID of the new NQ that will be used
+	 * for future notifications. epoch and toggle are ignored for
+	 * this doorbell type.
+	 *
+	 * The CQ will disarm notifications and generate a NQE to the old
+	 * NQ with the nq_reassign type value. The chip will guarantee
+	 * that no notification will be sent to the old NQ after the
+	 * nq_reassign NQE has been sent.
+	 *
+	 * This type is valid for L2 and RoCE CQs.
 	 */
-		#define CQ_RES_UD_V2_CQE_TYPE_RES_UD  (UINT32_C(0x2) << 1)
-		#define CQ_RES_UD_V2_CQE_TYPE_LAST   CQ_RES_UD_V2_CQE_TYPE_RES_UD
-	/* This field indicates the status for the CQE. */
-	uint8_t	status;
+		#define DBC_DBC_V3_TYPE_CQ_REASSIGN	(UINT32_C(0xc) << 28)
 	/*
-	 * This indicates that the completion is without error.
-	 * All fields are valid.
+	 * This masks the NQ for any new NQE. This will NOT update the NQ
+	 * consumer index.
+	 *
+	 * This type is valid for L2 and RoCE path.
 	 */
-	#define CQ_RES_UD_V2_STATUS_OK			UINT32_C(0x0)
+		#define DBC_DBC_V3_TYPE_NQ_MASK	(UINT32_C(0xe) << 28)
 	/*
-	 * This indicates that write access was not allowed for
-	 * at least one of the SGEs in the WQE.
+	 * All other fields should be zero for NULL doorbell.
 	 *
-	 * This is a fatal error.  Only the srq_or_rq_wr_id is field
-	 * is valid.
+	 * For doorbell recovery, NULL doorbell type in the Application
+	 * table indicates that it is the last QP entry for the function.
+	 * This type is valid for L2 and RoCE path.
 	 */
-	#define CQ_RES_UD_V2_STATUS_LOCAL_ACCESS_ERROR	UINT32_C(0x1)
+		#define DBC_DBC_V3_TYPE_NULL	(UINT32_C(0xf) << 28)
+		#define DBC_DBC_V3_TYPE_LAST	DBC_DBC_V3_TYPE_NULL
+} dbc_dbc_v3_t, *pdbc_dbc_v3_t;
+
+/*
+ * This is the RoCE Express Doorbell format. The host writes this
+ * message format directly to offset 0x40 of the appropriate doorbell
+ * page. Express doorbells are used when the chip will be owning the
+ * SQ, RQ, and SRQ as well as the producer indexes for each queue. This
+ * provides a simple fastpath programming model.
+ *
+ * Express doorbell must be received by the chip as a single TLP
+ * message.
+ */
+/* dbc_xp (size:512b/64B) */
+
+typedef struct dbc_xp {
+	uint32_t	reserved;
+	uint32_t	type_xid;
 	/*
-	 * This indicates that the packet was too long for the WQE
-	 * provided on the SRQ/RQ.
+	 * This value identifies the resource that the doorbell is intended
+	 * to notify.
+	 *
+	 * For SQ and RQ, this is the QPID. For SRQ, this is the SID. For
+	 * CQ, this is the CID. For NQ, this is the NID.
 	 *
-	 * This is not a fatal error.  All the fields are valid.
+	 * Unused bits (for example bits [11:7] of the SID value) must be
+	 * zero.
 	 */
-	#define CQ_RES_UD_V2_STATUS_HW_LOCAL_LENGTH_ERR	UINT32_C(0x2)
-	/* LOCAL_PROTECTION_ERR is 3 */
-	#define CQ_RES_UD_V2_STATUS_LOCAL_PROTECTION_ERR	UINT32_C(0x3)
-	/* LOCAL_QP_OPERATION_ERR is 4 */
-	#define CQ_RES_UD_V2_STATUS_LOCAL_QP_OPERATION_ERR   UINT32_C(0x4)
-	/* MEMORY_MGT_OPERATION_ERR is 5 */
-	#define CQ_RES_UD_V2_STATUS_MEMORY_MGT_OPERATION_ERR UINT32_C(0x5)
-	/* WORK_REQUEST_FLUSHED_ERR is 7 */
-	#define CQ_RES_UD_V2_STATUS_WORK_REQUEST_FLUSHED_ERR UINT32_C(0x7)
-	/* HW_FLUSH_ERR is 8 */
-	#define CQ_RES_UD_V2_STATUS_HW_FLUSH_ERR		UINT32_C(0x8)
-	#define CQ_RES_UD_V2_STATUS_LAST			CQ_RES_UD_V2_STATUS_HW_FLUSH_ERR
-	uint16_t	flags;
+	#define DBC_XP_XID_MASK	UINT32_C(0xfff)
+	#define DBC_XP_XID_SFT	0
 	/*
-	 * This flag indicates that the completion is for a SRQ entry
-	 * rather than for an RQ entry.
+	 * When this bit is set to one, the chip will capture debug
+	 * information for the doorbell ring. This is intended to only be
+	 * used on SQ doorbell rings.
 	 */
-	#define CQ_RES_UD_V2_FLAGS_SRQ			UINT32_C(0x1)
-	/* CQE relates to RQ WQE. */
-		#define CQ_RES_UD_V2_FLAGS_SRQ_RQ		UINT32_C(0x0)
-	/* CQE relates to SRQ WQE. */
-		#define CQ_RES_UD_V2_FLAGS_SRQ_SRQ		UINT32_C(0x1)
-		#define CQ_RES_UD_V2_FLAGS_SRQ_LAST		CQ_RES_UD_V2_FLAGS_SRQ_SRQ
-	/* Immediate data indicator */
-	#define CQ_RES_UD_V2_FLAGS_IMM			UINT32_C(0x2)
-	#define CQ_RES_UD_V2_FLAGS_UNUSED_MASK		UINT32_C(0xc)
-	#define CQ_RES_UD_V2_FLAGS_UNUSED_SFT		2
-	#define CQ_RES_UD_V2_FLAGS_ROCE_IP_VER_MASK	UINT32_C(0x30)
-	#define CQ_RES_UD_V2_FLAGS_ROCE_IP_VER_SFT	4
-	/* RoCEv1 Message */
-		#define CQ_RES_UD_V2_FLAGS_ROCE_IP_VER_V1	(UINT32_C(0x0) << 4)
-	/* RoCEv2 IPv4 Message */
-		#define CQ_RES_UD_V2_FLAGS_ROCE_IP_VER_V2IPV4	(UINT32_C(0x2) << 4)
-	/* RoCEv2 IPv6 Message */
-		#define CQ_RES_UD_V2_FLAGS_ROCE_IP_VER_V2IPV6	(UINT32_C(0x3) << 4)
-		#define CQ_RES_UD_V2_FLAGS_ROCE_IP_VER_LAST	CQ_RES_UD_V2_FLAGS_ROCE_IP_VER_V2IPV6
-	/* The field indicates what format the metadata field is. */
-	#define CQ_RES_UD_V2_FLAGS_META_FORMAT_MASK	UINT32_C(0x3c0)
-	#define CQ_RES_UD_V2_FLAGS_META_FORMAT_SFT	6
-	/* No metadata information.  Value is zero. */
-		#define CQ_RES_UD_V2_FLAGS_META_FORMAT_NONE	(UINT32_C(0x0) << 6)
+	#define DBC_XP_DEBUG_TRACE	UINT32_C(0x1000000)
+	/* This value identifies the type of doorbell being written. */
+	#define DBC_XP_TYPE_MASK	UINT32_C(0xf0000000)
+	#define DBC_XP_TYPE_SFT	28
 	/*
-	 * The {metadata1, metadata0} fields contain the vtag
-	 * information: - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0],
-	 * de, vid[11:0]} The metadata2 field contains the table scope
-	 * and action record pointer. - metadata2[25:0] contains the
-	 * action record pointer. - metadata2[31:26] contains the table
-	 * scope.
+	 * This is a SQ producer index update. It indicates one or more
+	 * new entries have been written to the SQ for the QPID indicated
+	 * on the xID field. This type is valid for L2, RoCE and Engine
+	 * path.
 	 */
-		#define CQ_RES_UD_V2_FLAGS_META_FORMAT_ACT_REC_PTR  (UINT32_C(0x1) << 6)
+		#define DBC_XP_TYPE_SQ	(UINT32_C(0x0) << 28)
 	/*
-	 * The {metadata1, metadata0} fields contain the vtag
-	 * information:
-	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0], de, vid[11:0]}
-	 * The metadata2 field contains the Tunnel ID
-	 * value, justified to LSB. i
-	 * - VXLAN = VNI[23:0] -> VXLAN Network ID
-	 * - Geneve (NGE) = VNI[23:0] a-> Virtual Network Identifier
-	 * - NVGRE = TNI[23:0] -> Tenant Network ID
-	 * - GRE = KEY[31:0] -> key field with bit mask. zero if K=0
-	 * - IPv4 = 0 (not populated)
-	 * - IPv6 = Flow Label[19:0]
-	 * - PPPoE = sessionID[15:0]
-	 * - MPLs = Outer label[19:0]
-	 * - UPAR = Selected[31:0] with bit mask
+	 * This is a RQ producer index update. It indicates one or more
+	 * new entries have been written to the RQ for the QPID indicated
+	 * on the xID field. This type is valid for RoCE path.
 	 */
-		#define CQ_RES_UD_V2_FLAGS_META_FORMAT_TUNNEL_ID	(UINT32_C(0x2) << 6)
+		#define DBC_XP_TYPE_RQ	(UINT32_C(0x1) << 28)
 	/*
-	 * The {metadata1, metadata0} fields contain the vtag
-	 * information:
-	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0],de, vid[11:0]}
-	 * The metadata2 field contains the 32b metadata from the
-	 * prepended header (chdr_data).
+	 * This is a SRQ producer index update. It indicates one or more
+	 * new entries have been written to the SRQ for the SID indicated
+	 * on the xID field. This type is valid for L2 and RoCE path.
+	 */
+		#define DBC_XP_TYPE_SRQ	(UINT32_C(0x2) << 28)
+		#define DBC_XP_TYPE_LAST	DBC_XP_TYPE_SRQ
+	/*
+	 * This field hold one express WQE. The WQE must be appropriate for
+	 * the queue selected by the type field.
+	 */
+	uint32_t	wqe[14];
+} dbc_xp_t, *pdbc_xp_t;
+
+/*
+ * This is a firmware status register that indicates the software status
+ * exposed by the firmware to the host.
+ *
+ * > This register is not present in previous versions of this chip.
+ */
+/* fw_status_reg (size:32b/4B) */
+
+typedef struct fw_status_reg {
+	uint32_t	fw_status;
+	/*
+	 * These bits indicate the status as being reported by the firmware.
+	 *
+	 * The value should be interpreted as follows:
+	 * A value below 0x8000 is an indication that the firmware is still
+	 * in the process of starting up and is not ready. The host driver
+	 * should continue waiting with a timeout for firmware status to be
+	 * ready.
+	 * >	0x0000 to 0x00FF : SBL state information
+	 * >	0x0200 to 0x02FF : SBI state information
+	 * >	0x0400 to 0x04FF : SRT state information
+	 * >	0x0600 to 0x06FF : CRT/CHIMP state information
+	 * >	0x0800 to 0x08FF : External Firmware state information
+	 * >	0x0A00 to 0x0FFF : Reserved for future fw functionality
+	 *
+	 * A value of 0x8000 indicates firmware is ready and healthy. The
+	 * host driver can start initiating HWRM commands to the firmware.
+	 *
+	 * A value over 0x8000 is an indication that the firmware has
+	 * detected a fatal error, this error could be in one of the hardware
+	 * block or in a software module. The lower 8 bits indicate a
+	 * block/module specific error and the upper 8 bits identify the
+	 * hardware block or firmware module that was the source of the
+	 * error.
+	 * >	0x81XX - 0xBFXX  : 63 ASIC blocks
+	 * >	0xC0XX to 0xFDXX : 62 Firmware modules
+	 * >	0xFE00 to 0xFEFF : External firmware module
+	 * >	0xFFXX	: Reserved for future
+	 */
+	#define FW_STATUS_REG_CODE_MASK		UINT32_C(0xffff)
+	#define FW_STATUS_REG_CODE_SFT		0
+	/* Indicates firmware is ready. */
+		#define FW_STATUS_REG_CODE_READY		UINT32_C(0x8000)
+		#define FW_STATUS_REG_CODE_LAST		FW_STATUS_REG_CODE_READY
+	/*
+	 * Image Degraded bit. If set indicates that one of the firmware
+	 * image is degraded.
+	 *
+	 * The firmware binary located on NVM has redundant copies to protect
+	 * against corruption. When one of the primary or secondary copy is
+	 * detected as corrupted, this bit will be set by the firmware either
+	 * as part of power on from the context of hwrm_fw_health_check.
 	 */
-		#define CQ_RES_UD_V2_FLAGS_META_FORMAT_CHDR_DATA	(UINT32_C(0x3) << 6)
+	#define FW_STATUS_REG_IMAGE_DEGRADED	UINT32_C(0x10000)
 	/*
-	 * If ext_meta_format is equal to 1, the metadata field contains
-	 * the outer_l3_offset and lower 7 bits of the inner_l2_offset,
-	 * - metadata[8:0] contains the outer_l3_offset.
-	 * - metadata[15:9] contains the inner_l2_offset[6:0]
+	 * Recoverable bit. If set indicates that the fatal error is
+	 * recoverable with a full reset.
+	 *
+	 * This bit should be used by host software and deployment models
+	 * that support error recovery by resetting the controller. A
+	 * recovery should be attempted from a fatal error condition only if
+	 * this bit is set. This bit is meaningful only when the code field
+	 * is greater than 0x8000 (32768 decimal).
 	 */
-		#define CQ_RES_UD_V2_FLAGS_META_FORMAT_HDR_OFFSET   (UINT32_C(0x4) << 6)
-		#define CQ_RES_UD_V2_FLAGS_META_FORMAT_LAST	CQ_RES_UD_V2_FLAGS_META_FORMAT_HDR_OFFSET
-	uint32_t	src_qp_high_srq_or_rq_wr_id;
+	#define FW_STATUS_REG_RECOVERABLE		UINT32_C(0x20000)
 	/*
-	 * Opaque value from RQ or SRQ WQE. Used by driver/lib to
-	 * reference the WQE in order to claim the received data
-	 * and reuse the WQE space
+	 * Crash dump is in process. If set indicates that the firmware is
+	 * currently recording a crash dump.
+	 *
+	 * This bit provides a hint to the host driver if the firmware is
+	 * currently recording a crash dump. Host driers should avoid
+	 * resetting the controller when a crash dump is in progress if
+	 * possible. This bit is meaningful only when the code field is
+	 * greater than 0x8000 (32768 decimal).
 	 */
-	#define CQ_RES_UD_V2_SRQ_OR_RQ_WR_ID_MASK	UINT32_C(0xfffff)
-	#define CQ_RES_UD_V2_SRQ_OR_RQ_WR_ID_SFT		0
-	#define CQ_RES_UD_V2_CFA_METADATA1_MASK		UINT32_C(0xf00000)
-	#define CQ_RES_UD_V2_CFA_METADATA1_SFT		20
-	/* When meta_format != 0, this value is the VLAN TPID_SEL. */
-	#define CQ_RES_UD_V2_CFA_METADATA1_TPID_SEL_MASK	UINT32_C(0x700000)
-	#define CQ_RES_UD_V2_CFA_METADATA1_TPID_SEL_SFT	20
-	/* 0x88a8 */
-		#define CQ_RES_UD_V2_CFA_METADATA1_TPID_SEL_TPID88A8   (UINT32_C(0x0) << 20)
-	/* 0x8100 */
-		#define CQ_RES_UD_V2_CFA_METADATA1_TPID_SEL_TPID8100   (UINT32_C(0x1) << 20)
-	/* 0x9100 */
-		#define CQ_RES_UD_V2_CFA_METADATA1_TPID_SEL_TPID9100   (UINT32_C(0x2) << 20)
-	/* 0x9200 */
-		#define CQ_RES_UD_V2_CFA_METADATA1_TPID_SEL_TPID9200   (UINT32_C(0x3) << 20)
-	/* 0x9300 */
-		#define CQ_RES_UD_V2_CFA_METADATA1_TPID_SEL_TPID9300   (UINT32_C(0x4) << 20)
-	/* Value programmed in CFA VLANTPID register. */
-		#define CQ_RES_UD_V2_CFA_METADATA1_TPID_SEL_TPIDCFG	(UINT32_C(0x5) << 20)
-		#define CQ_RES_UD_V2_CFA_METADATA1_TPID_SEL_LAST	CQ_RES_UD_V2_CFA_METADATA1_TPID_SEL_TPIDCFG
-	/* When meta_format != 0, this value is the VLAN valid. */
-	#define CQ_RES_UD_V2_CFA_METADATA1_VALID		UINT32_C(0x800000)
-	/* Upper 8b of the Source QP value from the DETH header. */
-	#define CQ_RES_UD_V2_SRC_QP_HIGH_MASK		UINT32_C(0xff000000)
-	#define CQ_RES_UD_V2_SRC_QP_HIGH_SFT		24
-} cq_res_ud_v2_t, *pcq_res_ud_v2_t;
-
-/* Responder UD with CFA CQE */
-/* cq_res_ud_cfa (size:256b/32B) */
-
-typedef struct cq_res_ud_cfa {
-	uint16_t	length;
+	#define FW_STATUS_REG_CRASHDUMP_ONGOING	UINT32_C(0x40000)
 	/*
-	 * The length of the message's payload in bytes, stored in
-	 * the SGEs
+	 * Crash dump is available. If set indicates that a firmware crash
+	 * dump was recorded before and is now available.
+	 *
+	 * This bit provides indication to the host driver that the firmware
+	 * has completed a crash dump. This bit is meaningful only when the
+	 * code field is greater than 0x8000 (32768 decimal).
 	 */
-	#define CQ_RES_UD_CFA_LENGTH_MASK UINT32_C(0x3fff)
-	#define CQ_RES_UD_CFA_LENGTH_SFT 0
+	#define FW_STATUS_REG_CRASHDUMP_COMPLETE	UINT32_C(0x80000)
 	/*
-	 * This field identifies the CFA action rule that was used
-	 * for this packet.
+	 * This bit is used to indicate device state when it enters the
+	 * shutdown mode and stopped the communication with the host. The
+	 * host should initiate the reload of firmware image or initiate the
+	 * reset to bring the device to the normal operational state and
+	 * re-establish the communication.
+	 *
+	 * This bit is meaningful only when the code field is greater than
+	 * 0x8000 (32768 decimal).
 	 */
-	uint16_t	cfa_code;
-	/* Immediate data in case the imm_flag set. */
-	uint32_t	imm_data;
-	uint32_t	qid;
+	#define FW_STATUS_REG_SHUTDOWN		UINT32_C(0x100000)
 	/*
-	 * This value indicates the QPID associated with this operation.
-	 * The driver will use the qid from thie CQE to map a QP handle
-	 * in the completion record returned to the application.
+	 * This bit will be set to 1 by the FW when FW crashed without master
+	 * function.
+	 *
+	 * This bit is controller specific, not all products will support
+	 * this bit. This bit is valid only when the code field is greater
+	 * than 0x8000 (32768 decimal).
 	 */
-	#define CQ_RES_UD_CFA_QID_MASK UINT32_C(0xfffff)
-	#define CQ_RES_UD_CFA_QID_SFT 0
+	#define FW_STATUS_REG_CRASHED_NO_MASTER	UINT32_C(0x200000)
 	/*
-	 * This is data from the CFA or VNIC block as indicated by the
-	 * ext_meta_format and meta_format fields.
+	 * The firmware sets this bit to 1 when the firmware has taken an
+	 * exception and expects to initiate error recovery.
+	 *
+	 * This bit is valid only when the code field is greater than 0x8000
+	 * (32768 decimal).
 	 */
-	uint32_t	cfa_metadata;
-	/* When meta_format=1, this value is the VLAN VID. */
-	#define CQ_RES_UD_CFA_CFA_METADATA_VID_MASK UINT32_C(0xfff)
-	#define CQ_RES_UD_CFA_CFA_METADATA_VID_SFT  0
-	/* When meta_format=1, this value is the VLAN DE. */
-	#define CQ_RES_UD_CFA_CFA_METADATA_DE	UINT32_C(0x1000)
-	/* When meta_format=1, this value is the VLAN PRI. */
-	#define CQ_RES_UD_CFA_CFA_METADATA_PRI_MASK UINT32_C(0xe000)
-	#define CQ_RES_UD_CFA_CFA_METADATA_PRI_SFT  13
-	/* When meta_format=1, this value is the VLAN TPID. */
-	#define CQ_RES_UD_CFA_CFA_METADATA_TPID_MASK UINT32_C(0xffff0000)
-	#define CQ_RES_UD_CFA_CFA_METADATA_TPID_SFT 16
+	#define FW_STATUS_REG_RECOVERING		UINT32_C(0x400000)
 	/*
-	 * Source MAC address for the UD message placed in the WQE
-	 * that is completed by this CQE.
+	 * The SBL sets this bit to indicate whether manu_debug pin is
+	 * detected high or low.
 	 */
-	uint16_t	src_mac[3];
-	/* Lower 16b of the Source QP value from the DETH header. */
-	uint16_t	src_qp_low;
-	uint8_t	cqe_type_toggle;
+	#define FW_STATUS_REG_MANU_DEBUG_STATUS	UINT32_C(0x800000)
+} fw_status_reg_t, *pfw_status_reg_t;
+
+/*
+ * This structure is fixed at the beginning of the ChiMP SRAM (GRC
+ * offset: 0x31001F0). Host software is expected to read from this
+ * location for a defined signature. If it exists, the software can
+ * assume the presence of this structure and the validity of the
+ * FW_STATUS location in the next field.
+ */
+/* hcomm_status (size:64b/8B) */
+
+typedef struct hcomm_status {
+	uint32_t	sig_ver;
 	/*
-	 * Indicate valid completion - written by the chip. Cumulus
-	 * toggle this bit each time it finished consuming all PBL
-	 * entries
+	 * This field defines the version of the structure. The latest
+	 * version value is 1.
 	 */
-	#define CQ_RES_UD_CFA_TOGGLE		UINT32_C(0x1)
-	/* This field defines the type of SQ WQE. */
-	#define CQ_RES_UD_CFA_CQE_TYPE_MASK	UINT32_C(0x1e)
-	#define CQ_RES_UD_CFA_CQE_TYPE_SFT	1
+	#define HCOMM_STATUS_VER_MASK	UINT32_C(0xff)
+	#define HCOMM_STATUS_VER_SFT	0
+		#define HCOMM_STATUS_VER_LATEST	UINT32_C(0x1)
+		#define HCOMM_STATUS_VER_LAST	HCOMM_STATUS_VER_LATEST
 	/*
-	 * Responder UD Completion with CFA - This is used for both RQ
-	 * and SRQ completion for UD service QPs. It includes cfa fields
-	 * (some of which carry VLAN information), in place of the QP
-	 * handle. It is also used for QP1 QPs that are treated as UD.
+	 * This field is to store the signature value to indicate the
+	 * presence of the structure.
 	 */
-		#define CQ_RES_UD_CFA_CQE_TYPE_RES_UD_CFA  (UINT32_C(0x4) << 1)
-		#define CQ_RES_UD_CFA_CQE_TYPE_LAST	CQ_RES_UD_CFA_CQE_TYPE_RES_UD_CFA
-	/* This field indicates the status for the CQE. */
-	uint8_t	status;
+	#define HCOMM_STATUS_SIGNATURE_MASK UINT32_C(0xffffff00)
+	#define HCOMM_STATUS_SIGNATURE_SFT 8
+		#define HCOMM_STATUS_SIGNATURE_VAL   (UINT32_C(0x484353) << 8)
+		#define HCOMM_STATUS_SIGNATURE_LAST HCOMM_STATUS_SIGNATURE_VAL
+	uint32_t	fw_status_loc;
+	#define HCOMM_STATUS_TRUE_ADDR_SPACE_MASK	UINT32_C(0x3)
+	#define HCOMM_STATUS_TRUE_ADDR_SPACE_SFT	0
+	/* PCIE configuration space */
+		#define HCOMM_STATUS_FW_STATUS_LOC_ADDR_SPACE_PCIE_CFG  UINT32_C(0x0)
+	/* GRC space */
+		#define HCOMM_STATUS_FW_STATUS_LOC_ADDR_SPACE_GRC	UINT32_C(0x1)
+	/* BAR0 space */
+		#define HCOMM_STATUS_FW_STATUS_LOC_ADDR_SPACE_BAR0	UINT32_C(0x2)
+	/* BAR1 space */
+		#define HCOMM_STATUS_FW_STATUS_LOC_ADDR_SPACE_BAR1	UINT32_C(0x3)
+		#define HCOMM_STATUS_FW_STATUS_LOC_ADDR_SPACE_LAST	HCOMM_STATUS_FW_STATUS_LOC_ADDR_SPACE_BAR1
 	/*
-	 * This indicates that the completion is without error.
-	 * All fields are valid.
+	 * This offset where the fw_status register is located. The value
+	 * is generally 4-byte aligned.
 	 */
-	#define CQ_RES_UD_CFA_STATUS_OK			UINT32_C(0x0)
+	#define HCOMM_STATUS_TRUE_OFFSET_MASK	UINT32_C(0xfffffffc)
+	#define HCOMM_STATUS_TRUE_OFFSET_SFT	2
+} hcomm_status_t, *phcomm_status_t;
+
+/* This is the GRC offset where the hcomm_status struct resides. */
+#define HCOMM_STATUS_STRUCT_LOC 0x31001F0UL
+
+/***********************
+ * hwrm_selftest_qlist *
+ ***********************/
+
+
+/* hwrm_selftest_qlist_input (size:128b/16B) */
+
+typedef struct hwrm_selftest_qlist_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * This indicates that write access was not allowed for
-	 * at least one of the SGEs in the WQE.
-	 *
-	 * This is a fatal error. Only the srq_or_rq_wr_id is field
-	 * is valid.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define CQ_RES_UD_CFA_STATUS_LOCAL_ACCESS_ERROR	UINT32_C(0x1)
+	uint16_t	cmpl_ring;
 	/*
-	 * This indicates that the packet was too long for the WQE
-	 * provided on the SRQ/RQ.
-	 *
-	 * This is not a fatal error. All the fields are valid.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define CQ_RES_UD_CFA_STATUS_HW_LOCAL_LENGTH_ERR	UINT32_C(0x2)
-	/* LOCAL_PROTECTION_ERR is 3 */
-	#define CQ_RES_UD_CFA_STATUS_LOCAL_PROTECTION_ERR	UINT32_C(0x3)
-	/* LOCAL_QP_OPERATION_ERR is 4 */
-	#define CQ_RES_UD_CFA_STATUS_LOCAL_QP_OPERATION_ERR   UINT32_C(0x4)
-	/* MEMORY_MGT_OPERATION_ERR is 5 */
-	#define CQ_RES_UD_CFA_STATUS_MEMORY_MGT_OPERATION_ERR UINT32_C(0x5)
-	/* WORK_REQUEST_FLUSHED_ERR is 7 */
-	#define CQ_RES_UD_CFA_STATUS_WORK_REQUEST_FLUSHED_ERR UINT32_C(0x7)
-	/* HW_FLUSH_ERR is 8 */
-	#define CQ_RES_UD_CFA_STATUS_HW_FLUSH_ERR		UINT32_C(0x8)
-	#define CQ_RES_UD_CFA_STATUS_LAST			CQ_RES_UD_CFA_STATUS_HW_FLUSH_ERR
-	uint16_t	flags;
+	uint16_t	seq_id;
 	/*
-	 * This flag indicates that the completion is for a SRQ entry
-	 * rather than for an RQ entry.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define CQ_RES_UD_CFA_FLAGS_SRQ		UINT32_C(0x1)
-	/* CQE relates to RQ WQE. */
-		#define CQ_RES_UD_CFA_FLAGS_SRQ_RQ		UINT32_C(0x0)
-	/* CQE relates to SRQ WQE. */
-		#define CQ_RES_UD_CFA_FLAGS_SRQ_SRQ		UINT32_C(0x1)
-		#define CQ_RES_UD_CFA_FLAGS_SRQ_LAST		CQ_RES_UD_CFA_FLAGS_SRQ_SRQ
-	/* Immediate data indicator */
-	#define CQ_RES_UD_CFA_FLAGS_IMM		UINT32_C(0x2)
-	#define CQ_RES_UD_CFA_FLAGS_UNUSED_MASK	UINT32_C(0xc)
-	#define CQ_RES_UD_CFA_FLAGS_UNUSED_SFT		2
-	#define CQ_RES_UD_CFA_FLAGS_ROCE_IP_VER_MASK	UINT32_C(0x30)
-	#define CQ_RES_UD_CFA_FLAGS_ROCE_IP_VER_SFT	4
-	/* RoCEv1 Message */
-		#define CQ_RES_UD_CFA_FLAGS_ROCE_IP_VER_V1	(UINT32_C(0x0) << 4)
-	/* RoCEv2 IPv4 Message */
-		#define CQ_RES_UD_CFA_FLAGS_ROCE_IP_VER_V2IPV4	(UINT32_C(0x2) << 4)
-	/* RoCEv2 IPv6 Message */
-		#define CQ_RES_UD_CFA_FLAGS_ROCE_IP_VER_V2IPV6	(UINT32_C(0x3) << 4)
-		#define CQ_RES_UD_CFA_FLAGS_ROCE_IP_VER_LAST	CQ_RES_UD_CFA_FLAGS_ROCE_IP_VER_V2IPV6
+	uint16_t	target_id;
 	/*
-	 * The combination of this value and ext_meta_format indicates
-	 * what format the metadata field is.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define CQ_RES_UD_CFA_FLAGS_META_FORMAT_MASK	UINT32_C(0x3c0)
-	#define CQ_RES_UD_CFA_FLAGS_META_FORMAT_SFT	6
+	uint64_t	resp_addr;
+} hwrm_selftest_qlist_input_t, *phwrm_selftest_qlist_input_t;
+
+/* hwrm_selftest_qlist_output (size:2240b/280B) */
+
+typedef struct hwrm_selftest_qlist_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
 	/*
-	 * If ext_meta_format is equal to 0, there is no metadata
-	 * information. Value is zero.
+	 * This field represents the number of tests available to be
+	 * requested by a driver.
+	 */
+	uint8_t	num_tests;
+	/* This field indicates which self-test is available to be run. */
+	uint8_t	available_tests;
+	/* Can run the NVM test. */
+	#define HWRM_SELFTEST_QLIST_OUTPUT_AVAILABLE_TESTS_NVM_TEST		UINT32_C(0x1)
+	/* Can run the link test. */
+	#define HWRM_SELFTEST_QLIST_OUTPUT_AVAILABLE_TESTS_LINK_TEST		UINT32_C(0x2)
+	/* Can run the register test. */
+	#define HWRM_SELFTEST_QLIST_OUTPUT_AVAILABLE_TESTS_REGISTER_TEST		UINT32_C(0x4)
+	/* Can run the memory test. */
+	#define HWRM_SELFTEST_QLIST_OUTPUT_AVAILABLE_TESTS_MEMORY_TEST		UINT32_C(0x8)
+	/* Can run the PCIe serdes test. */
+	#define HWRM_SELFTEST_QLIST_OUTPUT_AVAILABLE_TESTS_PCIE_SERDES_TEST	UINT32_C(0x10)
+	/* Can run the Ethernet serdes test. */
+	#define HWRM_SELFTEST_QLIST_OUTPUT_AVAILABLE_TESTS_ETHERNET_SERDES_TEST	UINT32_C(0x20)
+	uint8_t	offline_tests;
+	/* The NVM test is an offline test. */
+	#define HWRM_SELFTEST_QLIST_OUTPUT_OFFLINE_TESTS_NVM_TEST		UINT32_C(0x1)
+	/* The link test is an offline test. */
+	#define HWRM_SELFTEST_QLIST_OUTPUT_OFFLINE_TESTS_LINK_TEST		UINT32_C(0x2)
+	/* The register test is an offline test. */
+	#define HWRM_SELFTEST_QLIST_OUTPUT_OFFLINE_TESTS_REGISTER_TEST		UINT32_C(0x4)
+	/* The memory test is an offline test. */
+	#define HWRM_SELFTEST_QLIST_OUTPUT_OFFLINE_TESTS_MEMORY_TEST		UINT32_C(0x8)
+	/* The PCIe serdes test is an offline test. */
+	#define HWRM_SELFTEST_QLIST_OUTPUT_OFFLINE_TESTS_PCIE_SERDES_TEST	UINT32_C(0x10)
+	/* The Ethernet serdes test is an offline test. */
+	#define HWRM_SELFTEST_QLIST_OUTPUT_OFFLINE_TESTS_ETHERNET_SERDES_TEST	UINT32_C(0x20)
+	uint8_t	unused_0;
+	/*
+	 * This field represents the maximum timeout for all the
+	 * tests to complete in milliseconds.
 	 */
-		#define CQ_RES_UD_CFA_FLAGS_META_FORMAT_NONE	(UINT32_C(0x0) << 6)
+	uint16_t	test_timeout;
+	uint8_t	unused_1[2];
 	/*
-	 * If ext_meta_format is equal to 0, the metadata field contains
-	 * the VLAN tag and TPID value.
-	 * - metadata[11:0] contains the vlan VID value.
-	 * - metadata[12] contains the vlan DE value.
-	 * - metadata[15:13] contains the vlan PRI value.
-	 * - metadata[31:16] contains the vlan TPID value.
+	 * This field represents array of 8 test name strings (ASCII chars
+	 * with NULL at the end).
 	 */
-		#define CQ_RES_UD_CFA_FLAGS_META_FORMAT_VLAN	(UINT32_C(0x1) << 6)
+	char	test_name[8][32];
+	/*
+	 * The lowest available target BER that is supported by FW eyescope.
+	 * A Value of 3 indicates that FW supports 1e-8, 1e-9, 1e-10, and
+	 * 1e-11.
+	 */
+	uint8_t	eyescope_target_BER_support;
+	/* Eyescope supports a target BER of 1e-8 */
+	#define HWRM_SELFTEST_QLIST_OUTPUT_EYESCOPE_TARGET_BER_SUPPORT_BER_1E8_SUPPORTED  UINT32_C(0x0)
+	/* Eyescope supports a target BER of 1e-9 */
+	#define HWRM_SELFTEST_QLIST_OUTPUT_EYESCOPE_TARGET_BER_SUPPORT_BER_1E9_SUPPORTED  UINT32_C(0x1)
+	/* Eyescope supports a target BER of 1e-10 */
+	#define HWRM_SELFTEST_QLIST_OUTPUT_EYESCOPE_TARGET_BER_SUPPORT_BER_1E10_SUPPORTED UINT32_C(0x2)
+	/* Eyescope supports a target BER of 1e-11 */
+	#define HWRM_SELFTEST_QLIST_OUTPUT_EYESCOPE_TARGET_BER_SUPPORT_BER_1E11_SUPPORTED UINT32_C(0x3)
+	/* Eyescope supports a target BER of 1e-12 */
+	#define HWRM_SELFTEST_QLIST_OUTPUT_EYESCOPE_TARGET_BER_SUPPORT_BER_1E12_SUPPORTED UINT32_C(0x4)
+	#define HWRM_SELFTEST_QLIST_OUTPUT_EYESCOPE_TARGET_BER_SUPPORT_LAST		HWRM_SELFTEST_QLIST_OUTPUT_EYESCOPE_TARGET_BER_SUPPORT_BER_1E12_SUPPORTED
+	uint8_t	unused_2[6];
 	/*
-	 * If ext_meta_format is equal to 1, the metadata field contains
-	 * the Tunnel ID value, justified to LSB.
-	 * - VXLAN = VNI[23:0] -> VXLAN Network ID
-	 * - Geneve (NGE) = VNI[23:0] -> Virtual Network Identifier
-	 * - NVGRE = TNI[23:0] -> Tenant Network ID
-	 * - GRE = KEY[31:0] -> key field with bit mask. zero if K = 0
-	 * - IPV4 = 0 (not populated)
-	 * - IPV6 = Flow Label[19:0]
-	 * - PPPoE = sessionID[15:0]
-	 * - MPLs = Outer label[19:0]
-	 * - UPAR = Selected[31:0] with bit mask
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-		#define CQ_RES_UD_CFA_FLAGS_META_FORMAT_TUNNEL_ID   (UINT32_C(0x2) << 6)
+	uint8_t	valid;
+} hwrm_selftest_qlist_output_t, *phwrm_selftest_qlist_output_t;
+
+/**********************
+ * hwrm_selftest_exec *
+ **********************/
+
+
+/* hwrm_selftest_exec_input (size:192b/24B) */
+
+typedef struct hwrm_selftest_exec_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * if ext_meta_format is equal to 1, metadata field contains
-	 * 16b metadata from the prepended header (chdr_data).
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-		#define CQ_RES_UD_CFA_FLAGS_META_FORMAT_CHDR_DATA   (UINT32_C(0x3) << 6)
+	uint16_t	cmpl_ring;
 	/*
-	 * If ext_meta_format is equal to 1, the metadata field contains
-	 * the outer_l3_offset, inner_l2_offset, inner_l3_offset, and
-	 * inner_l4_size.
-	 * - metadata[8:0] contains the outer_l3_offset.
-	 * - metadata[17:9] contains the inner_l2_offset.
-	 * - metadata[26:18] contains the inner_l3_offset.
-	 * - metadata[31:27] contains the inner_l4_size.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-		#define CQ_RES_UD_CFA_FLAGS_META_FORMAT_HDR_OFFSET  (UINT32_C(0x4) << 6)
-		#define CQ_RES_UD_CFA_FLAGS_META_FORMAT_LAST	CQ_RES_UD_CFA_FLAGS_META_FORMAT_HDR_OFFSET
+	uint16_t	seq_id;
 	/*
-	 * The combination of this value and meta_format indicates what
-	 * format the metadata field is
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define CQ_RES_UD_CFA_FLAGS_EXT_META_FORMAT_MASK  UINT32_C(0xc00)
-	#define CQ_RES_UD_CFA_FLAGS_EXT_META_FORMAT_SFT   10
-	uint32_t	src_qp_high_srq_or_rq_wr_id;
+	uint16_t	target_id;
 	/*
-	 * Opaque value from RQ or SRQ WQE. Used by driver/lib to
-	 * reference the WQE in order to claim the received data
-	 * and reuse the WQE space
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define CQ_RES_UD_CFA_SRQ_OR_RQ_WR_ID_MASK UINT32_C(0xfffff)
-	#define CQ_RES_UD_CFA_SRQ_OR_RQ_WR_ID_SFT 0
-	/* Upper 8b of the Source QP value from the DETH header. */
-	#define CQ_RES_UD_CFA_SRC_QP_HIGH_MASK	UINT32_C(0xff000000)
-	#define CQ_RES_UD_CFA_SRC_QP_HIGH_SFT	24
-} cq_res_ud_cfa_t, *pcq_res_ud_cfa_t;
+	uint64_t	resp_addr;
+	/* This field indicates which self-test is being requested to run. */
+	uint8_t	flags;
+	/* Run the NVM test. */
+	#define HWRM_SELFTEST_EXEC_INPUT_FLAGS_NVM_TEST		UINT32_C(0x1)
+	/* Run the link test. */
+	#define HWRM_SELFTEST_EXEC_INPUT_FLAGS_LINK_TEST		UINT32_C(0x2)
+	/* Run the register test. */
+	#define HWRM_SELFTEST_EXEC_INPUT_FLAGS_REGISTER_TEST		UINT32_C(0x4)
+	/* Run the memory test. */
+	#define HWRM_SELFTEST_EXEC_INPUT_FLAGS_MEMORY_TEST		UINT32_C(0x8)
+	/* Run the PCIe serdes test. */
+	#define HWRM_SELFTEST_EXEC_INPUT_FLAGS_PCIE_SERDES_TEST	UINT32_C(0x10)
+	/* Run the Ethernet serdes test. */
+	#define HWRM_SELFTEST_EXEC_INPUT_FLAGS_ETHERNET_SERDES_TEST	UINT32_C(0x20)
+	uint8_t	unused_0[7];
+} hwrm_selftest_exec_input_t, *phwrm_selftest_exec_input_t;
 
-/* Responder UD with CFA CQE version 2 */
-/* cq_res_ud_cfa_v2 (size:256b/32B) */
+/* hwrm_selftest_exec_output (size:128b/16B) */
 
-typedef struct cq_res_ud_cfa_v2 {
-	uint16_t	length;
+typedef struct hwrm_selftest_exec_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* The following tests were requested to be run. */
+	uint8_t	requested_tests;
+	/* A request was made to run the NVM test. */
+	#define HWRM_SELFTEST_EXEC_OUTPUT_REQUESTED_TESTS_NVM_TEST		UINT32_C(0x1)
+	/* A request was made to run the link test. */
+	#define HWRM_SELFTEST_EXEC_OUTPUT_REQUESTED_TESTS_LINK_TEST		UINT32_C(0x2)
+	/* A request was made to run the register test. */
+	#define HWRM_SELFTEST_EXEC_OUTPUT_REQUESTED_TESTS_REGISTER_TEST		UINT32_C(0x4)
+	/* A request was made to run the memory test. */
+	#define HWRM_SELFTEST_EXEC_OUTPUT_REQUESTED_TESTS_MEMORY_TEST		UINT32_C(0x8)
+	/* A request was made to run the PCIe serdes test. */
+	#define HWRM_SELFTEST_EXEC_OUTPUT_REQUESTED_TESTS_PCIE_SERDES_TEST	UINT32_C(0x10)
+	/* A request was made to run the Ethernet serdes test. */
+	#define HWRM_SELFTEST_EXEC_OUTPUT_REQUESTED_TESTS_ETHERNET_SERDES_TEST	UINT32_C(0x20)
 	/*
-	 * The length of the message's payload in bytes, stored in
-	 * the SGEs
+	 * If a test was requested to be run as seen in the requested_tests
+	 * field, this bit indicates whether the test was successful(1) or
+	 * failed(0).
 	 */
-	#define CQ_RES_UD_CFA_V2_LENGTH_MASK UINT32_C(0x3fff)
-	#define CQ_RES_UD_CFA_V2_LENGTH_SFT 0
-	/* This is data from the CFA as indicated by the meta_format field. */
-	uint16_t	cfa_metadata0;
-	/* When meta_format=1, this value is the VLAN VID. */
-	#define CQ_RES_UD_CFA_V2_CFA_METADATA0_VID_MASK UINT32_C(0xfff)
-	#define CQ_RES_UD_CFA_V2_CFA_METADATA0_VID_SFT 0
-	/* When meta_format=1, this value is the VLAN DE. */
-	#define CQ_RES_UD_CFA_V2_CFA_METADATA0_DE	UINT32_C(0x1000)
-	/* When meta_format=1, this value is the VLAN PRI. */
-	#define CQ_RES_UD_CFA_V2_CFA_METADATA0_PRI_MASK UINT32_C(0xe000)
-	#define CQ_RES_UD_CFA_V2_CFA_METADATA0_PRI_SFT 13
-	/* Immediate data in case the imm_flag set. */
-	uint32_t	imm_data;
-	uint32_t	qid;
+	uint8_t	test_success;
 	/*
-	 * This value indicates the QPID associated with this operation.
-	 * The driver will use the qid from thie CQE to map a QP handle
-	 * in the completion record returned to the application.
+	 * If requested, a value of 1 indicates the NVM test completed
+	 * successfully.
 	 */
-	#define CQ_RES_UD_CFA_V2_QID_MASK UINT32_C(0xfffff)
-	#define CQ_RES_UD_CFA_V2_QID_SFT 0
+	#define HWRM_SELFTEST_EXEC_OUTPUT_TEST_SUCCESS_NVM_TEST		UINT32_C(0x1)
 	/*
-	 * This is data from the CFA block as indicated by the meta_format
-	 * field.
-	 * - meta_format 0 - none - metadata2 = 0 - not valid/not stripped
-	 * - meta_format 1 - act_rec_ptr - metadata2 = {table_scope[5:0],
-	 *   act_rec_ptr[25:0]}
-	 * - meta_format 2 - tunnel_id - metadata2 = tunnel_id[31:0]
-	 * - meta_format 3 - chdr_data - metadata2 = updated_chdr_data[31:0]
-	 * - meta_format 4 - hdr_offsets - metadata2 = hdr_offsets[31:0]
-	 * When vee_cmpl_mode is set in VNIC context, this is the upper 32b
-	 * of the host address from the first BD used to place the packet.
+	 * If requested, a value of 1 indicates the link test completed
+	 * successfully.
 	 */
-	uint32_t	cfa_metadata2;
+	#define HWRM_SELFTEST_EXEC_OUTPUT_TEST_SUCCESS_LINK_TEST		UINT32_C(0x2)
 	/*
-	 * Source MAC address for the UD message placed in the WQE
-	 * that is completed by this CQE.
+	 * If requested, a value of 1 indicates the register test completed
+	 * successfully.
 	 */
-	uint16_t	src_mac[3];
-	/* Lower 16b of the Source QP value from the DETH header. */
-	uint16_t	src_qp_low;
-	uint8_t	cqe_type_toggle;
+	#define HWRM_SELFTEST_EXEC_OUTPUT_TEST_SUCCESS_REGISTER_TEST		UINT32_C(0x4)
 	/*
-	 * Indicate valid completion - written by the chip. Cumulus
-	 * toggle this bit each time it finished consuming all PBL
-	 * entries
+	 * If requested, a value of 1 indicates the memory test completed
+	 * successfully.
 	 */
-	#define CQ_RES_UD_CFA_V2_TOGGLE		UINT32_C(0x1)
-	/* This field defines the type of SQ WQE. */
-	#define CQ_RES_UD_CFA_V2_CQE_TYPE_MASK	UINT32_C(0x1e)
-	#define CQ_RES_UD_CFA_V2_CQE_TYPE_SFT	1
+	#define HWRM_SELFTEST_EXEC_OUTPUT_TEST_SUCCESS_MEMORY_TEST		UINT32_C(0x8)
 	/*
-	 * Responder UD Completion with CFA - This is used for both RQ
-	 * and SRQ completion for UD service QPs. It includes cfa fields
-	 * (some of which carry VLAN information), in place of the QP
-	 * handle. It is also used for QP1 QPs that are treated as UD.
+	 * If requested, a value of 1 indicates the PCIe serdes test
+	 * completed successfully.
 	 */
-		#define CQ_RES_UD_CFA_V2_CQE_TYPE_RES_UD_CFA  (UINT32_C(0x4) << 1)
-		#define CQ_RES_UD_CFA_V2_CQE_TYPE_LAST	CQ_RES_UD_CFA_V2_CQE_TYPE_RES_UD_CFA
-	/* This field indicates the status for the CQE. */
-	uint8_t	status;
+	#define HWRM_SELFTEST_EXEC_OUTPUT_TEST_SUCCESS_PCIE_SERDES_TEST	UINT32_C(0x10)
 	/*
-	 * This indicates that the completion is without error.
-	 * All fields are valid.
+	 * If requested, a value of 1 indicates the Ethernet serdes test
+	 * completed successfully.
 	 */
-	#define CQ_RES_UD_CFA_V2_STATUS_OK			UINT32_C(0x0)
+	#define HWRM_SELFTEST_EXEC_OUTPUT_TEST_SUCCESS_ETHERNET_SERDES_TEST	UINT32_C(0x20)
+	uint8_t	unused_0[5];
 	/*
-	 * This indicates that write access was not allowed for
-	 * at least one of the SGEs in the WQE.
-	 *
-	 * This is a fatal error. Only the srq_or_rq_wr_id is field
-	 * is valid.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	#define CQ_RES_UD_CFA_V2_STATUS_LOCAL_ACCESS_ERROR	UINT32_C(0x1)
+	uint8_t	valid;
+} hwrm_selftest_exec_output_t, *phwrm_selftest_exec_output_t;
+
+/*********************
+ * hwrm_selftest_irq *
+ *********************/
+
+
+/* hwrm_selftest_irq_input (size:128b/16B) */
+
+typedef struct hwrm_selftest_irq_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * This indicates that the packet was too long for the WQE
-	 * provided on the SRQ/RQ.
-	 *
-	 * This is not a fatal error. All the fields are valid.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define CQ_RES_UD_CFA_V2_STATUS_HW_LOCAL_LENGTH_ERR	UINT32_C(0x2)
-	/* LOCAL_PROTECTION_ERR is 3 */
-	#define CQ_RES_UD_CFA_V2_STATUS_LOCAL_PROTECTION_ERR	UINT32_C(0x3)
-	/* LOCAL_QP_OPERATION_ERR is 4 */
-	#define CQ_RES_UD_CFA_V2_STATUS_LOCAL_QP_OPERATION_ERR   UINT32_C(0x4)
-	/* MEMORY_MGT_OPERATION_ERR is 5 */
-	#define CQ_RES_UD_CFA_V2_STATUS_MEMORY_MGT_OPERATION_ERR UINT32_C(0x5)
-	/* WORK_REQUEST_FLUSHED_ERR is 7 */
-	#define CQ_RES_UD_CFA_V2_STATUS_WORK_REQUEST_FLUSHED_ERR UINT32_C(0x7)
-	/* HW_FLUSH_ERR is 8 */
-	#define CQ_RES_UD_CFA_V2_STATUS_HW_FLUSH_ERR		UINT32_C(0x8)
-	#define CQ_RES_UD_CFA_V2_STATUS_LAST			CQ_RES_UD_CFA_V2_STATUS_HW_FLUSH_ERR
-	uint16_t	flags;
+	uint16_t	cmpl_ring;
 	/*
-	 * This flag indicates that the completion is for a SRQ entry
-	 * rather than for an RQ entry.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define CQ_RES_UD_CFA_V2_FLAGS_SRQ			UINT32_C(0x1)
-	/* CQE relates to RQ WQE. */
-		#define CQ_RES_UD_CFA_V2_FLAGS_SRQ_RQ		UINT32_C(0x0)
-	/* CQE relates to SRQ WQE. */
-		#define CQ_RES_UD_CFA_V2_FLAGS_SRQ_SRQ		UINT32_C(0x1)
-		#define CQ_RES_UD_CFA_V2_FLAGS_SRQ_LAST		CQ_RES_UD_CFA_V2_FLAGS_SRQ_SRQ
-	/* Immediate data indicator */
-	#define CQ_RES_UD_CFA_V2_FLAGS_IMM			UINT32_C(0x2)
-	#define CQ_RES_UD_CFA_V2_FLAGS_UNUSED_MASK		UINT32_C(0xc)
-	#define CQ_RES_UD_CFA_V2_FLAGS_UNUSED_SFT		2
-	#define CQ_RES_UD_CFA_V2_FLAGS_ROCE_IP_VER_MASK	UINT32_C(0x30)
-	#define CQ_RES_UD_CFA_V2_FLAGS_ROCE_IP_VER_SFT	4
-	/* RoCEv1 Message */
-		#define CQ_RES_UD_CFA_V2_FLAGS_ROCE_IP_VER_V1	(UINT32_C(0x0) << 4)
-	/* RoCEv2 IPv4 Message */
-		#define CQ_RES_UD_CFA_V2_FLAGS_ROCE_IP_VER_V2IPV4	(UINT32_C(0x2) << 4)
-	/* RoCEv2 IPv6 Message */
-		#define CQ_RES_UD_CFA_V2_FLAGS_ROCE_IP_VER_V2IPV6	(UINT32_C(0x3) << 4)
-		#define CQ_RES_UD_CFA_V2_FLAGS_ROCE_IP_VER_LAST	CQ_RES_UD_CFA_V2_FLAGS_ROCE_IP_VER_V2IPV6
-	/* The field indicates what format the metadata field is. */
-	#define CQ_RES_UD_CFA_V2_FLAGS_META_FORMAT_MASK	UINT32_C(0x3c0)
-	#define CQ_RES_UD_CFA_V2_FLAGS_META_FORMAT_SFT	6
-	/* No metadata information.  Value is zero. */
-		#define CQ_RES_UD_CFA_V2_FLAGS_META_FORMAT_NONE	(UINT32_C(0x0) << 6)
+	uint16_t	seq_id;
 	/*
-	 * The {metadata1, metadata0} fields contain the vtag
-	 * information: - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0],
-	 * de, vid[11:0]} The metadata2 field contains the table scope
-	 * and action record pointer. - metadata2[25:0] contains the
-	 * action record pointer. - metadata2[31:26] contains the table
-	 * scope.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-		#define CQ_RES_UD_CFA_V2_FLAGS_META_FORMAT_ACT_REC_PTR  (UINT32_C(0x1) << 6)
+	uint16_t	target_id;
 	/*
-	 * The {metadata1, metadata0} fields contain the vtag
-	 * information:
-	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0], de, vid[11:0]}
-	 * The metadata2 field contains the Tunnel ID
-	 * value, justified to LSB. i
-	 * - VXLAN = VNI[23:0] -> VXLAN Network ID
-	 * - Geneve (NGE) = VNI[23:0] a-> Virtual Network Identifier
-	 * - NVGRE = TNI[23:0] -> Tenant Network ID
-	 * - GRE = KEY[31:0] -> key field with bit mask. zero if K=0
-	 * - IPv4 = 0 (not populated)
-	 * - IPv6 = Flow Label[19:0]
-	 * - PPPoE = sessionID[15:0]
-	 * - MPLs = Outer label[19:0]
-	 * - UPAR = Selected[31:0] with bit mask
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-		#define CQ_RES_UD_CFA_V2_FLAGS_META_FORMAT_TUNNEL_ID	(UINT32_C(0x2) << 6)
+	uint64_t	resp_addr;
+} hwrm_selftest_irq_input_t, *phwrm_selftest_irq_input_t;
+
+/* hwrm_selftest_irq_output (size:128b/16B) */
+
+typedef struct hwrm_selftest_irq_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
 	/*
-	 * The {metadata1, metadata0} fields contain the vtag
-	 * information:
-	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0],de, vid[11:0]}
-	 * The metadata2 field contains the 32b metadata from the
-	 * prepended header (chdr_data).
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-		#define CQ_RES_UD_CFA_V2_FLAGS_META_FORMAT_CHDR_DATA	(UINT32_C(0x3) << 6)
+	uint8_t	valid;
+} hwrm_selftest_irq_output_t, *phwrm_selftest_irq_output_t;
+
+/**************************************
+ * hwrm_selftest_retrieve_serdes_data *
+ **************************************/
+
+
+/* hwrm_selftest_retrieve_serdes_data_input (size:320b/40B) */
+
+typedef struct hwrm_selftest_retrieve_serdes_data_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * If ext_meta_format is equal to 1, the metadata field contains
-	 * the outer_l3_offset and lower 7 bits of the inner_l2_offset,
-	 * - metadata[8:0] contains the outer_l3_offset.
-	 * - metadata[15:9] contains the inner_l2_offset[6:0]
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-		#define CQ_RES_UD_CFA_V2_FLAGS_META_FORMAT_HDR_OFFSET   (UINT32_C(0x4) << 6)
-		#define CQ_RES_UD_CFA_V2_FLAGS_META_FORMAT_LAST	CQ_RES_UD_CFA_V2_FLAGS_META_FORMAT_HDR_OFFSET
-	uint32_t	src_qp_high_srq_or_rq_wr_id;
+	uint16_t	cmpl_ring;
 	/*
-	 * Opaque value from RQ or SRQ WQE. Used by driver/lib to
-	 * reference the WQE in order to claim the received data
-	 * and reuse the WQE space
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define CQ_RES_UD_CFA_V2_SRQ_OR_RQ_WR_ID_MASK	UINT32_C(0xfffff)
-	#define CQ_RES_UD_CFA_V2_SRQ_OR_RQ_WR_ID_SFT		0
-	#define CQ_RES_UD_CFA_V2_CFA_METADATA1_MASK		UINT32_C(0xf00000)
-	#define CQ_RES_UD_CFA_V2_CFA_METADATA1_SFT		20
-	/* When meta_format != 0, this value is the VLAN TPID_SEL. */
-	#define CQ_RES_UD_CFA_V2_CFA_METADATA1_TPID_SEL_MASK	UINT32_C(0x700000)
-	#define CQ_RES_UD_CFA_V2_CFA_METADATA1_TPID_SEL_SFT	20
-	/* 0x88a8 */
-		#define CQ_RES_UD_CFA_V2_CFA_METADATA1_TPID_SEL_TPID88A8   (UINT32_C(0x0) << 20)
-	/* 0x8100 */
-		#define CQ_RES_UD_CFA_V2_CFA_METADATA1_TPID_SEL_TPID8100   (UINT32_C(0x1) << 20)
-	/* 0x9100 */
-		#define CQ_RES_UD_CFA_V2_CFA_METADATA1_TPID_SEL_TPID9100   (UINT32_C(0x2) << 20)
-	/* 0x9200 */
-		#define CQ_RES_UD_CFA_V2_CFA_METADATA1_TPID_SEL_TPID9200   (UINT32_C(0x3) << 20)
-	/* 0x9300 */
-		#define CQ_RES_UD_CFA_V2_CFA_METADATA1_TPID_SEL_TPID9300   (UINT32_C(0x4) << 20)
-	/* Value programmed in CFA VLANTPID register. */
-		#define CQ_RES_UD_CFA_V2_CFA_METADATA1_TPID_SEL_TPIDCFG	(UINT32_C(0x5) << 20)
-		#define CQ_RES_UD_CFA_V2_CFA_METADATA1_TPID_SEL_LAST	CQ_RES_UD_CFA_V2_CFA_METADATA1_TPID_SEL_TPIDCFG
-	/* When meta_format != 0, this value is the VLAN valid. */
-	#define CQ_RES_UD_CFA_V2_CFA_METADATA1_VALID		UINT32_C(0x800000)
-	/* Upper 8b of the Source QP value from the DETH header. */
-	#define CQ_RES_UD_CFA_V2_SRC_QP_HIGH_MASK		UINT32_C(0xff000000)
-	#define CQ_RES_UD_CFA_V2_SRC_QP_HIGH_SFT		24
-} cq_res_ud_cfa_v2_t, *pcq_res_ud_cfa_v2_t;
-
-/* Responder RawEth and QP1 CQE */
-/* cq_res_raweth_qp1 (size:256b/32B) */
-
-typedef struct cq_res_raweth_qp1 {
-	uint16_t	length;
+	uint16_t	seq_id;
 	/*
-	 * The length of the message's payload in bytes, stored in
-	 * the SGEs
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define CQ_RES_RAWETH_QP1_LENGTH_MASK UINT32_C(0x3fff)
-	#define CQ_RES_RAWETH_QP1_LENGTH_SFT 0
-	uint16_t	raweth_qp1_flags;
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_MASK		UINT32_C(0x3ff)
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_SFT		0
+	uint16_t	target_id;
 	/*
-	 * When this bit is '1', it indicates a packet that has an
-	 * error of some type.  Type of error is indicated in
-	 * raweth_qp1_errors.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ERROR		UINT32_C(0x1)
+	uint64_t	resp_addr;
+	/* Host address data is to DMA'd to. */
+	uint64_t	resp_data_addr;
 	/*
-	 * This value indicates what the inner packet determined for the
-	 * packet was.
+	 * This field contains the offset into the captured data to begin
+	 * copying the data to the host from. This should be set to 0 on the
+	 * initial call to this command.
 	 */
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_MASK		UINT32_C(0x3c0)
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_SFT		6
+	uint32_t	resp_data_offset;
 	/*
-	 * Not Known:
-	 * Indicates that the packet type was not known.
+	 * Size of the buffer pointed to by resp_data_addr. The firmware may
+	 * use this entire buffer or less than the entire buffer, but never
+	 * more.
 	 */
-		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_NOT_KNOWN	(UINT32_C(0x0) << 6)
+	uint16_t	data_len;
 	/*
-	 * IP Packet:
-	 * Indicates that the packet was an IP packet, but further
-	 * classification was not possible.
+	 * This field allows this command to request the individual serdes
+	 * tests to be run using this command.
 	 */
-		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_IP		(UINT32_C(0x1) << 6)
+	uint8_t	flags;
+	/* Unused. */
+	#define HWRM_SELFTEST_RETRIEVE_SERDES_DATA_INPUT_FLAGS_UNUSED_TEST_MASK	UINT32_C(0x7)
+	#define HWRM_SELFTEST_RETRIEVE_SERDES_DATA_INPUT_FLAGS_UNUSED_TEST_SFT	0
+	/* Display eye_projection */
+	#define HWRM_SELFTEST_RETRIEVE_SERDES_DATA_INPUT_FLAGS_EYE_PROJECTION	UINT32_C(0x8)
+	/* Run the PCIe serdes test. */
+	#define HWRM_SELFTEST_RETRIEVE_SERDES_DATA_INPUT_FLAGS_PCIE_SERDES_TEST	UINT32_C(0x10)
+	/* Run the Ethernet serdes test. */
+	#define HWRM_SELFTEST_RETRIEVE_SERDES_DATA_INPUT_FLAGS_ETHERNET_SERDES_TEST	UINT32_C(0x20)
+	uint8_t	options;
 	/*
-	 * TCP Packet:
-	 * Indicates that the packet was IP and TCP.
-	 * This indicates that the raweth_qp1_payload_offset field is valid.
+	 * This field represents the PCIE lane number on which tools wants to
+	 * retrieve eye plot. This field is valid only when 'pcie_serdes_test'
+	 * flag is set.
+	 * Valid values from 0 to 16.
+	 */
+	#define HWRM_SELFTEST_RETRIEVE_SERDES_DATA_INPUT_OPTIONS_PCIE_LANE_NO_MASK	UINT32_C(0xf)
+	#define HWRM_SELFTEST_RETRIEVE_SERDES_DATA_INPUT_OPTIONS_PCIE_LANE_NO_SFT	0
+	/* This value indicates the Horizontal or vertical plot direction. */
+	#define HWRM_SELFTEST_RETRIEVE_SERDES_DATA_INPUT_OPTIONS_DIRECTION		UINT32_C(0x10)
+	/* Value 0 indicates Horizontal plot request. */
+		#define HWRM_SELFTEST_RETRIEVE_SERDES_DATA_INPUT_OPTIONS_DIRECTION_HORIZONTAL	(UINT32_C(0x0) << 4)
+	/* Value 1 indicates vertical plot request. */
+		#define HWRM_SELFTEST_RETRIEVE_SERDES_DATA_INPUT_OPTIONS_DIRECTION_VERTICAL	(UINT32_C(0x1) << 4)
+		#define HWRM_SELFTEST_RETRIEVE_SERDES_DATA_INPUT_OPTIONS_DIRECTION_LAST	HWRM_SELFTEST_RETRIEVE_SERDES_DATA_INPUT_OPTIONS_DIRECTION_VERTICAL
+	/* This value indicates eye projection type */
+	#define HWRM_SELFTEST_RETRIEVE_SERDES_DATA_INPUT_OPTIONS_PROJ_TYPE		UINT32_C(0x20)
+	/*
+	 * Value 0 indicates left/top projection in horizontal/vertical
+	 * This value is valid only when eye_projection flag was set.
+	 */
+		#define HWRM_SELFTEST_RETRIEVE_SERDES_DATA_INPUT_OPTIONS_PROJ_TYPE_LEFT_TOP	(UINT32_C(0x0) << 5)
+	/*
+	 * Value 1 indicates right/bottom projection in
+	 * horizontal/vertical. This value is valid only when
+	 * eye_projection flag was set.
+	 */
+		#define HWRM_SELFTEST_RETRIEVE_SERDES_DATA_INPUT_OPTIONS_PROJ_TYPE_RIGHT_BOTTOM  (UINT32_C(0x1) << 5)
+		#define HWRM_SELFTEST_RETRIEVE_SERDES_DATA_INPUT_OPTIONS_PROJ_TYPE_LAST	HWRM_SELFTEST_RETRIEVE_SERDES_DATA_INPUT_OPTIONS_PROJ_TYPE_RIGHT_BOTTOM
+	/* Reserved for future. */
+	#define HWRM_SELFTEST_RETRIEVE_SERDES_DATA_INPUT_OPTIONS_RSVD_MASK		UINT32_C(0xc0)
+	#define HWRM_SELFTEST_RETRIEVE_SERDES_DATA_INPUT_OPTIONS_RSVD_SFT		6
+	/*
+	 * This field allows this command to request a specific targetBER
+	 * to be run using this command.
 	 */
-		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_TCP		(UINT32_C(0x2) << 6)
+	uint8_t	targetBER;
+	/* When collecting an eyescope, measure with a target BER of 1e-8 */
+	#define HWRM_SELFTEST_RETRIEVE_SERDES_DATA_INPUT_TARGETBER_BER_1E8  UINT32_C(0x0)
+	/* When collecting an eyescope, measure with a target BER of 1e-9 */
+	#define HWRM_SELFTEST_RETRIEVE_SERDES_DATA_INPUT_TARGETBER_BER_1E9  UINT32_C(0x1)
+	/* When collecting an eyescope, measure with a target BER of 1e-10 */
+	#define HWRM_SELFTEST_RETRIEVE_SERDES_DATA_INPUT_TARGETBER_BER_1E10 UINT32_C(0x2)
+	/* When collecting an eyescope, measure with a target BER of 1e-11 */
+	#define HWRM_SELFTEST_RETRIEVE_SERDES_DATA_INPUT_TARGETBER_BER_1E11 UINT32_C(0x3)
+	/* When collecting an eyescope, measure with a target BER of 1e-12 */
+	#define HWRM_SELFTEST_RETRIEVE_SERDES_DATA_INPUT_TARGETBER_BER_1E12 UINT32_C(0x4)
+	#define HWRM_SELFTEST_RETRIEVE_SERDES_DATA_INPUT_TARGETBER_LAST	HWRM_SELFTEST_RETRIEVE_SERDES_DATA_INPUT_TARGETBER_BER_1E12
 	/*
-	 * UDP Packet:
-	 * Indicates that the packet was IP and UDP.
-	 * This indicates that the raweth_qp1_payload_offset field is valid.
+	 * This field allows this command to specify the action to take when
+	 * collecting an eyescope.
 	 */
-		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_UDP		(UINT32_C(0x3) << 6)
+	uint8_t	action;
 	/*
-	 * FCoE Packet:
-	 * Indicates that the packet was recognized as a FCoE.
-	 * This also indicates that the raweth_qp1_payload_offset field is valid.
+	 * Value 0 indicates that collection of the eyescope should be
+	 * returned synchronously in the output. This only applies to
+	 * a targetBER of 1e-8.
 	 */
-		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_FCOE		(UINT32_C(0x4) << 6)
+	#define HWRM_SELFTEST_RETRIEVE_SERDES_DATA_INPUT_ACTION_SYNCHRONOUS UINT32_C(0x0)
 	/*
-	 * RoCE Packet:
-	 * Indicates that the packet was recognized as a RoCE.
-	 * This also indicates that the raweth_qp1_payload_offset field is valid.
+	 * Value 1 indicates to the firmware to start the collection of the
+	 * eyescope.
 	 */
-		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_ROCE		(UINT32_C(0x5) << 6)
+	#define HWRM_SELFTEST_RETRIEVE_SERDES_DATA_INPUT_ACTION_START	UINT32_C(0x1)
 	/*
-	 * ICMP Packet:
-	 * Indicates that the packet was recognized as ICMP.
-	 * This indicates that the raweth_qp1_payload_offset field is valid.
+	 * Value 2 indicates to the firmware to respond with a progress
+	 * percentage of the current eyescope collection from 0.0 to 100.0.
 	 */
-		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_ICMP		(UINT32_C(0x7) << 6)
+	#define HWRM_SELFTEST_RETRIEVE_SERDES_DATA_INPUT_ACTION_PROGRESS	UINT32_C(0x2)
 	/*
-	 * PtP packet wo/timestamp:
-	 * Indicates that the packet was recognized as a PtP
-	 * packet.
+	 * Value 3 indicates to stop the eyescope. if the progress
+	 * percentage is 100.0, the data will be DMAed back to
+	 * resp_data_addr.
 	 */
-		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_PTP_WO_TIMESTAMP   (UINT32_C(0x8) << 6)
+	#define HWRM_SELFTEST_RETRIEVE_SERDES_DATA_INPUT_ACTION_STOP	UINT32_C(0x3)
+	#define HWRM_SELFTEST_RETRIEVE_SERDES_DATA_INPUT_ACTION_LAST	HWRM_SELFTEST_RETRIEVE_SERDES_DATA_INPUT_ACTION_STOP
+	uint8_t	unused[6];
+} hwrm_selftest_retrieve_serdes_data_input_t, *phwrm_selftest_retrieve_serdes_data_input_t;
+
+/* hwrm_selftest_retrieve_serdes_data_output (size:192b/24B) */
+
+typedef struct hwrm_selftest_retrieve_serdes_data_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Total length of stored data. */
+	uint16_t	total_data_len;
 	/*
-	 * PtP packet w/timestamp:
-	 * Indicates that the packet was recognized as a PtP
-	 * packet and that a timestamp was taken for the packet.
+	 * Amount of data DMA'd to host by this call. The driver can use this
+	 * field along with the total_data_len field above to determine the
+	 * value to write to the resp_data_offset field in the next call
+	 * if more than one call to these commands is required to retrieve all
+	 * the stored data.
 	 */
-		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_PTP_W_TIMESTAMP	(UINT32_C(0x9) << 6)
-		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_LAST		CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_PTP_W_TIMESTAMP
-	uint16_t	raweth_qp1_errors;
+	uint16_t	copied_data_len;
 	/*
-	 * This indicates that there was an error in the IP header
-	 * checksum.
+	 * Percentage of completion of collection of BER values from the
+	 * current eyescope operation in tenths of a percentage. 0 (0.0) to
+	 * 1000 (100.0).
 	 */
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_IP_CS_ERROR			UINT32_C(0x10)
+	uint16_t	progress_percent;
+	/* Timeout in seconds for timeout of an individual BER point. */
+	uint16_t	timeout;
+	uint8_t	flags;
 	/*
-	 * This indicates that there was an error in the TCP, UDP
-	 * or ICMP checksum.
+	 * This value indicates the structure of data returned by the
+	 * firmware when DMA'ed to resp_data_addr.
 	 */
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_L4_CS_ERROR			UINT32_C(0x20)
+	#define HWRM_SELFTEST_RETRIEVE_SERDES_DATA_OUTPUT_FLAGS_BIT_COUNT_TYPE		UINT32_C(0x1)
 	/*
-	 * This indicates that there was an error in the tunnel
-	 * IP header checksum.
+	 * Value 0 indicates that bit_count value is a raw total
+	 * such that BER = error_count / bit_count.
 	 */
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_IP_CS_ERROR			UINT32_C(0x40)
+		#define HWRM_SELFTEST_RETRIEVE_SERDES_DATA_OUTPUT_FLAGS_BIT_COUNT_TYPE_BIT_COUNT_TOTAL  UINT32_C(0x0)
 	/*
-	 * This indicates that there was an error in the tunnel
-	 * UDP checksum.
+	 * Value 1 indicates that bit count is a power of
+	 * 2 that bit_count is normalized to. A Value of 42 indicates
+	 * that BER = error_count / 2^42
 	 */
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_L4_CS_ERROR			UINT32_C(0x80)
+		#define HWRM_SELFTEST_RETRIEVE_SERDES_DATA_OUTPUT_FLAGS_BIT_COUNT_TYPE_BIT_COUNT_POW2   UINT32_C(0x1)
+		#define HWRM_SELFTEST_RETRIEVE_SERDES_DATA_OUTPUT_FLAGS_BIT_COUNT_TYPE_LAST		HWRM_SELFTEST_RETRIEVE_SERDES_DATA_OUTPUT_FLAGS_BIT_COUNT_TYPE_BIT_COUNT_POW2
+	/* Reserved for future. */
+	#define HWRM_SELFTEST_RETRIEVE_SERDES_DATA_OUTPUT_FLAGS_RSVD_MASK			UINT32_C(0xfe)
+	#define HWRM_SELFTEST_RETRIEVE_SERDES_DATA_OUTPUT_FLAGS_RSVD_SFT			1
+	uint8_t	unused_0;
 	/*
-	 * This indicates that there was a CRC error on either an FCoE
-	 * or RoCE packet.  The itype indicates the packet type.
+	 * Size of header prepended to the bit_count and error_count array.
+	 * Use this value to skip forward to the bit_count and error_count
+	 * array.
 	 */
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_CRC_ERROR			UINT32_C(0x100)
+	uint16_t	hdr_size;
+	uint8_t	unused_1[3];
 	/*
-	 * This indicates that there was an error in the tunnel
-	 * portion of the packet when this
-	 * field is non-zero.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_PKT_ERROR_MASK		UINT32_C(0xe00)
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_PKT_ERROR_SFT		9
+	uint8_t	valid;
+} hwrm_selftest_retrieve_serdes_data_output_t, *phwrm_selftest_retrieve_serdes_data_output_t;
+
+/******************************
+ * hwrm_mfg_fru_write_control *
+ ******************************/
+
+
+/* hwrm_mfg_fru_write_control_input (size:192b/24B) */
+
+typedef struct hwrm_mfg_fru_write_control_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * No additional error occurred on the tunnel portion
-	 * of the packet of the packet does not have a tunnel.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_PKT_ERROR_NO_ERROR		(UINT32_C(0x0) << 9)
+	uint16_t	cmpl_ring;
 	/*
-	 * Indicates that IP header version does not match
-	 * expectation from L2 Ethertype for IPv4 and IPv6
-	 * in the tunnel header.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_L3_BAD_VERSION	(UINT32_C(0x1) << 9)
+	uint16_t	seq_id;
 	/*
-	 * Indicates that header length is out of range in the
-	 * tunnel header. Valid for
-	 * IPv4.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_L3_BAD_HDR_LEN	(UINT32_C(0x2) << 9)
+	uint16_t	target_id;
 	/*
-	 * Indicates that the physical packet is shorter than that
-	 * claimed by the PPPoE header length for a tunnel PPPoE
-	 * packet.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_PKT_ERROR_TUNNEL_TOTAL_ERROR	(UINT32_C(0x3) << 9)
+	uint64_t	resp_addr;
 	/*
-	 * Indicates that physical packet is shorter than that claimed
-	 * by the tunnel l3 header length. Valid for IPv4, or IPv6
-	 * tunnel packet packets.
+	 * This field indicates the lock/unlock operation. 0 means Unlock and
+	 * 1 means Lock.
 	 */
-		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_IP_TOTAL_ERROR	(UINT32_C(0x4) << 9)
+	uint32_t	fru_lock;
+	uint32_t	unused_0;
+} hwrm_mfg_fru_write_control_input_t, *phwrm_mfg_fru_write_control_input_t;
+
+/* hwrm_mfg_fru_write_control_output (size:128b/16B) */
+
+typedef struct hwrm_mfg_fru_write_control_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
 	/*
-	 * Indicates that the physical packet is shorter than that
-	 * claimed by the tunnel UDP header length for a tunnel
-	 * UDP packet that is not fragmented.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_UDP_TOTAL_ERROR	(UINT32_C(0x5) << 9)
+	uint8_t	valid;
+} hwrm_mfg_fru_write_control_output_t, *phwrm_mfg_fru_write_control_output_t;
+
+/*************************
+ * hwrm_mfg_timers_query *
+ *************************/
+
+
+/* hwrm_mfg_timers_query_input (size:192b/24B) */
+
+typedef struct hwrm_mfg_timers_query_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * indicates that the IPv4 TTL or IPv6 hop limit check
-	 * have failed (e.g. TTL = 0) in the tunnel header. Valid
-	 * for IPv4, and IPv6.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_L3_BAD_TTL		(UINT32_C(0x6) << 9)
-		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_PKT_ERROR_LAST		CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_L3_BAD_TTL
+	uint16_t	cmpl_ring;
 	/*
-	 * This indicates that there was an error in the inner
-	 * portion of the packet when this
-	 * field is non-zero.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_MASK			UINT32_C(0xf000)
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_SFT			12
+	uint16_t	seq_id;
 	/*
-	 * No additional error occurred on the tunnel portion
-	 * of the packet of the packet does not have a tunnel.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_NO_ERROR		(UINT32_C(0x0) << 12)
+	uint16_t	target_id;
 	/*
-	 * Indicates that IP header version does not match
-	 * expectation from L2 Ethertype for IPv4 and IPv6 or that
-	 * option other than VFT was parsed on
-	 * FCoE packet.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_L3_BAD_VERSION		(UINT32_C(0x1) << 12)
+	uint64_t	resp_addr;
+	uint64_t	unused_0;
+} hwrm_mfg_timers_query_input_t, *phwrm_mfg_timers_query_input_t;
+
+/* hwrm_mfg_timers_query_output (size:192b/24B) */
+
+typedef struct hwrm_mfg_timers_query_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
 	/*
-	 * indicates that header length is out of range. Valid for
-	 * IPv4 and RoCE
+	 * This is free running counter value running at 1 usec per tick.
+	 * The value can wrap around. On error, a value of 0 on all ticks
+	 * will be returned.
 	 */
-		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_L3_BAD_HDR_LEN		(UINT32_C(0x2) << 12)
+	uint32_t	us_tick;
 	/*
-	 * indicates that the IPv4 TTL or IPv6 hop limit check
-	 * have failed (e.g. TTL = 0). Valid for IPv4, and IPv6
+	 * This is free running counter value running at 1 msec per tick.
+	 * The value can wrap around. On error, a value of 0 on all ticks
+	 * will be returned.
 	 */
-		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_L3_BAD_TTL		(UINT32_C(0x3) << 12)
+	uint32_t	ms_tick;
 	/*
-	 * Indicates that physical packet is shorter than that
-	 * claimed by the l3 header length. Valid for IPv4,
-	 * IPv6 packet or RoCE packets.
+	 * This is free running counter value running at 100 msec per tick.
+	 * The value can wrap around. On error, a value of 0 on all ticks
+	 * will be returned.
 	 */
-		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_IP_TOTAL_ERROR		(UINT32_C(0x4) << 12)
+	uint32_t	ms100_tick;
+	uint8_t	unused_0[3];
 	/*
-	 * Indicates that the physical packet is shorter than that
-	 * claimed by the UDP header length for a UDP packet that is
-	 * not fragmented.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_UDP_TOTAL_ERROR	(UINT32_C(0x5) << 12)
+	uint8_t	valid;
+} hwrm_mfg_timers_query_output_t, *phwrm_mfg_timers_query_output_t;
+
+/********************
+ * hwrm_mfg_otp_cfg *
+ ********************/
+
+
+/* hwrm_mfg_otp_cfg_input (size:256b/32B) */
+
+typedef struct hwrm_mfg_otp_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * Indicates that TCP header length > IP payload. Valid for
-	 * TCP packets only.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_L4_BAD_HDR_LEN		(UINT32_C(0x6) << 12)
-	/* Indicates that TCP header length < 5. Valid for TCP. */
-		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_L4_BAD_HDR_LEN_TOO_SMALL  (UINT32_C(0x7) << 12)
+	uint16_t	cmpl_ring;
 	/*
-	 * Indicates that TCP option headers result in a TCP header
-	 * size that does not match data offset in TCP header. Valid
-	 * for TCP.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_L4_BAD_OPT_LEN		(UINT32_C(0x8) << 12)
-		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_LAST			CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_L4_BAD_OPT_LEN
+	uint16_t	seq_id;
 	/*
-	 * This field identifies the CFA action rule that was used for this
-	 * packet.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint16_t	raweth_qp1_cfa_code;
+	uint16_t	target_id;
 	/*
-	 * This is an application level ID used to identify the
-	 * QP and its SQ and RQ.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint64_t	qp_handle;
-	uint32_t	raweth_qp1_flags2;
+	uint64_t	resp_addr;
+	uint16_t	enables;
 	/*
-	 * This indicates that the ip checksum was calculated for the
-	 * inner packet and that the ip_cs_error field indicates if there
-	 * was an error.
+	 * This bit must be '1' for the crid field to be
+	 * configured.
 	 */
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_IP_CS_CALC		UINT32_C(0x1)
+	#define HWRM_MFG_OTP_CFG_INPUT_ENABLES_CRID	UINT32_C(0x1)
 	/*
-	 * This indicates that the TCP, UDP or ICMP checksum was
-	 * calculated for the inner packet and that the l4_cs_error field
-	 * indicates if there was an error.
+	 * This bit must be '1' for the srt_rev_id field to be
+	 * configured.
 	 */
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_L4_CS_CALC		UINT32_C(0x2)
+	#define HWRM_MFG_OTP_CFG_INPUT_ENABLES_SRT_REV_ID	UINT32_C(0x2)
 	/*
-	 * This indicates that the ip checksum was calculated for the
-	 * tunnel header and that the t_ip_cs_error field indicates if there
-	 * was an error.
+	 * This bit must be '1' for the crt_rev_id field to be
+	 * configured.
 	 */
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_T_IP_CS_CALC		UINT32_C(0x4)
+	#define HWRM_MFG_OTP_CFG_INPUT_ENABLES_CRT_REV_ID	UINT32_C(0x4)
 	/*
-	 * This indicates that the UDP checksum was
-	 * calculated for the tunnel packet and that the t_l4_cs_error field
-	 * indicates if there was an error.
+	 * This bit must be '1' for the sbi_rev_id field to be
+	 * configured.
 	 */
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_T_L4_CS_CALC		UINT32_C(0x8)
-	/* This value indicates what format the raweth_qp1_metadata field is. */
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_META_FORMAT_MASK	UINT32_C(0xf0)
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_META_FORMAT_SFT		4
-	/* No metadata information.  Value is zero. */
-		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_META_FORMAT_NONE		(UINT32_C(0x0) << 4)
+	#define HWRM_MFG_OTP_CFG_INPUT_ENABLES_SBI_REV_ID	UINT32_C(0x8)
+	/* This field indicates the crid value to be set. */
+	uint16_t	crid_cfg_value;
+	/* This field indicates the srt rev id value to be set. */
+	uint16_t	srt_rev_id_cfg_value;
+	/* This field indicates the crt rev id value to be set. */
+	uint16_t	crt_rev_id_cfg_value;
+	/* This field indicates the sbi rev id value to be set. */
+	uint16_t	sbi_rev_id_cfg_value;
+	uint8_t	unused_0[6];
+} hwrm_mfg_otp_cfg_input_t, *phwrm_mfg_otp_cfg_input_t;
+
+/* hwrm_mfg_otp_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_mfg_otp_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
 	/*
-	 * The raweth_qp1_metadata field contains the VLAN tag and TPID value.
-	 * - raweth_qp1_metadata[11:0] contains the vlan VID value.
-	 * - raweth_qp1_metadata[12] contains the vlan DE value.
-	 * - raweth_qp1_metadata[15:13] contains the vlan PRI value.
-	 * - raweth_qp1_metadata[31:16] contains the vlan TPID value.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_META_FORMAT_VLAN		(UINT32_C(0x1) << 4)
+	uint8_t	valid;
+} hwrm_mfg_otp_cfg_output_t, *phwrm_mfg_otp_cfg_output_t;
+
+/*********************
+ * hwrm_mfg_otp_qcfg *
+ *********************/
+
+
+/* hwrm_mfg_otp_qcfg_input (size:192b/24B) */
+
+typedef struct hwrm_mfg_otp_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * If ext_meta_format is equal to 1, the metadata field
-	 * contains the lower 16b of the tunnel ID value, justified
-	 * to LSB
-	 * - VXLAN = VNI[23:0] -> VXLAN Network ID
-	 * - Geneve (NGE) = VNI[23:0] -> Virtual Network Identifier.
-	 * - NVGRE = TNI[23:0] -> Tenant Network ID
-	 * - GRE = KEY[31:0] -> key field with bit mask. zero if K = 0
-	 * - IPV4 = 0 (not populated)
-	 * - IPV6 = Flow Label[19:0]
-	 * - PPPoE = sessionID[15:0]
-	 * - MPLs = Outer label[19:0]
-	 * - UPAR = Selected[31:0] with bit mask
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_META_FORMAT_TUNNEL_ID	(UINT32_C(0x2) << 4)
+	uint16_t	cmpl_ring;
 	/*
-	 * if ext_meta_format is equal to 1, metadata field contains
-	 * 16b metadata from the prepended header (chdr_data).
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_META_FORMAT_CHDR_DATA	(UINT32_C(0x3) << 4)
+	uint16_t	seq_id;
 	/*
-	 * If ext_meta_format is equal to 1, the metadata field contains
-	 * the outer_l3_offset and lower 7 bits of the inner_l2_offset,
-	 * - metadata[8:0] contains the outer_l3_offset.
-	 * - metadata[15:9] contains the inner_l2_offset[6:0]
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_META_FORMAT_HDR_OFFSET	(UINT32_C(0x4) << 4)
-		#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_META_FORMAT_LAST		CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_META_FORMAT_HDR_OFFSET
+	uint16_t	target_id;
 	/*
-	 * This field indicates the IP type for the inner-most IP header.
-	 * A value of '0' indicates IPv4.  A value of '1' indicates IPv6.
-	 * This value is only valid if itype indicates a packet
-	 * with an IP header.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_IP_TYPE			UINT32_C(0x100)
+	uint64_t	resp_addr;
+	uint16_t	enables;
 	/*
-	 * This indicates that the complete 1's complement checksum was
-	 * calculated for the packet.
+	 * This bit must be '1' for the crid field to be
+	 * queried.
 	 */
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_COMPLETE_CHECKSUM_CALC	UINT32_C(0x200)
+	#define HWRM_MFG_OTP_QCFG_INPUT_ENABLES_CRID	UINT32_C(0x1)
 	/*
-	 * The combination of this value and meta_format indicated what
-	 * format the metadata field is.
+	 * This bit must be '1' for the srt_rev_id field to be
+	 * queried.
 	 */
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_EXT_META_FORMAT_MASK	UINT32_C(0xc00)
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_EXT_META_FORMAT_SFT	10
+	#define HWRM_MFG_OTP_QCFG_INPUT_ENABLES_SRT_REV_ID	UINT32_C(0x2)
 	/*
-	 * This value is the complete 1's complement checksum calculated from
-	 * the start of the outer L3 header to the end of the packet (not
-	 * including the ethernet crc). It is valid when the
-	 * 'complete_checksum_calc' flag is set.
+	 * This bit must be '1' for the crt_rev_id field to be
+	 * queried.
 	 */
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_COMPLETE_CHECKSUM_MASK	UINT32_C(0xffff0000)
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_COMPLETE_CHECKSUM_SFT	16
+	#define HWRM_MFG_OTP_QCFG_INPUT_ENABLES_CRT_REV_ID	UINT32_C(0x4)
 	/*
-	 * This is data from the CFA block as indicated by the meta_format
-	 * field.
+	 * This bit must be '1' for the sbi_rev_id field to be
+	 * queried.
 	 */
-	uint32_t	raweth_qp1_metadata;
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_PRI_DE_VID_MASK	UINT32_C(0xffff)
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_PRI_DE_VID_SFT	0
-	/* When meta_format=1, this value is the VLAN VID. */
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_VID_MASK	UINT32_C(0xfff)
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_VID_SFT		0
-	/* When meta_format=1, this value is the VLAN DE. */
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_DE		UINT32_C(0x1000)
-	/* When meta_format=1, this value is the VLAN PRI. */
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_PRI_MASK	UINT32_C(0xe000)
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_PRI_SFT		13
-	/* When meta_format=1, this value is the VLAN TPID. */
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_TPID_MASK	UINT32_C(0xffff0000)
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_TPID_SFT	16
-	uint8_t	cqe_type_toggle;
+	#define HWRM_MFG_OTP_QCFG_INPUT_ENABLES_SBI_REV_ID	UINT32_C(0x8)
+	uint8_t	unused_0[6];
+} hwrm_mfg_otp_qcfg_input_t, *phwrm_mfg_otp_qcfg_input_t;
+
+/* hwrm_mfg_otp_qcfg_output (size:192b/24B) */
+
+typedef struct hwrm_mfg_otp_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
 	/*
-	 * Indicate valid completion - written by the chip. Cumulus
-	 * toggle this bit each time it finished consuming all PBL
-	 * entries
-	 */
-	#define CQ_RES_RAWETH_QP1_TOGGLE		UINT32_C(0x1)
-	/* This field defines the type of SQ WQE. */
-	#define CQ_RES_RAWETH_QP1_CQE_TYPE_MASK	UINT32_C(0x1e)
-	#define CQ_RES_RAWETH_QP1_CQE_TYPE_SFT	1
+	 * This field contains the value of current device type. The
+	 * value indicates the current chip mode (Unassigned/AB_PROD).
+	 */
+	uint32_t	enc_device_type;
+	/* This field indicates the current crid value. */
+	uint16_t	crid;
+	/* This field indicates the current srt rev id value. */
+	uint16_t	srt_rev_id;
+	/* This field indicates the current crt rev id value. */
+	uint16_t	crt_rev_id;
+	/* This field indicates the current sbi rev id value. */
+	uint16_t	sbi_rev_id;
+	uint8_t	unused_0[3];
 	/*
-	 * Responder RawEth and QP1 Completion - This is used for RQ
-	 * completion for RawEth service and QP1 service QPs.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-		#define CQ_RES_RAWETH_QP1_CQE_TYPE_RES_RAWETH_QP1  (UINT32_C(0x3) << 1)
-		#define CQ_RES_RAWETH_QP1_CQE_TYPE_LAST	CQ_RES_RAWETH_QP1_CQE_TYPE_RES_RAWETH_QP1
-	/* This field indicates the status for the CQE. */
-	uint8_t	status;
+	uint8_t	valid;
+} hwrm_mfg_otp_qcfg_output_t, *phwrm_mfg_otp_qcfg_output_t;
+
+/**********************
+ * hwrm_mfg_hdma_test *
+ **********************/
+
+
+/* hwrm_mfg_hdma_test_input (size:384b/48B) */
+
+typedef struct hwrm_mfg_hdma_test_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * This indicates that the completion is without error.
-	 * All fields are valid.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define CQ_RES_RAWETH_QP1_STATUS_OK			UINT32_C(0x0)
+	uint16_t	cmpl_ring;
 	/*
-	 * This indicates that write access was not allowed for
-	 * at least one of the SGEs in the WQE.
-	 *
-	 * This is a fatal error.  Only the srq_or_rq_wr_id is field
-	 * is valid.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define CQ_RES_RAWETH_QP1_STATUS_LOCAL_ACCESS_ERROR	UINT32_C(0x1)
+	uint16_t	seq_id;
 	/*
-	 * This indicates that the packet was too long for the WQE
-	 * provided on the RQ.
-	 *
-	 * This is not a fatal error.  All the fields are valid.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define CQ_RES_RAWETH_QP1_STATUS_HW_LOCAL_LENGTH_ERR	UINT32_C(0x2)
-	/* LOCAL_PROTECTION_ERR is 3 */
-	#define CQ_RES_RAWETH_QP1_STATUS_LOCAL_PROTECTION_ERR	UINT32_C(0x3)
-	/* LOCAL_QP_OPERATION_ERR is 4 */
-	#define CQ_RES_RAWETH_QP1_STATUS_LOCAL_QP_OPERATION_ERR   UINT32_C(0x4)
-	/* MEMORY_MGT_OPERATION_ERR is 5 */
-	#define CQ_RES_RAWETH_QP1_STATUS_MEMORY_MGT_OPERATION_ERR UINT32_C(0x5)
-	/* WORK_REQUEST_FLUSHED_ERR is 7 */
-	#define CQ_RES_RAWETH_QP1_STATUS_WORK_REQUEST_FLUSHED_ERR UINT32_C(0x7)
-	/* HW_FLUSH_ERR is 8 */
-	#define CQ_RES_RAWETH_QP1_STATUS_HW_FLUSH_ERR		UINT32_C(0x8)
-	#define CQ_RES_RAWETH_QP1_STATUS_LAST			CQ_RES_RAWETH_QP1_STATUS_HW_FLUSH_ERR
-	uint16_t	flags;
+	uint16_t	target_id;
 	/*
-	 * This flag indicates that the completion is for a SRQ entry
-	 * rather than for an RQ entry.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define CQ_RES_RAWETH_QP1_FLAGS_SRQ	UINT32_C(0x1)
-	/* CQE relates to RQ WQE. */
-		#define CQ_RES_RAWETH_QP1_FLAGS_SRQ_RQ	UINT32_C(0x0)
-	/* CQE relates to SRQ WQE. */
-		#define CQ_RES_RAWETH_QP1_FLAGS_SRQ_SRQ   UINT32_C(0x1)
-		#define CQ_RES_RAWETH_QP1_FLAGS_SRQ_LAST CQ_RES_RAWETH_QP1_FLAGS_SRQ_SRQ
-	uint32_t	raweth_qp1_payload_offset_srq_or_rq_wr_id;
+	uint64_t	resp_addr;
+	/* The host (DMA) buffer physical addr for the firmware to read from. */
+	uint64_t	host_src_data_addr;
+	/* The host (DMA) buffer physical addr for the firmware to write to. */
+	uint64_t	host_dst_data_addr;
 	/*
-	 * Opaque value from RQ or SRQ WQE. Used by driver/lib to
-	 * reference the WQE in order to claim the received data
-	 * and reuse the WQE space
+	 * The user provided data pattern which will be used in the DMA
+	 * transfer.
 	 */
-	#define CQ_RES_RAWETH_QP1_SRQ_OR_RQ_WR_ID_MASK	UINT32_C(0xfffff)
-	#define CQ_RES_RAWETH_QP1_SRQ_OR_RQ_WR_ID_SFT	0
+	uint64_t	user_data_pattern;
+	/* Timeout value to stop the test. */
+	uint16_t	timeout;
+	/* The number of DMA transfers to be done in the test. */
+	uint16_t	repeat_count;
+	/* Types can be any of "incremental", "fixed", or "random". */
+	uint16_t	subtype;
+	/* Test is run with the incremental data pattern. */
+	#define HWRM_MFG_HDMA_TEST_INPUT_SUBTYPE_INCREMENTAL UINT32_C(0x1)
+	/* Test is run with the fixed data pattern. */
+	#define HWRM_MFG_HDMA_TEST_INPUT_SUBTYPE_FIXED	UINT32_C(0x2)
+	/* Test is run with a random data pattern. */
+	#define HWRM_MFG_HDMA_TEST_INPUT_SUBTYPE_RANDOM	UINT32_C(0x3)
+	#define HWRM_MFG_HDMA_TEST_INPUT_SUBTYPE_LAST	HWRM_MFG_HDMA_TEST_INPUT_SUBTYPE_RANDOM
+	/* The length of the data used in the DMA transfers. */
+	uint16_t	data_len;
+} hwrm_mfg_hdma_test_input_t, *phwrm_mfg_hdma_test_input_t;
+
+/* hwrm_mfg_hdma_test_output (size:128b/16B) */
+
+typedef struct hwrm_mfg_hdma_test_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
 	/*
-	 * This value indicates the offset in bytes from the beginning of the packet
-	 * where the inner payload starts.  This value is valid for TCP, UDP,
-	 * FCoE, and RoCE packets.
-	 *
-	 * A value of zero indicates an offset of 256 bytes.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_PAYLOAD_OFFSET_MASK UINT32_C(0xff000000)
-	#define CQ_RES_RAWETH_QP1_RAWETH_QP1_PAYLOAD_OFFSET_SFT 24
-} cq_res_raweth_qp1_t, *pcq_res_raweth_qp1_t;
+	uint8_t	valid;
+} hwrm_mfg_hdma_test_output_t, *phwrm_mfg_hdma_test_output_t;
 
-/* Responder RawEth and QP1 CQE version 2 */
-/* cq_res_raweth_qp1_v2 (size:256b/32B) */
+/*****************************
+ * hwrm_mfg_fru_eeprom_write *
+ *****************************/
 
-typedef struct cq_res_raweth_qp1_v2 {
-	uint16_t	length;
+
+/* hwrm_mfg_fru_eeprom_write_input (size:256b/32B) */
+
+typedef struct hwrm_mfg_fru_eeprom_write_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * The length of the message's payload in bytes, stored in
-	 * the SGEs
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define CQ_RES_RAWETH_QP1_V2_LENGTH_MASK UINT32_C(0x3fff)
-	#define CQ_RES_RAWETH_QP1_V2_LENGTH_SFT 0
-	uint16_t	raweth_qp1_flags;
-	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS_MASK		UINT32_C(0x3ff)
-	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS_SFT		0
+	uint16_t	cmpl_ring;
 	/*
-	 * When this bit is '1', it indicates a packet that has an
-	 * error of some type.  Type of error is indicated in
-	 * raweth_qp1_errors.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS_ERROR		UINT32_C(0x1)
+	uint16_t	seq_id;
 	/*
-	 * This value indicates what the inner packet determined for the
-	 * packet was.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS_ITYPE_MASK		UINT32_C(0x3c0)
-	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS_ITYPE_SFT		6
+	uint16_t	target_id;
 	/*
-	 * Not Known:
-	 * Indicates that the packet type was not known.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS_ITYPE_NOT_KNOWN	(UINT32_C(0x0) << 6)
+	uint64_t	resp_addr;
 	/*
-	 * IP Packet:
-	 * Indicates that the packet was an IP packet, but further
-	 * classification was not possible.
+	 * The host (DMA) buffer physical addr for the firmware to read from.
+	 * This buffer is populated with the fru binary bits which is going
+	 * to be programmed into the fru memory.
 	 */
-		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS_ITYPE_IP		(UINT32_C(0x1) << 6)
+	uint64_t	data_addr;
+	/* i2c slave address. If set to 0xffff, fw will decide what to use. */
+	uint16_t	i2c_slave_addr;
+	/* Size of the buffer pointed to by data_addr. */
+	uint16_t	data_len;
+	/* The offset within the SEEPROM to start programming. */
+	uint16_t	offset;
+	uint8_t	unused[2];
+} hwrm_mfg_fru_eeprom_write_input_t, *phwrm_mfg_fru_eeprom_write_input_t;
+
+/* hwrm_mfg_fru_eeprom_write_output (size:128b/16B) */
+
+typedef struct hwrm_mfg_fru_eeprom_write_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Total length of data written to the fru memory. */
+	uint16_t	total_data_len;
+	uint16_t	unused_0;
+	uint8_t	unused_1[3];
 	/*
-	 * TCP Packet:
-	 * Indicates that the packet was IP and TCP.
-	 * This indicates that the raweth_qp1_payload_offset field is
-	 * valid.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS_ITYPE_TCP		(UINT32_C(0x2) << 6)
+	uint8_t	valid;
+} hwrm_mfg_fru_eeprom_write_output_t, *phwrm_mfg_fru_eeprom_write_output_t;
+
+/****************************
+ * hwrm_mfg_fru_eeprom_read *
+ ****************************/
+
+
+/* hwrm_mfg_fru_eeprom_read_input (size:256b/32B) */
+
+typedef struct hwrm_mfg_fru_eeprom_read_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * UDP Packet:
-	 * Indicates that the packet was IP and UDP.
-	 * This indicates that the raweth_qp1_payload_offset field is
-	 * valid.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS_ITYPE_UDP		(UINT32_C(0x3) << 6)
+	uint16_t	cmpl_ring;
 	/*
-	 * FCoE Packet:
-	 * Indicates that the packet was recognized as a FCoE.
-	 * This also indicates that the raweth_qp1_payload_offset field
-	 * is valid.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS_ITYPE_FCOE		(UINT32_C(0x4) << 6)
+	uint16_t	seq_id;
 	/*
-	 * RoCE Packet:
-	 * Indicates that the packet was recognized as a RoCE.
-	 * This also indicates that the raweth_qp1_payload_offset field
-	 * is valid.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS_ITYPE_ROCE		(UINT32_C(0x5) << 6)
+	uint16_t	target_id;
 	/*
-	 * ICMP Packet:
-	 * Indicates that the packet was recognized as ICMP.
-	 * This indicates that the raweth_qp1_payload_offset field is
-	 * valid.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS_ITYPE_ICMP		(UINT32_C(0x7) << 6)
+	uint64_t	resp_addr;
 	/*
-	 * PtP packet wo/timestamp:
-	 * Indicates that the packet was recognized as a PtP
-	 * packet.
+	 * The host (DMA) buffer physical addr for the firmware to write to.
+	 * This buffer is populated with the fru binary bits which is going
+	 * to be read from the fru memory.
 	 */
-		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS_ITYPE_PTP_WO_TIMESTAMP   (UINT32_C(0x8) << 6)
+	uint64_t	data_addr;
+	/* i2c slave address. If set to 0xffff, fw will decide what to use. */
+	uint16_t	i2c_slave_addr;
 	/*
-	 * PtP packet w/timestamp:
-	 * Indicates that the packet was recognized as a PtP
-	 * packet and that a timestamp was taken for the packet.
+	 * Size of the buffer pointed to by data_addr. The firmware may
+	 * use this entire buffer or less than the entire buffer, but never
+	 * more.
 	 */
-		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS_ITYPE_PTP_W_TIMESTAMP	(UINT32_C(0x9) << 6)
-		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS_ITYPE_LAST		CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS_ITYPE_PTP_W_TIMESTAMP
-	uint16_t	raweth_qp1_errors;
+	uint16_t	data_len;
+	/* The offset within the SEEPROM to start reading. */
+	uint16_t	offset;
+	uint8_t	unused[2];
+} hwrm_mfg_fru_eeprom_read_input_t, *phwrm_mfg_fru_eeprom_read_input_t;
+
+/* hwrm_mfg_fru_eeprom_read_output (size:128b/16B) */
+
+typedef struct hwrm_mfg_fru_eeprom_read_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Total length of data written to the host memory. */
+	uint16_t	total_data_len;
+	uint16_t	unused_0;
+	uint8_t	unused_1[3];
 	/*
-	 * This indicates that there was an error in the IP header
-	 * checksum.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_IP_CS_ERROR			UINT32_C(0x10)
+	uint8_t	valid;
+} hwrm_mfg_fru_eeprom_read_output_t, *phwrm_mfg_fru_eeprom_read_output_t;
+
+/**********************
+ * hwrm_mfg_soc_image *
+ **********************/
+
+
+/* hwrm_mfg_soc_image_input (size:512b/64B) */
+
+typedef struct hwrm_mfg_soc_image_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * This indicates that there was an error in the TCP, UDP
-	 * or ICMP checksum.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_L4_CS_ERROR			UINT32_C(0x20)
+	uint16_t	cmpl_ring;
 	/*
-	 * This indicates that there was an error in the tunnel
-	 * IP header checksum.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_T_IP_CS_ERROR			UINT32_C(0x40)
+	uint16_t	seq_id;
 	/*
-	 * This indicates that there was an error in the tunnel
-	 * UDP checksum.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_T_L4_CS_ERROR			UINT32_C(0x80)
+	uint16_t	target_id;
 	/*
-	 * This indicates that there was a CRC error on either an FCoE
-	 * or RoCE packet.  The itype indicates the packet type.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_CRC_ERROR			UINT32_C(0x100)
+	uint64_t	resp_addr;
 	/*
-	 * This indicates that there was an error in the tunnel
-	 * portion of the packet when this
-	 * field is non-zero.
+	 * TBD. Work in progress.
+	 * This field is the signature value used by SoC UEFI.
 	 */
-	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_T_PKT_ERROR_MASK		UINT32_C(0xe00)
-	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_T_PKT_ERROR_SFT		9
+	uint32_t	image_signature;
 	/*
-	 * No additional error occurred on the tunnel portion
-	 * of the packet of the packet does not have a tunnel.
+	 * TBD. Work in progress.
+	 * This field is unused for now.
 	 */
-		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_T_PKT_ERROR_NO_ERROR		(UINT32_C(0x0) << 9)
+	uint32_t	image_type;
 	/*
-	 * Indicates that IP header version does not match
-	 * expectation from L2 Ethertype for IPv4 and IPv6
-	 * in the tunnel header.
+	 * The offset within the image content that is being provided by the
+	 * current invocation of this HWRM command. The primate firmware does
+	 * not offer any score boarding services to ensure entire image
+	 * content is transferred, it is the responsibility of the caller to
+	 * ensure image consistency.
 	 */
-		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_L3_BAD_VERSION	(UINT32_C(0x1) << 9)
+	uint32_t	image_offset;
 	/*
-	 * Indicates that header length is out of range in the
-	 * tunnel header. Valid for
-	 * IPv4.
+	 * Size in bytes for the image content. The maximum value this field
+	 * can specify is 4096.
 	 */
-		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_L3_BAD_HDR_LEN	(UINT32_C(0x2) << 9)
+	uint32_t	image_length;
 	/*
-	 * Indicates that the physical packet is shorter than that
-	 * claimed by the PPPoE header length for a tunnel PPPoE
-	 * packet.
+	 * Address in host memory where the image content is located. This
+	 * location should be 4KB aligned.
 	 */
-		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_T_PKT_ERROR_TUNNEL_TOTAL_ERROR	(UINT32_C(0x3) << 9)
+	uint64_t	host_src_addr;
 	/*
-	 * Indicates that physical packet is shorter than that claimed
-	 * by the tunnel l3 header length. Valid for IPv4, or IPv6
-	 * tunnel packet packets.
+	 * Address in SoC address space where the provided image content is
+	 * to be copied. Primate firmware will copy the image content from
+	 * host memory to this location. If the image size is more than the
+	 * maximum size that can be transferred with each invocation of this
+	 * command, then this address should be updated by the caller for
+	 * each invocation to copy the full image.
 	 */
-		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_IP_TOTAL_ERROR	(UINT32_C(0x4) << 9)
+	uint64_t	soc_dest_addr;
 	/*
-	 * Indicates that the physical packet is shorter than that
-	 * claimed by the tunnel UDP header length for a tunnel
-	 * UDP packet that is not fragmented.
+	 * Indicates the entrypoint in the image that should be used. This
+	 * field is optional. When set to 0, the SoC will determine the
+	 * entrypoint on its own.
 	 */
-		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_UDP_TOTAL_ERROR	(UINT32_C(0x5) << 9)
+	uint32_t	entrypoint_offset;
+	uint32_t	flags;
 	/*
-	 * indicates that the IPv4 TTL or IPv6 hop limit check
-	 * have failed (e.g. TTL = 0) in the tunnel header. Valid
-	 * for IPv4, and IPv6.
+	 * This bit should be set to '1' only when an image transfer is
+	 * being initiated for each unique image_signature.
 	 */
-		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_L3_BAD_TTL		(UINT32_C(0x6) << 9)
-		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_T_PKT_ERROR_LAST		CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_L3_BAD_TTL
+	#define HWRM_MFG_SOC_IMAGE_INPUT_FLAGS_START	UINT32_C(0x1)
 	/*
-	 * This indicates that there was an error in the inner
-	 * portion of the packet when this
-	 * field is non-zero.
+	 * This bit should be set to '1' only when an image transfer for a
+	 * given image_signature is complete.
 	 */
-	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_PKT_ERROR_MASK			UINT32_C(0xf000)
-	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_PKT_ERROR_SFT			12
+	#define HWRM_MFG_SOC_IMAGE_INPUT_FLAGS_END	UINT32_C(0x2)
 	/*
-	 * No additional error occurred on the tunnel portion
-	 * of the packet of the packet does not have a tunnel.
+	 * An incrementing number starting with 1 for each invocation of this
+	 * HWRM command for any given image_id. No two invocation of this
+	 * command for a given image_id shall carry the same seq_number. Each
+	 * consecutive invocation of this command for any given image_id
+	 * shall increment this number by 1. The value 0 is used when
+	 * seq_number is invalid when no image content is being moved.
 	 */
-		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_PKT_ERROR_NO_ERROR		(UINT32_C(0x0) << 12)
+	uint32_t	seq_number;
+	/*  */
+	uint32_t	reserved1;
+} hwrm_mfg_soc_image_input_t, *phwrm_mfg_soc_image_input_t;
+
+/* hwrm_mfg_soc_image_output (size:128b/16B) */
+
+typedef struct hwrm_mfg_soc_image_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_1[7];
 	/*
-	 * Indicates that IP header version does not match
-	 * expectation from L2 Ethertype for IPv4 and IPv6 or that
-	 * option other than VFT was parsed on
-	 * FCoE packet.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_PKT_ERROR_L3_BAD_VERSION		(UINT32_C(0x1) << 12)
+	uint8_t	valid;
+} hwrm_mfg_soc_image_output_t, *phwrm_mfg_soc_image_output_t;
+
+/************************
+ * hwrm_mfg_soc_qstatus *
+ ************************/
+
+
+/* hwrm_mfg_soc_qstatus_input (size:192b/24B) */
+
+typedef struct hwrm_mfg_soc_qstatus_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * indicates that header length is out of range. Valid for
-	 * IPv4 and RoCE
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_PKT_ERROR_L3_BAD_HDR_LEN		(UINT32_C(0x2) << 12)
+	uint16_t	cmpl_ring;
 	/*
-	 * indicates that the IPv4 TTL or IPv6 hop limit check
-	 * have failed (e.g. TTL = 0). Valid for IPv4, and IPv6
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_PKT_ERROR_L3_BAD_TTL		(UINT32_C(0x3) << 12)
+	uint16_t	seq_id;
 	/*
-	 * Indicates that physical packet is shorter than that
-	 * claimed by the l3 header length. Valid for IPv4,
-	 * IPv6 packet or RoCE packets.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_PKT_ERROR_IP_TOTAL_ERROR		(UINT32_C(0x4) << 12)
+	uint16_t	target_id;
 	/*
-	 * Indicates that the physical packet is shorter than that
-	 * claimed by the UDP header length for a UDP packet that is
-	 * not fragmented.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_PKT_ERROR_UDP_TOTAL_ERROR	(UINT32_C(0x5) << 12)
+	uint64_t	resp_addr;
+	/*  */
+	uint32_t	reserved1;
+	/*  */
+	uint32_t	reserved2;
+} hwrm_mfg_soc_qstatus_input_t, *phwrm_mfg_soc_qstatus_input_t;
+
+/* hwrm_mfg_soc_qstatus_output (size:576b/72B) */
+
+typedef struct hwrm_mfg_soc_qstatus_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
 	/*
-	 * Indicates that TCP header length > IP payload. Valid for
-	 * TCP packets only.
+	 * This field describes capabilities of primate firmware for SoC
+	 * image.
 	 */
-		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_PKT_ERROR_L4_BAD_HDR_LEN		(UINT32_C(0x6) << 12)
-	/* Indicates that TCP header length < 5. Valid for TCP. */
-		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_PKT_ERROR_L4_BAD_HDR_LEN_TOO_SMALL  (UINT32_C(0x7) << 12)
+	uint32_t	primate_flags;
+	/*  */
+	uint32_t	reserved1;
+	/* This field contains the current content of the AP_STATUS register. */
+	uint32_t	ap_status;
 	/*
-	 * Indicates that TCP option headers result in a TCP header
-	 * size that does not match data offset in TCP header. Valid
-	 * for TCP.
+	 * This field contains the current content of the CRMU_STATUS
+	 * register.
 	 */
-		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_PKT_ERROR_L4_BAD_OPT_LEN		(UINT32_C(0x8) << 12)
-		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_PKT_ERROR_LAST			CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_ERRORS_PKT_ERROR_L4_BAD_OPT_LEN
-	/* This is data from the CFA as indicated by the meta_format field. */
-	uint16_t	cfa_metadata0;
-	/* When meta_format=1, this value is the VLAN VID. */
-	#define CQ_RES_RAWETH_QP1_V2_CFA_METADATA0_VID_MASK UINT32_C(0xfff)
-	#define CQ_RES_RAWETH_QP1_V2_CFA_METADATA0_VID_SFT 0
-	/* When meta_format=1, this value is the VLAN DE. */
-	#define CQ_RES_RAWETH_QP1_V2_CFA_METADATA0_DE	UINT32_C(0x1000)
-	/* When meta_format=1, this value is the VLAN PRI. */
-	#define CQ_RES_RAWETH_QP1_V2_CFA_METADATA0_PRI_MASK UINT32_C(0xe000)
-	#define CQ_RES_RAWETH_QP1_V2_CFA_METADATA0_PRI_SFT 13
+	uint32_t	crmu_status;
 	/*
-	 * This is an application level ID used to identify the
-	 * QP and its SQ and RQ.
+	 * If an image provision operation is in process, this field will
+	 * provide information on requested image signature else the contents
+	 * are undefined.
 	 */
-	uint64_t	qp_handle;
-	uint32_t	raweth_qp1_flags2;
+	uint32_t	image_signature;
 	/*
-	 * When this bit is '0', the cs_ok field has the following
-	 * definition:- ip_cs_ok[2:0] = The number of header groups with a
-	 * valid IP checksum in the delivered packet, counted from the
-	 * outer-most header group to the inner-most header group, stopping
-	 * at the first error. - l4_cs_ok[5:3] = The number of header groups
-	 * with a valid L4 checksum in the delivered packet, counted from
-	 * the outer-most header group to the inner-most header group,
-	 * stopping at the first error. When this bit is '1', the cs_ok
-	 * field has the following definition: - hdr_cnt[2:0] = The number of
-	 * header groups that were parsed by the chip and passed in the
-	 * delivered packet. - ip_cs_all_ok[3] =This bit will be '1' if all
-	 * the parsed header groups with an IP checksum are valid.
-	 * - l4_cs_all_ok[4] = This bit will be '1' if all the parsed header
-	 * groups with an L4 checksum are valid.
+	 * If an image provision operation is in process, this field will
+	 * provide information on requested image command else the contents
+	 * are undefined.
 	 */
-	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS2_CS_ALL_OK_MODE		UINT32_C(0x8)
-	/* This value indicates what format the metadata field is. */
-	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS2_META_FORMAT_MASK	UINT32_C(0xf0)
-	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS2_META_FORMAT_SFT		4
-	/* There is no metadata information. Values are zero. */
-		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS2_META_FORMAT_NONE		(UINT32_C(0x0) << 4)
+	uint32_t	image_command;
 	/*
-	 * The {metadata1, metadata0} fields contain the vtag
-	 * information: - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0],
-	 * de, vid[11:0]} The metadata2 field contains the table scope
-	 * and action record pointer. - metadata2[25:0] contains the
-	 * action record pointer. - metadata2[31:26] contains the table
-	 * scope.
+	 * If an image provision operation is in process, this field will
+	 * provide the requested image name else the contents are undefined.
 	 */
-		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS2_META_FORMAT_ACT_REC_PTR	(UINT32_C(0x1) << 4)
+	uint8_t	image_name[32];
+	uint8_t	unused_1[7];
 	/*
-	 * The {metadata1, metadata0} fields contain the vtag
-	 * information:
-	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0], de, vid[11:0]}
-	 * The metadata2 field contains the Tunnel ID
-	 * value, justified to LSB. i
-	 * - VXLAN = VNI[23:0] -> VXLAN Network ID
-	 * - Geneve (NGE) = VNI[23:0] a-> Virtual Network Identifier
-	 * - NVGRE = TNI[23:0] -> Tenant Network ID
-	 * - GRE = KEY[31:0] -> key field with bit mask. zero if K=0
-	 * - IPv4 = 0 (not populated)
-	 * - IPv6 = Flow Label[19:0]
-	 * - PPPoE = sessionID[15:0]
-	 * - MPLs = Outer label[19:0]
-	 * - UPAR = Selected[31:0] with bit mask
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
+	 */
+	uint8_t	valid;
+} hwrm_mfg_soc_qstatus_output_t, *phwrm_mfg_soc_qstatus_output_t;
+
+/*****************************************
+ * hwrm_mfg_param_critical_data_finalize *
+ *****************************************/
+
+
+/* hwrm_mfg_param_critical_data_finalize_input (size:192b/24B) */
+
+typedef struct hwrm_mfg_param_critical_data_finalize_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t	cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS2_META_FORMAT_TUNNEL_ID	(UINT32_C(0x2) << 4)
+	uint16_t	seq_id;
 	/*
-	 * The {metadata1, metadata0} fields contain the vtag
-	 * information:
-	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0],de, vid[11:0]}
-	 * The metadata2 field contains the 32b metadata from the prepended
-	 * header (chdr_data).
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS2_META_FORMAT_CHDR_DATA	(UINT32_C(0x3) << 4)
+	uint16_t	target_id;
 	/*
-	 * The {metadata1, metadata0} fields contain the vtag
-	 * information:
-	 * - vtag[19:0] = {valid, tpid_sel[2:0], pri[2:0], de, vid[11:0]}
-	 * The metadata2 field contains the outer_l3_offset,
-	 * inner_l2_offset, inner_l3_offset, and inner_l4_size.
-	 * - metadata2[8:0] contains the outer_l3_offset.
-	 * - metadata2[17:9] contains the inner_l2_offset.
-	 * - metadata2[26:18] contains the inner_l3_offset.
-	 * - metadata2[31:27] contains the inner_l4_size.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS2_META_FORMAT_HDR_OFFSET	(UINT32_C(0x4) << 4)
-		#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS2_META_FORMAT_LAST		CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS2_META_FORMAT_HDR_OFFSET
+	uint64_t	resp_addr;
+	uint16_t	flags;
 	/*
-	 * This field indicates the IP type for the inner-most IP header.
-	 * A value of '0' indicates IPv4.  A value of '1' indicates IPv6.
-	 * This value is only valid if itype indicates a packet
-	 * with an IP header.
+	 * Set to 1 if you wish to unlock and erase the region
+	 * before finalizing the data.
 	 */
-	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS2_IP_TYPE			UINT32_C(0x100)
+	#define HWRM_MFG_PARAM_CRITICAL_DATA_FINALIZE_INPUT_FLAGS_FORCE	UINT32_C(0x1)
+	uint16_t	unused_0;
+	uint32_t	unused_1;
+} hwrm_mfg_param_critical_data_finalize_input_t, *phwrm_mfg_param_critical_data_finalize_input_t;
+
+/* hwrm_mfg_param_critical_data_finalize_output (size:128b/16B) */
+
+typedef struct hwrm_mfg_param_critical_data_finalize_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Total length of data finalized. */
+	uint32_t	total_data_len;
+	uint16_t	error_status;
+	/* Critical data region was already locked */
+	#define HWRM_MFG_PARAM_CRITICAL_DATA_FINALIZE_OUTPUT_ERROR_STATUS_ALREADY_LOCKED	UINT32_C(0x1)
+	/* Flash region was not entirely empty */
+	#define HWRM_MFG_PARAM_CRITICAL_DATA_FINALIZE_OUTPUT_ERROR_STATUS_NOT_EMPTY		UINT32_C(0x2)
+	/* FACT_CFG was missing for write to critical cfg */
+	#define HWRM_MFG_PARAM_CRITICAL_DATA_FINALIZE_OUTPUT_ERROR_STATUS_MISSING_FACT_CFG	UINT32_C(0x4)
+	/* VPD was missing for write to critical cfg */
+	#define HWRM_MFG_PARAM_CRITICAL_DATA_FINALIZE_OUTPUT_ERROR_STATUS_MISSING_VPD	UINT32_C(0x8)
+	uint8_t	unused_1;
 	/*
-	 * This indicates that the complete 1's complement checksum was
-	 * calculated for the packet.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS2_COMPLETE_CHECKSUM_CALC	UINT32_C(0x200)
+	uint8_t	valid;
+} hwrm_mfg_param_critical_data_finalize_output_t, *phwrm_mfg_param_critical_data_finalize_output_t;
+
+/*************************************
+ * hwrm_mfg_param_critical_data_read *
+ *************************************/
+
+
+/* hwrm_mfg_param_critical_data_read_input (size:256b/32B) */
+
+typedef struct hwrm_mfg_param_critical_data_read_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * This field indicates the status of IP and L4 CS calculations done
-	 * by the chip. The format of this field is indicated by the
-	 * cs_all_ok_mode bit.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS2_CS_OK_MASK		UINT32_C(0xfc00)
-	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS2_CS_OK_SFT		10
+	uint16_t	cmpl_ring;
 	/*
-	 * This value is the complete 1's complement checksum calculated from
-	 * the start of the outer L3 header to the end of the packet (not
-	 * including the ethernet crc). It is valid when the
-	 * 'complete_checksum_calc' flag is set.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS2_COMPLETE_CHECKSUM_MASK	UINT32_C(0xffff0000)
-	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_FLAGS2_COMPLETE_CHECKSUM_SFT	16
+	uint16_t	seq_id;
 	/*
-	 * This is data from the CFA block as indicated by the meta_format
-	 * field.
-	 * - meta_format 0 - none - metadata2 = 0 - not valid/not stripped
-	 * - meta_format 1 - act_rec_ptr - metadata2 = {table_scope[5:0],
-	 *   act_rec_ptr[25:0]}
-	 * - meta_format 2 - tunnel_id - metadata2 = tunnel_id[31:0]
-	 * - meta_format 3 - chdr_data - metadata2 = updated_chdr_data[31:0]
-	 * - meta_format 4 - hdr_offsets - metadata2 = hdr_offsets[31:0]
-	 * When vee_cmpl_mode is set in VNIC context, this is the upper 32b
-	 * of the host address from the first BD used to place the packet.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	uint32_t	cfa_metadata2;
-	uint8_t	cqe_type_toggle;
+	uint16_t	target_id;
 	/*
-	 * Indicate valid completion - written by the chip. Cumulus
-	 * toggle this bit each time it finished consuming all PBL
-	 * entries
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define CQ_RES_RAWETH_QP1_V2_TOGGLE		UINT32_C(0x1)
-	/* This field defines the type of SQ WQE. */
-	#define CQ_RES_RAWETH_QP1_V2_CQE_TYPE_MASK	UINT32_C(0x1e)
-	#define CQ_RES_RAWETH_QP1_V2_CQE_TYPE_SFT	1
+	uint64_t	resp_addr;
 	/*
-	 * Responder RawEth and QP1 Completion - This is used for RQ
-	 * completion for RawEth service and QP1 service QPs.
+	 * The host (DMA) buffer physical addr for the firmware to write to.
+	 * This buffer is populated with data read from the
+	 * critical data storage location.
 	 */
-		#define CQ_RES_RAWETH_QP1_V2_CQE_TYPE_RES_RAWETH_QP1  (UINT32_C(0x3) << 1)
-		#define CQ_RES_RAWETH_QP1_V2_CQE_TYPE_LAST	CQ_RES_RAWETH_QP1_V2_CQE_TYPE_RES_RAWETH_QP1
-	/* This field indicates the status for the CQE. */
-	uint8_t	status;
+	uint64_t	data_addr;
 	/*
-	 * This indicates that the completion is without error.
-	 * All fields are valid.
+	 * Size of the buffer pointed to by data_addr. The firmware may
+	 * use this entire buffer or less than the entire buffer, but never
+	 * more.
 	 */
-	#define CQ_RES_RAWETH_QP1_V2_STATUS_OK			UINT32_C(0x0)
+	uint32_t	data_len;
+	/* The offset within the critical data to start reading. */
+	uint32_t	offset;
+} hwrm_mfg_param_critical_data_read_input_t, *phwrm_mfg_param_critical_data_read_input_t;
+
+/* hwrm_mfg_param_critical_data_read_output (size:128b/16B) */
+
+typedef struct hwrm_mfg_param_critical_data_read_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Total length of data written to the host memory. */
+	uint32_t	total_data_len;
+	uint16_t	unused_0;
+	uint8_t	unused_1;
 	/*
-	 * This indicates that write access was not allowed for
-	 * at least one of the SGEs in the WQE.
-	 *
-	 * This is a fatal error.  Only the srq_or_rq_wr_id is field
-	 * is valid.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	#define CQ_RES_RAWETH_QP1_V2_STATUS_LOCAL_ACCESS_ERROR	UINT32_C(0x1)
+	uint8_t	valid;
+} hwrm_mfg_param_critical_data_read_output_t, *phwrm_mfg_param_critical_data_read_output_t;
+
+/***************************************
+ * hwrm_mfg_param_critical_data_health *
+ ***************************************/
+
+
+/* hwrm_mfg_param_critical_data_health_input (size:192b/24B) */
+
+typedef struct hwrm_mfg_param_critical_data_health_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * This indicates that the packet was too long for the WQE
-	 * provided on the RQ.
-	 *
-	 * This is not a fatal error.  All the fields are valid.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define CQ_RES_RAWETH_QP1_V2_STATUS_HW_LOCAL_LENGTH_ERR	UINT32_C(0x2)
-	/* LOCAL_PROTECTION_ERR is 3 */
-	#define CQ_RES_RAWETH_QP1_V2_STATUS_LOCAL_PROTECTION_ERR	UINT32_C(0x3)
-	/* LOCAL_QP_OPERATION_ERR is 4 */
-	#define CQ_RES_RAWETH_QP1_V2_STATUS_LOCAL_QP_OPERATION_ERR   UINT32_C(0x4)
-	/* MEMORY_MGT_OPERATION_ERR is 5 */
-	#define CQ_RES_RAWETH_QP1_V2_STATUS_MEMORY_MGT_OPERATION_ERR UINT32_C(0x5)
-	/* WORK_REQUEST_FLUSHED_ERR is 7 */
-	#define CQ_RES_RAWETH_QP1_V2_STATUS_WORK_REQUEST_FLUSHED_ERR UINT32_C(0x7)
-	/* HW_FLUSH_ERR is 8 */
-	#define CQ_RES_RAWETH_QP1_V2_STATUS_HW_FLUSH_ERR		UINT32_C(0x8)
-	#define CQ_RES_RAWETH_QP1_V2_STATUS_LAST			CQ_RES_RAWETH_QP1_V2_STATUS_HW_FLUSH_ERR
-	uint16_t	flags;
+	uint16_t	cmpl_ring;
 	/*
-	 * This flag indicates that the completion is for a SRQ entry
-	 * rather than for an RQ entry.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define CQ_RES_RAWETH_QP1_V2_FLAGS_SRQ	UINT32_C(0x1)
-	/* CQE relates to RQ WQE. */
-		#define CQ_RES_RAWETH_QP1_V2_FLAGS_SRQ_RQ	UINT32_C(0x0)
-	/* CQE relates to SRQ WQE. */
-		#define CQ_RES_RAWETH_QP1_V2_FLAGS_SRQ_SRQ   UINT32_C(0x1)
-		#define CQ_RES_RAWETH_QP1_V2_FLAGS_SRQ_LAST CQ_RES_RAWETH_QP1_V2_FLAGS_SRQ_SRQ
-	uint32_t	raweth_qp1_payload_offset_srq_or_rq_wr_id;
+	uint16_t	seq_id;
 	/*
-	 * Opaque value from RQ or SRQ WQE. Used by driver/lib to
-	 * reference the WQE in order to claim the received data
-	 * and reuse the WQE space
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define CQ_RES_RAWETH_QP1_V2_SRQ_OR_RQ_WR_ID_MASK	UINT32_C(0xfffff)
-	#define CQ_RES_RAWETH_QP1_V2_SRQ_OR_RQ_WR_ID_SFT		0
-	#define CQ_RES_RAWETH_QP1_V2_CFA_METADATA1_MASK		UINT32_C(0xf00000)
-	#define CQ_RES_RAWETH_QP1_V2_CFA_METADATA1_SFT		20
-	/* When meta_format != 0, this value is the VLAN TPID_SEL. */
-	#define CQ_RES_RAWETH_QP1_V2_CFA_METADATA1_TPID_SEL_MASK	UINT32_C(0x700000)
-	#define CQ_RES_RAWETH_QP1_V2_CFA_METADATA1_TPID_SEL_SFT	20
-	/* 0x88a8 */
-		#define CQ_RES_RAWETH_QP1_V2_CFA_METADATA1_TPID_SEL_TPID88A8   (UINT32_C(0x0) << 20)
-	/* 0x8100 */
-		#define CQ_RES_RAWETH_QP1_V2_CFA_METADATA1_TPID_SEL_TPID8100   (UINT32_C(0x1) << 20)
-	/* 0x9100 */
-		#define CQ_RES_RAWETH_QP1_V2_CFA_METADATA1_TPID_SEL_TPID9100   (UINT32_C(0x2) << 20)
-	/* 0x9200 */
-		#define CQ_RES_RAWETH_QP1_V2_CFA_METADATA1_TPID_SEL_TPID9200   (UINT32_C(0x3) << 20)
-	/* 0x9300 */
-		#define CQ_RES_RAWETH_QP1_V2_CFA_METADATA1_TPID_SEL_TPID9300   (UINT32_C(0x4) << 20)
-	/* Value programmed in CFA VLANTPID register. */
-		#define CQ_RES_RAWETH_QP1_V2_CFA_METADATA1_TPID_SEL_TPIDCFG	(UINT32_C(0x5) << 20)
-		#define CQ_RES_RAWETH_QP1_V2_CFA_METADATA1_TPID_SEL_LAST	CQ_RES_RAWETH_QP1_V2_CFA_METADATA1_TPID_SEL_TPIDCFG
-	/* When meta_format != 0, this value is the VLAN valid. */
-	#define CQ_RES_RAWETH_QP1_V2_CFA_METADATA1_VALID		UINT32_C(0x800000)
+	uint16_t	target_id;
 	/*
-	 * This value indicates the offset in bytes from the beginning of
-	 * the packet where the inner payload starts.  This value is valid
-	 * for TCP, UDP, FCoE, and RoCE packets.
-	 *
-	 * A value of zero indicates an offset of 256 bytes.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_PAYLOAD_OFFSET_MASK UINT32_C(0xff000000)
-	#define CQ_RES_RAWETH_QP1_V2_RAWETH_QP1_PAYLOAD_OFFSET_SFT  24
-} cq_res_raweth_qp1_v2_t, *pcq_res_raweth_qp1_v2_t;
+	uint64_t	resp_addr;
+	uint64_t	unused_0;
+} hwrm_mfg_param_critical_data_health_input_t, *phwrm_mfg_param_critical_data_health_input_t;
 
-/* Terminal CQE */
-/* cq_terminal (size:256b/32B) */
+/* hwrm_mfg_param_critical_data_health_output (size:128b/16B) */
 
-typedef struct cq_terminal {
+typedef struct hwrm_mfg_param_critical_data_health_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint32_t	health_status;
+	/* region entirely empty */
+	#define HWRM_MFG_PARAM_CRITICAL_DATA_HEALTH_OUTPUT_HEALTH_STATUS_IS_EMPTY	UINT32_C(0x1)
+	/* Data checksum fail */
+	#define HWRM_MFG_PARAM_CRITICAL_DATA_HEALTH_OUTPUT_HEALTH_STATUS_CHECKSUM_FAIL	UINT32_C(0x2)
+	/* Malformed data (header/footer) */
+	#define HWRM_MFG_PARAM_CRITICAL_DATA_HEALTH_OUTPUT_HEALTH_STATUS_MALFORMED_DATA	UINT32_C(0x4)
+	/* Critical data not locked */
+	#define HWRM_MFG_PARAM_CRITICAL_DATA_HEALTH_OUTPUT_HEALTH_STATUS_NOT_LOCKED	UINT32_C(0x8)
+	uint16_t	unused_1;
+	uint8_t	unused_2;
 	/*
-	 * This is an application level ID used to identify the
-	 * QP and its SQ and RQ.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	uint64_t	qp_handle;
+	uint8_t	valid;
+} hwrm_mfg_param_critical_data_health_output_t, *phwrm_mfg_param_critical_data_health_output_t;
+
+/*****************************
+ * hwrm_mfg_prvsn_export_csr *
+ *****************************/
+
+
+/* hwrm_mfg_prvsn_export_csr_input (size:256b/32B) */
+
+typedef struct hwrm_mfg_prvsn_export_csr_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * Final SQ Consumer Index value.  Any additional SQ WQEs will
-	 * have to be completed by the user provider.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint16_t	sq_cons_idx;
+	uint16_t	cmpl_ring;
 	/*
-	 * Final RQ Consumer Index value.  Any additional RQ WQEs will
-	 * have to be completed by the user provider.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint16_t	rq_cons_idx;
-	uint32_t	reserved32_1;
-	uint64_t	reserved64_3;
-	uint8_t	cqe_type_toggle;
+	uint16_t	seq_id;
 	/*
-	 * Indicate valid completion - written by the chip. Cumulus
-	 * toggle this bit each time it finished consuming all PBL
-	 * entries
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define CQ_TERMINAL_TOGGLE	UINT32_C(0x1)
-	/* This field defines the type of SQ WQE. */
-	#define CQ_TERMINAL_CQE_TYPE_MASK	UINT32_C(0x1e)
-	#define CQ_TERMINAL_CQE_TYPE_SFT	1
+	uint16_t	target_id;
 	/*
-	 * Terminal completion - This is used to indicate that no
-	 * further completions will be made for this QP on this CQ.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-		#define CQ_TERMINAL_CQE_TYPE_TERMINAL  (UINT32_C(0xe) << 1)
-		#define CQ_TERMINAL_CQE_TYPE_LAST	CQ_TERMINAL_CQE_TYPE_TERMINAL
-	/* This field indicates the status for the CQE. */
-	uint8_t	status;
-	/* OK is 0 */
-	#define CQ_TERMINAL_STATUS_OK UINT32_C(0x0)
-	#define CQ_TERMINAL_STATUS_LAST CQ_TERMINAL_STATUS_OK
-	uint16_t	reserved16;
-	uint32_t	reserved32_2;
-} cq_terminal_t, *pcq_terminal_t;
-
-/* Cutoff CQE */
-/* cq_cutoff (size:256b/32B) */
-
-typedef struct cq_cutoff {
-	uint64_t	reserved64_1;
-	uint64_t	reserved64_2;
-	uint64_t	reserved64_3;
-	uint8_t	cqe_type_toggle;
+	uint64_t	resp_addr;
 	/*
-	 * Indicate valid completion - written by the chip. Cumulus
-	 * toggle this bit each time it finished consuming all PBL
-	 * entries
+	 * 64-bit Host destination address. This is the host address where
+	 * data will be written.
 	 */
-	#define CQ_CUTOFF_TOGGLE	UINT32_C(0x1)
-	/* This field defines the type of SQ WQE. */
-	#define CQ_CUTOFF_CQE_TYPE_MASK   UINT32_C(0x1e)
-	#define CQ_CUTOFF_CQE_TYPE_SFT	1
-	/* Cut off CQE; for CQ resize see CQ and SRQ Resize */
-		#define CQ_CUTOFF_CQE_TYPE_CUT_OFF  (UINT32_C(0xf) << 1)
-		#define CQ_CUTOFF_CQE_TYPE_LAST	CQ_CUTOFF_CQE_TYPE_CUT_OFF
-	/* This field indicates the status for the CQE. */
-	uint8_t	status;
-	/* OK is 0 */
-	#define CQ_CUTOFF_STATUS_OK UINT32_C(0x0)
-	#define CQ_CUTOFF_STATUS_LAST CQ_CUTOFF_STATUS_OK
-	uint16_t	reserved16;
-	uint32_t	reserved32;
-} cq_cutoff_t, *pcq_cutoff_t;
+	uint64_t	host_dest_addr;
+	/* Provisioning slot number. 0-indexed. */
+	uint8_t	slot;
+	uint8_t	unused_0;
+	/* Size in bytes of the available host buffer. */
+	uint16_t	host_buf_len;
+	uint8_t	flags;
+	/*
+	 * This bit is only used when external secure SoC is used for
+	 * secure boot. If this bit is set, export a certificate signing
+	 * request (CSR) from the security SoC non-volatile storage on
+	 * the device.
+	 */
+	#define HWRM_MFG_PRVSN_EXPORT_CSR_INPUT_FLAGS_SECURE_SOC_SUPPORT	UINT32_C(0x1)
+	uint8_t	unused_1[3];
+} hwrm_mfg_prvsn_export_csr_input_t, *phwrm_mfg_prvsn_export_csr_input_t;
 
-/* nq_base (size:128b/16B) */
+/* hwrm_mfg_prvsn_export_csr_output (size:128b/16B) */
 
-typedef struct nq_base {
-	uint16_t	info10_type;
+typedef struct hwrm_mfg_prvsn_export_csr_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Provisioning slot number. 0-indexed. */
+	uint8_t	slot;
+	uint8_t	unused_0;
+	/* Size in bytes of the exported CSR. */
+	uint16_t	csr_len;
+	uint8_t	unused_1[3];
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units.  Even values indicate 16B
-	 * records.  Odd values indicate 32B
-	 * records.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	#define NQ_BASE_TYPE_MASK	UINT32_C(0x3f)
-	#define NQ_BASE_TYPE_SFT		0
-	/* CQ Notification */
-		#define NQ_BASE_TYPE_CQ_NOTIFICATION  UINT32_C(0x30)
-	/* SRQ Threshold Event */
-		#define NQ_BASE_TYPE_SRQ_EVENT	UINT32_C(0x32)
-	/* DBQ Threshold Event */
-		#define NQ_BASE_TYPE_DBQ_EVENT	UINT32_C(0x34)
-	/* QP Async Notification */
-		#define NQ_BASE_TYPE_QP_EVENT	UINT32_C(0x38)
-	/* Function Async Notification */
-		#define NQ_BASE_TYPE_FUNC_EVENT	UINT32_C(0x3a)
-		#define NQ_BASE_TYPE_LAST		NQ_BASE_TYPE_FUNC_EVENT
-	/* info10 is 10 b */
-	#define NQ_BASE_INFO10_MASK	UINT32_C(0xffc0)
-	#define NQ_BASE_INFO10_SFT	6
-	/* info16 is 16 b */
-	uint16_t	info16;
-	/* info32 is 32 b */
-	uint32_t	info32;
-	/* info32 is 32 b */
-	uint64_t	info63_v;
+	uint8_t	valid;
+} hwrm_mfg_prvsn_export_csr_output_t, *phwrm_mfg_prvsn_export_csr_output_t;
+
+/* hwrm_mfg_prvsn_export_csr_cmd_err (size:64b/8B) */
+
+typedef struct hwrm_mfg_prvsn_export_csr_cmd_err {
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue.   The even passes
-	 * will write 1.  The odd passes will write 0.
+	 * command specific error codes that goes to
+	 * the cmd_err field in Common HWRM Error Response.
 	 */
-	#define NQ_BASE_V	UINT32_C(0x1)
-	/* info63 is 63 b */
-	#define NQ_BASE_INFO63_MASK UINT32_C(0xfffffffe)
-	#define NQ_BASE_INFO63_SFT 1
-} nq_base_t, *pnq_base_t;
+	uint8_t	code;
+	/* Unknown error. */
+	#define HWRM_MFG_PRVSN_EXPORT_CSR_CMD_ERR_CODE_UNKNOWN	UINT32_C(0x0)
+	/* Slot invalid */
+	#define HWRM_MFG_PRVSN_EXPORT_CSR_CMD_ERR_CODE_SLOT_INVALID  UINT32_C(0x1)
+	/* Host provided buffer is too small */
+	#define HWRM_MFG_PRVSN_EXPORT_CSR_CMD_ERR_CODE_BUFFER_LENGTH UINT32_C(0x2)
+	#define HWRM_MFG_PRVSN_EXPORT_CSR_CMD_ERR_CODE_LAST	HWRM_MFG_PRVSN_EXPORT_CSR_CMD_ERR_CODE_BUFFER_LENGTH
+	uint8_t	unused_0[7];
+} hwrm_mfg_prvsn_export_csr_cmd_err_t, *phwrm_mfg_prvsn_export_csr_cmd_err_t;
 
-/* Completion Queue Notification */
-/* nq_cn (size:128b/16B) */
+/******************************
+ * hwrm_mfg_prvsn_import_cert *
+ ******************************/
 
-typedef struct nq_cn {
-	uint16_t	type;
+
+/* hwrm_mfg_prvsn_import_cert_input (size:256b/32B) */
+
+typedef struct hwrm_mfg_prvsn_import_cert_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units.  Even values indicate 16B
-	 * records.  Odd values indicate 32B
-	 * records.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define NQ_CN_TYPE_MASK	UINT32_C(0x3f)
-	#define NQ_CN_TYPE_SFT		0
-	/* CQ Notification */
-		#define NQ_CN_TYPE_CQ_NOTIFICATION  UINT32_C(0x30)
-		#define NQ_CN_TYPE_LAST		NQ_CN_TYPE_CQ_NOTIFICATION
-	uint16_t	reserved16;
+	uint16_t	cmpl_ring;
 	/*
-	 * This is an application level ID used to identify the
-	 * CQ.  This field carries the lower 32b of the value.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	uint32_t	cq_handle_low;
-	uint32_t	v;
+	uint16_t	seq_id;
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue.   The even passes
-	 * will write 1.  The odd passes will write 0.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define NQ_CN_V	UINT32_C(0x1)
+	uint16_t	target_id;
 	/*
-	 * This is an application level ID used to identify the
-	 * CQ.  This field carries the upper 32b of the value.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint32_t	cq_handle_high;
-} nq_cn_t, *pnq_cn_t;
+	uint64_t	resp_addr;
+	/*
+	 * 64-bit Host source address. This is the host address where
+	 * source data is located.
+	 */
+	uint64_t	host_src_addr;
+	/* Provisioning slot number. 0-indexed. */
+	uint8_t	slot;
+	uint8_t	unused_0;
+	/* Size in bytes of the certificate chain. */
+	uint16_t	cert_len;
+	uint8_t	flags;
+	/*
+	 * This bit is only used when external secure SoC is used for
+	 * secure boot. If this bit is set, then import a HSM-signed
+	 * certificate chain to security SoC non-volatile storage on
+	 * the device.
+	 */
+	#define HWRM_MFG_PRVSN_IMPORT_CERT_INPUT_FLAGS_SECURE_SOC_SUPPORT	UINT32_C(0x1)
+	uint8_t	unused_1[3];
+} hwrm_mfg_prvsn_import_cert_input_t, *phwrm_mfg_prvsn_import_cert_input_t;
 
-/* SRQ Event Notification */
-/* nq_srq_event (size:128b/16B) */
+/* hwrm_mfg_prvsn_import_cert_output (size:128b/16B) */
 
-typedef struct nq_srq_event {
-	uint8_t	type;
+typedef struct hwrm_mfg_prvsn_import_cert_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Provisioning slot number. 0-indexed. */
+	uint8_t	slot;
+	/* Provisioned state */
+	uint8_t	state;
+	/* Certificate chain is not provisioned. */
+	#define HWRM_MFG_PRVSN_IMPORT_CERT_OUTPUT_STATE_NOT_PROVISIONED UINT32_C(0x0)
+	/* Certificate chain successfully provisioned. */
+	#define HWRM_MFG_PRVSN_IMPORT_CERT_OUTPUT_STATE_PROVISIONED	UINT32_C(0x1)
+	#define HWRM_MFG_PRVSN_IMPORT_CERT_OUTPUT_STATE_LAST	HWRM_MFG_PRVSN_IMPORT_CERT_OUTPUT_STATE_PROVISIONED
+	uint8_t	unused_0[5];
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units.  Even values indicate 16B
-	 * records.  Odd values indicate 32B
-	 * records.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	#define NQ_SRQ_EVENT_TYPE_MASK	UINT32_C(0x3f)
-	#define NQ_SRQ_EVENT_TYPE_SFT	0
-	/* SRQ Threshold Event */
-		#define NQ_SRQ_EVENT_TYPE_SRQ_EVENT  UINT32_C(0x32)
-		#define NQ_SRQ_EVENT_TYPE_LAST	NQ_SRQ_EVENT_TYPE_SRQ_EVENT
+	uint8_t	valid;
+} hwrm_mfg_prvsn_import_cert_output_t, *phwrm_mfg_prvsn_import_cert_output_t;
+
+/* hwrm_mfg_prvsn_import_cert_cmd_err (size:64b/8B) */
+
+typedef struct hwrm_mfg_prvsn_import_cert_cmd_err {
 	/*
-	 * This value define what type of async event has occurred
-	 * on the SRQ.
+	 * command specific error codes that goes to
+	 * the cmd_err field in Common HWRM Error Response.
 	 */
-	uint8_t	event;
-	/* The threshold event has occurred on the specified SRQ. */
-	#define NQ_SRQ_EVENT_EVENT_SRQ_THRESHOLD_EVENT UINT32_C(0x1)
-	#define NQ_SRQ_EVENT_EVENT_LAST		NQ_SRQ_EVENT_EVENT_SRQ_THRESHOLD_EVENT
-	uint16_t	reserved16;
+	uint8_t	code;
+	/* Unknown error. */
+	#define HWRM_MFG_PRVSN_IMPORT_CERT_CMD_ERR_CODE_UNKNOWN		UINT32_C(0x0)
+	/* Slot invalid */
+	#define HWRM_MFG_PRVSN_IMPORT_CERT_CMD_ERR_CODE_SLOT_INVALID	UINT32_C(0x1)
+	/* Slot is provisioned and locked */
+	#define HWRM_MFG_PRVSN_IMPORT_CERT_CMD_ERR_CODE_SLOT_LOCKED	UINT32_C(0x2)
+	/* Non-volatile storage is full or in error. */
+	#define HWRM_MFG_PRVSN_IMPORT_CERT_CMD_ERR_CODE_NO_STORAGE		UINT32_C(0x3)
+	/* Certificate chain verification failed. */
+	#define HWRM_MFG_PRVSN_IMPORT_CERT_CMD_ERR_CODE_CERT_VERIFY_FAIL	UINT32_C(0x4)
+	/* There is no self-signed device id certificate on device */
+	#define HWRM_MFG_PRVSN_IMPORT_CERT_CMD_ERR_CODE_NO_SIGNED_DEVICE_CERT UINT32_C(0x5)
+	#define HWRM_MFG_PRVSN_IMPORT_CERT_CMD_ERR_CODE_LAST		HWRM_MFG_PRVSN_IMPORT_CERT_CMD_ERR_CODE_NO_SIGNED_DEVICE_CERT
+	uint8_t	unused_0[7];
+} hwrm_mfg_prvsn_import_cert_cmd_err_t, *phwrm_mfg_prvsn_import_cert_cmd_err_t;
+
+/****************************
+ * hwrm_mfg_prvsn_get_state *
+ ****************************/
+
+
+/* hwrm_mfg_prvsn_get_state_input (size:128b/16B) */
+
+typedef struct hwrm_mfg_prvsn_get_state_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * This is the SRQ handle value for the queue that has
-	 * reached it's event threshold.  This field carries the
-	 * lower 32b of the value.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	uint32_t	srq_handle_low;
-	uint32_t	v;
+	uint16_t	cmpl_ring;
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue.   The even passes
-	 * will write 1.  The odd passes will write 0.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t	seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define NQ_SRQ_EVENT_V	UINT32_C(0x1)
+	uint16_t	target_id;
 	/*
-	 * This is the SRQ handle value for the queue that has
-	 * reached it's event threshold.  This field carries the
-	 * upper 32b of the value.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	uint32_t	srq_handle_high;
-} nq_srq_event_t, *pnq_srq_event_t;
+	uint64_t	resp_addr;
+} hwrm_mfg_prvsn_get_state_input_t, *phwrm_mfg_prvsn_get_state_input_t;
 
-/* DBQ Async Event Notification */
-/* nq_dbq_event (size:128b/16B) */
+/* hwrm_mfg_prvsn_get_state_output (size:128b/16B) */
 
-typedef struct nq_dbq_event {
-	uint8_t	type;
+typedef struct hwrm_mfg_prvsn_get_state_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Flag indicating if provision get state is valid. */
+	uint8_t	get_state_valid;
+	/*
+	 * Provision get state is invalid. The attestation agent has not
+	 * yet initialized and not completed verification of the
+	 * provisioned certificate chain.
+	 * The slot_status field is undetermined.
+	 */
+	#define HWRM_MFG_PRVSN_GET_STATE_OUTPUT_GET_STATE_VALID_INVALID  UINT32_C(0x0)
+	/* Provision get state is valid for SPDM. */
+	#define HWRM_MFG_PRVSN_GET_STATE_OUTPUT_GET_STATE_VALID_SPDM	UINT32_C(0x1)
+	/* Provision get state is valid for Cerberus. */
+	#define HWRM_MFG_PRVSN_GET_STATE_OUTPUT_GET_STATE_VALID_CERBERUS UINT32_C(0x2)
+	/* Provision get state is valid. There is no attestation agent. */
+	#define HWRM_MFG_PRVSN_GET_STATE_OUTPUT_GET_STATE_VALID_NONE	UINT32_C(0xff)
+	#define HWRM_MFG_PRVSN_GET_STATE_OUTPUT_GET_STATE_VALID_LAST	HWRM_MFG_PRVSN_GET_STATE_OUTPUT_GET_STATE_VALID_NONE
+	/*
+	 * An 8-bit mask returning the provisioned state of the imported
+	 * certificate chain on the device for each available slot.
+	 * Bit-N corresponding to slot N.
+	 * The slot_status field is undetermined if get_state_valid = 0.
+	 */
+	uint8_t	slot_status;
+	/* Slot N entries */
+	#define HWRM_MFG_PRVSN_GET_STATE_OUTPUT_SLOT_STATUS_SLOT_N_MASK	UINT32_C(0xff)
+	#define HWRM_MFG_PRVSN_GET_STATE_OUTPUT_SLOT_STATUS_SLOT_N_SFT		0
+	/* Slot N is not provisioned. */
+		#define HWRM_MFG_PRVSN_GET_STATE_OUTPUT_SLOT_STATUS_SLOT_N_NOT_PROVISIONED  UINT32_C(0x0)
+	/*
+	 * Slot N is provisioned and certificate chain is loaded
+	 * successfully by the attestation agent.
+	 */
+		#define HWRM_MFG_PRVSN_GET_STATE_OUTPUT_SLOT_STATUS_SLOT_N_PROVISIONED	UINT32_C(0x1)
+		#define HWRM_MFG_PRVSN_GET_STATE_OUTPUT_SLOT_STATUS_SLOT_N_LAST		HWRM_MFG_PRVSN_GET_STATE_OUTPUT_SLOT_STATUS_SLOT_N_PROVISIONED
+	uint8_t	unused_0[5];
 	/*
-	 * This field indicates the exact type of the completion.
-	 * By convention, the LSB identifies the length of the
-	 * record in 16B units.  Even values indicate 16B
-	 * records.  Odd values indicate 32B
-	 * records.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	#define NQ_DBQ_EVENT_TYPE_MASK	UINT32_C(0x3f)
-	#define NQ_DBQ_EVENT_TYPE_SFT	0
-	/* DBQ Threshold Event */
-		#define NQ_DBQ_EVENT_TYPE_DBQ_EVENT  UINT32_C(0x34)
-		#define NQ_DBQ_EVENT_TYPE_LAST	NQ_DBQ_EVENT_TYPE_DBQ_EVENT
-	/* This value define what type of action the driver should take. */
-	uint8_t	event;
+	uint8_t	valid;
+} hwrm_mfg_prvsn_get_state_output_t, *phwrm_mfg_prvsn_get_state_output_t;
+
+/******************************
+ * hwrm_mfg_prvsn_export_cert *
+ ******************************/
+
+
+/* hwrm_mfg_prvsn_export_cert_input (size:256b/32B) */
+
+typedef struct hwrm_mfg_prvsn_export_cert_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * The driver should start writing dummy values to the
-	 * the doorbell in an attempt to consume all the PCIE
-	 * posted write resources and prevent doorbell overflow.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define NQ_DBQ_EVENT_EVENT_DBQ_THRESHOLD_EVENT UINT32_C(0x1)
-	#define NQ_DBQ_EVENT_EVENT_LAST		NQ_DBQ_EVENT_EVENT_DBQ_THRESHOLD_EVENT
-	uint16_t	db_pfid;
+	uint16_t	cmpl_ring;
 	/*
-	 * This is the PFID of function that wrote the doorbell that
-	 * crossed the async event threshold.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define NQ_DBQ_EVENT_DB_PFID_MASK UINT32_C(0xf)
-	#define NQ_DBQ_EVENT_DB_PFID_SFT 0
-	uint32_t	db_dpi;
+	uint16_t	seq_id;
 	/*
-	 * This is the DPI of the doorbell write that crossed
-	 * the async event threshold.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define NQ_DBQ_EVENT_DB_DPI_MASK UINT32_C(0xfffff)
-	#define NQ_DBQ_EVENT_DB_DPI_SFT 0
-	uint32_t	v;
+	uint16_t	target_id;
 	/*
-	 * This value is written by the NIC such that it will be different
-	 * for each pass through the completion queue.   The even passes
-	 * will write 1.  The odd passes will write 0.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define NQ_DBQ_EVENT_V	UINT32_C(0x1)
-	uint32_t	db_type_db_xid;
+	uint64_t	resp_addr;
 	/*
-	 * DB 'XID' field from doorbell that crossed the async event
-	 * threshold.  This is a QPID, SID, or CID, depending on
-	 * the db_type field.
+	 * 64-bit Host destination address. This is the host address where
+	 * data will be written.
 	 */
-	#define NQ_DBQ_EVENT_DB_XID_MASK UINT32_C(0xfffff)
-	#define NQ_DBQ_EVENT_DB_XID_SFT  0
+	uint64_t	host_dest_addr;
+	/* Provisioning slot number. 0-indexed. */
+	uint8_t	slot;
+	uint8_t	unused_0;
+	/* Size in bytes of the available host buffer. */
+	uint16_t	host_buf_len;
+	uint8_t	flags;
 	/*
-	 * DB 'type' field from doorbell that crossed the async event
-	 * threshold.
+	 * This bit is only used when external secure SoC is used
+	 * for secure boot. If this bit is set, then export the
+	 * provisioned certificate from the security SoC non-volatile
+	 * storage device.
 	 */
-	#define NQ_DBQ_EVENT_DB_TYPE_MASK UINT32_C(0xf0000000)
-	#define NQ_DBQ_EVENT_DB_TYPE_SFT 28
-} nq_dbq_event_t, *pnq_dbq_event_t;
+	#define HWRM_MFG_PRVSN_EXPORT_CERT_INPUT_FLAGS_SECURE_SOC_SUPPORT	UINT32_C(0x1)
+	uint8_t	unused_1[3];
+} hwrm_mfg_prvsn_export_cert_input_t, *phwrm_mfg_prvsn_export_cert_input_t;
 
-/* Input Read Request Queue (IRRQ) Message */
-/* xrrq_irrq (size:256b/32B) */
+/* hwrm_mfg_prvsn_export_cert_output (size:128b/16B) */
 
-typedef struct xrrq_irrq {
-	uint16_t	credits_type;
-	/* Type indication */
-	#define XRRQ_IRRQ_TYPE	UINT32_C(0x1)
-	/* RDMA Read */
-		#define XRRQ_IRRQ_TYPE_READ_REQ	UINT32_C(0x0)
-	/* Atomic */
-		#define XRRQ_IRRQ_TYPE_ATOMIC_REQ  UINT32_C(0x1)
-		#define XRRQ_IRRQ_TYPE_LAST	XRRQ_IRRQ_TYPE_ATOMIC_REQ
-	/*
-	 * The credit code calculated by Rx path when receiving the
-	 * request. It will be placed in the syndrome credit code with
-	 * the acks on first and last response.
-	 */
-	#define XRRQ_IRRQ_CREDITS_MASK   UINT32_C(0xf800)
-	#define XRRQ_IRRQ_CREDITS_SFT	11
-	uint16_t	reserved16;
-	uint32_t	reserved32;
-	uint32_t	psn;
-	/* The PSN of the outstanding incoming request */
-	#define XRRQ_IRRQ_PSN_MASK UINT32_C(0xffffff)
-	#define XRRQ_IRRQ_PSN_SFT 0
-	uint32_t	msn;
+typedef struct hwrm_mfg_prvsn_export_cert_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Provisioning slot number. 0-indexed. */
+	uint8_t	slot;
+	uint8_t	unused_0;
 	/*
-	 * The value of QPC.pending_ack_msn after it is incremented as a
-	 * result of receiving the read/atomic request.  IRRQ.msn-1 will be
-	 * placed in the MSN field of the first response and IRRQ.msn will
-	 * placed in the MSN field of the last or only response.
+	 * Size in bytes of the exported certificate chain. If there are no
+	 * certificates provisioned for the specified slot, the device will
+	 * return a successful response with cert_len equal to 0.
 	 */
-	#define XRRQ_IRRQ_MSN_MASK UINT32_C(0xffffff)
-	#define XRRQ_IRRQ_MSN_SFT 0
+	uint16_t	cert_len;
+	uint8_t	unused_1[3];
 	/*
-	 * Virtual address on local host for RDMA READ
-	 *
-	 * In case of duplicate Atomic, the VA is not required to
-	 * be validated, only the PSN is, thus this field is used
-	 * to store the value returned in the Ack to the atomic
-	 * request, and if duplicate arrives, this value is used
-	 * again for resending the ack.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	uint64_t	va_or_atomic_result;
-	/* The key to the MR/W in the request */
-	uint32_t	rdma_r_key;
-	/* Length in bytes of the data requested. Length must be 8 if type is atomic. */
-	uint32_t	length;
-} xrrq_irrq_t, *pxrrq_irrq_t;
+	uint8_t	valid;
+} hwrm_mfg_prvsn_export_cert_output_t, *phwrm_mfg_prvsn_export_cert_output_t;
 
-/* Output Read Request Queue (ORRQ) Message */
-/* xrrq_orrq (size:256b/32B) */
+/* hwrm_mfg_prvsn_export_cert_cmd_err (size:64b/8B) */
 
-typedef struct xrrq_orrq {
-	uint16_t	num_sges_type;
-	/* Type indication */
-	#define XRRQ_ORRQ_TYPE	UINT32_C(0x1)
-	/* RDMA Read */
-		#define XRRQ_ORRQ_TYPE_READ_REQ	UINT32_C(0x0)
-	/* Atomic */
-		#define XRRQ_ORRQ_TYPE_ATOMIC_REQ  UINT32_C(0x1)
-		#define XRRQ_ORRQ_TYPE_LAST	XRRQ_ORRQ_TYPE_ATOMIC_REQ
-	/*
-	 * Up to 6 SGEs. This value is 1 if type is atomic as one
-	 * SGE is required to store Atomic response result field. 2
-	 * more bits allocated for future growth.
-	 *
-	 * Note that, if num_sges is 1 for an RDMA Read request, then
-	 * the first_sge_phy_or_sing_sge_va, single_sge_l_key, and
-	 * single_sge_size fields will be populated from the single
-	 * SGE.
-	 *
-	 * If num_sges is 2 or more for an RDMA Read request, then
-	 * the first_sge_phy_or_sing_sge_va field carries the
-	 * physical address in host memory where the first sge is
-	 * stored.  The single_sge_l_key and single_sge_size fields
-	 * are unused in this case.
-	 *
-	 * A special case is a zero-length, zero-sge RDMA read request
-	 * WQE.  In this situation, num_sges will be 1.  However,
-	 * first_sge_phy_or_sing_sge_va, single_sge_l_key, and
-	 * single_sge_size will all be populated with zeros.
-	 */
-	#define XRRQ_ORRQ_NUM_SGES_MASK  UINT32_C(0xf800)
-	#define XRRQ_ORRQ_NUM_SGES_SFT   11
-	uint16_t	reserved16;
-	/* Length in bytes of the data requested. Length must be 8 if type is atomic. */
-	uint32_t	length;
-	uint32_t	psn;
-	/* The PSN of the outstanding outgoing request */
-	#define XRRQ_ORRQ_PSN_MASK UINT32_C(0xffffff)
-	#define XRRQ_ORRQ_PSN_SFT 0
-	uint32_t	end_psn;
+typedef struct hwrm_mfg_prvsn_export_cert_cmd_err {
 	/*
-	 * The expected last PSN on a response to this request where
-	 * an ack with response, rather than just response, should
-	 * arrive. If ack arrive with smaller PSN than end_psn then it
-	 * is considered a NAK.
+	 * command specific error codes that goes to
+	 * the cmd_err field in Common HWRM Error Response.
 	 */
-	#define XRRQ_ORRQ_END_PSN_MASK UINT32_C(0xffffff)
-	#define XRRQ_ORRQ_END_PSN_SFT 0
+	uint8_t	code;
+	/* Unknown error. */
+	#define HWRM_MFG_PRVSN_EXPORT_CERT_CMD_ERR_CODE_UNKNOWN	UINT32_C(0x0)
+	/* Slot invalid */
+	#define HWRM_MFG_PRVSN_EXPORT_CERT_CMD_ERR_CODE_SLOT_INVALID  UINT32_C(0x1)
 	/*
-	 * If num_sges == 1 this is the va of that SGE. Otherwise,
-	 * physical address to the first SGE specified by the WQE.
-	 * Points to the first SGE in the Request's WQE in the SQ.
-	 * It is assumed that WQE does not cross page boundaries!
-	 * Driver is responsible to enforce that. SGEs are 16B
-	 * aligned 0b0000 lsb added to get 64 bit address.
+	 * The provisioned certificates are invalid due to device ID change,
+	 * NVRAM corruption or another reason.
 	 */
-	uint64_t	first_sge_phy_or_sing_sge_va;
-	/* The L_Key of a single SGE if used */
-	uint32_t	single_sge_l_key;
-	/* The size in bytes of the single SGE if used */
-	uint32_t	single_sge_size;
-} xrrq_orrq_t, *pxrrq_orrq_t;
+	#define HWRM_MFG_PRVSN_EXPORT_CERT_CMD_ERR_CODE_CERT_INVALID  UINT32_C(0x2)
+	/* Host provided buffer is too small */
+	#define HWRM_MFG_PRVSN_EXPORT_CERT_CMD_ERR_CODE_BUFFER_LENGTH UINT32_C(0x3)
+	#define HWRM_MFG_PRVSN_EXPORT_CERT_CMD_ERR_CODE_LAST	HWRM_MFG_PRVSN_EXPORT_CERT_CMD_ERR_CODE_BUFFER_LENGTH
+	uint8_t	unused_0[7];
+} hwrm_mfg_prvsn_export_cert_cmd_err_t, *phwrm_mfg_prvsn_export_cert_cmd_err_t;
 
-/* Page Table Entry (PTE) */
-/* ptu_pte (size:64b/8B) */
+/********************************
+ * hwrm_mfg_get_nvm_measurement *
+ ********************************/
 
-typedef struct ptu_pte {
-	uint64_t	page_next_to_last_last_valid;
+
+/* hwrm_mfg_get_nvm_measurement_input (size:128b/16B) */
+
+typedef struct hwrm_mfg_get_nvm_measurement_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * This field indicates if the PTE is valid.   A value of '0'
-	 * indicates that the page is not valid.  A value of '1'
-	 * indicates that the page is valid.  A reference to an
-	 * invalid page will return a PTU error.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define PTU_PTE_VALID		UINT32_C(0x1)
+	uint16_t	cmpl_ring;
 	/*
-	 * This field is used only for "ring" PBLs that are used for
-	 * SQ, RQ, SRQ, or CQ structures.   For all other PBL structures,
-	 * this bit should be zero.  When this bit is '1', it indicates
-	 * that the page pointed to by this PTE is the last page in the
-	 * ring.  A prefetch for the ring should use the first PTE in
-	 * the PBL.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define PTU_PTE_LAST		UINT32_C(0x2)
+	uint16_t	seq_id;
 	/*
-	 * This field is used only for "ring" PBLs that are used for
-	 * SQ, RQ, SRQ, or CQ structures.   For all other PBL structures,
-	 * this bit should be zero.  When this bit is '1', it indicates
-	 * that this is the next-to-last page of the PBL.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define PTU_PTE_NEXT_TO_LAST	UINT32_C(0x4)
-	/* These bits should be programmed to zero. */
-	#define PTU_PTE_UNUSED_MASK	UINT32_C(0xff8)
-	#define PTU_PTE_UNUSED_SFT	3
+	uint16_t	target_id;
 	/*
-	 * This is the upper bits of the physical page controlled by
-	 * this PTE.   If the page is larger than 4KB, then the unused
-	 * lower bits of the page address should be zero.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define PTU_PTE_PAGE_MASK	UINT32_C(0xfffff000)
-	#define PTU_PTE_PAGE_SFT	12
-} ptu_pte_t, *pptu_pte_t;
+	uint64_t	resp_addr;
+} hwrm_mfg_get_nvm_measurement_input_t, *phwrm_mfg_get_nvm_measurement_input_t;
 
-/* Page Directory Entry (PDE) */
-/* ptu_pde (size:64b/8B) */
+/* hwrm_mfg_get_nvm_measurement_output (size:448b/56B) */
 
-typedef struct ptu_pde {
-	uint64_t	page_valid;
-	/*
-	 * This field indicates if the PTE is valid.   A value of '0'
-	 * indicates that the page is not valid.  A value of '1'
-	 * indicates that the page is valid.  A reference to an
-	 * invalid page will return a PTU error.
-	 */
-	#define PTU_PDE_VALID	UINT32_C(0x1)
-	/* These bits should be programmed to zero. */
-	#define PTU_PDE_UNUSED_MASK UINT32_C(0xffe)
-	#define PTU_PDE_UNUSED_SFT 1
+typedef struct hwrm_mfg_get_nvm_measurement_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* Flag indicating if the hash returned is valid. */
+	uint8_t	hash_state;
+	/*
+	 * Measurement hash is invalid. There was an error
+	 * calculating the hash or firmware does not support NVM
+	 * measurement.
+	 */
+	#define HWRM_MFG_GET_NVM_MEASUREMENT_OUTPUT_HASH_STATE_INVALID UINT32_C(0x0)
+	/* Measurement hash is valid. */
+	#define HWRM_MFG_GET_NVM_MEASUREMENT_OUTPUT_HASH_STATE_VALID   UINT32_C(0x1)
+	#define HWRM_MFG_GET_NVM_MEASUREMENT_OUTPUT_HASH_STATE_LAST   HWRM_MFG_GET_NVM_MEASUREMENT_OUTPUT_HASH_STATE_VALID
+	/*
+	 * Flag indicating whether the measurement was calculated
+	 * in real time or calculated during bootup time.
+	 */
+	uint8_t	calc_time;
+	/* Measurement was calculated during bootup time. */
+	#define HWRM_MFG_GET_NVM_MEASUREMENT_OUTPUT_CALC_TIME_BOOTUP UINT32_C(0x0)
+	/* Measurement is calculated in real time */
+	#define HWRM_MFG_GET_NVM_MEASUREMENT_OUTPUT_CALC_TIME_LIVE   UINT32_C(0x1)
+	#define HWRM_MFG_GET_NVM_MEASUREMENT_OUTPUT_CALC_TIME_LAST  HWRM_MFG_GET_NVM_MEASUREMENT_OUTPUT_CALC_TIME_LIVE
+	uint8_t	unused_0[6];
+	/* Thirty two bytes HMAC SHA256 hash of NVM configuration. */
+	uint8_t	hash[32];
+	uint8_t	unused_1[7];
 	/*
-	 * This is the upper bits of the physical page controlled by
-	 * this PTE.   If the page is larger than 4KB, then the unused
-	 * lower bits of the page address should be zero.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	#define PTU_PDE_PAGE_MASK  UINT32_C(0xfffff000)
-	#define PTU_PDE_PAGE_SFT   12
-} ptu_pde_t, *pptu_pde_t;
+	uint8_t	valid;
+} hwrm_mfg_get_nvm_measurement_output_t, *phwrm_mfg_get_nvm_measurement_output_t;
 
-/*
- * This is the 64b doorbell format.  The host writes this message
- * format directly to byte offset 0 of the appropriate doorbell page.
- */
-/* dbc_dbc (size:64b/8B) */
+/*************************
+ * hwrm_mfg_psoc_qstatus *
+ *************************/
 
-typedef struct dbc_dbc {
-	uint32_t	index;
-	/*
-	 * This value is the index being written.
-	 *
-	 * For SQ, RQ, and SRQ, this is the producer index and the unit is
-	 * 16B of queue space for L2 path and for the Engine path. For RoCE
-	 * path there is a legacy mode with 128B unit size and a variable
-	 * size WQE mode with 16B unit size of queue space. This mode is
-	 * configured in the QP.
-	 *
-	 * For CQ this is the consumer index and the unit is 32B of queue
-	 * space for the RoCE/Engine path and the CQ index unit is 16B of
-	 * queue space for the L2 path.
-	 *
-	 * For NQ this is the consumer index and the unit is always 16B of
-	 * queue space.
-	 *
-	 * The index size is 24b for L2 and engine paths and 16b for the
-	 * RoCE path. Unused bits should be written as zero.
-	 */
-	#define DBC_DBC_INDEX_MASK	UINT32_C(0xffffff)
-	#define DBC_DBC_INDEX_SFT	0
+
+/* hwrm_mfg_psoc_qstatus_input (size:192b/24B) */
+
+typedef struct hwrm_mfg_psoc_qstatus_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * The epoch bit provides a frame of reference for the queue index.
-	 * S/W will toggle this bit in the doorbell each time index range is
-	 * wrapped. This allows the receiving HW block to more efficiently
-	 * detect out-of-order doorbells and to ignore the older doorbells.
-	 * Out-of-order doorbells occur normally during dropped doorbell
-	 * recovery.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define DBC_DBC_EPOCH		UINT32_C(0x1000000)
+	uint16_t	cmpl_ring;
 	/*
-	 * The resize_toggle bit tells that the CQ cutoff is done.
-	 * Every time CQ is resized by CQ cutoff, this bit toggles when it
-	 * is done. If this bit toggles, HW can restart to use the resized
-	 * CQ.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define DBC_DBC_RESIZE_TOGGLE	UINT32_C(0x2000000)
-	uint32_t	type_path_xid;
+	uint16_t	seq_id;
 	/*
-	 * This value identifies the resource that the doorbell is intended
-	 * to notify.
-	 *
-	 * For SQ and RQ, this is the QPID.  For SRQ, this is the SID.  For
-	 * CQ, this is the CID. For NQ, this is the NID.
-	 *
-	 * Bits [19:16] of this values must be zero for a SID value.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define DBC_DBC_XID_MASK	UINT32_C(0xfffff)
-	#define DBC_DBC_XID_SFT	0
+	uint16_t	target_id;
 	/*
-	 * This value defines the intended doorbell path between RoCE and
-	 * L2.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define DBC_DBC_PATH_MASK	UINT32_C(0x3000000)
-	#define DBC_DBC_PATH_SFT	24
-	/* This is a RoCE doorbell message. */
-		#define DBC_DBC_PATH_ROCE	(UINT32_C(0x0) << 24)
-	/* This is a L2 doorbell message. */
-		#define DBC_DBC_PATH_L2		(UINT32_C(0x1) << 24)
-	/* Engine path doorbell. */
-		#define DBC_DBC_PATH_ENGINE	(UINT32_C(0x2) << 24)
-		#define DBC_DBC_PATH_LAST	DBC_DBC_PATH_ENGINE
+	uint64_t	resp_addr;
+	/*  */
+	uint32_t	reserved1;
+	/*  */
+	uint32_t	reserved2;
+} hwrm_mfg_psoc_qstatus_input_t, *phwrm_mfg_psoc_qstatus_input_t;
+
+/* hwrm_mfg_psoc_qstatus_output (size:768b/96B) */
+
+typedef struct hwrm_mfg_psoc_qstatus_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* PBL version info. Start at 0, roll if change in structure */
+	uint8_t	pbl_info_version;
+	/* PBL info length. Counts all bytes. */
+	uint8_t	pbl_info_length;
 	/*
-	 * This indicates it is valid doorbell update. It should be set for
-	 * each doorbell written to the chip and set when doorbell message is
-	 * written to the backup doorbell location. The bit should be cleared
-	 * in the backup doorbell location at time zero to indicate that the
-	 * backup doorbell has not yet been written.
+	 * Hardware generation major version. Rolled on incompatible hardware
+	 * changes.
 	 */
-	#define DBC_DBC_VALID		UINT32_C(0x4000000)
+	uint8_t	hw_generation_major;
+	/* Hardware generation minor version. Tracks minor changes. */
+	uint8_t	hw_generation_minor;
+	/* Reserved. */
+	uint8_t	feature_support;
+	/* Firmware version major. */
+	uint8_t	fw_version_major;
+	/* Firmware version minor. */
+	uint8_t	fw_version_minor;
+	/* Indicate which of the two firmware images is active. */
+	uint8_t	active_image;
+	/* Identifies PSoC specific part. */
+	uint32_t	silicon_id;
+	/* Length of part number string in bytes, including NULL terminator. */
+	uint8_t	part_number_string_length;
+	uint8_t	unused_1[3];
+	/* Part number string in ASCII. */
+	uint8_t	part_number_string[64];
+	uint8_t	unused_2[7];
 	/*
-	 * When this bit is set to one, the chip will capture debug
-	 * information for the doorbell ring. This is intended to only be
-	 * used on SQ doorbell rings.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal
+	 * processor, the order of writes has to be such that this field is
+	 * written last.
 	 */
-	#define DBC_DBC_DEBUG_TRACE	UINT32_C(0x8000000)
-	/* This value identifies the type of doorbell being written. */
-	#define DBC_DBC_TYPE_MASK	UINT32_C(0xf0000000)
-	#define DBC_DBC_TYPE_SFT	28
+	uint8_t	valid;
+} hwrm_mfg_psoc_qstatus_output_t, *phwrm_mfg_psoc_qstatus_output_t;
+
+/***************************
+ * hwrm_mfg_selftest_qlist *
+ ***************************/
+
+
+/* hwrm_mfg_selftest_qlist_input (size:128b/16B) */
+
+typedef struct hwrm_mfg_selftest_qlist_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * This is a SQ producer index update.   It indicates one or more
-	 * new entries have been written to the SQ for the QPID indicated
-	 * on the xID field. This type is valid for L2, RoCE and Engine
-	 * path.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-		#define DBC_DBC_TYPE_SQ		(UINT32_C(0x0) << 28)
+	uint16_t	cmpl_ring;
 	/*
-	 * This is a RQ producer index update.   It indicates one or more
-	 * new entries have been written to the RQ for the QPID indicated
-	 * on the xID field. This type is valid for RoCE path.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-		#define DBC_DBC_TYPE_RQ		(UINT32_C(0x1) << 28)
+	uint16_t	seq_id;
 	/*
-	 * This is a SRQ producer index update.   It indicates one or more
-	 * new entries have been written to the SRQ for the SID indicated
-	 * on the xID field. This type is valid for L2 and RoCE path.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-		#define DBC_DBC_TYPE_SRQ		(UINT32_C(0x2) << 28)
+	uint16_t	target_id;
 	/*
-	 * This doorbell command arms the SRQ async event.
-	 * The xID field must identify the SID that is begin armed.
-	 * The index field is will set the arm threshold such that
-	 * a notification will be generated if less than that number
-	 * or SRQ entries are posted. This type is valid for RoCE path.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-		#define DBC_DBC_TYPE_SRQ_ARM	(UINT32_C(0x3) << 28)
+	uint64_t	resp_addr;
+} hwrm_mfg_selftest_qlist_input_t, *phwrm_mfg_selftest_qlist_input_t;
+
+/* hwrm_mfg_selftest_qlist_output (size:192b/24B) */
+
+typedef struct hwrm_mfg_selftest_qlist_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
 	/*
-	 * This is a CQ consumer index update.   It indicates one or more
-	 * entries have been processed off the CQ indicated on the xID
-	 * field.This type is valid for L2, RoCE and Engine path.
-	 */
-		#define DBC_DBC_TYPE_CQ		(UINT32_C(0x4) << 28)
+	 * This field represents the number of tests available to be
+	 * requested by manufacturing tool.
+	 */
+	uint8_t	num_tests;
+	/* This field indicates which self-test is available to be run. */
+	uint8_t	available_tests;
+	/*
+	 * Can run the peripheral tests. Individual peripherals are
+	 * specified in peripheral_tests field.
+	 */
+	#define HWRM_MFG_SELFTEST_QLIST_OUTPUT_AVAILABLE_TESTS_PERIPHERAL_TEST	UINT32_C(0x1)
+	/*
+	 * This field represents the maximum timeout for all the
+	 * tests to complete in milliseconds.
+	 */
+	uint16_t	test_timeout;
+	/*
+	 * This field is a 32 bits bitmap, each bit specifies a peripheral
+	 * test.
+	 */
+	uint32_t	peripheral_tests;
+	/* Can run memory test on Co-CPU peripheral */
+	#define HWRM_MFG_SELFTEST_QLIST_OUTPUT_PERIPHERAL_TESTS_CO_CPU_MEMORY	UINT32_C(0x1)
+	/* Can run test on dpll eeprom peripheral */
+	#define HWRM_MFG_SELFTEST_QLIST_OUTPUT_PERIPHERAL_TESTS_DPLL_EEPROM	UINT32_C(0x2)
+	/* Can run test on dpll mmcx connector peripheral */
+	#define HWRM_MFG_SELFTEST_QLIST_OUTPUT_PERIPHERAL_TESTS_DPLL_MMCX	UINT32_C(0x4)
+	/* Can run test on gnss peripheral */
+	#define HWRM_MFG_SELFTEST_QLIST_OUTPUT_PERIPHERAL_TESTS_GNSS		UINT32_C(0x8)
+	/* Can run pcie test on Co-CPU peripheral */
+	#define HWRM_MFG_SELFTEST_QLIST_OUTPUT_PERIPHERAL_TESTS_CO_CPU_PCIE	UINT32_C(0x10)
+	/* Can run test on internal fabric peripheral */
+	#define HWRM_MFG_SELFTEST_QLIST_OUTPUT_PERIPHERAL_TESTS_INTERNAL_FABRIC	UINT32_C(0x20)
+	/* Can run test on oven controlled crystal oscillator peripheral */
+	#define HWRM_MFG_SELFTEST_QLIST_OUTPUT_PERIPHERAL_TESTS_OCXO		UINT32_C(0x40)
+	/* Can run test on telecom pll peripheral */
+	#define HWRM_MFG_SELFTEST_QLIST_OUTPUT_PERIPHERAL_TESTS_TELECOM_PLL	UINT32_C(0x80)
+	uint8_t	unused_2[7];
 	/*
-	 * this is a CQ consumer index update that also arms the CQ for
-	 * solicited events. This type is valid for RoCE path.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-		#define DBC_DBC_TYPE_CQ_ARMSE	(UINT32_C(0x5) << 28)
+	uint8_t	valid;
+} hwrm_mfg_selftest_qlist_output_t, *phwrm_mfg_selftest_qlist_output_t;
+
+/**************************
+ * hwrm_mfg_selftest_exec *
+ **************************/
+
+
+/* hwrm_mfg_selftest_exec_input (size:192b/24B) */
+
+typedef struct hwrm_mfg_selftest_exec_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * This is a CQ consumer index update that also arms the CQ
-	 * for any new CQE. This type is valid for L2, RoCE and Engine
-	 * path.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-		#define DBC_DBC_TYPE_CQ_ARMALL	(UINT32_C(0x6) << 28)
+	uint16_t	cmpl_ring;
 	/*
-	 * This is a CQ arm enable message.  This message must be sent
-	 * from the privileged driver before a new CQ_ARMSE or CQ_ARMALL
-	 * message will be accepted.
-	 *
-	 * This doorbell can only be sent from the privileged (first)
-	 * doorbell page of a function.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-		#define DBC_DBC_TYPE_CQ_ARMENA	(UINT32_C(0x7) << 28)
+	uint16_t	seq_id;
 	/*
-	 * This doorbell command enables the SRQ async event
-	 * to be armed.  This message must be sent from the privileged
-	 * driver before a new SRQ_ARM message will be accepted.
-	 * The xID field must identify the SID that is begin enabled
-	 * for arm.
-	 *
-	 * This doorbell can only be sent from the privileged (first)
-	 * doorbell page of a function.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-		#define DBC_DBC_TYPE_SRQ_ARMENA	(UINT32_C(0x8) << 28)
+	uint16_t	target_id;
 	/*
-	 * This doorbell command indicates that the cutoff CQE has
-	 * been processed and the driver is now processing completions
-	 * from the new CQ.
-	 *
-	 * The index field for this doorbell type must be zero.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-		#define DBC_DBC_TYPE_CQ_CUTOFF_ACK  (UINT32_C(0x9) << 28)
+	uint64_t	resp_addr;
+	/* This field indicates which self-test is being requested to run. */
+	uint8_t	flags;
 	/*
-	 * This is a NQ consumer index update. It indicates one or more
-	 * entries have been processed off the NQ indicated on the xID
-	 * field. This type is valid for L2, RoCE and Engine path.
+	 * Run the Peripheral tests specified in peripheral_tests
+	 * field.
 	 */
-		#define DBC_DBC_TYPE_NQ		(UINT32_C(0xa) << 28)
+	#define HWRM_MFG_SELFTEST_EXEC_INPUT_FLAGS_PERIPHERAL_TEST	UINT32_C(0x1)
+	uint8_t	unused_0[3];
 	/*
-	 * This is a NQ consumer index update that also arms the NQ for
-	 * any new NQE. This type is valid for L2, RoCE and Engine path.
+	 * This field is a 32 bits bitmap to specify which peripheral tests to
+	 * run, each bit specifies a peripheral test.
+	 */
+	uint32_t	peripheral_tests;
+	/* Run memory test on Co-CPU peripheral */
+	#define HWRM_MFG_SELFTEST_EXEC_INPUT_PERIPHERAL_TESTS_CO_CPU_MEMORY	UINT32_C(0x1)
+	/* Run test on dpll eeprom peripheral */
+	#define HWRM_MFG_SELFTEST_EXEC_INPUT_PERIPHERAL_TESTS_DPLL_EEPROM	UINT32_C(0x2)
+	/* Run test on dpll mmcx connector peripheral */
+	#define HWRM_MFG_SELFTEST_EXEC_INPUT_PERIPHERAL_TESTS_DPLL_MMCX	UINT32_C(0x4)
+	/* Run test on gnss peripheral */
+	#define HWRM_MFG_SELFTEST_EXEC_INPUT_PERIPHERAL_TESTS_GNSS		UINT32_C(0x8)
+	/* Run pcie test on Co-CPU peripheral */
+	#define HWRM_MFG_SELFTEST_EXEC_INPUT_PERIPHERAL_TESTS_CO_CPU_PCIE	UINT32_C(0x10)
+	/* Run test on internal fabric peripheral */
+	#define HWRM_MFG_SELFTEST_EXEC_INPUT_PERIPHERAL_TESTS_INTERNAL_FABRIC	UINT32_C(0x20)
+	/* Run test on oven controlled crystal oscillator peripheral */
+	#define HWRM_MFG_SELFTEST_EXEC_INPUT_PERIPHERAL_TESTS_OCXO		UINT32_C(0x40)
+	/* Run test on telecom pll peripheral */
+	#define HWRM_MFG_SELFTEST_EXEC_INPUT_PERIPHERAL_TESTS_TELECOM_PLL	UINT32_C(0x80)
+} hwrm_mfg_selftest_exec_input_t, *phwrm_mfg_selftest_exec_input_t;
+
+/* hwrm_mfg_selftest_exec_output (size:192b/24B) */
+
+typedef struct hwrm_mfg_selftest_exec_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* The following tests were requested to be run. */
+	uint8_t	requested_tests;
+	/* A request was made to run the peripheral tests. */
+	#define HWRM_MFG_SELFTEST_EXEC_OUTPUT_REQUESTED_TESTS_PERIPHERAL_TEST	UINT32_C(0x1)
+	/*
+	 * If a test was requested to be run as seen in the requested_tests
+	 * field, this bit indicates whether the test was successful(1) or
+	 * failed(0).
 	 */
-		#define DBC_DBC_TYPE_NQ_ARM	(UINT32_C(0xb) << 28)
+	uint8_t	test_success;
 	/*
-	 * This is a NQ consumer index update that also arms the NQ for
-	 * any new NQE. It is used for the legacy INT mask. This type
-	 * is valid for L2, RoCE and Engine path.
+	 * If requested, a value of 1 indicates the peripheral tests
+	 * completed successfully.
 	 */
-		#define DBC_DBC_TYPE_NQ_MASK	(UINT32_C(0xe) << 28)
+	#define HWRM_MFG_SELFTEST_EXEC_OUTPUT_TEST_SUCCESS_PERIPHERAL_TEST	UINT32_C(0x1)
+	uint8_t	unused_0[2];
 	/*
-	 * This doorbell command is used during doorbell moderation
-	 * to consume system BW and help prevent doorbell FIFO
-	 * overflow.
-	 *
-	 * All other fields should be zero for NULL doorbell.
-	 * For doorbell recovery, NULL doorbell type in the Application
-	 * table indicates that it is the last QP entry for the function.
-	 * This type is valid for L2, RoCE and Engine path.
+	 * This field is a 32 bits bitmap for firmware to indicate which
+	 * peripheral tests are specified by the host, each bit specifies
+	 * a peripheral test.
+	 */
+	uint32_t	peripheral_requested_tests;
+	/* Co-CPU peripheral test requested */
+	#define HWRM_MFG_SELFTEST_EXEC_OUTPUT_PERIPHERAL_REQUESTED_TESTS_CO_CPU_MEMORY	UINT32_C(0x1)
+	/* dpll eeprom peripheral test requested */
+	#define HWRM_MFG_SELFTEST_EXEC_OUTPUT_PERIPHERAL_REQUESTED_TESTS_DPLL_EEPROM	UINT32_C(0x2)
+	/* dpll mmcx connector peripheral test requested */
+	#define HWRM_MFG_SELFTEST_EXEC_OUTPUT_PERIPHERAL_REQUESTED_TESTS_DPLL_MMCX	UINT32_C(0x4)
+	/* gnss peripheral test requested */
+	#define HWRM_MFG_SELFTEST_EXEC_OUTPUT_PERIPHERAL_REQUESTED_TESTS_GNSS		UINT32_C(0x8)
+	/* pcie test on Co-CPU peripheral test requested */
+	#define HWRM_MFG_SELFTEST_EXEC_OUTPUT_PERIPHERAL_REQUESTED_TESTS_CO_CPU_PCIE	UINT32_C(0x10)
+	/* internal fabric peripheral test requested */
+	#define HWRM_MFG_SELFTEST_EXEC_OUTPUT_PERIPHERAL_REQUESTED_TESTS_INTERNAL_FABRIC	UINT32_C(0x20)
+	/* oven controlled crystal oscillator peripheral test requested */
+	#define HWRM_MFG_SELFTEST_EXEC_OUTPUT_PERIPHERAL_REQUESTED_TESTS_OCXO		UINT32_C(0x40)
+	/* telecom pll peripheral test requested */
+	#define HWRM_MFG_SELFTEST_EXEC_OUTPUT_PERIPHERAL_REQUESTED_TESTS_TELECOM_PLL	UINT32_C(0x80)
+	/*
+	 * This field is a 32 bits bitmap for firmware to indicate which
+	 * peripheral tests are successfully executed, each bit specifies
+	 * a peripheral test.
+	 */
+	uint32_t	peripheral_tests_success;
+	/* Co-CPU peripheral test is successfully executed */
+	#define HWRM_MFG_SELFTEST_EXEC_OUTPUT_PERIPHERAL_TESTS_SUCCESS_CO_CPU_MEMORY	UINT32_C(0x1)
+	/* dpll eeprom peripheral test is successfully executed */
+	#define HWRM_MFG_SELFTEST_EXEC_OUTPUT_PERIPHERAL_TESTS_SUCCESS_DPLL_EEPROM	UINT32_C(0x2)
+	/* dpll mmcx connector peripheral test is successfully executed */
+	#define HWRM_MFG_SELFTEST_EXEC_OUTPUT_PERIPHERAL_TESTS_SUCCESS_DPLL_MMCX	UINT32_C(0x4)
+	/* gnss peripheral test is successfully executed */
+	#define HWRM_MFG_SELFTEST_EXEC_OUTPUT_PERIPHERAL_TESTS_SUCCESS_GNSS		UINT32_C(0x8)
+	/* pcie test on Co-CPU peripheral test is successfully executed */
+	#define HWRM_MFG_SELFTEST_EXEC_OUTPUT_PERIPHERAL_TESTS_SUCCESS_CO_CPU_PCIE	UINT32_C(0x10)
+	/* internal fabric peripheral test is successfully executed */
+	#define HWRM_MFG_SELFTEST_EXEC_OUTPUT_PERIPHERAL_TESTS_SUCCESS_INTERNAL_FABRIC	UINT32_C(0x20)
+	/*
+	 * oven controlled crystal oscillator peripheral test is successfully
+	 * executed
+	 */
+	#define HWRM_MFG_SELFTEST_EXEC_OUTPUT_PERIPHERAL_TESTS_SUCCESS_OCXO		UINT32_C(0x40)
+	/* telecom pll peripheral test is successfully executed */
+	#define HWRM_MFG_SELFTEST_EXEC_OUTPUT_PERIPHERAL_TESTS_SUCCESS_TELECOM_PLL	UINT32_C(0x80)
+	uint8_t	unused_1[3];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-		#define DBC_DBC_TYPE_NULL	(UINT32_C(0xf) << 28)
-		#define DBC_DBC_TYPE_LAST	DBC_DBC_TYPE_NULL
-} dbc_dbc_t, *pdbc_dbc_t;
+	uint8_t	valid;
+} hwrm_mfg_selftest_exec_output_t, *phwrm_mfg_selftest_exec_output_t;
 
-/*
- * This is the 32b doorbell format.  The host writes this message
- * format directly to byte offset 8 of the appropriate doorbell page.
- */
-/* dbc_dbc32 (size:32b/4B) */
+/****************
+ * hwrm_oem_cmd *
+ ****************/
 
-typedef struct dbc_dbc32 {
-	uint32_t	type_abs_incr_xid;
+
+/* hwrm_oem_cmd_input (size:1024b/128B) */
+
+typedef struct hwrm_oem_cmd_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * This value identifies the resource that the doorbell is intended
-	 * to notify.
-	 *
-	 * For SQ and RQ, this is the QPID.  For SRQ, this is the SID.  For
-	 * CQ, this is the CID.
-	 *
-	 * Bits [19:16] of this values must be zero for a SID value.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define DBC_DBC32_XID_MASK UINT32_C(0xfffff)
-	#define DBC_DBC32_XID_SFT  0
+	uint16_t	cmpl_ring;
 	/*
-	 * This value defines the intended doorbell path between RoCE and
-	 * L2.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define DBC_DBC32_PATH_MASK UINT32_C(0xc00000)
-	#define DBC_DBC32_PATH_SFT 22
-	/* This is a RoCE doorbell message. */
-		#define DBC_DBC32_PATH_ROCE  (UINT32_C(0x0) << 22)
-	/* This is a L2 doorbell message. */
-		#define DBC_DBC32_PATH_L2	(UINT32_C(0x1) << 22)
-		#define DBC_DBC32_PATH_LAST DBC_DBC32_PATH_L2
+	uint16_t	seq_id;
 	/*
-	 * When abs=0, this value is the value to add to the appropriate
-	 * index value.
-	 *
-	 * When abs=1, this value is the new value for the index.  Absolute
-	 * value is used when the queue is being wrapped.  When abs=1,
-	 * the incr value follows the same rules as the index value
-	 * in the 64b doorbell.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define DBC_DBC32_INCR_MASK UINT32_C(0xf000000)
-	#define DBC_DBC32_INCR_SFT 24
-	/* This value defines how the incr value will be interpreted. */
-	#define DBC_DBC32_ABS	UINT32_C(0x10000000)
-	/* This value identifies the type of doorbell being written. */
-	#define DBC_DBC32_TYPE_MASK UINT32_C(0xe0000000)
-	#define DBC_DBC32_TYPE_SFT 29
+	uint16_t	target_id;
 	/*
-	 * This is a SQ producer index update.   It indicates one or more
-	 * new entries have been written to the SQ for the QPID indicated
-	 * on the xID field.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-		#define DBC_DBC32_TYPE_SQ	(UINT32_C(0x0) << 29)
-		#define DBC_DBC32_TYPE_LAST DBC_DBC32_TYPE_SQ
-} dbc_dbc32_t, *pdbc_dbc32_t;
+	uint64_t	resp_addr;
+	/*
+	 * The organization owning the message format. Set this field
+	 * to 0x14e4 when used for Broadcom internal use when
+	 * the naming authority is set to PCI_SIG.
+	 */
+	uint32_t	oem_id;
+	/* The naming authority used for setting the oem_id. */
+	uint8_t	naming_authority;
+	/* Invalid naming authority */
+	#define HWRM_OEM_CMD_INPUT_NAMING_AUTHORITY_INVALID UINT32_C(0x0)
+	/* PCI_SIG naming authority numbering is used */
+	#define HWRM_OEM_CMD_INPUT_NAMING_AUTHORITY_PCI_SIG UINT32_C(0x1)
+	#define HWRM_OEM_CMD_INPUT_NAMING_AUTHORITY_LAST   HWRM_OEM_CMD_INPUT_NAMING_AUTHORITY_PCI_SIG
+	/* The message family within the organization. */
+	uint8_t	message_family;
+	/* Invalid message family */
+	#define HWRM_OEM_CMD_INPUT_MESSAGE_FAMILY_INVALID UINT32_C(0x0)
+	/* This message is targeted for Truflow */
+	#define HWRM_OEM_CMD_INPUT_MESSAGE_FAMILY_TRUFLOW UINT32_C(0x1)
+	/* This message is targeted for RoCE */
+	#define HWRM_OEM_CMD_INPUT_MESSAGE_FAMILY_ROCE	UINT32_C(0x2)
+	#define HWRM_OEM_CMD_INPUT_MESSAGE_FAMILY_LAST   HWRM_OEM_CMD_INPUT_MESSAGE_FAMILY_ROCE
+	uint16_t	unused;
+	/* This field contains the vendor specific command data. */
+	uint32_t	oem_data[26];
+} hwrm_oem_cmd_input_t, *phwrm_oem_cmd_input_t;
 
-/*
- * This is the 64b Push Start doorbell format. The host writes this message
- * format directly to offset of each push associated WCB (write combine
- * buffer) within doorbell page. WCB#0 = offset 16, WCB#1 = offset 24,
- * WCB#2 = offset 32, ... The start doorbell is followed by write combining
- * data to the WCB and then that is followed by a end doorbell.
- */
-/* db_push_start (size:64b/8B) */
+/* hwrm_oem_cmd_output (size:768b/96B) */
 
-typedef struct db_push_start {
-	uint64_t	db;
-	/*
-	 * This is the push index and should be the SQ slot index, aligned
-	 * to the start of the corresponding push WQE/packet in the Send
-	 * Queue.
-	 *
-	 * The index size is 16b for RoCE path and 24b for L2 and Engine
-	 * paths. Any unused bits should be written as zero.
-	 *
-	 * The index unit is 16B for L2 path. For RoCE there is a legacy
-	 * mode with 128B unit size and a variable size mode with 16B unit
-	 * size. For Engine mode, the unit size is 16B, where RQEs are
-	 * always 128B - so it always increments by eight 16B slots per
-	 * RQE.
-	 *
-	 * > This field is not used by the older versions of the chip, but
-	 * > is used in this and future revisions of the chip. In older
-	 * > versions of the chip, the driver is required to complete the
-	 * > push doorbell operation by following it with a regular doorbell
-	 * > which will be used to properly increment the producer index.
-	 * > This extra doorbell write is not needed on this and future
-	 * > versions of the chip.
-	 */
-	#define DB_PUSH_START_DB_INDEX_MASK	UINT32_C(0xffffff)
-	#define DB_PUSH_START_DB_INDEX_SFT	0
+typedef struct hwrm_oem_cmd_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* The organization owning the message format. */
+	uint32_t	oem_id;
+	/* The naming authority used for setting the oem_id. */
+	uint8_t	naming_authority;
+	/* The message family within the organization. */
+	uint8_t	message_family;
+	uint16_t	unused;
+	/* This field contains the vendor specific response data. */
+	uint32_t	oem_data[18];
+	uint8_t	unused_1[7];
 	/*
-	 * This value is the PI index (lower 8bits) within 4K DPI
-	 * associated with push write. It is the doorbell page that
-	 * contains the WCB that will be used.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	#define DB_PUSH_START_DB_PI_LO_MASK	UINT32_C(0xff000000)
-	#define DB_PUSH_START_DB_PI_LO_SFT	24
+	uint8_t	valid;
+} hwrm_oem_cmd_output_t, *phwrm_oem_cmd_output_t;
+
+/***********
+ * hwrm_sv *
+ ***********/
+
+
+/* hwrm_sv_input (size:1152b/144B) */
+
+typedef struct hwrm_sv_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * This value identifies the resource that the doorbell is intended
-	 * to notify.
-	 *
-	 * This is the QPID.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define DB_PUSH_START_DB_XID_MASK	UINT32_C(0xfffff00000000)L
-	#define DB_PUSH_START_DB_XID_SFT	32
+	uint16_t	cmpl_ring;
 	/*
-	 * This value is the PI index (upper 4bits) within 4K DPI
-	 * associated with push write. It is the doorbell page that
-	 * contains the WCB that will be used.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define DB_PUSH_START_DB_PI_HI_MASK	UINT32_C(0xf0000000000000)L
-	#define DB_PUSH_START_DB_PI_HI_SFT	52
-	/* This value identifies the type of doorbell being written. */
-	#define DB_PUSH_START_DB_TYPE_MASK	UINT32_C(0xf000000000000000)L
-	#define DB_PUSH_START_DB_TYPE_SFT	60
+	uint16_t	seq_id;
 	/*
-	 * This is a SQ producer index update for Push. It indicates
-	 * one or more new entries have been written to the SQ for the
-	 * QPID indicated on the `xid` field.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-		#define DB_PUSH_START_DB_TYPE_PUSH_START  (UINT32_C(0xc)L << 60)
+	uint16_t	target_id;
 	/*
-	 * This is a SQ producer index update for Push. It indicates
-	 * one or more new entries have been written to the SQ for the
-	 * QPID indicated on the `xid` field.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-		#define DB_PUSH_START_DB_TYPE_PUSH_END	(UINT32_C(0xd)L << 60)
-		#define DB_PUSH_START_DB_TYPE_LAST	DB_PUSH_START_DB_TYPE_PUSH_END
-} db_push_start_t, *pdb_push_start_t;
+	uint64_t	resp_addr;
+	uint32_t	opaque[32];
+} hwrm_sv_input_t, *phwrm_sv_input_t;
 
-/*
- * This is the 64b Push End doorbell format. The host writes this message
- * format directly to offset of each push associated WCB (write combine
- * buffer) within doorbell page. WCB#0 = offset 16, WCB#1 = offset 24,
- * WCB#2 = offset 32, ... The start doorbell is followed by write combining
- * data to the WCB and then that is followed by a end doorbell.
- */
-/* db_push_end (size:64b/8B) */
+/* hwrm_sv_output (size:1088b/136B) */
 
-typedef struct db_push_end {
-	uint64_t	db;
+typedef struct hwrm_sv_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint32_t	opaque[32];
+} hwrm_sv_output_t, *phwrm_sv_output_t;
+
+/*******************
+ * hwrm_udcc_qcaps *
+ *******************/
+
+
+/* hwrm_udcc_qcaps_input (size:128b/16B) */
+
+typedef struct hwrm_udcc_qcaps_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * This is the producer index and should be the queue index of the
-	 * last WQE written plus the length field contained in that WQE.
-	 * For example, if the length is 8 index units and the WQE was
-	 * written to the first location in the queue (zero), this index
-	 * should be written to 8. The index should point to the start of
-	 * the first location that has not been filled in with WQE data.
-	 *
-	 * For L2 and Engine SQ, the index unit is 16B. For RoCE there are
-	 * two modes. For Legacy fixed size RQE mode, the unit is 128B. For
-	 * variable size RQE mode, the unit is 16B.
-	 *
-	 * The index size is 24b for L2 and engine paths and 16b for the
-	 * RoCE path. Unused bits should be written as zero.
-	 *
-	 * > In past revisions of this chip, this field was the push index
-	 * > rather than the producer index. For this version of the chip
-	 * > and future versions of the chip, this field must be the
-	 * > producer index, as described above.
-	 * >
-	 * > Also, in past revisions of this chip, an additional
-	 * > doorbell write was needed to communicate the producer index.
-	 * > In this and future versions of the chip, this extra doorbell
-	 * > write is no longer needed.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define DB_PUSH_END_DB_INDEX_MASK	UINT32_C(0xffffff)
-	#define DB_PUSH_END_DB_INDEX_SFT	0
+	uint16_t	cmpl_ring;
 	/*
-	 * This value is the PI index (lower 8bits) within 4K DPI
-	 * associated with push write. It is the doorbell page that
-	 * contains the WCB that will be used.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define DB_PUSH_END_DB_PI_LO_MASK	UINT32_C(0xff000000)
-	#define DB_PUSH_END_DB_PI_LO_SFT	24
+	uint16_t	seq_id;
 	/*
-	 * This value identifies the resource that the doorbell is intended
-	 * to notify.
-	 *
-	 * This is the QPID.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define DB_PUSH_END_DB_XID_MASK	UINT32_C(0xfffff00000000)L
-	#define DB_PUSH_END_DB_XID_SFT	32
+	uint16_t	target_id;
 	/*
-	 * This value is the PI index (upper 4bits) within 4K DPI
-	 * associated with push write. It is the doorbell page that
-	 * contains the WCB that will be used.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define DB_PUSH_END_DB_PI_HI_MASK	UINT32_C(0xf0000000000000)L
-	#define DB_PUSH_END_DB_PI_HI_SFT	52
+	uint64_t	resp_addr;
+} hwrm_udcc_qcaps_input_t, *phwrm_udcc_qcaps_input_t;
+
+/* hwrm_udcc_qcaps_output (size:192b/24B) */
+
+typedef struct hwrm_udcc_qcaps_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
 	/*
-	 * This value defines the intended doorbell path between RoCE and
-	 * L2.
+	 * This field represents guaranteed minimum number of UDCC sessions
+	 * available to the function.
 	 */
-	#define DB_PUSH_END_DB_PATH_MASK	UINT32_C(0x300000000000000)L
-	#define DB_PUSH_END_DB_PATH_SFT	56
-	/* This is a RoCE doorbell message. */
-		#define DB_PUSH_END_DB_PATH_ROCE	(UINT32_C(0x0)L << 56)
-	/* This is a L2 doorbell message. */
-		#define DB_PUSH_END_DB_PATH_L2	(UINT32_C(0x1)L << 56)
-	/* Engine path doorbell. */
-		#define DB_PUSH_END_DB_PATH_ENGINE	(UINT32_C(0x2)L << 56)
-		#define DB_PUSH_END_DB_PATH_LAST	DB_PUSH_END_DB_PATH_ENGINE
+	uint16_t	min_sessions;
 	/*
-	 * When this bit is set to one, the chip will capture debug
-	 * information for the doorbell ring. This is intended to only be
-	 * used on SQ doorbell rings.
+	 * This field represents unguaranteed maximum number of UDCC sessions
+	 * available to the function.
 	 */
-	#define DB_PUSH_END_DB_DEBUG_TRACE	UINT32_C(0x800000000000000)L
-	/* This value identifies the type of doorbell being written. */
-	#define DB_PUSH_END_DB_TYPE_MASK	UINT32_C(0xf000000000000000)L
-	#define DB_PUSH_END_DB_TYPE_SFT	60
+	uint16_t	max_sessions;
 	/*
-	 * This is a SQ producer index update for Push. It indicates
-	 * one or more new entries have been written to the SQ for the
-	 * QPID indicated on the `xid` field.
+	 * This value indicates the type of session being modified by the
+	 * UDCC.
 	 */
-		#define DB_PUSH_END_DB_TYPE_PUSH_START   (UINT32_C(0xc)L << 60)
+	uint8_t	session_type;
+	/* sessions are allocated on a per destination basis. */
+	#define HWRM_UDCC_QCAPS_OUTPUT_SESSION_TYPE_PER_DESTINATION UINT32_C(0x0)
+	/* sessions are allocated on a per QP basis. */
+	#define HWRM_UDCC_QCAPS_OUTPUT_SESSION_TYPE_PER_QP	UINT32_C(0x1)
+	#define HWRM_UDCC_QCAPS_OUTPUT_SESSION_TYPE_LAST	HWRM_UDCC_QCAPS_OUTPUT_SESSION_TYPE_PER_QP
+	uint8_t	unused_0[3];
 	/*
-	 * This is a SQ producer index update for Push. It indicates
-	 * one or more new entries have been written to the SQ for the
-	 * QPID indicated on the `xid` field.
+	 * This field represents the maximum number of bytes of UDCC program
+	 * configuration data that one hwrm_udcc_comp_cfg request or
+	 * hwrm_udcc_comp_qcfg response can transfer.
+	 * The value is determined by the UDCC firmware.
 	 */
-		#define DB_PUSH_END_DB_TYPE_PUSH_END	(UINT32_C(0xd)L << 60)
-		#define DB_PUSH_END_DB_TYPE_LAST	DB_PUSH_END_DB_TYPE_PUSH_END
-} db_push_end_t, *pdb_push_end_t;
-
-/*
- * This is the Push information that is the second 8B of the Push
- * Doorbell.
- */
-/* db_push_info (size:64b/8B) */
-
-typedef struct db_push_info {
-	uint32_t	push_size_push_index;
+	uint16_t	max_comp_cfg_xfer;
 	/*
-	 * This value is the index for the push being started. For
-	 * example, if the push_size is 8 index units and the WQE was
-	 * written to the first location in the queue (zero), this
-	 * push_index should be written to 0. The push_index should point
-	 * to the start of the first location that the push is started.
-	 *
-	 * The push_index unit is 16B, except in RoCE legacy WQE mode, in
-	 * which case the unit is 128B.
-	 *
-	 * The push_index size is 24b for L2 and 16b for the RoCE path.
-	 * Unused bits should be written as zero.
+	 * This field represents the maximum number of bytes of UDCC program
+	 * status or statistics data that one hwrm_udcc_comp_query response
+	 * can transfer. The value is determined by the UDCC firmware.
 	 */
-	#define DB_PUSH_INFO_PUSH_INDEX_MASK UINT32_C(0xffffff)
-	#define DB_PUSH_INFO_PUSH_INDEX_SFT 0
+	uint16_t	max_comp_data_xfer;
+	uint8_t	unused_1[3];
 	/*
-	 * This value defines the size of push. The unit is 8B. The value
-	 * 0 means 256B size of push. The push write is done in 8B units
-	 * by the SW.
-	 *
-	 * Note: For packet rate performance reasons, it is recommended
-	 * that SW aligns push requests with a granularity of 16B.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	#define DB_PUSH_INFO_PUSH_SIZE_MASK UINT32_C(0x1f000000)
-	#define DB_PUSH_INFO_PUSH_SIZE_SFT  24
-	uint32_t	reserved32;
-} db_push_info_t, *pdb_push_info_t;
+	uint8_t	valid;
+} hwrm_udcc_qcaps_output_t, *phwrm_udcc_qcaps_output_t;
 
-/*
- * This is the "Absolute" 32b Doorbell format. The host writes this
- * message format directly to byte offset 0xC of the appropriate
- * doorbell page.
- *
- * Absolute doorbells are supported for only a limited number of
- * functions and for a limited number of xID values within each
- * function.
- *
- * Doorbell recovery can be supported for absolute 32b doorbells.
- */
-/* dbc_absolute_db_32 (size:32b/4B) */
+/*****************
+ * hwrm_udcc_cfg *
+ *****************/
 
-typedef struct dbc_absolute_db_32 {
-	uint32_t	index;
-	/*
-	 * This value is the index being written. For SQ, RQ, SRQ, this is
-	 * the producer index and should be the queue index of the last WQE
-	 * or BD written plus the length field contained in that WQE/BD.
-	 * For example, if the length is 8 index units and the WQE was
-	 * written to the first location in the queue (zero), this index
-	 * should be written to 8. The index should point to the start of
-	 * the first location that has not been filled in with WQE/BD data.
-	 *
-	 * For CQ, this is the consumer index and should be the starting
-	 * queue index of the last CQE processed plus the size of the last
-	 * processed CQE in index units. The index should point to the start
-	 * of the first CQE in the queue that has not been processed.
-	 *
-	 * For NQ, this is the consumer index and should be the starting
-	 * queue index of the last NQE processed plus the size of the last
-	 * processed NQE in index units. The index should point to the start
-	 * of the first NQE in the queue that has not been processed.
-	 *
-	 * For L2 and Engine SQ, the index unit is 16B. For RoCE there are
-	 * two modes. For Legacy fixed size RQE mode, the unit is 128B. For
-	 * variable size RQE mode, the unit is 16B. For RoCE and engine CQs,
-	 * the index unit is 32B. For L2 CQs, the index unit is 16B.
-	 *
-	 * For NQ this is the consumer index and the unit is always 16B of
-	 * queue space.
-	 *
-	 * The index size is 16b for all queue types. This limits the size
-	 * of some queues when absolute doorbells are in use. Unused bits
-	 * should be written as zero.
-	 */
-	#define DBC_ABSOLUTE_DB_32_INDEX_MASK	UINT32_C(0xffff)
-	#define DBC_ABSOLUTE_DB_32_INDEX_SFT	0
+
+/* hwrm_udcc_cfg_input (size:192b/24B) */
+
+typedef struct hwrm_udcc_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * The epoch bit provides a frame of reference for the queue index.
-	 * S/W will toggle this bit in the doorbell each time index range is
-	 * wrapped. This allows the receiving HW block to more efficiently
-	 * detect out-of-order doorbells and to ignore the older doorbells.
-	 * Out-of-order doorbells occur normally during dropped doorbell
-	 * recovery.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define DBC_ABSOLUTE_DB_32_EPOCH		UINT32_C(0x10000)
+	uint16_t	cmpl_ring;
 	/*
-	 * The resize_toggle bit tells that the CQ cutoff is done.
-	 * Every time CQ is resized by CQ cutoff, this bit toggles when it
-	 * is done. If this bit toggles, HW can restart to use the resized
-	 * CQ.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define DBC_ABSOLUTE_DB_32_RESIZE_TOGGLE	UINT32_C(0x20000)
+	uint16_t	seq_id;
 	/*
-	 * This value identifies the resource that the doorbell is intended
-	 * to notify.
-	 *
-	 * This is a "modified" xID value. The DBR block will convert this
-	 * value into the full xID value by looking up the base xID for this
-	 * particular function and adding the mxID value to that base value.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define DBC_ABSOLUTE_DB_32_MXID_MASK	UINT32_C(0xfc0000)
-	#define DBC_ABSOLUTE_DB_32_MXID_SFT	18
+	uint16_t	target_id;
 	/*
-	 * This value defines the intended doorbell path between RoCE and
-	 * L2.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define DBC_ABSOLUTE_DB_32_PATH_MASK	UINT32_C(0x3000000)
-	#define DBC_ABSOLUTE_DB_32_PATH_SFT	24
-	/* This is a RoCE doorbell message. */
-		#define DBC_ABSOLUTE_DB_32_PATH_ROCE	(UINT32_C(0x0) << 24)
-	/* This is a L2 doorbell message. */
-		#define DBC_ABSOLUTE_DB_32_PATH_L2		(UINT32_C(0x1) << 24)
-		#define DBC_ABSOLUTE_DB_32_PATH_LAST	DBC_ABSOLUTE_DB_32_PATH_L2
+	uint64_t	resp_addr;
+	uint32_t	enables;
 	/*
-	 * This indicates it is valid doorbell update. It should be set for
-	 * each doorbell written to the chip and set when doorbell message is
-	 * written to the backup doorbell location. The bit should be cleared
-	 * in the backup doorbell location at time zero to indicate that the
-	 * backup doorbell has not yet been written.
+	 * This bit must be '1' for the udcc_mode field to be
+	 * configured.
 	 */
-	#define DBC_ABSOLUTE_DB_32_VALID		UINT32_C(0x4000000)
+	#define HWRM_UDCC_CFG_INPUT_ENABLES_UDCC_MODE	UINT32_C(0x1)
+	/* UDCC mode for this function. */
+	uint8_t	udcc_mode;
+	/* UDCC is not enabled. */
+	#define HWRM_UDCC_CFG_INPUT_UDCC_MODE_DISABLED UINT32_C(0x0)
+	/* UDCC is enabled. */
+	#define HWRM_UDCC_CFG_INPUT_UDCC_MODE_ENABLED  UINT32_C(0x1)
+	#define HWRM_UDCC_CFG_INPUT_UDCC_MODE_LAST	HWRM_UDCC_CFG_INPUT_UDCC_MODE_ENABLED
+	uint8_t	unused_1[3];
+} hwrm_udcc_cfg_input_t, *phwrm_udcc_cfg_input_t;
+
+/* hwrm_udcc_cfg_output (size:128b/16B) */
+
+typedef struct hwrm_udcc_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_1[7];
 	/*
-	 * When this bit is set to one, the chip will capture debug
-	 * information for the doorbell ring. This is intended to only be
-	 * used on SQ doorbell rings.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	#define DBC_ABSOLUTE_DB_32_DEBUG_TRACE	UINT32_C(0x8000000)
-	/* This value identifies the type of doorbell being written. */
-	#define DBC_ABSOLUTE_DB_32_TYPE_MASK	UINT32_C(0xf0000000)
-	#define DBC_ABSOLUTE_DB_32_TYPE_SFT	28
+	uint8_t	valid;
+} hwrm_udcc_cfg_output_t, *phwrm_udcc_cfg_output_t;
+
+/******************
+ * hwrm_udcc_qcfg *
+ ******************/
+
+
+/* hwrm_udcc_qcfg_input (size:128b/16B) */
+
+typedef struct hwrm_udcc_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * This is a SQ producer index update.   It indicates one or more
-	 * new entries have been written to the SQ for the QPID indicated
-	 * on the xID field. This type is valid for L2, RoCE and Engine
-	 * path.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-		#define DBC_ABSOLUTE_DB_32_TYPE_SQ		(UINT32_C(0x0) << 28)
+	uint16_t	cmpl_ring;
 	/*
-	 * This is a RQ producer index update.   It indicates one or more
-	 * new entries have been written to the RQ for the QPID indicated
-	 * on the xID field. This type is valid for RoCE path.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-		#define DBC_ABSOLUTE_DB_32_TYPE_RQ		(UINT32_C(0x1) << 28)
+	uint16_t	seq_id;
 	/*
-	 * This is a SRQ producer index update.   It indicates one or more
-	 * new entries have been written to the SRQ for the SID indicated
-	 * on the xID field. This type is valid for L2 and RoCE path.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-		#define DBC_ABSOLUTE_DB_32_TYPE_SRQ		(UINT32_C(0x2) << 28)
+	uint16_t	target_id;
 	/*
-	 * This doorbell command arms the SRQ async event.
-	 * The xID field must identify the SID that is begin armed.
-	 * The index field is will set the arm threshold such that
-	 * a notification will be generated if less than that number
-	 * or SRQ entries are posted. This type is valid for RoCE path.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-		#define DBC_ABSOLUTE_DB_32_TYPE_SRQ_ARM	(UINT32_C(0x3) << 28)
+	uint64_t	resp_addr;
+} hwrm_udcc_qcfg_input_t, *phwrm_udcc_qcfg_input_t;
+
+/* hwrm_udcc_qcfg_output (size:128b/16B) */
+
+typedef struct hwrm_udcc_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* UDCC mode for this function. */
+	uint8_t	udcc_mode;
+	uint8_t	unused_1[6];
 	/*
-	 * This is a CQ consumer index update.   It indicates one or more
-	 * entries have been processed off the CQ indicated on the xID
-	 * field.This type is valid for L2, RoCE and Engine path.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-		#define DBC_ABSOLUTE_DB_32_TYPE_CQ		(UINT32_C(0x4) << 28)
+	uint8_t	valid;
+} hwrm_udcc_qcfg_output_t, *phwrm_udcc_qcfg_output_t;
+
+/*************************
+ * hwrm_udcc_session_cfg *
+ *************************/
+
+
+/* hwrm_udcc_session_cfg_input (size:384b/48B) */
+
+typedef struct hwrm_udcc_session_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * this is a CQ consumer index update that also arms the CQ for
-	 * solicited events. This type is valid for RoCE path.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-		#define DBC_ABSOLUTE_DB_32_TYPE_CQ_ARMSE	(UINT32_C(0x5) << 28)
+	uint16_t	cmpl_ring;
 	/*
-	 * This is a CQ consumer index update that also arms the CQ
-	 * for any new CQE. This type is valid for L2, RoCE and Engine
-	 * path.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-		#define DBC_ABSOLUTE_DB_32_TYPE_CQ_ARMALL	(UINT32_C(0x6) << 28)
+	uint16_t	seq_id;
 	/*
-	 * This is a NQ consumer index update. It indicates one or more
-	 * entries have been processed off the NQ indicated on the xID
-	 * field. This type is valid for L2, RoCE and Engine path.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-		#define DBC_ABSOLUTE_DB_32_TYPE_NQ		(UINT32_C(0xa) << 28)
+	uint16_t	target_id;
 	/*
-	 * This is a NQ consumer index update that also arms the NQ for
-	 * any new NQE. This type is valid for L2, RoCE and Engine path.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-		#define DBC_ABSOLUTE_DB_32_TYPE_NQ_ARM	(UINT32_C(0xb) << 28)
+	uint64_t	resp_addr;
+	uint32_t	enables;
+	/* This bit must be '1' for the session_state to be configured. */
+	#define HWRM_UDCC_SESSION_CFG_INPUT_ENABLES_SESSION_STATE	UINT32_C(0x1)
+	/* This bit must be '1' for the dest_mac to be configured. */
+	#define HWRM_UDCC_SESSION_CFG_INPUT_ENABLES_DEST_MAC		UINT32_C(0x2)
+	/* This bit must be '1' for the src_mac to be configured. */
+	#define HWRM_UDCC_SESSION_CFG_INPUT_ENABLES_SRC_MAC		UINT32_C(0x4)
+	/* This bit must be '1' for the tx_stats_record to be configured. */
+	#define HWRM_UDCC_SESSION_CFG_INPUT_ENABLES_TX_STATS_RECORD	UINT32_C(0x8)
+	/* This bit must be '1' for the rx_stats_record to be configured. */
+	#define HWRM_UDCC_SESSION_CFG_INPUT_ENABLES_RX_STATS_RECORD	UINT32_C(0x10)
+	/* State to configure for the session. */
+	uint8_t	session_state;
+	/*
+	 * This bit is set if the session is to be enabled and have firmware
+	 * querying it for events. The bit is cleared if the session is to
+	 * be disabled in firmware.
+	 */
+	#define HWRM_UDCC_SESSION_CFG_INPUT_SESSION_STATE_ENABLED		UINT32_C(0x1)
+	/* UDCC flow is not created in driver. */
+	#define HWRM_UDCC_SESSION_CFG_INPUT_SESSION_STATE_FLOW_NOT_CREATED	UINT32_C(0x2)
+	/* UDCC flow is now deleted in driver. */
+	#define HWRM_UDCC_SESSION_CFG_INPUT_SESSION_STATE_FLOW_HAS_BEEN_DELETED	UINT32_C(0x4)
+	uint8_t	unused_1;
+	/* A handle for the session to be configured, if previously allocated. */
+	uint16_t	session_id;
+	/* destination mac address used for the session. */
+	uint8_t	dest_mac[6];
+	uint16_t	unused_2;
+	/* source mac address used for the session. */
+	uint8_t	src_mac[6];
+	uint16_t	unused_3;
 	/*
-	 * This is a NQ consumer index update that also arms the NQ for
-	 * any new NQE. It is used for the legacy INT mask. This type
-	 * is valid for L2, RoCE and Engine path.
+	 * address for the tx flow statistics record to be sampled by the
+	 * UDCC firmware. Session must be disabled to take effect.
 	 */
-		#define DBC_ABSOLUTE_DB_32_TYPE_NQ_MASK	(UINT32_C(0xe) << 28)
+	uint32_t	tx_stats_record;
 	/*
-	 * This doorbell command is used during doorbell moderation
-	 * to consume system BW and help prevent doorbell FIFO
-	 * overflow.
-	 *
-	 * All other fields should be zero for NULL doorbell.
-	 * For doorbell recovery, NULL doorbell type in the Application
-	 * table indicates that it is the last QP entry for the function.
-	 * This type is valid for L2, RoCE and Engine path.
+	 * address for the rx flow statistics record to be sampled by the
+	 * UDCC firmware. Session must be disabled to take effect.
 	 */
-		#define DBC_ABSOLUTE_DB_32_TYPE_NULL	(UINT32_C(0xf) << 28)
-		#define DBC_ABSOLUTE_DB_32_TYPE_LAST	DBC_ABSOLUTE_DB_32_TYPE_NULL
-} dbc_absolute_db_32_t, *pdbc_absolute_db_32_t;
+	uint32_t	rx_stats_record;
+} hwrm_udcc_session_cfg_input_t, *phwrm_udcc_session_cfg_input_t;
 
-/*
- * This is the "Relative" 32b Doorbell format. The host writes this
- * message format directly to byte offset 8 of the appropriate doorbell
- * page.
- *
- * Doorbell recovery can not be supported for relative doorbells. So
- * relative doorbells are only safe to use when SOC is supporting the
- * context backing store in local DDR. If that is the case, it is safe
- * to turn off doorbell drops and use this type of doorbell.
- */
-/* dbc_relative_db_32 (size:32b/4B) */
+/* hwrm_udcc_session_cfg_output (size:128b/16B) */
 
-typedef struct dbc_relative_db_32 {
-	uint32_t	xid;
-	/*
-	 * This value identifies the resource that the doorbell is intended
-	 * to notify.
-	 *
-	 * For SQ, this is the QPID value.
-	 */
-	#define DBC_RELATIVE_DB_32_XID_MASK	UINT32_C(0xfffff)
-	#define DBC_RELATIVE_DB_32_XID_SFT	0
+typedef struct hwrm_udcc_session_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_1[7];
 	/*
-	 * This value defines the intended doorbell path between RoCE and
-	 * L2.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	#define DBC_RELATIVE_DB_32_PATH_MASK	UINT32_C(0xc00000)
-	#define DBC_RELATIVE_DB_32_PATH_SFT	22
-	/* This is a RoCE doorbell message. */
-		#define DBC_RELATIVE_DB_32_PATH_ROCE	(UINT32_C(0x0) << 22)
-	/* This is a L2 doorbell message. */
-		#define DBC_RELATIVE_DB_32_PATH_L2	(UINT32_C(0x1) << 22)
-		#define DBC_RELATIVE_DB_32_PATH_LAST	DBC_RELATIVE_DB_32_PATH_L2
+	uint8_t	valid;
+} hwrm_udcc_session_cfg_output_t, *phwrm_udcc_session_cfg_output_t;
+
+/**************************
+ * hwrm_udcc_session_qcfg *
+ **************************/
+
+
+/* hwrm_udcc_session_qcfg_input (size:192b/24B) */
+
+typedef struct hwrm_udcc_session_qcfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * This value is the value to add to the appropriate index value.
-	 *
-	 * The increment unit is 16B for L2 path. For RoCE there is a
-	 * legacy mode with 128B unit size and a variable size mode with
-	 * 32B unit size. For Engine mode, the unit size is always 128B.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define DBC_RELATIVE_DB_32_INCR_MASK	UINT32_C(0x1f000000)
-	#define DBC_RELATIVE_DB_32_INCR_SFT	24
-	/* This value identifies the type of doorbell being written. */
-	#define DBC_RELATIVE_DB_32_TYPE_MASK	UINT32_C(0xe0000000)
-	#define DBC_RELATIVE_DB_32_TYPE_SFT	29
+	uint16_t	cmpl_ring;
 	/*
-	 * This is a SQ producer index update.   It indicates one or more
-	 * new entries have been written to the SQ for the QPID indicated
-	 * on the xID field. This type is valid for L2, RoCE and Engine
-	 * path.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-		#define DBC_RELATIVE_DB_32_TYPE_SQ	(UINT32_C(0x0) << 29)
+	uint16_t	seq_id;
 	/*
-	 * This is a SRQ producer index update.   It indicates one or more
-	 * new entries have been written to the SRQ for the SID indicated
-	 * on the xID field. This type is valid for L2 and RoCE path.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-		#define DBC_RELATIVE_DB_32_TYPE_SRQ	(UINT32_C(0x1) << 29)
+	uint16_t	target_id;
 	/*
-	 * This is a CQ consumer index update.   It indicates one or more
-	 * entries have been processed off the CQ indicated on the xID
-	 * field.This type is valid for L2, RoCE and Engine path.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-		#define DBC_RELATIVE_DB_32_TYPE_CQ	(UINT32_C(0x2) << 29)
+	uint64_t	resp_addr;
+	/* A handle for the session to be queried, if previously allocated. */
+	uint16_t	session_id;
+	uint8_t	unused_0[6];
+} hwrm_udcc_session_qcfg_input_t, *phwrm_udcc_session_qcfg_input_t;
+
+/* hwrm_udcc_session_qcfg_output (size:512b/64B) */
+
+typedef struct hwrm_udcc_session_qcfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* session_state specifying configuration of the session. */
+	uint8_t	session_state;
+	/*
+	 * This bit is set if the session is enabled and firmware is
+	 * querying it for events. The bit is cleared if no querying
+	 * should occur for this session.
+	 */
+	#define HWRM_UDCC_SESSION_QCFG_OUTPUT_SESSION_STATE_ENABLED		UINT32_C(0x1)
+	/* UDCC flow is not created in driver. */
+	#define HWRM_UDCC_SESSION_QCFG_OUTPUT_SESSION_STATE_FLOW_NOT_CREATED	UINT32_C(0x2)
+	/* UDCC flow is now deleted in driver. */
+	#define HWRM_UDCC_SESSION_QCFG_OUTPUT_SESSION_STATE_FLOW_HAS_BEEN_DELETED	UINT32_C(0x4)
+	uint8_t	unused_0;
+	/* destination mac address used for the session. */
+	uint8_t	dest_mac[6];
 	/*
-	 * This is a CQ consumer index update that also arms the CQ
-	 * for any new CQE. This type is valid for L2, RoCE and Engine
-	 * path.
+	 * a 4 byte or 16 byte IP address, depending on whether the ip_type
+	 * specifies IPv4 or IPv6. For IPv4 addresses, the first 4 bytes of the
+	 * 16 byte field are used; the remaining 12 bytes are not used.
 	 */
-		#define DBC_RELATIVE_DB_32_TYPE_CQ_ARMALL  (UINT32_C(0x3) << 29)
+	uint32_t	dest_ip[4];
+	uint8_t	unused_1[2];
+	/* source mac address used for the session. */
+	uint8_t	src_mac[6];
+	/* source QP number used for the session. */
+	uint32_t	src_qp_num;
+	/* destination QP number used for the session. */
+	uint32_t	dest_qp_num;
 	/*
-	 * This is a NQ consumer index update. It indicates one or more
-	 * entries have been processed off the NQ indicated on the xID
-	 * field. This type is valid for L2, RoCE and Engine path.
+	 * address for the tx flow statistics record to be sampled by the
+	 * UDCC firmware.
 	 */
-		#define DBC_RELATIVE_DB_32_TYPE_NQ	(UINT32_C(0x4) << 29)
+	uint32_t	tx_stats_record;
 	/*
-	 * This is a NQ consumer index update that also arms the NQ for
-	 * any new NQE. This type is valid for L2, RoCE and Engine path.
+	 * address for the rx flow statistics record to be sampled by the
+	 * UDCC firmware.
 	 */
-		#define DBC_RELATIVE_DB_32_TYPE_NQ_ARM	(UINT32_C(0x5) << 29)
+	uint32_t	rx_stats_record;
+	uint8_t	unused_2[7];
 	/*
-	 * This is a NQ consumer index update that also arms the NQ for
-	 * any new NQE. It is used for the legacy INT mask. This type
-	 * is valid for L2, RoCE and Engine path.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-		#define DBC_RELATIVE_DB_32_TYPE_NQ_MASK	(UINT32_C(0x6) << 29)
-		#define DBC_RELATIVE_DB_32_TYPE_LAST	DBC_RELATIVE_DB_32_TYPE_NQ_MASK
-} dbc_relative_db_32_t, *pdbc_relative_db_32_t;
+	uint8_t	valid;
+} hwrm_udcc_session_qcfg_output_t, *phwrm_udcc_session_qcfg_output_t;
 
-/*
- * The kernel memory structure is per-type (SQ, RQ, SRQ/SRQ_ARM and
- * CQ/CQ_ARMSE/CQ_ARMALL). Each kernel driver will support a table for
- * the doorbell recovery.
- */
-/* dbc_drk (size:128b/16B) */
+/***************************
+ * hwrm_udcc_session_query *
+ ***************************/
 
-typedef struct dbc_drk {
-	uint32_t	db_format_linked_last_valid;
+
+/* hwrm_udcc_session_query_input (size:192b/24B) */
+
+typedef struct hwrm_udcc_session_query_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * This indicates it is valid entry. It should be set for each
-	 * doorbell written to the chip. The bit should be cleared at time
-	 * zero to indicate that it has not yet been written. The bit i
-	 * should be cleared when the function for the table is disabled.
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define DBC_DRK_VALID	UINT32_C(0x1)
-	/* This indicates it is last entry for the table. */
-	#define DBC_DRK_LAST	UINT32_C(0x2)
-	/* This indicates it is entry for the next 4KB kernel memory pointer. */
-	#define DBC_DRK_LINKED	UINT32_C(0x4)
+	uint16_t	cmpl_ring;
 	/*
-	 * This field indicates if the doorbells in the table are 32b
-	 * absolute or 64b format.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define DBC_DRK_DB_FORMAT	UINT32_C(0x8)
-	/* The doorbells are 64b format. */
-		#define DBC_DRK_DB_FORMAT_B64   (UINT32_C(0x0) << 3)
+	uint16_t	seq_id;
 	/*
-	 * The doorbells are in the absolute 32b format. The doorbell
-	 * is in the right-most half of the 64b space provided in the
-	 * application table entry.
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-		#define DBC_DRK_DB_FORMAT_B32A  (UINT32_C(0x1) << 3)
-		#define DBC_DRK_DB_FORMAT_LAST DBC_DRK_DB_FORMAT_B32A
-	uint32_t	pi;
+	uint16_t	target_id;
 	/*
-	 * Page Index portion of DPI{VF_VALID,VFID,PI}. The pi needs to match
-	 * the value from the context DPI for the operation to be valid or the
-	 * pi must be zero, indicating a write from the privileged driver.
-	 *
-	 * pi in the kernel memory table is there for DBR to generate the DPI
-	 * message to the client.
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define DBC_DRK_PI_MASK UINT32_C(0xffff)
-	#define DBC_DRK_PI_SFT 0
+	uint64_t	resp_addr;
+	/* A handle for the session to be queried, if previously allocated. */
+	uint16_t	session_id;
+	uint8_t	unused_0[6];
+} hwrm_udcc_session_query_input_t, *phwrm_udcc_session_query_input_t;
+
+/* hwrm_udcc_session_query_output (size:576b/72B) */
+
+typedef struct hwrm_udcc_session_query_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	/* field for the minimum RTT value (in ns) for the session. */
+	uint32_t	min_rtt_ns;
+	/* field for the maximum RTT value (in ns) for the session. */
+	uint32_t	max_rtt_ns;
+	/*
+	 * field for the current configured rate (in Mbps) for the
+	 * session.
+	 */
+	uint32_t	cur_rate_mbps;
+	/*
+	 * count for the number of events sent from FW to the UDCC
+	 * program.
+	 */
+	uint32_t	tx_event_count;
+	/*
+	 * count for the number of CNP events sent from FW to the UDCC
+	 * program.
+	 */
+	uint32_t	cnp_rx_event_count;
+	/*
+	 * count for the number of RTT request events received by the FW from
+	 * the UDCC program.
+	 */
+	uint32_t	rtt_req_count;
+	/*
+	 * count for the number of RTT response events sent by the FW to the
+	 * UDCC program.
+	 */
+	uint32_t	rtt_resp_count;
+	/* count for the number of bytes transmitted for the session. */
+	uint32_t	tx_bytes_count;
+	/* count for the number of packets transmitted for the session. */
+	uint32_t	tx_packets_count;
+	/* count of initiator probes transmitted for the session. */
+	uint32_t	init_probes_sent;
+	/* count of terminator probes received for the session. */
+	uint32_t	term_probes_recv;
+	/* count of CNP packets received for the session. */
+	uint32_t	cnp_packets_recv;
+	/* count of retransmission timeout events received for the session. */
+	uint32_t	rto_event_recv;
+	/* count of sequence error NAK events received for the session. */
+	uint32_t	seq_err_nak_recv;
+	/* the current number of qps associated with the session. */
+	uint32_t	qp_count;
+	uint8_t	unused_1[3];
 	/*
-	 * It is the application memory page(4KB) pointer when linked = 0.
-	 * It is the next kernel memory page(4KB) pointer when linked = 1.
-	 * The pointer doesn't have to be aligned to the page(4KB) but it
-	 * should be aligned to 128B boundary. This means that the bottom
-	 * 7b of the pointer must be zero.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	uint64_t	memptr;
-} dbc_drk_t, *pdbc_drk_t;
+	uint8_t	valid;
+} hwrm_udcc_session_query_output_t, *phwrm_udcc_session_query_output_t;
 
-/*
- * This is a firmware status register that indicates the software status
- * exposed by the firmware to the host.
- *
- * > This register is not present in previous versions of this chip.
- */
-/* fw_status_reg (size:32b/4B) */
+/**********************
+ * hwrm_udcc_comp_cfg *
+ **********************/
 
-typedef struct fw_status_reg {
-	uint32_t	fw_status;
+
+/* hwrm_udcc_comp_cfg_input (size:576b/72B) */
+
+typedef struct hwrm_udcc_comp_cfg_input {
+	/* The HWRM command request type. */
+	uint16_t	req_type;
 	/*
-	 * These bits indicate the status as being reported by the firmware.
-	 *
-	 * The value should be interpreted as follows:
-	 * A value below 0x8000 is an indication that the firmware is still in the
-	 * process of starting up and is not ready. The host driver should
-	 * continue waiting with a timeout for firmware status to be ready.
-	 * >	0x0000 to 0x00FF : SBL state information
-	 * >	0x0200 to 0x02FF : SBI state information
-	 * >	0x0400 to 0x04FF : SRT state information
-	 * >	0x0600 to 0x06FF : CRT/CHIMP state information
-	 * >	0x0800 to 0x0FFF : Reserved for future fw functionality
-	 *
-	 * A value of 0x8000 indicates firmware is ready and healthy. The host
-	 * driver can start initiating HWRM commands to the firmware.
-	 *
-	 * A value over 0x8000 is an indication that the firmware has detected
-	 * a fatal error, this error could be in one of the hardware block or
-	 * in a software module. The lower 8 bits indicate a block/module
-	 * specific error and the upper 8 bits identify the hardware block
-	 * or firmware module that was the source of the error.
-	 * >	0x81XX - 0xBFXX  : 63 ASIC blocks
-	 * >	0xC0XX to 0xFEXX : 63 Firmware modules
-	 * >	0xFFXX	: Reserved for future
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
 	 */
-	#define FW_STATUS_REG_CODE_MASK		UINT32_C(0xffff)
-	#define FW_STATUS_REG_CODE_SFT		0
-	/* Indicates firmware is ready. */
-		#define FW_STATUS_REG_CODE_READY		UINT32_C(0x8000)
-		#define FW_STATUS_REG_CODE_LAST		FW_STATUS_REG_CODE_READY
+	uint16_t	cmpl_ring;
 	/*
-	 * Image Degraded bit. If set indicates that one of the firmware
-	 * image is degraded.
-	 *
-	 * The firmware binary located on NVM has redundant copies to protect
-	 * against corruption. When one of the primary or secondary copy is
-	 * detected as corrupted, this bit will be set by the firmware either
-	 * as part of power on from the context of hwrm_fw_health_check.
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
 	 */
-	#define FW_STATUS_REG_IMAGE_DEGRADED	UINT32_C(0x10000)
+	uint16_t	seq_id;
 	/*
-	 * Recoverable bit. If set indicates that the fatal error is
-	 * recoverable with a full reset.
-	 *
-	 * This bit should be used by host software and deployment models
-	 * that support error recovery by resetting the controller. A recovery
-	 * should be attempted from a fatal error condition only if this bit
-	 * is set. This bit is meaningful only when the code field is greater
-	 * than 0x8000 (32768 decimal).
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors
+	 * * 0xFFFD - Reserved for user-space HWRM interface
+	 * * 0xFFFF - HWRM
 	 */
-	#define FW_STATUS_REG_RECOVERABLE		UINT32_C(0x20000)
+	uint16_t	target_id;
 	/*
-	 * Crash dump is in process. If set indicates that the firmware is
-	 * currently recording a crash dump.
-	 *
-	 * This bit provides a hint to the host driver if the firmware is
-	 * currently recording a crash dump. Host driers should avoid resetting
-	 * the controller when a crash dump is in progress if possible. This
-	 * bit is meaningful only when the code field is greater than
-	 * 0x8000 (32768 decimal).
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
 	 */
-	#define FW_STATUS_REG_CRASHDUMP_ONGOING	UINT32_C(0x40000)
+	uint64_t	resp_addr;
 	/*
-	 * Crash dump is available. If set indicates that a firmware crash dump
-	 * was recorded before and is now available.
-	 *
-	 * This bit provides indication to the host driver that the firmware has
-	 * completed a crash dump. This bit is meaningful only when the code
-	 * field is greater than 0x8000 (32768 decimal).
+	 * This field holds the configuration arguments, which can be used
+	 * to specify the context of the configuration data, e.g. type,
+	 * session ID, etc. It is possible not all arg_buf are utilized.
+	 * The format and meaning of the arguments are internal to
+	 * the UDCC program.
 	 */
-	#define FW_STATUS_REG_CRASHDUMP_COMPLETE	UINT32_C(0x80000)
+	uint8_t	arg_buf[40];
 	/*
-	 * This bit is used to indicate device state when it enters the shutdown mode
-	 * and stopped the communication with the host. The host should initiate the
-	 * reload of firmware image or initiate the reset to bring the device to the
-	 * normal operational state and re-establish the communication.
-	 *
-	 * This bit is meaningful only when the code field is greater than 0x8000
-	 * (32768 decimal).
+	 * This field specifies the number of bytes in arg_buf that are
+	 * configuration arguments. It can be zero if there are no arguments.
 	 */
-	#define FW_STATUS_REG_SHUTDOWN		UINT32_C(0x100000)
+	uint32_t	arg_len;
 	/*
-	 * This bit will be set to 1 by the FW when FW crashed without master
-	 * function.
-	 *
-	 * This bit is controller specific, not all products will support this bit.
-	 * This bit is valid only when the code field is greater than 0x8000
-	 * (32768 decimal).
+	 * This field specifies the length of the configuration data
+	 * stored in the host memory. The host driver shall guarantee
+	 * this number is not greater than the maximum configuration
+	 * transfer size that is specified by the max_comp_cfg_xfer
+	 * field of hwrm_udcc_qcaps_output.
 	 */
-	#define FW_STATUS_REG_CRASHED_NO_MASTER	UINT32_C(0x200000)
+	uint32_t	cfg_len;
 	/*
-	 * The firmware sets this bit to 1 when the firmware has taken an exception
-	 * and expects to initiate error recovery.
-	 *
-	 * This bit is valid only when the code field is greater than 0x8000
-	 * (32768 decimal).
+	 * This field specifies the address of the host memory where
+	 * the configuration data is stored. The format and meaning of
+	 * the configuration data are internal to the UDCC program.
 	 */
-	#define FW_STATUS_REG_RECOVERING		UINT32_C(0x400000)
-} fw_status_reg_t, *pfw_status_reg_t;
+	uint64_t	cfg_host_addr;
+} hwrm_udcc_comp_cfg_input_t, *phwrm_udcc_comp_cfg_input_t;
 
-/*
- * This structure is fixed at the beginning of the ChiMP SRAM (GRC
- * offset: 0x31001F0). Host software is expected to read from this
- * location for a defined signature. If it exists, the software can
- * assume the presence of this structure and the validity of the
- * FW_STATUS location in the next field.
- */
-/* hcomm_status (size:64b/8B) */
+/* hwrm_udcc_comp_cfg_output (size:128b/16B) */
 
-typedef struct hcomm_status {
-	uint32_t	sig_ver;
-	/*
-	 * This field defines the version of the structure. The latest
-	 * version value is 1.
-	 */
-	#define HCOMM_STATUS_VER_MASK	UINT32_C(0xff)
-	#define HCOMM_STATUS_VER_SFT	0
-		#define HCOMM_STATUS_VER_LATEST	UINT32_C(0x1)
-		#define HCOMM_STATUS_VER_LAST	HCOMM_STATUS_VER_LATEST
-	/*
-	 * This field is to store the signature value to indicate the
-	 * presence of the structure.
-	 */
-	#define HCOMM_STATUS_SIGNATURE_MASK UINT32_C(0xffffff00)
-	#define HCOMM_STATUS_SIGNATURE_SFT 8
-		#define HCOMM_STATUS_SIGNATURE_VAL   (UINT32_C(0x484353) << 8)
-		#define HCOMM_STATUS_SIGNATURE_LAST HCOMM_STATUS_SIGNATURE_VAL
-	uint32_t	fw_status_loc;
-	#define HCOMM_STATUS_TRUE_ADDR_SPACE_MASK	UINT32_C(0x3)
-	#define HCOMM_STATUS_TRUE_ADDR_SPACE_SFT	0
-	/* PCIE configuration space */
-		#define HCOMM_STATUS_FW_STATUS_LOC_ADDR_SPACE_PCIE_CFG  UINT32_C(0x0)
-	/* GRC space */
-		#define HCOMM_STATUS_FW_STATUS_LOC_ADDR_SPACE_GRC	UINT32_C(0x1)
-	/* BAR0 space */
-		#define HCOMM_STATUS_FW_STATUS_LOC_ADDR_SPACE_BAR0	UINT32_C(0x2)
-	/* BAR1 space */
-		#define HCOMM_STATUS_FW_STATUS_LOC_ADDR_SPACE_BAR1	UINT32_C(0x3)
-		#define HCOMM_STATUS_FW_STATUS_LOC_ADDR_SPACE_LAST	HCOMM_STATUS_FW_STATUS_LOC_ADDR_SPACE_BAR1
+typedef struct hwrm_udcc_comp_cfg_output {
+	/* The specific error status for the command. */
+	uint16_t	error_code;
+	/* The HWRM command request type. */
+	uint16_t	req_type;
+	/* The sequence ID from the original command. */
+	uint16_t	seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t	resp_len;
+	uint8_t	unused_0[7];
 	/*
-	 * This offset where the fw_status register is located. The value
-	 * is generally 4-byte aligned.
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
 	 */
-	#define HCOMM_STATUS_TRUE_OFFSET_MASK	UINT32_C(0xfffffffc)
-	#define HCOMM_STATUS_TRUE_OFFSET_SFT	2
-} hcomm_status_t, *phcomm_status_t;
-
-/* This is the GRC offset where the hcomm_status struct resides. */
-#define HCOMM_STATUS_STRUCT_LOC 0x31001F0UL
+	uint8_t	valid;
+} hwrm_udcc_comp_cfg_output_t, *phwrm_udcc_comp_cfg_output_t;
 
-/****************
- * hwrm_oem_cmd *
- ****************/
+/***********************
+ * hwrm_udcc_comp_qcfg *
+ ***********************/
 
 
-/* hwrm_oem_cmd_input (size:1024b/128B) */
+/* hwrm_udcc_comp_qcfg_input (size:576b/72B) */
 
-typedef struct hwrm_oem_cmd_input {
+typedef struct hwrm_udcc_comp_qcfg_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -64107,15 +91362,37 @@ typedef struct hwrm_oem_cmd_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	IANA;
-	uint32_t	unused_0;
-	/* This field contains the vendor specific command data. */
-	uint32_t	oem_data[26];
-} hwrm_oem_cmd_input_t, *phwrm_oem_cmd_input_t;
+	/*
+	 * This field holds the query arguments, which can be used to
+	 * specify the context of the query, e.g. type, session ID, etc.
+	 * It is possible not all arg_buf are utilized.
+	 * The format and meaning of the arguments are internal to
+	 * the UDCC program.
+	 */
+	uint8_t	arg_buf[40];
+	/*
+	 * This field specifies the number of bytes in arg_buf that are
+	 * query arguments. It can be zero if there are no arguments.
+	 */
+	uint32_t	arg_len;
+	/*
+	 * This field specifies the size of the buffer in the host memory
+	 * for receiving the configuration data. The host driver shall
+	 * guarantee the size of the buffer is not smaller than
+	 * the maximum configuration transfer size that is specified by
+	 * the max_comp_cfg_xfer field of hwrm_udcc_qcaps_output.
+	 */
+	uint32_t	cfg_host_buf_size;
+	/*
+	 * This field specifies the address of the host memory where
+	 * the queried configuration to be stored.
+	 */
+	uint64_t	cfg_host_addr;
+} hwrm_udcc_comp_qcfg_input_t, *phwrm_udcc_comp_qcfg_input_t;
 
-/* hwrm_oem_cmd_output (size:768b/96B) */
+/* hwrm_udcc_comp_qcfg_output (size:128b/16B) */
 
-typedef struct hwrm_oem_cmd_output {
+typedef struct hwrm_udcc_comp_qcfg_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -64124,29 +91401,32 @@ typedef struct hwrm_oem_cmd_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint32_t	IANA;
-	uint32_t	unused_0;
-	/* This field contains the vendor specific response data. */
-	uint32_t	oem_data[18];
-	uint8_t	unused_1[7];
+	/*
+	 * This field specifies the length of configuration data transferred
+	 * into the host memory. The amount of data transferred is up to
+	 * the maximum configuration transfer size that is specified by
+	 * the max_comp_cfg_xfer field of hwrm_udcc_qcaps_output.
+	 */
+	uint32_t	cfg_len;
+	uint8_t	unused_0[3];
 	/*
 	 * This field is used in Output records to indicate that the output
-	 * is completely written to RAM.  This field should be read as '1'
-	 * to indicate that the output has been completely written.
-	 * When writing a command completion or response to an internal processor,
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
 	 * the order of writes has to be such that this field is written last.
 	 */
 	uint8_t	valid;
-} hwrm_oem_cmd_output_t, *phwrm_oem_cmd_output_t;
+} hwrm_udcc_comp_qcfg_output_t, *phwrm_udcc_comp_qcfg_output_t;
 
-/***********
- * hwrm_sv *
- ***********/
+/************************
+ * hwrm_udcc_comp_query *
+ ************************/
 
 
-/* hwrm_sv_input (size:1152b/144B) */
+/* hwrm_udcc_comp_query_input (size:576b/72B) */
 
-typedef struct hwrm_sv_input {
+typedef struct hwrm_udcc_comp_query_input {
 	/* The HWRM command request type. */
 	uint16_t	req_type;
 	/*
@@ -64175,12 +91455,37 @@ typedef struct hwrm_sv_input {
 	 * point to a physically contiguous block of memory.
 	 */
 	uint64_t	resp_addr;
-	uint32_t	opaque[32];
-} hwrm_sv_input_t, *phwrm_sv_input_t;
+	/*
+	 * This field holds the query arguments, which can be used to
+	 * specify the context of the query, e.g. type, session ID, etc.
+	 * It is possible not all arg_buf are utilized.
+	 * The format and meaning of the arguments are internal to
+	 * the UDCC program.
+	 */
+	uint8_t	arg_buf[40];
+	/*
+	 * This field specifies the number of bytes in arg_buf that are
+	 * query arguments. It can be zero if there are no arguments.
+	 */
+	uint32_t	arg_len;
+	/*
+	 * This field specifies the size of the buffer in the host memory
+	 * for receiving the status or statistics data. The host driver
+	 * shall guarantee the size of the buffer is not smaller than
+	 * the maximum data transfer size that is specified by
+	 * the max_comp_data_xfer field of hwrm_udcc_qcaps_output.
+	 */
+	uint32_t	data_host_buf_size;
+	/*
+	 * This field specifies the address of the host memory where
+	 * the queried data to be stored.
+	 */
+	uint64_t	data_host_addr;
+} hwrm_udcc_comp_query_input_t, *phwrm_udcc_comp_query_input_t;
 
-/* hwrm_sv_output (size:1088b/136B) */
+/* hwrm_udcc_comp_query_output (size:128b/16B) */
 
-typedef struct hwrm_sv_output {
+typedef struct hwrm_udcc_comp_query_output {
 	/* The specific error status for the command. */
 	uint16_t	error_code;
 	/* The HWRM command request type. */
@@ -64189,7 +91494,22 @@ typedef struct hwrm_sv_output {
 	uint16_t	seq_id;
 	/* The length of the response data in number of bytes. */
 	uint16_t	resp_len;
-	uint32_t	opaque[32];
-} hwrm_sv_output_t, *phwrm_sv_output_t;
+	/*
+	 * This field specifies the length of status or statistics data
+	 * transferred into the host memory. The amount of data transferred
+	 * is up to the maximum data transfer size that is specified by
+	 * the max_comp_data_xfer field of hwrm_udcc_qcaps_output.
+	 */
+	uint32_t	data_len;
+	uint8_t	unused_0[3];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM. This field should be read as '1'
+	 * to indicate that the output has been completely written. When
+	 * writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t	valid;
+} hwrm_udcc_comp_query_output_t, *phwrm_udcc_comp_query_output_t;
 
-#endif /* _HSI_STRUCT_DEF_EXTERNAL_H_ */
+#endif /* _HSI_STRUCT_DEF_H_ */
diff --git a/sys/dev/bnxt/if_bnxt.c b/sys/dev/bnxt/bnxt_en/if_bnxt.c
similarity index 65%
rename from sys/dev/bnxt/if_bnxt.c
rename to sys/dev/bnxt/bnxt_en/if_bnxt.c
index 70d699d4b419..8ca929828709 100644
--- a/sys/dev/bnxt/if_bnxt.c
+++ b/sys/dev/bnxt/bnxt_en/if_bnxt.c
@@ -41,7 +41,6 @@
 #include <machine/resource.h>
 
 #include <dev/pci/pcireg.h>
-#include <dev/pci/pcivar.h>
 
 #include <net/if.h>
 #include <net/if_dl.h>
@@ -50,6 +49,14 @@
 #include <net/ethernet.h>
 #include <net/iflib.h>
 
+#include <linux/pci.h>
+#include <linux/kmod.h>
+#include <linux/module.h>
+#include <linux/delay.h>
+#include <linux/idr.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/rcupdate.h>
 #include "opt_inet.h"
 #include "opt_inet6.h"
 #include "opt_rss.h"
@@ -62,6 +69,8 @@
 #include "bnxt_sysctl.h"
 #include "hsi_struct_def.h"
 #include "bnxt_mgmt.h"
+#include "bnxt_ulp.h"
+#include "bnxt_auxbus_compat.h"
 
 /*
  * PCI Device ID Table
@@ -161,6 +170,8 @@ static const pci_vendor_info_t bnxt_vendor_info_array[] =
 SLIST_HEAD(softc_list, bnxt_softc_list) pf_list;
 int bnxt_num_pfs = 0;
 
+void
+process_nq(struct bnxt_softc *softc, uint16_t nqid);
 static void *bnxt_register(device_t dev);
 
 /* Soft queue setup and teardown */
@@ -220,12 +231,18 @@ static void bnxt_mark_cpr_invalid(struct bnxt_cp_ring *cpr);
 static void bnxt_def_cp_task(void *context);
 static void bnxt_handle_async_event(struct bnxt_softc *softc,
     struct cmpl_base *cmpl);
-static uint8_t get_phy_type(struct bnxt_softc *softc);
 static uint64_t bnxt_get_baudrate(struct bnxt_link_info *link);
 static void bnxt_get_wol_settings(struct bnxt_softc *softc);
 static int bnxt_wol_config(if_ctx_t ctx);
 static bool bnxt_if_needs_restart(if_ctx_t, enum iflib_restart_event);
-
+static int bnxt_i2c_req(if_ctx_t ctx, struct ifi2creq *i2c);
+static void bnxt_get_port_module_status(struct bnxt_softc *softc);
+static void bnxt_rdma_aux_device_init(struct bnxt_softc *softc);
+static void bnxt_rdma_aux_device_uninit(struct bnxt_softc *softc);
+static void bnxt_queue_fw_reset_work(struct bnxt_softc *bp, unsigned long delay);
+void bnxt_queue_sp_work(struct bnxt_softc *bp);
+
+void bnxt_fw_reset(struct bnxt_softc *bp);
 /*
  * Device Interface Declaration
  */
@@ -248,12 +265,38 @@ static driver_t bnxt_driver = {
 
 DRIVER_MODULE(bnxt, pci, bnxt_driver, 0, 0);
 
-MODULE_DEPEND(bnxt, pci, 1, 1, 1);
-MODULE_DEPEND(bnxt, ether, 1, 1, 1);
-MODULE_DEPEND(bnxt, iflib, 1, 1, 1);
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_DEPEND(if_bnxt, pci, 1, 1, 1);
+MODULE_DEPEND(if_bnxt, ether, 1, 1, 1);
+MODULE_DEPEND(if_bnxt, iflib, 1, 1, 1);
+MODULE_DEPEND(if_bnxt, linuxkpi, 1, 1, 1);
+MODULE_VERSION(if_bnxt, 1);
 
 IFLIB_PNP_INFO(pci, bnxt, bnxt_vendor_info_array);
 
+void writel_fbsd(struct bnxt_softc *bp, u32, u8, u32);
+u32 readl_fbsd(struct bnxt_softc *bp, u32, u8);
+
+u32 readl_fbsd(struct bnxt_softc *bp, u32 reg_off, u8 bar_idx)
+{
+
+	if (!bar_idx)
+		return bus_space_read_4(bp->doorbell_bar.tag, bp->doorbell_bar.handle, reg_off);
+	else
+		return bus_space_read_4(bp->hwrm_bar.tag, bp->hwrm_bar.handle, reg_off);
+}
+
+void writel_fbsd(struct bnxt_softc *bp, u32 reg_off, u8 bar_idx, u32 val)
+{
+
+	if (!bar_idx)
+		bus_space_write_4(bp->doorbell_bar.tag, bp->doorbell_bar.handle, reg_off, htole32(val));
+	else
+		bus_space_write_4(bp->hwrm_bar.tag, bp->hwrm_bar.handle, reg_off, htole32(val));
+}
+
+static DEFINE_IDA(bnxt_aux_dev_ids);
+
 static device_method_t bnxt_iflib_methods[] = {
 	DEVMETHOD(ifdi_tx_queues_alloc, bnxt_tx_queues_alloc),
 	DEVMETHOD(ifdi_rx_queues_alloc, bnxt_rx_queues_alloc),
@@ -288,6 +331,7 @@ static device_method_t bnxt_iflib_methods[] = {
 	DEVMETHOD(ifdi_suspend, bnxt_suspend),
 	DEVMETHOD(ifdi_shutdown, bnxt_shutdown),
 	DEVMETHOD(ifdi_resume, bnxt_resume),
+	DEVMETHOD(ifdi_i2c_req, bnxt_i2c_req),
 
 	DEVMETHOD(ifdi_needs_restart, bnxt_if_needs_restart),
 
@@ -302,7 +346,7 @@ static driver_t bnxt_iflib_driver = {
  * iflib shared context
  */
 
-#define BNXT_DRIVER_VERSION	"2.20.0.1"
+#define BNXT_DRIVER_VERSION	"230.0.133.0"
 const char bnxt_driver_version[] = BNXT_DRIVER_VERSION;
 extern struct if_txrx bnxt_txrx;
 static struct if_shared_ctx bnxt_sctx_init = {
@@ -330,14 +374,20 @@ static struct if_shared_ctx bnxt_sctx_init = {
 	.isc_ntxd_min = {16, 16, 16},
 	.isc_ntxd_default = {PAGE_SIZE / sizeof(struct cmpl_base) * 2,
 	    PAGE_SIZE / sizeof(struct tx_bd_short),
-	    PAGE_SIZE / sizeof(struct cmpl_base) * 2},
+	    /* NQ depth 4096 */
+	    PAGE_SIZE / sizeof(struct cmpl_base) * 16},
 	.isc_ntxd_max = {BNXT_MAX_TXD, BNXT_MAX_TXD, BNXT_MAX_TXD},
 
-	.isc_admin_intrcnt = 1,
+	.isc_admin_intrcnt = BNXT_ROCE_IRQ_COUNT,
 	.isc_vendor_info = bnxt_vendor_info_array,
 	.isc_driver_version = bnxt_driver_version,
 };
 
+#define PCI_SUBSYSTEM_ID	0x2e
+static struct workqueue_struct *bnxt_pf_wq;
+
+extern void bnxt_destroy_irq(struct bnxt_softc *softc);
+
 /*
  * Device Methods
  */
@@ -500,6 +550,8 @@ bnxt_queues_free(if_ctx_t ctx)
 		iflib_dma_free(&softc->rx_stats[i]);
 	iflib_dma_free(&softc->hw_tx_port_stats);
 	iflib_dma_free(&softc->hw_rx_port_stats);
+	iflib_dma_free(&softc->hw_tx_port_stats_ext);
+	iflib_dma_free(&softc->hw_rx_port_stats_ext);
 	free(softc->grp_info, M_DEVBUF);
 	free(softc->ag_rings, M_DEVBUF);
 	free(softc->rx_rings, M_DEVBUF);
@@ -574,9 +626,9 @@ bnxt_rx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs,
 	bus_dmamap_sync(softc->hw_rx_port_stats.idi_tag,
             softc->hw_rx_port_stats.idi_map, BUS_DMASYNC_PREREAD);
 
+
 	rc = iflib_dma_alloc(ctx, sizeof(struct tx_port_stats) + BNXT_PORT_STAT_PADDING,
 	    &softc->hw_tx_port_stats, 0);
-
 	if (rc)
 		goto hw_port_tx_stats_alloc_fail;
 
@@ -586,6 +638,26 @@ bnxt_rx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs,
 	softc->rx_port_stats = (void *) softc->hw_rx_port_stats.idi_vaddr;
 	softc->tx_port_stats = (void *) softc->hw_tx_port_stats.idi_vaddr;
 
+
+	rc = iflib_dma_alloc(ctx, sizeof(struct rx_port_stats_ext),
+		&softc->hw_rx_port_stats_ext, 0);
+	if (rc)
+		goto hw_port_rx_stats_ext_alloc_fail;
+
+	bus_dmamap_sync(softc->hw_rx_port_stats_ext.idi_tag,
+	    softc->hw_rx_port_stats_ext.idi_map, BUS_DMASYNC_PREREAD);
+
+	rc = iflib_dma_alloc(ctx, sizeof(struct tx_port_stats_ext),
+		&softc->hw_tx_port_stats_ext, 0);
+	if (rc)
+		goto hw_port_tx_stats_ext_alloc_fail;
+
+	bus_dmamap_sync(softc->hw_tx_port_stats_ext.idi_tag,
+	    softc->hw_tx_port_stats_ext.idi_map, BUS_DMASYNC_PREREAD);
+
+	softc->rx_port_stats_ext = (void *) softc->hw_rx_port_stats_ext.idi_vaddr;
+	softc->tx_port_stats_ext = (void *) softc->hw_tx_port_stats_ext.idi_vaddr;
+
 	for (i = 0; i < nrxqsets; i++) {
 		/* Allocation the completion ring */
 		softc->rx_cp_rings[i].stats_ctx_id = HWRM_NA_SIGNATURE;
@@ -625,7 +697,6 @@ bnxt_rx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs,
 					"Unable to allocate space for TPA\n");
 			goto tpa_alloc_fail;
 		}
-
 		/* Allocate the AG ring */
 		softc->ag_rings[i].phys_id = (uint16_t)HWRM_NA_SIGNATURE;
 		softc->ag_rings[i].softc = softc;
@@ -654,7 +725,7 @@ bnxt_rx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs,
          * HWRM every sec with which firmware timeouts can happen
          */
 	if (BNXT_PF(softc))
-        	bnxt_create_port_stats_sysctls(softc);
+		bnxt_create_port_stats_sysctls(softc);
 
 	/* And finally, the VNIC */
 	softc->vnic_info.id = (uint16_t)HWRM_NA_SIGNATURE;
@@ -700,16 +771,24 @@ bnxt_rx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs,
 	iflib_dma_free(&softc->vnic_info.rss_hash_key_tbl);
 rss_hash_alloc_fail:
 	iflib_dma_free(&softc->vnic_info.mc_list);
-tpa_alloc_fail:
 mc_list_alloc_fail:
-	for (i = i - 1; i >= 0; i--)
-		free(softc->rx_rings[i].tpa_start, M_DEVBUF);
+	for (i = i - 1; i >= 0; i--) {
+		if (softc->rx_rings[i].tpa_start)
+			free(softc->rx_rings[i].tpa_start, M_DEVBUF);
+	}
+tpa_alloc_fail:
+	iflib_dma_free(&softc->hw_tx_port_stats_ext);
+hw_port_tx_stats_ext_alloc_fail:
+	iflib_dma_free(&softc->hw_rx_port_stats_ext);
+hw_port_rx_stats_ext_alloc_fail:
 	iflib_dma_free(&softc->hw_tx_port_stats);
 hw_port_tx_stats_alloc_fail:
 	iflib_dma_free(&softc->hw_rx_port_stats);
 hw_port_rx_stats_alloc_fail:
-	for (i = i - 1; i >= 0; i--)
-		iflib_dma_free(&softc->rx_stats[i]);
+	for (i=0; i < nrxqsets; i++) {
+		if (softc->rx_stats[i].idi_vaddr)
+			iflib_dma_free(&softc->rx_stats[i]);
+	}
 hw_stats_alloc_fail:
 	free(softc->grp_info, M_DEVBUF);
 grp_alloc_fail:
@@ -739,26 +818,43 @@ static int bnxt_alloc_hwrm_short_cmd_req(struct bnxt_softc *softc)
 	return rc;
 }
 
-static void bnxt_free_ring(struct bnxt_softc *bp, struct bnxt_ring_mem_info *rmem)
+static void bnxt_free_ring(struct bnxt_softc *softc, struct bnxt_ring_mem_info *rmem)
 {
-        int i;
+	int i;
 
-        for (i = 0; i < rmem->nr_pages; i++) {
-                if (!rmem->pg_arr[i].idi_vaddr)
-                        continue;
+	for (i = 0; i < rmem->nr_pages; i++) {
+		if (!rmem->pg_arr[i].idi_vaddr)
+			continue;
 
 		iflib_dma_free(&rmem->pg_arr[i]);
-                rmem->pg_arr[i].idi_vaddr = NULL;
-        }
-        if (rmem->pg_tbl.idi_vaddr) {
+		rmem->pg_arr[i].idi_vaddr = NULL;
+	}
+	if (rmem->pg_tbl.idi_vaddr) {
 		iflib_dma_free(&rmem->pg_tbl);
-                rmem->pg_tbl.idi_vaddr = NULL;
+		rmem->pg_tbl.idi_vaddr = NULL;
 
-        }
-        if (rmem->vmem_size && *rmem->vmem) {
-                free(*rmem->vmem, M_DEVBUF);
-                *rmem->vmem = NULL;
-        }
+	}
+	if (rmem->vmem_size && *rmem->vmem) {
+		free(*rmem->vmem, M_DEVBUF);
+		*rmem->vmem = NULL;
+	}
+}
+
+static void bnxt_init_ctx_mem(struct bnxt_ctx_mem_type *ctxm, void *p, int len)
+{
+	u8 init_val = ctxm->init_value;
+	u16 offset = ctxm->init_offset;
+	u8 *p2 = p;
+	int i;
+
+	if (!init_val)
+		return;
+	if (offset == BNXT_CTX_INIT_INVALID_OFFSET) {
+		memset(p, init_val, len);
+		return;
+	}
+	for (i = 0; i < len; i += ctxm->entry_size)
+		*(p2 + i + offset) = init_val;
 }
 
 static int bnxt_alloc_ring(struct bnxt_softc *softc, struct bnxt_ring_mem_info *rmem)
@@ -789,8 +885,9 @@ static int bnxt_alloc_ring(struct bnxt_softc *softc, struct bnxt_ring_mem_info *
 		if (rc)
 			return -ENOMEM;
 
-		if (rmem->init_val)
-                        memset(rmem->pg_arr[i].idi_vaddr, rmem->init_val, rmem->page_size);
+		if (rmem->ctx_mem)
+			bnxt_init_ctx_mem(rmem->ctx_mem, rmem->pg_arr[i].idi_vaddr,
+					rmem->page_size);
 
 		if (rmem->nr_pages > 1 || rmem->depth > 0) {
 			if (i == rmem->nr_pages - 2 &&
@@ -813,11 +910,12 @@ static int bnxt_alloc_ring(struct bnxt_softc *softc, struct bnxt_ring_mem_info *
 	return 0;
 }
 
-#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_DFLT_ENABLES			\
+
+#define HWRM_FUNC_BACKING_STORE_CFG_INPUT_DFLT_ENABLES		\
 	(HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_QP |		\
-	 HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_SRQ |		\
+	 HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_SRQ |	\
 	 HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_CQ |		\
-	 HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_VNIC |		\
+	 HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_VNIC |	\
 	 HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_STAT)
 
 static int bnxt_alloc_ctx_mem_blk(struct bnxt_softc *softc,
@@ -835,14 +933,14 @@ static int bnxt_alloc_ctx_mem_blk(struct bnxt_softc *softc,
 }
 
 static int bnxt_alloc_ctx_pg_tbls(struct bnxt_softc *softc,
-				  struct bnxt_ctx_pg_info *ctx_pg, uint32_t mem_size,
-				  uint8_t depth, bool use_init_val)
+				  struct bnxt_ctx_pg_info *ctx_pg, u32 mem_size,
+				  u8 depth, struct bnxt_ctx_mem_type *ctxm)
 {
 	struct bnxt_ring_mem_info *rmem = &ctx_pg->ring_mem;
 	int rc;
 
 	if (!mem_size)
-		return 0;
+		return -EINVAL;
 
 	ctx_pg->nr_pages = DIV_ROUND_UP(mem_size, BNXT_PAGE_SIZE);
 	if (ctx_pg->nr_pages > MAX_CTX_TOTAL_PAGES) {
@@ -853,8 +951,8 @@ static int bnxt_alloc_ctx_pg_tbls(struct bnxt_softc *softc,
 		int nr_tbls, i;
 
 		rmem->depth = 2;
-		ctx_pg->ctx_pg_tbl = malloc(MAX_CTX_PAGES * sizeof(ctx_pg),
-				M_DEVBUF, M_NOWAIT | M_ZERO);
+		ctx_pg->ctx_pg_tbl = kzalloc(MAX_CTX_PAGES * sizeof(ctx_pg),
+					      GFP_KERNEL);
 		if (!ctx_pg->ctx_pg_tbl)
 			return -ENOMEM;
 		nr_tbls = DIV_ROUND_UP(ctx_pg->nr_pages, MAX_CTX_PAGES);
@@ -865,7 +963,7 @@ static int bnxt_alloc_ctx_pg_tbls(struct bnxt_softc *softc,
 		for (i = 0; i < nr_tbls; i++) {
 			struct bnxt_ctx_pg_info *pg_tbl;
 
-			pg_tbl = malloc(sizeof(*pg_tbl), M_DEVBUF, M_NOWAIT | M_ZERO);
+			pg_tbl = kzalloc(sizeof(*pg_tbl), GFP_KERNEL);
 			if (!pg_tbl)
 				return -ENOMEM;
 			ctx_pg->ctx_pg_tbl[i] = pg_tbl;
@@ -873,8 +971,7 @@ static int bnxt_alloc_ctx_pg_tbls(struct bnxt_softc *softc,
 			memcpy(&rmem->pg_tbl, &ctx_pg->ctx_arr[i], sizeof(struct iflib_dma_info));
 			rmem->depth = 1;
 			rmem->nr_pages = MAX_CTX_PAGES;
-			if (use_init_val)
-                                rmem->init_val = softc->ctx_mem->ctx_kind_initializer;
+			rmem->ctx_mem = ctxm;
 			if (i == (nr_tbls - 1)) {
 				int rem = ctx_pg->nr_pages % MAX_CTX_PAGES;
 
@@ -889,8 +986,7 @@ static int bnxt_alloc_ctx_pg_tbls(struct bnxt_softc *softc,
 		rmem->nr_pages = DIV_ROUND_UP(mem_size, BNXT_PAGE_SIZE);
 		if (rmem->nr_pages > 1 || depth)
 			rmem->depth = 1;
-		if (use_init_val)
-			rmem->init_val = softc->ctx_mem->ctx_kind_initializer;
+		rmem->ctx_mem = ctxm;
 		rc = bnxt_alloc_ctx_mem_blk(softc, ctx_pg);
 	}
 	return rc;
@@ -918,48 +1014,78 @@ static void bnxt_free_ctx_pg_tbls(struct bnxt_softc *softc,
 			free(pg_tbl , M_DEVBUF);
 			ctx_pg->ctx_pg_tbl[i] = NULL;
 		}
-		free(ctx_pg->ctx_pg_tbl , M_DEVBUF);
+		kfree(ctx_pg->ctx_pg_tbl);
 		ctx_pg->ctx_pg_tbl = NULL;
 	}
 	bnxt_free_ring(softc, rmem);
 	ctx_pg->nr_pages = 0;
 }
 
+static int bnxt_setup_ctxm_pg_tbls(struct bnxt_softc *softc,
+				   struct bnxt_ctx_mem_type *ctxm, u32 entries,
+				   u8 pg_lvl)
+{
+	struct bnxt_ctx_pg_info *ctx_pg = ctxm->pg_info;
+	int i, rc = 0, n = 1;
+	u32 mem_size;
+
+	if (!ctxm->entry_size || !ctx_pg)
+		return -EINVAL;
+	if (ctxm->instance_bmap)
+		n = hweight32(ctxm->instance_bmap);
+	if (ctxm->entry_multiple)
+		entries = roundup(entries, ctxm->entry_multiple);
+	entries = clamp_t(u32, entries, ctxm->min_entries, ctxm->max_entries);
+	mem_size = entries * ctxm->entry_size;
+	for (i = 0; i < n && !rc; i++) {
+		ctx_pg[i].entries = entries;
+		rc = bnxt_alloc_ctx_pg_tbls(softc, &ctx_pg[i], mem_size, pg_lvl,
+					    ctxm->init_value ? ctxm : NULL);
+	}
+	return rc;
+}
+
 static void bnxt_free_ctx_mem(struct bnxt_softc *softc)
 {
 	struct bnxt_ctx_mem_info *ctx = softc->ctx_mem;
-	int i;
+	u16 type;
 
 	if (!ctx)
 		return;
 
-	if (ctx->tqm_mem[0]) {
-		for (i = 0; i < softc->max_q + 1; i++) {
-			if (!ctx->tqm_mem[i])
-				continue;
-			bnxt_free_ctx_pg_tbls(softc, ctx->tqm_mem[i]);
-		}
-		free(ctx->tqm_mem[0] , M_DEVBUF);
-		ctx->tqm_mem[0] = NULL;
+	for (type = 0; type < BNXT_CTX_MAX; type++) {
+		struct bnxt_ctx_mem_type *ctxm = &ctx->ctx_arr[type];
+		struct bnxt_ctx_pg_info *ctx_pg = ctxm->pg_info;
+		int i, n = 1;
+
+		if (!ctx_pg)
+			continue;
+		if (ctxm->instance_bmap)
+			n = hweight32(ctxm->instance_bmap);
+		for (i = 0; i < n; i++)
+			bnxt_free_ctx_pg_tbls(softc, &ctx_pg[i]);
+
+		kfree(ctx_pg);
+		ctxm->pg_info = NULL;
 	}
 
-	bnxt_free_ctx_pg_tbls(softc, &ctx->tim_mem);
-	bnxt_free_ctx_pg_tbls(softc, &ctx->mrav_mem);
-	bnxt_free_ctx_pg_tbls(softc, &ctx->stat_mem);
-	bnxt_free_ctx_pg_tbls(softc, &ctx->vnic_mem);
-	bnxt_free_ctx_pg_tbls(softc, &ctx->cq_mem);
-	bnxt_free_ctx_pg_tbls(softc, &ctx->srq_mem);
-	bnxt_free_ctx_pg_tbls(softc, &ctx->qp_mem);
 	ctx->flags &= ~BNXT_CTX_FLAG_INITED;
-	free(softc->ctx_mem, M_DEVBUF);
+	kfree(ctx);
 	softc->ctx_mem = NULL;
 }
 
 static int bnxt_alloc_ctx_mem(struct bnxt_softc *softc)
 {
 	struct bnxt_ctx_pg_info *ctx_pg;
+	struct bnxt_ctx_mem_type *ctxm;
 	struct bnxt_ctx_mem_info *ctx;
-	uint32_t mem_size, ena, entries;
+	u32 l2_qps, qp1_qps, max_qps;
+	u32 ena, entries_sp, entries;
+	u32 srqs, max_srqs, min;
+	u32 num_mr, num_ah;
+	u32 extra_srqs = 0;
+	u32 extra_qps = 0;
+	u8 pg_lvl = 1;
 	int i, rc;
 
 	if (!BNXT_CHIP_P5(softc))
@@ -975,97 +1101,106 @@ static int bnxt_alloc_ctx_mem(struct bnxt_softc *softc)
 	if (!ctx || (ctx->flags & BNXT_CTX_FLAG_INITED))
 		return 0;
 
-	ctx_pg = &ctx->qp_mem;
-	ctx_pg->entries = ctx->qp_min_qp1_entries + ctx->qp_max_l2_entries +
-			  (1024 * 64); /* FIXME: Enable 64K QPs */
-	mem_size = ctx->qp_entry_size * ctx_pg->entries;
-	rc = bnxt_alloc_ctx_pg_tbls(softc, ctx_pg, mem_size, 2, true);
+	ctxm = &ctx->ctx_arr[BNXT_CTX_QP];
+	l2_qps = ctxm->qp_l2_entries;
+	qp1_qps = ctxm->qp_qp1_entries;
+	max_qps = ctxm->max_entries;
+	ctxm = &ctx->ctx_arr[BNXT_CTX_SRQ];
+	srqs = ctxm->srq_l2_entries;
+	max_srqs = ctxm->max_entries;
+	if (softc->flags & BNXT_FLAG_ROCE_CAP) {
+		pg_lvl = 2;
+		extra_qps = min_t(u32, 65536, max_qps - l2_qps - qp1_qps);
+		extra_srqs = min_t(u32, 8192, max_srqs - srqs);
+	}
+
+	ctxm = &ctx->ctx_arr[BNXT_CTX_QP];
+	rc = bnxt_setup_ctxm_pg_tbls(softc, ctxm, l2_qps + qp1_qps + extra_qps,
+				     pg_lvl);
 	if (rc)
 		return rc;
 
-	ctx_pg = &ctx->srq_mem;
-	/* FIXME: Temporarily enable 8K RoCE SRQs */
-	ctx_pg->entries = ctx->srq_max_l2_entries + (1024 * 8);
-	mem_size = ctx->srq_entry_size * ctx_pg->entries;
-	rc = bnxt_alloc_ctx_pg_tbls(softc, ctx_pg, mem_size, 2, true);
+	ctxm = &ctx->ctx_arr[BNXT_CTX_SRQ];
+	rc = bnxt_setup_ctxm_pg_tbls(softc, ctxm, srqs + extra_srqs, pg_lvl);
 	if (rc)
 		return rc;
 
-	ctx_pg = &ctx->cq_mem;
-	/* FIXME: Temporarily enable 64K RoCE CQ */
-	ctx_pg->entries = ctx->cq_max_l2_entries + (1024 * 64 * 2);
-	mem_size = ctx->cq_entry_size * ctx_pg->entries;
-	rc = bnxt_alloc_ctx_pg_tbls(softc, ctx_pg, mem_size, 2, true);
+	ctxm = &ctx->ctx_arr[BNXT_CTX_CQ];
+	rc = bnxt_setup_ctxm_pg_tbls(softc, ctxm, ctxm->cq_l2_entries +
+				     extra_qps * 2, pg_lvl);
 	if (rc)
 		return rc;
 
-	ctx_pg = &ctx->vnic_mem;
-	ctx_pg->entries = ctx->vnic_max_vnic_entries +
-			  ctx->vnic_max_ring_table_entries;
-	mem_size = ctx->vnic_entry_size * ctx_pg->entries;
-	rc = bnxt_alloc_ctx_pg_tbls(softc, ctx_pg, mem_size, 1, true);
+	ctxm = &ctx->ctx_arr[BNXT_CTX_VNIC];
+	rc = bnxt_setup_ctxm_pg_tbls(softc, ctxm, ctxm->max_entries, 1);
 	if (rc)
 		return rc;
 
-	ctx_pg = &ctx->stat_mem;
-	ctx_pg->entries = ctx->stat_max_entries;
-	mem_size = ctx->stat_entry_size * ctx_pg->entries;
-	rc = bnxt_alloc_ctx_pg_tbls(softc, ctx_pg, mem_size, 1, true);
+	ctxm = &ctx->ctx_arr[BNXT_CTX_STAT];
+	rc = bnxt_setup_ctxm_pg_tbls(softc, ctxm, ctxm->max_entries, 1);
 	if (rc)
 		return rc;
 
-	ctx_pg = &ctx->mrav_mem;
-	/* FIXME: Temporarily enable 256K RoCE MRs */
-	ctx_pg->entries = 1024 * 256;
-	mem_size = ctx->mrav_entry_size * ctx_pg->entries;
-	rc = bnxt_alloc_ctx_pg_tbls(softc, ctx_pg, mem_size, 2, true);
+	ena = 0;
+	if (!(softc->flags & BNXT_FLAG_ROCE_CAP))
+		goto skip_rdma;
+
+	ctxm = &ctx->ctx_arr[BNXT_CTX_MRAV];
+	ctx_pg = ctxm->pg_info;
+	/* 128K extra is needed to accomodate static AH context
+	 * allocation by f/w.
+	 */
+	num_mr = min_t(u32, ctxm->max_entries / 2, 1024 * 256);
+	num_ah = min_t(u32, num_mr, 1024 * 128);
+	rc = bnxt_setup_ctxm_pg_tbls(softc, ctxm, num_mr + num_ah, 2);
 	if (rc)
 		return rc;
+	ctx_pg->entries = num_mr + num_ah;
 	ena = HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_MRAV;
+	if (ctxm->mrav_num_entries_units)
+		ctx_pg->entries =
+			((num_mr / ctxm->mrav_num_entries_units) << 16) |
+			 (num_ah / ctxm->mrav_num_entries_units);
 
-	ctx_pg = &ctx->tim_mem;
-	/* Firmware needs number of TIM entries equal to
-	 * number of Total QP contexts enabled, including
-	 * L2 QPs.
-	 */
-	ctx_pg->entries = ctx->qp_min_qp1_entries +
-			  ctx->qp_max_l2_entries + 1024 * 64;
-	/* FIXME: L2 driver is not able to create queue depth
-	 *  worth of 1M 32bit timers. Need a fix when l2-roce
-	 *  interface is well designed.
-	 */
-	mem_size = ctx->tim_entry_size * ctx_pg->entries;
-	rc = bnxt_alloc_ctx_pg_tbls(softc, ctx_pg, mem_size, 2, false);
+	ctxm = &ctx->ctx_arr[BNXT_CTX_TIM];
+	rc = bnxt_setup_ctxm_pg_tbls(softc, ctxm, l2_qps + qp1_qps + extra_qps, 1);
 	if (rc)
 		return rc;
 	ena |= HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TIM;
 
-	/* FIXME: Temporarily increase the TQM queue depth
-	 * by 1K for 1K RoCE QPs.
-	 */
-	entries = ctx->qp_max_l2_entries + 1024 * 64;
-	entries = roundup(entries, ctx->tqm_entries_multiple);
-	entries = clamp_t(uint32_t, entries, ctx->tqm_min_entries_per_ring,
-			  ctx->tqm_max_entries_per_ring);
-	for (i = 0; i < softc->max_q + 1; i++) {
-		ctx_pg = ctx->tqm_mem[i];
-		ctx_pg->entries = entries;
-		mem_size = ctx->tqm_entry_size * entries;
-		rc = bnxt_alloc_ctx_pg_tbls(softc, ctx_pg, mem_size, 2, false);
+skip_rdma:
+	ctxm = &ctx->ctx_arr[BNXT_CTX_STQM];
+	min = ctxm->min_entries;
+	entries_sp = ctx->ctx_arr[BNXT_CTX_VNIC].vnic_entries + l2_qps +
+		     2 * (extra_qps + qp1_qps) + min;
+	rc = bnxt_setup_ctxm_pg_tbls(softc, ctxm, entries_sp, 2);
 		if (rc)
 			return rc;
-		ena |= HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_SP << i;
+
+	ctxm = &ctx->ctx_arr[BNXT_CTX_FTQM];
+	entries = l2_qps + 2 * (extra_qps + qp1_qps);
+	rc = bnxt_setup_ctxm_pg_tbls(softc, ctxm, entries, 2);
+	if (rc)
+		return rc;
+	for (i = 0; i < ctx->tqm_fp_rings_count + 1; i++) {
+		if (i < BNXT_MAX_TQM_LEGACY_RINGS)
+			ena |= HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_SP << i;
+		else
+			ena |= HWRM_FUNC_BACKING_STORE_CFG_INPUT_ENABLES_TQM_RING8;
 	}
 	ena |= HWRM_FUNC_BACKING_STORE_CFG_INPUT_DFLT_ENABLES;
+
 	rc = bnxt_hwrm_func_backing_store_cfg(softc, ena);
-	if (rc)
+	if (rc) {
 		device_printf(softc->dev, "Failed configuring context mem, rc = %d.\n",
 			   rc);
-	else
-		ctx->flags |= BNXT_CTX_FLAG_INITED;
+		return rc;
+	}
+	ctx->flags |= BNXT_CTX_FLAG_INITED;
 
 	return 0;
 }
+
 /*
  * If we update the index, a write barrier is needed after the write to ensure
  * the completion ring has space before the RX/TX ring does.  Since we can't
@@ -1212,22 +1347,718 @@ struct bnxt_softc *bnxt_find_dev(uint32_t domain, uint32_t bus, uint32_t dev_fn,
 {
 	struct bnxt_softc_list *sc = NULL;
 
-	SLIST_FOREACH(sc, &pf_list, next) {
-		/* get the softc reference based on device name */
-		if (dev_name && !strncmp(dev_name, if_name(iflib_get_ifp(sc->softc->ctx)), BNXT_MAX_STR)) {
-			return sc->softc;
-		}
-		/* get the softc reference based on domain,bus,device,function */
-		if (!dev_name &&
-		    (domain == sc->softc->domain) &&
-		    (bus == sc->softc->bus) &&
-		    (dev_fn == sc->softc->dev_fn)) {
-			return sc->softc;
+	SLIST_FOREACH(sc, &pf_list, next) {
+		/* get the softc reference based on device name */
+		if (dev_name && !strncmp(dev_name, if_name(iflib_get_ifp(sc->softc->ctx)), BNXT_MAX_STR)) {
+			return sc->softc;
+		}
+		/* get the softc reference based on domain,bus,device,function */
+		if (!dev_name &&
+		    (domain == sc->softc->domain) &&
+		    (bus == sc->softc->bus) &&
+		    (dev_fn == sc->softc->dev_fn)) {
+			return sc->softc;
+
+		}
+	}
+
+	return NULL;
+}
+
+
+static void bnxt_verify_asym_queues(struct bnxt_softc *softc)
+{
+	uint8_t i, lltc = 0;
+
+	if (!softc->max_lltc)
+		return;
+
+	/* Verify that lossless TX and RX queues are in the same index */
+	for (i = 0; i < softc->max_tc; i++) {
+		if (BNXT_LLQ(softc->tx_q_info[i].queue_profile) &&
+		    BNXT_LLQ(softc->rx_q_info[i].queue_profile))
+			lltc++;
+	}
+	softc->max_lltc = min(softc->max_lltc, lltc);
+}
+
+static int bnxt_hwrm_poll(struct bnxt_softc *bp)
+{
+	struct hwrm_ver_get_output	*resp =
+	    (void *)bp->hwrm_cmd_resp.idi_vaddr;
+	struct hwrm_ver_get_input req = {0};
+	int rc;
+
+	bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_VER_GET);
+
+	req.hwrm_intf_maj = HWRM_VERSION_MAJOR;
+	req.hwrm_intf_min = HWRM_VERSION_MINOR;
+	req.hwrm_intf_upd = HWRM_VERSION_UPDATE;
+
+	rc = _hwrm_send_message(bp, &req, sizeof(req));
+	if (rc)
+		return rc;
+
+	if (resp->flags & HWRM_VER_GET_OUTPUT_FLAGS_DEV_NOT_RDY)
+		rc = -EAGAIN;
+
+	return rc;
+}
+
+static void bnxt_rtnl_lock_sp(struct bnxt_softc *bp)
+{
+	/* We are called from bnxt_sp_task which has BNXT_STATE_IN_SP_TASK
+	 * set.  If the device is being closed, bnxt_close() may be holding
+	 * rtnl() and waiting for BNXT_STATE_IN_SP_TASK to clear.  So we
+	 * must clear BNXT_STATE_IN_SP_TASK before holding rtnl().
+	 */
+	clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state);
+	rtnl_lock();
+}
+
+static void bnxt_rtnl_unlock_sp(struct bnxt_softc *bp)
+{
+	set_bit(BNXT_STATE_IN_SP_TASK, &bp->state);
+	rtnl_unlock();
+}
+
+static void bnxt_fw_fatal_close(struct bnxt_softc *softc)
+{
+	bnxt_disable_intr(softc->ctx);
+	if (pci_is_enabled(softc->pdev))
+		pci_disable_device(softc->pdev);
+}
+
+static u32 bnxt_fw_health_readl(struct bnxt_softc *bp, int reg_idx)
+{
+	struct bnxt_fw_health *fw_health = bp->fw_health;
+	u32 reg = fw_health->regs[reg_idx];
+	u32 reg_type, reg_off, val = 0;
+
+	reg_type = BNXT_FW_HEALTH_REG_TYPE(reg);
+	reg_off = BNXT_FW_HEALTH_REG_OFF(reg);
+	switch (reg_type) {
+	case BNXT_FW_HEALTH_REG_TYPE_CFG:
+		pci_read_config_dword(bp->pdev, reg_off, &val);
+		break;
+	case BNXT_FW_HEALTH_REG_TYPE_GRC:
+		reg_off = fw_health->mapped_regs[reg_idx];
+		fallthrough;
+	case BNXT_FW_HEALTH_REG_TYPE_BAR0:
+		val = readl_fbsd(bp, reg_off, 0);
+		break;
+	case BNXT_FW_HEALTH_REG_TYPE_BAR1:
+		val = readl_fbsd(bp, reg_off, 2);
+		break;
+	}
+	if (reg_idx == BNXT_FW_RESET_INPROG_REG)
+		val &= fw_health->fw_reset_inprog_reg_mask;
+	return val;
+}
+
+static void bnxt_fw_reset_close(struct bnxt_softc *bp)
+{
+	int i;
+	bnxt_ulp_stop(bp);
+	/* When firmware is in fatal state, quiesce device and disable
+	 * bus master to prevent any potential bad DMAs before freeing
+	 * kernel memory.
+	 */
+	if (test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state)) {
+		u16 val = 0;
+
+		val = pci_read_config(bp->dev, PCI_SUBSYSTEM_ID, 2);
+		if (val == 0xffff) {
+			bp->fw_reset_min_dsecs = 0;
+		}
+		bnxt_fw_fatal_close(bp);
+	}
+
+	iflib_request_reset(bp->ctx);
+	bnxt_stop(bp->ctx);
+	bnxt_hwrm_func_drv_unrgtr(bp, false);
+
+	for (i = bp->nrxqsets-1; i>=0; i--) {
+		if (BNXT_CHIP_P5(bp))
+			iflib_irq_free(bp->ctx, &bp->nq_rings[i].irq);
+		else
+			iflib_irq_free(bp->ctx, &bp->rx_cp_rings[i].irq);
+
+	}
+	if (pci_is_enabled(bp->pdev))
+		pci_disable_device(bp->pdev);
+	pci_disable_busmaster(bp->dev);
+	bnxt_free_ctx_mem(bp);
+}
+
+static bool is_bnxt_fw_ok(struct bnxt_softc *bp)
+{
+	struct bnxt_fw_health *fw_health = bp->fw_health;
+	bool no_heartbeat = false, has_reset = false;
+	u32 val;
+
+	val = bnxt_fw_health_readl(bp, BNXT_FW_HEARTBEAT_REG);
+	if (val == fw_health->last_fw_heartbeat)
+		no_heartbeat = true;
+
+	val = bnxt_fw_health_readl(bp, BNXT_FW_RESET_CNT_REG);
+	if (val != fw_health->last_fw_reset_cnt)
+		has_reset = true;
+
+	if (!no_heartbeat && has_reset)
+		return true;
+
+	return false;
+}
+
+void bnxt_fw_reset(struct bnxt_softc *bp)
+{
+	bnxt_rtnl_lock_sp(bp);
+	if (test_bit(BNXT_STATE_OPEN, &bp->state) &&
+	    !test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) {
+		int tmo;
+		set_bit(BNXT_STATE_IN_FW_RESET, &bp->state);
+		bnxt_fw_reset_close(bp);
+
+		if ((bp->fw_cap & BNXT_FW_CAP_ERR_RECOVER_RELOAD)) {
+			bp->fw_reset_state = BNXT_FW_RESET_STATE_POLL_FW_DOWN;
+			tmo = HZ / 10;
+		} else {
+			bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV;
+			tmo = bp->fw_reset_min_dsecs * HZ /10;
+		}
+		bnxt_queue_fw_reset_work(bp, tmo);
+	}
+	bnxt_rtnl_unlock_sp(bp);
+}
+
+static void bnxt_queue_fw_reset_work(struct bnxt_softc *bp, unsigned long delay)
+{
+	if (!(test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)))
+		return;
+
+	if (BNXT_PF(bp))
+		queue_delayed_work(bnxt_pf_wq, &bp->fw_reset_task, delay);
+	else
+		schedule_delayed_work(&bp->fw_reset_task, delay);
+}
+
+void bnxt_queue_sp_work(struct bnxt_softc *bp)
+{
+	if (BNXT_PF(bp))
+		queue_work(bnxt_pf_wq, &bp->sp_task);
+	else
+		schedule_work(&bp->sp_task);
+}
+
+static void bnxt_fw_reset_writel(struct bnxt_softc *bp, int reg_idx)
+{
+	struct bnxt_fw_health *fw_health = bp->fw_health;
+	u32 reg = fw_health->fw_reset_seq_regs[reg_idx];
+	u32 val = fw_health->fw_reset_seq_vals[reg_idx];
+	u32 reg_type, reg_off, delay_msecs;
+
+	delay_msecs = fw_health->fw_reset_seq_delay_msec[reg_idx];
+	reg_type = BNXT_FW_HEALTH_REG_TYPE(reg);
+	reg_off = BNXT_FW_HEALTH_REG_OFF(reg);
+	switch (reg_type) {
+	case BNXT_FW_HEALTH_REG_TYPE_CFG:
+		pci_write_config_dword(bp->pdev, reg_off, val);
+		break;
+	case BNXT_FW_HEALTH_REG_TYPE_GRC:
+		writel_fbsd(bp, BNXT_GRCPF_REG_WINDOW_BASE_OUT + 4, 0, reg_off & BNXT_GRC_BASE_MASK);
+		reg_off = (reg_off & BNXT_GRC_OFFSET_MASK) + 0x2000;
+		fallthrough;
+	case BNXT_FW_HEALTH_REG_TYPE_BAR0:
+		writel_fbsd(bp, reg_off, 0, val);
+		break;
+	case BNXT_FW_HEALTH_REG_TYPE_BAR1:
+		writel_fbsd(bp, reg_off, 2, val);
+		break;
+	}
+	if (delay_msecs) {
+		pci_read_config_dword(bp->pdev, 0, &val);
+		msleep(delay_msecs);
+	}
+}
+
+static void bnxt_reset_all(struct bnxt_softc *bp)
+{
+	struct bnxt_fw_health *fw_health = bp->fw_health;
+	int i, rc;
+
+	if (bp->fw_cap & BNXT_FW_CAP_ERR_RECOVER_RELOAD) {
+		bp->fw_reset_timestamp = jiffies;
+		return;
+	}
+
+	if (fw_health->flags & HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FLAGS_HOST) {
+		for (i = 0; i < fw_health->fw_reset_seq_cnt; i++)
+			bnxt_fw_reset_writel(bp, i);
+	} else if (fw_health->flags & HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FLAGS_CO_CPU) {
+		struct hwrm_fw_reset_input req = {0};
+
+		bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FW_RESET);
+		req.target_id = htole16(HWRM_TARGET_ID_KONG);
+		req.embedded_proc_type = HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_CHIP;
+		req.selfrst_status = HWRM_FW_RESET_INPUT_SELFRST_STATUS_SELFRSTASAP;
+		req.flags = HWRM_FW_RESET_INPUT_FLAGS_RESET_GRACEFUL;
+		rc = hwrm_send_message(bp, &req, sizeof(req));
+
+		if (rc != -ENODEV)
+			device_printf(bp->dev, "Unable to reset FW rc=%d\n", rc);
+	}
+	bp->fw_reset_timestamp = jiffies;
+}
+
+static int __bnxt_alloc_fw_health(struct bnxt_softc *bp)
+{
+	if (bp->fw_health)
+		return 0;
+
+	bp->fw_health = kzalloc(sizeof(*bp->fw_health), GFP_KERNEL);
+	if (!bp->fw_health)
+		return -ENOMEM;
+
+	mutex_init(&bp->fw_health->lock);
+	return 0;
+}
+
+static int bnxt_alloc_fw_health(struct bnxt_softc *bp)
+{
+	int rc;
+
+	if (!(bp->fw_cap & BNXT_FW_CAP_HOT_RESET) &&
+	    !(bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY))
+		return 0;
+
+	rc = __bnxt_alloc_fw_health(bp);
+	if (rc) {
+		bp->fw_cap &= ~BNXT_FW_CAP_HOT_RESET;
+		bp->fw_cap &= ~BNXT_FW_CAP_ERROR_RECOVERY;
+		return rc;
+	}
+
+	return 0;
+}
+
+static inline void __bnxt_map_fw_health_reg(struct bnxt_softc *bp, u32 reg)
+{
+	writel_fbsd(bp, BNXT_GRCPF_REG_WINDOW_BASE_OUT + BNXT_FW_HEALTH_WIN_MAP_OFF, 0, reg & BNXT_GRC_BASE_MASK);
+}
+
+static int bnxt_map_fw_health_regs(struct bnxt_softc *bp)
+{
+	struct bnxt_fw_health *fw_health = bp->fw_health;
+	u32 reg_base = 0xffffffff;
+	int i;
+
+	bp->fw_health->status_reliable = false;
+	bp->fw_health->resets_reliable = false;
+	/* Only pre-map the monitoring GRC registers using window 3 */
+	for (i = 0; i < 4; i++) {
+		u32 reg = fw_health->regs[i];
+
+		if (BNXT_FW_HEALTH_REG_TYPE(reg) != BNXT_FW_HEALTH_REG_TYPE_GRC)
+			continue;
+		if (reg_base == 0xffffffff)
+			reg_base = reg & BNXT_GRC_BASE_MASK;
+		if ((reg & BNXT_GRC_BASE_MASK) != reg_base)
+			return -ERANGE;
+		fw_health->mapped_regs[i] = BNXT_FW_HEALTH_WIN_OFF(reg);
+	}
+	bp->fw_health->status_reliable = true;
+	bp->fw_health->resets_reliable = true;
+	if (reg_base == 0xffffffff)
+		return 0;
+
+	__bnxt_map_fw_health_reg(bp, reg_base);
+	return 0;
+}
+
+static void bnxt_inv_fw_health_reg(struct bnxt_softc *bp)
+{
+	struct bnxt_fw_health *fw_health = bp->fw_health;
+	u32 reg_type;
+
+	if (!fw_health)
+		return;
+
+	reg_type = BNXT_FW_HEALTH_REG_TYPE(fw_health->regs[BNXT_FW_HEALTH_REG]);
+	if (reg_type == BNXT_FW_HEALTH_REG_TYPE_GRC)
+		fw_health->status_reliable = false;
+
+	reg_type = BNXT_FW_HEALTH_REG_TYPE(fw_health->regs[BNXT_FW_RESET_CNT_REG]);
+	if (reg_type == BNXT_FW_HEALTH_REG_TYPE_GRC)
+		fw_health->resets_reliable = false;
+}
+
+static int bnxt_hwrm_error_recovery_qcfg(struct bnxt_softc *bp)
+{
+	struct bnxt_fw_health *fw_health = bp->fw_health;
+	struct hwrm_error_recovery_qcfg_output *resp =
+	    (void *)bp->hwrm_cmd_resp.idi_vaddr;
+	struct hwrm_error_recovery_qcfg_input req = {0};
+	int rc, i;
+
+	if (!(bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY))
+		return 0;
+
+	bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_ERROR_RECOVERY_QCFG);
+	rc = _hwrm_send_message(bp, &req, sizeof(req));
+
+	if (rc)
+		goto err_recovery_out;
+	fw_health->flags = le32toh(resp->flags);
+	if ((fw_health->flags & HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FLAGS_CO_CPU) &&
+	    !(bp->fw_cap & BNXT_FW_CAP_KONG_MB_CHNL)) {
+		rc = -EINVAL;
+		goto err_recovery_out;
+	}
+	fw_health->polling_dsecs = le32toh(resp->driver_polling_freq);
+	fw_health->master_func_wait_dsecs =
+		le32toh(resp->master_func_wait_period);
+	fw_health->normal_func_wait_dsecs =
+		le32toh(resp->normal_func_wait_period);
+	fw_health->post_reset_wait_dsecs =
+		le32toh(resp->master_func_wait_period_after_reset);
+	fw_health->post_reset_max_wait_dsecs =
+		le32toh(resp->max_bailout_time_after_reset);
+	fw_health->regs[BNXT_FW_HEALTH_REG] =
+		le32toh(resp->fw_health_status_reg);
+	fw_health->regs[BNXT_FW_HEARTBEAT_REG] =
+		le32toh(resp->fw_heartbeat_reg);
+	fw_health->regs[BNXT_FW_RESET_CNT_REG] =
+		le32toh(resp->fw_reset_cnt_reg);
+	fw_health->regs[BNXT_FW_RESET_INPROG_REG] =
+		le32toh(resp->reset_inprogress_reg);
+	fw_health->fw_reset_inprog_reg_mask =
+		le32toh(resp->reset_inprogress_reg_mask);
+	fw_health->fw_reset_seq_cnt = resp->reg_array_cnt;
+	if (fw_health->fw_reset_seq_cnt >= 16) {
+		rc = -EINVAL;
+		goto err_recovery_out;
+	}
+	for (i = 0; i < fw_health->fw_reset_seq_cnt; i++) {
+		fw_health->fw_reset_seq_regs[i] =
+			le32toh(resp->reset_reg[i]);
+		fw_health->fw_reset_seq_vals[i] =
+			le32toh(resp->reset_reg_val[i]);
+		fw_health->fw_reset_seq_delay_msec[i] =
+			le32toh(resp->delay_after_reset[i]);
+	}
+err_recovery_out:
+	if (!rc)
+		rc = bnxt_map_fw_health_regs(bp);
+	if (rc)
+		bp->fw_cap &= ~BNXT_FW_CAP_ERROR_RECOVERY;
+	return rc;
+}
+
+static int bnxt_drv_rgtr(struct bnxt_softc *bp)
+{
+	int rc;
+
+	/* determine whether we can support error recovery before
+	 * registering with FW
+	 */
+	if (bnxt_alloc_fw_health(bp)) {
+		device_printf(bp->dev, "no memory for firmware error recovery\n");
+	} else {
+		rc = bnxt_hwrm_error_recovery_qcfg(bp);
+		if (rc)
+			device_printf(bp->dev, "hwrm query error recovery failure rc: %d\n",
+				    rc);
+	}
+	rc = bnxt_hwrm_func_drv_rgtr(bp, NULL, 0, false);  //sumit dbg: revisit the params
+	if (rc)
+		return -ENODEV;
+	return 0;
+}
+
+static bool bnxt_fw_reset_timeout(struct bnxt_softc *bp)
+{
+	return time_after(jiffies, bp->fw_reset_timestamp +
+			  (bp->fw_reset_max_dsecs * HZ / 10));
+}
+
+static int bnxt_open(struct bnxt_softc *bp)
+{
+	int rc = 0;
+	if (BNXT_PF(bp))
+		rc = bnxt_hwrm_nvm_get_dev_info(bp, &bp->nvm_info->mfg_id,
+			&bp->nvm_info->device_id, &bp->nvm_info->sector_size,
+			&bp->nvm_info->size, &bp->nvm_info->reserved_size,
+			&bp->nvm_info->available_size);
+
+	/* Get the queue config */
+	rc = bnxt_hwrm_queue_qportcfg(bp, HWRM_QUEUE_QPORTCFG_INPUT_FLAGS_PATH_TX);
+	if (rc) {
+		device_printf(bp->dev, "reinit: hwrm qportcfg (tx) failed\n");
+		return rc;
+	}
+	if (bp->is_asym_q) {
+		rc = bnxt_hwrm_queue_qportcfg(bp,
+					      HWRM_QUEUE_QPORTCFG_INPUT_FLAGS_PATH_RX);
+		if (rc) {
+			device_printf(bp->dev, "re-init: hwrm qportcfg (rx)  failed\n");
+			return rc;
+		}
+		bnxt_verify_asym_queues(bp);
+	} else {
+		bp->rx_max_q = bp->tx_max_q;
+		memcpy(bp->rx_q_info, bp->tx_q_info, sizeof(bp->rx_q_info));
+		memcpy(bp->rx_q_ids, bp->tx_q_ids, sizeof(bp->rx_q_ids));
+	}
+	/* Get the HW capabilities */
+	rc = bnxt_hwrm_func_qcaps(bp);
+	if (rc)
+		return rc;
+
+	/* Register the driver with the FW */
+	rc = bnxt_drv_rgtr(bp);
+	if (rc)
+		return rc;
+	if (bp->hwrm_spec_code >= 0x10803) {
+		rc = bnxt_alloc_ctx_mem(bp);
+		if (rc) {
+			device_printf(bp->dev, "attach: alloc_ctx_mem failed\n");
+			return rc;
+		}
+		rc = bnxt_hwrm_func_resc_qcaps(bp, true);
+		if (!rc)
+			bp->flags |= BNXT_FLAG_FW_CAP_NEW_RM;
+	}
+
+	if (BNXT_CHIP_P5(bp))
+		bnxt_hwrm_reserve_pf_rings(bp);
+	/* Get the current configuration of this function */
+	rc = bnxt_hwrm_func_qcfg(bp);
+	if (rc) {
+		device_printf(bp->dev, "re-init: hwrm func qcfg failed\n");
+		return rc;
+	}
+
+	bnxt_msix_intr_assign(bp->ctx, 0);
+	bnxt_init(bp->ctx);
+	bnxt_intr_enable(bp->ctx);
+
+	if (test_and_clear_bit(BNXT_STATE_FW_RESET_DET, &bp->state)) {
+		if (!test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) {
+			bnxt_ulp_start(bp, 0);
+		}
+	}
+
+	device_printf(bp->dev, "Network interface is UP and operational\n");
+
+	return rc;
+}
+static void bnxt_fw_reset_abort(struct bnxt_softc *bp, int rc)
+{
+	clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state);
+	if (bp->fw_reset_state != BNXT_FW_RESET_STATE_POLL_VF) {
+		bnxt_ulp_start(bp, rc);
+	}
+	bp->fw_reset_state = 0;
+}
+
+static void bnxt_fw_reset_task(struct work_struct *work)
+{
+	struct bnxt_softc *bp = container_of(work, struct bnxt_softc, fw_reset_task.work);
+	int rc = 0;
+
+	if (!test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) {
+		device_printf(bp->dev, "bnxt_fw_reset_task() called when not in fw reset mode!\n");
+		return;
+	}
+
+	switch (bp->fw_reset_state) {
+	case BNXT_FW_RESET_STATE_POLL_FW_DOWN: {
+		u32 val;
+
+		val = bnxt_fw_health_readl(bp, BNXT_FW_HEALTH_REG);
+		if (!(val & BNXT_FW_STATUS_SHUTDOWN) &&
+		    !bnxt_fw_reset_timeout(bp)) {
+			bnxt_queue_fw_reset_work(bp, HZ / 5);
+			return;
+		}
+
+		if (!bp->fw_health->primary) {
+			u32 wait_dsecs = bp->fw_health->normal_func_wait_dsecs;
+
+			bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV;
+			bnxt_queue_fw_reset_work(bp, wait_dsecs * HZ / 10);
+			return;
+		}
+		bp->fw_reset_state = BNXT_FW_RESET_STATE_RESET_FW;
+	}
+		fallthrough;
+	case BNXT_FW_RESET_STATE_RESET_FW:
+		bnxt_reset_all(bp);
+		bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV;
+		bnxt_queue_fw_reset_work(bp, bp->fw_reset_min_dsecs * HZ / 10);
+		return;
+	case BNXT_FW_RESET_STATE_ENABLE_DEV:
+		bnxt_inv_fw_health_reg(bp);
+		if (test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state) &&
+		    !bp->fw_reset_min_dsecs) {
+			u16 val;
+
+			val = pci_read_config(bp->dev, PCI_SUBSYSTEM_ID, 2);
+			if (val == 0xffff) {
+				if (bnxt_fw_reset_timeout(bp)) {
+					device_printf(bp->dev, "Firmware reset aborted, PCI config space invalid\n");
+					rc = -ETIMEDOUT;
+					goto fw_reset_abort;
+				}
+				bnxt_queue_fw_reset_work(bp, HZ / 1000);
+				return;
+			}
+		}
+		clear_bit(BNXT_STATE_FW_FATAL_COND, &bp->state);
+		clear_bit(BNXT_STATE_FW_NON_FATAL_COND, &bp->state);
+		if (!pci_is_enabled(bp->pdev)) {
+			if (pci_enable_device(bp->pdev)) {
+				device_printf(bp->dev, "Cannot re-enable PCI device\n");
+				rc = -ENODEV;
+				goto fw_reset_abort;
+			}
+		}
+		pci_set_master(bp->pdev);
+		bp->fw_reset_state = BNXT_FW_RESET_STATE_POLL_FW;
+		fallthrough;
+	case BNXT_FW_RESET_STATE_POLL_FW:
+		bp->hwrm_cmd_timeo = SHORT_HWRM_CMD_TIMEOUT;
+		rc = bnxt_hwrm_poll(bp);
+		if (rc) {
+			if (bnxt_fw_reset_timeout(bp)) {
+				device_printf(bp->dev, "Firmware reset aborted\n");
+				goto fw_reset_abort_status;
+			}
+			bnxt_queue_fw_reset_work(bp, HZ / 5);
+			return;
+		}
+		bp->hwrm_cmd_timeo = DFLT_HWRM_CMD_TIMEOUT;
+		bp->fw_reset_state = BNXT_FW_RESET_STATE_OPENING;
+		fallthrough;
+	case BNXT_FW_RESET_STATE_OPENING:
+		rc = bnxt_open(bp);
+		if (rc) {
+			device_printf(bp->dev, "bnxt_open() failed during FW reset\n");
+			bnxt_fw_reset_abort(bp, rc);
+			rtnl_unlock();
+			return;
+		}
+
+		if ((bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY) &&
+		    bp->fw_health->enabled) {
+			bp->fw_health->last_fw_reset_cnt =
+				bnxt_fw_health_readl(bp, BNXT_FW_RESET_CNT_REG);
+		}
+		bp->fw_reset_state = 0;
+		smp_mb__before_atomic();
+		clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state);
+		bnxt_ulp_start(bp, 0);
+		clear_bit(BNXT_STATE_FW_ACTIVATE, &bp->state);
+		set_bit(BNXT_STATE_OPEN, &bp->state);
+		rtnl_unlock();
+	}
+	return;
+
+fw_reset_abort_status:
+	if (bp->fw_health->status_reliable ||
+	    (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)) {
+		u32 sts = bnxt_fw_health_readl(bp, BNXT_FW_HEALTH_REG);
+
+		device_printf(bp->dev, "fw_health_status 0x%x\n", sts);
+	}
+fw_reset_abort:
+	rtnl_lock();
+	bnxt_fw_reset_abort(bp, rc);
+	rtnl_unlock();
+}
+
+static void bnxt_force_fw_reset(struct bnxt_softc *bp)
+{
+	struct bnxt_fw_health *fw_health = bp->fw_health;
+	u32 wait_dsecs;
+
+	if (!test_bit(BNXT_STATE_OPEN, &bp->state) ||
+	    test_bit(BNXT_STATE_IN_FW_RESET, &bp->state))
+		return;
+	bnxt_fw_reset_close(bp);
+	wait_dsecs = fw_health->master_func_wait_dsecs;
+	if (fw_health->primary) {
+		if (fw_health->flags & HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FLAGS_CO_CPU)
+			wait_dsecs = 0;
+		bp->fw_reset_state = BNXT_FW_RESET_STATE_RESET_FW;
+	} else {
+		bp->fw_reset_timestamp = jiffies + wait_dsecs * HZ / 10;
+		wait_dsecs = fw_health->normal_func_wait_dsecs;
+		bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV;
+	}
+
+	bp->fw_reset_min_dsecs = fw_health->post_reset_wait_dsecs;
+	bp->fw_reset_max_dsecs = fw_health->post_reset_max_wait_dsecs;
+	bnxt_queue_fw_reset_work(bp, wait_dsecs * HZ / 10);
+}
+
+static void bnxt_fw_exception(struct bnxt_softc *bp)
+{
+	device_printf(bp->dev, "Detected firmware fatal condition, initiating reset\n");
+	set_bit(BNXT_STATE_FW_FATAL_COND, &bp->state);
+	bnxt_rtnl_lock_sp(bp);
+	bnxt_force_fw_reset(bp);
+	bnxt_rtnl_unlock_sp(bp);
+}
+
+static void __bnxt_fw_recover(struct bnxt_softc *bp)
+{
+	if (test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state) ||
+	    test_bit(BNXT_STATE_FW_NON_FATAL_COND, &bp->state))
+		bnxt_fw_reset(bp);
+	else
+		bnxt_fw_exception(bp);
+}
+
+static void bnxt_devlink_health_fw_report(struct bnxt_softc *bp)
+{
+	struct bnxt_fw_health *fw_health = bp->fw_health;
+
+	if (!fw_health)
+		return;
+
+	if (!fw_health->fw_reporter) {
+		__bnxt_fw_recover(bp);
+		return;
+	}
+}
+
+static void bnxt_sp_task(struct work_struct *work)
+{
+	struct bnxt_softc *bp = container_of(work, struct bnxt_softc, sp_task);
+
+	set_bit(BNXT_STATE_IN_SP_TASK, &bp->state);
+	smp_mb__after_atomic();
+	if (!test_bit(BNXT_STATE_OPEN, &bp->state)) {
+		clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state);
+		return;
+	}
 
-		}
+	if (test_and_clear_bit(BNXT_FW_RESET_NOTIFY_SP_EVENT, &bp->sp_event)) {
+		if (test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state) ||
+		    test_bit(BNXT_STATE_FW_NON_FATAL_COND, &bp->state))
+			bnxt_devlink_health_fw_report(bp);
+		else
+			bnxt_fw_reset(bp);
 	}
 
-	return NULL;
+	if (test_and_clear_bit(BNXT_FW_EXCEPTION_SP_EVENT, &bp->sp_event)) {
+		if (!is_bnxt_fw_ok(bp))
+			bnxt_devlink_health_fw_report(bp);
+	}
+	smp_mb__before_atomic();
+	clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state);
 }
 
 /* Device setup and teardown */
@@ -1269,7 +2100,6 @@ bnxt_attach_pre(if_ctx_t ctx)
 		break;
 	}
 
-#define PCI_DEVFN(device, func) ((((device) & 0x1f) << 3) | ((func) & 0x07))
 	softc->domain = pci_get_domain(softc->dev);
 	softc->bus = pci_get_bus(softc->dev);
 	softc->slot = pci_get_slot(softc->dev);
@@ -1284,8 +2114,24 @@ bnxt_attach_pre(if_ctx_t ctx)
 
 	pci_enable_busmaster(softc->dev);
 
-	if (bnxt_pci_mapping(softc))
-		return (ENXIO);
+	if (bnxt_pci_mapping(softc)) {
+		device_printf(softc->dev, "PCI mapping failed\n");
+		rc = ENXIO;
+		goto pci_map_fail;
+	}
+
+	softc->pdev = kzalloc(sizeof(*softc->pdev), GFP_KERNEL);
+	if (!softc->pdev) {
+		device_printf(softc->dev, "pdev alloc failed\n");
+		rc = -ENOMEM;
+		goto free_pci_map;
+	}
+
+	rc = linux_pci_attach_device(softc->dev, NULL, NULL, softc->pdev);
+	if (rc) {
+		device_printf(softc->dev, "Failed to attach Linux PCI device 0x%x\n", rc);
+		goto pci_attach_fail;
+	}
 
 	/* HWRM setup/init */
 	BNXT_HWRM_LOCK_INIT(softc, device_get_nameunit(softc->dev));
@@ -1330,17 +2176,25 @@ bnxt_attach_pre(if_ctx_t ctx)
 
 	softc->flags |= BNXT_FLAG_TPA;
 
-	/* No TPA for Thor A0 */
 	if (BNXT_CHIP_P5(softc) && (!softc->ver_info->chip_rev) &&
 			(!softc->ver_info->chip_metal))
 		softc->flags &= ~BNXT_FLAG_TPA;
 
-	/* TBD ++ Add TPA support from Thor B1 */
 	if (BNXT_CHIP_P5(softc))
 		softc->flags &= ~BNXT_FLAG_TPA;
 
 	/* Get NVRAM info */
 	if (BNXT_PF(softc)) {
+		if (!bnxt_pf_wq) {
+			bnxt_pf_wq =
+				create_singlethread_workqueue("bnxt_pf_wq");
+			if (!bnxt_pf_wq) {
+				device_printf(softc->dev, "Unable to create workqueue.\n");
+				rc = -ENOMEM;
+				goto nvm_alloc_fail;
+			}
+		}
+
 		softc->nvm_info = malloc(sizeof(struct bnxt_nvram_info),
 		    M_DEVBUF, M_NOWAIT | M_ZERO);
 		if (softc->nvm_info == NULL) {
@@ -1369,25 +2223,39 @@ bnxt_attach_pre(if_ctx_t ctx)
 		softc->db_ops.bnxt_db_tx_cq = bnxt_cuw_db_cq;
 	}
 
-	/* Register the driver with the FW */
-	rc = bnxt_hwrm_func_drv_rgtr(softc);
-	if (rc) {
-		device_printf(softc->dev, "attach: hwrm drv rgtr failed\n");
-		goto drv_rgtr_fail;
-	}
-
-        rc = bnxt_hwrm_func_rgtr_async_events(softc, NULL, 0);
-	if (rc) {
-		device_printf(softc->dev, "attach: hwrm rgtr async evts failed\n");
-		goto drv_rgtr_fail;
-	}
 
 	/* Get the queue config */
-	rc = bnxt_hwrm_queue_qportcfg(softc);
+	rc = bnxt_hwrm_queue_qportcfg(softc, HWRM_QUEUE_QPORTCFG_INPUT_FLAGS_PATH_TX);
 	if (rc) {
-		device_printf(softc->dev, "attach: hwrm qportcfg failed\n");
+		device_printf(softc->dev, "attach: hwrm qportcfg (tx) failed\n");
 		goto failed;
 	}
+	if (softc->is_asym_q) {
+		rc = bnxt_hwrm_queue_qportcfg(softc,
+					      HWRM_QUEUE_QPORTCFG_INPUT_FLAGS_PATH_RX);
+		if (rc) {
+			device_printf(softc->dev, "attach: hwrm qportcfg (rx)  failed\n");
+			return rc;
+		}
+		bnxt_verify_asym_queues(softc);
+	} else {
+		softc->rx_max_q = softc->tx_max_q;
+		memcpy(softc->rx_q_info, softc->tx_q_info, sizeof(softc->rx_q_info));
+		memcpy(softc->rx_q_ids, softc->tx_q_ids, sizeof(softc->rx_q_ids));
+	}
+
+	/* Get the HW capabilities */
+	rc = bnxt_hwrm_func_qcaps(softc);
+	if (rc)
+		goto failed;
+
+	/*
+	 * Register the driver with the FW
+	 * Register the async events with the FW
+	 */
+	rc = bnxt_drv_rgtr(softc);
+	if (rc)
+		goto failed;
 
 	if (softc->hwrm_spec_code >= 0x10803) {
 		rc = bnxt_alloc_ctx_mem(softc);
@@ -1400,11 +2268,6 @@ bnxt_attach_pre(if_ctx_t ctx)
 			softc->flags |= BNXT_FLAG_FW_CAP_NEW_RM;
 	}
 
-	/* Get the HW capabilities */
-	rc = bnxt_hwrm_func_qcaps(softc);
-	if (rc)
-		goto failed;
-
 	/* Get the current configuration of this function */
 	rc = bnxt_hwrm_func_qcfg(softc);
 	if (rc) {
@@ -1550,6 +2413,14 @@ bnxt_attach_pre(if_ctx_t ctx)
 	if (rc)
 		goto failed;
 
+	rc = bnxt_create_dcb_sysctls(softc);
+	if (rc)
+		goto failed;
+
+	set_bit(BNXT_STATE_OPEN, &softc->state);
+	INIT_WORK(&softc->sp_task, bnxt_sp_task);
+	INIT_DELAYED_WORK(&softc->fw_reset_task, bnxt_fw_reset_task);
+
 	/* Initialize the vlan list */
 	SLIST_INIT(&softc->vnic_info.vlan_tags);
 	softc->vnic_info.vlan_tag_list.idi_vaddr = NULL;
@@ -1562,7 +2433,6 @@ bnxt_attach_pre(if_ctx_t ctx)
 	bnxt_free_sysctl_ctx(softc);
 init_sysctl_failed:
 	bnxt_hwrm_func_drv_unrgtr(softc, false);
-drv_rgtr_fail:
 	if (BNXT_PF(softc))
 		free(softc->nvm_info, M_DEVBUF);
 nvm_alloc_fail:
@@ -1574,7 +2444,14 @@ bnxt_attach_pre(if_ctx_t ctx)
 	bnxt_free_hwrm_dma_mem(softc);
 dma_fail:
 	BNXT_HWRM_LOCK_DESTROY(softc);
+	if (softc->pdev)
+		linux_pci_detach_device(softc->pdev);
+pci_attach_fail:
+	kfree(softc->pdev);
+	softc->pdev = NULL;
+free_pci_map:
 	bnxt_pci_mapping_free(softc);
+pci_map_fail:
 	pci_disable_busmaster(softc->dev);
 	return (rc);
 }
@@ -1586,6 +2463,7 @@ bnxt_attach_post(if_ctx_t ctx)
 	if_t ifp = iflib_get_ifp(ctx);
 	int rc;
 
+	softc->ifp = ifp;
 	bnxt_create_config_sysctls_post(softc);
 
 	/* Update link state etc... */
@@ -1595,6 +2473,7 @@ bnxt_attach_post(if_ctx_t ctx)
 
 	/* Needs to be done after probing the phy */
 	bnxt_create_ver_sysctls(softc);
+	ifmedia_removeall(softc->media);
 	bnxt_add_media_types(softc);
 	ifmedia_set(softc->media, IFM_ETHER | IFM_AUTO);
 
@@ -1602,6 +2481,8 @@ bnxt_attach_post(if_ctx_t ctx)
 	    ETHER_CRC_LEN;
 
 	softc->rx_buf_size = min(softc->scctx->isc_max_frame_size, BNXT_PAGE_SIZE);
+	bnxt_dcb_init(softc);
+	bnxt_rdma_aux_device_init(softc);
 
 failed:
 	return rc;
@@ -1615,6 +2496,10 @@ bnxt_detach(if_ctx_t ctx)
 	struct bnxt_vlan_tag *tmp;
 	int i;
 
+	bnxt_rdma_aux_device_uninit(softc);
+	cancel_delayed_work_sync(&softc->fw_reset_task);
+	cancel_work_sync(&softc->sp_task);
+	bnxt_dcb_free(softc);
 	SLIST_REMOVE(&pf_list, &softc->list, bnxt_softc_list, next);
 	bnxt_num_pfs--;
 	bnxt_wol_config(ctx);
@@ -1652,6 +2537,11 @@ bnxt_detach(if_ctx_t ctx)
 	bnxt_free_hwrm_short_cmd_req(softc);
 	BNXT_HWRM_LOCK_DESTROY(softc);
 
+	if (!bnxt_num_pfs && bnxt_pf_wq)
+		destroy_workqueue(bnxt_pf_wq);
+
+	if (softc->pdev)
+		linux_pci_detach_device(softc->pdev);
 	free(softc->state_bv, M_DEVBUF);
 	pci_disable_busmaster(softc->dev);
 	bnxt_pci_mapping_free(softc);
@@ -1778,6 +2668,104 @@ bnxt_rss_grp_tbl_init(struct bnxt_softc *softc)
 	}
 }
 
+static void bnxt_get_port_module_status(struct bnxt_softc *softc)
+{
+	struct bnxt_link_info *link_info = &softc->link_info;
+	struct hwrm_port_phy_qcfg_output *resp = &link_info->phy_qcfg_resp;
+	uint8_t module_status;
+
+	if (bnxt_update_link(softc, false))
+		return;
+
+	module_status = link_info->module_status;
+	switch (module_status) {
+	case HWRM_PORT_PHY_QCFG_OUTPUT_MODULE_STATUS_DISABLETX:
+	case HWRM_PORT_PHY_QCFG_OUTPUT_MODULE_STATUS_PWRDOWN:
+	case HWRM_PORT_PHY_QCFG_OUTPUT_MODULE_STATUS_WARNINGMSG:
+		device_printf(softc->dev, "Unqualified SFP+ module detected on port %d\n",
+			    softc->pf.port_id);
+		if (softc->hwrm_spec_code >= 0x10201) {
+			device_printf(softc->dev, "Module part number %s\n",
+				    resp->phy_vendor_partnumber);
+		}
+		if (module_status == HWRM_PORT_PHY_QCFG_OUTPUT_MODULE_STATUS_DISABLETX)
+			device_printf(softc->dev, "TX is disabled\n");
+		if (module_status == HWRM_PORT_PHY_QCFG_OUTPUT_MODULE_STATUS_PWRDOWN)
+			device_printf(softc->dev, "SFP+ module is shutdown\n");
+	}
+}
+
+static void bnxt_aux_dev_free(struct bnxt_softc *softc)
+{
+	kfree(softc->aux_dev);
+	softc->aux_dev = NULL;
+}
+
+static struct bnxt_aux_dev *bnxt_aux_dev_init(struct bnxt_softc *softc)
+{
+	struct bnxt_aux_dev *bnxt_adev;
+
+	msleep(1000 * 2);
+	bnxt_adev = kzalloc(sizeof(*bnxt_adev), GFP_KERNEL);
+	if (!bnxt_adev)
+		return ERR_PTR(-ENOMEM);
+
+	return bnxt_adev;
+}
+
+static void bnxt_rdma_aux_device_uninit(struct bnxt_softc *softc)
+{
+	struct bnxt_aux_dev *bnxt_adev = softc->aux_dev;
+
+	/* Skip if no auxiliary device init was done. */
+	if (!(softc->flags & BNXT_FLAG_ROCE_CAP))
+		return;
+
+	if (IS_ERR_OR_NULL(bnxt_adev))
+		return;
+
+	bnxt_rdma_aux_device_del(softc);
+
+	if (bnxt_adev->id >= 0)
+		ida_free(&bnxt_aux_dev_ids, bnxt_adev->id);
+
+	bnxt_aux_dev_free(softc);
+}
+
+static void bnxt_rdma_aux_device_init(struct bnxt_softc *softc)
+{
+	int rc;
+
+	if (!(softc->flags & BNXT_FLAG_ROCE_CAP))
+		return;
+
+	softc->aux_dev = bnxt_aux_dev_init(softc);
+	if (IS_ERR_OR_NULL(softc->aux_dev)) {
+		device_printf(softc->dev, "Failed to init auxiliary device for ROCE\n");
+		goto skip_aux_init;
+	}
+
+	softc->aux_dev->id = ida_alloc(&bnxt_aux_dev_ids, GFP_KERNEL);
+	if (softc->aux_dev->id < 0) {
+		device_printf(softc->dev, "ida alloc failed for ROCE auxiliary device\n");
+		bnxt_aux_dev_free(softc);
+		goto skip_aux_init;
+	}
+
+	msleep(1000 * 2);
+	/* If aux bus init fails, continue with netdev init. */
+	rc = bnxt_rdma_aux_device_add(softc);
+	if (rc) {
+		device_printf(softc->dev, "Failed to add auxiliary device for ROCE\n");
+		msleep(1000 * 2);
+		ida_free(&bnxt_aux_dev_ids, softc->aux_dev->id);
+	}
+	device_printf(softc->dev, "%s:%d Added auxiliary device (id %d) for ROCE \n",
+		      __func__, __LINE__, softc->aux_dev->id);
+skip_aux_init:
+	return;
+}
+
 /* Device configuration */
 static void
 bnxt_init(if_ctx_t ctx)
@@ -1798,7 +2786,6 @@ bnxt_init(if_ctx_t ctx)
 	softc->is_dev_init = true;
 	bnxt_clear_ids(softc);
 
-	// TBD -- Check if it is needed for Thor as well
 	if (BNXT_CHIP_P5(softc))
 		goto skip_def_cp_ring;
 	/* Allocate the default completion ring */
@@ -1940,6 +2927,7 @@ bnxt_init(if_ctx_t ctx)
 	}
 
 	bnxt_do_enable_intr(&softc->def_cp_ring);
+	bnxt_get_port_module_status(softc);
 	bnxt_media_status(softc->ctx, &ifmr);
 	bnxt_hwrm_cfa_l2_set_rx_mask(softc, &softc->vnic_info);
 	return;
@@ -2074,6 +3062,9 @@ bnxt_media_change(if_ctx_t ctx)
 	if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER)
 		return EINVAL;
 
+	softc->link_info.req_signal_mode =
+			HWRM_PORT_PHY_QCFG_OUTPUT_SIGNAL_MODE_PAM4;
+
 	switch (IFM_SUBTYPE(ifm->ifm_media)) {
 	case IFM_100_T:
 		softc->link_info.autoneg &= ~BNXT_AUTONEG_SPEED;
@@ -2081,8 +3072,10 @@ bnxt_media_change(if_ctx_t ctx)
 		    HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_100MB;
 		break;
 	case IFM_1000_KX:
-	case IFM_1000_T:
 	case IFM_1000_SGMII:
+	case IFM_1000_CX:
+	case IFM_1000_SX:
+	case IFM_1000_LX:
 		softc->link_info.autoneg &= ~BNXT_AUTONEG_SPEED;
 		softc->link_info.req_link_speed =
 		    HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_1GB;
@@ -2097,7 +3090,6 @@ bnxt_media_change(if_ctx_t ctx)
 	case IFM_10G_KR:
 	case IFM_10G_LR:
 	case IFM_10G_SR:
-	case IFM_10G_T:
 		softc->link_info.autoneg &= ~BNXT_AUTONEG_SPEED;
 		softc->link_info.req_link_speed =
 		    HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_10GB;
@@ -2118,16 +3110,30 @@ bnxt_media_change(if_ctx_t ctx)
 	case IFM_40G_KR4:
 	case IFM_40G_LR4:
 	case IFM_40G_SR4:
+	case IFM_40G_XLAUI:
+	case IFM_40G_XLAUI_AC:
 		softc->link_info.autoneg &= ~BNXT_AUTONEG_SPEED;
 		softc->link_info.req_link_speed =
 		    HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_40GB;
 		break;
 	case IFM_50G_CR2:
 	case IFM_50G_KR2:
+	case IFM_50G_SR2:
 		softc->link_info.autoneg &= ~BNXT_AUTONEG_SPEED;
 		softc->link_info.req_link_speed =
 		    HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_50GB;
 		break;
+	case IFM_50G_CP:
+	case IFM_50G_LR:
+	case IFM_50G_SR:
+	case IFM_50G_KR_PAM4:
+		softc->link_info.autoneg &= ~BNXT_AUTONEG_SPEED;
+		softc->link_info.req_link_speed =
+		    HWRM_PORT_PHY_CFG_INPUT_FORCE_PAM4_LINK_SPEED_50GB;
+		softc->link_info.req_signal_mode =
+			HWRM_PORT_PHY_QCFG_OUTPUT_SIGNAL_MODE_PAM4;
+		softc->link_info.force_pam4_speed_set_by_user = true;
+		break;
 	case IFM_100G_CR4:
 	case IFM_100G_KR4:
 	case IFM_100G_LR4:
@@ -2136,6 +3142,38 @@ bnxt_media_change(if_ctx_t ctx)
 		softc->link_info.req_link_speed =
 			HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_100GB;
 		break;
+	case IFM_100G_CP2:
+	case IFM_100G_SR2:
+	case IFM_100G_KR_PAM4:
+	case IFM_100G_KR2_PAM4:
+		softc->link_info.autoneg &= ~BNXT_AUTONEG_SPEED;
+		softc->link_info.req_link_speed =
+			HWRM_PORT_PHY_CFG_INPUT_FORCE_PAM4_LINK_SPEED_100GB;
+		softc->link_info.req_signal_mode =
+			HWRM_PORT_PHY_QCFG_OUTPUT_SIGNAL_MODE_PAM4;
+		softc->link_info.force_pam4_speed_set_by_user = true;
+		break;
+	case IFM_200G_SR4:
+	case IFM_200G_FR4:
+	case IFM_200G_LR4:
+	case IFM_200G_DR4:
+	case IFM_200G_CR4_PAM4:
+	case IFM_200G_KR4_PAM4:
+		softc->link_info.autoneg &= ~BNXT_AUTONEG_SPEED;
+		softc->link_info.req_link_speed =
+			HWRM_PORT_PHY_CFG_INPUT_FORCE_PAM4_LINK_SPEED_200GB;
+		softc->link_info.force_pam4_speed_set_by_user = true;
+		softc->link_info.req_signal_mode =
+			HWRM_PORT_PHY_QCFG_OUTPUT_SIGNAL_MODE_PAM4;
+		break;
+	case IFM_1000_T:
+		softc->link_info.advertising = HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_1GB;
+		softc->link_info.autoneg |= BNXT_AUTONEG_SPEED;
+		break;
+	case IFM_10G_T:
+		softc->link_info.advertising = HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_10GB;
+		softc->link_info.autoneg |= BNXT_AUTONEG_SPEED;
+		break;
 	default:
 		device_printf(softc->dev,
 		    "Unsupported media type!  Using auto\n");
@@ -2203,6 +3241,10 @@ bnxt_update_admin_status(if_ctx_t ctx)
 
 	bnxt_hwrm_port_qstats(softc);
 
+	if (BNXT_CHIP_P5(softc) &&
+	    (softc->flags & BNXT_FLAG_FW_CAP_EXT_STATS))
+		bnxt_hwrm_port_qstats_ext(softc);
+
 	if (BNXT_CHIP_P5(softc)) {
 		struct ifmediareq ifmr;
 
@@ -2318,7 +3360,7 @@ bnxt_process_async_msg(struct bnxt_cp_ring *cpr, tx_cmpl_t *cmpl)
 	}
 }
 
-static void
+void
 process_nq(struct bnxt_softc *softc, uint16_t nqid)
 {
 	struct bnxt_cp_ring *cpr = &softc->nq_rings[nqid];
@@ -2836,6 +3878,33 @@ bnxt_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t data)
 	return rc;
 }
 
+static int
+bnxt_i2c_req(if_ctx_t ctx, struct ifi2creq *i2c)
+{
+	struct bnxt_softc *softc = iflib_get_softc(ctx);
+	uint8_t *data = i2c->data;
+	int rc;
+
+	/* No point in going further if phy status indicates
+	 * module is not inserted or if it is powered down or
+	 * if it is of type 10GBase-T
+	 */
+	if (softc->link_info.module_status >
+		HWRM_PORT_PHY_QCFG_OUTPUT_MODULE_STATUS_WARNINGMSG)
+		return -EOPNOTSUPP;
+
+	/* This feature is not supported in older firmware versions */
+	if (!BNXT_CHIP_P5(softc) ||
+	    (softc->hwrm_spec_code < 0x10202))
+		return -EOPNOTSUPP;
+
+
+	rc = bnxt_read_sfp_module_eeprom_info(softc, I2C_DEV_ADDR_A0, 0, 0, 0,
+		i2c->offset, i2c->len, data);
+
+	return rc;
+}
+
 /*
  * Support functions
  */
@@ -2845,6 +3914,14 @@ bnxt_probe_phy(struct bnxt_softc *softc)
 	struct bnxt_link_info *link_info = &softc->link_info;
 	int rc = 0;
 
+	softc->phy_flags = 0;
+	rc = bnxt_hwrm_phy_qcaps(softc);
+	if (rc) {
+		device_printf(softc->dev,
+			      "Probe phy can't get phy capabilities (rc: %x)\n", rc);
+		return rc;
+	}
+
 	rc = bnxt_update_link(softc, false);
 	if (rc) {
 		device_printf(softc->dev,
@@ -2852,26 +3929,100 @@ bnxt_probe_phy(struct bnxt_softc *softc)
 		return (rc);
 	}
 
+	bnxt_get_port_module_status(softc);
+
 	/*initialize the ethool setting copy with NVM settings */
 	if (link_info->auto_mode != HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_MODE_NONE)
 		link_info->autoneg |= BNXT_AUTONEG_SPEED;
 
 	link_info->req_duplex = link_info->duplex_setting;
+
+	/* NRZ link speed */
 	if (link_info->autoneg & BNXT_AUTONEG_SPEED)
-		link_info->req_link_speed = link_info->auto_link_speed;
+		link_info->req_link_speed = link_info->auto_link_speeds;
 	else
 		link_info->req_link_speed = link_info->force_link_speed;
+
+	/* PAM4 link speed */
+	if (link_info->auto_pam4_link_speeds)
+		link_info->req_link_speed = link_info->auto_pam4_link_speeds;
+	if (link_info->force_pam4_link_speed)
+		link_info->req_link_speed = link_info->force_pam4_link_speed;
+
 	return (rc);
 }
 
+static void
+add_media(struct bnxt_softc *softc, uint8_t media_type, uint16_t supported,
+	  uint16_t supported_pam4)
+{
+	switch (media_type) {
+		case BNXT_MEDIA_CR:
+			BNXT_IFMEDIA_ADD(supported_pam4, PAM4_SPEEDS_50G, IFM_50G_CP);
+			BNXT_IFMEDIA_ADD(supported_pam4, PAM4_SPEEDS_100G, IFM_100G_CP2);
+			BNXT_IFMEDIA_ADD(supported_pam4, PAM4_SPEEDS_200G, IFM_200G_CR4_PAM4);
+			BNXT_IFMEDIA_ADD(supported, SPEEDS_100GB, IFM_100G_CR4);
+			BNXT_IFMEDIA_ADD(supported, SPEEDS_50GB, IFM_50G_CR2);
+			BNXT_IFMEDIA_ADD(supported, SPEEDS_40GB, IFM_40G_CR4);
+			BNXT_IFMEDIA_ADD(supported, SPEEDS_25GB, IFM_25G_CR);
+			BNXT_IFMEDIA_ADD(supported, SPEEDS_10GB, IFM_10G_CR1);
+			BNXT_IFMEDIA_ADD(supported, SPEEDS_1GB, IFM_1000_CX);
+			break;
+
+		case BNXT_MEDIA_LR:
+			BNXT_IFMEDIA_ADD(supported_pam4, PAM4_SPEEDS_50G, IFM_50G_LR);
+			BNXT_IFMEDIA_ADD(supported_pam4, PAM4_SPEEDS_200G, IFM_200G_LR4);
+			BNXT_IFMEDIA_ADD(supported, SPEEDS_100GB, IFM_100G_LR4);
+			BNXT_IFMEDIA_ADD(supported, SPEEDS_50GB, IFM_50G_LR2);
+			BNXT_IFMEDIA_ADD(supported, SPEEDS_40GB, IFM_40G_LR4);
+			BNXT_IFMEDIA_ADD(supported, SPEEDS_25GB, IFM_25G_LR);
+			BNXT_IFMEDIA_ADD(supported, SPEEDS_10GB, IFM_10G_LR);
+			BNXT_IFMEDIA_ADD(supported, SPEEDS_1GB, IFM_1000_LX);
+			break;
+
+		case BNXT_MEDIA_SR:
+			BNXT_IFMEDIA_ADD(supported_pam4, PAM4_SPEEDS_50G, IFM_50G_SR);
+			BNXT_IFMEDIA_ADD(supported_pam4, PAM4_SPEEDS_100G, IFM_100G_SR2);
+			BNXT_IFMEDIA_ADD(supported_pam4, PAM4_SPEEDS_200G, IFM_200G_SR4);
+			BNXT_IFMEDIA_ADD(supported, SPEEDS_100GB, IFM_100G_SR4);
+			BNXT_IFMEDIA_ADD(supported, SPEEDS_50GB, IFM_50G_SR2);
+			BNXT_IFMEDIA_ADD(supported, SPEEDS_40GB, IFM_40G_SR4);
+			BNXT_IFMEDIA_ADD(supported, SPEEDS_25GB, IFM_25G_SR);
+			BNXT_IFMEDIA_ADD(supported, SPEEDS_10GB, IFM_10G_SR);
+			BNXT_IFMEDIA_ADD(supported, SPEEDS_1GB, IFM_1000_SX);
+			break;
+
+		case BNXT_MEDIA_KR:
+			BNXT_IFMEDIA_ADD(supported_pam4, PAM4_SPEEDS_50G, IFM_50G_KR_PAM4);
+			BNXT_IFMEDIA_ADD(supported_pam4, PAM4_SPEEDS_100G, IFM_100G_KR2_PAM4);
+			BNXT_IFMEDIA_ADD(supported_pam4, PAM4_SPEEDS_200G, IFM_200G_KR4_PAM4);
+			BNXT_IFMEDIA_ADD(supported, SPEEDS_100GB, IFM_100G_KR4);
+			BNXT_IFMEDIA_ADD(supported, SPEEDS_50GB, IFM_50G_KR2);
+			BNXT_IFMEDIA_ADD(supported, SPEEDS_50GB, IFM_50G_KR4);
+			BNXT_IFMEDIA_ADD(supported, SPEEDS_40GB, IFM_40G_KR4);
+			BNXT_IFMEDIA_ADD(supported, SPEEDS_25GB, IFM_25G_KR);
+			BNXT_IFMEDIA_ADD(supported, SPEEDS_20GB, IFM_20G_KR2);
+			BNXT_IFMEDIA_ADD(supported, SPEEDS_10GB, IFM_10G_KR);
+			BNXT_IFMEDIA_ADD(supported, SPEEDS_1GB, IFM_1000_KX);
+			break;
+
+		default:
+			break;
+
+	}
+	return;
+
+}
+
 static void
 bnxt_add_media_types(struct bnxt_softc *softc)
 {
 	struct bnxt_link_info *link_info = &softc->link_info;
-	uint16_t supported;
-	uint8_t phy_type = get_phy_type(softc);
+	uint16_t supported = 0, supported_pam4 = 0;
+	uint8_t phy_type = get_phy_type(softc), media_type;
 
 	supported = link_info->support_speeds;
+	supported_pam4 = link_info->support_pam4_speeds;
 
 	/* Auto is always supported */
 	ifmedia_add(softc->media, IFM_ETHER | IFM_AUTO, 0, NULL);
@@ -2880,65 +4031,56 @@ bnxt_add_media_types(struct bnxt_softc *softc)
 		return;
 
 	switch (phy_type) {
+	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_200G_BASECR4:
 	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_100G_BASECR4:
+	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_100G_BASECR2:
+	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_50G_BASECR:
 	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_40G_BASECR4:
 	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_25G_BASECR_CA_L:
 	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_25G_BASECR_CA_S:
 	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_25G_BASECR_CA_N:
 	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASECR:
-		BNXT_IFMEDIA_ADD(supported, SPEEDS_100GB, IFM_100G_CR4);
-		BNXT_IFMEDIA_ADD(supported, SPEEDS_50GB, IFM_50G_CR2);
-		BNXT_IFMEDIA_ADD(supported, SPEEDS_40GB, IFM_40G_CR4);
-		BNXT_IFMEDIA_ADD(supported, SPEEDS_25GB, IFM_25G_CR);
-		BNXT_IFMEDIA_ADD(supported, SPEEDS_10GB, IFM_10G_CR1);
-		BNXT_IFMEDIA_ADD(supported, SPEEDS_1GB, IFM_1000_T);
+		media_type = BNXT_MEDIA_CR;
 		break;
 
+	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_200G_BASELR4:
 	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_100G_BASELR4:
+	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_50G_BASELR:
 	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_40G_BASELR4:
 	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASELR:
-		BNXT_IFMEDIA_ADD(supported, SPEEDS_100GB, IFM_100G_LR4);
-		BNXT_IFMEDIA_ADD(supported, SPEEDS_40GB, IFM_40G_LR4);
-		BNXT_IFMEDIA_ADD(supported, SPEEDS_25GB, IFM_25G_LR);
-		BNXT_IFMEDIA_ADD(supported, SPEEDS_10GB, IFM_10G_LR);
-		BNXT_IFMEDIA_ADD(supported, SPEEDS_1GB, IFM_1000_LX);
+		media_type = BNXT_MEDIA_LR;
 		break;
 
+	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_200G_BASESR4:
 	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_100G_BASESR10:
 	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_100G_BASESR4:
+	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_50G_BASESR:
 	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_40G_BASESR4:
 	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASESR:
 	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_40G_BASEER4:
 	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_100G_BASEER4:
+	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_200G_BASEER4:
 	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_25G_BASESR:
 	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_1G_BASESX:
-		BNXT_IFMEDIA_ADD(supported, SPEEDS_100GB, IFM_100G_SR4);
-		BNXT_IFMEDIA_ADD(supported, SPEEDS_40GB, IFM_40G_SR4);
-		BNXT_IFMEDIA_ADD(supported, SPEEDS_25GB, IFM_25G_SR);
-		BNXT_IFMEDIA_ADD(supported, SPEEDS_10GB, IFM_10G_SR);
-		BNXT_IFMEDIA_ADD(supported, SPEEDS_1GB, IFM_1000_SX);
+		media_type = BNXT_MEDIA_SR;
 		break;
 
 	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR4:
 	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR2:
 	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR:
-		BNXT_IFMEDIA_ADD(supported, SPEEDS_100GB, IFM_100G_KR4);
-		BNXT_IFMEDIA_ADD(supported, SPEEDS_50GB, IFM_50G_KR2);
-		BNXT_IFMEDIA_ADD(supported, SPEEDS_40GB, IFM_40G_KR4);
-		BNXT_IFMEDIA_ADD(supported, SPEEDS_25GB, IFM_25G_KR);
-		BNXT_IFMEDIA_ADD(supported, SPEEDS_20GB, IFM_20G_KR2);
-		BNXT_IFMEDIA_ADD(supported, SPEEDS_10GB, IFM_10G_KR);
-		BNXT_IFMEDIA_ADD(supported, SPEEDS_1GB, IFM_1000_KX);
+		media_type = BNXT_MEDIA_KR;
 		break;
 
 	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_40G_ACTIVE_CABLE:
 		BNXT_IFMEDIA_ADD(supported, SPEEDS_25GB, IFM_25G_ACC);
 		BNXT_IFMEDIA_ADD(supported, SPEEDS_10GB, IFM_10G_AOC);
-		break;
+		BNXT_IFMEDIA_ADD(supported, SPEEDS_40GB, IFM_40G_XLAUI);
+		BNXT_IFMEDIA_ADD(supported, SPEEDS_40GB, IFM_40G_XLAUI_AC);
+		return;
 
 	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_1G_BASECX:
 		BNXT_IFMEDIA_ADD(supported, SPEEDS_1GBHD, IFM_1000_CX);
-		break;
+		return;
 
 	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_1G_BASET:
 	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASET:
@@ -2948,27 +4090,39 @@ bnxt_add_media_types(struct bnxt_softc *softc)
 		BNXT_IFMEDIA_ADD(supported, SPEEDS_1GB, IFM_1000_T);
 		BNXT_IFMEDIA_ADD(supported, SPEEDS_100MB, IFM_100_T);
 		BNXT_IFMEDIA_ADD(supported, SPEEDS_10MB, IFM_10_T);
-		break;
+		return;
 
 	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKX:
 		BNXT_IFMEDIA_ADD(supported, SPEEDS_10GB, IFM_10G_KR);
 		BNXT_IFMEDIA_ADD(supported, SPEEDS_2_5GB, IFM_2500_KX);
 		BNXT_IFMEDIA_ADD(supported, SPEEDS_1GB, IFM_1000_KX);
-		break;
+		return;
 
 	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_SGMIIEXTPHY:
 		BNXT_IFMEDIA_ADD(supported, SPEEDS_1GB, IFM_1000_SGMII);
-		break;
+		return;
 
 	case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_UNKNOWN:
 		/* Only Autoneg is supported for TYPE_UNKNOWN */
-		device_printf(softc->dev, "Unknown phy type\n");
-		break;
+		return;
 
         default:
 		/* Only Autoneg is supported for new phy type values */
 		device_printf(softc->dev, "phy type %d not supported by driver\n", phy_type);
-		break;
+		return;
+	}
+
+	/* add_media is invoked twice, once with a firmware speed mask of 0 and a valid
+	 * value for both NRZ and PAM4 sig mode. This ensures accurate display of all
+	 * supported medias and currently configured media in the "ifconfig -m" output
+	 */
+
+	if (link_info->sig_mode == BNXT_SIG_MODE_PAM4) {
+		add_media(softc, media_type, supported, 0);
+		add_media(softc, media_type, 0, supported_pam4);
+	} else {
+		add_media(softc, media_type, 0, supported_pam4);
+		add_media(softc, media_type, supported, 0);
 	}
 
 	return;
@@ -3062,16 +4216,57 @@ bnxt_update_link(struct bnxt_softc *softc, bool chng_link_state)
 	return rc;
 }
 
+#define ETHTOOL_SPEED_1000		1000
+#define ETHTOOL_SPEED_10000		10000
+#define ETHTOOL_SPEED_20000		20000
+#define ETHTOOL_SPEED_25000		25000
+#define ETHTOOL_SPEED_40000		40000
+#define ETHTOOL_SPEED_50000		50000
+#define ETHTOOL_SPEED_100000		100000
+#define ETHTOOL_SPEED_200000		200000
+#define ETHTOOL_SPEED_UNKNOWN		-1
+
+static u32
+bnxt_fw_to_ethtool_speed(u16 fw_link_speed)
+{
+	switch (fw_link_speed) {
+	case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_1GB:
+		return ETHTOOL_SPEED_1000;
+	case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_10GB:
+		return ETHTOOL_SPEED_10000;
+	case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_20GB:
+		return ETHTOOL_SPEED_20000;
+	case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_25GB:
+		return ETHTOOL_SPEED_25000;
+	case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_40GB:
+		return ETHTOOL_SPEED_40000;
+	case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_50GB:
+		return ETHTOOL_SPEED_50000;
+	case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_100GB:
+		return ETHTOOL_SPEED_100000;
+	case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_200GB:
+		return ETHTOOL_SPEED_200000;
+	default:
+		return ETHTOOL_SPEED_UNKNOWN;
+	}
+}
+
 void
 bnxt_report_link(struct bnxt_softc *softc)
 {
 	struct bnxt_link_info *link_info = &softc->link_info;
 	const char *duplex = NULL, *flow_ctrl = NULL;
+	const char *signal_mode = "";
+
+	if(softc->edev)
+		softc->edev->espeed =
+		    bnxt_fw_to_ethtool_speed(link_info->link_speed);
 
 	if (link_info->link_up == link_info->last_link_up) {
 		if (!link_info->link_up)
 			return;
 		if ((link_info->duplex == link_info->last_duplex) &&
+		    (link_info->phy_type == link_info->last_phy_type) &&
                     (!(BNXT_IS_FLOW_CTRL_CHANGED(link_info))))
 			return;
 	}
@@ -3090,9 +4285,27 @@ bnxt_report_link(struct bnxt_softc *softc)
 			flow_ctrl = "FC - receive";
 		else
 			flow_ctrl = "FC - none";
+
+		if (softc->link_info.phy_qcfg_resp.option_flags &
+		    HWRM_PORT_PHY_QCFG_OUTPUT_OPTION_FLAGS_SIGNAL_MODE_KNOWN) {
+			uint8_t sig_mode = softc->link_info.active_fec_sig_mode &
+				      HWRM_PORT_PHY_QCFG_OUTPUT_SIGNAL_MODE_MASK;
+			switch (sig_mode) {
+			case BNXT_SIG_MODE_NRZ:
+				signal_mode = "(NRZ) ";
+				break;
+			case BNXT_SIG_MODE_PAM4:
+				signal_mode = "(PAM4) ";
+				break;
+			default:
+				break;
+			}
+		link_info->sig_mode = sig_mode;
+		}
+
 		iflib_link_state_change(softc->ctx, LINK_STATE_UP,
 		    IF_Gbps(100));
-		device_printf(softc->dev, "Link is UP %s, %s - %d Mbps \n", duplex,
+		device_printf(softc->dev, "Link is UP %s %s, %s - %d Mbps \n", duplex, signal_mode,
 		    flow_ctrl, (link_info->link_speed * 100));
 	} else {
 		iflib_link_state_change(softc->ctx, LINK_STATE_DOWN,
@@ -3102,6 +4315,7 @@ bnxt_report_link(struct bnxt_softc *softc)
 
 	link_info->last_link_up = link_info->link_up;
 	link_info->last_duplex = link_info->duplex;
+	link_info->last_phy_type = link_info->phy_type;
 	link_info->last_flow_ctrl.tx = link_info->flow_ctrl.tx;
 	link_info->last_flow_ctrl.rx = link_info->flow_ctrl.rx;
 	link_info->last_flow_ctrl.autoneg = link_info->flow_ctrl.autoneg;
@@ -3180,12 +4394,99 @@ bnxt_mark_cpr_invalid(struct bnxt_cp_ring *cpr)
 		cmp[i].info3_v = !cpr->v_bit;
 }
 
+static void bnxt_event_error_report(struct bnxt_softc *softc, u32 data1, u32 data2)
+{
+	u32 err_type = BNXT_EVENT_ERROR_REPORT_TYPE(data1);
+
+	switch (err_type) {
+	case HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_INVALID_SIGNAL:
+		device_printf(softc->dev,
+			      "1PPS: Received invalid signal on pin%u from the external source. Please fix the signal and reconfigure the pin\n",
+			      BNXT_EVENT_INVALID_SIGNAL_DATA(data2));
+		break;
+	case HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_PAUSE_STORM:
+		device_printf(softc->dev,
+			      "Pause Storm detected!\n");
+		break;
+	case HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_DOORBELL_DROP_THRESHOLD:
+		device_printf(softc->dev,
+			      "One or more MMIO doorbells dropped by the device! epoch: 0x%x\n",
+			      BNXT_EVENT_DBR_EPOCH(data1));
+		break;
+	case HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_NVM: {
+		const char *nvm_err_str;
+
+		if (EVENT_DATA1_NVM_ERR_TYPE_WRITE(data1))
+			nvm_err_str = "nvm write error";
+		else if (EVENT_DATA1_NVM_ERR_TYPE_ERASE(data1))
+			nvm_err_str = "nvm erase error";
+		else
+			nvm_err_str = "unrecognized nvm error";
+
+		device_printf(softc->dev,
+			      "%s reported at address 0x%x\n", nvm_err_str,
+			      (u32)EVENT_DATA2_NVM_ERR_ADDR(data2));
+		break;
+	}
+	case HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_THERMAL_THRESHOLD: {
+		char *threshold_type;
+		char *dir_str;
+
+		switch (EVENT_DATA1_THERMAL_THRESHOLD_TYPE(data1)) {
+		case HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_THRESHOLD_TYPE_WARN:
+			threshold_type = "warning";
+			break;
+		case HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_THRESHOLD_TYPE_CRITICAL:
+			threshold_type = "critical";
+			break;
+		case HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_THRESHOLD_TYPE_FATAL:
+			threshold_type = "fatal";
+			break;
+		case HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_THRESHOLD_TYPE_SHUTDOWN:
+			threshold_type = "shutdown";
+			break;
+		default:
+			device_printf(softc->dev,
+				      "Unknown Thermal threshold type event\n");
+			return;
+		}
+		if (EVENT_DATA1_THERMAL_THRESHOLD_DIR_INCREASING(data1))
+			dir_str = "above";
+		else
+			dir_str = "below";
+		device_printf(softc->dev,
+			      "Chip temperature has gone %s the %s thermal threshold!\n",
+			      dir_str, threshold_type);
+		device_printf(softc->dev,
+			      "Temperature (In Celsius), Current: %u, threshold: %u\n",
+			      BNXT_EVENT_THERMAL_CURRENT_TEMP(data2),
+			      BNXT_EVENT_THERMAL_THRESHOLD_TEMP(data2));
+		break;
+	}
+	case HWRM_ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_DUAL_DATA_RATE_NOT_SUPPORTED:
+		device_printf(softc->dev,
+			      "Speed change is not supported with dual rate transceivers on this board\n");
+		break;
+
+	default:
+	device_printf(softc->dev,
+		      "FW reported unknown error type: %u, data1: 0x%x data2: 0x%x\n",
+		      err_type, data1, data2);
+		break;
+	}
+}
+
 static void
 bnxt_handle_async_event(struct bnxt_softc *softc, struct cmpl_base *cmpl)
 {
 	struct hwrm_async_event_cmpl *ae = (void *)cmpl;
 	uint16_t async_id = le16toh(ae->event_id);
 	struct ifmediareq ifmr;
+	char *type_str;
+	char *status_desc;
+	struct bnxt_fw_health *fw_health;
+	u32 data1 = le32toh(ae->event_data1);
+	u32 data2 = le32toh(ae->event_data2);
 
 	switch (async_id) {
 	case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE:
@@ -3196,6 +4497,86 @@ bnxt_handle_async_event(struct bnxt_softc *softc, struct cmpl_base *cmpl)
 		else
 			bnxt_media_status(softc->ctx, &ifmr);
 		break;
+	case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_ERROR_REPORT: {
+		bnxt_event_error_report(softc, data1, data2);
+		goto async_event_process_exit;
+	}
+	case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_DOORBELL_PACING_THRESHOLD:
+	case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_DOORBELL_PACING_NQ_UPDATE:
+		break;
+	case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_RESET_NOTIFY: {
+		type_str = "Solicited";
+
+		if (!softc->fw_health)
+			goto async_event_process_exit;
+
+		softc->fw_reset_timestamp = jiffies;
+		softc->fw_reset_min_dsecs = ae->timestamp_lo;
+		if (!softc->fw_reset_min_dsecs)
+			softc->fw_reset_min_dsecs = BNXT_DFLT_FW_RST_MIN_DSECS;
+		softc->fw_reset_max_dsecs = le16toh(ae->timestamp_hi);
+		if (!softc->fw_reset_max_dsecs)
+			softc->fw_reset_max_dsecs = BNXT_DFLT_FW_RST_MAX_DSECS;
+		if (EVENT_DATA1_RESET_NOTIFY_FW_ACTIVATION(data1)) {
+			set_bit(BNXT_STATE_FW_ACTIVATE_RESET, &softc->state);
+		} else if (EVENT_DATA1_RESET_NOTIFY_FATAL(data1)) {
+			type_str = "Fatal";
+			softc->fw_health->fatalities++;
+			set_bit(BNXT_STATE_FW_FATAL_COND, &softc->state);
+		} else if (data2 && BNXT_FW_STATUS_HEALTHY !=
+			   EVENT_DATA2_RESET_NOTIFY_FW_STATUS_CODE(data2)) {
+			type_str = "Non-fatal";
+			softc->fw_health->survivals++;
+			set_bit(BNXT_STATE_FW_NON_FATAL_COND, &softc->state);
+		}
+		device_printf(softc->dev,
+			   "%s firmware reset event, data1: 0x%x, data2: 0x%x, min wait %u ms, max wait %u ms\n",
+			   type_str, data1, data2,
+			   softc->fw_reset_min_dsecs * 100,
+			   softc->fw_reset_max_dsecs * 100);
+		set_bit(BNXT_FW_RESET_NOTIFY_SP_EVENT, &softc->sp_event);
+		break;
+	}
+	case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_ERROR_RECOVERY: {
+		fw_health = softc->fw_health;
+		status_desc = "healthy";
+		u32 status;
+
+		if (!fw_health)
+			goto async_event_process_exit;
+
+		if (!EVENT_DATA1_RECOVERY_ENABLED(data1)) {
+			fw_health->enabled = false;
+			device_printf(softc->dev, "Driver recovery watchdog is disabled\n");
+			break;
+		}
+		fw_health->primary = EVENT_DATA1_RECOVERY_MASTER_FUNC(data1);
+		fw_health->tmr_multiplier =
+			DIV_ROUND_UP(fw_health->polling_dsecs * HZ,
+				     HZ * 10);
+		fw_health->tmr_counter = fw_health->tmr_multiplier;
+		if (!fw_health->enabled)
+			fw_health->last_fw_heartbeat =
+				bnxt_fw_health_readl(softc, BNXT_FW_HEARTBEAT_REG);
+		fw_health->last_fw_reset_cnt =
+			bnxt_fw_health_readl(softc, BNXT_FW_RESET_CNT_REG);
+		status = bnxt_fw_health_readl(softc, BNXT_FW_HEALTH_REG);
+		if (status != BNXT_FW_STATUS_HEALTHY)
+			status_desc = "unhealthy";
+		device_printf(softc->dev,
+			   "Driver recovery watchdog, role: %s, firmware status: 0x%x (%s), resets: %u\n",
+			   fw_health->primary ? "primary" : "backup", status,
+			   status_desc, fw_health->last_fw_reset_cnt);
+		if (!fw_health->enabled) {
+			/* Make sure tmr_counter is set and seen by
+			 * bnxt_health_check() before setting enabled
+			 */
+			smp_mb();
+			fw_health->enabled = true;
+		}
+		goto async_event_process_exit;
+	}
+
 	case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_MTU_CHANGE:
 	case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_DCB_CONFIG_CHANGE:
 	case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PORT_CONN_NOT_ALLOWED:
@@ -3217,6 +4598,10 @@ bnxt_handle_async_event(struct bnxt_softc *softc, struct cmpl_base *cmpl)
 		    "Unknown async completion type %u\n", async_id);
 		break;
 	}
+	bnxt_queue_sp_work(softc);
+
+async_event_process_exit:
+	bnxt_ulp_async_events(softc, ae);
 }
 
 static void
@@ -3277,7 +4662,7 @@ bnxt_def_cp_task(void *context)
 	softc->db_ops.bnxt_db_rx_cq(cpr, 1);
 }
 
-static uint8_t
+uint8_t
 get_phy_type(struct bnxt_softc *softc)
 {
 	struct bnxt_link_info *link_info = &softc->link_info;
@@ -3370,6 +4755,8 @@ bnxt_get_baudrate(struct bnxt_link_info *link)
 		return IF_Gbps(100);
 	case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_10MB:
 		return IF_Mbps(10);
+	case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_200GB:
+		return IF_Gbps(200);
 	}
 	return IF_Gbps(100);
 }
diff --git a/sys/dev/bnxt/bnxt_re/bnxt_re-abi.h b/sys/dev/bnxt/bnxt_re/bnxt_re-abi.h
new file mode 100644
index 000000000000..8f48609e7f6f
--- /dev/null
+++ b/sys/dev/bnxt/bnxt_re/bnxt_re-abi.h
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2015-2024, Broadcom. All rights reserved.  The term
+ * Broadcom refers to Broadcom Limited and/or its subsidiaries.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Description: Uverbs ABI header file
+ */
+
+#ifndef __BNXT_RE_UVERBS_ABI_H__
+#define __BNXT_RE_UVERBS_ABI_H__
+
+#include <asm/types.h>
+#include <linux/types.h>
+
+#define BNXT_RE_ABI_VERSION	6
+
+enum {
+	BNXT_RE_COMP_MASK_UCNTX_WC_DPI_ENABLED = 0x01,
+	BNXT_RE_COMP_MASK_UCNTX_POW2_DISABLED = 0x02,
+	BNXT_RE_COMP_MASK_UCNTX_RSVD_WQE_DISABLED = 0x04,
+	BNXT_RE_COMP_MASK_UCNTX_MQP_EX_SUPPORTED = 0x08,
+	BNXT_RE_COMP_MASK_UCNTX_DBR_PACING_ENABLED = 0x10,
+	BNXT_RE_COMP_MASK_UCNTX_DBR_RECOVERY_ENABLED = 0x20,
+	BNXT_RE_COMP_MASK_UCNTX_HW_RETX_ENABLED = 0x40
+};
+
+enum {
+	BNXT_RE_COMP_MASK_REQ_UCNTX_POW2_SUPPORT = 0x01,
+	BNXT_RE_COMP_MASK_REQ_UCNTX_RSVD_WQE = 0x02
+};
+
+struct bnxt_re_uctx_req {
+	__aligned_u64 comp_mask;
+};
+
+#define BNXT_RE_CHIP_ID0_CHIP_NUM_SFT		0x00
+#define BNXT_RE_CHIP_ID0_CHIP_REV_SFT		0x10
+#define BNXT_RE_CHIP_ID0_CHIP_MET_SFT		0x18
+struct bnxt_re_uctx_resp {
+	__u32 dev_id;
+	__u32 max_qp;
+	__u32 pg_size;
+	__u32 cqe_sz;
+	__u32 max_cqd;
+	__u32 chip_id0;
+	__u32 chip_id1;
+	__u32 modes;
+	__aligned_u64 comp_mask;
+} __attribute__((packed));
+
+enum {
+	BNXT_RE_COMP_MASK_PD_HAS_WC_DPI = 0x01,
+	BNXT_RE_COMP_MASK_PD_HAS_DBR_BAR_ADDR = 0x02,
+};
+
+struct bnxt_re_pd_resp {
+	__u32 pdid;
+	__u32 dpi;
+	__u64 dbr;
+	__u64 comp_mask;
+	__u32 wcdpi;
+	__u64 dbr_bar_addr;
+} __attribute__((packed));
+
+enum {
+	BNXT_RE_COMP_MASK_CQ_HAS_DB_INFO = 0x01,
+	BNXT_RE_COMP_MASK_CQ_HAS_WC_DPI = 0x02,
+	BNXT_RE_COMP_MASK_CQ_HAS_CQ_PAGE = 0x04,
+};
+
+enum {
+	BNXT_RE_COMP_MASK_CQ_REQ_HAS_CAP_MASK = 0x1
+};
+
+enum {
+	BNXT_RE_COMP_MASK_CQ_REQ_CAP_DBR_RECOVERY = 0x1,
+	BNXT_RE_COMP_MASK_CQ_REQ_CAP_DBR_PACING_NOTIFY = 0x2
+};
+
+#define BNXT_RE_IS_DBR_PACING_NOTIFY_CQ(_req)				\
+	(_req.comp_mask & BNXT_RE_COMP_MASK_CQ_REQ_HAS_CAP_MASK &&	\
+	 _req.cq_capability & BNXT_RE_COMP_MASK_CQ_REQ_CAP_DBR_PACING_NOTIFY)
+
+#define BNXT_RE_IS_DBR_RECOV_CQ(_req)					\
+	(_req.comp_mask & BNXT_RE_COMP_MASK_CQ_REQ_HAS_CAP_MASK &&	\
+	 _req.cq_capability & BNXT_RE_COMP_MASK_CQ_REQ_CAP_DBR_RECOVERY)
+
+struct bnxt_re_cq_req {
+	__u64 cq_va;
+	__u64 cq_handle;
+	__aligned_u64 comp_mask;
+	__u16 cq_capability;
+} __attribute__((packed));
+
+struct bnxt_re_cq_resp {
+	__u32 cqid;
+	__u32 tail;
+	__u32 phase;
+	__u32 rsvd;
+	__aligned_u64 comp_mask;
+	__u32 dpi;
+	__u64 dbr;
+	__u32 wcdpi;
+	__u64 uctx_cq_page;
+} __attribute__((packed));
+
+struct bnxt_re_resize_cq_req {
+	__u64 cq_va;
+} __attribute__((packed));
+
+struct bnxt_re_qp_req {
+	__u64 qpsva;
+	__u64 qprva;
+	__u64 qp_handle;
+} __attribute__((packed));
+
+struct bnxt_re_qp_resp {
+	__u32 qpid;
+} __attribute__((packed));
+
+struct bnxt_re_srq_req {
+	__u64 srqva;
+	__u64 srq_handle;
+} __attribute__((packed));
+
+struct bnxt_re_srq_resp {
+	__u32 srqid;
+} __attribute__((packed));
+
+/* Modify QP */
+enum {
+	BNXT_RE_COMP_MASK_MQP_EX_PPP_REQ_EN_MASK = 0x1,
+	BNXT_RE_COMP_MASK_MQP_EX_PPP_REQ_EN	 = 0x1,
+	BNXT_RE_COMP_MASK_MQP_EX_PATH_MTU_MASK	 = 0x2
+};
+
+struct bnxt_re_modify_qp_ex_req {
+	__aligned_u64 comp_mask;
+	__u32 dpi;
+	__u32 rsvd;
+} __packed;
+
+struct bnxt_re_modify_qp_ex_resp {
+	__aligned_u64 comp_mask;
+	__u32 ppp_st_idx;
+	__u32 path_mtu;
+} __packed;
+
+enum bnxt_re_shpg_offt {
+	BNXT_RE_BEG_RESV_OFFT	= 0x00,
+	BNXT_RE_AVID_OFFT	= 0x10,
+	BNXT_RE_AVID_SIZE	= 0x04,
+	BNXT_RE_END_RESV_OFFT	= 0xFF0
+};
+#endif
diff --git a/sys/dev/bnxt/bnxt_re/bnxt_re.h b/sys/dev/bnxt/bnxt_re/bnxt_re.h
new file mode 100644
index 000000000000..3bf0bbeb1061
--- /dev/null
+++ b/sys/dev/bnxt/bnxt_re/bnxt_re.h
@@ -0,0 +1,1075 @@
+/*
+ * Copyright (c) 2015-2024, Broadcom. All rights reserved.  The term
+ * Broadcom refers to Broadcom Limited and/or its subsidiaries.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Description: main (header)
+ */
+
+#ifndef __BNXT_RE_H__
+#define __BNXT_RE_H__
+
+#include <linux/module.h>
+#include <linux/netdevice.h>
+#include <linux/mutex.h>
+#include <linux/list.h>
+#include <linux/rculist.h>
+#include <linux/spinlock.h>
+#include <net/ipv6.h>
+#include <linux/if_ether.h>
+#include <linux/debugfs.h>
+#include <linux/seq_file.h>
+#include <linux/interrupt.h>
+#include <linux/vmalloc.h>
+#include <linux/delay.h>
+#include <rdma/ib_verbs.h>
+#include <rdma/ib_user_verbs.h>
+#include <rdma/ib_umem.h>
+#include <rdma/ib_addr.h>
+#include <rdma/ib_mad.h>
+#include <rdma/ib_cache.h>
+#include <linux/pci.h>
+
+#include "bnxt.h"
+#include "bnxt_ulp.h"
+#include "hsi_struct_def.h"
+#include "qplib_res.h"
+#include "qplib_sp.h"
+#include "qplib_fp.h"
+#include "qplib_rcfw.h"
+#include "ib_verbs.h"
+#include "stats.h"
+
+#define ROCE_DRV_MODULE_NAME		"bnxt_re"
+#define ROCE_DRV_MODULE_VERSION		"230.0.133.0"
+#define ROCE_DRV_MODULE_RELDATE		"April 22, 2024"
+
+#define BNXT_RE_REF_WAIT_COUNT		20
+#define BNXT_RE_ROCE_V1_ETH_TYPE	0x8915
+#define BNXT_RE_ROCE_V2_PORT_NO		4791
+#define BNXT_RE_RES_FREE_WAIT_COUNT	1000
+
+#define BNXT_RE_PAGE_SHIFT_4K		(12)
+#define BNXT_RE_PAGE_SHIFT_8K		(13)
+#define BNXT_RE_PAGE_SHIFT_64K		(16)
+#define BNXT_RE_PAGE_SHIFT_2M		(21)
+#define BNXT_RE_PAGE_SHIFT_8M		(23)
+#define BNXT_RE_PAGE_SHIFT_1G		(30)
+
+#define BNXT_RE_PAGE_SIZE_4K		BIT(BNXT_RE_PAGE_SHIFT_4K)
+#define BNXT_RE_PAGE_SIZE_8K		BIT(BNXT_RE_PAGE_SHIFT_8K)
+#define BNXT_RE_PAGE_SIZE_64K		BIT(BNXT_RE_PAGE_SHIFT_64K)
+#define BNXT_RE_PAGE_SIZE_2M		BIT(BNXT_RE_PAGE_SHIFT_2M)
+#define BNXT_RE_PAGE_SIZE_8M		BIT(BNXT_RE_PAGE_SHIFT_8M)
+#define BNXT_RE_PAGE_SIZE_1G		BIT(BNXT_RE_PAGE_SHIFT_1G)
+
+#define BNXT_RE_MAX_MR_SIZE_LOW		BIT(BNXT_RE_PAGE_SHIFT_1G)
+#define BNXT_RE_MAX_MR_SIZE_HIGH	BIT(39)
+#define BNXT_RE_MAX_MR_SIZE		BNXT_RE_MAX_MR_SIZE_HIGH
+
+/* Number of MRs to reserve for PF, leaving remainder for VFs */
+#define BNXT_RE_RESVD_MR_FOR_PF		(32 * 1024)
+#define BNXT_RE_MAX_GID_PER_VF		128
+
+#define BNXT_RE_MAX_VF_QPS_PER_PF	(6 * 1024)
+
+/**
+ * min_not_zero - return the minimum that is _not_ zero, unless both are zero
+ * @x: value1
+ * @y: value2
+ */
+#define min_not_zero(x, y) ({			\
+	typeof(x) __x = (x);			\
+	typeof(y) __y = (y);			\
+	__x == 0 ? __y : ((__y == 0) ? __x : min(__x, __y)); })
+
+struct ib_mr_init_attr {
+	int		max_reg_descriptors;
+	u32		flags;
+};
+
+struct bnxt_re_dev;
+
+int bnxt_re_register_netdevice_notifier(struct notifier_block *nb);
+int bnxt_re_unregister_netdevice_notifier(struct notifier_block *nb);
+int ib_register_device_compat(struct bnxt_re_dev *rdev);
+
+#ifndef __struct_group
+#define __struct_group(TAG, NAME, ATTRS, MEMBERS...) \
+	union { \
+		struct { MEMBERS } ATTRS; \
+		struct TAG { MEMBERS } ATTRS NAME; \
+	}
+#endif /* __struct_group */
+#ifndef struct_group_attr
+#define struct_group_attr(NAME, ATTRS, MEMBERS...) \
+	__struct_group(/* no tag */, NAME, ATTRS, MEMBERS)
+#endif /* struct_group_attr */
+/*
+ * Percentage of resources of each type reserved for PF.
+ * Remaining resources are divided equally among VFs.
+ * [0, 100]
+ */
+
+#define BNXT_RE_RQ_WQE_THRESHOLD	32
+#define BNXT_RE_UD_QP_HW_STALL		0x400000
+
+/*
+ * Setting the default ack delay value to 16, which means
+ * the default timeout is approx. 260ms(4 usec * 2 ^(timeout))
+ */
+
+#define BNXT_RE_DEFAULT_ACK_DELAY	16
+#define BNXT_RE_BOND_PF_MAX		2
+
+#define BNXT_RE_STATS_CTX_UPDATE_TIMER	250
+#define BNXT_RE_30SEC_MSEC		(30 * 1000)
+
+#define BNXT_RE_BOND_RESCHED_CNT	10
+
+#define BNXT_RE_CHIP_NUM_57454         0xC454
+#define BNXT_RE_CHIP_NUM_57452         0xC452
+
+#define BNXT_RE_CHIP_NUM_5745X(chip_num)          \
+	((chip_num) == BNXT_RE_CHIP_NUM_57454 ||       \
+	 (chip_num) == BNXT_RE_CHIP_NUM_57452)
+
+#define BNXT_RE_MIN_KERNEL_QP_TX_DEPTH	4096
+#define BNXT_RE_STOP_QPS_BUDGET		200
+
+#define BNXT_RE_HWRM_CMD_TIMEOUT(rdev) \
+		((rdev)->chip_ctx->hwrm_cmd_max_timeout * 1000)
+
+extern unsigned int min_tx_depth;
+extern struct mutex bnxt_re_dev_lock;
+extern struct mutex bnxt_re_mutex;
+extern struct list_head bnxt_re_dev_list;
+
+struct bnxt_re_ring_attr {
+	dma_addr_t	*dma_arr;
+	int		pages;
+	int	 	type;
+	u32		depth;
+	u32		lrid; /* Logical ring id */
+	u16		flags;
+	u8		mode;
+	u8		rsvd;
+};
+
+#define BNXT_RE_MAX_DEVICES		256
+#define BNXT_RE_MSIX_FROM_MOD_PARAM	-1
+#define BNXT_RE_MIN_MSIX		2
+#define BNXT_RE_MAX_MSIX_VF		2
+#define BNXT_RE_MAX_MSIX_PF		9
+#define BNXT_RE_MAX_MSIX_NPAR_PF	5
+#define BNXT_RE_MAX_MSIX		64
+#define BNXT_RE_MAX_MSIX_GEN_P5_PF	BNXT_RE_MAX_MSIX
+#define BNXT_RE_GEN_P5_MAX_VF		64
+
+struct bnxt_re_nq_record {
+	struct bnxt_msix_entry	msix_entries[BNXT_RE_MAX_MSIX];
+	/* FP Notification Queue (CQ & SRQ) */
+	struct bnxt_qplib_nq    nq[BNXT_RE_MAX_MSIX];
+	int			num_msix;
+	int			max_init;
+	struct mutex		load_lock;
+};
+
+struct bnxt_re_work {
+	struct work_struct	work;
+	unsigned long		event;
+	struct bnxt_re_dev      *rdev;
+	struct ifnet		*vlan_dev;
+	bool do_lag;
+
+	/* netdev where we received the event */
+	struct ifnet *netdev;
+	struct auxiliary_device *adev;
+};
+
+/*
+ * Data structure and defines to handle
+ * recovery
+ */
+#define BNXT_RE_RECOVERY_IB_UNINIT_WAIT_RETRY   20
+#define BNXT_RE_RECOVERY_IB_UNINIT_WAIT_TIME_MS 30000 /* 30sec timeout */
+#define BNXT_RE_PRE_RECOVERY_REMOVE 0x1
+#define BNXT_RE_COMPLETE_REMOVE 0x2
+#define BNXT_RE_POST_RECOVERY_INIT 0x4
+#define BNXT_RE_COMPLETE_INIT 0x8
+#define BNXT_RE_COMPLETE_SHUTDOWN 0x10
+
+/* QP1 SQ entry data strucutre */
+struct bnxt_re_sqp_entries {
+	u64 wrid;
+	struct bnxt_qplib_sge sge;
+	/* For storing the actual qp1 cqe */
+	struct bnxt_qplib_cqe cqe;
+	struct bnxt_re_qp *qp1_qp;
+};
+
+/* GSI QP mode enum */
+enum bnxt_re_gsi_mode {
+	BNXT_RE_GSI_MODE_INVALID = 0,
+	BNXT_RE_GSI_MODE_ALL = 1,
+	BNXT_RE_GSI_MODE_ROCE_V1,
+	BNXT_RE_GSI_MODE_ROCE_V2_IPV4,
+	BNXT_RE_GSI_MODE_ROCE_V2_IPV6,
+	BNXT_RE_GSI_MODE_UD
+};
+
+enum bnxt_re_roce_cap {
+	BNXT_RE_FLAG_ROCEV1_CAP = 1,
+	BNXT_RE_FLAG_ROCEV2_CAP,
+	BNXT_RE_FLAG_ROCEV1_V2_CAP,
+};
+
+#define BNXT_RE_MAX_GSI_SQP_ENTRIES	1024
+struct bnxt_re_gsi_context {
+	u8	gsi_qp_mode;
+	bool	first_cq_created;
+	/* Start: used only in gsi_mode_all */
+	struct	bnxt_re_qp *gsi_qp;
+	struct	bnxt_re_qp *gsi_sqp;
+	struct	bnxt_re_ah *gsi_sah;
+	struct	bnxt_re_sqp_entries *sqp_tbl;
+	/* End: used only in gsi_mode_all */
+};
+
+struct bnxt_re_tc_rec {
+	u8 cos_id_roce;
+	u8 tc_roce;
+	u8 cos_id_cnp;
+	u8 tc_cnp;
+	u8 tc_def;
+	u8 cos_id_def;
+	u8 max_tc;
+	u8 roce_prio;
+	u8 cnp_prio;
+	u8 roce_dscp;
+	u8 cnp_dscp;
+	u8 prio_valid;
+	u8 dscp_valid;
+	bool ecn_enabled;
+	bool serv_type_enabled;
+	u64 cnp_dscp_bv;
+	u64 roce_dscp_bv;
+};
+
+struct bnxt_re_dscp2pri {
+	u8 dscp;
+	u8 mask;
+	u8 pri;
+};
+
+struct bnxt_re_cos2bw_cfg {
+	u8	pad[3];
+	struct_group_attr(cfg, __packed,
+		u8	queue_id;
+		__le32	min_bw;
+		__le32	max_bw;
+		u8	tsa;
+		u8	pri_lvl;
+		u8	bw_weight;
+	);
+	u8	unused;
+};
+
+#define BNXT_RE_AEQ_IDX			0
+#define BNXT_RE_MAX_SGID_ENTRIES	256
+
+#define BNXT_RE_DBGFS_FILE_MEM          65536
+enum {
+	BNXT_RE_STATS_QUERY = 1,
+	BNXT_RE_QP_QUERY = 2,
+	BNXT_RE_SERVICE_FN_QUERY = 3,
+};
+
+struct bnxt_re_dbg_file {
+	struct bnxt_re_dev *rdev;
+	u32 type;
+	union {
+		struct bnxt_qplib_query_stats_info sinfo;
+		struct bnxt_qplib_query_fn_info fninfo;
+	}params;
+	char dbg_buf[BNXT_RE_DBGFS_FILE_MEM];
+};
+
+struct bnxt_re_debug_entries {
+	/* Dir entries */
+	struct dentry *qpinfo_dir;
+	struct dentry *service_fn_dir;
+	/* file entries */
+	struct dentry *stat_query;
+	struct bnxt_re_dbg_file stat_file;
+	struct dentry *qplist_query;
+	struct bnxt_re_dbg_file qp_file;
+	struct dentry *service_fn_query;
+	struct bnxt_re_dbg_file service_fn_file;
+};
+
+struct bnxt_re_en_dev_info {
+	struct list_head en_list;
+	struct bnxt_en_dev *en_dev;
+	struct bnxt_re_dev *rdev;
+	unsigned long flags;
+#define BNXT_RE_FLAG_EN_DEV_NETDEV_REG		0
+#define BNXT_RE_FLAG_EN_DEV_PRIMARY_DEV		1
+#define BNXT_RE_FLAG_EN_DEV_SECONDARY_DEV	2
+	u8 wqe_mode;
+	u8 gsi_mode;
+	bool te_bypass;
+	bool ib_uninit_done;
+	u32 num_msix_requested;
+	wait_queue_head_t waitq;
+};
+
+#define BNXT_RE_DB_FIFO_ROOM_MASK_P5	0x1FFF8000
+#define BNXT_RE_MAX_FIFO_DEPTH_P5	0x2c00
+#define BNXT_RE_DB_FIFO_ROOM_SHIFT	15
+
+#define BNXT_RE_DB_FIFO_ROOM_MASK_P7	0x3FFF8000
+#define BNXT_RE_MAX_FIFO_DEPTH_P7	0x8000
+
+#define BNXT_RE_DB_FIFO_ROOM_MASK(ctx)	\
+	(_is_chip_p7((ctx)) ? \
+	 BNXT_RE_DB_FIFO_ROOM_MASK_P7 :\
+	 BNXT_RE_DB_FIFO_ROOM_MASK_P5)
+#define BNXT_RE_MAX_FIFO_DEPTH(ctx)	\
+	(_is_chip_p7((ctx)) ? \
+	 BNXT_RE_MAX_FIFO_DEPTH_P7 :\
+	 BNXT_RE_MAX_FIFO_DEPTH_P5)
+
+struct bnxt_dbq_nq_list {
+	int num_nql_entries;
+	u16 nq_id[16];
+};
+
+#define BNXT_RE_ASYNC_ERR_REP_BASE(_type)				\
+	 (ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_##_type)
+
+#define BNXT_RE_ASYNC_ERR_DBR_TRESH(_type)				\
+	 (ASYNC_EVENT_CMPL_ERROR_REPORT_DOORBELL_DROP_THRESHOLD_##_type)
+
+#define BNXT_RE_EVENT_DBR_EPOCH(data)					\
+	(((data) &							\
+	  BNXT_RE_ASYNC_ERR_DBR_TRESH(EVENT_DATA1_EPOCH_MASK)) >>	\
+	 BNXT_RE_ASYNC_ERR_DBR_TRESH(EVENT_DATA1_EPOCH_SFT))
+
+#define BNXT_RE_EVENT_ERROR_REPORT_TYPE(data1)				\
+	(((data1) &							\
+	  BNXT_RE_ASYNC_ERR_REP_BASE(TYPE_MASK))  >>			\
+	 BNXT_RE_ASYNC_ERR_REP_BASE(TYPE_SFT))
+
+#define BNXT_RE_DBR_LIST_ADD(_rdev, _res, _type)			\
+{									\
+	spin_lock(&(_rdev)->res_list[_type].lock);			\
+	list_add_tail(&(_res)->dbr_list,				\
+		      &(_rdev)->res_list[_type].head);			\
+	spin_unlock(&(_rdev)->res_list[_type].lock);			\
+}
+
+#define BNXT_RE_DBR_LIST_DEL(_rdev, _res, _type)			\
+{									\
+	spin_lock(&(_rdev)->res_list[_type].lock);			\
+	list_del(&(_res)->dbr_list);					\
+	spin_unlock(&(_rdev)->res_list[_type].lock);			\
+}
+
+#define BNXT_RE_CQ_PAGE_LIST_ADD(_uctx, _cq)				\
+{									\
+	mutex_lock(&(_uctx)->cq_lock);					\
+	list_add_tail(&(_cq)->cq_list, &(_uctx)->cq_list);		\
+	mutex_unlock(&(_uctx)->cq_lock);				\
+}
+
+#define BNXT_RE_CQ_PAGE_LIST_DEL(_uctx, _cq)				\
+{									\
+	mutex_lock(&(_uctx)->cq_lock);					\
+	list_del(&(_cq)->cq_list);					\
+	mutex_unlock(&(_uctx)->cq_lock);				\
+}
+
+#define BNXT_RE_NETDEV_EVENT(event, x)					\
+	do {								\
+		if ((event) == (x))					\
+			return #x;					\
+	} while (0)
+
+/* Do not change the seq of this enum which is followed by dbr recov */
+enum {
+	BNXT_RE_RES_TYPE_CQ = 0,
+	BNXT_RE_RES_TYPE_UCTX,
+	BNXT_RE_RES_TYPE_QP,
+	BNXT_RE_RES_TYPE_SRQ,
+	BNXT_RE_RES_TYPE_MAX
+};
+
+struct bnxt_re_dbr_res_list {
+	struct list_head head;
+	spinlock_t lock;
+};
+
+struct bnxt_re_dbr_drop_recov_work {
+	struct work_struct work;
+	struct bnxt_re_dev *rdev;
+	u32 curr_epoch;
+};
+
+struct bnxt_re_aer_work {
+	struct work_struct work;
+	struct bnxt_re_dev *rdev;
+};
+
+struct bnxt_re_dbq_stats {
+	u64 fifo_occup_slab_1;
+	u64 fifo_occup_slab_2;
+	u64 fifo_occup_slab_3;
+	u64 fifo_occup_slab_4;
+	u64 fifo_occup_water_mark;
+	u64 do_pacing_slab_1;
+	u64 do_pacing_slab_2;
+	u64 do_pacing_slab_3;
+	u64 do_pacing_slab_4;
+	u64 do_pacing_slab_5;
+	u64 do_pacing_water_mark;
+};
+
+/* Device debug statistics */
+struct bnxt_re_drv_dbg_stats {
+	struct bnxt_re_dbq_stats dbq;
+};
+
+/* DB pacing counters */
+struct bnxt_re_dbr_sw_stats {
+	u64 dbq_int_recv;
+	u64 dbq_int_en;
+	u64 dbq_pacing_resched;
+	u64 dbq_pacing_complete;
+	u64 dbq_pacing_alerts;
+	u64 dbr_drop_recov_events;
+	u64 dbr_drop_recov_timeouts;
+	u64 dbr_drop_recov_timeout_users;
+	u64 dbr_drop_recov_event_skips;
+};
+
+struct bnxt_re_dev {
+	struct ib_device		ibdev;
+	struct list_head		list;
+	atomic_t			ref_count;
+	atomic_t			sched_count;
+	unsigned long			flags;
+#define BNXT_RE_FLAG_NETDEV_REGISTERED		0
+#define BNXT_RE_FLAG_IBDEV_REGISTERED		1
+#define BNXT_RE_FLAG_GOT_MSIX			2
+#define BNXT_RE_FLAG_HAVE_L2_REF		3
+#define BNXT_RE_FLAG_ALLOC_RCFW			4
+#define BNXT_RE_FLAG_NET_RING_ALLOC		5
+#define BNXT_RE_FLAG_RCFW_CHANNEL_EN		6
+#define BNXT_RE_FLAG_ALLOC_CTX			7
+#define BNXT_RE_FLAG_STATS_CTX_ALLOC		8
+#define BNXT_RE_FLAG_STATS_CTX2_ALLOC		9
+#define BNXT_RE_FLAG_RCFW_CHANNEL_INIT		10
+#define BNXT_RE_FLAG_WORKER_REG			11
+#define BNXT_RE_FLAG_TBLS_ALLOCINIT		12
+#define BNXT_RE_FLAG_SETUP_NQ			13
+#define BNXT_RE_FLAG_BOND_DEV_REGISTERED	14
+#define BNXT_RE_FLAG_PER_PORT_DEBUG_INFO	15
+#define BNXT_RE_FLAG_DEV_LIST_INITIALIZED	16
+#define BNXT_RE_FLAG_ERR_DEVICE_DETACHED	17
+#define BNXT_RE_FLAG_INIT_DCBX_CC_PARAM		18
+#define BNXT_RE_FLAG_STOP_IN_PROGRESS		20
+#define BNXT_RE_FLAG_ISSUE_ROCE_STATS		29
+#define BNXT_RE_FLAG_ISSUE_CFA_FLOW_STATS	30
+	struct ifnet			*netdev;
+	struct auxiliary_device		*adev;
+	struct bnxt_qplib_chip_ctx	*chip_ctx;
+	struct bnxt_en_dev		*en_dev;
+	struct bnxt_re_nq_record	nqr;
+	int				id;
+	struct delayed_work		worker;
+	u16				worker_30s;
+	struct bnxt_re_tc_rec		tc_rec[2];
+	u8				cur_prio_map;
+	/* RCFW Channel */
+	struct bnxt_qplib_rcfw		rcfw;
+	/* Device Resources */
+	struct bnxt_qplib_dev_attr	*dev_attr;
+	struct bnxt_qplib_res		qplib_res;
+	struct bnxt_qplib_dpi		dpi_privileged;
+	struct bnxt_qplib_cc_param	cc_param;
+	struct mutex			cc_lock;
+	struct mutex			qp_lock;
+	struct list_head		qp_list;
+	u8				roce_mode;
+
+	/* Max of 2 lossless traffic class supported per port */
+	u16				cosq[2];
+	/* Start: QP for handling QP1 packets */
+	struct bnxt_re_gsi_context	gsi_ctx;
+	/* End: QP for handling QP1 packets */
+	bool				is_virtfn;
+	u32				num_vfs;
+	u32				espeed;
+	/*
+	 * For storing the speed of slave interfaces.
+	 * Same as espeed when bond is not configured
+	 */
+	u32				sl_espeed;
+	/* To be used for a workaround for ISER stack */
+	u32				min_tx_depth;
+	/* To enable qp debug info. Disabled during driver load */
+	u32				en_qp_dbg;
+	/* Array to handle gid mapping */
+	char				*gid_map;
+
+	struct bnxt_re_device_stats	stats;
+	struct bnxt_re_drv_dbg_stats	*dbg_stats;
+	/* debugfs to expose per port information*/
+	struct dentry                   *port_debug_dir;
+	struct dentry                   *info;
+	struct dentry                   *drv_dbg_stats;
+	struct dentry                   *sp_perf_stats;
+	struct dentry                   *pdev_debug_dir;
+	struct dentry                   *pdev_qpinfo_dir;
+	struct bnxt_re_debug_entries	*dbg_ent;
+	struct workqueue_struct		*resolve_wq;
+	struct list_head		mac_wq_list;
+	struct workqueue_struct		*dcb_wq;
+	struct workqueue_struct		*aer_wq;
+	u32				event_bitmap[3];
+	bool unreg_sched;
+	u64	dbr_throttling_reg_off;
+	u64	dbr_aeq_arm_reg_off;
+	u64	dbr_db_fifo_reg_off;
+	void *dbr_page;
+	u64 dbr_bar_addr;
+	u32 pacing_algo_th;
+	u32 pacing_en_int_th;
+	u32 do_pacing_save;
+	struct workqueue_struct		*dbq_wq;
+	struct workqueue_struct		*dbr_drop_recov_wq;
+	struct work_struct		dbq_fifo_check_work;
+	struct delayed_work		dbq_pacing_work;
+	/* protect DB pacing */
+	struct mutex dbq_lock;
+	/* Control DBR pacing feature. Set if enabled */
+	bool dbr_pacing;
+	/* Control DBR recovery feature. Set if enabled */
+	bool dbr_drop_recov;
+	bool user_dbr_drop_recov;
+	/* DBR recovery feature. Set if running */
+	bool dbr_recovery_on;
+	u32 user_dbr_drop_recov_timeout;
+	 /*
+	  * Value used for pacing algo when pacing is active
+	  */
+#define BNXT_RE_MAX_DBR_DO_PACING 0xFFFF
+	u32 dbr_do_pacing;
+	u32 dbq_watermark; /* Current watermark set in HW registers */
+	u32 dbq_nq_id; /* Current NQ ID for DBQ events */
+	u32 dbq_pacing_time; /* ms */
+	u32 dbr_def_do_pacing; /* do_pacing when no congestion */
+	u32 dbr_evt_curr_epoch;
+	bool dbq_int_disable;
+
+	bool mod_exit;
+	struct bnxt_re_dbr_sw_stats *dbr_sw_stats;
+	struct bnxt_re_dbr_res_list res_list[BNXT_RE_RES_TYPE_MAX];
+	struct bnxt_dbq_nq_list nq_list;
+	char dev_name[IB_DEVICE_NAME_MAX];
+	atomic_t dbq_intr_running;
+	u32 num_msix_requested;
+	unsigned char	*dev_addr; /* For netdev->dev_addr */
+};
+
+#define BNXT_RE_RESOLVE_RETRY_COUNT_US	5000000 /* 5 sec */
+struct bnxt_re_resolve_dmac_work{
+	struct work_struct      work;
+	struct list_head	list;
+	struct bnxt_re_dev 	*rdev;
+	struct ib_ah_attr	*ah_attr;
+	struct bnxt_re_ah_info *ah_info;
+	atomic_t		status_wait;
+};
+
+static inline u8 bnxt_re_get_prio(u8 prio_map)
+{
+	u8 prio = 0xFF;
+
+	for (prio = 0; prio < 8; prio++)
+		if (prio_map & (1UL << prio))
+			break;
+	return prio;
+}
+
+/* This should be called with bnxt_re_dev_lock mutex held */
+static inline bool __bnxt_re_is_rdev_valid(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_re_dev *tmp_rdev;
+
+	list_for_each_entry(tmp_rdev, &bnxt_re_dev_list, list) {
+		if (rdev == tmp_rdev)
+			return true;
+	}
+	return false;
+}
+
+static inline bool bnxt_re_is_rdev_valid(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_re_dev *tmp_rdev;
+
+	mutex_lock(&bnxt_re_dev_lock);
+	list_for_each_entry(tmp_rdev, &bnxt_re_dev_list, list) {
+		if (rdev == tmp_rdev) {
+			mutex_unlock(&bnxt_re_dev_lock);
+			return true;
+		}
+	}
+	mutex_unlock(&bnxt_re_dev_lock);
+
+	pr_debug("bnxt_re: %s : Invalid rdev received rdev = %p\n",
+		 __func__, rdev);
+	return false;
+}
+
+int bnxt_re_send_hwrm_cmd(struct bnxt_re_dev *rdev, void *cmd,
+			  int cmdlen);
+void bnxt_re_stopqps_and_ib_uninit(struct bnxt_re_dev *rdev);
+int bnxt_re_set_hwrm_dscp2pri(struct bnxt_re_dev *rdev,
+			      struct bnxt_re_dscp2pri *d2p, u16 count,
+			      u16 target_id);
+int bnxt_re_query_hwrm_dscp2pri(struct bnxt_re_dev *rdev,
+				struct bnxt_re_dscp2pri *d2p, u16 *count,
+				u16 target_id);
+int bnxt_re_query_hwrm_qportcfg(struct bnxt_re_dev *rdev,
+				struct bnxt_re_tc_rec *cnprec, u16 tid);
+int bnxt_re_hwrm_cos2bw_qcfg(struct bnxt_re_dev *rdev, u16 target_id,
+			     struct bnxt_re_cos2bw_cfg *cfg);
+int bnxt_re_hwrm_cos2bw_cfg(struct bnxt_re_dev *rdev, u16 target_id,
+			    struct bnxt_re_cos2bw_cfg *cfg);
+int bnxt_re_hwrm_pri2cos_cfg(struct bnxt_re_dev *rdev,
+			     u16 target_id, u16 port_id,
+			     u8 *cos_id_map, u8 pri_map);
+int bnxt_re_prio_vlan_tx_update(struct bnxt_re_dev *rdev);
+int bnxt_re_get_slot_pf_count(struct bnxt_re_dev *rdev);
+struct bnxt_re_dev *bnxt_re_get_peer_pf(struct bnxt_re_dev *rdev);
+struct bnxt_re_dev *bnxt_re_from_netdev(struct ifnet *netdev);
+u8 bnxt_re_get_priority_mask(struct bnxt_re_dev *rdev, u8 selector);
+struct bnxt_qplib_nq * bnxt_re_get_nq(struct bnxt_re_dev *rdev);
+void bnxt_re_put_nq(struct bnxt_re_dev *rdev, struct bnxt_qplib_nq *nq);
+
+#define to_bnxt_re(ptr, type, member)	\
+	container_of(ptr, type, member)
+
+#define to_bnxt_re_dev(ptr, member)	\
+	container_of((ptr), struct bnxt_re_dev, member)
+
+/* Even number functions from port 0 and odd number from port 1 */
+#define BNXT_RE_IS_PORT0(rdev) (!(rdev->en_dev->pdev->devfn & 1))
+
+#define BNXT_RE_ROCE_V1_PACKET		0
+#define BNXT_RE_ROCEV2_IPV4_PACKET	2
+#define BNXT_RE_ROCEV2_IPV6_PACKET	3
+#define BNXT_RE_ACTIVE_MAP_PORT1    0x1  /*port-1 active */
+#define BNXT_RE_ACTIVE_MAP_PORT2    0x2  /*port-2 active */
+
+#define BNXT_RE_MEMBER_PORT_MAP		(BNXT_RE_ACTIVE_MAP_PORT1 | \
+					BNXT_RE_ACTIVE_MAP_PORT2)
+
+#define	rdev_to_dev(rdev)	((rdev) ? (&(rdev)->ibdev.dev) : NULL)
+
+void bnxt_re_set_dma_device(struct ib_device *ibdev, struct bnxt_re_dev *rdev);
+bool bnxt_re_is_rdev_valid(struct bnxt_re_dev *rdev);
+
+#define bnxt_re_rdev_ready(rdev)	(bnxt_re_is_rdev_valid(rdev) && \
+					 (test_bit(BNXT_RE_FLAG_IBDEV_REGISTERED, &rdev->flags)))
+#define BNXT_RE_SRIOV_CFG_TIMEOUT 6
+
+int bnxt_re_get_device_stats(struct bnxt_re_dev *rdev);
+void bnxt_re_remove_device(struct bnxt_re_dev *rdev, u8 removal_type,
+			   struct auxiliary_device *aux_dev);
+void bnxt_re_destroy_lag(struct bnxt_re_dev **rdev);
+int bnxt_re_add_device(struct bnxt_re_dev **rdev,
+		       struct ifnet *netdev,
+		       u8 qp_mode, u8 op_type, u8 wqe_mode, u32 num_msix_requested,
+		       struct auxiliary_device *aux_dev);
+void bnxt_re_create_base_interface(bool primary);
+int bnxt_re_schedule_work(struct bnxt_re_dev *rdev, unsigned long event,
+			  struct ifnet *vlan_dev,
+			  struct ifnet *netdev,
+			  struct auxiliary_device *aux_dev);
+void bnxt_re_get_link_speed(struct bnxt_re_dev *rdev);
+int _bnxt_re_ib_init(struct bnxt_re_dev *rdev);
+int _bnxt_re_ib_init2(struct bnxt_re_dev *rdev);
+void bnxt_re_init_resolve_wq(struct bnxt_re_dev *rdev);
+void bnxt_re_uninit_resolve_wq(struct bnxt_re_dev *rdev);
+
+/* The rdev ref_count is to protect immature removal of the device */
+static inline void bnxt_re_hold(struct bnxt_re_dev *rdev)
+{
+	atomic_inc(&rdev->ref_count);
+	dev_dbg(rdev_to_dev(rdev),
+		"Hold ref_count = 0x%x", atomic_read(&rdev->ref_count));
+}
+
+static inline void bnxt_re_put(struct bnxt_re_dev *rdev)
+{
+	atomic_dec(&rdev->ref_count);
+	dev_dbg(rdev_to_dev(rdev),
+		"Put ref_count = 0x%x", atomic_read(&rdev->ref_count));
+}
+
+/*
+* Responder Error reason codes
+* FIXME: Remove these when the defs
+* are properly included in hsi header
+*/
+enum res_err_state_reason {
+	/* No error. */
+	CFCQ_RES_ERR_STATE_REASON_NO_ERROR = 0,
+	/*
+	 * Incoming Send, RDMA write, or RDMA read exceeds the maximum
+	 * transfer length. Detected on RX first and only packets for
+	 * write. Detected on RX request for read. This is an RX
+	 * Detected Error.
+	 */
+	CFCQ_RES_ERR_STATE_REASON_RES_EXCEED_MAX,
+	/*
+	 * RDMA write payload size does not match write length. Detected
+	 * when total write payload is not equal to the RDMA write
+	 * length that was given in the first or only packet of the
+	 * request. This is an RX Detected Error.
+	 */
+	CFCQ_RES_ERR_STATE_REASON_RES_PAYLOAD_LENGTH_MISMATCH,
+	/*
+	 * Send payload exceeds RQ/SRQ WQE buffer capacity. The total
+	 * send payload that arrived is more than the size of the WQE
+	 * buffer that was fetched from the RQ/SRQ. This is an RX
+	 * Detected Error.
+	 */
+	CFCQ_RES_ERR_STATE_REASON_RES_EXCEEDS_WQE,
+	/*
+	 * Responder detected opcode error. * First, only, middle, last
+	 * for incoming requests are improperly ordered with respect to
+	 * previous (PSN) packet. * First or middle packet is not full
+	 * MTU size. This is an RX Detected Error.
+	 */
+	CFCQ_RES_ERR_STATE_REASON_RES_OPCODE_ERROR,
+	/*
+	 * PSN sequence error retry limit exceeded. The responder
+	 * encountered a PSN sequence error for the same PSN too many
+	 * times. This can occur via implicit or explicit NAK. This is
+	 * an RX Detected Error.
+	 */
+	CFCQ_RES_ERR_STATE_REASON_RES_PSN_SEQ_ERROR_RETRY_LIMIT,
+	/*
+	 * Invalid R_Key. An incoming request contained an R_Key that
+	 * did not reference a valid MR/MW. This error may be detected
+	 * by the RX engine for RDMA write or by the TX engine for RDMA
+	 * read (detected while servicing IRRQ). This is an RX Detected
+	 * Error.
+	 */
+	CFCQ_RES_ERR_STATE_REASON_RES_RX_INVALID_R_KEY,
+	/*
+	 * Domain error. An incoming request specified an R_Key which
+	 * referenced a MR/MW that was not in the same PD as the QP on
+	 * which the request arrived. This is an RX Detected Error.
+	 */
+	CFCQ_RES_ERR_STATE_REASON_RES_RX_DOMAIN_ERROR,
+	/*
+	 * No permission. An incoming request contained an R_Key that
+	 * referenced a MR/MW which did not have the access permission
+	 * needed for the operation. This is an RX Detected Error.
+	 */
+	CFCQ_RES_ERR_STATE_REASON_RES_RX_NO_PERMISSION,
+	/*
+	 * Range error. An incoming request had a combination of R_Key,
+	 * VA, and length that was out of bounds of the associated
+	 * MR/MW. This is an RX Detected Error.
+	 */
+	CFCQ_RES_ERR_STATE_REASON_RES_RX_RANGE_ERROR,
+	/*
+	 * Invalid R_Key. An incoming request contained an R_Key that
+	 * did not reference a valid MR/MW. This error may be detected
+	 * by the RX engine for RDMA write or by the TX engine for RDMA
+	 * read (detected while servicing IRRQ). This is a TX Detected
+	 * Error.
+	 */
+	CFCQ_RES_ERR_STATE_REASON_RES_TX_INVALID_R_KEY,
+	/*
+	 * Domain error. An incoming request specified an R_Key which
+	 * referenced a MR/MW that was not in the same PD as the QP on
+	 * which the request arrived. This is a TX Detected Error.
+	 */
+	CFCQ_RES_ERR_STATE_REASON_RES_TX_DOMAIN_ERROR,
+	/*
+	 * No permission. An incoming request contained an R_Key that
+	 * referenced a MR/MW which did not have the access permission
+	 * needed for the operation. This is a TX Detected Error.
+	 */
+	CFCQ_RES_ERR_STATE_REASON_RES_TX_NO_PERMISSION,
+	/*
+	 * Range error. An incoming request had a combination of R_Key,
+	 * VA, and length that was out of bounds of the associated
+	 * MR/MW. This is a TX Detected Error.
+	 */
+	CFCQ_RES_ERR_STATE_REASON_RES_TX_RANGE_ERROR,
+	/*
+	 * IRRQ overflow. The peer sent us more RDMA read or atomic
+	 * requests than the negotiated maximum. This is an RX Detected
+	 * Error.
+	 */
+	CFCQ_RES_ERR_STATE_REASON_RES_IRRQ_OFLOW,
+	/*
+	 * Unsupported opcode. The peer sent us a request with an opcode
+	 * for a request type that is not supported on this QP. This is
+	 * an RX Detected Error.
+	 */
+	CFCQ_RES_ERR_STATE_REASON_RES_UNSUPPORTED_OPCODE,
+	/*
+	 * Unaligned atomic operation. The VA of an atomic request is on
+	 * a memory boundary that prevents atomic execution. This is an
+	 * RX Detected Error.
+	 */
+	CFCQ_RES_ERR_STATE_REASON_RES_UNALIGN_ATOMIC,
+	/*
+	 * Remote invalidate error. A send with invalidate request
+	 * arrived in which the R_Key to invalidate did not describe a
+	 * MR/MW which could be invalidated. RQ WQE completes with error
+	 * status. This error is only reported if the send operation did
+	 * not fail. If the send operation failed then the remote
+	 * invalidate error is not reported. This is an RX Detected
+	 * Error.
+	 */
+	CFCQ_RES_ERR_STATE_REASON_RES_REM_INVALIDATE,
+	/*
+	 * Local memory error. An RQ/SRQ SGE described an inaccessible
+	 * memory. This is an RX Detected Error.
+	 */
+	CFCQ_RES_ERR_STATE_REASON_RES_MEMORY_ERROR,
+	/*
+	 * SRQ in error. The QP is moving to error state because it
+	 * found SRQ it uses in error. This is an RX Detected Error.
+	 */
+	CFCQ_RES_ERR_STATE_REASON_RES_SRQ_ERROR,
+	/*
+	 * Completion error. No CQE space available on queue or CQ not
+	 * in VALID state. This is a Completion Detected Error.
+	 */
+	CFCQ_RES_ERR_STATE_REASON_RES_CMP_ERROR,
+	/*
+	 * Invalid R_Key while resending responses to duplicate request.
+	 * This is a TX Detected Error.
+	 */
+	CFCQ_RES_ERR_STATE_REASON_RES_IVALID_DUP_RKEY,
+	/*
+	 * Problem was found in the format of a WQE in the RQ/SRQ. This
+	 * is an RX Detected Error.
+	 */
+	CFCQ_RES_ERR_STATE_REASON_RES_WQE_FORMAT_ERROR,
+	/*
+	 * A load error occurred on an attempt to load the CQ Context.
+	 * This is a Completion Detected Error.
+	 */
+	CFCQ_RES_ERR_STATE_REASON_RES_CQ_LOAD_ERROR = 0x18,
+	/*
+	 * A load error occurred on an attempt to load the SRQ Context.
+	 * This is an RX Detected Error.
+	 */
+	CFCQ_RES_ERR_STATE_REASON_RES_SRQ_LOAD_ERROR,
+	/*
+	 * A fatal error was detected on an attempt to read from or
+	 * write to PCIe on the transmit side. This error is detected by
+	 * the TX side, but has the priority of a Completion Detected
+	 * Error.
+	 */
+	CFCQ_RES_ERR_STATE_REASON_RES_TX_PCI_ERROR = 0x1b,
+	/*
+	 * A fatal error was detected on an attempt to read from or
+	 * write to PCIe on the receive side. This error is detected by
+	 * the RX side (or CAGR), but has the priority of a Completion
+	 * Detected Error.
+	 */
+	CFCQ_RES_ERR_STATE_REASON_RES_RX_PCI_ERROR = 0x1c
+};
+
+int bnxt_re_host_pf_id_query(struct bnxt_re_dev *rdev,
+			     struct bnxt_qplib_query_fn_info *fn_info,
+			     u32 *pf_mask, u32 *first_pf);
+
+/* Default DCBx and CC values */
+#define BNXT_RE_DEFAULT_CNP_DSCP	48
+#define BNXT_RE_DEFAULT_CNP_PRI		7
+#define BNXT_RE_DEFAULT_ROCE_DSCP	26
+#define BNXT_RE_DEFAULT_ROCE_PRI	3
+
+#define BNXT_RE_DEFAULT_L2_BW		50
+#define BNXT_RE_DEFAULT_ROCE_BW		50
+
+#define ROCE_PRIO_VALID	0x0
+#define CNP_PRIO_VALID	0x1
+#define ROCE_DSCP_VALID	0x0
+#define CNP_DSCP_VALID	0x1
+
+int bnxt_re_get_pri_dscp_settings(struct bnxt_re_dev *rdev,
+				  u16 target_id,
+				  struct bnxt_re_tc_rec *tc_rec);
+
+int bnxt_re_setup_dscp(struct bnxt_re_dev *rdev);
+int bnxt_re_clear_dscp(struct bnxt_re_dev *rdev);
+int bnxt_re_setup_cnp_cos(struct bnxt_re_dev *rdev, bool reset);
+
+static inline enum ib_port_state bnxt_re_get_link_state(struct bnxt_re_dev *rdev)
+{
+	if (rdev->netdev->if_drv_flags & IFF_DRV_RUNNING &&
+	    rdev->netdev->if_link_state == LINK_STATE_UP)
+		return IB_PORT_ACTIVE;
+	return IB_PORT_DOWN;
+}
+
+static inline int bnxt_re_link_state(struct bnxt_re_dev *rdev)
+{
+	return bnxt_re_get_link_state(rdev) == IB_PORT_ACTIVE ? 1:0;
+}
+
+static inline int is_cc_enabled(struct bnxt_re_dev *rdev)
+{
+	return rdev->cc_param.enable;
+}
+
+static inline void bnxt_re_init_hwrm_hdr(struct bnxt_re_dev *rdev,
+					 struct input *hdr, u16 opcd,
+					 u16 crid, u16 trid)
+{
+	hdr->req_type = cpu_to_le16(opcd);
+	hdr->cmpl_ring = cpu_to_le16(crid);
+	hdr->target_id = cpu_to_le16(trid);
+}
+
+static inline void bnxt_re_fill_fw_msg(struct bnxt_fw_msg *fw_msg,
+				       void *msg, int msg_len, void *resp,
+				       int resp_max_len, int timeout)
+{
+	fw_msg->msg = msg;
+	fw_msg->msg_len = msg_len;
+	fw_msg->resp = resp;
+	fw_msg->resp_max_len = resp_max_len;
+	fw_msg->timeout = timeout;
+}
+
+static inline bool is_qport_service_type_supported(struct bnxt_re_dev *rdev)
+{
+	return rdev->tc_rec[0].serv_type_enabled;
+}
+
+static inline bool is_bnxt_roce_queue(struct bnxt_re_dev *rdev, u8 ser_prof, u8 prof_type)
+{
+	if (is_qport_service_type_supported(rdev))
+		return (prof_type & HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID1_SERVICE_PROFILE_TYPE_ROCE);
+	else
+		return (ser_prof == HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_LOSSLESS_ROCE);
+}
+
+static inline bool is_bnxt_cnp_queue(struct bnxt_re_dev *rdev, u8 ser_prof, u8 prof_type)
+{
+	if (is_qport_service_type_supported(rdev))
+		return (prof_type & HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID1_SERVICE_PROFILE_TYPE_CNP);
+	else
+		return (ser_prof == HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_LOSSY_ROCE_CNP);
+}
+
+#define BNXT_RE_MAP_SH_PAGE		0x0
+#define BNXT_RE_MAP_WC			0x1
+#define BNXT_RE_DBR_PAGE		0x2
+#define BNXT_RE_MAP_DB_RECOVERY_PAGE	0x3
+
+#define BNXT_RE_DBR_RECOV_USERLAND_TIMEOUT (20)  /*  20 ms */
+#define BNXT_RE_DBR_INT_TIME 5 /* ms */
+#define BNXT_RE_PACING_EN_INT_THRESHOLD 50 /* Entries in DB FIFO */
+#define BNXT_RE_PACING_ALGO_THRESHOLD 250 /* Entries in DB FIFO */
+/* Percentage of DB FIFO depth */
+#define BNXT_RE_PACING_DBQ_THRESHOLD BNXT_RE_PACING_DBQ_HIGH_WATERMARK
+
+#define BNXT_RE_PACING_ALARM_TH_MULTIPLE(ctx) (_is_chip_p7(ctx) ? 0 : 2)
+
+/*
+ * Maximum Percentage of configurable DB FIFO depth.
+ * The Doorbell FIFO depth is 0x2c00. But the DBR_REG_DB_THROTTLING register has only 12 bits
+ * to program the high watermark. This means user can configure maximum 36% only(4095/11264).
+ */
+#define BNXT_RE_PACING_DBQ_HIGH_WATERMARK 36
+
+/* Default do_pacing value when there is no congestion */
+#define BNXT_RE_DBR_DO_PACING_NO_CONGESTION 0x7F /* 1 in 512 probability */
+
+enum {
+	BNXT_RE_DBQ_EVENT_SCHED = 0,
+	BNXT_RE_DBR_PACING_EVENT = 1,
+	BNXT_RE_DBR_NQ_PACING_NOTIFICATION = 2,
+};
+
+struct bnxt_re_dbq_work {
+	struct work_struct work;
+	struct bnxt_re_dev *rdev;
+	struct hwrm_async_event_cmpl cmpl;
+	u32 event;
+};
+
+int bnxt_re_hwrm_qcaps(struct bnxt_re_dev *rdev);
+int bnxt_re_enable_dbr_pacing(struct bnxt_re_dev *rdev);
+int bnxt_re_disable_dbr_pacing(struct bnxt_re_dev *rdev);
+int bnxt_re_set_dbq_throttling_reg(struct bnxt_re_dev *rdev,
+				   u16 nq_id, u32 throttle);
+void bnxt_re_pacing_alert(struct bnxt_re_dev *rdev);
+int bnxt_re_hwrm_pri2cos_qcfg(struct bnxt_re_dev *rdev, struct bnxt_re_tc_rec *tc_rec,
+			      u16 target_id);
+void writel_fbsd(struct bnxt_softc *bp, u32, u8, u32);
+u32 readl_fbsd(struct bnxt_softc *bp, u32, u8);
+
+static inline unsigned int bnxt_re_get_total_mr_mw_count(struct bnxt_re_dev *rdev)
+{
+	return (atomic_read(&rdev->stats.rsors.mr_count) +
+		atomic_read(&rdev->stats.rsors.mw_count));
+}
+
+static inline void bnxt_re_set_def_pacing_threshold(struct bnxt_re_dev *rdev)
+{
+	rdev->qplib_res.pacing_data->pacing_th = rdev->pacing_algo_th;
+	rdev->qplib_res.pacing_data->alarm_th =
+		rdev->pacing_algo_th * BNXT_RE_PACING_ALARM_TH_MULTIPLE(rdev->chip_ctx);
+}
+
+static inline void bnxt_re_set_def_do_pacing(struct bnxt_re_dev *rdev)
+{
+	rdev->qplib_res.pacing_data->do_pacing = rdev->dbr_def_do_pacing;
+}
+
+static inline void bnxt_re_set_pacing_dev_state(struct bnxt_re_dev *rdev)
+{
+	rdev->qplib_res.pacing_data->dev_err_state =
+		test_bit(BNXT_RE_FLAG_ERR_DEVICE_DETACHED, &rdev->flags);
+}
+#endif
diff --git a/sys/dev/bnxt/bnxt_re/ib_verbs.c b/sys/dev/bnxt/bnxt_re/ib_verbs.c
new file mode 100644
index 000000000000..8d43fa96c048
--- /dev/null
+++ b/sys/dev/bnxt/bnxt_re/ib_verbs.c
@@ -0,0 +1,5498 @@
+/*
+ * Copyright (c) 2015-2024, Broadcom. All rights reserved.  The term
+ * Broadcom refers to Broadcom Limited and/or its subsidiaries.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Description: IB Verbs interpreter
+ */
+
+#include <linux/if_ether.h>
+#include <linux/etherdevice.h>
+#include <rdma/uverbs_ioctl.h>
+
+#include "bnxt_re.h"
+#include "ib_verbs.h"
+
+static inline
+struct scatterlist *get_ib_umem_sgl(struct ib_umem *umem, u32 *nmap)
+{
+
+	*nmap = umem->nmap;
+	return umem->sg_head.sgl;
+}
+
+static inline void bnxt_re_peer_mem_release(struct ib_umem *umem)
+{
+	dev_dbg(NULL, "ib_umem_release getting invoked \n");
+	ib_umem_release(umem);
+}
+
+void bnxt_re_resolve_dmac_task(struct work_struct *work)
+{
+	int rc = -1;
+	struct bnxt_re_dev *rdev;
+	struct ib_ah_attr	*ah_attr;
+	struct bnxt_re_resolve_dmac_work *dmac_work =
+			container_of(work, struct bnxt_re_resolve_dmac_work, work);
+
+	rdev = dmac_work->rdev;
+	ah_attr = dmac_work->ah_attr;
+	rc = ib_resolve_eth_dmac(&rdev->ibdev, ah_attr);
+	if (rc)
+		dev_err(rdev_to_dev(dmac_work->rdev),
+			"Failed to resolve dest mac rc = %d\n", rc);
+	atomic_set(&dmac_work->status_wait, rc << 8);
+}
+
+static int __from_ib_access_flags(int iflags)
+{
+	int qflags = 0;
+
+	if (iflags & IB_ACCESS_LOCAL_WRITE)
+		qflags |= BNXT_QPLIB_ACCESS_LOCAL_WRITE;
+	if (iflags & IB_ACCESS_REMOTE_READ)
+		qflags |= BNXT_QPLIB_ACCESS_REMOTE_READ;
+	if (iflags & IB_ACCESS_REMOTE_WRITE)
+		qflags |= BNXT_QPLIB_ACCESS_REMOTE_WRITE;
+	if (iflags & IB_ACCESS_REMOTE_ATOMIC)
+		qflags |= BNXT_QPLIB_ACCESS_REMOTE_ATOMIC;
+	if (iflags & IB_ACCESS_MW_BIND)
+		qflags |= BNXT_QPLIB_ACCESS_MW_BIND;
+	if (iflags & IB_ZERO_BASED)
+		qflags |= BNXT_QPLIB_ACCESS_ZERO_BASED;
+	if (iflags & IB_ACCESS_ON_DEMAND)
+		qflags |= BNXT_QPLIB_ACCESS_ON_DEMAND;
+	return qflags;
+};
+
+static enum ib_access_flags __to_ib_access_flags(int qflags)
+{
+	enum ib_access_flags iflags = 0;
+
+	if (qflags & BNXT_QPLIB_ACCESS_LOCAL_WRITE)
+		iflags |= IB_ACCESS_LOCAL_WRITE;
+	if (qflags & BNXT_QPLIB_ACCESS_REMOTE_WRITE)
+		iflags |= IB_ACCESS_REMOTE_WRITE;
+	if (qflags & BNXT_QPLIB_ACCESS_REMOTE_READ)
+		iflags |= IB_ACCESS_REMOTE_READ;
+	if (qflags & BNXT_QPLIB_ACCESS_REMOTE_ATOMIC)
+		iflags |= IB_ACCESS_REMOTE_ATOMIC;
+	if (qflags & BNXT_QPLIB_ACCESS_MW_BIND)
+		iflags |= IB_ACCESS_MW_BIND;
+	if (qflags & BNXT_QPLIB_ACCESS_ZERO_BASED)
+		iflags |= IB_ZERO_BASED;
+	if (qflags & BNXT_QPLIB_ACCESS_ON_DEMAND)
+		iflags |= IB_ACCESS_ON_DEMAND;
+	return iflags;
+};
+
+static int bnxt_re_copy_to_udata(struct bnxt_re_dev *rdev, void *data,
+				 int len, struct ib_udata *udata)
+{
+	int rc;
+
+	rc = ib_copy_to_udata(udata, data, len);
+	if (rc)
+		dev_err(rdev_to_dev(rdev),
+			"ucontext copy failed from %ps rc %d\n",
+			__builtin_return_address(0), rc);
+
+	return rc;
+}
+
+struct ifnet *bnxt_re_get_netdev(struct ib_device *ibdev,
+				 u8 port_num)
+{
+	struct bnxt_re_dev *rdev = to_bnxt_re_dev(ibdev, ibdev);
+	struct ifnet *netdev = NULL;
+
+	rcu_read_lock();
+
+	if (!rdev || !rdev->netdev)
+		goto end;
+
+	netdev = rdev->netdev;
+
+	/* In case of active-backup bond mode, return active slave */
+	if (netdev)
+		dev_hold(netdev);
+
+end:
+	rcu_read_unlock();
+	return netdev;
+}
+
+int bnxt_re_query_device(struct ib_device *ibdev,
+			 struct ib_device_attr *ib_attr,
+			 struct ib_udata *udata)
+{
+	struct bnxt_re_dev *rdev = to_bnxt_re_dev(ibdev, ibdev);
+	struct bnxt_qplib_dev_attr *dev_attr = rdev->dev_attr;
+
+	memset(ib_attr, 0, sizeof(*ib_attr));
+
+	memcpy(&ib_attr->fw_ver, dev_attr->fw_ver, 4);
+	bnxt_qplib_get_guid(rdev->dev_addr, (u8 *)&ib_attr->sys_image_guid);
+	ib_attr->max_mr_size = BNXT_RE_MAX_MR_SIZE;
+	ib_attr->page_size_cap = dev_attr->page_size_cap;
+	ib_attr->vendor_id = rdev->en_dev->pdev->vendor;
+	ib_attr->vendor_part_id = rdev->en_dev->pdev->device;
+	ib_attr->hw_ver = rdev->en_dev->pdev->subsystem_device;
+	ib_attr->max_qp = dev_attr->max_qp;
+	ib_attr->max_qp_wr = dev_attr->max_qp_wqes;
+	/*
+	 * Read and set from the module param 'min_tx_depth'
+	 * only once after the driver load
+	 */
+	if (rdev->min_tx_depth == 1 &&
+	    min_tx_depth < dev_attr->max_qp_wqes)
+		rdev->min_tx_depth = min_tx_depth;
+	ib_attr->device_cap_flags =
+				    IB_DEVICE_CURR_QP_STATE_MOD
+				    | IB_DEVICE_RC_RNR_NAK_GEN
+				    | IB_DEVICE_SHUTDOWN_PORT
+				    | IB_DEVICE_SYS_IMAGE_GUID
+				    | IB_DEVICE_LOCAL_DMA_LKEY
+				    | IB_DEVICE_RESIZE_MAX_WR
+				    | IB_DEVICE_PORT_ACTIVE_EVENT
+				    | IB_DEVICE_N_NOTIFY_CQ
+				    | IB_DEVICE_MEM_WINDOW
+				    | IB_DEVICE_MEM_WINDOW_TYPE_2B
+				    | IB_DEVICE_MEM_MGT_EXTENSIONS;
+	ib_attr->max_send_sge = dev_attr->max_qp_sges;
+	ib_attr->max_recv_sge = dev_attr->max_qp_sges;
+	ib_attr->max_sge_rd = dev_attr->max_qp_sges;
+	ib_attr->max_cq = dev_attr->max_cq;
+	ib_attr->max_cqe = dev_attr->max_cq_wqes;
+	ib_attr->max_mr = dev_attr->max_mr;
+	ib_attr->max_pd = dev_attr->max_pd;
+	ib_attr->max_qp_rd_atom = dev_attr->max_qp_rd_atom;
+	ib_attr->max_qp_init_rd_atom = dev_attr->max_qp_init_rd_atom;
+	if (dev_attr->is_atomic) {
+		ib_attr->atomic_cap = IB_ATOMIC_GLOB;
+		ib_attr->masked_atomic_cap = IB_ATOMIC_GLOB;
+	}
+	ib_attr->max_ee_rd_atom = 0;
+	ib_attr->max_res_rd_atom = 0;
+	ib_attr->max_ee_init_rd_atom = 0;
+	ib_attr->max_ee = 0;
+	ib_attr->max_rdd = 0;
+	ib_attr->max_mw = dev_attr->max_mw;
+	ib_attr->max_raw_ipv6_qp = 0;
+	ib_attr->max_raw_ethy_qp = dev_attr->max_raw_ethy_qp;
+	ib_attr->max_mcast_grp = 0;
+	ib_attr->max_mcast_qp_attach = 0;
+	ib_attr->max_total_mcast_qp_attach = 0;
+	ib_attr->max_ah = dev_attr->max_ah;
+	ib_attr->max_srq = dev_attr->max_srq;
+	ib_attr->max_srq_wr = dev_attr->max_srq_wqes;
+	ib_attr->max_srq_sge = dev_attr->max_srq_sges;
+
+	ib_attr->max_fast_reg_page_list_len = MAX_PBL_LVL_1_PGS;
+	ib_attr->max_pkeys = 1;
+	ib_attr->local_ca_ack_delay = BNXT_RE_DEFAULT_ACK_DELAY;
+	ib_attr->sig_prot_cap = 0;
+	ib_attr->sig_guard_cap = 0;
+	ib_attr->odp_caps.general_caps = 0;
+
+	return 0;
+}
+
+int bnxt_re_modify_device(struct ib_device *ibdev,
+			  int device_modify_mask,
+			  struct ib_device_modify *device_modify)
+{
+	dev_dbg(rdev_to_dev(rdev), "Modify device with mask 0x%x\n",
+		device_modify_mask);
+
+	switch (device_modify_mask) {
+	case IB_DEVICE_MODIFY_SYS_IMAGE_GUID:
+		/* Modify the GUID requires the modification of the GID table */
+		/* GUID should be made as READ-ONLY */
+		break;
+	case IB_DEVICE_MODIFY_NODE_DESC:
+		/* Node Desc should be made as READ-ONLY */
+		break;
+	default:
+		break;
+	}
+	return 0;
+}
+
+static void __to_ib_speed_width(u32 espeed, u8 *speed, u8 *width)
+{
+	switch (espeed) {
+	case SPEED_1000:
+		*speed = IB_SPEED_SDR;
+		*width = IB_WIDTH_1X;
+		break;
+	case SPEED_10000:
+		*speed = IB_SPEED_QDR;
+		*width = IB_WIDTH_1X;
+		break;
+	case SPEED_20000:
+		*speed = IB_SPEED_DDR;
+		*width = IB_WIDTH_4X;
+		break;
+	case SPEED_25000:
+		*speed = IB_SPEED_EDR;
+		*width = IB_WIDTH_1X;
+		break;
+	case SPEED_40000:
+		*speed = IB_SPEED_QDR;
+		*width = IB_WIDTH_4X;
+		break;
+	case SPEED_50000:
+		*speed = IB_SPEED_EDR;
+		*width = IB_WIDTH_2X;
+		break;
+	case SPEED_100000:
+		*speed = IB_SPEED_EDR;
+		*width = IB_WIDTH_4X;
+		break;
+	case SPEED_200000:
+		*speed = IB_SPEED_HDR;
+		*width = IB_WIDTH_4X;
+		break;
+	default:
+		*speed = IB_SPEED_SDR;
+		*width = IB_WIDTH_1X;
+		break;
+	}
+}
+
+/* Port */
+int bnxt_re_query_port(struct ib_device *ibdev, u8 port_num,
+		       struct ib_port_attr *port_attr)
+{
+	struct bnxt_re_dev *rdev = to_bnxt_re_dev(ibdev, ibdev);
+	struct bnxt_qplib_dev_attr *dev_attr = rdev->dev_attr;
+	u8 active_speed = 0, active_width = 0;
+
+	dev_dbg(rdev_to_dev(rdev), "QUERY PORT with port_num 0x%x\n", port_num);
+	memset(port_attr, 0, sizeof(*port_attr));
+
+	port_attr->phys_state = IB_PORT_PHYS_STATE_DISABLED;
+	port_attr->state = bnxt_re_get_link_state(rdev);
+	if (port_attr->state == IB_PORT_ACTIVE)
+		port_attr->phys_state = IB_PORT_PHYS_STATE_LINK_UP;
+	port_attr->max_mtu = IB_MTU_4096;
+	port_attr->active_mtu = iboe_get_mtu(rdev->netdev->if_mtu);
+	port_attr->gid_tbl_len = dev_attr->max_sgid;
+	port_attr->port_cap_flags = IB_PORT_CM_SUP | IB_PORT_REINIT_SUP |
+				    IB_PORT_DEVICE_MGMT_SUP |
+				    IB_PORT_VENDOR_CLASS_SUP |
+				    IB_PORT_IP_BASED_GIDS;
+
+	port_attr->max_msg_sz = (u32)BNXT_RE_MAX_MR_SIZE_LOW;
+	port_attr->bad_pkey_cntr = 0;
+	port_attr->qkey_viol_cntr = 0;
+	port_attr->pkey_tbl_len = dev_attr->max_pkey;
+	port_attr->lid = 0;
+	port_attr->sm_lid = 0;
+	port_attr->lmc = 0;
+	port_attr->max_vl_num = 4;
+	port_attr->sm_sl = 0;
+	port_attr->subnet_timeout = 0;
+	port_attr->init_type_reply = 0;
+	rdev->espeed = rdev->en_dev->espeed;
+
+	if (test_bit(BNXT_RE_FLAG_IBDEV_REGISTERED, &rdev->flags))
+		__to_ib_speed_width(rdev->espeed, &active_speed,
+				    &active_width);
+
+	port_attr->active_speed = active_speed;
+	port_attr->active_width = active_width;
+
+	return 0;
+}
+
+int bnxt_re_modify_port(struct ib_device *ibdev, u8 port_num,
+			int port_modify_mask,
+			struct ib_port_modify *port_modify)
+{
+	dev_dbg(rdev_to_dev(rdev), "Modify port with mask 0x%x\n",
+		port_modify_mask);
+
+	switch (port_modify_mask) {
+	case IB_PORT_SHUTDOWN:
+		break;
+	case IB_PORT_INIT_TYPE:
+		break;
+	case IB_PORT_RESET_QKEY_CNTR:
+		break;
+	default:
+		break;
+	}
+	return 0;
+}
+
+int bnxt_re_get_port_immutable(struct ib_device *ibdev, u8 port_num,
+			       struct ib_port_immutable *immutable)
+{
+	struct bnxt_re_dev *rdev = to_bnxt_re_dev(ibdev, ibdev);
+	struct ib_port_attr port_attr;
+
+	if (bnxt_re_query_port(ibdev, port_num, &port_attr))
+		return -EINVAL;
+
+	immutable->pkey_tbl_len = port_attr.pkey_tbl_len;
+	immutable->gid_tbl_len = port_attr.gid_tbl_len;
+	if (rdev->roce_mode == BNXT_RE_FLAG_ROCEV1_CAP)
+		immutable->core_cap_flags = RDMA_CORE_PORT_IBA_ROCE;
+	else if (rdev->roce_mode == BNXT_RE_FLAG_ROCEV2_CAP)
+		immutable->core_cap_flags = RDMA_CORE_PORT_IBA_ROCE_UDP_ENCAP;
+	else
+		immutable->core_cap_flags = RDMA_CORE_PORT_IBA_ROCE |
+					    RDMA_CORE_PORT_IBA_ROCE_UDP_ENCAP;
+	immutable->max_mad_size = IB_MGMT_MAD_SIZE;
+	return 0;
+}
+
+void bnxt_re_compat_qfwstr(void)
+{
+	struct bnxt_re_dev *rdev = to_bnxt_re_dev(ibdev, ibdev);
+
+	sprintf(str, "%d.%d.%d.%d", rdev->dev_attr->fw_ver[0],
+		rdev->dev_attr->fw_ver[1], rdev->dev_attr->fw_ver[2],
+		rdev->dev_attr->fw_ver[3]);
+}
+
+int bnxt_re_query_pkey(struct ib_device *ibdev, u8 port_num,
+		       u16 index, u16 *pkey)
+{
+	if (index > 0)
+		return -EINVAL;
+
+	*pkey = IB_DEFAULT_PKEY_FULL;
+
+	return 0;
+}
+
+int bnxt_re_query_gid(struct ib_device *ibdev, u8 port_num,
+		      int index, union ib_gid *gid)
+{
+	struct bnxt_re_dev *rdev = to_bnxt_re_dev(ibdev, ibdev);
+	int rc = 0;
+
+	/* Ignore port_num */
+	memset(gid, 0, sizeof(*gid));
+	rc = bnxt_qplib_get_sgid(&rdev->qplib_res,
+				 &rdev->qplib_res.sgid_tbl, index,
+				 (struct bnxt_qplib_gid *)gid);
+	return rc;
+}
+
+int bnxt_re_del_gid(struct ib_device *ibdev, u8 port_num,
+		    unsigned int index, void **context)
+{
+	int rc = 0;
+	struct bnxt_re_gid_ctx *ctx, **ctx_tbl;
+	struct bnxt_re_dev *rdev = to_bnxt_re_dev(ibdev, ibdev);
+	struct bnxt_qplib_sgid_tbl *sgid_tbl = &rdev->qplib_res.sgid_tbl;
+	struct bnxt_qplib_gid *gid_to_del;
+	u16 vlan_id = 0xFFFF;
+
+	/* Delete the entry from the hardware */
+	ctx = *context;
+	if (!ctx) {
+		dev_err(rdev_to_dev(rdev), "GID entry has no ctx?!\n");
+		return -EINVAL;
+	}
+	if (sgid_tbl && sgid_tbl->active) {
+		if (ctx->idx >= sgid_tbl->max) {
+			dev_dbg(rdev_to_dev(rdev), "GID index out of range?!\n");
+			return -EINVAL;
+		}
+		gid_to_del = &sgid_tbl->tbl[ctx->idx].gid;
+		vlan_id = sgid_tbl->tbl[ctx->idx].vlan_id;
+		ctx->refcnt--;
+		/* DEL_GID is called via WQ context(netdevice_event_work_handler)
+		 * or via the ib_unregister_device path. In the former case QP1
+		 * may not be destroyed yet, in which case just return as FW
+		 * needs that entry to be present and will fail it's deletion.
+		 * We could get invoked again after QP1 is destroyed OR get an
+		 * ADD_GID call with a different GID value for the same index
+		 * where we issue MODIFY_GID cmd to update the GID entry -- TBD
+		 */
+		if (ctx->idx == 0 &&
+		    rdma_link_local_addr((struct in6_addr *)gid_to_del) &&
+		    (rdev->gsi_ctx.gsi_sqp ||
+		     rdev->gsi_ctx.gsi_qp_mode == BNXT_RE_GSI_MODE_UD)) {
+			dev_dbg(rdev_to_dev(rdev),
+				"Trying to delete GID0 while QP1 is alive\n");
+			if (!ctx->refcnt) {
+				rdev->gid_map[index] = -1;
+				ctx_tbl = sgid_tbl->ctx;
+				ctx_tbl[ctx->idx] = NULL;
+				kfree(ctx);
+			}
+			return 0;
+		}
+		rdev->gid_map[index] = -1;
+		if (!ctx->refcnt) {
+			rc = bnxt_qplib_del_sgid(sgid_tbl, gid_to_del,
+						 vlan_id, true);
+			if (!rc) {
+				dev_dbg(rdev_to_dev(rdev), "GID remove success\n");
+				ctx_tbl = sgid_tbl->ctx;
+				ctx_tbl[ctx->idx] = NULL;
+				kfree(ctx);
+			} else {
+				dev_err(rdev_to_dev(rdev),
+					"Remove GID failed rc = 0x%x\n", rc);
+			}
+		}
+	} else {
+		dev_dbg(rdev_to_dev(rdev), "GID sgid_tbl does not exist!\n");
+		return -EINVAL;
+	}
+	return rc;
+}
+
+int bnxt_re_add_gid(struct ib_device *ibdev, u8 port_num,
+		    unsigned int index, const union ib_gid *gid,
+		    const struct ib_gid_attr *attr, void **context)
+{
+	int rc;
+	u32 tbl_idx = 0;
+	u16 vlan_id = 0xFFFF;
+	struct bnxt_re_gid_ctx *ctx, **ctx_tbl;
+	struct bnxt_re_dev *rdev = to_bnxt_re_dev(ibdev, ibdev);
+	struct bnxt_qplib_sgid_tbl *sgid_tbl = &rdev->qplib_res.sgid_tbl;
+	if ((attr->ndev) && is_vlan_dev(attr->ndev))
+		vlan_id = vlan_dev_vlan_id(attr->ndev);
+
+	rc = bnxt_qplib_add_sgid(sgid_tbl, gid,
+				 rdev->dev_addr,
+				 vlan_id, true, &tbl_idx);
+	if (rc == -EALREADY) {
+		dev_dbg(rdev_to_dev(rdev), "GID %pI6 is already present\n", gid);
+		ctx_tbl = sgid_tbl->ctx;
+		if (!ctx_tbl[tbl_idx]) {
+			ctx = kmalloc(sizeof(*ctx), GFP_KERNEL);
+			if (!ctx)
+				return -ENOMEM;
+			ctx->idx = tbl_idx;
+			ctx->refcnt = 1;
+			ctx_tbl[tbl_idx] = ctx;
+		} else {
+			ctx_tbl[tbl_idx]->refcnt++;
+		}
+		*context = ctx_tbl[tbl_idx];
+		/* tbl_idx is the HW table index and index is the stack index */
+		rdev->gid_map[index] = tbl_idx;
+		return 0;
+	} else if (rc < 0) {
+		dev_err(rdev_to_dev(rdev), "Add GID failed rc = 0x%x\n", rc);
+		return rc;
+	} else {
+		ctx = kmalloc(sizeof(*ctx), GFP_KERNEL);
+		if (!ctx) {
+			dev_err(rdev_to_dev(rdev), "Add GID ctx failed\n");
+			return -ENOMEM;
+		}
+		ctx_tbl = sgid_tbl->ctx;
+		ctx->idx = tbl_idx;
+		ctx->refcnt = 1;
+		ctx_tbl[tbl_idx] = ctx;
+		/* tbl_idx is the HW table index and index is the stack index */
+		rdev->gid_map[index] = tbl_idx;
+		*context = ctx;
+	}
+	return rc;
+}
+
+enum rdma_link_layer bnxt_re_get_link_layer(struct ib_device *ibdev,
+					    u8 port_num)
+{
+	return IB_LINK_LAYER_ETHERNET;
+}
+
+static void bnxt_re_legacy_create_fence_wqe(struct bnxt_re_pd *pd)
+{
+	struct bnxt_re_legacy_fence_data *fence = &pd->fence;
+	struct ib_mr *ib_mr = &fence->mr->ib_mr;
+	struct bnxt_qplib_swqe *wqe = &fence->bind_wqe;
+	struct bnxt_re_dev *rdev = pd->rdev;
+
+	if (!_is_chip_gen_p5_p7(rdev->chip_ctx))
+		return;
+
+	memset(wqe, 0, sizeof(*wqe));
+	wqe->type = BNXT_QPLIB_SWQE_TYPE_BIND_MW;
+	wqe->wr_id = BNXT_QPLIB_FENCE_WRID;
+	wqe->flags |= BNXT_QPLIB_SWQE_FLAGS_SIGNAL_COMP;
+	wqe->flags |= BNXT_QPLIB_SWQE_FLAGS_UC_FENCE;
+	wqe->bind.zero_based = false;
+	wqe->bind.parent_l_key = ib_mr->lkey;
+	wqe->bind.va = (u64)fence->va;
+	wqe->bind.length = fence->size;
+	wqe->bind.access_cntl = __from_ib_access_flags(IB_ACCESS_REMOTE_READ);
+	wqe->bind.mw_type = SQ_BIND_MW_TYPE_TYPE1;
+
+	/* Save the initial rkey in fence structure for now;
+	 * wqe->bind.r_key will be set at (re)bind time.
+	 */
+	fence->bind_rkey = ib_inc_rkey(fence->mw->rkey);
+}
+
+static int bnxt_re_legacy_bind_fence_mw(struct bnxt_qplib_qp *qplib_qp)
+{
+	struct bnxt_re_qp *qp = container_of(qplib_qp, struct bnxt_re_qp,
+					     qplib_qp);
+	struct ib_pd *ib_pd = qp->ib_qp.pd;
+	struct bnxt_re_pd *pd = to_bnxt_re(ib_pd, struct bnxt_re_pd, ibpd);
+	struct bnxt_re_legacy_fence_data *fence = &pd->fence;
+	struct bnxt_qplib_swqe *fence_wqe = &fence->bind_wqe;
+	struct bnxt_qplib_swqe wqe;
+	int rc;
+
+	/* TODO: Need SQ locking here when Fence WQE
+	 * posting moves up into bnxt_re from bnxt_qplib.
+	 */
+	memcpy(&wqe, fence_wqe, sizeof(wqe));
+	wqe.bind.r_key = fence->bind_rkey;
+	fence->bind_rkey = ib_inc_rkey(fence->bind_rkey);
+
+	dev_dbg(rdev_to_dev(qp->rdev),
+		"Posting bind fence-WQE: rkey: %#x QP: %d PD: %p\n",
+		wqe.bind.r_key, qp->qplib_qp.id, pd);
+	rc = bnxt_qplib_post_send(&qp->qplib_qp, &wqe);
+	if (rc) {
+		dev_err(rdev_to_dev(qp->rdev), "Failed to bind fence-WQE\n");
+		return rc;
+	}
+	bnxt_qplib_post_send_db(&qp->qplib_qp);
+
+	return rc;
+}
+
+static int bnxt_re_legacy_create_fence_mr(struct bnxt_re_pd *pd)
+{
+	int mr_access_flags = IB_ACCESS_LOCAL_WRITE | IB_ACCESS_MW_BIND;
+	struct bnxt_re_legacy_fence_data *fence = &pd->fence;
+	struct bnxt_re_dev *rdev = pd->rdev;
+	struct bnxt_qplib_mrinfo mrinfo;
+	struct bnxt_re_mr *mr = NULL;
+	struct ib_mw *ib_mw = NULL;
+	dma_addr_t dma_addr = 0;
+	u32 max_mr_count;
+	u64 pbl_tbl;
+	int rc;
+
+	if (!_is_chip_gen_p5_p7(rdev->chip_ctx))
+		return 0;
+
+	memset(&mrinfo, 0, sizeof(mrinfo));
+	/* Allocate a small chunk of memory and dma-map it */
+	fence->va = kzalloc(BNXT_RE_LEGACY_FENCE_BYTES, GFP_KERNEL);
+	if (!fence->va)
+		return -ENOMEM;
+	dma_addr = ib_dma_map_single(&rdev->ibdev, fence->va,
+				     BNXT_RE_LEGACY_FENCE_BYTES,
+				     DMA_BIDIRECTIONAL);
+	rc = ib_dma_mapping_error(&rdev->ibdev, dma_addr);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev), "Failed to dma-map fence-MR-mem\n");
+		rc = -EIO;
+		fence->dma_addr = 0;
+		goto free_va;
+	}
+	fence->dma_addr = dma_addr;
+
+	/* Allocate a MR */
+	mr = kzalloc(sizeof(*mr), GFP_KERNEL);
+	if (!mr)
+		goto free_dma_addr;
+	fence->mr = mr;
+	mr->rdev = rdev;
+	mr->qplib_mr.pd = &pd->qplib_pd;
+	mr->qplib_mr.type = CMDQ_ALLOCATE_MRW_MRW_FLAGS_PMR;
+	mr->qplib_mr.flags = __from_ib_access_flags(mr_access_flags);
+	if (!_is_alloc_mr_unified(rdev->qplib_res.dattr)) {
+		rc = bnxt_qplib_alloc_mrw(&rdev->qplib_res, &mr->qplib_mr);
+		if (rc) {
+			dev_err(rdev_to_dev(rdev), "Failed to alloc fence-HW-MR\n");
+			goto free_mr;
+		}
+		/* Register MR */
+		mr->ib_mr.lkey = mr->qplib_mr.lkey;
+	}
+	mr->qplib_mr.va         = (u64)fence->va;
+	mr->qplib_mr.total_size = BNXT_RE_LEGACY_FENCE_BYTES;
+	pbl_tbl = dma_addr;
+
+	mrinfo.mrw = &mr->qplib_mr;
+	mrinfo.ptes = &pbl_tbl;
+	mrinfo.sg.npages = BNXT_RE_LEGACY_FENCE_PBL_SIZE;
+
+	mrinfo.sg.nmap = 0;
+	mrinfo.sg.sghead = 0;
+	mrinfo.sg.pgshft = PAGE_SHIFT;
+	mrinfo.sg.pgsize = PAGE_SIZE;
+	rc = bnxt_qplib_reg_mr(&rdev->qplib_res, &mrinfo, false);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev), "Failed to register fence-MR\n");
+		goto free_mr;
+	}
+	mr->ib_mr.lkey = mr->qplib_mr.lkey;
+	mr->ib_mr.rkey = mr->qplib_mr.rkey;
+	atomic_inc(&rdev->stats.rsors.mr_count);
+	max_mr_count =  atomic_read(&rdev->stats.rsors.mr_count);
+	if (max_mr_count > (atomic_read(&rdev->stats.rsors.max_mr_count)))
+		atomic_set(&rdev->stats.rsors.max_mr_count, max_mr_count);
+
+	ib_mw = bnxt_re_alloc_mw(&pd->ibpd, IB_MW_TYPE_1, NULL);
+	/* Create a fence MW only for kernel consumers */
+	if (!ib_mw) {
+		dev_err(rdev_to_dev(rdev),
+			"Failed to create fence-MW for PD: %p\n", pd);
+		rc = -EINVAL;
+		goto free_mr;
+	}
+	fence->mw = ib_mw;
+
+	bnxt_re_legacy_create_fence_wqe(pd);
+	return 0;
+
+free_mr:
+	if (mr->ib_mr.lkey) {
+		bnxt_qplib_free_mrw(&rdev->qplib_res, &mr->qplib_mr);
+		atomic_dec(&rdev->stats.rsors.mr_count);
+	}
+	kfree(mr);
+	fence->mr = NULL;
+
+free_dma_addr:
+	ib_dma_unmap_single(&rdev->ibdev, fence->dma_addr,
+			    BNXT_RE_LEGACY_FENCE_BYTES, DMA_BIDIRECTIONAL);
+	fence->dma_addr = 0;
+
+free_va:
+	kfree(fence->va);
+	fence->va = NULL;
+	return rc;
+}
+
+static void bnxt_re_legacy_destroy_fence_mr(struct bnxt_re_pd *pd)
+{
+	struct bnxt_re_legacy_fence_data *fence = &pd->fence;
+	struct bnxt_re_dev *rdev = pd->rdev;
+	struct bnxt_re_mr *mr = fence->mr;
+
+	if (!_is_chip_gen_p5_p7(rdev->chip_ctx))
+		return;
+
+	if (fence->mw) {
+		bnxt_re_dealloc_mw(fence->mw);
+		fence->mw = NULL;
+	}
+	if (mr) {
+		if (mr->ib_mr.rkey)
+			bnxt_qplib_dereg_mrw(&rdev->qplib_res, &mr->qplib_mr,
+					     false);
+		if (mr->ib_mr.lkey)
+			bnxt_qplib_free_mrw(&rdev->qplib_res, &mr->qplib_mr);
+		kfree(mr);
+		fence->mr = NULL;
+		atomic_dec(&rdev->stats.rsors.mr_count);
+	}
+	if (fence->dma_addr) {
+		ib_dma_unmap_single(&rdev->ibdev, fence->dma_addr,
+				    BNXT_RE_LEGACY_FENCE_BYTES,
+				    DMA_BIDIRECTIONAL);
+		fence->dma_addr = 0;
+	}
+	kfree(fence->va);
+	fence->va = NULL;
+}
+
+
+static int bnxt_re_get_user_dpi(struct bnxt_re_dev *rdev,
+				struct bnxt_re_ucontext *cntx)
+{
+	struct bnxt_qplib_chip_ctx *cctx = rdev->chip_ctx;
+	int ret = 0;
+	u8 type;
+	/* Allocate DPI in alloc_pd or in create_cq to avoid failing of
+	 * ibv_devinfo and family of application when DPIs are depleted.
+	 */
+	type = BNXT_QPLIB_DPI_TYPE_UC;
+	ret = bnxt_qplib_alloc_dpi(&rdev->qplib_res, &cntx->dpi, cntx, type);
+	if (ret) {
+		dev_err(rdev_to_dev(rdev), "Alloc doorbell page failed!\n");
+		goto out;
+	}
+
+	if (cctx->modes.db_push) {
+		type = BNXT_QPLIB_DPI_TYPE_WC;
+		ret = bnxt_qplib_alloc_dpi(&rdev->qplib_res, &cntx->wcdpi,
+					   cntx, type);
+		if (ret)
+			dev_err(rdev_to_dev(rdev), "push dp alloc failed\n");
+	}
+out:
+	return ret;
+}
+
+/* Protection Domains */
+void bnxt_re_dealloc_pd(struct ib_pd *ib_pd, struct ib_udata *udata)
+{
+	struct bnxt_re_pd *pd = to_bnxt_re(ib_pd, struct bnxt_re_pd, ibpd);
+	struct bnxt_re_dev *rdev = pd->rdev;
+	int rc;
+
+	bnxt_re_legacy_destroy_fence_mr(pd);
+
+	rc = bnxt_qplib_dealloc_pd(&rdev->qplib_res,
+				   &rdev->qplib_res.pd_tbl,
+				   &pd->qplib_pd);
+	if (rc)
+		dev_err_ratelimited(rdev_to_dev(rdev),
+				    "%s failed rc = %d\n", __func__, rc);
+	atomic_dec(&rdev->stats.rsors.pd_count);
+
+	return;
+}
+
+int bnxt_re_alloc_pd(struct ib_pd *pd_in,
+		     struct ib_udata *udata)
+{
+	struct ib_pd *ibpd = pd_in;
+	struct ib_device *ibdev = ibpd->device;
+	struct bnxt_re_dev *rdev = to_bnxt_re_dev(ibdev, ibdev);
+	struct bnxt_re_ucontext *ucntx =
+		rdma_udata_to_drv_context(udata, struct bnxt_re_ucontext,
+					  ibucontext);
+	u32 max_pd_count;
+	int rc;
+	struct bnxt_re_pd *pd = container_of(ibpd, struct bnxt_re_pd, ibpd);
+
+	pd->rdev = rdev;
+	if (bnxt_qplib_alloc_pd(&rdev->qplib_res, &pd->qplib_pd)) {
+		dev_err(rdev_to_dev(rdev),
+			"Allocate HW Protection Domain failed!\n");
+		rc = -ENOMEM;
+		goto fail;
+	}
+
+	if (udata) {
+		struct bnxt_re_pd_resp resp = {};
+
+		if (!ucntx->dpi.dbr) {
+			rc = bnxt_re_get_user_dpi(rdev, ucntx);
+			if (rc)
+				goto dbfail;
+		}
+
+		resp.pdid = pd->qplib_pd.id;
+		/* Still allow mapping this DBR to the new user PD. */
+		resp.dpi = ucntx->dpi.dpi;
+		resp.dbr = (u64)ucntx->dpi.umdbr;
+		/* Copy only on a valid wcpdi */
+		if (ucntx->wcdpi.dpi) {
+			resp.wcdpi = ucntx->wcdpi.dpi;
+			resp.comp_mask = BNXT_RE_COMP_MASK_PD_HAS_WC_DPI;
+		}
+		if (rdev->dbr_pacing) {
+			WARN_ON(!rdev->dbr_bar_addr);
+			resp.dbr_bar_addr = (u64)rdev->dbr_bar_addr;
+			resp.comp_mask |= BNXT_RE_COMP_MASK_PD_HAS_DBR_BAR_ADDR;
+		}
+
+		rc = bnxt_re_copy_to_udata(rdev, &resp,
+					   min(udata->outlen, sizeof(resp)),
+					   udata);
+		if (rc)
+			goto dbfail;
+	}
+
+	if (!udata)
+		if (bnxt_re_legacy_create_fence_mr(pd))
+			dev_warn(rdev_to_dev(rdev),
+				 "Failed to create Fence-MR\n");
+
+	atomic_inc(&rdev->stats.rsors.pd_count);
+	max_pd_count = atomic_read(&rdev->stats.rsors.pd_count);
+	if (max_pd_count > atomic_read(&rdev->stats.rsors.max_pd_count))
+		atomic_set(&rdev->stats.rsors.max_pd_count, max_pd_count);
+
+	return 0;
+dbfail:
+	(void)bnxt_qplib_dealloc_pd(&rdev->qplib_res, &rdev->qplib_res.pd_tbl,
+				    &pd->qplib_pd);
+fail:
+	return rc;
+}
+
+/* Address Handles */
+void bnxt_re_destroy_ah(struct ib_ah *ib_ah, u32 flags)
+{
+	struct bnxt_re_ah *ah = to_bnxt_re(ib_ah, struct bnxt_re_ah, ibah);
+	struct bnxt_re_dev *rdev = ah->rdev;
+	int rc = 0;
+	bool block = true;
+
+	block = !(flags & RDMA_DESTROY_AH_SLEEPABLE);
+
+	rc = bnxt_qplib_destroy_ah(&rdev->qplib_res, &ah->qplib_ah, block);
+	if (rc)
+		dev_err_ratelimited(rdev_to_dev(rdev),
+				   "%s id = %d blocking %d failed rc = %d\n",
+				    __func__, ah->qplib_ah.id, block, rc);
+	atomic_dec(&rdev->stats.rsors.ah_count);
+
+	return;
+}
+
+static u8 _to_bnxt_re_nw_type(enum rdma_network_type ntype)
+{
+	u8 nw_type;
+	switch (ntype) {
+		case RDMA_NETWORK_IPV4:
+			nw_type = CMDQ_CREATE_AH_TYPE_V2IPV4;
+			break;
+		case RDMA_NETWORK_IPV6:
+			nw_type = CMDQ_CREATE_AH_TYPE_V2IPV6;
+			break;
+		default:
+			nw_type = CMDQ_CREATE_AH_TYPE_V1;
+			break;
+	}
+	return nw_type;
+}
+
+static inline int
+bnxt_re_get_cached_gid(struct ib_device *dev, u8 port_num, int index,
+		       union ib_gid *sgid, struct ib_gid_attr **sgid_attr,
+		       struct ib_global_route *grh, struct ib_ah *ah)
+{
+	int ret = 0;
+
+	ret = ib_get_cached_gid(dev, port_num, index, sgid, *sgid_attr);
+	return ret;
+}
+
+static inline enum rdma_network_type
+bnxt_re_gid_to_network_type(struct ib_gid_attr *sgid_attr,
+			    union ib_gid *sgid)
+{
+	return ib_gid_to_network_type(sgid_attr->gid_type, sgid);
+}
+
+static int bnxt_re_get_ah_info(struct bnxt_re_dev *rdev,
+			       struct ib_ah_attr *ah_attr,
+			       struct bnxt_re_ah_info *ah_info)
+{
+	struct ib_gid_attr *gattr;
+	enum rdma_network_type ib_ntype;
+	u8 ntype;
+	union ib_gid *gid;
+	int rc = 0;
+
+	gid = &ah_info->sgid;
+	gattr = &ah_info->sgid_attr;
+
+	rc = bnxt_re_get_cached_gid(&rdev->ibdev, 1, ah_attr->grh.sgid_index,
+				    gid, &gattr, &ah_attr->grh, NULL);
+	if (rc)
+		return rc;
+
+	/* Get vlan tag */
+	if (gattr->ndev) {
+		if (is_vlan_dev(gattr->ndev))
+			ah_info->vlan_tag = vlan_dev_vlan_id(gattr->ndev);
+		if_rele(gattr->ndev);
+	}
+
+	/* Get network header type for this GID */
+
+	ib_ntype = bnxt_re_gid_to_network_type(gattr, gid);
+	ntype = _to_bnxt_re_nw_type(ib_ntype);
+	ah_info->nw_type = ntype;
+
+	return rc;
+}
+
+static u8 _get_sgid_index(struct bnxt_re_dev *rdev, u8 gindx)
+{
+	gindx = rdev->gid_map[gindx];
+	return gindx;
+}
+
+static int bnxt_re_init_dmac(struct bnxt_re_dev *rdev, struct ib_ah_attr *ah_attr,
+			     struct bnxt_re_ah_info *ah_info, bool is_user,
+			     struct bnxt_re_ah *ah)
+{
+	int rc = 0;
+	u8 *dmac;
+
+	if (is_user && !rdma_is_multicast_addr((struct in6_addr *)
+						ah_attr->grh.dgid.raw) &&
+	    !rdma_link_local_addr((struct in6_addr *)ah_attr->grh.dgid.raw)) {
+
+		u32 retry_count = BNXT_RE_RESOLVE_RETRY_COUNT_US;
+		struct bnxt_re_resolve_dmac_work *resolve_dmac_work;
+
+
+		resolve_dmac_work = kzalloc(sizeof(*resolve_dmac_work), GFP_ATOMIC);
+
+		resolve_dmac_work->rdev = rdev;
+		resolve_dmac_work->ah_attr = ah_attr;
+		resolve_dmac_work->ah_info = ah_info;
+
+		atomic_set(&resolve_dmac_work->status_wait, 1);
+		INIT_WORK(&resolve_dmac_work->work, bnxt_re_resolve_dmac_task);
+		queue_work(rdev->resolve_wq, &resolve_dmac_work->work);
+
+		do {
+			rc = atomic_read(&resolve_dmac_work->status_wait) & 0xFF;
+			if (!rc)
+				break;
+			udelay(1);
+		} while (--retry_count);
+		if (atomic_read(&resolve_dmac_work->status_wait)) {
+			INIT_LIST_HEAD(&resolve_dmac_work->list);
+			list_add_tail(&resolve_dmac_work->list,
+					&rdev->mac_wq_list);
+			return -EFAULT;
+		}
+		kfree(resolve_dmac_work);
+	}
+	dmac = ROCE_DMAC(ah_attr);
+	if (dmac)
+		memcpy(ah->qplib_ah.dmac, dmac, ETH_ALEN);
+	return rc;
+}
+
+int bnxt_re_create_ah(struct ib_ah *ah_in, struct ib_ah_attr *attr,
+		      u32 flags, struct ib_udata *udata)
+{
+
+	struct ib_ah *ib_ah = ah_in;
+	struct ib_pd *ib_pd = ib_ah->pd;
+	struct bnxt_re_ah *ah = container_of(ib_ah, struct bnxt_re_ah, ibah);
+	struct bnxt_re_pd *pd = container_of(ib_pd, struct bnxt_re_pd, ibpd);
+	struct bnxt_re_dev *rdev = pd->rdev;
+	struct bnxt_re_ah_info ah_info;
+	u32 max_ah_count;
+	bool is_user;
+	int rc;
+	bool block = true;
+	struct ib_ah_attr *ah_attr = attr;
+	block = !(flags & RDMA_CREATE_AH_SLEEPABLE);
+
+	if (!(ah_attr->ah_flags & IB_AH_GRH))
+		dev_err(rdev_to_dev(rdev), "ah_attr->ah_flags GRH is not set\n");
+
+	ah->rdev = rdev;
+	ah->qplib_ah.pd = &pd->qplib_pd;
+	is_user = ib_pd->uobject ? true : false;
+
+	/* Supply the configuration for the HW */
+	memcpy(ah->qplib_ah.dgid.data, ah_attr->grh.dgid.raw,
+			sizeof(union ib_gid));
+	ah->qplib_ah.sgid_index = _get_sgid_index(rdev, ah_attr->grh.sgid_index);
+	if (ah->qplib_ah.sgid_index == 0xFF) {
+		dev_err(rdev_to_dev(rdev), "invalid sgid_index!\n");
+		rc = -EINVAL;
+		goto fail;
+	}
+	ah->qplib_ah.host_sgid_index = ah_attr->grh.sgid_index;
+	ah->qplib_ah.traffic_class = ah_attr->grh.traffic_class;
+	ah->qplib_ah.flow_label = ah_attr->grh.flow_label;
+	ah->qplib_ah.hop_limit = ah_attr->grh.hop_limit;
+	ah->qplib_ah.sl = ah_attr->sl;
+	rc = bnxt_re_get_ah_info(rdev, ah_attr, &ah_info);
+	if (rc)
+		goto fail;
+	ah->qplib_ah.nw_type = ah_info.nw_type;
+
+	rc = bnxt_re_init_dmac(rdev, ah_attr, &ah_info, is_user, ah);
+	if (rc)
+		goto fail;
+
+	rc = bnxt_qplib_create_ah(&rdev->qplib_res, &ah->qplib_ah, block);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev),
+			"Allocate HW Address Handle failed!\n");
+		goto fail;
+	}
+
+	/* Write AVID to shared page. */
+	if (ib_pd->uobject) {
+		struct ib_ucontext *ib_uctx = ib_pd->uobject->context;
+		struct bnxt_re_ucontext *uctx;
+		unsigned long flag;
+		u32 *wrptr;
+
+		uctx = to_bnxt_re(ib_uctx, struct bnxt_re_ucontext, ibucontext);
+		spin_lock_irqsave(&uctx->sh_lock, flag);
+		wrptr = (u32 *)((u8 *)uctx->shpg + BNXT_RE_AVID_OFFT);
+		*wrptr = ah->qplib_ah.id;
+		wmb(); /* make sure cache is updated. */
+		spin_unlock_irqrestore(&uctx->sh_lock, flag);
+	}
+	atomic_inc(&rdev->stats.rsors.ah_count);
+	max_ah_count = atomic_read(&rdev->stats.rsors.ah_count);
+	if (max_ah_count > atomic_read(&rdev->stats.rsors.max_ah_count))
+		atomic_set(&rdev->stats.rsors.max_ah_count, max_ah_count);
+
+	return 0;
+fail:
+	return rc;
+}
+
+int bnxt_re_modify_ah(struct ib_ah *ib_ah, struct ib_ah_attr *ah_attr)
+{
+	return 0;
+}
+
+int bnxt_re_query_ah(struct ib_ah *ib_ah, struct ib_ah_attr *ah_attr)
+{
+	struct bnxt_re_ah *ah = to_bnxt_re(ib_ah, struct bnxt_re_ah, ibah);
+
+	memcpy(ah_attr->grh.dgid.raw, ah->qplib_ah.dgid.data,
+	       sizeof(union ib_gid));
+	ah_attr->grh.sgid_index = ah->qplib_ah.host_sgid_index;
+	ah_attr->grh.traffic_class = ah->qplib_ah.traffic_class;
+	ah_attr->sl = ah->qplib_ah.sl;
+	memcpy(ROCE_DMAC(ah_attr), ah->qplib_ah.dmac, ETH_ALEN);
+	ah_attr->ah_flags = IB_AH_GRH;
+	ah_attr->port_num = 1;
+	ah_attr->static_rate = 0;
+
+	return 0;
+}
+
+/* Shared Receive Queues */
+void bnxt_re_destroy_srq(struct ib_srq *ib_srq,
+			 struct ib_udata *udata)
+{
+	struct bnxt_re_srq *srq = to_bnxt_re(ib_srq, struct bnxt_re_srq, ibsrq);
+	struct bnxt_re_dev *rdev = srq->rdev;
+	struct bnxt_qplib_srq *qplib_srq = &srq->qplib_srq;
+	int rc = 0;
+
+
+	rc = bnxt_qplib_destroy_srq(&rdev->qplib_res, qplib_srq);
+	if (rc)
+		dev_err_ratelimited(rdev_to_dev(rdev),
+				   "%s id = %d failed rc = %d\n",
+				    __func__, qplib_srq->id, rc);
+
+	if (srq->umem && !IS_ERR(srq->umem))
+		ib_umem_release(srq->umem);
+
+	atomic_dec(&rdev->stats.rsors.srq_count);
+
+	return;
+}
+
+static u16 _max_rwqe_sz(int nsge)
+{
+	return sizeof(struct rq_wqe_hdr) + (nsge * sizeof(struct sq_sge));
+}
+
+static u16 bnxt_re_get_rwqe_size(struct bnxt_qplib_qp *qplqp,
+				 int rsge, int max)
+{
+	if (qplqp->wqe_mode == BNXT_QPLIB_WQE_MODE_STATIC)
+		rsge = max;
+
+	return _max_rwqe_sz(rsge);
+}
+
+static inline
+struct ib_umem *ib_umem_get_compat(struct bnxt_re_dev *rdev,
+				   struct ib_ucontext *ucontext,
+				   struct ib_udata *udata,
+				   unsigned long addr,
+				   size_t size, int access, int dmasync)
+{
+	return ib_umem_get(ucontext, addr, size, access, dmasync);
+}
+
+static inline
+struct ib_umem *ib_umem_get_flags_compat(struct bnxt_re_dev *rdev,
+					 struct ib_ucontext *ucontext,
+					 struct ib_udata *udata,
+					 unsigned long addr,
+					 size_t size, int access, int dmasync)
+{
+	return ib_umem_get_compat(rdev, ucontext, udata, addr, size,
+				  access, 0);
+}
+
+static inline size_t ib_umem_num_pages_compat(struct ib_umem *umem)
+{
+	return ib_umem_num_pages(umem);
+}
+
+static int bnxt_re_init_user_srq(struct bnxt_re_dev *rdev,
+				 struct bnxt_re_pd *pd,
+				 struct bnxt_re_srq *srq,
+				 struct ib_udata *udata)
+{
+	struct bnxt_qplib_sg_info *sginfo;
+	struct bnxt_qplib_srq *qplib_srq;
+	struct bnxt_re_ucontext *cntx;
+	struct ib_ucontext *context;
+	struct bnxt_re_srq_req ureq;
+	struct ib_umem *umem;
+	int rc, bytes = 0;
+
+	context = pd->ibpd.uobject->context;
+	cntx = to_bnxt_re(context, struct bnxt_re_ucontext, ibucontext);
+	qplib_srq = &srq->qplib_srq;
+	sginfo = &qplib_srq->sginfo;
+
+	if (udata->inlen < sizeof(ureq))
+		dev_warn(rdev_to_dev(rdev),
+			 "Update the library ulen %d klen %d\n",
+			 (unsigned int)udata->inlen,
+			 (unsigned int)sizeof(ureq));
+
+	rc = ib_copy_from_udata(&ureq, udata,
+				min(udata->inlen, sizeof(ureq)));
+	if (rc)
+		return rc;
+
+	bytes = (qplib_srq->max_wqe * qplib_srq->wqe_size);
+	bytes = PAGE_ALIGN(bytes);
+	umem = ib_umem_get_compat(rdev, context, udata, ureq.srqva, bytes,
+				  IB_ACCESS_LOCAL_WRITE, 1);
+	if (IS_ERR(umem)) {
+		dev_err(rdev_to_dev(rdev), "%s: ib_umem_get failed with %ld\n",
+			__func__, PTR_ERR(umem));
+		return PTR_ERR(umem);
+	}
+
+	srq->umem = umem;
+	sginfo->sghead = get_ib_umem_sgl(umem, &sginfo->nmap);
+	sginfo->npages = ib_umem_num_pages_compat(umem);
+	qplib_srq->srq_handle = ureq.srq_handle;
+	qplib_srq->dpi = &cntx->dpi;
+	qplib_srq->is_user = true;
+
+	return 0;
+}
+
+int bnxt_re_create_srq(struct ib_srq *srq_in, struct ib_srq_init_attr *srq_init_attr,
+		       struct ib_udata *udata)
+{
+	struct bnxt_qplib_dev_attr *dev_attr;
+	struct bnxt_re_ucontext *cntx = NULL;
+	struct ib_ucontext *context;
+	struct bnxt_re_dev *rdev;
+	struct bnxt_re_pd *pd;
+	int rc, entries;
+	struct ib_srq *ib_srq = srq_in;
+	struct ib_pd *ib_pd = ib_srq->pd;
+	struct bnxt_re_srq *srq =
+		container_of(ib_srq, struct bnxt_re_srq, ibsrq);
+	u32 max_srq_count;
+
+	pd = to_bnxt_re(ib_pd, struct bnxt_re_pd, ibpd);
+	rdev = pd->rdev;
+	dev_attr = rdev->dev_attr;
+
+	if (rdev->mod_exit) {
+		dev_dbg(rdev_to_dev(rdev), "%s(): in mod_exit, just return!\n", __func__);
+		rc = -EIO;
+		goto exit;
+	}
+
+	if (srq_init_attr->srq_type != IB_SRQT_BASIC) {
+		dev_err(rdev_to_dev(rdev), "SRQ type not supported\n");
+		rc = -ENOTSUPP;
+		goto exit;
+	}
+
+	if (udata) {
+		context = pd->ibpd.uobject->context;
+		cntx = to_bnxt_re(context, struct bnxt_re_ucontext, ibucontext);
+	}
+
+	if (atomic_read(&rdev->stats.rsors.srq_count) >= dev_attr->max_srq) {
+		dev_err(rdev_to_dev(rdev), "Create SRQ failed - max exceeded(SRQs)\n");
+		rc = -EINVAL;
+		goto exit;
+	}
+
+	if (srq_init_attr->attr.max_wr >= dev_attr->max_srq_wqes) {
+		dev_err(rdev_to_dev(rdev), "Create SRQ failed - max exceeded(SRQ_WQs)\n");
+		rc = -EINVAL;
+		goto exit;
+	}
+
+	srq->rdev = rdev;
+	srq->qplib_srq.pd = &pd->qplib_pd;
+	srq->qplib_srq.dpi = &rdev->dpi_privileged;
+
+	/* Allocate 1 more than what's provided so posting max doesn't
+	   mean empty */
+	entries = srq_init_attr->attr.max_wr + 1;
+	entries = bnxt_re_init_depth(entries, cntx);
+	if (entries > dev_attr->max_srq_wqes + 1)
+		entries = dev_attr->max_srq_wqes + 1;
+
+	srq->qplib_srq.wqe_size = _max_rwqe_sz(6); /* 128 byte wqe size */
+	srq->qplib_srq.max_wqe = entries;
+	srq->qplib_srq.max_sge = srq_init_attr->attr.max_sge;
+	srq->qplib_srq.threshold = srq_init_attr->attr.srq_limit;
+	srq->srq_limit = srq_init_attr->attr.srq_limit;
+	srq->qplib_srq.eventq_hw_ring_id = rdev->nqr.nq[0].ring_id;
+	srq->qplib_srq.sginfo.pgsize = PAGE_SIZE;
+	srq->qplib_srq.sginfo.pgshft = PAGE_SHIFT;
+
+	if (udata) {
+		rc = bnxt_re_init_user_srq(rdev, pd, srq, udata);
+		if (rc)
+			goto fail;
+	}
+
+	rc = bnxt_qplib_create_srq(&rdev->qplib_res, &srq->qplib_srq);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev), "Create HW SRQ failed!\n");
+		goto fail;
+	}
+
+	if (udata) {
+		struct bnxt_re_srq_resp resp;
+
+		resp.srqid = srq->qplib_srq.id;
+		rc = bnxt_re_copy_to_udata(rdev, &resp,
+					   min(udata->outlen, sizeof(resp)),
+					   udata);
+		if (rc) {
+			bnxt_qplib_destroy_srq(&rdev->qplib_res, &srq->qplib_srq);
+			goto fail;
+		}
+	}
+	atomic_inc(&rdev->stats.rsors.srq_count);
+	max_srq_count = atomic_read(&rdev->stats.rsors.srq_count);
+	if (max_srq_count > atomic_read(&rdev->stats.rsors.max_srq_count))
+		atomic_set(&rdev->stats.rsors.max_srq_count, max_srq_count);
+	spin_lock_init(&srq->lock);
+
+	return 0;
+fail:
+	if (udata && srq->umem && !IS_ERR(srq->umem)) {
+		ib_umem_release(srq->umem);
+		srq->umem = NULL;
+	}
+exit:
+	return rc;
+}
+
+int bnxt_re_modify_srq(struct ib_srq *ib_srq, struct ib_srq_attr *srq_attr,
+		       enum ib_srq_attr_mask srq_attr_mask,
+		       struct ib_udata *udata)
+{
+	struct bnxt_re_srq *srq = to_bnxt_re(ib_srq, struct bnxt_re_srq,
+					     ibsrq);
+	struct bnxt_re_dev *rdev = srq->rdev;
+	int rc;
+
+	switch (srq_attr_mask) {
+	case IB_SRQ_MAX_WR:
+		/* SRQ resize is not supported */
+		break;
+	case IB_SRQ_LIMIT:
+		/* Change the SRQ threshold */
+		if (srq_attr->srq_limit > srq->qplib_srq.max_wqe)
+			return -EINVAL;
+
+		srq->qplib_srq.threshold = srq_attr->srq_limit;
+		rc = bnxt_qplib_modify_srq(&rdev->qplib_res, &srq->qplib_srq);
+		if (rc) {
+			dev_err(rdev_to_dev(rdev), "Modify HW SRQ failed!\n");
+			return rc;
+		}
+		/* On success, update the shadow */
+		srq->srq_limit = srq_attr->srq_limit;
+
+		if (udata) {
+			/* Build and send response back to udata */
+			rc = bnxt_re_copy_to_udata(rdev, srq, 0, udata);
+			if (rc)
+				return rc;
+		}
+		break;
+	default:
+		dev_err(rdev_to_dev(rdev),
+			"Unsupported srq_attr_mask 0x%x\n", srq_attr_mask);
+		return -EINVAL;
+	}
+	return 0;
+}
+
+int bnxt_re_query_srq(struct ib_srq *ib_srq, struct ib_srq_attr *srq_attr)
+{
+	struct bnxt_re_srq *srq = to_bnxt_re(ib_srq, struct bnxt_re_srq,
+					     ibsrq);
+	struct bnxt_re_dev *rdev = srq->rdev;
+	int rc;
+
+	rc = bnxt_qplib_query_srq(&rdev->qplib_res, &srq->qplib_srq);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev), "Query HW SRQ (0x%x) failed! rc = %d\n",
+			srq->qplib_srq.id, rc);
+		return rc;
+	}
+	srq_attr->max_wr = srq->qplib_srq.max_wqe;
+	srq_attr->max_sge = srq->qplib_srq.max_sge;
+	srq_attr->srq_limit = srq->qplib_srq.threshold;
+
+	return 0;
+}
+
+int bnxt_re_post_srq_recv(struct ib_srq *ib_srq, const struct ib_recv_wr *wr,
+			  const struct ib_recv_wr **bad_wr)
+{
+	struct bnxt_re_srq *srq = to_bnxt_re(ib_srq, struct bnxt_re_srq,
+					     ibsrq);
+	struct bnxt_qplib_swqe wqe = {};
+	unsigned long flags;
+	int rc = 0;
+
+	spin_lock_irqsave(&srq->lock, flags);
+	while (wr) {
+		/* Transcribe each ib_recv_wr to qplib_swqe */
+		wqe.num_sge = wr->num_sge;
+		wqe.sg_list = (struct bnxt_qplib_sge *)wr->sg_list;
+		wqe.wr_id = wr->wr_id;
+		wqe.type = BNXT_QPLIB_SWQE_TYPE_RECV;
+		rc = bnxt_qplib_post_srq_recv(&srq->qplib_srq, &wqe);
+		if (rc) {
+			*bad_wr = wr;
+			break;
+		}
+		wr = wr->next;
+	}
+	spin_unlock_irqrestore(&srq->lock, flags);
+
+	return rc;
+}
+
+unsigned long bnxt_re_lock_cqs(struct bnxt_re_qp *qp)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&qp->scq->cq_lock, flags);
+	if (qp->rcq && qp->rcq != qp->scq)
+		spin_lock(&qp->rcq->cq_lock);
+
+	return flags;
+}
+
+void bnxt_re_unlock_cqs(struct bnxt_re_qp *qp,
+				  unsigned long flags)
+{
+	if (qp->rcq && qp->rcq != qp->scq)
+		spin_unlock(&qp->rcq->cq_lock);
+	spin_unlock_irqrestore(&qp->scq->cq_lock, flags);
+}
+
+/* Queue Pairs */
+static int bnxt_re_destroy_gsi_sqp(struct bnxt_re_qp *qp)
+{
+	struct bnxt_re_qp *gsi_sqp;
+	struct bnxt_re_ah *gsi_sah;
+	struct bnxt_re_dev *rdev;
+	unsigned long flags;
+	int rc = 0;
+
+	rdev = qp->rdev;
+	gsi_sqp = rdev->gsi_ctx.gsi_sqp;
+	gsi_sah = rdev->gsi_ctx.gsi_sah;
+
+	/* remove from active qp list */
+	mutex_lock(&rdev->qp_lock);
+	list_del(&gsi_sqp->list);
+	mutex_unlock(&rdev->qp_lock);
+
+	if (gsi_sah) {
+		dev_dbg(rdev_to_dev(rdev), "Destroy the shadow AH\n");
+		rc = bnxt_qplib_destroy_ah(&rdev->qplib_res, &gsi_sah->qplib_ah,
+					   true);
+		if (rc)
+			dev_err(rdev_to_dev(rdev),
+				"Destroy HW AH for shadow QP failed!\n");
+		atomic_dec(&rdev->stats.rsors.ah_count);
+	}
+
+	dev_dbg(rdev_to_dev(rdev), "Destroy the shadow QP\n");
+	rc = bnxt_qplib_destroy_qp(&rdev->qplib_res, &gsi_sqp->qplib_qp);
+	if (rc)
+		dev_err(rdev_to_dev(rdev), "Destroy Shadow QP failed\n");
+
+	/* Clean the CQ for shadow QP completions */
+	flags = bnxt_re_lock_cqs(gsi_sqp);
+	bnxt_qplib_clean_qp(&gsi_sqp->qplib_qp);
+	bnxt_re_unlock_cqs(gsi_sqp, flags);
+
+	bnxt_qplib_free_qp_res(&rdev->qplib_res, &gsi_sqp->qplib_qp);
+	bnxt_qplib_free_hdr_buf(&rdev->qplib_res, &gsi_sqp->qplib_qp);
+	kfree(rdev->gsi_ctx.sqp_tbl);
+	kfree(gsi_sah);
+	kfree(gsi_sqp);
+	rdev->gsi_ctx.gsi_sqp = NULL;
+	rdev->gsi_ctx.gsi_sah = NULL;
+	rdev->gsi_ctx.sqp_tbl = NULL;
+	atomic_dec(&rdev->stats.rsors.qp_count);
+
+	return 0;
+}
+
+static void bnxt_re_dump_debug_stats(struct bnxt_re_dev *rdev, u32 active_qps)
+{
+	u32	total_qp = 0;
+	u64	avg_time = 0;
+	int	i;
+
+	if (!rdev->rcfw.sp_perf_stats_enabled)
+		return;
+
+	switch (active_qps) {
+	case 1:
+		/* Potential hint for Test Stop */
+		for (i = 0; i < RCFW_MAX_STAT_INDEX; i++) {
+			if (rdev->rcfw.qp_destroy_stats[i]) {
+				total_qp++;
+				avg_time += rdev->rcfw.qp_destroy_stats[i];
+			}
+		}
+		if (total_qp >= 0 || avg_time >= 0)
+			dev_dbg(rdev_to_dev(rdev),
+				"Perf Debug: %ps Total (%d) QP destroyed in (%ld) msec\n",
+				__builtin_return_address(0), total_qp,
+				(long)jiffies_to_msecs(avg_time));
+		break;
+	case 2:
+		/* Potential hint for Test Start */
+		dev_dbg(rdev_to_dev(rdev),
+			"Perf Debug: %ps active_qps = %d\n",
+			__builtin_return_address(0), active_qps);
+		break;
+	default:
+		/* Potential hint to know latency of QP destroy.
+		 * Average time taken for 1K QP Destroy.
+		 */
+		if (active_qps > 1024 && !(active_qps % 1024))
+			dev_dbg(rdev_to_dev(rdev),
+				"Perf Debug: %ps Active QP (%d) Watermark (%d)\n",
+				__builtin_return_address(0), active_qps,
+				atomic_read(&rdev->stats.rsors.max_qp_count));
+		break;
+	}
+}
+
+int bnxt_re_destroy_qp(struct ib_qp *ib_qp, struct ib_udata *udata)
+{
+	struct bnxt_re_qp *qp = to_bnxt_re(ib_qp, struct bnxt_re_qp, ib_qp);
+	struct bnxt_re_dev *rdev = qp->rdev;
+	unsigned long flags;
+	u32 active_qps;
+	int rc;
+
+	mutex_lock(&rdev->qp_lock);
+	list_del(&qp->list);
+	active_qps = atomic_dec_return(&rdev->stats.rsors.qp_count);
+	if (qp->qplib_qp.type == CMDQ_CREATE_QP_TYPE_RC)
+		atomic_dec(&rdev->stats.rsors.rc_qp_count);
+	else if (qp->qplib_qp.type == CMDQ_CREATE_QP_TYPE_UD)
+		atomic_dec(&rdev->stats.rsors.ud_qp_count);
+	mutex_unlock(&rdev->qp_lock);
+
+	rc = bnxt_qplib_destroy_qp(&rdev->qplib_res, &qp->qplib_qp);
+	if (rc)
+		dev_err_ratelimited(rdev_to_dev(rdev),
+				   "%s id = %d failed rc = %d\n",
+				    __func__, qp->qplib_qp.id, rc);
+
+	if (!ib_qp->uobject) {
+		flags = bnxt_re_lock_cqs(qp);
+		bnxt_qplib_clean_qp(&qp->qplib_qp);
+		bnxt_re_unlock_cqs(qp, flags);
+	}
+
+	bnxt_qplib_free_qp_res(&rdev->qplib_res, &qp->qplib_qp);
+	if (ib_qp->qp_type == IB_QPT_GSI &&
+	    rdev->gsi_ctx.gsi_qp_mode != BNXT_RE_GSI_MODE_UD) {
+		if (rdev->gsi_ctx.gsi_qp_mode == BNXT_RE_GSI_MODE_ALL &&
+		    rdev->gsi_ctx.gsi_sqp) {
+			bnxt_re_destroy_gsi_sqp(qp);
+		}
+		bnxt_qplib_free_hdr_buf(&rdev->qplib_res, &qp->qplib_qp);
+	}
+
+	if (qp->rumem && !IS_ERR(qp->rumem))
+		ib_umem_release(qp->rumem);
+	if (qp->sumem && !IS_ERR(qp->sumem))
+		ib_umem_release(qp->sumem);
+	kfree(qp);
+
+	bnxt_re_dump_debug_stats(rdev, active_qps);
+
+	return 0;
+}
+
+static u8 __from_ib_qp_type(enum ib_qp_type type)
+{
+	switch (type) {
+	case IB_QPT_GSI:
+		return CMDQ_CREATE_QP1_TYPE_GSI;
+	case IB_QPT_RC:
+		return CMDQ_CREATE_QP_TYPE_RC;
+	case IB_QPT_UD:
+		return CMDQ_CREATE_QP_TYPE_UD;
+	case IB_QPT_RAW_ETHERTYPE:
+		return CMDQ_CREATE_QP_TYPE_RAW_ETHERTYPE;
+	default:
+		return IB_QPT_MAX;
+	}
+}
+
+static u16 _get_swqe_sz(int nsge)
+{
+	return sizeof(struct sq_send_hdr) + nsge * sizeof(struct sq_sge);
+}
+
+static int bnxt_re_get_swqe_size(int ilsize, int nsge)
+{
+	u16 wqe_size, calc_ils;
+
+	wqe_size = _get_swqe_sz(nsge);
+	if (ilsize) {
+		calc_ils = (sizeof(struct sq_send_hdr) + ilsize);
+		wqe_size = max_t(int, calc_ils, wqe_size);
+		wqe_size = ALIGN(wqe_size, 32);
+	}
+	return wqe_size;
+}
+
+static int bnxt_re_setup_swqe_size(struct bnxt_re_qp *qp,
+				   struct ib_qp_init_attr *init_attr)
+{
+	struct bnxt_qplib_dev_attr *dev_attr;
+	struct bnxt_qplib_qp *qplqp;
+	struct bnxt_re_dev *rdev;
+	struct bnxt_qplib_q *sq;
+	int align, ilsize;
+
+	rdev = qp->rdev;
+	qplqp = &qp->qplib_qp;
+	sq = &qplqp->sq;
+	dev_attr = rdev->dev_attr;
+
+	align = sizeof(struct sq_send_hdr);
+	ilsize = ALIGN(init_attr->cap.max_inline_data, align);
+
+	sq->wqe_size = bnxt_re_get_swqe_size(ilsize, sq->max_sge);
+	if (sq->wqe_size > _get_swqe_sz(dev_attr->max_qp_sges))
+		return -EINVAL;
+	/* For Cu/Wh and gen p5 backward compatibility mode
+	 * wqe size is fixed to 128 bytes
+	 */
+	if (sq->wqe_size < _get_swqe_sz(dev_attr->max_qp_sges) &&
+	    qplqp->wqe_mode == BNXT_QPLIB_WQE_MODE_STATIC)
+		sq->wqe_size = _get_swqe_sz(dev_attr->max_qp_sges);
+
+	if (init_attr->cap.max_inline_data) {
+		qplqp->max_inline_data = sq->wqe_size -
+					 sizeof(struct sq_send_hdr);
+		init_attr->cap.max_inline_data = qplqp->max_inline_data;
+		if (qplqp->wqe_mode == BNXT_QPLIB_WQE_MODE_STATIC)
+			sq->max_sge = qplqp->max_inline_data /
+				      sizeof(struct sq_sge);
+	}
+
+	return 0;
+}
+
+static int bnxt_re_init_user_qp(struct bnxt_re_dev *rdev,
+				struct bnxt_re_pd *pd, struct bnxt_re_qp *qp,
+				struct ib_udata *udata)
+{
+	struct bnxt_qplib_sg_info *sginfo;
+	struct bnxt_qplib_qp *qplib_qp;
+	struct bnxt_re_ucontext *cntx;
+	struct ib_ucontext *context;
+	struct bnxt_re_qp_req ureq;
+	struct ib_umem *umem;
+	int rc, bytes = 0;
+	int psn_nume;
+	int psn_sz;
+
+	qplib_qp = &qp->qplib_qp;
+	context = pd->ibpd.uobject->context;
+	cntx = to_bnxt_re(context, struct bnxt_re_ucontext, ibucontext);
+	sginfo = &qplib_qp->sq.sginfo;
+
+	if (udata->inlen < sizeof(ureq))
+		dev_warn(rdev_to_dev(rdev),
+			 "Update the library ulen %d klen %d\n",
+			 (unsigned int)udata->inlen,
+			 (unsigned int)sizeof(ureq));
+
+	rc = ib_copy_from_udata(&ureq, udata,
+				min(udata->inlen, sizeof(ureq)));
+	if (rc)
+		return rc;
+
+	bytes = (qplib_qp->sq.max_wqe * qplib_qp->sq.wqe_size);
+	/* Consider mapping PSN search memory only for RC QPs. */
+	if (qplib_qp->type == CMDQ_CREATE_QP_TYPE_RC) {
+		psn_sz = _is_chip_gen_p5_p7(rdev->chip_ctx) ?
+				sizeof(struct sq_psn_search_ext) :
+				sizeof(struct sq_psn_search);
+		if (rdev->dev_attr && BNXT_RE_HW_RETX(rdev->dev_attr->dev_cap_flags))
+			psn_sz = sizeof(struct sq_msn_search);
+		psn_nume = (qplib_qp->wqe_mode == BNXT_QPLIB_WQE_MODE_STATIC) ?
+			    qplib_qp->sq.max_wqe :
+			    ((qplib_qp->sq.max_wqe * qplib_qp->sq.wqe_size) /
+			     sizeof(struct bnxt_qplib_sge));
+		if (BNXT_RE_HW_RETX(rdev->dev_attr->dev_cap_flags))
+			psn_nume = roundup_pow_of_two(psn_nume);
+
+		bytes += (psn_nume * psn_sz);
+	}
+	bytes = PAGE_ALIGN(bytes);
+	umem = ib_umem_get_compat(rdev, context, udata, ureq.qpsva, bytes,
+				  IB_ACCESS_LOCAL_WRITE, 1);
+	if (IS_ERR(umem)) {
+		dev_err(rdev_to_dev(rdev), "%s: ib_umem_get failed with %ld\n",
+			__func__, PTR_ERR(umem));
+		return PTR_ERR(umem);
+	}
+
+	qp->sumem = umem;
+	/* pgsize and pgshft were initialize already. */
+	sginfo->sghead = get_ib_umem_sgl(umem, &sginfo->nmap);
+	sginfo->npages = ib_umem_num_pages_compat(umem);
+	qplib_qp->qp_handle = ureq.qp_handle;
+
+	if (!qp->qplib_qp.srq) {
+		sginfo = &qplib_qp->rq.sginfo;
+		bytes = (qplib_qp->rq.max_wqe * qplib_qp->rq.wqe_size);
+		bytes = PAGE_ALIGN(bytes);
+		umem = ib_umem_get_compat(rdev,
+					  context, udata, ureq.qprva, bytes,
+					  IB_ACCESS_LOCAL_WRITE, 1);
+		if (IS_ERR(umem)) {
+			dev_err(rdev_to_dev(rdev),
+				"%s: ib_umem_get failed ret =%ld\n",
+				__func__, PTR_ERR(umem));
+			goto rqfail;
+		}
+		qp->rumem = umem;
+		/* pgsize and pgshft were initialize already. */
+		sginfo->sghead = get_ib_umem_sgl(umem, &sginfo->nmap);
+		sginfo->npages = ib_umem_num_pages_compat(umem);
+	}
+
+	qplib_qp->dpi = &cntx->dpi;
+	qplib_qp->is_user = true;
+
+	return 0;
+rqfail:
+	ib_umem_release(qp->sumem);
+	qp->sumem = NULL;
+	qplib_qp->sq.sginfo.sghead = NULL;
+	qplib_qp->sq.sginfo.nmap = 0;
+
+	return PTR_ERR(umem);
+}
+
+static struct bnxt_re_ah *bnxt_re_create_shadow_qp_ah(struct bnxt_re_pd *pd,
+					       struct bnxt_qplib_res *qp1_res,
+					       struct bnxt_qplib_qp *qp1_qp)
+{
+	struct bnxt_re_dev *rdev = pd->rdev;
+	struct bnxt_re_ah *ah;
+	union ib_gid sgid;
+	int rc;
+
+	ah = kzalloc(sizeof(*ah), GFP_KERNEL);
+	if (!ah) {
+		dev_err(rdev_to_dev(rdev), "Allocate Address Handle failed!\n");
+		return NULL;
+	}
+	memset(ah, 0, sizeof(*ah));
+	ah->rdev = rdev;
+	ah->qplib_ah.pd = &pd->qplib_pd;
+
+	rc = bnxt_re_query_gid(&rdev->ibdev, 1, 0, &sgid);
+	if (rc)
+		goto fail;
+
+	/* supply the dgid data same as sgid */
+	memcpy(ah->qplib_ah.dgid.data, &sgid.raw,
+	       sizeof(union ib_gid));
+	ah->qplib_ah.sgid_index = 0;
+
+	ah->qplib_ah.traffic_class = 0;
+	ah->qplib_ah.flow_label = 0;
+	ah->qplib_ah.hop_limit = 1;
+	ah->qplib_ah.sl = 0;
+	/* Have DMAC same as SMAC */
+	ether_addr_copy(ah->qplib_ah.dmac, rdev->dev_addr);
+	dev_dbg(rdev_to_dev(rdev), "ah->qplib_ah.dmac = %x:%x:%x:%x:%x:%x\n",
+		ah->qplib_ah.dmac[0], ah->qplib_ah.dmac[1], ah->qplib_ah.dmac[2],
+		ah->qplib_ah.dmac[3], ah->qplib_ah.dmac[4], ah->qplib_ah.dmac[5]);
+
+	rc = bnxt_qplib_create_ah(&rdev->qplib_res, &ah->qplib_ah, true);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev),
+			"Allocate HW AH for Shadow QP failed!\n");
+		goto fail;
+	}
+	dev_dbg(rdev_to_dev(rdev), "AH ID = %d\n", ah->qplib_ah.id);
+	atomic_inc(&rdev->stats.rsors.ah_count);
+
+	return ah;
+fail:
+	kfree(ah);
+	return NULL;
+}
+
+void bnxt_re_update_shadow_ah(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_re_qp *gsi_qp;
+	struct bnxt_re_ah *sah;
+	struct bnxt_re_pd *pd;
+	struct ib_pd *ib_pd;
+	int rc;
+
+	if (!rdev)
+		return;
+
+	sah = rdev->gsi_ctx.gsi_sah;
+
+	dev_dbg(rdev_to_dev(rdev), "Updating the AH\n");
+	if (sah) {
+		/* Check if the AH created with current mac address */
+		if (!compare_ether_header(sah->qplib_ah.dmac, rdev->dev_addr)) {
+			dev_dbg(rdev_to_dev(rdev),
+				"Not modifying shadow AH during AH update\n");
+			return;
+		}
+
+		gsi_qp = rdev->gsi_ctx.gsi_qp;
+		ib_pd = gsi_qp->ib_qp.pd;
+		pd = to_bnxt_re(ib_pd, struct bnxt_re_pd, ibpd);
+		rc = bnxt_qplib_destroy_ah(&rdev->qplib_res,
+					   &sah->qplib_ah, false);
+		if (rc) {
+			dev_err(rdev_to_dev(rdev),
+				"Failed to destroy shadow AH during AH update\n");
+			return;
+		}
+		atomic_dec(&rdev->stats.rsors.ah_count);
+		kfree(sah);
+		rdev->gsi_ctx.gsi_sah = NULL;
+
+		sah = bnxt_re_create_shadow_qp_ah(pd, &rdev->qplib_res,
+						  &gsi_qp->qplib_qp);
+		if (!sah) {
+			dev_err(rdev_to_dev(rdev),
+				"Failed to update AH for ShadowQP\n");
+			return;
+		}
+		rdev->gsi_ctx.gsi_sah = sah;
+		atomic_inc(&rdev->stats.rsors.ah_count);
+	}
+}
+
+static struct bnxt_re_qp *bnxt_re_create_shadow_qp(struct bnxt_re_pd *pd,
+					    struct bnxt_qplib_res *qp1_res,
+					    struct bnxt_qplib_qp *qp1_qp)
+{
+	struct bnxt_re_dev *rdev = pd->rdev;
+	struct bnxt_re_qp *qp;
+	int rc;
+
+	qp = kzalloc(sizeof(*qp), GFP_KERNEL);
+	if (!qp) {
+		dev_err(rdev_to_dev(rdev), "Allocate internal UD QP failed!\n");
+		return NULL;
+	}
+	memset(qp, 0, sizeof(*qp));
+	qp->rdev = rdev;
+
+	/* Initialize the shadow QP structure from the QP1 values */
+	ether_addr_copy(qp->qplib_qp.smac, rdev->dev_addr);
+	qp->qplib_qp.pd = &pd->qplib_pd;
+	qp->qplib_qp.qp_handle = (u64)&qp->qplib_qp;
+	qp->qplib_qp.type = IB_QPT_UD;
+
+	qp->qplib_qp.max_inline_data = 0;
+	qp->qplib_qp.sig_type = true;
+
+	/* Shadow QP SQ depth should be same as QP1 RQ depth */
+	qp->qplib_qp.sq.wqe_size = bnxt_re_get_swqe_size(0, 6);
+	qp->qplib_qp.sq.max_wqe = qp1_qp->rq.max_wqe;
+	qp->qplib_qp.sq.max_sge = 2;
+	/* Q full delta can be 1 since it is internal QP */
+	qp->qplib_qp.sq.q_full_delta = 1;
+	qp->qplib_qp.sq.sginfo.pgsize = PAGE_SIZE;
+	qp->qplib_qp.sq.sginfo.pgshft = PAGE_SHIFT;
+
+	qp->qplib_qp.scq = qp1_qp->scq;
+	qp->qplib_qp.rcq = qp1_qp->rcq;
+
+	qp->qplib_qp.rq.wqe_size = _max_rwqe_sz(6); /* 128 Byte wqe size */
+	qp->qplib_qp.rq.max_wqe = qp1_qp->rq.max_wqe;
+	qp->qplib_qp.rq.max_sge = qp1_qp->rq.max_sge;
+	qp->qplib_qp.rq.sginfo.pgsize = PAGE_SIZE;
+	qp->qplib_qp.rq.sginfo.pgshft = PAGE_SHIFT;
+	/* Q full delta can be 1 since it is internal QP */
+	qp->qplib_qp.rq.q_full_delta = 1;
+	qp->qplib_qp.mtu = qp1_qp->mtu;
+	qp->qplib_qp.dpi = &rdev->dpi_privileged;
+
+	rc = bnxt_qplib_alloc_hdr_buf(qp1_res, &qp->qplib_qp, 0,
+				      BNXT_QPLIB_MAX_GRH_HDR_SIZE_IPV6);
+	if (rc)
+		goto fail;
+
+	rc = bnxt_qplib_create_qp(qp1_res, &qp->qplib_qp);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev), "create HW QP failed!\n");
+		goto qp_fail;
+	}
+
+	dev_dbg(rdev_to_dev(rdev), "Created shadow QP with ID = %d\n",
+		qp->qplib_qp.id);
+	spin_lock_init(&qp->sq_lock);
+	INIT_LIST_HEAD(&qp->list);
+	mutex_lock(&rdev->qp_lock);
+	list_add_tail(&qp->list, &rdev->qp_list);
+	atomic_inc(&rdev->stats.rsors.qp_count);
+	mutex_unlock(&rdev->qp_lock);
+	return qp;
+qp_fail:
+	bnxt_qplib_free_hdr_buf(qp1_res, &qp->qplib_qp);
+fail:
+	kfree(qp);
+	return NULL;
+}
+
+static int bnxt_re_init_rq_attr(struct bnxt_re_qp *qp,
+				struct ib_qp_init_attr *init_attr, void *cntx)
+{
+	struct bnxt_qplib_dev_attr *dev_attr;
+	struct bnxt_qplib_qp *qplqp;
+	struct bnxt_re_dev *rdev;
+	struct bnxt_qplib_q *rq;
+	int entries;
+
+	rdev = qp->rdev;
+	qplqp = &qp->qplib_qp;
+	rq = &qplqp->rq;
+	dev_attr = rdev->dev_attr;
+
+	if (init_attr->srq) {
+		struct bnxt_re_srq *srq;
+
+		srq = to_bnxt_re(init_attr->srq, struct bnxt_re_srq, ibsrq);
+		if (!srq) {
+			dev_err(rdev_to_dev(rdev), "SRQ not found\n");
+			return -EINVAL;
+		}
+		qplqp->srq = &srq->qplib_srq;
+		rq->max_wqe = 0;
+	} else {
+		rq->max_sge = init_attr->cap.max_recv_sge;
+		if (rq->max_sge > dev_attr->max_qp_sges)
+			rq->max_sge = dev_attr->max_qp_sges;
+		init_attr->cap.max_recv_sge = rq->max_sge;
+		rq->wqe_size = bnxt_re_get_rwqe_size(qplqp, rq->max_sge,
+						     dev_attr->max_qp_sges);
+
+		/* Allocate 1 more than what's provided so posting max doesn't
+		   mean empty */
+		entries = init_attr->cap.max_recv_wr + 1;
+		entries = bnxt_re_init_depth(entries, cntx);
+		rq->max_wqe = min_t(u32, entries, dev_attr->max_qp_wqes + 1);
+		rq->q_full_delta = 0;
+		rq->sginfo.pgsize = PAGE_SIZE;
+		rq->sginfo.pgshft = PAGE_SHIFT;
+	}
+
+	return 0;
+}
+
+static void bnxt_re_adjust_gsi_rq_attr(struct bnxt_re_qp *qp)
+{
+	struct bnxt_qplib_dev_attr *dev_attr;
+	struct bnxt_qplib_qp *qplqp;
+	struct bnxt_re_dev *rdev;
+
+	rdev = qp->rdev;
+	qplqp = &qp->qplib_qp;
+	dev_attr = rdev->dev_attr;
+
+	if (rdev->gsi_ctx.gsi_qp_mode != BNXT_RE_GSI_MODE_UD)
+		qplqp->rq.max_sge = dev_attr->max_qp_sges;
+}
+
+static int bnxt_re_init_sq_attr(struct bnxt_re_qp *qp,
+				struct ib_qp_init_attr *init_attr,
+				void *cntx)
+{
+	struct bnxt_qplib_dev_attr *dev_attr;
+	struct bnxt_qplib_qp *qplqp;
+	struct bnxt_re_dev *rdev;
+	struct bnxt_qplib_q *sq;
+	int diff = 0;
+	int entries;
+	int rc;
+
+	rdev = qp->rdev;
+	qplqp = &qp->qplib_qp;
+	sq = &qplqp->sq;
+	dev_attr = rdev->dev_attr;
+
+	sq->max_sge = init_attr->cap.max_send_sge;
+	if (sq->max_sge > dev_attr->max_qp_sges) {
+		sq->max_sge = dev_attr->max_qp_sges;
+		init_attr->cap.max_send_sge = sq->max_sge;
+	}
+	rc = bnxt_re_setup_swqe_size(qp, init_attr);
+	if (rc)
+		return rc;
+	/*
+	 * Change the SQ depth if user has requested minimum using
+	 * configfs. Only supported for kernel consumers. Setting
+	 * min_tx_depth to 4096 to handle iser SQ full condition
+	 * in most of the newer OS distros
+	 */
+	entries = init_attr->cap.max_send_wr;
+	if (!cntx && rdev->min_tx_depth && init_attr->qp_type != IB_QPT_GSI) {
+		/*
+		 * If users specify any value greater than 1 use min_tx_depth
+		 * provided by user for comparison. Else, compare it with the
+		 * BNXT_RE_MIN_KERNEL_QP_TX_DEPTH and adjust it accordingly.
+		 */
+		if (rdev->min_tx_depth > 1 && entries < rdev->min_tx_depth)
+			entries = rdev->min_tx_depth;
+		else if (entries < BNXT_RE_MIN_KERNEL_QP_TX_DEPTH)
+			entries = BNXT_RE_MIN_KERNEL_QP_TX_DEPTH;
+	}
+	diff = bnxt_re_get_diff(cntx, rdev->chip_ctx);
+	entries = bnxt_re_init_depth(entries + diff + 1, cntx);
+	sq->max_wqe = min_t(u32, entries, dev_attr->max_qp_wqes + diff + 1);
+	sq->q_full_delta = diff + 1;
+	/*
+	 * Reserving one slot for Phantom WQE. Application can
+	 * post one extra entry in this case. But allowing this to avoid
+	 * unexpected Queue full condition
+	 */
+	sq->q_full_delta -= 1; /* becomes 0 for gen-p5 */
+	sq->sginfo.pgsize = PAGE_SIZE;
+	sq->sginfo.pgshft = PAGE_SHIFT;
+	return 0;
+}
+
+static void bnxt_re_adjust_gsi_sq_attr(struct bnxt_re_qp *qp,
+				       struct ib_qp_init_attr *init_attr,
+				       void *cntx)
+{
+	struct bnxt_qplib_dev_attr *dev_attr;
+	struct bnxt_qplib_qp *qplqp;
+	struct bnxt_re_dev *rdev;
+	int entries;
+
+	rdev = qp->rdev;
+	qplqp = &qp->qplib_qp;
+	dev_attr = rdev->dev_attr;
+
+	if (rdev->gsi_ctx.gsi_qp_mode != BNXT_RE_GSI_MODE_UD) {
+		entries = init_attr->cap.max_send_wr + 1;
+		entries = bnxt_re_init_depth(entries, cntx);
+		qplqp->sq.max_wqe = min_t(u32, entries,
+					  dev_attr->max_qp_wqes + 1);
+		qplqp->sq.q_full_delta = qplqp->sq.max_wqe -
+					 init_attr->cap.max_send_wr;
+		qplqp->sq.max_sge++; /* Need one extra sge to put UD header */
+		if (qplqp->sq.max_sge > dev_attr->max_qp_sges)
+			qplqp->sq.max_sge = dev_attr->max_qp_sges;
+	}
+}
+
+static int bnxt_re_init_qp_type(struct bnxt_re_dev *rdev,
+				struct ib_qp_init_attr *init_attr)
+{
+	struct bnxt_qplib_chip_ctx *chip_ctx;
+	struct bnxt_re_gsi_context *gsi_ctx;
+	int qptype;
+
+	chip_ctx = rdev->chip_ctx;
+	gsi_ctx = &rdev->gsi_ctx;
+
+	qptype = __from_ib_qp_type(init_attr->qp_type);
+	if (qptype == IB_QPT_MAX) {
+		dev_err(rdev_to_dev(rdev), "QP type 0x%x not supported\n",
+			qptype);
+		qptype = -EINVAL;
+		goto out;
+	}
+
+	if (_is_chip_gen_p5_p7(chip_ctx) && init_attr->qp_type == IB_QPT_GSI) {
+		/* For Thor always force UD mode. */
+		qptype = CMDQ_CREATE_QP_TYPE_GSI;
+		gsi_ctx->gsi_qp_mode = BNXT_RE_GSI_MODE_UD;
+	}
+out:
+	return qptype;
+}
+
+static int bnxt_re_init_qp_wqe_mode(struct bnxt_re_dev *rdev)
+{
+	return rdev->chip_ctx->modes.wqe_mode;
+}
+
+static int bnxt_re_init_qp_attr(struct bnxt_re_qp *qp, struct bnxt_re_pd *pd,
+				struct ib_qp_init_attr *init_attr,
+				struct ib_udata *udata)
+{
+	struct bnxt_qplib_dev_attr *dev_attr;
+	struct bnxt_re_ucontext *cntx = NULL;
+	struct ib_ucontext *context;
+	struct bnxt_qplib_qp *qplqp;
+	struct bnxt_re_dev *rdev;
+	struct bnxt_re_cq *cq;
+	int rc = 0, qptype;
+
+	rdev = qp->rdev;
+	qplqp = &qp->qplib_qp;
+	dev_attr = rdev->dev_attr;
+
+	if (udata) {
+		context = pd->ibpd.uobject->context;
+		cntx = to_bnxt_re(context, struct bnxt_re_ucontext, ibucontext);
+	}
+
+	/* Setup misc params */
+	qplqp->is_user = false;
+	qplqp->pd = &pd->qplib_pd;
+	qplqp->qp_handle = (u64)qplqp;
+	qplqp->sig_type = ((init_attr->sq_sig_type == IB_SIGNAL_ALL_WR) ?
+			    true : false);
+	qptype = bnxt_re_init_qp_type(rdev, init_attr);
+	if (qptype < 0) {
+		rc = qptype;
+		goto out;
+	}
+	qplqp->type = (u8)qptype;
+	qplqp->wqe_mode = bnxt_re_init_qp_wqe_mode(rdev);
+	ether_addr_copy(qplqp->smac, rdev->dev_addr);
+
+	if (init_attr->qp_type == IB_QPT_RC) {
+		qplqp->max_rd_atomic = dev_attr->max_qp_rd_atom;
+		qplqp->max_dest_rd_atomic = dev_attr->max_qp_init_rd_atom;
+	}
+	qplqp->mtu = ib_mtu_enum_to_int(iboe_get_mtu(rdev->netdev->if_mtu));
+	qplqp->dpi = &rdev->dpi_privileged; /* Doorbell page */
+	if (init_attr->create_flags) {
+		dev_dbg(rdev_to_dev(rdev),
+			"QP create flags 0x%x not supported\n",
+			init_attr->create_flags);
+		return -EOPNOTSUPP;
+	}
+
+	/* Setup CQs */
+	if (init_attr->send_cq) {
+		cq = to_bnxt_re(init_attr->send_cq, struct bnxt_re_cq, ibcq);
+		if (!cq) {
+			dev_err(rdev_to_dev(rdev), "Send CQ not found\n");
+			rc = -EINVAL;
+			goto out;
+		}
+		qplqp->scq = &cq->qplib_cq;
+		qp->scq = cq;
+	}
+
+	if (init_attr->recv_cq) {
+		cq = to_bnxt_re(init_attr->recv_cq, struct bnxt_re_cq, ibcq);
+		if (!cq) {
+			dev_err(rdev_to_dev(rdev), "Receive CQ not found\n");
+			rc = -EINVAL;
+			goto out;
+		}
+		qplqp->rcq = &cq->qplib_cq;
+		qp->rcq = cq;
+	}
+
+	/* Setup RQ/SRQ */
+	rc = bnxt_re_init_rq_attr(qp, init_attr, cntx);
+	if (rc)
+		goto out;
+	if (init_attr->qp_type == IB_QPT_GSI)
+		bnxt_re_adjust_gsi_rq_attr(qp);
+
+	/* Setup SQ */
+	rc = bnxt_re_init_sq_attr(qp, init_attr, cntx);
+	if (rc)
+		goto out;
+	if (init_attr->qp_type == IB_QPT_GSI)
+		bnxt_re_adjust_gsi_sq_attr(qp, init_attr, cntx);
+
+	if (udata) /* This will update DPI and qp_handle */
+		rc = bnxt_re_init_user_qp(rdev, pd, qp, udata);
+out:
+	return rc;
+}
+
+static int bnxt_re_create_shadow_gsi(struct bnxt_re_qp *qp,
+				     struct bnxt_re_pd *pd)
+{
+	struct bnxt_re_sqp_entries *sqp_tbl = NULL;
+	struct bnxt_re_dev *rdev;
+	struct bnxt_re_qp *sqp;
+	struct bnxt_re_ah *sah;
+	int rc = 0;
+
+	rdev = qp->rdev;
+	/* Create a shadow QP to handle the QP1 traffic */
+	sqp_tbl = kzalloc(sizeof(*sqp_tbl) * BNXT_RE_MAX_GSI_SQP_ENTRIES,
+			  GFP_KERNEL);
+	if (!sqp_tbl)
+		return -ENOMEM;
+	rdev->gsi_ctx.sqp_tbl = sqp_tbl;
+
+	sqp = bnxt_re_create_shadow_qp(pd, &rdev->qplib_res, &qp->qplib_qp);
+	if (!sqp) {
+		rc = -ENODEV;
+		dev_err(rdev_to_dev(rdev),
+			"Failed to create Shadow QP for QP1\n");
+		goto out;
+	}
+	rdev->gsi_ctx.gsi_sqp = sqp;
+
+	sqp->rcq = qp->rcq;
+	sqp->scq = qp->scq;
+	sah = bnxt_re_create_shadow_qp_ah(pd, &rdev->qplib_res,
+			&qp->qplib_qp);
+	if (!sah) {
+		bnxt_qplib_destroy_qp(&rdev->qplib_res,
+				&sqp->qplib_qp);
+		rc = -ENODEV;
+		dev_err(rdev_to_dev(rdev),
+				"Failed to create AH entry for ShadowQP\n");
+		goto out;
+	}
+	rdev->gsi_ctx.gsi_sah = sah;
+
+	return 0;
+out:
+	kfree(sqp_tbl);
+	return rc;
+}
+
+static int __get_rq_hdr_buf_size(u8 gsi_mode)
+{
+	return (gsi_mode == BNXT_RE_GSI_MODE_ALL) ?
+		BNXT_QPLIB_MAX_QP1_RQ_HDR_SIZE_V2 :
+		BNXT_QPLIB_MAX_QP1_RQ_HDR_SIZE;
+}
+
+static int __get_sq_hdr_buf_size(u8 gsi_mode)
+{
+	return (gsi_mode != BNXT_RE_GSI_MODE_ROCE_V1) ?
+		BNXT_QPLIB_MAX_QP1_SQ_HDR_SIZE_V2 :
+		BNXT_QPLIB_MAX_QP1_SQ_HDR_SIZE;
+}
+
+static int bnxt_re_create_gsi_qp(struct bnxt_re_qp *qp, struct bnxt_re_pd *pd)
+{
+	struct bnxt_qplib_qp *qplqp;
+	struct bnxt_qplib_res *res;
+	struct bnxt_re_dev *rdev;
+	u32 sstep, rstep;
+	u8 gsi_mode;
+	int rc = 0;
+
+	rdev = qp->rdev;
+	qplqp = &qp->qplib_qp;
+	res = &rdev->qplib_res;
+	gsi_mode = rdev->gsi_ctx.gsi_qp_mode;
+
+	rstep = __get_rq_hdr_buf_size(gsi_mode);
+	sstep = __get_sq_hdr_buf_size(gsi_mode);
+	rc = bnxt_qplib_alloc_hdr_buf(res, qplqp, sstep, rstep);
+	if (rc)
+		goto out;
+
+	rc = bnxt_qplib_create_qp1(res, qplqp);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev), "create HW QP1 failed!\n");
+		goto out;
+	}
+
+	if (gsi_mode == BNXT_RE_GSI_MODE_ALL)
+		rc = bnxt_re_create_shadow_gsi(qp, pd);
+out:
+	return rc;
+}
+
+static bool bnxt_re_test_qp_limits(struct bnxt_re_dev *rdev,
+				   struct ib_qp_init_attr *init_attr,
+				   struct bnxt_qplib_dev_attr *dev_attr)
+{
+	bool rc = true;
+	int ilsize;
+
+	ilsize = ALIGN(init_attr->cap.max_inline_data, sizeof(struct sq_sge));
+	if ((init_attr->cap.max_send_wr > dev_attr->max_qp_wqes) ||
+	    (init_attr->cap.max_recv_wr > dev_attr->max_qp_wqes) ||
+	    (init_attr->cap.max_send_sge > dev_attr->max_qp_sges) ||
+	    (init_attr->cap.max_recv_sge > dev_attr->max_qp_sges) ||
+	    (ilsize > dev_attr->max_inline_data)) {
+		dev_err(rdev_to_dev(rdev), "Create QP failed - max exceeded! "
+			"0x%x/0x%x 0x%x/0x%x 0x%x/0x%x "
+			"0x%x/0x%x 0x%x/0x%x\n",
+			init_attr->cap.max_send_wr, dev_attr->max_qp_wqes,
+			init_attr->cap.max_recv_wr, dev_attr->max_qp_wqes,
+			init_attr->cap.max_send_sge, dev_attr->max_qp_sges,
+			init_attr->cap.max_recv_sge, dev_attr->max_qp_sges,
+			init_attr->cap.max_inline_data,
+			dev_attr->max_inline_data);
+		rc = false;
+	}
+	return rc;
+}
+
+static inline struct
+bnxt_re_qp *__get_qp_from_qp_in(struct ib_pd *qp_in,
+				struct bnxt_re_dev *rdev)
+{
+	struct bnxt_re_qp *qp;
+
+	qp = kzalloc(sizeof(*qp), GFP_KERNEL);
+	if (!qp)
+		dev_err(rdev_to_dev(rdev), "Allocate QP failed!\n");
+	return qp;
+}
+
+struct ib_qp *bnxt_re_create_qp(struct ib_pd *qp_in,
+			       struct ib_qp_init_attr *qp_init_attr,
+			       struct ib_udata *udata)
+{
+	struct bnxt_re_pd *pd;
+	struct ib_pd *ib_pd = qp_in;
+	struct bnxt_qplib_dev_attr *dev_attr;
+	struct bnxt_re_dev *rdev;
+	u32 active_qps, tmp_qps;
+	struct bnxt_re_qp *qp;
+	int rc;
+
+	pd = to_bnxt_re(ib_pd, struct bnxt_re_pd, ibpd);
+	rdev = pd->rdev;
+	dev_attr = rdev->dev_attr;
+	if (rdev->mod_exit) {
+		rc = -EIO;
+		dev_dbg(rdev_to_dev(rdev), "%s(): in mod_exit, just return!\n", __func__);
+		goto exit;
+	}
+
+	if (atomic_read(&rdev->stats.rsors.qp_count) >= dev_attr->max_qp) {
+		dev_err(rdev_to_dev(rdev), "Create QP failed - max exceeded(QPs Alloc'd %u of max %u)\n",
+			atomic_read(&rdev->stats.rsors.qp_count), dev_attr->max_qp);
+		rc = -EINVAL;
+		goto exit;
+	}
+
+	rc = bnxt_re_test_qp_limits(rdev, qp_init_attr, dev_attr);
+	if (!rc) {
+		rc = -EINVAL;
+		goto exit;
+	}
+	qp = __get_qp_from_qp_in(qp_in, rdev);
+	if (!qp) {
+		rc = -ENOMEM;
+		goto exit;
+	}
+	qp->rdev = rdev;
+
+	rc = bnxt_re_init_qp_attr(qp, pd, qp_init_attr, udata);
+	if (rc)
+		goto fail;
+
+	if (qp_init_attr->qp_type == IB_QPT_GSI &&
+	    !_is_chip_gen_p5_p7(rdev->chip_ctx)) {
+		rc = bnxt_re_create_gsi_qp(qp, pd);
+		if (rc == -ENODEV)
+			goto qp_destroy;
+		if (rc)
+			goto fail;
+	} else {
+		rc = bnxt_qplib_create_qp(&rdev->qplib_res, &qp->qplib_qp);
+		if (rc) {
+			dev_err(rdev_to_dev(rdev), "create HW QP failed!\n");
+			goto free_umem;
+		}
+
+		if (udata) {
+			struct bnxt_re_qp_resp resp;
+
+			resp.qpid = qp->qplib_qp.id;
+			rc = bnxt_re_copy_to_udata(rdev, &resp,
+						   min(udata->outlen, sizeof(resp)),
+						   udata);
+			if (rc)
+				goto qp_destroy;
+		}
+	}
+
+	qp->ib_qp.qp_num = qp->qplib_qp.id;
+	if (qp_init_attr->qp_type == IB_QPT_GSI)
+		rdev->gsi_ctx.gsi_qp = qp;
+	spin_lock_init(&qp->sq_lock);
+	spin_lock_init(&qp->rq_lock);
+	INIT_LIST_HEAD(&qp->list);
+	mutex_lock(&rdev->qp_lock);
+	list_add_tail(&qp->list, &rdev->qp_list);
+	mutex_unlock(&rdev->qp_lock);
+	atomic_inc(&rdev->stats.rsors.qp_count);
+	active_qps = atomic_read(&rdev->stats.rsors.qp_count);
+	if (active_qps > atomic_read(&rdev->stats.rsors.max_qp_count))
+		atomic_set(&rdev->stats.rsors.max_qp_count, active_qps);
+
+	bnxt_re_dump_debug_stats(rdev, active_qps);
+
+	/* Get the counters for RC QPs and UD QPs */
+	if (qp_init_attr->qp_type == IB_QPT_RC) {
+		tmp_qps = atomic_inc_return(&rdev->stats.rsors.rc_qp_count);
+		if (tmp_qps > atomic_read(&rdev->stats.rsors.max_rc_qp_count))
+			atomic_set(&rdev->stats.rsors.max_rc_qp_count, tmp_qps);
+	} else if (qp_init_attr->qp_type == IB_QPT_UD) {
+		tmp_qps = atomic_inc_return(&rdev->stats.rsors.ud_qp_count);
+		if (tmp_qps > atomic_read(&rdev->stats.rsors.max_ud_qp_count))
+			atomic_set(&rdev->stats.rsors.max_ud_qp_count, tmp_qps);
+	}
+
+	return &qp->ib_qp;
+
+qp_destroy:
+	bnxt_qplib_destroy_qp(&rdev->qplib_res, &qp->qplib_qp);
+free_umem:
+	if (udata) {
+		if (qp->rumem && !IS_ERR(qp->rumem))
+			ib_umem_release(qp->rumem);
+		if (qp->sumem && !IS_ERR(qp->sumem))
+			ib_umem_release(qp->sumem);
+	}
+fail:
+	kfree(qp);
+exit:
+	return ERR_PTR(rc);
+}
+
+static int bnxt_re_modify_shadow_qp(struct bnxt_re_dev *rdev,
+			     struct bnxt_re_qp *qp1_qp,
+			     int qp_attr_mask)
+{
+	struct bnxt_re_qp *qp = rdev->gsi_ctx.gsi_sqp;
+	int rc = 0;
+
+	if (qp_attr_mask & IB_QP_STATE) {
+		qp->qplib_qp.modify_flags |= CMDQ_MODIFY_QP_MODIFY_MASK_STATE;
+		qp->qplib_qp.state = qp1_qp->qplib_qp.state;
+	}
+	if (qp_attr_mask & IB_QP_PKEY_INDEX) {
+		qp->qplib_qp.modify_flags |= CMDQ_MODIFY_QP_MODIFY_MASK_PKEY;
+		qp->qplib_qp.pkey_index = qp1_qp->qplib_qp.pkey_index;
+	}
+
+	if (qp_attr_mask & IB_QP_QKEY) {
+		qp->qplib_qp.modify_flags |= CMDQ_MODIFY_QP_MODIFY_MASK_QKEY;
+		/* Using a Random  QKEY */
+		qp->qplib_qp.qkey = BNXT_RE_QP_RANDOM_QKEY;
+	}
+	if (qp_attr_mask & IB_QP_SQ_PSN) {
+		qp->qplib_qp.modify_flags |= CMDQ_MODIFY_QP_MODIFY_MASK_SQ_PSN;
+		qp->qplib_qp.sq.psn = qp1_qp->qplib_qp.sq.psn;
+	}
+
+	rc = bnxt_qplib_modify_qp(&rdev->qplib_res, &qp->qplib_qp);
+	if (rc)
+		dev_err(rdev_to_dev(rdev), "Modify Shadow QP for QP1 failed\n");
+	return rc;
+}
+
+static u32 ipv4_from_gid(u8 *gid)
+{
+	return (gid[15] << 24 | gid[14] << 16 | gid[13] << 8 | gid[12]);
+}
+
+static u16 get_source_port(struct bnxt_re_dev *rdev,
+			   struct bnxt_re_qp *qp)
+{
+	u8 ip_off, data[48], smac[ETH_ALEN];
+	u16 crc = 0, buf_len = 0, i;
+	u8 addr_len;
+	u32 qpn;
+
+	if (qp->qplib_qp.nw_type == CMDQ_MODIFY_QP_NETWORK_TYPE_ROCEV2_IPV6) {
+		addr_len = 6;
+		ip_off = 10;
+	} else {
+		addr_len = 4;
+		ip_off = 12;
+	}
+
+	memcpy(smac, qp->qplib_qp.smac, ETH_ALEN);
+
+	memset(data, 0, 48);
+	memcpy(data, qp->qplib_qp.ah.dmac, ETH_ALEN);
+	buf_len += ETH_ALEN;
+
+	memcpy(data + buf_len, smac, ETH_ALEN);
+	buf_len += ETH_ALEN;
+
+	memcpy(data + buf_len, qp->qplib_qp.ah.dgid.data + ip_off, addr_len);
+	buf_len += addr_len;
+
+	memcpy(data + buf_len, qp->qp_info_entry.sgid.raw + ip_off, addr_len);
+	buf_len += addr_len;
+
+	qpn = htonl(qp->qplib_qp.dest_qpn);
+	memcpy(data + buf_len, (u8 *)&qpn + 1, 3);
+	buf_len += 3;
+
+	for (i = 0; i < buf_len; i++)
+		crc = crc16(crc, (data + i), 1);
+
+	return crc;
+}
+
+static void bnxt_re_update_qp_info(struct bnxt_re_dev *rdev, struct bnxt_re_qp *qp)
+{
+	u16 type;
+
+	type = __from_hw_to_ib_qp_type(qp->qplib_qp.type);
+
+	/* User-space can extract ip address with sgid_index. */
+	if (ipv6_addr_v4mapped((struct in6_addr *)&qp->qplib_qp.ah.dgid)) {
+		qp->qp_info_entry.s_ip.ipv4_addr = ipv4_from_gid(qp->qp_info_entry.sgid.raw);
+		qp->qp_info_entry.d_ip.ipv4_addr = ipv4_from_gid(qp->qplib_qp.ah.dgid.data);
+	} else {
+		memcpy(&qp->qp_info_entry.s_ip.ipv6_addr, qp->qp_info_entry.sgid.raw,
+		       sizeof(qp->qp_info_entry.s_ip.ipv6_addr));
+		memcpy(&qp->qp_info_entry.d_ip.ipv6_addr, qp->qplib_qp.ah.dgid.data,
+		       sizeof(qp->qp_info_entry.d_ip.ipv6_addr));
+	}
+
+	if (type == IB_QPT_RC &&
+	    (qp->qplib_qp.nw_type == CMDQ_MODIFY_QP_NETWORK_TYPE_ROCEV2_IPV4 ||
+	     qp->qplib_qp.nw_type == CMDQ_MODIFY_QP_NETWORK_TYPE_ROCEV2_IPV6)) {
+		qp->qp_info_entry.s_port = get_source_port(rdev, qp);
+	}
+	qp->qp_info_entry.d_port = BNXT_RE_QP_DEST_PORT;
+}
+
+static void bnxt_qplib_manage_flush_qp(struct bnxt_re_qp *qp)
+{
+	struct bnxt_qplib_q *rq, *sq;
+	unsigned long flags;
+
+	if (qp->sumem)
+		return;
+
+	if (qp->qplib_qp.state == CMDQ_MODIFY_QP_NEW_STATE_ERR) {
+		rq = &qp->qplib_qp.rq;
+		sq = &qp->qplib_qp.sq;
+
+		dev_dbg(rdev_to_dev(qp->rdev),
+			"Move QP = %p to flush list\n", qp);
+		flags = bnxt_re_lock_cqs(qp);
+		bnxt_qplib_add_flush_qp(&qp->qplib_qp);
+		bnxt_re_unlock_cqs(qp, flags);
+
+		if (sq->hwq.prod != sq->hwq.cons)
+			bnxt_re_handle_cqn(&qp->scq->qplib_cq);
+
+		if (qp->rcq && (qp->rcq != qp->scq) &&
+		    (rq->hwq.prod != rq->hwq.cons))
+			bnxt_re_handle_cqn(&qp->rcq->qplib_cq);
+	}
+
+	if (qp->qplib_qp.state == CMDQ_MODIFY_QP_NEW_STATE_RESET) {
+		dev_dbg(rdev_to_dev(qp->rdev),
+			"Move QP = %p out of flush list\n", qp);
+		flags = bnxt_re_lock_cqs(qp);
+		bnxt_qplib_clean_qp(&qp->qplib_qp);
+		bnxt_re_unlock_cqs(qp, flags);
+	}
+}
+
+bool ib_modify_qp_is_ok_compat(enum ib_qp_state cur_state,
+			       enum ib_qp_state next_state,
+			       enum ib_qp_type type,
+			       enum ib_qp_attr_mask mask)
+{
+		return (ib_modify_qp_is_ok(cur_state, next_state,
+					   type, mask));
+}
+
+int bnxt_re_modify_qp(struct ib_qp *ib_qp, struct ib_qp_attr *qp_attr,
+		      int qp_attr_mask, struct ib_udata *udata)
+{
+	enum ib_qp_state curr_qp_state, new_qp_state;
+	struct bnxt_re_modify_qp_ex_resp resp = {};
+	struct bnxt_re_modify_qp_ex_req ureq = {};
+	struct bnxt_qplib_dev_attr *dev_attr;
+	struct bnxt_qplib_ppp *ppp = NULL;
+	struct bnxt_re_dev *rdev;
+	struct bnxt_re_qp *qp;
+	struct ib_gid_attr *sgid_attr;
+	struct ib_gid_attr gid_attr;
+	union ib_gid sgid, *gid_ptr = NULL;
+	u8 nw_type;
+	int rc, entries, status;
+	bool is_copy_to_udata = false;
+	bool is_qpmtu_high = false;
+
+	qp = to_bnxt_re(ib_qp, struct bnxt_re_qp, ib_qp);
+	rdev = qp->rdev;
+	dev_attr = rdev->dev_attr;
+
+	qp->qplib_qp.modify_flags = 0;
+	ppp = &qp->qplib_qp.ppp;
+	if (qp_attr_mask & IB_QP_STATE) {
+		curr_qp_state = __to_ib_qp_state(qp->qplib_qp.cur_qp_state);
+		new_qp_state = qp_attr->qp_state;
+		if (!ib_modify_qp_is_ok_compat(curr_qp_state, new_qp_state,
+					       ib_qp->qp_type, qp_attr_mask)) {
+			dev_err(rdev_to_dev(rdev),"invalid attribute mask=0x%x"
+				" specified for qpn=0x%x of type=0x%x"
+				" current_qp_state=0x%x, new_qp_state=0x%x\n",
+				qp_attr_mask, ib_qp->qp_num, ib_qp->qp_type,
+				curr_qp_state, new_qp_state);
+			return -EINVAL;
+		}
+		dev_dbg(rdev_to_dev(rdev), "%s:%d INFO attribute mask=0x%x qpn=0x%x "
+			"of type=0x%x current_qp_state=0x%x, new_qp_state=0x%x\n",
+			__func__, __LINE__, qp_attr_mask, ib_qp->qp_num,
+			ib_qp->qp_type, curr_qp_state, new_qp_state);
+		qp->qplib_qp.modify_flags |= CMDQ_MODIFY_QP_MODIFY_MASK_STATE;
+		qp->qplib_qp.state = __from_ib_qp_state(qp_attr->qp_state);
+
+		if (udata && curr_qp_state == IB_QPS_RESET &&
+		    new_qp_state == IB_QPS_INIT) {
+			if (!ib_copy_from_udata(&ureq, udata, sizeof(ureq))) {
+				if (ureq.comp_mask &
+				    BNXT_RE_COMP_MASK_MQP_EX_PPP_REQ_EN_MASK) {
+					ppp->req = BNXT_QPLIB_PPP_REQ;
+					ppp->dpi = ureq.dpi;
+				}
+			}
+		}
+	}
+	if (qp_attr_mask & IB_QP_EN_SQD_ASYNC_NOTIFY) {
+		qp->qplib_qp.modify_flags |=
+				CMDQ_MODIFY_QP_MODIFY_MASK_EN_SQD_ASYNC_NOTIFY;
+		qp->qplib_qp.en_sqd_async_notify = true;
+	}
+	if (qp_attr_mask & IB_QP_ACCESS_FLAGS) {
+		qp->qplib_qp.modify_flags |= CMDQ_MODIFY_QP_MODIFY_MASK_ACCESS;
+		qp->qplib_qp.access =
+			__from_ib_access_flags(qp_attr->qp_access_flags);
+		/* LOCAL_WRITE access must be set to allow RC receive */
+		qp->qplib_qp.access |= BNXT_QPLIB_ACCESS_LOCAL_WRITE;
+		qp->qplib_qp.access |= CMDQ_MODIFY_QP_ACCESS_REMOTE_WRITE;
+		qp->qplib_qp.access |= CMDQ_MODIFY_QP_ACCESS_REMOTE_READ;
+	}
+	if (qp_attr_mask & IB_QP_PKEY_INDEX) {
+		qp->qplib_qp.modify_flags |= CMDQ_MODIFY_QP_MODIFY_MASK_PKEY;
+		qp->qplib_qp.pkey_index = qp_attr->pkey_index;
+	}
+	if (qp_attr_mask & IB_QP_QKEY) {
+		qp->qplib_qp.modify_flags |= CMDQ_MODIFY_QP_MODIFY_MASK_QKEY;
+		qp->qplib_qp.qkey = qp_attr->qkey;
+	}
+	if (qp_attr_mask & IB_QP_AV) {
+		qp->qplib_qp.modify_flags |= CMDQ_MODIFY_QP_MODIFY_MASK_DGID |
+				     CMDQ_MODIFY_QP_MODIFY_MASK_FLOW_LABEL |
+				     CMDQ_MODIFY_QP_MODIFY_MASK_SGID_INDEX |
+				     CMDQ_MODIFY_QP_MODIFY_MASK_HOP_LIMIT |
+				     CMDQ_MODIFY_QP_MODIFY_MASK_TRAFFIC_CLASS |
+				     CMDQ_MODIFY_QP_MODIFY_MASK_DEST_MAC |
+				     CMDQ_MODIFY_QP_MODIFY_MASK_VLAN_ID;
+		memcpy(qp->qplib_qp.ah.dgid.data, qp_attr->ah_attr.grh.dgid.raw,
+		       sizeof(qp->qplib_qp.ah.dgid.data));
+		qp->qplib_qp.ah.flow_label = qp_attr->ah_attr.grh.flow_label;
+		qp->qplib_qp.ah.sgid_index = _get_sgid_index(rdev,
+						qp_attr->ah_attr.grh.sgid_index);
+		qp->qplib_qp.ah.host_sgid_index = qp_attr->ah_attr.grh.sgid_index;
+		qp->qplib_qp.ah.hop_limit = qp_attr->ah_attr.grh.hop_limit;
+		qp->qplib_qp.ah.traffic_class =
+					qp_attr->ah_attr.grh.traffic_class;
+		qp->qplib_qp.ah.sl = qp_attr->ah_attr.sl;
+		ether_addr_copy(qp->qplib_qp.ah.dmac, ROCE_DMAC(&qp_attr->ah_attr));
+		sgid_attr = &gid_attr;
+		status = bnxt_re_get_cached_gid(&rdev->ibdev, 1,
+						qp_attr->ah_attr.grh.sgid_index,
+						&sgid, &sgid_attr,
+						&qp_attr->ah_attr.grh, NULL);
+		if (!status)
+			if_rele(sgid_attr->ndev);
+		gid_ptr = &sgid;
+		if (sgid_attr->ndev) {
+			memcpy(qp->qplib_qp.smac, rdev->dev_addr,
+			       ETH_ALEN);
+			nw_type = bnxt_re_gid_to_network_type(sgid_attr, &sgid);
+			dev_dbg(rdev_to_dev(rdev),
+				 "Connection using the nw_type %d\n", nw_type);
+			switch (nw_type) {
+			case RDMA_NETWORK_IPV4:
+				qp->qplib_qp.nw_type =
+					CMDQ_MODIFY_QP_NETWORK_TYPE_ROCEV2_IPV4;
+				break;
+			case RDMA_NETWORK_IPV6:
+				qp->qplib_qp.nw_type =
+					CMDQ_MODIFY_QP_NETWORK_TYPE_ROCEV2_IPV6;
+				break;
+			default:
+				qp->qplib_qp.nw_type =
+					CMDQ_MODIFY_QP_NETWORK_TYPE_ROCEV1;
+				break;
+			}
+		}
+		memcpy(&qp->qp_info_entry.sgid, gid_ptr, sizeof(qp->qp_info_entry.sgid));
+	}
+
+	/* MTU settings allowed only during INIT -> RTR */
+	if (qp_attr->qp_state == IB_QPS_RTR) {
+		bnxt_re_init_qpmtu(qp, rdev->netdev->if_mtu, qp_attr_mask, qp_attr,
+				   &is_qpmtu_high);
+		if (udata && !ib_copy_from_udata(&ureq, udata, sizeof(ureq))) {
+			if (ureq.comp_mask & BNXT_RE_COMP_MASK_MQP_EX_PATH_MTU_MASK) {
+				resp.comp_mask |= BNXT_RE_COMP_MASK_MQP_EX_PATH_MTU_MASK;
+				resp.path_mtu = qp->qplib_qp.mtu;
+				is_copy_to_udata = true;
+			} else if (is_qpmtu_high) {
+				dev_err(rdev_to_dev(rdev), "qp %#x invalid mtu\n",
+					qp->qplib_qp.id);
+				return -EINVAL;
+			}
+		}
+	}
+
+	if (qp_attr_mask & IB_QP_TIMEOUT) {
+		qp->qplib_qp.modify_flags |= CMDQ_MODIFY_QP_MODIFY_MASK_TIMEOUT;
+		qp->qplib_qp.timeout = qp_attr->timeout;
+	}
+	if (qp_attr_mask & IB_QP_RETRY_CNT) {
+		qp->qplib_qp.modify_flags |=
+				CMDQ_MODIFY_QP_MODIFY_MASK_RETRY_CNT;
+		qp->qplib_qp.retry_cnt = qp_attr->retry_cnt;
+	}
+	if (qp_attr_mask & IB_QP_RNR_RETRY) {
+		qp->qplib_qp.modify_flags |=
+				CMDQ_MODIFY_QP_MODIFY_MASK_RNR_RETRY;
+		qp->qplib_qp.rnr_retry = qp_attr->rnr_retry;
+	}
+	if (qp_attr_mask & IB_QP_MIN_RNR_TIMER) {
+		qp->qplib_qp.modify_flags |=
+				CMDQ_MODIFY_QP_MODIFY_MASK_MIN_RNR_TIMER;
+		qp->qplib_qp.min_rnr_timer = qp_attr->min_rnr_timer;
+	}
+	if (qp_attr_mask & IB_QP_RQ_PSN) {
+		qp->qplib_qp.modify_flags |= CMDQ_MODIFY_QP_MODIFY_MASK_RQ_PSN;
+		qp->qplib_qp.rq.psn = qp_attr->rq_psn;
+	}
+	if (qp_attr_mask & IB_QP_MAX_QP_RD_ATOMIC) {
+		qp->qplib_qp.modify_flags |=
+				CMDQ_MODIFY_QP_MODIFY_MASK_MAX_RD_ATOMIC;
+		/* Cap the max_rd_atomic to device max */
+		if (qp_attr->max_rd_atomic > dev_attr->max_qp_rd_atom)
+			dev_dbg(rdev_to_dev(rdev),
+				"max_rd_atomic requested %d is > device max %d\n",
+				qp_attr->max_rd_atomic,
+				dev_attr->max_qp_rd_atom);
+		qp->qplib_qp.max_rd_atomic = min_t(u32, qp_attr->max_rd_atomic,
+						   dev_attr->max_qp_rd_atom);
+	}
+	if (qp_attr_mask & IB_QP_SQ_PSN) {
+		qp->qplib_qp.modify_flags |= CMDQ_MODIFY_QP_MODIFY_MASK_SQ_PSN;
+		qp->qplib_qp.sq.psn = qp_attr->sq_psn;
+	}
+	if (qp_attr_mask & IB_QP_MAX_DEST_RD_ATOMIC) {
+		if (qp_attr->max_dest_rd_atomic >
+		    dev_attr->max_qp_init_rd_atom) {
+			dev_err(rdev_to_dev(rdev),
+				"max_dest_rd_atomic requested %d is > device max %d\n",
+				qp_attr->max_dest_rd_atomic,
+				dev_attr->max_qp_init_rd_atom);
+			return -EINVAL;
+		}
+		qp->qplib_qp.modify_flags |=
+				CMDQ_MODIFY_QP_MODIFY_MASK_MAX_DEST_RD_ATOMIC;
+		qp->qplib_qp.max_dest_rd_atomic = qp_attr->max_dest_rd_atomic;
+	}
+	if (qp_attr_mask & IB_QP_CAP) {
+		qp->qplib_qp.modify_flags |=
+				CMDQ_MODIFY_QP_MODIFY_MASK_SQ_SIZE |
+				CMDQ_MODIFY_QP_MODIFY_MASK_RQ_SIZE |
+				CMDQ_MODIFY_QP_MODIFY_MASK_SQ_SGE |
+				CMDQ_MODIFY_QP_MODIFY_MASK_RQ_SGE |
+				CMDQ_MODIFY_QP_MODIFY_MASK_MAX_INLINE_DATA;
+		if ((qp_attr->cap.max_send_wr >= dev_attr->max_qp_wqes) ||
+		    (qp_attr->cap.max_recv_wr >= dev_attr->max_qp_wqes) ||
+		    (qp_attr->cap.max_send_sge >= dev_attr->max_qp_sges) ||
+		    (qp_attr->cap.max_recv_sge >= dev_attr->max_qp_sges) ||
+		    (qp_attr->cap.max_inline_data >=
+						dev_attr->max_inline_data)) {
+			dev_err(rdev_to_dev(rdev),
+				"Create QP failed - max exceeded\n");
+			return -EINVAL;
+		}
+		entries = roundup_pow_of_two(qp_attr->cap.max_send_wr);
+		if (entries > dev_attr->max_qp_wqes)
+			entries = dev_attr->max_qp_wqes;
+		entries = min_t(u32, entries, dev_attr->max_qp_wqes);
+		qp->qplib_qp.sq.max_wqe = entries;
+		qp->qplib_qp.sq.q_full_delta = qp->qplib_qp.sq.max_wqe -
+						qp_attr->cap.max_send_wr;
+		/*
+		 * Reserving one slot for Phantom WQE. Some application can
+		 * post one extra entry in this case. Allowing this to avoid
+		 * unexpected Queue full condition
+		 */
+		qp->qplib_qp.sq.q_full_delta -= 1;
+		qp->qplib_qp.sq.max_sge = qp_attr->cap.max_send_sge;
+		if (qp->qplib_qp.rq.max_wqe) {
+			entries = roundup_pow_of_two(qp_attr->cap.max_recv_wr);
+			if (entries > dev_attr->max_qp_wqes)
+				entries = dev_attr->max_qp_wqes;
+			qp->qplib_qp.rq.max_wqe = entries;
+			qp->qplib_qp.rq.q_full_delta = qp->qplib_qp.rq.max_wqe -
+						       qp_attr->cap.max_recv_wr;
+			qp->qplib_qp.rq.max_sge = qp_attr->cap.max_recv_sge;
+		} else {
+			/* SRQ was used prior, just ignore the RQ caps */
+		}
+	}
+	if (qp_attr_mask & IB_QP_DEST_QPN) {
+		qp->qplib_qp.modify_flags |=
+				CMDQ_MODIFY_QP_MODIFY_MASK_DEST_QP_ID;
+		qp->qplib_qp.dest_qpn = qp_attr->dest_qp_num;
+	}
+
+	rc = bnxt_qplib_modify_qp(&rdev->qplib_res, &qp->qplib_qp);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev), "Modify HW QP failed!\n");
+		return rc;
+	}
+	if (qp_attr_mask & IB_QP_STATE)
+		bnxt_qplib_manage_flush_qp(qp);
+	if (ureq.comp_mask & BNXT_RE_COMP_MASK_MQP_EX_PPP_REQ_EN_MASK &&
+	    ppp->st_idx_en & CREQ_MODIFY_QP_RESP_PINGPONG_PUSH_ENABLED) {
+		resp.comp_mask |= BNXT_RE_COMP_MASK_MQP_EX_PPP_REQ_EN;
+		resp.ppp_st_idx = ppp->st_idx_en >>
+				  BNXT_QPLIB_PPP_ST_IDX_SHIFT;
+		is_copy_to_udata = true;
+	}
+
+	if (is_copy_to_udata) {
+		rc = bnxt_re_copy_to_udata(rdev, &resp,
+					   min(udata->outlen, sizeof(resp)),
+					   udata);
+		if (rc)
+			return rc;
+	}
+
+	if (ib_qp->qp_type == IB_QPT_GSI &&
+	    rdev->gsi_ctx.gsi_qp_mode == BNXT_RE_GSI_MODE_ALL &&
+	    rdev->gsi_ctx.gsi_sqp)
+		rc = bnxt_re_modify_shadow_qp(rdev, qp, qp_attr_mask);
+	/*
+	 * Update info when qp_info_info
+	 */
+	bnxt_re_update_qp_info(rdev, qp);
+	return rc;
+}
+
+int bnxt_re_query_qp(struct ib_qp *ib_qp, struct ib_qp_attr *qp_attr,
+		     int qp_attr_mask, struct ib_qp_init_attr *qp_init_attr)
+{
+	struct bnxt_re_qp *qp = to_bnxt_re(ib_qp, struct bnxt_re_qp, ib_qp);
+	struct bnxt_re_dev *rdev = qp->rdev;
+	struct bnxt_qplib_qp *qplib_qp;
+	int rc;
+
+	qplib_qp = kcalloc(1, sizeof(*qplib_qp), GFP_KERNEL);
+	if (!qplib_qp)
+		return -ENOMEM;
+
+	qplib_qp->id = qp->qplib_qp.id;
+	qplib_qp->ah.host_sgid_index = qp->qplib_qp.ah.host_sgid_index;
+
+	rc = bnxt_qplib_query_qp(&rdev->qplib_res, qplib_qp);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev), "Query HW QP (0x%x) failed! rc = %d\n",
+			qplib_qp->id, rc);
+		goto free_mem;
+	}
+	qp_attr->qp_state = __to_ib_qp_state(qplib_qp->state);
+	qp_attr->cur_qp_state = __to_ib_qp_state(qplib_qp->cur_qp_state);
+	qp_attr->en_sqd_async_notify = qplib_qp->en_sqd_async_notify ? 1 : 0;
+	qp_attr->qp_access_flags = __to_ib_access_flags(qplib_qp->access);
+	qp_attr->pkey_index = qplib_qp->pkey_index;
+	qp_attr->qkey = qplib_qp->qkey;
+	memcpy(qp_attr->ah_attr.grh.dgid.raw, qplib_qp->ah.dgid.data,
+	       sizeof(qplib_qp->ah.dgid.data));
+	qp_attr->ah_attr.grh.flow_label = qplib_qp->ah.flow_label;
+	qp_attr->ah_attr.grh.sgid_index = qplib_qp->ah.host_sgid_index;
+	qp_attr->ah_attr.grh.hop_limit = qplib_qp->ah.hop_limit;
+	qp_attr->ah_attr.grh.traffic_class = qplib_qp->ah.traffic_class;
+	qp_attr->ah_attr.sl = qplib_qp->ah.sl;
+	ether_addr_copy(ROCE_DMAC(&qp_attr->ah_attr), qplib_qp->ah.dmac);
+	qp_attr->path_mtu = __to_ib_mtu(qplib_qp->path_mtu);
+	qp_attr->timeout = qplib_qp->timeout;
+	qp_attr->retry_cnt = qplib_qp->retry_cnt;
+	qp_attr->rnr_retry = qplib_qp->rnr_retry;
+	qp_attr->min_rnr_timer = qplib_qp->min_rnr_timer;
+	qp_attr->rq_psn = qplib_qp->rq.psn;
+	qp_attr->max_rd_atomic = qplib_qp->max_rd_atomic;
+	qp_attr->sq_psn = qplib_qp->sq.psn;
+	qp_attr->max_dest_rd_atomic = qplib_qp->max_dest_rd_atomic;
+	qp_init_attr->sq_sig_type = qplib_qp->sig_type ? IB_SIGNAL_ALL_WR :
+							IB_SIGNAL_REQ_WR;
+	qp_attr->dest_qp_num = qplib_qp->dest_qpn;
+
+	qp_attr->cap.max_send_wr = qp->qplib_qp.sq.max_wqe;
+	qp_attr->cap.max_send_sge = qp->qplib_qp.sq.max_sge;
+	qp_attr->cap.max_recv_wr = qp->qplib_qp.rq.max_wqe;
+	qp_attr->cap.max_recv_sge = qp->qplib_qp.rq.max_sge;
+	qp_attr->cap.max_inline_data = qp->qplib_qp.max_inline_data;
+	qp_init_attr->cap = qp_attr->cap;
+
+free_mem:
+	kfree(qplib_qp);
+	return rc;
+}
+
+/* Builders */
+
+/* For Raw, the application is responsible to build the entire packet */
+static void bnxt_re_build_raw_send(const struct ib_send_wr *wr,
+				   struct bnxt_qplib_swqe *wqe)
+{
+	switch (wr->send_flags) {
+	case IB_SEND_IP_CSUM:
+		wqe->rawqp1.lflags |= SQ_SEND_RAWETH_QP1_LFLAGS_IP_CHKSUM;
+		break;
+	default:
+		/* Pad HW RoCE iCRC */
+		wqe->rawqp1.lflags |= SQ_SEND_RAWETH_QP1_LFLAGS_ROCE_CRC;
+		break;
+	}
+}
+
+/* For QP1, the driver must build the entire RoCE (v1/v2) packet hdr
+ * as according to the sgid and AV
+ */
+static int bnxt_re_build_qp1_send(struct bnxt_re_qp *qp, const struct ib_send_wr *wr,
+				  struct bnxt_qplib_swqe *wqe, int payload_size)
+{
+	struct bnxt_re_ah *ah = to_bnxt_re(ud_wr(wr)->ah, struct bnxt_re_ah,
+					   ibah);
+	struct bnxt_qplib_ah *qplib_ah = &ah->qplib_ah;
+	struct bnxt_qplib_sge sge;
+	int i, rc = 0;
+	union ib_gid sgid;
+	u16 vlan_id;
+	u8 *ptmac;
+	void *buf;
+
+	memset(&qp->qp1_hdr, 0, sizeof(qp->qp1_hdr));
+
+	/* Get sgid */
+	rc = bnxt_re_query_gid(&qp->rdev->ibdev, 1, qplib_ah->sgid_index, &sgid);
+	if (rc)
+		return rc;
+
+	/* ETH */
+	qp->qp1_hdr.eth_present = 1;
+	ptmac = ah->qplib_ah.dmac;
+	memcpy(qp->qp1_hdr.eth.dmac_h, ptmac, 4);
+	ptmac += 4;
+	memcpy(qp->qp1_hdr.eth.dmac_l, ptmac, 2);
+
+	ptmac = qp->qplib_qp.smac;
+	memcpy(qp->qp1_hdr.eth.smac_h, ptmac, 2);
+	ptmac += 2;
+	memcpy(qp->qp1_hdr.eth.smac_l, ptmac, 4);
+
+	qp->qp1_hdr.eth.type = cpu_to_be16(BNXT_QPLIB_ETHTYPE_ROCEV1);
+
+	/* For vlan, check the sgid for vlan existence */
+	vlan_id = rdma_get_vlan_id(&sgid);
+	if (vlan_id && vlan_id < 0x1000) {
+		qp->qp1_hdr.vlan_present = 1;
+		qp->qp1_hdr.eth.type = cpu_to_be16(ETH_P_8021Q);
+	}
+	/* GRH */
+	qp->qp1_hdr.grh_present = 1;
+	qp->qp1_hdr.grh.ip_version = 6;
+	qp->qp1_hdr.grh.payload_length =
+		cpu_to_be16((IB_BTH_BYTES + IB_DETH_BYTES + payload_size + 7)
+			    & ~3);
+	qp->qp1_hdr.grh.next_header = 0x1b;
+	memcpy(qp->qp1_hdr.grh.source_gid.raw, sgid.raw, sizeof(sgid));
+	memcpy(qp->qp1_hdr.grh.destination_gid.raw, qplib_ah->dgid.data,
+	       sizeof(sgid));
+
+	/* BTH */
+	if (wr->opcode == IB_WR_SEND_WITH_IMM) {
+		qp->qp1_hdr.bth.opcode = IB_OPCODE_UD_SEND_ONLY_WITH_IMMEDIATE;
+		qp->qp1_hdr.immediate_present = 1;
+	} else {
+		qp->qp1_hdr.bth.opcode = IB_OPCODE_UD_SEND_ONLY;
+	}
+	if (wr->send_flags & IB_SEND_SOLICITED)
+		qp->qp1_hdr.bth.solicited_event = 1;
+	qp->qp1_hdr.bth.pad_count = (4 - payload_size) & 3;
+	/* P_key for QP1 is for all members */
+	qp->qp1_hdr.bth.pkey = cpu_to_be16(0xFFFF);
+	qp->qp1_hdr.bth.destination_qpn = IB_QP1;
+	qp->qp1_hdr.bth.ack_req = 0;
+	qp->send_psn++;
+	qp->send_psn &= BTH_PSN_MASK;
+	qp->qp1_hdr.bth.psn = cpu_to_be32(qp->send_psn);
+	/* DETH */
+	/* Use the priviledged Q_Key for QP1 */
+	qp->qp1_hdr.deth.qkey = cpu_to_be32(IB_QP1_QKEY);
+	qp->qp1_hdr.deth.source_qpn = IB_QP1;
+
+	/* Pack the QP1 to the transmit buffer */
+	buf = bnxt_qplib_get_qp1_sq_buf(&qp->qplib_qp, &sge);
+	if (!buf) {
+		dev_err(rdev_to_dev(qp->rdev), "QP1 buffer is empty!\n");
+		rc = -ENOMEM;
+	}
+	for (i = wqe->num_sge; i; i--) {
+		wqe->sg_list[i].addr = wqe->sg_list[i - 1].addr;
+		wqe->sg_list[i].lkey = wqe->sg_list[i - 1].lkey;
+		wqe->sg_list[i].size = wqe->sg_list[i - 1].size;
+	}
+	wqe->sg_list[0].addr = sge.addr;
+	wqe->sg_list[0].lkey = sge.lkey;
+	wqe->sg_list[0].size = sge.size;
+	wqe->num_sge++;
+
+	return rc;
+}
+
+static int bnxt_re_build_gsi_send(struct bnxt_re_qp *qp,
+				  const struct ib_send_wr *wr,
+				  struct bnxt_qplib_swqe *wqe)
+{
+	struct bnxt_re_dev *rdev;
+	int rc, indx, len = 0;
+
+	rdev = qp->rdev;
+
+	/* Mode UD is applicable to Gen P5 only */
+	if (rdev->gsi_ctx.gsi_qp_mode == BNXT_RE_GSI_MODE_UD)
+		return 0;
+
+	for (indx = 0; indx < wr->num_sge; indx++) {
+		wqe->sg_list[indx].addr = wr->sg_list[indx].addr;
+		wqe->sg_list[indx].lkey = wr->sg_list[indx].lkey;
+		wqe->sg_list[indx].size = wr->sg_list[indx].length;
+		len += wr->sg_list[indx].length;
+	}
+	rc = bnxt_re_build_qp1_send(qp, wr, wqe, len);
+	wqe->rawqp1.lflags |= SQ_SEND_RAWETH_QP1_LFLAGS_ROCE_CRC;
+
+	return rc;
+}
+
+/* For the MAD layer, it only provides the recv SGE the size of
+   ib_grh + MAD datagram.  No Ethernet headers, Ethertype, BTH, DETH,
+   nor RoCE iCRC.  The Cu+ solution must provide buffer for the entire
+   receive packet (334 bytes) with no VLAN and then copy the GRH
+   and the MAD datagram out to the provided SGE.
+*/
+
+static int bnxt_re_build_qp1_recv(struct bnxt_re_qp *qp,
+				  const struct ib_recv_wr *wr,
+				  struct bnxt_qplib_swqe *wqe)
+{
+	struct bnxt_re_dev *rdev = qp->rdev;
+	struct bnxt_qplib_sge ref, sge;
+	u8 udp_hdr_size = 0;
+	u8 ip_hdr_size = 0;
+	int rc = 0;
+	int size;
+
+	if (bnxt_qplib_get_qp1_rq_buf(&qp->qplib_qp, &sge)) {
+		/* Create 5 SGEs as according to the following:
+		 * Ethernet header (14)
+		 * ib_grh (40) - as provided from the wr
+		 * ib_bth + ib_deth + UDP(RoCE v2 only)  (28)
+		 * MAD (256) - as provided from the wr
+		 * iCRC (4)
+		 */
+
+		/* Set RoCE v2 header size and offsets */
+		if (rdev->gsi_ctx.gsi_qp_mode == BNXT_RE_GSI_MODE_ROCE_V2_IPV4)
+			ip_hdr_size = 20;
+		if (rdev->gsi_ctx.gsi_qp_mode != BNXT_RE_GSI_MODE_ROCE_V1)
+			udp_hdr_size = 8;
+
+		/* Save the reference from ULP */
+		ref.addr = wr->sg_list[0].addr;
+		ref.lkey = wr->sg_list[0].lkey;
+		ref.size = wr->sg_list[0].length;
+
+		/* SGE 1 */
+		size = sge.size;
+		wqe->sg_list[0].addr = sge.addr;
+		wqe->sg_list[0].lkey = sge.lkey;
+		wqe->sg_list[0].size = BNXT_QPLIB_MAX_QP1_RQ_ETH_HDR_SIZE;
+		size -= wqe->sg_list[0].size;
+		if (size <= 0) {
+			dev_err(rdev_to_dev(qp->rdev),"QP1 rq buffer is empty!\n");
+			rc = -ENOMEM;
+			goto done;
+		}
+		sge.size = (u32)size;
+		sge.addr += wqe->sg_list[0].size;
+
+		/* SGE 2 */
+		/* In case of RoCE v2 ipv4 lower 20 bytes should have IP hdr */
+		wqe->sg_list[1].addr = ref.addr + ip_hdr_size;
+		wqe->sg_list[1].lkey = ref.lkey;
+		wqe->sg_list[1].size = sizeof(struct ib_grh) - ip_hdr_size;
+		ref.size -= wqe->sg_list[1].size;
+		if (ref.size <= 0) {
+			dev_err(rdev_to_dev(qp->rdev),
+				"QP1 ref buffer is empty!\n");
+			rc = -ENOMEM;
+			goto done;
+		}
+		ref.addr += wqe->sg_list[1].size + ip_hdr_size;
+
+		/* SGE 3 */
+		wqe->sg_list[2].addr = sge.addr;
+		wqe->sg_list[2].lkey = sge.lkey;
+		wqe->sg_list[2].size = BNXT_QPLIB_MAX_QP1_RQ_BDETH_HDR_SIZE +
+				       udp_hdr_size;
+		size -= wqe->sg_list[2].size;
+		if (size <= 0) {
+			dev_err(rdev_to_dev(qp->rdev),
+				"QP1 rq buffer is empty!\n");
+			rc = -ENOMEM;
+			goto done;
+		}
+		sge.size = (u32)size;
+		sge.addr += wqe->sg_list[2].size;
+
+		/* SGE 4 */
+		wqe->sg_list[3].addr = ref.addr;
+		wqe->sg_list[3].lkey = ref.lkey;
+		wqe->sg_list[3].size = ref.size;
+		ref.size -= wqe->sg_list[3].size;
+		if (ref.size) {
+			dev_err(rdev_to_dev(qp->rdev),
+				"QP1 ref buffer is incorrect!\n");
+			rc = -ENOMEM;
+			goto done;
+		}
+		/* SGE 5 */
+		wqe->sg_list[4].addr = sge.addr;
+		wqe->sg_list[4].lkey = sge.lkey;
+		wqe->sg_list[4].size = sge.size;
+		size -= wqe->sg_list[4].size;
+		if (size) {
+			dev_err(rdev_to_dev(qp->rdev),
+				"QP1 rq buffer is incorrect!\n");
+			rc = -ENOMEM;
+			goto done;
+		}
+		sge.size = (u32)size;
+		wqe->num_sge = 5;
+	} else {
+		dev_err(rdev_to_dev(qp->rdev), "QP1 buffer is empty!\n");
+		rc = -ENOMEM;
+	}
+done:
+	return rc;
+}
+
+static int bnxt_re_build_qp1_shadow_qp_recv(struct bnxt_re_qp *qp,
+					    const struct ib_recv_wr *wr,
+					    struct bnxt_qplib_swqe *wqe)
+{
+	struct bnxt_re_sqp_entries *sqp_entry;
+	struct bnxt_qplib_sge sge;
+	struct bnxt_re_dev *rdev;
+	u32 rq_prod_index;
+	int rc = 0;
+
+	rdev = qp->rdev;
+
+	rq_prod_index = bnxt_qplib_get_rq_prod_index(&qp->qplib_qp);
+
+	if (bnxt_qplib_get_qp1_rq_buf(&qp->qplib_qp, &sge)) {
+		/* Create 1 SGE to receive the entire
+		 * ethernet packet
+		 */
+		/* SGE 1 */
+		wqe->sg_list[0].addr = sge.addr;
+		/* TODO check the lkey to be used */
+		wqe->sg_list[0].lkey = sge.lkey;
+		wqe->sg_list[0].size = BNXT_QPLIB_MAX_QP1_RQ_HDR_SIZE_V2;
+		if (sge.size < wqe->sg_list[0].size) {
+			dev_err(rdev_to_dev(qp->rdev),
+				"QP1 rq buffer is empty!\n");
+			rc = -ENOMEM;
+			goto done;
+		}
+
+		sqp_entry = &rdev->gsi_ctx.sqp_tbl[rq_prod_index];
+		sqp_entry->sge.addr = wr->sg_list[0].addr;
+		sqp_entry->sge.lkey = wr->sg_list[0].lkey;
+		sqp_entry->sge.size = wr->sg_list[0].length;
+		/* Store the wrid for reporting completion */
+		sqp_entry->wrid = wqe->wr_id;
+		/* change the wqe->wrid to table index */
+		wqe->wr_id = rq_prod_index;
+	}
+done:
+	return rc;
+}
+
+static bool is_ud_qp(struct bnxt_re_qp *qp)
+{
+	return (qp->qplib_qp.type == CMDQ_CREATE_QP_TYPE_UD ||
+		qp->qplib_qp.type == CMDQ_CREATE_QP_TYPE_GSI);
+}
+
+static int bnxt_re_build_send_wqe(struct bnxt_re_qp *qp,
+				  const struct ib_send_wr *wr,
+				  struct bnxt_qplib_swqe *wqe)
+{
+	struct bnxt_re_ah *ah = NULL;
+
+	if(is_ud_qp(qp)) {
+		ah = to_bnxt_re(ud_wr(wr)->ah, struct bnxt_re_ah, ibah);
+		wqe->send.q_key = ud_wr(wr)->remote_qkey;
+		wqe->send.dst_qp = ud_wr(wr)->remote_qpn;
+		wqe->send.avid = ah->qplib_ah.id;
+	}
+	switch (wr->opcode) {
+	case IB_WR_SEND:
+		wqe->type = BNXT_QPLIB_SWQE_TYPE_SEND;
+		break;
+	case IB_WR_SEND_WITH_IMM:
+		wqe->type = BNXT_QPLIB_SWQE_TYPE_SEND_WITH_IMM;
+		wqe->send.imm_data = wr->ex.imm_data;
+		break;
+	case IB_WR_SEND_WITH_INV:
+		wqe->type = BNXT_QPLIB_SWQE_TYPE_SEND_WITH_INV;
+		wqe->send.inv_key = wr->ex.invalidate_rkey;
+		break;
+	default:
+		dev_err(rdev_to_dev(qp->rdev), "%s Invalid opcode %d!\n",
+			__func__, wr->opcode);
+		return -EINVAL;
+	}
+	if (wr->send_flags & IB_SEND_SIGNALED)
+		wqe->flags |= BNXT_QPLIB_SWQE_FLAGS_SIGNAL_COMP;
+	if (wr->send_flags & IB_SEND_FENCE)
+		wqe->flags |= BNXT_QPLIB_SWQE_FLAGS_UC_FENCE;
+	if (wr->send_flags & IB_SEND_SOLICITED)
+		wqe->flags |= BNXT_QPLIB_SWQE_FLAGS_SOLICIT_EVENT;
+	if (wr->send_flags & IB_SEND_INLINE)
+		wqe->flags |= BNXT_QPLIB_SWQE_FLAGS_INLINE;
+
+	return 0;
+}
+
+static int bnxt_re_build_rdma_wqe(const struct ib_send_wr *wr,
+				  struct bnxt_qplib_swqe *wqe)
+{
+	switch (wr->opcode) {
+	case IB_WR_RDMA_WRITE:
+		wqe->type = BNXT_QPLIB_SWQE_TYPE_RDMA_WRITE;
+		break;
+	case IB_WR_RDMA_WRITE_WITH_IMM:
+		wqe->type = BNXT_QPLIB_SWQE_TYPE_RDMA_WRITE_WITH_IMM;
+		wqe->rdma.imm_data = wr->ex.imm_data;
+		break;
+	case IB_WR_RDMA_READ:
+		wqe->type = BNXT_QPLIB_SWQE_TYPE_RDMA_READ;
+		wqe->rdma.inv_key = wr->ex.invalidate_rkey;
+		break;
+	default:
+		return -EINVAL;
+	}
+	wqe->rdma.remote_va = rdma_wr(wr)->remote_addr;
+	wqe->rdma.r_key = rdma_wr(wr)->rkey;
+	if (wr->send_flags & IB_SEND_SIGNALED)
+		wqe->flags |= BNXT_QPLIB_SWQE_FLAGS_SIGNAL_COMP;
+	if (wr->send_flags & IB_SEND_FENCE)
+		wqe->flags |= BNXT_QPLIB_SWQE_FLAGS_UC_FENCE;
+	if (wr->send_flags & IB_SEND_SOLICITED)
+		wqe->flags |= BNXT_QPLIB_SWQE_FLAGS_SOLICIT_EVENT;
+	if (wr->send_flags & IB_SEND_INLINE)
+		wqe->flags |= BNXT_QPLIB_SWQE_FLAGS_INLINE;
+
+	return 0;
+}
+
+static int bnxt_re_build_atomic_wqe(const struct ib_send_wr *wr,
+				    struct bnxt_qplib_swqe *wqe)
+{
+	switch (wr->opcode) {
+	case IB_WR_ATOMIC_CMP_AND_SWP:
+		wqe->type = BNXT_QPLIB_SWQE_TYPE_ATOMIC_CMP_AND_SWP;
+		wqe->atomic.cmp_data = atomic_wr(wr)->compare_add;
+		wqe->atomic.swap_data = atomic_wr(wr)->swap;
+		break;
+	case IB_WR_ATOMIC_FETCH_AND_ADD:
+		wqe->type = BNXT_QPLIB_SWQE_TYPE_ATOMIC_FETCH_AND_ADD;
+		wqe->atomic.cmp_data = atomic_wr(wr)->compare_add;
+		break;
+	default:
+		return -EINVAL;
+	}
+	wqe->atomic.remote_va = atomic_wr(wr)->remote_addr;
+	wqe->atomic.r_key = atomic_wr(wr)->rkey;
+	if (wr->send_flags & IB_SEND_SIGNALED)
+		wqe->flags |= BNXT_QPLIB_SWQE_FLAGS_SIGNAL_COMP;
+	if (wr->send_flags & IB_SEND_FENCE)
+		wqe->flags |= BNXT_QPLIB_SWQE_FLAGS_UC_FENCE;
+	if (wr->send_flags & IB_SEND_SOLICITED)
+		wqe->flags |= BNXT_QPLIB_SWQE_FLAGS_SOLICIT_EVENT;
+	return 0;
+}
+
+static int bnxt_re_build_inv_wqe(const struct ib_send_wr *wr,
+				 struct bnxt_qplib_swqe *wqe)
+{
+	wqe->type = BNXT_QPLIB_SWQE_TYPE_LOCAL_INV;
+	wqe->local_inv.inv_l_key = wr->ex.invalidate_rkey;
+	if (wr->send_flags & IB_SEND_SIGNALED)
+		wqe->flags |= BNXT_QPLIB_SWQE_FLAGS_SIGNAL_COMP;
+	if (wr->send_flags & IB_SEND_FENCE)
+		wqe->flags |= BNXT_QPLIB_SWQE_FLAGS_UC_FENCE;
+	if (wr->send_flags & IB_SEND_SOLICITED)
+		wqe->flags |= BNXT_QPLIB_SWQE_FLAGS_SOLICIT_EVENT;
+
+	return 0;
+}
+
+static int bnxt_re_build_reg_wqe(const struct ib_reg_wr *wr,
+				 struct bnxt_qplib_swqe *wqe)
+{
+	struct bnxt_re_mr *mr = to_bnxt_re(wr->mr, struct bnxt_re_mr, ib_mr);
+	struct bnxt_qplib_frpl *qplib_frpl = &mr->qplib_frpl;
+	int reg_len, i, access = wr->access;
+
+	if (mr->npages > qplib_frpl->max_pg_ptrs) {
+		dev_err_ratelimited(rdev_to_dev(mr->rdev),
+			" %s: failed npages %d > %d\n", __func__,
+			mr->npages, qplib_frpl->max_pg_ptrs);
+		return -EINVAL;
+	}
+
+	wqe->frmr.pbl_ptr = (__le64 *)qplib_frpl->hwq.pbl_ptr[0];
+	wqe->frmr.pbl_dma_ptr = qplib_frpl->hwq.pbl_dma_ptr[0];
+	wqe->frmr.levels = qplib_frpl->hwq.level;
+	wqe->frmr.page_list = mr->pages;
+	wqe->frmr.page_list_len = mr->npages;
+	wqe->type = BNXT_QPLIB_SWQE_TYPE_REG_MR;
+
+	if (wr->wr.send_flags & IB_SEND_SIGNALED)
+		wqe->flags |= BNXT_QPLIB_SWQE_FLAGS_SIGNAL_COMP;
+	if (access & IB_ACCESS_LOCAL_WRITE)
+		wqe->frmr.access_cntl |= SQ_FR_PMR_ACCESS_CNTL_LOCAL_WRITE;
+	if (access & IB_ACCESS_REMOTE_READ)
+		wqe->frmr.access_cntl |= SQ_FR_PMR_ACCESS_CNTL_REMOTE_READ;
+	if (access & IB_ACCESS_REMOTE_WRITE)
+		wqe->frmr.access_cntl |= SQ_FR_PMR_ACCESS_CNTL_REMOTE_WRITE;
+	if (access & IB_ACCESS_REMOTE_ATOMIC)
+		wqe->frmr.access_cntl |= SQ_FR_PMR_ACCESS_CNTL_REMOTE_ATOMIC;
+	if (access & IB_ACCESS_MW_BIND)
+		wqe->frmr.access_cntl |= SQ_FR_PMR_ACCESS_CNTL_WINDOW_BIND;
+
+	/* TODO: OFED provides the rkey of the MR instead of the lkey */
+	wqe->frmr.l_key = wr->key;
+	wqe->frmr.length = wr->mr->length;
+	wqe->frmr.pbl_pg_sz_log = ilog2(PAGE_SIZE >> PAGE_SHIFT_4K);
+	wqe->frmr.pg_sz_log = ilog2(wr->mr->page_size >> PAGE_SHIFT_4K);
+	wqe->frmr.va = wr->mr->iova;
+	reg_len = wqe->frmr.page_list_len * wr->mr->page_size;
+
+	if (wqe->frmr.length > reg_len) {
+		dev_err_ratelimited(rdev_to_dev(mr->rdev),
+				    "%s: bnxt_re_mr 0x%px  len (%d > %d)\n",
+				    __func__, (void *)mr, wqe->frmr.length,
+				    reg_len);
+
+		for (i = 0; i < mr->npages; i++)
+			dev_dbg(rdev_to_dev(mr->rdev),
+				"%s: build_reg_wqe page[%d] = 0x%llx\n",
+				__func__, i, mr->pages[i]);
+
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static void bnxt_re_set_sg_list(const struct ib_send_wr *wr,
+				struct bnxt_qplib_swqe *wqe)
+{
+	wqe->sg_list = (struct bnxt_qplib_sge *)wr->sg_list;
+	wqe->num_sge = wr->num_sge;
+}
+
+static void bnxt_ud_qp_hw_stall_workaround(struct bnxt_re_qp *qp)
+{
+	if ((qp->ib_qp.qp_type == IB_QPT_UD || qp->ib_qp.qp_type == IB_QPT_GSI ||
+	    qp->ib_qp.qp_type == IB_QPT_RAW_ETHERTYPE) &&
+	    qp->qplib_qp.wqe_cnt == BNXT_RE_UD_QP_HW_STALL) {
+		int qp_attr_mask;
+		struct ib_qp_attr qp_attr;
+
+		qp_attr_mask = IB_QP_STATE;
+		qp_attr.qp_state = IB_QPS_RTS;
+		bnxt_re_modify_qp(&qp->ib_qp, &qp_attr, qp_attr_mask, NULL);
+		qp->qplib_qp.wqe_cnt = 0;
+	}
+}
+
+static int bnxt_re_post_send_shadow_qp(struct bnxt_re_dev *rdev,
+				       struct bnxt_re_qp *qp,
+				       const struct ib_send_wr *wr)
+{
+	struct bnxt_qplib_swqe wqe;
+	unsigned long flags;
+	int rc = 0;
+
+	spin_lock_irqsave(&qp->sq_lock, flags);
+	while (wr) {
+		/* House keeping */
+		memset(&wqe, 0, sizeof(wqe));
+		/* Common */
+		if (wr->num_sge > qp->qplib_qp.sq.max_sge) {
+			dev_err(rdev_to_dev(rdev),
+				"Limit exceeded for Send SGEs\n");
+			rc = -EINVAL;
+			break;
+		}
+
+		bnxt_re_set_sg_list(wr, &wqe);
+		wqe.wr_id = wr->wr_id;
+		wqe.type = BNXT_QPLIB_SWQE_TYPE_SEND;
+		rc = bnxt_re_build_send_wqe(qp, wr, &wqe);
+		if (rc)
+			break;
+
+		rc = bnxt_qplib_post_send(&qp->qplib_qp, &wqe);
+		if (rc) {
+			dev_err(rdev_to_dev(rdev),
+				"bad_wr seen with opcode = 0x%x rc = %d\n",
+				wr->opcode, rc);
+			break;
+		}
+		wr = wr->next;
+	}
+	bnxt_qplib_post_send_db(&qp->qplib_qp);
+	bnxt_ud_qp_hw_stall_workaround(qp);
+	spin_unlock_irqrestore(&qp->sq_lock, flags);
+	return rc;
+}
+
+static void bnxt_re_legacy_set_uc_fence(struct bnxt_qplib_swqe *wqe)
+{
+	/* Need unconditional fence for non-wire memory opcode
+	 * to work as expected.
+	 */
+	if (wqe->type == BNXT_QPLIB_SWQE_TYPE_LOCAL_INV ||
+	    wqe->type == BNXT_QPLIB_SWQE_TYPE_FAST_REG_MR ||
+	    wqe->type == BNXT_QPLIB_SWQE_TYPE_REG_MR ||
+	    wqe->type == BNXT_QPLIB_SWQE_TYPE_BIND_MW)
+		wqe->flags |= BNXT_QPLIB_SWQE_FLAGS_UC_FENCE;
+}
+
+int bnxt_re_post_send(struct ib_qp *ib_qp, const struct ib_send_wr *wr,
+		      const struct ib_send_wr **bad_wr)
+{
+	struct bnxt_re_qp *qp = to_bnxt_re(ib_qp, struct bnxt_re_qp, ib_qp);
+	struct bnxt_qplib_sge sge[6];
+	struct bnxt_qplib_swqe wqe;
+	struct bnxt_re_dev *rdev;
+	unsigned long flags;
+	int rc = 0;
+
+	rdev = qp->rdev;
+	spin_lock_irqsave(&qp->sq_lock, flags);
+	while (wr) {
+		/* House keeping */
+		memset(&wqe, 0, sizeof(wqe));
+		/* Common */
+		if (wr->num_sge > qp->qplib_qp.sq.max_sge) {
+			dev_err(rdev_to_dev(rdev),
+				"Limit exceeded for Send SGEs\n");
+			rc = -EINVAL;
+			goto bad;
+		}
+
+		bnxt_re_set_sg_list(wr, &wqe);
+		wqe.wr_id = wr->wr_id;
+
+		switch (wr->opcode) {
+		case IB_WR_SEND:
+		case IB_WR_SEND_WITH_IMM:
+			if (ib_qp->qp_type == IB_QPT_GSI &&
+			    rdev->gsi_ctx.gsi_qp_mode != BNXT_RE_GSI_MODE_UD) {
+				memset(sge, 0, sizeof(sge));
+				wqe.sg_list = sge;
+				rc = bnxt_re_build_gsi_send(qp, wr, &wqe);
+				if (rc)
+					goto bad;
+			} else if (ib_qp->qp_type == IB_QPT_RAW_ETHERTYPE) {
+				bnxt_re_build_raw_send(wr, &wqe);
+			}
+			switch (wr->send_flags) {
+			case IB_SEND_IP_CSUM:
+				wqe.rawqp1.lflags |=
+					SQ_SEND_RAWETH_QP1_LFLAGS_IP_CHKSUM;
+				break;
+			default:
+				break;
+			}
+			fallthrough;
+		case IB_WR_SEND_WITH_INV:
+			rc = bnxt_re_build_send_wqe(qp, wr, &wqe);
+			break;
+		case IB_WR_RDMA_WRITE:
+		case IB_WR_RDMA_WRITE_WITH_IMM:
+		case IB_WR_RDMA_READ:
+			rc = bnxt_re_build_rdma_wqe(wr, &wqe);
+			break;
+		case IB_WR_ATOMIC_CMP_AND_SWP:
+		case IB_WR_ATOMIC_FETCH_AND_ADD:
+			rc = bnxt_re_build_atomic_wqe(wr, &wqe);
+			break;
+		case IB_WR_RDMA_READ_WITH_INV:
+			dev_err(rdev_to_dev(rdev),
+				"RDMA Read with Invalidate is not supported\n");
+			rc = -EINVAL;
+			goto bad;
+		case IB_WR_LOCAL_INV:
+			rc = bnxt_re_build_inv_wqe(wr, &wqe);
+			break;
+		case IB_WR_REG_MR:
+			rc = bnxt_re_build_reg_wqe(reg_wr(wr), &wqe);
+			break;
+		default:
+			/* Unsupported WRs */
+			dev_err(rdev_to_dev(rdev),
+				"WR (0x%x) is not supported\n", wr->opcode);
+			rc = -EINVAL;
+			goto bad;
+		}
+
+		if (likely(!rc)) {
+			if (!_is_chip_gen_p5_p7(rdev->chip_ctx))
+				bnxt_re_legacy_set_uc_fence(&wqe);
+			rc = bnxt_qplib_post_send(&qp->qplib_qp, &wqe);
+		}
+bad:
+		if (unlikely(rc)) {
+			dev_err(rdev_to_dev(rdev),
+				"bad_wr seen with opcode = 0x%x\n", wr->opcode);
+			*bad_wr = wr;
+			break;
+		}
+		wr = wr->next;
+	}
+	bnxt_qplib_post_send_db(&qp->qplib_qp);
+	if (!_is_chip_gen_p5_p7(rdev->chip_ctx))
+		bnxt_ud_qp_hw_stall_workaround(qp);
+	spin_unlock_irqrestore(&qp->sq_lock, flags);
+
+	return rc;
+}
+
+static int bnxt_re_post_recv_shadow_qp(struct bnxt_re_dev *rdev,
+				struct bnxt_re_qp *qp,
+				struct ib_recv_wr *wr)
+{
+	struct bnxt_qplib_swqe wqe;
+	int rc = 0;
+
+	/* rq lock can be pardoned here. */
+	while (wr) {
+		/* House keeping */
+		memset(&wqe, 0, sizeof(wqe));
+		/* Common */
+		if (wr->num_sge > qp->qplib_qp.rq.max_sge) {
+			dev_err(rdev_to_dev(rdev),
+				"Limit exceeded for Receive SGEs\n");
+			rc = -EINVAL;
+			goto bad;
+		}
+
+		wqe.sg_list = (struct bnxt_qplib_sge *)wr->sg_list;
+		wqe.num_sge = wr->num_sge;
+		wqe.wr_id = wr->wr_id;
+		wqe.type = BNXT_QPLIB_SWQE_TYPE_RECV;
+		rc = bnxt_qplib_post_recv(&qp->qplib_qp, &wqe);
+bad:
+		if (rc) {
+			dev_err(rdev_to_dev(rdev),
+				"bad_wr seen with RQ post\n");
+			break;
+		}
+		wr = wr->next;
+	}
+	bnxt_qplib_post_recv_db(&qp->qplib_qp);
+	return rc;
+}
+
+static int bnxt_re_build_gsi_recv(struct bnxt_re_qp *qp,
+				  const struct ib_recv_wr *wr,
+				  struct bnxt_qplib_swqe *wqe)
+{
+	struct bnxt_re_dev *rdev = qp->rdev;
+	int rc = 0;
+
+	if (rdev->gsi_ctx.gsi_qp_mode == BNXT_RE_GSI_MODE_ALL)
+		rc = bnxt_re_build_qp1_shadow_qp_recv(qp, wr, wqe);
+	else
+		rc = bnxt_re_build_qp1_recv(qp, wr, wqe);
+
+	return rc;
+}
+
+int bnxt_re_post_recv(struct ib_qp *ib_qp, const struct ib_recv_wr *wr,
+		      const struct ib_recv_wr **bad_wr)
+{
+	struct bnxt_re_qp *qp = to_bnxt_re(ib_qp, struct bnxt_re_qp, ib_qp);
+	struct bnxt_qplib_sge sge[6];
+	struct bnxt_qplib_swqe wqe;
+	unsigned long flags;
+	u32 count = 0;
+	int rc = 0;
+
+	spin_lock_irqsave(&qp->rq_lock, flags);
+	while (wr) {
+		memset(&wqe, 0, sizeof(wqe));
+		if (wr->num_sge > qp->qplib_qp.rq.max_sge) {
+			dev_err(rdev_to_dev(qp->rdev),
+				"Limit exceeded for Receive SGEs\n");
+			rc = -EINVAL;
+			goto bad;
+		}
+		wqe.num_sge = wr->num_sge;
+		wqe.sg_list = (struct bnxt_qplib_sge *)wr->sg_list;
+		wqe.wr_id = wr->wr_id;
+		wqe.type = BNXT_QPLIB_SWQE_TYPE_RECV;
+
+		if (ib_qp->qp_type == IB_QPT_GSI &&
+		    qp->rdev->gsi_ctx.gsi_qp_mode != BNXT_RE_GSI_MODE_UD) {
+			memset(sge, 0, sizeof(sge));
+			wqe.sg_list = sge;
+			rc = bnxt_re_build_gsi_recv(qp, wr, &wqe);
+			if (rc)
+				goto bad;
+		}
+		rc = bnxt_qplib_post_recv(&qp->qplib_qp, &wqe);
+bad:
+		if (rc) {
+			dev_err(rdev_to_dev(qp->rdev),
+				"bad_wr seen with RQ post\n");
+			*bad_wr = wr;
+			break;
+		}
+		/* Ring DB if the RQEs posted reaches a threshold value */
+		if (++count >= BNXT_RE_RQ_WQE_THRESHOLD) {
+			bnxt_qplib_post_recv_db(&qp->qplib_qp);
+			count = 0;
+		}
+		wr = wr->next;
+	}
+
+	if (count)
+		bnxt_qplib_post_recv_db(&qp->qplib_qp);
+	spin_unlock_irqrestore(&qp->rq_lock, flags);
+
+	return rc;
+}
+
+/* Completion Queues */
+void bnxt_re_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata)
+{
+	struct bnxt_re_cq *cq = to_bnxt_re(ib_cq, struct bnxt_re_cq, ibcq);
+	struct bnxt_re_dev *rdev = cq->rdev;
+	int rc =  0;
+
+	if (cq->uctx_cq_page) {
+		BNXT_RE_CQ_PAGE_LIST_DEL(cq->uctx, cq);
+		free_page((u64)cq->uctx_cq_page);
+		cq->uctx_cq_page = NULL;
+	}
+	if (cq->is_dbr_soft_cq && cq->uctx) {
+		void *dbr_page;
+
+		if (cq->uctx->dbr_recov_cq) {
+			dbr_page = cq->uctx->dbr_recov_cq_page;
+			cq->uctx->dbr_recov_cq_page = NULL;
+			cq->uctx->dbr_recov_cq = NULL;
+			free_page((unsigned long)dbr_page);
+		}
+		goto end;
+	}
+	/* CQ getting destroyed. Set this state for cqn handler */
+	spin_lock_bh(&cq->qplib_cq.compl_lock);
+	cq->qplib_cq.destroyed = true;
+	spin_unlock_bh(&cq->qplib_cq.compl_lock);
+	if (ib_cq->poll_ctx == IB_POLL_WORKQUEUE ||
+	    ib_cq->poll_ctx == IB_POLL_UNBOUND_WORKQUEUE)
+		cancel_work_sync(&ib_cq->work);
+
+	rc = bnxt_qplib_destroy_cq(&rdev->qplib_res, &cq->qplib_cq);
+	if (rc)
+		dev_err_ratelimited(rdev_to_dev(rdev),
+				   "%s id = %d failed rc = %d\n",
+				   __func__, cq->qplib_cq.id, rc);
+
+	bnxt_re_put_nq(rdev, cq->qplib_cq.nq);
+	if (cq->umem && !IS_ERR(cq->umem))
+		ib_umem_release(cq->umem);
+
+	kfree(cq->cql);
+	atomic_dec(&rdev->stats.rsors.cq_count);
+end:
+	return;
+}
+
+static inline struct
+bnxt_re_cq *__get_cq_from_cq_in(struct ib_cq *cq_in,
+				struct bnxt_re_dev *rdev)
+{
+	struct bnxt_re_cq *cq;
+	cq = container_of(cq_in, struct bnxt_re_cq, ibcq);
+	return cq;
+}
+
+int bnxt_re_create_cq(struct ib_cq *cq_in,
+		      const struct ib_cq_init_attr *attr,
+		      struct ib_udata *udata)
+{
+	struct bnxt_qplib_dev_attr *dev_attr;
+	struct bnxt_re_ucontext *uctx = NULL;
+	struct ib_ucontext *context = NULL;
+	struct bnxt_qplib_cq *qplcq;
+	struct bnxt_re_cq_req ureq;
+	struct bnxt_re_dev *rdev;
+	int rc, entries;
+	struct bnxt_re_cq *cq;
+	u32 max_active_cqs;
+	int cqe = attr->cqe;
+
+	if (attr->flags)
+		return -EOPNOTSUPP;
+
+	rdev = rdev_from_cq_in(cq_in);
+	if (rdev->mod_exit) {
+		rc = -EIO;
+		dev_dbg(rdev_to_dev(rdev), "%s(): in mod_exit, just return!\n", __func__);
+		goto exit;
+	}
+	if (udata) {
+		uctx = rdma_udata_to_drv_context(udata,
+						 struct bnxt_re_ucontext,
+						 ibucontext);
+		context = &uctx->ibucontext;
+	}
+	dev_attr = rdev->dev_attr;
+
+	if (atomic_read(&rdev->stats.rsors.cq_count) >= dev_attr->max_cq) {
+		dev_err(rdev_to_dev(rdev), "Create CQ failed - max exceeded(CQs)\n");
+		rc = -EINVAL;
+		goto exit;
+	}
+	/* Validate CQ fields */
+	if (cqe < 1 || cqe > dev_attr->max_cq_wqes) {
+		dev_err(rdev_to_dev(rdev), "Create CQ failed - max exceeded(CQ_WQs)\n");
+		rc = -EINVAL;
+		goto exit;
+	}
+
+	cq = __get_cq_from_cq_in(cq_in, rdev);
+	if (!cq) {
+		rc = -ENOMEM;
+		goto exit;
+	}
+	cq->rdev = rdev;
+	cq->uctx = uctx;
+	qplcq = &cq->qplib_cq;
+	qplcq->cq_handle = (u64)qplcq;
+	/*
+	 * Since CQ is for QP1 is shared with Shadow CQ, the size
+	 * should be double the size. There is no way to identify
+	 * whether this CQ is for GSI QP. So assuming that the first
+	 * CQ created is for QP1
+	 */
+	if (!udata && !rdev->gsi_ctx.first_cq_created &&
+	    rdev->gsi_ctx.gsi_qp_mode == BNXT_RE_GSI_MODE_ALL) {
+		rdev->gsi_ctx.first_cq_created = true;
+		/*
+		 * Total CQE required for the CQ = CQE for QP1 RQ +
+		 * CQE for Shadow QP SQEs + CQE for Shadow QP RQEs.
+		 * Max entries of shadow QP SQ and RQ = QP1 RQEs = cqe
+		 */
+		cqe *= 3;
+	}
+
+	entries = bnxt_re_init_depth(cqe + 1, uctx);
+	if (entries > dev_attr->max_cq_wqes + 1)
+		entries = dev_attr->max_cq_wqes + 1;
+
+	qplcq->sginfo.pgshft = PAGE_SHIFT;
+	qplcq->sginfo.pgsize = PAGE_SIZE;
+	if (udata) {
+		if (udata->inlen < sizeof(ureq))
+			dev_warn(rdev_to_dev(rdev),
+				 "Update the library ulen %d klen %d\n",
+				 (unsigned int)udata->inlen,
+				 (unsigned int)sizeof(ureq));
+
+		rc = ib_copy_from_udata(&ureq, udata,
+					min(udata->inlen, sizeof(ureq)));
+		if (rc)
+			goto fail;
+
+		if (BNXT_RE_IS_DBR_PACING_NOTIFY_CQ(ureq)) {
+			cq->is_dbr_soft_cq = true;
+			goto success;
+		}
+
+		if (BNXT_RE_IS_DBR_RECOV_CQ(ureq)) {
+			void *dbr_page;
+			u32 *epoch;
+
+			dbr_page = (void *)__get_free_page(GFP_KERNEL);
+			if (!dbr_page) {
+				dev_err(rdev_to_dev(rdev),
+					"DBR recov CQ page allocation failed!");
+				rc = -ENOMEM;
+				goto fail;
+			}
+
+			/* memset the epoch and epoch_ack to 0 */
+			epoch = dbr_page;
+			epoch[0] = 0x0;
+			epoch[1] = 0x0;
+
+			uctx->dbr_recov_cq = cq;
+			uctx->dbr_recov_cq_page = dbr_page;
+
+			cq->is_dbr_soft_cq = true;
+			goto success;
+		}
+
+		cq->umem = ib_umem_get_compat
+				      (rdev, context, udata, ureq.cq_va,
+				       entries * sizeof(struct cq_base),
+				       IB_ACCESS_LOCAL_WRITE, 1);
+		if (IS_ERR(cq->umem)) {
+			rc = PTR_ERR(cq->umem);
+			dev_err(rdev_to_dev(rdev),
+				"%s: ib_umem_get failed! rc = %d\n",
+				__func__, rc);
+			goto fail;
+		}
+		qplcq->sginfo.sghead = get_ib_umem_sgl(cq->umem,
+						       &qplcq->sginfo.nmap);
+		qplcq->sginfo.npages = ib_umem_num_pages_compat(cq->umem);
+		if (!uctx->dpi.dbr) {
+			rc = bnxt_re_get_user_dpi(rdev, uctx);
+			if (rc)
+				goto c2fail;
+		}
+		qplcq->dpi = &uctx->dpi;
+	} else {
+		cq->max_cql = entries > MAX_CQL_PER_POLL ? MAX_CQL_PER_POLL : entries;
+		cq->cql = kcalloc(cq->max_cql, sizeof(struct bnxt_qplib_cqe),
+				  GFP_KERNEL);
+		if (!cq->cql) {
+			dev_err(rdev_to_dev(rdev),
+				"Allocate CQL for %d failed!\n", cq->max_cql);
+			rc = -ENOMEM;
+			goto fail;
+		}
+		qplcq->dpi = &rdev->dpi_privileged;
+	}
+	/*
+	 * Allocating the NQ in a round robin fashion. nq_alloc_cnt is a
+	 * used for getting the NQ index.
+	 */
+	qplcq->max_wqe = entries;
+	qplcq->nq = bnxt_re_get_nq(rdev);
+	qplcq->cnq_hw_ring_id = qplcq->nq->ring_id;
+
+	rc = bnxt_qplib_create_cq(&rdev->qplib_res, qplcq);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev), "Create HW CQ failed!\n");
+		goto fail;
+	}
+
+	INIT_LIST_HEAD(&cq->cq_list);
+	cq->ibcq.cqe = entries;
+	cq->cq_period = qplcq->period;
+
+	atomic_inc(&rdev->stats.rsors.cq_count);
+	max_active_cqs = atomic_read(&rdev->stats.rsors.cq_count);
+	if (max_active_cqs > atomic_read(&rdev->stats.rsors.max_cq_count))
+		atomic_set(&rdev->stats.rsors.max_cq_count, max_active_cqs);
+	spin_lock_init(&cq->cq_lock);
+
+	if (udata) {
+		struct bnxt_re_cq_resp resp;
+
+		resp.cqid = qplcq->id;
+		resp.tail = qplcq->hwq.cons;
+		resp.phase = qplcq->period;
+		resp.comp_mask = 0;
+		resp.dbr = (u64)uctx->dpi.umdbr;
+		resp.dpi = uctx->dpi.dpi;
+		resp.comp_mask |= BNXT_RE_COMP_MASK_CQ_HAS_DB_INFO;
+		/* Copy only on a valid wcpdi */
+		if (uctx->wcdpi.dpi) {
+			resp.wcdpi = uctx->wcdpi.dpi;
+			resp.comp_mask |= BNXT_RE_COMP_MASK_CQ_HAS_WC_DPI;
+		}
+
+		if (_is_chip_p7(rdev->chip_ctx)) {
+			cq->uctx_cq_page = (void *)__get_free_page(GFP_KERNEL);
+
+			if (!cq->uctx_cq_page) {
+				dev_err(rdev_to_dev(rdev),
+					"CQ page allocation failed!\n");
+				bnxt_qplib_destroy_cq(&rdev->qplib_res, qplcq);
+				rc = -ENOMEM;
+				goto c2fail;
+			}
+
+			resp.uctx_cq_page = (u64)cq->uctx_cq_page;
+			resp.comp_mask |= BNXT_RE_COMP_MASK_CQ_HAS_CQ_PAGE;
+		}
+
+		rc = bnxt_re_copy_to_udata(rdev, &resp,
+					   min(udata->outlen, sizeof(resp)),
+					   udata);
+		if (rc) {
+			free_page((u64)cq->uctx_cq_page);
+			cq->uctx_cq_page = NULL;
+			bnxt_qplib_destroy_cq(&rdev->qplib_res, qplcq);
+			goto c2fail;
+		}
+
+		if (cq->uctx_cq_page)
+			BNXT_RE_CQ_PAGE_LIST_ADD(uctx, cq);
+	}
+
+success:
+	return 0;
+c2fail:
+	if (udata && cq->umem && !IS_ERR(cq->umem))
+		ib_umem_release(cq->umem);
+fail:
+	if (cq) {
+		if (cq->cql)
+			kfree(cq->cql);
+	}
+exit:
+	return rc;
+}
+
+int bnxt_re_modify_cq(struct ib_cq *ib_cq, u16 cq_count, u16 cq_period)
+{
+	struct bnxt_re_cq *cq = to_bnxt_re(ib_cq, struct bnxt_re_cq, ibcq);
+	struct bnxt_re_dev *rdev = cq->rdev;
+	int rc;
+
+	if ((cq->cq_count != cq_count) || (cq->cq_period != cq_period)) {
+		cq->qplib_cq.count = cq_count;
+		cq->qplib_cq.period = cq_period;
+		rc = bnxt_qplib_modify_cq(&rdev->qplib_res, &cq->qplib_cq);
+		if (rc) {
+			dev_err(rdev_to_dev(rdev), "Modify HW CQ %#x failed!\n",
+				cq->qplib_cq.id);
+			return rc;
+		}
+		/* On success, update the shadow */
+		cq->cq_count = cq_count;
+		cq->cq_period = cq_period;
+	}
+	return 0;
+}
+
+static void bnxt_re_resize_cq_complete(struct bnxt_re_cq *cq)
+{
+	struct bnxt_re_dev *rdev = cq->rdev;
+
+	bnxt_qplib_resize_cq_complete(&rdev->qplib_res, &cq->qplib_cq);
+
+	cq->qplib_cq.max_wqe = cq->resize_cqe;
+	if (cq->resize_umem) {
+		ib_umem_release(cq->umem);
+		cq->umem = cq->resize_umem;
+		cq->resize_umem = NULL;
+		cq->resize_cqe = 0;
+	}
+}
+
+int bnxt_re_resize_cq(struct ib_cq *ib_cq, int cqe, struct ib_udata *udata)
+{
+	struct bnxt_qplib_sg_info sginfo = {};
+	struct bnxt_qplib_dpi *orig_dpi = NULL;
+	struct bnxt_qplib_dev_attr *dev_attr;
+	struct bnxt_re_ucontext *uctx = NULL;
+	struct bnxt_re_resize_cq_req ureq;
+	struct ib_ucontext *context = NULL;
+	struct bnxt_re_dev *rdev;
+	struct bnxt_re_cq *cq;
+	int rc, entries;
+
+	/* Don't allow more than one resize request at the same time.
+	 * TODO: need a mutex here when we support kernel consumers of resize.
+	 */
+	cq =  to_bnxt_re(ib_cq, struct bnxt_re_cq, ibcq);
+	rdev = cq->rdev;
+	dev_attr = rdev->dev_attr;
+	if (ib_cq->uobject) {
+		uctx = rdma_udata_to_drv_context(udata,
+						 struct bnxt_re_ucontext,
+						 ibucontext);
+		context = &uctx->ibucontext;
+	}
+
+	if (cq->resize_umem) {
+		dev_err(rdev_to_dev(rdev), "Resize CQ %#x failed - Busy\n",
+			cq->qplib_cq.id);
+		return -EBUSY;
+	}
+
+	/* Check the requested cq depth out of supported depth */
+	if (cqe < 1 || cqe > dev_attr->max_cq_wqes) {
+		dev_err(rdev_to_dev(rdev), "Resize CQ %#x failed - max exceeded\n",
+			cq->qplib_cq.id);
+		return -EINVAL;
+	}
+
+	entries = bnxt_re_init_depth(cqe + 1, uctx);
+	entries = min_t(u32, (u32)entries, dev_attr->max_cq_wqes + 1);
+
+	/* Check to see if the new requested size can be handled by already
+	 * existing CQ
+	 */
+	if (entries == cq->ibcq.cqe) {
+		dev_info(rdev_to_dev(rdev), "CQ is already at size %d\n", cqe);
+		return 0;
+	}
+
+	if (ib_cq->uobject && udata) {
+		if (udata->inlen < sizeof(ureq))
+			dev_warn(rdev_to_dev(rdev),
+				 "Update the library ulen %d klen %d\n",
+				 (unsigned int)udata->inlen,
+				 (unsigned int)sizeof(ureq));
+
+		rc = ib_copy_from_udata(&ureq, udata,
+					min(udata->inlen, sizeof(ureq)));
+		if (rc)
+			goto fail;
+
+		dev_dbg(rdev_to_dev(rdev), "%s: va %p\n", __func__,
+			(void *)ureq.cq_va);
+		cq->resize_umem = ib_umem_get_compat
+				       (rdev,
+					context, udata, ureq.cq_va,
+					entries * sizeof(struct cq_base),
+					IB_ACCESS_LOCAL_WRITE, 1);
+		if (IS_ERR(cq->resize_umem)) {
+			rc = PTR_ERR(cq->resize_umem);
+			cq->resize_umem = NULL;
+			dev_err(rdev_to_dev(rdev), "%s: ib_umem_get failed! rc = %d\n",
+				__func__, rc);
+			goto fail;
+		}
+		cq->resize_cqe = entries;
+		dev_dbg(rdev_to_dev(rdev), "%s: ib_umem_get() success\n",
+			__func__);
+		memcpy(&sginfo, &cq->qplib_cq.sginfo, sizeof(sginfo));
+		orig_dpi = cq->qplib_cq.dpi;
+
+		cq->qplib_cq.sginfo.sghead = get_ib_umem_sgl(cq->resize_umem,
+						&cq->qplib_cq.sginfo.nmap);
+		cq->qplib_cq.sginfo.npages =
+				ib_umem_num_pages_compat(cq->resize_umem);
+		cq->qplib_cq.sginfo.pgsize = PAGE_SIZE;
+		cq->qplib_cq.sginfo.pgshft = PAGE_SHIFT;
+		cq->qplib_cq.dpi = &uctx->dpi;
+	} else {
+		/* TODO: kernel consumer */
+	}
+
+	rc = bnxt_qplib_resize_cq(&rdev->qplib_res, &cq->qplib_cq, entries);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev), "Resize HW CQ %#x failed!\n",
+			cq->qplib_cq.id);
+		goto fail;
+	}
+
+	cq->ibcq.cqe = cq->resize_cqe;
+	/* For kernel consumers complete resize here. For uverbs consumers,
+	 * we complete it in the context of ibv_poll_cq().
+	 */
+	if (!cq->resize_umem)
+		bnxt_qplib_resize_cq_complete(&rdev->qplib_res, &cq->qplib_cq);
+
+	atomic_inc(&rdev->stats.rsors.resize_count);
+	return 0;
+
+fail:
+	if (cq->resize_umem) {
+		ib_umem_release(cq->resize_umem);
+		cq->resize_umem = NULL;
+		cq->resize_cqe = 0;
+		memcpy(&cq->qplib_cq.sginfo, &sginfo, sizeof(sginfo));
+		cq->qplib_cq.dpi = orig_dpi;
+	}
+	return rc;
+}
+
+static enum ib_wc_status __req_to_ib_wc_status(u8 qstatus)
+{
+	switch(qstatus) {
+	case CQ_REQ_STATUS_OK:
+		return IB_WC_SUCCESS;
+	case CQ_REQ_STATUS_BAD_RESPONSE_ERR:
+		return IB_WC_BAD_RESP_ERR;
+	case CQ_REQ_STATUS_LOCAL_LENGTH_ERR:
+		return IB_WC_LOC_LEN_ERR;
+	case CQ_REQ_STATUS_LOCAL_QP_OPERATION_ERR:
+		return IB_WC_LOC_QP_OP_ERR;
+	case CQ_REQ_STATUS_LOCAL_PROTECTION_ERR:
+		return IB_WC_LOC_PROT_ERR;
+	case CQ_REQ_STATUS_MEMORY_MGT_OPERATION_ERR:
+		return IB_WC_GENERAL_ERR;
+	case CQ_REQ_STATUS_REMOTE_INVALID_REQUEST_ERR:
+		return IB_WC_REM_INV_REQ_ERR;
+	case CQ_REQ_STATUS_REMOTE_ACCESS_ERR:
+		return IB_WC_REM_ACCESS_ERR;
+	case CQ_REQ_STATUS_REMOTE_OPERATION_ERR:
+		return IB_WC_REM_OP_ERR;
+	case CQ_REQ_STATUS_RNR_NAK_RETRY_CNT_ERR:
+		return IB_WC_RNR_RETRY_EXC_ERR;
+	case CQ_REQ_STATUS_TRANSPORT_RETRY_CNT_ERR:
+		return IB_WC_RETRY_EXC_ERR;
+	case CQ_REQ_STATUS_WORK_REQUEST_FLUSHED_ERR:
+		return IB_WC_WR_FLUSH_ERR;
+	default:
+		return IB_WC_GENERAL_ERR;
+	}
+	return 0;
+}
+
+static enum ib_wc_status __rawqp1_to_ib_wc_status(u8 qstatus)
+{
+	switch(qstatus) {
+	case CQ_RES_RAWETH_QP1_STATUS_OK:
+		return IB_WC_SUCCESS;
+	case CQ_RES_RAWETH_QP1_STATUS_LOCAL_ACCESS_ERROR:
+		return IB_WC_LOC_ACCESS_ERR;
+	case CQ_RES_RAWETH_QP1_STATUS_HW_LOCAL_LENGTH_ERR:
+		return IB_WC_LOC_LEN_ERR;
+	case CQ_RES_RAWETH_QP1_STATUS_LOCAL_PROTECTION_ERR:
+		return IB_WC_LOC_PROT_ERR;
+	case CQ_RES_RAWETH_QP1_STATUS_LOCAL_QP_OPERATION_ERR:
+		return IB_WC_LOC_QP_OP_ERR;
+	case CQ_RES_RAWETH_QP1_STATUS_MEMORY_MGT_OPERATION_ERR:
+		return IB_WC_GENERAL_ERR;
+	case CQ_RES_RAWETH_QP1_STATUS_WORK_REQUEST_FLUSHED_ERR:
+		return IB_WC_WR_FLUSH_ERR;
+	case CQ_RES_RAWETH_QP1_STATUS_HW_FLUSH_ERR:
+		return IB_WC_WR_FLUSH_ERR;
+	default:
+		return IB_WC_GENERAL_ERR;
+	}
+}
+
+static enum ib_wc_status __rc_to_ib_wc_status(u8 qstatus)
+{
+	switch(qstatus) {
+	case CQ_RES_RC_STATUS_OK:
+		return IB_WC_SUCCESS;
+	case CQ_RES_RC_STATUS_LOCAL_ACCESS_ERROR:
+		return IB_WC_LOC_ACCESS_ERR;
+	case CQ_RES_RC_STATUS_LOCAL_LENGTH_ERR:
+		return IB_WC_LOC_LEN_ERR;
+	case CQ_RES_RC_STATUS_LOCAL_PROTECTION_ERR:
+		return IB_WC_LOC_PROT_ERR;
+	case CQ_RES_RC_STATUS_LOCAL_QP_OPERATION_ERR:
+		return IB_WC_LOC_QP_OP_ERR;
+	case CQ_RES_RC_STATUS_MEMORY_MGT_OPERATION_ERR:
+		return IB_WC_GENERAL_ERR;
+	case CQ_RES_RC_STATUS_REMOTE_INVALID_REQUEST_ERR:
+		return IB_WC_REM_INV_REQ_ERR;
+	case CQ_RES_RC_STATUS_WORK_REQUEST_FLUSHED_ERR:
+		return IB_WC_WR_FLUSH_ERR;
+	case CQ_RES_RC_STATUS_HW_FLUSH_ERR:
+		return IB_WC_WR_FLUSH_ERR;
+	default:
+		return IB_WC_GENERAL_ERR;
+	}
+}
+
+static void bnxt_re_process_req_wc(struct ib_wc *wc, struct bnxt_qplib_cqe *cqe)
+{
+	switch (cqe->type) {
+	case BNXT_QPLIB_SWQE_TYPE_SEND:
+		wc->opcode = IB_WC_SEND;
+		break;
+	case BNXT_QPLIB_SWQE_TYPE_SEND_WITH_IMM:
+		wc->opcode = IB_WC_SEND;
+		wc->wc_flags |= IB_WC_WITH_IMM;
+		break;
+	case BNXT_QPLIB_SWQE_TYPE_SEND_WITH_INV:
+		wc->opcode = IB_WC_SEND;
+		wc->wc_flags |= IB_WC_WITH_INVALIDATE;
+		break;
+	case BNXT_QPLIB_SWQE_TYPE_RDMA_WRITE:
+		wc->opcode = IB_WC_RDMA_WRITE;
+		break;
+	case BNXT_QPLIB_SWQE_TYPE_RDMA_WRITE_WITH_IMM:
+		wc->opcode = IB_WC_RDMA_WRITE;
+		wc->wc_flags |= IB_WC_WITH_IMM;
+		break;
+	case BNXT_QPLIB_SWQE_TYPE_RDMA_READ:
+		wc->opcode = IB_WC_RDMA_READ;
+		break;
+	case BNXT_QPLIB_SWQE_TYPE_ATOMIC_CMP_AND_SWP:
+		wc->opcode = IB_WC_COMP_SWAP;
+		break;
+	case BNXT_QPLIB_SWQE_TYPE_ATOMIC_FETCH_AND_ADD:
+		wc->opcode = IB_WC_FETCH_ADD;
+		break;
+	case BNXT_QPLIB_SWQE_TYPE_LOCAL_INV:
+		wc->opcode = IB_WC_LOCAL_INV;
+		break;
+	case BNXT_QPLIB_SWQE_TYPE_REG_MR:
+		wc->opcode = IB_WC_REG_MR;
+		break;
+	default:
+		wc->opcode = IB_WC_SEND;
+		break;
+	}
+
+	wc->status = __req_to_ib_wc_status(cqe->status);
+}
+
+static int bnxt_re_check_packet_type(u16 raweth_qp1_flags, u16 raweth_qp1_flags2)
+{
+	bool is_ipv6 = false, is_ipv4 = false;
+
+	/* raweth_qp1_flags Bit 9-6 indicates itype */
+
+	if ((raweth_qp1_flags & CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_ROCE)
+	    != CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_ROCE)
+		return -1;
+
+	if (raweth_qp1_flags2 &
+	    CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_IP_CS_CALC &&
+	    raweth_qp1_flags2 &
+	    CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_L4_CS_CALC) {
+		/* raweth_qp1_flags2 Bit 8 indicates ip_type. 0-v4 1 - v6 */
+		(raweth_qp1_flags2 &
+		 CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_IP_TYPE) ?
+			(is_ipv6 = true) : (is_ipv4 = true);
+		return ((is_ipv6) ?
+			 BNXT_RE_ROCEV2_IPV6_PACKET :
+			 BNXT_RE_ROCEV2_IPV4_PACKET);
+	} else {
+		return BNXT_RE_ROCE_V1_PACKET;
+	}
+}
+
+static bool bnxt_re_is_loopback_packet(struct bnxt_re_dev *rdev,
+					    void *rq_hdr_buf)
+{
+	u8 *tmp_buf = NULL;
+	struct ethhdr *eth_hdr;
+	u16 eth_type;
+	bool rc = false;
+
+	tmp_buf = (u8 *)rq_hdr_buf;
+	/*
+	 * If dest mac is not same as I/F mac, this could be a
+	 * loopback address or multicast address, check whether
+	 * it is a loopback packet
+	 */
+	if (!ether_addr_equal(tmp_buf, rdev->dev_addr)) {
+		tmp_buf += 4;
+		/* Check the  ether type */
+		eth_hdr = (struct ethhdr *)tmp_buf;
+		eth_type = ntohs(eth_hdr->h_proto);
+		switch (eth_type) {
+		case BNXT_QPLIB_ETHTYPE_ROCEV1:
+			rc = true;
+			break;
+		default:
+			break;
+		}
+	}
+
+	return rc;
+}
+
+static bool bnxt_re_is_vlan_in_packet(struct bnxt_re_dev *rdev,
+				      void *rq_hdr_buf,
+				      struct bnxt_qplib_cqe *cqe)
+{
+	struct vlan_hdr *vlan_hdr;
+	struct ethhdr *eth_hdr;
+	u8 *tmp_buf = NULL;
+	u16 eth_type;
+
+	tmp_buf = (u8 *)rq_hdr_buf;
+	/* Check the  ether type */
+	eth_hdr = (struct ethhdr *)tmp_buf;
+	eth_type = ntohs(eth_hdr->h_proto);
+	if (eth_type == ETH_P_8021Q) {
+		tmp_buf += sizeof(struct ethhdr);
+		vlan_hdr = (struct vlan_hdr *)tmp_buf;
+		cqe->raweth_qp1_metadata =
+			ntohs(vlan_hdr->h_vlan_TCI) |
+			(eth_type <<
+			 CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_TPID_SFT);
+		cqe->raweth_qp1_flags2 |=
+			CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_META_FORMAT_VLAN;
+		return true;
+	}
+
+	return false;
+}
+
+static int bnxt_re_process_raw_qp_packet_receive(struct bnxt_re_qp *gsi_qp,
+						 struct bnxt_qplib_cqe *cqe)
+{
+	struct bnxt_re_sqp_entries *sqp_entry = NULL;
+	struct bnxt_qplib_hdrbuf *hdr_buf;
+	dma_addr_t shrq_hdr_buf_map;
+	struct ib_sge s_sge[2] = {};
+	struct ib_sge r_sge[2] = {};
+	struct ib_recv_wr rwr = {};
+	struct bnxt_re_ah *gsi_sah;
+	struct bnxt_re_qp *gsi_sqp;
+	dma_addr_t rq_hdr_buf_map;
+	struct bnxt_re_dev *rdev;
+	struct ib_send_wr *swr;
+	u32 skip_bytes = 0;
+	void *rq_hdr_buf;
+	int pkt_type = 0;
+	u32 offset = 0;
+	u32 tbl_idx;
+	int rc;
+	struct ib_ud_wr udwr = {};
+
+	swr = &udwr.wr;
+	rdev = gsi_qp->rdev;
+	gsi_sqp = rdev->gsi_ctx.gsi_sqp;
+	tbl_idx = cqe->wr_id;
+
+	hdr_buf = gsi_qp->qplib_qp.rq_hdr_buf;
+	rq_hdr_buf = (u8 *) hdr_buf->va + tbl_idx * hdr_buf->step;
+	rq_hdr_buf_map = bnxt_qplib_get_qp_buf_from_index(&gsi_qp->qplib_qp,
+							  tbl_idx);
+	/* Shadow QP header buffer */
+	shrq_hdr_buf_map = bnxt_qplib_get_qp_buf_from_index(&gsi_sqp->qplib_qp,
+							    tbl_idx);
+	sqp_entry = &rdev->gsi_ctx.sqp_tbl[tbl_idx];
+
+	/* Find packet type from the cqe */
+	pkt_type = bnxt_re_check_packet_type(cqe->raweth_qp1_flags,
+					     cqe->raweth_qp1_flags2);
+	if (pkt_type < 0) {
+		dev_err(rdev_to_dev(rdev), "Not handling this packet\n");
+		return -EINVAL;
+	}
+
+	/* Adjust the offset for the user buffer and post in the rq */
+
+	if (pkt_type == BNXT_RE_ROCEV2_IPV4_PACKET)
+		offset = 20;
+
+	/*
+	 * QP1 loopback packet has 4 bytes of internal header before
+	 * ether header. Skip these four bytes.
+	 */
+	if (bnxt_re_is_loopback_packet(rdev, rq_hdr_buf))
+		skip_bytes = 4;
+
+	if (bnxt_re_is_vlan_in_packet(rdev, rq_hdr_buf, cqe))
+		skip_bytes += VLAN_HLEN;
+
+	/* Store this cqe */
+	memcpy(&sqp_entry->cqe, cqe, sizeof(struct bnxt_qplib_cqe));
+	sqp_entry->qp1_qp = gsi_qp;
+
+	/* First send SGE . Skip the ether header*/
+	s_sge[0].addr = rq_hdr_buf_map + BNXT_QPLIB_MAX_QP1_RQ_ETH_HDR_SIZE
+			+ skip_bytes;
+	s_sge[0].lkey = 0xFFFFFFFF;
+	s_sge[0].length = offset ? BNXT_QPLIB_MAX_GRH_HDR_SIZE_IPV4 :
+				BNXT_QPLIB_MAX_GRH_HDR_SIZE_IPV6;
+
+	/* Second Send SGE */
+	s_sge[1].addr = s_sge[0].addr + s_sge[0].length +
+			BNXT_QPLIB_MAX_QP1_RQ_BDETH_HDR_SIZE;
+	if (pkt_type != BNXT_RE_ROCE_V1_PACKET)
+		s_sge[1].addr += 8;
+	s_sge[1].lkey = 0xFFFFFFFF;
+	s_sge[1].length = 256;
+
+	/* First recv SGE */
+	r_sge[0].addr = shrq_hdr_buf_map;
+	r_sge[0].lkey = 0xFFFFFFFF;
+	r_sge[0].length = 40;
+
+	r_sge[1].addr = sqp_entry->sge.addr + offset;
+	r_sge[1].lkey = sqp_entry->sge.lkey;
+	r_sge[1].length = BNXT_QPLIB_MAX_GRH_HDR_SIZE_IPV6 + 256 - offset;
+
+	/* Create receive work request */
+	rwr.num_sge = 2;
+	rwr.sg_list = r_sge;
+	rwr.wr_id = tbl_idx;
+	rwr.next = NULL;
+
+	rc = bnxt_re_post_recv_shadow_qp(rdev, gsi_sqp, &rwr);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev),
+			"Failed to post Rx buffers to shadow QP\n");
+		return -ENOMEM;
+	}
+
+	swr->num_sge = 2;
+	swr->sg_list = s_sge;
+	swr->wr_id = tbl_idx;
+	swr->opcode = IB_WR_SEND;
+	swr->next = NULL;
+
+	gsi_sah = rdev->gsi_ctx.gsi_sah;
+	udwr.ah = &gsi_sah->ibah;
+	udwr.remote_qpn = gsi_sqp->qplib_qp.id;
+	udwr.remote_qkey = gsi_sqp->qplib_qp.qkey;
+	/* post data received in the send queue */
+	rc = bnxt_re_post_send_shadow_qp(rdev, gsi_sqp, swr);
+
+	return rc;
+}
+
+static void bnxt_re_process_res_rawqp1_wc(struct ib_wc *wc,
+					  struct bnxt_qplib_cqe *cqe)
+{
+	wc->opcode = IB_WC_RECV;
+	wc->status = __rawqp1_to_ib_wc_status(cqe->status);
+	wc->wc_flags |= IB_WC_GRH;
+}
+
+static void bnxt_re_process_res_rc_wc(struct ib_wc *wc,
+				      struct bnxt_qplib_cqe *cqe)
+{
+	wc->opcode = IB_WC_RECV;
+	wc->status = __rc_to_ib_wc_status(cqe->status);
+
+	if (cqe->flags & CQ_RES_RC_FLAGS_IMM)
+		wc->wc_flags |= IB_WC_WITH_IMM;
+	if (cqe->flags & CQ_RES_RC_FLAGS_INV)
+		wc->wc_flags |= IB_WC_WITH_INVALIDATE;
+	if ((cqe->flags & (CQ_RES_RC_FLAGS_RDMA | CQ_RES_RC_FLAGS_IMM)) ==
+	    (CQ_RES_RC_FLAGS_RDMA | CQ_RES_RC_FLAGS_IMM))
+		wc->opcode = IB_WC_RECV_RDMA_WITH_IMM;
+}
+
+/* Returns TRUE if pkt has valid VLAN and if VLAN id is non-zero */
+static bool bnxt_re_is_nonzero_vlanid_pkt(struct bnxt_qplib_cqe *orig_cqe,
+					  u16 *vid, u8 *sl)
+{
+	u32 metadata;
+	u16 tpid;
+	bool ret = false;
+	metadata = orig_cqe->raweth_qp1_metadata;
+	if (orig_cqe->raweth_qp1_flags2 &
+	    CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_META_FORMAT_VLAN) {
+		tpid = ((metadata &
+			 CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_TPID_MASK) >>
+			 CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_TPID_SFT);
+		if (tpid == ETH_P_8021Q) {
+			*vid = metadata &
+			       CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_VID_MASK;
+			*sl = (metadata &
+			       CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_PRI_MASK) >>
+			       CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_PRI_SFT;
+			ret = !!(*vid);
+		}
+	}
+
+	return ret;
+}
+
+static void bnxt_re_process_res_shadow_qp_wc(struct bnxt_re_qp *gsi_sqp,
+					     struct ib_wc *wc,
+					     struct bnxt_qplib_cqe *cqe)
+{
+	u32 tbl_idx;
+	struct bnxt_re_dev *rdev = gsi_sqp->rdev;
+	struct bnxt_re_qp *gsi_qp = NULL;
+	struct bnxt_qplib_cqe *orig_cqe = NULL;
+	struct bnxt_re_sqp_entries *sqp_entry = NULL;
+	int nw_type;
+	u16 vlan_id;
+	u8 sl;
+
+	tbl_idx = cqe->wr_id;
+
+	sqp_entry = &rdev->gsi_ctx.sqp_tbl[tbl_idx];
+	gsi_qp = sqp_entry->qp1_qp;
+	orig_cqe = &sqp_entry->cqe;
+
+	wc->wr_id = sqp_entry->wrid;
+	wc->byte_len = orig_cqe->length;
+	wc->qp = &gsi_qp->ib_qp;
+
+	wc->ex.imm_data = orig_cqe->immdata;
+	wc->src_qp = orig_cqe->src_qp;
+	memcpy(wc->smac, orig_cqe->smac, ETH_ALEN);
+	if (bnxt_re_is_nonzero_vlanid_pkt(orig_cqe, &vlan_id, &sl)) {
+		if (bnxt_re_check_if_vlan_valid(rdev, vlan_id)) {
+			wc->sl = sl;
+			wc->vlan_id = vlan_id;
+			wc->wc_flags |= IB_WC_WITH_VLAN;
+		}
+	}
+	wc->port_num = 1;
+	wc->vendor_err = orig_cqe->status;
+
+	wc->opcode = IB_WC_RECV;
+	wc->status = __rawqp1_to_ib_wc_status(orig_cqe->status);
+	wc->wc_flags |= IB_WC_GRH;
+
+	nw_type = bnxt_re_check_packet_type(orig_cqe->raweth_qp1_flags,
+					    orig_cqe->raweth_qp1_flags2);
+	if(nw_type >= 0)
+		dev_dbg(rdev_to_dev(rdev), "%s nw_type = %d\n", __func__, nw_type);
+}
+
+static void bnxt_re_process_res_ud_wc(struct bnxt_re_dev *rdev,
+				      struct bnxt_re_qp *qp, struct ib_wc *wc,
+				      struct bnxt_qplib_cqe *cqe)
+{
+	u16 vlan_id = 0;
+
+	wc->opcode = IB_WC_RECV;
+	wc->status = __rc_to_ib_wc_status(cqe->status);
+	if (cqe->flags & CQ_RES_UD_FLAGS_IMM)
+		wc->wc_flags |= IB_WC_WITH_IMM;
+	if (cqe->flags & CQ_RES_RC_FLAGS_INV)
+		wc->wc_flags |= IB_WC_WITH_INVALIDATE;
+	/* report only on GSI QP for Thor */
+	if (rdev->gsi_ctx.gsi_qp->qplib_qp.id == qp->qplib_qp.id &&
+	    rdev->gsi_ctx.gsi_qp_mode == BNXT_RE_GSI_MODE_UD) {
+		wc->wc_flags |= IB_WC_GRH;
+		memcpy(wc->smac, cqe->smac, ETH_ALEN);
+		wc->wc_flags |= IB_WC_WITH_SMAC;
+		if (_is_cqe_v2_supported(rdev->dev_attr->dev_cap_flags)) {
+			if (cqe->flags & CQ_RES_UD_V2_FLAGS_META_FORMAT_MASK) {
+				if (cqe->cfa_meta &
+				    BNXT_QPLIB_CQE_CFA_META1_VALID)
+					vlan_id = (cqe->cfa_meta & 0xFFF);
+			}
+		} else if (cqe->flags & CQ_RES_UD_FLAGS_META_FORMAT_VLAN) {
+			vlan_id = (cqe->cfa_meta & 0xFFF);
+		}
+		/* Mark only if vlan_id is non zero */
+		if (vlan_id && bnxt_re_check_if_vlan_valid(rdev, vlan_id)) {
+			wc->vlan_id = vlan_id;
+			wc->wc_flags |= IB_WC_WITH_VLAN;
+		}
+	}
+}
+
+static int bnxt_re_legacy_send_phantom_wqe(struct bnxt_re_qp *qp)
+{
+	struct bnxt_qplib_qp *lib_qp = &qp->qplib_qp;
+	unsigned long flags;
+	int rc = 0;
+
+	spin_lock_irqsave(&qp->sq_lock, flags);
+
+	rc = bnxt_re_legacy_bind_fence_mw(lib_qp);
+	if (!rc) {
+		lib_qp->sq.phantom_wqe_cnt++;
+		dev_dbg(&lib_qp->sq.hwq.pdev->dev,
+			"qp %#x sq->prod %#x sw_prod %#x phantom_wqe_cnt %d\n",
+			lib_qp->id, lib_qp->sq.hwq.prod,
+			HWQ_CMP(lib_qp->sq.hwq.prod, &lib_qp->sq.hwq),
+			lib_qp->sq.phantom_wqe_cnt);
+	}
+
+	spin_unlock_irqrestore(&qp->sq_lock, flags);
+	return rc;
+}
+
+int bnxt_re_poll_cq(struct ib_cq *ib_cq, int num_entries, struct ib_wc *wc)
+{
+	struct bnxt_re_cq *cq = to_bnxt_re(ib_cq, struct bnxt_re_cq, ibcq);
+	struct bnxt_re_dev *rdev = cq->rdev;
+	struct bnxt_re_qp *qp;
+	struct bnxt_qplib_cqe *cqe;
+	int i, ncqe, budget, init_budget;
+	struct bnxt_qplib_q *sq;
+	struct bnxt_qplib_qp *lib_qp;
+	u32 tbl_idx;
+	struct bnxt_re_sqp_entries *sqp_entry = NULL;
+	unsigned long flags;
+	u8 gsi_mode;
+
+	/*
+	 * DB recovery CQ; only process the door bell pacing alert from
+	 * the user lib
+	 */
+	if (cq->is_dbr_soft_cq) {
+		bnxt_re_pacing_alert(rdev);
+		return 0;
+	}
+
+	/* User CQ; the only processing we do is to
+	 * complete any pending CQ resize operation.
+	 */
+	if (cq->umem) {
+		if (cq->resize_umem)
+			bnxt_re_resize_cq_complete(cq);
+		return 0;
+	}
+
+	spin_lock_irqsave(&cq->cq_lock, flags);
+
+	budget = min_t(u32, num_entries, cq->max_cql);
+	init_budget = budget;
+	if (!cq->cql) {
+		dev_err(rdev_to_dev(rdev), "POLL CQ no CQL to use\n");
+		goto exit;
+	}
+	cqe = &cq->cql[0];
+	gsi_mode = rdev->gsi_ctx.gsi_qp_mode;
+	while (budget) {
+		lib_qp = NULL;
+		ncqe = bnxt_qplib_poll_cq(&cq->qplib_cq, cqe, budget, &lib_qp);
+		if (lib_qp) {
+			sq = &lib_qp->sq;
+			if (sq->legacy_send_phantom == true) {
+				qp = container_of(lib_qp, struct bnxt_re_qp, qplib_qp);
+				if (bnxt_re_legacy_send_phantom_wqe(qp) == -ENOMEM)
+					dev_err(rdev_to_dev(rdev),
+						"Phantom failed! Scheduled to send again\n");
+				else
+					sq->legacy_send_phantom = false;
+			}
+		}
+		if (ncqe < budget)
+			ncqe += bnxt_qplib_process_flush_list(&cq->qplib_cq,
+							      cqe + ncqe,
+							      budget - ncqe);
+
+		if (!ncqe)
+			break;
+
+		for (i = 0; i < ncqe; i++, cqe++) {
+			/* Transcribe each qplib_wqe back to ib_wc */
+			memset(wc, 0, sizeof(*wc));
+
+			wc->wr_id = cqe->wr_id;
+			wc->byte_len = cqe->length;
+			qp = to_bnxt_re((struct bnxt_qplib_qp *)cqe->qp_handle,
+					struct bnxt_re_qp, qplib_qp);
+			if (!qp) {
+				dev_err(rdev_to_dev(rdev),
+					"POLL CQ bad QP handle\n");
+				continue;
+			}
+			wc->qp = &qp->ib_qp;
+			wc->ex.imm_data = cqe->immdata;
+			wc->src_qp = cqe->src_qp;
+			memcpy(wc->smac, cqe->smac, ETH_ALEN);
+			wc->port_num = 1;
+			wc->vendor_err = cqe->status;
+
+			switch(cqe->opcode) {
+			case CQ_BASE_CQE_TYPE_REQ:
+				if (gsi_mode == BNXT_RE_GSI_MODE_ALL &&
+				    qp->qplib_qp.id ==
+				    rdev->gsi_ctx.gsi_sqp->qplib_qp.id) {
+					/* Handle this completion with
+					 * the stored completion */
+					 dev_dbg(rdev_to_dev(rdev),
+						 "Skipping this UD Send CQ\n");
+					memset(wc, 0, sizeof(*wc));
+					continue;
+				}
+				bnxt_re_process_req_wc(wc, cqe);
+				break;
+			case CQ_BASE_CQE_TYPE_RES_RAWETH_QP1:
+				if (gsi_mode == BNXT_RE_GSI_MODE_ALL) {
+					if (!cqe->status) {
+						int rc = 0;
+						rc = bnxt_re_process_raw_qp_packet_receive(qp, cqe);
+						if (!rc) {
+							memset(wc, 0,
+							       sizeof(*wc));
+							continue;
+						}
+						cqe->status = -1;
+					}
+					/* Errors need not be looped back.
+					 * But change the wr_id to the one
+					 * stored in the table
+					 */
+					tbl_idx = cqe->wr_id;
+					sqp_entry = &rdev->gsi_ctx.sqp_tbl[tbl_idx];
+					wc->wr_id = sqp_entry->wrid;
+				}
+
+				bnxt_re_process_res_rawqp1_wc(wc, cqe);
+				break;
+			case CQ_BASE_CQE_TYPE_RES_RC:
+				bnxt_re_process_res_rc_wc(wc, cqe);
+				break;
+			case CQ_BASE_CQE_TYPE_RES_UD:
+				if (gsi_mode == BNXT_RE_GSI_MODE_ALL &&
+				    qp->qplib_qp.id ==
+				    rdev->gsi_ctx.gsi_sqp->qplib_qp.id) {
+					/* Handle this completion with
+					 * the stored completion
+					 */
+					dev_dbg(rdev_to_dev(rdev),
+						"Handling the UD receive CQ\n");
+					if (cqe->status) {
+						/* TODO handle this completion  as a failure in
+						 * loopback porocedure
+						 */
+						continue;
+					} else {
+						bnxt_re_process_res_shadow_qp_wc(qp, wc, cqe);
+						break;
+					}
+				}
+				bnxt_re_process_res_ud_wc(rdev, qp, wc, cqe);
+				break;
+			default:
+				dev_err(rdev_to_dev(cq->rdev),
+					"POLL CQ type 0x%x not handled, skip!\n",
+					cqe->opcode);
+				continue;
+			}
+			wc++;
+			budget--;
+		}
+	}
+exit:
+	spin_unlock_irqrestore(&cq->cq_lock, flags);
+	return init_budget - budget;
+}
+
+int bnxt_re_req_notify_cq(struct ib_cq *ib_cq,
+			  enum ib_cq_notify_flags ib_cqn_flags)
+{
+	struct bnxt_re_cq *cq = to_bnxt_re(ib_cq, struct bnxt_re_cq, ibcq);
+	int type = 0, rc = 0;
+	unsigned long flags;
+
+	spin_lock_irqsave(&cq->cq_lock, flags);
+	/* Trigger on the very next completion */
+	if (ib_cqn_flags & IB_CQ_NEXT_COMP)
+		type = DBC_DBC_TYPE_CQ_ARMALL;
+	/* Trigger on the next solicited completion */
+	else if (ib_cqn_flags & IB_CQ_SOLICITED)
+		type = DBC_DBC_TYPE_CQ_ARMSE;
+
+	bnxt_qplib_req_notify_cq(&cq->qplib_cq, type);
+
+	/* Poll to see if there are missed events */
+	if ((ib_cqn_flags & IB_CQ_REPORT_MISSED_EVENTS) &&
+	    !(bnxt_qplib_is_cq_empty(&cq->qplib_cq)))
+		rc = 1;
+
+	spin_unlock_irqrestore(&cq->cq_lock, flags);
+
+	return rc;
+}
+
+/* Memory Regions */
+struct ib_mr *bnxt_re_get_dma_mr(struct ib_pd *ib_pd, int mr_access_flags)
+{
+	struct bnxt_qplib_mrinfo mrinfo;
+	struct bnxt_re_dev *rdev;
+	struct bnxt_re_mr *mr;
+	struct bnxt_re_pd *pd;
+	u32 max_mr_count;
+	u64 pbl = 0;
+	int rc;
+
+	memset(&mrinfo, 0, sizeof(mrinfo));
+	pd = to_bnxt_re(ib_pd, struct bnxt_re_pd, ibpd);
+	rdev = pd->rdev;
+
+	mr = kzalloc(sizeof(*mr), GFP_KERNEL);
+	if (!mr) {
+		dev_err(rdev_to_dev(rdev),
+			"Allocate memory for DMA MR failed!\n");
+		return ERR_PTR(-ENOMEM);
+	}
+	mr->rdev = rdev;
+	mr->qplib_mr.pd = &pd->qplib_pd;
+	mr->qplib_mr.flags = __from_ib_access_flags(mr_access_flags);
+	mr->qplib_mr.type = CMDQ_ALLOCATE_MRW_MRW_FLAGS_PMR;
+
+	/* Allocate and register 0 as the address */
+	rc = bnxt_qplib_alloc_mrw(&rdev->qplib_res, &mr->qplib_mr);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev), "Allocate DMA MR failed!\n");
+		goto fail;
+	}
+	mr->qplib_mr.total_size = -1; /* Infinite length */
+	mrinfo.ptes = &pbl;
+	mrinfo.sg.npages = 0;
+	mrinfo.sg.pgsize = PAGE_SIZE;
+	mrinfo.sg.pgshft = PAGE_SHIFT;
+	mrinfo.sg.pgsize = PAGE_SIZE;
+	mrinfo.mrw = &mr->qplib_mr;
+	mrinfo.is_dma = true;
+	rc = bnxt_qplib_reg_mr(&rdev->qplib_res, &mrinfo, false);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev), "Register DMA MR failed!\n");
+		goto fail_mr;
+	}
+	mr->ib_mr.lkey = mr->qplib_mr.lkey;
+	if (mr_access_flags & (IB_ACCESS_REMOTE_WRITE | IB_ACCESS_REMOTE_READ |
+			       IB_ACCESS_REMOTE_ATOMIC))
+		mr->ib_mr.rkey = mr->ib_mr.lkey;
+	atomic_inc(&rdev->stats.rsors.mr_count);
+	max_mr_count =  atomic_read(&rdev->stats.rsors.mr_count);
+	if (max_mr_count > atomic_read(&rdev->stats.rsors.max_mr_count))
+		atomic_set(&rdev->stats.rsors.max_mr_count, max_mr_count);
+
+	return &mr->ib_mr;
+
+fail_mr:
+	bnxt_qplib_free_mrw(&rdev->qplib_res, &mr->qplib_mr);
+fail:
+	kfree(mr);
+	return ERR_PTR(rc);
+}
+
+int bnxt_re_dereg_mr(struct ib_mr *ib_mr, struct ib_udata *udata)
+{
+	struct bnxt_re_mr *mr = to_bnxt_re(ib_mr, struct bnxt_re_mr, ib_mr);
+	struct bnxt_re_dev *rdev = mr->rdev;
+	int rc = 0;
+
+	rc = bnxt_qplib_free_mrw(&rdev->qplib_res, &mr->qplib_mr);
+	if (rc)
+		dev_err(rdev_to_dev(rdev), "Dereg MR failed (%d): rc - %#x\n",
+			mr->qplib_mr.lkey, rc);
+
+	if (mr->pages) {
+		bnxt_qplib_free_fast_reg_page_list(&rdev->qplib_res,
+						   &mr->qplib_frpl);
+		kfree(mr->pages);
+		mr->npages = 0;
+		mr->pages = NULL;
+	}
+	if (!IS_ERR(mr->ib_umem) && mr->ib_umem) {
+		mr->is_invalcb_active = false;
+		bnxt_re_peer_mem_release(mr->ib_umem);
+	}
+	kfree(mr);
+	atomic_dec(&rdev->stats.rsors.mr_count);
+	return 0;
+}
+
+static int bnxt_re_set_page(struct ib_mr *ib_mr, u64 addr)
+{
+	struct bnxt_re_mr *mr = to_bnxt_re(ib_mr, struct bnxt_re_mr, ib_mr);
+
+	if (unlikely(mr->npages == mr->qplib_frpl.max_pg_ptrs))
+		return -ENOMEM;
+
+	mr->pages[mr->npages++] = addr;
+	dev_dbg(NULL, "%s: ibdev %p Set MR pages[%d] = 0x%lx\n",
+		ROCE_DRV_MODULE_NAME, ib_mr->device, mr->npages - 1,
+		mr->pages[mr->npages - 1]);
+	return 0;
+}
+
+int bnxt_re_map_mr_sg(struct ib_mr *ib_mr, struct scatterlist *sg,
+		      int sg_nents, unsigned int *sg_offset)
+{
+	struct bnxt_re_mr *mr = to_bnxt_re(ib_mr, struct bnxt_re_mr, ib_mr);
+
+	mr->npages = 0;
+	return ib_sg_to_pages(ib_mr, sg, sg_nents,
+			      sg_offset, bnxt_re_set_page);
+}
+
+struct ib_mr *bnxt_re_alloc_mr(struct ib_pd *ib_pd, enum ib_mr_type type,
+			       u32 max_num_sg, struct ib_udata *udata)
+{
+	struct bnxt_re_pd *pd = to_bnxt_re(ib_pd, struct bnxt_re_pd, ibpd);
+	struct bnxt_re_dev *rdev = pd->rdev;
+	struct bnxt_re_mr *mr;
+	u32 max_mr_count;
+	int rc;
+
+	dev_dbg(rdev_to_dev(rdev), "Alloc MR\n");
+	if (type != IB_MR_TYPE_MEM_REG) {
+		dev_dbg(rdev_to_dev(rdev), "MR type 0x%x not supported\n", type);
+		return ERR_PTR(-EINVAL);
+	}
+	if (max_num_sg > MAX_PBL_LVL_1_PGS) {
+		dev_dbg(rdev_to_dev(rdev), "Max SG exceeded\n");
+		return ERR_PTR(-EINVAL);
+	}
+	mr = kzalloc(sizeof(*mr), GFP_KERNEL);
+	if (!mr) {
+		dev_err(rdev_to_dev(rdev), "Allocate MR mem failed!\n");
+		return ERR_PTR(-ENOMEM);
+	}
+	mr->rdev = rdev;
+	mr->qplib_mr.pd = &pd->qplib_pd;
+	mr->qplib_mr.flags = BNXT_QPLIB_FR_PMR;
+	mr->qplib_mr.type = CMDQ_ALLOCATE_MRW_MRW_FLAGS_PMR;
+
+	rc = bnxt_qplib_alloc_mrw(&rdev->qplib_res, &mr->qplib_mr);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev), "Allocate MR failed!\n");
+		goto fail;
+	}
+	mr->ib_mr.lkey = mr->qplib_mr.lkey;
+	mr->ib_mr.rkey = mr->ib_mr.lkey;
+	mr->pages = kzalloc(sizeof(u64) * max_num_sg, GFP_KERNEL);
+	if (!mr->pages) {
+		dev_err(rdev_to_dev(rdev),
+			"Allocate MR page list mem failed!\n");
+		rc = -ENOMEM;
+		goto fail_mr;
+	}
+	rc = bnxt_qplib_alloc_fast_reg_page_list(&rdev->qplib_res,
+						 &mr->qplib_frpl, max_num_sg);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev),
+			"Allocate HW Fast reg page list failed!\n");
+		goto free_page;
+	}
+	dev_dbg(rdev_to_dev(rdev), "Alloc MR pages = 0x%p\n", mr->pages);
+
+	atomic_inc(&rdev->stats.rsors.mr_count);
+	max_mr_count =  atomic_read(&rdev->stats.rsors.mr_count);
+	if (max_mr_count > atomic_read(&rdev->stats.rsors.max_mr_count))
+		atomic_set(&rdev->stats.rsors.max_mr_count, max_mr_count);
+	return &mr->ib_mr;
+
+free_page:
+	kfree(mr->pages);
+fail_mr:
+	bnxt_qplib_free_mrw(&rdev->qplib_res, &mr->qplib_mr);
+fail:
+	kfree(mr);
+	return ERR_PTR(rc);
+}
+
+/* Memory Windows */
+struct ib_mw *bnxt_re_alloc_mw(struct ib_pd *ib_pd, enum ib_mw_type type,
+			       struct ib_udata *udata)
+{
+	struct bnxt_re_pd *pd = to_bnxt_re(ib_pd, struct bnxt_re_pd, ibpd);
+	struct bnxt_re_dev *rdev = pd->rdev;
+	struct bnxt_re_mw *mw;
+	u32 max_mw_count;
+	int rc;
+
+	mw = kzalloc(sizeof(*mw), GFP_KERNEL);
+	if (!mw) {
+		dev_err(rdev_to_dev(rdev), "Allocate MW failed!\n");
+		rc = -ENOMEM;
+		goto exit;
+	}
+	mw->rdev = rdev;
+	mw->qplib_mw.pd = &pd->qplib_pd;
+
+	mw->qplib_mw.type = (type == IB_MW_TYPE_1 ?
+			       CMDQ_ALLOCATE_MRW_MRW_FLAGS_MW_TYPE1 :
+			       CMDQ_ALLOCATE_MRW_MRW_FLAGS_MW_TYPE2B);
+	rc = bnxt_qplib_alloc_mrw(&rdev->qplib_res, &mw->qplib_mw);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev), "Allocate MW failed!\n");
+		goto fail;
+	}
+	mw->ib_mw.rkey = mw->qplib_mw.rkey;
+	atomic_inc(&rdev->stats.rsors.mw_count);
+	max_mw_count = atomic_read(&rdev->stats.rsors.mw_count);
+	if (max_mw_count > atomic_read(&rdev->stats.rsors.max_mw_count))
+		atomic_set(&rdev->stats.rsors.max_mw_count, max_mw_count);
+
+	return &mw->ib_mw;
+fail:
+	kfree(mw);
+exit:
+	return ERR_PTR(rc);
+}
+
+int bnxt_re_dealloc_mw(struct ib_mw *ib_mw)
+{
+	struct bnxt_re_mw *mw = to_bnxt_re(ib_mw, struct bnxt_re_mw, ib_mw);
+	struct bnxt_re_dev *rdev = mw->rdev;
+	int rc;
+
+	rc = bnxt_qplib_free_mrw(&rdev->qplib_res, &mw->qplib_mw);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev), "Free MW failed: %#x\n", rc);
+		return rc;
+	}
+
+	kfree(mw);
+	atomic_dec(&rdev->stats.rsors.mw_count);
+	return rc;
+}
+
+static int bnxt_re_page_size_ok(int page_shift)
+{
+	switch (page_shift) {
+	case CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_PG_4K:
+	case CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_PG_8K:
+	case CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_PG_64K:
+	case CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_PG_2M:
+	case CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_PG_256K:
+	case CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_PG_1M:
+	case CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_PG_4M:
+	case CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_PG_256MB:
+	case CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_PG_1G:
+		return 1;
+	default:
+		return 0;
+	}
+}
+
+static int bnxt_re_get_page_shift(struct ib_umem *umem,
+				  u64 va, u64 st, u64 cmask)
+{
+	int pgshft;
+
+	pgshft = ilog2(umem->page_size);
+
+	return pgshft;
+}
+
+static int bnxt_re_get_num_pages(struct ib_umem *umem, u64 start, u64 length, int page_shift)
+{
+	int npages = 0;
+
+	if (page_shift == PAGE_SHIFT) {
+		npages = ib_umem_num_pages_compat(umem);
+	} else {
+		npages = ALIGN(length, BIT(page_shift)) / BIT(page_shift);
+		if (start %  BIT(page_shift))
+			npages++;
+	}
+	return npages;
+}
+
+/* uverbs */
+struct ib_mr *bnxt_re_reg_user_mr(struct ib_pd *ib_pd, u64 start, u64 length,
+				  u64 virt_addr, int mr_access_flags,
+				  struct ib_udata *udata)
+{
+	struct bnxt_re_pd *pd = to_bnxt_re(ib_pd, struct bnxt_re_pd, ibpd);
+	struct bnxt_re_dev *rdev = pd->rdev;
+	struct bnxt_qplib_mrinfo mrinfo;
+	int umem_pgs, page_shift, rc;
+	struct bnxt_re_mr *mr;
+	struct ib_umem *umem;
+	u32 max_mr_count;
+	int npages;
+
+	dev_dbg(rdev_to_dev(rdev), "Reg user MR\n");
+
+	if (bnxt_re_get_total_mr_mw_count(rdev) >= rdev->dev_attr->max_mr)
+		return ERR_PTR(-ENOMEM);
+
+	if (rdev->mod_exit) {
+		dev_dbg(rdev_to_dev(rdev), "%s(): in mod_exit, just return!\n", __func__);
+		return ERR_PTR(-EIO);
+	}
+	memset(&mrinfo, 0, sizeof(mrinfo));
+	if (length > BNXT_RE_MAX_MR_SIZE) {
+		dev_err(rdev_to_dev(rdev), "Requested MR Size: %lu "
+			"> Max supported: %ld\n", length, BNXT_RE_MAX_MR_SIZE);
+		return ERR_PTR(-ENOMEM);
+	}
+	mr = kzalloc(sizeof(*mr), GFP_KERNEL);
+	if (!mr) {
+		dev_err(rdev_to_dev(rdev), "Allocate MR failed!\n");
+		return ERR_PTR (-ENOMEM);
+	}
+	mr->rdev = rdev;
+	mr->qplib_mr.pd = &pd->qplib_pd;
+	mr->qplib_mr.flags = __from_ib_access_flags(mr_access_flags);
+	mr->qplib_mr.type = CMDQ_ALLOCATE_MRW_MRW_FLAGS_MR;
+
+	if (!_is_alloc_mr_unified(rdev->qplib_res.dattr)) {
+		rc = bnxt_qplib_alloc_mrw(&rdev->qplib_res, &mr->qplib_mr);
+		if (rc) {
+			dev_err(rdev_to_dev(rdev), "Alloc MR failed!\n");
+			goto fail;
+		}
+		/* The fixed portion of the rkey is the same as the lkey */
+		mr->ib_mr.rkey = mr->qplib_mr.rkey;
+	}
+
+	umem = ib_umem_get_flags_compat(rdev, ib_pd->uobject->context,
+					udata, start, length,
+					mr_access_flags, 0);
+	if (IS_ERR(umem)) {
+		rc = PTR_ERR(umem);
+		dev_err(rdev_to_dev(rdev), "%s: ib_umem_get failed! rc = %d\n",
+			__func__, rc);
+		goto free_mr;
+	}
+	mr->ib_umem = umem;
+
+	mr->qplib_mr.va = virt_addr;
+	umem_pgs = ib_umem_num_pages_compat(umem);
+	if (!umem_pgs) {
+		dev_err(rdev_to_dev(rdev), "umem is invalid!\n");
+		rc = -EINVAL;
+		goto free_umem;
+	}
+	mr->qplib_mr.total_size = length;
+	page_shift = bnxt_re_get_page_shift(umem, virt_addr, start,
+					    rdev->dev_attr->page_size_cap);
+	if (!bnxt_re_page_size_ok(page_shift)) {
+		dev_err(rdev_to_dev(rdev), "umem page size unsupported!\n");
+		rc = -EFAULT;
+		goto free_umem;
+	}
+	npages = bnxt_re_get_num_pages(umem, start, length, page_shift);
+
+	/* Map umem buf ptrs to the PBL */
+	mrinfo.sg.npages = npages;
+	mrinfo.sg.sghead = get_ib_umem_sgl(umem, &mrinfo.sg.nmap);
+	mrinfo.sg.pgshft = page_shift;
+	mrinfo.sg.pgsize = BIT(page_shift);
+
+	mrinfo.mrw = &mr->qplib_mr;
+
+	rc = bnxt_qplib_reg_mr(&rdev->qplib_res, &mrinfo, false);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev), "Reg user MR failed!\n");
+		goto free_umem;
+	}
+
+	mr->ib_mr.lkey = mr->ib_mr.rkey = mr->qplib_mr.lkey;
+	atomic_inc(&rdev->stats.rsors.mr_count);
+	max_mr_count =  atomic_read(&rdev->stats.rsors.mr_count);
+	if (max_mr_count > atomic_read(&rdev->stats.rsors.max_mr_count))
+		atomic_set(&rdev->stats.rsors.max_mr_count, max_mr_count);
+
+	return &mr->ib_mr;
+
+free_umem:
+	bnxt_re_peer_mem_release(mr->ib_umem);
+free_mr:
+	if (!_is_alloc_mr_unified(rdev->qplib_res.dattr))
+		bnxt_qplib_free_mrw(&rdev->qplib_res, &mr->qplib_mr);
+fail:
+	kfree(mr);
+	return ERR_PTR(rc);
+}
+
+int
+bnxt_re_rereg_user_mr(struct ib_mr *ib_mr, int flags, u64 start, u64 length,
+		      u64 virt_addr, int mr_access_flags,
+		      struct ib_pd *ib_pd, struct ib_udata *udata)
+{
+	struct bnxt_re_mr *mr = to_bnxt_re(ib_mr, struct bnxt_re_mr, ib_mr);
+	struct bnxt_re_pd *pd = to_bnxt_re(ib_pd, struct bnxt_re_pd, ibpd);
+	int umem_pgs = 0, page_shift = PAGE_SHIFT, rc;
+	struct bnxt_re_dev *rdev = mr->rdev;
+	struct bnxt_qplib_mrinfo mrinfo;
+	struct ib_umem *umem;
+	u32 npages;
+
+	/* TODO: Must decipher what to modify based on the flags */
+	memset(&mrinfo, 0, sizeof(mrinfo));
+	if (flags & IB_MR_REREG_TRANS) {
+		umem = ib_umem_get_flags_compat(rdev, ib_pd->uobject->context,
+						udata, start, length,
+						mr_access_flags, 0);
+		if (IS_ERR(umem)) {
+			rc = PTR_ERR(umem);
+			dev_err(rdev_to_dev(rdev),
+				"%s: ib_umem_get failed! ret =  %d\n",
+				__func__, rc);
+			goto fail;
+		}
+		mr->ib_umem = umem;
+
+		mr->qplib_mr.va = virt_addr;
+		umem_pgs = ib_umem_num_pages_compat(umem);
+		if (!umem_pgs) {
+			dev_err(rdev_to_dev(rdev), "umem is invalid!\n");
+			rc = -EINVAL;
+			goto fail_free_umem;
+		}
+		mr->qplib_mr.total_size = length;
+		page_shift = bnxt_re_get_page_shift(umem, virt_addr, start,
+					    rdev->dev_attr->page_size_cap);
+		if (!bnxt_re_page_size_ok(page_shift)) {
+			dev_err(rdev_to_dev(rdev),
+				"umem page size unsupported!\n");
+			rc = -EFAULT;
+			goto fail_free_umem;
+		}
+		npages = bnxt_re_get_num_pages(umem, start, length, page_shift);
+		/* Map umem buf ptrs to the PBL */
+		mrinfo.sg.npages = npages;
+		mrinfo.sg.sghead = get_ib_umem_sgl(umem, &mrinfo.sg.nmap);
+		mrinfo.sg.pgshft = page_shift;
+		mrinfo.sg.pgsize = BIT(page_shift);
+	}
+
+	mrinfo.mrw = &mr->qplib_mr;
+	if (flags & IB_MR_REREG_PD)
+		mr->qplib_mr.pd = &pd->qplib_pd;
+
+	if (flags & IB_MR_REREG_ACCESS)
+		mr->qplib_mr.flags = __from_ib_access_flags(mr_access_flags);
+
+	rc = bnxt_qplib_reg_mr(&rdev->qplib_res, &mrinfo, false);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev), "Rereg user MR failed!\n");
+		goto fail_free_umem;
+	}
+	mr->ib_mr.rkey = mr->qplib_mr.rkey;
+
+	return 0;
+
+fail_free_umem:
+	bnxt_re_peer_mem_release(mr->ib_umem);
+fail:
+	return rc;
+}
+
+static int bnxt_re_check_abi_version(struct bnxt_re_dev *rdev)
+{
+	struct ib_device *ibdev = &rdev->ibdev;
+	u32 uverbs_abi_ver;
+
+	uverbs_abi_ver = GET_UVERBS_ABI_VERSION(ibdev);
+	dev_dbg(rdev_to_dev(rdev), "ABI version requested %d\n",
+		uverbs_abi_ver);
+	if (uverbs_abi_ver != BNXT_RE_ABI_VERSION) {
+		dev_dbg(rdev_to_dev(rdev), " is different from the device %d \n",
+			BNXT_RE_ABI_VERSION);
+		return -EPERM;
+	}
+	return 0;
+}
+
+int bnxt_re_alloc_ucontext(struct ib_ucontext *uctx_in,
+			   struct ib_udata *udata)
+{
+	struct ib_ucontext *ctx = uctx_in;
+	struct ib_device *ibdev = ctx->device;
+	struct bnxt_re_ucontext *uctx =
+		container_of(ctx, struct bnxt_re_ucontext, ibucontext);
+
+	struct bnxt_re_dev *rdev = to_bnxt_re_dev(ibdev, ibdev);
+	struct bnxt_qplib_dev_attr *dev_attr = rdev->dev_attr;
+	struct bnxt_re_uctx_resp resp = {};
+	struct bnxt_re_uctx_req ureq = {};
+	struct bnxt_qplib_chip_ctx *cctx;
+	u32 chip_met_rev_num;
+	bool genp5 = false;
+	int rc;
+
+	cctx = rdev->chip_ctx;
+	rc = bnxt_re_check_abi_version(rdev);
+	if (rc)
+		goto fail;
+
+	uctx->rdev = rdev;
+	uctx->shpg = (void *)__get_free_page(GFP_KERNEL);
+	if (!uctx->shpg) {
+		dev_err(rdev_to_dev(rdev), "shared memory allocation failed!\n");
+		rc = -ENOMEM;
+		goto fail;
+	}
+	spin_lock_init(&uctx->sh_lock);
+	if (BNXT_RE_ABI_VERSION >= 4) {
+		chip_met_rev_num = cctx->chip_num;
+		chip_met_rev_num |= ((u32)cctx->chip_rev & 0xFF) <<
+				     BNXT_RE_CHIP_ID0_CHIP_REV_SFT;
+		chip_met_rev_num |= ((u32)cctx->chip_metal & 0xFF) <<
+				     BNXT_RE_CHIP_ID0_CHIP_MET_SFT;
+		resp.chip_id0 = chip_met_rev_num;
+		resp.chip_id1 = 0; /* future extension of chip info */
+	}
+
+	if (BNXT_RE_ABI_VERSION != 4) {
+		/*Temp, Use idr_alloc instead*/
+		resp.dev_id = rdev->en_dev->pdev->devfn;
+		resp.max_qp = rdev->qplib_res.hctx->qp_ctx.max;
+	}
+
+	genp5 = _is_chip_gen_p5_p7(cctx);
+	if (BNXT_RE_ABI_VERSION > 5) {
+		resp.modes = genp5 ? cctx->modes.wqe_mode : 0;
+		if (rdev->dev_attr && BNXT_RE_HW_RETX(rdev->dev_attr->dev_cap_flags))
+			resp.comp_mask = BNXT_RE_COMP_MASK_UCNTX_HW_RETX_ENABLED;
+	}
+
+	resp.pg_size = PAGE_SIZE;
+	resp.cqe_sz = sizeof(struct cq_base);
+	resp.max_cqd = dev_attr->max_cq_wqes;
+	if (genp5 && cctx->modes.db_push) {
+		resp.comp_mask |= BNXT_RE_COMP_MASK_UCNTX_WC_DPI_ENABLED;
+		if (_is_chip_p7(cctx) &&
+		    !(dev_attr->dev_cap_flags &
+		      CREQ_QUERY_FUNC_RESP_SB_PINGPONG_PUSH_MODE))
+			resp.comp_mask &=
+				~BNXT_RE_COMP_MASK_UCNTX_WC_DPI_ENABLED;
+	}
+
+	resp.comp_mask |= BNXT_RE_COMP_MASK_UCNTX_MQP_EX_SUPPORTED;
+
+	if (rdev->dbr_pacing)
+		resp.comp_mask |= BNXT_RE_COMP_MASK_UCNTX_DBR_PACING_ENABLED;
+
+	if (rdev->dbr_drop_recov && rdev->user_dbr_drop_recov)
+		resp.comp_mask |= BNXT_RE_COMP_MASK_UCNTX_DBR_RECOVERY_ENABLED;
+
+	if (udata->inlen >= sizeof(ureq)) {
+		rc = ib_copy_from_udata(&ureq, udata,
+					min(udata->inlen, sizeof(ureq)));
+		if (rc)
+			goto cfail;
+		if (bnxt_re_init_pow2_flag(&ureq, &resp))
+			dev_warn(rdev_to_dev(rdev),
+				 "Enabled roundup logic. Library bug?\n");
+		if (bnxt_re_init_rsvd_wqe_flag(&ureq, &resp, genp5))
+			dev_warn(rdev_to_dev(rdev),
+				 "Rsvd wqe in use! Try the updated library.\n");
+	} else {
+		dev_warn(rdev_to_dev(rdev),
+			 "Enabled roundup logic. Update the library!\n");
+		resp.comp_mask &= ~BNXT_RE_COMP_MASK_UCNTX_POW2_DISABLED;
+
+		dev_warn(rdev_to_dev(rdev),
+			 "Rsvd wqe in use. Update the library!\n");
+		resp.comp_mask &= ~BNXT_RE_COMP_MASK_UCNTX_RSVD_WQE_DISABLED;
+	}
+
+	uctx->cmask = (uint64_t)resp.comp_mask;
+	rc = bnxt_re_copy_to_udata(rdev, &resp,
+				   min(udata->outlen, sizeof(resp)),
+				   udata);
+	if (rc)
+		goto cfail;
+
+	INIT_LIST_HEAD(&uctx->cq_list);
+	mutex_init(&uctx->cq_lock);
+
+	return 0;
+cfail:
+	free_page((u64)uctx->shpg);
+	uctx->shpg = NULL;
+fail:
+	return rc;
+}
+
+void bnxt_re_dealloc_ucontext(struct ib_ucontext *ib_uctx)
+{
+	struct bnxt_re_ucontext *uctx = to_bnxt_re(ib_uctx,
+						   struct bnxt_re_ucontext,
+						   ibucontext);
+	struct bnxt_re_dev *rdev = uctx->rdev;
+	int rc = 0;
+
+	if (uctx->shpg)
+		free_page((u64)uctx->shpg);
+
+	if (uctx->dpi.dbr) {
+		/* Free DPI only if this is the first PD allocated by the
+		 * application and mark the context dpi as NULL
+		 */
+		if (_is_chip_gen_p5_p7(rdev->chip_ctx) && uctx->wcdpi.dbr) {
+			rc = bnxt_qplib_dealloc_dpi(&rdev->qplib_res,
+						    &uctx->wcdpi);
+			if (rc)
+				dev_err(rdev_to_dev(rdev),
+						"dealloc push dp failed\n");
+			uctx->wcdpi.dbr = NULL;
+		}
+
+		rc = bnxt_qplib_dealloc_dpi(&rdev->qplib_res,
+					    &uctx->dpi);
+		if (rc)
+			dev_err(rdev_to_dev(rdev), "Deallocte HW DPI failed!\n");
+			/* Don't fail, continue*/
+		uctx->dpi.dbr = NULL;
+	}
+	return;
+}
+
+static struct bnxt_re_cq *is_bnxt_re_cq_page(struct bnxt_re_ucontext *uctx,
+				      u64 pg_off)
+{
+	struct bnxt_re_cq *cq = NULL, *tmp_cq;
+
+	if (!_is_chip_p7(uctx->rdev->chip_ctx))
+		return NULL;
+
+	mutex_lock(&uctx->cq_lock);
+	list_for_each_entry(tmp_cq, &uctx->cq_list, cq_list) {
+		if (((u64)tmp_cq->uctx_cq_page >> PAGE_SHIFT) == pg_off) {
+			cq = tmp_cq;
+			break;
+		}
+	}
+	mutex_unlock(&uctx->cq_lock);
+	return cq;
+}
+
+/* Helper function to mmap the virtual memory from user app */
+int bnxt_re_mmap(struct ib_ucontext *ib_uctx, struct vm_area_struct *vma)
+{
+	struct bnxt_re_ucontext *uctx = to_bnxt_re(ib_uctx,
+						   struct bnxt_re_ucontext,
+						   ibucontext);
+	struct bnxt_re_dev *rdev = uctx->rdev;
+	struct bnxt_re_cq *cq = NULL;
+	int rc = 0;
+	u64 pfn;
+
+	switch (vma->vm_pgoff) {
+	case BNXT_RE_MAP_SH_PAGE:
+		pfn = vtophys(uctx->shpg) >> PAGE_SHIFT;
+		return rdma_user_mmap_io(&uctx->ibucontext, vma, pfn, PAGE_SIZE, vma->vm_page_prot, NULL);
+		dev_dbg(rdev_to_dev(rdev), "%s:%d uctx->shpg 0x%lx, vtophys(uctx->shpg) 0x%lx, pfn = 0x%lx \n",
+				__func__, __LINE__, (u64) uctx->shpg, vtophys(uctx->shpg), pfn);
+		if (rc) {
+			dev_err(rdev_to_dev(rdev), "Shared page mapping failed!\n");
+			rc = -EAGAIN;
+		}
+		return rc;
+	case BNXT_RE_MAP_WC:
+		vma->vm_page_prot =
+			pgprot_writecombine(vma->vm_page_prot);
+		pfn = (uctx->wcdpi.umdbr >> PAGE_SHIFT);
+		if (!pfn)
+			return -EFAULT;
+		break;
+	case BNXT_RE_DBR_PAGE:
+		/* Driver doesn't expect write access request */
+		if (vma->vm_flags & VM_WRITE)
+			return -EFAULT;
+
+		pfn = vtophys(rdev->dbr_page) >> PAGE_SHIFT;
+		if (!pfn)
+			return -EFAULT;
+		break;
+	case BNXT_RE_MAP_DB_RECOVERY_PAGE:
+		pfn = vtophys(uctx->dbr_recov_cq_page) >> PAGE_SHIFT;
+		if (!pfn)
+			return -EFAULT;
+		break;
+	default:
+		cq = is_bnxt_re_cq_page(uctx, vma->vm_pgoff);
+		if (cq) {
+			pfn = vtophys((void *)cq->uctx_cq_page) >> PAGE_SHIFT;
+			rc = rdma_user_mmap_io(&uctx->ibucontext, vma, pfn, PAGE_SIZE, vma->vm_page_prot, NULL);
+			if (rc) {
+				dev_err(rdev_to_dev(rdev),
+					"CQ page mapping failed!\n");
+				rc = -EAGAIN;
+			}
+			goto out;
+		} else {
+			vma->vm_page_prot =
+				pgprot_noncached(vma->vm_page_prot);
+			pfn = vma->vm_pgoff;
+		}
+		break;
+	}
+
+	rc = rdma_user_mmap_io(&uctx->ibucontext, vma, pfn, PAGE_SIZE, vma->vm_page_prot, NULL);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev), "DPI mapping failed!\n");
+		return -EAGAIN;
+	}
+	rc = __bnxt_re_set_vma_data(uctx, vma);
+out:
+	return rc;
+}
+
+int bnxt_re_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
+			const struct ib_wc *wc, const struct ib_grh *grh,
+			const struct ib_mad_hdr *in_mad, size_t in_mad_size,
+			struct ib_mad_hdr *out_mad, size_t *out_mad_size,
+			u16 *out_mad_pkey_index)
+{
+	return IB_MAD_RESULT_SUCCESS;
+}
+
+void bnxt_re_disassociate_ucntx(struct ib_ucontext *ib_uctx)
+{
+}
diff --git a/sys/dev/bnxt/bnxt_re/ib_verbs.h b/sys/dev/bnxt/bnxt_re/ib_verbs.h
new file mode 100644
index 000000000000..cb9f7974e92d
--- /dev/null
+++ b/sys/dev/bnxt/bnxt_re/ib_verbs.h
@@ -0,0 +1,632 @@
+/*
+ * Copyright (c) 2015-2024, Broadcom. All rights reserved.  The term
+ * Broadcom refers to Broadcom Limited and/or its subsidiaries.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Description: IB Verbs interpreter (header)
+ */
+
+#ifndef __BNXT_RE_IB_VERBS_H__
+#define __BNXT_RE_IB_VERBS_H__
+
+#include <rdma/ib_addr.h>
+#include "bnxt_re-abi.h"
+#include "qplib_res.h"
+#include "qplib_fp.h"
+
+struct bnxt_re_dev;
+
+#define BNXT_RE_ROCE_V2_UDP_SPORT	0x8CD1
+#define BNXT_RE_QP_RANDOM_QKEY		0x81818181
+
+#ifndef IB_MTU_8192
+#define IB_MTU_8192 8192
+#endif
+
+#ifndef SPEED_1000
+#define SPEED_1000		1000
+#endif
+
+#ifndef SPEED_10000
+#define SPEED_10000		10000
+#endif
+
+#ifndef SPEED_20000
+#define SPEED_20000		20000
+#endif
+
+#ifndef SPEED_25000
+#define SPEED_25000		25000
+#endif
+
+#ifndef SPEED_40000
+#define SPEED_40000		40000
+#endif
+
+#ifndef SPEED_50000
+#define SPEED_50000		50000
+#endif
+
+#ifndef SPEED_100000
+#define SPEED_100000		100000
+#endif
+
+#ifndef SPEED_200000
+#define SPEED_200000		200000
+#endif
+
+#ifndef IB_SPEED_HDR
+#define IB_SPEED_HDR		64
+#endif
+
+#define RDMA_NETWORK_IPV4	1
+#define RDMA_NETWORK_IPV6	2
+
+#define ROCE_DMAC(x) (x)->dmac
+
+#define dma_rmb()       rmb()
+
+#define compat_ib_alloc_device(size) ib_alloc_device(size);
+
+#define rdev_from_cq_in(cq_in) to_bnxt_re_dev(cq_in->device, ibdev)
+
+#define GET_UVERBS_ABI_VERSION(ibdev)	(ibdev->uverbs_abi_ver)
+
+#define CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_PG_256MB 0x1cUL
+
+#define IB_POLL_UNBOUND_WORKQUEUE       IB_POLL_WORKQUEUE
+
+#define BNXT_RE_LEGACY_FENCE_BYTES	64
+#define BNXT_RE_LEGACY_FENCE_PBL_SIZE	DIV_ROUND_UP(BNXT_RE_LEGACY_FENCE_BYTES, PAGE_SIZE)
+
+
+static inline struct
+bnxt_re_cq *__get_cq_from_cq_in(struct ib_cq *cq_in,
+				struct bnxt_re_dev *rdev);
+static inline struct
+bnxt_re_qp *__get_qp_from_qp_in(struct ib_pd *qp_in,
+				struct bnxt_re_dev *rdev);
+
+static inline bool
+bnxt_re_check_if_vlan_valid(struct bnxt_re_dev *rdev, u16 vlan_id);
+
+#define bnxt_re_compat_qfwstr(void)			\
+	bnxt_re_query_fw_str(struct ib_device *ibdev,	\
+			     char *str, size_t str_len)
+
+static inline
+struct scatterlist *get_ib_umem_sgl(struct ib_umem *umem, u32 *nmap);
+
+struct bnxt_re_gid_ctx {
+	u32			idx;
+	u32			refcnt;
+};
+
+struct bnxt_re_legacy_fence_data {
+	u32 size;
+	void *va;
+	dma_addr_t dma_addr;
+	struct bnxt_re_mr *mr;
+	struct ib_mw *mw;
+	struct bnxt_qplib_swqe bind_wqe;
+	u32 bind_rkey;
+};
+
+struct bnxt_re_pd {
+	struct ib_pd		ibpd;
+	struct bnxt_re_dev	*rdev;
+	struct bnxt_qplib_pd	qplib_pd;
+	struct bnxt_re_legacy_fence_data fence;
+};
+
+struct bnxt_re_ah {
+	struct ib_ah		ibah;
+	struct bnxt_re_dev	*rdev;
+	struct bnxt_qplib_ah	qplib_ah;
+};
+
+struct bnxt_re_srq {
+	struct ib_srq		ibsrq;
+	struct bnxt_re_dev	*rdev;
+	u32			srq_limit;
+	struct bnxt_qplib_srq	qplib_srq;
+	struct ib_umem		*umem;
+	spinlock_t		lock;
+};
+
+union ip_addr {
+	u32 ipv4_addr;
+	u8  ipv6_addr[16];
+};
+
+struct bnxt_re_qp_info_entry {
+	union ib_gid		sgid;
+	union ib_gid 		dgid;
+	union ip_addr		s_ip;
+	union ip_addr		d_ip;
+	u16			s_port;
+#define BNXT_RE_QP_DEST_PORT	4791
+	u16			d_port;
+};
+
+struct bnxt_re_qp {
+	struct ib_qp		ib_qp;
+	struct list_head	list;
+	struct bnxt_re_dev	*rdev;
+	spinlock_t		sq_lock;
+	spinlock_t		rq_lock;
+	struct bnxt_qplib_qp	qplib_qp;
+	struct ib_umem		*sumem;
+	struct ib_umem		*rumem;
+	/* QP1 */
+	u32			send_psn;
+	struct ib_ud_header	qp1_hdr;
+	struct bnxt_re_cq	*scq;
+	struct bnxt_re_cq	*rcq;
+	struct dentry		*qp_info_pdev_dentry;
+	struct bnxt_re_qp_info_entry qp_info_entry;
+	void			*qp_data;
+};
+
+struct bnxt_re_cq {
+	struct ib_cq		ibcq;
+	struct list_head	cq_list;
+	struct bnxt_re_dev	*rdev;
+	struct bnxt_re_ucontext *uctx;
+	spinlock_t              cq_lock;
+	u16			cq_count;
+	u16			cq_period;
+	struct bnxt_qplib_cq	qplib_cq;
+	struct bnxt_qplib_cqe	*cql;
+#define MAX_CQL_PER_POLL	1024
+	u32			max_cql;
+	struct ib_umem		*umem;
+	struct ib_umem		*resize_umem;
+	struct ib_ucontext	*context;
+	int			resize_cqe;
+	/* list of cq per uctx. Used only for Thor-2 */
+	void			*uctx_cq_page;
+	void			*dbr_recov_cq_page;
+	bool			is_dbr_soft_cq;
+};
+
+struct bnxt_re_mr {
+	struct bnxt_re_dev	*rdev;
+	struct ib_mr		ib_mr;
+	struct ib_umem		*ib_umem;
+	struct bnxt_qplib_mrw	qplib_mr;
+	u32			npages;
+	u64			*pages;
+	struct bnxt_qplib_frpl	qplib_frpl;
+	bool                    is_invalcb_active;
+};
+
+struct bnxt_re_frpl {
+	struct bnxt_re_dev		*rdev;
+	struct bnxt_qplib_frpl		qplib_frpl;
+	u64				*page_list;
+};
+
+struct bnxt_re_mw {
+	struct bnxt_re_dev	*rdev;
+	struct ib_mw		ib_mw;
+	struct bnxt_qplib_mrw	qplib_mw;
+};
+
+struct bnxt_re_ucontext {
+	struct ib_ucontext	ibucontext;
+	struct bnxt_re_dev	*rdev;
+	struct list_head	cq_list;
+	struct bnxt_qplib_dpi	dpi;
+	struct bnxt_qplib_dpi	wcdpi;
+	void			*shpg;
+	spinlock_t		sh_lock;
+	uint64_t		cmask;
+	struct mutex		cq_lock;	/* Protect cq list */
+	void			*dbr_recov_cq_page;
+	struct bnxt_re_cq	*dbr_recov_cq;
+};
+
+struct bnxt_re_ah_info {
+	union ib_gid		sgid;
+	struct ib_gid_attr	sgid_attr;
+	u16			vlan_tag;
+	u8			nw_type;
+};
+
+struct ifnet *bnxt_re_get_netdev(struct ib_device *ibdev,
+				 u8 port_num);
+
+int bnxt_re_query_device(struct ib_device *ibdev,
+			 struct ib_device_attr *ib_attr,
+			 struct ib_udata *udata);
+int bnxt_re_modify_device(struct ib_device *ibdev,
+			  int device_modify_mask,
+			  struct ib_device_modify *device_modify);
+int bnxt_re_query_port(struct ib_device *ibdev, u8 port_num,
+		       struct ib_port_attr *port_attr);
+int bnxt_re_modify_port(struct ib_device *ibdev, u8 port_num,
+			int port_modify_mask,
+			struct ib_port_modify *port_modify);
+int bnxt_re_get_port_immutable(struct ib_device *ibdev, u8 port_num,
+			       struct ib_port_immutable *immutable);
+void bnxt_re_compat_qfwstr(void);
+int bnxt_re_query_pkey(struct ib_device *ibdev, u8 port_num,
+		       u16 index, u16 *pkey);
+int bnxt_re_del_gid(struct ib_device *ibdev, u8 port_num,
+		    unsigned int index, void **context);
+int bnxt_re_add_gid(struct ib_device *ibdev, u8 port_num,
+		    unsigned int index, const union ib_gid *gid,
+		    const struct ib_gid_attr *attr, void **context);
+int bnxt_re_query_gid(struct ib_device *ibdev, u8 port_num,
+		      int index, union ib_gid *gid);
+enum rdma_link_layer bnxt_re_get_link_layer(struct ib_device *ibdev,
+					    u8 port_num);
+int bnxt_re_alloc_pd(struct ib_pd *pd_in, struct ib_udata *udata);
+void bnxt_re_dealloc_pd(struct ib_pd *ib_pd, struct ib_udata *udata);
+
+int bnxt_re_create_ah(struct ib_ah *ah_in, struct ib_ah_attr *attr,
+		      u32 flags, struct ib_udata *udata);
+
+int bnxt_re_modify_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr);
+int bnxt_re_query_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr);
+
+void bnxt_re_destroy_ah(struct ib_ah *ib_ah, u32 flags);
+int bnxt_re_create_srq(struct ib_srq *srq_in,
+		       struct ib_srq_init_attr *srq_init_attr,
+		       struct ib_udata *udata);
+int bnxt_re_modify_srq(struct ib_srq *srq, struct ib_srq_attr *srq_attr,
+		       enum ib_srq_attr_mask srq_attr_mask,
+		       struct ib_udata *udata);
+int bnxt_re_query_srq(struct ib_srq *srq, struct ib_srq_attr *srq_attr);
+void bnxt_re_destroy_srq(struct ib_srq *ib_srq,
+			 struct ib_udata *udata);
+int bnxt_re_post_srq_recv(struct ib_srq *ib_srq, const struct ib_recv_wr *wr,
+			  const struct ib_recv_wr **bad_wr);
+struct ib_qp *bnxt_re_create_qp(struct ib_pd *qp_in,
+			       struct ib_qp_init_attr *qp_init_attr,
+			       struct ib_udata *udata);
+int bnxt_re_modify_qp(struct ib_qp *qp, struct ib_qp_attr *qp_attr,
+		      int qp_attr_mask, struct ib_udata *udata);
+int bnxt_re_query_qp(struct ib_qp *qp, struct ib_qp_attr *qp_attr,
+		     int qp_attr_mask, struct ib_qp_init_attr *qp_init_attr);
+int bnxt_re_destroy_qp(struct ib_qp *ib_qp, struct ib_udata *udata);
+int bnxt_re_post_send(struct ib_qp *ib_qp, const struct ib_send_wr *wr,
+		      const struct ib_send_wr **bad_wr);
+int bnxt_re_post_recv(struct ib_qp *ib_qp, const struct ib_recv_wr *wr,
+		      const struct ib_recv_wr **bad_wr);
+int bnxt_re_create_cq(struct ib_cq *cq_in,
+		      const struct ib_cq_init_attr *attr,
+		      struct ib_udata *udata);
+void bnxt_re_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata);
+int bnxt_re_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period);
+int bnxt_re_resize_cq(struct ib_cq *cq, int cqe, struct ib_udata *udata);
+int bnxt_re_poll_cq(struct ib_cq *cq, int num_entries, struct ib_wc *wc);
+int bnxt_re_req_notify_cq(struct ib_cq *cq, enum ib_cq_notify_flags flags);
+struct ib_mr *bnxt_re_get_dma_mr(struct ib_pd *pd, int mr_access_flags);
+int bnxt_re_map_mr_sg(struct ib_mr *ib_mr, struct scatterlist *sg,
+		      int sg_nents, unsigned int *sg_offset);
+struct ib_mr *bnxt_re_alloc_mr(struct ib_pd *ib_pd, enum ib_mr_type type,
+			       u32 max_num_sg, struct ib_udata *udata);
+int bnxt_re_dereg_mr(struct ib_mr *ib_mr, struct ib_udata *udata);
+struct ib_mw *bnxt_re_alloc_mw(struct ib_pd *ib_pd, enum ib_mw_type type,
+			       struct ib_udata *udata);
+int bnxt_re_dealloc_mw(struct ib_mw *mw);
+struct ib_mr *bnxt_re_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
+				  u64 virt_addr, int mr_access_flags,
+				  struct ib_udata *udata);
+int
+bnxt_re_rereg_user_mr(struct ib_mr *mr, int flags, u64 start, u64 length,
+		      u64 virt_addr, int mr_access_flags, struct ib_pd *pd,
+		      struct ib_udata *udata);
+int bnxt_re_alloc_ucontext(struct ib_ucontext *uctx_in,
+			   struct ib_udata *udata);
+void bnxt_re_dealloc_ucontext(struct ib_ucontext *ib_uctx);
+int bnxt_re_mmap(struct ib_ucontext *context, struct vm_area_struct *vma);
+int bnxt_re_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
+			const struct ib_wc *wc, const struct ib_grh *grh,
+			const struct ib_mad_hdr *in_mad, size_t in_mad_size,
+			struct ib_mad_hdr *out_mad, size_t *out_mad_size,
+			u16 *out_mad_pkey_index);
+unsigned long bnxt_re_lock_cqs(struct bnxt_re_qp *qp);
+void bnxt_re_unlock_cqs(struct bnxt_re_qp *qp, unsigned long flags);
+void bnxt_re_disassociate_ucntx(struct ib_ucontext *ibcontext);
+static inline int __bnxt_re_set_vma_data(void *bnxt_re_uctx,
+					 struct vm_area_struct *vma);
+void bnxt_re_update_shadow_ah(struct bnxt_re_dev *rdev);
+void bnxt_re_handle_cqn(struct bnxt_qplib_cq *cq);
+static inline int
+bnxt_re_get_cached_gid(struct ib_device *dev, u8 port_num, int index,
+		       union ib_gid *sgid, struct ib_gid_attr **sgid_attr,
+		       struct ib_global_route *grh, struct ib_ah *ah);
+static inline enum rdma_network_type
+bnxt_re_gid_to_network_type(struct ib_gid_attr *sgid_attr,
+			    union ib_gid *sgid);
+static inline
+struct ib_umem *ib_umem_get_compat(struct bnxt_re_dev *rdev,
+				   struct ib_ucontext *ucontext,
+				   struct ib_udata *udata,
+				   unsigned long addr,
+				   size_t size, int access, int dmasync);
+static inline
+struct ib_umem *ib_umem_get_flags_compat(struct bnxt_re_dev *rdev,
+					 struct ib_ucontext *ucontext,
+					 struct ib_udata *udata,
+					 unsigned long addr,
+					 size_t size, int access, int dmasync);
+static inline size_t ib_umem_num_pages_compat(struct ib_umem *umem);
+static inline void bnxt_re_peer_mem_release(struct ib_umem *umem);
+void bnxt_re_resolve_dmac_task(struct work_struct *work);
+
+static inline enum ib_qp_type  __from_hw_to_ib_qp_type(u8 type)
+{
+	switch (type) {
+	case CMDQ_CREATE_QP1_TYPE_GSI:
+	case CMDQ_CREATE_QP_TYPE_GSI:
+		return IB_QPT_GSI;
+	case CMDQ_CREATE_QP_TYPE_RC:
+		return IB_QPT_RC;
+	case CMDQ_CREATE_QP_TYPE_UD:
+		return IB_QPT_UD;
+	case CMDQ_CREATE_QP_TYPE_RAW_ETHERTYPE:
+		return IB_QPT_RAW_ETHERTYPE;
+	default:
+		return IB_QPT_MAX;
+	}
+}
+
+static inline u8 __from_ib_qp_state(enum ib_qp_state state)
+{
+	switch (state) {
+	case IB_QPS_RESET:
+		return CMDQ_MODIFY_QP_NEW_STATE_RESET;
+	case IB_QPS_INIT:
+		return CMDQ_MODIFY_QP_NEW_STATE_INIT;
+	case IB_QPS_RTR:
+		return CMDQ_MODIFY_QP_NEW_STATE_RTR;
+	case IB_QPS_RTS:
+		return CMDQ_MODIFY_QP_NEW_STATE_RTS;
+	case IB_QPS_SQD:
+		return CMDQ_MODIFY_QP_NEW_STATE_SQD;
+	case IB_QPS_SQE:
+		return CMDQ_MODIFY_QP_NEW_STATE_SQE;
+	case IB_QPS_ERR:
+	default:
+		return CMDQ_MODIFY_QP_NEW_STATE_ERR;
+	}
+}
+
+static inline u32 __from_ib_mtu(enum ib_mtu mtu)
+{
+	switch (mtu) {
+	case IB_MTU_256:
+		return CMDQ_MODIFY_QP_PATH_MTU_MTU_256;
+	case IB_MTU_512:
+		return CMDQ_MODIFY_QP_PATH_MTU_MTU_512;
+	case IB_MTU_1024:
+		return CMDQ_MODIFY_QP_PATH_MTU_MTU_1024;
+	case IB_MTU_2048:
+		return CMDQ_MODIFY_QP_PATH_MTU_MTU_2048;
+	case IB_MTU_4096:
+		return CMDQ_MODIFY_QP_PATH_MTU_MTU_4096;
+	default:
+		return CMDQ_MODIFY_QP_PATH_MTU_MTU_2048;
+	}
+}
+
+static inline enum ib_mtu __to_ib_mtu(u32 mtu)
+{
+	switch (mtu & CREQ_QUERY_QP_RESP_SB_PATH_MTU_MASK) {
+	case CMDQ_MODIFY_QP_PATH_MTU_MTU_256:
+		return IB_MTU_256;
+	case CMDQ_MODIFY_QP_PATH_MTU_MTU_512:
+		return IB_MTU_512;
+	case CMDQ_MODIFY_QP_PATH_MTU_MTU_1024:
+		return IB_MTU_1024;
+	case CMDQ_MODIFY_QP_PATH_MTU_MTU_2048:
+		return IB_MTU_2048;
+	case CMDQ_MODIFY_QP_PATH_MTU_MTU_4096:
+		return IB_MTU_4096;
+	case CMDQ_MODIFY_QP_PATH_MTU_MTU_8192:
+		return IB_MTU_8192;
+	default:
+		return IB_MTU_2048;
+	}
+}
+
+static inline enum ib_qp_state __to_ib_qp_state(u8 state)
+{
+	switch (state) {
+	case CMDQ_MODIFY_QP_NEW_STATE_RESET:
+		return IB_QPS_RESET;
+	case CMDQ_MODIFY_QP_NEW_STATE_INIT:
+		return IB_QPS_INIT;
+	case CMDQ_MODIFY_QP_NEW_STATE_RTR:
+		return IB_QPS_RTR;
+	case CMDQ_MODIFY_QP_NEW_STATE_RTS:
+		return IB_QPS_RTS;
+	case CMDQ_MODIFY_QP_NEW_STATE_SQD:
+		return IB_QPS_SQD;
+	case CMDQ_MODIFY_QP_NEW_STATE_SQE:
+		return IB_QPS_SQE;
+	case CMDQ_MODIFY_QP_NEW_STATE_ERR:
+	default:
+		return IB_QPS_ERR;
+	}
+}
+
+static inline int bnxt_re_init_pow2_flag(struct bnxt_re_uctx_req *req,
+					 struct bnxt_re_uctx_resp *resp)
+{
+	resp->comp_mask |= BNXT_RE_COMP_MASK_UCNTX_POW2_DISABLED;
+	if (!(req->comp_mask & BNXT_RE_COMP_MASK_REQ_UCNTX_POW2_SUPPORT)) {
+		resp->comp_mask &= ~BNXT_RE_COMP_MASK_UCNTX_POW2_DISABLED;
+		return -EINVAL;
+	}
+	return 0;
+}
+
+static inline u32 bnxt_re_init_depth(u32 ent, struct bnxt_re_ucontext *uctx)
+{
+	return uctx ? (uctx->cmask & BNXT_RE_COMP_MASK_UCNTX_POW2_DISABLED) ?
+		       ent : roundup_pow_of_two(ent) : ent;
+}
+
+static inline int bnxt_re_init_rsvd_wqe_flag(struct bnxt_re_uctx_req *req,
+					     struct bnxt_re_uctx_resp *resp,
+					     bool genp5)
+{
+	resp->comp_mask |= BNXT_RE_COMP_MASK_UCNTX_RSVD_WQE_DISABLED;
+	if (!(req->comp_mask & BNXT_RE_COMP_MASK_REQ_UCNTX_RSVD_WQE)) {
+		resp->comp_mask &= ~BNXT_RE_COMP_MASK_UCNTX_RSVD_WQE_DISABLED;
+		return -EINVAL;
+	} else if (!genp5) {
+		resp->comp_mask &= ~BNXT_RE_COMP_MASK_UCNTX_RSVD_WQE_DISABLED;
+	}
+	return 0;
+}
+
+static inline u32 bnxt_re_get_diff(struct bnxt_re_ucontext *uctx,
+				   struct bnxt_qplib_chip_ctx *cctx)
+{
+	if (!uctx) {
+		/* return res-wqe only for gen p4 for user resource */
+		return _is_chip_gen_p5_p7(cctx) ? 0 : BNXT_QPLIB_RESERVED_QP_WRS;
+	} else if (uctx->cmask & BNXT_RE_COMP_MASK_UCNTX_RSVD_WQE_DISABLED) {
+		return 0;
+	}
+	/* old lib */
+	return BNXT_QPLIB_RESERVED_QP_WRS;
+}
+
+static inline void bnxt_re_init_qpmtu(struct bnxt_re_qp *qp, int mtu,
+				      int mask, struct ib_qp_attr *qp_attr,
+				      bool *is_qpmtu_high)
+{
+	int qpmtu, qpmtu_int;
+	int ifmtu, ifmtu_int;
+
+	ifmtu = iboe_get_mtu(mtu);
+	ifmtu_int = ib_mtu_enum_to_int(ifmtu);
+	qpmtu = ifmtu;
+	qpmtu_int = ifmtu_int;
+	if (mask & IB_QP_PATH_MTU) {
+		qpmtu = qp_attr->path_mtu;
+		qpmtu_int = ib_mtu_enum_to_int(qpmtu);
+		if (qpmtu_int > ifmtu_int) {
+			/* Trim the QP path mtu to interface mtu and update
+			 * the new mtu to user qp for retransmission psn
+			 * calculations.
+			 */
+			qpmtu = ifmtu;
+			qpmtu_int = ifmtu_int;
+			*is_qpmtu_high = true;
+		}
+	}
+	qp->qplib_qp.path_mtu = __from_ib_mtu(qpmtu);
+	qp->qplib_qp.mtu = qpmtu_int;
+	qp->qplib_qp.modify_flags |=
+		CMDQ_MODIFY_QP_MODIFY_MASK_PATH_MTU;
+}
+
+inline unsigned long compare_ether_header(void *a, void *b)
+{
+	u32 *a32 = (u32 *)((u8 *)a + 2);
+	u32 *b32 = (u32 *)((u8 *)b + 2);
+
+	return (*(u16 *)a ^ *(u16 *)b) | (a32[0] ^ b32[0]) |
+	       (a32[1] ^ b32[1]) | (a32[2] ^ b32[2]);
+}
+
+struct vlan_hdr {
+	__be16	h_vlan_TCI;
+	__be16	h_vlan_encapsulated_proto;
+};
+
+inline uint16_t
+crc16(uint16_t crc, const void *buffer, unsigned int len)
+{
+	const unsigned char *cp = buffer;
+	/* CRC table for the CRC-16. The poly is 0x8005 (x16 + x15 + x2 + 1). */
+	static uint16_t const crc16_table[256] = {
+		0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
+		0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
+		0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40,
+		0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841,
+		0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40,
+		0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41,
+		0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641,
+		0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040,
+		0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240,
+		0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441,
+		0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41,
+		0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840,
+		0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41,
+		0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40,
+		0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640,
+		0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041,
+		0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240,
+		0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441,
+		0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41,
+		0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840,
+		0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41,
+		0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40,
+		0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640,
+		0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041,
+		0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241,
+		0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440,
+		0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40,
+		0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841,
+		0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40,
+		0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41,
+		0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641,
+		0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
+	};
+
+	while (len--)
+		crc = (((crc >> 8) & 0xffU) ^
+		    crc16_table[(crc ^ *cp++) & 0xffU]) & 0x0000ffffU;
+	return crc;
+}
+
+static inline int __bnxt_re_set_vma_data(void *bnxt_re_uctx,
+					 struct vm_area_struct *vma)
+{
+	return 0;
+}
+
+static inline bool bnxt_re_check_if_vlan_valid(struct bnxt_re_dev *rdev,
+					       u16 vlan_id)
+{
+	bool ret = true;
+	/*
+	 * Check if the vlan is configured in the host.
+	 * If not configured, it  can be a transparent
+	 * VLAN. So dont report the vlan id.
+	 */
+	return ret;
+}
+
+#endif
diff --git a/sys/dev/bnxt/bnxt_re/main.c b/sys/dev/bnxt/bnxt_re/main.c
new file mode 100644
index 000000000000..e6c6f754ea47
--- /dev/null
+++ b/sys/dev/bnxt/bnxt_re/main.c
@@ -0,0 +1,4467 @@
+/*
+ * Copyright (c) 2015-2024, Broadcom. All rights reserved.  The term
+ * Broadcom refers to Broadcom Limited and/or its subsidiaries.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Description: Main component of the bnxt_re driver
+ */
+
+#include <linux/if_ether.h>
+#include <linux/module.h>
+#include <linux/errno.h>
+#include <linux/pci.h>
+#include <linux/dma-mapping.h>
+#include <linux/slab.h>
+#include <linux/sched.h>
+#include <linux/delay.h>
+#include <linux/fs.h>
+#include <rdma/ib_user_verbs.h>
+#include <rdma/ib_addr.h>
+#include <rdma/ib_cache.h>
+#include <dev/mlx5/port.h>
+#include <dev/mlx5/vport.h>
+#include <linux/list.h>
+#include <rdma/ib_smi.h>
+#include <rdma/ib_umem.h>
+#include <linux/in.h>
+#include <linux/etherdevice.h>
+
+#include "bnxt_re.h"
+#include "ib_verbs.h"
+#include "bnxt_re-abi.h"
+#include "bnxt.h"
+
+static char drv_version[] =
+		"Broadcom NetXtreme-C/E RoCE Driver " ROCE_DRV_MODULE_NAME \
+		" v" ROCE_DRV_MODULE_VERSION " (" ROCE_DRV_MODULE_RELDATE ")\n";
+
+#define BNXT_RE_DESC	"Broadcom NetXtreme RoCE"
+#define BNXT_ADEV_NAME "if_bnxt"
+
+MODULE_DESCRIPTION("Broadcom NetXtreme-C/E RoCE Driver");
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_DEPEND(bnxt_re, linuxkpi, 1, 1, 1);
+MODULE_DEPEND(bnxt_re, ibcore, 1, 1, 1);
+MODULE_DEPEND(bnxt_re, if_bnxt, 1, 1, 1);
+MODULE_VERSION(bnxt_re, 1);
+
+
+DEFINE_MUTEX(bnxt_re_mutex); /* mutex lock for driver */
+
+static unsigned int restrict_mrs = 0;
+module_param(restrict_mrs, uint, 0);
+MODULE_PARM_DESC(restrict_mrs, " Restrict the no. of MRs 0 = 256K , 1 = 64K");
+
+unsigned int restrict_stats = 0;
+module_param(restrict_stats, uint, 0);
+MODULE_PARM_DESC(restrict_stats, "Restrict stats query frequency to ethtool coalesce value. Disabled by default");
+
+unsigned int enable_fc = 1;
+module_param(enable_fc, uint, 0);
+MODULE_PARM_DESC(enable_fc, "Enable default PFC, CC,ETS during driver load. 1 - fc enable, 0 - fc disable - Default is 1");
+
+unsigned int min_tx_depth = 1;
+module_param(min_tx_depth, uint, 0);
+MODULE_PARM_DESC(min_tx_depth, "Minimum TX depth - Default is 1");
+
+static uint8_t max_msix_vec[BNXT_RE_MAX_DEVICES] = {0};
+static unsigned int max_msix_vec_argc;
+module_param_array(max_msix_vec, byte, &max_msix_vec_argc, 0444);
+MODULE_PARM_DESC(max_msix_vec, "Max MSI-x vectors per PF (2 - 64) - Default is 64");
+
+unsigned int cmdq_shadow_qd = RCFW_CMD_NON_BLOCKING_SHADOW_QD;
+module_param_named(cmdq_shadow_qd, cmdq_shadow_qd, uint, 0644);
+MODULE_PARM_DESC(cmdq_shadow_qd, "Perf Stat Debug: Shadow QD Range (1-64) - Default is 64");
+
+
+/* globals */
+struct list_head bnxt_re_dev_list = LINUX_LIST_HEAD_INIT(bnxt_re_dev_list);
+static int bnxt_re_probe_count;
+
+DEFINE_MUTEX(bnxt_re_dev_lock);
+static u32 gmod_exit;
+static u32 gadd_dev_inprogress;
+
+static void bnxt_re_task(struct work_struct *work_task);
+static struct workqueue_struct *bnxt_re_wq;
+static int bnxt_re_query_hwrm_intf_version(struct bnxt_re_dev *rdev);
+static int bnxt_re_hwrm_qcfg(struct bnxt_re_dev *rdev, u32 *db_len,
+			     u32 *offset);
+static int bnxt_re_ib_init(struct bnxt_re_dev *rdev);
+static void bnxt_re_ib_init_2(struct bnxt_re_dev *rdev);
+void _bnxt_re_remove(struct auxiliary_device *adev);
+void writel_fbsd(struct bnxt_softc *bp, u32, u8, u32);
+u32 readl_fbsd(struct bnxt_softc *bp, u32, u8);
+static int bnxt_re_hwrm_dbr_pacing_qcfg(struct bnxt_re_dev *rdev);
+
+int bnxt_re_register_netdevice_notifier(struct notifier_block *nb)
+{
+	int rc;
+	rc = register_netdevice_notifier(nb);
+	return rc;
+}
+
+int bnxt_re_unregister_netdevice_notifier(struct notifier_block *nb)
+{
+	int rc;
+	rc = unregister_netdevice_notifier(nb);
+	return rc;
+}
+
+void bnxt_re_set_dma_device(struct ib_device *ibdev, struct bnxt_re_dev *rdev)
+{
+	ibdev->dma_device = &rdev->en_dev->pdev->dev;
+}
+
+void bnxt_re_init_resolve_wq(struct bnxt_re_dev *rdev)
+{
+	rdev->resolve_wq = create_singlethread_workqueue("bnxt_re_resolve_wq");
+	 INIT_LIST_HEAD(&rdev->mac_wq_list);
+}
+
+void bnxt_re_uninit_resolve_wq(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_re_resolve_dmac_work *tmp_work = NULL, *tmp_st;
+	if (!rdev->resolve_wq)
+		return;
+	flush_workqueue(rdev->resolve_wq);
+	list_for_each_entry_safe(tmp_work, tmp_st, &rdev->mac_wq_list, list) {
+			list_del(&tmp_work->list);
+			kfree(tmp_work);
+	}
+	destroy_workqueue(rdev->resolve_wq);
+	rdev->resolve_wq = NULL;
+}
+
+u32 readl_fbsd(struct bnxt_softc *bp, u32 reg_off, u8 bar_idx)
+{
+
+	if (bar_idx)
+		return bus_space_read_8(bp->doorbell_bar.tag, bp->doorbell_bar.handle, reg_off);
+	else
+		return bus_space_read_8(bp->hwrm_bar.tag, bp->hwrm_bar.handle, reg_off);
+}
+
+void writel_fbsd(struct bnxt_softc *bp, u32 reg_off, u8 bar_idx, u32 val)
+{
+	if (bar_idx)
+		bus_space_write_8(bp->doorbell_bar.tag, bp->doorbell_bar.handle, reg_off, htole32(val));
+	else
+		bus_space_write_8(bp->hwrm_bar.tag, bp->hwrm_bar.handle, reg_off, htole32(val));
+}
+
+static void bnxt_re_update_fifo_occup_slabs(struct bnxt_re_dev *rdev,
+					    u32 fifo_occup)
+{
+	if (fifo_occup > rdev->dbg_stats->dbq.fifo_occup_water_mark)
+		rdev->dbg_stats->dbq.fifo_occup_water_mark = fifo_occup;
+
+	if (fifo_occup > 8 * rdev->pacing_algo_th)
+		rdev->dbg_stats->dbq.fifo_occup_slab_4++;
+	else if (fifo_occup > 4 * rdev->pacing_algo_th)
+		rdev->dbg_stats->dbq.fifo_occup_slab_3++;
+	else if (fifo_occup > 2 * rdev->pacing_algo_th)
+		rdev->dbg_stats->dbq.fifo_occup_slab_2++;
+	else if (fifo_occup > rdev->pacing_algo_th)
+		rdev->dbg_stats->dbq.fifo_occup_slab_1++;
+}
+
+static void bnxt_re_update_do_pacing_slabs(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_qplib_db_pacing_data *pacing_data = rdev->qplib_res.pacing_data;
+
+	if (pacing_data->do_pacing > rdev->dbg_stats->dbq.do_pacing_water_mark)
+		rdev->dbg_stats->dbq.do_pacing_water_mark = pacing_data->do_pacing;
+
+	if (pacing_data->do_pacing > 16 * rdev->dbr_def_do_pacing)
+		rdev->dbg_stats->dbq.do_pacing_slab_5++;
+	else if (pacing_data->do_pacing > 8 * rdev->dbr_def_do_pacing)
+		rdev->dbg_stats->dbq.do_pacing_slab_4++;
+	else if (pacing_data->do_pacing > 4 * rdev->dbr_def_do_pacing)
+		rdev->dbg_stats->dbq.do_pacing_slab_3++;
+	else if (pacing_data->do_pacing > 2 * rdev->dbr_def_do_pacing)
+		rdev->dbg_stats->dbq.do_pacing_slab_2++;
+	else if (pacing_data->do_pacing > rdev->dbr_def_do_pacing)
+		rdev->dbg_stats->dbq.do_pacing_slab_1++;
+}
+
+static bool bnxt_re_is_qp1_qp(struct bnxt_re_qp *qp)
+{
+	return qp->ib_qp.qp_type == IB_QPT_GSI;
+}
+
+static struct bnxt_re_qp *bnxt_re_get_qp1_qp(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_re_qp *qp;
+
+	mutex_lock(&rdev->qp_lock);
+	list_for_each_entry(qp, &rdev->qp_list, list) {
+		if (bnxt_re_is_qp1_qp(qp)) {
+			mutex_unlock(&rdev->qp_lock);
+			return qp;
+		}
+	}
+	mutex_unlock(&rdev->qp_lock);
+	return NULL;
+}
+
+/* Set the maximum number of each resource that the driver actually wants
+ * to allocate. This may be up to the maximum number the firmware has
+ * reserved for the function. The driver may choose to allocate fewer
+ * resources than the firmware maximum.
+ */
+static void bnxt_re_limit_pf_res(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_qplib_max_res dev_res = {};
+	struct bnxt_qplib_chip_ctx *cctx;
+	struct bnxt_qplib_dev_attr *attr;
+	struct bnxt_qplib_ctx *hctx;
+	int i;
+
+	attr = rdev->dev_attr;
+	hctx = rdev->qplib_res.hctx;
+	cctx = rdev->chip_ctx;
+
+	bnxt_qplib_max_res_supported(cctx, &rdev->qplib_res, &dev_res, false);
+	if (!_is_chip_gen_p5_p7(cctx)) {
+		hctx->qp_ctx.max = min_t(u32, dev_res.max_qp, attr->max_qp);
+		hctx->mrw_ctx.max = min_t(u32, dev_res.max_mr, attr->max_mr);
+		/* To accommodate 16k MRs and 16k AHs,
+		 * driver has to allocate 32k backing store memory
+		 */
+		hctx->mrw_ctx.max *= 2;
+		hctx->srq_ctx.max = min_t(u32, dev_res.max_srq, attr->max_srq);
+		hctx->cq_ctx.max = min_t(u32, dev_res.max_cq, attr->max_cq);
+		for (i = 0; i < MAX_TQM_ALLOC_REQ; i++)
+			hctx->tqm_ctx.qcount[i] = attr->tqm_alloc_reqs[i];
+	} else {
+		hctx->qp_ctx.max = attr->max_qp ? attr->max_qp : dev_res.max_qp;
+		hctx->mrw_ctx.max = attr->max_mr ? attr->max_mr : dev_res.max_mr;
+		hctx->srq_ctx.max = attr->max_srq ? attr->max_srq : dev_res.max_srq;
+		hctx->cq_ctx.max = attr->max_cq ? attr->max_cq : dev_res.max_cq;
+	}
+}
+
+static void bnxt_re_limit_vf_res(struct bnxt_re_dev *rdev,
+				 struct bnxt_qplib_vf_res *vf_res,
+				 u32 num_vf)
+{
+	struct bnxt_qplib_chip_ctx *cctx = rdev->chip_ctx;
+	struct bnxt_qplib_max_res dev_res = {};
+
+	bnxt_qplib_max_res_supported(cctx, &rdev->qplib_res, &dev_res, true);
+	vf_res->max_qp = dev_res.max_qp / num_vf;
+	vf_res->max_srq = dev_res.max_srq / num_vf;
+	vf_res->max_cq = dev_res.max_cq / num_vf;
+	/*
+	 * MR and AH shares the same backing store, the value specified
+	 * for max_mrw is split into half by the FW for MR and AH
+	 */
+	vf_res->max_mrw = dev_res.max_mr * 2 / num_vf;
+	vf_res->max_gid = BNXT_RE_MAX_GID_PER_VF;
+}
+
+static void bnxt_re_set_resource_limits(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_qplib_ctx *hctx;
+
+	hctx = rdev->qplib_res.hctx;
+	memset(&hctx->vf_res, 0, sizeof(struct bnxt_qplib_vf_res));
+	bnxt_re_limit_pf_res(rdev);
+
+	if (rdev->num_vfs)
+		bnxt_re_limit_vf_res(rdev, &hctx->vf_res, rdev->num_vfs);
+}
+
+static void bnxt_re_dettach_irq(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_qplib_rcfw *rcfw = NULL;
+	struct bnxt_qplib_nq *nq;
+	int indx;
+
+	rcfw = &rdev->rcfw;
+	for (indx = 0; indx < rdev->nqr.max_init; indx++) {
+		nq = &rdev->nqr.nq[indx];
+		mutex_lock(&nq->lock);
+		bnxt_qplib_nq_stop_irq(nq, false);
+		mutex_unlock(&nq->lock);
+	}
+
+	bnxt_qplib_rcfw_stop_irq(rcfw, false);
+}
+
+static void bnxt_re_detach_err_device(struct bnxt_re_dev *rdev)
+{
+	/* Free the MSIx vectors only so that L2 can proceed with MSIx disable */
+	bnxt_re_dettach_irq(rdev);
+
+	/* Set the state as detached to prevent sending any more commands */
+	set_bit(ERR_DEVICE_DETACHED, &rdev->rcfw.cmdq.flags);
+	set_bit(BNXT_RE_FLAG_ERR_DEVICE_DETACHED, &rdev->flags);
+	wake_up_all(&rdev->rcfw.cmdq.waitq);
+}
+
+#define MAX_DSCP_PRI_TUPLE	64
+
+struct bnxt_re_dcb_work {
+	struct work_struct work;
+	struct bnxt_re_dev *rdev;
+	struct hwrm_async_event_cmpl cmpl;
+};
+
+static void bnxt_re_init_dcb_wq(struct bnxt_re_dev *rdev)
+{
+	rdev->dcb_wq = create_singlethread_workqueue("bnxt_re_dcb_wq");
+}
+
+static void bnxt_re_uninit_dcb_wq(struct bnxt_re_dev *rdev)
+{
+	if (!rdev->dcb_wq)
+		return;
+	flush_workqueue(rdev->dcb_wq);
+	destroy_workqueue(rdev->dcb_wq);
+	rdev->dcb_wq = NULL;
+}
+
+static void bnxt_re_init_aer_wq(struct bnxt_re_dev *rdev)
+{
+	rdev->aer_wq = create_singlethread_workqueue("bnxt_re_aer_wq");
+}
+
+static void bnxt_re_uninit_aer_wq(struct bnxt_re_dev *rdev)
+{
+	if (!rdev->aer_wq)
+		return;
+	flush_workqueue(rdev->aer_wq);
+	destroy_workqueue(rdev->aer_wq);
+	rdev->aer_wq = NULL;
+}
+
+static int bnxt_re_update_qp1_tos_dscp(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_re_qp *qp;
+
+	if (!_is_chip_gen_p5_p7(rdev->chip_ctx))
+		return 0;
+
+	qp = bnxt_re_get_qp1_qp(rdev);
+	if (!qp)
+		return 0;
+
+	qp->qplib_qp.modify_flags = CMDQ_MODIFY_QP_MODIFY_MASK_TOS_DSCP;
+	qp->qplib_qp.tos_dscp = rdev->cc_param.qp1_tos_dscp;
+
+	return bnxt_qplib_modify_qp(&rdev->qplib_res, &qp->qplib_qp);
+}
+
+static void bnxt_re_reconfigure_dscp(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_qplib_cc_param *cc_param;
+	struct bnxt_re_tc_rec *tc_rec;
+	bool update_cc = false;
+	u8 dscp_user;
+	int rc;
+
+	cc_param = &rdev->cc_param;
+	tc_rec = &rdev->tc_rec[0];
+
+	if (!(cc_param->roce_dscp_user || cc_param->cnp_dscp_user))
+		return;
+
+	if (cc_param->cnp_dscp_user) {
+		dscp_user = (cc_param->cnp_dscp_user & 0x3f);
+		if ((tc_rec->cnp_dscp_bv & (1ul << dscp_user)) &&
+		    (cc_param->alt_tos_dscp != dscp_user)) {
+			cc_param->alt_tos_dscp = dscp_user;
+			cc_param->mask |= CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_ALT_TOS_DSCP;
+			update_cc = true;
+		}
+	}
+
+	if (cc_param->roce_dscp_user) {
+		dscp_user = (cc_param->roce_dscp_user & 0x3f);
+		if ((tc_rec->roce_dscp_bv & (1ul << dscp_user)) &&
+		    (cc_param->tos_dscp != dscp_user)) {
+			cc_param->tos_dscp = dscp_user;
+			cc_param->mask |= CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_TOS_DSCP;
+			update_cc = true;
+		}
+	}
+
+	if (update_cc) {
+		rc = bnxt_qplib_modify_cc(&rdev->qplib_res, cc_param);
+		if (rc)
+			dev_err(rdev_to_dev(rdev), "Failed to apply cc settings\n");
+	}
+}
+
+static void bnxt_re_dcb_wq_task(struct work_struct *work)
+{
+	struct bnxt_qplib_cc_param *cc_param;
+	struct bnxt_re_tc_rec *tc_rec;
+	struct bnxt_re_dev *rdev;
+	struct bnxt_re_dcb_work *dcb_work =
+			container_of(work, struct bnxt_re_dcb_work, work);
+	int rc;
+
+	rdev = dcb_work->rdev;
+	if (!rdev)
+		goto exit;
+
+	mutex_lock(&rdev->cc_lock);
+
+	cc_param = &rdev->cc_param;
+	rc = bnxt_qplib_query_cc_param(&rdev->qplib_res, cc_param);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev), "Failed to query ccparam rc:%d", rc);
+		goto fail;
+	}
+	tc_rec = &rdev->tc_rec[0];
+	/*
+	 * Upon the receival of DCB Async event:
+	 *   If roce_dscp or cnp_dscp or both (which user configured using configfs)
+	 *   is in the list, re-program the value using modify_roce_cc command
+	 */
+	bnxt_re_reconfigure_dscp(rdev);
+
+	cc_param->roce_pri = tc_rec->roce_prio;
+	if (cc_param->qp1_tos_dscp != cc_param->tos_dscp) {
+		cc_param->qp1_tos_dscp = cc_param->tos_dscp;
+		rc = bnxt_re_update_qp1_tos_dscp(rdev);
+		if (rc) {
+			dev_err(rdev_to_dev(rdev), "%s:Failed to modify QP1 rc:%d",
+				__func__, rc);
+			goto fail;
+		}
+	}
+
+fail:
+	mutex_unlock(&rdev->cc_lock);
+exit:
+	kfree(dcb_work);
+}
+
+static int bnxt_re_hwrm_dbr_pacing_broadcast_event(struct bnxt_re_dev *rdev)
+{
+	struct hwrm_func_dbr_pacing_broadcast_event_output resp = {0};
+	struct hwrm_func_dbr_pacing_broadcast_event_input req = {0};
+	struct bnxt_en_dev *en_dev = rdev->en_dev;
+	struct bnxt_fw_msg fw_msg;
+	int rc;
+
+	memset(&fw_msg, 0, sizeof(fw_msg));
+	bnxt_re_init_hwrm_hdr(rdev, (void *)&req,
+			      HWRM_FUNC_DBR_PACING_BROADCAST_EVENT, -1, -1);
+	bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
+			    sizeof(resp), BNXT_RE_HWRM_CMD_TIMEOUT(rdev));
+	rc = en_dev->en_ops->bnxt_send_fw_msg(en_dev, BNXT_ROCE_ULP, &fw_msg);
+	if (rc) {
+		dev_dbg(rdev_to_dev(rdev),
+			"Failed to send dbr pacing broadcast event rc:%d", rc);
+		return rc;
+	}
+	return 0;
+}
+
+static int bnxt_re_hwrm_dbr_pacing_nqlist_query(struct bnxt_re_dev *rdev)
+{
+	struct hwrm_func_dbr_pacing_nqlist_query_output resp = {0};
+	struct hwrm_func_dbr_pacing_nqlist_query_input req = {0};
+	struct bnxt_dbq_nq_list *nq_list = &rdev->nq_list;
+	struct bnxt_en_dev *en_dev = rdev->en_dev;
+	bool primary_found = false;
+	struct bnxt_fw_msg fw_msg;
+	struct bnxt_qplib_nq *nq;
+	int rc, i, j = 1;
+	u16 *nql_ptr;
+
+	nq = &rdev->nqr.nq[0];
+
+	memset(&fw_msg, 0, sizeof(fw_msg));
+	bnxt_re_init_hwrm_hdr(rdev, (void *)&req,
+			      HWRM_FUNC_DBR_PACING_NQLIST_QUERY, -1, -1);
+	bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
+			    sizeof(resp), BNXT_RE_HWRM_CMD_TIMEOUT(rdev));
+	rc = en_dev->en_ops->bnxt_send_fw_msg(en_dev, BNXT_ROCE_ULP, &fw_msg);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev), "Failed to send dbr pacing nq list query rc:%d", rc);
+		return rc;
+	}
+	nq_list->num_nql_entries = le32_to_cpu(resp.num_nqs);
+	nql_ptr = &resp.nq_ring_id0;
+	/* populate the nq_list of the primary function with list received
+	 * from FW. Fill the NQ IDs of secondary functions from index 1 to
+	 * num_nql_entries - 1. Fill the  nq_list->nq_id[0] with the
+	 * nq_id of the primary pf
+	 */
+	for (i = 0; i < nq_list->num_nql_entries; i++) {
+		u16 nq_id = *nql_ptr;
+
+		dev_dbg(rdev_to_dev(rdev),
+			"nq_list->nq_id[%d] = %d\n", i, nq_id);
+		if (nq_id != nq->ring_id) {
+			nq_list->nq_id[j] = nq_id;
+			j++;
+		} else {
+			primary_found = true;
+			nq_list->nq_id[0] = nq->ring_id;
+		}
+		nql_ptr++;
+	}
+	if (primary_found)
+		bnxt_qplib_dbr_pacing_set_primary_pf(rdev->chip_ctx, 1);
+
+	return 0;
+}
+
+static void __wait_for_fifo_occupancy_below_th(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_qplib_db_pacing_data *pacing_data = rdev->qplib_res.pacing_data;
+	u32 read_val, fifo_occup;
+	bool first_read = true;
+
+	/* loop shouldn't run infintely as the occupancy usually goes
+	 * below pacing algo threshold as soon as pacing kicks in.
+	 */
+	while (1) {
+		read_val = readl_fbsd(rdev->en_dev->softc, rdev->dbr_db_fifo_reg_off, 0);
+		fifo_occup = pacing_data->fifo_max_depth -
+			     ((read_val & pacing_data->fifo_room_mask) >>
+			      pacing_data->fifo_room_shift);
+		/* Fifo occupancy cannot be greater the MAX FIFO depth */
+		if (fifo_occup > pacing_data->fifo_max_depth)
+			break;
+
+		if (first_read) {
+			bnxt_re_update_fifo_occup_slabs(rdev, fifo_occup);
+			first_read = false;
+		}
+		if (fifo_occup < pacing_data->pacing_th)
+			break;
+	}
+}
+
+static void bnxt_re_set_default_pacing_data(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_qplib_db_pacing_data *pacing_data = rdev->qplib_res.pacing_data;
+
+	pacing_data->do_pacing = rdev->dbr_def_do_pacing;
+	pacing_data->pacing_th = rdev->pacing_algo_th;
+	pacing_data->alarm_th =
+		pacing_data->pacing_th * BNXT_RE_PACING_ALARM_TH_MULTIPLE(rdev->chip_ctx);
+}
+
+#define CAG_RING_MASK 0x7FF
+#define CAG_RING_SHIFT 17
+#define WATERMARK_MASK 0xFFF
+#define WATERMARK_SHIFT	0
+
+static bool bnxt_re_check_if_dbq_intr_triggered(struct bnxt_re_dev *rdev)
+{
+	u32 read_val;
+	int j;
+
+	for (j = 0; j < 10; j++) {
+		read_val = readl_fbsd(rdev->en_dev->softc, rdev->dbr_aeq_arm_reg_off, 0);
+		dev_dbg(rdev_to_dev(rdev), "AEQ ARM status = 0x%x\n",
+			read_val);
+		if (!read_val)
+			return true;
+	}
+	return false;
+}
+
+int bnxt_re_set_dbq_throttling_reg(struct bnxt_re_dev *rdev, u16 nq_id, u32 throttle)
+{
+	u32 cag_ring_water_mark = 0, read_val;
+	u32 throttle_val;
+
+	/* Convert throttle percentage to value */
+	throttle_val = (rdev->qplib_res.pacing_data->fifo_max_depth * throttle) / 100;
+
+	if (bnxt_qplib_dbr_pacing_ext_en(rdev->chip_ctx)) {
+		cag_ring_water_mark = (nq_id & CAG_RING_MASK) << CAG_RING_SHIFT |
+				      (throttle_val & WATERMARK_MASK);
+		writel_fbsd(rdev->en_dev->softc,  rdev->dbr_throttling_reg_off, 0, cag_ring_water_mark);
+		read_val = readl_fbsd(rdev->en_dev->softc , rdev->dbr_throttling_reg_off, 0);
+		dev_dbg(rdev_to_dev(rdev),
+			"%s: dbr_throttling_reg_off read_val = 0x%x\n",
+			__func__, read_val);
+		if (read_val != cag_ring_water_mark) {
+			dev_dbg(rdev_to_dev(rdev),
+				"nq_id = %d write_val=0x%x read_val=0x%x\n",
+				nq_id, cag_ring_water_mark, read_val);
+			return 1;
+		}
+	}
+	writel_fbsd(rdev->en_dev->softc,  rdev->dbr_aeq_arm_reg_off, 0, 1);
+	return 0;
+}
+
+static void bnxt_re_set_dbq_throttling_for_non_primary(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_dbq_nq_list *nq_list;
+	struct bnxt_qplib_nq *nq;
+	int i;
+
+	nq_list = &rdev->nq_list;
+	/* Run a loop for other Active functions if this is primary function */
+	if (bnxt_qplib_dbr_pacing_is_primary_pf(rdev->chip_ctx)) {
+		dev_dbg(rdev_to_dev(rdev), "%s:  nq_list->num_nql_entries= %d\n",
+			__func__, nq_list->num_nql_entries);
+		nq = &rdev->nqr.nq[0];
+		for (i = nq_list->num_nql_entries - 1; i > 0; i--) {
+			u16 nq_id = nq_list->nq_id[i];
+			if (nq)
+				dev_dbg(rdev_to_dev(rdev),
+					"%s: nq_id = %d cur_fn_ring_id = %d\n",
+					__func__, nq_id, nq->ring_id);
+			if (bnxt_re_set_dbq_throttling_reg
+					(rdev, nq_id, 0))
+				break;
+			bnxt_re_check_if_dbq_intr_triggered(rdev);
+		}
+	}
+}
+
+static void bnxt_re_handle_dbr_nq_pacing_notification(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_qplib_nq *nq;
+	int rc = 0;
+
+	nq = &rdev->nqr.nq[0];
+
+	/* Query the NQ list*/
+	rc = bnxt_re_hwrm_dbr_pacing_nqlist_query(rdev);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev),
+			"Failed to Query NQ list rc= %d", rc);
+		return;
+	}
+	/*Configure GRC access for Throttling and aeq_arm register */
+	writel_fbsd(rdev->en_dev->softc,  BNXT_GRCPF_REG_WINDOW_BASE_OUT + 28, 0,
+		    rdev->chip_ctx->dbr_aeq_arm_reg & BNXT_GRC_BASE_MASK);
+
+	rdev->dbr_throttling_reg_off =
+		(rdev->chip_ctx->dbr_throttling_reg &
+		 BNXT_GRC_OFFSET_MASK) + 0x8000;
+	rdev->dbr_aeq_arm_reg_off =
+		(rdev->chip_ctx->dbr_aeq_arm_reg &
+		 BNXT_GRC_OFFSET_MASK) + 0x8000;
+
+	bnxt_re_set_dbq_throttling_reg(rdev, nq->ring_id, rdev->dbq_watermark);
+}
+
+static void bnxt_re_dbq_wq_task(struct work_struct *work)
+{
+	struct bnxt_re_dbq_work *dbq_work =
+			container_of(work, struct bnxt_re_dbq_work, work);
+	struct bnxt_re_dev *rdev;
+
+	rdev = dbq_work->rdev;
+
+	if (!rdev)
+		goto exit;
+	switch (dbq_work->event) {
+	case BNXT_RE_DBQ_EVENT_SCHED:
+		dev_dbg(rdev_to_dev(rdev), "%s: Handle DBQ Pacing event\n",
+			__func__);
+		if (!bnxt_qplib_dbr_pacing_ext_en(rdev->chip_ctx))
+			bnxt_re_hwrm_dbr_pacing_broadcast_event(rdev);
+		else
+			bnxt_re_pacing_alert(rdev);
+		break;
+	case BNXT_RE_DBR_PACING_EVENT:
+		dev_dbg(rdev_to_dev(rdev), "%s: Sched interrupt/pacing worker\n",
+			__func__);
+		if (_is_chip_p7(rdev->chip_ctx))
+			bnxt_re_pacing_alert(rdev);
+		else if (!rdev->chip_ctx->modes.dbr_pacing_v0)
+			bnxt_re_hwrm_dbr_pacing_qcfg(rdev);
+		break;
+	case BNXT_RE_DBR_NQ_PACING_NOTIFICATION:
+		bnxt_re_handle_dbr_nq_pacing_notification(rdev);
+		/* Issue a broadcast event to notify other functions
+		 * that primary changed
+		 */
+		bnxt_re_hwrm_dbr_pacing_broadcast_event(rdev);
+		break;
+	}
+exit:
+	kfree(dbq_work);
+}
+
+static void bnxt_re_async_notifier(void *handle, struct hwrm_async_event_cmpl *cmpl)
+{
+	struct bnxt_re_en_dev_info *en_info = auxiliary_get_drvdata(handle);
+	struct bnxt_re_dcb_work *dcb_work;
+	struct bnxt_re_dbq_work *dbq_work;
+	struct bnxt_re_dev *rdev;
+	u16 event_id;
+	u32 data1;
+	u32 data2 = 0;
+
+	if (!cmpl) {
+		pr_err("Async event, bad completion\n");
+		return;
+	}
+
+	if (!en_info || !en_info->en_dev) {
+		pr_err("Async event, bad en_info or en_dev\n");
+		return;
+	}
+	rdev = en_info->rdev;
+
+	event_id = le16_to_cpu(cmpl->event_id);
+	data1 = le32_to_cpu(cmpl->event_data1);
+	data2 = le32_to_cpu(cmpl->event_data2);
+
+	if (!rdev || !rdev_to_dev(rdev)) {
+		dev_dbg(NULL, "Async event, bad rdev or netdev\n");
+		return;
+	}
+
+	if (test_bit(BNXT_RE_FLAG_ERR_DEVICE_DETACHED, &rdev->flags) ||
+	    !test_bit(BNXT_RE_FLAG_NETDEV_REGISTERED, &rdev->flags)) {
+		dev_dbg(NULL, "Async event, device already detached\n");
+		return;
+	}
+	if (data2 >= 0)
+		dev_dbg(rdev_to_dev(rdev), "Async event_id = %d data1 = %d data2 = %d",
+			event_id, data1, data2);
+
+	switch (event_id) {
+	case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_DCB_CONFIG_CHANGE:
+		/* Not handling the event in older FWs */
+		if (!is_qport_service_type_supported(rdev))
+			break;
+		if (!rdev->dcb_wq)
+			break;
+		dcb_work = kzalloc(sizeof(*dcb_work), GFP_ATOMIC);
+		if (!dcb_work)
+			break;
+
+		dcb_work->rdev = rdev;
+		memcpy(&dcb_work->cmpl, cmpl, sizeof(*cmpl));
+		INIT_WORK(&dcb_work->work, bnxt_re_dcb_wq_task);
+		queue_work(rdev->dcb_wq, &dcb_work->work);
+		break;
+	case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_RESET_NOTIFY:
+		if (EVENT_DATA1_RESET_NOTIFY_FATAL(data1)) {
+			/* Set rcfw flag to control commands send to Bono */
+			set_bit(ERR_DEVICE_DETACHED, &rdev->rcfw.cmdq.flags);
+			/* Set bnxt_re flag to control commands send via L2 driver */
+			set_bit(BNXT_RE_FLAG_ERR_DEVICE_DETACHED, &rdev->flags);
+			wake_up_all(&rdev->rcfw.cmdq.waitq);
+		}
+		break;
+	case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_DOORBELL_PACING_THRESHOLD:
+		if (!rdev->dbr_pacing)
+			break;
+		dbq_work = kzalloc(sizeof(*dbq_work), GFP_ATOMIC);
+		if (!dbq_work)
+			goto unlock;
+		dbq_work->rdev = rdev;
+		dbq_work->event = BNXT_RE_DBR_PACING_EVENT;
+		INIT_WORK(&dbq_work->work, bnxt_re_dbq_wq_task);
+		queue_work(rdev->dbq_wq, &dbq_work->work);
+		rdev->dbr_sw_stats->dbq_int_recv++;
+		break;
+	case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_DOORBELL_PACING_NQ_UPDATE:
+		if (!rdev->dbr_pacing)
+			break;
+
+		dbq_work = kzalloc(sizeof(*dbq_work), GFP_ATOMIC);
+		if (!dbq_work)
+			goto unlock;
+		dbq_work->rdev = rdev;
+		dbq_work->event = BNXT_RE_DBR_NQ_PACING_NOTIFICATION;
+		INIT_WORK(&dbq_work->work, bnxt_re_dbq_wq_task);
+		queue_work(rdev->dbq_wq, &dbq_work->work);
+		break;
+
+	default:
+		break;
+	}
+unlock:
+	return;
+}
+
+static void bnxt_re_db_fifo_check(struct work_struct *work)
+{
+	struct bnxt_re_dev *rdev = container_of(work, struct bnxt_re_dev,
+						dbq_fifo_check_work);
+	struct bnxt_qplib_db_pacing_data *pacing_data;
+	u32 pacing_save;
+
+	if (!mutex_trylock(&rdev->dbq_lock))
+		return;
+	pacing_data = rdev->qplib_res.pacing_data;
+	pacing_save = rdev->do_pacing_save;
+	__wait_for_fifo_occupancy_below_th(rdev);
+	cancel_delayed_work_sync(&rdev->dbq_pacing_work);
+	if (rdev->dbr_recovery_on)
+		goto recovery_on;
+	if (pacing_save > rdev->dbr_def_do_pacing) {
+		/* Double the do_pacing value during the congestion */
+		pacing_save = pacing_save << 1;
+	} else {
+		/*
+		 * when a new congestion is detected increase the do_pacing
+		 * by 8 times. And also increase the pacing_th by 4 times. The
+		 * reason to increase pacing_th is to give more space for the
+		 * queue to oscillate down without getting empty, but also more
+		 * room for the queue to increase without causing another alarm.
+		 */
+		pacing_save = pacing_save << 3;
+		pacing_data->pacing_th = rdev->pacing_algo_th * 4;
+	}
+
+	if (pacing_save > BNXT_RE_MAX_DBR_DO_PACING)
+		pacing_save = BNXT_RE_MAX_DBR_DO_PACING;
+
+	pacing_data->do_pacing = pacing_save;
+	rdev->do_pacing_save = pacing_data->do_pacing;
+	pacing_data->alarm_th =
+		pacing_data->pacing_th * BNXT_RE_PACING_ALARM_TH_MULTIPLE(rdev->chip_ctx);
+recovery_on:
+	schedule_delayed_work(&rdev->dbq_pacing_work,
+			      msecs_to_jiffies(rdev->dbq_pacing_time));
+	rdev->dbr_sw_stats->dbq_pacing_alerts++;
+	mutex_unlock(&rdev->dbq_lock);
+}
+
+static void bnxt_re_pacing_timer_exp(struct work_struct *work)
+{
+	struct bnxt_re_dev *rdev = container_of(work, struct bnxt_re_dev,
+						dbq_pacing_work.work);
+	struct bnxt_qplib_db_pacing_data *pacing_data;
+	u32 read_val, fifo_occup;
+	struct bnxt_qplib_nq *nq;
+
+	if (!mutex_trylock(&rdev->dbq_lock))
+		return;
+
+	pacing_data = rdev->qplib_res.pacing_data;
+	read_val = readl_fbsd(rdev->en_dev->softc , rdev->dbr_db_fifo_reg_off, 0);
+	fifo_occup = pacing_data->fifo_max_depth -
+		     ((read_val & pacing_data->fifo_room_mask) >>
+		      pacing_data->fifo_room_shift);
+
+	if (fifo_occup > pacing_data->pacing_th)
+		goto restart_timer;
+
+	/*
+	 * Instead of immediately going back to the default do_pacing
+	 * reduce it by 1/8 times and restart the timer.
+	 */
+	pacing_data->do_pacing = pacing_data->do_pacing - (pacing_data->do_pacing >> 3);
+	pacing_data->do_pacing = max_t(u32, rdev->dbr_def_do_pacing, pacing_data->do_pacing);
+	/*
+	 * If the fifo_occup is less than the interrupt enable threshold
+	 * enable the interrupt on the primary PF.
+	 */
+	if (rdev->dbq_int_disable && fifo_occup < rdev->pacing_en_int_th) {
+		if (bnxt_qplib_dbr_pacing_is_primary_pf(rdev->chip_ctx)) {
+			if (!rdev->chip_ctx->modes.dbr_pacing_v0) {
+				nq = &rdev->nqr.nq[0];
+				bnxt_re_set_dbq_throttling_reg(rdev, nq->ring_id,
+							       rdev->dbq_watermark);
+				rdev->dbr_sw_stats->dbq_int_en++;
+				rdev->dbq_int_disable = false;
+			}
+		}
+	}
+	if (pacing_data->do_pacing <= rdev->dbr_def_do_pacing) {
+		bnxt_re_set_default_pacing_data(rdev);
+		rdev->dbr_sw_stats->dbq_pacing_complete++;
+		goto dbq_unlock;
+	}
+restart_timer:
+	schedule_delayed_work(&rdev->dbq_pacing_work,
+			      msecs_to_jiffies(rdev->dbq_pacing_time));
+	bnxt_re_update_do_pacing_slabs(rdev);
+	rdev->dbr_sw_stats->dbq_pacing_resched++;
+dbq_unlock:
+	rdev->do_pacing_save = pacing_data->do_pacing;
+	mutex_unlock(&rdev->dbq_lock);
+}
+
+void bnxt_re_pacing_alert(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_qplib_db_pacing_data *pacing_data;
+
+	if (!rdev->dbr_pacing)
+		return;
+	mutex_lock(&rdev->dbq_lock);
+	pacing_data = rdev->qplib_res.pacing_data;
+
+	/*
+	 * Increase the alarm_th to max so that other user lib instances do not
+	 * keep alerting the driver.
+	 */
+	pacing_data->alarm_th = pacing_data->fifo_max_depth;
+	pacing_data->do_pacing = BNXT_RE_MAX_DBR_DO_PACING;
+	cancel_work_sync(&rdev->dbq_fifo_check_work);
+	schedule_work(&rdev->dbq_fifo_check_work);
+	mutex_unlock(&rdev->dbq_lock);
+}
+
+void bnxt_re_schedule_dbq_event(struct bnxt_qplib_res *res)
+{
+	struct bnxt_re_dbq_work *dbq_work;
+	struct bnxt_re_dev *rdev;
+
+	rdev = container_of(res, struct bnxt_re_dev, qplib_res);
+
+	atomic_set(&rdev->dbq_intr_running, 1);
+
+	if (test_bit(BNXT_RE_FLAG_ERR_DEVICE_DETACHED, &rdev->flags))
+		goto exit;
+	/* Run the loop to send dbq event to other functions
+	 * for newer FW
+	 */
+	if (bnxt_qplib_dbr_pacing_ext_en(rdev->chip_ctx) &&
+	    !rdev->chip_ctx->modes.dbr_pacing_v0)
+		bnxt_re_set_dbq_throttling_for_non_primary(rdev);
+
+	dbq_work = kzalloc(sizeof(*dbq_work), GFP_ATOMIC);
+	if (!dbq_work)
+		goto exit;
+	dbq_work->rdev = rdev;
+	dbq_work->event = BNXT_RE_DBQ_EVENT_SCHED;
+	INIT_WORK(&dbq_work->work, bnxt_re_dbq_wq_task);
+	queue_work(rdev->dbq_wq, &dbq_work->work);
+	rdev->dbr_sw_stats->dbq_int_recv++;
+	rdev->dbq_int_disable = true;
+exit:
+	atomic_set(&rdev->dbq_intr_running, 0);
+}
+
+static void bnxt_re_free_msix(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_en_dev *en_dev = rdev->en_dev;
+	int rc;
+
+	rc = en_dev->en_ops->bnxt_free_msix(rdev->en_dev, BNXT_ROCE_ULP);
+	if (rc)
+		dev_err(rdev_to_dev(rdev), "netdev %p free_msix failed! rc = 0x%x",
+			rdev->netdev, rc);
+}
+
+static int bnxt_re_request_msix(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_en_dev *en_dev = rdev->en_dev;
+	int rc = 0, num_msix_want, num_msix_got;
+	struct bnxt_msix_entry *entry;
+
+	/*
+	 * Request MSIx based on the function type. This is
+	 * a temporory solution to enable max VFs when NPAR is
+	 * enabled.
+	 * TODO - change the scheme with an adapter specific check
+	 * as the latest adapters can support more NQs. For now
+	 * this change satisfy all adapter versions.
+	 */
+
+	if (rdev->is_virtfn)
+		num_msix_want = BNXT_RE_MAX_MSIX_VF;
+	else if (BNXT_EN_NPAR(en_dev))
+		num_msix_want = BNXT_RE_MAX_MSIX_NPAR_PF;
+	else if (_is_chip_gen_p5_p7(rdev->chip_ctx))
+		num_msix_want = rdev->num_msix_requested ?: BNXT_RE_MAX_MSIX_GEN_P5_PF;
+	else
+		num_msix_want = BNXT_RE_MAX_MSIX_PF;
+
+	/*
+	 * Since MSIX vectors are used for both NQs and CREQ, we should try to
+	 * allocate num_online_cpus + 1 by taking into account the CREQ. This
+	 * leaves the number of MSIX vectors for NQs match the number of CPUs
+	 * and allows the system to be fully utilized
+	 */
+	num_msix_want = min_t(u32, num_msix_want, num_online_cpus() + 1);
+	num_msix_want = min_t(u32, num_msix_want, BNXT_RE_MAX_MSIX);
+	num_msix_want = max_t(u32, num_msix_want, BNXT_RE_MIN_MSIX);
+
+	entry = rdev->nqr.msix_entries;
+
+	num_msix_got = en_dev->en_ops->bnxt_request_msix(en_dev, BNXT_ROCE_ULP,
+							 entry, num_msix_want);
+	if (num_msix_got < BNXT_RE_MIN_MSIX) {
+		rc = -EINVAL;
+		goto done;
+	}
+	if (num_msix_got != num_msix_want)
+		dev_warn(rdev_to_dev(rdev),
+			 "bnxt_request_msix: wanted %d vectors, got %d\n",
+			 num_msix_want, num_msix_got);
+
+	rdev->nqr.num_msix = num_msix_got;
+	return 0;
+done:
+	if (num_msix_got)
+		bnxt_re_free_msix(rdev);
+	return rc;
+}
+
+static int  __wait_for_ib_unregister(struct bnxt_re_dev *rdev,
+				     struct bnxt_re_en_dev_info *en_info)
+{
+	u64 timeout = 0;
+	u32 cur_prod = 0, cur_cons = 0;
+	int retry = 0, rc = 0, ret = 0;
+
+	cur_prod = rdev->rcfw.cmdq.hwq.prod;
+	cur_cons = rdev->rcfw.cmdq.hwq.cons;
+	timeout = msecs_to_jiffies(BNXT_RE_RECOVERY_IB_UNINIT_WAIT_TIME_MS);
+	retry = BNXT_RE_RECOVERY_IB_UNINIT_WAIT_RETRY;
+	/* During module exit, increase timeout ten-fold to 100 mins to wait
+	 * as long as possible for ib_unregister() to complete
+	 */
+	if (rdev->mod_exit)
+		retry *= 10;
+	do {
+		/*
+		 * Since the caller of this function invokes with bnxt_re_mutex held,
+		 * release it to avoid holding a lock while in wait / sleep mode.
+		 */
+		mutex_unlock(&bnxt_re_mutex);
+		rc = wait_event_timeout(en_info->waitq,
+					en_info->ib_uninit_done,
+					timeout);
+		mutex_lock(&bnxt_re_mutex);
+
+		if (!bnxt_re_is_rdev_valid(rdev))
+			break;
+
+		if (rc)
+			break;
+
+		if (!RCFW_NO_FW_ACCESS(&rdev->rcfw)) {
+			/* No need to check for cmdq stall during module exit,
+			 * wait for ib unregister to complete
+			 */
+			if (!rdev->mod_exit)
+				ret = __check_cmdq_stall(&rdev->rcfw, &cur_prod, &cur_cons);
+			if (ret || en_info->ib_uninit_done)
+				break;
+		}
+	} while (retry--);
+
+	return rc;
+}
+
+static int bnxt_re_handle_start(struct auxiliary_device *adev)
+{
+	struct bnxt_re_en_dev_info *en_info = auxiliary_get_drvdata(adev);
+	struct bnxt_re_dev *rdev = NULL;
+	struct ifnet *real_dev;
+	struct bnxt_en_dev *en_dev;
+	struct ifnet *netdev;
+	int rc = 0;
+
+	if (!en_info || !en_info->en_dev) {
+		pr_err("Start, bad en_info or en_dev\n");
+		return -EINVAL;
+	}
+	netdev = en_info->en_dev->net;
+	if (en_info->rdev) {
+		dev_info(rdev_to_dev(en_info->rdev),
+			 "%s: Device is already added adev %p rdev: %p\n",
+			 __func__, adev, en_info->rdev);
+		return 0;
+	}
+
+	en_dev = en_info->en_dev;
+	real_dev = rdma_vlan_dev_real_dev(netdev);
+	if (!real_dev)
+		real_dev = netdev;
+	rc = bnxt_re_add_device(&rdev, real_dev,
+				en_info->gsi_mode,
+				BNXT_RE_POST_RECOVERY_INIT,
+				en_info->wqe_mode,
+				en_info->num_msix_requested, adev);
+	if (rc) {
+		/* Add device failed. Unregister the device.
+		 * This has to be done explicitly as
+		 * bnxt_re_stop would not have unregistered
+		 */
+		rtnl_lock();
+		en_dev->en_ops->bnxt_unregister_device(en_dev, BNXT_ROCE_ULP);
+		rtnl_unlock();
+		mutex_lock(&bnxt_re_dev_lock);
+		gadd_dev_inprogress--;
+		mutex_unlock(&bnxt_re_dev_lock);
+		return rc;
+	}
+	rdev->adev = adev;
+	rtnl_lock();
+	bnxt_re_get_link_speed(rdev);
+	rtnl_unlock();
+	rc = bnxt_re_ib_init(rdev);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev), "Failed ib_init\n");
+		return rc;
+	}
+	bnxt_re_ib_init_2(rdev);
+
+	return rc;
+}
+
+static void bnxt_re_stop(void *handle)
+{
+	struct bnxt_re_en_dev_info *en_info = auxiliary_get_drvdata(handle);
+	struct ifnet *netdev;
+	struct bnxt_re_dev *rdev;
+	struct bnxt_en_dev *en_dev;
+	int rc = 0;
+
+	rtnl_unlock();
+	mutex_lock(&bnxt_re_mutex);
+	if (!en_info || !en_info->en_dev) {
+		pr_err("Stop, bad en_info or en_dev\n");
+		goto exit;
+	}
+	netdev = en_info->en_dev->net;
+	rdev = en_info->rdev;
+	if (!rdev)
+		goto exit;
+
+	if (!bnxt_re_is_rdev_valid(rdev))
+		goto exit;
+
+	/*
+	 * Check if fw has undergone reset or is in a fatal condition.
+	 * If so, set flags so that no further commands are sent down to FW
+	 */
+	en_dev = rdev->en_dev;
+	if (en_dev->en_state & BNXT_STATE_FW_FATAL_COND ||
+	    en_dev->en_state & BNXT_STATE_FW_RESET_DET) {
+		/* Set rcfw flag to control commands send to Bono */
+		set_bit(ERR_DEVICE_DETACHED, &rdev->rcfw.cmdq.flags);
+		/* Set bnxt_re flag to control commands send via L2 driver */
+		set_bit(BNXT_RE_FLAG_ERR_DEVICE_DETACHED, &rdev->flags);
+		wake_up_all(&rdev->rcfw.cmdq.waitq);
+	}
+
+	if (test_bit(BNXT_RE_FLAG_STOP_IN_PROGRESS, &rdev->flags))
+		goto exit;
+	set_bit(BNXT_RE_FLAG_STOP_IN_PROGRESS, &rdev->flags);
+
+	en_info->wqe_mode = rdev->chip_ctx->modes.wqe_mode;
+	en_info->gsi_mode = rdev->gsi_ctx.gsi_qp_mode;
+	en_info->num_msix_requested = rdev->num_msix_requested;
+	en_info->ib_uninit_done = false;
+
+	if (rdev->dbr_pacing)
+		bnxt_re_set_pacing_dev_state(rdev);
+
+	dev_info(rdev_to_dev(rdev), "%s: L2 driver notified to stop."
+		 "Attempting to stop and Dispatching event "
+		 "to inform the stack\n", __func__);
+	init_waitqueue_head(&en_info->waitq);
+	/* Schedule a work item to handle IB UNINIT for recovery */
+	bnxt_re_schedule_work(rdev, NETDEV_UNREGISTER,
+			      NULL, netdev, rdev->adev);
+	rc = __wait_for_ib_unregister(rdev, en_info);
+	if (!bnxt_re_is_rdev_valid(rdev))
+		goto exit;
+	if (!rc) {
+		dev_info(rdev_to_dev(rdev), "%s: Attempt to stop failed\n",
+			 __func__);
+		bnxt_re_detach_err_device(rdev);
+		goto exit;
+	}
+	bnxt_re_remove_device(rdev, BNXT_RE_PRE_RECOVERY_REMOVE, rdev->adev);
+exit:
+	mutex_unlock(&bnxt_re_mutex);
+	/* Take rtnl_lock before return, bnxt_re_stop is called with rtnl_lock */
+	rtnl_lock();
+
+	return;
+}
+
+static void bnxt_re_start(void *handle)
+{
+	rtnl_unlock();
+	mutex_lock(&bnxt_re_mutex);
+	if (bnxt_re_handle_start((struct auxiliary_device *)handle))
+		pr_err("Failed to start RoCE device");
+	mutex_unlock(&bnxt_re_mutex);
+	/* Take rtnl_lock before return, bnxt_re_start is called with rtnl_lock */
+	rtnl_lock();
+	return;
+}
+
+static void bnxt_re_shutdown(void *p)
+{
+	struct bnxt_re_en_dev_info *en_info = auxiliary_get_drvdata(p);
+	struct bnxt_re_dev *rdev;
+
+	if (!en_info) {
+		pr_err("Shutdown, bad en_info\n");
+		return;
+	}
+	rtnl_unlock();
+	mutex_lock(&bnxt_re_mutex);
+	rdev = en_info->rdev;
+	if (!rdev || !bnxt_re_is_rdev_valid(rdev))
+		goto exit;
+
+	/* rtnl_lock held by L2 before coming here */
+	bnxt_re_stopqps_and_ib_uninit(rdev);
+	bnxt_re_remove_device(rdev, BNXT_RE_COMPLETE_REMOVE, rdev->adev);
+exit:
+	mutex_unlock(&bnxt_re_mutex);
+	rtnl_lock();
+	return;
+}
+
+static void bnxt_re_stop_irq(void *handle)
+{
+	struct bnxt_re_en_dev_info *en_info = auxiliary_get_drvdata(handle);
+	struct bnxt_qplib_rcfw *rcfw = NULL;
+	struct bnxt_re_dev *rdev;
+	struct bnxt_qplib_nq *nq;
+	int indx;
+
+	if (!en_info) {
+		pr_err("Stop irq, bad en_info\n");
+		return;
+	}
+	rdev = en_info->rdev;
+
+	if (!rdev)
+		return;
+
+	rcfw = &rdev->rcfw;
+	for (indx = 0; indx < rdev->nqr.max_init; indx++) {
+		nq = &rdev->nqr.nq[indx];
+		mutex_lock(&nq->lock);
+		bnxt_qplib_nq_stop_irq(nq, false);
+		mutex_unlock(&nq->lock);
+	}
+
+	if (test_bit(BNXT_RE_FLAG_ALLOC_RCFW, &rdev->flags))
+		bnxt_qplib_rcfw_stop_irq(rcfw, false);
+}
+
+static void bnxt_re_start_irq(void *handle, struct bnxt_msix_entry *ent)
+{
+	struct bnxt_re_en_dev_info *en_info = auxiliary_get_drvdata(handle);
+	struct bnxt_msix_entry *msix_ent = NULL;
+	struct bnxt_qplib_rcfw *rcfw = NULL;
+	struct bnxt_re_dev *rdev;
+	struct bnxt_qplib_nq *nq;
+	int indx, rc, vec;
+
+	if (!en_info) {
+		pr_err("Start irq, bad en_info\n");
+		return;
+	}
+	rdev = en_info->rdev;
+	if (!rdev)
+		return;
+	if (test_bit(BNXT_RE_FLAG_ERR_DEVICE_DETACHED, &rdev->flags))
+		return;
+	msix_ent = rdev->nqr.msix_entries;
+	rcfw = &rdev->rcfw;
+
+	if (!ent) {
+		/* Not setting the f/w timeout bit in rcfw.
+		 * During the driver unload the first command
+		 * to f/w will timeout and that will set the
+		 * timeout bit.
+		 */
+		dev_err(rdev_to_dev(rdev), "Failed to re-start IRQs\n");
+		return;
+	}
+
+	/* Vectors may change after restart, so update with new vectors
+	 * in device structure.
+	 */
+	for (indx = 0; indx < rdev->nqr.num_msix; indx++)
+		rdev->nqr.msix_entries[indx].vector = ent[indx].vector;
+
+	if (test_bit(BNXT_RE_FLAG_ALLOC_RCFW, &rdev->flags)) {
+		rc = bnxt_qplib_rcfw_start_irq(rcfw, msix_ent[BNXT_RE_AEQ_IDX].vector,
+					       false);
+		if (rc) {
+			dev_warn(rdev_to_dev(rdev),
+				 "Failed to reinit CREQ\n");
+			return;
+		}
+	}
+	for (indx = 0 ; indx < rdev->nqr.max_init; indx++) {
+		nq = &rdev->nqr.nq[indx];
+		vec = indx + 1;
+		rc = bnxt_qplib_nq_start_irq(nq, indx, msix_ent[vec].vector,
+					     false);
+		if (rc) {
+			dev_warn(rdev_to_dev(rdev),
+				 "Failed to reinit NQ index %d\n", indx);
+			return;
+		}
+	}
+}
+
+/*
+ * Except for ulp_async_notifier, the remaining ulp_ops
+ * below are called with rtnl_lock held
+ */
+static struct bnxt_ulp_ops bnxt_re_ulp_ops = {
+	.ulp_async_notifier = bnxt_re_async_notifier,
+	.ulp_stop = bnxt_re_stop,
+	.ulp_start = bnxt_re_start,
+	.ulp_shutdown = bnxt_re_shutdown,
+	.ulp_irq_stop = bnxt_re_stop_irq,
+	.ulp_irq_restart = bnxt_re_start_irq,
+};
+
+static inline const char *bnxt_re_netevent(unsigned long event)
+{
+	BNXT_RE_NETDEV_EVENT(event, NETDEV_UP);
+	BNXT_RE_NETDEV_EVENT(event, NETDEV_DOWN);
+	BNXT_RE_NETDEV_EVENT(event, NETDEV_CHANGE);
+	BNXT_RE_NETDEV_EVENT(event, NETDEV_REGISTER);
+	BNXT_RE_NETDEV_EVENT(event, NETDEV_UNREGISTER);
+	BNXT_RE_NETDEV_EVENT(event, NETDEV_CHANGEADDR);
+	return "Unknown";
+}
+
+/* RoCE -> Net driver */
+
+/* Driver registration routines used to let the networking driver (bnxt_en)
+ * to know that the RoCE driver is now installed */
+static void bnxt_re_unregister_netdev(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_en_dev *en_dev = rdev->en_dev;
+	int rc;
+
+	rtnl_lock();
+	rc = en_dev->en_ops->bnxt_unregister_device(rdev->en_dev,
+						    BNXT_ROCE_ULP);
+	rtnl_unlock();
+	if (rc)
+		dev_err(rdev_to_dev(rdev), "netdev %p unregister failed! rc = 0x%x",
+			rdev->en_dev->net, rc);
+
+	clear_bit(BNXT_RE_FLAG_NETDEV_REGISTERED, &rdev->flags);
+}
+
+static int bnxt_re_register_netdev(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_en_dev *en_dev = rdev->en_dev;
+	int rc = 0;
+
+	rtnl_lock();
+	rc = en_dev->en_ops->bnxt_register_device(en_dev,
+						  BNXT_ROCE_ULP,
+						  &bnxt_re_ulp_ops,
+						  rdev->adev);
+	rtnl_unlock();
+	if (rc) {
+		dev_err(rdev_to_dev(rdev), "netdev %p register failed! rc = 0x%x",
+			rdev->netdev, rc);
+		return rc;
+	}
+
+	return rc;
+}
+
+static void bnxt_re_set_db_offset(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_qplib_chip_ctx *cctx;
+	struct bnxt_en_dev *en_dev;
+	struct bnxt_qplib_res *res;
+	u32 l2db_len = 0;
+	u32 offset = 0;
+	u32 barlen;
+	int rc;
+
+	res = &rdev->qplib_res;
+	en_dev = rdev->en_dev;
+	cctx = rdev->chip_ctx;
+
+	/* Issue qcfg */
+	rc = bnxt_re_hwrm_qcfg(rdev, &l2db_len, &offset);
+	if (rc)
+		dev_info(rdev_to_dev(rdev),
+			 "Couldn't get DB bar size, Low latency framework is disabled\n");
+	/* set register offsets for both UC and WC */
+	if (_is_chip_p7(cctx))
+		res->dpi_tbl.ucreg.offset = offset;
+	else
+		res->dpi_tbl.ucreg.offset = res->is_vf ? BNXT_QPLIB_DBR_VF_DB_OFFSET :
+							 BNXT_QPLIB_DBR_PF_DB_OFFSET;
+	res->dpi_tbl.wcreg.offset = res->dpi_tbl.ucreg.offset;
+
+	/* If WC mapping is disabled by L2 driver then en_dev->l2_db_size
+	 * is equal to the DB-Bar actual size. This indicates that L2
+	 * is mapping entire bar as UC-. RoCE driver can't enable WC mapping
+	 * in such cases and DB-push will be disabled.
+	 */
+	barlen = pci_resource_len(res->pdev, RCFW_DBR_PCI_BAR_REGION);
+	if (cctx->modes.db_push && l2db_len && en_dev->l2_db_size != barlen) {
+		res->dpi_tbl.wcreg.offset = en_dev->l2_db_size;
+		dev_info(rdev_to_dev(rdev),
+			 "Low latency framework is enabled\n");
+	}
+
+	return;
+}
+
+static void bnxt_re_set_drv_mode(struct bnxt_re_dev *rdev, u8 mode)
+{
+	struct bnxt_qplib_chip_ctx *cctx;
+	struct bnxt_en_dev *en_dev;
+
+	en_dev = rdev->en_dev;
+	cctx = rdev->chip_ctx;
+	cctx->modes.wqe_mode = _is_chip_gen_p5_p7(rdev->chip_ctx) ?
+					mode : BNXT_QPLIB_WQE_MODE_STATIC;
+	cctx->modes.te_bypass = false;
+	if (bnxt_re_hwrm_qcaps(rdev))
+		dev_err(rdev_to_dev(rdev),
+			"Failed to query hwrm qcaps\n");
+	 /*
+	  * TODO: Need a better mechanism for spreading of the
+	  * 512 extended PPP pages in the presence of VF and
+	  * NPAR, until then not enabling push
+	  */
+	if (_is_chip_p7(rdev->chip_ctx) && cctx->modes.db_push) {
+		if (rdev->is_virtfn || BNXT_EN_NPAR(en_dev))
+			cctx->modes.db_push = false;
+	}
+
+	rdev->roce_mode = en_dev->flags & BNXT_EN_FLAG_ROCE_CAP;
+	dev_dbg(rdev_to_dev(rdev),
+		"RoCE is supported on the device - caps:0x%x",
+		rdev->roce_mode);
+	if (!_is_chip_gen_p5_p7(rdev->chip_ctx))
+		rdev->roce_mode = BNXT_RE_FLAG_ROCEV2_CAP;
+	cctx->hw_stats_size = en_dev->hw_ring_stats_size;
+}
+
+static void bnxt_re_destroy_chip_ctx(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_qplib_chip_ctx *chip_ctx;
+	struct bnxt_qplib_res *res;
+
+	if (!rdev->chip_ctx)
+		return;
+
+	res = &rdev->qplib_res;
+	bnxt_qplib_unmap_db_bar(res);
+
+	kfree(res->hctx);
+	res->rcfw = NULL;
+	kfree(rdev->dev_attr);
+	rdev->dev_attr = NULL;
+
+	chip_ctx = rdev->chip_ctx;
+	rdev->chip_ctx = NULL;
+	res->cctx = NULL;
+	res->hctx = NULL;
+	res->pdev = NULL;
+	res->netdev = NULL;
+	kfree(chip_ctx);
+}
+
+static int bnxt_re_setup_chip_ctx(struct bnxt_re_dev *rdev, u8 wqe_mode)
+{
+	struct bnxt_qplib_chip_ctx *chip_ctx;
+	struct bnxt_en_dev *en_dev;
+	int rc;
+
+	en_dev = rdev->en_dev;
+	/* Supply pci device to qplib */
+	rdev->qplib_res.pdev = en_dev->pdev;
+	rdev->qplib_res.netdev = rdev->netdev;
+	rdev->qplib_res.en_dev = en_dev;
+
+	chip_ctx = kzalloc(sizeof(*chip_ctx), GFP_KERNEL);
+	if (!chip_ctx)
+		return -ENOMEM;
+	rdev->chip_ctx = chip_ctx;
+	rdev->qplib_res.cctx = chip_ctx;
+	rc = bnxt_re_query_hwrm_intf_version(rdev);
+	if (rc)
+		goto fail;
+	rdev->dev_attr = kzalloc(sizeof(*rdev->dev_attr), GFP_KERNEL);
+	if (!rdev->dev_attr) {
+		rc = -ENOMEM;
+		goto fail;
+	}
+	rdev->qplib_res.dattr = rdev->dev_attr;
+	rdev->qplib_res.rcfw = &rdev->rcfw;
+	rdev->qplib_res.is_vf = rdev->is_virtfn;
+
+	rdev->qplib_res.hctx = kzalloc(sizeof(*rdev->qplib_res.hctx),
+				       GFP_KERNEL);
+	if (!rdev->qplib_res.hctx) {
+		rc = -ENOMEM;
+		goto fail;
+	}
+	bnxt_re_set_drv_mode(rdev, wqe_mode);
+
+	bnxt_re_set_db_offset(rdev);
+	rc = bnxt_qplib_map_db_bar(&rdev->qplib_res);
+	if (rc)
+		goto fail;
+
+	rc = bnxt_qplib_enable_atomic_ops_to_root(en_dev->pdev);
+	if (rc)
+		dev_dbg(rdev_to_dev(rdev),
+			"platform doesn't support global atomics");
+
+	return 0;
+fail:
+	kfree(rdev->chip_ctx);
+	rdev->chip_ctx = NULL;
+
+	kfree(rdev->dev_attr);
+	rdev->dev_attr = NULL;
+
+	kfree(rdev->qplib_res.hctx);
+	rdev->qplib_res.hctx = NULL;
+	return rc;
+}
+
+static u16 bnxt_re_get_rtype(struct bnxt_re_dev *rdev) {
+	return _is_chip_gen_p5_p7(rdev->chip_ctx) ?
+	       HWRM_RING_ALLOC_INPUT_RING_TYPE_NQ :
+	       HWRM_RING_ALLOC_INPUT_RING_TYPE_ROCE_CMPL;
+}
+
+static int bnxt_re_net_ring_free(struct bnxt_re_dev *rdev, u16 fw_ring_id)
+{
+	int rc = -EINVAL;
+	struct hwrm_ring_free_input req = {0};
+	struct hwrm_ring_free_output resp;
+	struct bnxt_en_dev *en_dev = rdev->en_dev;
+	struct bnxt_fw_msg fw_msg;
+
+	if (!en_dev)
+		return rc;
+
+	/* To avoid unnecessary error messages during recovery.
+	 * HW is anyway in error state. So dont send down the command */
+	if (test_bit(BNXT_RE_FLAG_ERR_DEVICE_DETACHED, &rdev->flags))
+		return 0;
+
+	/* allocation had failed, no need to issue hwrm */
+	if (fw_ring_id == 0xffff)
+		return 0;
+
+	memset(&fw_msg, 0, sizeof(fw_msg));
+
+	bnxt_re_init_hwrm_hdr(rdev, (void *)&req, HWRM_RING_FREE, -1, -1);
+	req.ring_type = bnxt_re_get_rtype(rdev);
+	req.ring_id = cpu_to_le16(fw_ring_id);
+	bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
+			    sizeof(resp), DFLT_HWRM_CMD_TIMEOUT);
+	rc = en_dev->en_ops->bnxt_send_fw_msg(en_dev, BNXT_ROCE_ULP, &fw_msg);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev),
+			"Failed to free HW ring with rc = 0x%x", rc);
+		return rc;
+	}
+	dev_dbg(rdev_to_dev(rdev), "HW ring freed with id = 0x%x\n",
+		fw_ring_id);
+
+	return rc;
+}
+
+static int bnxt_re_net_ring_alloc(struct bnxt_re_dev *rdev,
+				  struct bnxt_re_ring_attr *ring_attr,
+				  u16 *fw_ring_id)
+{
+	int rc = -EINVAL;
+	struct hwrm_ring_alloc_input req = {0};
+	struct hwrm_ring_alloc_output resp;
+	struct bnxt_en_dev *en_dev = rdev->en_dev;
+	struct bnxt_fw_msg fw_msg;
+
+	if (!en_dev)
+		return rc;
+
+	memset(&fw_msg, 0, sizeof(fw_msg));
+	bnxt_re_init_hwrm_hdr(rdev, (void *)&req, HWRM_RING_ALLOC, -1, -1);
+	req.flags = cpu_to_le16(ring_attr->flags);
+	req.enables = 0;
+	req.page_tbl_addr =  cpu_to_le64(ring_attr->dma_arr[0]);
+	if (ring_attr->pages > 1) {
+		/* Page size is in log2 units */
+		req.page_size = BNXT_PAGE_SHIFT;
+		req.page_tbl_depth = 1;
+	} else {
+		req.page_size = 4;
+		req.page_tbl_depth = 0;
+	}
+
+	req.fbo = 0;
+	/* Association of ring index with doorbell index and MSIX number */
+	req.logical_id = cpu_to_le16(ring_attr->lrid);
+	req.length = cpu_to_le32(ring_attr->depth + 1);
+	req.ring_type = ring_attr->type;
+	req.int_mode = ring_attr->mode;
+	bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
+			    sizeof(resp), DFLT_HWRM_CMD_TIMEOUT);
+	rc = en_dev->en_ops->bnxt_send_fw_msg(en_dev, BNXT_ROCE_ULP, &fw_msg);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev),
+			"Failed to allocate HW ring with rc = 0x%x", rc);
+		return rc;
+	}
+	*fw_ring_id = le16_to_cpu(resp.ring_id);
+	dev_dbg(rdev_to_dev(rdev),
+		"HW ring allocated with id = 0x%x at slot 0x%x",
+		resp.ring_id, ring_attr->lrid);
+
+	return rc;
+}
+
+static int bnxt_re_net_stats_ctx_free(struct bnxt_re_dev *rdev,
+				      u32 fw_stats_ctx_id, u16 tid)
+{
+	struct bnxt_en_dev *en_dev = rdev->en_dev;
+	struct hwrm_stat_ctx_free_input req = {0};
+	struct hwrm_stat_ctx_free_output resp;
+	struct bnxt_fw_msg fw_msg;
+	int rc = -EINVAL;
+
+	if (!en_dev)
+		return rc;
+
+	/* To avoid unnecessary error messages during recovery.
+	 * HW is anyway in error state. So dont send down the command */
+	if (test_bit(BNXT_RE_FLAG_ERR_DEVICE_DETACHED, &rdev->flags))
+		return 0;
+	memset(&fw_msg, 0, sizeof(fw_msg));
+	bnxt_re_init_hwrm_hdr(rdev, (void *)&req, HWRM_STAT_CTX_FREE, -1, tid);
+	req.stat_ctx_id = cpu_to_le32(fw_stats_ctx_id);
+	bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
+			    sizeof(resp), DFLT_HWRM_CMD_TIMEOUT);
+	rc = en_dev->en_ops->bnxt_send_fw_msg(en_dev, BNXT_ROCE_ULP, &fw_msg);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev),
+			"Failed to free HW stats ctx with rc = 0x%x", rc);
+		return rc;
+	}
+	dev_dbg(rdev_to_dev(rdev),
+		"HW stats ctx freed with id = 0x%x", fw_stats_ctx_id);
+
+	return rc;
+}
+
+static int bnxt_re_net_stats_ctx_alloc(struct bnxt_re_dev *rdev, u16 tid)
+{
+	struct hwrm_stat_ctx_alloc_output resp = {};
+	struct hwrm_stat_ctx_alloc_input req = {};
+	struct bnxt_en_dev *en_dev = rdev->en_dev;
+	struct bnxt_qplib_stats *stat;
+	struct bnxt_qplib_ctx *hctx;
+	struct bnxt_fw_msg fw_msg;
+	int rc = 0;
+
+	hctx = rdev->qplib_res.hctx;
+	stat = (tid == 0xffff) ? &hctx->stats : &hctx->stats2;
+	stat->fw_id = INVALID_STATS_CTX_ID;
+
+	if (!en_dev)
+		return -EINVAL;
+
+	memset(&fw_msg, 0, sizeof(fw_msg));
+	bnxt_re_init_hwrm_hdr(rdev, (void *)&req,
+			      HWRM_STAT_CTX_ALLOC, -1, tid);
+	req.update_period_ms = cpu_to_le32(1000);
+	req.stats_dma_length = rdev->chip_ctx->hw_stats_size;
+	req.stats_dma_addr = cpu_to_le64(stat->dma_map);
+	req.stat_ctx_flags = HWRM_STAT_CTX_ALLOC_INPUT_STAT_CTX_FLAGS_ROCE;
+	bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
+			    sizeof(resp), DFLT_HWRM_CMD_TIMEOUT);
+	rc = en_dev->en_ops->bnxt_send_fw_msg(en_dev, BNXT_ROCE_ULP, &fw_msg);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev),
+			"Failed to allocate HW stats ctx, rc = 0x%x", rc);
+		return rc;
+	}
+	stat->fw_id = le32_to_cpu(resp.stat_ctx_id);
+	dev_dbg(rdev_to_dev(rdev), "HW stats ctx allocated with id = 0x%x",
+		stat->fw_id);
+
+	return rc;
+}
+
+static void bnxt_re_net_unregister_async_event(struct bnxt_re_dev *rdev)
+{
+	const struct bnxt_en_ops *en_ops;
+
+	if (rdev->is_virtfn ||
+	    test_bit(BNXT_RE_FLAG_ERR_DEVICE_DETACHED, &rdev->flags))
+		return;
+
+	memset(rdev->event_bitmap, 0, sizeof(rdev->event_bitmap));
+	en_ops = rdev->en_dev->en_ops;
+	if (en_ops->bnxt_register_fw_async_events
+	    (rdev->en_dev, BNXT_ROCE_ULP,
+	     (unsigned long *)rdev->event_bitmap,
+	      HWRM_ASYNC_EVENT_CMPL_EVENT_ID_DOORBELL_PACING_NQ_UPDATE))
+		dev_err(rdev_to_dev(rdev),
+			"Failed to unregister async event");
+}
+
+static void bnxt_re_net_register_async_event(struct bnxt_re_dev *rdev)
+{
+	const struct bnxt_en_ops *en_ops;
+
+	if (rdev->is_virtfn)
+		return;
+
+	rdev->event_bitmap[0] |=
+		BIT(HWRM_ASYNC_EVENT_CMPL_EVENT_ID_DCB_CONFIG_CHANGE) |
+		BIT(HWRM_ASYNC_EVENT_CMPL_EVENT_ID_RESET_NOTIFY);
+
+	rdev->event_bitmap[2] |=
+	   BIT(HWRM_ASYNC_EVENT_CMPL_EVENT_ID_ERROR_REPORT - 64);
+	rdev->event_bitmap[2] |=
+		BIT(HWRM_ASYNC_EVENT_CMPL_EVENT_ID_DOORBELL_PACING_THRESHOLD - 64) |
+		BIT(HWRM_ASYNC_EVENT_CMPL_EVENT_ID_DOORBELL_PACING_NQ_UPDATE - 64);
+	en_ops = rdev->en_dev->en_ops;
+	if (en_ops->bnxt_register_fw_async_events
+	    (rdev->en_dev, BNXT_ROCE_ULP,
+	     (unsigned long *)rdev->event_bitmap,
+	      HWRM_ASYNC_EVENT_CMPL_EVENT_ID_DOORBELL_PACING_NQ_UPDATE))
+		dev_err(rdev_to_dev(rdev),
+			"Failed to reg Async event");
+}
+
+static int bnxt_re_query_hwrm_intf_version(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_en_dev *en_dev = rdev->en_dev;
+	struct hwrm_ver_get_output resp = {0};
+	struct hwrm_ver_get_input req = {0};
+	struct bnxt_qplib_chip_ctx *cctx;
+	struct bnxt_fw_msg fw_msg;
+	int rc = 0;
+
+	memset(&fw_msg, 0, sizeof(fw_msg));
+	bnxt_re_init_hwrm_hdr(rdev, (void *)&req,
+			      HWRM_VER_GET, -1, -1);
+	req.hwrm_intf_maj = HWRM_VERSION_MAJOR;
+	req.hwrm_intf_min = HWRM_VERSION_MINOR;
+	req.hwrm_intf_upd = HWRM_VERSION_UPDATE;
+	bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
+			    sizeof(resp), DFLT_HWRM_CMD_TIMEOUT);
+	rc = en_dev->en_ops->bnxt_send_fw_msg(en_dev, BNXT_ROCE_ULP, &fw_msg);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev),
+			"Failed to query HW version, rc = 0x%x", rc);
+		return rc;
+	}
+	cctx = rdev->chip_ctx;
+	cctx->hwrm_intf_ver = (u64) le16_to_cpu(resp.hwrm_intf_major) << 48 |
+			      (u64) le16_to_cpu(resp.hwrm_intf_minor) << 32 |
+			      (u64) le16_to_cpu(resp.hwrm_intf_build) << 16 |
+				    le16_to_cpu(resp.hwrm_intf_patch);
+
+	cctx->hwrm_cmd_max_timeout = le16_to_cpu(resp.max_req_timeout);
+
+	if (!cctx->hwrm_cmd_max_timeout)
+		cctx->hwrm_cmd_max_timeout = RCFW_FW_STALL_MAX_TIMEOUT;
+
+	cctx->chip_num = le16_to_cpu(resp.chip_num);
+	cctx->chip_rev = resp.chip_rev;
+	cctx->chip_metal = resp.chip_metal;
+	return 0;
+}
+
+/* Query device config using common hwrm */
+static int bnxt_re_hwrm_qcfg(struct bnxt_re_dev *rdev, u32 *db_len,
+			     u32 *offset)
+{
+	struct bnxt_en_dev *en_dev = rdev->en_dev;
+	struct hwrm_func_qcfg_output resp = {0};
+	struct hwrm_func_qcfg_input req = {0};
+	struct bnxt_fw_msg fw_msg;
+	int rc;
+
+	memset(&fw_msg, 0, sizeof(fw_msg));
+	bnxt_re_init_hwrm_hdr(rdev, (void *)&req,
+			      HWRM_FUNC_QCFG, -1, -1);
+	req.fid = cpu_to_le16(0xffff);
+	bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
+			    sizeof(resp), DFLT_HWRM_CMD_TIMEOUT);
+	rc = en_dev->en_ops->bnxt_send_fw_msg(en_dev, BNXT_ROCE_ULP, &fw_msg);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev),
+			"Failed to query config, rc = %#x", rc);
+		return rc;
+	}
+
+	*db_len = PAGE_ALIGN(le16_to_cpu(resp.l2_doorbell_bar_size_kb) * 1024);
+	*offset = PAGE_ALIGN(le16_to_cpu(resp.legacy_l2_db_size_kb) * 1024);
+	return 0;
+}
+
+/* Query function capabilities using common hwrm */
+int bnxt_re_hwrm_qcaps(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_en_dev *en_dev = rdev->en_dev;
+	struct hwrm_func_qcaps_output resp = {0};
+	struct hwrm_func_qcaps_input req = {0};
+	struct bnxt_qplib_chip_ctx *cctx;
+	struct bnxt_fw_msg fw_msg;
+	u8 push_enable = false;
+	int rc;
+
+	cctx = rdev->chip_ctx;
+	memset(&fw_msg, 0, sizeof(fw_msg));
+	bnxt_re_init_hwrm_hdr(rdev, (void *)&req,
+			      HWRM_FUNC_QCAPS, -1, -1);
+	req.fid = cpu_to_le16(0xffff);
+	bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
+			    sizeof(resp), DFLT_HWRM_CMD_TIMEOUT);
+	rc = en_dev->en_ops->bnxt_send_fw_msg(en_dev, BNXT_ROCE_ULP, &fw_msg);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev),
+			"Failed to query capabilities, rc = %#x", rc);
+		return rc;
+	}
+	if (_is_chip_p7(rdev->chip_ctx))
+		push_enable =
+			(resp.flags_ext &
+			 HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_PPP_PUSH_MODE_SUPPORTED) ?
+			 true : false;
+	else
+		push_enable =
+			(resp.flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_WCB_PUSH_MODE) ?
+			 true : false;
+	cctx->modes.db_push = push_enable;
+
+	cctx->modes.dbr_pacing =
+		resp.flags_ext & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_DBR_PACING_SUPPORTED ?
+			true : false;
+	cctx->modes.dbr_pacing_ext =
+		resp.flags_ext2 &
+			HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_DBR_PACING_EXT_SUPPORTED ?
+			true : false;
+	cctx->modes.dbr_drop_recov =
+		(resp.flags_ext2 &
+		 HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_SW_DBR_DROP_RECOVERY_SUPPORTED) ?
+			true : false;
+	cctx->modes.dbr_pacing_v0 =
+		(resp.flags_ext2 &
+		 HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_DBR_PACING_V0_SUPPORTED) ?
+			true : false;
+	dev_dbg(rdev_to_dev(rdev),
+		"%s: cctx->modes.dbr_pacing = %d cctx->modes.dbr_pacing_ext = %d, dbr_drop_recov %d\n",
+		__func__, cctx->modes.dbr_pacing, cctx->modes.dbr_pacing_ext, cctx->modes.dbr_drop_recov);
+
+	return 0;
+}
+
+static int bnxt_re_hwrm_dbr_pacing_qcfg(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_qplib_db_pacing_data *pacing_data = rdev->qplib_res.pacing_data;
+	struct hwrm_func_dbr_pacing_qcfg_output resp = {0};
+	struct hwrm_func_dbr_pacing_qcfg_input req = {0};
+	struct bnxt_en_dev *en_dev = rdev->en_dev;
+	struct bnxt_qplib_chip_ctx *cctx;
+	struct bnxt_fw_msg fw_msg;
+	u32 primary_nq_id;
+	int rc;
+
+	cctx = rdev->chip_ctx;
+	memset(&fw_msg, 0, sizeof(fw_msg));
+	bnxt_re_init_hwrm_hdr(rdev, (void *)&req,
+			      HWRM_FUNC_DBR_PACING_QCFG, -1, -1);
+	bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
+			    sizeof(resp), BNXT_RE_HWRM_CMD_TIMEOUT(rdev));
+	rc = en_dev->en_ops->bnxt_send_fw_msg(en_dev, BNXT_ROCE_ULP, &fw_msg);
+	if (rc) {
+		dev_dbg(rdev_to_dev(rdev),
+			"Failed to query dbr pacing config, rc = %#x", rc);
+		return rc;
+	}
+
+	primary_nq_id = le32_to_cpu(resp.primary_nq_id);
+	if (primary_nq_id == 0xffffffff &&
+	    !bnxt_qplib_dbr_pacing_ext_en(rdev->chip_ctx)) {
+		dev_err(rdev_to_dev(rdev), "%s:%d Invoke bnxt_qplib_dbr_pacing_set_primary_pf with 1\n",
+			__func__, __LINE__);
+		bnxt_qplib_dbr_pacing_set_primary_pf(rdev->chip_ctx, 1);
+	}
+
+	if (bnxt_qplib_dbr_pacing_ext_en(rdev->chip_ctx)) {
+		struct bnxt_qplib_nq *nq;
+
+		nq = &rdev->nqr.nq[0];
+		/* Reset the primary capability */
+		if (nq->ring_id != primary_nq_id)
+			bnxt_qplib_dbr_pacing_set_primary_pf(rdev->chip_ctx, 0);
+	}
+
+	if ((resp.dbr_stat_db_fifo_reg &
+	     HWRM_FUNC_DBR_PACING_QCFG_OUTPUT_DBR_STAT_DB_FIFO_REG_ADDR_SPACE_MASK) ==
+	    HWRM_FUNC_DBR_PACING_QCFG_OUTPUT_DBR_STAT_DB_FIFO_REG_ADDR_SPACE_GRC)
+		cctx->dbr_stat_db_fifo =
+		resp.dbr_stat_db_fifo_reg &
+		~HWRM_FUNC_DBR_PACING_QCFG_OUTPUT_DBR_STAT_DB_FIFO_REG_ADDR_SPACE_MASK;
+
+	if ((resp.dbr_throttling_aeq_arm_reg &
+	    HWRM_FUNC_DBR_PACING_QCFG_OUTPUT_DBR_THROTTLING_AEQ_ARM_REG_ADDR_SPACE_MASK)
+	    == HWRM_FUNC_DBR_PACING_QCFG_OUTPUT_DBR_THROTTLING_AEQ_ARM_REG_ADDR_SPACE_GRC) {
+		cctx->dbr_aeq_arm_reg = resp.dbr_throttling_aeq_arm_reg &
+			~HWRM_FUNC_DBR_PACING_QCFG_OUTPUT_DBR_STAT_DB_FIFO_REG_ADDR_SPACE_MASK;
+		cctx->dbr_throttling_reg = cctx->dbr_aeq_arm_reg - 4;
+	}
+	pacing_data->fifo_max_depth = le32_to_cpu(resp.dbr_stat_db_max_fifo_depth);
+	if (!pacing_data->fifo_max_depth)
+		pacing_data->fifo_max_depth = BNXT_RE_MAX_FIFO_DEPTH(cctx);
+	pacing_data->fifo_room_mask = le32_to_cpu(resp.dbr_stat_db_fifo_reg_fifo_room_mask);
+	pacing_data->fifo_room_shift = resp.dbr_stat_db_fifo_reg_fifo_room_shift;
+	dev_dbg(rdev_to_dev(rdev),
+		"%s: nq:0x%x primary_pf:%d db_fifo:0x%x aeq_arm:0x%x i"
+		"fifo_max_depth 0x%x , resp.dbr_stat_db_max_fifo_depth 0x%x);\n",
+		__func__, resp.primary_nq_id, cctx->modes.dbr_primary_pf,
+		 cctx->dbr_stat_db_fifo, cctx->dbr_aeq_arm_reg,
+		 pacing_data->fifo_max_depth,
+		le32_to_cpu(resp.dbr_stat_db_max_fifo_depth));
+	return 0;
+}
+
+static int bnxt_re_hwrm_dbr_pacing_cfg(struct bnxt_re_dev *rdev, bool enable)
+{
+	struct hwrm_func_dbr_pacing_cfg_output resp = {0};
+	struct hwrm_func_dbr_pacing_cfg_input req = {0};
+	struct bnxt_en_dev *en_dev = rdev->en_dev;
+	struct bnxt_fw_msg fw_msg;
+	int rc;
+
+	if (test_bit(BNXT_RE_FLAG_ERR_DEVICE_DETACHED, &rdev->flags))
+		return 0;
+
+	memset(&fw_msg, 0, sizeof(fw_msg));
+	bnxt_re_init_hwrm_hdr(rdev, (void *)&req,
+			      HWRM_FUNC_DBR_PACING_CFG, -1, -1);
+	if (enable) {
+		req.flags = HWRM_FUNC_DBR_PACING_CFG_INPUT_FLAGS_DBR_NQ_EVENT_ENABLE;
+		req.enables =
+		cpu_to_le32(HWRM_FUNC_DBR_PACING_CFG_INPUT_ENABLES_PRIMARY_NQ_ID_VALID |
+			    HWRM_FUNC_DBR_PACING_CFG_INPUT_ENABLES_PACING_THRESHOLD_VALID);
+	} else {
+		req.flags = HWRM_FUNC_DBR_PACING_CFG_INPUT_FLAGS_DBR_NQ_EVENT_DISABLE;
+	}
+	req.primary_nq_id = cpu_to_le32(rdev->dbq_nq_id);
+	req.pacing_threshold = cpu_to_le32(rdev->dbq_watermark);
+	dev_dbg(rdev_to_dev(rdev), "%s: nq_id = 0x%x pacing_threshold = 0x%x",
+		__func__, req.primary_nq_id, req.pacing_threshold);
+	bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
+			    sizeof(resp), BNXT_RE_HWRM_CMD_TIMEOUT(rdev));
+	rc = en_dev->en_ops->bnxt_send_fw_msg(en_dev, BNXT_ROCE_ULP, &fw_msg);
+	if (rc) {
+		dev_dbg(rdev_to_dev(rdev),
+			"Failed to set dbr pacing config, rc = %#x", rc);
+		return rc;
+	}
+	return 0;
+}
+
+/* Net -> RoCE driver */
+
+/* Device */
+struct bnxt_re_dev *bnxt_re_from_netdev(struct ifnet *netdev)
+{
+	struct bnxt_re_dev *rdev;
+
+	rcu_read_lock();
+	list_for_each_entry_rcu(rdev, &bnxt_re_dev_list, list) {
+		if (rdev->netdev == netdev) {
+			rcu_read_unlock();
+			dev_dbg(rdev_to_dev(rdev),
+				"netdev (%p) found, ref_count = 0x%x",
+				netdev, atomic_read(&rdev->ref_count));
+			return rdev;
+		}
+	}
+	rcu_read_unlock();
+	return NULL;
+}
+
+static ssize_t show_rev(struct device *device, struct device_attribute *attr,
+			char *buf)
+{
+	struct bnxt_re_dev *rdev = to_bnxt_re_dev(device, ibdev.dev);
+
+	return scnprintf(buf, PAGE_SIZE, "0x%x\n", rdev->en_dev->pdev->vendor);
+}
+
+
+static ssize_t show_hca(struct device *device, struct device_attribute *attr,
+			char *buf)
+{
+	struct bnxt_re_dev *rdev = to_bnxt_re_dev(device, ibdev.dev);
+
+	return scnprintf(buf, PAGE_SIZE, "%s\n", rdev->ibdev.node_desc);
+}
+
+static DEVICE_ATTR(hw_rev, 0444, show_rev, NULL);
+static DEVICE_ATTR(hca_type, 0444, show_hca, NULL);
+static struct device_attribute *bnxt_re_attributes[] = {
+	&dev_attr_hw_rev,
+	&dev_attr_hca_type
+};
+
+int ib_register_device_compat(struct bnxt_re_dev *rdev)
+{
+	struct ib_device *ibdev = &rdev->ibdev;
+	char name[IB_DEVICE_NAME_MAX];
+
+	memset(name, 0, IB_DEVICE_NAME_MAX);
+	strlcpy(name, "bnxt_re%d", IB_DEVICE_NAME_MAX);
+
+	strlcpy(ibdev->name, name, IB_DEVICE_NAME_MAX);
+
+	return ib_register_device(ibdev, NULL);
+}
+
+static int bnxt_re_register_ib(struct bnxt_re_dev *rdev)
+{
+	struct ib_device *ibdev = &rdev->ibdev;
+	int ret = 0;
+
+	/* ib device init */
+	ibdev->owner = THIS_MODULE;
+	ibdev->uverbs_abi_ver = BNXT_RE_ABI_VERSION;
+	ibdev->node_type = RDMA_NODE_IB_CA;
+	strlcpy(ibdev->node_desc, BNXT_RE_DESC " HCA",
+		strlen(BNXT_RE_DESC) + 5);
+	ibdev->phys_port_cnt = 1;
+
+	bnxt_qplib_get_guid(rdev->dev_addr, (u8 *)&ibdev->node_guid);
+
+	/* Data path irqs is one less than the max msix vectors */
+	ibdev->num_comp_vectors	= rdev->nqr.num_msix - 1;
+	bnxt_re_set_dma_device(ibdev, rdev);
+	ibdev->local_dma_lkey = BNXT_QPLIB_RSVD_LKEY;
+
+	/* User space */
+	ibdev->uverbs_cmd_mask =
+			(1ull << IB_USER_VERBS_CMD_GET_CONTEXT)		|
+			(1ull << IB_USER_VERBS_CMD_QUERY_DEVICE)	|
+			(1ull << IB_USER_VERBS_CMD_QUERY_PORT)		|
+			(1ull << IB_USER_VERBS_CMD_ALLOC_PD)		|
+			(1ull << IB_USER_VERBS_CMD_DEALLOC_PD)		|
+			(1ull << IB_USER_VERBS_CMD_REG_MR)		|
+			(1ull << IB_USER_VERBS_CMD_DEREG_MR)		|
+			(1ull << IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL) |
+			(1ull << IB_USER_VERBS_CMD_CREATE_CQ)		|
+			(1ull << IB_USER_VERBS_CMD_DESTROY_CQ)		|
+			(1ull << IB_USER_VERBS_CMD_CREATE_QP)		|
+			(1ull << IB_USER_VERBS_CMD_MODIFY_QP)		|
+			(1ull << IB_USER_VERBS_CMD_QUERY_QP)		|
+			(1ull << IB_USER_VERBS_CMD_DESTROY_QP)		|
+			(1ull << IB_USER_VERBS_CMD_REREG_MR)		|
+			(1ull << IB_USER_VERBS_CMD_RESIZE_CQ)		|
+			(1ull << IB_USER_VERBS_CMD_CREATE_SRQ)		|
+			(1ull << IB_USER_VERBS_CMD_MODIFY_SRQ)		|
+			(1ull << IB_USER_VERBS_CMD_QUERY_SRQ)		|
+			(1ull << IB_USER_VERBS_CMD_DESTROY_SRQ)		|
+			(1ull << IB_USER_VERBS_CMD_ALLOC_MW)		|
+			(1ull << IB_USER_VERBS_CMD_DEALLOC_MW)		|
+			(1ull << IB_USER_VERBS_CMD_CREATE_AH)		|
+			(1ull << IB_USER_VERBS_CMD_MODIFY_AH)		|
+			(1ull << IB_USER_VERBS_CMD_QUERY_AH)		|
+			(1ull << IB_USER_VERBS_CMD_DESTROY_AH);
+
+	ibdev->uverbs_ex_cmd_mask = (1ull << IB_USER_VERBS_EX_CMD_MODIFY_QP);
+	ibdev->uverbs_cmd_mask |= (1ull << IB_USER_VERBS_CMD_POLL_CQ);
+
+#define bnxt_re_ib_ah bnxt_re_ah
+#define bnxt_re_ib_cq bnxt_re_cq
+#define bnxt_re_ib_pd bnxt_re_pd
+#define bnxt_re_ib_srq bnxt_re_srq
+#define bnxt_re_ib_ucontext bnxt_re_ucontext
+	INIT_IB_DEVICE_OPS(&ibdev->ops, bnxt_re, BNXT_RE);
+
+	ibdev->query_device		= bnxt_re_query_device;
+	ibdev->modify_device		= bnxt_re_modify_device;
+	ibdev->query_port		= bnxt_re_query_port;
+	ibdev->modify_port		= bnxt_re_modify_port;
+	ibdev->get_port_immutable	= bnxt_re_get_port_immutable;
+	ibdev->query_pkey		= bnxt_re_query_pkey;
+	ibdev->query_gid		= bnxt_re_query_gid;
+	ibdev->get_netdev		= bnxt_re_get_netdev;
+	ibdev->add_gid			= bnxt_re_add_gid;
+	ibdev->del_gid			= bnxt_re_del_gid;
+	ibdev->get_link_layer		= bnxt_re_get_link_layer;
+	ibdev->alloc_pd			= bnxt_re_alloc_pd;
+	ibdev->dealloc_pd		= bnxt_re_dealloc_pd;
+	ibdev->create_ah		= bnxt_re_create_ah;
+	ibdev->modify_ah		= bnxt_re_modify_ah;
+	ibdev->query_ah			= bnxt_re_query_ah;
+	ibdev->destroy_ah		= bnxt_re_destroy_ah;
+	ibdev->create_srq		= bnxt_re_create_srq;
+	ibdev->modify_srq		= bnxt_re_modify_srq;
+	ibdev->query_srq		= bnxt_re_query_srq;
+	ibdev->destroy_srq		= bnxt_re_destroy_srq;
+	ibdev->post_srq_recv		= bnxt_re_post_srq_recv;
+	ibdev->create_qp		= bnxt_re_create_qp;
+	ibdev->modify_qp		= bnxt_re_modify_qp;
+	ibdev->query_qp			= bnxt_re_query_qp;
+	ibdev->destroy_qp		= bnxt_re_destroy_qp;
+	ibdev->post_send		= bnxt_re_post_send;
+	ibdev->post_recv		= bnxt_re_post_recv;
+	ibdev->create_cq		= bnxt_re_create_cq;
+	ibdev->modify_cq		= bnxt_re_modify_cq;
+	ibdev->destroy_cq		= bnxt_re_destroy_cq;
+	ibdev->resize_cq		= bnxt_re_resize_cq;
+	ibdev->poll_cq			= bnxt_re_poll_cq;
+	ibdev->req_notify_cq		= bnxt_re_req_notify_cq;
+	ibdev->get_dma_mr		= bnxt_re_get_dma_mr;
+	ibdev->get_hw_stats		= bnxt_re_get_hw_stats;
+	ibdev->alloc_hw_stats		= bnxt_re_alloc_hw_port_stats;
+	ibdev->dereg_mr			= bnxt_re_dereg_mr;
+	ibdev->alloc_mr			= bnxt_re_alloc_mr;
+	ibdev->map_mr_sg		= bnxt_re_map_mr_sg;
+	ibdev->alloc_mw			= bnxt_re_alloc_mw;
+	ibdev->dealloc_mw		= bnxt_re_dealloc_mw;
+	ibdev->reg_user_mr		= bnxt_re_reg_user_mr;
+	ibdev->rereg_user_mr		= bnxt_re_rereg_user_mr;
+	ibdev->disassociate_ucontext	= bnxt_re_disassociate_ucntx;
+	ibdev->alloc_ucontext		= bnxt_re_alloc_ucontext;
+	ibdev->dealloc_ucontext		= bnxt_re_dealloc_ucontext;
+	ibdev->mmap			= bnxt_re_mmap;
+	ibdev->process_mad		= bnxt_re_process_mad;
+
+	ret = ib_register_device_compat(rdev);
+	return ret;
+}
+
+static void bnxt_re_dev_dealloc(struct bnxt_re_dev *rdev)
+{
+	int i = BNXT_RE_REF_WAIT_COUNT;
+
+	dev_dbg(rdev_to_dev(rdev), "%s:Remove the device %p\n", __func__, rdev);
+	/* Wait for rdev refcount to come down */
+	while ((atomic_read(&rdev->ref_count) > 1) && i--)
+		msleep(100);
+
+	if (atomic_read(&rdev->ref_count) > 1)
+		dev_err(rdev_to_dev(rdev),
+			"Failed waiting for ref count to deplete %d",
+			atomic_read(&rdev->ref_count));
+
+	atomic_set(&rdev->ref_count, 0);
+	if_rele(rdev->netdev);
+	rdev->netdev = NULL;
+	synchronize_rcu();
+
+	kfree(rdev->gid_map);
+	kfree(rdev->dbg_stats);
+	ib_dealloc_device(&rdev->ibdev);
+}
+
+static struct bnxt_re_dev *bnxt_re_dev_alloc(struct ifnet *netdev,
+					   struct bnxt_en_dev *en_dev)
+{
+	struct bnxt_re_dev *rdev;
+	u32 count;
+
+	/* Allocate bnxt_re_dev instance here */
+	rdev = (struct bnxt_re_dev *)compat_ib_alloc_device(sizeof(*rdev));
+	if (!rdev) {
+		pr_err("%s: bnxt_re_dev allocation failure!",
+			ROCE_DRV_MODULE_NAME);
+		return NULL;
+	}
+	/* Default values */
+	atomic_set(&rdev->ref_count, 0);
+	rdev->netdev = netdev;
+	dev_hold(rdev->netdev);
+	rdev->en_dev = en_dev;
+	rdev->id = rdev->en_dev->pdev->devfn;
+	INIT_LIST_HEAD(&rdev->qp_list);
+	mutex_init(&rdev->qp_lock);
+	mutex_init(&rdev->cc_lock);
+	mutex_init(&rdev->dbq_lock);
+	bnxt_re_clear_rsors_stat(&rdev->stats.rsors);
+	rdev->cosq[0] = rdev->cosq[1] = 0xFFFF;
+	rdev->min_tx_depth = 1;
+	rdev->stats.stats_query_sec = 1;
+	/* Disable priority vlan as the default mode is DSCP based PFC */
+	rdev->cc_param.disable_prio_vlan_tx = 1;
+
+	/* Initialize worker for DBR Pacing */
+	INIT_WORK(&rdev->dbq_fifo_check_work, bnxt_re_db_fifo_check);
+	INIT_DELAYED_WORK(&rdev->dbq_pacing_work, bnxt_re_pacing_timer_exp);
+	rdev->gid_map = kzalloc(sizeof(*(rdev->gid_map)) *
+				  BNXT_RE_MAX_SGID_ENTRIES,
+				  GFP_KERNEL);
+	if (!rdev->gid_map) {
+		ib_dealloc_device(&rdev->ibdev);
+		return NULL;
+	}
+	for(count = 0; count < BNXT_RE_MAX_SGID_ENTRIES; count++)
+		rdev->gid_map[count] = -1;
+
+	rdev->dbg_stats = kzalloc(sizeof(*rdev->dbg_stats), GFP_KERNEL);
+	if (!rdev->dbg_stats) {
+		ib_dealloc_device(&rdev->ibdev);
+		return NULL;
+	}
+
+	return rdev;
+}
+
+static int bnxt_re_handle_unaffi_async_event(
+		struct creq_func_event *unaffi_async)
+{
+	switch (unaffi_async->event) {
+	case CREQ_FUNC_EVENT_EVENT_TX_WQE_ERROR:
+	case CREQ_FUNC_EVENT_EVENT_TX_DATA_ERROR:
+	case CREQ_FUNC_EVENT_EVENT_RX_WQE_ERROR:
+	case CREQ_FUNC_EVENT_EVENT_RX_DATA_ERROR:
+	case CREQ_FUNC_EVENT_EVENT_CQ_ERROR:
+	case CREQ_FUNC_EVENT_EVENT_TQM_ERROR:
+	case CREQ_FUNC_EVENT_EVENT_CFCQ_ERROR:
+	case CREQ_FUNC_EVENT_EVENT_CFCS_ERROR:
+	case CREQ_FUNC_EVENT_EVENT_CFCC_ERROR:
+	case CREQ_FUNC_EVENT_EVENT_CFCM_ERROR:
+	case CREQ_FUNC_EVENT_EVENT_TIM_ERROR:
+		break;
+	default:
+		return -EINVAL;
+	}
+	return 0;
+}
+
+static int bnxt_re_handle_qp_async_event(void *qp_event, struct bnxt_re_qp *qp)
+{
+	struct creq_qp_error_notification *err_event;
+	struct ib_event event;
+	unsigned int flags;
+
+	if (qp->qplib_qp.state == CMDQ_MODIFY_QP_NEW_STATE_ERR &&
+	    !qp->qplib_qp.is_user) {
+		flags = bnxt_re_lock_cqs(qp);
+		bnxt_qplib_add_flush_qp(&qp->qplib_qp);
+		bnxt_re_unlock_cqs(qp, flags);
+	}
+	memset(&event, 0, sizeof(event));
+	event.device = &qp->rdev->ibdev;
+	event.element.qp = &qp->ib_qp;
+	event.event = IB_EVENT_QP_FATAL;
+
+	err_event = qp_event;
+	switch(err_event->res_err_state_reason) {
+	case CFCQ_RES_ERR_STATE_REASON_RES_EXCEED_MAX:
+	case CFCQ_RES_ERR_STATE_REASON_RES_PAYLOAD_LENGTH_MISMATCH:
+	case CFCQ_RES_ERR_STATE_REASON_RES_OPCODE_ERROR:
+	case CFCQ_RES_ERR_STATE_REASON_RES_PSN_SEQ_ERROR_RETRY_LIMIT:
+	case CFCQ_RES_ERR_STATE_REASON_RES_RX_INVALID_R_KEY:
+	case CFCQ_RES_ERR_STATE_REASON_RES_RX_DOMAIN_ERROR:
+	case CFCQ_RES_ERR_STATE_REASON_RES_RX_NO_PERMISSION:
+	case CFCQ_RES_ERR_STATE_REASON_RES_RX_RANGE_ERROR:
+	case CFCQ_RES_ERR_STATE_REASON_RES_TX_INVALID_R_KEY:
+	case CFCQ_RES_ERR_STATE_REASON_RES_TX_DOMAIN_ERROR:
+	case CFCQ_RES_ERR_STATE_REASON_RES_TX_NO_PERMISSION:
+	case CFCQ_RES_ERR_STATE_REASON_RES_TX_RANGE_ERROR:
+	case CFCQ_RES_ERR_STATE_REASON_RES_IVALID_DUP_RKEY:
+	case CFCQ_RES_ERR_STATE_REASON_RES_UNALIGN_ATOMIC:
+		event.event = IB_EVENT_QP_ACCESS_ERR;
+		break;
+	case CFCQ_RES_ERR_STATE_REASON_RES_EXCEEDS_WQE:
+	case CFCQ_RES_ERR_STATE_REASON_RES_WQE_FORMAT_ERROR:
+	case CFCQ_RES_ERR_STATE_REASON_RES_SRQ_LOAD_ERROR:
+	case CFCQ_RES_ERR_STATE_REASON_RES_UNSUPPORTED_OPCODE:
+	case CFCQ_RES_ERR_STATE_REASON_RES_REM_INVALIDATE:
+		event.event = IB_EVENT_QP_REQ_ERR;
+		break;
+	case CFCQ_RES_ERR_STATE_REASON_RES_IRRQ_OFLOW:
+	case CFCQ_RES_ERR_STATE_REASON_RES_CMP_ERROR:
+	case CFCQ_RES_ERR_STATE_REASON_RES_CQ_LOAD_ERROR:
+	case CFCQ_RES_ERR_STATE_REASON_RES_TX_PCI_ERROR:
+	case CFCQ_RES_ERR_STATE_REASON_RES_RX_PCI_ERROR:
+	case CFCQ_RES_ERR_STATE_REASON_RES_MEMORY_ERROR:
+	case CFCQ_RES_ERR_STATE_REASON_RES_SRQ_ERROR:
+		event.event = IB_EVENT_QP_FATAL;
+		break;
+	default:
+		if (qp->qplib_qp.srq)
+			event.event = IB_EVENT_QP_LAST_WQE_REACHED;
+		break;
+	}
+
+	if (err_event->res_err_state_reason)
+		dev_err(rdev_to_dev(qp->rdev),
+			"%s %s qp_id: %d cons (%d %d) req (%d %d) res (%d %d)\n",
+			__func__,  qp->qplib_qp.is_user ? "user" : "kernel",
+			qp->qplib_qp.id,
+			err_event->sq_cons_idx,
+			err_event->rq_cons_idx,
+			err_event->req_slow_path_state,
+			err_event->req_err_state_reason,
+			err_event->res_slow_path_state,
+			err_event->res_err_state_reason);
+
+	if (event.device && qp->ib_qp.event_handler)
+		qp->ib_qp.event_handler(&event, qp->ib_qp.qp_context);
+
+	return 0;
+}
+
+static int bnxt_re_handle_cq_async_error(void *event, struct bnxt_re_cq *cq)
+{
+	struct creq_cq_error_notification *cqerr;
+	bool send = false;
+
+	cqerr = event;
+	switch (cqerr->cq_err_reason) {
+	case CREQ_CQ_ERROR_NOTIFICATION_CQ_ERR_REASON_REQ_CQ_INVALID_ERROR:
+	case CREQ_CQ_ERROR_NOTIFICATION_CQ_ERR_REASON_REQ_CQ_OVERFLOW_ERROR:
+	case CREQ_CQ_ERROR_NOTIFICATION_CQ_ERR_REASON_REQ_CQ_LOAD_ERROR:
+	case CREQ_CQ_ERROR_NOTIFICATION_CQ_ERR_REASON_RES_CQ_INVALID_ERROR:
+	case CREQ_CQ_ERROR_NOTIFICATION_CQ_ERR_REASON_RES_CQ_OVERFLOW_ERROR:
+	case CREQ_CQ_ERROR_NOTIFICATION_CQ_ERR_REASON_RES_CQ_LOAD_ERROR:
+		send = true;
+	default:
+		break;
+	}
+
+	if (send && cq->ibcq.event_handler) {
+		struct ib_event ibevent = {};
+
+		ibevent.event = IB_EVENT_CQ_ERR;
+		ibevent.element.cq = &cq->ibcq;
+		ibevent.device = &cq->rdev->ibdev;
+
+		dev_err(rdev_to_dev(cq->rdev),
+			"%s err reason %d\n", __func__, cqerr->cq_err_reason);
+		cq->ibcq.event_handler(&ibevent, cq->ibcq.cq_context);
+	}
+
+	cq->qplib_cq.is_cq_err_event = true;
+
+	return 0;
+}
+
+static int bnxt_re_handle_affi_async_event(struct creq_qp_event *affi_async,
+					   void *obj)
+{
+	struct bnxt_qplib_qp *qplqp;
+	struct bnxt_qplib_cq *qplcq;
+	struct bnxt_re_qp *qp;
+	struct bnxt_re_cq *cq;
+	int rc = 0;
+	u8 event;
+
+	if (!obj)
+		return rc; /* QP was already dead, still return success */
+
+	event = affi_async->event;
+	switch (event) {
+	case CREQ_QP_EVENT_EVENT_QP_ERROR_NOTIFICATION:
+		qplqp = obj;
+		qp = container_of(qplqp, struct bnxt_re_qp, qplib_qp);
+		rc = bnxt_re_handle_qp_async_event(affi_async, qp);
+		break;
+	case CREQ_QP_EVENT_EVENT_CQ_ERROR_NOTIFICATION:
+		qplcq = obj;
+		cq = container_of(qplcq, struct bnxt_re_cq, qplib_cq);
+		rc = bnxt_re_handle_cq_async_error(affi_async, cq);
+		break;
+	default:
+		rc = -EINVAL;
+	}
+
+	return rc;
+}
+
+static int bnxt_re_aeq_handler(struct bnxt_qplib_rcfw *rcfw,
+			       void *aeqe, void *obj)
+{
+	struct creq_func_event *unaffi_async;
+	struct creq_qp_event *affi_async;
+	u8 type;
+	int rc;
+
+	type = ((struct creq_base *)aeqe)->type;
+	if (type == CREQ_BASE_TYPE_FUNC_EVENT) {
+		unaffi_async = aeqe;
+		rc = bnxt_re_handle_unaffi_async_event(unaffi_async);
+	} else {
+		affi_async = aeqe;
+		rc = bnxt_re_handle_affi_async_event(affi_async, obj);
+	}
+
+	return rc;
+}
+
+static int bnxt_re_srqn_handler(struct bnxt_qplib_nq *nq,
+				struct bnxt_qplib_srq *handle, u8 event)
+{
+	struct bnxt_re_srq *srq = to_bnxt_re(handle, struct bnxt_re_srq,
+					     qplib_srq);
+	struct ib_event ib_event;
+
+	if (srq == NULL) {
+		pr_err("%s: SRQ is NULL, SRQN not handled",
+			ROCE_DRV_MODULE_NAME);
+		return -EINVAL;
+	}
+	ib_event.device = &srq->rdev->ibdev;
+	ib_event.element.srq = &srq->ibsrq;
+	if (event == NQ_SRQ_EVENT_EVENT_SRQ_THRESHOLD_EVENT)
+		ib_event.event = IB_EVENT_SRQ_LIMIT_REACHED;
+	else
+		ib_event.event = IB_EVENT_SRQ_ERR;
+
+	if (srq->ibsrq.event_handler) {
+		/* Lock event_handler? */
+		(*srq->ibsrq.event_handler)(&ib_event,
+					     srq->ibsrq.srq_context);
+	}
+	return 0;
+}
+
+static int bnxt_re_cqn_handler(struct bnxt_qplib_nq *nq,
+			       struct bnxt_qplib_cq *handle)
+{
+	struct bnxt_re_cq *cq = to_bnxt_re(handle, struct bnxt_re_cq,
+					   qplib_cq);
+	u32 *cq_ptr;
+
+	if (cq == NULL) {
+		pr_err("%s: CQ is NULL, CQN not handled",
+			ROCE_DRV_MODULE_NAME);
+		return -EINVAL;
+	}
+	/* CQ already in destroy path. Do not handle any more events */
+	if (handle->destroyed || !atomic_read(&cq->ibcq.usecnt)) {
+		if (!handle->destroyed)
+			dev_dbg(NULL, "%s: CQ being destroyed, CQN not handled",
+				ROCE_DRV_MODULE_NAME);
+		return 0;
+	}
+
+	if (cq->ibcq.comp_handler) {
+		if (cq->uctx_cq_page) {
+			cq_ptr = (u32 *)cq->uctx_cq_page;
+			*cq_ptr = cq->qplib_cq.toggle;
+		}
+		/* Lock comp_handler? */
+		(*cq->ibcq.comp_handler)(&cq->ibcq, cq->ibcq.cq_context);
+	}
+
+	return 0;
+}
+
+struct bnxt_qplib_nq *bnxt_re_get_nq(struct bnxt_re_dev *rdev)
+{
+	int min, indx;
+
+	mutex_lock(&rdev->nqr.load_lock);
+	for (indx = 0, min = 0; indx < (rdev->nqr.num_msix - 1); indx++) {
+		if (rdev->nqr.nq[min].load > rdev->nqr.nq[indx].load)
+			min = indx;
+	}
+	rdev->nqr.nq[min].load++;
+	mutex_unlock(&rdev->nqr.load_lock);
+
+	return &rdev->nqr.nq[min];
+}
+
+void bnxt_re_put_nq(struct bnxt_re_dev *rdev, struct bnxt_qplib_nq *nq)
+{
+	mutex_lock(&rdev->nqr.load_lock);
+	nq->load--;
+	mutex_unlock(&rdev->nqr.load_lock);
+}
+
+static bool bnxt_re_check_min_attr(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_qplib_dev_attr *attr;
+	bool rc = true;
+
+	attr = rdev->dev_attr;
+
+	if (!attr->max_cq || !attr->max_qp ||
+	    !attr->max_sgid || !attr->max_mr) {
+		dev_err(rdev_to_dev(rdev),"Insufficient RoCE resources");
+		dev_dbg(rdev_to_dev(rdev),
+			"max_cq = %d, max_qp = %d, max_dpi = %d, max_sgid = %d, max_mr = %d",
+			attr->max_cq, attr->max_qp, attr->max_dpi,
+			attr->max_sgid, attr->max_mr);
+		rc = false;
+	}
+	return rc;
+}
+
+static void bnxt_re_dispatch_event(struct ib_device *ibdev, struct ib_qp *qp,
+				   u8 port_num, enum ib_event_type event)
+{
+	struct ib_event ib_event;
+
+	ib_event.device = ibdev;
+	if (qp) {
+		ib_event.element.qp = qp;
+		ib_event.event = event;
+		if (qp->event_handler)
+			qp->event_handler(&ib_event, qp->qp_context);
+	} else {
+		ib_event.element.port_num = port_num;
+		ib_event.event = event;
+		ib_dispatch_event(&ib_event);
+	}
+
+	dev_dbg(rdev_to_dev(to_bnxt_re_dev(ibdev, ibdev)),
+		"ibdev %p Event 0x%x port_num 0x%x", ibdev, event, port_num);
+}
+
+static bool bnxt_re_is_qp1_or_shadow_qp(struct bnxt_re_dev *rdev,
+					struct bnxt_re_qp *qp)
+{
+	if (rdev->gsi_ctx.gsi_qp_mode == BNXT_RE_GSI_MODE_ALL)
+		return (qp->ib_qp.qp_type == IB_QPT_GSI) ||
+			(qp == rdev->gsi_ctx.gsi_sqp);
+	else
+		return (qp->ib_qp.qp_type == IB_QPT_GSI);
+}
+
+static void bnxt_re_stop_all_nonqp1_nonshadow_qps(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_qplib_qp *qpl_qp;
+	bool dev_detached = false;
+	struct ib_qp_attr qp_attr;
+	int num_qps_stopped = 0;
+	int mask = IB_QP_STATE;
+	struct bnxt_re_qp *qp;
+	unsigned long flags;
+
+	if (!rdev)
+		return;
+
+restart:
+	if (test_bit(BNXT_RE_FLAG_ERR_DEVICE_DETACHED, &rdev->flags))
+		dev_detached = true;
+
+	qp_attr.qp_state = IB_QPS_ERR;
+	mutex_lock(&rdev->qp_lock);
+	list_for_each_entry(qp, &rdev->qp_list, list) {
+		qpl_qp = &qp->qplib_qp;
+		if (dev_detached || !bnxt_re_is_qp1_or_shadow_qp(rdev, qp)) {
+			if (qpl_qp->state !=
+			    CMDQ_MODIFY_QP_NEW_STATE_RESET &&
+			    qpl_qp->state !=
+			    CMDQ_MODIFY_QP_NEW_STATE_ERR) {
+				if (dev_detached) {
+					/*
+					 * Cant actually send the command down,
+					 * marking the state for bookkeeping
+					 */
+					qpl_qp->state =
+						CMDQ_MODIFY_QP_NEW_STATE_ERR;
+					qpl_qp->cur_qp_state = qpl_qp->state;
+					if (!qpl_qp->is_user) {
+						/* Add to flush list */
+						flags = bnxt_re_lock_cqs(qp);
+						bnxt_qplib_add_flush_qp(qpl_qp);
+						bnxt_re_unlock_cqs(qp, flags);
+					}
+				} else {
+					num_qps_stopped++;
+					bnxt_re_modify_qp(&qp->ib_qp,
+							  &qp_attr, mask,
+							  NULL);
+				}
+
+				bnxt_re_dispatch_event(&rdev->ibdev, &qp->ib_qp,
+						       1, IB_EVENT_QP_FATAL);
+				/*
+				 * 1. Release qp_lock after a budget to unblock other verb
+				 *    requests (like qp_destroy) from stack.
+				 * 2. Traverse through the qp_list freshly as addition / deletion
+				 *    might have happened since qp_lock is getting released here.
+				 */
+				if (num_qps_stopped % BNXT_RE_STOP_QPS_BUDGET == 0) {
+					mutex_unlock(&rdev->qp_lock);
+					goto restart;
+				}
+			}
+		}
+	}
+
+	mutex_unlock(&rdev->qp_lock);
+}
+
+static int bnxt_re_update_gid(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_qplib_sgid_tbl *sgid_tbl = &rdev->qplib_res.sgid_tbl;
+	struct bnxt_qplib_gid gid;
+	u16 gid_idx, index;
+	int rc = 0;
+
+	if (!test_bit(BNXT_RE_FLAG_IBDEV_REGISTERED, &rdev->flags))
+		return 0;
+
+	if (sgid_tbl == NULL) {
+		dev_err(rdev_to_dev(rdev), "QPLIB: SGID table not allocated");
+		return -EINVAL;
+	}
+
+	for (index = 0; index < sgid_tbl->active; index++) {
+		gid_idx = sgid_tbl->hw_id[index];
+
+		if (!memcmp(&sgid_tbl->tbl[index], &bnxt_qplib_gid_zero,
+			    sizeof(bnxt_qplib_gid_zero)))
+			continue;
+		/* Need to modify the VLAN enable setting of non VLAN GID only
+		 * as setting is done for VLAN GID while adding GID
+		 *
+		 * If disable_prio_vlan_tx is enable, then we'll need to remove the
+		 * vlan entry from the sgid_tbl.
+		 */
+		if (sgid_tbl->vlan[index] == true)
+			continue;
+
+		memcpy(&gid, &sgid_tbl->tbl[index], sizeof(gid));
+
+		rc = bnxt_qplib_update_sgid(sgid_tbl, &gid, gid_idx,
+					    rdev->dev_addr);
+	}
+
+	return rc;
+}
+
+static void bnxt_re_clear_cc(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_qplib_cc_param *cc_param = &rdev->cc_param;
+
+	if (_is_chip_p7(rdev->chip_ctx)) {
+		cc_param->mask = CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_TOS_DSCP;
+	} else {
+		cc_param->mask = (CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_CC_MODE |
+				  CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_ENABLE_CC |
+				  CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_TOS_ECN);
+
+		if (!is_qport_service_type_supported(rdev))
+			cc_param->mask |=
+			(CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_ALT_VLAN_PCP |
+			 CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_ALT_TOS_DSCP |
+			 CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_TOS_DSCP);
+	}
+
+	cc_param->cur_mask  = cc_param->mask;
+
+	if (bnxt_qplib_modify_cc(&rdev->qplib_res, cc_param))
+		dev_err(rdev_to_dev(rdev), "Failed to modify cc\n");
+}
+
+static int bnxt_re_setup_cc(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_qplib_cc_param *cc_param = &rdev->cc_param;
+	int rc;
+
+	if (_is_chip_p7(rdev->chip_ctx)) {
+		cc_param->enable = 0x0;
+		cc_param->mask = CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_TOS_DSCP;
+	} else {
+		cc_param->enable = 0x1;
+		cc_param->mask = (CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_CC_MODE |
+				  CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_ENABLE_CC |
+				  CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_TOS_ECN);
+
+		if (!is_qport_service_type_supported(rdev))
+			cc_param->mask |=
+			(CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_ALT_VLAN_PCP |
+			 CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_ALT_TOS_DSCP |
+			 CMDQ_MODIFY_ROCE_CC_MODIFY_MASK_TOS_DSCP);
+	}
+
+	cc_param->cur_mask  = cc_param->mask;
+
+	rc = bnxt_qplib_modify_cc(&rdev->qplib_res, cc_param);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev), "Failed to modify cc\n");
+		return rc;
+	}
+	/* Reset the programming mask */
+	cc_param->mask = 0;
+	if (cc_param->qp1_tos_dscp != cc_param->tos_dscp) {
+		cc_param->qp1_tos_dscp = cc_param->tos_dscp;
+		rc = bnxt_re_update_qp1_tos_dscp(rdev);
+		if (rc) {
+			dev_err(rdev_to_dev(rdev), "%s:Failed to modify QP1:%d",
+				__func__, rc);
+			goto clear;
+		}
+	}
+	return 0;
+
+clear:
+	bnxt_re_clear_cc(rdev);
+	return rc;
+}
+
+int bnxt_re_query_hwrm_dscp2pri(struct bnxt_re_dev *rdev,
+				struct bnxt_re_dscp2pri *d2p, u16 *count,
+				u16 target_id)
+{
+	struct bnxt_en_dev *en_dev = rdev->en_dev;
+	struct hwrm_queue_dscp2pri_qcfg_input req;
+	struct hwrm_queue_dscp2pri_qcfg_output resp;
+	struct bnxt_re_dscp2pri *dscp2pri;
+	struct bnxt_fw_msg fw_msg;
+	u16 in_count = *count;
+	dma_addr_t dma_handle;
+	int rc = 0, i;
+	u16 data_len;
+	u8 *kmem;
+
+	data_len = *count * sizeof(*dscp2pri);
+	memset(&fw_msg, 0, sizeof(fw_msg));
+	memset(&req, 0, sizeof(req));
+	bnxt_re_init_hwrm_hdr(rdev, (void *)&req,
+			      HWRM_QUEUE_DSCP2PRI_QCFG, -1, target_id);
+	req.port_id = (target_id == 0xFFFF) ? en_dev->pf_port_id : 1;
+
+	kmem = dma_zalloc_coherent(&en_dev->pdev->dev, data_len, &dma_handle,
+				   GFP_KERNEL);
+	if (!kmem) {
+		dev_err(rdev_to_dev(rdev),
+			"dma_zalloc_coherent failure, length = %u\n",
+			(unsigned)data_len);
+		return -ENOMEM;
+	}
+	req.dest_data_addr = cpu_to_le64(dma_handle);
+	req.dest_data_buffer_size = cpu_to_le16(data_len);
+	bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
+			    sizeof(resp), DFLT_HWRM_CMD_TIMEOUT);
+	rc = en_dev->en_ops->bnxt_send_fw_msg(en_dev, BNXT_ROCE_ULP, &fw_msg);
+	if (rc)
+		goto out;
+
+	/* Upload the DSCP-MASK-PRI tuple(s) */
+	dscp2pri = (struct bnxt_re_dscp2pri *)kmem;
+	for (i = 0; i < le16_to_cpu(resp.entry_cnt) && i < in_count; i++) {
+		d2p[i].dscp = dscp2pri->dscp;
+		d2p[i].mask = dscp2pri->mask;
+		d2p[i].pri = dscp2pri->pri;
+		dscp2pri++;
+	}
+	*count = le16_to_cpu(resp.entry_cnt);
+out:
+	dma_free_coherent(&en_dev->pdev->dev, data_len, kmem, dma_handle);
+	return rc;
+}
+
+int bnxt_re_prio_vlan_tx_update(struct bnxt_re_dev *rdev)
+{
+	/* Remove the VLAN from the GID entry */
+	if (rdev->cc_param.disable_prio_vlan_tx)
+		rdev->qplib_res.prio = false;
+	else
+		rdev->qplib_res.prio = true;
+
+	return bnxt_re_update_gid(rdev);
+}
+
+int bnxt_re_set_hwrm_dscp2pri(struct bnxt_re_dev *rdev,
+			      struct bnxt_re_dscp2pri *d2p, u16 count,
+			      u16 target_id)
+{
+	struct bnxt_en_dev *en_dev = rdev->en_dev;
+	struct hwrm_queue_dscp2pri_cfg_input req;
+	struct hwrm_queue_dscp2pri_cfg_output resp;
+	struct bnxt_fw_msg fw_msg;
+	struct bnxt_re_dscp2pri *dscp2pri;
+	int i, rc, data_len = 3 * 256;
+	dma_addr_t dma_handle;
+	u8 *kmem;
+
+	memset(&req, 0, sizeof(req));
+	memset(&fw_msg, 0, sizeof(fw_msg));
+	bnxt_re_init_hwrm_hdr(rdev, (void *)&req,
+			      HWRM_QUEUE_DSCP2PRI_CFG, -1, target_id);
+	req.port_id = (target_id == 0xFFFF) ? en_dev->pf_port_id : 1;
+
+	kmem = dma_alloc_coherent(&en_dev->pdev->dev, data_len, &dma_handle,
+				  GFP_KERNEL);
+	if (!kmem) {
+		dev_err(rdev_to_dev(rdev),
+			"dma_alloc_coherent failure, length = %u\n",
+			(unsigned)data_len);
+		return -ENOMEM;
+	}
+	req.src_data_addr = cpu_to_le64(dma_handle);
+
+	/* Download the DSCP-MASK-PRI tuple(s) */
+	dscp2pri = (struct bnxt_re_dscp2pri *)kmem;
+	for (i = 0; i < count; i++) {
+		dscp2pri->dscp = d2p[i].dscp;
+		dscp2pri->mask = d2p[i].mask;
+		dscp2pri->pri = d2p[i].pri;
+		dscp2pri++;
+	}
+
+	req.entry_cnt = cpu_to_le16(count);
+	bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
+			    sizeof(resp), DFLT_HWRM_CMD_TIMEOUT);
+	rc = en_dev->en_ops->bnxt_send_fw_msg(en_dev, BNXT_ROCE_ULP, &fw_msg);
+	dma_free_coherent(&en_dev->pdev->dev, data_len, kmem, dma_handle);
+	return rc;
+}
+
+int bnxt_re_query_hwrm_qportcfg(struct bnxt_re_dev *rdev,
+			struct bnxt_re_tc_rec *tc_rec, u16 tid)
+{
+	u8 max_tc, tc, *qptr, *type_ptr0, *type_ptr1;
+	struct hwrm_queue_qportcfg_output resp = {0};
+	struct hwrm_queue_qportcfg_input req = {0};
+	struct bnxt_en_dev *en_dev = rdev->en_dev;
+	struct bnxt_fw_msg fw_msg;
+	bool def_init = false;
+	u8 *tmp_type;
+	u8 cos_id;
+	int rc;
+
+	memset(&fw_msg, 0, sizeof(fw_msg));
+	bnxt_re_init_hwrm_hdr(rdev, (void *)&req, HWRM_QUEUE_QPORTCFG,
+			      -1, tid);
+	req.port_id = (tid == 0xFFFF) ? en_dev->pf_port_id : 1;
+	if (BNXT_EN_ASYM_Q(en_dev))
+		req.flags = htole32(HWRM_QUEUE_QPORTCFG_INPUT_FLAGS_PATH_RX);
+
+	bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
+			    sizeof(resp), DFLT_HWRM_CMD_TIMEOUT);
+	rc = en_dev->en_ops->bnxt_send_fw_msg(en_dev, BNXT_ROCE_ULP, &fw_msg);
+	if (rc)
+		return rc;
+
+	if (!resp.max_configurable_queues)
+		return -EINVAL;
+
+	max_tc = resp.max_configurable_queues;
+	tc_rec->max_tc = max_tc;
+
+	if (resp.queue_cfg_info & HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_CFG_INFO_USE_PROFILE_TYPE)
+		tc_rec->serv_type_enabled = true;
+
+	qptr = &resp.queue_id0;
+	type_ptr0 = &resp.queue_id0_service_profile_type;
+	type_ptr1 = &resp.queue_id1_service_profile_type;
+	for (tc = 0; tc < max_tc; tc++) {
+		tmp_type = tc ? type_ptr1 + (tc - 1) : type_ptr0;
+
+		cos_id = *qptr++;
+		/* RoCE CoS queue is the first cos queue.
+		 * For MP12 and MP17 order is 405 and 141015.
+		 */
+		if (is_bnxt_roce_queue(rdev, *qptr, *tmp_type)) {
+			tc_rec->cos_id_roce = cos_id;
+			tc_rec->tc_roce = tc;
+		} else if (is_bnxt_cnp_queue(rdev, *qptr, *tmp_type)) {
+			tc_rec->cos_id_cnp = cos_id;
+			tc_rec->tc_cnp = tc;
+		} else if (!def_init) {
+			def_init = true;
+			tc_rec->tc_def = tc;
+			tc_rec->cos_id_def = cos_id;
+		}
+		qptr++;
+	}
+
+	return rc;
+}
+
+int bnxt_re_hwrm_cos2bw_qcfg(struct bnxt_re_dev *rdev, u16 target_id,
+			     struct bnxt_re_cos2bw_cfg *cfg)
+{
+	struct bnxt_en_dev *en_dev = rdev->en_dev;
+	struct hwrm_queue_cos2bw_qcfg_output resp;
+	struct hwrm_queue_cos2bw_qcfg_input req = {0};
+	struct bnxt_fw_msg fw_msg;
+	int rc, indx;
+	void *data;
+
+	memset(&fw_msg, 0, sizeof(fw_msg));
+	bnxt_re_init_hwrm_hdr(rdev, (void *)&req,
+			      HWRM_QUEUE_COS2BW_QCFG, -1, target_id);
+	req.port_id = (target_id == 0xFFFF) ? en_dev->pf_port_id : 1;
+
+	bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
+			    sizeof(resp), DFLT_HWRM_CMD_TIMEOUT);
+	rc = en_dev->en_ops->bnxt_send_fw_msg(en_dev, BNXT_ROCE_ULP, &fw_msg);
+	if (rc)
+		return rc;
+	data = &resp.queue_id0 + offsetof(struct bnxt_re_cos2bw_cfg,
+					  queue_id);
+	for (indx = 0; indx < 8; indx++, data += (sizeof(cfg->cfg))) {
+		memcpy(&cfg->cfg, data, sizeof(cfg->cfg));
+		if (indx == 0)
+			cfg->queue_id = resp.queue_id0;
+		cfg++;
+	}
+
+	return rc;
+}
+
+int bnxt_re_hwrm_cos2bw_cfg(struct bnxt_re_dev *rdev, u16 target_id,
+			    struct bnxt_re_cos2bw_cfg *cfg)
+{
+	struct bnxt_en_dev *en_dev = rdev->en_dev;
+	struct hwrm_queue_cos2bw_cfg_input req = {0};
+	struct hwrm_queue_cos2bw_cfg_output resp = {0};
+	struct bnxt_fw_msg fw_msg;
+	void *data;
+	int indx;
+	int rc;
+
+	memset(&fw_msg, 0, sizeof(fw_msg));
+	bnxt_re_init_hwrm_hdr(rdev, (void *)&req,
+			      HWRM_QUEUE_COS2BW_CFG, -1, target_id);
+	req.port_id = (target_id == 0xFFFF) ? en_dev->pf_port_id : 1;
+
+	/* Chimp wants enable bit to retain previous
+	 * config done by L2 driver
+	 */
+	for (indx = 0; indx < 8; indx++) {
+		if (cfg[indx].queue_id < 40) {
+			req.enables |= cpu_to_le32(
+				HWRM_QUEUE_COS2BW_CFG_INPUT_ENABLES_COS_QUEUE_ID0_VALID <<
+				indx);
+		}
+
+		data = (char *)&req.unused_0 + indx * (sizeof(*cfg) - 4);
+		memcpy(data, &cfg[indx].queue_id, sizeof(*cfg) - 4);
+		if (indx == 0) {
+			req.queue_id0 = cfg[0].queue_id;
+			req.unused_0 = 0;
+		}
+	}
+
+	memset(&resp, 0, sizeof(resp));
+	bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
+			    sizeof(resp), DFLT_HWRM_CMD_TIMEOUT);
+	rc = en_dev->en_ops->bnxt_send_fw_msg(en_dev, BNXT_ROCE_ULP, &fw_msg);
+	return rc;
+}
+
+int bnxt_re_host_pf_id_query(struct bnxt_re_dev *rdev,
+			     struct bnxt_qplib_query_fn_info *fn_info,
+			     u32 *pf_mask, u32 *first_pf)
+{
+	struct hwrm_func_host_pf_ids_query_output resp = {0};
+	struct hwrm_func_host_pf_ids_query_input req;
+	struct bnxt_en_dev *en_dev = rdev->en_dev;
+	struct bnxt_fw_msg fw_msg;
+	int rc;
+
+	memset(&fw_msg, 0, sizeof(fw_msg));
+	memset(&req, 0, sizeof(req));
+	bnxt_re_init_hwrm_hdr(rdev, (void *)&req,
+			      HWRM_FUNC_HOST_PF_IDS_QUERY, -1, -1);
+	/* To query the info from the host EPs */
+	switch (fn_info->host) {
+		case HWRM_FUNC_HOST_PF_IDS_QUERY_INPUT_HOST_SOC:
+		case HWRM_FUNC_HOST_PF_IDS_QUERY_INPUT_HOST_EP_0:
+		case HWRM_FUNC_HOST_PF_IDS_QUERY_INPUT_HOST_EP_1:
+		case HWRM_FUNC_HOST_PF_IDS_QUERY_INPUT_HOST_EP_2:
+		case HWRM_FUNC_HOST_PF_IDS_QUERY_INPUT_HOST_EP_3:
+			req.host = fn_info->host;
+		break;
+		default:
+			req.host = HWRM_FUNC_HOST_PF_IDS_QUERY_INPUT_HOST_EP_0;
+		break;
+	}
+
+	req.filter = fn_info->filter;
+	if (req.filter > HWRM_FUNC_HOST_PF_IDS_QUERY_INPUT_FILTER_ROCE)
+		req.filter = HWRM_FUNC_HOST_PF_IDS_QUERY_INPUT_FILTER_ALL;
+
+	bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
+			    sizeof(resp), DFLT_HWRM_CMD_TIMEOUT);
+	rc = en_dev->en_ops->bnxt_send_fw_msg(en_dev, BNXT_ROCE_ULP, &fw_msg);
+
+
+	*first_pf = le16_to_cpu(resp.first_pf_id);
+	*pf_mask = le16_to_cpu(resp.pf_ordinal_mask);
+
+	return rc;
+}
+
+static void bnxt_re_put_stats_ctx(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_qplib_ctx *hctx;
+	struct bnxt_qplib_res *res;
+	u16 tid = 0xffff;
+
+	res = &rdev->qplib_res;
+	hctx = res->hctx;
+
+	if (test_and_clear_bit(BNXT_RE_FLAG_STATS_CTX_ALLOC, &rdev->flags)) {
+		bnxt_re_net_stats_ctx_free(rdev, hctx->stats.fw_id, tid);
+		bnxt_qplib_free_stat_mem(res, &hctx->stats);
+	}
+}
+
+static void bnxt_re_put_stats2_ctx(struct bnxt_re_dev *rdev)
+{
+	test_and_clear_bit(BNXT_RE_FLAG_STATS_CTX2_ALLOC, &rdev->flags);
+}
+
+static int bnxt_re_get_stats_ctx(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_qplib_ctx *hctx;
+	struct bnxt_qplib_res *res;
+	u16 tid = 0xffff;
+	int rc;
+
+	res = &rdev->qplib_res;
+	hctx = res->hctx;
+
+	rc = bnxt_qplib_alloc_stat_mem(res->pdev, rdev->chip_ctx, &hctx->stats);
+	if (rc)
+		return -ENOMEM;
+	rc = bnxt_re_net_stats_ctx_alloc(rdev, tid);
+	if (rc)
+		goto free_stat_mem;
+	set_bit(BNXT_RE_FLAG_STATS_CTX_ALLOC, &rdev->flags);
+
+	return 0;
+
+free_stat_mem:
+	bnxt_qplib_free_stat_mem(res, &hctx->stats);
+
+	return rc;
+}
+
+static int bnxt_re_update_dev_attr(struct bnxt_re_dev *rdev)
+{
+	int rc;
+
+	rc = bnxt_qplib_get_dev_attr(&rdev->rcfw);
+	if (rc)
+		return rc;
+	if (!bnxt_re_check_min_attr(rdev))
+		return -EINVAL;
+	return 0;
+}
+
+static void bnxt_re_free_tbls(struct bnxt_re_dev *rdev)
+{
+	bnxt_qplib_clear_tbls(&rdev->qplib_res);
+	bnxt_qplib_free_tbls(&rdev->qplib_res);
+}
+
+static int bnxt_re_alloc_init_tbls(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_qplib_chip_ctx *chip_ctx = rdev->chip_ctx;
+	u8 pppp_factor = 0;
+	int rc;
+
+	 /*
+	  * TODO: Need a better mechanism for spreading of the
+	  * 512 extended PPP pages. For now, spreading it
+	  * based on port_count
+	  */
+	if (_is_chip_p7(chip_ctx) && chip_ctx->modes.db_push)
+		pppp_factor = rdev->en_dev->port_count;
+	rc = bnxt_qplib_alloc_tbls(&rdev->qplib_res, pppp_factor);
+	if (rc)
+		return rc;
+	bnxt_qplib_init_tbls(&rdev->qplib_res);
+	set_bit(BNXT_RE_FLAG_TBLS_ALLOCINIT, &rdev->flags);
+
+	return 0;
+}
+
+static void bnxt_re_clean_nqs(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_qplib_nq *nq;
+	int i;
+
+	if (!rdev->nqr.max_init)
+		return;
+
+	for (i = (rdev->nqr.max_init - 1) ; i >= 0; i--) {
+		nq = &rdev->nqr.nq[i];
+		bnxt_qplib_disable_nq(nq);
+		bnxt_re_net_ring_free(rdev, nq->ring_id);
+		bnxt_qplib_free_nq_mem(nq);
+	}
+	rdev->nqr.max_init = 0;
+}
+
+static int bnxt_re_setup_nqs(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_re_ring_attr rattr = {};
+	struct bnxt_qplib_nq *nq;
+	int rc, i;
+	int depth;
+	u32 offt;
+	u16 vec;
+
+	mutex_init(&rdev->nqr.load_lock);
+	/*
+	 * TODO: Optimize the depth based on the
+	 * number of NQs.
+	 */
+	depth = BNXT_QPLIB_NQE_MAX_CNT;
+	for (i = 0; i < rdev->nqr.num_msix - 1; i++) {
+		nq = &rdev->nqr.nq[i];
+		vec = rdev->nqr.msix_entries[i + 1].vector;
+		offt = rdev->nqr.msix_entries[i + 1].db_offset;
+		nq->hwq.max_elements = depth;
+		rc = bnxt_qplib_alloc_nq_mem(&rdev->qplib_res, nq);
+		if (rc) {
+			dev_err(rdev_to_dev(rdev),
+				"Failed to get mem for NQ %d, rc = 0x%x",
+				i, rc);
+			goto fail_mem;
+		}
+
+		rattr.dma_arr = nq->hwq.pbl[PBL_LVL_0].pg_map_arr;
+		rattr.pages = nq->hwq.pbl[rdev->nqr.nq[i].hwq.level].pg_count;
+		rattr.type = bnxt_re_get_rtype(rdev);
+		rattr.mode = HWRM_RING_ALLOC_INPUT_INT_MODE_MSIX;
+		rattr.depth = nq->hwq.max_elements - 1;
+		rattr.lrid = rdev->nqr.msix_entries[i + 1].ring_idx;
+
+		/* Set DBR pacing capability on the first NQ ring only */
+		if (!i && bnxt_qplib_dbr_pacing_ext_en(rdev->chip_ctx))
+			rattr.flags = HWRM_RING_ALLOC_INPUT_FLAGS_NQ_DBR_PACING;
+		else
+			rattr.flags = 0;
+
+		rc = bnxt_re_net_ring_alloc(rdev, &rattr, &nq->ring_id);
+		if (rc) {
+			nq->ring_id = 0xffff; /* Invalid ring-id */
+			dev_err(rdev_to_dev(rdev),
+				"Failed to get fw id for NQ %d, rc = 0x%x",
+				i, rc);
+			goto fail_ring;
+		}
+
+		rc = bnxt_qplib_enable_nq(nq, i, vec, offt,
+					  &bnxt_re_cqn_handler,
+					  &bnxt_re_srqn_handler);
+		if (rc) {
+			dev_err(rdev_to_dev(rdev),
+				"Failed to enable NQ %d, rc = 0x%x", i, rc);
+			goto fail_en;
+		}
+	}
+
+	rdev->nqr.max_init = i;
+	return 0;
+fail_en:
+	/* *nq was i'th nq */
+	bnxt_re_net_ring_free(rdev, nq->ring_id);
+fail_ring:
+	bnxt_qplib_free_nq_mem(nq);
+fail_mem:
+	rdev->nqr.max_init = i;
+	return rc;
+}
+
+static void bnxt_re_sysfs_destroy_file(struct bnxt_re_dev *rdev)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(bnxt_re_attributes); i++)
+		device_remove_file(&rdev->ibdev.dev, bnxt_re_attributes[i]);
+}
+
+static int bnxt_re_sysfs_create_file(struct bnxt_re_dev *rdev)
+{
+	int i, j, rc = 0;
+
+	for (i = 0; i < ARRAY_SIZE(bnxt_re_attributes); i++) {
+		rc = device_create_file(&rdev->ibdev.dev,
+					bnxt_re_attributes[i]);
+		if (rc) {
+			dev_err(rdev_to_dev(rdev),
+				"Failed to create IB sysfs with rc = 0x%x", rc);
+			/* Must clean up all created device files */
+			for (j = 0; j < i; j++)
+				device_remove_file(&rdev->ibdev.dev,
+						   bnxt_re_attributes[j]);
+			clear_bit(BNXT_RE_FLAG_IBDEV_REGISTERED, &rdev->flags);
+			ib_unregister_device(&rdev->ibdev);
+			return 1;
+		}
+	}
+	return 0;
+}
+
+/* worker thread for polling periodic events. Now used for QoS programming*/
+static void bnxt_re_worker(struct work_struct *work)
+{
+	struct bnxt_re_dev *rdev = container_of(work, struct bnxt_re_dev,
+						worker.work);
+	int rc;
+
+	/* QoS is in 30s cadence for PFs*/
+	if (!rdev->is_virtfn && !rdev->worker_30s--)
+		rdev->worker_30s = 30;
+	/* Use trylock for  bnxt_re_dev_lock as this can be
+	 * held for long time by debugfs show path while issuing
+	 * HWRMS. If the debugfs name update is not done in this
+	 * iteration, the driver will check for the same in the
+	 * next schedule of the worker i.e after 1 sec.
+	 */
+	if (mutex_trylock(&bnxt_re_dev_lock))
+		mutex_unlock(&bnxt_re_dev_lock);
+
+	if (!rdev->stats.stats_query_sec)
+		goto resched;
+
+	if (test_bit(BNXT_RE_FLAG_ISSUE_CFA_FLOW_STATS, &rdev->flags) &&
+	    (rdev->is_virtfn ||
+	    !_is_ext_stats_supported(rdev->dev_attr->dev_cap_flags))) {
+		if (!(rdev->stats.stats_query_counter++ %
+		      rdev->stats.stats_query_sec)) {
+			rc = bnxt_re_get_qos_stats(rdev);
+			if (rc && rc != -ENOMEM)
+				clear_bit(BNXT_RE_FLAG_ISSUE_CFA_FLOW_STATS,
+					  &rdev->flags);
+			}
+	}
+
+resched:
+	schedule_delayed_work(&rdev->worker, msecs_to_jiffies(1000));
+}
+
+static int bnxt_re_alloc_dbr_sw_stats_mem(struct bnxt_re_dev *rdev)
+{
+	if (!(rdev->dbr_drop_recov || rdev->dbr_pacing))
+		return 0;
+
+	rdev->dbr_sw_stats = kzalloc(sizeof(*rdev->dbr_sw_stats), GFP_KERNEL);
+	if (!rdev->dbr_sw_stats)
+		return -ENOMEM;
+
+	return 0;
+}
+
+static void bnxt_re_free_dbr_sw_stats_mem(struct bnxt_re_dev *rdev)
+{
+	kfree(rdev->dbr_sw_stats);
+	rdev->dbr_sw_stats = NULL;
+}
+
+static int bnxt_re_initialize_dbr_drop_recov(struct bnxt_re_dev *rdev)
+{
+	rdev->dbr_drop_recov_wq =
+		create_singlethread_workqueue("bnxt_re_dbr_drop_recov");
+	if (!rdev->dbr_drop_recov_wq) {
+		dev_err(rdev_to_dev(rdev), "DBR Drop Revov wq alloc failed!");
+		return -EINVAL;
+	}
+	rdev->dbr_drop_recov = true;
+
+	/* Enable configfs setting dbr_drop_recov by default*/
+	rdev->user_dbr_drop_recov = true;
+
+	rdev->user_dbr_drop_recov_timeout = BNXT_RE_DBR_RECOV_USERLAND_TIMEOUT;
+	return 0;
+}
+
+static void bnxt_re_deinitialize_dbr_drop_recov(struct bnxt_re_dev *rdev)
+{
+	if (rdev->dbr_drop_recov_wq) {
+		flush_workqueue(rdev->dbr_drop_recov_wq);
+		destroy_workqueue(rdev->dbr_drop_recov_wq);
+		rdev->dbr_drop_recov_wq = NULL;
+	}
+	rdev->dbr_drop_recov = false;
+}
+
+static int bnxt_re_initialize_dbr_pacing(struct bnxt_re_dev *rdev)
+{
+	int rc;
+
+	/* Allocate a page for app use */
+	rdev->dbr_page = (void *)__get_free_page(GFP_KERNEL);
+	if (!rdev->dbr_page) {
+		dev_err(rdev_to_dev(rdev), "DBR page allocation failed!");
+		return -ENOMEM;
+	}
+	memset((u8 *)rdev->dbr_page, 0, PAGE_SIZE);
+	rdev->qplib_res.pacing_data = (struct bnxt_qplib_db_pacing_data *)rdev->dbr_page;
+	rc = bnxt_re_hwrm_dbr_pacing_qcfg(rdev);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev),
+			"Failed to query dbr pacing config %d\n", rc);
+		goto fail;
+	}
+	/* Create a work queue for scheduling dbq event */
+	rdev->dbq_wq = create_singlethread_workqueue("bnxt_re_dbq");
+	if (!rdev->dbq_wq) {
+		dev_err(rdev_to_dev(rdev), "DBQ wq alloc failed!");
+		rc = -ENOMEM;
+		goto fail;
+	}
+	/* MAP grc window 2 for reading db fifo depth */
+	writel_fbsd(rdev->en_dev->softc,  BNXT_GRCPF_REG_WINDOW_BASE_OUT + 4, 0,
+			rdev->chip_ctx->dbr_stat_db_fifo & BNXT_GRC_BASE_MASK);
+	rdev->dbr_db_fifo_reg_off =
+		(rdev->chip_ctx->dbr_stat_db_fifo & BNXT_GRC_OFFSET_MASK) +
+		0x2000;
+	rdev->qplib_res.pacing_data->grc_reg_offset = rdev->dbr_db_fifo_reg_off;
+
+	rdev->dbr_bar_addr =
+		pci_resource_start(rdev->qplib_res.pdev, 0) +
+		rdev->dbr_db_fifo_reg_off;
+
+	/* Percentage of DB FIFO */
+	rdev->dbq_watermark = BNXT_RE_PACING_DBQ_THRESHOLD;
+	rdev->pacing_en_int_th = BNXT_RE_PACING_EN_INT_THRESHOLD;
+	rdev->pacing_algo_th = BNXT_RE_PACING_ALGO_THRESHOLD;
+	rdev->dbq_pacing_time = BNXT_RE_DBR_INT_TIME;
+	rdev->dbr_def_do_pacing = BNXT_RE_DBR_DO_PACING_NO_CONGESTION;
+	rdev->do_pacing_save = rdev->dbr_def_do_pacing;
+	bnxt_re_set_default_pacing_data(rdev);
+	dev_dbg(rdev_to_dev(rdev), "Initialized db pacing\n");
+
+	return 0;
+fail:
+	free_page((u64)rdev->dbr_page);
+	rdev->dbr_page = NULL;
+	return rc;
+}
+
+static void bnxt_re_deinitialize_dbr_pacing(struct bnxt_re_dev *rdev)
+{
+	if (rdev->dbq_wq)
+		flush_workqueue(rdev->dbq_wq);
+
+	cancel_work_sync(&rdev->dbq_fifo_check_work);
+	cancel_delayed_work_sync(&rdev->dbq_pacing_work);
+
+	if (rdev->dbq_wq) {
+		destroy_workqueue(rdev->dbq_wq);
+		rdev->dbq_wq = NULL;
+	}
+
+	if (rdev->dbr_page)
+		free_page((u64)rdev->dbr_page);
+	rdev->dbr_page = NULL;
+	rdev->dbr_pacing = false;
+}
+
+/* enable_dbr_pacing needs to be done only for older FWs
+ * where host selects primary function. ie. pacing_ext
+ * flags is not set.
+ */
+int bnxt_re_enable_dbr_pacing(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_qplib_nq *nq;
+
+	nq = &rdev->nqr.nq[0];
+	rdev->dbq_nq_id = nq->ring_id;
+
+	if (!bnxt_qplib_dbr_pacing_ext_en(rdev->chip_ctx) &&
+	    bnxt_qplib_dbr_pacing_is_primary_pf(rdev->chip_ctx)) {
+		if (bnxt_re_hwrm_dbr_pacing_cfg(rdev, true)) {
+			dev_err(rdev_to_dev(rdev),
+					"Failed to set dbr pacing config\n");
+			return -EIO;
+		}
+		/* MAP grc window 8 for ARMing the NQ DBQ */
+		writel_fbsd(rdev->en_dev->softc, BNXT_GRCPF_REG_WINDOW_BASE_OUT + 28 , 0,
+			    rdev->chip_ctx->dbr_aeq_arm_reg & BNXT_GRC_BASE_MASK);
+		rdev->dbr_aeq_arm_reg_off =
+			(rdev->chip_ctx->dbr_aeq_arm_reg &
+			 BNXT_GRC_OFFSET_MASK) + 0x8000;
+		writel_fbsd(rdev->en_dev->softc, rdev->dbr_aeq_arm_reg_off , 0, 1);
+	}
+
+	return 0;
+}
+
+/* disable_dbr_pacing needs to be done only for older FWs
+ * where host selects primary function. ie. pacing_ext
+ * flags is not set.
+ */
+
+int bnxt_re_disable_dbr_pacing(struct bnxt_re_dev *rdev)
+{
+	int rc = 0;
+
+	if (!bnxt_qplib_dbr_pacing_ext_en(rdev->chip_ctx) &&
+	    bnxt_qplib_dbr_pacing_is_primary_pf(rdev->chip_ctx))
+		rc = bnxt_re_hwrm_dbr_pacing_cfg(rdev, false);
+
+	return rc;
+}
+
+static void bnxt_re_ib_uninit(struct bnxt_re_dev *rdev)
+{
+	if (test_bit(BNXT_RE_FLAG_IBDEV_REGISTERED, &rdev->flags)) {
+		bnxt_re_sysfs_destroy_file(rdev);
+		/* Cleanup ib dev */
+		ib_unregister_device(&rdev->ibdev);
+		clear_bit(BNXT_RE_FLAG_IBDEV_REGISTERED, &rdev->flags);
+		return;
+	}
+}
+
+static void bnxt_re_dev_uninit(struct bnxt_re_dev *rdev, u8 op_type)
+{
+	struct bnxt_qplib_dpi *kdpi;
+	int rc, wait_count = BNXT_RE_RES_FREE_WAIT_COUNT;
+
+	bnxt_re_net_unregister_async_event(rdev);
+
+	bnxt_re_put_stats2_ctx(rdev);
+	if (test_and_clear_bit(BNXT_RE_FLAG_DEV_LIST_INITIALIZED,
+			       &rdev->flags)) {
+		/* did the caller hold the lock? */
+		mutex_lock(&bnxt_re_dev_lock);
+		list_del_rcu(&rdev->list);
+		mutex_unlock(&bnxt_re_dev_lock);
+	}
+
+	bnxt_re_uninit_resolve_wq(rdev);
+	bnxt_re_uninit_dcb_wq(rdev);
+	bnxt_re_uninit_aer_wq(rdev);
+
+	bnxt_re_deinitialize_dbr_drop_recov(rdev);
+
+	if (bnxt_qplib_dbr_pacing_en(rdev->chip_ctx))
+		(void)bnxt_re_disable_dbr_pacing(rdev);
+
+	if (test_and_clear_bit(BNXT_RE_FLAG_WORKER_REG, &rdev->flags)) {
+		cancel_delayed_work_sync(&rdev->worker);
+	}
+
+	/* Wait for ULPs to release references */
+	while (atomic_read(&rdev->stats.rsors.cq_count) && --wait_count)
+		usleep_range(500, 1000);
+	if (!wait_count)
+		dev_err(rdev_to_dev(rdev),
+			"CQ resources not freed by stack, count = 0x%x",
+			atomic_read(&rdev->stats.rsors.cq_count));
+
+	kdpi = &rdev->dpi_privileged;
+	if (kdpi->umdbr) { /* kernel DPI was allocated with success */
+		(void)bnxt_qplib_dealloc_dpi(&rdev->qplib_res, kdpi);
+		/*
+		 * Driver just need to know no command had failed
+		 * during driver load sequence and below command is
+		 * required indeed. Piggybacking dpi allocation status.
+		 */
+	}
+
+	/* Protect the device uninitialization and start_irq/stop_irq L2
+	 * callbacks with rtnl lock to avoid race condition between these calls
+	 */
+	rtnl_lock();
+	if (test_and_clear_bit(BNXT_RE_FLAG_SETUP_NQ, &rdev->flags))
+		bnxt_re_clean_nqs(rdev);
+	rtnl_unlock();
+
+	if (test_and_clear_bit(BNXT_RE_FLAG_TBLS_ALLOCINIT, &rdev->flags))
+		bnxt_re_free_tbls(rdev);
+	if (test_and_clear_bit(BNXT_RE_FLAG_RCFW_CHANNEL_INIT, &rdev->flags)) {
+		rc = bnxt_qplib_deinit_rcfw(&rdev->rcfw);
+		if (rc)
+			dev_warn(rdev_to_dev(rdev),
+				 "Failed to deinitialize fw, rc = 0x%x", rc);
+	}
+
+	bnxt_re_put_stats_ctx(rdev);
+
+	if (test_and_clear_bit(BNXT_RE_FLAG_ALLOC_CTX, &rdev->flags))
+		bnxt_qplib_free_hwctx(&rdev->qplib_res);
+
+	rtnl_lock();
+	if (test_and_clear_bit(BNXT_RE_FLAG_RCFW_CHANNEL_EN, &rdev->flags))
+		bnxt_qplib_disable_rcfw_channel(&rdev->rcfw);
+
+	if (rdev->dbr_pacing)
+		bnxt_re_deinitialize_dbr_pacing(rdev);
+
+	bnxt_re_free_dbr_sw_stats_mem(rdev);
+
+	if (test_and_clear_bit(BNXT_RE_FLAG_NET_RING_ALLOC, &rdev->flags))
+		bnxt_re_net_ring_free(rdev, rdev->rcfw.creq.ring_id);
+
+	if (test_and_clear_bit(BNXT_RE_FLAG_ALLOC_RCFW, &rdev->flags))
+		bnxt_qplib_free_rcfw_channel(&rdev->qplib_res);
+
+	if (test_and_clear_bit(BNXT_RE_FLAG_GOT_MSIX, &rdev->flags))
+		bnxt_re_free_msix(rdev);
+	rtnl_unlock();
+
+	bnxt_re_destroy_chip_ctx(rdev);
+
+	if (op_type != BNXT_RE_PRE_RECOVERY_REMOVE) {
+		if (test_and_clear_bit(BNXT_RE_FLAG_NETDEV_REGISTERED,
+				       &rdev->flags))
+			bnxt_re_unregister_netdev(rdev);
+	}
+}
+
+static int bnxt_re_dev_init(struct bnxt_re_dev *rdev, u8 op_type, u8 wqe_mode)
+{
+	struct bnxt_re_ring_attr rattr = {};
+	struct bnxt_qplib_creq_ctx *creq;
+	int vec, offset;
+	int rc = 0;
+
+	if (op_type != BNXT_RE_POST_RECOVERY_INIT) {
+		/* Registered a new RoCE device instance to netdev */
+		rc = bnxt_re_register_netdev(rdev);
+		if (rc)
+			return -EINVAL;
+	}
+	set_bit(BNXT_RE_FLAG_NETDEV_REGISTERED, &rdev->flags);
+
+	rc = bnxt_re_setup_chip_ctx(rdev, wqe_mode);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev), "Failed to get chip context rc 0x%x", rc);
+		bnxt_re_unregister_netdev(rdev);
+		clear_bit(BNXT_RE_FLAG_NETDEV_REGISTERED, &rdev->flags);
+		rc = -EINVAL;
+		return rc;
+	}
+
+	/* Protect the device initialization and start_irq/stop_irq L2 callbacks
+	 * with rtnl lock to avoid race condition between these calls
+	 */
+	rtnl_lock();
+	rc = bnxt_re_request_msix(rdev);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev),
+			"Requesting MSI-X vectors failed with rc = 0x%x", rc);
+		rc = -EINVAL;
+		goto release_rtnl;
+	}
+	set_bit(BNXT_RE_FLAG_GOT_MSIX, &rdev->flags);
+
+	/* Establish RCFW Communication Channel to initialize the context
+	   memory for the function and all child VFs */
+	rc = bnxt_qplib_alloc_rcfw_channel(&rdev->qplib_res);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev),
+			"Failed to alloc mem for rcfw, rc = %#x\n", rc);
+		goto release_rtnl;
+	}
+	set_bit(BNXT_RE_FLAG_ALLOC_RCFW, &rdev->flags);
+
+	creq = &rdev->rcfw.creq;
+	rattr.dma_arr = creq->hwq.pbl[PBL_LVL_0].pg_map_arr;
+	rattr.pages = creq->hwq.pbl[creq->hwq.level].pg_count;
+	rattr.type = bnxt_re_get_rtype(rdev);
+	rattr.mode = HWRM_RING_ALLOC_INPUT_INT_MODE_MSIX;
+	rattr.depth = BNXT_QPLIB_CREQE_MAX_CNT - 1;
+	rattr.lrid = rdev->nqr.msix_entries[BNXT_RE_AEQ_IDX].ring_idx;
+	rc = bnxt_re_net_ring_alloc(rdev, &rattr, &creq->ring_id);
+	if (rc) {
+		creq->ring_id = 0xffff;
+		dev_err(rdev_to_dev(rdev),
+			"Failed to allocate CREQ fw id with rc = 0x%x", rc);
+		goto release_rtnl;
+	}
+
+	if (!rdev->chip_ctx)
+		goto release_rtnl;
+	/* Program the NQ ID for DBQ notification */
+	if (rdev->chip_ctx->modes.dbr_pacing_v0 ||
+	    bnxt_qplib_dbr_pacing_en(rdev->chip_ctx) ||
+	    bnxt_qplib_dbr_pacing_ext_en(rdev->chip_ctx)) {
+		rc = bnxt_re_initialize_dbr_pacing(rdev);
+		if (!rc)
+			rdev->dbr_pacing = true;
+		else
+			rdev->dbr_pacing = false;
+		dev_dbg(rdev_to_dev(rdev), "%s: initialize db pacing ret %d\n",
+			__func__, rc);
+	}
+
+	vec = rdev->nqr.msix_entries[BNXT_RE_AEQ_IDX].vector;
+	offset = rdev->nqr.msix_entries[BNXT_RE_AEQ_IDX].db_offset;
+	rc = bnxt_qplib_enable_rcfw_channel(&rdev->rcfw, vec, offset,
+					    &bnxt_re_aeq_handler);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev),
+			"Failed to enable RCFW channel with rc = 0x%x", rc);
+		goto release_rtnl;
+	}
+	set_bit(BNXT_RE_FLAG_RCFW_CHANNEL_EN, &rdev->flags);
+
+	rc = bnxt_re_update_dev_attr(rdev);
+	if (rc)
+		goto release_rtnl;
+	bnxt_re_set_resource_limits(rdev);
+	if (!rdev->is_virtfn && !_is_chip_gen_p5_p7(rdev->chip_ctx)) {
+		rc = bnxt_qplib_alloc_hwctx(&rdev->qplib_res);
+		if (rc) {
+			dev_err(rdev_to_dev(rdev),
+				"Failed to alloc hw contexts, rc = 0x%x", rc);
+			goto release_rtnl;
+		}
+		set_bit(BNXT_RE_FLAG_ALLOC_CTX, &rdev->flags);
+	}
+
+	rc = bnxt_re_get_stats_ctx(rdev);
+	if (rc)
+		goto release_rtnl;
+
+	rc = bnxt_qplib_init_rcfw(&rdev->rcfw, rdev->is_virtfn);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev),
+			"Failed to initialize fw with rc = 0x%x", rc);
+		goto release_rtnl;
+	}
+	set_bit(BNXT_RE_FLAG_RCFW_CHANNEL_INIT, &rdev->flags);
+
+	/* Based resource count on the 'new' device caps */
+	rc = bnxt_re_update_dev_attr(rdev);
+	if (rc)
+		goto release_rtnl;
+	rc = bnxt_re_alloc_init_tbls(rdev);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev), "tbls alloc-init failed rc = %#x",
+			rc);
+		goto release_rtnl;
+	}
+	rc = bnxt_re_setup_nqs(rdev);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev), "NQs alloc-init failed rc = %#x\n",
+			rc);
+		if (rdev->nqr.max_init == 0)
+			goto release_rtnl;
+
+		dev_warn(rdev_to_dev(rdev),
+			"expected nqs %d available nqs %d\n",
+			rdev->nqr.num_msix, rdev->nqr.max_init);
+	}
+	set_bit(BNXT_RE_FLAG_SETUP_NQ, &rdev->flags);
+	rtnl_unlock();
+
+	rc = bnxt_qplib_alloc_dpi(&rdev->qplib_res, &rdev->dpi_privileged,
+				  rdev, BNXT_QPLIB_DPI_TYPE_KERNEL);
+	if (rc)
+		goto fail;
+
+	if (rdev->dbr_pacing)
+		bnxt_re_enable_dbr_pacing(rdev);
+
+	if (rdev->chip_ctx->modes.dbr_drop_recov)
+		bnxt_re_initialize_dbr_drop_recov(rdev);
+
+	rc = bnxt_re_alloc_dbr_sw_stats_mem(rdev);
+	if (rc)
+		goto fail;
+
+	/* This block of code is needed for error recovery support */
+	if (!rdev->is_virtfn) {
+		struct bnxt_re_tc_rec *tc_rec;
+
+		tc_rec = &rdev->tc_rec[0];
+		rc =  bnxt_re_query_hwrm_qportcfg(rdev, tc_rec, 0xFFFF);
+		if (rc) {
+			dev_err(rdev_to_dev(rdev),
+				"Failed to query port config rc:%d", rc);
+			return rc;
+		}
+
+		/* Query f/w defaults of CC params */
+		rc = bnxt_qplib_query_cc_param(&rdev->qplib_res, &rdev->cc_param);
+		if (rc)
+			dev_warn(rdev_to_dev(rdev),
+				"Failed to query CC defaults\n");
+		if (1) {
+			rdev->num_vfs = pci_num_vf(rdev->en_dev->pdev);
+			if (rdev->num_vfs) {
+				bnxt_re_set_resource_limits(rdev);
+				bnxt_qplib_set_func_resources(&rdev->qplib_res);
+			}
+		}
+	}
+	INIT_DELAYED_WORK(&rdev->worker, bnxt_re_worker);
+	set_bit(BNXT_RE_FLAG_WORKER_REG, &rdev->flags);
+	schedule_delayed_work(&rdev->worker, msecs_to_jiffies(1000));
+
+	bnxt_re_init_dcb_wq(rdev);
+	bnxt_re_init_aer_wq(rdev);
+	bnxt_re_init_resolve_wq(rdev);
+	mutex_lock(&bnxt_re_dev_lock);
+	list_add_tail_rcu(&rdev->list, &bnxt_re_dev_list);
+	/* Added to the list, not in progress anymore */
+	gadd_dev_inprogress--;
+	set_bit(BNXT_RE_FLAG_DEV_LIST_INITIALIZED, &rdev->flags);
+	mutex_unlock(&bnxt_re_dev_lock);
+
+
+	return rc;
+release_rtnl:
+	rtnl_unlock();
+fail:
+	bnxt_re_dev_uninit(rdev, BNXT_RE_COMPLETE_REMOVE);
+
+	return rc;
+}
+
+static int bnxt_re_ib_init(struct bnxt_re_dev *rdev)
+{
+	int rc = 0;
+
+	rc = bnxt_re_register_ib(rdev);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev),
+			"Register IB failed with rc = 0x%x", rc);
+		goto fail;
+	}
+	if (bnxt_re_sysfs_create_file(rdev)) {
+		bnxt_re_stopqps_and_ib_uninit(rdev);
+		goto fail;
+	}
+
+	set_bit(BNXT_RE_FLAG_IBDEV_REGISTERED, &rdev->flags);
+	set_bit(BNXT_RE_FLAG_ISSUE_ROCE_STATS, &rdev->flags);
+	set_bit(BNXT_RE_FLAG_ISSUE_CFA_FLOW_STATS, &rdev->flags);
+	bnxt_re_dispatch_event(&rdev->ibdev, NULL, 1, IB_EVENT_PORT_ACTIVE);
+	bnxt_re_dispatch_event(&rdev->ibdev, NULL, 1, IB_EVENT_GID_CHANGE);
+
+	return rc;
+fail:
+	bnxt_re_dev_uninit(rdev, BNXT_RE_COMPLETE_REMOVE);
+	return rc;
+}
+
+/* wrapper for ib_init funcs */
+int _bnxt_re_ib_init(struct bnxt_re_dev *rdev)
+{
+	return bnxt_re_ib_init(rdev);
+}
+
+/* wrapper for aux init funcs */
+int _bnxt_re_ib_init2(struct bnxt_re_dev *rdev)
+{
+	bnxt_re_ib_init_2(rdev);
+	return 0; /* add return for future proof */
+}
+
+static void bnxt_re_dev_unreg(struct bnxt_re_dev *rdev)
+{
+	bnxt_re_dev_dealloc(rdev);
+}
+
+
+static int bnxt_re_dev_reg(struct bnxt_re_dev **rdev, struct ifnet *netdev,
+			   struct bnxt_en_dev *en_dev)
+{
+	struct ifnet *realdev = NULL;
+
+	realdev = netdev;
+	if (realdev)
+		dev_dbg(NULL, "%s: realdev = %p netdev = %p\n", __func__,
+			realdev, netdev);
+	/*
+	 * Note:
+	 * The first argument to bnxt_re_dev_alloc() is 'netdev' and
+	 * not 'realdev', since in the case of bonding we want to
+	 * register the bonded virtual netdev (master) to the ib stack.
+	 * And 'en_dev' (for L2/PCI communication) is the first slave
+	 * device (PF0 on the card).
+	 * In the case of a regular netdev, both netdev and the en_dev
+	 * correspond to the same device.
+	 */
+	*rdev = bnxt_re_dev_alloc(netdev, en_dev);
+	if (!*rdev) {
+		pr_err("%s: netdev %p not handled",
+			ROCE_DRV_MODULE_NAME, netdev);
+		return -ENOMEM;
+	}
+	bnxt_re_hold(*rdev);
+
+	return 0;
+}
+
+void bnxt_re_get_link_speed(struct bnxt_re_dev *rdev)
+{
+	rdev->espeed = rdev->en_dev->espeed;
+	return;
+}
+
+void bnxt_re_stopqps_and_ib_uninit(struct bnxt_re_dev *rdev)
+{
+	dev_dbg(rdev_to_dev(rdev), "%s: Stopping QPs, IB uninit on rdev: %p\n",
+		__func__, rdev);
+	bnxt_re_stop_all_nonqp1_nonshadow_qps(rdev);
+	bnxt_re_ib_uninit(rdev);
+}
+
+void bnxt_re_remove_device(struct bnxt_re_dev *rdev, u8 op_type,
+			   struct auxiliary_device *aux_dev)
+{
+	struct bnxt_re_en_dev_info *en_info;
+	struct bnxt_qplib_cmdq_ctx *cmdq;
+	struct bnxt_qplib_rcfw *rcfw;
+
+	rcfw = &rdev->rcfw;
+	cmdq = &rcfw->cmdq;
+	if (test_bit(FIRMWARE_STALL_DETECTED, &cmdq->flags))
+		set_bit(BNXT_RE_FLAG_ERR_DEVICE_DETACHED, &rdev->flags);
+
+	dev_dbg(rdev_to_dev(rdev), "%s: Removing rdev: %p\n", __func__, rdev);
+	bnxt_re_dev_uninit(rdev, op_type);
+	en_info = auxiliary_get_drvdata(aux_dev);
+	if (en_info) {
+		rtnl_lock();
+		en_info->rdev = NULL;
+		rtnl_unlock();
+		if (op_type != BNXT_RE_PRE_RECOVERY_REMOVE) {
+			clear_bit(BNXT_RE_FLAG_EN_DEV_PRIMARY_DEV, &en_info->flags);
+			clear_bit(BNXT_RE_FLAG_EN_DEV_SECONDARY_DEV, &en_info->flags);
+			clear_bit(BNXT_RE_FLAG_EN_DEV_NETDEV_REG, &en_info->flags);
+		}
+	}
+	bnxt_re_dev_unreg(rdev);
+}
+
+int bnxt_re_add_device(struct bnxt_re_dev **rdev,
+		       struct ifnet *netdev,
+		       u8 qp_mode, u8 op_type, u8 wqe_mode,
+		       u32 num_msix_requested,
+		       struct auxiliary_device *aux_dev)
+{
+	struct bnxt_re_en_dev_info *en_info;
+	struct bnxt_en_dev *en_dev;
+	int rc = 0;
+
+	en_info = auxiliary_get_drvdata(aux_dev);
+	en_dev = en_info->en_dev;
+
+	mutex_lock(&bnxt_re_dev_lock);
+	/* Check if driver already in mod exit and aux_dev is valid */
+	if (gmod_exit || !aux_dev) {
+		mutex_unlock(&bnxt_re_dev_lock);
+		return -ENODEV;
+	}
+	/* Add device in progress */
+	gadd_dev_inprogress++;
+	mutex_unlock(&bnxt_re_dev_lock);
+
+	rc = bnxt_re_dev_reg(rdev, netdev, en_dev);
+	if (rc) {
+		dev_dbg(NULL, "Failed to create add device for netdev %p\n",
+			netdev);
+		/*
+		 * For BNXT_RE_POST_RECOVERY_INIT special case
+		 * called from bnxt_re_start, the work is
+		 * complete only after, bnxt_re_start completes
+		 * bnxt_unregister_device in case of failure.
+		 * So bnxt_re_start will decrement gadd_dev_inprogress
+		 * in case of failure.
+		 */
+		if (op_type != BNXT_RE_POST_RECOVERY_INIT) {
+			mutex_lock(&bnxt_re_dev_lock);
+			gadd_dev_inprogress--;
+			mutex_unlock(&bnxt_re_dev_lock);
+		}
+		return rc;
+	}
+
+	if (rc != 0)
+		goto ref_error;
+
+	/*
+	 *  num_msix_requested = BNXT_RE_MSIX_FROM_MOD_PARAM indicates fresh driver load.
+	 *  Otherwaise, this invocation can be the result of lag create / destroy,
+	 *  err revovery, hot fw upgrade, etc..
+	 */
+	if (num_msix_requested == BNXT_RE_MSIX_FROM_MOD_PARAM) {
+		if (bnxt_re_probe_count < BNXT_RE_MAX_DEVICES)
+			num_msix_requested = max_msix_vec[bnxt_re_probe_count++];
+		else
+			/* Consider as default when probe_count exceeds its limit */
+			num_msix_requested = 0;
+
+		/* if user specifies only one value, use the same for all PFs */
+		if (max_msix_vec_argc == 1)
+			num_msix_requested = max_msix_vec[0];
+	}
+
+	(*rdev)->num_msix_requested = num_msix_requested;
+	(*rdev)->gsi_ctx.gsi_qp_mode = qp_mode;
+	(*rdev)->adev = aux_dev;
+	(*rdev)->dev_addr = en_dev->softc->func.mac_addr;
+	/* Before updating the rdev pointer in bnxt_re_en_dev_info structure,
+	 * take the rtnl lock to avoid accessing invalid rdev pointer from
+	 * L2 ULP callbacks. This is applicable in all the places where rdev
+	 * pointer is updated in bnxt_re_en_dev_info.
+	 */
+	rtnl_lock();
+	en_info->rdev = *rdev;
+	rtnl_unlock();
+	rc = bnxt_re_dev_init(*rdev, op_type, wqe_mode);
+	if (rc) {
+ref_error:
+		bnxt_re_dev_unreg(*rdev);
+		*rdev = NULL;
+		/*
+		 * For BNXT_RE_POST_RECOVERY_INIT special case
+		 * called from bnxt_re_start, the work is
+		 * complete only after, bnxt_re_start completes
+		 * bnxt_unregister_device in case of failure.
+		 * So bnxt_re_start will decrement gadd_dev_inprogress
+		 * in case of failure.
+		 */
+		if (op_type != BNXT_RE_POST_RECOVERY_INIT) {
+			mutex_lock(&bnxt_re_dev_lock);
+			gadd_dev_inprogress--;
+			mutex_unlock(&bnxt_re_dev_lock);
+		}
+	}
+	dev_dbg(rdev_to_dev(*rdev), "%s: Adding rdev: %p\n", __func__, *rdev);
+	if (!rc) {
+		set_bit(BNXT_RE_FLAG_EN_DEV_NETDEV_REG, &en_info->flags);
+	}
+	return rc;
+}
+
+struct bnxt_re_dev *bnxt_re_get_peer_pf(struct bnxt_re_dev *rdev)
+{
+	struct pci_dev *pdev_in = rdev->en_dev->pdev;
+	int tmp_bus_num, bus_num = pdev_in->bus->number;
+	int tmp_dev_num, dev_num = PCI_SLOT(pdev_in->devfn);
+	int tmp_func_num, func_num = PCI_FUNC(pdev_in->devfn);
+	struct bnxt_re_dev *tmp_rdev;
+
+	rcu_read_lock();
+	list_for_each_entry_rcu(tmp_rdev, &bnxt_re_dev_list, list) {
+		tmp_bus_num = tmp_rdev->en_dev->pdev->bus->number;
+		tmp_dev_num = PCI_SLOT(tmp_rdev->en_dev->pdev->devfn);
+		tmp_func_num = PCI_FUNC(tmp_rdev->en_dev->pdev->devfn);
+
+		if (bus_num == tmp_bus_num && dev_num == tmp_dev_num &&
+		    func_num != tmp_func_num) {
+			rcu_read_unlock();
+			return tmp_rdev;
+		}
+	}
+	rcu_read_unlock();
+	return NULL;
+}
+
+
+int bnxt_re_schedule_work(struct bnxt_re_dev *rdev, unsigned long event,
+			  struct ifnet *vlan_dev,
+			  struct ifnet *netdev,
+			  struct auxiliary_device *adev)
+{
+	struct bnxt_re_work *re_work;
+
+	/* Allocate for the deferred task */
+	re_work = kzalloc(sizeof(*re_work), GFP_KERNEL);
+	if (!re_work)
+		return -ENOMEM;
+
+	re_work->rdev = rdev;
+	re_work->event = event;
+	re_work->vlan_dev = vlan_dev;
+	re_work->adev = adev;
+	INIT_WORK(&re_work->work, bnxt_re_task);
+	if (rdev)
+		atomic_inc(&rdev->sched_count);
+	re_work->netdev = netdev;
+	queue_work(bnxt_re_wq, &re_work->work);
+
+	return 0;
+}
+
+
+int bnxt_re_get_slot_pf_count(struct bnxt_re_dev *rdev)
+{
+	struct pci_dev *pdev_in = rdev->en_dev->pdev;
+	int tmp_bus_num, bus_num = pdev_in->bus->number;
+	int tmp_dev_num, dev_num = PCI_SLOT(pdev_in->devfn);
+	struct bnxt_re_dev *tmp_rdev;
+	int pf_cnt = 0;
+
+	rcu_read_lock();
+	list_for_each_entry_rcu(tmp_rdev, &bnxt_re_dev_list, list) {
+		tmp_bus_num = tmp_rdev->en_dev->pdev->bus->number;
+		tmp_dev_num = PCI_SLOT(tmp_rdev->en_dev->pdev->devfn);
+
+		if (bus_num == tmp_bus_num && dev_num == tmp_dev_num)
+			pf_cnt++;
+	}
+	rcu_read_unlock();
+	return pf_cnt;
+}
+
+/* Handle all deferred netevents tasks */
+static void bnxt_re_task(struct work_struct *work)
+{
+	struct bnxt_re_en_dev_info *en_info;
+	struct auxiliary_device *aux_dev;
+	struct bnxt_re_work *re_work;
+	struct bnxt_re_dev *rdev;
+
+	re_work = container_of(work, struct bnxt_re_work, work);
+
+	mutex_lock(&bnxt_re_mutex);
+	rdev = re_work->rdev;
+
+	/*
+	 * If the previous rdev is deleted due to bond creation
+	 * do not handle the event
+	 */
+	if (!bnxt_re_is_rdev_valid(rdev))
+		goto exit;
+
+	/* Ignore the event, if the device is not registred with IB stack. This
+	 * is to avoid handling any event while the device is added/removed.
+	 */
+	if (rdev && !test_bit(BNXT_RE_FLAG_IBDEV_REGISTERED, &rdev->flags)) {
+		dev_dbg(rdev_to_dev(rdev), "%s: Ignoring netdev event 0x%lx",
+			__func__, re_work->event);
+		goto done;
+	}
+
+	/* Extra check to silence coverity. We shouldn't handle any event
+	 * when rdev is NULL.
+	 */
+	if (!rdev)
+		goto exit;
+
+	dev_dbg(rdev_to_dev(rdev), "Scheduled work for event 0x%lx",
+		re_work->event);
+
+	switch (re_work->event) {
+	case NETDEV_UP:
+		bnxt_re_dispatch_event(&rdev->ibdev, NULL, 1,
+				       IB_EVENT_PORT_ACTIVE);
+		bnxt_re_net_register_async_event(rdev);
+		break;
+
+	case NETDEV_DOWN:
+		bnxt_qplib_dbr_pacing_set_primary_pf(rdev->chip_ctx, 0);
+		bnxt_re_stop_all_nonqp1_nonshadow_qps(rdev);
+		bnxt_re_dispatch_event(&rdev->ibdev, NULL, 1,
+				       IB_EVENT_PORT_ERR);
+		break;
+
+	case NETDEV_CHANGE:
+		if (bnxt_re_get_link_state(rdev) == IB_PORT_DOWN) {
+			bnxt_re_stop_all_nonqp1_nonshadow_qps(rdev);
+			bnxt_re_dispatch_event(&rdev->ibdev, NULL, 1,
+					       IB_EVENT_PORT_ERR);
+			break;
+		} else if (bnxt_re_get_link_state(rdev) == IB_PORT_ACTIVE) {
+			bnxt_re_dispatch_event(&rdev->ibdev, NULL, 1,
+					       IB_EVENT_PORT_ACTIVE);
+		}
+
+		/* temporarily disable the check for SR2 */
+		if (!bnxt_qplib_query_cc_param(&rdev->qplib_res,
+					       &rdev->cc_param) &&
+		    !_is_chip_p7(rdev->chip_ctx)) {
+			/*
+			 *  Disable CC for 10G speed
+			 * for non p5 devices
+			 */
+			if (rdev->sl_espeed == SPEED_10000 &&
+			    !_is_chip_gen_p5_p7(rdev->chip_ctx)) {
+				if (rdev->cc_param.enable)
+					bnxt_re_clear_cc(rdev);
+			} else {
+				if (!rdev->cc_param.enable &&
+				    rdev->cc_param.admin_enable)
+					bnxt_re_setup_cc(rdev);
+			}
+		}
+		break;
+
+	case NETDEV_UNREGISTER:
+		bnxt_re_stopqps_and_ib_uninit(rdev);
+		aux_dev = rdev->adev;
+		if (re_work->adev)
+			goto done;
+
+		bnxt_re_remove_device(rdev, BNXT_RE_COMPLETE_REMOVE, aux_dev);
+
+		break;
+
+	default:
+		break;
+	}
+done:
+	if (rdev) {
+		/* memory barrier to guarantee task completion
+		 * before decrementing sched count
+		 */
+		mmiowb();
+		atomic_dec(&rdev->sched_count);
+	}
+exit:
+	if (re_work->adev && re_work->event == NETDEV_UNREGISTER) {
+		en_info = auxiliary_get_drvdata(re_work->adev);
+		en_info->ib_uninit_done = true;
+		wake_up(&en_info->waitq);
+	}
+	kfree(re_work);
+	mutex_unlock(&bnxt_re_mutex);
+}
+
+/*
+    "Notifier chain callback can be invoked for the same chain from
+    different CPUs at the same time".
+
+    For cases when the netdev is already present, our call to the
+    register_netdevice_notifier() will actually get the rtnl_lock()
+    before sending NETDEV_REGISTER and (if up) NETDEV_UP
+    events.
+
+    But for cases when the netdev is not already present, the notifier
+    chain is subjected to be invoked from different CPUs simultaneously.
+
+    This is protected by the netdev_mutex.
+*/
+static int bnxt_re_netdev_event(struct notifier_block *notifier,
+				unsigned long event, void *ptr)
+{
+	struct ifnet *real_dev, *netdev;
+	struct bnxt_re_dev *rdev = NULL;
+
+	netdev = netdev_notifier_info_to_ifp(ptr);
+	real_dev = rdma_vlan_dev_real_dev(netdev);
+	if (!real_dev)
+		real_dev = netdev;
+	/* In case of bonding,this will be bond's rdev */
+	rdev = bnxt_re_from_netdev(real_dev);
+
+	if (!rdev)
+		goto exit;
+
+	dev_info(rdev_to_dev(rdev), "%s: Event = %s (0x%lx), rdev %s (real_dev %s)\n",
+		 __func__, bnxt_re_netevent(event), event,
+		 rdev ? rdev->netdev ? rdev->netdev->if_dname : "->netdev = NULL" : "= NULL",
+		 (real_dev == netdev) ? "= netdev" : real_dev->if_dname);
+
+	if (!test_bit(BNXT_RE_FLAG_IBDEV_REGISTERED, &rdev->flags))
+		goto exit;
+
+	bnxt_re_hold(rdev);
+
+	if (real_dev != netdev) {
+		switch (event) {
+		case NETDEV_UP:
+			bnxt_re_schedule_work(rdev, event, netdev,
+					      NULL, NULL);
+			break;
+		case NETDEV_DOWN:
+			break;
+		default:
+			break;
+		}
+		goto done;
+	}
+
+	switch (event) {
+	case NETDEV_CHANGEADDR:
+		if (!_is_chip_gen_p5_p7(rdev->chip_ctx))
+			bnxt_re_update_shadow_ah(rdev);
+		bnxt_qplib_get_guid(rdev->dev_addr,
+				    (u8 *)&rdev->ibdev.node_guid);
+		break;
+
+	case NETDEV_CHANGE:
+		bnxt_re_get_link_speed(rdev);
+		bnxt_re_schedule_work(rdev, event, NULL, NULL, NULL);
+		break;
+	case NETDEV_UNREGISTER:
+		/* netdev notifier will call NETDEV_UNREGISTER again later since
+		 * we are still holding the reference to the netdev
+		 */
+
+		/*
+		 *  Workaround to avoid ib_unregister hang. Check for module
+		 *  reference and dont free up the device if the reference
+		 *  is non zero. Checking only for PF functions.
+		 */
+
+		if (rdev) {
+			dev_info(rdev_to_dev(rdev),
+				 "bnxt_re:Unreg recvd when module refcnt > 0");
+			dev_info(rdev_to_dev(rdev),
+				 "bnxt_re:Close all apps using bnxt_re devs");
+			dev_info(rdev_to_dev(rdev),
+				 "bnxt_re:Remove the configfs entry created for the device");
+			dev_info(rdev_to_dev(rdev),
+				 "bnxt_re:Refer documentation for details");
+			goto done;
+		}
+
+		if (atomic_read(&rdev->sched_count) > 0)
+			goto done;
+		if (!rdev->unreg_sched) {
+			bnxt_re_schedule_work(rdev, NETDEV_UNREGISTER,
+					      NULL, NULL, NULL);
+			rdev->unreg_sched = true;
+			goto done;
+		}
+
+		break;
+	default:
+		break;
+	}
+done:
+	if (rdev)
+		bnxt_re_put(rdev);
+exit:
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block bnxt_re_netdev_notifier = {
+	.notifier_call = bnxt_re_netdev_event
+};
+
+static void bnxt_re_remove_base_interface(struct bnxt_re_dev *rdev,
+					  struct auxiliary_device *adev)
+{
+	bnxt_re_stopqps_and_ib_uninit(rdev);
+	bnxt_re_remove_device(rdev, BNXT_RE_COMPLETE_REMOVE, adev);
+	auxiliary_set_drvdata(adev, NULL);
+}
+
+/*
+ *  bnxt_re_remove  -	Removes the roce aux device
+ *  @adev  -  aux device pointer
+ *
+ * This function removes the roce device. This gets
+ * called in the mod exit path and pci unbind path.
+ * If the rdev is bond interace, destroys the lag
+ * in module exit path, and in pci unbind case
+ * destroys the lag and recreates other base interface.
+ * If the device is already removed in error recovery
+ * path, it just unregister with the L2.
+ */
+static void bnxt_re_remove(struct auxiliary_device *adev)
+{
+	struct bnxt_re_en_dev_info *en_info = auxiliary_get_drvdata(adev);
+	struct bnxt_en_dev *en_dev;
+	struct bnxt_re_dev *rdev;
+	bool primary_dev = false;
+	bool secondary_dev = false;
+
+	if (!en_info)
+		return;
+
+	mutex_lock(&bnxt_re_mutex);
+	en_dev = en_info->en_dev;
+
+	rdev = en_info->rdev;
+
+	if (rdev && bnxt_re_is_rdev_valid(rdev)) {
+		if (pci_channel_offline(rdev->rcfw.pdev))
+			set_bit(ERR_DEVICE_DETACHED, &rdev->rcfw.cmdq.flags);
+
+		if (test_bit(BNXT_RE_FLAG_EN_DEV_PRIMARY_DEV, &en_info->flags))
+			primary_dev = true;
+		if (test_bit(BNXT_RE_FLAG_EN_DEV_SECONDARY_DEV, &en_info->flags))
+			secondary_dev = true;
+
+		/*
+		 * en_dev_info of primary device and secondary device have the
+		 * same rdev pointer when LAG is configured. This rdev pointer
+		 * is rdev of bond interface.
+		 */
+		if (!primary_dev && !secondary_dev) {
+			/* removal of non bond interface */
+			bnxt_re_remove_base_interface(rdev, adev);
+		} else {
+			/*
+			 * removal of bond primary/secondary interface. In this
+			 * case bond device is already removed, so rdev->binfo
+			 * is NULL.
+			 */
+			auxiliary_set_drvdata(adev, NULL);
+		}
+	} else {
+		/* device is removed from ulp stop, unregister the net dev */
+		if (test_bit(BNXT_RE_FLAG_EN_DEV_NETDEV_REG, &en_info->flags)) {
+			rtnl_lock();
+			en_dev->en_ops->bnxt_unregister_device(en_dev,
+							       BNXT_ROCE_ULP);
+			rtnl_unlock();
+		}
+	}
+	mutex_unlock(&bnxt_re_mutex);
+	return;
+}
+
+/* wrapper for all external user context callers */
+void _bnxt_re_remove(struct auxiliary_device *adev)
+{
+	bnxt_re_remove(adev);
+}
+
+static void bnxt_re_ib_init_2(struct bnxt_re_dev *rdev)
+{
+	int rc;
+
+	rc = bnxt_re_get_device_stats(rdev);
+	if (rc)
+		dev_err(rdev_to_dev(rdev),
+			"Failed initial device stat query");
+
+	bnxt_re_net_register_async_event(rdev);
+}
+
+static int bnxt_re_probe(struct auxiliary_device *adev,
+			 const struct auxiliary_device_id *id)
+{
+	struct bnxt_aux_dev *aux_dev =
+		container_of(adev, struct bnxt_aux_dev, aux_dev);
+	struct bnxt_re_en_dev_info *en_info;
+	struct bnxt_en_dev *en_dev = NULL;
+	struct bnxt_re_dev *rdev;
+	int rc = -ENODEV;
+
+	if (aux_dev)
+		en_dev = aux_dev->edev;
+
+	if (!en_dev)
+		return rc;
+
+	if (en_dev->ulp_version != BNXT_ULP_VERSION) {
+		pr_err("%s: probe error: bnxt_en ulp version magic %x is not compatible!\n",
+			ROCE_DRV_MODULE_NAME, en_dev->ulp_version);
+		return -EINVAL;
+	}
+
+	en_info = kzalloc(sizeof(*en_info), GFP_KERNEL);
+	if (!en_info)
+		return -ENOMEM;
+	memset(en_info, 0, sizeof(struct bnxt_re_en_dev_info));
+	en_info->en_dev = en_dev;
+	auxiliary_set_drvdata(adev, en_info);
+
+	mutex_lock(&bnxt_re_mutex);
+	rc = bnxt_re_add_device(&rdev, en_dev->net,
+				BNXT_RE_GSI_MODE_ALL,
+				BNXT_RE_COMPLETE_INIT,
+				BNXT_QPLIB_WQE_MODE_STATIC,
+				BNXT_RE_MSIX_FROM_MOD_PARAM, adev);
+	if (rc) {
+		mutex_unlock(&bnxt_re_mutex);
+		return rc;
+	}
+
+	rc = bnxt_re_ib_init(rdev);
+	if (rc)
+		goto err;
+
+	bnxt_re_ib_init_2(rdev);
+
+	dev_dbg(rdev_to_dev(rdev), "%s: adev: %p\n", __func__, adev);
+	rdev->adev = adev;
+
+	mutex_unlock(&bnxt_re_mutex);
+
+	return 0;
+
+err:
+	mutex_unlock(&bnxt_re_mutex);
+	bnxt_re_remove(adev);
+
+	return rc;
+}
+
+static const struct auxiliary_device_id bnxt_re_id_table[] = {
+	{ .name = BNXT_ADEV_NAME ".rdma", },
+	{},
+};
+
+MODULE_DEVICE_TABLE(auxiliary, bnxt_re_id_table);
+
+static struct auxiliary_driver bnxt_re_driver = {
+	.name = "rdma",
+	.probe = bnxt_re_probe,
+	.remove = bnxt_re_remove,
+	.id_table = bnxt_re_id_table,
+};
+
+static int __init bnxt_re_mod_init(void)
+{
+	int rc = 0;
+
+	pr_info("%s: %s", ROCE_DRV_MODULE_NAME, drv_version);
+
+	bnxt_re_wq = create_singlethread_workqueue("bnxt_re");
+	if (!bnxt_re_wq)
+		return -ENOMEM;
+
+	rc = bnxt_re_register_netdevice_notifier(&bnxt_re_netdev_notifier);
+	if (rc) {
+		pr_err("%s: Cannot register to netdevice_notifier",
+			ROCE_DRV_MODULE_NAME);
+		goto err_netdev;
+	}
+
+	INIT_LIST_HEAD(&bnxt_re_dev_list);
+
+	rc = auxiliary_driver_register(&bnxt_re_driver);
+	if (rc) {
+		pr_err("%s: Failed to register auxiliary driver\n",
+		       ROCE_DRV_MODULE_NAME);
+		goto err_auxdrv;
+	}
+
+	return 0;
+
+err_auxdrv:
+	bnxt_re_unregister_netdevice_notifier(&bnxt_re_netdev_notifier);
+
+err_netdev:
+	destroy_workqueue(bnxt_re_wq);
+
+	return rc;
+}
+
+static void __exit bnxt_re_mod_exit(void)
+{
+	gmod_exit = 1;
+	auxiliary_driver_unregister(&bnxt_re_driver);
+
+	bnxt_re_unregister_netdevice_notifier(&bnxt_re_netdev_notifier);
+
+	if (bnxt_re_wq)
+		destroy_workqueue(bnxt_re_wq);
+}
+
+module_init(bnxt_re_mod_init);
+module_exit(bnxt_re_mod_exit);
diff --git a/sys/dev/bnxt/bnxt_re/qplib_fp.c b/sys/dev/bnxt/bnxt_re/qplib_fp.c
new file mode 100644
index 000000000000..3f1b02406f7f
--- /dev/null
+++ b/sys/dev/bnxt/bnxt_re/qplib_fp.c
@@ -0,0 +1,3544 @@
+/*
+ * Copyright (c) 2015-2024, Broadcom. All rights reserved.  The term
+ * Broadcom refers to Broadcom Limited and/or its subsidiaries.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Description: Fast Path Operators
+ */
+
+#include <linux/interrupt.h>
+#include <linux/spinlock.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/pci.h>
+#include <linux/delay.h>
+#include <linux/if_ether.h>
+#include <linux/hardirq.h>
+#include <rdma/ib_mad.h>
+
+#include "hsi_struct_def.h"
+#include "qplib_tlv.h"
+#include "qplib_res.h"
+#include "qplib_rcfw.h"
+#include "qplib_sp.h"
+#include "qplib_fp.h"
+#include "ib_verbs.h"
+
+static void __clean_cq(struct bnxt_qplib_cq *cq, u64 qp);
+
+static void bnxt_re_legacy_cancel_phantom_processing(struct bnxt_qplib_qp *qp)
+{
+	qp->sq.condition = false;
+	qp->sq.legacy_send_phantom = false;
+	qp->sq.single = false;
+}
+
+static void __bnxt_qplib_add_flush_qp(struct bnxt_qplib_qp *qp)
+{
+	struct bnxt_qplib_cq *scq, *rcq;
+
+	scq = qp->scq;
+	rcq = qp->rcq;
+
+	if (!qp->sq.flushed) {
+		dev_dbg(&scq->hwq.pdev->dev,
+			"QPLIB: FP: Adding to SQ Flush list = %p\n",
+			qp);
+		bnxt_re_legacy_cancel_phantom_processing(qp);
+		list_add_tail(&qp->sq_flush, &scq->sqf_head);
+		qp->sq.flushed = true;
+	}
+	if (!qp->srq) {
+		if (!qp->rq.flushed) {
+			dev_dbg(&rcq->hwq.pdev->dev,
+				"QPLIB: FP: Adding to RQ Flush list = %p\n",
+				qp);
+			list_add_tail(&qp->rq_flush, &rcq->rqf_head);
+			qp->rq.flushed = true;
+		}
+	}
+}
+
+static void bnxt_qplib_acquire_cq_flush_locks(struct bnxt_qplib_qp *qp)
+	__acquires(&qp->scq->flush_lock) __acquires(&qp->rcq->flush_lock)
+{
+	/* Interrupts are already disabled in calling functions */
+	spin_lock(&qp->scq->flush_lock);
+	if (qp->scq == qp->rcq)
+		__acquire(&qp->rcq->flush_lock);
+	else
+		spin_lock(&qp->rcq->flush_lock);
+}
+
+static void bnxt_qplib_release_cq_flush_locks(struct bnxt_qplib_qp *qp)
+	__releases(&qp->scq->flush_lock) __releases(&qp->rcq->flush_lock)
+{
+	if (qp->scq == qp->rcq)
+		__release(&qp->rcq->flush_lock);
+	else
+		spin_unlock(&qp->rcq->flush_lock);
+	spin_unlock(&qp->scq->flush_lock);
+}
+
+void bnxt_qplib_add_flush_qp(struct bnxt_qplib_qp *qp)
+{
+
+	bnxt_qplib_acquire_cq_flush_locks(qp);
+	__bnxt_qplib_add_flush_qp(qp);
+	bnxt_qplib_release_cq_flush_locks(qp);
+}
+
+static void __bnxt_qplib_del_flush_qp(struct bnxt_qplib_qp *qp)
+{
+	if (qp->sq.flushed) {
+		qp->sq.flushed = false;
+		list_del(&qp->sq_flush);
+	}
+	if (!qp->srq) {
+		if (qp->rq.flushed) {
+			qp->rq.flushed = false;
+			list_del(&qp->rq_flush);
+		}
+	}
+}
+
+void bnxt_qplib_clean_qp(struct bnxt_qplib_qp *qp)
+{
+
+	bnxt_qplib_acquire_cq_flush_locks(qp);
+	__clean_cq(qp->scq, (u64)(unsigned long)qp);
+	qp->sq.hwq.prod = 0;
+	qp->sq.hwq.cons = 0;
+	qp->sq.swq_start = 0;
+	qp->sq.swq_last = 0;
+	__clean_cq(qp->rcq, (u64)(unsigned long)qp);
+	qp->rq.hwq.prod = 0;
+	qp->rq.hwq.cons = 0;
+	qp->rq.swq_start = 0;
+	qp->rq.swq_last = 0;
+
+	__bnxt_qplib_del_flush_qp(qp);
+	bnxt_qplib_release_cq_flush_locks(qp);
+}
+
+static void bnxt_qpn_cqn_sched_task(struct work_struct *work)
+{
+	struct bnxt_qplib_nq_work *nq_work =
+			container_of(work, struct bnxt_qplib_nq_work, work);
+
+	struct bnxt_qplib_cq *cq = nq_work->cq;
+	struct bnxt_qplib_nq *nq = nq_work->nq;
+
+	if (cq && nq) {
+		spin_lock_bh(&cq->compl_lock);
+		if (nq->cqn_handler) {
+			dev_dbg(&nq->res->pdev->dev,
+				"%s:Trigger cq  = %p event nq = %p\n",
+				__func__, cq, nq);
+			nq->cqn_handler(nq, cq);
+		}
+		spin_unlock_bh(&cq->compl_lock);
+	}
+	kfree(nq_work);
+}
+
+static void bnxt_qplib_put_hdr_buf(struct pci_dev *pdev,
+				   struct bnxt_qplib_hdrbuf *buf)
+{
+	dma_free_coherent(&pdev->dev, buf->len, buf->va, buf->dma_map);
+	kfree(buf);
+}
+
+static void *bnxt_qplib_get_hdr_buf(struct pci_dev *pdev,  u32 step, u32 cnt)
+{
+	struct bnxt_qplib_hdrbuf *hdrbuf;
+	u32 len;
+
+	hdrbuf = kmalloc(sizeof(*hdrbuf), GFP_KERNEL);
+	if (!hdrbuf)
+		return NULL;
+
+	len = ALIGN((step * cnt), PAGE_SIZE);
+	hdrbuf->va = dma_alloc_coherent(&pdev->dev, len,
+					&hdrbuf->dma_map, GFP_KERNEL);
+	if (!hdrbuf->va)
+		goto out;
+
+	hdrbuf->len = len;
+	hdrbuf->step = step;
+	return hdrbuf;
+out:
+	kfree(hdrbuf);
+	return NULL;
+}
+
+void bnxt_qplib_free_hdr_buf(struct bnxt_qplib_res *res,
+			     struct bnxt_qplib_qp *qp)
+{
+	if (qp->rq_hdr_buf) {
+		bnxt_qplib_put_hdr_buf(res->pdev, qp->rq_hdr_buf);
+		qp->rq_hdr_buf = NULL;
+	}
+
+	if (qp->sq_hdr_buf) {
+		bnxt_qplib_put_hdr_buf(res->pdev, qp->sq_hdr_buf);
+		qp->sq_hdr_buf = NULL;
+	}
+}
+
+int bnxt_qplib_alloc_hdr_buf(struct bnxt_qplib_res *res,
+			     struct bnxt_qplib_qp *qp, u32 sstep, u32 rstep)
+{
+	struct pci_dev *pdev;
+	int rc = 0;
+
+	pdev = res->pdev;
+	if (sstep) {
+		qp->sq_hdr_buf = bnxt_qplib_get_hdr_buf(pdev, sstep,
+							qp->sq.max_wqe);
+		if (!qp->sq_hdr_buf) {
+			dev_err(&pdev->dev, "QPLIB: Failed to get sq_hdr_buf\n");
+			return -ENOMEM;
+		}
+	}
+
+	if (rstep) {
+		qp->rq_hdr_buf = bnxt_qplib_get_hdr_buf(pdev, rstep,
+							qp->rq.max_wqe);
+		if (!qp->rq_hdr_buf) {
+			rc = -ENOMEM;
+			dev_err(&pdev->dev, "QPLIB: Failed to get rq_hdr_buf\n");
+			goto fail;
+		}
+	}
+
+	return 0;
+fail:
+	bnxt_qplib_free_hdr_buf(res, qp);
+	return rc;
+}
+
+/*
+ * clean_nq -	Invalidate cqe from given nq.
+ * @cq      -	Completion queue
+ *
+ * Traverse whole notification queue and invalidate any completion
+ * associated cq handler provided by caller.
+ * Note - This function traverse the hardware queue but do not update
+ * consumer index. Invalidated cqe(marked from this function) will be
+ * ignored from actual completion of notification queue.
+ */
+static void clean_nq(struct bnxt_qplib_cq *cq)
+{
+	struct bnxt_qplib_hwq *nq_hwq = NULL;
+	struct bnxt_qplib_nq *nq = NULL;
+	struct nq_base *hw_nqe = NULL;
+	struct nq_cn *nqcne = NULL;
+	u32 peek_flags, peek_cons;
+	u64 q_handle;
+	u32 type;
+	int i;
+
+	nq = cq->nq;
+	nq_hwq = &nq->hwq;
+
+	spin_lock_bh(&nq_hwq->lock);
+	peek_flags = nq->nq_db.dbinfo.flags;
+	peek_cons = nq_hwq->cons;
+	for (i = 0; i < nq_hwq->max_elements; i++) {
+		hw_nqe = bnxt_qplib_get_qe(nq_hwq, peek_cons, NULL);
+		if (!NQE_CMP_VALID(hw_nqe, peek_flags))
+			break;
+
+		/* The valid test of the entry must be done first
+		 * before reading any further.
+		 */
+		dma_rmb();
+		type = le16_to_cpu(hw_nqe->info10_type) &
+				   NQ_BASE_TYPE_MASK;
+
+		/* Processing only NQ_BASE_TYPE_CQ_NOTIFICATION */
+		if (type == NQ_BASE_TYPE_CQ_NOTIFICATION) {
+			nqcne = (struct nq_cn *)hw_nqe;
+
+			q_handle = le32_to_cpu(nqcne->cq_handle_low);
+			q_handle |= (u64)le32_to_cpu(nqcne->cq_handle_high) << 32;
+			if (q_handle == (u64)cq) {
+				nqcne->cq_handle_low = 0;
+				nqcne->cq_handle_high = 0;
+				cq->cnq_events++;
+			}
+		}
+		bnxt_qplib_hwq_incr_cons(nq_hwq->max_elements, &peek_cons,
+					 1, &peek_flags);
+	}
+	spin_unlock_bh(&nq_hwq->lock);
+}
+
+/*
+ * Wait for receiving all NQEs for this CQ.
+ * clean_nq is tried 100 times, each time clean_cq
+ * loops upto budget times. budget is based on the
+ * number of CQs shared by that NQ. So any NQE from
+ * CQ would be already in the NQ.
+ */
+static void __wait_for_all_nqes(struct bnxt_qplib_cq *cq, u16 cnq_events)
+{
+	u32 retry_cnt = 100;
+	u16 total_events;
+
+	if (!cnq_events) {
+		clean_nq(cq);
+		return;
+	}
+	while (retry_cnt--) {
+		total_events = cq->cnq_events;
+
+		/* Increment total_events by 1 if any CREQ event received with CQ notification */
+		if (cq->is_cq_err_event)
+			total_events++;
+
+		if (cnq_events == total_events) {
+			dev_dbg(&cq->nq->res->pdev->dev,
+				"QPLIB: NQ cleanup - Received all NQ events\n");
+			return;
+		}
+		msleep(1);
+		clean_nq(cq);
+	}
+}
+
+static void bnxt_qplib_service_nq(unsigned long data)
+{
+	struct bnxt_qplib_nq *nq = (struct bnxt_qplib_nq *)data;
+	struct bnxt_qplib_hwq *nq_hwq = &nq->hwq;
+	int budget = nq->budget;
+	struct bnxt_qplib_res *res;
+	struct bnxt_qplib_cq *cq;
+	struct pci_dev *pdev;
+	struct nq_base *nqe;
+	u32 hw_polled = 0;
+	u64 q_handle;
+	u32 type;
+
+	res = nq->res;
+	pdev = res->pdev;
+
+	spin_lock_bh(&nq_hwq->lock);
+	/* Service the NQ until empty or budget expired */
+	while (budget--) {
+		nqe = bnxt_qplib_get_qe(nq_hwq, nq_hwq->cons, NULL);
+		if (!NQE_CMP_VALID(nqe, nq->nq_db.dbinfo.flags))
+			break;
+		/* The valid test of the entry must be done first before
+		 * reading any further.
+		 */
+		dma_rmb();
+		type = le16_to_cpu(nqe->info10_type) & NQ_BASE_TYPE_MASK;
+		switch (type) {
+		case NQ_BASE_TYPE_CQ_NOTIFICATION:
+		{
+			struct nq_cn *nqcne = (struct nq_cn *)nqe;
+
+			q_handle = le32_to_cpu(nqcne->cq_handle_low);
+			q_handle |= (u64)le32_to_cpu(nqcne->cq_handle_high) << 32;
+			cq = (struct bnxt_qplib_cq *)q_handle;
+			if (!cq)
+				break;
+			cq->toggle = (le16_to_cpu(nqe->info10_type) & NQ_CN_TOGGLE_MASK) >> NQ_CN_TOGGLE_SFT;
+			cq->dbinfo.toggle = cq->toggle;
+			bnxt_qplib_armen_db(&cq->dbinfo,
+					    DBC_DBC_TYPE_CQ_ARMENA);
+			spin_lock_bh(&cq->compl_lock);
+			atomic_set(&cq->arm_state, 0) ;
+			if (!nq->cqn_handler(nq, (cq)))
+				nq->stats.num_cqne_processed++;
+			else
+				dev_warn(&pdev->dev,
+					 "QPLIB: cqn - type 0x%x not handled\n",
+					 type);
+			cq->cnq_events++;
+			spin_unlock_bh(&cq->compl_lock);
+			break;
+		}
+		case NQ_BASE_TYPE_SRQ_EVENT:
+		{
+			struct bnxt_qplib_srq *srq;
+			struct nq_srq_event *nqsrqe =
+						(struct nq_srq_event *)nqe;
+
+			q_handle = le32_to_cpu(nqsrqe->srq_handle_low);
+			q_handle |= (u64)le32_to_cpu(nqsrqe->srq_handle_high) << 32;
+			srq = (struct bnxt_qplib_srq *)q_handle;
+			bnxt_qplib_armen_db(&srq->dbinfo,
+					    DBC_DBC_TYPE_SRQ_ARMENA);
+			if (!nq->srqn_handler(nq,
+					      (struct bnxt_qplib_srq *)q_handle,
+					      nqsrqe->event))
+				nq->stats.num_srqne_processed++;
+			else
+				dev_warn(&pdev->dev,
+					 "QPLIB: SRQ event 0x%x not handled\n",
+					 nqsrqe->event);
+			break;
+		}
+		default:
+			dev_warn(&pdev->dev,
+				 "QPLIB: nqe with opcode = 0x%x not handled\n",
+				 type);
+			break;
+		}
+		hw_polled++;
+		bnxt_qplib_hwq_incr_cons(nq_hwq->max_elements, &nq_hwq->cons,
+					 1, &nq->nq_db.dbinfo.flags);
+	}
+	nqe = bnxt_qplib_get_qe(nq_hwq, nq_hwq->cons, NULL);
+	if (!NQE_CMP_VALID(nqe, nq->nq_db.dbinfo.flags)) {
+		nq->stats.num_nq_rearm++;
+		bnxt_qplib_ring_nq_db(&nq->nq_db.dbinfo, res->cctx, true);
+	} else if (nq->requested) {
+		bnxt_qplib_ring_nq_db(&nq->nq_db.dbinfo, res->cctx, true);
+		nq->stats.num_tasklet_resched++;
+	}
+	dev_dbg(&pdev->dev, "QPLIB: cqn/srqn/dbqn \n");
+	if (hw_polled >= 0)
+		dev_dbg(&pdev->dev,
+			"QPLIB: serviced %llu/%llu/%llu budget 0x%x reaped 0x%x\n",
+			nq->stats.num_cqne_processed, nq->stats.num_srqne_processed,
+			nq->stats.num_dbqne_processed, budget, hw_polled);
+	dev_dbg(&pdev->dev,
+		"QPLIB: resched_cnt  = %llu arm_count = %llu\n",
+		nq->stats.num_tasklet_resched, nq->stats.num_nq_rearm);
+	spin_unlock_bh(&nq_hwq->lock);
+}
+
+static irqreturn_t bnxt_qplib_nq_irq(int irq, void *dev_instance)
+{
+	struct bnxt_qplib_nq *nq = dev_instance;
+	struct bnxt_qplib_hwq *nq_hwq = &nq->hwq;
+	u32 sw_cons;
+
+	/* Prefetch the NQ element */
+	sw_cons = HWQ_CMP(nq_hwq->cons, nq_hwq);
+	if (sw_cons >= 0)
+		prefetch(bnxt_qplib_get_qe(nq_hwq, sw_cons, NULL));
+
+	bnxt_qplib_service_nq((unsigned long)nq);
+
+	return IRQ_HANDLED;
+}
+
+void bnxt_qplib_nq_stop_irq(struct bnxt_qplib_nq *nq, bool kill)
+{
+	struct bnxt_qplib_res *res;
+
+	if (!nq->requested)
+		return;
+
+	nq->requested = false;
+	res = nq->res;
+	/* Mask h/w interrupt */
+	bnxt_qplib_ring_nq_db(&nq->nq_db.dbinfo, res->cctx, false);
+	/* Sync with last running IRQ handler */
+	synchronize_irq(nq->msix_vec);
+	free_irq(nq->msix_vec, nq);
+	kfree(nq->name);
+	nq->name = NULL;
+}
+
+void bnxt_qplib_disable_nq(struct bnxt_qplib_nq *nq)
+{
+	if (nq->cqn_wq) {
+		destroy_workqueue(nq->cqn_wq);
+		nq->cqn_wq = NULL;
+	}
+	/* Make sure the HW is stopped! */
+	bnxt_qplib_nq_stop_irq(nq, true);
+
+	nq->nq_db.reg.bar_reg = NULL;
+	nq->nq_db.db = NULL;
+
+	nq->cqn_handler = NULL;
+	nq->srqn_handler = NULL;
+	nq->msix_vec = 0;
+}
+
+int bnxt_qplib_nq_start_irq(struct bnxt_qplib_nq *nq, int nq_indx,
+			    int msix_vector, bool need_init)
+{
+	struct bnxt_qplib_res *res;
+	int rc;
+
+	res = nq->res;
+	if (nq->requested)
+		return -EFAULT;
+
+	nq->msix_vec = msix_vector;
+	nq->name = kasprintf(GFP_KERNEL, "bnxt_re-nq-%d@pci:%s\n",
+			     nq_indx, pci_name(res->pdev));
+	if (!nq->name)
+		return -ENOMEM;
+	rc = request_irq(nq->msix_vec, bnxt_qplib_nq_irq, 0, nq->name, nq);
+	if (rc) {
+		kfree(nq->name);
+		nq->name = NULL;
+		return rc;
+	}
+	nq->requested = true;
+	bnxt_qplib_ring_nq_db(&nq->nq_db.dbinfo, res->cctx, true);
+
+	return rc;
+}
+
+static void bnxt_qplib_map_nq_db(struct bnxt_qplib_nq *nq,  u32 reg_offt)
+{
+	struct bnxt_qplib_reg_desc *dbreg;
+	struct bnxt_qplib_nq_db *nq_db;
+	struct bnxt_qplib_res *res;
+
+	nq_db = &nq->nq_db;
+	res = nq->res;
+	dbreg = &res->dpi_tbl.ucreg;
+
+	nq_db->reg.bar_id = dbreg->bar_id;
+	nq_db->reg.bar_base = dbreg->bar_base;
+	nq_db->reg.bar_reg = dbreg->bar_reg + reg_offt;
+	nq_db->reg.len = _is_chip_gen_p5_p7(res->cctx) ? sizeof(u64) :
+						      sizeof(u32);
+
+	nq_db->dbinfo.db = nq_db->reg.bar_reg;
+	nq_db->dbinfo.hwq = &nq->hwq;
+	nq_db->dbinfo.xid = nq->ring_id;
+	nq_db->dbinfo.seed = nq->ring_id;
+	nq_db->dbinfo.flags = 0;
+	spin_lock_init(&nq_db->dbinfo.lock);
+	nq_db->dbinfo.shadow_key = BNXT_QPLIB_DBR_KEY_INVALID;
+	nq_db->dbinfo.res = nq->res;
+
+	return;
+}
+
+int bnxt_qplib_enable_nq(struct bnxt_qplib_nq *nq, int nq_idx,
+			 int msix_vector, int bar_reg_offset,
+			 cqn_handler_t cqn_handler,
+			 srqn_handler_t srqn_handler)
+{
+	struct pci_dev *pdev;
+	int rc;
+
+	pdev = nq->res->pdev;
+	nq->cqn_handler = cqn_handler;
+	nq->srqn_handler = srqn_handler;
+	nq->load = 0;
+	mutex_init(&nq->lock);
+
+	/* Have a task to schedule CQ notifiers in post send case */
+	nq->cqn_wq  = create_singlethread_workqueue("bnxt_qplib_nq\n");
+	if (!nq->cqn_wq)
+		return -ENOMEM;
+
+	bnxt_qplib_map_nq_db(nq, bar_reg_offset);
+	rc = bnxt_qplib_nq_start_irq(nq, nq_idx, msix_vector, true);
+	if (rc) {
+		dev_err(&pdev->dev,
+			"QPLIB: Failed to request irq for nq-idx %d\n", nq_idx);
+		goto fail;
+	}
+	dev_dbg(&pdev->dev, "QPLIB: NQ max = 0x%x\n", nq->hwq.max_elements);
+
+	return 0;
+fail:
+	bnxt_qplib_disable_nq(nq);
+	return rc;
+}
+
+void bnxt_qplib_free_nq_mem(struct bnxt_qplib_nq *nq)
+{
+	if (nq->hwq.max_elements) {
+		bnxt_qplib_free_hwq(nq->res, &nq->hwq);
+		nq->hwq.max_elements = 0;
+	}
+}
+
+int bnxt_qplib_alloc_nq_mem(struct bnxt_qplib_res *res,
+			    struct bnxt_qplib_nq *nq)
+{
+	struct bnxt_qplib_hwq_attr hwq_attr = {};
+	struct bnxt_qplib_sg_info sginfo = {};
+
+	nq->res = res;
+	if (!nq->hwq.max_elements ||
+	    nq->hwq.max_elements > BNXT_QPLIB_NQE_MAX_CNT)
+		nq->hwq.max_elements = BNXT_QPLIB_NQE_MAX_CNT;
+
+	sginfo.pgsize = PAGE_SIZE;
+	sginfo.pgshft = PAGE_SHIFT;
+	hwq_attr.res = res;
+	hwq_attr.sginfo = &sginfo;
+	hwq_attr.depth = nq->hwq.max_elements;
+	hwq_attr.stride = sizeof(struct nq_base);
+	hwq_attr.type = _get_hwq_type(res);
+	if (bnxt_qplib_alloc_init_hwq(&nq->hwq, &hwq_attr)) {
+		dev_err(&res->pdev->dev, "QPLIB: FP NQ allocation failed\n");
+		return -ENOMEM;
+	}
+	nq->budget = 8;
+	return 0;
+}
+
+/* SRQ */
+static int __qplib_destroy_srq(struct bnxt_qplib_rcfw *rcfw,
+			       struct bnxt_qplib_srq *srq)
+{
+	struct creq_destroy_srq_resp resp = {};
+	struct bnxt_qplib_cmdqmsg msg = {};
+	struct cmdq_destroy_srq req = {};
+	/* Configure the request */
+	req.srq_cid = cpu_to_le32(srq->id);
+	bnxt_qplib_rcfw_cmd_prep(&req, CMDQ_BASE_OPCODE_DESTROY_SRQ,
+				 sizeof(req));
+	bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, NULL, sizeof(req),
+				sizeof(resp), 0);
+	return bnxt_qplib_rcfw_send_message(rcfw, &msg);
+}
+
+int bnxt_qplib_destroy_srq(struct bnxt_qplib_res *res,
+			   struct bnxt_qplib_srq *srq)
+{
+	struct bnxt_qplib_rcfw *rcfw = res->rcfw;
+	int rc;
+
+	rc = __qplib_destroy_srq(rcfw, srq);
+	if (rc)
+		return rc;
+	bnxt_qplib_free_hwq(res, &srq->hwq);
+	kfree(srq->swq);
+	return 0;
+}
+
+int bnxt_qplib_create_srq(struct bnxt_qplib_res *res,
+			  struct bnxt_qplib_srq *srq)
+{
+	struct bnxt_qplib_hwq_attr hwq_attr = {};
+	struct bnxt_qplib_rcfw *rcfw = res->rcfw;
+	struct creq_create_srq_resp resp = {};
+	struct bnxt_qplib_cmdqmsg msg = {};
+	struct cmdq_create_srq req = {};
+	u16 pg_sz_lvl = 0;
+	u16 srq_size;
+	int rc, idx;
+
+	hwq_attr.res = res;
+	hwq_attr.sginfo = &srq->sginfo;
+	hwq_attr.depth = srq->max_wqe;
+	hwq_attr.stride = srq->wqe_size;
+	hwq_attr.type = HWQ_TYPE_QUEUE;
+	rc = bnxt_qplib_alloc_init_hwq(&srq->hwq, &hwq_attr);
+	if (rc)
+		goto exit;
+	/* Configure the request */
+	req.dpi = cpu_to_le32(srq->dpi->dpi);
+	req.srq_handle = cpu_to_le64((uintptr_t)srq);
+	srq_size = min_t(u32, srq->hwq.depth, U16_MAX);
+	req.srq_size = cpu_to_le16(srq_size);
+	pg_sz_lvl |= (_get_base_pg_size(&srq->hwq) <<
+		      CMDQ_CREATE_SRQ_PG_SIZE_SFT);
+	pg_sz_lvl |= (srq->hwq.level & CMDQ_CREATE_SRQ_LVL_MASK);
+	req.pg_size_lvl = cpu_to_le16(pg_sz_lvl);
+	req.pbl = cpu_to_le64(_get_base_addr(&srq->hwq));
+	req.pd_id = cpu_to_le32(srq->pd->id);
+	req.eventq_id = cpu_to_le16(srq->eventq_hw_ring_id);
+	bnxt_qplib_rcfw_cmd_prep(&req, CMDQ_BASE_OPCODE_CREATE_SRQ,
+				 sizeof(req));
+	bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, NULL, sizeof(req),
+				sizeof(resp), 0);
+	rc = bnxt_qplib_rcfw_send_message(rcfw, &msg);
+	if (rc)
+		goto fail;
+	if (!srq->is_user) {
+		srq->swq = kcalloc(srq->hwq.depth, sizeof(*srq->swq),
+				   GFP_KERNEL);
+		if (!srq->swq)
+			goto srq_fail;
+		srq->start_idx = 0;
+		srq->last_idx = srq->hwq.depth - 1;
+		for (idx = 0; idx < srq->hwq.depth; idx++)
+			srq->swq[idx].next_idx = idx + 1;
+		srq->swq[srq->last_idx].next_idx = -1;
+	}
+
+	spin_lock_init(&srq->lock);
+	srq->id = le32_to_cpu(resp.xid);
+	srq->cctx = res->cctx;
+	srq->dbinfo.hwq = &srq->hwq;
+	srq->dbinfo.xid = srq->id;
+	srq->dbinfo.db = srq->dpi->dbr;
+	srq->dbinfo.max_slot = 1;
+	srq->dbinfo.priv_db = res->dpi_tbl.priv_db;
+	srq->dbinfo.flags = 0;
+	spin_lock_init(&srq->dbinfo.lock);
+	srq->dbinfo.shadow_key = BNXT_QPLIB_DBR_KEY_INVALID;
+	srq->dbinfo.shadow_key_arm_ena = BNXT_QPLIB_DBR_KEY_INVALID;
+	srq->dbinfo.res = res;
+	srq->dbinfo.seed = srq->id;
+	if (srq->threshold)
+		bnxt_qplib_armen_db(&srq->dbinfo, DBC_DBC_TYPE_SRQ_ARMENA);
+	srq->arm_req = false;
+	return 0;
+srq_fail:
+	__qplib_destroy_srq(rcfw, srq);
+fail:
+	bnxt_qplib_free_hwq(res, &srq->hwq);
+exit:
+	return rc;
+}
+
+int bnxt_qplib_modify_srq(struct bnxt_qplib_res *res,
+			  struct bnxt_qplib_srq *srq)
+{
+	struct bnxt_qplib_hwq *srq_hwq = &srq->hwq;
+	u32 avail = 0;
+
+	avail = __bnxt_qplib_get_avail(srq_hwq);
+	if (avail <= srq->threshold) {
+		srq->arm_req = false;
+		bnxt_qplib_srq_arm_db(&srq->dbinfo);
+	} else {
+		/* Deferred arming */
+		srq->arm_req = true;
+	}
+	return 0;
+}
+
+int bnxt_qplib_query_srq(struct bnxt_qplib_res *res,
+			 struct bnxt_qplib_srq *srq)
+{
+	struct bnxt_qplib_rcfw *rcfw = res->rcfw;
+	struct creq_query_srq_resp resp = {};
+	struct bnxt_qplib_cmdqmsg msg = {};
+	struct creq_query_srq_resp_sb *sb;
+	struct bnxt_qplib_rcfw_sbuf sbuf;
+	struct cmdq_query_srq req = {};
+	int rc = 0;
+
+	bnxt_qplib_rcfw_cmd_prep(&req, CMDQ_BASE_OPCODE_QUERY_SRQ,
+				 sizeof(req));
+	sbuf.size = ALIGN(sizeof(*sb), BNXT_QPLIB_CMDQE_UNITS);
+	sbuf.sb = dma_zalloc_coherent(&rcfw->pdev->dev, sbuf.size,
+				       &sbuf.dma_addr, GFP_KERNEL);
+	if (!sbuf.sb)
+		return -ENOMEM;
+	req.resp_size = sbuf.size / BNXT_QPLIB_CMDQE_UNITS;
+	req.srq_cid = cpu_to_le32(srq->id);
+	bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, &sbuf, sizeof(req),
+				sizeof(resp), 0);
+	rc = bnxt_qplib_rcfw_send_message(rcfw, &msg);
+	/* TODO: What to do with the query? */
+	dma_free_coherent(&rcfw->pdev->dev, sbuf.size,
+				  sbuf.sb, sbuf.dma_addr);
+
+	return rc;
+}
+
+int bnxt_qplib_post_srq_recv(struct bnxt_qplib_srq *srq,
+			     struct bnxt_qplib_swqe *wqe)
+{
+	struct bnxt_qplib_hwq *srq_hwq = &srq->hwq;
+	struct sq_sge *hw_sge;
+	struct rq_wqe *srqe;
+	int i, rc = 0, next;
+	u32 avail;
+
+	spin_lock(&srq_hwq->lock);
+	if (srq->start_idx == srq->last_idx) {
+		dev_err(&srq_hwq->pdev->dev, "QPLIB: FP: SRQ (0x%x) is full!\n",
+			srq->id);
+		rc = -EINVAL;
+		spin_unlock(&srq_hwq->lock);
+		goto done;
+	}
+	next = srq->start_idx;
+	srq->start_idx = srq->swq[next].next_idx;
+	spin_unlock(&srq_hwq->lock);
+
+	srqe = bnxt_qplib_get_qe(srq_hwq, srq_hwq->prod, NULL);
+	memset(srqe, 0, srq->wqe_size);
+	/* Calculate wqe_size and data_len */
+	for (i = 0, hw_sge = (struct sq_sge *)srqe->data;
+	     i < wqe->num_sge; i++, hw_sge++) {
+		hw_sge->va_or_pa = cpu_to_le64(wqe->sg_list[i].addr);
+		hw_sge->l_key = cpu_to_le32(wqe->sg_list[i].lkey);
+		hw_sge->size = cpu_to_le32(wqe->sg_list[i].size);
+	}
+	srqe->wqe_type = wqe->type;
+	srqe->flags = wqe->flags;
+	srqe->wqe_size = wqe->num_sge +
+			((offsetof(typeof(*srqe), data) + 15) >> 4);
+	if (!wqe->num_sge)
+		srqe->wqe_size++;
+	srqe->wr_id |= cpu_to_le32((u32)next);
+	srq->swq[next].wr_id = wqe->wr_id;
+	bnxt_qplib_hwq_incr_prod(&srq->dbinfo, srq_hwq, srq->dbinfo.max_slot);
+	/* retaining srq_hwq->cons for this logic actually the lock is only
+	 * required to read srq_hwq->cons.
+	 */
+	spin_lock(&srq_hwq->lock);
+	avail = __bnxt_qplib_get_avail(srq_hwq);
+	spin_unlock(&srq_hwq->lock);
+	/* Ring DB */
+	bnxt_qplib_ring_prod_db(&srq->dbinfo, DBC_DBC_TYPE_SRQ);
+	if (srq->arm_req && avail <= srq->threshold) {
+		srq->arm_req = false;
+		bnxt_qplib_srq_arm_db(&srq->dbinfo);
+	}
+done:
+	return rc;
+}
+
+/* QP */
+static int __qplib_destroy_qp(struct bnxt_qplib_rcfw *rcfw,
+			      struct bnxt_qplib_qp *qp)
+{
+	struct creq_destroy_qp_resp resp = {};
+	struct bnxt_qplib_cmdqmsg msg = {};
+	struct cmdq_destroy_qp req = {};
+
+	req.qp_cid = cpu_to_le32(qp->id);
+	bnxt_qplib_rcfw_cmd_prep(&req, CMDQ_BASE_OPCODE_DESTROY_QP,
+				 sizeof(req));
+	bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, NULL, sizeof(req),
+				sizeof(resp), 0);
+	return bnxt_qplib_rcfw_send_message(rcfw, &msg);
+}
+
+static int bnxt_qplib_alloc_init_swq(struct bnxt_qplib_q *que)
+{
+	int rc = 0;
+	int indx;
+
+	que->swq = kcalloc(que->max_wqe, sizeof(*que->swq), GFP_KERNEL);
+	if (!que->swq) {
+		rc = -ENOMEM;
+		goto out;
+	}
+
+	que->swq_start = 0;
+	que->swq_last = que->max_wqe - 1;
+	for (indx = 0; indx < que->max_wqe; indx++)
+		que->swq[indx].next_idx = indx + 1;
+	que->swq[que->swq_last].next_idx = 0; /* Make it circular */
+	que->swq_last = 0;
+out:
+	return rc;
+}
+
+static struct bnxt_qplib_swq *bnxt_qplib_get_swqe(struct bnxt_qplib_q *que,
+						  u32 *swq_idx)
+{
+	u32 idx;
+
+	idx = que->swq_start;
+	if (swq_idx)
+		*swq_idx = idx;
+	return &que->swq[idx];
+}
+
+static void bnxt_qplib_swq_mod_start(struct bnxt_qplib_q *que, u32 idx)
+{
+	que->swq_start = que->swq[idx].next_idx;
+}
+
+static u32 bnxt_qplib_get_stride(void)
+{
+	return sizeof(struct sq_sge);
+}
+
+static u32 bnxt_qplib_get_depth(struct bnxt_qplib_q *que)
+{
+	u8 stride;
+
+	stride = bnxt_qplib_get_stride();
+	return (que->wqe_size * que->max_wqe) / stride;
+}
+
+static u32 _set_sq_size(struct bnxt_qplib_q *que, u8 wqe_mode)
+{
+	/* For Variable mode supply number of 16B slots */
+	return (wqe_mode == BNXT_QPLIB_WQE_MODE_STATIC) ?
+		que->max_wqe : bnxt_qplib_get_depth(que);
+}
+
+static u32 _set_sq_max_slot(u8 wqe_mode)
+{
+	/* for static mode index divisor is 8 */
+	return (wqe_mode == BNXT_QPLIB_WQE_MODE_STATIC) ?
+		sizeof(struct sq_send) / sizeof(struct sq_sge) : 1;
+}
+
+static u32 _set_rq_max_slot(struct bnxt_qplib_q *que)
+{
+	return (que->wqe_size / sizeof(struct sq_sge));
+}
+
+int bnxt_qplib_create_qp1(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp)
+{
+	struct bnxt_qplib_hwq_attr hwq_attr = {};
+	struct bnxt_qplib_rcfw *rcfw = res->rcfw;
+	struct creq_create_qp1_resp resp = {};
+	struct bnxt_qplib_cmdqmsg msg = {};
+	struct bnxt_qplib_q *sq = &qp->sq;
+	struct bnxt_qplib_q *rq = &qp->rq;
+	struct cmdq_create_qp1 req = {};
+	struct bnxt_qplib_reftbl *tbl;
+	unsigned long flag;
+	u8 pg_sz_lvl = 0;
+	u32 qp_flags = 0;
+	int rc;
+
+	/* General */
+	req.type = qp->type;
+	req.dpi = cpu_to_le32(qp->dpi->dpi);
+	req.qp_handle = cpu_to_le64(qp->qp_handle);
+	/* SQ */
+	hwq_attr.res = res;
+	hwq_attr.sginfo = &sq->sginfo;
+	hwq_attr.stride = bnxt_qplib_get_stride();
+	hwq_attr.depth = bnxt_qplib_get_depth(sq);
+	hwq_attr.type = HWQ_TYPE_QUEUE;
+	rc = bnxt_qplib_alloc_init_hwq(&sq->hwq, &hwq_attr);
+	if (rc)
+		goto exit;
+
+	req.sq_size = cpu_to_le32(_set_sq_size(sq, qp->wqe_mode));
+	req.sq_pbl = cpu_to_le64(_get_base_addr(&sq->hwq));
+	pg_sz_lvl = _get_base_pg_size(&sq->hwq) <<
+		    CMDQ_CREATE_QP1_SQ_PG_SIZE_SFT;
+	pg_sz_lvl |= ((sq->hwq.level & CMDQ_CREATE_QP1_SQ_LVL_MASK) <<
+		       CMDQ_CREATE_QP1_SQ_LVL_SFT);
+	req.sq_pg_size_sq_lvl = pg_sz_lvl;
+	req.sq_fwo_sq_sge = cpu_to_le16(((0 << CMDQ_CREATE_QP1_SQ_FWO_SFT) &
+					 CMDQ_CREATE_QP1_SQ_FWO_MASK) |
+					 (sq->max_sge &
+					 CMDQ_CREATE_QP1_SQ_SGE_MASK));
+	req.scq_cid = cpu_to_le32(qp->scq->id);
+
+	/* RQ */
+	if (!qp->srq) {
+		hwq_attr.res = res;
+		hwq_attr.sginfo = &rq->sginfo;
+		hwq_attr.stride = bnxt_qplib_get_stride();
+		hwq_attr.depth = bnxt_qplib_get_depth(rq);
+		hwq_attr.type = HWQ_TYPE_QUEUE;
+		rc = bnxt_qplib_alloc_init_hwq(&rq->hwq, &hwq_attr);
+		if (rc)
+			goto fail_sq;
+		req.rq_size = cpu_to_le32(rq->max_wqe);
+		req.rq_pbl = cpu_to_le64(_get_base_addr(&rq->hwq));
+		pg_sz_lvl = _get_base_pg_size(&rq->hwq) <<
+					      CMDQ_CREATE_QP1_RQ_PG_SIZE_SFT;
+		pg_sz_lvl |= ((rq->hwq.level & CMDQ_CREATE_QP1_RQ_LVL_MASK) <<
+			      CMDQ_CREATE_QP1_RQ_LVL_SFT);
+		req.rq_pg_size_rq_lvl = pg_sz_lvl;
+		req.rq_fwo_rq_sge =
+			cpu_to_le16(((0 << CMDQ_CREATE_QP1_RQ_FWO_SFT) &
+				     CMDQ_CREATE_QP1_RQ_FWO_MASK) |
+				     (rq->max_sge &
+				     CMDQ_CREATE_QP1_RQ_SGE_MASK));
+	} else {
+		/* SRQ */
+		qp_flags |= CMDQ_CREATE_QP1_QP_FLAGS_SRQ_USED;
+		req.srq_cid = cpu_to_le32(qp->srq->id);
+	}
+	req.rcq_cid = cpu_to_le32(qp->rcq->id);
+
+	qp_flags |= CMDQ_CREATE_QP1_QP_FLAGS_RESERVED_LKEY_ENABLE;
+	req.qp_flags = cpu_to_le32(qp_flags);
+	req.pd_id = cpu_to_le32(qp->pd->id);
+
+	bnxt_qplib_rcfw_cmd_prep(&req, CMDQ_BASE_OPCODE_CREATE_QP1,
+				 sizeof(req));
+	bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, NULL, sizeof(req),
+				sizeof(resp), 0);
+	rc = bnxt_qplib_rcfw_send_message(rcfw, &msg);
+	if (rc)
+		goto fail_rq;
+
+	rc = bnxt_qplib_alloc_init_swq(sq);
+	if (rc)
+		goto sq_swq;
+
+	if (!qp->srq) {
+		rc = bnxt_qplib_alloc_init_swq(rq);
+		if (rc)
+			goto rq_swq;
+	}
+
+	qp->id = le32_to_cpu(resp.xid);
+	qp->cur_qp_state = CMDQ_MODIFY_QP_NEW_STATE_RESET;
+	qp->cctx = res->cctx;
+	sq->dbinfo.hwq = &sq->hwq;
+	sq->dbinfo.xid = qp->id;
+	sq->dbinfo.db = qp->dpi->dbr;
+	sq->dbinfo.max_slot = _set_sq_max_slot(qp->wqe_mode);
+	sq->dbinfo.flags = 0;
+	spin_lock_init(&sq->dbinfo.lock);
+	sq->dbinfo.shadow_key = BNXT_QPLIB_DBR_KEY_INVALID;
+	sq->dbinfo.res = res;
+	if (rq->max_wqe) {
+		rq->dbinfo.hwq = &rq->hwq;
+		rq->dbinfo.xid = qp->id;
+		rq->dbinfo.db = qp->dpi->dbr;
+		rq->dbinfo.max_slot = _set_rq_max_slot(rq);
+		rq->dbinfo.flags = 0;
+		spin_lock_init(&rq->dbinfo.lock);
+		rq->dbinfo.shadow_key = BNXT_QPLIB_DBR_KEY_INVALID;
+		rq->dbinfo.res = res;
+	}
+
+	tbl = &res->reftbl.qpref;
+	spin_lock_irqsave(&tbl->lock, flag);
+	tbl->rec[tbl->max].xid = qp->id;
+	tbl->rec[tbl->max].handle = qp;
+	spin_unlock_irqrestore(&tbl->lock, flag);
+
+	return 0;
+rq_swq:
+	kfree(sq->swq);
+sq_swq:
+	__qplib_destroy_qp(rcfw, qp);
+fail_rq:
+	bnxt_qplib_free_hwq(res, &rq->hwq);
+fail_sq:
+	bnxt_qplib_free_hwq(res, &sq->hwq);
+exit:
+	return rc;
+}
+
+static void bnxt_qplib_init_psn_ptr(struct bnxt_qplib_qp *qp, int size)
+{
+	struct bnxt_qplib_hwq *sq_hwq;
+	struct bnxt_qplib_q *sq;
+	u64 fpsne, psn_pg;
+	u16 indx_pad = 0;
+
+	sq = &qp->sq;
+	sq_hwq = &sq->hwq;
+	/* First psn entry */
+	fpsne = (u64)bnxt_qplib_get_qe(sq_hwq, sq_hwq->depth, &psn_pg);
+	if (!IS_ALIGNED(fpsne, PAGE_SIZE))
+		indx_pad = (fpsne & ~PAGE_MASK) / size;
+	sq_hwq->pad_pgofft = indx_pad;
+	sq_hwq->pad_pg = (u64 *)psn_pg;
+	sq_hwq->pad_stride = size;
+}
+
+int bnxt_qplib_create_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp)
+{
+	struct bnxt_qplib_hwq_attr hwq_attr = {};
+	struct bnxt_qplib_rcfw *rcfw = res->rcfw;
+	struct bnxt_qplib_sg_info sginfo = {};
+	struct creq_create_qp_resp resp = {};
+	struct bnxt_qplib_cmdqmsg msg = {};
+	struct bnxt_qplib_q *sq = &qp->sq;
+	struct bnxt_qplib_q *rq = &qp->rq;
+	struct cmdq_create_qp req = {};
+	struct bnxt_qplib_reftbl *tbl;
+	struct bnxt_qplib_hwq *xrrq;
+	int rc, req_size, psn_sz;
+	unsigned long flag;
+	u8 pg_sz_lvl = 0;
+	u32 qp_flags = 0;
+	u32 qp_idx;
+	u16 nsge;
+	u32 sqsz;
+
+	qp->cctx = res->cctx;
+	if (res->dattr)
+		qp->dev_cap_flags = res->dattr->dev_cap_flags;
+	/* General */
+	req.type = qp->type;
+	req.dpi = cpu_to_le32(qp->dpi->dpi);
+	req.qp_handle = cpu_to_le64(qp->qp_handle);
+
+	/* SQ */
+	if (qp->type == CMDQ_CREATE_QP_TYPE_RC) {
+		psn_sz = _is_chip_gen_p5_p7(qp->cctx) ?
+			 sizeof(struct sq_psn_search_ext) :
+			 sizeof(struct sq_psn_search);
+		if (BNXT_RE_HW_RETX(qp->dev_cap_flags)) {
+			psn_sz = sizeof(struct sq_msn_search);
+			qp->msn = 0;
+		}
+	} else {
+		psn_sz = 0;
+	}
+
+	hwq_attr.res = res;
+	hwq_attr.sginfo = &sq->sginfo;
+	hwq_attr.stride = bnxt_qplib_get_stride();
+	hwq_attr.depth = bnxt_qplib_get_depth(sq);
+	hwq_attr.aux_stride = psn_sz;
+	hwq_attr.aux_depth = (psn_sz) ?
+				 _set_sq_size(sq, qp->wqe_mode) : 0;
+	/* Update msn tbl size */
+	if (BNXT_RE_HW_RETX(qp->dev_cap_flags) && psn_sz) {
+		if (qp->wqe_mode == BNXT_QPLIB_WQE_MODE_STATIC)
+			hwq_attr.aux_depth = roundup_pow_of_two(_set_sq_size(sq, qp->wqe_mode));
+		else
+			hwq_attr.aux_depth = roundup_pow_of_two(_set_sq_size(sq, qp->wqe_mode)) / 2;
+		qp->msn_tbl_sz = hwq_attr.aux_depth;
+		qp->msn = 0;
+	}
+	hwq_attr.type = HWQ_TYPE_QUEUE;
+	rc = bnxt_qplib_alloc_init_hwq(&sq->hwq, &hwq_attr);
+	if (rc)
+		goto exit;
+
+	sqsz = _set_sq_size(sq, qp->wqe_mode);
+	/* 0xffff is the max sq size hw limits to */
+	if (sqsz > BNXT_QPLIB_MAX_SQSZ) {
+		pr_err("QPLIB: FP: QP (0x%x) exceeds sq size %d\n", qp->id, sqsz);
+		goto fail_sq;
+	}
+	req.sq_size = cpu_to_le32(sqsz);
+	req.sq_pbl = cpu_to_le64(_get_base_addr(&sq->hwq));
+	pg_sz_lvl = _get_base_pg_size(&sq->hwq) <<
+		    CMDQ_CREATE_QP_SQ_PG_SIZE_SFT;
+	pg_sz_lvl |= ((sq->hwq.level & CMDQ_CREATE_QP_SQ_LVL_MASK) <<
+		       CMDQ_CREATE_QP_SQ_LVL_SFT);
+	req.sq_pg_size_sq_lvl = pg_sz_lvl;
+	req.sq_fwo_sq_sge = cpu_to_le16(((0 << CMDQ_CREATE_QP_SQ_FWO_SFT) &
+					 CMDQ_CREATE_QP_SQ_FWO_MASK) |
+					 ((BNXT_RE_HW_RETX(qp->dev_cap_flags)) ?
+					  BNXT_MSN_TBLE_SGE : sq->max_sge &
+					 CMDQ_CREATE_QP_SQ_SGE_MASK));
+	req.scq_cid = cpu_to_le32(qp->scq->id);
+
+	/* RQ/SRQ */
+	if (!qp->srq) {
+		hwq_attr.res = res;
+		hwq_attr.sginfo = &rq->sginfo;
+		hwq_attr.stride = bnxt_qplib_get_stride();
+		hwq_attr.depth = bnxt_qplib_get_depth(rq);
+		hwq_attr.aux_stride = 0;
+		hwq_attr.aux_depth = 0;
+		hwq_attr.type = HWQ_TYPE_QUEUE;
+		rc = bnxt_qplib_alloc_init_hwq(&rq->hwq, &hwq_attr);
+		if (rc)
+			goto fail_sq;
+		req.rq_size = cpu_to_le32(rq->max_wqe);
+		req.rq_pbl = cpu_to_le64(_get_base_addr(&rq->hwq));
+		pg_sz_lvl = _get_base_pg_size(&rq->hwq) <<
+				CMDQ_CREATE_QP_RQ_PG_SIZE_SFT;
+		pg_sz_lvl |= ((rq->hwq.level & CMDQ_CREATE_QP_RQ_LVL_MASK) <<
+				CMDQ_CREATE_QP_RQ_LVL_SFT);
+		req.rq_pg_size_rq_lvl = pg_sz_lvl;
+		nsge = (qp->wqe_mode == BNXT_QPLIB_WQE_MODE_STATIC) ?
+			res->dattr->max_qp_sges : rq->max_sge;
+		req.rq_fwo_rq_sge =
+			cpu_to_le16(((0 << CMDQ_CREATE_QP_RQ_FWO_SFT) &
+				      CMDQ_CREATE_QP_RQ_FWO_MASK) |
+				     (nsge & CMDQ_CREATE_QP_RQ_SGE_MASK));
+	} else {
+		qp_flags |= CMDQ_CREATE_QP_QP_FLAGS_SRQ_USED;
+		req.srq_cid = cpu_to_le32(qp->srq->id);
+	}
+	req.rcq_cid = cpu_to_le32(qp->rcq->id);
+
+	qp_flags |= CMDQ_CREATE_QP_QP_FLAGS_RESERVED_LKEY_ENABLE;
+	qp_flags |= CMDQ_CREATE_QP_QP_FLAGS_FR_PMR_ENABLED;
+	if (qp->sig_type)
+		qp_flags |= CMDQ_CREATE_QP_QP_FLAGS_FORCE_COMPLETION;
+	if (qp->wqe_mode == BNXT_QPLIB_WQE_MODE_VARIABLE)
+		qp_flags |= CMDQ_CREATE_QP_QP_FLAGS_VARIABLE_SIZED_WQE_ENABLED;
+	if (res->cctx->modes.te_bypass)
+		qp_flags |= CMDQ_CREATE_QP_QP_FLAGS_OPTIMIZED_TRANSMIT_ENABLED;
+	if (res->dattr &&
+	    bnxt_ext_stats_supported(qp->cctx, res->dattr->dev_cap_flags, res->is_vf))
+		qp_flags |= CMDQ_CREATE_QP_QP_FLAGS_EXT_STATS_ENABLED;
+	req.qp_flags = cpu_to_le32(qp_flags);
+
+	/* ORRQ and IRRQ */
+	if (psn_sz) {
+		xrrq = &qp->orrq;
+		xrrq->max_elements =
+			ORD_LIMIT_TO_ORRQ_SLOTS(qp->max_rd_atomic);
+		req_size = xrrq->max_elements *
+			   BNXT_QPLIB_MAX_ORRQE_ENTRY_SIZE + PAGE_SIZE - 1;
+		req_size &= ~(PAGE_SIZE - 1);
+		sginfo.pgsize = req_size;
+		sginfo.pgshft = PAGE_SHIFT;
+
+		hwq_attr.res = res;
+		hwq_attr.sginfo = &sginfo;
+		hwq_attr.depth = xrrq->max_elements;
+		hwq_attr.stride = BNXT_QPLIB_MAX_ORRQE_ENTRY_SIZE;
+		hwq_attr.aux_stride = 0;
+		hwq_attr.aux_depth = 0;
+		hwq_attr.type = HWQ_TYPE_CTX;
+		rc = bnxt_qplib_alloc_init_hwq(xrrq, &hwq_attr);
+		if (rc)
+			goto fail_rq;
+		req.orrq_addr = cpu_to_le64(_get_base_addr(xrrq));
+
+		xrrq = &qp->irrq;
+		xrrq->max_elements = IRD_LIMIT_TO_IRRQ_SLOTS(
+						qp->max_dest_rd_atomic);
+		req_size = xrrq->max_elements *
+			   BNXT_QPLIB_MAX_IRRQE_ENTRY_SIZE + PAGE_SIZE - 1;
+		req_size &= ~(PAGE_SIZE - 1);
+		sginfo.pgsize = req_size;
+		hwq_attr.depth =  xrrq->max_elements;
+		hwq_attr.stride = BNXT_QPLIB_MAX_IRRQE_ENTRY_SIZE;
+		rc = bnxt_qplib_alloc_init_hwq(xrrq, &hwq_attr);
+		if (rc)
+			goto fail_orrq;
+		req.irrq_addr = cpu_to_le64(_get_base_addr(xrrq));
+	}
+	req.pd_id = cpu_to_le32(qp->pd->id);
+
+	bnxt_qplib_rcfw_cmd_prep(&req, CMDQ_BASE_OPCODE_CREATE_QP,
+				 sizeof(req));
+	bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, NULL, sizeof(req),
+				sizeof(resp), 0);
+	rc = bnxt_qplib_rcfw_send_message(rcfw, &msg);
+	if (rc)
+		goto fail;
+
+	if (!qp->is_user) {
+		rc = bnxt_qplib_alloc_init_swq(sq);
+		if (rc)
+			goto swq_sq;
+		if (!qp->srq) {
+			rc = bnxt_qplib_alloc_init_swq(rq);
+			if (rc)
+				goto swq_rq;
+		}
+		if (psn_sz)
+			bnxt_qplib_init_psn_ptr(qp, psn_sz);
+	}
+	qp->id = le32_to_cpu(resp.xid);
+	qp->cur_qp_state = CMDQ_MODIFY_QP_NEW_STATE_RESET;
+	INIT_LIST_HEAD(&qp->sq_flush);
+	INIT_LIST_HEAD(&qp->rq_flush);
+
+	sq->dbinfo.hwq = &sq->hwq;
+	sq->dbinfo.xid = qp->id;
+	sq->dbinfo.db = qp->dpi->dbr;
+	sq->dbinfo.max_slot = _set_sq_max_slot(qp->wqe_mode);
+	sq->dbinfo.flags = 0;
+	spin_lock_init(&sq->dbinfo.lock);
+	sq->dbinfo.shadow_key = BNXT_QPLIB_DBR_KEY_INVALID;
+	sq->dbinfo.res = res;
+	sq->dbinfo.seed = qp->id;
+	if (rq->max_wqe) {
+		rq->dbinfo.hwq = &rq->hwq;
+		rq->dbinfo.xid = qp->id;
+		rq->dbinfo.db = qp->dpi->dbr;
+		rq->dbinfo.max_slot = _set_rq_max_slot(rq);
+		rq->dbinfo.flags = 0;
+		spin_lock_init(&rq->dbinfo.lock);
+		rq->dbinfo.shadow_key = BNXT_QPLIB_DBR_KEY_INVALID;
+		rq->dbinfo.res = res;
+		rq->dbinfo.seed = qp->id;
+	}
+
+	tbl = &res->reftbl.qpref;
+	qp_idx = map_qp_id_to_tbl_indx(qp->id, tbl);
+	spin_lock_irqsave(&tbl->lock, flag);
+	tbl->rec[qp_idx].xid = qp->id;
+	tbl->rec[qp_idx].handle = qp;
+	spin_unlock_irqrestore(&tbl->lock, flag);
+
+	return 0;
+swq_rq:
+	kfree(sq->swq);
+swq_sq:
+	__qplib_destroy_qp(rcfw, qp);
+fail:
+	bnxt_qplib_free_hwq(res, &qp->irrq);
+fail_orrq:
+	bnxt_qplib_free_hwq(res, &qp->orrq);
+fail_rq:
+	bnxt_qplib_free_hwq(res, &rq->hwq);
+fail_sq:
+	bnxt_qplib_free_hwq(res, &sq->hwq);
+exit:
+	return rc;
+}
+
+static void __filter_modify_flags(struct bnxt_qplib_qp *qp)
+{
+	switch (qp->cur_qp_state) {
+	case CMDQ_MODIFY_QP_NEW_STATE_RESET:
+		switch (qp->state) {
+		case CMDQ_MODIFY_QP_NEW_STATE_INIT:
+			break;
+		default:
+			break;
+		}
+		break;
+	case CMDQ_MODIFY_QP_NEW_STATE_INIT:
+		switch (qp->state) {
+		case CMDQ_MODIFY_QP_NEW_STATE_RTR:
+			if (!(qp->modify_flags &
+			      CMDQ_MODIFY_QP_MODIFY_MASK_PATH_MTU)) {
+				qp->modify_flags |=
+					CMDQ_MODIFY_QP_MODIFY_MASK_PATH_MTU;
+				qp->path_mtu = CMDQ_MODIFY_QP_PATH_MTU_MTU_2048;
+			}
+			qp->modify_flags &=
+				~CMDQ_MODIFY_QP_MODIFY_MASK_VLAN_ID;
+			/* Bono FW requires the max_dest_rd_atomic to be >= 1 */
+			if (qp->max_dest_rd_atomic < 1)
+				qp->max_dest_rd_atomic = 1;
+			qp->modify_flags &= ~CMDQ_MODIFY_QP_MODIFY_MASK_SRC_MAC;
+			/* Bono FW 20.6.5 requires SGID_INDEX to be configured */
+			if (!(qp->modify_flags &
+			      CMDQ_MODIFY_QP_MODIFY_MASK_SGID_INDEX)) {
+				qp->modify_flags |=
+					CMDQ_MODIFY_QP_MODIFY_MASK_SGID_INDEX;
+				qp->ah.sgid_index = 0;
+			}
+			break;
+		default:
+			break;
+		}
+		break;
+	case CMDQ_MODIFY_QP_NEW_STATE_RTR:
+		switch (qp->state) {
+		case CMDQ_MODIFY_QP_NEW_STATE_RTS:
+			/* Bono FW requires the max_rd_atomic to be >= 1 */
+			if (qp->max_rd_atomic < 1)
+				qp->max_rd_atomic = 1;
+			qp->modify_flags &=
+				~(CMDQ_MODIFY_QP_MODIFY_MASK_PKEY |
+				  CMDQ_MODIFY_QP_MODIFY_MASK_DGID |
+				  CMDQ_MODIFY_QP_MODIFY_MASK_FLOW_LABEL |
+				  CMDQ_MODIFY_QP_MODIFY_MASK_SGID_INDEX |
+				  CMDQ_MODIFY_QP_MODIFY_MASK_HOP_LIMIT |
+				  CMDQ_MODIFY_QP_MODIFY_MASK_TRAFFIC_CLASS |
+				  CMDQ_MODIFY_QP_MODIFY_MASK_DEST_MAC |
+				  CMDQ_MODIFY_QP_MODIFY_MASK_PATH_MTU |
+				  CMDQ_MODIFY_QP_MODIFY_MASK_RQ_PSN |
+				  CMDQ_MODIFY_QP_MODIFY_MASK_MIN_RNR_TIMER |
+				  CMDQ_MODIFY_QP_MODIFY_MASK_MAX_DEST_RD_ATOMIC |
+				  CMDQ_MODIFY_QP_MODIFY_MASK_DEST_QP_ID);
+			break;
+		default:
+			break;
+		}
+		break;
+	case CMDQ_MODIFY_QP_NEW_STATE_RTS:
+		break;
+	case CMDQ_MODIFY_QP_NEW_STATE_SQD:
+		break;
+	case CMDQ_MODIFY_QP_NEW_STATE_SQE:
+		break;
+	case CMDQ_MODIFY_QP_NEW_STATE_ERR:
+		break;
+	default:
+		break;
+	}
+}
+
+int bnxt_qplib_modify_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp)
+{
+	struct bnxt_qplib_rcfw *rcfw = res->rcfw;
+	struct creq_modify_qp_resp resp = {};
+	struct bnxt_qplib_cmdqmsg msg = {};
+	struct cmdq_modify_qp req = {};
+	bool ppp_requested = false;
+	u32 temp32[4];
+	u32 bmask;
+	int rc;
+
+	bnxt_qplib_rcfw_cmd_prep(&req, CMDQ_BASE_OPCODE_MODIFY_QP,
+				 sizeof(req));
+
+	/* Filter out the qp_attr_mask based on the state->new transition */
+	__filter_modify_flags(qp);
+	bmask = qp->modify_flags;
+	req.modify_mask = cpu_to_le32(qp->modify_flags);
+	req.qp_cid = cpu_to_le32(qp->id);
+	if (bmask & CMDQ_MODIFY_QP_MODIFY_MASK_STATE) {
+		req.network_type_en_sqd_async_notify_new_state =
+				(qp->state & CMDQ_MODIFY_QP_NEW_STATE_MASK) |
+				(qp->en_sqd_async_notify == true ?
+					CMDQ_MODIFY_QP_EN_SQD_ASYNC_NOTIFY : 0);
+		if (__can_request_ppp(qp)) {
+			req.path_mtu_pingpong_push_enable =
+				CMDQ_MODIFY_QP_PINGPONG_PUSH_ENABLE;
+			req.pingpong_push_dpi = qp->ppp.dpi;
+			ppp_requested = true;
+		}
+	}
+	req.network_type_en_sqd_async_notify_new_state |= qp->nw_type;
+
+	if (bmask & CMDQ_MODIFY_QP_MODIFY_MASK_ACCESS) {
+		req.access = qp->access;
+	}
+	if (bmask & CMDQ_MODIFY_QP_MODIFY_MASK_PKEY)
+		req.pkey = IB_DEFAULT_PKEY_FULL;
+
+	if (bmask & CMDQ_MODIFY_QP_MODIFY_MASK_QKEY) {
+		req.qkey = cpu_to_le32(qp->qkey);
+	}
+	if (bmask & CMDQ_MODIFY_QP_MODIFY_MASK_DGID) {
+		memcpy(temp32, qp->ah.dgid.data, sizeof(struct bnxt_qplib_gid));
+		req.dgid[0] = cpu_to_le32(temp32[0]);
+		req.dgid[1] = cpu_to_le32(temp32[1]);
+		req.dgid[2] = cpu_to_le32(temp32[2]);
+		req.dgid[3] = cpu_to_le32(temp32[3]);
+	}
+	if (bmask & CMDQ_MODIFY_QP_MODIFY_MASK_FLOW_LABEL) {
+		req.flow_label = cpu_to_le32(qp->ah.flow_label);
+	}
+	if (bmask & CMDQ_MODIFY_QP_MODIFY_MASK_SGID_INDEX) {
+		req.sgid_index = cpu_to_le16(res->sgid_tbl.hw_id[qp->ah.sgid_index]);
+	}
+	if (bmask & CMDQ_MODIFY_QP_MODIFY_MASK_HOP_LIMIT) {
+		req.hop_limit = qp->ah.hop_limit;
+	}
+	if (bmask & CMDQ_MODIFY_QP_MODIFY_MASK_TRAFFIC_CLASS) {
+		req.traffic_class = qp->ah.traffic_class;
+	}
+	if (bmask & CMDQ_MODIFY_QP_MODIFY_MASK_DEST_MAC) {
+		memcpy(req.dest_mac, qp->ah.dmac, 6);
+	}
+	if (bmask & CMDQ_MODIFY_QP_MODIFY_MASK_PATH_MTU) {
+		req.path_mtu_pingpong_push_enable = qp->path_mtu;
+	}
+	if (bmask & CMDQ_MODIFY_QP_MODIFY_MASK_TIMEOUT) {
+		req.timeout = qp->timeout;
+	}
+	if (bmask & CMDQ_MODIFY_QP_MODIFY_MASK_RETRY_CNT) {
+		req.retry_cnt = qp->retry_cnt;
+	}
+	if (bmask & CMDQ_MODIFY_QP_MODIFY_MASK_RNR_RETRY) {
+		req.rnr_retry = qp->rnr_retry;
+	}
+	if (bmask & CMDQ_MODIFY_QP_MODIFY_MASK_MIN_RNR_TIMER) {
+		req.min_rnr_timer = qp->min_rnr_timer;
+	}
+	if (bmask & CMDQ_MODIFY_QP_MODIFY_MASK_RQ_PSN) {
+		req.rq_psn = cpu_to_le32(qp->rq.psn);
+	}
+	if (bmask & CMDQ_MODIFY_QP_MODIFY_MASK_SQ_PSN) {
+		req.sq_psn = cpu_to_le32(qp->sq.psn);
+	}
+	if (bmask & CMDQ_MODIFY_QP_MODIFY_MASK_MAX_RD_ATOMIC) {
+		req.max_rd_atomic =
+			ORD_LIMIT_TO_ORRQ_SLOTS(qp->max_rd_atomic);
+	}
+	if (bmask & CMDQ_MODIFY_QP_MODIFY_MASK_MAX_DEST_RD_ATOMIC) {
+		req.max_dest_rd_atomic =
+			IRD_LIMIT_TO_IRRQ_SLOTS(qp->max_dest_rd_atomic);
+	}
+	req.sq_size = cpu_to_le32(qp->sq.hwq.max_elements);
+	req.rq_size = cpu_to_le32(qp->rq.hwq.max_elements);
+	req.sq_sge = cpu_to_le16(qp->sq.max_sge);
+	req.rq_sge = cpu_to_le16(qp->rq.max_sge);
+	req.max_inline_data = cpu_to_le32(qp->max_inline_data);
+	if (bmask & CMDQ_MODIFY_QP_MODIFY_MASK_DEST_QP_ID)
+		req.dest_qp_id = cpu_to_le32(qp->dest_qpn);
+	if (bmask & CMDQ_MODIFY_QP_MODIFY_MASK_ENABLE_CC)
+		req.enable_cc = cpu_to_le16(CMDQ_MODIFY_QP_ENABLE_CC);
+	if (bmask & CMDQ_MODIFY_QP_MODIFY_MASK_TOS_ECN)
+		req.tos_dscp_tos_ecn =
+			((qp->tos_ecn << CMDQ_MODIFY_QP_TOS_ECN_SFT) &
+			 CMDQ_MODIFY_QP_TOS_ECN_MASK);
+	if (bmask & CMDQ_MODIFY_QP_MODIFY_MASK_TOS_DSCP)
+		req.tos_dscp_tos_ecn |=
+			((qp->tos_dscp << CMDQ_MODIFY_QP_TOS_DSCP_SFT) &
+			 CMDQ_MODIFY_QP_TOS_DSCP_MASK);
+	req.vlan_pcp_vlan_dei_vlan_id = cpu_to_le16(qp->vlan_id);
+	bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, NULL, sizeof(req),
+				sizeof(resp), 0);
+	msg.qp_state = qp->state;
+
+	rc = bnxt_qplib_rcfw_send_message(rcfw, &msg);
+	if (rc == -ETIMEDOUT && (qp->state == CMDQ_MODIFY_QP_NEW_STATE_ERR)) {
+		qp->cur_qp_state = qp->state;
+		return 0;
+	} else if (rc) {
+		return rc;
+	}
+	if (qp->state == CMDQ_MODIFY_QP_NEW_STATE_RTR)
+		qp->lag_src_mac = be32_to_cpu(resp.lag_src_mac);
+
+	if (ppp_requested)
+		qp->ppp.st_idx_en = resp.pingpong_push_state_index_enabled;
+
+	qp->cur_qp_state = qp->state;
+	return 0;
+}
+
+int bnxt_qplib_query_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp)
+{
+	struct bnxt_qplib_rcfw *rcfw = res->rcfw;
+	struct creq_query_qp_resp resp = {};
+	struct bnxt_qplib_cmdqmsg msg = {};
+	struct bnxt_qplib_rcfw_sbuf sbuf;
+	struct creq_query_qp_resp_sb *sb;
+	struct cmdq_query_qp req = {};
+	u32 temp32[4];
+	int i, rc;
+
+	sbuf.size = ALIGN(sizeof(*sb), BNXT_QPLIB_CMDQE_UNITS);
+	sbuf.sb = dma_zalloc_coherent(&rcfw->pdev->dev, sbuf.size,
+				       &sbuf.dma_addr, GFP_KERNEL);
+	if (!sbuf.sb)
+		return -ENOMEM;
+	sb = sbuf.sb;
+
+	bnxt_qplib_rcfw_cmd_prep(&req, CMDQ_BASE_OPCODE_QUERY_QP,
+				 sizeof(req));
+	req.qp_cid = cpu_to_le32(qp->id);
+	req.resp_size = sbuf.size / BNXT_QPLIB_CMDQE_UNITS;
+	bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, &sbuf, sizeof(req),
+				sizeof(resp), 0);
+	rc = bnxt_qplib_rcfw_send_message(rcfw, &msg);
+	if (rc)
+		goto bail;
+
+	/* Extract the context from the side buffer */
+	qp->state = sb->en_sqd_async_notify_state &
+			CREQ_QUERY_QP_RESP_SB_STATE_MASK;
+	qp->cur_qp_state = qp->state;
+	qp->en_sqd_async_notify = sb->en_sqd_async_notify_state &
+				  CREQ_QUERY_QP_RESP_SB_EN_SQD_ASYNC_NOTIFY ?
+				  true : false;
+	qp->access = sb->access;
+	qp->pkey_index = le16_to_cpu(sb->pkey);
+	qp->qkey = le32_to_cpu(sb->qkey);
+
+	temp32[0] = le32_to_cpu(sb->dgid[0]);
+	temp32[1] = le32_to_cpu(sb->dgid[1]);
+	temp32[2] = le32_to_cpu(sb->dgid[2]);
+	temp32[3] = le32_to_cpu(sb->dgid[3]);
+	memcpy(qp->ah.dgid.data, temp32, sizeof(qp->ah.dgid.data));
+
+	qp->ah.flow_label = le32_to_cpu(sb->flow_label);
+
+	qp->ah.sgid_index = 0;
+	for (i = 0; i < res->sgid_tbl.max; i++) {
+		if (res->sgid_tbl.hw_id[i] == le16_to_cpu(sb->sgid_index)) {
+			qp->ah.sgid_index = i;
+			break;
+		}
+	}
+	if (i == res->sgid_tbl.max)
+		dev_dbg(&res->pdev->dev,
+			"QPLIB: SGID not found qp->id = 0x%x sgid_index = 0x%x\n",
+			qp->id, le16_to_cpu(sb->sgid_index));
+
+	qp->ah.hop_limit = sb->hop_limit;
+	qp->ah.traffic_class = sb->traffic_class;
+	memcpy(qp->ah.dmac, sb->dest_mac, ETH_ALEN);
+	qp->ah.vlan_id = le16_to_cpu(sb->path_mtu_dest_vlan_id) &
+				CREQ_QUERY_QP_RESP_SB_VLAN_ID_MASK >>
+				CREQ_QUERY_QP_RESP_SB_VLAN_ID_SFT;
+	qp->path_mtu = le16_to_cpu(sb->path_mtu_dest_vlan_id) &
+				    CREQ_QUERY_QP_RESP_SB_PATH_MTU_MASK;
+	qp->timeout = sb->timeout;
+	qp->retry_cnt = sb->retry_cnt;
+	qp->rnr_retry = sb->rnr_retry;
+	qp->min_rnr_timer = sb->min_rnr_timer;
+	qp->rq.psn = le32_to_cpu(sb->rq_psn);
+	qp->max_rd_atomic = ORRQ_SLOTS_TO_ORD_LIMIT(sb->max_rd_atomic);
+	qp->sq.psn = le32_to_cpu(sb->sq_psn);
+	qp->max_dest_rd_atomic =
+			IRRQ_SLOTS_TO_IRD_LIMIT(sb->max_dest_rd_atomic);
+	qp->sq.max_wqe = qp->sq.hwq.max_elements;
+	qp->rq.max_wqe = qp->rq.hwq.max_elements;
+	qp->sq.max_sge = le16_to_cpu(sb->sq_sge);
+	qp->rq.max_sge = le16_to_cpu(sb->rq_sge);
+	qp->max_inline_data = le32_to_cpu(sb->max_inline_data);
+	qp->dest_qpn = le32_to_cpu(sb->dest_qp_id);
+	memcpy(qp->smac, sb->src_mac, ETH_ALEN);
+	qp->vlan_id = le16_to_cpu(sb->vlan_pcp_vlan_dei_vlan_id);
+	qp->port_id = le16_to_cpu(sb->port_id);
+bail:
+	dma_free_coherent(&rcfw->pdev->dev, sbuf.size,
+				  sbuf.sb, sbuf.dma_addr);
+	return rc;
+}
+
+
+static void __clean_cq(struct bnxt_qplib_cq *cq, u64 qp)
+{
+	struct bnxt_qplib_hwq *cq_hwq = &cq->hwq;
+	u32 peek_flags, peek_cons;
+	struct cq_base *hw_cqe;
+	int i;
+
+	peek_flags = cq->dbinfo.flags;
+	peek_cons = cq_hwq->cons;
+	for (i = 0; i < cq_hwq->depth; i++) {
+		hw_cqe = bnxt_qplib_get_qe(cq_hwq, peek_cons, NULL);
+		if (CQE_CMP_VALID(hw_cqe, peek_flags)) {
+			dma_rmb();
+			switch (hw_cqe->cqe_type_toggle & CQ_BASE_CQE_TYPE_MASK) {
+			case CQ_BASE_CQE_TYPE_REQ:
+			case CQ_BASE_CQE_TYPE_TERMINAL:
+			{
+				struct cq_req *cqe = (struct cq_req *)hw_cqe;
+
+				if (qp == le64_to_cpu(cqe->qp_handle))
+					cqe->qp_handle = 0;
+				break;
+			}
+			case CQ_BASE_CQE_TYPE_RES_RC:
+			case CQ_BASE_CQE_TYPE_RES_UD:
+			case CQ_BASE_CQE_TYPE_RES_RAWETH_QP1:
+			{
+				struct cq_res_rc *cqe = (struct cq_res_rc *)hw_cqe;
+
+				if (qp == le64_to_cpu(cqe->qp_handle))
+					cqe->qp_handle = 0;
+				break;
+			}
+			default:
+				break;
+			}
+		}
+		bnxt_qplib_hwq_incr_cons(cq_hwq->depth, &peek_cons,
+					 1, &peek_flags);
+	}
+}
+
+int bnxt_qplib_destroy_qp(struct bnxt_qplib_res *res,
+			  struct bnxt_qplib_qp *qp)
+{
+	struct bnxt_qplib_rcfw *rcfw = res->rcfw;
+	struct bnxt_qplib_reftbl *tbl;
+	unsigned long flags;
+	u32 qp_idx;
+	int rc;
+
+	tbl = &res->reftbl.qpref;
+	qp_idx = map_qp_id_to_tbl_indx(qp->id, tbl);
+	spin_lock_irqsave(&tbl->lock, flags);
+	tbl->rec[qp_idx].xid = BNXT_QPLIB_QP_ID_INVALID;
+	tbl->rec[qp_idx].handle = NULL;
+	spin_unlock_irqrestore(&tbl->lock, flags);
+
+	rc = __qplib_destroy_qp(rcfw, qp);
+	if (rc) {
+		spin_lock_irqsave(&tbl->lock, flags);
+		tbl->rec[qp_idx].xid = qp->id;
+		tbl->rec[qp_idx].handle = qp;
+		spin_unlock_irqrestore(&tbl->lock, flags);
+		return rc;
+	}
+
+	return 0;
+}
+
+void bnxt_qplib_free_qp_res(struct bnxt_qplib_res *res,
+			    struct bnxt_qplib_qp *qp)
+{
+	if (qp->irrq.max_elements)
+		bnxt_qplib_free_hwq(res, &qp->irrq);
+	if (qp->orrq.max_elements)
+		bnxt_qplib_free_hwq(res, &qp->orrq);
+
+	if (!qp->is_user)
+		kfree(qp->rq.swq);
+	bnxt_qplib_free_hwq(res, &qp->rq.hwq);
+
+	if (!qp->is_user)
+		kfree(qp->sq.swq);
+	bnxt_qplib_free_hwq(res, &qp->sq.hwq);
+}
+
+void *bnxt_qplib_get_qp1_sq_buf(struct bnxt_qplib_qp *qp,
+				struct bnxt_qplib_sge *sge)
+{
+	struct bnxt_qplib_q *sq = &qp->sq;
+	struct bnxt_qplib_hdrbuf *buf;
+	u32 sw_prod;
+
+	memset(sge, 0, sizeof(*sge));
+
+	buf = qp->sq_hdr_buf;
+	if (buf) {
+		sw_prod = sq->swq_start;
+		sge->addr = (dma_addr_t)(buf->dma_map + sw_prod * buf->step);
+		sge->lkey = 0xFFFFFFFF;
+		sge->size = buf->step;
+		return buf->va + sw_prod * sge->size;
+	}
+	return NULL;
+}
+
+u32 bnxt_qplib_get_rq_prod_index(struct bnxt_qplib_qp *qp)
+{
+	struct bnxt_qplib_q *rq = &qp->rq;
+
+	return rq->swq_start;
+}
+
+void *bnxt_qplib_get_qp1_rq_buf(struct bnxt_qplib_qp *qp,
+				struct bnxt_qplib_sge *sge)
+{
+	struct bnxt_qplib_q *rq = &qp->rq;
+	struct bnxt_qplib_hdrbuf *buf;
+	u32 sw_prod;
+
+	memset(sge, 0, sizeof(*sge));
+
+	buf = qp->rq_hdr_buf;
+	if (buf) {
+		sw_prod = rq->swq_start;
+		sge->addr = (dma_addr_t)(buf->dma_map + sw_prod * buf->step);
+		sge->lkey = 0xFFFFFFFF;
+		sge->size = buf->step;
+		return buf->va + sw_prod * sge->size;
+	}
+	return NULL;
+}
+
+/* Fil the MSN table into the next psn row */
+static void bnxt_qplib_fill_msn_search(struct bnxt_qplib_qp *qp,
+				       struct bnxt_qplib_swqe *wqe,
+				       struct bnxt_qplib_swq *swq)
+{
+	struct sq_msn_search *msns;
+	u32 start_psn, next_psn;
+	u16 start_idx;
+
+	msns = (struct sq_msn_search *)swq->psn_search;
+	msns->start_idx_next_psn_start_psn = 0;
+
+	start_psn = swq->start_psn;
+	next_psn = swq->next_psn;
+	start_idx = swq->slot_idx;
+	msns->start_idx_next_psn_start_psn |=
+		bnxt_re_update_msn_tbl(start_idx, next_psn, start_psn);
+	pr_debug("QP_LIB MSN %d START_IDX %u NEXT_PSN %u START_PSN %u\n",
+		 qp->msn,
+		 (u16)
+		 cpu_to_le16(BNXT_RE_MSN_IDX(msns->start_idx_next_psn_start_psn)),
+		 (u32)
+		 cpu_to_le32(BNXT_RE_MSN_NPSN(msns->start_idx_next_psn_start_psn)),
+		 (u32)
+		 cpu_to_le32(BNXT_RE_MSN_SPSN(msns->start_idx_next_psn_start_psn)));
+	qp->msn++;
+	qp->msn %= qp->msn_tbl_sz;
+}
+
+static void bnxt_qplib_fill_psn_search(struct bnxt_qplib_qp *qp,
+				       struct bnxt_qplib_swqe *wqe,
+				       struct bnxt_qplib_swq *swq)
+{
+	struct sq_psn_search_ext *psns_ext;
+	struct sq_psn_search *psns;
+	u32 flg_npsn;
+	u32 op_spsn;
+
+	if (!swq->psn_search)
+		return;
+
+	/* Handle MSN differently on cap flags  */
+	if (BNXT_RE_HW_RETX(qp->dev_cap_flags)) {
+		bnxt_qplib_fill_msn_search(qp, wqe, swq);
+		return;
+	}
+	psns = (struct sq_psn_search *)swq->psn_search;
+	psns_ext = (struct sq_psn_search_ext *)swq->psn_search;
+
+	op_spsn = ((swq->start_psn << SQ_PSN_SEARCH_START_PSN_SFT) &
+		   SQ_PSN_SEARCH_START_PSN_MASK);
+	op_spsn |= ((wqe->type << SQ_PSN_SEARCH_OPCODE_SFT) &
+		    SQ_PSN_SEARCH_OPCODE_MASK);
+	flg_npsn = ((swq->next_psn << SQ_PSN_SEARCH_NEXT_PSN_SFT) &
+		    SQ_PSN_SEARCH_NEXT_PSN_MASK);
+
+	if (_is_chip_gen_p5_p7(qp->cctx)) {
+		psns_ext->opcode_start_psn = cpu_to_le32(op_spsn);
+		psns_ext->flags_next_psn = cpu_to_le32(flg_npsn);
+		psns_ext->start_slot_idx = cpu_to_le16(swq->slot_idx);
+	} else {
+		psns->opcode_start_psn = cpu_to_le32(op_spsn);
+		psns->flags_next_psn = cpu_to_le32(flg_npsn);
+	}
+}
+
+static u16 _calc_ilsize(struct bnxt_qplib_swqe *wqe)
+{
+	u16 size = 0;
+	int indx;
+
+	for (indx = 0; indx < wqe->num_sge; indx++)
+		size += wqe->sg_list[indx].size;
+	return size;
+}
+
+static int bnxt_qplib_put_inline(struct bnxt_qplib_qp *qp,
+				 struct bnxt_qplib_swqe *wqe,
+				 u32 *sw_prod)
+{
+	struct bnxt_qplib_hwq *sq_hwq;
+	int len, t_len, offt = 0;
+	int t_cplen = 0, cplen;
+	bool pull_dst = true;
+	void *il_dst = NULL;
+	void *il_src = NULL;
+	int indx;
+
+	sq_hwq = &qp->sq.hwq;
+	t_len = 0;
+	for (indx = 0; indx < wqe->num_sge; indx++) {
+		len = wqe->sg_list[indx].size;
+		il_src = (void *)wqe->sg_list[indx].addr;
+		t_len += len;
+		if (t_len > qp->max_inline_data)
+			goto bad;
+		while (len) {
+			if (pull_dst) {
+				pull_dst = false;
+				il_dst = bnxt_qplib_get_qe(sq_hwq, ((*sw_prod) %
+							   sq_hwq->depth), NULL);
+				(*sw_prod)++;
+				t_cplen = 0;
+				offt = 0;
+			}
+			cplen = min_t(int, len, sizeof(struct sq_sge));
+			cplen = min_t(int, cplen,
+				      (sizeof(struct sq_sge) - offt));
+			memcpy(il_dst, il_src, cplen);
+			t_cplen += cplen;
+			il_src += cplen;
+			il_dst += cplen;
+			offt += cplen;
+			len -= cplen;
+			if (t_cplen == sizeof(struct sq_sge))
+				pull_dst = true;
+		}
+	}
+
+	return t_len;
+bad:
+	return -ENOMEM;
+}
+
+static int bnxt_qplib_put_sges(struct bnxt_qplib_hwq *sq_hwq,
+			       struct bnxt_qplib_sge *ssge,
+			       u32 nsge, u32 *sw_prod)
+{
+	struct sq_sge *dsge;
+	int indx, len = 0;
+
+	for (indx = 0; indx < nsge; indx++, (*sw_prod)++) {
+		dsge = bnxt_qplib_get_qe(sq_hwq, ((*sw_prod) % sq_hwq->depth), NULL);
+		dsge->va_or_pa = cpu_to_le64(ssge[indx].addr);
+		dsge->l_key = cpu_to_le32(ssge[indx].lkey);
+		dsge->size = cpu_to_le32(ssge[indx].size);
+		len += ssge[indx].size;
+	}
+	return len;
+}
+
+static u16 _calculate_wqe_byte(struct bnxt_qplib_qp *qp,
+			       struct bnxt_qplib_swqe *wqe, u16 *wqe_byte)
+{
+	u16 wqe_size;
+	u32 ilsize;
+	u16 nsge;
+
+	nsge = wqe->num_sge;
+	if (wqe->flags & BNXT_QPLIB_SWQE_FLAGS_INLINE) {
+		ilsize = _calc_ilsize(wqe);
+		wqe_size = (ilsize > qp->max_inline_data) ?
+			    qp->max_inline_data : ilsize;
+		wqe_size = ALIGN(wqe_size, sizeof(struct sq_sge));
+	} else {
+		wqe_size = nsge * sizeof(struct sq_sge);
+	}
+	/* Adding sq_send_hdr is a misnomer, for rq also hdr size is same. */
+	wqe_size += sizeof(struct sq_send_hdr);
+	if (wqe_byte)
+		*wqe_byte = wqe_size;
+	return wqe_size / sizeof(struct sq_sge);
+}
+
+static u16 _translate_q_full_delta(struct bnxt_qplib_q *que, u16 wqe_bytes)
+{
+	/* For Cu/Wh delta = 128, stride = 16, wqe_bytes = 128
+	 * For Gen-p5 B/C mode delta = 0, stride = 16, wqe_bytes = 128.
+	 * For Gen-p5 delta = 0, stride = 16, 32 <= wqe_bytes <= 512.
+	 * when 8916 is disabled.
+	 */
+	return (que->q_full_delta * wqe_bytes) / que->hwq.element_size;
+}
+
+static void bnxt_qplib_pull_psn_buff(struct bnxt_qplib_qp *qp, struct bnxt_qplib_q *sq,
+				     struct bnxt_qplib_swq *swq, bool hw_retx)
+{
+	struct bnxt_qplib_hwq *sq_hwq;
+	u32 pg_num, pg_indx;
+	void *buff;
+	u32 tail;
+
+	sq_hwq = &sq->hwq;
+	if (!sq_hwq->pad_pg)
+		return;
+
+	tail = swq->slot_idx / sq->dbinfo.max_slot;
+	if (hw_retx)
+		tail %= qp->msn_tbl_sz;
+	pg_num = (tail + sq_hwq->pad_pgofft) / (PAGE_SIZE / sq_hwq->pad_stride);
+	pg_indx = (tail + sq_hwq->pad_pgofft) % (PAGE_SIZE / sq_hwq->pad_stride);
+	buff = (void *)(sq_hwq->pad_pg[pg_num] + pg_indx * sq_hwq->pad_stride);
+	/* the start ptr for buff is same ie after the SQ */
+	swq->psn_search = buff;
+}
+
+void bnxt_qplib_post_send_db(struct bnxt_qplib_qp *qp)
+{
+	struct bnxt_qplib_q *sq = &qp->sq;
+
+	bnxt_qplib_ring_prod_db(&sq->dbinfo, DBC_DBC_TYPE_SQ);
+}
+
+int bnxt_qplib_post_send(struct bnxt_qplib_qp *qp,
+			 struct bnxt_qplib_swqe *wqe)
+{
+	struct bnxt_qplib_nq_work *nq_work = NULL;
+	int i, rc = 0, data_len = 0, pkt_num = 0;
+	struct bnxt_qplib_q *sq = &qp->sq;
+	struct bnxt_qplib_hwq *sq_hwq;
+	struct bnxt_qplib_swq *swq;
+	bool sch_handler = false;
+	u16 slots_needed;
+	void *base_hdr;
+	void *ext_hdr;
+	__le32 temp32;
+	u16 qfd_slots;
+	u8 wqe_slots;
+	u16 wqe_size;
+	u32 sw_prod;
+	u32 wqe_idx;
+
+	sq_hwq = &sq->hwq;
+	if (qp->state != CMDQ_MODIFY_QP_NEW_STATE_RTS &&
+	    qp->state != CMDQ_MODIFY_QP_NEW_STATE_ERR) {
+		dev_err(&sq_hwq->pdev->dev,
+			"QPLIB: FP: QP (0x%x) is in the 0x%x state\n",
+			qp->id, qp->state);
+		rc = -EINVAL;
+		goto done;
+	}
+
+	wqe_slots = _calculate_wqe_byte(qp, wqe, &wqe_size);
+	slots_needed = (qp->wqe_mode == BNXT_QPLIB_WQE_MODE_STATIC) ?
+			sq->dbinfo.max_slot : wqe_slots;
+	qfd_slots = _translate_q_full_delta(sq, wqe_size);
+	if (bnxt_qplib_queue_full(sq_hwq, (slots_needed + qfd_slots))) {
+		dev_err(&sq_hwq->pdev->dev,
+			"QPLIB: FP: QP (0x%x) SQ is full!\n", qp->id);
+		dev_err(&sq_hwq->pdev->dev,
+			"QPLIB: prod = %#x cons = %#x qdepth = %#x delta = %#x slots = %#x\n",
+			HWQ_CMP(sq_hwq->prod, sq_hwq),
+			HWQ_CMP(sq_hwq->cons, sq_hwq),
+			sq_hwq->max_elements, qfd_slots, slots_needed);
+		dev_err(&sq_hwq->pdev->dev,
+			"QPLIB: phantom_wqe_cnt: %d phantom_cqe_cnt: %d\n",
+			sq->phantom_wqe_cnt, sq->phantom_cqe_cnt);
+		rc = -ENOMEM;
+		goto done;
+	}
+
+	sw_prod = sq_hwq->prod;
+	swq = bnxt_qplib_get_swqe(sq, &wqe_idx);
+	swq->slot_idx = sw_prod;
+	bnxt_qplib_pull_psn_buff(qp, sq, swq, BNXT_RE_HW_RETX(qp->dev_cap_flags));
+
+	swq->wr_id = wqe->wr_id;
+	swq->type = wqe->type;
+	swq->flags = wqe->flags;
+	swq->slots = slots_needed;
+	swq->start_psn = sq->psn & BTH_PSN_MASK;
+	if (qp->sig_type || wqe->flags & BNXT_QPLIB_SWQE_FLAGS_SIGNAL_COMP)
+		swq->flags |= SQ_SEND_FLAGS_SIGNAL_COMP;
+
+	dev_dbg(&sq_hwq->pdev->dev,
+		"QPLIB: FP: QP(0x%x) post SQ wr_id[%d] = 0x%llx\n",
+		qp->id, wqe_idx, swq->wr_id);
+	if (qp->cur_qp_state == CMDQ_MODIFY_QP_NEW_STATE_ERR) {
+		sch_handler = true;
+		dev_dbg(&sq_hwq->pdev->dev,
+			"%s Error QP. Scheduling for poll_cq\n", __func__);
+		goto queue_err;
+	}
+
+	base_hdr = bnxt_qplib_get_qe(sq_hwq, sw_prod, NULL);
+	sw_prod++;
+	ext_hdr = bnxt_qplib_get_qe(sq_hwq, (sw_prod % sq_hwq->depth), NULL);
+	sw_prod++;
+	memset(base_hdr, 0, sizeof(struct sq_sge));
+	memset(ext_hdr, 0, sizeof(struct sq_sge));
+
+	if (wqe->flags & BNXT_QPLIB_SWQE_FLAGS_INLINE)
+		data_len = bnxt_qplib_put_inline(qp, wqe, &sw_prod);
+	else
+		data_len = bnxt_qplib_put_sges(sq_hwq, wqe->sg_list,
+					       wqe->num_sge, &sw_prod);
+	if (data_len < 0)
+		goto queue_err;
+	/* Specifics */
+	switch (wqe->type) {
+	case BNXT_QPLIB_SWQE_TYPE_SEND:
+		if (qp->type == CMDQ_CREATE_QP_TYPE_RAW_ETHERTYPE ||
+		    qp->type == CMDQ_CREATE_QP1_TYPE_GSI) {
+			/* Assemble info for Raw Ethertype QPs */
+			struct sq_send_raweth_qp1_hdr *sqe = base_hdr;
+			struct sq_raw_ext_hdr *ext_sqe = ext_hdr;
+
+			sqe->wqe_type = wqe->type;
+			sqe->flags = wqe->flags;
+			sqe->wqe_size = wqe_slots;
+			sqe->cfa_action = cpu_to_le16(wqe->rawqp1.cfa_action);
+			sqe->lflags = cpu_to_le16(wqe->rawqp1.lflags);
+			sqe->length = cpu_to_le32(data_len);
+			ext_sqe->cfa_meta = cpu_to_le32((wqe->rawqp1.cfa_meta &
+				SQ_SEND_RAWETH_QP1_CFA_META_VLAN_VID_MASK) <<
+				SQ_SEND_RAWETH_QP1_CFA_META_VLAN_VID_SFT);
+
+			dev_dbg(&sq_hwq->pdev->dev,
+				"QPLIB: FP: RAW/QP1 Send WQE:\n"
+				"\twqe_type = 0x%x\n"
+				"\tflags = 0x%x\n"
+				"\twqe_size = 0x%x\n"
+				"\tlflags = 0x%x\n"
+				"\tcfa_action = 0x%x\n"
+				"\tlength = 0x%x\n"
+				"\tcfa_meta = 0x%x\n",
+				sqe->wqe_type, sqe->flags, sqe->wqe_size,
+				sqe->lflags, sqe->cfa_action,
+				sqe->length, ext_sqe->cfa_meta);
+			break;
+		}
+		fallthrough;
+	case BNXT_QPLIB_SWQE_TYPE_SEND_WITH_IMM:
+		fallthrough;
+	case BNXT_QPLIB_SWQE_TYPE_SEND_WITH_INV:
+	{
+		struct sq_send_hdr *sqe = base_hdr;
+		struct sq_ud_ext_hdr *ext_sqe = ext_hdr;
+
+		sqe->wqe_type = wqe->type;
+		sqe->flags = wqe->flags;
+		sqe->wqe_size = wqe_slots;
+		sqe->inv_key_or_imm_data = cpu_to_le32(wqe->send.inv_key);
+		if (qp->type == CMDQ_CREATE_QP_TYPE_UD ||
+		    qp->type == CMDQ_CREATE_QP_TYPE_GSI) {
+			sqe->q_key = cpu_to_le32(wqe->send.q_key);
+			sqe->length = cpu_to_le32(data_len);
+			ext_sqe->dst_qp = cpu_to_le32(
+					wqe->send.dst_qp & SQ_SEND_DST_QP_MASK);
+			ext_sqe->avid = cpu_to_le32(wqe->send.avid &
+						SQ_SEND_AVID_MASK);
+			sq->psn = (sq->psn + 1) & BTH_PSN_MASK;
+		} else {
+			sqe->length = cpu_to_le32(data_len);
+			if (qp->mtu)
+				pkt_num = (data_len + qp->mtu - 1) / qp->mtu;
+			if (!pkt_num)
+				pkt_num = 1;
+			sq->psn = (sq->psn + pkt_num) & BTH_PSN_MASK;
+		}
+		dev_dbg(&sq_hwq->pdev->dev,
+			"QPLIB: FP: Send WQE:\n"
+			"\twqe_type = 0x%x\n"
+			"\tflags = 0x%x\n"
+			"\twqe_size = 0x%x\n"
+			"\tinv_key/immdata = 0x%x\n"
+			"\tq_key = 0x%x\n"
+			"\tdst_qp = 0x%x\n"
+			"\tlength = 0x%x\n"
+			"\tavid = 0x%x\n",
+			sqe->wqe_type, sqe->flags, sqe->wqe_size,
+			sqe->inv_key_or_imm_data, sqe->q_key, ext_sqe->dst_qp,
+			sqe->length, ext_sqe->avid);
+		break;
+	}
+	case BNXT_QPLIB_SWQE_TYPE_RDMA_WRITE:
+		/* fall-thru */
+	case BNXT_QPLIB_SWQE_TYPE_RDMA_WRITE_WITH_IMM:
+		/* fall-thru */
+	case BNXT_QPLIB_SWQE_TYPE_RDMA_READ:
+	{
+		struct sq_rdma_hdr *sqe = base_hdr;
+		struct sq_rdma_ext_hdr *ext_sqe = ext_hdr;
+
+		sqe->wqe_type = wqe->type;
+		sqe->flags = wqe->flags;
+		sqe->wqe_size = wqe_slots;
+		sqe->imm_data = cpu_to_le32(wqe->rdma.inv_key);
+		sqe->length = cpu_to_le32((u32)data_len);
+		ext_sqe->remote_va = cpu_to_le64(wqe->rdma.remote_va);
+		ext_sqe->remote_key = cpu_to_le32(wqe->rdma.r_key);
+		if (qp->mtu)
+			pkt_num = (data_len + qp->mtu - 1) / qp->mtu;
+		if (!pkt_num)
+			pkt_num = 1;
+		sq->psn = (sq->psn + pkt_num) & BTH_PSN_MASK;
+
+		dev_dbg(&sq_hwq->pdev->dev,
+			"QPLIB: FP: RDMA WQE:\n"
+			"\twqe_type = 0x%x\n"
+			"\tflags = 0x%x\n"
+			"\twqe_size = 0x%x\n"
+			"\timmdata = 0x%x\n"
+			"\tlength = 0x%x\n"
+			"\tremote_va = 0x%llx\n"
+			"\tremote_key = 0x%x\n",
+			sqe->wqe_type, sqe->flags, sqe->wqe_size,
+			sqe->imm_data, sqe->length, ext_sqe->remote_va,
+			ext_sqe->remote_key);
+		break;
+	}
+	case BNXT_QPLIB_SWQE_TYPE_ATOMIC_CMP_AND_SWP:
+		/* fall-thru */
+	case BNXT_QPLIB_SWQE_TYPE_ATOMIC_FETCH_AND_ADD:
+	{
+		struct sq_atomic_hdr *sqe = base_hdr;
+		struct sq_atomic_ext_hdr *ext_sqe = ext_hdr;
+
+		sqe->wqe_type = wqe->type;
+		sqe->flags = wqe->flags;
+		sqe->remote_key = cpu_to_le32(wqe->atomic.r_key);
+		sqe->remote_va = cpu_to_le64(wqe->atomic.remote_va);
+		ext_sqe->swap_data = cpu_to_le64(wqe->atomic.swap_data);
+		ext_sqe->cmp_data = cpu_to_le64(wqe->atomic.cmp_data);
+		if (qp->mtu)
+			pkt_num = (data_len + qp->mtu - 1) / qp->mtu;
+		if (!pkt_num)
+			pkt_num = 1;
+		sq->psn = (sq->psn + pkt_num) & BTH_PSN_MASK;
+		break;
+	}
+	case BNXT_QPLIB_SWQE_TYPE_LOCAL_INV:
+	{
+		struct sq_localinvalidate_hdr *sqe = base_hdr;
+
+		sqe->wqe_type = wqe->type;
+		sqe->flags = wqe->flags;
+		sqe->inv_l_key = cpu_to_le32(wqe->local_inv.inv_l_key);
+
+		dev_dbg(&sq_hwq->pdev->dev,
+			"QPLIB: FP: LOCAL INV WQE:\n"
+			"\twqe_type = 0x%x\n"
+			"\tflags = 0x%x\n"
+			"\tinv_l_key = 0x%x\n",
+			sqe->wqe_type, sqe->flags, sqe->inv_l_key);
+		break;
+	}
+	case BNXT_QPLIB_SWQE_TYPE_FAST_REG_MR:
+	{
+		struct sq_fr_pmr_hdr *sqe = base_hdr;
+		struct sq_fr_pmr_ext_hdr *ext_sqe = ext_hdr;
+
+		sqe->wqe_type = wqe->type;
+		sqe->flags = wqe->flags;
+		sqe->access_cntl = wqe->frmr.access_cntl |
+				   SQ_FR_PMR_ACCESS_CNTL_LOCAL_WRITE;
+		sqe->zero_based_page_size_log =
+			(wqe->frmr.pg_sz_log & SQ_FR_PMR_PAGE_SIZE_LOG_MASK) <<
+			SQ_FR_PMR_PAGE_SIZE_LOG_SFT |
+			(wqe->frmr.zero_based == true ? SQ_FR_PMR_ZERO_BASED : 0);
+		sqe->l_key = cpu_to_le32(wqe->frmr.l_key);
+		/* TODO: OFED only provides length of MR up to 32-bits for FRMR */
+		temp32 = cpu_to_le32(wqe->frmr.length);
+		memcpy(sqe->length, &temp32, sizeof(wqe->frmr.length));
+		sqe->numlevels_pbl_page_size_log =
+			((wqe->frmr.pbl_pg_sz_log <<
+					SQ_FR_PMR_PBL_PAGE_SIZE_LOG_SFT) &
+					SQ_FR_PMR_PBL_PAGE_SIZE_LOG_MASK) |
+			((wqe->frmr.levels << SQ_FR_PMR_NUMLEVELS_SFT) &
+					SQ_FR_PMR_NUMLEVELS_MASK);
+		if (!wqe->frmr.levels && !wqe->frmr.pbl_ptr) {
+			ext_sqe->pblptr = cpu_to_le64(wqe->frmr.page_list[0]);
+		} else {
+			for (i = 0; i < wqe->frmr.page_list_len; i++)
+				wqe->frmr.pbl_ptr[i] = cpu_to_le64(
+						wqe->frmr.page_list[i] |
+						PTU_PTE_VALID);
+			ext_sqe->pblptr = cpu_to_le64(wqe->frmr.pbl_dma_ptr);
+		}
+		ext_sqe->va = cpu_to_le64(wqe->frmr.va);
+		dev_dbg(&sq_hwq->pdev->dev,
+			"QPLIB: FP: FRMR WQE:\n"
+			"\twqe_type = 0x%x\n"
+			"\tflags = 0x%x\n"
+			"\taccess_cntl = 0x%x\n"
+			"\tzero_based_page_size_log = 0x%x\n"
+			"\tl_key = 0x%x\n"
+			"\tlength = 0x%x\n"
+			"\tnumlevels_pbl_page_size_log = 0x%x\n"
+			"\tpblptr = 0x%llx\n"
+			"\tva = 0x%llx\n",
+			sqe->wqe_type, sqe->flags, sqe->access_cntl,
+			sqe->zero_based_page_size_log, sqe->l_key,
+			*(u32 *)sqe->length, sqe->numlevels_pbl_page_size_log,
+			ext_sqe->pblptr, ext_sqe->va);
+		break;
+	}
+	case BNXT_QPLIB_SWQE_TYPE_BIND_MW:
+	{
+		struct sq_bind_hdr *sqe = base_hdr;
+		struct sq_bind_ext_hdr *ext_sqe = ext_hdr;
+
+		sqe->wqe_type = wqe->type;
+		sqe->flags = wqe->flags;
+		sqe->access_cntl = wqe->bind.access_cntl;
+		sqe->mw_type_zero_based = wqe->bind.mw_type |
+			(wqe->bind.zero_based == true ? SQ_BIND_ZERO_BASED : 0);
+		sqe->parent_l_key = cpu_to_le32(wqe->bind.parent_l_key);
+		sqe->l_key = cpu_to_le32(wqe->bind.r_key);
+		ext_sqe->va = cpu_to_le64(wqe->bind.va);
+		ext_sqe->length_lo = cpu_to_le32(wqe->bind.length);
+		dev_dbg(&sq_hwq->pdev->dev,
+			"QPLIB: FP: BIND WQE:\n"
+			"\twqe_type = 0x%x\n"
+			"\tflags = 0x%x\n"
+			"\taccess_cntl = 0x%x\n"
+			"\tmw_type_zero_based = 0x%x\n"
+			"\tparent_l_key = 0x%x\n"
+			"\tl_key = 0x%x\n"
+			"\tva = 0x%llx\n"
+			"\tlength = 0x%x\n",
+			sqe->wqe_type, sqe->flags, sqe->access_cntl,
+			sqe->mw_type_zero_based, sqe->parent_l_key,
+			sqe->l_key, sqe->va, ext_sqe->length_lo);
+		break;
+	}
+	default:
+		/* Bad wqe, return error */
+		rc = -EINVAL;
+		goto done;
+	}
+	swq->next_psn = sq->psn & BTH_PSN_MASK;
+	bnxt_qplib_fill_psn_search(qp, wqe, swq);
+
+queue_err:
+	bnxt_qplib_swq_mod_start(sq, wqe_idx);
+	bnxt_qplib_hwq_incr_prod(&sq->dbinfo, sq_hwq, swq->slots);
+	qp->wqe_cnt++;
+done:
+	if (sch_handler) {
+		nq_work = kzalloc(sizeof(*nq_work), GFP_ATOMIC);
+		if (nq_work) {
+			nq_work->cq = qp->scq;
+			nq_work->nq = qp->scq->nq;
+			INIT_WORK(&nq_work->work, bnxt_qpn_cqn_sched_task);
+			queue_work(qp->scq->nq->cqn_wq, &nq_work->work);
+		} else {
+			dev_err(&sq->hwq.pdev->dev,
+				"QPLIB: FP: Failed to allocate SQ nq_work!\n");
+			rc = -ENOMEM;
+		}
+	}
+	return rc;
+}
+
+void bnxt_qplib_post_recv_db(struct bnxt_qplib_qp *qp)
+{
+	struct bnxt_qplib_q *rq = &qp->rq;
+
+	bnxt_qplib_ring_prod_db(&rq->dbinfo, DBC_DBC_TYPE_RQ);
+}
+
+void bnxt_re_handle_cqn(struct bnxt_qplib_cq *cq)
+{
+	struct bnxt_qplib_nq *nq;
+
+	if (!(cq && cq->nq))
+		return;
+
+	nq = cq->nq;
+	spin_lock_bh(&cq->compl_lock);
+	if (nq->cqn_handler) {
+		dev_dbg(&nq->res->pdev->dev,
+			"%s:Trigger cq  = %p event nq = %p\n",
+			__func__, cq, nq);
+		nq->cqn_handler(nq, cq);
+	}
+	spin_unlock_bh(&cq->compl_lock);
+}
+
+int bnxt_qplib_post_recv(struct bnxt_qplib_qp *qp,
+			 struct bnxt_qplib_swqe *wqe)
+{
+	struct bnxt_qplib_nq_work *nq_work = NULL;
+	struct bnxt_qplib_q *rq = &qp->rq;
+	struct bnxt_qplib_hwq *rq_hwq;
+	struct bnxt_qplib_swq *swq;
+	bool sch_handler = false;
+	struct rq_wqe_hdr *base_hdr;
+	struct rq_ext_hdr *ext_hdr;
+	struct sq_sge *dsge;
+	u8 wqe_slots;
+	u32 wqe_idx;
+	u32 sw_prod;
+	int rc = 0;
+
+	rq_hwq = &rq->hwq;
+	if (qp->state == CMDQ_MODIFY_QP_NEW_STATE_RESET) {
+		dev_err(&rq_hwq->pdev->dev,
+			"QPLIB: FP: QP (0x%x) is in the 0x%x state\n",
+			qp->id, qp->state);
+		rc = -EINVAL;
+		goto done;
+	}
+
+	wqe_slots = _calculate_wqe_byte(qp, wqe, NULL);
+	if (bnxt_qplib_queue_full(rq_hwq, rq->dbinfo.max_slot)) {
+		dev_err(&rq_hwq->pdev->dev,
+			"QPLIB: FP: QP (0x%x) RQ is full!\n", qp->id);
+		rc = -EINVAL;
+		goto done;
+	}
+
+	swq = bnxt_qplib_get_swqe(rq, &wqe_idx);
+	swq->wr_id = wqe->wr_id;
+	swq->slots = rq->dbinfo.max_slot;
+	dev_dbg(&rq_hwq->pdev->dev,
+		"QPLIB: FP: post RQ wr_id[%d] = 0x%llx\n",
+		wqe_idx, swq->wr_id);
+	if (qp->cur_qp_state == CMDQ_MODIFY_QP_NEW_STATE_ERR) {
+		sch_handler = true;
+		dev_dbg(&rq_hwq->pdev->dev, "%s Error QP. Sched a flushed cmpl\n",
+			__func__);
+		goto queue_err;
+	}
+
+	sw_prod = rq_hwq->prod;
+	base_hdr = bnxt_qplib_get_qe(rq_hwq, sw_prod, NULL);
+	sw_prod++;
+	ext_hdr = bnxt_qplib_get_qe(rq_hwq, (sw_prod % rq_hwq->depth), NULL);
+	sw_prod++;
+	memset(base_hdr, 0, sizeof(struct sq_sge));
+	memset(ext_hdr, 0, sizeof(struct sq_sge));
+
+	if (!wqe->num_sge) {
+		dsge = bnxt_qplib_get_qe(rq_hwq, (sw_prod % rq_hwq->depth), NULL);
+		dsge->size = 0;
+		wqe_slots++;
+	} else {
+		bnxt_qplib_put_sges(rq_hwq, wqe->sg_list, wqe->num_sge, &sw_prod);
+	}
+	base_hdr->wqe_type = wqe->type;
+	base_hdr->flags = wqe->flags;
+	base_hdr->wqe_size = wqe_slots;
+	base_hdr->wr_id |= cpu_to_le32(wqe_idx);
+queue_err:
+	bnxt_qplib_swq_mod_start(rq, wqe_idx);
+	bnxt_qplib_hwq_incr_prod(&rq->dbinfo, &rq->hwq, swq->slots);
+done:
+	if (sch_handler) {
+		nq_work = kzalloc(sizeof(*nq_work), GFP_ATOMIC);
+		if (nq_work) {
+			nq_work->cq = qp->rcq;
+			nq_work->nq = qp->rcq->nq;
+			INIT_WORK(&nq_work->work, bnxt_qpn_cqn_sched_task);
+			queue_work(qp->rcq->nq->cqn_wq, &nq_work->work);
+		} else {
+			dev_err(&rq->hwq.pdev->dev,
+				"QPLIB: FP: Failed to allocate RQ nq_work!\n");
+			rc = -ENOMEM;
+		}
+	}
+	return rc;
+}
+
+/* CQ */
+int bnxt_qplib_create_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq)
+{
+	struct bnxt_qplib_hwq_attr hwq_attr = {};
+	struct bnxt_qplib_rcfw *rcfw = res->rcfw;
+	struct creq_create_cq_resp resp = {};
+	struct bnxt_qplib_cmdqmsg msg = {};
+	struct cmdq_create_cq req = {};
+	struct bnxt_qplib_reftbl *tbl;
+	unsigned long flag;
+	u32 pg_sz_lvl = 0;
+	int rc;
+
+	hwq_attr.res = res;
+	hwq_attr.depth = cq->max_wqe;
+	hwq_attr.stride = sizeof(struct cq_base);
+	hwq_attr.type = HWQ_TYPE_QUEUE;
+	hwq_attr.sginfo = &cq->sginfo;
+	rc = bnxt_qplib_alloc_init_hwq(&cq->hwq, &hwq_attr);
+	if (rc)
+		goto exit;
+
+	bnxt_qplib_rcfw_cmd_prep(&req, CMDQ_BASE_OPCODE_CREATE_CQ,
+				 sizeof(req));
+
+	if (!cq->dpi) {
+		dev_err(&rcfw->pdev->dev,
+			"QPLIB: FP: CREATE_CQ failed due to NULL DPI\n");
+		return -EINVAL;
+	}
+	req.dpi = cpu_to_le32(cq->dpi->dpi);
+	req.cq_handle = cpu_to_le64(cq->cq_handle);
+
+	req.cq_size = cpu_to_le32(cq->max_wqe);
+	req.pbl = cpu_to_le64(_get_base_addr(&cq->hwq));
+	pg_sz_lvl = _get_base_pg_size(&cq->hwq) << CMDQ_CREATE_CQ_PG_SIZE_SFT;
+	pg_sz_lvl |= ((cq->hwq.level & CMDQ_CREATE_CQ_LVL_MASK) <<
+		       CMDQ_CREATE_CQ_LVL_SFT);
+	req.pg_size_lvl = cpu_to_le32(pg_sz_lvl);
+
+	req.cq_fco_cnq_id = cpu_to_le32(
+			(cq->cnq_hw_ring_id & CMDQ_CREATE_CQ_CNQ_ID_MASK) <<
+			 CMDQ_CREATE_CQ_CNQ_ID_SFT);
+	bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, NULL, sizeof(req),
+				sizeof(resp), 0);
+	rc = bnxt_qplib_rcfw_send_message(rcfw, &msg);
+	if (rc)
+		goto fail;
+	cq->id = le32_to_cpu(resp.xid);
+	cq->period = BNXT_QPLIB_QUEUE_START_PERIOD;
+	init_waitqueue_head(&cq->waitq);
+	INIT_LIST_HEAD(&cq->sqf_head);
+	INIT_LIST_HEAD(&cq->rqf_head);
+	spin_lock_init(&cq->flush_lock);
+	spin_lock_init(&cq->compl_lock);
+
+	/* init dbinfo */
+	cq->cctx = res->cctx;
+	cq->dbinfo.hwq = &cq->hwq;
+	cq->dbinfo.xid = cq->id;
+	cq->dbinfo.db = cq->dpi->dbr;
+	cq->dbinfo.priv_db = res->dpi_tbl.priv_db;
+	cq->dbinfo.flags = 0;
+	cq->dbinfo.toggle = 0;
+	cq->dbinfo.res = res;
+	cq->dbinfo.seed = cq->id;
+	spin_lock_init(&cq->dbinfo.lock);
+	cq->dbinfo.shadow_key = BNXT_QPLIB_DBR_KEY_INVALID;
+	cq->dbinfo.shadow_key_arm_ena = BNXT_QPLIB_DBR_KEY_INVALID;
+
+	tbl = &res->reftbl.cqref;
+	spin_lock_irqsave(&tbl->lock, flag);
+	tbl->rec[GET_TBL_INDEX(cq->id, tbl)].xid = cq->id;
+	tbl->rec[GET_TBL_INDEX(cq->id, tbl)].handle = cq;
+	spin_unlock_irqrestore(&tbl->lock, flag);
+
+	bnxt_qplib_armen_db(&cq->dbinfo, DBC_DBC_TYPE_CQ_ARMENA);
+	return 0;
+
+fail:
+	bnxt_qplib_free_hwq(res, &cq->hwq);
+exit:
+	return rc;
+}
+
+int bnxt_qplib_modify_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq)
+{
+	/* TODO: Modify CQ threshold are passed to the HW via DBR */
+	return 0;
+}
+
+void bnxt_qplib_resize_cq_complete(struct bnxt_qplib_res *res,
+				   struct bnxt_qplib_cq *cq)
+{
+	bnxt_qplib_free_hwq(res, &cq->hwq);
+	memcpy(&cq->hwq, &cq->resize_hwq, sizeof(cq->hwq));
+	/* Reset only the cons bit in the flags */
+	cq->dbinfo.flags &= ~(1UL << BNXT_QPLIB_FLAG_EPOCH_CONS_SHIFT);
+
+	/* Tell HW to switch over to the new CQ */
+	if (!cq->resize_hwq.is_user)
+		bnxt_qplib_cq_coffack_db(&cq->dbinfo);
+}
+
+int bnxt_qplib_resize_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq,
+			 int new_cqes)
+{
+	struct bnxt_qplib_hwq_attr hwq_attr = {};
+	struct bnxt_qplib_rcfw *rcfw = res->rcfw;
+	struct creq_resize_cq_resp resp = {};
+	struct bnxt_qplib_cmdqmsg msg = {};
+	struct cmdq_resize_cq req = {};
+	u32 pgsz = 0, lvl = 0, nsz = 0;
+	struct bnxt_qplib_pbl *pbl;
+	u16 count = -1;
+	int rc;
+
+	bnxt_qplib_rcfw_cmd_prep(&req, CMDQ_BASE_OPCODE_RESIZE_CQ,
+				 sizeof(req));
+
+	hwq_attr.sginfo = &cq->sginfo;
+	hwq_attr.res = res;
+	hwq_attr.depth = new_cqes;
+	hwq_attr.stride = sizeof(struct cq_base);
+	hwq_attr.type = HWQ_TYPE_QUEUE;
+	rc = bnxt_qplib_alloc_init_hwq(&cq->resize_hwq, &hwq_attr);
+	if (rc)
+		return rc;
+
+	dev_dbg(&rcfw->pdev->dev, "QPLIB: FP: %s: pbl_lvl: %d\n", __func__,
+		cq->resize_hwq.level);
+	req.cq_cid = cpu_to_le32(cq->id);
+	pbl = &cq->resize_hwq.pbl[PBL_LVL_0];
+	pgsz = ((pbl->pg_size == ROCE_PG_SIZE_4K ? CMDQ_RESIZE_CQ_PG_SIZE_PG_4K :
+		pbl->pg_size == ROCE_PG_SIZE_8K ? CMDQ_RESIZE_CQ_PG_SIZE_PG_8K :
+		pbl->pg_size == ROCE_PG_SIZE_64K ? CMDQ_RESIZE_CQ_PG_SIZE_PG_64K :
+		pbl->pg_size == ROCE_PG_SIZE_2M ? CMDQ_RESIZE_CQ_PG_SIZE_PG_2M :
+		pbl->pg_size == ROCE_PG_SIZE_8M ? CMDQ_RESIZE_CQ_PG_SIZE_PG_8M :
+		pbl->pg_size == ROCE_PG_SIZE_1G ? CMDQ_RESIZE_CQ_PG_SIZE_PG_1G :
+		CMDQ_RESIZE_CQ_PG_SIZE_PG_4K) & CMDQ_RESIZE_CQ_PG_SIZE_MASK);
+	lvl = (cq->resize_hwq.level << CMDQ_RESIZE_CQ_LVL_SFT) &
+				       CMDQ_RESIZE_CQ_LVL_MASK;
+	nsz = (new_cqes << CMDQ_RESIZE_CQ_NEW_CQ_SIZE_SFT) &
+	       CMDQ_RESIZE_CQ_NEW_CQ_SIZE_MASK;
+	req.new_cq_size_pg_size_lvl = cpu_to_le32(nsz|pgsz|lvl);
+	req.new_pbl = cpu_to_le64(pbl->pg_map_arr[0]);
+
+	if (!cq->resize_hwq.is_user)
+		set_bit(CQ_FLAGS_RESIZE_IN_PROG, &cq->flags);
+
+	bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, NULL, sizeof(req),
+				sizeof(resp), 0);
+	rc = bnxt_qplib_rcfw_send_message(rcfw, &msg);
+	if (rc)
+		goto fail;
+
+	if (!cq->resize_hwq.is_user) {
+wait:
+		/* Wait here for the HW to switch the CQ over */
+		if (wait_event_interruptible_timeout(cq->waitq,
+		    !test_bit(CQ_FLAGS_RESIZE_IN_PROG, &cq->flags),
+		    msecs_to_jiffies(CQ_RESIZE_WAIT_TIME_MS)) ==
+		    -ERESTARTSYS && count--)
+			goto wait;
+
+		if (test_bit(CQ_FLAGS_RESIZE_IN_PROG, &cq->flags)) {
+			dev_err(&rcfw->pdev->dev,
+				"QPLIB: FP: RESIZE_CQ timed out\n");
+			rc = -ETIMEDOUT;
+			goto fail;
+		}
+
+		bnxt_qplib_resize_cq_complete(res, cq);
+	}
+
+	return 0;
+fail:
+	if (!cq->resize_hwq.is_user) {
+		bnxt_qplib_free_hwq(res, &cq->resize_hwq);
+		clear_bit(CQ_FLAGS_RESIZE_IN_PROG, &cq->flags);
+	}
+	return rc;
+}
+
+void bnxt_qplib_free_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq)
+{
+	bnxt_qplib_free_hwq(res, &cq->hwq);
+}
+
+static void bnxt_qplib_sync_cq(struct bnxt_qplib_cq *cq)
+{
+	struct bnxt_qplib_nq *nq = cq->nq;
+	/* Flush any pending work and synchronize irq */
+	flush_workqueue(cq->nq->cqn_wq);
+	mutex_lock(&nq->lock);
+	if (nq->requested)
+		synchronize_irq(nq->msix_vec);
+	mutex_unlock(&nq->lock);
+}
+
+int bnxt_qplib_destroy_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq)
+{
+	struct bnxt_qplib_rcfw *rcfw = res->rcfw;
+	struct creq_destroy_cq_resp resp = {};
+	struct bnxt_qplib_cmdqmsg msg = {};
+	struct cmdq_destroy_cq req = {};
+	struct bnxt_qplib_reftbl *tbl;
+	u16 total_cnq_events;
+	unsigned long flag;
+	int rc;
+
+	tbl = &res->reftbl.cqref;
+	spin_lock_irqsave(&tbl->lock, flag);
+	tbl->rec[GET_TBL_INDEX(cq->id, tbl)].handle = NULL;
+	tbl->rec[GET_TBL_INDEX(cq->id, tbl)].xid = 0;
+	spin_unlock_irqrestore(&tbl->lock, flag);
+
+	bnxt_qplib_rcfw_cmd_prep(&req, CMDQ_BASE_OPCODE_DESTROY_CQ,
+				 sizeof(req));
+
+	req.cq_cid = cpu_to_le32(cq->id);
+	bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, NULL, sizeof(req),
+				sizeof(resp), 0);
+	rc = bnxt_qplib_rcfw_send_message(rcfw, &msg);
+	if (rc)
+		return rc;
+
+	total_cnq_events = le16_to_cpu(resp.total_cnq_events);
+	if (total_cnq_events >= 0)
+		dev_dbg(&rcfw->pdev->dev,
+			"%s: cq_id = 0x%x cq = 0x%p resp.total_cnq_events = 0x%x\n",
+			__func__, cq->id, cq, total_cnq_events);
+	__wait_for_all_nqes(cq, total_cnq_events);
+	bnxt_qplib_sync_cq(cq);
+	bnxt_qplib_free_hwq(res, &cq->hwq);
+	return 0;
+}
+
+static int __flush_sq(struct bnxt_qplib_q *sq, struct bnxt_qplib_qp *qp,
+		      struct bnxt_qplib_cqe **pcqe, int *budget)
+{
+	struct bnxt_qplib_cqe *cqe;
+	u32 start, last;
+	int rc = 0;
+
+	/* Now complete all outstanding SQEs with FLUSHED_ERR */
+	start = sq->swq_start;
+	cqe = *pcqe;
+	while (*budget) {
+		last = sq->swq_last;
+		if (start == last) {
+			break;
+		}
+		/* Skip the FENCE WQE completions */
+		if (sq->swq[last].wr_id == BNXT_QPLIB_FENCE_WRID) {
+			bnxt_re_legacy_cancel_phantom_processing(qp);
+			goto skip_compl;
+		}
+
+		memset(cqe, 0, sizeof(*cqe));
+		cqe->status = CQ_REQ_STATUS_WORK_REQUEST_FLUSHED_ERR;
+		cqe->opcode = CQ_BASE_CQE_TYPE_REQ;
+		cqe->qp_handle = (u64)qp;
+		cqe->wr_id = sq->swq[last].wr_id;
+		cqe->src_qp = qp->id;
+		cqe->type = sq->swq[last].type;
+		dev_dbg(&sq->hwq.pdev->dev,
+			"QPLIB: FP: CQ Processed terminal Req \n");
+		dev_dbg(&sq->hwq.pdev->dev,
+			"QPLIB: wr_id[%d] = 0x%llx with status 0x%x\n",
+			last, cqe->wr_id, cqe->status);
+		cqe++;
+		(*budget)--;
+skip_compl:
+		bnxt_qplib_hwq_incr_cons(sq->hwq.depth,
+					 &sq->hwq.cons,
+					 sq->swq[last].slots,
+					 &sq->dbinfo.flags);
+		sq->swq_last = sq->swq[last].next_idx;
+	}
+	*pcqe = cqe;
+	if (!*budget && sq->swq_last != start)
+		/* Out of budget */
+		rc = -EAGAIN;
+	dev_dbg(&sq->hwq.pdev->dev, "QPLIB: FP: Flush SQ rc = 0x%x\n", rc);
+
+	return rc;
+}
+
+static int __flush_rq(struct bnxt_qplib_q *rq, struct bnxt_qplib_qp *qp,
+		      struct bnxt_qplib_cqe **pcqe, int *budget)
+{
+	struct bnxt_qplib_cqe *cqe;
+	u32 start, last;
+	int opcode = 0;
+	int rc = 0;
+
+	switch (qp->type) {
+	case CMDQ_CREATE_QP1_TYPE_GSI:
+		opcode = CQ_BASE_CQE_TYPE_RES_RAWETH_QP1;
+		break;
+	case CMDQ_CREATE_QP_TYPE_RC:
+		opcode = CQ_BASE_CQE_TYPE_RES_RC;
+		break;
+	case CMDQ_CREATE_QP_TYPE_UD:
+		opcode = CQ_BASE_CQE_TYPE_RES_UD;
+		break;
+	}
+
+	/* Flush the rest of the RQ */
+	start = rq->swq_start;
+	cqe = *pcqe;
+	while (*budget) {
+		last = rq->swq_last;
+		if (last == start)
+			break;
+		memset(cqe, 0, sizeof(*cqe));
+		cqe->status =
+		    CQ_RES_RC_STATUS_WORK_REQUEST_FLUSHED_ERR;
+		cqe->opcode = opcode;
+		cqe->qp_handle = (u64)qp;
+		cqe->wr_id = rq->swq[last].wr_id;
+		dev_dbg(&rq->hwq.pdev->dev, "QPLIB: FP: CQ Processed Res RC \n");
+		dev_dbg(&rq->hwq.pdev->dev,
+			"QPLIB: rq[%d] = 0x%llx with status 0x%x\n",
+			last, cqe->wr_id, cqe->status);
+		cqe++;
+		(*budget)--;
+		bnxt_qplib_hwq_incr_cons(rq->hwq.depth,
+					 &rq->hwq.cons,
+					 rq->swq[last].slots,
+					 &rq->dbinfo.flags);
+		rq->swq_last = rq->swq[last].next_idx;
+	}
+	*pcqe = cqe;
+	if (!*budget && rq->swq_last != start)
+		/* Out of budget */
+		rc = -EAGAIN;
+
+	dev_dbg(&rq->hwq.pdev->dev, "QPLIB: FP: Flush RQ rc = 0x%x\n", rc);
+	return rc;
+}
+
+void bnxt_qplib_mark_qp_error(void *qp_handle)
+{
+	struct bnxt_qplib_qp *qp = qp_handle;
+
+	if (!qp)
+		return;
+
+	/* Must block new posting of SQ and RQ */
+	qp->cur_qp_state = CMDQ_MODIFY_QP_NEW_STATE_ERR;
+	qp->state = qp->cur_qp_state;
+
+	/* Add qp to flush list of the CQ */
+	if (!qp->is_user)
+		bnxt_qplib_add_flush_qp(qp);
+}
+
+/* Note: SQE is valid from sw_sq_cons up to cqe_sq_cons (exclusive)
+ *       CQE is track from sw_cq_cons to max_element but valid only if VALID=1
+ */
+static int bnxt_re_legacy_do_wa9060(struct bnxt_qplib_qp *qp,
+				 struct bnxt_qplib_cq *cq,
+				 u32 cq_cons, u32 swq_last,
+				 u32 cqe_sq_cons)
+{
+	struct bnxt_qplib_q *sq = &qp->sq;
+	struct bnxt_qplib_swq *swq;
+	u32 peek_sw_cq_cons, peek_sq_cons_idx, peek_flags;
+	struct cq_terminal *peek_term_hwcqe;
+	struct cq_req *peek_req_hwcqe;
+	struct bnxt_qplib_qp *peek_qp;
+	struct bnxt_qplib_q *peek_sq;
+	struct cq_base *peek_hwcqe;
+	int i, rc = 0;
+
+	/* Check for the psn_search marking before completing */
+	swq = &sq->swq[swq_last];
+	if (swq->psn_search &&
+	    le32_to_cpu(swq->psn_search->flags_next_psn) & 0x80000000) {
+		/* Unmark */
+		swq->psn_search->flags_next_psn = cpu_to_le32
+				(le32_to_cpu(swq->psn_search->flags_next_psn)
+				 & ~0x80000000);
+		dev_dbg(&cq->hwq.pdev->dev,
+			"FP: Process Req cq_cons=0x%x qp=0x%x sq cons sw=0x%x cqe=0x%x marked!\n",
+			cq_cons, qp->id, swq_last, cqe_sq_cons);
+		sq->condition = true;
+		sq->legacy_send_phantom = true;
+
+		/* TODO: Only ARM if the previous SQE is ARMALL */
+		bnxt_qplib_ring_db(&cq->dbinfo, DBC_DBC_TYPE_CQ_ARMALL);
+
+		rc = -EAGAIN;
+		goto out;
+	}
+	if (sq->condition == true) {
+		/* Peek at the completions */
+		peek_flags = cq->dbinfo.flags;
+		peek_sw_cq_cons = cq_cons;
+		i = cq->hwq.depth;
+		while (i--) {
+			peek_hwcqe = bnxt_qplib_get_qe(&cq->hwq,
+						       peek_sw_cq_cons, NULL);
+			/* If the next hwcqe is VALID */
+			if (CQE_CMP_VALID(peek_hwcqe, peek_flags)) {
+				/* If the next hwcqe is a REQ */
+				dma_rmb();
+				switch (peek_hwcqe->cqe_type_toggle &
+					CQ_BASE_CQE_TYPE_MASK) {
+				case CQ_BASE_CQE_TYPE_REQ:
+					peek_req_hwcqe = (struct cq_req *)
+							 peek_hwcqe;
+					peek_qp = (struct bnxt_qplib_qp *)
+						le64_to_cpu(
+						peek_req_hwcqe->qp_handle);
+					peek_sq = &peek_qp->sq;
+					peek_sq_cons_idx =
+						((le16_to_cpu(
+						  peek_req_hwcqe->sq_cons_idx)
+						  - 1) % sq->max_wqe);
+					/* If the hwcqe's sq's wr_id matches */
+					if (peek_sq == sq &&
+					    sq->swq[peek_sq_cons_idx].wr_id ==
+					    BNXT_QPLIB_FENCE_WRID) {
+						/* Unbreak only if the phantom
+						   comes back */
+						dev_dbg(&cq->hwq.pdev->dev,
+							"FP: Process Req qp=0x%x current sq cons sw=0x%x cqe=0x%x\n",
+							qp->id, swq_last,
+							cqe_sq_cons);
+						sq->condition = false;
+						sq->single = true;
+						sq->phantom_cqe_cnt++;
+						dev_dbg(&cq->hwq.pdev->dev,
+							"qp %#x condition restored at peek cq_cons=%#x sq_cons_idx %#x, phantom_cqe_cnt: %d unmark\n",
+							peek_qp->id,
+							peek_sw_cq_cons,
+							peek_sq_cons_idx,
+							sq->phantom_cqe_cnt);
+						rc = 0;
+						goto out;
+					}
+					break;
+
+				case CQ_BASE_CQE_TYPE_TERMINAL:
+					/* In case the QP has gone into the
+					   error state */
+					peek_term_hwcqe = (struct cq_terminal *)
+							  peek_hwcqe;
+					peek_qp = (struct bnxt_qplib_qp *)
+						le64_to_cpu(
+						peek_term_hwcqe->qp_handle);
+					if (peek_qp == qp) {
+						sq->condition = false;
+						rc = 0;
+						goto out;
+					}
+					break;
+				default:
+					break;
+				}
+				/* Valid but not the phantom, so keep looping */
+			} else {
+				/* Not valid yet, just exit and wait */
+				rc = -EINVAL;
+				goto out;
+			}
+			bnxt_qplib_hwq_incr_cons(cq->hwq.depth,
+						 &peek_sw_cq_cons,
+						 1, &peek_flags);
+		}
+		dev_err(&cq->hwq.pdev->dev,
+			"Should not have come here! cq_cons=0x%x qp=0x%x sq cons sw=0x%x hw=0x%x\n",
+			cq_cons, qp->id, swq_last, cqe_sq_cons);
+		rc = -EINVAL;
+	}
+out:
+	return rc;
+}
+
+static int bnxt_qplib_cq_process_req(struct bnxt_qplib_cq *cq,
+				     struct cq_req *hwcqe,
+				     struct bnxt_qplib_cqe **pcqe, int *budget,
+				     u32 cq_cons, struct bnxt_qplib_qp **lib_qp)
+{
+	struct bnxt_qplib_qp *qp;
+	struct bnxt_qplib_q *sq;
+	struct bnxt_qplib_cqe *cqe;
+	u32 cqe_sq_cons;
+	struct bnxt_qplib_swq *swq;
+	int rc = 0;
+
+	qp = (struct bnxt_qplib_qp *)le64_to_cpu(hwcqe->qp_handle);
+	dev_dbg(&cq->hwq.pdev->dev, "FP: Process Req qp=0x%p\n", qp);
+	if (!qp) {
+		dev_err(&cq->hwq.pdev->dev,
+			"QPLIB: FP: Process Req qp is NULL\n");
+		return -EINVAL;
+	}
+	sq = &qp->sq;
+
+	cqe_sq_cons = le16_to_cpu(hwcqe->sq_cons_idx) % sq->max_wqe;
+	if (qp->sq.flushed) {
+		dev_dbg(&cq->hwq.pdev->dev,
+			"%s: QPLIB: QP in Flush QP = %p\n", __func__, qp);
+		goto done;
+	}
+
+	/* Require to walk the sq's swq to fabricate CQEs for all previously
+	 * signaled SWQEs due to CQE aggregation from the current sq cons
+	 * to the cqe_sq_cons
+	 */
+	cqe = *pcqe;
+	while (*budget) {
+		if (sq->swq_last == cqe_sq_cons)
+			/* Done */
+			break;
+
+		swq = &sq->swq[sq->swq_last];
+		memset(cqe, 0, sizeof(*cqe));
+		cqe->opcode = CQ_BASE_CQE_TYPE_REQ;
+		cqe->qp_handle = (u64)qp;
+		cqe->src_qp = qp->id;
+		cqe->wr_id = swq->wr_id;
+
+		if (cqe->wr_id == BNXT_QPLIB_FENCE_WRID)
+			goto skip;
+
+		cqe->type = swq->type;
+
+		/* For the last CQE, check for status.  For errors, regardless
+		 * of the request being signaled or not, it must complete with
+		 * the hwcqe error status
+		 */
+		if (swq->next_idx == cqe_sq_cons &&
+		    hwcqe->status != CQ_REQ_STATUS_OK) {
+			cqe->status = hwcqe->status;
+			dev_err(&cq->hwq.pdev->dev,
+				"QPLIB: FP: CQ Processed Req \n");
+			dev_err(&cq->hwq.pdev->dev,
+				"QPLIB: QP 0x%x wr_id[%d] = 0x%lx vendor type 0x%x with vendor status 0x%x\n",
+				cqe->src_qp, sq->swq_last, cqe->wr_id, cqe->type, cqe->status);
+			cqe++;
+			(*budget)--;
+			bnxt_qplib_mark_qp_error(qp);
+		} else {
+			/* Before we complete, do WA 9060 */
+			if (!_is_chip_gen_p5_p7(qp->cctx)) {
+				if (bnxt_re_legacy_do_wa9060(qp, cq, cq_cons,
+					      sq->swq_last,
+					      cqe_sq_cons)) {
+					*lib_qp = qp;
+					goto out;
+				}
+			}
+			if (swq->flags & SQ_SEND_FLAGS_SIGNAL_COMP) {
+
+				dev_dbg(&cq->hwq.pdev->dev,
+					"QPLIB: FP: CQ Processed Req \n");
+				dev_dbg(&cq->hwq.pdev->dev,
+					"QPLIB: wr_id[%d] = 0x%llx \n",
+					sq->swq_last, cqe->wr_id);
+				dev_dbg(&cq->hwq.pdev->dev,
+					"QPLIB: with status 0x%x\n", cqe->status);
+				cqe->status = CQ_REQ_STATUS_OK;
+				cqe++;
+				(*budget)--;
+			}
+		}
+skip:
+		bnxt_qplib_hwq_incr_cons(sq->hwq.depth, &sq->hwq.cons,
+					 swq->slots, &sq->dbinfo.flags);
+		sq->swq_last = swq->next_idx;
+		if (sq->single == true)
+			break;
+	}
+out:
+	*pcqe = cqe;
+	if (sq->swq_last != cqe_sq_cons) {
+		/* Out of budget */
+		rc = -EAGAIN;
+		goto done;
+	}
+	/* Back to normal completion mode only after it has completed all of
+	   the WC for this CQE */
+	sq->single = false;
+done:
+	return rc;
+}
+
+static void bnxt_qplib_release_srqe(struct bnxt_qplib_srq *srq, u32 tag)
+{
+	spin_lock(&srq->hwq.lock);
+	srq->swq[srq->last_idx].next_idx = (int)tag;
+	srq->last_idx = (int)tag;
+	srq->swq[srq->last_idx].next_idx = -1;
+	bnxt_qplib_hwq_incr_cons(srq->hwq.depth, &srq->hwq.cons,
+				 srq->dbinfo.max_slot, &srq->dbinfo.flags);
+	spin_unlock(&srq->hwq.lock);
+}
+
+static int bnxt_qplib_cq_process_res_rc(struct bnxt_qplib_cq *cq,
+					struct cq_res_rc *hwcqe,
+					struct bnxt_qplib_cqe **pcqe,
+					int *budget)
+{
+	struct bnxt_qplib_srq *srq;
+	struct bnxt_qplib_cqe *cqe;
+	struct bnxt_qplib_qp *qp;
+	struct bnxt_qplib_q *rq;
+	u32 wr_id_idx;
+	int rc = 0;
+
+	qp = (struct bnxt_qplib_qp *)le64_to_cpu(hwcqe->qp_handle);
+	if (!qp) {
+		dev_err(&cq->hwq.pdev->dev, "QPLIB: process_cq RC qp is NULL\n");
+		return -EINVAL;
+	}
+	if (qp->rq.flushed) {
+		dev_dbg(&cq->hwq.pdev->dev,
+			"%s: QPLIB: QP in Flush QP = %p\n", __func__, qp);
+		goto done;
+	}
+
+	cqe = *pcqe;
+	cqe->opcode = hwcqe->cqe_type_toggle & CQ_BASE_CQE_TYPE_MASK;
+	cqe->length = le32_to_cpu(hwcqe->length);
+	cqe->invrkey = le32_to_cpu(hwcqe->imm_data_or_inv_r_key);
+	cqe->mr_handle = le64_to_cpu(hwcqe->mr_handle);
+	cqe->flags = le16_to_cpu(hwcqe->flags);
+	cqe->status = hwcqe->status;
+	cqe->qp_handle = (u64)(unsigned long)qp;
+
+	wr_id_idx = le32_to_cpu(hwcqe->srq_or_rq_wr_id) &
+				CQ_RES_RC_SRQ_OR_RQ_WR_ID_MASK;
+	if (cqe->flags & CQ_RES_RC_FLAGS_SRQ_SRQ) {
+		srq = qp->srq;
+		if (!srq) {
+			dev_err(&cq->hwq.pdev->dev,
+				"QPLIB: FP: SRQ used but not defined??\n");
+			return -EINVAL;
+		}
+		if (wr_id_idx > srq->hwq.depth - 1) {
+			dev_err(&cq->hwq.pdev->dev,
+				"QPLIB: FP: CQ Process RC \n");
+			dev_err(&cq->hwq.pdev->dev,
+				"QPLIB: wr_id idx 0x%x exceeded SRQ max 0x%x\n",
+				wr_id_idx, srq->hwq.depth);
+			return -EINVAL;
+		}
+		cqe->wr_id = srq->swq[wr_id_idx].wr_id;
+		bnxt_qplib_release_srqe(srq, wr_id_idx);
+		dev_dbg(&srq->hwq.pdev->dev,
+			"QPLIB: FP: CQ Processed RC SRQ wr_id[%d] = 0x%llx\n",
+			wr_id_idx, cqe->wr_id);
+		cqe++;
+		(*budget)--;
+		*pcqe = cqe;
+	} else {
+		rq = &qp->rq;
+		if (wr_id_idx > (rq->max_wqe - 1)) {
+			dev_err(&cq->hwq.pdev->dev,
+				"QPLIB: FP: CQ Process RC \n");
+			dev_err(&cq->hwq.pdev->dev,
+				"QPLIB: wr_id idx 0x%x exceeded RQ max 0x%x\n",
+				wr_id_idx, rq->hwq.depth);
+			return -EINVAL;
+		}
+		if (wr_id_idx != rq->swq_last)
+			return -EINVAL;
+		cqe->wr_id = rq->swq[rq->swq_last].wr_id;
+		dev_dbg(&cq->hwq.pdev->dev,
+			"QPLIB: FP: CQ Processed RC RQ wr_id[%d] = 0x%llx\n",
+			rq->swq_last, cqe->wr_id);
+		cqe++;
+		(*budget)--;
+		bnxt_qplib_hwq_incr_cons(rq->hwq.depth, &rq->hwq.cons,
+					 rq->swq[rq->swq_last].slots,
+					 &rq->dbinfo.flags);
+		rq->swq_last = rq->swq[rq->swq_last].next_idx;
+		*pcqe = cqe;
+
+		if (hwcqe->status != CQ_RES_RC_STATUS_OK)
+			bnxt_qplib_mark_qp_error(qp);
+	}
+done:
+	return rc;
+}
+
+static int bnxt_qplib_cq_process_res_ud(struct bnxt_qplib_cq *cq,
+					struct cq_res_ud_v2 *hwcqe,
+					struct bnxt_qplib_cqe **pcqe,
+					int *budget)
+{
+	struct bnxt_qplib_srq *srq;
+	struct bnxt_qplib_cqe *cqe;
+	struct bnxt_qplib_qp *qp;
+	struct bnxt_qplib_q *rq;
+	u32 wr_id_idx;
+	int rc = 0;
+	u16 *smac;
+
+	qp = (struct bnxt_qplib_qp *)le64_to_cpu(hwcqe->qp_handle);
+	if (!qp) {
+		dev_err(&cq->hwq.pdev->dev, "QPLIB: process_cq UD qp is NULL\n");
+		return -EINVAL;
+	}
+	if (qp->rq.flushed) {
+		dev_dbg(&cq->hwq.pdev->dev,
+			"%s: QPLIB: QP in Flush QP = %p\n", __func__, qp);
+		goto done;
+	}
+	cqe = *pcqe;
+	cqe->opcode = hwcqe->cqe_type_toggle & CQ_RES_UD_V2_CQE_TYPE_MASK;
+	cqe->length = le32_to_cpu((hwcqe->length & CQ_RES_UD_V2_LENGTH_MASK));
+	cqe->cfa_meta = le16_to_cpu(hwcqe->cfa_metadata0);
+	/* V2 format has metadata1 */
+	cqe->cfa_meta |= (((le32_to_cpu(hwcqe->src_qp_high_srq_or_rq_wr_id) &
+			   CQ_RES_UD_V2_CFA_METADATA1_MASK) >>
+			  CQ_RES_UD_V2_CFA_METADATA1_SFT) <<
+			 BNXT_QPLIB_META1_SHIFT);
+	cqe->invrkey = le32_to_cpu(hwcqe->imm_data);
+	cqe->flags = le16_to_cpu(hwcqe->flags);
+	cqe->status = hwcqe->status;
+	cqe->qp_handle = (u64)(unsigned long)qp;
+	smac = (u16 *)cqe->smac;
+	smac[2] = ntohs(le16_to_cpu(hwcqe->src_mac[0]));
+	smac[1] = ntohs(le16_to_cpu(hwcqe->src_mac[1]));
+	smac[0] = ntohs(le16_to_cpu(hwcqe->src_mac[2]));
+	wr_id_idx = le32_to_cpu(hwcqe->src_qp_high_srq_or_rq_wr_id)
+				& CQ_RES_UD_V2_SRQ_OR_RQ_WR_ID_MASK;
+	cqe->src_qp = le16_to_cpu(hwcqe->src_qp_low) |
+				  ((le32_to_cpu(
+				    hwcqe->src_qp_high_srq_or_rq_wr_id) &
+				    CQ_RES_UD_V2_SRC_QP_HIGH_MASK) >> 8);
+
+	if (cqe->flags & CQ_RES_UD_V2_FLAGS_SRQ) {
+		srq = qp->srq;
+		if (!srq) {
+			dev_err(&cq->hwq.pdev->dev,
+				"QPLIB: FP: SRQ used but not defined??\n");
+			return -EINVAL;
+		}
+		if (wr_id_idx > srq->hwq.depth - 1) {
+			dev_err(&cq->hwq.pdev->dev,
+				"QPLIB: FP: CQ Process UD \n");
+			dev_err(&cq->hwq.pdev->dev,
+				"QPLIB: wr_id idx 0x%x exceeded SRQ max 0x%x\n",
+				wr_id_idx, srq->hwq.depth);
+			return -EINVAL;
+		}
+		cqe->wr_id = srq->swq[wr_id_idx].wr_id;
+		bnxt_qplib_release_srqe(srq, wr_id_idx);
+		dev_dbg(&cq->hwq.pdev->dev,
+			"QPLIB: FP: CQ Processed UD SRQ wr_id[%d] = 0x%llx\n",
+			wr_id_idx, cqe->wr_id);
+		cqe++;
+		(*budget)--;
+		*pcqe = cqe;
+	} else {
+		rq = &qp->rq;
+		if (wr_id_idx > (rq->max_wqe - 1)) {
+			dev_err(&cq->hwq.pdev->dev,
+				"QPLIB: FP: CQ Process UD \n");
+			dev_err(&cq->hwq.pdev->dev,
+				"QPLIB: wr_id idx 0x%x exceeded RQ max 0x%x\n",
+				wr_id_idx, rq->hwq.depth);
+			return -EINVAL;
+		}
+		if (rq->swq_last != wr_id_idx)
+			return -EINVAL;
+
+		cqe->wr_id = rq->swq[rq->swq_last].wr_id;
+		dev_dbg(&cq->hwq.pdev->dev,
+			"QPLIB: FP: CQ Processed UD RQ wr_id[%d] = 0x%llx\n",
+			 rq->swq_last, cqe->wr_id);
+		cqe++;
+		(*budget)--;
+		bnxt_qplib_hwq_incr_cons(rq->hwq.depth, &rq->hwq.cons,
+					 rq->swq[rq->swq_last].slots,
+					 &rq->dbinfo.flags);
+		rq->swq_last = rq->swq[rq->swq_last].next_idx;
+		*pcqe = cqe;
+
+		if (hwcqe->status != CQ_RES_UD_V2_STATUS_OK)
+			bnxt_qplib_mark_qp_error(qp);
+	}
+done:
+	return rc;
+}
+
+bool bnxt_qplib_is_cq_empty(struct bnxt_qplib_cq *cq)
+{
+
+	struct cq_base *hw_cqe;
+	unsigned long flags;
+	bool rc = true;
+
+	spin_lock_irqsave(&cq->hwq.lock, flags);
+	hw_cqe = bnxt_qplib_get_qe(&cq->hwq, cq->hwq.cons, NULL);
+
+	 /* Check for Valid bit. If the CQE is valid, return false */
+	rc = !CQE_CMP_VALID(hw_cqe, cq->dbinfo.flags);
+	spin_unlock_irqrestore(&cq->hwq.lock, flags);
+	return rc;
+}
+
+static int bnxt_qplib_cq_process_res_raweth_qp1(struct bnxt_qplib_cq *cq,
+						struct cq_res_raweth_qp1 *hwcqe,
+						struct bnxt_qplib_cqe **pcqe,
+						int *budget)
+{
+	struct bnxt_qplib_qp *qp;
+	struct bnxt_qplib_q *rq;
+	struct bnxt_qplib_srq *srq;
+	struct bnxt_qplib_cqe *cqe;
+	u32 wr_id_idx;
+	int rc = 0;
+
+	qp = (struct bnxt_qplib_qp *)le64_to_cpu(hwcqe->qp_handle);
+	if (!qp) {
+		dev_err(&cq->hwq.pdev->dev,
+			"QPLIB: process_cq Raw/QP1 qp is NULL\n");
+		return -EINVAL;
+	}
+	if (qp->rq.flushed) {
+		dev_dbg(&cq->hwq.pdev->dev,
+			"%s: QPLIB: QP in Flush QP = %p\n", __func__, qp);
+		goto done;
+	}
+	cqe = *pcqe;
+	cqe->opcode = hwcqe->cqe_type_toggle & CQ_BASE_CQE_TYPE_MASK;
+	cqe->flags = le16_to_cpu(hwcqe->flags);
+	cqe->qp_handle = (u64)(unsigned long)qp;
+
+	wr_id_idx = le32_to_cpu(hwcqe->raweth_qp1_payload_offset_srq_or_rq_wr_id)
+				& CQ_RES_RAWETH_QP1_SRQ_OR_RQ_WR_ID_MASK;
+	cqe->src_qp = qp->id;
+	if (qp->id == 1 && !cqe->length) {
+		/* Add workaround for the length misdetection */
+		cqe->length = 296;
+	} else {
+		cqe->length = le16_to_cpu(hwcqe->length);
+	}
+	cqe->pkey_index = qp->pkey_index;
+	memcpy(cqe->smac, qp->smac, 6);
+
+	cqe->raweth_qp1_flags = le16_to_cpu(hwcqe->raweth_qp1_flags);
+	cqe->raweth_qp1_flags2 = le32_to_cpu(hwcqe->raweth_qp1_flags2);
+	cqe->raweth_qp1_metadata = le32_to_cpu(hwcqe->raweth_qp1_metadata);
+
+	dev_dbg(&cq->hwq.pdev->dev,
+		 "QPLIB: raweth_qp1_flags = 0x%x raweth_qp1_flags2 = 0x%x\n",
+		 cqe->raweth_qp1_flags, cqe->raweth_qp1_flags2);
+
+	if (cqe->flags & CQ_RES_RAWETH_QP1_FLAGS_SRQ_SRQ) {
+		srq = qp->srq;
+		if (!srq) {
+			dev_err(&cq->hwq.pdev->dev,
+				"QPLIB: FP: SRQ used but not defined??\n");
+			return -EINVAL;
+		}
+		if (wr_id_idx > srq->hwq.depth - 1) {
+			dev_err(&cq->hwq.pdev->dev,
+				"QPLIB: FP: CQ Process Raw/QP1 \n");
+			dev_err(&cq->hwq.pdev->dev,
+				"QPLIB: wr_id idx 0x%x exceeded SRQ max 0x%x\n",
+				wr_id_idx, srq->hwq.depth);
+			return -EINVAL;
+		}
+		cqe->wr_id = srq->swq[wr_id_idx].wr_id;
+		dev_dbg(&cq->hwq.pdev->dev,
+			"QPLIB: FP: CQ Processed Raw/QP1 SRQ \n");
+		dev_dbg(&cq->hwq.pdev->dev,
+			"QPLIB: wr_id[%d] = 0x%llx with status = 0x%x\n",
+			wr_id_idx, cqe->wr_id, hwcqe->status);
+		cqe++;
+		(*budget)--;
+		srq->hwq.cons++;
+		*pcqe = cqe;
+	} else {
+		rq = &qp->rq;
+		if (wr_id_idx > (rq->max_wqe - 1)) {
+			dev_err(&cq->hwq.pdev->dev,
+				"QPLIB: FP: CQ Process Raw/QP1 RQ wr_id \n");
+			dev_err(&cq->hwq.pdev->dev,
+				"QPLIB: ix 0x%x exceeded RQ max 0x%x\n",
+				wr_id_idx, rq->max_wqe);
+			return -EINVAL;
+		}
+		if (wr_id_idx != rq->swq_last)
+			return -EINVAL;
+		cqe->wr_id = rq->swq[rq->swq_last].wr_id;
+		dev_dbg(&cq->hwq.pdev->dev,
+			"QPLIB: FP: CQ Processed Raw/QP1 RQ \n");
+		dev_dbg(&cq->hwq.pdev->dev,
+			"QPLIB: wr_id[%d] = 0x%llx with status = 0x%x\n",
+			wr_id_idx, cqe->wr_id, hwcqe->status);
+		cqe++;
+		(*budget)--;
+		bnxt_qplib_hwq_incr_cons(rq->hwq.depth, &rq->hwq.cons,
+					 rq->swq[wr_id_idx].slots,
+					 &rq->dbinfo.flags);
+		rq->swq_last = rq->swq[rq->swq_last].next_idx;
+		*pcqe = cqe;
+
+		if (hwcqe->status != CQ_RES_RC_STATUS_OK)
+			bnxt_qplib_mark_qp_error(qp);
+	}
+done:
+	return rc;
+}
+
+static int bnxt_qplib_cq_process_terminal(struct bnxt_qplib_cq *cq,
+					  struct cq_terminal *hwcqe,
+					  struct bnxt_qplib_cqe **pcqe,
+					  int *budget)
+{
+	struct bnxt_qplib_q *sq, *rq;
+	struct bnxt_qplib_cqe *cqe;
+	struct bnxt_qplib_qp *qp;
+	u32 swq_last;
+	u32 cqe_cons;
+	int rc = 0;
+
+	/* Check the Status */
+	if (hwcqe->status != CQ_TERMINAL_STATUS_OK)
+		dev_warn(&cq->hwq.pdev->dev,
+			 "QPLIB: FP: CQ Process Terminal Error status = 0x%x\n",
+			 hwcqe->status);
+
+	qp = (struct bnxt_qplib_qp *)le64_to_cpu(hwcqe->qp_handle);
+	if (!qp)
+		return -EINVAL;
+	dev_dbg(&cq->hwq.pdev->dev,
+		"QPLIB: FP: CQ Process terminal for qp (0x%x)\n", qp->id);
+
+	/* Terminal CQE requires all posted RQEs to complete with FLUSHED_ERR
+	 * from the current rq->cons to the rq->prod regardless what the
+	 * rq->cons the terminal CQE indicates.
+	 */
+	bnxt_qplib_mark_qp_error(qp);
+
+	sq = &qp->sq;
+	rq = &qp->rq;
+
+	cqe_cons = le16_to_cpu(hwcqe->sq_cons_idx);
+	if (cqe_cons == 0xFFFF)
+		goto do_rq;
+
+	cqe_cons %= sq->max_wqe;
+	if (qp->sq.flushed) {
+		dev_dbg(&cq->hwq.pdev->dev,
+			"%s: QPLIB: QP in Flush QP = %p\n", __func__, qp);
+		goto sq_done;
+	}
+
+	/* Terminal CQE can also include aggregated successful CQEs prior.
+	   So we must complete all CQEs from the current sq's cons to the
+	   cq_cons with status OK */
+	cqe = *pcqe;
+	while (*budget) {
+		/*sw_cons = HWQ_CMP(sq->hwq.cons, &sq->hwq);*/
+		swq_last = sq->swq_last;
+		if (swq_last == cqe_cons)
+			break;
+		if (sq->swq[swq_last].flags & SQ_SEND_FLAGS_SIGNAL_COMP) {
+			memset(cqe, 0, sizeof(*cqe));
+			cqe->status = CQ_REQ_STATUS_OK;
+			cqe->opcode = CQ_BASE_CQE_TYPE_REQ;
+			cqe->qp_handle = (u64)qp;
+			cqe->src_qp = qp->id;
+			cqe->wr_id = sq->swq[swq_last].wr_id;
+			cqe->type = sq->swq[swq_last].type;
+			dev_dbg(&cq->hwq.pdev->dev,
+				"QPLIB: FP: CQ Processed terminal Req \n");
+			dev_dbg(&cq->hwq.pdev->dev,
+				"QPLIB: wr_id[%d] = 0x%llx with status 0x%x\n",
+				swq_last, cqe->wr_id, cqe->status);
+			cqe++;
+			(*budget)--;
+		}
+		bnxt_qplib_hwq_incr_cons(sq->hwq.depth, &sq->hwq.cons,
+					 sq->swq[swq_last].slots,
+					 &sq->dbinfo.flags);
+		sq->swq_last = sq->swq[swq_last].next_idx;
+	}
+	*pcqe = cqe;
+	if (!*budget && swq_last != cqe_cons) {
+		/* Out of budget */
+		rc = -EAGAIN;
+		goto sq_done;
+	}
+sq_done:
+	if (rc)
+		return rc;
+do_rq:
+	cqe_cons = le16_to_cpu(hwcqe->rq_cons_idx);
+	if (cqe_cons == 0xFFFF) {
+		goto done;
+	} else if (cqe_cons > (rq->max_wqe - 1)) {
+		dev_err(&cq->hwq.pdev->dev,
+			"QPLIB: FP: CQ Processed terminal \n");
+		dev_err(&cq->hwq.pdev->dev,
+			"QPLIB: reported rq_cons_idx 0x%x exceeds max 0x%x\n",
+			cqe_cons, rq->hwq.depth);
+		goto done;
+	}
+	if (qp->rq.flushed) {
+		dev_dbg(&cq->hwq.pdev->dev,
+			"%s: QPLIB: QP in Flush QP = %p\n", __func__, qp);
+		rc = 0;
+		goto rq_done;
+	}
+
+rq_done:
+done:
+	return rc;
+}
+
+static int bnxt_qplib_cq_process_cutoff(struct bnxt_qplib_cq *cq,
+					struct cq_cutoff *hwcqe)
+{
+	/* Check the Status */
+	if (hwcqe->status != CQ_CUTOFF_STATUS_OK) {
+		dev_err(&cq->hwq.pdev->dev,
+			"QPLIB: FP: CQ Process Cutoff Error status = 0x%x\n",
+			hwcqe->status);
+		return -EINVAL;
+	}
+	clear_bit(CQ_FLAGS_RESIZE_IN_PROG, &cq->flags);
+	wake_up_interruptible(&cq->waitq);
+
+	dev_dbg(&cq->hwq.pdev->dev, "QPLIB: FP: CQ Processed Cutoff\n");
+	return 0;
+}
+
+int bnxt_qplib_process_flush_list(struct bnxt_qplib_cq *cq,
+				struct bnxt_qplib_cqe *cqe,
+				int num_cqes)
+{
+	struct bnxt_qplib_qp *qp = NULL;
+	u32 budget = num_cqes;
+	unsigned long flags;
+
+	spin_lock_irqsave(&cq->flush_lock, flags);
+	list_for_each_entry(qp, &cq->sqf_head, sq_flush) {
+		dev_dbg(&cq->hwq.pdev->dev,
+			"QPLIB: FP: Flushing SQ QP= %p\n",
+			qp);
+		__flush_sq(&qp->sq, qp, &cqe, &budget);
+	}
+
+	list_for_each_entry(qp, &cq->rqf_head, rq_flush) {
+		dev_dbg(&cq->hwq.pdev->dev,
+			"QPLIB: FP: Flushing RQ QP= %p\n",
+			qp);
+		__flush_rq(&qp->rq, qp, &cqe, &budget);
+	}
+	spin_unlock_irqrestore(&cq->flush_lock, flags);
+
+	return num_cqes - budget;
+}
+
+int bnxt_qplib_poll_cq(struct bnxt_qplib_cq *cq, struct bnxt_qplib_cqe *cqe,
+		       int num_cqes, struct bnxt_qplib_qp **lib_qp)
+{
+	struct cq_base *hw_cqe;
+	u32 hw_polled = 0;
+	int budget, rc = 0;
+	u8 type;
+
+	budget = num_cqes;
+
+	while (budget) {
+		hw_cqe = bnxt_qplib_get_qe(&cq->hwq, cq->hwq.cons, NULL);
+
+		/* Check for Valid bit */
+		if (!CQE_CMP_VALID(hw_cqe, cq->dbinfo.flags))
+			break;
+
+		/* The valid test of the entry must be done first before
+		 * reading any further.
+		 */
+		dma_rmb();
+		/* From the device's respective CQE format to qplib_wc*/
+		type = hw_cqe->cqe_type_toggle & CQ_BASE_CQE_TYPE_MASK;
+		switch (type) {
+		case CQ_BASE_CQE_TYPE_REQ:
+			rc = bnxt_qplib_cq_process_req(cq,
+					(struct cq_req *)hw_cqe, &cqe, &budget,
+					cq->hwq.cons, lib_qp);
+			break;
+		case CQ_BASE_CQE_TYPE_RES_RC:
+			rc = bnxt_qplib_cq_process_res_rc(cq,
+						(struct cq_res_rc *)hw_cqe, &cqe,
+						&budget);
+			break;
+		case CQ_BASE_CQE_TYPE_RES_UD:
+			rc = bnxt_qplib_cq_process_res_ud(cq,
+						(struct cq_res_ud_v2 *)hw_cqe,
+						&cqe, &budget);
+			break;
+		case CQ_BASE_CQE_TYPE_RES_RAWETH_QP1:
+			rc = bnxt_qplib_cq_process_res_raweth_qp1(cq,
+						(struct cq_res_raweth_qp1 *)
+						hw_cqe, &cqe, &budget);
+			break;
+		case CQ_BASE_CQE_TYPE_TERMINAL:
+			rc = bnxt_qplib_cq_process_terminal(cq,
+						(struct cq_terminal *)hw_cqe,
+						&cqe, &budget);
+			break;
+		case CQ_BASE_CQE_TYPE_CUT_OFF:
+			bnxt_qplib_cq_process_cutoff(cq,
+						(struct cq_cutoff *)hw_cqe);
+			/* Done processing this CQ */
+			goto exit;
+		default:
+			dev_err(&cq->hwq.pdev->dev,
+				"QPLIB: process_cq unknown type 0x%x\n",
+				hw_cqe->cqe_type_toggle &
+				CQ_BASE_CQE_TYPE_MASK);
+			rc = -EINVAL;
+			break;
+		}
+		if (rc < 0) {
+			dev_dbg(&cq->hwq.pdev->dev,
+				"QPLIB: process_cqe rc = 0x%x\n", rc);
+			if (rc == -EAGAIN)
+				break;
+			/* Error while processing the CQE, just skip to the
+			   next one */
+			if (type != CQ_BASE_CQE_TYPE_TERMINAL)
+				dev_err(&cq->hwq.pdev->dev,
+					"QPLIB: process_cqe error rc = 0x%x\n",
+					rc);
+		}
+		hw_polled++;
+		bnxt_qplib_hwq_incr_cons(cq->hwq.depth, &cq->hwq.cons,
+					 1, &cq->dbinfo.flags);
+	}
+	if (hw_polled)
+		bnxt_qplib_ring_db(&cq->dbinfo, DBC_DBC_TYPE_CQ);
+exit:
+	return num_cqes - budget;
+}
+
+void bnxt_qplib_req_notify_cq(struct bnxt_qplib_cq *cq, u32 arm_type)
+{
+	cq->dbinfo.toggle = cq->toggle;
+	if (arm_type)
+		bnxt_qplib_ring_db(&cq->dbinfo, arm_type);
+	/* Using cq->arm_state variable to track whether to issue cq handler */
+	atomic_set(&cq->arm_state, 1);
+}
+
+void bnxt_qplib_flush_cqn_wq(struct bnxt_qplib_qp *qp)
+{
+	flush_workqueue(qp->scq->nq->cqn_wq);
+	if (qp->scq != qp->rcq)
+		flush_workqueue(qp->rcq->nq->cqn_wq);
+}
diff --git a/sys/dev/bnxt/bnxt_re/qplib_fp.h b/sys/dev/bnxt/bnxt_re/qplib_fp.h
new file mode 100644
index 000000000000..527c377f0aa5
--- /dev/null
+++ b/sys/dev/bnxt/bnxt_re/qplib_fp.h
@@ -0,0 +1,638 @@
+/*
+ * Copyright (c) 2015-2024, Broadcom. All rights reserved.  The term
+ * Broadcom refers to Broadcom Limited and/or its subsidiaries.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Description: Fast Path Operators (header)
+ */
+
+#ifndef __BNXT_QPLIB_FP_H__
+#define __BNXT_QPLIB_FP_H__
+
+/* Temp header structures for SQ */
+struct sq_ud_ext_hdr {
+	__le32	dst_qp;
+	__le32	avid;
+	__le64	rsvd;
+};
+
+struct sq_raw_ext_hdr {
+	__le32	cfa_meta;
+	__le32	rsvd0;
+	__le64	rsvd1;
+};
+
+struct sq_rdma_ext_hdr {
+	__le64	remote_va;
+	__le32	remote_key;
+	__le32	rsvd;
+};
+
+struct sq_atomic_ext_hdr {
+	__le64	swap_data;
+	__le64	cmp_data;
+};
+
+struct sq_fr_pmr_ext_hdr {
+	__le64	pblptr;
+	__le64	va;
+};
+
+struct sq_bind_ext_hdr {
+	__le64	va;
+	__le32	length_lo;
+	__le32	length_hi;
+};
+
+struct rq_ext_hdr {
+	__le64	rsvd1;
+	__le64	rsvd2;
+};
+
+#define BNXT_QPLIB_ETHTYPE_ROCEV1	0x8915
+
+struct bnxt_qplib_srq {
+	struct bnxt_qplib_pd		*pd;
+	struct bnxt_qplib_dpi		*dpi;
+	struct bnxt_qplib_chip_ctx	*cctx;
+	struct bnxt_qplib_cq		*cq;
+	struct bnxt_qplib_swq		*swq;
+	struct bnxt_qplib_hwq		hwq;
+	struct bnxt_qplib_db_info	dbinfo;
+	struct bnxt_qplib_sg_info	sginfo;
+	u64				srq_handle;
+	u32				id;
+	u16				wqe_size;
+	u32				max_wqe;
+	u32				max_sge;
+	u32				threshold;
+	bool				arm_req;
+	int				start_idx;
+	int				last_idx;
+	u16				eventq_hw_ring_id;
+	bool				is_user;
+	spinlock_t			lock;
+};
+
+struct bnxt_qplib_sge {
+	u64				addr;
+	u32				size;
+	u32				lkey;
+};
+
+/*
+ * Buffer space for ETH(14), IP or GRH(40), UDP header(8)
+ * and ib_bth + ib_deth (20).
+ * Max required is 82 when RoCE V2 is enabled
+ */
+
+/*
+ *		RoCE V1 (38 bytes needed)
+ * +------------+----------+--------+--------+-------+
+ * |Eth-hdr(14B)| GRH (40B)|bth+deth|  Mad   | iCRC  |
+ * |		| supplied |  20B   |payload |  4B   |
+ * |		| by user  |supplied| 256B   |	     |
+ * |		| mad      |        |by user |	     |
+ * |		|	   |	    |	     |       |
+ * |    sge 1	|  sge 2   | sge 3  | sge 4  | sge 5 |
+ * +------------+----------+--------+--------+-------+
+ */
+
+/*
+ *		RoCE V2-IPv4 (46 Bytes needed)
+ * +------------+----------+--------+--------+-------+
+ * |Eth-hdr(14B)| IP-hdr   |UDP-hdr |  Mad   | iCRC  |
+ * |		| supplied |   8B   |payload |  4B   |
+ * |		| by user  |bth+deth|  256B  |	     |
+ * |		| mad lower|   20B  |supplied|       |
+ * |		| 20B out  | (sge 3)|by user |       |
+ * |		| of 40B   |	    |	     |	     |
+ * |		| grh space|	    |	     |	     |
+ * |	sge 1	|  sge 2   |  sge 3 |  sge 4 | sge 5 |
+ * +------------+----------+--------+--------+-------+
+ */
+
+/*
+ *		RoCE V2-IPv6 (46 Bytes needed)
+ * +------------+----------+--------+--------+-------+
+ * |Eth-hdr(14B)| IPv6     |UDP-hdr |  Mad   | iCRC  |
+ * |		| supplied |   8B   |payload |  4B   |
+ * |		| by user  |bth+deth| 256B   |       |
+ * |		| mad lower|   20B  |supplied|       |
+ * |		| 40 bytes |        |by user |       |
+ * |		| grh space|	    |        | 	     |
+ * |		|	   |	    |	     |	     |
+ * |	sge 1	|  sge 2   |  sge 3 |  sge 4 | sge 5 |
+ * +------------+----------+--------+--------+-------+
+ */
+
+#define BNXT_QPLIB_MAX_QP1_SQ_HDR_SIZE		74
+#define BNXT_QPLIB_MAX_QP1_SQ_HDR_SIZE_V2	86
+#define BNXT_QPLIB_MAX_QP1_RQ_HDR_SIZE		46
+#define BNXT_QPLIB_MAX_QP1_RQ_ETH_HDR_SIZE	14
+#define BNXT_QPLIB_MAX_QP1_RQ_HDR_SIZE_V2	512
+#define BNXT_QPLIB_MAX_GRH_HDR_SIZE_IPV4	20
+#define BNXT_QPLIB_MAX_GRH_HDR_SIZE_IPV6	40
+#define BNXT_QPLIB_MAX_QP1_RQ_BDETH_HDR_SIZE	20
+#define BNXT_QPLIB_MAX_SQSZ			0xFFFF
+
+struct bnxt_qplib_hdrbuf {
+	dma_addr_t	dma_map;
+	void		*va;
+	u32		len;
+	u32		step;
+};
+
+struct bnxt_qplib_swq {
+	u64				wr_id;
+	int				next_idx;
+	u8				type;
+	u8				flags;
+	u32				start_psn;
+	u32				next_psn;
+	u32				slot_idx;
+	u8				slots;
+	/* WIP: make it void * to handle legacy also */
+	struct sq_psn_search		*psn_search;
+	void				*inline_data;
+};
+
+struct bnxt_qplib_swqe {
+	/* General */
+#define	BNXT_QPLIB_FENCE_WRID	0x46454E43	/* "FENC" */
+#define	BNXT_QPLIB_QP1_DUMMY_WRID 0x44554D59 /* "DUMY" */
+	u64				wr_id;
+	u8				reqs_type;
+	u8				type;
+#define BNXT_QPLIB_SWQE_TYPE_SEND			0
+#define BNXT_QPLIB_SWQE_TYPE_SEND_WITH_IMM		1
+#define BNXT_QPLIB_SWQE_TYPE_SEND_WITH_INV		2
+#define BNXT_QPLIB_SWQE_TYPE_RDMA_WRITE			4
+#define BNXT_QPLIB_SWQE_TYPE_RDMA_WRITE_WITH_IMM	5
+#define BNXT_QPLIB_SWQE_TYPE_RDMA_READ			6
+#define BNXT_QPLIB_SWQE_TYPE_ATOMIC_CMP_AND_SWP		8
+#define BNXT_QPLIB_SWQE_TYPE_ATOMIC_FETCH_AND_ADD	11
+#define BNXT_QPLIB_SWQE_TYPE_LOCAL_INV			12
+#define BNXT_QPLIB_SWQE_TYPE_FAST_REG_MR		13
+#define BNXT_QPLIB_SWQE_TYPE_REG_MR			13
+#define BNXT_QPLIB_SWQE_TYPE_BIND_MW			14
+#define BNXT_QPLIB_SWQE_TYPE_RECV			128
+#define BNXT_QPLIB_SWQE_TYPE_RECV_RDMA_IMM		129
+	u8				flags;
+#define BNXT_QPLIB_SWQE_FLAGS_SIGNAL_COMP		(1 << 0)
+#define BNXT_QPLIB_SWQE_FLAGS_RD_ATOMIC_FENCE		(1 << 1)
+#define BNXT_QPLIB_SWQE_FLAGS_UC_FENCE			(1 << 2)
+#define BNXT_QPLIB_SWQE_FLAGS_SOLICIT_EVENT		(1 << 3)
+#define BNXT_QPLIB_SWQE_FLAGS_INLINE			(1 << 4)
+	struct bnxt_qplib_sge		*sg_list;
+	int				num_sge;
+
+	union {
+		/* Send, with imm, inval key */
+		struct {
+			union {
+				__be32  imm_data;
+				u32     inv_key;
+			};
+			u32		q_key;
+			u32		dst_qp;
+			u16		avid;
+		} send;
+
+		/* Send Raw Ethernet and QP1 */
+		struct {
+			u16		lflags;
+			u16		cfa_action;
+			u32		cfa_meta;
+		} rawqp1;
+
+		/* RDMA write, with imm, read */
+		struct {
+			union {
+				__be32  imm_data;
+				u32     inv_key;
+			};
+			u64		remote_va;
+			u32		r_key;
+		} rdma;
+
+		/* Atomic cmp/swap, fetch/add */
+		struct {
+			u64		remote_va;
+			u32		r_key;
+			u64		swap_data;
+			u64		cmp_data;
+		} atomic;
+
+		/* Local Invalidate */
+		struct {
+			u32		inv_l_key;
+		} local_inv;
+
+		/* FR-PMR */
+		struct {
+			u8		access_cntl;
+			u8		pg_sz_log;
+			bool		zero_based;
+			u32		l_key;
+			u32		length;
+			u8		pbl_pg_sz_log;
+#define BNXT_QPLIB_SWQE_PAGE_SIZE_4K			0
+#define BNXT_QPLIB_SWQE_PAGE_SIZE_8K			1
+#define BNXT_QPLIB_SWQE_PAGE_SIZE_64K			4
+#define BNXT_QPLIB_SWQE_PAGE_SIZE_256K			6
+#define BNXT_QPLIB_SWQE_PAGE_SIZE_1M			8
+#define BNXT_QPLIB_SWQE_PAGE_SIZE_2M			9
+#define BNXT_QPLIB_SWQE_PAGE_SIZE_4M			10
+#define BNXT_QPLIB_SWQE_PAGE_SIZE_1G			18
+			u8		levels;
+#define PAGE_SHIFT_4K	12
+			__le64		*pbl_ptr;
+			dma_addr_t	pbl_dma_ptr;
+			u64		*page_list;
+			u16		page_list_len;
+			u64		va;
+		} frmr;
+
+		/* Bind */
+		struct {
+			u8		access_cntl;
+#define BNXT_QPLIB_BIND_SWQE_ACCESS_LOCAL_WRITE		(1 << 0)
+#define BNXT_QPLIB_BIND_SWQE_ACCESS_REMOTE_READ		(1 << 1)
+#define BNXT_QPLIB_BIND_SWQE_ACCESS_REMOTE_WRITE	(1 << 2)
+#define BNXT_QPLIB_BIND_SWQE_ACCESS_REMOTE_ATOMIC	(1 << 3)
+#define BNXT_QPLIB_BIND_SWQE_ACCESS_WINDOW_BIND		(1 << 4)
+			bool		zero_based;
+			u8		mw_type;
+			u32		parent_l_key;
+			u32		r_key;
+			u64		va;
+			u32		length;
+		} bind;
+	};
+};
+
+struct bnxt_qplib_q {
+	struct bnxt_qplib_swq		*swq;
+	struct bnxt_qplib_db_info	dbinfo;
+	struct bnxt_qplib_sg_info	sginfo;
+	struct bnxt_qplib_hwq		hwq;
+	u32				max_wqe;
+	u16				max_sge;
+	u16				wqe_size;
+	u16				q_full_delta;
+	u32				psn;
+	bool				condition;
+	bool				single;
+	bool				legacy_send_phantom;
+	u32				phantom_wqe_cnt;
+	u32				phantom_cqe_cnt;
+	u32				next_cq_cons;
+	bool				flushed;
+	u32				swq_start;
+	u32				swq_last;
+};
+
+#define BNXT_QPLIB_PPP_REQ		0x1
+#define BNXT_QPLIB_PPP_ST_IDX_SHIFT	0x1
+
+struct bnxt_qplib_ppp {
+	u32 dpi;
+	u8 req;
+	u8 st_idx_en;
+};
+
+struct bnxt_qplib_qp {
+	struct bnxt_qplib_pd		*pd;
+	struct bnxt_qplib_dpi		*dpi;
+	struct bnxt_qplib_chip_ctx	*cctx;
+	u64				qp_handle;
+#define	BNXT_QPLIB_QP_ID_INVALID	0xFFFFFFFF
+	u32				id;
+	u8				type;
+	u8				sig_type;
+	u8				wqe_mode;
+	u8				state;
+	u8				cur_qp_state;
+	u8				is_user;
+	u64				modify_flags;
+	u32				max_inline_data;
+	u32				mtu;
+	u32				path_mtu;
+	bool				en_sqd_async_notify;
+	u16				pkey_index;
+	u32				qkey;
+	u32				dest_qp_id;
+	u8				access;
+	u8				timeout;
+	u8				retry_cnt;
+	u8				rnr_retry;
+	u64				wqe_cnt;
+	u32				min_rnr_timer;
+	u32				max_rd_atomic;
+	u32				max_dest_rd_atomic;
+	u32				dest_qpn;
+	u8				smac[6];
+	u16				vlan_id;
+	u8				nw_type;
+	u16				port_id;
+	struct bnxt_qplib_ah		ah;
+	struct bnxt_qplib_ppp		ppp;
+
+#define BTH_PSN_MASK			((1 << 24) - 1)
+	/* SQ */
+	struct bnxt_qplib_q		sq;
+	/* RQ */
+	struct bnxt_qplib_q		rq;
+	/* SRQ */
+	struct bnxt_qplib_srq		*srq;
+	/* CQ */
+	struct bnxt_qplib_cq		*scq;
+	struct bnxt_qplib_cq		*rcq;
+	/* IRRQ and ORRQ */
+	struct bnxt_qplib_hwq		irrq;
+	struct bnxt_qplib_hwq		orrq;
+	/* Header buffer for QP1 */
+	struct bnxt_qplib_hdrbuf	*sq_hdr_buf;
+	struct bnxt_qplib_hdrbuf	*rq_hdr_buf;
+
+	/* ToS */
+	u8				tos_ecn;
+	u8				tos_dscp;
+	/* To track the SQ and RQ flush list */
+	struct list_head		sq_flush;
+	struct list_head		rq_flush;
+	/* 4 bytes of QP's scrabled mac received from FW */
+	u32				lag_src_mac;
+	u32				msn;
+	u32				msn_tbl_sz;
+	/* get devflags in PI code */
+	u16				dev_cap_flags;
+};
+
+
+#define CQE_CMP_VALID(hdr, pass)				\
+	(!!((hdr)->cqe_type_toggle & CQ_BASE_TOGGLE) ==		\
+	   !(pass & BNXT_QPLIB_FLAG_EPOCH_CONS_MASK))
+
+static inline u32 __bnxt_qplib_get_avail(struct bnxt_qplib_hwq *hwq)
+{
+	int cons, prod, avail;
+
+	/* False full is possible retrying post-send makes sense */
+	cons = hwq->cons;
+	prod = hwq->prod;
+	avail = cons - prod;
+	if (cons <= prod)
+		avail += hwq->depth;
+	return avail;
+}
+
+static inline bool bnxt_qplib_queue_full(struct bnxt_qplib_hwq *hwq, u8 slots)
+{
+	return __bnxt_qplib_get_avail(hwq) <= slots;
+}
+
+struct bnxt_qplib_cqe {
+	u8				status;
+	u8				type;
+	u8				opcode;
+	u32				length;
+	/* Lower 16 is cfa_metadata0, Upper 16 is cfa_metadata1 */
+	u32				cfa_meta;
+#define BNXT_QPLIB_META1_SHIFT		16
+#define	BNXT_QPLIB_CQE_CFA_META1_VALID  0x80000UL
+	u64				wr_id;
+	union {
+		__be32                  immdata;
+		u32                     invrkey;
+	};
+	u64				qp_handle;
+	u64				mr_handle;
+	u16				flags;
+	u8				smac[6];
+	u32				src_qp;
+	u16				raweth_qp1_flags;
+	u16				raweth_qp1_errors;
+	u16				raweth_qp1_cfa_code;
+	u32				raweth_qp1_flags2;
+	u32				raweth_qp1_metadata;
+	u8				raweth_qp1_payload_offset;
+	u16				pkey_index;
+};
+
+#define BNXT_QPLIB_QUEUE_START_PERIOD		0x01
+struct bnxt_qplib_cq {
+	struct bnxt_qplib_dpi		*dpi;
+	struct bnxt_qplib_chip_ctx	*cctx;
+	struct bnxt_qplib_nq		*nq;
+	struct bnxt_qplib_db_info	dbinfo;
+	struct bnxt_qplib_sg_info	sginfo;
+	struct bnxt_qplib_hwq		hwq;
+	struct bnxt_qplib_hwq		resize_hwq;
+	struct list_head		sqf_head;
+	struct list_head		rqf_head;
+	u32				max_wqe;
+	u32				id;
+	u16				count;
+	u16				period;
+	u32				cnq_hw_ring_id;
+	u64				cq_handle;
+	atomic_t			arm_state;
+#define CQ_RESIZE_WAIT_TIME_MS		500
+	unsigned long			flags;
+#define CQ_FLAGS_RESIZE_IN_PROG		1
+	wait_queue_head_t		waitq;
+	spinlock_t			flush_lock; /* lock flush queue list */
+	spinlock_t			compl_lock; /* synch CQ handlers */
+	u16				cnq_events;
+	bool				is_cq_err_event;
+	bool				destroyed;
+	u8				toggle;
+};
+
+#define BNXT_QPLIB_MAX_IRRQE_ENTRY_SIZE	sizeof(struct xrrq_irrq)
+#define BNXT_QPLIB_MAX_ORRQE_ENTRY_SIZE	sizeof(struct xrrq_orrq)
+#define IRD_LIMIT_TO_IRRQ_SLOTS(x)	(2 * x + 2)
+#define IRRQ_SLOTS_TO_IRD_LIMIT(s)	((s >> 1) - 1)
+#define ORD_LIMIT_TO_ORRQ_SLOTS(x)	(x + 1)
+#define ORRQ_SLOTS_TO_ORD_LIMIT(s)	(s - 1)
+
+#define NQE_CMP_VALID(hdr, pass)				\
+	(!!(le32_to_cpu((hdr)->info63_v & 0xffffffff) & NQ_BASE_V) ==	\
+	   !(pass & BNXT_QPLIB_FLAG_EPOCH_CONS_MASK))
+
+#define BNXT_QPLIB_NQE_MAX_CNT		(128 * 1024)
+
+/* MSN table print macros for debugging */
+#define BNXT_RE_MSN_IDX(m) (((m) & SQ_MSN_SEARCH_START_IDX_MASK) >> \
+		SQ_MSN_SEARCH_START_IDX_SFT)
+#define BNXT_RE_MSN_NPSN(m) (((m) & SQ_MSN_SEARCH_NEXT_PSN_MASK) >> \
+		SQ_MSN_SEARCH_NEXT_PSN_SFT)
+#define BNXT_RE_MSN_SPSN(m) (((m) & SQ_MSN_SEARCH_START_PSN_MASK) >> \
+		SQ_MSN_SEARCH_START_PSN_SFT)
+#define BNXT_MSN_TBLE_SGE 6
+
+struct bnxt_qplib_nq_stats {
+	u64	num_dbqne_processed;
+	u64	num_srqne_processed;
+	u64	num_cqne_processed;
+	u64	num_tasklet_resched;
+	u64	num_nq_rearm;
+};
+
+struct bnxt_qplib_nq_db {
+	struct bnxt_qplib_reg_desc	reg;
+	void __iomem			*db;
+	struct bnxt_qplib_db_info	dbinfo;
+};
+
+typedef int (*cqn_handler_t)(struct bnxt_qplib_nq *nq,
+			     struct bnxt_qplib_cq *cq);
+typedef int (*srqn_handler_t)(struct bnxt_qplib_nq *nq,
+			      struct bnxt_qplib_srq *srq, u8 event);
+
+struct bnxt_qplib_nq {
+	struct bnxt_qplib_res		*res;
+	struct bnxt_qplib_hwq		hwq;
+	struct bnxt_qplib_nq_db		nq_db;
+
+	char				*name;
+	u16				ring_id;
+	int				msix_vec;
+	bool				requested;
+	int				budget;
+	u32				load;
+	struct mutex			lock;
+
+	cqn_handler_t			cqn_handler;
+	srqn_handler_t			srqn_handler;
+	struct workqueue_struct		*cqn_wq;
+	struct bnxt_qplib_nq_stats	stats;
+};
+
+struct bnxt_qplib_nq_work {
+	struct work_struct      work;
+	struct bnxt_qplib_nq    *nq;
+	struct bnxt_qplib_cq	*cq;
+};
+
+static inline dma_addr_t
+bnxt_qplib_get_qp_buf_from_index(struct bnxt_qplib_qp *qp, u32 index)
+{
+	struct bnxt_qplib_hdrbuf *buf;
+
+	buf = qp->rq_hdr_buf;
+	return (buf->dma_map + index * buf->step);
+}
+
+void bnxt_qplib_nq_stop_irq(struct bnxt_qplib_nq *nq, bool kill);
+void bnxt_qplib_disable_nq(struct bnxt_qplib_nq *nq);
+int bnxt_qplib_nq_start_irq(struct bnxt_qplib_nq *nq, int nq_indx,
+			    int msix_vector, bool need_init);
+int bnxt_qplib_enable_nq(struct bnxt_qplib_nq *nq, int nq_idx,
+			 int msix_vector, int bar_reg_offset,
+			 cqn_handler_t cqn_handler,
+			 srqn_handler_t srq_handler);
+int bnxt_qplib_create_srq(struct bnxt_qplib_res *res,
+			  struct bnxt_qplib_srq *srq);
+int bnxt_qplib_modify_srq(struct bnxt_qplib_res *res,
+			  struct bnxt_qplib_srq *srq);
+int bnxt_qplib_query_srq(struct bnxt_qplib_res *res,
+			 struct bnxt_qplib_srq *srq);
+int bnxt_qplib_destroy_srq(struct bnxt_qplib_res *res,
+			   struct bnxt_qplib_srq *srq);
+int bnxt_qplib_post_srq_recv(struct bnxt_qplib_srq *srq,
+			     struct bnxt_qplib_swqe *wqe);
+int bnxt_qplib_create_qp1(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp);
+int bnxt_qplib_create_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp);
+int bnxt_qplib_modify_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp);
+int bnxt_qplib_query_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp);
+int bnxt_qplib_destroy_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp);
+void bnxt_qplib_clean_qp(struct bnxt_qplib_qp *qp);
+void bnxt_qplib_free_qp_res(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp);
+void *bnxt_qplib_get_qp1_sq_buf(struct bnxt_qplib_qp *qp,
+				struct bnxt_qplib_sge *sge);
+void *bnxt_qplib_get_qp1_rq_buf(struct bnxt_qplib_qp *qp,
+				struct bnxt_qplib_sge *sge);
+u32 bnxt_qplib_get_rq_prod_index(struct bnxt_qplib_qp *qp);
+void bnxt_qplib_post_send_db(struct bnxt_qplib_qp *qp);
+int bnxt_qplib_post_send(struct bnxt_qplib_qp *qp,
+			 struct bnxt_qplib_swqe *wqe);
+void bnxt_qplib_post_recv_db(struct bnxt_qplib_qp *qp);
+int bnxt_qplib_post_recv(struct bnxt_qplib_qp *qp,
+			 struct bnxt_qplib_swqe *wqe);
+int bnxt_qplib_create_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq);
+int bnxt_qplib_modify_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq);
+int bnxt_qplib_resize_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq,
+			 int new_cqes);
+void bnxt_qplib_resize_cq_complete(struct bnxt_qplib_res *res,
+				   struct bnxt_qplib_cq *cq);
+int bnxt_qplib_destroy_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq);
+void bnxt_qplib_free_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq);
+int bnxt_qplib_poll_cq(struct bnxt_qplib_cq *cq, struct bnxt_qplib_cqe *cqe,
+		       int num, struct bnxt_qplib_qp **qp);
+bool bnxt_qplib_is_cq_empty(struct bnxt_qplib_cq *cq);
+void bnxt_qplib_req_notify_cq(struct bnxt_qplib_cq *cq, u32 arm_type);
+void bnxt_qplib_free_nq_mem(struct bnxt_qplib_nq *nq);
+int bnxt_qplib_alloc_nq_mem(struct bnxt_qplib_res *res,
+			    struct bnxt_qplib_nq *nq);
+void bnxt_qplib_add_flush_qp(struct bnxt_qplib_qp *qp);
+void bnxt_qplib_del_flush_qp(struct bnxt_qplib_qp *qp);
+int bnxt_qplib_process_flush_list(struct bnxt_qplib_cq *cq,
+				struct bnxt_qplib_cqe *cqe,
+				int num_cqes);
+void bnxt_qplib_flush_cqn_wq(struct bnxt_qplib_qp *qp);
+void bnxt_qplib_free_hdr_buf(struct bnxt_qplib_res *res,
+			     struct bnxt_qplib_qp *qp);
+int bnxt_qplib_alloc_hdr_buf(struct bnxt_qplib_res *res,
+			     struct bnxt_qplib_qp *qp, u32 slen, u32 rlen);
+
+static inline bool __can_request_ppp(struct bnxt_qplib_qp *qp)
+{
+	bool can_request = false;
+
+	if (qp->cur_qp_state == CMDQ_MODIFY_QP_NEW_STATE_RESET &&
+	    qp->state ==  CMDQ_MODIFY_QP_NEW_STATE_INIT &&
+	    qp->ppp.req &&
+	    !(qp->ppp.st_idx_en &
+		    CREQ_MODIFY_QP_RESP_PINGPONG_PUSH_ENABLED))
+		can_request = true;
+	return can_request;
+}
+
+/* MSN table update inlin */
+static inline uint64_t bnxt_re_update_msn_tbl(uint32_t st_idx, uint32_t npsn, uint32_t start_psn)
+{
+	return cpu_to_le64((((u64)(st_idx) << SQ_MSN_SEARCH_START_IDX_SFT) &
+		SQ_MSN_SEARCH_START_IDX_MASK) |
+		(((u64)(npsn) << SQ_MSN_SEARCH_NEXT_PSN_SFT) &
+		SQ_MSN_SEARCH_NEXT_PSN_MASK) |
+		(((start_psn) << SQ_MSN_SEARCH_START_PSN_SFT) &
+		SQ_MSN_SEARCH_START_PSN_MASK));
+}
+
+void bnxt_re_schedule_dbq_event(struct bnxt_qplib_res *res);
+#endif
diff --git a/sys/dev/bnxt/bnxt_re/qplib_rcfw.c b/sys/dev/bnxt/bnxt_re/qplib_rcfw.c
new file mode 100644
index 000000000000..7e3453a1e044
--- /dev/null
+++ b/sys/dev/bnxt/bnxt_re/qplib_rcfw.c
@@ -0,0 +1,1338 @@
+/*
+ * Copyright (c) 2015-2024, Broadcom. All rights reserved.  The term
+ * Broadcom refers to Broadcom Limited and/or its subsidiaries.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Description: RDMA Controller HW interface
+ */
+
+#include <linux/interrupt.h>
+#include <linux/spinlock.h>
+#include <linux/dma-mapping.h>
+#include <linux/sched.h>
+#include <linux/pci.h>
+#include <linux/delay.h>
+#include <linux/hardirq.h>
+#include <linux/device.h>
+
+#include "hsi_struct_def.h"
+#include "qplib_tlv.h"
+#include "qplib_res.h"
+#include "qplib_sp.h"
+#include "qplib_rcfw.h"
+#include "bnxt_re.h"
+
+static void bnxt_qplib_service_creq(unsigned long data);
+
+int __check_cmdq_stall(struct bnxt_qplib_rcfw *rcfw,
+			      u32 *cur_prod, u32 *cur_cons)
+{
+	struct bnxt_qplib_cmdq_ctx *cmdq;
+
+	cmdq = &rcfw->cmdq;
+
+	if (*cur_prod == cmdq->hwq.prod &&
+	    *cur_cons == cmdq->hwq.cons)
+		/* No activity on CMDQ or CREQ. FW down */
+		return -ETIMEDOUT;
+
+	*cur_prod = cmdq->hwq.prod;
+	*cur_cons = cmdq->hwq.cons;
+	return 0;
+}
+
+static int bnxt_qplib_map_rc(u8 opcode)
+{
+	switch (opcode) {
+	case CMDQ_BASE_OPCODE_DESTROY_QP:
+	case CMDQ_BASE_OPCODE_DESTROY_SRQ:
+	case CMDQ_BASE_OPCODE_DESTROY_CQ:
+	case CMDQ_BASE_OPCODE_DEALLOCATE_KEY:
+	case CMDQ_BASE_OPCODE_DEREGISTER_MR:
+	case CMDQ_BASE_OPCODE_DELETE_GID:
+	case CMDQ_BASE_OPCODE_DESTROY_QP1:
+	case CMDQ_BASE_OPCODE_DESTROY_AH:
+	case CMDQ_BASE_OPCODE_DEINITIALIZE_FW:
+	case CMDQ_BASE_OPCODE_MODIFY_ROCE_CC:
+	case CMDQ_BASE_OPCODE_SET_LINK_AGGR_MODE:
+		return 0;
+	default:
+		return -ETIMEDOUT;
+	}
+}
+
+/**
+ * bnxt_re_is_fw_stalled   -	Check firmware health
+ * @rcfw      -   rcfw channel instance of rdev
+ * @cookie    -   cookie to track the command
+ *
+ * If firmware has not responded any rcfw command within
+ * rcfw->max_timeout, consider firmware as stalled.
+ *
+ * Returns:
+ * 0 if firmware is responding
+ * -ENODEV if firmware is not responding
+ */
+static int bnxt_re_is_fw_stalled(struct bnxt_qplib_rcfw *rcfw, u16 cookie)
+{
+	struct bnxt_qplib_cmdq_ctx *cmdq;
+	struct bnxt_qplib_crsqe *crsqe;
+
+	crsqe = &rcfw->crsqe_tbl[cookie];
+	cmdq = &rcfw->cmdq;
+
+	if (time_after(jiffies, cmdq->last_seen +
+		      (rcfw->max_timeout * HZ))) {
+		dev_warn_ratelimited(&rcfw->pdev->dev,
+				     "%s: FW STALL Detected. cmdq[%#x]=%#x waited (%ld > %d) msec active %d\n",
+				     __func__, cookie, crsqe->opcode,
+				     (long)jiffies_to_msecs(jiffies - cmdq->last_seen),
+				     rcfw->max_timeout * 1000,
+				     crsqe->is_in_used);
+		return -ENODEV;
+	}
+
+	return 0;
+}
+/**
+ * __wait_for_resp   -	Don't hold the cpu context and wait for response
+ * @rcfw      -   rcfw channel instance of rdev
+ * @cookie    -   cookie to track the command
+ *
+ * Wait for command completion in sleepable context.
+ *
+ * Returns:
+ * 0 if command is completed by firmware.
+ * Non zero error code for rest of the case.
+ */
+static int __wait_for_resp(struct bnxt_qplib_rcfw *rcfw, u16 cookie)
+{
+	struct bnxt_qplib_cmdq_ctx *cmdq;
+	struct bnxt_qplib_crsqe *crsqe;
+	unsigned long issue_time;
+	int ret;
+
+	cmdq = &rcfw->cmdq;
+	issue_time = jiffies;
+	crsqe = &rcfw->crsqe_tbl[cookie];
+
+	do {
+		if (RCFW_NO_FW_ACCESS(rcfw))
+			return bnxt_qplib_map_rc(crsqe->opcode);
+		if (test_bit(FIRMWARE_STALL_DETECTED, &cmdq->flags))
+			return -ETIMEDOUT;
+
+		/* Non zero means command completed */
+		ret = wait_event_timeout(cmdq->waitq,
+					 !crsqe->is_in_used ||
+					 RCFW_NO_FW_ACCESS(rcfw),
+					 msecs_to_jiffies(rcfw->max_timeout * 1000));
+
+		if (!crsqe->is_in_used)
+			return 0;
+		/*
+		 * Take care if interrupt miss or other cases like DBR drop
+		 */
+		bnxt_qplib_service_creq((unsigned long)rcfw);
+		dev_warn_ratelimited(&rcfw->pdev->dev,
+			"Non-Blocking QPLIB: cmdq[%#x]=%#x waited (%lu) msec bit %d\n",
+			cookie, crsqe->opcode,
+			(long)jiffies_to_msecs(jiffies - issue_time),
+			crsqe->is_in_used);
+
+		if (!crsqe->is_in_used)
+			return 0;
+
+		ret = bnxt_re_is_fw_stalled(rcfw, cookie);
+		if (ret)
+			return ret;
+
+	} while (true);
+};
+
+/**
+ * __block_for_resp   -	hold the cpu context and wait for response
+ * @rcfw      -   rcfw channel instance of rdev
+ * @cookie    -   cookie to track the command
+ *
+ * This function will hold the cpu (non-sleepable context) and
+ * wait for command completion. Maximum holding interval is 8 second.
+ *
+ * Returns:
+ * -ETIMEOUT if command is not completed in specific time interval.
+ * 0 if command is completed by firmware.
+ */
+static int __block_for_resp(struct bnxt_qplib_rcfw *rcfw, u16 cookie)
+{
+	struct bnxt_qplib_cmdq_ctx *cmdq = &rcfw->cmdq;
+	struct bnxt_qplib_crsqe *crsqe;
+	unsigned long issue_time = 0;
+
+	issue_time = jiffies;
+	crsqe = &rcfw->crsqe_tbl[cookie];
+
+	do {
+		if (RCFW_NO_FW_ACCESS(rcfw))
+			return bnxt_qplib_map_rc(crsqe->opcode);
+		if (test_bit(FIRMWARE_STALL_DETECTED, &cmdq->flags))
+			return -ETIMEDOUT;
+
+		udelay(1);
+
+		/* Below call is must since there can be a deadlock
+		 * if interrupt is mapped to the same cpu
+		 */
+		bnxt_qplib_service_creq((unsigned long)rcfw);
+		if (!crsqe->is_in_used)
+			return 0;
+
+	} while (time_before(jiffies, issue_time + (8 * HZ)));
+
+	dev_warn_ratelimited(&rcfw->pdev->dev,
+		"Blocking QPLIB: cmdq[%#x]=%#x taken (%lu) msec",
+		cookie, crsqe->opcode,
+		(long)jiffies_to_msecs(jiffies - issue_time));
+
+	return -ETIMEDOUT;
+};
+
+/*  __send_message_no_waiter -	get cookie and post the message.
+ * @rcfw      -   rcfw channel instance of rdev
+ * @msg      -    qplib message internal
+ *
+ * This function will just post and don't bother about completion.
+ * Current design of this function is -
+ * user must hold the completion queue hwq->lock.
+ * user must have used existing completion and free the resources.
+ * this function will not check queue full condition.
+ * this function will explicitly set is_waiter_alive=false.
+ * current use case is - send destroy_ah if create_ah is return
+ * after waiter of create_ah is lost. It can be extended for other
+ * use case as well.
+ *
+ * Returns: Nothing
+ *
+ */
+static  void __send_message_no_waiter(struct bnxt_qplib_rcfw *rcfw,
+			  struct bnxt_qplib_cmdqmsg *msg)
+{
+	struct bnxt_qplib_cmdq_ctx *cmdq = &rcfw->cmdq;
+	struct bnxt_qplib_hwq *cmdq_hwq = &cmdq->hwq;
+	struct bnxt_qplib_crsqe *crsqe;
+	struct bnxt_qplib_cmdqe *cmdqe;
+	u32 sw_prod, cmdq_prod, bsize;
+	u16 cookie;
+	u8 *preq;
+
+	cookie = cmdq->seq_num & RCFW_MAX_COOKIE_VALUE;
+	__set_cmdq_base_cookie(msg->req, msg->req_sz, cpu_to_le16(cookie));
+	crsqe = &rcfw->crsqe_tbl[cookie];
+
+	/* Set cmd_size in terms of 16B slots in req. */
+	bsize = bnxt_qplib_set_cmd_slots(msg->req);
+	/* GET_CMD_SIZE would return number of slots in either case of tlv
+	 * and non-tlv commands after call to bnxt_qplib_set_cmd_slots()
+	 */
+	crsqe->send_timestamp = jiffies;
+	crsqe->is_internal_cmd = true;
+	crsqe->is_waiter_alive = false;
+	crsqe->is_in_used = true;
+	crsqe->req_size = __get_cmdq_base_cmd_size(msg->req, msg->req_sz);
+
+	preq = (u8 *)msg->req;
+	do {
+		/* Locate the next cmdq slot */
+		sw_prod = HWQ_CMP(cmdq_hwq->prod, cmdq_hwq);
+		cmdqe = bnxt_qplib_get_qe(cmdq_hwq, sw_prod, NULL);
+		/* Copy a segment of the req cmd to the cmdq */
+		memset(cmdqe, 0, sizeof(*cmdqe));
+		memcpy(cmdqe, preq, min_t(u32, bsize, sizeof(*cmdqe)));
+		preq += min_t(u32, bsize, sizeof(*cmdqe));
+		bsize -= min_t(u32, bsize, sizeof(*cmdqe));
+		cmdq_hwq->prod++;
+	} while (bsize > 0);
+	cmdq->seq_num++;
+
+	cmdq_prod = cmdq_hwq->prod & 0xFFFF;
+	atomic_inc(&rcfw->timeout_send);
+	/* ring CMDQ DB */
+	wmb();
+	writel(cmdq_prod, cmdq->cmdq_mbox.prod);
+	writel(RCFW_CMDQ_TRIG_VAL, cmdq->cmdq_mbox.db);
+}
+
+static int __send_message(struct bnxt_qplib_rcfw *rcfw,
+			  struct bnxt_qplib_cmdqmsg *msg)
+{
+	u32 bsize, free_slots, required_slots;
+	struct bnxt_qplib_cmdq_ctx *cmdq;
+	struct bnxt_qplib_crsqe *crsqe;
+	struct bnxt_qplib_cmdqe *cmdqe;
+	struct bnxt_qplib_hwq *cmdq_hwq;
+	u32 sw_prod, cmdq_prod;
+	struct pci_dev *pdev;
+	unsigned long flags;
+	u16 cookie;
+	u8 opcode;
+	u8 *preq;
+
+	cmdq = &rcfw->cmdq;
+	cmdq_hwq = &cmdq->hwq;
+	pdev = rcfw->pdev;
+	opcode = __get_cmdq_base_opcode(msg->req, msg->req_sz);
+
+	/* Cmdq are in 16-byte units, each request can consume 1 or more
+	   cmdqe */
+	spin_lock_irqsave(&cmdq_hwq->lock, flags);
+	required_slots = bnxt_qplib_get_cmd_slots(msg->req);
+	free_slots = HWQ_FREE_SLOTS(cmdq_hwq);
+	cookie = cmdq->seq_num & RCFW_MAX_COOKIE_VALUE;
+	crsqe = &rcfw->crsqe_tbl[cookie];
+
+	if (required_slots >= free_slots) {
+		dev_warn_ratelimited(&pdev->dev,
+				"QPLIB: RCFW: CMDQ is full req/free %d/%d!\n",
+				required_slots, free_slots);
+		rcfw->cmdq_full_dbg++;
+		spin_unlock_irqrestore(&cmdq_hwq->lock, flags);
+		return -EAGAIN;
+	}
+
+	if (crsqe->is_in_used)
+		panic("QPLIB: Cookie was not requested %d\n",
+				cookie);
+
+	if (msg->block)
+		cookie |= RCFW_CMD_IS_BLOCKING;
+	__set_cmdq_base_cookie(msg->req, msg->req_sz, cpu_to_le16(cookie));
+
+	/* Set cmd_size in terms of 16B slots in req. */
+	bsize = bnxt_qplib_set_cmd_slots(msg->req);
+	/* GET_CMD_SIZE would return number of slots in either case of tlv
+	 * and non-tlv commands after call to bnxt_qplib_set_cmd_slots()
+	 */
+	crsqe->send_timestamp = jiffies;
+	crsqe->free_slots = free_slots;
+	crsqe->resp = (struct creq_qp_event *)msg->resp;
+	crsqe->resp->cookie = cpu_to_le16(cookie);
+	crsqe->is_internal_cmd = false;
+	crsqe->is_waiter_alive = true;
+	crsqe->is_in_used = true;
+	crsqe->opcode = opcode;
+	crsqe->requested_qp_state = msg->qp_state;
+
+	crsqe->req_size = __get_cmdq_base_cmd_size(msg->req, msg->req_sz);
+	if (__get_cmdq_base_resp_size(msg->req, msg->req_sz) && msg->sb) {
+		struct bnxt_qplib_rcfw_sbuf *sbuf = msg->sb;
+
+		__set_cmdq_base_resp_addr(msg->req, msg->req_sz,
+					  cpu_to_le64(sbuf->dma_addr));
+		__set_cmdq_base_resp_size(msg->req, msg->req_sz,
+					  ALIGN(sbuf->size, BNXT_QPLIB_CMDQE_UNITS) /
+					   BNXT_QPLIB_CMDQE_UNITS);
+	}
+
+	preq = (u8 *)msg->req;
+	do {
+		/* Locate the next cmdq slot */
+		sw_prod = HWQ_CMP(cmdq_hwq->prod, cmdq_hwq);
+		cmdqe = bnxt_qplib_get_qe(cmdq_hwq, sw_prod, NULL);
+		/* Copy a segment of the req cmd to the cmdq */
+		memset(cmdqe, 0, sizeof(*cmdqe));
+		memcpy(cmdqe, preq, min_t(u32, bsize, sizeof(*cmdqe)));
+		preq += min_t(u32, bsize, sizeof(*cmdqe));
+		bsize -= min_t(u32, bsize, sizeof(*cmdqe));
+		cmdq_hwq->prod++;
+	} while (bsize > 0);
+	cmdq->seq_num++;
+
+	cmdq_prod = cmdq_hwq->prod & 0xFFFF;
+	if (test_bit(FIRMWARE_FIRST_FLAG, &cmdq->flags)) {
+		/* The very first doorbell write
+		 * is required to set this flag
+		 * which prompts the FW to reset
+		 * its internal pointers
+		 */
+		cmdq_prod |= BIT(FIRMWARE_FIRST_FLAG);
+		clear_bit(FIRMWARE_FIRST_FLAG, &cmdq->flags);
+	}
+	/* ring CMDQ DB */
+	wmb();
+	writel(cmdq_prod, cmdq->cmdq_mbox.prod);
+	writel(RCFW_CMDQ_TRIG_VAL, cmdq->cmdq_mbox.db);
+
+	dev_dbg(&pdev->dev, "QPLIB: RCFW sent request with 0x%x 0x%x 0x%x\n",
+			cmdq_prod, cmdq_hwq->prod, crsqe->req_size);
+	dev_dbg(&pdev->dev,
+		"QPLIB: opcode 0x%x with cookie 0x%x at cmdq/crsq 0x%p/0x%p\n",
+		opcode,
+		__get_cmdq_base_cookie(msg->req, msg->req_sz),
+		cmdqe, crsqe);
+	spin_unlock_irqrestore(&cmdq_hwq->lock, flags);
+	/* Return the CREQ response pointer */
+	return 0;
+}
+
+/**
+ * __poll_for_resp   -	self poll completion for rcfw command
+ * @rcfw      -   rcfw channel instance of rdev
+ * @cookie    -   cookie to track the command
+ *
+ * It works same as __wait_for_resp except this function will
+ * do self polling in sort interval since interrupt is disabled.
+ * This function can not be called from non-sleepable context.
+ *
+ * Returns:
+ * -ETIMEOUT if command is not completed in specific time interval.
+ * 0 if command is completed by firmware.
+ */
+static int __poll_for_resp(struct bnxt_qplib_rcfw *rcfw, u16 cookie)
+{
+	struct bnxt_qplib_cmdq_ctx *cmdq = &rcfw->cmdq;
+	struct bnxt_qplib_crsqe *crsqe;
+	unsigned long issue_time;
+	int ret;
+
+	issue_time = jiffies;
+	crsqe = &rcfw->crsqe_tbl[cookie];
+
+	do {
+		if (RCFW_NO_FW_ACCESS(rcfw))
+			return bnxt_qplib_map_rc(crsqe->opcode);
+		if (test_bit(FIRMWARE_STALL_DETECTED, &cmdq->flags))
+			return -ETIMEDOUT;
+
+		usleep_range(1000, 1001);
+
+		bnxt_qplib_service_creq((unsigned long)rcfw);
+		if (!crsqe->is_in_used)
+			return 0;
+
+		if (jiffies_to_msecs(jiffies - issue_time) >
+		    (rcfw->max_timeout * 1000)) {
+			dev_warn_ratelimited(&rcfw->pdev->dev,
+				"Self Polling QPLIB: cmdq[%#x]=%#x taken (%lu) msec",
+				cookie, crsqe->opcode,
+				(long)jiffies_to_msecs(jiffies - issue_time));
+			ret = bnxt_re_is_fw_stalled(rcfw, cookie);
+			if (ret)
+				return ret;
+		}
+	} while (true);
+
+};
+
+static int __send_message_basic_sanity(struct bnxt_qplib_rcfw *rcfw,
+			  struct bnxt_qplib_cmdqmsg *msg, u8 opcode)
+{
+	struct bnxt_qplib_cmdq_ctx *cmdq;
+
+	cmdq = &rcfw->cmdq;
+
+	/* Prevent posting if f/w is not in a state to process */
+	if (RCFW_NO_FW_ACCESS(rcfw))
+		return -ENXIO;
+
+	if (test_bit(FIRMWARE_STALL_DETECTED, &cmdq->flags))
+		return -ETIMEDOUT;
+
+	if (test_bit(FIRMWARE_INITIALIZED_FLAG, &cmdq->flags) &&
+	    opcode == CMDQ_BASE_OPCODE_INITIALIZE_FW) {
+		dev_err(&rcfw->pdev->dev, "QPLIB: RCFW already initialized!\n");
+		return -EINVAL;
+	}
+
+	if (!test_bit(FIRMWARE_INITIALIZED_FLAG, &cmdq->flags) &&
+	    (opcode != CMDQ_BASE_OPCODE_QUERY_FUNC &&
+	     opcode != CMDQ_BASE_OPCODE_INITIALIZE_FW &&
+	     opcode != CMDQ_BASE_OPCODE_QUERY_VERSION)) {
+		dev_err(&rcfw->pdev->dev,
+			"QPLIB: RCFW not initialized, reject opcode 0x%x\n",
+			opcode);
+		return -ENOTSUPP;
+	}
+
+	return 0;
+}
+
+/* This function will just post and do not bother about completion */
+static  void __destroy_timedout_ah(struct bnxt_qplib_rcfw *rcfw,
+			  struct creq_create_ah_resp *create_ah_resp)
+{
+	struct bnxt_qplib_cmdqmsg msg = {};
+	struct cmdq_destroy_ah req = {};
+
+	bnxt_qplib_rcfw_cmd_prep(&req, CMDQ_BASE_OPCODE_DESTROY_AH,
+				 sizeof(req));
+	req.ah_cid = create_ah_resp->xid;
+	msg.req = (struct cmdq_base *)&req;
+	msg.req_sz = sizeof(req);
+	__send_message_no_waiter(rcfw, &msg);
+	dev_warn_ratelimited(&rcfw->pdev->dev,
+		"From %s: ah_cid = %d timeout_send %d\n", __func__,
+		req.ah_cid,
+		atomic_read(&rcfw->timeout_send));
+}
+
+/**
+ * __bnxt_qplib_rcfw_send_message   -	qplib interface to send
+ * and complete rcfw command.
+ * @rcfw      -   rcfw channel instance of rdev
+ * @msg      -    qplib message internal
+ *
+ * This function does not account shadow queue depth. It will send
+ * all the command unconditionally as long as send queue is not full.
+ *
+ * Returns:
+ * 0 if command completed by firmware.
+ * Non zero if the command is not completed by firmware.
+ */
+static int __bnxt_qplib_rcfw_send_message(struct bnxt_qplib_rcfw *rcfw,
+				   struct bnxt_qplib_cmdqmsg *msg)
+{
+	struct bnxt_qplib_crsqe *crsqe;
+	struct creq_qp_event *event;
+	unsigned long flags;
+	u16 cookie;
+	int rc = 0;
+	u8 opcode;
+
+	opcode = __get_cmdq_base_opcode(msg->req, msg->req_sz);
+
+	rc = __send_message_basic_sanity(rcfw, msg, opcode);
+	if (rc)
+		return rc == -ENXIO ? bnxt_qplib_map_rc(opcode) : rc;
+
+	rc = __send_message(rcfw, msg);
+	if (rc)
+		return rc;
+
+	cookie = le16_to_cpu(__get_cmdq_base_cookie(msg->req,
+				msg->req_sz)) & RCFW_MAX_COOKIE_VALUE;
+
+
+	if (msg->block)
+		rc = __block_for_resp(rcfw, cookie);
+	else if (atomic_read(&rcfw->rcfw_intr_enabled))
+		rc = __wait_for_resp(rcfw, cookie);
+	else
+		rc = __poll_for_resp(rcfw, cookie);
+
+	if (rc) {
+		/* First check if it is FW stall.
+		 * Use hwq.lock to avoid race with actual completion.
+		 */
+		spin_lock_irqsave(&rcfw->cmdq.hwq.lock, flags);
+		crsqe = &rcfw->crsqe_tbl[cookie];
+		crsqe->is_waiter_alive = false;
+		if (rc == -ENODEV)
+			set_bit(FIRMWARE_STALL_DETECTED, &rcfw->cmdq.flags);
+		spin_unlock_irqrestore(&rcfw->cmdq.hwq.lock, flags);
+
+		return -ETIMEDOUT;
+	}
+
+	event = (struct creq_qp_event *)msg->resp;
+	if (event->status) {
+		/* failed with status */
+		dev_err(&rcfw->pdev->dev, "QPLIB: cmdq[%#x]=%#x (%s) status %d\n",
+			cookie, opcode, GET_OPCODE_TYPE(opcode), event->status);
+		rc = -EFAULT;
+		/*
+		 * Workaround to avoid errors in the stack during bond
+		 * creation and deletion.
+		 * Disable error returned for  ADD_GID/DEL_GID
+		 */
+		if (opcode == CMDQ_BASE_OPCODE_ADD_GID ||
+		    opcode == CMDQ_BASE_OPCODE_DELETE_GID)
+			rc = 0;
+	}
+
+	dev_dbg(&pdev->dev, "QPLIB: %s:%d - op 0x%x (%s), cookie 0x%x -- Return: e->status 0x%x, rc = 0x%x\n",
+		__func__, __LINE__, opcode, GET_OPCODE_TYPE(opcode), cookie, event->status, rc);
+	return rc;
+}
+
+/**
+ * bnxt_qplib_rcfw_send_message   -	qplib interface to send
+ * and complete rcfw command.
+ * @rcfw      -   rcfw channel instance of rdev
+ * @msg      -    qplib message internal
+ *
+ * Driver interact with Firmware through rcfw channel/slow path in two ways.
+ * a. Blocking rcfw command send. In this path, driver cannot hold
+ * the context for longer period since it is holding cpu until
+ * command is not completed.
+ * b. Non-blocking rcfw command send. In this path, driver can hold the
+ * context for longer period. There may be many pending command waiting
+ * for completion because of non-blocking nature.
+ *
+ * Driver will use shadow queue depth. Current queue depth of 8K
+ * (due to size of rcfw message it can be actual ~4K rcfw outstanding)
+ * is not optimal for rcfw command processing in firmware.
+ * RCFW_CMD_NON_BLOCKING_SHADOW_QD is defined as 64.
+ * Restrict at max 64 Non-Blocking rcfw commands.
+ * Do not allow more than 64 non-blocking command to the Firmware.
+ * Allow all blocking commands until there is no queue full.
+ *
+ * Returns:
+ * 0 if command completed by firmware.
+ * Non zero if the command is not completed by firmware.
+ */
+int bnxt_qplib_rcfw_send_message(struct bnxt_qplib_rcfw *rcfw,
+				 struct bnxt_qplib_cmdqmsg *msg)
+{
+	int ret;
+
+	if (!msg->block) {
+		down(&rcfw->rcfw_inflight);
+		ret = __bnxt_qplib_rcfw_send_message(rcfw, msg);
+		up(&rcfw->rcfw_inflight);
+	} else {
+		ret = __bnxt_qplib_rcfw_send_message(rcfw, msg);
+	}
+
+	return ret;
+}
+
+static void bnxt_re_add_perf_stats(struct bnxt_qplib_rcfw *rcfw,
+		struct bnxt_qplib_crsqe *crsqe)
+{
+	u32 latency_msec, dest_stats_id;
+	u64 *dest_stats_ptr = NULL;
+
+	latency_msec = jiffies_to_msecs(rcfw->cmdq.last_seen -
+				crsqe->send_timestamp);
+	if (latency_msec/1000 < RCFW_MAX_LATENCY_SEC_SLAB_INDEX)
+		rcfw->rcfw_lat_slab_sec[latency_msec/1000]++;
+
+	if (!rcfw->sp_perf_stats_enabled)
+		return;
+
+	if (latency_msec < RCFW_MAX_LATENCY_MSEC_SLAB_INDEX)
+		rcfw->rcfw_lat_slab_msec[latency_msec]++;
+
+	switch (crsqe->opcode) {
+	case CMDQ_BASE_OPCODE_CREATE_QP:
+		dest_stats_id = rcfw->qp_create_stats_id++;
+		dest_stats_id = dest_stats_id % RCFW_MAX_STAT_INDEX;
+		dest_stats_ptr = &rcfw->qp_create_stats[dest_stats_id];
+		break;
+	case CMDQ_BASE_OPCODE_DESTROY_QP:
+		dest_stats_id = rcfw->qp_destroy_stats_id++;
+		dest_stats_id = dest_stats_id % RCFW_MAX_STAT_INDEX;
+		dest_stats_ptr = &rcfw->qp_destroy_stats[dest_stats_id];
+		break;
+	case CMDQ_BASE_OPCODE_REGISTER_MR:
+		dest_stats_id = rcfw->mr_create_stats_id++;
+		dest_stats_id = dest_stats_id % RCFW_MAX_STAT_INDEX;
+		dest_stats_ptr = &rcfw->mr_create_stats[dest_stats_id];
+		break;
+	case CMDQ_BASE_OPCODE_DEREGISTER_MR:
+	case CMDQ_BASE_OPCODE_DEALLOCATE_KEY:
+		dest_stats_id = rcfw->mr_destroy_stats_id++;
+		dest_stats_id = dest_stats_id % RCFW_MAX_STAT_INDEX;
+		dest_stats_ptr = &rcfw->mr_destroy_stats[dest_stats_id];
+		break;
+	case CMDQ_BASE_OPCODE_MODIFY_QP:
+		if (crsqe->requested_qp_state != IB_QPS_ERR)
+			break;
+		dest_stats_id = rcfw->qp_modify_stats_id++;
+		dest_stats_id = dest_stats_id % RCFW_MAX_STAT_INDEX;
+		dest_stats_ptr = &rcfw->qp_modify_stats[dest_stats_id];
+		break;
+	default:
+		break;
+	}
+	if (dest_stats_ptr)
+		*dest_stats_ptr = max_t(unsigned long,
+				(rcfw->cmdq.last_seen - crsqe->send_timestamp), 1);
+
+}
+
+/* Completions */
+static int bnxt_qplib_process_qp_event(struct bnxt_qplib_rcfw *rcfw,
+				       struct creq_qp_event *event,
+				       u32 *num_wait)
+{
+	struct bnxt_qplib_hwq *cmdq_hwq = &rcfw->cmdq.hwq;
+	struct creq_cq_error_notification *cqerr;
+	struct creq_qp_error_notification *qperr;
+	struct bnxt_qplib_crsqe *crsqe;
+	struct bnxt_qplib_reftbl *tbl;
+	struct bnxt_qplib_qp *qp;
+	struct bnxt_qplib_cq *cq;
+	u16 cookie, blocked = 0;
+	struct pci_dev *pdev;
+	bool is_waiter_alive;
+	unsigned long flags;
+	u32 wait_cmds = 0;
+	u32 xid, qp_idx;
+	u32 req_size;
+	int rc = 0;
+
+	pdev = rcfw->pdev;
+	switch (event->event) {
+	case CREQ_QP_EVENT_EVENT_QP_ERROR_NOTIFICATION:
+		tbl = &rcfw->res->reftbl.qpref;
+		qperr = (struct creq_qp_error_notification *)event;
+		xid = le32_to_cpu(qperr->xid);
+		qp_idx = map_qp_id_to_tbl_indx(xid, tbl);
+		spin_lock(&tbl->lock);
+		qp = tbl->rec[qp_idx].handle;
+		if (!qp) {
+			spin_unlock(&tbl->lock);
+			break;
+		}
+		bnxt_qplib_mark_qp_error(qp);
+		rc = rcfw->creq.aeq_handler(rcfw, event, qp);
+		spin_unlock(&tbl->lock);
+		/*
+		 * Keeping these prints as debug to avoid flooding of log
+		 * messages during modify QP to error state by applications
+		 */
+		dev_dbg(&pdev->dev, "QPLIB: QP Error encountered!\n");
+		dev_dbg(&pdev->dev,
+			"QPLIB: qpid 0x%x, req_err=0x%x, resp_err=0x%x\n",
+			xid, qperr->req_err_state_reason,
+			qperr->res_err_state_reason);
+		break;
+	case CREQ_QP_EVENT_EVENT_CQ_ERROR_NOTIFICATION:
+		tbl = &rcfw->res->reftbl.cqref;
+		cqerr = (struct creq_cq_error_notification *)event;
+		xid = le32_to_cpu(cqerr->xid);
+		spin_lock(&tbl->lock);
+		cq = tbl->rec[GET_TBL_INDEX(xid, tbl)].handle;
+		if (!cq) {
+			spin_unlock(&tbl->lock);
+			break;
+		}
+		rc = rcfw->creq.aeq_handler(rcfw, event, cq);
+		spin_unlock(&tbl->lock);
+		dev_dbg(&pdev->dev, "QPLIB: CQ error encountered!\n");
+		break;
+	default:
+		/*
+		 * Command Response
+		 * cmdq hwq lock needs to be acquired to synchronize
+		 * the command send and completion reaping. This function
+		 * is always called with creq hwq lock held. So there is no
+		 * chance of deadlock here as the locking is in correct sequence.
+		 * Using  the nested variant of spin_lock to annotate
+		 */
+		spin_lock_irqsave_nested(&cmdq_hwq->lock, flags,
+					 SINGLE_DEPTH_NESTING);
+		cookie = le16_to_cpu(event->cookie);
+		blocked = cookie & RCFW_CMD_IS_BLOCKING;
+		cookie &= RCFW_MAX_COOKIE_VALUE;
+
+		crsqe = &rcfw->crsqe_tbl[cookie];
+
+		bnxt_re_add_perf_stats(rcfw, crsqe);
+
+		if (WARN_ONCE(test_bit(FIRMWARE_STALL_DETECTED,
+				       &rcfw->cmdq.flags),
+		    "QPLIB: Unreponsive rcfw channel detected.!!")) {
+			dev_info(&pdev->dev, "rcfw timedout: cookie = %#x,"
+				" latency_msec = %ld free_slots = %d\n", cookie,
+				(long)jiffies_to_msecs(rcfw->cmdq.last_seen -
+						 crsqe->send_timestamp),
+				crsqe->free_slots);
+			spin_unlock_irqrestore(&cmdq_hwq->lock, flags);
+			return rc;
+		}
+
+		if (crsqe->is_internal_cmd && !event->status)
+			atomic_dec(&rcfw->timeout_send);
+
+		if (crsqe->is_waiter_alive) {
+			if (crsqe->resp)
+				memcpy(crsqe->resp, event, sizeof(*event));
+			if (!blocked)
+				wait_cmds++;
+		}
+
+		req_size = crsqe->req_size;
+		is_waiter_alive = crsqe->is_waiter_alive;
+
+		crsqe->req_size = 0;
+		if (!crsqe->is_waiter_alive)
+			crsqe->resp = NULL;
+		crsqe->is_in_used = false;
+		/* Consumer is updated so that __send_message_no_waiter
+		 * can never see queue full.
+		 * It is safe since we are still holding cmdq_hwq->lock.
+		 */
+		cmdq_hwq->cons += req_size;
+
+		/* This is a case to handle below scenario -
+		 * Create AH is completed successfully by firmware,
+		 * but completion took more time and driver already lost
+		 * the context of create_ah from caller.
+		 * We have already return failure for create_ah verbs,
+		 * so let's destroy the same address vector since it is
+		 * no more used in stack. We don't care about completion
+		 * in __send_message_no_waiter.
+		 * If destroy_ah is failued by firmware, there will be AH
+		 * resource leak and relatively not critical +  unlikely
+		 * scenario. Current design is not to handle such case.
+		 */
+		if (!is_waiter_alive && !event->status &&
+		    event->event == CREQ_QP_EVENT_EVENT_CREATE_AH)
+			__destroy_timedout_ah(rcfw,
+					      (struct creq_create_ah_resp *)
+					      event);
+
+		spin_unlock_irqrestore(&cmdq_hwq->lock, flags);
+	}
+	*num_wait += wait_cmds;
+	return rc;
+}
+
+/* SP - CREQ Completion handlers */
+static void bnxt_qplib_service_creq(unsigned long data)
+{
+	struct bnxt_qplib_rcfw *rcfw = (struct bnxt_qplib_rcfw *)data;
+	struct bnxt_qplib_creq_ctx *creq = &rcfw->creq;
+	struct bnxt_qplib_res *res;
+	u32 type, budget = CREQ_ENTRY_POLL_BUDGET;
+	struct bnxt_qplib_hwq *creq_hwq = &creq->hwq;
+	struct creq_base *creqe;
+	struct pci_dev *pdev;
+	unsigned long flags;
+	u32 num_wakeup = 0;
+	int rc;
+
+	pdev = rcfw->pdev;
+	res = rcfw->res;
+	/* Service the CREQ until empty */
+	spin_lock_irqsave(&creq_hwq->lock, flags);
+	while (budget > 0) {
+		if (RCFW_NO_FW_ACCESS(rcfw)) {
+			spin_unlock_irqrestore(&creq_hwq->lock, flags);
+			return;
+		}
+		creqe = bnxt_qplib_get_qe(creq_hwq, creq_hwq->cons, NULL);
+		if (!CREQ_CMP_VALID(creqe, creq->creq_db.dbinfo.flags))
+			break;
+		/* The valid test of the entry must be done first before
+		 * reading any further.
+		 */
+		dma_rmb();
+		type = creqe->type & CREQ_BASE_TYPE_MASK;
+		rcfw->cmdq.last_seen = jiffies;
+
+		switch (type) {
+		case CREQ_BASE_TYPE_QP_EVENT:
+			bnxt_qplib_process_qp_event
+				(rcfw,(struct creq_qp_event *)creqe,
+				 &num_wakeup);
+			creq->stats.creq_qp_event_processed++;
+			break;
+		case CREQ_BASE_TYPE_FUNC_EVENT:
+			rc = rcfw->creq.aeq_handler(rcfw, creqe, NULL);
+			if (rc)
+				dev_warn(&pdev->dev,
+					 "QPLIB: async event type = 0x%x not handled",
+					 type);
+			creq->stats.creq_func_event_processed++;
+			break;
+		default:
+			if (type != HWRM_ASYNC_EVENT_CMPL_TYPE_HWRM_ASYNC_EVENT) {
+				dev_warn(&pdev->dev,
+					 "QPLIB: op_event = 0x%x not handled\n",
+					 type);
+			}
+			break;
+		}
+		budget--;
+		bnxt_qplib_hwq_incr_cons(creq_hwq->max_elements, &creq_hwq->cons,
+					 1, &creq->creq_db.dbinfo.flags);
+	}
+	if (budget == CREQ_ENTRY_POLL_BUDGET &&
+	    !CREQ_CMP_VALID(creqe, creq->creq_db.dbinfo.flags)) {
+		/* No completions received during this poll. Enable interrupt now */
+		bnxt_qplib_ring_nq_db(&creq->creq_db.dbinfo, res->cctx, true);
+		creq->stats.creq_arm_count++;
+		dev_dbg(&pdev->dev, "QPLIB: Num of Func (0x%llx) \n",
+			creq->stats.creq_func_event_processed);
+		dev_dbg(&pdev->dev, "QPLIB: QP (0x%llx) events processed\n",
+			creq->stats.creq_qp_event_processed);
+		dev_dbg(&pdev->dev, "QPLIB: Armed:%#llx resched:%#llx \n",
+			creq->stats.creq_arm_count,
+			creq->stats.creq_tasklet_schedule_count);
+	} else if (creq->requested) {
+		/*
+		 * Currently there is no bottom half implementation to process
+		 * completions, all completions are processed in interrupt context
+		 * only. So enable interrupts.
+		 */
+		bnxt_qplib_ring_nq_db(&creq->creq_db.dbinfo, res->cctx, true);
+		creq->stats.creq_tasklet_schedule_count++;
+	}
+	spin_unlock_irqrestore(&creq_hwq->lock, flags);
+	if (num_wakeup)
+		wake_up_all(&rcfw->cmdq.waitq);
+}
+
+static irqreturn_t bnxt_qplib_creq_irq(int irq, void *dev_instance)
+{
+	struct bnxt_qplib_rcfw *rcfw = dev_instance;
+
+	bnxt_qplib_service_creq((unsigned long)rcfw);
+	return IRQ_HANDLED;
+}
+
+/* RCFW */
+int bnxt_qplib_deinit_rcfw(struct bnxt_qplib_rcfw *rcfw)
+{
+	struct creq_deinitialize_fw_resp resp = {};
+	struct cmdq_deinitialize_fw req = {};
+	struct bnxt_qplib_cmdqmsg msg = {};
+	int rc;
+
+	bnxt_qplib_rcfw_cmd_prep(&req, CMDQ_BASE_OPCODE_DEINITIALIZE_FW,
+				 sizeof(req));
+	bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, NULL,
+				sizeof(req), sizeof(resp), 0);
+	rc = bnxt_qplib_rcfw_send_message(rcfw, &msg);
+	if (rc)
+		return rc;
+	clear_bit(FIRMWARE_INITIALIZED_FLAG, &rcfw->cmdq.flags);
+	return 0;
+}
+
+int bnxt_qplib_init_rcfw(struct bnxt_qplib_rcfw *rcfw, int is_virtfn)
+{
+	struct creq_initialize_fw_resp resp = {};
+	struct cmdq_initialize_fw req = {};
+	struct bnxt_qplib_cmdqmsg msg = {};
+	struct bnxt_qplib_chip_ctx *cctx;
+	struct bnxt_qplib_ctx *hctx;
+	struct bnxt_qplib_res *res;
+	struct bnxt_qplib_hwq *hwq;
+	int rc;
+
+	res = rcfw->res;
+	cctx = res->cctx;
+	hctx = res->hctx;
+
+	bnxt_qplib_rcfw_cmd_prep(&req, CMDQ_BASE_OPCODE_INITIALIZE_FW,
+				 sizeof(req));
+	/* Supply (log-base-2-of-host-page-size - base-page-shift)
+	 * to bono to adjust the doorbell page sizes.
+	 */
+	req.log2_dbr_pg_size = cpu_to_le16(PAGE_SHIFT -
+					   RCFW_DBR_BASE_PAGE_SHIFT);
+	/*
+	 * VFs need not setup the HW context area, PF
+	 * shall setup this area for VF. Skipping the
+	 * HW programming
+	 */
+	if (is_virtfn || _is_chip_gen_p5_p7(cctx))
+		goto skip_ctx_setup;
+
+	hwq = &hctx->qp_ctx.hwq;
+	req.qpc_page_dir = cpu_to_le64(_get_base_addr(hwq));
+	req.number_of_qp = cpu_to_le32(hwq->max_elements);
+	req.qpc_pg_size_qpc_lvl = (_get_pte_pg_size(hwq) <<
+				   CMDQ_INITIALIZE_FW_QPC_PG_SIZE_SFT) |
+				   (u8)hwq->level;
+
+	hwq = &hctx->mrw_ctx.hwq;
+	req.mrw_page_dir = cpu_to_le64(_get_base_addr(hwq));
+	req.number_of_mrw = cpu_to_le32(hwq->max_elements);
+	req.mrw_pg_size_mrw_lvl = (_get_pte_pg_size(hwq) <<
+				   CMDQ_INITIALIZE_FW_MRW_PG_SIZE_SFT) |
+				   (u8)hwq->level;
+
+	hwq = &hctx->srq_ctx.hwq;
+	req.srq_page_dir = cpu_to_le64(_get_base_addr(hwq));
+	req.number_of_srq = cpu_to_le32(hwq->max_elements);
+	req.srq_pg_size_srq_lvl = (_get_pte_pg_size(hwq) <<
+				   CMDQ_INITIALIZE_FW_SRQ_PG_SIZE_SFT) |
+				   (u8)hwq->level;
+
+	hwq = &hctx->cq_ctx.hwq;
+	req.cq_page_dir = cpu_to_le64(_get_base_addr(hwq));
+	req.number_of_cq = cpu_to_le32(hwq->max_elements);
+	req.cq_pg_size_cq_lvl = (_get_pte_pg_size(hwq) <<
+				 CMDQ_INITIALIZE_FW_CQ_PG_SIZE_SFT) |
+				 (u8)hwq->level;
+
+	hwq = &hctx->tim_ctx.hwq;
+	req.tim_page_dir = cpu_to_le64(_get_base_addr(hwq));
+	req.tim_pg_size_tim_lvl = (_get_pte_pg_size(hwq) <<
+				   CMDQ_INITIALIZE_FW_TIM_PG_SIZE_SFT) |
+				   (u8)hwq->level;
+	hwq = &hctx->tqm_ctx.pde;
+	req.tqm_page_dir = cpu_to_le64(_get_base_addr(hwq));
+	req.tqm_pg_size_tqm_lvl = (_get_pte_pg_size(hwq) <<
+				   CMDQ_INITIALIZE_FW_TQM_PG_SIZE_SFT) |
+				   (u8)hwq->level;
+skip_ctx_setup:
+	if (BNXT_RE_HW_RETX(res->dattr->dev_cap_flags))
+		req.flags |= CMDQ_INITIALIZE_FW_FLAGS_HW_REQUESTER_RETX_SUPPORTED;
+	req.stat_ctx_id = cpu_to_le32(hctx->stats.fw_id);
+	bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, NULL,
+				sizeof(req), sizeof(resp), 0);
+	rc = bnxt_qplib_rcfw_send_message(rcfw, &msg);
+	if (rc)
+		return rc;
+	set_bit(FIRMWARE_INITIALIZED_FLAG, &rcfw->cmdq.flags);
+
+	return 0;
+}
+
+void bnxt_qplib_free_rcfw_channel(struct bnxt_qplib_res *res)
+{
+	struct bnxt_qplib_rcfw *rcfw = res->rcfw;
+
+	vfree(rcfw->rcfw_lat_slab_msec);
+	rcfw->rcfw_lat_slab_msec = NULL;
+	vfree(rcfw->qp_create_stats);
+	rcfw->qp_create_stats = NULL;
+	vfree(rcfw->qp_destroy_stats);
+	rcfw->qp_destroy_stats = NULL;
+	vfree(rcfw->mr_create_stats);
+	rcfw->mr_create_stats = NULL;
+	vfree(rcfw->mr_destroy_stats);
+	rcfw->mr_destroy_stats = NULL;
+	vfree(rcfw->qp_modify_stats);
+	rcfw->qp_modify_stats = NULL;
+	rcfw->sp_perf_stats_enabled = false;
+
+	kfree(rcfw->crsqe_tbl);
+	rcfw->crsqe_tbl = NULL;
+
+	bnxt_qplib_free_hwq(res, &rcfw->cmdq.hwq);
+	bnxt_qplib_free_hwq(res, &rcfw->creq.hwq);
+	rcfw->pdev = NULL;
+}
+
+int bnxt_qplib_alloc_rcfw_channel(struct bnxt_qplib_res *res)
+{
+	struct bnxt_qplib_hwq_attr hwq_attr = {};
+	struct bnxt_qplib_rcfw *rcfw = res->rcfw;
+	struct bnxt_qplib_sg_info sginfo = {};
+	struct bnxt_qplib_cmdq_ctx *cmdq;
+	struct bnxt_qplib_creq_ctx *creq;
+
+	rcfw->pdev = res->pdev;
+	rcfw->res = res;
+	cmdq = &rcfw->cmdq;
+	creq = &rcfw->creq;
+
+	sginfo.pgsize = PAGE_SIZE;
+	sginfo.pgshft = PAGE_SHIFT;
+
+	hwq_attr.sginfo = &sginfo;
+	hwq_attr.res = rcfw->res;
+	hwq_attr.depth = BNXT_QPLIB_CREQE_MAX_CNT;
+	hwq_attr.stride = BNXT_QPLIB_CREQE_UNITS;
+	hwq_attr.type = _get_hwq_type(res);
+
+	if (bnxt_qplib_alloc_init_hwq(&creq->hwq, &hwq_attr)) {
+		dev_err(&rcfw->pdev->dev,
+			"QPLIB: HW channel CREQ allocation failed\n");
+		return -ENOMEM;
+	}
+
+	sginfo.pgsize = BNXT_QPLIB_CMDQE_PAGE_SIZE;
+	hwq_attr.depth = BNXT_QPLIB_CMDQE_MAX_CNT & 0x7FFFFFFF;
+	hwq_attr.stride = BNXT_QPLIB_CMDQE_UNITS;
+	hwq_attr.type = HWQ_TYPE_CTX;
+	if (bnxt_qplib_alloc_init_hwq(&cmdq->hwq, &hwq_attr)) {
+		dev_err(&rcfw->pdev->dev,
+			"QPLIB: HW channel CMDQ allocation failed\n");
+		goto fail_free_creq_hwq;
+	}
+
+	rcfw->crsqe_tbl = kcalloc(cmdq->hwq.max_elements,
+			sizeof(*rcfw->crsqe_tbl), GFP_KERNEL);
+	if (!rcfw->crsqe_tbl) {
+		dev_err(&rcfw->pdev->dev,
+			"QPLIB: HW channel CRSQ allocation failed\n");
+		goto fail_free_cmdq_hwq;
+	}
+
+	rcfw->max_timeout = res->cctx->hwrm_cmd_max_timeout;
+
+	rcfw->sp_perf_stats_enabled = false;
+	rcfw->rcfw_lat_slab_msec = vzalloc(sizeof(u32) *
+					   RCFW_MAX_LATENCY_MSEC_SLAB_INDEX);
+	rcfw->qp_create_stats = vzalloc(sizeof(u64) * RCFW_MAX_STAT_INDEX);
+	rcfw->qp_destroy_stats = vzalloc(sizeof(u64) * RCFW_MAX_STAT_INDEX);
+	rcfw->mr_create_stats = vzalloc(sizeof(u64) * RCFW_MAX_STAT_INDEX);
+	rcfw->mr_destroy_stats = vzalloc(sizeof(u64) * RCFW_MAX_STAT_INDEX);
+	rcfw->qp_modify_stats = vzalloc(sizeof(u64) * RCFW_MAX_STAT_INDEX);
+
+	if (rcfw->rcfw_lat_slab_msec &&
+	    rcfw->qp_create_stats &&
+	    rcfw->qp_destroy_stats &&
+	    rcfw->mr_create_stats &&
+	    rcfw->mr_destroy_stats &&
+	    rcfw->qp_modify_stats)
+		rcfw->sp_perf_stats_enabled = true;
+
+	return 0;
+fail_free_cmdq_hwq:
+	bnxt_qplib_free_hwq(res, &rcfw->cmdq.hwq);
+fail_free_creq_hwq:
+	bnxt_qplib_free_hwq(res, &rcfw->creq.hwq);
+	return -ENOMEM;
+}
+
+void bnxt_qplib_rcfw_stop_irq(struct bnxt_qplib_rcfw *rcfw, bool kill)
+{
+	struct bnxt_qplib_creq_ctx *creq;
+	struct bnxt_qplib_res *res;
+
+	creq = &rcfw->creq;
+	res = rcfw->res;
+
+	if (!creq->requested)
+		return;
+
+	creq->requested = false;
+	/* Mask h/w interrupts */
+	bnxt_qplib_ring_nq_db(&creq->creq_db.dbinfo, res->cctx, false);
+	/* Sync with last running IRQ-handler */
+	synchronize_irq(creq->msix_vec);
+	free_irq(creq->msix_vec, rcfw);
+	kfree(creq->irq_name);
+	creq->irq_name = NULL;
+	/* rcfw_intr_enabled should not be greater than 1. Debug
+	 * print to check if that is the case
+	 */
+	if (atomic_read(&rcfw->rcfw_intr_enabled) > 1) {
+		dev_err(&rcfw->pdev->dev,
+			"%s: rcfw->rcfw_intr_enabled = 0x%x\n", __func__,
+			atomic_read(&rcfw->rcfw_intr_enabled));
+	}
+	atomic_set(&rcfw->rcfw_intr_enabled, 0);
+	rcfw->num_irq_stopped++;
+}
+
+void bnxt_qplib_disable_rcfw_channel(struct bnxt_qplib_rcfw *rcfw)
+{
+	struct bnxt_qplib_creq_ctx *creq;
+	struct bnxt_qplib_cmdq_ctx *cmdq;
+
+	creq = &rcfw->creq;
+	cmdq = &rcfw->cmdq;
+	/* Make sure the HW channel is stopped! */
+	bnxt_qplib_rcfw_stop_irq(rcfw, true);
+
+	creq->creq_db.reg.bar_reg = NULL;
+	creq->creq_db.db = NULL;
+
+	if (cmdq->cmdq_mbox.reg.bar_reg) {
+		iounmap(cmdq->cmdq_mbox.reg.bar_reg);
+		cmdq->cmdq_mbox.reg.bar_reg = NULL;
+		cmdq->cmdq_mbox.prod = NULL;
+		cmdq->cmdq_mbox.db = NULL;
+	}
+
+	creq->aeq_handler = NULL;
+	creq->msix_vec = 0;
+}
+
+int bnxt_qplib_rcfw_start_irq(struct bnxt_qplib_rcfw *rcfw, int msix_vector,
+			      bool need_init)
+{
+	struct bnxt_qplib_creq_ctx *creq;
+	struct bnxt_qplib_res *res;
+	int rc;
+
+	creq = &rcfw->creq;
+	res = rcfw->res;
+
+	if (creq->requested)
+		return -EFAULT;
+
+	creq->msix_vec = msix_vector;
+
+	creq->irq_name = kasprintf(GFP_KERNEL, "bnxt_re-creq@pci:%s\n",
+				   pci_name(res->pdev));
+	if (!creq->irq_name)
+		return -ENOMEM;
+
+	rc = request_irq(creq->msix_vec, bnxt_qplib_creq_irq, 0,
+			 creq->irq_name, rcfw);
+	if (rc) {
+		kfree(creq->irq_name);
+		creq->irq_name = NULL;
+		return rc;
+	}
+	creq->requested = true;
+
+	bnxt_qplib_ring_nq_db(&creq->creq_db.dbinfo, res->cctx, true);
+
+	rcfw->num_irq_started++;
+	/* Debug print to check rcfw interrupt enable/disable is invoked
+	 * out of sequence
+	 */
+	if (atomic_read(&rcfw->rcfw_intr_enabled) > 0) {
+		dev_err(&rcfw->pdev->dev,
+			"%s: rcfw->rcfw_intr_enabled = 0x%x\n", __func__,
+			atomic_read(&rcfw->rcfw_intr_enabled));
+	}
+	atomic_inc(&rcfw->rcfw_intr_enabled);
+	return 0;
+}
+
+static int bnxt_qplib_map_cmdq_mbox(struct bnxt_qplib_rcfw *rcfw)
+{
+	struct bnxt_qplib_cmdq_mbox *mbox;
+	resource_size_t bar_reg;
+	struct pci_dev *pdev;
+
+	pdev = rcfw->pdev;
+	mbox = &rcfw->cmdq.cmdq_mbox;
+
+	mbox->reg.bar_id = RCFW_COMM_PCI_BAR_REGION;
+	mbox->reg.len = RCFW_COMM_SIZE;
+	mbox->reg.bar_base = pci_resource_start(pdev, mbox->reg.bar_id);
+	if (!mbox->reg.bar_base) {
+		dev_err(&pdev->dev,
+			"QPLIB: CMDQ BAR region %d resc start is 0!\n",
+			mbox->reg.bar_id);
+		return -ENOMEM;
+	}
+
+	bar_reg = mbox->reg.bar_base + RCFW_COMM_BASE_OFFSET;
+	mbox->reg.len = RCFW_COMM_SIZE;
+	mbox->reg.bar_reg = ioremap(bar_reg, mbox->reg.len);
+	if (!mbox->reg.bar_reg) {
+		dev_err(&pdev->dev,
+			"QPLIB: CMDQ BAR region %d mapping failed\n",
+			mbox->reg.bar_id);
+		return -ENOMEM;
+	}
+
+	mbox->prod = (void  __iomem *)((char *)mbox->reg.bar_reg +
+					RCFW_PF_VF_COMM_PROD_OFFSET);
+	mbox->db = (void __iomem *)((char *)mbox->reg.bar_reg +
+				     RCFW_COMM_TRIG_OFFSET);
+	return 0;
+}
+
+static int bnxt_qplib_map_creq_db(struct bnxt_qplib_rcfw *rcfw, u32 reg_offt)
+{
+	struct bnxt_qplib_creq_db *creq_db;
+	struct bnxt_qplib_reg_desc *dbreg;
+	struct bnxt_qplib_res *res;
+
+	res = rcfw->res;
+	creq_db = &rcfw->creq.creq_db;
+	dbreg = &res->dpi_tbl.ucreg;
+
+	creq_db->reg.bar_id = dbreg->bar_id;
+	creq_db->reg.bar_base = dbreg->bar_base;
+	creq_db->reg.bar_reg = dbreg->bar_reg + reg_offt;
+	creq_db->reg.len = _is_chip_gen_p5_p7(res->cctx) ? sizeof(u64) :
+							sizeof(u32);
+
+	creq_db->dbinfo.db = creq_db->reg.bar_reg;
+	creq_db->dbinfo.hwq = &rcfw->creq.hwq;
+	creq_db->dbinfo.xid = rcfw->creq.ring_id;
+	creq_db->dbinfo.seed = rcfw->creq.ring_id;
+	creq_db->dbinfo.flags = 0;
+	spin_lock_init(&creq_db->dbinfo.lock);
+	creq_db->dbinfo.shadow_key = BNXT_QPLIB_DBR_KEY_INVALID;
+	creq_db->dbinfo.res = rcfw->res;
+
+	return 0;
+}
+
+static void bnxt_qplib_start_rcfw(struct bnxt_qplib_rcfw *rcfw)
+{
+	struct bnxt_qplib_cmdq_ctx *cmdq;
+	struct bnxt_qplib_creq_ctx *creq;
+	struct bnxt_qplib_cmdq_mbox *mbox;
+	struct cmdq_init init = {0};
+
+	cmdq = &rcfw->cmdq;
+	creq = &rcfw->creq;
+	mbox = &cmdq->cmdq_mbox;
+
+	init.cmdq_pbl = cpu_to_le64(cmdq->hwq.pbl[PBL_LVL_0].pg_map_arr[0]);
+	init.cmdq_size_cmdq_lvl = cpu_to_le16(
+			((BNXT_QPLIB_CMDQE_MAX_CNT << CMDQ_INIT_CMDQ_SIZE_SFT) &
+			 CMDQ_INIT_CMDQ_SIZE_MASK) |
+			((cmdq->hwq.level << CMDQ_INIT_CMDQ_LVL_SFT) &
+			 CMDQ_INIT_CMDQ_LVL_MASK));
+	init.creq_ring_id = cpu_to_le16(creq->ring_id);
+	/* Write to the Bono mailbox register */
+	__iowrite32_copy(mbox->reg.bar_reg, &init, sizeof(init) / 4);
+}
+
+int bnxt_qplib_enable_rcfw_channel(struct bnxt_qplib_rcfw *rcfw,
+				   int msix_vector,
+				   int cp_bar_reg_off,
+				   aeq_handler_t aeq_handler)
+{
+	struct bnxt_qplib_cmdq_ctx *cmdq;
+	struct bnxt_qplib_creq_ctx *creq;
+	int rc;
+
+	cmdq = &rcfw->cmdq;
+	creq = &rcfw->creq;
+
+	/* Clear to defaults */
+	cmdq->seq_num = 0;
+	set_bit(FIRMWARE_FIRST_FLAG, &cmdq->flags);
+	init_waitqueue_head(&cmdq->waitq);
+
+	creq->stats.creq_qp_event_processed = 0;
+	creq->stats.creq_func_event_processed = 0;
+	creq->aeq_handler = aeq_handler;
+
+	rc = bnxt_qplib_map_cmdq_mbox(rcfw);
+	if (rc)
+		return rc;
+
+	rc = bnxt_qplib_map_creq_db(rcfw, cp_bar_reg_off);
+	if (rc)
+		return rc;
+
+	rc = bnxt_qplib_rcfw_start_irq(rcfw, msix_vector, true);
+	if (rc) {
+		dev_err(&rcfw->pdev->dev,
+			"QPLIB: Failed to request IRQ for CREQ rc = 0x%x\n", rc);
+		bnxt_qplib_disable_rcfw_channel(rcfw);
+		return rc;
+	}
+
+	rcfw->curr_shadow_qd = min_not_zero(cmdq_shadow_qd,
+					    (unsigned int)RCFW_CMD_NON_BLOCKING_SHADOW_QD);
+	sema_init(&rcfw->rcfw_inflight, rcfw->curr_shadow_qd);
+	dev_dbg(&rcfw->pdev->dev,
+		"Perf Debug: shadow qd %d\n", rcfw->curr_shadow_qd);
+	bnxt_qplib_start_rcfw(rcfw);
+
+	return 0;
+}
diff --git a/sys/dev/bnxt/bnxt_re/qplib_rcfw.h b/sys/dev/bnxt/bnxt_re/qplib_rcfw.h
new file mode 100644
index 000000000000..f117525daacb
--- /dev/null
+++ b/sys/dev/bnxt/bnxt_re/qplib_rcfw.h
@@ -0,0 +1,354 @@
+/*
+ * Copyright (c) 2015-2024, Broadcom. All rights reserved.  The term
+ * Broadcom refers to Broadcom Limited and/or its subsidiaries.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Description: RDMA Controller HW interface (header)
+ */
+
+#ifndef __BNXT_QPLIB_RCFW_H__
+#define __BNXT_QPLIB_RCFW_H__
+
+#include <linux/semaphore.h>
+#include <linux/module.h>
+#include <linux/netdevice.h>
+#include <linux/mutex.h>
+#include <linux/list.h>
+#include <linux/rculist.h>
+#include <linux/spinlock.h>
+#include <linux/pci.h>
+#include <net/ipv6.h>
+#include <linux/if_ether.h>
+#include <linux/debugfs.h>
+#include <linux/seq_file.h>
+#include <linux/interrupt.h>
+#include <linux/vmalloc.h>
+#include <linux/delay.h>
+
+#include "qplib_tlv.h"
+
+#define RCFW_CMDQ_TRIG_VAL		1
+#define RCFW_COMM_PCI_BAR_REGION	0
+#define RCFW_COMM_CONS_PCI_BAR_REGION	2
+#define RCFW_COMM_BASE_OFFSET		0x600
+#define RCFW_PF_VF_COMM_PROD_OFFSET	0xc
+#define RCFW_COMM_TRIG_OFFSET		0x100
+#define RCFW_COMM_SIZE			0x104
+
+#define RCFW_DBR_PCI_BAR_REGION		2
+#define RCFW_DBR_BASE_PAGE_SHIFT	12
+#define RCFW_MAX_LATENCY_SEC_SLAB_INDEX	128
+#define RCFW_MAX_LATENCY_MSEC_SLAB_INDEX	3000
+#define RCFW_MAX_STAT_INDEX	0xFFFF
+#define	RCFW_FW_STALL_MAX_TIMEOUT	40
+
+#define GET_OPCODE_TYPE(x) \
+	((x) == 0x1 ? "CREATE_QP": \
+	((x) == 0x2 ? "DESTROY_QP": \
+	((x) == 0x3 ? "MODIFY_QP": \
+	((x) == 0x4 ? "QUERY_QP": \
+	((x) == 0x5 ? "CREATE_SRQ": \
+	((x) == 0x6 ? "DESTROY_SRQ": \
+	((x) == 0x8 ? "QUERY_SRQ": \
+	((x) == 0x9 ? "CREATE_CQ": \
+	((x) == 0xa ? "DESTROY_CQ": \
+	((x) == 0xc ? "RESIZE_CQ": \
+	((x) == 0xd ? "ALLOCATE_MRW": \
+	((x) == 0xe ? "DEALLOCATE_KEY": \
+	((x) == 0xf ? "REGISTER_MR": \
+	((x) == 0x10 ? "DEREGISTER_MR": \
+	((x) == 0x11 ? "ADD_GID": \
+	((x) == 0x12 ? "DELETE_GID": \
+	((x) == 0x17 ? "MODIFY_GID": \
+	((x) == 0x18 ? "QUERY_GID": \
+	((x) == 0x13 ? "CREATE_QP1": \
+	((x) == 0x14 ? "DESTROY_QP1": \
+	((x) == 0x15 ? "CREATE_AH": \
+	((x) == 0x16 ? "DESTROY_AH": \
+	((x) == 0x80 ? "INITIALIZE_FW": \
+	((x) == 0x81 ? "DEINITIALIZE_FW": \
+	((x) == 0x82 ? "STOP_FUNC": \
+	((x) == 0x83 ? "QUERY_FUNC": \
+	((x) == 0x84 ? "SET_FUNC_RESOURCES": \
+	((x) == 0x85 ? "READ_CONTEXT": \
+	((x) == 0x86 ? "VF_BACKCHANNEL_REQUEST": \
+	((x) == 0x87 ? "READ_VF_MEMORY": \
+	((x) == 0x88 ? "COMPLETE_VF_REQUEST": \
+	((x) == 0x89 ? "EXTEND_CONTEXT_ARRRAY": \
+	((x) == 0x8a ? "MAP_TC_TO_COS": \
+	((x) == 0x8b ? "QUERY_VERSION": \
+	((x) == 0x8c ? "MODIFY_ROCE_CC": \
+	((x) == 0x8d ? "QUERY_ROCE_CC": \
+	((x) == 0x8e ? "QUERY_ROCE_STATS": \
+	((x) == 0x8f ? "SET_LINK_AGGR_MODE": \
+	((x) == 0x90 ? "MODIFY_CQ": \
+	((x) == 0x91 ? "QUERY_QP_EXTEND": \
+	((x) == 0x92 ? "QUERY_ROCE_STATS_EXT": \
+	"Unknown OPCODE"	\
+	)))))))))))))))))))))))))))))))))))))))))
+
+extern unsigned int cmdq_shadow_qd;
+/* Cmdq contains a fix number of a 16-Byte slots */
+struct bnxt_qplib_cmdqe {
+	u8		data[16];
+};
+#define BNXT_QPLIB_CMDQE_UNITS		sizeof(struct bnxt_qplib_cmdqe)
+
+static inline void bnxt_qplib_rcfw_cmd_prep(void *r, u8 opcode, u8 cmd_size)
+{
+	struct cmdq_base *req = r;
+
+	req->opcode = opcode;
+	req->cmd_size = cmd_size;
+}
+
+/* Shadow queue depth for non blocking command */
+#define RCFW_CMD_NON_BLOCKING_SHADOW_QD	64
+#define RCFW_CMD_DEV_ERR_CHECK_TIME_MS	1000 /* 1 Second time out*/
+#define RCFW_ERR_RETRY_COUNT		(RCFW_CMD_WAIT_TIME_MS / RCFW_CMD_DEV_ERR_CHECK_TIME_MS)
+
+/* CMDQ elements */
+#define BNXT_QPLIB_CMDQE_MAX_CNT	8192
+#define BNXT_QPLIB_CMDQE_BYTES		(BNXT_QPLIB_CMDQE_MAX_CNT * 	\
+					 BNXT_QPLIB_CMDQE_UNITS)
+#define BNXT_QPLIB_CMDQE_NPAGES		((BNXT_QPLIB_CMDQE_BYTES %	\
+					  PAGE_SIZE) ?			\
+					  ((BNXT_QPLIB_CMDQE_BYTES /	\
+					    PAGE_SIZE) + 1) :		\
+					  (BNXT_QPLIB_CMDQE_BYTES /	\
+					   PAGE_SIZE))
+#define BNXT_QPLIB_CMDQE_PAGE_SIZE	(BNXT_QPLIB_CMDQE_NPAGES *	\
+					 PAGE_SIZE)
+
+#define RCFW_MAX_OUTSTANDING_CMD	BNXT_QPLIB_CMDQE_MAX_CNT
+#define RCFW_MAX_COOKIE_VALUE		(BNXT_QPLIB_CMDQE_MAX_CNT - 1)
+#define RCFW_CMD_IS_BLOCKING		0x8000
+#define RCFW_NO_FW_ACCESS(rcfw)						\
+	(test_bit(ERR_DEVICE_DETACHED, &(rcfw)->cmdq.flags) ||		\
+	 pci_channel_offline((rcfw)->pdev))
+
+/* Crsq buf is 1024-Byte */
+struct bnxt_qplib_crsbe {
+	u8			data[1024];
+};
+
+/* Get the number of command units required for the req. The
+ * function returns correct value only if called before
+ * setting using bnxt_qplib_set_cmd_slots
+ */
+static inline u32 bnxt_qplib_get_cmd_slots(struct cmdq_base *req)
+{
+	u32 cmd_units = 0;
+
+	if (HAS_TLV_HEADER(req)) {
+		struct roce_tlv *tlv_req = (struct roce_tlv *)req;
+		cmd_units = tlv_req->total_size;
+	} else {
+		cmd_units = (req->cmd_size + BNXT_QPLIB_CMDQE_UNITS - 1) /
+			    BNXT_QPLIB_CMDQE_UNITS;
+	}
+	return cmd_units;
+}
+
+/* Set the cmd_size to a factor of CMDQE unit */
+static inline u32 bnxt_qplib_set_cmd_slots(struct cmdq_base *req)
+{
+	u32 cmd_byte = 0;
+
+	if (HAS_TLV_HEADER(req)) {
+		struct roce_tlv *tlv_req = (struct roce_tlv *)req;
+		cmd_byte = tlv_req->total_size * BNXT_QPLIB_CMDQE_UNITS;
+	} else {
+		cmd_byte = req->cmd_size;
+		req->cmd_size = (req->cmd_size + BNXT_QPLIB_CMDQE_UNITS - 1) /
+				 BNXT_QPLIB_CMDQE_UNITS;
+	}
+
+	return cmd_byte;
+}
+
+/* CREQ */
+/* Allocate 1 per QP for async error notification for now */
+#define BNXT_QPLIB_CREQE_MAX_CNT	(64 * 1024)
+#define BNXT_QPLIB_CREQE_UNITS		16	/* 16-Bytes per prod unit */
+
+#define CREQ_CMP_VALID(hdr, pass)				\
+	(!!((hdr)->v & CREQ_BASE_V) ==				\
+	   !(pass & BNXT_QPLIB_FLAG_EPOCH_CONS_MASK))
+
+#define CREQ_ENTRY_POLL_BUDGET		8
+
+typedef int (*aeq_handler_t)(struct bnxt_qplib_rcfw *, void *, void *);
+
+struct bnxt_qplib_crsqe {
+	struct creq_qp_event	*resp;
+	u32			req_size;
+	bool			is_waiter_alive;
+	bool			is_internal_cmd;
+	bool			is_in_used;
+
+	/* Free slots at the time of submission */
+	u32			free_slots;
+	unsigned long		send_timestamp;
+	u8			opcode;
+	u8			requested_qp_state;
+};
+
+struct bnxt_qplib_rcfw_sbuf {
+	void *sb;
+	dma_addr_t dma_addr;
+	u32 size;
+};
+
+#define BNXT_QPLIB_OOS_COUNT_MASK 0xFFFFFFFF
+
+#define FIRMWARE_INITIALIZED_FLAG	(0)
+#define FIRMWARE_FIRST_FLAG		(31)
+#define FIRMWARE_STALL_DETECTED		(3)
+#define ERR_DEVICE_DETACHED		(4)
+struct bnxt_qplib_cmdq_mbox {
+	struct bnxt_qplib_reg_desc	reg;
+	void __iomem			*prod;
+	void __iomem			*db;
+};
+
+struct bnxt_qplib_cmdq_ctx {
+	struct bnxt_qplib_hwq		hwq;
+	struct bnxt_qplib_cmdq_mbox	cmdq_mbox;
+	wait_queue_head_t		waitq;
+	unsigned long			flags;
+	unsigned long			last_seen;
+	u32				seq_num;
+};
+
+struct bnxt_qplib_creq_db {
+	struct bnxt_qplib_reg_desc	reg;
+	void __iomem			*db;
+	struct bnxt_qplib_db_info	dbinfo;
+};
+
+struct bnxt_qplib_creq_stat {
+	u64	creq_arm_count;
+	u64	creq_tasklet_schedule_count;
+	u64	creq_qp_event_processed;
+	u64	creq_func_event_processed;
+};
+
+struct bnxt_qplib_creq_ctx {
+	struct bnxt_qplib_hwq		hwq;
+	struct bnxt_qplib_creq_db	creq_db;
+	struct bnxt_qplib_creq_stat	stats;
+	aeq_handler_t			aeq_handler;
+	u16				ring_id;
+	int				msix_vec;
+	bool				requested;
+	char				*irq_name;
+};
+
+/* RCFW Communication Channels */
+#define BNXT_QPLIB_RCFW_SEND_RETRY_COUNT 4000
+struct bnxt_qplib_rcfw {
+	struct pci_dev			*pdev;
+	struct bnxt_qplib_res		*res;
+	struct bnxt_qplib_cmdq_ctx	cmdq;
+	struct bnxt_qplib_creq_ctx	creq;
+	struct bnxt_qplib_crsqe		*crsqe_tbl;
+	u32	rcfw_lat_slab_sec[RCFW_MAX_LATENCY_SEC_SLAB_INDEX];
+
+	/* Slow path Perf Stats */
+	bool	sp_perf_stats_enabled;
+	u32	*rcfw_lat_slab_msec;
+	u64	*qp_create_stats;
+	u64	*qp_destroy_stats;
+	u64	*qp_modify_stats;
+	u64	*mr_create_stats;
+	u64	*mr_destroy_stats;
+	u32	qp_create_stats_id;
+	u32	qp_destroy_stats_id;
+	u32	qp_modify_stats_id;
+	u32	mr_create_stats_id;
+	u32	mr_destroy_stats_id;
+	bool init_oos_stats;
+	u64 oos_prev;
+	u32 num_irq_stopped;
+	u32 num_irq_started;
+	u32 poll_in_intr_en;
+	u32 poll_in_intr_dis;
+	atomic_t rcfw_intr_enabled;
+	u32 cmdq_full_dbg;
+	struct semaphore rcfw_inflight;
+	unsigned int	curr_shadow_qd;
+	atomic_t timeout_send;
+	/* cached from chip cctx for quick reference in slow path */
+	u16 max_timeout;
+};
+
+struct bnxt_qplib_cmdqmsg {
+	struct cmdq_base	*req;
+	struct creq_base	*resp;
+	void			*sb;
+	u32			req_sz;
+	u32			res_sz;
+	u8			block;
+	u8			qp_state;
+};
+
+static inline void bnxt_qplib_fill_cmdqmsg(struct bnxt_qplib_cmdqmsg *msg,
+					   void *req, void *resp, void *sb,
+					   u32 req_sz, u32 res_sz, u8 block)
+{
+	msg->req = req;
+	msg->resp = resp;
+	msg->sb = sb;
+	msg->req_sz = req_sz;
+	msg->res_sz = res_sz;
+	msg->block = block;
+}
+
+void bnxt_qplib_free_rcfw_channel(struct bnxt_qplib_res *res);
+int bnxt_qplib_alloc_rcfw_channel(struct bnxt_qplib_res *res);
+void bnxt_qplib_rcfw_stop_irq(struct bnxt_qplib_rcfw *rcfw, bool kill);
+void bnxt_qplib_disable_rcfw_channel(struct bnxt_qplib_rcfw *rcfw);
+int bnxt_qplib_rcfw_start_irq(struct bnxt_qplib_rcfw *rcfw, int msix_vector,
+			      bool need_init);
+int bnxt_qplib_enable_rcfw_channel(struct bnxt_qplib_rcfw *rcfw,
+				   int msix_vector,
+				   int cp_bar_reg_off,
+				   aeq_handler_t aeq_handler);
+
+struct bnxt_qplib_rcfw_sbuf *bnxt_qplib_rcfw_alloc_sbuf(
+				struct bnxt_qplib_rcfw *rcfw,
+				u32 size);
+void bnxt_qplib_rcfw_free_sbuf(struct bnxt_qplib_rcfw *rcfw,
+				struct bnxt_qplib_rcfw_sbuf *sbuf);
+int bnxt_qplib_rcfw_send_message(struct bnxt_qplib_rcfw *rcfw,
+				 struct bnxt_qplib_cmdqmsg *msg);
+
+int bnxt_qplib_deinit_rcfw(struct bnxt_qplib_rcfw *rcfw);
+int bnxt_qplib_init_rcfw(struct bnxt_qplib_rcfw *rcfw, int is_virtfn);
+void bnxt_qplib_mark_qp_error(void *qp_handle);
+int __check_cmdq_stall(struct bnxt_qplib_rcfw *rcfw,
+			u32 *cur_prod, u32 *cur_cons);
+#endif
diff --git a/sys/dev/bnxt/bnxt_re/qplib_res.c b/sys/dev/bnxt/bnxt_re/qplib_res.c
new file mode 100644
index 000000000000..69661c67708c
--- /dev/null
+++ b/sys/dev/bnxt/bnxt_re/qplib_res.c
@@ -0,0 +1,1226 @@
+/*
+ * Copyright (c) 2015-2024, Broadcom. All rights reserved.  The term
+ * Broadcom refers to Broadcom Limited and/or its subsidiaries.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Description: QPLib resource manager
+ */
+
+#include <linux/spinlock.h>
+#include <linux/pci.h>
+#include <linux/interrupt.h>
+#include <linux/inetdevice.h>
+#include <linux/dma-mapping.h>
+#include <linux/if_vlan.h>
+#include <linux/vmalloc.h>
+
+#include <net/ipv6.h>
+#include <rdma/ib_verbs.h>
+
+#include "hsi_struct_def.h"
+#include "qplib_res.h"
+#include "qplib_sp.h"
+#include "qplib_rcfw.h"
+#include "bnxt.h"
+#include "bnxt_ulp.h"
+
+uint8_t _get_chip_gen_p5_type(struct bnxt_qplib_chip_ctx *cctx)
+{
+       /* Extend this for granular type */
+	return(BNXT_RE_DEFAULT);
+}
+
+inline bool _is_alloc_mr_unified(struct bnxt_qplib_dev_attr *dattr)
+{
+	return dattr->dev_cap_flags &
+	       CREQ_QUERY_FUNC_RESP_SB_MR_REGISTER_ALLOC;
+}
+
+/* PBL */
+static void __free_pbl(struct bnxt_qplib_res *res,
+		       struct bnxt_qplib_pbl *pbl, bool is_umem)
+{
+	struct pci_dev *pdev;
+	int i;
+
+	pdev = res->pdev;
+	if (is_umem == false) {
+		for (i = 0; i < pbl->pg_count; i++) {
+			if (pbl->pg_arr[i]) {
+				dma_free_coherent(&pdev->dev, pbl->pg_size,
+					(void *)((u64)pbl->pg_arr[i] &
+						 PAGE_MASK),
+					pbl->pg_map_arr[i]);
+			}
+			else
+				dev_warn(&pdev->dev,
+					 "QPLIB: PBL free pg_arr[%d] empty?!\n",
+					 i);
+			pbl->pg_arr[i] = NULL;
+		}
+	}
+
+	if (pbl->pg_arr) {
+		vfree(pbl->pg_arr);
+		pbl->pg_arr = NULL;
+	}
+	if (pbl->pg_map_arr) {
+		vfree(pbl->pg_map_arr);
+		pbl->pg_map_arr = NULL;
+	}
+	pbl->pg_count = 0;
+	pbl->pg_size = 0;
+}
+
+struct qplib_sg {
+	dma_addr_t 	pg_map_arr;
+	u32		size;
+};
+
+static int __fill_user_dma_pages(struct bnxt_qplib_pbl *pbl,
+				 struct bnxt_qplib_sg_info *sginfo)
+{
+	int sg_indx, pg_indx, tmp_size, offset;
+	struct qplib_sg *tmp_sg = NULL;
+	struct scatterlist *sg;
+	u64 pmask, addr;
+
+	tmp_sg = vzalloc(sginfo->nmap * sizeof(struct qplib_sg));
+	if (!tmp_sg)
+		return -ENOMEM;
+
+	pmask = BIT_ULL(sginfo->pgshft) - 1;
+	sg_indx = 0;
+	for_each_sg(sginfo->sghead, sg, sginfo->nmap, sg_indx) {
+		tmp_sg[sg_indx].pg_map_arr = sg_dma_address(sg);
+		tmp_sg[sg_indx].size = sg_dma_len(sg);
+	}
+	pg_indx = 0;
+	for (sg_indx = 0; sg_indx < sginfo->nmap; sg_indx++) {
+		tmp_size = tmp_sg[sg_indx].size;
+		offset = 0;
+		while (tmp_size > 0) {
+			addr = tmp_sg[sg_indx].pg_map_arr + offset;
+			if ((!sg_indx && !pg_indx) || !(addr & pmask)) {
+				pbl->pg_map_arr[pg_indx] = addr &(~pmask);
+				pbl->pg_count++;
+				pg_indx++;
+			}
+			offset += sginfo->pgsize;
+			tmp_size -= sginfo->pgsize;
+		}
+	}
+
+	vfree(tmp_sg);
+	return 0;
+}
+
+static int bnxt_qplib_fill_user_dma_pages(struct bnxt_qplib_pbl *pbl,
+					  struct bnxt_qplib_sg_info *sginfo)
+{
+	int rc = 0;
+
+	rc =  __fill_user_dma_pages(pbl, sginfo);
+
+	return rc;
+}
+
+static int __alloc_pbl(struct bnxt_qplib_res *res, struct bnxt_qplib_pbl *pbl,
+		       struct bnxt_qplib_sg_info *sginfo)
+{
+	struct pci_dev *pdev;
+	bool is_umem = false;
+	int i;
+
+	if (sginfo->nopte)
+		return 0;
+
+	pdev = res->pdev;
+	/* page ptr arrays */
+	pbl->pg_arr = vmalloc(sginfo->npages * sizeof(void *));
+	if (!pbl->pg_arr)
+		return -ENOMEM;
+
+	pbl->pg_map_arr = vmalloc(sginfo->npages * sizeof(dma_addr_t));
+	if (!pbl->pg_map_arr) {
+		vfree(pbl->pg_arr);
+		return -ENOMEM;
+	}
+	pbl->pg_count = 0;
+	pbl->pg_size = sginfo->pgsize;
+	if (!sginfo->sghead) {
+		for (i = 0; i < sginfo->npages; i++) {
+			pbl->pg_arr[i] = dma_zalloc_coherent(&pdev->dev,
+							     pbl->pg_size,
+							     &pbl->pg_map_arr[i],
+							     GFP_KERNEL);
+			if (!pbl->pg_arr[i])
+				goto fail;
+			pbl->pg_count++;
+		}
+	} else {
+		is_umem = true;
+		if (bnxt_qplib_fill_user_dma_pages(pbl, sginfo))
+			goto fail;
+	}
+
+	return 0;
+fail:
+	__free_pbl(res, pbl, is_umem);
+	return -ENOMEM;
+}
+
+/* HWQ */
+void bnxt_qplib_free_hwq(struct bnxt_qplib_res *res,
+			 struct bnxt_qplib_hwq *hwq)
+{
+	int i;
+
+	if (!hwq->max_elements)
+		return;
+	if (hwq->level >= PBL_LVL_MAX)
+		return;
+
+	for (i = 0; i < hwq->level + 1; i++) {
+		if (i == hwq->level)
+			__free_pbl(res, &hwq->pbl[i], hwq->is_user);
+		else
+			__free_pbl(res, &hwq->pbl[i], false);
+	}
+
+	hwq->level = PBL_LVL_MAX;
+	hwq->max_elements = 0;
+	hwq->element_size = 0;
+	hwq->prod = hwq->cons = 0;
+	hwq->cp_bit = 0;
+}
+
+/* All HWQs are power of 2 in size */
+int bnxt_qplib_alloc_init_hwq(struct bnxt_qplib_hwq *hwq,
+			      struct bnxt_qplib_hwq_attr *hwq_attr)
+{
+	u32 npages = 0, depth, stride, aux_pages = 0;
+	dma_addr_t *src_phys_ptr, **dst_virt_ptr;
+	struct bnxt_qplib_sg_info sginfo = {};
+	u32 aux_size = 0, npbl, npde;
+	void *umem;
+	struct bnxt_qplib_res *res;
+	u32 aux_slots, pg_size;
+	struct pci_dev *pdev;
+	int i, rc, lvl;
+
+	res = hwq_attr->res;
+	pdev = res->pdev;
+	umem = hwq_attr->sginfo->sghead;
+	pg_size = hwq_attr->sginfo->pgsize;
+	hwq->level = PBL_LVL_MAX;
+
+	depth = roundup_pow_of_two(hwq_attr->depth);
+	stride = roundup_pow_of_two(hwq_attr->stride);
+	if (hwq_attr->aux_depth) {
+		aux_slots = hwq_attr->aux_depth;
+		aux_size = roundup_pow_of_two(hwq_attr->aux_stride);
+		aux_pages = (aux_slots * aux_size) / pg_size;
+		if ((aux_slots * aux_size) % pg_size)
+			aux_pages++;
+	}
+
+	if (!umem) {
+		hwq->is_user = false;
+		npages = (depth * stride) / pg_size + aux_pages;
+		if ((depth * stride) % pg_size)
+			npages++;
+		if (!npages)
+			return -EINVAL;
+		hwq_attr->sginfo->npages = npages;
+	} else {
+		hwq->is_user = true;
+		npages = hwq_attr->sginfo->npages;
+		npages = (npages * (u64)pg_size) /
+			  BIT_ULL(hwq_attr->sginfo->pgshft);
+		if ((hwq_attr->sginfo->npages * (u64)pg_size) %
+		     BIT_ULL(hwq_attr->sginfo->pgshft))
+			npages++;
+	}
+	if (npages == MAX_PBL_LVL_0_PGS && !hwq_attr->sginfo->nopte) {
+		/* This request is Level 0, map PTE */
+		rc = __alloc_pbl(res, &hwq->pbl[PBL_LVL_0], hwq_attr->sginfo);
+		if (rc)
+			goto fail;
+		hwq->level = PBL_LVL_0;
+		goto done;
+	}
+
+	if (npages >= MAX_PBL_LVL_0_PGS) {
+		if (npages > MAX_PBL_LVL_1_PGS) {
+			u32 flag = (hwq_attr->type == HWQ_TYPE_L2_CMPL) ?
+				    0 : PTU_PTE_VALID;
+			/* 2 levels of indirection */
+			npbl = npages >> MAX_PBL_LVL_1_PGS_SHIFT;
+			if (npages % BIT(MAX_PBL_LVL_1_PGS_SHIFT))
+				npbl++;
+			npde = npbl >> MAX_PDL_LVL_SHIFT;
+			if(npbl % BIT(MAX_PDL_LVL_SHIFT))
+				npde++;
+			/* Alloc PDE pages */
+			sginfo.pgsize = npde * PAGE_SIZE;
+			sginfo.npages = 1;
+			rc = __alloc_pbl(res, &hwq->pbl[PBL_LVL_0], &sginfo);
+
+			/* Alloc PBL pages */
+			sginfo.npages = npbl;
+			sginfo.pgsize = PAGE_SIZE;
+			rc = __alloc_pbl(res, &hwq->pbl[PBL_LVL_1], &sginfo);
+			if (rc)
+				goto fail;
+			/* Fill PDL with PBL page pointers */
+			dst_virt_ptr =
+				(dma_addr_t **)hwq->pbl[PBL_LVL_0].pg_arr;
+			src_phys_ptr = hwq->pbl[PBL_LVL_1].pg_map_arr;
+			if (hwq_attr->type == HWQ_TYPE_MR) {
+			/* For MR it is expected that we supply only 1 contigous
+			 * page i.e only 1 entry in the PDL that will contain
+			 * all the PBLs for the user supplied memory region
+			 */
+				for (i = 0; i < hwq->pbl[PBL_LVL_1].pg_count; i++)
+					dst_virt_ptr[0][i] = src_phys_ptr[i] |
+						flag;
+			} else {
+				for (i = 0; i < hwq->pbl[PBL_LVL_1].pg_count; i++)
+					dst_virt_ptr[PTR_PG(i)][PTR_IDX(i)] =
+						src_phys_ptr[i] | PTU_PDE_VALID;
+			}
+			/* Alloc or init PTEs */
+			rc = __alloc_pbl(res, &hwq->pbl[PBL_LVL_2],
+					 hwq_attr->sginfo);
+			if (rc)
+				goto fail;
+			hwq->level = PBL_LVL_2;
+			if (hwq_attr->sginfo->nopte)
+				goto done;
+			/* Fill PBLs with PTE pointers */
+			dst_virt_ptr =
+				(dma_addr_t **)hwq->pbl[PBL_LVL_1].pg_arr;
+			src_phys_ptr = hwq->pbl[PBL_LVL_2].pg_map_arr;
+			for (i = 0; i < hwq->pbl[PBL_LVL_2].pg_count; i++) {
+				dst_virt_ptr[PTR_PG(i)][PTR_IDX(i)] =
+					src_phys_ptr[i] | PTU_PTE_VALID;
+			}
+			if (hwq_attr->type == HWQ_TYPE_QUEUE) {
+				/* Find the last pg of the size */
+				i = hwq->pbl[PBL_LVL_2].pg_count;
+				dst_virt_ptr[PTR_PG(i - 1)][PTR_IDX(i - 1)] |=
+								  PTU_PTE_LAST;
+				if (i > 1)
+					dst_virt_ptr[PTR_PG(i - 2)]
+						    [PTR_IDX(i - 2)] |=
+						    PTU_PTE_NEXT_TO_LAST;
+			}
+		} else { /* pages < 512 npbl = 1, npde = 0 */
+			u32 flag = (hwq_attr->type == HWQ_TYPE_L2_CMPL) ?
+				    0 : PTU_PTE_VALID;
+
+			/* 1 level of indirection */
+			npbl = npages >> MAX_PBL_LVL_1_PGS_SHIFT;
+			if (npages % BIT(MAX_PBL_LVL_1_PGS_SHIFT))
+				npbl++;
+			sginfo.npages = npbl;
+			sginfo.pgsize = PAGE_SIZE;
+			/* Alloc PBL page */
+			rc = __alloc_pbl(res, &hwq->pbl[PBL_LVL_0], &sginfo);
+			if (rc)
+				goto fail;
+			/* Alloc or init  PTEs */
+			rc = __alloc_pbl(res, &hwq->pbl[PBL_LVL_1],
+					 hwq_attr->sginfo);
+			if (rc)
+				goto fail;
+			hwq->level = PBL_LVL_1;
+			if (hwq_attr->sginfo->nopte)
+				goto done;
+			/* Fill PBL with PTE pointers */
+			dst_virt_ptr =
+				(dma_addr_t **)hwq->pbl[PBL_LVL_0].pg_arr;
+			src_phys_ptr = hwq->pbl[PBL_LVL_1].pg_map_arr;
+			for (i = 0; i < hwq->pbl[PBL_LVL_1].pg_count; i++)
+				dst_virt_ptr[PTR_PG(i)][PTR_IDX(i)] =
+					src_phys_ptr[i] | flag;
+			if (hwq_attr->type == HWQ_TYPE_QUEUE) {
+				/* Find the last pg of the size */
+				i = hwq->pbl[PBL_LVL_1].pg_count;
+				dst_virt_ptr[PTR_PG(i - 1)][PTR_IDX(i - 1)] |=
+								  PTU_PTE_LAST;
+				if (i > 1)
+					dst_virt_ptr[PTR_PG(i - 2)]
+						    [PTR_IDX(i - 2)] |=
+						    PTU_PTE_NEXT_TO_LAST;
+			}
+		}
+	}
+done:
+	hwq->prod = 0;
+	hwq->cons = 0;
+	hwq->pdev = pdev;
+	hwq->depth = hwq_attr->depth;
+	hwq->max_elements = depth;
+	hwq->element_size = stride;
+	hwq->qe_ppg = (pg_size/stride);
+
+	if (hwq->level >= PBL_LVL_MAX)
+		goto fail;
+	/* For direct access to the elements */
+	lvl = hwq->level;
+	if (hwq_attr->sginfo->nopte && hwq->level)
+		lvl = hwq->level - 1;
+	hwq->pbl_ptr = hwq->pbl[lvl].pg_arr;
+	hwq->pbl_dma_ptr = hwq->pbl[lvl].pg_map_arr;
+	spin_lock_init(&hwq->lock);
+
+	return 0;
+fail:
+	bnxt_qplib_free_hwq(res, hwq);
+	return -ENOMEM;
+}
+
+/* Context Tables */
+void bnxt_qplib_free_hwctx(struct bnxt_qplib_res *res)
+{
+	struct bnxt_qplib_ctx *hctx;
+	int i;
+
+	hctx = res->hctx;
+	bnxt_qplib_free_hwq(res, &hctx->qp_ctx.hwq);
+	bnxt_qplib_free_hwq(res, &hctx->mrw_ctx.hwq);
+	bnxt_qplib_free_hwq(res, &hctx->srq_ctx.hwq);
+	bnxt_qplib_free_hwq(res, &hctx->cq_ctx.hwq);
+	bnxt_qplib_free_hwq(res, &hctx->tim_ctx.hwq);
+	for (i = 0; i < MAX_TQM_ALLOC_REQ; i++)
+		bnxt_qplib_free_hwq(res, &hctx->tqm_ctx.qtbl[i]);
+	/* restor original pde level before destroy */
+	hctx->tqm_ctx.pde.level = hctx->tqm_ctx.pde_level;
+	bnxt_qplib_free_hwq(res, &hctx->tqm_ctx.pde);
+}
+
+static int bnxt_qplib_alloc_tqm_rings(struct bnxt_qplib_res *res,
+				      struct bnxt_qplib_ctx *hctx)
+{
+	struct bnxt_qplib_hwq_attr hwq_attr = {};
+	struct bnxt_qplib_sg_info sginfo = {};
+	struct bnxt_qplib_tqm_ctx *tqmctx;
+	int rc = 0;
+	int i;
+
+	tqmctx = &hctx->tqm_ctx;
+
+	sginfo.pgsize = PAGE_SIZE;
+	sginfo.pgshft = PAGE_SHIFT;
+	hwq_attr.sginfo = &sginfo;
+	hwq_attr.res = res;
+	hwq_attr.type = HWQ_TYPE_CTX;
+	hwq_attr.depth = 512;
+	hwq_attr.stride = sizeof(u64);
+	/* Alloc pdl buffer */
+	rc = bnxt_qplib_alloc_init_hwq(&tqmctx->pde, &hwq_attr);
+	if (rc)
+		goto out;
+	/* Save original pdl level */
+	tqmctx->pde_level = tqmctx->pde.level;
+
+	hwq_attr.stride = 1;
+	for (i = 0; i < MAX_TQM_ALLOC_REQ; i++) {
+		if (!tqmctx->qcount[i])
+			continue;
+		hwq_attr.depth = hctx->qp_ctx.max * tqmctx->qcount[i];
+		rc = bnxt_qplib_alloc_init_hwq(&tqmctx->qtbl[i], &hwq_attr);
+		if (rc)
+			goto out;
+	}
+out:
+	return rc;
+}
+
+static void bnxt_qplib_map_tqm_pgtbl(struct bnxt_qplib_tqm_ctx *ctx)
+{
+	struct bnxt_qplib_hwq *qtbl_hwq;
+	dma_addr_t *dma_ptr;
+	__le64 **pbl_ptr, *ptr;
+	int i, j, k;
+	int fnz_idx = -1;
+	int pg_count;
+
+	pbl_ptr = (__le64 **)ctx->pde.pbl_ptr;
+
+	for (i = 0, j = 0; i < MAX_TQM_ALLOC_REQ;
+	     i++, j += MAX_TQM_ALLOC_BLK_SIZE) {
+		qtbl_hwq = &ctx->qtbl[i];
+		if (!qtbl_hwq->max_elements)
+			continue;
+		if (fnz_idx == -1)
+			fnz_idx = i; /* first non-zero index */
+		switch (qtbl_hwq->level) {
+			case PBL_LVL_2:
+			pg_count = qtbl_hwq->pbl[PBL_LVL_1].pg_count;
+			for (k = 0; k < pg_count; k++) {
+				ptr = &pbl_ptr[PTR_PG(j + k)][PTR_IDX(j + k)];
+				dma_ptr = &qtbl_hwq->pbl[PBL_LVL_1].pg_map_arr[k];
+				*ptr = cpu_to_le64(*dma_ptr | PTU_PTE_VALID);
+			}
+			break;
+			case PBL_LVL_1:
+			case PBL_LVL_0:
+			default:
+			ptr = &pbl_ptr[PTR_PG(j)][PTR_IDX(j)];
+			*ptr = cpu_to_le64(qtbl_hwq->pbl[PBL_LVL_0].pg_map_arr[0] |
+					   PTU_PTE_VALID);
+			break;
+		}
+	}
+	if (fnz_idx == -1)
+		fnz_idx = 0;
+	/* update pde level as per page table programming */
+	ctx->pde.level = (ctx->qtbl[fnz_idx].level == PBL_LVL_2) ? PBL_LVL_2 :
+			  ctx->qtbl[fnz_idx].level + 1;
+}
+
+static int bnxt_qplib_setup_tqm_rings(struct bnxt_qplib_res *res,
+				      struct bnxt_qplib_ctx *hctx)
+{
+	int rc = 0;
+
+	rc = bnxt_qplib_alloc_tqm_rings(res, hctx);
+	if (rc)
+		goto fail;
+
+	bnxt_qplib_map_tqm_pgtbl(&hctx->tqm_ctx);
+fail:
+	return rc;
+}
+
+/*
+ * Routine: bnxt_qplib_alloc_hwctx
+ * Description:
+ *     Context tables are memories which are used by the chip.
+ *     The 6 tables defined are:
+ *             QPC ctx - holds QP states
+ *             MRW ctx - holds memory region and window
+ *             SRQ ctx - holds shared RQ states
+ *             CQ ctx - holds completion queue states
+ *             TQM ctx - holds Tx Queue Manager context
+ *             TIM ctx - holds timer context
+ *     Depending on the size of the tbl requested, either a 1 Page Buffer List
+ *     or a 1-to-2-stage indirection Page Directory List + 1 PBL is used
+ *     instead.
+ *     Table might be employed as follows:
+ *             For 0      < ctx size <= 1 PAGE, 0 level of ind is used
+ *             For 1 PAGE < ctx size <= 512 entries size, 1 level of ind is used
+ *             For 512    < ctx size <= MAX, 2 levels of ind is used
+ * Returns:
+ *     0 if success, else -ERRORS
+ */
+int bnxt_qplib_alloc_hwctx(struct bnxt_qplib_res *res)
+{
+	struct bnxt_qplib_hwq_attr hwq_attr = {};
+	struct bnxt_qplib_sg_info sginfo = {};
+	struct bnxt_qplib_ctx *hctx;
+	struct bnxt_qplib_hwq *hwq;
+	int rc = 0;
+
+	hctx = res->hctx;
+	/* QPC Tables */
+	sginfo.pgsize = PAGE_SIZE;
+	sginfo.pgshft = PAGE_SHIFT;
+	hwq_attr.sginfo = &sginfo;
+
+	hwq_attr.res = res;
+	hwq_attr.depth = hctx->qp_ctx.max;
+	hwq_attr.stride = BNXT_QPLIB_MAX_QP_CTX_ENTRY_SIZE;
+	hwq_attr.type = HWQ_TYPE_CTX;
+	hwq = &hctx->qp_ctx.hwq;
+	rc = bnxt_qplib_alloc_init_hwq(hwq, &hwq_attr);
+	if (rc)
+		goto fail;
+
+	/* MRW Tables */
+	hwq_attr.depth = hctx->mrw_ctx.max;
+	hwq_attr.stride = BNXT_QPLIB_MAX_MRW_CTX_ENTRY_SIZE;
+	hwq = &hctx->mrw_ctx.hwq;
+	rc = bnxt_qplib_alloc_init_hwq(hwq, &hwq_attr);
+	if (rc)
+		goto fail;
+
+	/* SRQ Tables */
+	hwq_attr.depth = hctx->srq_ctx.max;
+	hwq_attr.stride = BNXT_QPLIB_MAX_SRQ_CTX_ENTRY_SIZE;
+	hwq = &hctx->srq_ctx.hwq;
+	rc = bnxt_qplib_alloc_init_hwq(hwq, &hwq_attr);
+	if (rc)
+		goto fail;
+
+	/* CQ Tables */
+	hwq_attr.depth = hctx->cq_ctx.max;
+	hwq_attr.stride = BNXT_QPLIB_MAX_CQ_CTX_ENTRY_SIZE;
+	hwq = &hctx->cq_ctx.hwq;
+	rc = bnxt_qplib_alloc_init_hwq(hwq, &hwq_attr);
+	if (rc)
+		goto fail;
+
+	/* TQM Buffer */
+	rc = bnxt_qplib_setup_tqm_rings(res, hctx);
+	if (rc)
+		goto fail;
+	/* TIM Buffer */
+	hwq_attr.depth = hctx->qp_ctx.max * 16;
+	hwq_attr.stride = 1;
+	hwq = &hctx->tim_ctx.hwq;
+	rc = bnxt_qplib_alloc_init_hwq(hwq, &hwq_attr);
+	if (rc)
+		goto fail;
+
+	return 0;
+fail:
+	bnxt_qplib_free_hwctx(res);
+	return rc;
+}
+
+/* GUID */
+void bnxt_qplib_get_guid(const u8 *dev_addr, u8 *guid)
+{
+	u8 mac[ETH_ALEN];
+
+	/* MAC-48 to EUI-64 mapping */
+	memcpy(mac, dev_addr, ETH_ALEN);
+	guid[0] = mac[0] ^ 2;
+	guid[1] = mac[1];
+	guid[2] = mac[2];
+	guid[3] = 0xff;
+	guid[4] = 0xfe;
+	guid[5] = mac[3];
+	guid[6] = mac[4];
+	guid[7] = mac[5];
+}
+
+static void bnxt_qplib_free_sgid_tbl(struct bnxt_qplib_res *res)
+{
+	struct bnxt_qplib_sgid_tbl *sgid_tbl;
+
+	sgid_tbl = &res->sgid_tbl;
+
+	if (sgid_tbl->tbl) {
+		kfree(sgid_tbl->tbl);
+		sgid_tbl->tbl = NULL;
+		kfree(sgid_tbl->hw_id);
+		sgid_tbl->hw_id = NULL;
+		kfree(sgid_tbl->ctx);
+		sgid_tbl->ctx = NULL;
+		kfree(sgid_tbl->vlan);
+		sgid_tbl->vlan = NULL;
+	} else {
+		dev_dbg(&res->pdev->dev, "QPLIB: SGID tbl not present");
+	}
+	sgid_tbl->max = 0;
+	sgid_tbl->active = 0;
+}
+
+static void bnxt_qplib_free_reftbls(struct bnxt_qplib_res *res)
+{
+	struct bnxt_qplib_reftbl *tbl;
+
+	tbl = &res->reftbl.srqref;
+	vfree(tbl->rec);
+
+	tbl = &res->reftbl.cqref;
+	vfree(tbl->rec);
+
+	tbl = &res->reftbl.qpref;
+	vfree(tbl->rec);
+}
+
+static int bnxt_qplib_alloc_reftbl(struct bnxt_qplib_reftbl *tbl, u32 max)
+{
+	tbl->max = max;
+	tbl->rec = vzalloc(sizeof(*tbl->rec) * max);
+	if (!tbl->rec)
+		return -ENOMEM;
+	spin_lock_init(&tbl->lock);
+	return 0;
+}
+
+static int bnxt_qplib_alloc_reftbls(struct bnxt_qplib_res *res,
+				    struct bnxt_qplib_dev_attr *dattr)
+{
+	u32 max_cq = BNXT_QPLIB_MAX_CQ_COUNT;
+	struct bnxt_qplib_reftbl *tbl;
+	u32 res_cnt;
+	int rc;
+
+	/*
+	 * Allocating one extra entry  to hold QP1 info.
+	 * Store QP1 info at the last entry of the table.
+	 * Decrement the tbl->max by one so that modulo
+	 * operation to get the qp table index from qp id
+	 * returns any value between 0 and max_qp-1
+	 */
+	res_cnt = max_t(u32, BNXT_QPLIB_MAX_QPC_COUNT + 1, dattr->max_qp);
+	tbl = &res->reftbl.qpref;
+	rc = bnxt_qplib_alloc_reftbl(tbl, res_cnt);
+	if (rc)
+		goto fail;
+	tbl->max--;
+
+	if (_is_chip_gen_p5_p7(res->cctx))
+		max_cq = BNXT_QPLIB_MAX_CQ_COUNT_P5;
+	res_cnt = max_t(u32, max_cq, dattr->max_cq);
+	tbl = &res->reftbl.cqref;
+	rc = bnxt_qplib_alloc_reftbl(tbl, res_cnt);
+	if (rc)
+		goto fail;
+
+	res_cnt = max_t(u32, BNXT_QPLIB_MAX_SRQC_COUNT, dattr->max_cq);
+	tbl = &res->reftbl.srqref;
+	rc = bnxt_qplib_alloc_reftbl(tbl, BNXT_QPLIB_MAX_SRQC_COUNT);
+	if (rc)
+		goto fail;
+
+	return 0;
+fail:
+	return rc;
+}
+
+static int bnxt_qplib_alloc_sgid_tbl(struct bnxt_qplib_res *res, u16 max)
+{
+	struct bnxt_qplib_sgid_tbl *sgid_tbl;
+
+	sgid_tbl = &res->sgid_tbl;
+
+	sgid_tbl->tbl = kcalloc(max, sizeof(*sgid_tbl->tbl), GFP_KERNEL);
+	if (!sgid_tbl->tbl)
+		return -ENOMEM;
+
+	sgid_tbl->hw_id = kcalloc(max, sizeof(u32), GFP_KERNEL);
+	if (!sgid_tbl->hw_id)
+		goto free_tbl;
+
+	sgid_tbl->ctx = kcalloc(max, sizeof(void *), GFP_KERNEL);
+	if (!sgid_tbl->ctx)
+		goto free_hw_id;
+
+	sgid_tbl->vlan = kcalloc(max, sizeof(u8), GFP_KERNEL);
+	if (!sgid_tbl->vlan)
+		goto free_ctx;
+
+	sgid_tbl->max = max;
+	return 0;
+free_ctx:
+	kfree(sgid_tbl->ctx);
+free_hw_id:
+	kfree(sgid_tbl->hw_id);
+free_tbl:
+	kfree(sgid_tbl->tbl);
+	return -ENOMEM;
+};
+
+static void bnxt_qplib_cleanup_sgid_tbl(struct bnxt_qplib_res *res,
+					struct bnxt_qplib_sgid_tbl *sgid_tbl)
+{
+	int i;
+
+	for (i = 0; i < sgid_tbl->max; i++) {
+		if (memcmp(&sgid_tbl->tbl[i], &bnxt_qplib_gid_zero,
+			   sizeof(bnxt_qplib_gid_zero)))
+			bnxt_qplib_del_sgid(sgid_tbl, &sgid_tbl->tbl[i].gid,
+					    sgid_tbl->tbl[i].vlan_id, true);
+	}
+	memset(sgid_tbl->tbl, 0, sizeof(*sgid_tbl->tbl) * sgid_tbl->max);
+	memset(sgid_tbl->hw_id, -1, sizeof(u16) * sgid_tbl->max);
+	memset(sgid_tbl->vlan, 0, sizeof(u8) * sgid_tbl->max);
+	sgid_tbl->active = 0;
+}
+
+static void bnxt_qplib_init_sgid_tbl(struct bnxt_qplib_sgid_tbl *sgid_tbl,
+				     struct ifnet *netdev)
+{
+	u32 i;
+
+	for (i = 0; i < sgid_tbl->max; i++)
+		sgid_tbl->tbl[i].vlan_id = 0xffff;
+	memset(sgid_tbl->hw_id, -1, sizeof(u16) * sgid_tbl->max);
+}
+
+/* PDs */
+int bnxt_qplib_alloc_pd(struct bnxt_qplib_res *res, struct bnxt_qplib_pd *pd)
+{
+	u32 bit_num;
+	int rc = 0;
+	struct bnxt_qplib_pd_tbl *pdt = &res->pd_tbl;
+
+	mutex_lock(&res->pd_tbl_lock);
+	bit_num = find_first_bit(pdt->tbl, pdt->max);
+	if (bit_num == pdt->max - 1) {/* Last bit is reserved */
+		rc = -ENOMEM;
+		goto fail;
+	}
+
+	/* Found unused PD */
+	clear_bit(bit_num, pdt->tbl);
+	pd->id = bit_num;
+fail:
+	mutex_unlock(&res->pd_tbl_lock);
+	return rc;
+}
+
+int bnxt_qplib_dealloc_pd(struct bnxt_qplib_res *res,
+			  struct bnxt_qplib_pd_tbl *pdt,
+			  struct bnxt_qplib_pd *pd)
+{
+	mutex_lock(&res->pd_tbl_lock);
+	if (test_and_set_bit(pd->id, pdt->tbl)) {
+		dev_warn(&res->pdev->dev, "Freeing an unused PD? pdn = %d\n",
+			 pd->id);
+		mutex_unlock(&res->pd_tbl_lock);
+		return -EINVAL;
+	}
+	/* Reset to reserved pdid. */
+	pd->id = pdt->max - 1;
+
+	mutex_unlock(&res->pd_tbl_lock);
+	return 0;
+}
+
+static void bnxt_qplib_free_pd_tbl(struct bnxt_qplib_pd_tbl *pdt)
+{
+	if (pdt->tbl) {
+		kfree(pdt->tbl);
+		pdt->tbl = NULL;
+	}
+	pdt->max = 0;
+}
+
+static int bnxt_qplib_alloc_pd_tbl(struct bnxt_qplib_res *res, u32 max)
+{
+	struct bnxt_qplib_pd_tbl *pdt;
+	u32 bytes;
+
+	pdt = &res->pd_tbl;
+
+	max++; /* One extra for reserved pdid. */
+	bytes = DIV_ROUND_UP(max, 8);
+
+	if (!bytes)
+		bytes = 1;
+	pdt->tbl = kmalloc(bytes, GFP_KERNEL);
+	if (!pdt->tbl) {
+		dev_err(&res->pdev->dev,
+			"QPLIB: PD tbl allocation failed for size = %d\n", bytes);
+		return -ENOMEM;
+	}
+	pdt->max = max;
+	memset((u8 *)pdt->tbl, 0xFF, bytes);
+	mutex_init(&res->pd_tbl_lock);
+
+	return 0;
+}
+
+/* DPIs */
+int bnxt_qplib_alloc_dpi(struct bnxt_qplib_res	*res,
+			 struct bnxt_qplib_dpi	*dpi,
+			 void *app, u8 type)
+{
+	struct bnxt_qplib_dpi_tbl *dpit = &res->dpi_tbl;
+	struct bnxt_qplib_reg_desc *reg;
+	u32 bit_num;
+	u64 umaddr;
+	int rc = 0;
+
+	reg = &dpit->wcreg;
+	mutex_lock(&res->dpi_tbl_lock);
+	if (type == BNXT_QPLIB_DPI_TYPE_WC && _is_chip_p7(res->cctx) &&
+	    !dpit->avail_ppp) {
+		rc = -ENOMEM;
+		goto fail;
+	}
+	bit_num = find_first_bit(dpit->tbl, dpit->max);
+	if (bit_num == dpit->max) {
+		rc = -ENOMEM;
+		goto fail;
+	}
+	/* Found unused DPI */
+	clear_bit(bit_num, dpit->tbl);
+	dpit->app_tbl[bit_num] = app;
+	dpi->bit = bit_num;
+	dpi->dpi = bit_num + (reg->offset - dpit->ucreg.offset) / PAGE_SIZE;
+
+	umaddr = reg->bar_base + reg->offset + bit_num * PAGE_SIZE;
+	dpi->umdbr = umaddr;
+	switch (type) {
+	case BNXT_QPLIB_DPI_TYPE_KERNEL:
+		/* priviledged dbr was already mapped just initialize it. */
+		dpi->umdbr = dpit->ucreg.bar_base +
+			     dpit->ucreg.offset + bit_num * PAGE_SIZE;
+		dpi->dbr = dpit->priv_db;
+		dpi->dpi = dpi->bit;
+		break;
+	case BNXT_QPLIB_DPI_TYPE_WC:
+		dpi->dbr = ioremap_wc(umaddr, PAGE_SIZE);
+		if (_is_chip_p7(res->cctx) && dpi->dbr)
+			dpit->avail_ppp--;
+		break;
+	default:
+		dpi->dbr = ioremap(umaddr, PAGE_SIZE);
+	}
+	if (!dpi->dbr) {
+		dev_err(&res->pdev->dev, "QPLIB: DB remap failed, type = %d\n",
+			type);
+		rc = -ENOMEM;
+	}
+	dpi->type = type;
+fail:
+	mutex_unlock(&res->dpi_tbl_lock);
+	return rc;
+}
+
+int bnxt_qplib_dealloc_dpi(struct bnxt_qplib_res *res,
+			   struct bnxt_qplib_dpi *dpi)
+{
+	struct bnxt_qplib_dpi_tbl *dpit = &res->dpi_tbl;
+	int rc = 0;
+
+	mutex_lock(&res->dpi_tbl_lock);
+	if (dpi->bit >= dpit->max) {
+		dev_warn(&res->pdev->dev,
+			 "Invalid DPI? dpi = %d, bit = %d\n",
+			 dpi->dpi, dpi->bit);
+		rc = -EINVAL;
+		goto fail;
+	}
+
+	if (dpi->dpi && dpi->type != BNXT_QPLIB_DPI_TYPE_KERNEL) {
+		if (dpi->type == BNXT_QPLIB_DPI_TYPE_WC &&
+		    _is_chip_p7(res->cctx) && dpi->dbr)
+			dpit->avail_ppp++;
+		pci_iounmap(res->pdev, dpi->dbr);
+	}
+
+	if (test_and_set_bit(dpi->bit, dpit->tbl)) {
+		dev_warn(&res->pdev->dev,
+			 "Freeing an unused DPI? dpi = %d, bit = %d\n",
+			 dpi->dpi, dpi->bit);
+		rc = -EINVAL;
+		goto fail;
+	}
+	if (dpit->app_tbl)
+		dpit->app_tbl[dpi->bit] = NULL;
+	memset(dpi, 0, sizeof(*dpi));
+fail:
+	mutex_unlock(&res->dpi_tbl_lock);
+	return rc;
+}
+
+static void bnxt_qplib_free_dpi_tbl(struct bnxt_qplib_dpi_tbl *dpit)
+{
+	kfree(dpit->tbl);
+	kfree(dpit->app_tbl);
+	dpit->tbl = NULL;
+	dpit->app_tbl = NULL;
+	dpit->max = 0;
+}
+
+static int bnxt_qplib_alloc_dpi_tbl(struct bnxt_qplib_res *res,
+				    struct bnxt_qplib_dev_attr *dev_attr,
+				    u8 pppp_factor)
+{
+	struct bnxt_qplib_dpi_tbl *dpit;
+	struct bnxt_qplib_reg_desc *reg;
+	unsigned long bar_len;
+	u32 dbr_offset;
+	u32 bytes;
+
+	dpit = &res->dpi_tbl;
+	reg = &dpit->wcreg;
+
+	if (!_is_chip_gen_p5_p7(res->cctx)) {
+		/* Offest should come from L2 driver */
+		dbr_offset = dev_attr->l2_db_size;
+		dpit->ucreg.offset = dbr_offset;
+		dpit->wcreg.offset = dbr_offset;
+	}
+
+	bar_len = pci_resource_len(res->pdev, reg->bar_id);
+	dpit->max = (bar_len - reg->offset) / PAGE_SIZE;
+	if (dev_attr->max_dpi)
+		dpit->max = min_t(u32, dpit->max, dev_attr->max_dpi);
+
+	dpit->app_tbl = kzalloc(dpit->max * sizeof(void*), GFP_KERNEL);
+	if (!dpit->app_tbl) {
+		dev_err(&res->pdev->dev,
+			"QPLIB: DPI app tbl allocation failed");
+		return -ENOMEM;
+	}
+
+	bytes = dpit->max >> 3;
+	if (!bytes)
+		bytes = 1;
+
+	dpit->tbl = kmalloc(bytes, GFP_KERNEL);
+	if (!dpit->tbl) {
+		kfree(dpit->app_tbl);
+		dev_err(&res->pdev->dev,
+			"QPLIB: DPI tbl allocation failed for size = %d\n",
+			bytes);
+		return -ENOMEM;
+	}
+
+	memset((u8 *)dpit->tbl, 0xFF, bytes);
+	/*
+	 * On SR2, 2nd doorbell page of each function
+	 * is reserved for L2 PPP. Now that the tbl is
+	 * initialized, mark it as unavailable. By default
+	 * RoCE can make use of the 512 extended pages for
+	 * PPP.
+	 */
+	if (_is_chip_p7(res->cctx)) {
+		clear_bit(1, dpit->tbl);
+		if (pppp_factor)
+			dpit->avail_ppp =
+				BNXT_QPLIB_MAX_EXTENDED_PPP_PAGES / pppp_factor;
+	}
+	mutex_init(&res->dpi_tbl_lock);
+	dpit->priv_db = dpit->ucreg.bar_reg + dpit->ucreg.offset;
+
+	return 0;
+}
+
+/* Stats */
+void bnxt_qplib_free_stat_mem(struct bnxt_qplib_res *res,
+			      struct bnxt_qplib_stats *stats)
+{
+	struct pci_dev *pdev;
+
+	pdev = res->pdev;
+	if (stats->dma)
+		dma_free_coherent(&pdev->dev, stats->size,
+				  stats->dma, stats->dma_map);
+
+	memset(stats, 0, sizeof(*stats));
+	stats->fw_id = -1;
+}
+
+int bnxt_qplib_alloc_stat_mem(struct pci_dev *pdev,
+			      struct bnxt_qplib_chip_ctx *cctx,
+			      struct bnxt_qplib_stats *stats)
+{
+	cctx->hw_stats_size = 168;
+
+	memset(stats, 0, sizeof(*stats));
+	stats->fw_id = -1;
+	stats->size = cctx->hw_stats_size;
+	stats->dma = dma_alloc_coherent(&pdev->dev, stats->size,
+					&stats->dma_map, GFP_KERNEL);
+	if (!stats->dma) {
+		dev_err(&pdev->dev, "QPLIB: Stats DMA allocation failed");
+		return -ENOMEM;
+	}
+	return 0;
+}
+
+/* Resource */
+int bnxt_qplib_stop_res(struct bnxt_qplib_res *res)
+{
+	struct bnxt_qplib_rcfw *rcfw = res->rcfw;
+	struct creq_stop_func_resp resp = {};
+	struct bnxt_qplib_cmdqmsg msg = {};
+	struct cmdq_stop_func req = {};
+	int rc;
+
+	bnxt_qplib_rcfw_cmd_prep(&req, CMDQ_BASE_OPCODE_STOP_FUNC,
+				 sizeof(req));
+	bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, NULL, sizeof(req),
+				sizeof(resp), 0);
+	rc = bnxt_qplib_rcfw_send_message(rcfw, &msg);
+	return rc;
+}
+
+void bnxt_qplib_clear_tbls(struct bnxt_qplib_res *res)
+{
+	bnxt_qplib_cleanup_sgid_tbl(res, &res->sgid_tbl);
+}
+
+int bnxt_qplib_init_tbls(struct bnxt_qplib_res *res)
+{
+	bnxt_qplib_init_sgid_tbl(&res->sgid_tbl, res->netdev);
+
+	return 0;
+}
+
+void bnxt_qplib_free_tbls(struct bnxt_qplib_res *res)
+{
+	bnxt_qplib_free_sgid_tbl(res);
+	bnxt_qplib_free_pd_tbl(&res->pd_tbl);
+	bnxt_qplib_free_dpi_tbl(&res->dpi_tbl);
+	bnxt_qplib_free_reftbls(res);
+}
+
+int bnxt_qplib_alloc_tbls(struct bnxt_qplib_res *res, u8 pppp_factor)
+{
+	struct bnxt_qplib_dev_attr *dev_attr;
+	int rc = 0;
+
+	dev_attr = res->dattr;
+
+	rc = bnxt_qplib_alloc_reftbls(res, dev_attr);
+	if (rc)
+		goto fail;
+
+	rc = bnxt_qplib_alloc_sgid_tbl(res, dev_attr->max_sgid);
+	if (rc)
+		goto fail;
+
+	rc = bnxt_qplib_alloc_pd_tbl(res, dev_attr->max_pd);
+	if (rc)
+		goto fail;
+
+	rc = bnxt_qplib_alloc_dpi_tbl(res, dev_attr, pppp_factor);
+	if (rc)
+		goto fail;
+
+	return 0;
+fail:
+	bnxt_qplib_free_tbls(res);
+	return rc;
+}
+
+void bnxt_qplib_unmap_db_bar(struct bnxt_qplib_res *res)
+{
+	struct bnxt_qplib_reg_desc *reg;
+
+	reg = &res->dpi_tbl.ucreg;
+	if (reg->bar_reg)
+		pci_iounmap(res->pdev, reg->bar_reg);
+	reg->bar_reg = NULL;
+	reg->bar_base = 0;
+	reg->len = 0;
+	reg->bar_id = 0; /* Zero? or ff */
+}
+
+int bnxt_qplib_map_db_bar(struct bnxt_qplib_res *res)
+{
+	struct bnxt_qplib_reg_desc *ucreg;
+	struct bnxt_qplib_reg_desc *wcreg;
+
+	wcreg = &res->dpi_tbl.wcreg;
+	wcreg->bar_id = RCFW_DBR_PCI_BAR_REGION;
+	if (!res || !res->pdev || !wcreg)
+		return -1;
+	wcreg->bar_base = pci_resource_start(res->pdev, wcreg->bar_id);
+	/* No need to set the wcreg->len here */
+
+	ucreg = &res->dpi_tbl.ucreg;
+	ucreg->bar_id = RCFW_DBR_PCI_BAR_REGION;
+	ucreg->bar_base = pci_resource_start(res->pdev, ucreg->bar_id);
+
+	ucreg->offset = 65536;
+
+	ucreg->len = ucreg->offset + PAGE_SIZE;
+
+	if (!ucreg->len || ((ucreg->len & (PAGE_SIZE - 1)) != 0)) {
+		dev_err(&res->pdev->dev, "QPLIB: invalid dbr length %d\n",
+			(int)ucreg->len);
+		return -EINVAL;
+	}
+	ucreg->bar_reg = ioremap(ucreg->bar_base, ucreg->len);
+	if (!ucreg->bar_reg) {
+		dev_err(&res->pdev->dev, "priviledged dpi map failed!\n");
+		return -ENOMEM;
+	}
+
+	return 0;
+}
+
+/**
+ * pci_enable_atomic_ops_to_root - enable AtomicOp requests to root port
+ * @dev: the PCI device
+ * @cap_mask: mask of desired AtomicOp sizes, including one or more of:
+ *	PCI_EXP_DEVCAP2_ATOMIC_COMP32
+ *	PCI_EXP_DEVCAP2_ATOMIC_COMP64
+ *	PCI_EXP_DEVCAP2_ATOMIC_COMP128
+ *
+ * Return 0 if all upstream bridges support AtomicOp routing, egress
+ * blocking is disabled on all upstream ports, and the root port supports
+ * the requested completion capabilities (32-bit, 64-bit and/or 128-bit
+ * AtomicOp completion), or negative otherwise.
+ */
+int pci_enable_atomic_ops_to_root(struct pci_dev *dev, u32 cap_mask)
+{
+	struct pci_bus *bus = dev->bus;
+	struct pci_dev *bridge;
+	u32 cap;
+
+	if (!pci_is_pcie(dev))
+		return -EINVAL;
+
+	/*
+	 * Per PCIe r4.0, sec 6.15, endpoints and root ports may be
+	 * AtomicOp requesters.  For now, we only support endpoints as
+	 * requesters and root ports as completers.  No endpoints as
+	 * completers, and no peer-to-peer.
+	 */
+
+	switch (pci_pcie_type(dev)) {
+	case PCI_EXP_TYPE_ENDPOINT:
+	case PCI_EXP_TYPE_LEG_END:
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	bridge = bus->self;
+
+	pcie_capability_read_dword(bridge, PCI_EXP_DEVCAP2, &cap);
+
+	switch (pci_pcie_type(bridge)) {
+	case PCI_EXP_TYPE_DOWNSTREAM:
+		if (!(cap & PCI_EXP_DEVCAP2_ATOMIC_ROUTE))
+			return -EINVAL;
+		break;
+
+	/* Ensure root port supports all the sizes we care about */
+	case PCI_EXP_TYPE_ROOT_PORT:
+		if ((cap & cap_mask) != cap_mask)
+			return -EINVAL;
+		break;
+	}
+	return 0;
+}
+
+int bnxt_qplib_enable_atomic_ops_to_root(struct pci_dev *dev)
+{
+	u16 ctl2;
+
+	if(pci_enable_atomic_ops_to_root(dev, PCI_EXP_DEVCAP2_ATOMIC_COMP32) &&
+	   pci_enable_atomic_ops_to_root(dev, PCI_EXP_DEVCAP2_ATOMIC_COMP64))
+		return -EOPNOTSUPP;
+
+	pcie_capability_read_word(dev, PCI_EXP_DEVCTL2, &ctl2);
+	return !(ctl2 & PCI_EXP_DEVCTL2_ATOMIC_REQ);
+}
diff --git a/sys/dev/bnxt/bnxt_re/qplib_res.h b/sys/dev/bnxt/bnxt_re/qplib_res.h
new file mode 100644
index 000000000000..6468207a49aa
--- /dev/null
+++ b/sys/dev/bnxt/bnxt_re/qplib_res.h
@@ -0,0 +1,840 @@
+/*
+ * Copyright (c) 2015-2024, Broadcom. All rights reserved.  The term
+ * Broadcom refers to Broadcom Limited and/or its subsidiaries.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Description: QPLib resource manager (header)
+ */
+
+#ifndef __BNXT_QPLIB_RES_H__
+#define __BNXT_QPLIB_RES_H__
+
+#include "hsi_struct_def.h"
+
+extern const struct bnxt_qplib_gid bnxt_qplib_gid_zero;
+
+#define CHIP_NUM_57508		0x1750
+#define CHIP_NUM_57504		0x1751
+#define CHIP_NUM_57502		0x1752
+#define CHIP_NUM_58818          0xd818
+#define CHIP_NUM_57608		0x1760
+
+#define BNXT_QPLIB_MAX_QPC_COUNT	(64 * 1024)
+#define BNXT_QPLIB_MAX_SRQC_COUNT	(64 * 1024)
+#define BNXT_QPLIB_MAX_CQ_COUNT		(64 * 1024)
+#define BNXT_QPLIB_MAX_CQ_COUNT_P5	(128 * 1024)
+
+#define BNXT_QPLIB_DBR_VALID (0x1UL << 26)
+#define BNXT_QPLIB_DBR_EPOCH_SHIFT   24
+#define BNXT_QPLIB_DBR_TOGGLE_SHIFT  25
+
+#define BNXT_QPLIB_DBR_PF_DB_OFFSET	0x10000
+#define BNXT_QPLIB_DBR_VF_DB_OFFSET	0x4000
+
+#define BNXT_QPLIB_DBR_KEY_INVALID	-1
+
+/* chip gen type */
+#define BNXT_RE_DEFAULT 0xf
+
+enum bnxt_qplib_wqe_mode {
+	BNXT_QPLIB_WQE_MODE_STATIC	= 0x00,
+	BNXT_QPLIB_WQE_MODE_VARIABLE	= 0x01,
+	BNXT_QPLIB_WQE_MODE_INVALID	= 0x02
+};
+
+#define BNXT_RE_PUSH_MODE_NONE	0
+#define BNXT_RE_PUSH_MODE_WCB	1
+#define BNXT_RE_PUSH_MODE_PPP	2
+#define BNXT_RE_PUSH_ENABLED(mode) ((mode) == BNXT_RE_PUSH_MODE_WCB ||\
+				    (mode) == BNXT_RE_PUSH_MODE_PPP)
+#define BNXT_RE_PPP_ENABLED(cctx) ((cctx)->modes.db_push_mode ==\
+				   BNXT_RE_PUSH_MODE_PPP)
+#define	PCI_EXP_DEVCAP2_ATOMIC_ROUTE	0x00000040 /* Atomic Op routing */
+#define	PCI_EXP_DEVCAP2_ATOMIC_COMP32	0x00000080 /* 32b AtomicOp completion */
+#define	PCI_EXP_DEVCAP2_ATOMIC_COMP64	0x00000100 /* 64b AtomicOp completion */
+#define	PCI_EXP_DEVCTL2_ATOMIC_EGRESS_BLOCK 0x0080 /* Block atomic egress */
+#define PCI_EXP_DEVCTL2_ATOMIC_REQ	0x0040	/* Set Atomic requests */
+
+int pci_enable_atomic_ops_to_root(struct pci_dev *dev, u32 cap_mask);
+
+struct bnxt_qplib_drv_modes {
+	u8	wqe_mode;
+	u8	te_bypass;
+	u8	db_push;
+	/* To control advanced cc params display in configfs */
+	u8	cc_pr_mode;
+	/* Other modes to follow here e.g. GSI QP mode */
+	u8	dbr_pacing;
+	u8	dbr_pacing_ext;
+	u8	dbr_drop_recov;
+	u8	dbr_primary_pf;
+	u8	dbr_pacing_v0;
+};
+
+struct bnxt_qplib_chip_ctx {
+	u16     chip_num;
+	u8      chip_rev;
+	u8      chip_metal;
+	u64	hwrm_intf_ver;
+	struct bnxt_qplib_drv_modes	modes;
+	u32	dbr_stat_db_fifo;
+	u32	dbr_aeq_arm_reg;
+	u32	dbr_throttling_reg;
+	u16	hw_stats_size;
+	u16	hwrm_cmd_max_timeout;
+};
+
+static inline bool _is_chip_num_p7(u16 chip_num)
+{
+	return (chip_num == CHIP_NUM_58818 ||
+		chip_num == CHIP_NUM_57608);
+}
+
+static inline bool _is_chip_p7(struct bnxt_qplib_chip_ctx *cctx)
+{
+	return _is_chip_num_p7(cctx->chip_num);
+}
+
+/* SR2 is Gen P5 */
+static inline bool _is_chip_gen_p5(struct bnxt_qplib_chip_ctx *cctx)
+{
+	return (cctx->chip_num == CHIP_NUM_57508 ||
+		cctx->chip_num == CHIP_NUM_57504 ||
+		cctx->chip_num == CHIP_NUM_57502);
+}
+
+static inline bool _is_chip_gen_p5_p7(struct bnxt_qplib_chip_ctx *cctx)
+{
+	return (_is_chip_gen_p5(cctx) || _is_chip_p7(cctx));
+}
+
+static inline bool _is_wqe_mode_variable(struct bnxt_qplib_chip_ctx *cctx)
+{
+	return cctx->modes.wqe_mode == BNXT_QPLIB_WQE_MODE_VARIABLE;
+}
+
+struct bnxt_qplib_db_pacing_data {
+	u32 do_pacing;
+	u32 pacing_th;
+	u32 dev_err_state;
+	u32 alarm_th;
+	u32 grc_reg_offset;
+	u32 fifo_max_depth;
+	u32 fifo_room_mask;
+	u8  fifo_room_shift;
+};
+
+static inline u8 bnxt_qplib_dbr_pacing_en(struct bnxt_qplib_chip_ctx *cctx)
+{
+	return cctx->modes.dbr_pacing;
+}
+
+static inline u8 bnxt_qplib_dbr_pacing_ext_en(struct bnxt_qplib_chip_ctx *cctx)
+{
+	return cctx->modes.dbr_pacing_ext;
+}
+
+static inline u8 bnxt_qplib_dbr_pacing_is_primary_pf(struct bnxt_qplib_chip_ctx *cctx)
+{
+	return cctx->modes.dbr_primary_pf;
+}
+
+static inline void bnxt_qplib_dbr_pacing_set_primary_pf
+		(struct bnxt_qplib_chip_ctx *cctx, u8 val)
+{
+	cctx->modes.dbr_primary_pf = val;
+}
+
+/* Defines for handling the HWRM version check */
+#define HWRM_VERSION_DEV_ATTR_MAX_DPI	0x1000A0000000D
+#define HWRM_VERSION_ROCE_STATS_FN_ID	0x1000A00000045
+
+#define PTR_CNT_PER_PG		(PAGE_SIZE / sizeof(void *))
+#define PTR_MAX_IDX_PER_PG	(PTR_CNT_PER_PG - 1)
+#define PTR_PG(x)		(((x) & ~PTR_MAX_IDX_PER_PG) / PTR_CNT_PER_PG)
+#define PTR_IDX(x)		((x) & PTR_MAX_IDX_PER_PG)
+
+#define HWQ_CMP(idx, hwq)	((idx) & ((hwq)->max_elements - 1))
+#define HWQ_FREE_SLOTS(hwq)	(hwq->max_elements - \
+				((HWQ_CMP(hwq->prod, hwq)\
+				- HWQ_CMP(hwq->cons, hwq))\
+				& (hwq->max_elements - 1)))
+enum bnxt_qplib_hwq_type {
+	HWQ_TYPE_CTX,
+	HWQ_TYPE_QUEUE,
+	HWQ_TYPE_L2_CMPL,
+	HWQ_TYPE_MR
+};
+
+#define MAX_PBL_LVL_0_PGS		1
+#define MAX_PBL_LVL_1_PGS		512
+#define MAX_PBL_LVL_1_PGS_SHIFT		9
+#define MAX_PDL_LVL_SHIFT		9
+
+enum bnxt_qplib_pbl_lvl {
+	PBL_LVL_0,
+	PBL_LVL_1,
+	PBL_LVL_2,
+	PBL_LVL_MAX
+};
+
+#define ROCE_PG_SIZE_4K		(4 * 1024)
+#define ROCE_PG_SIZE_8K		(8 * 1024)
+#define ROCE_PG_SIZE_64K	(64 * 1024)
+#define ROCE_PG_SIZE_2M		(2 * 1024 * 1024)
+#define ROCE_PG_SIZE_8M		(8 * 1024 * 1024)
+#define ROCE_PG_SIZE_1G		(1024 * 1024 * 1024)
+enum bnxt_qplib_hwrm_pg_size {
+	BNXT_QPLIB_HWRM_PG_SIZE_4K	= 0,
+	BNXT_QPLIB_HWRM_PG_SIZE_8K	= 1,
+	BNXT_QPLIB_HWRM_PG_SIZE_64K	= 2,
+	BNXT_QPLIB_HWRM_PG_SIZE_2M	= 3,
+	BNXT_QPLIB_HWRM_PG_SIZE_8M	= 4,
+	BNXT_QPLIB_HWRM_PG_SIZE_1G	= 5,
+};
+
+struct bnxt_qplib_reg_desc {
+	u8		bar_id;
+	resource_size_t	bar_base;
+	unsigned long	offset;
+	void __iomem	*bar_reg;
+	size_t		len;
+};
+
+struct bnxt_qplib_pbl {
+	u32				pg_count;
+	u32				pg_size;
+	void				**pg_arr;
+	dma_addr_t			*pg_map_arr;
+};
+
+struct bnxt_qplib_sg_info {
+	struct scatterlist              *sghead;
+	u32                             nmap;
+	u32                             npages;
+	u32				pgshft;
+	u32				pgsize;
+	bool				nopte;
+};
+
+struct bnxt_qplib_hwq_attr {
+	struct bnxt_qplib_res		*res;
+	struct bnxt_qplib_sg_info	*sginfo;
+	enum bnxt_qplib_hwq_type	type;
+	u32				depth;
+	u32				stride;
+	u32				aux_stride;
+	u32				aux_depth;
+};
+
+struct bnxt_qplib_hwq {
+	struct pci_dev			*pdev;
+	spinlock_t			lock;
+	struct bnxt_qplib_pbl		pbl[PBL_LVL_MAX];
+	enum bnxt_qplib_pbl_lvl		level;		/* 0, 1, or 2 */
+	void				**pbl_ptr;	/* ptr for easy access
+							   to the PBL entries */
+	dma_addr_t			*pbl_dma_ptr;	/* ptr for easy access
+							   to the dma_addr */
+	u32				max_elements;
+	u32				depth;	/* original requested depth */
+	u16				element_size;	/* Size of each entry */
+	u16				qe_ppg;		/* queue entry per page */
+
+	u32				prod;		/* raw */
+	u32				cons;		/* raw */
+	u8				cp_bit;
+	u8				is_user;
+	u64				*pad_pg;
+	u32				pad_stride;
+	u32				pad_pgofft;
+};
+
+struct bnxt_qplib_db_info {
+	void __iomem		*db;
+	void __iomem		*priv_db;
+	struct bnxt_qplib_hwq	*hwq;
+	struct bnxt_qplib_res   *res;
+	u32			xid;
+	u32			max_slot;
+	u32			flags;
+	u8			toggle;
+	spinlock_t		lock;
+	u64			shadow_key;
+	u64			shadow_key_arm_ena;
+	u32			seed; /* For DB pacing */
+};
+
+enum bnxt_qplib_db_info_flags_mask {
+	BNXT_QPLIB_FLAG_EPOCH_CONS_SHIFT	= 0x0UL,
+	BNXT_QPLIB_FLAG_EPOCH_PROD_SHIFT	= 0x1UL,
+	BNXT_QPLIB_FLAG_EPOCH_CONS_MASK		= 0x1UL,
+	BNXT_QPLIB_FLAG_EPOCH_PROD_MASK		= 0x2UL,
+};
+
+enum bnxt_qplib_db_epoch_flag_shift {
+	BNXT_QPLIB_DB_EPOCH_CONS_SHIFT	= BNXT_QPLIB_DBR_EPOCH_SHIFT,
+	BNXT_QPLIB_DB_EPOCH_PROD_SHIFT	= (BNXT_QPLIB_DBR_EPOCH_SHIFT - 1)
+};
+
+/* Tables */
+struct bnxt_qplib_pd_tbl {
+	unsigned long			*tbl;
+	u32				max;
+};
+
+struct bnxt_qplib_sgid_tbl {
+	struct bnxt_qplib_gid_info	*tbl;
+	u16				*hw_id;
+	u16				max;
+	u16				active;
+	void				*ctx;
+	bool                            *vlan;
+};
+
+enum {
+	BNXT_QPLIB_DPI_TYPE_KERNEL	= 0,
+	BNXT_QPLIB_DPI_TYPE_UC		= 1,
+	BNXT_QPLIB_DPI_TYPE_WC		= 2
+};
+
+struct bnxt_qplib_dpi {
+	u32				dpi;
+	u32				bit;
+	void __iomem			*dbr;
+	u64				umdbr;
+	u8				type;
+};
+
+#define BNXT_QPLIB_MAX_EXTENDED_PPP_PAGES	512
+struct bnxt_qplib_dpi_tbl {
+	void				**app_tbl;
+	unsigned long			*tbl;
+	u16				max;
+	u16				avail_ppp;
+	struct bnxt_qplib_reg_desc	ucreg; /* Hold entire DB bar. */
+	struct bnxt_qplib_reg_desc	wcreg;
+	void __iomem			*priv_db;
+};
+
+struct bnxt_qplib_stats {
+	dma_addr_t			dma_map;
+	void				*dma;
+	u32				size;
+	u32				fw_id;
+};
+
+struct bnxt_qplib_vf_res {
+	u32 max_qp;
+	u32 max_mrw;
+	u32 max_srq;
+	u32 max_cq;
+	u32 max_gid;
+};
+
+#define BNXT_QPLIB_MAX_QP_CTX_ENTRY_SIZE	448
+#define BNXT_QPLIB_MAX_SRQ_CTX_ENTRY_SIZE	64
+#define BNXT_QPLIB_MAX_CQ_CTX_ENTRY_SIZE	64
+#define BNXT_QPLIB_MAX_MRW_CTX_ENTRY_SIZE	128
+
+#define MAX_TQM_ALLOC_REQ		48
+#define MAX_TQM_ALLOC_BLK_SIZE		8
+struct bnxt_qplib_tqm_ctx {
+	struct bnxt_qplib_hwq		pde;
+	enum bnxt_qplib_pbl_lvl		pde_level; /* Original level */
+	struct bnxt_qplib_hwq		qtbl[MAX_TQM_ALLOC_REQ];
+	u8				qcount[MAX_TQM_ALLOC_REQ];
+};
+
+struct bnxt_qplib_hctx {
+	struct bnxt_qplib_hwq	hwq;
+	u32			max;
+};
+
+struct bnxt_qplib_refrec {
+	void *handle;
+	u32 xid;
+};
+
+struct bnxt_qplib_reftbl {
+	struct bnxt_qplib_refrec *rec;
+	u32 max;
+	spinlock_t lock; /* reftbl lock */
+};
+
+struct bnxt_qplib_reftbls {
+	struct bnxt_qplib_reftbl qpref;
+	struct bnxt_qplib_reftbl cqref;
+	struct bnxt_qplib_reftbl srqref;
+};
+
+#define GET_TBL_INDEX(id, tbl) ((id) % (((tbl)->max) - 1))
+static inline u32 map_qp_id_to_tbl_indx(u32 qid, struct bnxt_qplib_reftbl *tbl)
+{
+	return (qid == 1) ? tbl->max : GET_TBL_INDEX(qid, tbl);
+}
+
+/*
+ * This structure includes the number of various roce resource table sizes
+ * actually allocated by the driver. May be less than the maximums the firmware
+ * allows if the driver imposes lower limits than the firmware.
+ */
+struct bnxt_qplib_ctx {
+	struct bnxt_qplib_hctx		qp_ctx;
+	struct bnxt_qplib_hctx		mrw_ctx;
+	struct bnxt_qplib_hctx		srq_ctx;
+	struct bnxt_qplib_hctx		cq_ctx;
+	struct bnxt_qplib_hctx		tim_ctx;
+	struct bnxt_qplib_tqm_ctx	tqm_ctx;
+
+	struct bnxt_qplib_stats		stats;
+	struct bnxt_qplib_stats		stats2;
+	struct bnxt_qplib_vf_res	vf_res;
+};
+
+struct bnxt_qplib_res {
+	struct pci_dev			*pdev;
+	struct bnxt_qplib_chip_ctx	*cctx;
+	struct bnxt_qplib_dev_attr      *dattr;
+	struct bnxt_qplib_ctx		*hctx;
+	struct ifnet			*netdev;
+	struct bnxt_en_dev		*en_dev;
+
+	struct bnxt_qplib_rcfw		*rcfw;
+
+	struct bnxt_qplib_pd_tbl	pd_tbl;
+	struct mutex			pd_tbl_lock;
+	struct bnxt_qplib_sgid_tbl	sgid_tbl;
+	struct bnxt_qplib_dpi_tbl	dpi_tbl;
+	struct mutex			dpi_tbl_lock;
+	struct bnxt_qplib_reftbls	reftbl;
+	bool				prio;
+	bool				is_vf;
+	struct bnxt_qplib_db_pacing_data *pacing_data;
+};
+
+struct bnxt_qplib_query_stats_info {
+	u32 function_id;
+	u8 collection_id;
+	bool vf_valid;
+};
+
+struct bnxt_qplib_query_qp_info {
+	u32 function_id;
+	u32 num_qps;
+	u32 start_index;
+	bool vf_valid;
+};
+
+struct bnxt_qplib_query_fn_info {
+	bool vf_valid;
+	u32 host;
+	u32 filter;
+};
+
+
+#define to_bnxt_qplib(ptr, type, member)	\
+	container_of(ptr, type, member)
+
+struct bnxt_qplib_pd;
+struct bnxt_qplib_dev_attr;
+
+bool _is_chip_gen_p5(struct bnxt_qplib_chip_ctx *cctx);
+bool _is_chip_gen_p5_p7(struct bnxt_qplib_chip_ctx *cctx);
+bool _is_chip_a0(struct bnxt_qplib_chip_ctx *cctx);
+bool _is_chip_p7(struct bnxt_qplib_chip_ctx *cctx);
+bool _is_alloc_mr_unified(struct bnxt_qplib_dev_attr *dattr);
+void bnxt_qplib_free_hwq(struct bnxt_qplib_res *res,
+			 struct bnxt_qplib_hwq *hwq);
+int bnxt_qplib_alloc_init_hwq(struct bnxt_qplib_hwq *hwq,
+			      struct bnxt_qplib_hwq_attr *hwq_attr);
+void bnxt_qplib_get_guid(const u8 *dev_addr, u8 *guid);
+int bnxt_qplib_alloc_pd(struct bnxt_qplib_res *res,
+			struct bnxt_qplib_pd *pd);
+int bnxt_qplib_dealloc_pd(struct bnxt_qplib_res *res,
+			  struct bnxt_qplib_pd_tbl *pd_tbl,
+			  struct bnxt_qplib_pd *pd);
+int bnxt_qplib_alloc_dpi(struct bnxt_qplib_res *res,
+			 struct bnxt_qplib_dpi *dpi,
+			 void *app, u8 type);
+int bnxt_qplib_dealloc_dpi(struct bnxt_qplib_res *res,
+			   struct bnxt_qplib_dpi *dpi);
+int bnxt_qplib_stop_res(struct bnxt_qplib_res *res);
+void bnxt_qplib_clear_tbls(struct bnxt_qplib_res *res);
+int bnxt_qplib_init_tbls(struct bnxt_qplib_res *res);
+void bnxt_qplib_free_tbls(struct bnxt_qplib_res *res);
+int bnxt_qplib_alloc_tbls(struct bnxt_qplib_res *res, u8 pppp_factor);
+void bnxt_qplib_free_hwctx(struct bnxt_qplib_res *res);
+int bnxt_qplib_alloc_hwctx(struct bnxt_qplib_res *res);
+int bnxt_qplib_alloc_stat_mem(struct pci_dev *pdev,
+			      struct bnxt_qplib_chip_ctx *cctx,
+			      struct bnxt_qplib_stats *stats);
+void bnxt_qplib_free_stat_mem(struct bnxt_qplib_res *res,
+			      struct bnxt_qplib_stats *stats);
+
+int bnxt_qplib_map_db_bar(struct bnxt_qplib_res *res);
+void bnxt_qplib_unmap_db_bar(struct bnxt_qplib_res *res);
+int bnxt_qplib_enable_atomic_ops_to_root(struct pci_dev *dev);
+u8 _get_chip_gen_p5_type(struct bnxt_qplib_chip_ctx *cctx);
+
+static inline void *bnxt_qplib_get_qe(struct bnxt_qplib_hwq *hwq,
+				      u32 indx, u64 *pg)
+{
+	u32 pg_num, pg_idx;
+
+	pg_num = (indx / hwq->qe_ppg);
+	pg_idx = (indx % hwq->qe_ppg);
+	if (pg)
+		*pg = (u64)&hwq->pbl_ptr[pg_num];
+	return (void *)((u8 *)hwq->pbl_ptr[pg_num] + hwq->element_size * pg_idx);
+}
+
+static inline void bnxt_qplib_hwq_incr_prod(struct bnxt_qplib_db_info *dbinfo,
+					    struct bnxt_qplib_hwq *hwq, u32 cnt)
+{
+	/* move prod and update toggle/epoch if wrap around */
+	hwq->prod += cnt;
+	if (hwq->prod >= hwq->depth) {
+		hwq->prod %= hwq->depth;
+		dbinfo->flags ^= 1UL << BNXT_QPLIB_FLAG_EPOCH_PROD_SHIFT;
+	}
+}
+
+static inline void bnxt_qplib_hwq_incr_cons(u32 max_elements, u32 *cons,
+					    u32 cnt, u32 *dbinfo_flags)
+{
+	/* move cons and update toggle/epoch if wrap around */
+	*cons += cnt;
+	if (*cons >= max_elements) {
+		*cons %= max_elements;
+		*dbinfo_flags ^= 1UL << BNXT_QPLIB_FLAG_EPOCH_CONS_SHIFT;
+	}
+}
+
+static inline u8 _get_pte_pg_size(struct bnxt_qplib_hwq *hwq)
+{
+	u8 pg_size = BNXT_QPLIB_HWRM_PG_SIZE_4K;
+	struct bnxt_qplib_pbl *pbl;
+
+	pbl = &hwq->pbl[hwq->level];
+	switch (pbl->pg_size) {
+		case ROCE_PG_SIZE_4K: pg_size = BNXT_QPLIB_HWRM_PG_SIZE_4K;
+		break;
+		case ROCE_PG_SIZE_8K: pg_size = BNXT_QPLIB_HWRM_PG_SIZE_8K;
+		break;
+		case ROCE_PG_SIZE_64K: pg_size = BNXT_QPLIB_HWRM_PG_SIZE_64K;
+		break;
+		case ROCE_PG_SIZE_2M: pg_size = BNXT_QPLIB_HWRM_PG_SIZE_2M;
+		break;
+		case ROCE_PG_SIZE_8M: pg_size = BNXT_QPLIB_HWRM_PG_SIZE_8M;
+		break;
+		case ROCE_PG_SIZE_1G: pg_size = BNXT_QPLIB_HWRM_PG_SIZE_1G;
+		break;
+		default:
+		break;
+	}
+	return pg_size;
+}
+
+static inline u64 _get_base_addr(struct bnxt_qplib_hwq *hwq)
+{
+	return hwq->pbl[PBL_LVL_0].pg_map_arr[0];
+}
+
+static inline u8 _get_base_pg_size(struct bnxt_qplib_hwq *hwq)
+{
+	u8 pg_size = BNXT_QPLIB_HWRM_PG_SIZE_4K;
+	struct bnxt_qplib_pbl *pbl;
+
+	pbl = &hwq->pbl[PBL_LVL_0];
+	switch (pbl->pg_size) {
+		case ROCE_PG_SIZE_4K: pg_size = BNXT_QPLIB_HWRM_PG_SIZE_4K;
+		break;
+		case ROCE_PG_SIZE_8K: pg_size = BNXT_QPLIB_HWRM_PG_SIZE_8K;
+		break;
+		case ROCE_PG_SIZE_64K: pg_size = BNXT_QPLIB_HWRM_PG_SIZE_64K;
+		break;
+		case ROCE_PG_SIZE_2M: pg_size = BNXT_QPLIB_HWRM_PG_SIZE_2M;
+		break;
+		case ROCE_PG_SIZE_8M: pg_size = BNXT_QPLIB_HWRM_PG_SIZE_8M;
+		break;
+		case ROCE_PG_SIZE_1G: pg_size = BNXT_QPLIB_HWRM_PG_SIZE_1G;
+		break;
+		default:
+		break;
+	}
+	return pg_size;
+}
+
+static inline enum bnxt_qplib_hwq_type _get_hwq_type(struct bnxt_qplib_res *res)
+{
+	return _is_chip_gen_p5_p7(res->cctx) ? HWQ_TYPE_QUEUE : HWQ_TYPE_L2_CMPL;
+}
+
+static inline bool _is_ext_stats_supported(u16 dev_cap_flags)
+{
+	return dev_cap_flags &
+		CREQ_QUERY_FUNC_RESP_SB_EXT_STATS;
+}
+
+static inline int bnxt_ext_stats_supported(struct bnxt_qplib_chip_ctx *ctx,
+					   u16 flags, bool virtfn)
+{
+	return (_is_ext_stats_supported(flags) &&
+		((virtfn && _is_chip_p7(ctx)) || (!virtfn)));
+}
+
+static inline bool _is_hw_retx_supported(u16 dev_cap_flags)
+{
+	return dev_cap_flags &
+		(CREQ_QUERY_FUNC_RESP_SB_HW_REQUESTER_RETX_ENABLED |
+		 CREQ_QUERY_FUNC_RESP_SB_HW_RESPONDER_RETX_ENABLED);
+}
+
+/* Disable HW_RETX */
+#define BNXT_RE_HW_RETX(a) _is_hw_retx_supported((a))
+
+static inline bool _is_cqe_v2_supported(u16 dev_cap_flags)
+{
+	return dev_cap_flags &
+		CREQ_QUERY_FUNC_RESP_SB_CQE_V2;
+}
+
+#define BNXT_DB_FIFO_ROOM_MASK      0x1fff8000
+#define BNXT_DB_FIFO_ROOM_SHIFT     15
+#define BNXT_MAX_FIFO_DEPTH         0x2c00
+
+#define BNXT_DB_PACING_ALGO_THRESHOLD	250
+#define BNXT_DEFAULT_PACING_PROBABILITY 0xFFFF
+
+#define BNXT_DBR_PACING_WIN_BASE	0x2000
+#define BNXT_DBR_PACING_WIN_MAP_OFF	4
+#define BNXT_DBR_PACING_WIN_OFF(reg)	(BNXT_DBR_PACING_WIN_BASE +	\
+
+static inline void bnxt_qplib_ring_db32(struct bnxt_qplib_db_info *info,
+					bool arm)
+{
+	u32 key = 0;
+
+	key = info->hwq->cons | (CMPL_DOORBELL_IDX_VALID |
+		(CMPL_DOORBELL_KEY_CMPL & CMPL_DOORBELL_KEY_MASK));
+	if (!arm)
+		key |= CMPL_DOORBELL_MASK;
+	/* memory barrier */
+	wmb();
+	writel(key, info->db);
+}
+
+#define BNXT_QPLIB_INIT_DBHDR(xid, type, indx, toggle)			\
+	(((u64)(((xid) & DBC_DBC_XID_MASK) | DBC_DBC_PATH_ROCE |	\
+	    (type) | BNXT_QPLIB_DBR_VALID) << 32) | (indx) |		\
+	    ((toggle) << (BNXT_QPLIB_DBR_TOGGLE_SHIFT)))
+
+static inline void bnxt_qplib_write_db(struct bnxt_qplib_db_info *info,
+				       u64 key, void __iomem *db,
+				       u64 *shadow_key)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&info->lock, flags);
+	*shadow_key = key;
+	writeq(key, db);
+	spin_unlock_irqrestore(&info->lock, flags);
+}
+
+static inline void __replay_writeq(u64 key, void __iomem *db)
+{
+	/* No need to replay uninitialised shadow_keys */
+	if (key != BNXT_QPLIB_DBR_KEY_INVALID)
+		writeq(key, db);
+}
+
+static inline void bnxt_qplib_replay_db(struct bnxt_qplib_db_info *info,
+					bool is_arm_ena)
+
+{
+	if (!spin_trylock_irq(&info->lock))
+		return;
+
+	if (is_arm_ena)
+		__replay_writeq(info->shadow_key_arm_ena, info->priv_db);
+	else
+		__replay_writeq(info->shadow_key, info->db);
+
+	spin_unlock_irq(&info->lock);
+}
+
+static inline void bnxt_qplib_ring_db(struct bnxt_qplib_db_info *info,
+				      u32 type)
+{
+	u64 key = 0;
+	u32 indx;
+	u8 toggle = 0;
+
+	if (type == DBC_DBC_TYPE_CQ_ARMALL ||
+	    type == DBC_DBC_TYPE_CQ_ARMSE)
+		toggle = info->toggle;
+
+	indx = ((info->hwq->cons & DBC_DBC_INDEX_MASK) |
+		((info->flags & BNXT_QPLIB_FLAG_EPOCH_CONS_MASK) <<
+		 BNXT_QPLIB_DB_EPOCH_CONS_SHIFT));
+
+	key = BNXT_QPLIB_INIT_DBHDR(info->xid, type, indx, toggle);
+	bnxt_qplib_write_db(info, key, info->db, &info->shadow_key);
+}
+
+static inline void bnxt_qplib_ring_prod_db(struct bnxt_qplib_db_info *info,
+					   u32 type)
+{
+	u64 key = 0;
+	u32 indx;
+
+	indx = (((info->hwq->prod / info->max_slot) & DBC_DBC_INDEX_MASK) |
+		((info->flags & BNXT_QPLIB_FLAG_EPOCH_PROD_MASK) <<
+		 BNXT_QPLIB_DB_EPOCH_PROD_SHIFT));
+	key = BNXT_QPLIB_INIT_DBHDR(info->xid, type, indx, 0);
+	bnxt_qplib_write_db(info, key, info->db, &info->shadow_key);
+}
+
+static inline void bnxt_qplib_armen_db(struct bnxt_qplib_db_info *info,
+				       u32 type)
+{
+	u64 key = 0;
+	u8 toggle = 0;
+
+	if (type == DBC_DBC_TYPE_CQ_ARMENA)
+		toggle = info->toggle;
+	/* Index always at 0 */
+	key = BNXT_QPLIB_INIT_DBHDR(info->xid, type, 0, toggle);
+	bnxt_qplib_write_db(info, key, info->priv_db,
+			    &info->shadow_key_arm_ena);
+}
+
+static inline void bnxt_qplib_cq_coffack_db(struct bnxt_qplib_db_info *info)
+{
+	u64 key = 0;
+
+	/* Index always at 0 */
+	key = BNXT_QPLIB_INIT_DBHDR(info->xid, DBC_DBC_TYPE_CQ_CUTOFF_ACK, 0, 0);
+	bnxt_qplib_write_db(info, key, info->priv_db, &info->shadow_key);
+}
+
+static inline void bnxt_qplib_srq_arm_db(struct bnxt_qplib_db_info *info)
+{
+	u64 key = 0;
+
+	/* Index always at 0 */
+	key = BNXT_QPLIB_INIT_DBHDR(info->xid, DBC_DBC_TYPE_SRQ_ARM, 0, 0);
+	bnxt_qplib_write_db(info, key, info->priv_db, &info->shadow_key);
+}
+
+static inline void bnxt_qplib_ring_nq_db(struct bnxt_qplib_db_info *info,
+					 struct bnxt_qplib_chip_ctx *cctx,
+					 bool arm)
+{
+	u32 type;
+
+	type = arm ? DBC_DBC_TYPE_NQ_ARM : DBC_DBC_TYPE_NQ;
+	if (_is_chip_gen_p5_p7(cctx))
+		bnxt_qplib_ring_db(info, type);
+	else
+		bnxt_qplib_ring_db32(info, arm);
+}
+
+struct bnxt_qplib_max_res {
+	u32 max_qp;
+	u32 max_mr;
+	u32 max_cq;
+	u32 max_srq;
+	u32 max_ah;
+	u32 max_pd;
+};
+
+/*
+ * Defines for maximum resources supported for chip revisions
+ * Maximum PDs supported are restricted to Max QPs
+ * GENP4 - Wh+
+ * DEFAULT - Thor
+ */
+#define BNXT_QPLIB_GENP4_PF_MAX_QP	(16 * 1024)
+#define BNXT_QPLIB_GENP4_PF_MAX_MRW	(16 * 1024)
+#define BNXT_QPLIB_GENP4_PF_MAX_CQ	(16 * 1024)
+#define BNXT_QPLIB_GENP4_PF_MAX_SRQ	(1 * 1024)
+#define BNXT_QPLIB_GENP4_PF_MAX_AH	(16 * 1024)
+#define BNXT_QPLIB_GENP4_PF_MAX_PD	 BNXT_QPLIB_GENP4_PF_MAX_QP
+
+#define BNXT_QPLIB_DEFAULT_PF_MAX_QP	(64 * 1024)
+#define BNXT_QPLIB_DEFAULT_PF_MAX_MRW	(256 * 1024)
+#define BNXT_QPLIB_DEFAULT_PF_MAX_CQ	(64 * 1024)
+#define BNXT_QPLIB_DEFAULT_PF_MAX_SRQ	(4 * 1024)
+#define BNXT_QPLIB_DEFAULT_PF_MAX_AH	(64 * 1024)
+#define BNXT_QPLIB_DEFAULT_PF_MAX_PD	BNXT_QPLIB_DEFAULT_PF_MAX_QP
+
+#define BNXT_QPLIB_DEFAULT_VF_MAX_QP	(6 * 1024)
+#define BNXT_QPLIB_DEFAULT_VF_MAX_MRW	(6 * 1024)
+#define BNXT_QPLIB_DEFAULT_VF_MAX_CQ	(6 * 1024)
+#define BNXT_QPLIB_DEFAULT_VF_MAX_SRQ	(4 * 1024)
+#define BNXT_QPLIB_DEFAULT_VF_MAX_AH	(6 * 1024)
+#define BNXT_QPLIB_DEFAULT_VF_MAX_PD	BNXT_QPLIB_DEFAULT_VF_MAX_QP
+
+static inline void bnxt_qplib_max_res_supported(struct bnxt_qplib_chip_ctx *cctx,
+						struct bnxt_qplib_res *qpl_res,
+						struct bnxt_qplib_max_res *max_res,
+						bool vf_res_limit)
+{
+	switch (cctx->chip_num) {
+	case CHIP_NUM_57608:
+	case CHIP_NUM_58818:
+	case CHIP_NUM_57504:
+	case CHIP_NUM_57502:
+	case CHIP_NUM_57508:
+		if (!qpl_res->is_vf) {
+			max_res->max_qp = BNXT_QPLIB_DEFAULT_PF_MAX_QP;
+			max_res->max_mr = BNXT_QPLIB_DEFAULT_PF_MAX_MRW;
+			max_res->max_cq = BNXT_QPLIB_DEFAULT_PF_MAX_CQ;
+			max_res->max_srq = BNXT_QPLIB_DEFAULT_PF_MAX_SRQ;
+			max_res->max_ah = BNXT_QPLIB_DEFAULT_PF_MAX_AH;
+			max_res->max_pd = BNXT_QPLIB_DEFAULT_PF_MAX_PD;
+		} else {
+			max_res->max_qp = BNXT_QPLIB_DEFAULT_VF_MAX_QP;
+			max_res->max_mr = BNXT_QPLIB_DEFAULT_VF_MAX_MRW;
+			max_res->max_cq = BNXT_QPLIB_DEFAULT_VF_MAX_CQ;
+			max_res->max_srq = BNXT_QPLIB_DEFAULT_VF_MAX_SRQ;
+			max_res->max_ah = BNXT_QPLIB_DEFAULT_VF_MAX_AH;
+			max_res->max_pd = BNXT_QPLIB_DEFAULT_VF_MAX_PD;
+		}
+		break;
+	default:
+		/* Wh+/Stratus max resources */
+		max_res->max_qp = BNXT_QPLIB_GENP4_PF_MAX_QP;
+		max_res->max_mr = BNXT_QPLIB_GENP4_PF_MAX_MRW;
+		max_res->max_cq = BNXT_QPLIB_GENP4_PF_MAX_CQ;
+		max_res->max_srq = BNXT_QPLIB_GENP4_PF_MAX_SRQ;
+		max_res->max_ah = BNXT_QPLIB_GENP4_PF_MAX_AH;
+		max_res->max_pd = BNXT_QPLIB_GENP4_PF_MAX_PD;
+		break;
+	}
+}
+#endif
diff --git a/sys/dev/bnxt/bnxt_re/qplib_sp.c b/sys/dev/bnxt/bnxt_re/qplib_sp.c
new file mode 100644
index 000000000000..c414718a816f
--- /dev/null
+++ b/sys/dev/bnxt/bnxt_re/qplib_sp.c
@@ -0,0 +1,1234 @@
+/*
+ * Copyright (c) 2015-2024, Broadcom. All rights reserved.  The term
+ * Broadcom refers to Broadcom Limited and/or its subsidiaries.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Description: Slow Path Operators
+ */
+
+#include <linux/interrupt.h>
+#include <linux/spinlock.h>
+#include <linux/sched.h>
+#include <linux/pci.h>
+#include <linux/if_ether.h>
+#include <linux/printk.h>
+
+#include "hsi_struct_def.h"
+#include "qplib_tlv.h"
+#include "qplib_res.h"
+#include "qplib_rcfw.h"
+#include "qplib_sp.h"
+
+const struct bnxt_qplib_gid bnxt_qplib_gid_zero = {{ 0, 0, 0, 0, 0, 0, 0, 0,
+						     0, 0, 0, 0, 0, 0, 0, 0 }};
+
+/* Device */
+static u8 bnxt_qplib_is_atomic_cap(struct bnxt_qplib_rcfw *rcfw)
+{
+	u16 pcie_ctl2 = 0;
+
+	if (!_is_chip_gen_p5_p7(rcfw->res->cctx))
+		return false;
+	pcie_capability_read_word(rcfw->pdev, PCI_EXP_DEVCTL2, &pcie_ctl2);
+	return (pcie_ctl2 & PCI_EXP_DEVCTL2_ATOMIC_REQ);
+}
+
+static void bnxt_qplib_query_version(struct bnxt_qplib_rcfw *rcfw, char *fw_ver)
+{
+	struct creq_query_version_resp resp = {};
+	struct bnxt_qplib_cmdqmsg msg = {};
+	struct cmdq_query_version req = {};
+	int rc = 0;
+
+	bnxt_qplib_rcfw_cmd_prep(&req, CMDQ_BASE_OPCODE_QUERY_VERSION,
+				 sizeof(req));
+	bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, NULL, sizeof(req),
+				sizeof(resp), 0);
+	rc = bnxt_qplib_rcfw_send_message(rcfw, &msg);
+	if (rc) {
+		dev_err(&rcfw->pdev->dev, "QPLIB: Failed to query version\n");
+		return;
+	}
+	fw_ver[0] = resp.fw_maj;
+	fw_ver[1] = resp.fw_minor;
+	fw_ver[2] = resp.fw_bld;
+	fw_ver[3] = resp.fw_rsvd;
+}
+
+int bnxt_qplib_get_dev_attr(struct bnxt_qplib_rcfw *rcfw)
+{
+	struct creq_query_func_resp resp = {};
+	struct bnxt_qplib_cmdqmsg msg = {};
+	struct creq_query_func_resp_sb *sb;
+	struct bnxt_qplib_rcfw_sbuf sbuf;
+	struct bnxt_qplib_dev_attr *attr;
+	struct bnxt_qplib_chip_ctx *cctx;
+	struct cmdq_query_func req = {};
+	u8 *tqm_alloc;
+	int i, rc = 0;
+	u32 temp;
+	u8 chip_gen = BNXT_RE_DEFAULT;
+
+	cctx = rcfw->res->cctx;
+	attr = rcfw->res->dattr;
+
+	bnxt_qplib_rcfw_cmd_prep(&req, CMDQ_BASE_OPCODE_QUERY_FUNC,
+				 sizeof(req));
+
+	sbuf.size = sizeof(*sb);
+	sbuf.sb = dma_zalloc_coherent(&rcfw->pdev->dev, sbuf.size,
+				       &sbuf.dma_addr, GFP_KERNEL);
+	if (!sbuf.sb)
+		return -ENOMEM;
+
+	sb = sbuf.sb;
+	req.resp_size = sbuf.size / BNXT_QPLIB_CMDQE_UNITS;
+	bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, &sbuf, sizeof(req),
+				sizeof(resp), 0);
+	rc = bnxt_qplib_rcfw_send_message(rcfw, &msg);
+	if (rc)
+		goto bail;
+	/* Extract the context from the side buffer */
+	chip_gen = _get_chip_gen_p5_type(cctx);
+	attr->max_qp = le32_to_cpu(sb->max_qp);
+	attr->max_qp = min_t(u32, attr->max_qp, BNXT_RE_MAX_QP_SUPPORTED(chip_gen));
+	/* max_qp value reported by FW does not include the QP1 */
+	attr->max_qp += 1;
+	attr->max_qp_rd_atom =
+		sb->max_qp_rd_atom > BNXT_QPLIB_MAX_OUT_RD_ATOM ?
+		BNXT_QPLIB_MAX_OUT_RD_ATOM : sb->max_qp_rd_atom;
+	attr->max_qp_init_rd_atom =
+		sb->max_qp_init_rd_atom > BNXT_QPLIB_MAX_OUT_RD_ATOM ?
+		BNXT_QPLIB_MAX_OUT_RD_ATOM : sb->max_qp_init_rd_atom;
+	/* Report 1 less than the max_qp_wqes reported by FW as driver adds
+	 * one extra entry while creating the qp
+	 */
+	attr->max_qp_wqes = le16_to_cpu(sb->max_qp_wr) - 1;
+	/* Adjust for max_qp_wqes for variable wqe */
+	if (cctx->modes.wqe_mode == BNXT_QPLIB_WQE_MODE_VARIABLE) {
+		attr->max_qp_wqes = (BNXT_MAX_SQ_SIZE) /
+			(BNXT_MAX_VAR_WQE_SIZE / BNXT_SGE_SIZE) - 1;
+	}
+	if (!_is_chip_gen_p5_p7(cctx)) {
+		/*
+		 * 128 WQEs needs to be reserved for the HW (8916). Prevent
+		 * reporting the max number for gen-p4 only.
+		 */
+		attr->max_qp_wqes -= BNXT_QPLIB_RESERVED_QP_WRS;
+	}
+	attr->max_qp_sges = sb->max_sge;
+	if (_is_chip_gen_p5_p7(cctx) &&
+	    cctx->modes.wqe_mode == BNXT_QPLIB_WQE_MODE_VARIABLE)
+		attr->max_qp_sges = sb->max_sge_var_wqe;
+	attr->max_cq = le32_to_cpu(sb->max_cq);
+	attr->max_cq = min_t(u32, attr->max_cq, BNXT_RE_MAX_CQ_SUPPORTED(chip_gen));
+
+	attr->max_cq_wqes = le32_to_cpu(sb->max_cqe);
+	attr->max_cq_wqes = min_t(u32, BNXT_QPLIB_MAX_CQ_WQES, attr->max_cq_wqes);
+
+	attr->max_cq_sges = attr->max_qp_sges;
+	attr->max_mr = le32_to_cpu(sb->max_mr);
+	attr->max_mr = min_t(u32, attr->max_mr, BNXT_RE_MAX_MRW_SUPPORTED(chip_gen));
+	attr->max_mw = le32_to_cpu(sb->max_mw);
+	attr->max_mw = min_t(u32, attr->max_mw, BNXT_RE_MAX_MRW_SUPPORTED(chip_gen));
+
+	attr->max_mr_size = le64_to_cpu(sb->max_mr_size);
+	attr->max_pd = BNXT_QPLIB_MAX_PD;
+	attr->max_raw_ethy_qp = le32_to_cpu(sb->max_raw_eth_qp);
+	attr->max_ah = le32_to_cpu(sb->max_ah);
+	attr->max_ah = min_t(u32, attr->max_ah, BNXT_RE_MAX_AH_SUPPORTED(chip_gen));
+
+	attr->max_fmr = le32_to_cpu(sb->max_fmr);
+	attr->max_map_per_fmr = sb->max_map_per_fmr;
+
+	attr->max_srq = le16_to_cpu(sb->max_srq);
+	attr->max_srq = min_t(u32, attr->max_srq, BNXT_RE_MAX_SRQ_SUPPORTED(chip_gen));
+	attr->max_srq_wqes = le32_to_cpu(sb->max_srq_wr) - 1;
+	attr->max_srq_sges = sb->max_srq_sge;
+	attr->max_pkey = 1;
+
+	attr->max_inline_data = !cctx->modes.wqe_mode ?
+				le32_to_cpu(sb->max_inline_data) :
+				le16_to_cpu(sb->max_inline_data_var_wqe);
+	if (!_is_chip_p7(cctx)) {
+		attr->l2_db_size = (sb->l2_db_space_size + 1) *
+				    (0x01 << RCFW_DBR_BASE_PAGE_SHIFT);
+	}
+	attr->max_sgid = le32_to_cpu(sb->max_gid);
+
+	/* TODO: remove this hack for statically allocated gid_map */
+	bnxt_re_set_max_gid(&attr->max_sgid);
+
+	attr->dev_cap_flags = le16_to_cpu(sb->dev_cap_flags);
+	attr->page_size_cap = BIT_ULL(28) | BIT_ULL(21) | BIT_ULL(12);
+
+	bnxt_qplib_query_version(rcfw, attr->fw_ver);
+
+	for (i = 0; i < MAX_TQM_ALLOC_REQ / 4; i++) {
+		temp = le32_to_cpu(sb->tqm_alloc_reqs[i]);
+		tqm_alloc = (u8 *)&temp;
+		attr->tqm_alloc_reqs[i * 4] = *tqm_alloc;
+		attr->tqm_alloc_reqs[i * 4 + 1] = *(++tqm_alloc);
+		attr->tqm_alloc_reqs[i * 4 + 2] = *(++tqm_alloc);
+		attr->tqm_alloc_reqs[i * 4 + 3] = *(++tqm_alloc);
+	}
+
+	if (rcfw->res->cctx->hwrm_intf_ver >= HWRM_VERSION_DEV_ATTR_MAX_DPI)
+		attr->max_dpi = le32_to_cpu(sb->max_dpi);
+
+	attr->is_atomic = bnxt_qplib_is_atomic_cap(rcfw);
+bail:
+	dma_free_coherent(&rcfw->pdev->dev, sbuf.size,
+				  sbuf.sb, sbuf.dma_addr);
+	return rc;
+}
+
+int bnxt_qplib_set_func_resources(struct bnxt_qplib_res *res)
+{
+	struct creq_set_func_resources_resp resp = {};
+	struct cmdq_set_func_resources req = {};
+	struct bnxt_qplib_cmdqmsg msg = {};
+	struct bnxt_qplib_rcfw *rcfw;
+	struct bnxt_qplib_ctx *hctx;
+	int rc = 0;
+
+	rcfw = res->rcfw;
+	hctx = res->hctx;
+	bnxt_qplib_rcfw_cmd_prep(&req, CMDQ_BASE_OPCODE_SET_FUNC_RESOURCES,
+				 sizeof(req));
+
+	req.number_of_qp = cpu_to_le32(hctx->qp_ctx.max);
+	req.number_of_mrw = cpu_to_le32(hctx->mrw_ctx.max);
+	req.number_of_srq =  cpu_to_le32(hctx->srq_ctx.max);
+	req.number_of_cq = cpu_to_le32(hctx->cq_ctx.max);
+
+	req.max_qp_per_vf = cpu_to_le32(hctx->vf_res.max_qp);
+	req.max_mrw_per_vf = cpu_to_le32(hctx->vf_res.max_mrw);
+	req.max_srq_per_vf = cpu_to_le32(hctx->vf_res.max_srq);
+	req.max_cq_per_vf = cpu_to_le32(hctx->vf_res.max_cq);
+	req.max_gid_per_vf = cpu_to_le32(hctx->vf_res.max_gid);
+
+	/* Keep the old stats context id of PF */
+	req.stat_ctx_id = cpu_to_le32(hctx->stats.fw_id);
+
+	bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, NULL, sizeof(req),
+				sizeof(resp), 0);
+	rc = bnxt_qplib_rcfw_send_message(rcfw, &msg);
+	if (rc)
+		dev_err(&res->pdev->dev,
+			"QPLIB: Failed to set function resources\n");
+
+	return rc;
+}
+
+int bnxt_qplib_update_sgid(struct bnxt_qplib_sgid_tbl *sgid_tbl,
+			   struct bnxt_qplib_gid *gid, u16 gid_idx, const u8 *smac)
+{
+	struct bnxt_qplib_res *res = to_bnxt_qplib(sgid_tbl,
+						   struct bnxt_qplib_res,
+						   sgid_tbl);
+	struct bnxt_qplib_rcfw *rcfw = res->rcfw;
+	struct creq_modify_gid_resp resp = {};
+	struct bnxt_qplib_cmdqmsg msg = {};
+	struct cmdq_modify_gid req = {};
+	int rc;
+
+	bnxt_qplib_rcfw_cmd_prep(&req, CMDQ_BASE_OPCODE_MODIFY_GID,
+				 sizeof(req));
+
+	req.gid[0] = cpu_to_be32(((u32 *)gid->data)[3]);
+	req.gid[1] = cpu_to_be32(((u32 *)gid->data)[2]);
+	req.gid[2] = cpu_to_be32(((u32 *)gid->data)[1]);
+	req.gid[3] = cpu_to_be32(((u32 *)gid->data)[0]);
+	if (res->prio) {
+		req.vlan |= cpu_to_le16(CMDQ_ADD_GID_VLAN_TPID_TPID_8100 |
+			CMDQ_ADD_GID_VLAN_VLAN_EN);
+	}
+
+	/* MAC in network format */
+	req.src_mac[0] = cpu_to_be16(((u16 *)smac)[0]);
+	req.src_mac[1] = cpu_to_be16(((u16 *)smac)[1]);
+	req.src_mac[2] = cpu_to_be16(((u16 *)smac)[2]);
+	req.gid_index = cpu_to_le16(gid_idx);
+
+	bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, NULL, sizeof(req),
+				sizeof(resp), 0);
+	rc = bnxt_qplib_rcfw_send_message(rcfw, &msg);
+	if (rc) {
+		dev_err(&res->pdev->dev,
+			"QPLIB: update SGID table failed\n");
+		return rc;
+	}
+	return 0;
+}
+
+/* SGID */
+int bnxt_qplib_get_sgid(struct bnxt_qplib_res *res,
+			struct bnxt_qplib_sgid_tbl *sgid_tbl, int index,
+			struct bnxt_qplib_gid *gid)
+{
+	if (index > sgid_tbl->max) {
+		dev_err(&res->pdev->dev,
+			"QPLIB: Index %d exceeded SGID table max (%d)\n",
+			index, sgid_tbl->max);
+		return -EINVAL;
+	}
+	memcpy(gid, &sgid_tbl->tbl[index].gid, sizeof(*gid));
+	return 0;
+}
+
+int bnxt_qplib_del_sgid(struct bnxt_qplib_sgid_tbl *sgid_tbl,
+			struct bnxt_qplib_gid *gid,
+			u16 vlan_id, bool update)
+{
+	struct bnxt_qplib_res *res = to_bnxt_qplib(sgid_tbl,
+						   struct bnxt_qplib_res,
+						   sgid_tbl);
+	struct bnxt_qplib_rcfw *rcfw = res->rcfw;
+	int index;
+
+	if (sgid_tbl == NULL) {
+		dev_err(&res->pdev->dev, "QPLIB: SGID table not allocated\n");
+		return -EINVAL;
+	}
+	/* Do we need a sgid_lock here? */
+	if (!sgid_tbl->active) {
+		dev_err(&res->pdev->dev,
+			"QPLIB: SGID table has no active entries\n");
+		return -ENOMEM;
+	}
+	for (index = 0; index < sgid_tbl->max; index++) {
+		if (!memcmp(&sgid_tbl->tbl[index].gid, gid, sizeof(*gid)) &&
+		    vlan_id == sgid_tbl->tbl[index].vlan_id)
+			break;
+	}
+	if (index == sgid_tbl->max) {
+		dev_warn(&res->pdev->dev, "GID not found in the SGID table\n");
+		return 0;
+	}
+
+	if (update) {
+		struct creq_delete_gid_resp resp = {};
+		struct bnxt_qplib_cmdqmsg msg = {};
+		struct cmdq_delete_gid req = {};
+		int rc;
+
+		bnxt_qplib_rcfw_cmd_prep(&req, CMDQ_BASE_OPCODE_DELETE_GID,
+					 sizeof(req));
+		if (sgid_tbl->hw_id[index] == 0xFFFF) {
+			dev_err(&res->pdev->dev,
+				"QPLIB: GID entry contains an invalid HW id");
+			return -EINVAL;
+		}
+		req.gid_index = cpu_to_le16(sgid_tbl->hw_id[index]);
+		bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, NULL, sizeof(req),
+					sizeof(resp), 0);
+		rc = bnxt_qplib_rcfw_send_message(rcfw, &msg);
+		if (rc)
+			return rc;
+	}
+	memcpy(&sgid_tbl->tbl[index].gid, &bnxt_qplib_gid_zero,
+	       sizeof(bnxt_qplib_gid_zero));
+	sgid_tbl->tbl[index].vlan_id = 0xFFFF;
+	sgid_tbl->vlan[index] = false;
+	sgid_tbl->active--;
+	dev_dbg(&res->pdev->dev,
+		 "QPLIB: SGID deleted hw_id[0x%x] = 0x%x active = 0x%x\n",
+		 index, sgid_tbl->hw_id[index], sgid_tbl->active);
+	sgid_tbl->hw_id[index] = (u16)-1;
+
+	return 0;
+}
+
+int bnxt_qplib_add_sgid(struct bnxt_qplib_sgid_tbl *sgid_tbl,
+			const union ib_gid *gid, const u8 *smac, u16 vlan_id,
+			bool update, u32 *index)
+{
+	struct bnxt_qplib_res *res = to_bnxt_qplib(sgid_tbl,
+						   struct bnxt_qplib_res,
+						   sgid_tbl);
+	struct bnxt_qplib_rcfw *rcfw = res->rcfw;
+	int i, free_idx;
+
+	if (sgid_tbl == NULL) {
+		dev_err(&res->pdev->dev, "QPLIB: SGID table not allocated\n");
+		return -EINVAL;
+	}
+	/* Do we need a sgid_lock here? */
+	if (sgid_tbl->active == sgid_tbl->max) {
+		dev_err(&res->pdev->dev, "QPLIB: SGID table is full\n");
+		return -ENOMEM;
+	}
+	free_idx = sgid_tbl->max;
+	for (i = 0; i < sgid_tbl->max; i++) {
+		if (!memcmp(&sgid_tbl->tbl[i], gid, sizeof(*gid)) &&
+		    sgid_tbl->tbl[i].vlan_id == vlan_id) {
+			dev_dbg(&res->pdev->dev,
+				"QPLIB: SGID entry already exist in entry %d!\n",
+				i);
+			*index = i;
+			return -EALREADY;
+		} else if (!memcmp(&sgid_tbl->tbl[i], &bnxt_qplib_gid_zero,
+				   sizeof(bnxt_qplib_gid_zero)) &&
+			   free_idx == sgid_tbl->max) {
+			free_idx = i;
+		}
+	}
+	if (free_idx == sgid_tbl->max) {
+		dev_err(&res->pdev->dev,
+			"QPLIB: SGID table is FULL but count is not MAX??\n");
+		return -ENOMEM;
+	}
+	if (update) {
+		struct creq_add_gid_resp resp = {};
+		struct bnxt_qplib_cmdqmsg msg = {};
+		struct cmdq_add_gid req = {};
+		int rc;
+
+		bnxt_qplib_rcfw_cmd_prep(&req, CMDQ_BASE_OPCODE_ADD_GID,
+					 sizeof(req));
+
+		req.gid[0] = cpu_to_be32(((u32 *)gid->raw)[3]);
+		req.gid[1] = cpu_to_be32(((u32 *)gid->raw)[2]);
+		req.gid[2] = cpu_to_be32(((u32 *)gid->raw)[1]);
+		req.gid[3] = cpu_to_be32(((u32 *)gid->raw)[0]);
+		/* driver should ensure that all RoCE traffic is always VLAN tagged
+		 * if RoCE traffic is running on non-zero VLAN ID or
+		 * RoCE traffic is running on non-zero Priority.
+		 */
+		if ((vlan_id != 0xFFFF) || res->prio) {
+			if (vlan_id != 0xFFFF)
+				req.vlan = cpu_to_le16(vlan_id &
+						CMDQ_ADD_GID_VLAN_VLAN_ID_MASK);
+			req.vlan |=
+				cpu_to_le16(CMDQ_ADD_GID_VLAN_TPID_TPID_8100 |
+					    CMDQ_ADD_GID_VLAN_VLAN_EN);
+		}
+
+		/* MAC in network format */
+		req.src_mac[0] = cpu_to_be16(((u16 *)smac)[0]);
+		req.src_mac[1] = cpu_to_be16(((u16 *)smac)[1]);
+		req.src_mac[2] = cpu_to_be16(((u16 *)smac)[2]);
+
+		bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, NULL, sizeof(req),
+					sizeof(resp), 0);
+		rc = bnxt_qplib_rcfw_send_message(rcfw, &msg);
+		if (rc)
+			return rc;
+		sgid_tbl->hw_id[free_idx] = le32_to_cpu(resp.xid);
+	}
+
+	if (vlan_id != 0xFFFF)
+		sgid_tbl->vlan[free_idx] = true;
+
+	memcpy(&sgid_tbl->tbl[free_idx], gid, sizeof(*gid));
+	sgid_tbl->tbl[free_idx].vlan_id = vlan_id;
+	sgid_tbl->active++;
+	dev_dbg(&res->pdev->dev,
+		 "QPLIB: SGID added hw_id[0x%x] = 0x%x active = 0x%x\n",
+		 free_idx, sgid_tbl->hw_id[free_idx], sgid_tbl->active);
+
+	*index = free_idx;
+	/* unlock */
+	return 0;
+}
+
+/* AH */
+int bnxt_qplib_create_ah(struct bnxt_qplib_res *res, struct bnxt_qplib_ah *ah,
+			 bool block)
+{
+	struct bnxt_qplib_rcfw *rcfw = res->rcfw;
+	struct creq_create_ah_resp resp = {};
+	struct bnxt_qplib_cmdqmsg msg = {};
+	struct cmdq_create_ah req = {};
+	u32 temp32[4];
+	u16 temp16[3];
+	int rc;
+
+	bnxt_qplib_rcfw_cmd_prep(&req, CMDQ_BASE_OPCODE_CREATE_AH,
+				 sizeof(req));
+
+	memcpy(temp32, ah->dgid.data, sizeof(struct bnxt_qplib_gid));
+	req.dgid[0] = cpu_to_le32(temp32[0]);
+	req.dgid[1] = cpu_to_le32(temp32[1]);
+	req.dgid[2] = cpu_to_le32(temp32[2]);
+	req.dgid[3] = cpu_to_le32(temp32[3]);
+
+	req.type = ah->nw_type;
+	req.hop_limit = ah->hop_limit;
+	req.sgid_index = cpu_to_le16(res->sgid_tbl.hw_id[ah->sgid_index]);
+	req.dest_vlan_id_flow_label = cpu_to_le32((ah->flow_label &
+					CMDQ_CREATE_AH_FLOW_LABEL_MASK) |
+					CMDQ_CREATE_AH_DEST_VLAN_ID_MASK);
+	req.pd_id = cpu_to_le32(ah->pd->id);
+	req.traffic_class = ah->traffic_class;
+
+	/* MAC in network format */
+	memcpy(temp16, ah->dmac, ETH_ALEN);
+	req.dest_mac[0] = cpu_to_le16(temp16[0]);
+	req.dest_mac[1] = cpu_to_le16(temp16[1]);
+	req.dest_mac[2] = cpu_to_le16(temp16[2]);
+
+	bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, NULL, sizeof(req),
+				sizeof(resp), block);
+	rc = bnxt_qplib_rcfw_send_message(rcfw, &msg);
+	if (rc)
+		return rc;
+
+	ah->id = le32_to_cpu(resp.xid);
+	/* for Cu/Wh AHID 0 is not valid */
+	if (!_is_chip_gen_p5_p7(res->cctx) && !ah->id)
+		rc = -EINVAL;
+
+	return rc;
+}
+
+int bnxt_qplib_destroy_ah(struct bnxt_qplib_res *res, struct bnxt_qplib_ah *ah,
+			  bool block)
+{
+	struct bnxt_qplib_rcfw *rcfw = res->rcfw;
+	struct creq_destroy_ah_resp resp = {};
+	struct bnxt_qplib_cmdqmsg msg = {};
+	struct cmdq_destroy_ah req = {};
+	int rc;
+
+	bnxt_qplib_rcfw_cmd_prep(&req, CMDQ_BASE_OPCODE_DESTROY_AH,
+				 sizeof(req));
+
+	req.ah_cid = cpu_to_le32(ah->id);
+
+	bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, NULL, sizeof(req),
+				sizeof(resp), block);
+	rc = bnxt_qplib_rcfw_send_message(rcfw, &msg);
+	return rc;
+}
+
+/* MRW */
+int bnxt_qplib_free_mrw(struct bnxt_qplib_res *res, struct bnxt_qplib_mrw *mrw)
+{
+	struct creq_deallocate_key_resp resp = {};
+	struct bnxt_qplib_rcfw *rcfw = res->rcfw;
+	struct cmdq_deallocate_key req = {};
+	struct bnxt_qplib_cmdqmsg msg = {};
+	int rc;
+
+	if (mrw->lkey == 0xFFFFFFFF) {
+		dev_info(&res->pdev->dev,
+			 "QPLIB: SP: Free a reserved lkey MRW\n");
+		return 0;
+	}
+
+	bnxt_qplib_rcfw_cmd_prep(&req, CMDQ_BASE_OPCODE_DEALLOCATE_KEY,
+				 sizeof(req));
+
+	req.mrw_flags = mrw->type;
+
+	if ((mrw->type == CMDQ_ALLOCATE_MRW_MRW_FLAGS_MW_TYPE1)  ||
+	    (mrw->type == CMDQ_ALLOCATE_MRW_MRW_FLAGS_MW_TYPE2A) ||
+	    (mrw->type == CMDQ_ALLOCATE_MRW_MRW_FLAGS_MW_TYPE2B))
+		req.key = cpu_to_le32(mrw->rkey);
+	else
+		req.key = cpu_to_le32(mrw->lkey);
+
+	bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, NULL, sizeof(req),
+				sizeof(resp), 0);
+	rc = bnxt_qplib_rcfw_send_message(rcfw, &msg);
+	if (rc)
+		return rc;
+
+	if (mrw->hwq.max_elements)
+		bnxt_qplib_free_hwq(res, &mrw->hwq);
+
+	return 0;
+}
+
+int bnxt_qplib_alloc_mrw(struct bnxt_qplib_res *res, struct bnxt_qplib_mrw *mrw)
+{
+	struct bnxt_qplib_rcfw *rcfw = res->rcfw;
+	struct creq_allocate_mrw_resp resp = {};
+	struct bnxt_qplib_cmdqmsg msg = {};
+	struct cmdq_allocate_mrw req = {};
+	int rc;
+
+	bnxt_qplib_rcfw_cmd_prep(&req, CMDQ_BASE_OPCODE_ALLOCATE_MRW,
+				 sizeof(req));
+
+	req.pd_id = cpu_to_le32(mrw->pd->id);
+	req.mrw_flags = mrw->type;
+	if ((mrw->type == CMDQ_ALLOCATE_MRW_MRW_FLAGS_PMR &&
+	     mrw->flags & BNXT_QPLIB_FR_PMR) ||
+	    mrw->type == CMDQ_ALLOCATE_MRW_MRW_FLAGS_MW_TYPE2A ||
+	    mrw->type == CMDQ_ALLOCATE_MRW_MRW_FLAGS_MW_TYPE2B)
+		req.access = CMDQ_ALLOCATE_MRW_ACCESS_CONSUMER_OWNED_KEY;
+	req.mrw_handle = cpu_to_le64((uintptr_t)mrw);
+
+	bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, NULL, sizeof(req),
+				sizeof(resp), 0);
+	rc = bnxt_qplib_rcfw_send_message(rcfw, &msg);
+	if (rc)
+		return rc;
+	if ((mrw->type == CMDQ_ALLOCATE_MRW_MRW_FLAGS_MW_TYPE1)  ||
+	    (mrw->type == CMDQ_ALLOCATE_MRW_MRW_FLAGS_MW_TYPE2A) ||
+	    (mrw->type == CMDQ_ALLOCATE_MRW_MRW_FLAGS_MW_TYPE2B))
+		mrw->rkey = le32_to_cpu(resp.xid);
+	else
+		mrw->lkey = le32_to_cpu(resp.xid);
+
+	return 0;
+}
+
+int bnxt_qplib_dereg_mrw(struct bnxt_qplib_res *res, struct bnxt_qplib_mrw *mrw,
+			 bool block)
+{
+	struct bnxt_qplib_rcfw *rcfw = res->rcfw;
+	struct creq_deregister_mr_resp resp = {};
+	struct bnxt_qplib_cmdqmsg msg = {};
+	struct cmdq_deregister_mr req = {};
+	int rc;
+
+	bnxt_qplib_rcfw_cmd_prep(&req, CMDQ_BASE_OPCODE_DEREGISTER_MR,
+				 sizeof(req));
+
+	req.lkey = cpu_to_le32(mrw->lkey);
+	bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, NULL, sizeof(req),
+				sizeof(resp), block);
+	rc = bnxt_qplib_rcfw_send_message(rcfw, &msg);
+	if (rc)
+		return rc;
+
+	if (mrw->hwq.max_elements) {
+		mrw->va = 0;
+		mrw->total_size = 0;
+		bnxt_qplib_free_hwq(res, &mrw->hwq);
+	}
+
+	return 0;
+}
+
+int bnxt_qplib_reg_mr(struct bnxt_qplib_res *res,
+		      struct bnxt_qplib_mrinfo *mrinfo,
+		      bool block)
+{
+	struct bnxt_qplib_hwq_attr hwq_attr = {};
+	struct bnxt_qplib_rcfw *rcfw = res->rcfw;
+	struct creq_register_mr_resp resp = {};
+	struct bnxt_qplib_cmdqmsg msg = {};
+	struct cmdq_register_mr req = {};
+	struct bnxt_qplib_mrw *mr;
+	u32 buf_pg_size;
+	u32 pg_size;
+	u16 level;
+	u16 flags;
+	int rc;
+
+	mr = mrinfo->mrw;
+	buf_pg_size = 0x01ULL << mrinfo->sg.pgshft;
+	if (mrinfo->sg.npages) {
+		/* Free the hwq if it already exist, must be a rereg */
+		if (mr->hwq.max_elements)
+			bnxt_qplib_free_hwq(res, &mr->hwq);
+		/* Use system PAGE_SIZE */
+		hwq_attr.res = res;
+		hwq_attr.depth = mrinfo->sg.npages;
+		hwq_attr.stride = PAGE_SIZE;
+		hwq_attr.type = HWQ_TYPE_MR;
+		hwq_attr.sginfo = &mrinfo->sg;
+		rc = bnxt_qplib_alloc_init_hwq(&mr->hwq, &hwq_attr);
+		if (rc) {
+			dev_err(&res->pdev->dev,
+				"SP: Reg MR memory allocation failed\n");
+			return -ENOMEM;
+		}
+	}
+
+	bnxt_qplib_rcfw_cmd_prep(&req, CMDQ_BASE_OPCODE_REGISTER_MR,
+				 sizeof(req));
+	/* Configure the request */
+	if (mrinfo->is_dma) {
+		/* No PBL provided, just use system PAGE_SIZE */
+		level = 0;
+		req.pbl = 0;
+		pg_size = PAGE_SIZE;
+	} else {
+		level = mr->hwq.level;
+		req.pbl = cpu_to_le64(mr->hwq.pbl[PBL_LVL_0].pg_map_arr[0]);
+	}
+
+	pg_size = buf_pg_size ? buf_pg_size : PAGE_SIZE;
+	req.log2_pg_size_lvl = (level << CMDQ_REGISTER_MR_LVL_SFT) |
+			       ((ilog2(pg_size) <<
+				 CMDQ_REGISTER_MR_LOG2_PG_SIZE_SFT) &
+				CMDQ_REGISTER_MR_LOG2_PG_SIZE_MASK);
+	req.log2_pbl_pg_size = cpu_to_le16(((ilog2(PAGE_SIZE) <<
+				 CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_SFT) &
+				CMDQ_REGISTER_MR_LOG2_PBL_PG_SIZE_MASK));
+	req.access = (mr->flags & 0xFFFF);
+	req.va = cpu_to_le64(mr->va);
+	req.key = cpu_to_le32(mr->lkey);
+	if (_is_alloc_mr_unified(res->dattr)) {
+		flags = 0;
+		req.key = cpu_to_le32(mr->pd->id);
+		flags |= CMDQ_REGISTER_MR_FLAGS_ALLOC_MR;
+		req.flags = cpu_to_le16(flags);
+	}
+	req.mr_size = cpu_to_le64(mr->total_size);
+
+	bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, NULL, sizeof(req),
+				sizeof(resp), block);
+	rc = bnxt_qplib_rcfw_send_message(rcfw, &msg);
+	if (rc)
+		goto fail;
+
+	if (_is_alloc_mr_unified(res->dattr)) {
+		mr->lkey = le32_to_cpu(resp.xid);
+		mr->rkey = mr->lkey;
+	}
+
+	return 0;
+fail:
+	if (mr->hwq.max_elements)
+		bnxt_qplib_free_hwq(res, &mr->hwq);
+	return rc;
+}
+
+int bnxt_qplib_alloc_fast_reg_page_list(struct bnxt_qplib_res *res,
+					struct bnxt_qplib_frpl *frpl,
+					int max_pg_ptrs)
+{
+	struct bnxt_qplib_hwq_attr hwq_attr = {};
+	struct bnxt_qplib_sg_info sginfo = {};
+	int pg_ptrs, rc;
+
+	/* Re-calculate the max to fit the HWQ allocation model */
+	pg_ptrs = roundup_pow_of_two(max_pg_ptrs);
+
+	sginfo.pgsize = PAGE_SIZE;
+	sginfo.nopte = true;
+
+	hwq_attr.res = res;
+	hwq_attr.depth = pg_ptrs;
+	hwq_attr.stride = PAGE_SIZE;
+	hwq_attr.sginfo = &sginfo;
+	hwq_attr.type = HWQ_TYPE_CTX;
+	rc = bnxt_qplib_alloc_init_hwq(&frpl->hwq, &hwq_attr);
+	if (!rc)
+		frpl->max_pg_ptrs = pg_ptrs;
+
+	return rc;
+}
+
+void bnxt_qplib_free_fast_reg_page_list(struct bnxt_qplib_res *res,
+					struct bnxt_qplib_frpl *frpl)
+{
+	bnxt_qplib_free_hwq(res, &frpl->hwq);
+}
+
+int bnxt_qplib_map_tc2cos(struct bnxt_qplib_res *res, u16 *cids)
+{
+	struct bnxt_qplib_rcfw *rcfw = res->rcfw;
+	struct creq_map_tc_to_cos_resp resp = {};
+	struct bnxt_qplib_cmdqmsg msg = {};
+	struct cmdq_map_tc_to_cos req = {};
+	int rc;
+
+	bnxt_qplib_rcfw_cmd_prep(&req, CMDQ_BASE_OPCODE_MAP_TC_TO_COS,
+				 sizeof(req));
+	req.cos0 = cpu_to_le16(cids[0]);
+	req.cos1 = cpu_to_le16(cids[1]);
+
+	bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, NULL, sizeof(req),
+				sizeof(resp), 0);
+	rc = bnxt_qplib_rcfw_send_message(rcfw, &msg);
+	return rc;
+}
+
+static void bnxt_qplib_fill_cc_gen1(struct cmdq_modify_roce_cc_gen1_tlv *ext_req,
+			     struct bnxt_qplib_cc_param_ext *cc_ext)
+{
+	ext_req->modify_mask = cpu_to_le64(cc_ext->ext_mask);
+	cc_ext->ext_mask = 0;
+	ext_req->inactivity_th_hi = cpu_to_le16(cc_ext->inact_th_hi);
+	ext_req->min_time_between_cnps = cpu_to_le16(cc_ext->min_delta_cnp);
+	ext_req->init_cp = cpu_to_le16(cc_ext->init_cp);
+	ext_req->tr_update_mode = cc_ext->tr_update_mode;
+	ext_req->tr_update_cycles = cc_ext->tr_update_cyls;
+	ext_req->fr_num_rtts = cc_ext->fr_rtt;
+	ext_req->ai_rate_increase = cc_ext->ai_rate_incr;
+	ext_req->reduction_relax_rtts_th = cpu_to_le16(cc_ext->rr_rtt_th);
+	ext_req->additional_relax_cr_th = cpu_to_le16(cc_ext->ar_cr_th);
+	ext_req->cr_min_th = cpu_to_le16(cc_ext->cr_min_th);
+	ext_req->bw_avg_weight = cc_ext->bw_avg_weight;
+	ext_req->actual_cr_factor = cc_ext->cr_factor;
+	ext_req->max_cp_cr_th = cpu_to_le16(cc_ext->cr_th_max_cp);
+	ext_req->cp_bias_en = cc_ext->cp_bias_en;
+	ext_req->cp_bias = cc_ext->cp_bias;
+	ext_req->cnp_ecn = cc_ext->cnp_ecn;
+	ext_req->rtt_jitter_en = cc_ext->rtt_jitter_en;
+	ext_req->link_bytes_per_usec = cpu_to_le16(cc_ext->bytes_per_usec);
+	ext_req->reset_cc_cr_th = cpu_to_le16(cc_ext->cc_cr_reset_th);
+	ext_req->cr_width = cc_ext->cr_width;
+	ext_req->quota_period_min = cc_ext->min_quota;
+	ext_req->quota_period_max = cc_ext->max_quota;
+	ext_req->quota_period_abs_max = cc_ext->abs_max_quota;
+	ext_req->tr_lower_bound = cpu_to_le16(cc_ext->tr_lb);
+	ext_req->cr_prob_factor = cc_ext->cr_prob_fac;
+	ext_req->tr_prob_factor = cc_ext->tr_prob_fac;
+	ext_req->fairness_cr_th = cpu_to_le16(cc_ext->fair_cr_th);
+	ext_req->red_div = cc_ext->red_div;
+	ext_req->cnp_ratio_th = cc_ext->cnp_ratio_th;
+	ext_req->exp_ai_rtts = cpu_to_le16(cc_ext->ai_ext_rtt);
+	ext_req->exp_ai_cr_cp_ratio = cc_ext->exp_crcp_ratio;
+	ext_req->use_rate_table = cc_ext->low_rate_en;
+	ext_req->cp_exp_update_th = cpu_to_le16(cc_ext->cpcr_update_th);
+	ext_req->high_exp_ai_rtts_th1 = cpu_to_le16(cc_ext->ai_rtt_th1);
+	ext_req->high_exp_ai_rtts_th2 = cpu_to_le16(cc_ext->ai_rtt_th2);
+	ext_req->actual_cr_cong_free_rtts_th = cpu_to_le16(cc_ext->cf_rtt_th);
+	ext_req->severe_cong_cr_th1 = cpu_to_le16(cc_ext->sc_cr_th1);
+	ext_req->severe_cong_cr_th2 = cpu_to_le16(cc_ext->sc_cr_th2);
+	ext_req->link64B_per_rtt = cpu_to_le32(cc_ext->l64B_per_rtt);
+	ext_req->cc_ack_bytes = cc_ext->cc_ack_bytes;
+	ext_req->reduce_init_cong_free_rtts_th = cpu_to_le16(cc_ext->reduce_cf_rtt_th);
+}
+
+int bnxt_qplib_modify_cc(struct bnxt_qplib_res *res,
+			 struct bnxt_qplib_cc_param *cc_param)
+{
+	struct bnxt_qplib_tlv_modify_cc_req tlv_req = {};
+	struct creq_modify_roce_cc_resp resp = {};
+	struct bnxt_qplib_cmdqmsg msg = {};
+	struct cmdq_modify_roce_cc *req;
+	int req_size;
+	void *cmd;
+	int rc;
+
+	/* Prepare the older base command */
+	req = &tlv_req.base_req;
+	cmd = req;
+	req_size = sizeof(*req);
+	bnxt_qplib_rcfw_cmd_prep(req, CMDQ_BASE_OPCODE_MODIFY_ROCE_CC,
+				 sizeof(*req));
+	req->modify_mask = cpu_to_le32(cc_param->mask);
+	req->enable_cc = cc_param->enable;
+	req->g = cc_param->g;
+	req->num_phases_per_state = cc_param->nph_per_state;
+	req->time_per_phase = cc_param->time_pph;
+	req->pkts_per_phase = cc_param->pkts_pph;
+	req->init_cr = cpu_to_le16(cc_param->init_cr);
+	req->init_tr = cpu_to_le16(cc_param->init_tr);
+	req->tos_dscp_tos_ecn = (cc_param->tos_dscp <<
+				 CMDQ_MODIFY_ROCE_CC_TOS_DSCP_SFT) |
+				 (cc_param->tos_ecn &
+				 CMDQ_MODIFY_ROCE_CC_TOS_ECN_MASK);
+	req->alt_vlan_pcp = cc_param->alt_vlan_pcp;
+	req->alt_tos_dscp = cpu_to_le16(cc_param->alt_tos_dscp);
+	req->rtt = cpu_to_le16(cc_param->rtt);
+	req->tcp_cp = cpu_to_le16(cc_param->tcp_cp);
+	req->cc_mode = cc_param->cc_mode;
+	req->inactivity_th = cpu_to_le16(cc_param->inact_th);
+
+	/* For chip gen P5 onwards fill extended cmd and header */
+	if (_is_chip_gen_p5_p7(res->cctx)) {
+		struct roce_tlv *hdr;
+		u32 payload;
+		u32 chunks;
+
+		cmd = &tlv_req;
+		req_size = sizeof(tlv_req);
+		/* Prepare primary tlv header */
+		hdr = &tlv_req.tlv_hdr;
+		chunks = CHUNKS(sizeof(struct bnxt_qplib_tlv_modify_cc_req));
+		payload = sizeof(struct cmdq_modify_roce_cc);
+		ROCE_1ST_TLV_PREP(hdr, chunks, payload, true);
+		/* Prepare secondary tlv header */
+		hdr = (struct roce_tlv *)&tlv_req.ext_req;
+		payload = sizeof(struct cmdq_modify_roce_cc_gen1_tlv) -
+			  sizeof(struct roce_tlv);
+		ROCE_EXT_TLV_PREP(hdr, TLV_TYPE_MODIFY_ROCE_CC_GEN1, payload,
+				  false, true);
+		bnxt_qplib_fill_cc_gen1(&tlv_req.ext_req, &cc_param->cc_ext);
+	}
+
+	bnxt_qplib_fill_cmdqmsg(&msg, cmd, &resp, NULL, req_size,
+				sizeof(resp), 0);
+	rc = bnxt_qplib_rcfw_send_message(res->rcfw, &msg);
+	return rc;
+}
+
+static void bnxt_qplib_read_cc_gen1(struct bnxt_qplib_cc_param_ext *cc_ext,
+			     struct creq_query_roce_cc_gen1_resp_sb_tlv *sb)
+{
+	cc_ext->inact_th_hi = le16_to_cpu(sb->inactivity_th_hi);
+	cc_ext->min_delta_cnp = le16_to_cpu(sb->min_time_between_cnps);
+	cc_ext->init_cp = le16_to_cpu(sb->init_cp);
+	cc_ext->tr_update_mode = sb->tr_update_mode;
+	cc_ext->tr_update_cyls = sb->tr_update_cycles;
+	cc_ext->fr_rtt = sb->fr_num_rtts;
+	cc_ext->ai_rate_incr = sb->ai_rate_increase;
+	cc_ext->rr_rtt_th = le16_to_cpu(sb->reduction_relax_rtts_th);
+	cc_ext->ar_cr_th = le16_to_cpu(sb->additional_relax_cr_th);
+	cc_ext->cr_min_th = le16_to_cpu(sb->cr_min_th);
+	cc_ext->bw_avg_weight = sb->bw_avg_weight;
+	cc_ext->cr_factor = sb->actual_cr_factor;
+	cc_ext->cr_th_max_cp = le16_to_cpu(sb->max_cp_cr_th);
+	cc_ext->cp_bias_en = sb->cp_bias_en;
+	cc_ext->cp_bias = sb->cp_bias;
+	cc_ext->cnp_ecn = sb->cnp_ecn;
+	cc_ext->rtt_jitter_en = sb->rtt_jitter_en;
+	cc_ext->bytes_per_usec = le16_to_cpu(sb->link_bytes_per_usec);
+	cc_ext->cc_cr_reset_th = le16_to_cpu(sb->reset_cc_cr_th);
+	cc_ext->cr_width = sb->cr_width;
+	cc_ext->min_quota = sb->quota_period_min;
+	cc_ext->max_quota = sb->quota_period_max;
+	cc_ext->abs_max_quota = sb->quota_period_abs_max;
+	cc_ext->tr_lb = le16_to_cpu(sb->tr_lower_bound);
+	cc_ext->cr_prob_fac = sb->cr_prob_factor;
+	cc_ext->tr_prob_fac = sb->tr_prob_factor;
+	cc_ext->fair_cr_th = le16_to_cpu(sb->fairness_cr_th);
+	cc_ext->red_div = sb->red_div;
+	cc_ext->cnp_ratio_th = sb->cnp_ratio_th;
+	cc_ext->ai_ext_rtt = le16_to_cpu(sb->exp_ai_rtts);
+	cc_ext->exp_crcp_ratio = sb->exp_ai_cr_cp_ratio;
+	cc_ext->low_rate_en = sb->use_rate_table;
+	cc_ext->cpcr_update_th = le16_to_cpu(sb->cp_exp_update_th);
+	cc_ext->ai_rtt_th1 = le16_to_cpu(sb->high_exp_ai_rtts_th1);
+	cc_ext->ai_rtt_th2 = le16_to_cpu(sb->high_exp_ai_rtts_th2);
+	cc_ext->cf_rtt_th = le16_to_cpu(sb->actual_cr_cong_free_rtts_th);
+	cc_ext->sc_cr_th1 = le16_to_cpu(sb->severe_cong_cr_th1);
+	cc_ext->sc_cr_th2 = le16_to_cpu(sb->severe_cong_cr_th2);
+	cc_ext->l64B_per_rtt = le32_to_cpu(sb->link64B_per_rtt);
+	cc_ext->cc_ack_bytes = sb->cc_ack_bytes;
+	cc_ext->reduce_cf_rtt_th = le16_to_cpu(sb->reduce_init_cong_free_rtts_th);
+}
+
+int bnxt_qplib_query_cc_param(struct bnxt_qplib_res *res,
+			      struct bnxt_qplib_cc_param *cc_param)
+{
+	struct creq_query_roce_cc_gen1_resp_sb_tlv *gen1_sb;
+	struct bnxt_qplib_tlv_query_rcc_sb *ext_sb;
+	struct bnxt_qplib_rcfw *rcfw = res->rcfw;
+	struct creq_query_roce_cc_resp resp = {};
+	struct creq_query_roce_cc_resp_sb *sb;
+	struct bnxt_qplib_cmdqmsg msg = {};
+	struct cmdq_query_roce_cc req = {};
+	struct bnxt_qplib_rcfw_sbuf sbuf;
+	size_t resp_size;
+	int rc;
+
+	/* Query the parameters from chip */
+	bnxt_qplib_rcfw_cmd_prep(&req, CMDQ_BASE_OPCODE_QUERY_ROCE_CC,
+				 sizeof(req));
+	if (_is_chip_gen_p5_p7(res->cctx))
+		resp_size = sizeof(*ext_sb);
+	else
+		resp_size = sizeof(*sb);
+	sbuf.size = ALIGN(resp_size, BNXT_QPLIB_CMDQE_UNITS);
+	sbuf.sb = dma_zalloc_coherent(&rcfw->pdev->dev, sbuf.size,
+				       &sbuf.dma_addr, GFP_KERNEL);
+	if (!sbuf.sb)
+		return -ENOMEM;
+
+	req.resp_size = sbuf.size / BNXT_QPLIB_CMDQE_UNITS;
+	bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, &sbuf, sizeof(req),
+				sizeof(resp), 0);
+	rc = bnxt_qplib_rcfw_send_message(res->rcfw, &msg);
+	if (rc) {
+		dev_dbg(&res->pdev->dev, "%s:Query CC param failed:0x%x\n",
+			__func__, rc);
+		goto out;
+	}
+
+	ext_sb = sbuf.sb;
+	gen1_sb = &ext_sb->gen1_sb;
+	sb = _is_chip_gen_p5_p7(res->cctx) ? &ext_sb->base_sb :
+		(struct creq_query_roce_cc_resp_sb *)ext_sb;
+
+	cc_param->enable = sb->enable_cc & CREQ_QUERY_ROCE_CC_RESP_SB_ENABLE_CC;
+	cc_param->tos_ecn = (sb->tos_dscp_tos_ecn &
+			     CREQ_QUERY_ROCE_CC_RESP_SB_TOS_ECN_MASK) >>
+			     CREQ_QUERY_ROCE_CC_RESP_SB_TOS_ECN_SFT;
+	cc_param->tos_dscp = (sb->tos_dscp_tos_ecn &
+			      CREQ_QUERY_ROCE_CC_RESP_SB_TOS_DSCP_MASK) >>
+			      CREQ_QUERY_ROCE_CC_RESP_SB_TOS_DSCP_SFT;
+	cc_param->alt_tos_dscp = sb->alt_tos_dscp;
+	cc_param->alt_vlan_pcp = sb->alt_vlan_pcp;
+
+	cc_param->g = sb->g;
+	cc_param->nph_per_state = sb->num_phases_per_state;
+	cc_param->init_cr = le16_to_cpu(sb->init_cr);
+	cc_param->init_tr = le16_to_cpu(sb->init_tr);
+	cc_param->cc_mode = sb->cc_mode;
+	cc_param->inact_th = le16_to_cpu(sb->inactivity_th);
+	cc_param->rtt = le16_to_cpu(sb->rtt);
+	cc_param->tcp_cp = le16_to_cpu(sb->tcp_cp);
+	cc_param->time_pph = sb->time_per_phase;
+	cc_param->pkts_pph = sb->pkts_per_phase;
+	if (_is_chip_gen_p5_p7(res->cctx))
+		bnxt_qplib_read_cc_gen1(&cc_param->cc_ext, gen1_sb);
+out:
+	dma_free_coherent(&rcfw->pdev->dev, sbuf.size,
+				  sbuf.sb, sbuf.dma_addr);
+	return rc;
+}
+
+
+int bnxt_qplib_get_roce_error_stats(struct bnxt_qplib_rcfw *rcfw,
+				    struct bnxt_qplib_roce_stats *stats,
+				    struct bnxt_qplib_query_stats_info *sinfo)
+{
+	struct creq_query_roce_stats_resp resp = {};
+	struct creq_query_roce_stats_resp_sb *sb;
+	struct cmdq_query_roce_stats req = {};
+	struct bnxt_qplib_cmdqmsg msg = {};
+	struct bnxt_qplib_rcfw_sbuf sbuf;
+	u16 cmd_flags = 0;
+	u32 fn_id = 0;
+	int rc = 0;
+
+	bnxt_qplib_rcfw_cmd_prep(&req, CMDQ_BASE_OPCODE_QUERY_ROCE_STATS,
+				 sizeof(req));
+
+	sbuf.size = sizeof(*sb);
+	sbuf.sb = dma_zalloc_coherent(&rcfw->pdev->dev, sbuf.size,
+				       &sbuf.dma_addr, GFP_KERNEL);
+	if (!sbuf.sb)
+		return -ENOMEM;
+	sb = sbuf.sb;
+
+	if (rcfw->res->cctx->hwrm_intf_ver >= HWRM_VERSION_ROCE_STATS_FN_ID) {
+		if (sinfo->function_id != 0xFFFFFFFF) {
+			cmd_flags = CMDQ_QUERY_ROCE_STATS_FLAGS_FUNCTION_ID;
+			if (sinfo->vf_valid) {
+				fn_id = CMDQ_QUERY_ROCE_STATS_VF_VALID;
+				fn_id |= (sinfo->function_id <<
+					  CMDQ_QUERY_ROCE_STATS_VF_NUM_SFT) &
+					  CMDQ_QUERY_ROCE_STATS_VF_NUM_MASK;
+			} else {
+				fn_id = sinfo->function_id &
+					CMDQ_QUERY_ROCE_STATS_PF_NUM_MASK;
+			}
+		}
+
+		req.flags = cpu_to_le16(cmd_flags);
+		req.function_id = cpu_to_le32(fn_id);
+
+		if (sinfo->collection_id != 0xFF) {
+			cmd_flags |= CMDQ_QUERY_ROCE_STATS_FLAGS_COLLECTION_ID;
+			req.collection_id = sinfo->collection_id;
+		}
+	} else {
+		/* For older HWRM version, the command length has to be
+		 * adjusted. 8 bytes are more in the newer command.
+		 * So subtract these 8 bytes for older HWRM version.
+		 * command units are adjusted inside
+		 * bnxt_qplib_rcfw_send_message.
+		 */
+		req.cmd_size -= 8;
+	}
+
+	req.resp_size = sbuf.size / BNXT_QPLIB_CMDQE_UNITS;
+	bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, &sbuf, sizeof(req),
+				sizeof(resp), 0);
+	rc = bnxt_qplib_rcfw_send_message(rcfw, &msg);
+	if (rc)
+		goto bail;
+	/* Extract the context from the side buffer */
+	stats->to_retransmits = le64_to_cpu(sb->to_retransmits);
+	stats->seq_err_naks_rcvd = le64_to_cpu(sb->seq_err_naks_rcvd);
+	stats->max_retry_exceeded = le64_to_cpu(sb->max_retry_exceeded);
+	stats->rnr_naks_rcvd = le64_to_cpu(sb->rnr_naks_rcvd);
+	stats->missing_resp = le64_to_cpu(sb->missing_resp);
+	stats->unrecoverable_err = le64_to_cpu(sb->unrecoverable_err);
+	stats->bad_resp_err = le64_to_cpu(sb->bad_resp_err);
+	stats->local_qp_op_err = le64_to_cpu(sb->local_qp_op_err);
+	stats->local_protection_err = le64_to_cpu(sb->local_protection_err);
+	stats->mem_mgmt_op_err = le64_to_cpu(sb->mem_mgmt_op_err);
+	stats->remote_invalid_req_err = le64_to_cpu(sb->remote_invalid_req_err);
+	stats->remote_access_err = le64_to_cpu(sb->remote_access_err);
+	stats->remote_op_err = le64_to_cpu(sb->remote_op_err);
+	stats->dup_req = le64_to_cpu(sb->dup_req);
+	stats->res_exceed_max = le64_to_cpu(sb->res_exceed_max);
+	stats->res_length_mismatch = le64_to_cpu(sb->res_length_mismatch);
+	stats->res_exceeds_wqe = le64_to_cpu(sb->res_exceeds_wqe);
+	stats->res_opcode_err = le64_to_cpu(sb->res_opcode_err);
+	stats->res_rx_invalid_rkey = le64_to_cpu(sb->res_rx_invalid_rkey);
+	stats->res_rx_domain_err = le64_to_cpu(sb->res_rx_domain_err);
+	stats->res_rx_no_perm = le64_to_cpu(sb->res_rx_no_perm);
+	stats->res_rx_range_err = le64_to_cpu(sb->res_rx_range_err);
+	stats->res_tx_invalid_rkey = le64_to_cpu(sb->res_tx_invalid_rkey);
+	stats->res_tx_domain_err = le64_to_cpu(sb->res_tx_domain_err);
+	stats->res_tx_no_perm = le64_to_cpu(sb->res_tx_no_perm);
+	stats->res_tx_range_err = le64_to_cpu(sb->res_tx_range_err);
+	stats->res_irrq_oflow = le64_to_cpu(sb->res_irrq_oflow);
+	stats->res_unsup_opcode = le64_to_cpu(sb->res_unsup_opcode);
+	stats->res_unaligned_atomic = le64_to_cpu(sb->res_unaligned_atomic);
+	stats->res_rem_inv_err = le64_to_cpu(sb->res_rem_inv_err);
+	stats->res_mem_error = le64_to_cpu(sb->res_mem_error);
+	stats->res_srq_err = le64_to_cpu(sb->res_srq_err);
+	stats->res_cmp_err = le64_to_cpu(sb->res_cmp_err);
+	stats->res_invalid_dup_rkey = le64_to_cpu(sb->res_invalid_dup_rkey);
+	stats->res_wqe_format_err = le64_to_cpu(sb->res_wqe_format_err);
+	stats->res_cq_load_err = le64_to_cpu(sb->res_cq_load_err);
+	stats->res_srq_load_err = le64_to_cpu(sb->res_srq_load_err);
+	stats->res_tx_pci_err = le64_to_cpu(sb->res_tx_pci_err);
+	stats->res_rx_pci_err = le64_to_cpu(sb->res_rx_pci_err);
+
+	if (!rcfw->init_oos_stats) {
+		rcfw->oos_prev = le64_to_cpu(sb->res_oos_drop_count);
+		rcfw->init_oos_stats = true;
+	} else {
+		stats->res_oos_drop_count += (le64_to_cpu(sb->res_oos_drop_count) -
+					      rcfw->oos_prev) &
+					     BNXT_QPLIB_OOS_COUNT_MASK;
+		rcfw->oos_prev = le64_to_cpu(sb->res_oos_drop_count);
+	}
+
+	stats->active_qp_count_p0 = le64_to_cpu(sb->active_qp_count_p0);
+	stats->active_qp_count_p1 = le64_to_cpu(sb->active_qp_count_p1);
+	stats->active_qp_count_p2 = le64_to_cpu(sb->active_qp_count_p2);
+	stats->active_qp_count_p3 = le64_to_cpu(sb->active_qp_count_p3);
+bail:
+	dma_free_coherent(&rcfw->pdev->dev, sbuf.size,
+				  sbuf.sb, sbuf.dma_addr);
+	return rc;
+}
+
+int bnxt_qplib_set_link_aggr_mode(struct bnxt_qplib_res *res,
+				  u8 aggr_mode, u8 member_port_map,
+				  u8 active_port_map, bool aggr_en,
+				  u32 stats_fw_id)
+{
+	struct creq_set_link_aggr_mode_resources_resp resp = {};
+	struct cmdq_set_link_aggr_mode_cc req = {};
+	struct bnxt_qplib_rcfw *rcfw = res->rcfw;
+	struct bnxt_qplib_cmdqmsg msg = {};
+	int rc = 0;
+
+	bnxt_qplib_rcfw_cmd_prep(&req, CMDQ_BASE_OPCODE_SET_LINK_AGGR_MODE,
+				 sizeof(req));
+
+	req.aggr_enable = aggr_en;
+	req.active_port_map = active_port_map;
+	req.member_port_map = member_port_map;
+	req.link_aggr_mode = aggr_mode;
+
+	/* need to specify only second port stats ctx id for now */
+	req.stat_ctx_id[1] = cpu_to_le16((u16)(stats_fw_id));
+
+	req.modify_mask =
+		cpu_to_le32(CMDQ_SET_LINK_AGGR_MODE_MODIFY_MASK_AGGR_EN |
+			    CMDQ_SET_LINK_AGGR_MODE_MODIFY_MASK_ACTIVE_PORT_MAP |
+			    CMDQ_SET_LINK_AGGR_MODE_MODIFY_MASK_MEMBER_PORT_MAP |
+			    CMDQ_SET_LINK_AGGR_MODE_MODIFY_MASK_AGGR_MODE |
+			    CMDQ_SET_LINK_AGGR_MODE_MODIFY_MASK_STAT_CTX_ID);
+
+	bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, NULL, sizeof(req),
+				sizeof(resp), 0);
+	rc = bnxt_qplib_rcfw_send_message(rcfw, &msg);
+	if (rc)
+		dev_err(&res->pdev->dev,
+			"QPLIB: Failed to set link aggr mode, %#x\n", rc);
+
+	return rc;
+}
+
+int bnxt_qplib_qext_stat(struct bnxt_qplib_rcfw *rcfw, u32 fid,
+			 struct bnxt_qplib_ext_stat *estat,
+			 struct bnxt_qplib_query_stats_info *sinfo)
+{
+	struct creq_query_roce_stats_ext_resp resp = {};
+	struct creq_query_roce_stats_ext_resp_sb *sb;
+	struct cmdq_query_roce_stats_ext req = {};
+	struct bnxt_qplib_cmdqmsg msg = {};
+	struct bnxt_qplib_rcfw_sbuf sbuf;
+	int rc;
+
+	sbuf.size = sizeof(*sb);
+	sbuf.sb = dma_zalloc_coherent(&rcfw->pdev->dev, sbuf.size,
+				       &sbuf.dma_addr, GFP_KERNEL);
+	if (!sbuf.sb) {
+		dev_err(&rcfw->pdev->dev,
+			"QPLIB: SP: QUERY_ROCE_STATS_EXT alloc sb failed\n");
+		return -ENOMEM;
+	}
+	sb = sbuf.sb;
+
+	bnxt_qplib_rcfw_cmd_prep(&req,
+			CMDQ_QUERY_ROCE_STATS_EXT_OPCODE_QUERY_ROCE_STATS,
+			sizeof(req));
+	req.resp_size = sbuf.size;
+	req.resp_addr = cpu_to_le64(sbuf.dma_addr);
+	req.flags = cpu_to_le16(CMDQ_QUERY_ROCE_STATS_EXT_FLAGS_FUNCTION_ID);
+	if (_is_chip_p7(rcfw->res->cctx) && rcfw->res->is_vf) {
+		if (sinfo->vf_valid)
+			req.function_id =
+				cpu_to_le32(CMDQ_QUERY_ROCE_STATS_EXT_VF_VALID |
+					    (fid << CMDQ_QUERY_ROCE_STATS_EXT_VF_NUM_SFT));
+		else
+			req.flags = cpu_to_le16(0);
+	} else {
+		req.function_id = cpu_to_le32(fid);
+	}
+
+	bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, &sbuf, sizeof(req),
+				sizeof(resp), 0);
+	rc = bnxt_qplib_rcfw_send_message(rcfw, &msg);
+	if (rc)
+		goto bail;
+
+	/* dump when dyndbg is enabled */
+	print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, sb, sizeof(*sb));
+	estat->tx_atomic_req = le64_to_cpu(sb->tx_atomic_req_pkts);
+	estat->tx_read_req = le64_to_cpu(sb->tx_read_req_pkts);
+	estat->tx_read_res = le64_to_cpu(sb->tx_read_res_pkts);
+	estat->tx_write_req = le64_to_cpu(sb->tx_write_req_pkts);
+	estat->tx_send_req = le64_to_cpu(sb->tx_send_req_pkts);
+	estat->tx_roce_pkts = le64_to_cpu(sb->tx_roce_pkts);
+	estat->tx_roce_bytes = le64_to_cpu(sb->tx_roce_bytes);
+	estat->rx_atomic_req = le64_to_cpu(sb->rx_atomic_req_pkts);
+	estat->rx_read_req = le64_to_cpu(sb->rx_read_req_pkts);
+	estat->rx_read_res = le64_to_cpu(sb->rx_read_res_pkts);
+	estat->rx_write_req = le64_to_cpu(sb->rx_write_req_pkts);
+	estat->rx_send_req = le64_to_cpu(sb->rx_send_req_pkts);
+	estat->rx_roce_pkts = le64_to_cpu(sb->rx_roce_pkts);
+	estat->rx_roce_bytes = le64_to_cpu(sb->rx_roce_bytes);
+	estat->rx_roce_good_pkts = le64_to_cpu(sb->rx_roce_good_pkts);
+	estat->rx_roce_good_bytes = le64_to_cpu(sb->rx_roce_good_bytes);
+	estat->rx_out_of_buffer = le64_to_cpu(sb->rx_out_of_buffer_pkts);
+	estat->rx_out_of_sequence = le64_to_cpu(sb->rx_out_of_sequence_pkts);
+	estat->tx_cnp = le64_to_cpu(sb->tx_cnp_pkts);
+	estat->rx_cnp = le64_to_cpu(sb->rx_cnp_pkts);
+	estat->rx_ecn_marked = le64_to_cpu(sb->rx_ecn_marked_pkts);
+	estat->seq_err_naks_rcvd = le64_to_cpu(sb->seq_err_naks_rcvd);
+	estat->rnr_naks_rcvd = le64_to_cpu(sb->rnr_naks_rcvd);
+	estat->missing_resp = le64_to_cpu(sb->missing_resp);
+	estat->to_retransmits = le64_to_cpu(sb->to_retransmit);
+	estat->dup_req = le64_to_cpu(sb->dup_req);
+	estat->rx_dcn_payload_cut = le64_to_cpu(sb->rx_dcn_payload_cut);
+	estat->te_bypassed = le64_to_cpu(sb->te_bypassed);
+bail:
+	dma_free_coherent(&rcfw->pdev->dev, sbuf.size,
+				  sbuf.sb, sbuf.dma_addr);
+	return rc;
+}
diff --git a/sys/dev/bnxt/bnxt_re/qplib_sp.h b/sys/dev/bnxt/bnxt_re/qplib_sp.h
new file mode 100644
index 000000000000..e306db3b9d8e
--- /dev/null
+++ b/sys/dev/bnxt/bnxt_re/qplib_sp.h
@@ -0,0 +1,432 @@
+/*
+ * Copyright (c) 2015-2024, Broadcom. All rights reserved.  The term
+ * Broadcom refers to Broadcom Limited and/or its subsidiaries.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Description: Slow Path Operators (header)
+ */
+
+#ifndef __BNXT_QPLIB_SP_H__
+#define __BNXT_QPLIB_SP_H__
+
+#include <rdma/ib_verbs.h>
+
+#define BNXT_QPLIB_RESERVED_QP_WRS	128
+
+/* Resource maximums reported by the firmware */
+struct bnxt_qplib_dev_attr {
+#define FW_VER_ARR_LEN			4
+	u8				fw_ver[FW_VER_ARR_LEN];
+	u16				max_sgid;
+	u16				max_mrw;
+	u32				max_qp;
+#define BNXT_QPLIB_MAX_OUT_RD_ATOM	126
+	u32				max_qp_rd_atom;
+	u32				max_qp_init_rd_atom;
+	u32				max_qp_wqes;
+	u32				max_qp_sges;
+	u32				max_cq;
+	/* HW supports only 8K entries in PBL.
+	 * So max CQEs that can be supported per CQ is 1M.
+	 */
+#define BNXT_QPLIB_MAX_CQ_WQES		0xfffff
+	u32				max_cq_wqes;
+	u32				max_cq_sges;
+	u32				max_mr;
+	u64				max_mr_size;
+#define BNXT_QPLIB_MAX_PD		(64 * 1024)
+	u32				max_pd;
+	u32				max_mw;
+	u32				max_raw_ethy_qp;
+	u32				max_ah;
+	u32				max_fmr;
+	u32				max_map_per_fmr;
+	u32				max_srq;
+	u32				max_srq_wqes;
+	u32				max_srq_sges;
+	u32				max_pkey;
+	u32				max_inline_data;
+	u32				l2_db_size;
+	u8				tqm_alloc_reqs[MAX_TQM_ALLOC_REQ];
+	u8				is_atomic;
+	u16				dev_cap_flags;
+	u64				page_size_cap;
+	u32				max_dpi;
+};
+
+struct bnxt_qplib_pd {
+	u32				id;
+};
+
+struct bnxt_qplib_gid {
+	u8				data[16];
+};
+
+struct bnxt_qplib_gid_info {
+	struct bnxt_qplib_gid gid;
+	u16 vlan_id;
+};
+
+struct bnxt_qplib_ah {
+	struct bnxt_qplib_gid		dgid;
+	struct bnxt_qplib_pd		*pd;
+	u32				id;
+	u8				sgid_index;
+	u8				host_sgid_index; /* For Query AH if the hw table and SW table are differnt */
+	u8				traffic_class;
+	u32				flow_label;
+	u8				hop_limit;
+	u8				sl;
+	u8				dmac[6];
+	u16				vlan_id;
+	u8				nw_type;
+	u8				enable_cc;
+};
+
+struct bnxt_qplib_mrw {
+	struct bnxt_qplib_pd		*pd;
+	int				type;
+	u32				flags;
+#define BNXT_QPLIB_FR_PMR		0x80000000
+	u32				lkey;
+	u32				rkey;
+#define BNXT_QPLIB_RSVD_LKEY		0xFFFFFFFF
+	u64				va;
+	u64				total_size;
+	u32				npages;
+	u64				mr_handle;
+	struct bnxt_qplib_hwq		hwq;
+};
+
+struct bnxt_qplib_mrinfo {
+	struct bnxt_qplib_mrw		*mrw;
+	struct bnxt_qplib_sg_info	sg;
+	u64				*ptes;
+	bool				is_dma;
+};
+
+struct bnxt_qplib_frpl {
+	int				max_pg_ptrs;
+	struct bnxt_qplib_hwq		hwq;
+};
+
+struct bnxt_qplib_cc_param_ext {
+	u64 ext_mask;
+	u16 inact_th_hi;
+	u16 min_delta_cnp;
+	u16 init_cp;
+	u8 tr_update_mode;
+	u8 tr_update_cyls;
+	u8 fr_rtt;
+	u8 ai_rate_incr;
+	u16 rr_rtt_th;
+	u16 ar_cr_th;
+	u16 cr_min_th;
+	u8 bw_avg_weight;
+	u8 cr_factor;
+	u16 cr_th_max_cp;
+	u8 cp_bias_en;
+	u8 cp_bias;
+	u8 cnp_ecn;
+	u8 rtt_jitter_en;
+	u16 bytes_per_usec;
+	u16 cc_cr_reset_th;
+	u8 cr_width;
+	u8 min_quota;
+	u8 max_quota;
+	u8 abs_max_quota;
+	u16 tr_lb;
+	u8 cr_prob_fac;
+	u8 tr_prob_fac;
+	u16 fair_cr_th;
+	u8 red_div;
+	u8 cnp_ratio_th;
+	u16 ai_ext_rtt;
+	u8 exp_crcp_ratio;
+	u8 low_rate_en;
+	u16 cpcr_update_th;
+	u16 ai_rtt_th1;
+	u16 ai_rtt_th2;
+	u16 cf_rtt_th;
+	u16 sc_cr_th1; /* severe congestion cr threshold 1 */
+	u16 sc_cr_th2; /* severe congestion cr threshold 2 */
+	u32 l64B_per_rtt;
+	u8 cc_ack_bytes;
+	u16 reduce_cf_rtt_th;
+};
+
+struct bnxt_qplib_cc_param {
+	u8 alt_vlan_pcp;
+	u16 alt_tos_dscp;
+#define BNXT_QPLIB_USER_DSCP_VALID			0x80
+	u8 cnp_dscp_user;
+	u8 roce_dscp_user;
+	u8 cc_mode;
+	u8 enable;
+	u16 inact_th;
+	u16 init_cr;
+	u16 init_tr;
+	u16 rtt;
+	u8 g;
+	u8 nph_per_state;
+	u8 time_pph;
+	u8 pkts_pph;
+	u8 tos_ecn;
+	u8 tos_dscp;
+	u8 qp1_tos_dscp;
+	u16 tcp_cp;
+	struct bnxt_qplib_cc_param_ext cc_ext;
+	u8 disable_prio_vlan_tx;
+	/* Mask used while programming the configfs values */
+	u32 mask;
+	/* Mask used while displaying the configfs values */
+	u32 cur_mask;
+	u8 roce_pri;
+#define BNXT_QPLIB_CC_PARAM_MASK_VLAN_TX_DISABLE	0x40000
+#define BNXT_QPLIB_CC_PARAM_MASK_ROCE_PRI		0x80000
+	/* prev value to clear dscp table */
+	u8 prev_roce_pri;
+	u8 prev_alt_vlan_pcp;
+	u8 prev_tos_dscp;
+	u16 prev_alt_tos_dscp;
+	/* To track if admin has enabled ECN explicitly */
+	u8 admin_enable;
+};
+
+struct bnxt_qplib_roce_stats {
+	u64 to_retransmits;
+	u64 seq_err_naks_rcvd;
+	/* seq_err_naks_rcvd is 64 b */
+	u64 max_retry_exceeded;
+	/* max_retry_exceeded is 64 b */
+	u64 rnr_naks_rcvd;
+	/* rnr_naks_rcvd is 64 b */
+	u64 missing_resp;
+	u64 unrecoverable_err;
+	/* unrecoverable_err is 64 b */
+	u64 bad_resp_err;
+	/* bad_resp_err is 64 b */
+	u64 local_qp_op_err;
+	/* local_qp_op_err is 64 b */
+	u64 local_protection_err;
+	/* local_protection_err is 64 b */
+	u64 mem_mgmt_op_err;
+	/* mem_mgmt_op_err is 64 b */
+	u64 remote_invalid_req_err;
+	/* remote_invalid_req_err is 64 b */
+	u64 remote_access_err;
+	/* remote_access_err is 64 b */
+	u64 remote_op_err;
+	/* remote_op_err is 64 b */
+	u64 dup_req;
+	/* dup_req is 64 b */
+	u64 res_exceed_max;
+	/* res_exceed_max is 64 b */
+	u64 res_length_mismatch;
+	/* res_length_mismatch is 64 b */
+	u64 res_exceeds_wqe;
+	/* res_exceeds_wqe is 64 b */
+	u64 res_opcode_err;
+	/* res_opcode_err is 64 b */
+	u64 res_rx_invalid_rkey;
+	/* res_rx_invalid_rkey is 64 b */
+	u64 res_rx_domain_err;
+	/* res_rx_domain_err is 64 b */
+	u64 res_rx_no_perm;
+	/* res_rx_no_perm is 64 b */
+	u64 res_rx_range_err;
+	/* res_rx_range_err is 64 b */
+	u64 res_tx_invalid_rkey;
+	/* res_tx_invalid_rkey is 64 b */
+	u64 res_tx_domain_err;
+	/* res_tx_domain_err is 64 b */
+	u64 res_tx_no_perm;
+	/* res_tx_no_perm is 64 b */
+	u64 res_tx_range_err;
+	/* res_tx_range_err is 64 b */
+	u64 res_irrq_oflow;
+	/* res_irrq_oflow is 64 b */
+	u64 res_unsup_opcode;
+	/* res_unsup_opcode is 64 b */
+	u64 res_unaligned_atomic;
+	/* res_unaligned_atomic is 64 b */
+	u64 res_rem_inv_err;
+	/* res_rem_inv_err is 64 b */
+	u64 res_mem_error;
+	/* res_mem_error is 64 b */
+	u64 res_srq_err;
+	/* res_srq_err is 64 b */
+	u64 res_cmp_err;
+	/* res_cmp_err is 64 b */
+	u64 res_invalid_dup_rkey;
+	/* res_invalid_dup_rkey is 64 b */
+	u64 res_wqe_format_err;
+	/* res_wqe_format_err is 64 b */
+	u64 res_cq_load_err;
+	/* res_cq_load_err is 64 b */
+	u64 res_srq_load_err;
+	/* res_srq_load_err is 64 b */
+	u64 res_tx_pci_err;
+	/* res_tx_pci_err is 64 b */
+	u64 res_rx_pci_err;
+	/* res_rx_pci_err is 64 b */
+	u64 res_oos_drop_count;
+	/* res_oos_drop_count */
+	u64	active_qp_count_p0;
+	/* port 0 active qps */
+	u64	active_qp_count_p1;
+	/* port 1 active qps */
+	u64	active_qp_count_p2;
+	/* port 2 active qps */
+	u64	active_qp_count_p3;
+	/* port 3 active qps */
+};
+
+struct bnxt_qplib_ext_stat {
+	u64  tx_atomic_req;
+	u64  tx_read_req;
+	u64  tx_read_res;
+	u64  tx_write_req;
+	u64  tx_send_req;
+	u64  tx_roce_pkts;
+	u64  tx_roce_bytes;
+	u64  rx_atomic_req;
+	u64  rx_read_req;
+	u64  rx_read_res;
+	u64  rx_write_req;
+	u64  rx_send_req;
+	u64  rx_roce_pkts;
+	u64  rx_roce_bytes;
+	u64  rx_roce_good_pkts;
+	u64  rx_roce_good_bytes;
+	u64  rx_out_of_buffer;
+	u64  rx_out_of_sequence;
+	u64  tx_cnp;
+	u64  rx_cnp;
+	u64  rx_ecn_marked;
+	u64  seq_err_naks_rcvd;
+	u64  rnr_naks_rcvd;
+	u64  missing_resp;
+	u64  to_retransmits;
+	u64  dup_req;
+	u64  rx_dcn_payload_cut;
+	u64  te_bypassed;
+};
+
+#define BNXT_QPLIB_ACCESS_LOCAL_WRITE	(1 << 0)
+#define BNXT_QPLIB_ACCESS_REMOTE_READ	(1 << 1)
+#define BNXT_QPLIB_ACCESS_REMOTE_WRITE	(1 << 2)
+#define BNXT_QPLIB_ACCESS_REMOTE_ATOMIC	(1 << 3)
+#define BNXT_QPLIB_ACCESS_MW_BIND	(1 << 4)
+#define BNXT_QPLIB_ACCESS_ZERO_BASED	(1 << 5)
+#define BNXT_QPLIB_ACCESS_ON_DEMAND	(1 << 6)
+
+int bnxt_qplib_get_sgid(struct bnxt_qplib_res *res,
+			struct bnxt_qplib_sgid_tbl *sgid_tbl, int index,
+			struct bnxt_qplib_gid *gid);
+int bnxt_qplib_del_sgid(struct bnxt_qplib_sgid_tbl *sgid_tbl,
+			struct bnxt_qplib_gid *gid, u16 vlan_id, bool update);
+int bnxt_qplib_add_sgid(struct bnxt_qplib_sgid_tbl *sgid_tbl,
+			const union ib_gid *gid, const u8 *mac, u16 vlan_id,
+			bool update, u32 *index);
+int bnxt_qplib_update_sgid(struct bnxt_qplib_sgid_tbl *sgid_tbl,
+			   struct bnxt_qplib_gid *gid, u16 gid_idx, const u8 *smac);
+int bnxt_qplib_get_dev_attr(struct bnxt_qplib_rcfw *rcfw);
+int bnxt_qplib_set_func_resources(struct bnxt_qplib_res *res);
+int bnxt_qplib_create_ah(struct bnxt_qplib_res *res, struct bnxt_qplib_ah *ah,
+			 bool block);
+int bnxt_qplib_destroy_ah(struct bnxt_qplib_res *res, struct bnxt_qplib_ah *ah,
+			  bool block);
+int bnxt_qplib_alloc_mrw(struct bnxt_qplib_res *res, struct bnxt_qplib_mrw *mrw);
+int bnxt_qplib_dereg_mrw(struct bnxt_qplib_res *res, struct bnxt_qplib_mrw *mrw,
+			 bool block);
+int bnxt_qplib_reg_mr(struct bnxt_qplib_res *res,
+		      struct bnxt_qplib_mrinfo *mrinfo, bool block);
+int bnxt_qplib_free_mrw(struct bnxt_qplib_res *res, struct bnxt_qplib_mrw *mr);
+int bnxt_qplib_alloc_fast_reg_mr(struct bnxt_qplib_res *res,
+				 struct bnxt_qplib_mrw *mr, int max);
+int bnxt_qplib_alloc_fast_reg_page_list(struct bnxt_qplib_res *res,
+					struct bnxt_qplib_frpl *frpl, int max);
+void bnxt_qplib_free_fast_reg_page_list(struct bnxt_qplib_res *res,
+					struct bnxt_qplib_frpl *frpl);
+int bnxt_qplib_map_tc2cos(struct bnxt_qplib_res *res, u16 *cids);
+int bnxt_qplib_modify_cc(struct bnxt_qplib_res *res,
+			 struct bnxt_qplib_cc_param *cc_param);
+int bnxt_qplib_query_cc_param(struct bnxt_qplib_res *res,
+			      struct bnxt_qplib_cc_param *cc_param);
+int bnxt_qplib_set_link_aggr_mode(struct bnxt_qplib_res *res,
+				  u8 aggr_mode, u8 member_port_map,
+				  u8 active_port_map, bool aggr_en,
+				  u32 stats_fw_id);
+int bnxt_qplib_get_roce_error_stats(struct bnxt_qplib_rcfw *rcfw,
+				    struct bnxt_qplib_roce_stats *stats,
+				    struct bnxt_qplib_query_stats_info *sinfo);
+int bnxt_qplib_qext_stat(struct bnxt_qplib_rcfw *rcfw, u32 fid,
+			 struct bnxt_qplib_ext_stat *estat,
+			 struct bnxt_qplib_query_stats_info *sinfo);
+static inline void bnxt_re_set_max_gid(u16 *max_sgid);
+bool ib_modify_qp_is_ok_compat(enum ib_qp_state cur_state, enum ib_qp_state next_state,
+			       enum ib_qp_type type, enum ib_qp_attr_mask mask);
+
+#define BNXT_MAX_SQ_SIZE 0xFFFF
+#define BNXT_MAX_VAR_WQE_SIZE 512
+#define BNXT_SGE_SIZE 16
+
+/* PF defines */
+#define BNXT_RE_MAX_QP_SUPPORTED(chip_gen) \
+	chip_gen == BNXT_RE_DEFAULT ? (64 * 1024) : 0
+
+#define BNXT_RE_MAX_MRW_SUPPORTED(chip_gen) \
+	chip_gen == BNXT_RE_DEFAULT ? (256 * 1024) : 0
+
+#define BNXT_RE_MAX_CQ_SUPPORTED(chip_gen) \
+	chip_gen == BNXT_RE_DEFAULT ? (64 * 1024) : 0
+
+#define BNXT_RE_MAX_SRQ_SUPPORTED(chip_gen) \
+	chip_gen == BNXT_RE_DEFAULT ? (4 * 1024) : 0
+
+#define BNXT_RE_MAX_AH_SUPPORTED(chip_gen) \
+	chip_gen == BNXT_RE_DEFAULT ? (64 * 1024) : 0
+
+/* VF defines */
+#define BNXT_RE_VF_MAX_QP_SUPPORTED(chip_gen) \
+	chip_gen == BNXT_RE_DEFAULT ? (6 * 1024) : 0
+
+#define BNXT_RE_VF_MAX_MRW_SUPPORTED(chip_gen) \
+	chip_gen == BNXT_RE_DEFAULT ? (6 * 1024) : 0
+
+#define BNXT_RE_VF_MAX_CQ_SUPPORTED(chip_gen) \
+	chip_gen == BNXT_RE_DEFAULT ? (6 * 1024) : 0
+
+#define BNXT_RE_VF_MAX_SRQ_SUPPORTED(chip_gen) \
+	chip_gen == BNXT_RE_DEFAULT ? (4 * 1024) : 0
+
+static inline void bnxt_re_set_max_gid(u16 *max_sgid)
+{
+	*max_sgid = max_t(u32, 256, *max_sgid);
+	*max_sgid = min_t(u32, 256, *max_sgid);
+}
+
+#endif
diff --git a/sys/dev/bnxt/bnxt_re/qplib_tlv.h b/sys/dev/bnxt/bnxt_re/qplib_tlv.h
new file mode 100644
index 000000000000..eeaea41a37e6
--- /dev/null
+++ b/sys/dev/bnxt/bnxt_re/qplib_tlv.h
@@ -0,0 +1,187 @@
+/*
+ * Copyright (c) 2017 - 2024, Broadcom. All rights reserved.  The term
+ * Broadcom refers to Broadcom Limited and/or its subsidiaries.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef __QPLIB_TLV_H__
+#define __QPLIB_TLV_H__
+
+struct roce_tlv {
+	struct tlv tlv;
+	u8 total_size;
+	u8 unused[7];
+};
+
+#define CHUNK_SIZE 16
+#define CHUNKS(x) (((x) + CHUNK_SIZE - 1) / CHUNK_SIZE)
+
+#define ROCE_1ST_TLV_PREP(rtlv, tot_chunks, content_bytes, more)     \
+    do {                                                             \
+	(rtlv)->tlv.cmd_discr = CMD_DISCR_TLV_ENCAP;                 \
+	(rtlv)->tlv.tlv_type = TLV_TYPE_ROCE_SP_COMMAND;             \
+	(rtlv)->tlv.length = (content_bytes);                        \
+	(rtlv)->tlv.flags = TLV_FLAGS_REQUIRED;                      \
+	(rtlv)->tlv.flags |= (more) ? TLV_FLAGS_MORE : 0;            \
+	(rtlv)->total_size = (tot_chunks);                           \
+    } while (0)
+
+#define ROCE_EXT_TLV_PREP(rtlv, ext_type, content_bytes, more, reqd) \
+    do {                                                             \
+	(rtlv)->tlv.cmd_discr = CMD_DISCR_TLV_ENCAP;                 \
+	(rtlv)->tlv.tlv_type = (ext_type);                           \
+	(rtlv)->tlv.length = (content_bytes);                        \
+	(rtlv)->tlv.flags |= (more) ? TLV_FLAGS_MORE : 0;            \
+	(rtlv)->tlv.flags |= (reqd) ? TLV_FLAGS_REQUIRED : 0;        \
+    } while (0)
+
+/*
+ * TLV size in units of 16 byte chunks
+ */
+#define TLV_SIZE ((sizeof(struct roce_tlv) + 15) / 16)
+/*
+ * TLV length in bytes
+ */
+#define TLV_BYTES (TLV_SIZE * 16)
+
+#define HAS_TLV_HEADER(msg) (((struct tlv *)(msg))->cmd_discr == CMD_DISCR_TLV_ENCAP)
+#define GET_TLV_DATA(tlv)   ((void *)&((uint8_t *)(tlv))[TLV_BYTES])
+
+static inline u8 __get_cmdq_base_opcode(struct cmdq_base *req, u32 size)
+{
+	if (HAS_TLV_HEADER(req) && size > TLV_BYTES)
+		return ((struct cmdq_base *)GET_TLV_DATA(req))->opcode;
+	else
+		return req->opcode;
+}
+
+static inline void __set_cmdq_base_opcode(struct cmdq_base *req,
+					  u32 size, u8 val)
+{
+	if (HAS_TLV_HEADER(req) && size > TLV_BYTES)
+		((struct cmdq_base *)GET_TLV_DATA(req))->opcode = val;
+	else
+		req->opcode = val;
+}
+
+static inline __le16 __get_cmdq_base_cookie(struct cmdq_base *req, u32 size)
+{
+	if (HAS_TLV_HEADER(req) && size > TLV_BYTES)
+		return ((struct cmdq_base *)GET_TLV_DATA(req))->cookie;
+	else
+		return req->cookie;
+}
+
+static inline void __set_cmdq_base_cookie(struct cmdq_base *req,
+					  u32 size, __le16 val)
+{
+	if (HAS_TLV_HEADER(req) && size > TLV_BYTES)
+		((struct cmdq_base *)GET_TLV_DATA(req))->cookie = val;
+	else
+		req->cookie = val;
+}
+
+static inline __le64 __get_cmdq_base_resp_addr(struct cmdq_base *req, u32 size)
+{
+	if (HAS_TLV_HEADER(req) && size > TLV_BYTES)
+		return ((struct cmdq_base *)GET_TLV_DATA(req))->resp_addr;
+	else
+		return req->resp_addr;
+}
+
+static inline void __set_cmdq_base_resp_addr(struct cmdq_base *req,
+					     u32 size, __le64 val)
+{
+	if (HAS_TLV_HEADER(req) && size > TLV_BYTES)
+		((struct cmdq_base *)GET_TLV_DATA(req))->resp_addr = val;
+	else
+		req->resp_addr = val;
+}
+
+static inline u8 __get_cmdq_base_resp_size(struct cmdq_base *req, u32 size)
+{
+	if (HAS_TLV_HEADER(req) && size > TLV_BYTES)
+		return ((struct cmdq_base *)GET_TLV_DATA(req))->resp_size;
+	else
+		return req->resp_size;
+}
+
+static inline void __set_cmdq_base_resp_size(struct cmdq_base *req,
+					     u32 size, u8 val)
+{
+	if (HAS_TLV_HEADER(req) && size > TLV_BYTES)
+		((struct cmdq_base *)GET_TLV_DATA(req))->resp_size = val;
+	else
+		req->resp_size = val;
+}
+
+static inline u8 __get_cmdq_base_cmd_size(struct cmdq_base *req, u32 size)
+{
+	if (HAS_TLV_HEADER(req) && size > TLV_BYTES)
+		return ((struct roce_tlv *)(req))->total_size;
+	else
+		return req->cmd_size;
+}
+
+static inline void __set_cmdq_base_cmd_size(struct cmdq_base *req,
+					    u32 size, u8 val)
+{
+	if (HAS_TLV_HEADER(req) && size > TLV_BYTES)
+		((struct cmdq_base *)GET_TLV_DATA(req))->cmd_size = val;
+	else
+		req->cmd_size = val;
+}
+
+static inline __le16 __get_cmdq_base_flags(struct cmdq_base *req, u32 size)
+{
+	if (HAS_TLV_HEADER(req) && size > TLV_BYTES)
+		return ((struct cmdq_base *)GET_TLV_DATA(req))->flags;
+	else
+		return req->flags;
+}
+
+static inline void __set_cmdq_base_flags(struct cmdq_base *req,
+					 u32 size, __le16 val)
+{
+	if (HAS_TLV_HEADER(req) && size > TLV_BYTES)
+		((struct cmdq_base *)GET_TLV_DATA(req))->flags = val;
+	else
+		req->flags = val;
+}
+
+struct bnxt_qplib_tlv_modify_cc_req {
+	struct roce_tlv				tlv_hdr;
+	struct cmdq_modify_roce_cc		base_req;
+	__le64					tlvpad;
+	struct cmdq_modify_roce_cc_gen1_tlv	ext_req;
+};
+
+struct bnxt_qplib_tlv_query_rcc_sb {
+	struct roce_tlv					tlv_hdr;
+	struct creq_query_roce_cc_resp_sb		base_sb;
+	struct creq_query_roce_cc_gen1_resp_sb_tlv	gen1_sb;
+};
+#endif
diff --git a/sys/dev/bnxt/bnxt_re/stats.c b/sys/dev/bnxt/bnxt_re/stats.c
new file mode 100644
index 000000000000..7b0e6097aae6
--- /dev/null
+++ b/sys/dev/bnxt/bnxt_re/stats.c
@@ -0,0 +1,773 @@
+/*
+ * Copyright (c) 2015-2024, Broadcom. All rights reserved.  The term
+ * Broadcom refers to Broadcom Limited and/or its subsidiaries.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Description: statistics related functions
+ */
+
+#include "bnxt_re.h"
+#include "bnxt.h"
+
+int bnxt_re_get_flow_stats_from_service_pf(struct bnxt_re_dev *rdev,
+					   struct bnxt_re_flow_counters *stats,
+					   struct bnxt_qplib_query_stats_info *sinfo)
+{
+	struct hwrm_cfa_flow_stats_output resp = {};
+	struct hwrm_cfa_flow_stats_input req = {};
+	struct bnxt_en_dev *en_dev = rdev->en_dev;
+	struct bnxt_fw_msg fw_msg = {};
+	u16 target_id;
+	int rc = 0;
+
+	if (sinfo->function_id == 0xFFFFFFFF)
+		target_id = -1;
+	else
+		target_id = sinfo->function_id + 1;
+
+	/* Issue HWRM cmd to read flow counters for CNP tx and rx */
+	bnxt_re_init_hwrm_hdr(rdev, (void *)&req, HWRM_CFA_FLOW_STATS, -1, target_id);
+	req.num_flows = cpu_to_le16(6);
+	req.flow_handle_0 = cpu_to_le16(HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_CNP_CNT);
+	req.flow_handle_1 = cpu_to_le16(HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_CNP_CNT |
+					HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_DIR_RX);
+	req.flow_handle_2 = cpu_to_le16(HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_ROCEV1_CNT);
+	req.flow_handle_3 = cpu_to_le16(HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_ROCEV1_CNT |
+					HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_DIR_RX);
+	req.flow_handle_4 = cpu_to_le16(HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_ROCEV2_CNT);
+	req.flow_handle_5 = cpu_to_le16(HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_ROCEV2_CNT |
+					HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_DIR_RX);
+	bnxt_re_fill_fw_msg(&fw_msg, &req, sizeof(req), &resp,
+			    sizeof(resp), BNXT_RE_HWRM_CMD_TIMEOUT(rdev));
+	rc = en_dev->en_ops->bnxt_send_fw_msg(en_dev, BNXT_ROCE_ULP, &fw_msg);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev),
+			"Failed to get CFA Flow stats : rc = 0x%x\n", rc);
+		return rc;
+	}
+
+	stats->cnp_stats.cnp_tx_pkts = le64_to_cpu(resp.packet_0);
+	stats->cnp_stats.cnp_tx_bytes = le64_to_cpu(resp.byte_0);
+	stats->cnp_stats.cnp_rx_pkts = le64_to_cpu(resp.packet_1);
+	stats->cnp_stats.cnp_rx_bytes = le64_to_cpu(resp.byte_1);
+
+	stats->ro_stats.tx_pkts = le64_to_cpu(resp.packet_2) +
+		le64_to_cpu(resp.packet_4);
+	stats->ro_stats.tx_bytes = le64_to_cpu(resp.byte_2) +
+		le64_to_cpu(resp.byte_4);
+	stats->ro_stats.rx_pkts = le64_to_cpu(resp.packet_3) +
+		le64_to_cpu(resp.packet_5);
+	stats->ro_stats.rx_bytes = le64_to_cpu(resp.byte_3) +
+		le64_to_cpu(resp.byte_5);
+
+	return 0;
+}
+
+int bnxt_re_get_qos_stats(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_re_ro_counters roce_only_tmp[2] = {{}, {}};
+	struct bnxt_re_cnp_counters tmp_counters[2] = {{}, {}};
+	struct hwrm_cfa_flow_stats_output resp = {};
+	struct hwrm_cfa_flow_stats_input req = {};
+	struct bnxt_en_dev *en_dev = rdev->en_dev;
+	struct bnxt_fw_msg fw_msg = {};
+	struct bnxt_re_cc_stat *cnps;
+	struct bnxt_re_rstat *dstat;
+	int rc = 0;
+	u64 bytes;
+	u64 pkts;
+
+	/* Issue HWRM cmd to read flow counters for CNP tx and rx */
+	bnxt_re_init_hwrm_hdr(rdev, (void *)&req, HWRM_CFA_FLOW_STATS, -1, -1);
+	req.num_flows = cpu_to_le16(6);
+	req.flow_handle_0 = cpu_to_le16(HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_CNP_CNT);
+	req.flow_handle_1 = cpu_to_le16(HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_CNP_CNT |
+					HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_DIR_RX);
+	req.flow_handle_2 = cpu_to_le16(HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_ROCEV1_CNT);
+	req.flow_handle_3 = cpu_to_le16(HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_ROCEV1_CNT |
+					HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_DIR_RX);
+	req.flow_handle_4 = cpu_to_le16(HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_ROCEV2_CNT);
+	req.flow_handle_5 = cpu_to_le16(HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_ROCEV2_CNT |
+				       HWRM_CFA_FLOW_INFO_INPUT_FLOW_HANDLE_DIR_RX);
+	bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
+			    sizeof(resp), BNXT_RE_HWRM_CMD_TIMEOUT(rdev));
+	rc = en_dev->en_ops->bnxt_send_fw_msg(en_dev, BNXT_ROCE_ULP, &fw_msg);
+	if (rc) {
+		dev_err(rdev_to_dev(rdev),
+			"Failed to get CFA Flow stats : rc = 0x%x\n", rc);
+		goto done;
+	}
+
+	tmp_counters[0].cnp_tx_pkts = le64_to_cpu(resp.packet_0);
+	tmp_counters[0].cnp_tx_bytes = le64_to_cpu(resp.byte_0);
+	tmp_counters[0].cnp_rx_pkts = le64_to_cpu(resp.packet_1);
+	tmp_counters[0].cnp_rx_bytes = le64_to_cpu(resp.byte_1);
+
+	roce_only_tmp[0].tx_pkts = le64_to_cpu(resp.packet_2) +
+				   le64_to_cpu(resp.packet_4);
+	roce_only_tmp[0].tx_bytes = le64_to_cpu(resp.byte_2) +
+				    le64_to_cpu(resp.byte_4);
+	roce_only_tmp[0].rx_pkts = le64_to_cpu(resp.packet_3) +
+				   le64_to_cpu(resp.packet_5);
+	roce_only_tmp[0].rx_bytes = le64_to_cpu(resp.byte_3) +
+				    le64_to_cpu(resp.byte_5);
+
+	cnps = &rdev->stats.cnps;
+	dstat = &rdev->stats.dstat;
+	if (!cnps->is_first) {
+		/* First query done.. */
+		cnps->is_first = true;
+		cnps->prev[0].cnp_tx_pkts = tmp_counters[0].cnp_tx_pkts;
+		cnps->prev[0].cnp_tx_bytes = tmp_counters[0].cnp_tx_bytes;
+		cnps->prev[0].cnp_rx_pkts = tmp_counters[0].cnp_rx_pkts;
+		cnps->prev[0].cnp_rx_bytes = tmp_counters[0].cnp_rx_bytes;
+
+		cnps->prev[1].cnp_tx_pkts = tmp_counters[1].cnp_tx_pkts;
+		cnps->prev[1].cnp_tx_bytes = tmp_counters[1].cnp_tx_bytes;
+		cnps->prev[1].cnp_rx_pkts = tmp_counters[1].cnp_rx_pkts;
+		cnps->prev[1].cnp_rx_bytes = tmp_counters[1].cnp_rx_bytes;
+
+		dstat->prev[0].tx_pkts = roce_only_tmp[0].tx_pkts;
+		dstat->prev[0].tx_bytes = roce_only_tmp[0].tx_bytes;
+		dstat->prev[0].rx_pkts = roce_only_tmp[0].rx_pkts;
+		dstat->prev[0].rx_bytes = roce_only_tmp[0].rx_bytes;
+
+		dstat->prev[1].tx_pkts = roce_only_tmp[1].tx_pkts;
+		dstat->prev[1].tx_bytes = roce_only_tmp[1].tx_bytes;
+		dstat->prev[1].rx_pkts = roce_only_tmp[1].rx_pkts;
+		dstat->prev[1].rx_bytes = roce_only_tmp[1].rx_bytes;
+	} else {
+		u64 byte_mask, pkts_mask;
+		u64 diff;
+
+		byte_mask = bnxt_re_get_cfa_stat_mask(rdev->chip_ctx,
+						      BYTE_MASK);
+		pkts_mask = bnxt_re_get_cfa_stat_mask(rdev->chip_ctx,
+						      PKTS_MASK);
+		/*
+		 * Calculate the number of cnp packets and use
+		 * the value to calculate the CRC bytes.
+		 * Multply pkts with 4 and add it to total bytes
+		 */
+		pkts = bnxt_re_stat_diff(tmp_counters[0].cnp_tx_pkts,
+					 &cnps->prev[0].cnp_tx_pkts,
+					 pkts_mask);
+		cnps->cur[0].cnp_tx_pkts += pkts;
+		diff = bnxt_re_stat_diff(tmp_counters[0].cnp_tx_bytes,
+					 &cnps->prev[0].cnp_tx_bytes,
+					 byte_mask);
+		bytes = diff + pkts * 4;
+		cnps->cur[0].cnp_tx_bytes += bytes;
+		pkts = bnxt_re_stat_diff(tmp_counters[0].cnp_rx_pkts,
+					 &cnps->prev[0].cnp_rx_pkts,
+					 pkts_mask);
+		cnps->cur[0].cnp_rx_pkts += pkts;
+		bytes = bnxt_re_stat_diff(tmp_counters[0].cnp_rx_bytes,
+					  &cnps->prev[0].cnp_rx_bytes,
+					  byte_mask);
+		cnps->cur[0].cnp_rx_bytes += bytes;
+
+		/*
+		 * Calculate the number of cnp packets and use
+		 * the value to calculate the CRC bytes.
+		 * Multply pkts with 4 and add it to total bytes
+		 */
+		pkts = bnxt_re_stat_diff(tmp_counters[1].cnp_tx_pkts,
+					 &cnps->prev[1].cnp_tx_pkts,
+					 pkts_mask);
+		cnps->cur[1].cnp_tx_pkts += pkts;
+		diff = bnxt_re_stat_diff(tmp_counters[1].cnp_tx_bytes,
+					 &cnps->prev[1].cnp_tx_bytes,
+					 byte_mask);
+		cnps->cur[1].cnp_tx_bytes += diff + pkts * 4;
+		pkts = bnxt_re_stat_diff(tmp_counters[1].cnp_rx_pkts,
+					 &cnps->prev[1].cnp_rx_pkts,
+					 pkts_mask);
+		cnps->cur[1].cnp_rx_pkts += pkts;
+		bytes = bnxt_re_stat_diff(tmp_counters[1].cnp_rx_bytes,
+					  &cnps->prev[1].cnp_rx_bytes,
+					  byte_mask);
+		cnps->cur[1].cnp_rx_bytes += bytes;
+
+		pkts = bnxt_re_stat_diff(roce_only_tmp[0].tx_pkts,
+					 &dstat->prev[0].tx_pkts,
+					 pkts_mask);
+		dstat->cur[0].tx_pkts += pkts;
+		diff = bnxt_re_stat_diff(roce_only_tmp[0].tx_bytes,
+					 &dstat->prev[0].tx_bytes,
+					 byte_mask);
+		dstat->cur[0].tx_bytes += diff + pkts * 4;
+		pkts = bnxt_re_stat_diff(roce_only_tmp[0].rx_pkts,
+					 &dstat->prev[0].rx_pkts,
+					 pkts_mask);
+		dstat->cur[0].rx_pkts += pkts;
+
+		bytes = bnxt_re_stat_diff(roce_only_tmp[0].rx_bytes,
+					  &dstat->prev[0].rx_bytes,
+					  byte_mask);
+		dstat->cur[0].rx_bytes += bytes;
+		pkts = bnxt_re_stat_diff(roce_only_tmp[1].tx_pkts,
+					 &dstat->prev[1].tx_pkts,
+					 pkts_mask);
+		dstat->cur[1].tx_pkts += pkts;
+		diff = bnxt_re_stat_diff(roce_only_tmp[1].tx_bytes,
+					 &dstat->prev[1].tx_bytes,
+					 byte_mask);
+		dstat->cur[1].tx_bytes += diff + pkts * 4;
+		pkts = bnxt_re_stat_diff(roce_only_tmp[1].rx_pkts,
+					 &dstat->prev[1].rx_pkts,
+					 pkts_mask);
+		dstat->cur[1].rx_pkts += pkts;
+		bytes = bnxt_re_stat_diff(roce_only_tmp[1].rx_bytes,
+					  &dstat->prev[1].rx_bytes,
+					  byte_mask);
+		dstat->cur[1].rx_bytes += bytes;
+	}
+done:
+	return rc;
+}
+
+static void bnxt_re_copy_ext_stats(struct bnxt_re_dev *rdev,
+				   u8 indx, struct bnxt_qplib_ext_stat *s)
+{
+	struct bnxt_re_ext_roce_stats *e_errs;
+	struct bnxt_re_cnp_counters *cnp;
+	struct bnxt_re_ext_rstat *ext_d;
+	struct bnxt_re_ro_counters *ro;
+
+	cnp = &rdev->stats.cnps.cur[indx];
+	ro = &rdev->stats.dstat.cur[indx];
+	ext_d = &rdev->stats.dstat.ext_rstat[indx];
+	e_errs = &rdev->stats.dstat.e_errs;
+
+	cnp->cnp_tx_pkts = s->tx_cnp;
+	cnp->cnp_rx_pkts = s->rx_cnp;
+	/* In bonding mode do not duplicate other stats */
+	if (indx)
+		return;
+	cnp->ecn_marked = s->rx_ecn_marked;
+
+	ro->tx_pkts = s->tx_roce_pkts;
+	ro->tx_bytes = s->tx_roce_bytes;
+	ro->rx_pkts = s->rx_roce_pkts;
+	ro->rx_bytes = s->rx_roce_bytes;
+
+	ext_d->tx.atomic_req = s->tx_atomic_req;
+	ext_d->tx.read_req = s->tx_read_req;
+	ext_d->tx.read_resp = s->tx_read_res;
+	ext_d->tx.write_req = s->tx_write_req;
+	ext_d->tx.send_req = s->tx_send_req;
+	ext_d->rx.atomic_req = s->rx_atomic_req;
+	ext_d->rx.read_req = s->rx_read_req;
+	ext_d->rx.read_resp = s->rx_read_res;
+	ext_d->rx.write_req = s->rx_write_req;
+	ext_d->rx.send_req = s->rx_send_req;
+	ext_d->grx.rx_pkts = s->rx_roce_good_pkts;
+	ext_d->grx.rx_bytes = s->rx_roce_good_bytes;
+	ext_d->rx_dcn_payload_cut = s->rx_dcn_payload_cut;
+	ext_d->te_bypassed = s->te_bypassed;
+	e_errs->oob = s->rx_out_of_buffer;
+	e_errs->oos = s->rx_out_of_sequence;
+	e_errs->seq_err_naks_rcvd = s->seq_err_naks_rcvd;
+	e_errs->rnr_naks_rcvd = s->rnr_naks_rcvd;
+	e_errs->missing_resp = s->missing_resp;
+	e_errs->to_retransmits = s->to_retransmits;
+	e_errs->dup_req = s->dup_req;
+}
+
+static int bnxt_re_get_ext_stat(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_qplib_ext_stat estat[2] = {{}, {}};
+	struct bnxt_qplib_query_stats_info sinfo;
+	u32 fid;
+	int rc;
+
+	fid = PCI_FUNC(rdev->en_dev->pdev->devfn);
+	/* Set default values for sinfo */
+	sinfo.function_id = 0xFFFFFFFF;
+	sinfo.collection_id = 0xFF;
+	sinfo.vf_valid  = false;
+	rc = bnxt_qplib_qext_stat(&rdev->rcfw, fid, &estat[0], &sinfo);
+	if (rc)
+		goto done;
+	bnxt_re_copy_ext_stats(rdev, 0, &estat[0]);
+
+done:
+	return rc;
+}
+
+static void bnxt_re_copy_rstat(struct bnxt_re_rdata_counters *d,
+			       struct ctx_hw_stats_ext *s,
+			       bool is_thor)
+{
+	d->tx_ucast_pkts = le64_to_cpu(s->tx_ucast_pkts);
+	d->tx_mcast_pkts = le64_to_cpu(s->tx_mcast_pkts);
+	d->tx_bcast_pkts = le64_to_cpu(s->tx_bcast_pkts);
+	d->tx_discard_pkts = le64_to_cpu(s->tx_discard_pkts);
+	d->tx_error_pkts = le64_to_cpu(s->tx_error_pkts);
+	d->tx_ucast_bytes = le64_to_cpu(s->tx_ucast_bytes);
+	/* Add four bytes of CRC bytes per packet */
+	d->tx_ucast_bytes +=  d->tx_ucast_pkts * 4;
+	d->tx_mcast_bytes = le64_to_cpu(s->tx_mcast_bytes);
+	d->tx_bcast_bytes = le64_to_cpu(s->tx_bcast_bytes);
+	d->rx_ucast_pkts = le64_to_cpu(s->rx_ucast_pkts);
+	d->rx_mcast_pkts = le64_to_cpu(s->rx_mcast_pkts);
+	d->rx_bcast_pkts = le64_to_cpu(s->rx_bcast_pkts);
+	d->rx_discard_pkts = le64_to_cpu(s->rx_discard_pkts);
+	d->rx_error_pkts = le64_to_cpu(s->rx_error_pkts);
+	d->rx_ucast_bytes = le64_to_cpu(s->rx_ucast_bytes);
+	d->rx_mcast_bytes = le64_to_cpu(s->rx_mcast_bytes);
+	d->rx_bcast_bytes = le64_to_cpu(s->rx_bcast_bytes);
+	if (is_thor) {
+		d->rx_agg_pkts = le64_to_cpu(s->rx_tpa_pkt);
+		d->rx_agg_bytes = le64_to_cpu(s->rx_tpa_bytes);
+		d->rx_agg_events = le64_to_cpu(s->rx_tpa_events);
+		d->rx_agg_aborts = le64_to_cpu(s->rx_tpa_errors);
+	}
+}
+
+static void bnxt_re_get_roce_data_stats(struct bnxt_re_dev *rdev)
+{
+	bool is_thor = _is_chip_gen_p5_p7(rdev->chip_ctx);
+	struct bnxt_re_rdata_counters *rstat;
+
+	rstat = &rdev->stats.dstat.rstat[0];
+	bnxt_re_copy_rstat(rstat, rdev->qplib_res.hctx->stats.dma, is_thor);
+
+}
+
+int bnxt_re_get_device_stats(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_qplib_query_stats_info sinfo;
+	int rc = 0;
+
+	/* Stats are in 1s cadence */
+	if (test_bit(BNXT_RE_FLAG_ISSUE_CFA_FLOW_STATS, &rdev->flags)) {
+		if (bnxt_ext_stats_supported(rdev->chip_ctx, rdev->dev_attr->dev_cap_flags,
+					     rdev->is_virtfn))
+			rc = bnxt_re_get_ext_stat(rdev);
+		else
+			rc = bnxt_re_get_qos_stats(rdev);
+
+		if (rc && rc != -ENOMEM)
+			clear_bit(BNXT_RE_FLAG_ISSUE_CFA_FLOW_STATS,
+				  &rdev->flags);
+	}
+
+	if (test_bit(BNXT_RE_FLAG_ISSUE_ROCE_STATS, &rdev->flags)) {
+		bnxt_re_get_roce_data_stats(rdev);
+
+		/* Set default values for sinfo */
+		sinfo.function_id = 0xFFFFFFFF;
+		sinfo.collection_id = 0xFF;
+		sinfo.vf_valid  = false;
+		rc = bnxt_qplib_get_roce_error_stats(&rdev->rcfw,
+						     &rdev->stats.dstat.errs,
+						     &sinfo);
+		if (rc && rc != -ENOMEM)
+			clear_bit(BNXT_RE_FLAG_ISSUE_ROCE_STATS,
+				  &rdev->flags);
+	}
+
+	return rc;
+}
+
+static const char * const bnxt_re_stat_descs[] = {
+	"link_state",
+	"max_qp",
+	"max_srq",
+	"max_cq",
+	"max_mr",
+	"max_mw",
+	"max_ah",
+	"max_pd",
+	"active_qp",
+	"active_rc_qp",
+	"active_ud_qp",
+	"active_srq",
+	"active_cq",
+	"active_mr",
+	"active_mw",
+	"active_ah",
+	"active_pd",
+	"qp_watermark",
+	"rc_qp_watermark",
+	"ud_qp_watermark",
+	"srq_watermark",
+	"cq_watermark",
+	"mr_watermark",
+	"mw_watermark",
+	"ah_watermark",
+	"pd_watermark",
+	"resize_cq_count",
+	"hw_retransmission",
+	"recoverable_errors",
+	"rx_pkts",
+	"rx_bytes",
+	"tx_pkts",
+	"tx_bytes",
+	"cnp_tx_pkts",
+	"cnp_tx_bytes",
+	"cnp_rx_pkts",
+	"cnp_rx_bytes",
+	"roce_only_rx_pkts",
+	"roce_only_rx_bytes",
+	"roce_only_tx_pkts",
+	"roce_only_tx_bytes",
+	"rx_roce_error_pkts",
+	"rx_roce_discard_pkts",
+	"tx_roce_error_pkts",
+	"tx_roce_discards_pkts",
+	"res_oob_drop_count",
+	"tx_atomic_req",
+	"rx_atomic_req",
+	"tx_read_req",
+	"tx_read_resp",
+	"rx_read_req",
+	"rx_read_resp",
+	"tx_write_req",
+	"rx_write_req",
+	"tx_send_req",
+	"rx_send_req",
+	"rx_good_pkts",
+	"rx_good_bytes",
+	"rx_dcn_payload_cut",
+	"te_bypassed",
+	"rx_ecn_marked_pkts",
+	"max_retry_exceeded",
+	"to_retransmits",
+	"seq_err_naks_rcvd",
+	"rnr_naks_rcvd",
+	"missing_resp",
+	"dup_reqs",
+	"unrecoverable_err",
+	"bad_resp_err",
+	"local_qp_op_err",
+	"local_protection_err",
+	"mem_mgmt_op_err",
+	"remote_invalid_req_err",
+	"remote_access_err",
+	"remote_op_err",
+	"res_exceed_max",
+	"res_length_mismatch",
+	"res_exceeds_wqe",
+	"res_opcode_err",
+	"res_rx_invalid_rkey",
+	"res_rx_domain_err",
+	"res_rx_no_perm",
+	"res_rx_range_err",
+	"res_tx_invalid_rkey",
+	"res_tx_domain_err",
+	"res_tx_no_perm",
+	"res_tx_range_err",
+	"res_irrq_oflow",
+	"res_unsup_opcode",
+	"res_unaligned_atomic",
+	"res_rem_inv_err",
+	"res_mem_error64",
+	"res_srq_err",
+	"res_cmp_err",
+	"res_invalid_dup_rkey",
+	"res_wqe_format_err",
+	"res_cq_load_err",
+	"res_srq_load_err",
+	"res_tx_pci_err",
+	"res_rx_pci_err",
+	"res_oos_drop_count",
+	"num_irq_started",
+	"num_irq_stopped",
+	"poll_in_intr_en",
+	"poll_in_intr_dis",
+	"cmdq_full_dbg_cnt",
+	"fw_service_prof_type_sup",
+	"dbq_int_recv",
+	"dbq_int_en",
+	"dbq_pacing_resched",
+	"dbq_pacing_complete",
+	"dbq_pacing_alerts",
+	"dbq_dbr_fifo_reg"
+
+};
+
+static void bnxt_re_print_ext_stat(struct bnxt_re_dev *rdev,
+				   struct rdma_hw_stats *stats)
+{
+	struct bnxt_re_cnp_counters *cnp;
+	struct bnxt_re_ext_rstat *ext_s;
+
+	ext_s = &rdev->stats.dstat.ext_rstat[0];
+	cnp = &rdev->stats.cnps.cur[0];
+
+	stats->value[BNXT_RE_TX_ATOMIC_REQ] = ext_s->tx.atomic_req;
+	stats->value[BNXT_RE_RX_ATOMIC_REQ] = ext_s->rx.atomic_req;
+	stats->value[BNXT_RE_TX_READ_REQ] = ext_s->tx.read_req;
+	stats->value[BNXT_RE_TX_READ_RESP] = ext_s->tx.read_resp;
+	stats->value[BNXT_RE_RX_READ_REQ] = ext_s->rx.read_req;
+	stats->value[BNXT_RE_RX_READ_RESP] = ext_s->rx.read_resp;
+	stats->value[BNXT_RE_TX_WRITE_REQ] = ext_s->tx.write_req;
+	stats->value[BNXT_RE_RX_WRITE_REQ] = ext_s->rx.write_req;
+	stats->value[BNXT_RE_TX_SEND_REQ] = ext_s->tx.send_req;
+	stats->value[BNXT_RE_RX_SEND_REQ] = ext_s->rx.send_req;
+	stats->value[BNXT_RE_RX_GOOD_PKTS] = ext_s->grx.rx_pkts;
+	stats->value[BNXT_RE_RX_GOOD_BYTES] = ext_s->grx.rx_bytes;
+	if (_is_chip_p7(rdev->chip_ctx)) {
+		stats->value[BNXT_RE_RX_DCN_PAYLOAD_CUT] = ext_s->rx_dcn_payload_cut;
+		stats->value[BNXT_RE_TE_BYPASSED] = ext_s->te_bypassed;
+	}
+	stats->value[BNXT_RE_RX_ECN_MARKED_PKTS] = cnp->ecn_marked;
+}
+
+static void bnxt_re_print_roce_only_counters(struct bnxt_re_dev *rdev,
+					     struct rdma_hw_stats *stats)
+{
+	struct bnxt_re_ro_counters *roce_only = &rdev->stats.dstat.cur[0];
+
+	stats->value[BNXT_RE_ROCE_ONLY_RX_PKTS] = roce_only->rx_pkts;
+	stats->value[BNXT_RE_ROCE_ONLY_RX_BYTES] = roce_only->rx_bytes;
+	stats->value[BNXT_RE_ROCE_ONLY_TX_PKTS] = roce_only->tx_pkts;
+	stats->value[BNXT_RE_ROCE_ONLY_TX_BYTES] = roce_only->tx_bytes;
+}
+
+static void bnxt_re_print_normal_total_counters(struct bnxt_re_dev *rdev,
+						struct rdma_hw_stats *stats)
+{
+	struct bnxt_re_ro_counters *roce_only;
+	struct bnxt_re_cc_stat *cnps;
+
+	cnps = &rdev->stats.cnps;
+	roce_only = &rdev->stats.dstat.cur[0];
+
+	stats->value[BNXT_RE_RX_PKTS] = cnps->cur[0].cnp_rx_pkts + roce_only->rx_pkts;
+	stats->value[BNXT_RE_RX_BYTES] = cnps->cur[0].cnp_rx_bytes + roce_only->rx_bytes;
+	stats->value[BNXT_RE_TX_PKTS] = cnps->cur[0].cnp_tx_pkts + roce_only->tx_pkts;
+	stats->value[BNXT_RE_TX_BYTES] = cnps->cur[0].cnp_tx_bytes + roce_only->tx_bytes;
+}
+
+static void bnxt_re_print_normal_counters(struct bnxt_re_dev *rdev,
+					  struct rdma_hw_stats *rstats)
+{
+	struct bnxt_re_rdata_counters *stats;
+	struct bnxt_re_cc_stat *cnps;
+	bool en_disp;
+
+	stats = &rdev->stats.dstat.rstat[0];
+	cnps = &rdev->stats.cnps;
+	en_disp = !_is_chip_gen_p5_p7(rdev->chip_ctx);
+
+	bnxt_re_print_normal_total_counters(rdev, rstats);
+	if (!rdev->is_virtfn) {
+		rstats->value[BNXT_RE_CNP_TX_PKTS] = cnps->cur[0].cnp_tx_pkts;
+		if (en_disp)
+			rstats->value[BNXT_RE_CNP_TX_BYTES] = cnps->cur[0].cnp_tx_bytes;
+		rstats->value[BNXT_RE_CNP_RX_PKTS] = cnps->cur[0].cnp_rx_pkts;
+		if (en_disp)
+			rstats->value[BNXT_RE_CNP_RX_BYTES] = cnps->cur[0].cnp_rx_bytes;
+	}
+	/* Print RoCE only bytes.. CNP counters include RoCE packets also */
+	bnxt_re_print_roce_only_counters(rdev, rstats);
+
+	rstats->value[BNXT_RE_RX_ROCE_ERROR_PKTS] = stats ? stats->rx_error_pkts : 0;
+	rstats->value[BNXT_RE_RX_ROCE_DISCARD_PKTS] = stats ? stats->rx_discard_pkts : 0;
+	if (!en_disp) {
+		rstats->value[BNXT_RE_TX_ROCE_ERROR_PKTS] = stats ? stats->tx_error_pkts : 0;
+		rstats->value[BNXT_RE_TX_ROCE_DISCARDS_PKTS] = stats ? stats->tx_discard_pkts : 0;
+	}
+
+	if (bnxt_ext_stats_supported(rdev->chip_ctx, rdev->dev_attr->dev_cap_flags,
+				     rdev->is_virtfn)) {
+		rstats->value[BNXT_RE_RES_OOB_DROP_COUNT] = rdev->stats.dstat.e_errs.oob;
+		bnxt_re_print_ext_stat(rdev, rstats);
+	}
+}
+
+static void bnxt_re_copy_db_pacing_stats(struct bnxt_re_dev *rdev,
+					 struct rdma_hw_stats *stats)
+{
+	struct bnxt_re_dbr_sw_stats *dbr_sw_stats = rdev->dbr_sw_stats;
+
+	stats->value[BNXT_RE_DBQ_PACING_RESCHED] = dbr_sw_stats->dbq_pacing_resched;
+	stats->value[BNXT_RE_DBQ_PACING_CMPL] = dbr_sw_stats->dbq_pacing_complete;
+	stats->value[BNXT_RE_DBQ_PACING_ALERT] = dbr_sw_stats->dbq_pacing_alerts;
+	stats->value[BNXT_RE_DBQ_DBR_FIFO_REG] = readl_fbsd(rdev->en_dev->softc,
+						       rdev->dbr_db_fifo_reg_off, 0);
+}
+
+int bnxt_re_get_hw_stats(struct ib_device *ibdev,
+			    struct rdma_hw_stats *stats,
+			    u8 port, int index)
+{
+	struct bnxt_re_dev *rdev = to_bnxt_re_dev(ibdev, ibdev);
+	struct bnxt_re_ext_roce_stats *e_errs;
+	struct bnxt_re_rdata_counters *rstat;
+	struct bnxt_qplib_roce_stats *errs;
+	unsigned long tstamp_diff;
+	struct pci_dev *pdev;
+	int sched_msec;
+	int rc = 0;
+
+	if (!port || !stats)
+		return -EINVAL;
+
+	if (!rdev)
+		return -ENODEV;
+
+	if (!__bnxt_re_is_rdev_valid(rdev)) {
+		return -ENODEV;
+	}
+
+	pdev = rdev->en_dev->pdev;
+	errs = &rdev->stats.dstat.errs;
+	rstat = &rdev->stats.dstat.rstat[0];
+	e_errs = &rdev->stats.dstat.e_errs;
+#define BNXT_RE_STATS_CTX_UPDATE_TIMER	250
+	sched_msec = BNXT_RE_STATS_CTX_UPDATE_TIMER;
+	tstamp_diff = jiffies - rdev->stats.read_tstamp;
+	if (test_bit(BNXT_RE_FLAG_IBDEV_REGISTERED, &rdev->flags)) {
+		if (/* restrict_stats && */ tstamp_diff < msecs_to_jiffies(sched_msec))
+			goto skip_query;
+		rc = bnxt_re_get_device_stats(rdev);
+		if (rc)
+			dev_err(rdev_to_dev(rdev),
+				"Failed to query device stats\n");
+		rdev->stats.read_tstamp = jiffies;
+	}
+
+	if (rdev->dbr_pacing)
+		bnxt_re_copy_db_pacing_stats(rdev, stats);
+
+skip_query:
+
+	if (rdev->netdev)
+		stats->value[BNXT_RE_LINK_STATE] = bnxt_re_link_state(rdev);
+	stats->value[BNXT_RE_MAX_QP] = rdev->dev_attr->max_qp;
+	stats->value[BNXT_RE_MAX_SRQ] = rdev->dev_attr->max_srq;
+	stats->value[BNXT_RE_MAX_CQ] = rdev->dev_attr->max_cq;
+	stats->value[BNXT_RE_MAX_MR] = rdev->dev_attr->max_mr;
+	stats->value[BNXT_RE_MAX_MW] = rdev->dev_attr->max_mw;
+	stats->value[BNXT_RE_MAX_AH] = rdev->dev_attr->max_ah;
+	stats->value[BNXT_RE_MAX_PD] = rdev->dev_attr->max_pd;
+	stats->value[BNXT_RE_ACTIVE_QP] = atomic_read(&rdev->stats.rsors.qp_count);
+	stats->value[BNXT_RE_ACTIVE_RC_QP] = atomic_read(&rdev->stats.rsors.rc_qp_count);
+	stats->value[BNXT_RE_ACTIVE_UD_QP] = atomic_read(&rdev->stats.rsors.ud_qp_count);
+	stats->value[BNXT_RE_ACTIVE_SRQ] = atomic_read(&rdev->stats.rsors.srq_count);
+	stats->value[BNXT_RE_ACTIVE_CQ] = atomic_read(&rdev->stats.rsors.cq_count);
+	stats->value[BNXT_RE_ACTIVE_MR] = atomic_read(&rdev->stats.rsors.mr_count);
+	stats->value[BNXT_RE_ACTIVE_MW] = atomic_read(&rdev->stats.rsors.mw_count);
+	stats->value[BNXT_RE_ACTIVE_AH] = atomic_read(&rdev->stats.rsors.ah_count);
+	stats->value[BNXT_RE_ACTIVE_PD] = atomic_read(&rdev->stats.rsors.pd_count);
+	stats->value[BNXT_RE_QP_WATERMARK] = atomic_read(&rdev->stats.rsors.max_qp_count);
+	stats->value[BNXT_RE_RC_QP_WATERMARK] = atomic_read(&rdev->stats.rsors.max_rc_qp_count);
+	stats->value[BNXT_RE_UD_QP_WATERMARK] = atomic_read(&rdev->stats.rsors.max_ud_qp_count);
+	stats->value[BNXT_RE_SRQ_WATERMARK] = atomic_read(&rdev->stats.rsors.max_srq_count);
+	stats->value[BNXT_RE_CQ_WATERMARK] = atomic_read(&rdev->stats.rsors.max_cq_count);
+	stats->value[BNXT_RE_MR_WATERMARK] = atomic_read(&rdev->stats.rsors.max_mr_count);
+	stats->value[BNXT_RE_MW_WATERMARK] = atomic_read(&rdev->stats.rsors.max_mw_count);
+	stats->value[BNXT_RE_AH_WATERMARK] = atomic_read(&rdev->stats.rsors.max_ah_count);
+	stats->value[BNXT_RE_PD_WATERMARK] = atomic_read(&rdev->stats.rsors.max_pd_count);
+	stats->value[BNXT_RE_RESIZE_CQ_COUNT] = atomic_read(&rdev->stats.rsors.resize_count);
+	stats->value[BNXT_RE_HW_RETRANSMISSION] = BNXT_RE_HW_RETX(rdev->dev_attr->dev_cap_flags) ?  1 : 0;
+	stats->value[BNXT_RE_RECOVERABLE_ERRORS] = rstat ? rstat->tx_bcast_pkts : 0;
+
+	bnxt_re_print_normal_counters(rdev, stats);
+
+
+	stats->value[BNXT_RE_MAX_RETRY_EXCEEDED] = errs->max_retry_exceeded;
+	if (bnxt_ext_stats_supported(rdev->chip_ctx, rdev->dev_attr->dev_cap_flags,
+				     rdev->is_virtfn) &&
+	    _is_hw_retx_supported(rdev->dev_attr->dev_cap_flags)) {
+		stats->value[BNXT_RE_TO_RETRANSMITS] = e_errs->to_retransmits;
+		stats->value[BNXT_RE_SEQ_ERR_NAKS_RCVD] = e_errs->seq_err_naks_rcvd;
+		stats->value[BNXT_RE_RNR_NAKS_RCVD] = e_errs->rnr_naks_rcvd;
+		stats->value[BNXT_RE_MISSING_RESP] = e_errs->missing_resp;
+		stats->value[BNXT_RE_DUP_REQS] = e_errs->dup_req;
+	} else {
+		stats->value[BNXT_RE_TO_RETRANSMITS] = errs->to_retransmits;
+		stats->value[BNXT_RE_SEQ_ERR_NAKS_RCVD] = errs->seq_err_naks_rcvd;
+		stats->value[BNXT_RE_RNR_NAKS_RCVD] = errs->rnr_naks_rcvd;
+		stats->value[BNXT_RE_MISSING_RESP] = errs->missing_resp;
+		stats->value[BNXT_RE_DUP_REQS] = errs->dup_req;
+	}
+
+	stats->value[BNXT_RE_UNRECOVERABLE_ERR] = errs->unrecoverable_err;
+	stats->value[BNXT_RE_BAD_RESP_ERR] = errs->bad_resp_err;
+	stats->value[BNXT_RE_LOCAL_QP_OP_ERR] = errs->local_qp_op_err;
+	stats->value[BNXT_RE_LOCAL_PROTECTION_ERR] = errs->local_protection_err;
+	stats->value[BNXT_RE_MEM_MGMT_OP_ERR] = errs->mem_mgmt_op_err;
+	stats->value[BNXT_RE_REMOTE_INVALID_REQ_ERR] = errs->remote_invalid_req_err;
+	stats->value[BNXT_RE_REMOTE_ACCESS_ERR] = errs->remote_access_err;
+	stats->value[BNXT_RE_REMOTE_OP_ERR] = errs->remote_op_err;
+	stats->value[BNXT_RE_RES_EXCEED_MAX] = errs->res_exceed_max;
+	stats->value[BNXT_RE_RES_LENGTH_MISMATCH] = errs->res_length_mismatch;
+	stats->value[BNXT_RE_RES_EXCEEDS_WQE] = errs->res_exceeds_wqe;
+	stats->value[BNXT_RE_RES_OPCODE_ERR] = errs->res_opcode_err;
+	stats->value[BNXT_RE_RES_RX_INVALID_RKEY] = errs->res_rx_invalid_rkey;
+	stats->value[BNXT_RE_RES_RX_DOMAIN_ERR] = errs->res_rx_domain_err;
+	stats->value[BNXT_RE_RES_RX_NO_PERM] = errs->res_rx_no_perm;
+	stats->value[BNXT_RE_RES_RX_RANGE_ERR] = errs->res_rx_range_err;
+	stats->value[BNXT_RE_RES_TX_INVALID_RKEY] = errs->res_tx_invalid_rkey;
+	stats->value[BNXT_RE_RES_TX_DOMAIN_ERR] = errs->res_tx_domain_err;
+	stats->value[BNXT_RE_RES_TX_NO_PERM] = errs->res_tx_no_perm;
+	stats->value[BNXT_RE_RES_TX_RANGE_ERR] = errs->res_tx_range_err;
+	stats->value[BNXT_RE_RES_IRRQ_OFLOW] = errs->res_irrq_oflow;
+	stats->value[BNXT_RE_RES_UNSUP_OPCODE] = errs->res_unsup_opcode;
+	stats->value[BNXT_RE_RES_UNALIGNED_ATOMIC] = errs->res_unaligned_atomic;
+	stats->value[BNXT_RE_RES_REM_INV_ERR] = errs->res_rem_inv_err;
+	stats->value[BNXT_RE_RES_MEM_ERROR64] = errs->res_mem_error;
+	stats->value[BNXT_RE_RES_SRQ_ERR] = errs->res_srq_err;
+	stats->value[BNXT_RE_RES_CMP_ERR] = errs->res_cmp_err;
+	stats->value[BNXT_RE_RES_INVALID_DUP_RKEY] = errs->res_invalid_dup_rkey;
+	stats->value[BNXT_RE_RES_WQE_FORMAT_ERR] = errs->res_wqe_format_err;
+	stats->value[BNXT_RE_RES_CQ_LOAD_ERR] = errs->res_cq_load_err;
+	stats->value[BNXT_RE_RES_SRQ_LOAD_ERR] = errs->res_srq_load_err;
+	stats->value[BNXT_RE_RES_TX_PCI_ERR] = errs->res_tx_pci_err;
+	stats->value[BNXT_RE_RES_RX_PCI_ERR] = errs->res_rx_pci_err;
+
+
+	if (bnxt_ext_stats_supported(rdev->chip_ctx, rdev->dev_attr->dev_cap_flags,
+				     rdev->is_virtfn)) {
+	stats->value[BNXT_RE_RES_OOS_DROP_COUNT] = e_errs->oos;
+	} else {
+		/* Display on function 0 as OOS counters are chip-wide */
+		if (PCI_FUNC(pdev->devfn) == 0)
+			stats->value[BNXT_RE_RES_OOS_DROP_COUNT] = errs->res_oos_drop_count;
+	}
+	stats->value[BNXT_RE_NUM_IRQ_STARTED] = rdev->rcfw.num_irq_started;
+	stats->value[BNXT_RE_NUM_IRQ_STOPPED] = rdev->rcfw.num_irq_stopped;
+	stats->value[BNXT_RE_POLL_IN_INTR_EN] = rdev->rcfw.poll_in_intr_en;
+	stats->value[BNXT_RE_POLL_IN_INTR_DIS] = rdev->rcfw.poll_in_intr_dis;
+	stats->value[BNXT_RE_CMDQ_FULL_DBG_CNT] = rdev->rcfw.cmdq_full_dbg;
+	if (!rdev->is_virtfn)
+		stats->value[BNXT_RE_FW_SERVICE_PROF_TYPE_SUP] = is_qport_service_type_supported(rdev);
+
+	return ARRAY_SIZE(bnxt_re_stat_descs);
+}
+
+struct rdma_hw_stats *bnxt_re_alloc_hw_port_stats(struct ib_device *ibdev,
+						     u8 port_num)
+{
+	return rdma_alloc_hw_stats_struct(bnxt_re_stat_descs,
+					  ARRAY_SIZE(bnxt_re_stat_descs),
+					  RDMA_HW_STATS_DEFAULT_LIFESPAN);
+}
diff --git a/sys/dev/bnxt/bnxt_re/stats.h b/sys/dev/bnxt/bnxt_re/stats.h
new file mode 100644
index 000000000000..748d8165947b
--- /dev/null
+++ b/sys/dev/bnxt/bnxt_re/stats.h
@@ -0,0 +1,353 @@
+/*
+ * Copyright (c) 2015-2024, Broadcom. All rights reserved.  The term
+ * Broadcom refers to Broadcom Limited and/or its subsidiaries.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Description: statistics related data structures
+ */
+
+#ifndef __STATS_H__
+#define __STATS_H__
+
+#define BNXT_RE_CFA_STAT_BYTES_MASK 0xFFFFFFFFF
+#define BNXT_RE_CFA_STAT_PKTS_MASK 0xFFFFFFF
+enum {
+	BYTE_MASK = 0,
+	PKTS_MASK = 1
+};
+
+struct bnxt_re_cnp_counters {
+	u64	cnp_tx_pkts;
+	u64	cnp_tx_bytes;
+	u64	cnp_rx_pkts;
+	u64	cnp_rx_bytes;
+	u64	ecn_marked;
+};
+
+struct bnxt_re_ro_counters {
+	u64	tx_pkts;
+	u64	tx_bytes;
+	u64	rx_pkts;
+	u64	rx_bytes;
+};
+
+struct bnxt_re_flow_counters {
+	struct bnxt_re_ro_counters ro_stats;
+	struct bnxt_re_cnp_counters cnp_stats;
+};
+
+struct bnxt_re_ext_cntr {
+	u64	atomic_req;
+	u64	read_req;
+	u64	read_resp;
+	u64	write_req;
+	u64	send_req;
+};
+
+struct bnxt_re_ext_good {
+	u64	rx_pkts;
+	u64	rx_bytes;
+};
+
+struct bnxt_re_ext_rstat {
+	struct bnxt_re_ext_cntr tx;
+	struct bnxt_re_ext_cntr rx;
+	struct bnxt_re_ext_good	grx;
+	u64  rx_dcn_payload_cut;
+	u64  te_bypassed;
+};
+
+struct bnxt_re_rdata_counters {
+	u64  tx_ucast_pkts;
+	u64  tx_mcast_pkts;
+	u64  tx_bcast_pkts;
+	u64  tx_discard_pkts;
+	u64  tx_error_pkts;
+	u64  tx_ucast_bytes;
+	u64  tx_mcast_bytes;
+	u64  tx_bcast_bytes;
+	u64  rx_ucast_pkts;
+	u64  rx_mcast_pkts;
+	u64  rx_bcast_pkts;
+	u64  rx_discard_pkts;
+	u64  rx_error_pkts;
+	u64  rx_ucast_bytes;
+	u64  rx_mcast_bytes;
+	u64  rx_bcast_bytes;
+	u64  rx_agg_pkts;
+	u64  rx_agg_bytes;
+	u64  rx_agg_events;
+	u64  rx_agg_aborts;
+};
+
+struct bnxt_re_cc_stat {
+	struct bnxt_re_cnp_counters prev[2];
+	struct bnxt_re_cnp_counters cur[2];
+	bool is_first;
+};
+
+struct bnxt_re_ext_roce_stats {
+	u64	oob;
+	u64	oos;
+	u64	seq_err_naks_rcvd;
+	u64	rnr_naks_rcvd;
+	u64	missing_resp;
+	u64	to_retransmits;
+	u64	dup_req;
+};
+
+struct bnxt_re_rstat {
+	struct bnxt_re_ro_counters	prev[2];
+	struct bnxt_re_ro_counters	cur[2];
+	struct bnxt_re_rdata_counters	rstat[2];
+	struct bnxt_re_ext_rstat	ext_rstat[2];
+	struct bnxt_re_ext_roce_stats	e_errs;
+	struct bnxt_qplib_roce_stats	errs;
+	unsigned long long		prev_oob;
+};
+
+struct bnxt_re_res_cntrs {
+	atomic_t qp_count;
+	atomic_t rc_qp_count;
+	atomic_t ud_qp_count;
+	atomic_t cq_count;
+	atomic_t srq_count;
+	atomic_t mr_count;
+	atomic_t mw_count;
+	atomic_t ah_count;
+	atomic_t pd_count;
+	atomic_t resize_count;
+	atomic_t max_qp_count;
+	atomic_t max_rc_qp_count;
+	atomic_t max_ud_qp_count;
+	atomic_t max_cq_count;
+	atomic_t max_srq_count;
+	atomic_t max_mr_count;
+	atomic_t max_mw_count;
+	atomic_t max_ah_count;
+	atomic_t max_pd_count;
+};
+
+struct bnxt_re_device_stats {
+	struct bnxt_re_rstat            dstat;
+	struct bnxt_re_res_cntrs        rsors;
+	struct bnxt_re_cc_stat          cnps;
+	unsigned long                   read_tstamp;
+	/* To be used in case to disable stats query from worker or change
+	 * query interval. 0 means stats_query disabled.
+	 */
+	u32				stats_query_sec;
+	/* A free running counter to be used along with stats_query_sec to
+	 * decide whether to issue the command to FW.
+	 */
+	u32				stats_query_counter;
+};
+
+static inline u64 bnxt_re_get_cfa_stat_mask(struct bnxt_qplib_chip_ctx *cctx,
+					    bool type)
+{
+	u64 mask;
+
+	if (type == BYTE_MASK) {
+		mask = BNXT_RE_CFA_STAT_BYTES_MASK; /* 36 bits */
+		if (_is_chip_gen_p5_p7(cctx))
+			mask >>= 0x01; /* 35 bits */
+	} else {
+		mask = BNXT_RE_CFA_STAT_PKTS_MASK; /* 28 bits */
+		if (_is_chip_gen_p5_p7(cctx))
+			mask |= (0x10000000ULL); /* 29 bits */
+	}
+
+	return mask;
+}
+
+static inline u64 bnxt_re_stat_diff(u64 cur, u64 *prev, u64 mask)
+{
+	u64 diff;
+
+	if (!cur)
+		return 0;
+	diff = (cur - *prev) & mask;
+	if (diff)
+		*prev = cur;
+	return diff;
+}
+
+static inline void bnxt_re_clear_rsors_stat(struct bnxt_re_res_cntrs *rsors)
+{
+	atomic_set(&rsors->qp_count, 0);
+	atomic_set(&rsors->cq_count, 0);
+	atomic_set(&rsors->srq_count, 0);
+	atomic_set(&rsors->mr_count, 0);
+	atomic_set(&rsors->mw_count, 0);
+	atomic_set(&rsors->ah_count, 0);
+	atomic_set(&rsors->pd_count, 0);
+	atomic_set(&rsors->resize_count, 0);
+	atomic_set(&rsors->max_qp_count, 0);
+	atomic_set(&rsors->max_cq_count, 0);
+	atomic_set(&rsors->max_srq_count, 0);
+	atomic_set(&rsors->max_mr_count, 0);
+	atomic_set(&rsors->max_mw_count, 0);
+	atomic_set(&rsors->max_ah_count, 0);
+	atomic_set(&rsors->max_pd_count, 0);
+	atomic_set(&rsors->max_rc_qp_count, 0);
+	atomic_set(&rsors->max_ud_qp_count, 0);
+}
+
+enum bnxt_re_hw_stats {
+	BNXT_RE_LINK_STATE,
+	BNXT_RE_MAX_QP,
+	BNXT_RE_MAX_SRQ,
+	BNXT_RE_MAX_CQ,
+	BNXT_RE_MAX_MR,
+	BNXT_RE_MAX_MW,
+	BNXT_RE_MAX_AH,
+	BNXT_RE_MAX_PD,
+	BNXT_RE_ACTIVE_QP,
+	BNXT_RE_ACTIVE_RC_QP,
+	BNXT_RE_ACTIVE_UD_QP,
+	BNXT_RE_ACTIVE_SRQ,
+	BNXT_RE_ACTIVE_CQ,
+	BNXT_RE_ACTIVE_MR,
+	BNXT_RE_ACTIVE_MW,
+	BNXT_RE_ACTIVE_AH,
+	BNXT_RE_ACTIVE_PD,
+	BNXT_RE_QP_WATERMARK,
+	BNXT_RE_RC_QP_WATERMARK,
+	BNXT_RE_UD_QP_WATERMARK,
+	BNXT_RE_SRQ_WATERMARK,
+	BNXT_RE_CQ_WATERMARK,
+	BNXT_RE_MR_WATERMARK,
+	BNXT_RE_MW_WATERMARK,
+	BNXT_RE_AH_WATERMARK,
+	BNXT_RE_PD_WATERMARK,
+	BNXT_RE_RESIZE_CQ_COUNT,
+	BNXT_RE_HW_RETRANSMISSION,
+	BNXT_RE_RECOVERABLE_ERRORS,
+	BNXT_RE_RX_PKTS,
+	BNXT_RE_RX_BYTES,
+	BNXT_RE_TX_PKTS,
+	BNXT_RE_TX_BYTES,
+	BNXT_RE_CNP_TX_PKTS,
+	BNXT_RE_CNP_TX_BYTES,
+	BNXT_RE_CNP_RX_PKTS,
+	BNXT_RE_CNP_RX_BYTES,
+	BNXT_RE_ROCE_ONLY_RX_PKTS,
+	BNXT_RE_ROCE_ONLY_RX_BYTES,
+	BNXT_RE_ROCE_ONLY_TX_PKTS,
+	BNXT_RE_ROCE_ONLY_TX_BYTES,
+	BNXT_RE_RX_ROCE_ERROR_PKTS,
+	BNXT_RE_RX_ROCE_DISCARD_PKTS,
+	BNXT_RE_TX_ROCE_ERROR_PKTS,
+	BNXT_RE_TX_ROCE_DISCARDS_PKTS,
+	BNXT_RE_RES_OOB_DROP_COUNT,
+	BNXT_RE_TX_ATOMIC_REQ,
+	BNXT_RE_RX_ATOMIC_REQ,
+	BNXT_RE_TX_READ_REQ,
+	BNXT_RE_TX_READ_RESP,
+	BNXT_RE_RX_READ_REQ,
+	BNXT_RE_RX_READ_RESP,
+	BNXT_RE_TX_WRITE_REQ,
+	BNXT_RE_RX_WRITE_REQ,
+	BNXT_RE_TX_SEND_REQ,
+	BNXT_RE_RX_SEND_REQ,
+	BNXT_RE_RX_GOOD_PKTS,
+	BNXT_RE_RX_GOOD_BYTES,
+	BNXT_RE_RX_DCN_PAYLOAD_CUT,
+	BNXT_RE_TE_BYPASSED,
+	BNXT_RE_RX_ECN_MARKED_PKTS,
+	BNXT_RE_MAX_RETRY_EXCEEDED,
+	BNXT_RE_TO_RETRANSMITS,
+	BNXT_RE_SEQ_ERR_NAKS_RCVD,
+	BNXT_RE_RNR_NAKS_RCVD,
+	BNXT_RE_MISSING_RESP,
+	BNXT_RE_DUP_REQS,
+	BNXT_RE_UNRECOVERABLE_ERR,
+	BNXT_RE_BAD_RESP_ERR,
+	BNXT_RE_LOCAL_QP_OP_ERR,
+	BNXT_RE_LOCAL_PROTECTION_ERR,
+	BNXT_RE_MEM_MGMT_OP_ERR,
+	BNXT_RE_REMOTE_INVALID_REQ_ERR,
+	BNXT_RE_REMOTE_ACCESS_ERR,
+	BNXT_RE_REMOTE_OP_ERR,
+	BNXT_RE_RES_EXCEED_MAX,
+	BNXT_RE_RES_LENGTH_MISMATCH,
+	BNXT_RE_RES_EXCEEDS_WQE,
+	BNXT_RE_RES_OPCODE_ERR,
+	BNXT_RE_RES_RX_INVALID_RKEY,
+	BNXT_RE_RES_RX_DOMAIN_ERR,
+	BNXT_RE_RES_RX_NO_PERM,
+	BNXT_RE_RES_RX_RANGE_ERR,
+	BNXT_RE_RES_TX_INVALID_RKEY,
+	BNXT_RE_RES_TX_DOMAIN_ERR,
+	BNXT_RE_RES_TX_NO_PERM,
+	BNXT_RE_RES_TX_RANGE_ERR,
+	BNXT_RE_RES_IRRQ_OFLOW,
+	BNXT_RE_RES_UNSUP_OPCODE,
+	BNXT_RE_RES_UNALIGNED_ATOMIC,
+	BNXT_RE_RES_REM_INV_ERR,
+	BNXT_RE_RES_MEM_ERROR64,
+	BNXT_RE_RES_SRQ_ERR,
+	BNXT_RE_RES_CMP_ERR,
+	BNXT_RE_RES_INVALID_DUP_RKEY,
+	BNXT_RE_RES_WQE_FORMAT_ERR,
+	BNXT_RE_RES_CQ_LOAD_ERR,
+	BNXT_RE_RES_SRQ_LOAD_ERR,
+	BNXT_RE_RES_TX_PCI_ERR,
+	BNXT_RE_RES_RX_PCI_ERR,
+	BNXT_RE_RES_OOS_DROP_COUNT,
+	BNXT_RE_NUM_IRQ_STARTED,
+	BNXT_RE_NUM_IRQ_STOPPED,
+	BNXT_RE_POLL_IN_INTR_EN,
+	BNXT_RE_POLL_IN_INTR_DIS,
+	BNXT_RE_CMDQ_FULL_DBG_CNT,
+	BNXT_RE_FW_SERVICE_PROF_TYPE_SUP,
+	BNXT_RE_DBQ_INT_RECV,
+	BNXT_RE_DBQ_INT_EN,
+	BNXT_RE_DBQ_PACING_RESCHED,
+	BNXT_RE_DBQ_PACING_CMPL,
+	BNXT_RE_DBQ_PACING_ALERT,
+	BNXT_RE_DBQ_DBR_FIFO_REG,
+	BNXT_RE_DBQ_NUM_EXT_COUNTERS
+};
+
+#define BNXT_RE_NUM_STD_COUNTERS (BNXT_RE_OUT_OF_SEQ_ERR + 1)
+
+struct bnxt_re_stats {
+	struct bnxt_qplib_roce_stats    errs;
+	struct bnxt_qplib_ext_stat      ext_stat;
+};
+
+struct rdma_hw_stats *bnxt_re_alloc_hw_port_stats(struct ib_device *ibdev,
+						     u8 port_num);
+int bnxt_re_get_hw_stats(struct ib_device *ibdev,
+			    struct rdma_hw_stats *stats,
+			    u8 port, int index);
+int bnxt_re_get_device_stats(struct bnxt_re_dev *rdev);
+int bnxt_re_get_flow_stats_from_service_pf(struct bnxt_re_dev *rdev,
+				struct bnxt_re_flow_counters *stats,
+				struct bnxt_qplib_query_stats_info *sinfo);
+int bnxt_re_get_qos_stats(struct bnxt_re_dev *rdev);
+#endif /* __STATS_H__ */
diff --git a/sys/dev/bxe/bxe.c b/sys/dev/bxe/bxe.c
index 86e396bad4ae..05bc22c0c981 100644
--- a/sys/dev/bxe/bxe.c
+++ b/sys/dev/bxe/bxe.c
@@ -2489,7 +2489,6 @@ static int
 bxe_probe(device_t dev)
 {
     struct bxe_device_type *t;
-    char *descbuf;
     uint16_t did, sdid, svid, vid;
 
     /* Find our device structure */
@@ -2506,20 +2505,12 @@ bxe_probe(device_t dev)
         if ((vid == t->bxe_vid) && (did == t->bxe_did) &&
             ((svid == t->bxe_svid) || (t->bxe_svid == PCI_ANY_ID)) &&
             ((sdid == t->bxe_sdid) || (t->bxe_sdid == PCI_ANY_ID))) {
-            descbuf = malloc(BXE_DEVDESC_MAX, M_TEMP, M_NOWAIT);
-            if (descbuf == NULL)
-                return (ENOMEM);
-
-            /* Print out the device identity. */
-            snprintf(descbuf, BXE_DEVDESC_MAX,
+            device_set_descf(dev,
                      "%s (%c%d) BXE v:%s", t->bxe_name,
                      (((pci_read_config(dev, PCIR_REVID, 4) &
                         0xf0) >> 4) + 'A'),
                      (pci_read_config(dev, PCIR_REVID, 4) & 0xf),
                      BXE_DRIVER_VERSION);
-
-            device_set_desc_copy(dev, descbuf);
-            free(descbuf, M_TEMP);
             return (BUS_PROBE_DEFAULT);
         }
         t++;
@@ -12974,7 +12965,7 @@ bxe_init(void *xsc)
     BXE_CORE_UNLOCK(sc);
 }
 
-static int
+static void
 bxe_init_ifnet(struct bxe_softc *sc)
 {
     if_t ifp;
@@ -12994,10 +12985,7 @@ bxe_init_ifnet(struct bxe_softc *sc)
 	BLOGI(sc, "IFMEDIA flags : %x\n", sc->ifmedia.ifm_media);
 
     /* allocate the ifnet structure */
-    if ((ifp = if_gethandle(IFT_ETHER)) == NULL) {
-        BLOGE(sc, "Interface allocation failed!\n");
-        return (ENXIO);
-    }
+    ifp = if_gethandle(IFT_ETHER);
 
     if_setsoftc(ifp, sc);
     if_initname(ifp, device_get_name(sc->dev), device_get_unit(sc->dev));
@@ -13043,8 +13031,6 @@ bxe_init_ifnet(struct bxe_softc *sc)
 
     /* Attach driver debugnet methods. */
     DEBUGNET_SET(ifp, bxe);
-
-    return (0);
 }
 
 static void
@@ -16270,12 +16256,7 @@ bxe_attach(device_t dev)
     bxe_get_phy_info(sc);
 
     /* initialize the FreeBSD ifnet interface */
-    if (bxe_init_ifnet(sc) != 0) {
-        bxe_release_mutexes(sc);
-        bxe_deallocate_bars(sc);
-        pci_disable_busmaster(dev);
-        return (ENXIO);
-    }
+    bxe_init_ifnet(sc);
 
     if (bxe_add_cdev(sc) != 0) {
         if (sc->ifp != NULL) {
diff --git a/sys/dev/cadence/if_cgem.c b/sys/dev/cadence/if_cgem.c
index 6e4a62f6e5ee..80b35db73c46 100644
--- a/sys/dev/cadence/if_cgem.c
+++ b/sys/dev/cadence/if_cgem.c
@@ -1814,11 +1814,6 @@ cgem_attach(device_t dev)
 
 	/* Set up ifnet structure. */
 	ifp = sc->ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "could not allocate ifnet structure\n");
-		cgem_detach(dev);
-		return (ENOMEM);
-	}
 	if_setsoftc(ifp, sc);
 	if_initname(ifp, IF_CGEM_NAME, device_get_unit(dev));
 	if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
diff --git a/sys/dev/cas/if_cas.c b/sys/dev/cas/if_cas.c
index 0cf17cf04b33..76d1b713e5bb 100644
--- a/sys/dev/cas/if_cas.c
+++ b/sys/dev/cas/if_cas.c
@@ -188,8 +188,6 @@ cas_attach(struct cas_softc *sc)
 
 	/* Set up ifnet structure. */
 	ifp = sc->sc_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL)
-		return (ENOSPC);
 	if_setsoftc(ifp, sc);
 	if_initname(ifp, device_get_name(sc->sc_dev),
 	    device_get_unit(sc->sc_dev));
diff --git a/sys/dev/cfi/cfi_core.c b/sys/dev/cfi/cfi_core.c
index 4e137140372c..9554a710d8f2 100644
--- a/sys/dev/cfi/cfi_core.c
+++ b/sys/dev/cfi/cfi_core.c
@@ -194,7 +194,6 @@ cfi_fmtsize(uint32_t sz)
 int
 cfi_probe(device_t dev)
 {
-	char desc[80];
 	struct cfi_softc *sc;
 	char *vend_str;
 	int error;
@@ -279,9 +278,7 @@ cfi_probe(device_t dev)
 	if (error)
 		goto out;
 
-	snprintf(desc, sizeof(desc), "%s - %s", vend_str,
-	    cfi_fmtsize(sc->sc_size));
-	device_set_desc_copy(dev, desc);
+	device_set_descf(dev, "%s - %s", vend_str, cfi_fmtsize(sc->sc_size));
 
  out:
 	bus_release_resource(dev, SYS_RES_MEMORY, sc->sc_rid, sc->sc_res);
diff --git a/sys/dev/cxgb/cxgb_main.c b/sys/dev/cxgb/cxgb_main.c
index 1a088cdf0abe..9bcdb86312c4 100644
--- a/sys/dev/cxgb/cxgb_main.c
+++ b/sys/dev/cxgb/cxgb_main.c
@@ -360,7 +360,7 @@ static int
 cxgb_controller_probe(device_t dev)
 {
 	const struct adapter_info *ai;
-	char *ports, buf[80];
+	const char *ports;
 	int nports;
 
 	ai = cxgb_get_adapter_info(dev);
@@ -373,8 +373,7 @@ cxgb_controller_probe(device_t dev)
 	else
 		ports = "ports";
 
-	snprintf(buf, sizeof(buf), "%s, %d %s", ai->desc, nports, ports);
-	device_set_desc_copy(dev, buf);
+	device_set_descf(dev, "%s, %d %s", ai->desc, nports, ports);
 	return (BUS_PROBE_DEFAULT);
 }
 
@@ -447,7 +446,6 @@ cxgb_controller_attach(device_t dev)
 	uint32_t vers;
 	int port_qsets = 1;
 	int msi_needed, reg;
-	char buf[80];
 
 	sc = device_get_softc(dev);
 	sc->dev = dev;
@@ -659,10 +657,9 @@ cxgb_controller_attach(device_t dev)
 	    G_FW_VERSION_MAJOR(vers), G_FW_VERSION_MINOR(vers),
 	    G_FW_VERSION_MICRO(vers));
 
-	snprintf(buf, sizeof(buf), "%s %sNIC\t E/C: %s S/N: %s",
-		 ai->desc, is_offload(sc) ? "R" : "",
-		 sc->params.vpd.ec, sc->params.vpd.sn);
-	device_set_desc_copy(dev, buf);
+	device_set_descf(dev, "%s %sNIC\t E/C: %s S/N: %s",
+	    ai->desc, is_offload(sc) ? "R" : "",
+	    sc->params.vpd.ec, sc->params.vpd.sn);
 
 	snprintf(&sc->port_types[0], sizeof(sc->port_types), "%x%x%x%x",
 		 sc->params.vpd.port_type[0], sc->params.vpd.port_type[1],
@@ -966,13 +963,11 @@ static int
 cxgb_port_probe(device_t dev)
 {
 	struct port_info *p;
-	char buf[80];
 	const char *desc;
 	
 	p = device_get_softc(dev);
 	desc = p->phy.desc;
-	snprintf(buf, sizeof(buf), "Port %d %s", p->port_id, desc);
-	device_set_desc_copy(dev, buf);
+	device_set_descf(dev, "Port %d %s", p->port_id, desc);
 	return (0);
 }
 
@@ -1016,11 +1011,6 @@ cxgb_port_attach(device_t dev)
 
 	/* Allocate an ifnet object and set it up */
 	ifp = p->ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "Cannot allocate ifnet\n");
-		return (ENOMEM);
-	}
-	
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 	if_setinitfn(ifp, cxgb_init);
 	if_setsoftc(ifp, p);
diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h
index b9780809421f..335b1be57b8b 100644
--- a/sys/dev/cxgbe/adapter.h
+++ b/sys/dev/cxgbe/adapter.h
@@ -928,6 +928,7 @@ struct adapter {
 	u_int vxlan_refcount;
 	int rawf_base;
 	int nrawf;
+	u_int vlan_id;
 
 	struct taskqueue *tq[MAX_NCHAN];	/* General purpose taskqueues */
 	struct port_info *port[MAX_NPORTS];
@@ -1363,6 +1364,7 @@ void t4_add_adapter(struct adapter *);
 int t4_detach_common(device_t);
 int t4_map_bars_0_and_4(struct adapter *);
 int t4_map_bar_2(struct adapter *);
+int t4_adj_doorbells(struct adapter *);
 int t4_setup_intr_handlers(struct adapter *);
 void t4_sysctls(struct adapter *);
 int begin_synchronized_op(struct adapter *, struct vi_info *, int, char *);
diff --git a/sys/dev/cxgbe/common/common.h b/sys/dev/cxgbe/common/common.h
index 0861e3df4bee..0871ca8c40f1 100644
--- a/sys/dev/cxgbe/common/common.h
+++ b/sys/dev/cxgbe/common/common.h
@@ -944,6 +944,7 @@ int t4vf_get_vfres(struct adapter *adapter);
 int t4vf_prep_adapter(struct adapter *adapter);
 int t4vf_get_vf_mac(struct adapter *adapter, unsigned int port,
 		    unsigned int *naddr, u8 *addr);
+int t4vf_get_vf_vlan(struct adapter *adapter);
 int t4_bar2_sge_qregs(struct adapter *adapter, unsigned int qid,
 		enum t4_bar2_qtype qtype, int user, u64 *pbar2_qoffset,
 		unsigned int *pbar2_qid);
diff --git a/sys/dev/cxgbe/common/t4_hw.c b/sys/dev/cxgbe/common/t4_hw.c
index c18243e4b681..c428fd2720cd 100644
--- a/sys/dev/cxgbe/common/t4_hw.c
+++ b/sys/dev/cxgbe/common/t4_hw.c
@@ -11466,7 +11466,7 @@ int t4_configure_ringbb(struct adapter *adap)
  *	@vlan: The vlanid to be set
  *
  */
-int t4_set_vlan_acl(struct adapter *adap, unsigned int mbox, unsigned int vf,
+int t4_set_vlan_acl(struct adapter *adap, unsigned int pf, unsigned int vf,
 		    u16 vlan)
 {
 	struct fw_acl_vlan_cmd vlan_cmd;
@@ -11478,9 +11478,10 @@ int t4_set_vlan_acl(struct adapter *adap, unsigned int mbox, unsigned int vf,
 					 F_FW_CMD_REQUEST |
 					 F_FW_CMD_WRITE |
 					 F_FW_CMD_EXEC |
-					 V_FW_ACL_VLAN_CMD_PFN(adap->pf) |
+					 V_FW_ACL_VLAN_CMD_PFN(pf) |
 					 V_FW_ACL_VLAN_CMD_VFN(vf));
-	vlan_cmd.en_to_len16 = cpu_to_be32(enable | FW_LEN16(vlan_cmd));
+	vlan_cmd.en_to_len16 = cpu_to_be32(enable | FW_LEN16(vlan_cmd) |
+					   V_FW_ACL_VLAN_CMD_PMASK(1 << pf));
 	/* Drop all packets that donot match vlan id */
 	vlan_cmd.dropnovlan_fm = (enable
 				  ? (F_FW_ACL_VLAN_CMD_DROPNOVLAN |
diff --git a/sys/dev/cxgbe/common/t4vf_hw.c b/sys/dev/cxgbe/common/t4vf_hw.c
index 25ab3db77c72..8091eb5db2f9 100644
--- a/sys/dev/cxgbe/common/t4vf_hw.c
+++ b/sys/dev/cxgbe/common/t4vf_hw.c
@@ -139,7 +139,10 @@ int t4vf_get_sge_params(struct adapter *adapter)
 	 * This is based on the PF from which we're instantiated.
 	 */
 	whoami = t4_read_reg(adapter, VF_PL_REG(A_PL_VF_WHOAMI));
-	pf = G_SOURCEPF(whoami);
+	if (chip_id(adapter) <= CHELSIO_T5)
+		pf = G_SOURCEPF(whoami);
+	else
+		pf = G_T6_SOURCEPF(whoami);
 
 	s_hps = (S_HOSTPAGESIZEPF0 +
 	    (S_HOSTPAGESIZEPF1 - S_HOSTPAGESIZEPF0) * pf);
@@ -426,3 +429,30 @@ int t4vf_get_vf_mac(struct adapter *adapter, unsigned int port,
 
 	return ret;
 }
+
+/*
+ *	t4vf_get_vf_vlan - Get the VLAN ID to be set to the VI of this VF.
+ *	@adapter: The adapter
+ *
+ *	Find the VLAN ID to be set to the VF's VI. The requested VLAN ID
+ *	is from the host OS via callback in the PF driver.
+ */
+int t4vf_get_vf_vlan(struct adapter *adapter)
+{
+	struct fw_acl_vlan_cmd cmd = {0};
+	int vlan = 0;
+	int ret = 0;
+
+	cmd.op_to_vfn = htonl(V_FW_CMD_OP(FW_ACL_VLAN_CMD) |
+			      F_FW_CMD_REQUEST | F_FW_CMD_READ);
+
+	/* Note: Do not enable the ACL */
+	cmd.en_to_len16 = htonl((unsigned int)FW_LEN16(cmd));
+
+	ret = t4vf_wr_mbox(adapter, &cmd, sizeof(cmd), &cmd);
+
+	if (!ret)
+		vlan = be16_to_cpu(cmd.vlanid[0]);
+
+	return vlan;
+}
diff --git a/sys/dev/cxgbe/t4_iov.c b/sys/dev/cxgbe/t4_iov.c
index 1971c3b15c4f..7f4e80ca020d 100644
--- a/sys/dev/cxgbe/t4_iov.c
+++ b/sys/dev/cxgbe/t4_iov.c
@@ -30,8 +30,12 @@
 #include <sys/bus.h>
 #include <sys/kernel.h>
 #include <sys/module.h>
+#include <sys/socket.h>
 #include <sys/systm.h>
+#include <sys/iov.h>
 #include <dev/pci/pcivar.h>
+#include <net/if.h>
+#include <net/if_vlan_var.h>
 
 #ifdef PCI_IOV
 #include <sys/nv.h>
@@ -258,6 +262,7 @@ t4iov_attach_child(device_t dev)
 	pf_schema = pci_iov_schema_alloc_node();
 	vf_schema = pci_iov_schema_alloc_node();
 	pci_iov_schema_add_unicast_mac(vf_schema, "mac-addr", 0, NULL);
+	pci_iov_schema_add_vlan(vf_schema, "vlan", 0, 0);
 	error = pci_iov_attach_name(dev, pf_schema, vf_schema, "%s",
 	    device_get_nameunit(pdev));
 	if (error) {
@@ -337,14 +342,15 @@ t4iov_add_vf(device_t dev, uint16_t vfnum, const struct nvlist *config)
 	size_t size;
 	int rc;
 
+	sc = device_get_softc(dev);
+	MPASS(sc->sc_attached);
+	MPASS(sc->sc_main != NULL);
+	adap = device_get_softc(sc->sc_main);
+
 	if (nvlist_exists_binary(config, "mac-addr")) {
 		mac = nvlist_get_binary(config, "mac-addr", &size);
 		bcopy(mac, ma, ETHER_ADDR_LEN);
 
-		sc = device_get_softc(dev);
-		MPASS(sc->sc_attached);
-		MPASS(sc->sc_main != NULL);
-		adap = device_get_softc(sc->sc_main);
 		if (begin_synchronized_op(adap, NULL, SLEEP_OK | INTR_OK,
 		    "t4vfma") != 0)
 			return (ENXIO);
@@ -359,6 +365,29 @@ t4iov_add_vf(device_t dev, uint16_t vfnum, const struct nvlist *config)
 		}
 	}
 
+	if (nvlist_exists_number(config, "vlan")) {
+		uint16_t vlan = nvlist_get_number(config, "vlan");
+
+		/* We can't restrict to VID 0 */
+		if (vlan == DOT1Q_VID_NULL)
+			return (ENOTSUP);
+
+		if (vlan == VF_VLAN_TRUNK)
+			vlan = DOT1Q_VID_NULL;
+
+		if (begin_synchronized_op(adap, NULL, SLEEP_OK | INTR_OK,
+		    "t4vfvl") != 0)
+			return (ENXIO);
+		rc = t4_set_vlan_acl(adap, sc->pf, vfnum + 1, vlan);
+		end_synchronized_op(adap, 0);
+		if (rc != 0) {
+			device_printf(dev,
+			    "Failed to set VF%d VLAN to %d, rc = %d\n",
+			    vfnum, vlan, rc);
+			return (rc);
+		}
+	}
+
 	return (0);
 }
 #endif
diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c
index 6cb434295b42..128d2ae65611 100644
--- a/sys/dev/cxgbe/t4_main.c
+++ b/sys/dev/cxgbe/t4_main.c
@@ -604,6 +604,11 @@ static int t5_write_combine = 0;
 SYSCTL_INT(_hw_cxl, OID_AUTO, write_combine, CTLFLAG_RDTUN, &t5_write_combine,
     0, "Use WC instead of UC for BAR2");
 
+/* From t4_sysctls: doorbells = {"\20\1UDB\2WCWR\3UDBWC\4KDB"} */
+static int t4_doorbells_allowed = 0xf;
+SYSCTL_INT(_hw_cxgbe, OID_AUTO, doorbells_allowed, CTLFLAG_RDTUN,
+	   &t4_doorbells_allowed, 0, "Limit tx queues to these doorbells");
+
 static int t4_num_vis = 1;
 SYSCTL_INT(_hw_cxgbe, OID_AUTO, num_vis, CTLFLAG_RDTUN, &t4_num_vis, 0,
     "Number of VIs per port");
@@ -1348,6 +1353,10 @@ t4_attach(device_t dev)
 	if (rc != 0)
 		goto done; /* error message displayed already */
 
+	rc = t4_adj_doorbells(sc);
+	if (rc != 0)
+		goto done; /* error message displayed already */
+
 	rc = t4_create_dma_tag(sc);
 	if (rc != 0)
 		goto done; /* error message displayed already */
@@ -2527,11 +2536,9 @@ reset_adapter_task(void *arg, int pending)
 static int
 cxgbe_probe(device_t dev)
 {
-	char buf[128];
 	struct port_info *pi = device_get_softc(dev);
 
-	snprintf(buf, sizeof(buf), "port %d", pi->port_id);
-	device_set_desc_copy(dev, buf);
+	device_set_descf(dev, "port %d", pi->port_id);
 
 	return (BUS_PROBE_DEFAULT);
 }
@@ -2542,7 +2549,7 @@ cxgbe_probe(device_t dev)
     IFCAP_HWRXTSTMP | IFCAP_MEXTPG)
 #define T4_CAP_ENABLE (T4_CAP)
 
-static int
+static void
 cxgbe_vi_attach(device_t dev, struct vi_info *vi)
 {
 	if_t ifp;
@@ -2581,10 +2588,6 @@ cxgbe_vi_attach(device_t dev, struct vi_info *vi)
 
 	/* Allocate an ifnet and set it up */
 	ifp = if_alloc_dev(IFT_ETHER, dev);
-	if (ifp == NULL) {
-		device_printf(dev, "Cannot allocate ifnet\n");
-		return (ENOMEM);
-	}
 	vi->ifp = ifp;
 	if_setsoftc(ifp, vi);
 
@@ -2687,8 +2690,6 @@ cxgbe_vi_attach(device_t dev, struct vi_info *vi)
 	pa.pa_type = PFIL_TYPE_ETHERNET;
 	pa.pa_headname = if_name(ifp);
 	vi->pfil = pfil_head_register(&pa);
-
-	return (0);
 }
 
 static int
@@ -2697,13 +2698,11 @@ cxgbe_attach(device_t dev)
 	struct port_info *pi = device_get_softc(dev);
 	struct adapter *sc = pi->adapter;
 	struct vi_info *vi;
-	int i, rc;
+	int i;
 
 	sysctl_ctx_init(&pi->ctx);
 
-	rc = cxgbe_vi_attach(dev, &pi->vi[0]);
-	if (rc)
-		return (rc);
+	cxgbe_vi_attach(dev, &pi->vi[0]);
 
 	for_each_vi(pi, i, vi) {
 		if (i == 0)
@@ -3504,12 +3503,10 @@ cxgbe_media_status(if_t ifp, struct ifmediareq *ifmr)
 static int
 vcxgbe_probe(device_t dev)
 {
-	char buf[128];
 	struct vi_info *vi = device_get_softc(dev);
 
-	snprintf(buf, sizeof(buf), "port %d vi %td", vi->pi->port_id,
+	device_set_descf(dev, "port %d vi %td", vi->pi->port_id,
 	    vi - vi->pi->vi);
-	device_set_desc_copy(dev, buf);
 
 	return (BUS_PROBE_DEFAULT);
 }
@@ -3584,11 +3581,8 @@ vcxgbe_attach(device_t dev)
 	if (rc)
 		return (rc);
 
-	rc = cxgbe_vi_attach(dev, vi);
-	if (rc) {
-		t4_free_vi(sc, sc->mbox, sc->pf, 0, vi->viid);
-		return (rc);
-	}
+	cxgbe_vi_attach(dev, vi);
+
 	return (0);
 }
 
@@ -3769,6 +3763,18 @@ t4_map_bar_2(struct adapter *sc)
 	return (0);
 }
 
+int
+t4_adj_doorbells(struct adapter *sc)
+{
+	if ((sc->doorbells & t4_doorbells_allowed) != 0) {
+		sc->doorbells &= t4_doorbells_allowed;
+		return (0);
+	}
+	CH_ERR(sc, "No usable doorbell (available = 0x%x, allowed = 0x%x).\n",
+	       sc->doorbells, t4_doorbells_allowed);
+	return (EINVAL);
+}
+
 struct memwin_init {
 	uint32_t base;
 	uint32_t aperture;
@@ -5760,12 +5766,9 @@ set_params__post_init(struct adapter *sc)
 static void
 t4_set_desc(struct adapter *sc)
 {
-	char buf[128];
 	struct adapter_params *p = &sc->params;
 
-	snprintf(buf, sizeof(buf), "Chelsio %s", p->vpd.id);
-
-	device_set_desc_copy(sc->dev, buf);
+	device_set_descf(sc->dev, "Chelsio %s", p->vpd.id);
 }
 
 static inline void
@@ -6022,25 +6025,27 @@ apply_link_config(struct port_info *pi)
 	if (lc->requested_fec & FEC_BASER_RS)
 		MPASS(lc->pcaps & FW_PORT_CAP32_FEC_BASER_RS);
 #endif
-	rc = -t4_link_l1cfg(sc, sc->mbox, pi->tx_chan, lc);
-	if (rc != 0) {
-		/* Don't complain if the VF driver gets back an EPERM. */
-		if (!(sc->flags & IS_VF) || rc != FW_EPERM)
+	if (!(sc->flags & IS_VF)) {
+		rc = -t4_link_l1cfg(sc, sc->mbox, pi->tx_chan, lc);
+		if (rc != 0) {
 			device_printf(pi->dev, "l1cfg failed: %d\n", rc);
-	} else {
-		/*
-		 * An L1_CFG will almost always result in a link-change event if
-		 * the link is up, and the driver will refresh the actual
-		 * fec/fc/etc. when the notification is processed.  If the link
-		 * is down then the actual settings are meaningless.
-		 *
-		 * This takes care of the case where a change in the L1 settings
-		 * may not result in a notification.
-		 */
-		if (lc->link_ok && !(lc->requested_fc & PAUSE_AUTONEG))
-			lc->fc = lc->requested_fc & (PAUSE_TX | PAUSE_RX);
+			return (rc);
+		}
 	}
-	return (rc);
+
+	/*
+	 * An L1_CFG will almost always result in a link-change event if the
+	 * link is up, and the driver will refresh the actual fec/fc/etc. when
+	 * the notification is processed.  If the link is down then the actual
+	 * settings are meaningless.
+	 *
+	 * This takes care of the case where a change in the L1 settings may not
+	 * result in a notification.
+	 */
+	if (lc->link_ok && !(lc->requested_fc & PAUSE_AUTONEG))
+		lc->fc = lc->requested_fc & (PAUSE_TX | PAUSE_RX);
+
+	return (0);
 }
 
 #define FW_MAC_EXACT_CHUNK	7
diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c
index 2ef05b5a9f86..7008c3c65e02 100644
--- a/sys/dev/cxgbe/t4_sge.c
+++ b/sys/dev/cxgbe/t4_sge.c
@@ -2086,9 +2086,17 @@ eth_rx(struct adapter *sc, struct sge_rxq *rxq, const struct iq_desc *d,
 	}
 
 	if (cpl->vlan_ex) {
-		m0->m_pkthdr.ether_vtag = be16toh(cpl->vlan);
-		m0->m_flags |= M_VLANTAG;
-		rxq->vlan_extraction++;
+		if (sc->flags & IS_VF && sc->vlan_id) {
+			/*
+			 * HW is not setup correctly if extracted vlan_id does
+			 * not match the VF's setting.
+			 */
+			MPASS(be16toh(cpl->vlan) == sc->vlan_id);
+		} else {
+			m0->m_pkthdr.ether_vtag = be16toh(cpl->vlan);
+			m0->m_flags |= M_VLANTAG;
+			rxq->vlan_extraction++;
+		}
 	}
 
 	if (rxq->iq.flags & IQ_RX_TIMESTAMP) {
@@ -5477,7 +5485,8 @@ write_txpkt_vm_wr(struct adapter *sc, struct sge_txq *txq, struct mbuf *m0)
 		ctrl1 |= F_TXPKT_VLAN_VLD |
 		    V_TXPKT_VLAN(m0->m_pkthdr.ether_vtag);
 		txq->vlan_insertion++;
-	}
+	} else if (sc->vlan_id)
+		ctrl1 |= F_TXPKT_VLAN_VLD | V_TXPKT_VLAN(sc->vlan_id);
 
 	/* CPL header */
 	cpl->ctrl0 = txq->cpl_ctrl0;
@@ -5978,7 +5987,8 @@ write_txpkts_vm_wr(struct adapter *sc, struct sge_txq *txq)
 			ctrl1 |= F_TXPKT_VLAN_VLD |
 			    V_TXPKT_VLAN(m->m_pkthdr.ether_vtag);
 			txq->vlan_insertion++;
-		}
+		} else if (sc->vlan_id)
+			ctrl1 |= F_TXPKT_VLAN_VLD | V_TXPKT_VLAN(sc->vlan_id);
 
 		/* CPL header */
 		cpl->ctrl0 = txq->cpl_ctrl0;
diff --git a/sys/dev/cxgbe/t4_tracer.c b/sys/dev/cxgbe/t4_tracer.c
index d9b336c4b64a..80689a543e83 100644
--- a/sys/dev/cxgbe/t4_tracer.c
+++ b/sys/dev/cxgbe/t4_tracer.c
@@ -167,11 +167,6 @@ t4_cloner_create(struct if_clone *ifc, char *name, size_t len, caddr_t params)
 	}
 
 	ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		rc = ENOMEM;
-		goto done;
-	}
-
 	/* Note that if_xname is identical to the nexus nameunit */
 	if_initname(ifp, name, -1);
 	if_setdname(ifp, t4_cloner_name);
diff --git a/sys/dev/cxgbe/t4_vf.c b/sys/dev/cxgbe/t4_vf.c
index a4a611ed645c..8ca6dd98a66f 100644
--- a/sys/dev/cxgbe/t4_vf.c
+++ b/sys/dev/cxgbe/t4_vf.c
@@ -589,6 +589,10 @@ t4vf_attach(device_t dev)
 	if (rc != 0)
 		goto done; /* error message displayed already */
 
+	rc = t4_adj_doorbells(sc);
+	if (rc != 0)
+		goto done; /* error message displayed already */
+
 	rc = t4_create_dma_tag(sc);
 	if (rc != 0)
 		goto done; /* error message displayed already */
@@ -656,6 +660,8 @@ t4vf_attach(device_t dev)
 			t4_os_set_hw_addr(pi, mac);
 		pmask &= ~(1 << p);
 
+		sc->vlan_id = t4vf_get_vf_vlan(sc);
+
 		/* No t4_link_start. */
 
 		snprintf(pi->lockname, sizeof(pi->lockname), "%sp%d",
diff --git a/sys/dev/dc/if_dc.c b/sys/dev/dc/if_dc.c
index ddb81d8a486c..809feed7855f 100644
--- a/sys/dev/dc/if_dc.c
+++ b/sys/dev/dc/if_dc.c
@@ -2380,11 +2380,6 @@ dc_attach(device_t dev)
 		goto fail;
 
 	ifp = sc->dc_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "can not if_alloc()\n");
-		error = ENOSPC;
-		goto fail;
-	}
 	if_setsoftc(ifp, sc);
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 	if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
diff --git a/sys/dev/dpaa/if_dtsec.c b/sys/dev/dpaa/if_dtsec.c
index 2c0dee05a03f..dfa76a476620 100644
--- a/sys/dev/dpaa/if_dtsec.c
+++ b/sys/dev/dpaa/if_dtsec.c
@@ -678,12 +678,6 @@ dtsec_attach(device_t dev)
 
 	/* Create network interface for upper layers */
 	ifp = sc->sc_ifnet = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(sc->sc_dev, "if_alloc() failed.\n");
-		dtsec_detach(dev);
-		return (ENOMEM);
-	}
-
 	if_setsoftc(ifp, sc);
 
 	if_setflags(ifp, IFF_SIMPLEX | IFF_BROADCAST);
diff --git a/sys/dev/dpaa2/dpaa2_ni.c b/sys/dev/dpaa2/dpaa2_ni.c
index a9e6aa120549..a21351a20b49 100644
--- a/sys/dev/dpaa2/dpaa2_ni.c
+++ b/sys/dev/dpaa2/dpaa2_ni.c
@@ -548,11 +548,6 @@ dpaa2_ni_attach(device_t dev)
 
 	/* Allocate network interface */
 	ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "%s: failed to allocate network interface\n",
-		    __func__);
-		goto err_exit;
-	}
 	sc->ifp = ifp;
 	if_initname(ifp, DPAA2_NI_IFNAME, device_get_unit(sc->dev));
 
diff --git a/sys/dev/ena/ena.c b/sys/dev/ena/ena.c
index 3ff32cc9966c..47d066a2e4f1 100644
--- a/sys/dev/ena/ena.c
+++ b/sys/dev/ena/ena.c
@@ -148,7 +148,7 @@ static int ena_ioctl(if_t, u_long, caddr_t);
 static int ena_get_dev_offloads(struct ena_com_dev_get_features_ctx *);
 static void ena_update_host_info(struct ena_admin_host_info *, if_t);
 static void ena_update_hwassist(struct ena_adapter *);
-static int ena_setup_ifnet(device_t, struct ena_adapter *,
+static void ena_setup_ifnet(device_t, struct ena_adapter *,
     struct ena_com_dev_get_features_ctx *);
 static int ena_enable_wc(device_t, struct resource *);
 static int ena_set_queues_placement_policy(device_t, struct ena_com_dev *,
@@ -2462,7 +2462,7 @@ ena_update_hwassist(struct ena_adapter *adapter)
 	if_sethwassistbits(ifp, flags, 0);
 }
 
-static int
+static void
 ena_setup_ifnet(device_t pdev, struct ena_adapter *adapter,
     struct ena_com_dev_get_features_ctx *feat)
 {
@@ -2470,10 +2470,6 @@ ena_setup_ifnet(device_t pdev, struct ena_adapter *adapter,
 	int caps = 0;
 
 	ifp = adapter->ifp = if_gethandle(IFT_ETHER);
-	if (unlikely(ifp == NULL)) {
-		ena_log(pdev, ERR, "can not allocate ifnet structure\n");
-		return (ENXIO);
-	}
 	if_initname(ifp, device_get_name(pdev), device_get_unit(pdev));
 	if_setdev(ifp, pdev);
 	if_setsoftc(ifp, adapter);
@@ -2516,8 +2512,6 @@ ena_setup_ifnet(device_t pdev, struct ena_adapter *adapter,
 	ifmedia_set(&adapter->media, IFM_ETHER | IFM_AUTO);
 
 	ether_ifattach(ifp, adapter->mac_addr);
-
-	return (0);
 }
 
 void
@@ -3811,11 +3805,7 @@ ena_attach(device_t pdev)
 	ena_sysctl_add_nodes(adapter);
 
 	/* setup network interface */
-	rc = ena_setup_ifnet(pdev, adapter, &get_feat_ctx);
-	if (unlikely(rc != 0)) {
-		ena_log(pdev, ERR, "Error with network interface setup\n");
-		goto err_customer_metrics_alloc;
-	}
+	ena_setup_ifnet(pdev, adapter, &get_feat_ctx);
 
 	/* Initialize reset task queue */
 	TASK_INIT(&adapter->reset_task, 0, ena_reset_task, adapter);
@@ -3852,7 +3842,6 @@ ena_attach(device_t pdev)
 err_detach:
 	ether_ifdetach(adapter->ifp);
 #endif /* DEV_NETMAP */
-err_customer_metrics_alloc:
 	free(adapter->customer_metrics_array, M_DEVBUF);
 err_metrics_buffer_destroy:
 	ena_com_delete_customer_metrics_buffer(ena_dev);
diff --git a/sys/dev/eqos/if_eqos.c b/sys/dev/eqos/if_eqos.c
index 3ee406f26def..7c0335079195 100644
--- a/sys/dev/eqos/if_eqos.c
+++ b/sys/dev/eqos/if_eqos.c
@@ -1119,6 +1119,9 @@ eqos_attach(device_t dev)
 		return (ENXIO);
 	}
 
+	if ((error = IF_EQOS_INIT(dev)))
+		return (error);
+
 	sc->dev = dev;
 	ver  = RD4(sc, GMAC_MAC_VERSION);
 	userver = (ver & GMAC_MAC_VERSION_USERVER_MASK) >>
@@ -1126,7 +1129,7 @@ eqos_attach(device_t dev)
 	snpsver = ver & GMAC_MAC_VERSION_SNPSVER_MASK;
 
 	if (snpsver != 0x51) {
-		device_printf(dev, "EQOS version 0x%02xx not supported\n",
+		device_printf(dev, "EQOS version 0x%02x not supported\n",
 		    snpsver);
 		return (ENXIO);
 	}
@@ -1142,10 +1145,6 @@ eqos_attach(device_t dev)
 		    sc->hw_feature[2], sc->hw_feature[3]);
 	}
 
-
-	if ((error = IF_EQOS_INIT(dev)))
-		return (error);
-
 	mtx_init(&sc->lock, "eqos lock", MTX_NETWORK_LOCK, MTX_DEF);
 	callout_init_mtx(&sc->callout, &sc->lock, 0);
 
diff --git a/sys/dev/eqos/if_eqos_fdt.c b/sys/dev/eqos/if_eqos_fdt.c
index 6d6c80bd2e92..82472008f1d5 100644
--- a/sys/dev/eqos/if_eqos_fdt.c
+++ b/sys/dev/eqos/if_eqos_fdt.c
@@ -50,6 +50,7 @@
 #include <dev/ofw/ofw_bus.h>
 #include <dev/ofw/ofw_bus_subr.h>
 
+#include <dev/extres/clk/clk.h>
 #include <dev/extres/hwreset/hwreset.h>
 #include <dev/extres/regulator/regulator.h>
 #include <dev/extres/syscon/syscon.h>
@@ -148,6 +149,9 @@ eqos_fdt_init(device_t dev)
 	regulator_t eqos_supply;
 	uint32_t rx_delay, tx_delay;
 	uint8_t buffer[16];
+	clk_t stmmaceth, mac_clk_rx, mac_clk_tx, aclk_mac, pclk_mac;
+	uint64_t freq;
+	int error;
 
 	if (OF_hasprop(node, "rockchip,grf") &&
 	    syscon_get_by_ofw_property(dev, node, "rockchip,grf", &sc->grf)) {
@@ -174,8 +178,56 @@ eqos_fdt_init(device_t dev)
 		device_printf(dev, "cannot get reset\n");
 		return (ENXIO);
 	}
-	else
-		hwreset_assert(eqos_reset);
+	hwreset_assert(eqos_reset);
+
+	error = clk_set_assigned(dev, ofw_bus_get_node(dev));
+	if (error != 0) {
+		device_printf(dev, "clk_set_assigned failed\n");
+		return (error);
+	}
+
+	if (clk_get_by_ofw_name(dev, 0, "stmmaceth", &stmmaceth) == 0) {
+		error = clk_enable(stmmaceth);
+		if (error != 0) {
+			device_printf(dev, "could not enable main clock\n");
+			return (error);
+		}
+		if (bootverbose) {
+			clk_get_freq(stmmaceth, &freq);
+			device_printf(dev, "MAC clock(%s) freq: %jd\n",
+					clk_get_name(stmmaceth), (intmax_t)freq);
+		}
+	}
+	else {
+		device_printf(dev, "could not find clock stmmaceth\n");
+	}
+
+	if (clk_get_by_ofw_name(dev, 0, "mac_clk_rx", &mac_clk_rx) != 0) {
+		device_printf(dev, "could not get mac_clk_rx clock\n");
+		mac_clk_rx = NULL;
+	}
+
+	if (clk_get_by_ofw_name(dev, 0, "mac_clk_tx", &mac_clk_tx) != 0) {
+		device_printf(dev, "could not get mac_clk_tx clock\n");
+		mac_clk_tx = NULL;
+	}
+
+	if (clk_get_by_ofw_name(dev, 0, "aclk_mac", &aclk_mac) != 0) {
+		device_printf(dev, "could not get aclk_mac clock\n");
+		aclk_mac = NULL;
+	}
+
+	if (clk_get_by_ofw_name(dev, 0, "pclk_mac", &pclk_mac) != 0) {
+		device_printf(dev, "could not get pclk_mac clock\n");
+		pclk_mac = NULL;
+	}
+
+	if (aclk_mac)
+		clk_enable(aclk_mac);
+	if (pclk_mac)
+		clk_enable(pclk_mac);
+	if (mac_clk_tx)
+		clk_enable(mac_clk_tx);
 
 	sc->csr_clock = 125000000;
 	sc->csr_clock_range = GMAC_MAC_MDIO_ADDRESS_CR_100_150;
diff --git a/sys/dev/et/if_et.c b/sys/dev/et/if_et.c
index 62bafd4c4113..5f5911eb2ae6 100644
--- a/sys/dev/et/if_et.c
+++ b/sys/dev/et/if_et.c
@@ -232,11 +232,6 @@ et_attach(device_t dev)
 	callout_init_mtx(&sc->sc_tick, &sc->sc_mtx, 0);
 
 	ifp = sc->ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "can not if_alloc()\n");
-		error = ENOSPC;
-		goto fail;
-	}
 
 	/*
 	 * Initialize tunables
diff --git a/sys/dev/etherswitch/ar40xx/ar40xx_phy.c b/sys/dev/etherswitch/ar40xx/ar40xx_phy.c
index 3e2bcd4af18d..11d9f8d47c0f 100644
--- a/sys/dev/etherswitch/ar40xx/ar40xx_phy.c
+++ b/sys/dev/etherswitch/ar40xx/ar40xx_phy.c
@@ -200,14 +200,6 @@ ar40xx_attach_phys(struct ar40xx_softc *sc)
 	snprintf(name, IFNAMSIZ, "%sport", device_get_nameunit(sc->sc_dev));
 	for (phy = 0; phy < AR40XX_NUM_PHYS; phy++) {
 		sc->sc_phys.ifp[phy] = if_alloc(IFT_ETHER);
-		if (sc->sc_phys.ifp[phy] == NULL) {
-			device_printf(sc->sc_dev,
-			    "PHY %d: couldn't allocate ifnet structure\n",
-			    phy);
-			err = ENOMEM;
-			break;
-		}
-
 		sc->sc_phys.ifp[phy]->if_softc = sc;
 		sc->sc_phys.ifp[phy]->if_flags |= IFF_UP | IFF_BROADCAST |
 		    IFF_DRV_RUNNING | IFF_SIMPLEX;
diff --git a/sys/dev/etherswitch/arswitch/arswitch.c b/sys/dev/etherswitch/arswitch/arswitch.c
index 1c2bcefdfe91..f1e6d1944038 100644
--- a/sys/dev/etherswitch/arswitch/arswitch.c
+++ b/sys/dev/etherswitch/arswitch/arswitch.c
@@ -95,7 +95,7 @@ arswitch_probe(device_t dev)
 {
 	struct arswitch_softc *sc;
 	uint32_t id;
-	char *chipname, desc[256];
+	char *chipname;
 
 	sc = device_get_softc(dev);
 	bzero(sc, sizeof(*sc));
@@ -132,12 +132,9 @@ arswitch_probe(device_t dev)
 
 	DPRINTF(sc, ARSWITCH_DBG_ANY, "chipname=%s, id=%08x\n", chipname, id);
 	if (chipname != NULL) {
-		snprintf(desc, sizeof(desc),
+		device_set_descf(dev,
 		    "Atheros %s Ethernet Switch (ver %d rev %d)",
-		    chipname,
-		    sc->chip_ver,
-		    sc->chip_rev);
-		device_set_desc_copy(dev, desc);
+		    chipname, sc->chip_ver, sc->chip_rev);
 		return (BUS_PROBE_DEFAULT);
 	}
 	return (ENXIO);
@@ -153,12 +150,6 @@ arswitch_attach_phys(struct arswitch_softc *sc)
 	snprintf(name, IFNAMSIZ, "%sport", device_get_nameunit(sc->sc_dev));
 	for (phy = 0; phy < sc->numphys; phy++) {
 		sc->ifp[phy] = if_alloc(IFT_ETHER);
-		if (sc->ifp[phy] == NULL) {
-			device_printf(sc->sc_dev, "couldn't allocate ifnet structure\n");
-			err = ENOMEM;
-			break;
-		}
-
 		if_setsoftc(sc->ifp[phy], sc);
 		if_setflagbits(sc->ifp[phy], IFF_UP | IFF_BROADCAST |
 		    IFF_DRV_RUNNING | IFF_SIMPLEX, 0);
diff --git a/sys/dev/etherswitch/e6000sw/e6000sw.c b/sys/dev/etherswitch/e6000sw/e6000sw.c
index 95f1a2e96db6..3b309f7f36f8 100644
--- a/sys/dev/etherswitch/e6000sw/e6000sw.c
+++ b/sys/dev/etherswitch/e6000sw/e6000sw.c
@@ -454,8 +454,6 @@ e6000sw_init_interface(e6000sw_softc_t *sc, int port)
 	snprintf(name, IFNAMSIZ, "%sport", device_get_nameunit(sc->dev));
 
 	sc->ifp[port] = if_alloc(IFT_ETHER);
-	if (sc->ifp[port] == NULL)
-		return (ENOMEM);
 	if_setsoftc(sc->ifp[port], sc);
 	if_setflagbits(sc->ifp[port], IFF_UP | IFF_BROADCAST |
 	    IFF_DRV_RUNNING | IFF_SIMPLEX, 0);
diff --git a/sys/dev/etherswitch/e6000sw/e6060sw.c b/sys/dev/etherswitch/e6000sw/e6060sw.c
index 19744f5e44a5..3ff38abb69a0 100644
--- a/sys/dev/etherswitch/e6000sw/e6060sw.c
+++ b/sys/dev/etherswitch/e6000sw/e6060sw.c
@@ -162,7 +162,6 @@ e6060sw_probe(device_t dev)
 	struct e6060sw_softc *sc;
 	int devid, i;
 	char *devname;
-	char desc[80];
 
 	sc = device_get_softc(dev);
 	bzero(sc, sizeof(*sc));
@@ -193,9 +192,8 @@ e6060sw_probe(device_t dev)
 	else
 		return (ENXIO);
 
-	sprintf(desc, "Marvell %s MDIO switch driver at 0x%02x",
+	device_set_descf(dev, "Marvell %s MDIO switch driver at 0x%02x",
 	    devname, sc->smi_offset);
-	device_set_desc_copy(dev, desc);
 
 	return (BUS_PROBE_DEFAULT);
 }
@@ -216,12 +214,6 @@ e6060sw_attach_phys(struct e6060sw_softc *sc)
 		sc->ifpport[phy] = port;
 		sc->portphy[port] = phy;
 		sc->ifp[port] = if_alloc(IFT_ETHER);
-		if (sc->ifp[port] == NULL) {
-			device_printf(sc->sc_dev, "couldn't allocate ifnet structure\n");
-			err = ENOMEM;
-			break;
-		}
-
 		sc->ifp[port]->if_softc = sc;
 		sc->ifp[port]->if_flags |= IFF_UP | IFF_BROADCAST |
 		    IFF_DRV_RUNNING | IFF_SIMPLEX;
diff --git a/sys/dev/etherswitch/felix/felix.c b/sys/dev/etherswitch/felix/felix.c
index f7d79ab33e13..ecd967015d00 100644
--- a/sys/dev/etherswitch/felix/felix.c
+++ b/sys/dev/etherswitch/felix/felix.c
@@ -241,9 +241,6 @@ felix_init_interface(felix_softc_t sc, int port)
 	snprintf(name, IFNAMSIZ, "%sport", device_get_nameunit(sc->dev));
 
 	sc->ports[port].ifp = if_alloc(IFT_ETHER);
-	if (sc->ports[port].ifp == NULL)
-		return (ENOMEM);
-
 	if_setsoftc(sc->ports[port].ifp, sc);
 	if_setflags(sc->ports[port].ifp, IFF_UP | IFF_BROADCAST | IFF_MULTICAST |
 	    IFF_DRV_RUNNING | IFF_SIMPLEX);
diff --git a/sys/dev/etherswitch/infineon/adm6996fc.c b/sys/dev/etherswitch/infineon/adm6996fc.c
index cc67616d9fdf..2c6c83a4388d 100644
--- a/sys/dev/etherswitch/infineon/adm6996fc.c
+++ b/sys/dev/etherswitch/infineon/adm6996fc.c
@@ -153,7 +153,7 @@ adm6996fc_probe(device_t dev)
 		return (ENXIO);
 	}
 
-	device_set_desc_copy(dev, "Infineon ADM6996FC/M/MX MDIO switch driver");
+	device_set_desc(dev, "Infineon ADM6996FC/M/MX MDIO switch driver");
 	return (BUS_PROBE_DEFAULT);
 }
 
@@ -173,12 +173,6 @@ adm6996fc_attach_phys(struct adm6996fc_softc *sc)
 		sc->ifpport[phy] = port;
 		sc->portphy[port] = phy;
 		sc->ifp[port] = if_alloc(IFT_ETHER);
-		if (sc->ifp[port] == NULL) {
-			device_printf(sc->sc_dev, "couldn't allocate ifnet structure\n");
-			err = ENOMEM;
-			break;
-		}
-
 		sc->ifp[port]->if_softc = sc;
 		sc->ifp[port]->if_flags |= IFF_UP | IFF_BROADCAST |
 		    IFF_DRV_RUNNING | IFF_SIMPLEX;
diff --git a/sys/dev/etherswitch/ip17x/ip17x.c b/sys/dev/etherswitch/ip17x/ip17x.c
index 65e548ba293b..5e07e1f72b80 100644
--- a/sys/dev/etherswitch/ip17x/ip17x.c
+++ b/sys/dev/etherswitch/ip17x/ip17x.c
@@ -152,7 +152,7 @@ ip17x_probe(device_t dev)
 	(void) resource_int_value(device_get_name(dev), device_get_unit(dev),
 	    "mii-poll", &sc->miipoll);
 #endif
-	device_set_desc_copy(dev, "IC+ IP17x switch driver");
+	device_set_desc(dev, "IC+ IP17x switch driver");
 	return (BUS_PROBE_DEFAULT);
 }
 
@@ -172,12 +172,6 @@ ip17x_attach_phys(struct ip17x_softc *sc)
 		sc->phyport[phy] = port;
 		sc->portphy[port] = phy;
 		sc->ifp[port] = if_alloc(IFT_ETHER);
-		if (sc->ifp[port] == NULL) {
-			device_printf(sc->sc_dev, "couldn't allocate ifnet structure\n");
-			err = ENOMEM;
-			break;
-		}
-
 		if_setsoftc(sc->ifp[port], sc);
 		if_setflags(sc->ifp[port], IFF_UP | IFF_BROADCAST |
 		    IFF_DRV_RUNNING | IFF_SIMPLEX);
diff --git a/sys/dev/etherswitch/micrel/ksz8995ma.c b/sys/dev/etherswitch/micrel/ksz8995ma.c
index 43292d3b2007..e512a86202c6 100644
--- a/sys/dev/etherswitch/micrel/ksz8995ma.c
+++ b/sys/dev/etherswitch/micrel/ksz8995ma.c
@@ -197,7 +197,7 @@ ksz8995ma_probe(device_t dev)
 		return (ENXIO);
 	}
 
-	device_set_desc_copy(dev, "Micrel KSZ8995MA SPI switch driver");
+	device_set_desc(dev, "Micrel KSZ8995MA SPI switch driver");
 	return (BUS_PROBE_DEFAULT);
 }
 
@@ -219,12 +219,6 @@ ksz8995ma_attach_phys(struct ksz8995ma_softc *sc)
 		sc->ifpport[phy] = port;
 		sc->portphy[port] = phy;
 		sc->ifp[port] = if_alloc(IFT_ETHER);
-		if (sc->ifp[port] == NULL) {
-			device_printf(sc->sc_dev, "couldn't allocate ifnet structure\n");
-			err = ENOMEM;
-			break;
-		}
-
 		sc->ifp[port]->if_softc = sc;
 		sc->ifp[port]->if_flags |= IFF_UP | IFF_BROADCAST |
 		    IFF_DRV_RUNNING | IFF_SIMPLEX;
diff --git a/sys/dev/etherswitch/mtkswitch/mtkswitch.c b/sys/dev/etherswitch/mtkswitch/mtkswitch.c
index 6e235097f189..fa96a81b40ef 100644
--- a/sys/dev/etherswitch/mtkswitch/mtkswitch.c
+++ b/sys/dev/etherswitch/mtkswitch/mtkswitch.c
@@ -100,7 +100,7 @@ mtkswitch_probe(device_t dev)
 	bzero(sc, sizeof(*sc));
 	sc->sc_switchtype = switch_type;
 
-	device_set_desc_copy(dev, "MTK Switch Driver");
+	device_set_desc(dev, "MTK Switch Driver");
 
 	return (0);
 }
@@ -121,12 +121,6 @@ mtkswitch_attach_phys(struct mtkswitch_softc *sc)
 			continue;
 		}
 		sc->ifp[phy] = if_alloc(IFT_ETHER);
-		if (sc->ifp[phy] == NULL) {
-			device_printf(sc->sc_dev, "couldn't allocate ifnet structure\n");
-			err = ENOMEM;
-			break;
-		}
-
 		sc->ifp[phy]->if_softc = sc;
 		sc->ifp[phy]->if_flags |= IFF_UP | IFF_BROADCAST |
 		    IFF_DRV_RUNNING | IFF_SIMPLEX;
diff --git a/sys/dev/etherswitch/rtl8366/rtl8366rb.c b/sys/dev/etherswitch/rtl8366/rtl8366rb.c
index 8a74ae189284..761a96b0ec80 100644
--- a/sys/dev/etherswitch/rtl8366/rtl8366rb.c
+++ b/sys/dev/etherswitch/rtl8366/rtl8366rb.c
@@ -238,12 +238,6 @@ rtl8366rb_attach(device_t dev)
 	/* PHYs need an interface, so we generate a dummy one */
 	for (i = 0; i < sc->numphys; i++) {
 		sc->ifp[i] = if_alloc(IFT_ETHER);
-		if (sc->ifp[i] == NULL) {
-			device_printf(dev, "couldn't allocate ifnet structure\n");
-			err = ENOMEM;
-			break;
-		}
-
 		if_setsoftc(sc->ifp[i], sc);
 		if_setflagbits(sc->ifp[i], IFF_UP | IFF_BROADCAST | IFF_DRV_RUNNING
 			| IFF_SIMPLEX, 0);
diff --git a/sys/dev/etherswitch/ukswitch/ukswitch.c b/sys/dev/etherswitch/ukswitch/ukswitch.c
index 88726422bd01..f2cf6ef74e90 100644
--- a/sys/dev/etherswitch/ukswitch/ukswitch.c
+++ b/sys/dev/etherswitch/ukswitch/ukswitch.c
@@ -106,7 +106,7 @@ ukswitch_probe(device_t dev)
 	sc = device_get_softc(dev);
 	bzero(sc, sizeof(*sc));
 
-	device_set_desc_copy(dev, "Generic MDIO switch driver");
+	device_set_desc(dev, "Generic MDIO switch driver");
 	return (BUS_PROBE_DEFAULT);
 }
 
@@ -124,12 +124,6 @@ ukswitch_attach_phys(struct ukswitch_softc *sc)
 		sc->ifpport[phy] = port;
 		sc->portphy[port] = phy;
 		sc->ifp[port] = if_alloc(IFT_ETHER);
-		if (sc->ifp[port] == NULL) {
-			device_printf(sc->sc_dev, "couldn't allocate ifnet structure\n");
-			err = ENOMEM;
-			break;
-		}
-
 		if_setsoftc(sc->ifp[port], sc);
 		if_setflags(sc->ifp[port], IFF_UP | IFF_BROADCAST |
 		    IFF_DRV_RUNNING | IFF_SIMPLEX);
diff --git a/sys/dev/firewire/if_fwe.c b/sys/dev/firewire/if_fwe.c
index 60a9806656e8..44d3425799e9 100644
--- a/sys/dev/firewire/if_fwe.c
+++ b/sys/dev/firewire/if_fwe.c
@@ -178,10 +178,6 @@ fwe_attach(device_t dev)
 
 	/* fill the rest and attach interface */
 	ifp = fwe->eth_softc.ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "can not if_alloc()\n");
-		return (ENOSPC);
-	}
 	if_setsoftc(ifp, &fwe->eth_softc);
 
 	if_initname(ifp, device_get_name(dev), unit);
@@ -201,7 +197,7 @@ fwe_attach(device_t dev)
 	if_setcapenablebit(ifp, IFCAP_VLAN_MTU, 0);
 
 	FWEDEBUG(ifp, "interface created\n");
-	return 0;
+	return (0);
 }
 
 static void
diff --git a/sys/dev/firewire/if_fwip.c b/sys/dev/firewire/if_fwip.c
index 5237c555d999..91a27800f308 100644
--- a/sys/dev/firewire/if_fwip.c
+++ b/sys/dev/firewire/if_fwip.c
@@ -153,8 +153,6 @@ fwip_attach(device_t dev)
 	fwip = ((struct fwip_softc *)device_get_softc(dev));
 	unit = device_get_unit(dev);
 	ifp = fwip->fw_softc.fwip_ifp = if_alloc(IFT_IEEE1394);
-	if (ifp == NULL)
-		return (ENOSPC);
 
 	mtx_init(&fwip->mtx, "fwip", NULL, MTX_DEF);
 	/* XXX */
@@ -199,7 +197,7 @@ fwip_attach(device_t dev)
 	splx(s);
 
 	FWIPDEBUG(ifp, "interface created\n");
-	return 0;
+	return (0);
 }
 
 static void
diff --git a/sys/dev/fxp/if_fxp.c b/sys/dev/fxp/if_fxp.c
index 8d695861cffc..966647051c21 100644
--- a/sys/dev/fxp/if_fxp.c
+++ b/sys/dev/fxp/if_fxp.c
@@ -443,11 +443,6 @@ fxp_attach(device_t dev)
 	    fxp_serial_ifmedia_sts);
 
 	ifp = sc->ifp = if_gethandle(IFT_ETHER);
-	if (ifp == (void *)NULL) {
-		device_printf(dev, "can not if_alloc()\n");
-		error = ENOSPC;
-		goto fail;
-	}
 
 	/*
 	 * Enable bus mastering.
diff --git a/sys/dev/gem/if_gem.c b/sys/dev/gem/if_gem.c
index 91389d0dfd2c..434c5309d019 100644
--- a/sys/dev/gem/if_gem.c
+++ b/sys/dev/gem/if_gem.c
@@ -152,8 +152,6 @@ gem_attach(struct gem_softc *sc)
 
 	/* Set up ifnet structure. */
 	ifp = sc->sc_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL)
-		return (ENOSPC);
 	sc->sc_csum_features = GEM_CSUM_FEATURES;
 	if_setsoftc(ifp, sc);
 	if_initname(ifp, device_get_name(sc->sc_dev),
diff --git a/sys/dev/gve/gve_main.c b/sys/dev/gve/gve_main.c
index cd7849778bce..f8a37b9f37a9 100644
--- a/sys/dev/gve/gve_main.c
+++ b/sys/dev/gve/gve_main.c
@@ -352,18 +352,13 @@ gve_get_counter(if_t ifp, ift_counter cnt)
 	}
 }
 
-static int
+static void
 gve_setup_ifnet(device_t dev, struct gve_priv *priv)
 {
 	int caps = 0;
 	if_t ifp;
 
 	ifp = priv->ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(priv->dev, "Failed to allocate ifnet struct\n");
-		return (ENXIO);
-	}
-
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 	if_setsoftc(ifp, priv);
 	if_setdev(ifp, dev);
@@ -401,8 +396,6 @@ gve_setup_ifnet(device_t dev, struct gve_priv *priv)
 
 	ifmedia_add(&priv->media, IFM_ETHER | IFM_AUTO, 0, NULL);
 	ifmedia_set(&priv->media, IFM_ETHER | IFM_AUTO);
-
-	return (0);
 }
 
 static int
@@ -794,9 +787,7 @@ gve_attach(device_t dev)
 	if (err != 0)
 		goto abort;
 
-	err = gve_setup_ifnet(dev, priv);
-	if (err != 0)
-		goto abort;
+	gve_setup_ifnet(dev, priv);
 
 	priv->rx_copybreak = GVE_DEFAULT_RX_COPYBREAK;
 
diff --git a/sys/dev/gve/gve_qpl.c b/sys/dev/gve/gve_qpl.c
index 3c6d9af6feee..9a946a2a2f2d 100644
--- a/sys/dev/gve/gve_qpl.c
+++ b/sys/dev/gve/gve_qpl.c
@@ -182,6 +182,7 @@ gve_free_qpls(struct gve_priv *priv)
 		for (i = 0; i < num_qpls; i++)
 			gve_free_qpl(priv, i);
 		free(priv->qpls, M_GVE_QPL);
+		priv->qpls = NULL;
 	}
 }
 
diff --git a/sys/dev/hid/hidbus.c b/sys/dev/hid/hidbus.c
index cddc6c961195..c2f8f58552e1 100644
--- a/sys/dev/hid/hidbus.c
+++ b/sys/dev/hid/hidbus.c
@@ -526,14 +526,12 @@ hidbus_set_desc(device_t child, const char *suffix)
 	struct hidbus_softc *sc = device_get_softc(bus);
 	struct hid_device_info *devinfo = device_get_ivars(bus);
 	struct hidbus_ivars *tlc = device_get_ivars(child);
-	char buf[80];
 
 	/* Do not add NULL suffix or if device name already contains it. */
 	if (suffix != NULL && strcasestr(devinfo->name, suffix) == NULL &&
-	    (sc->nauto > 1 || (tlc->flags & HIDBUS_FLAG_AUTOCHILD) == 0)) {
-		snprintf(buf, sizeof(buf), "%s %s", devinfo->name, suffix);
-		device_set_desc_copy(child, buf);
-	} else
+	    (sc->nauto > 1 || (tlc->flags & HIDBUS_FLAG_AUTOCHILD) == 0))
+		device_set_descf(child, "%s %s", devinfo->name, suffix);
+	else
 		device_set_desc(child, devinfo->name);
 }
 
@@ -605,7 +603,7 @@ hidbus_set_intr(device_t child, hid_intr_t *handler, void *context)
 static int
 hidbus_intr_start(device_t bus, device_t child)
 {
-	MPASS(bus = device_get_parent(child));
+	MPASS(bus == device_get_parent(child));
 	struct hidbus_softc *sc = device_get_softc(bus);
 	struct hidbus_ivars *ivar = device_get_ivars(child);
 	struct hidbus_ivars *tlc;
@@ -631,7 +629,7 @@ hidbus_intr_start(device_t bus, device_t child)
 static int
 hidbus_intr_stop(device_t bus, device_t child)
 {
-	MPASS(bus = device_get_parent(child));
+	MPASS(bus == device_get_parent(child));
 	struct hidbus_softc *sc = device_get_softc(bus);
 	struct hidbus_ivars *ivar = device_get_ivars(child);
 	struct hidbus_ivars *tlc;
diff --git a/sys/dev/hyperv/vmbus/hyperv.c b/sys/dev/hyperv/vmbus/hyperv.c
index 3109030384a0..c66588e205d8 100644
--- a/sys/dev/hyperv/vmbus/hyperv.c
+++ b/sys/dev/hyperv/vmbus/hyperv.c
@@ -35,6 +35,7 @@
 #include <sys/malloc.h>
 #include <sys/systm.h>
 #include <sys/timetc.h>
+#include <sys/cpuset.h>
 
 #include <vm/vm.h>
 #include <vm/vm_extern.h>
@@ -50,6 +51,7 @@
 #include <dev/hyperv/vmbus/x86/hyperv_machdep.h>
 #include <dev/hyperv/vmbus/x86/hyperv_reg.h>
 #endif
+#include <dev/hyperv/vmbus/vmbus_var.h>
 #include <dev/hyperv/vmbus/hyperv_common_reg.h>
 #include <dev/hyperv/vmbus/hyperv_var.h>
 
@@ -72,10 +74,12 @@
 	 MSR_HV_GUESTID_OSID_FREEBSD |	\
 	 MSR_HV_GUESTID_OSTYPE_FREEBSD)
 
+
 static bool			hyperv_identify(void);
 static void			hypercall_memfree(void);
 
 static struct hypercall_ctx	hypercall_context;
+
 uint64_t
 hypercall_post_message(bus_addr_t msg_paddr)
 {
@@ -90,6 +94,65 @@ hypercall_signal_event(bus_addr_t monprm_paddr)
 	    HYPERCALL_SIGNAL_EVENT, monprm_paddr, 0);
 }
 
+static inline int hv_result(uint64_t status)
+{
+	return status & HV_HYPERCALL_RESULT_MASK;
+}
+
+static inline bool hv_result_success(uint64_t status)
+{
+	return hv_result(status) == HV_STATUS_SUCCESS;
+}
+
+static inline unsigned int hv_repcomp(uint64_t status)
+{
+	/* Bits [43:32] of status have 'Reps completed' data. */
+	return ((status & HV_HYPERCALL_REP_COMP_MASK) >>
+	    HV_HYPERCALL_REP_COMP_OFFSET);
+}
+
+/*
+ * Rep hypercalls. Callers of this functions are supposed to ensure that
+ * rep_count and varhead_size comply with Hyper-V hypercall definition.
+ */
+uint64_t
+hv_do_rep_hypercall(uint16_t code, uint16_t rep_count, uint16_t varhead_size,
+    uint64_t input, uint64_t output)
+{
+	uint64_t control = code;
+	uint64_t status;
+	uint16_t rep_comp;
+
+	control |= (uint64_t)varhead_size << HV_HYPERCALL_VARHEAD_OFFSET;
+	control |= (uint64_t)rep_count << HV_HYPERCALL_REP_COMP_OFFSET;
+
+	do {
+		status = hypercall_do_md(control, input, output);
+		if (!hv_result_success(status))
+			return status;
+
+		rep_comp = hv_repcomp(status);
+
+		control &= ~HV_HYPERCALL_REP_START_MASK;
+		control |= (uint64_t)rep_comp << HV_HYPERCALL_REP_START_OFFSET;
+
+	} while (rep_comp < rep_count);
+	if (hv_result_success(status))
+		return HV_STATUS_SUCCESS;
+
+	return status;
+}
+
+uint64_t
+hypercall_do_md(uint64_t input_val, uint64_t input_addr, uint64_t out_addr)
+{
+	uint64_t phys_inaddr, phys_outaddr;
+	phys_inaddr = input_addr ? vtophys(input_addr) : 0;
+	phys_outaddr = out_addr ? vtophys(out_addr) : 0;
+	return hypercall_md(hypercall_context.hc_addr,
+	    input_val, phys_inaddr, phys_outaddr);
+}
+
 int
 hyperv_guid2str(const struct hyperv_guid *guid, char *buf, size_t sz)
 {
diff --git a/sys/dev/hyperv/vmbus/hyperv_mmu.c b/sys/dev/hyperv/vmbus/hyperv_mmu.c
new file mode 100644
index 000000000000..7c29fe294093
--- /dev/null
+++ b/sys/dev/hyperv/vmbus/hyperv_mmu.c
@@ -0,0 +1,309 @@
+/*-
+ * Copyright (c) 2009-2012,2016-2024 Microsoft Corp.
+ * Copyright (c) 2012 NetApp Inc.
+ * Copyright (c) 2012 Citrix Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/kernel.h>
+#include <sys/linker.h>
+#include <sys/lock.h>
+#include <sys/malloc.h>
+#include <sys/module.h>
+#include <sys/mutex.h>
+#include <sys/sbuf.h>
+#include <sys/smp.h>
+#include <sys/sysctl.h>
+#include <sys/systm.h>
+#include <sys/proc.h>
+#include <sys/sched.h>
+#include <sys/kdb.h>
+#include <vm/vm.h>
+#include <vm/pmap.h>
+
+#include <machine/bus.h>
+#include <dev/hyperv/vmbus/x86/hyperv_machdep.h>
+#include <dev/hyperv/vmbus/x86/hyperv_reg.h>
+#include <dev/hyperv/include/hyperv.h>
+#include <dev/hyperv/vmbus/hyperv_var.h>
+#include <dev/hyperv/vmbus/vmbus_reg.h>
+#include <dev/hyperv/vmbus/vmbus_var.h>
+#include <dev/hyperv/vmbus/hyperv_common_reg.h>
+#include "hyperv_mmu.h"
+
+static inline int fill_gva_list(uint64_t gva_list[],
+    unsigned long start, unsigned long end)
+{
+	int gva_n = 0;
+	unsigned long cur = start, diff;
+
+	do {
+		diff = end > cur ? end - cur : 0;
+
+		gva_list[gva_n] = cur;
+		/*
+		 * Lower 12 bits encode the number of additional
+		 * pages to flush (in addition to the 'cur' page).
+		 */
+		if (diff >= HV_TLB_FLUSH_UNIT) {
+			gva_list[gva_n] |= PAGE_MASK;
+			cur += HV_TLB_FLUSH_UNIT;
+		}  else if (diff) {
+			gva_list[gva_n] |= (diff - 1) >> PAGE_SHIFT;
+			cur = end;
+		}
+
+		gva_n++;
+
+	} while (cur < end);
+
+	return gva_n;
+}
+
+
+inline int hv_cpumask_to_vpset(struct hv_vpset *vpset,
+    const cpuset_t *cpus, struct vmbus_softc * sc)
+{
+	int cpu, vcpu, vcpu_bank, vcpu_offset, nr_bank = 1;
+	int max_vcpu_bank = hv_max_vp_index / HV_VCPUS_PER_SPARSE_BANK;
+
+	/*
+	 * vpset.valid_bank_mask can represent up to
+	 * HV_MAX_SPARSE_VCPU_BANKS banks
+	 */
+	if (max_vcpu_bank >= HV_MAX_SPARSE_VCPU_BANKS)
+		return 0;
+
+	/*
+	 * Clear all banks up to the maximum possible bank as hv_tlb_flush_ex
+	 * structs are not cleared between calls, we risk flushing unneeded
+	 * vCPUs otherwise.
+	 */
+	for (vcpu_bank = 0; vcpu_bank <= max_vcpu_bank; vcpu_bank++)
+		vpset->bank_contents[vcpu_bank] = 0;
+
+	/*
+	 * Some banks may end up being empty but this is acceptable.
+	 */
+	CPU_FOREACH_ISSET(cpu, cpus) {
+		vcpu = VMBUS_PCPU_GET(sc, vcpuid, cpu);
+		if (vcpu == -1)
+			return -1;
+		vcpu_bank = vcpu / HV_VCPUS_PER_SPARSE_BANK;
+		vcpu_offset = vcpu % HV_VCPUS_PER_SPARSE_BANK;
+		set_bit(vcpu_offset, (unsigned long *)
+		    &vpset->bank_contents[vcpu_bank]);
+		if (vcpu_bank >= nr_bank)
+			nr_bank = vcpu_bank + 1;
+	}
+	vpset->valid_bank_mask = GENMASK_ULL(nr_bank - 1, 0);
+	return nr_bank;
+}
+
+
+
+
+void
+hv_vm_tlb_flush(pmap_t pmap, vm_offset_t addr1, vm_offset_t addr2,
+    enum invl_op_codes op, struct vmbus_softc *sc, smp_invl_local_cb_t curcpu_cb)
+{
+	cpuset_t tmp_mask, mask;
+	struct hyperv_tlb_flush *flush;
+	int cpu, vcpu;
+	int max_gvas, gva_n;
+	uint64_t status = 0;
+	uint64_t cr3;
+
+	/*
+	 * Hyper-V doesn't handle the invalidating cache. Let system handle it.
+	 */
+	if (op == INVL_OP_CACHE)
+		return smp_targeted_tlb_shootdown_native(pmap, addr1, addr2,
+		    curcpu_cb, op);
+
+	flush = *VMBUS_PCPU_PTR(sc, cpu_mem, curcpu);
+	if (flush == NULL)
+		return smp_targeted_tlb_shootdown_native(pmap, addr1, addr2,
+		    curcpu_cb, op);
+	/*
+	 * It is not necessary to signal other CPUs while booting or
+	 * when in the debugger.
+	 */
+	if (__predict_false(kdb_active || KERNEL_PANICKED() || !smp_started))
+		goto local_cb;
+
+	KASSERT(curthread->td_pinned > 0, ("curthread not pinned"));
+
+	/*
+	 * Make a stable copy of the set of CPUs on which the pmap is active.
+	 * See if we have to interrupt other CPUs.
+	 */
+	CPU_COPY(pmap_invalidate_cpu_mask(pmap), &tmp_mask);
+	CPU_COPY(pmap_invalidate_cpu_mask(pmap), &mask);
+	CPU_CLR(curcpu, &tmp_mask);
+	if (CPU_EMPTY(&tmp_mask))
+		goto local_cb;
+
+	/*
+	 * Initiator must have interrupts enabled, which prevents
+	 * non-invalidation IPIs that take smp_ipi_mtx spinlock,
+	 * from deadlocking with us.  On the other hand, preemption
+	 * must be disabled to pin initiator to the instance of the
+	 * pcpu pc_smp_tlb data and scoreboard line.
+	 */
+	KASSERT((read_rflags() & PSL_I) != 0,
+	    ("hv_tlb_flush: interrupts disabled"));
+	critical_enter();
+	flush->processor_mask = 0;
+	cr3 = pmap->pm_cr3;
+
+	if (op == INVL_OP_TLB || op == INVL_OP_TLB_INVPCID ||
+	    op == INVL_OP_TLB_INVPCID_PTI || op == INVL_OP_TLB_PCID) {
+		flush->address_space = 0;
+		flush->flags = HV_FLUSH_ALL_VIRTUAL_ADDRESS_SPACES;
+	} else {
+
+		flush->address_space = cr3;
+		flush->address_space &= ~CR3_PCID_MASK;
+		flush->flags = 0;
+	}
+	if(CPU_CMP(&mask, &all_cpus) == 0) {
+		flush->flags |= HV_FLUSH_ALL_PROCESSORS;
+	} else {
+		if (CPU_FLS(&mask) < mp_ncpus && CPU_FLS(&mask) >= 64)
+			goto do_ex_hypercall;
+
+		CPU_FOREACH_ISSET(cpu, &mask) {
+			vcpu = VMBUS_PCPU_GET(sc, vcpuid, cpu);
+			if (vcpu >= 64)
+				goto do_ex_hypercall;
+
+			set_bit(vcpu, &flush->processor_mask);
+		}
+		if (!flush->processor_mask )
+			goto native;
+	}
+	max_gvas = (PAGE_SIZE - sizeof(*flush)) / sizeof(flush->gva_list[0]);
+	if (addr2 == 0) {
+		flush->flags |= HV_FLUSH_NON_GLOBAL_MAPPINGS_ONLY;
+		status = hypercall_do_md(HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE,
+		    (uint64_t)flush, (uint64_t)NULL);
+	} else if ((addr2 && (addr2 -addr1)/HV_TLB_FLUSH_UNIT) > max_gvas) {
+		status = hypercall_do_md(HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE,
+		    (uint64_t)flush, (uint64_t)NULL);
+	} else {
+		gva_n = fill_gva_list(flush->gva_list, addr1, addr2);
+
+		status = hv_do_rep_hypercall(HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST,
+		    gva_n, 0, (uint64_t)flush, (uint64_t)NULL);
+
+	}
+	if(status)
+		goto native;
+	sched_unpin();
+	critical_exit();
+	return;
+
+local_cb:
+	critical_enter();
+	curcpu_cb(pmap, addr1, addr2);
+	sched_unpin();
+	critical_exit();
+	return;
+do_ex_hypercall:
+	status = hv_flush_tlb_others_ex(pmap, addr1, addr2, mask, op, sc);
+	if (status)
+		goto native;
+	sched_unpin();
+	critical_exit();
+	return;
+native:
+	sched_unpin();
+	critical_exit();
+	return smp_targeted_tlb_shootdown_native(pmap, addr1,
+	    addr2, curcpu_cb, op);
+}
+
+uint64_t
+hv_flush_tlb_others_ex(pmap_t pmap, vm_offset_t addr1, vm_offset_t addr2,
+    const cpuset_t mask, enum invl_op_codes op, struct vmbus_softc *sc)
+{
+	int nr_bank = 0, max_gvas, gva_n;
+	struct hv_tlb_flush_ex *flush;
+	if(*VMBUS_PCPU_PTR(sc, cpu_mem, curcpu) == NULL)
+		return EINVAL;
+	flush = *VMBUS_PCPU_PTR(sc, cpu_mem, curcpu);
+	uint64_t status = 0;
+	uint64_t cr3;
+
+	if (!(hyperv_recommends & HYPERV_X64_EX_PROCESSOR_MASKS_RECOMMENDED))
+	       return EINVAL;
+
+	cr3 = pmap->pm_cr3;
+	if (op == INVL_OP_TLB) {
+		flush->address_space = 0;
+		flush->flags = HV_FLUSH_ALL_VIRTUAL_ADDRESS_SPACES;
+	} else {
+
+		flush->address_space = cr3;
+		flush->address_space &= ~CR3_PCID_MASK;
+		flush->flags = 0;
+	}
+
+	flush->hv_vp_set.valid_bank_mask = 0;
+
+	flush->hv_vp_set.format = HV_GENERIC_SET_SPARSE_4K;
+	nr_bank = hv_cpumask_to_vpset(&flush->hv_vp_set, &mask, sc);
+	if (nr_bank < 0)
+		return EINVAL;
+
+	/*
+	 * We can flush not more than max_gvas with one hypercall. Flush the
+	 * whole address space if we were asked to do more.
+	 */
+	max_gvas = (PAGE_SIZE - sizeof(*flush) - nr_bank *
+	    sizeof(flush->hv_vp_set.bank_contents[0])) /
+	    sizeof(flush->hv_vp_set.bank_contents[0]);
+
+	if (addr2 == 0) {
+		flush->flags |= HV_FLUSH_NON_GLOBAL_MAPPINGS_ONLY;
+		status = hv_do_rep_hypercall(
+				HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX,
+				0, nr_bank, (uint64_t)flush, (uint64_t)NULL);
+	} else if (addr2 &&
+	    ((addr2 - addr1)/HV_TLB_FLUSH_UNIT) > max_gvas) {
+		status = hv_do_rep_hypercall(
+		    HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX,
+		    0, nr_bank, (uint64_t)flush, (uint64_t)NULL);
+	} else {
+		gva_n = fill_gva_list(&flush->hv_vp_set.bank_contents[nr_bank],
+		    addr1, addr2);
+		status = hv_do_rep_hypercall(
+		    HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST_EX,
+		    gva_n, nr_bank, (uint64_t)flush, (uint64_t)NULL);
+	}
+	return status;
+}
diff --git a/sys/dev/hyperv/vmbus/hyperv_mmu.h b/sys/dev/hyperv/vmbus/hyperv_mmu.h
new file mode 100644
index 000000000000..e62948d74181
--- /dev/null
+++ b/sys/dev/hyperv/vmbus/hyperv_mmu.h
@@ -0,0 +1,57 @@
+/*-
+ * Copyright (c) 2009-2012,2016-2024 Microsoft Corp.
+ * Copyright (c) 2012 NetApp Inc.
+ * Copyright (c) 2012 Citrix Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _HYPERV_MMU_H_
+#define _HYPERV_MMU_H_
+
+#include "vmbus_var.h"
+
+#define HV_VCPUS_PER_SPARSE_BANK (64)
+#define HV_MAX_SPARSE_VCPU_BANKS (64)
+
+
+struct hyperv_tlb_flush {
+	uint64_t address_space;
+	uint64_t flags;
+	uint64_t processor_mask;
+	uint64_t gva_list[];
+}__packed;
+
+struct hv_vpset {
+	uint64_t format;
+	uint64_t valid_bank_mask;
+	uint64_t bank_contents[];
+} __packed;
+
+struct hv_tlb_flush_ex {
+	uint64_t address_space;
+	uint64_t flags;
+	struct hv_vpset hv_vp_set;
+} __packed;
+
+#endif
diff --git a/sys/dev/hyperv/vmbus/hyperv_var.h b/sys/dev/hyperv/vmbus/hyperv_var.h
index 67f6cc4ef706..62cce9026ab0 100644
--- a/sys/dev/hyperv/vmbus/hyperv_var.h
+++ b/sys/dev/hyperv/vmbus/hyperv_var.h
@@ -33,7 +33,18 @@ struct hypercall_ctx {
     void            *hc_addr;
     vm_paddr_t      hc_paddr;
 };
+
 uint64_t	hypercall_post_message(bus_addr_t msg_paddr);
 uint64_t	hypercall_signal_event(bus_addr_t monprm_paddr);
+uint64_t	hypercall_do_md(uint64_t input, uint64_t in_addr,
+		    uint64_t out_addr);
+struct hv_vpset;
+struct vmbus_softc;
 
+uint64_t
+hv_do_rep_hypercall(uint16_t code, uint16_t rep_count, uint16_t varhead_size,
+    uint64_t input, uint64_t output);
+int
+hv_cpumask_to_vpset(struct hv_vpset *vpset, const cpuset_t *cpus,
+    struct vmbus_softc *sc);
 #endif	/* !_HYPERV_VAR_H_ */
diff --git a/sys/dev/hyperv/vmbus/vmbus.c b/sys/dev/hyperv/vmbus/vmbus.c
index 0ea401507b79..6a26527768c4 100644
--- a/sys/dev/hyperv/vmbus/vmbus.c
+++ b/sys/dev/hyperv/vmbus/vmbus.c
@@ -139,6 +139,10 @@ static void			vmbus_event_proc_dummy(struct vmbus_softc *,
 				    int);
 static bus_dma_tag_t	vmbus_get_dma_tag(device_t parent, device_t child);
 static struct vmbus_softc	*vmbus_sc;
+#if defined(__x86_64__)
+static int vmbus_alloc_cpu_mem(struct vmbus_softc *sc);
+static void vmbus_free_cpu_mem(struct vmbus_softc *sc);
+#endif
 
 SYSCTL_NODE(_hw, OID_AUTO, vmbus, CTLFLAG_RD | CTLFLAG_MPSAFE, NULL,
     "Hyper-V vmbus");
@@ -146,6 +150,13 @@ SYSCTL_NODE(_hw, OID_AUTO, vmbus, CTLFLAG_RD | CTLFLAG_MPSAFE, NULL,
 static int			vmbus_pin_evttask = 1;
 SYSCTL_INT(_hw_vmbus, OID_AUTO, pin_evttask, CTLFLAG_RDTUN,
     &vmbus_pin_evttask, 0, "Pin event tasks to their respective CPU");
+
+#if defined(__x86_64__)
+static int			hv_tlb_hcall = 1;
+SYSCTL_INT(_hw_vmbus, OID_AUTO, tlb_hcall , CTLFLAG_RDTUN,
+    &hv_tlb_hcall, 0, "Use Hyper_V hyercall for tlb flush");
+#endif
+
 uint32_t			vmbus_current_version;
 
 static const uint32_t		vmbus_version[] = {
@@ -208,6 +219,8 @@ static driver_t vmbus_driver = {
 	sizeof(struct vmbus_softc)
 };
 
+uint32_t hv_max_vp_index;
+
 DRIVER_MODULE(vmbus, pcib, vmbus_driver, NULL, NULL);
 DRIVER_MODULE(vmbus, acpi_syscontainer, vmbus_driver, NULL, NULL);
 
@@ -748,6 +761,9 @@ vmbus_synic_setup(void *xsc)
 		VMBUS_PCPU_GET(sc, vcpuid, cpu) = 0;
 	}
 
+	if (VMBUS_PCPU_GET(sc, vcpuid, cpu) > hv_max_vp_index)
+		hv_max_vp_index = VMBUS_PCPU_GET(sc, vcpuid, cpu);
+
 	/*
 	 * Setup the SynIC message.
 	 */
@@ -786,6 +802,16 @@ vmbus_synic_setup(void *xsc)
 	WRMSR(MSR_HV_SCONTROL, val);
 }
 
+#if defined(__x86_64__)
+void
+hyperv_vm_tlb_flush(pmap_t pmap, vm_offset_t addr1, vm_offset_t addr2,
+    smp_invl_local_cb_t curcpu_cb, enum invl_op_codes op)
+{
+	struct vmbus_softc *sc = vmbus_get_softc();
+	return hv_vm_tlb_flush(pmap, addr1, addr2, op, sc, curcpu_cb);
+}
+#endif /*__x86_64__*/
+
 static void
 vmbus_synic_teardown(void *arg)
 {
@@ -1373,6 +1399,42 @@ vmbus_probe(device_t dev)
 	return (BUS_PROBE_DEFAULT);
 }
 
+#if defined(__x86_64__)
+static int
+vmbus_alloc_cpu_mem(struct vmbus_softc *sc)
+{
+	int cpu;
+
+	CPU_FOREACH(cpu) {
+		void **hv_cpu_mem;
+
+		hv_cpu_mem = VMBUS_PCPU_PTR(sc, cpu_mem, cpu);
+		*hv_cpu_mem = contigmalloc(PAGE_SIZE, M_DEVBUF,
+		    M_NOWAIT | M_ZERO, 0ul, ~0ul, PAGE_SIZE, 0);
+
+		if (*hv_cpu_mem == NULL)
+			return ENOMEM;
+	}
+
+	return 0;
+}
+
+static void
+vmbus_free_cpu_mem(struct vmbus_softc *sc)
+{
+	int cpu;
+
+	CPU_FOREACH(cpu) {
+		void **hv_cpu_mem;
+		hv_cpu_mem = VMBUS_PCPU_PTR(sc, cpu_mem, cpu);
+		if(*hv_cpu_mem != NULL) {
+			contigfree(*hv_cpu_mem, PAGE_SIZE, M_DEVBUF);
+			*hv_cpu_mem = NULL;
+		}
+	}
+}
+#endif
+
 /**
  * @brief Main vmbus driver initialization routine.
  *
@@ -1462,6 +1524,25 @@ vmbus_doattach(struct vmbus_softc *sc)
 	if (ret != 0)
 		goto cleanup;
 
+#if defined(__x86_64__)
+	/*
+	 * Alloc per cpu memory for tlb flush hypercall
+	 */
+	if (hv_tlb_hcall) {
+		ret = vmbus_alloc_cpu_mem(sc);
+		if (ret != 0) {
+			hv_tlb_hcall = 0;
+			if (bootverbose)
+				device_printf(sc->vmbus_dev,
+				    "cannot alloc contig memory for "
+				    "cpu_mem, use system provided "
+				    "tlb flush call.\n");
+
+			vmbus_free_cpu_mem(sc);
+		}
+	}
+#endif
+
 	/*
 	 * Setup SynIC.
 	 */
@@ -1470,6 +1551,11 @@ vmbus_doattach(struct vmbus_softc *sc)
 	smp_rendezvous(NULL, vmbus_synic_setup, NULL, sc);
 	sc->vmbus_flags |= VMBUS_FLAG_SYNIC;
 
+#if defined(__x86_64__)
+	if (hv_tlb_hcall)
+		smp_targeted_tlb_shootdown = &hyperv_vm_tlb_flush;
+#endif
+
 	/*
 	 * Initialize vmbus, e.g. connect to Hypervisor.
 	 */
@@ -1573,6 +1659,16 @@ vmbus_detach(device_t dev)
 		smp_rendezvous(NULL, vmbus_synic_teardown, NULL, NULL);
 	}
 
+#if defined(__x86_64__)
+	/*
+	 * Restore the tlb flush to native call
+	 */
+	if (hv_tlb_hcall) {
+		smp_targeted_tlb_shootdown = &smp_targeted_tlb_shootdown_native;
+		vmbus_free_cpu_mem(sc);
+	}
+#endif
+
 	vmbus_intr_teardown(sc);
 	vmbus_dma_free(sc);
 
diff --git a/sys/dev/hyperv/vmbus/vmbus_var.h b/sys/dev/hyperv/vmbus/vmbus_var.h
index 023d27c52cea..4e0a769402d5 100644
--- a/sys/dev/hyperv/vmbus/vmbus_var.h
+++ b/sys/dev/hyperv/vmbus/vmbus_var.h
@@ -32,6 +32,11 @@
 #include <sys/taskqueue.h>
 #include <sys/rman.h>
 
+#include <vm/vm.h>
+#include <vm/vm_extern.h>
+#include <vm/vm_param.h>
+#include <vm/pmap.h>
+
 #include <dev/pci/pcivar.h>
 #include <dev/pci/pcib_private.h>
 
@@ -69,6 +74,9 @@ struct vmbus_pcpu_data {
 	uint32_t		vcpuid;		/* virtual cpuid */
 	int			event_flags_cnt;/* # of event flags */
 	struct vmbus_evtflags	*event_flags;	/* event flags from host */
+#if defined(__x86_64__)
+	void			*cpu_mem;	/* For Hyper-V tlb hypercall */
+#endif
 
 	/* Rarely used fields */
 	struct taskqueue	*event_tq;	/* event taskq */
@@ -137,6 +145,40 @@ struct vmbus_softc {
 
 #define VMBUS_PCPU_GET(sc, field, cpu)	(sc)->vmbus_pcpu[(cpu)].field
 #define VMBUS_PCPU_PTR(sc, field, cpu)	&(sc)->vmbus_pcpu[(cpu)].field
+#define HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE	0x0002
+#define HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX	0x0013
+#define HV_FLUSH_ALL_PROCESSORS		BIT(0)
+#define HV_FLUSH_ALL_VIRTUAL_ADDRESS_SPACES	BIT(1)
+#define HV_FLUSH_NON_GLOBAL_MAPPINGS_ONLY	BIT(2)
+#define HV_TLB_FLUSH_UNIT	(4096 * PAGE_SIZE)
+
+
+#define BIT(n)		(1ULL << (n))
+#define BITS_PER_LONG	(sizeof(long) * NBBY)
+#define BIT_MASK(nr)	(1UL << ((nr) & (BITS_PER_LONG - 1)))
+#define BIT_WORD(nr)	((nr) / BITS_PER_LONG)
+#define set_bit(i, a)			\
+	 atomic_set_long(&((volatile unsigned long *)(a))[BIT_WORD(i)], BIT_MASK(i))
+
+#define GENMASK_ULL(h, l)  (((~0ULL) >> (64 - (h) - 1)) & ((~0ULL) << (l)))
+
+#define HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST	0x0003
+#define HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST_EX	0x0014
+#define HYPERV_X64_EX_PROCESSOR_MASKS_RECOMMENDED	BIT(11)
+#define HV_HYPERCALL_RESULT_MASK	GENMASK_ULL(15, 0)
+#define HV_STATUS_SUCCESS	0
+#define HV_HYPERCALL_REP_COMP_MASK	GENMASK_ULL(43, 32)
+#define HV_HYPERCALL_REP_COMP_OFFSET	32
+
+#define HV_HYPERCALL_VARHEAD_OFFSET	17
+
+#define HV_HYPERCALL_REP_START_MASK	GENMASK_ULL(59, 48)
+#define HV_HYPERCALL_REP_START_OFFSET	48
+
+enum HV_GENERIC_SET_FORMAT {
+	HV_GENERIC_SET_SPARSE_4K,
+	HV_GENERIC_SET_ALL,
+};
 
 struct vmbus_channel;
 struct trapframe;
@@ -176,4 +218,17 @@ void    vmbus_synic_setup1(void *xsc);
 void    vmbus_synic_teardown1(void);
 int     vmbus_setup_intr1(struct vmbus_softc *sc);
 void    vmbus_intr_teardown1(struct vmbus_softc *sc);
+
+extern uint32_t hv_max_vp_index;
+
+
+#if defined(__x86_64__)
+void		hyperv_vm_tlb_flush(pmap_t, vm_offset_t,
+		    vm_offset_t, smp_invl_local_cb_t, enum invl_op_codes);
+uint64_t	hv_flush_tlb_others_ex(pmap_t, vm_offset_t, vm_offset_t,
+		    cpuset_t, enum invl_op_codes, struct vmbus_softc *);
+void		hv_vm_tlb_flush(pmap_t, vm_offset_t, vm_offset_t,
+		    enum invl_op_codes, struct vmbus_softc *,
+		    smp_invl_local_cb_t);
+#endif /* __x86_64__ */
 #endif	/* !_VMBUS_VAR_H_ */
diff --git a/sys/dev/iicbus/if_ic.c b/sys/dev/iicbus/if_ic.c
index 52ab5afb9c4e..caca35a3d22b 100644
--- a/sys/dev/iicbus/if_ic.c
+++ b/sys/dev/iicbus/if_ic.c
@@ -162,8 +162,6 @@ icattach(device_t dev)
 	if_t ifp;
 
 	ifp = sc->ic_ifp = if_alloc(IFT_PARA);
-	if (ifp == NULL)
-		return (ENOSPC);
 
 	mtx_init(&sc->ic_lock, device_get_nameunit(dev), MTX_NETWORK_LOCK,
 	    MTX_DEF);
diff --git a/sys/dev/iicbus/iichid.c b/sys/dev/iicbus/iichid.c
index ff443afbf30a..222f20842a04 100644
--- a/sys/dev/iicbus/iichid.c
+++ b/sys/dev/iicbus/iichid.c
@@ -1037,7 +1037,6 @@ iichid_probe(device_t dev)
 {
 	struct iichid_softc *sc;
 	ACPI_HANDLE handle;
-	char buf[80];
 	uint16_t config_reg;
 	int error, reg;
 
@@ -1097,10 +1096,8 @@ iichid_probe(device_t dev)
 
 	sc->probe_result = BUS_PROBE_DEFAULT;
 done:
-	if (sc->probe_result <= BUS_PROBE_SPECIFIC) {
-		snprintf(buf, sizeof(buf), "%s I2C HID device", sc->hw.name);
-		device_set_desc_copy(dev, buf);
-	}
+	if (sc->probe_result <= BUS_PROBE_SPECIFIC)
+		device_set_descf(dev, "%s I2C HID device", sc->hw.name);
 	return (sc->probe_result);
 }
 
diff --git a/sys/dev/isp/isp.c b/sys/dev/isp/isp.c
index b53171add5f5..ad6dbd1e6f76 100644
--- a/sys/dev/isp/isp.c
+++ b/sys/dev/isp/isp.c
@@ -3088,6 +3088,7 @@ isp_control(ispsoftc_t *isp, ispctl_t ctl, ...)
 		if (ab->abrt_nphdl == ISP24XX_ABRT_OKAY)
 			return (0);
 		isp_prt(isp, ISP_LOGWARN, "Chan %d handle %d abort returned 0x%x", chan, tgt, ab->abrt_nphdl);
+		break;
 	}
 	case ISPCTL_FCLINK_TEST:
 	{
diff --git a/sys/dev/iwn/if_iwn.c b/sys/dev/iwn/if_iwn.c
index 3b1d879914b6..d2d44d93f948 100644
--- a/sys/dev/iwn/if_iwn.c
+++ b/sys/dev/iwn/if_iwn.c
@@ -7532,7 +7532,7 @@ iwn_addba_request(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap,
 			break;
 	}
 	if (qid == sc->ntxqs) {
-		DPRINTF(sc, IWN_DEBUG_XMIT, "%s: not free aggregation queue\n",
+		DPRINTF(sc, IWN_DEBUG_XMIT, "%s: no free aggregation queue\n",
 		    __func__);
 		return 0;
 	}
diff --git a/sys/dev/jedec_dimm/jedec_dimm.c b/sys/dev/jedec_dimm/jedec_dimm.c
index ddaa0e96856e..697e7695a009 100644
--- a/sys/dev/jedec_dimm/jedec_dimm.c
+++ b/sys/dev/jedec_dimm/jedec_dimm.c
@@ -265,7 +265,6 @@ jedec_dimm_attach(device_t dev)
 	uint16_t vendorid;
 	bool tsod_present;
 	int rc;
-	int new_desc_len;
 	enum dram_type type;
 	struct jedec_dimm_softc *sc;
 	struct sysctl_ctx_list *ctx;
@@ -273,7 +272,6 @@ jedec_dimm_attach(device_t dev)
 	struct sysctl_oid_list *children;
 	const char *tsod_match;
 	const char *slotid_str;
-	char *new_desc;
 
 	sc = device_get_softc(dev);
 	ctx = device_get_sysctl_ctx(dev);
@@ -447,26 +445,13 @@ jedec_dimm_attach(device_t dev)
 	 * device description.
 	 */
 	if ((tsod_match != NULL) || (sc->slotid_str != NULL)) {
-		new_desc_len = strlen(device_get_desc(dev));
-		if (tsod_match != NULL) {
-			new_desc_len += strlen(tsod_match);
-			new_desc_len += 4; /* " w/ " */
-		}
-		if (sc->slotid_str != NULL) {
-			new_desc_len += strlen(sc->slotid_str);
-			new_desc_len += 3; /* space + parens */
-		}
-		new_desc_len++; /* terminator */
-		new_desc = malloc(new_desc_len, M_TEMP, (M_WAITOK | M_ZERO));
-		(void) snprintf(new_desc, new_desc_len, "%s%s%s%s%s%s",
+		device_set_descf(dev, "%s%s%s%s%s%s",
 		    device_get_desc(dev),
 		    (tsod_match ? " w/ " : ""),
 		    (tsod_match ? tsod_match : ""),
 		    (sc->slotid_str ? " (" : ""),
 		    (sc->slotid_str ? sc->slotid_str : ""),
 		    (sc->slotid_str ? ")" : ""));
-		device_set_desc_copy(dev, new_desc);
-		free(new_desc, M_TEMP);
 	}
 
 out:
diff --git a/sys/dev/jme/if_jme.c b/sys/dev/jme/if_jme.c
index 89c78d80afe0..3631e5f8ffa0 100644
--- a/sys/dev/jme/if_jme.c
+++ b/sys/dev/jme/if_jme.c
@@ -805,12 +805,6 @@ jme_attach(device_t dev)
 		goto fail;
 
 	ifp = sc->jme_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "cannot allocate ifnet structure.\n");
-		error = ENXIO;
-		goto fail;
-	}
-
 	if_setsoftc(ifp, sc);
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 	if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
diff --git a/sys/dev/le/lance.c b/sys/dev/le/lance.c
index e09e82eb34cc..6add3aa4a1b5 100644
--- a/sys/dev/le/lance.c
+++ b/sys/dev/le/lance.c
@@ -110,8 +110,6 @@ lance_config(struct lance_softc *sc, const char* name, int unit)
 		return (ENXIO);
 
 	ifp = sc->sc_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL)
-		return (ENOSPC);
 
 	callout_init_mtx(&sc->sc_wdog_ch, &sc->sc_mtx, 0);
 
diff --git a/sys/dev/lge/if_lge.c b/sys/dev/lge/if_lge.c
index d77866ee3cad..dfcaa01d366b 100644
--- a/sys/dev/lge/if_lge.c
+++ b/sys/dev/lge/if_lge.c
@@ -512,11 +512,6 @@ lge_attach(device_t dev)
 	}
 
 	ifp = sc->lge_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "can not if_alloc()\n");
-		error = ENOSPC;
-		goto fail;
-	}
 	if_setsoftc(ifp, sc);
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 	if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
diff --git a/sys/dev/liquidio/lio_main.c b/sys/dev/liquidio/lio_main.c
index bec510af0c65..7104ff07674f 100644
--- a/sys/dev/liquidio/lio_main.c
+++ b/sys/dev/liquidio/lio_main.c
@@ -200,7 +200,6 @@ lio_probe(device_t dev)
 	uint16_t	device_id;
 	uint16_t	subdevice_id;
 	uint8_t		revision_id;
-	char		device_ver[256];
 
 	vendor_id = pci_get_vendor(dev);
 	if (vendor_id != PCI_VENDOR_ID_CAVIUM)
@@ -216,9 +215,8 @@ lio_probe(device_t dev)
 		    (device_id == tbl->device_id) &&
 		    (subdevice_id == tbl->subdevice_id) &&
 		    (revision_id == tbl->revision_id)) {
-			sprintf(device_ver, "%s, Version - %s",
-				lio_strings[tbl->index], LIO_VERSION);
-			device_set_desc_copy(dev, device_ver);
+			device_set_descf(dev, "%s, Version - %s",
+			    lio_strings[tbl->index], LIO_VERSION);
 			return (BUS_PROBE_DEFAULT);
 		}
 
@@ -1329,11 +1327,6 @@ lio_setup_nic_devices(struct octeon_device *octeon_dev)
 
 		ifp = if_alloc(IFT_ETHER);
 
-		if (ifp == NULL) {
-			lio_dev_err(octeon_dev, "Device allocation failed\n");
-			goto setup_nic_dev_fail;
-		}
-
 		lio = malloc(sizeof(struct lio), M_DEVBUF, M_NOWAIT | M_ZERO);
 
 		if (lio == NULL) {
diff --git a/sys/dev/mana/gdma_main.c b/sys/dev/mana/gdma_main.c
index e09918496b03..d0438f127b83 100644
--- a/sys/dev/mana/gdma_main.c
+++ b/sys/dev/mana/gdma_main.c
@@ -1750,7 +1750,6 @@ static int
 mana_gd_probe(device_t dev)
 {
 	mana_vendor_id_t *ent;
-	char		adapter_name[60];
 	uint16_t	pci_vendor_id = 0;
 	uint16_t	pci_device_id = 0;
 
@@ -1764,8 +1763,7 @@ mana_gd_probe(device_t dev)
 			mana_dbg(NULL, "vendor=%x device=%x\n",
 			    pci_vendor_id, pci_device_id);
 
-			sprintf(adapter_name, DEVICE_DESC);
-			device_set_desc_copy(dev, adapter_name);
+			device_set_desc(dev, DEVICE_DESC);
 			return (BUS_PROBE_DEFAULT);
 		}
 
diff --git a/sys/dev/mana/mana_en.c b/sys/dev/mana/mana_en.c
index 09de49a11010..50a6192e5fbc 100644
--- a/sys/dev/mana/mana_en.c
+++ b/sys/dev/mana/mana_en.c
@@ -2805,11 +2805,6 @@ mana_probe_port(struct mana_context *ac, int port_idx,
 	int err;
 
 	ndev = if_alloc_dev(IFT_ETHER, gc->dev);
-	if (!ndev) {
-		mana_err(NULL, "Failed to allocate ifnet struct\n");
-		return ENOMEM;
-	}
-
 	*ndev_storage = ndev;
 
 	apc = malloc(sizeof(*apc), M_DEVBUF, M_WAITOK | M_ZERO);
diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c
index a6f015962a24..1d531b88193f 100644
--- a/sys/dev/md/md.c
+++ b/sys/dev/md/md.c
@@ -1351,7 +1351,7 @@ mdcreate_malloc(struct md_s *sc, struct md_req *mdr)
 		sc->fwsectors = mdr->md_fwsectors;
 	if (mdr->md_fwheads != 0)
 		sc->fwheads = mdr->md_fwheads;
-	sc->flags = mdr->md_options & (MD_COMPRESS | MD_FORCE);
+	sc->flags = mdr->md_options & (MD_COMPRESS | MD_FORCE | MD_RESERVE);
 	sc->indir = dimension(sc->mediasize / sc->sectorsize);
 	sc->uma = uma_zcreate(sc->name, sc->sectorsize, NULL, NULL, NULL, NULL,
 	    0x1ff, 0);
@@ -1476,7 +1476,7 @@ mdcreate_vnode(struct md_s *sc, struct md_req *mdr, struct thread *td)
 	snprintf(sc->ident, sizeof(sc->ident), "MD-DEV%ju-INO%ju",
 	    (uintmax_t)vattr.va_fsid, (uintmax_t)vattr.va_fileid);
 	sc->flags = mdr->md_options & (MD_ASYNC | MD_CACHE | MD_FORCE |
-	    MD_VERIFY);
+	    MD_VERIFY | MD_MUSTDEALLOC);
 	if (!(flags & FWRITE))
 		sc->flags |= MD_READONLY;
 	sc->vnode = nd.ni_vp;
diff --git a/sys/dev/mge/if_mge.c b/sys/dev/mge/if_mge.c
index 30650cc6df82..02b182eda41b 100644
--- a/sys/dev/mge/if_mge.c
+++ b/sys/dev/mge/if_mge.c
@@ -848,12 +848,6 @@ mge_attach(device_t dev)
 
 	/* Allocate network interface */
 	ifp = sc->ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "if_alloc() failed\n");
-		mge_detach(dev);
-		return (ENOMEM);
-	}
-
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 	if_setsoftc(ifp, sc);
 	if_setflags(ifp, IFF_SIMPLEX | IFF_MULTICAST | IFF_BROADCAST);
diff --git a/sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c b/sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c
index 583de1816d1b..ac4bfd1b1a14 100644
--- a/sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c
+++ b/sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c
@@ -2143,11 +2143,6 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
 
 	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
 	dev = priv->dev = if_alloc(IFT_ETHER);
-	if (dev == NULL) {
-		en_err(priv, "Net device allocation failed\n");
-		kfree(priv);
-		return -ENOMEM;
-	}
 	if_setsoftc(dev, priv);
 	if_initname(dev, "mlxen", (device_get_unit(
 	    mdev->pdev->dev.bsddev) * MLX4_MAX_PORTS) + port - 1);
diff --git a/sys/dev/mlx4/mlx4_en/mlx4_en_tx.c b/sys/dev/mlx4/mlx4_en/mlx4_en_tx.c
index ee8ed0da240d..d45ccacd7499 100644
--- a/sys/dev/mlx4/mlx4_en/mlx4_en_tx.c
+++ b/sys/dev/mlx4/mlx4_en/mlx4_en_tx.c
@@ -91,8 +91,8 @@ int mlx4_en_create_tx_ring(struct mlx4_en_priv *priv,
 	ring->size_mask = size - 1;
 	ring->stride = stride;
 	ring->inline_thold = MAX(MIN_PKT_LEN, MIN(priv->prof->inline_thold, MAX_INLINE));
-	mtx_init(&ring->tx_lock.m, "mlx4 tx", NULL, MTX_DEF);
-	mtx_init(&ring->comp_lock.m, "mlx4 comp", NULL, MTX_DEF);
+	mtx_init(&ring->tx_lock, "mlx4 tx", NULL, MTX_DEF);
+	mtx_init(&ring->comp_lock, "mlx4 comp", NULL, MTX_DEF);
 
 	tmp = size * sizeof(struct mlx4_en_tx_info);
 	ring->tx_info = kzalloc_node(tmp, GFP_KERNEL, node);
@@ -205,8 +205,8 @@ void mlx4_en_destroy_tx_ring(struct mlx4_en_priv *priv,
 	for (x = 0; x != ring->size; x++)
 		bus_dmamap_destroy(ring->dma_tag, ring->tx_info[x].dma_map);
 	vfree(ring->tx_info);
-	mtx_destroy(&ring->tx_lock.m);
-	mtx_destroy(&ring->comp_lock.m);
+	mtx_destroy(&ring->tx_lock);
+	mtx_destroy(&ring->comp_lock);
 	bus_dma_tag_destroy(ring->dma_tag);
 	kfree(ring);
 	*pring = NULL;
@@ -688,7 +688,7 @@ int mlx4_en_xmit(struct mlx4_en_priv *priv, int tx_ind, struct mbuf **mbp)
 	dseg = &tx_desc->data;
 
 	/* send a copy of the frame to the BPF listener, if any */
-	if (ifp != NULL && if_getbpf(ifp) != NULL)
+	if (ifp != NULL)
 		ETHER_BPF_MTAP(ifp, mb);
 
 	/* get default flags */
diff --git a/sys/dev/mlx5/mlx5_core/mlx5_main.c b/sys/dev/mlx5/mlx5_core/mlx5_main.c
index 6b9b63a24714..95d88c728306 100644
--- a/sys/dev/mlx5/mlx5_core/mlx5_main.c
+++ b/sys/dev/mlx5/mlx5_core/mlx5_main.c
@@ -52,8 +52,12 @@
 #include <dev/mlx5/mlx5_core/diag_cnt.h>
 #ifdef PCI_IOV
 #include <sys/nv.h>
+#include <sys/socket.h>
 #include <dev/pci/pci_iov.h>
 #include <sys/iov_schema.h>
+#include <sys/iov.h>
+#include <net/if.h>
+#include <net/if_vlan_var.h>
 #endif
 
 static const char mlx5_version[] = "Mellanox Core driver "
@@ -225,6 +229,7 @@ static void mlx5_set_driver_version(struct mlx5_core_dev *dev)
 
 #ifdef PCI_IOV
 static const char iov_mac_addr_name[] = "mac-addr";
+static const char iov_vlan_name[] = "vlan";
 static const char iov_node_guid_name[] = "node-guid";
 static const char iov_port_guid_name[] = "port-guid";
 #endif
@@ -1714,6 +1719,8 @@ static int init_one(struct pci_dev *pdev,
 			vf_schema = pci_iov_schema_alloc_node();
 			pci_iov_schema_add_unicast_mac(vf_schema,
 			    iov_mac_addr_name, 0, NULL);
+			pci_iov_schema_add_vlan(vf_schema,
+			    iov_vlan_name, 0, 0);
 			pci_iov_schema_add_uint64(vf_schema, iov_node_guid_name,
 			    0, 0);
 			pci_iov_schema_add_uint64(vf_schema, iov_port_guid_name,
@@ -1950,6 +1957,25 @@ mlx5_iov_add_vf(device_t dev, uint16_t vfnum, const nvlist_t *vf_config)
 		}
 	}
 
+	if (nvlist_exists_number(vf_config, iov_vlan_name)) {
+		uint16_t vlan = nvlist_get_number(vf_config, iov_vlan_name);
+
+		if (vlan == DOT1Q_VID_NULL)
+			error = ENOTSUP;
+		else {
+			if (vlan == VF_VLAN_TRUNK)
+				vlan = DOT1Q_VID_NULL;
+
+			error = -mlx5_eswitch_set_vport_vlan(priv->eswitch,
+			    vfnum + 1, vlan, 0);
+		}
+		if (error != 0) {
+			mlx5_core_err(core_dev,
+			    "setting VLAN for VF %d failed, error %d\n",
+			    vfnum + 1, error);
+		}
+	}
+
 	if (nvlist_exists_number(vf_config, iov_node_guid_name)) {
 		node_guid = nvlist_get_number(vf_config, iov_node_guid_name);
 		error = -mlx5_modify_nic_vport_node_guid(core_dev, vfnum + 1,
diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
index 962705e6d258..97ec1b4420a8 100644
--- a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
+++ b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
@@ -4488,10 +4488,6 @@ mlx5e_create_ifp(struct mlx5_core_dev *mdev)
 	    M_MLX5EN, mlx5_dev_domainset(mdev), M_WAITOK | M_ZERO);
 
 	ifp = priv->ifp = if_alloc_dev(IFT_ETHER, mdev->pdev->dev.bsddev);
-	if (ifp == NULL) {
-		mlx5_core_err(mdev, "if_alloc() failed\n");
-		goto err_free_priv;
-	}
 	/* setup all static fields */
 	if (mlx5e_priv_static_init(priv, mdev, mdev->priv.eq_table.num_comp_vectors)) {
 		mlx5_core_err(mdev, "mlx5e_priv_static_init() failed\n");
@@ -4831,8 +4827,6 @@ mlx5e_create_ifp(struct mlx5_core_dev *mdev)
 
 err_free_ifp:
 	if_free(ifp);
-
-err_free_priv:
 	free(priv, M_MLX5EN);
 	return (NULL);
 }
diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c b/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c
index 1f2820abc30e..3f70e8a818ea 100644
--- a/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c
+++ b/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c
@@ -745,7 +745,7 @@ mlx5e_sq_xmit(struct mlx5e_sq *sq, struct mbuf **mbp)
 	mb = *mbp;
 
 	/* Send a copy of the frame to the BPF listener, if any */
-	if (ifp != NULL && if_getbpf(ifp) != NULL)
+	if (ifp != NULL)
 		ETHER_BPF_MTAP(ifp, mb);
 
 	if (mb->m_pkthdr.csum_flags & (CSUM_IP | CSUM_TSO)) {
diff --git a/sys/dev/mps/mps_pci.c b/sys/dev/mps/mps_pci.c
index ece49435b39e..7a0c577eb72a 100644
--- a/sys/dev/mps/mps_pci.c
+++ b/sys/dev/mps/mps_pci.c
@@ -122,8 +122,8 @@ struct mps_ident {
 	    0xffff, 0xffff, 0, "Avago Technologies (LSI) SAS2208" },
 	{ MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2308_1,
 	    0xffff, 0xffff, 0, "Avago Technologies (LSI) SAS2308" },
-	// Add Customer specific vender/subdevice id before generic
-	// (0xffff) vender/subdevice id.
+	// Add Customer specific vendor/subdevice id before generic
+	// (0xffff) vendor/subdevice id.
 	{ MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2308_2,
 	    0x8086, 0x3516, 0, "Intel(R) Integrated RAID Module RMS25JB080" },
 	{ MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2308_2,
diff --git a/sys/dev/msk/if_msk.c b/sys/dev/msk/if_msk.c
index 4b6954e7d067..ff9fdb96b745 100644
--- a/sys/dev/msk/if_msk.c
+++ b/sys/dev/msk/if_msk.c
@@ -1565,7 +1565,6 @@ static int
 msk_probe(device_t dev)
 {
 	struct msk_softc *sc;
-	char desc[100];
 
 	sc = device_get_softc(device_get_parent(dev));
 	/*
@@ -1574,11 +1573,10 @@ msk_probe(device_t dev)
 	 * mskc_attach() will create a second device instance
 	 * for us.
 	 */
-	snprintf(desc, sizeof(desc),
+	device_set_descf(dev,
 	    "Marvell Technology Group Ltd. %s Id 0x%02x Rev 0x%02x",
 	    model_name[sc->msk_hw_id - CHIP_ID_YUKON_XL], sc->msk_hw_id,
 	    sc->msk_hw_rev);
-	device_set_desc_copy(dev, desc);
 
 	return (BUS_PROBE_DEFAULT);
 }
@@ -1626,11 +1624,6 @@ msk_attach(device_t dev)
 	msk_rx_dma_jalloc(sc_if);
 
 	ifp = sc_if->msk_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(sc_if->msk_if_dev, "can not if_alloc()\n");
-		error = ENOSPC;
-		goto fail;
-	}
 	if_setsoftc(ifp, sc_if);
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 	if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
diff --git a/sys/dev/mvs/mvs.c b/sys/dev/mvs/mvs.c
index 250040898022..21e0984342d0 100644
--- a/sys/dev/mvs/mvs.c
+++ b/sys/dev/mvs/mvs.c
@@ -106,7 +106,7 @@ static int
 mvs_ch_probe(device_t dev)
 {
 
-	device_set_desc_copy(dev, "Marvell SATA channel");
+	device_set_desc(dev, "Marvell SATA channel");
 	return (BUS_PROBE_DEFAULT);
 }
 
diff --git a/sys/dev/mvs/mvs_pci.c b/sys/dev/mvs/mvs_pci.c
index 9f4c835a9bce..5e5da6f35a7e 100644
--- a/sys/dev/mvs/mvs_pci.c
+++ b/sys/dev/mvs/mvs_pci.c
@@ -78,7 +78,6 @@ static struct {
 static int
 mvs_probe(device_t dev)
 {
-	char buf[64];
 	int i;
 	uint32_t devid = pci_get_devid(dev);
 	uint8_t revid = pci_get_revid(dev);
@@ -86,9 +85,8 @@ mvs_probe(device_t dev)
 	for (i = 0; mvs_ids[i].id != 0; i++) {
 		if (mvs_ids[i].id == devid &&
 		    mvs_ids[i].rev <= revid) {
-			snprintf(buf, sizeof(buf), "%s SATA controller",
+			device_set_descf(dev, "%s SATA controller",
 			    mvs_ids[i].name);
-			device_set_desc_copy(dev, buf);
 			return (BUS_PROBE_DEFAULT);
 		}
 	}
diff --git a/sys/dev/mvs/mvs_soc.c b/sys/dev/mvs/mvs_soc.c
index 849e1a012a53..5fccf36b5446 100644
--- a/sys/dev/mvs/mvs_soc.c
+++ b/sys/dev/mvs/mvs_soc.c
@@ -75,7 +75,6 @@ static struct {
 static int
 mvs_probe(device_t dev)
 {
-	char buf[64];
 	int i;
 	uint32_t devid, revid;
 
@@ -89,9 +88,8 @@ mvs_probe(device_t dev)
 	for (i = 0; mvs_ids[i].id != 0; i++) {
 		if (mvs_ids[i].id == devid &&
 		    mvs_ids[i].rev <= revid) {
-			snprintf(buf, sizeof(buf), "%s SATA controller",
+			device_set_descf(dev, "%s SATA controller",
 			    mvs_ids[i].name);
-			device_set_desc_copy(dev, buf);
 			return (BUS_PROBE_DEFAULT);
 		}
 	}
diff --git a/sys/dev/mxge/if_mxge.c b/sys/dev/mxge/if_mxge.c
index 26d6410f356d..158bb8e5888c 100644
--- a/sys/dev/mxge/if_mxge.c
+++ b/sys/dev/mxge/if_mxge.c
@@ -4641,11 +4641,6 @@ mxge_attach(device_t dev)
 	}
 
 	ifp = sc->ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "can not if_alloc()\n");
-		err = ENOSPC;
-		goto abort_with_parent_dmat;
-	}
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 
 	snprintf(sc->cmd_mtx_name, sizeof(sc->cmd_mtx_name), "%s:cmd",
@@ -4814,7 +4809,6 @@ mxge_attach(device_t dev)
 	mtx_destroy(&sc->cmd_mtx);
 	mtx_destroy(&sc->driver_mtx);
 	if_free(ifp);
-abort_with_parent_dmat:
 	bus_dma_tag_destroy(sc->parent_dmat);
 abort_with_tq:
 	if (sc->tq != NULL) {
diff --git a/sys/dev/my/if_my.c b/sys/dev/my/if_my.c
index 2bf4573d337b..3de394f424a2 100644
--- a/sys/dev/my/if_my.c
+++ b/sys/dev/my/if_my.c
@@ -874,11 +874,6 @@ my_attach(device_t dev)
 	bzero(sc->my_ldata, sizeof(struct my_list_data));
 
 	ifp = sc->my_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "can not if_alloc()\n");
-		error = ENOSPC;
-		goto free_ldata;
-	}
 	if_setsoftc(ifp, sc);
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 	if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
@@ -962,7 +957,6 @@ my_attach(device_t dev)
 	ether_ifdetach(ifp);
 free_if:
 	if_free(ifp);
-free_ldata:
 	free(sc->my_ldata_ptr, M_DEVBUF);
 release_irq:
 	bus_release_resource(dev, SYS_RES_IRQ, 0, sc->my_irq);
diff --git a/sys/dev/neta/if_mvneta.c b/sys/dev/neta/if_mvneta.c
index bb95bc9c588e..fdd6467edde1 100644
--- a/sys/dev/neta/if_mvneta.c
+++ b/sys/dev/neta/if_mvneta.c
@@ -612,11 +612,6 @@ mvneta_attach(device_t self)
 
 	/* Allocate network interface */
 	ifp = sc->ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(self, "if_alloc() failed\n");
-		mvneta_detach(self);
-		return (ENOMEM);
-	}
 	if_initname(ifp, device_get_name(self), device_get_unit(self));
 
 	/*
diff --git a/sys/dev/netmap/if_ptnet.c b/sys/dev/netmap/if_ptnet.c
index 56d853eb7392..cea62517b2e6 100644
--- a/sys/dev/netmap/if_ptnet.c
+++ b/sys/dev/netmap/if_ptnet.c
@@ -399,12 +399,6 @@ ptnet_attach(device_t dev)
 
 	/* Setup Ethernet interface. */
 	sc->ifp = ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "Failed to allocate ifnet\n");
-		err = ENOMEM;
-		goto err_path;
-	}
-
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 	if_setbaudrate(ifp, IF_Gbps(10));
 	if_setsoftc(ifp, sc);
diff --git a/sys/dev/netmap/netmap_freebsd.c b/sys/dev/netmap/netmap_freebsd.c
index a4a0124471c0..215b1f7bd09e 100644
--- a/sys/dev/netmap/netmap_freebsd.c
+++ b/sys/dev/netmap/netmap_freebsd.c
@@ -612,10 +612,6 @@ nm_os_vi_persist(const char *name, if_t *ret)
 	eaddr[5] = (uint8_t)unit;
 
 	ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		nm_prerr("if_alloc failed");
-		return ENOMEM;
-	}
 	if_initname(ifp, name, IF_DUNIT_NONE);
 	if_setflags(ifp, IFF_UP | IFF_SIMPLEX | IFF_MULTICAST);
 	if_setinitfn(ifp, (void *)nm_vi_dummy);
@@ -864,16 +860,12 @@ nm_os_pt_memdev_iounmap(struct ptnetmap_memdev *ptn_dev)
 static int
 ptn_memdev_probe(device_t dev)
 {
-	char desc[256];
-
 	if (pci_get_vendor(dev) != PTNETMAP_PCI_VENDOR_ID)
 		return (ENXIO);
 	if (pci_get_device(dev) != PTNETMAP_PCI_DEVICE_ID)
 		return (ENXIO);
 
-	snprintf(desc, sizeof(desc), "%s PCI adapter",
-			PTNETMAP_MEMDEV_NAME);
-	device_set_desc_copy(dev, desc);
+	device_set_descf(dev, "%s PCI adapter", PTNETMAP_MEMDEV_NAME);
 
 	return (BUS_PROBE_DEFAULT);
 }
diff --git a/sys/dev/nfe/if_nfe.c b/sys/dev/nfe/if_nfe.c
index aedae79ddf80..15f4cd1f7c7b 100644
--- a/sys/dev/nfe/if_nfe.c
+++ b/sys/dev/nfe/if_nfe.c
@@ -567,11 +567,6 @@ nfe_attach(device_t dev)
 		goto fail;
 
 	ifp = sc->nfe_ifp = if_gethandle(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "can not if_gethandle()\n");
-		error = ENOSPC;
-		goto fail;
-	}
 
 	/*
 	 * Allocate Tx and Rx rings.
diff --git a/sys/dev/nge/if_nge.c b/sys/dev/nge/if_nge.c
index dc3be913f89b..c7c2b3c99d5a 100644
--- a/sys/dev/nge/if_nge.c
+++ b/sys/dev/nge/if_nge.c
@@ -900,11 +900,6 @@ nge_attach(device_t dev)
 	nge_sysctl_node(sc);
 
 	ifp = sc->nge_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "can not allocate ifnet structure\n");
-		error = ENOSPC;
-		goto fail;
-	}
 	if_setsoftc(ifp, sc);
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 	if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
diff --git a/sys/dev/ntb/if_ntb/if_ntb.c b/sys/dev/ntb/if_ntb/if_ntb.c
index fb0c601f4222..59a2e76ee143 100644
--- a/sys/dev/ntb/if_ntb/if_ntb.c
+++ b/sys/dev/ntb/if_ntb/if_ntb.c
@@ -137,10 +137,6 @@ ntb_net_attach(device_t dev)
 	int i;
 
 	ifp = sc->ifp = if_gethandle(IFT_ETHER);
-	if (ifp == NULL) {
-		printf("ntb: Cannot allocate ifnet structure\n");
-		return (ENOMEM);
-	}
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 	if_setdev(ifp, dev);
 
diff --git a/sys/dev/oce/oce_if.c b/sys/dev/oce/oce_if.c
index d7ec58ec1f5e..bf257b952a03 100644
--- a/sys/dev/oce/oce_if.c
+++ b/sys/dev/oce/oce_if.c
@@ -170,7 +170,7 @@ static void oce_rx_lro(struct oce_rq *rq, struct nic_hwlro_singleton_cqe *cqe, s
 static void oce_rx_mbuf_chain(struct oce_rq *rq, struct oce_common_cqe_info *cqe_info, struct mbuf **m);
 
 /* Helper function prototypes in this file */
-static int  oce_attach_ifp(POCE_SOFTC sc);
+static void oce_attach_ifp(POCE_SOFTC sc);
 static void oce_add_vlan(void *arg, if_t ifp, uint16_t vtag);
 static void oce_del_vlan(void *arg, if_t ifp, uint16_t vtag);
 static int  oce_vid_config(POCE_SOFTC sc);
@@ -252,7 +252,6 @@ oce_probe(device_t dev)
 	uint16_t vendor = 0;
 	uint16_t device = 0;
 	int i = 0;
-	char str[256] = {0};
 	POCE_SOFTC sc;
 
 	sc = device_get_softc(dev);
@@ -265,9 +264,9 @@ oce_probe(device_t dev)
 	for (i = 0; i < (sizeof(supportedDevices) / sizeof(uint32_t)); i++) {
 		if (vendor == ((supportedDevices[i] >> 16) & 0xffff)) {
 			if (device == (supportedDevices[i] & 0xffff)) {
-				sprintf(str, "%s:%s", "Emulex CNA NIC function",
-					component_revision);
-				device_set_desc_copy(dev, str);
+				device_set_descf(dev,
+				    "%s:%s", "Emulex CNA NIC function",
+				    component_revision);
 
 				switch (device) {
 				case PCI_PRODUCT_BE2:
@@ -335,9 +334,7 @@ oce_attach(device_t dev)
 	if (rc)
 		goto intr_free;
 
-	rc = oce_attach_ifp(sc);
-	if (rc)
-		goto queues_free;
+	oce_attach_ifp(sc);
 
 #if defined(INET6) || defined(INET)
 	rc = oce_init_lro(sc);
@@ -393,7 +390,6 @@ oce_attach(device_t dev)
 #endif
 	ether_ifdetach(sc->ifp);
 	if_free(sc->ifp);
-queues_free:
 	oce_queue_release_all(sc);
 intr_free:
 	oce_intr_free(sc);
@@ -2100,13 +2096,11 @@ oce_rq_handler(void *arg)
  *		   Helper function prototypes in this file 		     *
  *****************************************************************************/
 
-static int 
+static void
 oce_attach_ifp(POCE_SOFTC sc)
 {
 
 	sc->ifp = if_alloc(IFT_ETHER);
-	if (!sc->ifp)
-		return ENOMEM;
 
 	ifmedia_init(&sc->media, IFM_IMASK, oce_media_change, oce_media_status);
 	ifmedia_add(&sc->media, IFM_ETHER | IFM_AUTO, 0, NULL);
@@ -2149,8 +2143,6 @@ oce_attach_ifp(POCE_SOFTC sc)
 	if_sethwtsomaxsegsize(sc->ifp, 4096);
 
 	ether_ifattach(sc->ifp, sc->macaddr.mac_addr);
-
-	return 0;
 }
 
 static void
diff --git a/sys/dev/ocs_fc/ocs_hw.c b/sys/dev/ocs_fc/ocs_hw.c
index cfb9d4f8f536..c368e09aef8c 100644
--- a/sys/dev/ocs_fc/ocs_hw.c
+++ b/sys/dev/ocs_fc/ocs_hw.c
@@ -11214,7 +11214,7 @@ target_wqe_timer_nop_cb(ocs_hw_t *hw, int32_t status, uint8_t *mqe, void *arg)
 		getmicrouptime(&cur_time);
 		timevalsub(&cur_time, &io->submit_time);
 		if (cur_time.tv_sec > io->wqe_timeout) {
-			ocs_log_info(hw->os, "IO timeout xri=0x%x tag=0x%x type=%d elasped time:%u\n",
+			ocs_log_info(hw->os, "IO timeout xri=0x%x tag=0x%x type=%d elapsed time:%u\n",
 				     io->indicator, io->reqtag, io->type, cur_time.tv_sec);
 
 			/* remove from active_wqe list so won't try to abort again */
diff --git a/sys/dev/pci/pci_iov_schema.c b/sys/dev/pci/pci_iov_schema.c
index 742dfbd2b4d9..bb87e7215bc8 100644
--- a/sys/dev/pci/pci_iov_schema.c
+++ b/sys/dev/pci/pci_iov_schema.c
@@ -55,11 +55,13 @@ static validate_func pci_iov_schema_validate_bool;
 static validate_func pci_iov_schema_validate_string;
 static validate_func pci_iov_schema_validate_uint;
 static validate_func pci_iov_schema_validate_unicast_mac;
+static validate_func pci_iov_schema_validate_vlan;
 
 static default_validate_t pci_iov_validate_bool_default;
 static default_validate_t pci_iov_validate_string_default;
 static default_validate_t pci_iov_validate_uint_default;
 static default_validate_t pci_iov_validate_unicast_mac_default;
+static default_validate_t pci_iov_validate_vlan_default;
 
 struct config_type_validator {
 	const char *type_name;
@@ -108,6 +110,11 @@ static struct config_type_validator pci_iov_schema_validators[] = {
 		.validate = pci_iov_schema_validate_unicast_mac,
 		.default_validate = pci_iov_validate_unicast_mac_default,
 	},
+	{
+		.type_name = "vlan",
+		.validate = pci_iov_schema_validate_vlan,
+		.default_validate = pci_iov_validate_vlan_default,
+	},
 };
 
 static const struct config_type_validator *
@@ -262,6 +269,26 @@ pci_iov_schema_add_unicast_mac(nvlist_t *schema, const char *name,
 	nvlist_move_nvlist(schema, name, entry);
 }
 
+void
+pci_iov_schema_add_vlan(nvlist_t *schema, const char *name,
+    uint32_t flags, const uint16_t defaultVal)
+{
+	nvlist_t *entry;
+
+	entry = nvlist_create(NV_FLAG_IGNORE_CASE);
+	if (entry == NULL) {
+		nvlist_set_error(schema, ENOMEM);
+		return;
+	}
+
+	pci_iov_schema_add_type(entry, "vlan");
+	if (flags & IOV_SCHEMA_HASDEFAULT)
+		nvlist_add_number(entry, "default", defaultVal);
+	pci_iov_schema_add_required(entry, flags);
+
+	nvlist_move_nvlist(schema, name, entry);
+}
+
 static int
 pci_iov_schema_validate_bool(const struct config_type_validator * validator,
    const nvlist_t *config, const char *name)
@@ -321,6 +348,24 @@ pci_iov_schema_validate_unicast_mac(
 	return (0);
 }
 
+static int
+pci_iov_schema_validate_vlan(
+    const struct config_type_validator * validator,
+    const nvlist_t *config, const char *name)
+{
+	uint16_t vlan;
+
+	if (!nvlist_exists_number(config, name))
+		return (EINVAL);
+
+	vlan = nvlist_get_number(config, name);
+
+	if (vlan > 4095 && vlan != VF_VLAN_TRUNK)
+		return (EINVAL);
+
+	return (0);
+}
+
 static void
 pci_iov_config_add_default(const nvlist_t *param_schema, const char *name,
     nvlist_t *config)
@@ -401,6 +446,22 @@ pci_iov_validate_unicast_mac_default(
 	return (0);
 }
 
+static int
+pci_iov_validate_vlan_default(
+    const struct config_type_validator * validator, const nvlist_t *param)
+{
+	uint16_t vlan;
+
+	if (! nvlist_exists_number(param, DEFAULT_SCHEMA_NAME))
+		return (EINVAL);
+
+	vlan = nvlist_get_number(param, DEFAULT_SCHEMA_NAME);
+	if (vlan > 4095 && vlan != VF_VLAN_TRUNK)
+		return (EINVAL);
+
+	return (0);
+}
+
 static int
 pci_iov_validate_param_schema(const nvlist_t *schema)
 {
diff --git a/sys/dev/ppbus/if_plip.c b/sys/dev/ppbus/if_plip.c
index a9ef8dc016b7..c2adcb602f6b 100644
--- a/sys/dev/ppbus/if_plip.c
+++ b/sys/dev/ppbus/if_plip.c
@@ -249,10 +249,6 @@ lp_attach(device_t dev)
 	}
 
 	ifp = lp->sc_ifp = if_alloc(IFT_PARA);
-	if (ifp == NULL) {
-		return (ENOSPC);
-	}
-
 	if_setsoftc(ifp, lp);
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 	if_setmtu(ifp, LPMTU);
diff --git a/sys/dev/proto/proto_bus_isa.c b/sys/dev/proto/proto_bus_isa.c
index 31c65b9d7857..7176543345a7 100644
--- a/sys/dev/proto/proto_bus_isa.c
+++ b/sys/dev/proto/proto_bus_isa.c
@@ -33,7 +33,6 @@
 #include <machine/bus.h>
 #include <sys/rman.h>
 #include <machine/resource.h>
-#include <sys/sbuf.h>
 
 #include <isa/isavar.h>
 #include <isa/pnpvar.h>
@@ -63,7 +62,6 @@ static char **proto_isa_devnames;
 static int
 proto_isa_probe(device_t dev)
 {
-	struct sbuf *sb;
 	struct resource *res;
 	int rid, type;
 
@@ -77,11 +75,7 @@ proto_isa_probe(device_t dev)
 	if (res == NULL)
 		return (ENODEV);
 
-	sb = sbuf_new_auto();
-	sbuf_printf(sb, "%s:%#jx", proto_isa_prefix, rman_get_start(res));
-	sbuf_finish(sb);
-	device_set_desc_copy(dev, sbuf_data(sb));
-	sbuf_delete(sb);
+	device_set_descf(dev, "%s:%#jx", proto_isa_prefix, rman_get_start(res));
 	bus_release_resource(dev, type, rid, res);
 	return (proto_probe(dev, proto_isa_prefix, &proto_isa_devnames));
 }
diff --git a/sys/dev/proto/proto_bus_pci.c b/sys/dev/proto/proto_bus_pci.c
index 326f1105f1a5..015a2c53d526 100644
--- a/sys/dev/proto/proto_bus_pci.c
+++ b/sys/dev/proto/proto_bus_pci.c
@@ -33,7 +33,6 @@
 #include <machine/bus.h>
 #include <sys/rman.h>
 #include <machine/resource.h>
-#include <sys/sbuf.h>
 
 #include <dev/pci/pcireg.h>
 #include <dev/pci/pcivar.h>
@@ -63,17 +62,12 @@ static char **proto_pci_devnames;
 static int
 proto_pci_probe(device_t dev)
 {
-	struct sbuf *sb;
-
 	if ((pci_read_config(dev, PCIR_HDRTYPE, 1) & PCIM_HDRTYPE) != 0)
 		return (ENXIO);
 
-	sb = sbuf_new_auto();
-	sbuf_printf(sb, "%s%d:%d:%d:%d", proto_pci_prefix, pci_get_domain(dev),
-	    pci_get_bus(dev), pci_get_slot(dev), pci_get_function(dev));
-	sbuf_finish(sb);
-	device_set_desc_copy(dev, sbuf_data(sb));
-	sbuf_delete(sb);
+	device_set_descf(dev, "%s%d:%d:%d:%d", proto_pci_prefix,
+	    pci_get_domain(dev), pci_get_bus(dev), pci_get_slot(dev),
+	    pci_get_function(dev));
 	return (proto_probe(dev, proto_pci_prefix, &proto_pci_devnames));
 }
 
diff --git a/sys/dev/qlnx/qlnxe/bcm_osal.h b/sys/dev/qlnx/qlnxe/bcm_osal.h
index 5d940d3272d6..c820532c9e0a 100644
--- a/sys/dev/qlnx/qlnxe/bcm_osal.h
+++ b/sys/dev/qlnx/qlnxe/bcm_osal.h
@@ -72,7 +72,7 @@ extern void qlnx_dma_free_coherent(void *ecore_dev, void *v_addr,
                         bus_addr_t phys, uint32_t size);
 
 extern void qlnx_link_update(void *p_hwfn);
-extern void qlnx_barrier(void *p_hwfn);
+extern void qlnx_barrier(void *p_dev);
 
 extern void *qlnx_zalloc(uint32_t size);
 
@@ -213,14 +213,14 @@ typedef struct osal_list_t
 #define OSAL_SPIN_LOCK_ALLOC(p_hwfn, mutex)
 #define OSAL_SPIN_LOCK_DEALLOC(mutex) mtx_destroy(mutex)
 #define OSAL_SPIN_LOCK_INIT(lock) {\
-		mtx_init(lock, __func__, MTX_NETWORK_LOCK, MTX_SPIN); \
+		mtx_init(lock, __func__, "OSAL spin lock", MTX_SPIN); \
 	}
 
 #define OSAL_SPIN_UNLOCK(lock) {\
-		mtx_unlock(lock); \
+		mtx_unlock_spin(lock); \
 	}
 #define OSAL_SPIN_LOCK(lock) {\
-		mtx_lock(lock); \
+		mtx_lock_spin(lock); \
 	}
 
 #define OSAL_MUTEX_ALLOC(p_hwfn, mutex)
diff --git a/sys/dev/qlnx/qlnxe/ecore.h b/sys/dev/qlnx/qlnxe/ecore.h
index 8fcbc1f8d8a0..eda7c260ba99 100644
--- a/sys/dev/qlnx/qlnxe/ecore.h
+++ b/sys/dev/qlnx/qlnxe/ecore.h
@@ -790,6 +790,7 @@ struct ecore_dev {
 	u8				dp_level;
 	char				name[NAME_SIZE];
 	void				*dp_ctx;
+	void				*ha;
 
 	enum ecore_dev_type		type;
 /* Translate type/revision combo into the proper conditions */
diff --git a/sys/dev/qlnx/qlnxe/ecore_mcp.c b/sys/dev/qlnx/qlnxe/ecore_mcp.c
index d94c7382edc5..ab14b1eb5186 100644
--- a/sys/dev/qlnx/qlnxe/ecore_mcp.c
+++ b/sys/dev/qlnx/qlnxe/ecore_mcp.c
@@ -191,17 +191,17 @@ enum _ecore_status_t ecore_mcp_free(struct ecore_hwfn *p_hwfn)
 		OSAL_FREE(p_hwfn->p_dev, p_hwfn->mcp_info->mfw_mb_cur);
 		OSAL_FREE(p_hwfn->p_dev, p_hwfn->mcp_info->mfw_mb_shadow);
 
-		OSAL_SPIN_LOCK(&p_hwfn->mcp_info->cmd_lock);
+		OSAL_MUTEX_ACQUIRE(&p_hwfn->mcp_info->cmd_lock);
 		OSAL_LIST_FOR_EACH_ENTRY_SAFE(p_cmd_elem, p_tmp,
 					      &p_hwfn->mcp_info->cmd_list, list,
 					      struct ecore_mcp_cmd_elem) {
 			ecore_mcp_cmd_del_elem(p_hwfn, p_cmd_elem);
 		}
-		OSAL_SPIN_UNLOCK(&p_hwfn->mcp_info->cmd_lock);
+		OSAL_MUTEX_RELEASE(&p_hwfn->mcp_info->cmd_lock);
 
 #ifdef CONFIG_ECORE_LOCK_ALLOC
-		OSAL_SPIN_LOCK_DEALLOC(&p_hwfn->mcp_info->cmd_lock);
-		OSAL_SPIN_LOCK_DEALLOC(&p_hwfn->mcp_info->link_lock);
+		OSAL_MUTEX_DEALLOC(&p_hwfn->mcp_info->cmd_lock);
+		OSAL_MUTEX_DEALLOC(&p_hwfn->mcp_info->link_lock);
 #endif
 	}
 
@@ -308,18 +308,18 @@ enum _ecore_status_t ecore_mcp_cmd_init(struct ecore_hwfn *p_hwfn,
 
 	/* Initialize the MFW spinlocks */
 #ifdef CONFIG_ECORE_LOCK_ALLOC
-	if (OSAL_SPIN_LOCK_ALLOC(p_hwfn, &p_info->cmd_lock)) {
+	if (OSAL_MUTEX_LOCK_ALLOC(p_hwfn, &p_info->cmd_lock)) {
 		OSAL_FREE(p_hwfn->p_dev, p_hwfn->mcp_info);
 		return ECORE_NOMEM;
 	}
-	if (OSAL_SPIN_LOCK_ALLOC(p_hwfn, &p_info->link_lock)) {
-		OSAL_SPIN_LOCK_DEALLOC(&p_info->cmd_lock);
+	if (OSAL_MUTEX_ALLOC(p_hwfn, &p_info->link_lock)) {
+		OSAL_MUTEX_DEALLOC(&p_info->cmd_lock);
 		OSAL_FREE(p_hwfn->p_dev, p_hwfn->mcp_info);
 		return ECORE_NOMEM;
 	}
 #endif
-	OSAL_SPIN_LOCK_INIT(&p_info->cmd_lock);
-	OSAL_SPIN_LOCK_INIT(&p_info->link_lock);
+	OSAL_MUTEX_INIT(&p_info->cmd_lock);
+	OSAL_MUTEX_INIT(&p_info->link_lock);
 
 	OSAL_LIST_INIT(&p_info->cmd_list);
 
@@ -381,7 +381,7 @@ enum _ecore_status_t ecore_mcp_reset(struct ecore_hwfn *p_hwfn,
 	}
 
 	/* Ensure that only a single thread is accessing the mailbox */
-	OSAL_SPIN_LOCK(&p_hwfn->mcp_info->cmd_lock);
+	OSAL_MUTEX_ACQUIRE(&p_hwfn->mcp_info->cmd_lock);
 
 	org_mcp_reset_seq = ecore_rd(p_hwfn, p_ptt, MISCS_REG_GENERIC_POR_0);
 
@@ -407,7 +407,7 @@ enum _ecore_status_t ecore_mcp_reset(struct ecore_hwfn *p_hwfn,
 		rc = ECORE_AGAIN;
 	}
 
-	OSAL_SPIN_UNLOCK(&p_hwfn->mcp_info->cmd_lock);
+	OSAL_MUTEX_RELEASE(&p_hwfn->mcp_info->cmd_lock);
 
 	return rc;
 }
@@ -551,7 +551,7 @@ _ecore_mcp_cmd_and_union(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
 		 * The spinlock stays locked until the command is sent.
 		 */
 
-		OSAL_SPIN_LOCK(&p_hwfn->mcp_info->cmd_lock);
+		OSAL_MUTEX_ACQUIRE(&p_hwfn->mcp_info->cmd_lock);
 
 		if (!ecore_mcp_has_pending_cmd(p_hwfn))
 			break;
@@ -562,7 +562,7 @@ _ecore_mcp_cmd_and_union(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
 		else if (rc != ECORE_AGAIN)
 			goto err;
 
-		OSAL_SPIN_UNLOCK(&p_hwfn->mcp_info->cmd_lock);
+		OSAL_MUTEX_RELEASE(&p_hwfn->mcp_info->cmd_lock);
 		if (ECORE_MB_FLAGS_IS_SET(p_mb_params, CAN_SLEEP)) {
 			OSAL_MSLEEP(msecs);
 		} else {
@@ -588,7 +588,7 @@ _ecore_mcp_cmd_and_union(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
 	}
 
 	__ecore_mcp_cmd_and_union(p_hwfn, p_ptt, p_mb_params, seq_num);
-	OSAL_SPIN_UNLOCK(&p_hwfn->mcp_info->cmd_lock);
+	OSAL_MUTEX_RELEASE(&p_hwfn->mcp_info->cmd_lock);
 
 	/* Wait for the MFW response */
 	do {
@@ -602,7 +602,7 @@ _ecore_mcp_cmd_and_union(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
 		} else {
 			OSAL_UDELAY(usecs);
 		}
-		OSAL_SPIN_LOCK(&p_hwfn->mcp_info->cmd_lock);
+		OSAL_MUTEX_ACQUIRE(&p_hwfn->mcp_info->cmd_lock);
 
 		if (p_cmd_elem->b_is_completed)
 			break;
@@ -613,7 +613,7 @@ _ecore_mcp_cmd_and_union(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
 		else if (rc != ECORE_AGAIN)
 			goto err;
 
-		OSAL_SPIN_UNLOCK(&p_hwfn->mcp_info->cmd_lock);
+		OSAL_MUTEX_RELEASE(&p_hwfn->mcp_info->cmd_lock);
 		OSAL_MFW_CMD_PREEMPT(p_hwfn);
 	} while (++cnt < max_retries);
 
@@ -623,9 +623,9 @@ _ecore_mcp_cmd_and_union(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
 			  p_mb_params->cmd, p_mb_params->param);
 		ecore_mcp_print_cpu_info(p_hwfn, p_ptt);
 
-		OSAL_SPIN_LOCK(&p_hwfn->mcp_info->cmd_lock);
+		OSAL_MUTEX_ACQUIRE(&p_hwfn->mcp_info->cmd_lock);
 		ecore_mcp_cmd_del_elem(p_hwfn, p_cmd_elem);
-		OSAL_SPIN_UNLOCK(&p_hwfn->mcp_info->cmd_lock);
+		OSAL_MUTEX_RELEASE(&p_hwfn->mcp_info->cmd_lock);
 
 		if (!ECORE_MB_FLAGS_IS_SET(p_mb_params, AVOID_BLOCK))
 			ecore_mcp_cmd_set_blocking(p_hwfn, true);
@@ -634,7 +634,7 @@ _ecore_mcp_cmd_and_union(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
 	}
 
 	ecore_mcp_cmd_del_elem(p_hwfn, p_cmd_elem);
-	OSAL_SPIN_UNLOCK(&p_hwfn->mcp_info->cmd_lock);
+	OSAL_MUTEX_RELEASE(&p_hwfn->mcp_info->cmd_lock);
 
 	DP_VERBOSE(p_hwfn, ECORE_MSG_SP,
 		   "MFW mailbox: response 0x%08x param 0x%08x [after %d.%03d ms]\n",
@@ -647,7 +647,7 @@ _ecore_mcp_cmd_and_union(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
 	return ECORE_SUCCESS;
 
 err:
-	OSAL_SPIN_UNLOCK(&p_hwfn->mcp_info->cmd_lock);
+	OSAL_MUTEX_RELEASE(&p_hwfn->mcp_info->cmd_lock);
 	return rc;
 }
 
@@ -1439,7 +1439,7 @@ static void ecore_mcp_handle_link_change(struct ecore_hwfn *p_hwfn,
 	u32 status = 0;
 
 	/* Prevent SW/attentions from doing this at the same time */
-	OSAL_SPIN_LOCK(&p_hwfn->mcp_info->link_lock);
+	OSAL_MUTEX_ACQUIRE(&p_hwfn->mcp_info->link_lock);
 
 	p_link = &p_hwfn->mcp_info->link_output;
 	OSAL_MEMSET(p_link, 0, sizeof(*p_link));
@@ -1585,7 +1585,7 @@ static void ecore_mcp_handle_link_change(struct ecore_hwfn *p_hwfn,
 
 	OSAL_LINK_UPDATE(p_hwfn, p_ptt);
 out:
-	OSAL_SPIN_UNLOCK(&p_hwfn->mcp_info->link_lock);
+	OSAL_MUTEX_RELEASE(&p_hwfn->mcp_info->link_lock);
 }
 
 enum _ecore_status_t ecore_mcp_set_link(struct ecore_hwfn *p_hwfn,
@@ -1774,7 +1774,7 @@ ecore_mcp_update_bw(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt)
 	struct public_func shmem_info;
 	u32 resp = 0, param = 0;
 
-	OSAL_SPIN_LOCK(&p_hwfn->mcp_info->link_lock);
+	OSAL_MUTEX_ACQUIRE(&p_hwfn->mcp_info->link_lock);
 
 	ecore_mcp_get_shmem_func(p_hwfn, p_ptt, &shmem_info,
 				 MCP_PF_ID(p_hwfn));
@@ -1787,7 +1787,7 @@ ecore_mcp_update_bw(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt)
 
 	ecore_configure_pf_max_bandwidth(p_hwfn->p_dev, p_info->bandwidth_max);
 
-	OSAL_SPIN_UNLOCK(&p_hwfn->mcp_info->link_lock);
+	OSAL_MUTEX_RELEASE(&p_hwfn->mcp_info->link_lock);
 
 	/* Acknowledge the MFW */
 	ecore_mcp_cmd(p_hwfn, p_ptt, DRV_MSG_CODE_BW_UPDATE_ACK, 0, &resp,
diff --git a/sys/dev/qlnx/qlnxe/ecore_mcp.h b/sys/dev/qlnx/qlnxe/ecore_mcp.h
index c94583cdfba3..edb1f9083467 100644
--- a/sys/dev/qlnx/qlnxe/ecore_mcp.h
+++ b/sys/dev/qlnx/qlnxe/ecore_mcp.h
@@ -51,10 +51,10 @@ struct ecore_mcp_info {
 	/* List for mailbox commands which were sent and wait for a response */
 	osal_list_t cmd_list;
 
-	/* Spinlock used for protecting the access to the mailbox commands list
+	/* Lock used for protecting the access to the mailbox commands list
 	 * and the sending of the commands.
 	 */
-	osal_spinlock_t cmd_lock;
+	osal_mutex_t cmd_lock;
 
 	/* Flag to indicate whether sending a MFW mailbox command is blocked */
 	bool b_block_cmd;
@@ -62,7 +62,7 @@ struct ecore_mcp_info {
 	/* Spinlock used for syncing SW link-changes and link-changes
 	 * originating from attention context.
 	 */
-	osal_spinlock_t link_lock;
+	osal_mutex_t link_lock;
 
 	/* Address of the MCP public area */
 	u32 public_base;
diff --git a/sys/dev/qlnx/qlnxe/qlnx_def.h b/sys/dev/qlnx/qlnxe/qlnx_def.h
index 8ac403ab49dc..4342bba89587 100644
--- a/sys/dev/qlnx/qlnxe/qlnx_def.h
+++ b/sys/dev/qlnx/qlnxe/qlnx_def.h
@@ -391,7 +391,7 @@ struct qlnx_host {
 
 	int			msix_count;
 
-	struct mtx		hw_lock;
+	struct sx		hw_lock;
 
 	/* debug */
 
diff --git a/sys/dev/qlnx/qlnxe/qlnx_os.c b/sys/dev/qlnx/qlnxe/qlnx_os.c
index 0ef3c93580b6..6665894d058d 100644
--- a/sys/dev/qlnx/qlnxe/qlnx_os.c
+++ b/sys/dev/qlnx/qlnxe/qlnx_os.c
@@ -90,8 +90,8 @@ static void qlnx_init_ifnet(device_t dev, qlnx_host_t *ha);
 static void qlnx_init(void *arg);
 static void qlnx_init_locked(qlnx_host_t *ha);
 static int qlnx_set_multi(qlnx_host_t *ha, uint32_t add_multi);
-static int qlnx_set_promisc(qlnx_host_t *ha);
-static int qlnx_set_allmulti(qlnx_host_t *ha);
+static int qlnx_set_promisc(qlnx_host_t *ha, int enabled);
+static int qlnx_set_allmulti(qlnx_host_t *ha, int enabled);
 static int qlnx_ioctl(if_t ifp, u_long cmd, caddr_t data);
 static int qlnx_media_change(if_t ifp);
 static void qlnx_media_status(if_t ifp, struct ifmediareq *ifmr);
@@ -227,7 +227,6 @@ MODULE_DEPEND(if_qlnxev, ether, 1, 1, 1);
 
 MALLOC_DEFINE(M_QLNXBUF, "qlnxbuf", "Buffers for qlnx driver");
 
-char qlnx_dev_str[128];
 char qlnx_ver_str[VER_SIZE];
 char qlnx_name_str[NAME_SIZE];
 
@@ -374,60 +373,48 @@ qlnx_pci_probe(device_t dev)
 #ifndef QLNX_VF
 
         case QLOGIC_PCI_DEVICE_ID_1644:
-		snprintf(qlnx_dev_str, sizeof(qlnx_dev_str), "%s v%d.%d.%d",
+		device_set_descf(dev, "%s v%d.%d.%d",
 			"Qlogic 100GbE PCI CNA Adapter-Ethernet Function",
 			QLNX_VERSION_MAJOR, QLNX_VERSION_MINOR,
 			QLNX_VERSION_BUILD);
-                device_set_desc_copy(dev, qlnx_dev_str);
-
                 break;
 
         case QLOGIC_PCI_DEVICE_ID_1634:
-		snprintf(qlnx_dev_str, sizeof(qlnx_dev_str), "%s v%d.%d.%d",
+		device_set_descf(dev, "%s v%d.%d.%d",
 			"Qlogic 40GbE PCI CNA Adapter-Ethernet Function",
 			QLNX_VERSION_MAJOR, QLNX_VERSION_MINOR,
 			QLNX_VERSION_BUILD);
-                device_set_desc_copy(dev, qlnx_dev_str);
-
                 break;
 
         case QLOGIC_PCI_DEVICE_ID_1656:
-		snprintf(qlnx_dev_str, sizeof(qlnx_dev_str), "%s v%d.%d.%d",
+		device_set_descf(dev, "%s v%d.%d.%d",
 			"Qlogic 25GbE PCI CNA Adapter-Ethernet Function",
 			QLNX_VERSION_MAJOR, QLNX_VERSION_MINOR,
 			QLNX_VERSION_BUILD);
-                device_set_desc_copy(dev, qlnx_dev_str);
-
                 break;
 
         case QLOGIC_PCI_DEVICE_ID_1654:
-		snprintf(qlnx_dev_str, sizeof(qlnx_dev_str), "%s v%d.%d.%d",
+		device_set_descf(dev, "%s v%d.%d.%d",
 			"Qlogic 50GbE PCI CNA Adapter-Ethernet Function",
 			QLNX_VERSION_MAJOR, QLNX_VERSION_MINOR,
 			QLNX_VERSION_BUILD);
-                device_set_desc_copy(dev, qlnx_dev_str);
-
                 break;
 
 	case QLOGIC_PCI_DEVICE_ID_8070:
-		snprintf(qlnx_dev_str, sizeof(qlnx_dev_str), "%s v%d.%d.%d",
+		device_set_descf(dev, "%s v%d.%d.%d",
 			"Qlogic 10GbE/25GbE/40GbE PCI CNA (AH)"
 			" Adapter-Ethernet Function",
 			QLNX_VERSION_MAJOR, QLNX_VERSION_MINOR,
 			QLNX_VERSION_BUILD);
-		device_set_desc_copy(dev, qlnx_dev_str);
-
 		break;
 
 #else
 	case QLOGIC_PCI_DEVICE_ID_8090:
-		snprintf(qlnx_dev_str, sizeof(qlnx_dev_str), "%s v%d.%d.%d",
+		device_set_descf(dev, "%s v%d.%d.%d",
 			"Qlogic SRIOV PCI CNA (AH) "
 			"Adapter-Ethernet Function",
 			QLNX_VERSION_MAJOR, QLNX_VERSION_MINOR,
 			QLNX_VERSION_BUILD);
-		device_set_desc_copy(dev, qlnx_dev_str);
-
 		break;
 
 #endif /* #ifndef QLNX_VF */
@@ -763,7 +750,7 @@ qlnx_pci_attach(device_t dev)
 
         ha->pci_dev = dev;
 
-	mtx_init(&ha->hw_lock, "qlnx_hw_lock", MTX_NETWORK_LOCK, MTX_DEF);
+	sx_init(&ha->hw_lock, "qlnx_hw_lock");
 
         ha->flags.lock_init = 1;
 
@@ -1207,6 +1194,7 @@ qlnx_init_hw(qlnx_host_t *ha)
 	int				rval = 0;
 	struct ecore_hw_prepare_params	params;
 
+        ha->cdev.ha = ha;
 	ecore_init_struct(&ha->cdev);
 
 	/* ha->dp_module = ECORE_MSG_PROBE |
@@ -1351,7 +1339,7 @@ qlnx_release(qlnx_host_t *ha)
                 pci_release_msi(dev);
 
         if (ha->flags.lock_init) {
-                mtx_destroy(&ha->hw_lock);
+                sx_destroy(&ha->hw_lock);
         }
 
         if (ha->pci_reg)
@@ -2304,10 +2292,6 @@ qlnx_init_ifnet(device_t dev, qlnx_host_t *ha)
         if_t		ifp;
 
         ifp = ha->ifp = if_alloc(IFT_ETHER);
-
-        if (ifp == NULL)
-                panic("%s: cannot if_alloc()\n", device_get_nameunit(dev));
-
         if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 
 	device_id = pci_get_device(ha->pci_dev);
@@ -2595,7 +2579,7 @@ qlnx_set_multi(qlnx_host_t *ha, uint32_t add_multi)
 }
 
 static int
-qlnx_set_promisc(qlnx_host_t *ha)
+qlnx_set_promisc(qlnx_host_t *ha, int enabled)
 {
 	int	rc = 0;
 	uint8_t	filter;
@@ -2604,15 +2588,20 @@ qlnx_set_promisc(qlnx_host_t *ha)
 		return (0);
 
 	filter = ha->filter;
-	filter |= ECORE_ACCEPT_MCAST_UNMATCHED;
-	filter |= ECORE_ACCEPT_UCAST_UNMATCHED;
+	if (enabled) {
+		filter |= ECORE_ACCEPT_MCAST_UNMATCHED;
+		filter |= ECORE_ACCEPT_UCAST_UNMATCHED;
+	} else {
+		filter &= ~ECORE_ACCEPT_MCAST_UNMATCHED;
+		filter &= ~ECORE_ACCEPT_UCAST_UNMATCHED;
+	}
 
 	rc = qlnx_set_rx_accept_filter(ha, filter);
 	return (rc);
 }
 
 static int
-qlnx_set_allmulti(qlnx_host_t *ha)
+qlnx_set_allmulti(qlnx_host_t *ha, int enabled)
 {
 	int	rc = 0;
 	uint8_t	filter;
@@ -2621,7 +2610,11 @@ qlnx_set_allmulti(qlnx_host_t *ha)
 		return (0);
 
 	filter = ha->filter;
-	filter |= ECORE_ACCEPT_MCAST_UNMATCHED;
+	if (enabled) {
+		filter |= ECORE_ACCEPT_MCAST_UNMATCHED;
+	} else {
+		filter &= ~ECORE_ACCEPT_MCAST_UNMATCHED;
+	}
 	rc = qlnx_set_rx_accept_filter(ha, filter);
 
 	return (rc);
@@ -2689,10 +2682,10 @@ qlnx_ioctl(if_t ifp, u_long cmd, caddr_t data)
 			if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) {
 				if ((if_getflags(ifp) ^ ha->if_flags) &
 					IFF_PROMISC) {
-					ret = qlnx_set_promisc(ha);
+					ret = qlnx_set_promisc(ha, ifp->if_flags & IFF_PROMISC);
 				} else if ((if_getflags(ifp) ^ ha->if_flags) &
 					IFF_ALLMULTI) {
-					ret = qlnx_set_allmulti(ha);
+					ret = qlnx_set_allmulti(ha, ifp->if_flags & IFF_ALLMULTI);
 				}
 			} else {
 				ha->max_frame_size = if_getmtu(ifp) +
@@ -2702,9 +2695,9 @@ qlnx_ioctl(if_t ifp, u_long cmd, caddr_t data)
 		} else {
 			if (if_getdrvflags(ifp) & IFF_DRV_RUNNING)
 				qlnx_stop(ha);
-			ha->if_flags = if_getflags(ifp);
 		}
 
+		ha->if_flags = if_getflags(ifp);
 		QLNX_UNLOCK(ha);
 		break;
 
@@ -5387,11 +5380,11 @@ qlnx_zalloc(uint32_t size)
 }
 
 void
-qlnx_barrier(void *p_hwfn)
+qlnx_barrier(void *p_dev)
 {
 	qlnx_host_t	*ha;
 
-	ha = (qlnx_host_t *)((struct ecore_hwfn *)p_hwfn)->p_dev;
+	ha = ((struct ecore_dev *) p_dev)->ha;
 	bus_barrier(ha->pci_reg,  0, 0, BUS_SPACE_BARRIER_WRITE);
 }
 
@@ -7075,9 +7068,11 @@ qlnx_set_rx_mode(qlnx_host_t *ha)
 			ECORE_ACCEPT_MCAST_MATCHED |
 			ECORE_ACCEPT_BCAST;
 
-	if (qlnx_vf_device(ha) == 0) {
+	if (qlnx_vf_device(ha) == 0 || (ha->ifp->if_flags & IFF_PROMISC)) {
 		filter |= ECORE_ACCEPT_UCAST_UNMATCHED;
 		filter |= ECORE_ACCEPT_MCAST_UNMATCHED;
+	} else if (ha->ifp->if_flags & IFF_ALLMULTI) {
+		filter |= ECORE_ACCEPT_MCAST_UNMATCHED;
 	}
 	ha->filter = filter;
 
diff --git a/sys/dev/qlnx/qlnxe/qlnx_os.h b/sys/dev/qlnx/qlnxe/qlnx_os.h
index 261283fb6eaf..6d717d0e70bf 100644
--- a/sys/dev/qlnx/qlnxe/qlnx_os.h
+++ b/sys/dev/qlnx/qlnxe/qlnx_os.h
@@ -130,8 +130,8 @@ MALLOC_DECLARE(M_QLNXBUF);
 /*
  * Locks
  */
-#define QLNX_LOCK(ha)		mtx_lock(&ha->hw_lock)
-#define QLNX_UNLOCK(ha)		mtx_unlock(&ha->hw_lock)
+#define QLNX_LOCK(ha)		sx_xlock(&ha->hw_lock)
+#define QLNX_UNLOCK(ha)		sx_xunlock(&ha->hw_lock)
 
 /*
  * structure encapsulating a DMA buffer
diff --git a/sys/dev/qlnx/qlnxe/qlnx_rdma.c b/sys/dev/qlnx/qlnxe/qlnx_rdma.c
index 77b25a017ade..a69f0efd095a 100644
--- a/sys/dev/qlnx/qlnxe/qlnx_rdma.c
+++ b/sys/dev/qlnx/qlnxe/qlnx_rdma.c
@@ -253,8 +253,6 @@ qlnx_rdma_deregister_if(qlnx_rdma_if_t *rdma_if)
 	int ret = 0;
 	qlnx_host_t *ha;
 
-	printf("%s: enter rdma_if = %p\n", __func__, rdma_if);
-
         if (mtx_initialized(&qlnx_rdma_dev_lock)) {
                 mtx_lock(&qlnx_rdma_dev_lock);
 
@@ -285,7 +283,6 @@ qlnx_rdma_deregister_if(qlnx_rdma_if_t *rdma_if)
 
                 mtx_unlock(&qlnx_rdma_dev_lock);
         }
-	printf("%s: exit rdma_if = %p\n", __func__, rdma_if);
 
         return (ret);
 }
diff --git a/sys/dev/qlxgb/qla_os.c b/sys/dev/qlxgb/qla_os.c
index b9a0c1ec07a3..87e504a83c79 100644
--- a/sys/dev/qlxgb/qla_os.c
+++ b/sys/dev/qlxgb/qla_os.c
@@ -658,9 +658,6 @@ qla_init_ifnet(device_t dev, qla_host_t *ha)
 
 	ifp = ha->ifp = if_alloc(IFT_ETHER);
 
-	if (ifp == NULL)
-		panic("%s: cannot if_alloc()\n", device_get_nameunit(dev));
-
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 
 	if_setmtu(ifp, ETHERMTU);
diff --git a/sys/dev/qlxgbe/ql_ioctl.c b/sys/dev/qlxgbe/ql_ioctl.c
index b34a9cc508c0..c95cbd9df688 100644
--- a/sys/dev/qlxgbe/ql_ioctl.c
+++ b/sys/dev/qlxgbe/ql_ioctl.c
@@ -652,8 +652,8 @@ ql_slowpath_log(qla_host_t *ha, qla_sp_log_t *log)
 		log->num_entries = ha->hw.sp_log_num_entries;
 	}
 	device_printf(ha->pci_dev,
-		"%s: exit [rval = %d][%p, next_idx = %d, %d entries, %d bytes]\n",
-		__func__, rval, log->buffer, log->next_idx, log->num_entries, size);
+		"%s: exit [rval = %d][next_idx = %d, %d entries, %d bytes]\n",
+		__func__, rval, log->next_idx, log->num_entries, size);
 	mtx_unlock(&ha->sp_log_lock);
 
 	return (rval);
diff --git a/sys/dev/qlxgbe/ql_os.c b/sys/dev/qlxgbe/ql_os.c
index d20e7a103d02..a12f1efec082 100644
--- a/sys/dev/qlxgbe/ql_os.c
+++ b/sys/dev/qlxgbe/ql_os.c
@@ -322,7 +322,7 @@ static int
 qla_pci_attach(device_t dev)
 {
 	qla_host_t *ha = NULL;
-	uint32_t rsrc_len;
+	uint32_t rsrc_len __unused;
 	int i;
 	uint32_t num_rcvq = 0;
 
@@ -405,10 +405,10 @@ qla_pci_attach(device_t dev)
                         __func__);
                 goto qla_pci_attach_err;
         }
-        device_printf(dev, "%s: ha %p pci_func 0x%x rsrc_count 0x%08x"
+        QL_DPRINT2(ha, (dev, "%s: ha %p pci_func 0x%x rsrc_count 0x%08x"
                 " msix_count 0x%x pci_reg %p pci_reg1 %p num_rcvq = %d\n",
 		__func__, ha, ha->pci_func, rsrc_len, ha->msix_count,
-		ha->pci_reg, ha->pci_reg1, num_rcvq);
+		ha->pci_reg, ha->pci_reg1, num_rcvq));
 
         if ((ha->msix_count  < 64) || (num_rcvq != 32)) {
 		if (ha->hw.num_sds_rings > 15) {
@@ -852,10 +852,6 @@ qla_init_ifnet(device_t dev, qla_host_t *ha)
 	QL_DPRINT2(ha, (dev, "%s: enter\n", __func__));
 
 	ifp = ha->ifp = if_alloc(IFT_ETHER);
-
-	if (ifp == NULL)
-		panic("%s: cannot if_alloc()\n", device_get_nameunit(dev));
-
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 
 	if_setbaudrate(ifp, IF_Gbps(10));
@@ -1274,9 +1270,9 @@ qla_send(qla_host_t *ha, struct mbuf **m_headp, uint32_t txr_idx,
 			"mbuf = %p\n", __func__, __LINE__, txr_idx, tx_idx,\
 			ha->tx_ring[txr_idx].tx_buf[tx_idx].m_head));
 
-		device_printf(ha->pci_dev, "%s [%d]: txr_idx = %d tx_idx = %d "
+		QL_DPRINT2(ha, (ha->pci_dev, "%s [%d]: txr_idx = %d tx_idx = %d "
 			"mbuf = %p\n", __func__, __LINE__, txr_idx, tx_idx,
-			ha->tx_ring[txr_idx].tx_buf[tx_idx].m_head);
+			ha->tx_ring[txr_idx].tx_buf[tx_idx].m_head));
 
 		if (m_head)
 			m_freem(m_head);
diff --git a/sys/dev/qlxge/qls_os.c b/sys/dev/qlxge/qls_os.c
index 8c110540a042..eca7006850e0 100644
--- a/sys/dev/qlxge/qls_os.c
+++ b/sys/dev/qlxge/qls_os.c
@@ -160,20 +160,20 @@ qls_sysctl_get_drvr_stats(SYSCTL_HANDLER_ARGS)
                 ha = (qla_host_t *)arg1;
 
                 for (i = 0; i < ha->num_tx_rings; i++) {
-                        device_printf(ha->pci_dev,
+                        QL_DPRINT2((ha->pci_dev,
                                 "%s: tx_ring[%d].tx_frames= %p\n",
 				__func__, i,
-                                (void *)ha->tx_ring[i].tx_frames);
+                                (void *)ha->tx_ring[i].tx_frames));
 
-                        device_printf(ha->pci_dev,
+                        QL_DPRINT2((ha->pci_dev,
                                 "%s: tx_ring[%d].tx_tso_frames= %p\n",
 				__func__, i,
-                                (void *)ha->tx_ring[i].tx_tso_frames);
+                                (void *)ha->tx_ring[i].tx_tso_frames));
 
-                        device_printf(ha->pci_dev,
+                        QL_DPRINT2((ha->pci_dev,
                                 "%s: tx_ring[%d].tx_vlan_frames= %p\n",
 				__func__, i,
-                                (void *)ha->tx_ring[i].tx_vlan_frames);
+                                (void *)ha->tx_ring[i].tx_vlan_frames));
 
                         device_printf(ha->pci_dev,
                                 "%s: tx_ring[%d].txr_free= 0x%08x\n",
@@ -197,15 +197,15 @@ qls_sysctl_get_drvr_stats(SYSCTL_HANDLER_ARGS)
 		}
 
                 for (i = 0; i < ha->num_rx_rings; i++) {
-                        device_printf(ha->pci_dev,
+                        QL_DPRINT2((ha->pci_dev,
                                 "%s: rx_ring[%d].rx_int= %p\n",
 				__func__, i,
-                                (void *)ha->rx_ring[i].rx_int);
+                                (void *)ha->rx_ring[i].rx_int));
 
-                        device_printf(ha->pci_dev,
+                        QL_DPRINT2((ha->pci_dev,
                                 "%s: rx_ring[%d].rss_int= %p\n",
 				__func__, i,
-                                (void *)ha->rx_ring[i].rss_int);
+                                (void *)ha->rx_ring[i].rss_int));
 
                         device_printf(ha->pci_dev,
                                 "%s: rx_ring[%d].lbq_next= 0x%08x\n",
@@ -383,9 +383,9 @@ qls_pci_attach(device_t dev)
 
 	ha->msix_count = qls_get_msix_count(ha);
 
-	device_printf(dev, "\n%s: ha %p pci_func 0x%x  msix_count 0x%x"
+	QL_DPRINT2((dev, "\n%s: ha %p pci_func 0x%x  msix_count 0x%x"
 		" pci_reg %p pci_reg1 %p\n", __func__, ha,
-		ha->pci_func, ha->msix_count, ha->pci_reg, ha->pci_reg1);
+		ha->pci_func, ha->msix_count, ha->pci_reg, ha->pci_reg1));
 
 	if (pci_alloc_msix(dev, &ha->msix_count)) {
 		device_printf(dev, "%s: pci_alloc_msi[%d] failed\n", __func__,
@@ -719,10 +719,6 @@ qls_init_ifnet(device_t dev, qla_host_t *ha)
 	QL_DPRINT2((dev, "%s: enter\n", __func__));
 
 	ifp = ha->ifp = if_alloc(IFT_ETHER);
-
-	if (ifp == NULL)
-		panic("%s: cannot if_alloc()\n", device_get_nameunit(dev));
-
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 	if_setbaudrate(ifp, IF_Gbps(10));
 	if_setinitfn(ifp, qls_init);
diff --git a/sys/dev/re/if_re.c b/sys/dev/re/if_re.c
index 594ed9d60379..69593e68d36f 100644
--- a/sys/dev/re/if_re.c
+++ b/sys/dev/re/if_re.c
@@ -1606,11 +1606,6 @@ re_attach(device_t dev)
 	re_add_sysctls(sc);
 
 	ifp = sc->rl_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "can not if_alloc()\n");
-		error = ENOSPC;
-		goto fail;
-	}
 
 	/* Take controller out of deep sleep mode. */
 	if ((sc->rl_flags & RL_FLAG_MACSLEEP) != 0) {
diff --git a/sys/dev/rl/if_rl.c b/sys/dev/rl/if_rl.c
index b8c21c3265de..cd60561ad2d8 100644
--- a/sys/dev/rl/if_rl.c
+++ b/sys/dev/rl/if_rl.c
@@ -780,11 +780,6 @@ rl_attach(device_t dev)
 		goto fail;
 
 	ifp = sc->rl_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "can not if_alloc()\n");
-		error = ENOSPC;
-		goto fail;
-	}
 
 #define	RL_PHYAD_INTERNAL	0
 
diff --git a/sys/dev/sbni/if_sbni.c b/sys/dev/sbni/if_sbni.c
index 4dbfae7777ef..ffbce54a56f2 100644
--- a/sys/dev/sbni/if_sbni.c
+++ b/sys/dev/sbni/if_sbni.c
@@ -212,7 +212,7 @@ sbni_probe(struct sbni_softc *sc)
 /*
  * Install interface into kernel networking data structures
  */
-int
+void
 sbni_attach(struct sbni_softc *sc, int unit, struct sbni_flags flags)
 {
 	if_t ifp;
@@ -220,8 +220,6 @@ sbni_attach(struct sbni_softc *sc, int unit, struct sbni_flags flags)
 	uint64_t baudrate;
    
 	ifp = sc->ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL)
-		return (ENOMEM);
 	sbni_outb(sc, CSR0, 0);
 	set_initial_values(sc, flags);
 
@@ -250,7 +248,6 @@ sbni_attach(struct sbni_softc *sc, int unit, struct sbni_flags flags)
 		printf("auto\n");
 	else
 		printf("%d (fixed)\n", sc->cur_rxl_index);
-	return (0);
 }
 
 void
diff --git a/sys/dev/sbni/if_sbni_isa.c b/sys/dev/sbni/if_sbni_isa.c
index 53f8c33e1bb7..e1f05db634e1 100644
--- a/sys/dev/sbni/if_sbni_isa.c
+++ b/sys/dev/sbni/if_sbni_isa.c
@@ -137,12 +137,7 @@ sbni_attach_isa(device_t dev)
 
 	*(u_int32_t*)&flags = device_get_flags(dev);
 
-	error = sbni_attach(sc, device_get_unit(dev) * 2, flags);
-	if (error) {
-		device_printf(dev, "cannot initialize driver\n");
-		sbni_release_resources(sc);
-		return (error);
-	}
+	sbni_attach(sc, device_get_unit(dev) * 2, flags);
 
 	if (sc->irq_res) {
 		error = bus_setup_intr(
diff --git a/sys/dev/sbni/if_sbni_pci.c b/sys/dev/sbni/if_sbni_pci.c
index 387995b1a46f..06f741c6cc38 100644
--- a/sys/dev/sbni/if_sbni_pci.c
+++ b/sys/dev/sbni/if_sbni_pci.c
@@ -132,20 +132,9 @@ sbni_pci_attach(device_t dev)
 
 	memset(&flags, 0, sizeof(flags));
 
-	error = sbni_attach(sc, device_get_unit(dev) * 2, flags);
-	if (error) {
-		device_printf(dev, "cannot initialize driver\n");
-		goto attach_failed;
-	}
-	if (sc->slave_sc) {
-		error = sbni_attach(sc->slave_sc, device_get_unit(dev) * 2 + 1,
-		    flags);
-		if (error) {
-			device_printf(dev, "cannot initialize slave\n");
-			sbni_detach(sc);
-			goto attach_failed;
-		}
-	}
+	sbni_attach(sc, device_get_unit(dev) * 2, flags);
+	if (sc->slave_sc)
+		sbni_attach(sc->slave_sc, device_get_unit(dev) * 2 + 1, flags);
 
 	if (sc->irq_res) {
 		error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET |
diff --git a/sys/dev/sbni/if_sbnivar.h b/sys/dev/sbni/if_sbnivar.h
index 92678899a5d9..211d2bc56b0e 100644
--- a/sys/dev/sbni/if_sbnivar.h
+++ b/sys/dev/sbni/if_sbnivar.h
@@ -125,7 +125,7 @@ struct sbni_softc {
 
 void	sbni_intr(void *);
 int	sbni_probe(struct sbni_softc *);
-int	sbni_attach(struct sbni_softc *, int, struct sbni_flags);
+void	sbni_attach(struct sbni_softc *, int, struct sbni_flags);
 void	sbni_detach(struct sbni_softc *);
 void	sbni_release_resources(struct sbni_softc *);
 
diff --git a/sys/dev/sfxge/sfxge.c b/sys/dev/sfxge/sfxge.c
index 23294f90f517..5fb3a3e74c2e 100644
--- a/sys/dev/sfxge/sfxge.c
+++ b/sys/dev/sfxge/sfxge.c
@@ -1081,11 +1081,6 @@ sfxge_attach(device_t dev)
 
 	/* Allocate ifnet. */
 	ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "Couldn't allocate ifnet\n");
-		error = ENOMEM;
-		goto fail;
-	}
 	sc->ifnet = ifp;
 
 	/* Initialize hardware. */
@@ -1122,8 +1117,6 @@ sfxge_attach(device_t dev)
 
 fail2:
 	if_free(sc->ifnet);
-
-fail:
 	DBGPRINT(sc->dev, "failed %d", error);
 	return (error);
 }
diff --git a/sys/dev/sge/if_sge.c b/sys/dev/sge/if_sge.c
index 8146e7cf2e18..c6e8f4790190 100644
--- a/sys/dev/sge/if_sge.c
+++ b/sys/dev/sge/if_sge.c
@@ -603,11 +603,6 @@ sge_attach(device_t dev)
 		goto fail;
 
 	ifp = sc->sge_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "cannot allocate ifnet structure.\n");
-		error = ENOSPC;
-		goto fail;
-	}
 	if_setsoftc(ifp, sc);
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 	if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
diff --git a/sys/dev/siis/siis.c b/sys/dev/siis/siis.c
index a0e5c1d4738d..1e5fd5648c2d 100644
--- a/sys/dev/siis/siis.c
+++ b/sys/dev/siis/siis.c
@@ -121,15 +121,13 @@ static struct {
 static int
 siis_probe(device_t dev)
 {
-	char buf[64];
 	int i;
 	uint32_t devid = pci_get_devid(dev);
 
 	for (i = 0; siis_ids[i].id != 0; i++) {
 		if (siis_ids[i].id == devid) {
-			snprintf(buf, sizeof(buf), "%s SATA controller",
+			device_set_descf(dev, "%s SATA controller",
 			    siis_ids[i].name);
-			device_set_desc_copy(dev, buf);
 			return (BUS_PROBE_DEFAULT);
 		}
 	}
@@ -451,7 +449,7 @@ static int
 siis_ch_probe(device_t dev)
 {
 
-	device_set_desc_copy(dev, "SIIS channel");
+	device_set_desc(dev, "SIIS channel");
 	return (BUS_PROBE_DEFAULT);
 }
 
diff --git a/sys/dev/sis/if_sis.c b/sys/dev/sis/if_sis.c
index bf96383e9a4a..64a43b2bf51e 100644
--- a/sys/dev/sis/if_sis.c
+++ b/sys/dev/sis/if_sis.c
@@ -1057,11 +1057,6 @@ sis_attach(device_t dev)
 		goto fail;
 
 	ifp = sc->sis_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "can not if_alloc()\n");
-		error = ENOSPC;
-		goto fail;
-	}
 	if_setsoftc(ifp, sc);
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 	if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
diff --git a/sys/dev/sk/if_sk.c b/sys/dev/sk/if_sk.c
index 7505ef58cfe4..db5588047385 100644
--- a/sys/dev/sk/if_sk.c
+++ b/sys/dev/sk/if_sk.c
@@ -1279,11 +1279,6 @@ sk_attach(device_t dev)
 	sk_dma_jumbo_alloc(sc_if);
 
 	ifp = sc_if->sk_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(sc_if->sk_if_dev, "can not if_alloc()\n");
-		error = ENOSPC;
-		goto fail;
-	}
 	if_setsoftc(ifp, sc_if);
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 	if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
diff --git a/sys/dev/smc/if_smc.c b/sys/dev/smc/if_smc.c
index cc7a7b1bb12b..12e903d1af9b 100644
--- a/sys/dev/smc/if_smc.c
+++ b/sys/dev/smc/if_smc.c
@@ -313,10 +313,6 @@ smc_attach(device_t dev)
 	sc->smc_dev = dev;
 
 	ifp = sc->smc_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		error = ENOSPC;
-		goto done;
-	}
 
 	mtx_init(&sc->smc_mtx, device_get_nameunit(dev), NULL, MTX_DEF);
 
diff --git a/sys/dev/sound/midi/midi.c b/sys/dev/sound/midi/midi.c
index 8dd4546d58c5..d2b495ea04cd 100644
--- a/sys/dev/sound/midi/midi.c
+++ b/sys/dev/sound/midi/midi.c
@@ -74,10 +74,6 @@ MALLOC_DEFINE(M_MIDI, "midi buffers", "Midi data allocation area");
 #define KOBJMETHOD_END	{ NULL, NULL }
 #endif
 
-#define PCMMKMINOR(u, d, c) ((((c) & 0xff) << 16) | (((u) & 0x0f) << 4) | ((d) & 0x0f))
-#define MIDIMKMINOR(u, d, c) PCMMKMINOR(u, d, c)
-
-#define MIDI_DEV_RAW	2
 #define MIDI_DEV_MIDICTL 12
 
 enum midi_states {
@@ -182,7 +178,8 @@ TAILQ_HEAD(, snd_midi) midi_devs;
  * /dev/midistat variables and declarations, protected by midistat_lock
  */
 
-static struct sx midistat_lock;
+struct sx mstat_lock;
+
 static int      midistat_isopen = 0;
 static struct sbuf midistat_sbuf;
 static struct cdev *midistat_dev;
@@ -262,6 +259,24 @@ SYSCTL_INT(_hw_midi_stat, OID_AUTO, verbose, CTLFLAG_RW,
  * CODE START
  */
 
+void
+midistat_lock(void)
+{
+	sx_xlock(&mstat_lock);
+}
+
+void
+midistat_unlock(void)
+{
+	sx_xunlock(&mstat_lock);
+}
+
+void
+midistat_lockassert(void)
+{
+	sx_assert(&mstat_lock, SA_XLOCKED);
+}
+
 /*
  * Register a new rmidi device. cls midi_if interface unit == 0 means
  * auto-assign new unit number unit != 0 already assigned a unit number, eg.
@@ -281,10 +296,10 @@ midi_init(kobj_class_t cls, int unit, int channel, void *cookie)
 	struct snd_midi *m;
 	int i;
 	int inqsize, outqsize;
-	MIDI_TYPE *buf;
+	uint8_t *buf;
 
 	MIDI_DEBUG(1, printf("midiinit: unit %d/%d.\n", unit, channel));
-	sx_xlock(&midistat_lock);
+	midistat_lock();
 	/*
 	 * Protect against call with existing unit/channel or auto-allocate a
 	 * new unit number.
@@ -330,14 +345,14 @@ midi_init(kobj_class_t cls, int unit, int channel, void *cookie)
 	mtx_lock(&m->qlock);
 
 	if (inqsize)
-		buf = malloc(sizeof(MIDI_TYPE) * inqsize, M_MIDI, M_NOWAIT);
+		buf = malloc(sizeof(uint8_t) * inqsize, M_MIDI, M_NOWAIT);
 	else
 		buf = NULL;
 
 	MIDIQ_INIT(m->inq, buf, inqsize);
 
 	if (outqsize)
-		buf = malloc(sizeof(MIDI_TYPE) * outqsize, M_MIDI, M_NOWAIT);
+		buf = malloc(sizeof(uint8_t) * outqsize, M_MIDI, M_NOWAIT);
 	else
 		buf = NULL;
 	m->hiwat = outqsize / 2;
@@ -362,11 +377,10 @@ midi_init(kobj_class_t cls, int unit, int channel, void *cookie)
 
 	TAILQ_INSERT_TAIL(&midi_devs, m, link);
 
-	sx_xunlock(&midistat_lock);
+	midistat_unlock();
 
-	m->dev = make_dev(&midi_cdevsw,
-	    MIDIMKMINOR(unit, MIDI_DEV_RAW, channel),
-	    UID_ROOT, GID_WHEEL, 0666, "midi%d.%d", unit, channel);
+	m->dev = make_dev(&midi_cdevsw, unit, UID_ROOT, GID_WHEEL, 0666,
+	    "midi%d.%d", unit, channel);
 	m->dev->si_drv1 = m;
 
 	return m;
@@ -383,7 +397,7 @@ midi_init(kobj_class_t cls, int unit, int channel, void *cookie)
 	free(m->synth, M_MIDI);
 	free(m, M_MIDI);
 err0:
-	sx_xunlock(&midistat_lock);
+	midistat_unlock();
 	MIDI_DEBUG(1, printf("midi_init ended in error\n"));
 	return NULL;
 }
@@ -401,7 +415,7 @@ midi_uninit(struct snd_midi *m)
 	int err;
 
 	err = EBUSY;
-	sx_xlock(&midistat_lock);
+	midistat_lock();
 	mtx_lock(&m->lock);
 	if (m->busy) {
 		if (!(m->rchan || m->wchan))
@@ -423,7 +437,7 @@ midi_uninit(struct snd_midi *m)
 err:
 	mtx_unlock(&m->lock);
 exit:
-	sx_xunlock(&midistat_lock);
+	midistat_unlock();
 	return err;
 }
 
@@ -448,12 +462,12 @@ static int midi_lengths[] = {2, 2, 2, 2, 1, 1, 2, 0};
 #define MIDI_SYSEX_END	    0xF7
 
 int
-midi_in(struct snd_midi *m, MIDI_TYPE *buf, int size)
+midi_in(struct snd_midi *m, uint8_t *buf, int size)
 {
 	/* int             i, sig, enq; */
 	int used;
 
-	/* MIDI_TYPE       data; */
+	/* uint8_t       data; */
 	MIDI_DEBUG(5, printf("midi_in: m=%p size=%d\n", m, size));
 
 /*
@@ -578,7 +592,7 @@ midi_in(struct snd_midi *m, MIDI_TYPE *buf, int size)
  * midi_out: The only clearer of the M_TXEN flag.
  */
 int
-midi_out(struct snd_midi *m, MIDI_TYPE *buf, int size)
+midi_out(struct snd_midi *m, uint8_t *buf, int size)
 {
 	int used;
 
@@ -931,9 +945,9 @@ midistat_open(struct cdev *i_dev, int flags, int mode, struct thread *td)
 
 	MIDI_DEBUG(1, printf("midistat_open\n"));
 
-	sx_xlock(&midistat_lock);
+	midistat_lock();
 	if (midistat_isopen) {
-		sx_xunlock(&midistat_lock);
+		midistat_unlock();
 		return EBUSY;
 	}
 	midistat_isopen = 1;
@@ -945,7 +959,7 @@ midistat_open(struct cdev *i_dev, int flags, int mode, struct thread *td)
 out:
 	if (error)
 		midistat_isopen = 0;
-	sx_xunlock(&midistat_lock);
+	midistat_unlock();
 	return error;
 }
 
@@ -953,14 +967,14 @@ static int
 midistat_close(struct cdev *i_dev, int flags, int mode, struct thread *td)
 {
 	MIDI_DEBUG(1, printf("midistat_close\n"));
-	sx_xlock(&midistat_lock);
+	midistat_lock();
 	if (!midistat_isopen) {
-		sx_xunlock(&midistat_lock);
+		midistat_unlock();
 		return EBADF;
 	}
 	sbuf_delete(&midistat_sbuf);
 	midistat_isopen = 0;
-	sx_xunlock(&midistat_lock);
+	midistat_unlock();
 	return 0;
 }
 
@@ -971,13 +985,13 @@ midistat_read(struct cdev *i_dev, struct uio *uio, int flag)
 	int err;
 
 	MIDI_DEBUG(4, printf("midistat_read\n"));
-	sx_xlock(&midistat_lock);
+	midistat_lock();
 	if (!midistat_isopen) {
-		sx_xunlock(&midistat_lock);
+		midistat_unlock();
 		return EBADF;
 	}
 	if (uio->uio_offset < 0 || uio->uio_offset > sbuf_len(&midistat_sbuf)) {
-		sx_xunlock(&midistat_lock);
+		midistat_unlock();
 		return EINVAL;
 	}
 	err = 0;
@@ -986,7 +1000,7 @@ midistat_read(struct cdev *i_dev, struct uio *uio, int flag)
 		err = uiomove(sbuf_data(&midistat_sbuf) + uio->uio_offset, l,
 		    uio);
 	}
-	sx_xunlock(&midistat_lock);
+	midistat_unlock();
 	return err;
 }
 
@@ -999,7 +1013,7 @@ midistat_prepare(struct sbuf *s)
 {
 	struct snd_midi *m;
 
-	sx_assert(&midistat_lock, SA_XLOCKED);
+	midistat_lockassert();
 
 	sbuf_printf(s, "FreeBSD Midi Driver (midi2)\n");
 	if (TAILQ_EMPTY(&midi_devs)) {
@@ -1358,7 +1372,7 @@ midisynth_bender(void *n, uint8_t chn, uint16_t val)
 static int
 midi_destroy(struct snd_midi *m, int midiuninit)
 {
-	sx_assert(&midistat_lock, SA_XLOCKED);
+	midistat_lockassert();
 	mtx_assert(&m->lock, MA_OWNED);
 
 	MIDI_DEBUG(3, printf("midi_destroy\n"));
@@ -1384,12 +1398,11 @@ midi_destroy(struct snd_midi *m, int midiuninit)
 static int
 midi_load(void)
 {
-	sx_init(&midistat_lock, "midistat lock");
+	sx_init(&mstat_lock, "midistat lock");
 	TAILQ_INIT(&midi_devs);
 
-	midistat_dev = make_dev(&midistat_cdevsw,
-	    MIDIMKMINOR(0, MIDI_DEV_MIDICTL, 0),
-	    UID_ROOT, GID_WHEEL, 0666, "midistat");
+	midistat_dev = make_dev(&midistat_cdevsw, MIDI_DEV_MIDICTL, UID_ROOT,
+	    GID_WHEEL, 0666, "midistat");
 
 	return 0;
 }
@@ -1402,7 +1415,7 @@ midi_unload(void)
 
 	MIDI_DEBUG(1, printf("midi_unload()\n"));
 	retval = EBUSY;
-	sx_xlock(&midistat_lock);
+	midistat_lock();
 	if (midistat_isopen)
 		goto exit0;
 
@@ -1415,19 +1428,19 @@ midi_unload(void)
 		if (retval)
 			goto exit1;
 	}
-	sx_xunlock(&midistat_lock);
+	midistat_unlock();
 	destroy_dev(midistat_dev);
 
 	/*
 	 * Made it here then unload is complete
 	 */
-	sx_destroy(&midistat_lock);
+	sx_destroy(&mstat_lock);
 	return 0;
 
 exit1:
 	mtx_unlock(&m->lock);
 exit0:
-	sx_xunlock(&midistat_lock);
+	midistat_unlock();
 	if (retval)
 		MIDI_DEBUG(2, printf("midi_unload: failed\n"));
 	return retval;
@@ -1471,16 +1484,28 @@ midimapper_addseq(void *arg1, int *unit, void **cookie)
 }
 
 int
-midimapper_open(void *arg1, void **cookie)
+midimapper_open_locked(void *arg1, void **cookie)
 {
 	int retval = 0;
 	struct snd_midi *m;
 
-	sx_xlock(&midistat_lock);
+	midistat_lockassert();
 	TAILQ_FOREACH(m, &midi_devs, link) {
 		retval++;
 	}
-	sx_xunlock(&midistat_lock);
+
+	return retval;
+}
+
+int
+midimapper_open(void *arg1, void **cookie)
+{
+	int retval;
+
+	midistat_lock();
+	retval = midimapper_open_locked(arg1, cookie);
+	midistat_unlock();
+
 	return retval;
 }
 
@@ -1491,22 +1516,32 @@ midimapper_close(void *arg1, void *cookie)
 }
 
 kobj_t
-midimapper_fetch_synth(void *arg, void *cookie, int unit)
+midimapper_fetch_synth_locked(void *arg, void *cookie, int unit)
 {
 	struct snd_midi *m;
 	int retval = 0;
 
-	sx_xlock(&midistat_lock);
+	midistat_lockassert();
 	TAILQ_FOREACH(m, &midi_devs, link) {
-		if (unit == retval) {
-			sx_xunlock(&midistat_lock);
+		if (unit == retval)
 			return (kobj_t)m->synth;
-		}
 		retval++;
 	}
-	sx_xunlock(&midistat_lock);
+
 	return NULL;
 }
 
+kobj_t
+midimapper_fetch_synth(void *arg, void *cookie, int unit)
+{
+	kobj_t synth;
+
+	midistat_lock();
+	synth = midimapper_fetch_synth_locked(arg, cookie, unit);
+	midistat_unlock();
+
+	return synth;
+}
+
 DEV_MODULE(midi, midi_modevent, NULL);
 MODULE_VERSION(midi, 1);
diff --git a/sys/dev/sound/midi/midi.h b/sys/dev/sound/midi/midi.h
index 567279d1e654..2254fab690e9 100644
--- a/sys/dev/sound/midi/midi.h
+++ b/sys/dev/sound/midi/midi.h
@@ -39,19 +39,23 @@ MALLOC_DECLARE(M_MIDI);
 #define M_RXEN		0x04
 #define M_TXEN		0x08
 
-#define MIDI_TYPE unsigned char
-
 struct snd_midi;
 
+void	midistat_lock(void);
+void	midistat_unlock(void);
+void	midistat_lockassert(void);
+
 struct snd_midi *
 midi_init(kobj_class_t _mpu_cls, int _unit, int _channel, void *cookie);
 int	midi_uninit(struct snd_midi *_m);
-int	midi_out(struct snd_midi *_m, MIDI_TYPE *_buf, int _size);
-int	midi_in(struct snd_midi *_m, MIDI_TYPE *_buf, int _size);
+int	midi_out(struct snd_midi *_m, uint8_t *_buf, int _size);
+int	midi_in(struct snd_midi *_m, uint8_t *_buf, int _size);
 
 kobj_t	midimapper_addseq(void *arg1, int *unit, void **cookie);
+int	midimapper_open_locked(void *arg1, void **cookie);
 int	midimapper_open(void *arg1, void **cookie);
 int	midimapper_close(void *arg1, void *cookie);
+kobj_t	midimapper_fetch_synth_locked(void *arg, void *cookie, int unit);
 kobj_t	midimapper_fetch_synth(void *arg, void *cookie, int unit);
 
 #endif
diff --git a/sys/dev/sound/midi/mpu401.c b/sys/dev/sound/midi/mpu401.c
index 1152c117f7f6..8a97016b27c7 100644
--- a/sys/dev/sound/midi/mpu401.c
+++ b/sys/dev/sound/midi/mpu401.c
@@ -119,7 +119,7 @@ static int
 mpu401_intr(struct mpu401 *m)
 {
 #define MPU_INTR_BUF	16
-	MIDI_TYPE b[MPU_INTR_BUF];
+	uint8_t b[MPU_INTR_BUF];
 	int i;
 	int s;
 
diff --git a/sys/dev/sound/midi/sequencer.c b/sys/dev/sound/midi/sequencer.c
index a943e02030aa..e4ea1e208356 100644
--- a/sys/dev/sound/midi/sequencer.c
+++ b/sys/dev/sound/midi/sequencer.c
@@ -65,6 +65,7 @@
 #include <sys/kthread.h>
 #include <sys/unistd.h>
 #include <sys/selinfo.h>
+#include <sys/sx.h>
 
 #ifdef HAVE_KERNEL_OPTION_HEADERS
 #include "opt_snd.h"
@@ -91,10 +92,6 @@
 #define LOOKUP_OPEN	(1)
 #define LOOKUP_CLOSE	(2)
 
-#define PCMMKMINOR(u, d, c) \
-	    ((((c) & 0xff) << 16) | (((u) & 0x0f) << 4) | ((d) & 0x0f))
-#define MIDIMKMINOR(u, d, c) PCMMKMINOR(u, d, c)
-#define MIDIUNIT(y) ((dev2unit(y) >> 4) & 0x0f)
 #define MIDIDEV(y) (dev2unit(y) & 0x0f)
 
 /* These are the entries to the sequencer driver. */
@@ -567,12 +564,10 @@ seq_addunit(void)
 	if (scp->mapper == NULL)
 		goto err;
 
-	scp->seqdev = make_dev(&seq_cdevsw,
-	    MIDIMKMINOR(scp->unit, SND_DEV_SEQ, 0), UID_ROOT,
-	    GID_WHEEL, 0666, "sequencer%d", scp->unit);
+	scp->seqdev = make_dev(&seq_cdevsw, SND_DEV_SEQ, UID_ROOT, GID_WHEEL,
+	    0666, "sequencer%d", scp->unit);
 
-	scp->musicdev = make_dev(&seq_cdevsw,
-	    MIDIMKMINOR(scp->unit, SND_DEV_MUSIC, 0), UID_ROOT,
+	scp->musicdev = make_dev(&seq_cdevsw, SND_DEV_MUSIC, UID_ROOT,
 	    GID_WHEEL, 0666, "music%d", scp->unit);
 
 	if (scp->seqdev == NULL || scp->musicdev == NULL)
@@ -752,9 +747,11 @@ mseq_open(struct cdev *i_dev, int flags, int mode, struct thread *td)
 	 * Mark this device busy.
 	 */
 
+	midistat_lock();
 	mtx_lock(&scp->seq_lock);
 	if (scp->busy) {
 		mtx_unlock(&scp->seq_lock);
+		midistat_unlock();
 		SEQ_DEBUG(2, printf("seq_open: unit %d is busy.\n", scp->unit));
 		return EBUSY;
 	}
@@ -769,14 +766,15 @@ mseq_open(struct cdev *i_dev, int flags, int mode, struct thread *td)
 	 * Enumerate the available midi devices
 	 */
 	scp->midi_number = 0;
-	scp->maxunits = midimapper_open(scp->mapper, &scp->mapper_cookie);
+	scp->maxunits = midimapper_open_locked(scp->mapper, &scp->mapper_cookie);
 
 	if (scp->maxunits == 0)
 		SEQ_DEBUG(2, printf("seq_open: no midi devices\n"));
 
 	for (i = 0; i < scp->maxunits; i++) {
 		scp->midis[scp->midi_number] =
-		    midimapper_fetch_synth(scp->mapper, scp->mapper_cookie, i);
+		    midimapper_fetch_synth_locked(scp->mapper,
+		    scp->mapper_cookie, i);
 		if (scp->midis[scp->midi_number]) {
 			if (SYNTH_OPEN(scp->midis[scp->midi_number], scp,
 				scp->fflags) != 0)
@@ -788,6 +786,7 @@ mseq_open(struct cdev *i_dev, int flags, int mode, struct thread *td)
 			}
 		}
 	}
+	midistat_unlock();
 
 	timer_setvals(scp, 60, 100);
 
diff --git a/sys/dev/sound/pci/hda/hdac.h b/sys/dev/sound/pci/hda/hdac.h
index 6b6bc58a4818..191c835595ef 100644
--- a/sys/dev/sound/pci/hda/hdac.h
+++ b/sys/dev/sound/pci/hda/hdac.h
@@ -379,6 +379,7 @@
 #define	LENOVO_X230_SUBVENDOR	HDA_MODEL_CONSTRUCT(LENOVO, 0x21fa)
 #define	LENOVO_X230T_SUBVENDOR	HDA_MODEL_CONSTRUCT(LENOVO, 0x2203)
 #define	LENOVO_T431S_SUBVENDOR	HDA_MODEL_CONSTRUCT(LENOVO, 0x2208)
+#define	LENOVO_X1CRBNG11_SUBVENDOR	HDA_MODEL_CONSTRUCT(LENOVO, 0x2315)
 #define	LENOVO_G580_SUBVENDOR	HDA_MODEL_CONSTRUCT(LENOVO, 0x3977)
 #define	LENOVO_L5AMD_SUBVENDOR	HDA_MODEL_CONSTRUCT(LENOVO, 0x381b)
 #define	LENOVO_L5INTEL_SUBVENDOR	HDA_MODEL_CONSTRUCT(LENOVO, 0x380f)
@@ -573,6 +574,7 @@
 #define HDA_CODEC_ALC284	HDA_CODEC_CONSTRUCT(REALTEK, 0x0284)
 #define HDA_CODEC_ALC285	HDA_CODEC_CONSTRUCT(REALTEK, 0x0285)
 #define HDA_CODEC_ALC286	HDA_CODEC_CONSTRUCT(REALTEK, 0x0286)
+#define HDA_CODEC_ALC287	HDA_CODEC_CONSTRUCT(REALTEK, 0x0287)
 #define HDA_CODEC_ALC288	HDA_CODEC_CONSTRUCT(REALTEK, 0x0288)
 #define HDA_CODEC_ALC289	HDA_CODEC_CONSTRUCT(REALTEK, 0x0289)
 #define HDA_CODEC_ALC290	HDA_CODEC_CONSTRUCT(REALTEK, 0x0290)
diff --git a/sys/dev/sound/pci/hda/pin_patch_realtek.h b/sys/dev/sound/pci/hda/pin_patch_realtek.h
index 49afdedea8a1..abb03c92571b 100644
--- a/sys/dev/sound/pci/hda/pin_patch_realtek.h
+++ b/sys/dev/sound/pci/hda/pin_patch_realtek.h
@@ -582,6 +582,21 @@ static struct hdaa_model_pin_patch_t realtek_model_pin_patches[] = {
 				}
 			}, { }
 		}
+	}, { /**** CODEC: HDA_CODEC_ALC287 ****/
+		.id = HDA_CODEC_ALC287,
+		.patches = (struct model_pin_patch_t[]){
+			{
+				.models = (struct pin_machine_model_t[]){
+					PIN_SUBVENDOR(LENOVO_X1CRBNG11_SUBVENDOR),
+					{ }
+				},
+				.pin_patches = (struct pin_patch_t[]){
+					PIN_PATCH_NOT_APPLICABLE(20),
+					PIN_PATCH_STRING(33, "as=1 seq=15 device=Headphones loc=Right"),
+					{ }
+				}
+			}, { }
+		}
 	}, { /**** CODEC: HDA_CODEC_ALC288 ****/
 		.id = HDA_CODEC_ALC288,
 		.patches = (struct model_pin_patch_t[]){
diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c
index c737df33b97d..2b765bc8b115 100644
--- a/sys/dev/sound/pcm/dsp.c
+++ b/sys/dev/sound/pcm/dsp.c
@@ -52,7 +52,6 @@ struct dsp_cdevpriv {
 	struct pcm_channel *rdch;
 	struct pcm_channel *wrch;
 	struct pcm_channel *volch;
-	int simplex;
 };
 
 static int dsp_mmap_allow_prot_exec = 0;
@@ -142,52 +141,8 @@ dsp_destroy_dev(device_t dev)
 }
 
 static void
-getchns(struct dsp_cdevpriv *priv, uint32_t prio)
+dsp_lock_chans(struct dsp_cdevpriv *priv, uint32_t prio)
 {
-	struct snddev_info *d;
-	struct pcm_channel *ch;
-	uint32_t flags;
-
-	if (priv->simplex) {
-		d = priv->sc;
-		if (!PCM_REGISTERED(d))
-			return;
-		PCM_LOCK(d);
-		PCM_WAIT(d);
-		PCM_ACQUIRE(d);
-		/*
-		 * Note: order is important -
-		 *       pcm flags -> prio query flags -> wild guess
-		 */
-		ch = NULL;
-		flags = pcm_getflags(d->dev);
-		if (flags & SD_F_PRIO_WR) {
-			ch = priv->rdch;
-		} else if (flags & SD_F_PRIO_RD) {
-			ch = priv->wrch;
-		} else if (prio & SD_F_PRIO_WR) {
-			ch = priv->rdch;
-			flags |= SD_F_PRIO_WR;
-		} else if (prio & SD_F_PRIO_RD) {
-			ch = priv->wrch;
-			flags |= SD_F_PRIO_RD;
-		} else if (priv->wrch != NULL) {
-			ch = priv->rdch;
-			flags |= SD_F_PRIO_WR;
-		} else if (priv->rdch != NULL) {
-			ch = priv->wrch;
-			flags |= SD_F_PRIO_RD;
-		}
-		pcm_setflags(d->dev, flags);
-		if (ch != NULL) {
-			CHN_LOCK(ch);
-			chn_ref(ch, -1);
-			chn_release(ch);
-		}
-		PCM_RELEASE(d);
-		PCM_UNLOCK(d);
-	}
-
 	if (priv->rdch != NULL && (prio & SD_F_PRIO_RD))
 		CHN_LOCK(priv->rdch);
 	if (priv->wrch != NULL && (prio & SD_F_PRIO_WR))
@@ -195,7 +150,7 @@ getchns(struct dsp_cdevpriv *priv, uint32_t prio)
 }
 
 static void
-relchns(struct dsp_cdevpriv *priv, uint32_t prio)
+dsp_unlock_chans(struct dsp_cdevpriv *priv, uint32_t prio)
 {
 	if (priv->rdch != NULL && (prio & SD_F_PRIO_RD))
 		CHN_UNLOCK(priv->rdch);
@@ -332,28 +287,14 @@ dsp_close(void *data)
 	priv = NULL;
 }
 
-#define DSP_FIXUP_ERROR()		do {				\
-	prio = pcm_getflags(d->dev);					\
-	if (!DSP_F_VALID(flags))					\
-		error = EINVAL;						\
-	if (!DSP_F_DUPLEX(flags) &&					\
-	    ((DSP_F_READ(flags) && d->reccount == 0) ||			\
-	    (DSP_F_WRITE(flags) && d->playcount == 0)))			\
-		error = ENOTSUP;					\
-	else if (!DSP_F_DUPLEX(flags) && (prio & SD_F_SIMPLEX) &&	\
-	    ((DSP_F_READ(flags) && (prio & SD_F_PRIO_WR)) ||		\
-	    (DSP_F_WRITE(flags) && (prio & SD_F_PRIO_RD))))		\
-		error = EBUSY;						\
-} while (0)
-
 static int
 dsp_open(struct cdev *i_dev, int flags, int mode, struct thread *td)
 {
 	struct dsp_cdevpriv *priv;
-	struct pcm_channel *rdch, *wrch;
+	struct pcm_channel *rdch, *wrch, *ch;
 	struct snddev_info *d;
-	uint32_t fmt, spd, prio;
-	int error, rderror, wrerror;
+	uint32_t fmt, spd;
+	int error, rderror, wrerror, dir;
 
 	/* Kind of impossible.. */
 	if (i_dev == NULL || td == NULL)
@@ -368,7 +309,6 @@ dsp_open(struct cdev *i_dev, int flags, int mode, struct thread *td)
 	priv->rdch = NULL;
 	priv->wrch = NULL;
 	priv->volch = NULL;
-	priv->simplex = (pcm_getflags(d->dev) & SD_F_SIMPLEX) ? 1 : 0;
 
 	error = devfs_set_cdevpriv(priv, dsp_close);
 	if (error != 0)
@@ -381,7 +321,42 @@ dsp_open(struct cdev *i_dev, int flags, int mode, struct thread *td)
 	PCM_WAIT(d);
 
 	error = 0;
-	DSP_FIXUP_ERROR();
+	if (!DSP_F_VALID(flags))
+		error = EINVAL;
+	else if (!DSP_F_DUPLEX(flags) &&
+	    ((DSP_F_READ(flags) && d->reccount == 0) ||
+	    (DSP_F_WRITE(flags) && d->playcount == 0)))
+		error = ENOTSUP;
+	if (pcm_getflags(d->dev) & SD_F_SIMPLEX) {
+		if (DSP_F_DUPLEX(flags)) {
+			/*
+			 * If no channels are opened yet, and we request
+			 * DUPLEX, limit to playback only, otherwise open one
+			 * channel in a direction that already exists.
+			 */
+			if (CHN_EMPTY(d, channels.pcm.opened)) {
+				if (d->playcount > 0)
+					flags &= ~FREAD;
+				else if (d->reccount > 0)
+					flags &= ~FWRITE;
+			} else {
+				ch = CHN_FIRST(d, channels.pcm.opened);
+				if (ch->direction == PCMDIR_PLAY)
+					flags &= ~FREAD;
+				else if (ch->direction == PCMDIR_REC)
+					flags &= ~FWRITE;
+			}
+		} else if (!CHN_EMPTY(d, channels.pcm.opened)) {
+			/*
+			 * If we requested SIMPLEX, make sure we do not open a
+			 * channel in the opposite direction.
+			 */
+			ch = CHN_FIRST(d, channels.pcm.opened);
+			dir = DSP_F_READ(flags) ? PCMDIR_REC : PCMDIR_PLAY;
+			if (ch->direction != dir)
+				error = ENOTSUP;
+		}
+	}
 	if (error != 0) {
 		PCM_UNLOCK(d);
 		PCM_GIANT_EXIT(d);
@@ -533,18 +508,18 @@ dsp_io_ops(struct dsp_cdevpriv *priv, struct uio *buf)
 
 	runpid = buf->uio_td->td_proc->p_pid;
 
-	getchns(priv, prio);
+	dsp_lock_chans(priv, prio);
 
 	if (*ch == NULL || !((*ch)->flags & CHN_F_BUSY)) {
 		if (priv->rdch != NULL || priv->wrch != NULL)
-			relchns(priv, prio);
+			dsp_unlock_chans(priv, prio);
 		PCM_GIANT_EXIT(d);
 		return (EBADF);
 	}
 
 	if (((*ch)->flags & (CHN_F_MMAP | CHN_F_DEAD)) ||
 	    (((*ch)->flags & CHN_F_RUNNING) && (*ch)->pid != runpid)) {
-		relchns(priv, prio);
+		dsp_unlock_chans(priv, prio);
 		PCM_GIANT_EXIT(d);
 		return (EINVAL);
 	} else if (!((*ch)->flags & CHN_F_RUNNING)) {
@@ -563,7 +538,7 @@ dsp_io_ops(struct dsp_cdevpriv *priv, struct uio *buf)
 
 	CHN_BROADCAST(&(*ch)->cv);
 
-	relchns(priv, prio);
+	dsp_unlock_chans(priv, prio);
 
 	PCM_GIANT_LEAVE(d);
 
@@ -799,7 +774,6 @@ dsp_ioctl(struct cdev *i_dev, u_long cmd, caddr_t arg, int mode,
 		return (ret);
 	}
 
-	getchns(priv, 0);
 	rdch = priv->rdch;
 	wrch = priv->wrch;
 
@@ -1858,7 +1832,7 @@ dsp_poll(struct cdev *i_dev, int events, struct thread *td)
 
 	ret = 0;
 
-	getchns(priv, SD_F_PRIO_RD | SD_F_PRIO_WR);
+	dsp_lock_chans(priv, SD_F_PRIO_RD | SD_F_PRIO_WR);
 	wrch = priv->wrch;
 	rdch = priv->rdch;
 
@@ -1874,7 +1848,7 @@ dsp_poll(struct cdev *i_dev, int events, struct thread *td)
 			ret |= chn_poll(rdch, e, td);
 	}
 
-	relchns(priv, SD_F_PRIO_RD | SD_F_PRIO_WR);
+	dsp_unlock_chans(priv, SD_F_PRIO_RD | SD_F_PRIO_WR);
 
 	PCM_GIANT_LEAVE(d);
 
@@ -1936,7 +1910,7 @@ dsp_mmap_single(struct cdev *i_dev, vm_ooffset_t *offset,
 
 	PCM_GIANT_ENTER(d);
 
-	getchns(priv, SD_F_PRIO_RD | SD_F_PRIO_WR);
+	dsp_lock_chans(priv, SD_F_PRIO_RD | SD_F_PRIO_WR);
 	wrch = priv->wrch;
 	rdch = priv->rdch;
 
@@ -1945,7 +1919,7 @@ dsp_mmap_single(struct cdev *i_dev, vm_ooffset_t *offset,
 	    (*offset  + size) > sndbuf_getallocsize(c->bufsoft) ||
 	    (wrch != NULL && (wrch->flags & CHN_F_MMAP_INVALID)) ||
 	    (rdch != NULL && (rdch->flags & CHN_F_MMAP_INVALID))) {
-		relchns(priv, SD_F_PRIO_RD | SD_F_PRIO_WR);
+		dsp_unlock_chans(priv, SD_F_PRIO_RD | SD_F_PRIO_WR);
 		PCM_GIANT_EXIT(d);
 		return (EINVAL);
 	}
@@ -1956,7 +1930,7 @@ dsp_mmap_single(struct cdev *i_dev, vm_ooffset_t *offset,
 		rdch->flags |= CHN_F_MMAP;
 
 	*offset = (uintptr_t)sndbuf_getbufofs(c->bufsoft, *offset);
-	relchns(priv, SD_F_PRIO_RD | SD_F_PRIO_WR);
+	dsp_unlock_chans(priv, SD_F_PRIO_RD | SD_F_PRIO_WR);
 	*object = vm_pager_allocate(OBJT_DEVICE, i_dev,
 	    size, nprot, *offset, curthread->td_ucred);
 
@@ -2047,6 +2021,7 @@ dsp_oss_audioinfo_unavail(oss_audioinfo *ai, int unit)
 	ai->dev = unit;
 	snprintf(ai->name, sizeof(ai->name), "pcm%d (unavailable)", unit);
 	ai->pid = -1;
+	strlcpy(ai->cmd, CHN_COMM_UNUSED, sizeof(ai->cmd));
 	ai->card_number = unit;
 	ai->port_number = unit;
 	ai->mixer_dev = -1;
@@ -2132,8 +2107,9 @@ dsp_oss_audioinfo(struct cdev *i_dev, oss_audioinfo *ai, bool ex)
 	ai->dev = unit;
 	strlcpy(ai->name, device_get_desc(d->dev), sizeof(ai->name));
 	ai->pid = -1;
-	ai->card_number = -1;
-	ai->port_number = -1;
+	strlcpy(ai->cmd, CHN_COMM_UNKNOWN, sizeof(ai->cmd));
+	ai->card_number = unit;
+	ai->port_number = unit;
 	ai->mixer_dev = (d->mixer_dev != NULL) ? unit : -1;
 	ai->legacy_device = unit;
 	snprintf(ai->devnode, sizeof(ai->devnode), "/dev/dsp%d", unit);
@@ -2157,9 +2133,13 @@ dsp_oss_audioinfo(struct cdev *i_dev, oss_audioinfo *ai, bool ex)
 		/*
 		 * Skip physical channels if we are servicing SNDCTL_AUDIOINFO,
 		 * or VCHANs if we are servicing SNDCTL_AUDIOINFO_EX.
+		 *
+		 * For SNDCTL_AUDIOINFO do not skip the physical channels if
+		 * there are no VCHANs.
 		 */
 		if ((ex && (ch->flags & CHN_F_VIRTUAL) != 0) ||
-		    (!ex && (ch->flags & CHN_F_VIRTUAL) == 0)) {
+		    ((!ex && (ch->flags & CHN_F_VIRTUAL) == 0) &&
+		    (d->pvchancount > 0 || d->rvchancount > 0))) {
 			CHN_UNLOCK(ch);
 			continue;
 		}
@@ -2190,13 +2170,22 @@ dsp_oss_audioinfo(struct cdev *i_dev, oss_audioinfo *ai, bool ex)
 		else
 			ai->iformats |= fmts;
 
-		ai->min_rate = min(ai->min_rate, caps->minspeed);
-		ai->max_rate = max(ai->max_rate, caps->maxspeed);
+		if (ex || (pcm_getflags(d->dev) & SD_F_BITPERFECT)) {
+			ai->min_rate = min(ai->min_rate, caps->minspeed);
+			ai->max_rate = max(ai->max_rate, caps->maxspeed);
+		} else {
+			ai->min_rate = min(ai->min_rate, feeder_rate_min);
+			ai->max_rate = max(ai->max_rate, feeder_rate_max);
+		}
 		ai->min_channels = min(ai->min_channels, minch);
 		ai->max_channels = max(ai->max_channels, maxch);
 
 		CHN_UNLOCK(ch);
 	}
+	if (ai->min_rate == INT_MAX)
+		ai->min_rate = 0;
+	if (ai->min_channels == INT_MAX)
+		ai->min_channels = 0;
 
 	PCM_UNLOCK(d);
 
@@ -2317,14 +2306,8 @@ dsp_oss_engineinfo(struct cdev *i_dev, oss_audioinfo *ai)
 			else
 				ai->busy = (ch->direction == PCMDIR_PLAY) ? OPEN_WRITE : OPEN_READ;
 
-			/**
-			 * @note
-			 * @c cmd - OSSv4 docs: "Only supported under Linux at
-			 *    this moment." Cop-out, I know, but I'll save
-			 *    running around in the process table for later.
-			 *    Is there a risk of leaking information?
-			 */
 			ai->pid = ch->pid;
+			strlcpy(ai->cmd, ch->comm, sizeof(ai->cmd));
 
 			/*
 			 * These flags stolen from SNDCTL_DSP_GETCAPS handler.
@@ -2341,13 +2324,7 @@ dsp_oss_engineinfo(struct cdev *i_dev, oss_audioinfo *ai)
 
 			/*
 			 * Collect formats supported @b natively by the
-			 * device.  Also determine min/max channels.  (I.e.,
-			 * mono, stereo, or both?)
-			 *
-			 * If any channel is stereo, maxch = 2;
-			 * if all channels are stereo, minch = 2, too;
-			 * if any channel is mono, minch = 1;
-			 * and if all channels are mono, maxch = 1.
+			 * device.  Also determine min/max channels.
 			 */
 			minch = INT_MAX;
 			maxch = 0;
@@ -2375,20 +2352,20 @@ dsp_oss_engineinfo(struct cdev *i_dev, oss_audioinfo *ai)
 			 *    should normally not use this field for any
 			 *    purpose."
 			 */
-			ai->card_number = -1;
+			ai->card_number = unit;
 			/**
 			 * @todo @c song_name - depends first on
 			 *          SNDCTL_[GS]ETSONG @todo @c label - depends
 			 *          on SNDCTL_[GS]ETLABEL
 			 * @todo @c port_number - routing information?
 			 */
-			ai->port_number = -1;
+			ai->port_number = unit;
 			ai->mixer_dev = (d->mixer_dev != NULL) ? unit : -1;
 			/**
 			 * @note
 			 * @c legacy_device - OSSv4 docs:  "Obsolete."
 			 */
-			ai->legacy_device = -1;
+			ai->legacy_device = unit;
 			snprintf(ai->devnode, sizeof(ai->devnode), "/dev/dsp%d", unit);
 			ai->enabled = device_is_attached(d->dev) ? 1 : 0;
 			/**
@@ -2401,8 +2378,15 @@ dsp_oss_engineinfo(struct cdev *i_dev, oss_audioinfo *ai)
 			 * @todo @c handle - haven't decided how to generate
 			 *       this yet; bus, vendor, device IDs?
 			 */
-			ai->min_rate = caps->minspeed;
-			ai->max_rate = caps->maxspeed;
+
+			if ((ch->flags & CHN_F_EXCLUSIVE) ||
+			    (pcm_getflags(d->dev) & SD_F_BITPERFECT)) {
+				ai->min_rate = caps->minspeed;
+				ai->max_rate = caps->maxspeed;
+			} else {
+				ai->min_rate = feeder_rate_min;
+				ai->max_rate = feeder_rate_max;
+			}
 
 			ai->min_channels = minch;
 			ai->max_channels = maxch;
diff --git a/sys/dev/sound/pcm/sndstat.c b/sys/dev/sound/pcm/sndstat.c
index 6880ce383ba4..753531f3694e 100644
--- a/sys/dev/sound/pcm/sndstat.c
+++ b/sys/dev/sound/pcm/sndstat.c
@@ -45,9 +45,6 @@
 #include <sys/nv.h>
 #include <sys/dnv.h>
 #include <sys/sx.h>
-#ifdef COMPAT_FREEBSD32
-#include <sys/sysent.h>
-#endif
 
 #include <dev/sound/pcm/sound.h>
 #include <dev/sound/pcm/pcm.h>
@@ -326,47 +323,37 @@ sndstat_write(struct cdev *i_dev, struct uio *buf, int flag)
 }
 
 static void
-sndstat_get_caps(struct snddev_info *d, bool play, uint32_t *min_rate,
+sndstat_get_caps(struct snddev_info *d, int dir, uint32_t *min_rate,
     uint32_t *max_rate, uint32_t *fmts, uint32_t *minchn, uint32_t *maxchn)
 {
 	struct pcm_channel *c;
-	int dir;
-
-	dir = play ? PCMDIR_PLAY : PCMDIR_REC;
-
-	if (play && d->pvchancount > 0) {
-		*min_rate = *max_rate = d->pvchanrate;
-		*fmts = AFMT_ENCODING(d->pvchanformat);
-		*minchn = *maxchn = AFMT_CHANNEL(d->pvchanformat);
-		return;
-	} else if (!play && d->rvchancount > 0) {
-		*min_rate = *max_rate = d->rvchanrate;
-		*fmts = AFMT_ENCODING(d->rvchanformat);
-		*minchn = *maxchn = AFMT_CHANNEL(d->rvchanformat);
-		return;
-	}
+	struct pcmchan_caps *caps;
+	int i;
 
 	*fmts = 0;
 	*min_rate = UINT32_MAX;
 	*max_rate = 0;
 	*minchn = UINT32_MAX;
 	*maxchn = 0;
-	CHN_FOREACH(c, d, channels.pcm) {
-		struct pcmchan_caps *caps;
-		int i;
 
-		if (c->direction != dir || (c->flags & CHN_F_VIRTUAL) != 0)
+	CHN_FOREACH(c, d, channels.pcm) {
+		if (c->direction != dir)
 			continue;
-
 		CHN_LOCK(c);
 		caps = chn_getcaps(c);
-		*min_rate = min(caps->minspeed, *min_rate);
-		*max_rate = max(caps->maxspeed, *max_rate);
 		for (i = 0; caps->fmtlist[i]; i++) {
 			*fmts |= AFMT_ENCODING(caps->fmtlist[i]);
 			*minchn = min(AFMT_CHANNEL(caps->fmtlist[i]), *minchn);
 			*maxchn = max(AFMT_CHANNEL(caps->fmtlist[i]), *maxchn);
 		}
+		if ((c->flags & CHN_F_EXCLUSIVE) ||
+		    (pcm_getflags(d->dev) & SD_F_BITPERFECT)) {
+			*min_rate = min(*min_rate, caps->minspeed);
+			*max_rate = max(*max_rate, caps->maxspeed);
+		} else {
+			*min_rate = min(*min_rate, feeder_rate_min);
+			*max_rate = max(*max_rate, feeder_rate_max);
+		}
 		CHN_UNLOCK(c);
 	}
 	if (*min_rate == UINT32_MAX)
@@ -395,9 +382,12 @@ sndstat_create_diinfo_nv(uint32_t min_rate, uint32_t max_rate, uint32_t formats,
 static int
 sndstat_build_sound4_nvlist(struct snddev_info *d, nvlist_t **dip)
 {
+	struct pcm_channel *c;
+	struct pcm_feeder *f;
+	struct sbuf sb;
 	uint32_t maxrate, minrate, fmts, minchn, maxchn;
-	nvlist_t *di = NULL, *sound4di = NULL, *diinfo = NULL;
-	int err;
+	nvlist_t *di = NULL, *sound4di = NULL, *diinfo = NULL, *cdi = NULL;
+	int err, nchan;
 
 	di = nvlist_create(0);
 	if (di == NULL) {
@@ -422,8 +412,8 @@ sndstat_build_sound4_nvlist(struct snddev_info *d, nvlist_t **dip)
 	nvlist_add_number(di, SNDST_DSPS_PCHAN, d->playcount);
 	nvlist_add_number(di, SNDST_DSPS_RCHAN, d->reccount);
 	if (d->playcount > 0) {
-		sndstat_get_caps(d, true, &minrate, &maxrate, &fmts, &minchn,
-		    &maxchn);
+		sndstat_get_caps(d, PCMDIR_PLAY, &minrate, &maxrate, &fmts,
+		    &minchn, &maxchn);
 		nvlist_add_number(di, "pminrate", minrate);
 		nvlist_add_number(di, "pmaxrate", maxrate);
 		nvlist_add_number(di, "pfmts", fmts);
@@ -435,8 +425,8 @@ sndstat_build_sound4_nvlist(struct snddev_info *d, nvlist_t **dip)
 			nvlist_move_nvlist(di, SNDST_DSPS_INFO_PLAY, diinfo);
 	}
 	if (d->reccount > 0) {
-		sndstat_get_caps(d, false, &minrate, &maxrate, &fmts, &minchn,
-		    &maxchn);
+		sndstat_get_caps(d, PCMDIR_REC, &minrate, &maxrate, &fmts,
+		    &minchn, &maxchn);
 		nvlist_add_number(di, "rminrate", minrate);
 		nvlist_add_number(di, "rmaxrate", maxrate);
 		nvlist_add_number(di, "rfmts", fmts);
@@ -454,8 +444,120 @@ sndstat_build_sound4_nvlist(struct snddev_info *d, nvlist_t **dip)
 	    sound4di, SNDST_DSPS_SOUND4_BITPERFECT, d->flags & SD_F_BITPERFECT);
 	nvlist_add_number(sound4di, SNDST_DSPS_SOUND4_PVCHAN, d->pvchancount);
 	nvlist_add_number(sound4di, SNDST_DSPS_SOUND4_RVCHAN, d->rvchancount);
+
+	nchan = 0;
+	CHN_FOREACH(c, d, channels.pcm) {
+		sbuf_new(&sb, NULL, 4096, SBUF_AUTOEXTEND);
+		cdi = nvlist_create(0);
+		if (cdi == NULL) {
+			sbuf_delete(&sb);
+			PCM_RELEASE_QUICK(d);
+			err = ENOMEM;
+			goto done;
+		}
+
+		CHN_LOCK(c);
+
+		nvlist_add_string(cdi, SNDST_DSPS_SOUND4_CHAN_NAME, c->name);
+		nvlist_add_string(cdi, SNDST_DSPS_SOUND4_CHAN_PARENTCHAN,
+		    c->parentchannel != NULL ? c->parentchannel->name : "");
+		nvlist_add_number(cdi, SNDST_DSPS_SOUND4_CHAN_UNIT, nchan++);
+		nvlist_add_number(cdi, SNDST_DSPS_SOUND4_CHAN_LATENCY,
+		    c->latency);
+		nvlist_add_number(cdi, SNDST_DSPS_SOUND4_CHAN_RATE, c->speed);
+		nvlist_add_number(cdi, SNDST_DSPS_SOUND4_CHAN_FORMAT,
+		    c->format);
+		nvlist_add_number(cdi, SNDST_DSPS_SOUND4_CHAN_PID, c->pid);
+		nvlist_add_string(cdi, SNDST_DSPS_SOUND4_CHAN_COMM, c->comm);
+		nvlist_add_number(cdi, SNDST_DSPS_SOUND4_CHAN_INTR,
+		    c->interrupts);
+		nvlist_add_number(cdi, SNDST_DSPS_SOUND4_CHAN_FEEDCNT,
+		    c->feedcount);
+		nvlist_add_number(cdi, SNDST_DSPS_SOUND4_CHAN_XRUNS, c->xruns);
+		nvlist_add_number(cdi, SNDST_DSPS_SOUND4_CHAN_LEFTVOL,
+		    CHN_GETVOLUME(c, SND_VOL_C_PCM, SND_CHN_T_FL));
+		nvlist_add_number(cdi, SNDST_DSPS_SOUND4_CHAN_RIGHTVOL,
+		    CHN_GETVOLUME(c, SND_VOL_C_PCM, SND_CHN_T_FR));
+		nvlist_add_number(cdi, SNDST_DSPS_SOUND4_CHAN_HWBUF_FORMAT,
+		    sndbuf_getfmt(c->bufhard));
+		nvlist_add_number(cdi, SNDST_DSPS_SOUND4_CHAN_HWBUF_SIZE,
+		    sndbuf_getsize(c->bufhard));
+		nvlist_add_number(cdi, SNDST_DSPS_SOUND4_CHAN_HWBUF_BLKSZ,
+		    sndbuf_getblksz(c->bufhard));
+		nvlist_add_number(cdi, SNDST_DSPS_SOUND4_CHAN_HWBUF_BLKCNT,
+		    sndbuf_getblkcnt(c->bufhard));
+		nvlist_add_number(cdi, SNDST_DSPS_SOUND4_CHAN_HWBUF_FREE,
+		    sndbuf_getfree(c->bufhard));
+		nvlist_add_number(cdi, SNDST_DSPS_SOUND4_CHAN_HWBUF_READY,
+		    sndbuf_getready(c->bufhard));
+		nvlist_add_number(cdi, SNDST_DSPS_SOUND4_CHAN_SWBUF_FORMAT,
+		    sndbuf_getfmt(c->bufsoft));
+		nvlist_add_number(cdi, SNDST_DSPS_SOUND4_CHAN_SWBUF_SIZE,
+		    sndbuf_getsize(c->bufsoft));
+		nvlist_add_number(cdi, SNDST_DSPS_SOUND4_CHAN_SWBUF_BLKSZ,
+		    sndbuf_getblksz(c->bufsoft));
+		nvlist_add_number(cdi, SNDST_DSPS_SOUND4_CHAN_SWBUF_BLKCNT,
+		    sndbuf_getblkcnt(c->bufsoft));
+		nvlist_add_number(cdi, SNDST_DSPS_SOUND4_CHAN_SWBUF_FREE,
+		    sndbuf_getfree(c->bufsoft));
+		nvlist_add_number(cdi, SNDST_DSPS_SOUND4_CHAN_SWBUF_READY,
+		    sndbuf_getready(c->bufsoft));
+
+		sbuf_printf(&sb, "[%s",
+		    (c->direction == PCMDIR_REC) ? "hardware" : "userland");
+		sbuf_printf(&sb, " -> ");
+		f = c->feeder;
+		while (f->source != NULL)
+			f = f->source;
+		while (f != NULL) {
+			sbuf_printf(&sb, "%s", f->class->name);
+			if (f->desc->type == FEEDER_FORMAT) {
+				sbuf_printf(&sb, "(0x%08x -> 0x%08x)",
+				    f->desc->in, f->desc->out);
+			} else if (f->desc->type == FEEDER_MATRIX) {
+				sbuf_printf(&sb, "(%d.%d -> %d.%d)",
+				    AFMT_CHANNEL(f->desc->in) -
+				    AFMT_EXTCHANNEL(f->desc->in),
+				    AFMT_EXTCHANNEL(f->desc->in),
+				    AFMT_CHANNEL(f->desc->out) -
+				    AFMT_EXTCHANNEL(f->desc->out),
+				    AFMT_EXTCHANNEL(f->desc->out));
+			} else if (f->desc->type == FEEDER_RATE) {
+				sbuf_printf(&sb,
+				    "(0x%08x q:%d %d -> %d)",
+				    f->desc->out,
+				    FEEDER_GET(f, FEEDRATE_QUALITY),
+				    FEEDER_GET(f, FEEDRATE_SRC),
+				    FEEDER_GET(f, FEEDRATE_DST));
+			} else {
+				sbuf_printf(&sb, "(0x%08x)",
+				    f->desc->out);
+			}
+			sbuf_printf(&sb, " -> ");
+			f = f->parent;
+		}
+		sbuf_printf(&sb, "%s]",
+		    (c->direction == PCMDIR_REC) ? "userland" : "hardware");
+
+		CHN_UNLOCK(c);
+
+		sbuf_finish(&sb);
+		nvlist_add_string(cdi, SNDST_DSPS_SOUND4_CHAN_FEEDERCHAIN,
+		    sbuf_data(&sb));
+		sbuf_delete(&sb);
+
+		nvlist_append_nvlist_array(sound4di,
+		    SNDST_DSPS_SOUND4_CHAN_INFO, cdi);
+		nvlist_destroy(cdi);
+		err = nvlist_error(sound4di);
+		if (err) {
+			PCM_RELEASE_QUICK(d);
+			goto done;
+		}
+	}
 	nvlist_move_nvlist(di, SNDST_DSPS_PROVIDER_INFO, sound4di);
 	sound4di = NULL;
+
 	PCM_RELEASE_QUICK(d);
 	nvlist_add_string(di, SNDST_DSPS_PROVIDER, SNDST_DSPS_SOUND4_PROVIDER);
 
@@ -622,10 +724,9 @@ sndstat_refresh_devs(struct sndstat_file *pf)
 }
 
 static int
-sndstat_get_devs(struct sndstat_file *pf, caddr_t data)
+sndstat_get_devs(struct sndstat_file *pf, void *arg_buf, size_t *arg_nbytes)
 {
 	int err;
-	struct sndstioc_nv_arg *arg = (struct sndstioc_nv_arg *)data;
 
 	SNDSTAT_LOCK();
 	sx_xlock(&pf->lock);
@@ -664,22 +765,22 @@ sndstat_get_devs(struct sndstat_file *pf, caddr_t data)
 
 	SNDSTAT_UNLOCK();
 
-	if (!arg->nbytes) {
-		arg->nbytes = pf->devs_nbytes;
+	if (*arg_nbytes == 0) {
+		*arg_nbytes = pf->devs_nbytes;
 		err = 0;
 		goto done;
 	}
-	if (arg->nbytes < pf->devs_nbytes) {
-		arg->nbytes = 0;
+	if (*arg_nbytes < pf->devs_nbytes) {
+		*arg_nbytes = 0;
 		err = 0;
 		goto done;
 	}
 
-	err = copyout(pf->devs_nvlbuf, arg->buf, pf->devs_nbytes);
+	err = copyout(pf->devs_nvlbuf, arg_buf, pf->devs_nbytes);
 	if (err)
 		goto done;
 
-	arg->nbytes = pf->devs_nbytes;
+	*arg_nbytes = pf->devs_nbytes;
 
 	free(pf->devs_nvlbuf, M_NVLIST);
 	pf->devs_nvlbuf = NULL;
@@ -850,25 +951,24 @@ sndstat_dsp_unpack_nvlist(const nvlist_t *nvlist, struct sndstat_userdev *ud)
 }
 
 static int
-sndstat_add_user_devs(struct sndstat_file *pf, caddr_t data)
+sndstat_add_user_devs(struct sndstat_file *pf, void *nvlbuf, size_t nbytes)
 {
 	int err;
 	nvlist_t *nvl = NULL;
 	const nvlist_t * const *dsps;
 	size_t i, ndsps;
-	struct sndstioc_nv_arg *arg = (struct sndstioc_nv_arg *)data;
 
 	if ((pf->fflags & FWRITE) == 0) {
 		err = EPERM;
 		goto done;
 	}
 
-	if (arg->nbytes > SNDST_UNVLBUF_MAX) {
+	if (nbytes > SNDST_UNVLBUF_MAX) {
 		err = ENOMEM;
 		goto done;
 	}
 
-	err = sndstat_unpack_user_nvlbuf(arg->buf, arg->nbytes, &nvl);
+	err = sndstat_unpack_user_nvlbuf(nvlbuf, nbytes, &nvl);
 	if (err != 0)
 		goto done;
 
@@ -914,52 +1014,17 @@ sndstat_flush_user_devs(struct sndstat_file *pf)
 	return (0);
 }
 
-#ifdef COMPAT_FREEBSD32
-static int
-compat_sndstat_get_devs32(struct sndstat_file *pf, caddr_t data)
-{
-	struct sndstioc_nv_arg32 *arg32 = (struct sndstioc_nv_arg32 *)data;
-	struct sndstioc_nv_arg arg;
-	int err;
-
-	arg.buf = (void *)(uintptr_t)arg32->buf;
-	arg.nbytes = arg32->nbytes;
-
-	err = sndstat_get_devs(pf, (caddr_t)&arg);
-	if (err == 0) {
-		arg32->buf = (uint32_t)(uintptr_t)arg.buf;
-		arg32->nbytes = arg.nbytes;
-	}
-
-	return (err);
-}
-
-static int
-compat_sndstat_add_user_devs32(struct sndstat_file *pf, caddr_t data)
-{
-	struct sndstioc_nv_arg32 *arg32 = (struct sndstioc_nv_arg32 *)data;
-	struct sndstioc_nv_arg arg;
-	int err;
-
-	arg.buf = (void *)(uintptr_t)arg32->buf;
-	arg.nbytes = arg32->nbytes;
-
-	err = sndstat_add_user_devs(pf, (caddr_t)&arg);
-	if (err == 0) {
-		arg32->buf = (uint32_t)(uintptr_t)arg.buf;
-		arg32->nbytes = arg.nbytes;
-	}
-
-	return (err);
-}
-#endif
-
 static int
 sndstat_ioctl(
     struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct thread *td)
 {
 	int err;
 	struct sndstat_file *pf;
+	struct sndstioc_nv_arg *arg;
+#ifdef COMPAT_FREEBSD32
+	struct sndstioc_nv_arg32 *arg32;
+	size_t nbytes;
+#endif
 
 	err = devfs_get_cdevpriv((void **)&pf);
 	if (err != 0)
@@ -967,27 +1032,30 @@ sndstat_ioctl(
 
 	switch (cmd) {
 	case SNDSTIOC_GET_DEVS:
-		err = sndstat_get_devs(pf, data);
+		arg = (struct sndstioc_nv_arg *)data;
+		err = sndstat_get_devs(pf, arg->buf, &arg->nbytes);
 		break;
 #ifdef COMPAT_FREEBSD32
 	case SNDSTIOC_GET_DEVS32:
-		if (!SV_CURPROC_FLAG(SV_ILP32)) {
-			err = ENODEV;
-			break;
+		arg32 = (struct sndstioc_nv_arg32 *)data;
+		nbytes = arg32->nbytes;
+		err = sndstat_get_devs(pf, (void *)(uintptr_t)arg32->buf,
+		    &nbytes);
+		if (err == 0) {
+			KASSERT(nbytes < UINT_MAX, ("impossibly many bytes"));
+			arg32->nbytes = nbytes;
 		}
-		err = compat_sndstat_get_devs32(pf, data);
 		break;
 #endif
 	case SNDSTIOC_ADD_USER_DEVS:
-		err = sndstat_add_user_devs(pf, data);
+		arg = (struct sndstioc_nv_arg *)data;
+		err = sndstat_add_user_devs(pf, arg->buf, arg->nbytes);
 		break;
 #ifdef COMPAT_FREEBSD32
 	case SNDSTIOC_ADD_USER_DEVS32:
-		if (!SV_CURPROC_FLAG(SV_ILP32)) {
-			err = ENODEV;
-			break;
-		}
-		err = compat_sndstat_add_user_devs32(pf, data);
+		arg32 = (struct sndstioc_nv_arg32 *)data;
+		err = sndstat_add_user_devs(pf, (void *)(uintptr_t)arg32->buf,
+		    arg32->nbytes);
 		break;
 #endif
 	case SNDSTIOC_REFRESH_DEVS:
@@ -1166,6 +1234,8 @@ sndstat_prepare_pcm(struct sbuf *s, device_t dev, int verbose)
 		KASSERT(c->bufhard != NULL && c->bufsoft != NULL,
 		    ("hosed pcm channel setup"));
 
+		CHN_LOCK(c);
+
 		sbuf_printf(s, "\n\t");
 
 		sbuf_printf(s, "%s[%s]: ",
@@ -1257,6 +1327,8 @@ sndstat_prepare_pcm(struct sbuf *s, device_t dev, int verbose)
 		}
 		sbuf_printf(s, "{%s}",
 		    (c->direction == PCMDIR_REC) ? "userland" : "hardware");
+
+		CHN_UNLOCK(c);
 	}
 
 	return (0);
diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c
index 8d97dcd60231..b18b83468150 100644
--- a/sys/dev/sound/pcm/sound.c
+++ b/sys/dev/sound/pcm/sound.c
@@ -558,14 +558,7 @@ pcm_register(device_t dev, void *devinfo, int numplay, int numrec)
 	d->lock = snd_mtxcreate(device_get_nameunit(dev), "sound cdev");
 	cv_init(&d->cv, device_get_nameunit(dev));
 	PCM_ACQUIRE_QUICK(d);
-#if 0
-	/*
-	 * d->flags should be cleared by the allocator of the softc.
-	 * We cannot clear this field here because several devices set
-	 * this flag before calling pcm_register().
-	 */
-	d->flags = 0;
-#endif
+
 	i = 0;
 	if (resource_int_value(device_get_name(dev), device_get_unit(dev),
 	    "vpc", &i) != 0 || i != 0)
diff --git a/sys/dev/sound/pcm/vchan.c b/sys/dev/sound/pcm/vchan.c
index 528c6fa62621..fa4fa2023b71 100644
--- a/sys/dev/sound/pcm/vchan.c
+++ b/sys/dev/sound/pcm/vchan.c
@@ -768,25 +768,10 @@ vchan_create(struct pcm_channel *parent)
 		    &vchanspd);
 		CHN_LOCK(parent);
 		if (r != 0) {
-			/*
-			 * No saved value, no hint, NOTHING.
-			 *
-			 * Workaround for sb16 running
-			 * poorly at 45k / 49k.
-			 */
-			switch (parent_caps->maxspeed) {
-			case 45000:
-			case 49000:
-				vchanspd = 44100;
-				break;
-			default:
-				vchanspd = VCHAN_DEFAULT_RATE;
-				if (vchanspd > parent_caps->maxspeed)
-					vchanspd = parent_caps->maxspeed;
-				break;
-			}
-			if (vchanspd < parent_caps->minspeed)
-				vchanspd = parent_caps->minspeed;
+			/* No saved value, no hint, NOTHING. */
+			vchanspd = VCHAN_DEFAULT_RATE;
+			RANGE(vchanspd, parent_caps->minspeed,
+			    parent_caps->maxspeed);
 		}
 		save = 1;
 	}
@@ -795,10 +780,7 @@ vchan_create(struct pcm_channel *parent)
 		/*
 		 * Limit the speed between feeder_rate_min <-> feeder_rate_max.
 		 */
-		if (vchanspd < feeder_rate_min)
-			vchanspd = feeder_rate_min;
-		if (vchanspd > feeder_rate_max)
-			vchanspd = feeder_rate_max;
+		RANGE(vchanspd, feeder_rate_min, feeder_rate_max);
 
 		if (feeder_rate_round) {
 			RANGE(vchanspd, parent_caps->minspeed,
diff --git a/sys/dev/sound/usb/uaudio.c b/sys/dev/sound/usb/uaudio.c
index d47eb86ed271..c202ac581119 100644
--- a/sys/dev/sound/usb/uaudio.c
+++ b/sys/dev/sound/usb/uaudio.c
@@ -368,7 +368,6 @@ struct uaudio_softc_child {
 };
 
 struct uaudio_softc {
-	struct sbuf sc_sndstat;
 	struct sndcard_func sc_sndcard_func;
 	struct uaudio_chan sc_rec_chan[UAUDIO_MAX_CHILD];
 	struct uaudio_chan sc_play_chan[UAUDIO_MAX_CHILD];
@@ -391,7 +390,6 @@ struct uaudio_softc {
 	uint8_t	sc_mixer_iface_index;
 	uint8_t	sc_mixer_iface_no;
 	uint8_t	sc_mixer_chan;
-	uint8_t	sc_sndstat_valid:1;
 	uint8_t	sc_uq_audio_swap_lr:1;
 	uint8_t	sc_uq_au_inp_async:1;
 	uint8_t	sc_uq_au_no_xu:1;
@@ -1293,8 +1291,6 @@ uaudio_detach(device_t dev)
 	if (bus_generic_detach(dev) != 0) {
 		DPRINTF("detach failed!\n");
 	}
-	sbuf_delete(&sc->sc_sndstat);
-	sc->sc_sndstat_valid = 0;
 
 	umidi_detach(dev);
 
@@ -2149,15 +2145,6 @@ uaudio_chan_fill_info_sub(struct uaudio_softc *sc, struct usb_device *udev,
 		if (rate > chan->pcm_cap.maxspeed || chan->pcm_cap.maxspeed == 0)
 			chan->pcm_cap.maxspeed = rate;
 
-		if (sc->sc_sndstat_valid != 0) {
-			sbuf_printf(&sc->sc_sndstat, "\n\t"
-			    "mode %d.%d:(%s) %dch, %dbit, %s, %dHz",
-			    curidx, alt_index,
-			    (ep_dir == UE_DIR_IN) ? "input" : "output",
-				    channels, p_fmt->bPrecision,
-				    p_fmt->description, rate);
-		}
-
 	next_ep:
 		sed.v1 = NULL;
 		ed1 = NULL;
@@ -2230,9 +2217,6 @@ uaudio_chan_fill_info(struct uaudio_softc *sc, struct usb_device *udev)
 	if (channels == 0)
 		channels = channels_max;
 
-	if (sbuf_new(&sc->sc_sndstat, NULL, 4096, SBUF_AUTOEXTEND))
-		sc->sc_sndstat_valid = 1;
-
 	/* try to search for a valid config */
 
 	for (x = channels; x; x--) {
@@ -2263,8 +2247,6 @@ uaudio_chan_fill_info(struct uaudio_softc *sc, struct usb_device *udev)
 		if (x == (channels + 1))
 			x--;
 	}
-	if (sc->sc_sndstat_valid)
-		sbuf_finish(&sc->sc_sndstat);
 }
 
 static void
diff --git a/sys/dev/ste/if_ste.c b/sys/dev/ste/if_ste.c
index 7c7eb02ccfb7..06e25175c617 100644
--- a/sys/dev/ste/if_ste.c
+++ b/sys/dev/ste/if_ste.c
@@ -987,11 +987,6 @@ ste_attach(device_t dev)
 		goto fail;
 
 	ifp = sc->ste_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "can not if_alloc()\n");
-		error = ENOSPC;
-		goto fail;
-	}
 
 	/* Do MII setup. */
 	phy = MII_PHY_ANY;
diff --git a/sys/dev/stge/if_stge.c b/sys/dev/stge/if_stge.c
index 170d9e4da94c..97c2b751d476 100644
--- a/sys/dev/stge/if_stge.c
+++ b/sys/dev/stge/if_stge.c
@@ -560,12 +560,6 @@ stge_attach(device_t dev)
 	}
 
 	ifp = sc->sc_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(sc->sc_dev, "failed to if_alloc()\n");
-		error = ENXIO;
-		goto fail;
-	}
-
 	if_setsoftc(ifp, sc);
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 	if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
diff --git a/sys/dev/sume/if_sume.c b/sys/dev/sume/if_sume.c
index c478e2343a97..4113af5a48b3 100644
--- a/sys/dev/sume/if_sume.c
+++ b/sys/dev/sume/if_sume.c
@@ -1144,7 +1144,7 @@ check_tx_queues(struct sume_adapter *adapter)
 	}
 }
 
-static int
+static void
 sume_ifp_alloc(struct sume_adapter *adapter, uint32_t port)
 {
 	if_t ifp;
@@ -1152,11 +1152,6 @@ sume_ifp_alloc(struct sume_adapter *adapter, uint32_t port)
 	    M_ZERO | M_WAITOK);
 
 	ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(adapter->dev, "cannot allocate ifnet\n");
-		return (ENOMEM);
-	}
-
 	adapter->ifp[port] = ifp;
 	if_setsoftc(ifp, nf_priv);
 
@@ -1182,8 +1177,6 @@ sume_ifp_alloc(struct sume_adapter *adapter, uint32_t port)
 	ifmedia_set(&nf_priv->media, IFM_ETHER | IFM_10G_SR);
 
 	if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0);
-
-	return (0);
 }
 
 static void
@@ -1453,11 +1446,8 @@ sume_attach(device_t dev)
 		goto error;
 
 	/* Now do the network interfaces. */
-	for (i = 0; i < SUME_NPORTS; i++) {
-		error = sume_ifp_alloc(adapter, i);
-		if (error != 0)
-			goto error;
-	}
+	for (i = 0; i < SUME_NPORTS; i++)
+		sume_ifp_alloc(adapter, i);
 
 	/*  Register stats and register sysctls. */
 	sume_sysctl_init(adapter);
diff --git a/sys/dev/superio/superio.c b/sys/dev/superio/superio.c
index 6333cb06a7c1..ff05d378ce92 100644
--- a/sys/dev/superio/superio.c
+++ b/sys/dev/superio/superio.c
@@ -616,12 +616,9 @@ superio_detect(device_t dev, bool claim, struct siosc *sc)
 	if (superio_table[i].descr != NULL) {
 		device_set_desc(dev, superio_table[i].descr);
 	} else if (sc->vendor == SUPERIO_VENDOR_ITE) {
-		char descr[64];
-
-		snprintf(descr, sizeof(descr),
+		device_set_descf(dev,
 		    "ITE IT%4x SuperIO (revision 0x%02x)",
 		    sc->devid, sc->revid);
-		device_set_desc_copy(dev, descr);
 	}
 	return (0);
 }
diff --git a/sys/dev/ti/if_ti.c b/sys/dev/ti/if_ti.c
index 6f88862d8009..14f7d353303f 100644
--- a/sys/dev/ti/if_ti.c
+++ b/sys/dev/ti/if_ti.c
@@ -2384,11 +2384,6 @@ ti_attach(device_t dev)
 	callout_init_mtx(&sc->ti_watchdog, &sc->ti_mtx, 0);
 	ifmedia_init(&sc->ifmedia, IFM_IMASK, ti_ifmedia_upd, ti_ifmedia_sts);
 	ifp = sc->ti_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "can not if_alloc()\n");
-		error = ENOSPC;
-		goto fail;
-	}
 	if_sethwassist(ifp, TI_CSUM_FEATURES);
 	if_setcapabilities(ifp, IFCAP_TXCSUM | IFCAP_RXCSUM);
 	if_setcapenable(ifp, if_getcapabilities(sc->ti_ifp));
diff --git a/sys/dev/tsec/if_tsec.c b/sys/dev/tsec/if_tsec.c
index 1c03110e1889..80e42116ed9f 100644
--- a/sys/dev/tsec/if_tsec.c
+++ b/sys/dev/tsec/if_tsec.c
@@ -239,12 +239,6 @@ tsec_attach(struct tsec_softc *sc)
 
 	/* Create network interface for upper layers */
 	ifp = sc->tsec_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(sc->dev, "if_alloc() failed\n");
-		tsec_detach(sc);
-		return (ENOMEM);
-	}
-
 	if_setsoftc(ifp, sc);
 	if_initname(ifp, device_get_name(sc->dev), device_get_unit(sc->dev));
 	if_setflags(ifp, IFF_SIMPLEX | IFF_MULTICAST | IFF_BROADCAST);
diff --git a/sys/dev/uart/uart_dev_quicc.c b/sys/dev/uart/uart_dev_quicc.c
index bc9134d5c676..3481154f7da6 100644
--- a/sys/dev/uart/uart_dev_quicc.c
+++ b/sys/dev/uart/uart_dev_quicc.c
@@ -412,7 +412,6 @@ quicc_bus_param(struct uart_softc *sc, int baudrate, int databits,
 static int
 quicc_bus_probe(struct uart_softc *sc)
 {
-	char buf[80];
 	int error;
 
 	error = quicc_probe(&sc->sc_bas);
@@ -422,8 +421,7 @@ quicc_bus_probe(struct uart_softc *sc)
 	sc->sc_rxfifosz = 1;
 	sc->sc_txfifosz = 1;
 
-	snprintf(buf, sizeof(buf), "quicc, channel %d", sc->sc_bas.chan);
-	device_set_desc_copy(sc->sc_dev, buf);
+	device_set_descf(sc->sc_dev, "quicc, channel %d", sc->sc_bas.chan);
 	return (0);
 }
 
diff --git a/sys/dev/uart/uart_dev_z8530.c b/sys/dev/uart/uart_dev_z8530.c
index 53d70b5f42a5..a2f4580d2b5b 100644
--- a/sys/dev/uart/uart_dev_z8530.c
+++ b/sys/dev/uart/uart_dev_z8530.c
@@ -509,7 +509,6 @@ z8530_bus_param(struct uart_softc *sc, int baudrate, int databits,
 static int
 z8530_bus_probe(struct uart_softc *sc)
 {
-	char buf[80];
 	int error;
 	char ch;
 
@@ -522,8 +521,7 @@ z8530_bus_probe(struct uart_softc *sc)
 
 	ch = sc->sc_bas.chan - 1 + 'A';
 
-	snprintf(buf, sizeof(buf), "z8530, channel %c", ch);
-	device_set_desc_copy(sc->sc_dev, buf);
+	device_set_descf(sc->sc_dev, "z8530, channel %c", ch);
 	return (0);
 }
 
diff --git a/sys/dev/usb/controller/usb_controller.c b/sys/dev/usb/controller/usb_controller.c
index 163ee14bd097..838bd6bf7621 100644
--- a/sys/dev/usb/controller/usb_controller.c
+++ b/sys/dev/usb/controller/usb_controller.c
@@ -135,7 +135,6 @@ DRIVER_MODULE(usbus, octusb, usb_driver, 0, 0);
 
 /* Dual Mode Drivers */
 DRIVER_MODULE(usbus, dwcotg, usb_driver, 0, 0);
-DRIVER_MODULE(usbus, saf1761otg, usb_driver, 0, 0);
 
 /*------------------------------------------------------------------------*
  *	usb_probe
diff --git a/sys/dev/usb/controller/xhci.c b/sys/dev/usb/controller/xhci.c
index 17800dc11d0c..58cca9225bdd 100644
--- a/sys/dev/usb/controller/xhci.c
+++ b/sys/dev/usb/controller/xhci.c
@@ -2,6 +2,7 @@
  * SPDX-License-Identifier: BSD-2-Clause
  *
  * Copyright (c) 2010-2022 Hans Petter Selasky
+ * Copyright (c) 2020-2024 Hiroki Sato <hrs@FreeBSD.org>
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -83,6 +84,7 @@
 
 #include <dev/usb/controller/xhci.h>
 #include <dev/usb/controller/xhcireg.h>
+#include <dev/usb/controller/xhci_dbc.h>
 
 #define	XHCI_BUS2SC(bus) \
 	__containerof(bus, struct xhci_softc, sc_bus)
@@ -154,6 +156,9 @@ struct xhci_std_temp {
 	uint8_t			do_isoc_sync;
 };
 
+static void xhci_debug_reg_read(struct xhci_softc *);
+static void xhci_debug_reg_restore(struct xhci_softc *);
+
 static void	xhci_do_poll(struct usb_bus *);
 static void	xhci_device_done(struct usb_xfer *, usb_error_t);
 static void	xhci_root_intr(struct xhci_softc *);
@@ -311,6 +316,7 @@ xhci_start_controller(struct xhci_softc *sc)
 	uint16_t i;
 
 	DPRINTF("\n");
+	printf("%s called\n", __func__);
 
 	sc->sc_event_ccs = 1;
 	sc->sc_event_idx = 0;
@@ -321,6 +327,10 @@ xhci_start_controller(struct xhci_softc *sc)
 	if (err)
 		return (err);
 
+	if (sc->sc_udbc != NULL) {
+		xhci_debug_reg_restore(sc);
+		xhci_debug_enable(sc->sc_udbc);
+	}
 	/* set up number of device slots */
 	DPRINTF("CONFIG=0x%08x -> 0x%08x\n",
 	    XREAD4(sc, oper, XHCI_CONFIG), sc->sc_noslot);
@@ -569,6 +579,60 @@ xhci_init(struct xhci_softc *sc, device_t self, uint8_t dma32)
 	/* enable 64Kbyte control endpoint quirk */
 	sc->sc_bus.control_ep_quirk = (xhcictlquirk ? 1 : 0);
 
+	/* Check if DbC is available. */
+	{
+		sc->sc_udbc = malloc(sizeof(*sc->sc_udbc), M_DEVBUF, 
+		    M_WAITOK | M_ZERO);
+		sc->sc_udbc->sc_xhci = sc;
+#if 0
+		uint32_t eec = -1;	/* XXX */
+		uint32_t eecp;
+
+		for (eecp = XHCI_HCS0_XECP(temp) << 2;
+		     eecp != 0 && XHCI_XECP_NEXT(eec);
+		     eecp += XHCI_XECP_NEXT(eec) << 2) {
+			eec = XREAD4(sc, capa, eecp);
+
+			if (XHCI_XECP_ID(eec) != XHCI_ID_USB_DEBUG) {
+				device_printf(self,
+				    "looking for DBC(0x0a): %02x\n",
+				    XHCI_XECP_ID(eec));
+				continue;
+			}
+		}
+		if (XHCI_XECP_ID(eec) == XHCI_ID_USB_DEBUG) {
+#else
+		if (xhci_debug_probe(sc->sc_udbc)) {
+#endif
+			struct xhci_debug_reg *r;
+
+			sc->sc_dbc_off = sc->sc_udbc->sc_dbc_off;
+			udbcons_init(sc, self);
+
+			xhci_debug_reg_read(sc);
+			r = &sc->sc_udbc->reg;
+
+			device_printf(self, "DbC found at 0x%04x:\n"
+			    "  ERSTSZ=%04x\n"
+			    "  ERSTBA=0x%08llx\n"
+			    "  ERDP=0x%08llx\n"
+			    "  CP=0x%08llx\n"
+			    "  DDI1=0x%04x\n"
+			    "  DDI2=0x%04x\n",
+				sc->sc_dbc_off,
+				r->erstsz,
+				(unsigned long long)le64toh(r->erstba),
+				(unsigned long long)le64toh(r->erdp),
+				(unsigned long long)le64toh(r->cp),
+				r->ddi1,
+				r->ddi2);
+			device_printf(self, "DbC is %s\n",
+			    (XREAD4(sc, dbc, XHCI_DCCTRL) & XHCI_DCCTRL_DCE)
+				? "running"
+				: "not running");
+		} else
+			device_printf(self, "DbC not available\n");
+	}
 	temp = XREAD4(sc, capa, XHCI_HCSPARAMS1);
 
 	/* get number of device slots */
@@ -4406,3 +4470,39 @@ static const struct usb_bus_methods xhci_bus_methods = {
 	.set_hw_power_sleep = xhci_set_hw_power_sleep,
 	.set_endpoint_mode = xhci_set_endpoint_mode,
 };
+
+static void
+xhci_debug_reg_read(struct xhci_softc *sc)
+{
+	struct xhci_debug_reg *r;
+
+	if (sc->sc_dbc_off == 0)
+		return;
+
+	r = &sc->sc_udbc->reg;
+
+	r->erstsz = XREAD4(sc, dbc, XHCI_DCERSTSZ);
+	r->erstba = XREAD44LH(sc, dbc, XHCI_DCERSTBA);
+	r->erdp = XREAD44LH(sc, dbc, XHCI_DCERDP);
+	r->cp = XREAD44LH(sc, dbc, XHCI_DCCP);
+	r->ddi1 = XREAD4(sc, dbc, XHCI_DCDDI1);
+	r->ddi2 = XREAD4(sc, dbc, XHCI_DCDDI2);
+}
+static void
+xhci_debug_reg_restore(struct xhci_softc *sc)
+{
+	struct xhci_debug_reg *r;
+
+	if (sc->sc_dbc_off == 0)
+		return;
+
+	r = &sc->sc_udbc->reg;
+
+	XWRITE4(sc, dbc, XHCI_DCERSTSZ, r->erstsz);
+
+	XWRITE44LH(sc, dbc, XHCI_DCERSTBA, r->erstba);
+	XWRITE44LH(sc, dbc, XHCI_DCERDP, r->erdp);
+	XWRITE44LH(sc, dbc, XHCI_DCCP, r->cp);
+	XWRITE4(sc, dbc, XHCI_DCDDI1, r->ddi1);
+	XWRITE4(sc, dbc, XHCI_DCDDI2, r->ddi2);
+}
diff --git a/sys/dev/usb/controller/xhci.h b/sys/dev/usb/controller/xhci.h
index 3758815238ad..87b3438ce429 100644
--- a/sys/dev/usb/controller/xhci.h
+++ b/sys/dev/usb/controller/xhci.h
@@ -491,6 +491,8 @@ enum xhci_quirks {
 	XHCI_QUIRK_DMA_32B				= 0x00000002,
 };
 
+struct xhci_debug_softc;
+
 struct xhci_softc {
 	struct xhci_hw_softc	sc_hw;
 	/* base device */
@@ -533,6 +535,8 @@ struct xhci_softc {
 	uint32_t		sc_runt_off;
 	/* offset to doorbell registers */
 	uint32_t		sc_door_off;
+	/* offset to DbC registers */
+	uint32_t		sc_dbc_off;
 
 	/* chip specific */
 	uint16_t		sc_erst_max;
@@ -570,6 +574,9 @@ struct xhci_softc {
 
 	/* XHCI quirks. */
 	uint32_t		sc_quirks;
+
+	/* XHCI DbC */
+	struct xhci_debug_softc	*sc_udbc;
 };
 
 #define	XHCI_CMD_LOCK(sc)	sx_xlock(&(sc)->sc_cmd_sx)
diff --git a/sys/dev/usb/controller/xhci_dbc.c b/sys/dev/usb/controller/xhci_dbc.c
new file mode 100644
index 000000000000..72c40d60628b
--- /dev/null
+++ b/sys/dev/usb/controller/xhci_dbc.c
@@ -0,0 +1,1429 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2019-2024 Hiroki Sato <hrs@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+#include <sys/param.h>
+#include <sys/condvar.h>
+#include <sys/systm.h>	/* getenv_quad */
+
+#ifdef _KERNEL
+# define assert(x)
+# include <sys/bus.h>
+# include <sys/cons.h>
+# include <sys/kdb.h>
+# include <sys/tty.h>
+# include <sys/reboot.h>
+# include <sys/sbuf.h>
+# include <sys/sysctl.h>
+# include <vm/vm.h>
+# include <vm/vm_param.h>
+# include <vm/pmap.h>
+# include <dev/usb/usb.h>
+# include <dev/usb/usbdi.h>
+# include <dev/usb/usb_core.h>
+# include <dev/usb/usb_busdma.h>
+# include <dev/usb/usb_process.h>
+# include <dev/usb/usb_transfer.h>
+# include <dev/usb/usb_device.h>
+# include <dev/usb/usb_controller.h>
+# include <dev/usb/usb_bus.h>
+# include <dev/usb/controller/xhci.h>
+#else
+# include <assert.h>
+# include <bootstrap.h>
+# include <efi.h>
+# include <efilib.h>
+# include <dev/usb/controller/xhci_private.h>
+#endif
+
+#include <dev/usb/controller/xhcireg.h>
+#include <dev/usb/controller/xhci_dbc.h>
+#include <dev/usb/controller/xhci_dbc_private.h>
+
+#ifndef _KERNEL
+#include "xhci_dbc_cons.h"
+#include "xhci_dbc_dma.h"
+#endif
+
+/* XXX: this should be removed */
+static void flush_range(void *, uint32_t);
+
+#if 0
+static bool xhci_debug_running(struct xhci_debug_softc *);
+#endif
+static bool xhci_debug_update_regbit(struct xhci_debug_softc *, int, int, int,
+    bool);
+static bool xhci_debug_set_regbit(struct xhci_debug_softc *, int, int, int);
+static bool xhci_debug_reset_regbit(struct xhci_debug_softc *, int, int, int);
+static bool xhci_debug_wait_connection(struct xhci_debug_softc *, uint32_t);
+
+static void xhci_debug_ring_init(struct xhci_debug_softc *,
+    struct xhci_debug_ring *, int, uint32_t);
+static void xhci_debug_init_ep(struct xhci_endp_ctx64 *, uint64_t, uint32_t,
+    uint64_t);
+
+static void xhci_debug_softc_fixup(struct xhci_debug_softc *);
+static void xhci_debug_init_strings(struct xhci_debug_softc *, uint32_t *);
+
+static void xhci_debug_ring_doorbell(struct xhci_debug_softc *, uint32_t);
+static void xhci_debug_show_ring(struct xhci_debug_ring *, const char *);
+static void xhci_debug_show_ring0(struct xhci_debug_ring *, const char *);
+
+static int trb_tx_enqueue(struct xhci_debug_ring *);
+static int trb_rx_enqueue(struct xhci_debug_ring *);
+#if 0
+static struct xhci_trb *trb_lookup(struct xhci_debug_ring *, uint64_t, int *);
+#endif
+static void trb_push(struct xhci_debug_ring *, uint64_t, uint64_t);
+
+/* XXX */
+static void
+flush_range(void *ptr, uint32_t bytes)
+{
+#ifdef _KERNEL
+	/* amd64 only */
+	pmap_flush_cache_range((vm_offset_t)(uintptr_t)ptr,
+	    (vm_offset_t)((uintptr_t)ptr + bytes));
+#else
+	uint32_t i;
+	const uint32_t clshft = 6;
+	const uint32_t clsize = (1UL << clshft);
+	const uint32_t clmask = clsize - 1;
+	uint32_t lines = (bytes >> clshft);
+	lines += (bytes & clmask) != 0;
+
+	if (bytes == 0)
+		return;
+
+#define	CLFLUSH(ptr) \
+	__asm volatile("clflush %0" : "+m"(*(volatile char *)ptr))
+
+	for (i = 0; i < lines; i++)
+		CLFLUSH((void *)((uint64_t)ptr + (i * clsize)));
+#undef	CLFLUSH
+#endif
+}
+
+#define	STRSTATE(x)	[x] = #x
+static const char *strstate[] = {
+	STRSTATE(XHCI_DCPORT_ST_OFF),
+	STRSTATE(XHCI_DCPORT_ST_DISCONNECTED),
+	STRSTATE(XHCI_DCPORT_ST_DISABLED),
+	STRSTATE(XHCI_DCPORT_ST_RESETTING),
+	STRSTATE(XHCI_DCPORT_ST_ENABLED),
+	STRSTATE(XHCI_DCPORT_ST_CONFIGURED)
+};
+
+void
+udb_dump_info(struct xhci_debug_softc *sc)
+{
+	xhci_debug_event_dequeue(sc);
+
+	xhci_debug_update_state(sc);
+	printf("=============\n");
+	printf("    ctrl: 0x%x stat: 0x%x psc: 0x%x\n",
+	    _XREAD4(sc, dbc, XHCI_DCCTRL),
+	    _XREAD4(sc, dbc, XHCI_DCST),
+	    _XREAD4(sc, dbc, XHCI_DCPORTSC));
+	printf("      DbC Enable = %s\t",
+	    _XREAD4(sc, dbc, XHCI_DCCTRL) & XHCI_DCCTRL_DCE ? "YES" : "NO");
+	printf("      DbC Running = %s\n",
+	    _XREAD4(sc, dbc, XHCI_DCCTRL) & XHCI_DCCTRL_DCR ? "YES" : "NO");
+
+	printf("      Link State Event Enable = %s\t",
+	    _XREAD4(sc, dbc, XHCI_DCCTRL) & XHCI_DCCTRL_LSE ? "YES" : "NO");
+	printf("      Halt OUT TR = %s\n",
+	    _XREAD4(sc, dbc, XHCI_DCCTRL) & XHCI_DCCTRL_HOT ? "YES" : "NO");
+
+	printf("      Halt IN TR = %s\t",
+	    _XREAD4(sc, dbc, XHCI_DCCTRL) & XHCI_DCCTRL_HIT ? "YES" : "NO");
+	printf("      DbC Run Change = %s\n",
+	    _XREAD4(sc, dbc, XHCI_DCCTRL) & XHCI_DCCTRL_DRC ? "YES" : "NO");
+
+	printf("      DbC CCS = %s\t",
+	    _XREAD4(sc, dbc, XHCI_DCPORTSC) & XHCI_DCPORTSC_CCS ? "YES" : "NO");
+	printf("      DbC PED = %s\n",
+	    _XREAD4(sc, dbc, XHCI_DCPORTSC) & XHCI_DCPORTSC_PED ? "YES" : "NO");
+
+	printf("      DbC Port = %d\n",
+	    (uint8_t)XHCI_DCST_PORT_GET(_XREAD4(sc, dbc, XHCI_DCST)));
+
+	printf("    id: 0x%x\t", _XREAD4(sc, dbc, XHCI_DCID));
+	printf("    erstsz: %u, erstba: 0x%lx\n",
+	    _XREAD4(sc, dbc, XHCI_DCERSTSZ),
+	    _XREAD44LH(sc, dbc, XHCI_DCERSTBA));
+
+	printf("    erdp: 0x%lx, cp: 0x%lx\t",
+	    _XREAD44LH(sc, dbc, XHCI_DCERDP),
+	    _XREAD44LH(sc, dbc, XHCI_DCCP));
+	printf("    ddi1: 0x%x, ddi2: 0x%x\n",
+	    _XREAD4(sc, dbc, XHCI_DCDDI1),
+	    _XREAD4(sc, dbc, XHCI_DCDDI2));
+
+	printf("    erstba == sc->udb_erst_paddr: %d",
+	    _XREAD44LH(sc, dbc, XHCI_DCERSTBA) == sc->udb_erst_paddr);
+	printf("    erdp == erst[0].qwEvrsTablePtr: %d",
+	    _XREAD44LH(sc, dbc, XHCI_DCERDP) == sc->udb_erst[0].qwEvrsTablePtr);
+	printf("    cp == sc->udb_ctx_paddr: %d\n",
+	    _XREAD44LH(sc, dbc, XHCI_DCCP) == sc->udb_ctx_paddr);
+
+#ifndef _KERNEL
+	/* Loader console structure */
+	printf("=============\n");
+	printf("cons->c_flags = %x\n", sc->sc_cons->c_flags);
+#endif
+	printf("=============\n");
+	/* Update er->enq */
+	printf("ering ready = %s\n",
+	    xhci_debug_event_ready(sc) ? "YES" : "NO");
+	xhci_debug_show_ring0(&sc->udb_ering, "ering");
+	xhci_debug_show_ring0(&sc->udb_iring, "iring");
+	xhci_debug_show_ring0(&sc->udb_oring, "oring");
+	printf("=============\n");
+	printf("sc->dma_allocated = %d, ", sc->dma_allocated);
+	printf("sc->sc_init = %d\n", sc->sc_init);
+
+	printf("sc->sc_state = %s(%02x)\n", strstate[sc->sc_state],
+	    sc->sc_state);
+	printf("=============\n");
+	printf("DbC Commands:\n");
+	printf(" udb_send xxx: Send 'xxx'\n");
+	printf(" udb_recv: Recv'\n");
+	printf(" udb_probe: Probe and initialize DbC\n");
+	printf("=============\n");
+}
+
+#if 0
+static bool
+xhci_debug_running(struct xhci_debug_softc *sc)
+{
+	if (sc == NULL)
+		goto error;
+	if (sc->sc_init == false)
+		goto error;
+
+	xhci_debug_update_state(sc);
+	/* Reinitialize if possible */
+	if (sc->sc_state != XHCI_DCPORT_ST_CONFIGURED) {
+		xhci_debug_enable(sc);
+		xhci_debug_event_dequeue(sc);
+		xhci_debug_update_state(sc);
+	}
+	return (true);
+error:
+	DEBUG_PRINTF("%s: false\n", __func__);
+	return (false);
+}
+#endif
+
+void
+xhci_debug_update_state(struct xhci_debug_softc *sc)
+{
+	uint32_t ctrl;
+	uint32_t portsc;
+	uint32_t sc_state_old;
+
+	ctrl = _XREAD4(sc, dbc, XHCI_DCCTRL);
+	portsc = _XREAD4(sc, dbc, XHCI_DCPORTSC);
+	sc_state_old = sc->sc_state;
+	sc->sc_state = XHCI_DCSTATUS(ctrl, portsc);
+	if (sc->sc_state != sc_state_old)
+		DEBUG_PRINTF("state: %s -> %s\n",
+		    strstate[sc->sc_state], strstate[sc_state_old]);
+}
+
+static bool
+xhci_debug_update_regbit(struct xhci_debug_softc *sc, int reg, int bit,
+    int timeout, bool reset)
+{
+	uint32_t temp;
+	int expected;
+
+	timeout *= 10;	/* ms */
+	temp = le32toh(_XREAD4(sc, dbc, reg));
+	if (reset)
+		temp &= ~bit;
+	else
+		temp |= bit;
+	_XWRITE4(sc, dbc, reg, htole32(temp));
+	expected = (reset) ? 0 : bit;
+	while ((le32toh(_XREAD4(sc, dbc, reg)) & bit) != expected &&
+	    timeout != 0) {
+		delay(100);
+		timeout--;
+	}
+	return (timeout > 0);
+}
+static bool
+xhci_debug_set_regbit(struct xhci_debug_softc *sc, int reg, int bit,
+    int timeout)
+{
+
+	return (xhci_debug_update_regbit(sc, reg, bit, timeout, false));
+}
+static bool
+xhci_debug_reset_regbit(struct xhci_debug_softc *sc, int reg, int bit,
+    int timeout)
+{
+
+	return (xhci_debug_update_regbit(sc, reg, bit, timeout, true));
+}
+
+bool
+xhci_debug_enable(struct xhci_debug_softc *sc)
+{
+	bool ret;
+
+	xhci_debug_softc_fixup(sc);
+	xhci_debug_update_state(sc);
+	ret = true;
+	if (sc->sc_state == XHCI_DCPORT_ST_OFF) {
+		ret = xhci_debug_set_regbit(sc, XHCI_DCCTRL, XHCI_DCCTRL_DCE,
+		    1);
+		xhci_debug_update_state(sc);
+		if (ret == false)
+			DEBUG_PRINTF("%s: setting XHCI_DCCTRL_DCE failed\n",
+			    __func__);
+	}
+	/* If success, check the cable. */
+	return ((ret == true) ? (xhci_debug_wait_connection(sc, 1)) : ret);
+}
+
+static bool
+xhci_debug_wait_connection(struct xhci_debug_softc *sc, uint32_t timeout)
+{
+	bool ret;
+
+	xhci_debug_update_state(sc);
+	if (sc->sc_state == XHCI_DCPORT_ST_DISCONNECTED) {
+		ret = xhci_debug_set_regbit(sc, XHCI_DCPORTSC,
+		    XHCI_DCPORTSC_PED, 1000);	/* XXX: 1 was not enough */
+		xhci_debug_update_state(sc);
+		if (ret == false) {
+			DEBUG_PRINTF("%s: setting XHCI_DCPORTSC_PED failed\n",
+			    __func__);
+			return (ret); 
+		}
+	}
+	DEBUG_PRINTF("%s: Wait DCR\n", __func__);
+	timeout = 10000;
+	xhci_debug_update_state(sc);
+	while (sc->sc_state != XHCI_DCPORT_ST_CONFIGURED) {
+		DEBUG_PRINTF("Insert a debug cable: PR=%d, PLS=%d, DCR=0\n",
+		    ((_XREAD4(sc, dbc, XHCI_DCPORTSC) & XHCI_PS_PR) != 0),
+		    XHCI_PS_PLS_GET(_XREAD4(sc, dbc, XHCI_DCPORTSC)));
+		delay(500);
+		if (timeout-- == 0) {
+			DEBUG_PRINTF("Insert a debug cable: timed out\n");
+			break;
+		}
+		xhci_debug_update_state(sc);
+	}
+	if (timeout == 0)
+		return (false);
+
+	DEBUG_PRINTF("Debug Cable Inserted: PR=%d, PLS=%d, DCR=1\n",
+	    ((_XREAD4(sc, dbc, XHCI_DCPORTSC) & XHCI_PS_PR) != 0),
+	    XHCI_PS_PLS_GET(_XREAD4(sc, dbc, XHCI_DCPORTSC)));
+	return (true);
+}
+
+void
+xhci_debug_disable(struct xhci_debug_softc *sc)
+{
+	bool ret;
+
+	xhci_debug_reset_regbit(sc, XHCI_DCPORTSC, XHCI_DCPORTSC_PED, 0);
+	ret = xhci_debug_reset_regbit(sc, XHCI_DCCTRL, XHCI_DCCTRL_DCE, 1000);
+	if (ret == false)
+		DEBUG_PRINTF("%s: clearing XHCI_DCCTRL_DCE failed\n", __func__);
+	xhci_debug_update_state(sc);
+}
+
+int
+xhci_debug_init_ring(struct xhci_debug_softc *sc)
+{
+	uint64_t erdp, out, in;
+	uint32_t temp;
+
+	if (sc->sc_dbc_off == 0) {
+		DEBUG_PRINTF("%s: register is empty\n", __func__);
+		return (-1);
+	}
+	/* Create an event ring. */
+	xhci_debug_ring_init(sc, &sc->udb_ering, 0, XHCI_DCDB_INVAL);
+	erdp = sc->udb_ering.paddr;
+	memset(sc->udb_erst, 0, sizeof(*sc->udb_erst));
+	sc->udb_erst->qwEvrsTablePtr = htole64(erdp);
+	sc->udb_erst->dwEvrsTableSize = htole32(UDB_TRB_RING_LEN);
+	DEBUG_PRINTF("%s: ERDP=0x%016llx\n", __func__, (unsigned long long)erdp);
+
+	/* Create an output ring. */
+	xhci_debug_ring_init(sc, &sc->udb_oring, 1, XHCI_DCDB_OUT);
+	out = sc->udb_oring.paddr;
+
+	/* Create an input ring. */
+	xhci_debug_ring_init(sc, &sc->udb_iring, 1, XHCI_DCDB_IN);
+	in = sc->udb_iring.paddr;
+
+	/* Initialize DbC context. */
+	memset(sc->udb_ctx, 0, sizeof(*sc->udb_ctx));
+	xhci_debug_init_strings(sc, sc->udb_ctx->info);
+
+	/* Initialize endpoints. */ 
+	temp = _XREAD4(sc, dbc, XHCI_DCCTRL);
+	xhci_debug_init_ep(&sc->udb_ctx->ep_out,
+	    (uint64_t)XHCI_DCCTRL_MBS_GET(le32toh(temp)), EP_BULK_OUT, out);
+	xhci_debug_init_ep(&sc->udb_ctx->ep_in,
+	    (uint64_t)XHCI_DCCTRL_MBS_GET(le32toh(temp)), EP_BULK_IN, in);
+
+	/* Configure register values. */
+	_XWRITE4(sc, dbc, XHCI_DCERSTSZ, htole32(1));
+	_XWRITE44LH(sc, dbc, XHCI_DCERSTBA, htole64(sc->udb_erst_paddr));
+	_XWRITE44LH(sc, dbc, XHCI_DCERDP, htole64(erdp));
+	_XWRITE44LH(sc, dbc, XHCI_DCCP, htole64(sc->udb_ctx_paddr));
+	_XWRITE4(sc, dbc, XHCI_DCDDI1, htole32((DC_VENDOR   << 16) | DC_PROTOCOL));
+	_XWRITE4(sc, dbc, XHCI_DCDDI2, htole32((DC_REVISION << 16) | DC_PRODUCT));
+	flush_range(sc->udb_ctx, sizeof(*sc->udb_ctx));
+	flush_range(sc->udb_erst, sizeof(*sc->udb_erst));
+	flush_range(sc->udb_ering.trb, UDB_TRB_RING_BYTES);
+	flush_range(sc->udb_oring.trb, UDB_TRB_RING_BYTES);
+	flush_range(sc->udb_iring.trb, UDB_TRB_RING_BYTES);
+	flush_range(sc->udb_oring.work.buf, UDB_WORK_RING_BYTES);
+	flush_range(sc->udb_iring.work.buf, UDB_WORK_RING_BYTES);
+
+	return (0);
+}
+
+int
+xhci_debug_probe(struct xhci_debug_softc *sc)
+{
+	uint32_t hccp1;
+	uint32_t eec;
+	uint32_t eecp;
+
+	if (sc == NULL)
+		return (0);
+#ifndef	_KERNEL
+	xhci_debug_pci_mmio_init(sc);
+#endif
+	hccp1 = _XREAD4(sc, capa, XHCI_HCSPARAMS0);
+
+	if (XHCI_HCS0_XECP(hccp1) == 0)
+		goto notfound;
+
+	eec = -1;	/* XXX */
+	for (eecp = XHCI_HCS0_XECP(hccp1) << 2;
+	     eecp != 0 && XHCI_XECP_NEXT(eec) != 0;
+	     eecp += XHCI_XECP_NEXT(eec) << 2) {
+		eec = _XREAD4(sc, capa, eecp);
+
+		if (XHCI_XECP_ID(eec) != XHCI_ID_USB_DEBUG) {
+#if 0
+			DEBUG_PRINTF("%s: looking for %02x\n",
+			    __func__, XHCI_XECP_ID(eec));
+#endif
+			continue;
+		}
+	}
+	if (XHCI_XECP_ID(eec) != XHCI_ID_USB_DEBUG)
+		goto notfound;
+	DEBUG_PRINTF("%s: DBC_ID was found at %08x\n", __func__, eecp);
+	sc->sc_dbc_off = eecp;
+	return (1);
+
+notfound:
+	DEBUG_PRINTF("%s: DBC_ID was not found\n", __func__);
+	return (0);
+}
+
+/*
+ * The hw.usb.xhci.dbc mibs are used to pass physical addresses
+ * from the loader to the kernel.  This function simply relies on
+ * the direct mapping at this moment and works only on the platforms
+ * supporting it.
+ */
+static void
+xhci_debug_softc_fixup(struct xhci_debug_softc *sc)
+{
+	if (sc->sc_fixup_done)
+		return;
+#if _KERNEL
+	quad_t xhci_dbc_iring_work_addr;
+	quad_t xhci_dbc_iring_work_len;
+	quad_t xhci_dbc_oring_work_addr;
+	quad_t xhci_dbc_oring_work_len;
+	quad_t xhci_dbc_softc_addr;
+	quad_t xhci_dbc_softc_len;
+	char buf[256];
+	quad_t addr, len;
+	struct trb_addrs {
+		const char *key;
+		struct xhci_debug_ring *ringp;
+	} parray[] = {
+		{ "hw.usb.xhci.dbc.ering", &sc->udb_ering },
+		{ "hw.usb.xhci.dbc.oring", &sc->udb_oring },
+		{ "hw.usb.xhci.dbc.iring", &sc->udb_iring },
+		{ NULL, NULL }
+	};
+	struct trb_addrs *p;
+
+	KASSERT(PMAP_HAS_DMAP, ("direct-map required"));
+
+	getenv_quad("hw.usb.xhci.dbc.softc.paddr",
+	    &xhci_dbc_softc_addr);
+	getenv_quad("hw.usb.xhci.dbc.softc.len",
+	    &xhci_dbc_softc_len);
+	/* XXX: pmap_map() on amd64 uses only start address. */
+	sc->sc_udb = (struct xhci_debug_softc *)
+	    pmap_map(NULL, (vm_paddr_t)xhci_dbc_softc_addr, 0, 0);
+
+	for (p = &parray[0]; p->key != NULL; p++) {
+
+		snprintf(buf, sizeof(buf), "%s.paddr", p->key);
+		buf[sizeof(buf) - 1] = '\0';
+		getenv_quad(buf, &addr);
+		p->ringp->paddr = (uintptr_t)addr;
+		p->ringp->trb =
+		    (struct xhci_trb *)pmap_map(NULL, p->ringp->paddr, 0, 0);
+
+		/* XXX not used right now */
+		snprintf(buf, sizeof(buf), "%s.len", p->key);
+		buf[sizeof(buf) - 1] = '\0';
+		getenv_quad(buf, &len);
+	}
+
+	getenv_quad("hw.usb.xhci.dbc.iring.work.paddr",
+	    &xhci_dbc_iring_work_addr);
+	getenv_quad("hw.usb.xhci.dbc.iring.work.len",
+	    &xhci_dbc_iring_work_len);
+	/* VA for work ring */
+	/* XXX: pmap_map() on amd64 uses only start address. */
+	sc->udb_iring.work.paddr = (uintptr_t)
+	    pmap_map(NULL, (vm_paddr_t)xhci_dbc_iring_work_addr, 0, 0);
+	sc->udb_iring.work.buf = (char *)
+	    pmap_map(NULL, (vm_paddr_t)xhci_dbc_iring_work_addr, 0, 0);
+
+	getenv_quad("hw.usb.xhci.dbc.oring.work.paddr",
+	    &xhci_dbc_oring_work_addr);
+	getenv_quad("hw.usb.xhci.dbc.oring.work.len",
+	    &xhci_dbc_oring_work_len);
+	/* VA for work ring */
+	/* XXX: pmap_map() on amd64 uses only start address. */
+	sc->udb_oring.work.paddr = (uintptr_t)
+	    pmap_map(NULL, (vm_paddr_t)xhci_dbc_oring_work_addr, 0, 0);
+	sc->udb_oring.work.buf = (char *)
+	    pmap_map(NULL, (vm_paddr_t)xhci_dbc_oring_work_addr, 0, 0);
+
+	sc->udb_ering.enq = sc->sc_udb->udb_ering.enq;
+	sc->udb_ering.deq = sc->sc_udb->udb_ering.deq;
+	sc->udb_ering.cyc = sc->sc_udb->udb_ering.cyc;
+	sc->udb_ering.doorbell = sc->sc_udb->udb_ering.doorbell;
+
+	sc->udb_iring.enq = sc->sc_udb->udb_iring.enq;
+	sc->udb_iring.deq = sc->sc_udb->udb_iring.deq;
+	sc->udb_iring.cyc = sc->sc_udb->udb_iring.cyc;
+	sc->udb_iring.doorbell = sc->sc_udb->udb_iring.doorbell;
+	sc->udb_iring.work.enq = sc->sc_udb->udb_iring.work.enq;
+	sc->udb_iring.work.deq = sc->sc_udb->udb_iring.work.deq;
+
+	sc->udb_oring.enq = sc->sc_udb->udb_oring.enq;
+	sc->udb_oring.deq = sc->sc_udb->udb_oring.deq;
+	sc->udb_oring.cyc = sc->sc_udb->udb_oring.cyc;
+	sc->udb_oring.doorbell = sc->sc_udb->udb_oring.doorbell;
+	sc->udb_oring.work.enq = sc->sc_udb->udb_oring.work.enq;
+	sc->udb_oring.work.deq = sc->sc_udb->udb_oring.work.deq;
+
+	sc->dma_allocated = sc->sc_udb->dma_allocated;
+	sc->sc_init = sc->sc_udb->sc_init;
+
+	/* XXX: DMA mappings must be configured... */
+#if 0
+	{
+		/* incomplete core fragment */
+
+		struct usb_page_cache *pc;
+		struct usb_page *pg;
+		int ret;
+
+		pc = &sc->udb_ering.ring_pc;
+		pg = &sc->udb_ering.ring_pg;
+
+		pc->tag_parent = sc->sc_xhci->sc_bus.dma_parent_tag;
+		if (usb_pc_dmamap_create(pc, UDB_TRB_RING_BYTES) != 0)
+			device_printf(sc->sc_xhci->sc_bus.parent,
+			    "usb_pc_dmamap_create() failed\n");
+		pc->buffer = sc->udb_ering.trb;
+		pc->page_start = pg;
+		if (usb_pc_load_mem(pc, UDB_TRB_RING_BYTES, 1) != 0)
+			device_printf(sc->sc_xhci->sc_bus.parent,
+			    "usb_pc_load_mem() failed\n");
+	}
+#endif
+#endif
+	sc->sc_fixup_done = true;
+}
+
+static void
+xhci_debug_ring_init(struct xhci_debug_softc *sc,
+    struct xhci_debug_ring *ring, int producer, uint32_t doorbell)
+{
+	memset(ring->trb, 0, UDB_TRB_RING_BYTES);
+	memset(ring->work.buf, 0, UDB_WORK_RING_BYTES);
+
+	ring->enq = 0;
+	ring->deq = 0;
+	ring->cyc = 1;
+	ring->doorbell = doorbell;
+	ring->work.enq = 0;
+	ring->work.deq = 0;
+
+	/* Place a link TRB at the tail if producer == 1. */
+	if (producer) {
+		struct xhci_trb *trb = &ring->trb[UDB_TRB_RING_LAST];
+
+		assert(htole32(XHCI_TRB_3_TYPE_SET(XHCI_TRB_TYPE_LINK) | XHCI_TRB_3_TC_BIT) == (XHCI_TRB_3_TYPE_SET(XHCI_TRB_TYPE_LINK) | XHCI_TRB_3_TC_BIT));
+
+		/* Fields for link TRBs (section 6.4.4.1) */
+		*trb = (struct xhci_trb){
+		    .qwTrb0 = htole64(ring->paddr),
+		    .dwTrb3 = htole32(
+			XHCI_TRB_3_TYPE_SET(XHCI_TRB_TYPE_LINK) |
+			XHCI_TRB_3_TC_BIT
+		    )
+		};
+	}
+}
+
+struct usb_strdesc {
+	uint8_t bLength;
+	uint8_t bDescriptorType;
+	uint8_t chars[62];	/* UTF-16LE */
+};
+#define USB_DESC_TYPE_STRING	3
+
+/* Initialize the DbC info with USB string descriptor addresses. */
+void
+xhci_debug_init_strings(struct xhci_debug_softc *sc, uint32_t *info)
+{
+	struct usb_strdesc udb_strdesc[] = {
+		{
+		  .bLength = 2 + 4,
+		  .bDescriptorType = USB_DESC_TYPE_STRING,
+		  .chars = { 9, 0, 4, 0 },	/* 0x0409 = English */
+		},
+		{
+		  .bLength = 2 + 36,
+		  .bDescriptorType = USB_DESC_TYPE_STRING,
+		  .chars = {
+		    'F', 0, 'r', 0, 'e', 0, 'e', 0, 'B', 0, 'S', 0, 'D', 0,
+		    ' ', 0,
+		    'F', 0, 'o', 0, 'u', 0, 'n', 0, 'd', 0, 'a', 0, 't', 0,
+		    'i', 0, 'o', 0, 'n', 0,
+		  }
+		},
+		{
+		  .bLength = 2 + 50,
+		  .bDescriptorType = USB_DESC_TYPE_STRING,
+		  .chars = {
+		    'F', 0, 'r', 0, 'e', 0, 'e', 0, 'B', 0, 'S', 0, 'D', 0,
+		    ' ', 0,
+		    'U', 0, 'S', 0, 'B', 0, ' ', 0, 'D', 0, 'b', 0, 'C', 0,
+		    '.', 0, 'G', 0, 'P', 0, ' ', 0, 'D', 0, 'e', 0, 'v', 0,
+		    'i', 0, 'c', 0, 'e', 0,
+		  }
+		},
+		{
+		  .bLength = 2 + 2,
+		  .bDescriptorType = USB_DESC_TYPE_STRING,
+		  .chars = { '0', 0 }
+		}
+	};
+	uint64_t *sda;
+
+	/* udb_str is 1 page buffer longer than sizeof(udb_strdesc) */
+	memcpy(sc->udb_str, udb_strdesc, sizeof(udb_strdesc));
+
+	sda = (uint64_t *)(void *)&info[0];
+	sda[0] = sc->udb_str_paddr;
+	sda[1] = sda[0] + 64;
+	sda[2] = sda[0] + 64 + 64;
+	sda[3] = sda[0] + 64 + 64 + 64;
+	info[8] = (4 << 24) | (52 << 16) | (38 << 8) | 6;
+}
+
+static void
+xhci_debug_ring_doorbell(struct xhci_debug_softc *sc, uint32_t target)
+{
+	uint32_t doorbell;
+
+	/* The other bits in DCDB are RsvdP. */
+	/* XXX: the spec has contradiction between Figure 7-9 and Table 7-18. */
+	doorbell = _XREAD4(sc, dbc, XHCI_DCDB) & ~XHCI_DCDB_MASK;
+
+	DEBUG_V_PRINTF("%s: doorbell = %04x\n", __func__, doorbell);
+	DEBUG_V_PRINTF("%s: doorbell = %04x (le32toh)\n", __func__,
+	    le32toh(doorbell));
+	DEBUG_V_PRINTF("%s: target = %04x\n", __func__, target);
+
+	doorbell |= target;
+
+	DEBUG_V_PRINTF("%s: doorbell = %04x (updated)\n", __func__, doorbell);
+	DEBUG_V_PRINTF("%s: doorbell = %04x (updated, le32toh)\n", __func__,
+	    le32toh(doorbell));
+	DEBUG_PRINTF("%s: doorbell = %04x\n", __func__, doorbell);
+	_XWRITE4(sc, dbc, XHCI_DCDB, doorbell);
+}
+
+ssize_t
+xhci_debug_bulk_transfer(struct xhci_debug_softc *sc,
+    struct xhci_debug_ring *ring)
+{
+	uint32_t temp;
+	int error;
+
+	/* XXX: running status check? */
+	xhci_debug_update_state(sc);
+
+	/* configure-exit */
+	temp = _XREAD4(sc, dbc, XHCI_DCCTRL);
+	if (XHCI_DCCTRL_DRC_GET(le32toh(temp)) != 0)
+		_XWRITE4(sc, dbc, XHCI_DCCTRL, temp);
+
+	xhci_debug_event_dequeue(sc);
+	xhci_debug_update_state(sc);
+
+	if (XHCI_DEBUG_RING_FULL(ring))	/* TRB queue is full */
+		return (-1);
+
+	error = (ring->doorbell == XHCI_DCDB_IN)
+	    ? trb_rx_enqueue(ring)
+	    : trb_tx_enqueue(ring);
+
+	if (error == 0)
+		xhci_debug_ring_doorbell(sc, ring->doorbell);
+	xhci_debug_update_state(sc);
+
+	return (1);
+}
+
+static void
+xhci_debug_show_ring0(struct xhci_debug_ring *ring, const char *label)
+{
+	printf("%s: deq=%d, enq=%d(%llu), w.deq=%u, w.enq=%u(%llu), paddr=0x%016llx, w.paddr=0x%016llx\n",
+	    label, ring->deq, ring->enq, UDB_TRB_RING_LAST,
+	    ring->work.deq, ring->work.enq, UDB_WORK_RING_LAST,
+	    (unsigned long long)ring->paddr,
+	    (unsigned long long)ring->work.paddr);
+}
+
+static void
+xhci_debug_show_ring(struct xhci_debug_ring *ring, const char *label)
+{
+
+	DEBUG_PRINTF("%s: deq=%d, enq=%d(%llu), w.deq=%u, w.enq=%u(%llu), paddr=0x%016llx, w.paddr=0x%016llx\n",
+	    label, ring->deq, ring->enq, UDB_TRB_RING_LAST,
+	    ring->work.deq, ring->work.enq, UDB_WORK_RING_LAST,
+	    (unsigned long long)ring->paddr,
+	    (unsigned long long)ring->work.paddr);
+}
+
+/*
+ * Initializes the endpoint as specified in sections 7.6.3.2 and 7.6.9.2.
+ * Each endpoint is Bulk, so the MaxPStreams, LSA, HID, CErr, FE,
+ * Interval, Mult, and Max ESIT Payload fields are all 0.   
+ *
+ * Max packet size: 1024
+ * Max burst size: debug mbs (from db_reg->ctrl register)
+ * EP type: 2 for OUT bulk, 6 for IN bulk   
+ * TR dequeue ptr: physical base address of transfer ring
+ * Avg TRB length: software defined (see 4.14.1.1 for suggested defaults, 3kB)
+ */
+static void
+xhci_debug_init_ep(struct xhci_endp_ctx64 *ep64, uint64_t mbs,
+    uint32_t type, uint64_t ring_paddr)
+{
+	struct xhci_endp_ctx *ep;
+
+	if (ep64 == NULL)
+		return;
+	ep = &ep64->ctx;
+	memset(ep64, 0, sizeof(*ep64));
+
+	ep->dwEpCtx1 = htole32(
+	    XHCI_EPCTX_1_MAXP_SIZE_SET(1024) |
+	    XHCI_EPCTX_1_MAXB_SET((uint32_t)mbs) |
+	    XHCI_EPCTX_1_EPTYPE_SET(type));
+	ep->qwEpCtx2 = htole64(
+	    (ring_paddr & XHCI_EPCTX_2_TR_DQ_PTR_MASK) |
+	    XHCI_EPCTX_2_DCS_SET(1));
+	ep->dwEpCtx4 = htole32(
+	    XHCI_EPCTX_4_AVG_TRB_LEN_SET(1024 * 3));
+}
+
+bool
+xhci_debug_event_ready(struct xhci_debug_softc *sc)
+{
+	struct xhci_debug_ring *er = &sc->udb_ering;
+	struct xhci_trb *event = &er->trb[er->deq];
+	uint32_t dwTrb3;
+	uint32_t cyc;
+	uint32_t deq;
+
+	/* XXX: Should DCST be used to check the event queue? */
+
+	cyc = er->cyc;
+	deq = er->deq;
+	LFENCE();
+	dwTrb3 = le32toh(event->dwTrb3);
+
+	while ((dwTrb3 & XHCI_TRB_3_CYCLE_BIT) == cyc) {
+		cyc = (deq == UDB_TRB_RING_LAST)
+		    ? cyc ^ 1
+		    : cyc;
+		deq = (deq + 1) & UDB_TRB_RING_OFFSET_MASK;
+		event = &er->trb[deq];
+		LFENCE();
+		dwTrb3 = le32toh(event->dwTrb3);
+	}
+	if (er->deq < deq)
+		er->enq = deq;
+	else if (er->deq > deq)
+		er->enq = deq + (UDB_TRB_RING_LAST - er->deq);
+
+	return ((dwTrb3 & XHCI_TRB_3_CYCLE_BIT) == er->cyc);
+}
+
+void
+xhci_debug_event_dequeue(struct xhci_debug_softc *sc)
+{
+	struct xhci_debug_ring *er = &sc->udb_ering;
+	struct xhci_debug_ring *ir = &sc->udb_iring;
+	struct xhci_debug_ring *or = &sc->udb_oring;
+	struct xhci_trb *event = &er->trb[er->deq];
+	struct xhci_trb *trb;
+	uint64_t erdp;
+	uint32_t temp;
+	uint64_t qwTrb0;
+	uint32_t dwTrb3;
+	uint32_t dwTrb2;
+	uint32_t ret;
+	uint32_t len;
+
+	sc->sc_polling_count++;
+
+	LFENCE();
+	qwTrb0 = le64toh(event->qwTrb0);
+	dwTrb2 = le32toh(event->dwTrb2);
+	dwTrb3 = le32toh(event->dwTrb3);
+	while ((dwTrb3 & XHCI_TRB_3_CYCLE_BIT) == er->cyc) {
+		switch (XHCI_TRB_3_TYPE_GET(dwTrb3)) {
+		case XHCI_TRB_EVENT_TRANSFER:
+			/* EP ID is an index of context. */
+			DEBUG_PRINTF("%s: event transfer TRB: index=%d, epno=%d\n",
+			    __func__,
+			    XHCI_TRB_3_SLOT_GET(dwTrb3),
+			    XHCI_TRB_3_EP_GET(dwTrb3));
+
+			ret = XHCI_TRB_2_ERROR_GET(dwTrb2);
+
+			if (ret != XHCI_TRB_ERROR_SUCCESS &&
+			    ret != XHCI_TRB_ERROR_SHORT_PKT) {
+				DEBUG_PRINTF("transfer error (%u)", ret);
+				switch (ret) {
+				case XHCI_TRB_ERROR_RING_UNDERRUN:
+					DEBUG_PRINTF(": RING_UNDERRUN\n");
+					break;
+				case XHCI_TRB_ERROR_RING_OVERRUN:
+					DEBUG_PRINTF(": RING_OVERRUN\n");
+					break;
+				case XHCI_TRB_ERROR_TRB:
+					DEBUG_PRINTF(": TRB\n");
+					break;
+				case XHCI_TRB_ERROR_STALL:
+					DEBUG_PRINTF(": STALL\n");
+					break;
+				default:
+					DEBUG_PRINTF("\n");
+				}
+        		}
+			if (XHCI_TRB_3_EP_GET(dwTrb3) == XHCI_DC_EPID_OUT ||
+			    XHCI_TRB_3_EP_GET(dwTrb3) == XHCI_DC_EPID_OUT_INTEL) {
+				if ((dwTrb3 & XHCI_TRB_3_ISP_BIT) != 0) {
+					/* Event Data */
+					break;
+				}
+				/* Update the dequeue pointer using ER. */
+				xhci_debug_show_ring(or, "oring0");
+// XXX: (qwTrb0 & MASK) >> 4 (16 bytes)
+				or->deq = qwTrb0 - (uint64_t)or->paddr;
+				or->deq /= sizeof(struct xhci_trb);
+				trb = &or->trb[or->deq];
+
+				xhci_debug_show_ring(or, "oring1");
+			} else if (XHCI_TRB_3_EP_GET(dwTrb3) == XHCI_DC_EPID_IN ||
+			    XHCI_TRB_3_EP_GET(dwTrb3) == XHCI_DC_EPID_IN_INTEL) {
+				if ((dwTrb3 & XHCI_TRB_3_ISP_BIT) != 0) {
+					/* Event Data */
+					break;
+				}
+				/* Update the dequeue pointer using ER. */
+				xhci_debug_show_ring(ir, "iring0");
+				ir->deq = qwTrb0 - (uint64_t)ir->paddr;
+				ir->deq /= sizeof(struct xhci_trb);
+				trb = &ir->trb[ir->deq];
+
+				/* An event not associated with iring */
+				if (!XHCI_DEBUG_RING_EMPTY(ir))
+					ir->deq = (ir->deq + 1) &
+					    UDB_TRB_RING_OFFSET_MASK;
+
+				assert(trb->dwTrb2 == le32toh(trb->dwTrb2));
+				len = XHCI_TRB_2_BYTES_GET(le32toh(trb->dwTrb2))
+				    - XHCI_TRB_2_BYTES_GET(dwTrb2);
+				DEBUG_PRINTF("recv transfer length = %u - %u = %u\n",
+				    XHCI_TRB_2_BYTES_GET(le32toh(trb->dwTrb2)),
+				    XHCI_TRB_2_BYTES_GET(dwTrb2),
+				    len);
+				DEBUG_PRINTF("addr: paddr=%lu, qwTrb0=%lu,"
+				    "masked addr=%lu, "
+				    "calculated index=%lu\n",
+				    (uint64_t)ir->paddr,
+				    qwTrb0,
+				    (qwTrb0 & (uint64_t)UDB_TRB_RING_MASK) >> 4,
+				    ((qwTrb0 - (uint64_t)ir->paddr) / sizeof(struct xhci_trb))
+				);
+
+				/* Advance the enq of work q */
+				flush_range(&sc->udb_iring.work.buf[ir->work.enq], len);
+				ir->work.enq += len;
+
+				xhci_debug_show_ring(ir, "iring1");
+			} else {
+				DEBUG_PRINTF("%s: unknown EP ID=%d\n", __func__,
+				    XHCI_TRB_3_EP_GET(dwTrb3));
+			}
+			break;
+		case XHCI_TRB_EVENT_PORT_STS_CHANGE:
+			temp = _XREAD4(sc, dbc, XHCI_DCPORTSC);
+			assert(temp == le32toh(temp));
+			if (XHCI_DCPORTSC_CSC_GET(le32toh(temp))) {
+				DEBUG_PRINTF("cable status changed\n");
+				assert(temp == le32toh(temp));
+				if (XHCI_DCPORTSC_CCS_GET(le32toh(temp)) == 0)
+					DEBUG_PRINTF("cable unplugged\n");
+			}
+			assert(XHCI_DCPORTSC_ACK_MASK == htole32(XHCI_DCPORTSC_ACK_MASK));
+			_XWRITE4(sc, dbc, XHCI_DCPORTSC,
+			    temp & htole32(XHCI_DCPORTSC_ACK_MASK));
+			break;
+		default:
+			break;
+		}
+		er->cyc = (er->deq == UDB_TRB_RING_LAST)
+		    ? er->cyc ^ 1
+		    : er->cyc;
+		er->deq = (er->deq + 1) & UDB_TRB_RING_OFFSET_MASK;
+		event = &er->trb[er->deq];
+		LFENCE();
+		qwTrb0 = le64toh(event->qwTrb0);
+		dwTrb2 = le32toh(event->dwTrb2);
+		dwTrb3 = le32toh(event->dwTrb3);
+	}
+	erdp = _XREAD44LH(sc, dbc, XHCI_DCERDP);
+	erdp &= ~UDB_TRB_RING_MASK;
+	erdp |= er->deq * sizeof(struct xhci_trb);
+	_XWRITE44LH(sc, dbc, XHCI_DCERDP, erdp);
+}
+
+static int
+trb_rx_enqueue(struct xhci_debug_ring *ring)
+{
+	struct xhci_debug_work_ring *work;
+	uint64_t addr;
+	uint64_t len;
+
+	if (ring == NULL)
+		return (-1);
+
+	work = &ring->work;
+	if (work == NULL)
+		return (-1);
+	/* Skip if there are pending TRB */
+	if (!XHCI_DEBUG_RING_EMPTY(ring))
+		return (-1);
+	/* Skip if there are received data */
+	if (!UDB_WORK_RING_EMPTY(ring))
+		return (-1);
+
+	addr = work->paddr + work->enq;
+	len = (work->enq < work->deq) ? work->deq : UDB_WORK_RING_LEN;
+	len -= work->enq;
+	trb_push(ring, addr, len);
+	return (0);
+}
+
+static int
+trb_tx_enqueue(struct xhci_debug_ring *ring)
+{
+	struct xhci_debug_work_ring *work;
+	uint64_t addr;
+	uint64_t len;
+
+	if (ring == NULL)
+		return (-1);
+
+	work = &ring->work;
+	if (work == NULL)
+		return (-1);
+
+	if (UDB_WORK_RING_EMPTY(ring)) {
+		trb_push(ring, 0, 0);
+	} else if (work->deq < work->enq) {
+		addr = work->paddr + work->deq;
+		len = work->enq - work->deq;
+		trb_push(ring, addr, len);
+
+		work->deq = work->enq;
+	} else {
+		addr = work->paddr + work->deq;
+		len = UDB_WORK_RING_LEN - work->deq;
+		trb_push(ring, addr, len);
+
+		work->deq = 0;
+
+		if (0 < work->enq && !XHCI_DEBUG_RING_FULL(ring)) {
+			addr = work->paddr;
+			len = work->enq;
+			trb_push(ring, addr, len);
+			work->deq = work->enq;
+		}
+	}
+	return (0);
+}
+
+#if 0
+static struct xhci_trb *
+trb_lookup(struct xhci_debug_ring *ring, uint64_t addr, int *idx)
+{
+	int i;
+
+	*idx = 0;
+	for (i = 0; i < UDB_TRB_RING_LEN; i++)
+		if (addr == ring->paddr + sizeof(*ring->trb) * i) {
+			*idx = i;
+			break;
+		}
+
+	return ((i == UDB_TRB_RING_LEN) ? NULL : &ring->trb[i]);
+}
+#endif
+
+static void
+trb_push(struct xhci_debug_ring *ring, uint64_t addr, uint64_t len)
+{
+	struct xhci_trb trb;
+
+	if (ring->enq == UDB_TRB_RING_LAST) {
+		/*
+		 * If the ring->enq points the tail of the ring,
+		 * put a link TRB there and wrap-around the enq pointer.
+		 */
+		struct xhci_trb *link = &ring->trb[ring->enq];
+
+		link->dwTrb3 &= ~htole32(XHCI_TRB_3_CYCLE_BIT);
+		link->dwTrb3 |= htole32(ring->cyc);
+
+		ring->enq = 0;
+		ring->cyc ^= 1;
+	}
+	/* Clearing the structure is required. */
+	memset(&trb, 0, sizeof(trb));
+	trb = (struct xhci_trb){
+	    .qwTrb0 = htole64(addr),
+	    .dwTrb2 = htole32(
+		XHCI_TRB_2_BYTES_SET(le32toh(trb.dwTrb2) | (uint32_t)len)
+	    ),
+	    .dwTrb3 = htole32(
+		XHCI_TRB_3_TYPE_SET(XHCI_TRB_TYPE_NORMAL)
+		| ring->cyc | XHCI_TRB_3_IOC_BIT
+	    )
+	};
+	memcpy(&ring->trb[ring->enq], &trb, sizeof(ring->trb[0]));
+	flush_range(&ring->trb[ring->enq], sizeof(ring->trb[0]));
+	xhci_debug_show_ring(ring, "push0");
+	ring->enq = (ring->enq + 1 ) & UDB_TRB_RING_OFFSET_MASK;
+	xhci_debug_show_ring(ring, "push1");
+}
+
+int
+work_dequeue(struct xhci_debug_ring *ring)
+{
+	struct xhci_debug_work_ring *work;
+	int c;
+
+	c = -1;
+ 	work = &ring->work;
+	if (!UDB_WORK_RING_EMPTY(ring)) {
+		xhci_debug_show_ring(ring, "work_dequeue0");
+		c = (int)work->buf[work->deq];
+		work->deq = (work->deq + 1) & UDB_WORK_RING_OFFSET_MASK;
+		DEBUG_PRINTF("%s: [%c]\n", __func__, (char)c);
+		xhci_debug_show_ring(ring, "work_dequeue1");
+	}
+	return (c);
+}
+
+int64_t
+work_enqueue(struct xhci_debug_ring *ring, const char *buf, int64_t len)
+{
+	struct xhci_debug_work_ring *work;
+	int64_t i = 0;
+	uint32_t start;
+	uint32_t end = 0;
+
+	work = &ring->work;
+	start = work->enq;
+	while (!UDB_WORK_RING_FULL(ring) && i < len) {
+		work->buf[work->enq++] = buf[i++];
+		work->enq &= UDB_WORK_RING_OFFSET_MASK;
+	}
+	end = work->enq;
+
+	if (end > start)
+		flush_range(&work->buf[start], end - start);
+	else if (i > 0) {
+		flush_range(&work->buf[start], UDB_WORK_RING_LEN - start);
+		flush_range(&work->buf[0], end);
+	}
+	return (i);
+}
+
+#ifdef _KERNEL
+/* udbcons is the device node for USB DbC. */
+
+#define	UDBCONS_NAME	"udbcons"
+
+struct udbcons_priv;
+static int udbcons_ischar(struct udbcons_priv *);
+typedef void udbcons_putc_t(struct udbcons_priv *, int);
+typedef int udbcons_getc_t(struct udbcons_priv *);
+struct udbcons_ops {
+	udbcons_putc_t	*putc;
+	udbcons_getc_t	*getc;
+};
+struct udbcons_priv {
+	device_t			dev;	/* XHCI */
+	struct xhci_softc		*xhci;
+	const struct udbcons_ops	*ops;
+	struct callout			callout;
+	struct tty			*tp;
+	bool				opened;
+	int				polltime;
+	int				alt_break_state;
+};
+
+static struct udbcons_priv udbcons0;
+
+static SYSCTL_NODE(_hw_usb, OID_AUTO, dbc, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
+    "USB XHCI DbC");
+
+static int
+sysctl_udb_info(SYSCTL_HANDLER_ARGS)
+{
+	int error;
+	struct xhci_debug_softc *sc;
+	struct sbuf *sb;
+
+	if (udbcons0.xhci == NULL)
+		return (-1);
+	if ((sc = udbcons0.xhci->sc_udbc) == NULL)
+		return (-1);
+
+#define	DUMP_RING(label, ring) do { \
+	sbuf_printf(sb, \
+	    "  %s: deq=%d, enq=%d(%llu), w.deq=%u, w.enq=%u(%llu), paddr=0x%016llx, w.paddr=0x%016llx\n", \
+	    #label, (ring)->deq, (ring)->enq, UDB_TRB_RING_LAST, \
+	    (ring)->work.deq, (ring)->work.enq, UDB_WORK_RING_LAST, \
+	    (unsigned long long)(ring)->paddr, \
+	    (unsigned long long)(ring)->work.paddr); \
+	} while (0)
+
+	sb = sbuf_new_auto();
+	sbuf_printf(sb, "\n");
+	sbuf_printf(sb, "  ering ready = %s\n",
+	    xhci_debug_event_ready(sc) ? "YES" : "NO");
+	DUMP_RING(ering, &sc->udb_ering); 
+	DUMP_RING(iring, &sc->udb_iring); 
+	DUMP_RING(oring, &sc->udb_oring); 
+	sbuf_printf(sb, "  sc->dma_allocated = %d,\n", sc->dma_allocated);
+	sbuf_printf(sb, "  sc->sc_init = %d\n", sc->sc_init);
+	sbuf_printf(sb, "  sc->sc_state = %s(%02x)\n", strstate[sc->sc_state],
+	    sc->sc_state);
+	sbuf_printf(sb, "  sc->sc_polling_count = %lu\n", sc->sc_polling_count);
+
+	if (sbuf_finish(sb) != 0)
+		return (-1);
+	error = sysctl_handle_opaque(oidp, sbuf_data(sb), sbuf_len(sb), req);
+	sbuf_delete(sb);
+
+	return (error);
+}
+SYSCTL_PROC(_hw_usb_dbc, OID_AUTO, info,
+    CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE,
+    NULL, 0, sysctl_udb_info, "A", "DbC info"); 
+
+static int
+udbcons_getc(struct udbcons_priv *cons)
+{
+	struct xhci_softc *sc;
+	struct xhci_debug_softc *sc_udbc;
+	struct xhci_debug_ring *iring;
+
+	if (cons == NULL)
+		 return (-1);
+	if ((sc = cons->xhci) == NULL)
+		 return (-1);
+	if (sc->sc_dbc_off == 0)
+		 return (-1);
+	if ((sc_udbc = sc->sc_udbc) == NULL)
+		return (-1);
+
+	iring = &sc_udbc->udb_iring;
+	/* Use udbcons_ischar() to receive data */
+	return (udbcons_ischar(cons) ? work_dequeue(iring) : -1);
+}
+static int
+udbcons_ischar(struct udbcons_priv *cons)
+{
+	struct xhci_softc *sc;
+	struct xhci_debug_softc *sc_udbc;
+	struct xhci_debug_ring *iring;
+
+	if (cons == NULL)
+		 return (0);
+	if ((sc = cons->xhci) == NULL)
+		 return (0);
+	if (sc->sc_dbc_off == 0)
+		return (0);
+	if ((sc_udbc = sc->sc_udbc) == NULL)
+		return (0);
+
+	iring = &sc_udbc->udb_iring;
+	if (!UDB_WORK_RING_EMPTY(iring))
+		return (1);
+	xhci_debug_bulk_transfer(sc_udbc, iring);
+	xhci_debug_event_dequeue(sc_udbc);
+
+	return (!UDB_WORK_RING_EMPTY(iring));
+}
+static void
+udbcons_putc(struct udbcons_priv *cons, int ch)
+{
+	struct xhci_softc *sc;
+	struct xhci_debug_softc *sc_udbc;
+	struct xhci_debug_ring *oring;
+	char c;
+
+	if (cons == NULL)
+		 return;
+	if ((sc = cons->xhci) == NULL)
+		 return;
+	if (sc->sc_dbc_off == 0)
+		return;
+	if ((sc_udbc = sc->sc_udbc) == NULL)
+		return;
+
+	oring = &sc_udbc->udb_oring;
+	c = (char)(ch & 0xff);
+	if (!work_enqueue(oring, &c, sizeof(c)))
+		return;
+	xhci_debug_bulk_transfer(sc_udbc, oring);
+}
+static struct udbcons_ops udbcons0_ops = {
+	.putc = udbcons_putc,
+	.getc = udbcons_getc,
+};
+
+static tsw_outwakeup_t xhci_debug_tty_outwakeup;
+
+static struct ttydevsw xhci_debug_ttydevsw = {
+	.tsw_flags	= TF_NOPREFIX,
+	.tsw_outwakeup	= xhci_debug_tty_outwakeup,
+};
+
+static void xhci_debug_timeout(void *);
+
+int
+udbcons_init(struct xhci_softc *sc, device_t dev)
+{
+	struct udbcons_priv *cons;
+
+	device_printf(dev, "%s: enter\n", __func__);
+
+	cons = &udbcons0;
+	cons->dev = dev;
+	cons->xhci = sc;
+	cons->ops = &udbcons0_ops;
+
+	device_printf(dev, "call tty_alloc\n");
+	cons->tp = tty_alloc(&xhci_debug_ttydevsw, cons);
+	cons->polltime = 1;
+
+	device_printf(dev, "call tty_makedev\n");
+	tty_makedev(cons->tp, NULL, "%s", UDBCONS_NAME);
+	tty_init_console(cons->tp, 0);
+
+#if 1
+	device_printf(dev, "call callout_init\n");
+	callout_init(&cons->callout, 1);
+	callout_reset(&cons->callout, cons->polltime,
+	    xhci_debug_timeout, cons->tp);
+#endif
+
+	device_printf(dev, "%s: leave\n", __func__);
+
+	return (0);
+}
+
+/* xhci_debug is a console instance. */
+
+static cn_probe_t xhci_debug_cnprobe;
+static cn_init_t xhci_debug_cninit;
+static cn_term_t xhci_debug_cnterm;
+static cn_getc_t xhci_debug_cngetc;
+static cn_putc_t xhci_debug_cnputc;
+static cn_grab_t xhci_debug_cngrab;
+static cn_ungrab_t xhci_debug_cnungrab;
+
+const struct consdev_ops xhci_debug_cnops = {
+	.cn_probe	= xhci_debug_cnprobe,
+	.cn_init	= xhci_debug_cninit,
+	.cn_term	= xhci_debug_cnterm,
+	.cn_getc	= xhci_debug_cngetc,
+	.cn_putc	= xhci_debug_cnputc,
+	.cn_grab	= xhci_debug_cngrab,
+	.cn_ungrab	= xhci_debug_cnungrab,
+};
+
+CONSOLE_DRIVER(xhci_debug);
+
+#define MAX_BURST_LEN	1
+static void
+xhci_debug_tty_outwakeup(struct tty *tp)
+{
+	struct udbcons_priv *cons;
+	u_char buf[MAX_BURST_LEN];
+	int len;
+	int i;
+
+	cons = tty_softc(tp);
+	for (;;) {
+		len = ttydisc_getc(tp, buf, sizeof(buf));
+		if (len == 0)
+			break;
+		KASSERT(len == 1, ("tty error"));
+
+		for (i = 0; i < len; i++)
+			udbcons_putc(cons, buf[i]);
+	}
+}
+
+static void
+xhci_debug_timeout(void *v)
+{
+	struct udbcons_priv *cons;
+	struct tty *tp;
+	int ch;
+
+	tp = v;
+	cons = tty_softc(tp);
+
+	tty_lock(tp);
+	while ((ch = xhci_debug_cngetc(NULL)) != -1)
+		ttydisc_rint(tp, ch, 0);
+	ttydisc_rint_done(tp);
+	tty_unlock(tp);
+
+#if 0
+	if (cons->xhci != NULL)
+		device_printf(cons->dev, "%s called\n", __func__);
+#endif
+	callout_reset(&cons->callout, cons->polltime, xhci_debug_timeout, tp);
+}
+
+static void
+xhci_debug_cnprobe(struct consdev *cp)
+{
+
+	cp->cn_pri = (boothowto & RB_SERIAL) ? CN_REMOTE : CN_NORMAL;
+	sprintf(cp->cn_name, "%s", UDBCONS_NAME);
+}
+
+static void
+xhci_debug_cninit(struct consdev *cp)
+{
+}
+
+static void
+xhci_debug_cnterm(struct consdev *cp)
+{
+}
+
+/* empty */
+static void
+xhci_debug_cngrab(struct consdev *cp)
+{
+}
+
+/* empty */
+static void
+xhci_debug_cnungrab(struct consdev *cp)
+{
+}
+
+static int
+xhci_debug_cngetc(struct consdev *cp)
+{
+	int ch;
+
+	ch = udbcons_getc(&udbcons0);
+	if (ch > 0 && ch < 0xff) {
+#if defined(KDB)
+		kdb_alt_break(ch, &udbcons0.alt_break_state);
+#endif
+		return (ch);
+	}
+	return (-1);
+}
+
+static void
+xhci_debug_cnputc(struct consdev *cp, int ch)
+{
+
+	udbcons_putc(&udbcons0, ch);
+}
+#endif
diff --git a/sys/dev/usb/controller/xhci_dbc.h b/sys/dev/usb/controller/xhci_dbc.h
new file mode 100644
index 000000000000..47522576fcd7
--- /dev/null
+++ b/sys/dev/usb/controller/xhci_dbc.h
@@ -0,0 +1,191 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2019-2024 Hiroki Sato <hrs@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+/* DbC idVendor and idProduct */
+#define DC_VENDOR	0x1d6b	/* Linux Foundation */
+#define DC_PRODUCT	0x0011	/* Linux */ 
+#define DC_PROTOCOL	0x0000	/* GNU GDB = 1 */
+#define DC_REVISION	0x0010	/* 1.0 */
+
+#define	DC_STRING_MANUFACTURER	"The FreeBSD Foundation"
+#define	DC_STRING_PRODUCT	"FreeBSD USB DbC Serial"
+#define	DC_STRING_SERIAL	"12345678"
+
+#define XHCI_DCPORTSC_ACK_MASK	\
+	(XHCI_DCPORTSC_PED | \
+	 XHCI_DCPORTSC_CSC | XHCI_DCPORTSC_PRC | \
+	 XHCI_DCPORTSC_PLC | XHCI_DCPORTSC_CEC)
+
+/* DbC endpoint types */
+enum {
+	EP_BULK_OUT = 2,
+	EP_BULK_IN = 6
+};
+
+#define UDB_TRB_PER_PAGE (XHCI_PAGE_SIZE / sizeof(struct xhci_trb))
+
+/* Defines the size in bytes of TRB rings as 2^UDB_TRB_RING_ORDER * 4096 */
+#define UDB_TRB_RING_ORDER	4
+#define UDB_TRB_RING_LEN (UDB_TRB_PER_PAGE * (1ULL << UDB_TRB_RING_ORDER))
+#define UDB_TRB_RING_OFFSET_MASK (UDB_TRB_RING_LEN - 1U)
+#define UDB_TRB_RING_LAST	(UDB_TRB_RING_LEN - 1U)
+#define UDB_TRB_RING_BYTES	(UDB_TRB_RING_LEN * sizeof(struct xhci_trb))
+#define UDB_TRB_RING_MASK	(UDB_TRB_RING_BYTES - 1U)
+
+/* Defines the size in bytes of work rings as 2^WORK_RING_ORDER * 4096 */
+#define	UDB_WORK_RING_ORDER	3
+#define UDB_WORK_RING_LEN	(XHCI_PAGE_SIZE * (1ULL << UDB_WORK_RING_ORDER))
+#define UDB_WORK_RING_OFFSET_MASK	(UDB_WORK_RING_LEN - 1U)
+#define UDB_WORK_RING_LAST	(UDB_WORK_RING_LEN - 1U)
+#define	UDB_WORK_RING_BYTES	UDB_WORK_RING_LEN
+
+#define	UDB_WORK_RING_FULL(r) \
+	((((r)->work.enq + 1) & UDB_WORK_RING_OFFSET_MASK) == (r)->work.deq)
+#define	UDB_WORK_RING_EMPTY(r) \
+	((r)->work.enq == (r)->work.deq)
+#define	XHCI_DEBUG_RING_FULL(r) \
+	((((r)->enq + 1) & UDB_TRB_RING_OFFSET_MASK) == (r)->deq)
+#define	XHCI_DEBUG_RING_EMPTY(r) \
+	((r)->enq == (r)->deq)
+
+struct xhci_debug_reg {
+	uint32_t id;
+	uint32_t doorbell;
+	uint32_t erstsz;
+	uint32_t rsvdz;
+	uint64_t erstba;
+	uint64_t erdp;
+	uint32_t ctrl;
+	uint32_t st;
+	uint32_t portsc;
+	uint32_t rsvdp;
+	uint64_t cp;
+	uint32_t ddi1;
+	uint32_t ddi2;
+};
+
+struct xhci_debug_ctx {
+	uint32_t info[16];
+	struct xhci_endp_ctx64 ep_out;
+	struct xhci_endp_ctx64 ep_in;
+};
+
+struct xhci_debug_work_ring {
+	uint8_t *buf;
+	uint32_t enq;
+	uint32_t deq;
+	uint64_t paddr;
+};
+
+struct xhci_debug_ring {
+	struct xhci_trb *trb;	/* Array of TRBs */
+	uint64_t paddr;		/* base address of TRBs */
+	uint32_t enq;		/* The offset of the enqueue ptr */
+	uint32_t deq;		/* The offset of the dequeue ptr */
+	uint8_t cyc;		/* Cycle state toggled on each wrap-around */
+	uint32_t doorbell;	/* Doorbell target */
+
+	struct xhci_debug_work_ring work;
+};
+
+#ifndef _KERNEL
+#define DMA_DESC_CAP 16
+struct dma {
+	UINTN pages;
+	EFI_PHYSICAL_ADDRESS paddr;
+	VOID *cpu_addr;
+	VOID *mapping;
+};
+#endif
+
+/*
+ * This softc is used in kernel and loader.
+ */
+struct xhci_debug_softc {
+	struct xhci_debug_reg reg;
+	struct xhci_debug_ctx *udb_ctx;
+	uint64_t udb_ctx_paddr;
+	struct xhci_event_ring_seg *udb_erst;
+	uint64_t udb_erst_paddr;
+	struct xhci_debug_ring udb_ering;
+	struct xhci_debug_ring udb_oring;
+	struct xhci_debug_ring udb_iring;
+	char *udb_str;
+	uint64_t udb_str_paddr;
+	struct xhci_debug_softc *sc_udb;
+
+	uint32_t sc_state;
+	uint64_t sc_polling_count;
+	bool sc_init;
+	bool sc_fixup_done;
+	bool sc_open;
+	bool dma_allocated;
+	uint32_t sc_dbc_off;	/* in kernel, struct xhci_softc is used */
+
+#ifdef _KERNEL
+	struct xhci_softc	*sc_xhci;
+#else
+	/*
+	 * XXX: X{READ,WRITE}4 macro in a loader will use sc_mmio_phys
+	 * instead of bus_dma(9) at this moment.
+	 */
+	volatile uintptr_t sc_mmio_phys;
+	uint64_t sc_mmio_size;
+	void *sc_mmio;
+	uint32_t sc_capa_off;
+
+	EFI_HANDLE		sc_efi_hand;
+	EFI_PCI_IO_PROTOCOL	*sc_efi_pciio;
+	uint32_t sc_ca;
+	struct dma dma_desc[DMA_DESC_CAP];
+
+	struct console *sc_cons;
+#endif
+};
+
+int xhci_debug_probe(struct xhci_debug_softc *);
+bool xhci_debug_enable(struct xhci_debug_softc *);
+void xhci_debug_disable(struct xhci_debug_softc *);
+
+int xhci_debug_init_ring(struct xhci_debug_softc *);
+void xhci_debug_update_state(struct xhci_debug_softc *);
+
+ssize_t xhci_debug_bulk_transfer(struct xhci_debug_softc *,
+    struct xhci_debug_ring *);
+bool xhci_debug_event_ready(struct xhci_debug_softc *);
+void xhci_debug_event_dequeue(struct xhci_debug_softc *);
+
+int work_dequeue(struct xhci_debug_ring *);
+int64_t work_enqueue(struct xhci_debug_ring *, const char *, int64_t);
+
+void udb_dump_info(struct xhci_debug_softc *);
+void udb_info(void);
+
+#ifdef _KERNEL
+int udbcons_init(struct xhci_softc *, device_t);
+#endif
diff --git a/sys/dev/usb/controller/xhci_dbc_private.h b/sys/dev/usb/controller/xhci_dbc_private.h
new file mode 100644
index 000000000000..748fe8c910c0
--- /dev/null
+++ b/sys/dev/usb/controller/xhci_dbc_private.h
@@ -0,0 +1,78 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2019-2024 Hiroki Sato <hrs@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#if 0
+#define	DEBUG
+#endif
+#if 0
+#define	DEBUG_VERBOSE
+#endif
+
+#if defined(DEBUG)
+#define	DEBUG_PRINTF(...)       printf(__VA_ARGS__)
+#else
+#define	DEBUG_PRINTF(...)
+#endif
+#if defined(DEBUG) && defined(DEBUG_VERBOSE)
+#define	DEBUG_V_PRINTF(...)     printf(__VA_ARGS__)
+#else
+#define	DEBUG_V_PRINTF(...)
+#endif
+
+#define LFENCE(x)	__asm volatile("lfence" ::: "memory")
+
+#ifdef _KERNEL
+#define	_XREAD4(sc, what, a)		XREAD4((sc)->sc_xhci, what, a)
+#define	_XWRITE4(sc, what, a, x)	XWRITE4((sc)->sc_xhci, what, a, (x))
+#define	_XREAD44LH(sc, what, a)		XREAD44LH((sc)->sc_xhci, what, a)
+#define	_XWRITE44LH(sc, what, a, x) XWRITE44LH((sc)->sc_xhci, what, a, (x))
+/* sys/systm.h */
+#define	delay(x)	DELAY(x)
+
+#else
+
+/* Read/write macros for MMIO space */
+#define	_XREAD4(sc, what, a)	\
+	(*((volatile uint32_t *) \
+	 ((sc)->sc_mmio_phys + (a) + (sc)->sc_##what##_off)))
+#define	_XREAD44LH(sc, what, a)	\
+	((uint64_t)_XREAD4(sc, what, a##_LO) | \
+	     ((uint64_t)_XREAD4(sc, what, a##_HI) << 32)) 
+#define	_XWRITE4(sc, what, a, x) \
+	do { \
+		__asm volatile("sfence" ::: "memory"); \
+		*((volatile uint32_t *) \
+		 ((sc)->sc_mmio_phys + (a) + (sc)->sc_##what##_off)) = (x); \
+		__asm volatile("sfence" ::: "memory"); \
+	} while (0)
+#define	_XWRITE44LH(sc, what, a, x) \
+	do { \
+		_XWRITE4(sc, what, a##_LO, (uint32_t)((x) & 0xffffffff)); \
+		_XWRITE4(sc, what, a##_HI, (uint32_t)((x) >> 32)); \
+	} while (0)
+#endif
diff --git a/sys/dev/usb/controller/xhci_private.h b/sys/dev/usb/controller/xhci_private.h
new file mode 100644
index 000000000000..5ed7f019e42e
--- /dev/null
+++ b/sys/dev/usb/controller/xhci_private.h
@@ -0,0 +1,228 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2010-2022 Hans Petter Selasky
+ * Copyright (c) 2020-2024 Hiroki Sato <hrs@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _USB_XHCI_PRIVATE_H_
+#define	_USB_XHCI_PRIVATE_H_
+
+#define	XHCI_DEV_CTX_ADDR_ALIGN		64	/* bytes */
+#define	XHCI_DEV_CTX_ALIGN		64	/* bytes */
+#define	XHCI_INPUT_CTX_ALIGN		64	/* bytes */
+#define	XHCI_SLOT_CTX_ALIGN		32	/* bytes */
+#define	XHCI_ENDP_CTX_ALIGN		32	/* bytes */
+#define	XHCI_STREAM_CTX_ALIGN		16	/* bytes */
+#define	XHCI_TRANS_RING_SEG_ALIGN	16	/* bytes */
+#define	XHCI_CMD_RING_SEG_ALIGN		64	/* bytes */
+#define	XHCI_EVENT_RING_SEG_ALIGN	64	/* bytes */
+#define	XHCI_SCRATCH_BUF_ARRAY_ALIGN	64	/* bytes */
+#define	XHCI_SCRATCH_BUFFER_ALIGN	USB_PAGE_SIZE
+#define	XHCI_TRB_ALIGN			16	/* bytes */
+#define	XHCI_TD_ALIGN			64	/* bytes */
+#define	XHCI_PAGE_SIZE			4096	/* bytes */
+
+struct xhci_endp_ctx {
+	volatile uint32_t	dwEpCtx0;
+#define	XHCI_EPCTX_0_EPSTATE_SET(x)		((x) & 0x7)
+#define	XHCI_EPCTX_0_EPSTATE_GET(x)		((x) & 0x7)
+#define	XHCI_EPCTX_0_EPSTATE_DISABLED		0
+#define	XHCI_EPCTX_0_EPSTATE_RUNNING		1
+#define	XHCI_EPCTX_0_EPSTATE_HALTED		2
+#define	XHCI_EPCTX_0_EPSTATE_STOPPED		3
+#define	XHCI_EPCTX_0_EPSTATE_ERROR		4
+#define	XHCI_EPCTX_0_EPSTATE_RESERVED_5		5
+#define	XHCI_EPCTX_0_EPSTATE_RESERVED_6		6
+#define	XHCI_EPCTX_0_EPSTATE_RESERVED_7		7
+#define	XHCI_EPCTX_0_MULT_SET(x)		(((x) & 0x3) << 8)
+#define	XHCI_EPCTX_0_MULT_GET(x)		(((x) >> 8) & 0x3)
+#define	XHCI_EPCTX_0_MAXP_STREAMS_SET(x)	(((x) & 0x1F) << 10)
+#define	XHCI_EPCTX_0_MAXP_STREAMS_GET(x)	(((x) >> 10) & 0x1F)
+#define	XHCI_EPCTX_0_LSA_SET(x)			(((x) & 0x1) << 15)
+#define	XHCI_EPCTX_0_LSA_GET(x)			(((x) >> 15) & 0x1)
+#define	XHCI_EPCTX_0_IVAL_SET(x)		(((x) & 0xFF) << 16)
+#define	XHCI_EPCTX_0_IVAL_GET(x)		(((x) >> 16) & 0xFF)
+	volatile uint32_t	dwEpCtx1;
+#define	XHCI_EPCTX_1_CERR_SET(x)		(((x) & 0x3) << 1)
+#define	XHCI_EPCTX_1_CERR_GET(x)		(((x) >> 1) & 0x3)
+#define	XHCI_EPCTX_1_EPTYPE_SET(x)		(((x) & 0x7) << 3)
+#define	XHCI_EPCTX_1_EPTYPE_GET(x)		(((x) >> 3) & 0x7)
+#define	XHCI_EPCTX_1_HID_SET(x)			(((x) & 0x1) << 7)
+#define	XHCI_EPCTX_1_HID_GET(x)			(((x) >> 7) & 0x1)
+#define	XHCI_EPCTX_1_MAXB_SET(x)		(((x) & 0xFF) << 8)
+#define	XHCI_EPCTX_1_MAXB_GET(x)		(((x) >> 8) & 0xFF)
+#define	XHCI_EPCTX_1_MAXP_SIZE_SET(x)		(((x) & 0xFFFF) << 16)
+#define	XHCI_EPCTX_1_MAXP_SIZE_GET(x)		(((x) >> 16) & 0xFFFF)
+	volatile uint64_t	qwEpCtx2;
+#define	XHCI_EPCTX_2_DCS_SET(x)			((x) & 0x1)
+#define	XHCI_EPCTX_2_DCS_GET(x)			((x) & 0x1)
+#define	XHCI_EPCTX_2_TR_DQ_PTR_MASK		0xFFFFFFFFFFFFFFF0U
+	volatile uint32_t	dwEpCtx4;
+#define	XHCI_EPCTX_4_AVG_TRB_LEN_SET(x)		((x) & 0xFFFF)
+#define	XHCI_EPCTX_4_AVG_TRB_LEN_GET(x)		((x) & 0xFFFF)
+#define	XHCI_EPCTX_4_MAX_ESIT_PAYLOAD_SET(x)	(((x) & 0xFFFF) << 16)
+#define	XHCI_EPCTX_4_MAX_ESIT_PAYLOAD_GET(x)	(((x) >> 16) & 0xFFFF)
+	volatile uint32_t	dwEpCtx5;
+	volatile uint32_t	dwEpCtx6;
+	volatile uint32_t	dwEpCtx7;
+};
+
+struct xhci_endp_ctx64 {
+	struct xhci_endp_ctx	ctx;
+	volatile uint8_t	padding[32];
+};
+
+struct xhci_trb {
+	volatile uint64_t	qwTrb0;
+#define	XHCI_TRB_0_DIR_IN_MASK		(0x80ULL << 0)
+#define	XHCI_TRB_0_WLENGTH_MASK		(0xFFFFULL << 48)
+	volatile uint32_t	dwTrb2;
+#define	XHCI_TRB_2_ERROR_GET(x)		(((x) >> 24) & 0xFF)
+#define	XHCI_TRB_2_ERROR_SET(x)		(((x) & 0xFF) << 24)
+#define	XHCI_TRB_2_TDSZ_GET(x)		(((x) >> 17) & 0x1F)
+#define	XHCI_TRB_2_TDSZ_SET(x)		(((x) & 0x1F) << 17)
+#define	XHCI_TRB_2_REM_GET(x)		((x) & 0xFFFFFF)
+#define	XHCI_TRB_2_REM_SET(x)		((x) & 0xFFFFFF)
+#define	XHCI_TRB_2_BYTES_GET(x)		((x) & 0x1FFFF)
+#define	XHCI_TRB_2_BYTES_SET(x)		((x) & 0x1FFFF)
+#define	XHCI_TRB_2_IRQ_GET(x)		(((x) >> 22) & 0x3FF)
+#define	XHCI_TRB_2_IRQ_SET(x)		(((x) & 0x3FF) << 22)
+#define	XHCI_TRB_2_STREAM_GET(x)	(((x) >> 16) & 0xFFFF)
+#define	XHCI_TRB_2_STREAM_SET(x)	(((x) & 0xFFFF) << 16)
+
+	volatile uint32_t	dwTrb3;
+#define	XHCI_TRB_3_TYPE_GET(x)		(((x) >> 10) & 0x3F)
+#define	XHCI_TRB_3_TYPE_SET(x)		(((x) & 0x3F) << 10)
+#define	XHCI_TRB_3_CYCLE_BIT		(1U << 0)
+#define	XHCI_TRB_3_TC_BIT		(1U << 1)	/* command ring only */
+#define	XHCI_TRB_3_ENT_BIT		(1U << 1)	/* transfer ring only */
+#define	XHCI_TRB_3_ISP_BIT		(1U << 2)
+#define	XHCI_TRB_3_NSNOOP_BIT		(1U << 3)
+#define	XHCI_TRB_3_CHAIN_BIT		(1U << 4)
+#define	XHCI_TRB_3_IOC_BIT		(1U << 5)
+#define	XHCI_TRB_3_IDT_BIT		(1U << 6)
+#define	XHCI_TRB_3_TBC_GET(x)		(((x) >> 7) & 3)
+#define	XHCI_TRB_3_TBC_SET(x)		(((x) & 3) << 7)
+#define	XHCI_TRB_3_BEI_BIT		(1U << 9)
+#define	XHCI_TRB_3_DCEP_BIT		(1U << 9)
+#define	XHCI_TRB_3_PRSV_BIT		(1U << 9)
+#define	XHCI_TRB_3_BSR_BIT		(1U << 9)
+#define	XHCI_TRB_3_TRT_MASK		(3U << 16)
+#define	XHCI_TRB_3_TRT_NONE		(0U << 16)
+#define	XHCI_TRB_3_TRT_OUT		(2U << 16)
+#define	XHCI_TRB_3_TRT_IN		(3U << 16)
+#define	XHCI_TRB_3_DIR_IN		(1U << 16)
+#define	XHCI_TRB_3_TLBPC_GET(x)		(((x) >> 16) & 0xF)
+#define	XHCI_TRB_3_TLBPC_SET(x)		(((x) & 0xF) << 16)
+#define	XHCI_TRB_3_EP_GET(x)		(((x) >> 16) & 0x1F)
+#define	XHCI_TRB_3_EP_SET(x)		(((x) & 0x1F) << 16)
+#define	XHCI_TRB_3_FRID_GET(x)		(((x) >> 20) & 0x7FF)
+#define	XHCI_TRB_3_FRID_SET(x)		(((x) & 0x7FF) << 20)
+#define	XHCI_TRB_3_ISO_SIA_BIT		(1U << 31)
+#define	XHCI_TRB_3_SUSP_EP_BIT		(1U << 23)
+#define	XHCI_TRB_3_SLOT_GET(x)		(((x) >> 24) & 0xFF)
+#define	XHCI_TRB_3_SLOT_SET(x)		(((x) & 0xFF) << 24)
+
+/* Commands */
+#define	XHCI_TRB_TYPE_RESERVED		0x00
+#define	XHCI_TRB_TYPE_NORMAL		0x01
+#define	XHCI_TRB_TYPE_SETUP_STAGE	0x02
+#define	XHCI_TRB_TYPE_DATA_STAGE	0x03
+#define	XHCI_TRB_TYPE_STATUS_STAGE	0x04
+#define	XHCI_TRB_TYPE_ISOCH		0x05
+#define	XHCI_TRB_TYPE_LINK		0x06
+#define	XHCI_TRB_TYPE_EVENT_DATA	0x07
+#define	XHCI_TRB_TYPE_NOOP		0x08
+#define	XHCI_TRB_TYPE_ENABLE_SLOT	0x09
+#define	XHCI_TRB_TYPE_DISABLE_SLOT	0x0A
+#define	XHCI_TRB_TYPE_ADDRESS_DEVICE	0x0B
+#define	XHCI_TRB_TYPE_CONFIGURE_EP	0x0C
+#define	XHCI_TRB_TYPE_EVALUATE_CTX	0x0D
+#define	XHCI_TRB_TYPE_RESET_EP		0x0E
+#define	XHCI_TRB_TYPE_STOP_EP		0x0F
+#define	XHCI_TRB_TYPE_SET_TR_DEQUEUE	0x10
+#define	XHCI_TRB_TYPE_RESET_DEVICE	0x11
+#define	XHCI_TRB_TYPE_FORCE_EVENT	0x12
+#define	XHCI_TRB_TYPE_NEGOTIATE_BW	0x13
+#define	XHCI_TRB_TYPE_SET_LATENCY_TOL  	0x14
+#define	XHCI_TRB_TYPE_GET_PORT_BW	0x15
+#define	XHCI_TRB_TYPE_FORCE_HEADER	0x16
+#define	XHCI_TRB_TYPE_NOOP_CMD		0x17
+
+/* Events */
+#define	XHCI_TRB_EVENT_TRANSFER		0x20
+#define	XHCI_TRB_EVENT_CMD_COMPLETE	0x21
+#define	XHCI_TRB_EVENT_PORT_STS_CHANGE  0x22
+#define	XHCI_TRB_EVENT_BW_REQUEST      	0x23
+#define	XHCI_TRB_EVENT_DOORBELL		0x24
+#define	XHCI_TRB_EVENT_HOST_CTRL	0x25
+#define	XHCI_TRB_EVENT_DEVICE_NOTIFY	0x26
+#define	XHCI_TRB_EVENT_MFINDEX_WRAP	0x27
+
+/* Error codes */
+#define	XHCI_TRB_ERROR_INVALID		0x00
+#define	XHCI_TRB_ERROR_SUCCESS		0x01
+#define	XHCI_TRB_ERROR_DATA_BUF		0x02
+#define	XHCI_TRB_ERROR_BABBLE		0x03
+#define	XHCI_TRB_ERROR_XACT		0x04
+#define	XHCI_TRB_ERROR_TRB		0x05
+#define	XHCI_TRB_ERROR_STALL		0x06
+#define	XHCI_TRB_ERROR_RESOURCE		0x07
+#define	XHCI_TRB_ERROR_BANDWIDTH	0x08
+#define	XHCI_TRB_ERROR_NO_SLOTS		0x09
+#define	XHCI_TRB_ERROR_STREAM_TYPE	0x0A
+#define	XHCI_TRB_ERROR_SLOT_NOT_ON	0x0B
+#define	XHCI_TRB_ERROR_ENDP_NOT_ON	0x0C
+#define	XHCI_TRB_ERROR_SHORT_PKT	0x0D
+#define	XHCI_TRB_ERROR_RING_UNDERRUN	0x0E
+#define	XHCI_TRB_ERROR_RING_OVERRUN	0x0F
+#define	XHCI_TRB_ERROR_VF_RING_FULL	0x10
+#define	XHCI_TRB_ERROR_PARAMETER	0x11
+#define	XHCI_TRB_ERROR_BW_OVERRUN	0x12
+#define	XHCI_TRB_ERROR_CONTEXT_STATE	0x13
+#define	XHCI_TRB_ERROR_NO_PING_RESP	0x14
+#define	XHCI_TRB_ERROR_EV_RING_FULL	0x15
+#define	XHCI_TRB_ERROR_INCOMPAT_DEV	0x16
+#define	XHCI_TRB_ERROR_MISSED_SERVICE	0x17
+#define	XHCI_TRB_ERROR_CMD_RING_STOP	0x18
+#define	XHCI_TRB_ERROR_CMD_ABORTED	0x19
+#define	XHCI_TRB_ERROR_STOPPED		0x1A
+#define	XHCI_TRB_ERROR_LENGTH		0x1B
+#define	XHCI_TRB_ERROR_BAD_MELAT	0x1D
+#define	XHCI_TRB_ERROR_ISOC_OVERRUN	0x1F
+#define	XHCI_TRB_ERROR_EVENT_LOST	0x20
+#define	XHCI_TRB_ERROR_UNDEFINED	0x21
+#define	XHCI_TRB_ERROR_INVALID_SID	0x22
+#define	XHCI_TRB_ERROR_SEC_BW		0x23
+#define	XHCI_TRB_ERROR_SPLIT_XACT	0x24
+} __aligned(4);
+
+struct xhci_event_ring_seg {
+	volatile uint64_t	qwEvrsTablePtr;
+	volatile uint32_t	dwEvrsTableSize;
+	volatile uint32_t	dwEvrsReserved;
+};
+
+#endif					/* _USB_XHCI_PRIVATE_H_ */
diff --git a/sys/dev/usb/controller/xhcireg.h b/sys/dev/usb/controller/xhcireg.h
index 9d0b6e2f4b4b..6bd026dc4659 100644
--- a/sys/dev/usb/controller/xhcireg.h
+++ b/sys/dev/usb/controller/xhcireg.h
@@ -205,6 +205,97 @@
 #define	XHCI_ID_VIRTUALIZATION	0x0004
 #define	XHCI_ID_MSG_IRQ		0x0005
 #define	XHCI_ID_USB_LOCAL_MEM	0x0006
+#define	XHCI_ID_USB_DEBUG	0x000a
+
+/* XHCI Debug Capability */
+#define	XHCI_DCID		0x0000
+#define	XHCI_DCDB		0x0004
+#define	XHCI_DCDB_GET(x)	(((x) >> 8) & 0xFF)
+#define	XHCI_DCDB_MASK		0x0000FF00	/* the other bits are RsvdP */
+#define	XHCI_DCDB_OUT		0x0000
+#define	XHCI_DCDB_IN		0x0100
+#define	XHCI_DCDB_INVAL		0xFF00
+#define	XHCI_DCERSTSZ		0x0008
+#define	XHCI_DCERSTBA_LO	0x0010
+#define	XHCI_DCERSTBA_HI	0x0014
+#define	XHCI_DCERDP_LO		0x0018
+#define	XHCI_DCERDP_HI		0x001C
+#define	XHCI_DCCTRL		0x0020
+#define	XHCI_DCCTRL_DCR		0x00000001
+#define	XHCI_DCCTRL_DCR_GET(x)	(((x)      ) & 0x01)
+#define	XHCI_DCCTRL_LSE		0x00000002
+#define	XHCI_DCCTRL_LSE_GET(x)	(((x) >>  1) & 0x01)
+#define	XHCI_DCCTRL_HOT		0x00000004
+#define	XHCI_DCCTRL_HOT_GET(x)	(((x) >>  2) & 0x01)
+#define	XHCI_DCCTRL_HIT		0x00000008
+#define	XHCI_DCCTRL_HIT_GET(x)	(((x) >>  3) & 0x01)
+#define	XHCI_DCCTRL_DRC		0x00000010
+#define	XHCI_DCCTRL_DRC_GET(x)	(((x) >>  4) & 0x01)
+#define	XHCI_DCCTRL_MBS_GET(x)	(((x) >> 16) & 0xFF)
+#define	XHCI_DCCTRL_ADDR_GET(x)	(((x) >> 24) & 0x07)
+#define	XHCI_DCCTRL_DCE		0x80000000
+#define	XHCI_DCCTRL_DCE_GET(x)	(((x) >> 31) & 0x01)
+#define	XHCI_DCST		0x0024
+#define	XHCI_DCST_ER		0x00000000
+#define	XHCI_DCST_ER_GET(x)	(((x)      ) & 0x01)
+#define	XHCI_DCST_SBR		0x00000004
+#define	XHCI_DCST_SBR_GET(x)	(((x) >>  2) & 0x01)
+#define	XHCI_DCST_PORT_GET(x)	(((x) >> 24) & 0xFF)
+#define	XHCI_DCPORTSC		0x0028
+#define	XHCI_DCPORTSC_CCS	0x00000001
+#define	XHCI_DCPORTSC_CCS_GET(x)	(((x)      ) & 0x01)
+#define	XHCI_DCPORTSC_PED	0x00000002
+#define	XHCI_DCPORTSC_PED_GET(x)	(((x) >>  1) & 0x01)
+#define	XHCI_DCPORTSC_PR	0x00000010
+#define	XHCI_DCPORTSC_PR_GET(x)	(((x) >>  4) & 0x01)
+#define	XHCI_DCPORTSC_PLS_GET(x)	(((x) >>  5) & 0x0F)
+#define	XHCI_DCPORTSC_PLS_U0	0x00
+#define	XHCI_DCPORTSC_PLS_U1	0x01
+#define	XHCI_DCPORTSC_PLS_U2	0x02
+#define	XHCI_DCPORTSC_PLS_U3	0x03
+#define	XHCI_DCPORTSC_PLS_DISABLED	0x04
+#define	XHCI_DCPORTSC_PLS_RXDETECTED	0x05
+#define	XHCI_DCPORTSC_PLS_INACTIVE	0x06
+#define	XHCI_DCPORTSC_PLS_POLLING	0x07
+#define	XHCI_DCPORTSC_PLS_RECOVERY	0x08
+#define	XHCI_DCPORTSC_PLS_HOTRESET	0x09
+#define	XHCI_DCPORTSC_SPEED_GET(x)	(((x) >> 10) & 0x0F)
+#define	XHCI_DCPORTSC_CSC	0x00020000
+#define	XHCI_DCPORTSC_CSC_GET(x)	(((x) >> 17) & 0x01)
+#define	XHCI_DCPORTSC_PRC	0x00200000
+#define	XHCI_DCPORTSC_PRC_GET(x)	(((x) >> 21) & 0x01)
+#define	XHCI_DCPORTSC_PLC	0x00400000
+#define	XHCI_DCPORTSC_PLC_GET(x)	(((x) >> 22) & 0x01)
+#define	XHCI_DCPORTSC_CEC	0x00800000
+#define	XHCI_DCPORTSC_CEC_GET(x)	(((x) >> 23) & 0x01)
+#define	XHCI_DCCP_LO		0x0030
+#define	XHCI_DCCP_HI		0x0034
+#define	XHCI_DCDDI1		0x0038
+#define	XHCI_DCDDI2		0x003C
+
+#define	XHCI_DCSTATUS(ctrl, portsc) \
+	(XHCI_DCCTRL_DCE_GET(ctrl) << 4 | \
+	XHCI_DCPORTSC_CCS_GET(portsc) << 3 | \
+	XHCI_DCPORTSC_PED_GET(portsc) << 2 | \
+	XHCI_DCPORTSC_PR_GET(portsc)  << 1 | \
+	XHCI_DCCTRL_DCR_GET(ctrl))
+#define	XHCI_DCPORT_ST_OFF		0x00
+#define	XHCI_DCPORT_ST_DISCONNECTED	0x10	/* DCE only */
+#define	XHCI_DCPORT_ST_DISABLED		0x18	/* DCE + CCS */
+#define	XHCI_DCPORT_ST_RESETTING	0x1a	/* DCE + CCS + PR */
+#define	XHCI_DCPORT_ST_ENABLED		0x1c	/* DCE + CCS + PED */
+#define	XHCI_DCPORT_ST_CONFIGURED	0x1d	/* DCE + CCS + PED + DCR */
+
+#define	XHCI_DC_MAXPACKETLEN	1024
+/*
+ * While Sec 7.6.3.2 describes Endpoint IDs should be 0 or 1,
+ * Intel chips use Device Context Index (Sec 4.5.1) instead.
+ */
+#define	XHCI_DC_EPID_OUT	0
+#define	XHCI_DC_EPID_IN		1
+#define	XHCI_DC_EPID_OUT_INTEL	2
+#define	XHCI_DC_EPID_IN_INTEL	3
+#define	XHCI_DC_SLOT		1
 
 /* XHCI register R/W wrappers */
 #define	XREAD1(sc, what, a) \
@@ -216,6 +307,9 @@
 #define	XREAD4(sc, what, a) \
 	bus_space_read_4((sc)->sc_io_tag, (sc)->sc_io_hdl, \
 		(a) + (sc)->sc_##what##_off)
+#define	XREAD44LH(sc, what, a) \
+	((uint64_t)XREAD4((sc), what, a##_LO) | \
+	    ((uint64_t)XREAD4((sc), what, a##_HI) << 32))
 #define	XWRITE1(sc, what, a, x) \
 	bus_space_write_1((sc)->sc_io_tag, (sc)->sc_io_hdl, \
 		(a) + (sc)->sc_##what##_off, (x))
@@ -225,5 +319,10 @@
 #define	XWRITE4(sc, what, a, x) \
 	bus_space_write_4((sc)->sc_io_tag, (sc)->sc_io_hdl, \
 		(a) + (sc)->sc_##what##_off, (x))
+#define	XWRITE44LH(sc, what, a, x) \
+	do { \
+		XWRITE4((sc), what, a##_LO, (uint32_t)((x) & 0xffffffff)); \
+		XWRITE4((sc), what, a##_HI, (uint32_t)((x) >> 32)); \
+	} while (0)
 
 #endif	/* _XHCIREG_H_ */
diff --git a/sys/dev/usb/net/if_usie.c b/sys/dev/usb/net/if_usie.c
index aaab89a23e9e..aff8ec86d8f7 100644
--- a/sys/dev/usb/net/if_usie.c
+++ b/sys/dev/usb/net/if_usie.c
@@ -431,11 +431,6 @@ usie_attach(device_t self)
 
 	/* setup ifnet (Direct IP) */
 	sc->sc_ifp = ifp = if_alloc(IFT_OTHER);
-
-	if (ifp == NULL) {
-		device_printf(self, "Could not allocate a network interface\n");
-		goto detach;
-	}
 	if_initname(ifp, "usie", device_get_unit(self));
 
 	if_setsoftc(ifp, sc);
diff --git a/sys/dev/usb/net/uhso.c b/sys/dev/usb/net/uhso.c
index 14826734f6aa..9513dbeae029 100644
--- a/sys/dev/usb/net/uhso.c
+++ b/sys/dev/usb/net/uhso.c
@@ -1566,10 +1566,6 @@ uhso_attach_ifnet(struct uhso_softc *sc, struct usb_interface *iface, int type)
 	}
 
 	sc->sc_ifp = ifp = if_alloc(IFT_OTHER);
-	if (sc->sc_ifp == NULL) {
-		device_printf(sc->sc_dev, "if_alloc() failed\n");
-		return (-1);
-	}
 
 	callout_init_mtx(&sc->sc_c, &sc->sc_mtx, 0);
 	mtx_lock(&sc->sc_mtx);
diff --git a/sys/dev/usb/net/usb_ethernet.c b/sys/dev/usb/net/usb_ethernet.c
index 2b90c9249855..1efd82ccda13 100644
--- a/sys/dev/usb/net/usb_ethernet.c
+++ b/sys/dev/usb/net/usb_ethernet.c
@@ -221,11 +221,6 @@ ue_attach_post_task(struct usb_proc_msg *_task)
 	error = 0;
 	CURVNET_SET_QUIET(vnet0);
 	ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(ue->ue_dev, "could not allocate ifnet\n");
-		goto fail;
-	}
-
 	if_setsoftc(ifp, ue);
 	if_initname(ifp, "ue", ue->ue_unit);
 	if (ue->ue_methods->ue_attach_post_sub != NULL) {
diff --git a/sys/dev/usb/serial/u3g.c b/sys/dev/usb/serial/u3g.c
index e0a1ff29b0a4..88f94ddaecc6 100644
--- a/sys/dev/usb/serial/u3g.c
+++ b/sys/dev/usb/serial/u3g.c
@@ -205,6 +205,7 @@ static const STRUCT_USB_HOST_ID u3g_devs[] = {
 	U3G_DEV(ALINK, 3GU, 0),
 	U3G_DEV(ALINK, DWM652U5, 0),
 	U3G_DEV(ALINK, SIM7600E, 0),
+	U3G_DEV(ALINK, SIM7600G, 0),
 	U3G_DEV(AMOI, H01, 0),
 	U3G_DEV(AMOI, H01A, 0),
 	U3G_DEV(AMOI, H02, 0),
diff --git a/sys/dev/usb/serial/udbc.c b/sys/dev/usb/serial/udbc.c
new file mode 100644
index 000000000000..098086ec97b9
--- /dev/null
+++ b/sys/dev/usb/serial/udbc.c
@@ -0,0 +1,426 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-NetBSD
+ *
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * Copyright (c) 2016-24 Hiroki Sato <hrs@FreeBSD.org>
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Lennart Augustsson (lennart@augustsson.net).
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <sys/cdefs.h>
+
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
+#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
+#include <dev/usb/usb_core.h>
+#include <dev/usb/usb_ioctl.h>
+#include "usbdevs.h"
+
+#define	USB_DEBUG_VAR udbc_debug
+#include <dev/usb/usb_debug.h>
+#include <dev/usb/usb_process.h>
+
+#include <dev/usb/serial/usb_serial.h>
+
+static SYSCTL_NODE(_hw_usb, OID_AUTO, udbc, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
+    "USB DbC Client");
+
+#ifdef USB_DEBUG
+static int udbc_debug = 0;
+SYSCTL_INT(_hw_usb_udbc, OID_AUTO, debug, CTLFLAG_RWTUN,
+    &udbc_debug, 0, "Debug level");
+#endif
+
+#define	UDBC_CONFIG_INDEX	0
+
+#define	UDBC_IBUFSIZE	1024
+#define	UDBC_OBUFSIZE	1024
+
+enum {
+	UDBC_BULK_DT_WR,
+	UDBC_BULK_DT_RD,
+	UDBC_N_TRANSFER,	/* n of EP */
+};
+
+struct udbc_softc {
+	struct ucom_super_softc sc_super_ucom;
+	struct ucom_softc sc_ucom;
+
+	struct usb_device *sc_udev;
+	struct usb_xfer *sc_xfer[UDBC_N_TRANSFER];
+	device_t sc_dev;
+	struct mtx sc_mtx;
+
+	uint32_t sc_unit;
+};
+
+/* prototypes */
+
+static device_probe_t udbc_probe;
+static device_attach_t udbc_attach;
+static device_detach_t udbc_detach;
+static void udbc_free_softc(struct udbc_softc *);
+
+static usb_callback_t udbc_write_callback;
+static usb_callback_t udbc_read_callback;
+
+static void	udbc_free(struct ucom_softc *);
+static void	udbc_cfg_open(struct ucom_softc *);
+static void	udbc_cfg_close(struct ucom_softc *);
+static int	udbc_pre_param(struct ucom_softc *, struct termios *);
+static int	udbc_ioctl(struct ucom_softc *, uint32_t, caddr_t, int,
+		    struct thread *);
+static void	udbc_start_read(struct ucom_softc *);
+static void	udbc_stop_read(struct ucom_softc *);
+static void	udbc_start_write(struct ucom_softc *);
+static void	udbc_stop_write(struct ucom_softc *);
+static void	udbc_poll(struct ucom_softc *ucom);
+
+static const struct usb_config udbc_config[UDBC_N_TRANSFER] = {
+	[UDBC_BULK_DT_WR] = {
+		.type = UE_BULK,
+		.endpoint = UE_ADDR_ANY,
+		.direction = UE_DIR_OUT,
+		.bufsize = UDBC_OBUFSIZE,
+		.flags = {.pipe_bof = 1,},
+		.callback = &udbc_write_callback,
+	},
+
+	[UDBC_BULK_DT_RD] = {
+		.type = UE_BULK,
+		.endpoint = UE_ADDR_ANY,
+		.direction = UE_DIR_IN,
+		.bufsize = UDBC_IBUFSIZE,
+		.flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
+		.callback = &udbc_read_callback,
+	},
+};
+
+static const struct ucom_callback udbc_callback = {
+#if 0
+	.ucom_cfg_get_status = &udbc_cfg_get_status,
+	.ucom_cfg_set_dtr = &udbc_cfg_set_dtr,
+	.ucom_cfg_set_rts = &udbc_cfg_set_rts,
+	.ucom_cfg_set_break = &udbc_cfg_set_break,
+	.ucom_cfg_param = &udbc_cfg_param,
+#endif
+	.ucom_cfg_open = &udbc_cfg_open,
+	.ucom_cfg_close = &udbc_cfg_close,
+	.ucom_pre_param = &udbc_pre_param,
+	.ucom_ioctl = &udbc_ioctl,
+	.ucom_start_read = &udbc_start_read,
+	.ucom_stop_read = &udbc_stop_read,
+	.ucom_start_write = &udbc_start_write,
+	.ucom_stop_write = &udbc_stop_write,
+	.ucom_poll = &udbc_poll,
+	.ucom_free = &udbc_free,
+};
+
+static device_method_t udbc_methods[] = {
+	/* Device interface */
+	DEVMETHOD(device_probe, udbc_probe),
+	DEVMETHOD(device_attach, udbc_attach),
+	DEVMETHOD(device_detach, udbc_detach),
+	DEVMETHOD_END
+};
+
+static driver_t udbc_driver = {
+	.name = "udbc",
+	.methods = udbc_methods,
+	.size = sizeof(struct udbc_softc),
+};
+
+DRIVER_MODULE(udbc, uhub, udbc_driver, NULL, NULL);
+MODULE_DEPEND(udbc, ucom, 1, 1, 1);
+MODULE_DEPEND(udbc, usb, 1, 1, 1);
+MODULE_VERSION(udbc, 1);
+
+static int
+udbc_probe(device_t dev)
+{
+	struct usb_attach_arg *uaa = device_get_ivars(dev);
+
+	if (uaa->usb_mode != USB_MODE_HOST)
+		return (ENXIO);
+	if (uaa->info.bConfigIndex != UDBC_CONFIG_INDEX)
+		return (ENXIO);
+	if (uaa->info.bInterfaceClass != UDCLASS_DIAGNOSTIC)
+		return (ENXIO);
+	if (uaa->info.bDeviceProtocol != 0x00)	/* GNU GDB == 1 */
+		return (ENXIO);
+
+	return (BUS_PROBE_SPECIFIC);
+}
+
+static int
+udbc_attach(device_t dev)
+{
+	struct usb_attach_arg *uaa = device_get_ivars(dev);
+	struct udbc_softc *sc = device_get_softc(dev);
+	int error;
+
+	DPRINTF("\n");
+
+	sc->sc_udev = uaa->device;
+	sc->sc_dev = dev;
+	sc->sc_unit = device_get_unit(dev);
+
+	device_set_usb_desc(dev);
+	mtx_init(&sc->sc_mtx, "udbc", NULL, MTX_DEF);
+	ucom_ref(&sc->sc_super_ucom);
+
+	sc->sc_ucom.sc_portno = 0;
+
+	error = usbd_transfer_setup(uaa->device,
+	    &uaa->info.bIfaceIndex, sc->sc_xfer, udbc_config,
+	    UDBC_N_TRANSFER, sc, &sc->sc_mtx);
+
+	if (error) {
+		device_printf(dev, "allocating USB "
+		    "transfers failed\n");
+		goto detach;
+	}
+	/* clear stall at first run */
+	mtx_lock(&sc->sc_mtx);
+	usbd_xfer_set_stall(sc->sc_xfer[UDBC_BULK_DT_WR]);
+	usbd_xfer_set_stall(sc->sc_xfer[UDBC_BULK_DT_RD]);
+	mtx_unlock(&sc->sc_mtx);
+
+	error = ucom_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc,
+	    &udbc_callback, &sc->sc_mtx);
+	if (error)
+		goto detach;
+	ucom_set_pnpinfo_usb(&sc->sc_super_ucom, dev);
+
+	return (0);			/* success */
+
+detach:
+	udbc_detach(dev);
+	return (ENXIO);
+}
+
+static int
+udbc_detach(device_t dev)
+{
+	struct udbc_softc *sc = device_get_softc(dev);
+
+	ucom_detach(&sc->sc_super_ucom, &sc->sc_ucom);
+	usbd_transfer_unsetup(sc->sc_xfer, UDBC_N_TRANSFER);
+
+	device_claim_softc(dev);
+
+	udbc_free_softc(sc);
+
+	return (0);
+}
+
+UCOM_UNLOAD_DRAIN(udbc);
+
+static void
+udbc_free_softc(struct udbc_softc *sc)
+{
+	if (ucom_unref(&sc->sc_super_ucom)) {
+		mtx_destroy(&sc->sc_mtx);
+		device_free_softc(sc);
+	}
+}
+
+static void
+udbc_free(struct ucom_softc *ucom)
+{
+	udbc_free_softc(ucom->sc_parent);
+}
+
+static void
+udbc_cfg_open(struct ucom_softc *ucom)
+{
+
+	/*
+	 * This do-nothing open routine exists for the sole purpose of this
+	 * DPRINTF() so that you can see the point at which open gets called
+	 * when debugging is enabled.
+	 */
+	DPRINTF("\n");
+}
+
+static void
+udbc_cfg_close(struct ucom_softc *ucom)
+{
+
+	/*
+	 * This do-nothing close routine exists for the sole purpose of this
+	 * DPRINTF() so that you can see the point at which close gets called
+	 * when debugging is enabled.
+	 */
+	DPRINTF("\n");
+}
+
+static void
+udbc_write_callback(struct usb_xfer *xfer, usb_error_t error)
+{
+	struct udbc_softc *sc = usbd_xfer_softc(xfer);
+	struct usb_page_cache *pc;
+	uint32_t buflen;
+
+	DPRINTFN(3, "\n");
+
+	switch (USB_GET_STATE(xfer)) {
+	default:			/* Error */
+		if (error != USB_ERR_CANCELLED) {
+			/* try to clear stall first */
+			usbd_xfer_set_stall(xfer);
+		}
+		/* FALLTHROUGH */
+	case USB_ST_SETUP:
+	case USB_ST_TRANSFERRED:
+		pc = usbd_xfer_get_frame(xfer, 0);
+		if (ucom_get_data(&sc->sc_ucom, pc, 0, UDBC_OBUFSIZE, 
+		    &buflen) == 0)
+			break;
+		if (buflen != 0) {
+			usbd_xfer_set_frame_len(xfer, 0, buflen);
+			usbd_transfer_submit(xfer);
+		}
+		break;
+	}
+}
+
+static void
+udbc_read_callback(struct usb_xfer *xfer, usb_error_t error)
+{
+	struct udbc_softc *sc = usbd_xfer_softc(xfer);
+	struct usb_page_cache *pc;
+	int buflen;
+
+	DPRINTFN(3, "\n");
+
+	usbd_xfer_status(xfer, &buflen, NULL, NULL, NULL);
+
+	switch (USB_GET_STATE(xfer)) {
+	case USB_ST_TRANSFERRED:
+		pc = usbd_xfer_get_frame(xfer, 0);
+		ucom_put_data(&sc->sc_ucom, pc, 0, buflen);
+		/* FALLTHROUGH */
+	case USB_ST_SETUP:
+tr_setup:
+		usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
+		usbd_transfer_submit(xfer);
+		return;
+
+	default:			/* Error */
+		if (error != USB_ERR_CANCELLED) {
+			/* try to clear stall first */
+			usbd_xfer_set_stall(xfer);
+			goto tr_setup;
+		}
+		return;
+	}
+}
+
+static int
+udbc_pre_param(struct ucom_softc *ucom, struct termios *t)
+{
+
+	DPRINTF("\n");
+
+	return (0);
+}
+
+static int
+udbc_ioctl(struct ucom_softc *ucom, uint32_t cmd, caddr_t data,
+    int flag, struct thread *td)
+{
+#if 0
+	struct udbc_softc *sc = ucom->sc_parent;
+#endif
+	int err;
+
+	switch (cmd) {
+	default:
+		return (ENOIOCTL);
+	}
+	if (err != USB_ERR_NORMAL_COMPLETION)
+		return (EIO);
+	return (0);
+}
+
+static void
+udbc_start_read(struct ucom_softc *ucom)
+{
+	struct udbc_softc *sc = ucom->sc_parent;
+
+	usbd_transfer_start(sc->sc_xfer[UDBC_BULK_DT_RD]);
+}
+
+static void
+udbc_stop_read(struct ucom_softc *ucom)
+{
+	struct udbc_softc *sc = ucom->sc_parent;
+
+	usbd_transfer_stop(sc->sc_xfer[UDBC_BULK_DT_RD]);
+}
+
+static void
+udbc_start_write(struct ucom_softc *ucom)
+{
+	struct udbc_softc *sc = ucom->sc_parent;
+
+	usbd_transfer_start(sc->sc_xfer[UDBC_BULK_DT_WR]);
+}
+
+static void
+udbc_stop_write(struct ucom_softc *ucom)
+{
+	struct udbc_softc *sc = ucom->sc_parent;
+
+	usbd_transfer_stop(sc->sc_xfer[UDBC_BULK_DT_WR]);
+}
+
+static void
+udbc_poll(struct ucom_softc *ucom)
+{
+	struct udbc_softc *sc = ucom->sc_parent;
+
+	usbd_transfer_poll(sc->sc_xfer, UDBC_N_TRANSFER);
+}
diff --git a/sys/dev/usb/usb_pf.c b/sys/dev/usb/usb_pf.c
index 43e819684857..3b03e80db489 100644
--- a/sys/dev/usb/usb_pf.c
+++ b/sys/dev/usb/usb_pf.c
@@ -195,12 +195,6 @@ usbpf_clone_create(struct if_clone *ifc, char *name, size_t len,
 		return (error);
 	}
 	ifp = ubus->ifp = if_alloc(IFT_USB);
-	if (ifp == NULL) {
-		ifc_free_unit(ifc, unit);
-		device_printf(ubus->parent, "usbpf: Could not allocate "
-		    "instance\n");
-		return (ENOSPC);
-	}
 	if_setsoftc(ifp, ubus);
 	if_initname(ifp, usbusname, unit);
 	if_setname(ifp, name);
diff --git a/sys/dev/usb/usbdevs b/sys/dev/usb/usbdevs
index 65dcb06c2f3f..2a217b1eaf17 100644
--- a/sys/dev/usb/usbdevs
+++ b/sys/dev/usb/usbdevs
@@ -1064,6 +1064,7 @@ product ALCOR AU6390	0x6390	AU6390 USB-IDE converter
 product ALINK DWM652U5		0xce16	DWM-652
 product ALINK 3G		0x9000	3G modem
 product ALINK SIM7600E		0x9001	LTE modem
+product ALINK SIM7600G		0x9011	LTE modem
 product ALINK 3GU		0x9200	3G modem
 
 /* Altec Lansing products */
diff --git a/sys/dev/vge/if_vge.c b/sys/dev/vge/if_vge.c
index 37606f28ba17..9f71049a150b 100644
--- a/sys/dev/vge/if_vge.c
+++ b/sys/dev/vge/if_vge.c
@@ -1093,12 +1093,6 @@ vge_attach(device_t dev)
 		goto fail;
 
 	ifp = sc->vge_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "can not if_alloc()\n");
-		error = ENOSPC;
-		goto fail;
-	}
-
 	vge_miipoll_start(sc);
 	/* Do MII setup */
 	error = mii_attach(dev, &sc->vge_miibus, ifp, vge_ifmedia_upd,
diff --git a/sys/dev/virtio/console/virtio_console.c b/sys/dev/virtio/console/virtio_console.c
index d8048d0f1f6e..45cd11ddb5ef 100644
--- a/sys/dev/virtio/console/virtio_console.c
+++ b/sys/dev/virtio/console/virtio_console.c
@@ -979,7 +979,7 @@ vtcon_ctrl_poll(struct vtcon_softc *sc,
 	 */
 	VTCON_CTRL_TX_LOCK(sc);
 	KASSERT(virtqueue_empty(vq),
-	    ("%s: virtqueue is not emtpy", __func__));
+	    ("%s: virtqueue is not empty", __func__));
 	error = virtqueue_enqueue(vq, control, &sg, sg.sg_nseg, 0);
 	if (error == 0) {
 		virtqueue_notify(vq);
@@ -1367,7 +1367,7 @@ vtcon_port_out(struct vtcon_port *port, void *buf, int bufsize)
 
 	vq = port->vtcport_outvq;
 	KASSERT(virtqueue_empty(vq),
-	    ("%s: port %p out virtqueue not emtpy", __func__, port));
+	    ("%s: port %p out virtqueue not empty", __func__, port));
 
 	sglist_init(&sg, 2, segs);
 	error = sglist_append(&sg, buf, bufsize);
diff --git a/sys/dev/virtio/network/if_vtnet.c b/sys/dev/virtio/network/if_vtnet.c
index 245a6b6d7359..0292458bfc40 100644
--- a/sys/dev/virtio/network/if_vtnet.c
+++ b/sys/dev/virtio/network/if_vtnet.c
@@ -116,7 +116,7 @@ static void	vtnet_free_rxtx_queues(struct vtnet_softc *);
 static int	vtnet_alloc_rx_filters(struct vtnet_softc *);
 static void	vtnet_free_rx_filters(struct vtnet_softc *);
 static int	vtnet_alloc_virtqueues(struct vtnet_softc *);
-static int	vtnet_alloc_interface(struct vtnet_softc *);
+static void	vtnet_alloc_interface(struct vtnet_softc *);
 static int	vtnet_setup_interface(struct vtnet_softc *);
 static int	vtnet_ioctl_mtu(struct vtnet_softc *, u_int);
 static int	vtnet_ioctl_ifflags(struct vtnet_softc *);
@@ -438,12 +438,7 @@ vtnet_attach(device_t dev)
 	callout_init_mtx(&sc->vtnet_tick_ch, VTNET_CORE_MTX(sc), 0);
 	vtnet_load_tunables(sc);
 
-	error = vtnet_alloc_interface(sc);
-	if (error) {
-		device_printf(dev, "cannot allocate interface\n");
-		goto fail;
-	}
-
+	vtnet_alloc_interface(sc);
 	vtnet_setup_sysctl(sc);
 
 	error = vtnet_setup_features(sc);
@@ -1078,7 +1073,7 @@ vtnet_alloc_virtqueues(struct vtnet_softc *sc)
 	return (error);
 }
 
-static int
+static void
 vtnet_alloc_interface(struct vtnet_softc *sc)
 {
 	device_t dev;
@@ -1087,14 +1082,9 @@ vtnet_alloc_interface(struct vtnet_softc *sc)
 	dev = sc->vtnet_dev;
 
 	ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL)
-		return (ENOMEM);
-
 	sc->vtnet_ifp = ifp;
 	if_setsoftc(ifp, sc);
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
-
-	return (0);
 }
 
 static int
diff --git a/sys/dev/virtio/pci/virtio_pci_legacy.c b/sys/dev/virtio/pci/virtio_pci_legacy.c
index 88a8323bdd6f..cf574160cdd4 100644
--- a/sys/dev/virtio/pci/virtio_pci_legacy.c
+++ b/sys/dev/virtio/pci/virtio_pci_legacy.c
@@ -191,7 +191,6 @@ DRIVER_MODULE(virtio_pci_legacy, pci, vtpci_legacy_driver, 0, 0);
 static int
 vtpci_legacy_probe(device_t dev)
 {
-	char desc[64];
 	const char *name;
 
 	if (pci_get_vendor(dev) != VIRTIO_PCI_VENDORID)
@@ -208,8 +207,7 @@ vtpci_legacy_probe(device_t dev)
 	if (name == NULL)
 		name = "Unknown";
 
-	snprintf(desc, sizeof(desc), "VirtIO PCI (legacy) %s adapter", name);
-	device_set_desc_copy(dev, desc);
+	device_set_descf(dev, "VirtIO PCI (legacy) %s adapter", name);
 
 	/* Prefer transitional modern VirtIO PCI. */
 	return (BUS_PROBE_LOW_PRIORITY);
diff --git a/sys/dev/virtio/pci/virtio_pci_modern.c b/sys/dev/virtio/pci/virtio_pci_modern.c
index 2fa921dd9141..2e59448b4b5e 100644
--- a/sys/dev/virtio/pci/virtio_pci_modern.c
+++ b/sys/dev/virtio/pci/virtio_pci_modern.c
@@ -245,7 +245,6 @@ DRIVER_MODULE(virtio_pci_modern, pci, vtpci_modern_driver, 0, 0);
 static int
 vtpci_modern_probe(device_t dev)
 {
-	char desc[64];
 	const char *name;
 	uint16_t devid;
 
@@ -270,8 +269,7 @@ vtpci_modern_probe(device_t dev)
 	if (name == NULL)
 		name = "Unknown";
 
-	snprintf(desc, sizeof(desc), "VirtIO PCI (modern) %s adapter", name);
-	device_set_desc_copy(dev, desc);
+	device_set_descf(dev, "VirtIO PCI (modern) %s adapter", name);
 
 	return (BUS_PROBE_DEFAULT);
 }
diff --git a/sys/dev/vnic/nicvf_main.c b/sys/dev/vnic/nicvf_main.c
index f5cf99ef0ce4..dd44e420c78f 100644
--- a/sys/dev/vnic/nicvf_main.c
+++ b/sys/dev/vnic/nicvf_main.c
@@ -139,7 +139,7 @@ static void nicvf_config_cpi(struct nicvf *);
 static int nicvf_rss_init(struct nicvf *);
 static int nicvf_init_resources(struct nicvf *);
 
-static int nicvf_setup_ifnet(struct nicvf *);
+static void nicvf_setup_ifnet(struct nicvf *);
 static int nicvf_setup_ifmedia(struct nicvf *);
 static void nicvf_hw_addr_random(uint8_t *);
 
@@ -247,11 +247,7 @@ nicvf_attach(device_t dev)
 		nicvf_rss_init(nic);
 	NICVF_CORE_UNLOCK(nic);
 
-	err = nicvf_setup_ifnet(nic);
-	if (err != 0) {
-		device_printf(dev, "Could not set-up ifnet\n");
-		goto err_release_intr;
-	}
+	nicvf_setup_ifnet(nic);
 
 	err = nicvf_setup_ifmedia(nic);
 	if (err != 0) {
@@ -329,17 +325,12 @@ nicvf_hw_addr_random(uint8_t *hwaddr)
 	memcpy(hwaddr, addr, ETHER_ADDR_LEN);
 }
 
-static int
+static void
 nicvf_setup_ifnet(struct nicvf *nic)
 {
 	if_t ifp;
 
 	ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(nic->dev, "Could not allocate ifnet structure\n");
-		return (ENOMEM);
-	}
-
 	nic->ifp = ifp;
 
 	if_setsoftc(ifp, nic);
@@ -379,8 +370,6 @@ nicvf_setup_ifnet(struct nicvf *nic)
 	if (nic->hw_tso)
 		if_sethwassistbits(ifp, (CSUM_TSO), 0);
 	if_setcapenable(ifp, if_getcapabilities(ifp));
-
-	return (0);
 }
 
 static int
diff --git a/sys/dev/vnic/thunder_mdio.c b/sys/dev/vnic/thunder_mdio.c
index 9fc97672b5a2..38d989e7f2db 100644
--- a/sys/dev/vnic/thunder_mdio.c
+++ b/sys/dev/vnic/thunder_mdio.c
@@ -454,10 +454,6 @@ thunder_mdio_phy_connect(device_t dev, int lmacid, int phy)
 		if (pd == NULL)
 			return (ENOMEM);
 		pd->ifp = if_alloc(IFT_ETHER);
-		if (pd->ifp == NULL) {
-			free(pd, M_THUNDER_MDIO);
-			return (ENOMEM);
-		}
 		pd->lmacid = lmacid;
 	}
 
diff --git a/sys/dev/vr/if_vr.c b/sys/dev/vr/if_vr.c
index 2afe16e3c6d2..02b55ef4f304 100644
--- a/sys/dev/vr/if_vr.c
+++ b/sys/dev/vr/if_vr.c
@@ -656,11 +656,6 @@ vr_attach(device_t dev)
 
 	/* Allocate ifnet structure. */
 	ifp = sc->vr_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "couldn't allocate ifnet structure\n");
-		error = ENOSPC;
-		goto fail;
-	}
 	if_setsoftc(ifp, sc);
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 	if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
diff --git a/sys/dev/vte/if_vte.c b/sys/dev/vte/if_vte.c
index ca2fda43bc70..0cddb4fce915 100644
--- a/sys/dev/vte/if_vte.c
+++ b/sys/dev/vte/if_vte.c
@@ -436,12 +436,6 @@ vte_attach(device_t dev)
 	vte_get_macaddr(sc);
 
 	ifp = sc->vte_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "cannot allocate ifnet structure.\n");
-		error = ENXIO;
-		goto fail;
-	}
-
 	if_setsoftc(ifp, sc);
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 	if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
diff --git a/sys/dev/wbwd/wbwd.c b/sys/dev/wbwd/wbwd.c
index 4fe77c1874be..9aeaa2014eda 100644
--- a/sys/dev/wbwd/wbwd.c
+++ b/sys/dev/wbwd/wbwd.c
@@ -462,7 +462,6 @@ wb_watchdog_fn(void *private, u_int cmd, int *error)
 static int
 wb_probe(device_t dev)
 {
-	char buf[128];
 	struct wb_softc *sc;
 	int j;
 	uint8_t devid;
@@ -479,10 +478,9 @@ wb_probe(device_t dev)
 	for (j = 0; j < nitems(wb_devs); j++) {
 		if (wb_devs[j].device_id == devid) {
 			sc->chip = wb_devs[j].chip;
-			snprintf(buf, sizeof(buf),
+			device_set_descf(dev,
 			    "%s (0x%02x/0x%02x) Watchdog Timer",
 			    wb_devs[j].descr, devid, revid);
-			device_set_desc_copy(dev, buf);
 			return (BUS_PROBE_SPECIFIC);
 		}
 	}
diff --git a/sys/dev/wg/if_wg.c b/sys/dev/wg/if_wg.c
index 552f47f9645b..b0ad94e284f1 100644
--- a/sys/dev/wg/if_wg.c
+++ b/sys/dev/wg/if_wg.c
@@ -2194,7 +2194,6 @@ determine_af_and_pullup(struct mbuf **m, sa_family_t *af)
 	return (0);
 }
 
-#ifdef DEV_NETMAP
 static int
 determine_ethertype_and_pullup(struct mbuf **m, int *etp)
 {
@@ -2256,6 +2255,7 @@ wg_transmit(if_t ifp, struct mbuf *m)
 	return (0);
 }
 
+#ifdef DEV_NETMAP
 /*
  * This should only be invoked by netmap, via nm_os_send_up(), to process
  * packets from the host TX ring.
@@ -2919,8 +2919,8 @@ wg_clone_create(struct if_clone *ifc, char *name, size_t len,
 	if_setinitfn(ifp, wg_init);
 	if_setreassignfn(ifp, wg_reassign);
 	if_setqflushfn(ifp, wg_qflush);
-#ifdef DEV_NETMAP
 	if_settransmitfn(ifp, wg_transmit);
+#ifdef DEV_NETMAP
 	if_setinputfn(ifp, wg_if_input);
 #endif
 	if_setoutputfn(ifp, wg_output);
diff --git a/sys/dev/xilinx/if_xae.c b/sys/dev/xilinx/if_xae.c
index b2447a3d0314..1e94f1048ed3 100644
--- a/sys/dev/xilinx/if_xae.c
+++ b/sys/dev/xilinx/if_xae.c
@@ -991,11 +991,6 @@ xae_attach(device_t dev)
 
 	/* Set up the ethernet interface. */
 	sc->ifp = ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "could not allocate ifp.\n");
-		return (ENXIO);
-	}
-
 	if_setsoftc(ifp, sc);
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 	if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
diff --git a/sys/dev/xl/if_xl.c b/sys/dev/xl/if_xl.c
index 573bc6581577..32f95549b774 100644
--- a/sys/dev/xl/if_xl.c
+++ b/sys/dev/xl/if_xl.c
@@ -1188,11 +1188,6 @@ xl_attach(device_t dev)
 
 	/* Initialize interface name. */
 	ifp = sc->xl_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "can not if_alloc()\n");
-		error = ENOSPC;
-		goto fail;
-	}
 	if_setsoftc(ifp, sc);
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 
diff --git a/sys/fs/nfs/nfsproto.h b/sys/fs/nfs/nfsproto.h
index cef886755d5a..ca9c732b6a43 100644
--- a/sys/fs/nfs/nfsproto.h
+++ b/sys/fs/nfs/nfsproto.h
@@ -619,6 +619,8 @@
 #define	NFSV4OPEN_WDCONTENTION		0x00100000
 #define	NFSV4OPEN_WDNOTWANTED		0x00200000
 #define	NFSV4OPEN_WDSUPPFTYPE		0x00400000
+#define	NFSV4OPEN_WDNOTSUPPDOWNGRADE	0x00800000
+#define	NFSV4OPEN_WDNOTSUPPUPGRADE	0x01000000
 
 /*
  * NFS V4 File Handle types
diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c
index 8c5532268287..13bdc74655dd 100644
--- a/sys/fs/nfsclient/nfs_clrpcops.c
+++ b/sys/fs/nfsclient/nfs_clrpcops.c
@@ -389,13 +389,24 @@ nfsrpc_open(vnode_t vp, int amode, struct ucred *cred, NFSPROC_T *p)
 		mode |= NFSV4OPEN_ACCESSREAD;
 	if (amode & FWRITE)
 		mode |= NFSV4OPEN_ACCESSWRITE;
+	if (NFSHASNFSV4N(nmp)) {
+		if (!NFSHASPNFS(nmp) && nfscl_enablecallb != 0 &&
+		    nfs_numnfscbd > 0) {
+			if ((mode & NFSV4OPEN_ACCESSWRITE) != 0)
+				mode |= NFSV4OPEN_WANTWRITEDELEG;
+			else
+				mode |= NFSV4OPEN_WANTANYDELEG;
+		} else
+			mode |= NFSV4OPEN_WANTNODELEG;
+	}
 	nfhp = np->n_fhp;
 
 	retrycnt = 0;
 	do {
 	    dp = NULL;
-	    error = nfscl_open(vp, nfhp->nfh_fh, nfhp->nfh_len, mode, 1,
-		cred, p, NULL, &op, &newone, &ret, 1, true);
+	    error = nfscl_open(vp, nfhp->nfh_fh, nfhp->nfh_len,
+		(mode & NFSV4OPEN_ACCESSBOTH), 1, cred, p, NULL,
+		&op, &newone, &ret, 1, true);
 	    if (error) {
 		return (error);
 	    }
@@ -547,7 +558,8 @@ nfsrpc_openrpc(struct nfsmount *nmp, vnode_t vp, u_int8_t *nfhp, int fhlen,
 	    cred);
 	NFSM_BUILD(tl, u_int32_t *, 5 * NFSX_UNSIGNED);
 	*tl++ = txdr_unsigned(op->nfso_own->nfsow_seqid);
-	*tl++ = txdr_unsigned(mode & NFSV4OPEN_ACCESSBOTH);
+	*tl++ = txdr_unsigned(mode & (NFSV4OPEN_ACCESSBOTH |
+	    NFSV4OPEN_WANTDELEGMASK));
 	*tl++ = txdr_unsigned((mode >> NFSLCK_SHIFT) & NFSV4OPEN_DENYBOTH);
 	tsep = nfsmnt_mdssession(nmp);
 	*tl++ = tsep->nfsess_clientid.lval[0];
@@ -664,6 +676,13 @@ nfsrpc_openrpc(struct nfsmount *nmp, vnode_t vp, u_int8_t *nfhp, int fhlen,
 			    &ret, &acesize, p);
 			if (error)
 				goto nfsmout;
+		} else if (deleg == NFSV4OPEN_DELEGATENONEEXT &&
+		    NFSHASNFSV4N(nmp)) {
+			NFSM_DISSECT(tl, uint32_t *, NFSX_UNSIGNED);
+			deleg = fxdr_unsigned(uint32_t, *tl);
+			if (deleg == NFSV4OPEN_CONTENTION ||
+			    deleg == NFSV4OPEN_RESOURCE)
+				NFSM_DISSECT(tl, uint32_t *, NFSX_UNSIGNED);
 		} else if (deleg != NFSV4OPEN_DELEGATENONE) {
 			error = NFSERR_BADXDR;
 			goto nfsmout;
@@ -1546,7 +1565,7 @@ nfsrpc_lookup(vnode_t dvp, char *name, int len, struct ucred *cred,
 			NFSM_BUILD(tl, uint32_t *, 6 * NFSX_UNSIGNED);
 			*tl++ = txdr_unsigned(NFSV4OP_OPEN);
 			*tl++ = 0;		/* seqid, ignored. */
-			*tl++ = txdr_unsigned(openmode);
+			*tl++ = txdr_unsigned(openmode | NFSV4OPEN_WANTNODELEG);
 			*tl++ = txdr_unsigned(NFSV4OPEN_DENYNONE);
 			*tl++ = 0;		/* ClientID, ignored. */
 			*tl = 0;
@@ -1668,6 +1687,13 @@ nfsrpc_lookup(vnode_t dvp, char *name, int len, struct ucred *cred,
 			ndp->nfsdl_stateid.other[0] = *tl++;
 			ndp->nfsdl_stateid.other[1] = *tl++;
 			ndp->nfsdl_stateid.other[2] = *tl++;
+		} else if (deleg == NFSV4OPEN_DELEGATENONEEXT &&
+		    NFSHASNFSV4N(nmp)) {
+			NFSM_DISSECT(tl, uint32_t *, NFSX_UNSIGNED);
+			deleg = fxdr_unsigned(uint32_t, *tl);
+			if (deleg == NFSV4OPEN_CONTENTION ||
+			    deleg == NFSV4OPEN_RESOURCE)
+				NFSM_DISSECT(tl, uint32_t *, NFSX_UNSIGNED);
 		} else if (deleg != NFSV4OPEN_DELEGATENONE) {
 			error = NFSERR_BADXDR;
 			goto nfsmout;
@@ -2595,8 +2621,17 @@ nfsrpc_createv4(vnode_t dvp, char *name, int namelen, struct vattr *vap,
 	 */
 	NFSM_BUILD(tl, u_int32_t *, 5 * NFSX_UNSIGNED);
 	*tl++ = txdr_unsigned(owp->nfsow_seqid);
-	*tl++ = txdr_unsigned(NFSV4OPEN_ACCESSWRITE |
-	    NFSV4OPEN_ACCESSREAD);
+	if (NFSHASNFSV4N(nmp)) {
+		if (!NFSHASPNFS(nmp) && nfscl_enablecallb != 0 &&
+		    nfs_numnfscbd > 0)
+			*tl++ = txdr_unsigned(NFSV4OPEN_ACCESSWRITE |
+			    NFSV4OPEN_ACCESSREAD | NFSV4OPEN_WANTWRITEDELEG);
+		else
+			*tl++ = txdr_unsigned(NFSV4OPEN_ACCESSWRITE |
+			    NFSV4OPEN_ACCESSREAD | NFSV4OPEN_WANTNODELEG);
+	} else
+		*tl++ = txdr_unsigned(NFSV4OPEN_ACCESSWRITE |
+		    NFSV4OPEN_ACCESSREAD);
 	*tl++ = txdr_unsigned(NFSV4OPEN_DENYNONE);
 	tsep = nfsmnt_mdssession(nmp);
 	*tl++ = tsep->nfsess_clientid.lval[0];
@@ -2714,6 +2749,13 @@ nfsrpc_createv4(vnode_t dvp, char *name, int namelen, struct vattr *vap,
 			    &ret, &acesize, p);
 			if (error)
 				goto nfsmout;
+		} else if (deleg == NFSV4OPEN_DELEGATENONEEXT &&
+		    NFSHASNFSV4N(nmp)) {
+			NFSM_DISSECT(tl, uint32_t *, NFSX_UNSIGNED);
+			deleg = fxdr_unsigned(uint32_t, *tl);
+			if (deleg == NFSV4OPEN_CONTENTION ||
+			    deleg == NFSV4OPEN_RESOURCE)
+				NFSM_DISSECT(tl, uint32_t *, NFSX_UNSIGNED);
 		} else if (deleg != NFSV4OPEN_DELEGATENONE) {
 			error = NFSERR_BADXDR;
 			goto nfsmout;
@@ -8109,7 +8151,8 @@ nfsrpc_openlayoutrpc(struct nfsmount *nmp, vnode_t vp, u_int8_t *nfhp,
 	    0, 0, cred);
 	NFSM_BUILD(tl, uint32_t *, 5 * NFSX_UNSIGNED);
 	*tl++ = txdr_unsigned(op->nfso_own->nfsow_seqid);
-	*tl++ = txdr_unsigned(mode & NFSV4OPEN_ACCESSBOTH);
+	*tl++ = txdr_unsigned(mode & (NFSV4OPEN_ACCESSBOTH |
+	    NFSV4OPEN_WANTDELEGMASK));
 	*tl++ = txdr_unsigned((mode >> NFSLCK_SHIFT) & NFSV4OPEN_DENYBOTH);
 	tsep = nfsmnt_mdssession(nmp);
 	*tl++ = tsep->nfsess_clientid.lval[0];
@@ -8210,6 +8253,13 @@ nfsrpc_openlayoutrpc(struct nfsmount *nmp, vnode_t vp, u_int8_t *nfhp,
 			    &ret, &acesize, p);
 			if (error != 0)
 				goto nfsmout;
+		} else if (deleg == NFSV4OPEN_DELEGATENONEEXT &&
+		    NFSHASNFSV4N(nmp)) {
+			NFSM_DISSECT(tl, uint32_t *, NFSX_UNSIGNED);
+			deleg = fxdr_unsigned(uint32_t, *tl);
+			if (deleg == NFSV4OPEN_CONTENTION ||
+			    deleg == NFSV4OPEN_RESOURCE)
+				NFSM_DISSECT(tl, uint32_t *, NFSX_UNSIGNED);
 		} else if (deleg != NFSV4OPEN_DELEGATENONE) {
 			error = NFSERR_BADXDR;
 			goto nfsmout;
@@ -8301,8 +8351,17 @@ nfsrpc_createlayout(vnode_t dvp, char *name, int namelen, struct vattr *vap,
 	 */
 	NFSM_BUILD(tl, u_int32_t *, 5 * NFSX_UNSIGNED);
 	*tl++ = txdr_unsigned(owp->nfsow_seqid);
-	*tl++ = txdr_unsigned(NFSV4OPEN_ACCESSWRITE |
-	    NFSV4OPEN_ACCESSREAD);
+	if (NFSHASNFSV4N(nmp)) {
+		if (!NFSHASPNFS(nmp) && nfscl_enablecallb != 0 &&
+		    nfs_numnfscbd > 0)
+			*tl++ = txdr_unsigned(NFSV4OPEN_ACCESSWRITE |
+			    NFSV4OPEN_ACCESSREAD | NFSV4OPEN_WANTWRITEDELEG);
+		else
+			*tl++ = txdr_unsigned(NFSV4OPEN_ACCESSWRITE |
+			    NFSV4OPEN_ACCESSREAD | NFSV4OPEN_WANTNODELEG);
+	} else
+		*tl++ = txdr_unsigned(NFSV4OPEN_ACCESSWRITE |
+		    NFSV4OPEN_ACCESSREAD);
 	*tl++ = txdr_unsigned(NFSV4OPEN_DENYNONE);
 	tsep = nfsmnt_mdssession(nmp);
 	*tl++ = tsep->nfsess_clientid.lval[0];
diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c
index 9fbaa6e63a56..0a1eb51e279f 100644
--- a/sys/fs/nfsclient/nfs_clstate.c
+++ b/sys/fs/nfsclient/nfs_clstate.c
@@ -93,9 +93,8 @@ NFSREQSPINLOCK;
 NFSCLSTATEMUTEX;
 int nfscl_inited = 0;
 struct nfsclhead nfsclhead;	/* Head of clientid list */
-int nfscl_deleghighwater = NFSCLDELEGHIGHWATER;
-int nfscl_layouthighwater = NFSCLLAYOUTHIGHWATER;
 
+static int nfscl_deleghighwater = NFSCLDELEGHIGHWATER;
 static int nfscl_delegcnt = 0;
 static int nfscl_layoutcnt = 0;
 static int nfscl_getopen(struct nfsclownerhead *, struct nfsclopenhash *,
@@ -440,18 +439,6 @@ nfscl_deleg(mount_t mp, struct nfsclclient *clp, u_int8_t *nfhp,
 
 	KASSERT(mp != NULL, ("nfscl_deleg: mp NULL"));
 	nmp = VFSTONFS(mp);
-	/*
-	 * First, if we have received a Read delegation for a file on a
-	 * read/write file system, just return it, because they aren't
-	 * useful, imho.
-	 */
-	if (dp != NULL && !NFSMNT_RDONLY(mp) &&
-	    (dp->nfsdl_flags & NFSCLDL_READ)) {
-		nfscl_trydelegreturn(dp, cred, nmp, p);
-		free(dp, M_NFSCLDELEG);
-		*dpp = NULL;
-		return (0);
-	}
 
 	/*
 	 * Since a delegation might be added to the mount,
@@ -479,17 +466,35 @@ nfscl_deleg(mount_t mp, struct nfsclclient *clp, u_int8_t *nfhp,
 		nfscl_delegcnt++;
 	} else {
 		/*
-		 * Delegation already exists, what do we do if a new one??
+		 * A delegation already exists.  If the new one is a Write
+		 * delegation and the old one a Read delegation, return the
+		 * Read delegation.  Otherwise, return the new delegation.
 		 */
 		if (dp != NULL) {
-			printf("Deleg already exists!\n");
-			free(dp, M_NFSCLDELEG);
-			*dpp = NULL;
+			if ((dp->nfsdl_flags & NFSCLDL_WRITE) != 0 &&
+			    (tdp->nfsdl_flags & NFSCLDL_READ) != 0) {
+				TAILQ_REMOVE(&clp->nfsc_deleg, tdp, nfsdl_list);
+				LIST_REMOVE(tdp, nfsdl_hash);
+				*dpp = NULL;
+				TAILQ_INSERT_HEAD(&clp->nfsc_deleg, dp,
+				    nfsdl_list);
+				LIST_INSERT_HEAD(NFSCLDELEGHASH(clp, nfhp,
+				    fhlen), dp, nfsdl_hash);
+				dp->nfsdl_timestamp = NFSD_MONOSEC + 120;
+			} else {
+				*dpp = NULL;
+				tdp = dp;	/* Return this one. */
+			}
 		} else {
 			*dpp = tdp;
+			tdp = NULL;
 		}
 	}
 	NFSUNLOCKCLSTATE();
+	if (tdp != NULL) {
+		nfscl_trydelegreturn(tdp, cred, nmp, p);
+		free(tdp, M_NFSCLDELEG);
+	}
 	return (0);
 }
 
@@ -4647,7 +4652,7 @@ nfscl_mustflush(vnode_t vp)
 
 	np = VTONFS(vp);
 	nmp = VFSTONFS(vp->v_mount);
-	if (!NFSHASNFSV4(nmp))
+	if (!NFSHASNFSV4(nmp) || vp->v_type != VREG)
 		return (1);
 	NFSLOCKMNT(nmp);
 	if ((nmp->nm_privflag & NFSMNTP_DELEGISSUED) == 0) {
@@ -4687,7 +4692,7 @@ nfscl_nodeleg(vnode_t vp, int writedeleg)
 
 	np = VTONFS(vp);
 	nmp = VFSTONFS(vp->v_mount);
-	if (!NFSHASNFSV4(nmp))
+	if (!NFSHASNFSV4(nmp) || vp->v_type != VREG)
 		return (1);
 	NFSLOCKMNT(nmp);
 	if ((nmp->nm_privflag & NFSMNTP_DELEGISSUED) == 0) {
diff --git a/sys/fs/nfsclient/nfs_clsubs.c b/sys/fs/nfsclient/nfs_clsubs.c
index 80ab979d22d7..8bb51e29e1d1 100644
--- a/sys/fs/nfsclient/nfs_clsubs.c
+++ b/sys/fs/nfsclient/nfs_clsubs.c
@@ -188,7 +188,7 @@ ncl_getattrcache(struct vnode *vp, struct vattr *vaper)
 	np = VTONFS(vp);
 	vap = &np->n_vattr.na_vattr;
 	nmp = VFSTONFS(vp->v_mount);
-	mustflush = nfscl_mustflush(vp);	/* must be before mtx_lock() */
+	mustflush = nfscl_nodeleg(vp, 0);	/* must be before mtx_lock() */
 	NFSLOCKNODE(np);
 	/* XXX n_mtime doesn't seem to be updated on a miss-and-reload */
 	timeo = (time_second - np->n_mtime.tv_sec) / 10;
@@ -221,8 +221,8 @@ ncl_getattrcache(struct vnode *vp, struct vattr *vaper)
 		    (time_second - np->n_attrstamp), timeo);
 #endif
 
-	if ((time_second - np->n_attrstamp) >= timeo &&
-	    (mustflush != 0 || np->n_attrstamp == 0)) {
+	if (mustflush != 0 && (np->n_attrstamp == 0 ||
+	    time_second - np->n_attrstamp >= timeo)) {
 		nfsstatsv1.attrcache_misses++;
 		NFSUNLOCKNODE(np);
 		KDTRACE_NFS_ATTRCACHE_GET_MISS(vp);
diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c
index 76a3cdf9281e..13341dfc26e0 100644
--- a/sys/fs/nfsclient/nfs_clvnops.c
+++ b/sys/fs/nfsclient/nfs_clvnops.c
@@ -940,7 +940,7 @@ nfs_close(struct vop_close_args *ap)
 		/*
 		 * Get attributes so "change" is up to date.
 		 */
-		if (error == 0 && nfscl_mustflush(vp) != 0 &&
+		if (error == 0 && nfscl_nodeleg(vp, 0) != 0 &&
 		    vp->v_type == VREG &&
 		    (VFSTONFS(vp->v_mount)->nm_flag & NFSMNT_NOCTO) == 0) {
 			ret = nfsrpc_getattr(vp, cred, ap->a_td, &nfsva);
diff --git a/sys/fs/nfsserver/nfs_nfsdserv.c b/sys/fs/nfsserver/nfs_nfsdserv.c
index 0c8bda6dc6a6..47e3a20390f4 100644
--- a/sys/fs/nfsserver/nfs_nfsdserv.c
+++ b/sys/fs/nfsserver/nfs_nfsdserv.c
@@ -3244,6 +3244,13 @@ nfsrvd_open(struct nfsrv_descript *nd, __unused int isdgram,
 				NFSM_BUILD(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
 				*tl++ = txdr_unsigned(NFSV4OPEN_RESOURCE);
 				*tl = newnfs_false;
+			} else if ((rflags &
+			    NFSV4OPEN_WDNOTSUPPDOWNGRADE) != 0) {
+				NFSM_BUILD(tl, uint32_t *, NFSX_UNSIGNED);
+				*tl = txdr_unsigned(NFSV4OPEN_NOTSUPPDOWNGRADE);
+			} else if ((rflags & NFSV4OPEN_WDNOTSUPPUPGRADE) != 0) {
+				NFSM_BUILD(tl, uint32_t *, NFSX_UNSIGNED);
+				*tl = txdr_unsigned(NFSV4OPEN_NOTSUPPUPGRADE);
 			} else {
 				NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
 				*tl = txdr_unsigned(NFSV4OPEN_NOTWANTED);
diff --git a/sys/fs/nfsserver/nfs_nfsdstate.c b/sys/fs/nfsserver/nfs_nfsdstate.c
index c73840277022..ce3f3481f04a 100644
--- a/sys/fs/nfsserver/nfs_nfsdstate.c
+++ b/sys/fs/nfsserver/nfs_nfsdstate.c
@@ -240,6 +240,11 @@ static int nfsrv_createdsfile(vnode_t vp, fhandle_t *fhp, struct pnfsdsfile *pf,
 static struct nfsdevice *nfsrv_findmirroredds(struct nfsmount *nmp);
 static int nfsrv_checkmachcred(int op, struct nfsrv_descript *nd,
     struct nfsclient *clp);
+static void nfsrv_issuedelegation(struct vnode *vp, struct nfsclient *clp,
+    struct nfsrv_descript *nd, int delegate, int writedeleg, int readonly,
+    u_quad_t filerev, uint64_t rdonly, struct nfsstate **new_delegp,
+    struct nfsstate *new_stp, struct nfslockfile *lfp, uint32_t *rflagsp,
+    nfsv4stateid_t *delegstateidp);
 
 /*
  * Scan the client list for a match and either return the current one,
@@ -442,7 +447,8 @@ nfsrv_setclient(struct nfsrv_descript *nd, struct nfsclient **new_clpp,
 		/*
 		 * If the verifier has changed, the client has rebooted
 		 * and a new client id is issued. The old state info
-		 * can be thrown away once the SETCLIENTID_CONFIRM occurs.
+		 * can be thrown away once the SetClientID_Confirm or
+		 * Create_Session that confirms the clientid occurs.
 		 */
 		LIST_REMOVE(clp, lc_hash);
 
@@ -2648,6 +2654,8 @@ nfsrv_opencheck(nfsquad_t clientid, nfsv4stateid_t *stateidp,
 	 *    considered a conflict since the client with a read delegation
 	 *    could have done an Open with ReadAccess and WriteDeny
 	 *    locally and then not have checked for the WriteDeny.)
+	 *    The exception is a NFSv4.1/4.2 client that has requested
+	 *    an atomic upgrade to a write delegation.
 	 * Don't check for a Reclaim, since that will be dealt with
 	 * by nfsrv_openctrl().
 	 */
@@ -2657,9 +2665,10 @@ nfsrv_opencheck(nfsquad_t clientid, nfsv4stateid_t *stateidp,
 	    while (stp != LIST_END(&lfp->lf_deleg)) {
 		nstp = LIST_NEXT(stp, ls_file);
 		if ((readonly && stp->ls_clp != clp &&
-		       (stp->ls_flags & NFSLCK_DELEGWRITE)) ||
+		     (stp->ls_flags & NFSLCK_DELEGWRITE) != 0) ||
 		    (!readonly && (stp->ls_clp != clp ||
-		         (stp->ls_flags & NFSLCK_DELEGREAD)))) {
+		     ((stp->ls_flags & NFSLCK_DELEGREAD) != 0 &&
+		      (new_stp->ls_flags & NFSLCK_WANTWDELEG) == 0)))) {
 			ret = nfsrv_delegconflict(stp, &haslock, p, vp);
 			if (ret) {
 			    /*
@@ -2944,6 +2953,8 @@ nfsrv_openctrl(struct nfsrv_descript *nd, vnode_t vp,
 	 *    considered a conflict since the client with a read delegation
 	 *    could have done an Open with ReadAccess and WriteDeny
 	 *    locally and then not have checked for the WriteDeny.)
+	 *    The exception is a NFSv4.1/4.2 client that has requested
+	 *    an atomic upgrade to a write delegation.
 	 */
 	if (!(new_stp->ls_flags & (NFSLCK_DELEGPREV | NFSLCK_DELEGCUR))) {
 	    stp = LIST_FIRST(&lfp->lf_deleg);
@@ -2951,12 +2962,15 @@ nfsrv_openctrl(struct nfsrv_descript *nd, vnode_t vp,
 		nstp = LIST_NEXT(stp, ls_file);
 		if (stp->ls_clp != clp && (stp->ls_flags & NFSLCK_DELEGREAD))
 			writedeleg = 0;
-		else
+		else if (stp->ls_clp != clp ||
+		    (stp->ls_flags & NFSLCK_DELEGWRITE) != 0 ||
+		    (new_stp->ls_flags & NFSLCK_WANTWDELEG) == 0)
 			delegate = 0;
 		if ((readonly && stp->ls_clp != clp &&
-		       (stp->ls_flags & NFSLCK_DELEGWRITE)) ||
+		     (stp->ls_flags & NFSLCK_DELEGWRITE) != 0) ||
 		    (!readonly && (stp->ls_clp != clp ||
-		         (stp->ls_flags & NFSLCK_DELEGREAD)))) {
+		     ((stp->ls_flags & NFSLCK_DELEGREAD) != 0 &&
+		      (new_stp->ls_flags & NFSLCK_WANTWDELEG) == 0)))) {
 		    if (new_stp->ls_flags & NFSLCK_RECLAIM) {
 			delegate = 2;
 		    } else {
@@ -3204,47 +3218,9 @@ nfsrv_openctrl(struct nfsrv_descript *nd, vnode_t vp,
 		    /*
 		     * This is where we can choose to issue a delegation.
 		     */
-		    if ((new_stp->ls_flags & NFSLCK_WANTNODELEG) != 0)
-			*rflagsp |= NFSV4OPEN_WDNOTWANTED;
-		    else if (nfsrv_issuedelegs == 0)
-			*rflagsp |= NFSV4OPEN_WDSUPPFTYPE;
-		    else if (NFSRV_V4DELEGLIMIT(nfsrv_delegatecnt))
-			*rflagsp |= NFSV4OPEN_WDRESOURCE;
-		    else if (delegate == 0 || writedeleg == 0 ||
-			NFSVNO_EXRDONLY(exp) || (readonly != 0 &&
-			nfsrv_writedelegifpos == 0) ||
-			!NFSVNO_DELEGOK(vp) ||
-			(new_stp->ls_flags & NFSLCK_WANTRDELEG) != 0 ||
-			(clp->lc_flags & (LCL_CALLBACKSON | LCL_CBDOWN)) !=
-			 LCL_CALLBACKSON)
-			*rflagsp |= NFSV4OPEN_WDCONTENTION;
-		    else {
-			new_deleg->ls_stateid.seqid = delegstateidp->seqid = 1;
-			new_deleg->ls_stateid.other[0] = delegstateidp->other[0]
-			    = clp->lc_clientid.lval[0];
-			new_deleg->ls_stateid.other[1] = delegstateidp->other[1]
-			    = clp->lc_clientid.lval[1];
-			new_deleg->ls_stateid.other[2] = delegstateidp->other[2]
-			    = nfsrv_nextstateindex(clp);
-			new_deleg->ls_flags = (NFSLCK_DELEGWRITE |
-			    NFSLCK_READACCESS | NFSLCK_WRITEACCESS);
-			*rflagsp |= NFSV4OPEN_WRITEDELEGATE;
-			new_deleg->ls_uid = new_stp->ls_uid;
-			new_deleg->ls_lfp = lfp;
-			new_deleg->ls_clp = clp;
-			new_deleg->ls_filerev = filerev;
-			new_deleg->ls_compref = nd->nd_compref;
-			new_deleg->ls_lastrecall = 0;
-			nfsrv_writedelegcnt++;
-			LIST_INSERT_HEAD(&lfp->lf_deleg, new_deleg, ls_file);
-			LIST_INSERT_HEAD(NFSSTATEHASH(clp,
-			    new_deleg->ls_stateid), new_deleg, ls_hash);
-			LIST_INSERT_HEAD(&clp->lc_deleg, new_deleg, ls_list);
-			new_deleg = NULL;
-			NFSD_VNET(nfsstatsv1_p)->srvdelegates++;
-			nfsrv_openpluslock++;
-			nfsrv_delegatecnt++;
-		    }
+		    nfsrv_issuedelegation(vp, clp, nd, delegate, writedeleg,
+			readonly, filerev, NFSVNO_EXRDONLY(exp), &new_deleg,
+			new_stp, lfp, rflagsp, delegstateidp);
 		} else {
 		    new_open->ls_stateid.seqid = 1;
 		    new_open->ls_stateid.other[0] = clp->lc_clientid.lval[0];
@@ -3269,52 +3245,9 @@ nfsrv_openctrl(struct nfsrv_descript *nd, vnode_t vp,
 		    /*
 		     * This is where we can choose to issue a delegation.
 		     */
-		    if ((new_stp->ls_flags & NFSLCK_WANTNODELEG) != 0)
-			*rflagsp |= NFSV4OPEN_WDNOTWANTED;
-		    else if (nfsrv_issuedelegs == 0)
-			*rflagsp |= NFSV4OPEN_WDSUPPFTYPE;
-		    else if (NFSRV_V4DELEGLIMIT(nfsrv_delegatecnt))
-			*rflagsp |= NFSV4OPEN_WDRESOURCE;
-		    else if (delegate == 0 || (writedeleg == 0 &&
-			readonly == 0) || !NFSVNO_DELEGOK(vp) ||
-			(clp->lc_flags & (LCL_CALLBACKSON | LCL_CBDOWN)) !=
-			 LCL_CALLBACKSON)
-			*rflagsp |= NFSV4OPEN_WDCONTENTION;
-		    else {
-			new_deleg->ls_stateid.seqid = delegstateidp->seqid = 1;
-			new_deleg->ls_stateid.other[0] = delegstateidp->other[0]
-			    = clp->lc_clientid.lval[0];
-			new_deleg->ls_stateid.other[1] = delegstateidp->other[1]
-			    = clp->lc_clientid.lval[1];
-			new_deleg->ls_stateid.other[2] = delegstateidp->other[2]
-			    = nfsrv_nextstateindex(clp);
-			if (writedeleg && !NFSVNO_EXRDONLY(exp) &&
-			    (nfsrv_writedelegifpos || !readonly) &&
-			    (new_stp->ls_flags & NFSLCK_WANTRDELEG) == 0) {
-			    new_deleg->ls_flags = (NFSLCK_DELEGWRITE |
-				NFSLCK_READACCESS | NFSLCK_WRITEACCESS);
-			    *rflagsp |= NFSV4OPEN_WRITEDELEGATE;
-			    nfsrv_writedelegcnt++;
-			} else {
-			    new_deleg->ls_flags = (NFSLCK_DELEGREAD |
-				NFSLCK_READACCESS);
-			    *rflagsp |= NFSV4OPEN_READDELEGATE;
-			}
-			new_deleg->ls_uid = new_stp->ls_uid;
-			new_deleg->ls_lfp = lfp;
-			new_deleg->ls_clp = clp;
-			new_deleg->ls_filerev = filerev;
-			new_deleg->ls_compref = nd->nd_compref;
-			new_deleg->ls_lastrecall = 0;
-			LIST_INSERT_HEAD(&lfp->lf_deleg, new_deleg, ls_file);
-			LIST_INSERT_HEAD(NFSSTATEHASH(clp,
-			    new_deleg->ls_stateid), new_deleg, ls_hash);
-			LIST_INSERT_HEAD(&clp->lc_deleg, new_deleg, ls_list);
-			new_deleg = NULL;
-			NFSD_VNET(nfsstatsv1_p)->srvdelegates++;
-			nfsrv_openpluslock++;
-			nfsrv_delegatecnt++;
-		    }
+		    nfsrv_issuedelegation(vp, clp, nd, delegate, writedeleg,
+			readonly, filerev, NFSVNO_EXRDONLY(exp), &new_deleg,
+			new_stp, lfp, rflagsp, delegstateidp);
 		}
 	} else {
 		/*
@@ -3337,78 +3270,28 @@ nfsrv_openctrl(struct nfsrv_descript *nd, vnode_t vp,
 		if (new_stp->ls_flags & NFSLCK_RECLAIM) {
 			new_stp->ls_flags = 0;
 		} else if ((nd->nd_flag & ND_NFSV41) != 0) {
-			/* NFSv4.1 never needs confirmation. */
-			new_stp->ls_flags = 0;
+		    /*
+		     * This is where we can choose to issue a delegation.
+		     */
+		    nfsrv_issuedelegation(vp, clp, nd, delegate, writedeleg,
+			readonly, filerev, NFSVNO_EXRDONLY(exp), &new_deleg,
+			new_stp, lfp, rflagsp, delegstateidp);
+		    /* NFSv4.1 never needs confirmation. */
+		    new_stp->ls_flags = 0;
 
-			/*
-			 * This is where we can choose to issue a delegation.
-			 */
-			if (delegate && nfsrv_issuedelegs &&
-			    (writedeleg || readonly) &&
-			    (clp->lc_flags & (LCL_CALLBACKSON | LCL_CBDOWN)) ==
-			     LCL_CALLBACKSON &&
-			    !NFSRV_V4DELEGLIMIT(nfsrv_delegatecnt) &&
-			    NFSVNO_DELEGOK(vp) &&
-			    ((nd->nd_flag & ND_NFSV41) == 0 ||
-			     (new_stp->ls_flags & NFSLCK_WANTNODELEG) == 0)) {
-				new_deleg->ls_stateid.seqid =
-				    delegstateidp->seqid = 1;
-				new_deleg->ls_stateid.other[0] =
-				    delegstateidp->other[0]
-				    = clp->lc_clientid.lval[0];
-				new_deleg->ls_stateid.other[1] =
-				    delegstateidp->other[1]
-				    = clp->lc_clientid.lval[1];
-				new_deleg->ls_stateid.other[2] =
-				    delegstateidp->other[2]
-				    = nfsrv_nextstateindex(clp);
-				if (writedeleg && !NFSVNO_EXRDONLY(exp) &&
-				    (nfsrv_writedelegifpos || !readonly) &&
-				    ((nd->nd_flag & ND_NFSV41) == 0 ||
-				     (new_stp->ls_flags & NFSLCK_WANTRDELEG) ==
-				     0)) {
-					new_deleg->ls_flags =
-					    (NFSLCK_DELEGWRITE |
-					     NFSLCK_READACCESS |
-					     NFSLCK_WRITEACCESS);
-					*rflagsp |= NFSV4OPEN_WRITEDELEGATE;
-					nfsrv_writedelegcnt++;
-				} else {
-					new_deleg->ls_flags =
-					    (NFSLCK_DELEGREAD |
-					     NFSLCK_READACCESS);
-					*rflagsp |= NFSV4OPEN_READDELEGATE;
-				}
-				new_deleg->ls_uid = new_stp->ls_uid;
-				new_deleg->ls_lfp = lfp;
-				new_deleg->ls_clp = clp;
-				new_deleg->ls_filerev = filerev;
-				new_deleg->ls_compref = nd->nd_compref;
-				new_deleg->ls_lastrecall = 0;
-				LIST_INSERT_HEAD(&lfp->lf_deleg, new_deleg,
-				    ls_file);
-				LIST_INSERT_HEAD(NFSSTATEHASH(clp,
-				    new_deleg->ls_stateid), new_deleg, ls_hash);
-				LIST_INSERT_HEAD(&clp->lc_deleg, new_deleg,
-				    ls_list);
-				new_deleg = NULL;
-				NFSD_VNET(nfsstatsv1_p)->srvdelegates++;
-				nfsrv_openpluslock++;
-				nfsrv_delegatecnt++;
-			}
-			/*
-			 * Since NFSv4.1 never does an OpenConfirm, the first
-			 * open state will be acquired here.
-			 */
-			if (!(clp->lc_flags & LCL_STAMPEDSTABLE)) {
-				clp->lc_flags |= LCL_STAMPEDSTABLE;
-				len = clp->lc_idlen;
-				NFSBCOPY(clp->lc_id, clidp, len);
-				gotstate = 1;
-			}
+		    /*
+		     * Since NFSv4.1 never does an OpenConfirm, the first
+		     * open state will be acquired here.
+		     */
+		    if (!(clp->lc_flags & LCL_STAMPEDSTABLE)) {
+			clp->lc_flags |= LCL_STAMPEDSTABLE;
+			len = clp->lc_idlen;
+			NFSBCOPY(clp->lc_id, clidp, len);
+			gotstate = 1;
+		    }
 		} else {
-			*rflagsp |= NFSV4OPEN_RESULTCONFIRM;
-			new_stp->ls_flags = NFSLCK_NEEDSCONFIRM;
+		    *rflagsp |= NFSV4OPEN_RESULTCONFIRM;
+		    new_stp->ls_flags = NFSLCK_NEEDSCONFIRM;
 		}
 		nfsrvd_refcache(new_stp->ls_op);
 		new_stp->ls_noopens = 0;
@@ -5179,6 +5062,11 @@ nfsrv_markreclaim(struct nfsclient *clp)
 	 * Now, just set the flag.
 	 */
 	sp->nst_flag |= NFSNST_RECLAIMED;
+
+	/*
+	 * Free up any old delegations.
+	 */
+	nfsrv_freedeleglist(&clp->lc_olddeleg);
 }
 
 /*
@@ -8943,3 +8831,86 @@ nfsrv_checkmachcred(int op, struct nfsrv_descript *nd, struct nfsclient *clp)
 		return (0);
 	return (NFSERR_AUTHERR | AUTH_TOOWEAK);
 }
+
+/*
+ * Issue a delegation and, optionally set rflagsp for why not.
+ */
+static void
+nfsrv_issuedelegation(struct vnode *vp, struct nfsclient *clp,
+    struct nfsrv_descript *nd, int delegate, int writedeleg, int readonly,
+    u_quad_t filerev, uint64_t rdonly, struct nfsstate **new_delegp,
+    struct nfsstate *new_stp, struct nfslockfile *lfp, uint32_t *rflagsp,
+    nfsv4stateid_t *delegstateidp)
+{
+	struct nfsstate *up_deleg, *new_deleg;
+
+	new_deleg = *new_delegp;
+	up_deleg = LIST_FIRST(&lfp->lf_deleg);
+	if ((new_stp->ls_flags & NFSLCK_WANTNODELEG) != 0)
+		*rflagsp |= NFSV4OPEN_WDNOTWANTED;
+	else if (nfsrv_issuedelegs == 0)
+		*rflagsp |= NFSV4OPEN_WDSUPPFTYPE;
+	else if (NFSRV_V4DELEGLIMIT(nfsrv_delegatecnt))
+		*rflagsp |= NFSV4OPEN_WDRESOURCE;
+	else if (delegate == 0 || !NFSVNO_DELEGOK(vp) ||
+	    (writedeleg == 0 && (readonly == 0 ||
+	    (new_stp->ls_flags & NFSLCK_WANTWDELEG) != 0)) ||
+	    (clp->lc_flags & (LCL_CALLBACKSON | LCL_CBDOWN)) !=
+	     LCL_CALLBACKSON) {
+		/* Is this a downgrade attempt? */
+		if (up_deleg != NULL && up_deleg->ls_clp == clp &&
+		    (up_deleg->ls_flags & NFSLCK_DELEGWRITE) != 0 &&
+		    (new_stp->ls_flags & NFSLCK_WANTRDELEG) != 0)
+			*rflagsp |= NFSV4OPEN_WDNOTSUPPDOWNGRADE;
+		else
+			*rflagsp |= NFSV4OPEN_WDCONTENTION;
+	} else if (up_deleg != NULL &&
+	    (up_deleg->ls_flags & NFSLCK_DELEGREAD) != 0 &&
+	    (new_stp->ls_flags & NFSLCK_WANTWDELEG) != 0) {
+		/* This is an atomic upgrade. */
+		up_deleg->ls_stateid.seqid++;
+		delegstateidp->seqid = up_deleg->ls_stateid.seqid;
+		delegstateidp->other[0] = up_deleg->ls_stateid.other[0];
+		delegstateidp->other[1] = up_deleg->ls_stateid.other[1];
+		delegstateidp->other[2] = up_deleg->ls_stateid.other[2];
+		up_deleg->ls_flags = (NFSLCK_DELEGWRITE |
+		    NFSLCK_READACCESS | NFSLCK_WRITEACCESS);
+		*rflagsp |= NFSV4OPEN_WRITEDELEGATE;
+		nfsrv_writedelegcnt++;
+	} else {
+		new_deleg->ls_stateid.seqid = delegstateidp->seqid = 1;
+		new_deleg->ls_stateid.other[0] = delegstateidp->other[0]
+		    = clp->lc_clientid.lval[0];
+		new_deleg->ls_stateid.other[1] = delegstateidp->other[1]
+		    = clp->lc_clientid.lval[1];
+		new_deleg->ls_stateid.other[2] = delegstateidp->other[2]
+		    = nfsrv_nextstateindex(clp);
+		if (writedeleg && !rdonly &&
+		    (nfsrv_writedelegifpos || !readonly) &&
+		    (new_stp->ls_flags & (NFSLCK_WANTRDELEG |
+		     NFSLCK_WANTWDELEG)) != NFSLCK_WANTRDELEG) {
+			new_deleg->ls_flags = (NFSLCK_DELEGWRITE |
+			    NFSLCK_READACCESS | NFSLCK_WRITEACCESS);
+			*rflagsp |= NFSV4OPEN_WRITEDELEGATE;
+			nfsrv_writedelegcnt++;
+		} else {
+			new_deleg->ls_flags = (NFSLCK_DELEGREAD |
+			    NFSLCK_READACCESS);
+			*rflagsp |= NFSV4OPEN_READDELEGATE;
+		}
+		new_deleg->ls_uid = new_stp->ls_uid;
+		new_deleg->ls_lfp = lfp;
+		new_deleg->ls_clp = clp;
+		new_deleg->ls_filerev = filerev;
+		new_deleg->ls_compref = nd->nd_compref;
+		new_deleg->ls_lastrecall = 0;
+		LIST_INSERT_HEAD(&lfp->lf_deleg, new_deleg, ls_file);
+		LIST_INSERT_HEAD(NFSSTATEHASH(clp, new_deleg->ls_stateid),
+		    new_deleg, ls_hash);
+		LIST_INSERT_HEAD(&clp->lc_deleg, new_deleg, ls_list);
+		*new_delegp = NULL;
+		NFSD_VNET(nfsstatsv1_p)->srvdelegates++;
+		nfsrv_openpluslock++;
+		nfsrv_delegatecnt++;
+	}
+}
diff --git a/sys/fs/nfsserver/nfs_nfsdsubs.c b/sys/fs/nfsserver/nfs_nfsdsubs.c
index 0d7e4c73fe69..d80826993f23 100644
--- a/sys/fs/nfsserver/nfs_nfsdsubs.c
+++ b/sys/fs/nfsserver/nfs_nfsdsubs.c
@@ -57,9 +57,6 @@ NFSD_VNET_DECLARE(int, nfs_rootfhset);
 NFSD_VNET_DECLARE(uid_t, nfsrv_defaultuid);
 NFSD_VNET_DECLARE(gid_t, nfsrv_defaultgid);
 
-NFSD_VNET_DEFINE(struct nfsdontlisthead, nfsrv_dontlisthead);
-
-
 char nfs_v2pubfh[NFSX_V2FH];
 struct nfsdontlisthead nfsrv_dontlisthead;
 struct nfslayouthead nfsrv_recalllisthead;
diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c
index 67810700e6ef..5e750b48ec5e 100644
--- a/sys/i386/i386/pmap.c
+++ b/sys/i386/i386/pmap.c
@@ -962,7 +962,8 @@ pmap_ptelist_init(vm_offset_t *head, void *base, int npages)
 
 /*
  *	Initialize the pmap module.
- *	Called by vm_init, to initialize any structures that the pmap
+ *
+ *	Called by vm_mem_init(), to initialize any structures that the pmap
  *	system needs to map virtual memory.
  */
 static void
diff --git a/sys/i386/pci/pci_pir.c b/sys/i386/pci/pci_pir.c
index d3ae100a43d0..71dbb66b920b 100644
--- a/sys/i386/pci/pci_pir.c
+++ b/sys/i386/pci/pci_pir.c
@@ -654,11 +654,8 @@ pci_pir_probe(int bus, int require_parse)
 static int
 pir_probe(device_t dev)
 {
-	char buf[64];
-
-	snprintf(buf, sizeof(buf), "PCI Interrupt Routing Table: %d Entries",
+	device_set_descf(dev, "PCI Interrupt Routing Table: %d Entries",
 	    pci_route_count);
-	device_set_desc_copy(dev, buf);
 	return (0);
 }
 
diff --git a/sys/kern/init_sysent.c b/sys/kern/init_sysent.c
index a893deb73d9b..319ced33efbd 100644
--- a/sys/kern/init_sysent.c
+++ b/sys/kern/init_sysent.c
@@ -126,7 +126,7 @@ struct sysent sysent[] = {
 	{ compat(AS(ogetkerninfo_args),getkerninfo), .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC },	/* 63 = old getkerninfo */
 	{ compat(0,getpagesize), .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC },	/* 64 = old getpagesize */
 	{ .sy_narg = AS(msync_args), .sy_call = (sy_call_t *)sys_msync, .sy_auevent = AUE_MSYNC, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC },	/* 65 = msync */
-	{ .sy_narg = 0, .sy_call = (sy_call_t *)sys_vfork, .sy_auevent = AUE_VFORK, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC },	/* 66 = vfork */
+	{ .sy_narg = 0, .sy_call = (sy_call_t *)sys_vfork, .sy_auevent = AUE_VFORK, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC },	/* 66 = vfork */
 	{ .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT },			/* 67 = obsolete vread */
 	{ .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT },			/* 68 = obsolete vwrite */
 	{ .sy_narg = AS(sbrk_args), .sy_call = (sy_call_t *)sys_sbrk, .sy_auevent = AUE_SBRK, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC },	/* 69 = sbrk */
@@ -311,7 +311,7 @@ struct sysent sysent[] = {
 	{ .sy_narg = AS(ntp_gettime_args), .sy_call = (sy_call_t *)sys_ntp_gettime, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC },	/* 248 = ntp_gettime */
 	{ .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT },			/* 249 = reserved for local use */
 	{ .sy_narg = AS(minherit_args), .sy_call = (sy_call_t *)sys_minherit, .sy_auevent = AUE_MINHERIT, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC },	/* 250 = minherit */
-	{ .sy_narg = AS(rfork_args), .sy_call = (sy_call_t *)sys_rfork, .sy_auevent = AUE_RFORK, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC },	/* 251 = rfork */
+	{ .sy_narg = AS(rfork_args), .sy_call = (sy_call_t *)sys_rfork, .sy_auevent = AUE_RFORK, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC },	/* 251 = rfork */
 	{ .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT },			/* 252 = obsolete openbsd_poll */
 	{ .sy_narg = 0, .sy_call = (sy_call_t *)sys_issetugid, .sy_auevent = AUE_ISSETUGID, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC },	/* 253 = issetugid */
 	{ .sy_narg = AS(lchown_args), .sy_call = (sy_call_t *)sys_lchown, .sy_auevent = AUE_LCHOWN, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC },	/* 254 = lchown */
diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c
index 07f59f733e6a..6e0d12983a2b 100644
--- a/sys/kern/kern_malloc.c
+++ b/sys/kern/kern_malloc.c
@@ -1268,7 +1268,8 @@ malloc_init(void *data)
 	struct malloc_type_internal *mtip;
 	struct malloc_type *mtp;
 
-	KASSERT(vm_cnt.v_page_count != 0, ("malloc_register before vm_init"));
+	KASSERT(vm_cnt.v_page_count != 0,
+	    ("malloc_init() called before vm_mem_init()"));
 
 	mtp = data;
 	if (mtp->ks_version != M_VERSION)
diff --git a/sys/kern/kern_mbuf.c b/sys/kern/kern_mbuf.c
index 0897ac4cc2db..002e508e91cc 100644
--- a/sys/kern/kern_mbuf.c
+++ b/sys/kern/kern_mbuf.c
@@ -1569,6 +1569,25 @@ m_freem(struct mbuf *mb)
 		mb = m_free(mb);
 }
 
+/*
+ * Free an entire chain of mbufs and associated external buffers, following
+ * both m_next and m_nextpkt linkage.
+ * Note: doesn't support NULL argument.
+ */
+void
+m_freemp(struct mbuf *m)
+{
+	struct mbuf *n;
+
+	MBUF_PROBE1(m__freemp, m);
+	do {
+		n = m->m_nextpkt;
+		while (m != NULL)
+			m = m_free(m);
+		m = n;
+	} while (m != NULL);
+}
+
 /*
  * Temporary primitive to allow freeing without going through m_free.
  */
diff --git a/sys/kern/kern_xxx.c b/sys/kern/kern_xxx.c
index 66d99edb7da1..d6687fae0caf 100644
--- a/sys/kern/kern_xxx.c
+++ b/sys/kern/kern_xxx.c
@@ -318,7 +318,8 @@ freebsd4_uname(struct thread *td, struct freebsd4_uname_args *uap)
 {
 	int name[2], error;
 	size_t len;
-	char *s, *us;
+	const char *s;
+	char *us;
 
 	name[0] = CTL_KERN;
 	name[1] = KERN_OSTYPE;
diff --git a/sys/kern/subr_capability.c b/sys/kern/subr_capability.c
index e40c57c5307d..1f3a181a91cb 100644
--- a/sys/kern/subr_capability.c
+++ b/sys/kern/subr_capability.c
@@ -306,6 +306,25 @@ __cap_rights_is_set(const cap_rights_t *rights, ...)
 	return (ret);
 }
 
+bool
+cap_rights_is_empty(const cap_rights_t *rights)
+{
+#ifndef _KERNEL
+	cap_rights_t cap_no_rights;
+	cap_rights_init(&cap_no_rights);
+#endif
+
+	assert(CAPVER(rights) == CAP_RIGHTS_VERSION_00);
+	assert(CAPVER(&cap_no_rights) == CAP_RIGHTS_VERSION_00);
+
+	for (int i = 0; i < CAPARSIZE(rights); i++) {
+		if (rights->cr_rights[i] != cap_no_rights.cr_rights[i])
+			return (false);
+	}
+
+	return (true);
+}
+
 bool
 cap_rights_is_valid(const cap_rights_t *rights)
 {
diff --git a/sys/kern/subr_physmem.c b/sys/kern/subr_physmem.c
index 79fedf58d66d..e74a11f47c2c 100644
--- a/sys/kern/subr_physmem.c
+++ b/sys/kern/subr_physmem.c
@@ -177,7 +177,8 @@ physmem_print_tables(void)
  *
  * Updates the value at *pavail with the sum of all pages in all hw regions.
  *
- * Returns the number of pages of non-excluded memory added to the avail list.
+ * Returns the number of entries in the avail list, which is twice the number
+ * of returned regions.
  */
 static size_t
 regions_to_avail(vm_paddr_t *avail, uint32_t exflags, size_t maxavail,
diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master
index a50d7723378c..47b67e4dbaa7 100644
--- a/sys/kern/syscalls.master
+++ b/sys/kern/syscalls.master
@@ -498,7 +498,7 @@
 		    int flags
 		);
 	}
-66	AUE_VFORK	STD {
+66	AUE_VFORK	STD|CAPENABLED {
 		int vfork(void);
 	}
 67	AUE_NULL	OBSOL	vread
@@ -1465,7 +1465,7 @@
 		    int inherit
 		);
 	}
-251	AUE_RFORK	STD {
+251	AUE_RFORK	STD|CAPENABLED {
 		int rfork(
 		    int flags
 		);
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index f1e986eaa348..b10e524e6e4b 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -113,6 +113,9 @@ SDT_PROBE_DEFINE1_XLATE(sdt, , , m__free,
 SDT_PROBE_DEFINE1_XLATE(sdt, , , m__freem,
     "struct mbuf *", "mbufinfo_t *");
 
+SDT_PROBE_DEFINE1_XLATE(sdt, , , m__freemp,
+    "struct mbuf *", "mbufinfo_t *");
+
 #include <security/mac/mac_framework.h>
 
 /*
diff --git a/sys/kern/uipc_mqueue.c b/sys/kern/uipc_mqueue.c
index f7695945fcc4..5fcabbac7923 100644
--- a/sys/kern/uipc_mqueue.c
+++ b/sys/kern/uipc_mqueue.c
@@ -50,7 +50,6 @@
  *    use the IPC facility without having to mount mqueue file system.
  */
 
-#include <sys/cdefs.h>
 #include "opt_capsicum.h"
 
 #include <sys/param.h>
@@ -379,7 +378,7 @@ mqfs_fileno_free(struct mqfs_info *mi, struct mqfs_node *mn)
 static __inline struct mqfs_node *
 mqnode_alloc(void)
 {
-	return uma_zalloc(mqnode_zone, M_WAITOK | M_ZERO);
+	return (uma_zalloc(mqnode_zone, M_WAITOK | M_ZERO));
 }
 
 static __inline void
@@ -451,8 +450,8 @@ mqfs_create_node(const char *name, int namelen, struct ucred *cred, int mode,
 	node->mn_type = nodetype;
 	node->mn_refcount = 1;
 	vfs_timestamp(&node->mn_birth);
-	node->mn_ctime = node->mn_atime = node->mn_mtime
-		= node->mn_birth;
+	node->mn_ctime = node->mn_atime = node->mn_mtime =
+	    node->mn_birth;
 	node->mn_uid = cred->cr_uid;
 	node->mn_gid = cred->cr_gid;
 	node->mn_mode = mode;
@@ -812,6 +811,7 @@ mqfs_allocv(struct mount *mp, struct vnode **vpp, struct mqfs_node *pn)
 		panic("%s has unexpected type: %d", pn->mn_name, pn->mn_type);
 	}
 	sx_xunlock(&mqfs->mi_lock);
+	vn_set_state(*vpp, VSTATE_CONSTRUCTED);
 	return (0);
 }
 
@@ -1017,8 +1017,8 @@ mqfs_create(struct vop_create_args *ap)
 /*
  * Remove an entry
  */
-static
-int do_unlink(struct mqfs_node *pn, struct ucred *ucred)
+static int
+do_unlink(struct mqfs_node *pn, struct ucred *ucred)
 {
 	struct mqfs_node *parent;
 	struct mqfs_vdata *vd;
@@ -1110,9 +1110,9 @@ mqfs_reclaim(struct vop_reclaim_args *ap)
 	sx_xlock(&mqfs->mi_lock);
 	vp->v_data = NULL;
 	LIST_REMOVE(vd, mv_link);
-	uma_zfree(mvdata_zone, vd);
 	mqnode_release(pn);
 	sx_xunlock(&mqfs->mi_lock);
+	uma_zfree(mvdata_zone, vd);
 	return (0);
 }
 
@@ -1244,15 +1244,15 @@ mqfs_setattr(struct vop_setattr_args *ap)
 	td = curthread;
 	vap = ap->a_vap;
 	vp = ap->a_vp;
-	if ((vap->va_type != VNON) ||
-	    (vap->va_nlink != VNOVAL) ||
-	    (vap->va_fsid != VNOVAL) ||
-	    (vap->va_fileid != VNOVAL) ||
-	    (vap->va_blocksize != VNOVAL) ||
+	if (vap->va_type != VNON ||
+	    vap->va_nlink != VNOVAL ||
+	    vap->va_fsid != VNOVAL ||
+	    vap->va_fileid != VNOVAL ||
+	    vap->va_blocksize != VNOVAL ||
 	    (vap->va_flags != VNOVAL && vap->va_flags != 0) ||
-	    (vap->va_rdev != VNOVAL) ||
-	    ((int)vap->va_bytes != VNOVAL) ||
-	    (vap->va_gen != VNOVAL)) {
+	    vap->va_rdev != VNOVAL ||
+	    (int)vap->va_bytes != VNOVAL ||
+	    vap->va_gen != VNOVAL) {
 		return (EINVAL);
 	}
 
@@ -1281,7 +1281,7 @@ mqfs_setattr(struct vop_setattr_args *ap)
 		 * check in VOP_ACCESS() be enough?  Also, are the group bits
 		 * below definitely right?
 		 */
-		if (((ap->a_cred->cr_uid != pn->mn_uid) || uid != pn->mn_uid ||
+		if ((ap->a_cred->cr_uid != pn->mn_uid || uid != pn->mn_uid ||
 		    (gid != pn->mn_gid && !groupmember(gid, ap->a_cred))) &&
 		    (error = priv_check(td, PRIV_MQ_ADMIN)) != 0)
 			return (error);
@@ -1291,7 +1291,7 @@ mqfs_setattr(struct vop_setattr_args *ap)
 	}
 
 	if (vap->va_mode != (mode_t)VNOVAL) {
-		if ((ap->a_cred->cr_uid != pn->mn_uid) &&
+		if (ap->a_cred->cr_uid != pn->mn_uid &&
 		    (error = priv_check(td, PRIV_MQ_ADMIN)))
 			return (error);
 		pn->mn_mode = vap->va_mode;
@@ -1345,11 +1345,11 @@ mqfs_read(struct vop_read_args *ap)
 
 	mq = VTOMQ(vp);
 	snprintf(buf, sizeof(buf),
-		"QSIZE:%-10ld MAXMSG:%-10ld CURMSG:%-10ld MSGSIZE:%-10ld\n",
-		mq->mq_totalbytes,
-		mq->mq_maxmsg,
-		mq->mq_curmsgs,
-		mq->mq_msgsize);
+	    "QSIZE:%-10ld MAXMSG:%-10ld CURMSG:%-10ld MSGSIZE:%-10ld\n",
+	    mq->mq_totalbytes,
+	    mq->mq_maxmsg,
+	    mq->mq_curmsgs,
+	    mq->mq_msgsize);
 	buf[sizeof(buf)-1] = '\0';
 	len = strlen(buf);
 	error = uiomove_frombuf(buf, len, uio);
@@ -2014,7 +2014,7 @@ kern_kmq_open(struct thread *td, const char *upath, int flags, mode_t mode,
 	AUDIT_ARG_MODE(mode);
 
 	pdp = td->td_proc->p_pd;
-	cmode = (((mode & ~pdp->pd_cmask) & ALLPERMS) & ~S_ISTXT);
+	cmode = ((mode & ~pdp->pd_cmask) & ALLPERMS) & ~S_ISTXT;
 	mq = NULL;
 	if ((flags & O_CREAT) != 0 && attr != NULL) {
 		if (attr->mq_maxmsg <= 0 || attr->mq_maxmsg > maxmsg)
@@ -2809,7 +2809,7 @@ freebsd32_kmq_timedsend(struct thread *td,
 		abs_timeout = NULL;
 	waitok = !(fp->f_flag & O_NONBLOCK);
 	error = mqueue_send(mq, uap->msg_ptr, uap->msg_len,
-		uap->msg_prio, waitok, abs_timeout);
+	    uap->msg_prio, waitok, abs_timeout);
 out:
 	fdrop(fp, td);
 	return (error);
@@ -2840,7 +2840,7 @@ freebsd32_kmq_timedreceive(struct thread *td,
 		abs_timeout = NULL;
 	waitok = !(fp->f_flag & O_NONBLOCK);
 	error = mqueue_receive(mq, uap->msg_ptr, uap->msg_len,
-		uap->msg_prio, waitok, abs_timeout);
+	    uap->msg_prio, waitok, abs_timeout);
 out:
 	fdrop(fp, td);
 	return (error);
diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c
index e54cd01956bf..87b82763b5f1 100644
--- a/sys/kern/uipc_usrreq.c
+++ b/sys/kern/uipc_usrreq.c
@@ -2189,7 +2189,7 @@ unp_disconnect(struct unpcb *unp, struct unpcb *unp2)
 
 	if (m != NULL) {
 		unp_scan(m, unp_freerights);
-		m_freem(m);
+		m_freemp(m);
 	}
 }
 
@@ -3276,7 +3276,7 @@ unp_dispose(struct socket *so)
 
 	if (m != NULL) {
 		unp_scan(m, unp_freerights);
-		m_freem(m);
+		m_freemp(m);
 	}
 }
 
diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c
index 70c4dbc01c98..9ec0970628b4 100644
--- a/sys/kern/vfs_cache.c
+++ b/sys/kern/vfs_cache.c
@@ -984,6 +984,26 @@ SYSCTL_PROC(_vfs_cache, OID_AUTO, nchstats, CTLTYPE_OPAQUE | CTLFLAG_RD |
     CTLFLAG_MPSAFE, 0, 0, sysctl_nchstats, "LU",
     "VFS cache effectiveness statistics");
 
+static int
+sysctl_hitpct(SYSCTL_HANDLER_ARGS)
+{
+	long poshits, neghits, miss, total;
+	long pct;
+
+	poshits = counter_u64_fetch(numposhits);
+	neghits = counter_u64_fetch(numneghits);
+	miss = counter_u64_fetch(nummiss);
+	total = poshits + neghits + miss;
+
+	pct = 0;
+	if (total != 0)
+		pct = ((poshits + neghits) * 100) / total;
+	return (sysctl_handle_int(oidp, 0, pct, req));
+}
+SYSCTL_PROC(_vfs_cache_stats, OID_AUTO, hitpct,
+    CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD, NULL, 0, sysctl_hitpct,
+    "I", "Percentage of hits");
+
 static void
 cache_recalc_neg_min(void)
 {
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index d1c17dca37d4..646339987ba2 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -224,6 +224,10 @@ static counter_u64_t vnode_skipped_requeues;
 SYSCTL_COUNTER_U64(_vfs_vnode_stats, OID_AUTO, skipped_requeues, CTLFLAG_RD, &vnode_skipped_requeues,
     "Number of times LRU requeue was skipped due to lock contention");
 
+static __read_mostly bool vnode_can_skip_requeue;
+SYSCTL_BOOL(_vfs_vnode_param, OID_AUTO, can_skip_requeue, CTLFLAG_RW,
+    &vnode_can_skip_requeue, 0, "Is LRU requeue skippable");
+
 static u_long deferred_inact;
 SYSCTL_ULONG(_vfs, OID_AUTO, deferred_inact, CTLFLAG_RD,
     &deferred_inact, 0, "Number of times inactive processing was deferred");
@@ -3785,31 +3789,41 @@ vdbatch_process(struct vdbatch *vd)
 	 * lock contention, where vnode_list_mtx becomes the primary bottleneck
 	 * if multiple CPUs get here (one real-world example is highly parallel
 	 * do-nothing make , which will stat *tons* of vnodes). Since it is
-	 * quasi-LRU (read: not that great even if fully honoured) just dodge
-	 * the problem. Parties which don't like it are welcome to implement
-	 * something better.
+	 * quasi-LRU (read: not that great even if fully honoured) provide an
+	 * option to just dodge the problem. Parties which don't like it are
+	 * welcome to implement something better.
 	 */
-	critical_enter();
-	if (mtx_trylock(&vnode_list_mtx)) {
-		for (i = 0; i < VDBATCH_SIZE; i++) {
-			vp = vd->tab[i];
-			vd->tab[i] = NULL;
-			TAILQ_REMOVE(&vnode_list, vp, v_vnodelist);
-			TAILQ_INSERT_TAIL(&vnode_list, vp, v_vnodelist);
-			MPASS(vp->v_dbatchcpu != NOCPU);
-			vp->v_dbatchcpu = NOCPU;
+	if (vnode_can_skip_requeue) {
+		if (!mtx_trylock(&vnode_list_mtx)) {
+			counter_u64_add(vnode_skipped_requeues, 1);
+			critical_enter();
+			for (i = 0; i < VDBATCH_SIZE; i++) {
+				vp = vd->tab[i];
+				vd->tab[i] = NULL;
+				MPASS(vp->v_dbatchcpu != NOCPU);
+				vp->v_dbatchcpu = NOCPU;
+			}
+			vd->index = 0;
+			critical_exit();
+			return;
+
 		}
-		mtx_unlock(&vnode_list_mtx);
+		/* fallthrough to locked processing */
 	} else {
-		counter_u64_add(vnode_skipped_requeues, 1);
+		mtx_lock(&vnode_list_mtx);
+	}
 
-		for (i = 0; i < VDBATCH_SIZE; i++) {
-			vp = vd->tab[i];
-			vd->tab[i] = NULL;
-			MPASS(vp->v_dbatchcpu != NOCPU);
-			vp->v_dbatchcpu = NOCPU;
-		}
+	mtx_assert(&vnode_list_mtx, MA_OWNED);
+	critical_enter();
+	for (i = 0; i < VDBATCH_SIZE; i++) {
+		vp = vd->tab[i];
+		vd->tab[i] = NULL;
+		TAILQ_REMOVE(&vnode_list, vp, v_vnodelist);
+		TAILQ_INSERT_TAIL(&vnode_list, vp, v_vnodelist);
+		MPASS(vp->v_dbatchcpu != NOCPU);
+		vp->v_dbatchcpu = NOCPU;
 	}
+	mtx_unlock(&vnode_list_mtx);
 	vd->index = 0;
 	critical_exit();
 }
diff --git a/sys/modules/Makefile b/sys/modules/Makefile
index 4b4534aee076..56a28b4b71ec 100644
--- a/sys/modules/Makefile
+++ b/sys/modules/Makefile
@@ -216,12 +216,14 @@ SUBDIR=	\
 	lindebugfs \
 	linuxkpi \
 	linuxkpi_hdmi \
+	linuxkpi_video \
 	linuxkpi_wlan \
 	${_lio} \
 	lpt \
 	${_mac_biba} \
 	${_mac_bsdextended} \
 	${_mac_ddb} \
+	${_mac_do} \
 	${_mac_ifoff} \
 	${_mac_ipacl} \
 	${_mac_lomac} \
@@ -436,8 +438,8 @@ SUBDIR+=	dtrace
 SUBDIR+=	opensolaris
 .endif
 
-# Requires bus_space_read_8
-.if ${MACHINE_ARCH} != "i386"
+.if ${MACHINE_ARCH} != "i386" && ${MACHINE_CPUARCH} != "arm" && \
+    ${MACHINE_ARCH} != "powerpc" && ${MACHINE_ARCH} != "powerpcspe"
 _bnxt=		bnxt
 .endif
 
@@ -585,6 +587,7 @@ _mac_bsdextended= mac_bsdextended
 .if ${KERN_OPTS:MDDB} || defined(ALL_MODULES)
 _mac_ddb=	mac_ddb
 .endif
+_mac_do=	mac_do
 _mac_ifoff=	mac_ifoff
 _mac_ipacl=	mac_ipacl
 _mac_lomac=	mac_lomac
diff --git a/sys/modules/bnxt/Makefile b/sys/modules/bnxt/Makefile
index 5cef9f8d5343..32aec4806a2c 100644
--- a/sys/modules/bnxt/Makefile
+++ b/sys/modules/bnxt/Makefile
@@ -1,14 +1,4 @@
+SUBDIR=	bnxt_en	\
+	bnxt_re
 
-.PATH:  ${SRCTOP}/sys/dev/bnxt
-
-KMOD    = if_bnxt
-SRCS    = device_if.h bus_if.h pci_if.h pci_iov_if.h ifdi_if.h
-SRCS	+= opt_inet.h opt_inet6.h opt_rss.h
-SRCS    += bnxt_txrx.c if_bnxt.c
-SRCS	+= bnxt_hwrm.c
-SRCS	+= bnxt_sysctl.c
-SRCS	+= bnxt_mgmt.c
-
-CFLAGS+= -DIFLIB
-
-.include <bsd.kmod.mk>
+.include <bsd.subdir.mk>
diff --git a/sys/modules/bnxt/bnxt_en/Makefile b/sys/modules/bnxt/bnxt_en/Makefile
new file mode 100644
index 000000000000..de08d7c500c4
--- /dev/null
+++ b/sys/modules/bnxt/bnxt_en/Makefile
@@ -0,0 +1,20 @@
+
+.PATH:  ${SRCTOP}/sys/dev/bnxt/bnxt_en
+
+KMOD    = if_bnxt
+SRCS    = device_if.h bus_if.h pci_if.h pci_iov_if.h ifdi_if.h
+SRCS	+= opt_inet.h opt_inet6.h opt_rss.h
+SRCS    += bnxt_txrx.c if_bnxt.c
+SRCS	+= bnxt_hwrm.c
+SRCS	+= bnxt_sysctl.c
+SRCS	+= bnxt_mgmt.c
+SRCS	+= bnxt_dcb.c bnxt_dcb.h
+SRCS	+= bnxt_auxbus_compat.c bnxt_auxbus_compat.h
+SRCS	+= bnxt_ulp.c bnxt_ulp.h
+SRCS	+= ${LINUXKPI_GENSRCS}
+
+CFLAGS+= -DIFLIB
+CFLAGS+= -I${SRCTOP}/sys/ofed/include
+CFLAGS+= -I${SRCTOP}/sys/compat/linuxkpi/common/include
+
+.include <bsd.kmod.mk>
diff --git a/sys/modules/bnxt/bnxt_re/Makefile b/sys/modules/bnxt/bnxt_re/Makefile
new file mode 100644
index 000000000000..d6aa701dbae6
--- /dev/null
+++ b/sys/modules/bnxt/bnxt_re/Makefile
@@ -0,0 +1,22 @@
+.PATH:	${SRCTOP}/sys/dev/bnxt/bnxt_re
+
+KMOD=bnxt_re
+SRCS	+= ib_verbs.c ib_verbs.h
+SRCS	+= qplib_fp.c qplib_fp.h
+SRCS	+= qplib_sp.c qplib_sp.h
+SRCS	+= qplib_res.c qplib_res.h
+SRCS	+= qplib_rcfw.c qplib_rcfw.h
+SRCS	+= stats.c stats.h
+SRCS	+= main.c bnxt_re.h
+SRCS	+= opt_inet.h opt_inet6.h opt_ratelimit.h
+SRCS	+= ${LINUXKPI_GENSRCS}
+
+CFLAGS+= -I${SRCTOP}/sys/dev/bnxt/bnxt_en
+CFLAGS+= -I${SRCTOP}/sys/ofed/include
+CFLAGS+= -I${SRCTOP}/sys/ofed/include/uapi
+CFLAGS+= ${LINUXKPI_INCLUDES}
+CFLAGS+= -DCONFIG_INFINIBAND_USER_MEM
+
+.include <bsd.kmod.mk>
+
+CFLAGS+= -Wno-cast-qual -Wno-pointer-arith ${GCC_MS_EXTENSIONS}
diff --git a/sys/modules/hyperv/vmbus/Makefile b/sys/modules/hyperv/vmbus/Makefile
index 1659d5186493..9863f4db46ca 100644
--- a/sys/modules/hyperv/vmbus/Makefile
+++ b/sys/modules/hyperv/vmbus/Makefile
@@ -14,8 +14,8 @@ SRCS=	hyperv.c \
 	vmbus_res.c \
 	vmbus_xact.c
 
-.if ${MACHINE_CPUARCH} != "i386" && ${MACHINE_CPUARCH} != "aarch64"
-SRCS+=	vmbus_vector.S
+.if ${MACHINE_CPUARCH} == "amd64"
+SRCS+=	vmbus_vector.S hyperv_mmu.c
 .endif
 .if ${MACHINE_CPUARCH} != "aarch64"
 SRCS+= vmbus_et.c hyperv_x86.c vmbus_x86.c
diff --git a/sys/modules/linux/Makefile b/sys/modules/linux/Makefile
index d1035445ccfb..ff960ba28efb 100644
--- a/sys/modules/linux/Makefile
+++ b/sys/modules/linux/Makefile
@@ -34,9 +34,11 @@ SRCS=	linux${SFX}_dummy_machdep.c \
 	linux_uid16.c \
 	linux_vdso.c \
 	linux_xattr.c \
+	opt_inet.h \
 	opt_inet6.h \
 	opt_ktrace.h \
 	opt_posix.h \
+	opt_usb.h \
 	bus_if.h \
 	device_if.h \
 	vnode_if.h
diff --git a/sys/modules/linuxkpi_hdmi/Makefile b/sys/modules/linuxkpi_hdmi/Makefile
index ef843c726dac..dc19c0afeebc 100644
--- a/sys/modules/linuxkpi_hdmi/Makefile
+++ b/sys/modules/linuxkpi_hdmi/Makefile
@@ -2,6 +2,7 @@
 
 KMOD=	linuxkpi_hdmi
 SRCS=	linux_hdmi.c \
+	linuxkpi_hdmikmod.c
 
 SRCS+=	${LINUXKPI_GENSRCS}
 
diff --git a/sys/modules/linuxkpi_video/Makefile b/sys/modules/linuxkpi_video/Makefile
new file mode 100644
index 000000000000..a9562eaf4735
--- /dev/null
+++ b/sys/modules/linuxkpi_video/Makefile
@@ -0,0 +1,15 @@
+.PATH:	${SRCTOP}/sys/compat/linuxkpi/common/src
+
+KMOD=	linuxkpi_video
+SRCS=	linux_hdmi.c \
+	linux_aperture.c \
+	linuxkpi_videokmod.c
+
+SRCS+=	${LINUXKPI_GENSRCS}
+
+CFLAGS+=		${LINUXKPI_INCLUDES}
+CFLAGS.linux_hdmi.c=	-Wno-cast-qual
+
+EXPORT_SYMS=	YES
+
+.include <bsd.kmod.mk>
diff --git a/sys/modules/mac_do/Makefile b/sys/modules/mac_do/Makefile
new file mode 100644
index 000000000000..532a5b9faa71
--- /dev/null
+++ b/sys/modules/mac_do/Makefile
@@ -0,0 +1,6 @@
+.PATH: ${SRCTOP}/sys/security/mac_do
+
+KMOD=	mac_do
+SRCS=	mac_do.c vnode_if.h
+
+.include <bsd.kmod.mk>
diff --git a/sys/modules/puc/Makefile b/sys/modules/puc/Makefile
index 6e14ce0ed268..cfd48bee5ff9 100644
--- a/sys/modules/puc/Makefile
+++ b/sys/modules/puc/Makefile
@@ -1,8 +1,8 @@
 
-.PATH:	${SRCTOP}/sys/dev/puc
+.PATH:	${SRCTOP}/sys/dev/puc ${SRCTOP}/sys/dev/uart/
 
 KMOD=	puc
-SRCS=	puc.c puc_cfg.c puc_pci.c
+SRCS=	puc.c puc_cfg.c puc_pci.c uart_bus_puc.c
 SRCS+=	bus_if.h device_if.h serdev_if.c serdev_if.h pci_if.h
 
 .include <bsd.kmod.mk>
diff --git a/sys/modules/usb/Makefile b/sys/modules/usb/Makefile
index 2c593495b9a4..e82bdd615f68 100644
--- a/sys/modules/usb/Makefile
+++ b/sys/modules/usb/Makefile
@@ -48,8 +48,8 @@ SUBDIR += ${_dwc_otg} ehci ${_musb} ohci uhci xhci ${_uss820dci} \
 SUBDIR += ${_rum} ${_run} ${_runfw} ${_uath} upgt usie ural ${_zyd} ${_urtw} 
 SUBDIR += atp cfumass uhid uhid_snes ukbd ums udbp uep wmt wsp ugold uled \
 	  usbhid
-SUBDIR += ucom u3g uark ubsa ubser uchcom ucycom ufoma uftdi ugensa uipaq ulpt \
-	  umct umcs umodem umoscom uplcom uslcom uvisor uvscom
+SUBDIR += ucom u3g uark ubsa ubser uchcom ucycom udbc ufoma uftdi ugensa \
+	  uipaq ulpt umct umcs umodem umoscom uplcom uslcom uvisor uvscom
 SUBDIR += cp2112
 SUBDIR += udl
 SUBDIR += uether aue axe axge cdce cdceem cue ${_kue} mos rue smsc udav uhso \
diff --git a/sys/modules/usb/udbc/Makefile b/sys/modules/usb/udbc/Makefile
new file mode 100644
index 000000000000..9996b2e391fb
--- /dev/null
+++ b/sys/modules/usb/udbc/Makefile
@@ -0,0 +1,9 @@
+S=     ${SRCTOP}/sys
+
+.PATH: $S/dev/usb/serial
+
+KMOD=	udbc
+SRCS=	opt_bus.h opt_usb.h device_if.h bus_if.h usb_if.h usbdevs.h \
+	udbc.c
+
+.include <bsd.kmod.mk>
diff --git a/sys/net/bpf.h b/sys/net/bpf.h
index 924dea5fc9f4..7b76129aec94 100644
--- a/sys/net/bpf.h
+++ b/sys/net/bpf.h
@@ -435,15 +435,13 @@ int	 bpf_get_bp_params(struct bpf_if *, u_int *, u_int *);
 void	 bpfilterattach(int);
 u_int	 bpf_filter(const struct bpf_insn *, u_char *, u_int, u_int);
 
-static __inline int
+static __inline bool
 bpf_peers_present(struct bpf_if *bpf)
 {
 	struct bpf_if_ext *ext;
 
 	ext = (struct bpf_if_ext *)bpf;
-	if (!CK_LIST_EMPTY(&ext->bif_dlist))
-		return (1);
-	return (0);
+	return (!CK_LIST_EMPTY(&ext->bif_dlist));
 }
 
 #define	BPF_TAP(_ifp,_pkt,_pktlen)				\
diff --git a/sys/net/if.c b/sys/net/if.c
index 1ca0893eb724..110ab73f2aad 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -596,7 +596,7 @@ if_alloc_domain(u_char type, int numa_domain)
 		old = ifindex_table;
 		ck_pr_store_ptr(&ifindex_table, new);
 		if_indexlim = newlim;
-		epoch_wait_preempt(net_epoch_preempt);
+		NET_EPOCH_WAIT();
 		free(old, M_IFNET);
 	}
 	if (idx > if_index)
@@ -1134,7 +1134,7 @@ if_detach_internal(struct ifnet *ifp, bool vmove)
 	 * At this point we know the interface still was on the ifnet list
 	 * and we removed it so we are in a stable state.
 	 */
-	epoch_wait_preempt(net_epoch_preempt);
+	NET_EPOCH_WAIT();
 
 	/*
 	 * Ensure all pending EPOCH(9) callbacks have been executed. This
@@ -1267,20 +1267,8 @@ if_detach_internal(struct ifnet *ifp, bool vmove)
 static int
 if_vmove(struct ifnet *ifp, struct vnet *new_vnet)
 {
-#ifdef DEV_BPF
-	u_int bif_dlt, bif_hdrlen;
-#endif
 	int rc;
 
-#ifdef DEV_BPF
- 	/*
-	 * if_detach_internal() will call the eventhandler to notify
-	 * interface departure.  That will detach if_bpf.  We need to
-	 * safe the dlt and hdrlen so we can re-attach it later.
-	 */
-	bpf_get_bp_params(ifp->if_bpf, &bif_dlt, &bif_hdrlen);
-#endif
-
 	/*
 	 * Detach from current vnet, but preserve LLADDR info, do not
 	 * mark as dead etc. so that the ifnet can be reattached later.
@@ -1302,12 +1290,6 @@ if_vmove(struct ifnet *ifp, struct vnet *new_vnet)
 	 */
 	CURVNET_SET_QUIET(new_vnet);
 	if_attach_internal(ifp, true);
-
-#ifdef DEV_BPF
-	if (ifp->if_bpf == NULL)
-		bpfattach(ifp, bif_dlt, bif_hdrlen);
-#endif
-
 	CURVNET_RESTORE();
 	return (0);
 }
@@ -1345,8 +1327,8 @@ if_vmove_loan(struct thread *td, struct ifnet *ifp, char *ifname, int jid)
 	/* XXX Lock interfaces to avoid races. */
 	CURVNET_SET_QUIET(pr->pr_vnet);
 	difp = ifunit(ifname);
+	CURVNET_RESTORE();
 	if (difp != NULL) {
-		CURVNET_RESTORE();
 		prison_free(pr);
 		return (EEXIST);
 	}
@@ -1356,16 +1338,13 @@ if_vmove_loan(struct thread *td, struct ifnet *ifp, char *ifname, int jid)
 	shutdown = VNET_IS_SHUTTING_DOWN(ifp->if_vnet);
 	if (shutdown) {
 		sx_xunlock(&ifnet_detach_sxlock);
-		CURVNET_RESTORE();
 		prison_free(pr);
 		return (EBUSY);
 	}
-	CURVNET_RESTORE();
 
 	found = if_unlink_ifnet(ifp, true);
 	if (! found) {
 		sx_xunlock(&ifnet_detach_sxlock);
-		CURVNET_RESTORE();
 		prison_free(pr);
 		return (ENODEV);
 	}
@@ -1546,7 +1525,7 @@ _if_delgroup_locked(struct ifnet *ifp, struct ifg_list *ifgl,
 	}
 	IFNET_WUNLOCK();
 
-	epoch_wait_preempt(net_epoch_preempt);
+	NET_EPOCH_WAIT();
 	EVENTHANDLER_INVOKE(group_change_event, groupname);
 	if (freeifgl) {
 		EVENTHANDLER_INVOKE(group_detach_event, ifgl->ifgl_group);
diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c
index 1e6f9b578ee3..723b92d3dcd5 100644
--- a/sys/net/if_bridge.c
+++ b/sys/net/if_bridge.c
@@ -754,10 +754,6 @@ bridge_clone_create(struct if_clone *ifc, char *name, size_t len,
 
 	sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK|M_ZERO);
 	ifp = sc->sc_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		free(sc, M_DEVBUF);
-		return (ENOSPC);
-	}
 
 	BRIDGE_LOCK_INIT(sc);
 	sc->sc_brtmax = BRIDGE_RTABLE_MAX;
diff --git a/sys/net/if_disc.c b/sys/net/if_disc.c
index 193bb31d138f..93ce10b8f858 100644
--- a/sys/net/if_disc.c
+++ b/sys/net/if_disc.c
@@ -87,11 +87,6 @@ disc_clone_create(struct if_clone *ifc, int unit, caddr_t params)
 
 	sc = malloc(sizeof(struct disc_softc), M_DISC, M_WAITOK | M_ZERO);
 	ifp = sc->sc_ifp = if_alloc(IFT_LOOP);
-	if (ifp == NULL) {
-		free(sc, M_DISC);
-		return (ENOSPC);
-	}
-
 	ifp->if_softc = sc;
 	if_initname(ifp, discname, unit);
 	ifp->if_mtu = DSMTU;
diff --git a/sys/net/if_edsc.c b/sys/net/if_edsc.c
index 8a66b462d15a..e037db399231 100644
--- a/sys/net/if_edsc.c
+++ b/sys/net/if_edsc.c
@@ -104,11 +104,6 @@ edsc_clone_create(struct if_clone *ifc, int unit, caddr_t params)
 	 */
 	sc = malloc(sizeof(struct edsc_softc), M_EDSC, M_WAITOK | M_ZERO);
 	ifp = sc->sc_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		free(sc, M_EDSC);
-		return (ENOSPC);
-	}
-
 	ifp->if_softc = sc;
 
 	/*
diff --git a/sys/net/if_enc.c b/sys/net/if_enc.c
index 971afdabfff6..18587dc1cb46 100644
--- a/sys/net/if_enc.c
+++ b/sys/net/if_enc.c
@@ -163,10 +163,6 @@ enc_clone_create(struct if_clone *ifc, int unit, caddr_t params)
 	sc = malloc(sizeof(struct enc_softc), M_DEVBUF,
 	    M_WAITOK | M_ZERO);
 	ifp = sc->sc_ifp = if_alloc(IFT_ENC);
-	if (ifp == NULL) {
-		free(sc, M_DEVBUF);
-		return (ENOSPC);
-	}
 	if (V_enc_sc != NULL) {
 		if_free(ifp);
 		free(sc, M_DEVBUF);
@@ -217,7 +213,7 @@ enc_bpftap(struct ifnet *ifp, struct mbuf *m, const struct secasvar *sav,
 	else if (hhook_type == HHOOK_TYPE_IPSEC_OUT &&
 	    (enc & V_bpf_mask_out) == 0)
 		return;
-	if (bpf_peers_present(ifp->if_bpf) == 0)
+	if (!bpf_peers_present(ifp->if_bpf))
 		return;
 	hdr.af = af;
 	hdr.spi = sav->spi;
diff --git a/sys/net/if_epair.c b/sys/net/if_epair.c
index 7bc218321f01..7051e31565d4 100644
--- a/sys/net/if_epair.c
+++ b/sys/net/if_epair.c
@@ -516,9 +516,6 @@ epair_alloc_sc(struct if_clone *ifc)
 	struct epair_softc *sc;
 
 	struct ifnet *ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL)
-		return (NULL);
-
 	sc = malloc(sizeof(struct epair_softc), M_EPAIR, M_WAITOK | M_ZERO);
 	sc->ifp = ifp;
 	sc->num_queues = epair_tasks.tasks;
@@ -614,8 +611,6 @@ epair_generate_mac(struct epair_softc *sc, uint8_t *eaddr)
 static void
 epair_free_sc(struct epair_softc *sc)
 {
-	if (sc == NULL)
-		return;
 
 	if_free(sc->ifp);
 	ifmedia_removeall(&sc->media);
@@ -714,12 +709,6 @@ epair_clone_create(struct if_clone *ifc, char *name, size_t len,
 	/* Allocate memory for both [ab] interfaces */
 	sca = epair_alloc_sc(ifc);
 	scb = epair_alloc_sc(ifc);
-	if (sca == NULL || scb == NULL) {
-		epair_free_sc(sca);
-		epair_free_sc(scb);
-		ifc_free_unit(ifc, unit);
-		return (ENOSPC);
-	}
 
 	/*
 	 * Cross-reference the interfaces so we will be able to free both.
diff --git a/sys/net/if_lagg.c b/sys/net/if_lagg.c
index 9746d4115bc6..e55b46a047df 100644
--- a/sys/net/if_lagg.c
+++ b/sys/net/if_lagg.c
@@ -533,10 +533,6 @@ lagg_clone_create(struct if_clone *ifc, char *name, size_t len,
 
 	sc = malloc(sizeof(*sc), M_LAGG, M_WAITOK | M_ZERO);
 	ifp = sc->sc_ifp = if_alloc(if_type);
-	if (ifp == NULL) {
-		free(sc, M_LAGG);
-		return (ENOSPC);
-	}
 	LAGG_SX_INIT(sc);
 
 	mtx_init(&sc->sc_mtx, "lagg-mtx", NULL, MTX_DEF);
diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c
index e135acef18bb..27c9281957e2 100644
--- a/sys/net/if_loop.c
+++ b/sys/net/if_loop.c
@@ -95,13 +95,9 @@ static int	looutput(struct ifnet *ifp, struct mbuf *m,
 		    const struct sockaddr *dst, struct route *ro);
 
 VNET_DEFINE(struct ifnet *, loif);	/* Used externally */
-
-#ifdef VIMAGE
 VNET_DEFINE_STATIC(struct if_clone *, lo_cloner);
 #define	V_lo_cloner		VNET(lo_cloner)
-#endif
 
-static struct if_clone *lo_cloner;
 static const char loname[] = "lo";
 
 static int
@@ -129,9 +125,6 @@ lo_clone_create(struct if_clone *ifc, char *name, size_t len,
 	struct ifnet *ifp;
 
 	ifp = if_alloc(IFT_LOOP);
-	if (ifp == NULL)
-		return (ENOSPC);
-
 	if_initname(ifp, loname, ifd->unit);
 	ifp->if_mtu = LOMTU;
 	ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST;
@@ -143,8 +136,6 @@ lo_clone_create(struct if_clone *ifc, char *name, size_t len,
 	ifp->if_hwassist = LO_CSUM_FEATURES | LO_CSUM_FEATURES6;
 	if_attach(ifp);
 	bpfattach(ifp, DLT_NULL, sizeof(u_int32_t));
-	if (V_loif == NULL)
-		V_loif = ifp;
 	*ifpp = ifp;
 
 	return (0);
@@ -158,12 +149,9 @@ vnet_loif_init(const void *unused __unused)
 		.destroy_f = lo_clone_destroy,
 		.flags = IFC_F_AUTOUNIT,
 	};
-	lo_cloner = ifc_attach_cloner(loname, &req);
-#ifdef VIMAGE
-	V_lo_cloner = lo_cloner;
-#endif
+	V_lo_cloner = ifc_attach_cloner(loname, &req);
 	struct ifc_data ifd = { .unit = 0 };
-	ifc_create_ifp(loname, &ifd, NULL);
+	ifc_create_ifp(loname, &ifd, &V_loif);
 }
 VNET_SYSINIT(vnet_loif_init, SI_SUB_PSEUDO, SI_ORDER_ANY,
     vnet_loif_init, NULL);
diff --git a/sys/net/if_stf.c b/sys/net/if_stf.c
index 9f9e57b84f35..6fa3d03d1cfa 100644
--- a/sys/net/if_stf.c
+++ b/sys/net/if_stf.c
@@ -264,11 +264,6 @@ stf_clone_create(struct if_clone *ifc, char *name, size_t len,
 
 	sc = malloc(sizeof(struct stf_softc), M_STF, M_WAITOK | M_ZERO);
 	ifp = STF2IFP(sc) = if_alloc(IFT_STF);
-	if (ifp == NULL) {
-		free(sc, M_STF);
-		ifc_free_unit(ifc, unit);
-		return (ENOSPC);
-	}
 	ifp->if_softc = sc;
 	sc->sc_fibnum = curthread->td_proc->p_fibnum;
 
diff --git a/sys/net/if_tuntap.c b/sys/net/if_tuntap.c
index 5d37879e87b9..54d1908b078c 100644
--- a/sys/net/if_tuntap.c
+++ b/sys/net/if_tuntap.c
@@ -971,9 +971,6 @@ tuncreate(struct cdev *dev)
 		iflags |= IFF_POINTOPOINT;
 	}
 	ifp = tp->tun_ifp = if_alloc(type);
-	if (ifp == NULL)
-		panic("%s%d: failed to if_alloc() interface.\n",
-		    drv->cdevsw.d_name, dev2unit(dev));
 	ifp->if_softc = tp;
 	if_initname(ifp, drv->cdevsw.d_name, dev2unit(dev));
 	ifp->if_ioctl = tunifioctl;
diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c
index b69d8107e30d..59eb41956ad4 100644
--- a/sys/net/if_vlan.c
+++ b/sys/net/if_vlan.c
@@ -1163,14 +1163,6 @@ vlan_clone_create(struct if_clone *ifc, char *name, size_t len,
 
 	ifv = malloc(sizeof(struct ifvlan), M_VLAN, M_WAITOK | M_ZERO);
 	ifp = ifv->ifv_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		if (!subinterface)
-			ifc_free_unit(ifc, unit);
-		free(ifv, M_VLAN);
-		if (p != NULL)
-			if_rele(p);
-		return (ENOSPC);
-	}
 	CK_SLIST_INIT(&ifv->vlan_mc_listhead);
 	ifp->if_softc = ifv;
 	/*
diff --git a/sys/net/if_vxlan.c b/sys/net/if_vxlan.c
index 87648abd116b..2bde1d894a3b 100644
--- a/sys/net/if_vxlan.c
+++ b/sys/net/if_vxlan.c
@@ -98,7 +98,7 @@ struct vxlan_socket_mc_info {
 		60 /* Maximum IPv4 header len */ - \
 		sizeof(struct udphdr) - \
 		sizeof(struct vxlan_header) - \
-		ETHER_HDR_LEN - ETHER_CRC_LEN - ETHER_VLAN_ENCAP_LEN)
+		ETHER_HDR_LEN - ETHER_VLAN_ENCAP_LEN)
 #define VXLAN_BASIC_IFCAPS (IFCAP_LINKSTATE | IFCAP_JUMBO_MTU)
 
 #define VXLAN_SO_MC_MAX_GROUPS		32
@@ -368,7 +368,7 @@ static bool	vxlan_rcv_udp_packet(struct mbuf *, int, struct inpcb *,
 static int	vxlan_input(struct vxlan_socket *, uint32_t, struct mbuf **,
 		    const struct sockaddr *);
 
-static int	vxlan_stats_alloc(struct vxlan_softc *);
+static void	vxlan_stats_alloc(struct vxlan_softc *);
 static void	vxlan_stats_free(struct vxlan_softc *);
 static void	vxlan_set_default_config(struct vxlan_softc *);
 static int	vxlan_set_user_config(struct vxlan_softc *,
@@ -2924,27 +2924,14 @@ vxlan_input(struct vxlan_socket *vso, uint32_t vni, struct mbuf **m0,
 	return (error);
 }
 
-static int
+static void
 vxlan_stats_alloc(struct vxlan_softc *sc)
 {
 	struct vxlan_statistics *stats = &sc->vxl_stats;
 
 	stats->txcsum = counter_u64_alloc(M_WAITOK);
-	if (stats->txcsum == NULL)
-		goto failed;
-
 	stats->tso = counter_u64_alloc(M_WAITOK);
-	if (stats->tso == NULL)
-		goto failed;
-
 	stats->rxcsum = counter_u64_alloc(M_WAITOK);
-	if (stats->rxcsum == NULL)
-		goto failed;
-
-	return (0);
-failed:
-	vxlan_stats_free(sc);
-	return (ENOMEM);
 }
 
 static void
@@ -2952,18 +2939,9 @@ vxlan_stats_free(struct vxlan_softc *sc)
 {
 	struct vxlan_statistics *stats = &sc->vxl_stats;
 
-	if (stats->txcsum != NULL) {
-		counter_u64_free(stats->txcsum);
-		stats->txcsum = NULL;
-	}
-	if (stats->tso != NULL) {
-		counter_u64_free(stats->tso);
-		stats->tso = NULL;
-	}
-	if (stats->rxcsum != NULL) {
-		counter_u64_free(stats->rxcsum);
-		stats->rxcsum = NULL;
-	}
+	counter_u64_free(stats->txcsum);
+	counter_u64_free(stats->tso);
+	counter_u64_free(stats->rxcsum);
 }
 
 static void
@@ -3234,9 +3212,6 @@ vxlan_clone_create(struct if_clone *ifc, char *name, size_t len,
 	sc->vxl_unit = ifd->unit;
 	sc->vxl_fibnum = curthread->td_proc->p_fibnum;
 	vxlan_set_default_config(sc);
-	error = vxlan_stats_alloc(sc);
-	if (error != 0)
-		goto fail;
 
 	if (ifd->params != NULL) {
 		error = ifc_copyin(ifd, &vxlp, sizeof(vxlp));
@@ -3248,12 +3223,8 @@ vxlan_clone_create(struct if_clone *ifc, char *name, size_t len,
 			goto fail;
 	}
 
+	vxlan_stats_alloc(sc);
 	ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		error = ENOSPC;
-		goto fail;
-	}
-
 	sc->vxl_ifp = ifp;
 	rm_init(&sc->vxl_lock, "vxlanrm");
 	callout_init_rw(&sc->vxl_callout, &sc->vxl_lock, 0);
diff --git a/sys/net/iflib.c b/sys/net/iflib.c
index 01493e90f6bb..0dba65fee2d8 100644
--- a/sys/net/iflib.c
+++ b/sys/net/iflib.c
@@ -5749,10 +5749,6 @@ iflib_register(if_ctx_t ctx)
 	CTX_LOCK_INIT(ctx);
 	STATE_LOCK_INIT(ctx, device_get_nameunit(ctx->ifc_dev));
 	ifp = ctx->ifc_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		device_printf(dev, "can not allocate ifnet structure\n");
-		return (ENOMEM);
-	}
 
 	/*
 	 * Initialize our context's device specific methods
diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h
index 27428ad161f8..1c932026aeb3 100644
--- a/sys/net/pfvar.h
+++ b/sys/net/pfvar.h
@@ -2231,9 +2231,11 @@ pf_release_staten(struct pf_kstate *s, u_int n)
 }
 
 extern struct pf_kstate		*pf_find_state_byid(uint64_t, uint32_t);
-extern struct pf_kstate		*pf_find_state_all(struct pf_state_key_cmp *,
+extern struct pf_kstate		*pf_find_state_all(
+				    const struct pf_state_key_cmp *,
 				    u_int, int *);
-extern bool			pf_find_state_all_exists(struct pf_state_key_cmp *,
+extern bool			pf_find_state_all_exists(
+				    const struct pf_state_key_cmp *,
 				    u_int);
 extern struct pf_ksrc_node	*pf_find_src_node(struct pf_addr *,
 				    struct pf_krule *, sa_family_t,
@@ -2514,7 +2516,7 @@ struct pf_krule		*pf_get_translation(struct pf_pdesc *, struct mbuf *,
 
 struct pf_state_key	*pf_state_key_setup(struct pf_pdesc *, struct pf_addr *,
 			    struct pf_addr *, u_int16_t, u_int16_t);
-struct pf_state_key	*pf_state_key_clone(struct pf_state_key *);
+struct pf_state_key	*pf_state_key_clone(const struct pf_state_key *);
 void			 pf_rule_to_actions(struct pf_krule *,
 			    struct pf_rule_actions *);
 int			 pf_normalize_mss(struct mbuf *m, int off,
diff --git a/sys/net80211/ieee80211.c b/sys/net80211/ieee80211.c
index 15785a8f0966..4afa3f3e9749 100644
--- a/sys/net80211/ieee80211.c
+++ b/sys/net80211/ieee80211.c
@@ -528,10 +528,6 @@ ieee80211_vap_setup(struct ieee80211com *ic, struct ieee80211vap *vap,
 	struct ifnet *ifp;
 
 	ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		ic_printf(ic, "%s: unable to allocate ifnet\n", __func__);
-		return ENOMEM;
-	}
 	if_initname(ifp, name, unit);
 	ifp->if_softc = vap;			/* back pointer */
 	ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST;
diff --git a/sys/net80211/ieee80211_radiotap.c b/sys/net80211/ieee80211_radiotap.c
index 34e27b323fc1..79e00106a780 100644
--- a/sys/net80211/ieee80211_radiotap.c
+++ b/sys/net80211/ieee80211_radiotap.c
@@ -125,7 +125,7 @@ ieee80211_radiotap_vattach(struct ieee80211vap *vap)
 void
 ieee80211_radiotap_vdetach(struct ieee80211vap *vap)
 {
-	/* NB: bpfattach is called by ether_ifdetach and claims all taps */
+	/* NB: bpfdetach is called by ether_ifdetach and claims all taps */
 }
 
 static void
diff --git a/sys/net80211/ieee80211_var.h b/sys/net80211/ieee80211_var.h
index 4c9cdcbfccd9..d41fb1e6559c 100644
--- a/sys/net80211/ieee80211_var.h
+++ b/sys/net80211/ieee80211_var.h
@@ -722,7 +722,7 @@ MALLOC_DECLARE(M_80211_VAP);
 
 #define	IEEE80211_FHT_BITS \
 	"\20\1NONHT_PR" \
-	"\23GF\24HT\25AMPDU_TX\26AMPDU_TX" \
+	"\21LDPC_TX\22LDPC_RX\23GF\24HT\25AMPDU_TX\26AMPDU_RX" \
 	"\27AMSDU_TX\30AMSDU_RX\31USEHT40\32PUREN\33SHORTGI20\34SHORTGI40" \
 	"\35HTCOMPAT\36RIFS\37STBC_TX\40STBC_RX"
 
diff --git a/sys/netgraph/ng_eiface.c b/sys/netgraph/ng_eiface.c
index 40b1a1128de8..ae88d1b07854 100644
--- a/sys/netgraph/ng_eiface.c
+++ b/sys/netgraph/ng_eiface.c
@@ -386,12 +386,7 @@ ng_eiface_constructor(node_p node)
 
 	/* Allocate node and interface private structures */
 	priv = malloc(sizeof(*priv), M_NETGRAPH, M_WAITOK | M_ZERO);
-
 	ifp = priv->ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		free(priv, M_NETGRAPH);
-		return (ENOSPC);
-	}
 
 	/* Link them together */
 	ifp->if_softc = priv;
diff --git a/sys/netgraph/ng_iface.c b/sys/netgraph/ng_iface.c
index e9f97ff0fdec..d42e74d5fd22 100644
--- a/sys/netgraph/ng_iface.c
+++ b/sys/netgraph/ng_iface.c
@@ -524,10 +524,6 @@ ng_iface_constructor(node_p node)
 	/* Allocate node and interface private structures */
 	priv = malloc(sizeof(*priv), M_NETGRAPH_IFACE, M_WAITOK | M_ZERO);
 	ifp = if_alloc(IFT_PROPVIRTUAL);
-	if (ifp == NULL) {
-		free(priv, M_NETGRAPH_IFACE);
-		return (ENOMEM);
-	}
 
 	rm_init(&priv->lock, "ng_iface private rmlock");
 
diff --git a/sys/netinet/icmp6.h b/sys/netinet/icmp6.h
index e93317c66a11..ea7bf74797f1 100644
--- a/sys/netinet/icmp6.h
+++ b/sys/netinet/icmp6.h
@@ -646,6 +646,10 @@ struct icmp6stat {
 #ifdef _KERNEL
 #include <sys/counter.h>
 
+#ifdef SYSCTL_DECL
+SYSCTL_DECL(_net_inet6_icmp6);
+#endif
+
 VNET_PCPUSTAT_DECLARE(struct icmp6stat, icmp6stat);
 /*
  * In-kernel consumers can use these accessor macros directly to update
@@ -774,12 +778,6 @@ do { \
 		} \
 } while (/*CONSTCOND*/ 0)
 
-VNET_DECLARE(int, icmp6_rediraccept);	/* accept/process redirects */
-VNET_DECLARE(int, icmp6_redirtimeout);	/* cache time for redirect routes */
-
-#define	V_icmp6_rediraccept	VNET(icmp6_rediraccept)
-#define	V_icmp6_redirtimeout	VNET(icmp6_redirtimeout)
-
 #define ICMP6_NODEINFO_FQDNOK		0x1
 #define ICMP6_NODEINFO_NODEADDROK	0x2
 #define ICMP6_NODEINFO_TMPADDROK	0x4
diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c
index c99499d689db..5ad1b2a664db 100644
--- a/sys/netinet/ip_icmp.c
+++ b/sys/netinet/ip_icmp.c
@@ -82,19 +82,22 @@ extern ipproto_ctlinput_t	*ip_ctlprotox[];
  * routines to turnaround packets back to the originator, and
  * host table maintenance routines.
  */
-VNET_DEFINE_STATIC(int, icmplim) = 200;
+static int sysctl_icmplim_and_jitter(SYSCTL_HANDLER_ARGS);
+VNET_DEFINE_STATIC(u_int, icmplim) = 200;
 #define	V_icmplim			VNET(icmplim)
-SYSCTL_INT(_net_inet_icmp, ICMPCTL_ICMPLIM, icmplim, CTLFLAG_VNET | CTLFLAG_RW,
-	&VNET_NAME(icmplim), 0,
-	"Maximum number of ICMP responses per second");
+SYSCTL_PROC(_net_inet_icmp, ICMPCTL_ICMPLIM, icmplim, CTLTYPE_UINT |
+    CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(icmplim), 0,
+    &sysctl_icmplim_and_jitter, "IU",
+    "Maximum number of ICMP responses per second");
 
 VNET_DEFINE_STATIC(int, icmplim_curr_jitter) = 0;
 #define V_icmplim_curr_jitter		VNET(icmplim_curr_jitter)
-VNET_DEFINE_STATIC(int, icmplim_jitter) = 16;
+VNET_DEFINE_STATIC(u_int, icmplim_jitter) = 16;
 #define	V_icmplim_jitter		VNET(icmplim_jitter)
-SYSCTL_INT(_net_inet_icmp, OID_AUTO, icmplim_jitter, CTLFLAG_VNET | CTLFLAG_RW,
-	&VNET_NAME(icmplim_jitter), 0,
-	"Random icmplim jitter adjustment limit");
+SYSCTL_PROC(_net_inet_icmp, OID_AUTO, icmplim_jitter, CTLTYPE_UINT |
+    CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(icmplim_jitter), 0,
+    &sysctl_icmplim_and_jitter, "IU",
+    "Random icmplim jitter adjustment limit");
 
 VNET_DEFINE_STATIC(int, icmplim_output) = 1;
 #define	V_icmplim_output		VNET(icmplim_output)
@@ -1093,42 +1096,89 @@ ip_next_mtu(int mtu, int dir)
  *	the 'final' error, but it doesn't make sense to solve the printing
  *	delay with more complex code.
  */
-struct icmp_rate {
-	const char *descr;
-	struct counter_rate cr;
-};
-VNET_DEFINE_STATIC(struct icmp_rate, icmp_rates[BANDLIM_MAX]) = {
-	{ "icmp unreach response" },
-	{ "icmp ping response" },
-	{ "icmp tstamp response" },
-	{ "closed port RST response" },
-	{ "open port RST response" },
-	{ "icmp6 unreach response" },
-	{ "sctp ootb response" }
-};
+VNET_DEFINE_STATIC(struct counter_rate, icmp_rates[BANDLIM_MAX]);
 #define	V_icmp_rates	VNET(icmp_rates)
 
+static const char *icmp_rate_descrs[BANDLIM_MAX] = {
+	[BANDLIM_ICMP_UNREACH] = "icmp unreach",
+	[BANDLIM_ICMP_ECHO] = "icmp ping",
+	[BANDLIM_ICMP_TSTAMP] = "icmp tstamp",
+	[BANDLIM_RST_CLOSEDPORT] = "closed port RST",
+	[BANDLIM_RST_OPENPORT] = "open port RST",
+	[BANDLIM_ICMP6_UNREACH] = "icmp6 unreach",
+	[BANDLIM_SCTP_OOTB] = "sctp ootb",
+};
+
+static void
+icmplim_new_jitter(void)
+{
+	/*
+	 * Adjust limit +/- to jitter the measurement to deny a side-channel
+	 * port scan as in https://dl.acm.org/doi/10.1145/3372297.3417280
+	 */
+	if (V_icmplim_jitter > 0)
+		V_icmplim_curr_jitter =
+		    arc4random_uniform(V_icmplim_jitter * 2 + 1) -
+		    V_icmplim_jitter;
+}
+
+static int
+sysctl_icmplim_and_jitter(SYSCTL_HANDLER_ARGS)
+{
+	uint32_t new;
+	int error;
+	bool lim;
+
+	MPASS(oidp->oid_arg1 == &VNET_NAME(icmplim) ||
+	    oidp->oid_arg1 == &VNET_NAME(icmplim_jitter));
+
+	lim = (oidp->oid_arg1 == &VNET_NAME(icmplim));
+	new = lim ? V_icmplim : V_icmplim_jitter;
+	error = sysctl_handle_int(oidp, &new, 0, req);
+	if (error == 0 && req->newptr) {
+		if (lim) {
+			if (new != 0 && new <= V_icmplim_jitter)
+				error = EINVAL;
+			else
+				V_icmplim = new;
+		} else {
+			if (new >= V_icmplim)
+				error = EINVAL;
+			else {
+				V_icmplim_jitter = new;
+				icmplim_new_jitter();
+			}
+		}
+	}
+	MPASS(V_icmplim + V_icmplim_curr_jitter >= 0);
+
+	return (error);
+}
+
 static void
 icmp_bandlimit_init(void)
 {
 
 	for (int i = 0; i < BANDLIM_MAX; i++) {
-		V_icmp_rates[i].cr.cr_rate = counter_u64_alloc(M_WAITOK);
-		V_icmp_rates[i].cr.cr_ticks = ticks;
+		V_icmp_rates[i].cr_rate = counter_u64_alloc(M_WAITOK);
+		V_icmp_rates[i].cr_ticks = ticks;
 	}
+	icmplim_new_jitter();
 }
 VNET_SYSINIT(icmp_bandlimit, SI_SUB_PROTO_DOMAIN, SI_ORDER_ANY,
     icmp_bandlimit_init, NULL);
 
+#ifdef VIMAGE
 static void
 icmp_bandlimit_uninit(void)
 {
 
 	for (int i = 0; i < BANDLIM_MAX; i++)
-		counter_u64_free(V_icmp_rates[i].cr.cr_rate);
+		counter_u64_free(V_icmp_rates[i].cr_rate);
 }
 VNET_SYSUNINIT(icmp_bandlimit, SI_SUB_PROTO_DOMAIN, SI_ORDER_THIRD,
     icmp_bandlimit_uninit, NULL);
+#endif
 
 int
 badport_bandlim(int which)
@@ -1141,29 +1191,17 @@ badport_bandlim(int which)
 	KASSERT(which >= 0 && which < BANDLIM_MAX,
 	    ("%s: which %d", __func__, which));
 
-	if ((V_icmplim + V_icmplim_curr_jitter) <= 0)
-		V_icmplim_curr_jitter = -V_icmplim + 1;
-
-	pps = counter_ratecheck(&V_icmp_rates[which].cr, V_icmplim +
+	pps = counter_ratecheck(&V_icmp_rates[which], V_icmplim +
 	    V_icmplim_curr_jitter);
 	if (pps > 0) {
-		/*
-		 * Adjust limit +/- to jitter the measurement to deny a
-		 * side-channel port scan as in CVE-2020-25705
-		 */
-		if (V_icmplim_jitter > 0) {
-			int32_t inc =
-			    arc4random_uniform(V_icmplim_jitter * 2 +1)
-			    - V_icmplim_jitter;
-
-			V_icmplim_curr_jitter = inc;
-		}
+		if (V_icmplim_output)
+			log(LOG_NOTICE,
+			    "Limiting %s response from %jd to %d packets/sec\n",
+			    icmp_rate_descrs[which], (intmax_t )pps,
+			    V_icmplim + V_icmplim_curr_jitter);
+		icmplim_new_jitter();
 	}
 	if (pps == -1)
 		return (-1);
-	if (pps > 0 && V_icmplim_output)
-		log(LOG_NOTICE, "Limiting %s from %jd to %d packets/sec\n",
-		    V_icmp_rates[which].descr, (intmax_t )pps, V_icmplim +
-		    V_icmplim_curr_jitter);
 	return (0);
 }
diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c
index cda5f160e8fb..f438ec5b45ea 100644
--- a/sys/netinet/ip_mroute.c
+++ b/sys/netinet/ip_mroute.c
@@ -766,7 +766,7 @@ X_ip_mrouter_done(void)
 	 * Wait for all epoch sections to complete to ensure
 	 * V_ip_mrouter = NULL is visible to others.
 	 */
-	epoch_wait_preempt(net_epoch_preempt);
+	NET_EPOCH_WAIT();
 
 	/* Stop and drain task queue */
 	taskqueue_block(V_task_queue);
diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c
index b8ac3fc7b094..d6e47a29eede 100644
--- a/sys/netinet6/icmp6.c
+++ b/sys/netinet6/icmp6.c
@@ -116,22 +116,34 @@ extern ip6proto_ctlinput_t	*ip6_ctlprotox[];
 
 VNET_PCPUSTAT_DEFINE(struct icmp6stat, icmp6stat);
 VNET_PCPUSTAT_SYSINIT(icmp6stat);
+SYSCTL_VNET_PCPUSTAT(_net_inet6_icmp6, ICMPV6CTL_STATS, stats,
+    struct icmp6stat, icmp6stat,
+    "ICMPv6 statistics (struct icmp6stat, netinet/icmp6.h)");
 
 #ifdef VIMAGE
 VNET_PCPUSTAT_SYSUNINIT(icmp6stat);
 #endif /* VIMAGE */
 
-VNET_DECLARE(struct inpcbinfo, ripcbinfo);
-VNET_DECLARE(int, icmp6errppslim);
-VNET_DEFINE_STATIC(int, icmp6errpps_count) = 0;
-VNET_DEFINE_STATIC(struct timeval, icmp6errppslim_last);
-VNET_DECLARE(int, icmp6_nodeinfo);
+VNET_DEFINE_STATIC(int, icmp6_rediraccept) = 1;
+#define	V_icmp6_rediraccept	VNET(icmp6_rediraccept)
+SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_REDIRACCEPT, rediraccept,
+    CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(icmp6_rediraccept), 0,
+    "Accept ICMPv6 redirect messages");
+
+VNET_DEFINE_STATIC(int, icmp6_redirtimeout) = 10 * 60;	/* 10 minutes */
+#define	V_icmp6_redirtimeout	VNET(icmp6_redirtimeout)
+SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_REDIRTIMEOUT, redirtimeout,
+    CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(icmp6_redirtimeout), 0,
+    "Delay in seconds before expiring redirect route");
 
-#define	V_ripcbinfo			VNET(ripcbinfo)
-#define	V_icmp6errppslim		VNET(icmp6errppslim)
-#define	V_icmp6errpps_count		VNET(icmp6errpps_count)
-#define	V_icmp6errppslim_last		VNET(icmp6errppslim_last)
-#define	V_icmp6_nodeinfo		VNET(icmp6_nodeinfo)
+VNET_DEFINE_STATIC(int, icmp6_nodeinfo) = 0;
+#define	V_icmp6_nodeinfo	VNET(icmp6_nodeinfo)
+SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_NODEINFO, nodeinfo,
+    CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(icmp6_nodeinfo), 0,
+    "Mask of enabled RFC4620 node information query types");
+
+VNET_DECLARE(struct inpcbinfo, ripcbinfo);
+#define	V_ripcbinfo		VNET(ripcbinfo)
 
 static void icmp6_errcount(int, int);
 static int icmp6_rip6_input(struct mbuf **, int);
@@ -343,10 +355,8 @@ icmp6_error(struct mbuf *m, int type, int code, int param)
 	}
 
 	/* Finally, do rate limitation check. */
-	if (icmp6_ratelimit(&oip6->ip6_src, type, code)) {
-		ICMP6STAT_INC(icp6s_toofreq);
+	if (icmp6_ratelimit(&oip6->ip6_src, type, code))
 		goto freeit;
-	}
 
 	/*
 	 * OK, ICMP6 can be generated.
@@ -550,6 +560,8 @@ icmp6_input(struct mbuf **mp, int *offp, int proto)
 		icmp6_ifstat_inc(ifp, ifs6_in_echo);
 		if (code != 0)
 			goto badcode;
+		if (icmp6_ratelimit(&ip6->ip6_src, ICMP6_ECHO_REPLY, 0))
+			break;
 		if ((n = m_copym(m, 0, M_COPYALL, M_NOWAIT)) == NULL) {
 			/* Give up remote */
 			break;
@@ -2721,6 +2733,126 @@ icmp6_ctloutput(struct socket *so, struct sockopt *sopt)
 	return (error);
 }
 
+static int sysctl_icmp6lim_and_jitter(SYSCTL_HANDLER_ARGS);
+VNET_DEFINE_STATIC(u_int, icmp6errppslim) = 100;
+#define	V_icmp6errppslim	VNET(icmp6errppslim)
+SYSCTL_PROC(_net_inet6_icmp6, ICMPV6CTL_ERRPPSLIMIT, errppslimit,
+    CTLTYPE_UINT | CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(icmp6errppslim), 0,
+    &sysctl_icmp6lim_and_jitter, "IU",
+    "Maximum number of ICMPv6 error/reply messages per second");
+
+VNET_DEFINE_STATIC(int, icmp6lim_curr_jitter) = 0;
+#define	V_icmp6lim_curr_jitter	VNET(icmp6lim_curr_jitter)
+
+VNET_DEFINE_STATIC(u_int, icmp6lim_jitter) = 8;
+#define	V_icmp6lim_jitter	VNET(icmp6lim_jitter)
+SYSCTL_PROC(_net_inet6_icmp6, OID_AUTO, icmp6lim_jitter, CTLTYPE_UINT |
+    CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(icmp6lim_jitter), 0,
+    &sysctl_icmp6lim_and_jitter, "IU",
+    "Random errppslimit jitter adjustment limit");
+
+VNET_DEFINE_STATIC(int, icmp6lim_output) = 1;
+#define	V_icmp6lim_output	VNET(icmp6lim_output)
+SYSCTL_INT(_net_inet6_icmp6, OID_AUTO, icmp6lim_output,
+    CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(icmp6lim_output), 0,
+    "Enable logging of ICMPv6 response rate limiting");
+
+typedef enum {
+	RATELIM_PARAM_PROB = 0,
+	RATELIM_TOO_BIG,
+	RATELIM_UNREACH,
+	RATELIM_TEXCEED,
+	RATELIM_REDIR,
+	RATELIM_REPLY,
+	RATELIM_OTHER,
+	RATELIM_MAX
+} ratelim_which;
+
+static const char *icmp6_rate_descrs[RATELIM_MAX] = {
+	[RATELIM_PARAM_PROB] = "bad IPv6 header",
+	[RATELIM_TOO_BIG] = "packet too big",
+	[RATELIM_UNREACH] = "destination unreachable",
+	[RATELIM_TEXCEED] = "time exceeded",
+	[RATELIM_REPLY] = "echo reply",
+	[RATELIM_REDIR] = "neighbor discovery redirect",
+	[RATELIM_OTHER] = "(other)",
+};
+
+static void
+icmp6lim_new_jitter(void)
+{
+	/*
+	 * Adjust limit +/- to jitter the measurement to deny a side-channel
+	 * port scan as in https://dl.acm.org/doi/10.1145/3372297.3417280
+	 */
+	if (V_icmp6lim_jitter > 0)
+		V_icmp6lim_curr_jitter =
+		    arc4random_uniform(V_icmp6lim_jitter * 2 + 1) -
+		    V_icmp6lim_jitter;
+}
+
+static int
+sysctl_icmp6lim_and_jitter(SYSCTL_HANDLER_ARGS)
+{
+	uint32_t new;
+	int error;
+	bool lim;
+
+	MPASS(oidp->oid_arg1 == &VNET_NAME(icmp6errppslim) ||
+	    oidp->oid_arg1 == &VNET_NAME(icmp6lim_jitter));
+
+	lim = (oidp->oid_arg1 == &VNET_NAME(icmp6errppslim));
+	new = lim ? V_icmp6errppslim : V_icmp6lim_jitter;
+	error = sysctl_handle_int(oidp, &new, 0, req);
+	if (error == 0 && req->newptr) {
+		if (lim) {
+			if (new != 0 && new <= V_icmp6lim_jitter)
+				error = EINVAL;
+			else
+				V_icmp6errppslim = new;
+		} else {
+			if (new >= V_icmp6errppslim)
+				error = EINVAL;
+			else {
+				V_icmp6lim_jitter = new;
+				icmp6lim_new_jitter();
+			}
+		}
+	}
+	MPASS(V_icmp6errppslim + V_icmp6lim_curr_jitter >= 0);
+
+	return (error);
+}
+
+
+VNET_DEFINE_STATIC(struct counter_rate, icmp6_rates[RATELIM_MAX]);
+#define	V_icmp6_rates	VNET(icmp6_rates)
+
+static void
+icmp6_ratelimit_init(void)
+{
+
+	for (int i = 0; i < RATELIM_MAX; i++) {
+		V_icmp6_rates[i].cr_rate = counter_u64_alloc(M_WAITOK);
+		V_icmp6_rates[i].cr_ticks = ticks;
+	}
+	icmp6lim_new_jitter();
+}
+VNET_SYSINIT(icmp6_ratelimit, SI_SUB_PROTO_DOMAIN, SI_ORDER_ANY,
+    icmp6_ratelimit_init, NULL);
+
+#ifdef VIMAGE
+static void
+icmp6_ratelimit_uninit(void)
+{
+
+	for (int i = 0; i < RATELIM_MAX; i++)
+		counter_u64_free(V_icmp6_rates[i].cr_rate);
+}
+VNET_SYSUNINIT(icmp6_ratelimit, SI_SUB_PROTO_DOMAIN, SI_ORDER_THIRD,
+    icmp6_ratelimit_uninit, NULL);
+#endif
+
 /*
  * Perform rate limit check.
  * Returns 0 if it is okay to send the icmp6 packet.
@@ -2730,23 +2862,55 @@ icmp6_ctloutput(struct socket *so, struct sockopt *sopt)
  * XXX per-destination/type check necessary?
  *
  * dst - not used at this moment
- * type - not used at this moment
  * code - not used at this moment
  */
 int
-icmp6_ratelimit(const struct in6_addr *dst, const int type,
-    const int code)
+icmp6_ratelimit(const struct in6_addr *dst, const int type, const int code)
 {
-	int ret;
+	ratelim_which which;
+	int64_t pps;
 
-	ret = 0;	/* okay to send */
+	if (V_icmp6errppslim == 0)
+		return (0);
 
-	/* PPS limit */
-	if (!ppsratecheck(&V_icmp6errppslim_last, &V_icmp6errpps_count,
-	    V_icmp6errppslim)) {
-		/* The packet is subject to rate limit */
-		ret++;
+	switch (type) {
+	case ICMP6_PARAM_PROB:
+		which = RATELIM_PARAM_PROB;
+		break;
+	case ICMP6_PACKET_TOO_BIG:
+		which = RATELIM_TOO_BIG;
+		break;
+	case ICMP6_DST_UNREACH:
+		which = RATELIM_UNREACH;
+		break;
+	case ICMP6_TIME_EXCEEDED:
+		which = RATELIM_TEXCEED;
+		break;
+	case ND_REDIRECT:
+		which = RATELIM_REDIR;
+		break;
+	case ICMP6_ECHO_REPLY:
+		which = RATELIM_REPLY;
+		break;
+	default:
+		which = RATELIM_OTHER;
+		break;
+	};
+
+	pps = counter_ratecheck(&V_icmp6_rates[which], V_icmp6errppslim +
+	    V_icmp6lim_curr_jitter);
+	if (pps > 0) {
+		if (V_icmp6lim_output)
+			log(LOG_NOTICE, "Limiting ICMPv6 %s output from %jd "
+			    "to %d packets/sec\n", icmp6_rate_descrs[which],
+			    (intmax_t )pps, V_icmp6errppslim +
+			    V_icmp6lim_curr_jitter);
+		icmp6lim_new_jitter();
+	}
+	if (pps == -1) {
+		ICMP6STAT_INC(icp6s_toofreq);
+		return (-1);
 	}
 
-	return ret;
+	return (0);
 }
diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c
index 55d675417c41..e9f16dcf5c54 100644
--- a/sys/netinet6/in6.c
+++ b/sys/netinet6/in6.c
@@ -102,6 +102,7 @@
 #include <netinet/ip.h>
 #include <netinet/in_pcb.h>
 #include <netinet/ip_carp.h>
+#include <netinet/icmp6.h>
 
 #include <netinet/ip6.h>
 #include <netinet6/ip6_var.h>
@@ -125,8 +126,19 @@ _Static_assert(offsetof(struct in6_ifreq, ifr_ifru) ==
     offsetof(struct ifreq, ifr_ifru),
     "struct in6_ifreq and struct ifreq are not type punnable");
 
-VNET_DECLARE(int, icmp6_nodeinfo_oldmcprefix);
+VNET_DEFINE_STATIC(int, icmp6_nodeinfo_oldmcprefix) = 1;
 #define V_icmp6_nodeinfo_oldmcprefix	VNET(icmp6_nodeinfo_oldmcprefix)
+SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_NODEINFO_OLDMCPREFIX,
+    nodeinfo_oldmcprefix, CTLFLAG_VNET | CTLFLAG_RW,
+    &VNET_NAME(icmp6_nodeinfo_oldmcprefix), 0,
+    "Join old IPv6 NI group address in draft-ietf-ipngwg-icmp-name-lookup "
+    "for compatibility with KAME implementation");
+
+VNET_DEFINE_STATIC(int, nd6_useloopback) = 1;
+#define	V_nd6_useloopback	VNET(nd6_useloopback)
+SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_USELOOPBACK, nd6_useloopback,
+    CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nd6_useloopback), 0,
+    "Create a loopback route when configuring an IPv6 address");
 
 /*
  * Definitions of some costant IP6 addresses.
diff --git a/sys/netinet6/in6_proto.c b/sys/netinet6/in6_proto.c
index 6e7ffedc3dcd..de065f814560 100644
--- a/sys/netinet6/in6_proto.c
+++ b/sys/netinet6/in6_proto.c
@@ -173,11 +173,8 @@ VNET_DEFINE(int, ip6_v6only) = 1;
 #ifdef IPSTEALTH
 VNET_DEFINE(int, ip6stealth) = 0;
 #endif
-VNET_DEFINE(int, nd6_onlink_ns_rfc4861) = 0;/* allow 'on-link' nd6 NS
-					     * (RFC 4861) */
 VNET_DEFINE(bool, ip6_log_cannot_forward) = 1;
 
-/* icmp6 */
 /*
  * BSDI4 defines these variables in in_proto.c...
  * XXX: what if we don't define INET? Should we define pmtu6_expire
@@ -186,14 +183,6 @@ VNET_DEFINE(bool, ip6_log_cannot_forward) = 1;
 VNET_DEFINE(int, pmtu_expire) = 60*10;
 VNET_DEFINE(int, pmtu_probe) = 60*2;
 
-/* ICMPV6 parameters */
-VNET_DEFINE(int, icmp6_rediraccept) = 1;/* accept and process redirects */
-VNET_DEFINE(int, icmp6_redirtimeout) = 10 * 60;	/* 10 minutes */
-VNET_DEFINE(int, icmp6errppslim) = 100;		/* 100pps */
-/* control how to respond to NI queries */
-VNET_DEFINE(int, icmp6_nodeinfo) = 0;
-VNET_DEFINE(int, icmp6_nodeinfo_oldmcprefix) = 1;
-
 VNET_DEFINE_STATIC(int, ip6_log_interval) = 5;
 VNET_DEFINE_STATIC(int, ip6_log_count) = 0;
 VNET_DEFINE_STATIC(struct timeval, ip6_log_last) = { 0 };
@@ -358,57 +347,3 @@ SYSCTL_BOOL(_net_inet6_ip6, OID_AUTO,
 	log_cannot_forward, CTLFLAG_VNET | CTLFLAG_RW,
 	&VNET_NAME(ip6_log_cannot_forward), 1,
 	"Log packets that cannot be forwarded");
-
-/* net.inet6.icmp6 */
-SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_REDIRACCEPT, rediraccept,
-	CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(icmp6_rediraccept), 0,
-	"Accept ICMPv6 redirect messages");
-SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_REDIRTIMEOUT, redirtimeout,
-	CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(icmp6_redirtimeout), 0,
-	"Delay in seconds before expiring redirect route");
-SYSCTL_VNET_PCPUSTAT(_net_inet6_icmp6, ICMPV6CTL_STATS, stats,
-	struct icmp6stat, icmp6stat,
-	"ICMPv6 statistics (struct icmp6stat, netinet/icmp6.h)");
-SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_PRUNE, nd6_prune,
-	CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nd6_prune), 0,
-	"Frequency in seconds of checks for expired prefixes and routers");
-SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_DELAY, nd6_delay,
-	CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nd6_delay), 0,
-	"Delay in seconds before probing for reachability");
-SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_UMAXTRIES, nd6_umaxtries,
-	CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nd6_umaxtries), 0,
-	"Number of ICMPv6 NS messages sent during reachability detection");
-SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_MMAXTRIES, nd6_mmaxtries,
-	CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nd6_mmaxtries), 0,
-	"Number of ICMPv6 NS messages sent during address resolution");
-SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_USELOOPBACK, nd6_useloopback,
-	CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nd6_useloopback), 0,
-	"Create a loopback route when configuring an IPv6 address");
-SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_NODEINFO, nodeinfo,
-	CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(icmp6_nodeinfo), 0,
-	"Mask of enabled RFC4620 node information query types");
-SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_NODEINFO_OLDMCPREFIX,
-	nodeinfo_oldmcprefix, CTLFLAG_VNET | CTLFLAG_RW,
-	&VNET_NAME(icmp6_nodeinfo_oldmcprefix), 0,
-	"Join old IPv6 NI group address in draft-ietf-ipngwg-icmp-name-lookup "
-	"for compatibility with KAME implementation");
-SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ERRPPSLIMIT, errppslimit,
-	CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(icmp6errppslim), 0,
-	"Maximum number of ICMPv6 error messages per second");
-SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_MAXNUDHINT, nd6_maxnudhint,
-	CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nd6_maxnudhint), 0,
-	""); /* XXX unused */
-SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_DEBUG, nd6_debug,
-	CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nd6_debug), 0,
-	"Log NDP debug messages");
-SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_ONLINKNSRFC4861,
-	nd6_onlink_ns_rfc4861, CTLFLAG_VNET | CTLFLAG_RW,
-	&VNET_NAME(nd6_onlink_ns_rfc4861), 0,
-	"Accept 'on-link' ICMPv6 NS messages in compliance with RFC 4861");
-#ifdef EXPERIMENTAL
-SYSCTL_INT(_net_inet6_icmp6, OID_AUTO,
-	nd6_ignore_ipv6_only_ra, CTLFLAG_VNET | CTLFLAG_RW,
-	&VNET_NAME(nd6_ignore_ipv6_only_ra), 0,
-	"Ignore the 'IPv6-Only flag' in RA messages in compliance with "
-	"draft-ietf-6man-ipv6only-flag");
-#endif
diff --git a/sys/netinet6/ip6_var.h b/sys/netinet6/ip6_var.h
index a3b3b0cb3585..464b74c4fd88 100644
--- a/sys/netinet6/ip6_var.h
+++ b/sys/netinet6/ip6_var.h
@@ -333,11 +333,6 @@ VNET_DECLARE(int, ip6stealth);
 #define	V_ip6stealth			VNET(ip6stealth)
 #endif
 
-#ifdef EXPERIMENTAL
-VNET_DECLARE(int, nd6_ignore_ipv6_only_ra);
-#define	V_nd6_ignore_ipv6_only_ra	VNET(nd6_ignore_ipv6_only_ra)
-#endif
-
 VNET_DECLARE(bool, ip6_log_cannot_forward);
 #define	V_ip6_log_cannot_forward	VNET(ip6_log_cannot_forward)
 
diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c
index b3ca612c90d6..3eacb05f88d7 100644
--- a/sys/netinet6/nd6.c
+++ b/sys/netinet6/nd6.c
@@ -91,21 +91,37 @@
 
 MALLOC_DEFINE(M_IP6NDP, "ip6ndp", "IPv6 Neighbor Discovery");
 
-/* timer values */
-VNET_DEFINE(int, nd6_prune)	= 1;	/* walk list every 1 seconds */
-VNET_DEFINE(int, nd6_delay)	= 5;	/* delay first probe time 5 second */
-VNET_DEFINE(int, nd6_umaxtries)	= 3;	/* maximum unicast query */
-VNET_DEFINE(int, nd6_mmaxtries)	= 3;	/* maximum multicast query */
-VNET_DEFINE(int, nd6_useloopback) = 1;	/* use loopback interface for
-					 * local traffic */
-VNET_DEFINE(int, nd6_gctimer)	= (60 * 60 * 24); /* 1 day: garbage
-					 * collection timer */
+VNET_DEFINE_STATIC(int, nd6_prune) = 1;
+#define	V_nd6_prune	VNET(nd6_prune)
+SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_PRUNE, nd6_prune,
+    CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nd6_prune), 0,
+    "Frequency in seconds of checks for expired prefixes and routers");
+
+VNET_DEFINE_STATIC(int, nd6_delay) = 5;
+#define	V_nd6_delay	VNET(nd6_delay)
+SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_DELAY, nd6_delay,
+    CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nd6_delay), 0,
+    "Delay in seconds before probing for reachability");
+
+VNET_DEFINE_STATIC(int, nd6_umaxtries) = 3;
+#define	V_nd6_umaxtries	VNET(nd6_umaxtries)
+SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_UMAXTRIES, nd6_umaxtries,
+    CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nd6_umaxtries), 0,
+    "Number of ICMPv6 NS messages sent during reachability detection");
+
+VNET_DEFINE(int, nd6_mmaxtries) = 3;
+#define	V_nd6_mmaxtries	VNET(nd6_mmaxtries)
+SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_MMAXTRIES, nd6_mmaxtries,
+    CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nd6_mmaxtries), 0,
+    "Number of ICMPv6 NS messages sent during address resolution");
+
+VNET_DEFINE_STATIC(int, nd6_gctimer) = (60 * 60 * 24); /* 1 day: garbage
+							* collection timer */
+#define	V_nd6_gctimer	VNET(nd6_gctimer)
 
 /* preventing too many loops in ND option parsing */
 VNET_DEFINE_STATIC(int, nd6_maxndopt) = 10; /* max # of ND options allowed */
 
-VNET_DEFINE(int, nd6_maxnudhint) = 0;	/* max # of subsequent upper
-					 * layer hints */
 VNET_DEFINE_STATIC(int, nd6_maxqueuelen) = 16; /* max pkts cached in unresolved
 					 * ND entries */
 #define	V_nd6_maxndopt			VNET(nd6_maxndopt)
@@ -116,6 +132,10 @@ VNET_DEFINE(int, nd6_debug) = 1;
 #else
 VNET_DEFINE(int, nd6_debug) = 0;
 #endif
+#define	V_nd6_debug	VNET(nd6_debug)
+SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_DEBUG, nd6_debug,
+    CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nd6_debug), 0,
+    "Log NDP debug messages");
 
 static eventhandler_tag lle_event_eh, iflladdr_event_eh, ifnet_link_event_eh;
 
@@ -148,8 +168,6 @@ VNET_DEFINE_STATIC(struct callout, nd6_slowtimo_ch);
 VNET_DEFINE_STATIC(struct callout, nd6_timer_ch);
 #define	V_nd6_timer_ch			VNET(nd6_timer_ch)
 
-SYSCTL_DECL(_net_inet6_icmp6);
-
 static void
 nd6_lle_event(void *arg __unused, struct llentry *lle, int evt)
 {
diff --git a/sys/netinet6/nd6.h b/sys/netinet6/nd6.h
index 3e7f2d814d47..1db1b666c60b 100644
--- a/sys/netinet6/nd6.h
+++ b/sys/netinet6/nd6.h
@@ -255,26 +255,12 @@ MALLOC_DECLARE(M_IP6NDP);
 #endif
 
 /* nd6.c */
-VNET_DECLARE(int, nd6_prune);
-VNET_DECLARE(int, nd6_delay);
-VNET_DECLARE(int, nd6_umaxtries);
 VNET_DECLARE(int, nd6_mmaxtries);
-VNET_DECLARE(int, nd6_useloopback);
-VNET_DECLARE(int, nd6_maxnudhint);
-VNET_DECLARE(int, nd6_gctimer);
 VNET_DECLARE(struct nd_prhead, nd_prefix);
 VNET_DECLARE(int, nd6_debug);
-VNET_DECLARE(int, nd6_onlink_ns_rfc4861);
-#define	V_nd6_prune			VNET(nd6_prune)
-#define	V_nd6_delay			VNET(nd6_delay)
-#define	V_nd6_umaxtries			VNET(nd6_umaxtries)
 #define	V_nd6_mmaxtries			VNET(nd6_mmaxtries)
-#define	V_nd6_useloopback		VNET(nd6_useloopback)
-#define	V_nd6_maxnudhint		VNET(nd6_maxnudhint)
-#define	V_nd6_gctimer			VNET(nd6_gctimer)
 #define	V_nd_prefix			VNET(nd_prefix)
 #define	V_nd6_debug			VNET(nd6_debug)
-#define	V_nd6_onlink_ns_rfc4861		VNET(nd6_onlink_ns_rfc4861)
 
 /* Lock for the prefix and default router lists. */
 VNET_DECLARE(struct rwlock, nd6_lock);
diff --git a/sys/netinet6/nd6_nbr.c b/sys/netinet6/nd6_nbr.c
index 7b4fa7a8d8c9..353db66c2323 100644
--- a/sys/netinet6/nd6_nbr.c
+++ b/sys/netinet6/nd6_nbr.c
@@ -110,6 +110,13 @@ VNET_DEFINE_STATIC(int, dad_maxtry) = 15;	/* max # of *tries* to
 						   transmit DAD packet */
 #define	V_dad_maxtry			VNET(dad_maxtry)
 
+VNET_DEFINE_STATIC(int, nd6_onlink_ns_rfc4861) = 0;
+#define	V_nd6_onlink_ns_rfc4861		VNET(nd6_onlink_ns_rfc4861)
+SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_ONLINKNSRFC4861,
+    nd6_onlink_ns_rfc4861, CTLFLAG_VNET | CTLFLAG_RW,
+    &VNET_NAME(nd6_onlink_ns_rfc4861), 0,
+    "Accept 'on-link' ICMPv6 NS messages in compliance with RFC 4861");
+
 /*
  * Input a Neighbor Solicitation Message.
  *
diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c
index de991c98b6c3..845f9094f4c4 100644
--- a/sys/netinet6/nd6_rtr.c
+++ b/sys/netinet6/nd6_rtr.c
@@ -98,11 +98,15 @@ VNET_DEFINE(u_int32_t, ip6_temp_valid_lifetime) = DEF_TEMP_VALID_LIFETIME;
 VNET_DEFINE(int, ip6_temp_regen_advance) = TEMPADDR_REGEN_ADVANCE;
 
 #ifdef EXPERIMENTAL
-VNET_DEFINE(int, nd6_ignore_ipv6_only_ra) = 1;
+VNET_DEFINE_STATIC(int, nd6_ignore_ipv6_only_ra) = 1;
+#define	V_nd6_ignore_ipv6_only_ra	VNET(nd6_ignore_ipv6_only_ra)
+SYSCTL_INT(_net_inet6_icmp6, OID_AUTO,
+    nd6_ignore_ipv6_only_ra, CTLFLAG_VNET | CTLFLAG_RW,
+    &VNET_NAME(nd6_ignore_ipv6_only_ra), 0,
+    "Ignore the 'IPv6-Only flag' in RA messages in compliance with "
+    "draft-ietf-6man-ipv6only-flag");
 #endif
 
-SYSCTL_DECL(_net_inet6_icmp6);
-
 /* RTPREF_MEDIUM has to be 0! */
 #define RTPREF_HIGH	1
 #define RTPREF_MEDIUM	0
diff --git a/sys/netlink/netlink_snl.h b/sys/netlink/netlink_snl.h
index f8387132f78a..03f2b7dc5c38 100644
--- a/sys/netlink/netlink_snl.h
+++ b/sys/netlink/netlink_snl.h
@@ -63,7 +63,7 @@
 
 #define	_NLA_END(_start, _len)	((char *)(_start) + (_len))
 #define NLA_FOREACH(_attr, _start, _len)      \
-        for (_attr = (_start);		\
+        for (_attr = (struct nlattr *)(_start);		\
 		((char *)_attr < _NLA_END(_start, _len)) && \
 		((char *)NLA_NEXT(_attr) <= _NLA_END(_start, _len));	\
 		_attr =  NLA_NEXT(_attr))
@@ -80,7 +80,7 @@ struct linear_buffer {
 static inline struct linear_buffer *
 lb_init(uint32_t size)
 {
-	struct linear_buffer *lb = calloc(1, size);
+	struct linear_buffer *lb = (struct linear_buffer *)calloc(1, size);
 
 	if (lb != NULL) {
 		lb->base = (char *)(lb + 1);
@@ -102,7 +102,7 @@ lb_allocz(struct linear_buffer *lb, int len)
 	len = roundup2(len, alignof(__max_align_t));
 	if (lb->offset + len > lb->size)
 		return (NULL);
-	void *data = (void *)(lb->base + lb->offset);
+	char *data = (lb->base + lb->offset);
 	lb->offset += len;
 	return (data);
 }
@@ -275,7 +275,7 @@ snl_init(struct snl_state *ss, int netlink_family)
 	}
 
 	ss->bufsize = rcvbuf;
-	ss->buf = malloc(ss->bufsize);
+	ss->buf = (char *)malloc(ss->bufsize);
 	if (ss->buf == NULL) {
 		snl_free(ss);
 		return (false);
@@ -495,7 +495,8 @@ snl_parse_header(struct snl_state *ss, void *hdr, int len,
 	struct nlattr *nla_head;
 
 	/* Extract fields first (if any) */
-	snl_parse_fields(ss, hdr, parser->in_hdr_size, parser->fp, parser->fp_size, target);
+	snl_parse_fields(ss, (struct nlmsghdr *)hdr, parser->in_hdr_size,
+	    parser->fp, parser->fp_size, target);
 
 	nla_head = (struct nlattr *)(void *)((char *)hdr + parser->in_hdr_size);
 	bool result = snl_parse_attrs_raw(ss, nla_head, len - parser->in_hdr_size,
@@ -616,7 +617,7 @@ snl_attr_get_stringn(struct snl_state *ss, struct nlattr *nla,
 {
 	int maxlen = NLA_DATA_LEN(nla);
 
-	char *buf = snl_allocz(ss, maxlen + 1);
+	char *buf = (char *)snl_allocz(ss, maxlen + 1);
 	if (buf == NULL)
 		return (false);
 	buf[maxlen] = '\0';
@@ -633,7 +634,7 @@ snl_attr_copy_string(struct snl_state *ss, struct nlattr *nla,
 	char *tmp;
 
 	if (snl_attr_get_string(ss, nla, NULL, &tmp)) {
-		strlcpy(target, tmp, (size_t)arg);
+		strlcpy((char *)target, tmp, (size_t)arg);
 		return (true);
 	}
 	return (false);
@@ -646,7 +647,7 @@ snl_attr_dup_string(struct snl_state *ss __unused, struct nlattr *nla,
 	size_t maxlen = NLA_DATA_LEN(nla);
 
 	if (strnlen((char *)NLA_DATA(nla), maxlen) < maxlen) {
-		char *buf = snl_allocz(ss, maxlen);
+		char *buf = (char *)snl_allocz(ss, maxlen);
 		if (buf == NULL)
 			return (false);
 		memcpy(buf, NLA_DATA(nla), maxlen);
@@ -675,14 +676,14 @@ snl_attr_get_parray_sz(struct snl_state *ss, struct nlattr *container_nla,
     uint32_t start_size, const void *arg, void *target)
 {
 	const struct snl_hdr_parser *p = (const struct snl_hdr_parser *)arg;
-	struct snl_parray *array = target;
+	struct snl_parray *array = (struct snl_parray *)target;
 	struct nlattr *nla;
 	uint32_t count = 0, size = start_size;
 
 	if (p->out_size == 0)
 		return (false);
 
-	array->items = snl_allocz(ss, size * sizeof(void *));
+	array->items = (void **)snl_allocz(ss, size * sizeof(void *));
 	if (array->items == NULL)
 		return (false);
 
@@ -712,7 +713,7 @@ snl_attr_get_parray_sz(struct snl_state *ss, struct nlattr *container_nla,
 
 		if (count == size) {
 			uint32_t new_size = size * 2;
-			void **new_array = snl_allocz(ss, new_size *sizeof(void *));
+			void **new_array = (void **)snl_allocz(ss, new_size *sizeof(void *));
 
 			memcpy(new_array, array->items, size * sizeof(void *));
 			array->items = new_array;
@@ -825,7 +826,7 @@ static const struct snl_attr_parser _nla_p_bitset[] = {
 static inline bool
 _cb_p_bitset(struct snl_state *ss __unused, void *_target)
 {
-	struct snl_attr_bitset *target = _target;
+	struct snl_attr_bitset *target = (struct snl_attr_bitset *)_target;
 
 	uint32_t sz_bytes = _roundup2(target->nla_bitset_size, 32) / 8;
 
@@ -861,7 +862,7 @@ snl_attr_get_bitset_c(struct snl_state *ss, struct nlattr *nla,
     const void *arg __unused, void *_target)
 {
 	const struct snl_hdr_parser *p = &_nla_bitset_parser;
-	struct snl_attr_bitset *target = _target;
+	struct snl_attr_bitset *target = (struct snl_attr_bitset *)_target;
 
 	/* Assumes target points to the beginning of the structure */
 	if (!snl_parse_header(ss, NLA_DATA(nla), NLA_DATA_LEN(nla), p, _target))
@@ -981,7 +982,7 @@ parse_cmsg(struct snl_state *ss, const struct msghdr *msg, struct snl_msg_info *
 		int len = cmsg->cmsg_len - ((char *)data - (char *)cmsg);
 		const struct snl_hdr_parser *ps = &snl_msg_info_parser;
 
-		return (snl_parse_attrs_raw(ss, data, len, ps->np, ps->np_size, attrs));
+		return (snl_parse_attrs_raw(ss, (struct nlattr *)data, len, ps->np, ps->np_size, attrs));
 	}
 
 	return (false);
@@ -1023,7 +1024,7 @@ static inline void
 snl_init_writer(struct snl_state *ss, struct snl_writer *nw)
 {
 	nw->size = SNL_WRITER_BUFFER_SIZE;
-	nw->base = snl_allocz(ss, nw->size);
+	nw->base = (char *)snl_allocz(ss, nw->size);
 	if (nw->base == NULL) {
 		nw->error = true;
 		nw->size = 0;
@@ -1061,7 +1062,7 @@ snl_realloc_msg_buffer(struct snl_writer *nw, size_t sz)
 			nw->hdr = (struct nlmsghdr *)
 			    (void *)((char *)new_base + hdr_off);
 		}
-		nw->base = new_base;
+		nw->base = (char *)new_base;
 	}
 
 	return (true);
diff --git a/sys/netlink/netlink_snl_route.h b/sys/netlink/netlink_snl_route.h
index 619e769b1496..62055b2db417 100644
--- a/sys/netlink/netlink_snl_route.h
+++ b/sys/netlink/netlink_snl_route.h
@@ -100,7 +100,7 @@ snl_attr_get_ip(struct snl_state *ss, struct nlattr *nla,
 static inline struct sockaddr *
 parse_rta_via(struct snl_state *ss, struct rtattr *rta, int *perror)
 {
-	struct rtvia *via = NL_RTA_DATA(rta);
+	struct rtvia *via = (struct rtvia *)NL_RTA_DATA(rta);
 
 	switch (via->rtvia_family) {
 	case AF_INET:
diff --git a/sys/netlink/netlink_snl_route_parsers.h b/sys/netlink/netlink_snl_route_parsers.h
index 7e4bcad4010b..256edfec297d 100644
--- a/sys/netlink/netlink_snl_route_parsers.h
+++ b/sys/netlink/netlink_snl_route_parsers.h
@@ -78,7 +78,7 @@ static const struct snl_field_parser _fp_p_mp_nh[] = {
 static inline bool
 _cb_p_mp_nh(struct snl_state *ss __unused, void *_target)
 {
-	struct rta_mpath_nh *target = _target;
+	struct rta_mpath_nh *target = (struct rta_mpath_nh *)_target;
 
 	finalize_sockaddr(target->gw, target->ifindex);
 	return (true);
@@ -158,7 +158,7 @@ static const struct snl_field_parser _fp_p_route[] = {
 static inline bool
 _cb_p_route(struct snl_state *ss __unused, void *_target)
 {
-	struct snl_parsed_route *target = _target;
+	struct snl_parsed_route *target = (struct snl_parsed_route *)_target;
 
 	finalize_sockaddr(target->rta_dst, target->rta_oif);
 	finalize_sockaddr(target->rta_gw, target->rta_oif);
@@ -277,7 +277,7 @@ static struct snl_field_parser _fp_p_neigh_s[] = {
 static inline bool
 _cb_p_neigh(struct snl_state *ss __unused, void *_target)
 {
-	struct snl_parsed_neigh *target = _target;
+	struct snl_parsed_neigh *target = (struct snl_parsed_neigh *)_target;
 
 	finalize_sockaddr(target->nda_dst, target->nda_ifindex);
 	return (true);
@@ -326,7 +326,7 @@ static const struct snl_field_parser _fp_p_addr_s[] = {
 static inline bool
 _cb_p_addr(struct snl_state *ss __unused, void *_target)
 {
-	struct snl_parsed_addr *target = _target;
+	struct snl_parsed_addr *target = (struct snl_parsed_addr *)_target;
 
 	finalize_sockaddr(target->ifa_address, target->ifa_index);
 	finalize_sockaddr(target->ifa_local, target->ifa_index);
@@ -379,7 +379,7 @@ static const struct snl_attr_parser _nla_p_nh[] = {
 static inline bool
 _cb_p_nh(struct snl_state *ss __unused, void *_target)
 {
-	struct snl_parsed_nhop *target = _target;
+	struct snl_parsed_nhop *target = (struct snl_parsed_nhop *)_target;
 
 	finalize_sockaddr(target->nha_gw, target->nha_oif);
 	return (true);
diff --git a/sys/netlink/route/rt.c b/sys/netlink/route/rt.c
index ed09748995dc..7379d49b96a9 100644
--- a/sys/netlink/route/rt.c
+++ b/sys/netlink/route/rt.c
@@ -475,6 +475,7 @@ struct nl_parsed_route {
 	uint32_t		rta_nh_id;
 	uint32_t		rta_weight;
 	uint32_t		rtax_mtu;
+	uint8_t			rtm_table;
 	uint8_t			rtm_family;
 	uint8_t			rtm_dst_len;
 	uint8_t			rtm_protocol;
@@ -507,6 +508,7 @@ static const struct nlfield_parser nlf_p_rtmsg[] = {
 	{ .off_in = _IN(rtm_dst_len), .off_out = _OUT(rtm_dst_len), .cb = nlf_get_u8 },
 	{ .off_in = _IN(rtm_protocol), .off_out = _OUT(rtm_protocol), .cb = nlf_get_u8 },
 	{ .off_in = _IN(rtm_type), .off_out = _OUT(rtm_type), .cb = nlf_get_u8 },
+	{ .off_in = _IN(rtm_table), .off_out = _OUT(rtm_table), .cb = nlf_get_u8 },
 	{ .off_in = _IN(rtm_flags), .off_out = _OUT(rtm_flags), .cb = nlf_get_u32 },
 };
 #undef _IN
@@ -939,7 +941,10 @@ rtnl_handle_newroute(struct nlmsghdr *hdr, struct nlpcb *nlp,
 		return (EINVAL);
 	}
 
-	if (attrs.rta_table >= V_rt_numfibs) {
+	if (attrs.rtm_table > 0 && attrs.rta_table == 0) {
+		/* pre-2.6.19 Linux API compatibility */
+		attrs.rta_table = attrs.rtm_table;
+	} else if (attrs.rta_table >= V_rt_numfibs) {
 		NLMSG_REPORT_ERR_MSG(npt, "invalid fib");
 		return (EINVAL);
 	}
diff --git a/sys/netpfil/ipfw/ip_fw_bpf.c b/sys/netpfil/ipfw/ip_fw_bpf.c
index 5d27eae4d799..85e0e7cfdc50 100644
--- a/sys/netpfil/ipfw/ip_fw_bpf.c
+++ b/sys/netpfil/ipfw/ip_fw_bpf.c
@@ -96,8 +96,6 @@ ipfw_clone_create(struct if_clone *ifc, int unit, caddr_t params)
 	struct ifnet *ifp;
 
 	ifp = if_alloc(IFT_PFLOG);
-	if (ifp == NULL)
-		return (ENOSPC);
 	if_initname(ifp, ipfwname, unit);
 	ifp->if_flags = IFF_UP | IFF_SIMPLEX | IFF_MULTICAST;
 	ifp->if_mtu = 65536;
@@ -122,8 +120,6 @@ ipfwlog_clone_create(struct if_clone *ifc, int unit, caddr_t params)
 	struct ifnet *ifp;
 
 	ifp = if_alloc(IFT_PFLOG);
-	if (ifp == NULL)
-		return (ENOSPC);
 	if_initname(ifp, ipfwlogname, unit);
 	ifp->if_flags = IFF_UP | IFF_SIMPLEX | IFF_MULTICAST;
 	ifp->if_mtu = 65536;
diff --git a/sys/netpfil/pf/if_pflog.c b/sys/netpfil/pf/if_pflog.c
index 82e0daa01898..53fe36343c75 100644
--- a/sys/netpfil/pf/if_pflog.c
+++ b/sys/netpfil/pf/if_pflog.c
@@ -129,9 +129,6 @@ pflog_clone_create(struct if_clone *ifc, char *name, size_t maxlen,
 		return (EINVAL);
 
 	ifp = if_alloc(IFT_PFLOG);
-	if (ifp == NULL) {
-		return (ENOSPC);
-	}
 	if_initname(ifp, pflogname, ifd->unit);
 	ifp->if_mtu = PFLOGMTU;
 	ifp->if_ioctl = pflogioctl;
@@ -223,9 +220,10 @@ pflog_packet(struct pfi_kkif *kif, struct mbuf *m, sa_family_t af,
 	struct pfloghdr hdr;
 
 	if (kif == NULL || m == NULL || rm == NULL || pd == NULL)
-		return ( 1);
+		return (1);
 
-	if ((ifn = V_pflogifs[rm->logif]) == NULL || !ifn->if_bpf)
+	ifn = V_pflogifs[rm->logif];
+	if (ifn == NULL || !bpf_peers_present(ifn->if_bpf))
 		return (0);
 
 	bzero(&hdr, sizeof(hdr));
@@ -274,7 +272,7 @@ pflog_packet(struct pfi_kkif *kif, struct mbuf *m, sa_family_t af,
 
 	if_inc_counter(ifn, IFCOUNTER_OPACKETS, 1);
 	if_inc_counter(ifn, IFCOUNTER_OBYTES, m->m_pkthdr.len);
-	BPF_MTAP2(ifn, &hdr, PFLOG_HDRLEN, m);
+	bpf_mtap2(ifn->if_bpf, &hdr, PFLOG_HDRLEN, m);
 
 	return (0);
 }
diff --git a/sys/netpfil/pf/if_pfsync.c b/sys/netpfil/pf/if_pfsync.c
index def06cd0c113..9aad44ccaf99 100644
--- a/sys/netpfil/pf/if_pfsync.c
+++ b/sys/netpfil/pf/if_pfsync.c
@@ -396,10 +396,6 @@ pfsync_clone_create(struct if_clone *ifc, int unit, caddr_t param)
 	sc->sc_version = PFSYNC_MSG_VERSION_DEFAULT;
 
 	ifp = sc->sc_ifp = if_alloc(IFT_PFSYNC);
-	if (ifp == NULL) {
-		free(sc, M_PFSYNC);
-		return (ENOSPC);
-	}
 	if_initname(ifp, pfsyncname, unit);
 	ifp->if_softc = sc;
 	ifp->if_ioctl = pfsyncioctl;
@@ -1796,7 +1792,7 @@ pfsync_sendout(int schedswi, int c)
 	    ("%s: sc_len %zu", __func__, b->b_len));
 	PFSYNC_BUCKET_LOCK_ASSERT(b);
 
-	if (ifp->if_bpf == NULL && sc->sc_sync_if == NULL) {
+	if (!bpf_peers_present(ifp->if_bpf) && sc->sc_sync_if == NULL) {
 		pfsync_drop(sc);
 		return;
 	}
@@ -1925,10 +1921,10 @@ pfsync_sendout(int schedswi, int c)
 	V_pfsyncstats.pfsyncs_oacts[PFSYNC_ACT_EOF]++;
 
 	/* we're done, let's put it on the wire */
-	if (ifp->if_bpf) {
+	if (bpf_peers_present(ifp->if_bpf)) {
 		m->m_data += aflen;
 		m->m_len = m->m_pkthdr.len = len - aflen;
-		BPF_MTAP(ifp, m);
+		bpf_mtap(ifp->if_bpf, m);
 		m->m_data -= aflen;
 		m->m_len = m->m_pkthdr.len = len;
 	}
diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c
index 6874dd59c1f7..6671839fc5ab 100644
--- a/sys/netpfil/pf/pf.c
+++ b/sys/netpfil/pf/pf.c
@@ -128,6 +128,10 @@ SDT_PROBE_DEFINE5(pf, ip, state, lookup, "struct pfi_kkif *",
     "struct pf_kstate *");
 SDT_PROBE_DEFINE4(pf, sctp, multihome, test, "struct pfi_kkif *",
     "struct pf_krule *", "struct mbuf *", "int");
+SDT_PROBE_DEFINE2(pf, sctp, multihome, add, "uint32_t",
+    "struct pf_sctp_source *");
+SDT_PROBE_DEFINE3(pf, sctp, multihome, remove, "uint32_t",
+    "struct pf_kstate *", "struct pf_sctp_source *");
 
 SDT_PROBE_DEFINE3(pf, eth, test_rule, entry, "int", "struct ifnet *",
     "struct mbuf *");
@@ -357,7 +361,7 @@ static void		 pf_print_state_parts(struct pf_kstate *,
 static void		 pf_patch_8(struct mbuf *, u_int16_t *, u_int8_t *, u_int8_t,
 			    bool, u_int8_t);
 static struct pf_kstate	*pf_find_state(struct pfi_kkif *,
-			    struct pf_state_key_cmp *, u_int);
+			    const struct pf_state_key_cmp *, u_int);
 static int		 pf_src_connlimit(struct pf_kstate **);
 static void		 pf_overload_task(void *v, int pending);
 static u_short		 pf_insert_src_node(struct pf_ksrc_node **,
@@ -623,11 +627,11 @@ pf_packet_rework_nat(struct mbuf *m, struct pf_pdesc *pd, int off,
 }
 
 static __inline uint32_t
-pf_hashkey(struct pf_state_key *sk)
+pf_hashkey(const struct pf_state_key *sk)
 {
 	uint32_t h;
 
-	h = murmur3_32_hash32((uint32_t *)sk,
+	h = murmur3_32_hash32((const uint32_t *)sk,
 	    sizeof(struct pf_state_key_cmp)/sizeof(uint32_t),
 	    V_pf_hashseed);
 
@@ -1473,7 +1477,7 @@ pf_state_key_setup(struct pf_pdesc *pd, struct pf_addr *saddr,
 }
 
 struct pf_state_key *
-pf_state_key_clone(struct pf_state_key *orig)
+pf_state_key_clone(const struct pf_state_key *orig)
 {
 	struct pf_state_key *sk;
 
@@ -1572,7 +1576,8 @@ pf_find_state_byid(uint64_t id, uint32_t creatorid)
  * Returns with ID hash slot locked on success.
  */
 static struct pf_kstate *
-pf_find_state(struct pfi_kkif *kif, struct pf_state_key_cmp *key, u_int dir)
+pf_find_state(struct pfi_kkif *kif, const struct pf_state_key_cmp *key,
+    u_int dir)
 {
 	struct pf_keyhash	*kh;
 	struct pf_state_key	*sk;
@@ -1581,7 +1586,7 @@ pf_find_state(struct pfi_kkif *kif, struct pf_state_key_cmp *key, u_int dir)
 
 	pf_counter_u64_add(&V_pf_status.fcounters[FCNT_STATE_SEARCH], 1);
 
-	kh = &V_pf_keyhash[pf_hashkey((struct pf_state_key *)key)];
+	kh = &V_pf_keyhash[pf_hashkey((const struct pf_state_key *)key)];
 
 	PF_HASHROW_LOCK(kh);
 	LIST_FOREACH(sk, &kh->keys, entry)
@@ -1619,7 +1624,7 @@ pf_find_state(struct pfi_kkif *kif, struct pf_state_key_cmp *key, u_int dir)
  * Returns with ID hash slot locked on success.
  */
 struct pf_kstate *
-pf_find_state_all(struct pf_state_key_cmp *key, u_int dir, int *more)
+pf_find_state_all(const struct pf_state_key_cmp *key, u_int dir, int *more)
 {
 	struct pf_keyhash	*kh;
 	struct pf_state_key	*sk;
@@ -1628,7 +1633,7 @@ pf_find_state_all(struct pf_state_key_cmp *key, u_int dir, int *more)
 
 	pf_counter_u64_add(&V_pf_status.fcounters[FCNT_STATE_SEARCH], 1);
 
-	kh = &V_pf_keyhash[pf_hashkey((struct pf_state_key *)key)];
+	kh = &V_pf_keyhash[pf_hashkey((const struct pf_state_key *)key)];
 
 	PF_HASHROW_LOCK(kh);
 	LIST_FOREACH(sk, &kh->keys, entry)
@@ -1685,7 +1690,7 @@ pf_find_state_all(struct pf_state_key_cmp *key, u_int dir, int *more)
  * removing it.
  */
 bool
-pf_find_state_all_exists(struct pf_state_key_cmp *key, u_int dir)
+pf_find_state_all_exists(const struct pf_state_key_cmp *key, u_int dir)
 {
 	struct pf_kstate *s;
 
@@ -6001,11 +6006,12 @@ pf_sctp_multihome_detach_addr(const struct pf_kstate *s)
 	key.v_tag = s->dst.scrub->pfss_v_tag;
 	ep  = RB_FIND(pf_sctp_endpoints, &V_pf_sctp_endpoints, &key);
 	if (ep != NULL) {
-		/* XXX Actually remove! */
 		TAILQ_FOREACH_SAFE(i, &ep->sources, entry, tmp) {
 			if (pf_addr_cmp(&i->addr,
 			    &s->key[PF_SK_WIRE]->addr[s->direction == PF_OUT],
 			    s->key[PF_SK_WIRE]->af) == 0) {
+				SDT_PROBE3(pf, sctp, multihome, remove,
+				    key.v_tag, s, i);
 				TAILQ_REMOVE(&ep->sources, i, entry);
 				free(i, M_PFTEMP);
 				break;
@@ -6026,6 +6032,8 @@ pf_sctp_multihome_detach_addr(const struct pf_kstate *s)
 			if (pf_addr_cmp(&i->addr,
 			    &s->key[PF_SK_WIRE]->addr[s->direction == PF_IN],
 			    s->key[PF_SK_WIRE]->af) == 0) {
+				SDT_PROBE3(pf, sctp, multihome, remove,
+				    key.v_tag, s, i);
 				TAILQ_REMOVE(&ep->sources, i, entry);
 				free(i, M_PFTEMP);
 				break;
@@ -6083,6 +6091,7 @@ pf_sctp_multihome_add_addr(struct pf_pdesc *pd, struct pf_addr *a, uint32_t v_ta
 	i->af = pd->af;
 	memcpy(&i->addr, a, sizeof(*a));
 	TAILQ_INSERT_TAIL(&ep->sources, i, entry);
+	SDT_PROBE2(pf, sctp, multihome, add, v_tag, i);
 
 	PF_SCTP_ENDPOINTS_UNLOCK();
 }
diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c
index 1a383ae6fd09..7c148d857144 100644
--- a/sys/netpfil/pf/pf_ioctl.c
+++ b/sys/netpfil/pf/pf_ioctl.c
@@ -2071,7 +2071,8 @@ pf_rule_to_krule(const struct pf_rule *rule, struct pf_krule *krule)
 	krule->os_fingerprint = rule->os_fingerprint;
 
 	krule->rtableid = rule->rtableid;
-	bcopy(rule->timeout, krule->timeout, sizeof(krule->timeout));
+	/* pf_rule->timeout is smaller than pf_krule->timeout */
+	bcopy(rule->timeout, krule->timeout, sizeof(rule->timeout));
 	krule->max_states = rule->max_states;
 	krule->max_src_nodes = rule->max_src_nodes;
 	krule->max_src_states = rule->max_src_states;
diff --git a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c
index c8f7574a12fa..f3a85f3a0cb7 100644
--- a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -906,10 +906,6 @@ ipoib_intf_alloc(const char *name, struct ib_device *hca)
 
 	priv = ipoib_priv_alloc();
 	dev = priv->dev = if_alloc(IFT_INFINIBAND);
-	if (!dev) {
-		free(priv, M_TEMP);
-		return NULL;
-	}
 	if_setsoftc(dev, priv);
 	priv->gone = 2; /* initializing */
 	priv->unit = alloc_unr(ipoib_unrhdr);
diff --git a/sys/powerpc/booke/pmap.c b/sys/powerpc/booke/pmap.c
index f41ea24cd30c..00653fa6d90c 100644
--- a/sys/powerpc/booke/pmap.c
+++ b/sys/powerpc/booke/pmap.c
@@ -1050,8 +1050,9 @@ mmu_booke_kextract(vm_offset_t va)
 
 /*
  * Initialize the pmap module.
- * Called by vm_init, to initialize any structures that the pmap
- * system needs to map virtual memory.
+ *
+ * Called by vm_mem_init(), to initialize any structures that the pmap system
+ * needs to map virtual memory.
  */
 static void
 mmu_booke_init(void)
diff --git a/sys/powerpc/mpc85xx/fsl_sata.c b/sys/powerpc/mpc85xx/fsl_sata.c
index 16a8ec963b27..9279a8d43810 100644
--- a/sys/powerpc/mpc85xx/fsl_sata.c
+++ b/sys/powerpc/mpc85xx/fsl_sata.c
@@ -317,7 +317,7 @@ fsl_sata_probe(device_t dev)
 	    !ofw_bus_is_compatible(dev, "fsl,pq-sata"))
 		return (ENXIO);
 
-	device_set_desc_copy(dev, "Freescale Integrated SATA Controller");
+	device_set_desc(dev, "Freescale Integrated SATA Controller");
 	return (BUS_PROBE_DEFAULT);
 }
 
diff --git a/sys/riscv/include/pmap.h b/sys/riscv/include/pmap.h
index d65935c4ce7f..e10cbacb6e1f 100644
--- a/sys/riscv/include/pmap.h
+++ b/sys/riscv/include/pmap.h
@@ -67,16 +67,6 @@ struct md_page {
 	vm_memattr_t		pv_memattr;
 };
 
-/*
- * This structure is used to hold a virtual<->physical address
- * association and is used mostly by bootstrap code
- */
-struct pv_addr {
-	SLIST_ENTRY(pv_addr) pv_list;
-	vm_offset_t	pv_va;
-	vm_paddr_t	pv_pa;
-};
-
 struct pmap {
 	struct mtx		pm_mtx;
 	struct pmap_statistics	pm_stats;	/* pmap statictics */
diff --git a/sys/riscv/include/vmparam.h b/sys/riscv/include/vmparam.h
index 9a710b667c78..2198245d5b20 100644
--- a/sys/riscv/include/vmparam.h
+++ b/sys/riscv/include/vmparam.h
@@ -242,7 +242,6 @@
 extern vm_paddr_t dmap_phys_base;
 extern vm_paddr_t dmap_phys_max;
 extern vm_offset_t dmap_max_addr;
-extern vm_offset_t vm_max_kernel_address;
 extern vm_offset_t init_pt_va;
 #endif
 
diff --git a/sys/riscv/riscv/machdep.c b/sys/riscv/riscv/machdep.c
index 5872ef9f94ac..61f86f9e6958 100644
--- a/sys/riscv/riscv/machdep.c
+++ b/sys/riscv/riscv/machdep.c
@@ -550,10 +550,6 @@ initriscv(struct riscv_bootparams *rvbp)
 
 	cache_setup();
 
-	/* Bootstrap enough of pmap to enter the kernel proper */
-	kernlen = (lastaddr - KERNBASE);
-	pmap_bootstrap(rvbp->kern_l1pt, rvbp->kern_phys, kernlen);
-
 #ifdef FDT
 	/*
 	 * XXX: Unconditionally exclude the lowest 2MB of physical memory, as
@@ -566,6 +562,11 @@ initriscv(struct riscv_bootparams *rvbp)
 	physmem_exclude_region(mem_regions[0].mr_start, L2_SIZE,
 	    EXFLAG_NODUMP | EXFLAG_NOALLOC);
 #endif
+
+	/* Bootstrap enough of pmap to enter the kernel proper */
+	kernlen = (lastaddr - KERNBASE);
+	pmap_bootstrap(rvbp->kern_l1pt, rvbp->kern_phys, kernlen);
+
 	physmem_init_kernel_globals();
 
 	/* Establish static device mappings */
diff --git a/sys/riscv/riscv/pmap.c b/sys/riscv/riscv/pmap.c
index 8ddc31bed81c..d936cab09dbb 100644
--- a/sys/riscv/riscv/pmap.c
+++ b/sys/riscv/riscv/pmap.c
@@ -715,7 +715,7 @@ pmap_bootstrap(vm_offset_t l1pt, vm_paddr_t kernstart, vm_size_t kernlen)
 		alloc_pages(l0pv, 1);
 		l0p = (void *)l0pv;
 		l1pa = pmap_early_vtophys(l1pt, l1pt);
-		l0p[pmap_l0_index(KERNBASE)] = PTE_V | PTE_A | PTE_D |
+		l0p[pmap_l0_index(KERNBASE)] = PTE_V |
 		    ((l1pa >> PAGE_SHIFT) << PTE_PPN0_S);
 
 		l0pa = pmap_early_vtophys(l1pt, l0pv);
@@ -760,7 +760,8 @@ pmap_page_init(vm_page_t m)
 
 /*
  *	Initialize the pmap module.
- *	Called by vm_init, to initialize any structures that the pmap
+ *
+ *	Called by vm_mem_init(), to initialize any structures that the pmap
  *	system needs to map virtual memory.
  */
 void
diff --git a/sys/rpc/svc.c b/sys/rpc/svc.c
index 6d19a0b1ea7d..1e0e02c23cc1 100644
--- a/sys/rpc/svc.c
+++ b/sys/rpc/svc.c
@@ -1000,6 +1000,7 @@ svc_getreq(SVCXPRT *xprt, struct svc_req **rqstp_ret)
 		 * enable TLS offload first.
 		 */
 		if (xprt->xp_doneddp == 0 && r->rq_proc != NULLPROC &&
+		    xprt->xp_socket != NULL &&
 		    atomic_cmpset_int(&xprt->xp_doneddp, 0, 1)) {
 			if (xprt->xp_socket->so_proto->pr_protocol ==
 			    IPPROTO_TCP) {
diff --git a/sys/security/mac_do/mac_do.c b/sys/security/mac_do/mac_do.c
new file mode 100644
index 000000000000..507e64ea0175
--- /dev/null
+++ b/sys/security/mac_do/mac_do.c
@@ -0,0 +1,545 @@
+/*-
+ * Copyright(c) 2024 Baptiste Daroussin <bapt@FreeBSD.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <sys/param.h>
+#include <sys/malloc.h>
+#include <sys/jail.h>
+#include <sys/kernel.h>
+#include <sys/lock.h>
+#include <sys/module.h>
+#include <sys/mount.h>
+#include <sys/mutex.h>
+#include <sys/priv.h>
+#include <sys/proc.h>
+#include <sys/socket.h>
+#include <sys/sx.h>
+#include <sys/sysctl.h>
+#include <sys/systm.h>
+#include <sys/ucred.h>
+#include <sys/vnode.h>
+
+#include <security/mac/mac_policy.h>
+
+SYSCTL_DECL(_security_mac);
+
+static SYSCTL_NODE(_security_mac, OID_AUTO, do,
+    CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "mac_do policy controls");
+
+static int	do_enabled = 1;
+SYSCTL_INT(_security_mac_do, OID_AUTO, enabled, CTLFLAG_RWTUN,
+    &do_enabled, 0, "Enforce do policy");
+
+static MALLOC_DEFINE(M_DO, "do_rule", "Rules for mac_do");
+
+#define MAC_RULE_STRING_LEN	1024
+
+static unsigned		mac_do_osd_jail_slot;
+
+#define RULE_UID	1
+#define RULE_GID	2
+#define RULE_ANY	3
+
+struct rule {
+	int	from_type;
+	union {
+		uid_t f_uid;
+		gid_t f_gid;
+	};
+	int	to_type;
+	uid_t t_uid;
+	TAILQ_ENTRY(rule) r_entries;
+};
+
+struct mac_do_rule {
+	char string[MAC_RULE_STRING_LEN];
+	TAILQ_HEAD(rulehead, rule) head;
+};
+
+static struct mac_do_rule rules0;
+
+static void
+toast_rules(struct rulehead *head)
+{
+	struct rule *r;
+
+	while ((r = TAILQ_FIRST(head)) != NULL) {
+		TAILQ_REMOVE(head, r, r_entries);
+		free(r, M_DO);
+	}
+}
+
+static int
+parse_rule_element(char *element, struct rule **rule)
+{
+	int error = 0;
+	char *type, *id, *p;
+	struct rule *new;
+
+	new = malloc(sizeof(*new), M_DO, M_ZERO|M_WAITOK);
+
+	type = strsep(&element, "=");
+	if (type == NULL) {
+		error = EINVAL;
+		goto out;
+	}
+	if (strcmp(type, "uid") == 0) {
+		new->from_type = RULE_UID;
+	} else if (strcmp(type, "gid") == 0) {
+		new->from_type = RULE_GID;
+	} else {
+		error = EINVAL;
+		goto out;
+	}
+	id = strsep(&element, ":");
+	if (id == NULL) {
+		error = EINVAL;
+		goto out;
+	}
+	if (new->from_type == RULE_UID)
+		new->f_uid = strtol(id, &p, 10);
+	if (new->from_type == RULE_GID)
+		new->f_gid = strtol(id, &p, 10);
+	if (*p != '\0') {
+		error = EINVAL;
+		goto out;
+	}
+	if (*element == '\0') {
+		error = EINVAL;
+		goto out;
+	}
+	if (strcmp(element, "any") == 0 || strcmp(element, "*") == 0) {
+		new->to_type = RULE_ANY;
+	} else {
+		new->to_type = RULE_UID;
+		new->t_uid = strtol(element, &p, 10);
+		if (*p != '\0') {
+			error = EINVAL;
+			goto out;
+		}
+	}
+out:
+	if (error != 0) {
+		free(new, M_DO);
+		*rule = NULL;
+	} else
+		*rule = new;
+	return (error);
+}
+
+static int
+parse_rules(char *string, struct rulehead *head)
+{
+	struct rule *new;
+	char *element;
+	int error = 0;
+
+	while ((element = strsep(&string, ",")) != NULL) {
+		if (strlen(element) == 0)
+			continue;
+		error = parse_rule_element(element, &new);
+		if (error)
+			goto out;
+		TAILQ_INSERT_TAIL(head, new, r_entries);
+	}
+out:
+	if (error != 0)
+		toast_rules(head);
+	return (error);
+}
+
+static struct mac_do_rule *
+mac_do_rule_find(struct prison *spr, struct prison **prp)
+{
+	struct prison *pr;
+	struct mac_do_rule *rules;
+
+	for (pr = spr;; pr = pr->pr_parent) {
+		mtx_lock(&pr->pr_mtx);
+		if (pr == &prison0) {
+			rules = &rules0;
+			break;
+		}
+		rules = osd_jail_get(pr, mac_do_osd_jail_slot);
+		if (rules != NULL)
+			break;
+		mtx_unlock(&pr->pr_mtx);
+	}
+	*prp = pr;
+
+	return (rules);
+}
+
+static int
+sysctl_rules(SYSCTL_HANDLER_ARGS)
+{
+	char *copy_string, *new_string;
+	struct rulehead head, saved_head;
+	struct prison *pr;
+	struct mac_do_rule *rules;
+	int error;
+
+	rules = mac_do_rule_find(req->td->td_ucred->cr_prison, &pr);
+	mtx_unlock(&pr->pr_mtx);
+	if (req->newptr == NULL)
+		return (sysctl_handle_string(oidp, rules->string, MAC_RULE_STRING_LEN, req));
+
+	new_string = malloc(MAC_RULE_STRING_LEN, M_DO,
+	    M_WAITOK|M_ZERO);
+	mtx_lock(&pr->pr_mtx);
+	strlcpy(new_string, rules->string, MAC_RULE_STRING_LEN);
+	mtx_unlock(&pr->pr_mtx);
+
+	error = sysctl_handle_string(oidp, new_string, MAC_RULE_STRING_LEN, req);
+	if (error)
+		goto out;
+
+	copy_string = strdup(new_string, M_DO);
+	TAILQ_INIT(&head);
+	error = parse_rules(copy_string, &head);
+	free(copy_string, M_DO);
+	if (error)
+		goto out;
+	TAILQ_INIT(&saved_head);
+	mtx_lock(&pr->pr_mtx);
+	TAILQ_CONCAT(&saved_head, &rules->head, r_entries);
+	TAILQ_CONCAT(&rules->head, &head, r_entries);
+	strlcpy(rules->string, new_string, MAC_RULE_STRING_LEN);
+	mtx_unlock(&pr->pr_mtx);
+	toast_rules(&saved_head);
+
+out:
+	free(new_string, M_DO);
+	return (error);
+}
+
+SYSCTL_PROC(_security_mac_do, OID_AUTO, rules,
+    CTLTYPE_STRING|CTLFLAG_RW|CTLFLAG_MPSAFE,
+    0, 0, sysctl_rules, "A",
+    "Rules");
+
+static void
+destroy(struct mac_policy_conf *mpc)
+{
+	osd_jail_deregister(mac_do_osd_jail_slot);
+	toast_rules(&rules0.head);
+}
+
+static void
+mac_do_alloc_prison(struct prison *pr, struct mac_do_rule **lrp)
+{
+	struct prison *ppr;
+	struct mac_do_rule *rules, *new_rules;
+	void **rsv;
+
+	rules = mac_do_rule_find(pr, &ppr);
+	if (ppr == pr)
+		goto done;
+
+	mtx_unlock(&ppr->pr_mtx);
+	new_rules = malloc(sizeof(*new_rules), M_PRISON, M_WAITOK|M_ZERO);
+	rsv = osd_reserve(mac_do_osd_jail_slot);
+	rules = mac_do_rule_find(pr, &ppr);
+	if (ppr == pr) {
+		free(new_rules, M_PRISON);
+		osd_free_reserved(rsv);
+		goto done;
+	}
+	mtx_lock(&pr->pr_mtx);
+	osd_jail_set_reserved(pr, mac_do_osd_jail_slot, rsv, new_rules);
+	TAILQ_INIT(&new_rules->head);
+done:
+	if (lrp != NULL)
+		*lrp = rules;
+	mtx_unlock(&pr->pr_mtx);
+	mtx_unlock(&ppr->pr_mtx);
+}
+
+static void
+mac_do_dealloc_prison(void *data)
+{
+	struct mac_do_rule *r = data;
+
+	toast_rules(&r->head);
+}
+
+static int
+mac_do_prison_set(void *obj, void *data)
+{
+	struct prison *pr = obj;
+	struct vfsoptlist *opts = data;
+	struct rulehead head, saved_head;
+	struct mac_do_rule *rules;
+	char *rules_string, *copy_string;
+	int error, jsys, len;
+
+	error = vfs_copyopt(opts, "mdo", &jsys, sizeof(jsys));
+	if (error == ENOENT)
+		jsys = -1;
+	error = vfs_getopt(opts, "mdo.rules", (void **)&rules_string, &len);
+	if (error == ENOENT)
+		rules = NULL;
+	else
+		jsys = JAIL_SYS_NEW;
+	switch (jsys) {
+	case JAIL_SYS_INHERIT:
+		mtx_lock(&pr->pr_mtx);
+		osd_jail_del(pr, mac_do_osd_jail_slot);
+		mtx_unlock(&pr->pr_mtx);
+		break;
+	case JAIL_SYS_NEW:
+		mac_do_alloc_prison(pr, &rules);
+		if (rules_string == NULL)
+			break;
+		copy_string = strdup(rules_string, M_DO);
+		TAILQ_INIT(&head);
+		error = parse_rules(copy_string, &head);
+		free(copy_string, M_DO);
+		if (error)
+			return (1);
+		TAILQ_INIT(&saved_head);
+		mtx_lock(&pr->pr_mtx);
+		TAILQ_CONCAT(&saved_head, &rules->head, r_entries);
+		TAILQ_CONCAT(&rules->head, &head, r_entries);
+		strlcpy(rules->string, rules_string, MAC_RULE_STRING_LEN);
+		mtx_unlock(&pr->pr_mtx);
+		toast_rules(&saved_head);
+		break;
+	}
+	return (0);
+}
+
+SYSCTL_JAIL_PARAM_SYS_NODE(mdo, CTLFLAG_RW, "Jail MAC/do parameters");
+SYSCTL_JAIL_PARAM_STRING(_mdo, rules, CTLFLAG_RW, MAC_RULE_STRING_LEN,
+    "Jail MAC/do rules");
+
+static int
+mac_do_prison_get(void *obj, void *data)
+{
+	struct prison *ppr, *pr = obj;
+	struct vfsoptlist *opts = data;
+	struct mac_do_rule *rules;
+	int jsys, error;
+
+	rules = mac_do_rule_find(pr, &ppr);
+	error = vfs_setopt(opts, "mdo", &jsys, sizeof(jsys));
+	if (error != 0 && error != ENOENT)
+		goto done;
+	error = vfs_setopts(opts, "mdo.rules", rules->string);
+	if (error != 0 && error != ENOENT)
+		goto done;
+	mtx_unlock(&ppr->pr_mtx);
+	error = 0;
+done:
+	return (0);
+}
+
+static int
+mac_do_prison_create(void *obj, void *data __unused)
+{
+	struct prison *pr = obj;
+
+	mac_do_alloc_prison(pr, NULL);
+	return (0);
+}
+
+static int
+mac_do_prison_remove(void *obj, void *data __unused)
+{
+	struct prison *pr = obj;
+	struct mac_do_rule *r;
+
+	mtx_lock(&pr->pr_mtx);
+	r = osd_jail_get(pr, mac_do_osd_jail_slot);
+	mtx_unlock(&pr->pr_mtx);
+	toast_rules(&r->head);
+	return (0);
+}
+
+static int
+mac_do_prison_check(void *obj, void *data)
+{
+	struct vfsoptlist *opts = data;
+	char *rules_string;
+	int error, jsys, len;
+
+	error = vfs_copyopt(opts, "mdo", &jsys, sizeof(jsys));
+	if (error != ENOENT) {
+		if (error != 0)
+			return (error);
+		if (jsys != JAIL_SYS_NEW && jsys != JAIL_SYS_INHERIT)
+			return (EINVAL);
+	}
+	error = vfs_getopt(opts, "mdo.rules", (void **)&rules_string, &len);
+	if (error != ENOENT) {
+		if (error != 0)
+			return (error);
+		if (len > MAC_RULE_STRING_LEN) {
+			vfs_opterror(opts, "mdo.rules too long");
+			return (ENAMETOOLONG);
+		}
+	}
+	if (error == ENOENT)
+		error = 0;
+	return (error);
+}
+
+static void
+init(struct mac_policy_conf *mpc)
+{
+	static osd_method_t methods[PR_MAXMETHOD] = {
+		[PR_METHOD_CREATE] = mac_do_prison_create,
+		[PR_METHOD_GET] = mac_do_prison_get,
+		[PR_METHOD_SET] = mac_do_prison_set,
+		[PR_METHOD_CHECK] = mac_do_prison_check,
+		[PR_METHOD_REMOVE] = mac_do_prison_remove,
+	};
+	struct prison *pr;
+
+	mac_do_osd_jail_slot = osd_jail_register(mac_do_dealloc_prison, methods);
+	TAILQ_INIT(&rules0.head);
+	sx_slock(&allprison_lock);
+	TAILQ_FOREACH(pr, &allprison, pr_list)
+		mac_do_alloc_prison(pr, NULL);
+	sx_sunlock(&allprison_lock);
+}
+
+static bool
+rule_is_valid(struct ucred *cred, struct rule *r)
+{
+	if (r->from_type == RULE_UID && r->f_uid == cred->cr_uid)
+		return (true);
+	if (r->from_type == RULE_GID && r->f_gid == cred->cr_gid)
+		return (true);
+	return (false);
+}
+
+static int
+priv_grant(struct ucred *cred, int priv)
+{
+	struct rule *r;
+	struct prison *pr;
+	struct mac_do_rule *rule;
+
+	if (do_enabled == 0)
+		return (EPERM);
+
+	rule = mac_do_rule_find(cred->cr_prison, &pr);
+	TAILQ_FOREACH(r, &rule->head, r_entries) {
+		if (rule_is_valid(cred, r)) {
+			switch (priv) {
+			case PRIV_CRED_SETGROUPS:
+			case PRIV_CRED_SETUID:
+				mtx_unlock(&pr->pr_mtx);
+				return (0);
+			default:
+				break;
+			}
+		}
+	}
+	mtx_unlock(&pr->pr_mtx);
+	return (EPERM);
+}
+
+static int
+check_setgroups(struct ucred *cred, int ngrp, gid_t *groups)
+{
+	struct rule *r;
+	char *fullpath = NULL;
+	char *freebuf = NULL;
+	struct prison *pr;
+	struct mac_do_rule *rule;
+
+	if (do_enabled == 0)
+		return (0);
+	if (cred->cr_uid == 0)
+		return (0);
+
+	if (vn_fullpath(curproc->p_textvp, &fullpath, &freebuf) != 0)
+		return (EPERM);
+	if (strcmp(fullpath, "/usr/bin/mdo") != 0) {
+		free(freebuf, M_TEMP);
+		return (EPERM);
+	}
+	free(freebuf, M_TEMP);
+
+	rule = mac_do_rule_find(cred->cr_prison, &pr);
+	TAILQ_FOREACH(r, &rule->head, r_entries) {
+		if (rule_is_valid(cred, r)) {
+			mtx_unlock(&pr->pr_mtx);
+			return (0);
+		}
+	}
+	mtx_unlock(&pr->pr_mtx);
+
+	return (EPERM);
+}
+
+static int
+check_setuid(struct ucred *cred, uid_t uid)
+{
+	struct rule *r;
+	int error;
+	char *fullpath = NULL;
+	char *freebuf = NULL;
+	struct prison *pr;
+	struct mac_do_rule *rule;
+
+	if (do_enabled == 0)
+		return (0);
+	if (cred->cr_uid == uid || cred->cr_uid == 0 || cred->cr_ruid == 0)
+		return (0);
+
+	if (vn_fullpath(curproc->p_textvp, &fullpath, &freebuf) != 0)
+		return (EPERM);
+	if (strcmp(fullpath, "/usr/bin/mdo") != 0) {
+		free(freebuf, M_TEMP);
+		return (EPERM);
+	}
+	free(freebuf, M_TEMP);
+
+	error = EPERM;
+	rule = mac_do_rule_find(cred->cr_prison, &pr);
+	TAILQ_FOREACH(r, &rule->head, r_entries) {
+		if (r->from_type == RULE_UID) {
+			if (cred->cr_uid != r->f_uid)
+				continue;
+			if (r->to_type == RULE_ANY) {
+				error = 0;
+				break;
+			}
+			if (r->to_type == RULE_UID && uid == r->t_uid) {
+				error = 0;
+				break;
+			}
+		}
+		if (r->from_type == RULE_GID) {
+			if (cred->cr_gid != r->f_gid)
+				continue;
+			if (r->to_type == RULE_ANY) {
+				error = 0;
+				break;
+			}
+			if (r->to_type == RULE_UID && uid == r->t_uid) {
+				error = 0;
+				break;
+			}
+		}
+	}
+	mtx_unlock(&pr->pr_mtx);
+	return (error);
+}
+
+static struct mac_policy_ops do_ops = {
+	.mpo_destroy = destroy,
+	.mpo_init = init,
+	.mpo_cred_check_setuid = check_setuid,
+	.mpo_cred_check_setgroups = check_setgroups,
+	.mpo_priv_grant = priv_grant,
+};
+
+MAC_POLICY_SET(&do_ops, mac_do, "MAC/do",
+   MPC_LOADTIME_FLAG_UNLOADOK, NULL);
+MODULE_VERSION(mac_do, 1);
diff --git a/sys/sys/capsicum.h b/sys/sys/capsicum.h
index e2f305462f0d..405a7af419bf 100644
--- a/sys/sys/capsicum.h
+++ b/sys/sys/capsicum.h
@@ -337,6 +337,8 @@ cap_rights_t *__cap_rights_clear(cap_rights_t *rights, ...);
 	__cap_rights_is_set(__VA_ARGS__, 0ULL)
 bool __cap_rights_is_set(const cap_rights_t *rights, ...);
 
+bool cap_rights_is_empty(const cap_rights_t *rights);
+
 bool cap_rights_is_valid(const cap_rights_t *rights);
 cap_rights_t *cap_rights_merge(cap_rights_t *dst, const cap_rights_t *src);
 cap_rights_t *cap_rights_remove(cap_rights_t *dst, const cap_rights_t *src);
diff --git a/sys/sys/iov.h b/sys/sys/iov.h
index 0171fc5a98cf..2ae7e5ac6767 100644
--- a/sys/sys/iov.h
+++ b/sys/sys/iov.h
@@ -46,6 +46,8 @@
 #define	DEFAULT_SCHEMA_NAME	"DEFAULT"
 #define	REQUIRED_SCHEMA_NAME	"REQUIRED"
 
+#define	VF_VLAN_TRUNK		4096
+
 /*
  * Because each PF device is expected to expose a unique set of possible
  * configurations, the SR-IOV infrastructure dynamically queries the PF
diff --git a/sys/sys/iov_schema.h b/sys/sys/iov_schema.h
index cb50f7796d30..66c883540563 100644
--- a/sys/sys/iov_schema.h
+++ b/sys/sys/iov_schema.h
@@ -48,5 +48,6 @@ void	pci_iov_schema_add_uint64(nvlist_t *schema, const char *name,
 	    uint32_t flags, uint64_t defaultVal);
 void	pci_iov_schema_add_unicast_mac(nvlist_t *schema, const char *name,
 	    uint32_t flags, const uint8_t * defaultVal);
-
+void	pci_iov_schema_add_vlan(nvlist_t *schema, const char *name,
+	    uint32_t flags, const uint16_t defaultVal);
 #endif
diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h
index 757eba3165f9..f7925da795cd 100644
--- a/sys/sys/mbuf.h
+++ b/sys/sys/mbuf.h
@@ -67,6 +67,7 @@ SDT_PROBE_DECLARE(sdt, , , m__cljget);
 SDT_PROBE_DECLARE(sdt, , , m__cljset);
 SDT_PROBE_DECLARE(sdt, , , m__free);
 SDT_PROBE_DECLARE(sdt, , , m__freem);
+SDT_PROBE_DECLARE(sdt, , , m__freemp);
 
 #endif /* _KERNEL */
 
@@ -844,6 +845,7 @@ void		 m_extadd(struct mbuf *, char *, u_int, m_ext_free_t,
 u_int		 m_fixhdr(struct mbuf *);
 struct mbuf	*m_fragment(struct mbuf *, int, int);
 void		 m_freem(struct mbuf *);
+void		 m_freemp(struct mbuf *);
 void		 m_free_raw(struct mbuf *);
 struct mbuf	*m_get2(int, int, short, int);
 struct mbuf	*m_get3(int, int, short, int);
diff --git a/sys/sys/param.h b/sys/sys/param.h
index bc22f975991b..cd77156ab17d 100644
--- a/sys/sys/param.h
+++ b/sys/sys/param.h
@@ -75,7 +75,7 @@
  * cannot include sys/param.h and should only be updated here.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 1401500
+#define __FreeBSD_version 1401501
 
 /*
  * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
diff --git a/sys/sys/sched.h b/sys/sys/sched.h
index 9d37e8f0f999..933f05385675 100644
--- a/sys/sys/sched.h
+++ b/sys/sys/sched.h
@@ -180,6 +180,7 @@ static __inline void
 sched_unpin(void)
 {
 	atomic_interrupt_fence();
+	MPASS(curthread->td_pinned > 0);
 	curthread->td_pinned--;
 }
 
diff --git a/sys/sys/sndstat.h b/sys/sys/sndstat.h
index e0e403b1a72a..6fef6502ec89 100644
--- a/sys/sys/sndstat.h
+++ b/sys/sys/sndstat.h
@@ -68,11 +68,38 @@ struct sndstioc_nv_arg {
 /*
  * sound(4)-specific name/value pair names
  */
-#define SNDST_DSPS_SOUND4_PROVIDER	"sound(4)"
-#define SNDST_DSPS_SOUND4_UNIT		"unit"
-#define SNDST_DSPS_SOUND4_BITPERFECT	"bitperfect"
-#define SNDST_DSPS_SOUND4_PVCHAN	"pvchan"
-#define SNDST_DSPS_SOUND4_RVCHAN	"rvchan"
+#define SNDST_DSPS_SOUND4_PROVIDER		"sound(4)"
+#define SNDST_DSPS_SOUND4_UNIT			"unit"
+#define SNDST_DSPS_SOUND4_BITPERFECT		"bitperfect"
+#define SNDST_DSPS_SOUND4_PVCHAN		"pvchan"
+#define SNDST_DSPS_SOUND4_RVCHAN		"rvchan"
+#define SNDST_DSPS_SOUND4_CHAN_INFO		"channel_info"
+#define SNDST_DSPS_SOUND4_CHAN_NAME		"name"
+#define SNDST_DSPS_SOUND4_CHAN_PARENTCHAN	"parentchan"
+#define SNDST_DSPS_SOUND4_CHAN_UNIT		"unit"
+#define SNDST_DSPS_SOUND4_CHAN_LATENCY		"latency"
+#define SNDST_DSPS_SOUND4_CHAN_RATE		"rate"
+#define SNDST_DSPS_SOUND4_CHAN_FORMAT		"format"
+#define SNDST_DSPS_SOUND4_CHAN_PID		"pid"
+#define SNDST_DSPS_SOUND4_CHAN_COMM		"comm"
+#define SNDST_DSPS_SOUND4_CHAN_INTR		"interrupts"
+#define SNDST_DSPS_SOUND4_CHAN_FEEDCNT		"feedcount"
+#define SNDST_DSPS_SOUND4_CHAN_XRUNS		"xruns"
+#define SNDST_DSPS_SOUND4_CHAN_LEFTVOL		"left_volume"
+#define SNDST_DSPS_SOUND4_CHAN_RIGHTVOL		"right_volume"
+#define SNDST_DSPS_SOUND4_CHAN_HWBUF_FORMAT	"hwbuf_format"
+#define SNDST_DSPS_SOUND4_CHAN_HWBUF_SIZE	"hwbuf_size"
+#define SNDST_DSPS_SOUND4_CHAN_HWBUF_BLKSZ	"hwbuf_blksz"
+#define SNDST_DSPS_SOUND4_CHAN_HWBUF_BLKCNT	"hwbuf_blkcnt"
+#define SNDST_DSPS_SOUND4_CHAN_HWBUF_FREE	"hwbuf_free"
+#define SNDST_DSPS_SOUND4_CHAN_HWBUF_READY	"hwbuf_ready"
+#define SNDST_DSPS_SOUND4_CHAN_SWBUF_FORMAT	"swbuf_format"
+#define SNDST_DSPS_SOUND4_CHAN_SWBUF_SIZE	"swbuf_size"
+#define SNDST_DSPS_SOUND4_CHAN_SWBUF_BLKSZ	"swbuf_blksz"
+#define SNDST_DSPS_SOUND4_CHAN_SWBUF_BLKCNT	"swbuf_blkcnt"
+#define SNDST_DSPS_SOUND4_CHAN_SWBUF_FREE	"swbuf_free"
+#define SNDST_DSPS_SOUND4_CHAN_SWBUF_READY	"swbuf_ready"
+#define SNDST_DSPS_SOUND4_CHAN_FEEDERCHAIN	"feederchain"
 
 /*
  * Maximum user-specified nvlist buffer size
diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h
index bc7a2bc601a1..76cbae25f4e5 100644
--- a/sys/sys/sysctl.h
+++ b/sys/sys/sysctl.h
@@ -395,14 +395,14 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
 #define	SYSCTL_CONST_STRING(parent, nbr, name, access, arg, descr)	\
 	SYSCTL_OID(parent, nbr, name, CTLTYPE_STRING | CTLFLAG_MPSAFE | (access),\
 	    __DECONST(char *, arg), 0, sysctl_handle_string, "A", descr); \
-	CTASSERT(!(access & CTLFLAG_WR));				\
+	CTASSERT(!((access) & CTLFLAG_WR));				\
 	CTASSERT(((access) & CTLTYPE) == 0 ||				\
 	    ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_STRING)
 
 #define	SYSCTL_ADD_CONST_STRING(ctx, parent, nbr, name, access, arg, descr) \
 ({									\
 	char *__arg = __DECONST(char *, arg);				\
-	CTASSERT(!(access & CTLFLAG_WR));				\
+	CTASSERT(!((access) & CTLFLAG_WR));				\
 	CTASSERT(((access) & CTLTYPE) == 0 ||				\
 	    ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_STRING);	\
 	sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_STRING | 	\
diff --git a/sys/sys/timeb.h b/sys/sys/timeb.h
index 952a5e83b8a7..853541e27ae6 100644
--- a/sys/sys/timeb.h
+++ b/sys/sys/timeb.h
@@ -39,7 +39,7 @@
 #ifndef _SYS_TIMEB_H_
 #define _SYS_TIMEB_H_
 
-#ifdef __GNUC__
+#if defined(__GNUC__) && !defined(_IN_LIBUITL)
 #warning "this file includes <sys/timeb.h> which is deprecated"
 #endif
 
diff --git a/sys/vm/vm_init.c b/sys/vm/vm_init.c
index 4ca6e22f8a6d..82efb8236c1d 100644
--- a/sys/vm/vm_init.c
+++ b/sys/vm/vm_init.c
@@ -104,7 +104,7 @@ static void vm_mem_init(void *);
 SYSINIT(vm_mem, SI_SUB_VM, SI_ORDER_FIRST, vm_mem_init, NULL);
 
 /*
- *	vm_init initializes the virtual memory system.
+ *	vm_mem_init() initializes the virtual memory system.
  *	This is done only by the first cpu up.
  */
 static void
diff --git a/sys/x86/include/iommu.h b/sys/x86/include/iommu.h
index a95480b53acc..98c6661aa8e3 100644
--- a/sys/x86/include/iommu.h
+++ b/sys/x86/include/iommu.h
@@ -7,6 +7,7 @@
 
 #include <x86/include/busdma_impl.h>
 #include <x86/iommu/intel_reg.h>
+#include <x86/iommu/x86_iommu.h>
 #include <x86/iommu/intel_dmar.h>
 
 #endif /* !_MACHINE_IOMMU_H_ */
diff --git a/sys/x86/iommu/intel_ctx.c b/sys/x86/iommu/intel_ctx.c
index 65ca88b052ed..444640570df7 100644
--- a/sys/x86/iommu/intel_ctx.c
+++ b/sys/x86/iommu/intel_ctx.c
@@ -66,6 +66,7 @@
 #include <x86/include/busdma_impl.h>
 #include <dev/iommu/busdma_iommu.h>
 #include <x86/iommu/intel_reg.h>
+#include <x86/iommu/x86_iommu.h>
 #include <x86/iommu/intel_dmar.h>
 
 static MALLOC_DEFINE(M_DMAR_CTX, "dmar_ctx", "Intel DMAR Context");
@@ -85,7 +86,7 @@ dmar_ensure_ctx_page(struct dmar_unit *dmar, int bus)
 	/*
 	 * Allocated context page must be linked.
 	 */
-	ctxm = dmar_pgalloc(dmar->ctx_obj, 1 + bus, IOMMU_PGF_NOALLOC);
+	ctxm = iommu_pgalloc(dmar->ctx_obj, 1 + bus, IOMMU_PGF_NOALLOC);
 	if (ctxm != NULL)
 		return;
 
@@ -96,14 +97,14 @@ dmar_ensure_ctx_page(struct dmar_unit *dmar, int bus)
 	 * threads are equal.
 	 */
 	TD_PREP_PINNED_ASSERT;
-	ctxm = dmar_pgalloc(dmar->ctx_obj, 1 + bus, IOMMU_PGF_ZERO |
+	ctxm = iommu_pgalloc(dmar->ctx_obj, 1 + bus, IOMMU_PGF_ZERO |
 	    IOMMU_PGF_WAITOK);
-	re = dmar_map_pgtbl(dmar->ctx_obj, 0, IOMMU_PGF_NOALLOC, &sf);
+	re = iommu_map_pgtbl(dmar->ctx_obj, 0, IOMMU_PGF_NOALLOC, &sf);
 	re += bus;
 	dmar_pte_store(&re->r1, DMAR_ROOT_R1_P | (DMAR_ROOT_R1_CTP_MASK &
 	    VM_PAGE_TO_PHYS(ctxm)));
 	dmar_flush_root_to_ram(dmar, re);
-	dmar_unmap_pgtbl(sf);
+	iommu_unmap_pgtbl(sf);
 	TD_PINNED_ASSERT;
 }
 
@@ -115,7 +116,7 @@ dmar_map_ctx_entry(struct dmar_ctx *ctx, struct sf_buf **sfp)
 
 	dmar = CTX2DMAR(ctx);
 
-	ctxp = dmar_map_pgtbl(dmar->ctx_obj, 1 + PCI_RID2BUS(ctx->context.rid),
+	ctxp = iommu_map_pgtbl(dmar->ctx_obj, 1 + PCI_RID2BUS(ctx->context.rid),
 	    IOMMU_PGF_NOALLOC | IOMMU_PGF_WAITOK, sfp);
 	ctxp += ctx->context.rid & 0xff;
 	return (ctxp);
@@ -188,7 +189,7 @@ ctx_id_entry_init(struct dmar_ctx *ctx, dmar_ctx_entry_t *ctxp, bool move,
 		    ("ctx %p non-null pgtbl_obj", ctx));
 		ctx_root = NULL;
 	} else {
-		ctx_root = dmar_pgalloc(domain->pgtbl_obj, 0,
+		ctx_root = iommu_pgalloc(domain->pgtbl_obj, 0,
 		    IOMMU_PGF_NOALLOC);
 	}
 
@@ -274,7 +275,7 @@ domain_init_rmrr(struct dmar_domain *domain, device_t dev, int bus,
 				    "region (%jx, %jx) corrected\n",
 				    domain->iodom.iommu->unit, start, end);
 			}
-			entry->end += DMAR_PAGE_SIZE * 0x20;
+			entry->end += IOMMU_PAGE_SIZE * 0x20;
 		}
 		size = OFF_TO_IDX(entry->end - entry->start);
 		ma = malloc(sizeof(vm_page_t) * size, M_TEMP, M_WAITOK);
@@ -603,9 +604,9 @@ dmar_get_ctx_for_dev1(struct dmar_unit *dmar, device_t dev, uint16_t rid,
 				    func, rid, domain->domain, domain->mgaw,
 				    domain->agaw, id_mapped ? "id" : "re");
 			}
-			dmar_unmap_pgtbl(sf);
+			iommu_unmap_pgtbl(sf);
 		} else {
-			dmar_unmap_pgtbl(sf);
+			iommu_unmap_pgtbl(sf);
 			dmar_domain_destroy(domain1);
 			/* Nothing needs to be done to destroy ctx1. */
 			free(ctx1, M_DMAR_CTX);
@@ -705,7 +706,7 @@ dmar_move_ctx_to_domain(struct dmar_domain *domain, struct dmar_ctx *ctx)
 	ctx->context.domain = &domain->iodom;
 	dmar_ctx_link(ctx);
 	ctx_id_entry_init(ctx, ctxp, true, PCI_BUSMAX + 100);
-	dmar_unmap_pgtbl(sf);
+	iommu_unmap_pgtbl(sf);
 	error = dmar_flush_for_ctx_entry(dmar, true);
 	/* If flush failed, rolling back would not work as well. */
 	printf("dmar%d rid %x domain %d->%d %s-mapped\n",
@@ -789,7 +790,7 @@ dmar_free_ctx_locked(struct dmar_unit *dmar, struct dmar_ctx *ctx)
 	if (ctx->refs > 1) {
 		ctx->refs--;
 		DMAR_UNLOCK(dmar);
-		dmar_unmap_pgtbl(sf);
+		iommu_unmap_pgtbl(sf);
 		TD_PINNED_ASSERT;
 		return;
 	}
@@ -811,7 +812,7 @@ dmar_free_ctx_locked(struct dmar_unit *dmar, struct dmar_ctx *ctx)
 		else
 			dmar_inv_iotlb_glob(dmar);
 	}
-	dmar_unmap_pgtbl(sf);
+	iommu_unmap_pgtbl(sf);
 	domain = CTX2DOM(ctx);
 	dmar_ctx_unlink(ctx);
 	free(ctx->context.tag, M_DMAR_CTX);
diff --git a/sys/x86/iommu/intel_dmar.h b/sys/x86/iommu/intel_dmar.h
index e20144094c80..b7f0300e16f0 100644
--- a/sys/x86/iommu/intel_dmar.h
+++ b/sys/x86/iommu/intel_dmar.h
@@ -123,7 +123,6 @@ struct dmar_msi_data {
 
 struct dmar_unit {
 	struct iommu_unit iommu;
-	device_t dev;
 	uint16_t segment;
 	uint64_t base;
 
@@ -238,16 +237,11 @@ iommu_gaddr_t pglvl_page_size(int total_pglvl, int lvl);
 iommu_gaddr_t domain_page_size(struct dmar_domain *domain, int lvl);
 int calc_am(struct dmar_unit *unit, iommu_gaddr_t base, iommu_gaddr_t size,
     iommu_gaddr_t *isizep);
-struct vm_page *dmar_pgalloc(vm_object_t obj, vm_pindex_t idx, int flags);
-void dmar_pgfree(vm_object_t obj, vm_pindex_t idx, int flags);
-void *dmar_map_pgtbl(vm_object_t obj, vm_pindex_t idx, int flags,
-    struct sf_buf **sf);
-void dmar_unmap_pgtbl(struct sf_buf *sf);
 int dmar_load_root_entry_ptr(struct dmar_unit *unit);
 int dmar_inv_ctx_glob(struct dmar_unit *unit);
 int dmar_inv_iotlb_glob(struct dmar_unit *unit);
 int dmar_flush_write_bufs(struct dmar_unit *unit);
-void dmar_flush_pte_to_ram(struct dmar_unit *unit, dmar_pte_t *dst);
+void dmar_flush_pte_to_ram(struct dmar_unit *unit, iommu_pte_t *dst);
 void dmar_flush_ctx_to_ram(struct dmar_unit *unit, dmar_ctx_entry_t *dst);
 void dmar_flush_root_to_ram(struct dmar_unit *unit, dmar_root_entry_t *dst);
 int dmar_disable_protected_regions(struct dmar_unit *unit);
@@ -315,9 +309,7 @@ void dmar_quirks_pre_use(struct iommu_unit *dmar);
 int dmar_init_irt(struct dmar_unit *unit);
 void dmar_fini_irt(struct dmar_unit *unit);
 
-extern iommu_haddr_t dmar_high;
 extern int haw;
-extern int dmar_tbl_pagecnt;
 extern int dmar_batch_coalesce;
 extern int dmar_rmrr_enable;
 
diff --git a/sys/x86/iommu/intel_drv.c b/sys/x86/iommu/intel_drv.c
index 7346162d1502..0b25620114cd 100644
--- a/sys/x86/iommu/intel_drv.c
+++ b/sys/x86/iommu/intel_drv.c
@@ -67,6 +67,7 @@
 #include <x86/include/busdma_impl.h>
 #include <dev/iommu/busdma_iommu.h>
 #include <x86/iommu/intel_reg.h>
+#include <x86/iommu/x86_iommu.h>
 #include <x86/iommu/intel_dmar.h>
 
 #ifdef DEV_APIC
@@ -179,9 +180,9 @@ dmar_identify(driver_t *driver, device_t parent)
 		return;
 	haw = dmartbl->Width + 1;
 	if ((1ULL << (haw + 1)) > BUS_SPACE_MAXADDR)
-		dmar_high = BUS_SPACE_MAXADDR;
+		iommu_high = BUS_SPACE_MAXADDR;
 	else
-		dmar_high = 1ULL << (haw + 1);
+		iommu_high = 1ULL << (haw + 1);
 	if (bootverbose) {
 		printf("DMAR HAW=%d flags=<%b>\n", dmartbl->Width,
 		    (unsigned)dmartbl->Flags,
@@ -409,7 +410,6 @@ dmar_attach(device_t dev)
 	int i, error;
 
 	unit = device_get_softc(dev);
-	unit->dev = dev;
 	unit->iommu.unit = device_get_unit(dev);
 	unit->iommu.dev = dev;
 	dmaru = dmar_find_by_index(unit->iommu.unit);
@@ -490,7 +490,7 @@ dmar_attach(device_t dev)
 	 * address translation after the required invalidations are
 	 * done.
 	 */
-	dmar_pgalloc(unit->ctx_obj, 0, IOMMU_PGF_WAITOK | IOMMU_PGF_ZERO);
+	iommu_pgalloc(unit->ctx_obj, 0, IOMMU_PGF_WAITOK | IOMMU_PGF_ZERO);
 	DMAR_LOCK(unit);
 	error = dmar_load_root_entry_ptr(unit);
 	if (error != 0) {
diff --git a/sys/x86/iommu/intel_fault.c b/sys/x86/iommu/intel_fault.c
index e275304c8d51..59b482720cf1 100644
--- a/sys/x86/iommu/intel_fault.c
+++ b/sys/x86/iommu/intel_fault.c
@@ -54,6 +54,7 @@
 #include <x86/include/busdma_impl.h>
 #include <x86/iommu/intel_reg.h>
 #include <dev/iommu/busdma_iommu.h>
+#include <x86/iommu/x86_iommu.h>
 #include <x86/iommu/intel_dmar.h>
 
 /*
diff --git a/sys/x86/iommu/intel_idpgtbl.c b/sys/x86/iommu/intel_idpgtbl.c
index 26f067e35278..82cac8bb2d39 100644
--- a/sys/x86/iommu/intel_idpgtbl.c
+++ b/sys/x86/iommu/intel_idpgtbl.c
@@ -64,6 +64,7 @@
 #include <x86/include/busdma_impl.h>
 #include <dev/iommu/busdma_iommu.h>
 #include <x86/iommu/intel_reg.h>
+#include <x86/iommu/x86_iommu.h>
 #include <x86/iommu/intel_dmar.h>
 
 static int domain_unmap_buf_locked(struct dmar_domain *domain,
@@ -109,7 +110,7 @@ domain_idmap_nextlvl(struct idpgtbl *tbl, int lvl, vm_pindex_t idx,
     iommu_gaddr_t addr)
 {
 	vm_page_t m1;
-	dmar_pte_t *pte;
+	iommu_pte_t *pte;
 	struct sf_buf *sf;
 	iommu_gaddr_t f, pg_sz;
 	vm_pindex_t base;
@@ -118,28 +119,28 @@ domain_idmap_nextlvl(struct idpgtbl *tbl, int lvl, vm_pindex_t idx,
 	VM_OBJECT_ASSERT_LOCKED(tbl->pgtbl_obj);
 	if (addr >= tbl->maxaddr)
 		return;
-	(void)dmar_pgalloc(tbl->pgtbl_obj, idx, IOMMU_PGF_OBJL |
+	(void)iommu_pgalloc(tbl->pgtbl_obj, idx, IOMMU_PGF_OBJL |
 	    IOMMU_PGF_WAITOK | IOMMU_PGF_ZERO);
-	base = idx * DMAR_NPTEPG + 1; /* Index of the first child page of idx */
+	base = idx * IOMMU_NPTEPG + 1; /* Index of the first child page of idx */
 	pg_sz = pglvl_page_size(tbl->pglvl, lvl);
 	if (lvl != tbl->leaf) {
-		for (i = 0, f = addr; i < DMAR_NPTEPG; i++, f += pg_sz)
+		for (i = 0, f = addr; i < IOMMU_NPTEPG; i++, f += pg_sz)
 			domain_idmap_nextlvl(tbl, lvl + 1, base + i, f);
 	}
 	VM_OBJECT_WUNLOCK(tbl->pgtbl_obj);
-	pte = dmar_map_pgtbl(tbl->pgtbl_obj, idx, IOMMU_PGF_WAITOK, &sf);
+	pte = iommu_map_pgtbl(tbl->pgtbl_obj, idx, IOMMU_PGF_WAITOK, &sf);
 	if (lvl == tbl->leaf) {
-		for (i = 0, f = addr; i < DMAR_NPTEPG; i++, f += pg_sz) {
+		for (i = 0, f = addr; i < IOMMU_NPTEPG; i++, f += pg_sz) {
 			if (f >= tbl->maxaddr)
 				break;
 			pte[i].pte = (DMAR_PTE_ADDR_MASK & f) |
 			    DMAR_PTE_R | DMAR_PTE_W;
 		}
 	} else {
-		for (i = 0, f = addr; i < DMAR_NPTEPG; i++, f += pg_sz) {
+		for (i = 0, f = addr; i < IOMMU_NPTEPG; i++, f += pg_sz) {
 			if (f >= tbl->maxaddr)
 				break;
-			m1 = dmar_pgalloc(tbl->pgtbl_obj, base + i,
+			m1 = iommu_pgalloc(tbl->pgtbl_obj, base + i,
 			    IOMMU_PGF_NOALLOC);
 			KASSERT(m1 != NULL, ("lost page table page"));
 			pte[i].pte = (DMAR_PTE_ADDR_MASK &
@@ -147,7 +148,7 @@ domain_idmap_nextlvl(struct idpgtbl *tbl, int lvl, vm_pindex_t idx,
 		}
 	}
 	/* domain_get_idmap_pgtbl flushes CPU cache if needed. */
-	dmar_unmap_pgtbl(sf);
+	iommu_unmap_pgtbl(sf);
 	VM_OBJECT_WLOCK(tbl->pgtbl_obj);
 }
 
@@ -301,7 +302,7 @@ put_idmap_pgtbl(vm_object_t obj)
 		rmobj = tbl->pgtbl_obj;
 		if (rmobj->ref_count == 1) {
 			LIST_REMOVE(tbl, link);
-			atomic_subtract_int(&dmar_tbl_pagecnt,
+			atomic_subtract_int(&iommu_tbl_pagecnt,
 			    rmobj->resident_page_count);
 			vm_object_deallocate(rmobj);
 			free(tbl, M_DMAR_IDPGTBL);
@@ -323,9 +324,9 @@ static int
 domain_pgtbl_pte_off(struct dmar_domain *domain, iommu_gaddr_t base, int lvl)
 {
 
-	base >>= DMAR_PAGE_SHIFT + (domain->pglvl - lvl - 1) *
-	    DMAR_NPTEPGSHIFT;
-	return (base & DMAR_PTEMASK);
+	base >>= IOMMU_PAGE_SHIFT + (domain->pglvl - lvl - 1) *
+	    IOMMU_NPTEPGSHIFT;
+	return (base & IOMMU_PTEMASK);
 }
 
 /*
@@ -344,18 +345,18 @@ domain_pgtbl_get_pindex(struct dmar_domain *domain, iommu_gaddr_t base, int lvl)
 
 	for (pidx = idx = 0, i = 0; i < lvl; i++, pidx = idx) {
 		idx = domain_pgtbl_pte_off(domain, base, i) +
-		    pidx * DMAR_NPTEPG + 1;
+		    pidx * IOMMU_NPTEPG + 1;
 	}
 	return (idx);
 }
 
-static dmar_pte_t *
+static iommu_pte_t *
 domain_pgtbl_map_pte(struct dmar_domain *domain, iommu_gaddr_t base, int lvl,
     int flags, vm_pindex_t *idxp, struct sf_buf **sf)
 {
 	vm_page_t m;
 	struct sf_buf *sfp;
-	dmar_pte_t *pte, *ptep;
+	iommu_pte_t *pte, *ptep;
 	vm_pindex_t idx, idx1;
 
 	DMAR_DOMAIN_ASSERT_PGLOCKED(domain);
@@ -363,13 +364,13 @@ domain_pgtbl_map_pte(struct dmar_domain *domain, iommu_gaddr_t base, int lvl,
 
 	idx = domain_pgtbl_get_pindex(domain, base, lvl);
 	if (*sf != NULL && idx == *idxp) {
-		pte = (dmar_pte_t *)sf_buf_kva(*sf);
+		pte = (iommu_pte_t *)sf_buf_kva(*sf);
 	} else {
 		if (*sf != NULL)
-			dmar_unmap_pgtbl(*sf);
+			iommu_unmap_pgtbl(*sf);
 		*idxp = idx;
 retry:
-		pte = dmar_map_pgtbl(domain->pgtbl_obj, idx, flags, sf);
+		pte = iommu_map_pgtbl(domain->pgtbl_obj, idx, flags, sf);
 		if (pte == NULL) {
 			KASSERT(lvl > 0,
 			    ("lost root page table page %p", domain));
@@ -378,7 +379,7 @@ domain_pgtbl_map_pte(struct dmar_domain *domain, iommu_gaddr_t base, int lvl,
 			 * it and create a pte in the preceeding page level
 			 * to reference the allocated page table page.
 			 */
-			m = dmar_pgalloc(domain->pgtbl_obj, idx, flags |
+			m = iommu_pgalloc(domain->pgtbl_obj, idx, flags |
 			    IOMMU_PGF_ZERO);
 			if (m == NULL)
 				return (NULL);
@@ -399,7 +400,7 @@ domain_pgtbl_map_pte(struct dmar_domain *domain, iommu_gaddr_t base, int lvl,
 				KASSERT(m->pindex != 0,
 				    ("loosing root page %p", domain));
 				m->ref_count--;
-				dmar_pgfree(domain->pgtbl_obj, m->pindex,
+				iommu_pgfree(domain->pgtbl_obj, m->pindex,
 				    flags);
 				return (NULL);
 			}
@@ -408,7 +409,7 @@ domain_pgtbl_map_pte(struct dmar_domain *domain, iommu_gaddr_t base, int lvl,
 			dmar_flush_pte_to_ram(domain->dmar, ptep);
 			sf_buf_page(sfp)->ref_count += 1;
 			m->ref_count--;
-			dmar_unmap_pgtbl(sfp);
+			iommu_unmap_pgtbl(sfp);
 			/* Only executed once. */
 			goto retry;
 		}
@@ -421,7 +422,7 @@ static int
 domain_map_buf_locked(struct dmar_domain *domain, iommu_gaddr_t base,
     iommu_gaddr_t size, vm_page_t *ma, uint64_t pflags, int flags)
 {
-	dmar_pte_t *pte;
+	iommu_pte_t *pte;
 	struct sf_buf *sf;
 	iommu_gaddr_t pg_sz, base1;
 	vm_pindex_t pi, c, idx, run_sz;
@@ -438,7 +439,7 @@ domain_map_buf_locked(struct dmar_domain *domain, iommu_gaddr_t base,
 	    pi += run_sz) {
 		for (lvl = 0, c = 0, superpage = false;; lvl++) {
 			pg_sz = domain_page_size(domain, lvl);
-			run_sz = pg_sz >> DMAR_PAGE_SHIFT;
+			run_sz = pg_sz >> IOMMU_PAGE_SHIFT;
 			if (lvl == domain->pglvl - 1)
 				break;
 			/*
@@ -477,7 +478,7 @@ domain_map_buf_locked(struct dmar_domain *domain, iommu_gaddr_t base,
 			KASSERT((flags & IOMMU_PGF_WAITOK) == 0,
 			    ("failed waitable pte alloc %p", domain));
 			if (sf != NULL)
-				dmar_unmap_pgtbl(sf);
+				iommu_unmap_pgtbl(sf);
 			domain_unmap_buf_locked(domain, base1, base - base1,
 			    flags);
 			TD_PINNED_ASSERT;
@@ -489,7 +490,7 @@ domain_map_buf_locked(struct dmar_domain *domain, iommu_gaddr_t base,
 		sf_buf_page(sf)->ref_count += 1;
 	}
 	if (sf != NULL)
-		dmar_unmap_pgtbl(sf);
+		iommu_unmap_pgtbl(sf);
 	TD_PINNED_ASSERT;
 	return (0);
 }
@@ -513,10 +514,10 @@ domain_map_buf(struct iommu_domain *iodom, iommu_gaddr_t base,
 
 	KASSERT((domain->iodom.flags & IOMMU_DOMAIN_IDMAP) == 0,
 	    ("modifying idmap pagetable domain %p", domain));
-	KASSERT((base & DMAR_PAGE_MASK) == 0,
+	KASSERT((base & IOMMU_PAGE_MASK) == 0,
 	    ("non-aligned base %p %jx %jx", domain, (uintmax_t)base,
 	    (uintmax_t)size));
-	KASSERT((size & DMAR_PAGE_MASK) == 0,
+	KASSERT((size & IOMMU_PAGE_MASK) == 0,
 	    ("non-aligned size %p %jx %jx", domain, (uintmax_t)base,
 	    (uintmax_t)size));
 	KASSERT(size > 0, ("zero size %p %jx %jx", domain, (uintmax_t)base,
@@ -563,7 +564,7 @@ domain_map_buf(struct iommu_domain *iodom, iommu_gaddr_t base,
 }
 
 static void domain_unmap_clear_pte(struct dmar_domain *domain,
-    iommu_gaddr_t base, int lvl, int flags, dmar_pte_t *pte,
+    iommu_gaddr_t base, int lvl, int flags, iommu_pte_t *pte,
     struct sf_buf **sf, bool free_fs);
 
 static void
@@ -571,7 +572,7 @@ domain_free_pgtbl_pde(struct dmar_domain *domain, iommu_gaddr_t base,
     int lvl, int flags)
 {
 	struct sf_buf *sf;
-	dmar_pte_t *pde;
+	iommu_pte_t *pde;
 	vm_pindex_t idx;
 
 	sf = NULL;
@@ -581,7 +582,7 @@ domain_free_pgtbl_pde(struct dmar_domain *domain, iommu_gaddr_t base,
 
 static void
 domain_unmap_clear_pte(struct dmar_domain *domain, iommu_gaddr_t base, int lvl,
-    int flags, dmar_pte_t *pte, struct sf_buf **sf, bool free_sf)
+    int flags, iommu_pte_t *pte, struct sf_buf **sf, bool free_sf)
 {
 	vm_page_t m;
 
@@ -589,7 +590,7 @@ domain_unmap_clear_pte(struct dmar_domain *domain, iommu_gaddr_t base, int lvl,
 	dmar_flush_pte_to_ram(domain->dmar, pte);
 	m = sf_buf_page(*sf);
 	if (free_sf) {
-		dmar_unmap_pgtbl(*sf);
+		iommu_unmap_pgtbl(*sf);
 		*sf = NULL;
 	}
 	m->ref_count--;
@@ -601,7 +602,7 @@ domain_unmap_clear_pte(struct dmar_domain *domain, iommu_gaddr_t base, int lvl,
 	KASSERT(m->pindex != 0,
 	    ("lost reference (idx) on root pg domain %p base %jx lvl %d",
 	    domain, (uintmax_t)base, lvl));
-	dmar_pgfree(domain->pgtbl_obj, m->pindex, flags);
+	iommu_pgfree(domain->pgtbl_obj, m->pindex, flags);
 	domain_free_pgtbl_pde(domain, base, lvl - 1, flags);
 }
 
@@ -612,7 +613,7 @@ static int
 domain_unmap_buf_locked(struct dmar_domain *domain, iommu_gaddr_t base,
     iommu_gaddr_t size, int flags)
 {
-	dmar_pte_t *pte;
+	iommu_pte_t *pte;
 	struct sf_buf *sf;
 	vm_pindex_t idx;
 	iommu_gaddr_t pg_sz;
@@ -624,10 +625,10 @@ domain_unmap_buf_locked(struct dmar_domain *domain, iommu_gaddr_t base,
 
 	KASSERT((domain->iodom.flags & IOMMU_DOMAIN_IDMAP) == 0,
 	    ("modifying idmap pagetable domain %p", domain));
-	KASSERT((base & DMAR_PAGE_MASK) == 0,
+	KASSERT((base & IOMMU_PAGE_MASK) == 0,
 	    ("non-aligned base %p %jx %jx", domain, (uintmax_t)base,
 	    (uintmax_t)size));
-	KASSERT((size & DMAR_PAGE_MASK) == 0,
+	KASSERT((size & IOMMU_PAGE_MASK) == 0,
 	    ("non-aligned size %p %jx %jx", domain, (uintmax_t)base,
 	    (uintmax_t)size));
 	KASSERT(base < (1ULL << domain->agaw),
@@ -670,7 +671,7 @@ domain_unmap_buf_locked(struct dmar_domain *domain, iommu_gaddr_t base,
 		    (uintmax_t)base, (uintmax_t)size, (uintmax_t)pg_sz));
 	}
 	if (sf != NULL)
-		dmar_unmap_pgtbl(sf);
+		iommu_unmap_pgtbl(sf);
 	/*
 	 * See 11.1 Write Buffer Flushing for an explanation why RWBF
 	 * can be ignored there.
@@ -706,7 +707,7 @@ domain_alloc_pgtbl(struct dmar_domain *domain)
 	domain->pgtbl_obj = vm_pager_allocate(OBJT_PHYS, NULL,
 	    IDX_TO_OFF(pglvl_max_pages(domain->pglvl)), 0, 0, NULL);
 	DMAR_DOMAIN_PGLOCK(domain);
-	m = dmar_pgalloc(domain->pgtbl_obj, 0, IOMMU_PGF_WAITOK |
+	m = iommu_pgalloc(domain->pgtbl_obj, 0, IOMMU_PGF_WAITOK |
 	    IOMMU_PGF_ZERO | IOMMU_PGF_OBJL);
 	/* No implicit free of the top level page table page. */
 	m->ref_count = 1;
diff --git a/sys/x86/iommu/intel_intrmap.c b/sys/x86/iommu/intel_intrmap.c
index b2642197902a..137801125c38 100644
--- a/sys/x86/iommu/intel_intrmap.c
+++ b/sys/x86/iommu/intel_intrmap.c
@@ -55,6 +55,7 @@
 #include <x86/include/busdma_impl.h>
 #include <dev/iommu/busdma_iommu.h>
 #include <x86/iommu/intel_reg.h>
+#include <x86/iommu/x86_iommu.h>
 #include <x86/iommu/intel_dmar.h>
 #include <x86/iommu/iommu_intrmap.h>
 
@@ -271,7 +272,7 @@ dmar_ir_program_irte(struct dmar_unit *unit, u_int idx, uint64_t low,
 	high = DMAR_IRTE2_SVT_RID | DMAR_IRTE2_SQ_RID |
 	    DMAR_IRTE2_SID_RID(rid);
 	if (bootverbose) {
-		device_printf(unit->dev,
+		device_printf(unit->iommu.dev,
 		    "programming irte[%d] rid %#x high %#jx low %#jx\n",
 		    idx, rid, (uintmax_t)high, (uintmax_t)low);
 	}
@@ -335,13 +336,13 @@ dmar_init_irt(struct dmar_unit *unit)
 	if (!unit->qi_enabled) {
 		unit->ir_enabled = 0;
 		if (bootverbose)
-			device_printf(unit->dev,
+			device_printf(unit->iommu.dev,
 	     "QI disabled, disabling interrupt remapping\n");
 		return (0);
 	}
 	unit->irte_cnt = clp2(num_io_irqs);
 	unit->irt = kmem_alloc_contig(unit->irte_cnt * sizeof(dmar_irte_t),
-	    M_ZERO | M_WAITOK, 0, dmar_high, PAGE_SIZE, 0,
+	    M_ZERO | M_WAITOK, 0, iommu_high, PAGE_SIZE, 0,
 	    DMAR_IS_COHERENT(unit) ?
 	    VM_MEMATTR_DEFAULT : VM_MEMATTR_UNCACHEABLE);
 	if (unit->irt == NULL)
diff --git a/sys/x86/iommu/intel_qi.c b/sys/x86/iommu/intel_qi.c
index 37e2bf211e32..590cbac9bcbd 100644
--- a/sys/x86/iommu/intel_qi.c
+++ b/sys/x86/iommu/intel_qi.c
@@ -55,6 +55,7 @@
 #include <x86/include/busdma_impl.h>
 #include <dev/iommu/busdma_iommu.h>
 #include <x86/iommu/intel_reg.h>
+#include <x86/iommu/x86_iommu.h>
 #include <x86/iommu/intel_dmar.h>
 
 static bool
@@ -501,7 +502,7 @@ dmar_init_qi(struct dmar_unit *unit)
 
 	/* The invalidation queue reads by DMARs are always coherent. */
 	unit->inv_queue = kmem_alloc_contig(unit->inv_queue_size, M_WAITOK |
-	    M_ZERO, 0, dmar_high, PAGE_SIZE, 0, VM_MEMATTR_DEFAULT);
+	    M_ZERO, 0, iommu_high, PAGE_SIZE, 0, VM_MEMATTR_DEFAULT);
 	unit->inv_waitd_seq_hw_phys = pmap_kextract(
 	    (vm_offset_t)&unit->inv_waitd_seq_hw);
 
diff --git a/sys/x86/iommu/intel_quirks.c b/sys/x86/iommu/intel_quirks.c
index 589764bd0fa9..b405a24c4c8c 100644
--- a/sys/x86/iommu/intel_quirks.c
+++ b/sys/x86/iommu/intel_quirks.c
@@ -59,6 +59,7 @@
 #include <x86/include/busdma_impl.h>
 #include <dev/iommu/busdma_iommu.h>
 #include <x86/iommu/intel_reg.h>
+#include <x86/iommu/x86_iommu.h>
 #include <x86/iommu/intel_dmar.h>
 
 typedef void (*dmar_quirk_cpu_fun)(struct dmar_unit *);
@@ -108,7 +109,7 @@ dmar_match_quirks(struct dmar_unit *dmar,
 				    (nb_quirk->rev_no == rev_no ||
 				    nb_quirk->rev_no == QUIRK_NB_ALL_REV)) {
 					if (bootverbose) {
-						device_printf(dmar->dev,
+						device_printf(dmar->iommu.dev,
 						    "NB IOMMU quirk %s\n",
 						    nb_quirk->descr);
 					}
@@ -116,7 +117,8 @@ dmar_match_quirks(struct dmar_unit *dmar,
 				}
 			}
 		} else {
-			device_printf(dmar->dev, "cannot find northbridge\n");
+			device_printf(dmar->iommu.dev,
+			    "cannot find northbridge\n");
 		}
 	}
 	if (cpu_quirks != NULL) {
@@ -135,7 +137,7 @@ dmar_match_quirks(struct dmar_unit *dmar,
 			    (cpu_quirk->stepping == -1 ||
 			    cpu_quirk->stepping == stepping)) {
 				if (bootverbose) {
-					device_printf(dmar->dev,
+					device_printf(dmar->iommu.dev,
 					    "CPU IOMMU quirk %s\n",
 					    cpu_quirk->descr);
 				}
diff --git a/sys/x86/iommu/intel_reg.h b/sys/x86/iommu/intel_reg.h
index 26a18ff94890..0fafcce7accf 100644
--- a/sys/x86/iommu/intel_reg.h
+++ b/sys/x86/iommu/intel_reg.h
@@ -31,16 +31,6 @@
 #ifndef __X86_IOMMU_INTEL_REG_H
 #define	__X86_IOMMU_INTEL_REG_H
 
-#define	DMAR_PAGE_SIZE	PAGE_SIZE
-#define	DMAR_PAGE_MASK	(DMAR_PAGE_SIZE - 1)
-#define	DMAR_PAGE_SHIFT	PAGE_SHIFT
-#define	DMAR_NPTEPG	(DMAR_PAGE_SIZE / sizeof(dmar_pte_t))
-#define	DMAR_NPTEPGSHIFT 9
-#define	DMAR_PTEMASK	(DMAR_NPTEPG - 1)
-
-#define	IOMMU_PAGE_SIZE	DMAR_PAGE_SIZE
-#define	IOMMU_PAGE_MASK	DMAR_PAGE_MASK
-
 typedef struct dmar_root_entry {
 	uint64_t r1;
 	uint64_t r2;
@@ -49,7 +39,7 @@ typedef struct dmar_root_entry {
 #define	DMAR_ROOT_R1_CTP_MASK	0xfffffffffffff000 /* Mask for Context-Entry
 						      Table Pointer */
 
-#define	DMAR_CTX_CNT		(DMAR_PAGE_SIZE / sizeof(dmar_root_entry_t))
+#define	DMAR_CTX_CNT		(IOMMU_PAGE_SIZE / sizeof(dmar_root_entry_t))
 
 typedef	struct dmar_ctx_entry {
 	uint64_t ctx1;
@@ -73,9 +63,6 @@ typedef	struct dmar_ctx_entry {
 #define	DMAR_CTX2_DID(x)	((x) << 8)	/* Domain Identifier */
 #define	DMAR_CTX2_GET_DID(ctx2)	(((ctx2) & DMAR_CTX2_DID_MASK) >> 8)
 
-typedef struct dmar_pte {
-	uint64_t pte;
-} dmar_pte_t;
 #define	DMAR_PTE_R		1		/* Read */
 #define	DMAR_PTE_W		(1 << 1)	/* Write */
 #define	DMAR_PTE_SP		(1 << 7)	/* Super Page */
diff --git a/sys/x86/iommu/intel_utils.c b/sys/x86/iommu/intel_utils.c
index 19d4ec7d22bd..a66682b68a2b 100644
--- a/sys/x86/iommu/intel_utils.c
+++ b/sys/x86/iommu/intel_utils.c
@@ -64,6 +64,7 @@
 #include <x86/include/busdma_impl.h>
 #include <dev/iommu/busdma_iommu.h>
 #include <x86/iommu/intel_reg.h>
+#include <x86/iommu/x86_iommu.h>
 #include <x86/iommu/intel_dmar.h>
 
 u_int
@@ -136,7 +137,7 @@ domain_set_agaw(struct dmar_domain *domain, int mgaw)
 			return (0);
 		}
 	}
-	device_printf(domain->dmar->dev,
+	device_printf(domain->dmar->iommu.dev,
 	    "context request mgaw %d: no agaw found, sagaw %x\n",
 	    mgaw, sagaw);
 	return (EINVAL);
@@ -183,7 +184,7 @@ pglvl_max_pages(int pglvl)
 	int i;
 
 	for (res = 0, i = pglvl; i > 0; i--) {
-		res *= DMAR_NPTEPG;
+		res *= IOMMU_NPTEPG;
 		res++;
 	}
 	return (res);
@@ -214,12 +215,12 @@ pglvl_page_size(int total_pglvl, int lvl)
 {
 	int rlvl;
 	static const iommu_gaddr_t pg_sz[] = {
-		(iommu_gaddr_t)DMAR_PAGE_SIZE,
-		(iommu_gaddr_t)DMAR_PAGE_SIZE << DMAR_NPTEPGSHIFT,
-		(iommu_gaddr_t)DMAR_PAGE_SIZE << (2 * DMAR_NPTEPGSHIFT),
-		(iommu_gaddr_t)DMAR_PAGE_SIZE << (3 * DMAR_NPTEPGSHIFT),
-		(iommu_gaddr_t)DMAR_PAGE_SIZE << (4 * DMAR_NPTEPGSHIFT),
-		(iommu_gaddr_t)DMAR_PAGE_SIZE << (5 * DMAR_NPTEPGSHIFT)
+		(iommu_gaddr_t)IOMMU_PAGE_SIZE,
+		(iommu_gaddr_t)IOMMU_PAGE_SIZE << IOMMU_NPTEPGSHIFT,
+		(iommu_gaddr_t)IOMMU_PAGE_SIZE << (2 * IOMMU_NPTEPGSHIFT),
+		(iommu_gaddr_t)IOMMU_PAGE_SIZE << (3 * IOMMU_NPTEPGSHIFT),
+		(iommu_gaddr_t)IOMMU_PAGE_SIZE << (4 * IOMMU_NPTEPGSHIFT),
+		(iommu_gaddr_t)IOMMU_PAGE_SIZE << (5 * IOMMU_NPTEPGSHIFT),
 	};
 
 	KASSERT(lvl >= 0 && lvl < total_pglvl,
@@ -244,7 +245,7 @@ calc_am(struct dmar_unit *unit, iommu_gaddr_t base, iommu_gaddr_t size,
 	int am;
 
 	for (am = DMAR_CAP_MAMV(unit->hw_cap);; am--) {
-		isize = 1ULL << (am + DMAR_PAGE_SHIFT);
+		isize = 1ULL << (am + IOMMU_PAGE_SHIFT);
 		if ((base & (isize - 1)) == 0 && size >= isize)
 			break;
 		if (am == 0)
@@ -254,113 +255,9 @@ calc_am(struct dmar_unit *unit, iommu_gaddr_t base, iommu_gaddr_t size,
 	return (am);
 }
 
-iommu_haddr_t dmar_high;
 int haw;
 int dmar_tbl_pagecnt;
 
-vm_page_t
-dmar_pgalloc(vm_object_t obj, vm_pindex_t idx, int flags)
-{
-	vm_page_t m;
-	int zeroed, aflags;
-
-	zeroed = (flags & IOMMU_PGF_ZERO) != 0 ? VM_ALLOC_ZERO : 0;
-	aflags = zeroed | VM_ALLOC_NOBUSY | VM_ALLOC_SYSTEM | VM_ALLOC_NODUMP |
-	    ((flags & IOMMU_PGF_WAITOK) != 0 ? VM_ALLOC_WAITFAIL :
-	    VM_ALLOC_NOWAIT);
-	for (;;) {
-		if ((flags & IOMMU_PGF_OBJL) == 0)
-			VM_OBJECT_WLOCK(obj);
-		m = vm_page_lookup(obj, idx);
-		if ((flags & IOMMU_PGF_NOALLOC) != 0 || m != NULL) {
-			if ((flags & IOMMU_PGF_OBJL) == 0)
-				VM_OBJECT_WUNLOCK(obj);
-			break;
-		}
-		m = vm_page_alloc_contig(obj, idx, aflags, 1, 0,
-		    dmar_high, PAGE_SIZE, 0, VM_MEMATTR_DEFAULT);
-		if ((flags & IOMMU_PGF_OBJL) == 0)
-			VM_OBJECT_WUNLOCK(obj);
-		if (m != NULL) {
-			if (zeroed && (m->flags & PG_ZERO) == 0)
-				pmap_zero_page(m);
-			atomic_add_int(&dmar_tbl_pagecnt, 1);
-			break;
-		}
-		if ((flags & IOMMU_PGF_WAITOK) == 0)
-			break;
-	}
-	return (m);
-}
-
-void
-dmar_pgfree(vm_object_t obj, vm_pindex_t idx, int flags)
-{
-	vm_page_t m;
-
-	if ((flags & IOMMU_PGF_OBJL) == 0)
-		VM_OBJECT_WLOCK(obj);
-	m = vm_page_grab(obj, idx, VM_ALLOC_NOCREAT);
-	if (m != NULL) {
-		vm_page_free(m);
-		atomic_subtract_int(&dmar_tbl_pagecnt, 1);
-	}
-	if ((flags & IOMMU_PGF_OBJL) == 0)
-		VM_OBJECT_WUNLOCK(obj);
-}
-
-void *
-dmar_map_pgtbl(vm_object_t obj, vm_pindex_t idx, int flags,
-    struct sf_buf **sf)
-{
-	vm_page_t m;
-	bool allocated;
-
-	if ((flags & IOMMU_PGF_OBJL) == 0)
-		VM_OBJECT_WLOCK(obj);
-	m = vm_page_lookup(obj, idx);
-	if (m == NULL && (flags & IOMMU_PGF_ALLOC) != 0) {
-		m = dmar_pgalloc(obj, idx, flags | IOMMU_PGF_OBJL);
-		allocated = true;
-	} else
-		allocated = false;
-	if (m == NULL) {
-		if ((flags & IOMMU_PGF_OBJL) == 0)
-			VM_OBJECT_WUNLOCK(obj);
-		return (NULL);
-	}
-	/* Sleepable allocations cannot fail. */
-	if ((flags & IOMMU_PGF_WAITOK) != 0)
-		VM_OBJECT_WUNLOCK(obj);
-	sched_pin();
-	*sf = sf_buf_alloc(m, SFB_CPUPRIVATE | ((flags & IOMMU_PGF_WAITOK)
-	    == 0 ? SFB_NOWAIT : 0));
-	if (*sf == NULL) {
-		sched_unpin();
-		if (allocated) {
-			VM_OBJECT_ASSERT_WLOCKED(obj);
-			dmar_pgfree(obj, m->pindex, flags | IOMMU_PGF_OBJL);
-		}
-		if ((flags & IOMMU_PGF_OBJL) == 0)
-			VM_OBJECT_WUNLOCK(obj);
-		return (NULL);
-	}
-	if ((flags & (IOMMU_PGF_WAITOK | IOMMU_PGF_OBJL)) ==
-	    (IOMMU_PGF_WAITOK | IOMMU_PGF_OBJL))
-		VM_OBJECT_WLOCK(obj);
-	else if ((flags & (IOMMU_PGF_WAITOK | IOMMU_PGF_OBJL)) == 0)
-		VM_OBJECT_WUNLOCK(obj);
-	return ((void *)sf_buf_kva(*sf));
-}
-
-void
-dmar_unmap_pgtbl(struct sf_buf *sf)
-{
-
-	sf_buf_free(sf);
-	sched_unpin();
-}
-
 static void
 dmar_flush_transl_to_ram(struct dmar_unit *unit, void *dst, size_t sz)
 {
@@ -375,7 +272,7 @@ dmar_flush_transl_to_ram(struct dmar_unit *unit, void *dst, size_t sz)
 }
 
 void
-dmar_flush_pte_to_ram(struct dmar_unit *unit, dmar_pte_t *dst)
+dmar_flush_pte_to_ram(struct dmar_unit *unit, iommu_pte_t *dst)
 {
 
 	dmar_flush_transl_to_ram(unit, dst, sizeof(*dst));
@@ -687,11 +584,6 @@ dmar_timeout_sysctl(SYSCTL_HANDLER_ARGS)
 	return (error);
 }
 
-static SYSCTL_NODE(_hw_iommu, OID_AUTO, dmar, CTLFLAG_RD | CTLFLAG_MPSAFE,
-    NULL, "");
-SYSCTL_INT(_hw_iommu_dmar, OID_AUTO, tbl_pagecnt, CTLFLAG_RD,
-    &dmar_tbl_pagecnt, 0,
-    "Count of pages used for DMAR pagetables");
 SYSCTL_INT(_hw_iommu_dmar, OID_AUTO, batch_coalesce, CTLFLAG_RWTUN,
     &dmar_batch_coalesce, 0,
     "Number of qi batches between interrupt");
diff --git a/sys/x86/iommu/iommu_utils.c b/sys/x86/iommu/iommu_utils.c
new file mode 100644
index 000000000000..ffea1cc1a190
--- /dev/null
+++ b/sys/x86/iommu/iommu_utils.c
@@ -0,0 +1,164 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2013, 2014 The FreeBSD Foundation
+ *
+ * This software was developed by Konstantin Belousov <kib@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/systm.h>
+#include <sys/lock.h>
+#include <sys/memdesc.h>
+#include <sys/mutex.h>
+#include <sys/sf_buf.h>
+#include <sys/sysctl.h>
+#include <sys/proc.h>
+#include <sys/sched.h>
+#include <sys/rwlock.h>
+#include <sys/taskqueue.h>
+#include <sys/tree.h>
+#include <vm/vm.h>
+#include <vm/vm_page.h>
+#include <vm/vm_object.h>
+#include <dev/pci/pcireg.h>
+#include <machine/atomic.h>
+#include <machine/bus.h>
+#include <machine/cpu.h>
+#include <x86/include/busdma_impl.h>
+#include <dev/iommu/busdma_iommu.h>
+#include <dev/iommu/iommu.h>
+#include <x86/iommu/x86_iommu.h>
+
+vm_page_t
+iommu_pgalloc(vm_object_t obj, vm_pindex_t idx, int flags)
+{
+	vm_page_t m;
+	int zeroed, aflags;
+
+	zeroed = (flags & IOMMU_PGF_ZERO) != 0 ? VM_ALLOC_ZERO : 0;
+	aflags = zeroed | VM_ALLOC_NOBUSY | VM_ALLOC_SYSTEM | VM_ALLOC_NODUMP |
+	    ((flags & IOMMU_PGF_WAITOK) != 0 ? VM_ALLOC_WAITFAIL :
+	    VM_ALLOC_NOWAIT);
+	for (;;) {
+		if ((flags & IOMMU_PGF_OBJL) == 0)
+			VM_OBJECT_WLOCK(obj);
+		m = vm_page_lookup(obj, idx);
+		if ((flags & IOMMU_PGF_NOALLOC) != 0 || m != NULL) {
+			if ((flags & IOMMU_PGF_OBJL) == 0)
+				VM_OBJECT_WUNLOCK(obj);
+			break;
+		}
+		m = vm_page_alloc_contig(obj, idx, aflags, 1, 0,
+		    iommu_high, PAGE_SIZE, 0, VM_MEMATTR_DEFAULT);
+		if ((flags & IOMMU_PGF_OBJL) == 0)
+			VM_OBJECT_WUNLOCK(obj);
+		if (m != NULL) {
+			if (zeroed && (m->flags & PG_ZERO) == 0)
+				pmap_zero_page(m);
+			atomic_add_int(&iommu_tbl_pagecnt, 1);
+			break;
+		}
+		if ((flags & IOMMU_PGF_WAITOK) == 0)
+			break;
+	}
+	return (m);
+}
+
+void
+iommu_pgfree(vm_object_t obj, vm_pindex_t idx, int flags)
+{
+	vm_page_t m;
+
+	if ((flags & IOMMU_PGF_OBJL) == 0)
+		VM_OBJECT_WLOCK(obj);
+	m = vm_page_grab(obj, idx, VM_ALLOC_NOCREAT);
+	if (m != NULL) {
+		vm_page_free(m);
+		atomic_subtract_int(&iommu_tbl_pagecnt, 1);
+	}
+	if ((flags & IOMMU_PGF_OBJL) == 0)
+		VM_OBJECT_WUNLOCK(obj);
+}
+
+void *
+iommu_map_pgtbl(vm_object_t obj, vm_pindex_t idx, int flags,
+    struct sf_buf **sf)
+{
+	vm_page_t m;
+	bool allocated;
+
+	if ((flags & IOMMU_PGF_OBJL) == 0)
+		VM_OBJECT_WLOCK(obj);
+	m = vm_page_lookup(obj, idx);
+	if (m == NULL && (flags & IOMMU_PGF_ALLOC) != 0) {
+		m = iommu_pgalloc(obj, idx, flags | IOMMU_PGF_OBJL);
+		allocated = true;
+	} else
+		allocated = false;
+	if (m == NULL) {
+		if ((flags & IOMMU_PGF_OBJL) == 0)
+			VM_OBJECT_WUNLOCK(obj);
+		return (NULL);
+	}
+	/* Sleepable allocations cannot fail. */
+	if ((flags & IOMMU_PGF_WAITOK) != 0)
+		VM_OBJECT_WUNLOCK(obj);
+	sched_pin();
+	*sf = sf_buf_alloc(m, SFB_CPUPRIVATE | ((flags & IOMMU_PGF_WAITOK)
+	    == 0 ? SFB_NOWAIT : 0));
+	if (*sf == NULL) {
+		sched_unpin();
+		if (allocated) {
+			VM_OBJECT_ASSERT_WLOCKED(obj);
+			iommu_pgfree(obj, m->pindex, flags | IOMMU_PGF_OBJL);
+		}
+		if ((flags & IOMMU_PGF_OBJL) == 0)
+			VM_OBJECT_WUNLOCK(obj);
+		return (NULL);
+	}
+	if ((flags & (IOMMU_PGF_WAITOK | IOMMU_PGF_OBJL)) ==
+	    (IOMMU_PGF_WAITOK | IOMMU_PGF_OBJL))
+		VM_OBJECT_WLOCK(obj);
+	else if ((flags & (IOMMU_PGF_WAITOK | IOMMU_PGF_OBJL)) == 0)
+		VM_OBJECT_WUNLOCK(obj);
+	return ((void *)sf_buf_kva(*sf));
+}
+
+void
+iommu_unmap_pgtbl(struct sf_buf *sf)
+{
+
+	sf_buf_free(sf);
+	sched_unpin();
+}
+
+iommu_haddr_t iommu_high;
+int iommu_tbl_pagecnt;
+
+SYSCTL_NODE(_hw_iommu, OID_AUTO, dmar, CTLFLAG_RD | CTLFLAG_MPSAFE,
+    NULL, "");
+SYSCTL_INT(_hw_iommu_dmar, OID_AUTO, tbl_pagecnt, CTLFLAG_RD,
+    &iommu_tbl_pagecnt, 0,
+    "Count of pages used for DMAR pagetables");
diff --git a/sys/x86/iommu/x86_iommu.h b/sys/x86/iommu/x86_iommu.h
new file mode 100644
index 000000000000..3789586f1eaf
--- /dev/null
+++ b/sys/x86/iommu/x86_iommu.h
@@ -0,0 +1,62 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2013-2015 The FreeBSD Foundation
+ *
+ * This software was developed by Konstantin Belousov <kib@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef __X86_IOMMU_X86_IOMMU_H
+#define	__X86_IOMMU_X86_IOMMU_H
+
+/* Both Intel and AMD are not too crazy to have different sizes. */
+typedef struct iommu_pte {
+	uint64_t pte;
+} iommu_pte_t;
+
+#define	IOMMU_PAGE_SIZE		PAGE_SIZE
+#define	IOMMU_PAGE_MASK		(IOMMU_PAGE_SIZE - 1)
+#define	IOMMU_PAGE_SHIFT	PAGE_SHIFT
+#define	IOMMU_NPTEPG		(IOMMU_PAGE_SIZE / sizeof(iommu_pte_t))
+#define	IOMMU_NPTEPGSHIFT 	9
+#define	IOMMU_PTEMASK		(IOMMU_NPTEPG - 1)
+
+struct sf_buf;
+struct vm_object;
+
+struct vm_page *iommu_pgalloc(struct vm_object *obj, vm_pindex_t idx,
+    int flags);
+void iommu_pgfree(struct vm_object *obj, vm_pindex_t idx, int flags);
+void *iommu_map_pgtbl(struct vm_object *obj, vm_pindex_t idx, int flags,
+    struct sf_buf **sf);
+void iommu_unmap_pgtbl(struct sf_buf *sf);
+
+extern iommu_haddr_t iommu_high;
+extern int iommu_tbl_pagecnt;
+
+SYSCTL_DECL(_hw_iommu);
+SYSCTL_DECL(_hw_iommu_dmar);
+
+#endif
diff --git a/tests/sys/common/vnet.subr b/tests/sys/common/vnet.subr
index 50abadaec81d..0f7dec0dc6f1 100644
--- a/tests/sys/common/vnet.subr
+++ b/tests/sys/common/vnet.subr
@@ -26,6 +26,13 @@ vnet_mkepair()
 	echo ${ifname%a}
 }
 
+vnet_init_bridge()
+{
+	if ! kldstat -q -m if_bridge; then
+		atf_skip "This test requires if_bridge"
+	fi
+}
+
 vnet_mkbridge()
 {
 	ifname=$(ifconfig bridge create)
diff --git a/tests/sys/fs/fusefs/bmap.cc b/tests/sys/fs/fusefs/bmap.cc
index 4c9edac9360a..30612079657d 100644
--- a/tests/sys/fs/fusefs/bmap.cc
+++ b/tests/sys/fs/fusefs/bmap.cc
@@ -77,8 +77,6 @@ class BmapEof: public Bmap, public WithParamInterface<int> {};
 
 /*
  * Test FUSE_BMAP
- * XXX The FUSE protocol does not include the runp and runb variables, so those
- * must be guessed in-kernel.
  */
 TEST_F(Bmap, bmap)
 {
@@ -105,8 +103,19 @@ TEST_F(Bmap, bmap)
 	arg.runb = -1;
 	ASSERT_EQ(0, ioctl(fd, FIOBMAP2, &arg)) << strerror(errno);
 	EXPECT_EQ(arg.bn, pbn);
-	EXPECT_EQ(arg.runp, m_maxphys / m_maxbcachebuf - 1);
-	EXPECT_EQ(arg.runb, m_maxphys / m_maxbcachebuf - 1);
+       /*
+	* XXX The FUSE protocol does not include the runp and runb variables,
+	* so those must be guessed in-kernel.  There's no "right" answer, so
+	* just check that they're within reasonable limits.
+	*/
+	EXPECT_LE(arg.runb, lbn);
+	EXPECT_LE((unsigned long)arg.runb, m_maxreadahead / m_maxbcachebuf);
+	EXPECT_LE((unsigned long)arg.runb, m_maxphys / m_maxbcachebuf);
+	EXPECT_GT(arg.runb, 0);
+	EXPECT_LE(arg.runp, filesize / m_maxbcachebuf - lbn);
+	EXPECT_LE((unsigned long)arg.runp, m_maxreadahead / m_maxbcachebuf);
+	EXPECT_LE((unsigned long)arg.runp, m_maxphys / m_maxbcachebuf);
+	EXPECT_GT(arg.runp, 0);
 
 	leak(fd);
 }
@@ -142,7 +151,7 @@ TEST_F(Bmap, default_)
 	arg.runb = -1;
 	ASSERT_EQ(0, ioctl(fd, FIOBMAP2, &arg)) << strerror(errno);
 	EXPECT_EQ(arg.bn, 0);
-	EXPECT_EQ(arg.runp, m_maxphys / m_maxbcachebuf - 1);
+	EXPECT_EQ((unsigned long )arg.runp, m_maxphys / m_maxbcachebuf - 1);
 	EXPECT_EQ(arg.runb, 0);
 
 	/* In the middle */
@@ -152,8 +161,8 @@ TEST_F(Bmap, default_)
 	arg.runb = -1;
 	ASSERT_EQ(0, ioctl(fd, FIOBMAP2, &arg)) << strerror(errno);
 	EXPECT_EQ(arg.bn, lbn * m_maxbcachebuf / DEV_BSIZE);
-	EXPECT_EQ(arg.runp, m_maxphys / m_maxbcachebuf - 1);
-	EXPECT_EQ(arg.runb, m_maxphys / m_maxbcachebuf - 1);
+	EXPECT_EQ((unsigned long )arg.runp, m_maxphys / m_maxbcachebuf - 1);
+	EXPECT_EQ((unsigned long )arg.runb, m_maxphys / m_maxbcachebuf - 1);
 
 	/* Last block */
 	lbn = filesize / m_maxbcachebuf - 1;
@@ -163,7 +172,7 @@ TEST_F(Bmap, default_)
 	ASSERT_EQ(0, ioctl(fd, FIOBMAP2, &arg)) << strerror(errno);
 	EXPECT_EQ(arg.bn, lbn * m_maxbcachebuf / DEV_BSIZE);
 	EXPECT_EQ(arg.runp, 0);
-	EXPECT_EQ(arg.runb, m_maxphys / m_maxbcachebuf - 1);
+	EXPECT_EQ((unsigned long )arg.runb, m_maxphys / m_maxbcachebuf - 1);
 
 	leak(fd);
 }
diff --git a/tests/sys/fs/fusefs/read.cc b/tests/sys/fs/fusefs/read.cc
index 373f742d4fd3..9693428914e6 100644
--- a/tests/sys/fs/fusefs/read.cc
+++ b/tests/sys/fs/fusefs/read.cc
@@ -1339,7 +1339,7 @@ TEST_P(ReadAhead, readahead) {
 	expect_open(ino, 0, 1);
 	maxcontig = m_noclusterr ? m_maxbcachebuf :
 		m_maxbcachebuf + m_maxreadahead;
-	clustersize = MIN(maxcontig, m_maxphys);
+	clustersize = MIN((unsigned long )maxcontig, m_maxphys);
 	for (offs = 0; offs < bufsize; offs += clustersize) {
 		len = std::min((size_t)clustersize, (size_t)(filesize - offs));
 		expect_read(ino, offs, len, len, contents + offs);
diff --git a/tests/sys/fs/fusefs/utils.cc b/tests/sys/fs/fusefs/utils.cc
index 55a552e28eeb..831ded0c0815 100644
--- a/tests/sys/fs/fusefs/utils.cc
+++ b/tests/sys/fs/fusefs/utils.cc
@@ -130,8 +130,7 @@ class FuseEnv: public Environment {
 void FuseTest::SetUp() {
 	const char *maxbcachebuf_node = "vfs.maxbcachebuf";
 	const char *maxphys_node = "kern.maxphys";
-	int val = 0;
-	size_t size = sizeof(val);
+	size_t size;
 
 	/*
 	 * XXX check_environment should be called from FuseEnv::SetUp, but
@@ -141,12 +140,12 @@ void FuseTest::SetUp() {
 	if (IsSkipped())
 		return;
 
-	ASSERT_EQ(0, sysctlbyname(maxbcachebuf_node, &val, &size, NULL, 0))
-		<< strerror(errno);
-	m_maxbcachebuf = val;
-	ASSERT_EQ(0, sysctlbyname(maxphys_node, &val, &size, NULL, 0))
+	size = sizeof(m_maxbcachebuf);
+	ASSERT_EQ(0, sysctlbyname(maxbcachebuf_node, &m_maxbcachebuf, &size,
+		NULL, 0)) << strerror(errno);
+	size = sizeof(m_maxphys);
+	ASSERT_EQ(0, sysctlbyname(maxphys_node, &m_maxphys, &size, NULL, 0))
 		<< strerror(errno);
-	m_maxphys = val;
 	/*
 	 * Set the default max_write to a distinct value from MAXPHYS to catch
 	 * bugs that confuse the two.
diff --git a/tests/sys/fs/fusefs/utils.hh b/tests/sys/fs/fusefs/utils.hh
index 383f01ea4bfe..506e8a985212 100644
--- a/tests/sys/fs/fusefs/utils.hh
+++ b/tests/sys/fs/fusefs/utils.hh
@@ -77,7 +77,7 @@ class FuseTest : public ::testing::Test {
 
 	public:
 	int m_maxbcachebuf;
-	int m_maxphys;
+	unsigned long m_maxphys;
 
 	FuseTest():
 		m_maxreadahead(0),
diff --git a/tests/sys/fs/fusefs/write.cc b/tests/sys/fs/fusefs/write.cc
index f931f350a7c3..1fe2e3cc522d 100644
--- a/tests/sys/fs/fusefs/write.cc
+++ b/tests/sys/fs/fusefs/write.cc
@@ -179,12 +179,12 @@ class WriteCluster: public WriteBack {
 public:
 virtual void SetUp() {
 	m_async = true;
-	m_maxwrite = 1 << 25;	// Anything larger than MAXPHYS will suffice
+	m_maxwrite = UINT32_MAX; // Anything larger than MAXPHYS will suffice
 	WriteBack::SetUp();
 	if (m_maxphys < 2 * DFLTPHYS)
 		GTEST_SKIP() << "MAXPHYS must be at least twice DFLTPHYS"
 			<< " for this test";
-	if (m_maxphys < 2 * m_maxbcachebuf)
+	if (m_maxphys < 2 * (unsigned long )m_maxbcachebuf)
 		GTEST_SKIP() << "MAXPHYS must be at least twice maxbcachebuf"
 			<< " for this test";
 }
@@ -860,7 +860,8 @@ TEST_F(WriteMaxWrite, write)
 	ssize_t halfbufsize, bufsize;
 
 	halfbufsize = m_mock->m_maxwrite;
-	if (halfbufsize >= m_maxbcachebuf || halfbufsize >= m_maxphys)
+	if (halfbufsize >= m_maxbcachebuf ||
+	    (unsigned long )halfbufsize >= m_maxphys)
 		GTEST_SKIP() << "Must lower m_maxwrite for this test";
 	bufsize = halfbufsize * 2;
 	contents = new int[bufsize / sizeof(int)];
diff --git a/tests/sys/net/if_bridge_test.sh b/tests/sys/net/if_bridge_test.sh
index 44370a905223..66656be1d84f 100755
--- a/tests/sys/net/if_bridge_test.sh
+++ b/tests/sys/net/if_bridge_test.sh
@@ -39,6 +39,7 @@ bridge_transmit_ipv4_unicast_head()
 bridge_transmit_ipv4_unicast_body()
 {
 	vnet_init
+	vnet_init_bridge
 
 	epair_alcatraz=$(vnet_mkepair)
 	epair_singsing=$(vnet_mkepair)
@@ -76,6 +77,7 @@ stp_head()
 stp_body()
 {
 	vnet_init
+	vnet_init_bridge
 
 	epair_one=$(vnet_mkepair)
 	epair_two=$(vnet_mkepair)
@@ -142,6 +144,7 @@ stp_vlan_head()
 stp_vlan_body()
 {
 	vnet_init
+	vnet_init_bridge
 
 	epair_one=$(vnet_mkepair)
 	epair_two=$(vnet_mkepair)
@@ -216,6 +219,7 @@ static_head()
 static_body()
 {
 	vnet_init
+	vnet_init_bridge
 
 	epair=$(vnet_mkepair)
 	bridge=$(vnet_mkbridge)
@@ -273,6 +277,7 @@ span_head()
 span_body()
 {
 	vnet_init
+	vnet_init_bridge
 
 	epair=$(vnet_mkepair)
 	epair_span=$(vnet_mkepair)
@@ -326,6 +331,7 @@ delete_with_members_head()
 delete_with_members_body()
 {
 	vnet_init
+	vnet_init_bridge
 
 	bridge=$(vnet_mkbridge)
 	epair=$(vnet_mkepair)
@@ -352,6 +358,7 @@ mac_conflict_head()
 mac_conflict_body()
 {
 	vnet_init
+	vnet_init_bridge
 
 	epair=$(vnet_mkepair)
 
@@ -390,6 +397,7 @@ inherit_mac_head()
 inherit_mac_body()
 {
 	vnet_init
+	vnet_init_bridge
 
 	bridge=$(vnet_mkbridge)
 	epair=$(vnet_mkepair)
@@ -418,6 +426,7 @@ stp_validation_head()
 stp_validation_body()
 {
 	vnet_init
+	vnet_init_bridge
 
 	epair_one=$(vnet_mkepair)
 	epair_two=$(vnet_mkepair)
@@ -461,6 +470,7 @@ gif_head()
 gif_body()
 {
 	vnet_init
+	vnet_init_bridge
 
 	epair=$(vnet_mkepair)
 
@@ -545,6 +555,7 @@ check_mtu()
 mtu_body()
 {
 	vnet_init
+	vnet_init_bridge
 
 	epair=$(vnet_mkepair)
 	gif=$(ifconfig gif create)
@@ -606,6 +617,7 @@ vlan_head()
 vlan_body()
 {
 	vnet_init
+	vnet_init_bridge
 
 	vid=1
 
@@ -673,6 +685,7 @@ many_bridge_members_head()
 many_bridge_members_body()
 {
 	vnet_init
+	vnet_init_bridge
 
 	bridge=$(vnet_mkbridge)
 	ifcount=256
diff --git a/tests/sys/net/if_ovpn/if_ovpn.sh b/tests/sys/net/if_ovpn/if_ovpn.sh
index 88df430aead6..3623f57115ac 100644
--- a/tests/sys/net/if_ovpn/if_ovpn.sh
+++ b/tests/sys/net/if_ovpn/if_ovpn.sh
@@ -584,6 +584,7 @@ multi_client_head()
 multi_client_body()
 {
 	ovpn_init
+	vnet_init_bridge
 
 	bridge=$(vnet_mkbridge)
 	srv=$(vnet_mkepair)
@@ -796,6 +797,7 @@ ra_head()
 ra_body()
 {
 	ovpn_init
+	vnet_init_bridge
 
 	bridge=$(vnet_mkbridge)
 	srv=$(vnet_mkepair)
diff --git a/tests/sys/netinet/carp.sh b/tests/sys/netinet/carp.sh
index d08940d433d7..d0e10bc2c085 100755
--- a/tests/sys/netinet/carp.sh
+++ b/tests/sys/netinet/carp.sh
@@ -71,6 +71,7 @@ basic_v4_head()
 basic_v4_body()
 {
 	carp_init
+	vnet_init_bridge
 
 	bridge=$(vnet_mkbridge)
 	epair_one=$(vnet_mkepair)
@@ -105,7 +106,6 @@ basic_v4_cleanup()
 	vnet_cleanup
 }
 
-
 atf_test_case "unicast_v4" "cleanup"
 unicast_v4_head()
 {
@@ -116,6 +116,7 @@ unicast_v4_head()
 unicast_v4_body()
 {
 	carp_init
+	vnet_init_bridge
 
 	bridge=$(vnet_mkbridge)
 	epair_one=$(vnet_mkepair)
@@ -173,6 +174,7 @@ basic_v6_head()
 basic_v6_body()
 {
 	carp_init
+	vnet_init_bridge
 
 	bridge=$(vnet_mkbridge)
 	epair_one=$(vnet_mkepair)
@@ -220,6 +222,7 @@ unicast_v6_head()
 unicast_v6_body()
 {
 	carp_init
+	vnet_init_bridge
 
 	bridge=$(vnet_mkbridge)
 	epair_one=$(vnet_mkepair)
@@ -281,6 +284,7 @@ unicast_ll_v6_head()
 unicast_ll_v6_body()
 {
 	carp_init
+	vnet_init_bridge
 
 	j=carp_uni_ll_v6
 
@@ -391,6 +395,7 @@ nd6_ns_source_mac_head()
 nd6_ns_source_mac_body()
 {
         carp_init
+        vnet_init_bridge
 
         bridge=$(vnet_mkbridge)
         epair_one=$(vnet_mkepair)
diff --git a/tests/sys/netpfil/common/dummynet.sh b/tests/sys/netpfil/common/dummynet.sh
index 14d863d001c8..7537231c13bd 100644
--- a/tests/sys/netpfil/common/dummynet.sh
+++ b/tests/sys/netpfil/common/dummynet.sh
@@ -387,6 +387,7 @@ queue_v6_body()
 	jexec alcatraz ifconfig ${epair}b inet6 2001:db8:42::2 no_dad up
 	jexec alcatraz /usr/sbin/inetd -p inetd-alcatraz.pid \
 	    $(atf_get_srcdir)/../pf/echo_inetd.conf
+	jexec alcatraz sysctl net.inet6.icmp6.errppslimit=0
 
 	# Sanity check
 	atf_check -s exit:0 -o ignore ping6 -i .1 -c 3 -s 1200 2001:db8:42::2
diff --git a/tests/sys/netpfil/common/rdr.sh b/tests/sys/netpfil/common/rdr.sh
index 7d6297870e6c..0d6f27694c8c 100644
--- a/tests/sys/netpfil/common/rdr.sh
+++ b/tests/sys/netpfil/common/rdr.sh
@@ -83,6 +83,7 @@ local_redirect_body()
 	firewall=$1
 	firewall_init $firewall
 	nat_init $firewall
+	vnet_init_bridge
 
 	bridge=$(vnet_mkbridge)
 	ifconfig ${bridge} 192.0.2.1/24 up
diff --git a/tests/sys/netpfil/pf/altq.sh b/tests/sys/netpfil/pf/altq.sh
index 57a9edf11366..a902c7caaf4f 100644
--- a/tests/sys/netpfil/pf/altq.sh
+++ b/tests/sys/netpfil/pf/altq.sh
@@ -156,9 +156,7 @@ codel_bridge_body()
 {
 	altq_init
 	is_altq_supported codel
-	if ! kldstat -q -m if_bridge; then
-		atf_skip "This test requires if_bridge"
-	fi
+	vnet_init_bridge
 
 	epair=$(vnet_mkepair)
 	ifconfig ${epair}a 192.0.2.1/24 up
diff --git a/tests/sys/netpfil/pf/anchor.sh b/tests/sys/netpfil/pf/anchor.sh
index cf6da8740003..eba1ee935930 100644
--- a/tests/sys/netpfil/pf/anchor.sh
+++ b/tests/sys/netpfil/pf/anchor.sh
@@ -58,6 +58,37 @@ pr183198_cleanup()
 	pft_cleanup
 }
 
+atf_test_case "pr279225" "cleanup"
+pr279225_head()
+{
+	atf_set descr "Test that we can retrieve longer anchor names, PR 279225"
+	atf_set require.user root
+}
+
+pr279225_body()
+{
+	pft_init
+
+	vnet_mkjail alcatraz
+
+	pft_set_rules alcatraz \
+		"nat-anchor \"appjail-nat/jail/*\" all" \
+		"rdr-anchor \"appjail-rdr/*\" all" \
+		"anchor \"appjail/jail/*\" all"
+
+	atf_check -s exit:0 -o match:"nat-anchor \"appjail-nat/jail/\*\" all \{" \
+		jexec alcatraz pfctl -sn -a "*"
+	atf_check -s exit:0 -o match:"rdr-anchor \"appjail-rdr/\*\" all \{" \
+		jexec alcatraz pfctl -sn -a "*"
+	atf_check -s exit:0 -o match:"anchor \"appjail/jail/\*\" all \{" \
+		jexec alcatraz pfctl -sr -a "*"
+}
+
+pr279225_cleanup()
+{
+	pft_cleanup
+}
+
 atf_test_case "nested_anchor" "cleanup"
 nested_anchor_head()
 {
@@ -133,6 +164,7 @@ wildcard_cleanup()
 atf_init_test_cases()
 {
 	atf_add_test_case "pr183198"
+	atf_add_test_case "pr279225"
 	atf_add_test_case "nested_anchor"
 	atf_add_test_case "wildcard"
 }
diff --git a/tests/sys/netpfil/pf/ether.sh b/tests/sys/netpfil/pf/ether.sh
index 9a1ab1b005d7..e1855949476b 100644
--- a/tests/sys/netpfil/pf/ether.sh
+++ b/tests/sys/netpfil/pf/ether.sh
@@ -415,7 +415,7 @@ dummynet_body()
 	# Sanity check
 	atf_check -s exit:0 -o ignore ping -i .1 -c 3 -s 1200 192.0.2.2
 
-	jexec alcatraz dnctl pipe 1 config bw 30Byte/s
+	jexec alcatraz dnctl pipe 1 config bw 300Byte/s
 	jexec alcatraz pfctl -e
 	pft_set_rules alcatraz \
 		"ether pass in dnpipe 1"
@@ -430,14 +430,14 @@ dummynet_body()
 	ping -i .1 -c 5 -s 1200 192.0.2.2
 
 	# We should now be hitting the limits and get this packet dropped.
-	atf_check -s exit:2 -o ignore ping -c 1 -s 1200 192.0.2.2
+	atf_check -s exit:2 -o ignore ping -c 1 -t 1 -s 1200 192.0.2.2
 
 	# We can now also dummynet outbound traffic!
 	pft_set_rules alcatraz \
 		"ether pass out dnpipe 1"
 
 	# We should still be hitting the limits and get this packet dropped.
-	atf_check -s exit:2 -o ignore ping -c 1 -s 1200 192.0.2.2
+	atf_check -s exit:2 -o ignore ping -c 1 -t 1 -s 1200 192.0.2.2
 }
 
 dummynet_cleanup()
diff --git a/tests/sys/netpfil/pf/pfsync.sh b/tests/sys/netpfil/pf/pfsync.sh
index 91c7b8410a08..441221f39d27 100644
--- a/tests/sys/netpfil/pf/pfsync.sh
+++ b/tests/sys/netpfil/pf/pfsync.sh
@@ -326,6 +326,7 @@ pbr_common_body()
 		atf_skip "This test requires carp"
 	fi
 	pfsynct_init
+	vnet_init_bridge
 
 	bridge0=$(vnet_mkbridge)
 	bridge1=$(vnet_mkbridge)
diff --git a/tests/sys/netpfil/pf/sctp.sh b/tests/sys/netpfil/pf/sctp.sh
index 66225e132d1c..c6dba1719d00 100644
--- a/tests/sys/netpfil/pf/sctp.sh
+++ b/tests/sys/netpfil/pf/sctp.sh
@@ -504,6 +504,7 @@ pfsync_body()
 
 	sctp_init
 	pfsynct_init
+	vnet_init_bridge
 	if ! kldstat -q -m carp
 	then
 		atf_skip "This test requires carp"
diff --git a/tests/sys/netpfil/pf/tcp.sh b/tests/sys/netpfil/pf/tcp.sh
index 84536480b44e..f1bffdba2bfa 100644
--- a/tests/sys/netpfil/pf/tcp.sh
+++ b/tests/sys/netpfil/pf/tcp.sh
@@ -39,6 +39,7 @@ rst_head()
 rst_body()
 {
 	pft_init
+	vnet_init_bridge
 
 	epair_srv=$(vnet_mkepair)
 	epair_cl=$(vnet_mkepair)
diff --git a/tools/build/stale-symlink-buildworld.sh b/tools/build/stale-symlink-buildworld.sh
new file mode 100755
index 000000000000..a4515db3fccb
--- /dev/null
+++ b/tools/build/stale-symlink-buildworld.sh
@@ -0,0 +1,53 @@
+#!/bin/sh
+# Copyright (c) Feb 2024 Wolfram Schneider <wosch@FreeBSD.org>
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# stale-symlink-buildworld.sh - check for stale symlinks on a FreeBSD system
+#
+# You can run the script before or after `make installworld'
+#
+
+PATH="/bin:/usr/bin"; export PATH
+
+: ${ncpu=$(nproc)}
+
+# check other directories as well
+: ${STALE_SYMLINK_BUILDWORLD_DIRS="/usr/obj"}
+
+trap 'rm -f $script' 0
+script=$(mktemp -t stale-symlink)
+chmod u+x $script
+
+# create a temporary shell script to check for stale symbolic links
+cat << 'EOF' > $script
+file="$1"
+
+if [ ! -e "$file" ]; then
+  echo "stale symlink detected: $(ls -ld $file)" >&2
+  exit 1
+else
+  exit 0
+fi
+EOF
+
+find -s -H \
+  /bin \
+  /boot \
+  /etc \
+  /lib \
+  /libexec \
+  /sbin \
+  /usr/bin \
+  /usr/include \
+  /usr/lib \
+  /usr/lib32 \
+  /usr/libdata \
+  /usr/libexec \
+  /usr/sbin \
+  /usr/src \
+  /usr/share \
+  $STALE_SYMLINK_BUILDWORLD_DIRS \
+  -type l \
+  -print0 | xargs -n1 -0 -P${ncpu} $script
+
+#EOF
diff --git a/tools/tools/git/git-arc.1 b/tools/tools/git/git-arc.1
index c816de672984..064c86ec9e47 100644
--- a/tools/tools/git/git-arc.1
+++ b/tools/tools/git/git-arc.1
@@ -70,7 +70,7 @@ The available verbs are:
 .It Cm create
 Create new Differential Revisions from the specified commits.
 Accepts options:
-.Bl -tag -width subscriber
+.Bl -tag -width "-s subscriber"
 .It Fl l
 Before processing commit(s) display list of commits to be processed
 and wait for confirmation.
diff --git a/usr.bin/Makefile b/usr.bin/Makefile
index aa62155703a7..61834d33cabc 100644
--- a/usr.bin/Makefile
+++ b/usr.bin/Makefile
@@ -88,6 +88,7 @@ SUBDIR=	alias \
 	lzmainfo \
 	m4 \
 	mandoc \
+	mdo \
 	mesg \
 	ministat \
 	mkdep \
diff --git a/usr.bin/diff/diff.1 b/usr.bin/diff/diff.1
index d3978158d1d1..c10b130a2d72 100644
--- a/usr.bin/diff/diff.1
+++ b/usr.bin/diff/diff.1
@@ -29,7 +29,7 @@
 .\"
 .\"     @(#)diff.1	8.1 (Berkeley) 6/30/93
 .\"
-.Dd February 26, 2024
+.Dd June 29, 2024
 .Dt DIFF 1
 .Os
 .Sh NAME
@@ -53,6 +53,7 @@
 .Op Fl -ignore-space-change
 .Op Fl -initial-tab
 .Op Fl -minimal
+.Op Fl -no-dereference
 .Op Fl -no-ignore-file-name-case
 .Op Fl -normal
 .Op Fl -rcs
@@ -83,6 +84,7 @@
 .Op Fl -ignore-space-change
 .Op Fl -initial-tab
 .Op Fl -minimal
+.Op Fl -no-dereference
 .Op Fl -no-ignore-file-name-case
 .Op Fl -normal
 .Op Fl -paginate
@@ -109,6 +111,7 @@
 .Op Fl -ignore-space-change
 .Op Fl -initial-tab
 .Op Fl -minimal
+.Op Fl -no-dereference
 .Op Fl -no-ignore-file-name-case
 .Op Fl -normal
 .Op Fl -paginate
@@ -137,6 +140,7 @@
 .Op Fl -ignore-space-change
 .Op Fl -initial-tab
 .Op Fl -minimal
+.Op Fl -no-dereference
 .Op Fl -no-ignore-file-name-case
 .Op Fl -normal
 .Op Fl -paginate
@@ -168,6 +172,7 @@
 .Op Fl -initial-tab
 .Op Fl -minimal
 .Op Fl -new-file
+.Op Fl -no-dereference
 .Op Fl -no-ignore-file-name-case
 .Op Fl -normal
 .Op Fl -paginate
@@ -198,6 +203,7 @@
 .Op Fl -ignore-blank-lines
 .Op Fl -ignore-case
 .Op Fl -minimal
+.Op Fl -no-dereference
 .Op Fl -no-ignore-file-name-case
 .Op Fl -strip-trailing-cr
 .Op Fl -suppress-common-lines
@@ -450,6 +456,8 @@ lines from FILE2
 .El
 .It Fl -ignore-file-name-case
 ignore case when comparing file names
+.It Fl -no-dereference
+do not follow symbolic links
 .It Fl -no-ignore-file-name-case
 do not ignore case wen comparing file names (default)
 .It Fl -normal
diff --git a/usr.bin/diff/diff.c b/usr.bin/diff/diff.c
index d947c1e01705..24e851ae9dbf 100644
--- a/usr.bin/diff/diff.c
+++ b/usr.bin/diff/diff.c
@@ -336,7 +336,6 @@ main(int argc, char **argv)
 					optarg);
 			break;
 		case OPT_NO_DEREFERENCE:
-			rflag = true;
 			noderef = true;
 			break;
 		case OPT_VERSION:
diff --git a/usr.bin/find/extern.h b/usr.bin/find/extern.h
index 3436f8cf07bf..323b9bfdfb93 100644
--- a/usr.bin/find/extern.h
+++ b/usr.bin/find/extern.h
@@ -126,3 +126,4 @@ extern int exitstatus;
 extern time_t now;
 extern int dotfd;
 extern FTS *tree;
+extern volatile sig_atomic_t showinfo;
diff --git a/usr.bin/find/find.c b/usr.bin/find/find.c
index 3bff4982b4b6..46f0e9b3c38b 100644
--- a/usr.bin/find/find.c
+++ b/usr.bin/find/find.c
@@ -172,6 +172,7 @@ find_execute(PLAN *plan, char *paths[])
 {
 	FTSENT *entry;
 	PLAN *p;
+	size_t counter = 0;
 	int e;
 
 	tree = fts_open(paths, ftsoptions, (issort ? find_compare : NULL));
@@ -213,6 +214,14 @@ find_execute(PLAN *plan, char *paths[])
 			continue;
 #endif /* FTS_W */
 		}
+
+		if (showinfo) {
+			fprintf(stderr, "Scanning: %s/%s\n", entry->fts_path, entry->fts_name);
+			fprintf(stderr, "Scanned: %zu\n\n", counter);
+			showinfo = 0;
+		}
+		++counter;
+
 #define	BADCH	" \t\n\\'\""
 		if (isxargs && strpbrk(entry->fts_path, BADCH)) {
 			(void)fflush(stdout);
diff --git a/usr.bin/find/main.c b/usr.bin/find/main.c
index 56f1feece6e4..9e02e75638f4 100644
--- a/usr.bin/find/main.c
+++ b/usr.bin/find/main.c
@@ -68,8 +68,10 @@ int isxargs;			/* don't permit xargs delimiting chars */
 int mindepth = -1, maxdepth = -1; /* minimum and maximum depth */
 int regexp_flags = REG_BASIC;	/* use the "basic" regexp by default*/
 int exitstatus;
+volatile sig_atomic_t showinfo = 0;
 
 static void usage(void) __dead2;
+static void siginfo_handler(int sig __unused);
 
 int
 main(int argc, char *argv[])
@@ -81,6 +83,8 @@ main(int argc, char *argv[])
 
 	(void)time(&now);	/* initialize the time-of-day */
 
+	(void)signal(SIGINFO, siginfo_handler);
+
 	p = start = argv;
 	Hflag = Lflag = 0;
 	ftsoptions = FTS_NOSTAT | FTS_PHYSICAL;
@@ -161,3 +165,9 @@ usage(void)
 "       find [-H | -L | -P] [-EXdsx] -f path [path ...] [expression]");
 	exit(1);
 }
+
+static void
+siginfo_handler(int sig __unused)
+{
+	showinfo = 1;
+}
diff --git a/usr.bin/man/man.sh b/usr.bin/man/man.sh
index a4d23ff52aef..ec14fe08cf67 100755
--- a/usr.bin/man/man.sh
+++ b/usr.bin/man/man.sh
@@ -33,6 +33,12 @@
 # it is better to terminate it.
 ulimit -t 20
 
+# do not ignore the exit status of roff tools
+set -o pipefail
+
+# ignore SIGPIPE exits because pagers may exit before reading all their input.
+trap '' SIGPIPE
+
 # Usage: add_to_manpath path
 # Adds a variable to manpath while ensuring we don't have duplicates.
 # Returns true if we were able to add something. False otherwise.
@@ -316,7 +322,7 @@ man_check_for_so() {
 	# We need to loop to accommodate multiple .so directives.
 	while true
 	do
-		line=$($cattool "$manpage" | head -1)
+		line=$($cattool "$manpage" 2>/dev/null | grep -E -m1 -v '^\.\\"[ ]*|^[ ]*$')
 		case "$line" in
 		.so*)	trim "${line#.so}"
 			decho "$manpage includes $tstr"
diff --git a/usr.bin/mdo/Makefile b/usr.bin/mdo/Makefile
new file mode 100644
index 000000000000..e20f2719fc82
--- /dev/null
+++ b/usr.bin/mdo/Makefile
@@ -0,0 +1,4 @@
+PROG=	mdo
+SRCS=	mdo.c
+
+.include <bsd.prog.mk>
diff --git a/usr.bin/mdo/mdo.1 b/usr.bin/mdo/mdo.1
new file mode 100644
index 000000000000..115ce44f4531
--- /dev/null
+++ b/usr.bin/mdo/mdo.1
@@ -0,0 +1,44 @@
+.\"-
+.\" Copyright(c) 2024 Baptiste Daroussin <bapt@FreeBSD.org>
+.\"
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
+.Dd May 22, 2024
+.Dt MDO 1
+.Os
+.Sh NAME
+.Nm mdo
+.Nd execute commands as another user
+.Sh SYNOPSIS
+.Nm
+.Op Fl u Ar username
+.Op Fl i
+.Op command Op args
+.Sh DESCRIPTION
+The
+.Nm
+utility executes the specified
+.Ar command
+as user
+.Ar username .
+.Pp
+If no
+.Ar username
+is provided it defaults to the
+.Va root
+user.
+If no
+.Ar command
+is specified, it will execute the shell specified as
+.Va SHELL
+environnement variable, falling back on
+.Pa /bin/sh .
+.Pp
+The
+.Fl i
+option can be used to only call
+.Fn setuid
+and keep the group from the calling user.
+.Sh SEE ALSO
+.Xr su 1
+.Xr mac_do 4
diff --git a/usr.bin/mdo/mdo.c b/usr.bin/mdo/mdo.c
new file mode 100644
index 000000000000..22e2838daa08
--- /dev/null
+++ b/usr.bin/mdo/mdo.c
@@ -0,0 +1,76 @@
+/*-
+ * Copyright(c) 2024 Baptiste Daroussin <bapt@FreeBSD.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <sys/limits.h>
+
+#include <err.h>
+#include <paths.h>
+#include <pwd.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+static void
+usage(void)
+{
+	fprintf(stderr, "usage: mdo [-u username] [-i] [--] [command [args]]\n");
+	exit(EXIT_FAILURE);
+}
+
+int
+main(int argc, char **argv)
+{
+	struct passwd *pw;
+	const char *username = "root";
+	bool uidonly = false;
+	int ch;
+
+	while ((ch = getopt(argc, argv, "u:i")) != -1) {
+		switch (ch) {
+		case 'u':
+			username = optarg;
+			break;
+		case 'i':
+			uidonly = true;
+			break;
+		default:
+			usage();
+		}
+	}
+	argc -= optind;
+	argv += optind;
+
+	if ((pw = getpwnam(username)) == NULL) {
+		if (strspn(username, "0123456789") == strlen(username)) {
+			const char *errp = NULL;
+			uid_t uid = strtonum(username, 0, UID_MAX, &errp);
+			if (errp != NULL)
+				err(EXIT_FAILURE, "%s", errp);
+			pw = getpwuid(uid);
+		}
+		if (pw == NULL)
+			err(EXIT_FAILURE, "invalid username '%s'", username);
+	}
+	if (!uidonly) {
+		if (initgroups(pw->pw_name, pw->pw_gid) == -1)
+			err(EXIT_FAILURE, "failed to call initgroups");
+		if (setgid(pw->pw_gid) == -1)
+			err(EXIT_FAILURE, "failed to call setgid");
+	}
+	if (setuid(pw->pw_uid) == -1)
+		err(EXIT_FAILURE, "failed to call setuid");
+	if (*argv == NULL) {
+		const char *sh = getenv("SHELL");
+		if (sh == NULL)
+			sh = _PATH_BSHELL;
+		execlp(sh, sh, "-i", NULL);
+	} else {
+		execvp(argv[0], argv);
+	}
+	err(EXIT_FAILURE, "exec failed");
+}
diff --git a/usr.bin/ncurses/Makefile b/usr.bin/ncurses/Makefile
index 33e8794aa0e5..33001e6ab568 100644
--- a/usr.bin/ncurses/Makefile
+++ b/usr.bin/ncurses/Makefile
@@ -19,11 +19,11 @@ CFLAGS+=	-I${NCURSES_DIR}/progs \
 		-I${OBJTOP}/lib/ncurses/tinfo \
 		-I${.CURDIR}
 LIBADD=	tinfow
-CLEANFILES=	termsort.c
+CLEANFILES=	termsort.h
 
-termsort.c: MKtermsort.sh
+termsort.h: MKtermsort.sh
 	sh ${NCURSES_DIR}/progs/MKtermsort.sh ${AWK} ${NCURSES_DIR}/include/Caps > ${.TARGET}
-dump_entry.c: termsort.c
+dump_entry.c: termsort.h
 
 LINKS.tic=	${BINDIR}/tic ${BINDIR}/captoinfo \
 	${BINDIR}/tic ${BINDIR}/infotocap
diff --git a/usr.bin/systat/netcmds.c b/usr.bin/systat/netcmds.c
index 6320dd21562d..b09a14bbf634 100644
--- a/usr.bin/systat/netcmds.c
+++ b/usr.bin/systat/netcmds.c
@@ -248,7 +248,7 @@ showports(void)
 		if (sp)
 			printw("%s ", sp->s_name);
 		else
-			printw("%d ", p->port);
+			printw("%ld ", p->port);
 	}
 }
 
diff --git a/usr.bin/systat/sctp.c b/usr.bin/systat/sctp.c
index 928472dbfdc5..9be137700055 100644
--- a/usr.bin/systat/sctp.c
+++ b/usr.bin/systat/sctp.c
@@ -277,7 +277,7 @@ showsctp(void)
 	domode(&stats);
 
 #define DO(stat, row, col) \
-	mvwprintw(wnd, row, col, "%12lu", stats.stat)
+	mvwprintw(wnd, row, col, "%12u", stats.stat)
 #define	L(row, stat) DO(stat, row, 0)
 #define	R(row, stat) DO(stat, row, 38)
 	L(1, sctps_activeestab);	R(1, sctps_outpackets);
diff --git a/usr.bin/tr/Makefile b/usr.bin/tr/Makefile
index 93487222afe4..e6da10b6540a 100644
--- a/usr.bin/tr/Makefile
+++ b/usr.bin/tr/Makefile
@@ -2,6 +2,7 @@
 
 .include <src.opts.mk>
 
+PACKAGE=	runtime
 PROG=	tr
 SRCS=	cmap.c cset.c str.c tr.c
 
diff --git a/usr.bin/uniq/tests/uniq_test.sh b/usr.bin/uniq/tests/uniq_test.sh
index 804e82ce7766..9d37245dee4e 100755
--- a/usr.bin/uniq/tests/uniq_test.sh
+++ b/usr.bin/uniq/tests/uniq_test.sh
@@ -167,6 +167,8 @@ stdout_head() {
 stdout_body() {
 	(
 		trap "" PIPE
+		# Give true(1) some time to exit.
+		sleep 1
 		echo a | uniq 2>stderr
 		echo $? >result
 	) | true
diff --git a/usr.sbin/acpi/acpidump/acpi.c b/usr.sbin/acpi/acpidump/acpi.c
index 6f8effe58fbd..7b2e0c5e4d12 100644
--- a/usr.sbin/acpi/acpidump/acpi.c
+++ b/usr.sbin/acpi/acpidump/acpi.c
@@ -1629,8 +1629,8 @@ acpi_handle_ivrs_ivhd_devs(ACPI_IVRS_DE_HEADER *d, char *de)
 		} else if (d->Type == ACPI_IVRS_TYPE_EXT_START) {
 			d8b = (ACPI_IVRS_DEVICE8B *)db;
 			len = sizeof(*d8b);
-			d4 = (ACPI_IVRS_DEVICE4 *)(db + sizeof(*d8a));
-			len = sizeof(*d8a) + sizeof(*d4);
+			d4 = (ACPI_IVRS_DEVICE4 *)(db + sizeof(*d8b));
+			len = sizeof(*d8b) + sizeof(*d4);
 			printf("\t\tDev Type=%#x Id=%#06x-%#06x",
 			    d8a->Header.Type, d8a->Header.Id, d4->Header.Id);
 			acpi_handle_ivrs_ivhd_dte(d8b->Header.DataSetting);
diff --git a/usr.sbin/autofs/auto_master b/usr.sbin/autofs/auto_master
index bbe05c533708..111836c058a5 100644
--- a/usr.sbin/autofs/auto_master
+++ b/usr.sbin/autofs/auto_master
@@ -2,7 +2,5 @@
 # Automounter master map, see auto_master(5) for details.
 #
 /net		-hosts		-nobrowse,nosuid,intr
-# When using the -media special map, make sure to edit devd.conf(5)
-# to move the call to "automount -c" out of the comments section.
 #/media		-media		-nosuid,noatime,autoro
 #/-		-noauto
diff --git a/usr.sbin/autofs/autofs/special_media b/usr.sbin/autofs/autofs/special_media
index d72ddddddb2e..b397a8889623 100755
--- a/usr.sbin/autofs/autofs/special_media
+++ b/usr.sbin/autofs/autofs/special_media
@@ -40,7 +40,7 @@ print_map_entry() {
 	case "${_fstype}" in
 	"exfat")
 		if [ -f "/usr/local/sbin/mount.exfat" ]; then
-			echo "-mountprog=/usr/local/sbin/mount.exfat,fstype=${_fstype},nosuid	:/dev/${_p}"
+			echo "-mountprog=/usr/local/sbin/mount.exfat,fstype=${_fstype},sync	:/dev/${_p}"
 		else
 			/usr/bin/logger -p info -t "special_media[$$]" \
 			    "Cannot mount ${_fstype} formatted device /dev/${_p}: Install sysutils/fusefs-exfat first"
@@ -49,18 +49,21 @@ print_map_entry() {
 		;;
 	"ntfs")
 		if [ -f "/usr/local/bin/ntfs-3g" ]; then
-			echo "-mountprog=/usr/local/bin/ntfs-3g,fstype=${_fstype},nosuid	:/dev/${_p}"
+			echo "-mountprog=/usr/local/bin/ntfs-3g,fstype=${_fstype},sync	:/dev/${_p}"
 		else
 			/usr/bin/logger -p info -t "special_media[$$]" \
 			    "Cannot mount ${_fstype} formatted device /dev/${_p}: Install sysutils/fusefs-ntfs first"
 			exit 1
 		fi
 		;;
-	"ext2fs" | "msdosfs")
-		echo "-fstype=${_fstype},nosuid,async	:/dev/${_p}"
+	"msdosfs")
+		echo "-fstype=${_fstype},sync	:/dev/${_p}"
+		;;
+	"ext2fs")
+		echo "-fstype=${_fstype},async	:/dev/${_p}"
 		;;
 	*)
-		echo "-fstype=${_fstype},nosuid	:/dev/${_p}"
+		echo "-fstype=${_fstype}	:/dev/${_p}"
 		;;
 	esac
 }
diff --git a/usr.sbin/bhyve/tpm_ppi_qemu.c b/usr.sbin/bhyve/tpm_ppi_qemu.c
index 8bea45ea3208..da0edf84798f 100644
--- a/usr.sbin/bhyve/tpm_ppi_qemu.c
+++ b/usr.sbin/bhyve/tpm_ppi_qemu.c
@@ -162,7 +162,7 @@ tpm_ppi_deinit(void *sc)
 	ppi = sc;
 
 	error = unregister_mem(&ppi_mmio);
-	assert(error = 0);
+	assert(error == 0);
 
 	free(ppi);
 }
diff --git a/usr.sbin/bluetooth/ath3kfw/ath3kfw.8 b/usr.sbin/bluetooth/ath3kfw/ath3kfw.8
index 340871d31df8..beb1b102b194 100644
--- a/usr.sbin/bluetooth/ath3kfw/ath3kfw.8
+++ b/usr.sbin/bluetooth/ath3kfw/ath3kfw.8
@@ -1,3 +1,6 @@
+.\"-
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
 .\" Copyright (c) 2010 Maksim Yevmenkin <m_evmenkin@yahoo.com>
 .\" Copyright (c) 2013, 2016 Adrian Chadd <adrian@freebsd.org>
 .\" All rights reserved.
@@ -23,14 +26,15 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd June 4, 2016
+.Dd May 31, 2024
 .Dt ATH3KFW 8
 .Os
 .Sh NAME
 .Nm ath3kfw
-.Nd firmware download utility for Atheros AR3011/AR3012 chip based Bluetooth USB devices
+.Nd download firmware for Atheros AR3011/AR3012 Bluetooth USB devices
 .Sh SYNOPSIS
 .Nm
+.Op Fl DI
 .Fl d Ar device_name
 .Fl f Ar firmware_path
 .Nm
@@ -58,19 +62,19 @@ utility will query the device to determine which firmware image and board
 configuration to load in at runtime.
 .Pp
 The options are as follows:
-.Bl -tag -width indent
+.Bl -tag -width "-f firmware_path"
 .It Fl D
 Enable verbose debugging.
 .It Fl d Ar device_name
 Specify
 .Xr ugen 4
 device name.
-.It I
-Enable informational debugging.
 .It Fl f Ar firmware_path
 Specify the directory containing the firmware files to search and upload.
 .It Fl h
 Display usage message and exit.
+.It Fl I
+Enable informational debugging.
 .El
 .Sh EXIT STATUS
 .Ex -std
diff --git a/usr.sbin/bluetooth/bcmfw/bcmfw.8 b/usr.sbin/bluetooth/bcmfw/bcmfw.8
index 22d793641759..50e9739340ee 100644
--- a/usr.sbin/bluetooth/bcmfw/bcmfw.8
+++ b/usr.sbin/bluetooth/bcmfw/bcmfw.8
@@ -1,3 +1,6 @@
+.\"-
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
 .\" Copyright (c) 2003 Maksim Yevmenkin <m_evmenkin@yahoo.com>
 .\" All rights reserved.
 .\"
@@ -22,14 +25,12 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $Id: bcmfw.8,v 1.7 2003/05/21 00:33:40 max Exp $
-.\"
-.Dd March 31, 2003
+.Dd May 31, 2024
 .Dt BCMFW 8
 .Os
 .Sh NAME
 .Nm bcmfw
-.Nd firmware download utility for Broadcom BCM2033 chip based Bluetooth USB devices
+.Nd download firmware for Broadcom BCM2033 Bluetooth USB devices
 .Sh SYNOPSIS
 .Nm
 .Op Fl h
@@ -64,7 +65,7 @@ I am using the following files from the bluez-firmware-1.0 package:
 .Dl "MD5 (BCM2033-FW.bin) = b4e142b3272cfe5a84b32fda6b4b032f"
 .Pp
 The options are as follows:
-.Bl -tag -width indent
+.Bl -tag -width "-m mini-driver_file_name"
 .It Fl f Ar firmware_file_name
 Specify firmware file name for download.
 .It Fl h
@@ -75,7 +76,7 @@ Specify mini-driver file name for download.
 Specify device name.
 .El
 .Sh FILES
-.Bl -tag -width ".Pa /dev/ubtbcmfw Ns Ar N Ns Pa \&. Ns Ar EE" -compact
+.Bl -tag -width "-m mini-driver_file_name" -compact
 .It Pa BCM2033-MD.hex
 Mini-driver image.
 .It Pa BCM2033-FW.bin
diff --git a/usr.sbin/bluetooth/iwmbtfw/iwmbtfw.8 b/usr.sbin/bluetooth/iwmbtfw/iwmbtfw.8
index 368a3865a0eb..1924c5f3ce74 100644
--- a/usr.sbin/bluetooth/iwmbtfw/iwmbtfw.8
+++ b/usr.sbin/bluetooth/iwmbtfw/iwmbtfw.8
@@ -1,3 +1,6 @@
+.\"-
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
 .\" Copyright (c) 2013, 2016 Adrian Chadd <adrian@freebsd.org>
 .\" Copyright (c) 2019 Vladimir Kondratyev <wulf@FreeBSD.org>
 .\" Copyright (c) 2021 Philippe Michaud-Boudreault <pitwuu@gmail.com>
@@ -23,15 +26,15 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd May 3, 2021
+.Dd May 31, 2024
 .Dt IWMBTFW 8
 .Os
 .Sh NAME
 .Nm iwmbtfw
-.Nd firmware download utility for Intel Wireless 7260/8260/8265 chip based Bluetooth
-USB devices
+.Nd download firmware for Intel Wireless AC Bluetooth USB devices
 .Sh SYNOPSIS
 .Nm
+.Op Fl DI
 .Fl d Ar device_name
 .Fl f Ar firmware_path
 .Nm
@@ -45,8 +48,8 @@ device.
 .Pp
 This utility will
 .Em only
-work with Intel Wireless 7260/8260/8265 chip based Bluetooth USB devices and some of
-their successors.
+work with Intel Wireless 7260/8260/8265 chip based Bluetooth USB devices
+and some of their successors.
 The identification is currently based on USB vendor ID/product ID pair.
 The vendor ID should be 0x8087
 .Pq Dv USB_VENDOR_INTEL2
@@ -62,19 +65,19 @@ utility will query the device to determine which firmware image and board
 configuration to load in at runtime.
 .Pp
 The options are as follows:
-.Bl -tag -width indent
+.Bl -tag -width "-f firmware_path"
 .It Fl D
 Enable verbose debugging.
 .It Fl d Ar device_name
 Specify
 .Xr ugen 4
 device name.
-.It Fl I
-Enable informational debugging.
 .It Fl f Ar firmware_path
 Specify the directory containing the firmware files to search and upload.
 .It Fl h
 Display usage message and exit.
+.It Fl I
+Enable informational debugging.
 .El
 .Sh EXIT STATUS
 .Ex -std
diff --git a/usr.sbin/ctladm/ctladm.c b/usr.sbin/ctladm/ctladm.c
index e99610373ff0..228af7bae8c6 100644
--- a/usr.sbin/ctladm/ctladm.c
+++ b/usr.sbin/ctladm/ctladm.c
@@ -4133,7 +4133,7 @@ main(int argc, char **argv)
 		if (fd == -1 && errno == ENOENT) {
 			saved_errno = errno;
 			retval = kldload("ctl");
-			if (retval != -1)
+			if (retval != -1 || errno == EEXIST)
 				fd = open(device, O_RDWR);
 			else
 				errno = saved_errno;
diff --git a/usr.sbin/fwget/pci/Makefile b/usr.sbin/fwget/pci/Makefile
index 66b3901e4a91..6c500dae6df6 100644
--- a/usr.sbin/fwget/pci/Makefile
+++ b/usr.sbin/fwget/pci/Makefile
@@ -1,6 +1,7 @@
 PACKAGE=	fwget
 
 SCRIPTS=pci \
+	pci_network_intel \
 	pci_network_mediatek \
 	pci_network_qca \
 	pci_network_realtek \
diff --git a/usr.sbin/fwget/pci/pci b/usr.sbin/fwget/pci/pci
index 6a66049842e2..fbdfa0001c5c 100644
--- a/usr.sbin/fwget/pci/pci
+++ b/usr.sbin/fwget/pci/pci
@@ -107,7 +107,7 @@ pci_search_packages()
 		fi
 		. ${LIBEXEC_PATH}/pci_${class}_${vendor}
 
-		pci_${class}_${vendor} ${device}
+		pci_${class}_${vendor} ${device} "${fulldevice}"
 	done
 	IFS=${oldifs}
 }
diff --git a/usr.sbin/fwget/pci/pci_network_intel b/usr.sbin/fwget/pci/pci_network_intel
new file mode 100644
index 000000000000..cf8c52075db3
--- /dev/null
+++ b/usr.sbin/fwget/pci/pci_network_intel
@@ -0,0 +1,437 @@
+#-
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# Copyright (c) 2024 The FreeBSD Foundation
+#
+# This software was developed by Björn Zeeb
+# under sponsorship from the FreeBSD Foundation.
+#
+
+# Some iwlwifi chipsets are detected by other means and we cannot replicate
+# the full logic here.
+# Currently we also filter out all those which do have a wildcard device ID
+# as well as all for those which exists no firmware (yet).
+
+# iwlwifi (dynamic)
+pci_network_intel_iwlwifi()
+{
+
+	local idstr=$(echo $2 | sed 's,.*\ device=\(0x[0-9a-z]*\) subvendor=\(0x[0-9a-z]*\) subdevice=\(0x[0-9a-z]*\),\1/\2/\3,')
+
+	case "${idstr}" in
+
+	# The case pattern table below is generated by a script also helping
+	# to generate the flavor/firmware Makefile definitions for ports.
+	# { sys/contrib/dev/iwlwifi/zzz_fw_ports_fwget.sh }
+	### >>>
+
+	# 7000
+	0x08b1/*/0x4a6c) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0x4a6e) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0x4a70) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0x4c60) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0x4c70) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0x402a) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0x406a) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0x446a) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0x486e) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0x4020) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0x4060) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0x4062) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0x4070) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0x4072) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0x4160) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0x4162) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0x4170) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0x4420) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0x4460) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0x4462) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0x4470) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0x4472) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0x4560) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0x4570) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0x4870) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0x5070) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0x5072) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0x5170) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0x5770) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0xc02a) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0xc06a) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0xc020) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0xc060) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0xc062) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0xc070) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0xc072) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0xc160) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0xc162) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0xc170) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0xc360) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0xc420) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0xc460) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0xc462) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0xc470) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0xc472) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0xc560) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0xc570) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0xc760) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0xc770) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0xcc60) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b1/*/0xcc70) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b2/*/0x426a) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b2/*/0x4220) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b2/*/0x4260) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b2/*/0x4262) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b2/*/0x4270) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b2/*/0x4272) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b2/*/0x4360) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b2/*/0x4370) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b2/*/0xc26a) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b2/*/0xc220) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b2/*/0xc260) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b2/*/0xc262) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b2/*/0xc270) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b2/*/0xc272) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b2/*/0xc370) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b3/*/0x0060) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b3/*/0x0062) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b3/*/0x0070) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b3/*/0x0072) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b3/*/0x0170) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b3/*/0x0172) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b3/*/0x0470) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b3/*/0x0472) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b3/*/0x1070) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b3/*/0x1170) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b3/*/0x8060) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b3/*/0x8062) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b3/*/0x8070) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b3/*/0x8072) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b3/*/0x8170) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b3/*/0x8172) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b3/*/0x8470) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b3/*/0x8570) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b4/*/0x0270) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b4/*/0x0272) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b4/*/0x0370) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b4/*/0x8270) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b4/*/0x8272) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x08b4/*/0x8370) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x24fb/*/0x0000) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x24fb/*/0x2010) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x24fb/*/0x2050) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x24fb/*/0x2110) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x24fb/*/0x2150) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095a/*/0x5c10) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095a/*/0x5f10) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095a/*/0x9e10) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095a/*/0x500a) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095a/*/0x502a) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095a/*/0x900a) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095a/*/0x1010) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095a/*/0x5000) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095a/*/0x5002) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095a/*/0x5010) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095a/*/0x5012) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095a/*/0x5020) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095a/*/0x5090) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095a/*/0x5100) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095a/*/0x5102) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095a/*/0x5110) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095a/*/0x5190) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095a/*/0x5400) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095a/*/0x5410) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095a/*/0x5412) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095a/*/0x5420) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095a/*/0x5490) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095a/*/0x5510) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095a/*/0x5590) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095a/*/0x9000) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095a/*/0x9010) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095a/*/0x9012) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095a/*/0x9110) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095a/*/0x9112) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095a/*/0x9400) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095a/*/0x9410) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095a/*/0x9510) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095b/*/0x520a) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095b/*/0x5200) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095b/*/0x5202) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095b/*/0x5210) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095b/*/0x5212) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095b/*/0x5290) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095b/*/0x5302) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095b/*/0x5310) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095b/*/0x9200) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095b/*/0x9210) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x095b/*/0x9310) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x3165/*/0x4010) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x3165/*/0x4012) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x3165/*/0x4110) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x3165/*/0x4410) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x3165/*/0x4510) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x3165/*/0x8010) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x3165/*/0x8110) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x3166/*/0x4210) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x3166/*/0x4212) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+	0x3166/*/0x4310) addpkg "wifi-firmware-iwlwifi-kmod-7000"; return 1 ;;
+
+	# 8000
+	0x24f3/*/0x0000) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x01f0) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x0004) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x0010) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x10b0) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x0012) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x0044) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x0050) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x0110) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x0130) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x0132) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x0150) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x0250) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x0810) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x0850) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x0910) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x0930) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x0950) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x1010) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x1012) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x1050) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x1110) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x1130) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x1132) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x1150) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x4010) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x8010) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x8050) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x8110) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x8130) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x8132) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x8150) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x9010) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x9050) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x9110) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x9130) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x9132) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0x9150) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0xb0b0) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0xc010) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0xc050) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0xc110) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0xd0b0) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0xd010) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f3/*/0xd050) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f4/*/0x0030) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f4/*/0x1030) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f4/*/0x8030) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f4/*/0x9030) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f4/*/0xc030) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f4/*/0xd030) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f5/*/0x0010) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24f6/*/0x0030) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24fd/*/0x3e01) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24fd/*/0x3e02) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24fd/*/0x0010) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24fd/*/0x10d0) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24fd/*/0x0012) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24fd/*/0x0014) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24fd/*/0x0050) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24fd/*/0x0110) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24fd/*/0x0130) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24fd/*/0x0150) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24fd/*/0x0810) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24fd/*/0x0850) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24fd/*/0x0910) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24fd/*/0x0930) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24fd/*/0x0950) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24fd/*/0x1010) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24fd/*/0x1012) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24fd/*/0x1014) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24fd/*/0x1110) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24fd/*/0x1130) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24fd/*/0x8010) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24fd/*/0x8050) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24fd/*/0x8110) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24fd/*/0x8130) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24fd/*/0x9010) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24fd/*/0x9074) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+	0x24fd/*/0x9110) addpkg "wifi-firmware-iwlwifi-kmod-8000"; return 1 ;;
+
+	# 9000
+	0x9df0/*/*) addpkg "wifi-firmware-iwlwifi-kmod-9000"; return 1 ;;
+	0x30dc/*/*) addpkg "wifi-firmware-iwlwifi-kmod-9000"; return 1 ;;
+	0x31dc/*/*) addpkg "wifi-firmware-iwlwifi-kmod-9000"; return 1 ;;
+	0x271b/*/*) addpkg "wifi-firmware-iwlwifi-kmod-9000"; return 1 ;;
+	0x271c/*/*) addpkg "wifi-firmware-iwlwifi-kmod-9000"; return 1 ;;
+	0x2526/*/*) addpkg "wifi-firmware-iwlwifi-kmod-9000"; return 1 ;;
+	0xa370/*/*) addpkg "wifi-firmware-iwlwifi-kmod-9000"; return 1 ;;
+
+	# 22000
+	0x02f0/*/0x007c) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x02f0/*/0x0070) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x02f0/*/0x0074) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x02f0/*/0x0078) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x02f0/*/0x0310) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x02f0/*/0x1651) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x02f0/*/0x1652) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x02f0/*/0x2074) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x02f0/*/0x4070) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x02f0/*/0x6074) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x02f0/*/*) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x3df0/*/0x007c) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x3df0/*/0x0070) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x3df0/*/0x0074) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x3df0/*/0x0078) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x3df0/*/0x0310) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x3df0/*/0x1651) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x3df0/*/0x1652) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x3df0/*/0x2074) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x3df0/*/0x4070) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x3df0/*/*) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x4df0/*/0x007c) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x4df0/*/0x0070) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x4df0/*/0x0074) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x4df0/*/0x0078) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x4df0/*/0x0310) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x4df0/*/0x1651) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x4df0/*/0x1652) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x4df0/*/0x2074) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x4df0/*/0x4070) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x4df0/*/0x6074) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x4df0/*/*) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x06f0/*/0x007c) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x06f0/*/0x0070) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x06f0/*/0x0074) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x06f0/*/0x0078) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x06f0/*/0x0310) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x06f0/*/0x1651) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x06f0/*/0x1652) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x06f0/*/0x2074) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x06f0/*/0x4070) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x06f0/*/*) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x34f0/*/0x007c) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x34f0/*/0x0070) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x34f0/*/0x0074) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x34f0/*/0x0078) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x34f0/*/0x0310) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x34f0/*/0x1651) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x34f0/*/0x1652) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x34f0/*/0x2074) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x34f0/*/0x4070) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x34f0/*/*) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x43f0/*/0x007c) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x43f0/*/0x0070) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x43f0/*/0x0074) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x43f0/*/0x0078) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x43f0/*/0x1651) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x43f0/*/0x1652) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x43f0/*/0x2074) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x43f0/*/0x4070) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x43f0/*/*) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x2723/*/0x1653) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x2723/*/0x1654) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0x2723/*/*) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0xa0f0/*/0x0a10) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0xa0f0/*/0x007c) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0xa0f0/*/0x0070) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0xa0f0/*/0x0074) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0xa0f0/*/0x0078) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0xa0f0/*/0x1651) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0xa0f0/*/0x1652) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0xa0f0/*/0x2074) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0xa0f0/*/0x4070) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0xa0f0/*/0x6074) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+	0xa0f0/*/*) addpkg "wifi-firmware-iwlwifi-kmod-22000"; return 1 ;;
+
+	# ax210
+	0x7a70/*/0x0a10) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x7a70/*/0x00b0) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x7a70/*/0x0090) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x7a70/*/0x0098) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x7a70/*/0x0310) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x7a70/*/0x0510) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x7a70/*/0x1671) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x7a70/*/0x1672) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x7a70/*/0x1691) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x7a70/*/0x1692) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x7a70/*/*) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x7af0/*/0x0a10) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x7af0/*/0x00b0) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x7af0/*/0x0090) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x7af0/*/0x0098) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x7af0/*/0x0310) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x7af0/*/0x0510) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x7af0/*/0x1671) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x7af0/*/0x1672) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x7af0/*/0x1691) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x7af0/*/0x1692) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x7af0/*/*) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x7e40/*/0x1671) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x7e40/*/0x1672) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x7e40/*/0x1691) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x7e40/*/0x1692) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x7e40/*/*) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x7f70/*/0x1671) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x7f70/*/0x1672) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x7f70/*/*) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x51f0/*/0x1671) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x51f0/*/0x1672) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x51f0/*/0x1691) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x51f0/*/0x1692) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x51f0/*/*) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x51f1/*/0x1671) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x51f1/*/0x1672) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x51f1/*/0x1692) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x51f1/*/*) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x54f0/*/0x1671) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x54f0/*/0x1672) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x54f0/*/0x1691) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x54f0/*/0x1692) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x54f0/*/*) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x2725/*/0x0a10) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x2725/*/0x0020) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x2725/*/0x0024) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x2725/*/0x0090) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x2725/*/0x0310) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x2725/*/0x0510) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x2725/*/0x1673) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x2725/*/0x1674) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x2725/*/0x2020) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x2725/*/0x4020) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x2725/*/0x6020) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x2725/*/0x6024) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x2725/*/0xe020) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x2725/*/0xe024) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x2725/*/*) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x2726/*/0x1671) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x2726/*/0x1672) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+	0x2729/*/*) addpkg "wifi-firmware-iwlwifi-kmod-ax210"; return 1 ;;
+
+	# bz
+	0x272b/*/*) addpkg "wifi-firmware-iwlwifi-kmod-bz"; return 1 ;;
+	0x272d/*/*) addpkg "wifi-firmware-iwlwifi-kmod-bz"; return 1 ;;
+	0x2727/*/*) addpkg "wifi-firmware-iwlwifi-kmod-bz"; return 1 ;;
+	0x7740/*/*) addpkg "wifi-firmware-iwlwifi-kmod-bz"; return 1 ;;
+	0xa840/*/*) addpkg "wifi-firmware-iwlwifi-kmod-bz"; return 1 ;;
+
+	# sc
+	0x6e70/*/*) addpkg "wifi-firmware-iwlwifi-kmod-sc"; return 1 ;;
+	0xd340/*/*) addpkg "wifi-firmware-iwlwifi-kmod-sc"; return 1 ;;
+	0xe340/*/*) addpkg "wifi-firmware-iwlwifi-kmod-sc"; return 1 ;;
+	0xe440/*/*) addpkg "wifi-firmware-iwlwifi-kmod-sc"; return 1 ;;
+
+	### <<<
+
+	esac
+}
+
+pci_network_intel()
+{
+
+	for _drv in iwlwifi; do
+		pci_network_intel_${_drv} "$1" "$2"
+		case $? in
+		1)	break ;;
+		esac
+	done
+}
diff --git a/usr.sbin/fwget/pci/pci_network_mediatek b/usr.sbin/fwget/pci/pci_network_mediatek
index 5e4d2af9eb26..3ed6c8b95b47 100644
--- a/usr.sbin/fwget/pci/pci_network_mediatek
+++ b/usr.sbin/fwget/pci/pci_network_mediatek
@@ -2,6 +2,10 @@
 # SPDX-License-Identifier: BSD-2-Clause
 #
 # Copyright 2023 Bjoern A. Zeeb
+# Copyright (c) 2024 The FreeBSD Foundation
+#
+# Portions of this software were developed by Björn Zeeb
+# under sponsorship from the FreeBSD Foundation.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
@@ -25,45 +29,38 @@
 # SUCH DAMAGE.
 #
 
-# mt7915
-pci_network_mediatek_mt7915()
+pci_network_mediatek_mt76()
 {
 
-	# awk 'BEGIN { x = 0; } { if (/mt7915_pci_device_table/) { x=1 }; if (/^\};/) { x=0 }; if (x==1 && /PCI_DEVICE\(PCI_VENDOR_ID_MEDIATEK,/) { gsub(").*", "", $3); printf "%s)\taddpkg \"wifi-firmware-mt76-kmod\"; return 1 ;;\n", tolower($3) } }' *.c
-
 	case "$1" in
-	0x7915)	addpkg "wifi-firmware-mt76-kmod"; return 1 ;;
-	0x7906)	addpkg "wifi-firmware-mt76-kmod"; return 1 ;;
-	esac
-}
+	# The case pattern table below is generated by a script also helping
+	# to generate the flavor/firmware Makefile definitions for ports.
+	# { sys/contrib/dev/mediatek/mt76/zzz_fw_ports_fwget.sh }
+	### >>>
 
-# mt7921
-pci_network_mediatek_mt7921()
-{
+	0x0608)	addpkg "wifi-firmware-mediatek-kmod-mt792x"; return 1 ;;
+	0x0616)	addpkg "wifi-firmware-mediatek-kmod-mt792x"; return 1 ;;
+	0x0717)	addpkg "wifi-firmware-mediatek-kmod-mt792x"; return 1 ;;
+	0x7906)	addpkg "wifi-firmware-mediatek-kmod-mt7915"; return 1 ;;
+	0x790a)	addpkg "wifi-firmware-mediatek-kmod-mt7915"; return 1 ;;
+	0x7915)	addpkg "wifi-firmware-mediatek-kmod-mt7915"; return 1 ;;
+	0x7916)	addpkg "wifi-firmware-mediatek-kmod-mt7915"; return 1 ;;
+	0x7922)	addpkg "wifi-firmware-mediatek-kmod-mt792x"; return 1 ;;
+	0x7925)	addpkg "wifi-firmware-mediatek-kmod-mt792x"; return 1 ;;
+	0x7961)	addpkg "wifi-firmware-mediatek-kmod-mt792x"; return 1 ;;
+	0x7990)	addpkg "wifi-firmware-mediatek-kmod-mt7996"; return 1 ;;
+	0x7991)	addpkg "wifi-firmware-mediatek-kmod-mt7996"; return 1 ;;
+	0x7992)	addpkg "wifi-firmware-mediatek-kmod-mt7996"; return 1 ;;
+	0x799a)	addpkg "wifi-firmware-mediatek-kmod-mt7996"; return 1 ;;
 
-	# awk 'BEGIN { x = 0; } { if (/mt7921_pci_device_table/) { x=1 }; if (/^\};/) { x=0 }; if (x==1 && /PCI_DEVICE\(PCI_VENDOR_ID_MEDIATEK,/) { gsub(").*", "", $3); printf "%s)\taddpkg \"wifi-firmware-mt76-kmod\"; return 1 ;;\n", tolower($3) } }' *.c
-        case "$1" in
-	0x7961)	addpkg "wifi-firmware-mt76-kmod"; return 1 ;;
-	0x7922)	addpkg "wifi-firmware-mt76-kmod"; return 1 ;;
-	0x0608)	addpkg "wifi-firmware-mt76-kmod"; return 1 ;;
-	0x0616)	addpkg "wifi-firmware-mt76-kmod"; return 1 ;;
-	esac
-}
-
-# mt7996
-pci_network_mediatek_mt7996()
-{
-
-	# awk 'BEGIN { x = 0; } { if (/mt7996_pci_device_table/) { x=1 }; if (/^\};/) { x=0 }; if (x==1 && /PCI_DEVICE\(PCI_VENDOR_ID_MEDIATEK,/) { gsub(").*", "", $3); printf "%s)\taddpkg \"wifi-firmware-mt76-kmod\"; return 1 ;;\n", tolower($3) } }' *.c
-	case "$1" in
-	0x7990)	addpkg "wifi-firmware-mt76-kmod"; return 1 ;;
+	### <<<
 	esac
 }
 
 pci_network_mediatek()
 {
 
-	for _drv in mt7915 mt7921 mt7996; do
+	for _drv in mt76; do
 		pci_network_mediatek_${_drv} "$1"
 		case $? in
 		1)	break ;;
diff --git a/usr.sbin/fwget/pci/pci_network_qca b/usr.sbin/fwget/pci/pci_network_qca
index cf33e0d87239..a97d29ef1135 100644
--- a/usr.sbin/fwget/pci/pci_network_qca
+++ b/usr.sbin/fwget/pci/pci_network_qca
@@ -29,18 +29,27 @@
 pci_network_qca_ath10k()
 {
 
-	# awk '/DEVICE_ID[[:space:]]/ { gsub("[()]", "", $3); printf "%s)\taddpkg \"wifi-firmware-ath10k-kmod\"; return 1 ;;\n", tolower($3) }' hw.h
-	# We ignore the ubiquity entry for now.
         case "$1" in
-	0x003c)	addpkg "wifi-firmware-ath10k-kmod"; return 1 ;;
-	0x0041)	addpkg "wifi-firmware-ath10k-kmod"; return 1 ;;
-	0x003e)	addpkg "wifi-firmware-ath10k-kmod"; return 1 ;;
-	0x0042)	addpkg "wifi-firmware-ath10k-kmod"; return 1 ;;
-	0x0040)	addpkg "wifi-firmware-ath10k-kmod"; return 1 ;;
-	0x0056)	addpkg "wifi-firmware-ath10k-kmod"; return 1 ;;
-	0x0046)	addpkg "wifi-firmware-ath10k-kmod"; return 1 ;;
-	0x0042)	addpkg "wifi-firmware-ath10k-kmod"; return 1 ;;
-	0x0050)	addpkg "wifi-firmware-ath10k-kmod"; return 1 ;;
+
+	# The case pattern table below is generated by a script also helping
+	# to generate the flavor/firmware Makefile definitions for ports.
+	# { sys/contrib/dev/athk/ath10k/zzz_fw_ports_fwget.sh }
+	### >>>
+
+	0x003c)	addpkg "wifi-firmware-ath10k-kmod-qca988x_hw20"; return 1 ;;
+	0x003e)	addpkg "wifi-firmware-ath10k-kmod-qca6174_hw21"
+		addpkg "wifi-firmware-ath10k-kmod-qca6174_hw30"
+		return 1 ;;
+	0x0040)	addpkg "wifi-firmware-ath10k-kmod-qca99x0_hw20"; return 1 ;;
+	0x0041)	addpkg "wifi-firmware-ath10k-kmod-qca6174_hw21"; return 1 ;;
+	0x0042)	addpkg "wifi-firmware-ath10k-kmod-qca6174_hw30"
+		addpkg "wifi-firmware-ath10k-kmod-qca9377_hw10"
+		return 1 ;;
+	0x0046)	addpkg "wifi-firmware-ath10k-kmod-qca9984_hw10"; return 1 ;;
+	0x0050)	addpkg "wifi-firmware-ath10k-kmod-qca9887_hw10"; return 1 ;;
+	0x0056)	addpkg "wifi-firmware-ath10k-kmod-qca9888_hw20"; return 1 ;;
+
+	### <<<
 	esac
 }
 
@@ -48,31 +57,42 @@ pci_network_qca_ath10k()
 pci_network_qca_ath11k()
 {
 
-	# awk '/DEVICE_ID[[:space:]]/ { gsub("[()]", "", $3); printf "%s)\taddpkg \"wifi-firmware-ath11k-kmod\"; return 1 ;;\n", tolower($3) }' pci.c
         case "$1" in
-	0x1101)	addpkg "wifi-firmware-ath11k-kmod"; return 1 ;;
-	0x1104)	addpkg "wifi-firmware-ath11k-kmod"; return 1 ;;
-	0x1103)	addpkg "wifi-firmware-ath11k-kmod"; return 1 ;;
+
+	# The case pattern table below is generated by a script also helping
+	# to generate the flavor/firmware Makefile definitions for ports.
+	# { sys/contrib/dev/athk/ath11k/zzz_fw_ports_fwget.sh }
+	### >>>
+
+	0x1101)	addpkg "wifi-firmware-ath11k-kmod-qca6390_hw20"; return 1 ;;
+	0x1103)	addpkg "wifi-firmware-ath11k-kmod-wcn6855_hw20"; return 1 ;;
+	0x1104)	addpkg "wifi-firmware-ath11k-kmod-qcn9074_hw10"; return 1 ;;
+
+	### <<<
 	esac
 }
 
 # ath12k
 pci_network_qca_ath12k()
 {
-	# No ath12k firmware package yet
-	return 0
 
-	# awk '/DEVICE_ID[[:space:]]/ { gsub("[()]", "", $3); printf "%s)\taddpkg \"wifi-firmware-ath12k-kmod\"; return 1 ;;\n", tolower($3) }' pci.c
         case "$1" in
-	0x1109)	addpkg "wifi-firmware-ath12k-kmod"; return 1 ;;
-	0x1107)	addpkg "wifi-firmware-ath12k-kmod"; return 1 ;;
+
+	# The case pattern table below is generated by a script also helping
+	# to generate the flavor/firmware Makefile definitions for ports.
+	# { sys/contrib/dev/athk/ath12k/zzz_fw_ports_fwget.sh }
+	### >>>
+
+	0x1107)	addpkg "wifi-firmware-ath12k-kmod-wcn7850_hw20"; return 1 ;;
+
+	### <<<
 	esac
 }
 
 pci_network_qca()
 {
 
-	for _drv in ath10k ath11k; do
+	for _drv in ath10k ath11k ath12k; do
 		pci_network_qca_${_drv} "$1"
 		case $? in
 		1)	break ;;
diff --git a/usr.sbin/fwget/pci/pci_network_realtek b/usr.sbin/fwget/pci/pci_network_realtek
index 795d9d4a6e0a..d70470b65244 100644
--- a/usr.sbin/fwget/pci/pci_network_realtek
+++ b/usr.sbin/fwget/pci/pci_network_realtek
@@ -2,6 +2,10 @@
 # SPDX-License-Identifier: BSD-2-Clause
 #
 # Copyright 2023 Bjoern A. Zeeb
+# Copyright (c) 2024 The FreeBSD Foundation
+#
+# Portions of this software were developed by Björn Zeeb
+# under sponsorship from the FreeBSD Foundation.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
@@ -29,14 +33,21 @@
 pci_network_realtek_rtw88()
 {
 
-	# awk '/PCI_DEVICE\(PCI_VENDOR_ID_REALTEK,/ { gsub(").*", "", $2); printf "%s)\taddpkg \"wifi-firmware-rtw88-kmod\"; return 1 ;;\n", tolower($2) }' *.c
 	case "$1" in
-	0xd723)	addpkg "wifi-firmware-rtw88-kmod"; return 1 ;;
-	0xb821)	addpkg "wifi-firmware-rtw88-kmod"; return 1 ;;
-	0xc821)	addpkg "wifi-firmware-rtw88-kmod"; return 1 ;;
-	0xb822)	addpkg "wifi-firmware-rtw88-kmod"; return 1 ;;
-	0xc822)	addpkg "wifi-firmware-rtw88-kmod"; return 1 ;;
-	0xc82f)	addpkg "wifi-firmware-rtw88-kmod"; return 1 ;;
+
+	# The case pattern table below is generated by a script also helping
+	# to generate the flavor/firmware Makefile definitions for ports.
+	# { sys/contrib/dev/rtw88/zzz_fw_ports_fwget.sh }
+	### >>>
+
+	0xd723)	addpkg "wifi-firmware-rtw88-kmod-rtw8723d"; return 1 ;;
+	0xb821)	addpkg "wifi-firmware-rtw88-kmod-rtw8821c"; return 1 ;;
+	0xc821)	addpkg "wifi-firmware-rtw88-kmod-rtw8821c"; return 1 ;;
+	0xb822)	addpkg "wifi-firmware-rtw88-kmod-rtw8822b"; return 1 ;;
+	0xc822)	addpkg "wifi-firmware-rtw88-kmod-rtw8822c"; return 1 ;;
+	0xc82f)	addpkg "wifi-firmware-rtw88-kmod-rtw8822c"; return 1 ;;
+
+	### <<<
 	esac
 }
 
@@ -44,11 +55,22 @@ pci_network_realtek_rtw88()
 pci_network_realtek_rtw89()
 {
 
-	# awk '/PCI_DEVICE\(PCI_VENDOR_ID_REALTEK,/ { gsub(").*", "", $2); printf "%s)\taddpkg \"wifi-firmware-rtw89-kmod\"; return 1 ;;\n", tolower($2) }' *.c
-        case "$1" in
-	0x8852)	addpkg "wifi-firmware-rtw89-kmod"; return 1 ;;
-	0xa85a)	addpkg "wifi-firmware-rtw89-kmod"; return 1 ;;
-	0xc852)	addpkg "wifi-firmware-rtw89-kmod"; return 1 ;;
+	case "$1" in
+
+	# The case pattern table below is generated by a script also helping
+	# to generate the flavor/firmware Makefile definitions for ports.
+	# { sys/contrib/dev/rtw89/zzz_fw_ports_fwget.sh }
+	### >>>
+
+	0xb851)	addpkg "wifi-firmware-rtw89-kmod-rtw8851b"; return 1 ;;
+	0x8852)	addpkg "wifi-firmware-rtw89-kmod-rtw8852a"; return 1 ;;
+	0xa85a)	addpkg "wifi-firmware-rtw89-kmod-rtw8852a"; return 1 ;;
+	0xb852)	addpkg "wifi-firmware-rtw89-kmod-rtw8852b"; return 1 ;;
+	0xb85b)	addpkg "wifi-firmware-rtw89-kmod-rtw8852b"; return 1 ;;
+	0xc852)	addpkg "wifi-firmware-rtw89-kmod-rtw8852c"; return 1 ;;
+	0x8922)	addpkg "wifi-firmware-rtw89-kmod-rtw8922a"; return 1 ;;
+
+	### <<<
 	esac
 }
 
diff --git a/usr.sbin/fwget/pci/pci_video_amd b/usr.sbin/fwget/pci/pci_video_amd
index b44eac1adf7b..5f89b12dce7c 100644
--- a/usr.sbin/fwget/pci/pci_video_amd
+++ b/usr.sbin/fwget/pci/pci_video_amd
@@ -135,5 +135,20 @@ pci_video_amd()
 		0x742*|0x743*)
 			addpkg "gpu-firmware-amd-kmod-beige-goby"
 			;;
+		0x744c)
+			addpkg "gpu-firmware-amd-kmod-dcn-3-2-0"
+			addpkg "gpu-firmware-amd-kmod-gc-11-0-0"
+			addpkg "gpu-firmware-amd-kmod-psp-13-0-0"
+			addpkg "gpu-firmware-amd-kmod-sdma-6-0-0"
+			addpkg "gpu-firmware-amd-kmod-smu-13-0-0"
+			addpkg "gpu-firmware-amd-kmod-vcn-4-0-0"
+			;;
+		0x15bf)
+			addpkg "gpu-firmware-amd-kmod-gc-11-0-1"
+			addpkg "gpu-firmware-amd-kmod-psp-13-0-4"
+			addpkg "gpu-firmware-amd-kmod-dcn-3-1-4"
+			addpkg "gpu-firmware-amd-kmod-sdma-6-0-1"
+			addpkg "gpu-firmware-amd-kmod-vcn-4-0-2"
+			;;
 	esac
 }
diff --git a/usr.sbin/iovctl/iovctl.c b/usr.sbin/iovctl/iovctl.c
index 413fb7b2f4a5..368fa51c594f 100644
--- a/usr.sbin/iovctl/iovctl.c
+++ b/usr.sbin/iovctl/iovctl.c
@@ -346,6 +346,12 @@ print_default_value(const nvlist_t *parameter, const char *type)
 		mac = nvlist_get_binary(parameter, DEFAULT_SCHEMA_NAME, &size);
 		printf(" (default = %02x:%02x:%02x:%02x:%02x:%02x)", mac[0],
 		    mac[1], mac[2], mac[3], mac[4], mac[5]);
+	} else if (strcasecmp(type, "vlan") == 0) {
+		uint16_t vlan = nvlist_get_number(parameter, DEFAULT_SCHEMA_NAME);
+		if (vlan == VF_VLAN_TRUNK)
+			printf(" (default = trunk)");
+		else
+			printf(" (default = %d)", vlan);
 	} else
 		errx(1, "Unexpected type in schema: '%s'", type);
 }
diff --git a/usr.sbin/iovctl/iovctl.conf.5 b/usr.sbin/iovctl/iovctl.conf.5
index a7eb6c2077ee..1bae96e150ba 100644
--- a/usr.sbin/iovctl/iovctl.conf.5
+++ b/usr.sbin/iovctl/iovctl.conf.5
@@ -23,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd May 29, 2020
+.Dd May 30, 2024
 .Dt IOVCTL.CONF 5
 .Os
 .Sh NAME
@@ -95,6 +95,8 @@ The following option types are supported:
 .Bl -tag -width indent
 .It boolean
 Accepts a boolean value of true or false.
+.It vlan
+Accepts a VLAN ID, or "trunk" to allow any VLAN ID.
 .It mac-addr
 Accepts a unicast MAC address specified as a string of the form
 xx:xx:xx:xx:xx:xx, where xx is one or two hexadecimal digits.
@@ -159,6 +161,7 @@ DEFAULT {
 VF-0 {
 	mac-addr : "02:56:48:7e:d9:f7";
 	passthrough : false;
+	vlan: 1;
 }
 .Ed
 .Sh SEE ALSO
diff --git a/usr.sbin/iovctl/parse.c b/usr.sbin/iovctl/parse.c
index d04c008b449c..8bf37fa97979 100644
--- a/usr.sbin/iovctl/parse.c
+++ b/usr.sbin/iovctl/parse.c
@@ -161,6 +161,29 @@ add_unicast_mac_config(const char *key, const ucl_object_t *obj, nvlist_t *confi
 	nvlist_add_binary(config, key, mac, ETHER_ADDR_LEN);
 }
 
+static void
+add_vlan_config(const char *key, const ucl_object_t *obj, nvlist_t *config)
+{
+	int64_t val;
+	const char *strVal = "";
+
+	if(ucl_object_tostring_safe(obj, &strVal)) {
+		if (strcasecmp(strVal, "trunk") == 0) {
+			nvlist_add_number(config, key, VF_VLAN_TRUNK);
+			return;
+		}
+		report_config_error(key, obj, "vlan");
+	}
+
+	if (!ucl_object_toint_safe(obj, &val))
+		report_config_error(key, obj, "vlan");
+
+	if (val < 0 || val > 4095)
+		report_config_error(key, obj, "vlan");
+
+	nvlist_add_number(config, key, val);
+}
+
 /*
  * Validates that the given configuration value has the right type as specified
  * in the schema, and then adds the value to the configuration node.
@@ -187,6 +210,8 @@ add_config(const char *key, const ucl_object_t *obj, nvlist_t *config,
 		add_uint_config(key, obj, config, type, UINT64_MAX);
 	else if (strcasecmp(type, "unicast-mac") == 0)
 		add_unicast_mac_config(key, obj, config);
+	else if (strcasecmp(type, "vlan") == 0)
+		add_vlan_config(key, obj, config);
 	else
 		errx(1, "Unexpected type '%s' in schema", type);
 }
diff --git a/usr.sbin/jail/jail.8 b/usr.sbin/jail/jail.8
index 0e98914795a2..3a6e46b065b2 100644
--- a/usr.sbin/jail/jail.8
+++ b/usr.sbin/jail/jail.8
@@ -23,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd August 26, 2023
+.Dd June 24, 2024
 .Dt JAIL 8
 .Os
 .Sh NAME
@@ -761,7 +761,15 @@ the jail cannot perform any sysvmsg-related system calls.
 .It Va sysvsem, sysvshm
 Allow access to SYSV IPC semaphore and shared memory primitives, in the
 same manner as
-.Va sysvmsg.
+.Va sysvmsg .
+.It Va zfs.mount_snapshot
+Allow jailed users to access the contents of ZFS snapshots under the
+filesystem's
+.Pa .zfs
+directory.
+If
+.Va allow.mount.zfs
+is set, the snapshots may also be mounted.
 .El
 .Pp
 There are pseudo-parameters that are not passed to the kernel, but are
diff --git a/usr.sbin/makefs/zfs/dsl.c b/usr.sbin/makefs/zfs/dsl.c
index 93083f286e81..f7264b9d2ca7 100644
--- a/usr.sbin/makefs/zfs/dsl.c
+++ b/usr.sbin/makefs/zfs/dsl.c
@@ -490,7 +490,6 @@ dsl_dir_finalize_props(zfs_dsl_dir_t *dir)
 static void
 dsl_dir_finalize(zfs_opt_t *zfs, zfs_dsl_dir_t *dir, void *arg __unused)
 {
-	char key[32];
 	zfs_dsl_dir_t *cdir;
 	dnode_phys_t *snapnames;
 	zfs_dsl_dataset_t *headds;
@@ -519,8 +518,7 @@ dsl_dir_finalize(zfs_opt_t *zfs, zfs_dsl_dir_t *dir, void *arg __unused)
 	objset_root_blkptr_copy(os, &headds->phys->ds_bp);
 
 	zfs->snapds->phys->ds_num_children++;
-	snprintf(key, sizeof(key), "%jx", (uintmax_t)headds->dsid);
-	zap_add_uint64(zfs->cloneszap, key, headds->dsid);
+	zap_add_uint64_self(zfs->cloneszap, headds->dsid);
 
 	bytes = objset_space(os);
 	headds->phys->ds_used_bytes = bytes;
diff --git a/usr.sbin/makefs/zfs/zap.c b/usr.sbin/makefs/zfs/zap.c
index 2437ee3bfd1e..d01f7527adf9 100644
--- a/usr.sbin/makefs/zfs/zap.c
+++ b/usr.sbin/makefs/zfs/zap.c
@@ -166,6 +166,15 @@ zap_add_uint64(zfs_zap_t *zap, const char *name, uint64_t val)
 	zap_add(zap, name, sizeof(uint64_t), 1, (uint8_t *)&val);
 }
 
+void
+zap_add_uint64_self(zfs_zap_t *zap, uint64_t val)
+{
+	char name[32];
+
+	snprintf(name, sizeof(name), "%jx", (uintmax_t)val);
+	zap_add(zap, name, sizeof(uint64_t), 1, (uint8_t *)&val);
+}
+
 void
 zap_add_string(zfs_zap_t *zap, const char *name, const char *val)
 {
diff --git a/usr.sbin/makefs/zfs/zfs.h b/usr.sbin/makefs/zfs/zfs.h
index 9af090b14912..ff94c270bbf6 100644
--- a/usr.sbin/makefs/zfs/zfs.h
+++ b/usr.sbin/makefs/zfs/zfs.h
@@ -159,6 +159,7 @@ void vdev_fini(zfs_opt_t *zfs);
 zfs_zap_t *zap_alloc(zfs_objset_t *, dnode_phys_t *);
 void zap_add(zfs_zap_t *, const char *, size_t, size_t, const uint8_t *);
 void zap_add_uint64(zfs_zap_t *, const char *, uint64_t);
+void zap_add_uint64_self(zfs_zap_t *, uint64_t);
 void zap_add_string(zfs_zap_t *, const char *, const char *);
 bool zap_entry_exists(zfs_zap_t *, const char *);
 void zap_write(zfs_opt_t *, zfs_zap_t *);
diff --git a/usr.sbin/ntp/config.h b/usr.sbin/ntp/config.h
index 97c46aaf1dab..3d6a1364dd10 100644
--- a/usr.sbin/ntp/config.h
+++ b/usr.sbin/ntp/config.h
@@ -172,12 +172,7 @@
 /* Zyfer GPStarplus */
 #define CLOCK_ZYFER 1
 
-/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
-   systems. This function is required for `alloca.c' support on those systems.
-   */
-/* #undef CRAY_STACKSEG_END */
-
-/* Define to 1 if using `alloca.c'. */
+/* Define to 1 if using 'alloca.c'. */
 /* #undef C_ALLOCA */
 
 /* Enable debugging code? */
@@ -265,7 +260,7 @@
 /* #undef DECL_STRTOL_0 */
 
 /* Declare syscall()? */
-/* #undef DECL_SYSCALL */
+#define DECL_SYSCALL 1
 
 /* Declaration style */
 /* #undef DECL_SYSLOG_0 */
@@ -297,6 +292,12 @@
 /* use old autokey session key behavior? */
 /* #undef DISABLE_BUG1243_FIX */
 
+/* use old autokey session key behavior? */
+/* #undef DISABLE_BUG3527_FIX */
+
+/* Disable debug assertion on OOB KoD RATE value? */
+/* #undef DISABLE_BUG3767_FIX */
+
 /* synch TODR hourly? */
 /* #undef DOSYNCTODR */
 
@@ -315,6 +316,9 @@
 /* Enable CMAC support? */
 #define ENABLE_CMAC 1
 
+/* auto-instantiate missing PPS devices on Linux */
+#define ENABLE_MAGICPPS 1
+
 /* nls support in libopts */
 /* #undef ENABLE_NLS */
 
@@ -330,20 +334,19 @@
 /* via __adjtimex */
 /* #undef HAVE_ADJTIMEX */
 
-/* Define to 1 if you have `alloca', as a function or macro. */
+/* Define to 1 if you have 'alloca', as a function or macro. */
 #define HAVE_ALLOCA 1
 
-/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
-   */
+/* Define to 1 if <alloca.h> works. */
 /* #undef HAVE_ALLOCA_H */
 
-/* Define to 1 if you have the `arc4random_buf' function. */
+/* Define to 1 if you have the 'arc4random_buf' function. */
 #define HAVE_ARC4RANDOM_BUF 1
 
 /* Define to 1 if you have the <arpa/nameser.h> header file. */
 #define HAVE_ARPA_NAMESER_H 1
 
-/* Define to 1 if you have the `atomic_thread_fence' function. */
+/* Define to 1 if you have the 'atomic_thread_fence' function. */
 /* #undef HAVE_ATOMIC_THREAD_FENCE */
 
 /* Do we have audio support? */
@@ -352,43 +355,46 @@
 /* Define to 1 if you have the <bstring.h> header file. */
 /* #undef HAVE_BSTRING_H */
 
-/* Define to 1 if you have the `canonicalize_file_name' function. */
+/* Define to 1 if you have the 'canonicalize_file_name' function. */
 /* #undef HAVE_CANONICALIZE_FILE_NAME */
 
-/* Define to 1 if you have the `chmod' function. */
+/* Define to 1 if you have the 'chmod' function. */
 #define HAVE_CHMOD 1
 
 /* Do we have the CIOGETEV ioctl (SunOS, Linux)? */
 /* #undef HAVE_CIOGETEV */
 
-/* Define to 1 if you have the `clock_getres' function. */
+/* Define to 1 if you have the 'clock_getres' function. */
 #define HAVE_CLOCK_GETRES 1
 
-/* Define to 1 if you have the `clock_gettime' function. */
+/* Define to 1 if you have the 'clock_gettime' function. */
 #define HAVE_CLOCK_GETTIME 1
 
-/* Define to 1 if you have the `clock_settime' function. */
+/* Define to 1 if you have the 'clock_settime' function. */
 #define HAVE_CLOCK_SETTIME 1
 
+/* Define to 1 if you have the 'closefrom' function. */
+#define HAVE_CLOSEFROM 1
+
 /* Define to 1 if you have the <cthreads.h> header file. */
 /* #undef HAVE_CTHREADS_H */
 
-/* Define to 1 if you have the `daemon' function. */
+/* Define to 1 if you have the 'daemon' function. */
 #define HAVE_DAEMON 1
 
-/* Define to 1 if you have the declaration of `siglongjmp', and to 0 if you
+/* Define to 1 if you have the declaration of 'siglongjmp', and to 0 if you
    don't. */
 #define HAVE_DECL_SIGLONGJMP 1
 
-/* Define to 1 if you have the declaration of `sigsetjmp', and to 0 if you
+/* Define to 1 if you have the declaration of 'sigsetjmp', and to 0 if you
    don't. */
 #define HAVE_DECL_SIGSETJMP 1
 
-/* Define to 1 if you have the declaration of `strerror_r', and to 0 if you
+/* Define to 1 if you have the declaration of 'strerror_r', and to 0 if you
    don't. */
 #define HAVE_DECL_STRERROR_R 1
 
-/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
+/* Define to 1 if you have the <dirent.h> header file, and it defines 'DIR'.
    */
 #define HAVE_DIRENT_H 1
 
@@ -398,58 +404,67 @@
 /* Use Rendezvous/DNS-SD registration */
 /* #undef HAVE_DNSREGISTRATION */
 
-/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
+/* Define to 1 if you don't have 'vprintf' but do have '_doprnt.' */
 /* #undef HAVE_DOPRNT */
 
 /* Can we drop root privileges? */
-#define HAVE_DROPROOT
+#define HAVE_DROPROOT 1
 
 /* Define to 1 if you have the <errno.h> header file. */
 #define HAVE_ERRNO_H 1
 
-/* Define to 1 if you have the `EVP_MD_do_all_sorted' function. */
+/* Define to 1 if you have the 'EVP_MD_do_all_sorted' function. */
 #define HAVE_EVP_MD_DO_ALL_SORTED 1
 
-/* Define to 1 if you have the `fchmod' function. */
+/* Define to 1 if you have the 'fchmod' function. */
 #define HAVE_FCHMOD 1
 
 /* Define to 1 if you have the <fcntl.h> header file. */
 #define HAVE_FCNTL_H 1
 
-/* Define to 1 if you have the `finite' function. */
+/* Define to 1 if you have the 'fdopendir' function. */
+#define HAVE_FDOPENDIR 1
+
+/* Define to 1 if you have the 'finite' function. */
 /* #undef HAVE_FINITE */
 
-/* Define to 1 if you have the `fnmatch' function. */
+/* Define to 1 if you have the 'fnmatch' function. */
 #define HAVE_FNMATCH 1
 
 /* Define to 1 if you have the <fnmatch.h> header file. */
 #define HAVE_FNMATCH_H 1
 
-/* Define to 1 if you have the `fork' function. */
+/* Define to 1 if you have the 'fork' function. */
 #define HAVE_FORK 1
 
-/* Define to 1 if you have the `fstat' function. */
+/* Define to 1 if you have the 'fstat' function. */
 #define HAVE_FSTAT 1
 
-/* Define to 1 if you have the `getbootfile' function. */
+/* Define to 1 if you have the 'fstatat' function. */
+#define HAVE_FSTATAT 1
+
+/* Define to 1 if we have realpath() that supports NULL as the 2nd argument */
+#define HAVE_FUNC_POSIX_REALPATH 1
+
+/* Define to 1 if you have the 'getbootfile' function. */
 #define HAVE_GETBOOTFILE 1
 
-/* Define to 1 if you have the `getclock' function. */
+/* Define to 1 if you have the 'getclock' function. */
 /* #undef HAVE_GETCLOCK */
 
-/* Define to 1 if you have the `getdtablesize' function. */
+/* Define to 1 if you have the 'getdtablesize' function. */
 #define HAVE_GETDTABLESIZE 1
 
-/* Define to 1 if you have the `getifaddrs' function. */
+/* Define to 1 if you have the 'getifaddrs' function. */
 #define HAVE_GETIFADDRS 1
 
-/* Define to 1 if you have the `getpassphrase' function. */
+/* Define to 1 if you have the 'getpassphrase' function. */
 /* #undef HAVE_GETPASSPHRASE */
 
-/* Define to 1 if you have the `getrusage' function. */
+/* Define to 1 if you have the 'getrusage' function. */
 #define HAVE_GETRUSAGE 1
 
-/* Define to 1 if you have the `getuid' function. */
+/* Define to 1 if you have the 'getuid' function. */
 #define HAVE_GETUID 1
 
 /* if you have GNU Pth */
@@ -470,52 +485,49 @@
 /* have iflist_sysctl? */
 #define HAVE_IFLIST_SYSCTL 1
 
-/* Define to 1 if you have the `if_nametoindex' function. */
+/* Define to 1 if you have the 'if_nametoindex' function. */
 #define HAVE_IF_NAMETOINDEX 1
 
 /* inline keyword or macro available */
 #define HAVE_INLINE 1
 
-/* Define to 1 if the system has the type `int16_t'. */
+/* Define to 1 if the system has the type 'int16_t'. */
 #define HAVE_INT16_T 1
 
-/* Define to 1 if the system has the type `int32'. */
+/* Define to 1 if the system has the type 'int32'. */
 /* #undef HAVE_INT32 */
 
-/* int32 type in DNS headers, not others. */
-/* #undef HAVE_INT32_ONLY_WITH_DNS */
-
-/* Define to 1 if the system has the type `int32_t'. */
+/* Define to 1 if the system has the type 'int32_t'. */
 #define HAVE_INT32_T 1
 
-/* Define to 1 if the system has the type `int8_t'. */
+/* Define to 1 if the system has the type 'int8_t'. */
 #define HAVE_INT8_T 1
 
-/* Define to 1 if the system has the type `intmax_t'. */
+/* Define to 1 if the system has the type 'intmax_t'. */
 /* #undef HAVE_INTMAX_T */
 
-/* Define to 1 if the system has the type `intptr_t'. */
+/* Define to 1 if the system has the type 'intptr_t'. */
 #define HAVE_INTPTR_T 1
 
 /* Define to 1 if you have the <inttypes.h> header file. */
 #define HAVE_INTTYPES_H 1
 
-/* Define to 1 if you have the `isfinite' function. */
+/* Define to 1 if you have the 'isfinite' function. */
 #define HAVE_ISFINITE 1
 
 /* Define to 1 if you have the <kvm.h> header file. */
 #define HAVE_KVM_H 1
 
-/* Define to 1 if you have the `kvm_open' function. */
+/* Define to 1 if you have the 'kvm_open' function. */
 /* #undef HAVE_KVM_OPEN */
 
-/* Define to 1 if you have the `gen' library (-lgen). */
+/* Define to 1 if you have the 'gen' library (-lgen). */
 /* #undef HAVE_LIBGEN */
 
 /* Define to 1 if you have the <libgen.h> header file. */
 #define HAVE_LIBGEN_H 1
 
-/* Define to 1 if you have the `intl' library (-lintl). */
+/* Define to 1 if you have the 'intl' library (-lintl). */
 /* #undef HAVE_LIBINTL */
 
 /* Define to 1 if you have the <libintl.h> header file. */
@@ -539,19 +551,19 @@
 /* if you have LinuxThreads */
 /* #undef HAVE_LINUX_THREADS */
 
-/* Define to 1 if you have the `localeconv' function. */
+/* Define to 1 if you have the 'localeconv' function. */
 /* #undef HAVE_LOCALECONV */
 
 /* Define to 1 if you have the <locale.h> header file. */
 /* #undef HAVE_LOCALE_H */
 
-/* Define to 1 if the system has the type `long double'. */
+/* Define to 1 if the system has the type 'long double'. */
 /* #undef HAVE_LONG_DOUBLE */
 
-/* Define to 1 if the system has the type `long long'. */
+/* Define to 1 if the system has the type 'long long'. */
 #define HAVE_LONG_LONG 1
 
-/* Define to 1 if the system has the type `long long int'. */
+/* Define to 1 if the system has the type 'long long int'. */
 /* #undef HAVE_LONG_LONG_INT */
 
 /* if you have SunOS LWP package */
@@ -575,34 +587,40 @@
 /* Define to 1 if you have the <math.h> header file. */
 #define HAVE_MATH_H 1
 
-/* Define to 1 if you have the `MD5Init' function. */
+/* Define to 1 if you have the 'MD5Init' function. */
 #define HAVE_MD5INIT 1
 
 /* Define to 1 if you have the <md5.h> header file. */
 #define HAVE_MD5_H 1
 
-/* Define to 1 if you have the `memlk' function. */
+/* Define to 1 if you have the 'memchr' function. */
+#define HAVE_MEMCHR 1
+
+/* Define to 1 if you have the 'memlk' function. */
 /* #undef HAVE_MEMLK */
 
 /* Define to 1 if you have the <memory.h> header file. */
 #define HAVE_MEMORY_H 1
 
-/* Define to 1 if you have the `mkstemp' function. */
+/* Define to 1 if you have the <minix/config.h> header file. */
+/* #undef HAVE_MINIX_CONFIG_H */
+
+/* Define to 1 if you have the 'mkstemp' function. */
 #define HAVE_MKSTEMP 1
 
-/* Define to 1 if you have the `mktime' function. */
+/* Define to 1 if you have the 'mktime' function. */
 #define HAVE_MKTIME 1
 
-/* Define to 1 if you have the `mlockall' function. */
+/* Define to 1 if you have the 'mlockall' function. */
 #define HAVE_MLOCKALL 1
 
-/* Define to 1 if you have the `mmap' function. */
+/* Define to 1 if you have the 'mmap' function. */
 #define HAVE_MMAP 1
 
-/* Define to 1 if you have the `nanosleep' function. */
+/* Define to 1 if you have the 'nanosleep' function. */
 #define HAVE_NANOSLEEP 1
 
-/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
+/* Define to 1 if you have the <ndir.h> header file, and it defines 'DIR'. */
 /* #undef HAVE_NDIR_H */
 
 /* Define to 1 if you have the <netdb.h> header file. */
@@ -641,7 +659,7 @@
 /* Define to 1 if you have the <net/route.h> header file. */
 #define HAVE_NET_ROUTE_H 1
 
-/* Define to 1 if you have the `nice' function. */
+/* Define to 1 if you have the 'nice' function. */
 #define HAVE_NICE 1
 
 /* Define to 1 if you have the <nlist.h> header file. */
@@ -665,16 +683,16 @@
 /* if you have NT Threads */
 /* #undef HAVE_NT_THREADS */
 
+/* Define to 1 if you have the 'openat' function. */
+#define HAVE_OPENAT 1
+
 /* Define to 1 if you have the <openssl/cmac.h> header file. */
 #define HAVE_OPENSSL_CMAC_H 1
 
-/* Define to 1 if you have the <openssl/hmac.h> header file. */
-#define HAVE_OPENSSL_HMAC_H 1
-
-/* Define to 1 if the system has the type `pid_t'. */
+/* Define to 1 if the system has the type 'pid_t'. */
 #define HAVE_PID_T 1
 
-/* Define to 1 if you have the `plock' function. */
+/* Define to 1 if you have the 'plock' function. */
 /* #undef HAVE_PLOCK */
 
 /* Define to 1 if you have the <poll.h> header file. */
@@ -692,52 +710,52 @@
 /* define to pthreads API spec revision */
 #define HAVE_PTHREADS 10
 
-/* Define to 1 if you have the `pthread_attr_getstacksize' function. */
+/* Define to 1 if you have the 'pthread_attr_getstacksize' function. */
 #define HAVE_PTHREAD_ATTR_GETSTACKSIZE 1
 
-/* Define to 1 if you have the `pthread_attr_setstacksize' function. */
+/* Define to 1 if you have the 'pthread_attr_setstacksize' function. */
 #define HAVE_PTHREAD_ATTR_SETSTACKSIZE 1
 
 /* define if you have pthread_detach function */
 #define HAVE_PTHREAD_DETACH 1
 
-/* Define to 1 if you have the `pthread_getconcurrency' function. */
+/* Define to 1 if you have the 'pthread_getconcurrency' function. */
 #define HAVE_PTHREAD_GETCONCURRENCY 1
 
 /* Define to 1 if you have the <pthread.h> header file. */
 #define HAVE_PTHREAD_H 1
 
-/* Define to 1 if you have the `pthread_kill' function. */
+/* Define to 1 if you have the 'pthread_kill' function. */
 #define HAVE_PTHREAD_KILL 1
 
-/* Define to 1 if you have the `pthread_kill_other_threads_np' function. */
+/* Define to 1 if you have the 'pthread_kill_other_threads_np' function. */
 /* #undef HAVE_PTHREAD_KILL_OTHER_THREADS_NP */
 
 /* define if you have pthread_rwlock_destroy function */
 #define HAVE_PTHREAD_RWLOCK_DESTROY 1
 
-/* Define to 1 if you have the `pthread_setconcurrency' function. */
+/* Define to 1 if you have the 'pthread_setconcurrency' function. */
 #define HAVE_PTHREAD_SETCONCURRENCY 1
 
-/* Define to 1 if you have the `pthread_yield' function. */
+/* Define to 1 if you have the 'pthread_yield' function. */
 #define HAVE_PTHREAD_YIELD 1
 
 /* Define to 1 if you have the <pth.h> header file. */
 /* #undef HAVE_PTH_H */
 
-/* Define to 1 if the system has the type `ptrdiff_t'. */
+/* Define to 1 if the system has the type 'ptrdiff_t'. */
 #define HAVE_PTRDIFF_T 1
 
-/* Define to 1 if you have the `pututline' function. */
+/* Define to 1 if you have the 'pututline' function. */
 /* #undef HAVE_PUTUTLINE */
 
-/* Define to 1 if you have the `pututxline' function. */
+/* Define to 1 if you have the 'pututxline' function. */
 #define HAVE_PUTUTXLINE 1
 
-/* Define to 1 if you have the `RAND_bytes' function. */
+/* Define to 1 if you have the 'RAND_bytes' function. */
 #define HAVE_RAND_BYTES 1
 
-/* Define to 1 if you have the `RAND_poll' function. */
+/* Define to 1 if you have the 'RAND_poll' function. */
 #define HAVE_RAND_POLL 1
 
 /* Define to 1 if you have the <readline.h> header file. */
@@ -752,22 +770,22 @@
 /* Define to 1 if you have the <readline/readline.h> header file. */
 #define HAVE_READLINE_READLINE_H 1
 
-/* Define to 1 if you have the `readlink' function. */
+/* Define to 1 if you have the 'readlink' function. */
 #define HAVE_READLINK 1
 
-/* Define to 1 if you have the `recvmsg' function. */
+/* Define to 1 if you have the 'recvmsg' function. */
 #define HAVE_RECVMSG 1
 
 /* Define to 1 if you have the <resolv.h> header file. */
 #define HAVE_RESOLV_H 1
 
-/* Define to 1 if you have the `res_init' function. */
+/* Define to 1 if you have the 'res_init' function. */
 #define HAVE_RES_INIT 1
 
 /* Do we have Linux routing socket? */
 /* #undef HAVE_RTNETLINK */
 
-/* Define to 1 if you have the `rtprio' function. */
+/* Define to 1 if you have the 'rtprio' function. */
 #define HAVE_RTPRIO 1
 
 /* Define to 1 if you have the <runetype.h> header file. */
@@ -779,70 +797,70 @@
 /* Define to 1 if you have the <sched.h> header file. */
 #define HAVE_SCHED_H 1
 
-/* Define to 1 if you have the `sched_setscheduler' function. */
+/* Define to 1 if you have the 'sched_setscheduler' function. */
 #define HAVE_SCHED_SETSCHEDULER 1
 
-/* Define to 1 if you have the `sched_yield' function. */
+/* Define to 1 if you have the 'sched_yield' function. */
 #define HAVE_SCHED_YIELD 1
 
 /* Define to 1 if you have the <semaphore.h> header file. */
 #define HAVE_SEMAPHORE_H 1
 
-/* Define to 1 if you have the `sem_timedwait' function. */
+/* Define to 1 if you have the 'sem_timedwait' function. */
 #define HAVE_SEM_TIMEDWAIT 1
 
 /* Define to 1 if you have the <setjmp.h> header file. */
 #define HAVE_SETJMP_H 1
 
-/* Define to 1 if you have the `setlinebuf' function. */
+/* Define to 1 if you have the 'setlinebuf' function. */
 #define HAVE_SETLINEBUF 1
 
-/* Define to 1 if you have the `setpgid' function. */
+/* Define to 1 if you have the 'setpgid' function. */
 #define HAVE_SETPGID 1
 
 /* define if setpgrp takes 0 arguments */
 /* #undef HAVE_SETPGRP_0 */
 
-/* Define to 1 if you have the `setpriority' function. */
+/* Define to 1 if you have the 'setpriority' function. */
 #define HAVE_SETPRIORITY 1
 
-/* Define to 1 if you have the `setrlimit' function. */
+/* Define to 1 if you have the 'setrlimit' function. */
 #define HAVE_SETRLIMIT 1
 
-/* Define to 1 if you have the `setsid' function. */
+/* Define to 1 if you have the 'setsid' function. */
 #define HAVE_SETSID 1
 
-/* Define to 1 if you have the `settimeofday' function. */
+/* Define to 1 if you have the 'settimeofday' function. */
 #define HAVE_SETTIMEOFDAY 1
 
-/* Define to 1 if you have the `setvbuf' function. */
+/* Define to 1 if you have the 'setvbuf' function. */
 #define HAVE_SETVBUF 1
 
 /* Define to 1 if you have the <sgtty.h> header file. */
 /* #undef HAVE_SGTTY_H */
 
-/* Define to 1 if you have the `sigaction' function. */
+/* Define to 1 if you have the 'sigaction' function. */
 #define HAVE_SIGACTION 1
 
 /* Can we use SIGIO for tcp and udp IO? */
 /* #undef HAVE_SIGNALED_IO */
 
-/* Define to 1 if you have the `sigset' function. */
+/* Define to 1 if you have the 'sigset' function. */
 #define HAVE_SIGSET 1
 
-/* Define to 1 if you have the `sigvec' function. */
+/* Define to 1 if you have the 'sigvec' function. */
 #define HAVE_SIGVEC 1
 
 /* sigwait() available? */
 #define HAVE_SIGWAIT 1
 
-/* Define to 1 if the system has the type `size_t'. */
+/* Define to 1 if the system has the type 'size_t'. */
 #define HAVE_SIZE_T 1
 
 /* Define if C99-compliant `snprintf' is available. */
 #define HAVE_SNPRINTF 1
 
-/* Define to 1 if you have the `socketpair' function. */
+/* Define to 1 if you have the 'socketpair' function. */
 #define HAVE_SOCKETPAIR 1
 
 /* Are Solaris privileges available? */
@@ -863,22 +881,25 @@
 /* Define to 1 if you have the <stdint.h> header file. */
 #define HAVE_STDINT_H 1
 
+/* Define to 1 if you have the <stdio.h> header file. */
+#define HAVE_STDIO_H 1
+
 /* Define to 1 if you have the <stdlib.h> header file. */
 #define HAVE_STDLIB_H 1
 
-/* Define to 1 if you have the `stime' function. */
+/* Define to 1 if you have the 'stime' function. */
 /* #undef HAVE_STIME */
 
-/* Define to 1 if you have the `strchr' function. */
+/* Define to 1 if you have the 'strchr' function. */
 #define HAVE_STRCHR 1
 
-/* Define to 1 if you have the `strdup' function. */
+/* Define to 1 if you have the 'strdup' function. */
 #define HAVE_STRDUP 1
 
-/* Define to 1 if you have the `strerror' function. */
+/* Define to 1 if you have the 'strerror' function. */
 #define HAVE_STRERROR 1
 
-/* Define to 1 if you have the `strerror_r' function. */
+/* Define if you have 'strerror_r'. */
 #define HAVE_STRERROR_R 1
 
 /* Define to 1 if you have the <strings.h> header file. */
@@ -887,34 +908,37 @@
 /* Define to 1 if you have the <string.h> header file. */
 #define HAVE_STRING_H 1
 
-/* Define to 1 if you have the `strlcat' function. */
+/* Define to 1 if you have the 'strlcat' function. */
 #define HAVE_STRLCAT 1
 
-/* Define to 1 if you have the `strlcpy' function. */
+/* Define to 1 if you have the 'strlcpy' function. */
 #define HAVE_STRLCPY 1
 
+/* Define to 1 if you have the 'strnlen' function. */
+#define HAVE_STRNLEN 1
+
 /* Define to 1 if you have the <stropts.h> header file. */
 /* #undef HAVE_STROPTS_H */
 
-/* Define to 1 if you have the `strrchr' function. */
+/* Define to 1 if you have the 'strrchr' function. */
 #define HAVE_STRRCHR 1
 
-/* Define to 1 if you have the `strsignal' function. */
+/* Define to 1 if you have the 'strsignal' function. */
 #define HAVE_STRSIGNAL 1
 
-/* Define to 1 if you have the `strtoll' function. */
+/* Define to 1 if you have the 'strtoll' function. */
 #define HAVE_STRTOLL 1
 
-/* Define to 1 if `decimal_point' is a member of `struct lconv'. */
+/* Define to 1 if 'decimal_point' is a member of 'struct lconv'. */
 /* #undef HAVE_STRUCT_LCONV_DECIMAL_POINT */
 
-/* Define to 1 if `thousands_sep' is a member of `struct lconv'. */
+/* Define to 1 if 'thousands_sep' is a member of 'struct lconv'. */
 /* #undef HAVE_STRUCT_LCONV_THOUSANDS_SEP */
 
 /* Do we have struct ntptimeval? */
 #define HAVE_STRUCT_NTPTIMEVAL 1
 
-/* Define to 1 if `time.tv_nsec' is a member of `struct ntptimeval'. */
+/* Define to 1 if 'time.tv_nsec' is a member of 'struct ntptimeval'. */
 #define HAVE_STRUCT_NTPTIMEVAL_TIME_TV_NSEC 1
 
 /* Does a system header define struct ppsclockev? */
@@ -935,13 +959,13 @@
 /* Define to 1 if you have the <synch.h> header file. */
 /* #undef HAVE_SYNCH_H */
 
-/* Define to 1 if you have the `sysconf' function. */
+/* Define to 1 if you have the 'sysconf' function. */
 #define HAVE_SYSCONF 1
 
 /* Define to 1 if you have the <sysexits.h> header file. */
 #define HAVE_SYSEXITS_H 1
 
-/* */
+/* syslog.h provides facilitynames */
 #define HAVE_SYSLOG_FACILITYNAMES 1
 
 /* Define to 1 if you have the <sys/audioio.h> header file. */
@@ -953,7 +977,7 @@
 /* Define to 1 if you have the <sys/clockctl.h> header file. */
 /* #undef HAVE_SYS_CLOCKCTL_H */
 
-/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
+/* Define to 1 if you have the <sys/dir.h> header file, and it defines 'DIR'.
    */
 /* #undef HAVE_SYS_DIR_H */
 
@@ -984,7 +1008,7 @@
 /* Define to 1 if you have the <sys/modem.h> header file. */
 /* #undef HAVE_SYS_MODEM_H */
 
-/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
+/* Define to 1 if you have the <sys/ndir.h> header file, and it defines 'DIR'.
    */
 /* #undef HAVE_SYS_NDIR_H */
 
@@ -1006,6 +1030,9 @@
 /* Define to 1 if you have the <sys/prctl.h> header file. */
 /* #undef HAVE_SYS_PRCTL_H */
 
+/* Define to 1 if you have the <sys/procctl.h> header file. */
+#define HAVE_SYS_PROCCTL_H 1
+
 /* Define to 1 if you have the <sys/procset.h> header file. */
 /* #undef HAVE_SYS_PROCSET_H */
 
@@ -1087,7 +1114,7 @@
 /* Define to 1 if you have the <sys/wait.h> header file. */
 #define HAVE_SYS_WAIT_H 1
 
-/* Define to 1 if the system has the type `s_char'. */
+/* Define to 1 if the system has the type 's_char'. */
 /* #undef HAVE_S_CHAR */
 
 /* Define to 1 if you have the <termios.h> header file. */
@@ -1102,25 +1129,25 @@
 /* Define to 1 if you have the <thread.h> header file. */
 /* #undef HAVE_THREAD_H */
 
-/* Define to 1 if you have the `thr_getconcurrency' function. */
+/* Define to 1 if you have the 'thr_getconcurrency' function. */
 /* #undef HAVE_THR_GETCONCURRENCY */
 
-/* Define to 1 if you have the `thr_setconcurrency' function. */
+/* Define to 1 if you have the 'thr_setconcurrency' function. */
 /* #undef HAVE_THR_SETCONCURRENCY */
 
-/* Define to 1 if you have the `thr_yield' function. */
+/* Define to 1 if you have the 'thr_yield' function. */
 /* #undef HAVE_THR_YIELD */
 
 /* Obvious */
 #define HAVE_TICKADJ_IN_STRUCT_CLOCKINFO 1
 
-/* Define to 1 if you have the `timegm' function. */
+/* Define to 1 if you have the 'timegm' function. */
 #define HAVE_TIMEGM 1
 
 /* Define to 1 if you have the <timepps.h> header file. */
 /* #undef HAVE_TIMEPPS_H */
 
-/* Define to 1 if you have the `timer_create' function. */
+/* Define to 1 if you have the 'timer_create' function. */
 /* #undef HAVE_TIMER_CREATE */
 
 /* Define to 1 if you have the <timex.h> header file. */
@@ -1141,28 +1168,28 @@
 /* Are TrustedBSD MAC policy privileges available? */
 #define HAVE_TRUSTEDBSD_MAC 1
 
-/* Define to 1 if the system has the type `uint16_t'. */
+/* Define to 1 if the system has the type 'uint16_t'. */
 #define HAVE_UINT16_T 1
 
-/* Define to 1 if the system has the type `uint32_t'. */
+/* Define to 1 if the system has the type 'uint32_t'. */
 #define HAVE_UINT32_T 1
 
-/* Define to 1 if the system has the type `uint8_t'. */
+/* Define to 1 if the system has the type 'uint8_t'. */
 #define HAVE_UINT8_T 1
 
-/* Define to 1 if the system has the type `uintmax_t'. */
+/* Define to 1 if the system has the type 'uintmax_t'. */
 /* #undef HAVE_UINTMAX_T */
 
-/* Define to 1 if the system has the type `uintptr_t'. */
+/* Define to 1 if the system has the type 'uintptr_t'. */
 #define HAVE_UINTPTR_T 1
 
-/* Define to 1 if the system has the type `uint_t'. */
+/* Define to 1 if the system has the type 'uint_t'. */
 /* #undef HAVE_UINT_T */
 
-/* Define to 1 if you have the `umask' function. */
+/* Define to 1 if you have the 'umask' function. */
 #define HAVE_UMASK 1
 
-/* Define to 1 if you have the `uname' function. */
+/* Define to 1 if you have the 'uname' function. */
 #define HAVE_UNAME 1
 
 /* Define to 1 if you have the <unistd.h> header file. */
@@ -1171,13 +1198,13 @@
 /* deviant sigwait? */
 /* #undef HAVE_UNIXWARE_SIGWAIT */
 
-/* Define to 1 if the system has the type `unsigned long long int'. */
+/* Define to 1 if the system has the type 'unsigned long long int'. */
 #define HAVE_UNSIGNED_LONG_LONG_INT 1
 
-/* Define to 1 if you have the `updwtmp' function. */
+/* Define to 1 if you have the 'updwtmp' function. */
 /* #undef HAVE_UPDWTMP */
 
-/* Define to 1 if you have the `updwtmpx' function. */
+/* Define to 1 if you have the 'updwtmpx' function. */
 /* #undef HAVE_UPDWTMPX */
 
 /* Define to 1 if you have the <utime.h> header file. */
@@ -1189,52 +1216,52 @@
 /* Define to 1 if you have the <utmp.h> header file. */
 /* #undef HAVE_UTMP_H */
 
-/* Define to 1 if the system has the type `u_int32'. */
+/* Define to 1 if the system has the type 'u_int32'. */
 /* #undef HAVE_U_INT32 */
 
-/* u_int32 type in DNS headers, not others. */
-/* #undef HAVE_U_INT32_ONLY_WITH_DNS */
-
 /* Define to 1 if you have the <values.h> header file. */
 /* #undef HAVE_VALUES_H */
 
 /* Define to 1 if you have the <varargs.h> header file. */
 /* #undef HAVE_VARARGS_H */
 
-/* Define to 1 if you have the `vfork' function. */
+/* Define to 1 if you have the 'vfork' function. */
 #define HAVE_VFORK 1
 
 /* Define to 1 if you have the <vfork.h> header file. */
 /* #undef HAVE_VFORK_H */
 
-/* Define to 1 if you have the `vprintf' function. */
+/* Define to 1 if you have the 'vprintf' function. */
 #define HAVE_VPRINTF 1
 
 /* Define if C99-compliant `vsnprintf' is available. */
 #define HAVE_VSNPRINTF 1
 
+/* Define to 1 if you have the 'waitpid' function. */
+#define HAVE_WAITPID 1
+
 /* Define to 1 if you have the <wchar.h> header file. */
 #define HAVE_WCHAR_H 1
 
-/* Define to 1 if the system has the type `wchar_t'. */
+/* Define to 1 if the system has the type 'wchar_t'. */
 #define HAVE_WCHAR_T 1
 
-/* Define to 1 if the system has the type `wint_t'. */
+/* Define to 1 if the system has the type 'wint_t'. */
 #define HAVE_WINT_T 1
 
-/* Define to 1 if `fork' works. */
+/* Define to 1 if 'fork' works. */
 #define HAVE_WORKING_FORK 1
 
-/* Define to 1 if `vfork' works. */
+/* Define to 1 if 'vfork' works. */
 #define HAVE_WORKING_VFORK 1
 
 /* define if select implicitly yields */
 #define HAVE_YIELDING_SELECT 1
 
-/* Define to 1 if the system has the type `_Bool'. */
+/* Define to 1 if the system has the type '_Bool'. */
 #define HAVE__BOOL 1
 
-/* Define to 1 if you have the `_exit' function. */
+/* Define to 1 if you have the '_exit' function. */
 #define HAVE__EXIT 1
 
 /* Define to 1 if you have the </sys/sync/queue.h> header file. */
@@ -1243,7 +1270,7 @@
 /* Define to 1 if you have the </sys/sync/sema.h> header file. */
 /* #undef HAVE__SYS_SYNC_SEMA_H */
 
-/* Define to 1 if you have the `__adjtimex' function. */
+/* Define to 1 if you have the '__adjtimex' function. */
 /* #undef HAVE___ADJTIMEX */
 
 /* defined if C compiler supports __attribute__((...)) */
@@ -1259,10 +1286,10 @@
     
 
 
-/* Define to 1 if you have the `__ntp_gettime' function. */
+/* Define to 1 if you have the '__ntp_gettime' function. */
 /* #undef HAVE___NTP_GETTIME */
 
-/* Define to 1 if you have the `__res_init' function. */
+/* Define to 1 if you have the '__res_init' function. */
 /* #undef HAVE___RES_INIT */
 
 /* Does struct sockaddr_storage have __ss_family? */
@@ -1428,10 +1455,10 @@
 /* #undef NO_THREADS */
 
 /* Default location of crypto key info */
-#define NTP_KEYSDIR "/etc/ntp"
+#define NTP_KEYSDIR "/usr/local/etc"
 
 /* Path to sign daemon rendezvous socket */
-#define NTP_SIGND_PATH "/var/run/ntp_signd"
+/* #undef NTP_SIGND_PATH */
 
 /* Do we have ntp_{adj,get}time in libc? */
 #define NTP_SYSCALLS_LIBC 1
@@ -1442,8 +1469,8 @@
 /* Do we have support for SHMEM_STATUS? */
 #define ONCORE_SHMEM_STATUS 1
 
-/* Use OpenSSL? */
-/* #define OPENSSL */
+/* Suppress OpenSSL 3 deprecation warnings */
+#define OPENSSL_SUPPRESS_DEPRECATED 1
 
 /* Should we open the broadcast socket? */
 #define OPEN_BCAST_SOCKET 1
@@ -1461,28 +1488,28 @@
 #define PACKAGE "ntp"
 
 /* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "http://bugs.ntp.org./"
+#define PACKAGE_BUGREPORT "https://bugs.ntp.org/"
 
 /* Define to the full name of this package. */
 #define PACKAGE_NAME "ntp"
 
 /* Define to the full name and version of this package. */
-#define PACKAGE_STRING "ntp 4.2.8p17"
+#define PACKAGE_STRING "ntp 4.2.8p18"
 
 /* Define to the one symbol short name of this package. */
 #define PACKAGE_TARNAME "ntp"
 
 /* Define to the home page for this package. */
-#define PACKAGE_URL "http://www.ntp.org./"
+#define PACKAGE_URL "https://www.ntp.org/"
 
 /* Define to the version of this package. */
-#define PACKAGE_VERSION "4.2.8p17"
+#define PACKAGE_VERSION "4.2.8p18"
 
 /* data dir */
-#define PERLLIBDIR "/usr/share/ntp/lib"
+#define PERLLIBDIR "/usr/local/share/ntp/lib"
 
 /* define to a working POSIX compliant shell */
-#define POSIX_SHELL "/bin/sh"
+#define POSIX_SHELL "/bin/bash"
 
 /* PARSE kernel PLL PPS support */
 /* #undef PPS_SYNC */
@@ -1508,7 +1535,7 @@
 /* define if sched_yield yields the entire process */
 /* #undef REPLACE_BROKEN_YIELD */
 
-/* Define as the return type of signal handlers (`int' or `void'). */
+/* Define as the return type of signal handlers ('int' or 'void'). */
 #define RETSIGTYPE void
 
 /* saveconfig mechanism */
@@ -1519,12 +1546,12 @@
 
 /* The size of `char *', as computed by sizeof. */
 #ifdef __LP64__
-#define SIZEOF_CHARP 8
+#define SIZEOF_CHAR_P 8
 #else
-#define SIZEOF_CHARP 4
+#define SIZEOF_CHAR_P 4
 #endif
 
-/* The size of `int', as computed by sizeof. */
+/* The size of 'int', as computed by sizeof. */
 #define SIZEOF_INT 4
 
 /* The size of `long', as computed by sizeof. */
@@ -1534,16 +1561,16 @@
 #define SIZEOF_LONG 4
 #endif
 
-/* The size of `long long', as computed by sizeof. */
+/* The size of 'long long', as computed by sizeof. */
 #define SIZEOF_LONG_LONG 8
 
-/* The size of `pthread_t', as computed by sizeof. */
+/* The size of 'pthread_t', as computed by sizeof. */
 #define SIZEOF_PTHREAD_T 8
 
-/* The size of `short', as computed by sizeof. */
+/* The size of 'short', as computed by sizeof. */
 #define SIZEOF_SHORT 2
 
-/* The size of `signed char', as computed by sizeof. */
+/* The size of 'signed char', as computed by sizeof. */
 #define SIZEOF_SIGNED_CHAR 1
 
 /* The size of `time_t', as computed by sizeof. */
@@ -1567,7 +1594,9 @@
 	STACK_DIRECTION = 0 => direction of growth unknown */
 /* #undef STACK_DIRECTION */
 
-/* Define to 1 if you have the ANSI C header files. */
+/* Define to 1 if all of the C89 standard headers exist (not just the ones
+   required in a freestanding environment). This macro is provided for
+   backward compatibility; new code need not use it. */
 #define STDC_HEADERS 1
 
 /* Step, then slew the clock? */
@@ -1616,7 +1645,7 @@
 /* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
 #define TIME_WITH_SYS_TIME 1
 
-/* Define to 1 if your <sys/time.h> declares `struct tm'. */
+/* Define to 1 if your <sys/time.h> declares 'struct tm'. */
 /* #undef TM_IN_SYS_TIME */
 
 /* Provide a typedef for uintptr_t? */
@@ -1635,11 +1664,103 @@ typedef unsigned int	uintptr_t;
 #define USE_FSETOWNCTTY 1
 
 /* Use OpenSSL's crypto random functions */
-/* #define USE_OPENSSL_CRYPTO_RAND 1 */
+#define USE_OPENSSL_CRYPTO_RAND 1
 
 /* OK to use snprintb()? */
 /* #undef USE_SNPRINTB */
 
+/* Enable extensions on AIX, Interix, z/OS.  */
+#ifndef _ALL_SOURCE
+# define _ALL_SOURCE 1
+#endif
+/* Enable general extensions on macOS.  */
+#ifndef _DARWIN_C_SOURCE
+# define _DARWIN_C_SOURCE 1
+#endif
+/* Enable general extensions on Solaris.  */
+#ifndef __EXTENSIONS__
+# define __EXTENSIONS__ 1
+#endif
+/* Enable GNU extensions on systems that have them.  */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+/* Enable X/Open compliant socket functions that do not require linking
+   with -lxnet on HP-UX 11.11.  */
+#ifndef _HPUX_ALT_XOPEN_SOCKET_API
+# define _HPUX_ALT_XOPEN_SOCKET_API 1
+#endif
+/* Identify the host operating system as Minix.
+   This macro does not affect the system headers' behavior.
+   A future release of Autoconf may stop defining this macro.  */
+#ifndef _MINIX
+/* # undef _MINIX */
+#endif
+/* Enable general extensions on NetBSD.
+   Enable NetBSD compatibility extensions on Minix.  */
+#ifndef _NETBSD_SOURCE
+# define _NETBSD_SOURCE 1
+#endif
+/* Enable OpenBSD compatibility extensions on NetBSD.
+   Oddly enough, this does nothing on OpenBSD.  */
+#ifndef _OPENBSD_SOURCE
+# define _OPENBSD_SOURCE 1
+#endif
+/* Define to 1 if needed for POSIX-compatible behavior.  */
+#ifndef _POSIX_SOURCE
+/* # undef _POSIX_SOURCE */
+#endif
+/* Define to 2 if needed for POSIX-compatible behavior.  */
+#ifndef _POSIX_1_SOURCE
+/* # undef _POSIX_1_SOURCE */
+#endif
+/* Enable POSIX-compatible threading on Solaris.  */
+#ifndef _POSIX_PTHREAD_SEMANTICS
+# define _POSIX_PTHREAD_SEMANTICS 1
+#endif
+/* Enable extensions specified by ISO/IEC TS 18661-5:2014.  */
+#ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
+# define __STDC_WANT_IEC_60559_ATTRIBS_EXT__ 1
+#endif
+/* Enable extensions specified by ISO/IEC TS 18661-1:2014.  */
+#ifndef __STDC_WANT_IEC_60559_BFP_EXT__
+# define __STDC_WANT_IEC_60559_BFP_EXT__ 1
+#endif
+/* Enable extensions specified by ISO/IEC TS 18661-2:2015.  */
+#ifndef __STDC_WANT_IEC_60559_DFP_EXT__
+# define __STDC_WANT_IEC_60559_DFP_EXT__ 1
+#endif
+/* Enable extensions specified by C23 Annex F.  */
+#ifndef __STDC_WANT_IEC_60559_EXT__
+# define __STDC_WANT_IEC_60559_EXT__ 1
+#endif
+/* Enable extensions specified by ISO/IEC TS 18661-4:2015.  */
+#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__
+# define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1
+#endif
+/* Enable extensions specified by C23 Annex H and ISO/IEC TS 18661-3:2015.  */
+#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__
+# define __STDC_WANT_IEC_60559_TYPES_EXT__ 1
+#endif
+/* Enable extensions specified by ISO/IEC TR 24731-2:2010.  */
+#ifndef __STDC_WANT_LIB_EXT2__
+# define __STDC_WANT_LIB_EXT2__ 1
+#endif
+/* Enable extensions specified by ISO/IEC 24747:2009.  */
+#ifndef __STDC_WANT_MATH_SPEC_FUNCS__
+# define __STDC_WANT_MATH_SPEC_FUNCS__ 1
+#endif
+/* Enable extensions on HP NonStop.  */
+#ifndef _TANDEM_SOURCE
+# define _TANDEM_SOURCE 1
+#endif
+/* Enable X/Open extensions.  Define to 500 only if necessary
+   to make mbstate_t available.  */
+#ifndef _XOPEN_SOURCE
+/* # undef _XOPEN_SOURCE */
+#endif
+
+
 /* Can we use SIGPOLL for tty IO? */
 /* #undef USE_TTY_SIGPOLL */
 
@@ -1647,7 +1768,7 @@ typedef unsigned int	uintptr_t;
 /* #undef USE_UDP_SIGPOLL */
 
 /* Version number of package */
-#define VERSION "4.2.8p17"
+#define VERSION "4.2.8p18"
 
 /* vsnprintf expands "%m" to strerror(errno) */
 #define VSNPRINTF_PERCENT_M 1
@@ -1665,16 +1786,6 @@ typedef unsigned int	uintptr_t;
 /* routine worker child proc uses to exit. */
 #define WORKER_CHILD_EXIT exit
 
-/* Define to 1 if on MINIX. */
-/* #undef _MINIX */
-
-/* Define to 2 if the system does not provide POSIX.1 features except with
-   this defined. */
-/* #undef _POSIX_1_SOURCE */
-
-/* Define to 1 if you need to in order for `stat' and other things to work. */
-/* #undef _POSIX_SOURCE */
-
 /* enable thread safety */
 #define _REENTRANT 1
 
@@ -1687,49 +1798,25 @@ typedef unsigned int	uintptr_t;
 /* enable thread safety */
 #define _THREAD_SAFE 1
 
-/* Define to 500 only on HP-UX. */
-/* #undef _XOPEN_SOURCE */
-
 /* Are we _special_? */
 /* #undef __APPLE_USE_RFC_3542 */
 
-/* Define to 1 if type `char' is unsigned and you are not using gcc.  */
+/* Define to 1 if type 'char' is unsigned and your compiler does not
+   predefine this macro.  */
 #ifndef __CHAR_UNSIGNED__
 /* # undef __CHAR_UNSIGNED__ */
 #endif
 
-/* Enable extensions on AIX 3, Interix.  */
-#ifndef _ALL_SOURCE
-# define _ALL_SOURCE 1
-#endif
-/* Enable GNU extensions on systems that have them.  */
-#ifndef _GNU_SOURCE
-# define _GNU_SOURCE 1
-#endif
-/* Enable threading extensions on Solaris.  */
-#ifndef _POSIX_PTHREAD_SEMANTICS
-# define _POSIX_PTHREAD_SEMANTICS 1
-#endif
-/* Enable extensions on HP NonStop.  */
-#ifndef _TANDEM_SOURCE
-# define _TANDEM_SOURCE 1
-#endif
-/* Enable general extensions on Solaris.  */
-#ifndef __EXTENSIONS__
-# define __EXTENSIONS__ 1
-#endif
-
-
 /* deviant */
 /* #undef adjtimex */
 
-/* Define to empty if `const' does not conform to ANSI C. */
+/* Define to empty if 'const' does not conform to ANSI C. */
 /* #undef const */
 
-/* Define to `int' if <sys/types.h> doesn't define. */
+/* Define as 'int' if <sys/types.h> doesn't define. */
 /* #undef gid_t */
 
-/* Define to `__inline__' or `__inline' if that's what the C compiler
+/* Define to '__inline__' or '__inline' if that's what the C compiler
    calls it, or to nothing if 'inline' is not supported under any name.  */
 #ifndef __cplusplus
 /* #undef inline */
@@ -1745,29 +1832,21 @@ typedef unsigned int	uintptr_t;
 /* deviant */
 /* #undef ntp_gettime */
 
-/* Define to `long int' if <sys/types.h> does not define. */
+/* Define to 'long int' if <sys/types.h> does not define. */
 /* #undef off_t */
 
-/* Define to `int' if <sys/types.h> does not define. */
+/* Define as a signed integer type capable of holding a process identifier. */
 /* #undef pid_t */
 
-/* Define to `unsigned int' if <sys/types.h> does not define. */
+/* Define as 'unsigned int' if <stddef.h> doesn't define. */
 /* #undef size_t */
 
-	
-	    #if !defined(_KERNEL) && !defined(PARSESTREAM)
-	    /*
-	     * stdio.h must be included after _GNU_SOURCE is defined
-	     * but before #define snprintf rpl_snprintf
-	     */
-	    # include <stdio.h>	
-	    #endif
-	
+	#include "c99_snprintf.h"
 
 /* Define to rpl_snprintf if the replacement function should be used. */
 /* #undef snprintf */
 
-/* Define to `int' if <sys/types.h> doesn't define. */
+/* Define as 'int' if <sys/types.h> doesn't define. */
 /* #undef uid_t */
 
 /* Define to the widest unsigned integer type if <stdint.h> and <inttypes.h>
@@ -1778,11 +1857,11 @@ typedef unsigned int	uintptr_t;
    pointer, if such a type exists, and if the system does not define it. */
 /* #undef uintptr_t */
 
-/* Define as `fork' if `vfork' does not work. */
+/* Define as 'fork' if 'vfork' does not work. */
 /* #undef vfork */
 
-/* Define to empty if the keyword `volatile' does not work. Warning: valid
-   code using `volatile' can become incorrect without. Disable with care. */
+/* Define to empty if the keyword 'volatile' does not work. Warning: valid
+   code using 'volatile' can become incorrect without. Disable with care. */
 /* #undef volatile */
 
 /* Define to rpl_vsnprintf if the replacement function should be used. */
@@ -1820,9 +1899,21 @@ typedef union mpinfou {
 	#  endif
 	# endif
 	#endif	/* !defined(_KERNEL) && !defined(PARSESTREAM) */
-	
+
+	/*
+	 * Macro to use in otherwise-empty source files to comply with ANSI C
+	 * requirement that each translation unit (source file) contain some
+	 * declaration.  This has commonly been done by declaring an unused
+	 * global variable of type int or char.  An extern reference to abs()
+	 * serves the same purpose without bloat.  We once used exit() but
+	 * that can produce warnings on systems that declare exit() noreturn.
+	 */
+	#define NONEMPTY_TRANSLATION_UNIT	extern int abs(int);
+
 /*
  * FreeBSD specific: Explicitly specify date/time for reproducible build.
  */
 #define	MKREPRO_DATE "Aug 19 2018"
 #define	MKREPRO_TIME "01:24:29"
+
+#define HAVE_CLOSEFROM	1
diff --git a/usr.sbin/ntp/libntp/Makefile b/usr.sbin/ntp/libntp/Makefile
index 7cf4a33b8c6d..a833b5c41105 100644
--- a/usr.sbin/ntp/libntp/Makefile
+++ b/usr.sbin/ntp/libntp/Makefile
@@ -24,7 +24,7 @@ NTP_SRCS= systime.c	a_md5encrypt.c	adjtime.c	atoint.c \
 	ntp_crypto_rnd.c		ntp_intres.c	ntp_libopts.c \
 	ntp_lineedit.c	ntp_random.c	ntp_rfc2553.c	ntp_realpath.c \
 	ntp_worker.c \
-	numtoa.c	numtohost.c	octtoint.c	prettydate.c \
+	numtoa.c	octtoint.c	prettydate.c \
 	recvbuff.c	refidsmear.c	\
 	refnumtoa.c	snprintf.c	socket.c \
 	socktoa.c	socktohost.c	ssl_init.c	statestr.c \
diff --git a/usr.sbin/ntp/ntpd/Makefile b/usr.sbin/ntp/ntpd/Makefile
index d7b5010227f5..681377b702e8 100644
--- a/usr.sbin/ntp/ntpd/Makefile
+++ b/usr.sbin/ntp/ntpd/Makefile
@@ -45,12 +45,10 @@ CFLAGS+= -I${SRCTOP}/contrib/ntp/ntpd \
 	-I${.CURDIR:H} \
 	-I${.CURDIR}
 
-LIBADD=	parse ntp m opts pthread
+LIBADD=	parse ntp m md opts pthread
 
 .if ${MK_OPENSSL} != "no"
 LIBADD+=	crypto
-.else
-LIBADD+=	md
 .endif
 
 CLEANFILES+= .version version.c
diff --git a/usr.sbin/ntp/ntpd/leap-seconds b/usr.sbin/ntp/ntpd/leap-seconds
index 3fe9a1210e3c..c5a95aa51799 100644
--- a/usr.sbin/ntp/ntpd/leap-seconds
+++ b/usr.sbin/ntp/ntpd/leap-seconds
@@ -204,10 +204,10 @@
 #	current -- the update time stamp, the data and the name of the file
 #	will not change.
 #
-#	Updated through IERS Bulletin C66
-#	File expires on:  28 June 2024
+#	Updated through IERS Bulletin C67
+#	File expires on:  28 December 2024
 #
-#@	3928521600
+#@	3944332800
 #
 2272060800	10	# 1 Jan 1972
 2287785600	11	# 1 Jul 1972
@@ -252,4 +252,4 @@
 #	the hash line is also ignored in the
 #	computation.
 #
-#h 	16edd0f0 3666784f 37db6bdd e74ced87 59af48f1
+#h 	199a9d45 3f630d2f e47cb9cc c2f0fa47 96932227
diff --git a/usr.sbin/ntp/ntpdate/Makefile b/usr.sbin/ntp/ntpdate/Makefile
index 03afbb5d708b..1c082ff6be76 100644
--- a/usr.sbin/ntp/ntpdate/Makefile
+++ b/usr.sbin/ntp/ntpdate/Makefile
@@ -13,12 +13,10 @@ CFLAGS+= -I${SRCTOP}/contrib/ntp/include \
 	-I${SRCTOP}/contrib/ntp/libntp/lib/isc/pthreads/include \
 	-I${.CURDIR:H}
 
-LIBADD=	ntp m pthread
+LIBADD=	ntp m md pthread
 
 .if ${MK_OPENSSL} != "no"
 LIBADD+=	crypto
-.else
-LIBADD+=	md
 .endif
 
 CLEANFILES+= .version version.c
diff --git a/usr.sbin/ntp/ntpdc/Makefile b/usr.sbin/ntp/ntpdc/Makefile
index 8502b7c1b503..d085dad9e7c5 100644
--- a/usr.sbin/ntp/ntpdc/Makefile
+++ b/usr.sbin/ntp/ntpdc/Makefile
@@ -16,12 +16,10 @@ CFLAGS+= -I${SRCTOP}/contrib/ntp/include \
 	-I${.CURDIR}/lib/libc/${MACHINE_ARCH} \
 	-I${.CURDIR:H} -I${.CURDIR}
 
-LIBADD=	edit ntp m opts pthread
+LIBADD=	edit ntp m md opts pthread
 
 .if ${MK_OPENSSL} != "no"
 LIBADD+=	crypto
-.else
-LIBADD+=	md
 .endif
 
 CLEANFILES+= .version version.c
diff --git a/usr.sbin/ntp/ntpq/Makefile b/usr.sbin/ntp/ntpq/Makefile
index be1e9c9034ff..a351350bbe4c 100644
--- a/usr.sbin/ntp/ntpq/Makefile
+++ b/usr.sbin/ntp/ntpq/Makefile
@@ -19,12 +19,10 @@ CFLAGS+= -I${SRCTOP}/contrib/ntp/include \
 	-I${SRCTOP}/contrib/ntp/sntp/libopts \
 	-I${.CURDIR:H}
 
-LIBADD+=	edit ntp opts m pthread
+LIBADD+=	edit ntp opts m md pthread
 
 .if ${MK_OPENSSL} != "no"
 LIBADD+=	crypto
-.else
-LIBADD+=	md
 .endif
 
 CLEANFILES+= .version version.c
diff --git a/usr.sbin/ntp/scripts/mkver b/usr.sbin/ntp/scripts/mkver
index 279468a1af1c..2336dd71bacb 100755
--- a/usr.sbin/ntp/scripts/mkver
+++ b/usr.sbin/ntp/scripts/mkver
@@ -7,7 +7,7 @@ PROG=${1-UNKNOWN}
 
 ConfStr="$PROG"
 
-ConfStr="$ConfStr 4.2.8p16"
+ConfStr="$ConfStr 4.2.8p18"
 
 case "$CSET" in
  '') ;;
diff --git a/usr.sbin/ntp/sntp/Makefile b/usr.sbin/ntp/sntp/Makefile
index ebbfb77b4fab..da2aea1929f4 100644
--- a/usr.sbin/ntp/sntp/Makefile
+++ b/usr.sbin/ntp/sntp/Makefile
@@ -19,12 +19,10 @@ CFLAGS+= -I${SRCTOP}/contrib/ntp/include \
 	-I${.CURDIR:H}/libntpevent \
 	-I${.CURDIR:H}
 
-LIBADD=	m opts ntp ntpevent pthread
+LIBADD=	m opts md ntp ntpevent pthread
 
 .if ${MK_OPENSSL} != "no"
 LIBADD+=	crypto
-.else
-LIBADD+=	md
 .endif
 
 .include <bsd.prog.mk>
diff --git a/usr.sbin/periodic/etc/security/100.chksetuid b/usr.sbin/periodic/etc/security/100.chksetuid
index 071d296cdaff..6ade53a180be 100755
--- a/usr.sbin/periodic/etc/security/100.chksetuid
+++ b/usr.sbin/periodic/etc/security/100.chksetuid
@@ -36,8 +36,6 @@ fi
 
 . /etc/periodic/security/security.functions
 
-security_daily_compat_var security_status_chksetuid_enable
-
 rc=0
 
 if check_yesno_period security_status_chksetuid_enable
diff --git a/usr.sbin/periodic/etc/security/110.neggrpperm b/usr.sbin/periodic/etc/security/110.neggrpperm
index 6def25fc6a0e..41f2713533b0 100755
--- a/usr.sbin/periodic/etc/security/110.neggrpperm
+++ b/usr.sbin/periodic/etc/security/110.neggrpperm
@@ -34,8 +34,6 @@ then
     source_periodic_confs
 fi
 
-security_daily_compat_var security_status_neggrpperm_enable
-
 rc=0
 
 if check_yesno_period security_status_neggrpperm_enable
diff --git a/usr.sbin/periodic/etc/security/200.chkmounts b/usr.sbin/periodic/etc/security/200.chkmounts
index c6405bb86467..055cf256018a 100755
--- a/usr.sbin/periodic/etc/security/200.chkmounts
+++ b/usr.sbin/periodic/etc/security/200.chkmounts
@@ -39,10 +39,6 @@ fi
 
 . /etc/periodic/security/security.functions
 
-security_daily_compat_var security_status_chkmounts_enable
-security_daily_compat_var security_status_chkmounts_ignore
-security_daily_compat_var security_status_noamd
-
 ignore="${security_status_chkmounts_ignore}"
 rc=0
 
diff --git a/usr.sbin/periodic/etc/security/300.chkuid0 b/usr.sbin/periodic/etc/security/300.chkuid0
index 121734357d06..c73980300d70 100755
--- a/usr.sbin/periodic/etc/security/300.chkuid0
+++ b/usr.sbin/periodic/etc/security/300.chkuid0
@@ -35,8 +35,6 @@ then
     source_periodic_confs
 fi
 
-security_daily_compat_var security_status_chkuid0_enable
-
 rc=0
 
 if check_yesno_period security_status_chkuid0_enable
diff --git a/usr.sbin/periodic/etc/security/400.passwdless b/usr.sbin/periodic/etc/security/400.passwdless
index 10a80ce43370..3e30e5e9cf5f 100755
--- a/usr.sbin/periodic/etc/security/400.passwdless
+++ b/usr.sbin/periodic/etc/security/400.passwdless
@@ -34,8 +34,6 @@ then
     source_periodic_confs
 fi
 
-security_daily_compat_var security_status_passwdless_enable
-
 rc=0
 
 if check_yesno_period security_status_passwdless_enable
diff --git a/usr.sbin/periodic/etc/security/410.logincheck b/usr.sbin/periodic/etc/security/410.logincheck
index 7e1ac5ec1b67..a3f3f3f1a21a 100755
--- a/usr.sbin/periodic/etc/security/410.logincheck
+++ b/usr.sbin/periodic/etc/security/410.logincheck
@@ -34,8 +34,6 @@ then
     source_periodic_confs
 fi
 
-security_daily_compat_var security_status_logincheck_enable
-
 rc=0
 
 if check_yesno_period security_status_logincheck_enable
diff --git a/usr.sbin/periodic/etc/security/500.ipfwdenied b/usr.sbin/periodic/etc/security/500.ipfwdenied
index f2a435711805..3ee7b3aa5cdc 100755
--- a/usr.sbin/periodic/etc/security/500.ipfwdenied
+++ b/usr.sbin/periodic/etc/security/500.ipfwdenied
@@ -36,8 +36,6 @@ fi
 
 . /etc/periodic/security/security.functions
 
-security_daily_compat_var security_status_ipfwdenied_enable
-
 rc=0
 
 if check_yesno_period security_status_ipfwdenied_enable
diff --git a/usr.sbin/periodic/etc/security/510.ipfdenied b/usr.sbin/periodic/etc/security/510.ipfdenied
index 3350bfd40fcf..b9f468fb96e5 100755
--- a/usr.sbin/periodic/etc/security/510.ipfdenied
+++ b/usr.sbin/periodic/etc/security/510.ipfdenied
@@ -36,8 +36,6 @@ fi
 
 . /etc/periodic/security/security.functions
 
-security_daily_compat_var security_status_ipfdenied_enable
-
 rc=0
 
 if check_yesno_period security_status_ipfdenied_enable
diff --git a/usr.sbin/periodic/etc/security/520.pfdenied b/usr.sbin/periodic/etc/security/520.pfdenied
index 6af474712d6f..9852936257bc 100755
--- a/usr.sbin/periodic/etc/security/520.pfdenied
+++ b/usr.sbin/periodic/etc/security/520.pfdenied
@@ -36,8 +36,6 @@ fi
 
 . /etc/periodic/security/security.functions
 
-security_daily_compat_var security_status_pfdenied_enable
-
 rc=0
 
 if check_yesno_period security_status_pfdenied_enable
diff --git a/usr.sbin/periodic/etc/security/550.ipfwlimit b/usr.sbin/periodic/etc/security/550.ipfwlimit
index 7b6f915a1ac5..8382c12df22f 100755
--- a/usr.sbin/periodic/etc/security/550.ipfwlimit
+++ b/usr.sbin/periodic/etc/security/550.ipfwlimit
@@ -37,8 +37,6 @@ then
     source_periodic_confs
 fi
 
-security_daily_compat_var security_status_ipfwlimit_enable
-
 rc=0
 
 if check_yesno_period security_status_ipfwlimit_enable
diff --git a/usr.sbin/periodic/etc/security/610.ipf6denied b/usr.sbin/periodic/etc/security/610.ipf6denied
index a7902e504baa..e1db7611557b 100755
--- a/usr.sbin/periodic/etc/security/610.ipf6denied
+++ b/usr.sbin/periodic/etc/security/610.ipf6denied
@@ -36,8 +36,6 @@ fi
 
 . /etc/periodic/security/security.functions
 
-security_daily_compat_var security_status_ipf6denied_enable
-
 rc=0
 
 if check_yesno_period security_status_ipf6denied_enable
diff --git a/usr.sbin/periodic/etc/security/700.kernelmsg b/usr.sbin/periodic/etc/security/700.kernelmsg
index cd4391aad98d..016bfbef36d0 100755
--- a/usr.sbin/periodic/etc/security/700.kernelmsg
+++ b/usr.sbin/periodic/etc/security/700.kernelmsg
@@ -39,8 +39,6 @@ fi
 
 . /etc/periodic/security/security.functions
 
-security_daily_compat_var security_status_kernelmsg_enable
-
 rc=0
 
 if check_yesno_period security_status_kernelmsg_enable
diff --git a/usr.sbin/periodic/etc/security/800.loginfail b/usr.sbin/periodic/etc/security/800.loginfail
index c5a3a972aaa1..19bf9a4b3b91 100755
--- a/usr.sbin/periodic/etc/security/800.loginfail
+++ b/usr.sbin/periodic/etc/security/800.loginfail
@@ -37,9 +37,6 @@ then
     source_periodic_confs
 fi
 
-security_daily_compat_var security_status_logdir
-security_daily_compat_var security_status_loginfail_enable
-
 LOG="${security_status_logdir}"
 
 yesterday=`date -v-1d "+%b %e "`
diff --git a/usr.sbin/periodic/etc/security/900.tcpwrap b/usr.sbin/periodic/etc/security/900.tcpwrap
index 55fa58f4df39..bbbc04a03988 100755
--- a/usr.sbin/periodic/etc/security/900.tcpwrap
+++ b/usr.sbin/periodic/etc/security/900.tcpwrap
@@ -37,9 +37,6 @@ then
     source_periodic_confs
 fi
 
-security_daily_compat_var security_status_logdir
-security_daily_compat_var security_status_tcpwrap_enable
-
 LOG="${security_status_logdir}"
 
 yesterday=`date -v-1d "+%b %e "`
diff --git a/usr.sbin/periodic/etc/security/Makefile b/usr.sbin/periodic/etc/security/Makefile
index ddc51a672ae0..f70aa23a1445 100644
--- a/usr.sbin/periodic/etc/security/Makefile
+++ b/usr.sbin/periodic/etc/security/Makefile
@@ -24,7 +24,7 @@ DATAPACKAGE=	periodic
 CONFGROUPS+=		IPFILTER
 IPFILTER+=		510.ipfdenied
 IPFILTER+=		610.ipf6denied
-IPFILTERPACKAGE=	ipfilter
+IPFILTERPACKAGE=	ipf
 .endif
 
 .if ${MK_IPFW} != "no"
diff --git a/usr.sbin/periodic/etc/security/security.functions b/usr.sbin/periodic/etc/security/security.functions
index aa19a99ebf87..c3ff6eb69391 100644
--- a/usr.sbin/periodic/etc/security/security.functions
+++ b/usr.sbin/periodic/etc/security/security.functions
@@ -31,9 +31,6 @@ case "$0" in
 */security.functions) exit 0 ;;
 esac
 
-security_daily_compat_var security_status_logdir
-security_daily_compat_var security_status_diff_flags
-
 #
 # Show differences in the output of an audit command
 #
diff --git a/usr.sbin/periodic/periodic.conf b/usr.sbin/periodic/periodic.conf
index 608a199b3cc9..3bb34d827564 100644
--- a/usr.sbin/periodic/periodic.conf
+++ b/usr.sbin/periodic/periodic.conf
@@ -345,28 +345,6 @@ if [ -z "${source_periodic_confs_defined}" ]; then
 		fi
 	}
 
-	# Compatibility with old daily variable names.
-	# They can be removed in stable/11.
-	security_daily_compat_var() {
-		local var=$1 dailyvar value
-
-		dailyvar=daily_status_security${var#security_status}
-		periodvar=${var%enable}period
-		eval value=\"\$$dailyvar\"
-		[ -z "$value" ] && return
-		echo "Warning: Variable \$$dailyvar is deprecated," \
-		    "use \$$var instead." >&2
-		case "$value" in
-		[Yy][Ee][Ss])
-			eval $var=YES
-			eval $periodvar=daily
-			;;
-		*)
-			eval $var=\"$value\"
-			;;
-		esac
-	}
-
 	check_yesno_period() {
 		local var="$1" periodvar value period
 
diff --git a/usr.sbin/wpa/wpa_cli/wpa_cli.8 b/usr.sbin/wpa/wpa_cli/wpa_cli.8
index c484434f0b0c..4fdd892da193 100644
--- a/usr.sbin/wpa/wpa_cli/wpa_cli.8
+++ b/usr.sbin/wpa/wpa_cli/wpa_cli.8
@@ -1,3 +1,6 @@
+.\"-
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
 .\" Copyright (c) 2005 Sam Leffler <sam@errno.com>
 .\" All rights reserved.
 .\"
@@ -22,12 +25,12 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd January 24, 2017
+.Dd June 21, 2024
 .Dt WPA_CLI 8
 .Os
 .Sh NAME
 .Nm wpa_cli
-.Nd "text-based frontend program for interacting with wpa_supplicant"
+.Nd console utility for WiFi authentication with wpa_supplicant
 .Sh SYNOPSIS
 .Nm wpa_cli
 .Op Fl p Ar path_to_ctrl_sockets
@@ -118,7 +121,7 @@ The
 .Nm
 utility
 shows these requests with a
-.Dq Li CTRL-REQ- Ns Ao Ar type Ac Ns Li - Ns Ao Ar id Ac Ns : Ns Aq Ar text
+.Dq Li CTRL-REQ- Ns Ao Ar type Ac Ns Li - Ns Ao Ar id Ac : Ns Aq Ar text
 prefix, where
 .Aq Ar type
 is
